diff --git a/.gitmodules b/.gitmodules index 6a72d1d37..5857dce33 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,21 +1,12 @@ [submodule "packages/base/any/initrds/buildroot/builds/buildroot-mirror"] path = packages/base/any/initrds/buildroot/builds/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 = http://github.com/opennetworklinux/linux-3.9.6 [submodule "sm/infra"] path = sm/infra url = http://github.com/floodlight/infra [submodule "sm/bigcode"] path = sm/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 = 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 = http://github.com/opennetworklinux/build-artifacts diff --git a/builds/any/rootfs/stretch/common/all-base-packages.yml b/builds/any/rootfs/stretch/common/all-base-packages.yml index be961d7aa..7a3562510 100644 --- a/builds/any/rootfs/stretch/common/all-base-packages.yml +++ b/builds/any/rootfs/stretch/common/all-base-packages.yml @@ -89,4 +89,3 @@ - memtester - lsb-release - tknos-firmware -- mrvl-fw-image diff --git a/builds/any/rootfs/stretch/common/arm64-base-packages.yml b/builds/any/rootfs/stretch/common/arm64-base-packages.yml index 2ade6aee0..138809291 100644 --- a/builds/any/rootfs/stretch/common/arm64-base-packages.yml +++ b/builds/any/rootfs/stretch/common/arm64-base-packages.yml @@ -11,3 +11,4 @@ - dnsmasq - dnsutils - mft +- mrvl-fw-image diff --git a/builds/any/rootfs/stretch/common/arm64-onl-packages.yml b/builds/any/rootfs/stretch/common/arm64-onl-packages.yml index e58df638d..a0fb2d2c4 100644 --- a/builds/any/rootfs/stretch/common/arm64-onl-packages.yml +++ b/builds/any/rootfs/stretch/common/arm64-onl-packages.yml @@ -4,6 +4,3 @@ # ############################################################ - onl-loader-fit - - - diff --git a/packages/base/any/kernels/legacy/linux-3.8.13 b/packages/base/any/kernels/legacy/linux-3.8.13 deleted file mode 160000 index 9cabf0dd1..000000000 --- a/packages/base/any/kernels/legacy/linux-3.8.13 +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 9cabf0dd1e9fea8d68fc3091d7530db07effe599 diff --git a/packages/base/any/kernels/legacy/linux-3.9.6 b/packages/base/any/kernels/legacy/linux-3.9.6 deleted file mode 160000 index d0512f069..000000000 --- a/packages/base/any/kernels/legacy/linux-3.9.6 +++ /dev/null @@ -1 +0,0 @@ -Subproject commit d0512f06933736dd3c49c78e89d07fa254ffec36 diff --git a/packages/platforms-closed b/packages/platforms-closed deleted file mode 160000 index 52a63355e..000000000 --- a/packages/platforms-closed +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 52a63355e1a4da6326a3ee341e07604582516cd6 diff --git a/packages/platforms/celestica/Makefile b/packages/platforms/celestica/Makefile deleted file mode 100644 index 003238cf6..000000000 --- a/packages/platforms/celestica/Makefile +++ /dev/null @@ -1 +0,0 @@ -include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/celestica/vendor-config/Makefile b/packages/platforms/celestica/vendor-config/Makefile deleted file mode 100644 index 003238cf6..000000000 --- a/packages/platforms/celestica/vendor-config/Makefile +++ /dev/null @@ -1 +0,0 @@ -include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/celestica/vendor-config/PKG.yml b/packages/platforms/celestica/vendor-config/PKG.yml deleted file mode 100644 index 4dbad12be..000000000 --- a/packages/platforms/celestica/vendor-config/PKG.yml +++ /dev/null @@ -1 +0,0 @@ -!include $ONL_TEMPLATES/platform-config-vendor.yml VENDOR=celestica Vendor=Celestica diff --git a/packages/platforms/celestica/vendor-config/src/python/celestica/__init__.py b/packages/platforms/celestica/vendor-config/src/python/celestica/__init__.py deleted file mode 100644 index a0ae6df72..000000000 --- a/packages/platforms/celestica/vendor-config/src/python/celestica/__init__.py +++ /dev/null @@ -1,8 +0,0 @@ -#!/usr/bin/python - -from onl.platform.base import * - -class OnlPlatformCelestica(OnlPlatformBase): - MANUFACTURER='Celestica' - PRIVATE_ENTERPRISE_NUMBER=12290 - diff --git a/packages/platforms/celestica/x86-64/Makefile b/packages/platforms/celestica/x86-64/Makefile deleted file mode 100644 index 003238cf6..000000000 --- a/packages/platforms/celestica/x86-64/Makefile +++ /dev/null @@ -1 +0,0 @@ -include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/celestica/x86-64/modules/Makefile b/packages/platforms/celestica/x86-64/modules/Makefile deleted file mode 100644 index 003238cf6..000000000 --- a/packages/platforms/celestica/x86-64/modules/Makefile +++ /dev/null @@ -1 +0,0 @@ -include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/celestica/x86-64/modules/PKG.yml b/packages/platforms/celestica/x86-64/modules/PKG.yml deleted file mode 100644 index a337be1b3..000000000 --- a/packages/platforms/celestica/x86-64/modules/PKG.yml +++ /dev/null @@ -1 +0,0 @@ -!include $ONL_TEMPLATES/no-arch-vendor-modules.yml ARCH=amd64 VENDOR=celestica diff --git a/packages/platforms/celestica/x86-64/redstone-xp/.gitignore b/packages/platforms/celestica/x86-64/redstone-xp/.gitignore deleted file mode 100644 index 4d978b36a..000000000 --- a/packages/platforms/celestica/x86-64/redstone-xp/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -*x86*64*cel*redstone*xp*.mk -onlpdump.mk diff --git a/packages/platforms/celestica/x86-64/redstone-xp/Makefile b/packages/platforms/celestica/x86-64/redstone-xp/Makefile deleted file mode 100644 index 003238cf6..000000000 --- a/packages/platforms/celestica/x86-64/redstone-xp/Makefile +++ /dev/null @@ -1 +0,0 @@ -include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/celestica/x86-64/redstone-xp/modules/Makefile b/packages/platforms/celestica/x86-64/redstone-xp/modules/Makefile deleted file mode 100644 index 003238cf6..000000000 --- a/packages/platforms/celestica/x86-64/redstone-xp/modules/Makefile +++ /dev/null @@ -1 +0,0 @@ -include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/celestica/x86-64/redstone-xp/modules/PKG.yml b/packages/platforms/celestica/x86-64/redstone-xp/modules/PKG.yml deleted file mode 100644 index debdbdd4c..000000000 --- a/packages/platforms/celestica/x86-64/redstone-xp/modules/PKG.yml +++ /dev/null @@ -1 +0,0 @@ -!include $ONL_TEMPLATES/no-platform-modules.yml ARCH=amd64 VENDOR=celestica BASENAME=x86-64-cel-redstone-xp diff --git a/packages/platforms/celestica/x86-64/redstone-xp/onlp/Makefile b/packages/platforms/celestica/x86-64/redstone-xp/onlp/Makefile deleted file mode 100644 index 003238cf6..000000000 --- a/packages/platforms/celestica/x86-64/redstone-xp/onlp/Makefile +++ /dev/null @@ -1 +0,0 @@ -include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/celestica/x86-64/redstone-xp/onlp/PKG.yml b/packages/platforms/celestica/x86-64/redstone-xp/onlp/PKG.yml deleted file mode 100644 index 99f2f77ea..000000000 --- a/packages/platforms/celestica/x86-64/redstone-xp/onlp/PKG.yml +++ /dev/null @@ -1 +0,0 @@ -!include $ONL_TEMPLATES/onlp-platform-any.yml PLATFORM=x86-64-cel-redstone-xp ARCH=amd64 TOOLCHAIN=x86_64-linux-gnu diff --git a/packages/platforms/celestica/x86-64/redstone-xp/onlp/builds/Makefile b/packages/platforms/celestica/x86-64/redstone-xp/onlp/builds/Makefile deleted file mode 100644 index e7437cb23..000000000 --- a/packages/platforms/celestica/x86-64/redstone-xp/onlp/builds/Makefile +++ /dev/null @@ -1,2 +0,0 @@ -FILTER=src -include $(ONL)/make/subdirs.mk diff --git a/packages/platforms/celestica/x86-64/redstone-xp/onlp/builds/lib/Makefile b/packages/platforms/celestica/x86-64/redstone-xp/onlp/builds/lib/Makefile deleted file mode 100644 index 0db6847d0..000000000 --- a/packages/platforms/celestica/x86-64/redstone-xp/onlp/builds/lib/Makefile +++ /dev/null @@ -1,2 +0,0 @@ -PLATFORM := x86-64-cel-redstone-xp -include $(ONL)/packages/base/any/onlp/builds/platform/libonlp-platform.mk diff --git a/packages/platforms/celestica/x86-64/redstone-xp/onlp/builds/onlpdump/Makefile b/packages/platforms/celestica/x86-64/redstone-xp/onlp/builds/onlpdump/Makefile deleted file mode 100644 index cc89c612e..000000000 --- a/packages/platforms/celestica/x86-64/redstone-xp/onlp/builds/onlpdump/Makefile +++ /dev/null @@ -1,2 +0,0 @@ -PLATFORM := x86-64-cel-redstone-xp -include $(ONL)/packages/base/any/onlp/builds/platform/onlps.mk diff --git a/packages/platforms/celestica/x86-64/redstone-xp/onlp/builds/x86_64_cel_redstone_xp/.gitignore b/packages/platforms/celestica/x86-64/redstone-xp/onlp/builds/x86_64_cel_redstone_xp/.gitignore deleted file mode 100644 index c81d16be3..000000000 --- a/packages/platforms/celestica/x86-64/redstone-xp/onlp/builds/x86_64_cel_redstone_xp/.gitignore +++ /dev/null @@ -1 +0,0 @@ -*.mk diff --git a/packages/platforms/celestica/x86-64/redstone-xp/onlp/builds/x86_64_cel_redstone_xp/.module b/packages/platforms/celestica/x86-64/redstone-xp/onlp/builds/x86_64_cel_redstone_xp/.module deleted file mode 100644 index 2aa1d02a6..000000000 --- a/packages/platforms/celestica/x86-64/redstone-xp/onlp/builds/x86_64_cel_redstone_xp/.module +++ /dev/null @@ -1 +0,0 @@ -name: x86_64_cel_redstone_xp diff --git a/packages/platforms/celestica/x86-64/redstone-xp/onlp/builds/x86_64_cel_redstone_xp/Makefile b/packages/platforms/celestica/x86-64/redstone-xp/onlp/builds/x86_64_cel_redstone_xp/Makefile deleted file mode 100644 index 551d44b78..000000000 --- a/packages/platforms/celestica/x86-64/redstone-xp/onlp/builds/x86_64_cel_redstone_xp/Makefile +++ /dev/null @@ -1,9 +0,0 @@ -############################################################################### -# -# -# -############################################################################### -include $(ONL)/make/config.mk -MODULE := x86_64_cel_redstone_xp -AUTOMODULE := x86_64_cel_redstone_xp -include $(BUILDER)/definemodule.mk diff --git a/packages/platforms/celestica/x86-64/redstone-xp/onlp/builds/x86_64_cel_redstone_xp/module/auto/make.mk b/packages/platforms/celestica/x86-64/redstone-xp/onlp/builds/x86_64_cel_redstone_xp/module/auto/make.mk deleted file mode 100644 index 49c7a8e1c..000000000 --- a/packages/platforms/celestica/x86-64/redstone-xp/onlp/builds/x86_64_cel_redstone_xp/module/auto/make.mk +++ /dev/null @@ -1,9 +0,0 @@ -############################################################################### -# -# x86_64_cel_redstone_xp Autogeneration -# -############################################################################### -x86_64_cel_redstone_xp_AUTO_DEFS := module/auto/x86_64_cel_redstone_xp.yml -x86_64_cel_redstone_xp_AUTO_DIRS := module/inc/x86_64_cel_redstone_xp module/src -include $(BUILDER)/auto.mk - diff --git a/packages/platforms/celestica/x86-64/redstone-xp/onlp/builds/x86_64_cel_redstone_xp/module/auto/x86_64_cel_redstone_xp.yml b/packages/platforms/celestica/x86-64/redstone-xp/onlp/builds/x86_64_cel_redstone_xp/module/auto/x86_64_cel_redstone_xp.yml deleted file mode 100644 index 24157ac95..000000000 --- a/packages/platforms/celestica/x86-64/redstone-xp/onlp/builds/x86_64_cel_redstone_xp/module/auto/x86_64_cel_redstone_xp.yml +++ /dev/null @@ -1,287 +0,0 @@ -############################################################################### -# -# x86_64_cel_redstone_xp Autogeneration Definitions. -# -############################################################################### - -cdefs: &cdefs -- X86_64_CEL_REDSTONE_XP_CONFIG_INCLUDE_LOGGING: - doc: "Include or exclude logging." - default: 1 -- X86_64_CEL_REDSTONE_XP_CONFIG_LOG_OPTIONS_DEFAULT: - doc: "Default enabled log options." - default: AIM_LOG_OPTIONS_DEFAULT -- X86_64_CEL_REDSTONE_XP_CONFIG_LOG_BITS_DEFAULT: - doc: "Default enabled log bits." - default: AIM_LOG_BITS_DEFAULT -- X86_64_CEL_REDSTONE_XP_CONFIG_LOG_CUSTOM_BITS_DEFAULT: - doc: "Default enabled custom log bits." - default: 0 -- X86_64_CEL_REDSTONE_XP_CONFIG_PORTING_STDLIB: - doc: "Default all porting macros to use the C standard libraries." - default: 1 -- X86_64_CEL_REDSTONE_XP_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS: - doc: "Include standard library headers for stdlib porting macros." - default: X86_64_CEL_REDSTONE_XP_CONFIG_PORTING_STDLIB -- X86_64_CEL_REDSTONE_XP_CONFIG_INCLUDE_UCLI: - doc: "Include generic uCli support." - default: 0 - - -definitions: - cdefs: - X86_64_CEL_REDSTONE_XP_CONFIG_HEADER: - defs: *cdefs - basename: x86_64_cel_redstone_xp_config - - portingmacro: - X86_64_CEL_REDSTONE_XP: - macros: - - malloc - - free - - memset - - memcpy - - - vsnprintf - - snprintf - - strlen - - - enum: &enums - cpld1_reg: - members: - - VERSION: 0x100 - - SCRATCH: 0x101 - - RESET_CONTROL: 0x102 - - RESET_SOURCE: 0x103 - - BOARD_TYPE: 0x104 - - INT_PORT_STATUS: 0x110 - - INT0_SOURCE_STATUS: 0x111 - - INT0_SOURCE_INT: 0x112 - - INT0_SOURCE_MASK: 0x113 - - POWER_SUPPLY_STATUS: 0x120 - - POWER_GOOD_STATUS: 0x121 - - BPP_CONTROL: 0x122 - - WRITE_PROTECT_CONTROL: 0x123 - - MISC_STATUS_CONTROL: 0x124 - - INFO_RAM_ADDR_HIGH: 0x130 - - INFO_RAM_ADDR_LOW: 0x131 - - INFO_RAM_READ_DATA: 0x132 - - INFO_RAM_WRITE_DATA: 0x133 - - cpld2_reg: - members: - - VERSION: 0x200 - - SCRATCH: 0x201 - - I2C_PORT_ID: 0x210 - - I2C_OP_CODE: 0x211 - - I2C_DEV_ADDR: 0x212 - - I2C_CMD_BYTE0: 0x213 - - I2C_CMD_BYTE1: 0x214 - - I2C_CMD_BYTE2: 0x215 - - I2C_STATUS_RESET: 0x216 - - - I2C_WRITE_DATA_BYTE0: 0x220 - - I2C_WRITE_DATA_BYTE1: 0x221 - - I2C_WRITE_DATA_BYTE2: 0x222 - - I2C_WRITE_DATA_BYTE3: 0x223 - - I2C_WRITE_DATA_BYTE4: 0x224 - - I2C_WRITE_DATA_BYTE5: 0x225 - - I2C_WRITE_DATA_BYTE6: 0x226 - - I2C_WRITE_DATA_BYTE7: 0x227 - - - I2C_READ_DATA_BYTE0: 0x230 - - I2C_READ_DATA_BYTE1: 0x231 - - I2C_READ_DATA_BYTE2: 0x232 - - I2C_READ_DATA_BYTE3: 0x233 - - I2C_READ_DATA_BYTE4: 0x234 - - I2C_READ_DATA_BYTE5: 0x235 - - I2C_READ_DATA_BYTE6: 0x236 - - I2C_READ_DATA_BYTE7: 0x237 - - - SFP_1_8_RX_LOS: 0x240 - - SFP_9_16_RX_LOS: 0x241 - - SFP_17_18_RX_LOS: 0x242 - - - SFP_1_8_RX_LOS_INT: 0x243 - - SFP_9_16_RX_LOS_INT: 0x244 - - SFP_17_18_RX_LOS_INT: 0x245 - - - SFP_1_8_RX_LOS_MASK: 0x246 - - SFP_9_16_RX_LOS_MASK: 0x247 - - SFP_17_18_RX_LOS_MASK: 0x248 - - - SFP_1_8_TX_DISABLE: 0x250 - - SFP_9_16_TX_DISABLE: 0x251 - - SFP_17_18_TX_DISABLE: 0x252 - - - SFP_1_8_RS_CONTROL: 0x253 - - SFP_9_16_RS_CONTROL: 0x254 - - SFP_17_18_RS_CONTROL: 0x255 - - - SFP_1_8_TX_FAULT: 0x256 - - SFP_9_16_TX_FAULT: 0x257 - - SFP_17_18_TX_FAULT: 0x258 - - - SFP_1_8_ABS_STATUS: 0x259 - - SFP_9_16_ABS_STATUS: 0x25A - - SFP_17_18_ABS_STATUS: 0x25B - - cpld3_reg: - members: - - VERSION: 0x280 - - SCRATCH: 0x281 - - I2C_PORT_ID: 0x290 - - I2C_OP_CODE: 0x291 - - I2C_DEV_ADDR: 0x292 - - I2C_CMD_BYTE0: 0x293 - - I2C_CMD_BYTE1: 0x294 - - I2C_CMD_BYTE2: 0x295 - - I2C_STATUS_RESET: 0x296 - - - I2C_WRITE_DATA_BYTE0: 0x2A0 - - I2C_WRITE_DATA_BYTE1: 0x2A1 - - I2C_WRITE_DATA_BYTE2: 0x2A2 - - I2C_WRITE_DATA_BYTE3: 0x2A3 - - I2C_WRITE_DATA_BYTE4: 0x2A4 - - I2C_WRITE_DATA_BYTE5: 0x2A5 - - I2C_WRITE_DATA_BYTE6: 0x2A6 - - I2C_WRITE_DATA_BYTE7: 0x2A7 - - - I2C_READ_DATA_BYTE0: 0x2B0 - - I2C_READ_DATA_BYTE1: 0x2B1 - - I2C_READ_DATA_BYTE2: 0x2B2 - - I2C_READ_DATA_BYTE3: 0x2B3 - - I2C_READ_DATA_BYTE4: 0x2B4 - - I2C_READ_DATA_BYTE5: 0x2B5 - - I2C_READ_DATA_BYTE6: 0x2B6 - - I2C_READ_DATA_BYTE7: 0x2B7 - - - SFP_19_26_RX_LOS: 0x2C0 - - SFP_27_34_RX_LOS: 0x2C1 - - SFP_35_36_RX_LOS: 0x2C2 - - - SFP_19_26_RX_LOS_INT: 0x2C3 - - SFP_27_34_RX_LOS_INT: 0x2C4 - - SFP_35_36_RX_LOS_INT: 0x2C5 - - - SFP_19_26_RX_LOS_MASK: 0x2C6 - - SFP_27_34_RX_LOS_MASK: 0x2C7 - - SFP_35_36_RX_LOS_MASK: 0x2C8 - - - SFP_19_26_TX_DISABLE: 0x2D0 - - SFP_27_34_TX_DISABLE: 0x2D1 - - SFP_35_36_TX_DISABLE: 0x2D2 - - - SFP_19_26_RS_CONTROL: 0x2D3 - - SFP_27_34_RS_CONTROL: 0x2D4 - - SFP_35_36_RS_CONTROL: 0x2D5 - - - SFP_19_26_TX_FAULT: 0x2D6 - - SFP_27_34_TX_FAULT: 0x2D7 - - SFP_35_36_TX_FAULT: 0x2D8 - - - SFP_19_26_ABS_STATUS: 0x2D9 - - SFP_27_34_ABS_STATUS: 0x2DA - - SFP_35_36_ABS_STATUS: 0x2DB - - - cpld4_reg: - members: - - VERSION: 0x300 - - SCRATCH: 0x301 - - RESET_CONTROL: 0x302 - - LED_CONTROL: 0x303 - - MISC_STATUS_CONTROL: 0x304 - - INT_PORT_STATUS: 0x305 - - INT0_SOURCE_STATUS: 0x306 - - INT1_SOURCE_STATUS: 0x307 - - INT2_SOURCE_STATUS: 0x308 - - INT0_SOURCE_INT: 0x309 - - INT1_SOURCE_INT: 0x30A - - INT2_SOURCE_INT: 0x30B - - INT0_SOURCE_MASK: 0x30C - - INT1_SOURCE_MASK: 0x30D - - INT2_SOURCE_MASK: 0x30E - - I2C_PORT_ID: 0x310 - - I2C_OP_CODE: 0x311 - - I2C_DEV_ADDR: 0x312 - - I2C_COMMAND_BYTE0: 0x313 - - I2C_COMMAND_BYTE1: 0x314 - - I2C_COMMAND_BYTE2: 0x315 - - I2C_STATUS_RESET: 0x316 - - - I2C_WRITE_DATA_BYTE0: 0x320 - - I2C_WRITE_DATA_BYTE1: 0x321 - - I2C_WRITE_DATA_BYTE2: 0x322 - - I2C_WRITE_DATA_BYTE3: 0x323 - - I2C_WRITE_DATA_BYTE4: 0x324 - - I2C_WRITE_DATA_BYTE5: 0x325 - - I2C_WRITE_DATA_BYTE6: 0x326 - - I2C_WRITE_DATA_BYTE7: 0x327 - - - I2C_READ_DATA_BYTE0: 0x330 - - I2C_READ_DATA_BYTE1: 0x331 - - I2C_READ_DATA_BYTE2: 0x332 - - I2C_READ_DATA_BYTE3: 0x333 - - I2C_READ_DATA_BYTE4: 0x334 - - I2C_READ_DATA_BYTE5: 0x335 - - I2C_READ_DATA_BYTE6: 0x336 - - I2C_READ_DATA_BYTE7: 0x337 - - - QSFP_RESET_CONTROL: 0x360 - - QSFP_LPMOD_CONTROL: 0x361 - - QSFP_ABS_STATUS: 0x362 - - QSFP_INT_STATUS: 0x363 - - QSFP_I2C_READY: 0x364 - - cpld5_reg: - members: - - VERSION: 0x380 - - SCRATCH: 0x381 - - I2C_PORT_ID: 0x390 - - I2C_OP_CODE: 0x391 - - I2C_DEV_ADDR: 0x392 - - I2C_CMD_BYTE0: 0x393 - - I2C_CMD_BYTE1: 0x394 - - I2C_CMD_BYTE2: 0x395 - - I2C_STATUS_RESET: 0x396 - - - I2C_WRITE_DATA_BYTE0: 0x3A0 - - I2C_WRITE_DATA_BYTE1: 0x3A1 - - I2C_WRITE_DATA_BYTE2: 0x3A2 - - I2C_WRITE_DATA_BYTE3: 0x3A3 - - I2C_WRITE_DATA_BYTE4: 0x3A4 - - I2C_WRITE_DATA_BYTE5: 0x3A5 - - I2C_WRITE_DATA_BYTE6: 0x3A6 - - I2C_WRITE_DATA_BYTE7: 0x3A7 - - - I2C_READ_DATA_BYTE0: 0x3B0 - - I2C_READ_DATA_BYTE1: 0x3B1 - - I2C_READ_DATA_BYTE2: 0x3B2 - - I2C_READ_DATA_BYTE3: 0x3B3 - - I2C_READ_DATA_BYTE4: 0x3B4 - - I2C_READ_DATA_BYTE5: 0x3B5 - - I2C_READ_DATA_BYTE6: 0x3B6 - - I2C_READ_DATA_BYTE7: 0x3B7 - - - SFP_37_44_RX_LOS: 0x3C0 - - SFP_45_48_RX_LOS: 0x3C1 - - - SFP_37_44_RX_LOS_INT: 0x3C2 - - SFP_45_48_RX_LOS_INT: 0x3C3 - - - SFP_37_44_RX_LOS_MASK: 0x3C4 - - SFP_45_48_RX_LOS_MASK: 0x3C5 - - - SFP_37_44_TX_DISABLE: 0x3D0 - - SFP_45_48_TX_DISABLE: 0x3D1 - - - SFP_37_44_RS_CONTROL: 0x3D2 - - SFP_45_48_RS_CONTROL: 0x3D3 - - - SFP_37_44_TX_FAULT: 0x3D4 - - SFP_45_48_TX_FAULT: 0x3D5 - - - SFP_37_44_ABS_STATUS: 0x3D6 - - SFP_45_48_ABS_STATUS: 0x3D7 diff --git a/packages/platforms/celestica/x86-64/redstone-xp/onlp/builds/x86_64_cel_redstone_xp/module/inc/x86_64_cel_redstone_xp/x86_64_cel_redstone_xp.x b/packages/platforms/celestica/x86-64/redstone-xp/onlp/builds/x86_64_cel_redstone_xp/module/inc/x86_64_cel_redstone_xp/x86_64_cel_redstone_xp.x deleted file mode 100644 index db56c7660..000000000 --- a/packages/platforms/celestica/x86-64/redstone-xp/onlp/builds/x86_64_cel_redstone_xp/module/inc/x86_64_cel_redstone_xp/x86_64_cel_redstone_xp.x +++ /dev/null @@ -1,14 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#include - -/* <--auto.start.xmacro(ALL).define> */ -/* */ - -/* <--auto.start.xenum(ALL).define> */ -/* */ - - diff --git a/packages/platforms/celestica/x86-64/redstone-xp/onlp/builds/x86_64_cel_redstone_xp/module/inc/x86_64_cel_redstone_xp/x86_64_cel_redstone_xp_config.h b/packages/platforms/celestica/x86-64/redstone-xp/onlp/builds/x86_64_cel_redstone_xp/module/inc/x86_64_cel_redstone_xp/x86_64_cel_redstone_xp_config.h deleted file mode 100644 index 1648a12f1..000000000 --- a/packages/platforms/celestica/x86-64/redstone-xp/onlp/builds/x86_64_cel_redstone_xp/module/inc/x86_64_cel_redstone_xp/x86_64_cel_redstone_xp_config.h +++ /dev/null @@ -1,127 +0,0 @@ -/**************************************************************************//** - * - * @file - * @brief x86_64_cel_redstone_xp Configuration Header - * - * @addtogroup x86_64_cel_redstone_xp-config - * @{ - * - *****************************************************************************/ -#ifndef __X86_64_CEL_REDSTONE_XP_CONFIG_H__ -#define __X86_64_CEL_REDSTONE_XP_CONFIG_H__ - -#ifdef GLOBAL_INCLUDE_CUSTOM_CONFIG -#include -#endif -#ifdef X86_64_CEL_REDSTONE_XP_INCLUDE_CUSTOM_CONFIG -#include -#endif - -/* */ -#include -/** - * X86_64_CEL_REDSTONE_XP_CONFIG_INCLUDE_LOGGING - * - * Include or exclude logging. */ - - -#ifndef X86_64_CEL_REDSTONE_XP_CONFIG_INCLUDE_LOGGING -#define X86_64_CEL_REDSTONE_XP_CONFIG_INCLUDE_LOGGING 1 -#endif - -/** - * X86_64_CEL_REDSTONE_XP_CONFIG_LOG_OPTIONS_DEFAULT - * - * Default enabled log options. */ - - -#ifndef X86_64_CEL_REDSTONE_XP_CONFIG_LOG_OPTIONS_DEFAULT -#define X86_64_CEL_REDSTONE_XP_CONFIG_LOG_OPTIONS_DEFAULT AIM_LOG_OPTIONS_DEFAULT -#endif - -/** - * X86_64_CEL_REDSTONE_XP_CONFIG_LOG_BITS_DEFAULT - * - * Default enabled log bits. */ - - -#ifndef X86_64_CEL_REDSTONE_XP_CONFIG_LOG_BITS_DEFAULT -#define X86_64_CEL_REDSTONE_XP_CONFIG_LOG_BITS_DEFAULT AIM_LOG_BITS_DEFAULT -#endif - -/** - * X86_64_CEL_REDSTONE_XP_CONFIG_LOG_CUSTOM_BITS_DEFAULT - * - * Default enabled custom log bits. */ - - -#ifndef X86_64_CEL_REDSTONE_XP_CONFIG_LOG_CUSTOM_BITS_DEFAULT -#define X86_64_CEL_REDSTONE_XP_CONFIG_LOG_CUSTOM_BITS_DEFAULT 0 -#endif - -/** - * X86_64_CEL_REDSTONE_XP_CONFIG_PORTING_STDLIB - * - * Default all porting macros to use the C standard libraries. */ - - -#ifndef X86_64_CEL_REDSTONE_XP_CONFIG_PORTING_STDLIB -#define X86_64_CEL_REDSTONE_XP_CONFIG_PORTING_STDLIB 1 -#endif - -/** - * X86_64_CEL_REDSTONE_XP_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS - * - * Include standard library headers for stdlib porting macros. */ - - -#ifndef X86_64_CEL_REDSTONE_XP_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS -#define X86_64_CEL_REDSTONE_XP_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS X86_64_CEL_REDSTONE_XP_CONFIG_PORTING_STDLIB -#endif - -/** - * X86_64_CEL_REDSTONE_XP_CONFIG_INCLUDE_UCLI - * - * Include generic uCli support. */ - - -#ifndef X86_64_CEL_REDSTONE_XP_CONFIG_INCLUDE_UCLI -#define X86_64_CEL_REDSTONE_XP_CONFIG_INCLUDE_UCLI 0 -#endif - - - -/** - * All compile time options can be queried or displayed - */ - -/** Configuration settings structure. */ -typedef struct x86_64_cel_redstone_xp_config_settings_s { - /** name */ - const char* name; - /** value */ - const char* value; -} x86_64_cel_redstone_xp_config_settings_t; - -/** Configuration settings table. */ -/** x86_64_cel_redstone_xp_config_settings table. */ -extern x86_64_cel_redstone_xp_config_settings_t x86_64_cel_redstone_xp_config_settings[]; - -/** - * @brief Lookup a configuration setting. - * @param setting The name of the configuration option to lookup. - */ -const char* x86_64_cel_redstone_xp_config_lookup(const char* setting); - -/** - * @brief Show the compile-time configuration. - * @param pvs The output stream. - */ -int x86_64_cel_redstone_xp_config_show(struct aim_pvs_s* pvs); - -/* */ - -#include "x86_64_cel_redstone_xp_porting.h" - -#endif /* __X86_64_CEL_REDSTONE_XP_CONFIG_H__ */ -/* @} */ diff --git a/packages/platforms/celestica/x86-64/redstone-xp/onlp/builds/x86_64_cel_redstone_xp/module/inc/x86_64_cel_redstone_xp/x86_64_cel_redstone_xp_dox.h b/packages/platforms/celestica/x86-64/redstone-xp/onlp/builds/x86_64_cel_redstone_xp/module/inc/x86_64_cel_redstone_xp/x86_64_cel_redstone_xp_dox.h deleted file mode 100644 index 80e739cd9..000000000 --- a/packages/platforms/celestica/x86-64/redstone-xp/onlp/builds/x86_64_cel_redstone_xp/module/inc/x86_64_cel_redstone_xp/x86_64_cel_redstone_xp_dox.h +++ /dev/null @@ -1,26 +0,0 @@ -/**************************************************************************//** - * - * x86_64_cel_redstone_xp Doxygen Header - * - *****************************************************************************/ -#ifndef __X86_64_CEL_REDSTONE_XP_DOX_H__ -#define __X86_64_CEL_REDSTONE_XP_DOX_H__ - -/** - * @defgroup x86_64_cel_redstone_xp x86_64_cel_redstone_xp - x86_64_cel_redstone_xp Description - * - -The documentation overview for this module should go here. - - * - * @{ - * - * @defgroup x86_64_cel_redstone_xp-x86_64_cel_redstone_xp Public Interface - * @defgroup x86_64_cel_redstone_xp-config Compile Time Configuration - * @defgroup x86_64_cel_redstone_xp-porting Porting Macros - * - * @} - * - */ - -#endif /* __X86_64_CEL_REDSTONE_XP_DOX_H__ */ diff --git a/packages/platforms/celestica/x86-64/redstone-xp/onlp/builds/x86_64_cel_redstone_xp/module/inc/x86_64_cel_redstone_xp/x86_64_cel_redstone_xp_porting.h b/packages/platforms/celestica/x86-64/redstone-xp/onlp/builds/x86_64_cel_redstone_xp/module/inc/x86_64_cel_redstone_xp/x86_64_cel_redstone_xp_porting.h deleted file mode 100644 index 5cf829c79..000000000 --- a/packages/platforms/celestica/x86-64/redstone-xp/onlp/builds/x86_64_cel_redstone_xp/module/inc/x86_64_cel_redstone_xp/x86_64_cel_redstone_xp_porting.h +++ /dev/null @@ -1,97 +0,0 @@ -/**************************************************************************//** - * - * @file - * @brief x86_64_cel_redstone_xp Porting Macros. - * - * @addtogroup x86_64_cel_redstone_xp-porting - * @{ - * - *****************************************************************************/ -#ifndef __X86_64_CEL_REDSTONE_XP_PORTING_H__ -#define __X86_64_CEL_REDSTONE_XP_PORTING_H__ - - -/* */ -#if X86_64_CEL_REDSTONE_XP_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS == 1 -#include -#include -#include -#include -#include -#endif - -#ifndef X86_64_CEL_REDSTONE_XP_MALLOC - #if defined(GLOBAL_MALLOC) - #define X86_64_CEL_REDSTONE_XP_MALLOC GLOBAL_MALLOC - #elif X86_64_CEL_REDSTONE_XP_CONFIG_PORTING_STDLIB == 1 - #define X86_64_CEL_REDSTONE_XP_MALLOC malloc - #else - #error The macro X86_64_CEL_REDSTONE_XP_MALLOC is required but cannot be defined. - #endif -#endif - -#ifndef X86_64_CEL_REDSTONE_XP_FREE - #if defined(GLOBAL_FREE) - #define X86_64_CEL_REDSTONE_XP_FREE GLOBAL_FREE - #elif X86_64_CEL_REDSTONE_XP_CONFIG_PORTING_STDLIB == 1 - #define X86_64_CEL_REDSTONE_XP_FREE free - #else - #error The macro X86_64_CEL_REDSTONE_XP_FREE is required but cannot be defined. - #endif -#endif - -#ifndef X86_64_CEL_REDSTONE_XP_MEMSET - #if defined(GLOBAL_MEMSET) - #define X86_64_CEL_REDSTONE_XP_MEMSET GLOBAL_MEMSET - #elif X86_64_CEL_REDSTONE_XP_CONFIG_PORTING_STDLIB == 1 - #define X86_64_CEL_REDSTONE_XP_MEMSET memset - #else - #error The macro X86_64_CEL_REDSTONE_XP_MEMSET is required but cannot be defined. - #endif -#endif - -#ifndef X86_64_CEL_REDSTONE_XP_MEMCPY - #if defined(GLOBAL_MEMCPY) - #define X86_64_CEL_REDSTONE_XP_MEMCPY GLOBAL_MEMCPY - #elif X86_64_CEL_REDSTONE_XP_CONFIG_PORTING_STDLIB == 1 - #define X86_64_CEL_REDSTONE_XP_MEMCPY memcpy - #else - #error The macro X86_64_CEL_REDSTONE_XP_MEMCPY is required but cannot be defined. - #endif -#endif - -#ifndef X86_64_CEL_REDSTONE_XP_VSNPRINTF - #if defined(GLOBAL_VSNPRINTF) - #define X86_64_CEL_REDSTONE_XP_VSNPRINTF GLOBAL_VSNPRINTF - #elif X86_64_CEL_REDSTONE_XP_CONFIG_PORTING_STDLIB == 1 - #define X86_64_CEL_REDSTONE_XP_VSNPRINTF vsnprintf - #else - #error The macro X86_64_CEL_REDSTONE_XP_VSNPRINTF is required but cannot be defined. - #endif -#endif - -#ifndef X86_64_CEL_REDSTONE_XP_SNPRINTF - #if defined(GLOBAL_SNPRINTF) - #define X86_64_CEL_REDSTONE_XP_SNPRINTF GLOBAL_SNPRINTF - #elif X86_64_CEL_REDSTONE_XP_CONFIG_PORTING_STDLIB == 1 - #define X86_64_CEL_REDSTONE_XP_SNPRINTF snprintf - #else - #error The macro X86_64_CEL_REDSTONE_XP_SNPRINTF is required but cannot be defined. - #endif -#endif - -#ifndef X86_64_CEL_REDSTONE_XP_STRLEN - #if defined(GLOBAL_STRLEN) - #define X86_64_CEL_REDSTONE_XP_STRLEN GLOBAL_STRLEN - #elif X86_64_CEL_REDSTONE_XP_CONFIG_PORTING_STDLIB == 1 - #define X86_64_CEL_REDSTONE_XP_STRLEN strlen - #else - #error The macro X86_64_CEL_REDSTONE_XP_STRLEN is required but cannot be defined. - #endif -#endif - -/* */ - - -#endif /* __X86_64_CEL_REDSTONE_XP_PORTING_H__ */ -/* @} */ diff --git a/packages/platforms/celestica/x86-64/redstone-xp/onlp/builds/x86_64_cel_redstone_xp/module/make.mk b/packages/platforms/celestica/x86-64/redstone-xp/onlp/builds/x86_64_cel_redstone_xp/module/make.mk deleted file mode 100644 index 5ee878c74..000000000 --- a/packages/platforms/celestica/x86-64/redstone-xp/onlp/builds/x86_64_cel_redstone_xp/module/make.mk +++ /dev/null @@ -1,10 +0,0 @@ -############################################################################### -# -# -# -############################################################################### -THIS_DIR := $(dir $(lastword $(MAKEFILE_LIST))) -x86_64_cel_redstone_xp_INCLUDES := -I $(THIS_DIR)inc -x86_64_cel_redstone_xp_INTERNAL_INCLUDES := -I $(THIS_DIR)src -x86_64_cel_redstone_xp_DEPENDMODULE_ENTRIES := init:x86_64_cel_redstone_xp ucli:x86_64_cel_redstone_xp - diff --git a/packages/platforms/celestica/x86-64/redstone-xp/onlp/builds/x86_64_cel_redstone_xp/module/src/Makefile b/packages/platforms/celestica/x86-64/redstone-xp/onlp/builds/x86_64_cel_redstone_xp/module/src/Makefile deleted file mode 100644 index 2d27ef620..000000000 --- a/packages/platforms/celestica/x86-64/redstone-xp/onlp/builds/x86_64_cel_redstone_xp/module/src/Makefile +++ /dev/null @@ -1,9 +0,0 @@ -############################################################################### -# -# Local source generation targets. -# -############################################################################### - -ucli: - @../../../../tools/uclihandlers.py x86_64_cel_redstone_xp_ucli.c - diff --git a/packages/platforms/celestica/x86-64/redstone-xp/onlp/builds/x86_64_cel_redstone_xp/module/src/fani.c b/packages/platforms/celestica/x86-64/redstone-xp/onlp/builds/x86_64_cel_redstone_xp/module/src/fani.c deleted file mode 100644 index 2e626534f..000000000 --- a/packages/platforms/celestica/x86-64/redstone-xp/onlp/builds/x86_64_cel_redstone_xp/module/src/fani.c +++ /dev/null @@ -1,111 +0,0 @@ -#include - -#include "i2c_chips.h" -#include "platform.h" - -onlp_fan_info_t f_info[FAN_COUNT + 1] = { - { - { ONLP_FAN_ID_CREATE(1), "Chassis Fan 1", 0 }, - 0x0, - }, - { - { ONLP_FAN_ID_CREATE(2), "Chassis Fan 2", 0 }, - 0x0, - }, - { - { ONLP_FAN_ID_CREATE(3), "Chassis Fan 3", 0 }, - 0x0, - }, - { - { ONLP_FAN_ID_CREATE(4), "Chassis Fan 4", 0 }, - 0x0, - }, - { - { ONLP_FAN_ID_CREATE(5), "Chassis Fan 5", 0 }, - 0x0, - }, - { - { ONLP_FAN_ID_CREATE(6), "Chassis Fan 6", 0 }, - 0x0, - }, - { - { ONLP_FAN_ID_CREATE(7), "Chassis Fan 7", 0 }, - 0x0, - }, - { - { ONLP_FAN_ID_CREATE(8), "Chassis Fan 8", 0 }, - 0x0, - }, - { - { ONLP_FAN_ID_CREATE(8), "PSU Fan 1", 0 }, - 0x0, - }, - { - { ONLP_FAN_ID_CREATE(8), "PSU Fan 2", 0 }, - 0x0, - }, -}; - - -int -onlp_fani_init(void) -{ - fanInit(); - return ONLP_STATUS_OK; -} - -int -onlp_fani_rpm_set(onlp_oid_t id, int rpm) -{ - int fan_id; - unsigned short p; - - /* Max speed 12000 RPM. 1 % is 120 RPM */ - p = (unsigned short) (rpm/120); - if ( p > 100) - p = 100; - - fan_id = ONLP_OID_ID_GET(id) - 1; - - fanSpeedSet(fan_id, p); - return ONLP_STATUS_OK; -} - -int -onlp_fani_percentage_set(onlp_oid_t id, int p) -{ - int fan_id; - - fan_id = ONLP_OID_ID_GET(id) - 1; - - fanSpeedSet(fan_id, (unsigned short)p); - return ONLP_STATUS_OK; -} - -int -onlp_fani_info_get(onlp_oid_t id, onlp_fan_info_t* info) -{ - int fan_id; - - fan_id = ONLP_OID_ID_GET(id) - 1; - - if (fan_id > FAN_COUNT) - return ONLP_STATUS_E_INTERNAL; - - *info = f_info[fan_id]; - - if (!getFanPresent(fan_id)) - info->status |= ONLP_FAN_STATUS_PRESENT; - else - return ONLP_STATUS_E_MISSING; - - if (getFanAirflow(fan_id)) - info->status |= ONLP_FAN_STATUS_F2B; - else - info->status |= ONLP_FAN_STATUS_B2F; - - fanSpeedGet(fan_id, &(info->rpm)); - fanPwmGet(fan_id, &(info->percentage)); - - return ONLP_STATUS_OK; -} diff --git a/packages/platforms/celestica/x86-64/redstone-xp/onlp/builds/x86_64_cel_redstone_xp/module/src/i2c_chips.c b/packages/platforms/celestica/x86-64/redstone-xp/onlp/builds/x86_64_cel_redstone_xp/module/src/i2c_chips.c deleted file mode 100644 index cfdeeb9ea..000000000 --- a/packages/platforms/celestica/x86-64/redstone-xp/onlp/builds/x86_64_cel_redstone_xp/module/src/i2c_chips.c +++ /dev/null @@ -1,1954 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - - -#include "i2c_dev.h" -#include "i2c_chips.h" -#include "redstone_cpld.h" - -#define PSOC_CTRL_SMBUS 0x01 - -static struct ts_info ts[] = { - {0x48, 0x0, 0x3}, - {0x4E, 0x0, 0x3}, - {0x49, 0x0, 0x3}, - {0x4A, 0x0, 0x3}, -}; - -static const struct dev_info i2c_dev[NUM_CHIPS] = { - {1,0x73, 4, "lm75_cpu"}, - {2,0x73, 5, "lm75_out"}, - {3,0x71, 4, "lm75_in"}, - {4,0x71, 5, "lm75_sw"}, - {5, 0x73, 2, "syseeprom"}, - {6, 0x71, 2, "gbeeeprom"}, - {9, 0x73, 7, "pca9506"}, -}; - -#define FANGROUP_NUM 4 -static const struct fan_config fan[FAN_NUM] = { - {0x4D, 0x4E, 0x40}, //Fan 1 Front - {0x2E, 0x4E, 0x40}, //Fan 1 Rear - {0x4D, 0x6E, 0x60}, //Fan 2 F - {0x2e, 0x3E, 0x30}, //Fan 2 R - {0x4D, 0x5E, 0x50}, //Fan 3 F - {0x2E, 0x7E, 0x70}, //Fan 3 R - {0x4D, 0x3E, 0x30}, //Fan 4 F - {0x2E, 0x5E, 0x50}, //Fan 4 R -}; - -static struct led_gpio ledGpio[] = { - {32, 31}, //4_0,3_7, gpio(x_y) = x*8+y - {30, 29}, //3_6,3_5 - {38, 37}, //4_6,4_5 - {34, 33}, //4_2,4_1 -}; -static unsigned char airFlowGpio[] = { - 16, //IO2_0 gpio = 2*8+0, gpio(x_y) = x*8+y - 15, //IO1_7 - 19, //IO2_3 - 17, //IO2_1 -}; -static unsigned char presentGpio[] = { - 11, //IO1_3 gpio = 2*8+0, gpio(x_y) = x*8+y - 10, //IO1_2 - 14, //IO1_6 - 12, //IO1_4 -}; - -static int has_been_read = 0; -static unsigned char cpu_id = 0x00; - -unsigned long in_sus_val = 0x00000000; -unsigned long in_core_val = 0x00000000; - -int openChannel(unsigned char dev_id) -{ - unsigned char data; - int ret = -1; - int i; - for(i=0; i< NUM_CHIPS; i++) - { - if(dev_id == i2c_dev[i].dev_id) - { - data = 0x0 | (0x1 << i2c_dev[i].channel) ; - ret = chips_write_byte(i2c_dev[i].sw_addr, 0x0, data); - if(ret < 0) - return ret; - } - } - return ret; -} - -int closeChannel(unsigned char dev_id) -{ - int ret = -1; - int i; - for(i=0; i< NUM_CHIPS; i++) - { - if(dev_id == i2c_dev[i].dev_id) - { - ret = chips_write_byte(i2c_dev[i].sw_addr, 0x0, 0x0); - if(ret < 0) - return ret; - } - } - return ret; -} - - -/* GPIO INPUT: return zero or nonzero */ -void gpio_sus_init(unsigned int gpio) -{ - outl_p((inl_p(0x580) | (1 << gpio)), 0x580);//100 0000 0001 0011 0000 -} - -unsigned char gpio_sus_get_value(unsigned int gpio) -{ - unsigned char ucRet = 0; - - if ( inl_p( 0x588 ) & (1 << gpio) ) { - ucRet = 0x01; - } - else { - ucRet = 0x00; - } - - return ( ucRet ); - -} -void gpio_sus_set_value(unsigned int gpio, unsigned char val) -{ - if(val) - in_sus_val |= (1 << gpio); - else - in_sus_val &= ~(1 << gpio); - - outl_p( in_sus_val, 0x588 ); -} - - -/**************************************************************** - * gpio_set_dir - ****************************************************************/ -void gpio_sus_set_dir(unsigned int gpio, unsigned int out_flag) -{ - - if (out_flag) - outl_p((inl_p(0x584) & (~(1 << gpio))), 0x584);//output set 0 - else - outl_p((inl_p(0x584) | (1 << gpio)), 0x584);//input set 1 -} - -void gpio_core_init(unsigned int gpio) -{ - outl_p((inl_p(0x500) | (1 << gpio)), 0x500);//100 0000 0001 0011 0000 -} - -unsigned char gpio_core_get_value(unsigned int gpio) -{ - unsigned char ucRet = 0; - - if ( inl_p( 0x508 ) & (1 << gpio) ) { - ucRet = 0x01; - } - else { - ucRet = 0x00; - } - - return ( ucRet ); - -} -void gpio_core_set_value(unsigned int gpio, unsigned char val) -{ - - inl_p(0x508); - if(val) - in_core_val |= (1 << gpio); - else - in_core_val &= ~(1 << gpio); - - outl_p( in_core_val, 0x508 ); -} - - -/**************************************************************** - * gpio_set_dir - ****************************************************************/ -void gpio_core_set_dir(unsigned int gpio, unsigned int out_flag) -{ - - if (out_flag) - outl_p((inl_p(0x504) & (~(1 << gpio))), 0x504);//output set 0 - else - outl_p((inl_p(0x504) | (1 << gpio)), 0x504);//input set 1 -} - - -#define setbit(x,y) x|=(1<> 8); - return data; -} - -/*added by Gerald*/ -#define CPLD_RAM_ADDR_HIGH_BYTE_REG (0x130) -#define CPLD_RAM_ADDR_LOW_BYTE_REG (0x131) -#define CPLD_RAM_READ_REG (0x132) - -#define FAN1_RAM_SPEED_LOW (20) -#define FAN_PRES_STATUS (15) -#define FRONT_FAN_STATUS (FAN_PRES_STATUS + 1) -#define REAR_FAN_STATUS (FAN_PRES_STATUS + 2) - -#define PSU_PRES_STATUS (50) - -int read_ram_from_cpld(const unsigned short ram_offset, unsigned char *value) -{ - int ret; - unsigned char ram_hbyte, ram_lbyte; - unsigned char data; - - /* set RAM offset high byte first as described in spec */ - ram_hbyte = (ram_offset & 0xff00) >> 8 ; - ret = write_cpld(CPLD_RAM_ADDR_HIGH_BYTE_REG, ram_hbyte); - if (ret < 0) - { - printf("write ram offset high byte error\n"); - return ret; - } - - /* set RAM offset low byte */ - ram_lbyte = ram_offset & 0xff; - ret = write_cpld(CPLD_RAM_ADDR_LOW_BYTE_REG, ram_lbyte); - if (ret < 0) - { - printf("write ram offset low byte error\n"); - return ret; - } - - ret = read_cpld(CPLD_RAM_READ_REG, &data); - if(ret >= 0) - *value = data; - return ret; -} - -int read_ram_short_from_cpld(const unsigned short ram_offset, unsigned short *value) -{ - int ret = 0; - unsigned char data; - - ret = read_ram_from_cpld(ram_offset + 1, &data); - if(ret < 0) - return ret; - - *value = data << 8; - - ret = read_ram_from_cpld(ram_offset, &data); - *value |= data ; - return ret; -} - -#define PSOC_WATCHDOG_STATE (2) -#define PSOC_RXP_SXP_FLAG (4) -#define PSOC_PWM_RAM_REG (18) -#define PSOC_9506PORT_RAM_BASE (40) -#define PSU_STATE_RAM (50) - -int getWdFromCpldRam(unsigned char *val) -{ - int ret = 0; - unsigned char data; - - if(getCpuId() == PSOC_CTRL_SMBUS) { - ret = read_ram_from_cpld(PSOC_WATCHDOG_STATE, &data); - //printf("getWdFromCpldRam: ret=%d, data=%u\n", ret, data); - if(ret >= 0) - *val = data; - } - return ret; -} - -int getPwmFromCpldRam(unsigned char *val) -{ - int ret = 0; - unsigned char data; - - if(getCpuId() == PSOC_CTRL_SMBUS) { - ret = read_ram_from_cpld(PSOC_PWM_RAM_REG, &data); - //printf("getWdFromCpldRam: ret=%d, data=%u\n", ret, data); - if(ret >= 0) - *val = data; - } - return ret; -} - -#if 0 -int getAirFlowFromCpldRam(unsigned char *val, int index) -{ - int ret = 0; - unsigned char data; - - if(index > 5 || index < -1) - return -1; - - if(getCpuId() == PSOC_CTRL_SMBUS) { - ret = read_ram_from_cpld(PSOC_9506PORT_RAM_BASE + (index - 1), &data); - //printf("getWdFromCpldRam: ret=%d, data=%u\n", ret, data); - if(ret >= 0) { - *val = data; - } - } - return ret; -} -#endif - -int getRxpSxpFlag(unsigned char *val) -{ - int ret = 0; - unsigned char data; - - if(getCpuId() == PSOC_CTRL_SMBUS) { - ret = read_ram_from_cpld(PSOC_RXP_SXP_FLAG, &data); - //printf("getRxpSxpFlag: ret=%d, data=%u\n", ret, data); - if(ret >= 0) - *val = data; - } - - return ret; -} - -/*end of Gerald*/ -static int LM75_TEMP_FROM_REG(short data) -{ - return (swap(data&0xFFFF) /128)/2; -} - -#define ROA_TEMP_REM_REG (6) -#define BCM_TEMP_REM_REG (ROA_TEMP_REM_REG + 1) -#define CPU_TEMP_REM_REG (ROA_TEMP_REM_REG + 2) -#define FOA_TEMP_REM_REG (ROA_TEMP_REM_REG + 3) -#define TEMP_STATUS_RAM_REG (ROA_TEMP_REM_REG + 4) -#define PSOC_VER_BIT1 (ROA_TEMP_REM_REG + 5) -#define PSOC_VER_BIT2 (ROA_TEMP_REM_REG + 6) - -int getPSoCVersion(unsigned char *val) -{ - int ret = 0; - unsigned char data; - - if(getCpuId() == PSOC_CTRL_SMBUS) { - ret = read_ram_from_cpld(PSOC_VER_BIT1, &data); - if(ret >= 0) - *val = data; - if(ret < 0) - return ret; - - ret = read_ram_from_cpld(PSOC_VER_BIT2, &data); - if(ret >= 0) - *(val+1) = data; - if(ret < 0) - return ret; - } - return ret; -} - -int getTempStatus(unsigned char *val) -{ - int ret = 0; - unsigned char data; - - if(getCpuId() == PSOC_CTRL_SMBUS) { - ret = read_ram_from_cpld(TEMP_STATUS_RAM_REG, &data); - //printf("getRxpSxpFlag: ret=%d, data=%u\n", ret, data); - if(ret >= 0) - *val = data; - - return ret; - } - return ret; -} -int tsTempGet(int id, short *temp) -{ - int ret; - unsigned char data; - - if(getCpuId() == PSOC_CTRL_SMBUS) - { - ret = read_ram_from_cpld(ROA_TEMP_REM_REG + id, &data); - //printf("getPsuStatus: data=%u\n", data); - if(ret >= 0) - *temp = (short)data; - return ret; - } - else - { - unsigned short bufTmp = 0; - if((ret = getCtrlOfBus()) < 0) - return ret; - if((ret = enableChip(ts[id].ts_addr)) < 0) - return ret; - - ret = chips_read_word(ts[id].ts_addr, ts[id].temp_reg, &bufTmp); - if(ret >= 0) - *temp = LM75_TEMP_FROM_REG((short)bufTmp); - - disableChip(ts[id].ts_addr); - } - return ret; -} - -int tsOsGet(int id, unsigned short *temp) -{ - int ret; - unsigned char data; - - if(getCpuId() == PSOC_CTRL_SMBUS) - { - ret = read_ram_from_cpld(ROA_TEMP_REM_REG + id, &data); - //printf("getPsuStatus: data=%u\n", data); - if(ret >= 0) - *temp = (short)data; - return ret; - } - else - { - unsigned short bufTmp = 0; - if((ret = getCtrlOfBus()) < 0) - return ret; - - if((ret = enableChip(ts[id].ts_addr)) < 0) - return ret; - - ret = chips_read_word(ts[id].ts_addr, ts[id].os_reg, &bufTmp); - if(ret >= 0) - *temp = LM75_TEMP_FROM_REG((short)bufTmp); - - disableChip(ts[id].ts_addr); - } - return ret; -} - -int getTsShutdown(int id) -{ - int ret; - unsigned char data; - - if(getCpuId() == PSOC_CTRL_SMBUS) - { - ret = read_ram_from_cpld(ROA_TEMP_REM_REG + id, &data); - //printf("getPsuStatus: data=%u\n", data); - if(ret >= 0) - ret = (short)data; - return ret; - } - else - { - if((ret = getCtrlOfBus()) < 0) - return ret; - if((ret = enableChip(ts[id].ts_addr)) < 0) - return ret; - - ret = chips_read_byte(ts[id].ts_addr, 0x1, &data); - if(ret >= 0) - ret = data & 0x1; - - disableChip(ts[id].ts_addr); - - } - return ret; -} - -int setTsShutdown(int id, int shutdown) -{ - unsigned char data; - int ret; - - if((ret = getCtrlOfBus()) < 0) - return ret; - - if((ret = enableChip(ts[id].ts_addr)) < 0) - return ret; - - ret = chips_read_byte(ts[id].ts_addr, 0x1, &data); - - if(ret >= 0) { - if(shutdown == 1) { - data |= 0x1; - ret = chips_write_byte(ts[id].ts_addr, 0x1, data); - } else { - data &= 0xFE; - ret = chips_write_byte(ts[id].ts_addr, 0x1, data); - } - } - disableChip(ts[id].ts_addr); - return ret; -} - -static short convert_short(char *s, int len) -{ - short i; - short res = 0; - - for(i = 1; i < len; i++) { - res = res * 2 + (s[i] - '0'); - } - if(s[0] == '1') - return -res; - - return res; -} - -static long convert_linear(char *data) -{ - unsigned char low, high; - short N, Y; - long ret; - int temp = 1; - char s[11]; - int i; - - low = data[0]; - high = data[1]; - - if((high & 0x80) > 0) - high = ~high + 0x88; - for(i = 0; i < 5; i++) { - s[i] = (high & (0x80 >> i)) > 0 ? '1' : '0'; - } - - N = convert_short(s, 5); - high = data[1]; - if((high & 0x04) > 0) { - high = ~high + 0x40; - if((low != 0xff) && (low != 0x0)) - low = ~low + 0x1; - else { - low = 0x00; - high += 0x1; - } - - } - for(i = 5; i < 8; i++) - s[i-5] = (high & (0x80 >> i)) > 0 ? '1' : '0'; - for(i = 0; i < 8; i++) - s[i + 3] = (low & (0x80 >> i)) > 0 ? '1' : '0'; - - Y = convert_short(s, 11); - - if(N > 0) { - while(N > 0) { - temp = temp * 2; - N--; - } - - ret = Y * temp * 100; - } - else { - N = 0 - N; - while(N > 0) { - temp = temp * 2; - N--; - } - ret = (Y * 100) / temp; - } - - return ret; -} -int convert_vol(char *data) -{ - char low, high; - short temp; - short ret; - int i; - char s[16]; - - low = data[0]; - high = data[1]; - //printf("low = %x, high = %x\n", low, high); - if((high & 0x80) > 0) - { - high = ~high + 0x80; - if(low != 0xff) - low += ~low + 0x1; - else - { - low = 0x0; - high += 0x1; - } - } - for(i = 0; i < 8; i++) - s[i] = (high & (0x80 >> i)) > 0 ? '1' : '0'; - for(i = 0; i < 8; i++) - s[i + 8] = (low & (0x80 >> i)) > 0 ? '1' : '0'; - //printf("s = %s\n", s); - temp = convert_short(s, 16); - //printf("temp = %x\n", temp); - ret = (temp * 100) / 0x200; - - return ret; -} -#define PSU_RAM_VIN_LOW(i) (90 - i * 20) -#define PSU_RAM_IIN_LOW(i) (PSU_RAM_VIN_LOW(i) + 4) -#define PSU_RAM_VOUT_LOW(i) (PSU_RAM_VIN_LOW(i) + 2) -#define PSU_RAM_IOUT_LOW(i) (PSU_RAM_VIN_LOW(i) + 6) -#define PSU_RAM_POUT_LOW(i) (PSU_RAM_VIN_LOW(i) + 10) -#define PSU_RAM_PIN_LOW(i) (PSU_RAM_VIN_LOW(i) + 8) -#define PSU_RAM_TEMP1_LOW(i) (56 - (i) * 2) -#define PSU_RAM_FAN_SPEED_LOW(i) (62 - (i)*2) -#define PSU_RAM_STATUS (50) - -int getPsuInfo(int id, struct psuInfo * info) -{ - int status; - int ret; -// char cpld_psu_reg; -// char cpld_psu_reg_tmp; - unsigned short vin; - unsigned short iin; - unsigned short vout; - unsigned short iout; - unsigned short pout; - unsigned short pin; - unsigned short temp; - char psu_addr[] = { - 0x58, - 0x59, - }; - - if(getCpuId() == PSOC_CTRL_SMBUS) { - status = getPsuPresent(id); - if(status == 1) - return -1; - - if(status == 0) {//PSU-L present - if ((ret = read_ram_short_from_cpld(PSU_RAM_VIN_LOW(id), &vin)) < 0) - return -1; - if ((ret = read_ram_short_from_cpld(PSU_RAM_IIN_LOW(id), &iin)) < 0) - return -1; - if ((ret = read_ram_short_from_cpld(PSU_RAM_VOUT_LOW(id), &vout)) < 0) - return -1; - if ((ret = read_ram_short_from_cpld(PSU_RAM_IOUT_LOW(id), &iout)) < 0) - return -1; - if ((ret = read_ram_short_from_cpld(PSU_RAM_POUT_LOW(id), &pout)) < 0) - return -1; - if ((ret = read_ram_short_from_cpld(PSU_RAM_PIN_LOW(id), &pin)) < 0) - return -1; - if ((ret = read_ram_short_from_cpld(PSU_RAM_TEMP1_LOW(id), &temp)) < 0) - return -1; - - info->vin = convert_linear((char *)&vin) * 10; - info->iin = convert_linear((char *)&iin) * 10; - info->vout = convert_vol((char *)&vout) * 10; - info->iout = convert_linear((char *)&iout) * 10; - info->pout = convert_linear((char *)&pout) * 10; - info->pin = convert_linear((char *)&pin) * 10; - info->temp = convert_linear((char *)&temp)/100; - return 0; - } - - } else { - status = getPsuPresent(id); - if (status == 0) - { - if((ret = getCtrlOfBus()) < 0) - return ret; - if((ret = enableChip(psu_addr[id])) < 0) - return ret; - - if((ret = chips_read_word(psu_addr[id], PSU_READ_VIN, &vin)) < 0) - goto error; - if((ret = chips_read_word(psu_addr[id], PSU_READ_IIN, &iin)) < 0) - goto error; - if((ret = chips_read_word(psu_addr[id], PSU_READ_VOUT, &vout)) < 0) - goto error; - if((ret = chips_read_word(psu_addr[id], PSU_READ_IOUT, &iout)) < 0) - goto error; - if((ret = chips_read_word(psu_addr[id], PSU_READ_POUT, &pout)) < 0) - goto error; - if((ret = chips_read_word(psu_addr[id], PSU_READ_PIN, &pin)) < 0) - goto error; - if((ret = chips_read_word(psu_addr[id], PSU_READ_TEMP_1, &temp)) < 0) - goto error; - info->vin = convert_linear((char *)&vin) * 10; - info->iin = convert_linear((char *)&iin) * 10; - info->vout = convert_vol((char *)&vout) * 10; - info->iout = convert_linear((char *)&iout) * 10; - info->pout = convert_linear((char *)&pout) * 10; - info->pin = convert_linear((char *)&pin) * 10; - info->temp = convert_linear((char *)&temp)/100; - if((ret = disableChip(psu_addr[id])) < 0) - return ret; - return 0; - } - } - -error: - ret = disableChip(psu_addr[id]); - return -1; - -} -//return value 0:present, 1,absent -int getPsuPresent(int id) -{ - - unsigned char data; - int ret = -1; - - if(getCpuId() == PSOC_CTRL_SMBUS) - { - ret = read_ram_from_cpld(PSU_STATE_RAM, &data); - if(ret >= 0) { - ret = (data >> (1-id)) & 0x1; - ret = (ret == 0) ? 1 : 0; - } - } - else - { - int gpio; - switch(id) - { - case 0: - gpio = 27;//IO3_3 - break; - case 1: - gpio = 28;//IO3_4 - break; - default: - ret = -1; - return ret; - } - ret = pca9506_init_pin(gpio,gpio_in); - if(ret < 0) - return ret; - ret = pca9506_read_pin(gpio); - } - - - return ret; -} - -int read_psu(unsigned char addr, unsigned char reg, unsigned short *value) -{ - int status; - int ret = -1; - unsigned short data; - int id = 0; - if(addr == 0x58) - id = 8; - else if(addr == 0x59) - id = 9; - status = getFanPresent(id); - - if (status == 0) - { - if((ret = getCtrlOfBus()) < 0) - return ret; - if((ret = enableChip(addr)) < 0) - return ret; - - if((ret = chips_read_word(addr, reg, &data)) < 0) - goto error; - *value = data; - if((ret = disableChip(addr)) < 0) - return ret; - return 0; - } - else - { - goto error; - } - -error: - ret = disableChip(addr); - return -1; - -} - -int write_psu(unsigned char addr, unsigned char reg, unsigned short value) -{ -#if 0 - int status; - int ret = -1; - int id; - unsigned char data[5]; - unsigned char crc = 0; - unsigned char errStatus = 0; - unsigned char blockData[3]; - - unsigned char *wrData = (unsigned char *)&value; - - data[0] = (addr << 1) | 0;//0 i2c write - data[1] = reg; - data[2] = wrData[0]; - data[3] = wrData[1]; - crc = i2c_smbus_pec(crc, data, 4); - - blockData[0] = data[2]; - blockData[1] = data[3]; - blockData[2] = crc; - - if(addr == 0x58) - id = 8; - else if(addr == 0x59) - id = 9; - status = getFanPresent(id); - - if (status == 0) - { - if((ret = getCtrlOfBus()) < 0) - return ret; - if((ret = enableChip(addr)) < 0) - return ret; - - if((ret = chips_write_block(addr, reg, 3, blockData)) < 0) - goto error; - - if((ret = disableChip(addr)) < 0) - return ret; - return 0; - } - else - { - goto error; - } - -error: - ret = disableChip(addr); - return -1; -#endif - int status; - int ret = -1; - //unsigned short data; - int id = 0; - - if(addr == 0x58) - id = 8; - else if(addr == 0x59) - id = 9; - status = getFanPresent(id); - - if (status == 0) - { - if((ret = getCtrlOfBus()) < 0) - return ret; - if((ret = enableChip(addr)) < 0) - return ret; - - if((ret = chips_write_word_pec(addr, reg, value, 1)) < 0) - goto error; - if((ret = disableChip(addr)) < 0) - return ret; - return 0; - } - else - { - goto error; - } - -error: - ret = disableChip(addr); - return -1; - -} - -/*dev_id 5: system eeprom, dev_id 6: switch eeprom*/ -int -eeprom_enable(unsigned char dev_id) -{ - int ret =0; - unsigned char buf = 0x00; - int regNum = 0x123; - - ret = read_cpld(regNum, &buf); - buf &= ~(BIT0); - ret = write_cpld(regNum, buf); - - if(getCpuId() != PSOC_CTRL_SMBUS) { - getCtrlOfBus(); - ret = openChannel(dev_id); - } - return ret; - -} - - - -int -eeprom_disable(unsigned char dev_id) -{ - int ret =0; - unsigned char buf = 0x00; - int regNum = 0x123;; - - - if(getCpuId() != PSOC_CTRL_SMBUS) { - closeChannel(dev_id); - read_cpld(regNum, &buf); - buf |= BIT0; - ret = write_cpld(regNum, buf); - } - return ret; -} - -/* -close bios flash protect -[3] RW 0b0 Control The Status of SPD2_WP. -[2] RW 0b0 Control The Status of SPD1_WP. -*/ -int biosflash_enable() -{ - int ret =0; - unsigned char buf = 0x00; - int regNum = 0x123;; - - ret = read_cpld(regNum, &buf); - buf &= ~(BIT2 | BIT3); - ret = write_cpld(regNum, buf); - - return ret; - -} -/* -open bios flash protect -*/ -int biosflash_disable() -{ - int ret =0; - unsigned char buf = 0x00; - int regNum = 0x123;; - - ret = read_cpld(regNum, &buf); - buf |= (BIT2 | BIT3); - ret = write_cpld(regNum, buf); - - return ret; -} - -static inline int pca9506_read_byte_data(unsigned char reg,unsigned char *value) -{ - int ret; - - if(getCpuId() == PSOC_CTRL_SMBUS) { - unsigned char buf; - ret = read_cpld((int)0x198, &buf); - if(ret >= 0) - *value = (short)buf; - } else { - unsigned char data; - if((ret = getCtrlOfBus()) < 0) - return ret; - - if((ret = openChannel(9)) < 0) - { - return ret; - } - - - ret = chips_read_byte(PCA9506_ADDR, reg, &data); - if(ret >= 0) - *value = data; - - closeChannel(9); - } - return ret; -} - -static inline int pca9506_write_byte_data(unsigned char reg, unsigned char val) -{ - int ret = -1; - - if(getCpuId() == PSOC_CTRL_SMBUS) - { - unsigned char buf; - return read_cpld((int)0x198, &buf); - } else { - //unsigned char data; - if((ret = getCtrlOfBus()) < 0) - return ret; - - if((ret = openChannel(9)) < 0) - return ret; - - - ret = chips_write_byte(PCA9506_ADDR, reg, val); - closeChannel(9); - } - return ret; -} - -int pca9506_init_pin(unsigned char port, gpio_dir val) -{ - int ret = -1; - unsigned char bank = 0; - unsigned char bit = 0; - - unsigned char cfg_reg = 0; - //unsigned char input_reg = 0; - unsigned char output_reg = 0; - - unsigned char cfg_val = 0; - //unsigned char input_val = 0; - unsigned char output_val = 0; - - bank = port/8; - bit = port%8; - - cfg_reg = PCA9506_IOC0_REG + bank; - output_reg = PCA9506_OP0_REG + bank; - - // set output direction - ret = pca9506_read_byte_data(cfg_reg,&cfg_val); - - bit &= 0xf; - if(val == gpio_out) - cfg_val &= ~(0x01 << bit); - else - cfg_val |= (PCA9506_IO_INPUT << bit); - - ret = pca9506_write_byte_data(cfg_reg, cfg_val); - - if(val == gpio_out) - { - // set value - ret = pca9506_read_byte_data(output_reg, &output_val); - - val &= 0x01; - output_val &= ~(0x01 << bit); - output_val |= (val << bit); - ret = pca9506_write_byte_data(output_reg, output_val); - } - return ret; -} - -int pca9506_read_pin(unsigned char port) -{ - unsigned char bank = 0; - unsigned char bit = 0; - - //unsigned char cfg_reg = 0; - unsigned char input_reg = 0; - - //unsigned char cfg_val = 0; - unsigned char input_val = 0; - - bank = port/8; - bit = port%8; - - input_reg = PCA9506_IP0_REG + bank; - - // get value - pca9506_read_byte_data(input_reg, &input_val); - - return (input_val >> bit) & 0x01; -} - - -int pca9506_write_pin(unsigned char port, unsigned char val) -{ - int ret = -1; - unsigned char bank = 0; - unsigned char bit = 0; - - //unsigned char cfg_reg = 0; - unsigned char input_reg = 0; - unsigned char output_reg = 0; - - //unsigned char cfg_val = 0; - unsigned char input_val = 0; - //unsigned char output_val = 0; - - bank = port/8; - bit = port%8; - - input_reg = PCA9506_IP0_REG + bank; - output_reg = PCA9506_OP0_REG + bank; - - // get value - ret = pca9506_read_byte_data(input_reg,&input_val); - - val &= 0x01; - input_val &= ~(0x01 << bit); - input_val |= (val << bit); - ret = pca9506_write_byte_data(output_reg, input_val); - - return ret; -} - -/* -* param: id is fan id, from 0 to FAN_NUM + 1 -* return: 0 means present, 1 means absent -*/ -int getFanPresent(int id) -{ - - unsigned char data; - int ret = -1; - - if(getCpuId() == PSOC_CTRL_SMBUS) - { - int off; - if(id >= (FAN_NUM + 2) || id < 0) - return -1; - - if(id < FAN_NUM) - off = id / 2; - else - off = id - FAN_NUM; - - if(id <= (FAN_NUM - 1)) - ret = read_ram_from_cpld(FAN_PRES_STATUS, &data); - else - ret = read_ram_from_cpld(PSU_PRES_STATUS, &data); - - if(id <= (FAN_NUM - 1)) - ret = (data >> off) & 0x1; - else { - //ret = (data >> (1 - off)) & 0x1; - ret = (data & (1 << (1 - off))) ? 1 : 0; - } - - ret ^= 1; - } else { - int gpio = 0; - - if(id < FAN_NUM) - gpio = presentGpio[id>>1]; - else if(id == FAN_NUM) - gpio = 27;//IO3_3; - else if(id == (FAN_NUM + 1)) - gpio = 28;//IO3_4 - ret = pca9506_init_pin(gpio,gpio_in); - if(ret < 0) - return ret; - ret = pca9506_read_pin(gpio); - - } - - - return ret; -} - -//ret 1 failed, 0 OK -int getFanStatus(int id) -{ - unsigned char data; - //unsigned short value; - int ret = -1; - - if(id <0 || id >= FAN_NUM) - return ret; - - if(getCpuId() == PSOC_CTRL_SMBUS) - { - if(id % 2) {//front - ret = read_ram_from_cpld(FRONT_FAN_STATUS, &data); - //printf("getFanStatus, front: id=%d, data=%u, ret=%d\n", id, data, ret); - if(ret < 0) - return ret; - else - ret = (data >> (id / 2)) & 0x1; - }else { //rear - ret = read_ram_from_cpld(REAR_FAN_STATUS, &data); - if(ret < 0) - return ret; - else - ret = (data >> (id / 2)) & 0x1; - } - - } - else - { - if(id < FAN_NUM) //emc2305 fan controller - { - if((ret = getCtrlOfBus()) < 0) - return ret; - if((ret = enableChip(fan[id].emc_addr)) < 0) - return ret; - //ret = getFanPresent(id); - //if(ret < 0) - // return ret; - ret = chips_read_byte(fan[id].emc_addr, 0x25, &data); - if(ret < 0) - { - disableChip(fan[id].emc_addr); - return ret; - } - - if (((data >> (0x1 << id)) & 0x01) == 0x01) { - ret = 1; - } - disableChip(fan[id].emc_addr); - } - else - { - if((id == FAN_NUM)||(ret == (FAN_NUM + 1))) - { - ret = 0; - } - } - } - return ret; - -} - - -// 1 is F2B, 0 is B2F -int getFanAirflow(int id) -{ - - unsigned char data_io1, data_io2; - int ret = -1; - - if(getCpuId() == 0x01) - { - int off; - switch(id) - { - case 0: - case 1: - off = 0; - break; - case 2: - case 3: - off = 1; - break; - case 4: - case 5: - off = 2; - break; - case 6: - case 7: - off = 3; - break; - default: - ret = -1; - return ret; - } - - ret = read_ram_from_cpld(PSOC_9506PORT_RAM_BASE + 1, &data_io1); - if(ret < 0) - return -1; - - ret = read_ram_from_cpld(PSOC_9506PORT_RAM_BASE + 2, &data_io2); - if(ret < 0) - return -1; - - //printf("getFanAirflow: ret=%d, data_io1=%u, data_io2=%u\n", ret, data_io1, data_io2); - - if(off == 0) - ret = (data_io2 & 1) ? 1 : 0; - else if(off == 1) - ret = (data_io1 & (1 << 7)) ? 1 : 0; - else if(off == 2) - ret = (data_io2 & (1 << 3)) ? 1 : 0; - else if(off == 3) - ret = (data_io2 & (1 << 1)) ? 1 : 0; - else - ret = -1; - -#if 0 - if(id <= 7) - ret = read_cpld(CPLD_FAN_PRESENT, &data); - else - ret = read_cpld(CPLD_PSU_STATUS, &data); - - if(ret >= 0) - ret = (data >> off) & 0x1; -#endif - } - else - { - int gpio; - - if(id < FAN_NUM) - gpio = airFlowGpio[id>>1]; - else - return ret; - ret = pca9506_init_pin(gpio,gpio_in); - if(ret < 0) - return ret; - ret = pca9506_read_pin(gpio); - - } - - - return ret; -} - -//on_off 0 set let red/green led on, 1 off. color 0 green 1 red, 2 yellow -static int setFanLed(int id, unsigned char color, unsigned char on_off) -{ - - unsigned char data; - int ret = -1; - - if(getCpuId() == 0x01) - { - int off; - switch(id) - { - case 0: - case 1: - off = 0; - break; - case 2: - case 3: - off = 1; - break; - case 4: - case 5: - off = 2; - break; - case 6: - case 7: - off = 3; - break; - case 8: - off = 4; - break; - case 9: - off = 5; - break; - default: - ret = -1; - return ret; - } - if(id <= 7) - ret = read_cpld(CPLD_FAN_PRESENT, &data); - else - ret = read_cpld(CPLD_PSU_STATUS, &data); - if(ret >= 0) - ret = (data >> off) & 0x1; - } - else - { - int gpio; - gpio = (color == 0)?ledGpio[id>>1].green_gpio:ledGpio[id>>1].red_gpio; - ret = pca9506_init_pin(gpio,gpio_out); - if(ret < 0) - return ret; - ret = pca9506_write_pin(gpio,on_off); - - } - - - return ret; -} -int setFanLedGreen(int id) -{ - int ret = -1; - ret = setFanLed(id,red,1); - ret = setFanLed(id,green,0); - return ret; -} -int setFanLedRed(int id) -{ - int ret = -1; - ret = setFanLed(id,green,1); - ret = setFanLed(id,red,0); - return ret; -} -int setFanLedYellow(int id) -{ - int ret = -1; - ret = setFanLed(id,red,0); - ret = setFanLed(id,green,0); - return ret; -} -int setFanLedOff(int id) -{ - int ret = -1; - ret = setFanLed(id,red,1); - ret = setFanLed(id,green,1); - return ret; -} - -int setPsuLedOn(int id) -{ - int ret = -1; - unsigned char buf = 0x00; - ret = read_cpld(CPLD_FP_LED, &buf); - buf &= ~(1 << (2 + id)); - ret = write_cpld(CPLD_FP_LED, buf); - return ret; -} -int setPsuLedOff(int id) -{ - int ret = -1; - unsigned char buf = 0x00; - - ret = read_cpld(CPLD_FP_LED, &buf); - - buf |= 1 << (2 + id); - ret = write_cpld(CPLD_FP_LED, buf); - if (ret < 0) - { - printf("write error\n"); - return ret; - } - - return ret; - -} -int setSysLedOn() -{ - int ret = -1; - unsigned char buf = 0x00; - ret = read_cpld(CPLD_FP_LED, &buf); - buf &= ~(BIT0); - buf &= ~(BIT1);; - ret = write_cpld(CPLD_FP_LED, buf); - if (ret < 0) - { - printf("setSysLedOn error\n"); - return ret; - } - - return ret; - -} - -int -setSysLedOff() -{ - int ret = -1; - unsigned char buf = 0x00; - - ret = read_cpld(CPLD_FP_LED, &buf); - buf |= 0x11; - ret = write_cpld(CPLD_FP_LED, buf); - if (ret < 0) - { - printf("setSysLedOff error\n"); - return ret; - } - - return ret; - -} - - -static int FAN_PERIOD_TO_RPM(int x) -{ - if (x > (0xf5c2 >> 3)) /*<1000rpm, fan fail*/ - return 0; - - return 3932160 * 2 / x; -} - -int fanPwmGet(int id, int *pwm) -{ - unsigned char data; - unsigned short value; - int ret = -1; - - - if(getCpuId() == 0x01) - { - ret = read_ram_from_cpld(PSOC_PWM_RAM_REG, &data); - //printf("getWdFromCpldRam: ret=%d, data=%u\n", ret, data); - if(ret >= 0) - *pwm = (data * 100)/255; - //*speed = FAN_PERIOD_TO_RPM((*speed & 0x0FFFF)>> 3); - //*speed = FAN_PERIOD_TO_RPM(*speed >> 3); - } - else - { - if(id < FAN_NUM) //emc2305 fan controller - { - if((ret = getCtrlOfBus()) < 0) - return ret; - if((ret = enableChip(fan[id].emc_addr)) < 0) - return ret; - //ret = getFanPresent(id); - //if(ret < 0) - // return ret; - ret = chips_read_byte(fan[id].emc_addr, fan[id].driver_reg, &data);//pwm = speed*255/100 - if(ret < 0) - { - disableChip(fan[id].emc_addr); - return ret; - } - *pwm = (data * 100)/255; - disableChip(fan[id].emc_addr); - } - else - { - if(id == FAN_NUM)//psu fan - { - //unsigned short temp; - - ret = read_psu(0x58, PSU_PWM_REG, &value); - - - //ret = read_psu(0x58, PSU_PWM_REG, &temp); - if(ret < 0) - return ret; - *pwm = value; - } - else if(id == (FAN_NUM + 1)) - { - ret = read_psu(0x59, PSU_PWM_REG, &value); - if(ret < 0) - return ret; - *pwm = value; - } - - } - } - return ret; -} - -int fanSpeedGet(int id, int *speed) -{ - unsigned char data; - unsigned short value; - int ret = -1; - - if(getCpuId() == PSOC_CTRL_SMBUS) - { - if(id <= FAN_NUM - 1) { - ret = read_ram_from_cpld(FAN1_RAM_SPEED_LOW + id * 2 + 1, &data); - if(ret < 0) { - return ret; - } - - *speed = data << 8; - - ret = read_ram_from_cpld(FAN1_RAM_SPEED_LOW + id * 2, &data); - if(ret >= 0) { - *speed |= data ; - } else { - } - } else { - if ((ret = read_ram_short_from_cpld(PSU_RAM_FAN_SPEED_LOW(id-8), &value)) < 0) - return -1; - //*speed = value; - *speed = convert_linear((char *)&value)/100; - } - //*speed = FAN_PERIOD_TO_RPM((*speed & 0x0FFFF)>> 3); - //*speed = FAN_PERIOD_TO_RPM(*speed >> 3); - } - else - { - if(id < FAN_NUM) //emc2305 fan controller - { - if((ret = getCtrlOfBus()) < 0) - return ret; - if((ret = enableChip(fan[id].emc_addr)) < 0) - return ret; - //ret = getFanPresent(id); - //if(ret < 0) - // return ret; - ret = chips_read_byte(fan[id].emc_addr, fan[id].speed_reg, &data); - if(ret < 0) { - disableChip(fan[id].emc_addr); - return ret; - } - *speed = data << 8; - usleep(50000); - ret = chips_read_byte(fan[id].emc_addr, (fan[id].speed_reg+1), &data); - if(ret >= 0) - { - *speed |= data ; - } - //*speed = FAN_PERIOD_TO_RPM((*speed & 0x0FFFF)>> 3); - *speed = FAN_PERIOD_TO_RPM(*speed >> 3); - disableChip(fan[id].emc_addr); - } - else - { - if(id == FAN_NUM) - { - ret = read_psu(0x58, PSU_SPEED_REG, &value); - if(ret < 0) - return ret; - *speed = convert_linear((char *)&value)/100; - } - else if(id == (FAN_NUM + 1)) - { - ret = read_psu(0x59, PSU_SPEED_REG, &value); - if(ret < 0) - return ret; - *speed = convert_linear((char *)&value)/100; - } - } - } - return ret; -} -#define EMC2305_REG_FAN_DRIVE(n) (0x30 + 0x10 * n) -#define EMC2305_REG_FAN_MIN_DRIVE(n) (0x38 + 0x10 * n) -#define EMC2305_REG_FAN_TACH(n) (0x3E + 0x10 * n) - - -int fanInit() -{ - int ret = -1; - int id = 0; - unsigned char sys_fan_speed = 0x66; - - if(getCpuId() == PSOC_CTRL_SMBUS) - { - - //*speed = FAN_PERIOD_TO_RPM((*speed & 0x0FFFF)>> 3); - //*speed = FAN_PERIOD_TO_RPM(*speed >> 3); - } - else - { - for (id = 0; id < FAN_NUM; id++) { - if((ret = getCtrlOfBus()) < 0) - return ret; - if((ret = enableChip(fan[id].emc_addr)) < 0) - return ret; - - /* set minimum drive to 20% */ - ret = chips_write_byte(fan[id].emc_addr, (fan[id].driver_reg-0x30)/0x10+0x38, 0x33); - ret = chips_write_byte(fan[id].emc_addr, fan[id].driver_reg, sys_fan_speed); - if(ret < 0) - { - disableChip(fan[id].emc_addr); - return ret; - } - - disableChip(fan[id].emc_addr); - } - } - return ret; -} -//id 0-based -int fanSpeedSet(int id, unsigned short speed) -{ - int ret = -1; - - if(getCpuId() == PSOC_CTRL_SMBUS) - { - - //*speed = FAN_PERIOD_TO_RPM((*speed & 0x0FFFF)>> 3); - //*speed = FAN_PERIOD_TO_RPM(*speed >> 3); - } - else - { - if(id < FAN_NUM) //emc2305 fan controller - { - if((ret = getCtrlOfBus()) < 0) - return ret; - if((ret = enableChip(fan[id].emc_addr)) < 0) - return ret; - - ret = chips_write_byte(fan[id].emc_addr, fan[id].driver_reg, speed*255/100);//current_pwm_value*255/100 - if(ret < 0) - { - disableChip(fan[id].emc_addr); - return ret; - } - - disableChip(fan[id].emc_addr); - } - else - { - if(id == FAN_NUM)//psu fan - { - //unsigned short temp; - - ret = write_psu(0x58, PSU_PWM_REG, speed); - - //ret = read_psu(0x58, PSU_PWM_REG, &temp); - if(ret < 0) - return ret; - } - else if(id == (FAN_NUM + 1)) - { - ret = write_psu(0x59, PSU_PWM_REG, speed); - if(ret < 0) - return ret; - } - } - } - return ret; -} diff --git a/packages/platforms/celestica/x86-64/redstone-xp/onlp/builds/x86_64_cel_redstone_xp/module/src/i2c_chips.h b/packages/platforms/celestica/x86-64/redstone-xp/onlp/builds/x86_64_cel_redstone_xp/module/src/i2c_chips.h deleted file mode 100644 index 23bdc8ee5..000000000 --- a/packages/platforms/celestica/x86-64/redstone-xp/onlp/builds/x86_64_cel_redstone_xp/module/src/i2c_chips.h +++ /dev/null @@ -1,225 +0,0 @@ -#ifndef I2C_CHIPS_HH -#define I2C_CHIPS_HH - -/* PSU registers */ -#define PSU_STATUS_VOUT 0x7a -#define PSU_STATUS_IOUT 0x7b -#define PSU_STATUS_TEMP 0x7d - -#define PSU_READ_VIN 0x88 -#define PSU_READ_IIN 0x89 -#define PSU_READ_VOUT 0x8b -#define PSU_READ_IOUT 0x8c -#define PSU_READ_TEMP_1 0x8d -#define PSU_READ_POUT 0x96 -#define PSU_READ_PIN 0x97 -#define PSU_PWM_REG 0x3b -#define PSU_SPEED_REG 0x90 - -#define PSU_MFR_ID 0x99 // 7 byte -#define PSU_MFR_MODEL 0x9a // 14 byte -#define PSU_MFR_REVISION 0x9b // 5 byte -#define PSU_MFR_LOCATION 0x9c -#define PSU_MFR_DATE 0x9d -#define PSU_MFR_SERIAL 0x9e -#define PCA9506_IP0_REG 0x00 -#define PCA9506_IP1_REG 0x01 -#define PCA9506_IP2_REG 0x02 -#define PCA9506_IP3_REG 0x03 -#define PCA9506_IP4_REG 0x04 - -#define PCA9506_OP0_REG 0x08 -#define PCA9506_OP1_REG 0x09 -#define PCA9506_OP2_REG 0x0A -#define PCA9506_OP3_REG 0x0B -#define PCA9506_OP4_REG 0x0C - -#define PCA9506_PI0_REG 0x10 -#define PCA9506_PI1_REG 0x11 -#define PCA9506_PI2_REG 0x12 -#define PCA9506_PI3_REG 0x13 -#define PCA9506_PI4_REG 0x14 - -#define PCA9506_IOC0_REG 0x18 -#define PCA9506_IOC1_REG 0x19 -#define PCA9506_IOC2_REG 0x1A -#define PCA9506_IOC3_REG 0x1B -#define PCA9506_IOC4_REG 0x1C - -#define PCA9506_MSK0_REG 0x20 -#define PCA9506_MSK1_REG 0x21 -#define PCA9506_MSK2_REG 0x22 -#define PCA9506_MSK3_REG 0x23 -#define PCA9506_MSK4_REG 0x24 - -#define PCA9506_IO_INPUT 1 -#define PCA9506_IO_OUTPUT 0 - -#define PCA9506_IO_LOW 0 -#define PCA9506_IO_HIGH 1 -#define PCA9506_ADDR 0x20 - - - -struct psuInfo -{ - unsigned int vin; - unsigned int iin; - unsigned int vout; - unsigned int iout; - unsigned int pout; - unsigned int pin; - unsigned int temp; -}; - -struct chips_info -{ - char addr; - char sw_addr; - int channel; - char *name; -}; - -struct dev_info -{ - unsigned char dev_id; - char sw_addr; - int channel; - char *name; -}; - -struct fan_config -{ - char emc_addr; - char speed_reg; - char driver_reg; -}; -struct fan_cpld_reg -{ - unsigned short hight_byte_reg; - unsigned short low_byte_reg; -}; - - -struct ts_info -{ - char ts_addr; - char temp_reg; - char os_reg; -}; - -typedef enum -{ - gpio_in = 0, - gpio_out = 1 -} gpio_dir; - -typedef enum -{ - F2B= 0, - B2F = 1 -} fan_airflow; -typedef enum -{ - green = 0, - red = 1, - yellow = 1 -} gpio_color; -struct led_gpio -{ - int green_gpio; - int red_gpio; -}; - - -int getCtrlOfBus(void); -int enableChip(char addr); -int disableChip(char addr); - -int fanSpeedGet(int id, int *speed); -int fanSpeedSet(int id, unsigned short speed); -int fanPwmGet(int id, int *pwm); - -int tsTempGet(int id, short *temp); -int tsOsGet(int id, unsigned short *temp); -int getTsShutdown(int id); -int setTsShutdown(int id, int shutdown); -int getPsuInfo(int id, struct psuInfo * info); -int getWdFromCpldRam(unsigned char *val); -int getRxpSxpFlag(unsigned char *val); -//int getPsuPresStatus(int id); -int getPSoCVersion(unsigned char *val); -int getTempStatus(unsigned char *val); -unsigned char getCpuId(); -int openChannel(unsigned char dev_id); -int closeChannel(unsigned char dev_id); -int eeprom_enable(unsigned char dev_id); -int eeprom_disable(unsigned char dev_id); -int pca9506_init_pin(unsigned char port, gpio_dir val); -int pca9506_write_pin(unsigned char port, unsigned char val); -int pca9506_read_pin(unsigned char port); - -int fanInit(); -int getFanPresent(int id); -int getFanAirflow(int id); -int getFanStatus(int id); - -int setFanLedGreen(int id); -int setFanLedRed(int id); -int setFanLedYellow(int id); -int setFanLedOff(int id); -int setPsuLedOn(int id); -int setPsuLedOff(int id); -int setSysLedOn(); -int setSysLedOff(); - - -void watchdog_disable(); -/* watchdog timer must less than 1.2s */ -void watchdog_enable(); -void watchdog_service(); - - - -int read_psu(unsigned char addr, unsigned char reg, unsigned short *value); -int write_psu(unsigned char addr, unsigned char reg, unsigned short value); -int setPsuLedOff(int id); -int setPsuLedOn(int id); -int getPsuPresent(int id); - -int biosflash_enable(); -int biosflash_disable(); - - - -struct i2cMutex { - int init_flag; - pthread_mutex_t mutex; - pthread_cond_t lock_free; - volatile int is_locking; -}; - -#define NUM_CHIPS 10 -static const struct chips_info i2c_chips[NUM_CHIPS] = { - {0x50, 0x73, 2, "eeprom"}, - {0x4D, 0x73, 3, "emc2305_1"}, - {0x2E, 0x73, 3, "emc2305_2"}, - {0x58, 0x73, 0, "PSU_L"}, - {0x59, 0x73, 1, "PSU_R"}, - {0x48, 0x73, 4, "lm75_cpu"}, - {0x4E, 0x73, 5, "lm75_out"}, - {0x49, 0x71, 4, "lm75_in"}, - {0x4A, 0x71, 5, "lm75_sw"}, - {0x20, 0x73, 7, "pca9506"}, -}; - - -#ifdef L7_MAX_FANS_PER_UNIT -#define FAN_NUM L7_MAX_FANS_PER_UNIT -#else -#define FAN_NUM 8 -#endif - -#define FANGROUP_NUM 4 - -#endif diff --git a/packages/platforms/celestica/x86-64/redstone-xp/onlp/builds/x86_64_cel_redstone_xp/module/src/i2c_dev.c b/packages/platforms/celestica/x86-64/redstone-xp/onlp/builds/x86_64_cel_redstone_xp/module/src/i2c_dev.c deleted file mode 100644 index cff2ef320..000000000 --- a/packages/platforms/celestica/x86-64/redstone-xp/onlp/builds/x86_64_cel_redstone_xp/module/src/i2c_dev.c +++ /dev/null @@ -1,483 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include - -#include "i2c_dev.h" - -static int -i2c_write_2b(char addr, __u8 buf[2]) -{ - - int busNum = 1; - dataType type = LEN_BYTE; - int ret = -1; - unsigned char reg; - unsigned char data; - - reg = buf[0]; - data = buf[1]; - - ret = i2c_smbus_write(busNum, addr, reg, type, 1, &data); - return ret; -} - -static int -i2c_write_3b(char addr, __u8 buf[3]) -{ - int busNum = 1; - dataType type = LEN_WORD; - int ret = -1; - char data[2]; - - data[0] = buf[1]; - data[1] = buf[2]; - - ret = i2c_smbus_write(busNum, addr, buf[0], type, 1, (unsigned char *)&data); - - return ret; -} - -static inline int -i2c_smbus_access(int file, char read_write, __u8 command, - int size, union i2c_smbus_data *data) -{ - struct i2c_smbus_ioctl_data args; - int ret; - - args.read_write = read_write; - args.command = command; - args.size = size; - args.data = data; - - ret = ioctl(file, I2C_SMBUS, &args); - - return ret; -} - -static int -i2c_smbus_write_word_data(int file, __u8 command, - __u16 value) -{ - union i2c_smbus_data data; - data.word = value; - return i2c_smbus_access(file, I2C_SMBUS_WRITE, command, - I2C_SMBUS_WORD_DATA, &data); -} - -static int -i2c_smbus_write_byte_data(int file, __u8 command, - __u8 value) -{ - union i2c_smbus_data data; - data.byte = value; - return i2c_smbus_access(file, I2C_SMBUS_WRITE, command, - I2C_SMBUS_BYTE_DATA, &data); -} - -static int -i2c_smbus_read_byte(int file,__u8 *buf) -{ - union i2c_smbus_data data; - if (i2c_smbus_access(file,I2C_SMBUS_READ,0,I2C_SMBUS_BYTE,&data)) { - return -1; - } else { - *buf = 0x0FF & data.byte; - return 0; - } -} -static int -i2_smbus_read_only(int busNum, short addr, dataType type, - int size,__u8 *buf) -{ - int i; - int fd; - int ret = -1; - char fname[20]; - - sprintf(fname, "/dev/i2c-%d", busNum); - fd = open(fname, O_RDWR); - - if(fd < 0) - return ret; - - ret = ioctl(fd, I2C_SLAVE, addr); - - if(LEN_BYTE == type) { - for(i=0; i> 8) & 0x0FF; - buf[2*i] = val & 0x0FF; - } - } - close(fd); - return ret; -} - - - -int i2c_smbus_write_pec(int busNum, short addr, __u8 reg, dataType type, - int pec_flag, __u8 *buf) -{ - int fd; - int ret = -1; - short val; - char fname[20]; - - sprintf(fname, "/dev/i2c-%d", busNum); - fd = open(fname, O_RDWR); - - if(fd < 0) - return ret; - - ret = ioctl(fd, I2C_SLAVE, addr); - ret = ioctl(fd, I2C_PEC, pec_flag); - if(LEN_BYTE == type) { - ret = i2c_smbus_write_byte_data(fd, reg, buf[0]); - } else { - val = (((unsigned short)(buf[1])) << 8) | buf[0]; - //val = (((unsigned short)(buf[2*i])) << 8) | buf[2*i+1]; - ret = i2c_smbus_write_word_data(fd, reg, val); - } - close(fd); - return ret; -} - -int i2c_smbus_write_block_data(int busNum, short addr, __u8 command, - __u8 length, const __u8 *values) -{ - union i2c_smbus_data data; - int i; - int fd; - int ret = -1; - char fname[20]; - - if (length > 32) - length = 32; - for (i = 1; i <= length; i++) - data.block[i] = values[i-1]; - data.block[0] = length; - - - sprintf(fname, "/dev/i2c-%d", busNum); - fd = open(fname, O_RDWR); - - if(fd < 0) - return ret; - - ret = ioctl(fd, I2C_SLAVE, addr); - ret = ioctl(fd, I2C_PEC, 1); - - ret = i2c_smbus_access(fd,I2C_SMBUS_WRITE,command, - I2C_SMBUS_BLOCK_DATA, &data); - close(fd); - return ret; -} - -int i2c_smbus_read_16reg(int busNum, short addr, short reg, - int size, __u8 *buf) -{ - int i; - int fd; - int ret = -1; - char regNum[2]; - char fname[20]; - struct i2c_rdwr_ioctl_data ioctl_data; - struct i2c_msg msgs[2]; - - sprintf(fname, "/dev/i2c-%d", busNum); - fd = open(fname, O_RDWR); - if(fd < 0) - return ret; - - ret = ioctl(fd, I2C_SLAVE, addr); - - for(i=0; i> 8) & 0x0FF; - msgs[0].addr= addr; - msgs[0].len= 2; - msgs[0].buf= regNum; - msgs[1].addr= addr; - msgs[1].flags |= I2C_M_RD; - msgs[1].len= 1; - msgs[1].buf= (char *)&buf[i]; - ioctl_data.nmsgs= 2; - ioctl_data.msgs= msgs; - ret = ioctl(fd, I2C_RDWR, &ioctl_data); - if(ret) - break; - } - close(fd); - return ret; -} -//obsoleted -int i2c_smbus_write_16reg(int busNum, short addr, short reg, - int size, const __u8 *buf) -{ - int i; - int fd; - int ret = -1; - char wBuf[3]; - char fname[20]; - struct i2c_rdwr_ioctl_data ioctl_data; - struct i2c_msg msg; - - sprintf(fname, "/dev/i2c-%d", busNum); - fd = open(fname, O_RDWR); - - if(fd < 0) - return ret; - ret = ioctl(fd, I2C_SLAVE, addr); - - for(i=0; i> 8) & 0x0FF; - wBuf[2] = buf[i]; - msg.addr= addr; - msg.flags = 0; - msg.len= 3; - msg.buf= wBuf; - ioctl_data.nmsgs= 1; - ioctl_data.msgs= &msg; - ret = ioctl(fd, I2C_RDWR, &ioctl_data); - if(ret) - break; - } - close(fd); - return ret; -} - -int i2c_smbus_write_16reg_8byte(int busNum, short addr, short reg, - int size, const __u8 *buf) -{ - int i; - int fd; - int ret = -1; - char wBuf[10]; - char fname[20]; - struct i2c_rdwr_ioctl_data ioctl_data; - struct i2c_msg msg; - - sprintf(fname, "/dev/i2c-%d", busNum); - fd = open(fname, O_RDWR); - - if(fd < 0) - return ret; - - for(i=0; i> 8) & 0x0FF; - memcpy(&wBuf[2],&buf[i], 8); - msg.addr= addr; - msg.flags = 0; - msg.len= 10+1; - msg.buf= wBuf; - ioctl_data.nmsgs= 1; - ioctl_data.msgs= &msg; - ret = ioctl(fd, I2C_RDWR, &ioctl_data); - if(ret) - break; - } - close(fd); - return ret; -} - -int chips_read_byte(char addr, __u8 reg, __u8 *data) -{ - char busNum = 1; - dataType type = LEN_BYTE; - int ret = -1; - ret = i2_smbus_read(busNum, addr, reg, type, 1, data); - return ret; -} - -int chips_read_word(char addr, __u8 reg, unsigned short *data) -{ - int busNum = 1; - unsigned char buf[2]; - dataType type = LEN_WORD; - int ret = -1; - ret = i2_smbus_read(busNum, addr, reg, type, 1, buf); - if(ret >= 0) - { - *data = ((unsigned short)buf[1] << 8) | buf[0]; - } - return ret; -} - -int -chips_write_word(char addr, __u8 reg, unsigned short data) -{ - int busNum = 1; - dataType type = LEN_WORD; - int ret = -1; - unsigned char buf[2] = - { (data >> 8) & 0x00ff, data & 0x00ff}; - ret = i2c_smbus_write(busNum, addr, reg, type, 1, (unsigned char *)&buf); - //ret = i2c_smbus_write(busNum, addr, reg, type, 1, (char *)&data); - return ret; -} - -int -chips_write_word_pec(char addr, __u8 reg, unsigned short data, int pec_flag) -{ - int busNum = 1; - dataType type = LEN_WORD; - int ret = -1; - ret = i2c_smbus_write_pec(busNum, addr, reg, type, pec_flag, (unsigned char *)&data); - return ret; -} - -int -chips_write_block(char addr, __u8 reg, int byteCnt, unsigned char* wrData) -{ - int busNum = 1; - int ret = -1; - - ret = i2c_smbus_write_block_data(busNum, addr, reg, byteCnt, wrData); - return ret; -} - -int -chips_write_byte(char addr, __u8 reg, const __u8 data) -{ - int busNum = 1; - dataType type = LEN_BYTE; - int ret = -1; - ret = i2c_smbus_write(busNum, addr, reg, type, 1, (unsigned char *)&data); - return ret; -} - -int -i2c_smbus_write(int busNum, short addr, __u8 reg, dataType type, - int size, __u8 *buf) -{ - int i; - int fd; - int ret = -1; - short val; - char fname[20]; - - sprintf(fname, "/dev/i2c-%d", busNum); - fd = open(fname, O_RDWR); - if(fd < 0) - return ret; - - ret = ioctl(fd, I2C_SLAVE, addr); - if(LEN_BYTE == type) - { - for(i=0; i> 8) & 0x0ff, mem_addr & 0x0ff }; - ret = i2c_write_2b(addr, buf); - - if (ret < 0) - return ret; - ret = i2_smbus_read_only(busNum, addr, type, 1, data); - return ret; -} - -int -eeprom_write_byte(char addr, __u16 mem_addr, __u8 data) -{ - __u8 buf[3] = - { (mem_addr >> 8) & 0x00ff, mem_addr & 0x00ff, data }; - return i2c_write_3b(addr, buf); -} - diff --git a/packages/platforms/celestica/x86-64/redstone-xp/onlp/builds/x86_64_cel_redstone_xp/module/src/i2c_dev.h b/packages/platforms/celestica/x86-64/redstone-xp/onlp/builds/x86_64_cel_redstone_xp/module/src/i2c_dev.h deleted file mode 100644 index 0262e6e51..000000000 --- a/packages/platforms/celestica/x86-64/redstone-xp/onlp/builds/x86_64_cel_redstone_xp/module/src/i2c_dev.h +++ /dev/null @@ -1,158 +0,0 @@ -#ifndef I2C_DEV_HH -#define I2C_DEV_HH - -#include -#include - -typedef enum data_len -{ - LEN_BYTE, - LEN_WORD, -}dataType; - -/* ----- commands for the ioctl like i2c_command call: - * note that additional calls are defined in the algorithm and hw - * dependent layers - these can be listed here, or see the - * corresponding header files. - */ - /* -> bit-adapter specific ioctls */ -#define I2C_RETRIES 0x0701 /* number of times a device address */ - /* should be polled when not */ - /* acknowledging */ -#define I2C_TIMEOUT 0x0702 /* set timeout - call with int */ - - -/* this is for i2c-dev.c */ -#define I2C_SLAVE 0x0703 /* Change slave address */ - /* Attn.: Slave address is 7 or 10 bits */ -#define I2C_SLAVE_FORCE 0x0706 /* Change slave address */ - /* Attn.: Slave address is 7 or 10 bits */ - /* This changes the address, even if it */ - /* is already taken! */ -#define I2C_TENBIT 0x0704 /* 0 for 7 bit addrs, != 0 for 10 bit */ - -#define I2C_FUNCS 0x0705 /* Get the adapter functionality */ -#define I2C_RDWR 0x0707 /* Combined R/W transfer (one stop only)*/ -#define I2C_PEC 0x0708 /* != 0 for SMBus PEC */ - -#define I2C_SMBUS 0x0720 /* SMBus-level access */ - -/* smbus_access read or write markers */ -#define I2C_SMBUS_READ 1 -#define I2C_SMBUS_WRITE 0 - -/* - * I2C Message - used for pure i2c transaction, also from /dev interface - */ -struct i2c_msg { - __u16 addr; /* slave address */ - unsigned short flags; -#define I2C_M_TEN 0x10 /* we have a ten bit chip address */ -#define I2C_M_RD 0x01 -#define I2C_M_NOSTART 0x4000 -#define I2C_M_REV_DIR_ADDR 0x2000 -#define I2C_M_IGNORE_NAK 0x1000 -#define I2C_M_NO_RD_ACK 0x0800 - short len; /* msg length */ - char *buf; /* pointer to msg data */ -}; - -/* To determine what functionality is present */ - -#define I2C_FUNC_I2C 0x00000001 -#define I2C_FUNC_10BIT_ADDR 0x00000002 -#define I2C_FUNC_PROTOCOL_MANGLING 0x00000004 /* I2C_M_{REV_DIR_ADDR,NOSTART,..} */ -#define I2C_FUNC_SMBUS_PEC 0x00000008 -#define I2C_FUNC_SMBUS_BLOCK_PROC_CALL 0x00008000 /* SMBus 2.0 */ -#define I2C_FUNC_SMBUS_QUICK 0x00010000 -#define I2C_FUNC_SMBUS_READ_BYTE 0x00020000 -#define I2C_FUNC_SMBUS_WRITE_BYTE 0x00040000 -#define I2C_FUNC_SMBUS_READ_BYTE_DATA 0x00080000 -#define I2C_FUNC_SMBUS_WRITE_BYTE_DATA 0x00100000 -#define I2C_FUNC_SMBUS_READ_WORD_DATA 0x00200000 -#define I2C_FUNC_SMBUS_WRITE_WORD_DATA 0x00400000 -#define I2C_FUNC_SMBUS_PROC_CALL 0x00800000 -#define I2C_FUNC_SMBUS_READ_BLOCK_DATA 0x01000000 -#define I2C_FUNC_SMBUS_WRITE_BLOCK_DATA 0x02000000 -#define I2C_FUNC_SMBUS_READ_I2C_BLOCK 0x04000000 /* I2C-like block xfer */ -#define I2C_FUNC_SMBUS_WRITE_I2C_BLOCK 0x08000000 /* w/ 1-byte reg. addr. */ - -#define I2C_FUNC_SMBUS_BYTE (I2C_FUNC_SMBUS_READ_BYTE | \ - I2C_FUNC_SMBUS_WRITE_BYTE) -#define I2C_FUNC_SMBUS_BYTE_DATA (I2C_FUNC_SMBUS_READ_BYTE_DATA | \ - I2C_FUNC_SMBUS_WRITE_BYTE_DATA) -#define I2C_FUNC_SMBUS_WORD_DATA (I2C_FUNC_SMBUS_READ_WORD_DATA | \ - I2C_FUNC_SMBUS_WRITE_WORD_DATA) -#define I2C_FUNC_SMBUS_BLOCK_DATA (I2C_FUNC_SMBUS_READ_BLOCK_DATA | \ - I2C_FUNC_SMBUS_WRITE_BLOCK_DATA) -#define I2C_FUNC_SMBUS_I2C_BLOCK (I2C_FUNC_SMBUS_READ_I2C_BLOCK | \ - I2C_FUNC_SMBUS_WRITE_I2C_BLOCK) - -/* Old name, for compatibility */ -#define I2C_FUNC_SMBUS_HWPEC_CALC I2C_FUNC_SMBUS_PEC - -/* - * Data for SMBus Messages - */ -#define I2C_SMBUS_BLOCK_MAX 32 /* As specified in SMBus standard */ -#define I2C_SMBUS_I2C_BLOCK_MAX 32 /* Not specified but we use same structure */ - -union i2c_smbus_data { - __u8 byte; - __u16 word; - __u8 block[I2C_SMBUS_BLOCK_MAX + 2]; /* block[0] is used for length */ - /* and one more for PEC */ -}; - -/* SMBus transaction types (size parameter in the above functions) - Note: these no longer correspond to the (arbitrary) PIIX4 internal codes! */ -#define I2C_SMBUS_QUICK 0 -#define I2C_SMBUS_BYTE 1 -#define I2C_SMBUS_BYTE_DATA 2 -#define I2C_SMBUS_WORD_DATA 3 -#define I2C_SMBUS_PROC_CALL 4 -#define I2C_SMBUS_BLOCK_DATA 5 -#define I2C_SMBUS_I2C_BLOCK_BROKEN 6 -#define I2C_SMBUS_BLOCK_PROC_CALL 7 /* SMBus 2.0 */ -#define I2C_SMBUS_I2C_BLOCK_DATA 8 - - -/* This is the structure as used in the I2C_SMBUS ioctl call */ -struct i2c_smbus_ioctl_data { - __u8 read_write; - __u8 command; - __u32 size; - union i2c_smbus_data *data; -}; - -/* This is the structure as used in the I2C_RDWR ioctl call */ -struct i2c_rdwr_ioctl_data { - struct i2c_msg *msgs; /* pointers to i2c_msgs */ - __u32 nmsgs; /* number of i2c_msgs */ -}; - -int i2_smbus_read(int busNum, short addr, __u8 reg, dataType type, - int size, __u8 *buf); -int i2c_smbus_write(int busNum, short addr, __u8 reg, dataType type, - int size, __u8 *buf); -int i2c_smbus_write_pec(int busNum, short addr, __u8 reg, dataType type, - int pec_flag, __u8 *buf); -int chips_write_block(char addr, __u8 reg, int byteCnt, unsigned char* wrData); - -int i2c_smbus_read_16reg(int busNum, short addr, short reg, - int size, __u8 *buf); -int i2c_smbus_write_16reg(int busNum, short addr, short reg, - int size, const __u8 *buf); -int i2c_smbus_write_16reg_8byte(int busNum, short addr, short reg, - int size, const __u8 *buf); -int chips_read_byte(char addr, __u8 reg, __u8 *data); -int chips_write_byte(char addr, __u8 reg, const __u8 data); -int chips_read_word(char addr, __u8 reg, unsigned short *data); -int chips_write_word(char addr, __u8 reg, unsigned short data); -int chips_write_word_pec(char addr, __u8 reg, unsigned short data, int pec_flag); - - -int eeprom_read_byte(char addr, __u16 mem_addr, __u8 *data); -int eeprom_write_byte(char addr, __u16 mem_addr, __u8 data); - -#endif diff --git a/packages/platforms/celestica/x86-64/redstone-xp/onlp/builds/x86_64_cel_redstone_xp/module/src/ledi.c b/packages/platforms/celestica/x86-64/redstone-xp/onlp/builds/x86_64_cel_redstone_xp/module/src/ledi.c deleted file mode 100644 index 63a052104..000000000 --- a/packages/platforms/celestica/x86-64/redstone-xp/onlp/builds/x86_64_cel_redstone_xp/module/src/ledi.c +++ /dev/null @@ -1,141 +0,0 @@ -#include -#include -#include -#include -#include - -#include "i2c_chips.h" -#include "platform.h" - -/* - * Get the information for the given LED OID. - */ -static onlp_led_info_t led_info[] = -{ - { - { ONLP_LED_ID_CREATE(LED_SYSTEM), "Chassis System LED(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_FAN_1), "Chassis FAN(1) 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_ID_CREATE(LED_FAN_2), "Chassis FAN(2) 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_ID_CREATE(LED_FAN_3), "Chassis FAN(3) 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_ID_CREATE(LED_FAN_4), "Chassis FAN(4) 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_ID_CREATE(LED_FAN_5), "Chassis FAN(5) 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_ID_CREATE(LED_FAN_6), "Chassis FAN(6) 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_ID_CREATE(LED_FAN_7), "Chassis FAN(7) 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_ID_CREATE(LED_FAN_8), "Chassis FAN(8) 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_ID_CREATE(LED_PSU_1), "Chassis PSU(1) 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_ID_CREATE(LED_PSU_2), "Chassis PSU(2) LED", 0 }, - ONLP_LED_STATUS_PRESENT, - ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_ORANGE | ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_AUTO, - } -}; - -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) - 1; - - *info = led_info[led_id]; - info->status |= ONLP_LED_STATUS_ON; - info->mode |= ONLP_LED_MODE_ON; - - return ONLP_STATUS_OK; -} - -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); - else - return onlp_ledi_mode_set(id, ONLP_LED_MODE_ON); -} - -int -onlp_ledi_mode_set(onlp_oid_t id, onlp_led_mode_t mode) -{ - int led_id, psu; - - led_id = ONLP_OID_ID_GET(id) - 1; - switch (led_id) { - case LED_SYSTEM: - if (mode == ONLP_LED_MODE_OFF) - setSysLedOff(); - else - setSysLedOn(); - break; - case LED_FAN_1: - case LED_FAN_2: - case LED_FAN_3: - case LED_FAN_4: - case LED_FAN_5: - case LED_FAN_6: - case LED_FAN_7: - case LED_FAN_8: - if (mode == ONLP_LED_MODE_OFF) - setFanLedOff(led_id); - else - setFanLedGreen(led_id); - break; - case LED_PSU_1: - case LED_PSU_2: - psu = led_id - LED_PSU_1; - if (mode == ONLP_LED_MODE_OFF) - setPsuLedOn(psu); - else - setPsuLedOff(psu); - break; - default: - return ONLP_STATUS_E_INTERNAL; - break; - } - return ONLP_STATUS_OK; -} diff --git a/packages/platforms/celestica/x86-64/redstone-xp/onlp/builds/x86_64_cel_redstone_xp/module/src/make.mk b/packages/platforms/celestica/x86-64/redstone-xp/onlp/builds/x86_64_cel_redstone_xp/module/src/make.mk deleted file mode 100644 index d7345b178..000000000 --- a/packages/platforms/celestica/x86-64/redstone-xp/onlp/builds/x86_64_cel_redstone_xp/module/src/make.mk +++ /dev/null @@ -1,9 +0,0 @@ -############################################################################### -# -# -# -############################################################################### - -LIBRARY := x86_64_cel_redstone_xp -$(LIBRARY)_SUBDIR := $(dir $(lastword $(MAKEFILE_LIST))) -include $(BUILDER)/lib.mk diff --git a/packages/platforms/celestica/x86-64/redstone-xp/onlp/builds/x86_64_cel_redstone_xp/module/src/platform.h b/packages/platforms/celestica/x86-64/redstone-xp/onlp/builds/x86_64_cel_redstone_xp/module/src/platform.h deleted file mode 100644 index 8753f4247..000000000 --- a/packages/platforms/celestica/x86-64/redstone-xp/onlp/builds/x86_64_cel_redstone_xp/module/src/platform.h +++ /dev/null @@ -1,28 +0,0 @@ -#ifndef _PLATFORM_REDSTONE_H_ -#define _PLATFORM_REDSTONE_H_ - -#define FAN_COUNT 10 -#define PSU_FAN 8 -#define THERMAL_COUNT 6 -#define LED_COUNT 11 - -#define THERMAL_MAIN_BOARD_REAR 0 -#define THERMAL_BCM 1 -#define THERMAL_CPU 2 -#define THERMAL_MAIN_BOARD_FRONT 3 -#define THERMAL_PSU1 4 -#define THERMAL_PSU2 5 - -#define LED_SYSTEM 0 -#define LED_FAN_1 1 -#define LED_FAN_2 2 -#define LED_FAN_3 3 -#define LED_FAN_4 4 -#define LED_FAN_5 5 -#define LED_FAN_6 6 -#define LED_FAN_7 7 -#define LED_FAN_8 8 -#define LED_PSU_1 9 -#define LED_PSU_2 10 - -#endif /* _PLATFORM_REDSTONE_H_ */ diff --git a/packages/platforms/celestica/x86-64/redstone-xp/onlp/builds/x86_64_cel_redstone_xp/module/src/psui.c b/packages/platforms/celestica/x86-64/redstone-xp/onlp/builds/x86_64_cel_redstone_xp/module/src/psui.c deleted file mode 100644 index a3f426cc7..000000000 --- a/packages/platforms/celestica/x86-64/redstone-xp/onlp/builds/x86_64_cel_redstone_xp/module/src/psui.c +++ /dev/null @@ -1,50 +0,0 @@ -#include - -#include "i2c_chips.h" -#include "platform.h" - -static -onlp_psu_info_t psu_info[] = -{ - { - { ONLP_PSU_ID_CREATE(1), "PSU-1", 0 }, - }, - { - { ONLP_PSU_ID_CREATE(2), "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 psu_id; - struct psuInfo psu; - - psu_id = ONLP_OID_ID_GET(id) - 1; - *info = psu_info[psu_id]; - - if (!getPsuPresent(psu_id)) - info->status |= ONLP_PSU_STATUS_PRESENT; - else - return ONLP_STATUS_E_MISSING; - - getPsuInfo(psu_id, &psu); - - info->mvin = psu.vin; - info->mvout = psu.vout; - info->miin = psu.iin; - info->miout = psu.iout; - info->mpin = psu.pin; - info->mpout = psu.pout; - - if (!(info->mpin)) - info->status |= ONLP_PSU_STATUS_UNPLUGGED; - - return ONLP_STATUS_OK; -} diff --git a/packages/platforms/celestica/x86-64/redstone-xp/onlp/builds/x86_64_cel_redstone_xp/module/src/redstone_cpld.c b/packages/platforms/celestica/x86-64/redstone-xp/onlp/builds/x86_64_cel_redstone_xp/module/src/redstone_cpld.c deleted file mode 100644 index f70b3178a..000000000 --- a/packages/platforms/celestica/x86-64/redstone-xp/onlp/builds/x86_64_cel_redstone_xp/module/src/redstone_cpld.c +++ /dev/null @@ -1,322 +0,0 @@ -#include -#include -#include - -#include -#include "x86_64_cel_redstone_xp_log.h" -#include "x86_64_cel_redstone_xp_int.h" -#include "redstone_cpld.h" - -int -cpld_io_init(void) -{ - /* Initialize LPC access ports */ - if(ioperm(0x100, 0x2FF, 1) == -1) { - AIM_LOG_ERROR("ioperm() failed: %{errno}", errno); - return -1; - } - return 0; -} - -int -cpld_read(int addr) -{ - return inb(addr); -} - -void -cpld_write(int addr, uint8_t value) -{ - outb(value, addr); -} - -int read_cpld(int reg, unsigned char *value) -{ - *value = inb(reg); - return 0; -} -int write_cpld(int reg, unsigned char value) -{ - outb(value, reg); - return 0; -} - -void -cpld_modify(int addr, uint8_t andmask, uint8_t ormask) -{ - int v; - read_cpld(addr, (unsigned char *)&v); - v &= andmask; - v |= ormask; - cpld_write(addr, v); -} - -int -cpld_dump(aim_pvs_t* pvs, int cpldid) -{ - int data; - - aim_map_si_t* si; - aim_map_si_t* maps[] = { - cpld1_reg_map, - cpld2_reg_map, - cpld3_reg_map, - cpld4_reg_map, - cpld5_reg_map, - }; - if(cpldid < 1 || cpldid > 5) { - aim_printf(pvs, "Invalid CPLDID %d\n", cpldid); - return -1; - } - else { - for(si = maps[cpldid-1]; si->s; si++) { - read_cpld(si->i, (unsigned char *)&data); - aim_printf(pvs, " %32.32s [0x%.2x] = 0x%.2x %{8bits}\n", si->s, si->i, data, data); - } - } - return 0; -} - - -#define PORT_BANK1_START 1 -#define PORT_BANK1_END 18 -#define PORT_BANK2_START 19 -#define PORT_BANK2_END 36 -#define PORT_BANK3_START 37 -#define PORT_BANK3_END 48 -#define PORT_BANK4_START 49 -#define PORT_BANK4_END 54 -int -read_sfp(int portID, char devAddr, char reg, char *data, int len) -{ - int count; - char byte; - short temp; - short portid, opcode, devaddr, cmdbyte0, ssrr, writedata = 0, readdata; - int ioBase = 0; - - cpld_io_init(); - - if ((reg + len) > 256) - return -1; - - if ((portID >= PORT_BANK1_START) && (portID <= PORT_BANK1_END)) { - portid = 0x210; - opcode = 0x211; - devaddr = 0x212; - cmdbyte0 = 0x213; - ssrr = 0x216; - writedata = 0x220; - readdata = 0x230; - - while ((inb(ioBase + ssrr) & 0x40)); - - if ((inb(ioBase + ssrr) & 0x80) == 0x80) { - outb(0x00, ioBase + ssrr); - usleep(3000); - outb(0x01, ioBase + ssrr); - return -1; - } - } else if ((portID >= PORT_BANK2_START) && (portID <= PORT_BANK2_END)) { - portid = 0x290; - opcode = 0x291; - devaddr = 0x292; - cmdbyte0 = 0x293; - ssrr = 0x296; - writedata = 0x2A0; - readdata = 0x2B0; - - while ((inb(ioBase + ssrr) & 0x40)); - - if ((inb(ioBase + ssrr) & 0x80) == 0x80) { - outb(0x00, ioBase + ssrr); - usleep(3000); - outb(0x01, ioBase + ssrr); - return -1; - } - } else if ((portID >= PORT_BANK3_START) && (portID <= PORT_BANK3_END)) { - portid = 0x390; - opcode = 0x391; - devaddr = 0x392; - cmdbyte0 = 0x393; - ssrr = 0x396; - writedata = 0x3A0; - readdata = 0x3B0; - - while ((inb(ioBase + ssrr) & 0x40)); - - if ((inb(ioBase + ssrr) & 0x80) == 0x80) { - outb(0x00, ioBase + ssrr); - usleep(3000); - outb(0x01, ioBase + ssrr); - return -1; - } - } else if ((portID >= PORT_BANK4_START) && (portID <= PORT_BANK4_END)) { - portid = 0x310; - opcode = 0x311; - devaddr = 0x312; - cmdbyte0 = 0x313; - ssrr = 0x316; - writedata = 0x320; - readdata = 0x330; - - while ((inb(ioBase + ssrr) & 0x40)); - - if ((inb(ioBase + ssrr) & 0x80) == 0x80) { - outb(0x00, ioBase + ssrr); - usleep(3000); - outb(0x01, ioBase + ssrr); - return -1; - } - } else { - return -1; - } - - byte = 0x40 + portID; - outb(byte, ioBase + portid); - outb(reg,ioBase + cmdbyte0); - - while (len > 0) { - count = (len >= 8) ? 8 : len; - len -= count; - byte = count * 16 + 1; - outb(byte, ioBase + opcode); - devAddr |= 0x01; - outb(devAddr, ioBase + devaddr); - - while ((inb(ioBase + ssrr) & 0x40)) - usleep(100); - - if ((inb(ioBase + ssrr) & 0x80) == 0x80) { - outb(0x00, ioBase + ssrr); - usleep(3000); - outb(0x01, ioBase + ssrr); - return -1; - } - - temp = ioBase + readdata; - - while (count-- > 0) { - char read_byte; - read_byte = inb(temp); - *(data++) = read_byte; - temp++; - } - - if (len > 0) { - reg += 0x08; - outb(reg, ioBase + cmdbyte0); - } - } - return writedata * 0; -} - -int -write_sfp(int portID, char devAddr, char reg, char *data, int len) -{ - int count; - char byte; - short temp; - short portid, opcode, devaddr, cmdbyte0, ssrr, writedata, readdata; - int ioBase = 0; - - if ((reg + len) > 256) - return -1; - - if ((portID >= PORT_BANK1_START) && (portID <= PORT_BANK1_END)) { - portid = 0x210; - opcode = 0x211; - devaddr = 0x212; - cmdbyte0 = 0x213; - ssrr = 0x216; - writedata = 0x220; - readdata = 0x230; - while ((inb(ioBase + ssrr) & 0x40)); - if ((inb(ioBase + ssrr) & 0x80) == 0x80) { - outb(0x00, ioBase + ssrr); - usleep(3000); - outb(0x01, ioBase + ssrr); - return -1; - } - } else if ((portID >= PORT_BANK2_START) && (portID <= PORT_BANK2_END)) { - portid = 0x290; - opcode = 0x291; - devaddr = 0x292; - cmdbyte0 = 0x293; - ssrr = 0x296; - writedata = 0x2A0; - readdata = 0x2B0; - while ((inb(ioBase + ssrr) & 0x40)); - if ((inb(ioBase + ssrr) & 0x80) == 0x80) { - outb(0x00, ioBase + ssrr); - usleep(3000); - outb(0x01, ioBase + ssrr); - return -1; - } - } else if ((portID >= PORT_BANK3_START) && (portID <= PORT_BANK3_END)) { - portid = 0x390; - opcode = 0x391; - devaddr = 0x392; - cmdbyte0 = 0x393; - ssrr = 0x396; - writedata = 0x3A0; - readdata = 0x3B0; - while ((inb(ioBase + ssrr) & 0x40)); - if ((inb(ioBase + ssrr) & 0x80) == 0x80) { - outb(0x00, ioBase + ssrr); - usleep(3000); - outb(0x01, ioBase + ssrr); - return -1; - } - } else if ((portID >= PORT_BANK4_START) && (portID <= PORT_BANK4_END)) { - portid = 0x310; - opcode = 0x311; - devaddr = 0x312; - cmdbyte0 = 0x313; - ssrr = 0x316; - writedata = 0x320; - readdata = 0x330; - while ((inb(ioBase + ssrr) & 0x40)); - if ((inb(ioBase + ssrr) & 0x80) == 0x80) { - outb(0x00, ioBase + ssrr); - usleep(3000); - outb(0x01, ioBase + ssrr); - return -1; - } - } else { - return -1; - } - - byte = 0x40 + portID; - outb(byte, ioBase + portid); - outb(reg, ioBase + cmdbyte0); - while (len > 0) { - count = (len >= 8) ? 8 : len; - len -= count; - byte = (count << 4) + 1; - outb(byte, ioBase + opcode); - temp = ioBase + writedata; - while (count-- > 0) { - outb(*(data++), temp); - temp += 0x01; - } - devAddr &= 0xfe; - outb(devAddr, ioBase + devaddr); - while ((inb(ioBase + ssrr) & 0x40)) - { - usleep(100); - } - if ((inb(ioBase + ssrr) & 0x80) == 0x80) { - outb(0x00, ioBase + ssrr); - usleep(3000); - outb(0x01, ioBase + ssrr); - return -1; - } - if (len > 0) { - reg += 0x08; - outb(ioBase + cmdbyte0, reg); - } - } - return writedata * readdata * 0; -} - diff --git a/packages/platforms/celestica/x86-64/redstone-xp/onlp/builds/x86_64_cel_redstone_xp/module/src/redstone_cpld.h b/packages/platforms/celestica/x86-64/redstone-xp/onlp/builds/x86_64_cel_redstone_xp/module/src/redstone_cpld.h deleted file mode 100644 index 2dffc7b2c..000000000 --- a/packages/platforms/celestica/x86-64/redstone-xp/onlp/builds/x86_64_cel_redstone_xp/module/src/redstone_cpld.h +++ /dev/null @@ -1,69 +0,0 @@ -#ifndef _REDSTONE_CPLD_H_ -#define _REDSTONE_CPLD_H_ - -#include -#include -#include - -#define BIT0 0x1 -#define BIT1 0x1 << 1 -#define BIT2 0x1 << 2 -#define BIT3 0x1 << 3 -#define BIT4 0x1 << 4 -#define BIT5 0x1 << 5 -#define BIT6 0x1 << 6 -#define BIT7 0x1 << 7 - -typedef struct RegData -{ - unsigned short regId; /*register number*/ - char val; /*register value*/ - unsigned char rw; /*0:read 1:write*/ -}RegData_t; - -typedef struct SfpData -{ - char regId; - int portId; - char devAddr; - char val[256]; - unsigned char rw; - unsigned char len; -}SfpData_t; - -#define CPLD_TYPE ( 0x89 ) -#define IOCTL_READ_REG _IOR(CPLD_TYPE,0x05,RegData_t) -#define IOCTL_WRITE_REG _IOW(CPLD_TYPE,0x08,RegData_t) -#define IOCTL_SFP_READ _IOR(CPLD_TYPE,0x0F,RegData_t) -#define IOCTL_SFP_WRITE _IOW(CPLD_TYPE,0x10,RegData_t) - -#define CPLD1_REVISION 0x100 -#define CPLD_RESET_CONTROL 0x102 - -#define CPLD2_REVISION 0x200 -#define CPLD3_REVISION 0x280 -#define CPLD4_REVISION 0x300 -#define CPLD5_REVISION 0x380 -#define CPLD_FAN_PRESENT 0x194 -#define CPLD_FAN_STATUS_1 0x195 -#define CPLD_FAN_STATUS_2 0x195 -#define CPLD_PSU_STATUS 0x197 -#define CPLD_FP_LED 0x303 - - -int cpldRegRead(int regId, unsigned char *data, int size); -int cpldRegWrite(int regId, unsigned char *data, int size); -int cpldVersionGet(int cpld); - -int read_cpld(int reg, unsigned char *value); -int write_cpld(int reg, unsigned char value); -int read_sfp(int portID, char devAddr, char reg, char *data, int len); -int write_sfp(int portID, char devAddr, char reg, char *data, int len); - -int cpld_io_init(void); -int cpld_read(int addr); -void cpld_write(int addr, uint8_t value); -void cpld_modify(int addr, uint8_t andmask, uint8_t ormask); -int cpld_dump(aim_pvs_t* pvs, int cpldid); - -#endif /* _REDSTONE_CPLD_H_ */ diff --git a/packages/platforms/celestica/x86-64/redstone-xp/onlp/builds/x86_64_cel_redstone_xp/module/src/sfp_xfp.h b/packages/platforms/celestica/x86-64/redstone-xp/onlp/builds/x86_64_cel_redstone_xp/module/src/sfp_xfp.h deleted file mode 100644 index 2d51782c6..000000000 --- a/packages/platforms/celestica/x86-64/redstone-xp/onlp/builds/x86_64_cel_redstone_xp/module/src/sfp_xfp.h +++ /dev/null @@ -1,294 +0,0 @@ -#ifndef INCLUDE_SFP_XFP -#define INCLUDE_SFP_XFP - -/* SFP I2C parameters start here */ -/* 0xA0 */ -#define SFP_REVISION_ADDR 56 -#define SFP_REVISION_SIZE 1 -#define SFP_DIAGMODE_ADDR 92 -#define SFP_DIAGMODE_SIZE 1 -#define SFP_COMPLIANCE_ADDR 94 -#define SFP_COMPLIANCE_SIZE 1 -#define SFP_COMPLIANCE_NONE 0 -#define SFP_OPTIONS_ADDR 65 -#define SFP_OPTIONS_SIZE 1 -#define SFP_DIAGMODE_EXTERNAL_CALIBRATION_MASK 0x10 /* bit 4 */ -#define SFP_TX_FAULT_SUPPORT_MASK (1<<3) /* Table 3.7, Options, byte 65, bit 3 */ -#define SFP_TX_FAULT_MASK (1<<2) /* Table 3.17, A/D Values and Status Bits, byte 110, bit 2 */ -#define SFP_LOS_MASK (1<<1) /* Table 3.17, A/D Values and Status Bits, byte 110, bit 1 */ -#define SFP_RX_POWER_PHANTOM_READ 0 - -/* 0xA2 */ -/* Calibration constants */ -#define SFP_RX_PWR4_ADDR 56 -#define SFP_RX_PWR4_SIZE 4 -#define SFP_RX_PWR3_ADDR 60 -#define SFP_RX_PWR3_SIZE 4 -#define SFP_RX_PWR2_ADDR 64 -#define SFP_RX_PWR2_SIZE 4 -#define SFP_RX_PWR1_ADDR 68 -#define SFP_RX_PWR1_SIZE 4 -#define SFP_RX_PWR0_ADDR 72 -#define SFP_RX_PWR0_SIZE 4 -#define SFP_TX_CURRENT_SLOPE_ADDR 76 -#define SFP_TX_CURRENT_SLOPE_SIZE 2 -#define SFP_TX_CURRENT_OFFSET_ADDR 78 -#define SFP_TX_CURRENT_OFFSET_SIZE 2 -#define SFP_TX_POWER_SLOPE_ADDR 80 -#define SFP_TX_POWER_SLOPE_SIZE 2 -#define SFP_TX_POWER_OFFSET_ADDR 82 -#define SFP_TX_POWER_OFFSET_SIZE 2 -#define SFP_T_SLOPE_ADDR 84 -#define SFP_T_SLOPE_SIZE 2 -#define SFP_T_OFFSET_ADDR 86 -#define SFP_T_OFFSET_SIZE 2 -#define SFP_V_SLOPE_ADDR 88 -#define SFP_V_SLOPE_SIZE 2 -#define SFP_V_OFFSET_ADDR 90 -#define SFP_V_OFFSET_SIZE 2 - -/* 0xAC */ -/* Registers (0-31) */ -#define SFP_COPPER_PHY_CNTRL 0 /* Control Register */ -#define SFP_COPPER_PHY_STATUS 1 /* Status Register */ -#define SFP_COPPER_PHY_ID0 2 /* PHY Identifier */ -#define SFP_COPPER_PHY_ID1 3 /* PHY Identifier */ -#define SFP_COPPER_PHY_SPEC_STATUS 17 /* PHY Specific Status Register */ -#define SFP_COPPER_PHY_EXT_ADDR 22 /* Extended Address for Cable Diagnostic Reg */ -#define SFP_COPPER_PHY_CABLE_DIAG 28 /* GE interface Cable Diagnostic Registers */ -#define SFP_COPPER_PHY_REG29 29 /* Reg. 29 */ -#define SFP_COPPER_PHY_REG30 30 /* Reg. 30 */ -#define SFP_COPPER_PHY_REG31 31 /* Reg. 31 */ - -#define SFP_COPPER_PHY_OUI 0x0141 -#define SFP_COPPER_PHY_MODEL_MASK 0x03F0 - -#define SFP_IF_ERROR_RETURN(op) do { int __rc__; if ((__rc__ = (op)) < 0) return(L7_FAILURE); } while(0) - -/********************************************************************* -* In addition to the hardware specs, please see Application Note AN-2030 -* available from FINISAR. -*********************************************************************/ -#define SFP_XFP_FINISAR_OUI 0x009065 -#define SFP_XFP_TYPE_ADDR 0 -#define SFP_XFP_TYPE_SFP 0x03 -#define SFP_XFP_TYPE_SFP_PLUS 0x03 -#define SFP_XFP_TYPE_XFP 0x06 -#define SFP_XFP_TEMPERATURE_ADDR 96 -#define SFP_XFP_TEMPERATURE_SIZE 2 -#define SFP_XFP_VOLTAGE_ADDR 98 -#define SFP_XFP_VOLTAGE_SIZE 2 -#define SFP_XFP_CURRENT_ADDR 100 -#define SFP_XFP_CURRENT_SIZE 2 -#define SFP_XFP_TX_POWER_ADDR 102 -#define SFP_XFP_TX_POWER_SIZE 2 -#define SFP_XFP_RX_POWER_ADDR 104 -#define SFP_XFP_RX_POWER_SIZE 2 -#define SFP_XFP_LOS_ADDR 110 -#define SFP_XFP_LOS_SIZE 1 - -#define SFP_VENDOR_NAME_ADDR 20 -#define SFP_VENDOR_OUI_ADDR 37 -#define SFP_VENDOR_OUI_SIZE 3 -#define SFP_VENDOR_PN_ADDR 40 -#define SFP_VENDOR_REV_ADDR 56 -#define SFP_VENDOR_SN_ADDR 68 -#define SFP_VENDOR_DATE_ADDR 84 -#define SFP_VENDOR_DATE_SIZE 8 -#define SFP_NOMINAL_SIG_RATE_ADDR 12 -#define SFP_NOMINAL_SIG_RATE_SIZE 1 -#define SFP_LINK_LENGTH_50UM_ADDR 16 -#define SFP_LINK_LENGTH_50UM_SIZE 1 -#define SFP_LINK_LENGTH_62_5UM_ADDR 17 -#define SFP_LINK_LENGTH_62_5UM_SIZE 1 -#define SFP_WAVELENGTH_ADDR 60 -#define SFP_WAVELENGTH_SIZE 2 -#define SFP_DAC_LENGTH_ADDR 18 -#define SFP_DAC_LENGTH_SIZE 1 - - -#define QSFP_ADDRESS_DELTA 128 -#define QSFP_TEMPERATURE_ADDR 22 -#define QSFP_VOLTAGE_ADDR 26 -#define QSFP_TX_FAULT_ADDR 4 -#define QSFP_LOS_ADDR 3 -#define QSFP_RX_POWER_ADDR 34 -#define QSFP_TX_POWER_ADDR 42 -#define QSFP_VENDOR_NAME_ADDR 148 -#define QSFP_VENDOR_NAME_SIZE 16 -#define QSFP_VENDOR_PN_ADDR 168 -#define QSFP_VENDOR_PN_SIZE 16 -#define QSFP_VENDOR_SN_ADDR 196 -#define QSFP_VENDOR_SN_SIZE 16 -#define QSFP_VENDOR_REV_ADDR 184 -#define QSFP_VENDOR_REV_SIZE 2 -#define QSFP_NOMINAL_SIG_RATE_ADDR 140 -#define QSFP_NOMINAL_SIG_RATE_SIZE 1 -#define QSFP_LINK_LENGTH_50UM_ADDR 144 -#define QSFP_LINK_LENGTH_50UM_SIZE 1 -#define QSFP_LINK_LENGTH_62_5UM_ADDR 145 -#define QSFP_LINK_LENGTH_62_5UM_SIZE 1 -#define QSFP_WAVELENGTH_ADDR 186 -#define QSFP_WAVELENGTH_SIZE 2 -#define QSFP_DAC_LENGTH_ADDR 146 -#define QSFP_DAC_LENGTH_SIZE 1 -#define QSFP_ETHERNET_COMPLIANCE_ADDR 131 -#define QSFP_ETHERNET_COMPLIANCE_SIZE 1 - -/* - * SFF Committee - * SFF-8436 Specification - * QSFP+ 10 Gbs 4X PLUGGABLE TRANSCEIVER - * Rev 4.5 January 7, 2013 - * - * Table 33, Address 131 Bits - */ -#define QSFP_ETHERNET_COMPLIANCE_RESERVED (1 << 7) -#define QSFP_ETHERNET_COMPLIANCE_10GBASE_LRM (1 << 6) -#define QSFP_ETHERNET_COMPLIANCE_10GBASE_LR (1 << 5) -#define QSFP_ETHERNET_COMPLIANCE_10GBASE_SR (1 << 4) -#define QSFP_ETHERNET_COMPLIANCE_40GBASE_CR4 (1 << 3) -#define QSFP_ETHERNET_COMPLIANCE_40GBASE_SR4 (1 << 2) -#define QSFP_ETHERNET_COMPLIANCE_40GBASE_LR4 (1 << 1) -#define QSFP_ETHERNET_COMPLIANCE_40GACTIVE (1 << 0) -/* -SFF Committee -INF-8077i -10 Gigabit Small Form Factor Pluggable Module -Revision 4.5 August 31, 2005 -*/ - -#define XFP_AUX1_ADDR 106 -#define XFP_AUX2_ADDR 108 -#define XFP_AUX_CONFIG 222 -#define XFP_AUX_SIZE 2 -#define XFP_PAGE_SELECT 127 -/* from table 59 of INF-8077i */ -#define XFP_AUX_INPUT_NONE 0 -#define XFP_AUX_INPUT_BIAS_VOLTAGE 1 -#define XFP_AUX_INPUT_TEC_CURRENT 3 -#define XFP_AUX_INPUT_LASER_TEMP 4 -#define XFP_AUX_INPUT_LASER_WAVE 5 -#define XFP_AUX_INPUT_5_VOLTAGE 6 -#define XFP_AUX_INPUT_3_3_VOLTAGE 7 -#define XFP_AUX_INPUT_1_8_VOLTAGE 8 -#define XFP_AUX_INPUT_MASK 0xF -#define XFP_FAULT_ADDR 111 -#define XFP_FAULT_SIZE 1 -#define XFP_TX_FAULT_MASK (1<<6) /* Table 42 General Control/Status Bits, byte 111, bit 6 */ - -#define XFP_VENDOR_NAME_ADDR 148 -#define XFP_VENDOR_NAME_SIZE 15 -#define XFP_VENDOR_PN_ADDR 168 -#define XFP_VENDOR_PN_SIZE 16 -#define XFP_VENDOR_SN_ADDR 196 -#define XFP_VENDOR_SN_SIZE 16 -#define XFP_VENDOR_DATE_ADDR 212 -#define XFP_VENDOR_DATE_SIZE 8 -#define XFP_VENDOR_OUI_ADDR 165 -#define XFP_VENDOR_OUI_SIZE 3 -#define XFP_VENDOR_REV_ADDR 184 -#define XFP_VENDOR_REV_SIZE 2 - -/* Validation of the modules in the hpcIsValidXxx() routine */ -/* Controls wheter the hpcIsValidXxx() actually tries to read the */ -/* xFP signature from the pluggable module. */ -#define SFP_VALIDATE_MODULE 0 -#define XFP_VALIDATE_MODULE 1 -#define SFP_SFPPLUS_VALIDATE_MODULE 1 - - -#define SFF8472_ID_ADDR 0 -#define SFF8472_EXT_ID_ADDR 1 -#define SFF8472_10G_COMPLIANCE_ADDR 3 -#define SFF8472_ETHERNET_COMPLIANCE_ADDR 6 -#define SFF8472_SFPPLUS_CABLE_TECH_ADDR 8 -#define SFF8472_BIT_RATE_ADDR 12 - - -#define SFF8472_DIAG_MON_TYPE_ADDR 92 -#define SFF8472_DIAG_MON_TYPE_SIZE 1 -#define SFF8472_COMPLIANCE_ADDR 94 -#define SFF8472_COMPLIANCE_SIZE 1 - -#define SFF8436_COMPLIANCE_ADDR 131 -#define SFF8436_COMPLIANCE_SIZE 1 - -#define SFF8436_40G_ACTIVE (1 << 0) -#define SFF8436_40G_BASE_LR4 (1 << 1) -#define SFF8436_40G_BASE_SR4 (1 << 2) -#define SFF8436_40G_BASE_CR4 (1 << 3) -#define SFF8436_10G_BASE_SR (1 << 4) -#define SFF8436_10G_BASE_LR (1 << 5) -#define SFF8436_10G_BASE_LRM (1 << 6) - - -#define SFF8472_COMPLIANCE_NONE (0x0) -#define SFF8472_DIGITAL_DIAG_IMPLEMENTED (0x1 << 6) - -#define SFF8472_SFP_ID (0x03) -#define SFF8472_SFP_EXT_ID (0x04) -#define SFF8472_XFP_ID (0x06) -#define SFF8436_QSFP_PLUS_ID (0x0d) - -#define SFF8472_10G_BASE_ER (1<<7) -#define SFF8472_10G_BASE_LRM (1<<6) -#define SFF8472_10G_BASE_LR (1<<5) -#define SFF8472_10G_BASE_SR (1<<4) - -#define SFF8472_10G_BASE (SFF8472_10G_BASE_ER | \ - SFF8472_10G_BASE_LRM | \ - SFF8472_10G_BASE_LR | \ - SFF8472_10G_BASE_SR ) - -#define SFF8472_10G_SPEED (0x64) - -#define SFF8472_100M_BASE_FX (1 << 5) -#define SFF8472_100M_BASE_LX (1 << 4) -#define SFF8472_1G_BASE_T (1<<3) -#define SFF8472_1G_BASE_CX (1<<2) -#define SFF8472_1G_BASE_LX (1<<1) -#define SFF8472_1G_BASE_SX (1) - -#define SFF8472_1G_BASE (SFF8472_1G_BASE_T | \ - SFF8472_1G_BASE_CX | \ - SFF8472_1G_BASE_LX | \ - SFF8472_1G_BASE_SX ) - -#define SFF8472_100M_BASE (SFF8472_100M_BASE_FX | SFF8472_100M_BASE_LX) - -#define SFF8431_COMPLIANCE (1<<0) -#define SFF8431_LIMITED_COMPLIANCE (1<<2) -#define SFF8431_APPENDIX_E_COMPLIANCE (1<<0) - -#define SFPPLUS_ACTIVE_CABLE (1<<3) -#define SFPPLUS_PASSIVE_CABLE (1<<2) - -#define SFPPLUS_CABLE_TECH (SFPPLUS_ACTIVE_CABLE | \ - SFPPLUS_PASSIVE_CABLE ) - - -#define TRANSCEIVER_NOT_PRESENT (0) -#define TRANSCEIVER_TYPE_100M (1) -#define TRANSCEIVER_TYPE_1G (2) -#define TRANSCEIVER_TYPE_10G (3) -#define TRANSCEIVER_TYPE_QSFP (4) -#define TRANSCEIVER_TYPE_XFP (5) -#define TRANSCEIVER_TYPE_INVALID (6) - -#if L7_FEAT_SFP_QUALIFICATION -extern L7_RC_t hpcSfpOpticQualify(L7_uint32 slot, L7_uint32 port); -#define HPC_SFP_OPTICS_QUALIFY(slot,port) hpcSfpOpticQualify(slot,port) -#else -#define HPC_SFP_OPTICS_QUALIFY(slot,port) L7_NOT_SUPPORTED -#endif - -#define HPC_SFP_CUST_WAVELENGTH_READ(slot, port, wavelength) L7_NOT_SUPPORTED -#define HPC_SFP_CUST_DATARATE_READ(slot, port, dataRate) L7_NOT_SUPPORTED -#define HPC_SFP_CUST_OPTIC_MEDIA_TYPE_GET(slot, port, opticType) L7_NOT_SUPPORTED - -#ifdef INCLUDE_SFP_XFP_OVERRIDES -#include "sfp_xfp_overrides.h" -#endif - -#endif /* INCLUDE_SFP_XFP */ diff --git a/packages/platforms/celestica/x86-64/redstone-xp/onlp/builds/x86_64_cel_redstone_xp/module/src/sfpi.c b/packages/platforms/celestica/x86-64/redstone-xp/onlp/builds/x86_64_cel_redstone_xp/module/src/sfpi.c deleted file mode 100644 index f4764ed5c..000000000 --- a/packages/platforms/celestica/x86-64/redstone-xp/onlp/builds/x86_64_cel_redstone_xp/module/src/sfpi.c +++ /dev/null @@ -1,294 +0,0 @@ -#include - -#include -#include -#include -#include -#include - -#include "redstone_cpld.h" -#include "x86_64_cel_redstone_xp_int.h" -#include "sfp_xfp.h" - - -static int -_get_sfp_state(int sfp) -{ - unsigned char val = 0; - int reg; - int ret = -1; - - if (!sfp) - return sfp; - - if(sfp < 9) { - reg = 0x259; - ret = read_cpld(reg, &val); - if(ret < 0) - return ret; - val &= 0x1 << (sfp - 1); - } else if((sfp > 8) && (sfp < 17)) { - reg = 0x25A; - ret = read_cpld(reg, &val); - if(ret < 0) - return ret; - val &= 0x1 << ((sfp - 1) % 8); - } else if((sfp > 16) && (sfp < 19)) { - reg = 0x25B; - ret = read_cpld(reg, &val); - if(ret < 0) - return ret; - val &= 0x1 << ((sfp - 1) % 8); - } else if((sfp > 18) && (sfp < 29)) { - reg = 0x2D9; - ret = read_cpld(reg, &val); - if(ret < 0) - return ret; - val &= 0x1 << ((sfp - 3) % 8); - } else if((sfp > 28) && (sfp < 35)) { - reg = 0x2DA; - ret = read_cpld(reg, &val); - if(ret < 0) - return ret; - val &= 0x1 << ((sfp - 3) % 8); - } else if((sfp > 34) && (sfp < 37)) { - reg = 0x2DB; - ret = read_cpld(reg, &val); - if(ret < 0) - return ret; - val &= 0x1 << ((sfp - 3) % 8); - } else if((sfp > 36) && (sfp < 45)) { - reg = 0x3D6; - ret = read_cpld(reg, &val); - if(ret < 0) - return ret; - val &= 0x1 << ((sfp - 5) % 8); - } else if((sfp > 44) && (sfp < 49)) { - reg = 0x3D7; - ret = read_cpld(reg, &val); - if(ret < 0) - return ret; - val &= 0x1 << ((sfp - 5) % 8); - } else if((sfp > 48) && (sfp <= CEL_REDSTONE_MAX_PORT)) { - reg = 0x3D7; - ret = read_cpld(reg, &val); - if(ret < 0) - return ret; - val &= 0x1 << ((sfp - 1) % 8); - } - return (ret = (val ? 0 : 1)); -} - -/*@ _read_sfp - * return - * 0 on success - * *data_p with result - */ -static int -_read_sfp(int port, uint8_t *data_p, uint32_t addr, uint32_t offset, uint32_t size) -{ - char byte = 0; - - read_sfp(port, 0xA0, 0x7F, &byte, 1); - - if (byte) { - byte = 0; - write_sfp(port, 0xA0, 0x7F, &byte, 1); - usleep(40000); - } - return (read_sfp(port, (addr<<1), offset, (char *)data_p, size)); -} - -/* @_spf_rx_los - * return - * 1 if rx_loss - * else 0 - * Arg - * port - */ -static int -_sfp_rx_los(int port) -{ - unsigned char byte = 0; - - if (!_get_sfp_state(port)) - return 1; - //return ONLP_STATUS_E_MISSING; - - if (port <= 48) { - _read_sfp(port, &byte, ALL_SFP_DIAG_I2C_ADDRESS, SFP_XFP_LOS_ADDR, SFP_XFP_LOS_SIZE); - } else if (port <= 54) { - _read_sfp(port, &byte, ALL_SFP_DIAG_I2C_ADDRESS, QSFP_LOS_ADDR, SFP_XFP_LOS_SIZE); - } - - if (SFP_LOS_MASK == (byte & SFP_LOS_MASK)) - return 1; - - return 0; -} - -/* @_spf_tx_fault - * return - * if tx fault - * else 0 - * Arg - * port - */ -static int -_sfp_tx_fault(int port) -{ - unsigned int option = 0; - - if (!_get_sfp_state(port)) - return -1; - - if (port <= 48) { - _read_sfp(port, (uint8_t *)&option, ALL_SFP_DIAG_I2C_ADDRESS, SFP_OPTIONS_ADDR, SFP_OPTIONS_SIZE); - } else if (port <= 54) { - _read_sfp(port, (uint8_t *)&option, ALL_SFP_DIAG_I2C_ADDRESS, QSFP_TX_FAULT_ADDR, SFP_OPTIONS_SIZE); - } - - if (SFP_TX_FAULT_MASK & option) - return 1; - - return 0; -} - - -int -onlp_sfpi_bitmap_get(onlp_sfp_bitmap_t* bmap) -{ - int p; - - for(p = 1; p <= CEL_REDSTONE_MAX_PORT; p++) - AIM_BITMAP_SET(bmap, p); - return ONLP_STATUS_OK; -} - -int -onlp_sfpi_init(void) -{ - return ONLP_STATUS_OK; -} - -/* -* @onlp_sfpi_is_present -* Return -* 1 if present. -* 0 if not present. -* < 0 if error. -*/ -int -onlp_sfpi_is_present(int port) -{ - return (_get_sfp_state(port)); -} - -int -onlp_sfpi_denit(void) -{ - return ONLP_STATUS_OK; -} - -int -onlp_sfpi_control_get(int port, onlp_sfp_control_t control, int* value) -{ - int rt; - switch(control) - { - case ONLP_SFP_CONTROL_RX_LOS: - rt = _sfp_rx_los(port); - if (rt < 0) - return ONLP_STATUS_E_INTERNAL; - - *value = rt; - return ONLP_STATUS_OK; - - case ONLP_SFP_CONTROL_TX_FAULT: - rt = _sfp_tx_fault(port); - if (rt < 0) - return ONLP_STATUS_E_INTERNAL; - - *value = rt; - return ONLP_STATUS_OK; - - default: - return ONLP_STATUS_E_UNSUPPORTED; - - } -} - -int -onlp_sfpi_control_set(int port, onlp_sfp_control_t control, int value) -{ - switch(control) { - case ONLP_SFP_CONTROL_TX_DISABLE: - //return _tx_enable_set__(port, !value); - return ONLP_STATUS_E_UNSUPPORTED; - default: - return ONLP_STATUS_E_UNSUPPORTED; - } -} - -int -onlp_sfpi_port_map(int port, int* rport) -{ - /* rport need to be port+1 as the face plate starts at 1 */ - - *rport = port; - return ONLP_STATUS_OK; -} - -int -onlp_sfpi_eeprom_read(int port, uint8_t data[256]) -{ - if (port > CEL_REDSTONE_MAX_PORT) { - return ONLP_STATUS_E_MISSING; - } - - if (!_get_sfp_state(port)) - return ONLP_STATUS_E_MISSING; - - memset(data, 0, 256); - if (_read_sfp(port, data, ALL_SFP_I2C_ADDRESS, 0, 256) == -1) - return ONLP_STATUS_OK; - - return ONLP_STATUS_OK; -} - -int -onlp_sfpi_presence_bitmap_get(onlp_sfp_bitmap_t* dst) -{ - uint32_t i; - int rt; - - AIM_BITMAP_CLR_ALL(dst); - - for(i=0; i< CEL_REDSTONE_MAX_PORT; i++) { - rt = _get_sfp_state(i); - if (rt < 0 ) { - return ONLP_STATUS_E_INTERNAL; - } else if (rt) { - AIM_BITMAP_SET(dst, i); - } - } - return ONLP_STATUS_OK; -} - -int -onlp_sfpi_rx_los_bitmap_get(onlp_sfp_bitmap_t* dst) -{ - uint32_t i; - int rt; - - AIM_BITMAP_CLR_ALL(dst); - for(i=1; i<= CEL_REDSTONE_MAX_PORT; i++) { - rt = _sfp_rx_los(i); - if (rt < 0 ) { - return ONLP_STATUS_E_INTERNAL; - } else if (rt) { - AIM_BITMAP_SET(dst, i); - } - } - return ONLP_STATUS_OK; -} diff --git a/packages/platforms/celestica/x86-64/redstone-xp/onlp/builds/x86_64_cel_redstone_xp/module/src/sys_eeprom.c b/packages/platforms/celestica/x86-64/redstone-xp/onlp/builds/x86_64_cel_redstone_xp/module/src/sys_eeprom.c deleted file mode 100644 index 488937cdf..000000000 --- a/packages/platforms/celestica/x86-64/redstone-xp/onlp/builds/x86_64_cel_redstone_xp/module/src/sys_eeprom.c +++ /dev/null @@ -1,66 +0,0 @@ -#include -#include -#include -#include -#include -#include - -#include "sys_eeprom.h" -#include "i2c_chips.h" -#include "i2c_dev.h" -#include "redstone_cpld.h" - -static inline u_int8_t is_valid_tlvinfo_header(tlvinfo_header_t *hdr) -{ - int max_size = TLV_TOTAL_LEN_MAX; - - return((strcmp(hdr->signature, TLV_INFO_ID_STRING) == 0) && - (hdr->version == TLV_INFO_VERSION) && - (be16_to_cpu(hdr->totallen) <= max_size)); -} - -int -read_sys_eeprom(void *eeprom_data, int offset, int len) -{ - int ret = 0; - int i = 0; - u_int8_t *c; - - int addr = SYS_EEPROM_OFFSET + offset; - unsigned char dev_id = 5; - - c = eeprom_data; - if (eeprom_enable(dev_id) < 0) { - printf("ERROR: Cannot open I2C device\n"); - return -1; - } - - for (i = 0; i < len; i++) { - unsigned char buf; - ret = eeprom_read_byte(CONFIG_SYS_I2C_EEPROM_ADDR, addr, &buf); - *c = buf; - c++; - addr++; - } - - eeprom_disable(dev_id); - return ret; -} - -int -read_eeprom(u_int8_t *eeprom, int *size) -{ - int ret; - tlvinfo_header_t *eeprom_hdr = (tlvinfo_header_t *) eeprom; - u_int8_t *buf = eeprom + sizeof(tlvinfo_header_t); - - /* Read the header */ - ret = read_sys_eeprom((void *)eeprom_hdr, 0, sizeof(tlvinfo_header_t)); - - /* If the header was successfully read, read the TLVs */ - if ((ret == 0) && is_valid_tlvinfo_header(eeprom_hdr)) - ret = read_sys_eeprom((void *)buf, sizeof(tlvinfo_header_t), - be16_to_cpu(eeprom_hdr->totallen)); - - return ret; -} diff --git a/packages/platforms/celestica/x86-64/redstone-xp/onlp/builds/x86_64_cel_redstone_xp/module/src/sys_eeprom.h b/packages/platforms/celestica/x86-64/redstone-xp/onlp/builds/x86_64_cel_redstone_xp/module/src/sys_eeprom.h deleted file mode 100644 index be31e28e8..000000000 --- a/packages/platforms/celestica/x86-64/redstone-xp/onlp/builds/x86_64_cel_redstone_xp/module/src/sys_eeprom.h +++ /dev/null @@ -1,186 +0,0 @@ -#ifndef SYS_EEPROM_HH -#define SYS_EEPROM_HH - -#include -#ifdef __cplusplus -extern "C" { -#endif - -#define be16_to_cpu(x) __be16_to_cpu(x) -#define cpu_to_be16(x) __cpu_to_be16(x) - -#define FALSE 0 -#define TRUE (!FALSE) - -/* - * Tlvinf header: Layout of the header for the TlvInfo format - * - * See the end of this file for details of this eeprom format - */ -struct __attribute__ ((__packed__)) tlvinfo_header_s { - char signature[8]; /* 0x00 - 0x07 EEPROM Tag "TlvInfo" */ - u_int8_t version; /* 0x08 Structure version */ - u_int16_t totallen; /* 0x09 - 0x0A Length of all data which follows */ -}; -typedef struct tlvinfo_header_s tlvinfo_header_t; - -// Header Field Constants -#define TLV_INFO_ID_STRING "TlvInfo" -#define TLV_INFO_VERSION 0x01 -#define TLV_TOTAL_LEN_MAX (SYS_EEPROM_SIZE - sizeof(tlvinfo_header_t)) - -/* - * TlvInfo TLV: Layout of a TLV field - */ -struct __attribute__ ((__packed__)) tlvinfo_tlv_s { - u_int8_t type; - u_int8_t length; - u_int8_t value[0]; -}; -typedef struct tlvinfo_tlv_s tlvinfo_tlv_t; - -/* Maximum length of a TLV value in bytes */ -#define TLV_VALUE_MAX_LEN 255 - -/** - * The TLV Types. - * - * Keep these in sync with tlv_code_list in cmd_sys_eeprom.c - */ -#define TLV_CODE_PRODUCT_NAME 0x21 -#define TLV_CODE_PART_NUMBER 0x22 -#define TLV_CODE_SERIAL_NUMBER 0x23 -#define TLV_CODE_MAC_BASE 0x24 -#define TLV_CODE_MANUF_DATE 0x25 -#define TLV_CODE_DEVICE_VERSION 0x26 -#define TLV_CODE_LABEL_REVISION 0x27 -#define TLV_CODE_PLATFORM_NAME 0x28 -#define TLV_CODE_ONIE_VERSION 0x29 -#define TLV_CODE_MAC_SIZE 0x2A -#define TLV_CODE_MANUF_NAME 0x2B -#define TLV_CODE_MANUF_COUNTRY 0x2C -#define TLV_CODE_VENDOR_NAME 0x2D -#define TLV_CODE_DIAG_VERSION 0x2E -#define TLV_CODE_SERVICE_TAG 0x2F -#define TLV_CODE_VENDOR_EXT 0xFD -#define TLV_CODE_CRC_32 0xFE - -/* - * Struct for displaying the TLV codes and names. - */ -struct tlv_code_desc { - u_int8_t m_code; - char* m_name; -}; - -/* - * List of TLV codes and names. - */ -static const struct tlv_code_desc tlv_code_list[] = { - { TLV_CODE_PRODUCT_NAME , "Product Name"}, - { TLV_CODE_PART_NUMBER , "Part Number"}, - { TLV_CODE_SERIAL_NUMBER , "Serial Number"}, - { TLV_CODE_MAC_BASE , "Base MAC Address"}, - { TLV_CODE_MANUF_DATE , "Manufacture Date"}, - { TLV_CODE_DEVICE_VERSION , "Device Version"}, - { TLV_CODE_LABEL_REVISION , "Label Revision"}, - { TLV_CODE_PLATFORM_NAME , "Platform Name"}, - { TLV_CODE_ONIE_VERSION , "Loader Version"}, - { TLV_CODE_MAC_SIZE , "MAC Addresses"}, - { TLV_CODE_MANUF_NAME , "Manufacturer"}, - { TLV_CODE_MANUF_COUNTRY , "Country Code"}, - { TLV_CODE_VENDOR_NAME , "Vendor Name"}, - { TLV_CODE_DIAG_VERSION , "Diag Version"}, - { TLV_CODE_SERVICE_TAG , "Service Tag"}, - { TLV_CODE_VENDOR_EXT , "Vendor Extension"}, - { TLV_CODE_CRC_32 , "CRC-32"}, -}; - -static inline const char* tlv_type2name(u_int8_t type) -{ - char* name = "Unknown"; - int i; - - for (i = 0; i < sizeof(tlv_code_list)/sizeof(tlv_code_list[0]); i++) { - if (tlv_code_list[i].m_code == type) { - name = tlv_code_list[i].m_name; - break; - } - } - return name; -} - -/* - * The max decode value is currently for the 'raw' type or the 'vendor - * extension' type, both of which have the same decode format. The - * max decode string size is computed as follows: - * - * strlen(" 0xFF") * TLV_VALUE_MAX_LEN + 1 - * - */ -#define TLV_DECODE_VALUE_MAX_LEN ((5 * TLV_VALUE_MAX_LEN) + 1) - - -/* - * Each platform must define the following platform-specific macros - * in sys_eeprom_platform.h: - * SYS_EEPROM_SIZE: size of usable eeprom - * SYS_EEPROM_I2C_DEVICE: i2c-bus - * SYS_EEPROM_I2C_ADDR: address on the bus - * The following may also be defined in sys_eeprom_platform.h, else - * the defaults with take over: - * SYS_EEPROM_MAX_SIZE: Total size of the eeprom - * SYS_EEPROM_OFFSET: offset from where the ONIE header starts - */ -//#include "sys_eeprom_platform.h" -#define CONFIG_SYS_I2C_EEPROM_ADDR 0x50 -#ifndef SYS_EEPROM_SIZE -#define SYS_EEPROM_SIZE 1024 -#endif - -#ifndef SYS_EEPROM_I2C_DEVICE -#define SYS_EEPROM_I2C_DEVICE 1 -#endif - -#ifndef SYS_EEPROM_I2C_ADDR -#define SYS_EEPROM_I2C_ADDR 0x50 -#endif -#ifndef SYS_EEPROM_MAX_SIZE -#define SYS_EEPROM_MAX_SIZE 2048 -#endif - -#ifndef SYS_EEPROM_OFFSET -#define SYS_EEPROM_OFFSET 0 -#endif - -#ifndef SYS_EEPROM_SIZE - #error SYS_EEPROM_SIZE not defined! -#endif - -#ifndef SYS_EEPROM_I2C_DEVICE - #error SYS_EEPROM_I2C_DEVICE not defined! -#endif - -#ifndef SYS_EEPROM_I2C_ADDR - #error SYS_EEPROM_I2C_ADDR not defined! -#endif - -#if (SYS_EEPROM_SIZE + SYS_EEPROM_OFFSET > SYS_EEPROM_MAX_SIZE) - #error SYS_EEPROM_SIZE + SYS_EEPROM_OFFSET is greater than SYS_EEPROM_MAX_SIZE -#endif - -// Access functions to onie_tlvinfo -int prog_eeprom(u_int8_t * eeprom); -void update_eeprom_header(u_int8_t *eeprom); -u_int8_t tlvinfo_find_tlv(u_int8_t *eeprom, u_int8_t tcode, int *eeprom_index); -u_int8_t tlvinfo_delete_tlv(u_int8_t * eeprom, u_int8_t code); -u_int8_t tlvinfo_add_tlv(u_int8_t * eeprom, int tcode, char * strval); -u_int8_t tlvinfo_decode_tlv(u_int8_t *eeprom, u_int8_t tcode, char* value); -void show_tlv_code_list(void); -void show_eeprom(void); -int read_eeprom(u_int8_t *, int *); - -#ifdef __cplusplus -} -#endif -#endif diff --git a/packages/platforms/celestica/x86-64/redstone-xp/onlp/builds/x86_64_cel_redstone_xp/module/src/sysi.c b/packages/platforms/celestica/x86-64/redstone-xp/onlp/builds/x86_64_cel_redstone_xp/module/src/sysi.c deleted file mode 100644 index c3bf8bc17..000000000 --- a/packages/platforms/celestica/x86-64/redstone-xp/onlp/builds/x86_64_cel_redstone_xp/module/src/sysi.c +++ /dev/null @@ -1,175 +0,0 @@ -/* - * Copyright - */ -#include -#include -#include -#include - -#include "x86_64_cel_redstone_xp_log.h" -#include "platform.h" -#include "sys_eeprom.h" -#include "redstone_cpld.h" - -const char* -onlp_sysi_platform_get(void) -{ - return "x86-64-cel-redstone-xp-r0"; -} - -int -onlp_sysi_init(void) -{ - return cpld_io_init(); -} - - -int -onlp_sysi_debug(aim_pvs_t* pvs, int argc, char* argv[]) -{ - int c; - for(c = 1; c <= 5; c++) { - aim_printf(pvs, "CPLD%d:\n", c); - cpld_dump(pvs, c); - } - return 0; -} - -int -onlp_sysi_platform_set(const char* name) -{ - /* - * For the purposes of this example we - * accept all platforms. - */ - return ONLP_STATUS_OK; -} - -int -onlp_sysi_onie_data_phys_addr_get(void** pa) -{ - return ONLP_STATUS_E_UNSUPPORTED; -} - -int -onlp_sysi_onie_data_get(uint8_t** data, int* size) -{ - uint8_t* rdata = aim_zmalloc(512); - - read_eeprom(rdata, size); - if (size) { - *data = rdata; - return ONLP_STATUS_OK; - } - return ONLP_STATUS_E_INTERNAL; -} - -void -onlp_sysi_onie_data_free(uint8_t* data) -{ - /* - * We returned a static array in onlp_sysi_onie_data_get() - * so no free operation is required. - */ -} - -static int -_onlp_sysi_calc_speed(int atemp) -{ - int fan_speed = 0; - - if (atemp < 38 ) { - fan_speed = 50; - } else if ( atemp < 40) { - fan_speed = 60; - } else if ( atemp < 42) { - fan_speed = 70; - } else if ( atemp < 44) { - fan_speed = 80; - } else if ( atemp < 46) { - fan_speed = 90; - } else { - fan_speed = 100; - } - - return fan_speed; -} - -/* - * Thermal profile for Celestica Redstone XP - * - * Default Fan speed: 50% - * Normal operating temperature range: < 46C - * Fan Speed profile: - * 46C + : 100% Fan speed - * 44C : 80% Fan speed - * 42C : 70% Fan speed - * 40C : 60% Fan speed - * 38C - : 50% Fan speed - */ -int -onlp_sysi_platform_manage_fans(void) -{ - int i, atemp = 0, count = 0; - int fan_speed = 0; - static int o_speed = 0, o_psu_speed[2] = {0,0}; - onlp_thermal_info_t t_info; - - for (i = 1; i < PSU_FAN; i++) { - onlp_thermali_info_get(ONLP_THERMAL_ID_CREATE(i), &t_info); - if (t_info.mcelsius) { - count++; - atemp += t_info.mcelsius; - } - } - atemp = atemp/count; - - fan_speed = _onlp_sysi_calc_speed(atemp); - if (o_speed != fan_speed) { - for (i = 1; i < PSU_FAN; i++) - onlp_fani_percentage_set(ONLP_FAN_ID_CREATE(i), fan_speed); - o_speed = fan_speed; - } - - /* Control PSU FAN */ - for (i = 0; i < 2 ; i++) { - onlp_thermali_info_get(ONLP_THERMAL_ID_CREATE(i), &t_info); - if (t_info.mcelsius) { - atemp = t_info.mcelsius; - fan_speed = _onlp_sysi_calc_speed(atemp); - if (fan_speed != o_psu_speed[i]) { - onlp_fani_percentage_set(ONLP_FAN_ID_CREATE(PSU_FAN + i), fan_speed); - o_psu_speed[i] = fan_speed; - } - } - } - - return ONLP_STATUS_OK; -} - -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)); - - /* 2 PSUs */ - *e++ = ONLP_PSU_ID_CREATE(1); - *e++ = ONLP_PSU_ID_CREATE(2); - - /* LEDs Item */ - for (i=1; i<=LED_COUNT; i++) - *e++ = ONLP_LED_ID_CREATE(i); - - /* THERMALs Item */ - for (i=1; i<=THERMAL_COUNT; i++) - *e++ = ONLP_THERMAL_ID_CREATE(i); - - /* Fans Item */ - for (i=1; i<=FAN_COUNT; i++) - *e++ = ONLP_FAN_ID_CREATE(i); - - return ONLP_STATUS_OK; -} diff --git a/packages/platforms/celestica/x86-64/redstone-xp/onlp/builds/x86_64_cel_redstone_xp/module/src/thermali.c b/packages/platforms/celestica/x86-64/redstone-xp/onlp/builds/x86_64_cel_redstone_xp/module/src/thermali.c deleted file mode 100644 index a5f4c23b8..000000000 --- a/packages/platforms/celestica/x86-64/redstone-xp/onlp/builds/x86_64_cel_redstone_xp/module/src/thermali.c +++ /dev/null @@ -1,73 +0,0 @@ -#include -#include -#include -#include -#include - -#include "i2c_chips.h" -#include "platform.h" - -static onlp_thermal_info_t thermal_info[] = { - { { ONLP_THERMAL_ID_CREATE(THERMAL_MAIN_BOARD_REAR), "Chassis Thermal (Rear)", 0}, - ONLP_THERMAL_STATUS_PRESENT, - ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS - }, - { { ONLP_THERMAL_ID_CREATE(THERMAL_BCM), "BCM SOC Thermal sensor", 0}, - ONLP_THERMAL_STATUS_PRESENT, - ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS - }, - { { ONLP_THERMAL_ID_CREATE(THERMAL_CPU), "CPU Core", 0}, - ONLP_THERMAL_STATUS_PRESENT, - ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS - }, - { { ONLP_THERMAL_ID_CREATE(THERMAL_MAIN_BOARD_FRONT), "Chassis Thermal Sensor (Front)", 0}, - ONLP_THERMAL_STATUS_PRESENT, - ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS - }, - { { ONLP_THERMAL_ID_CREATE(THERMAL_PSU1), "PSU-1 Thermal Sensor", ONLP_PSU_ID_CREATE(1)}, - ONLP_THERMAL_STATUS_PRESENT, - ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS - }, - { { ONLP_THERMAL_ID_CREATE(THERMAL_PSU2), "PSU-2 Thermal Sensor", ONLP_PSU_ID_CREATE(2)}, - 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 sensor_id; - struct psuInfo psu; - short temp; - - sensor_id = ONLP_OID_ID_GET(id) - 1; - - *info = thermal_info[sensor_id]; - - switch (sensor_id) { - case THERMAL_MAIN_BOARD_REAR: - case THERMAL_MAIN_BOARD_FRONT: - case THERMAL_BCM: - case THERMAL_CPU: - tsTempGet(sensor_id, &temp); - info->mcelsius = temp; - break; - case THERMAL_PSU1: - getPsuInfo(0, &psu); - info->mcelsius = psu.temp; - break; - case THERMAL_PSU2: - getPsuInfo(1, &psu); - info->mcelsius = psu.temp; - break; - } - return ONLP_STATUS_OK; -} - diff --git a/packages/platforms/celestica/x86-64/redstone-xp/onlp/builds/x86_64_cel_redstone_xp/module/src/x86_64_cel_redstone_xp_config.c b/packages/platforms/celestica/x86-64/redstone-xp/onlp/builds/x86_64_cel_redstone_xp/module/src/x86_64_cel_redstone_xp_config.c deleted file mode 100644 index 6e257e88d..000000000 --- a/packages/platforms/celestica/x86-64/redstone-xp/onlp/builds/x86_64_cel_redstone_xp/module/src/x86_64_cel_redstone_xp_config.c +++ /dev/null @@ -1,76 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#include - -/* */ -#define __x86_64_cel_redstone_xp_config_STRINGIFY_NAME(_x) #_x -#define __x86_64_cel_redstone_xp_config_STRINGIFY_VALUE(_x) __x86_64_cel_redstone_xp_config_STRINGIFY_NAME(_x) -x86_64_cel_redstone_xp_config_settings_t x86_64_cel_redstone_xp_config_settings[] = -{ -#ifdef X86_64_CEL_REDSTONE_XP_CONFIG_INCLUDE_LOGGING - { __x86_64_cel_redstone_xp_config_STRINGIFY_NAME(X86_64_CEL_REDSTONE_XP_CONFIG_INCLUDE_LOGGING), __x86_64_cel_redstone_xp_config_STRINGIFY_VALUE(X86_64_CEL_REDSTONE_XP_CONFIG_INCLUDE_LOGGING) }, -#else -{ X86_64_CEL_REDSTONE_XP_CONFIG_INCLUDE_LOGGING(__x86_64_cel_redstone_xp_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_CEL_REDSTONE_XP_CONFIG_LOG_OPTIONS_DEFAULT - { __x86_64_cel_redstone_xp_config_STRINGIFY_NAME(X86_64_CEL_REDSTONE_XP_CONFIG_LOG_OPTIONS_DEFAULT), __x86_64_cel_redstone_xp_config_STRINGIFY_VALUE(X86_64_CEL_REDSTONE_XP_CONFIG_LOG_OPTIONS_DEFAULT) }, -#else -{ X86_64_CEL_REDSTONE_XP_CONFIG_LOG_OPTIONS_DEFAULT(__x86_64_cel_redstone_xp_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_CEL_REDSTONE_XP_CONFIG_LOG_BITS_DEFAULT - { __x86_64_cel_redstone_xp_config_STRINGIFY_NAME(X86_64_CEL_REDSTONE_XP_CONFIG_LOG_BITS_DEFAULT), __x86_64_cel_redstone_xp_config_STRINGIFY_VALUE(X86_64_CEL_REDSTONE_XP_CONFIG_LOG_BITS_DEFAULT) }, -#else -{ X86_64_CEL_REDSTONE_XP_CONFIG_LOG_BITS_DEFAULT(__x86_64_cel_redstone_xp_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_CEL_REDSTONE_XP_CONFIG_LOG_CUSTOM_BITS_DEFAULT - { __x86_64_cel_redstone_xp_config_STRINGIFY_NAME(X86_64_CEL_REDSTONE_XP_CONFIG_LOG_CUSTOM_BITS_DEFAULT), __x86_64_cel_redstone_xp_config_STRINGIFY_VALUE(X86_64_CEL_REDSTONE_XP_CONFIG_LOG_CUSTOM_BITS_DEFAULT) }, -#else -{ X86_64_CEL_REDSTONE_XP_CONFIG_LOG_CUSTOM_BITS_DEFAULT(__x86_64_cel_redstone_xp_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_CEL_REDSTONE_XP_CONFIG_PORTING_STDLIB - { __x86_64_cel_redstone_xp_config_STRINGIFY_NAME(X86_64_CEL_REDSTONE_XP_CONFIG_PORTING_STDLIB), __x86_64_cel_redstone_xp_config_STRINGIFY_VALUE(X86_64_CEL_REDSTONE_XP_CONFIG_PORTING_STDLIB) }, -#else -{ X86_64_CEL_REDSTONE_XP_CONFIG_PORTING_STDLIB(__x86_64_cel_redstone_xp_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_CEL_REDSTONE_XP_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS - { __x86_64_cel_redstone_xp_config_STRINGIFY_NAME(X86_64_CEL_REDSTONE_XP_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS), __x86_64_cel_redstone_xp_config_STRINGIFY_VALUE(X86_64_CEL_REDSTONE_XP_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS) }, -#else -{ X86_64_CEL_REDSTONE_XP_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS(__x86_64_cel_redstone_xp_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_CEL_REDSTONE_XP_CONFIG_INCLUDE_UCLI - { __x86_64_cel_redstone_xp_config_STRINGIFY_NAME(X86_64_CEL_REDSTONE_XP_CONFIG_INCLUDE_UCLI), __x86_64_cel_redstone_xp_config_STRINGIFY_VALUE(X86_64_CEL_REDSTONE_XP_CONFIG_INCLUDE_UCLI) }, -#else -{ X86_64_CEL_REDSTONE_XP_CONFIG_INCLUDE_UCLI(__x86_64_cel_redstone_xp_config_STRINGIFY_NAME), "__undefined__" }, -#endif - { NULL, NULL } -}; -#undef __x86_64_cel_redstone_xp_config_STRINGIFY_VALUE -#undef __x86_64_cel_redstone_xp_config_STRINGIFY_NAME - -const char* -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)) { - return x86_64_cel_redstone_xp_config_settings[i].value; - } - } - return NULL; -} - -int -x86_64_cel_redstone_xp_config_show(struct aim_pvs_s* pvs) -{ - int i; - for(i = 0; x86_64_cel_redstone_xp_config_settings[i].name; i++) { - aim_printf(pvs, "%s = %s\n", x86_64_cel_redstone_xp_config_settings[i].name, x86_64_cel_redstone_xp_config_settings[i].value); - } - return i; -} - -/* */ - diff --git a/packages/platforms/celestica/x86-64/redstone-xp/onlp/builds/x86_64_cel_redstone_xp/module/src/x86_64_cel_redstone_xp_enums.c b/packages/platforms/celestica/x86-64/redstone-xp/onlp/builds/x86_64_cel_redstone_xp/module/src/x86_64_cel_redstone_xp_enums.c deleted file mode 100644 index 426c91b75..000000000 --- a/packages/platforms/celestica/x86-64/redstone-xp/onlp/builds/x86_64_cel_redstone_xp/module/src/x86_64_cel_redstone_xp_enums.c +++ /dev/null @@ -1,674 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#include -#include "x86_64_cel_redstone_xp_int.h" - -/* */ -aim_map_si_t cpld1_reg_map[] = -{ - { "VERSION", CPLD1_REG_VERSION }, - { "SCRATCH", CPLD1_REG_SCRATCH }, - { "RESET_CONTROL", CPLD1_REG_RESET_CONTROL }, - { "RESET_SOURCE", CPLD1_REG_RESET_SOURCE }, - { "BOARD_TYPE", CPLD1_REG_BOARD_TYPE }, - { "INT_PORT_STATUS", CPLD1_REG_INT_PORT_STATUS }, - { "INT0_SOURCE_STATUS", CPLD1_REG_INT0_SOURCE_STATUS }, - { "INT0_SOURCE_INT", CPLD1_REG_INT0_SOURCE_INT }, - { "INT0_SOURCE_MASK", CPLD1_REG_INT0_SOURCE_MASK }, - { "POWER_SUPPLY_STATUS", CPLD1_REG_POWER_SUPPLY_STATUS }, - { "POWER_GOOD_STATUS", CPLD1_REG_POWER_GOOD_STATUS }, - { "BPP_CONTROL", CPLD1_REG_BPP_CONTROL }, - { "WRITE_PROTECT_CONTROL", CPLD1_REG_WRITE_PROTECT_CONTROL }, - { "MISC_STATUS_CONTROL", CPLD1_REG_MISC_STATUS_CONTROL }, - { "INFO_RAM_ADDR_HIGH", CPLD1_REG_INFO_RAM_ADDR_HIGH }, - { "INFO_RAM_ADDR_LOW", CPLD1_REG_INFO_RAM_ADDR_LOW }, - { "INFO_RAM_READ_DATA", CPLD1_REG_INFO_RAM_READ_DATA }, - { "INFO_RAM_WRITE_DATA", CPLD1_REG_INFO_RAM_WRITE_DATA }, - { NULL, 0 } -}; - -aim_map_si_t cpld1_reg_desc_map[] = -{ - { "None", CPLD1_REG_VERSION }, - { "None", CPLD1_REG_SCRATCH }, - { "None", CPLD1_REG_RESET_CONTROL }, - { "None", CPLD1_REG_RESET_SOURCE }, - { "None", CPLD1_REG_BOARD_TYPE }, - { "None", CPLD1_REG_INT_PORT_STATUS }, - { "None", CPLD1_REG_INT0_SOURCE_STATUS }, - { "None", CPLD1_REG_INT0_SOURCE_INT }, - { "None", CPLD1_REG_INT0_SOURCE_MASK }, - { "None", CPLD1_REG_POWER_SUPPLY_STATUS }, - { "None", CPLD1_REG_POWER_GOOD_STATUS }, - { "None", CPLD1_REG_BPP_CONTROL }, - { "None", CPLD1_REG_WRITE_PROTECT_CONTROL }, - { "None", CPLD1_REG_MISC_STATUS_CONTROL }, - { "None", CPLD1_REG_INFO_RAM_ADDR_HIGH }, - { "None", CPLD1_REG_INFO_RAM_ADDR_LOW }, - { "None", CPLD1_REG_INFO_RAM_READ_DATA }, - { "None", CPLD1_REG_INFO_RAM_WRITE_DATA }, - { NULL, 0 } -}; - -const char* -cpld1_reg_name(cpld1_reg_t e) -{ - const char* name; - if(aim_map_si_i(&name, e, cpld1_reg_map, 0)) { - return name; - } - else { - return "-invalid value for enum type 'cpld1_reg'"; - } -} - -int -cpld1_reg_value(const char* str, cpld1_reg_t* e, int substr) -{ - int i; - AIM_REFERENCE(substr); - if(aim_map_si_s(&i, str, cpld1_reg_map, 0)) { - /* Enum Found */ - *e = i; - return 0; - } - else { - return -1; - } -} - -const char* -cpld1_reg_desc(cpld1_reg_t e) -{ - const char* name; - if(aim_map_si_i(&name, e, cpld1_reg_desc_map, 0)) { - return name; - } - else { - return "-invalid value for enum type 'cpld1_reg'"; - } -} - -int -cpld1_reg_valid(cpld1_reg_t e) -{ - return aim_map_si_i(NULL, e, cpld1_reg_map, 0) ? 1 : 0; -} - - -aim_map_si_t cpld2_reg_map[] = -{ - { "VERSION", CPLD2_REG_VERSION }, - { "SCRATCH", CPLD2_REG_SCRATCH }, - { "I2C_PORT_ID", CPLD2_REG_I2C_PORT_ID }, - { "I2C_OP_CODE", CPLD2_REG_I2C_OP_CODE }, - { "I2C_DEV_ADDR", CPLD2_REG_I2C_DEV_ADDR }, - { "I2C_CMD_BYTE0", CPLD2_REG_I2C_CMD_BYTE0 }, - { "I2C_CMD_BYTE1", CPLD2_REG_I2C_CMD_BYTE1 }, - { "I2C_CMD_BYTE2", CPLD2_REG_I2C_CMD_BYTE2 }, - { "I2C_STATUS_RESET", CPLD2_REG_I2C_STATUS_RESET }, - { "I2C_WRITE_DATA_BYTE0", CPLD2_REG_I2C_WRITE_DATA_BYTE0 }, - { "I2C_WRITE_DATA_BYTE1", CPLD2_REG_I2C_WRITE_DATA_BYTE1 }, - { "I2C_WRITE_DATA_BYTE2", CPLD2_REG_I2C_WRITE_DATA_BYTE2 }, - { "I2C_WRITE_DATA_BYTE3", CPLD2_REG_I2C_WRITE_DATA_BYTE3 }, - { "I2C_WRITE_DATA_BYTE4", CPLD2_REG_I2C_WRITE_DATA_BYTE4 }, - { "I2C_WRITE_DATA_BYTE5", CPLD2_REG_I2C_WRITE_DATA_BYTE5 }, - { "I2C_WRITE_DATA_BYTE6", CPLD2_REG_I2C_WRITE_DATA_BYTE6 }, - { "I2C_WRITE_DATA_BYTE7", CPLD2_REG_I2C_WRITE_DATA_BYTE7 }, - { "I2C_READ_DATA_BYTE0", CPLD2_REG_I2C_READ_DATA_BYTE0 }, - { "I2C_READ_DATA_BYTE1", CPLD2_REG_I2C_READ_DATA_BYTE1 }, - { "I2C_READ_DATA_BYTE2", CPLD2_REG_I2C_READ_DATA_BYTE2 }, - { "I2C_READ_DATA_BYTE3", CPLD2_REG_I2C_READ_DATA_BYTE3 }, - { "I2C_READ_DATA_BYTE4", CPLD2_REG_I2C_READ_DATA_BYTE4 }, - { "I2C_READ_DATA_BYTE5", CPLD2_REG_I2C_READ_DATA_BYTE5 }, - { "I2C_READ_DATA_BYTE6", CPLD2_REG_I2C_READ_DATA_BYTE6 }, - { "I2C_READ_DATA_BYTE7", CPLD2_REG_I2C_READ_DATA_BYTE7 }, - { "SFP_1_8_RX_LOS", CPLD2_REG_SFP_1_8_RX_LOS }, - { "SFP_9_16_RX_LOS", CPLD2_REG_SFP_9_16_RX_LOS }, - { "SFP_17_18_RX_LOS", CPLD2_REG_SFP_17_18_RX_LOS }, - { "SFP_1_8_RX_LOS_INT", CPLD2_REG_SFP_1_8_RX_LOS_INT }, - { "SFP_9_16_RX_LOS_INT", CPLD2_REG_SFP_9_16_RX_LOS_INT }, - { "SFP_17_18_RX_LOS_INT", CPLD2_REG_SFP_17_18_RX_LOS_INT }, - { "SFP_1_8_RX_LOS_MASK", CPLD2_REG_SFP_1_8_RX_LOS_MASK }, - { "SFP_9_16_RX_LOS_MASK", CPLD2_REG_SFP_9_16_RX_LOS_MASK }, - { "SFP_17_18_RX_LOS_MASK", CPLD2_REG_SFP_17_18_RX_LOS_MASK }, - { "SFP_1_8_TX_DISABLE", CPLD2_REG_SFP_1_8_TX_DISABLE }, - { "SFP_9_16_TX_DISABLE", CPLD2_REG_SFP_9_16_TX_DISABLE }, - { "SFP_17_18_TX_DISABLE", CPLD2_REG_SFP_17_18_TX_DISABLE }, - { "SFP_1_8_RS_CONTROL", CPLD2_REG_SFP_1_8_RS_CONTROL }, - { "SFP_9_16_RS_CONTROL", CPLD2_REG_SFP_9_16_RS_CONTROL }, - { "SFP_17_18_RS_CONTROL", CPLD2_REG_SFP_17_18_RS_CONTROL }, - { "SFP_1_8_TX_FAULT", CPLD2_REG_SFP_1_8_TX_FAULT }, - { "SFP_9_16_TX_FAULT", CPLD2_REG_SFP_9_16_TX_FAULT }, - { "SFP_17_18_TX_FAULT", CPLD2_REG_SFP_17_18_TX_FAULT }, - { "SFP_1_8_ABS_STATUS", CPLD2_REG_SFP_1_8_ABS_STATUS }, - { "SFP_9_16_ABS_STATUS", CPLD2_REG_SFP_9_16_ABS_STATUS }, - { "SFP_17_18_ABS_STATUS", CPLD2_REG_SFP_17_18_ABS_STATUS }, - { NULL, 0 } -}; - -aim_map_si_t cpld2_reg_desc_map[] = -{ - { "None", CPLD2_REG_VERSION }, - { "None", CPLD2_REG_SCRATCH }, - { "None", CPLD2_REG_I2C_PORT_ID }, - { "None", CPLD2_REG_I2C_OP_CODE }, - { "None", CPLD2_REG_I2C_DEV_ADDR }, - { "None", CPLD2_REG_I2C_CMD_BYTE0 }, - { "None", CPLD2_REG_I2C_CMD_BYTE1 }, - { "None", CPLD2_REG_I2C_CMD_BYTE2 }, - { "None", CPLD2_REG_I2C_STATUS_RESET }, - { "None", CPLD2_REG_I2C_WRITE_DATA_BYTE0 }, - { "None", CPLD2_REG_I2C_WRITE_DATA_BYTE1 }, - { "None", CPLD2_REG_I2C_WRITE_DATA_BYTE2 }, - { "None", CPLD2_REG_I2C_WRITE_DATA_BYTE3 }, - { "None", CPLD2_REG_I2C_WRITE_DATA_BYTE4 }, - { "None", CPLD2_REG_I2C_WRITE_DATA_BYTE5 }, - { "None", CPLD2_REG_I2C_WRITE_DATA_BYTE6 }, - { "None", CPLD2_REG_I2C_WRITE_DATA_BYTE7 }, - { "None", CPLD2_REG_I2C_READ_DATA_BYTE0 }, - { "None", CPLD2_REG_I2C_READ_DATA_BYTE1 }, - { "None", CPLD2_REG_I2C_READ_DATA_BYTE2 }, - { "None", CPLD2_REG_I2C_READ_DATA_BYTE3 }, - { "None", CPLD2_REG_I2C_READ_DATA_BYTE4 }, - { "None", CPLD2_REG_I2C_READ_DATA_BYTE5 }, - { "None", CPLD2_REG_I2C_READ_DATA_BYTE6 }, - { "None", CPLD2_REG_I2C_READ_DATA_BYTE7 }, - { "None", CPLD2_REG_SFP_1_8_RX_LOS }, - { "None", CPLD2_REG_SFP_9_16_RX_LOS }, - { "None", CPLD2_REG_SFP_17_18_RX_LOS }, - { "None", CPLD2_REG_SFP_1_8_RX_LOS_INT }, - { "None", CPLD2_REG_SFP_9_16_RX_LOS_INT }, - { "None", CPLD2_REG_SFP_17_18_RX_LOS_INT }, - { "None", CPLD2_REG_SFP_1_8_RX_LOS_MASK }, - { "None", CPLD2_REG_SFP_9_16_RX_LOS_MASK }, - { "None", CPLD2_REG_SFP_17_18_RX_LOS_MASK }, - { "None", CPLD2_REG_SFP_1_8_TX_DISABLE }, - { "None", CPLD2_REG_SFP_9_16_TX_DISABLE }, - { "None", CPLD2_REG_SFP_17_18_TX_DISABLE }, - { "None", CPLD2_REG_SFP_1_8_RS_CONTROL }, - { "None", CPLD2_REG_SFP_9_16_RS_CONTROL }, - { "None", CPLD2_REG_SFP_17_18_RS_CONTROL }, - { "None", CPLD2_REG_SFP_1_8_TX_FAULT }, - { "None", CPLD2_REG_SFP_9_16_TX_FAULT }, - { "None", CPLD2_REG_SFP_17_18_TX_FAULT }, - { "None", CPLD2_REG_SFP_1_8_ABS_STATUS }, - { "None", CPLD2_REG_SFP_9_16_ABS_STATUS }, - { "None", CPLD2_REG_SFP_17_18_ABS_STATUS }, - { NULL, 0 } -}; - -const char* -cpld2_reg_name(cpld2_reg_t e) -{ - const char* name; - if(aim_map_si_i(&name, e, cpld2_reg_map, 0)) { - return name; - } - else { - return "-invalid value for enum type 'cpld2_reg'"; - } -} - -int -cpld2_reg_value(const char* str, cpld2_reg_t* e, int substr) -{ - int i; - AIM_REFERENCE(substr); - if(aim_map_si_s(&i, str, cpld2_reg_map, 0)) { - /* Enum Found */ - *e = i; - return 0; - } - else { - return -1; - } -} - -const char* -cpld2_reg_desc(cpld2_reg_t e) -{ - const char* name; - if(aim_map_si_i(&name, e, cpld2_reg_desc_map, 0)) { - return name; - } - else { - return "-invalid value for enum type 'cpld2_reg'"; - } -} - -int -cpld2_reg_valid(cpld2_reg_t e) -{ - return aim_map_si_i(NULL, e, cpld2_reg_map, 0) ? 1 : 0; -} - - -aim_map_si_t cpld3_reg_map[] = -{ - { "VERSION", CPLD3_REG_VERSION }, - { "SCRATCH", CPLD3_REG_SCRATCH }, - { "I2C_PORT_ID", CPLD3_REG_I2C_PORT_ID }, - { "I2C_OP_CODE", CPLD3_REG_I2C_OP_CODE }, - { "I2C_DEV_ADDR", CPLD3_REG_I2C_DEV_ADDR }, - { "I2C_CMD_BYTE0", CPLD3_REG_I2C_CMD_BYTE0 }, - { "I2C_CMD_BYTE1", CPLD3_REG_I2C_CMD_BYTE1 }, - { "I2C_CMD_BYTE2", CPLD3_REG_I2C_CMD_BYTE2 }, - { "I2C_STATUS_RESET", CPLD3_REG_I2C_STATUS_RESET }, - { "I2C_WRITE_DATA_BYTE0", CPLD3_REG_I2C_WRITE_DATA_BYTE0 }, - { "I2C_WRITE_DATA_BYTE1", CPLD3_REG_I2C_WRITE_DATA_BYTE1 }, - { "I2C_WRITE_DATA_BYTE2", CPLD3_REG_I2C_WRITE_DATA_BYTE2 }, - { "I2C_WRITE_DATA_BYTE3", CPLD3_REG_I2C_WRITE_DATA_BYTE3 }, - { "I2C_WRITE_DATA_BYTE4", CPLD3_REG_I2C_WRITE_DATA_BYTE4 }, - { "I2C_WRITE_DATA_BYTE5", CPLD3_REG_I2C_WRITE_DATA_BYTE5 }, - { "I2C_WRITE_DATA_BYTE6", CPLD3_REG_I2C_WRITE_DATA_BYTE6 }, - { "I2C_WRITE_DATA_BYTE7", CPLD3_REG_I2C_WRITE_DATA_BYTE7 }, - { "I2C_READ_DATA_BYTE0", CPLD3_REG_I2C_READ_DATA_BYTE0 }, - { "I2C_READ_DATA_BYTE1", CPLD3_REG_I2C_READ_DATA_BYTE1 }, - { "I2C_READ_DATA_BYTE2", CPLD3_REG_I2C_READ_DATA_BYTE2 }, - { "I2C_READ_DATA_BYTE3", CPLD3_REG_I2C_READ_DATA_BYTE3 }, - { "I2C_READ_DATA_BYTE4", CPLD3_REG_I2C_READ_DATA_BYTE4 }, - { "I2C_READ_DATA_BYTE5", CPLD3_REG_I2C_READ_DATA_BYTE5 }, - { "I2C_READ_DATA_BYTE6", CPLD3_REG_I2C_READ_DATA_BYTE6 }, - { "I2C_READ_DATA_BYTE7", CPLD3_REG_I2C_READ_DATA_BYTE7 }, - { "SFP_19_26_RX_LOS", CPLD3_REG_SFP_19_26_RX_LOS }, - { "SFP_27_34_RX_LOS", CPLD3_REG_SFP_27_34_RX_LOS }, - { "SFP_35_36_RX_LOS", CPLD3_REG_SFP_35_36_RX_LOS }, - { "SFP_19_26_RX_LOS_INT", CPLD3_REG_SFP_19_26_RX_LOS_INT }, - { "SFP_27_34_RX_LOS_INT", CPLD3_REG_SFP_27_34_RX_LOS_INT }, - { "SFP_35_36_RX_LOS_INT", CPLD3_REG_SFP_35_36_RX_LOS_INT }, - { "SFP_19_26_RX_LOS_MASK", CPLD3_REG_SFP_19_26_RX_LOS_MASK }, - { "SFP_27_34_RX_LOS_MASK", CPLD3_REG_SFP_27_34_RX_LOS_MASK }, - { "SFP_35_36_RX_LOS_MASK", CPLD3_REG_SFP_35_36_RX_LOS_MASK }, - { "SFP_19_26_TX_DISABLE", CPLD3_REG_SFP_19_26_TX_DISABLE }, - { "SFP_27_34_TX_DISABLE", CPLD3_REG_SFP_27_34_TX_DISABLE }, - { "SFP_35_36_TX_DISABLE", CPLD3_REG_SFP_35_36_TX_DISABLE }, - { "SFP_19_26_RS_CONTROL", CPLD3_REG_SFP_19_26_RS_CONTROL }, - { "SFP_27_34_RS_CONTROL", CPLD3_REG_SFP_27_34_RS_CONTROL }, - { "SFP_35_36_RS_CONTROL", CPLD3_REG_SFP_35_36_RS_CONTROL }, - { "SFP_19_26_TX_FAULT", CPLD3_REG_SFP_19_26_TX_FAULT }, - { "SFP_27_34_TX_FAULT", CPLD3_REG_SFP_27_34_TX_FAULT }, - { "SFP_35_36_TX_FAULT", CPLD3_REG_SFP_35_36_TX_FAULT }, - { "SFP_19_26_ABS_STATUS", CPLD3_REG_SFP_19_26_ABS_STATUS }, - { "SFP_27_34_ABS_STATUS", CPLD3_REG_SFP_27_34_ABS_STATUS }, - { "SFP_35_36_ABS_STATUS", CPLD3_REG_SFP_35_36_ABS_STATUS }, - { NULL, 0 } -}; - -aim_map_si_t cpld3_reg_desc_map[] = -{ - { "None", CPLD3_REG_VERSION }, - { "None", CPLD3_REG_SCRATCH }, - { "None", CPLD3_REG_I2C_PORT_ID }, - { "None", CPLD3_REG_I2C_OP_CODE }, - { "None", CPLD3_REG_I2C_DEV_ADDR }, - { "None", CPLD3_REG_I2C_CMD_BYTE0 }, - { "None", CPLD3_REG_I2C_CMD_BYTE1 }, - { "None", CPLD3_REG_I2C_CMD_BYTE2 }, - { "None", CPLD3_REG_I2C_STATUS_RESET }, - { "None", CPLD3_REG_I2C_WRITE_DATA_BYTE0 }, - { "None", CPLD3_REG_I2C_WRITE_DATA_BYTE1 }, - { "None", CPLD3_REG_I2C_WRITE_DATA_BYTE2 }, - { "None", CPLD3_REG_I2C_WRITE_DATA_BYTE3 }, - { "None", CPLD3_REG_I2C_WRITE_DATA_BYTE4 }, - { "None", CPLD3_REG_I2C_WRITE_DATA_BYTE5 }, - { "None", CPLD3_REG_I2C_WRITE_DATA_BYTE6 }, - { "None", CPLD3_REG_I2C_WRITE_DATA_BYTE7 }, - { "None", CPLD3_REG_I2C_READ_DATA_BYTE0 }, - { "None", CPLD3_REG_I2C_READ_DATA_BYTE1 }, - { "None", CPLD3_REG_I2C_READ_DATA_BYTE2 }, - { "None", CPLD3_REG_I2C_READ_DATA_BYTE3 }, - { "None", CPLD3_REG_I2C_READ_DATA_BYTE4 }, - { "None", CPLD3_REG_I2C_READ_DATA_BYTE5 }, - { "None", CPLD3_REG_I2C_READ_DATA_BYTE6 }, - { "None", CPLD3_REG_I2C_READ_DATA_BYTE7 }, - { "None", CPLD3_REG_SFP_19_26_RX_LOS }, - { "None", CPLD3_REG_SFP_27_34_RX_LOS }, - { "None", CPLD3_REG_SFP_35_36_RX_LOS }, - { "None", CPLD3_REG_SFP_19_26_RX_LOS_INT }, - { "None", CPLD3_REG_SFP_27_34_RX_LOS_INT }, - { "None", CPLD3_REG_SFP_35_36_RX_LOS_INT }, - { "None", CPLD3_REG_SFP_19_26_RX_LOS_MASK }, - { "None", CPLD3_REG_SFP_27_34_RX_LOS_MASK }, - { "None", CPLD3_REG_SFP_35_36_RX_LOS_MASK }, - { "None", CPLD3_REG_SFP_19_26_TX_DISABLE }, - { "None", CPLD3_REG_SFP_27_34_TX_DISABLE }, - { "None", CPLD3_REG_SFP_35_36_TX_DISABLE }, - { "None", CPLD3_REG_SFP_19_26_RS_CONTROL }, - { "None", CPLD3_REG_SFP_27_34_RS_CONTROL }, - { "None", CPLD3_REG_SFP_35_36_RS_CONTROL }, - { "None", CPLD3_REG_SFP_19_26_TX_FAULT }, - { "None", CPLD3_REG_SFP_27_34_TX_FAULT }, - { "None", CPLD3_REG_SFP_35_36_TX_FAULT }, - { "None", CPLD3_REG_SFP_19_26_ABS_STATUS }, - { "None", CPLD3_REG_SFP_27_34_ABS_STATUS }, - { "None", CPLD3_REG_SFP_35_36_ABS_STATUS }, - { NULL, 0 } -}; - -const char* -cpld3_reg_name(cpld3_reg_t e) -{ - const char* name; - if(aim_map_si_i(&name, e, cpld3_reg_map, 0)) { - return name; - } - else { - return "-invalid value for enum type 'cpld3_reg'"; - } -} - -int -cpld3_reg_value(const char* str, cpld3_reg_t* e, int substr) -{ - int i; - AIM_REFERENCE(substr); - if(aim_map_si_s(&i, str, cpld3_reg_map, 0)) { - /* Enum Found */ - *e = i; - return 0; - } - else { - return -1; - } -} - -const char* -cpld3_reg_desc(cpld3_reg_t e) -{ - const char* name; - if(aim_map_si_i(&name, e, cpld3_reg_desc_map, 0)) { - return name; - } - else { - return "-invalid value for enum type 'cpld3_reg'"; - } -} - -int -cpld3_reg_valid(cpld3_reg_t e) -{ - return aim_map_si_i(NULL, e, cpld3_reg_map, 0) ? 1 : 0; -} - - -aim_map_si_t cpld4_reg_map[] = -{ - { "VERSION", CPLD4_REG_VERSION }, - { "SCRATCH", CPLD4_REG_SCRATCH }, - { "RESET_CONTROL", CPLD4_REG_RESET_CONTROL }, - { "LED_CONTROL", CPLD4_REG_LED_CONTROL }, - { "MISC_STATUS_CONTROL", CPLD4_REG_MISC_STATUS_CONTROL }, - { "INT_PORT_STATUS", CPLD4_REG_INT_PORT_STATUS }, - { "INT0_SOURCE_STATUS", CPLD4_REG_INT0_SOURCE_STATUS }, - { "INT1_SOURCE_STATUS", CPLD4_REG_INT1_SOURCE_STATUS }, - { "INT2_SOURCE_STATUS", CPLD4_REG_INT2_SOURCE_STATUS }, - { "INT0_SOURCE_INT", CPLD4_REG_INT0_SOURCE_INT }, - { "INT1_SOURCE_INT", CPLD4_REG_INT1_SOURCE_INT }, - { "INT2_SOURCE_INT", CPLD4_REG_INT2_SOURCE_INT }, - { "INT0_SOURCE_MASK", CPLD4_REG_INT0_SOURCE_MASK }, - { "INT1_SOURCE_MASK", CPLD4_REG_INT1_SOURCE_MASK }, - { "INT2_SOURCE_MASK", CPLD4_REG_INT2_SOURCE_MASK }, - { "I2C_PORT_ID", CPLD4_REG_I2C_PORT_ID }, - { "I2C_OP_CODE", CPLD4_REG_I2C_OP_CODE }, - { "I2C_DEV_ADDR", CPLD4_REG_I2C_DEV_ADDR }, - { "I2C_COMMAND_BYTE0", CPLD4_REG_I2C_COMMAND_BYTE0 }, - { "I2C_COMMAND_BYTE1", CPLD4_REG_I2C_COMMAND_BYTE1 }, - { "I2C_COMMAND_BYTE2", CPLD4_REG_I2C_COMMAND_BYTE2 }, - { "I2C_STATUS_RESET", CPLD4_REG_I2C_STATUS_RESET }, - { "I2C_WRITE_DATA_BYTE0", CPLD4_REG_I2C_WRITE_DATA_BYTE0 }, - { "I2C_WRITE_DATA_BYTE1", CPLD4_REG_I2C_WRITE_DATA_BYTE1 }, - { "I2C_WRITE_DATA_BYTE2", CPLD4_REG_I2C_WRITE_DATA_BYTE2 }, - { "I2C_WRITE_DATA_BYTE3", CPLD4_REG_I2C_WRITE_DATA_BYTE3 }, - { "I2C_WRITE_DATA_BYTE4", CPLD4_REG_I2C_WRITE_DATA_BYTE4 }, - { "I2C_WRITE_DATA_BYTE5", CPLD4_REG_I2C_WRITE_DATA_BYTE5 }, - { "I2C_WRITE_DATA_BYTE6", CPLD4_REG_I2C_WRITE_DATA_BYTE6 }, - { "I2C_WRITE_DATA_BYTE7", CPLD4_REG_I2C_WRITE_DATA_BYTE7 }, - { "I2C_READ_DATA_BYTE0", CPLD4_REG_I2C_READ_DATA_BYTE0 }, - { "I2C_READ_DATA_BYTE1", CPLD4_REG_I2C_READ_DATA_BYTE1 }, - { "I2C_READ_DATA_BYTE2", CPLD4_REG_I2C_READ_DATA_BYTE2 }, - { "I2C_READ_DATA_BYTE3", CPLD4_REG_I2C_READ_DATA_BYTE3 }, - { "I2C_READ_DATA_BYTE4", CPLD4_REG_I2C_READ_DATA_BYTE4 }, - { "I2C_READ_DATA_BYTE5", CPLD4_REG_I2C_READ_DATA_BYTE5 }, - { "I2C_READ_DATA_BYTE6", CPLD4_REG_I2C_READ_DATA_BYTE6 }, - { "I2C_READ_DATA_BYTE7", CPLD4_REG_I2C_READ_DATA_BYTE7 }, - { "QSFP_RESET_CONTROL", CPLD4_REG_QSFP_RESET_CONTROL }, - { "QSFP_LPMOD_CONTROL", CPLD4_REG_QSFP_LPMOD_CONTROL }, - { "QSFP_ABS_STATUS", CPLD4_REG_QSFP_ABS_STATUS }, - { "QSFP_INT_STATUS", CPLD4_REG_QSFP_INT_STATUS }, - { "QSFP_I2C_READY", CPLD4_REG_QSFP_I2C_READY }, - { NULL, 0 } -}; - -aim_map_si_t cpld4_reg_desc_map[] = -{ - { "None", CPLD4_REG_VERSION }, - { "None", CPLD4_REG_SCRATCH }, - { "None", CPLD4_REG_RESET_CONTROL }, - { "None", CPLD4_REG_LED_CONTROL }, - { "None", CPLD4_REG_MISC_STATUS_CONTROL }, - { "None", CPLD4_REG_INT_PORT_STATUS }, - { "None", CPLD4_REG_INT0_SOURCE_STATUS }, - { "None", CPLD4_REG_INT1_SOURCE_STATUS }, - { "None", CPLD4_REG_INT2_SOURCE_STATUS }, - { "None", CPLD4_REG_INT0_SOURCE_INT }, - { "None", CPLD4_REG_INT1_SOURCE_INT }, - { "None", CPLD4_REG_INT2_SOURCE_INT }, - { "None", CPLD4_REG_INT0_SOURCE_MASK }, - { "None", CPLD4_REG_INT1_SOURCE_MASK }, - { "None", CPLD4_REG_INT2_SOURCE_MASK }, - { "None", CPLD4_REG_I2C_PORT_ID }, - { "None", CPLD4_REG_I2C_OP_CODE }, - { "None", CPLD4_REG_I2C_DEV_ADDR }, - { "None", CPLD4_REG_I2C_COMMAND_BYTE0 }, - { "None", CPLD4_REG_I2C_COMMAND_BYTE1 }, - { "None", CPLD4_REG_I2C_COMMAND_BYTE2 }, - { "None", CPLD4_REG_I2C_STATUS_RESET }, - { "None", CPLD4_REG_I2C_WRITE_DATA_BYTE0 }, - { "None", CPLD4_REG_I2C_WRITE_DATA_BYTE1 }, - { "None", CPLD4_REG_I2C_WRITE_DATA_BYTE2 }, - { "None", CPLD4_REG_I2C_WRITE_DATA_BYTE3 }, - { "None", CPLD4_REG_I2C_WRITE_DATA_BYTE4 }, - { "None", CPLD4_REG_I2C_WRITE_DATA_BYTE5 }, - { "None", CPLD4_REG_I2C_WRITE_DATA_BYTE6 }, - { "None", CPLD4_REG_I2C_WRITE_DATA_BYTE7 }, - { "None", CPLD4_REG_I2C_READ_DATA_BYTE0 }, - { "None", CPLD4_REG_I2C_READ_DATA_BYTE1 }, - { "None", CPLD4_REG_I2C_READ_DATA_BYTE2 }, - { "None", CPLD4_REG_I2C_READ_DATA_BYTE3 }, - { "None", CPLD4_REG_I2C_READ_DATA_BYTE4 }, - { "None", CPLD4_REG_I2C_READ_DATA_BYTE5 }, - { "None", CPLD4_REG_I2C_READ_DATA_BYTE6 }, - { "None", CPLD4_REG_I2C_READ_DATA_BYTE7 }, - { "None", CPLD4_REG_QSFP_RESET_CONTROL }, - { "None", CPLD4_REG_QSFP_LPMOD_CONTROL }, - { "None", CPLD4_REG_QSFP_ABS_STATUS }, - { "None", CPLD4_REG_QSFP_INT_STATUS }, - { "None", CPLD4_REG_QSFP_I2C_READY }, - { NULL, 0 } -}; - -const char* -cpld4_reg_name(cpld4_reg_t e) -{ - const char* name; - if(aim_map_si_i(&name, e, cpld4_reg_map, 0)) { - return name; - } - else { - return "-invalid value for enum type 'cpld4_reg'"; - } -} - -int -cpld4_reg_value(const char* str, cpld4_reg_t* e, int substr) -{ - int i; - AIM_REFERENCE(substr); - if(aim_map_si_s(&i, str, cpld4_reg_map, 0)) { - /* Enum Found */ - *e = i; - return 0; - } - else { - return -1; - } -} - -const char* -cpld4_reg_desc(cpld4_reg_t e) -{ - const char* name; - if(aim_map_si_i(&name, e, cpld4_reg_desc_map, 0)) { - return name; - } - else { - return "-invalid value for enum type 'cpld4_reg'"; - } -} - -int -cpld4_reg_valid(cpld4_reg_t e) -{ - return aim_map_si_i(NULL, e, cpld4_reg_map, 0) ? 1 : 0; -} - - -aim_map_si_t cpld5_reg_map[] = -{ - { "VERSION", CPLD5_REG_VERSION }, - { "SCRATCH", CPLD5_REG_SCRATCH }, - { "I2C_PORT_ID", CPLD5_REG_I2C_PORT_ID }, - { "I2C_OP_CODE", CPLD5_REG_I2C_OP_CODE }, - { "I2C_DEV_ADDR", CPLD5_REG_I2C_DEV_ADDR }, - { "I2C_CMD_BYTE0", CPLD5_REG_I2C_CMD_BYTE0 }, - { "I2C_CMD_BYTE1", CPLD5_REG_I2C_CMD_BYTE1 }, - { "I2C_CMD_BYTE2", CPLD5_REG_I2C_CMD_BYTE2 }, - { "I2C_STATUS_RESET", CPLD5_REG_I2C_STATUS_RESET }, - { "I2C_WRITE_DATA_BYTE0", CPLD5_REG_I2C_WRITE_DATA_BYTE0 }, - { "I2C_WRITE_DATA_BYTE1", CPLD5_REG_I2C_WRITE_DATA_BYTE1 }, - { "I2C_WRITE_DATA_BYTE2", CPLD5_REG_I2C_WRITE_DATA_BYTE2 }, - { "I2C_WRITE_DATA_BYTE3", CPLD5_REG_I2C_WRITE_DATA_BYTE3 }, - { "I2C_WRITE_DATA_BYTE4", CPLD5_REG_I2C_WRITE_DATA_BYTE4 }, - { "I2C_WRITE_DATA_BYTE5", CPLD5_REG_I2C_WRITE_DATA_BYTE5 }, - { "I2C_WRITE_DATA_BYTE6", CPLD5_REG_I2C_WRITE_DATA_BYTE6 }, - { "I2C_WRITE_DATA_BYTE7", CPLD5_REG_I2C_WRITE_DATA_BYTE7 }, - { "I2C_READ_DATA_BYTE0", CPLD5_REG_I2C_READ_DATA_BYTE0 }, - { "I2C_READ_DATA_BYTE1", CPLD5_REG_I2C_READ_DATA_BYTE1 }, - { "I2C_READ_DATA_BYTE2", CPLD5_REG_I2C_READ_DATA_BYTE2 }, - { "I2C_READ_DATA_BYTE3", CPLD5_REG_I2C_READ_DATA_BYTE3 }, - { "I2C_READ_DATA_BYTE4", CPLD5_REG_I2C_READ_DATA_BYTE4 }, - { "I2C_READ_DATA_BYTE5", CPLD5_REG_I2C_READ_DATA_BYTE5 }, - { "I2C_READ_DATA_BYTE6", CPLD5_REG_I2C_READ_DATA_BYTE6 }, - { "I2C_READ_DATA_BYTE7", CPLD5_REG_I2C_READ_DATA_BYTE7 }, - { "SFP_37_44_RX_LOS", CPLD5_REG_SFP_37_44_RX_LOS }, - { "SFP_45_48_RX_LOS", CPLD5_REG_SFP_45_48_RX_LOS }, - { "SFP_37_44_RX_LOS_INT", CPLD5_REG_SFP_37_44_RX_LOS_INT }, - { "SFP_45_48_RX_LOS_INT", CPLD5_REG_SFP_45_48_RX_LOS_INT }, - { "SFP_37_44_RX_LOS_MASK", CPLD5_REG_SFP_37_44_RX_LOS_MASK }, - { "SFP_45_48_RX_LOS_MASK", CPLD5_REG_SFP_45_48_RX_LOS_MASK }, - { "SFP_37_44_TX_DISABLE", CPLD5_REG_SFP_37_44_TX_DISABLE }, - { "SFP_45_48_TX_DISABLE", CPLD5_REG_SFP_45_48_TX_DISABLE }, - { "SFP_37_44_RS_CONTROL", CPLD5_REG_SFP_37_44_RS_CONTROL }, - { "SFP_45_48_RS_CONTROL", CPLD5_REG_SFP_45_48_RS_CONTROL }, - { "SFP_37_44_TX_FAULT", CPLD5_REG_SFP_37_44_TX_FAULT }, - { "SFP_45_48_TX_FAULT", CPLD5_REG_SFP_45_48_TX_FAULT }, - { "SFP_37_44_ABS_STATUS", CPLD5_REG_SFP_37_44_ABS_STATUS }, - { "SFP_45_48_ABS_STATUS", CPLD5_REG_SFP_45_48_ABS_STATUS }, - { NULL, 0 } -}; - -aim_map_si_t cpld5_reg_desc_map[] = -{ - { "None", CPLD5_REG_VERSION }, - { "None", CPLD5_REG_SCRATCH }, - { "None", CPLD5_REG_I2C_PORT_ID }, - { "None", CPLD5_REG_I2C_OP_CODE }, - { "None", CPLD5_REG_I2C_DEV_ADDR }, - { "None", CPLD5_REG_I2C_CMD_BYTE0 }, - { "None", CPLD5_REG_I2C_CMD_BYTE1 }, - { "None", CPLD5_REG_I2C_CMD_BYTE2 }, - { "None", CPLD5_REG_I2C_STATUS_RESET }, - { "None", CPLD5_REG_I2C_WRITE_DATA_BYTE0 }, - { "None", CPLD5_REG_I2C_WRITE_DATA_BYTE1 }, - { "None", CPLD5_REG_I2C_WRITE_DATA_BYTE2 }, - { "None", CPLD5_REG_I2C_WRITE_DATA_BYTE3 }, - { "None", CPLD5_REG_I2C_WRITE_DATA_BYTE4 }, - { "None", CPLD5_REG_I2C_WRITE_DATA_BYTE5 }, - { "None", CPLD5_REG_I2C_WRITE_DATA_BYTE6 }, - { "None", CPLD5_REG_I2C_WRITE_DATA_BYTE7 }, - { "None", CPLD5_REG_I2C_READ_DATA_BYTE0 }, - { "None", CPLD5_REG_I2C_READ_DATA_BYTE1 }, - { "None", CPLD5_REG_I2C_READ_DATA_BYTE2 }, - { "None", CPLD5_REG_I2C_READ_DATA_BYTE3 }, - { "None", CPLD5_REG_I2C_READ_DATA_BYTE4 }, - { "None", CPLD5_REG_I2C_READ_DATA_BYTE5 }, - { "None", CPLD5_REG_I2C_READ_DATA_BYTE6 }, - { "None", CPLD5_REG_I2C_READ_DATA_BYTE7 }, - { "None", CPLD5_REG_SFP_37_44_RX_LOS }, - { "None", CPLD5_REG_SFP_45_48_RX_LOS }, - { "None", CPLD5_REG_SFP_37_44_RX_LOS_INT }, - { "None", CPLD5_REG_SFP_45_48_RX_LOS_INT }, - { "None", CPLD5_REG_SFP_37_44_RX_LOS_MASK }, - { "None", CPLD5_REG_SFP_45_48_RX_LOS_MASK }, - { "None", CPLD5_REG_SFP_37_44_TX_DISABLE }, - { "None", CPLD5_REG_SFP_45_48_TX_DISABLE }, - { "None", CPLD5_REG_SFP_37_44_RS_CONTROL }, - { "None", CPLD5_REG_SFP_45_48_RS_CONTROL }, - { "None", CPLD5_REG_SFP_37_44_TX_FAULT }, - { "None", CPLD5_REG_SFP_45_48_TX_FAULT }, - { "None", CPLD5_REG_SFP_37_44_ABS_STATUS }, - { "None", CPLD5_REG_SFP_45_48_ABS_STATUS }, - { NULL, 0 } -}; - -const char* -cpld5_reg_name(cpld5_reg_t e) -{ - const char* name; - if(aim_map_si_i(&name, e, cpld5_reg_map, 0)) { - return name; - } - else { - return "-invalid value for enum type 'cpld5_reg'"; - } -} - -int -cpld5_reg_value(const char* str, cpld5_reg_t* e, int substr) -{ - int i; - AIM_REFERENCE(substr); - if(aim_map_si_s(&i, str, cpld5_reg_map, 0)) { - /* Enum Found */ - *e = i; - return 0; - } - else { - return -1; - } -} - -const char* -cpld5_reg_desc(cpld5_reg_t e) -{ - const char* name; - if(aim_map_si_i(&name, e, cpld5_reg_desc_map, 0)) { - return name; - } - else { - return "-invalid value for enum type 'cpld5_reg'"; - } -} - -int -cpld5_reg_valid(cpld5_reg_t e) -{ - return aim_map_si_i(NULL, e, cpld5_reg_map, 0) ? 1 : 0; -} - -/* */ - diff --git a/packages/platforms/celestica/x86-64/redstone-xp/onlp/builds/x86_64_cel_redstone_xp/module/src/x86_64_cel_redstone_xp_int.h b/packages/platforms/celestica/x86-64/redstone-xp/onlp/builds/x86_64_cel_redstone_xp/module/src/x86_64_cel_redstone_xp_int.h deleted file mode 100644 index 27f574672..000000000 --- a/packages/platforms/celestica/x86-64/redstone-xp/onlp/builds/x86_64_cel_redstone_xp/module/src/x86_64_cel_redstone_xp_int.h +++ /dev/null @@ -1,337 +0,0 @@ -/**************************************************************************//** - * - * x86_64_cel_redstone_xp Internal Header - * - *****************************************************************************/ -#ifndef __X86_64_CEL_REDSTONE_XP_INT_H__ -#define __X86_64_CEL_REDSTONE_XP_INT_H__ - -#include - -/* */ -/** cpld1_reg */ -typedef enum cpld1_reg_e { - CPLD1_REG_VERSION = 256, - CPLD1_REG_SCRATCH = 257, - CPLD1_REG_RESET_CONTROL = 258, - CPLD1_REG_RESET_SOURCE = 259, - CPLD1_REG_BOARD_TYPE = 260, - CPLD1_REG_INT_PORT_STATUS = 272, - CPLD1_REG_INT0_SOURCE_STATUS = 273, - CPLD1_REG_INT0_SOURCE_INT = 274, - CPLD1_REG_INT0_SOURCE_MASK = 275, - CPLD1_REG_POWER_SUPPLY_STATUS = 288, - CPLD1_REG_POWER_GOOD_STATUS = 289, - CPLD1_REG_BPP_CONTROL = 290, - CPLD1_REG_WRITE_PROTECT_CONTROL = 291, - CPLD1_REG_MISC_STATUS_CONTROL = 292, - CPLD1_REG_INFO_RAM_ADDR_HIGH = 304, - CPLD1_REG_INFO_RAM_ADDR_LOW = 305, - CPLD1_REG_INFO_RAM_READ_DATA = 306, - CPLD1_REG_INFO_RAM_WRITE_DATA = 307, -} cpld1_reg_t; - -/** Enum names. */ -const char* cpld1_reg_name(cpld1_reg_t e); - -/** Enum values. */ -int cpld1_reg_value(const char* str, cpld1_reg_t* e, int substr); - -/** Enum descriptions. */ -const char* cpld1_reg_desc(cpld1_reg_t e); - -/** Enum validator. */ -int cpld1_reg_valid(cpld1_reg_t e); - -/** validator */ -#define CPLD1_REG_VALID(_e) \ - (cpld1_reg_valid((_e))) - -/** cpld1_reg_map table. */ -extern aim_map_si_t cpld1_reg_map[]; -/** cpld1_reg_desc_map table. */ -extern aim_map_si_t cpld1_reg_desc_map[]; - -/** cpld2_reg */ -typedef enum cpld2_reg_e { - CPLD2_REG_VERSION = 512, - CPLD2_REG_SCRATCH = 513, - CPLD2_REG_I2C_PORT_ID = 528, - CPLD2_REG_I2C_OP_CODE = 529, - CPLD2_REG_I2C_DEV_ADDR = 530, - CPLD2_REG_I2C_CMD_BYTE0 = 531, - CPLD2_REG_I2C_CMD_BYTE1 = 532, - CPLD2_REG_I2C_CMD_BYTE2 = 533, - CPLD2_REG_I2C_STATUS_RESET = 534, - CPLD2_REG_I2C_WRITE_DATA_BYTE0 = 544, - CPLD2_REG_I2C_WRITE_DATA_BYTE1 = 545, - CPLD2_REG_I2C_WRITE_DATA_BYTE2 = 546, - CPLD2_REG_I2C_WRITE_DATA_BYTE3 = 547, - CPLD2_REG_I2C_WRITE_DATA_BYTE4 = 548, - CPLD2_REG_I2C_WRITE_DATA_BYTE5 = 549, - CPLD2_REG_I2C_WRITE_DATA_BYTE6 = 550, - CPLD2_REG_I2C_WRITE_DATA_BYTE7 = 551, - CPLD2_REG_I2C_READ_DATA_BYTE0 = 560, - CPLD2_REG_I2C_READ_DATA_BYTE1 = 561, - CPLD2_REG_I2C_READ_DATA_BYTE2 = 562, - CPLD2_REG_I2C_READ_DATA_BYTE3 = 563, - CPLD2_REG_I2C_READ_DATA_BYTE4 = 564, - CPLD2_REG_I2C_READ_DATA_BYTE5 = 565, - CPLD2_REG_I2C_READ_DATA_BYTE6 = 566, - CPLD2_REG_I2C_READ_DATA_BYTE7 = 567, - CPLD2_REG_SFP_1_8_RX_LOS = 576, - CPLD2_REG_SFP_9_16_RX_LOS = 577, - CPLD2_REG_SFP_17_18_RX_LOS = 578, - CPLD2_REG_SFP_1_8_RX_LOS_INT = 579, - CPLD2_REG_SFP_9_16_RX_LOS_INT = 580, - CPLD2_REG_SFP_17_18_RX_LOS_INT = 581, - CPLD2_REG_SFP_1_8_RX_LOS_MASK = 582, - CPLD2_REG_SFP_9_16_RX_LOS_MASK = 583, - CPLD2_REG_SFP_17_18_RX_LOS_MASK = 584, - CPLD2_REG_SFP_1_8_TX_DISABLE = 592, - CPLD2_REG_SFP_9_16_TX_DISABLE = 593, - CPLD2_REG_SFP_17_18_TX_DISABLE = 594, - CPLD2_REG_SFP_1_8_RS_CONTROL = 595, - CPLD2_REG_SFP_9_16_RS_CONTROL = 596, - CPLD2_REG_SFP_17_18_RS_CONTROL = 597, - CPLD2_REG_SFP_1_8_TX_FAULT = 598, - CPLD2_REG_SFP_9_16_TX_FAULT = 599, - CPLD2_REG_SFP_17_18_TX_FAULT = 600, - CPLD2_REG_SFP_1_8_ABS_STATUS = 601, - CPLD2_REG_SFP_9_16_ABS_STATUS = 602, - CPLD2_REG_SFP_17_18_ABS_STATUS = 603, -} cpld2_reg_t; - -/** Enum names. */ -const char* cpld2_reg_name(cpld2_reg_t e); - -/** Enum values. */ -int cpld2_reg_value(const char* str, cpld2_reg_t* e, int substr); - -/** Enum descriptions. */ -const char* cpld2_reg_desc(cpld2_reg_t e); - -/** Enum validator. */ -int cpld2_reg_valid(cpld2_reg_t e); - -/** validator */ -#define CPLD2_REG_VALID(_e) \ - (cpld2_reg_valid((_e))) - -/** cpld2_reg_map table. */ -extern aim_map_si_t cpld2_reg_map[]; -/** cpld2_reg_desc_map table. */ -extern aim_map_si_t cpld2_reg_desc_map[]; - -/** cpld3_reg */ -typedef enum cpld3_reg_e { - CPLD3_REG_VERSION = 640, - CPLD3_REG_SCRATCH = 641, - CPLD3_REG_I2C_PORT_ID = 656, - CPLD3_REG_I2C_OP_CODE = 657, - CPLD3_REG_I2C_DEV_ADDR = 658, - CPLD3_REG_I2C_CMD_BYTE0 = 659, - CPLD3_REG_I2C_CMD_BYTE1 = 660, - CPLD3_REG_I2C_CMD_BYTE2 = 661, - CPLD3_REG_I2C_STATUS_RESET = 662, - CPLD3_REG_I2C_WRITE_DATA_BYTE0 = 672, - CPLD3_REG_I2C_WRITE_DATA_BYTE1 = 673, - CPLD3_REG_I2C_WRITE_DATA_BYTE2 = 674, - CPLD3_REG_I2C_WRITE_DATA_BYTE3 = 675, - CPLD3_REG_I2C_WRITE_DATA_BYTE4 = 676, - CPLD3_REG_I2C_WRITE_DATA_BYTE5 = 677, - CPLD3_REG_I2C_WRITE_DATA_BYTE6 = 678, - CPLD3_REG_I2C_WRITE_DATA_BYTE7 = 679, - CPLD3_REG_I2C_READ_DATA_BYTE0 = 688, - CPLD3_REG_I2C_READ_DATA_BYTE1 = 689, - CPLD3_REG_I2C_READ_DATA_BYTE2 = 690, - CPLD3_REG_I2C_READ_DATA_BYTE3 = 691, - CPLD3_REG_I2C_READ_DATA_BYTE4 = 692, - CPLD3_REG_I2C_READ_DATA_BYTE5 = 693, - CPLD3_REG_I2C_READ_DATA_BYTE6 = 694, - CPLD3_REG_I2C_READ_DATA_BYTE7 = 695, - CPLD3_REG_SFP_19_26_RX_LOS = 704, - CPLD3_REG_SFP_27_34_RX_LOS = 705, - CPLD3_REG_SFP_35_36_RX_LOS = 706, - CPLD3_REG_SFP_19_26_RX_LOS_INT = 707, - CPLD3_REG_SFP_27_34_RX_LOS_INT = 708, - CPLD3_REG_SFP_35_36_RX_LOS_INT = 709, - CPLD3_REG_SFP_19_26_RX_LOS_MASK = 710, - CPLD3_REG_SFP_27_34_RX_LOS_MASK = 711, - CPLD3_REG_SFP_35_36_RX_LOS_MASK = 712, - CPLD3_REG_SFP_19_26_TX_DISABLE = 720, - CPLD3_REG_SFP_27_34_TX_DISABLE = 721, - CPLD3_REG_SFP_35_36_TX_DISABLE = 722, - CPLD3_REG_SFP_19_26_RS_CONTROL = 723, - CPLD3_REG_SFP_27_34_RS_CONTROL = 724, - CPLD3_REG_SFP_35_36_RS_CONTROL = 725, - CPLD3_REG_SFP_19_26_TX_FAULT = 726, - CPLD3_REG_SFP_27_34_TX_FAULT = 727, - CPLD3_REG_SFP_35_36_TX_FAULT = 728, - CPLD3_REG_SFP_19_26_ABS_STATUS = 729, - CPLD3_REG_SFP_27_34_ABS_STATUS = 730, - CPLD3_REG_SFP_35_36_ABS_STATUS = 731, -} cpld3_reg_t; - -/** Enum names. */ -const char* cpld3_reg_name(cpld3_reg_t e); - -/** Enum values. */ -int cpld3_reg_value(const char* str, cpld3_reg_t* e, int substr); - -/** Enum descriptions. */ -const char* cpld3_reg_desc(cpld3_reg_t e); - -/** Enum validator. */ -int cpld3_reg_valid(cpld3_reg_t e); - -/** validator */ -#define CPLD3_REG_VALID(_e) \ - (cpld3_reg_valid((_e))) - -/** cpld3_reg_map table. */ -extern aim_map_si_t cpld3_reg_map[]; -/** cpld3_reg_desc_map table. */ -extern aim_map_si_t cpld3_reg_desc_map[]; - -/** cpld4_reg */ -typedef enum cpld4_reg_e { - CPLD4_REG_VERSION = 768, - CPLD4_REG_SCRATCH = 769, - CPLD4_REG_RESET_CONTROL = 770, - CPLD4_REG_LED_CONTROL = 771, - CPLD4_REG_MISC_STATUS_CONTROL = 772, - CPLD4_REG_INT_PORT_STATUS = 773, - CPLD4_REG_INT0_SOURCE_STATUS = 774, - CPLD4_REG_INT1_SOURCE_STATUS = 775, - CPLD4_REG_INT2_SOURCE_STATUS = 776, - CPLD4_REG_INT0_SOURCE_INT = 777, - CPLD4_REG_INT1_SOURCE_INT = 778, - CPLD4_REG_INT2_SOURCE_INT = 779, - CPLD4_REG_INT0_SOURCE_MASK = 780, - CPLD4_REG_INT1_SOURCE_MASK = 781, - CPLD4_REG_INT2_SOURCE_MASK = 782, - CPLD4_REG_I2C_PORT_ID = 784, - CPLD4_REG_I2C_OP_CODE = 785, - CPLD4_REG_I2C_DEV_ADDR = 786, - CPLD4_REG_I2C_COMMAND_BYTE0 = 787, - CPLD4_REG_I2C_COMMAND_BYTE1 = 788, - CPLD4_REG_I2C_COMMAND_BYTE2 = 789, - CPLD4_REG_I2C_STATUS_RESET = 790, - CPLD4_REG_I2C_WRITE_DATA_BYTE0 = 800, - CPLD4_REG_I2C_WRITE_DATA_BYTE1 = 801, - CPLD4_REG_I2C_WRITE_DATA_BYTE2 = 802, - CPLD4_REG_I2C_WRITE_DATA_BYTE3 = 803, - CPLD4_REG_I2C_WRITE_DATA_BYTE4 = 804, - CPLD4_REG_I2C_WRITE_DATA_BYTE5 = 805, - CPLD4_REG_I2C_WRITE_DATA_BYTE6 = 806, - CPLD4_REG_I2C_WRITE_DATA_BYTE7 = 807, - CPLD4_REG_I2C_READ_DATA_BYTE0 = 816, - CPLD4_REG_I2C_READ_DATA_BYTE1 = 817, - CPLD4_REG_I2C_READ_DATA_BYTE2 = 818, - CPLD4_REG_I2C_READ_DATA_BYTE3 = 819, - CPLD4_REG_I2C_READ_DATA_BYTE4 = 820, - CPLD4_REG_I2C_READ_DATA_BYTE5 = 821, - CPLD4_REG_I2C_READ_DATA_BYTE6 = 822, - CPLD4_REG_I2C_READ_DATA_BYTE7 = 823, - CPLD4_REG_QSFP_RESET_CONTROL = 864, - CPLD4_REG_QSFP_LPMOD_CONTROL = 865, - CPLD4_REG_QSFP_ABS_STATUS = 866, - CPLD4_REG_QSFP_INT_STATUS = 867, - CPLD4_REG_QSFP_I2C_READY = 868, -} cpld4_reg_t; - -/** Enum names. */ -const char* cpld4_reg_name(cpld4_reg_t e); - -/** Enum values. */ -int cpld4_reg_value(const char* str, cpld4_reg_t* e, int substr); - -/** Enum descriptions. */ -const char* cpld4_reg_desc(cpld4_reg_t e); - -/** Enum validator. */ -int cpld4_reg_valid(cpld4_reg_t e); - -/** validator */ -#define CPLD4_REG_VALID(_e) \ - (cpld4_reg_valid((_e))) - -/** cpld4_reg_map table. */ -extern aim_map_si_t cpld4_reg_map[]; -/** cpld4_reg_desc_map table. */ -extern aim_map_si_t cpld4_reg_desc_map[]; - -/** cpld5_reg */ -typedef enum cpld5_reg_e { - CPLD5_REG_VERSION = 896, - CPLD5_REG_SCRATCH = 897, - CPLD5_REG_I2C_PORT_ID = 912, - CPLD5_REG_I2C_OP_CODE = 913, - CPLD5_REG_I2C_DEV_ADDR = 914, - CPLD5_REG_I2C_CMD_BYTE0 = 915, - CPLD5_REG_I2C_CMD_BYTE1 = 916, - CPLD5_REG_I2C_CMD_BYTE2 = 917, - CPLD5_REG_I2C_STATUS_RESET = 918, - CPLD5_REG_I2C_WRITE_DATA_BYTE0 = 928, - CPLD5_REG_I2C_WRITE_DATA_BYTE1 = 929, - CPLD5_REG_I2C_WRITE_DATA_BYTE2 = 930, - CPLD5_REG_I2C_WRITE_DATA_BYTE3 = 931, - CPLD5_REG_I2C_WRITE_DATA_BYTE4 = 932, - CPLD5_REG_I2C_WRITE_DATA_BYTE5 = 933, - CPLD5_REG_I2C_WRITE_DATA_BYTE6 = 934, - CPLD5_REG_I2C_WRITE_DATA_BYTE7 = 935, - CPLD5_REG_I2C_READ_DATA_BYTE0 = 944, - CPLD5_REG_I2C_READ_DATA_BYTE1 = 945, - CPLD5_REG_I2C_READ_DATA_BYTE2 = 946, - CPLD5_REG_I2C_READ_DATA_BYTE3 = 947, - CPLD5_REG_I2C_READ_DATA_BYTE4 = 948, - CPLD5_REG_I2C_READ_DATA_BYTE5 = 949, - CPLD5_REG_I2C_READ_DATA_BYTE6 = 950, - CPLD5_REG_I2C_READ_DATA_BYTE7 = 951, - CPLD5_REG_SFP_37_44_RX_LOS = 960, - CPLD5_REG_SFP_45_48_RX_LOS = 961, - CPLD5_REG_SFP_37_44_RX_LOS_INT = 962, - CPLD5_REG_SFP_45_48_RX_LOS_INT = 963, - CPLD5_REG_SFP_37_44_RX_LOS_MASK = 964, - CPLD5_REG_SFP_45_48_RX_LOS_MASK = 965, - CPLD5_REG_SFP_37_44_TX_DISABLE = 976, - CPLD5_REG_SFP_45_48_TX_DISABLE = 977, - CPLD5_REG_SFP_37_44_RS_CONTROL = 978, - CPLD5_REG_SFP_45_48_RS_CONTROL = 979, - CPLD5_REG_SFP_37_44_TX_FAULT = 980, - CPLD5_REG_SFP_45_48_TX_FAULT = 981, - CPLD5_REG_SFP_37_44_ABS_STATUS = 982, - CPLD5_REG_SFP_45_48_ABS_STATUS = 983, -} cpld5_reg_t; - -/** Enum names. */ -const char* cpld5_reg_name(cpld5_reg_t e); - -/** Enum values. */ -int cpld5_reg_value(const char* str, cpld5_reg_t* e, int substr); - -/** Enum descriptions. */ -const char* cpld5_reg_desc(cpld5_reg_t e); - -/** Enum validator. */ -int cpld5_reg_valid(cpld5_reg_t e); - -/** validator */ -#define CPLD5_REG_VALID(_e) \ - (cpld5_reg_valid((_e))) - -/** cpld5_reg_map table. */ -extern aim_map_si_t cpld5_reg_map[]; -/** cpld5_reg_desc_map table. */ -extern aim_map_si_t cpld5_reg_desc_map[]; -/* */ - -#define CEL_REDSTONE_MAX_PORT 54 -#define ALL_SFP_I2C_ADDRESS (0xA0 >> 1) -#define ALL_SFP_DIAG_I2C_ADDRESS (0xA2 >> 1) -#define SFP_XFP_LOS_ADDR 110 -#define SFP_XFP_LOS_SIZE 1 -#define QSFP_LOS_ADDR 3 - -#endif /* __X86_64_CEL_REDSTONE_XP_INT_H__ */ diff --git a/packages/platforms/celestica/x86-64/redstone-xp/onlp/builds/x86_64_cel_redstone_xp/module/src/x86_64_cel_redstone_xp_log.c b/packages/platforms/celestica/x86-64/redstone-xp/onlp/builds/x86_64_cel_redstone_xp/module/src/x86_64_cel_redstone_xp_log.c deleted file mode 100644 index 363c1170e..000000000 --- a/packages/platforms/celestica/x86-64/redstone-xp/onlp/builds/x86_64_cel_redstone_xp/module/src/x86_64_cel_redstone_xp_log.c +++ /dev/null @@ -1,18 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#include - -#include "x86_64_cel_redstone_xp_log.h" -/* - * x86_64_cel_redstone_xp log struct. - */ -AIM_LOG_STRUCT_DEFINE( - X86_64_CEL_REDSTONE_XP_CONFIG_LOG_OPTIONS_DEFAULT, - X86_64_CEL_REDSTONE_XP_CONFIG_LOG_BITS_DEFAULT, - NULL, /* Custom log map */ - X86_64_CEL_REDSTONE_XP_CONFIG_LOG_CUSTOM_BITS_DEFAULT - ); - diff --git a/packages/platforms/celestica/x86-64/redstone-xp/onlp/builds/x86_64_cel_redstone_xp/module/src/x86_64_cel_redstone_xp_log.h b/packages/platforms/celestica/x86-64/redstone-xp/onlp/builds/x86_64_cel_redstone_xp/module/src/x86_64_cel_redstone_xp_log.h deleted file mode 100644 index 03a5649b3..000000000 --- a/packages/platforms/celestica/x86-64/redstone-xp/onlp/builds/x86_64_cel_redstone_xp/module/src/x86_64_cel_redstone_xp_log.h +++ /dev/null @@ -1,12 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#ifndef __X86_64_CEL_REDSTONE_XP_LOG_H__ -#define __X86_64_CEL_REDSTONE_XP_LOG_H__ - -#define AIM_LOG_MODULE_NAME x86_64_cel_redstone_xp -#include - -#endif /* __X86_64_CEL_REDSTONE_XP_LOG_H__ */ diff --git a/packages/platforms/celestica/x86-64/redstone-xp/onlp/builds/x86_64_cel_redstone_xp/module/src/x86_64_cel_redstone_xp_module.c b/packages/platforms/celestica/x86-64/redstone-xp/onlp/builds/x86_64_cel_redstone_xp/module/src/x86_64_cel_redstone_xp_module.c deleted file mode 100644 index 6c337ad51..000000000 --- a/packages/platforms/celestica/x86-64/redstone-xp/onlp/builds/x86_64_cel_redstone_xp/module/src/x86_64_cel_redstone_xp_module.c +++ /dev/null @@ -1,24 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#include - -#include "x86_64_cel_redstone_xp_log.h" - -static int -datatypes_init__(void) -{ -#define X86_64_CEL_REDSTONE_XP_ENUMERATION_ENTRY(_enum_name, _desc) AIM_DATATYPE_MAP_REGISTER(_enum_name, _enum_name##_map, _desc, AIM_LOG_INTERNAL); -#include - return 0; -} - -void __x86_64_cel_redstone_xp_module_init__(void) -{ - AIM_LOG_STRUCT_REGISTER(); - datatypes_init__(); -} - -int __onlp_platform_version__ = 1; diff --git a/packages/platforms/celestica/x86-64/redstone-xp/onlp/builds/x86_64_cel_redstone_xp/module/src/x86_64_cel_redstone_xp_ucli.c b/packages/platforms/celestica/x86-64/redstone-xp/onlp/builds/x86_64_cel_redstone_xp/module/src/x86_64_cel_redstone_xp_ucli.c deleted file mode 100644 index 97a4473c6..000000000 --- a/packages/platforms/celestica/x86-64/redstone-xp/onlp/builds/x86_64_cel_redstone_xp/module/src/x86_64_cel_redstone_xp_ucli.c +++ /dev/null @@ -1,50 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#include - -#if X86_64_CEL_REDSTONE_XP_CONFIG_INCLUDE_UCLI == 1 - -#include -#include -#include - -static ucli_status_t -x86_64_cel_redstone_xp_ucli_ucli__config__(ucli_context_t* uc) -{ - UCLI_HANDLER_MACRO_MODULE_CONFIG(x86_64_cel_redstone_xp) -} - -/* */ -/* */ - -static ucli_module_t -x86_64_cel_redstone_xp_ucli_module__ = - { - "x86_64_cel_redstone_xp_ucli", - NULL, - x86_64_cel_redstone_xp_ucli_ucli_handlers__, - NULL, - NULL, - }; - -ucli_node_t* -x86_64_cel_redstone_xp_ucli_node_create(void) -{ - ucli_node_t* n; - ucli_module_init(&x86_64_cel_redstone_xp_ucli_module__); - n = ucli_node_create("x86_64_cel_redstone_xp", NULL, &x86_64_cel_redstone_xp_ucli_module__); - ucli_node_subnode_add(n, ucli_module_log_node_create("x86_64_cel_redstone_xp")); - return n; -} - -#else -void* -x86_64_cel_redstone_xp_ucli_node_create(void) -{ - return NULL; -} -#endif - diff --git a/packages/platforms/celestica/x86-64/redstone-xp/platform-config/Makefile b/packages/platforms/celestica/x86-64/redstone-xp/platform-config/Makefile deleted file mode 100644 index 003238cf6..000000000 --- a/packages/platforms/celestica/x86-64/redstone-xp/platform-config/Makefile +++ /dev/null @@ -1 +0,0 @@ -include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/celestica/x86-64/redstone-xp/platform-config/r0/Makefile b/packages/platforms/celestica/x86-64/redstone-xp/platform-config/r0/Makefile deleted file mode 100644 index 003238cf6..000000000 --- a/packages/platforms/celestica/x86-64/redstone-xp/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/celestica/x86-64/redstone-xp/platform-config/r0/PKG.yml b/packages/platforms/celestica/x86-64/redstone-xp/platform-config/r0/PKG.yml deleted file mode 100644 index 7ff2ca363..000000000 --- a/packages/platforms/celestica/x86-64/redstone-xp/platform-config/r0/PKG.yml +++ /dev/null @@ -1 +0,0 @@ -!include $ONL_TEMPLATES/platform-config-platform.yml ARCH=amd64 VENDOR=celestica BASENAME=x86-64-cel-redstone-xp REVISION=r0 diff --git a/packages/platforms/celestica/x86-64/redstone-xp/platform-config/r0/src/lib/x86-64-cel-redstone-xp-r0.yml b/packages/platforms/celestica/x86-64/redstone-xp/platform-config/r0/src/lib/x86-64-cel-redstone-xp-r0.yml deleted file mode 100644 index 3c37e6b5d..000000000 --- a/packages/platforms/celestica/x86-64/redstone-xp/platform-config/r0/src/lib/x86-64-cel-redstone-xp-r0.yml +++ /dev/null @@ -1,31 +0,0 @@ ---- - -###################################################################### -# -# platform-config for REDSTONE -# -###################################################################### - -x86-64-cel-redstone-xp-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/celestica/x86-64/redstone-xp/platform-config/r0/src/python/x86_64_cel_redstone_xp_r0/__init__.py b/packages/platforms/celestica/x86-64/redstone-xp/platform-config/r0/src/python/x86_64_cel_redstone_xp_r0/__init__.py deleted file mode 100644 index 0a683e2fe..000000000 --- a/packages/platforms/celestica/x86-64/redstone-xp/platform-config/r0/src/python/x86_64_cel_redstone_xp_r0/__init__.py +++ /dev/null @@ -1,8 +0,0 @@ -from onl.platform.base import * -from onl.platform.celestica import * - -class OnlPlatform_x86_64_cel_redstone_xp_r0(OnlPlatformCelestica, - OnlPlatformPortConfig_48x10_6x40): - PLATFORM='x86-64-cel-redstone-xp-r0' - MODEL="Redstone XP" - SYS_OBJECT_ID=".2060.1" diff --git a/packages/platforms/celestica/x86-64/seastone/Makefile b/packages/platforms/celestica/x86-64/seastone/Makefile deleted file mode 100644 index dc1e7b86f..000000000 --- a/packages/platforms/celestica/x86-64/seastone/Makefile +++ /dev/null @@ -1 +0,0 @@ -include $(ONL)/make/pkg.mk diff --git a/packages/platforms/celestica/x86-64/seastone/modules/Makefile b/packages/platforms/celestica/x86-64/seastone/modules/Makefile deleted file mode 100644 index 003238cf6..000000000 --- a/packages/platforms/celestica/x86-64/seastone/modules/Makefile +++ /dev/null @@ -1 +0,0 @@ -include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/celestica/x86-64/seastone/modules/PKG.yml b/packages/platforms/celestica/x86-64/seastone/modules/PKG.yml deleted file mode 100644 index d76f692aa..000000000 --- a/packages/platforms/celestica/x86-64/seastone/modules/PKG.yml +++ /dev/null @@ -1 +0,0 @@ -!include $ONL_TEMPLATES/no-platform-modules.yml ARCH=amd64 VENDOR=celestica BASENAME=x86-64-cel-seastone diff --git a/packages/platforms/celestica/x86-64/seastone/onlp/Makefile b/packages/platforms/celestica/x86-64/seastone/onlp/Makefile deleted file mode 100644 index dc1e7b86f..000000000 --- a/packages/platforms/celestica/x86-64/seastone/onlp/Makefile +++ /dev/null @@ -1 +0,0 @@ -include $(ONL)/make/pkg.mk diff --git a/packages/platforms/celestica/x86-64/seastone/onlp/PKG.yml b/packages/platforms/celestica/x86-64/seastone/onlp/PKG.yml deleted file mode 100644 index e45f8811c..000000000 --- a/packages/platforms/celestica/x86-64/seastone/onlp/PKG.yml +++ /dev/null @@ -1,15 +0,0 @@ -variables: - platform: x86-64-cel-seastone-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 - comment: dummy package for ONLP on Celestica Seastone -packages: - - name: onlp-${platform} - summary: ONLP Package for the ${platform} platform. - - changelog: initial version diff --git a/packages/platforms/celestica/x86-64/seastone/platform-config/Makefile b/packages/platforms/celestica/x86-64/seastone/platform-config/Makefile deleted file mode 100644 index dc1e7b86f..000000000 --- a/packages/platforms/celestica/x86-64/seastone/platform-config/Makefile +++ /dev/null @@ -1 +0,0 @@ -include $(ONL)/make/pkg.mk diff --git a/packages/platforms/celestica/x86-64/seastone/platform-config/r0/Makefile b/packages/platforms/celestica/x86-64/seastone/platform-config/r0/Makefile deleted file mode 100644 index dc1e7b86f..000000000 --- a/packages/platforms/celestica/x86-64/seastone/platform-config/r0/Makefile +++ /dev/null @@ -1 +0,0 @@ -include $(ONL)/make/pkg.mk diff --git a/packages/platforms/celestica/x86-64/seastone/platform-config/r0/PKG.yml b/packages/platforms/celestica/x86-64/seastone/platform-config/r0/PKG.yml deleted file mode 100644 index 8db41dc9b..000000000 --- a/packages/platforms/celestica/x86-64/seastone/platform-config/r0/PKG.yml +++ /dev/null @@ -1 +0,0 @@ -!include $ONL_TEMPLATES/platform-config-platform.yml ARCH=amd64 VENDOR=celestica BASENAME=x86-64-cel-seastone REVISION=r0 diff --git a/packages/platforms/celestica/x86-64/seastone/platform-config/r0/src/lib/x86-64-cel-seastone-r0.yml b/packages/platforms/celestica/x86-64/seastone/platform-config/r0/src/lib/x86-64-cel-seastone-r0.yml deleted file mode 100644 index c8255d1fa..000000000 --- a/packages/platforms/celestica/x86-64/seastone/platform-config/r0/src/lib/x86-64-cel-seastone-r0.yml +++ /dev/null @@ -1,32 +0,0 @@ ---- - -###################################################################### -# -# platform-config for Celestica Seastone -# -# -###################################################################### - -x86-64-cel-seastone-r0: - - grub: - - serial: >- - --port=0x3f8 - --speed=115200 - --word=8 - --parity=0 - --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/celestica/x86-64/seastone/platform-config/r0/src/python/x86_64_cel_seastone_r0/__init__.py b/packages/platforms/celestica/x86-64/seastone/platform-config/r0/src/python/x86_64_cel_seastone_r0/__init__.py deleted file mode 100644 index d0953da1d..000000000 --- a/packages/platforms/celestica/x86-64/seastone/platform-config/r0/src/python/x86_64_cel_seastone_r0/__init__.py +++ /dev/null @@ -1,8 +0,0 @@ -from onl.platform.base import * -from onl.platform.celestica import * - -class OnlPlatform_x86_64_cel_seastone_r0(OnlPlatformCelestica, - OnlPlatformPortConfig_48x10_6x40): - PLATFORM='x86-64-cel-seastone-r0' - MODEL="Seastone" - SYS_OBJECT_ID=".2060.1" diff --git a/packages/platforms/celestica/x86-64/silverstone/Makefile b/packages/platforms/celestica/x86-64/silverstone/Makefile deleted file mode 100755 index dc1e7b86f..000000000 --- a/packages/platforms/celestica/x86-64/silverstone/Makefile +++ /dev/null @@ -1 +0,0 @@ -include $(ONL)/make/pkg.mk diff --git a/packages/platforms/celestica/x86-64/silverstone/modules/Makefile b/packages/platforms/celestica/x86-64/silverstone/modules/Makefile deleted file mode 100755 index 003238cf6..000000000 --- a/packages/platforms/celestica/x86-64/silverstone/modules/Makefile +++ /dev/null @@ -1 +0,0 @@ -include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/celestica/x86-64/silverstone/modules/PKG.yml b/packages/platforms/celestica/x86-64/silverstone/modules/PKG.yml deleted file mode 100755 index 3418341b4..000000000 --- a/packages/platforms/celestica/x86-64/silverstone/modules/PKG.yml +++ /dev/null @@ -1 +0,0 @@ -!include $ONL_TEMPLATES/platform-modules.yml ARCH=amd64 VENDOR=celestica BASENAME=x86-64-cel-silverstone KERNELS="onl-kernel-4.14-lts-x86-64-all:amd64" diff --git a/packages/platforms/celestica/x86-64/silverstone/modules/builds/Makefile b/packages/platforms/celestica/x86-64/silverstone/modules/builds/Makefile deleted file mode 100644 index 339d58905..000000000 --- a/packages/platforms/celestica/x86-64/silverstone/modules/builds/Makefile +++ /dev/null @@ -1,6 +0,0 @@ -KERNELS := onl-kernel-4.14-lts-x86-64-all:amd64 -KMODULES := src -VENDOR := celestica -BASENAME := x86-64-cel-silverstone -ARCH := x86_64 -include $(ONL)/make/kmodule.mk diff --git a/packages/platforms/celestica/x86-64/silverstone/modules/builds/src/Makefile b/packages/platforms/celestica/x86-64/silverstone/modules/builds/src/Makefile deleted file mode 100644 index 0a0d7bd5e..000000000 --- a/packages/platforms/celestica/x86-64/silverstone/modules/builds/src/Makefile +++ /dev/null @@ -1 +0,0 @@ -obj-m := mc24lc64t.o optoe.o i2c-cls.o cls-switchboard.o i2c-ocores.o xcvr-cls.o cpld_b.o switchboard-diag.o diff --git a/packages/platforms/celestica/x86-64/silverstone/modules/builds/src/cls-switchboard.c b/packages/platforms/celestica/x86-64/silverstone/modules/builds/src/cls-switchboard.c deleted file mode 100644 index 89beb649c..000000000 --- a/packages/platforms/celestica/x86-64/silverstone/modules/builds/src/cls-switchboard.c +++ /dev/null @@ -1,542 +0,0 @@ -/* - * cls-switchboard.c - PCI device driver for Silverstone Switch board FPGA. - * - * Author: Pradchaya Phucharoen - * - * Copyright (C) 2019 Celestica 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 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 -#include "i2c-ocores.h" -#include "xcvr-cls.h" - -#define MOD_VERSION "2.1.1" -#define DRV_NAME "cls-switchboard" - -#define I2C_MUX_CHANNEL(_ch, _adap_id, _deselect) \ - [_ch] = { .adap_id = _adap_id, .deselect_on_exit = _deselect } - -#define FPGA_PCIE_DEVICE_ID 0x7021 -#define MMIO_BAR 0 -#define I2C_BUS_OFS 9 - -/* I2C ocore configurations */ -#define OCORE_REGSHIFT 2 -#define OCORE_IP_CLK_khz 62500 -#define OCORE_BUS_CLK_khz 100 -#define OCORE_REG_IO_WIDTH 1 - -/* Optical port xcvr configuration */ -#define XCVR_REG_SHIFT 2 -#define XCVR_NUM_PORT 34 -#define XCVR_PORT_REG_SIZE 0x10 - -/* i2c_bus_config - an i2c-core resource and platform data - * @id - I2C bus device ID, for identification. - * @res - resources for an i2c-core device. - * @num_res - size of the resources. - * @pdata - a platform data of an i2c-core device. - */ -struct i2c_bus_config { - int id; - struct resource *res; - ssize_t num_res; - struct ocores_i2c_platform_data pdata; -}; - -/* switchbrd_priv - switchboard private data */ -struct switchbrd_priv { - unsigned long base; - int num_i2c_bus; - struct platform_device **i2cbuses_pdev; - struct platform_device *regio_pdev; - struct platform_device *spiflash_pdev; - struct platform_device *xcvr_pdev; -}; - -/* I2C bus speed param */ -static int bus_clock_master_1 = 100; -module_param(bus_clock_master_1, int, 0660); -MODULE_PARM_DESC(bus_clock_master_1, - "I2C master 1 bus speed in KHz 50/80/100/200/400"); - -static int bus_clock_master_2 = 100; -module_param(bus_clock_master_2, int, 0660); -MODULE_PARM_DESC(bus_clock_master_2, - "I2C master 2 bus speed in KHz 50/80/100/200/400"); - -static int bus_clock_master_3 = 100; -module_param(bus_clock_master_3, int, 0660); -MODULE_PARM_DESC(bus_clock_master_3, - "I2C master 3 bus speed in KHz 50/80/100/200/400"); - -static int bus_clock_master_4 = 100; -module_param(bus_clock_master_4, int, 0660); -MODULE_PARM_DESC(bus_clock_master_4, - "I2C master 4 bus speed in KHz 50/80/100/200/400"); - -static int bus_clock_master_5 = 100; -module_param(bus_clock_master_5, int, 0660); -MODULE_PARM_DESC(bus_clock_master_5, - "I2C master 5 bus speed in KHz 50/80/100/200/400"); - -// NOTE: Silverstone i2c channel mapping is very wierd!!! -/* PCA9548 channel config on MASTER BUS 3 */ -static struct pca954x_platform_mode i2c_mux_70_modes[] = { - I2C_MUX_CHANNEL(5, I2C_BUS_OFS + 23, true), - I2C_MUX_CHANNEL(6, I2C_BUS_OFS + 26, true), - I2C_MUX_CHANNEL(0, I2C_BUS_OFS + 27, true), - I2C_MUX_CHANNEL(7, I2C_BUS_OFS + 28, true), - I2C_MUX_CHANNEL(2, I2C_BUS_OFS + 29, true), - I2C_MUX_CHANNEL(4, I2C_BUS_OFS + 30, true), - I2C_MUX_CHANNEL(3, I2C_BUS_OFS + 31, true), - I2C_MUX_CHANNEL(1, I2C_BUS_OFS + 32, true), -}; - -static struct pca954x_platform_mode i2c_mux_71_modes[] = { - I2C_MUX_CHANNEL(2, I2C_BUS_OFS + 1, true), - I2C_MUX_CHANNEL(3, I2C_BUS_OFS + 2, true), - I2C_MUX_CHANNEL(0, I2C_BUS_OFS + 3, true), - I2C_MUX_CHANNEL(1, I2C_BUS_OFS + 4, true), - I2C_MUX_CHANNEL(6, I2C_BUS_OFS + 5, true), - I2C_MUX_CHANNEL(5, I2C_BUS_OFS + 6, true), - I2C_MUX_CHANNEL(7, I2C_BUS_OFS + 15, true), - I2C_MUX_CHANNEL(4, I2C_BUS_OFS + 8, true), -}; - -static struct pca954x_platform_mode i2c_mux_72_modes[] = { - I2C_MUX_CHANNEL(1, I2C_BUS_OFS + 17, true), - I2C_MUX_CHANNEL(7, I2C_BUS_OFS + 18, true), - I2C_MUX_CHANNEL(4, I2C_BUS_OFS + 19, true), - I2C_MUX_CHANNEL(0, I2C_BUS_OFS + 20, true), - I2C_MUX_CHANNEL(5, I2C_BUS_OFS + 21, true), - I2C_MUX_CHANNEL(2, I2C_BUS_OFS + 22, true), - I2C_MUX_CHANNEL(3, I2C_BUS_OFS + 25, true), - I2C_MUX_CHANNEL(6, I2C_BUS_OFS + 24, true), -}; - -static struct pca954x_platform_mode i2c_mux_73_modes[] = { - I2C_MUX_CHANNEL(4, I2C_BUS_OFS + 9, true), - I2C_MUX_CHANNEL(3, I2C_BUS_OFS + 10, true), - I2C_MUX_CHANNEL(6, I2C_BUS_OFS + 11, true), - I2C_MUX_CHANNEL(2, I2C_BUS_OFS + 12, true), - I2C_MUX_CHANNEL(1, I2C_BUS_OFS + 13, true), - I2C_MUX_CHANNEL(5, I2C_BUS_OFS + 14, true), - I2C_MUX_CHANNEL(7, I2C_BUS_OFS + 7, true), - I2C_MUX_CHANNEL(0, I2C_BUS_OFS + 16, true), -}; - -static struct pca954x_platform_data om_muxes[] = { - { - .modes = i2c_mux_70_modes, - .num_modes = ARRAY_SIZE(i2c_mux_70_modes), - }, - { - .modes = i2c_mux_71_modes, - .num_modes = ARRAY_SIZE(i2c_mux_71_modes), - }, - { - .modes = i2c_mux_72_modes, - .num_modes = ARRAY_SIZE(i2c_mux_72_modes), - }, - { - .modes = i2c_mux_73_modes, - .num_modes = ARRAY_SIZE(i2c_mux_73_modes), - }, -}; - -/* Optical Module bus 3 i2c muxes info */ -static struct i2c_board_info i2c_info_3[] = { - { - I2C_BOARD_INFO("pca9548", 0x70), - .platform_data = &om_muxes[0], - }, - { - I2C_BOARD_INFO("pca9548", 0x71), - .platform_data = &om_muxes[1], - }, - { - I2C_BOARD_INFO("pca9548", 0x72), - .platform_data = &om_muxes[2], - }, - { - I2C_BOARD_INFO("pca9548", 0x73), - .platform_data = &om_muxes[3], - }, -}; - -/* RESOURCE SEPERATES BY FUNCTION */ -/* Resource IOMEM for i2c bus 1 */ -static struct resource cls_i2c_res_1[] = { - { - .start = 0x800, .end = 0x81F, - .flags = IORESOURCE_MEM,}, -}; - -/* Resource IOMEM for i2c bus 2 */ -static struct resource cls_i2c_res_2[] = { - { - .start = 0x820, .end = 0x83F, - .flags = IORESOURCE_MEM,}, -}; - -/* Resource IOMEM for i2c bus 3 */ -static struct resource cls_i2c_res_3[] = { - { - .start = 0x840, .end = 0x85F, - .flags = IORESOURCE_MEM,}, -}; - -/* Resource IOMEM for i2c bus 4 */ -static struct resource cls_i2c_res_4[] = { - { - .start = 0x860, .end = 0x87F, - .flags = IORESOURCE_MEM,}, -}; - -/* Resource IOMEM for i2c bus 5 */ -static struct resource cls_i2c_res_5[] = { - { - .start = 0x880, .end = 0x89F, - .flags = IORESOURCE_MEM,}, -}; - -/* Resource IOMEM for reg access */ -static struct resource reg_io_res[] = { - { - .start = 0x00, .end = 0xFF, - .flags = IORESOURCE_MEM,}, -}; - -/* Resource IOMEM for spi flash firmware upgrade */ -static struct resource spi_flash_res[] = { - { - .start = 0x1200, .end = 0x121F, - .flags = IORESOURCE_MEM,}, -}; - -/* Resource IOMEM for front panel XCVR */ -static struct resource xcvr_res[] = { - { - .start = 0x4000, .end = 0x421F, - .flags = IORESOURCE_MEM,}, -}; - -static struct i2c_bus_config i2c_bus_configs[] = { - { - .id = 1, - .res = cls_i2c_res_1, - .num_res = ARRAY_SIZE(cls_i2c_res_1), - .pdata = { - .reg_shift = OCORE_REGSHIFT, - .reg_io_width = OCORE_REG_IO_WIDTH, - .clock_khz = OCORE_IP_CLK_khz, - .bus_khz = OCORE_BUS_CLK_khz, - .big_endian = false, - .num_devices = 0, - .devices = NULL, - }, - }, - { - .id = 2, - .res = cls_i2c_res_2, - .num_res = ARRAY_SIZE(cls_i2c_res_2), - .pdata = { - .reg_shift = OCORE_REGSHIFT, - .reg_io_width = OCORE_REG_IO_WIDTH, - .clock_khz = OCORE_IP_CLK_khz, - .bus_khz = OCORE_BUS_CLK_khz, - .big_endian = false, - .num_devices = 0, - .devices = NULL, - }, - }, - { - .id = 3, - .res = cls_i2c_res_3, - .num_res = ARRAY_SIZE(cls_i2c_res_3), - .pdata = { - .reg_shift = OCORE_REGSHIFT, - .reg_io_width = OCORE_REG_IO_WIDTH, - .clock_khz = OCORE_IP_CLK_khz, - .bus_khz = OCORE_BUS_CLK_khz, - .big_endian = false, - .num_devices = ARRAY_SIZE(i2c_info_3), - .devices = i2c_info_3, - }, - }, - { - .id = 4, - .res = cls_i2c_res_4, - .num_res = ARRAY_SIZE(cls_i2c_res_4), - .pdata = { - .reg_shift = OCORE_REGSHIFT, - .reg_io_width = OCORE_REG_IO_WIDTH, - .clock_khz = OCORE_IP_CLK_khz, - .bus_khz = OCORE_BUS_CLK_khz, - .big_endian = false, - .num_devices = 0, - .devices = NULL, - }, - }, - { - .id = 5, - .res = cls_i2c_res_5, - .num_res = ARRAY_SIZE(cls_i2c_res_5), - .pdata = { - .reg_shift = OCORE_REGSHIFT, - .reg_io_width = OCORE_REG_IO_WIDTH, - .clock_khz = OCORE_IP_CLK_khz, - .bus_khz = OCORE_BUS_CLK_khz, - .big_endian = false, - .num_devices = 0, - .devices = NULL, - }, - }, -}; - -/* xcvr front panel mapping */ -static struct port_info front_panel_ports[] = { - {"QSFP1", 1, QSFP}, - {"QSFP2", 2, QSFP}, - {"QSFP3", 3, QSFP}, - {"QSFP4", 4, QSFP}, - {"QSFP5", 5, QSFP}, - {"QSFP6", 6, QSFP}, - {"QSFP7", 7, QSFP}, - {"QSFP8", 8, QSFP}, - {"QSFP9", 9, QSFP}, - {"QSFP10", 10, QSFP}, - {"QSFP11", 11, QSFP}, - {"QSFP12", 12, QSFP}, - {"QSFP13", 13, QSFP}, - {"QSFP14", 14, QSFP}, - {"QSFP15", 15, QSFP}, - {"QSFP16", 16, QSFP}, - {"QSFP17", 17, QSFP}, - {"QSFP18", 18, QSFP}, - {"QSFP19", 19, QSFP}, - {"QSFP20", 20, QSFP}, - {"QSFP21", 21, QSFP}, - {"QSFP22", 22, QSFP}, - {"QSFP23", 23, QSFP}, - {"QSFP24", 24, QSFP}, - {"QSFP25", 25, QSFP}, - {"QSFP26", 26, QSFP}, - {"QSFP27", 27, QSFP}, - {"QSFP28", 28, QSFP}, - {"QSFP29", 29, QSFP}, - {"QSFP30", 30, QSFP}, - {"QSFP31", 31, QSFP}, - {"QSFP32", 32, QSFP}, - {"SFP1", 33, SFP}, - {"SFP2", 34, SFP}, - /* END OF LIST */ -}; - -static struct cls_xcvr_platform_data xcvr_data = { - .port_reg_size = 0x10, - .num_ports = ARRAY_SIZE(front_panel_ports), - .devices = front_panel_ports, -}; - - -// TODO: Add a platform configuration struct, and use probe as a factory, -// so xcvr, fwupgrade device can configured as options. - -static int cls_fpga_probe(struct pci_dev *dev, const struct pci_device_id *id) -{ - - struct switchbrd_priv *priv; - struct platform_device **i2cbuses_pdev; - struct platform_device *regio_pdev; - struct platform_device *xcvr_pdev; - unsigned long rstart; - int num_i2c_bus, i; - int err; - - err = pci_enable_device(dev); - if (err){ - dev_err(&dev->dev, "Failed to enable PCI device\n"); - goto err_exit; - } - - /* Check for valid MMIO address */ - rstart = pci_resource_start(dev, MMIO_BAR); - if (!rstart) { - dev_err(&dev->dev, "Switchboard base address uninitialized, " - "check FPGA\n"); - err = -ENODEV; - goto err_disable_device; - } - - dev_dbg(&dev->dev, "BAR%d res: 0x%lx-0x%llx\n", MMIO_BAR, - rstart, pci_resource_end(dev, MMIO_BAR)); - - priv = devm_kzalloc(&dev->dev, - sizeof(struct switchbrd_priv), GFP_KERNEL); - if (!priv){ - err = -ENOMEM; - goto err_disable_device; - } - - pci_set_drvdata(dev, priv); - num_i2c_bus = ARRAY_SIZE(i2c_bus_configs); - i2cbuses_pdev = devm_kzalloc( - &dev->dev, - num_i2c_bus * sizeof(struct platform_device*), - GFP_KERNEL); - - reg_io_res[0].start += rstart; - reg_io_res[0].end += rstart; - - xcvr_res[0].start += rstart; - xcvr_res[0].end += rstart; - - regio_pdev = platform_device_register_resndata( - &dev->dev, "cls-swbrd-io", - -1, - reg_io_res, ARRAY_SIZE(reg_io_res), - NULL, 0); - - if (IS_ERR(regio_pdev)) { - dev_err(&dev->dev, "Failed to register cls-swbrd-io\n"); - err = PTR_ERR(regio_pdev); - goto err_disable_device; - } - - xcvr_pdev = platform_device_register_resndata( - NULL, - "cls-xcvr", - -1, - xcvr_res, - ARRAY_SIZE(xcvr_res), - &xcvr_data, - sizeof(xcvr_data)); - - if (IS_ERR(xcvr_pdev)) { - dev_err(&dev->dev, "Failed to register xcvr node\n"); - err = PTR_ERR(xcvr_pdev); - goto err_unregister_regio; - } - - for(i = 0; i < num_i2c_bus; i++){ - - i2c_bus_configs[i].res[0].start += rstart; - i2c_bus_configs[i].res[0].end += rstart; - - switch (i + 1) { - case 1: - i2c_bus_configs[i].pdata.bus_khz = bus_clock_master_1; - break; - case 2: - i2c_bus_configs[i].pdata.bus_khz = bus_clock_master_2; - break; - case 3: - i2c_bus_configs[i].pdata.bus_khz = bus_clock_master_3; - break; - case 4: - i2c_bus_configs[i].pdata.bus_khz = bus_clock_master_4; - break; - case 5: - i2c_bus_configs[i].pdata.bus_khz = bus_clock_master_5; - break; - default: - i2c_bus_configs[i].pdata.bus_khz = OCORE_BUS_CLK_khz; - } - - dev_dbg(&dev->dev, "i2c-bus.%d: 0x%llx - 0x%llx\n", - i2c_bus_configs[i].id, - i2c_bus_configs[i].res[0].start, - i2c_bus_configs[i].res[0].end); - - i2cbuses_pdev[i] = platform_device_register_resndata( - &dev->dev, "cls-ocores-i2c", - i2c_bus_configs[i].id, - i2c_bus_configs[i].res, - i2c_bus_configs[i].num_res, - &i2c_bus_configs[i].pdata, - sizeof(i2c_bus_configs[i].pdata)); - - if (IS_ERR(i2cbuses_pdev[i])) { - dev_err(&dev->dev, "Failed to register ocores-i2c.%d\n", - i2c_bus_configs[i].id); - err = PTR_ERR(i2cbuses_pdev[i]); - goto err_unregister_ocore; - } - } - - priv->base = rstart; - priv->num_i2c_bus = num_i2c_bus; - priv->i2cbuses_pdev = i2cbuses_pdev; - priv->regio_pdev = regio_pdev; - priv->xcvr_pdev = xcvr_pdev; - return 0; - -err_unregister_ocore: - for(i = 0; i < num_i2c_bus; i++){ - if(priv->i2cbuses_pdev[i]){ - platform_device_unregister(priv->i2cbuses_pdev[i]); - } - } -err_unregister_xcvr: - platform_device_unregister(xcvr_pdev); -err_unregister_regio: - platform_device_unregister(regio_pdev); -err_disable_device: - pci_disable_device(dev); -err_exit: - return err; -} - -static void cls_fpga_remove(struct pci_dev *dev) -{ - int i; - struct switchbrd_priv *priv = pci_get_drvdata(dev); - - for(i = 0; i < priv->num_i2c_bus; i++){ - if(priv->i2cbuses_pdev[i]) - platform_device_unregister(priv->i2cbuses_pdev[i]); - } - platform_device_unregister(priv->xcvr_pdev); - platform_device_unregister(priv->regio_pdev); - pci_disable_device(dev); - return; -}; - -static const struct pci_device_id pci_clsswbrd[] = { - { PCI_VDEVICE(XILINX, FPGA_PCIE_DEVICE_ID) }, - {0, } -}; - -MODULE_DEVICE_TABLE(pci, pci_clsswbrd); - -static struct pci_driver clsswbrd_pci_driver = { - .name = DRV_NAME, - .id_table = pci_clsswbrd, - .probe = cls_fpga_probe, - .remove = cls_fpga_remove, -}; - -module_pci_driver(clsswbrd_pci_driver); - -MODULE_AUTHOR("Pradchaya P."); -MODULE_DESCRIPTION("Celestica Silverstone switchboard driver"); -MODULE_VERSION(MOD_VERSION); -MODULE_LICENSE("GPL"); diff --git a/packages/platforms/celestica/x86-64/silverstone/modules/builds/src/cpld_b.c b/packages/platforms/celestica/x86-64/silverstone/modules/builds/src/cpld_b.c deleted file mode 100644 index f777f190e..000000000 --- a/packages/platforms/celestica/x86-64/silverstone/modules/builds/src/cpld_b.c +++ /dev/null @@ -1,414 +0,0 @@ -/* - * cpld_b .c - The CPLD driver for the Base Board of Silverstone - * The driver implement sysfs to access CPLD register on the baseboard of Silverstone via LPC bus. - * Copyright (C) 2018 Celestica 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 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 -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define DRIVER_NAME "sys_cpld" -/** - * CPLD register address for read and write. - */ -#define VERSION_ADDR 0xA100 -#define SCRATCH_ADDR 0xA101 -#define SYS_LED_ADDR 0xA162 -#define CPLD_REGISTER_SIZE 0x77 - -struct cpld_b_data { - struct mutex cpld_lock; - uint16_t read_addr; -}; - -struct cpld_b_data *cpld_data; - -/** - * Read the value from scratch register as hex string. - * @param dev kernel device - * @param devattr kernel device attribute - * @param buf buffer for get value - * @return Hex string read from scratch register. - */ - - -static ssize_t scratch_show(struct device *dev, struct device_attribute *devattr, - char *buf) -{ - unsigned char data = 0; - mutex_lock(&cpld_data->cpld_lock); - data = inb(SCRATCH_ADDR); - mutex_unlock(&cpld_data->cpld_lock); - return sprintf(buf,"0x%2.2x\n", data); -} - -/** - * Set scratch register with specific hex string. - * @param dev kernel device - * @param devattr kernel device attribute - * @param buf buffer of set value - * @param count number of bytes in buffer - * @return number of bytes written, or error code < 0. - */ -static ssize_t scratch_store(struct device *dev, struct device_attribute *devattr, - const char *buf, size_t count) -{ - unsigned long data; - char *last; - - mutex_lock(&cpld_data->cpld_lock); - data = (uint16_t)strtoul(buf,&last,16); - if(data == 0 && buf == last){ - mutex_unlock(&cpld_data->cpld_lock); - return -EINVAL; - } - outb(data, SCRATCH_ADDR); - mutex_unlock(&cpld_data->cpld_lock); - return count; -} -static DEVICE_ATTR_RW(scratch); - - -/* CPLD version attributes */ -static ssize_t version_show(struct device *dev, struct device_attribute *attr, char *buf) -{ - int len = 0; - // CPLD register is one byte - mutex_lock(&cpld_data->cpld_lock); - len = sprintf(buf, "0x%2.2x\n",inb(VERSION_ADDR)); - mutex_unlock(&cpld_data->cpld_lock); - return len; -} -static DEVICE_ATTR_RO(version); - - -static ssize_t getreg_store(struct device *dev, struct device_attribute *devattr, - const char *buf, size_t count) -{ - // CPLD register is one byte - uint16_t addr; - char *last; - - addr = (uint16_t)strtoul(buf,&last,16); - if(addr == 0 && buf == last){ - return -EINVAL; - } - cpld_data->read_addr = addr; - return count; -} - -static ssize_t getreg_show(struct device *dev, struct device_attribute *attr, char *buf) -{ - int len = 0; - // CPLD register is one byte - mutex_lock(&cpld_data->cpld_lock); - len = sprintf(buf, "0x%2.2x\n",inb(cpld_data->read_addr)); - mutex_unlock(&cpld_data->cpld_lock); - return len; -} -static DEVICE_ATTR_RW(getreg); - -static ssize_t setreg_store(struct device *dev, struct device_attribute *devattr, - const char *buf, size_t count) -{ - // CPLD register is one byte - uint16_t addr; - uint8_t value; - char *tok; - char clone[count]; - char *pclone = clone; - char *last; - - strcpy(clone, buf); - - mutex_lock(&cpld_data->cpld_lock); - tok = strsep((char**)&pclone, " "); - if(tok == NULL){ - mutex_unlock(&cpld_data->cpld_lock); - return -EINVAL; - } - addr = (uint16_t)strtoul(tok,&last,16); - if(addr == 0 && tok == last){ - mutex_unlock(&cpld_data->cpld_lock); - return -EINVAL; - } - - tok = strsep((char**)&pclone, " "); - if(tok == NULL){ - mutex_unlock(&cpld_data->cpld_lock); - return -EINVAL; - } - value = (uint8_t)strtoul(tok,&last,16); - if(value == 0 && tok == last){ - mutex_unlock(&cpld_data->cpld_lock); - return -EINVAL; - } - - outb(value,addr); - mutex_unlock(&cpld_data->cpld_lock); - return count; -} -static DEVICE_ATTR_WO(setreg); - -/** - * Read all CPLD register in binary mode. - * @return number of byte read. - */ -static ssize_t dump_read(struct file *filp, struct kobject *kobj, - struct bin_attribute *attr, char *buf, - loff_t off, size_t count) -{ - unsigned long i=0; - ssize_t status; - - mutex_lock(&cpld_data->cpld_lock); -begin: - if(i < count){ - buf[i++] = inb(VERSION_ADDR + off); - off++; - msleep(1); - goto begin; - } - status = count; -exit: - mutex_unlock(&cpld_data->cpld_lock); - return status; -} -static BIN_ATTR_RO(dump, CPLD_REGISTER_SIZE); - -/** - * Show system led status - on/off/1k/4k - * @param dev kernel device - * @param devattr kernel device attribute - * @param buf buffer for get value - * @return Hex string read from scratch register. - */ -static ssize_t sys_led_show(struct device *dev, struct device_attribute *devattr, - char *buf) -{ - unsigned char data = 0; - mutex_lock(&cpld_data->cpld_lock); - data = inb(SYS_LED_ADDR); - mutex_unlock(&cpld_data->cpld_lock); - data = data & 0x3; - return sprintf(buf, "%s\n", - data == 0x03 ? "off" : data == 0x02 ? "4k" : data ==0x01 ? "1k": "on"); -} - -/** - * Set the status of system led - on/off/1k/4k - * @param dev kernel device - * @param devattr kernel device attribute - * @param buf buffer of set value - * @param count number of bytes in buffer - * @return number of bytes written, or error code < 0. - */ -static ssize_t sys_led_store(struct device *dev, struct device_attribute *devattr, - const char *buf, size_t count) -{ - unsigned char led_status,data; - if(sysfs_streq(buf, "off")){ - led_status = 0x03; - }else if(sysfs_streq(buf, "4k")){ - led_status = 0x02; - }else if(sysfs_streq(buf, "1k")){ - led_status = 0x01; - }else if(sysfs_streq(buf, "on")){ - led_status = 0x00; - }else{ - count = -EINVAL; - return count; - } - mutex_lock(&cpld_data->cpld_lock); - data = inb(SYS_LED_ADDR); - data = data & ~(0x3); - data = data | led_status; - outb(data, SYS_LED_ADDR); - mutex_unlock(&cpld_data->cpld_lock); - return count; -} -static DEVICE_ATTR_RW(sys_led); - -/** - * Show system led color - both/green/yellow/none - * @param dev kernel device - * @param devattr kernel device attribute - * @param buf buffer for get value - * @return Hex string read from scratch register. - */ -static ssize_t sys_led_color_show(struct device *dev, struct device_attribute *devattr, - char *buf) -{ - unsigned char data = 0; - mutex_lock(&cpld_data->cpld_lock); - data = inb(SYS_LED_ADDR); - mutex_unlock(&cpld_data->cpld_lock); - data = (data >> 4) & 0x3; - return sprintf(buf, "%s\n", - data == 0x03 ? "off" : data == 0x02 ? "yellow" : data ==0x01 ? "green": "both"); -} - -/** - * Set the color of system led - both/green/yellow/none - * @param dev kernel device - * @param devattr kernel device attribute - * @param buf buffer of set value - * @param count number of bytes in buffer - * @return number of bytes written, or error code < 0. - */ -static ssize_t sys_led_color_store(struct device *dev, struct device_attribute *devattr, - const char *buf, size_t count) -{ - unsigned char led_status,data; - if(sysfs_streq(buf, "off")){ - led_status = 0x03; - }else if(sysfs_streq(buf, "yellow")){ - led_status = 0x02; - }else if(sysfs_streq(buf, "green")){ - led_status = 0x01; - }else if(sysfs_streq(buf, "both")){ - led_status = 0x00; - }else{ - count = -EINVAL; - return count; - } - mutex_lock(&cpld_data->cpld_lock); - data = inb(SYS_LED_ADDR); - data = data & ~( 0x3 << 4); - data = data | (led_status << 4); - outb(data, SYS_LED_ADDR); - mutex_unlock(&cpld_data->cpld_lock); - return count; -} -static DEVICE_ATTR_RW(sys_led_color); - -static struct attribute *cpld_b_attrs[] = { - &dev_attr_version.attr, - &dev_attr_scratch.attr, - &dev_attr_getreg.attr, - &dev_attr_setreg.attr, - &dev_attr_sys_led.attr, - &dev_attr_sys_led_color.attr, - NULL, -}; - -static struct bin_attribute *cpld_b_bin_attrs[] = { - &bin_attr_dump, - NULL, -}; - -static struct attribute_group cpld_b_attrs_grp = { - .attrs = cpld_b_attrs, - .bin_attrs = cpld_b_bin_attrs, -}; - -static struct resource cpld_b_resources[] = { - { - .start = 0xA100, - .end = 0xA176, - .flags = IORESOURCE_IO, - }, -}; - -static void cpld_b_dev_release( struct device * dev) -{ - return; -} - -static struct platform_device cpld_b_dev = { - .name = DRIVER_NAME, - .id = -1, - .num_resources = ARRAY_SIZE(cpld_b_resources), - .resource = cpld_b_resources, - .dev = { - .release = cpld_b_dev_release, - } -}; - -static int cpld_b_drv_probe(struct platform_device *pdev) -{ - struct resource *res; - int err = 0; - - cpld_data = devm_kzalloc(&pdev->dev, sizeof(struct cpld_b_data), - GFP_KERNEL); - if (!cpld_data) - return -ENOMEM; - - mutex_init(&cpld_data->cpld_lock); - - cpld_data->read_addr = VERSION_ADDR; - - res = platform_get_resource(pdev, IORESOURCE_IO, 0); - if (unlikely(!res)) { - printk(KERN_ERR "Specified Resource Not Available...\n"); - return -ENODEV; - } - - err = sysfs_create_group(&pdev->dev.kobj, &cpld_b_attrs_grp); - if (err) { - printk(KERN_ERR "Cannot create sysfs for baseboard CPLD\n"); - return err; - } - return 0; -} - -static int cpld_b_drv_remove(struct platform_device *pdev) -{ - sysfs_remove_group(&pdev->dev.kobj, &cpld_b_attrs_grp); - return 0; -} - -static struct platform_driver cpld_b_drv = { - .probe = cpld_b_drv_probe, - .remove = __exit_p(cpld_b_drv_remove), - .driver = { - .name = DRIVER_NAME, - }, -}; - -int cpld_b_init(void) -{ - // Register platform device and platform driver - platform_device_register(&cpld_b_dev); - platform_driver_register(&cpld_b_drv); - return 0; -} - -void cpld_b_exit(void) -{ - // Unregister platform device and platform driver - platform_driver_unregister(&cpld_b_drv); - platform_device_unregister(&cpld_b_dev); -} - -module_init(cpld_b_init); -module_exit(cpld_b_exit); - - -MODULE_AUTHOR("Celestica Inc."); -MODULE_DESCRIPTION("CELESTICA SILVERSTONE WHITEBOX CPLD baseboard driver"); -MODULE_VERSION("0.0.2"); -MODULE_LICENSE("GPL"); diff --git a/packages/platforms/celestica/x86-64/silverstone/modules/builds/src/i2c-cls.c b/packages/platforms/celestica/x86-64/silverstone/modules/builds/src/i2c-cls.c deleted file mode 100644 index 6faed7e46..000000000 --- a/packages/platforms/celestica/x86-64/silverstone/modules/builds/src/i2c-cls.c +++ /dev/null @@ -1,514 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0+ -/* - * i2c-cls.c - I2C bus driver for Celestica pci-to-i2c controller. - * - * Pradchaya Phucharoen - * Copyright (C) 2019 Celestica Corp. - */ - -/* Based on: i2c-mpc.c */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "i2c-cls.h" - -/* The registers for one core */ -#define CLS_I2C_FDR 0 -#define CLS_I2C_CR 1 -#define CLS_I2C_SR 2 -#define CLS_I2C_DR 3 -#define CLS_I2C_PORT_ID 4 - -#define CCR_MEN 0x80 -#define CCR_MIEN 0x40 -#define CCR_MSTA 0x20 -#define CCR_MTX 0x10 -#define CCR_TXAK 0x08 -#define CCR_RSTA 0x04 - -#define CSR_MCF 0x80 -#define CSR_MAAS 0x40 -#define CSR_MBB 0x20 -#define CSR_MAL 0x10 -#define CSR_SRW 0x04 -#define CSR_MIF 0x02 -#define CSR_RXAK 0x01 - -/* - * struct cls_i2c - private data for cls i2c core - * @base: virtual base address - * @reg_shift: number of bytes between register - * @port_id: i2c core id - * @timeout_us: adapter timeout in jiffies - * @fdr: a frequency divier corresponding to each bus speed - * @bus_clk_khz: bus clock for reference - * @adap: i2c adapter instance - * @setreg: accessor function to set register - * @getreg: accessor function to get register - */ -struct cls_i2c { - void __iomem *base; - unsigned int reg_shift; - unsigned int port_id; - unsigned int timeout_us; - unsigned int fdr; - unsigned int bus_clk_khz; - struct i2c_adapter adap; - void (*setreg)(struct cls_i2c *i2c, int reg, u8 value); - u8 (*getreg)(struct cls_i2c *i2c, int reg); -}; - -/* accessor function for 8 bit io space */ -static void setreg_8(struct cls_i2c *i2c, int reg, u8 value) -{ - iowrite8(value, i2c->base + (reg * i2c->reg_shift)); -} - -static inline u8 getreg_8(struct cls_i2c *i2c, int reg) -{ - return ioread8(i2c->base + (reg * i2c->reg_shift)); -} - -/* Accesser wrapper */ -static inline void cls_setreg(struct cls_i2c *i2c, int reg, u8 value) -{ - i2c->setreg(i2c, reg, value); -} - -static inline u8 cls_getreg(struct cls_i2c *i2c, int reg) -{ - return i2c->getreg(i2c, reg); -} - -/* Sometimes 9th clock pulse isn't generated, and slave doesn't release - * the bus, because it wants to send ACK. - * Following sequence of enabling/disabling and sending start/stop generates - * the 9 pulses, so it's all OK. - */ -static void cls_i2c_fixup(struct cls_i2c *i2c) -{ - int k; - u32 delay_us = 1000000 / i2c->bus_clk_khz + 1; - - if (delay_us < 2) - delay_us = 2; - - for (k = 9; k; k--) { - cls_setreg(i2c, CLS_I2C_CR, 0); - cls_setreg(i2c, CLS_I2C_CR, CCR_MSTA | CCR_MTX | CCR_MEN); - cls_getreg(i2c, CLS_I2C_DR); - cls_setreg(i2c, CLS_I2C_CR, CCR_MEN); - udelay(delay_us << 1); /* Why delay x2 here? */ - } -} - -static int i2c_wait(struct cls_i2c *i2c, unsigned timeout, int writing) -{ - unsigned long orig_jiffies = jiffies; - u32 cmd_err; - int result = 0; - - while (!(cls_getreg(i2c, CLS_I2C_SR) & CSR_MIF)) { - schedule(); - if (time_after(jiffies, orig_jiffies + timeout)) { - dev_dbg(&i2c->adap.dev, "timeout\n"); - cls_setreg(i2c, CLS_I2C_CR, 0); - result = -ETIMEDOUT; - break; - } - } - cmd_err = cls_getreg(i2c, CLS_I2C_SR); - cls_setreg(i2c, CLS_I2C_SR, 0); - - if (result < 0) - return result; - - if (!(cmd_err & CSR_MCF)) { - dev_dbg(&i2c->adap.dev, "unfinished\n"); - return -EIO; - } - - if (cmd_err & CSR_MAL) { - dev_dbg(&i2c->adap.dev, "MAL\n"); - return -EAGAIN; - } - - if (writing && (cmd_err & CSR_RXAK)) { - dev_dbg(&i2c->adap.dev, "No RXAK\n"); - /* generate stop */ - cls_setreg(i2c, CLS_I2C_CR, CCR_MEN); - return -ENXIO; - } - return 0; -} - -static void cls_i2c_start(struct cls_i2c *i2c) -{ - /* Clear arbitration */ - cls_setreg(i2c, CLS_I2C_SR, 0); - /* Start with MEN */ - cls_setreg(i2c, CLS_I2C_CR, CCR_MEN); -} - -static void cls_i2c_stop(struct cls_i2c *i2c) -{ - cls_setreg(i2c, CLS_I2C_CR, CCR_MEN); -} - -static int cls_write(struct cls_i2c *i2c, int target, - const u8 *data, int length, int restart) -{ - int i, result; - unsigned timeout = i2c->adap.timeout; - u32 flags = restart ? CCR_RSTA : 0; - - /* Start as master */ - cls_setreg(i2c, CLS_I2C_CR, - CCR_MIEN | CCR_MEN | CCR_MSTA | CCR_MTX | flags); - /* Write target byte */ - cls_setreg(i2c, CLS_I2C_DR, (target << 1)); - - result = i2c_wait(i2c, timeout, 1); - if (result < 0) - return result; - - for (i = 0; i < length; i++) { - /* Write data byte */ - cls_setreg(i2c, CLS_I2C_DR, data[i]); - - result = i2c_wait(i2c, timeout, 1); - if (result < 0) - return result; - } - - return 0; -} - -static int cls_read(struct cls_i2c *i2c, int target, - u8 *data, int length, int restart, bool recv_len) -{ - unsigned timeout = i2c->adap.timeout; - int i, result; - u32 flags = restart ? CCR_RSTA : 0; - - /* Switch to read - restart */ - cls_setreg(i2c, CLS_I2C_CR, - CCR_MIEN | CCR_MEN | CCR_MSTA | CCR_MTX | flags); - /* Write target address byte - this time with the read flag set */ - cls_setreg(i2c, CLS_I2C_DR, (target << 1) | 1); - - result = i2c_wait(i2c, timeout, 1); - if (result < 0) - return result; - - if (length) { - if (length == 1 && !recv_len) - cls_setreg(i2c, CLS_I2C_CR, - CCR_MIEN | CCR_MEN | CCR_MSTA | CCR_TXAK); - else - cls_setreg(i2c, CLS_I2C_CR, - CCR_MIEN | CCR_MEN | CCR_MSTA); - /* Dummy read */ - cls_getreg(i2c, CLS_I2C_DR); - } - - for (i = 0; i < length; i++) { - u8 byte; - - result = i2c_wait(i2c, timeout, 0); - if (result < 0) - return result; - - /* - * For block reads, we have to know the total length (1st byte) - * before we can determine if we are done. - */ - if (i || !recv_len) { - /* Generate txack on next to last byte */ - if (i == length - 2) - cls_setreg(i2c, CLS_I2C_CR, CCR_MIEN - | CCR_MEN | CCR_MSTA - | CCR_TXAK); - /* Do not generate stop on last byte */ - if (i == length - 1) - cls_setreg(i2c, CLS_I2C_CR, CCR_MIEN - | CCR_MEN | CCR_MSTA - | CCR_MTX); - } - - byte = cls_getreg(i2c, CLS_I2C_DR); - - /* - * Adjust length if first received byte is length. - * The length is 1 length byte plus actually data length - */ - if (i == 0 && recv_len) { - if (byte == 0 || byte > I2C_SMBUS_BLOCK_MAX) - return -EPROTO; - length += byte; - /* - * For block reads, generate txack here if data length - * is 1 byte (total length is 2 bytes). - */ - if (length == 2) - cls_setreg(i2c, CLS_I2C_CR, CCR_MIEN - | CCR_MEN | CCR_MSTA - | CCR_TXAK); - } - data[i] = byte; - } - - return length; -} - -static int cls_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs, int num) -{ - struct i2c_msg *pmsg; - int i; - int ret = 0; - unsigned long orig_jiffies = jiffies; - struct cls_i2c *i2c = i2c_get_adapdata(adap); - - cls_i2c_start(i2c); - - /* Allow bus up to 1s to become not busy */ - while (cls_getreg(i2c, CLS_I2C_SR) & CSR_MBB) { - if (signal_pending(current)) { - dev_dbg(&i2c->adap.dev, "Interrupted\n"); - cls_setreg(i2c, CLS_I2C_CR, 0); - return -EINTR; - } - if (time_after(jiffies, orig_jiffies + HZ)) { - u8 status = cls_getreg(i2c, CLS_I2C_SR); - - dev_dbg(&i2c->adap.dev, "timeout\n"); - if ((status & (CSR_MCF | CSR_MBB | CSR_RXAK)) != 0) { - cls_setreg(i2c, CLS_I2C_SR, status & ~CSR_MAL); - cls_i2c_fixup(i2c); - } - return -EIO; - } - schedule(); - } - - for (i = 0; ret >= 0 && i < num; i++) { - pmsg = &msgs[i]; - dev_dbg(&i2c->adap.dev, - "Doing %s %d bytes to 0x%02x - %d of %d messages\n", - pmsg->flags & I2C_M_RD ? "read" : "write", - pmsg->len, pmsg->addr, i + 1, num); - if (pmsg->flags & I2C_M_RD) { - bool recv_len = pmsg->flags & I2C_M_RECV_LEN; - - ret = cls_read(i2c, pmsg->addr, pmsg->buf, pmsg->len, - i, recv_len); - if (recv_len && ret > 0) - pmsg->len = ret; - } else { - ret = cls_write(i2c, pmsg->addr, pmsg->buf, - pmsg->len, i); - } - } - cls_i2c_stop(i2c); /* Initiate STOP */ - orig_jiffies = jiffies; - /* Wait until STOP is seen, allow up to 1 s */ - while (cls_getreg(i2c, CLS_I2C_SR) & CSR_MBB) { - if (time_after(jiffies, orig_jiffies + HZ)) { - u8 status = readb(i2c->base + CLS_I2C_SR); - - dev_dbg(&i2c->adap.dev, "timeout\n"); - if ((status & (CSR_MCF | CSR_MBB | CSR_RXAK)) != 0) { - cls_setreg(i2c, CLS_I2C_SR, status & ~CSR_MAL); - cls_i2c_fixup(i2c); - } - return -EIO; - } - cond_resched(); - } - return (ret < 0) ? ret : num; -} - -static u32 cls_i2c_func(struct i2c_adapter *adap) -{ - return I2C_FUNC_I2C | I2C_FUNC_SMBUS_EMUL - | I2C_FUNC_SMBUS_READ_BLOCK_DATA - | I2C_FUNC_SMBUS_BLOCK_PROC_CALL; -} - -static struct i2c_algorithm cls_i2c_algorithm = { - .master_xfer = cls_xfer, - .functionality = cls_i2c_func, -}; - -static const struct i2c_adapter cls_i2c_adapter = { - .owner = THIS_MODULE, - .class = I2C_CLASS_DEPRECATED, - .algo = &cls_i2c_algorithm, - .nr = -1, -}; - -static int cls_i2c_probe(struct platform_device *pdev) -{ - struct cls_i2c *i2c; - struct cls_i2c_platform_data *pdata; - struct resource *res; - int ret; - int i; - - i2c = devm_kzalloc(&pdev->dev, sizeof(*i2c), GFP_KERNEL); - if (!i2c){ - ret = -ENOMEM; - goto err_exit; - } - - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); - if (res) { - i2c->base = devm_ioremap_resource(&pdev->dev, res); - if (IS_ERR(i2c->base)){ - ret = PTR_ERR(i2c->base); - goto err_exit; - } - } - - pdata = dev_get_platdata(&pdev->dev); - if (pdata) { - i2c->port_id = pdata->port_id; - i2c->reg_shift = pdata->reg_shift; - - switch(pdata->bus_clk_mode){ - case CLK50KHZ: - i2c->fdr = 63; - i2c->bus_clk_khz = 50000; - break; - case CLK100KHZ: - i2c->fdr = 31; - i2c->bus_clk_khz = 100000; - break; - case CLK200KHZ: - i2c->fdr = 15; - i2c->bus_clk_khz = 200000; - break; - case CLK400KHZ: - i2c->fdr = 7; - i2c->bus_clk_khz = 400000; - break; - default: - /* defaults set bus clock to 100Khz */ - i2c->fdr = 31; - i2c->bus_clk_khz = 100000; - break; - } - - if(pdata->timeout_us) - i2c->timeout_us = pdata->timeout_us; - else - /* defaults set timeout to 1ms */ - i2c->timeout_us = 10000; - } - - i2c->setreg = setreg_8; - i2c->getreg = getreg_8; - - /* init the i2c register */ - cls_setreg(i2c, CLS_I2C_FDR, i2c->fdr); - cls_setreg(i2c, CLS_I2C_PORT_ID, i2c->port_id); - - /* hook up driver to tree */ - platform_set_drvdata(pdev, i2c); - i2c->adap = cls_i2c_adapter; - scnprintf(i2c->adap.name, sizeof(i2c->adap.name), - "I2C adapter at %llx", (unsigned long long)res->start); - i2c_set_adapdata(&i2c->adap, i2c); - i2c->adap.timeout = usecs_to_jiffies(i2c->timeout_us); - i2c->adap.dev.parent = &pdev->dev; - i2c->adap.nr = -1; - - if(pdata){ - if(pdata->adap_id >= 0) - i2c->adap.nr = pdata->adap_id; - } - - /* add i2c adapter to i2c tree */ - ret = i2c_add_numbered_adapter(&i2c->adap); - if (ret) - goto err_exit; - - /* add in known devices to the bus */ - if (pdata) { - for (i = 0; i < pdata->num_devices; i++) - i2c_new_device(&i2c->adap, pdata->devices + i); - } - - return 0; - -err_exit: - return ret; -} - -static int cls_i2c_remove(struct platform_device *pdev) -{ - struct cls_i2c *i2c = platform_get_drvdata(pdev); - - /* remove adapter & data */ - i2c_del_adapter(&i2c->adap); - - return 0; -} - -#ifdef CONFIG_PM_SLEEP -static int cls_i2c_suspend(struct device *dev) -{ - struct cls_i2c *i2c = dev_get_drvdata(dev); - - i2c->fdr = cls_getreg(i2c, CLS_I2C_FDR); - i2c->port_id = cls_getreg(i2c, CLS_I2C_PORT_ID); - - return 0; -} - -static int cls_i2c_resume(struct device *dev) -{ - struct cls_i2c *i2c = dev_get_drvdata(dev); - - cls_setreg(i2c, CLS_I2C_FDR, i2c->fdr); - cls_setreg(i2c, CLS_I2C_PORT_ID, i2c->port_id); - - return 0; -} - -static SIMPLE_DEV_PM_OPS(cls_i2c_pm, cls_i2c_suspend, cls_i2c_resume); -#define CLS_I2C_PM (&cls_i2c_pm) -#else -#define CLS_I2C_PM NULL -#endif - - -static struct platform_driver cls_i2c_driver = { - .probe = cls_i2c_probe, - .remove = cls_i2c_remove, - .driver = { - .name = "cls-i2c", - .pm = CLS_I2C_PM, - }, -}; - -module_platform_driver(cls_i2c_driver); - -MODULE_AUTHOR("Pradchaya Phucharoen"); -MODULE_DESCRIPTION("Celestica PCI to I2C bus driver"); -MODULE_LICENSE("GPL"); -MODULE_ALIAS("platform:cls-i2c"); \ No newline at end of file diff --git a/packages/platforms/celestica/x86-64/silverstone/modules/builds/src/i2c-cls.h b/packages/platforms/celestica/x86-64/silverstone/modules/builds/src/i2c-cls.h deleted file mode 100644 index e27005008..000000000 --- a/packages/platforms/celestica/x86-64/silverstone/modules/builds/src/i2c-cls.h +++ /dev/null @@ -1,41 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0+ -/* - * i2c-cls.h - * - * Pradchaya Phucharoen - * Copyright (C) 2019 Celestica Corp. - */ - -#ifndef _LINUX_I2C_CLS_H -#define _LINUX_I2C_CLS_H - -/* i2c bus speed mode */ -typedef enum{ - // Preserved zero - CLK50KHZ = 1, - CLK100KHZ = 2, - CLK200KHZ = 3, - CLK400KHZ = 4, -}bus_clk; - -/* - * struct cls_i2c_platform_data - platform data for celestica i2c driver - * @reg_shift: number of bytes between register - * @port_id i2c core id - * @bus_clk_mode: i2c bus clock speed mode - * @timeout_us: adapter timeout in us - * @adap_id: bus number for adapter device, -1 for dynamic allocate. - * @num_devices: number of devices on the bus - * @devices: devices conncted to the bus - */ -struct cls_i2c_platform_data { - unsigned int reg_shift; - unsigned int port_id; - bus_clk bus_clk_mode; - unsigned int timeout_us; - int adap_id; - u8 num_devices; /* number of devices in the devices list */ - struct i2c_board_info const *devices; /* devices connected to the bus */ -}; - -#endif /* _LINUX_I2C_CLS_H */ diff --git a/packages/platforms/celestica/x86-64/silverstone/modules/builds/src/i2c-ocores.c b/packages/platforms/celestica/x86-64/silverstone/modules/builds/src/i2c-ocores.c deleted file mode 100644 index 7d9f40fbb..000000000 --- a/packages/platforms/celestica/x86-64/silverstone/modules/builds/src/i2c-ocores.c +++ /dev/null @@ -1,836 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -/* - * i2c-ocores.c: I2C bus driver for OpenCores I2C controller - * (https://opencores.org/project/i2c/overview) - * - * Peter Korsgaard - * - * Support for the GRLIB port of the controller by - * Andreas Larsson - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -// #include -#include -#include -#include -#include -#include -#include "i2c-ocores.h" - -#define OCORES_FLAG_POLL BIT(0) - -/* - * 'process_lock' exists because ocores_process() and ocores_process_timeout() - * can't run in parallel. - */ -struct ocores_i2c { - void __iomem *base; - int iobase; - u32 reg_shift; - u32 reg_io_width; - unsigned long flags; - wait_queue_head_t wait; - struct i2c_adapter adap; - struct i2c_msg *msg; - int pos; - int nmsgs; - int state; /* see STATE_ */ - int nack_retry; - spinlock_t process_lock; - struct clk *clk; - int ip_clock_khz; - int bus_clock_khz; - void (*setreg)(struct ocores_i2c *i2c, int reg, u8 value); - u8 (*getreg)(struct ocores_i2c *i2c, int reg); -}; - -/* registers */ -#define OCI2C_PRELOW 0 -#define OCI2C_PREHIGH 1 -#define OCI2C_CONTROL 2 -#define OCI2C_DATA 3 -#define OCI2C_CMD 4 /* write only */ -#define OCI2C_STATUS 4 /* read only, same address as OCI2C_CMD */ - -#define OCI2C_CTRL_IEN 0x40 -#define OCI2C_CTRL_EN 0x80 - -#define OCI2C_CMD_START 0x91 -#define OCI2C_CMD_STOP 0x41 -#define OCI2C_CMD_READ 0x21 -#define OCI2C_CMD_WRITE 0x11 -#define OCI2C_CMD_READ_ACK 0x21 -#define OCI2C_CMD_READ_NACK 0x29 -#define OCI2C_CMD_IACK 0x01 - -#define OCI2C_STAT_IF 0x01 -#define OCI2C_STAT_TIP 0x02 -#define OCI2C_STAT_ARBLOST 0x20 -#define OCI2C_STAT_BUSY 0x40 -#define OCI2C_STAT_NACK 0x80 - -#define STATE_DONE 0 -#define STATE_START 1 -#define STATE_WRITE 2 -#define STATE_READ 3 -#define STATE_ERROR 4 - -#define TYPE_OCORES 0 -#define TYPE_GRLIB 1 - -static void oc_setreg_8(struct ocores_i2c *i2c, int reg, u8 value) -{ - iowrite8(value, i2c->base + (reg << i2c->reg_shift)); -} - -static void oc_setreg_16(struct ocores_i2c *i2c, int reg, u8 value) -{ - iowrite16(value, i2c->base + (reg << i2c->reg_shift)); -} - -static void oc_setreg_32(struct ocores_i2c *i2c, int reg, u8 value) -{ - iowrite32(value, i2c->base + (reg << i2c->reg_shift)); -} - -static void oc_setreg_16be(struct ocores_i2c *i2c, int reg, u8 value) -{ - iowrite16be(value, i2c->base + (reg << i2c->reg_shift)); -} - -static void oc_setreg_32be(struct ocores_i2c *i2c, int reg, u8 value) -{ - iowrite32be(value, i2c->base + (reg << i2c->reg_shift)); -} - -static inline u8 oc_getreg_8(struct ocores_i2c *i2c, int reg) -{ - return ioread8(i2c->base + (reg << i2c->reg_shift)); -} - -static inline u8 oc_getreg_16(struct ocores_i2c *i2c, int reg) -{ - return ioread16(i2c->base + (reg << i2c->reg_shift)); -} - -static inline u8 oc_getreg_32(struct ocores_i2c *i2c, int reg) -{ - return ioread32(i2c->base + (reg << i2c->reg_shift)); -} - -static inline u8 oc_getreg_16be(struct ocores_i2c *i2c, int reg) -{ - return ioread16be(i2c->base + (reg << i2c->reg_shift)); -} - -static inline u8 oc_getreg_32be(struct ocores_i2c *i2c, int reg) -{ - return ioread32be(i2c->base + (reg << i2c->reg_shift)); -} - -static void oc_setreg_io_8(struct ocores_i2c *i2c, int reg, u8 value) -{ - outb(value, i2c->iobase + reg); -} - -static inline u8 oc_getreg_io_8(struct ocores_i2c *i2c, int reg) -{ - return inb(i2c->iobase + reg); -} - -static inline void oc_setreg(struct ocores_i2c *i2c, int reg, u8 value) -{ - i2c->setreg(i2c, reg, value); -} - -static inline u8 oc_getreg(struct ocores_i2c *i2c, int reg) -{ - return i2c->getreg(i2c, reg); -} - -static void ocores_process(struct ocores_i2c *i2c, u8 stat) -{ - struct i2c_msg *msg = i2c->msg; - unsigned long flags; - - /* - * If we spin here is because we are in timeout, so we are going - * to be in STATE_ERROR. See ocores_process_timeout() - */ - spin_lock_irqsave(&i2c->process_lock, flags); - - dev_dbg(&i2c->adap.dev, "STATE: %d\n", i2c->state); - - if ((i2c->state == STATE_DONE) || (i2c->state == STATE_ERROR)) { - /* stop has been sent */ - oc_setreg(i2c, OCI2C_CMD, OCI2C_CMD_IACK); - wake_up(&i2c->wait); - goto out; - } - - /* error? */ - if (stat & OCI2C_STAT_ARBLOST) { - i2c->state = STATE_START; - oc_setreg(i2c, OCI2C_CMD, OCI2C_CMD_START); - dev_dbg(&i2c->adap.dev, "ERR: AL\n"); - goto out; - } - - if ((i2c->state == STATE_START) || (i2c->state == STATE_WRITE)) { - i2c->state = - (msg->flags & I2C_M_RD) ? STATE_READ : STATE_WRITE; - - if (stat & OCI2C_STAT_NACK) { - dev_dbg(&i2c->adap.dev, "ERR: NACK\n"); - i2c->state = STATE_ERROR; - if(!(msg->flags & I2C_M_RD)) - i2c->nack_retry = 1; - oc_setreg(i2c, OCI2C_CMD, OCI2C_CMD_STOP); - goto out; - } - } else { - msg->buf[i2c->pos++] = oc_getreg(i2c, OCI2C_DATA); - } - - /* end of msg? */ - if (i2c->pos == msg->len) { - i2c->nmsgs--; - i2c->msg++; - i2c->pos = 0; - msg = i2c->msg; - - if (i2c->nmsgs) { /* end? */ - /* send start? */ - if (!(msg->flags & I2C_M_NOSTART)) { - u8 addr = i2c_8bit_addr_from_msg(msg); - - i2c->state = STATE_START; - - oc_setreg(i2c, OCI2C_DATA, addr); - oc_setreg(i2c, OCI2C_CMD, OCI2C_CMD_START); - goto out; - } - i2c->state = (msg->flags & I2C_M_RD) - ? STATE_READ : STATE_WRITE; - } else { - i2c->state = STATE_DONE; - oc_setreg(i2c, OCI2C_CMD, OCI2C_CMD_STOP); - goto out; - } - } - - if (i2c->state == STATE_READ) { - oc_setreg(i2c, OCI2C_CMD, i2c->pos == (msg->len-1) ? - OCI2C_CMD_READ_NACK : OCI2C_CMD_READ_ACK); - } else { - oc_setreg(i2c, OCI2C_DATA, msg->buf[i2c->pos++]); - oc_setreg(i2c, OCI2C_CMD, OCI2C_CMD_WRITE); - } - -out: - spin_unlock_irqrestore(&i2c->process_lock, flags); -} - -static irqreturn_t ocores_isr(int irq, void *dev_id) -{ - struct ocores_i2c *i2c = dev_id; - u8 stat = oc_getreg(i2c, OCI2C_STATUS); - - dev_dbg(&i2c->adap.dev, "STATUS: 0x%x\n", stat); - - if (!(stat & OCI2C_STAT_IF)) - return IRQ_NONE; - - ocores_process(i2c, stat); - - return IRQ_HANDLED; -} - -/** - * Process timeout event - * @i2c: ocores I2C device instance - */ -static void ocores_process_timeout(struct ocores_i2c *i2c) -{ - unsigned long flags; - - spin_lock_irqsave(&i2c->process_lock, flags); - i2c->state = STATE_ERROR; - oc_setreg(i2c, OCI2C_CMD, OCI2C_CMD_STOP); - spin_unlock_irqrestore(&i2c->process_lock, flags); -} - -/** - * Wait until something change in a given register - * @i2c: ocores I2C device instance - * @reg: register to query - * @mask: bitmask to apply on register value - * @val: expected result - * @timeout: timeout in jiffies - * - * Timeout is necessary to avoid to stay here forever when the chip - * does not answer correctly. - * - * Return: 0 on success, -ETIMEDOUT on timeout - */ -static int ocores_wait(struct ocores_i2c *i2c, - int reg, u8 mask, u8 val, - const unsigned long timeout) -{ - unsigned long j; - - j = jiffies + timeout; - while (1) { - u8 status = oc_getreg(i2c, reg); - - if ((status & mask) == val) - break; - - if (time_after(jiffies, j)) - return -ETIMEDOUT; - cpu_relax(); - cond_resched(); - } - return 0; -} - -/** - * Wait until is possible to process some data - * @i2c: ocores I2C device instance - * - * Used when the device is in polling mode (interrupts disabled). - * - * Return: 0 on success, -ETIMEDOUT on timeout - */ -static int ocores_poll_wait(struct ocores_i2c *i2c) -{ - u8 mask; - int err; - - if (i2c->state == STATE_DONE || i2c->state == STATE_ERROR) { - /* transfer is over */ - mask = OCI2C_STAT_BUSY; - } else { - /* on going transfer */ - mask = OCI2C_STAT_TIP; - /* - * We wait for the data to be transferred (8bit), - * then we start polling on the ACK/NACK bit - */ - udelay((8 * 1000) / i2c->bus_clock_khz); - } - - dev_dbg(&i2c->adap.dev, "Wait for: 0x%x\n", mask); - - /* - * once we are here we expect to get the expected result immediately - * so if after 1ms we timeout then something is broken. - */ - err = ocores_wait(i2c, OCI2C_STATUS, mask, 0, msecs_to_jiffies(30)); - if (err) - dev_warn(i2c->adap.dev.parent, - "%s: STATUS timeout, bit 0x%x did not clear in 30ms\n", - __func__, mask); - return err; -} - -/** - * It handles an IRQ-less transfer - * @i2c: ocores I2C device instance - * - * Even if IRQ are disabled, the I2C OpenCore IP behavior is exactly the same - * (only that IRQ are not produced). This means that we can re-use entirely - * ocores_isr(), we just add our polling code around it. - * - * It can run in atomic context - */ -static void ocores_process_polling(struct ocores_i2c *i2c) -{ - while (1) { - irqreturn_t ret; - int err; - - err = ocores_poll_wait(i2c); - if (err) { - i2c->state = STATE_ERROR; - break; /* timeout */ - } - - ret = ocores_isr(-1, i2c); - if (ret == IRQ_NONE) - break; /* all messages have been transferred */ - } -} - -static int ocores_xfer_core(struct ocores_i2c *i2c, - struct i2c_msg *msgs, int num, - bool polling) -{ - int ret; - u8 ctrl; - - ctrl = oc_getreg(i2c, OCI2C_CONTROL); - if (polling) - oc_setreg(i2c, OCI2C_CONTROL, ctrl & ~OCI2C_CTRL_IEN); - else - oc_setreg(i2c, OCI2C_CONTROL, ctrl | OCI2C_CTRL_IEN); - - i2c->msg = msgs; - i2c->pos = 0; - i2c->nmsgs = num; - i2c->state = STATE_START; - - dev_dbg(&i2c->adap.dev, "STATE: %d\n", i2c->state); - - oc_setreg(i2c, OCI2C_DATA, i2c_8bit_addr_from_msg(i2c->msg)); - oc_setreg(i2c, OCI2C_CMD, OCI2C_CMD_START); - - if (polling) { - ocores_process_polling(i2c); - } else { - ret = wait_event_timeout(i2c->wait, - (i2c->state == STATE_ERROR) || - (i2c->state == STATE_DONE), HZ); - if (ret == 0) { - ocores_process_timeout(i2c); - return -ETIMEDOUT; - } - } - - return (i2c->state == STATE_DONE) ? num : -EIO; -} - -static int ocores_xfer_polling(struct i2c_adapter *adap, - struct i2c_msg *msgs, int num) -{ - return ocores_xfer_core(i2c_get_adapdata(adap), msgs, num, true); -} - -static int ocores_xfer(struct i2c_adapter *adap, - struct i2c_msg *msgs, int num) -{ - int ret; - int retry=0; - int max_retry = 0; - struct ocores_i2c *i2c = i2c_get_adapdata(adap); - - i2c->nack_retry = 0; - - if (i2c->flags & OCORES_FLAG_POLL) - { - //return ocores_xfer_polling(adap, msgs, num); - ret = ocores_xfer_polling(adap, msgs, num); - // Fix i2cdetect issue - if(num == 1) - max_retry = 5; - else - max_retry = 5; - - while((i2c->nack_retry == 1)&&(retry < max_retry)) - { - retry++; - i2c->nack_retry = 0; - ret = ocores_xfer_polling(adap, msgs, num); - // printk("nack retry polling = %d\n",retry); - } - i2c->nack_retry = 0; - return ret; - } - return ocores_xfer_core(i2c, msgs, num, false); -} - -static int ocores_init(struct device *dev, struct ocores_i2c *i2c) -{ - int prescale; - int diff; - u8 ctrl = oc_getreg(i2c, OCI2C_CONTROL); - - /* make sure the device is disabled */ - ctrl &= ~(OCI2C_CTRL_EN | OCI2C_CTRL_IEN); - oc_setreg(i2c, OCI2C_CONTROL, ctrl); - - prescale = (i2c->ip_clock_khz / (5 * i2c->bus_clock_khz)) - 1; - prescale = clamp(prescale, 0, 0xffff); - - diff = i2c->ip_clock_khz / (5 * (prescale + 1)) - i2c->bus_clock_khz; - if (abs(diff) > i2c->bus_clock_khz / 10) { - dev_err(dev, - "Unsupported clock settings: core: %d KHz, bus: %d KHz\n", - i2c->ip_clock_khz, i2c->bus_clock_khz); - return -EINVAL; - } - - oc_setreg(i2c, OCI2C_PRELOW, prescale & 0xff); - oc_setreg(i2c, OCI2C_PREHIGH, prescale >> 8); - - dev_info(dev, "Set bus speed to %d KHz\n", i2c->bus_clock_khz); - dev_info(dev, "Prescale: %d\n", prescale); - - /* Init the device */ - oc_setreg(i2c, OCI2C_CMD, OCI2C_CMD_IACK); - oc_setreg(i2c, OCI2C_CONTROL, ctrl | OCI2C_CTRL_EN); - - return 0; -} - - -static u32 ocores_func(struct i2c_adapter *adap) -{ - return I2C_FUNC_I2C | I2C_FUNC_SMBUS_EMUL; -} - -static const struct i2c_algorithm ocores_algorithm = { - .master_xfer = ocores_xfer, - .functionality = ocores_func, -}; - -static const struct i2c_adapter ocores_adapter = { - .owner = THIS_MODULE, - .name = "i2c-ocores", - .class = I2C_CLASS_DEPRECATED, - .algo = &ocores_algorithm, -}; - -static const struct of_device_id ocores_i2c_match[] = { - { - .compatible = "opencores,i2c-ocores", - .data = (void *)TYPE_OCORES, - }, - { - .compatible = "aeroflexgaisler,i2cmst", - .data = (void *)TYPE_GRLIB, - }, - {}, -}; -MODULE_DEVICE_TABLE(of, ocores_i2c_match); - -#ifdef CONFIG_OF -/* - * Read and write functions for the GRLIB port of the controller. Registers are - * 32-bit big endian and the PRELOW and PREHIGH registers are merged into one - * register. The subsequent registers have their offsets decreased accordingly. - */ -static u8 oc_getreg_grlib(struct ocores_i2c *i2c, int reg) -{ - u32 rd; - int rreg = reg; - - if (reg != OCI2C_PRELOW) - rreg--; - rd = ioread32be(i2c->base + (rreg << i2c->reg_shift)); - if (reg == OCI2C_PREHIGH) - return (u8)(rd >> 8); - else - return (u8)rd; -} - -static void oc_setreg_grlib(struct ocores_i2c *i2c, int reg, u8 value) -{ - u32 curr, wr; - int rreg = reg; - - if (reg != OCI2C_PRELOW) - rreg--; - if (reg == OCI2C_PRELOW || reg == OCI2C_PREHIGH) { - curr = ioread32be(i2c->base + (rreg << i2c->reg_shift)); - if (reg == OCI2C_PRELOW) - wr = (curr & 0xff00) | value; - else - wr = (((u32)value) << 8) | (curr & 0xff); - } else { - wr = value; - } - iowrite32be(wr, i2c->base + (rreg << i2c->reg_shift)); -} - -static int ocores_i2c_of_probe(struct platform_device *pdev, - struct ocores_i2c *i2c) -{ - struct device_node *np = pdev->dev.of_node; - const struct of_device_id *match; - u32 val; - u32 clock_frequency; - bool clock_frequency_present; - - if (of_property_read_u32(np, "reg-shift", &i2c->reg_shift)) { - /* no 'reg-shift', check for deprecated 'regstep' */ - if (!of_property_read_u32(np, "regstep", &val)) { - if (!is_power_of_2(val)) { - dev_err(&pdev->dev, "invalid regstep %d\n", - val); - return -EINVAL; - } - i2c->reg_shift = ilog2(val); - dev_warn(&pdev->dev, - "regstep property deprecated, use reg-shift\n"); - } - } - - clock_frequency_present = !of_property_read_u32(np, "clock-frequency", - &clock_frequency); - i2c->bus_clock_khz = 100; - - i2c->clk = devm_clk_get(&pdev->dev, NULL); - - if (!IS_ERR(i2c->clk)) { - int ret = clk_prepare_enable(i2c->clk); - - if (ret) { - dev_err(&pdev->dev, - "clk_prepare_enable failed: %d\n", ret); - return ret; - } - i2c->ip_clock_khz = clk_get_rate(i2c->clk) / 1000; - if (clock_frequency_present) - i2c->bus_clock_khz = clock_frequency / 1000; - } - - if (i2c->ip_clock_khz == 0) { - if (of_property_read_u32(np, "opencores,ip-clock-frequency", - &val)) { - if (!clock_frequency_present) { - dev_err(&pdev->dev, - "Missing required parameter 'opencores,ip-clock-frequency'\n"); - clk_disable_unprepare(i2c->clk); - return -ENODEV; - } - i2c->ip_clock_khz = clock_frequency / 1000; - dev_warn(&pdev->dev, - "Deprecated usage of the 'clock-frequency' property, please update to 'opencores,ip-clock-frequency'\n"); - } else { - i2c->ip_clock_khz = val / 1000; - if (clock_frequency_present) - i2c->bus_clock_khz = clock_frequency / 1000; - } - } - - of_property_read_u32(pdev->dev.of_node, "reg-io-width", - &i2c->reg_io_width); - - match = of_match_node(ocores_i2c_match, pdev->dev.of_node); - if (match && (long)match->data == TYPE_GRLIB) { - dev_dbg(&pdev->dev, "GRLIB variant of i2c-ocores\n"); - i2c->setreg = oc_setreg_grlib; - i2c->getreg = oc_getreg_grlib; - } - - return 0; -} -#else -#define ocores_i2c_of_probe(pdev, i2c) -ENODEV -#endif - -static int ocores_i2c_probe(struct platform_device *pdev) -{ - struct ocores_i2c *i2c; - struct ocores_i2c_platform_data *pdata; - struct resource *res; - int irq; - int ret; - int i; - - i2c = devm_kzalloc(&pdev->dev, sizeof(*i2c), GFP_KERNEL); - if (!i2c) - return -ENOMEM; - - spin_lock_init(&i2c->process_lock); - - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); - if (res) { - i2c->base = devm_ioremap_resource(&pdev->dev, res); - if (IS_ERR(i2c->base)) - return PTR_ERR(i2c->base); - } else { - res = platform_get_resource(pdev, IORESOURCE_IO, 0); - if (!res) - return -EINVAL; - i2c->iobase = res->start; - if (!devm_request_region(&pdev->dev, res->start, - resource_size(res), - pdev->name)) { - dev_err(&pdev->dev, "Can't get I/O resource.\n"); - return -EBUSY; - } - i2c->setreg = oc_setreg_io_8; - i2c->getreg = oc_getreg_io_8; - } - - pdata = dev_get_platdata(&pdev->dev); - if (pdata) { - i2c->reg_shift = pdata->reg_shift; - i2c->reg_io_width = pdata->reg_io_width; - i2c->ip_clock_khz = pdata->clock_khz; - if (pdata->bus_khz) - i2c->bus_clock_khz = pdata->bus_khz; - else - i2c->bus_clock_khz = 100; - } else { - ret = ocores_i2c_of_probe(pdev, i2c); - if (ret) - return ret; - } - - if (i2c->reg_io_width == 0) - i2c->reg_io_width = 1; /* Set to default value */ - - if (!i2c->setreg || !i2c->getreg) { - bool be = pdata ? pdata->big_endian : - of_device_is_big_endian(pdev->dev.of_node); - - switch (i2c->reg_io_width) { - case 1: - i2c->setreg = oc_setreg_8; - i2c->getreg = oc_getreg_8; - break; - - case 2: - i2c->setreg = be ? oc_setreg_16be : oc_setreg_16; - i2c->getreg = be ? oc_getreg_16be : oc_getreg_16; - break; - - case 4: - i2c->setreg = be ? oc_setreg_32be : oc_setreg_32; - i2c->getreg = be ? oc_getreg_32be : oc_getreg_32; - break; - - default: - dev_err(&pdev->dev, "Unsupported I/O width (%d)\n", - i2c->reg_io_width); - ret = -EINVAL; - goto err_clk; - } - } - - init_waitqueue_head(&i2c->wait); - - irq = platform_get_irq(pdev, 0); - if (irq == -ENXIO) { - i2c->flags |= OCORES_FLAG_POLL; - } else { - if (irq < 0) - return irq; - } - - if (!(i2c->flags & OCORES_FLAG_POLL)) { - ret = devm_request_irq(&pdev->dev, irq, ocores_isr, 0, - pdev->name, i2c); - if (ret) { - dev_err(&pdev->dev, "Cannot claim IRQ\n"); - goto err_clk; - } - } - - ret = ocores_init(&pdev->dev, i2c); - if (ret) - goto err_clk; - - /* hook up driver to tree */ - platform_set_drvdata(pdev, i2c); - i2c->adap = ocores_adapter; - i2c_set_adapdata(&i2c->adap, i2c); - i2c->adap.dev.parent = &pdev->dev; - i2c->adap.dev.of_node = pdev->dev.of_node; - - /* add i2c adapter to i2c tree */ - ret = i2c_add_adapter(&i2c->adap); - if (ret) - goto err_clk; - - /* add in known devices to the bus */ - if (pdata) { - for (i = 0; i < pdata->num_devices; i++) - i2c_new_device(&i2c->adap, pdata->devices + i); - } - - return 0; - -err_clk: - clk_disable_unprepare(i2c->clk); - return ret; -} - -static int ocores_i2c_remove(struct platform_device *pdev) -{ - struct ocores_i2c *i2c = platform_get_drvdata(pdev); - u8 ctrl = oc_getreg(i2c, OCI2C_CONTROL); - - /* disable i2c logic */ - ctrl &= ~(OCI2C_CTRL_EN | OCI2C_CTRL_IEN); - oc_setreg(i2c, OCI2C_CONTROL, ctrl); - - /* remove adapter & data */ - i2c_del_adapter(&i2c->adap); - - if (!IS_ERR(i2c->clk)) - clk_disable_unprepare(i2c->clk); - - return 0; -} - -#ifdef CONFIG_PM_SLEEP -static int ocores_i2c_suspend(struct device *dev) -{ - struct ocores_i2c *i2c = dev_get_drvdata(dev); - u8 ctrl = oc_getreg(i2c, OCI2C_CONTROL); - - /* make sure the device is disabled */ - ctrl &= ~(OCI2C_CTRL_EN | OCI2C_CTRL_IEN); - oc_setreg(i2c, OCI2C_CONTROL, ctrl); - - if (!IS_ERR(i2c->clk)) - clk_disable_unprepare(i2c->clk); - return 0; -} - -static int ocores_i2c_resume(struct device *dev) -{ - struct ocores_i2c *i2c = dev_get_drvdata(dev); - - if (!IS_ERR(i2c->clk)) { - unsigned long rate; - int ret = clk_prepare_enable(i2c->clk); - - if (ret) { - dev_err(dev, - "clk_prepare_enable failed: %d\n", ret); - return ret; - } - rate = clk_get_rate(i2c->clk) / 1000; - if (rate) - i2c->ip_clock_khz = rate; - } - return ocores_init(dev, i2c); -} - -static SIMPLE_DEV_PM_OPS(ocores_i2c_pm, ocores_i2c_suspend, ocores_i2c_resume); -#define OCORES_I2C_PM (&ocores_i2c_pm) -#else -#define OCORES_I2C_PM NULL -#endif - -static struct platform_driver ocores_i2c_driver = { - .probe = ocores_i2c_probe, - .remove = ocores_i2c_remove, - .driver = { - .name = "cls-ocores-i2c", - .of_match_table = ocores_i2c_match, - .pm = OCORES_I2C_PM, - }, -}; - -module_platform_driver(ocores_i2c_driver); - -MODULE_AUTHOR("Peter Korsgaard "); -MODULE_DESCRIPTION("OpenCores I2C bus driver"); -MODULE_LICENSE("GPL"); -MODULE_ALIAS("platform:cls-ocores-i2c"); diff --git a/packages/platforms/celestica/x86-64/silverstone/modules/builds/src/i2c-ocores.h b/packages/platforms/celestica/x86-64/silverstone/modules/builds/src/i2c-ocores.h deleted file mode 100644 index 25926b385..000000000 --- a/packages/platforms/celestica/x86-64/silverstone/modules/builds/src/i2c-ocores.h +++ /dev/null @@ -1,22 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/* - * i2c-ocores.h - definitions for the i2c-ocores interface - * - * Peter Korsgaard - */ - -#ifndef _LINUX_I2C_OCORES_H -#define _LINUX_I2C_OCORES_H - -struct ocores_i2c_platform_data { - u32 reg_shift; /* register offset shift value */ - u32 reg_io_width; /* register io read/write width */ - u32 clock_khz; /* input clock in kHz */ - u32 bus_khz; /* bus clock in kHz */ - bool big_endian; /* registers are big endian */ - u8 num_devices; /* number of devices in the devices list */ - struct i2c_board_info const *devices; /* devices connected to the bus */ -}; - -#endif /* _LINUX_I2C_OCORES_H */ - diff --git a/packages/platforms/celestica/x86-64/silverstone/modules/builds/src/mc24lc64t.c b/packages/platforms/celestica/x86-64/silverstone/modules/builds/src/mc24lc64t.c deleted file mode 100644 index 7a621e7ac..000000000 --- a/packages/platforms/celestica/x86-64/silverstone/modules/builds/src/mc24lc64t.c +++ /dev/null @@ -1,174 +0,0 @@ -/* - * mc24lc64t.c - driver for Microchip 24LC64T - * - * Copyright (C) 2017 Celestica 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 Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - */ - -#include -#include -#include -#include -#include -#include -#include -#include - -#define EEPROM_SIZE 8192 //mc24lt64t eeprom size in bytes. - -struct mc24lc64t_data { - struct mutex update_lock; -}; - -static ssize_t mc24lc64t_read(struct file *filp, struct kobject *kobj, - struct bin_attribute *bin_attr, - char *buf, loff_t off, size_t count) -{ - struct i2c_client *client = kobj_to_i2c_client(kobj); - struct mc24lc64t_data *drvdata = i2c_get_clientdata(client); - unsigned long timeout, read_time, i = 0; - int status; - - mutex_lock(&drvdata->update_lock); - - if (i2c_smbus_write_byte_data(client, off>>8, off)) - { - status = -EIO; - goto exit; - } - - msleep(1); - -begin: - - if (i < count) - { - timeout = jiffies + msecs_to_jiffies(25); /* 25 mS timeout*/ - do { - read_time = jiffies; - - status = i2c_smbus_read_byte(client); - if (status >= 0) - { - buf[i++] = status; - goto begin; - } - } while (time_before(read_time, timeout)); - - status = -ETIMEDOUT; - goto exit; - } - - status = count; - -exit: - mutex_unlock(&drvdata->update_lock); - - return status; -} - - -static ssize_t mc24lc64t_write (struct file *filp, struct kobject *kobj, - struct bin_attribute *bin_attr, - char *buf, loff_t off, size_t count){ - - struct i2c_client *client = kobj_to_i2c_client(kobj); - struct mc24lc64t_data *drvdata = i2c_get_clientdata(client); - unsigned long timeout, write_time, i = 0; - int status; - u16 value; - - mutex_lock(&drvdata->update_lock); - -begin: - if (i < count){ - timeout = jiffies + msecs_to_jiffies(25); /* 25 mS timeout*/ - value = (buf[i] << 8 | ( off &0xff)); - do { - write_time = jiffies; - status = i2c_smbus_write_word_data(client, off>>8, value); - if (status >= 0) - { - // increase offset - off++; - // increase buffer index - i++; - goto begin; - } - } while (time_before(write_time, timeout)); - status = -ETIMEDOUT; - goto exit; - } - status = count; - -exit: - mutex_unlock(&drvdata->update_lock); - return status; -} - - -static struct bin_attribute mc24lc64t_bit_attr = { - .attr = { - .name = "eeprom", - .mode = S_IRUGO | S_IWUGO, - }, - .size = EEPROM_SIZE, - .read = mc24lc64t_read, - .write = mc24lc64t_write, -}; - -static int mc24lc64t_probe(struct i2c_client *client, - const struct i2c_device_id *id) -{ - struct i2c_adapter *adapter = client->adapter; - struct mc24lc64t_data *drvdata; - int err; - - if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_WRITE_BYTE_DATA - | I2C_FUNC_SMBUS_READ_BYTE)) - return -EPFNOSUPPORT; - - if (!(drvdata = devm_kzalloc(&client->dev, - sizeof(struct mc24lc64t_data), GFP_KERNEL))) - return -ENOMEM; - - i2c_set_clientdata(client, drvdata); - mutex_init(&drvdata->update_lock); - - err = sysfs_create_bin_file(&client->dev.kobj, &mc24lc64t_bit_attr); - return err; -} - -static int mc24lc64t_remove(struct i2c_client *client) -{ - struct mc24lc64t_data *drvdata = i2c_get_clientdata(client); - sysfs_remove_bin_file(&client->dev.kobj, &mc24lc64t_bit_attr); - - return 0; -} - -static const struct i2c_device_id mc24lc64t_id[] = { - { "24lc64t", 0 }, - { } -}; -MODULE_DEVICE_TABLE(i2c, mc24lc64t_id); - -static struct i2c_driver mc24lc64t_driver = { - .driver = { - .name = "mc24lc64t", - .owner = THIS_MODULE, - }, - .probe = mc24lc64t_probe, - .remove = mc24lc64t_remove, - .id_table = mc24lc64t_id, -}; - -module_i2c_driver(mc24lc64t_driver); - -MODULE_AUTHOR("Abhisit Sangjan "); -MODULE_DESCRIPTION("Microchip 24LC64T Driver"); -MODULE_LICENSE("GPL"); diff --git a/packages/platforms/celestica/x86-64/silverstone/modules/builds/src/optoe.c b/packages/platforms/celestica/x86-64/silverstone/modules/builds/src/optoe.c deleted file mode 100644 index 11ce9efa7..000000000 --- a/packages/platforms/celestica/x86-64/silverstone/modules/builds/src/optoe.c +++ /dev/null @@ -1,1198 +0,0 @@ -/* - * 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. - * - * The CMIS (Common Management Interface Specification) defines use of - * considerably more pages (at least to page 0xAF), which this driver - * supports. - * - * NOTE: This version of the driver ONLY SUPPORTS BANK 0 PAGES on CMIS - * devices. - * - **/ - -/* #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 - -#ifdef EEPROM_CLASS -#include -#endif - -#include - -/* The maximum length of a port name */ -#define MAX_PORT_NAME_LEN 20 - -struct optoe_platform_data { - u32 byte_len; /* size (sum of all addr) */ - u16 page_size; /* for writes */ - u8 flags; - void *dummy1; /* backward compatibility */ - void *dummy2; /* backward compatibility */ - -#ifdef EEPROM_CLASS - struct eeprom_platform_data *eeprom_data; -#endif - char port_name[MAX_PORT_NAME_LEN]; -}; - -/* 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) -#define TWO_ADDR_NO_0X51_SIZE (2 * 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 QSFP_NOT_PAGEABLE (1<<2) -#define CMIS_NOT_PAGEABLE (1<<7) -#define TWO_ADDR_PAGEABLE_REG 0x40 -#define TWO_ADDR_PAGEABLE (1<<4) -#define TWO_ADDR_0X51_REG 92 -#define TWO_ADDR_0X51_SUPP (1<<6) -#define OPTOE_ID_REG 0 -#define OPTOE_READ_OP 0 -#define OPTOE_WRITE_OP 1 -#define OPTOE_EOF 0 /* used for access beyond end of device */ - -struct optoe_data { - struct optoe_platform_data chip; - 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 int write_max; - - unsigned int 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[]; -}; - - -/* - * 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 int 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 int 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 -#define CMIS_ADDR 3 - -static const struct i2c_device_id optoe_ids[] = { - { "optoe1", ONE_ADDR }, - { "optoe2", TWO_ADDR }, - { "optoe3", CMIS_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 int 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 int 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 */ - usleep_range(1000, 2000); - } 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 int offset, size_t count) -{ - struct i2c_msg msg; - ssize_t status; - unsigned long timeout, write_time; - unsigned int 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 */ - usleep_range(1000, 2000); - } 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, int 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, - "%s off %lld page:%d phy_offset:%lld, count:%ld, opcode:%d\n", - __func__, 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 OPTOE_EOF (zero) - */ -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 not_pageable; - int status; - size_t maxlen; - - if (off < 0) - return -EINVAL; - if (optoe->dev_class == TWO_ADDR) { - /* SFP case */ - /* if only using addr 0x50 (first 256 bytes) we're good */ - if ((off + len) <= TWO_ADDR_NO_0X51_SIZE) - return len; - /* if offset exceeds possible pages, we're not good */ - if (off >= TWO_ADDR_EEPROM_SIZE) - return OPTOE_EOF; - /* 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 OPTOE_EOF; - - /* will be accessing addr 0x51, is that supported? */ - /* byte 92, bit 6 implies DDM support, 0x51 support */ - status = optoe_eeprom_read(optoe, client, ®val, - TWO_ADDR_0X51_REG, 1); - if (status < 0) - return status; - if (regval & TWO_ADDR_0X51_SUPP) { - /* addr 0x51 is OK */ - maxlen = TWO_ADDR_EEPROM_UNPAGED_SIZE - off; - } else { - /* addr 0x51 NOT supported, trim to 256 max */ - if (off >= TWO_ADDR_NO_0X51_SIZE) - return OPTOE_EOF; - maxlen = TWO_ADDR_NO_0X51_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, CMIS 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 OPTOE_EOF; - /* 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 (optoe->dev_class == ONE_ADDR) { - not_pageable = QSFP_NOT_PAGEABLE; - } else { - not_pageable = CMIS_NOT_PAGEABLE; - } - dev_dbg(&client->dev, - "Paging Register: 0x%x; not_pageable mask: 0x%x\n", - regval, not_pageable); - - if (regval & not_pageable) { - /* pages not supported, trim len to unpaged size */ - if (off >= ONE_ADDR_EEPROM_UNPAGED_SIZE) - return OPTOE_EOF; - 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, int 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; - loff_t chunk_end_offset = 0; - - dev_dbg(&client->dev, - "%s: off %lld len:%ld, opcode:%s\n", - __func__, 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 == OPTOE_EOF) || (status < 0)) { - mutex_unlock(&optoe->lock); - return status; - } - 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 an offset not equal to 0 (within the chunk) - * and read/write less than the rest of the chunk - * 2. start at an offset not equal to 0 and read/write the rest - * of the chunk - * 3. start at offset 0 (within the chunk) and read/write less - * than entire chunk - * 4. start at offset 0 (within the chunk), and read/write - * the entire chunk - */ - chunk_start_offset = chunk * OPTOE_PAGE_SIZE; - chunk_end_offset = chunk_start_offset + OPTOE_PAGE_SIZE; - - if (chunk_start_offset < off) { - chunk_offset = off; - if ((off + pending_len) < chunk_end_offset) - chunk_len = pending_len; - else - chunk_len = chunk_end_offset - off; - } else { - chunk_offset = chunk_start_offset; - if (pending_len < OPTOE_PAGE_SIZE) - chunk_len = pending_len; - else - chunk_len = OPTOE_PAGE_SIZE; - } - - 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, - "o_u_c: chunk %d c_offset %lld c_len %ld failed %d!\n", - chunk, chunk_offset, (long int) chunk_len, status); - if (status > 0) - retval += status; - if (retval == 0) - retval = status; - break; - } - buf += status; - pending_len -= status; - retval += status; - } - mutex_unlock(&optoe->lock); - - return retval; -} - -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); -} - -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_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 i2c addresses used, thus - * legal values are "1" (QSFP class) and "2" (SFP class) - * And... CMIS spec is 1 i2c address, but puts the pageable - * bit in a different location, so CMIS devices are "3" - */ - - if (kstrtoint(buf, 0, &dev_class) != 0 || - dev_class < 1 || dev_class > 3) - return -EINVAL; - - mutex_lock(&optoe->lock); - if (dev_class == TWO_ADDR) { - /* SFP family */ - /* if it doesn't exist, create 0x51 i2c address */ - if (!optoe->client[1]) { - optoe->client[1] = i2c_new_dummy(client->adapter, 0x51); - if (!optoe->client[1]) { - dev_err(&client->dev, - "address 0x51 unavailable\n"); - mutex_unlock(&optoe->lock); - return -EADDRINUSE; - } - } - optoe->bin.size = TWO_ADDR_EEPROM_SIZE; - optoe->num_addresses = 2; - } else { - /* one-address (eg QSFP) and CMIS family */ - /* if it exists, remove 0x51 i2c address */ - if (optoe->client[1]) - i2c_unregister_device(optoe->client[1]); - optoe->bin.size = ONE_ADDR_EEPROM_SIZE; - optoe->num_addresses = 1; - } - optoe->dev_class = dev_class; - mutex_unlock(&optoe->lock); - - return count; -} - -/* - * if using the EEPROM CLASS driver, we don't report a port_name, - * the EEPROM CLASS drive handles that. Hence all this code is - * only compiled if we are NOT using the EEPROM CLASS driver. - */ -#ifndef EEPROM_CLASS - -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, 0644, show_port_name, set_port_name); -#endif /* if NOT defined EEPROM_CLASS, the common case */ - -static DEVICE_ATTR(dev_class, 0644, show_dev_class, set_dev_class); - -static struct attribute *optoe_attrs[] = { -#ifndef EEPROM_CLASS - &dev_attr_port_name.attr, -#endif - &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; - char port_name[MAX_PORT_NAME_LEN]; - - 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; - /* take the port name from the supplied platform data */ -#ifdef EEPROM_CLASS - strncpy(port_name, chip.eeprom_data->label, MAX_PORT_NAME_LEN); -#else - memcpy(port_name, chip.port_name, MAX_PORT_NAME_LEN); -#endif - 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"); - strcpy(port_name, "unitialized"); - chip.flags = 0; -#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; - num_addresses = 2; - } else if (strcmp(client->name, "optoe3") == 0) { - /* CMIS spec */ - optoe->dev_class = CMIS_ADDR; - chip.byte_len = ONE_ADDR_EEPROM_SIZE; - num_addresses = 1; - } else { /* those were the only 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; - memcpy(optoe->port_name, port_name, MAX_PORT_NAME_LEN); - - /* - * 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 = 0444; - optoe->bin.read = optoe_bin_read; - optoe->bin.size = chip.byte_len; - - 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 int write_max = 1; - - optoe->bin.write = optoe_bin_write; - optoe->bin.attr.mode |= 0200; - - 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; - - /* SFF-8472 spec requires that the second I2C address be 0x51 */ - if (num_addresses == 2) { - optoe->client[1] = i2c_new_dummy(client->adapter, 0x51); - if (!optoe->client[1]) { - dev_err(&client->dev, "address 0x51 unavailable\n"); - 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"); - } - - 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: - if (num_addresses == 2) { - if (optoe->client[1]) - i2c_unregister_device(optoe->client[1]); - } - - 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"); \ No newline at end of file diff --git a/packages/platforms/celestica/x86-64/silverstone/modules/builds/src/switchboard-diag.c b/packages/platforms/celestica/x86-64/silverstone/modules/builds/src/switchboard-diag.c deleted file mode 100644 index ee3e6d7be..000000000 --- a/packages/platforms/celestica/x86-64/silverstone/modules/builds/src/switchboard-diag.c +++ /dev/null @@ -1,1310 +0,0 @@ -/* - * switchboard-diag.c - driver for Silverstone Switch board FPGA/CPLD diag. - * - * Author: Pradchaya Phucharoen - * - * Copyright (C) 2019 Celestica 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 Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * DISCLAIMER: THIS FILE IS INTENEDED TO PRESERVE THE SYSFS NODES FOR - * BACKWARD COMPATIBLE WITH OLD DIAGNOSTIC PACKAGE. THE MODULE *REMAP* - * THE PCI MEMORY REGION 0 OF THE FPGA PCI DEVICE, YOU CAN SEE THE - * WARNING MESSAGE IN KERNEL LOG. PLEASE *DO NOT* FOLLOW THIS DESIGN. - * - * / - * \--sys - * \--devices - * \--platform - * \--cls_switch - * |--FPGA - * |--CPLD1 - * |--CPLD2 - * \--SFF - * |--QSFP[1..32] - * \--SFP[1..2] - * - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define MOD_VERSION "2.0.3" -#define FPGA_PCI_DEVICE_ID 0x7021 -#define FPGA_PCI_BAR_NUM 0 -#define SWITCH_CPLD_ADAP_NUM 4 - -#define CLASS_NAME "cls_fpga" -#define DRIVER_NAME "cls_switch" -#define FPGA_PCI_NAME "cls_fpga_pci" -#define DEVICE_NAME "fwupgrade" - -static int fpga_pci_probe(struct pci_dev *pdev); -static void fpga_pci_remove(void); - - -/* -======================================== -FPGA PCIe BAR 0 Registers -======================================== -Misc Control 0x00000000 - 0x000000FF. -I2C_CH1 0x00000100 - 0x00000110 -I2C_CH2 0x00000200 - 0x00000210. -I2C_CH3 0x00000300 - 0x00000310. -I2C_CH4 0x00000400 - 0x00000410. -I2C_CH5 0x00000500 - 0x00000510. -I2C_CH6 0x00000600 - 0x00000610. -I2C_CH7 0x00000700 - 0x00000710. -I2C_CH8 0x00000800 - 0x00000810. -I2C_CH9 0x00000900 - 0x00000910. -I2C_CH10 0x00000A00 - 0x00000A10. -I2C_CH11 0x00000B00 - 0x00000B10. -I2C_CH12 0x00000C00 - 0x00000C10. -I2C_CH13 0x00000D00 - 0x00000D10. -SPI Master 0x00001200 - 0x00001300. -DPLL SPI Master 0x00001320 - 0x0000132F. -PORT XCVR 0x00004000 - 0x00004FFF. -*/ - -/* MISC */ -#define FPGA_VERSION 0x0000 -#define FPGA_VERSION_MJ_MSK 0xff00 -#define FPGA_VERSION_MN_MSK 0x00ff -#define FPGA_SCRATCH 0x0004 -#define FPGA_PORT_XCVR_READY 0x000c - -#define I2C_MASTER_CH_1 1 -#define I2C_MASTER_CH_2 2 -#define I2C_MASTER_CH_3 3 - -/* FPGA FRONT PANEL PORT MGMT */ -#define SFF_PORT_CTRL_BASE 0x4000 -#define SFF_PORT_STATUS_BASE 0x4004 -#define SFF_PORT_INT_STATUS_BASE 0x4008 -#define SFF_PORT_INT_MASK_BASE 0x400c - -#define PORT_XCVR_REGISTER_SIZE 0x1000 - -/* PORT CTRL REGISTER -[31:7] RSVD -[6] LPMOD 6 -[5] RSVD -[4] RST 4 -[3:1] RSVD -[0] TXDIS 0 -*/ -#define CTRL_LPMOD 6 -#define CTRL_RST 4 -#define CTRL_TXDIS 0 - -/* PORT STATUS REGISTER -[31:6] RSVD -[5] IRQ 5 -[4] PRESENT 4 -[3] RSVD -[2] TXFAULT 2 -[1] RXLOS 1 -[0] MODABS 0 -*/ -#define STAT_IRQ 5 -#define STAT_PRESENT 4 -#define STAT_TXFAULT 2 -#define STAT_RXLOS 1 -#define STAT_MODABS 0 - -/* PORT INTRPT REGISTER -[31:6] RSVD -[5] INT_N 5 -[4] PRESENT 4 -[3] RSVD -[2] RSVD -[1] RXLOS 1 -[0] MODABS 0 -*/ -#define INTR_INT_N 5 -#define INTR_PRESENT 4 -#define INTR_TXFAULT 2 -#define INTR_RXLOS 1 -#define INTR_MODABS 0 - -/* PORT INT MASK REGISTER -[31:6] RSVD -[5] INT_N 5 -[4] PRESENT 4 -[3] RSVD -[2] RSVD -[1] RXLOS_INT 1 -[0] MODABS 0 -*/ -#define MASK_INT_N 5 -#define MASK_PRESENT 4 -#define MASK_TXFAULT 2 -#define MASK_RXLOS 1 -#define MASK_MODABS 0 - -/** - * - * The function is i2c algorithm implement to allow master access to - * correct endpoint devices trough the PCA9548 switch devices. - * - * FPGA I2C Master [mutex resource] - * | - * | - * --------------------------- - * | PCA9548(s) | - * ---1--2--3--4--5--6--7--8-- - * | | | | | | | | - * EEPROM ... EEPROM - * - */ - -#define VIRTUAL_I2C_QSFP_PORT 32 -#define VIRTUAL_I2C_SFP_PORT 2 -#define CPLD1_SLAVE_ADDR 0x30 -#define CPLD2_SLAVE_ADDR 0x31 -#define NUM_I2C_CLIENT 2 -#define SFF_PORT_TOTAL VIRTUAL_I2C_QSFP_PORT + VIRTUAL_I2C_SFP_PORT - -static struct class* fpgafwclass = NULL; // < The device-driver class struct pointer - -enum PORT_TYPE { - NONE, - QSFP, - SFP -}; - -struct i2c_switch { - unsigned char master_bus; // I2C bus number - unsigned char switch_addr; // PCA9548 device address, 0xFF if directly connect to a bus. - unsigned char channel; // PCA9548 channel number. If the switch_addr is 0xFF, this value is ignored. - enum PORT_TYPE port_type; // QSFP/SFP tranceiver port type. - char calling_name[20]; // Calling name. -}; - -struct i2c_dev_data { - int portid; - struct i2c_switch pca9548; -}; - -/* PREDEFINED I2C SWITCH DEVICE TOPOLOGY */ -static struct i2c_switch fpga_i2c_bus_dev[] = { - /* BUS3 QSFP Exported as virtual bus */ - {I2C_MASTER_CH_3, 0x71, 2, QSFP, "QSFP1"}, {I2C_MASTER_CH_3, 0x71, 3, QSFP, "QSFP2"}, - {I2C_MASTER_CH_3, 0x71, 0, QSFP, "QSFP3"}, {I2C_MASTER_CH_3, 0x71, 1, QSFP, "QSFP4"}, - {I2C_MASTER_CH_3, 0x71, 6, QSFP, "QSFP5"}, {I2C_MASTER_CH_3, 0x71, 5, QSFP, "QSFP6"}, - {I2C_MASTER_CH_3, 0x73, 7, QSFP, "QSFP7"}, {I2C_MASTER_CH_3, 0x71, 4, QSFP, "QSFP8"}, - - {I2C_MASTER_CH_3, 0x73, 4, QSFP, "QSFP9"}, {I2C_MASTER_CH_3, 0x73, 3, QSFP, "QSFP10"}, - {I2C_MASTER_CH_3, 0x73, 6, QSFP, "QSFP11"}, {I2C_MASTER_CH_3, 0x73, 2, QSFP, "QSFP12"}, - {I2C_MASTER_CH_3, 0x73, 1, QSFP, "QSFP13"}, {I2C_MASTER_CH_3, 0x73, 5, QSFP, "QSFP14"}, - {I2C_MASTER_CH_3, 0x71, 7, QSFP, "QSFP15"}, {I2C_MASTER_CH_3, 0x73, 0, QSFP, "QSFP16"}, - - {I2C_MASTER_CH_3, 0x72, 1, QSFP, "QSFP17"}, {I2C_MASTER_CH_3, 0x72, 7, QSFP, "QSFP18"}, - {I2C_MASTER_CH_3, 0x72, 4, QSFP, "QSFP19"}, {I2C_MASTER_CH_3, 0x72, 0, QSFP, "QSFP20"}, - {I2C_MASTER_CH_3, 0x72, 5, QSFP, "QSFP21"}, {I2C_MASTER_CH_3, 0x72, 2, QSFP, "QSFP22"}, - {I2C_MASTER_CH_3, 0x70, 5, QSFP, "QSFP23"}, {I2C_MASTER_CH_3, 0x72, 6, QSFP, "QSFP24"}, - - {I2C_MASTER_CH_3, 0x72, 3, QSFP, "QSFP25"}, {I2C_MASTER_CH_3, 0x70, 6, QSFP, "QSFP26"}, - {I2C_MASTER_CH_3, 0x70, 0, QSFP, "QSFP27"}, {I2C_MASTER_CH_3, 0x70, 7, QSFP, "QSFP28"}, - {I2C_MASTER_CH_3, 0x70, 2, QSFP, "QSFP29"}, {I2C_MASTER_CH_3, 0x70, 4, QSFP, "QSFP30"}, - {I2C_MASTER_CH_3, 0x70, 3, QSFP, "QSFP31"}, {I2C_MASTER_CH_3, 0x70, 1, QSFP, "QSFP32"}, - /* BUS1 SFP+ Exported as virtual bus */ - {I2C_MASTER_CH_1, 0xFF, 0, SFP, "SFP1"}, - /* BUS2 SFP+ Exported as virtual bus */ - {I2C_MASTER_CH_2, 0xFF, 0, SFP, "SFP2"}, -}; - -struct fpga_device { - /* data mmio region */ - void __iomem *data_base_addr; - resource_size_t data_mmio_start; - resource_size_t data_mmio_len; -}; - -static struct fpga_device fpga_dev = { - .data_base_addr = 0, - .data_mmio_start = 0, - .data_mmio_len = 0, -}; - -struct silverstone_fpga_data { - struct device *sff_devices[SFF_PORT_TOTAL]; - struct i2c_client *cpld_i2c_clients[NUM_I2C_CLIENT]; - struct mutex fpga_lock; // For FPGA internal lock - void __iomem * fpga_read_addr; - uint8_t cpld1_read_addr; - uint8_t cpld2_read_addr; -}; - -struct sff_device_data { - int portid; - enum PORT_TYPE port_type; -}; - -struct silverstone_fpga_data *fpga_data; - -/* - * Kernel object for other module drivers. - * Other module can use these kobject as a parent. - */ - -static struct kobject *fpga = NULL; -static struct kobject *cpld1 = NULL; -static struct kobject *cpld2 = NULL; - -/** - * Device node in sysfs tree. - */ -static struct device *sff_dev = NULL; - -/** - * Show the value of the register set by 'set_fpga_reg_address' - * If the address is not set by 'set_fpga_reg_address' first, - * The version register is selected by default. - * @param buf register value in hextring - * @return number of bytes read, or an error code - */ -static ssize_t get_fpga_reg_value(struct device *dev, struct device_attribute *devattr, - char *buf) -{ - // read data from the address - uint32_t data; - data = ioread32(fpga_data->fpga_read_addr); - return sprintf(buf, "0x%8.8x\n", data); -} -/** - * Store the register address - * @param buf address wanted to be read value of - * @return number of bytes stored, or an error code - */ -static ssize_t set_fpga_reg_address(struct device *dev, struct device_attribute *devattr, - const char *buf, size_t count) -{ - uint32_t addr; - char *last; - - addr = (uint32_t)strtoul(buf, &last, 16); - if (addr == 0 && buf == last) { - return -EINVAL; - } - fpga_data->fpga_read_addr = fpga_dev.data_base_addr + addr; - return count; -} -/** - * Show value of fpga scratch register - * @param buf register value in hexstring - * @return number of bytes read, or an error code - */ -static ssize_t get_fpga_scratch(struct device *dev, struct device_attribute *devattr, - char *buf) -{ - return sprintf(buf, "0x%8.8x\n", ioread32(fpga_dev.data_base_addr + FPGA_SCRATCH) & 0xffffffff); -} -/** - * Store value of fpga scratch register - * @param buf scratch register value passing from user space - * @return number of bytes stored, or an error code - */ -static ssize_t set_fpga_scratch(struct device *dev, struct device_attribute *devattr, - const char *buf, size_t count) -{ - uint32_t data; - char *last; - data = (uint32_t)strtoul(buf, &last, 16); - if (data == 0 && buf == last) { - return -EINVAL; - } - iowrite32(data, fpga_dev.data_base_addr + FPGA_SCRATCH); - return count; -} -/** - * Store a value in a specific register address - * @param buf the value and address in format '0xhhhh 0xhhhhhhhh' - * @return number of bytes sent by user space, or an error code - */ -static ssize_t set_fpga_reg_value(struct device *dev, struct device_attribute *devattr, - const char *buf, size_t count) -{ - // register are 4 bytes - uint32_t addr; - uint32_t value; - uint32_t mode = 8; - char *tok; - char clone[count]; - char *pclone = clone; - char *last; - - strcpy(clone, buf); - - mutex_lock(&fpga_data->fpga_lock); - tok = strsep((char**)&pclone, " "); - if (tok == NULL) { - mutex_unlock(&fpga_data->fpga_lock); - return -EINVAL; - } - addr = (uint32_t)strtoul(tok, &last, 16); - if (addr == 0 && tok == last) { - mutex_unlock(&fpga_data->fpga_lock); - return -EINVAL; - } - tok = strsep((char**)&pclone, " "); - if (tok == NULL) { - mutex_unlock(&fpga_data->fpga_lock); - return -EINVAL; - } - value = (uint32_t)strtoul(tok, &last, 16); - if (value == 0 && tok == last) { - mutex_unlock(&fpga_data->fpga_lock); - return -EINVAL; - } - tok = strsep((char**)&pclone, " "); - if (tok == NULL) { - mode = 32; - } else { - mode = (uint32_t)strtoul(tok, &last, 10); - if (mode == 0 && tok == last) { - mutex_unlock(&fpga_data->fpga_lock); - return -EINVAL; - } - } - if (mode == 32) { - iowrite32(value, fpga_dev.data_base_addr + addr); - } else if (mode == 8) { - iowrite8(value, fpga_dev.data_base_addr + addr); - } else { - mutex_unlock(&fpga_data->fpga_lock); - return -EINVAL; - } - mutex_unlock(&fpga_data->fpga_lock); - return count; -} - -/** - * Read all FPGA XCVR register in binary mode. - * @param buf Raw transceivers port startus and control register values - * @return number of bytes read, or an error code - */ -static ssize_t dump_read(struct file *filp, struct kobject *kobj, - struct bin_attribute *attr, char *buf, - loff_t off, size_t count) -{ - unsigned long i = 0; - ssize_t status; - u8 read_reg; - - if ( off + count > PORT_XCVR_REGISTER_SIZE ) { - return -EINVAL; - } - mutex_lock(&fpga_data->fpga_lock); - while (i < count) { - read_reg = ioread8(fpga_dev.data_base_addr + SFF_PORT_CTRL_BASE + off + i); - buf[i++] = read_reg; - } - status = count; - mutex_unlock(&fpga_data->fpga_lock); - return status; -} - -/** - * Show FPGA port XCVR ready status - * @param buf 1 if the functin is ready, 0 if not. - * @return number of bytes read, or an error code - */ -static ssize_t ready_show(struct device *dev, struct device_attribute *attr, char *buf) -{ - u32 data; - unsigned int REGISTER = FPGA_PORT_XCVR_READY; - - mutex_lock(&fpga_data->fpga_lock); - data = ioread32(fpga_dev.data_base_addr + REGISTER); - mutex_unlock(&fpga_data->fpga_lock); - return sprintf(buf, "%d\n", (data >> 0) & 1U); -} - -/* FPGA attributes */ -static DEVICE_ATTR( getreg, 0600, get_fpga_reg_value, set_fpga_reg_address); -static DEVICE_ATTR( scratch, 0600, get_fpga_scratch, set_fpga_scratch); -static DEVICE_ATTR( setreg, 0200, NULL , set_fpga_reg_value); -static DEVICE_ATTR_RO(ready); -static BIN_ATTR_RO( dump, PORT_XCVR_REGISTER_SIZE); - -static struct bin_attribute *fpga_bin_attrs[] = { - &bin_attr_dump, - NULL, -}; - -static struct attribute *fpga_attrs[] = { - &dev_attr_getreg.attr, - &dev_attr_scratch.attr, - &dev_attr_setreg.attr, - &dev_attr_ready.attr, - NULL, -}; - -static struct attribute_group fpga_attr_grp = { - .attrs = fpga_attrs, - .bin_attrs = fpga_bin_attrs, -}; - -/* SW CPLDs attributes */ -static ssize_t cpld1_getreg_show(struct device *dev, struct device_attribute *attr, char *buf) -{ - // CPLD register is one byte - uint8_t data; - struct i2c_client *client = fpga_data->cpld_i2c_clients[0]; - data = i2c_smbus_read_byte_data(client, fpga_data->cpld1_read_addr); - if(data < 0) - return data; - return sprintf(buf, "0x%2.2x\n", data); -} - -static ssize_t cpld1_getreg_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t size) -{ - uint8_t addr; - char *last; - addr = (uint8_t)strtoul(buf, &last, 16); - if (addr == 0 && buf == last) { - return -EINVAL; - } - fpga_data->cpld1_read_addr = addr; - return size; -} - -struct device_attribute dev_attr_cpld1_getreg = __ATTR(getreg, 0600, cpld1_getreg_show, cpld1_getreg_store); - -static ssize_t cpld1_scratch_show(struct device *dev, struct device_attribute *attr, char *buf) -{ - // CPLD register is one byte - int value; - struct i2c_client *client = fpga_data->cpld_i2c_clients[0]; - - value = i2c_smbus_read_byte_data(client, 0x01); - if(value < 0) - return value; - return sprintf(buf, "0x%.2x\n", value); -} - -static ssize_t cpld1_scratch_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t size) -{ - // CPLD register is one byte - - u8 value; - ssize_t status; - struct i2c_client *client = fpga_data->cpld_i2c_clients[0]; - - status = kstrtou8(buf, 0, &value); - if(status != 0) - return status; - status = i2c_smbus_write_byte_data(client, 0x01, value); - if(status == 0) - status = size; - return status; -} -struct device_attribute dev_attr_cpld1_scratch = __ATTR(scratch, 0600, cpld1_scratch_show, cpld1_scratch_store); - -static ssize_t cpld1_setreg_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t size) -{ - - uint8_t addr, value; - struct i2c_client *client = fpga_data->cpld_i2c_clients[0]; - char *tok; - char clone[size]; - char *pclone = clone; - char *last; - int err; - - strcpy(clone, buf); - - tok = strsep((char**)&pclone, " "); - if (tok == NULL) { - return -EINVAL; - } - addr = (uint8_t)strtoul(tok, &last, 16); - if (addr == 0 && tok == last) { - return -EINVAL; - } - tok = strsep((char**)&pclone, " "); - if (tok == NULL) { - return -EINVAL; - } - value = (uint8_t)strtoul(tok, &last, 16); - if (value == 0 && tok == last) { - return -EINVAL; - } - err = i2c_smbus_write_byte_data(client, addr, value); - if (err < 0) - return err; - - return size; -} -struct device_attribute dev_attr_cpld1_setreg = __ATTR(setreg, 0200, NULL, cpld1_setreg_store); - -static struct attribute *cpld1_attrs[] = { - &dev_attr_cpld1_getreg.attr, - &dev_attr_cpld1_scratch.attr, - &dev_attr_cpld1_setreg.attr, - NULL, -}; - -static struct attribute_group cpld1_attr_grp = { - .attrs = cpld1_attrs, -}; - -static ssize_t cpld2_getreg_show(struct device *dev, struct device_attribute *attr, char *buf) -{ - // CPLD register is one byte - uint8_t data; - struct i2c_client *client = fpga_data->cpld_i2c_clients[1]; - data = i2c_smbus_read_byte_data(client, fpga_data->cpld2_read_addr); - if(data < 0) - return data; - return sprintf(buf, "0x%2.2x\n", data); -} - -static ssize_t cpld2_getreg_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t size) -{ - // CPLD register is one byte - uint8_t addr; - char *last; - addr = (uint8_t)strtoul(buf, &last, 16); - if (addr == 0 && buf == last) { - return -EINVAL; - } - fpga_data->cpld2_read_addr = addr; - return size; -} -struct device_attribute dev_attr_cpld2_getreg = __ATTR(getreg, 0600, cpld2_getreg_show, cpld2_getreg_store); - -static ssize_t cpld2_scratch_show(struct device *dev, struct device_attribute *attr, char *buf) -{ - // CPLD register is one byte - int value; - struct i2c_client *client = fpga_data->cpld_i2c_clients[1]; - - value = i2c_smbus_read_byte_data(client, 0x01); - if(value < 0) - return value; - return sprintf(buf, "0x%.2x\n", value); -} - -static ssize_t cpld2_scratch_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t size) -{ - // CPLD register is one byte - u8 value; - ssize_t status; - struct i2c_client *client = fpga_data->cpld_i2c_clients[1]; - - status = kstrtou8(buf, 0, &value); - if(status != 0) - return status; - status = i2c_smbus_write_byte_data(client, 0x01, value); - if(status == 0) - status = size; - return status; -} -struct device_attribute dev_attr_cpld2_scratch = __ATTR(scratch, 0600, cpld2_scratch_show, cpld2_scratch_store); - -static ssize_t cpld2_setreg_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t size) -{ - uint8_t addr, value; - struct i2c_client *client = fpga_data->cpld_i2c_clients[1]; - char *tok; - char clone[size]; - char *pclone = clone; - char *last; - int err; - - strcpy(clone, buf); - - tok = strsep((char**)&pclone, " "); - if (tok == NULL) { - return -EINVAL; - } - addr = (uint8_t)strtoul(tok, &last, 16); - if (addr == 0 && tok == last) { - return -EINVAL; - } - tok = strsep((char**)&pclone, " "); - if (tok == NULL) { - return -EINVAL; - } - value = (uint8_t)strtoul(tok, &last, 16); - if (value == 0 && tok == last) { - return -EINVAL; - } - err = i2c_smbus_write_byte_data(client, addr, value); - if (err < 0) - return err; - - return size; -} -struct device_attribute dev_attr_cpld2_setreg = __ATTR(setreg, 0200, NULL, cpld2_setreg_store); - -static struct attribute *cpld2_attrs[] = { - &dev_attr_cpld2_getreg.attr, - &dev_attr_cpld2_scratch.attr, - &dev_attr_cpld2_setreg.attr, - NULL, -}; - -static struct attribute_group cpld2_attr_grp = { - .attrs = cpld2_attrs, -}; - -/* QSFP/SFP+ attributes */ -static ssize_t qsfp_modirq_show(struct device *dev, struct device_attribute *attr, char *buf) -{ - u32 data; - struct sff_device_data *dev_data = dev_get_drvdata(dev); - unsigned int portid = dev_data->portid; - unsigned int REGISTER = SFF_PORT_STATUS_BASE + (portid - 1) * 0x10; - - mutex_lock(&fpga_data->fpga_lock); - data = ioread32(fpga_dev.data_base_addr + REGISTER); - mutex_unlock(&fpga_data->fpga_lock); - return sprintf(buf, "%d\n", (data >> STAT_IRQ) & 1U); -} -DEVICE_ATTR_RO(qsfp_modirq); - -static ssize_t qsfp_modprs_show(struct device *dev, struct device_attribute *attr, char *buf) -{ - u32 data; - struct sff_device_data *dev_data = dev_get_drvdata(dev); - unsigned int portid = dev_data->portid; - unsigned int REGISTER = SFF_PORT_STATUS_BASE + (portid - 1) * 0x10; - - mutex_lock(&fpga_data->fpga_lock); - data = ioread32(fpga_dev.data_base_addr + REGISTER); - mutex_unlock(&fpga_data->fpga_lock); - return sprintf(buf, "%d\n", (data >> STAT_PRESENT) & 1U); -} -DEVICE_ATTR_RO(qsfp_modprs); - -static ssize_t sfp_txfault_show(struct device *dev, struct device_attribute *attr, char *buf) -{ - u32 data; - struct sff_device_data *dev_data = dev_get_drvdata(dev); - unsigned int portid = dev_data->portid; - unsigned int REGISTER = SFF_PORT_STATUS_BASE + (portid - 1) * 0x10; - - mutex_lock(&fpga_data->fpga_lock); - data = ioread32(fpga_dev.data_base_addr + REGISTER); - mutex_unlock(&fpga_data->fpga_lock); - return sprintf(buf, "%d\n", (data >> STAT_TXFAULT) & 1U); -} -DEVICE_ATTR_RO(sfp_txfault); - -static ssize_t sfp_rxlos_show(struct device *dev, struct device_attribute *attr, char *buf) -{ - u32 data; - struct sff_device_data *dev_data = dev_get_drvdata(dev); - unsigned int portid = dev_data->portid; - unsigned int REGISTER = SFF_PORT_STATUS_BASE + (portid - 1) * 0x10; - - mutex_lock(&fpga_data->fpga_lock); - data = ioread32(fpga_dev.data_base_addr + REGISTER); - mutex_unlock(&fpga_data->fpga_lock); - return sprintf(buf, "%d\n", (data >> STAT_RXLOS) & 1U); -} -DEVICE_ATTR_RO(sfp_rxlos); - -static ssize_t sfp_modabs_show(struct device *dev, struct device_attribute *attr, char *buf) -{ - u32 data; - struct sff_device_data *dev_data = dev_get_drvdata(dev); - unsigned int portid = dev_data->portid; - unsigned int REGISTER = SFF_PORT_STATUS_BASE + (portid - 1) * 0x10; - - mutex_lock(&fpga_data->fpga_lock); - data = ioread32(fpga_dev.data_base_addr + REGISTER); - mutex_unlock(&fpga_data->fpga_lock); - return sprintf(buf, "%d\n", (data >> STAT_MODABS) & 1U); -} -DEVICE_ATTR_RO(sfp_modabs); - -static ssize_t qsfp_lpmode_show(struct device *dev, struct device_attribute *attr, char *buf) -{ - u32 data; - struct sff_device_data *dev_data = dev_get_drvdata(dev); - unsigned int portid = dev_data->portid; - unsigned int REGISTER = SFF_PORT_CTRL_BASE + (portid - 1) * 0x10; - - mutex_lock(&fpga_data->fpga_lock); - data = ioread32(fpga_dev.data_base_addr + REGISTER); - mutex_unlock(&fpga_data->fpga_lock); - return sprintf(buf, "%d\n", (data >> CTRL_LPMOD) & 1U); -} -static ssize_t qsfp_lpmode_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t size) -{ - ssize_t status; - long value; - u32 data; - struct sff_device_data *dev_data = dev_get_drvdata(dev); - unsigned int portid = dev_data->portid; - unsigned int REGISTER = SFF_PORT_CTRL_BASE + (portid - 1) * 0x10; - - mutex_lock(&fpga_data->fpga_lock); - status = kstrtol(buf, 0, &value); - if (status == 0) { - // if value is 0, disable the lpmode - data = ioread32(fpga_dev.data_base_addr + REGISTER); - if (!value) - data = data & ~( (u32)0x1 << CTRL_LPMOD); - else - data = data | ((u32)0x1 << CTRL_LPMOD); - iowrite32(data, fpga_dev.data_base_addr + REGISTER); - status = size; - } - mutex_unlock(&fpga_data->fpga_lock); - return status; -} -DEVICE_ATTR_RW(qsfp_lpmode); - -static ssize_t qsfp_reset_show(struct device *dev, struct device_attribute *attr, char *buf) -{ - u32 data; - struct sff_device_data *dev_data = dev_get_drvdata(dev); - unsigned int portid = dev_data->portid; - unsigned int REGISTER = SFF_PORT_CTRL_BASE + (portid - 1) * 0x10; - - mutex_lock(&fpga_data->fpga_lock); - data = ioread32(fpga_dev.data_base_addr + REGISTER); - mutex_unlock(&fpga_data->fpga_lock); - return sprintf(buf, "%d\n", (data >> CTRL_RST) & 1U); -} - -static ssize_t qsfp_reset_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t size) -{ - ssize_t status; - long value; - u32 data; - struct sff_device_data *dev_data = dev_get_drvdata(dev); - unsigned int portid = dev_data->portid; - unsigned int REGISTER = SFF_PORT_CTRL_BASE + (portid - 1) * 0x10; - - mutex_lock(&fpga_data->fpga_lock); - status = kstrtol(buf, 0, &value); - if (status == 0) { - // if value is 0, reset signal is low - data = ioread32(fpga_dev.data_base_addr + REGISTER); - if (!value) - data = data & ~( (u32)0x1 << CTRL_RST); - else - data = data | ((u32)0x1 << CTRL_RST); - iowrite32(data, fpga_dev.data_base_addr + REGISTER); - status = size; - } - mutex_unlock(&fpga_data->fpga_lock); - return status; -} -DEVICE_ATTR_RW(qsfp_reset); - -static ssize_t sfp_txdisable_show(struct device *dev, struct device_attribute *attr, char *buf) -{ - u32 data; - struct sff_device_data *dev_data = dev_get_drvdata(dev); - unsigned int portid = dev_data->portid; - unsigned int REGISTER = SFF_PORT_CTRL_BASE + (portid - 1) * 0x10; - - mutex_lock(&fpga_data->fpga_lock); - data = ioread32(fpga_dev.data_base_addr + REGISTER); - mutex_unlock(&fpga_data->fpga_lock); - return sprintf(buf, "%d\n", (data >> CTRL_TXDIS) & 1U); -} -static ssize_t sfp_txdisable_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t size) -{ - ssize_t status; - long value; - u32 data; - struct sff_device_data *dev_data = dev_get_drvdata(dev); - unsigned int portid = dev_data->portid; - unsigned int REGISTER = SFF_PORT_CTRL_BASE + (portid - 1) * 0x10; - - mutex_lock(&fpga_data->fpga_lock); - status = kstrtol(buf, 0, &value); - if (status == 0) { - // check if value is 0 clear - data = ioread32(fpga_dev.data_base_addr + REGISTER); - if (!value) - data = data & ~( (u32)0x1 << CTRL_TXDIS); - else - data = data | ((u32)0x1 << CTRL_TXDIS); - iowrite32(data, fpga_dev.data_base_addr + REGISTER); - status = size; - } - mutex_unlock(&fpga_data->fpga_lock); - return status; -} -DEVICE_ATTR_RW(sfp_txdisable); - -static struct attribute *sff_attrs[] = { - &dev_attr_qsfp_modirq.attr, - &dev_attr_qsfp_modprs.attr, - &dev_attr_qsfp_lpmode.attr, - &dev_attr_qsfp_reset.attr, - &dev_attr_sfp_txfault.attr, - &dev_attr_sfp_rxlos.attr, - &dev_attr_sfp_modabs.attr, - &dev_attr_sfp_txdisable.attr, - NULL, -}; - -static struct attribute_group sff_attr_grp = { - .attrs = sff_attrs, -}; - -static const struct attribute_group *sff_attr_grps[] = { - &sff_attr_grp, - NULL -}; - - -static ssize_t port_led_mode_show(struct device *dev, struct device_attribute *attr, char *buf) -{ - // value can be "nomal", "test" - int led_mode_1, led_mode_2; - struct i2c_client *cpld1 = fpga_data->cpld_i2c_clients[0]; - struct i2c_client *cpld2 = fpga_data->cpld_i2c_clients[1]; - - led_mode_1 = i2c_smbus_read_byte_data(cpld1, 0x09); - if (led_mode_1 < 0) - return led_mode_1; - - led_mode_2 = i2c_smbus_read_byte_data(cpld2, 0x09); - if (led_mode_2 < 0) - return led_mode_2; - - return sprintf(buf, "%s %s\n", - led_mode_1 ? "test" : "normal", - led_mode_2 ? "test" : "normal"); -} -static ssize_t port_led_mode_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t size) -{ - int status; - u8 led_mode_1; - struct i2c_client *cpld1 = fpga_data->cpld_i2c_clients[0]; - struct i2c_client *cpld2 = fpga_data->cpld_i2c_clients[1]; - - if (sysfs_streq(buf, "test")) { - led_mode_1 = 0x01; - } else if (sysfs_streq(buf, "normal")) { - led_mode_1 = 0x00; - } else { - return -EINVAL; - } - - status = i2c_smbus_write_byte_data(cpld1, 0x09, led_mode_1); - if ( status < 0 ) - return status; - - status = i2c_smbus_write_byte_data(cpld2, 0x09, led_mode_1); - if ( status < 0 ) - return status; - - return size; -} -DEVICE_ATTR_RW(port_led_mode); - -// Only work when port_led_mode set to 1 -static ssize_t port_led_color_show(struct device *dev, struct device_attribute *attr, char *buf) -{ - // value can be R/G/B/C/M/Y/W/OFF - int led_color1, led_color2; - - struct i2c_client *cpld1 = fpga_data->cpld_i2c_clients[0]; - struct i2c_client *cpld2 = fpga_data->cpld_i2c_clients[1]; - - led_color1 = i2c_smbus_read_byte_data(cpld1, 0x0A); - if (led_color1 < 0) - return led_color1; - - led_color2 = i2c_smbus_read_byte_data(cpld2, 0x0A); - if (led_color2 < 0) - return led_color2; - - return sprintf(buf, "%s %s\n", - led_color1 == 0x07 ? "off" : led_color1 == 0x06 ? "green" : led_color1 == 0x05 ? "red" : led_color1 == 0x04 ? - "yellow" : led_color1 == 0x03 ? "blue" : led_color1 == 0x02 ? "cyan" : led_color1 == 0x01 ? "magenta" : "white", - led_color2 == 0x07 ? "off" : led_color2 == 0x06 ? "green" : led_color2 == 0x05 ? "red" : led_color2 == 0x04 ? - "yellow" : led_color2 == 0x03 ? "blue" : led_color2 == 0x02 ? "cyan" : led_color2 == 0x01 ? "magenta" : "white"); -} - -static ssize_t port_led_color_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t size) -{ - ssize_t status; - u8 led_color; - - struct i2c_client *cpld1 = fpga_data->cpld_i2c_clients[0]; - struct i2c_client *cpld2 = fpga_data->cpld_i2c_clients[1]; - - if (sysfs_streq(buf, "off")) { - led_color = 0x07; - } else if (sysfs_streq(buf, "green")) { - led_color = 0x06; - } else if (sysfs_streq(buf, "red")) { - led_color = 0x05; - } else if (sysfs_streq(buf, "yellow")) { - led_color = 0x04; - } else if (sysfs_streq(buf, "blue")) { - led_color = 0x03; - } else if (sysfs_streq(buf, "cyan")) { - led_color = 0x02; - } else if (sysfs_streq(buf, "magenta")) { - led_color = 0x01; - } else if (sysfs_streq(buf, "white")) { - led_color = 0x00; - } else { - status = -EINVAL; - return status; - } - - status = i2c_smbus_write_byte_data(cpld1, 0x0A, led_color); - if (status < 0) - return status; - - status = i2c_smbus_write_byte_data(cpld2, 0x0A, led_color); - if (status < 0) - return status; - - return size; -} -DEVICE_ATTR_RW(port_led_color); - -static struct attribute *sff_led_test[] = { - &dev_attr_port_led_mode.attr, - &dev_attr_port_led_color.attr, - NULL, -}; - -static struct attribute_group sff_led_test_grp = { - .attrs = sff_led_test, -}; - -static struct device * silverstone_sff_init(int portid) { - struct sff_device_data *new_data; - struct device *new_device; - - new_data = kzalloc(sizeof(*new_data), GFP_KERNEL); - if (!new_data) { - printk(KERN_ALERT "Cannot alloc sff device data @port%d", portid); - return NULL; - } - /* The QSFP port ID start from 1 */ - new_data->portid = portid + 1; - new_data->port_type = fpga_i2c_bus_dev[portid].port_type; - new_device = device_create_with_groups(fpgafwclass, - sff_dev, - MKDEV(0, 0), - new_data, - sff_attr_grps, - "%s", - fpga_i2c_bus_dev[portid].calling_name); - if (IS_ERR(new_device)) { - printk(KERN_ALERT "Cannot create sff device @port%d", portid); - kfree(new_data); - return NULL; - } - return new_device; -} - - -static void silverstone_dev_release( struct device * dev) -{ - return; -} - -static struct platform_device silverstone_dev = { - .name = DRIVER_NAME, - .id = -1, - .num_resources = 0, - .dev = { - .release = silverstone_dev_release, - } -}; - -static int silverstone_drv_probe(struct platform_device *pdev) -{ - int ret = 0; - int portid_count; - struct i2c_adapter *cpld_bus_adap; - struct i2c_client *cpld1_client; - struct i2c_client *cpld2_client; - - struct pci_dev *pci_dev = pci_get_device(PCI_VENDOR_ID_XILINX, - FPGA_PCI_DEVICE_ID, - NULL); - if (pci_dev){ - fpga_pci_probe(pci_dev); - pci_dev_put(pci_dev); - } else { - ret = -ENODEV; - goto err_exit; - } - - fpga_data = devm_kzalloc(&pdev->dev, sizeof(struct silverstone_fpga_data), - GFP_KERNEL); - - if (!fpga_data){ - ret = -ENOMEM; - goto err_exit; - } - - /* The device class need to be instantiated before this function called */ - BUG_ON(fpgafwclass == NULL); - - cpld_bus_adap = i2c_get_adapter(SWITCH_CPLD_ADAP_NUM); - if (!cpld_bus_adap){ - dev_err(&pdev->dev, "cannot get switch board I2C adapter i2c-%d\n", - SWITCH_CPLD_ADAP_NUM); - ret = PTR_ERR(cpld_bus_adap); - goto err_exit; - } - cpld1_client = i2c_new_dummy(cpld_bus_adap, CPLD1_SLAVE_ADDR); - i2c_put_adapter(cpld_bus_adap); - if (!cpld1_client){ - dev_err(&pdev->dev, "cannot create i2c dummy device of CPLD1\n"); - ret = -ENODEV; - goto err_exit; - } - - cpld2_client = i2c_new_dummy(cpld1_client->adapter, CPLD2_SLAVE_ADDR); - if (!cpld2_client){ - dev_err(&pdev->dev, "cannot create i2c dummy device of CPLD2\n"); - ret = ENODEV; - goto err_free_cli_clpd1; - } - - fpga = kobject_create_and_add("FPGA", &pdev->dev.kobj); - if (!fpga) { - ret = -ENOMEM; - goto err_free_cli_clpd2; - } - - ret = sysfs_create_group(fpga, &fpga_attr_grp); - if (ret != 0) { - printk(KERN_ERR "Cannot create FPGA sysfs attributes\n"); - goto err_remove_fpga; - } - - cpld1 = kobject_create_and_add("CPLD1", &pdev->dev.kobj); - if (!cpld1) { - ret = -ENOMEM; - goto err_remove_grp_fpga; - } - ret = sysfs_create_group(cpld1, &cpld1_attr_grp); - if (ret != 0) { - printk(KERN_ERR "Cannot create CPLD1 sysfs attributes\n"); - goto err_remove_cpld1; - } - - cpld2 = kobject_create_and_add("CPLD2", &pdev->dev.kobj); - if (!cpld2) { - ret = -ENOMEM; - goto err_remove_grp_cpld1; - } - ret = sysfs_create_group(cpld2, &cpld2_attr_grp); - if (ret != 0) { - printk(KERN_ERR "Cannot create CPLD2 sysfs attributes\n"); - goto err_remove_cpld2; - } - - sff_dev = device_create(fpgafwclass, NULL, MKDEV(0, 0), NULL, "sff_device"); - if (IS_ERR(sff_dev)) { - ret = PTR_ERR(sff_dev); - goto err_remove_grp_cpld2; - } - - ret = sysfs_create_group(&sff_dev->kobj, &sff_led_test_grp); - if (ret != 0) { - goto err_remove_sff; - } - - ret = sysfs_create_link(&pdev->dev.kobj, &sff_dev->kobj, "SFF"); - if (ret != 0) { - goto err_remove_grp_sff; - } - - /* Init SFF devices */ - for (portid_count = 0; portid_count < SFF_PORT_TOTAL; portid_count++) { - fpga_data->sff_devices[portid_count] = silverstone_sff_init(portid_count); - } - - // Set default read address to VERSION - fpga_data->fpga_read_addr = fpga_dev.data_base_addr + FPGA_VERSION; - fpga_data->cpld1_read_addr = 0x00; - fpga_data->cpld2_read_addr = 0x00; - fpga_data->cpld_i2c_clients[0] = cpld1_client; - fpga_data->cpld_i2c_clients[1] = cpld2_client; - mutex_init(&fpga_data->fpga_lock); - -return 0; - -err_remove_grp_sff: - sysfs_remove_group(&sff_dev->kobj, &sff_led_test_grp); -err_remove_sff: - device_destroy(fpgafwclass, MKDEV(0, 0)); -err_remove_grp_cpld2: - sysfs_remove_group(cpld2, &cpld2_attr_grp); -err_remove_cpld2: - kobject_put(cpld2); -err_remove_grp_cpld1: - sysfs_remove_group(cpld1, &cpld1_attr_grp); -err_remove_cpld1: - kobject_put(cpld1); -err_remove_grp_fpga: - sysfs_remove_group(fpga, &fpga_attr_grp); -err_remove_fpga: - kobject_put(fpga); -err_free_cli_clpd2: - i2c_unregister_device(cpld2_client); -err_free_cli_clpd1: - i2c_unregister_device(cpld1_client); -err_exit: - return ret; - -} - -static int silverstone_drv_remove(struct platform_device *pdev) -{ - int portid_count; - struct sff_device_data *rem_data; - struct i2c_client *rem_cli; - - rem_cli = fpga_data->cpld_i2c_clients[0]; - if(rem_cli) - i2c_unregister_device(rem_cli); - - rem_cli = fpga_data->cpld_i2c_clients[1]; - if(rem_cli) - i2c_unregister_device(rem_cli); - - for (portid_count = 0; portid_count < SFF_PORT_TOTAL; portid_count++) { - if (fpga_data->sff_devices[portid_count] != NULL) { - rem_data = dev_get_drvdata(fpga_data->sff_devices[portid_count]); - device_unregister(fpga_data->sff_devices[portid_count]); - put_device(fpga_data->sff_devices[portid_count]); - kfree(rem_data); - } - } - - sysfs_remove_group(fpga, &fpga_attr_grp); - sysfs_remove_group(cpld1, &cpld1_attr_grp); - sysfs_remove_group(cpld2, &cpld2_attr_grp); - sysfs_remove_group(&sff_dev->kobj, &sff_led_test_grp); - kobject_put(fpga); - kobject_put(cpld1); - kobject_put(cpld2); - device_destroy(fpgafwclass, MKDEV(0, 0)); - fpga_pci_remove(); - return 0; -} - -/* move this on top of platform_probe() */ -static int fpga_pci_probe(struct pci_dev *pdev) -{ - int err; - struct device *dev = &pdev->dev; - uint32_t fpga_version; - - /* Skip the reqions request and mmap the resource */ - /* bar0: data mmio region */ - fpga_dev.data_mmio_start = pci_resource_start(pdev, FPGA_PCI_BAR_NUM); - fpga_dev.data_mmio_len = pci_resource_len(pdev, FPGA_PCI_BAR_NUM); - fpga_dev.data_base_addr = ioremap_nocache(fpga_dev.data_mmio_start, - fpga_dev.data_mmio_len); - if (!fpga_dev.data_base_addr) { - dev_err(dev, "cannot iomap region of size %lu\n", - (unsigned long)fpga_dev.data_mmio_len); - err = PTR_ERR(fpga_dev.data_base_addr); - goto err_exit; - } - dev_info(dev, "data_mmio iomap base = 0x%lx \n", - (unsigned long)fpga_dev.data_base_addr); - dev_info(dev, "data_mmio_start = 0x%lx data_mmio_len = %lu\n", - (unsigned long)fpga_dev.data_mmio_start, - (unsigned long)fpga_dev.data_mmio_len); - - printk(KERN_INFO "FPGA PCIe driver probe OK.\n"); - printk(KERN_INFO "FPGA ioremap registers of size %lu\n", - (unsigned long)fpga_dev.data_mmio_len); - printk(KERN_INFO "FPGA Virtual BAR %d at %8.8lx - %8.8lx\n", - FPGA_PCI_BAR_NUM, - (unsigned long)fpga_dev.data_base_addr, - (unsigned long)(fpga_dev.data_base_addr + fpga_dev.data_mmio_len)); - printk(KERN_INFO ""); - fpga_version = ioread32(fpga_dev.data_base_addr); - printk(KERN_INFO "FPGA VERSION : %8.8x\n", fpga_version); - - fpgafwclass = class_create(THIS_MODULE, CLASS_NAME); - if (IS_ERR(fpgafwclass)) { - printk(KERN_ALERT "Failed to register device class\n"); - err = PTR_ERR(fpgafwclass); - goto mem_unmap; - } - return 0; - -mem_unmap: - iounmap(fpga_dev.data_base_addr); -err_exit: - return err; -} - -static void fpga_pci_remove(void) -{ - iounmap(fpga_dev.data_base_addr); - class_unregister(fpgafwclass); - class_destroy(fpgafwclass); -}; - - -static struct platform_driver silverstone_drv = { - .probe = silverstone_drv_probe, - .remove = __exit_p(silverstone_drv_remove), - .driver = { - .name = DRIVER_NAME, - }, -}; - -int silverstone_init(void) -{ - platform_device_register(&silverstone_dev); - platform_driver_register(&silverstone_drv); - return 0; -} - -void silverstone_exit(void) -{ - platform_driver_unregister(&silverstone_drv); - platform_device_unregister(&silverstone_dev); -} - -module_init(silverstone_init); -module_exit(silverstone_exit); - -MODULE_AUTHOR("Celestica Inc."); -MODULE_DESCRIPTION("Silverstone Sysfs Nodes for Diagnostic Tool"); -MODULE_VERSION(MOD_VERSION); -MODULE_LICENSE("GPL"); \ No newline at end of file diff --git a/packages/platforms/celestica/x86-64/silverstone/modules/builds/src/xcvr-cls.c b/packages/platforms/celestica/x86-64/silverstone/modules/builds/src/xcvr-cls.c deleted file mode 100644 index bc0da613e..000000000 --- a/packages/platforms/celestica/x86-64/silverstone/modules/builds/src/xcvr-cls.c +++ /dev/null @@ -1,520 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0+ -/* - * xcvr-cls.c - front panel port control. - * - * Pradchaya Phucharoen - * Copyright (C) 2019 Celestica Corp. - */ - -#include -#include -#include -#include -#include -#include -#include -#include "xcvr-cls.h" - -/* FPGA front panel */ -#define PORT_CTRL 0 -#define PORT_STATUS 0x4 -#define PORT_INT_STATUS 0x8 -#define PORT_INT_MASK 0xC - -/* - * Port control degister - * LPMOD : active high, RW - * RST : active low, RW - * TXDIS : active high, RW -*/ -#define CTRL_LPMOD BIT(6) -#define CTRL_RST_L BIT(4) -#define CTRL_TXDIS BIT(0) - -/* - * Port status register - * IRQ : active low, RO - * PRESENT : active low, RO, for QSFP - * TXFAULT : active high, RO - * RXLOS : active high, RO - * MODABS : active high, RO, for SFP -*/ -#define STAT_IRQ_L BIT(5) -#define STAT_PRESENT_L BIT(4) -#define STAT_TXFAULT BIT(2) -#define STAT_RXLOS BIT(1) -#define STAT_MODABS BIT(0) - -/* - * NOTE: Interrupt and mask must be expose as bitfeild. - * Because the registers of interrupt flags are read-clear. - * - * Port interrupt flag resgister - * INT_N : interrupt flag, set when INT_N is assert. - * PRESENT : interrupt flag, set when QSFP module plugin/plugout. - * RXLOS : interrupt flag, set when rxlos is assert. - * MODABS : interrupt flag, set when SFP module plugin/plugout. -*/ -#define INTR_INT_N BIT(5) -#define INTR_PRESENT BIT(4) -#define INTR_TXFAULT BIT(2) -#define INTR_RXLOS BIT(1) -#define INTR_MODABS BIT(0) - -/* - * Port interrupt mask register - * INT_N : active low - * PRESENT : active low - * RXLOS_INT : active low - * MODABS : active low -*/ -#define MASK_INT_N_L BIT(5) -#define MASK_PRESENT_L BIT(4) -#define MASK_TXFAULT_L BIT(2) -#define MASK_RXLOS_L BIT(1) -#define MASK_MODABS_L BIT(0) - - -/* - * port_data - optical port data - * @xcvr: xcvr memory accessor - * @name: port name - * @index: front panel port index starting from 1 - */ -struct port_data { - struct xcvr_priv *xcvr; - const char *name; - unsigned int index; -}; - -/* - * xcvr_priv - port xcvr private data - * @dev: device for reference - * @base: virtual base address - * @num_ports: number of front panel ports - * @fp_devs: list of front panel port devices - */ -struct xcvr_priv { - struct device* dev; - void __iomem *base; - int port_reg_size; - int num_ports; - struct device **fp_devs; -}; - -static inline void port_setreg(struct xcvr_priv *xcvr, int reg, int index, u8 value) -{ - return iowrite8(value, xcvr->base + reg + (index - 1) * xcvr->port_reg_size); -} - -static inline u8 port_getreg(struct xcvr_priv *xcvr, int reg, int index) -{ - return ioread8(xcvr->base + reg + (index - 1) * xcvr->port_reg_size); -} - -static ssize_t qsfp_modprsL_show(struct device *dev, - struct device_attribute *attr, char *buf) -{ - u8 data; - struct port_data *port_data = dev_get_drvdata(dev); - unsigned int index = port_data->index; - - data = port_getreg(port_data->xcvr, PORT_STATUS, index); - return sprintf(buf, "%d\n", (data & STAT_PRESENT_L)?1:0); -} - -static ssize_t qsfp_irqL_show(struct device *dev, - struct device_attribute *attr, char *buf) -{ - u8 data; - struct port_data *port_data = dev_get_drvdata(dev); - unsigned int index = port_data->index; - - data = port_getreg(port_data->xcvr, PORT_STATUS, index); - return sprintf(buf, "%d\n", (data & STAT_IRQ_L)?1:0); -} - -static ssize_t qsfp_lpmode_show(struct device *dev, - struct device_attribute *attr, char *buf) -{ - u8 data; - struct port_data *port_data = dev_get_drvdata(dev); - unsigned int index = port_data->index; - - data = port_getreg(port_data->xcvr, PORT_CTRL, index); - return sprintf(buf, "%d\n", (data & CTRL_LPMOD)?1:0); -} - -static ssize_t qsfp_lpmode_store(struct device *dev, - struct device_attribute *attr, - const char *buf, size_t size) -{ - ssize_t status; - long value; - u8 data; - struct port_data *port_data = dev_get_drvdata(dev); - unsigned int index = port_data->index; - - status = kstrtol(buf, 0, &value); - if (status == 0) { - data = port_getreg(port_data->xcvr, PORT_CTRL, index); - if (value == 0) - data &= ~CTRL_LPMOD; - else - data |= CTRL_LPMOD; - port_setreg(port_data->xcvr, PORT_CTRL, index, data); - status = size; - } - return status; -} - -static ssize_t qsfp_resetL_show(struct device *dev, - struct device_attribute *attr, char *buf) -{ - u8 data; - struct port_data *port_data = dev_get_drvdata(dev); - unsigned int index = port_data->index; - - data = port_getreg(port_data->xcvr, PORT_CTRL, index); - return sprintf(buf, "%d\n", (data & CTRL_RST_L)?1:0); -} - -static ssize_t qsfp_resetL_store(struct device *dev, - struct device_attribute *attr, - const char *buf, size_t size) -{ - ssize_t status; - long value; - u8 data; - struct port_data *port_data = dev_get_drvdata(dev); - unsigned int index = port_data->index; - - status = kstrtol(buf, 0, &value); - if (status == 0) { - data = port_getreg(port_data->xcvr, PORT_CTRL, index); - if (value == 0) - data &= ~CTRL_RST_L; - else - data |= CTRL_RST_L; - port_setreg(port_data->xcvr, PORT_CTRL, index, data); - status = size; - } - return status; -} - -static ssize_t sfp_modabs_show(struct device *dev, - struct device_attribute *attr, char *buf) -{ - u8 data; - struct port_data *port_data = dev_get_drvdata(dev); - unsigned int index = port_data->index; - - data = port_getreg(port_data->xcvr, PORT_STATUS, index); - return sprintf(buf, "%d\n", (data & STAT_MODABS)?1:0); -} - -static ssize_t sfp_txfault_show(struct device *dev, - struct device_attribute *attr, char *buf) -{ - u8 data; - struct port_data *port_data = dev_get_drvdata(dev); - unsigned int index = port_data->index; - - data = port_getreg(port_data->xcvr, PORT_STATUS, index); - return sprintf(buf, "%d\n", (data & STAT_TXFAULT)?1:0); -} - -static ssize_t sfp_rxlos_show(struct device *dev, - struct device_attribute *attr, char *buf) -{ - u8 data; - struct port_data *port_data = dev_get_drvdata(dev); - unsigned int index = port_data->index; - - data = port_getreg(port_data->xcvr, PORT_STATUS, index); - return sprintf(buf, "%d\n", (data & STAT_RXLOS)?1:0); -} - -static ssize_t sfp_txdisable_show(struct device *dev, - struct device_attribute *attr, char *buf) -{ - u8 data; - struct port_data *port_data = dev_get_drvdata(dev); - unsigned int index = port_data->index; - - data = port_getreg(port_data->xcvr, PORT_CTRL, index); - return sprintf(buf, "%d\n", (data & CTRL_TXDIS)?1:0); -} - -static ssize_t sfp_txdisable_store(struct device *dev, - struct device_attribute *attr, - const char *buf, size_t size) -{ - ssize_t status; - long value; - u8 data; - struct port_data *port_data = dev_get_drvdata(dev); - unsigned int index = port_data->index; - - status = kstrtol(buf, 0, &value); - if (status == 0) { - data = port_getreg(port_data->xcvr, PORT_CTRL, index); - if (value == 0) - data &= ~CTRL_TXDIS; - else - data |= CTRL_TXDIS; - port_setreg(port_data->xcvr, PORT_CTRL, index, data); - status = size; - } - return status; -} - -static ssize_t interrupt_show(struct device *dev, - struct device_attribute *attr, char *buf) -{ - u8 data; - struct port_data *port_data = dev_get_drvdata(dev); - unsigned int index = port_data->index; - - data = port_getreg(port_data->xcvr, PORT_INT_STATUS, index); - return sprintf(buf, "0x%2.2x\n", data); -} - -static ssize_t interrupt_store(struct device *dev, - struct device_attribute *attr, - const char *buf, size_t size) -{ - ssize_t status; - long value; - struct port_data *port_data = dev_get_drvdata(dev); - unsigned int index = port_data->index; - - status = kstrtoul(buf, 0, &value); - if (status == 0) { - port_setreg(port_data->xcvr, PORT_INT_STATUS, index, value); - status = size; - } - return status; -} - -static ssize_t interrupt_mask_show(struct device *dev, - struct device_attribute *attr, char *buf) -{ - u8 data; - struct port_data *port_data = dev_get_drvdata(dev); - unsigned int index = port_data->index; - - data = port_getreg(port_data->xcvr, PORT_INT_MASK, index); - return sprintf(buf, "0x%2.2x\n", data); -} - -static ssize_t interrupt_mask_store(struct device *dev, - struct device_attribute *attr, - const char *buf, size_t size) -{ - ssize_t status; - long value; - struct port_data *port_data = dev_get_drvdata(dev); - unsigned int index = port_data->index; - - status = kstrtoul(buf, 0, &value); - if (status == 0) { - port_setreg(port_data->xcvr, PORT_INT_MASK, index, value); - status = size; - } - return status; -} - -DEVICE_ATTR_RO(qsfp_modprsL); -DEVICE_ATTR_RO(qsfp_irqL); -DEVICE_ATTR_RW(qsfp_lpmode); -DEVICE_ATTR_RW(qsfp_resetL); - -DEVICE_ATTR_RO(sfp_modabs); -DEVICE_ATTR_RO(sfp_txfault); -DEVICE_ATTR_RO(sfp_rxlos); -DEVICE_ATTR_RW(sfp_txdisable); - -DEVICE_ATTR_RW(interrupt); -DEVICE_ATTR_RW(interrupt_mask); - -/* qsfp_attrs */ -static struct attribute *qsfp_attrs[] = { - &dev_attr_qsfp_modprsL.attr, - &dev_attr_qsfp_lpmode.attr, - &dev_attr_qsfp_resetL.attr, - &dev_attr_interrupt.attr, - &dev_attr_interrupt_mask.attr, - NULL -}; - -/* sfp_attrs */ -static struct attribute *sfp_attrs[] = { - &dev_attr_sfp_modabs.attr, - &dev_attr_sfp_txfault.attr, - &dev_attr_sfp_rxlos.attr, - &dev_attr_sfp_txdisable.attr, - &dev_attr_interrupt.attr, - &dev_attr_interrupt_mask.attr, - NULL -}; - -ATTRIBUTE_GROUPS(qsfp); -ATTRIBUTE_GROUPS(sfp); - -/* A single port device init */ -static struct device* init_port(struct device *dev, - struct xcvr_priv *xcvr, - struct port_info info, - const struct attribute_group **groups) -{ - struct port_data *new_data; - - new_data = devm_kzalloc(dev, sizeof(struct port_data), GFP_KERNEL); - if (!new_data) - return ERR_PTR(-ENOMEM); - - new_data->index = info.index; - new_data->name = info.name; - new_data->xcvr = xcvr; - - return devm_hwmon_device_register_with_groups(dev, - info.name, - new_data, - groups); -} - -static void xcvr_cleanup(struct xcvr_priv *xcvr) -{ - struct device *dev; - struct port_data *data; - int i; - - for (i = 0; i < xcvr->num_ports; i++){ - dev = xcvr->fp_devs[i]; - if (dev == NULL) - continue; - data = dev_get_drvdata(dev); - sysfs_remove_link(&xcvr->dev->kobj, data->name); - } -} - -static int cls_xcvr_probe(struct platform_device *pdev) -{ - - struct xcvr_priv *xcvr; - struct cls_xcvr_platform_data *pdata; - struct resource *res; - int ret; - int i; - - struct device **port_devs; - - xcvr = devm_kzalloc(&pdev->dev, sizeof(struct xcvr_priv), GFP_KERNEL); - if (!xcvr){ - ret = -ENOMEM; - goto err_exit; - } - - dev_set_drvdata(&pdev->dev, xcvr); - - /* mmap resource */ - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); - if (res) { - xcvr->base = devm_ioremap_resource(&pdev->dev, res); - if (IS_ERR(xcvr->base)){ - ret = PTR_ERR(xcvr->base); - goto err_exit; - } - } - - pdata = dev_get_platdata(&pdev->dev); - xcvr->dev = &pdev->dev; - - if (pdata) { - /* assign pdata */ - xcvr->num_ports = pdata->num_ports; - xcvr->port_reg_size = pdata->port_reg_size; - } - - /* alloc front panel device list */ - port_devs = devm_kzalloc(&pdev->dev, - xcvr->num_ports * sizeof(struct device*), - GFP_KERNEL); - if (!port_devs){ - ret = -ENOMEM; - goto err_exit; - } - - - if (pdata) { - /* create each device attrs group determined by type */ - for (i = 0; i < pdata->num_ports; i++) { - struct device *fp_dev; - - if (pdata->devices[i].type == SFP){ - fp_dev = init_port(&pdev->dev, - xcvr, - pdata->devices[i], - sfp_groups); - }else{ - fp_dev = init_port(&pdev->dev, - xcvr, - pdata->devices[i], - qsfp_groups); - } - if (IS_ERR(fp_dev)) { - dev_err(&pdev->dev, - "Failed to init port %s\n", - pdata->devices[i].name); - ret = PTR_ERR(fp_dev); - goto dev_clean_up; - } - - dev_info(&pdev->dev, - "Register port %s\n", - pdata->devices[i].name); - - WARN(sysfs_create_link(&pdev->dev.kobj, - &fp_dev->kobj, - pdata->devices[i].name), - "can't create symlink to %s\n", pdata->devices[i].name); - port_devs[i] = fp_dev; - fp_dev = NULL; - } - xcvr->fp_devs = port_devs; - } - - return 0; - -dev_clean_up: - xcvr_cleanup(xcvr); -err_exit: - return ret; - -} - - -static int cls_xcvr_remove(struct platform_device *pdev) -{ - struct xcvr_priv *xcvr = dev_get_drvdata(&pdev->dev); - xcvr_cleanup(xcvr); - return 0; -} - - -static struct platform_driver cls_xcvr_driver = { - .probe = cls_xcvr_probe, - .remove = cls_xcvr_remove, - .driver = { - .name = "cls-xcvr", - }, -}; - -module_platform_driver(cls_xcvr_driver); - -MODULE_AUTHOR("Pradchaya Phucharoen"); -MODULE_DESCRIPTION("Celestica xcvr control driver"); -MODULE_VERSION("0.0.1-3"); -MODULE_LICENSE("GPL"); -MODULE_ALIAS("platform:cls-xcvr"); \ No newline at end of file diff --git a/packages/platforms/celestica/x86-64/silverstone/modules/builds/src/xcvr-cls.h b/packages/platforms/celestica/x86-64/silverstone/modules/builds/src/xcvr-cls.h deleted file mode 100644 index 7659a7c0e..000000000 --- a/packages/platforms/celestica/x86-64/silverstone/modules/builds/src/xcvr-cls.h +++ /dev/null @@ -1,41 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0+ -/* - * xcvr-cls.h - * - * Pradchaya Phucharoen - * Copyright (C) 2019 Celestica Corp. - */ - -#ifndef _LINUX_I2C_CLS_H -#define _LINUX_I2C_CLS_H - -enum PORT_TYPE { - NONE = 0, - SFP, - QSFP -}; - -/* - * port_info - optical port info - * @index: front panel port index starting from 1 - * @typr: port type, see *PORT_TYPE* - */ -struct port_info { - const char *name; - unsigned int index; - enum PORT_TYPE type; -}; - -/* - * cls_xcvr_platform_data - port xcvr private data - * @port_reg_size: register range of each port - * @num_ports: number of front panel ports - * @devices: list of front panel port info - */ -struct cls_xcvr_platform_data { - unsigned int port_reg_size; - int num_ports; - struct port_info *devices; -}; - -#endif /* _LINUX_I2C_CLS_H */ \ No newline at end of file diff --git a/packages/platforms/celestica/x86-64/silverstone/onlp/Makefile b/packages/platforms/celestica/x86-64/silverstone/onlp/Makefile deleted file mode 100644 index 003238cf6..000000000 --- a/packages/platforms/celestica/x86-64/silverstone/onlp/Makefile +++ /dev/null @@ -1 +0,0 @@ -include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/celestica/x86-64/silverstone/onlp/PKG.yml b/packages/platforms/celestica/x86-64/silverstone/onlp/PKG.yml deleted file mode 100644 index c3c19e67b..000000000 --- a/packages/platforms/celestica/x86-64/silverstone/onlp/PKG.yml +++ /dev/null @@ -1 +0,0 @@ -!include $ONL_TEMPLATES/onlp-platform-any.yml PLATFORM=x86-64-cel-silverstone ARCH=amd64 TOOLCHAIN=x86_64-linux-gnu \ No newline at end of file diff --git a/packages/platforms/celestica/x86-64/silverstone/onlp/builds/Makefile b/packages/platforms/celestica/x86-64/silverstone/onlp/builds/Makefile deleted file mode 100644 index 5d5b5169a..000000000 --- a/packages/platforms/celestica/x86-64/silverstone/onlp/builds/Makefile +++ /dev/null @@ -1,2 +0,0 @@ -FILTER=src -include $(ONL)/make/subdirs.mk diff --git a/packages/platforms/celestica/x86-64/silverstone/onlp/builds/lib/Makefile b/packages/platforms/celestica/x86-64/silverstone/onlp/builds/lib/Makefile deleted file mode 100644 index 435a13a58..000000000 --- a/packages/platforms/celestica/x86-64/silverstone/onlp/builds/lib/Makefile +++ /dev/null @@ -1,2 +0,0 @@ -PLATFORM := x86-64-cel-silverstone -include $(ONL)/packages/base/any/onlp/builds/platform/libonlp-platform.mk \ No newline at end of file diff --git a/packages/platforms/celestica/x86-64/silverstone/onlp/builds/onlpdump/Makefile b/packages/platforms/celestica/x86-64/silverstone/onlp/builds/onlpdump/Makefile deleted file mode 100644 index 9f72eaf5b..000000000 --- a/packages/platforms/celestica/x86-64/silverstone/onlp/builds/onlpdump/Makefile +++ /dev/null @@ -1,2 +0,0 @@ -PLATFORM := x86-64-cel-silverstone -include $(ONL)/packages/base/any/onlp/builds/platform/onlps.mk diff --git a/packages/platforms/celestica/x86-64/silverstone/onlp/builds/x86_64_cel_silverstone/.module b/packages/platforms/celestica/x86-64/silverstone/onlp/builds/x86_64_cel_silverstone/.module deleted file mode 100644 index f1f39b764..000000000 --- a/packages/platforms/celestica/x86-64/silverstone/onlp/builds/x86_64_cel_silverstone/.module +++ /dev/null @@ -1 +0,0 @@ -name: x86_64_cel_silverstone diff --git a/packages/platforms/celestica/x86-64/silverstone/onlp/builds/x86_64_cel_silverstone/Makefile b/packages/platforms/celestica/x86-64/silverstone/onlp/builds/x86_64_cel_silverstone/Makefile deleted file mode 100644 index 99f2e208c..000000000 --- a/packages/platforms/celestica/x86-64/silverstone/onlp/builds/x86_64_cel_silverstone/Makefile +++ /dev/null @@ -1,9 +0,0 @@ -############################################################################### -# -# -# -############################################################################### -include $(ONL)/make/config.mk -MODULE := x86_64_cel_silverstone -AUTOMODULE := x86_64_cel_silverstone -include $(BUILDER)/definemodule.mk diff --git a/packages/platforms/celestica/x86-64/silverstone/onlp/builds/x86_64_cel_silverstone/module/auto/make.mk b/packages/platforms/celestica/x86-64/silverstone/onlp/builds/x86_64_cel_silverstone/module/auto/make.mk deleted file mode 100644 index 37a53cf33..000000000 --- a/packages/platforms/celestica/x86-64/silverstone/onlp/builds/x86_64_cel_silverstone/module/auto/make.mk +++ /dev/null @@ -1,9 +0,0 @@ -############################################################################### -# -# x86_64_cel_silverstone Autogeneration -# -############################################################################### -x86_64_cel_silverstone_AUTO_DEFS := module/auto/x86_64_cel_silverstone.yml -x86_64_cel_silverstone_AUTO_DIRS := module/inc/x86_64_cel_silverstone module/src -include $(BUILDER)/auto.mk - diff --git a/packages/platforms/celestica/x86-64/silverstone/onlp/builds/x86_64_cel_silverstone/module/auto/x86_64_cel_silverstone.yml b/packages/platforms/celestica/x86-64/silverstone/onlp/builds/x86_64_cel_silverstone/module/auto/x86_64_cel_silverstone.yml deleted file mode 100644 index e35322fae..000000000 --- a/packages/platforms/celestica/x86-64/silverstone/onlp/builds/x86_64_cel_silverstone/module/auto/x86_64_cel_silverstone.yml +++ /dev/null @@ -1,47 +0,0 @@ -############################################################################### -# -# x86_64_cel_silverstone Autogeneration Definitions. -# -############################################################################### - -cdefs: &cdefs -- X86_64_CEL_SILVERSTONE_CONFIG_INCLUDE_LOGGING: - doc: "Include or exclude logging." - default: 1 -- X86_64_CEL_SILVERSTONE_CONFIG_LOG_OPTIONS_DEFAULT: - doc: "Default enabled log options." - default: AIM_LOG_OPTIONS_DEFAULT -- X86_64_CEL_SILVERSTONE_CONFIG_LOG_BITS_DEFAULT: - doc: "Default enabled log bits." - default: AIM_LOG_BITS_DEFAULT -- X86_64_CEL_SILVERSTONE_CONFIG_LOG_CUSTOM_BITS_DEFAULT: - doc: "Default enabled custom log bits." - default: 0 -- X86_64_CEL_SILVERSTONE_CONFIG_PORTING_STDLIB: - doc: "Default all porting macros to use the C standard libraries." - default: 1 -- X86_64_CEL_SILVERSTONE_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS: - doc: "Include standard library headers for stdlib porting macros." - default: X86_64_CEL_SILVERSTONE_CONFIG_PORTING_STDLIB -- X86_64_CEL_SILVERSTONE_CONFIG_INCLUDE_UCLI: - doc: "Include generic uCli support." - default: 0 - - -definitions: - cdefs: - X86_64_CEL_SILVERSTONE_CONFIG_HEADER: - defs: *cdefs - basename: x86_64_cel_silverstone_config - - portingmacro: - X86_64_CEL_SILVERSTONE: - macros: - - malloc - - free - - memset - - memcpy - - strncpy - - vsnprintf - - snprintf - - strlen \ No newline at end of file diff --git a/packages/platforms/celestica/x86-64/silverstone/onlp/builds/x86_64_cel_silverstone/module/inc/x86_64_cel_silverstone/x86_64_cel_silverstone.x b/packages/platforms/celestica/x86-64/silverstone/onlp/builds/x86_64_cel_silverstone/module/inc/x86_64_cel_silverstone/x86_64_cel_silverstone.x deleted file mode 100644 index b71624c0a..000000000 --- a/packages/platforms/celestica/x86-64/silverstone/onlp/builds/x86_64_cel_silverstone/module/inc/x86_64_cel_silverstone/x86_64_cel_silverstone.x +++ /dev/null @@ -1,14 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#include - -/* <--auto.start.xmacro(ALL).define> */ -/* */ - -/* <--auto.start.xenum(ALL).define> */ -/* */ - - diff --git a/packages/platforms/celestica/x86-64/silverstone/onlp/builds/x86_64_cel_silverstone/module/inc/x86_64_cel_silverstone/x86_64_cel_silverstone_config.h b/packages/platforms/celestica/x86-64/silverstone/onlp/builds/x86_64_cel_silverstone/module/inc/x86_64_cel_silverstone/x86_64_cel_silverstone_config.h deleted file mode 100644 index ad6fc5831..000000000 --- a/packages/platforms/celestica/x86-64/silverstone/onlp/builds/x86_64_cel_silverstone/module/inc/x86_64_cel_silverstone/x86_64_cel_silverstone_config.h +++ /dev/null @@ -1,127 +0,0 @@ -/**************************************************************************//** - * - * @file - * @brief x86_64_cel_silverstone Configuration Header - * - * @addtogroup x86_64_cel_silverstone-config - * @{ - * - *****************************************************************************/ -#ifndef __X86_64_CEL_SILVERSTONE_CONFIG_H__ -#define __X86_64_CEL_SILVERSTONE_CONFIG_H__ - -#ifdef GLOBAL_INCLUDE_CUSTOM_CONFIG -#include -#endif -#ifdef X86_64_CEL_SILVERSTONE_INCLUDE_CUSTOM_CONFIG -#include -#endif - -/* */ -#include -/** - * X86_64_CEL_SILVERSTONE_CONFIG_INCLUDE_LOGGING - * - * Include or exclude logging. */ - - -#ifndef X86_64_CEL_SILVERSTONE_CONFIG_INCLUDE_LOGGING -#define X86_64_CEL_SILVERSTONE_CONFIG_INCLUDE_LOGGING 1 -#endif - -/** - * X86_64_CEL_SILVERSTONE_CONFIG_LOG_OPTIONS_DEFAULT - * - * Default enabled log options. */ - - -#ifndef X86_64_CEL_SILVERSTONE_CONFIG_LOG_OPTIONS_DEFAULT -#define X86_64_CEL_SILVERSTONE_CONFIG_LOG_OPTIONS_DEFAULT AIM_LOG_OPTIONS_DEFAULT -#endif - -/** - * X86_64_CEL_SILVERSTONE_CONFIG_LOG_BITS_DEFAULT - * - * Default enabled log bits. */ - - -#ifndef X86_64_CEL_SILVERSTONE_CONFIG_LOG_BITS_DEFAULT -#define X86_64_CEL_SILVERSTONE_CONFIG_LOG_BITS_DEFAULT AIM_LOG_BITS_DEFAULT -#endif - -/** - * X86_64_CEL_SILVERSTONE_CONFIG_LOG_CUSTOM_BITS_DEFAULT - * - * Default enabled custom log bits. */ - - -#ifndef X86_64_CEL_SILVERSTONE_CONFIG_LOG_CUSTOM_BITS_DEFAULT -#define X86_64_CEL_SILVERSTONE_CONFIG_LOG_CUSTOM_BITS_DEFAULT 0 -#endif - -/** - * X86_64_CEL_SILVERSTONE_CONFIG_PORTING_STDLIB - * - * Default all porting macros to use the C standard libraries. */ - - -#ifndef X86_64_CEL_SILVERSTONE_CONFIG_PORTING_STDLIB -#define X86_64_CEL_SILVERSTONE_CONFIG_PORTING_STDLIB 1 -#endif - -/** - * X86_64_CEL_SILVERSTONE_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS - * - * Include standard library headers for stdlib porting macros. */ - - -#ifndef X86_64_CEL_SILVERSTONE_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS -#define X86_64_CEL_SILVERSTONE_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS X86_64_CEL_SILVERSTONE_CONFIG_PORTING_STDLIB -#endif - -/** - * X86_64_CEL_SILVERSTONE_CONFIG_INCLUDE_UCLI - * - * Include generic uCli support. */ - - -#ifndef X86_64_CEL_SILVERSTONE_CONFIG_INCLUDE_UCLI -#define X86_64_CEL_SILVERSTONE_CONFIG_INCLUDE_UCLI 0 -#endif - - - -/** - * All compile time options can be queried or displayed - */ - -/** Configuration settings structure. */ -typedef struct x86_64_cel_silverstone_config_settings_s { - /** name */ - const char* name; - /** value */ - const char* value; -} x86_64_cel_silverstone_config_settings_t; - -/** Configuration settings table. */ -/** x86_64_cel_silverstone_config_settings table. */ -extern x86_64_cel_silverstone_config_settings_t x86_64_cel_silverstone_config_settings[]; - -/** - * @brief Lookup a configuration setting. - * @param setting The name of the configuration option to lookup. - */ -const char* x86_64_cel_silverstone_config_lookup(const char* setting); - -/** - * @brief Show the compile-time configuration. - * @param pvs The output stream. - */ -int x86_64_cel_silverstone_config_show(struct aim_pvs_s* pvs); - -/* */ - -#include "x86_64_cel_silverstone_porting.h" - -#endif /* __X86_64_CEL_SILVERSTONE_CONFIG_H__ */ -/* @} */ diff --git a/packages/platforms/celestica/x86-64/silverstone/onlp/builds/x86_64_cel_silverstone/module/inc/x86_64_cel_silverstone/x86_64_cel_silverstone_dox.h b/packages/platforms/celestica/x86-64/silverstone/onlp/builds/x86_64_cel_silverstone/module/inc/x86_64_cel_silverstone/x86_64_cel_silverstone_dox.h deleted file mode 100644 index 9034b9cc7..000000000 --- a/packages/platforms/celestica/x86-64/silverstone/onlp/builds/x86_64_cel_silverstone/module/inc/x86_64_cel_silverstone/x86_64_cel_silverstone_dox.h +++ /dev/null @@ -1,26 +0,0 @@ -/**************************************************************************//** - * - * x86_64_cel_silverstone Doxygen Header - * - *****************************************************************************/ -#ifndef __X86_64_CEL_SILVERSTONE_DOX_H__ -#define __X86_64_CEL_SILVERSTONE_DOX_H__ - -/** - * @defgroup x86_64_cel_silverstone x86_64_cel_silverstone - x86_64_cel_silverstone Description - * - -The documentation overview for this module should go here. - - * - * @{ - * - * @defgroup x86_64_cel_silverstone-x86_64_cel_silverstone Public Interface - * @defgroup x86_64_cel_silverstone-config Compile Time Configuration - * @defgroup x86_64_cel_silverstone-porting Porting Macros - * - * @} - * - */ - -#endif /* __X86_64_CEL_SILVERSTONE_DOX_H__ */ diff --git a/packages/platforms/celestica/x86-64/silverstone/onlp/builds/x86_64_cel_silverstone/module/inc/x86_64_cel_silverstone/x86_64_cel_silverstone_porting.h b/packages/platforms/celestica/x86-64/silverstone/onlp/builds/x86_64_cel_silverstone/module/inc/x86_64_cel_silverstone/x86_64_cel_silverstone_porting.h deleted file mode 100644 index 86919e7fc..000000000 --- a/packages/platforms/celestica/x86-64/silverstone/onlp/builds/x86_64_cel_silverstone/module/inc/x86_64_cel_silverstone/x86_64_cel_silverstone_porting.h +++ /dev/null @@ -1,107 +0,0 @@ -/**************************************************************************//** - * - * @file - * @brief x86_64_cel_silverstone Porting Macros. - * - * @addtogroup x86_64_cel_silverstone-porting - * @{ - * - *****************************************************************************/ -#ifndef __X86_64_CEL_SILVERSTONE_PORTING_H__ -#define __X86_64_CEL_SILVERSTONE_PORTING_H__ - - -/* */ -#if X86_64_CEL_SILVERSTONE_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS == 1 -#include -#include -#include -#include -#include -#endif - -#ifndef X86_64_CEL_SILVERSTONE_MALLOC - #if defined(GLOBAL_MALLOC) - #define X86_64_CEL_SILVERSTONE_MALLOC GLOBAL_MALLOC - #elif X86_64_CEL_SILVERSTONE_CONFIG_PORTING_STDLIB == 1 - #define X86_64_CEL_SILVERSTONE_MALLOC malloc - #else - #error The macro X86_64_CEL_SILVERSTONE_MALLOC is required but cannot be defined. - #endif -#endif - -#ifndef X86_64_CEL_SILVERSTONE_FREE - #if defined(GLOBAL_FREE) - #define X86_64_CEL_SILVERSTONE_FREE GLOBAL_FREE - #elif X86_64_CEL_SILVERSTONE_CONFIG_PORTING_STDLIB == 1 - #define X86_64_CEL_SILVERSTONE_FREE free - #else - #error The macro X86_64_CEL_SILVERSTONE_FREE is required but cannot be defined. - #endif -#endif - -#ifndef X86_64_CEL_SILVERSTONE_MEMSET - #if defined(GLOBAL_MEMSET) - #define X86_64_CEL_SILVERSTONE_MEMSET GLOBAL_MEMSET - #elif X86_64_CEL_SILVERSTONE_CONFIG_PORTING_STDLIB == 1 - #define X86_64_CEL_SILVERSTONE_MEMSET memset - #else - #error The macro X86_64_CEL_SILVERSTONE_MEMSET is required but cannot be defined. - #endif -#endif - -#ifndef X86_64_CEL_SILVERSTONE_MEMCPY - #if defined(GLOBAL_MEMCPY) - #define X86_64_CEL_SILVERSTONE_MEMCPY GLOBAL_MEMCPY - #elif X86_64_CEL_SILVERSTONE_CONFIG_PORTING_STDLIB == 1 - #define X86_64_CEL_SILVERSTONE_MEMCPY memcpy - #else - #error The macro X86_64_CEL_SILVERSTONE_MEMCPY is required but cannot be defined. - #endif -#endif - -#ifndef X86_64_CEL_SILVERSTONE_STRNCPY - #if defined(GLOBAL_STRNCPY) - #define X86_64_CEL_SILVERSTONE_STRNCPY GLOBAL_STRNCPY - #elif X86_64_CEL_SILVERSTONE_CONFIG_PORTING_STDLIB == 1 - #define X86_64_CEL_SILVERSTONE_STRNCPY strncpy - #else - #error The macro X86_64_CEL_SILVERSTONE_STRNCPY is required but cannot be defined. - #endif -#endif - -#ifndef X86_64_CEL_SILVERSTONE_VSNPRINTF - #if defined(GLOBAL_VSNPRINTF) - #define X86_64_CEL_SILVERSTONE_VSNPRINTF GLOBAL_VSNPRINTF - #elif X86_64_CEL_SILVERSTONE_CONFIG_PORTING_STDLIB == 1 - #define X86_64_CEL_SILVERSTONE_VSNPRINTF vsnprintf - #else - #error The macro X86_64_CEL_SILVERSTONE_VSNPRINTF is required but cannot be defined. - #endif -#endif - -#ifndef X86_64_CEL_SILVERSTONE_SNPRINTF - #if defined(GLOBAL_SNPRINTF) - #define X86_64_CEL_SILVERSTONE_SNPRINTF GLOBAL_SNPRINTF - #elif X86_64_CEL_SILVERSTONE_CONFIG_PORTING_STDLIB == 1 - #define X86_64_CEL_SILVERSTONE_SNPRINTF snprintf - #else - #error The macro X86_64_CEL_SILVERSTONE_SNPRINTF is required but cannot be defined. - #endif -#endif - -#ifndef X86_64_CEL_SILVERSTONE_STRLEN - #if defined(GLOBAL_STRLEN) - #define X86_64_CEL_SILVERSTONE_STRLEN GLOBAL_STRLEN - #elif X86_64_CEL_SILVERSTONE_CONFIG_PORTING_STDLIB == 1 - #define X86_64_CEL_SILVERSTONE_STRLEN strlen - #else - #error The macro X86_64_CEL_SILVERSTONE_STRLEN is required but cannot be defined. - #endif -#endif - -/* */ - - -#endif /* __X86_64_CEL_SILVERSTONE_PORTING_H__ */ -/* @} */ diff --git a/packages/platforms/celestica/x86-64/silverstone/onlp/builds/x86_64_cel_silverstone/module/make.mk b/packages/platforms/celestica/x86-64/silverstone/onlp/builds/x86_64_cel_silverstone/module/make.mk deleted file mode 100644 index 9580796c9..000000000 --- a/packages/platforms/celestica/x86-64/silverstone/onlp/builds/x86_64_cel_silverstone/module/make.mk +++ /dev/null @@ -1,10 +0,0 @@ -############################################################################### -# -# -# -############################################################################### -THIS_DIR := $(dir $(lastword $(MAKEFILE_LIST))) -x86_64_cel_silverstone_INCLUDES := -I $(THIS_DIR)inc -x86_64_cel_silverstone_INTERNAL_INCLUDES := -I $(THIS_DIR)src -x86_64_cel_silverstone_DEPENDMODULE_ENTRIES := init:x86_64_cel_silverstone ucli:x86_64_cel_silverstone - diff --git a/packages/platforms/celestica/x86-64/silverstone/onlp/builds/x86_64_cel_silverstone/module/src/Makefile b/packages/platforms/celestica/x86-64/silverstone/onlp/builds/x86_64_cel_silverstone/module/src/Makefile deleted file mode 100644 index a9b377713..000000000 --- a/packages/platforms/celestica/x86-64/silverstone/onlp/builds/x86_64_cel_silverstone/module/src/Makefile +++ /dev/null @@ -1,9 +0,0 @@ -############################################################################### -# -# Local source generation targets. -# -############################################################################### - -ucli: - @../../../../tools/uclihandlers.py x86_64_cel_silverstone_ucli.c - diff --git a/packages/platforms/celestica/x86-64/silverstone/onlp/builds/x86_64_cel_silverstone/module/src/fani.c b/packages/platforms/celestica/x86-64/silverstone/onlp/builds/x86_64_cel_silverstone/module/src/fani.c deleted file mode 100644 index 71eda1a63..000000000 --- a/packages/platforms/celestica/x86-64/silverstone/onlp/builds/x86_64_cel_silverstone/module/src/fani.c +++ /dev/null @@ -1,103 +0,0 @@ -#include -#include "platform.h" - -onlp_fan_info_t f_info[FAN_COUNT + 1] = { - {}, - { - {ONLP_FAN_ID_CREATE(1), "Chassis Fan 1", 0}, - 0, - ONLP_FAN_CAPS_B2F | ONLP_FAN_CAPS_F2B | ONLP_FAN_CAPS_GET_RPM | ONLP_FAN_CAPS_GET_PERCENTAGE, - }, - { - {ONLP_FAN_ID_CREATE(2), "Chassis Fan 2", 0}, - 0, - ONLP_FAN_CAPS_B2F | ONLP_FAN_CAPS_F2B | ONLP_FAN_CAPS_GET_RPM | ONLP_FAN_CAPS_GET_PERCENTAGE, - }, - { - {ONLP_FAN_ID_CREATE(3), "Chassis Fan 3", 0}, - 0, - ONLP_FAN_CAPS_B2F | ONLP_FAN_CAPS_F2B | ONLP_FAN_CAPS_GET_RPM | ONLP_FAN_CAPS_GET_PERCENTAGE, - }, - { - {ONLP_FAN_ID_CREATE(4), "Chassis Fan 4", 0}, - 0, - ONLP_FAN_CAPS_B2F | ONLP_FAN_CAPS_F2B | ONLP_FAN_CAPS_GET_RPM | ONLP_FAN_CAPS_GET_PERCENTAGE, - }, - { - {ONLP_FAN_ID_CREATE(5), "Chassis Fan 5", 0}, - 0, - ONLP_FAN_CAPS_B2F | ONLP_FAN_CAPS_F2B | ONLP_FAN_CAPS_GET_RPM | ONLP_FAN_CAPS_GET_PERCENTAGE, - }, - { - {ONLP_FAN_ID_CREATE(6), "Chassis Fan 6", 0}, - 0, - ONLP_FAN_CAPS_B2F | ONLP_FAN_CAPS_F2B | ONLP_FAN_CAPS_GET_RPM | ONLP_FAN_CAPS_GET_PERCENTAGE, - }, - { - {ONLP_FAN_ID_CREATE(7), "Chassis Fan 7", 0}, - 0, - ONLP_FAN_CAPS_B2F | ONLP_FAN_CAPS_F2B | ONLP_FAN_CAPS_GET_RPM | ONLP_FAN_CAPS_GET_PERCENTAGE, - }, - { - {ONLP_FAN_ID_CREATE(8), "PSU Fan 1", ONLP_PSU_ID_CREATE(1)}, - 0, - ONLP_FAN_CAPS_B2F | ONLP_FAN_CAPS_F2B | ONLP_FAN_CAPS_GET_RPM | ONLP_FAN_CAPS_GET_PERCENTAGE, - }, - { - {ONLP_FAN_ID_CREATE(9), "PSU Fan 2", ONLP_PSU_ID_CREATE(2)}, - 0, - ONLP_FAN_CAPS_B2F | ONLP_FAN_CAPS_F2B | ONLP_FAN_CAPS_GET_RPM | ONLP_FAN_CAPS_GET_PERCENTAGE, - }, -}; - -int onlp_fani_init(void) -{ - return ONLP_STATUS_OK; -} - -int onlp_fani_info_get(onlp_oid_t id, onlp_fan_info_t *info_p) -{ - int fan_id; - - fan_id = ONLP_OID_ID_GET(id); - - *info_p = f_info[fan_id]; - - uint8_t spd_result; - int isfanb2f = 0; - - if(fan_id <= 7){ - get_fan_info(fan_id, info_p->model, info_p->serial,&isfanb2f); - }else{ - int psu_id = 0; - if(fan_id == 8){ - psu_id = 1; - }else if(fan_id == 9){ - psu_id = 2; - } - get_psu_model_sn(psu_id, info_p->model, info_p->serial); - isfanb2f = -1; - } - - - spd_result = get_fan_speed(fan_id,&(info_p->percentage), &(info_p->rpm)); - if(spd_result){ - return ONLP_FAN_STATUS_FAILED; - } - - info_p->status |= ONLP_FAN_STATUS_PRESENT; - - switch (isfanb2f) - { - case ONLP_FAN_STATUS_F2B: - info_p->status |= ONLP_FAN_STATUS_F2B; - break; - case ONLP_FAN_STATUS_B2F: - info_p->status |= ONLP_FAN_STATUS_B2F; - break; - default: - break; - } - - return ONLP_STATUS_OK; -} diff --git a/packages/platforms/celestica/x86-64/silverstone/onlp/builds/x86_64_cel_silverstone/module/src/ledi.c b/packages/platforms/celestica/x86-64/silverstone/onlp/builds/x86_64_cel_silverstone/module/src/ledi.c deleted file mode 100644 index dd51875bc..000000000 --- a/packages/platforms/celestica/x86-64/silverstone/onlp/builds/x86_64_cel_silverstone/module/src/ledi.c +++ /dev/null @@ -1,118 +0,0 @@ -#include -#include -#include -#include -#include -#include "platform.h" - -enum onlp_led_id -{ - LED_RESERVED = 0, - LED_SYSTEM, - LED_ALARM, - LED_PSU, - LED_FAN -}; - -/* - * Get the information for the given LED OID. - */ -static onlp_led_info_t led_info[] = -{ - { }, - { - { ONLP_LED_ID_CREATE(LED_SYSTEM), "System LED (Front)", 0 }, - ONLP_LED_STATUS_PRESENT, - ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_YELLOW | ONLP_LED_CAPS_YELLOW_BLINKING | ONLP_LED_CAPS_GREEN | - ONLP_LED_CAPS_GREEN_BLINKING | ONLP_LED_CAPS_AUTO, - }, - { - { ONLP_LED_ID_CREATE(LED_ALARM), "Alert LED (Front)", 0 }, - ONLP_LED_STATUS_PRESENT, - ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_YELLOW | ONLP_LED_CAPS_YELLOW_BLINKING | ONLP_LED_CAPS_GREEN | - ONLP_LED_CAPS_GREEN_BLINKING, - }, - { - { ONLP_LED_ID_CREATE(LED_PSU), "PSU LED (Front)", 0 }, - ONLP_LED_STATUS_PRESENT, - ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_AUTO | ONLP_LED_CAPS_YELLOW | ONLP_LED_CAPS_GREEN, - }, - { - { ONLP_LED_ID_CREATE(LED_FAN), "FAN LED (Front)", 0 }, - ONLP_LED_STATUS_PRESENT, - ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_AUTO | ONLP_LED_CAPS_YELLOW | 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_p) -{ - int led_id; - uint8_t led_color = 0; - uint8_t blink_status = 0; - uint8_t hw_control_status = 0; - uint8_t result = 0; - - led_id = ONLP_OID_ID_GET(id); - *info_p = led_info[led_id]; - - result = get_led_status(led_id); - - if(result != 0xFF) - info_p->status |= ONLP_LED_STATUS_ON; - - switch(led_id){ - case LED_SYSTEM: - case LED_ALARM: - - led_color = (result >> 4)&0x3; - if(led_color == 0){ - if(led_id==LED_SYSTEM) - info_p->mode |= ONLP_LED_MODE_AUTO; - if(led_id==LED_ALARM) - info_p->mode |= ONLP_LED_MODE_OFF; - } - if(led_color == 1){ - info_p->mode |= ONLP_LED_MODE_GREEN; - } - if(led_color == 2){ - info_p->mode |= ONLP_LED_MODE_YELLOW; - } - if(led_color == 3){ - info_p->mode |= ONLP_LED_MODE_OFF; - break; - } - - blink_status = result & 0x3; - if(blink_status == 1 || blink_status == 2){ - int current_mode = info_p->mode; - info_p->mode = current_mode+1; - } - - break; - case LED_PSU: - case LED_FAN: - hw_control_status = (result >> 4) & 0x1; - led_color = result & 0x3; - if(!hw_control_status) - { - if(led_color == 1){ - info_p->mode = ONLP_LED_MODE_YELLOW; - }else if(led_color == 2){ - info_p->mode = ONLP_LED_MODE_GREEN; - }else if(led_color == 3){ - info_p->mode = ONLP_LED_MODE_OFF; - } - }else{ - info_p->mode = ONLP_LED_MODE_AUTO; - } - break; - } - return ONLP_STATUS_OK; -} diff --git a/packages/platforms/celestica/x86-64/silverstone/onlp/builds/x86_64_cel_silverstone/module/src/make.mk b/packages/platforms/celestica/x86-64/silverstone/onlp/builds/x86_64_cel_silverstone/module/src/make.mk deleted file mode 100644 index 5a6f7bcab..000000000 --- a/packages/platforms/celestica/x86-64/silverstone/onlp/builds/x86_64_cel_silverstone/module/src/make.mk +++ /dev/null @@ -1,9 +0,0 @@ -############################################################################### -# -# -# -############################################################################### - -LIBRARY := x86_64_cel_silverstone -$(LIBRARY)_SUBDIR := $(dir $(lastword $(MAKEFILE_LIST))) -include $(BUILDER)/lib.mk diff --git a/packages/platforms/celestica/x86-64/silverstone/onlp/builds/x86_64_cel_silverstone/module/src/platform.c b/packages/platforms/celestica/x86-64/silverstone/onlp/builds/x86_64_cel_silverstone/module/src/platform.c deleted file mode 100644 index b6ac3a9a3..000000000 --- a/packages/platforms/celestica/x86-64/silverstone/onlp/builds/x86_64_cel_silverstone/module/src/platform.c +++ /dev/null @@ -1,1112 +0,0 @@ -////////////////////////////////////////////////////////////// -// PLATFORM FUNCTION TO INTERACT WITH SYS_CPLD AND BMC // -////////////////////////////////////////////////////////////// - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -#include "platform.h" - -char command[256]; -FILE *fp; - -static struct device_info fan_information[FAN_COUNT + 1] = { - {"unknown", "unknown",1}, //check - {}, //Fan 1 - {}, //Fan 2 - {}, //Fan 3 - {}, //Fan 4 - {}, - {}, - {}, - {}, - {}, -}; - -static struct device_info psu_information[PSU_COUNT + 1] = { - {"unknown", "unknown"}, //check - {}, //PSU 1 - {}, //PSU 2 -}; - -static const struct led_reg_mapper led_mapper[LED_COUNT + 1] = { - {}, - {"LED_SYSTEM", LED_SYSTEM_H, LED_SYSTEM_REGISTER}, - {"LED_ALARM", LED_ALARM_H, ALARM_REGISTER}, - {"LED_PSU", LED_PSU_H, PSU_LED_REGISTER}, - {"LED_FAN",LED_FAN_H,LED_FAN_REGISTER} -}; - -static const struct psu_reg_bit_mapper psu_mapper [PSU_COUNT + 1] = { - {}, - {0xa160, 3, 7, 1}, - {0xa160, 2, 6, 0}, -}; - -void update_shm_mem(void) -{ - (void)fill_shared_memory(ONLP_SENSOR_CACHE_SHARED, ONLP_SENSOR_CACHE_SEM, ONLP_SENSOR_CACHE_FILE); - (void)fill_shared_memory(ONLP_FRU_CACHE_SHARED, ONLP_FRU_CACHE_SEM, ONLP_FRU_CACHE_FILE); - (void)fill_shared_memory(ONLP_SENSOR_LIST_CACHE_SHARED, ONLP_SENSOR_LIST_SEM, ONLP_SENSOR_LIST_FILE); -} - -int is_cache_exist(){ - const char *sdr_cache_path="/tmp/onlp-sensor-list-cache.txt"; - const char *fru_cache_path="/tmp/onlp-fru-cache.txt"; - const char *time_setting_path="/var/opt/interval_time.txt"; - time_t current_time; - int interval_time = 30; //set default to 30 sec - double sdr_diff_time,fru_diff_time; - struct stat sdr_fst,fru_fst; - bzero(&sdr_fst,sizeof(sdr_fst)); - bzero(&fru_fst,sizeof(fru_fst)); - - //Read setting - if(access(time_setting_path, F_OK) == -1){ //Setting not exist - return -1; - }else{ - FILE *fp; - - fp = fopen(time_setting_path, "r"); // read setting - - if (fp == NULL) - { - perror("Error while opening the file.\n"); - exit(EXIT_FAILURE); - } - - fscanf(fp,"%d", &interval_time); - - fclose(fp); - } - - if ((access(sdr_cache_path, F_OK) == -1) && (access(fru_cache_path, F_OK) == -1)){ //Cache not exist - return -1; - }else{ //Cache exist - current_time = time(NULL); - if (stat(sdr_cache_path,&sdr_fst) != 0) { printf("stat() sdr_cache failed\n"); return -1; } - if (stat(fru_cache_path,&fru_fst) != 0) { printf("stat() fru_cache failed\n"); return -1; } - - sdr_diff_time = difftime(current_time,sdr_fst.st_mtime); - fru_diff_time = difftime(current_time,fru_fst.st_mtime); - - if((sdr_diff_time > interval_time)&&(fru_diff_time > interval_time)){ - return -1; - } - return 1; - } -} - -int is_shm_mem_ready(){ - - if(USE_SHM_METHOD){ - const char *sdr_cache_path="/run/shm/onlp-sensor-list-cache-shared"; - const char *fru_cache_path="/run/shm/onlp-fru-cache-shared"; - - if(access(fru_cache_path, F_OK) == -1 || access(sdr_cache_path, F_OK) == -1 ){ //Shared cache files not exist - return 0; - } - - return 1; - } - - return 0; -} - -int create_cache(){ - (void)system("ipmitool fru > /tmp/onlp-fru-cache.tmp; sync; rm -f /tmp/onlp-fru-cache.txt; mv /tmp/onlp-fru-cache.tmp /tmp/onlp-fru-cache.txt"); - (void)system("ipmitool sensor list > /tmp/onlp-sensor-list-cache.tmp; sync; rm -f /tmp/onlp-sensor-list-cache.txt; mv /tmp/onlp-sensor-list-cache.tmp /tmp/onlp-sensor-list-cache.txt"); - if(USE_SHM_METHOD){ - update_shm_mem(); - } - return 1; -} - -void array_trim(char *strIn, char *strOut) -{ - int i, j; - - i = 0; - j = strlen(strIn) - 1; - - while(strIn[i] == ' ') ++i; - while(strIn[j] == ' ') --j; - - strncpy(strOut, strIn + i , j - i + 1); - strOut[j - i + 1] = '\0'; -} - -uint8_t read_register(uint16_t dev_reg) -{ - int status; - sprintf(command, "echo 0x%x > %sgetreg", dev_reg, SYS_CPLD_PATH); - fp = popen(command, "r"); - if (!fp) - { - printf("Failed : Can't specify CPLD register\n"); - return -1; - } - pclose(fp); - fp = popen("cat " SYS_CPLD_PATH "getreg", "r"); - if (!fp) - { - printf("Failed : Can't open sysfs\n"); - return -1; - } - fscanf(fp, "%x", &status); - pclose(fp); - - return status; -} - -int exec_ipmitool_cmd(char *cmd, char *retd) -{ - int ret = 0; - int i = 0; - char c; - FILE *pFd = NULL; - - pFd = popen(cmd, "r"); - if (pFd != NULL) - { - c = fgetc(pFd); - while (c != EOF) - { - //printf ("%c", c); - retd[i] = c; - i++; - c = fgetc(pFd); - } - pclose(pFd); - } - - return ret; -} - -uint8_t get_led_status(int id) -{ - uint8_t ret = 0xFF; - - if (id >= (LED_COUNT + 2) || id < 0) - return 0xFF; - - if (id <= (LED_COUNT)) - { - uint8_t result = 0; - uint16_t led_stat_reg; - led_stat_reg = led_mapper[id].dev_reg; - result = read_register(led_stat_reg); - ret = result; - } - - return ret; -} - -char *read_tmp_cache(char *cmd, char *cache_file_path) -{ - FILE* pFd = NULL; - char *str = NULL; - int round = 1; - - for(round = 1;round <= 10;round++){ - pFd = fopen(cache_file_path, "r"); - if(pFd != NULL ){ - - struct stat st; - - stat(cache_file_path, &st); - - int size = st.st_size; - str = (char *)malloc(size + 1); - - memset (str, 0, size+1); - - fread(str, size+1, 1, pFd); - - fclose(pFd); - break; - }else{ - usleep(5000); //Sleep for 5 Microsec for waiting the file operation complete - } - } - - if(round >= 10 && str == NULL){ - str = (char *)malloc(1); - memset (str, 0, 1); - } - - return str; -} - -uint8_t get_psu_status(int id) -{ - uint8_t ret = 0xFF; - uint16_t psu_stat_reg; - - if (id <= (PSU_COUNT)) - { - uint8_t result = 0; - psu_stat_reg = psu_mapper[id].sta_reg; - result = read_register(psu_stat_reg); - ret = result; - } - - return ret; -} - -int get_psu_info(int id, int *mvin, int *mvout, int *mpin, int *mpout, int *miin, int *miout) -{ - char *tmp = (char *)NULL; - int len = 0; - int index = 0; - - int i = 0; - int ret = 0; - char strTmp[12][128] = {{0}, {0}}; - char *token = NULL; - char *psu_sensor_name[12] = { - "PSU1_VIn", "PSU1_CIn", "PSU1_PIn", "PSU1_VOut", - "PSU1_COut", "PSU1_POut", "PSU2_VIn", "PSU2_CIn", - "PSU2_PIn", "PSU2_VOut","PSU2_COut","PSU2_POut"}; - - /* - String example: - root@localhost:~# ipmitool sensor list | grep PSU - PSU1_Status | 0x0 | discrete | 0x0180| na | na | na | na | na | na - PSU2_Status | 0x0 | discrete | 0x0180| na | na | na | na | na | na - PSU1_Fan | na | RPM | na | na | na | na | na | na | na - PSU2_Fan | 15800.000 | RPM | ok | na | na | na | na | na | na - PSU1_VIn | na | Volts | na | na 0 | na | na | 239.800 | 264.000 | na - PSU1_CIn | na | Amps | na | na 1 | na | na | na | 14.080 | na - PSU1_PIn | na | Watts | na | na 2 | na | na | na | 1500.000 | na - PSU1_Temp1 | na | degrees C | na | na | na | na | na | na | na - PSU1_Temp2 | na | degrees C | na | na | na | na | na | na | na - PSU1_VOut | na | Volts | na | na 3 | na | na | na | 13.500 | 15.600 - PSU1_COut | na | Amps | na | na 4 | na | na | na | 125.000 | na - PSU1_POut | na | Watts | na | na 5 | na | na | na | 1500.000 | na - PSU2_VIn | 228.800 | Volts | ok | na 6 | na | na | 239.800 | 264.000 | na - PSU2_CIn | 0.480 | Amps | ok | na 7 | na | na | na | 14.080 | na - PSU2_PIn | 114.000 | Watts | ok | na 8 | na | na | na | 1500.000 | na - PSU2_Temp1 | 26.000 | degrees C | ok | na | na | na | na | na | na - PSU2_Temp2 | 43.000 | degrees C | ok | na | na | na | na | na | na - PSU2_VOut | 12.000 | Volts | ok | na 9 | na | na | na | 13.500 | 15.600 - PSU2_COut | 7.500 | Amps | ok | na 10 | na | na | na | 125.000 | na - PSU2_POut | 90.000 | Watts | ok | na 11 | na | na | na | 1500.000 | na - root@localhost:~# - */ - if((NULL == mvin) || (NULL == mvout) ||(NULL == mpin) || (NULL == mpout) || (NULL == miin) || (NULL == miout)) - { - printf("%s null pointer!\n", __FUNCTION__); - return -1; - } - - if(is_shm_mem_ready()){ - ret = open_file(ONLP_SENSOR_LIST_CACHE_SHARED,ONLP_SENSOR_LIST_SEM, &tmp, &len); - if(ret < 0 || !tmp){ - printf("Failed - Failed to obtain system information\n"); - (void)free(tmp); - tmp = (char *)NULL; - return ret; - } - }else{ - // use unsafe method to read the cache file. - sprintf(command, "cat %s",ONLP_SENSOR_LIST_FILE); - tmp = read_tmp_cache(command,ONLP_SENSOR_LIST_FILE); - } - - char *content, *temp_pointer; - int flag = 0; - content = strtok_r(tmp, "\n", &temp_pointer); - - int search_from = 0; - int search_to = 0; - - if(id == 1){ - search_from = 0; - search_to = 5; - }else{ - search_from = 6; - search_to = 11; - } - - while(content != NULL && search_from <= search_to){ - if (strstr(content, psu_sensor_name[search_from])) - { - flag = 1; - index++; - } - - if(flag == 1){ - i = 0; - token = strtok(content, "|"); - while( token != NULL ) - { - if(i == 1){ - array_trim(token, &strTmp[search_from][i]); - search_from++; - } - i++; - if(i > 2) break; - token = strtok(NULL, "|"); - } - } - - - flag = 0; - content = strtok_r(NULL, "\n", &temp_pointer); - } - - if(content){ - content = (char *)NULL; - } - if(temp_pointer){ - temp_pointer = (char *)NULL; - } - if(tmp){ - (void)free(tmp); - tmp = (char *)NULL; - } - - if (id == 1) - { - if (0 == strcmp(&strTmp[0][1], "na")) - *mvin = 0; - else - *mvin = atof(&strTmp[0][1]) * 1000.0; - - if (0 == strcmp(&strTmp[3][1], "na")) - *mvout = 0; - else - *mvout = atof(&strTmp[3][1]) * 1000.0; - - if (0 == strcmp(&strTmp[2][1], "na")) - *mpin = 0; - else - *mpin = atof(&strTmp[2][1]) * 1000.0; - - if (0 == strcmp(&strTmp[5][1], "na")) - *mpout = 0; - else - *mpout = atof(&strTmp[5][1]) * 1000.0; - - if (0 == strcmp(&strTmp[1][1], "na")) - *miin = 0; - else - *miin = atof(&strTmp[1][1]) * 1000.0; - - if (0 == strcmp(&strTmp[4][1], "na")) - *miout = 0; - else - *miout = atof(&strTmp[4][1]) * 1000.0; - } - else - { - if (0 == strcmp(&strTmp[6][1], "na")) - *mvin = 0; - else - *mvin = atof(&strTmp[6][1]) * 1000.0; - - if (0 == strcmp(&strTmp[9][1], "na")) - *mvout = 0; - else - *mvout = atof(&strTmp[9][1]) * 1000.0; - - if (0 == strcmp(&strTmp[8][1], "na")) - *mpin = 0; - else - *mpin = atof(&strTmp[8][1]) * 1000.0; - - if (0 == strcmp(&strTmp[11][1], "na")) - *mpout = 0; - else - *mpout = atof(&strTmp[11][1]) * 1000.0; - - if (0 == strcmp(&strTmp[7][1], "na")) - *miin = 0; - else - *miin = atof(&strTmp[7][1]) * 1000.0; - - if (0 == strcmp(&strTmp[10][1], "na")) - *miout = 0; - else - *miout = atof(&strTmp[10][1]) * 1000.0; - } - - return ret; -} - -int get_psu_model_sn(int id, char *model, char *serial_number) -{ - int index; - char *token; - char *tmp = (char *)NULL; - int len = 0; - int ret = -1; - int search_psu_id = 1; - - if (0 == strcasecmp(psu_information[0].model, "unknown")) { - - index = 0; - if(is_shm_mem_ready()){ - ret = open_file(ONLP_FRU_CACHE_SHARED,ONLP_FRU_CACHE_SEM, &tmp, &len); - if(ret < 0 || !tmp){ - printf("Failed - Failed to obtain system information\n"); - (void)free(tmp); - tmp = (char *)NULL; - return ret; - } - }else{ - // use unsafe method to read the cache file. - sprintf(command, "cat %s",ONLP_FRU_CACHE_FILE); - tmp = read_tmp_cache(command,ONLP_FRU_CACHE_FILE); - } - - char *content, *temp_pointer; - int flag = 0; - /* - String example: - root@localhost:~# ipmitool fru (Pull out PSU1) - - FRU Device Description : FRU_PSUL (ID 3) - Device not present (Unknown (0x81)) - - FRU Device Description : FRU_PSUR (ID 4) - Board Mfg Date : Mon Mar 11 08:55:00 2019 - Board Mfg : DELTA-THAILAND - Board Product : 1500W-CAPELLA-PSU 1500W - Board Serial : FFGT1911000697 - Board Part Number : TDPS1500AB6B - - */ - content = strtok_r(tmp, "\n", &temp_pointer); - - while(content != NULL){ - if (strstr(content, "FRU Device Description : FRU_PSU")) { - flag = 1; - index++; - } - if(flag == 1){ - if (strstr(content, "Device not present")) { - index++; - flag=0; - } - else if (strstr(content, "Board Product")) { - token = strtok(content, ":"); - token = strtok(NULL, ":"); - char* trim_token = trim(token); - sprintf(psu_information[index].model,"%s",trim_token); - } - else if (strstr(content, "Board Serial")) { - token = strtok(content, ":"); - token = strtok(NULL, ":"); - char* trim_token = trim(token); - sprintf(psu_information[index].serial_number,"%s",trim_token); - flag = 0; - search_psu_id++; - } - } - if(search_psu_id > PSU_COUNT){ - content = NULL; - }else{ - content = strtok_r(NULL, "\n", &temp_pointer); - } - } - - sprintf(psu_information[0].model,"pass"); //Mark as complete - - if(temp_pointer){ - temp_pointer = (char *)NULL; - } - if(tmp){ - (void)free(tmp); - tmp = (char *)NULL; - } - } - - strcpy(model, psu_information[id].model); - strcpy(serial_number, psu_information[id].serial_number); - - return 1; -} - -int get_fan_info(int id, char *model, char *serial, int *isfanb2f) -{ - int index; - char *token; - char *tmp = (char *)NULL; - int len = 0; - int ret = -1; - - if (0 == strcasecmp(fan_information[0].model, "unknown")) { - index = 0; - if(is_shm_mem_ready()){ - ret = open_file(ONLP_FRU_CACHE_SHARED,ONLP_FRU_CACHE_SEM, &tmp, &len); - if(ret < 0 || !tmp){ - printf("Failed - Failed to obtain system information\n"); - (void)free(tmp); - tmp = (char *)NULL; - return ret; - } - }else{ - // use unsafe method to read the cache file. - sprintf(command, "cat %s",ONLP_FRU_CACHE_FILE); - tmp = read_tmp_cache(command,ONLP_FRU_CACHE_FILE); - } - /* - String example: - root@localhost:~# ipmitool fru (Pull out FAN1) - - FRU Device Description : FRU_FAN1 (ID 6) - Device not present (Unknown (0x81)) - - FRU Device Description : FRU_FAN2 (ID 7) - Board Mfg Date : Sat Apr 6 10:26:00 2019 - Board Mfg : Celestica - Board Product : Fan Board 2 - Board Serial : R1141-F0018-01GD0119170163 - Board Part Number : R1141-F0018-01 - Board Extra : Mt.Echo-Fan - Board Extra : 02 - Board Extra : F2B - - . - . - - FRU Device Description : FRU_FAN7 (ID 12) - Board Mfg Date : Sat Apr 6 10:26:00 2019 - Board Mfg : Celestica - Board Product : Fan Board 7 - Board Serial : R1141-F0018-01GD0119170165 - Board Part Number : R1141-F0018-01 - Board Extra : Mt.Echo-Fan - Board Extra : 02 - Board Extra : F2B - - */ - char *content, *temp_pointer; - int flag = 0; - content = strtok_r(tmp, "\n", &temp_pointer); - - while(content != NULL){ - if (strstr(content, "FRU_FAN") && !strstr(content,"FRU_FANBRD")) { - flag = 1; - index++; - } - if(flag == 1){ - if (strstr(content, "Device not present")) { - index++; - flag=0; - } - else if (strstr(content, "Board Serial")) { - token = strtok(content, ":"); - token = strtok(NULL, ":"); - char* trim_token = trim(token); - sprintf(fan_information[index].serial_number,"%s",trim_token); - } - else if (strstr(content, "Board Part Number")) { - token = strtok(content, ":"); - token = strtok(NULL, ":"); - char* trim_token = trim(token); - sprintf(fan_information[index].model,"%s",trim_token); - - }else if (strstr(content, "Board Extra")) - { - token = strtok(content, ":"); - token = strtok(NULL, ":"); - char* trim_token = trim(token); - //Check until find B2F or F2B - if(strcmp(trim_token, "B2F") == 0){ - fan_information[index].airflow = 4; - flag = 0; - }else if(strcmp(trim_token ,"F2B") == 0){ - fan_information[index].airflow = 8; - flag = 0; - } - - } - - } - if(index > FAN_COUNT){ - content = NULL; - }else{ - content = strtok_r(NULL, "\n", &temp_pointer); - } - } - - sprintf(fan_information[0].model,"pass"); //Mark as complete - - if(temp_pointer){ - temp_pointer = (char *)NULL; - } - if(tmp){ - (void)free(tmp); - tmp = (char *)NULL; - } - } - strcpy(model, fan_information[id].model); - strcpy(serial, fan_information[id].serial_number); - *isfanb2f = fan_information[id].airflow; - - return 1; -} - -int get_sensor_info(int id, int *temp, int *warn, int *error, int *shutdown) -{ - char *tmp = (char *)NULL; - int len = 0; - int index = 0; - - int i = 0; - int ret = 0; - char strTmp[10][128] = {{0}, {0}}; - char *token = NULL; - char *Thermal_sensor_name[13] = { - "TEMP_CPU", "TEMP_BB", "TEMP_SW_U16", "TEMP_SW_U52", - "TEMP_FAN_U17", "TEMP_FAN_U52","SW_U04_Temp","SW_U14_Temp","SW_U4403_Temp", - "PSU1_Temp1", "PSU1_Temp2","PSU2_Temp1", "PSU2_Temp2"}; - - if((NULL == temp) || (NULL == warn) || (NULL == error) || (NULL == shutdown)) - { - printf("%s null pointer!\n", __FUNCTION__); - return -1; - } - - /* - String example: - ipmitool sensor list - TEMP_CPU | 1.000 | degrees C | ok | 5.000 | 9.000 | 16.000 | 65.000 | 73.000 | 75.606 - TEMP_FAN_U52 | 32.000 | degrees C | ok | na | na | na | na | 70.000 | 75.000 - PSUR_Temp1 | na | degrees C | na | na | na | na | na | na | na - */ - if(is_shm_mem_ready()){ - ret = open_file(ONLP_SENSOR_LIST_CACHE_SHARED,ONLP_SENSOR_LIST_SEM, &tmp, &len); - if(ret < 0 || !tmp){ - printf("Failed - Failed to obtain system information\n"); - (void)free(tmp); - tmp = (char *)NULL; - return ret; - } - }else{ - // use unsafe method to read the cache file. - sprintf(command, "cat %s",ONLP_SENSOR_LIST_FILE); - tmp = read_tmp_cache(command,ONLP_SENSOR_LIST_FILE); - } - - char *content, *temp_pointer; - int flag = 0; - content = strtok_r(tmp, "\n", &temp_pointer); - while(content != NULL){ - if (strstr(content, Thermal_sensor_name[id - 1])) { - flag = 1; - index++; - } - if(flag == 1){ - - i = 0; - token = strtok(content, "|"); - while( token != NULL ) - { - array_trim(token, &strTmp[i][0]); - i++; - if(i > 10) break; - token = strtok(NULL, "|"); - } - - flag = 3; - } - - if(flag == 3){ - content = NULL; - }else{ - content = strtok_r(NULL, "\n", &temp_pointer); - } - } - - if (0 == strcmp(&strTmp[1][0], "na")) - *temp = 0; - else - *temp = atof(&strTmp[1][0]) * 1000.0; - - if (0 == strcmp(&strTmp[7][0], "na")) - *warn = 0; - else - *warn = atof(&strTmp[7][0]) * 1000.0; - - if (0 == strcmp(&strTmp[8][0], "na")) - *error = 0; - else - *error = atof(&strTmp[8][0]) * 1000.0; - - if (0 == strcmp(&strTmp[9][0], "na")) - *shutdown = 0; - else - *shutdown = atof(&strTmp[9][0]) * 1000.0; - - if(content){ - content = (char *)NULL; - } - if(temp_pointer){ - temp_pointer = (char *)NULL; - } - if(tmp){ - (void)free(tmp); - tmp = (char *)NULL; - } - - return 0; -} - -int get_fan_speed(int id,int *per, int *rpm) -{ - - int max_rpm_speed = 29700;// = 100% speed - char *tmp = (char *)NULL; - int len = 0; - int index = 0; - - int i = 0; - int ret = 0; - char strTmp[2][128] = {{0}, {0}}; - char *token = NULL; - char *Fan_sensor_name[9] = { - "Fan1_Rear", "Fan2_Rear", "Fan3_Rear", "Fan4_Rear", - "Fan5_Rear", "Fan6_Rear", "Fan7_Rear","PSU1_Fan","PSU2_Fan"}; - - if((NULL == per) || (NULL == rpm)) - { - printf("%s null pointer!\n", __FUNCTION__); - return -1; - } - - /* - String example: - ipmitool sensor list (Plug out FAN1 and PSU 1) - Fan1_Rear | na | RPM | na | na | 1050.000 | na | na | na | na - Fan2_Rear | 28650.000 | RPM | ok | na | 1050.000 | na | na | na | na - Fan3_Rear | 29250.000 | RPM | ok | na | 1050.000 | na | na | na | na - Fan4_Rear | 28650.000 | RPM | ok | na | 1050.000 | na | na | na | na - Fan5_Rear | 29400.000 | RPM | ok | na | 1050.000 | na | na | na | na - Fan6_Rear | 29100.000 | RPM | ok | na | 1050.000 | na | na | na | na - Fan7_Rear | 29100.000 | RPM | ok | na | 1050.000 | na | na | na | na - PSU1_Fan | na | RPM | na | na | na | na | na | na | na - PSU2_Fan | 15800.000 | RPM | ok | na | na | na | na | na | na - */ - if(is_shm_mem_ready()){ - ret = open_file(ONLP_SENSOR_LIST_CACHE_SHARED,ONLP_SENSOR_LIST_SEM, &tmp, &len); - if(ret < 0 || !tmp){ - printf("Failed - Failed to obtain system information\n"); - (void)free(tmp); - tmp = (char *)NULL; - return ret; - } - }else{ - // use unsafe method to read the cache file. - sprintf(command, "cat %s",ONLP_SENSOR_LIST_FILE); - tmp = read_tmp_cache(command,ONLP_SENSOR_LIST_FILE); - } - - char *content, *temp_pointer; - int flag = 0; - content = strtok_r(tmp, "\n", &temp_pointer); - while(content != NULL){ - if (strstr(content, Fan_sensor_name[id - 1])) { - flag = 1; - index++; - } - if(flag == 1){ - - i = 0; - token = strtok(content, "|"); - while( token != NULL ) - { - array_trim(token, &strTmp[i][0]); - i++; - if(i > 2) break; - token = strtok(NULL, "|"); - } - - flag = 3; - } - - if(flag == 3){ - content = NULL; - }else{ - content = strtok_r(NULL, "\n", &temp_pointer); - } - } - - if (0 == strcmp(&strTmp[1][0], "na")){ - *rpm = 0; - ret = -1; - }else{ - *rpm = atof(&strTmp[1][0]); - } - - if (0 == strcmp(&strTmp[1][0], "na")) - *per = 0; - else - *per = (atof(&strTmp[1][0]) * 100 )/ max_rpm_speed; - - if(content){ - content = (char *)NULL; - } - if(temp_pointer){ - temp_pointer = (char *)NULL; - } - if(tmp){ - (void)free(tmp); - tmp = (char *)NULL; - } - - return ret; -} - -int read_device_node_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 read_device_node_string(char *filename, char *buffer, int buf_size, int data_len) -{ - int ret; - - if (data_len >= buf_size) - { - return -1; - } - - ret = read_device_node_binary(filename, buffer, buf_size - 1, data_len); - if (ret == 0) - { - buffer[buf_size - 1] = '\0'; - } - - return ret; -} - -char* trim (char *s) -{ - int i; - - while (isspace (*s)) s++; // skip left side white spaces - for (i = strlen (s) - 1; (isspace (s[i])); i--) ; // skip right side white spaces - s[i + 1] = '\0'; - - return s; -} - -int fill_shared_memory(const char *shm_path, const char *sem_path, const char *cache_path) -{ - int seg_size = 0; - int shm_fd = -1; - struct shm_map_data * shm_map_ptr = (struct shm_map_data *)NULL; - - if(!shm_path || !sem_path || !cache_path){ - return -1; - } - - seg_size = sizeof(struct shm_map_data); - - shm_fd = shm_open(shm_path, O_CREAT|O_RDWR, S_IRWXU|S_IRWXG); - if(shm_fd < 0){ - - printf("\nshm_path:%s. errno:%d\n", shm_path, errno); - return -1; - } - - ftruncate(shm_fd, seg_size); - - shm_map_ptr = (struct shm_map_data *)mmap(NULL, seg_size, PROT_READ|PROT_WRITE, MAP_SHARED, shm_fd, 0); - if(shm_map_ptr == MAP_FAILED){ - printf("\nMAP_FAILED. errno:%d.\n", errno); - close(shm_fd); - return -1; - } - - if(access(cache_path, F_OK) == -1) - { - munmap(shm_map_ptr, seg_size); - close(shm_fd); - return -1; - } - - struct stat sta; - stat(cache_path, &sta); - int st_size = sta.st_size; - if(st_size == 0){ - munmap(shm_map_ptr, seg_size); - close(shm_fd); - return -1; - } - - char *cache_buffer = (char *)malloc(st_size); - if(!cache_buffer){ - munmap(shm_map_ptr, seg_size); - close(shm_fd); - return -1; - } - - memset(cache_buffer, 0, st_size); - - FILE *cache_fp = fopen(cache_path, "r"); - if(!cache_fp) - { - free(cache_buffer); - munmap(shm_map_ptr, seg_size); - close(shm_fd); - return -1; - } - - int cache_len = fread(cache_buffer, 1, st_size, cache_fp); - if(st_size != cache_len) - { - munmap(shm_map_ptr, seg_size); - close(shm_fd); - free(cache_buffer); - fclose(cache_fp); - return -1; - } - - sem_t * sem_id = sem_open(sem_path, O_CREAT, S_IRUSR | S_IWUSR, 1); - if(sem_id == SEM_FAILED){ - munmap(shm_map_ptr, seg_size); - close(shm_fd); - free(cache_buffer); - fclose(cache_fp); - return -1; - } - - sem_wait(sem_id); - - memcpy(shm_map_ptr->data, cache_buffer, st_size); - - shm_map_ptr->size = st_size; - - sem_post(sem_id); - - (void)free(cache_buffer); - - sem_close(sem_id); - - munmap(shm_map_ptr, seg_size); - - close(shm_fd); - - return 0; -} - -int dump_shared_memory(const char *shm_path, const char *sem_path, struct shm_map_data *shared_mem) -{ - sem_t *sem_id = (sem_t *)NULL; - struct shm_map_data *map_ptr = (struct shm_map_data *)NULL; - int seg_size = 0; - int shm_fd = -1; - - if(!shm_path || !sem_path || !shared_mem){ - return -1; - } - - seg_size = sizeof(struct shm_map_data); - - - shm_fd = shm_open(shm_path, O_RDONLY, 0666); - if(shm_fd < 0){ - return -1; - } - - map_ptr = (struct shm_map_data *)mmap(NULL, seg_size, PROT_READ, MAP_SHARED, shm_fd, 0); - if(map_ptr == MAP_FAILED){ - close(shm_fd); - return -1; - } - - sem_id = sem_open(sem_path, 0); - if(SEM_FAILED == sem_id){ - munmap(map_ptr, seg_size); - close(shm_fd); - return -1; - } - - sem_wait(sem_id); - - memcpy(shared_mem, map_ptr, sizeof(struct shm_map_data)); - - sem_post(sem_id); - - sem_close(sem_id); - - munmap(map_ptr, seg_size); - close(shm_fd); - - return 0; -} - -int open_file(const char *shm_path, const char *sem_path, char **cache_data, int *cache_size) -{ - int res = -1; - char *tmp_ptr = (char *)NULL; - struct shm_map_data shm_map_tmp; - - memset(&shm_map_tmp, 0, sizeof(struct shm_map_data)); - - res = dump_shared_memory(shm_path, sem_path, &shm_map_tmp); - if(!res){ - tmp_ptr = malloc(shm_map_tmp.size); - if(!tmp_ptr){ - res = -1; - return res; - } - - memset(tmp_ptr, 0, shm_map_tmp.size); - - memcpy(tmp_ptr, shm_map_tmp.data, shm_map_tmp.size); - - *cache_data = tmp_ptr; - - *cache_size = shm_map_tmp.size; - } - - return res; -} diff --git a/packages/platforms/celestica/x86-64/silverstone/onlp/builds/x86_64_cel_silverstone/module/src/platform.h b/packages/platforms/celestica/x86-64/silverstone/onlp/builds/x86_64_cel_silverstone/module/src/platform.h deleted file mode 100644 index 822145cd4..000000000 --- a/packages/platforms/celestica/x86-64/silverstone/onlp/builds/x86_64_cel_silverstone/module/src/platform.h +++ /dev/null @@ -1,147 +0,0 @@ -#ifndef _PLATFORM_SEASTONE_H_ -#define _PLATFORM_SEASTONE_H_ -#include - -#define PREFIX_PATH_LEN 100 - -//FAN -#define FAN_COUNT 9 -#define CHASSIS_FAN_COUNT 7 - -//PSU -#define PSU_COUNT 2 -#define PSU_STA_REGISTER 0xA160 -#define PSU_LED_REGISTER 0xA161 - -//THERMAL -#define THERMAL_COUNT 13 -#define THERMAL_REGISTER 0xA176 -#define CHASSIS_THERMAL_COUNT 9 - -//ALARM -#define ALARM_REGISTER 0xA163 - -//LED -#define LED_COUNT 4 - -#define LED_SYSTEM_H 1 -#define LED_SYSTEM_REGISTER 0xA162 -#define LED_SYSTEM_BOTH 3 -#define LED_SYSTEM_GREEN 1 -#define LED_SYSTEM_YELLOW 2 -#define LED_SYSTEM_OFF 3 -#define LED_SYSTEM_4_HZ 2 -#define LED_SYSTEM_1_HZ 1 - -#define LED_FAN_H 4 -#define LED_FAN_REGISTER 0xA165 -#define LED_ALARM_H 2 -#define LED_PSU_H 3 -#define NELEMS(x) (sizeof(x) / sizeof((x)[0])) - -#define ONLP_SENSOR_CACHE_SHARED "/onlp-sensor-cache-shared" -#define ONLP_FRU_CACHE_SHARED "/onlp-fru-cache-shared" -#define ONLP_SENSOR_LIST_CACHE_SHARED "/onlp-sensor-list-cache-shared" - -#define ONLP_SENSOR_CACHE_SEM "/onlp-sensor-cache-sem" -#define ONLP_FRU_CACHE_SEM "/onlp-fru-cache-sem" -#define ONLP_SENSOR_LIST_SEM "/onlp-sensor-list-cache-sem" - -#define ONLP_SENSOR_CACHE_FILE "/tmp/onlp-sensor-cache.txt" -#define ONLP_FRU_CACHE_FILE "/tmp/onlp-fru-cache.txt" -#define ONLP_SENSOR_LIST_FILE "/tmp/onlp-sensor-list-cache.txt" - -#define PSUL_ID 1 -#define PSUR_ID 2 - -#define NUM_OF_CPLD 1 - -#define USE_SHM_METHOD 0 - -struct shm_map_data{ - char data[16384]; - int size; -}; - -struct device_info{ - char serial_number[256]; - char model[256]; - int airflow; -}; - -struct fan_config_p{ - uint16_t pwm_reg; - uint16_t ctrl_sta_reg; - uint16_t rear_spd_reg; - uint16_t front_spd_reg; -}; - -struct led_reg_mapper{ - char *name; - uint16_t device; - uint16_t dev_reg; -}; - -struct psu_reg_bit_mapper{ - uint16_t sta_reg; - uint8_t bit_present; - uint8_t bit_ac_sta; - uint8_t bit_pow_sta; -}; - -struct search_psu_sdr_info_mapper{ - char* keyword; - char unit; -}; - -typedef struct psuInfo_p -{ - unsigned int lvin; - unsigned int liin; - unsigned int lvout; - unsigned int liout; - unsigned int lpout; - unsigned int lpin; - unsigned int ltemp; - - unsigned int rvin; - unsigned int riin; - unsigned int rvout; - unsigned int riout; - unsigned int rpout; - unsigned int rpin; - unsigned int rtemp; -}psuInfo_p; - -#define SYS_CPLD_PATH "/sys/devices/platform/sys_cpld/" -#define PLATFORM_PATH "/sys/devices/platform/cls-xcvr/" -#define I2C_DEVICE_PATH "/sys/bus/i2c/devices/" -#define PREFIX_PATH_ON_SYS_EEPROM "/sys/bus/i2c/devices/i2c-0/0-0056/eeprom" - -uint8_t get_led_status(int id); -int get_psu_model_sn(int id,char* model,char* serial_number); - -int get_psu_info(int id,int *mvin,int *mvout,int *mpin,int *mpout,int *miin,int *miout); -char* trim (char *s); -int get_fan_info(int id,char* model,char* serial,int *get_fan_info); -int get_sensor_info(int id, int *temp, int *warn, int *error, int *shutdown); -int read_device_node_binary(char *filename, char *buffer, int buf_size, int data_len); -int read_device_node_string(char *filename, char *buffer, int buf_size, int data_len); -int get_fan_speed(int id,int* per,int* rpm); -uint8_t get_psu_status(int id); -int dump_shared_memory(const char *shm_path, const char *sem_path, struct shm_map_data *shared_mem); -int fill_shared_memory(const char *shm_path, const char *sem_path, const char *cache_path); -int open_file(const char *shm_path, const char *sem_path, char **cache_data, int *cache_size); -int create_cache(); -void update_shm_mem(void); -int is_cache_exist(); - -#define DEBUG_MODE 0 - -#if (DEBUG_MODE == 1) - #define DEBUG_PRINT(format, ...) printf(format, __VA_ARGS__) -#else - #define DEBUG_PRINT(format, ...) -#endif - -#endif /* _PLATFORM_SEASTONE_H_ */ diff --git a/packages/platforms/celestica/x86-64/silverstone/onlp/builds/x86_64_cel_silverstone/module/src/psui.c b/packages/platforms/celestica/x86-64/silverstone/onlp/builds/x86_64_cel_silverstone/module/src/psui.c deleted file mode 100644 index b676ac6a5..000000000 --- a/packages/platforms/celestica/x86-64/silverstone/onlp/builds/x86_64_cel_silverstone/module/src/psui.c +++ /dev/null @@ -1,83 +0,0 @@ -#include -#include "platform.h" - -static onlp_psu_info_t psu_info[] = - { - {}, - { - {ONLP_PSU_ID_CREATE(PSUL_ID), "PSU-Left", 0}, - "", - "", - 0, - ONLP_PSU_CAPS_AC | ONLP_PSU_CAPS_VIN | ONLP_PSU_CAPS_VOUT | ONLP_PSU_CAPS_IIN | ONLP_PSU_CAPS_IOUT | ONLP_PSU_CAPS_PIN | ONLP_PSU_CAPS_POUT, - }, - { - {ONLP_PSU_ID_CREATE(PSUR_ID), "PSU-Right", 0}, - "", - "", - 0, - ONLP_PSU_CAPS_AC | ONLP_PSU_CAPS_VIN | ONLP_PSU_CAPS_VOUT | ONLP_PSU_CAPS_IIN | ONLP_PSU_CAPS_IOUT | ONLP_PSU_CAPS_PIN | ONLP_PSU_CAPS_POUT, - }}; - -static const struct psu_reg_bit_mapper psu_mapper[PSU_COUNT + 1] = { - {}, - {0xa160, 3, 7, 1}, - {0xa160, 2, 6, 0}, -}; - -uint8_t psu_status = 0; - -struct psuInfo_p temp_info[] = { - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}}; - -int onlp_psui_init(void) -{ - return ONLP_STATUS_OK; -} - -int onlp_psui_info_get(onlp_oid_t id, onlp_psu_info_t *info_p) -{ - int psu_id,psu_offset=0;; - psu_id = ONLP_OID_ID_GET(id); - *info_p = psu_info[psu_id]; - - int present_status=0,ac_status=0,pow_status=0; - - if(psu_status == 0) - psu_status = get_psu_status(psu_id); - - present_status = (psu_status >> psu_mapper[psu_id].bit_present) & 0x01; - ac_status = (psu_status >> psu_mapper[psu_id].bit_ac_sta) & 0x01; - pow_status = (psu_status >> psu_mapper[psu_id].bit_pow_sta) & 0x01; - - if (!present_status) - { - info_p->status |= ONLP_PSU_STATUS_PRESENT; - if (!(ac_status && pow_status)) - info_p->status = ONLP_PSU_STATUS_FAILED; - } - else - { - info_p->status |= ONLP_PSU_STATUS_UNPLUGGED; - } - - get_psu_model_sn(psu_id,info_p->model,info_p->serial); - - get_psu_info(psu_id,&(info_p->mvin),&(info_p->mvout),&(info_p->mpin),&(info_p->mpout),&(info_p->miin),&(info_p->miout)); - - if((info_p->mvin == 0) && (info_p->mpin == 0) && (info_p->miin == 0)){ - info_p->status |= ONLP_PSU_STATUS_UNPLUGGED; - } - - if(psu_id == 1){ - psu_offset = 1; - }else if(psu_id == 2){ - psu_offset = 3; - } - - info_p->hdr.coids[0] = ONLP_THERMAL_ID_CREATE(psu_offset + CHASSIS_THERMAL_COUNT); - info_p->hdr.coids[1] = ONLP_THERMAL_ID_CREATE(psu_offset+1 + CHASSIS_THERMAL_COUNT); - info_p->hdr.coids[2] = ONLP_FAN_ID_CREATE(psu_id + CHASSIS_FAN_COUNT); - - return ONLP_STATUS_OK; -} diff --git a/packages/platforms/celestica/x86-64/silverstone/onlp/builds/x86_64_cel_silverstone/module/src/sfpi.c b/packages/platforms/celestica/x86-64/silverstone/onlp/builds/x86_64_cel_silverstone/module/src/sfpi.c deleted file mode 100644 index 83c1a6e98..000000000 --- a/packages/platforms/celestica/x86-64/silverstone/onlp/builds/x86_64_cel_silverstone/module/src/sfpi.c +++ /dev/null @@ -1,212 +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 -#include "x86_64_cel_silverstone_log.h" -#include "platform.h" - -static int qsfp_count__ = 32; -static int sfp_count__ = 2; -static int i2c_bus_offset = 9; -static char node_path[PREFIX_PATH_LEN] = {0}; -char command[256]; -char buf[256]; -FILE *fp; - -static int cel_silverstone_qsfp_sfp_node_read_int(char *path, int *value, int data_len) -{ - int ret = 0; - char buf[8]; - *value = 0; - - ret = read_device_node_string(path, buf, sizeof(buf), data_len); - if (ret == 0) { - int is_not_present = atoi(buf); - if (!is_not_present) - { - *value = !is_not_present; - } - } - return ret; -} - -static char * cel_silverstone_sfp_qsfp_get_port_path(int port, char *node_name) -{ - if (port <= qsfp_count__ + sfp_count__) - { - if (port <= qsfp_count__) - { - sprintf(node_path, "%s/QSFP%d/qsfp_modprsL", PLATFORM_PATH, port); - } - else - { - sprintf(node_path, "%s/SFP%d/sfp_modabs", PLATFORM_PATH, port - qsfp_count__); - } - } - else - { - AIM_LOG_ERROR("Number of port config is mismatch port(%d)\r\n", port); - return ""; - } - - return node_path; -} - -static char * cel_silverstone_sfp_qsfp_get_eeprom_path(int port, char *node_name) -{ - if (port <= qsfp_count__ + sfp_count__) - { - if (port <= qsfp_count__) - { - sprintf(node_path, "%s/%d-0050/eeprom", I2C_DEVICE_PATH, port + i2c_bus_offset); //QSFP 10 - 41 - } - else - { - sprintf(node_path, "%s/%d-0050/eeprom", I2C_DEVICE_PATH, port - qsfp_count__); //SFP 1 - 2 - } - } - else - { - AIM_LOG_ERROR("Number of port config is mismatch port(%d)\r\n", port); - return ""; - } - - return node_path; -} - -static uint64_t cel_silverstone_sfp_qsfp_get_all_ports_present(void) -{ - int i, ret; - uint64_t present = 0; - char *path; - - for (i = 0; i < (qsfp_count__ + sfp_count__); i++) - { - path = cel_silverstone_sfp_qsfp_get_port_path(i + 1, "present"); - if (cel_silverstone_qsfp_sfp_node_read_int(path, &ret, 0) != 0) - { - ret = 0; - } - present |= ((uint64_t)ret << i); - } - - return present; -} - -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 = 0; p < (qsfp_count__ + sfp_count__); p++) - { - AIM_BITMAP_SET(bmap, p); - } - - return ONLP_STATUS_OK; -} - -/* -* Return 1 if present. -* Return 0 if not present. -* Return < 0 if error. -*/ -int onlp_sfpi_is_present(int port) -{ - int present; - char *path = cel_silverstone_sfp_qsfp_get_port_path(port + 1, "present"); - if (cel_silverstone_qsfp_sfp_node_read_int(path, &present, 0) != 0) - { - if (port <= qsfp_count__) - { - AIM_LOG_ERROR("Unable to read present status from qsfp port(%d)\r\n", port); - } - else - { - AIM_LOG_ERROR("Unable to read present status from sfp port(%d)\r\n", port - qsfp_count__); - } - - return ONLP_STATUS_E_INTERNAL; - } - return present; -} - -int onlp_sfpi_presence_bitmap_get(onlp_sfp_bitmap_t *dst) -{ - int i = 0; - uint64_t presence_all = 0; - - presence_all = cel_silverstone_sfp_qsfp_get_all_ports_present(); - - /* Populate bitmap */ - for (i = 0; presence_all; i++) - { - AIM_BITMAP_MOD(dst, i, (presence_all & 1)); - presence_all >>= 1; - } - return ONLP_STATUS_OK; -} - -/* - * This function reads the SFPs idrom and returns in - * in the data buffer provided. - */ -int onlp_sfpi_eeprom_read(int port, uint8_t data[256]) -{ - char *path; - - path = cel_silverstone_sfp_qsfp_get_eeprom_path(port + 1, "eeprom"); - - /* - * Read the SFP eeprom into data[] - * - * Return MISSING if SFP is missing. - * Return OK if eeprom is read - */ - memset(data, 0, 256); - if (read_device_node_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; - } - - return ONLP_STATUS_OK; -} - -int onlp_sfpi_rx_los_bitmap_get(onlp_sfp_bitmap_t *dst) -{ - return ONLP_STATUS_OK; -} - -/* - * De-initialize the SFPI subsystem. - */ -int onlp_sfpi_denit(void) -{ - return ONLP_STATUS_OK; -} diff --git a/packages/platforms/celestica/x86-64/silverstone/onlp/builds/x86_64_cel_silverstone/module/src/sysi.c b/packages/platforms/celestica/x86-64/silverstone/onlp/builds/x86_64_cel_silverstone/module/src/sysi.c deleted file mode 100644 index c22a111e8..000000000 --- a/packages/platforms/celestica/x86-64/silverstone/onlp/builds/x86_64_cel_silverstone/module/src/sysi.c +++ /dev/null @@ -1,135 +0,0 @@ -#include -#include - -#include -#include -#include -#include -#include - -#include "x86_64_cel_silverstone_int.h" -#include "x86_64_cel_silverstone_log.h" -#include "platform.h" -//Below include add for support Cache system -#include -#include -#include -#include - -static char arr_cplddev_name[NUM_OF_CPLD][10] = -{ - "version" -}; - -const char *onlp_sysi_platform_get(void) -{ - return "x86-64-cel-silverstone-r0"; -} - -int onlp_sysi_init(void) -{ - return ONLP_STATUS_OK; -} - -int onlp_sysi_platform_info_get(onlp_platform_info_t *pi) -{ - int i, v[NUM_OF_CPLD] = {0}; - char r_data[10] = {0}; - char fullpath[PREFIX_PATH_LEN] = {0}; - - for (i = 0; i < NUM_OF_CPLD; i++) - { - memset(fullpath, 0, PREFIX_PATH_LEN); - sprintf(fullpath, "%s%s", SYS_CPLD_PATH, arr_cplddev_name[i]); - if (read_device_node_string(fullpath, r_data, sizeof(r_data), 0) != 0) - { - DEBUG_PRINT("%s(%d): read %s error\n", __FUNCTION__, __LINE__, fullpath); - return ONLP_STATUS_E_INTERNAL; - } - v[i] = strtol(r_data, NULL, 0); - } - pi->cpld_versions = aim_fstrdup("CPLD_B=0x%02x", v[0]); - return 0; -} - -void onlp_sysi_platform_info_free(onlp_platform_info_t *pi) -{ - aim_free(pi->cpld_versions); -} - -int onlp_sysi_onie_data_get(uint8_t **data, int *size) -{ - uint8_t *rdata = aim_zmalloc(256); - - if (onlp_file_read(rdata, 256, size, PREFIX_PATH_ON_SYS_EEPROM) == ONLP_STATUS_OK) - { - if (*size == 256) - { - *data = rdata; - return ONLP_STATUS_OK; - } - } - aim_free(rdata); - rdata = NULL; - *size = 0; - DEBUG_PRINT("[Debug][%s][%d][Can't get onie data]\n", __FUNCTION__, __LINE__); - return ONLP_STATUS_E_INTERNAL; -} - -void onlp_sysi_onie_data_free(uint8_t *data) -{ - aim_free(data); -} - -int onlp_sysi_platform_manage_init(void) -{ - if (is_cache_exist() < 1) - { - create_cache(); - } - return ONLP_STATUS_OK; -} - -int onlp_sysi_platform_manage_fans(void) -{ - if (is_cache_exist() < 1) - { - create_cache(); - } - return ONLP_STATUS_OK; -} - -int onlp_sysi_platform_manage_leds(void) -{ - if (is_cache_exist() < 1) - { - create_cache(); - } - return ONLP_STATUS_OK; -} - -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)); - - /* 2 PSUs */ - *e++ = ONLP_PSU_ID_CREATE(1); - *e++ = ONLP_PSU_ID_CREATE(2); - - // // /* LEDs Item */ - for (i = 1; i <= LED_COUNT; i++) - *e++ = ONLP_LED_ID_CREATE(i); - - // // /* THERMALs Item */ - for (i = 1; i <= CHASSIS_THERMAL_COUNT; i++) - *e++ = ONLP_THERMAL_ID_CREATE(i); - - // /* Fans Item */ - for (i = 1; i <= CHASSIS_FAN_COUNT; i++) - *e++ = ONLP_FAN_ID_CREATE(i); - - return ONLP_STATUS_OK; -} diff --git a/packages/platforms/celestica/x86-64/silverstone/onlp/builds/x86_64_cel_silverstone/module/src/thermali.c b/packages/platforms/celestica/x86-64/silverstone/onlp/builds/x86_64_cel_silverstone/module/src/thermali.c deleted file mode 100644 index 83c6e53ea..000000000 --- a/packages/platforms/celestica/x86-64/silverstone/onlp/builds/x86_64_cel_silverstone/module/src/thermali.c +++ /dev/null @@ -1,94 +0,0 @@ -#include -#include -#include -#include -#include -#include "platform.h" - -static onlp_thermal_info_t thermal_info[] = { - { }, - { { ONLP_THERMAL_ID_CREATE(1), "Temp_CPU", 0}, - ONLP_THERMAL_STATUS_PRESENT, - ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS - }, - { { ONLP_THERMAL_ID_CREATE(2), "TEMP_BB", 0}, - ONLP_THERMAL_STATUS_PRESENT, - ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS - }, - { { ONLP_THERMAL_ID_CREATE(3), "TEMP_SW_U16", 0}, - ONLP_THERMAL_STATUS_PRESENT, - ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS - }, - { { ONLP_THERMAL_ID_CREATE(4), "TEMP_SW_U52", 0}, - ONLP_THERMAL_STATUS_PRESENT, - ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS - }, - { { ONLP_THERMAL_ID_CREATE(5), "TEMP_FAN_U17", 0}, - ONLP_THERMAL_STATUS_PRESENT, - ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS - }, - { { ONLP_THERMAL_ID_CREATE(6), "TEMP_FAN_U52", 0}, - ONLP_THERMAL_STATUS_PRESENT, - ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS - }, - { { ONLP_THERMAL_ID_CREATE(7), "SW_U04_Temp", 0}, - ONLP_THERMAL_STATUS_PRESENT, - ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS - }, - { { ONLP_THERMAL_ID_CREATE(8), "SW_U14_Temp", 0}, - ONLP_THERMAL_STATUS_PRESENT, - ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS - }, - { { ONLP_THERMAL_ID_CREATE(9), "SW_U4403_Temp", 0}, - ONLP_THERMAL_STATUS_PRESENT, - ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS - }, - { { ONLP_THERMAL_ID_CREATE(10), "PSUL_Temp1", ONLP_PSU_ID_CREATE(1)}, - ONLP_THERMAL_STATUS_PRESENT, - ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS - }, - { { ONLP_THERMAL_ID_CREATE(11), "PSUL_Temp2", ONLP_PSU_ID_CREATE(1)}, - ONLP_THERMAL_STATUS_PRESENT, - ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS - }, - { { ONLP_THERMAL_ID_CREATE(12), "PSUR_Temp1", ONLP_PSU_ID_CREATE(2)}, - ONLP_THERMAL_STATUS_PRESENT, - ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS - }, - { { ONLP_THERMAL_ID_CREATE(13), "PSUR_Temp2", ONLP_PSU_ID_CREATE(2)}, - 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_p) -{ - int thermal_id; - int thermal_status = 0; - int temp, warn, err, shutdown; - - thermal_id = ONLP_OID_ID_GET(id); - memcpy(info_p, &thermal_info[thermal_id], sizeof(onlp_thermal_info_t)); - - /* Get thermal temperature. */ - thermal_status = get_sensor_info(thermal_id, &temp, &warn, &err, &shutdown); - if (-1 == thermal_status) - { - info_p->status = ONLP_THERMAL_STATUS_FAILED; - } - else - { - info_p->status = ONLP_THERMAL_STATUS_PRESENT; - info_p->mcelsius = temp; - info_p->thresholds.warning = warn; - info_p->thresholds.error = err; - info_p->thresholds.shutdown = shutdown; - } - - return ONLP_STATUS_OK; -} diff --git a/packages/platforms/celestica/x86-64/silverstone/onlp/builds/x86_64_cel_silverstone/module/src/x86_64_cel_silverstone_config.c b/packages/platforms/celestica/x86-64/silverstone/onlp/builds/x86_64_cel_silverstone/module/src/x86_64_cel_silverstone_config.c deleted file mode 100644 index ae30befa5..000000000 --- a/packages/platforms/celestica/x86-64/silverstone/onlp/builds/x86_64_cel_silverstone/module/src/x86_64_cel_silverstone_config.c +++ /dev/null @@ -1,76 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#include - -/* */ -#define __x86_64_cel_silverstone_config_STRINGIFY_NAME(_x) #_x -#define __x86_64_cel_silverstone_config_STRINGIFY_VALUE(_x) __x86_64_cel_silverstone_config_STRINGIFY_NAME(_x) -x86_64_cel_silverstone_config_settings_t x86_64_cel_silverstone_config_settings[] = -{ -#ifdef X86_64_CEL_SILVERSTONE_CONFIG_INCLUDE_LOGGING - { __x86_64_cel_silverstone_config_STRINGIFY_NAME(X86_64_CEL_SILVERSTONE_CONFIG_INCLUDE_LOGGING), __x86_64_cel_silverstone_config_STRINGIFY_VALUE(X86_64_CEL_SILVERSTONE_CONFIG_INCLUDE_LOGGING) }, -#else -{ X86_64_CEL_SILVERSTONE_CONFIG_INCLUDE_LOGGING(__x86_64_cel_silverstone_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_CEL_SILVERSTONE_CONFIG_LOG_OPTIONS_DEFAULT - { __x86_64_cel_silverstone_config_STRINGIFY_NAME(X86_64_CEL_SILVERSTONE_CONFIG_LOG_OPTIONS_DEFAULT), __x86_64_cel_silverstone_config_STRINGIFY_VALUE(X86_64_CEL_SILVERSTONE_CONFIG_LOG_OPTIONS_DEFAULT) }, -#else -{ X86_64_CEL_SILVERSTONE_CONFIG_LOG_OPTIONS_DEFAULT(__x86_64_cel_silverstone_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_CEL_SILVERSTONE_CONFIG_LOG_BITS_DEFAULT - { __x86_64_cel_silverstone_config_STRINGIFY_NAME(X86_64_CEL_SILVERSTONE_CONFIG_LOG_BITS_DEFAULT), __x86_64_cel_silverstone_config_STRINGIFY_VALUE(X86_64_CEL_SILVERSTONE_CONFIG_LOG_BITS_DEFAULT) }, -#else -{ X86_64_CEL_SILVERSTONE_CONFIG_LOG_BITS_DEFAULT(__x86_64_cel_silverstone_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_CEL_SILVERSTONE_CONFIG_LOG_CUSTOM_BITS_DEFAULT - { __x86_64_cel_silverstone_config_STRINGIFY_NAME(X86_64_CEL_SILVERSTONE_CONFIG_LOG_CUSTOM_BITS_DEFAULT), __x86_64_cel_silverstone_config_STRINGIFY_VALUE(X86_64_CEL_SILVERSTONE_CONFIG_LOG_CUSTOM_BITS_DEFAULT) }, -#else -{ X86_64_CEL_SILVERSTONE_CONFIG_LOG_CUSTOM_BITS_DEFAULT(__x86_64_cel_silverstone_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_CEL_SILVERSTONE_CONFIG_PORTING_STDLIB - { __x86_64_cel_silverstone_config_STRINGIFY_NAME(X86_64_CEL_SILVERSTONE_CONFIG_PORTING_STDLIB), __x86_64_cel_silverstone_config_STRINGIFY_VALUE(X86_64_CEL_SILVERSTONE_CONFIG_PORTING_STDLIB) }, -#else -{ X86_64_CEL_SILVERSTONE_CONFIG_PORTING_STDLIB(__x86_64_cel_silverstone_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_CEL_SILVERSTONE_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS - { __x86_64_cel_silverstone_config_STRINGIFY_NAME(X86_64_CEL_SILVERSTONE_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS), __x86_64_cel_silverstone_config_STRINGIFY_VALUE(X86_64_CEL_SILVERSTONE_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS) }, -#else -{ X86_64_CEL_SILVERSTONE_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS(__x86_64_cel_silverstone_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_CEL_SILVERSTONE_CONFIG_INCLUDE_UCLI - { __x86_64_cel_silverstone_config_STRINGIFY_NAME(X86_64_CEL_SILVERSTONE_CONFIG_INCLUDE_UCLI), __x86_64_cel_silverstone_config_STRINGIFY_VALUE(X86_64_CEL_SILVERSTONE_CONFIG_INCLUDE_UCLI) }, -#else -{ X86_64_CEL_SILVERSTONE_CONFIG_INCLUDE_UCLI(__x86_64_cel_silverstone_config_STRINGIFY_NAME), "__undefined__" }, -#endif - { NULL, NULL } -}; -#undef __x86_64_cel_silverstone_config_STRINGIFY_VALUE -#undef __x86_64_cel_silverstone_config_STRINGIFY_NAME - -const char* -x86_64_cel_silverstone_config_lookup(const char* setting) -{ - int i; - for(i = 0; x86_64_cel_silverstone_config_settings[i].name; i++) { - if(strcmp(x86_64_cel_silverstone_config_settings[i].name, setting)) { - return x86_64_cel_silverstone_config_settings[i].value; - } - } - return NULL; -} - -int -x86_64_cel_silverstone_config_show(struct aim_pvs_s* pvs) -{ - int i; - for(i = 0; x86_64_cel_silverstone_config_settings[i].name; i++) { - aim_printf(pvs, "%s = %s\n", x86_64_cel_silverstone_config_settings[i].name, x86_64_cel_silverstone_config_settings[i].value); - } - return i; -} - -/* */ - diff --git a/packages/platforms/celestica/x86-64/silverstone/onlp/builds/x86_64_cel_silverstone/module/src/x86_64_cel_silverstone_enums.c b/packages/platforms/celestica/x86-64/silverstone/onlp/builds/x86_64_cel_silverstone/module/src/x86_64_cel_silverstone_enums.c deleted file mode 100644 index 44438e22c..000000000 --- a/packages/platforms/celestica/x86-64/silverstone/onlp/builds/x86_64_cel_silverstone/module/src/x86_64_cel_silverstone_enums.c +++ /dev/null @@ -1,6 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#include \ No newline at end of file diff --git a/packages/platforms/celestica/x86-64/silverstone/onlp/builds/x86_64_cel_silverstone/module/src/x86_64_cel_silverstone_int.h b/packages/platforms/celestica/x86-64/silverstone/onlp/builds/x86_64_cel_silverstone/module/src/x86_64_cel_silverstone_int.h deleted file mode 100644 index 7e4159301..000000000 --- a/packages/platforms/celestica/x86-64/silverstone/onlp/builds/x86_64_cel_silverstone/module/src/x86_64_cel_silverstone_int.h +++ /dev/null @@ -1,11 +0,0 @@ -/**************************************************************************//** - * - * x86_64_cel_silverstone Internal Header - * - *****************************************************************************/ -#ifndef __X86_64_CEL_SILVERSTONE_INT_H__ -#define __X86_64_CEL_SILVERSTONE_INT_H__ - -#include - -#endif /* __X86_64_CEL_SILVERSTONE_INT_H__ */ \ No newline at end of file diff --git a/packages/platforms/celestica/x86-64/silverstone/onlp/builds/x86_64_cel_silverstone/module/src/x86_64_cel_silverstone_log.c b/packages/platforms/celestica/x86-64/silverstone/onlp/builds/x86_64_cel_silverstone/module/src/x86_64_cel_silverstone_log.c deleted file mode 100644 index ae32d0ee9..000000000 --- a/packages/platforms/celestica/x86-64/silverstone/onlp/builds/x86_64_cel_silverstone/module/src/x86_64_cel_silverstone_log.c +++ /dev/null @@ -1,18 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#include - -#include "x86_64_cel_silverstone_log.h" -/* - * x86_64_cel_silverstone log struct. - */ -AIM_LOG_STRUCT_DEFINE( - X86_64_CEL_SILVERSTONE_CONFIG_LOG_OPTIONS_DEFAULT, - X86_64_CEL_SILVERSTONE_CONFIG_LOG_BITS_DEFAULT, - NULL, /* Custom log map */ - X86_64_CEL_SILVERSTONE_CONFIG_LOG_CUSTOM_BITS_DEFAULT - ); - diff --git a/packages/platforms/celestica/x86-64/silverstone/onlp/builds/x86_64_cel_silverstone/module/src/x86_64_cel_silverstone_log.h b/packages/platforms/celestica/x86-64/silverstone/onlp/builds/x86_64_cel_silverstone/module/src/x86_64_cel_silverstone_log.h deleted file mode 100644 index 49cdbeb26..000000000 --- a/packages/platforms/celestica/x86-64/silverstone/onlp/builds/x86_64_cel_silverstone/module/src/x86_64_cel_silverstone_log.h +++ /dev/null @@ -1,12 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#ifndef __X86_64_CEL_SILVERSTONE_LOG_H__ -#define __X86_64_CEL_SILVERSTONE_LOG_H__ - -#define AIM_LOG_MODULE_NAME x86_64_cel_silverstone -#include - -#endif /* __X86_64_CEL_SILVERSTONE_LOG_H__ */ diff --git a/packages/platforms/celestica/x86-64/silverstone/onlp/builds/x86_64_cel_silverstone/module/src/x86_64_cel_silverstone_module.c b/packages/platforms/celestica/x86-64/silverstone/onlp/builds/x86_64_cel_silverstone/module/src/x86_64_cel_silverstone_module.c deleted file mode 100644 index 9554526bf..000000000 --- a/packages/platforms/celestica/x86-64/silverstone/onlp/builds/x86_64_cel_silverstone/module/src/x86_64_cel_silverstone_module.c +++ /dev/null @@ -1,24 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#include - -#include "x86_64_cel_silverstone_log.h" - -static int -datatypes_init__(void) -{ -#define X86_64_CEL_SILVERSTONE_ENUMERATION_ENTRY(_enum_name, _desc) AIM_DATATYPE_MAP_REGISTER(_enum_name, _enum_name##_map, _desc, AIM_LOG_INTERNAL); -#include - return 0; -} - -void __x86_64_cel_silverstone_module_init__(void) -{ - AIM_LOG_STRUCT_REGISTER(); - datatypes_init__(); -} - -int __onlp_platform_version__ = 1; diff --git a/packages/platforms/celestica/x86-64/silverstone/onlp/builds/x86_64_cel_silverstone/module/src/x86_64_cel_silverstone_ucli.c b/packages/platforms/celestica/x86-64/silverstone/onlp/builds/x86_64_cel_silverstone/module/src/x86_64_cel_silverstone_ucli.c deleted file mode 100644 index cfd43cb1c..000000000 --- a/packages/platforms/celestica/x86-64/silverstone/onlp/builds/x86_64_cel_silverstone/module/src/x86_64_cel_silverstone_ucli.c +++ /dev/null @@ -1,50 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#include - -#if X86_64_CEL_SILVERSTONE_CONFIG_INCLUDE_UCLI == 1 - -#include -#include -#include - -static ucli_status_t -x86_64_cel_silverstone_ucli_ucli__config__(ucli_context_t* uc) -{ - UCLI_HANDLER_MACRO_MODULE_CONFIG(x86_64_cel_silverstone) -} - -/* */ -/* */ - -static ucli_module_t -x86_64_cel_silverstone_ucli_module__ = - { - "x86_64_cel_silverstone_ucli", - NULL, - x86_64_cel_silverstone_ucli_ucli_handlers__, - NULL, - NULL, - }; - -ucli_node_t* -x86_64_cel_silverstone_ucli_node_create(void) -{ - ucli_node_t* n; - ucli_module_init(&x86_64_cel_silverstone_ucli_module__); - n = ucli_node_create("x86_64_cel_silverstone", NULL, &x86_64_cel_silverstone_ucli_module__); - ucli_node_subnode_add(n, ucli_module_log_node_create("x86_64_cel_silverstone")); - return n; -} - -#else -void* -x86_64_cel_silverstone_ucli_node_create(void) -{ - return NULL; -} -#endif - diff --git a/packages/platforms/celestica/x86-64/silverstone/platform-config/Makefile b/packages/platforms/celestica/x86-64/silverstone/platform-config/Makefile deleted file mode 100755 index dc1e7b86f..000000000 --- a/packages/platforms/celestica/x86-64/silverstone/platform-config/Makefile +++ /dev/null @@ -1 +0,0 @@ -include $(ONL)/make/pkg.mk diff --git a/packages/platforms/celestica/x86-64/silverstone/platform-config/r0/Makefile b/packages/platforms/celestica/x86-64/silverstone/platform-config/r0/Makefile deleted file mode 100755 index dc1e7b86f..000000000 --- a/packages/platforms/celestica/x86-64/silverstone/platform-config/r0/Makefile +++ /dev/null @@ -1 +0,0 @@ -include $(ONL)/make/pkg.mk diff --git a/packages/platforms/celestica/x86-64/silverstone/platform-config/r0/PKG.yml b/packages/platforms/celestica/x86-64/silverstone/platform-config/r0/PKG.yml deleted file mode 100755 index d8ca5707b..000000000 --- a/packages/platforms/celestica/x86-64/silverstone/platform-config/r0/PKG.yml +++ /dev/null @@ -1 +0,0 @@ -!include $ONL_TEMPLATES/platform-config-platform.yml ARCH=amd64 VENDOR=celestica BASENAME=x86-64-cel-silverstone REVISION=r0 diff --git a/packages/platforms/celestica/x86-64/silverstone/platform-config/r0/src/lib/x86-64-cel-silverstone-r0.yml b/packages/platforms/celestica/x86-64/silverstone/platform-config/r0/src/lib/x86-64-cel-silverstone-r0.yml deleted file mode 100755 index 2edfca683..000000000 --- a/packages/platforms/celestica/x86-64/silverstone/platform-config/r0/src/lib/x86-64-cel-silverstone-r0.yml +++ /dev/null @@ -1,45 +0,0 @@ ---- - -###################################################################### -# -# platform-config for Silverstone -# -###################################################################### - -x86-64-cel-silverstone-r0: - - grub: - - serial: >- - --port=0x3f8 - --speed=115200 - --word=8 - --parity=no - --stop=1 - - kernel: - <<: *kernel-4-14 - - args: >- - nopat - console=ttyS0,115200n8 - - installer: - - ONL-BOOT: - =: 128MiB - format: ext4 - - ONL-CONFIG: - =: 128MiB - format: ext4 - - ONL-IMAGES: - =: 1GiB - format: ext4 - - ONL-DATA: - =: 3GiB - format: ext4 - - ##network: - ## interfaces: - ## ma1: - ## name: ~ - ## syspath: pci0000:00/0000:00:14.0 diff --git a/packages/platforms/celestica/x86-64/silverstone/platform-config/r0/src/python/x86_64_cel_silverstone_r0/__init__.py b/packages/platforms/celestica/x86-64/silverstone/platform-config/r0/src/python/x86_64_cel_silverstone_r0/__init__.py deleted file mode 100755 index bea081149..000000000 --- a/packages/platforms/celestica/x86-64/silverstone/platform-config/r0/src/python/x86_64_cel_silverstone_r0/__init__.py +++ /dev/null @@ -1,67 +0,0 @@ -from onl.platform.base import * -from onl.platform.celestica import * - -class OnlPlatform_x86_64_cel_silverstone_r0(OnlPlatformCelestica, - OnlPlatformPortConfig_32x400_2x10): - PLATFORM='x86-64-cel-silverstone-r0' - MODEL="silverstone" - SYS_OBJECT_ID=".2060.1" - - def baseconfig(self): - onlp_interval_time = 30 #second - file_path = "/var/opt/interval_time.txt" - - print("Initialize Silverstone driver") - - qsfp_qty = 32 - sfp_qty = 2 - qsfp_offset = 9 - actual_port_num = 1 - - self.insmod("i2c-ocores.ko") - self.insmod("i2c-cls.ko") - self.insmod("cls-switchboard.ko") - self.insmod("cpld_b.ko") - self.insmod("switchboard-diag.ko") - self.insmod("mc24lc64t.ko") - self.insmod("optoe.ko") - self.insmod("xcvr-cls.ko") - - #tlv eeprom device - self.new_i2c_device('24lc64t', 0x56, 0) - - #transceiver device - for x in range(sfp_qty): - self.new_i2c_device('optoe2',0x50,x+1) - os.system("echo 'SFP{1}' > /sys/bus/i2c/devices/{0}-0050/port_name".format(x+1,actual_port_num)) - actual_port_num += 1 - - actual_port_num = 1 - - for y in range(qsfp_qty): - self.new_i2c_device('optoe3',0x50,qsfp_offset+y+1) - os.system("echo 'QSFP{1}' > /sys/bus/i2c/devices/{0}-0050/port_name".format(qsfp_offset+y+1,actual_port_num)) - actual_port_num += 1 - - os.system("echo '3' > /proc/sys/kernel/printk") - - if os.path.exists(file_path): - pass - else: - with open(file_path, 'w') as f: - f.write("{0}\r\n".format(onlp_interval_time)) - f.close() - - #Prevent ONL take a long waiting time at Waiting for /dev to be fully populated... step when boot-up - rulefilepath = "/etc/udev/rules.d/70-persistent-net.rules" - if os.path.exists(rulefilepath): - os.system("rm {0}".format(rulefilepath)) - else: - pass - - #initialize onlp cache files - print("Initialize ONLP Cache files") - os.system("ipmitool fru > /tmp/onlp-fru-cache.tmp; sync; rm -f /tmp/onlp-fru-cache.txt; mv /tmp/onlp-fru-cache.tmp /tmp/onlp-fru-cache.txt") - os.system("ipmitool sensor list > /tmp/onlp-sensor-list-cache.tmp; sync; rm -f /tmp/onlp-sensor-list-cache.txt; mv /tmp/onlp-sensor-list-cache.tmp /tmp/onlp-sensor-list-cache.txt") - - return True diff --git a/packages/platforms/dell/Makefile b/packages/platforms/dell/Makefile deleted file mode 100644 index 003238cf6..000000000 --- a/packages/platforms/dell/Makefile +++ /dev/null @@ -1 +0,0 @@ -include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/dell/vendor-config/Makefile b/packages/platforms/dell/vendor-config/Makefile deleted file mode 100644 index 003238cf6..000000000 --- a/packages/platforms/dell/vendor-config/Makefile +++ /dev/null @@ -1 +0,0 @@ -include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/dell/vendor-config/PKG.yml b/packages/platforms/dell/vendor-config/PKG.yml deleted file mode 100644 index e4a67be4d..000000000 --- a/packages/platforms/dell/vendor-config/PKG.yml +++ /dev/null @@ -1 +0,0 @@ -!include $ONL/packages/base/any/templates/platform-config-vendor.yml VENDOR=dell Vendor=Dell diff --git a/packages/platforms/dell/vendor-config/src/python/dell/__init__.py b/packages/platforms/dell/vendor-config/src/python/dell/__init__.py deleted file mode 100644 index 3b69223ef..000000000 --- a/packages/platforms/dell/vendor-config/src/python/dell/__init__.py +++ /dev/null @@ -1,7 +0,0 @@ -#!/usr/bin/python - -from onl.platform.base import * - -class OnlPlatformDell(OnlPlatformBase): - MANUFACTURER='Dell' - PRIVATE_ENTERPRISE_NUMBER=674 diff --git a/packages/platforms/dellemc/Makefile b/packages/platforms/dellemc/Makefile deleted file mode 100644 index 003238cf6..000000000 --- a/packages/platforms/dellemc/Makefile +++ /dev/null @@ -1 +0,0 @@ -include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/dellemc/vendor-config/Makefile b/packages/platforms/dellemc/vendor-config/Makefile deleted file mode 100644 index 003238cf6..000000000 --- a/packages/platforms/dellemc/vendor-config/Makefile +++ /dev/null @@ -1 +0,0 @@ -include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/dellemc/vendor-config/PKG.yml b/packages/platforms/dellemc/vendor-config/PKG.yml deleted file mode 100644 index 971a145ef..000000000 --- a/packages/platforms/dellemc/vendor-config/PKG.yml +++ /dev/null @@ -1 +0,0 @@ -!include $ONL/packages/base/any/templates/platform-config-vendor.yml VENDOR=dellemc Vendor=DellEMC diff --git a/packages/platforms/dellemc/vendor-config/src/python/dellemc/__init__.py b/packages/platforms/dellemc/vendor-config/src/python/dellemc/__init__.py deleted file mode 100644 index 02e877ec7..000000000 --- a/packages/platforms/dellemc/vendor-config/src/python/dellemc/__init__.py +++ /dev/null @@ -1,7 +0,0 @@ -#!/usr/bin/python - -from onl.platform.base import * - -class OnlPlatformDellEMC(OnlPlatformBase): - MANUFACTURER='DellEMC' - PRIVATE_ENTERPRISE_NUMBER=674 diff --git a/packages/platforms/ingrasys/Makefile b/packages/platforms/ingrasys/Makefile deleted file mode 100755 index 003238cf6..000000000 --- a/packages/platforms/ingrasys/Makefile +++ /dev/null @@ -1 +0,0 @@ -include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/ingrasys/vendor-config/Makefile b/packages/platforms/ingrasys/vendor-config/Makefile deleted file mode 100755 index 003238cf6..000000000 --- a/packages/platforms/ingrasys/vendor-config/Makefile +++ /dev/null @@ -1 +0,0 @@ -include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/ingrasys/vendor-config/PKG.yml b/packages/platforms/ingrasys/vendor-config/PKG.yml deleted file mode 100755 index 3c21bbc5c..000000000 --- a/packages/platforms/ingrasys/vendor-config/PKG.yml +++ /dev/null @@ -1 +0,0 @@ -!include $ONL_TEMPLATES/platform-config-vendor.yml VENDOR=ingrasys Vendor=Ingrasys diff --git a/packages/platforms/ingrasys/vendor-config/src/python/ingrasys/__init__.py b/packages/platforms/ingrasys/vendor-config/src/python/ingrasys/__init__.py deleted file mode 100755 index d18f63299..000000000 --- a/packages/platforms/ingrasys/vendor-config/src/python/ingrasys/__init__.py +++ /dev/null @@ -1,7 +0,0 @@ -#!/usr/bin/python - -from onl.platform.base import * - -class OnlPlatformIngrasys(OnlPlatformBase): - MANUFACTURER='Ingrasys' - PRIVATE_ENTERPRISE_NUMBER=2468 diff --git a/packages/platforms/ingrasys/x86-64/Makefile b/packages/platforms/ingrasys/x86-64/Makefile deleted file mode 100755 index 003238cf6..000000000 --- a/packages/platforms/ingrasys/x86-64/Makefile +++ /dev/null @@ -1 +0,0 @@ -include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/ingrasys/x86-64/modules/Makefile b/packages/platforms/ingrasys/x86-64/modules/Makefile deleted file mode 100755 index 003238cf6..000000000 --- a/packages/platforms/ingrasys/x86-64/modules/Makefile +++ /dev/null @@ -1 +0,0 @@ -include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/ingrasys/x86-64/modules/PKG.yml b/packages/platforms/ingrasys/x86-64/modules/PKG.yml deleted file mode 100755 index 74f7e1b12..000000000 --- a/packages/platforms/ingrasys/x86-64/modules/PKG.yml +++ /dev/null @@ -1 +0,0 @@ -!include $ONL_TEMPLATES/arch-vendor-modules.yml ARCH=amd64 VENDOR=ingrasys KERNELS="onl-kernel-3.16-lts-x86-64-all:amd64" \ No newline at end of file diff --git a/packages/platforms/ingrasys/x86-64/modules/builds/.gitignore b/packages/platforms/ingrasys/x86-64/modules/builds/.gitignore deleted file mode 100644 index a65b41774..000000000 --- a/packages/platforms/ingrasys/x86-64/modules/builds/.gitignore +++ /dev/null @@ -1 +0,0 @@ -lib diff --git a/packages/platforms/ingrasys/x86-64/modules/builds/Makefile b/packages/platforms/ingrasys/x86-64/modules/builds/Makefile deleted file mode 100755 index f08898aa4..000000000 --- a/packages/platforms/ingrasys/x86-64/modules/builds/Makefile +++ /dev/null @@ -1,6 +0,0 @@ -KERNELS := onl-kernel-3.16-lts-x86-64-all:amd64 -KMODULES := $(wildcard *.c) -VENDOR := ingrasys -BASENAME := common -ARCH := x86_64 -include $(ONL)/make/kmodule.mk diff --git a/packages/platforms/ingrasys/x86-64/modules/builds/eeprom_mb.c b/packages/platforms/ingrasys/x86-64/modules/builds/eeprom_mb.c deleted file mode 100755 index 528864d93..000000000 --- a/packages/platforms/ingrasys/x86-64/modules/builds/eeprom_mb.c +++ /dev/null @@ -1,267 +0,0 @@ -/* - * Copyright (C) 1998, 1999 Frodo Looijaard and - * Philip Edelbrock - * Copyright (C) 2003 Greg Kroah-Hartman - * Copyright (C) 2003 IBM Corp. - * Copyright (C) 2004 Jean Delvare - * - * 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. - */ - -/* enable dev_dbg print out */ -//#define DEBUG - -#include -#include -#include -#include -#include -#include -#include - -/* Addresses to scan */ -static const unsigned short normal_i2c[] = { /*0x50, 0x51, 0x52, 0x53, 0x54, - 0x55, 0x56, 0x57,*/ I2C_CLIENT_END }; - -/* Size of EEPROM in bytes */ -#define EEPROM_SIZE 512 - -#define SLICE_BITS (6) -#define SLICE_SIZE (1 << SLICE_BITS) -#define SLICE_NUM (EEPROM_SIZE/SLICE_SIZE) - -/* Each client has this additional data */ -struct eeprom_data { - struct mutex update_lock; - u8 valid; /* bitfield, bit!=0 if slice is valid */ - unsigned long last_updated[SLICE_NUM]; /* In jiffies, 8 slices */ - u8 data[EEPROM_SIZE]; /* Register values */ -}; - - -static void mb_eeprom_update_client(struct i2c_client *client, u8 slice) -{ - struct eeprom_data *data = i2c_get_clientdata(client); - int i, j; - int ret; - int addr; - - mutex_lock(&data->update_lock); - - if (!(data->valid & (1 << slice)) || - time_after(jiffies, data->last_updated[slice] + 300 * HZ)) { - dev_dbg(&client->dev, "Starting eeprom update, slice %u\n", slice); - - addr = slice << SLICE_BITS; - - ret = i2c_smbus_write_byte_data(client, (u8)((addr >> 8) & 0xFF), (u8)(addr & 0xFF)); - /* select the eeprom address */ - if (ret < 0) { - dev_err(&client->dev, "address set failed\n"); - goto exit; - } - - if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_READ_BYTE)) { - goto exit; - } - - for (i = slice << SLICE_BITS; i < (slice + 1) << SLICE_BITS; i+= SLICE_SIZE) { - for (j = i; j < (i+SLICE_SIZE); j++) { - int res; - - res = i2c_smbus_read_byte(client); - if (res < 0) { - goto exit; - } - - data->data[j] = res & 0xFF; - } - } - - data->last_updated[slice] = jiffies; - data->valid |= (1 << slice); - } -exit: - mutex_unlock(&data->update_lock); -} - -static ssize_t mb_eeprom_read(struct file *filp, struct kobject *kobj, - struct bin_attribute *bin_attr, - char *buf, loff_t off, size_t count) -{ - struct i2c_client *client = to_i2c_client(container_of(kobj, struct device, kobj)); - struct eeprom_data *data = i2c_get_clientdata(client); - u8 slice; - - if (off > EEPROM_SIZE) { - return 0; - } - if (off + count > EEPROM_SIZE) { - count = EEPROM_SIZE - off; - } - if (count == 0) { - return 0; - } - - /* Only refresh slices which contain requested bytes */ - for (slice = off >> SLICE_BITS; slice <= (off + count - 1) >> SLICE_BITS; slice++) { - mb_eeprom_update_client(client, slice); - } - - memcpy(buf, &data->data[off], count); - - return count; -} - -static ssize_t mb_eeprom_write(struct file *filp, struct kobject *kobj, - struct bin_attribute *bin_attr, - char *buf, loff_t off, size_t count) -{ - struct i2c_client *client = to_i2c_client(container_of(kobj, struct device, kobj)); - struct eeprom_data *data = i2c_get_clientdata(client); - int ret; - int i; - u8 cmd; - u16 value16; - - dev_dbg(&client->dev, "mb_eeprom_write off=%d, count=%d\n", (int)off, (int)count); - - if (off > EEPROM_SIZE) { - return 0; - } - if (off + count > EEPROM_SIZE) { - count = EEPROM_SIZE - off; - } - if (count == 0) { - return 0; - } - - mutex_lock(&data->update_lock); - - for(i=0; i < count; i++) { - /* write command */ - cmd = (off >> 8) & 0xff; - value16 = off & 0xff; - value16 |= buf[i] << 8; - ret = i2c_smbus_write_word_data(client, cmd, value16); - - if (ret < 0) { - dev_err(&client->dev, "write address failed at %d \n", (int)off); - goto exit; - } - - off++; - - /* need to wait for write complete */ - udelay(10000); - } -exit: - mutex_unlock(&data->update_lock); - /* force to update client when reading */ - for(i=0; i < SLICE_NUM; i++) { - data->last_updated[i] = 0; - } - - return count; -} - -static struct bin_attribute mb_eeprom_attr = { - .attr = { - .name = "eeprom", - .mode = S_IRUGO | S_IWUSR, - }, - .size = EEPROM_SIZE, - .read = mb_eeprom_read, - .write = mb_eeprom_write, -}; - -/* Return 0 if detection is successful, -ENODEV otherwise */ -static int mb_eeprom_detect(struct i2c_client *client, struct i2c_board_info *info) -{ - struct i2c_adapter *adapter = client->adapter; - - /* EDID EEPROMs are often 24C00 EEPROMs, which answer to all - addresses 0x50-0x57, but we only care about 0x51 and 0x55. So decline - attaching to addresses >= 0x56 on DDC buses */ - if (!(adapter->class & I2C_CLASS_SPD) && client->addr >= 0x56) { - return -ENODEV; - } - - if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_READ_BYTE) - && !i2c_check_functionality(adapter, I2C_FUNC_SMBUS_WRITE_BYTE_DATA)) { - return -ENODEV; - } - - strlcpy(info->type, "eeprom", I2C_NAME_SIZE); - - return 0; -} - -static int mb_eeprom_probe(struct i2c_client *client, - const struct i2c_device_id *id) -{ - struct eeprom_data *data; - int err; - - if (!(data = kzalloc(sizeof(struct eeprom_data), GFP_KERNEL))) { - err = -ENOMEM; - goto exit; - } - - memset(data->data, 0xff, EEPROM_SIZE); - i2c_set_clientdata(client, data); - mutex_init(&data->update_lock); - - /* create the sysfs eeprom file */ - err = sysfs_create_bin_file(&client->dev.kobj, &mb_eeprom_attr); - if (err) { - goto exit_kfree; - } - - return 0; - -exit_kfree: - kfree(data); -exit: - return err; -} - -static int mb_eeprom_remove(struct i2c_client *client) -{ - sysfs_remove_bin_file(&client->dev.kobj, &mb_eeprom_attr); - kfree(i2c_get_clientdata(client)); - - return 0; -} - -static const struct i2c_device_id mb_eeprom_id[] = { - { "mb_eeprom", 0 }, - { } -}; - -static struct i2c_driver mb_eeprom_driver = { - .driver = { - .name = "mb_eeprom", - }, - .probe = mb_eeprom_probe, - .remove = mb_eeprom_remove, - .id_table = mb_eeprom_id, - - .class = I2C_CLASS_DDC | I2C_CLASS_SPD, - .detect = mb_eeprom_detect, - .address_list = normal_i2c, -}; - -module_i2c_driver(mb_eeprom_driver); - -MODULE_AUTHOR("Wade "); -MODULE_DESCRIPTION("Ingrasys Mother Borad EEPROM driver"); -MODULE_LICENSE("GPL"); diff --git a/packages/platforms/ingrasys/x86-64/s9100/.gitignore b/packages/platforms/ingrasys/x86-64/s9100/.gitignore deleted file mode 100755 index 9f7b1342f..000000000 --- a/packages/platforms/ingrasys/x86-64/s9100/.gitignore +++ /dev/null @@ -1 +0,0 @@ -onlpdump.mk diff --git a/packages/platforms/ingrasys/x86-64/s9100/Makefile b/packages/platforms/ingrasys/x86-64/s9100/Makefile deleted file mode 100755 index 003238cf6..000000000 --- a/packages/platforms/ingrasys/x86-64/s9100/Makefile +++ /dev/null @@ -1 +0,0 @@ -include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/ingrasys/x86-64/s9100/modules/Makefile b/packages/platforms/ingrasys/x86-64/s9100/modules/Makefile deleted file mode 100755 index 003238cf6..000000000 --- a/packages/platforms/ingrasys/x86-64/s9100/modules/Makefile +++ /dev/null @@ -1 +0,0 @@ -include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/ingrasys/x86-64/s9100/modules/PKG.yml b/packages/platforms/ingrasys/x86-64/s9100/modules/PKG.yml deleted file mode 100755 index 9005a6f48..000000000 --- a/packages/platforms/ingrasys/x86-64/s9100/modules/PKG.yml +++ /dev/null @@ -1 +0,0 @@ -!include $ONL_TEMPLATES/no-platform-modules.yml ARCH=amd64 VENDOR=ingrasys BASENAME=x86-64-ingrasys-s9100 KERNELS="onl-kernel-3.16-lts-x86-64-all:amd64" diff --git a/packages/platforms/ingrasys/x86-64/s9100/onlp/Makefile b/packages/platforms/ingrasys/x86-64/s9100/onlp/Makefile deleted file mode 100755 index 003238cf6..000000000 --- a/packages/platforms/ingrasys/x86-64/s9100/onlp/Makefile +++ /dev/null @@ -1 +0,0 @@ -include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/ingrasys/x86-64/s9100/onlp/PKG.yml b/packages/platforms/ingrasys/x86-64/s9100/onlp/PKG.yml deleted file mode 100755 index 591587255..000000000 --- a/packages/platforms/ingrasys/x86-64/s9100/onlp/PKG.yml +++ /dev/null @@ -1 +0,0 @@ -!include $ONL_TEMPLATES/onlp-platform-any.yml PLATFORM=x86-64-ingrasys-s9100 ARCH=amd64 TOOLCHAIN=x86_64-linux-gnu diff --git a/packages/platforms/ingrasys/x86-64/s9100/onlp/builds/Makefile b/packages/platforms/ingrasys/x86-64/s9100/onlp/builds/Makefile deleted file mode 100755 index e7437cb23..000000000 --- a/packages/platforms/ingrasys/x86-64/s9100/onlp/builds/Makefile +++ /dev/null @@ -1,2 +0,0 @@ -FILTER=src -include $(ONL)/make/subdirs.mk diff --git a/packages/platforms/ingrasys/x86-64/s9100/onlp/builds/lib/.gitignore b/packages/platforms/ingrasys/x86-64/s9100/onlp/builds/lib/.gitignore deleted file mode 100644 index c81d16be3..000000000 --- a/packages/platforms/ingrasys/x86-64/s9100/onlp/builds/lib/.gitignore +++ /dev/null @@ -1 +0,0 @@ -*.mk diff --git a/packages/platforms/ingrasys/x86-64/s9100/onlp/builds/lib/Makefile b/packages/platforms/ingrasys/x86-64/s9100/onlp/builds/lib/Makefile deleted file mode 100755 index a55794931..000000000 --- a/packages/platforms/ingrasys/x86-64/s9100/onlp/builds/lib/Makefile +++ /dev/null @@ -1,2 +0,0 @@ -PLATFORM := x86-64-ingrasys-s9100 -include $(ONL)/packages/base/any/onlp/builds/platform/libonlp-platform.mk diff --git a/packages/platforms/ingrasys/x86-64/s9100/onlp/builds/onlpdump/Makefile b/packages/platforms/ingrasys/x86-64/s9100/onlp/builds/onlpdump/Makefile deleted file mode 100755 index 2a89d34f1..000000000 --- a/packages/platforms/ingrasys/x86-64/s9100/onlp/builds/onlpdump/Makefile +++ /dev/null @@ -1,2 +0,0 @@ -PLATFORM := x86-64-ingrasys-s9100 -include $(ONL)/packages/base/any/onlp/builds/platform/onlps.mk diff --git a/packages/platforms/ingrasys/x86-64/s9100/onlp/builds/x86_64_ingrasys_s9100/.gitignore b/packages/platforms/ingrasys/x86-64/s9100/onlp/builds/x86_64_ingrasys_s9100/.gitignore deleted file mode 100755 index d274ea3d9..000000000 --- a/packages/platforms/ingrasys/x86-64/s9100/onlp/builds/x86_64_ingrasys_s9100/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -/x86_64_ingrasys_s9100.mk -/doc diff --git a/packages/platforms/ingrasys/x86-64/s9100/onlp/builds/x86_64_ingrasys_s9100/.module b/packages/platforms/ingrasys/x86-64/s9100/onlp/builds/x86_64_ingrasys_s9100/.module deleted file mode 100755 index 8958f013a..000000000 --- a/packages/platforms/ingrasys/x86-64/s9100/onlp/builds/x86_64_ingrasys_s9100/.module +++ /dev/null @@ -1 +0,0 @@ -name: x86_64_ingrasys_s9100 diff --git a/packages/platforms/ingrasys/x86-64/s9100/onlp/builds/x86_64_ingrasys_s9100/Makefile b/packages/platforms/ingrasys/x86-64/s9100/onlp/builds/x86_64_ingrasys_s9100/Makefile deleted file mode 100755 index c9d9e890b..000000000 --- a/packages/platforms/ingrasys/x86-64/s9100/onlp/builds/x86_64_ingrasys_s9100/Makefile +++ /dev/null @@ -1,10 +0,0 @@ -############################################################ -# -# -# -############################################################ -include $(ONL)/make/config.mk - -MODULE := x86_64_ingrasys_s9100 -AUTOMODULE := x86_64_ingrasys_s9100 -include $(BUILDER)/definemodule.mk diff --git a/packages/platforms/ingrasys/x86-64/s9100/onlp/builds/x86_64_ingrasys_s9100/module/auto/make.mk b/packages/platforms/ingrasys/x86-64/s9100/onlp/builds/x86_64_ingrasys_s9100/module/auto/make.mk deleted file mode 100755 index 659223938..000000000 --- a/packages/platforms/ingrasys/x86-64/s9100/onlp/builds/x86_64_ingrasys_s9100/module/auto/make.mk +++ /dev/null @@ -1,7 +0,0 @@ -# -# 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 -include $(BUILDER)/auto.mk diff --git a/packages/platforms/ingrasys/x86-64/s9100/onlp/builds/x86_64_ingrasys_s9100/module/auto/x86_64_ingrasys_s9100.yml b/packages/platforms/ingrasys/x86-64/s9100/onlp/builds/x86_64_ingrasys_s9100/module/auto/x86_64_ingrasys_s9100.yml deleted file mode 100755 index 27be346be..000000000 --- a/packages/platforms/ingrasys/x86-64/s9100/onlp/builds/x86_64_ingrasys_s9100/module/auto/x86_64_ingrasys_s9100.yml +++ /dev/null @@ -1,46 +0,0 @@ -############################################################################### -# -# X86_64_INGRASYS_S9100 Autogeneration Definitions. -# -############################################################################### - -cdefs: &cdefs -- X86_64_INGRASYS_S9100_CONFIG_INCLUDE_LOGGING: - doc: "Include or exclude logging." - default: 1 -- X86_64_INGRASYS_S9100_CONFIG_LOG_OPTIONS_DEFAULT: - doc: "Default enabled log options." - default: AIM_LOG_OPTIONS_DEFAULT -- X86_64_INGRASYS_S9100_CONFIG_LOG_BITS_DEFAULT: - doc: "Default enabled log bits." - default: AIM_LOG_BITS_DEFAULT -- X86_64_INGRASYS_S9100_CONFIG_LOG_CUSTOM_BITS_DEFAULT: - doc: "Default enabled custom log bits." - default: 0 -- X86_64_INGRASYS_S9100_CONFIG_PORTING_STDLIB: - doc: "Default all porting macros to use the C standard libraries." - default: 1 -- X86_64_INGRASYS_S9100_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS: - doc: "Include standard library headers for stdlib porting macros." - default: X86_64_INGRASYS_S9100_CONFIG_PORTING_STDLIB -- X86_64_INGRASYS_S9100_CONFIG_INCLUDE_UCLI: - doc: "Include generic uCli support." - default: 0 - - -definitions: - cdefs: - X86_64_INGRASYS_S9100_CONFIG_HEADER: - defs: *cdefs - basename: x86_64_ingrasys_s9100_config - - portingmacro: - X86_64_INGRASYS_S9100: - macros: - - malloc - - free - - memset - - memcpy - - vsnprintf - - snprintf - - strlen diff --git a/packages/platforms/ingrasys/x86-64/s9100/onlp/builds/x86_64_ingrasys_s9100/module/inc/x86_64_ingrasys_s9100/x86_64_ingrasys_s9100.x b/packages/platforms/ingrasys/x86-64/s9100/onlp/builds/x86_64_ingrasys_s9100/module/inc/x86_64_ingrasys_s9100/x86_64_ingrasys_s9100.x deleted file mode 100755 index d8db28cf7..000000000 --- a/packages/platforms/ingrasys/x86-64/s9100/onlp/builds/x86_64_ingrasys_s9100/module/inc/x86_64_ingrasys_s9100/x86_64_ingrasys_s9100.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/ingrasys/x86-64/s9100/onlp/builds/x86_64_ingrasys_s9100/module/inc/x86_64_ingrasys_s9100/x86_64_ingrasys_s9100_config.h b/packages/platforms/ingrasys/x86-64/s9100/onlp/builds/x86_64_ingrasys_s9100/module/inc/x86_64_ingrasys_s9100/x86_64_ingrasys_s9100_config.h deleted file mode 100755 index 64eaed7aa..000000000 --- a/packages/platforms/ingrasys/x86-64/s9100/onlp/builds/x86_64_ingrasys_s9100/module/inc/x86_64_ingrasys_s9100/x86_64_ingrasys_s9100_config.h +++ /dev/null @@ -1,152 +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 x86_64_ingrasys_s9100 Configuration Header - * - * @addtogroup x86_64_ingrasys_s9100-config - * @{ - * - *****************************************************************************/ -#ifndef __X86_64_INGRASYS_S9100_CONFIG_H__ -#define __X86_64_INGRASYS_S9100_CONFIG_H__ - -#ifdef GLOBAL_INCLUDE_CUSTOM_CONFIG -#include -#endif -#ifdef X86_64_INGRASYS_S9100_INCLUDE_CUSTOM_CONFIG -#include -#endif - -/* */ -#include -/** - * X86_64_INGRASYS_S9100_CONFIG_INCLUDE_LOGGING - * - * Include or exclude logging. */ - - -#ifndef X86_64_INGRASYS_S9100_CONFIG_INCLUDE_LOGGING -#define X86_64_INGRASYS_S9100_CONFIG_INCLUDE_LOGGING 1 -#endif - -/** - * X86_64_INGRASYS_S9100_CONFIG_LOG_OPTIONS_DEFAULT - * - * Default enabled log options. */ - - -#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_INGRASYS_S9100_CONFIG_LOG_BITS_DEFAULT - * - * Default enabled log bits. */ - - -#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_INGRASYS_S9100_CONFIG_LOG_CUSTOM_BITS_DEFAULT - * - * Default enabled custom log bits. */ - - -#ifndef X86_64_INGRASYS_S9100_CONFIG_LOG_CUSTOM_BITS_DEFAULT -#define X86_64_INGRASYS_S9100_CONFIG_LOG_CUSTOM_BITS_DEFAULT 0 -#endif - -/** - * X86_64_INGRASYS_S9100_CONFIG_PORTING_STDLIB - * - * Default all porting macros to use the C standard libraries. */ - - -#ifndef X86_64_INGRASYS_S9100_CONFIG_PORTING_STDLIB -#define X86_64_INGRASYS_S9100_CONFIG_PORTING_STDLIB 1 -#endif - -/** - * X86_64_INGRASYS_S9100_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS - * - * Include standard library headers for stdlib porting macros. */ - - -#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_INGRASYS_S9100_CONFIG_INCLUDE_UCLI - * - * Include generic uCli support. */ - - -#ifndef X86_64_INGRASYS_S9100_CONFIG_INCLUDE_UCLI -#define X86_64_INGRASYS_S9100_CONFIG_INCLUDE_UCLI 0 -#endif - - - -/** - * All compile time options can be queried or displayed - */ - -/** Configuration settings structure. */ -typedef struct x86_64_ingrasys_s9100_config_settings_s { - /** name */ - const char* name; - /** value */ - const char* value; -} x86_64_ingrasys_s9100_config_settings_t; - -/** Configuration settings table. */ -/** x86_64_ingrasys_s9100_config_settings table. */ -extern x86_64_ingrasys_s9100_config_settings_t x86_64_ingrasys_s9100_config_settings[]; - -/** - * @brief Lookup a configuration setting. - * @param setting The name of the configuration option to lookup. - */ -const char* x86_64_ingrasys_s9100_config_lookup(const char* setting); - -/** - * @brief Show the compile-time configuration. - * @param pvs The output stream. - */ -int x86_64_ingrasys_s9100_config_show(struct aim_pvs_s* pvs); - -/* */ - -#include "x86_64_ingrasys_s9100_porting.h" - -#endif /* __X86_64_INGRASYS_S9100_CONFIG_H__ */ -/* @} */ diff --git a/packages/platforms/ingrasys/x86-64/s9100/onlp/builds/x86_64_ingrasys_s9100/module/inc/x86_64_ingrasys_s9100/x86_64_ingrasys_s9100_dox.h b/packages/platforms/ingrasys/x86-64/s9100/onlp/builds/x86_64_ingrasys_s9100/module/inc/x86_64_ingrasys_s9100/x86_64_ingrasys_s9100_dox.h deleted file mode 100755 index c796e25b4..000000000 --- a/packages/platforms/ingrasys/x86-64/s9100/onlp/builds/x86_64_ingrasys_s9100/module/inc/x86_64_ingrasys_s9100/x86_64_ingrasys_s9100_dox.h +++ /dev/null @@ -1,26 +0,0 @@ -/**************************************************************************//** - * - * x86_64_ingrasys_s9100 Doxygen Header - * - *****************************************************************************/ -#ifndef __x86_64_ingrasys_s9100_DOX_H__ -#define __x86_64_ingrasys_s9100_DOX_H__ - -/** - * @defgroup x86_64_ingrasys_s9100 x86_64_ingrasys_s9100 - x86_64_ingrasys_s9100 Description - * - -The documentation overview for this module should go here. - - * - * @{ - * - * @defgroup x86_64_ingrasys_s9100-x86_64_ingrasys_s9100 Public Interface - * @defgroup x86_64_ingrasys_s9100-config Compile Time Configuration - * @defgroup x86_64_ingrasys_s9100-porting Porting Macros - * - * @} - * - */ - -#endif /* __x86_64_ingrasys_s9100_DOX_H__ */ diff --git a/packages/platforms/ingrasys/x86-64/s9100/onlp/builds/x86_64_ingrasys_s9100/module/inc/x86_64_ingrasys_s9100/x86_64_ingrasys_s9100_porting.h b/packages/platforms/ingrasys/x86-64/s9100/onlp/builds/x86_64_ingrasys_s9100/module/inc/x86_64_ingrasys_s9100/x86_64_ingrasys_s9100_porting.h deleted file mode 100755 index 5b16c5bcb..000000000 --- a/packages/platforms/ingrasys/x86-64/s9100/onlp/builds/x86_64_ingrasys_s9100/module/inc/x86_64_ingrasys_s9100/x86_64_ingrasys_s9100_porting.h +++ /dev/null @@ -1,96 +0,0 @@ -/********************************************************//** - * - * @file - * @brief x86_64_Ingrasys_s9100 Porting Macros. - * - * @addtogroup x86_64_Ingrasys_s9100-porting - * @{ - * - ***********************************************************/ -#ifndef __X86_64_INGRASYS_S9100_PORTING_H__ -#define __X86_64_INGRASYS_S9100_PORTING_H__ - -/* */ -#if X86_64_INGRASYS_S9100_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS == 1 -#include -#include -#include -#include -#include -#endif - -#ifndef X86_64_INGRASYS_S9100_MALLOC - #if defined(GLOBAL_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_INGRASYS_S9100_MALLOC is required but cannot be defined. - #endif -#endif - -#ifndef X86_64_INGRASYS_S9100_FREE - #if defined(GLOBAL_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_INGRASYS_S9100_FREE is required but cannot be defined. - #endif -#endif - -#ifndef X86_64_INGRASYS_S9100_MEMSET - #if defined(GLOBAL_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_INGRASYS_S9100_MEMSET is required but cannot be defined. - #endif -#endif - -#ifndef X86_64_INGRASYS_S9100_MEMCPY - #if defined(GLOBAL_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_INGRASYS_S9100_MEMCPY is required but cannot be defined. - #endif -#endif - -#ifndef X86_64_INGRASYS_S9100_VSNPRINTF - #if defined(GLOBAL_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_INGRASYS_S9100_VSNPRINTF is required but cannot be defined. - #endif -#endif - -#ifndef X86_64_INGRASYS_S9100_SNPRINTF - #if defined(GLOBAL_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_INGRASYS_S9100_SNPRINTF is required but cannot be defined. - #endif -#endif - -#ifndef X86_64_INGRASYS_S9100_STRLEN - #if defined(GLOBAL_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_INGRASYS_S9100_STRLEN is required but cannot be defined. - #endif -#endif - -/* */ - - -#endif /* __X86_64_INGRASYS_S9100_PORTING_H__ */ -/* @} */ diff --git a/packages/platforms/ingrasys/x86-64/s9100/onlp/builds/x86_64_ingrasys_s9100/module/make.mk b/packages/platforms/ingrasys/x86-64/s9100/onlp/builds/x86_64_ingrasys_s9100/module/make.mk deleted file mode 100755 index 87e53be9f..000000000 --- a/packages/platforms/ingrasys/x86-64/s9100/onlp/builds/x86_64_ingrasys_s9100/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))) -x86_64_ingrasys_s9100_INCLUDES := -I $(THIS_DIR)inc -x86_64_ingrasys_s9100_INTERNAL_INCLUDES := -I $(THIS_DIR)src -x86_64_ingrasys_s9100_DEPENDMODULE_ENTRIES := init:x86_64_ingrasys_s9100 ucli:x86_64_ingrasys_s9100 - diff --git a/packages/platforms/ingrasys/x86-64/s9100/onlp/builds/x86_64_ingrasys_s9100/module/src/Makefile b/packages/platforms/ingrasys/x86-64/s9100/onlp/builds/x86_64_ingrasys_s9100/module/src/Makefile deleted file mode 100755 index 5ccb9ac73..000000000 --- a/packages/platforms/ingrasys/x86-64/s9100/onlp/builds/x86_64_ingrasys_s9100/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 x86_64_ingrasys_s9100_ucli.c - diff --git a/packages/platforms/ingrasys/x86-64/s9100/onlp/builds/x86_64_ingrasys_s9100/module/src/fani.c b/packages/platforms/ingrasys/x86-64/s9100/onlp/builds/x86_64_ingrasys_s9100/module/src/fani.c deleted file mode 100755 index 66f33b164..000000000 --- a/packages/platforms/ingrasys/x86-64/s9100/onlp/builds/x86_64_ingrasys_s9100/module/src/fani.c +++ /dev/null @@ -1,326 +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. - * - * - ************************************************************ - * - * Fan Platform Implementation Defaults. - * - ***********************************************************/ -#include -#include "x86_64_ingrasys_s9100_int.h" -#include -#include -#include "platform_lib.h" - -onlp_fan_info_t fan_info[] = { - { }, /* Not used */ - { - { FAN_OID_FAN1, "FANTRAY 1-A", 0 }, - ONLP_FAN_STATUS_PRESENT, - ONLP_FAN_CAPS_GET_RPM | ONLP_FAN_CAPS_GET_PERCENTAGE, - 0, - 0, - ONLP_FAN_MODE_INVALID, - }, - { - { FAN_OID_FAN2, "FANTRAY 1-B", 0 }, - ONLP_FAN_STATUS_PRESENT, - ONLP_FAN_CAPS_GET_RPM | ONLP_FAN_CAPS_GET_PERCENTAGE, - 0, - 0, - ONLP_FAN_MODE_INVALID, - }, - { - { FAN_OID_FAN3, "FANTRAY 2-A", 0 }, - ONLP_FAN_STATUS_PRESENT, - ONLP_FAN_CAPS_GET_RPM | ONLP_FAN_CAPS_GET_PERCENTAGE, - 0, - 0, - ONLP_FAN_MODE_INVALID, - }, - { - { FAN_OID_FAN4, "FANTRAY 2-B", 0 }, - ONLP_FAN_STATUS_PRESENT, - ONLP_FAN_CAPS_GET_RPM | ONLP_FAN_CAPS_GET_PERCENTAGE, - 0, - 0, - ONLP_FAN_MODE_INVALID, - }, - { - { FAN_OID_FAN5, "FANTRAY 3-A", 0 }, - ONLP_FAN_STATUS_PRESENT, - ONLP_FAN_CAPS_GET_RPM | ONLP_FAN_CAPS_GET_PERCENTAGE, - 0, - 0, - ONLP_FAN_MODE_INVALID, - }, - { - { FAN_OID_FAN6, "FANTRAY 3-B", 0 }, - ONLP_FAN_STATUS_PRESENT, - ONLP_FAN_CAPS_GET_RPM | ONLP_FAN_CAPS_GET_PERCENTAGE, - 0, - 0, - ONLP_FAN_MODE_INVALID, - }, - { - { FAN_OID_FAN7, "FANTRAY 4-A", 0 }, - ONLP_FAN_STATUS_PRESENT, - ONLP_FAN_CAPS_GET_RPM | ONLP_FAN_CAPS_GET_PERCENTAGE, - 0, - 0, - ONLP_FAN_MODE_INVALID, - }, - { - { FAN_OID_FAN8, "FANTRAY 4-B", 0 }, - ONLP_FAN_STATUS_PRESENT, - ONLP_FAN_CAPS_GET_RPM | ONLP_FAN_CAPS_GET_PERCENTAGE, - 0, - 0, - ONLP_FAN_MODE_INVALID, - }, - { - { FAN_OID_PSU_FAN1, "PSU-1 FAN", 0 }, - ONLP_FAN_STATUS_PRESENT, - }, - { - { FAN_OID_PSU_FAN2, "PSU-2 FAN", 0 }, - ONLP_FAN_STATUS_PRESENT, - } -}; -/* - * This function will be called prior to all of onlp_fani_* functions. - */ -int -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) { - return ONLP_STATUS_E_INTERNAL; - } - - /* fan status > 1, means failure */ - if (fan_status > 0) { - info->status |= ONLP_FAN_STATUS_FAILED; - return ONLP_STATUS_OK; - } - - rv = onlp_file_read_int(&fan_rpm, SYS_FAN_PREFIX "fan%d_input", id); - if (rv < 0) { - return ONLP_STATUS_E_INTERNAL; - } - info->rpm = fan_rpm; - - /* get speed percentage*/ - switch (id) - { - case FAN_ID_FAN1: - case FAN_ID_FAN2: - case FAN_ID_FAN3: - case FAN_ID_FAN4: - rv = onlp_file_read_int(&perc_val, SYS_FAN_PREFIX "pwm%d", FAN_CTRL_SET1); - break; - case FAN_ID_FAN5: - case FAN_ID_FAN6: - case FAN_ID_FAN7: - case FAN_ID_FAN8: - rv = onlp_file_read_int(&perc_val, SYS_FAN_PREFIX "pwm%d", FAN_CTRL_SET2); - break; - default: - return ONLP_STATUS_E_INVALID; - } - if (rv < 0) { - return ONLP_STATUS_E_INTERNAL; - } - - percentage = (info->rpm*100)/max_fan_speed; - - info->percentage = percentage; - - return ONLP_STATUS_OK; -} - -int -sys_fan_rpm_percent_set(int perc) -{ - int rc; - rc = onlp_file_write_int(perc, SYS_FAN_PREFIX "pwm%d", FAN_CTRL_SET1); - - if (rc < 0) { - return ONLP_STATUS_E_INTERNAL; - } - - rc = onlp_file_write_int(perc, SYS_FAN_PREFIX "pwm%d", FAN_CTRL_SET2); - if (rc < 0) { - return ONLP_STATUS_E_INTERNAL; - } - - return ONLP_STATUS_OK; -} - -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 percentage) -{ - int fid, perc_val, rc; - fid = ONLP_OID_ID_GET(id); - - /* Set fan speed - Driver accept value in range between 128 and 255. - Value 128 is 50%. - Value 200 is 80%. - Value 255 is 100%. - */ - if (percentage == 100) { - perc_val = 255; - } else if (percentage == 80) { - perc_val = 200; - } else if (percentage == 50) { - perc_val = 128; - } else { - return ONLP_STATUS_E_INVALID; - } - - switch (fid) - { - case FAN_ID_FAN1: - case FAN_ID_FAN2: - case FAN_ID_FAN3: - case FAN_ID_FAN4: - case FAN_ID_FAN5: - case FAN_ID_FAN6: - case FAN_ID_FAN7: - case FAN_ID_FAN8: - rc = sys_fan_rpm_percent_set(perc_val); - break; - default: - return ONLP_STATUS_E_INVALID; - } - return rc; -} - -int -onlp_fani_info_get(onlp_oid_t id, onlp_fan_info_t* rv) -{ - int fan_id ,rc; - - fan_id = ONLP_OID_ID_GET(id); - *rv = fan_info[fan_id]; - rv->caps |= ONLP_FAN_CAPS_GET_RPM; - - switch (fan_id) { - case FAN_ID_FAN1: - case FAN_ID_FAN2: - case FAN_ID_FAN3: - case FAN_ID_FAN4: - case FAN_ID_FAN5: - case FAN_ID_FAN6: - case FAN_ID_FAN7: - case FAN_ID_FAN8: - rc = sys_fan_info_get(rv, fan_id); - break; - case FAN_ID_PSU_FAN1: - case FAN_ID_PSU_FAN2: - rc = psu_fan_info_get(rv, fan_id); - break; - default: - return ONLP_STATUS_E_INTERNAL; - break; - } - - return rc; -} - diff --git a/packages/platforms/ingrasys/x86-64/s9100/onlp/builds/x86_64_ingrasys_s9100/module/src/ledi.c b/packages/platforms/ingrasys/x86-64/s9100/onlp/builds/x86_64_ingrasys_s9100/module/src/ledi.c deleted file mode 100755 index b694ca2e8..000000000 --- a/packages/platforms/ingrasys/x86-64/s9100/onlp/builds/x86_64_ingrasys_s9100/module/src/ledi.c +++ /dev/null @@ -1,216 +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 -#include -#include -#include -#include - -#include "platform_lib.h" - -/* - * Get the information for the given LED OID. - */ -static onlp_led_info_t led_info[] = -{ - { }, /* Not used */ - { - { LED_OID_SYSTEM, "Chassis LED 1 (SYS LED)", 0 }, - ONLP_LED_STATUS_PRESENT, - ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_GREEN, - }, - { - { LED_OID_FAN, "Chassis LED 2 (FAN 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_PSU1, "Chassis LED 3 (PSU1 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_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. - */ -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, 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]; - - 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; -} - -/* - * 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) -{ - int led_id, rc; - - led_id = ONLP_OID_ID_GET(id); - switch (led_id) { - case LED_SYSTEM_LED: - rc = system_led_set(mode); - break; - case LED_FAN_LED: - rc = fan_led_set(mode); - break; - case LED_PSU1_LED: - rc = psu1_led_set(mode); - break; - 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; - } - - return rc; -} - -int -onlp_ledi_ioctl(onlp_oid_t id, va_list vargs) -{ - return ONLP_STATUS_OK; -} diff --git a/packages/platforms/ingrasys/x86-64/s9100/onlp/builds/x86_64_ingrasys_s9100/module/src/make.mk b/packages/platforms/ingrasys/x86-64/s9100/onlp/builds/x86_64_ingrasys_s9100/module/src/make.mk deleted file mode 100755 index d0885bbfd..000000000 --- a/packages/platforms/ingrasys/x86-64/s9100/onlp/builds/x86_64_ingrasys_s9100/module/src/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. -# -# -############################################################ -# -# -# -############################################################ - -LIBRARY := x86_64_ingrasys_s9100 -$(LIBRARY)_SUBDIR := $(dir $(lastword $(MAKEFILE_LIST))) -#$(LIBRARY)_LAST := 1 -include $(BUILDER)/lib.mk diff --git a/packages/platforms/ingrasys/x86-64/s9100/onlp/builds/x86_64_ingrasys_s9100/module/src/platform_lib.c b/packages/platforms/ingrasys/x86-64/s9100/onlp/builds/x86_64_ingrasys_s9100/module/src/platform_lib.c deleted file mode 100755 index 43d2b9656..000000000 --- a/packages/platforms/ingrasys/x86-64/s9100/onlp/builds/x86_64_ingrasys_s9100/module/src/platform_lib.c +++ /dev/null @@ -1,596 +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 -#include -#include -#include -#include -#include - -#include "platform_lib.h" - -int -psu_thermal_get(onlp_thermal_info_t* info, int thermal_id) -{ - int pw_exist, pw_good, offset, i2c_bus, rc; - int value, buf, psu_mask; - unsigned int y_value = 0; - unsigned char n_value = 0; - unsigned int temp = 0; - char result[32]; - - if (thermal_id == THERMAL_ID_PSU1_1) { - i2c_bus = I2C_BUS_8; - offset = PSU_THERMAL1_OFFSET; - psu_mask = PSU1_MUX_MASK; - } else if (thermal_id == THERMAL_ID_PSU1_2) { - i2c_bus = I2C_BUS_8; - offset = PSU_THERMAL2_OFFSET; - psu_mask = PSU1_MUX_MASK; - } else if (thermal_id == THERMAL_ID_PSU2_1) { - i2c_bus = I2C_BUS_9; - offset = PSU_THERMAL1_OFFSET; - psu_mask = PSU2_MUX_MASK; - } else if (thermal_id == THERMAL_ID_PSU2_2) { - i2c_bus = I2C_BUS_9; - offset = PSU_THERMAL2_OFFSET; - 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 (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; - } - - if (pw_good != PSU_STATUS_POWER_GOOD) { - info->mcelsius = 0; - return ONLP_STATUS_OK; - } - - value = onlp_i2c_readw(i2c_bus, PSU_REG, offset, ONLP_I2C_F_FORCE); - - y_value = (value & 0x07FF); - if ((value & 0x8000)&&(y_value)) { - n_value = 0xF0 + (((value) >> 11) & 0x0F); - n_value = (~n_value) +1; - temp = (unsigned int)(1<> 11) & 0x0F); - snprintf(result, sizeof(result), "%d", (y_value*(1<mcelsius = (int)(buf * 1000); - - return ONLP_STATUS_OK; -} - - -int -psu_fan_info_get(onlp_fan_info_t* info, int id) -{ - int pw_exist, pw_good, i2c_bus, psu_mask, rc; - unsigned int tmp_fan_rpm, fan_rpm; - - if (id == FAN_ID_PSU_FAN1) { - i2c_bus = I2C_BUS_8; - psu_mask = PSU1_MUX_MASK; - } else if (id == FAN_ID_PSU_FAN2) { - i2c_bus = I2C_BUS_9; - psu_mask = PSU2_MUX_MASK; - } else { - return ONLP_STATUS_E_INTERNAL; - } - - /* check psu status */ - if ((rc = psu_present_get(&pw_exist, I2C_BUS_0, psu_mask)) != ONLP_STATUS_OK) { - return ONLP_STATUS_E_INTERNAL; - } - - 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) { - return ONLP_STATUS_E_INTERNAL; - } - - if (pw_good != PSU_STATUS_POWER_GOOD) { - info->rpm = 0; - return ONLP_STATUS_OK; - } - - tmp_fan_rpm = onlp_i2c_readw(i2c_bus, PSU_REG, PSU_FAN_RPM_OFFSET, ONLP_I2C_F_FORCE); - - fan_rpm = (unsigned int)tmp_fan_rpm; - fan_rpm = (fan_rpm & 0x07FF) * (1 << ((fan_rpm >> 11) & 0x1F)); - info->rpm = (int)fan_rpm; - - return ONLP_STATUS_OK; -} - -int -psu_vout_get(onlp_psu_info_t* info, int i2c_bus) -{ - int v_value = 0; - int n_value = 0; - unsigned int temp = 0; - char result[32]; - double dvalue; - memset(result, 0, sizeof(result)); - - n_value = onlp_i2c_readb(i2c_bus, PSU_REG, PSU_VOUT_OFFSET1, ONLP_I2C_F_FORCE); - if (n_value < 0) { - return ONLP_STATUS_E_INTERNAL; - } - - v_value = onlp_i2c_readw(i2c_bus, PSU_REG, PSU_VOUT_OFFSET2, ONLP_I2C_F_FORCE); - if (v_value < 0) { - return ONLP_STATUS_E_INTERNAL; - } - - if (n_value & 0x10) { - n_value = 0xF0 + (n_value & 0x0F); - n_value = (~n_value) +1; - temp = (unsigned int)(1< 0.0) { - info->caps |= ONLP_PSU_CAPS_VOUT; - info->mvout = (int)(dvalue * 1000); - } - - return ONLP_STATUS_OK; -} - -int -psu_iout_get(onlp_psu_info_t* info, int i2c_bus) -{ - int value; - unsigned int y_value = 0; - unsigned char n_value = 0; - unsigned int temp = 0; - char result[32]; - memset(result, 0, sizeof(result)); - double dvalue; - - value = onlp_i2c_readw(i2c_bus, PSU_REG, PSU_IOUT_OFFSET, ONLP_I2C_F_FORCE); - if (value < 0) { - return ONLP_STATUS_E_INTERNAL; - } - - y_value = (value & 0x07FF); - if ((value & 0x8000)&&(y_value)) - { - n_value = 0xF0 + (((value) >> 11) & 0x0F); - n_value = (~n_value) +1; - temp = (unsigned int)(1<> 11) & 0x0F); - snprintf(result, sizeof(result), "%d", (y_value*(1< 0.0) { - info->caps |= ONLP_PSU_CAPS_IOUT; - info->miout = (int)(dvalue * 1000); - } - - return ONLP_STATUS_OK; -} - -int -psu_pout_get(onlp_psu_info_t* info, int i2c_bus) -{ - int value; - unsigned int y_value = 0; - unsigned char n_value = 0; - unsigned int temp = 0; - char result[32]; - memset(result, 0, sizeof(result)); - double dvalue; - - value = onlp_i2c_readw(i2c_bus, PSU_REG, PSU_POUT_OFFSET, ONLP_I2C_F_FORCE); - if (value < 0) { - return ONLP_STATUS_E_INTERNAL; - } - - y_value = (value & 0x07FF); - if ((value & 0x8000)&&(y_value)) - { - n_value = 0xF0 + (((value) >> 11) & 0x0F); - n_value = (~n_value) +1; - temp = (unsigned int)(1<> 11) & 0x0F); - snprintf(result, sizeof(result), "%d", (y_value*(1< 0.0) { - info->caps |= ONLP_PSU_CAPS_POUT; - info->mpout = (int)(dvalue * 1000); - } - - return ONLP_STATUS_OK; -} - -int -psu_pin_get(onlp_psu_info_t* info, int i2c_bus) -{ - int value; - unsigned int y_value = 0; - unsigned char n_value = 0; - unsigned int temp = 0; - char result[32]; - memset(result, 0, sizeof(result)); - double dvalue; - - value = onlp_i2c_readw(i2c_bus, PSU_REG, PSU_PIN_OFFSET, ONLP_I2C_F_FORCE); - if (value < 0) { - return ONLP_STATUS_E_INTERNAL; - } - - y_value = (value & 0x07FF); - if ((value & 0x8000)&&(y_value)) - { - n_value = 0xF0 + (((value) >> 11) & 0x0F); - n_value = (~n_value) +1; - temp = (unsigned int)(1<> 11) & 0x0F); - snprintf(result, sizeof(result), "%d", (y_value*(1< 0.0) { - info->caps |= ONLP_PSU_CAPS_PIN; - info->mpin = (int)(dvalue * 1000); - } - - return ONLP_STATUS_OK; -} - -int -psu_eeprom_get(onlp_psu_info_t* info, int id) -{ - uint8_t data[256]; - char eeprom_path[128]; - int data_len, i, rc; - memset(data, 0, sizeof(data)); - memset(eeprom_path, 0, sizeof(eeprom_path)); - - if (id == PSU_ID_PSU1) { - rc = onlp_file_read(data, sizeof(data), &data_len, PSU1_EEPROM_PATH); - } else { - rc = onlp_file_read(data, sizeof(data), &data_len, PSU2_EEPROM_PATH); - } - - if (rc == ONLP_STATUS_OK) - { - i = 11; - - /* Manufacturer Name */ - data_len = (data[i]&0x0f); - i++; - i += data_len; - - /* Product Name */ - data_len = (data[i]&0x0f); - i++; - memcpy(info->model, (char *) &(data[i]), data_len); - i += data_len; - - /* Product part,model number */ - data_len = (data[i]&0x0f); - i++; - i += data_len; - - /* Product Version */ - data_len = (data[i]&0x0f); - i++; - i += data_len; - - /* Product Serial Number */ - data_len = (data[i]&0x0f); - i++; - memcpy(info->serial, (char *) &(data[i]), data_len); - } else { - strcpy(info->model, "Missing"); - strcpy(info->serial, "Missing"); - } - - return ONLP_STATUS_OK; -} - - -int -psu_present_get(int *pw_exist, int i2c_bus, int psu_mask) -{ - int psu_pres; - - psu_pres = onlp_i2c_readb(i2c_bus, PSU_STATE_REG, PSU_PRESENT_OFFSET, ONLP_I2C_F_FORCE); - if (psu_pres < 0) { - return ONLP_STATUS_E_INTERNAL; - } - - *pw_exist = ((psu_pres & psu_mask) ? 0 : 1); - return ONLP_STATUS_OK; -} - -int -psu_pwgood_get(int *pw_good, int i2c_bus, int psu_mask) -{ - int psu_pwgood; - - psu_pwgood = onlp_i2c_readb(i2c_bus, PSU_STATE_REG, PSU_PWGOOD_OFFSET, ONLP_I2C_F_FORCE); - if (psu_pwgood < 0) { - return ONLP_STATUS_E_INTERNAL; - } - - *pw_good = (((psu_pwgood >> 3 ) & psu_mask) ? 1 : 0); - return ONLP_STATUS_OK; -} - -int -qsfp_present_get(int port, int *pres_val) -{ - int reg_addr, val, offset; - - if (port >= 1 && port <= 8) { - reg_addr = QSFP_PRES_REG1; - offset = QSFP_PRES_OFFSET1; - } else if (port >= 9 && port <= 16) { - reg_addr = QSFP_PRES_REG1; - offset = QSFP_PRES_OFFSET2; - } else if (port >= 17 && port <= 24) { - reg_addr = QSFP_PRES_REG2; - offset = QSFP_PRES_OFFSET1; - } else if (port >= 25 && port <= 32) { - reg_addr = QSFP_PRES_REG2; - offset = QSFP_PRES_OFFSET2; - } else { - return ONLP_STATUS_E_INTERNAL; - } - - val = onlp_i2c_readb(I2C_BUS_6, reg_addr, offset, ONLP_I2C_F_FORCE); - if (val < 0) { - return ONLP_STATUS_E_INTERNAL; - } - - *pres_val = val; - - return ONLP_STATUS_OK; -} - - -int -system_led_set(onlp_led_mode_t mode) -{ - int rc; - if(mode == ONLP_LED_MODE_GREEN) { - rc = onlp_i2c_modifyb(I2C_BUS_9, LED_REG, LED_OFFSET, LED_SYS_AND_MASK, - LED_SYS_GMASK, ONLP_I2C_F_FORCE); - } - else if(mode == ONLP_LED_MODE_ORANGE) { - rc = onlp_i2c_modifyb(I2C_BUS_9, LED_REG, LED_OFFSET, LED_SYS_AND_MASK, - LED_SYS_YMASK, ONLP_I2C_F_FORCE); - } else { - return ONLP_STATUS_E_INTERNAL; - } - - if (rc < 0) { - return ONLP_STATUS_E_INTERNAL; - } - - return ONLP_STATUS_OK; -} - -int -fan_led_set(onlp_led_mode_t mode) -{ - int rc; - if(mode == ONLP_LED_MODE_GREEN) { - rc = onlp_i2c_modifyb(I2C_BUS_9, LED_REG, LED_OFFSET, LED_FAN_AND_MASK, - LED_FAN_GMASK, ONLP_I2C_F_FORCE); - } - else if(mode == ONLP_LED_MODE_ORANGE) { - rc = onlp_i2c_modifyb(I2C_BUS_9, LED_REG, LED_OFFSET, LED_FAN_AND_MASK, - LED_FAN_YMASK, ONLP_I2C_F_FORCE); - } else { - return ONLP_STATUS_E_INTERNAL; - } - - if (rc < 0) { - return ONLP_STATUS_E_INTERNAL; - } - - return ONLP_STATUS_OK; -} - -int -psu1_led_set(onlp_led_mode_t mode) -{ - int rc; - if(mode == ONLP_LED_MODE_GREEN) { - rc = onlp_i2c_modifyb(I2C_BUS_9, LED_REG, LED_OFFSET, - LED_PSU1_AND_MASK, LED_PSU1_GMASK, - ONLP_I2C_F_FORCE); - } else if(mode == ONLP_LED_MODE_ORANGE) { - 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; - } - - if (rc < 0) { - return ONLP_STATUS_E_INTERNAL; - } - - return ONLP_STATUS_OK; -} - -int -psu2_led_set(onlp_led_mode_t mode) -{ - int rc; - if(mode == ONLP_LED_MODE_GREEN) { - rc = onlp_i2c_modifyb(I2C_BUS_9, LED_REG, LED_OFFSET, - LED_PSU2_AND_MASK, LED_PSU2_GMASK, - ONLP_I2C_F_FORCE); - } else if(mode == ONLP_LED_MODE_ORANGE) { - 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; - } - - - if (rc < 0) { - return ONLP_STATUS_E_INTERNAL; - } - - 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) -{ - int cpld_release, cpld_version, cpld_rev; - - cpld_rev = onlp_i2c_readb(I2C_BUS_0, CPLD_REG, CPLD_VER_OFFSET, ONLP_I2C_F_FORCE); - if (cpld_rev < 0) { - return ONLP_STATUS_E_INTERNAL; - } - - cpld_release = (((cpld_rev) >> 6 & 0x01)); - cpld_version = (((cpld_rev) & 0x3F)); - - pi->cpld_versions = aim_fstrdup( - "CPLD is %d version(0:RD 1:Release), Revision is 0x%02x\n", - cpld_release, cpld_version); - - return ONLP_STATUS_OK; -} diff --git a/packages/platforms/ingrasys/x86-64/s9100/onlp/builds/x86_64_ingrasys_s9100/module/src/platform_lib.h b/packages/platforms/ingrasys/x86-64/s9100/onlp/builds/x86_64_ingrasys_s9100/module/src/platform_lib.h deleted file mode 100755 index 315fdbd5d..000000000 --- a/packages/platforms/ingrasys/x86-64/s9100/onlp/builds/x86_64_ingrasys_s9100/module/src/platform_lib.h +++ /dev/null @@ -1,268 +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. - * - * - ************************************************************ - * - * - * - ***********************************************************/ -#ifndef __PLATFORM_LIB_H__ -#define __PLATFORM_LIB_H__ - -#include -#include -#include -#include -#include -#include "x86_64_ingrasys_s9100_int.h" -#include "x86_64_ingrasys_s9100_log.h" - -#include -#define SYS_HWMON_TEMP_PREFIX "/sys/class/hwmon/hwmon1/device/" -#define SYS_CORE_TEMP_PREFIX "/sys/class/hwmon/hwmon0/device/hwmon/hwmon0/" -#define SYS_FAN_PREFIX "/sys/class/hwmon/hwmon1/device/" -#define SYS_EEPROM_PATH "/sys/bus/i2c/devices/9-0054/eeprom" -#define SYS_EEPROM_SIZE 512 -#define PSU1_EEPROM_PATH "/sys/bus/i2c/devices/8-0050/eeprom" -#define PSU2_EEPROM_PATH "/sys/bus/i2c/devices/9-0050/eeprom" -#define PSU_STATUS_PRESENT 1 -#define PSU_STATUS_POWER_GOOD 1 -#define FAN_PRESENT 0 -#define FAN_CTRL_SET1 1 -#define FAN_CTRL_SET2 2 -#define MAX_SYS_FAN_NUM 8 -#define BOARD_THERMAL_NUM 6 -#define SYS_FAN_NUM 8 -#define QSFP_NUM 32 - -#define THERMAL_NUM 10 -#define LED_NUM 4 -#define FAN_NUM 10 - - - -#define THERMAL_SHUTDOWN_DEFAULT 105000 - -#define THERMAL_ERROR_DEFAULT 95000 -#define THERMAL_ERROR_FAN_PERC 100 - -#define THERMAL_WARNING_DEFAULT 77000 -#define THERMAL_WARNING_FAN_PERC 80 - -#define THERMAL_NORMAL_DEFAULT 72000 -#define THERMAL_NORMAL_FAN_PERC 50 - - -/* I2C bus */ -#define I2C_BUS_0 0 -#define I2C_BUS_1 1 -#define I2C_BUS_2 2 -#define I2C_BUS_3 3 -#define I2C_BUS_4 4 -#define I2C_BUS_5 5 -#define I2C_BUS_6 6 -#define I2C_BUS_7 7 -#define I2C_BUS_8 8 -#define I2C_BUS_9 9 - -/* PSU */ -#define PSU1_MUX_MASK 0x01 -#define PSU2_MUX_MASK 0x02 -#define PSU_THERMAL1_OFFSET 0x8D -#define PSU_THERMAL2_OFFSET 0x8E -#define PSU_THERMAL_REG 0x58 -#define PSU_FAN_RPM_REG 0x58 -#define PSU_FAN_RPM_OFFSET 0x90 -#define PSU_REG 0x58 -#define PSU_VOUT_OFFSET1 0x20 -#define PSU_VOUT_OFFSET2 0x8B -#define PSU_IOUT_OFFSET 0x8C -#define PSU_POUT_OFFSET 0x96 -#define PSU_PIN_OFFSET 0x97 -#define PSU_STATE_REG 0x33 -#define PSU_PRESENT_OFFSET 0x03 -#define PSU_PWGOOD_OFFSET 0x02 - -/* LED */ -#define LED_REG 0x22 -#define LED_OFFSET 0x02 -#define LED_SYS_AND_MASK 0x3F -#define LED_SYS_GMASK 0x40 -#define LED_SYS_YMASK 0x80 -#define LED_FAN_AND_MASK 0xF3 -#define LED_FAN_GMASK 0x04 -#define LED_FAN_YMASK 0x08 -#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 -#define CPLD_VER_OFFSET 0x01 - -/* QSFP */ -#define QSFP_PRES_REG1 0x20 -#define QSFP_PRES_REG2 0x21 -#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 */ -typedef enum led_id_e { - LED_SYSTEM_LED = 1, - 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 */ -typedef enum thermal_oid_e { - THERMAL_OID_FRONT_MAC = ONLP_THERMAL_ID_CREATE(1), - THERMAL_OID_REAR_MAC = ONLP_THERMAL_ID_CREATE(2), - THERMAL_OID_CPU1 = ONLP_THERMAL_ID_CREATE(3), - THERMAL_OID_CPU2 = ONLP_THERMAL_ID_CREATE(4), - THERMAL_OID_CPU3 = ONLP_THERMAL_ID_CREATE(5), - THERMAL_OID_CPU4 = ONLP_THERMAL_ID_CREATE(6), - THERMAL_OID_PSU1_1 = ONLP_THERMAL_ID_CREATE(7), - THERMAL_OID_PSU1_2 = ONLP_THERMAL_ID_CREATE(8), - THERMAL_OID_PSU2_1 = ONLP_THERMAL_ID_CREATE(9), - THERMAL_OID_PSU2_2 = ONLP_THERMAL_ID_CREATE(10) -} thermal_oid_t; - -/** thermal_id */ -typedef enum thermal_id_e { - THERMAL_ID_FRONT_MAC = 1, - THERMAL_ID_REAR_MAC = 2, - THERMAL_ID_CPU1 = 3, - THERMAL_ID_CPU2 = 4, - THERMAL_ID_CPU3 = 5, - THERMAL_ID_CPU4 = 6, - THERMAL_ID_PSU1_1 = 7, - THERMAL_ID_PSU1_2 = 8, - THERMAL_ID_PSU2_1 = 9, - THERMAL_ID_PSU2_2 = 10, -} thermal_id_t; - -/* Shortcut for CPU thermal threshold value. */ -#define THERMAL_THRESHOLD_INIT_DEFAULTS \ - { THERMAL_WARNING_DEFAULT, \ - THERMAL_ERROR_DEFAULT, \ - THERMAL_SHUTDOWN_DEFAULT } - -/** 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_PSU_FAN1 = ONLP_FAN_ID_CREATE(9), - FAN_OID_PSU_FAN2 = ONLP_FAN_ID_CREATE(10) -} fan_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_PSU_FAN1 = 9, - FAN_ID_PSU_FAN2 = 10 -} fan_id_t; - -/** led_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; - -/** fan_id */ -typedef enum psu_id_e { - PSU_ID_PSU1 = 1, - PSU_ID_PSU2 = 2 -} psu_id_t; - -int psu_thermal_get(onlp_thermal_info_t* info, int id); - -int psu_fan_info_get(onlp_fan_info_t* info, int id); - -int psu_vout_get(onlp_psu_info_t* info, int i2c_bus); - -int psu_iout_get(onlp_psu_info_t* info, int i2c_bus); - -int psu_pout_get(onlp_psu_info_t* info, int i2c_bus); - -int psu_pin_get(onlp_psu_info_t* info, int i2c_bus); - -int psu_eeprom_get(onlp_psu_info_t* info, int id); - -int psu_present_get(int *pw_exist, int i2c_bus, int psu_mask); - -int psu_pwgood_get(int *pw_good, int i2c_bus, int psu_mask); - -int psu2_led_set(onlp_led_mode_t mode); - -int psu1_led_set(onlp_led_mode_t mode); - -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); - -#endif /* __PLATFORM_LIB_H__ */ diff --git a/packages/platforms/ingrasys/x86-64/s9100/onlp/builds/x86_64_ingrasys_s9100/module/src/psui.c b/packages/platforms/ingrasys/x86-64/s9100/onlp/builds/x86_64_ingrasys_s9100/module/src/psui.c deleted file mode 100755 index 52f0d92fe..000000000 --- a/packages/platforms/ingrasys/x86-64/s9100/onlp/builds/x86_64_ingrasys_s9100/module/src/psui.c +++ /dev/null @@ -1,152 +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 - -#include "platform_lib.h" - -static onlp_psu_info_t pinfo[] = -{ - { }, /* Not used */ - { - { - PSU_OID_PSU1, - "PSU-1", - 0, - { - FAN_OID_PSU_FAN1, - }, - } - }, - { - { - PSU_OID_PSU2, - "PSU-2", - 0, - { - FAN_OID_PSU_FAN2, - }, - } - } -}; - -int -onlp_psui_init(void) -{ - return ONLP_STATUS_OK; -} - -int -psu_status_info_get(int id, onlp_psu_info_t *info) -{ - int pw_exist, pw_good, rc, psu_mask, i2c_bus; - - if (id == PSU_ID_PSU1) { - i2c_bus = I2C_BUS_8; - psu_mask = PSU1_MUX_MASK; - } else if (id == PSU_ID_PSU2) { - i2c_bus = I2C_BUS_9; - psu_mask = PSU2_MUX_MASK; - } else { - return ONLP_STATUS_E_INTERNAL; - } - - /* Get power present status */ - if ((rc = psu_present_get(&pw_exist, 0, psu_mask)) != ONLP_STATUS_OK) { - return ONLP_STATUS_E_INTERNAL; - } - - if (pw_exist != PSU_STATUS_PRESENT) { - info->status &= ~ONLP_PSU_STATUS_PRESENT; - info->status |= ONLP_PSU_STATUS_FAILED; - return ONLP_STATUS_OK; - } - info->status |= ONLP_PSU_STATUS_PRESENT; - - /* Get power good status */ - if ((rc = psu_pwgood_get(&pw_good, 0, psu_mask)) != ONLP_STATUS_OK) { - return ONLP_STATUS_E_INTERNAL; - } - - 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 */ - if ((rc = psu_eeprom_get(info, id)) != ONLP_STATUS_OK) { - return ONLP_STATUS_E_INTERNAL; - } - - /* Get power iout status */ - if ((rc = psu_iout_get(info, i2c_bus)) != ONLP_STATUS_OK) { - return ONLP_STATUS_E_INTERNAL; - } - - /* Get power pout status */ - if ((rc = psu_pout_get(info, i2c_bus)) != ONLP_STATUS_OK) { - return ONLP_STATUS_E_INTERNAL; - } - - /* Get power pin status */ - if ((rc = psu_pin_get(info, i2c_bus)) != ONLP_STATUS_OK) { - return ONLP_STATUS_E_INTERNAL; - } - - /* Get power vout status */ - if ((rc = psu_vout_get(info, i2c_bus)) != ONLP_STATUS_OK) { - return ONLP_STATUS_E_INTERNAL; - } - - return ONLP_STATUS_OK; -} - -int -onlp_psui_info_get(onlp_oid_t id, onlp_psu_info_t* info) -{ - int pid; - - pid = ONLP_OID_ID_GET(id); - memset(info, 0, sizeof(onlp_psu_info_t)); - - /* Set the onlp_oid_hdr_t */ - *info = pinfo[pid]; - - switch (pid) { - case PSU_ID_PSU1: - case PSU_ID_PSU2: - return psu_status_info_get(pid, info); - break; - default: - return ONLP_STATUS_E_UNSUPPORTED; - break; - } - - return ONLP_STATUS_OK; - - -} diff --git a/packages/platforms/ingrasys/x86-64/s9100/onlp/builds/x86_64_ingrasys_s9100/module/src/sfpi.c b/packages/platforms/ingrasys/x86-64/s9100/onlp/builds/x86_64_ingrasys_s9100/module/src/sfpi.c deleted file mode 100755 index eb2b6737a..000000000 --- a/packages/platforms/ingrasys/x86-64/s9100/onlp/builds/x86_64_ingrasys_s9100/module/src/sfpi.c +++ /dev/null @@ -1,159 +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 -#include -#include -#include -#include -#include -#include "x86_64_ingrasys_s9100_log.h" -#include "platform_lib.h" - -int -onlp_sfpi_init(void) -{ - return ONLP_STATUS_OK; -} - -int -onlp_sfpi_bitmap_get(onlp_sfp_bitmap_t* bmap) -{ - int p; - for(p = 1; p <= QSFP_NUM; p++) { - AIM_BITMAP_SET(bmap, p); - } - return ONLP_STATUS_OK; -} - -int -onlp_sfpi_is_present(int port) -{ - int status, presentchan, rc, pres_val; - - if ((rc = qsfp_present_get(port, &pres_val)) != ONLP_STATUS_OK) { - return ONLP_STATUS_E_INTERNAL; - } - - presentchan = (( (port - 1) % 8 )); - presentchan = (( ((presentchan % 2)) == 1 ? presentchan - 1 : presentchan + 1 )); - - /* status: 0 -> Down, 1 -> Up */ - status=(( ((pres_val & ( 1 << presentchan))) != 0 ? 0 : 1 )); - - return status; -} - - -int -onlp_sfpi_presence_bitmap_get(onlp_sfp_bitmap_t* dst) -{ - int p = 1; - int rc = 0; - - for (p = 1; p <= QSFP_NUM; p++) { - rc = onlp_sfpi_is_present(p); - AIM_BITMAP_MOD(dst, p, (1 == rc) ? 1 : 0); - } - - return ONLP_STATUS_OK; -} - -/* - * This function reads the SFPs idrom and returns in - * in the data buffer provided. - */ -int -onlp_sfpi_eeprom_read(int port, uint8_t data[256]) -{ - int eeprombusidx, eeprombus, eeprombusbase; - char eeprom_path[512], eeprom_addr[32]; - memset(eeprom_path, 0, sizeof(eeprom_path)); - memset(eeprom_addr, 0, sizeof(eeprom_addr)); - aim_strlcpy(eeprom_addr, "0050", sizeof(eeprom_addr)); - - memset(data, 0, 256); - - if (port >= 1 && port <= 8) { - eeprombusbase=10; - } else if (port >= 9 && port <= 16) { - eeprombusbase=18; - } else if (port >= 17 && port <= 24) { - eeprombusbase=26; - } else if (port >= 25 && port <= 32) { - eeprombusbase=34; - } else { - return 0; - } - - eeprombusidx = port % 8; - switch (eeprombusidx) { - case 1: - eeprombus = eeprombusbase + 1; - break; - case 2: - eeprombus = eeprombusbase + 0; - break; - case 3: - eeprombus = eeprombusbase + 3; - break; - case 4: - eeprombus = eeprombusbase + 2; - break; - case 5: - eeprombus = eeprombusbase + 5; - break; - case 6: - eeprombus = eeprombusbase + 4; - break; - case 7: - eeprombus = eeprombusbase + 7; - break; - case 0: - eeprombus = eeprombusbase + 6; - break; - default: - return ONLP_STATUS_E_INTERNAL; - break; - } - - snprintf(eeprom_path, sizeof(eeprom_path), - "/sys/bus/i2c/devices/%d-%s/eeprom", eeprombus, eeprom_addr); - - if (onlplib_sfp_eeprom_read_file(eeprom_path, data) != 0) { - AIM_LOG_INFO("Unable to read eeprom from port(%d)\r\n", port); - return ONLP_STATUS_E_INTERNAL; - } - - return ONLP_STATUS_OK; -} - -/* - * De-initialize the SFPI subsystem. - */ -int -onlp_sfpi_denit(void) -{ - return ONLP_STATUS_OK; -} diff --git a/packages/platforms/ingrasys/x86-64/s9100/onlp/builds/x86_64_ingrasys_s9100/module/src/sysi.c b/packages/platforms/ingrasys/x86-64/s9100/onlp/builds/x86_64_ingrasys_s9100/module/src/sysi.c deleted file mode 100755 index d21e112ea..000000000 --- a/packages/platforms/ingrasys/x86-64/s9100/onlp/builds/x86_64_ingrasys_s9100/module/src/sysi.c +++ /dev/null @@ -1,340 +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 -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "platform_lib.h" - -const char* -onlp_sysi_platform_get(void) -{ - return "x86-64-ingrasys-s9100-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(SYS_EEPROM_SIZE); - if(onlp_file_read(rdata, SYS_EEPROM_SIZE, size, SYS_EEPROM_PATH) == ONLP_STATUS_OK) { - if(*size == SYS_EEPROM_SIZE) { - AIM_LOG_INFO("read success\n"); - *data = rdata; - return ONLP_STATUS_OK; - } - } - - AIM_LOG_INFO("Unable to data get eeprom \n"); - aim_free(rdata); - *size = 0; - return ONLP_STATUS_E_INTERNAL; -} - -int -onlp_sysi_oids_get(onlp_oid_t* table, int max) -{ - onlp_oid_t* e = table; - memset(table, 0, max*sizeof(onlp_oid_t)); - int i; - - /* 2 PSUs */ - *e++ = ONLP_PSU_ID_CREATE(1); - *e++ = ONLP_PSU_ID_CREATE(2); - - /* LEDs Item */ - for (i=1; i<=LED_NUM; i++) { - *e++ = ONLP_LED_ID_CREATE(i); - } - - /* THERMALs Item */ - for (i=1; i<=THERMAL_NUM; i++) { - *e++ = ONLP_THERMAL_ID_CREATE(i); - } - - /* Fans Item */ - for (i=1; i<=FAN_NUM; i++) { - *e++ = ONLP_FAN_ID_CREATE(i); - } - - return ONLP_STATUS_OK; -} - -int -decide_fan_percentage(int is_up, int new_temp) -{ - int new_perc; - if (is_up) { - if (new_temp >= THERMAL_ERROR_DEFAULT) { - new_perc = THERMAL_ERROR_FAN_PERC; - } else if (new_temp >= THERMAL_WARNING_DEFAULT) { - new_perc = THERMAL_WARNING_FAN_PERC; - } else { - new_perc = THERMAL_NORMAL_FAN_PERC; - } - } else { - if (new_temp <= THERMAL_NORMAL_DEFAULT) { - new_perc = THERMAL_NORMAL_FAN_PERC; - } else if (new_temp <= THERMAL_WARNING_DEFAULT) { - new_perc = THERMAL_WARNING_FAN_PERC; - } else { - new_perc = THERMAL_ERROR_FAN_PERC; - } - } - - return new_perc; -} - -int -platform_thermal_temp_get(int *thermal_temp) -{ - int i, temp, max_temp, rc; - onlp_thermal_info_t thermal_info; - memset(&thermal_info, 0, sizeof(thermal_info)); - uint32_t thermal_arr[] = { THERMAL_OID_FRONT_MAC, - THERMAL_OID_REAR_MAC, - THERMAL_OID_CPU1, - THERMAL_OID_CPU2, - THERMAL_OID_CPU3, - THERMAL_OID_CPU4 }; - max_temp = 0; - - for (i=0; i max_temp) { - max_temp = temp; - } - } - *thermal_temp = max_temp; - - return ONLP_STATUS_OK; -} - -int -onlp_sysi_platform_manage_fans(void) -{ - int rc, is_up ,new_temp, thermal_temp, diff; - static int new_perc = 0, ori_perc = 0; - static int ori_temp = 0; - onlp_thermal_info_t thermal_info; - memset(&thermal_info, 0, sizeof(thermal_info)); - - /* get new temperature */ - if ((rc = platform_thermal_temp_get(&thermal_temp)) != ONLP_STATUS_OK) { - goto _EXIT; - } - - new_temp = thermal_temp; - diff = new_temp - ori_temp; - - if (diff == 0) { - goto _EXIT; - } else { - is_up = (diff > 0 ? 1 : 0); - } - - new_perc = decide_fan_percentage(is_up, new_temp); - - if (ori_perc == new_perc) { - goto _EXIT; - } - - - AIM_LOG_INFO("Front Fan Speeds Percent are now at %d%%", new_perc); - - if ((rc = onlp_fani_percentage_set(THERMAL_OID_FRONT_MAC, new_perc)) != ONLP_STATUS_OK) { - goto _EXIT; - } - - /* update */ - ori_perc = new_perc; - ori_temp = new_temp; - -_EXIT : - return rc; -} - -int -onlp_sysi_platform_manage_leds(void) -{ - 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, - FAN_OID_FAN4, - FAN_OID_FAN5, - FAN_OID_FAN6, - 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; - } - - psu1_status = psu_info.status; - if (psu1_status != pre_psu1_status) { - 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); - } - - if (rc != ONLP_STATUS_OK) { - goto _EXIT; - } - pre_psu1_status = psu1_status; - } - - if ((rc = onlp_psui_info_get(PSU_OID_PSU2, &psu_info)) != ONLP_STATUS_OK) { - goto _EXIT; - } - - psu2_status = psu_info.status; - if( psu2_status != pre_psu2_status) { - 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); - } - - if (rc != ONLP_STATUS_OK) { - goto _EXIT; - } - pre_psu2_status = psu2_status; - } - - /* FAN LED CTRL */ - - 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 (rc != ONLP_STATUS_OK) { - goto _EXIT; - } - - pre_fan_tray_status[fan_tray_id - 5] = sum; - } - } - } - - 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; - } - -_EXIT : - return rc; -} - -int -onlp_sysi_platform_info_get(onlp_platform_info_t* pi) -{ - int rc; - if ((rc = sysi_platform_info_get(pi)) != ONLP_STATUS_OK) { - return ONLP_STATUS_E_INTERNAL; - } - - return ONLP_STATUS_OK; -} - diff --git a/packages/platforms/ingrasys/x86-64/s9100/onlp/builds/x86_64_ingrasys_s9100/module/src/thermali.c b/packages/platforms/ingrasys/x86-64/s9100/onlp/builds/x86_64_ingrasys_s9100/module/src/thermali.c deleted file mode 100755 index 50f48c8d3..000000000 --- a/packages/platforms/ingrasys/x86-64/s9100/onlp/builds/x86_64_ingrasys_s9100/module/src/thermali.c +++ /dev/null @@ -1,181 +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. - * - * - ************************************************************ - * - * Thermal Sensor Platform Implementation. - * - ***********************************************************/ -#include -#include -#include "x86_64_ingrasys_s9100_log.h" -#include "platform_lib.h" - -static onlp_thermal_info_t thermal_info[] = { - { }, /* Not used */ - { { THERMAL_OID_FRONT_MAC, "Chassis Thermal (Front)", 0}, - ONLP_THERMAL_STATUS_PRESENT, - ONLP_THERMAL_CAPS_ALL, 0, THERMAL_THRESHOLD_INIT_DEFAULTS - }, - { { THERMAL_OID_REAR_MAC, "Chassis Thermal (Rear)", 0}, - ONLP_THERMAL_STATUS_PRESENT, - ONLP_THERMAL_CAPS_ALL, 0, THERMAL_THRESHOLD_INIT_DEFAULTS - }, - { { THERMAL_OID_CPU1, "CPU Thermal 1", 0}, - ONLP_THERMAL_STATUS_PRESENT, - ONLP_THERMAL_CAPS_ALL, 0, THERMAL_THRESHOLD_INIT_DEFAULTS - }, - { { THERMAL_OID_CPU2, "CPU Thermal 2", 0}, - ONLP_THERMAL_STATUS_PRESENT, - ONLP_THERMAL_CAPS_ALL, 0, THERMAL_THRESHOLD_INIT_DEFAULTS - }, - { { THERMAL_OID_CPU3, "CPU Thermal 3", 0}, - ONLP_THERMAL_STATUS_PRESENT, - ONLP_THERMAL_CAPS_ALL, 0, THERMAL_THRESHOLD_INIT_DEFAULTS - }, - { { THERMAL_OID_CPU4, "CPU Thermal 4", 0}, - ONLP_THERMAL_STATUS_PRESENT, - ONLP_THERMAL_CAPS_ALL, 0, THERMAL_THRESHOLD_INIT_DEFAULTS - }, - { { THERMAL_OID_PSU1_1, "PSU-1 Thermal 1", PSU_OID_PSU1}, - ONLP_THERMAL_STATUS_PRESENT, - ONLP_THERMAL_CAPS_GET_TEMPERATURE, 0 - }, - { { THERMAL_OID_PSU1_2, "PSU-1 Thermal 2", PSU_OID_PSU1}, - ONLP_THERMAL_STATUS_PRESENT, - ONLP_THERMAL_CAPS_GET_TEMPERATURE, 0 - }, - { { THERMAL_OID_PSU2_1, "PSU-2 Thermal 1", PSU_OID_PSU2}, - ONLP_THERMAL_STATUS_PRESENT, - ONLP_THERMAL_CAPS_GET_TEMPERATURE, 0 - }, - { { THERMAL_OID_PSU2_2, "PSU-2 Thermal 2", PSU_OID_PSU2}, - ONLP_THERMAL_STATUS_PRESENT, - ONLP_THERMAL_CAPS_GET_TEMPERATURE, 0 - } -}; - -/* - * This will be called to intiialize the thermali subsystem. - */ -int -onlp_thermali_init(void) -{ - return ONLP_STATUS_OK; -} - -static int -sys_thermal_info_get(onlp_thermal_info_t* info, int id) -{ - int rv; - - rv = onlp_file_read_int(&info->mcelsius, - SYS_FAN_PREFIX "/temp%d_input", id); - - if(rv == ONLP_STATUS_E_INTERNAL) { - return rv; - } - - if(rv == ONLP_STATUS_E_MISSING) { - info->status &= ~1; - return 0; - } - - return ONLP_STATUS_OK; -} - -static int -cpu_thermal_info_get(onlp_thermal_info_t* info, int id) -{ - int rv; - int offset; - offset = 1; - id = id - offset; - rv = onlp_file_read_int(&info->mcelsius, - SYS_CORE_TEMP_PREFIX "/temp%d_input", id); - - if(rv == ONLP_STATUS_E_INTERNAL) { - return rv; - } - - if(rv == ONLP_STATUS_E_MISSING) { - info->status &= ~1; - return 0; - } - - return ONLP_STATUS_OK; -} - - -int -psu_thermal_info_get(onlp_thermal_info_t* info, int id) -{ - int rv; - - rv = psu_thermal_get(info, id); - if(rv == ONLP_STATUS_E_INTERNAL) { - return rv; - } - - 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 sensor_id, rc; - sensor_id = ONLP_OID_ID_GET(id); - - *info = thermal_info[sensor_id]; - info->caps |= ONLP_THERMAL_CAPS_GET_TEMPERATURE; - - switch (sensor_id) { - case THERMAL_ID_FRONT_MAC: - case THERMAL_ID_REAR_MAC: - rc = sys_thermal_info_get(info, sensor_id); - break; - case THERMAL_ID_CPU1: - case THERMAL_ID_CPU2: - case THERMAL_ID_CPU3: - case THERMAL_ID_CPU4: - rc = cpu_thermal_info_get(info, sensor_id); - break; - case THERMAL_ID_PSU1_1: - case THERMAL_ID_PSU1_2: - case THERMAL_ID_PSU2_1: - case THERMAL_ID_PSU2_2: - rc = psu_thermal_info_get(info, sensor_id); - break; - default: - return ONLP_STATUS_E_INTERNAL; - break; - } - - return rc; -} diff --git a/packages/platforms/ingrasys/x86-64/s9100/onlp/builds/x86_64_ingrasys_s9100/module/src/x86_64_ingrasys_s9100_config.c b/packages/platforms/ingrasys/x86-64/s9100/onlp/builds/x86_64_ingrasys_s9100/module/src/x86_64_ingrasys_s9100_config.c deleted file mode 100755 index 79a092aa9..000000000 --- a/packages/platforms/ingrasys/x86-64/s9100/onlp/builds/x86_64_ingrasys_s9100/module/src/x86_64_ingrasys_s9100_config.c +++ /dev/null @@ -1,96 +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 __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_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_INGRASYS_S9100_CONFIG_INCLUDE_LOGGING(__x86_64_ingrasys_s9100_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#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_INGRASYS_S9100_CONFIG_LOG_OPTIONS_DEFAULT(__x86_64_ingrasys_s9100_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#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_INGRASYS_S9100_CONFIG_LOG_BITS_DEFAULT(__x86_64_ingrasys_s9100_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#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_INGRASYS_S9100_CONFIG_LOG_CUSTOM_BITS_DEFAULT(__x86_64_ingrasys_s9100_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#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_INGRASYS_S9100_CONFIG_PORTING_STDLIB(__x86_64_ingrasys_s9100_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#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_INGRASYS_S9100_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS(__x86_64_ingrasys_s9100_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#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_INGRASYS_S9100_CONFIG_INCLUDE_UCLI(__x86_64_ingrasys_s9100_config_STRINGIFY_NAME), "__undefined__" }, -#endif - { NULL, NULL } -}; -#undef __x86_64_ingrasys_s9100_config_STRINGIFY_VALUE -#undef __x86_64_ingrasys_s9100_config_STRINGIFY_NAME - -const char* -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)) { - return x86_64_ingrasys_s9100_config_settings[i].value; - } - } - return NULL; -} - -int -x86_64_ingrasys_s9100_config_show(struct aim_pvs_s* pvs) -{ - int i; - for(i = 0; x86_64_ingrasys_s9100_config_settings[i].name; i++) { - aim_printf(pvs, "%s = %s\n", x86_64_ingrasys_s9100_config_settings[i].name, x86_64_ingrasys_s9100_config_settings[i].value); - } - return i; -} - -/* */ - diff --git a/packages/platforms/ingrasys/x86-64/s9100/onlp/builds/x86_64_ingrasys_s9100/module/src/x86_64_ingrasys_s9100_enums.c b/packages/platforms/ingrasys/x86-64/s9100/onlp/builds/x86_64_ingrasys_s9100/module/src/x86_64_ingrasys_s9100_enums.c deleted file mode 100755 index 6bbc233ce..000000000 --- a/packages/platforms/ingrasys/x86-64/s9100/onlp/builds/x86_64_ingrasys_s9100/module/src/x86_64_ingrasys_s9100_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/ingrasys/x86-64/s9100/onlp/builds/x86_64_ingrasys_s9100/module/src/x86_64_ingrasys_s9100_int.h b/packages/platforms/ingrasys/x86-64/s9100/onlp/builds/x86_64_ingrasys_s9100/module/src/x86_64_ingrasys_s9100_int.h deleted file mode 100755 index f1921224d..000000000 --- a/packages/platforms/ingrasys/x86-64/s9100/onlp/builds/x86_64_ingrasys_s9100/module/src/x86_64_ingrasys_s9100_int.h +++ /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. - * - * - ************************************************************ - * - * - * - ***********************************************************/ - -#ifndef __x86_64_ingrasys_s9100_INT_H__ -#define __x86_64_ingrasys_s9100_INT_H__ - -#endif /* __x86_64_ingrasys_s9100_INT_H__ */ diff --git a/packages/platforms/ingrasys/x86-64/s9100/onlp/builds/x86_64_ingrasys_s9100/module/src/x86_64_ingrasys_s9100_log.c b/packages/platforms/ingrasys/x86-64/s9100/onlp/builds/x86_64_ingrasys_s9100/module/src/x86_64_ingrasys_s9100_log.c deleted file mode 100755 index da647a75b..000000000 --- a/packages/platforms/ingrasys/x86-64/s9100/onlp/builds/x86_64_ingrasys_s9100/module/src/x86_64_ingrasys_s9100_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 "x86_64_ingrasys_s9100_log.h" -/* - * x86_64_ingrasys_s9100 log struct. - */ -AIM_LOG_STRUCT_DEFINE( - X86_64_INGRASYS_S9100_CONFIG_LOG_OPTIONS_DEFAULT, - X86_64_INGRASYS_S9100_CONFIG_LOG_BITS_DEFAULT, - NULL, /* Custom log map */ - X86_64_INGRASYS_S9100_CONFIG_LOG_CUSTOM_BITS_DEFAULT - ); - diff --git a/packages/platforms/ingrasys/x86-64/s9100/onlp/builds/x86_64_ingrasys_s9100/module/src/x86_64_ingrasys_s9100_log.h b/packages/platforms/ingrasys/x86-64/s9100/onlp/builds/x86_64_ingrasys_s9100/module/src/x86_64_ingrasys_s9100_log.h deleted file mode 100755 index 2c2347033..000000000 --- a/packages/platforms/ingrasys/x86-64/s9100/onlp/builds/x86_64_ingrasys_s9100/module/src/x86_64_ingrasys_s9100_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 __x86_64_ingrasys_s9100_LOG_H__ -#define __x86_64_ingrasys_s9100_LOG_H__ - -#define AIM_LOG_MODULE_NAME x86_64_ingrasys_s9100 -#include - -#endif /* __x86_64_ingrasys_s9100_LOG_H__ */ diff --git a/packages/platforms/ingrasys/x86-64/s9100/onlp/builds/x86_64_ingrasys_s9100/module/src/x86_64_ingrasys_s9100_module.c b/packages/platforms/ingrasys/x86-64/s9100/onlp/builds/x86_64_ingrasys_s9100/module/src/x86_64_ingrasys_s9100_module.c deleted file mode 100755 index 5711fc4a9..000000000 --- a/packages/platforms/ingrasys/x86-64/s9100/onlp/builds/x86_64_ingrasys_s9100/module/src/x86_64_ingrasys_s9100_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 "x86_64_ingrasys_s9100_log.h" - -static int -datatypes_init__(void) -{ -#define INGRASYS_S9100_ENUMERATION_ENTRY(_enum_name, _desc) AIM_DATATYPE_MAP_REGISTER(_enum_name, _enum_name##_map, _desc, AIM_LOG_INTERNAL); -#include - return 0; -} - -void __x86_64_ingrasys_s9100_module_init__(void) -{ - AIM_LOG_STRUCT_REGISTER(); - datatypes_init__(); -} - -int __onlp_platform_version__ = 1; diff --git a/packages/platforms/ingrasys/x86-64/s9100/onlp/builds/x86_64_ingrasys_s9100/module/src/x86_64_ingrasys_s9100_ucli.c b/packages/platforms/ingrasys/x86-64/s9100/onlp/builds/x86_64_ingrasys_s9100/module/src/x86_64_ingrasys_s9100_ucli.c deleted file mode 100755 index 54d8b9a7b..000000000 --- a/packages/platforms/ingrasys/x86-64/s9100/onlp/builds/x86_64_ingrasys_s9100/module/src/x86_64_ingrasys_s9100_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 X86_64_INGRASYS_9100_CONFIG_INCLUDE_UCLI == 1 - -#include -#include -#include - -static ucli_status_t -x86_64_ingrasys_s9100_ucli_ucli__config__(ucli_context_t* uc) -{ - UCLI_HANDLER_MACRO_MODULE_CONFIG(x86_64_ingrasys_s9100) -} - -/* */ -/****************************************************************************** - * - * These handler table(s) were autogenerated from the symbols in this - * source file. - * - *****************************************************************************/ -static ucli_command_handler_f x86_64_ingrasys_s9100_ucli_ucli_handlers__[] = -{ - x86_64_ingrasys_s9100_ucli_ucli__config__, - NULL -}; -/******************************************************************************/ -/* */ - -static ucli_module_t -x86_64_ingrasys_s9100_ucli_module__ = - { - "x86_64_ingrasys_s9100_ucli", - NULL, - x86_64_ingrasys_s9100_ucli_ucli_handlers__, - NULL, - NULL, - }; - -ucli_node_t* -x86_64_ingrasys_s9100_ucli_node_create(void) -{ - ucli_node_t* n; - ucli_module_init(&x86_64_ingrasys_s9100_ucli_module__); - n = ucli_node_create("x86_64_ingrasys_s9100", NULL, &x86_64_ingrasys_s9100_ucli_module__); - ucli_node_subnode_add(n, ucli_module_log_node_create("x86_64_ingrasys_s9100")); - return n; -} - -#else -void* -x86_64_ingrasys_s9100_ucli_node_create(void) -{ - return NULL; -} -#endif - diff --git a/packages/platforms/ingrasys/x86-64/s9100/platform-config/Makefile b/packages/platforms/ingrasys/x86-64/s9100/platform-config/Makefile deleted file mode 100755 index 003238cf6..000000000 --- a/packages/platforms/ingrasys/x86-64/s9100/platform-config/Makefile +++ /dev/null @@ -1 +0,0 @@ -include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/ingrasys/x86-64/s9100/platform-config/r0/Makefile b/packages/platforms/ingrasys/x86-64/s9100/platform-config/r0/Makefile deleted file mode 100755 index 003238cf6..000000000 --- a/packages/platforms/ingrasys/x86-64/s9100/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/ingrasys/x86-64/s9100/platform-config/r0/PKG.yml b/packages/platforms/ingrasys/x86-64/s9100/platform-config/r0/PKG.yml deleted file mode 100755 index afedc8f30..000000000 --- a/packages/platforms/ingrasys/x86-64/s9100/platform-config/r0/PKG.yml +++ /dev/null @@ -1 +0,0 @@ -!include $ONL_TEMPLATES/platform-config-platform.yml ARCH=amd64 VENDOR=ingrasys BASENAME=x86-64-ingrasys-s9100 REVISION=r0 diff --git a/packages/platforms/ingrasys/x86-64/s9100/platform-config/r0/src/lib/x86-64-ingrasys-s9100-r0.yml b/packages/platforms/ingrasys/x86-64/s9100/platform-config/r0/src/lib/x86-64-ingrasys-s9100-r0.yml deleted file mode 100755 index 7d45ee0d9..000000000 --- a/packages/platforms/ingrasys/x86-64/s9100/platform-config/r0/src/lib/x86-64-ingrasys-s9100-r0.yml +++ /dev/null @@ -1,30 +0,0 @@ ---- - -###################################################################### -# -# platform-config for x86-64-ingrasys-s9100 -# -###################################################################### - -x86-64-ingrasys-s9100-r0: - - grub: - - serial: >- - --port=0x2f8 - --speed=115200 - --word=8 - --parity=no - --stop=1 - - kernel: - <<: *kernel-3-16 - - args: >- - console=ttyS1,115200n8 - - ##network - ## interfaces: - ## ma1: - ## name: ~ - ## syspath: pci0000:00/0000:00:03.0 diff --git a/packages/platforms/ingrasys/x86-64/s9100/platform-config/r0/src/python/x86_64_ingrasys_s9100_r0/__init__.py b/packages/platforms/ingrasys/x86-64/s9100/platform-config/r0/src/python/x86_64_ingrasys_s9100_r0/__init__.py deleted file mode 100755 index 3b6ad44ee..000000000 --- a/packages/platforms/ingrasys/x86-64/s9100/platform-config/r0/src/python/x86_64_ingrasys_s9100_r0/__init__.py +++ /dev/null @@ -1,574 +0,0 @@ -from onl.platform.base import * -from onl.platform.ingrasys import * -import os - -class OnlPlatform_x86_64_ingrasys_s9100_r0(OnlPlatformIngrasys): - PLATFORM='x86-64-ingrasys-s9100-r0' - MODEL="s9100" - SYS_OBJECT_ID=".8.1" - - def baseconfig(self): - - os.system("modprobe i2c_ismt") - self.insmod("eeprom_mb") - os.system("modprobe w83795") - os.system("modprobe eeprom") - os.system("modprobe gpio_pca953x") - self.insmod("optoe") - - ########### initialize I2C bus 1 ########### - self.new_i2c_device('pca9548', 0x70, 1) - - # initialize i2c - self.new_i2c_devices( - [ - ('pca9548', 0x71, 2), - ('pca9548', 0x72, 3), - ('pca9548', 0x73, 4), - ('pca9548', 0x74, 5), - ] - ) - - # initialize SMBUS0 IO Expander - os.system("i2cset -y 0 0x27 4 0x00") - os.system("i2cset -y 0 0x27 5 0x00") - os.system("i2cset -y 0 0x27 2 0x00") - os.system("i2cset -y 0 0x27 3 0x00") - os.system("i2cset -y 0 0x27 6 0xFF") - os.system("i2cset -y 0 0x27 7 0xFF") - - # initialize SMBUS1 ABS - os.system("i2cset -y 6 0x20 4 0x00") - os.system("i2cset -y 6 0x20 5 0x00") - os.system("i2cset -y 6 0x20 6 0xFF") - os.system("i2cset -y 6 0x20 7 0xFF") - - os.system("i2cset -y 6 0x21 4 0x00") - os.system("i2cset -y 6 0x21 5 0x00") - os.system("i2cset -y 6 0x21 6 0xFF") - os.system("i2cset -y 6 0x21 7 0xFF") - # initialize Transcevior INT - os.system("i2cset -y -r 6 0x22 4 0x00") - os.system("i2cset -y -r 6 0x22 5 0x00") - os.system("i2cset -y -r 6 0x22 6 0xFF") - os.system("i2cset -y -r 6 0x22 7 0xFF") - - os.system("i2cset -y -r 6 0x23 4 0x00") - os.system("i2cset -y -r 6 0x23 5 0x00") - os.system("i2cset -y -r 6 0x23 6 0xFF") - os.system("i2cset -y -r 6 0x23 7 0xFF") - - # initialize set ZQSFP LP_MODE = 0 - os.system("i2cset -y -r 7 0x20 4 0x00") - os.system("i2cset -y -r 7 0x20 5 0x00") - os.system("i2cset -y -r 7 0x20 2 0x00") - os.system("i2cset -y -r 7 0x20 3 0x00") - os.system("i2cset -y -r 7 0x20 6 0x00") - os.system("i2cset -y -r 7 0x20 7 0x00") - - os.system("i2cset -y -r 7 0x21 4 0x00") - os.system("i2cset -y -r 7 0x21 5 0x00") - os.system("i2cset -y -r 7 0x21 2 0x00") - os.system("i2cset -y -r 7 0x21 3 0x00") - os.system("i2cset -y -r 7 0x21 6 0x00") - os.system("i2cset -y -r 7 0x21 7 0x00") - - # initialize set ZQSFP RST = 1 - os.system("i2cset -y -r 7 0x22 4 0x00") - os.system("i2cset -y -r 7 0x22 5 0x00") - os.system("i2cset -y -r 7 0x22 2 0xFF") - os.system("i2cset -y -r 7 0x22 3 0xFF") - os.system("i2cset -y -r 7 0x22 6 0x00") - os.system("i2cset -y -r 7 0x22 7 0x00") - - os.system("i2cset -y -r 7 0x23 4 0x00") - os.system("i2cset -y -r 7 0x23 5 0x00") - os.system("i2cset -y -r 7 0x23 2 0xFF") - os.system("i2cset -y -r 7 0x23 3 0xFF") - os.system("i2cset -y -r 7 0x23 6 0x00") - os.system("i2cset -y -r 7 0x23 7 0x00") - - # initialize set ZQSFP mode - os.system("i2cset -y -r 7 0x24 4 0x00") - os.system("i2cset -y -r 7 0x24 5 0x00") - os.system("i2cset -y -r 7 0x24 2 0x00") - os.system("i2cset -y -r 7 0x24 3 0x00") - os.system("i2cset -y -r 7 0x24 6 0x00") - os.system("i2cset -y -r 7 0x24 7 0x00") - - os.system("i2cset -y -r 7 0x25 4 0x00") - os.system("i2cset -y -r 7 0x25 5 0x00") - os.system("i2cset -y -r 7 0x25 2 0x00") - os.system("i2cset -y -r 7 0x25 3 0x00") - os.system("i2cset -y -r 7 0x25 6 0x00") - os.system("i2cset -y -r 7 0x25 7 0x00") - - # initialize ZQSFP/SFP+/E-Card General - os.system("i2cset -y -r 8 0x20 4 0x00") - os.system("i2cset -y -r 8 0x20 5 0x00") - os.system("i2cset -y -r 8 0x20 6 0xFF") - os.system("i2cset -y -r 8 0x20 7 0xFF") - - # initialize LED board after PVT (S9100_IO_EXP_LED_ID) - os.system("i2cset -y -r 9 0x22 4 0x00") - os.system("i2cset -y -r 9 0x22 5 0x00") - os.system("i2cset -y -r 9 0x22 6 0x00") - os.system("i2cset -y -r 9 0x22 7 0x00") - - # initialize PSU I/O (S9100_IO_EXP_PSU_ID) - os.system("i2cset -y -r 8 0x23 4 0x00") - os.system("i2cset -y -r 8 0x23 5 0x00") - os.system("i2cset -y -r 8 0x23 2 0x00") - os.system("i2cset -y -r 8 0x23 3 0x00") - os.system("i2cset -y -r 8 0x23 6 0xBB") - os.system("i2cset -y -r 8 0x23 7 0xFF") - - # initialize ABS Port 0-15 - self.new_i2c_device('pca9535', 0x20, 6) - os.system("echo 496 > /sys/class/gpio/export") - os.system("echo 497 > /sys/class/gpio/export") - os.system("echo 498 > /sys/class/gpio/export") - os.system("echo 499 > /sys/class/gpio/export") - os.system("echo 500 > /sys/class/gpio/export") - os.system("echo 501 > /sys/class/gpio/export") - os.system("echo 502 > /sys/class/gpio/export") - os.system("echo 503 > /sys/class/gpio/export") - os.system("echo 504 > /sys/class/gpio/export") - os.system("echo 505 > /sys/class/gpio/export") - os.system("echo 506 > /sys/class/gpio/export") - os.system("echo 507 > /sys/class/gpio/export") - os.system("echo 508 > /sys/class/gpio/export") - os.system("echo 509 > /sys/class/gpio/export") - os.system("echo 510 > /sys/class/gpio/export") - os.system("echo 511 > /sys/class/gpio/export") - os.system("echo 1 > /sys/class/gpio/gpio496/active_low") - os.system("echo 1 > /sys/class/gpio/gpio497/active_low") - os.system("echo 1 > /sys/class/gpio/gpio498/active_low") - os.system("echo 1 > /sys/class/gpio/gpio499/active_low") - os.system("echo 1 > /sys/class/gpio/gpio500/active_low") - os.system("echo 1 > /sys/class/gpio/gpio501/active_low") - os.system("echo 1 > /sys/class/gpio/gpio502/active_low") - os.system("echo 1 > /sys/class/gpio/gpio503/active_low") - os.system("echo 1 > /sys/class/gpio/gpio504/active_low") - os.system("echo 1 > /sys/class/gpio/gpio505/active_low") - os.system("echo 1 > /sys/class/gpio/gpio506/active_low") - os.system("echo 1 > /sys/class/gpio/gpio507/active_low") - os.system("echo 1 > /sys/class/gpio/gpio508/active_low") - os.system("echo 1 > /sys/class/gpio/gpio509/active_low") - os.system("echo 1 > /sys/class/gpio/gpio510/active_low") - os.system("echo 1 > /sys/class/gpio/gpio511/active_low") - - # initialize ABS Port 16-31 - self.new_i2c_device('pca9535', 0x21, 6) - os.system("echo 480 > /sys/class/gpio/export") - os.system("echo 481 > /sys/class/gpio/export") - os.system("echo 482 > /sys/class/gpio/export") - os.system("echo 483 > /sys/class/gpio/export") - os.system("echo 484 > /sys/class/gpio/export") - os.system("echo 485 > /sys/class/gpio/export") - os.system("echo 486 > /sys/class/gpio/export") - os.system("echo 487 > /sys/class/gpio/export") - os.system("echo 488 > /sys/class/gpio/export") - os.system("echo 489 > /sys/class/gpio/export") - os.system("echo 490 > /sys/class/gpio/export") - os.system("echo 491 > /sys/class/gpio/export") - os.system("echo 492 > /sys/class/gpio/export") - os.system("echo 493 > /sys/class/gpio/export") - os.system("echo 494 > /sys/class/gpio/export") - os.system("echo 495 > /sys/class/gpio/export") - os.system("echo 1 > /sys/class/gpio/gpio480/active_low") - os.system("echo 1 > /sys/class/gpio/gpio481/active_low") - os.system("echo 1 > /sys/class/gpio/gpio482/active_low") - os.system("echo 1 > /sys/class/gpio/gpio483/active_low") - os.system("echo 1 > /sys/class/gpio/gpio484/active_low") - os.system("echo 1 > /sys/class/gpio/gpio485/active_low") - os.system("echo 1 > /sys/class/gpio/gpio486/active_low") - os.system("echo 1 > /sys/class/gpio/gpio487/active_low") - os.system("echo 1 > /sys/class/gpio/gpio488/active_low") - os.system("echo 1 > /sys/class/gpio/gpio489/active_low") - os.system("echo 1 > /sys/class/gpio/gpio490/active_low") - os.system("echo 1 > /sys/class/gpio/gpio491/active_low") - os.system("echo 1 > /sys/class/gpio/gpio492/active_low") - os.system("echo 1 > /sys/class/gpio/gpio493/active_low") - os.system("echo 1 > /sys/class/gpio/gpio494/active_low") - os.system("echo 1 > /sys/class/gpio/gpio495/active_low") - - # initialize INT Port 0-15 - self.new_i2c_device('pca9535', 0x22, 6) - os.system("echo 464 > /sys/class/gpio/export") - os.system("echo 465 > /sys/class/gpio/export") - os.system("echo 466 > /sys/class/gpio/export") - os.system("echo 467 > /sys/class/gpio/export") - os.system("echo 468 > /sys/class/gpio/export") - os.system("echo 469 > /sys/class/gpio/export") - os.system("echo 470 > /sys/class/gpio/export") - os.system("echo 471 > /sys/class/gpio/export") - os.system("echo 472 > /sys/class/gpio/export") - os.system("echo 473 > /sys/class/gpio/export") - os.system("echo 474 > /sys/class/gpio/export") - os.system("echo 475 > /sys/class/gpio/export") - os.system("echo 476 > /sys/class/gpio/export") - os.system("echo 477 > /sys/class/gpio/export") - os.system("echo 478 > /sys/class/gpio/export") - os.system("echo 479 > /sys/class/gpio/export") - os.system("echo 1 > /sys/class/gpio/gpio464/active_low") - os.system("echo 1 > /sys/class/gpio/gpio465/active_low") - os.system("echo 1 > /sys/class/gpio/gpio466/active_low") - os.system("echo 1 > /sys/class/gpio/gpio467/active_low") - os.system("echo 1 > /sys/class/gpio/gpio468/active_low") - os.system("echo 1 > /sys/class/gpio/gpio469/active_low") - os.system("echo 1 > /sys/class/gpio/gpio470/active_low") - os.system("echo 1 > /sys/class/gpio/gpio471/active_low") - os.system("echo 1 > /sys/class/gpio/gpio472/active_low") - os.system("echo 1 > /sys/class/gpio/gpio473/active_low") - os.system("echo 1 > /sys/class/gpio/gpio474/active_low") - os.system("echo 1 > /sys/class/gpio/gpio475/active_low") - os.system("echo 1 > /sys/class/gpio/gpio476/active_low") - os.system("echo 1 > /sys/class/gpio/gpio477/active_low") - os.system("echo 1 > /sys/class/gpio/gpio478/active_low") - os.system("echo 1 > /sys/class/gpio/gpio479/active_low") - - # initialize INT Port 16-31 - self.new_i2c_device('pca9535', 0x23, 6) - os.system("echo 448 > /sys/class/gpio/export") - os.system("echo 449 > /sys/class/gpio/export") - os.system("echo 450 > /sys/class/gpio/export") - os.system("echo 451 > /sys/class/gpio/export") - os.system("echo 452 > /sys/class/gpio/export") - os.system("echo 453 > /sys/class/gpio/export") - os.system("echo 454 > /sys/class/gpio/export") - os.system("echo 455 > /sys/class/gpio/export") - os.system("echo 456 > /sys/class/gpio/export") - os.system("echo 457 > /sys/class/gpio/export") - os.system("echo 458 > /sys/class/gpio/export") - os.system("echo 459 > /sys/class/gpio/export") - os.system("echo 460 > /sys/class/gpio/export") - os.system("echo 461 > /sys/class/gpio/export") - os.system("echo 462 > /sys/class/gpio/export") - os.system("echo 463 > /sys/class/gpio/export") - os.system("echo 1 > /sys/class/gpio/gpio448/active_low") - os.system("echo 1 > /sys/class/gpio/gpio449/active_low") - os.system("echo 1 > /sys/class/gpio/gpio450/active_low") - os.system("echo 1 > /sys/class/gpio/gpio451/active_low") - os.system("echo 1 > /sys/class/gpio/gpio452/active_low") - os.system("echo 1 > /sys/class/gpio/gpio453/active_low") - os.system("echo 1 > /sys/class/gpio/gpio454/active_low") - os.system("echo 1 > /sys/class/gpio/gpio455/active_low") - os.system("echo 1 > /sys/class/gpio/gpio456/active_low") - os.system("echo 1 > /sys/class/gpio/gpio457/active_low") - os.system("echo 1 > /sys/class/gpio/gpio458/active_low") - os.system("echo 1 > /sys/class/gpio/gpio459/active_low") - os.system("echo 1 > /sys/class/gpio/gpio460/active_low") - os.system("echo 1 > /sys/class/gpio/gpio461/active_low") - os.system("echo 1 > /sys/class/gpio/gpio462/active_low") - os.system("echo 1 > /sys/class/gpio/gpio463/active_low") - - # initialize LP Mode Port 0-15 - self.new_i2c_device('pca9535', 0x20, 7) - os.system("echo 432 > /sys/class/gpio/export") - os.system("echo 433 > /sys/class/gpio/export") - os.system("echo 434 > /sys/class/gpio/export") - os.system("echo 435 > /sys/class/gpio/export") - os.system("echo 436 > /sys/class/gpio/export") - os.system("echo 437 > /sys/class/gpio/export") - os.system("echo 438 > /sys/class/gpio/export") - os.system("echo 439 > /sys/class/gpio/export") - os.system("echo 440 > /sys/class/gpio/export") - os.system("echo 441 > /sys/class/gpio/export") - os.system("echo 442 > /sys/class/gpio/export") - os.system("echo 443 > /sys/class/gpio/export") - os.system("echo 444 > /sys/class/gpio/export") - os.system("echo 445 > /sys/class/gpio/export") - os.system("echo 446 > /sys/class/gpio/export") - os.system("echo 447 > /sys/class/gpio/export") - os.system("echo out > /sys/class/gpio/gpio432/direction") - os.system("echo out > /sys/class/gpio/gpio433/direction") - os.system("echo out > /sys/class/gpio/gpio434/direction") - os.system("echo out > /sys/class/gpio/gpio435/direction") - os.system("echo out > /sys/class/gpio/gpio436/direction") - os.system("echo out > /sys/class/gpio/gpio437/direction") - os.system("echo out > /sys/class/gpio/gpio438/direction") - os.system("echo out > /sys/class/gpio/gpio439/direction") - os.system("echo out > /sys/class/gpio/gpio440/direction") - os.system("echo out > /sys/class/gpio/gpio441/direction") - os.system("echo out > /sys/class/gpio/gpio442/direction") - os.system("echo out > /sys/class/gpio/gpio443/direction") - os.system("echo out > /sys/class/gpio/gpio444/direction") - os.system("echo out > /sys/class/gpio/gpio445/direction") - os.system("echo out > /sys/class/gpio/gpio446/direction") - os.system("echo out > /sys/class/gpio/gpio447/direction") - - # initialize LP Mode Port 16-31 - self.new_i2c_device('pca9535', 0x21, 7) - os.system("echo 416 > /sys/class/gpio/export") - os.system("echo 417 > /sys/class/gpio/export") - os.system("echo 418 > /sys/class/gpio/export") - os.system("echo 419 > /sys/class/gpio/export") - os.system("echo 420 > /sys/class/gpio/export") - os.system("echo 421 > /sys/class/gpio/export") - os.system("echo 422 > /sys/class/gpio/export") - os.system("echo 423 > /sys/class/gpio/export") - os.system("echo 424 > /sys/class/gpio/export") - os.system("echo 425 > /sys/class/gpio/export") - os.system("echo 426 > /sys/class/gpio/export") - os.system("echo 427 > /sys/class/gpio/export") - os.system("echo 428 > /sys/class/gpio/export") - os.system("echo 429 > /sys/class/gpio/export") - os.system("echo 430 > /sys/class/gpio/export") - os.system("echo 431 > /sys/class/gpio/export") - - os.system("echo out > /sys/class/gpio/gpio416/direction") - os.system("echo out > /sys/class/gpio/gpio417/direction") - os.system("echo out > /sys/class/gpio/gpio418/direction") - os.system("echo out > /sys/class/gpio/gpio419/direction") - os.system("echo out > /sys/class/gpio/gpio420/direction") - os.system("echo out > /sys/class/gpio/gpio421/direction") - os.system("echo out > /sys/class/gpio/gpio422/direction") - os.system("echo out > /sys/class/gpio/gpio423/direction") - os.system("echo out > /sys/class/gpio/gpio424/direction") - os.system("echo out > /sys/class/gpio/gpio425/direction") - os.system("echo out > /sys/class/gpio/gpio426/direction") - os.system("echo out > /sys/class/gpio/gpio427/direction") - os.system("echo out > /sys/class/gpio/gpio428/direction") - os.system("echo out > /sys/class/gpio/gpio429/direction") - os.system("echo out > /sys/class/gpio/gpio430/direction") - os.system("echo out > /sys/class/gpio/gpio431/direction") - - # initialize RST Port 0-15 - self.new_i2c_device('pca9535', 0x22, 7) - os.system("echo 400 > /sys/class/gpio/export") - os.system("echo 401 > /sys/class/gpio/export") - os.system("echo 402 > /sys/class/gpio/export") - os.system("echo 403 > /sys/class/gpio/export") - os.system("echo 404 > /sys/class/gpio/export") - os.system("echo 405 > /sys/class/gpio/export") - os.system("echo 406 > /sys/class/gpio/export") - os.system("echo 407 > /sys/class/gpio/export") - os.system("echo 408 > /sys/class/gpio/export") - os.system("echo 409 > /sys/class/gpio/export") - os.system("echo 410 > /sys/class/gpio/export") - os.system("echo 411 > /sys/class/gpio/export") - os.system("echo 412 > /sys/class/gpio/export") - os.system("echo 413 > /sys/class/gpio/export") - os.system("echo 414 > /sys/class/gpio/export") - os.system("echo 415 > /sys/class/gpio/export") - os.system("echo out > /sys/class/gpio/gpio400/direction") - os.system("echo out > /sys/class/gpio/gpio401/direction") - os.system("echo out > /sys/class/gpio/gpio402/direction") - os.system("echo out > /sys/class/gpio/gpio403/direction") - os.system("echo out > /sys/class/gpio/gpio404/direction") - os.system("echo out > /sys/class/gpio/gpio405/direction") - os.system("echo out > /sys/class/gpio/gpio406/direction") - os.system("echo out > /sys/class/gpio/gpio407/direction") - os.system("echo out > /sys/class/gpio/gpio408/direction") - os.system("echo out > /sys/class/gpio/gpio409/direction") - os.system("echo out > /sys/class/gpio/gpio410/direction") - os.system("echo out > /sys/class/gpio/gpio411/direction") - os.system("echo out > /sys/class/gpio/gpio412/direction") - 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) - os.system("echo 384 > /sys/class/gpio/export") - os.system("echo 385 > /sys/class/gpio/export") - os.system("echo 386 > /sys/class/gpio/export") - os.system("echo 387 > /sys/class/gpio/export") - os.system("echo 388 > /sys/class/gpio/export") - os.system("echo 389 > /sys/class/gpio/export") - os.system("echo 390 > /sys/class/gpio/export") - os.system("echo 391 > /sys/class/gpio/export") - os.system("echo 392 > /sys/class/gpio/export") - os.system("echo 393 > /sys/class/gpio/export") - os.system("echo 394 > /sys/class/gpio/export") - os.system("echo 395 > /sys/class/gpio/export") - os.system("echo 396 > /sys/class/gpio/export") - os.system("echo 397 > /sys/class/gpio/export") - os.system("echo 398 > /sys/class/gpio/export") - os.system("echo 399 > /sys/class/gpio/export") - os.system("echo out > /sys/class/gpio/gpio384/direction") - os.system("echo out > /sys/class/gpio/gpio385/direction") - os.system("echo out > /sys/class/gpio/gpio386/direction") - os.system("echo out > /sys/class/gpio/gpio387/direction") - os.system("echo out > /sys/class/gpio/gpio388/direction") - os.system("echo out > /sys/class/gpio/gpio389/direction") - os.system("echo out > /sys/class/gpio/gpio390/direction") - os.system("echo out > /sys/class/gpio/gpio391/direction") - os.system("echo out > /sys/class/gpio/gpio392/direction") - os.system("echo out > /sys/class/gpio/gpio393/direction") - os.system("echo out > /sys/class/gpio/gpio394/direction") - os.system("echo out > /sys/class/gpio/gpio395/direction") - os.system("echo out > /sys/class/gpio/gpio396/direction") - 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) - os.system("echo 368 > /sys/class/gpio/export") - os.system("echo 369 > /sys/class/gpio/export") - os.system("echo 370 > /sys/class/gpio/export") - os.system("echo 371 > /sys/class/gpio/export") - os.system("echo 372 > /sys/class/gpio/export") - os.system("echo 373 > /sys/class/gpio/export") - os.system("echo 374 > /sys/class/gpio/export") - os.system("echo 375 > /sys/class/gpio/export") - os.system("echo 376 > /sys/class/gpio/export") - os.system("echo 377 > /sys/class/gpio/export") - os.system("echo 378 > /sys/class/gpio/export") - os.system("echo 379 > /sys/class/gpio/export") - os.system("echo 380 > /sys/class/gpio/export") - os.system("echo 381 > /sys/class/gpio/export") - os.system("echo 382 > /sys/class/gpio/export") - os.system("echo 383 > /sys/class/gpio/export") - os.system("echo out > /sys/class/gpio/gpio368/direction") - os.system("echo out > /sys/class/gpio/gpio369/direction") - os.system("echo out > /sys/class/gpio/gpio370/direction") - os.system("echo out > /sys/class/gpio/gpio371/direction") - os.system("echo out > /sys/class/gpio/gpio372/direction") - os.system("echo out > /sys/class/gpio/gpio373/direction") - os.system("echo out > /sys/class/gpio/gpio374/direction") - os.system("echo out > /sys/class/gpio/gpio375/direction") - os.system("echo out > /sys/class/gpio/gpio376/direction") - os.system("echo out > /sys/class/gpio/gpio377/direction") - os.system("echo out > /sys/class/gpio/gpio378/direction") - os.system("echo out > /sys/class/gpio/gpio379/direction") - os.system("echo out > /sys/class/gpio/gpio380/direction") - os.system("echo out > /sys/class/gpio/gpio381/direction") - os.system("echo out > /sys/class/gpio/gpio382/direction") - os.system("echo out > /sys/class/gpio/gpio383/direction") - - # initialize MODSEL Port 16-31 - self.new_i2c_device('pca9535', 0x25, 7) - os.system("echo 352 > /sys/class/gpio/export") - os.system("echo 353> /sys/class/gpio/export") - os.system("echo 354> /sys/class/gpio/export") - os.system("echo 355> /sys/class/gpio/export") - os.system("echo 356 > /sys/class/gpio/export") - os.system("echo 357 > /sys/class/gpio/export") - os.system("echo 358 > /sys/class/gpio/export") - os.system("echo 359 > /sys/class/gpio/export") - os.system("echo 360 > /sys/class/gpio/export") - os.system("echo 361 > /sys/class/gpio/export") - os.system("echo 362 > /sys/class/gpio/export") - os.system("echo 363 > /sys/class/gpio/export") - os.system("echo 364 > /sys/class/gpio/export") - os.system("echo 365 > /sys/class/gpio/export") - os.system("echo 366 > /sys/class/gpio/export") - os.system("echo 367 > /sys/class/gpio/export") - os.system("echo out > /sys/class/gpio/gpio352/direction") - os.system("echo out > /sys/class/gpio/gpio353/direction") - os.system("echo out > /sys/class/gpio/gpio354/direction") - os.system("echo out > /sys/class/gpio/gpio355/direction") - os.system("echo out > /sys/class/gpio/gpio356/direction") - os.system("echo out > /sys/class/gpio/gpio357/direction") - os.system("echo out > /sys/class/gpio/gpio358/direction") - os.system("echo out > /sys/class/gpio/gpio359/direction") - os.system("echo out > /sys/class/gpio/gpio360/direction") - os.system("echo out > /sys/class/gpio/gpio361/direction") - os.system("echo out > /sys/class/gpio/gpio362/direction") - os.system("echo out > /sys/class/gpio/gpio363/direction") - os.system("echo out > /sys/class/gpio/gpio364/direction") - os.system("echo out > /sys/class/gpio/gpio365/direction") - os.system("echo out > /sys/class/gpio/gpio366/direction") - os.system("echo out > /sys/class/gpio/gpio367/direction") - - # initialize qsfp eeprom - for port in range(1, 33): - self.new_i2c_device('sff8436', 0x50, port + 9) - - # initialize sys eeprom devices - self.new_i2c_device('mb_eeprom', 0x54, 9) - - # initialize temperature sensor - os.system("i2cset -y -r -f 0 0x2F 0x00 0x80") - os.system("i2cset -y -r -f 0 0x2F 0x05 0x7F") - os.system("i2cset -y -r -f 0 0x2F 0x04 0x0A") - - # initialize psu eeprom devices - self.new_i2c_device('eeprom', 0x50, 8) - self.new_i2c_device('eeprom', 0x50, 9) - - # initialize sys led - 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 - - diff --git a/packages/platforms/ingrasys/x86-64/s9180-32x/.gitignore b/packages/platforms/ingrasys/x86-64/s9180-32x/.gitignore deleted file mode 100755 index 9f7b1342f..000000000 --- a/packages/platforms/ingrasys/x86-64/s9180-32x/.gitignore +++ /dev/null @@ -1 +0,0 @@ -onlpdump.mk diff --git a/packages/platforms/ingrasys/x86-64/s9180-32x/Makefile b/packages/platforms/ingrasys/x86-64/s9180-32x/Makefile deleted file mode 100755 index 003238cf6..000000000 --- a/packages/platforms/ingrasys/x86-64/s9180-32x/Makefile +++ /dev/null @@ -1 +0,0 @@ -include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/ingrasys/x86-64/s9180-32x/modules/Makefile b/packages/platforms/ingrasys/x86-64/s9180-32x/modules/Makefile deleted file mode 100755 index 003238cf6..000000000 --- a/packages/platforms/ingrasys/x86-64/s9180-32x/modules/Makefile +++ /dev/null @@ -1 +0,0 @@ -include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/ingrasys/x86-64/s9180-32x/modules/PKG.yml b/packages/platforms/ingrasys/x86-64/s9180-32x/modules/PKG.yml deleted file mode 100755 index 23adefed7..000000000 --- a/packages/platforms/ingrasys/x86-64/s9180-32x/modules/PKG.yml +++ /dev/null @@ -1 +0,0 @@ -!include $ONL_TEMPLATES/no-platform-modules.yml ARCH=amd64 VENDOR=ingrasys BASENAME=x86-64-ingrasys-s9180-32x KERNELS="onl-kernel-3.16-lts-x86-64-all:amd64" diff --git a/packages/platforms/ingrasys/x86-64/s9180-32x/onlp/Makefile b/packages/platforms/ingrasys/x86-64/s9180-32x/onlp/Makefile deleted file mode 100755 index 003238cf6..000000000 --- a/packages/platforms/ingrasys/x86-64/s9180-32x/onlp/Makefile +++ /dev/null @@ -1 +0,0 @@ -include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/ingrasys/x86-64/s9180-32x/onlp/PKG.yml b/packages/platforms/ingrasys/x86-64/s9180-32x/onlp/PKG.yml deleted file mode 100755 index c87e02d45..000000000 --- a/packages/platforms/ingrasys/x86-64/s9180-32x/onlp/PKG.yml +++ /dev/null @@ -1 +0,0 @@ -!include $ONL_TEMPLATES/onlp-platform-any.yml PLATFORM=x86-64-ingrasys-s9180-32x ARCH=amd64 TOOLCHAIN=x86_64-linux-gnu diff --git a/packages/platforms/ingrasys/x86-64/s9180-32x/onlp/builds/Makefile b/packages/platforms/ingrasys/x86-64/s9180-32x/onlp/builds/Makefile deleted file mode 100755 index e7437cb23..000000000 --- a/packages/platforms/ingrasys/x86-64/s9180-32x/onlp/builds/Makefile +++ /dev/null @@ -1,2 +0,0 @@ -FILTER=src -include $(ONL)/make/subdirs.mk diff --git a/packages/platforms/ingrasys/x86-64/s9180-32x/onlp/builds/lib/Makefile b/packages/platforms/ingrasys/x86-64/s9180-32x/onlp/builds/lib/Makefile deleted file mode 100755 index 0a0cec494..000000000 --- a/packages/platforms/ingrasys/x86-64/s9180-32x/onlp/builds/lib/Makefile +++ /dev/null @@ -1,2 +0,0 @@ -PLATFORM := x86-64-ingrasys-s9180-32x -include $(ONL)/packages/base/any/onlp/builds/platform/libonlp-platform.mk diff --git a/packages/platforms/ingrasys/x86-64/s9180-32x/onlp/builds/onlpdump/Makefile b/packages/platforms/ingrasys/x86-64/s9180-32x/onlp/builds/onlpdump/Makefile deleted file mode 100755 index b78738c52..000000000 --- a/packages/platforms/ingrasys/x86-64/s9180-32x/onlp/builds/onlpdump/Makefile +++ /dev/null @@ -1,2 +0,0 @@ -PLATFORM := x86-64-ingrasys-s9180-32x -include $(ONL)/packages/base/any/onlp/builds/platform/onlps.mk diff --git a/packages/platforms/ingrasys/x86-64/s9180-32x/onlp/builds/x86_64_ingrasys_s9180_32x/.gitignore b/packages/platforms/ingrasys/x86-64/s9180-32x/onlp/builds/x86_64_ingrasys_s9180_32x/.gitignore deleted file mode 100755 index bb569e2ca..000000000 --- a/packages/platforms/ingrasys/x86-64/s9180-32x/onlp/builds/x86_64_ingrasys_s9180_32x/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -/x86_64_ingrasys_s9180_32x.mk -/doc diff --git a/packages/platforms/ingrasys/x86-64/s9180-32x/onlp/builds/x86_64_ingrasys_s9180_32x/.module b/packages/platforms/ingrasys/x86-64/s9180-32x/onlp/builds/x86_64_ingrasys_s9180_32x/.module deleted file mode 100755 index 88300c899..000000000 --- a/packages/platforms/ingrasys/x86-64/s9180-32x/onlp/builds/x86_64_ingrasys_s9180_32x/.module +++ /dev/null @@ -1 +0,0 @@ -name: x86_64_ingrasys_s9180_32x diff --git a/packages/platforms/ingrasys/x86-64/s9180-32x/onlp/builds/x86_64_ingrasys_s9180_32x/Makefile b/packages/platforms/ingrasys/x86-64/s9180-32x/onlp/builds/x86_64_ingrasys_s9180_32x/Makefile deleted file mode 100755 index 9e00628a4..000000000 --- a/packages/platforms/ingrasys/x86-64/s9180-32x/onlp/builds/x86_64_ingrasys_s9180_32x/Makefile +++ /dev/null @@ -1,10 +0,0 @@ -############################################################ -# -# -# -############################################################ -include $(ONL)/make/config.mk - -MODULE := x86_64_ingrasys_s9180_32x -AUTOMODULE := x86_64_ingrasys_s9180_32x -include $(BUILDER)/definemodule.mk diff --git a/packages/platforms/ingrasys/x86-64/s9180-32x/onlp/builds/x86_64_ingrasys_s9180_32x/module/auto/make.mk b/packages/platforms/ingrasys/x86-64/s9180-32x/onlp/builds/x86_64_ingrasys_s9180_32x/module/auto/make.mk deleted file mode 100755 index c15a1824a..000000000 --- a/packages/platforms/ingrasys/x86-64/s9180-32x/onlp/builds/x86_64_ingrasys_s9180_32x/module/auto/make.mk +++ /dev/null @@ -1,7 +0,0 @@ -# -# x86_64_ingrasys_s9180_32x Autogeneration -# -############################################################################### -x86_64_ingrasys_s9180_32x_AUTO_DEFS := module/auto/x86_64_ingrasys_s9180_32x.yml -x86_64_ingrasys_s9180_32x_AUTO_DIRS := module/inc/x86_64_ingrasys_s9180_32x module/src -include $(BUILDER)/auto.mk diff --git a/packages/platforms/ingrasys/x86-64/s9180-32x/onlp/builds/x86_64_ingrasys_s9180_32x/module/auto/x86_64_ingrasys_s9180_32x.yml b/packages/platforms/ingrasys/x86-64/s9180-32x/onlp/builds/x86_64_ingrasys_s9180_32x/module/auto/x86_64_ingrasys_s9180_32x.yml deleted file mode 100755 index b0fa3bea9..000000000 --- a/packages/platforms/ingrasys/x86-64/s9180-32x/onlp/builds/x86_64_ingrasys_s9180_32x/module/auto/x86_64_ingrasys_s9180_32x.yml +++ /dev/null @@ -1,47 +0,0 @@ -############################################################################### -# -# X86_64_INGRASYS_S9180_32X Autogeneration Definitions. -# -############################################################################### - -cdefs: &cdefs -- X86_64_INGRASYS_S9180_32X_CONFIG_INCLUDE_LOGGING: - doc: "Include or exclude logging." - default: 1 -- X86_64_INGRASYS_S9180_32X_CONFIG_LOG_OPTIONS_DEFAULT: - doc: "Default enabled log options." - default: AIM_LOG_OPTIONS_DEFAULT -- X86_64_INGRASYS_S9180_32X_CONFIG_LOG_BITS_DEFAULT: - doc: "Default enabled log bits." - default: AIM_LOG_BITS_DEFAULT -- X86_64_INGRASYS_S9180_32X_CONFIG_LOG_CUSTOM_BITS_DEFAULT: - doc: "Default enabled custom log bits." - default: 0 -- X86_64_INGRASYS_S9180_32X_CONFIG_PORTING_STDLIB: - doc: "Default all porting macros to use the C standard libraries." - default: 1 -- X86_64_INGRASYS_S9180_32X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS: - doc: "Include standard library headers for stdlib porting macros." - default: X86_64_INGRASYS_S9180_32X_CONFIG_PORTING_STDLIB -- X86_64_INGRASYS_S9180_32X_CONFIG_INCLUDE_UCLI: - doc: "Include generic uCli support." - default: 0 - - -definitions: - cdefs: - X86_64_INGRASYS_S9180_32X_CONFIG_HEADER: - defs: *cdefs - basename: x86_64_ingrasys_s9180_32x_config - - portingmacro: - X86_64_INGRASYS_S9180_32X: - macros: - - malloc - - free - - memset - - memcpy - - - vsnprintf - - snprintf - - strlen diff --git a/packages/platforms/ingrasys/x86-64/s9180-32x/onlp/builds/x86_64_ingrasys_s9180_32x/module/inc/x86_64_ingrasys_s9180_32x/x86_64_ingrasys_s9180_32x.x b/packages/platforms/ingrasys/x86-64/s9180-32x/onlp/builds/x86_64_ingrasys_s9180_32x/module/inc/x86_64_ingrasys_s9180_32x/x86_64_ingrasys_s9180_32x.x deleted file mode 100755 index e13d404cb..000000000 --- a/packages/platforms/ingrasys/x86-64/s9180-32x/onlp/builds/x86_64_ingrasys_s9180_32x/module/inc/x86_64_ingrasys_s9180_32x/x86_64_ingrasys_s9180_32x.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/ingrasys/x86-64/s9180-32x/onlp/builds/x86_64_ingrasys_s9180_32x/module/inc/x86_64_ingrasys_s9180_32x/x86_64_ingrasys_s9180_32x_config.h b/packages/platforms/ingrasys/x86-64/s9180-32x/onlp/builds/x86_64_ingrasys_s9180_32x/module/inc/x86_64_ingrasys_s9180_32x/x86_64_ingrasys_s9180_32x_config.h deleted file mode 100755 index fb22046f0..000000000 --- a/packages/platforms/ingrasys/x86-64/s9180-32x/onlp/builds/x86_64_ingrasys_s9180_32x/module/inc/x86_64_ingrasys_s9180_32x/x86_64_ingrasys_s9180_32x_config.h +++ /dev/null @@ -1,152 +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 x86_64_ingrasys_s9180_32x Configuration Header - * - * @addtogroup x86_64_ingrasys_s9180_32x-config - * @{ - * - *****************************************************************************/ -#ifndef __X86_64_INGRASYS_S9180_32X_CONFIG_H__ -#define __X86_64_INGRASYS_S9180_32X_CONFIG_H__ - -#ifdef GLOBAL_INCLUDE_CUSTOM_CONFIG -#include -#endif -#ifdef X86_64_INGRASYS_S9180_32X_INCLUDE_CUSTOM_CONFIG -#include -#endif - -/* */ -#include -/** - * X86_64_INGRASYS_S9180_32X_CONFIG_INCLUDE_LOGGING - * - * Include or exclude logging. */ - - -#ifndef X86_64_INGRASYS_S9180_32X_CONFIG_INCLUDE_LOGGING -#define X86_64_INGRASYS_S9180_32X_CONFIG_INCLUDE_LOGGING 1 -#endif - -/** - * X86_64_INGRASYS_S9180_32X_CONFIG_LOG_OPTIONS_DEFAULT - * - * Default enabled log options. */ - - -#ifndef X86_64_INGRASYS_S9180_32X_CONFIG_LOG_OPTIONS_DEFAULT -#define X86_64_INGRASYS_S9180_32X_CONFIG_LOG_OPTIONS_DEFAULT AIM_LOG_OPTIONS_DEFAULT -#endif - -/** - * X86_64_INGRASYS_S9180_32X_CONFIG_LOG_BITS_DEFAULT - * - * Default enabled log bits. */ - - -#ifndef X86_64_INGRASYS_S9180_32X_CONFIG_LOG_BITS_DEFAULT -#define X86_64_INGRASYS_S9180_32X_CONFIG_LOG_BITS_DEFAULT AIM_LOG_BITS_DEFAULT -#endif - -/** - * X86_64_INGRASYS_S9180_32X_CONFIG_LOG_CUSTOM_BITS_DEFAULT - * - * Default enabled custom log bits. */ - - -#ifndef X86_64_INGRASYS_S9180_32X_CONFIG_LOG_CUSTOM_BITS_DEFAULT -#define X86_64_INGRASYS_S9180_32X_CONFIG_LOG_CUSTOM_BITS_DEFAULT 0 -#endif - -/** - * X86_64_INGRASYS_S9180_32X_CONFIG_PORTING_STDLIB - * - * Default all porting macros to use the C standard libraries. */ - - -#ifndef X86_64_INGRASYS_S9180_32X_CONFIG_PORTING_STDLIB -#define X86_64_INGRASYS_S9180_32X_CONFIG_PORTING_STDLIB 1 -#endif - -/** - * X86_64_INGRASYS_S9180_32X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS - * - * Include standard library headers for stdlib porting macros. */ - - -#ifndef X86_64_INGRASYS_S9180_32X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS -#define X86_64_INGRASYS_S9180_32X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS X86_64_INGRASYS_S9180_32X_CONFIG_PORTING_STDLIB -#endif - -/** - * X86_64_INGRASYS_S9180_32X_CONFIG_INCLUDE_UCLI - * - * Include generic uCli support. */ - - -#ifndef X86_64_INGRASYS_S9180_32X_CONFIG_INCLUDE_UCLI -#define X86_64_INGRASYS_S9180_32X_CONFIG_INCLUDE_UCLI 0 -#endif - - - -/** - * All compile time options can be queried or displayed - */ - -/** Configuration settings structure. */ -typedef struct x86_64_ingrasys_s9180_32x_config_settings_s { - /** name */ - const char* name; - /** value */ - const char* value; -} x86_64_ingrasys_s9180_32x_config_settings_t; - -/** Configuration settings table. */ -/** x86_64_ingrasys_s9180_32x_config_settings table. */ -extern x86_64_ingrasys_s9180_32x_config_settings_t x86_64_ingrasys_s9180_32x_config_settings[]; - -/** - * @brief Lookup a configuration setting. - * @param setting The name of the configuration option to lookup. - */ -const char* x86_64_ingrasys_s9180_32x_config_lookup(const char* setting); - -/** - * @brief Show the compile-time configuration. - * @param pvs The output stream. - */ -int x86_64_ingrasys_s9180_32x_config_show(struct aim_pvs_s* pvs); - -/* */ - -#include "x86_64_ingrasys_s9180_32x_porting.h" - -#endif /* __X86_64_INGRASYS_S9180_32X_CONFIG_H__ */ -/* @} */ diff --git a/packages/platforms/ingrasys/x86-64/s9180-32x/onlp/builds/x86_64_ingrasys_s9180_32x/module/inc/x86_64_ingrasys_s9180_32x/x86_64_ingrasys_s9180_32x_dox.h b/packages/platforms/ingrasys/x86-64/s9180-32x/onlp/builds/x86_64_ingrasys_s9180_32x/module/inc/x86_64_ingrasys_s9180_32x/x86_64_ingrasys_s9180_32x_dox.h deleted file mode 100755 index 76067c8e3..000000000 --- a/packages/platforms/ingrasys/x86-64/s9180-32x/onlp/builds/x86_64_ingrasys_s9180_32x/module/inc/x86_64_ingrasys_s9180_32x/x86_64_ingrasys_s9180_32x_dox.h +++ /dev/null @@ -1,26 +0,0 @@ -/**************************************************************************//** - * - * x86_64_ingrasys_s9180_32x Doxygen Header - * - *****************************************************************************/ -#ifndef __x86_64_ingrasys_s9180_32x_DOX_H__ -#define __x86_64_ingrasys_s9180_32x_DOX_H__ - -/** - * @defgroup x86_64_ingrasys_s9180_32x x86_64_ingrasys_s9180_32x - x86_64_ingrasys_s9180_32x Description - * - -The documentation overview for this module should go here. - - * - * @{ - * - * @defgroup x86_64_ingrasys_s9180_32x-x86_64_ingrasys_s9180_32x Public Interface - * @defgroup x86_64_ingrasys_s9180_32x-config Compile Time Configuration - * @defgroup x86_64_ingrasys_s9180_32x-porting Porting Macros - * - * @} - * - */ - -#endif /* __x86_64_ingrasys_s9180_32x_DOX_H__ */ diff --git a/packages/platforms/ingrasys/x86-64/s9180-32x/onlp/builds/x86_64_ingrasys_s9180_32x/module/inc/x86_64_ingrasys_s9180_32x/x86_64_ingrasys_s9180_32x_porting.h b/packages/platforms/ingrasys/x86-64/s9180-32x/onlp/builds/x86_64_ingrasys_s9180_32x/module/inc/x86_64_ingrasys_s9180_32x/x86_64_ingrasys_s9180_32x_porting.h deleted file mode 100755 index 401474741..000000000 --- a/packages/platforms/ingrasys/x86-64/s9180-32x/onlp/builds/x86_64_ingrasys_s9180_32x/module/inc/x86_64_ingrasys_s9180_32x/x86_64_ingrasys_s9180_32x_porting.h +++ /dev/null @@ -1,96 +0,0 @@ -/********************************************************//** - * - * @file - * @brief x86_64_Ingrasys_s9180_32x Porting Macros. - * - * @addtogroup x86_64_Ingrasys_s9180_32x-porting - * @{ - * - ***********************************************************/ -#ifndef __X86_64_INGRASYS_S9180_32X_PORTING_H__ -#define __X86_64_INGRASYS_S9180_32X_PORTING_H__ - -/* */ -#if X86_64_INGRASYS_S9180_32X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS == 1 -#include -#include -#include -#include -#include -#endif - -#ifndef X86_64_INGRASYS_S9180_32X_MALLOC - #if defined(GLOBAL_MALLOC) - #define X86_64_INGRASYS_S9180_32X_MALLOC GLOBAL_MALLOC - #elif X86_64_INGRASYS_S9180_32X_CONFIG_PORTING_STDLIB == 1 - #define X86_64_INGRASYS_S9180_32X_MALLOC malloc - #else - #error The macro X86_64_INGRASYS_S9180_32X_MALLOC is required but cannot be defined. - #endif -#endif - -#ifndef X86_64_INGRASYS_S9180_32X_FREE - #if defined(GLOBAL_FREE) - #define X86_64_INGRASYS_S9180_32X_FREE GLOBAL_FREE - #elif X86_64_INGRASYS_S9180_32X_CONFIG_PORTING_STDLIB == 1 - #define X86_64_INGRASYS_S9180_32X_FREE free - #else - #error The macro X86_64_INGRASYS_S9180_32X_FREE is required but cannot be defined. - #endif -#endif - -#ifndef X86_64_INGRASYS_S9180_32X_MEMSET - #if defined(GLOBAL_MEMSET) - #define X86_64_INGRASYS_S9180_32X_MEMSET GLOBAL_MEMSET - #elif X86_64_INGRASYS_S9180_32X_CONFIG_PORTING_STDLIB == 1 - #define X86_64_INGRASYS_S9180_32X_MEMSET memset - #else - #error The macro X86_64_INGRASYS_S9180_32X_MEMSET is required but cannot be defined. - #endif -#endif - -#ifndef X86_64_INGRASYS_S9180_32X_MEMCPY - #if defined(GLOBAL_MEMCPY) - #define X86_64_INGRASYS_S9180_32X_MEMCPY GLOBAL_MEMCPY - #elif X86_64_INGRASYS_S9180_32X_CONFIG_PORTING_STDLIB == 1 - #define X86_64_INGRASYS_S9180_32X_MEMCPY memcpy - #else - #error The macro X86_64_INGRASYS_S9180_32X_MEMCPY is required but cannot be defined. - #endif -#endif - -#ifndef X86_64_INGRASYS_S9180_32X_VSNPRINTF - #if defined(GLOBAL_VSNPRINTF) - #define X86_64_INGRASYS_S9180_32X_VSNPRINTF GLOBAL_VSNPRINTF - #elif X86_64_INGRASYS_S9180_32X_CONFIG_PORTING_STDLIB == 1 - #define X86_64_INGRASYS_S9180_32X_VSNPRINTF vsnprintf - #else - #error The macro X86_64_INGRASYS_S9180_32X_VSNPRINTF is required but cannot be defined. - #endif -#endif - -#ifndef X86_64_INGRASYS_S9180_32X_SNPRINTF - #if defined(GLOBAL_SNPRINTF) - #define X86_64_INGRASYS_S9180_32X_SNPRINTF GLOBAL_SNPRINTF - #elif X86_64_INGRASYS_S9180_32X_CONFIG_PORTING_STDLIB == 1 - #define X86_64_INGRASYS_S9180_32X_SNPRINTF snprintf - #else - #error The macro X86_64_INGRASYS_S9180_32X_SNPRINTF is required but cannot be defined. - #endif -#endif - -#ifndef X86_64_INGRASYS_S9180_32X_STRLEN - #if defined(GLOBAL_STRLEN) - #define X86_64_INGRASYS_S9180_32X_STRLEN GLOBAL_STRLEN - #elif X86_64_INGRASYS_S9180_32X_CONFIG_PORTING_STDLIB == 1 - #define X86_64_INGRASYS_S9180_32X_STRLEN strlen - #else - #error The macro X86_64_INGRASYS_S9180_32X_STRLEN is required but cannot be defined. - #endif -#endif - -/* */ - - -#endif /* __X86_64_INGRASYS_S9180_32X_PORTING_H__ */ -/* @} */ diff --git a/packages/platforms/ingrasys/x86-64/s9180-32x/onlp/builds/x86_64_ingrasys_s9180_32x/module/make.mk b/packages/platforms/ingrasys/x86-64/s9180-32x/onlp/builds/x86_64_ingrasys_s9180_32x/module/make.mk deleted file mode 100755 index 03592ef69..000000000 --- a/packages/platforms/ingrasys/x86-64/s9180-32x/onlp/builds/x86_64_ingrasys_s9180_32x/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))) -x86_64_ingrasys_s9180_32x_INCLUDES := -I $(THIS_DIR)inc -x86_64_ingrasys_s9180_32x_INTERNAL_INCLUDES := -I $(THIS_DIR)src -x86_64_ingrasys_s9180_32x_DEPENDMODULE_ENTRIES := init:x86_64_ingrasys_s9180_32x ucli:x86_64_ingrasys_s9180_32x - diff --git a/packages/platforms/ingrasys/x86-64/s9180-32x/onlp/builds/x86_64_ingrasys_s9180_32x/module/src/Makefile b/packages/platforms/ingrasys/x86-64/s9180-32x/onlp/builds/x86_64_ingrasys_s9180_32x/module/src/Makefile deleted file mode 100755 index fe84a5d12..000000000 --- a/packages/platforms/ingrasys/x86-64/s9180-32x/onlp/builds/x86_64_ingrasys_s9180_32x/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 x86_64_ingrasys_s9180_32x_ucli.c - diff --git a/packages/platforms/ingrasys/x86-64/s9180-32x/onlp/builds/x86_64_ingrasys_s9180_32x/module/src/fani.c b/packages/platforms/ingrasys/x86-64/s9180-32x/onlp/builds/x86_64_ingrasys_s9180_32x/module/src/fani.c deleted file mode 100755 index 45e38fdbd..000000000 --- a/packages/platforms/ingrasys/x86-64/s9180-32x/onlp/builds/x86_64_ingrasys_s9180_32x/module/src/fani.c +++ /dev/null @@ -1,349 +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. - * - * - ************************************************************ - * - * Fan Platform Implementation Defaults. - * - ***********************************************************/ -#include -#include "x86_64_ingrasys_s9180_32x_int.h" -#include -#include -#include "platform_lib.h" - -onlp_fan_info_t fan_info[] = { - { }, /* Not used */ - { - { FAN_OID_FAN1, "FANTRAY 1-A", 0 }, - ONLP_FAN_STATUS_PRESENT, - ONLP_FAN_CAPS_GET_RPM | ONLP_FAN_CAPS_GET_PERCENTAGE, - 0, - 0, - ONLP_FAN_MODE_INVALID, - }, - { - { FAN_OID_FAN2, "FANTRAY 1-B", 0 }, - ONLP_FAN_STATUS_PRESENT, - ONLP_FAN_CAPS_GET_RPM | ONLP_FAN_CAPS_GET_PERCENTAGE, - 0, - 0, - ONLP_FAN_MODE_INVALID, - }, - { - { FAN_OID_FAN3, "FANTRAY 2-A", 0 }, - ONLP_FAN_STATUS_PRESENT, - ONLP_FAN_CAPS_GET_RPM | ONLP_FAN_CAPS_GET_PERCENTAGE, - 0, - 0, - ONLP_FAN_MODE_INVALID, - }, - { - { FAN_OID_FAN4, "FANTRAY 2-B", 0 }, - ONLP_FAN_STATUS_PRESENT, - ONLP_FAN_CAPS_GET_RPM | ONLP_FAN_CAPS_GET_PERCENTAGE, - 0, - 0, - ONLP_FAN_MODE_INVALID, - }, - { - { FAN_OID_FAN5, "FANTRAY 3-A", 0 }, - ONLP_FAN_STATUS_PRESENT, - ONLP_FAN_CAPS_GET_RPM | ONLP_FAN_CAPS_GET_PERCENTAGE, - 0, - 0, - ONLP_FAN_MODE_INVALID, - }, - { - { FAN_OID_FAN6, "FANTRAY 3-B", 0 }, - ONLP_FAN_STATUS_PRESENT, - ONLP_FAN_CAPS_GET_RPM | ONLP_FAN_CAPS_GET_PERCENTAGE, - 0, - 0, - ONLP_FAN_MODE_INVALID, - }, - { - { FAN_OID_FAN7, "FANTRAY 4-A", 0 }, - ONLP_FAN_STATUS_PRESENT, - ONLP_FAN_CAPS_GET_RPM | ONLP_FAN_CAPS_GET_PERCENTAGE, - 0, - 0, - ONLP_FAN_MODE_INVALID, - }, - { - { FAN_OID_FAN8, "FANTRAY 4-B", 0 }, - ONLP_FAN_STATUS_PRESENT, - ONLP_FAN_CAPS_GET_RPM | ONLP_FAN_CAPS_GET_PERCENTAGE, - 0, - 0, - ONLP_FAN_MODE_INVALID, - }, - { - { FAN_OID_PSU_FAN1, "PSU-1 FAN", 0 }, - ONLP_FAN_STATUS_PRESENT, - }, - { - { FAN_OID_PSU_FAN2, "PSU-2 FAN", 0 }, - ONLP_FAN_STATUS_PRESENT, - } -}; - -/* - * This function will be called prior to all of onlp_fani_* functions. - */ -int -onlp_fani_init(void) -{ - return ONLP_STATUS_OK; -} - -int sys_fan_present_get(onlp_fan_info_t* info, int id) -{ - int rv, fan_presence, i2c_bus, offset, fan_reg_mask; - - if ( bmc_enable ) { - return ONLP_STATUS_E_UNSUPPORTED; - } - - /* get fan presence*/ - i2c_bus = I2C_BUS_59; - switch (id) - { - case FAN_ID_FAN1: - case FAN_ID_FAN2: - offset = 1; - fan_reg_mask = FAN_1_2_PRESENT_MASK; - break; - case FAN_ID_FAN3: - case FAN_ID_FAN4: - offset = 1; - fan_reg_mask = FAN_3_4_PRESENT_MASK; - break; - case FAN_ID_FAN5: - case FAN_ID_FAN6: - offset = 0; - fan_reg_mask = FAN_5_6_PRESENT_MASK; - break; - case FAN_ID_FAN7: - case FAN_ID_FAN8: - offset = 0; - fan_reg_mask = FAN_7_8_PRESENT_MASK; - break; - default: - return ONLP_STATUS_E_INVALID; - } - - rv = onlp_i2c_readb(i2c_bus, FAN_GPIO_ADDR, 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 = 22000; - fan_status = 0; - fan_rpm = 0; - - if ( bmc_enable ) { - return ONLP_STATUS_E_UNSUPPORTED; - } - - 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) { - return ONLP_STATUS_E_INTERNAL; - } - - /* fan status > 1, means failure */ - if (fan_status > 0) { - info->status |= ONLP_FAN_STATUS_FAILED; - return ONLP_STATUS_OK; - } - - rv = onlp_file_read_int(&fan_rpm, SYS_FAN_PREFIX "fan%d_input", id); - if (rv < 0) { - return ONLP_STATUS_E_INTERNAL; - } - info->rpm = fan_rpm; - - /* get speed percentage*/ - switch (id) - { - case FAN_ID_FAN1: - case FAN_ID_FAN2: - case FAN_ID_FAN3: - case FAN_ID_FAN4: - rv = onlp_file_read_int(&perc_val, SYS_FAN_PREFIX "pwm%d", - FAN_CTRL_SET1); - break; - case FAN_ID_FAN5: - case FAN_ID_FAN6: - case FAN_ID_FAN7: - case FAN_ID_FAN8: - rv = onlp_file_read_int(&perc_val, SYS_FAN_PREFIX "pwm%d", - FAN_CTRL_SET2); - break; - default: - return ONLP_STATUS_E_INVALID; - } - if (rv < 0) { - return ONLP_STATUS_E_INTERNAL; - } - - percentage = (info->rpm*100)/max_fan_speed; - info->percentage = percentage; - - return ONLP_STATUS_OK; -} - -int -sys_fan_rpm_percent_set(int perc) -{ - int rc; - - if ( bmc_enable ) { - return ONLP_STATUS_E_UNSUPPORTED; - } - - rc = onlp_file_write_int(perc, SYS_FAN_PREFIX "pwm%d", FAN_CTRL_SET1); - - if (rc < 0) { - return ONLP_STATUS_E_INTERNAL; - } - - rc = onlp_file_write_int(perc, SYS_FAN_PREFIX "pwm%d", FAN_CTRL_SET2); - if (rc < 0) { - return ONLP_STATUS_E_INTERNAL; - } - - return ONLP_STATUS_OK; -} - -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 percentage) -{ - int fid, perc_val, rc; - - if ( bmc_enable ) { - return ONLP_STATUS_E_UNSUPPORTED; - } - - fid = ONLP_OID_ID_GET(id); - - /* - * Set fan speed - * Driver accept value in range between 128 and 255. - * Value 128 is 50%. - * Value 200 is 80%. - * Value 255 is 100%. - */ - if (percentage == 100) { - perc_val = 255; - } else if (percentage == 80) { - perc_val = 200; - } else if (percentage == 50) { - perc_val = 128; - } else { - return ONLP_STATUS_E_INVALID; - } - - switch (fid) - { - case FAN_ID_FAN1: - case FAN_ID_FAN2: - case FAN_ID_FAN3: - case FAN_ID_FAN4: - case FAN_ID_FAN5: - case FAN_ID_FAN6: - case FAN_ID_FAN7: - case FAN_ID_FAN8: - rc = sys_fan_rpm_percent_set(perc_val); - break; - default: - return ONLP_STATUS_E_INVALID; - } - return rc; -} - -int -onlp_fani_info_get(onlp_oid_t id, onlp_fan_info_t* rv) -{ - int fan_id ,rc; - - if ( bmc_enable ) { - return ONLP_STATUS_E_UNSUPPORTED; - } - - fan_id = ONLP_OID_ID_GET(id); - *rv = fan_info[fan_id]; - rv->caps |= ONLP_FAN_CAPS_GET_RPM; - - switch (fan_id) { - case FAN_ID_FAN1: - case FAN_ID_FAN2: - case FAN_ID_FAN3: - case FAN_ID_FAN4: - case FAN_ID_FAN5: - case FAN_ID_FAN6: - case FAN_ID_FAN7: - case FAN_ID_FAN8: - rc = sys_fan_info_get(rv, fan_id); - break; - case FAN_ID_PSU_FAN1: - case FAN_ID_PSU_FAN2: - rc = psu_fan_info_get(rv, fan_id); - break; - default: - return ONLP_STATUS_E_INTERNAL; - break; - } - - return rc; -} diff --git a/packages/platforms/ingrasys/x86-64/s9180-32x/onlp/builds/x86_64_ingrasys_s9180_32x/module/src/ledi.c b/packages/platforms/ingrasys/x86-64/s9180-32x/onlp/builds/x86_64_ingrasys_s9180_32x/module/src/ledi.c deleted file mode 100755 index 9b90f0130..000000000 --- a/packages/platforms/ingrasys/x86-64/s9180-32x/onlp/builds/x86_64_ingrasys_s9180_32x/module/src/ledi.c +++ /dev/null @@ -1,236 +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 -#include -#include -#include -#include - -#include "platform_lib.h" - -/* - * Get the information for the given LED OID. - */ -static onlp_led_info_t led_info[] = -{ - { }, /* Not used */ - { - { LED_OID_SYSTEM, "Chassis LED 1 (SYS LED)", 0 }, - ONLP_LED_STATUS_PRESENT, - ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_GREEN, - }, - { - { LED_OID_FAN, "Chassis LED 2 (FAN 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_PSU1, "Chassis LED 3 (PSU1 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_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. - */ -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, pw_exist, pw_good, rc, psu_mask, fan_id; - int exist_offset, good_offset, i2c_bus; - onlp_fan_info_t fan_info; - - if ( bmc_enable ) { - return ONLP_STATUS_E_UNSUPPORTED; - } - - memset(&fan_info, 0, sizeof(onlp_fan_info_t)); - led_id = ONLP_OID_ID_GET(id); - - *info = led_info[led_id]; - - if (id == LED_OID_PSU1 || id == LED_OID_PSU2) { - - psu_mask = PSU_MUX_MASK; - - if (id == LED_OID_PSU1) { - i2c_bus = I2C_BUS_PSU1; - exist_offset = PSU1_PRESENT_OFFSET; - good_offset = PSU1_PWGOOD_OFFSET; - } else { - i2c_bus = I2C_BUS_PSU2; - exist_offset = PSU2_PRESENT_OFFSET; - good_offset = PSU2_PWGOOD_OFFSET; - } - /* check psu status */ - if ((rc = psu_present_get(&pw_exist, exist_offset, i2c_bus, psu_mask)) - != ONLP_STATUS_OK) { - return ONLP_STATUS_E_INTERNAL; - } - if ((rc = psu_pwgood_get(&pw_good, good_offset, i2c_bus, 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; -} - -/* - * 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) -{ - int led_id, rc; - - if ( bmc_enable ) { - return ONLP_STATUS_E_UNSUPPORTED; - } - - led_id = ONLP_OID_ID_GET(id); - switch (led_id) { - case LED_SYSTEM_LED: - rc = system_led_set(mode); - break; - case LED_FAN_LED: - rc = fan_led_set(mode); - break; - case LED_PSU1_LED: - rc = psu1_led_set(mode); - break; - 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; - } - - return rc; -} - -int -onlp_ledi_ioctl(onlp_oid_t id, va_list vargs) -{ - return ONLP_STATUS_OK; -} diff --git a/packages/platforms/ingrasys/x86-64/s9180-32x/onlp/builds/x86_64_ingrasys_s9180_32x/module/src/make.mk b/packages/platforms/ingrasys/x86-64/s9180-32x/onlp/builds/x86_64_ingrasys_s9180_32x/module/src/make.mk deleted file mode 100755 index e34082b6c..000000000 --- a/packages/platforms/ingrasys/x86-64/s9180-32x/onlp/builds/x86_64_ingrasys_s9180_32x/module/src/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. -# -# -############################################################ -# -# -# -############################################################ - -LIBRARY := x86_64_ingrasys_s9180_32x -$(LIBRARY)_SUBDIR := $(dir $(lastword $(MAKEFILE_LIST))) -#$(LIBRARY)_LAST := 1 -include $(BUILDER)/lib.mk diff --git a/packages/platforms/ingrasys/x86-64/s9180-32x/onlp/builds/x86_64_ingrasys_s9180_32x/module/src/platform_lib.c b/packages/platforms/ingrasys/x86-64/s9180-32x/onlp/builds/x86_64_ingrasys_s9180_32x/module/src/platform_lib.c deleted file mode 100755 index daa64144b..000000000 --- a/packages/platforms/ingrasys/x86-64/s9180-32x/onlp/builds/x86_64_ingrasys_s9180_32x/module/src/platform_lib.c +++ /dev/null @@ -1,694 +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 -#include -#include -#include -#include -#include - -#include "platform_lib.h" - -int -psu_thermal_get(onlp_thermal_info_t* info, int thermal_id) -{ - int pw_exist, pw_good, exist_offset, good_offset; - int offset, i2c_bus, rc; - int value, buf, psu_mask; - unsigned int y_value = 0; - unsigned char n_value = 0; - unsigned int temp = 0; - char result[32]; - - if ( bmc_enable ) { - return ONLP_STATUS_E_UNSUPPORTED; - } - - if (thermal_id == THERMAL_ID_PSU1_1) { - i2c_bus = I2C_BUS_PSU1; - offset = PSU_THERMAL1_OFFSET; - exist_offset = PSU1_PRESENT_OFFSET; - good_offset = PSU1_PWGOOD_OFFSET; - } else if (thermal_id == THERMAL_ID_PSU1_2) { - i2c_bus = I2C_BUS_PSU1; - offset = PSU_THERMAL2_OFFSET; - exist_offset = PSU1_PRESENT_OFFSET; - good_offset = PSU1_PWGOOD_OFFSET; - } else if (thermal_id == THERMAL_ID_PSU2_1) { - i2c_bus = I2C_BUS_PSU2; - offset = PSU_THERMAL1_OFFSET; - exist_offset = PSU2_PRESENT_OFFSET; - good_offset = PSU2_PWGOOD_OFFSET; - } else if (thermal_id == THERMAL_ID_PSU2_2) { - i2c_bus = I2C_BUS_PSU2; - offset = PSU_THERMAL2_OFFSET; - exist_offset = PSU2_PRESENT_OFFSET; - good_offset = PSU2_PWGOOD_OFFSET; - } - - psu_mask = PSU_MUX_MASK; - - /* check psu status */ - if ((rc = psu_present_get(&pw_exist, exist_offset, I2C_BUS_0, psu_mask)) - != ONLP_STATUS_OK) { - return ONLP_STATUS_E_INTERNAL; - } - - 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, good_offset, I2C_BUS_0, psu_mask)) - != ONLP_STATUS_OK) { - return ONLP_STATUS_E_INTERNAL; - } - - if (pw_good != PSU_STATUS_POWER_GOOD) { - info->mcelsius = 0; - return ONLP_STATUS_OK; - } - - value = onlp_i2c_readw(i2c_bus, PSU_REG, offset, ONLP_I2C_F_FORCE); - - y_value = (value & 0x07FF); - if ((value & 0x8000)&&(y_value)) { - n_value = 0xF0 + (((value) >> 11) & 0x0F); - n_value = (~n_value) +1; - temp = (unsigned int)(1<> 11) & 0x0F); - snprintf(result, sizeof(result), "%d", (y_value*(1<mcelsius = (int)(buf * 1000); - - return ONLP_STATUS_OK; -} - -int -psu_fan_info_get(onlp_fan_info_t* info, int id) -{ - int pw_exist, pw_good, exist_offset, good_offset; - int i2c_bus, psu_mask, rc; - unsigned int tmp_fan_rpm, fan_rpm; - - if ( bmc_enable ) { - return ONLP_STATUS_E_UNSUPPORTED; - } - - if (id == FAN_ID_PSU_FAN1) { - i2c_bus = I2C_BUS_PSU1; - exist_offset = PSU1_PRESENT_OFFSET; - good_offset = PSU1_PWGOOD_OFFSET; - } else if (id == FAN_ID_PSU_FAN2) { - i2c_bus = I2C_BUS_PSU2; - exist_offset = PSU2_PRESENT_OFFSET; - good_offset = PSU2_PWGOOD_OFFSET; - } else { - return ONLP_STATUS_E_INTERNAL; - } - - psu_mask = PSU_MUX_MASK; - - /* check psu status */ - if ((rc = psu_present_get(&pw_exist, exist_offset, I2C_BUS_0, psu_mask)) - != ONLP_STATUS_OK) { - return ONLP_STATUS_E_INTERNAL; - } - - 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, good_offset, I2C_BUS_0, psu_mask)) - != ONLP_STATUS_OK) { - return ONLP_STATUS_E_INTERNAL; - } - - if (pw_good != PSU_STATUS_POWER_GOOD) { - info->rpm = 0; - return ONLP_STATUS_OK; - } - - tmp_fan_rpm = onlp_i2c_readw(i2c_bus, PSU_REG, PSU_FAN_RPM_OFFSET, ONLP_I2C_F_FORCE); - - fan_rpm = (unsigned int)tmp_fan_rpm; - fan_rpm = (fan_rpm & 0x07FF) * (1 << ((fan_rpm >> 11) & 0x1F)); - info->rpm = (int)fan_rpm; - - return ONLP_STATUS_OK; -} - -int -psu_vout_get(onlp_psu_info_t* info, int i2c_bus) -{ - int v_value = 0; - int n_value = 0; - unsigned int temp = 0; - char result[32]; - double dvalue; - memset(result, 0, sizeof(result)); - - if ( bmc_enable ) { - return ONLP_STATUS_E_UNSUPPORTED; - } - - n_value = onlp_i2c_readb(i2c_bus, PSU_REG, PSU_VOUT_OFFSET1, ONLP_I2C_F_FORCE); - if (n_value < 0) { - return ONLP_STATUS_E_INTERNAL; - } - - v_value = onlp_i2c_readw(i2c_bus, PSU_REG, PSU_VOUT_OFFSET2, ONLP_I2C_F_FORCE); - if (v_value < 0) { - return ONLP_STATUS_E_INTERNAL; - } - - if (n_value & 0x10) { - n_value = 0xF0 + (n_value & 0x0F); - n_value = (~n_value) +1; - temp = (unsigned int)(1< 0.0) { - info->caps |= ONLP_PSU_CAPS_VOUT; - info->mvout = (int)(dvalue * 1000); - } - - return ONLP_STATUS_OK; -} - -int -psu_iout_get(onlp_psu_info_t* info, int i2c_bus) -{ - int value; - unsigned int y_value = 0; - unsigned char n_value = 0; - unsigned int temp = 0; - char result[32]; - memset(result, 0, sizeof(result)); - double dvalue; - - if ( bmc_enable ) { - return ONLP_STATUS_E_UNSUPPORTED; - } - - value = onlp_i2c_readw(i2c_bus, PSU_REG, PSU_IOUT_OFFSET, ONLP_I2C_F_FORCE); - if (value < 0) { - return ONLP_STATUS_E_INTERNAL; - } - - y_value = (value & 0x07FF); - if ((value & 0x8000)&&(y_value)) - { - n_value = 0xF0 + (((value) >> 11) & 0x0F); - n_value = (~n_value) +1; - temp = (unsigned int)(1<> 11) & 0x0F); - snprintf(result, sizeof(result), "%d", (y_value*(1< 0.0) { - info->caps |= ONLP_PSU_CAPS_IOUT; - info->miout = (int)(dvalue * 1000); - } - - return ONLP_STATUS_OK; -} - -int -psu_pout_get(onlp_psu_info_t* info, int i2c_bus) -{ - int value; - unsigned int y_value = 0; - unsigned char n_value = 0; - unsigned int temp = 0; - char result[32]; - memset(result, 0, sizeof(result)); - double dvalue; - - if ( bmc_enable ) { - return ONLP_STATUS_E_UNSUPPORTED; - } - - value = onlp_i2c_readw(i2c_bus, PSU_REG, PSU_POUT_OFFSET, ONLP_I2C_F_FORCE); - if (value < 0) { - return ONLP_STATUS_E_INTERNAL; - } - - y_value = (value & 0x07FF); - if ((value & 0x8000)&&(y_value)) - { - n_value = 0xF0 + (((value) >> 11) & 0x0F); - n_value = (~n_value) +1; - temp = (unsigned int)(1<> 11) & 0x0F); - snprintf(result, sizeof(result), "%d", (y_value*(1< 0.0) { - info->caps |= ONLP_PSU_CAPS_POUT; - info->mpout = (int)(dvalue * 1000); - } - - return ONLP_STATUS_OK; -} - -int -psu_pin_get(onlp_psu_info_t* info, int i2c_bus) -{ - int value; - unsigned int y_value = 0; - unsigned char n_value = 0; - unsigned int temp = 0; - char result[32]; - memset(result, 0, sizeof(result)); - double dvalue; - - if ( bmc_enable ) { - return ONLP_STATUS_E_UNSUPPORTED; - } - - value = onlp_i2c_readw(i2c_bus, PSU_REG, PSU_PIN_OFFSET, ONLP_I2C_F_FORCE); - if (value < 0) { - return ONLP_STATUS_E_INTERNAL; - } - - y_value = (value & 0x07FF); - if ((value & 0x8000)&&(y_value)) - { - n_value = 0xF0 + (((value) >> 11) & 0x0F); - n_value = (~n_value) +1; - temp = (unsigned int)(1<> 11) & 0x0F); - snprintf(result, sizeof(result), "%d", (y_value*(1< 0.0) { - info->caps |= ONLP_PSU_CAPS_PIN; - info->mpin = (int)(dvalue * 1000); - } - - return ONLP_STATUS_OK; -} - -int -psu_eeprom_get(onlp_psu_info_t* info, int id) -{ - uint8_t data[256]; - char eeprom_path[128]; - int data_len, i, rc; - memset(data, 0, sizeof(data)); - memset(eeprom_path, 0, sizeof(eeprom_path)); - - if ( bmc_enable ) { - return ONLP_STATUS_E_UNSUPPORTED; - } - - if (id == PSU_ID_PSU1) { - rc = onlp_file_read(data, sizeof(data), &data_len, PSU1_EEPROM_PATH); - } else { - rc = onlp_file_read(data, sizeof(data), &data_len, PSU2_EEPROM_PATH); - } - - if (rc == ONLP_STATUS_OK) - { - i = 11; - - /* Manufacturer Name */ - data_len = (data[i]&0x0f); - i++; - i += data_len; - - /* Product Name */ - data_len = (data[i]&0x0f); - i++; - memcpy(info->model, (char *) &(data[i]), data_len); - i += data_len; - - /* Product part,model number */ - data_len = (data[i]&0x0f); - i++; - i += data_len; - - /* Product Version */ - data_len = (data[i]&0x0f); - i++; - i += data_len; - - /* Product Serial Number */ - data_len = (data[i]&0x0f); - i++; - memcpy(info->serial, (char *) &(data[i]), data_len); - } else { - strcpy(info->model, "Missing"); - strcpy(info->serial, "Missing"); - } - - return ONLP_STATUS_OK; -} - - -int -psu_present_get(int *pw_exist, int exist_offset, int i2c_bus, int psu_mask) -{ - int psu_pres; - - if ( bmc_enable ) { - return ONLP_STATUS_E_UNSUPPORTED; - } - - psu_pres = onlp_i2c_readb(i2c_bus, PSU_STATE_REG, 0x0, - ONLP_I2C_F_FORCE); - if (psu_pres < 0) { - return ONLP_STATUS_E_INTERNAL; - } - - *pw_exist = (((psu_pres >> exist_offset) & psu_mask) ? 0 : 1); - return ONLP_STATUS_OK; -} - -int -psu_pwgood_get(int *pw_good, int good_offset, int i2c_bus, int psu_mask) -{ - int psu_pwgood; - - if ( bmc_enable ) { - return ONLP_STATUS_E_UNSUPPORTED; - } - - psu_pwgood = onlp_i2c_readb(i2c_bus, PSU_STATE_REG, 0x0, - ONLP_I2C_F_FORCE); - if (psu_pwgood < 0) { - return ONLP_STATUS_E_INTERNAL; - } - - *pw_good = (((psu_pwgood >> good_offset) & psu_mask) ? 1 : 0); - return ONLP_STATUS_OK; -} - -int -qsfp_present_get(int port, int *pres_val) -{ - int status, rc, gpio_num; - - if (port >= 1 && port <= 16) { - gpio_num = 496 + ((port - 1) ^ 1); - } else if (port >= 17 && port <= 32) { - gpio_num = 464 + ((port - 1) ^ 1); - } else if (port == 33) { - gpio_num = 432; - } else if (port == 34) { - gpio_num = 433; - } - - if ((rc = onlp_file_read_int(&status, "/sys/class/gpio/gpio%d/value", - gpio_num)) != ONLP_STATUS_OK) { - return ONLP_STATUS_E_INTERNAL; - } - - *pres_val = status; - - return ONLP_STATUS_OK; -} - - -int -system_led_set(onlp_led_mode_t mode) -{ - int rc; - - if ( bmc_enable ) { - return ONLP_STATUS_E_UNSUPPORTED; - } - - if(mode == ONLP_LED_MODE_GREEN) { - rc = onlp_i2c_modifyb(I2C_BUS_50, LED_REG, LED_OFFSET, LED_SYS_AND_MASK, - LED_SYS_GMASK, ONLP_I2C_F_FORCE); - } - else if(mode == ONLP_LED_MODE_ORANGE) { - rc = onlp_i2c_modifyb(I2C_BUS_50, LED_REG, LED_OFFSET, LED_SYS_AND_MASK, - LED_SYS_YMASK, ONLP_I2C_F_FORCE); - } else { - return ONLP_STATUS_E_INTERNAL; - } - - if (rc < 0) { - return ONLP_STATUS_E_INTERNAL; - } - - return ONLP_STATUS_OK; -} - -int -fan_led_set(onlp_led_mode_t mode) -{ - int rc; - - if ( bmc_enable ) { - return ONLP_STATUS_E_UNSUPPORTED; - } - - if(mode == ONLP_LED_MODE_GREEN ) { - rc = onlp_i2c_modifyb(I2C_BUS_50, LED_REG, LED_OFFSET, LED_FAN_AND_MASK, - LED_FAN_GMASK, ONLP_I2C_F_FORCE); - } - else if(mode == ONLP_LED_MODE_ORANGE) { - rc = onlp_i2c_modifyb(I2C_BUS_50, LED_REG, LED_OFFSET, LED_FAN_AND_MASK, - LED_FAN_YMASK, ONLP_I2C_F_FORCE); - } else { - return ONLP_STATUS_E_INTERNAL; - } - - if (rc < 0) { - return ONLP_STATUS_E_INTERNAL; - } - - return ONLP_STATUS_OK; -} - -int -psu1_led_set(onlp_led_mode_t mode) -{ - int rc; - - if ( bmc_enable ) { - return ONLP_STATUS_E_UNSUPPORTED; - } - - if(mode == ONLP_LED_MODE_GREEN) { - rc = onlp_i2c_modifyb(I2C_BUS_50, LED_REG, LED_PWOK_OFFSET, - LED_PSU1_ON_AND_MASK, LED_PSU1_ON_OR_MASK, - ONLP_I2C_F_FORCE); - rc = onlp_i2c_modifyb(I2C_BUS_50, LED_REG, LED_OFFSET, - LED_PSU1_AND_MASK, LED_PSU1_GMASK, - ONLP_I2C_F_FORCE); - } else if(mode == ONLP_LED_MODE_ORANGE) { - rc = onlp_i2c_modifyb(I2C_BUS_50, LED_REG, LED_PWOK_OFFSET, - LED_PSU1_ON_AND_MASK, LED_PSU1_ON_OR_MASK, - ONLP_I2C_F_FORCE); - rc = onlp_i2c_modifyb(I2C_BUS_50, 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_50, LED_REG, LED_PWOK_OFFSET, - LED_PSU1_OFF_AND_MASK, LED_PSU1_OFF_OR_MASK, - ONLP_I2C_F_FORCE); - } else { - return ONLP_STATUS_E_INTERNAL; - } - - if (rc < 0) { - return ONLP_STATUS_E_INTERNAL; - } - - return ONLP_STATUS_OK; -} - -int -psu2_led_set(onlp_led_mode_t mode) -{ - int rc; - - if ( bmc_enable ) { - return ONLP_STATUS_E_UNSUPPORTED; - } - - if(mode == ONLP_LED_MODE_GREEN) { - rc = onlp_i2c_modifyb(I2C_BUS_50, LED_REG, LED_PWOK_OFFSET, - LED_PSU2_ON_AND_MASK, LED_PSU2_ON_OR_MASK, - ONLP_I2C_F_FORCE); - rc = onlp_i2c_modifyb(I2C_BUS_50, LED_REG, LED_OFFSET, - LED_PSU2_AND_MASK, LED_PSU2_GMASK, - ONLP_I2C_F_FORCE); - } else if(mode == ONLP_LED_MODE_ORANGE) { - rc = onlp_i2c_modifyb(I2C_BUS_50, LED_REG, LED_PWOK_OFFSET, - LED_PSU2_ON_AND_MASK, LED_PSU2_ON_OR_MASK, - ONLP_I2C_F_FORCE); - rc = onlp_i2c_modifyb(I2C_BUS_50, 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_50, LED_REG, LED_PWOK_OFFSET, - LED_PSU2_OFF_AND_MASK, LED_PSU2_OFF_OR_MASK, - ONLP_I2C_F_FORCE); - } else { - return ONLP_STATUS_E_INTERNAL; - } - - - if (rc < 0) { - return ONLP_STATUS_E_INTERNAL; - } - - 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; - - if ( bmc_enable ) { - return ONLP_STATUS_E_UNSUPPORTED; - } - - 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_59, FAN_GPIO_ADDR, offset, 0xFC, - 0x02, ONLP_I2C_F_FORCE); - } else if (mode == ONLP_LED_MODE_ORANGE) { - rc = onlp_i2c_modifyb(I2C_BUS_59, FAN_GPIO_ADDR, offset, 0xFC, - 0x01, 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_59, FAN_GPIO_ADDR, offset, 0xCF, - 0x20, ONLP_I2C_F_FORCE); - } else if (mode == ONLP_LED_MODE_ORANGE) { - rc = onlp_i2c_modifyb(I2C_BUS_59, FAN_GPIO_ADDR, offset, 0xCF, - 0x10, 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) -{ - int cpld_release, cpld_version, cpld_rev; - - cpld_rev = onlp_i2c_readb(I2C_BUS_44, CPLD_REG, CPLD_VER_OFFSET, ONLP_I2C_F_FORCE); - if (cpld_rev < 0) { - return ONLP_STATUS_E_INTERNAL; - } - - cpld_release = (((cpld_rev) >> 6 & 0x01)); - cpld_version = (((cpld_rev) & 0x3F)); - - pi->cpld_versions = aim_fstrdup( - "CPLD is %d version(0:RD 1:Release), Revision is 0x%02x\n", - cpld_release, cpld_version); - - return ONLP_STATUS_OK; -} - -bool -onlp_sysi_bmc_en_get(void) -{ - int value; - - if (onlp_file_read_int(&value, BMC_EN_FILE_PATH) < 0) { - // flag file not exist, default to not enable - return false; - } - - /* 1 - enable, 0 - no enable */ - if ( value ) - return true; - - return false; -} diff --git a/packages/platforms/ingrasys/x86-64/s9180-32x/onlp/builds/x86_64_ingrasys_s9180_32x/module/src/platform_lib.h b/packages/platforms/ingrasys/x86-64/s9180-32x/onlp/builds/x86_64_ingrasys_s9180_32x/module/src/platform_lib.h deleted file mode 100755 index 004315b92..000000000 --- a/packages/platforms/ingrasys/x86-64/s9180-32x/onlp/builds/x86_64_ingrasys_s9180_32x/module/src/platform_lib.h +++ /dev/null @@ -1,314 +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. - * - * - ************************************************************ - * - * - * - ***********************************************************/ -#ifndef __PLATFORM_LIB_H__ -#define __PLATFORM_LIB_H__ - -#include -#include -#include -#include -#include -#include "x86_64_ingrasys_s9180_32x_int.h" -#include "x86_64_ingrasys_s9180_32x_log.h" - -#include -#define SYS_CPU_TEMP_PREFIX "/sys/class/hwmon/hwmon0/" -#define SYS_CORE_TEMP_PREFIX "/sys/class/hwmon/hwmon2/" -#define SYS_CPU_BOARD_TEMP_PREFIX "/sys/class/hwmon/hwmon3/" -#define SYS_PSU1_NEAR_TEMP_PREFIX "/sys/class/hwmon/hwmon4/" -#define SYS_PSU2_NEAR_TEMP_PREFIX "/sys/class/hwmon/hwmon7/" -#define SYS_MAC_REAR_TEMP_PREFIX "/sys/class/hwmon/hwmon5/" -#define SYS_QSFP_NEAR_TEMP_PREFIX "/sys/class/hwmon/hwmon6/" - -#define SYS_BMC_CPU_BOARD_TEMP_PREFIX "/sys/class/hwmon/hwmon1/" - -#define SYS_FAN_PREFIX "/sys/class/hwmon/hwmon1/device/" -#define SYS_EEPROM_PATH "/sys/bus/i2c/devices/0-0051/eeprom" -#define SYS_EEPROM_SIZE 512 -#define PSU1_EEPROM_PATH "/sys/bus/i2c/devices/58-0050/eeprom" -#define PSU2_EEPROM_PATH "/sys/bus/i2c/devices/57-0050/eeprom" -#define BMC_EN_FILE_PATH "/etc/onl/bmc_en" -#define PSU_STATUS_PRESENT 1 -#define PSU_STATUS_POWER_GOOD 1 -#define FAN_PRESENT 0 -#define FAN_CTRL_SET1 1 -#define FAN_CTRL_SET2 2 -#define MAX_SYS_FAN_NUM 8 -#define BOARD_THERMAL_NUM 6 -#define SYS_FAN_NUM 8 -//#define QSFP_NUM 32 -#define PORT_NUM 34 - -#define THERMAL_NUM 15 -#define LED_NUM 4 -#define FAN_NUM 10 - - - -#define THERMAL_SHUTDOWN_DEFAULT 105000 - -#define THERMAL_ERROR_DEFAULT 95000 -#define THERMAL_ERROR_FAN_PERC 100 - -#define THERMAL_WARNING_DEFAULT 77000 -#define THERMAL_WARNING_FAN_PERC 80 - -#define THERMAL_NORMAL_DEFAULT 72000 -#define THERMAL_NORMAL_FAN_PERC 50 - -/* I2C bus */ -#define I2C_BUS_0 0 -#define I2C_BUS_1 1 -#define I2C_BUS_2 2 -#define I2C_BUS_3 3 -#define I2C_BUS_4 4 -#define I2C_BUS_5 5 -#define I2C_BUS_6 6 -#define I2C_BUS_7 7 -#define I2C_BUS_8 8 -#define I2C_BUS_9 9 -#define I2C_BUS_44 44 /* cpld */ -#define I2C_BUS_50 50 /* SYS LED */ -#define I2C_BUS_57 (57) /* PSU2 */ -#define I2C_BUS_58 (58) /* PSU1 */ -#define I2C_BUS_59 59 /* FRU */ - -#define I2C_BUS_PSU1 I2C_BUS_58 /* PSU1 */ -#define I2C_BUS_PSU2 I2C_BUS_57 /* PSU2 */ - -/* PSU */ -#define PSU_MUX_MASK 0x01 - -#define PSU_THERMAL1_OFFSET 0x8D -#define PSU_THERMAL2_OFFSET 0x8E -#define PSU_THERMAL_REG 0x58 -#define PSU_FAN_RPM_REG 0x58 -#define PSU_FAN_RPM_OFFSET 0x90 -#define PSU_REG 0x58 -#define PSU_VOUT_OFFSET1 0x20 -#define PSU_VOUT_OFFSET2 0x8B -#define PSU_IOUT_OFFSET 0x8C -#define PSU_POUT_OFFSET 0x96 -#define PSU_PIN_OFFSET 0x97 - -#define PSU_STATE_REG 0x25 -#define PSU1_PRESENT_OFFSET 0x04 -#define PSU2_PRESENT_OFFSET 0x01 -#define PSU1_PWGOOD_OFFSET 0x03 -#define PSU2_PWGOOD_OFFSET 0x00 - -/* LED */ -#define LED_REG 0x75 -#define LED_OFFSET 0x02 -#define LED_PWOK_OFFSET 0x03 - -#define LED_SYS_AND_MASK 0xFE -#define LED_SYS_GMASK 0x01 -#define LED_SYS_YMASK 0x00 - -#define LED_FAN_AND_MASK 0xF9 -#define LED_FAN_GMASK 0x02 -#define LED_FAN_YMASK 0x06 - -#define LED_PSU2_AND_MASK 0xEF -#define LED_PSU2_GMASK 0x00 -#define LED_PSU2_YMASK 0x10 -#define LED_PSU2_ON_AND_MASK 0xFD -#define LED_PSU2_ON_OR_MASK 0x02 -#define LED_PSU2_OFF_AND_MASK 0xFD -#define LED_PSU2_OFF_OR_MASK 0x00 -#define LED_PSU1_AND_MASK 0xF7 -#define LED_PSU1_GMASK 0x00 -#define LED_PSU1_YMASK 0x08 -#define LED_PSU1_ON_AND_MASK 0xFE -#define LED_PSU1_ON_OR_MASK 0x01 -#define LED_PSU1_OFF_AND_MASK 0xFE -#define LED_PSU1_OFF_OR_MASK 0x00 -#define LED_SYS_ON_MASK 0x00 -#define LED_SYS_OFF_MASK 0x33 - -/* SYS */ -#define CPLD_REG 0x33 -#define CPLD_VER_OFFSET 0x01 - -/* QSFP */ -#define QSFP_PRES_REG1 0x20 -#define QSFP_PRES_REG2 0x21 -#define QSFP_PRES_OFFSET1 0x00 -#define QSFP_PRES_OFFSET2 0x01 - -/* FAN */ -#define FAN_GPIO_ADDR 0x20 -#define FAN_1_2_PRESENT_MASK 0x40 -#define FAN_3_4_PRESENT_MASK 0x04 -#define FAN_5_6_PRESENT_MASK 0x40 -#define FAN_7_8_PRESENT_MASK 0x04 - -/** 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 */ -typedef enum led_id_e { - LED_SYSTEM_LED = 1, - 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 */ -typedef enum thermal_oid_e { - THERMAL_OID_FRONT_MAC = ONLP_THERMAL_ID_CREATE(1), - THERMAL_OID_ASIC = ONLP_THERMAL_ID_CREATE(2), - THERMAL_OID_CPU1 = ONLP_THERMAL_ID_CREATE(3), - THERMAL_OID_CPU2 = ONLP_THERMAL_ID_CREATE(4), - THERMAL_OID_CPU3 = ONLP_THERMAL_ID_CREATE(5), - THERMAL_OID_CPU4 = ONLP_THERMAL_ID_CREATE(6), - THERMAL_OID_PSU1_1 = ONLP_THERMAL_ID_CREATE(7), - THERMAL_OID_PSU1_2 = ONLP_THERMAL_ID_CREATE(8), - THERMAL_OID_PSU2_1 = ONLP_THERMAL_ID_CREATE(9), - THERMAL_OID_PSU2_2 = ONLP_THERMAL_ID_CREATE(10), - THERMAL_OID_CPU_BOARD = ONLP_THERMAL_ID_CREATE(11), - THERMAL_OID_PSU1_NEAR = ONLP_THERMAL_ID_CREATE(12), - THERMAL_OID_PSU2_NEAR = ONLP_THERMAL_ID_CREATE(13), - THERMAL_OID_MAC_REAR = ONLP_THERMAL_ID_CREATE(14), - THERMAL_OID_QSFP_NEAR = ONLP_THERMAL_ID_CREATE(15), -} thermal_oid_t; - -/** thermal_id */ -typedef enum thermal_id_e { - THERMAL_ID_FRONT_MAC = 1, - THERMAL_ID_ASIC = 2, - THERMAL_ID_CPU1 = 3, - THERMAL_ID_CPU2 = 4, - THERMAL_ID_CPU3 = 5, - THERMAL_ID_CPU4 = 6, - THERMAL_ID_PSU1_1 = 7, - THERMAL_ID_PSU1_2 = 8, - THERMAL_ID_PSU2_1 = 9, - THERMAL_ID_PSU2_2 = 10, - THERMAL_ID_CPU_BOARD = 11, - THERMAL_ID_PSU1_NEAR = 12, - THERMAL_ID_PSU2_NEAR = 13, - THERMAL_ID_MAC_REAR = 14, - THERMAL_ID_QSFP_NEAR = 15, -} thermal_id_t; - -/* Shortcut for CPU thermal threshold value. */ -#define THERMAL_THRESHOLD_INIT_DEFAULTS \ - { THERMAL_WARNING_DEFAULT, \ - THERMAL_ERROR_DEFAULT, \ - THERMAL_SHUTDOWN_DEFAULT } - -/** 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_PSU_FAN1 = ONLP_FAN_ID_CREATE(9), - FAN_OID_PSU_FAN2 = ONLP_FAN_ID_CREATE(10) -} fan_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_PSU_FAN1 = 9, - FAN_ID_PSU_FAN2 = 10 -} fan_id_t; - -/** led_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; - -/** fan_id */ -typedef enum psu_id_e { - PSU_ID_PSU1 = 1, - PSU_ID_PSU2 = 2 -} psu_id_t; - -int psu_thermal_get(onlp_thermal_info_t* info, int id); - -int psu_fan_info_get(onlp_fan_info_t* info, int id); - -int psu_vout_get(onlp_psu_info_t* info, int i2c_bus); - -int psu_iout_get(onlp_psu_info_t* info, int i2c_bus); - -int psu_pout_get(onlp_psu_info_t* info, int i2c_bus); - -int psu_pin_get(onlp_psu_info_t* info, int i2c_bus); - -int psu_eeprom_get(onlp_psu_info_t* info, int id); - -int psu_present_get(int *pw_exist, int exist_offset, - int i2c_bus, int psu_mask); - -int psu_pwgood_get(int *pw_good, int good_offset, int i2c_bus, int psu_mask); - -int psu2_led_set(onlp_led_mode_t mode); - -int psu1_led_set(onlp_led_mode_t mode); - -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); - -bool onlp_sysi_bmc_en_get(void); - -extern bool bmc_enable; -#endif /* __PLATFORM_LIB_H__ */ diff --git a/packages/platforms/ingrasys/x86-64/s9180-32x/onlp/builds/x86_64_ingrasys_s9180_32x/module/src/psui.c b/packages/platforms/ingrasys/x86-64/s9180-32x/onlp/builds/x86_64_ingrasys_s9180_32x/module/src/psui.c deleted file mode 100755 index 1d18b81ff..000000000 --- a/packages/platforms/ingrasys/x86-64/s9180-32x/onlp/builds/x86_64_ingrasys_s9180_32x/module/src/psui.c +++ /dev/null @@ -1,168 +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 - -#include "platform_lib.h" - -static onlp_psu_info_t pinfo[] = -{ - { }, /* Not used */ - { - { - PSU_OID_PSU1, - "PSU-1", - 0, - { - FAN_OID_PSU_FAN1, - }, - } - }, - { - { - PSU_OID_PSU2, - "PSU-2", - 0, - { - FAN_OID_PSU_FAN2, - }, - } - } -}; - -int -onlp_psui_init(void) -{ - return ONLP_STATUS_OK; -} - -int -psu_status_info_get(int id, onlp_psu_info_t *info) -{ - int pw_exist, exist_offset; - int pw_good, good_offset; - int rc, psu_mask, i2c_bus; - - if ( bmc_enable ) { - return ONLP_STATUS_E_UNSUPPORTED; - } - - if (id == PSU_ID_PSU1) { - i2c_bus = I2C_BUS_PSU1; - exist_offset = PSU1_PRESENT_OFFSET; - good_offset = PSU1_PWGOOD_OFFSET; - } else if (id == PSU_ID_PSU2) { - i2c_bus = I2C_BUS_PSU2; - exist_offset = PSU2_PRESENT_OFFSET; - good_offset = PSU2_PWGOOD_OFFSET; - } else { - return ONLP_STATUS_E_INTERNAL; - } - - psu_mask = PSU_MUX_MASK; - - /* Get power present status */ - if ((rc = psu_present_get(&pw_exist, exist_offset, I2C_BUS_0, psu_mask)) - != ONLP_STATUS_OK) { - return ONLP_STATUS_E_INTERNAL; - } - - if (pw_exist != PSU_STATUS_PRESENT) { - info->status &= ~ONLP_PSU_STATUS_PRESENT; - info->status |= ONLP_PSU_STATUS_FAILED; - return ONLP_STATUS_OK; - } - info->status |= ONLP_PSU_STATUS_PRESENT; - - /* Get power good status */ - if ((rc = psu_pwgood_get(&pw_good, good_offset, I2C_BUS_0, psu_mask)) - != ONLP_STATUS_OK) { - return ONLP_STATUS_E_INTERNAL; - } - - 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 */ - if ((rc = psu_eeprom_get(info, id)) != ONLP_STATUS_OK) { - return ONLP_STATUS_E_INTERNAL; - } - - /* Get power iout status */ - if ((rc = psu_iout_get(info, i2c_bus)) != ONLP_STATUS_OK) { - return ONLP_STATUS_E_INTERNAL; - } - - /* Get power pout status */ - if ((rc = psu_pout_get(info, i2c_bus)) != ONLP_STATUS_OK) { - return ONLP_STATUS_E_INTERNAL; - } - - /* Get power pin status */ - if ((rc = psu_pin_get(info, i2c_bus)) != ONLP_STATUS_OK) { - return ONLP_STATUS_E_INTERNAL; - } - - /* Get power vout status */ - if ((rc = psu_vout_get(info, i2c_bus)) != ONLP_STATUS_OK) { - return ONLP_STATUS_E_INTERNAL; - } - - return ONLP_STATUS_OK; -} - -int -onlp_psui_info_get(onlp_oid_t id, onlp_psu_info_t* info) -{ - int pid; - - if ( bmc_enable ) { - return ONLP_STATUS_E_UNSUPPORTED; - } - - pid = ONLP_OID_ID_GET(id); - memset(info, 0, sizeof(onlp_psu_info_t)); - - /* Set the onlp_oid_hdr_t */ - *info = pinfo[pid]; - - switch (pid) { - case PSU_ID_PSU1: - case PSU_ID_PSU2: - return psu_status_info_get(pid, info); - break; - default: - return ONLP_STATUS_E_UNSUPPORTED; - break; - } - - return ONLP_STATUS_OK; - - -} diff --git a/packages/platforms/ingrasys/x86-64/s9180-32x/onlp/builds/x86_64_ingrasys_s9180_32x/module/src/sfpi.c b/packages/platforms/ingrasys/x86-64/s9180-32x/onlp/builds/x86_64_ingrasys_s9180_32x/module/src/sfpi.c deleted file mode 100755 index 9f10b887e..000000000 --- a/packages/platforms/ingrasys/x86-64/s9180-32x/onlp/builds/x86_64_ingrasys_s9180_32x/module/src/sfpi.c +++ /dev/null @@ -1,160 +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 -#include -#include -#include -#include -#include -#include -#include "x86_64_ingrasys_s9180_32x_log.h" -#include "platform_lib.h" - -int -onlp_sfpi_init(void) -{ - return ONLP_STATUS_OK; -} - -int -onlp_sfpi_bitmap_get(onlp_sfp_bitmap_t* bmap) -{ - int p; - for(p = 1; p <= PORT_NUM; p++) { - AIM_BITMAP_SET(bmap, p); - } - return ONLP_STATUS_OK; -} - -int -onlp_sfpi_is_present(int port) -{ - int status; - - if (qsfp_present_get(port, &status) != ONLP_STATUS_OK) { - return ONLP_STATUS_E_INTERNAL; - } - - return status; -} - - -int -onlp_sfpi_presence_bitmap_get(onlp_sfp_bitmap_t* dst) -{ - int p = 1; - int rc = 0; - - for (p = 1; p <= PORT_NUM; p++) { - rc = onlp_sfpi_is_present(p); - AIM_BITMAP_MOD(dst, p, (1 == rc) ? 1 : 0); - } - - return ONLP_STATUS_OK; -} - -/* - * This function reads the SFPs idrom and returns in - * in the data buffer provided. - */ -int -onlp_sfpi_eeprom_read(int port, uint8_t data[256]) -{ - int eeprombusidx, eeprombus, eeprombusbase; - char eeprom_path[512], eeprom_addr[32]; - memset(eeprom_path, 0, sizeof(eeprom_path)); - memset(eeprom_addr, 0, sizeof(eeprom_addr)); - aim_strlcpy(eeprom_addr, "0050", sizeof(eeprom_addr)); - - memset(data, 0, 256); - - if (port >= 1 && port <= 8) { - eeprombusbase = 9; - } else if (port >= 9 && port <= 16) { - eeprombusbase = 17; - } else if (port >= 17 && port <= 24) { - eeprombusbase = 25; - } else if (port >= 25 && port <= 32) { - eeprombusbase = 33; - } else if (port == 33) { - eeprombus = 45; - } else if (port == 34) { - eeprombus = 46; - } else { - return 0; - } - - /* port 33 and 34 doesn't need to swap */ - if (port >=1 && port <= 32) { - eeprombusidx = port % 8; - switch (eeprombusidx) { - case 1: - eeprombus = eeprombusbase + 1; - break; - case 2: - eeprombus = eeprombusbase + 0; - break; - case 3: - eeprombus = eeprombusbase + 3; - break; - case 4: - eeprombus = eeprombusbase + 2; - break; - case 5: - eeprombus = eeprombusbase + 5; - break; - case 6: - eeprombus = eeprombusbase + 4; - break; - case 7: - eeprombus = eeprombusbase + 7; - break; - case 0: - eeprombus = eeprombusbase + 6; - break; - default: - return ONLP_STATUS_E_INTERNAL; - break; - } - } - - snprintf(eeprom_path, sizeof(eeprom_path), - "/sys/bus/i2c/devices/%d-%s/eeprom", eeprombus, eeprom_addr); - - if (onlplib_sfp_eeprom_read_file(eeprom_path, data) != 0) { - return ONLP_STATUS_E_INTERNAL; - } - - return ONLP_STATUS_OK; -} - -/* - * De-initialize the SFPI subsystem. - */ -int -onlp_sfpi_denit(void) -{ - return ONLP_STATUS_OK; -} diff --git a/packages/platforms/ingrasys/x86-64/s9180-32x/onlp/builds/x86_64_ingrasys_s9180_32x/module/src/sysi.c b/packages/platforms/ingrasys/x86-64/s9180-32x/onlp/builds/x86_64_ingrasys_s9180_32x/module/src/sysi.c deleted file mode 100755 index 0ade2ed3a..000000000 --- a/packages/platforms/ingrasys/x86-64/s9180-32x/onlp/builds/x86_64_ingrasys_s9180_32x/module/src/sysi.c +++ /dev/null @@ -1,403 +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 -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "platform_lib.h" - -bool bmc_enable = false; - -const char* -onlp_sysi_platform_get(void) -{ - return "x86-64-ingrasys-s9180-32x-r0"; -} - -int -onlp_sysi_init(void) -{ - /* check if the platform is bmc enabled */ - if ( onlp_sysi_bmc_en_get() ) { - bmc_enable = true; - //AIM_LOG_INFO("BMC detected on platform!"); - AIM_SYSLOG_INFO( - "BMC detected on platform!", - "BMC detected on platform!", - "BMC detected on platform!"); - } else { - bmc_enable = false; - //AIM_LOG_INFO("BMC NOT detected on platform!"); - AIM_SYSLOG_INFO( - "BMC NOT detected on platform!", - "BMC NOT detected on platform!", - "BMC NOT detected on platform!"); - } - - return ONLP_STATUS_OK; -} - -int -onlp_sysi_onie_data_get(uint8_t** data, int* size) -{ - uint8_t* rdata = aim_zmalloc(SYS_EEPROM_SIZE); - if(onlp_file_read(rdata, SYS_EEPROM_SIZE, size, SYS_EEPROM_PATH) == ONLP_STATUS_OK) { - if(*size == SYS_EEPROM_SIZE) { - *data = rdata; - return ONLP_STATUS_OK; - } - } - - AIM_LOG_INFO("Unable to get data from eeprom \n"); - aim_free(rdata); - *size = 0; - return ONLP_STATUS_E_INTERNAL; -} - -void -onlp_sysi_onie_data_free(uint8_t* data) -{ - if (data) { - aim_free(data); - } -} - -int -onlp_sysi_oids_get(onlp_oid_t* table, int max) -{ - onlp_oid_t* e = table; - memset(table, 0, max*sizeof(onlp_oid_t)); - int i; - - if ( !bmc_enable ) { - /* 2 PSUs */ - *e++ = ONLP_PSU_ID_CREATE(1); - *e++ = ONLP_PSU_ID_CREATE(2); - - /* LEDs Item */ - for (i=1; i<=LED_NUM; i++) { - *e++ = ONLP_LED_ID_CREATE(i); - } - - /* Fans Item */ - for (i=1; i<=FAN_NUM; i++) { - *e++ = ONLP_FAN_ID_CREATE(i); - } - } - - /* THERMALs Item */ - if ( !bmc_enable ) { - for (i=1; i<=THERMAL_NUM; i++) { - *e++ = ONLP_THERMAL_ID_CREATE(i); - } - } else { - *e++ = THERMAL_OID_CPU1; - *e++ = THERMAL_OID_CPU2; - *e++ = THERMAL_OID_CPU3; - *e++ = THERMAL_OID_CPU4; - *e++ = THERMAL_OID_CPU_BOARD; - } - - return ONLP_STATUS_OK; -} - -int -decide_fan_percentage(int is_up, int new_temp) -{ - int new_perc; - if (is_up) { - if (new_temp >= THERMAL_ERROR_DEFAULT) { - new_perc = THERMAL_ERROR_FAN_PERC; - } else if (new_temp >= THERMAL_WARNING_DEFAULT) { - new_perc = THERMAL_WARNING_FAN_PERC; - } else { - new_perc = THERMAL_NORMAL_FAN_PERC; - } - } else { - if (new_temp <= THERMAL_NORMAL_DEFAULT) { - new_perc = THERMAL_NORMAL_FAN_PERC; - } else if (new_temp <= THERMAL_WARNING_DEFAULT) { - new_perc = THERMAL_WARNING_FAN_PERC; - } else { - new_perc = THERMAL_ERROR_FAN_PERC; - } - } - - return new_perc; -} - -int -platform_thermal_temp_get(int *thermal_temp) -{ - int i, temp, max_temp, rc; - onlp_thermal_info_t thermal_info; - memset(&thermal_info, 0, sizeof(thermal_info)); - uint32_t thermal_arr[] = { THERMAL_OID_FRONT_MAC, - THERMAL_OID_ASIC, - THERMAL_OID_CPU1, - THERMAL_OID_CPU2, - THERMAL_OID_CPU3, - THERMAL_OID_CPU4 }; - max_temp = 0; - - for (i=0; i max_temp) { - max_temp = temp; - } - } - *thermal_temp = max_temp; - - return ONLP_STATUS_OK; -} - -int -onlp_sysi_platform_manage_fans(void) -{ - int rc, is_up ,new_temp, thermal_temp, diff; - static int new_perc = 0, ori_perc = 0; - static int ori_temp = 0; - onlp_thermal_info_t thermal_info; - memset(&thermal_info, 0, sizeof(thermal_info)); - - if ( bmc_enable ) { - return ONLP_STATUS_E_UNSUPPORTED; - } - - /* get new temperature */ - if ((rc = platform_thermal_temp_get(&thermal_temp)) != ONLP_STATUS_OK) { - goto _EXIT; - } - - new_temp = thermal_temp; - diff = new_temp - ori_temp; - - if (diff == 0) { - goto _EXIT; - } else { - is_up = (diff > 0 ? 1 : 0); - } - - new_perc = decide_fan_percentage(is_up, new_temp); - - if (ori_perc == new_perc) { - goto _EXIT; - } - - - AIM_LOG_INFO("The Fan Speeds Percent are now at %d%%", new_perc); - - if ((rc = onlp_fani_percentage_set(THERMAL_OID_ASIC, new_perc)) != ONLP_STATUS_OK) { - goto _EXIT; - } - - /* update */ - ori_perc = new_perc; - ori_temp = new_temp; - -_EXIT : - return rc; -} - -int -onlp_sysi_platform_manage_leds(void) -{ - int psu1_status, psu2_status, rc, i; - static int pre_psu1_status = 0, pre_psu2_status = 0, pre_fan_status = 0; - - //------------------------------- - static int pre_fan_tray_status[4] = {0}; - int fan_tray_id, sum, total = 0; - onlp_led_status_t fan_tray_status[SYS_FAN_NUM]; - //------------------------------- - - onlp_psu_info_t psu_info; - onlp_fan_info_t fan_info; - - //-------- ----------------------- - memset(&fan_tray_status, 0, sizeof(fan_tray_status)); - //------------------------------- - - memset(&psu_info, 0, sizeof(onlp_psu_info_t)); - memset(&fan_info, 0, sizeof(onlp_fan_info_t)); - uint32_t fan_arr[] = { FAN_OID_FAN1, - FAN_OID_FAN2, - FAN_OID_FAN3, - FAN_OID_FAN4, - FAN_OID_FAN5, - FAN_OID_FAN6, - FAN_OID_FAN7, - FAN_OID_FAN8, }; - - if ( bmc_enable ) { - return ONLP_STATUS_E_UNSUPPORTED; - } - - /* PSU LED CTRL */ - if ((rc = onlp_psui_info_get(PSU_OID_PSU1, &psu_info)) != ONLP_STATUS_OK) { - goto _EXIT; - } - - psu1_status = psu_info.status; - if (psu1_status != pre_psu1_status) { - 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); - } - - if (rc != ONLP_STATUS_OK) { - goto _EXIT; - } - pre_psu1_status = psu1_status; - } - - if ((rc = onlp_psui_info_get(PSU_OID_PSU2, &psu_info)) != ONLP_STATUS_OK) { - goto _EXIT; - } - - psu2_status = psu_info.status; - if( psu2_status != pre_psu2_status) { - 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); - } - - if (rc != ONLP_STATUS_OK) { - goto _EXIT; - } - pre_psu2_status = psu2_status; - } - - /* FAN LED CTRL */ - 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 (rc != ONLP_STATUS_OK) { - goto _EXIT; - } - - pre_fan_tray_status[fan_tray_id - 5] = sum; - } - } - } - - - 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; - } - -_EXIT : - return rc; -} - -int -onlp_sysi_platform_info_get(onlp_platform_info_t* pi) -{ - int rc; - if ((rc = sysi_platform_info_get(pi)) != ONLP_STATUS_OK) { - return ONLP_STATUS_E_INTERNAL; - } - - return ONLP_STATUS_OK; -} - -void -onlp_sysi_platform_info_free(onlp_platform_info_t* pi) -{ - if (pi->cpld_versions) { - aim_free(pi->cpld_versions); - } - - if (pi->other_versions) { - aim_free(pi->other_versions); - } -} - diff --git a/packages/platforms/ingrasys/x86-64/s9180-32x/onlp/builds/x86_64_ingrasys_s9180_32x/module/src/thermali.c b/packages/platforms/ingrasys/x86-64/s9180-32x/onlp/builds/x86_64_ingrasys_s9180_32x/module/src/thermali.c deleted file mode 100755 index 6891b9e7e..000000000 --- a/packages/platforms/ingrasys/x86-64/s9180-32x/onlp/builds/x86_64_ingrasys_s9180_32x/module/src/thermali.c +++ /dev/null @@ -1,330 +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. - * - * - ************************************************************ - * - * Thermal Sensor Platform Implementation. - * - ***********************************************************/ -#include -#include -#include "x86_64_ingrasys_s9180_32x_log.h" -#include "platform_lib.h" - -static onlp_thermal_info_t thermal_info[] = { - { }, /* Not used */ - { { THERMAL_OID_FRONT_MAC, "Front MAC", 0}, - ONLP_THERMAL_STATUS_PRESENT, - ONLP_THERMAL_CAPS_ALL, 0, {62700, 66000, 69000} - }, - { { THERMAL_OID_ASIC, "ASIC Core Temp", 0}, - ONLP_THERMAL_STATUS_PRESENT, - ONLP_THERMAL_CAPS_ALL, 0, {84787, 89250, 93712} - }, - { { THERMAL_OID_CPU1, "CPU Thermal 1", 0}, - ONLP_THERMAL_STATUS_PRESENT, - ONLP_THERMAL_CAPS_ALL, 0, THERMAL_THRESHOLD_INIT_DEFAULTS - }, - { { THERMAL_OID_CPU2, "CPU Thermal 2", 0}, - ONLP_THERMAL_STATUS_PRESENT, - ONLP_THERMAL_CAPS_ALL, 0, THERMAL_THRESHOLD_INIT_DEFAULTS - }, - { { THERMAL_OID_CPU3, "CPU Thermal 3", 0}, - ONLP_THERMAL_STATUS_PRESENT, - ONLP_THERMAL_CAPS_ALL, 0, THERMAL_THRESHOLD_INIT_DEFAULTS - }, - { { THERMAL_OID_CPU4, "CPU Thermal 4", 0}, - ONLP_THERMAL_STATUS_PRESENT, - ONLP_THERMAL_CAPS_ALL, 0, THERMAL_THRESHOLD_INIT_DEFAULTS - }, - { { THERMAL_OID_PSU1_1, "PSU-1 Thermal 1", PSU_OID_PSU1}, - ONLP_THERMAL_STATUS_PRESENT, - ONLP_THERMAL_CAPS_GET_TEMPERATURE, 0 - }, - { { THERMAL_OID_PSU1_2, "PSU-1 Thermal 2", PSU_OID_PSU1}, - ONLP_THERMAL_STATUS_PRESENT, - ONLP_THERMAL_CAPS_GET_TEMPERATURE, 0 - }, - { { THERMAL_OID_PSU2_1, "PSU-2 Thermal 1", PSU_OID_PSU2}, - ONLP_THERMAL_STATUS_PRESENT, - ONLP_THERMAL_CAPS_GET_TEMPERATURE, 0 - }, - { { THERMAL_OID_PSU2_2, "PSU-2 Thermal 2", PSU_OID_PSU2}, - ONLP_THERMAL_STATUS_PRESENT, - ONLP_THERMAL_CAPS_GET_TEMPERATURE, 0 - }, - { { THERMAL_OID_CPU_BOARD, "CPU Board", 0}, - ONLP_THERMAL_STATUS_PRESENT, - ONLP_THERMAL_CAPS_ALL, 0, {59774, 62920, 66066} - }, - { { THERMAL_OID_PSU1_NEAR, "Near PSU 1", 0}, - ONLP_THERMAL_STATUS_PRESENT, - ONLP_THERMAL_CAPS_ALL, 0, {61132, 64350, 67567} - }, - { { THERMAL_OID_PSU2_NEAR, "Near PSU 2", 0}, - ONLP_THERMAL_STATUS_PRESENT, - ONLP_THERMAL_CAPS_ALL, 0, {61132, 64350, 67567} - }, - { { THERMAL_OID_MAC_REAR, "Rear MAC", 0}, - ONLP_THERMAL_STATUS_PRESENT, - ONLP_THERMAL_CAPS_ALL, 0, {5727, 60260, 63273} - }, - { { THERMAL_OID_QSFP_NEAR, "Near QSFP Port", 0}, - ONLP_THERMAL_STATUS_PRESENT, - ONLP_THERMAL_CAPS_ALL, 0, {55508, 58430, 61351} - } -}; - -/* - * This will be called to intiialize the thermali subsystem. - */ -int -onlp_thermali_init(void) -{ - return ONLP_STATUS_OK; -} - -static int -sys_thermal_info_get(onlp_thermal_info_t* info, int id) -{ - int rv; - - if ( bmc_enable ) { - return ONLP_STATUS_E_UNSUPPORTED; - } else { - rv = onlp_file_read_int(&info->mcelsius, - SYS_CORE_TEMP_PREFIX "temp%d_input", id); - } - - if(rv == ONLP_STATUS_E_INTERNAL) { - return rv; - } - - if(rv == ONLP_STATUS_E_MISSING) { - info->status &= ~1; - return 0; - } - - return ONLP_STATUS_OK; -} - -static int -cpu_thermal_info_get(onlp_thermal_info_t* info, int id) -{ - int rv; - int offset; - - offset = 1; - id = id - offset; - rv = onlp_file_read_int(&info->mcelsius, - SYS_CPU_TEMP_PREFIX "temp%d_input", id); - - if(rv == ONLP_STATUS_E_INTERNAL) { - return rv; - } - - if(rv == ONLP_STATUS_E_MISSING) { - info->status &= ~1; - return 0; - } - - return ONLP_STATUS_OK; -} - -int -psu_thermal_info_get(onlp_thermal_info_t* info, int id) -{ - int rv; - - if ( bmc_enable ) { - return ONLP_STATUS_E_UNSUPPORTED; - } - - rv = psu_thermal_get(info, id); - if(rv == ONLP_STATUS_E_INTERNAL) { - return rv; - } - - return ONLP_STATUS_OK; -} - -static int -cpu_board_thermal_info_get(onlp_thermal_info_t* info) -{ - int rv; - - if ( bmc_enable ) { - rv = onlp_file_read_int(&info->mcelsius, - SYS_BMC_CPU_BOARD_TEMP_PREFIX "temp1_input"); - } else { - rv = onlp_file_read_int(&info->mcelsius, - SYS_CPU_BOARD_TEMP_PREFIX "temp1_input"); - } - - if (rv == ONLP_STATUS_E_INTERNAL) { - return rv; - } - - if (rv == ONLP_STATUS_E_MISSING) { - info->status &= ~1; - return 0; - } - - return ONLP_STATUS_OK; -} - -static int -psu_near_thermal_info_get(onlp_thermal_info_t* info, int id) -{ - int rv; - - if (id == THERMAL_ID_PSU1_NEAR) { - if ( bmc_enable ) { - return ONLP_STATUS_E_UNSUPPORTED; - } else { - rv = onlp_file_read_int(&info->mcelsius, - SYS_PSU1_NEAR_TEMP_PREFIX "temp1_input"); - } - } else if (id == THERMAL_ID_PSU2_NEAR) { - if ( bmc_enable ) { - return ONLP_STATUS_E_UNSUPPORTED; - } else { - rv = onlp_file_read_int(&info->mcelsius, - SYS_PSU2_NEAR_TEMP_PREFIX "temp1_input"); - } - } else { - return ONLP_STATUS_E_INTERNAL; - } - - if (rv == ONLP_STATUS_E_INTERNAL) { - return rv; - } - - if (rv == ONLP_STATUS_E_MISSING) { - info->status &= ~1; - return 0; - } - - return ONLP_STATUS_OK; -} - -static int -mac_rear_thermal_info_get(onlp_thermal_info_t* info) -{ - int rv; - - if ( bmc_enable ) { - return ONLP_STATUS_E_UNSUPPORTED; - } else { - rv = onlp_file_read_int(&info->mcelsius, - SYS_MAC_REAR_TEMP_PREFIX "temp1_input"); - } - - if (rv == ONLP_STATUS_E_INTERNAL) { - return rv; - } - - if (rv == ONLP_STATUS_E_MISSING) { - info->status &= ~1; - return 0; - } - - return ONLP_STATUS_OK; -} - -static int -qsfp_near_thermal_info_get(onlp_thermal_info_t* info) -{ - int rv; - - if ( bmc_enable ) { - return ONLP_STATUS_E_UNSUPPORTED; - } else { - rv = onlp_file_read_int(&info->mcelsius, - SYS_QSFP_NEAR_TEMP_PREFIX "temp1_input"); - } - - if (rv == ONLP_STATUS_E_INTERNAL) { - return rv; - } - - if (rv == ONLP_STATUS_E_MISSING) { - info->status &= ~1; - return 0; - } - - 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 sensor_id, rc; - sensor_id = ONLP_OID_ID_GET(id); - - *info = thermal_info[sensor_id]; - info->caps |= ONLP_THERMAL_CAPS_GET_TEMPERATURE; - - switch (sensor_id) { - case THERMAL_ID_ASIC: - case THERMAL_ID_FRONT_MAC: - rc = sys_thermal_info_get(info, sensor_id); - break; - case THERMAL_ID_CPU1: - case THERMAL_ID_CPU2: - case THERMAL_ID_CPU3: - case THERMAL_ID_CPU4: - rc = cpu_thermal_info_get(info, sensor_id); - break; - case THERMAL_ID_PSU1_1: - case THERMAL_ID_PSU1_2: - case THERMAL_ID_PSU2_1: - case THERMAL_ID_PSU2_2: - rc = psu_thermal_info_get(info, sensor_id); - break; - case THERMAL_ID_CPU_BOARD: - rc = cpu_board_thermal_info_get(info); - break; - case THERMAL_ID_PSU1_NEAR: - case THERMAL_ID_PSU2_NEAR: - rc = psu_near_thermal_info_get(info, sensor_id); - break; - case THERMAL_ID_MAC_REAR: - rc = mac_rear_thermal_info_get(info); - break; - case THERMAL_ID_QSFP_NEAR: - rc = qsfp_near_thermal_info_get(info); - break; - default: - return ONLP_STATUS_E_INTERNAL; - break; - } - - return rc; -} diff --git a/packages/platforms/ingrasys/x86-64/s9180-32x/onlp/builds/x86_64_ingrasys_s9180_32x/module/src/x86_64_ingrasys_s9180_32x_config.c b/packages/platforms/ingrasys/x86-64/s9180-32x/onlp/builds/x86_64_ingrasys_s9180_32x/module/src/x86_64_ingrasys_s9180_32x_config.c deleted file mode 100755 index e99351803..000000000 --- a/packages/platforms/ingrasys/x86-64/s9180-32x/onlp/builds/x86_64_ingrasys_s9180_32x/module/src/x86_64_ingrasys_s9180_32x_config.c +++ /dev/null @@ -1,96 +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 __x86_64_ingrasys_s9180_32x_config_STRINGIFY_NAME(_x) #_x -#define __x86_64_ingrasys_s9180_32x_config_STRINGIFY_VALUE(_x) __x86_64_ingrasys_s9180_32x_config_STRINGIFY_NAME(_x) -x86_64_ingrasys_s9180_32x_config_settings_t x86_64_ingrasys_s9180_32x_config_settings[] = -{ -#ifdef X86_64_INGRASYS_S9180_32X_CONFIG_INCLUDE_LOGGING - { __x86_64_ingrasys_s9180_32x_config_STRINGIFY_NAME(X86_64_INGRASYS_S9180_32X_CONFIG_INCLUDE_LOGGING), __x86_64_ingrasys_s9180_32x_config_STRINGIFY_VALUE(X86_64_INGRASYS_S9180_32X_CONFIG_INCLUDE_LOGGING) }, -#else -{ X86_64_INGRASYS_S9180_32X_CONFIG_INCLUDE_LOGGING(__x86_64_ingrasys_s9180_32x_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_INGRASYS_S9180_32X_CONFIG_LOG_OPTIONS_DEFAULT - { __x86_64_ingrasys_s9180_32x_config_STRINGIFY_NAME(X86_64_INGRASYS_S9180_32X_CONFIG_LOG_OPTIONS_DEFAULT), __x86_64_ingrasys_s9180_32x_config_STRINGIFY_VALUE(X86_64_INGRASYS_S9180_32X_CONFIG_LOG_OPTIONS_DEFAULT) }, -#else -{ X86_64_INGRASYS_S9180_32X_CONFIG_LOG_OPTIONS_DEFAULT(__x86_64_ingrasys_s9180_32x_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_INGRASYS_S9180_32X_CONFIG_LOG_BITS_DEFAULT - { __x86_64_ingrasys_s9180_32x_config_STRINGIFY_NAME(X86_64_INGRASYS_S9180_32X_CONFIG_LOG_BITS_DEFAULT), __x86_64_ingrasys_s9180_32x_config_STRINGIFY_VALUE(X86_64_INGRASYS_S9180_32X_CONFIG_LOG_BITS_DEFAULT) }, -#else -{ X86_64_INGRASYS_S9180_32X_CONFIG_LOG_BITS_DEFAULT(__x86_64_ingrasys_s9180_32x_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_INGRASYS_S9180_32X_CONFIG_LOG_CUSTOM_BITS_DEFAULT - { __x86_64_ingrasys_s9180_32x_config_STRINGIFY_NAME(X86_64_INGRASYS_S9180_32X_CONFIG_LOG_CUSTOM_BITS_DEFAULT), __x86_64_ingrasys_s9180_32x_config_STRINGIFY_VALUE(X86_64_INGRASYS_S9180_32X_CONFIG_LOG_CUSTOM_BITS_DEFAULT) }, -#else -{ X86_64_INGRASYS_S9180_32X_CONFIG_LOG_CUSTOM_BITS_DEFAULT(__x86_64_ingrasys_s9180_32x_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_INGRASYS_S9180_32X_CONFIG_PORTING_STDLIB - { __x86_64_ingrasys_s9180_32x_config_STRINGIFY_NAME(X86_64_INGRASYS_S9180_32X_CONFIG_PORTING_STDLIB), __x86_64_ingrasys_s9180_32x_config_STRINGIFY_VALUE(X86_64_INGRASYS_S9180_32X_CONFIG_PORTING_STDLIB) }, -#else -{ X86_64_INGRASYS_S9180_32X_CONFIG_PORTING_STDLIB(__x86_64_ingrasys_s9180_32x_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_INGRASYS_S9180_32X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS - { __x86_64_ingrasys_s9180_32x_config_STRINGIFY_NAME(X86_64_INGRASYS_S9180_32X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS), __x86_64_ingrasys_s9180_32x_config_STRINGIFY_VALUE(X86_64_INGRASYS_S9180_32X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS) }, -#else -{ X86_64_INGRASYS_S9180_32X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS(__x86_64_ingrasys_s9180_32x_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_INGRASYS_S9180_32X_CONFIG_INCLUDE_UCLI - { __x86_64_ingrasys_s9180_32x_config_STRINGIFY_NAME(X86_64_INGRASYS_S9180_32X_CONFIG_INCLUDE_UCLI), __x86_64_ingrasys_s9180_32x_config_STRINGIFY_VALUE(X86_64_INGRASYS_S9180_32X_CONFIG_INCLUDE_UCLI) }, -#else -{ X86_64_INGRASYS_S9180_32X_CONFIG_INCLUDE_UCLI(__x86_64_ingrasys_s9180_32x_config_STRINGIFY_NAME), "__undefined__" }, -#endif - { NULL, NULL } -}; -#undef __x86_64_ingrasys_s9180_32x_config_STRINGIFY_VALUE -#undef __x86_64_ingrasys_s9180_32x_config_STRINGIFY_NAME - -const char* -x86_64_ingrasys_s9180_32x_config_lookup(const char* setting) -{ - int i; - for(i = 0; x86_64_ingrasys_s9180_32x_config_settings[i].name; i++) { - if(!strcmp(x86_64_ingrasys_s9180_32x_config_settings[i].name, setting)) { - return x86_64_ingrasys_s9180_32x_config_settings[i].value; - } - } - return NULL; -} - -int -x86_64_ingrasys_s9180_32x_config_show(struct aim_pvs_s* pvs) -{ - int i; - for(i = 0; x86_64_ingrasys_s9180_32x_config_settings[i].name; i++) { - aim_printf(pvs, "%s = %s\n", x86_64_ingrasys_s9180_32x_config_settings[i].name, x86_64_ingrasys_s9180_32x_config_settings[i].value); - } - return i; -} - -/* */ - diff --git a/packages/platforms/ingrasys/x86-64/s9180-32x/onlp/builds/x86_64_ingrasys_s9180_32x/module/src/x86_64_ingrasys_s9180_32x_enums.c b/packages/platforms/ingrasys/x86-64/s9180-32x/onlp/builds/x86_64_ingrasys_s9180_32x/module/src/x86_64_ingrasys_s9180_32x_enums.c deleted file mode 100755 index 30d7f9082..000000000 --- a/packages/platforms/ingrasys/x86-64/s9180-32x/onlp/builds/x86_64_ingrasys_s9180_32x/module/src/x86_64_ingrasys_s9180_32x_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/ingrasys/x86-64/s9180-32x/onlp/builds/x86_64_ingrasys_s9180_32x/module/src/x86_64_ingrasys_s9180_32x_int.h b/packages/platforms/ingrasys/x86-64/s9180-32x/onlp/builds/x86_64_ingrasys_s9180_32x/module/src/x86_64_ingrasys_s9180_32x_int.h deleted file mode 100755 index 54e126e40..000000000 --- a/packages/platforms/ingrasys/x86-64/s9180-32x/onlp/builds/x86_64_ingrasys_s9180_32x/module/src/x86_64_ingrasys_s9180_32x_int.h +++ /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. - * - * - ************************************************************ - * - * - * - ***********************************************************/ - -#ifndef __x86_64_ingrasys_s9180_32x_INT_H__ -#define __x86_64_ingrasys_s9180_32x_INT_H__ - -#endif /* __x86_64_ingrasys_s9180_32x_INT_H__ */ diff --git a/packages/platforms/ingrasys/x86-64/s9180-32x/onlp/builds/x86_64_ingrasys_s9180_32x/module/src/x86_64_ingrasys_s9180_32x_log.c b/packages/platforms/ingrasys/x86-64/s9180-32x/onlp/builds/x86_64_ingrasys_s9180_32x/module/src/x86_64_ingrasys_s9180_32x_log.c deleted file mode 100755 index 58547e5ec..000000000 --- a/packages/platforms/ingrasys/x86-64/s9180-32x/onlp/builds/x86_64_ingrasys_s9180_32x/module/src/x86_64_ingrasys_s9180_32x_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 "x86_64_ingrasys_s9180_32x_log.h" -/* - * x86_64_ingrasys_s9180_32x log struct. - */ -AIM_LOG_STRUCT_DEFINE( - X86_64_INGRASYS_S9180_32X_CONFIG_LOG_OPTIONS_DEFAULT, - X86_64_INGRASYS_S9180_32X_CONFIG_LOG_BITS_DEFAULT, - NULL, /* Custom log map */ - X86_64_INGRASYS_S9180_32X_CONFIG_LOG_CUSTOM_BITS_DEFAULT - ); - diff --git a/packages/platforms/ingrasys/x86-64/s9180-32x/onlp/builds/x86_64_ingrasys_s9180_32x/module/src/x86_64_ingrasys_s9180_32x_log.h b/packages/platforms/ingrasys/x86-64/s9180-32x/onlp/builds/x86_64_ingrasys_s9180_32x/module/src/x86_64_ingrasys_s9180_32x_log.h deleted file mode 100755 index f69147bfc..000000000 --- a/packages/platforms/ingrasys/x86-64/s9180-32x/onlp/builds/x86_64_ingrasys_s9180_32x/module/src/x86_64_ingrasys_s9180_32x_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 __x86_64_ingrasys_s9180_32x_LOG_H__ -#define __x86_64_ingrasys_s9180_32x_LOG_H__ - -#define AIM_LOG_MODULE_NAME x86_64_ingrasys_s9180_32x -#include - -#endif /* __x86_64_ingrasys_s9180_32x_LOG_H__ */ diff --git a/packages/platforms/ingrasys/x86-64/s9180-32x/onlp/builds/x86_64_ingrasys_s9180_32x/module/src/x86_64_ingrasys_s9180_32x_module.c b/packages/platforms/ingrasys/x86-64/s9180-32x/onlp/builds/x86_64_ingrasys_s9180_32x/module/src/x86_64_ingrasys_s9180_32x_module.c deleted file mode 100755 index 2233bc472..000000000 --- a/packages/platforms/ingrasys/x86-64/s9180-32x/onlp/builds/x86_64_ingrasys_s9180_32x/module/src/x86_64_ingrasys_s9180_32x_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 "x86_64_ingrasys_s9180_32x_log.h" - -static int -datatypes_init__(void) -{ -#define INGRASYS_S9180_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_ingrasys_s9180_32x_module_init__(void) -{ - AIM_LOG_STRUCT_REGISTER(); - datatypes_init__(); -} - -int __onlp_platform_version__ = 1; diff --git a/packages/platforms/ingrasys/x86-64/s9180-32x/onlp/builds/x86_64_ingrasys_s9180_32x/module/src/x86_64_ingrasys_s9180_32x_ucli.c b/packages/platforms/ingrasys/x86-64/s9180-32x/onlp/builds/x86_64_ingrasys_s9180_32x/module/src/x86_64_ingrasys_s9180_32x_ucli.c deleted file mode 100755 index 7a949573a..000000000 --- a/packages/platforms/ingrasys/x86-64/s9180-32x/onlp/builds/x86_64_ingrasys_s9180_32x/module/src/x86_64_ingrasys_s9180_32x_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 X86_64_INGRASYS_S9180_32X_CONFIG_INCLUDE_UCLI == 1 - -#include -#include -#include - -static ucli_status_t -x86_64_ingrasys_s9180_32x_ucli_ucli__config__(ucli_context_t* uc) -{ - UCLI_HANDLER_MACRO_MODULE_CONFIG(x86_64_ingrasys_s9180_32x) -} - -/* */ -/****************************************************************************** - * - * These handler table(s) were autogenerated from the symbols in this - * source file. - * - *****************************************************************************/ -static ucli_command_handler_f x86_64_ingrasys_s9180_32x_ucli_ucli_handlers__[] = -{ - x86_64_ingrasys_s9180_32x_ucli_ucli__config__, - NULL -}; -/******************************************************************************/ -/* */ - -static ucli_module_t -x86_64_ingrasys_s9180_32x_ucli_module__ = - { - "x86_64_ingrasys_s9180_32x_ucli", - NULL, - x86_64_ingrasys_s9180_32x_ucli_ucli_handlers__, - NULL, - NULL, - }; - -ucli_node_t* -x86_64_ingrasys_s9180_32x_ucli_node_create(void) -{ - ucli_node_t* n; - ucli_module_init(&x86_64_ingrasys_s9180_32x_ucli_module__); - n = ucli_node_create("x86_64_ingrasys_s9180_32x", NULL, &x86_64_ingrasys_s9180_32x_ucli_module__); - ucli_node_subnode_add(n, ucli_module_log_node_create("x86_64_ingrasys_s9180_32x")); - return n; -} - -#else -void* -x86_64_ingrasys_s9180_32x_ucli_node_create(void) -{ - return NULL; -} -#endif - diff --git a/packages/platforms/ingrasys/x86-64/s9180-32x/platform-config/Makefile b/packages/platforms/ingrasys/x86-64/s9180-32x/platform-config/Makefile deleted file mode 100755 index 003238cf6..000000000 --- a/packages/platforms/ingrasys/x86-64/s9180-32x/platform-config/Makefile +++ /dev/null @@ -1 +0,0 @@ -include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/ingrasys/x86-64/s9180-32x/platform-config/r0/Makefile b/packages/platforms/ingrasys/x86-64/s9180-32x/platform-config/r0/Makefile deleted file mode 100755 index 003238cf6..000000000 --- a/packages/platforms/ingrasys/x86-64/s9180-32x/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/ingrasys/x86-64/s9180-32x/platform-config/r0/PKG.yml b/packages/platforms/ingrasys/x86-64/s9180-32x/platform-config/r0/PKG.yml deleted file mode 100755 index 8054debad..000000000 --- a/packages/platforms/ingrasys/x86-64/s9180-32x/platform-config/r0/PKG.yml +++ /dev/null @@ -1 +0,0 @@ -!include $ONL_TEMPLATES/platform-config-platform.yml ARCH=amd64 VENDOR=ingrasys BASENAME=x86-64-ingrasys-s9180-32x REVISION=r0 diff --git a/packages/platforms/ingrasys/x86-64/s9180-32x/platform-config/r0/src/lib/x86-64-ingrasys-s9180-32x-r0.yml b/packages/platforms/ingrasys/x86-64/s9180-32x/platform-config/r0/src/lib/x86-64-ingrasys-s9180-32x-r0.yml deleted file mode 100755 index 1e2b09020..000000000 --- a/packages/platforms/ingrasys/x86-64/s9180-32x/platform-config/r0/src/lib/x86-64-ingrasys-s9180-32x-r0.yml +++ /dev/null @@ -1,30 +0,0 @@ ---- - -###################################################################### -# -# platform-config for x86-64-ingrasys-s9180-32x -# -###################################################################### - -x86-64-ingrasys-s9180-32x-r0: - - grub: - - serial: >- - --port=0x3f8 - --speed=115200 - --word=8 - --parity=no - --stop=1 - - kernel: - <<: *kernel-3-16 - - args: >- - console=ttyS0,115200n8 - - ##network - ## interfaces: - ## ma1: - ## name: ~ - ## syspath: pci0000:00/0000:00:03.0 diff --git a/packages/platforms/ingrasys/x86-64/s9180-32x/platform-config/r0/src/python/x86_64_ingrasys_s9180_32x_r0/__init__.py b/packages/platforms/ingrasys/x86-64/s9180-32x/platform-config/r0/src/python/x86_64_ingrasys_s9180_32x_r0/__init__.py deleted file mode 100755 index 1ec7c8ffe..000000000 --- a/packages/platforms/ingrasys/x86-64/s9180-32x/platform-config/r0/src/python/x86_64_ingrasys_s9180_32x_r0/__init__.py +++ /dev/null @@ -1,518 +0,0 @@ -from onl.platform.base import * -from onl.platform.ingrasys import * -import os -import sys -import subprocess - -def msg(s, fatal=False): - sys.stderr.write(s) - sys.stderr.flush() - if fatal: - sys.exit(1) - -class OnlPlatform_x86_64_ingrasys_s9180_32x_r0(OnlPlatformIngrasys): - PLATFORM='x86-64-ingrasys-s9180-32x-r0' - MODEL="S9180-32X" - SYS_OBJECT_ID=".9180.32" - - def check_bmc_enable(self): - # check if main mux accessable, if no, bmc enabled - retcode = subprocess.call('i2cget -y 0 0x76 0x0 2>/dev/null', shell=True) - # fail if retrun code not 0 - if retcode: - return 1 - return 0 - - def baseconfig(self): - - bmc_enable = self.check_bmc_enable() - msg("bmc enable : %r\n" % (True if bmc_enable else False)) - - # record the result for onlp - os.system("echo %d > /etc/onl/bmc_en" % bmc_enable) - - if bmc_enable: - return self.baseconfig_bmc() - - # vid to mac vdd value mapping - vdd_val_array=( 0.85, 0.82, 0.77, 0.87, 0.74, 0.84, 0.79, 0.89 ) - # vid to rov reg value mapping - rov_reg_array=( 0x24, 0x21, 0x1C, 0x26, 0x19, 0x23, 0x1E, 0x28 ) - - self.insmod("eeprom_mb") - # init SYS EEPROM devices - self.new_i2c_devices( - [ - # on main board - ('mb_eeprom', 0x55, 0), - # on cpu board - ('mb_eeprom', 0x51, 0), - ] - ) - - os.system("modprobe w83795") - os.system("modprobe eeprom") - os.system("modprobe gpio_pca953x") - self.insmod("optoe") - - ########### initialize I2C bus 0 ########### - # init PCA9548 - self.new_i2c_devices( - [ - ('pca9548', 0x70, 0), - ('pca9548', 0x71, 1), - ('pca9548', 0x71, 2), - ('pca9548', 0x71, 3), - ('pca9548', 0x71, 4), - ('pca9548', 0x71, 7), - ('pca9548', 0x76, 0), - ] - ) - - # init PCA9545 - self.new_i2c_device('pca9545', 0x72, 0) - - # Golden Finger to show CPLD - os.system("i2cget -y 44 0x74 2") - - # Reset BMC Dummy Board - os.system("i2cset -y -r 0 0x26 4 0x00") - os.system("i2cset -y -r 0 0x26 5 0x00") - os.system("i2cset -y -r 0 0x26 2 0x3F") - os.system("i2cset -y -r 0 0x26 3 0x1F") - os.system("i2cset -y -r 0 0x26 6 0xC0") - os.system("i2cset -y -r 0 0x26 7 0x00") - - # CPU Baord - os.system("i2cset -y -r 0 0x77 6 0xFF") - os.system("i2cset -y -r 0 0x77 7 0xFF") - - # init SMBUS1 ABS - os.system("i2cset -y -r 5 0x20 4 0x00") - os.system("i2cset -y -r 5 0x20 5 0x00") - os.system("i2cset -y -r 5 0x20 6 0xFF") - os.system("i2cset -y -r 5 0x20 7 0xFF") - - os.system("i2cset -y -r 5 0x21 4 0x00") - os.system("i2cset -y -r 5 0x21 5 0x00") - os.system("i2cset -y -r 5 0x21 6 0xFF") - os.system("i2cset -y -r 5 0x21 7 0xFF") - - os.system("i2cset -y -r 5 0x22 4 0x00") - os.system("i2cset -y -r 5 0x22 5 0x00") - os.system("i2cset -y -r 5 0x22 6 0xFF") - os.system("i2cset -y -r 5 0x22 7 0xFF") - - os.system("i2cset -y -r 5 0x23 4 0x00") - os.system("i2cset -y -r 5 0x23 5 0x00") - os.system("i2cset -y -r 5 0x23 2 0xCF") - os.system("i2cset -y -r 5 0x23 3 0xF0") - os.system("i2cset -y -r 5 0x23 6 0xCF") - os.system("i2cset -y -r 5 0x23 7 0xF0") - - # init SFP - os.system("i2cset -y -r 5 0x27 4 0x00") - os.system("i2cset -y -r 5 0x27 5 0x00") - os.system("i2cset -y -r 5 0x27 2 0x00") - os.system("i2cset -y -r 5 0x27 3 0x00") - os.system("i2cset -y -r 5 0x27 6 0xCF") - os.system("i2cset -y -r 5 0x27 7 0xF0") - - # set ZQSFP LP_MODE = 0 - os.system("i2cset -y -r 6 0x20 4 0x00") - os.system("i2cset -y -r 6 0x20 5 0x00") - os.system("i2cset -y -r 6 0x20 2 0x00") - os.system("i2cset -y -r 6 0x20 3 0x00") - os.system("i2cset -y -r 6 0x20 6 0x00") - os.system("i2cset -y -r 6 0x20 7 0x00") - - os.system("i2cset -y -r 6 0x21 4 0x00") - os.system("i2cset -y -r 6 0x21 5 0x00") - os.system("i2cset -y -r 6 0x21 2 0x00") - os.system("i2cset -y -r 6 0x21 3 0x00") - os.system("i2cset -y -r 6 0x21 6 0x00") - os.system("i2cset -y -r 6 0x21 7 0x00") - - # set ZQSFP RST = 1 - os.system("i2cset -y -r 6 0x22 4 0x00") - os.system("i2cset -y -r 6 0x22 5 0x00") - os.system("i2cset -y -r 6 0x22 2 0xFF") - os.system("i2cset -y -r 6 0x22 3 0xFF") - os.system("i2cset -y -r 6 0x22 6 0x00") - os.system("i2cset -y -r 6 0x22 7 0x00") - - os.system("i2cset -y -r 6 0x23 4 0x00") - os.system("i2cset -y -r 6 0x23 5 0x00") - os.system("i2cset -y -r 6 0x23 2 0xFF") - os.system("i2cset -y -r 6 0x23 3 0xFF") - os.system("i2cset -y -r 6 0x23 6 0x00") - os.system("i2cset -y -r 6 0x23 7 0x00") - - # init Host GPIO - os.system("i2cset -y -r 0 0x74 4 0x00") - os.system("i2cset -y -r 0 0x74 5 0x00") - os.system("i2cset -y -r 0 0x74 2 0x0F") - os.system("i2cset -y -r 0 0x74 3 0xDF") - os.system("i2cset -y -r 0 0x74 6 0x08") - os.system("i2cset -y -r 0 0x74 7 0x1F") - - # init LED board after PVT (BAREFOOT_IO_EXP_LED_ID) - #os.system("i2cset -y -r 50 0x75 4 0x00") - #os.system("i2cset -y -r 50 0x75 5 0x00") - #os.system("i2cset -y -r 50 0x75 6 0x00") - #os.system("i2cset -y -r 50 0x75 7 0xFF") - - # init Board ID - os.system("i2cset -y -r 51 0x27 4 0x00") - os.system("i2cset -y -r 51 0x27 5 0x00") - os.system("i2cset -y -r 51 0x27 6 0xFF") - os.system("i2cset -y -r 51 0x27 7 0xFF") - - # init Board ID of Dummy BMC Board - os.system("i2cset -y -r 0 0x24 4 0x00") - os.system("i2cset -y -r 0 0x24 5 0x00") - os.system("i2cset -y -r 0 0x24 6 0xFF") - os.system("i2cset -y -r 0 0x24 7 0xFF") - - # init PSU I/O (BAREFOOT_IO_EXP_PSU_ID) - os.system("i2cset -y -r 0 0x25 4 0x00") - os.system("i2cset -y -r 0 0x25 5 0x00") - os.system("i2cset -y -r 0 0x25 2 0x00") - os.system("i2cset -y -r 0 0x25 3 0x1D") - os.system("i2cset -y -r 0 0x25 6 0xDB") - os.system("i2cset -y -r 0 0x25 7 0x03") - - # init FAN I/O (BAREFOOT_IO_EXP_FAN_ID) - os.system("i2cset -y -r 59 0x20 4 0x00") - os.system("i2cset -y -r 59 0x20 5 0x00") - os.system("i2cset -y -r 59 0x20 2 0x11") - os.system("i2cset -y -r 59 0x20 3 0x11") - os.system("i2cset -y -r 59 0x20 6 0xCC") - os.system("i2cset -y -r 59 0x20 7 0xCC") - - # init Fan - # select bank 0 - os.system("i2cset -y -r 56 0x2F 0x00 0x80") - # enable FANIN 1-8 - os.system("i2cset -y -r 56 0x2F 0x06 0xFF") - # disable FANIN 9-14 - os.system("i2cset -y -r 56 0x2F 0x07 0x00") - # select bank 2 - os.system("i2cset -y -r 56 0x2F 0x00 0x82") - # set PWM mode in FOMC - os.system("i2cset -y -r 56 0x2F 0x0F 0x00") - - # init VOLMON - os.system("i2cset -y -r 56 0x2F 0x00 0x80") - os.system("i2cset -y -r 56 0x2F 0x01 0x1C") - os.system("i2cset -y -r 56 0x2F 0x00 0x80") - os.system("i2cset -y -r 56 0x2F 0x02 0xFF") - os.system("i2cset -y -r 56 0x2F 0x03 0x50") - os.system("i2cset -y -r 56 0x2F 0x04 0x0A") - os.system("i2cset -y -r 56 0x2F 0x00 0x80") - os.system("i2cset -y -r 56 0x2F 0x01 0x1D") - self.new_i2c_device('w83795adg', 0x2F, 56) - - # init Fan Speed - os.system("echo 120 > /sys/class/hwmon/hwmon1/device/pwm1") - os.system("echo 120 > /sys/class/hwmon/hwmon1/device/pwm2") - - # init Temperature - self.new_i2c_devices( - [ - # ASIC Coretemp and Front MAC - ('lm86', 0x4C, 41), - - # CPU Board - ('tmp75', 0x4F, 0), - - # Near PSU1 - ('tmp75', 0x48, 41), - - # Rear MAC - ('tmp75', 0x4A, 41), - - # Near Port 32 - ('tmp75', 0x4B, 41), - - # Near PSU2 - ('tmp75', 0x4D, 41), - ] - ) - - # init GPIO, ABS Port 0-15 - self.new_i2c_device('pca9535', 0x20, 5) - for i in range(496, 512): - os.system("echo %d > /sys/class/gpio/export" % i) - os.system("echo 1 > /sys/class/gpio/gpio%d/active_low" % i) - - # init GPIO, ABS Port 16-31 - self.new_i2c_device('pca9535', 0x21, 5) - for i in range(480, 496): - os.system("echo %d > /sys/class/gpio/export" % i) - os.system("echo 1 > /sys/class/gpio/gpio%d/active_low" % i) - - # init GPIO, INT Port 0-15 - self.new_i2c_device('pca9535', 0x22, 5) - for i in range(464, 480): - os.system("echo %d > /sys/class/gpio/export" % i) - os.system("echo 1 > /sys/class/gpio/gpio%d/active_low" % i) - - # init GPIO, INT Port 16-31 - self.new_i2c_device('pca9535', 0x23, 5) - for i in range(448, 464): - os.system("echo %d > /sys/class/gpio/export" % i) - os.system("echo 1 > /sys/class/gpio/gpio%d/active_low" % i) - - # init GPIO, SFP - self.new_i2c_device('pca9535', 0x27, 5) - for i in range(432, 448): - os.system("echo %d > /sys/class/gpio/export" % i) - if i == 180 or i == 181 or i == 184 or \ - i == 185 or i == 186 or i == 187: - os.system("echo out > /sys/class/gpio/gpio%d/direction" % i) - else: - os.system("echo 1 > /sys/class/gpio/gpio%d/active_low" % i) - - # init GPIO, LP Mode Port 0-15 - self.new_i2c_device('pca9535', 0x20, 6) - for i in range(416, 432): - os.system("echo %d > /sys/class/gpio/export" % i) - os.system("echo out > /sys/class/gpio/gpio%d/direction" % i) - - # init GPIO, LP Mode Port 16-31 - self.new_i2c_device('pca9535', 0x21, 6) - for i in range(400, 416): - os.system("echo %d > /sys/class/gpio/export" % i) - os.system("echo out > /sys/class/gpio/gpio%d/direction" % i) - - # init GPIO, RST Port 0-15 - self.new_i2c_device('pca9535', 0x22, 6) - for i in range(384, 400): - os.system("echo %d > /sys/class/gpio/export" % i) - os.system("echo out > /sys/class/gpio/gpio%d/direction" % i) - os.system("echo 1 > /sys/class/gpio/gpio%d/active_low" % i) - os.system("echo 0 > /sys/class/gpio/gpio%d/value" % i) - - # init GPIO, RST Port 16-31 - self.new_i2c_device('pca9535', 0x23, 6) - for i in range(368, 384): - os.system("echo %d > /sys/class/gpio/export" % i) - os.system("echo out > /sys/class/gpio/gpio%d/direction" % i) - os.system("echo 1 > /sys/class/gpio/gpio%d/active_low" % i) - os.system("echo 0 > /sys/class/gpio/gpio%d/value" % i) - - # init QSFP EEPROM - for port in range(1, 33): - self.new_i2c_device('optoe1', 0x50, port + 8) - - # init SFP(0/1) EEPROM - self.new_i2c_device('sff8436', 0x50, 45) - self.new_i2c_device('sff8436', 0x50, 46) - - # init PSU(0/1) EEPROM devices - self.new_i2c_device('eeprom', 0x50, 57) - self.new_i2c_device('eeprom', 0x50, 58) - - # _mac_vdd_init - reg_val_str = subprocess.check_output("""i2cget -y 44 0x33 0x42 2>/dev/null""", shell=True) - reg_val = int(reg_val_str, 16) - vid = reg_val & 0x7 - mac_vdd_val = vdd_val_array[vid] - rov_reg = rov_reg_array[vid] - - msg("Setting mac vdd %1.2f with rov register value 0x%x\n" % (mac_vdd_val, rov_reg) ) - os.system("i2cset -y -r 55 0x22 0x21 0x%x w" % rov_reg) - - # init SYS LED - os.system("i2cset -y -r 50 0x75 2 0x01") - os.system("i2cset -y -r 50 0x75 4 0x00") - os.system("i2cset -y -r 50 0x75 5 0x00") - os.system("i2cset -y -r 50 0x75 6 0x00") - os.system("i2cset -y -r 50 0x75 7 0x00") - - return True - - def baseconfig_bmc(self): - - self.insmod("eeprom_mb") - # init SYS EEPROM devices - self.new_i2c_devices( - [ - # on cpu board - ('mb_eeprom', 0x51, 0), - ] - ) - - os.system("modprobe eeprom") - os.system("modprobe gpio_pca953x") - self.insmod("optoe") - - ########### initialize I2C bus 0 ########### - # init PCA9548 - self.new_i2c_devices( - [ - ('pca9548', 0x70, 0), - ('pca9548', 0x71, 1), - ('pca9548', 0x71, 2), - ('pca9548', 0x71, 3), - ('pca9548', 0x71, 4), - ('pca9548', 0x71, 7), - ] - ) - - # Golden Finger to show CPLD - os.system("i2cget -y 44 0x74 2") - - # CPU Baord - os.system("i2cset -y -r 0 0x77 6 0xFF") - os.system("i2cset -y -r 0 0x77 7 0xFF") - - # init SMBUS1 ABS - os.system("i2cset -y -r 5 0x20 4 0x00") - os.system("i2cset -y -r 5 0x20 5 0x00") - os.system("i2cset -y -r 5 0x20 6 0xFF") - os.system("i2cset -y -r 5 0x20 7 0xFF") - - os.system("i2cset -y -r 5 0x21 4 0x00") - os.system("i2cset -y -r 5 0x21 5 0x00") - os.system("i2cset -y -r 5 0x21 6 0xFF") - os.system("i2cset -y -r 5 0x21 7 0xFF") - - os.system("i2cset -y -r 5 0x22 4 0x00") - os.system("i2cset -y -r 5 0x22 5 0x00") - os.system("i2cset -y -r 5 0x22 6 0xFF") - os.system("i2cset -y -r 5 0x22 7 0xFF") - - os.system("i2cset -y -r 5 0x23 4 0x00") - os.system("i2cset -y -r 5 0x23 5 0x00") - os.system("i2cset -y -r 5 0x23 2 0xCF") - os.system("i2cset -y -r 5 0x23 3 0xF0") - os.system("i2cset -y -r 5 0x23 6 0xCF") - os.system("i2cset -y -r 5 0x23 7 0xF0") - - # init SFP - os.system("i2cset -y -r 5 0x27 4 0x00") - os.system("i2cset -y -r 5 0x27 5 0x00") - os.system("i2cset -y -r 5 0x27 2 0x00") - os.system("i2cset -y -r 5 0x27 3 0x00") - os.system("i2cset -y -r 5 0x27 6 0xCF") - os.system("i2cset -y -r 5 0x27 7 0xF0") - - # set ZQSFP LP_MODE = 0 - os.system("i2cset -y -r 6 0x20 4 0x00") - os.system("i2cset -y -r 6 0x20 5 0x00") - os.system("i2cset -y -r 6 0x20 2 0x00") - os.system("i2cset -y -r 6 0x20 3 0x00") - os.system("i2cset -y -r 6 0x20 6 0x00") - os.system("i2cset -y -r 6 0x20 7 0x00") - - os.system("i2cset -y -r 6 0x21 4 0x00") - os.system("i2cset -y -r 6 0x21 5 0x00") - os.system("i2cset -y -r 6 0x21 2 0x00") - os.system("i2cset -y -r 6 0x21 3 0x00") - os.system("i2cset -y -r 6 0x21 6 0x00") - os.system("i2cset -y -r 6 0x21 7 0x00") - - # set ZQSFP RST = 1 - os.system("i2cset -y -r 6 0x22 4 0x00") - os.system("i2cset -y -r 6 0x22 5 0x00") - os.system("i2cset -y -r 6 0x22 2 0xFF") - os.system("i2cset -y -r 6 0x22 3 0xFF") - os.system("i2cset -y -r 6 0x22 6 0x00") - os.system("i2cset -y -r 6 0x22 7 0x00") - - os.system("i2cset -y -r 6 0x23 4 0x00") - os.system("i2cset -y -r 6 0x23 5 0x00") - os.system("i2cset -y -r 6 0x23 2 0xFF") - os.system("i2cset -y -r 6 0x23 3 0xFF") - os.system("i2cset -y -r 6 0x23 6 0x00") - os.system("i2cset -y -r 6 0x23 7 0x00") - - # init Host GPIO - os.system("i2cset -y -r 0 0x74 4 0x00") - os.system("i2cset -y -r 0 0x74 5 0x00") - os.system("i2cset -y -r 0 0x74 2 0x0F") - os.system("i2cset -y -r 0 0x74 3 0xDF") - os.system("i2cset -y -r 0 0x74 6 0x08") - os.system("i2cset -y -r 0 0x74 7 0x1F") - - # init Temperature - self.new_i2c_devices( - [ - # CPU Board - ('tmp75', 0x4F, 0), - ] - ) - - # init GPIO, ABS Port 0-15 - self.new_i2c_device('pca9535', 0x20, 5) - for i in range(496, 512): - os.system("echo %d > /sys/class/gpio/export" % i) - os.system("echo 1 > /sys/class/gpio/gpio%d/active_low" % i) - - # init GPIO, ABS Port 16-31 - self.new_i2c_device('pca9535', 0x21, 5) - for i in range(480, 496): - os.system("echo %d > /sys/class/gpio/export" % i) - os.system("echo 1 > /sys/class/gpio/gpio%d/active_low" % i) - - # init GPIO, INT Port 0-15 - self.new_i2c_device('pca9535', 0x22, 5) - for i in range(464, 480): - os.system("echo %d > /sys/class/gpio/export" % i) - os.system("echo 1 > /sys/class/gpio/gpio%d/active_low" % i) - - # init GPIO, INT Port 16-31 - self.new_i2c_device('pca9535', 0x23, 5) - for i in range(448, 464): - os.system("echo %d > /sys/class/gpio/export" % i) - os.system("echo 1 > /sys/class/gpio/gpio%d/active_low" % i) - - # init GPIO, SFP - self.new_i2c_device('pca9535', 0x27, 5) - for i in range(432, 448): - os.system("echo %d > /sys/class/gpio/export" % i) - if i == 180 or i == 181 or i == 184 or \ - i == 185 or i == 186 or i == 187: - os.system("echo out > /sys/class/gpio/gpio%d/direction" % i) - else: - os.system("echo 1 > /sys/class/gpio/gpio%d/active_low" % i) - - # init GPIO, LP Mode Port 0-15 - self.new_i2c_device('pca9535', 0x20, 6) - for i in range(416, 432): - os.system("echo %d > /sys/class/gpio/export" % i) - os.system("echo out > /sys/class/gpio/gpio%d/direction" % i) - - # init GPIO, LP Mode Port 16-31 - self.new_i2c_device('pca9535', 0x21, 6) - for i in range(400, 416): - os.system("echo %d > /sys/class/gpio/export" % i) - os.system("echo out > /sys/class/gpio/gpio%d/direction" % i) - - # init GPIO, RST Port 0-15 - self.new_i2c_device('pca9535', 0x22, 6) - for i in range(384, 400): - os.system("echo %d > /sys/class/gpio/export" % i) - os.system("echo out > /sys/class/gpio/gpio%d/direction" % i) - os.system("echo 1 > /sys/class/gpio/gpio%d/active_low" % i) - os.system("echo 0 > /sys/class/gpio/gpio%d/value" % i) - - # init GPIO, RST Port 16-31 - self.new_i2c_device('pca9535', 0x23, 6) - for i in range(368, 384): - os.system("echo %d > /sys/class/gpio/export" % i) - os.system("echo out > /sys/class/gpio/gpio%d/direction" % i) - os.system("echo 1 > /sys/class/gpio/gpio%d/active_low" % i) - os.system("echo 0 > /sys/class/gpio/gpio%d/value" % i) - - # init QSFP EEPROM - for port in range(1, 33): - self.new_i2c_device('optoe1', 0x50, port + 8) - - # init SFP(0/1) EEPROM - self.new_i2c_device('sff8436', 0x50, 45) - self.new_i2c_device('sff8436', 0x50, 46) - - return True diff --git a/packages/platforms/ingrasys/x86-64/s9230-64x/.gitignore b/packages/platforms/ingrasys/x86-64/s9230-64x/.gitignore deleted file mode 100755 index 9f7b1342f..000000000 --- a/packages/platforms/ingrasys/x86-64/s9230-64x/.gitignore +++ /dev/null @@ -1 +0,0 @@ -onlpdump.mk diff --git a/packages/platforms/ingrasys/x86-64/s9230-64x/Makefile b/packages/platforms/ingrasys/x86-64/s9230-64x/Makefile deleted file mode 100755 index 003238cf6..000000000 --- a/packages/platforms/ingrasys/x86-64/s9230-64x/Makefile +++ /dev/null @@ -1 +0,0 @@ -include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/ingrasys/x86-64/s9230-64x/modules/Makefile b/packages/platforms/ingrasys/x86-64/s9230-64x/modules/Makefile deleted file mode 100755 index 003238cf6..000000000 --- a/packages/platforms/ingrasys/x86-64/s9230-64x/modules/Makefile +++ /dev/null @@ -1 +0,0 @@ -include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/ingrasys/x86-64/s9230-64x/modules/PKG.yml b/packages/platforms/ingrasys/x86-64/s9230-64x/modules/PKG.yml deleted file mode 100755 index 82fa39a83..000000000 --- a/packages/platforms/ingrasys/x86-64/s9230-64x/modules/PKG.yml +++ /dev/null @@ -1 +0,0 @@ -!include $ONL_TEMPLATES/platform-modules.yml ARCH=amd64 VENDOR=ingrasys BASENAME=x86-64-ingrasys-s9230-64x KERNELS="onl-kernel-3.16-lts-x86-64-all:amd64" diff --git a/packages/platforms/ingrasys/x86-64/s9230-64x/modules/builds/.gitignore b/packages/platforms/ingrasys/x86-64/s9230-64x/modules/builds/.gitignore deleted file mode 100644 index a65b41774..000000000 --- a/packages/platforms/ingrasys/x86-64/s9230-64x/modules/builds/.gitignore +++ /dev/null @@ -1 +0,0 @@ -lib diff --git a/packages/platforms/ingrasys/x86-64/s9230-64x/modules/builds/Makefile b/packages/platforms/ingrasys/x86-64/s9230-64x/modules/builds/Makefile deleted file mode 100644 index 8d3e3edc5..000000000 --- a/packages/platforms/ingrasys/x86-64/s9230-64x/modules/builds/Makefile +++ /dev/null @@ -1,6 +0,0 @@ -KERNELS := onl-kernel-3.16-lts-x86-64-all:amd64 -KMODULES := $(wildcard *.c) -VENDOR := ingrasys -BASENAME := x86-64-ingrasys-s9230-64x -ARCH := x86_64 -include $(ONL)/make/kmodule.mk diff --git a/packages/platforms/ingrasys/x86-64/s9230-64x/modules/builds/ingrasys_s9230_64x_i2c_cpld.c b/packages/platforms/ingrasys/x86-64/s9230-64x/modules/builds/ingrasys_s9230_64x_i2c_cpld.c deleted file mode 100644 index c9872f6a5..000000000 --- a/packages/platforms/ingrasys/x86-64/s9230-64x/modules/builds/ingrasys_s9230_64x_i2c_cpld.c +++ /dev/null @@ -1,1461 +0,0 @@ -/* - * A i2c cpld driver for the ingrasys_s9230_64x - * - * Copyright (C) 2017 Ingrasys Technology Corporation. - * Leo Lin - * - * 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 - -#ifndef INGRASYS_S9230_64X_I2C_CPLD_H -#define INGRASYS_S9230_64X_I2C_CPLD_H - -/* CPLD device index value */ -enum cpld_id { - cpld1, - cpld2, - cpld3, - cpld4, - cpld5 -}; - -/* port number on CPLD */ -#define CPLD_1_PORT_NUM 12 -#define CPLD_2_PORT_NUM 13 - -/* QSFP port number */ -#define QSFP_MAX_PORT_NUM 64 -#define QSFP_MIN_PORT_NUM 1 - -/* SFP+ port number */ -#define SFP_MAX_PORT_NUM 2 -#define SFP_MIN_PORT_NUM 1 - - -/* CPLD registers */ -#define CPLD_BOARD_TYPE_REG 0x0 -#define CPLD_EXT_BOARD_TYPE_REG 0x7 -#define CPLD_VERSION_REG 0x1 -#define CPLD_ID_REG 0x2 -#define CPLD_QSFP_PORT_STATUS_BASE_REG 0x20 -#define CPLD_QSFP_PORT_CONFIG_BASE_REG 0x30 -#define CPLD_QSFP_PORT_INTERRUPT_REG 0x40 -#define CPLD_SFP_PORT_STATUS_REG 0x2F -#define CPLD_SFP_PORT_CONFIG_REG 0x3F -#define CPLD_QSFP_PORT_INTERRUPT_REG 0x40 -#define CPLD_10GMUX_CONFIG_REG 0x41 -#define CPLD_BMC_STATUS_REG 0x42 -#define CPLD_BMC_WATCHDOG_REG 0x43 -#define CPLD_USB_STATUS_REG 0x44 -#define CPLD_REST_CONTROL_REG 0x4A - - -/* bit definition for register value */ -enum CPLD_QSFP_PORT_STATUS_BITS { - CPLD_QSFP_PORT_STATUS_INT_BIT, - CPLD_QSFP_PORT_STATUS_ABS_BIT, -}; -enum CPLD_QSFP_PORT_CONFIG_BITS { - CPLD_QSFP_PORT_CONFIG_RESET_BIT, - CPLD_QSFP_PORT_CONFIG_RESERVE_BIT, - CPLD_QSFP_PORT_CONFIG_LPMODE_BIT, -}; -enum CPLD_SFP_PORT_STATUS_BITS { - CPLD_SFP_PORT_STATUS_PRESENT_BIT, - CPLD_SFP_PORT_STATUS_TXFAULT_BIT, - CPLD_SFP_PORT_STATUS_RXLOS_BIT, -}; -enum CPLD_SFP_PORT_CONFIG_BITS { - CPLD_SFP_PORT_CONFIG_TXDIS_BIT, - CPLD_SFP_PORT_CONFIG_RS_BIT, - CPLD_SFP_PORT_CONFIG_TS_BIT, -}; -enum CPLD_10GMUX_CONFIG_BITS { - CPLD_10GMUX_CONFIG_ENSMB_BIT, - CPLD_10GMUX_CONFIG_ENINPUT_BIT, - CPLD_10GMUX_CONFIG_SEL1_BIT, - CPLD_10GMUX_CONFIG_SEL0_BIT, -}; -enum CPLD_BMC_WATCHDOG_BITS { - CPLD_10GMUX_CONFIG_ENTIMER_BIT, - CPLD_10GMUX_CONFIG_TIMEOUT_BIT, -}; -enum CPLD_RESET_CONTROL_BITS { - CPLD_RESET_CONTROL_SWRST_BIT, - CPLD_RESET_CONTROL_CP2104RST_BIT, - CPLD_RESET_CONTROL_82P33814RST_BIT, - CPLD_RESET_CONTROL_BMCRST_BIT, -}; - -/* bit field structure for register value */ -struct cpld_reg_board_type_t { - u8 build_rev:2; - u8 hw_rev:2; - u8 board_id:4; -}; - -struct cpld_reg_version_t { - u8 revision:6; - u8 release:1; - u8 reserve:1; -}; - -struct cpld_reg_id_t { - u8 id:3; - u8 release:5; -}; - -/* common manipulation */ -#define INVALID(i, min, max) ((i < min) || (i > max) ? 1u : 0u) -#define READ_BIT(val, bit) ((0u == (val & (1<bf_name) -#define READ_BF_1(bf_struct, val, bf_name, bf_value) \ - bf_struct bf; \ - bf.data = val; \ - bf_value = bf.bf_name -#define BOARD_TYPE_BUILD_REV_GET(val, res) \ - READ_BF(cpld_reg_board_type_t, val, build_rev, res) -#define BOARD_TYPE_HW_REV_GET(val, res) \ - READ_BF(cpld_reg_board_type_t, val, hw_rev, res) -#define BOARD_TYPE_BOARD_ID_GET(val, res) \ - READ_BF(cpld_reg_board_type_t, val, board_id, res) -#define CPLD_VERSION_REV_GET(val, res) \ - READ_BF(cpld_reg_version_t, val, revision, res) -#define CPLD_VERSION_REL_GET(val, res) \ - READ_BF(cpld_reg_version_t, val, release, res) -#define CPLD_ID_ID_GET(val, res) \ - READ_BF(cpld_reg_id_t, val, id, res) -#define CPLD_ID_REL_GET(val, res) \ - READ_BF(cpld_reg_id_t, val, release, res) -/* QSFP/SFP registers manipulation */ -#define QSFP_TO_CPLD_IDX(qsfp_port, cpld_index, cpld_port) \ -{ \ - if (QSFP_MIN_PORT_NUM <= qsfp_port && qsfp_port <= CPLD_1_PORT_NUM) { \ - cpld_index = cpld1; \ - cpld_port = qsfp_port - 1; \ - } else if (CPLD_1_PORT_NUM < qsfp_port \ - && qsfp_port <= QSFP_MAX_PORT_NUM) { \ - cpld_index = cpld2 + (qsfp_port - 1 - CPLD_1_PORT_NUM) \ - / CPLD_2_PORT_NUM; \ - cpld_port = (qsfp_port - 1 - CPLD_1_PORT_NUM) % \ - CPLD_2_PORT_NUM; \ - } else { \ - cpld_index = 0; \ - cpld_port = 0; \ - } \ -} -#define SFP_TO_CPLD_IDX(sfp_port, cpld_index) \ - (cpld_index = sfp_port - SFP_MIN_PORT_NUM) -#define QSFP_PORT_STATUS_REG(cpld_port) \ - (CPLD_QSFP_PORT_STATUS_BASE_REG + cpld_port) -#define QSFP_PORT_CONFIG_REG(cpld_port) \ - (CPLD_QSFP_PORT_CONFIG_BASE_REG + cpld_port) -#define QSFP_PORT_INT_BIT_GET(port_status_value) \ - READ_BIT(port_status_value, CPLD_QSFP_PORT_STATUS_INT_BIT) -#define QSFP_PORT_ABS_BIT_GET(port_status_value) \ - READ_BIT(port_status_value, CPLD_QSFP_PORT_STATUS_ABS_BIT) -#define QSFP_PORT_RESET_BIT_GET(port_config_value) \ - READ_BIT(port_config_value, CPLD_QSFP_PORT_CONFIG_RESET_BIT) -#define QSFP_PORT_LPMODE_BIT_GET(port_config_value) \ - READ_BIT(port_config_value, CPLD_QSFP_PORT_CONFIG_LPMODE_BIT) -#define QSFP_PORT_RESET_BIT_SET(port_config_value) \ - SET_BIT(port_config_value, CPLD_QSFP_PORT_CONFIG_RESET_BIT) -#define QSFP_PORT_RESET_BIT_CLEAR(port_config_value) \ - CLEAR_BIT(port_config_value, CPLD_QSFP_PORT_CONFIG_RESET_BIT) -#define QSFP_PORT_LPMODE_BIT_SET(port_config_value) \ - SET_BIT(port_config_value, CPLD_QSFP_PORT_CONFIG_LPMODE_BIT) -#define QSFP_PORT_LPMODE_BIT_CLEAR(port_config_value) \ - CLEAR_BIT(port_config_value, CPLD_QSFP_PORT_CONFIG_LPMODE_BIT) -#define SFP_PORT_PRESENT_BIT_GET(port_status_value) \ - READ_BIT(port_status_value, CPLD_SFP_PORT_STATUS_PRESENT_BIT) - -#define SFP_PORT_TXFAULT_BIT_GET(port_status_value) \ - READ_BIT(port_status_value, CPLD_SFP_PORT_STATUS_TXFAULT_BIT) -#define SFP_PORT_RXLOS_BIT_GET(port_status_value) \ - READ_BIT(port_status_value, CPLD_SFP_PORT_STATUS_RXLOS_BIT) -#define SFP_PORT_TXDIS_BIT_GET(port_status_value) \ - READ_BIT(port_status_value, CPLD_SFP_PORT_CONFIG_TXDIS_BIT) -#define SFP_PORT_RS_BIT_GET(port_config_value) \ - READ_BIT(port_config_value, CPLD_SFP_PORT_CONFIG_RS_BIT) -#define SFP_PORT_TS_BIT_GET(port_config_value) \ - READ_BIT(port_config_value, CPLD_SFP_PORT_CONFIG_TS_BIT) -#define SFP_PORT_TXDIS_BIT_SET(port_config_value) \ - SET_BIT(port_config_value, CPLD_SFP_PORT_CONFIG_TXDIS_BIT) -#define SFP_PORT_TXDIS_BIT_CLEAR(port_config_value) \ - CLEAR_BIT(port_config_value, CPLD_SFP_PORT_CONFIG_TXDIS_BIT) -#define SFP_PORT_RS_BIT_SET(port_config_value) \ - SET_BIT(port_config_value, CPLD_SFP_PORT_CONFIG_RS_BIT) -#define SFP_PORT_RS_BIT_CLEAR(port_config_value) \ - CLEAR_BIT(port_config_value, CPLD_SFP_PORT_CONFIG_RS_BIT) -#define SFP_PORT_TS_BIT_SET(port_config_value) \ - SET_BIT(port_config_value, CPLD_SFP_PORT_CONFIG_TS_BIT) -#define SFP_PORT_TS_BIT_CLEAR(port_config_value) \ - CLEAR_BIT(port_config_value, CPLD_SFP_PORT_CONFIG_TS_BIT) - -/* CPLD access functions */ -extern int ingrasys_i2c_cpld_get_qsfp_port_status_val(u8 port_num); -extern int ingrasys_i2c_cpld_get_qsfp_port_config_val(u8 port_num); -extern int ingrasys_i2c_cpld_set_qsfp_port_config_val(u8 port_num, u8 reg_val); -extern int ingrasys_i2c_cpld_get_sfp_port_status_val(u8 port_num); -extern int ingrasys_i2c_cpld_get_sfp_port_config_val(u8 port_num); -extern int ingrasys_i2c_cpld_set_sfp_port_config_val(u8 port_num, u8 reg_val); -extern u8 fp_port_to_phy_port(u8 fp_port); -#endif - -#ifdef DEBUG -#define DEBUG_PRINT(fmt, args...) \ - printk(KERN_INFO "%s:%s[%d]: " fmt "\r\n", \ - __FILE__, __func__, __LINE__, ##args) -#else -#define DEBUG_PRINT(fmt, args...) -#endif - -#define I2C_READ_BYTE_DATA(ret, lock, i2c_client, reg) \ -{ \ - mutex_lock(lock); \ - ret = i2c_smbus_read_byte_data(i2c_client, reg); \ - mutex_unlock(lock); \ -} -#define I2C_WRITE_BYTE_DATA(ret, lock, i2c_client, reg, val) \ -{ \ - mutex_lock(lock); \ - ret = i2c_smbus_write_byte_data(i2c_client, reg, val); \ - mutex_unlock(lock); \ -} - -/* CPLD sysfs attributes index */ -enum s9230_64x_cpld_sysfs_attributes { - CPLD_ACCESS_REG, - CPLD_REGISTER_VAL, - CPLD_PORT_START, - CPLD_PORTS, - CPLD_VERSION, - CPLD_ID, - CPLD_BOARD_TYPE, - CPLD_EXT_BOARD_TYPE, - CPLD_QSFP_PORT_STATUS_1, - CPLD_QSFP_PORT_STATUS_2, - CPLD_QSFP_PORT_STATUS_3, - CPLD_QSFP_PORT_STATUS_4, - CPLD_QSFP_PORT_STATUS_5, - CPLD_QSFP_PORT_STATUS_6, - CPLD_QSFP_PORT_STATUS_7, - CPLD_QSFP_PORT_STATUS_8, - CPLD_QSFP_PORT_STATUS_9, - CPLD_QSFP_PORT_STATUS_10, - CPLD_QSFP_PORT_STATUS_11, - CPLD_QSFP_PORT_STATUS_12, - CPLD_QSFP_PORT_STATUS_13, - CPLD_QSFP_PORT_CONFIG_1, - CPLD_QSFP_PORT_CONFIG_2, - CPLD_QSFP_PORT_CONFIG_3, - CPLD_QSFP_PORT_CONFIG_4, - CPLD_QSFP_PORT_CONFIG_5, - CPLD_QSFP_PORT_CONFIG_6, - CPLD_QSFP_PORT_CONFIG_7, - CPLD_QSFP_PORT_CONFIG_8, - CPLD_QSFP_PORT_CONFIG_9, - CPLD_QSFP_PORT_CONFIG_10, - CPLD_QSFP_PORT_CONFIG_11, - CPLD_QSFP_PORT_CONFIG_12, - CPLD_QSFP_PORT_CONFIG_13, - CPLD_QSFP_PORT_INTERRUPT, - CPLD_SFP_PORT_STATUS, - CPLD_SFP_PORT_CONFIG, - CPLD_10GMUX_CONFIG, - CPLD_BMC_STATUS, - CPLD_BMC_WATCHDOG, - CPLD_USB_STATUS, -}; - -/* CPLD sysfs attributes hook functions */ -static ssize_t read_access_register(struct device *dev, - struct device_attribute *da, char *buf); -static ssize_t write_access_register(struct device *dev, - struct device_attribute *da, const char *buf, size_t count); -static ssize_t read_register_value(struct device *dev, - struct device_attribute *da, char *buf); -static ssize_t write_register_value(struct device *dev, - struct device_attribute *da, const char *buf, size_t count); -static ssize_t get_qsfp_port_start(struct device *dev, - struct device_attribute *da, char *buf); -static ssize_t get_qsfp_ports(struct device *dev, - struct device_attribute *da, char *buf); -static ssize_t read_cpld_version(struct device *dev, - struct device_attribute *da, char *buf); -static ssize_t read_cpld_id(struct device *dev, - struct device_attribute *da, char *buf); -static ssize_t read_board_type(struct device *dev, - struct device_attribute *da, char *buf); -static ssize_t read_ext_board_type(struct device *dev, - struct device_attribute *da, char *buf); -static ssize_t read_qsfp_port_status(struct device *dev, - struct device_attribute *da, char *buf); -static ssize_t read_qsfp_port_config(struct device *dev, - struct device_attribute *da, char *buf); -static ssize_t write_qsfp_port_config(struct device *dev, - struct device_attribute *da, const char *buf, size_t count); -static ssize_t read_qsfp_port_interrupt(struct device *dev, - struct device_attribute *da, char *buf); -static ssize_t read_sfp_port_status(struct device *dev, - struct device_attribute *da, char *buf); -static ssize_t read_sfp_port_config(struct device *dev, - struct device_attribute *da, char *buf); -static ssize_t write_sfp_port_config(struct device *dev, - struct device_attribute *da, const char *buf, size_t count); -static ssize_t read_10gmux_config(struct device *dev, - struct device_attribute *da, char *buf); -static ssize_t write_10gmux_config(struct device *dev, - struct device_attribute *da, const char *buf, size_t count); -static ssize_t read_bmc_status(struct device *dev, - struct device_attribute *da, char *buf); -static ssize_t read_bmc_watchdog(struct device *dev, - struct device_attribute *da, char *buf); -static ssize_t write_bmc_watchdog(struct device *dev, - struct device_attribute *da, const char *buf, size_t count); -static ssize_t read_usb_status(struct device *dev, - struct device_attribute *da, char *buf); - -static LIST_HEAD(cpld_client_list); /* client list for cpld */ -static struct mutex list_lock; /* mutex for client list */ - -struct cpld_client_node { - struct i2c_client *client; - struct list_head list; -}; - -struct cpld_data { - int index; /* CPLD index */ - struct mutex access_lock; /* mutex for cpld access */ - u8 access_reg; /* register to access */ -}; - -/* CPLD device id and data */ -static const struct i2c_device_id ingrasys_i2c_cpld_id[] = { - { "ingrasys_cpld1", cpld1 }, - { "ingrasys_cpld2", cpld2 }, - { "ingrasys_cpld3", cpld3 }, - { "ingrasys_cpld4", cpld4 }, - { "ingrasys_cpld5", cpld5 }, - {} -}; - -/* Addresses scanned for ingrasys_i2c_cpld */ -static const unsigned short cpld_i2c_addr[] = { 0x33, I2C_CLIENT_END }; - -/* define all support register access of cpld in attribute */ -static SENSOR_DEVICE_ATTR(cpld_access_register, S_IWUSR | S_IRUGO, - read_access_register, write_access_register, CPLD_ACCESS_REG); -static SENSOR_DEVICE_ATTR(cpld_register_value, S_IWUSR | S_IRUGO, - read_register_value, write_register_value, CPLD_REGISTER_VAL); -static SENSOR_DEVICE_ATTR(cpld_qsfp_port_start, S_IRUGO, - get_qsfp_port_start, NULL, CPLD_PORT_START); -static SENSOR_DEVICE_ATTR(cpld_qsfp_ports, S_IRUGO, - get_qsfp_ports, NULL, CPLD_PORTS); -static SENSOR_DEVICE_ATTR(cpld_version, S_IRUGO, - read_cpld_version, NULL, CPLD_VERSION); -static SENSOR_DEVICE_ATTR(cpld_id, S_IRUGO, read_cpld_id, NULL, CPLD_ID); -static SENSOR_DEVICE_ATTR(cpld_board_type, S_IRUGO, - read_board_type, NULL, CPLD_BOARD_TYPE); -static SENSOR_DEVICE_ATTR(cpld_ext_board_type, S_IRUGO, - read_ext_board_type, NULL, CPLD_EXT_BOARD_TYPE); -static SENSOR_DEVICE_ATTR(cpld_qsfp_port_status_1, S_IRUGO, - read_qsfp_port_status, NULL, CPLD_QSFP_PORT_STATUS_1); -static SENSOR_DEVICE_ATTR(cpld_qsfp_port_status_2, S_IRUGO, - read_qsfp_port_status, NULL, CPLD_QSFP_PORT_STATUS_2); -static SENSOR_DEVICE_ATTR(cpld_qsfp_port_status_3, S_IRUGO, - read_qsfp_port_status, NULL, CPLD_QSFP_PORT_STATUS_3); -static SENSOR_DEVICE_ATTR(cpld_qsfp_port_status_4, S_IRUGO, - read_qsfp_port_status, NULL, CPLD_QSFP_PORT_STATUS_4); -static SENSOR_DEVICE_ATTR(cpld_qsfp_port_status_5, S_IRUGO, - read_qsfp_port_status, NULL, CPLD_QSFP_PORT_STATUS_5); -static SENSOR_DEVICE_ATTR(cpld_qsfp_port_status_6, S_IRUGO, - read_qsfp_port_status, NULL, CPLD_QSFP_PORT_STATUS_6); -static SENSOR_DEVICE_ATTR(cpld_qsfp_port_status_7, S_IRUGO, - read_qsfp_port_status, NULL, CPLD_QSFP_PORT_STATUS_7); -static SENSOR_DEVICE_ATTR(cpld_qsfp_port_status_8, S_IRUGO, - read_qsfp_port_status, NULL, CPLD_QSFP_PORT_STATUS_8); -static SENSOR_DEVICE_ATTR(cpld_qsfp_port_status_9, S_IRUGO, - read_qsfp_port_status, NULL, CPLD_QSFP_PORT_STATUS_9); -static SENSOR_DEVICE_ATTR(cpld_qsfp_port_status_10, S_IRUGO, - read_qsfp_port_status, NULL, CPLD_QSFP_PORT_STATUS_10); -static SENSOR_DEVICE_ATTR(cpld_qsfp_port_status_11, S_IRUGO, - read_qsfp_port_status, NULL, CPLD_QSFP_PORT_STATUS_11); -static SENSOR_DEVICE_ATTR(cpld_qsfp_port_status_12, S_IRUGO, - read_qsfp_port_status, NULL, CPLD_QSFP_PORT_STATUS_12); -static SENSOR_DEVICE_ATTR(cpld_qsfp_port_status_13, S_IRUGO, - read_qsfp_port_status, NULL, CPLD_QSFP_PORT_STATUS_13); -static SENSOR_DEVICE_ATTR(cpld_qsfp_port_config_1, S_IWUSR | S_IRUGO, - read_qsfp_port_config, write_qsfp_port_config, CPLD_QSFP_PORT_CONFIG_1); -static SENSOR_DEVICE_ATTR(cpld_qsfp_port_config_2, S_IWUSR | S_IRUGO, - read_qsfp_port_config, write_qsfp_port_config, - CPLD_QSFP_PORT_CONFIG_2); -static SENSOR_DEVICE_ATTR(cpld_qsfp_port_config_3, S_IWUSR | S_IRUGO, - read_qsfp_port_config, write_qsfp_port_config, - CPLD_QSFP_PORT_CONFIG_3); -static SENSOR_DEVICE_ATTR(cpld_qsfp_port_config_4, S_IWUSR | S_IRUGO, - read_qsfp_port_config, write_qsfp_port_config, - CPLD_QSFP_PORT_CONFIG_4); -static SENSOR_DEVICE_ATTR(cpld_qsfp_port_config_5, S_IWUSR | S_IRUGO, - read_qsfp_port_config, write_qsfp_port_config, - CPLD_QSFP_PORT_CONFIG_5); -static SENSOR_DEVICE_ATTR(cpld_qsfp_port_config_6, S_IWUSR | S_IRUGO, - read_qsfp_port_config, write_qsfp_port_config, - CPLD_QSFP_PORT_CONFIG_6); -static SENSOR_DEVICE_ATTR(cpld_qsfp_port_config_7, S_IWUSR | S_IRUGO, - read_qsfp_port_config, write_qsfp_port_config, - CPLD_QSFP_PORT_CONFIG_7); -static SENSOR_DEVICE_ATTR(cpld_qsfp_port_config_8, S_IWUSR | S_IRUGO, - read_qsfp_port_config, write_qsfp_port_config, - CPLD_QSFP_PORT_CONFIG_8); -static SENSOR_DEVICE_ATTR(cpld_qsfp_port_config_9, S_IWUSR | S_IRUGO, - read_qsfp_port_config, write_qsfp_port_config, - CPLD_QSFP_PORT_CONFIG_9); -static SENSOR_DEVICE_ATTR(cpld_qsfp_port_config_10, S_IWUSR | S_IRUGO, - read_qsfp_port_config, write_qsfp_port_config, - CPLD_QSFP_PORT_CONFIG_10); -static SENSOR_DEVICE_ATTR(cpld_qsfp_port_config_11, S_IWUSR | S_IRUGO, - read_qsfp_port_config, write_qsfp_port_config, - CPLD_QSFP_PORT_CONFIG_11); -static SENSOR_DEVICE_ATTR(cpld_qsfp_port_config_12, S_IWUSR | S_IRUGO, - read_qsfp_port_config, write_qsfp_port_config, - CPLD_QSFP_PORT_CONFIG_12); -static SENSOR_DEVICE_ATTR(cpld_qsfp_port_config_13, S_IWUSR | S_IRUGO, - read_qsfp_port_config, write_qsfp_port_config, - CPLD_QSFP_PORT_CONFIG_13); -static SENSOR_DEVICE_ATTR(cpld_qsfp_port_interrupt, S_IRUGO, - read_qsfp_port_interrupt, NULL, CPLD_QSFP_PORT_INTERRUPT); -static SENSOR_DEVICE_ATTR(cpld_sfp_port_status, S_IRUGO, - read_sfp_port_status, NULL, CPLD_SFP_PORT_STATUS); -static SENSOR_DEVICE_ATTR(cpld_sfp_port_config, S_IWUSR | S_IRUGO, - read_sfp_port_config, write_sfp_port_config, CPLD_SFP_PORT_CONFIG); -static SENSOR_DEVICE_ATTR(cpld_10gmux_config, S_IWUSR | S_IRUGO, - read_10gmux_config, write_10gmux_config, - CPLD_10GMUX_CONFIG); -static SENSOR_DEVICE_ATTR(cpld_bmc_status, S_IRUGO, - read_bmc_status, NULL, CPLD_BMC_STATUS); -static SENSOR_DEVICE_ATTR(cpld_bmc_watchdog, S_IWUSR | S_IRUGO, - read_bmc_watchdog, write_bmc_watchdog, - CPLD_BMC_WATCHDOG); -static SENSOR_DEVICE_ATTR(cpld_usb_status, S_IRUGO, - read_usb_status, NULL, CPLD_USB_STATUS); - - -/* define support attributes of cpldx , total 5 */ -/* cpld 1 */ -static struct attribute *s9230_64x_cpld1_attributes[] = { - &sensor_dev_attr_cpld_access_register.dev_attr.attr, - &sensor_dev_attr_cpld_register_value.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_start.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_ports.dev_attr.attr, - &sensor_dev_attr_cpld_version.dev_attr.attr, - &sensor_dev_attr_cpld_id.dev_attr.attr, - &sensor_dev_attr_cpld_board_type.dev_attr.attr, - &sensor_dev_attr_cpld_ext_board_type.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_status_1.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_status_2.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_status_3.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_status_4.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_status_5.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_status_6.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_status_7.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_status_8.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_status_9.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_status_10.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_status_11.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_status_12.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_config_1.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_config_2.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_config_3.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_config_4.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_config_5.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_config_6.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_config_7.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_config_8.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_config_9.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_config_10.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_config_11.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_config_12.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_interrupt.dev_attr.attr, - &sensor_dev_attr_cpld_sfp_port_status.dev_attr.attr, - &sensor_dev_attr_cpld_sfp_port_config.dev_attr.attr, - &sensor_dev_attr_cpld_10gmux_config.dev_attr.attr, - &sensor_dev_attr_cpld_bmc_status.dev_attr.attr, - &sensor_dev_attr_cpld_bmc_watchdog.dev_attr.attr, - &sensor_dev_attr_cpld_usb_status.dev_attr.attr, - NULL -}; -/* cpld 2 */ -static struct attribute *s9230_64x_cpld2_attributes[] = { - &sensor_dev_attr_cpld_access_register.dev_attr.attr, - &sensor_dev_attr_cpld_register_value.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_start.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_ports.dev_attr.attr, - &sensor_dev_attr_cpld_version.dev_attr.attr, - &sensor_dev_attr_cpld_id.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_status_1.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_status_2.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_status_3.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_status_4.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_status_5.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_status_6.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_status_7.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_status_8.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_status_9.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_status_10.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_status_11.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_status_12.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_status_13.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_config_1.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_config_2.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_config_3.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_config_4.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_config_5.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_config_6.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_config_7.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_config_8.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_config_9.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_config_10.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_config_11.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_config_12.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_config_13.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_interrupt.dev_attr.attr, - &sensor_dev_attr_cpld_sfp_port_status.dev_attr.attr, - &sensor_dev_attr_cpld_sfp_port_config.dev_attr.attr, - NULL -}; -/* cpld 3 / cpld 4 / cpld 5 */ -static struct attribute *s9230_64x_cpld345_attributes[] = { -&sensor_dev_attr_cpld_access_register.dev_attr.attr, - &sensor_dev_attr_cpld_register_value.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_start.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_ports.dev_attr.attr, - &sensor_dev_attr_cpld_version.dev_attr.attr, - &sensor_dev_attr_cpld_id.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_status_1.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_status_2.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_status_3.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_status_4.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_status_5.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_status_6.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_status_7.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_status_8.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_status_9.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_status_10.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_status_11.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_status_12.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_status_13.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_config_1.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_config_2.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_config_3.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_config_4.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_config_5.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_config_6.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_config_7.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_config_8.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_config_9.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_config_10.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_config_11.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_config_12.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_config_13.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_interrupt.dev_attr.attr, - NULL -}; - -/* cpld 1 attributes group */ -static const struct attribute_group s9230_64x_cpld1_group = { - .attrs = s9230_64x_cpld1_attributes, -}; -/* cpld 2 attributes group */ -static const struct attribute_group s9230_64x_cpld2_group = { - .attrs = s9230_64x_cpld2_attributes, -}; -/* cpld 3/4/5 attributes group */ -static const struct attribute_group s9230_64x_cpld345_group = { - .attrs = s9230_64x_cpld345_attributes, -}; - -/* read access register from cpld data */ -static ssize_t read_access_register(struct device *dev, - struct device_attribute *da, - char *buf) -{ - struct i2c_client *client = to_i2c_client(dev); - struct cpld_data *data = i2c_get_clientdata(client); - u8 reg = data->access_reg; - - return sprintf(buf, "0x%x\n", reg); -} - -/* write access register to cpld data */ -static ssize_t write_access_register(struct device *dev, - struct device_attribute *da, - const char *buf, - size_t count) -{ - struct i2c_client *client = to_i2c_client(dev); - struct cpld_data *data = i2c_get_clientdata(client); - u8 reg; - - if (kstrtou8(buf, 0, ®) < 0) - return -EINVAL; - - data->access_reg = reg; - return count; -} - -/* read the value of access register in cpld data */ -static ssize_t read_register_value(struct device *dev, - struct device_attribute *da, - char *buf) -{ - struct i2c_client *client = to_i2c_client(dev); - struct cpld_data *data = i2c_get_clientdata(client); - u8 reg = data->access_reg; - int reg_val; - - I2C_READ_BYTE_DATA(reg_val, &data->access_lock, client, reg); - - if (reg_val < 0) - return -1; - - return sprintf(buf, "0x%x\n", reg_val); -} - -/* wrtie the value to access register in cpld data */ -static ssize_t write_register_value(struct device *dev, - struct device_attribute *da, - const char *buf, - size_t count) -{ - struct i2c_client *client = to_i2c_client(dev); - struct cpld_data *data = i2c_get_clientdata(client); - int ret = -EIO; - u8 reg = data->access_reg; - u8 reg_val; - - if (kstrtou8(buf, 0, ®_val) < 0) - return -EINVAL; - - I2C_WRITE_BYTE_DATA(ret, &data->access_lock, client, reg, reg_val); - - return count; -} - -/* get qsfp port start number of the cpld device */ -/* the start number use to tranlate qsfp port to cpld port */ -/* the cpld port use to access the qsfp port register in cpld */ -static ssize_t get_qsfp_port_start(struct device *dev, - struct device_attribute *da, - char *buf) -{ - struct sensor_device_attribute *attr = to_sensor_dev_attr(da); - struct i2c_client *client = to_i2c_client(dev); - struct cpld_data *data = i2c_get_clientdata(client); - int port_base_num; - - if (attr->index == CPLD_PORT_START) { - if (data->index == cpld1) { - port_base_num = 1; - } else { - port_base_num = CPLD_1_PORT_NUM + - CPLD_2_PORT_NUM*(data->index - 1) + 1; - } - return sprintf(buf, "%d\n", port_base_num); - } - return -1; -} - -/* get total qsfp port which contain register in the cpld device */ -static ssize_t get_qsfp_ports(struct device *dev, - struct device_attribute *da, - char *buf) -{ - struct sensor_device_attribute *attr = to_sensor_dev_attr(da); - struct i2c_client *client = to_i2c_client(dev); - struct cpld_data *data = i2c_get_clientdata(client); - int ports; - - if (attr->index == CPLD_PORTS) { - if (data->index == cpld1) - ports = CPLD_1_PORT_NUM; - else - ports = CPLD_2_PORT_NUM; - return sprintf(buf, "%d\n", ports); - } - return -1; -} - -/* get cpdl version register value */ -static ssize_t read_cpld_version(struct device *dev, - struct device_attribute *da, - char *buf) -{ - struct sensor_device_attribute *attr = to_sensor_dev_attr(da); - struct i2c_client *client = to_i2c_client(dev); - struct cpld_data *data = i2c_get_clientdata(client); - u8 reg; - int reg_val; - - if (attr->index == CPLD_VERSION) { - reg = CPLD_VERSION_REG; - I2C_READ_BYTE_DATA(reg_val, &data->access_lock, client, reg); - if (reg_val < 0) - return -1; - return sprintf(buf, "0x%02x\n", reg_val); - } - return -1; -} - -/* get cpdl id register value */ -static ssize_t read_cpld_id(struct device *dev, - struct device_attribute *da, - char *buf) -{ - struct sensor_device_attribute *attr = to_sensor_dev_attr(da); - struct i2c_client *client = to_i2c_client(dev); - struct cpld_data *data = i2c_get_clientdata(client); - u8 reg; - int reg_val; - - if (attr->index == CPLD_ID) { - reg = CPLD_ID_REG; - I2C_READ_BYTE_DATA(reg_val, &data->access_lock, client, reg); - if (reg_val < 0) - return -1; - return sprintf(buf, "0x%02x\n", reg_val); - } - return -1; -} - -/* get board type register value */ -static ssize_t read_board_type(struct device *dev, - struct device_attribute *da, - char *buf) -{ - struct sensor_device_attribute *attr = to_sensor_dev_attr(da); - struct i2c_client *client = to_i2c_client(dev); - struct cpld_data *data = i2c_get_clientdata(client); - u8 reg; - int reg_val; - - if (attr->index == CPLD_BOARD_TYPE) { - reg = CPLD_BOARD_TYPE_REG; - I2C_READ_BYTE_DATA(reg_val, &data->access_lock, client, reg); - if (reg_val < 0) - return -1; - return sprintf(buf, "0x%02x\n", reg_val); - } - return -1; -} - -/* get extend board type register value */ -static ssize_t read_ext_board_type(struct device *dev, - struct device_attribute *da, - char *buf) -{ - struct sensor_device_attribute *attr = to_sensor_dev_attr(da); - struct i2c_client *client = to_i2c_client(dev); - struct cpld_data *data = i2c_get_clientdata(client); - u8 reg; - int reg_val; - - if (attr->index == CPLD_EXT_BOARD_TYPE) { - reg = CPLD_EXT_BOARD_TYPE_REG; - I2C_READ_BYTE_DATA(reg_val, &data->access_lock, client, reg); - if (reg_val < 0) - return -1; - return sprintf(buf, "0x%02x\n", reg_val); - } - return -1; -} - -/* get qsfp port status register value */ -static ssize_t read_qsfp_port_status(struct device *dev, - struct device_attribute *da, - char *buf) -{ - struct sensor_device_attribute *attr = to_sensor_dev_attr(da); - struct i2c_client *client = to_i2c_client(dev); - struct cpld_data *data = i2c_get_clientdata(client); - u8 reg; - int reg_val; - - if (attr->index >= CPLD_QSFP_PORT_STATUS_1 && - attr->index <= CPLD_QSFP_PORT_STATUS_13) { - reg = CPLD_QSFP_PORT_STATUS_BASE_REG + - (attr->index - CPLD_QSFP_PORT_STATUS_1); - I2C_READ_BYTE_DATA(reg_val, &data->access_lock, client, reg); - if (reg_val < 0) - return -1; - return sprintf(buf, "0x%02x\n", reg_val); - } - return -1; -} - -/* get qsfp port config register value */ -static ssize_t read_qsfp_port_config(struct device *dev, - struct device_attribute *da, - char *buf) -{ - struct sensor_device_attribute *attr = to_sensor_dev_attr(da); - struct i2c_client *client = to_i2c_client(dev); - struct cpld_data *data = i2c_get_clientdata(client); - u8 reg; - int reg_val; - - if (attr->index >= CPLD_QSFP_PORT_CONFIG_1 && - attr->index <= CPLD_QSFP_PORT_CONFIG_13) { - reg = CPLD_QSFP_PORT_CONFIG_BASE_REG + - (attr->index - CPLD_QSFP_PORT_CONFIG_1); - I2C_READ_BYTE_DATA(reg_val, &data->access_lock, client, reg); - if (reg_val < 0) - return -1; - return sprintf(buf, "0x%02x\n", reg_val); - } - return -1; -} - -/* set value to qsfp port config register */ -static ssize_t write_qsfp_port_config(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 cpld_data *data = i2c_get_clientdata(client); - u8 reg, reg_val; - int ret; - - if (kstrtou8(buf, 0, ®_val) < 0) - return -EINVAL; - - if (attr->index >= CPLD_QSFP_PORT_CONFIG_1 && - attr->index <= CPLD_QSFP_PORT_CONFIG_13) { - reg = CPLD_QSFP_PORT_CONFIG_BASE_REG + - (attr->index - CPLD_QSFP_PORT_CONFIG_1); - I2C_WRITE_BYTE_DATA(ret, &data->access_lock, - client, reg, reg_val); - } - return count; -} - -/* get qsfp port interrupt register value */ -static ssize_t read_qsfp_port_interrupt(struct device *dev, - struct device_attribute *da, - char *buf) -{ - struct sensor_device_attribute *attr = to_sensor_dev_attr(da); - struct i2c_client *client = to_i2c_client(dev); - struct cpld_data *data = i2c_get_clientdata(client); - u8 reg; - int reg_val; - - if (attr->index == CPLD_QSFP_PORT_INTERRUPT) { - reg = CPLD_QSFP_PORT_INTERRUPT_REG; - I2C_READ_BYTE_DATA(reg_val, &data->access_lock, client, reg); - if (reg_val < 0) - return -1; - return sprintf(buf, "0x%02x\n", reg_val); - } - return -1; -} - -/* get sfp port status register value */ -static ssize_t read_sfp_port_status(struct device *dev, - struct device_attribute *da, - char *buf) -{ - struct sensor_device_attribute *attr = to_sensor_dev_attr(da); - struct i2c_client *client = to_i2c_client(dev); - struct cpld_data *data = i2c_get_clientdata(client); - u8 reg; - int reg_val; - - if (attr->index == CPLD_SFP_PORT_STATUS) { - reg = CPLD_SFP_PORT_STATUS_REG; - I2C_READ_BYTE_DATA(reg_val, &data->access_lock, client, reg); - if (reg_val < 0) - return -1; - return sprintf(buf, "0x%02x\n", reg_val); - } - return -1; -} - -/* get sfp port config register value */ -static ssize_t read_sfp_port_config(struct device *dev, - struct device_attribute *da, - char *buf) -{ - struct sensor_device_attribute *attr = to_sensor_dev_attr(da); - struct i2c_client *client = to_i2c_client(dev); - struct cpld_data *data = i2c_get_clientdata(client); - u8 reg; - int reg_val; - - if (attr->index == CPLD_SFP_PORT_CONFIG) { - reg = CPLD_SFP_PORT_CONFIG_REG; - I2C_READ_BYTE_DATA(reg_val, &data->access_lock, client, reg); - if (reg_val < 0) - return -1; - return sprintf(buf, "0x%02x\n", reg_val); - } - return -1; -} - -/* set value to sfp port config register */ -static ssize_t write_sfp_port_config(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 cpld_data *data = i2c_get_clientdata(client); - u8 reg, reg_val; - int ret; - - if (kstrtou8(buf, 0, ®_val) < 0) - return -EINVAL; - - if (attr->index == CPLD_SFP_PORT_CONFIG) { - reg = CPLD_SFP_PORT_CONFIG_REG; - I2C_WRITE_BYTE_DATA(ret, &data->access_lock, - client, reg, reg_val); - } - return count; -} - -/* get 10g mux config register value */ -static ssize_t read_10gmux_config(struct device *dev, - struct device_attribute *da, - char *buf) -{ - struct sensor_device_attribute *attr = to_sensor_dev_attr(da); - struct i2c_client *client = to_i2c_client(dev); - struct cpld_data *data = i2c_get_clientdata(client); - u8 reg; - int reg_val; - - if (attr->index == CPLD_10GMUX_CONFIG) { - reg = CPLD_10GMUX_CONFIG_REG; - I2C_READ_BYTE_DATA(reg_val, &data->access_lock, client, reg); - if (reg_val < 0) - return -1; - return sprintf(buf, "0x%02x\n", reg_val); - } - return -1; -} - -/* set value to 10g mux config register */ -static ssize_t write_10gmux_config(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 cpld_data *data = i2c_get_clientdata(client); - u8 reg, reg_val; - int ret; - - if (kstrtou8(buf, 0, ®_val) < 0) - return -EINVAL; - - if (attr->index == CPLD_10GMUX_CONFIG) { - reg = CPLD_10GMUX_CONFIG_REG; - I2C_WRITE_BYTE_DATA(ret, &data->access_lock, - client, reg, reg_val); - } - return count; -} - -/* get bmc status register value */ -static ssize_t read_bmc_status(struct device *dev, - struct device_attribute *da, - char *buf) -{ - struct sensor_device_attribute *attr = to_sensor_dev_attr(da); - struct i2c_client *client = to_i2c_client(dev); - struct cpld_data *data = i2c_get_clientdata(client); - u8 reg; - int reg_val; - - if (attr->index == CPLD_BMC_STATUS) { - reg = CPLD_BMC_STATUS_REG; - I2C_READ_BYTE_DATA(reg_val, &data->access_lock, client, reg); - if (reg_val < 0) - return -1; - return sprintf(buf, "0x%02x\n", reg_val); - } - return -1; -} - -/* get bmc watchdog register value */ -static ssize_t read_bmc_watchdog(struct device *dev, - struct device_attribute *da, - char *buf) -{ - struct sensor_device_attribute *attr = to_sensor_dev_attr(da); - struct i2c_client *client = to_i2c_client(dev); - struct cpld_data *data = i2c_get_clientdata(client); - u8 reg; - int reg_val; - - if (attr->index == CPLD_BMC_WATCHDOG) { - reg = CPLD_BMC_WATCHDOG_REG; - I2C_READ_BYTE_DATA(reg_val, &data->access_lock, client, reg); - if (reg_val < 0) - return -1; - return sprintf(buf, "0x%02x\n", reg_val); - } - return -1; -} - -/* set value to bmc watchdog register */ -static ssize_t write_bmc_watchdog(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 cpld_data *data = i2c_get_clientdata(client); - u8 reg, reg_val; - int ret; - - if (kstrtou8(buf, 0, ®_val) < 0) - return -EINVAL; - - if (attr->index == CPLD_BMC_WATCHDOG) { - reg = CPLD_BMC_WATCHDOG_REG; - I2C_WRITE_BYTE_DATA(ret, &data->access_lock, - client, reg, reg_val); - } - return count; -} - -/* get usb status register value */ -static ssize_t read_usb_status(struct device *dev, - struct device_attribute *da, - char *buf) -{ - struct sensor_device_attribute *attr = to_sensor_dev_attr(da); - struct i2c_client *client = to_i2c_client(dev); - struct cpld_data *data = i2c_get_clientdata(client); - u8 reg; - int reg_val; - - if (attr->index == CPLD_USB_STATUS) { - reg = CPLD_USB_STATUS_REG; - I2C_READ_BYTE_DATA(reg_val, &data->access_lock, client, reg); - if (reg_val < 0) - return -1; - return sprintf(buf, "0x%02x\n", reg_val); - } - return -1; -} - -/* add valid cpld client to list */ -static void ingrasys_i2c_cpld_add_client(struct i2c_client *client) -{ - struct cpld_client_node *node = NULL; - - node = kzalloc(sizeof(struct cpld_client_node), GFP_KERNEL); - if (!node) { - dev_info(&client->dev, - "Can't allocate cpld_client_node for index %d\n", - client->addr); - return; - } - - node->client = client; - - mutex_lock(&list_lock); - list_add(&node->list, &cpld_client_list); - mutex_unlock(&list_lock); -} - -/* remove exist cpld client in list */ -static void ingrasys_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); -} - -/* cpld drvier probe */ -static int ingrasys_i2c_cpld_probe(struct i2c_client *client, - const struct i2c_device_id *dev_id) -{ - int status; - struct cpld_data *data = NULL; - int ret = -EPERM; - int err; - int idx; - - data = kzalloc(sizeof(struct cpld_data), GFP_KERNEL); - if (!data) - return -ENOMEM; - - /* init cpld data for client */ - i2c_set_clientdata(client, data); - mutex_init(&data->access_lock); - - if (!i2c_check_functionality(client->adapter, - I2C_FUNC_SMBUS_BYTE_DATA)) { - dev_info(&client->dev, - "i2c_check_functionality failed (0x%x)\n", - client->addr); - status = -EIO; - goto exit; - } - - /* get cpld id from device */ - ret = i2c_smbus_read_byte_data(client, CPLD_ID_REG); - - if (ret < 0) { - dev_info(&client->dev, - "fail to get cpld id (0x%x) at addr (0x%x)\n", - CPLD_ID_REG, client->addr); - status = -EIO; - goto exit; - } - - CPLD_ID_ID_GET(ret, idx); - - if (INVALID(idx, cpld1, cpld5)) { - dev_info(&client->dev, - "cpld id %d(device) not valid\n", idx); - //status = -EPERM; - //goto exit; - } - -#if 0 - /* change client name for each cpld with index */ - snprintf(client->name, sizeof(client->name), "%s_%d", client->name, - data->index); -#endif - - data->index = dev_id->driver_data; - - /* register sysfs hooks for different cpld group */ - dev_info(&client->dev, "probe cpld with index %d\n", data->index); - switch (data->index) { - case cpld1: - status = sysfs_create_group(&client->dev.kobj, - &s9230_64x_cpld1_group); - break; - case cpld2: - status = sysfs_create_group(&client->dev.kobj, - &s9230_64x_cpld2_group); - break; - case cpld3: - case cpld4: - case cpld5: - status = sysfs_create_group(&client->dev.kobj, - &s9230_64x_cpld345_group); - break; - default: - status = -EINVAL; - } - - if (status) - goto exit; - - dev_info(&client->dev, "chip found\n"); - - /* add probe chip to client list */ - ingrasys_i2c_cpld_add_client(client); - - return 0; -exit: - sysfs_remove_group(&client->dev.kobj, &s9230_64x_cpld345_group); - return status; -} - -/* cpld drvier remove */ -static int ingrasys_i2c_cpld_remove(struct i2c_client *client) -{ - struct cpld_data *data = i2c_get_clientdata(client); - - switch (data->index) { - case cpld1: - sysfs_remove_group(&client->dev.kobj, &s9230_64x_cpld1_group); - break; - case cpld2: - sysfs_remove_group(&client->dev.kobj, &s9230_64x_cpld2_group); - break; - case cpld3: - case cpld4: - case cpld5: - sysfs_remove_group(&client->dev.kobj, - &s9230_64x_cpld345_group); - break; - } - - ingrasys_i2c_cpld_remove_client(client); - return 0; -} - -MODULE_DEVICE_TABLE(i2c, ingrasys_i2c_cpld_id); - -static struct i2c_driver ingrasys_i2c_cpld_driver = { - .class = I2C_CLASS_HWMON, - .driver = { - .name = "ingrasys_i2c_cpld", - }, - .probe = ingrasys_i2c_cpld_probe, - .remove = ingrasys_i2c_cpld_remove, - .id_table = ingrasys_i2c_cpld_id, - .address_list = cpld_i2c_addr, -}; - -/* provid cpld register read */ -/* cpld_idx indicate the index of cpld device */ -int ingrasys_i2c_cpld_read(u8 cpld_idx, - u8 reg) -{ - struct list_head *list_node = NULL; - struct cpld_client_node *cpld_node = NULL; - int ret = -EPERM; - struct cpld_data *data; - - list_for_each(list_node, &cpld_client_list) { - cpld_node = list_entry(list_node, - struct cpld_client_node, list); - data = i2c_get_clientdata(cpld_node->client); - if (data->index == cpld_idx) { - DEBUG_PRINT("cpld_idx=%d, read reg 0x%02x", - cpld_idx, reg); - I2C_READ_BYTE_DATA(ret, &data->access_lock, - cpld_node->client, reg); - DEBUG_PRINT("cpld_idx=%d, read reg 0x%02x = 0x%02x", - cpld_idx, reg, ret); - break; - } - } - - return ret; -} -EXPORT_SYMBOL(ingrasys_i2c_cpld_read); - -/* provid cpld register write */ -/* cpld_idx indicate the index of cpld device */ -int ingrasys_i2c_cpld_write(u8 cpld_idx, - u8 reg, - u8 value) -{ - struct list_head *list_node = NULL; - struct cpld_client_node *cpld_node = NULL; - int ret = -EIO; - struct cpld_data *data; - - list_for_each(list_node, &cpld_client_list) { - cpld_node = list_entry(list_node, - struct cpld_client_node, list); - data = i2c_get_clientdata(cpld_node->client); - - if (data->index == cpld_idx) { - I2C_WRITE_BYTE_DATA(ret, &data->access_lock, - cpld_node->client, - reg, value); - DEBUG_PRINT("cpld_idx=%d, write reg 0x%02x val 0x%02x, ret=%d", - cpld_idx, reg, value, ret); - break; - } - } - - return ret; -} -EXPORT_SYMBOL(ingrasys_i2c_cpld_write); - -/* provid qsfp port status register read */ -/* port_num indicate the front panel qsfp port number */ -int ingrasys_i2c_cpld_get_qsfp_port_status_val(u8 port_num) -{ - u8 cpld_idx, cpld_port, reg; - int reg_val; - - if (INVALID(port_num, QSFP_MIN_PORT_NUM, QSFP_MAX_PORT_NUM)) { - DEBUG_PRINT("invalid input value %d", port_num); - return -1; - } - QSFP_TO_CPLD_IDX(port_num, cpld_idx, cpld_port); - reg = QSFP_PORT_STATUS_REG(cpld_port); - DEBUG_PRINT("port_num=%d, cpld_idx=%d, cpld_port=%d, reg=0x%x", - port_num, cpld_idx, cpld_port, reg); - reg_val = ingrasys_i2c_cpld_read(cpld_idx, reg); - return reg_val; -} -EXPORT_SYMBOL(ingrasys_i2c_cpld_get_qsfp_port_status_val); - -/* provid qsfp port config register read */ -/* port_num indicate the front panel qsfp port number */ -int ingrasys_i2c_cpld_get_qsfp_port_config_val(u8 port_num) -{ - u8 cpld_idx, cpld_port, reg; - int reg_val; - - if (INVALID(port_num, QSFP_MIN_PORT_NUM, QSFP_MAX_PORT_NUM)) { - DEBUG_PRINT("invalid input value %d", port_num); - return -1; - } - QSFP_TO_CPLD_IDX(port_num, cpld_idx, cpld_port); - reg = QSFP_PORT_CONFIG_REG(cpld_port); - DEBUG_PRINT("port_num=%d, cpld_idx=%d, cpld_port=%d, reg=0x%x", - port_num, cpld_idx, cpld_port, reg); - reg_val = ingrasys_i2c_cpld_read(cpld_idx, reg); - return reg_val; -} -EXPORT_SYMBOL(ingrasys_i2c_cpld_get_qsfp_port_config_val); - -/* provid qsfp port config register write */ -/* port_num indicate the front panel qsfp port number */ -int ingrasys_i2c_cpld_set_qsfp_port_config_val(u8 port_num, - u8 reg_val) -{ - u8 cpld_idx, cpld_port, reg, ret; - - if (INVALID(port_num, QSFP_MIN_PORT_NUM, QSFP_MAX_PORT_NUM)) { - DEBUG_PRINT("invalid input value %d", port_num); - return -1; - } - QSFP_TO_CPLD_IDX(port_num, cpld_idx, cpld_port); - reg = QSFP_PORT_CONFIG_REG(cpld_port); - DEBUG_PRINT("port_num=%d, cpld_idx=%d, cpld_port=%d, reg=0x%x", - port_num, cpld_idx, cpld_port, reg); - ret = ingrasys_i2c_cpld_write(cpld_idx, reg, reg_val); - return ret; -} -EXPORT_SYMBOL(ingrasys_i2c_cpld_set_qsfp_port_config_val); - -/* provid sfp port status register read */ -/* port_num indicate the front panel qsfp port number */ -int ingrasys_i2c_cpld_get_sfp_port_status_val(u8 port_num) -{ - u8 cpld_idx, reg; - int reg_val; - - if (INVALID(port_num, SFP_MIN_PORT_NUM, SFP_MAX_PORT_NUM)) { - DEBUG_PRINT("invalid input value %d", port_num); - return -1; - } - SFP_TO_CPLD_IDX(port_num, cpld_idx); - reg = CPLD_SFP_PORT_STATUS_REG; - DEBUG_PRINT("port_num=%d, cpld_idx=%d, reg=0x%x", - port_num, cpld_idx, reg); - reg_val = ingrasys_i2c_cpld_read(cpld_idx, reg); - return reg_val; -} -EXPORT_SYMBOL(ingrasys_i2c_cpld_get_sfp_port_status_val); - -/* provid qsfp port config register read */ -/* port_num indicate the front panel qsfp port number */ -int ingrasys_i2c_cpld_get_sfp_port_config_val(u8 port_num) -{ - u8 cpld_idx, reg; - int reg_val; - - if (INVALID(port_num, SFP_MIN_PORT_NUM, SFP_MAX_PORT_NUM)) { - DEBUG_PRINT("invalid input value %d", port_num); - return -1; - } - SFP_TO_CPLD_IDX(port_num, cpld_idx); - reg = CPLD_SFP_PORT_CONFIG_REG; - DEBUG_PRINT("port_num=%d, cpld_idx=%d, reg=0x%x", - port_num, cpld_idx, reg); - reg_val = ingrasys_i2c_cpld_read(cpld_idx, reg); - return reg_val; -} -EXPORT_SYMBOL(ingrasys_i2c_cpld_get_sfp_port_config_val); - -/* provid qsfp port config register write */ -/* port_num indicate the front panel qsfp port number */ -int ingrasys_i2c_cpld_set_sfp_port_config_val(u8 port_num, - u8 reg_val) -{ - u8 cpld_idx, reg, ret; - - if (INVALID(port_num, SFP_MIN_PORT_NUM, SFP_MAX_PORT_NUM)) { - DEBUG_PRINT("invalid input value %d", port_num); - return -1; - } - SFP_TO_CPLD_IDX(port_num, cpld_idx); - reg = CPLD_SFP_PORT_CONFIG_REG; - DEBUG_PRINT("port_num=%d, cpld_idx=%d, reg=0x%x", - port_num, cpld_idx, reg); - ret = ingrasys_i2c_cpld_write(cpld_idx, reg, reg_val); - return ret; -} -EXPORT_SYMBOL(ingrasys_i2c_cpld_set_sfp_port_config_val); - -static int __init ingrasys_i2c_cpld_init(void) -{ - mutex_init(&list_lock); - return i2c_add_driver(&ingrasys_i2c_cpld_driver); -} - -static void __exit ingrasys_i2c_cpld_exit(void) -{ - i2c_del_driver(&ingrasys_i2c_cpld_driver); -} - -MODULE_AUTHOR("Leo Lin "); -MODULE_DESCRIPTION("ingrasys_i2c_cpld driver"); -MODULE_LICENSE("GPL"); - -module_init(ingrasys_i2c_cpld_init); -module_exit(ingrasys_i2c_cpld_exit); - diff --git a/packages/platforms/ingrasys/x86-64/s9230-64x/modules/builds/ingrasys_s9230_64x_i2c_cpld.h b/packages/platforms/ingrasys/x86-64/s9230-64x/modules/builds/ingrasys_s9230_64x_i2c_cpld.h deleted file mode 100644 index e0e53174d..000000000 --- a/packages/platforms/ingrasys/x86-64/s9230-64x/modules/builds/ingrasys_s9230_64x_i2c_cpld.h +++ /dev/null @@ -1,223 +0,0 @@ -/* header file for i2c cpld driver of ingrasys_s9230_64x - * - * Copyright (C) 2017 Ingrasys Technology Corporation. - * Leo Lin - * - * 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. - */ - -#ifndef INGRASYS_S9230_64X_I2C_CPLD_H -#define INGRASYS_S9230_64X_I2C_CPLD_H - -/* CPLD device index value */ -enum cpld_id { - cpld1, - cpld2, - cpld3, - cpld4, - cpld5 -}; - -/* port number on CPLD */ -#define CPLD_1_PORT_NUM 12 -#define CPLD_2_PORT_NUM 13 - -/* QSFP port number */ -#define QSFP_MAX_PORT_NUM 64 -#define QSFP_MIN_PORT_NUM 1 - -/* SFP+ port number */ -#define SFP_MAX_PORT_NUM 2 -#define SFP_MIN_PORT_NUM 1 - - -/* CPLD registers */ -#define CPLD_BOARD_TYPE_REG 0x0 -#define CPLD_EXT_BOARD_TYPE_REG 0x7 -#define CPLD_VERSION_REG 0x1 -#define CPLD_ID_REG 0x2 -#define CPLD_QSFP_PORT_STATUS_BASE_REG 0x20 -#define CPLD_QSFP_PORT_CONFIG_BASE_REG 0x30 -#define CPLD_QSFP_PORT_INTERRUPT_REG 0x40 -#define CPLD_SFP_PORT_STATUS_REG 0x2F -#define CPLD_SFP_PORT_CONFIG_REG 0x3F -#define CPLD_QSFP_PORT_INTERRUPT_REG 0x40 -#define CPLD_10GMUX_CONFIG_REG 0x41 -#define CPLD_BMC_STATUS_REG 0x42 -#define CPLD_BMC_WATCHDOG_REG 0x43 -#define CPLD_USB_STATUS_REG 0x44 -#define CPLD_REST_CONTROL_REG 0x4A - - -/* bit definition for register value */ -enum CPLD_QSFP_PORT_STATUS_BITS { - CPLD_QSFP_PORT_STATUS_INT_BIT, - CPLD_QSFP_PORT_STATUS_ABS_BIT, -}; -enum CPLD_QSFP_PORT_CONFIG_BITS { - CPLD_QSFP_PORT_CONFIG_RESET_BIT, - CPLD_QSFP_PORT_CONFIG_RESERVE_BIT, - CPLD_QSFP_PORT_CONFIG_LPMODE_BIT, -}; -enum CPLD_SFP_PORT_STATUS_BITS { - CPLD_SFP_PORT_STATUS_PRESENT_BIT, - CPLD_SFP_PORT_STATUS_TXFAULT_BIT, - CPLD_SFP_PORT_STATUS_RXLOS_BIT, -}; -enum CPLD_SFP_PORT_CONFIG_BITS { - CPLD_SFP_PORT_CONFIG_TXDIS_BIT, - CPLD_SFP_PORT_CONFIG_RS_BIT, - CPLD_SFP_PORT_CONFIG_TS_BIT, -}; -enum CPLD_10GMUX_CONFIG_BITS { - CPLD_10GMUX_CONFIG_ENSMB_BIT, - CPLD_10GMUX_CONFIG_ENINPUT_BIT, - CPLD_10GMUX_CONFIG_SEL1_BIT, - CPLD_10GMUX_CONFIG_SEL0_BIT, -}; -enum CPLD_BMC_WATCHDOG_BITS { - CPLD_10GMUX_CONFIG_ENTIMER_BIT, - CPLD_10GMUX_CONFIG_TIMEOUT_BIT, -}; -enum CPLD_RESET_CONTROL_BITS { - CPLD_RESET_CONTROL_SWRST_BIT, - CPLD_RESET_CONTROL_CP2104RST_BIT, - CPLD_RESET_CONTROL_82P33814RST_BIT, - CPLD_RESET_CONTROL_BMCRST_BIT, -}; - -/* bit field structure for register value */ -struct cpld_reg_board_type_t { - u8 build_rev:2; - u8 hw_rev:2; - u8 board_id:4; -}; - -struct cpld_reg_version_t { - u8 revision:6; - u8 release:1; - u8 reserve:1; -}; - -struct cpld_reg_id_t { - u8 id:3; - u8 release:5; -}; - -/* common manipulation */ -#define INVALID(i, min, max) ((i < min) || (i > max) ? 1u : 0u) -#define READ_BIT(val, bit) ((0u == (val & (1<bf_name) -#define READ_BF_1(bf_struct, val, bf_name, bf_value) \ - bf_struct bf; \ - bf.data = val; \ - bf_value = bf.bf_name -#define BOARD_TYPE_BUILD_REV_GET(val, res) \ - READ_BF(cpld_reg_board_type_t, val, build_rev, res) -#define BOARD_TYPE_HW_REV_GET(val, res) \ - READ_BF(cpld_reg_board_type_t, val, hw_rev, res) -#define BOARD_TYPE_BOARD_ID_GET(val, res) \ - READ_BF(cpld_reg_board_type_t, val, board_id, res) -#define CPLD_VERSION_REV_GET(val, res) \ - READ_BF(cpld_reg_version_t, val, revision, res) -#define CPLD_VERSION_REL_GET(val, res) \ - READ_BF(cpld_reg_version_t, val, release, res) -#define CPLD_ID_ID_GET(val, res) \ - READ_BF(cpld_reg_id_t, val, id, res) -#define CPLD_ID_REL_GET(val, res) \ - READ_BF(cpld_reg_id_t, val, release, res) -/* QSFP/SFP registers manipulation */ -#define QSFP_TO_CPLD_IDX(qsfp_port, cpld_index, cpld_port) \ -{ \ - if (QSFP_MIN_PORT_NUM <= qsfp_port && qsfp_port <= CPLD_1_PORT_NUM) { \ - cpld_index = cpld1; \ - cpld_port = qsfp_port - 1; \ - } else if (CPLD_1_PORT_NUM < qsfp_port \ - && qsfp_port <= QSFP_MAX_PORT_NUM) { \ - cpld_index = cpld2 + (qsfp_port - 1 - CPLD_1_PORT_NUM) \ - / CPLD_2_PORT_NUM; \ - cpld_port = (qsfp_port - 1 - CPLD_1_PORT_NUM) % \ - CPLD_2_PORT_NUM; \ - } else { \ - cpld_index = 0; \ - cpld_port = 0; \ - } \ -} -#define SFP_TO_CPLD_IDX(sfp_port, cpld_index) \ - (cpld_index = sfp_port - SFP_MIN_PORT_NUM) -#define QSFP_PORT_STATUS_REG(cpld_port) \ - (CPLD_QSFP_PORT_STATUS_BASE_REG + cpld_port) -#define QSFP_PORT_CONFIG_REG(cpld_port) \ - (CPLD_QSFP_PORT_CONFIG_BASE_REG + cpld_port) -#define QSFP_PORT_INT_BIT_GET(port_status_value) \ - READ_BIT(port_status_value, CPLD_QSFP_PORT_STATUS_INT_BIT) -#define QSFP_PORT_ABS_BIT_GET(port_status_value) \ - READ_BIT(port_status_value, CPLD_QSFP_PORT_STATUS_ABS_BIT) -#define QSFP_PORT_RESET_BIT_GET(port_config_value) \ - READ_BIT(port_config_value, CPLD_QSFP_PORT_CONFIG_RESET_BIT) -#define QSFP_PORT_LPMODE_BIT_GET(port_config_value) \ - READ_BIT(port_config_value, CPLD_QSFP_PORT_CONFIG_LPMODE_BIT) -#define QSFP_PORT_RESET_BIT_SET(port_config_value) \ - SET_BIT(port_config_value, CPLD_QSFP_PORT_CONFIG_RESET_BIT) -#define QSFP_PORT_RESET_BIT_CLEAR(port_config_value) \ - CLEAR_BIT(port_config_value, CPLD_QSFP_PORT_CONFIG_RESET_BIT) -#define QSFP_PORT_LPMODE_BIT_SET(port_config_value) \ - SET_BIT(port_config_value, CPLD_QSFP_PORT_CONFIG_LPMODE_BIT) -#define QSFP_PORT_LPMODE_BIT_CLEAR(port_config_value) \ - CLEAR_BIT(port_config_value, CPLD_QSFP_PORT_CONFIG_LPMODE_BIT) -#define SFP_PORT_PRESENT_BIT_GET(port_status_value) \ - READ_BIT(port_status_value, CPLD_SFP_PORT_STATUS_PRESENT_BIT) - -#define SFP_PORT_TXFAULT_BIT_GET(port_status_value) \ - READ_BIT(port_status_value, CPLD_SFP_PORT_STATUS_TXFAULT_BIT) -#define SFP_PORT_RXLOS_BIT_GET(port_status_value) \ - READ_BIT(port_status_value, CPLD_SFP_PORT_STATUS_RXLOS_BIT) -#define SFP_PORT_TXDIS_BIT_GET(port_status_value) \ - READ_BIT(port_status_value, CPLD_SFP_PORT_CONFIG_TXDIS_BIT) -#define SFP_PORT_RS_BIT_GET(port_config_value) \ - READ_BIT(port_config_value, CPLD_SFP_PORT_CONFIG_RS_BIT) -#define SFP_PORT_TS_BIT_GET(port_config_value) \ - READ_BIT(port_config_value, CPLD_SFP_PORT_CONFIG_TS_BIT) -#define SFP_PORT_TXDIS_BIT_SET(port_config_value) \ - SET_BIT(port_config_value, CPLD_SFP_PORT_CONFIG_TXDIS_BIT) -#define SFP_PORT_TXDIS_BIT_CLEAR(port_config_value) \ - CLEAR_BIT(port_config_value, CPLD_SFP_PORT_CONFIG_TXDIS_BIT) -#define SFP_PORT_RS_BIT_SET(port_config_value) \ - SET_BIT(port_config_value, CPLD_SFP_PORT_CONFIG_RS_BIT) -#define SFP_PORT_RS_BIT_CLEAR(port_config_value) \ - CLEAR_BIT(port_config_value, CPLD_SFP_PORT_CONFIG_RS_BIT) -#define SFP_PORT_TS_BIT_SET(port_config_value) \ - SET_BIT(port_config_value, CPLD_SFP_PORT_CONFIG_TS_BIT) -#define SFP_PORT_TS_BIT_CLEAR(port_config_value) \ - CLEAR_BIT(port_config_value, CPLD_SFP_PORT_CONFIG_TS_BIT) - -/* CPLD access functions */ -extern int ingrasys_i2c_cpld_get_qsfp_port_status_val(u8 port_num); -extern int ingrasys_i2c_cpld_get_qsfp_port_config_val(u8 port_num); -extern int ingrasys_i2c_cpld_set_qsfp_port_config_val(u8 port_num, u8 reg_val); -extern int ingrasys_i2c_cpld_get_sfp_port_status_val(u8 port_num); -extern int ingrasys_i2c_cpld_get_sfp_port_config_val(u8 port_num); -extern int ingrasys_i2c_cpld_set_sfp_port_config_val(u8 port_num, u8 reg_val); -extern u8 fp_port_to_phy_port(u8 fp_port); -#endif - diff --git a/packages/platforms/ingrasys/x86-64/s9230-64x/modules/builds/ingrasys_s9230_64x_platform.h b/packages/platforms/ingrasys/x86-64/s9230-64x/modules/builds/ingrasys_s9230_64x_platform.h deleted file mode 100644 index a14853fda..000000000 --- a/packages/platforms/ingrasys/x86-64/s9230-64x/modules/builds/ingrasys_s9230_64x_platform.h +++ /dev/null @@ -1,148 +0,0 @@ -#ifndef _S9230_64X_PLATFORM_H -#define _S9230_64X_PLATFORM_H - -#include - -// remove debug before release -#define DEBUG - -enum bus_order { - I2C_BUS_MAIN, - MUX_9548_0_CH0, - MUX_9548_0_CH1, - MUX_9548_0_CH2, - MUX_9548_0_CH3, - MUX_9548_0_CH4, - MUX_9548_0_CH5, - MUX_9548_0_CH6, - MUX_9548_0_CH7, - MUX_9548_1_CH0, - MUX_9548_1_CH1, - MUX_9548_1_CH2, - MUX_9548_1_CH3, - MUX_9548_1_CH4, - MUX_9548_1_CH5, - MUX_9548_1_CH6, - MUX_9548_1_CH7, - MUX_9546_0_CH0, - MUX_9546_0_CH1, - MUX_9546_0_CH2, - MUX_9546_0_CH3, - MUX_9546_1_CH0, - MUX_9546_1_CH1, - MUX_9546_1_CH2, - MUX_9546_1_CH3, - MUX_9548_2_CH0, - MUX_9548_2_CH1, - MUX_9548_2_CH2, - MUX_9548_2_CH3, - MUX_9548_2_CH4, - MUX_9548_2_CH5, - MUX_9548_2_CH6, - MUX_9548_2_CH7, - MUX_9548_3_CH0, - MUX_9548_3_CH1, - MUX_9548_3_CH2, - MUX_9548_3_CH3, - MUX_9548_3_CH4, - MUX_9548_3_CH5, - MUX_9548_3_CH6, - MUX_9548_3_CH7, - MUX_9548_4_CH0, - MUX_9548_4_CH1, - MUX_9548_4_CH2, - MUX_9548_4_CH3, - MUX_9548_4_CH4, - MUX_9548_4_CH5, - MUX_9548_4_CH6, - MUX_9548_4_CH7, - MUX_9548_5_CH0, - MUX_9548_5_CH1, - MUX_9548_5_CH2, - MUX_9548_5_CH3, - MUX_9548_5_CH4, - MUX_9548_5_CH5, - MUX_9548_5_CH6, - MUX_9548_5_CH7, - MUX_9548_6_CH0, - MUX_9548_6_CH1, - MUX_9548_6_CH2, - MUX_9548_6_CH3, - MUX_9548_6_CH4, - MUX_9548_6_CH5, - MUX_9548_6_CH6, - MUX_9548_6_CH7, - MUX_9548_7_CH0, - MUX_9548_7_CH1, - MUX_9548_7_CH2, - MUX_9548_7_CH3, - MUX_9548_7_CH4, - MUX_9548_7_CH5, - MUX_9548_7_CH6, - MUX_9548_7_CH7, - MUX_9548_8_CH0, - MUX_9548_8_CH1, - MUX_9548_8_CH2, - MUX_9548_8_CH3, - MUX_9548_8_CH4, - MUX_9548_8_CH5, - MUX_9548_8_CH6, - MUX_9548_8_CH7, - MUX_9548_9_CH0, - MUX_9548_9_CH1, - MUX_9548_9_CH2, - MUX_9548_9_CH3, - MUX_9548_9_CH4, - MUX_9548_9_CH5, - MUX_9548_9_CH6, - MUX_9548_9_CH7, - MUX_9548_10_CH0, - MUX_9548_10_CH1, - MUX_9548_10_CH2, - MUX_9548_10_CH3, - MUX_9548_10_CH4, - MUX_9548_10_CH5, - MUX_9548_10_CH6, - MUX_9548_10_CH7, -}; - -#define I2C_ADDR_MUX_9555_0 (0x20) -#define I2C_ADDR_MUX_9555_1 (0x24) -#define I2C_ADDR_MUX_9555_2 (0x25) -#define I2C_ADDR_MUX_9555_3 (0x26) -#define I2C_ADDR_MUX_9539_0 (0x76) -#define I2C_ADDR_MUX_9539_1 (0x76) -#define I2C_BUS_FAN_STATUS (I2C_BUS_MAIN) -#define I2C_BUS_SYS_LED (MUX_9548_1_CH1) - -#define NUM_OF_I2C_MUX (11) -#define NUM_OF_CPLD (5) -#define NUM_OF_QSFP_PORT (64) -#define NUM_OF_SFP_PORT (2) -#define QSFP_EEPROM_I2C_ADDR (0x50) - -enum gpio_reg { - REG_PORT0_IN, - REG_PORT1_IN, - REG_PORT0_OUT, - REG_PORT1_OUT, - REG_PORT0_POL, - REG_PORT1_POL, - REG_PORT0_DIR, - REG_PORT1_DIR, -}; - -struct ing_i2c_board_info { - int ch; - int size; - struct i2c_board_info *board_info; -}; - -struct i2c_init_data { - __u16 ch; - __u16 addr; - __u8 reg; - __u8 value; -}; - -#endif diff --git a/packages/platforms/ingrasys/x86-64/s9230-64x/modules/builds/ingrasys_s9230_64x_psu.c b/packages/platforms/ingrasys/x86-64/s9230-64x/modules/builds/ingrasys_s9230_64x_psu.c deleted file mode 100644 index 452fd3c22..000000000 --- a/packages/platforms/ingrasys/x86-64/s9230-64x/modules/builds/ingrasys_s9230_64x_psu.c +++ /dev/null @@ -1,536 +0,0 @@ -/* - * S9230-64x PSU driver - * - * Copyright (C) 2017 Ingrasys, 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., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#ifndef _S9230_64X_PLATFORM_H -#define _S9230_64X_PLATFORM_H - -#include - -// remove debug before release -#define DEBUG - -enum bus_order { - I2C_BUS_MAIN, - MUX_9548_0_CH0, - MUX_9548_0_CH1, - MUX_9548_0_CH2, - MUX_9548_0_CH3, - MUX_9548_0_CH4, - MUX_9548_0_CH5, - MUX_9548_0_CH6, - MUX_9548_0_CH7, - MUX_9548_1_CH0, - MUX_9548_1_CH1, - MUX_9548_1_CH2, - MUX_9548_1_CH3, - MUX_9548_1_CH4, - MUX_9548_1_CH5, - MUX_9548_1_CH6, - MUX_9548_1_CH7, - MUX_9546_0_CH0, - MUX_9546_0_CH1, - MUX_9546_0_CH2, - MUX_9546_0_CH3, - MUX_9546_1_CH0, - MUX_9546_1_CH1, - MUX_9546_1_CH2, - MUX_9546_1_CH3, - MUX_9548_2_CH0, - MUX_9548_2_CH1, - MUX_9548_2_CH2, - MUX_9548_2_CH3, - MUX_9548_2_CH4, - MUX_9548_2_CH5, - MUX_9548_2_CH6, - MUX_9548_2_CH7, - MUX_9548_3_CH0, - MUX_9548_3_CH1, - MUX_9548_3_CH2, - MUX_9548_3_CH3, - MUX_9548_3_CH4, - MUX_9548_3_CH5, - MUX_9548_3_CH6, - MUX_9548_3_CH7, - MUX_9548_4_CH0, - MUX_9548_4_CH1, - MUX_9548_4_CH2, - MUX_9548_4_CH3, - MUX_9548_4_CH4, - MUX_9548_4_CH5, - MUX_9548_4_CH6, - MUX_9548_4_CH7, - MUX_9548_5_CH0, - MUX_9548_5_CH1, - MUX_9548_5_CH2, - MUX_9548_5_CH3, - MUX_9548_5_CH4, - MUX_9548_5_CH5, - MUX_9548_5_CH6, - MUX_9548_5_CH7, - MUX_9548_6_CH0, - MUX_9548_6_CH1, - MUX_9548_6_CH2, - MUX_9548_6_CH3, - MUX_9548_6_CH4, - MUX_9548_6_CH5, - MUX_9548_6_CH6, - MUX_9548_6_CH7, - MUX_9548_7_CH0, - MUX_9548_7_CH1, - MUX_9548_7_CH2, - MUX_9548_7_CH3, - MUX_9548_7_CH4, - MUX_9548_7_CH5, - MUX_9548_7_CH6, - MUX_9548_7_CH7, - MUX_9548_8_CH0, - MUX_9548_8_CH1, - MUX_9548_8_CH2, - MUX_9548_8_CH3, - MUX_9548_8_CH4, - MUX_9548_8_CH5, - MUX_9548_8_CH6, - MUX_9548_8_CH7, - MUX_9548_9_CH0, - MUX_9548_9_CH1, - MUX_9548_9_CH2, - MUX_9548_9_CH3, - MUX_9548_9_CH4, - MUX_9548_9_CH5, - MUX_9548_9_CH6, - MUX_9548_9_CH7, - MUX_9548_10_CH0, - MUX_9548_10_CH1, - MUX_9548_10_CH2, - MUX_9548_10_CH3, - MUX_9548_10_CH4, - MUX_9548_10_CH5, - MUX_9548_10_CH6, - MUX_9548_10_CH7, -}; - -#define I2C_ADDR_MUX_9555_0 (0x20) -#define I2C_ADDR_MUX_9555_1 (0x24) -#define I2C_ADDR_MUX_9555_2 (0x25) -#define I2C_ADDR_MUX_9555_3 (0x26) -#define I2C_ADDR_MUX_9539_0 (0x76) -#define I2C_ADDR_MUX_9539_1 (0x76) -#define I2C_BUS_FAN_STATUS (I2C_BUS_MAIN) -#define I2C_BUS_SYS_LED (MUX_9548_1_CH1) - -#define NUM_OF_I2C_MUX (11) -#define NUM_OF_CPLD (5) -#define NUM_OF_QSFP_PORT (64) -#define NUM_OF_SFP_PORT (2) -#define QSFP_EEPROM_I2C_ADDR (0x50) - -enum gpio_reg { - REG_PORT0_IN, - REG_PORT1_IN, - REG_PORT0_OUT, - REG_PORT1_OUT, - REG_PORT0_POL, - REG_PORT1_POL, - REG_PORT0_DIR, - REG_PORT1_DIR, -}; - -struct ing_i2c_board_info { - int ch; - int size; - struct i2c_board_info *board_info; -}; - -struct i2c_init_data { - __u16 ch; - __u16 addr; - __u8 reg; - __u8 value; -}; - -#endif - -static ssize_t show_psu_eeprom(struct device *dev, - struct device_attribute *da, - char *buf); -static struct s9230_psu_data *s9230_psu_update_status(struct device *dev); -static struct s9230_psu_data *s9230_psu_update_eeprom(struct device *dev); -static int s9230_psu_read_block(struct i2c_client *client, - u8 command, - u8 *data, - int data_len); - - -#define DRIVER_NAME "psu" - -// Addresses scanned -static const unsigned short normal_i2c[] = { 0x50, I2C_CLIENT_END }; - -/* PSU EEPROM SIZE */ -#define EEPROM_SZ 256 -#define READ_EEPROM 1 -#define NREAD_EEPROM 0 - -static struct i2c_client pca9555_client; - -/* pca9555 gpio pin mapping */ -#define PSU2_PWROK 0 -#define PSU2_PRSNT_L 1 -#define PSU2_PWRON_L 2 -#define PSU1_PWROK 3 -#define PSU1_PRSNT_L 4 -#define PSU1_PWRON_L 5 -#define TMP_75_INT_L 6 - -/* Driver Private Data */ -struct s9230_psu_data { - struct mutex lock; - char valid; /* !=0 if registers are valid */ - unsigned long last_updated; /* In jiffies */ - u8 index; /* PSU index */ - s32 status; /* IO expander value */ - char eeprom[EEPROM_SZ]; /* psu eeprom data */ - char psuABS; /* PSU absent */ - char psuPG; /* PSU power good */ -}; - -enum psu_index -{ - s9230_psu1, - s9230_psu2 -}; - -/* - * display power good attribute - */ -static ssize_t -show_psu_pg(struct device *dev, - struct device_attribute *devattr, - char *buf) -{ - struct s9230_psu_data *data = s9230_psu_update_status(dev); - unsigned int value; - - mutex_lock(&data->lock); - value = data->psuPG; - mutex_unlock(&data->lock); - - return sprintf(buf, "%d\n", value); -} - -/* - * display power absent attribute - */ -static ssize_t -show_psu_abs(struct device *dev, - struct device_attribute *devattr, - char *buf) -{ - struct s9230_psu_data *data = s9230_psu_update_status(dev); - unsigned int value; - - mutex_lock(&data->lock); - value = data->psuABS; - mutex_unlock(&data->lock); - - return sprintf(buf, "%d\n", value); -} - - -/* - * sysfs attributes for psu - */ -static DEVICE_ATTR(psu_pg, S_IRUGO, show_psu_pg, NULL); -static DEVICE_ATTR(psu_abs, S_IRUGO, show_psu_abs, NULL); -static DEVICE_ATTR(psu_eeprom, S_IRUGO, show_psu_eeprom, NULL); - -static struct attribute *s9230_psu_attributes[] = { - &dev_attr_psu_pg.attr, - &dev_attr_psu_abs.attr, - &dev_attr_psu_eeprom.attr, - NULL -}; - -/* - * display psu eeprom content - */ -static ssize_t -show_psu_eeprom(struct device *dev, - struct device_attribute *da, - char *buf) -{ - struct s9230_psu_data *data = s9230_psu_update_eeprom(dev); - - memcpy(buf, (char *)data->eeprom, EEPROM_SZ); - return EEPROM_SZ; -} - -static const struct attribute_group s9230_psu_group = { - .attrs = s9230_psu_attributes, -}; - -/* - * check gpio expander is accessible - */ -static int -pca9555_detect(struct i2c_client *client) -{ - if (i2c_smbus_read_byte_data(client, REG_PORT0_DIR) < 0) { - return -ENODEV; - } - - return 0; -} - -/* - * client address init - */ -static void -i2c_devices_client_address_init(struct i2c_client *client) -{ - pca9555_client = *client; - pca9555_client.addr = 0x25; -} - -static int -s9230_psu_probe(struct i2c_client *client, - const struct i2c_device_id *dev_id) -{ - struct s9230_psu_data *data; - int status, err; - - if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_I2C_BLOCK)) { - status = -EIO; - goto exit; - } - - data = kzalloc(sizeof(struct s9230_psu_data), GFP_KERNEL); - if (!data) { - status = -ENOMEM; - goto exit; - } - memset(data, 0, sizeof(struct s9230_psu_data)); - i2c_set_clientdata(client, data); - data->valid = 0; - data->index = dev_id->driver_data; - mutex_init(&data->lock); - - i2c_devices_client_address_init(client); - - err = pca9555_detect(&pca9555_client); - if (err) { - return err; - } - - dev_info(&client->dev, "chip found\n"); - - /* Register sysfs hooks */ - status = sysfs_create_group(&client->dev.kobj, &s9230_psu_group); - if (status) { - goto exit_free; - } - - return 0; - -exit_remove: - sysfs_remove_group(&client->dev.kobj, &s9230_psu_group); -exit_free: - kfree(data); -exit: - - return status; -} - -static int -s9230_psu_remove(struct i2c_client *client) -{ - struct s9230_psu_data *data = i2c_get_clientdata(client); - - sysfs_remove_group(&client->dev.kobj, &s9230_psu_group); - kfree(data); - - return 0; -} - - -/* - * psu eeprom read utility - */ -static int -s9230_psu_read_block(struct i2c_client *client, - u8 command, - u8 *data, - int data_len) -{ - int i=0, ret=0; - int blk_max = 32; //max block read size - - /* read eeprom, 32 * 8 = 256 bytes */ - for (i=0; i < EEPROM_SZ/blk_max; i++) { - ret = i2c_smbus_read_i2c_block_data(client, (i*blk_max), blk_max, - data + (i*blk_max)); - if (ret < 0) { - return ret; - } - } - return ret; -} - -/* - * update eeprom content - */ -static struct s9230_psu_data -*s9230_psu_update_eeprom(struct device *dev) -{ - struct i2c_client *client = to_i2c_client(dev); - struct s9230_psu_data *data = i2c_get_clientdata(client); - s32 status = 0; - int psu_pwrok = 0; - int psu_prsnt_l = 0; - - mutex_lock(&data->lock); - - if (time_after(jiffies, data->last_updated + 300 * HZ) - || !data->valid) { - - /* Read psu status */ - - status = i2c_smbus_read_word_data(&(pca9555_client), REG_PORT0_IN); - data->status = status; - - /*read psu status from io expander*/ - - if (data->index == s9230_psu1) { - psu_pwrok = PSU1_PWROK; - psu_prsnt_l = PSU1_PRSNT_L; - } else { - psu_pwrok = PSU2_PWROK; - psu_prsnt_l = PSU2_PRSNT_L; - } - data->psuPG = (status >> psu_pwrok) & 0x1; - data->psuABS = (status >> psu_prsnt_l) & 0x1; - - /* Read eeprom */ - if (!data->psuABS) { - //clear local eeprom data - memset(data->eeprom, 0, EEPROM_SZ); - - //read eeprom - status = s9230_psu_read_block(client, 0, data->eeprom, - ARRAY_SIZE(data->eeprom)); - - if (status < 0) { - memset(data->eeprom, 0, EEPROM_SZ); - dev_err(&client->dev, "Read eeprom failed, status=(%d)\n", status); - } else { - data->valid = 1; - } - } else { - memset(data->eeprom, 0, EEPROM_SZ); - } - data->last_updated = jiffies; - } - - mutex_unlock(&data->lock); - - return data; -} - -/* - * update psu status - */ -static struct s9230_psu_data -*s9230_psu_update_status(struct device *dev) -{ - struct i2c_client *client = to_i2c_client(dev); - struct s9230_psu_data *data = i2c_get_clientdata(client); - s32 status = 0; - int psu_pwrok = 0; - int psu_prsnt_l = 0; - - mutex_lock(&data->lock); - - /* Read psu status */ - - status = i2c_smbus_read_word_data(&(pca9555_client), REG_PORT0_IN); - data->status = status; - - /*read psu status from io expander*/ - - if (data->index == s9230_psu1) { - psu_pwrok = PSU1_PWROK; - psu_prsnt_l = PSU1_PRSNT_L; - } else { - psu_pwrok = PSU2_PWROK; - psu_prsnt_l = PSU2_PRSNT_L; - } - data->psuPG = (status >> psu_pwrok) & 0x1; - data->psuABS = (status >> psu_prsnt_l) & 0x1; - - mutex_unlock(&data->lock); - - return data; -} - -static const struct i2c_device_id s9230_psu_id[] = { - { "psu1", s9230_psu1 }, - { "psu2", s9230_psu2 }, - {} -}; - -MODULE_DEVICE_TABLE(i2c, s9230_psu_id); - -static struct i2c_driver s9230_psu_driver = { - .driver = { - .name = DRIVER_NAME, - }, - .probe = s9230_psu_probe, - .remove = s9230_psu_remove, - .id_table = s9230_psu_id, - .address_list = normal_i2c, -}; - -static int __init s9230_psu_init(void) -{ - return i2c_add_driver(&s9230_psu_driver); -} - -static void __exit s9230_psu_exit(void) -{ - i2c_del_driver(&s9230_psu_driver); -} - -module_init(s9230_psu_init); -module_exit(s9230_psu_exit); - -MODULE_AUTHOR("Jason Tsai "); -MODULE_DESCRIPTION("S9230-64X psu driver"); -MODULE_LICENSE("GPL"); diff --git a/packages/platforms/ingrasys/x86-64/s9230-64x/onlp/Makefile b/packages/platforms/ingrasys/x86-64/s9230-64x/onlp/Makefile deleted file mode 100755 index 003238cf6..000000000 --- a/packages/platforms/ingrasys/x86-64/s9230-64x/onlp/Makefile +++ /dev/null @@ -1 +0,0 @@ -include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/ingrasys/x86-64/s9230-64x/onlp/PKG.yml b/packages/platforms/ingrasys/x86-64/s9230-64x/onlp/PKG.yml deleted file mode 100755 index af72636a6..000000000 --- a/packages/platforms/ingrasys/x86-64/s9230-64x/onlp/PKG.yml +++ /dev/null @@ -1 +0,0 @@ -!include $ONL_TEMPLATES/onlp-platform-any.yml PLATFORM=x86-64-ingrasys-s9230-64x ARCH=amd64 TOOLCHAIN=x86_64-linux-gnu diff --git a/packages/platforms/ingrasys/x86-64/s9230-64x/onlp/builds/Makefile b/packages/platforms/ingrasys/x86-64/s9230-64x/onlp/builds/Makefile deleted file mode 100755 index e7437cb23..000000000 --- a/packages/platforms/ingrasys/x86-64/s9230-64x/onlp/builds/Makefile +++ /dev/null @@ -1,2 +0,0 @@ -FILTER=src -include $(ONL)/make/subdirs.mk diff --git a/packages/platforms/ingrasys/x86-64/s9230-64x/onlp/builds/lib/Makefile b/packages/platforms/ingrasys/x86-64/s9230-64x/onlp/builds/lib/Makefile deleted file mode 100755 index adaa35b69..000000000 --- a/packages/platforms/ingrasys/x86-64/s9230-64x/onlp/builds/lib/Makefile +++ /dev/null @@ -1,2 +0,0 @@ -PLATFORM := x86-64-ingrasys-s9230-64x -include $(ONL)/packages/base/any/onlp/builds/platform/libonlp-platform.mk diff --git a/packages/platforms/ingrasys/x86-64/s9230-64x/onlp/builds/onlpdump/Makefile b/packages/platforms/ingrasys/x86-64/s9230-64x/onlp/builds/onlpdump/Makefile deleted file mode 100755 index 0674704ec..000000000 --- a/packages/platforms/ingrasys/x86-64/s9230-64x/onlp/builds/onlpdump/Makefile +++ /dev/null @@ -1,2 +0,0 @@ -PLATFORM := x86-64-ingrasys-s9230-64x -include $(ONL)/packages/base/any/onlp/builds/platform/onlps.mk diff --git a/packages/platforms/ingrasys/x86-64/s9230-64x/onlp/builds/x86_64_ingrasys_s9230_64x/.gitignore b/packages/platforms/ingrasys/x86-64/s9230-64x/onlp/builds/x86_64_ingrasys_s9230_64x/.gitignore deleted file mode 100755 index 760be8d1a..000000000 --- a/packages/platforms/ingrasys/x86-64/s9230-64x/onlp/builds/x86_64_ingrasys_s9230_64x/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -/x86_64_ingrasys_s9230_64x.mk -/doc diff --git a/packages/platforms/ingrasys/x86-64/s9230-64x/onlp/builds/x86_64_ingrasys_s9230_64x/.module b/packages/platforms/ingrasys/x86-64/s9230-64x/onlp/builds/x86_64_ingrasys_s9230_64x/.module deleted file mode 100755 index 07bc03d01..000000000 --- a/packages/platforms/ingrasys/x86-64/s9230-64x/onlp/builds/x86_64_ingrasys_s9230_64x/.module +++ /dev/null @@ -1 +0,0 @@ -name: x86_64_ingrasys_s9230_64x diff --git a/packages/platforms/ingrasys/x86-64/s9230-64x/onlp/builds/x86_64_ingrasys_s9230_64x/Makefile b/packages/platforms/ingrasys/x86-64/s9230-64x/onlp/builds/x86_64_ingrasys_s9230_64x/Makefile deleted file mode 100755 index b75a4beb2..000000000 --- a/packages/platforms/ingrasys/x86-64/s9230-64x/onlp/builds/x86_64_ingrasys_s9230_64x/Makefile +++ /dev/null @@ -1,10 +0,0 @@ -############################################################ -# -# -# -############################################################ -include $(ONL)/make/config.mk - -MODULE := x86_64_ingrasys_s9230_64x -AUTOMODULE := x86_64_ingrasys_s9230_64x -include $(BUILDER)/definemodule.mk diff --git a/packages/platforms/ingrasys/x86-64/s9230-64x/onlp/builds/x86_64_ingrasys_s9230_64x/module/auto/make.mk b/packages/platforms/ingrasys/x86-64/s9230-64x/onlp/builds/x86_64_ingrasys_s9230_64x/module/auto/make.mk deleted file mode 100755 index 2d8d7f9b9..000000000 --- a/packages/platforms/ingrasys/x86-64/s9230-64x/onlp/builds/x86_64_ingrasys_s9230_64x/module/auto/make.mk +++ /dev/null @@ -1,7 +0,0 @@ -# -# x86_64_ingrasys_s9230_64x Autogeneration -# -############################################################################### -x86_64_ingrasys_s9230_64x_AUTO_DEFS := module/auto/x86_64_ingrasys_s9230_64x.yml -x86_64_ingrasys_s9230_64x_AUTO_DIRS := module/inc/x86_64_ingrasys_s9230_64x module/src -include $(BUILDER)/auto.mk diff --git a/packages/platforms/ingrasys/x86-64/s9230-64x/onlp/builds/x86_64_ingrasys_s9230_64x/module/auto/x86_64_ingrasys_s9230_64x.yml b/packages/platforms/ingrasys/x86-64/s9230-64x/onlp/builds/x86_64_ingrasys_s9230_64x/module/auto/x86_64_ingrasys_s9230_64x.yml deleted file mode 100755 index eeb909c64..000000000 --- a/packages/platforms/ingrasys/x86-64/s9230-64x/onlp/builds/x86_64_ingrasys_s9230_64x/module/auto/x86_64_ingrasys_s9230_64x.yml +++ /dev/null @@ -1,47 +0,0 @@ -############################################################################### -# -# X86_64_INGRASYS_S9230_64X Autogeneration Definitions. -# -############################################################################### - -cdefs: &cdefs -- X86_64_INGRASYS_S9230_64X_CONFIG_INCLUDE_LOGGING: - doc: "Include or exclude logging." - default: 1 -- X86_64_INGRASYS_S9230_64X_CONFIG_LOG_OPTIONS_DEFAULT: - doc: "Default enabled log options." - default: AIM_LOG_OPTIONS_DEFAULT -- X86_64_INGRASYS_S9230_64X_CONFIG_LOG_BITS_DEFAULT: - doc: "Default enabled log bits." - default: AIM_LOG_BITS_DEFAULT -- X86_64_INGRASYS_S9230_64X_CONFIG_LOG_CUSTOM_BITS_DEFAULT: - doc: "Default enabled custom log bits." - default: 0 -- X86_64_INGRASYS_S9230_64X_CONFIG_PORTING_STDLIB: - doc: "Default all porting macros to use the C standard libraries." - default: 1 -- X86_64_INGRASYS_S9230_64X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS: - doc: "Include standard library headers for stdlib porting macros." - default: X86_64_INGRASYS_S9230_64X_CONFIG_PORTING_STDLIB -- X86_64_INGRASYS_S9230_64X_CONFIG_INCLUDE_UCLI: - doc: "Include generic uCli support." - default: 0 - - -definitions: - cdefs: - X86_64_INGRASYS_S9230_64X_CONFIG_HEADER: - defs: *cdefs - basename: x86_64_ingrasys_s9230_64x_config - - portingmacro: - X86_64_INGRASYS_S9230_64X: - macros: - - malloc - - free - - memset - - memcpy - - - vsnprintf - - snprintf - - strlen diff --git a/packages/platforms/ingrasys/x86-64/s9230-64x/onlp/builds/x86_64_ingrasys_s9230_64x/module/inc/x86_64_ingrasys_s9230_64x/x86_64_ingrasys_s9230_64x.x b/packages/platforms/ingrasys/x86-64/s9230-64x/onlp/builds/x86_64_ingrasys_s9230_64x/module/inc/x86_64_ingrasys_s9230_64x/x86_64_ingrasys_s9230_64x.x deleted file mode 100755 index e46a5c5c1..000000000 --- a/packages/platforms/ingrasys/x86-64/s9230-64x/onlp/builds/x86_64_ingrasys_s9230_64x/module/inc/x86_64_ingrasys_s9230_64x/x86_64_ingrasys_s9230_64x.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/ingrasys/x86-64/s9230-64x/onlp/builds/x86_64_ingrasys_s9230_64x/module/inc/x86_64_ingrasys_s9230_64x/x86_64_ingrasys_s9230_64x_config.h b/packages/platforms/ingrasys/x86-64/s9230-64x/onlp/builds/x86_64_ingrasys_s9230_64x/module/inc/x86_64_ingrasys_s9230_64x/x86_64_ingrasys_s9230_64x_config.h deleted file mode 100755 index 944dd1cb1..000000000 --- a/packages/platforms/ingrasys/x86-64/s9230-64x/onlp/builds/x86_64_ingrasys_s9230_64x/module/inc/x86_64_ingrasys_s9230_64x/x86_64_ingrasys_s9230_64x_config.h +++ /dev/null @@ -1,152 +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 x86_64_ingrasys_s9230_64x Configuration Header - * - * @addtogroup x86_64_ingrasys_s9230_64x-config - * @{ - * - *****************************************************************************/ -#ifndef __X86_64_INGRASYS_S9230_64X_CONFIG_H__ -#define __X86_64_INGRASYS_S9230_64X_CONFIG_H__ - -#ifdef GLOBAL_INCLUDE_CUSTOM_CONFIG -#include -#endif -#ifdef X86_64_INGRASYS_S9230_64X_INCLUDE_CUSTOM_CONFIG -#include -#endif - -/* */ -#include -/** - * X86_64_INGRASYS_S9230_64X_CONFIG_INCLUDE_LOGGING - * - * Include or exclude logging. */ - - -#ifndef X86_64_INGRASYS_S9230_64X_CONFIG_INCLUDE_LOGGING -#define X86_64_INGRASYS_S9230_64X_CONFIG_INCLUDE_LOGGING 1 -#endif - -/** - * X86_64_INGRASYS_S9230_64X_CONFIG_LOG_OPTIONS_DEFAULT - * - * Default enabled log options. */ - - -#ifndef X86_64_INGRASYS_S9230_64X_CONFIG_LOG_OPTIONS_DEFAULT -#define X86_64_INGRASYS_S9230_64X_CONFIG_LOG_OPTIONS_DEFAULT AIM_LOG_OPTIONS_DEFAULT -#endif - -/** - * X86_64_INGRASYS_S9230_64X_CONFIG_LOG_BITS_DEFAULT - * - * Default enabled log bits. */ - - -#ifndef X86_64_INGRASYS_S9230_64X_CONFIG_LOG_BITS_DEFAULT -#define X86_64_INGRASYS_S9230_64X_CONFIG_LOG_BITS_DEFAULT AIM_LOG_BITS_DEFAULT -#endif - -/** - * X86_64_INGRASYS_S9230_64X_CONFIG_LOG_CUSTOM_BITS_DEFAULT - * - * Default enabled custom log bits. */ - - -#ifndef X86_64_INGRASYS_S9230_64X_CONFIG_LOG_CUSTOM_BITS_DEFAULT -#define X86_64_INGRASYS_S9230_64X_CONFIG_LOG_CUSTOM_BITS_DEFAULT 0 -#endif - -/** - * X86_64_INGRASYS_S9230_64X_CONFIG_PORTING_STDLIB - * - * Default all porting macros to use the C standard libraries. */ - - -#ifndef X86_64_INGRASYS_S9230_64X_CONFIG_PORTING_STDLIB -#define X86_64_INGRASYS_S9230_64X_CONFIG_PORTING_STDLIB 1 -#endif - -/** - * X86_64_INGRASYS_S9230_64X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS - * - * Include standard library headers for stdlib porting macros. */ - - -#ifndef X86_64_INGRASYS_S9230_64X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS -#define X86_64_INGRASYS_S9230_64X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS X86_64_INGRASYS_S9230_64X_CONFIG_PORTING_STDLIB -#endif - -/** - * X86_64_INGRASYS_S9230_64X_CONFIG_INCLUDE_UCLI - * - * Include generic uCli support. */ - - -#ifndef X86_64_INGRASYS_S9230_64X_CONFIG_INCLUDE_UCLI -#define X86_64_INGRASYS_S9230_64X_CONFIG_INCLUDE_UCLI 0 -#endif - - - -/** - * All compile time options can be queried or displayed - */ - -/** Configuration settings structure. */ -typedef struct x86_64_ingrasys_s9230_64x_config_settings_s { - /** name */ - const char* name; - /** value */ - const char* value; -} x86_64_ingrasys_s9230_64x_config_settings_t; - -/** Configuration settings table. */ -/** x86_64_ingrasys_s9230_64x_config_settings table. */ -extern x86_64_ingrasys_s9230_64x_config_settings_t x86_64_ingrasys_s9230_64x_config_settings[]; - -/** - * @brief Lookup a configuration setting. - * @param setting The name of the configuration option to lookup. - */ -const char* x86_64_ingrasys_s9230_64x_config_lookup(const char* setting); - -/** - * @brief Show the compile-time configuration. - * @param pvs The output stream. - */ -int x86_64_ingrasys_s9230_64x_config_show(struct aim_pvs_s* pvs); - -/* */ - -#include "x86_64_ingrasys_s9230_64x_porting.h" - -#endif /* __X86_64_INGRASYS_S9230_64X_CONFIG_H__ */ -/* @} */ diff --git a/packages/platforms/ingrasys/x86-64/s9230-64x/onlp/builds/x86_64_ingrasys_s9230_64x/module/inc/x86_64_ingrasys_s9230_64x/x86_64_ingrasys_s9230_64x_dox.h b/packages/platforms/ingrasys/x86-64/s9230-64x/onlp/builds/x86_64_ingrasys_s9230_64x/module/inc/x86_64_ingrasys_s9230_64x/x86_64_ingrasys_s9230_64x_dox.h deleted file mode 100755 index fa93c32f5..000000000 --- a/packages/platforms/ingrasys/x86-64/s9230-64x/onlp/builds/x86_64_ingrasys_s9230_64x/module/inc/x86_64_ingrasys_s9230_64x/x86_64_ingrasys_s9230_64x_dox.h +++ /dev/null @@ -1,26 +0,0 @@ -/**************************************************************************//** - * - * x86_64_ingrasys_s9230_64x Doxygen Header - * - *****************************************************************************/ -#ifndef __x86_64_ingrasys_s9230_64x_DOX_H__ -#define __x86_64_ingrasys_s9230_64x_DOX_H__ - -/** - * @defgroup x86_64_ingrasys_s9230_64x x86_64_ingrasys_s9230_64x - x86_64_ingrasys_s9230_64x Description - * - -The documentation overview for this module should go here. - - * - * @{ - * - * @defgroup x86_64_ingrasys_s9230_64x-x86_64_ingrasys_s9230_64x Public Interface - * @defgroup x86_64_ingrasys_s9230_64x-config Compile Time Configuration - * @defgroup x86_64_ingrasys_s9230_64x-porting Porting Macros - * - * @} - * - */ - -#endif /* __x86_64_ingrasys_s9230_64x_DOX_H__ */ diff --git a/packages/platforms/ingrasys/x86-64/s9230-64x/onlp/builds/x86_64_ingrasys_s9230_64x/module/inc/x86_64_ingrasys_s9230_64x/x86_64_ingrasys_s9230_64x_porting.h b/packages/platforms/ingrasys/x86-64/s9230-64x/onlp/builds/x86_64_ingrasys_s9230_64x/module/inc/x86_64_ingrasys_s9230_64x/x86_64_ingrasys_s9230_64x_porting.h deleted file mode 100755 index 240f63e37..000000000 --- a/packages/platforms/ingrasys/x86-64/s9230-64x/onlp/builds/x86_64_ingrasys_s9230_64x/module/inc/x86_64_ingrasys_s9230_64x/x86_64_ingrasys_s9230_64x_porting.h +++ /dev/null @@ -1,96 +0,0 @@ -/********************************************************//** - * - * @file - * @brief x86_64_Ingrasys_s9230_64x Porting Macros. - * - * @addtogroup x86_64_Ingrasys_s9230_64x-porting - * @{ - * - ***********************************************************/ -#ifndef __X86_64_INGRASYS_S9230_64X_PORTING_H__ -#define __X86_64_INGRASYS_S9230_64X_PORTING_H__ - -/* */ -#if X86_64_INGRASYS_S9230_64X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS == 1 -#include -#include -#include -#include -#include -#endif - -#ifndef X86_64_INGRASYS_S9230_64X_MALLOC - #if defined(GLOBAL_MALLOC) - #define X86_64_INGRASYS_S9230_64X_MALLOC GLOBAL_MALLOC - #elif X86_64_INGRASYS_S9230_64X_CONFIG_PORTING_STDLIB == 1 - #define X86_64_INGRASYS_S9230_64X_MALLOC malloc - #else - #error The macro X86_64_INGRASYS_S9230_64X_MALLOC is required but cannot be defined. - #endif -#endif - -#ifndef X86_64_INGRASYS_S9230_64X_FREE - #if defined(GLOBAL_FREE) - #define X86_64_INGRASYS_S9230_64X_FREE GLOBAL_FREE - #elif X86_64_INGRASYS_S9230_64X_CONFIG_PORTING_STDLIB == 1 - #define X86_64_INGRASYS_S9230_64X_FREE free - #else - #error The macro X86_64_INGRASYS_S9230_64X_FREE is required but cannot be defined. - #endif -#endif - -#ifndef X86_64_INGRASYS_S9230_64X_MEMSET - #if defined(GLOBAL_MEMSET) - #define X86_64_INGRASYS_S9230_64X_MEMSET GLOBAL_MEMSET - #elif X86_64_INGRASYS_S9230_64X_CONFIG_PORTING_STDLIB == 1 - #define X86_64_INGRASYS_S9230_64X_MEMSET memset - #else - #error The macro X86_64_INGRASYS_S9230_64X_MEMSET is required but cannot be defined. - #endif -#endif - -#ifndef X86_64_INGRASYS_S9230_64X_MEMCPY - #if defined(GLOBAL_MEMCPY) - #define X86_64_INGRASYS_S9230_64X_MEMCPY GLOBAL_MEMCPY - #elif X86_64_INGRASYS_S9230_64X_CONFIG_PORTING_STDLIB == 1 - #define X86_64_INGRASYS_S9230_64X_MEMCPY memcpy - #else - #error The macro X86_64_INGRASYS_S9230_64X_MEMCPY is required but cannot be defined. - #endif -#endif - -#ifndef X86_64_INGRASYS_S9230_64X_VSNPRINTF - #if defined(GLOBAL_VSNPRINTF) - #define X86_64_INGRASYS_S9230_64X_VSNPRINTF GLOBAL_VSNPRINTF - #elif X86_64_INGRASYS_S9230_64X_CONFIG_PORTING_STDLIB == 1 - #define X86_64_INGRASYS_S9230_64X_VSNPRINTF vsnprintf - #else - #error The macro X86_64_INGRASYS_S9230_64X_VSNPRINTF is required but cannot be defined. - #endif -#endif - -#ifndef X86_64_INGRASYS_S9230_64X_SNPRINTF - #if defined(GLOBAL_SNPRINTF) - #define X86_64_INGRASYS_S9230_64X_SNPRINTF GLOBAL_SNPRINTF - #elif X86_64_INGRASYS_S9230_64X_CONFIG_PORTING_STDLIB == 1 - #define X86_64_INGRASYS_S9230_64X_SNPRINTF snprintf - #else - #error The macro X86_64_INGRASYS_S9230_64X_SNPRINTF is required but cannot be defined. - #endif -#endif - -#ifndef X86_64_INGRASYS_S9230_64X_STRLEN - #if defined(GLOBAL_STRLEN) - #define X86_64_INGRASYS_S9230_64X_STRLEN GLOBAL_STRLEN - #elif X86_64_INGRASYS_S9230_64X_CONFIG_PORTING_STDLIB == 1 - #define X86_64_INGRASYS_S9230_64X_STRLEN strlen - #else - #error The macro X86_64_INGRASYS_S9230_64X_STRLEN is required but cannot be defined. - #endif -#endif - -/* */ - - -#endif /* __X86_64_INGRASYS_S9230_64X_PORTING_H__ */ -/* @} */ diff --git a/packages/platforms/ingrasys/x86-64/s9230-64x/onlp/builds/x86_64_ingrasys_s9230_64x/module/make.mk b/packages/platforms/ingrasys/x86-64/s9230-64x/onlp/builds/x86_64_ingrasys_s9230_64x/module/make.mk deleted file mode 100755 index 2ec883213..000000000 --- a/packages/platforms/ingrasys/x86-64/s9230-64x/onlp/builds/x86_64_ingrasys_s9230_64x/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))) -x86_64_ingrasys_s9230_64x_INCLUDES := -I $(THIS_DIR)inc -x86_64_ingrasys_s9230_64x_INTERNAL_INCLUDES := -I $(THIS_DIR)src -x86_64_ingrasys_s9230_64x_DEPENDMODULE_ENTRIES := init:x86_64_ingrasys_s9230_64x ucli:x86_64_ingrasys_s9230_64x - diff --git a/packages/platforms/ingrasys/x86-64/s9230-64x/onlp/builds/x86_64_ingrasys_s9230_64x/module/src/Makefile b/packages/platforms/ingrasys/x86-64/s9230-64x/onlp/builds/x86_64_ingrasys_s9230_64x/module/src/Makefile deleted file mode 100755 index 140dba653..000000000 --- a/packages/platforms/ingrasys/x86-64/s9230-64x/onlp/builds/x86_64_ingrasys_s9230_64x/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 x86_64_ingrasys_s9230_64x_ucli.c - diff --git a/packages/platforms/ingrasys/x86-64/s9230-64x/onlp/builds/x86_64_ingrasys_s9230_64x/module/src/fani.c b/packages/platforms/ingrasys/x86-64/s9230-64x/onlp/builds/x86_64_ingrasys_s9230_64x/module/src/fani.c deleted file mode 100755 index b060d04e7..000000000 --- a/packages/platforms/ingrasys/x86-64/s9230-64x/onlp/builds/x86_64_ingrasys_s9230_64x/module/src/fani.c +++ /dev/null @@ -1,272 +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. - * - * - ************************************************************ - * - * Fan Platform Implementation Defaults. - * - ***********************************************************/ -#include -#include "x86_64_ingrasys_s9230_64x_int.h" -#include -#include -#include "platform_lib.h" - -onlp_fan_info_t fan_info[] = { - { }, /* Not used */ - { - { FAN_OID_FAN1, "FANTRAY 1", 0 }, - ONLP_FAN_STATUS_PRESENT, - ONLP_FAN_CAPS_GET_RPM | ONLP_FAN_CAPS_GET_PERCENTAGE, - 0, - 0, - ONLP_FAN_MODE_INVALID, - }, - { - { FAN_OID_FAN2, "FANTRAY 2", 0 }, - ONLP_FAN_STATUS_PRESENT, - ONLP_FAN_CAPS_GET_RPM | ONLP_FAN_CAPS_GET_PERCENTAGE, - 0, - 0, - ONLP_FAN_MODE_INVALID, - }, - { - { FAN_OID_FAN3, "FANTRAY 3", 0 }, - ONLP_FAN_STATUS_PRESENT, - ONLP_FAN_CAPS_GET_RPM | ONLP_FAN_CAPS_GET_PERCENTAGE, - 0, - 0, - ONLP_FAN_MODE_INVALID, - }, - { - { FAN_OID_FAN4, "FANTRAY 4", 0 }, - ONLP_FAN_STATUS_PRESENT, - ONLP_FAN_CAPS_GET_RPM | ONLP_FAN_CAPS_GET_PERCENTAGE, - 0, - 0, - ONLP_FAN_MODE_INVALID, - }, - { - { FAN_OID_PSU_FAN1, "PSU-1 FAN", 0 }, - ONLP_FAN_STATUS_PRESENT, - }, - { - { FAN_OID_PSU_FAN2, "PSU-2 FAN", 0 }, - ONLP_FAN_STATUS_PRESENT, - } -}; - -/* - * This function will be called prior to all of onlp_fani_* functions. - */ -int -onlp_fani_init(void) -{ - return ONLP_STATUS_OK; -} - -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_FANTRAY_LED; - switch (id) - { - case FAN_ID_FAN1: - offset = 0; - fan_reg_mask = FAN_1_PRESENT_MASK; - break; - case FAN_ID_FAN2: - offset = 0; - fan_reg_mask = FAN_2_PRESENT_MASK; - break; - case FAN_ID_FAN3: - offset = 1; - fan_reg_mask = FAN_3_PRESENT_MASK; - break; - case FAN_ID_FAN4: - offset = 1; - fan_reg_mask = FAN_4_PRESENT_MASK; - break; - default: - return ONLP_STATUS_E_INVALID; - } - - rv = onlp_i2c_readb(i2c_bus, FAN_GPIO_ADDR, 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 = 10000; - 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", 2 * id - 1); - if (rv < 0) { - return ONLP_STATUS_E_INTERNAL; - } - - /* fan status > 1, means failure */ - if (fan_status > 0) { - info->status |= ONLP_FAN_STATUS_FAILED; - return ONLP_STATUS_OK; - } - - rv = onlp_file_read_int(&fan_rpm, SYS_FAN_PREFIX "fan%d_input", 2 * id - 1); - if (rv < 0) { - return ONLP_STATUS_E_INTERNAL; - } - info->rpm = fan_rpm; - - /* get speed percentage*/ - switch (id) - { - case FAN_ID_FAN1: - case FAN_ID_FAN2: - case FAN_ID_FAN3: - case FAN_ID_FAN4: - rv = onlp_file_read_int(&perc_val, SYS_FAN_PREFIX "pwm%d", - FAN_CTRL_SET2); - break; - default: - return ONLP_STATUS_E_INVALID; - } - if (rv < 0) { - return ONLP_STATUS_E_INTERNAL; - } - - percentage = (info->rpm*100)/max_fan_speed; - info->percentage = percentage; - - return ONLP_STATUS_OK; -} - -int -sys_fan_rpm_percent_set(int perc) -{ - int rc; - - rc = onlp_file_write_int(perc, SYS_FAN_PREFIX "pwm%d", FAN_CTRL_SET2); - if (rc < 0) { - return ONLP_STATUS_E_INTERNAL; - } - - return ONLP_STATUS_OK; -} - -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 percentage) -{ - int fid, perc_val, rc; - fid = ONLP_OID_ID_GET(id); - - /* - * Set fan speed - * Driver accept value in range between 128 and 255. - * Value 128 is 50%. - * Value 200 is 80%. - * Value 255 is 100%. - */ - if (percentage == 100) { - perc_val = 255; - } else if (percentage == 80) { - perc_val = 200; - } else if (percentage == 50) { - perc_val = 128; - } else { - return ONLP_STATUS_E_INVALID; - } - - switch (fid) - { - case FAN_ID_FAN1: - case FAN_ID_FAN2: - case FAN_ID_FAN3: - case FAN_ID_FAN4: - rc = sys_fan_rpm_percent_set(perc_val); - break; - default: - return ONLP_STATUS_E_INVALID; - } - return rc; -} - -int -onlp_fani_info_get(onlp_oid_t id, onlp_fan_info_t* rv) -{ - int fan_id ,rc; - - fan_id = ONLP_OID_ID_GET(id); - *rv = fan_info[fan_id]; - rv->caps |= ONLP_FAN_CAPS_GET_RPM; - - switch (fan_id) { - case FAN_ID_FAN1: - case FAN_ID_FAN2: - case FAN_ID_FAN3: - case FAN_ID_FAN4: - rc = sys_fan_info_get(rv, fan_id); - break; - case FAN_ID_PSU_FAN1: - case FAN_ID_PSU_FAN2: - rc = psu_fan_info_get(rv, fan_id); - break; - default: - return ONLP_STATUS_E_INTERNAL; - break; - } - - return rc; -} diff --git a/packages/platforms/ingrasys/x86-64/s9230-64x/onlp/builds/x86_64_ingrasys_s9230_64x/module/src/ledi.c b/packages/platforms/ingrasys/x86-64/s9230-64x/onlp/builds/x86_64_ingrasys_s9230_64x/module/src/ledi.c deleted file mode 100755 index 36f7612ab..000000000 --- a/packages/platforms/ingrasys/x86-64/s9230-64x/onlp/builds/x86_64_ingrasys_s9230_64x/module/src/ledi.c +++ /dev/null @@ -1,223 +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 -#include -#include -#include -#include - -#include "platform_lib.h" - -/* - * Get the information for the given LED OID. - */ -static onlp_led_info_t led_info[] = -{ - { }, /* Not used */ - { - { LED_OID_SYSTEM, "Chassis LED 1 (SYS LED)", 0 }, - ONLP_LED_STATUS_PRESENT, - ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_GREEN, - }, - { - { LED_OID_FAN, "Chassis LED 2 (FAN 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_PSU1, "Chassis LED 3 (PSU1 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_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. - */ -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, pw_exist, pw_good, rc, fan_id; - onlp_fan_info_t fan_info; - char *sys_psu_prefix = NULL; - - memset(&fan_info, 0, sizeof(onlp_fan_info_t)); - led_id = ONLP_OID_ID_GET(id); - - *info = led_info[led_id]; - - if (id == LED_OID_PSU1 || id == LED_OID_PSU2) { - - if (id == LED_OID_PSU1) { - sys_psu_prefix = SYS_PSU1_PREFIX; - - } else { - sys_psu_prefix = SYS_PSU2_PREFIX; - } - /* check psu status */ - if ((rc = psu_present_get(&pw_exist, sys_psu_prefix)) - != ONLP_STATUS_OK) { - return ONLP_STATUS_E_INTERNAL; - } - if ((rc = psu_pwgood_get(&pw_good, sys_psu_prefix)) - != 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_FAN4; ++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; -} - -/* - * 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) -{ - int led_id, rc; - - led_id = ONLP_OID_ID_GET(id); - switch (led_id) { - case LED_SYSTEM_LED: - rc = system_led_set(mode); - break; - case LED_FAN_LED: - rc = fan_led_set(mode); - break; - case LED_PSU1_LED: - rc = psu1_led_set(mode); - break; - 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; - } - - return rc; -} - -int -onlp_ledi_ioctl(onlp_oid_t id, va_list vargs) -{ - return ONLP_STATUS_OK; -} diff --git a/packages/platforms/ingrasys/x86-64/s9230-64x/onlp/builds/x86_64_ingrasys_s9230_64x/module/src/make.mk b/packages/platforms/ingrasys/x86-64/s9230-64x/onlp/builds/x86_64_ingrasys_s9230_64x/module/src/make.mk deleted file mode 100755 index a1b7ffae7..000000000 --- a/packages/platforms/ingrasys/x86-64/s9230-64x/onlp/builds/x86_64_ingrasys_s9230_64x/module/src/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. -# -# -############################################################ -# -# -# -############################################################ - -LIBRARY := x86_64_ingrasys_s9230_64x -$(LIBRARY)_SUBDIR := $(dir $(lastword $(MAKEFILE_LIST))) -#$(LIBRARY)_LAST := 1 -include $(BUILDER)/lib.mk diff --git a/packages/platforms/ingrasys/x86-64/s9230-64x/onlp/builds/x86_64_ingrasys_s9230_64x/module/src/platform_lib.c b/packages/platforms/ingrasys/x86-64/s9230-64x/onlp/builds/x86_64_ingrasys_s9230_64x/module/src/platform_lib.c deleted file mode 100755 index 8e91b7d10..000000000 --- a/packages/platforms/ingrasys/x86-64/s9230-64x/onlp/builds/x86_64_ingrasys_s9230_64x/module/src/platform_lib.c +++ /dev/null @@ -1,583 +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 -#include -#include -#include -#include -#include - -#include "platform_lib.h" - -int -psu_thermal_get(onlp_thermal_info_t* info, int thermal_id) -{ - int pw_exist, pw_good; - int offset, i2c_bus, rc; - int value, buf; - unsigned int y_value = 0; - unsigned char n_value = 0; - unsigned int temp = 0; - char result[32]; - char *sys_psu_prefix = NULL; - - if (thermal_id == THERMAL_ID_PSU1_1) { - i2c_bus = I2C_BUS_PSU1; - offset = PSU_THERMAL1_OFFSET; - sys_psu_prefix = SYS_PSU1_PREFIX; - } else if (thermal_id == THERMAL_ID_PSU1_2) { - i2c_bus = I2C_BUS_PSU1; - offset = PSU_THERMAL2_OFFSET; - sys_psu_prefix = SYS_PSU1_PREFIX; - } else if (thermal_id == THERMAL_ID_PSU2_1) { - i2c_bus = I2C_BUS_PSU2; - offset = PSU_THERMAL1_OFFSET; - sys_psu_prefix = SYS_PSU2_PREFIX; - } else if (thermal_id == THERMAL_ID_PSU2_2) { - i2c_bus = I2C_BUS_PSU2; - offset = PSU_THERMAL2_OFFSET; - sys_psu_prefix = SYS_PSU2_PREFIX; - } - - /* check psu status */ - if ((rc = psu_present_get(&pw_exist, sys_psu_prefix)) - != ONLP_STATUS_OK) { - return ONLP_STATUS_E_INTERNAL; - } - - 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, sys_psu_prefix)) - != ONLP_STATUS_OK) { - return ONLP_STATUS_E_INTERNAL; - } - - if (pw_good != PSU_STATUS_POWER_GOOD) { - info->mcelsius = 0; - return ONLP_STATUS_OK; - } - - value = onlp_i2c_readw(i2c_bus, PSU_REG, offset, ONLP_I2C_F_FORCE); - - y_value = (value & 0x07FF); - if ((value & 0x8000)&&(y_value)) { - n_value = 0xF0 + (((value) >> 11) & 0x0F); - n_value = (~n_value) +1; - temp = (unsigned int)(1<> 11) & 0x0F); - snprintf(result, sizeof(result), "%d", (y_value*(1<mcelsius = (int)(buf * 1000); - - return ONLP_STATUS_OK; -} - -int -psu_fan_info_get(onlp_fan_info_t* info, int id) -{ - int pw_exist, pw_good; - int i2c_bus, rc; - unsigned int tmp_fan_rpm, fan_rpm; - char *sys_psu_prefix = NULL; - - if (id == FAN_ID_PSU_FAN1) { - i2c_bus = I2C_BUS_PSU1; - sys_psu_prefix = SYS_PSU1_PREFIX; - } else if (id == FAN_ID_PSU_FAN2) { - i2c_bus = I2C_BUS_PSU2; - sys_psu_prefix = SYS_PSU2_PREFIX; - } else { - return ONLP_STATUS_E_INTERNAL; - } - - /* check psu status */ - if ((rc = psu_present_get(&pw_exist, sys_psu_prefix)) - != ONLP_STATUS_OK) { - return ONLP_STATUS_E_INTERNAL; - } - - 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, sys_psu_prefix)) - != ONLP_STATUS_OK) { - return ONLP_STATUS_E_INTERNAL; - } - - if (pw_good != PSU_STATUS_POWER_GOOD) { - info->rpm = 0; - return ONLP_STATUS_OK; - } - - tmp_fan_rpm = onlp_i2c_readw(i2c_bus, PSU_REG, PSU_FAN_RPM_OFFSET, ONLP_I2C_F_FORCE); - - fan_rpm = (unsigned int)tmp_fan_rpm; - fan_rpm = (fan_rpm & 0x07FF) * (1 << ((fan_rpm >> 11) & 0x1F)); - info->rpm = (int)fan_rpm; - - return ONLP_STATUS_OK; -} - -int -psu_vout_get(onlp_psu_info_t* info, int i2c_bus) -{ - int v_value = 0; - int n_value = 0; - unsigned int temp = 0; - char result[32]; - double dvalue; - memset(result, 0, sizeof(result)); - - n_value = onlp_i2c_readb(i2c_bus, PSU_REG, PSU_VOUT_OFFSET1, ONLP_I2C_F_FORCE); - if (n_value < 0) { - return ONLP_STATUS_E_INTERNAL; - } - - v_value = onlp_i2c_readw(i2c_bus, PSU_REG, PSU_VOUT_OFFSET2, ONLP_I2C_F_FORCE); - if (v_value < 0) { - return ONLP_STATUS_E_INTERNAL; - } - - if (n_value & 0x10) { - n_value = 0xF0 + (n_value & 0x0F); - n_value = (~n_value) +1; - temp = (unsigned int)(1< 0.0) { - info->caps |= ONLP_PSU_CAPS_VOUT; - info->mvout = (int)(dvalue * 1000); - } - - return ONLP_STATUS_OK; -} - -int -psu_iout_get(onlp_psu_info_t* info, int i2c_bus) -{ - int value; - unsigned int y_value = 0; - unsigned char n_value = 0; - unsigned int temp = 0; - char result[32]; - memset(result, 0, sizeof(result)); - double dvalue; - - value = onlp_i2c_readw(i2c_bus, PSU_REG, PSU_IOUT_OFFSET, ONLP_I2C_F_FORCE); - if (value < 0) { - return ONLP_STATUS_E_INTERNAL; - } - - y_value = (value & 0x07FF); - if ((value & 0x8000)&&(y_value)) - { - n_value = 0xF0 + (((value) >> 11) & 0x0F); - n_value = (~n_value) +1; - temp = (unsigned int)(1<> 11) & 0x0F); - snprintf(result, sizeof(result), "%d", (y_value*(1< 0.0) { - info->caps |= ONLP_PSU_CAPS_IOUT; - info->miout = (int)(dvalue * 1000); - } - - return ONLP_STATUS_OK; -} - -int -psu_pout_get(onlp_psu_info_t* info, int i2c_bus) -{ - int value; - unsigned int y_value = 0; - unsigned char n_value = 0; - unsigned int temp = 0; - char result[32]; - memset(result, 0, sizeof(result)); - double dvalue; - - value = onlp_i2c_readw(i2c_bus, PSU_REG, PSU_POUT_OFFSET, ONLP_I2C_F_FORCE); - if (value < 0) { - return ONLP_STATUS_E_INTERNAL; - } - - y_value = (value & 0x07FF); - if ((value & 0x8000)&&(y_value)) - { - n_value = 0xF0 + (((value) >> 11) & 0x0F); - n_value = (~n_value) +1; - temp = (unsigned int)(1<> 11) & 0x0F); - snprintf(result, sizeof(result), "%d", (y_value*(1< 0.0) { - info->caps |= ONLP_PSU_CAPS_POUT; - info->mpout = (int)(dvalue * 1000); - } - - return ONLP_STATUS_OK; -} - -int -psu_pin_get(onlp_psu_info_t* info, int i2c_bus) -{ - int value; - unsigned int y_value = 0; - unsigned char n_value = 0; - unsigned int temp = 0; - char result[32]; - memset(result, 0, sizeof(result)); - double dvalue; - - value = onlp_i2c_readw(i2c_bus, PSU_REG, PSU_PIN_OFFSET, ONLP_I2C_F_FORCE); - if (value < 0) { - return ONLP_STATUS_E_INTERNAL; - } - - y_value = (value & 0x07FF); - if ((value & 0x8000)&&(y_value)) - { - n_value = 0xF0 + (((value) >> 11) & 0x0F); - n_value = (~n_value) +1; - temp = (unsigned int)(1<> 11) & 0x0F); - snprintf(result, sizeof(result), "%d", (y_value*(1< 0.0) { - info->caps |= ONLP_PSU_CAPS_PIN; - info->mpin = (int)(dvalue * 1000); - } - - return ONLP_STATUS_OK; -} - -int -psu_eeprom_get(onlp_psu_info_t* info, int id) -{ - uint8_t data[256]; - char eeprom_path[128]; - int data_len, i, rc; - memset(data, 0, sizeof(data)); - memset(eeprom_path, 0, sizeof(eeprom_path)); - - if (id == PSU_ID_PSU1) { - rc = onlp_file_read(data, sizeof(data), &data_len, PSU1_EEPROM_PATH); - } else { - rc = onlp_file_read(data, sizeof(data), &data_len, PSU2_EEPROM_PATH); - } - - if (rc == ONLP_STATUS_OK) - { - i = 11; - - /* Manufacturer Name */ - data_len = (data[i]&0x0f); - i++; - i += data_len; - - /* Product Name */ - data_len = (data[i]&0x0f); - i++; - memcpy(info->model, (char *) &(data[i]), data_len); - i += data_len; - - /* Product part,model number */ - data_len = (data[i]&0x0f); - i++; - i += data_len; - - /* Product Version */ - data_len = (data[i]&0x0f); - i++; - i += data_len; - - /* Product Serial Number */ - data_len = (data[i]&0x0f); - i++; - memcpy(info->serial, (char *) &(data[i]), data_len); - } else { - strcpy(info->model, "Missing"); - strcpy(info->serial, "Missing"); - } - - return ONLP_STATUS_OK; -} - - -int -psu_present_get(int *pw_exist, char *sys_psu_prefix) -{ - int rv, psu_pres; - - rv = onlp_file_read_int(&psu_pres, "%spsu_abs", sys_psu_prefix); - if (rv < 0) { - return ONLP_STATUS_E_INTERNAL; - } - - *pw_exist = (psu_pres ? 0 : 1); - return ONLP_STATUS_OK; -} - -int -psu_pwgood_get(int *pw_good, char *sys_psu_prefix) -{ - int rv, psu_pwgood; - - rv = onlp_file_read_int(&psu_pwgood, "%spsu_pg", sys_psu_prefix); - if (rv < 0) { - return ONLP_STATUS_E_INTERNAL; - } - - *pw_good = (psu_pwgood ? 1 : 0); - return ONLP_STATUS_OK; -} - -int -system_led_set(onlp_led_mode_t mode) -{ - int rc; - if(mode == ONLP_LED_MODE_GREEN) { - rc = onlp_i2c_modifyb(I2C_BUS_SYS_LED, LED_REG, LED_OFFSET, LED_SYS_AND_MASK, - LED_SYS_GMASK, ONLP_I2C_F_FORCE); - } - else if(mode == ONLP_LED_MODE_ORANGE) { - rc = onlp_i2c_modifyb(I2C_BUS_SYS_LED, LED_REG, LED_OFFSET, LED_SYS_AND_MASK, - LED_SYS_YMASK, ONLP_I2C_F_FORCE); - } else { - return ONLP_STATUS_E_INTERNAL; - } - - if (rc < 0) { - return ONLP_STATUS_E_INTERNAL; - } - - return ONLP_STATUS_OK; -} - -int -fan_led_set(onlp_led_mode_t mode) -{ - int rc; - - if(mode == ONLP_LED_MODE_GREEN) { - rc = onlp_i2c_modifyb(I2C_BUS_SYS_LED, LED_REG, LED_OFFSET, LED_FAN_AND_MASK, - LED_FAN_GMASK, ONLP_I2C_F_FORCE); - } - else if(mode == ONLP_LED_MODE_ORANGE) { - rc = onlp_i2c_modifyb(I2C_BUS_SYS_LED, LED_REG, LED_OFFSET, LED_FAN_AND_MASK, - LED_FAN_YMASK, ONLP_I2C_F_FORCE); - } - else if(mode == ONLP_LED_MODE_OFF) { - rc = onlp_i2c_modifyb(I2C_BUS_SYS_LED, LED_REG, LED_OFFSET, LED_FAN_AND_MASK, - LED_FAN_OFFMASK, ONLP_I2C_F_FORCE); - } else { - return ONLP_STATUS_E_INTERNAL; - } - - if (rc < 0) { - return ONLP_STATUS_E_INTERNAL; - } - - return ONLP_STATUS_OK; -} - -int -psu1_led_set(onlp_led_mode_t mode) -{ - int rc; - if(mode == ONLP_LED_MODE_GREEN) { - rc = onlp_i2c_modifyb(I2C_BUS_SYS_LED, LED_REG, LED_OFFSET, - LED_PSU1_AND_MASK, LED_PSU1_GMASK, - ONLP_I2C_F_FORCE); - } else if(mode == ONLP_LED_MODE_ORANGE) { - rc = onlp_i2c_modifyb(I2C_BUS_SYS_LED, 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_SYS_LED, LED_REG, LED_OFFSET, - LED_PSU1_AND_MASK, LED_PSU1_OFFMASK, - ONLP_I2C_F_FORCE); - } else { - return ONLP_STATUS_E_INTERNAL; - } - - if (rc < 0) { - return ONLP_STATUS_E_INTERNAL; - } - - return ONLP_STATUS_OK; -} - -int -psu2_led_set(onlp_led_mode_t mode) -{ - int rc; - if(mode == ONLP_LED_MODE_GREEN) { - rc = onlp_i2c_modifyb(I2C_BUS_SYS_LED, LED_REG, LED_OFFSET, - LED_PSU2_AND_MASK, LED_PSU2_GMASK, - ONLP_I2C_F_FORCE); - } else if(mode == ONLP_LED_MODE_ORANGE) { - rc = onlp_i2c_modifyb(I2C_BUS_SYS_LED, 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_SYS_LED, LED_REG, LED_OFFSET, - LED_PSU2_AND_MASK, LED_PSU2_OFFMASK, - ONLP_I2C_F_FORCE); - } else { - return ONLP_STATUS_E_INTERNAL; - } - - - if (rc < 0) { - return ONLP_STATUS_E_INTERNAL; - } - - 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; - - temp_id = ONLP_OID_ID_GET(id); - switch (temp_id) { - case LED_FAN_TRAY1: - fan_tray_id = 1; - offset = 2; - break; - case LED_FAN_TRAY2: - fan_tray_id = 2; - offset = 2; - break; - case LED_FAN_TRAY3: - fan_tray_id = 3; - offset = 3; - break; - case LED_FAN_TRAY4: - 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_FANTRAY_LED, FAN_GPIO_ADDR, offset, 0xFC, - 0x01, ONLP_I2C_F_FORCE); - } else if (mode == ONLP_LED_MODE_ORANGE) { - rc = onlp_i2c_modifyb(I2C_BUS_FANTRAY_LED, FAN_GPIO_ADDR, 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_FANTRAY_LED, FAN_GPIO_ADDR, offset, 0xCF, - 0x10, ONLP_I2C_F_FORCE); - } else if (mode == ONLP_LED_MODE_ORANGE) { - rc = onlp_i2c_modifyb(I2C_BUS_FANTRAY_LED, FAN_GPIO_ADDR, 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) -{ - int cpld_version, cpld_rev; - int bus_i; - char line[64] = "", output[512] = ""; - - for(bus_i=I2C_BUS_CPLD1; bus_i <= I2C_BUS_CPLD5; ++bus_i) { - - int rv; - rv = onlp_file_read_int(&cpld_rev, CPLD_REG_PATH, bus_i, CPLD_REG, CPLD_VERSION_KEY); - if (rv < 0) { - return ONLP_STATUS_E_INTERNAL; - } - - if (cpld_rev < 0) { - return ONLP_STATUS_E_INTERNAL; - } - - cpld_version = (((cpld_rev) & 0x3F)); - - snprintf(line, sizeof(line), "CPLD%d:0x%x, ", bus_i, cpld_version); - strcat(output, line); - } - - pi->cpld_versions = aim_fstrdup("%s", output); - return ONLP_STATUS_OK; -} diff --git a/packages/platforms/ingrasys/x86-64/s9230-64x/onlp/builds/x86_64_ingrasys_s9230_64x/module/src/platform_lib.h b/packages/platforms/ingrasys/x86-64/s9230-64x/onlp/builds/x86_64_ingrasys_s9230_64x/module/src/platform_lib.h deleted file mode 100755 index 29384cf5f..000000000 --- a/packages/platforms/ingrasys/x86-64/s9230-64x/onlp/builds/x86_64_ingrasys_s9230_64x/module/src/platform_lib.h +++ /dev/null @@ -1,309 +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. - * - * - ************************************************************ - * - * - * - ***********************************************************/ -#ifndef __PLATFORM_LIB_H__ -#define __PLATFORM_LIB_H__ - -#include -#include -#include -#include -#include -#include "x86_64_ingrasys_s9230_64x_int.h" -#include "x86_64_ingrasys_s9230_64x_log.h" -#include - -#define SYS_CPU_TEMP_PREFIX "/sys/class/hwmon/hwmon0/" -#define SYS_REAR_PANEL_TEMP_PREFIX "/sys/class/hwmon/hwmon1/" -#define SYS_REAR_MAC_TEMP_PREFIX "/sys/class/hwmon/hwmon2/" -#define SYS_FRONT_PANEL_PREFIX "/sys/class/hwmon/hwmon3/" -#define SYS_FRONT_MAC_PREFIX "/sys/class/hwmon/hwmon4/" -#define SYS_BMC_BOARD_PREFIX "/sys/class/hwmon/hwmon5/" -#define SYS_CPU_BOARD_PREFIX "/sys/class/hwmon/hwmon6/" -#define SYS_FAN_PREFIX "/sys/class/hwmon/hwmon7/device/" -#define SYS_PSU1_PREFIX "/sys/bus/i2c/devices/i2c-18/18-0050/" -#define SYS_PSU2_PREFIX "/sys/bus/i2c/devices/i2c-17/17-0050/" -#define SYS_EEPROM_PATH "/sys/bus/i2c/devices/0-0051/eeprom" -#define SYS_EEPROM_SIZE 512 -#define PSU1_EEPROM_PATH "/sys/bus/i2c/devices/18-0050/psu_eeprom" -#define PSU2_EEPROM_PATH "/sys/bus/i2c/devices/17-0050/psu_eeprom" -#define PSU_STATUS_PRESENT 1 -#define PSU_STATUS_POWER_GOOD 1 -#define FAN_PRESENT 0 -#define FAN_CTRL_SET1 1 -#define FAN_CTRL_SET2 2 -#define BOARD_THERMAL_NUM 6 -#define SYS_FAN_NUM 4 -#define PORT_NUM 66 - -#define THERMAL_NUM 14 -#define LED_NUM 4 -#define FAN_NUM 6 - - - -#define THERMAL_SHUTDOWN_DEFAULT 105000 - -#define THERMAL_ERROR_DEFAULT 95000 -#define THERMAL_ERROR_FAN_PERC 100 - -#define THERMAL_WARNING_DEFAULT 77000 -#define THERMAL_WARNING_FAN_PERC 80 - -#define THERMAL_NORMAL_DEFAULT 72000 -#define THERMAL_NORMAL_FAN_PERC 50 - -/* I2C bus */ -#define I2C_BUS_0 0 -#define I2C_BUS_1 1 -#define I2C_BUS_2 2 -#define I2C_BUS_3 3 -#define I2C_BUS_4 4 -#define I2C_BUS_5 5 -#define I2C_BUS_10 10 /* SYS_LED */ -#define I2C_BUS_17 (17) /* PSU2 */ -#define I2C_BUS_18 (18) /* PSU1 */ - -#define I2C_BUS_PSU1 I2C_BUS_18 /* PSU1 */ -#define I2C_BUS_PSU2 I2C_BUS_17 /* PSU2 */ -#define I2C_BUS_SYS_LED I2C_BUS_10 /* SYS LED */ -#define I2C_BUS_FANTRAY_LED I2C_BUS_0 /* FANTRAY LED */ -#define I2C_BUS_CPLD1 I2C_BUS_1 /* CPLD 1 */ -#define I2C_BUS_CPLD2 I2C_BUS_2 /* CPLD 2 */ -#define I2C_BUS_CPLD3 I2C_BUS_3 /* CPLD 3 */ -#define I2C_BUS_CPLD4 I2C_BUS_4 /* CPLD 4 */ -#define I2C_BUS_CPLD5 I2C_BUS_5 /* CPLD 5 */ - -/* PSU */ -#define PSU_MUX_MASK 0x01 - -#define PSU_THERMAL1_OFFSET 0x8D -#define PSU_THERMAL2_OFFSET 0x8E -#define PSU_THERMAL_REG 0x58 -#define PSU_FAN_RPM_REG 0x58 -#define PSU_FAN_RPM_OFFSET 0x90 -#define PSU_REG 0x58 -#define PSU_VOUT_OFFSET1 0x20 -#define PSU_VOUT_OFFSET2 0x8B -#define PSU_IOUT_OFFSET 0x8C -#define PSU_POUT_OFFSET 0x96 -#define PSU_PIN_OFFSET 0x97 - -#define PSU_STATE_REG 0x25 -#define PSU1_PRESENT_OFFSET 0x04 -#define PSU2_PRESENT_OFFSET 0x01 -#define PSU1_PWGOOD_OFFSET 0x03 -#define PSU2_PWGOOD_OFFSET 0x00 - -/* LED */ -#define LED_REG 0x76 -#define LED_OFFSET 0x02 -#define LED_PWOK_OFFSET 0x03 - -#define LED_SYS_AND_MASK 0x7F -#define LED_SYS_GMASK 0x80 -#define LED_SYS_YMASK 0x00 - -#define LED_FAN_AND_MASK 0x9F -#define LED_FAN_GMASK 0x40 -#define LED_FAN_YMASK 0x60 -#define LED_FAN_OFFMASK 0x00 - -#define LED_PSU2_AND_MASK 0xF9 -#define LED_PSU2_GMASK 0x04 -#define LED_PSU2_YMASK 0x06 -#define LED_PSU2_OFFMASK 0x00 - -#define LED_PSU1_AND_MASK 0xE7 -#define LED_PSU1_GMASK 0x10 -#define LED_PSU1_YMASK 0x18 -#define LED_PSU1_OFFMASK 0x00 - -#define LED_SYS_ON_MASK 0x00 -#define LED_SYS_OFF_MASK 0x33 - -/* SYS */ -#define CPLD_REG 0x33 -#define CPLD_VER_OFFSET 0x01 - -/* QSFP */ -#define QSFP_PRES_REG1 0x20 -#define QSFP_PRES_REG2 0x21 -#define QSFP_PRES_OFFSET1 0x00 -#define QSFP_PRES_OFFSET2 0x01 - -/* FANTRAY */ -#define FAN_GPIO_ADDR 0x20 -#define FAN_1_PRESENT_MASK 0x04 -#define FAN_2_PRESENT_MASK 0x40 -#define FAN_3_PRESENT_MASK 0x04 -#define FAN_4_PRESENT_MASK 0x40 - -/* CPLD */ -//#define CPLDx_I2C_ADDR 0x21 -#define QSFP_EEPROM_I2C_ADDR 0x50 -#define CPLD1_PORTS 12 -#define CPLDx_PORTS 13 -#define CPLD_OFFSET 1 -#define CPLD_QSFP_PRES_BIT 1 -#define CPLD_SFP_PRES_BIT 0 -#define CPLD_QSFP_REG_PATH "/sys/bus/i2c/devices/%d-00%02x/%s_%d" -#define CPLD_SFP_REG_PATH "/sys/bus/i2c/devices/%d-00%02x/%s" -#define CPLD_REG_PATH "/sys/bus/i2c/devices/%d-00%02x/%s" -#define CPLD_QSFP_PORT_STATUS_KEY "cpld_qsfp_port_status" -#define CPLD_SFP_PORT_STATUS_KEY "cpld_sfp_port_status" -#define CPLD_VERSION_KEY "cpld_version" - - - -/** 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 */ -typedef enum led_id_e { - LED_SYSTEM_LED = 1, - 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 */ -typedef enum thermal_oid_e { - THERMAL_OID_CPU1 = ONLP_THERMAL_ID_CREATE(1), - THERMAL_OID_CPU2 = ONLP_THERMAL_ID_CREATE(2), - THERMAL_OID_CPU3 = ONLP_THERMAL_ID_CREATE(3), - THERMAL_OID_CPU4 = ONLP_THERMAL_ID_CREATE(4), - THERMAL_OID_REAR_PANEL = ONLP_THERMAL_ID_CREATE(5), - THERMAL_OID_REAR_MAC = ONLP_THERMAL_ID_CREATE(6), - THERMAL_OID_FRONT_PANEL = ONLP_THERMAL_ID_CREATE(7), - THERMAL_OID_FRONT_MAC = ONLP_THERMAL_ID_CREATE(8), - THERMAL_OID_BMC_BOARD = ONLP_THERMAL_ID_CREATE(9), - THERMAL_OID_CPU_BOARD = ONLP_THERMAL_ID_CREATE(10), - THERMAL_OID_PSU1_1 = ONLP_THERMAL_ID_CREATE(11), - THERMAL_OID_PSU1_2 = ONLP_THERMAL_ID_CREATE(12), - THERMAL_OID_PSU2_1 = ONLP_THERMAL_ID_CREATE(13), - THERMAL_OID_PSU2_2 = ONLP_THERMAL_ID_CREATE(14), -} thermal_oid_t; - -/** thermal_id */ -typedef enum thermal_id_e { - THERMAL_ID_CPU1 = 1, - THERMAL_ID_CPU2 = 2, - THERMAL_ID_CPU3 = 3, - THERMAL_ID_CPU4 = 4, - THERMAL_ID_REAR_PANEL = 5, - THERMAL_ID_REAR_MAC = 6, - THERMAL_ID_FRONT_PANEL = 7, - THERMAL_ID_FRONT_MAC = 8, - THERMAL_ID_BMC_BOARD = 9, - THERMAL_ID_CPU_BOARD = 10, - THERMAL_ID_PSU1_1 = 11, - THERMAL_ID_PSU1_2 = 12, - THERMAL_ID_PSU2_1 = 13, - THERMAL_ID_PSU2_2 = 14, -} thermal_id_t; - -/* Shortcut for CPU thermal threshold value. */ -#define THERMAL_THRESHOLD_INIT_DEFAULTS \ - { THERMAL_WARNING_DEFAULT, \ - THERMAL_ERROR_DEFAULT, \ - THERMAL_SHUTDOWN_DEFAULT } - -/** 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_PSU_FAN1 = ONLP_FAN_ID_CREATE(5), - FAN_OID_PSU_FAN2 = ONLP_FAN_ID_CREATE(6) -} fan_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_PSU_FAN1 = 5, - FAN_ID_PSU_FAN2 = 6 -} fan_id_t; - -/** led_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; - -/** fan_id */ -typedef enum psu_id_e { - PSU_ID_PSU1 = 1, - PSU_ID_PSU2 = 2 -} psu_id_t; - -int psu_thermal_get(onlp_thermal_info_t* info, int id); - -int psu_fan_info_get(onlp_fan_info_t* info, int id); - -int psu_vout_get(onlp_psu_info_t* info, int i2c_bus); - -int psu_iout_get(onlp_psu_info_t* info, int i2c_bus); - -int psu_pout_get(onlp_psu_info_t* info, int i2c_bus); - -int psu_pin_get(onlp_psu_info_t* info, int i2c_bus); - -int psu_eeprom_get(onlp_psu_info_t* info, int id); - -int psu_present_get(int *pw_exist, char *sys_psu_prefix); - -int psu_pwgood_get(int *pw_good, char *sys_psu_prefix); - -int psu2_led_set(onlp_led_mode_t mode); - -int psu1_led_set(onlp_led_mode_t mode); - -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); - -#endif /* __PLATFORM_LIB_H__ */ diff --git a/packages/platforms/ingrasys/x86-64/s9230-64x/onlp/builds/x86_64_ingrasys_s9230_64x/module/src/psui.c b/packages/platforms/ingrasys/x86-64/s9230-64x/onlp/builds/x86_64_ingrasys_s9230_64x/module/src/psui.c deleted file mode 100755 index a8f385fbd..000000000 --- a/packages/platforms/ingrasys/x86-64/s9230-64x/onlp/builds/x86_64_ingrasys_s9230_64x/module/src/psui.c +++ /dev/null @@ -1,156 +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 - -#include "platform_lib.h" - -static onlp_psu_info_t pinfo[] = -{ - { }, /* Not used */ - { - { - PSU_OID_PSU1, - "PSU-1", - 0, - { - FAN_OID_PSU_FAN1, - }, - } - }, - { - { - PSU_OID_PSU2, - "PSU-2", - 0, - { - FAN_OID_PSU_FAN2, - }, - } - } -}; - -int -onlp_psui_init(void) -{ - return ONLP_STATUS_OK; -} - -int -psu_status_info_get(int id, onlp_psu_info_t *info) -{ - int pw_exist, pw_good; - int rc, i2c_bus; - char *sys_psu_prefix = NULL; - - if (id == PSU_ID_PSU1) { - i2c_bus = I2C_BUS_PSU1; - sys_psu_prefix = SYS_PSU1_PREFIX; - } else if (id == PSU_ID_PSU2) { - i2c_bus = I2C_BUS_PSU2; - sys_psu_prefix = SYS_PSU2_PREFIX; - } else { - return ONLP_STATUS_E_INTERNAL; - } - - /* Get power present status */ - if ((rc = psu_present_get(&pw_exist, sys_psu_prefix)) - != ONLP_STATUS_OK) { - return ONLP_STATUS_E_INTERNAL; - } - - if (pw_exist != PSU_STATUS_PRESENT) { - info->status &= ~ONLP_PSU_STATUS_PRESENT; - info->status |= ONLP_PSU_STATUS_FAILED; - return ONLP_STATUS_OK; - } - info->status |= ONLP_PSU_STATUS_PRESENT; - - /* Get power good status */ - if ((rc = psu_pwgood_get(&pw_good, sys_psu_prefix)) - != ONLP_STATUS_OK) { - return ONLP_STATUS_E_INTERNAL; - } - - 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 */ - if ((rc = psu_eeprom_get(info, id)) != ONLP_STATUS_OK) { - return ONLP_STATUS_E_INTERNAL; - } - - /* Get power iout status */ - if ((rc = psu_iout_get(info, i2c_bus)) != ONLP_STATUS_OK) { - return ONLP_STATUS_E_INTERNAL; - } - - /* Get power pout status */ - if ((rc = psu_pout_get(info, i2c_bus)) != ONLP_STATUS_OK) { - return ONLP_STATUS_E_INTERNAL; - } - - /* Get power pin status */ - if ((rc = psu_pin_get(info, i2c_bus)) != ONLP_STATUS_OK) { - return ONLP_STATUS_E_INTERNAL; - } - - /* Get power vout status */ - if ((rc = psu_vout_get(info, i2c_bus)) != ONLP_STATUS_OK) { - return ONLP_STATUS_E_INTERNAL; - } - - return ONLP_STATUS_OK; -} - -int -onlp_psui_info_get(onlp_oid_t id, onlp_psu_info_t* info) -{ - int pid; - - pid = ONLP_OID_ID_GET(id); - memset(info, 0, sizeof(onlp_psu_info_t)); - - /* Set the onlp_oid_hdr_t */ - *info = pinfo[pid]; - - switch (pid) { - case PSU_ID_PSU1: - case PSU_ID_PSU2: - return psu_status_info_get(pid, info); - break; - default: - return ONLP_STATUS_E_UNSUPPORTED; - break; - } - - return ONLP_STATUS_OK; - - -} diff --git a/packages/platforms/ingrasys/x86-64/s9230-64x/onlp/builds/x86_64_ingrasys_s9230_64x/module/src/sfpi.c b/packages/platforms/ingrasys/x86-64/s9230-64x/onlp/builds/x86_64_ingrasys_s9230_64x/module/src/sfpi.c deleted file mode 100755 index c8e08fa83..000000000 --- a/packages/platforms/ingrasys/x86-64/s9230-64x/onlp/builds/x86_64_ingrasys_s9230_64x/module/src/sfpi.c +++ /dev/null @@ -1,182 +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 -#include -#include -#include -#include -#include -#include -#include "x86_64_ingrasys_s9230_64x_log.h" -#include "platform_lib.h" - -static int _fp2phy_port_mapping[64] = { - 1, 2, 5, 6, 9, 10, 13, 14, 17, 18, 21, 22, 25, 26, 29, 30, - 33, 34, 37, 38, 41, 42, 45, 46, 49, 50, 53, 54, 57, 58, 61, 62, - 3, 4, 7, 8, 11, 12, 15, 16, 19, 20, 23, 24, 27, 28, 31, 32, - 35, 36, 39, 40, 43, 44, 47, 48, 51, 52, 55, 56, 59, 60, 63, 64}; - -static void -qsfp_to_cpld_index(int phy_port, int *cpld_id, int *cpld_port_index) -{ - phy_port = phy_port - 1; - if (phy_port < CPLD1_PORTS) { - *cpld_id = 0; - *cpld_port_index = phy_port + 1; - } else { - *cpld_id = 1 + (phy_port - CPLD1_PORTS) / CPLDx_PORTS; - *cpld_port_index = ((phy_port - CPLD1_PORTS) % CPLDx_PORTS) + 1; - } - return; -} - - -int -onlp_sfpi_init(void) -{ - return ONLP_STATUS_OK; -} - -int -onlp_sfpi_bitmap_get(onlp_sfp_bitmap_t* bmap) -{ - int p; - for(p = 1; p <= PORT_NUM; p++) { - AIM_BITMAP_SET(bmap, p); - } - return ONLP_STATUS_OK; -} - -int -onlp_sfpi_is_present(int port) -{ - int status, phy_port; - int i2c_id, cpld_id, cpld_port_index; - char reg_path[128]; - int value, mask; - uint8_t data[8]; - int data_len; - - if (port >= 1 && port <=64) { - phy_port = _fp2phy_port_mapping[port-1]; - qsfp_to_cpld_index(phy_port, &cpld_id, &cpld_port_index); - - i2c_id = CPLD_OFFSET + cpld_id; - mask = 1 << CPLD_QSFP_PRES_BIT; - - snprintf(reg_path, 128, CPLD_QSFP_REG_PATH, i2c_id, CPLD_REG, CPLD_QSFP_PORT_STATUS_KEY, cpld_port_index); - } else if (port>= 65 && port <= 66) { - cpld_port_index = 0; - mask = 1 << CPLD_SFP_PRES_BIT; - - if (port == 65) { - i2c_id = CPLD_OFFSET; - } else { - i2c_id = CPLD_OFFSET + 1; - } - - snprintf(reg_path, 128, CPLD_SFP_REG_PATH, i2c_id, CPLD_REG, CPLD_SFP_PORT_STATUS_KEY); - } else { - return ONLP_STATUS_E_INTERNAL; - } - - if (onlp_file_read(data, sizeof(data), &data_len, reg_path) == ONLP_STATUS_OK) { - //convert hex string to integer - value = (int) strtol ((char *) data, NULL, 16); - - if ( (value & mask) == 0) { - status = 1; - } else { - status = 0; - } - } else { - return ONLP_STATUS_E_INTERNAL; - } - - return status; -} - - -int -onlp_sfpi_presence_bitmap_get(onlp_sfp_bitmap_t* dst) -{ - int p = 1; - int rc = 0; - - for (p = 1; p <= PORT_NUM; p++) { - rc = onlp_sfpi_is_present(p); - AIM_BITMAP_MOD(dst, p, (1 == rc) ? 1 : 0); - } - - return ONLP_STATUS_OK; -} - -/* - * This function reads the SFPs idrom and returns in - * in the data buffer provided. - */ -int -onlp_sfpi_eeprom_read(int port, uint8_t data[256]) -{ - int eeprombus=0, eeprombusbase=0, phy_port=0, port_group=0, eeprombusshift=0; - char eeprom_path[512], eeprom_addr[32]; - memset(eeprom_path, 0, sizeof(eeprom_path)); - memset(eeprom_addr, 0, sizeof(eeprom_addr)); - aim_strlcpy(eeprom_addr, "0050", sizeof(eeprom_addr)); - - memset(data, 0, 256); - - if (port >=1 && port <= 64) { - phy_port = _fp2phy_port_mapping[port-1]; - port_group = (phy_port-1)/8; - eeprombusbase = 33 + (port_group * 8); - eeprombusshift = (phy_port-1)%8; - eeprombus = eeprombusbase + eeprombusshift; - } else if (port == 65 ){ - eeprombus = 21; - } else if (port == 66 ){ - eeprombus = 22; - } else { - return ONLP_STATUS_E_INTERNAL; - } - - snprintf(eeprom_path, sizeof(eeprom_path), - "/sys/bus/i2c/devices/%d-%s/eeprom", eeprombus, eeprom_addr); - - if (onlplib_sfp_eeprom_read_file(eeprom_path, data) != 0) { - return ONLP_STATUS_E_INTERNAL; - } - - return ONLP_STATUS_OK; -} - -/* - * De-initialize the SFPI subsystem. - */ -int -onlp_sfpi_denit(void) -{ - return ONLP_STATUS_OK; -} diff --git a/packages/platforms/ingrasys/x86-64/s9230-64x/onlp/builds/x86_64_ingrasys_s9230_64x/module/src/sysi.c b/packages/platforms/ingrasys/x86-64/s9230-64x/onlp/builds/x86_64_ingrasys_s9230_64x/module/src/sysi.c deleted file mode 100755 index 1e6567a2a..000000000 --- a/packages/platforms/ingrasys/x86-64/s9230-64x/onlp/builds/x86_64_ingrasys_s9230_64x/module/src/sysi.c +++ /dev/null @@ -1,339 +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 -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "platform_lib.h" - -const char* -onlp_sysi_platform_get(void) -{ - return "x86-64-ingrasys-s9230-64x-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(SYS_EEPROM_SIZE); - if(onlp_file_read(rdata, SYS_EEPROM_SIZE, size, SYS_EEPROM_PATH) == ONLP_STATUS_OK) { - if(*size == SYS_EEPROM_SIZE) { - *data = rdata; - return ONLP_STATUS_OK; - } - } - - AIM_LOG_INFO("Unable to get data from eeprom \n"); - aim_free(rdata); - *size = 0; - return ONLP_STATUS_E_INTERNAL; -} - -int -onlp_sysi_oids_get(onlp_oid_t* table, int max) -{ - onlp_oid_t* e = table; - memset(table, 0, max*sizeof(onlp_oid_t)); - int i; - - /* 2 PSUs */ - *e++ = ONLP_PSU_ID_CREATE(1); - *e++ = ONLP_PSU_ID_CREATE(2); - - /* LEDs Item */ - for (i=1; i<=LED_NUM; i++) { - *e++ = ONLP_LED_ID_CREATE(i); - } - - /* THERMALs Item */ - for (i=1; i<=THERMAL_NUM; i++) { - *e++ = ONLP_THERMAL_ID_CREATE(i); - } - - /* Fans Item */ - for (i=1; i<=FAN_NUM; i++) { - *e++ = ONLP_FAN_ID_CREATE(i); - } - - return ONLP_STATUS_OK; -} - -int -decide_fan_percentage(int is_up, int new_temp) -{ - int new_perc; - if (is_up) { - if (new_temp >= THERMAL_ERROR_DEFAULT) { - new_perc = THERMAL_ERROR_FAN_PERC; - } else if (new_temp >= THERMAL_WARNING_DEFAULT) { - new_perc = THERMAL_WARNING_FAN_PERC; - } else { - new_perc = THERMAL_NORMAL_FAN_PERC; - } - } else { - if (new_temp <= THERMAL_NORMAL_DEFAULT) { - new_perc = THERMAL_NORMAL_FAN_PERC; - } else if (new_temp <= THERMAL_WARNING_DEFAULT) { - new_perc = THERMAL_WARNING_FAN_PERC; - } else { - new_perc = THERMAL_ERROR_FAN_PERC; - } - } - - return new_perc; -} - -int -platform_thermal_temp_get(int *thermal_temp) -{ - int i, temp, max_temp, rc; - onlp_thermal_info_t thermal_info; - memset(&thermal_info, 0, sizeof(thermal_info)); - uint32_t thermal_arr[] = { THERMAL_OID_FRONT_MAC, - THERMAL_OID_REAR_MAC, - THERMAL_OID_CPU1, - THERMAL_OID_CPU2, - THERMAL_OID_CPU3, - THERMAL_OID_CPU4 }; - max_temp = 0; - - for (i=0; i max_temp) { - max_temp = temp; - } - } - *thermal_temp = max_temp; - - return ONLP_STATUS_OK; -} - -int -onlp_sysi_platform_manage_fans(void) -{ - int rc, is_up ,new_temp, thermal_temp, diff; - static int new_perc = 0, ori_perc = 0; - static int ori_temp = 0; - onlp_thermal_info_t thermal_info; - memset(&thermal_info, 0, sizeof(thermal_info)); - - /* get new temperature */ - if ((rc = platform_thermal_temp_get(&thermal_temp)) != ONLP_STATUS_OK) { - goto _EXIT; - } - - new_temp = thermal_temp; - diff = new_temp - ori_temp; - - if (diff == 0) { - goto _EXIT; - } else { - is_up = (diff > 0 ? 1 : 0); - } - - new_perc = decide_fan_percentage(is_up, new_temp); - - if (ori_perc == new_perc) { - goto _EXIT; - } - - - AIM_LOG_INFO("The Fan Speeds Percent are now at %d%%", new_perc); - - if ((rc = onlp_fani_percentage_set(THERMAL_OID_REAR_MAC, new_perc)) != ONLP_STATUS_OK) { - goto _EXIT; - } - - /* update */ - ori_perc = new_perc; - ori_temp = new_temp; - -_EXIT : - return rc; -} - -int -onlp_sysi_platform_manage_leds(void) -{ - int psu1_status, psu2_status, rc, i; - static int pre_psu1_status = 0, pre_psu2_status = 0, pre_fan_status = 0; - - //------------------------------- - static int pre_fan_tray_status[4] = {0}; - int fan_tray_id, sum, total = 0; - onlp_led_status_t fan_tray_status[SYS_FAN_NUM]; - //------------------------------- - - onlp_psu_info_t psu_info; - onlp_fan_info_t fan_info; - - //-------- ----------------------- - memset(&fan_tray_status, 0, sizeof(fan_tray_status)); - //------------------------------- - - memset(&psu_info, 0, sizeof(onlp_psu_info_t)); - memset(&fan_info, 0, sizeof(onlp_fan_info_t)); - uint32_t fan_arr[] = { FAN_OID_FAN1, - FAN_OID_FAN2, - FAN_OID_FAN3, - FAN_OID_FAN4, }; - - /* PSU LED CTRL */ - if ((rc = onlp_psui_info_get(PSU_OID_PSU1, &psu_info)) != ONLP_STATUS_OK) { - goto _EXIT; - } - - psu1_status = psu_info.status; - if (psu1_status != pre_psu1_status) { - 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); - } - - if (rc != ONLP_STATUS_OK) { - goto _EXIT; - } - pre_psu1_status = psu1_status; - } - - if ((rc = onlp_psui_info_get(PSU_OID_PSU2, &psu_info)) != ONLP_STATUS_OK) { - goto _EXIT; - } - - psu2_status = psu_info.status; - if( psu2_status != pre_psu2_status) { - 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); - } - - if (rc != ONLP_STATUS_OK) { - goto _EXIT; - } - pre_psu2_status = psu2_status; - } - - /* FAN LED CTRL */ - 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 (rc != ONLP_STATUS_OK) { - goto _EXIT; - } - - pre_fan_tray_status[fan_tray_id - 5] = sum; - } - } - - if (total != pre_fan_status) { - if (total == (ONLP_LED_STATUS_PRESENT * 4)) { - 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; - } - -_EXIT : - return rc; -} - -int -onlp_sysi_platform_info_get(onlp_platform_info_t* pi) -{ - int rc; - if ((rc = sysi_platform_info_get(pi)) != ONLP_STATUS_OK) { - return ONLP_STATUS_E_INTERNAL; - } - - return ONLP_STATUS_OK; -} - diff --git a/packages/platforms/ingrasys/x86-64/s9230-64x/onlp/builds/x86_64_ingrasys_s9230_64x/module/src/thermali.c b/packages/platforms/ingrasys/x86-64/s9230-64x/onlp/builds/x86_64_ingrasys_s9230_64x/module/src/thermali.c deleted file mode 100755 index b4b4a196d..000000000 --- a/packages/platforms/ingrasys/x86-64/s9230-64x/onlp/builds/x86_64_ingrasys_s9230_64x/module/src/thermali.c +++ /dev/null @@ -1,221 +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. - * - * - ************************************************************ - * - * Thermal Sensor Platform Implementation. - * - ***********************************************************/ -#include -#include -#include "x86_64_ingrasys_s9230_64x_log.h" -#include "platform_lib.h" - -static onlp_thermal_info_t thermal_info[] = { - { }, /* Not used */ - { { THERMAL_OID_CPU1, "CPU Thermal 1", 0}, - ONLP_THERMAL_STATUS_PRESENT, - ONLP_THERMAL_CAPS_ALL, 0, THERMAL_THRESHOLD_INIT_DEFAULTS - }, - { { THERMAL_OID_CPU2, "CPU Thermal 2", 0}, - ONLP_THERMAL_STATUS_PRESENT, - ONLP_THERMAL_CAPS_ALL, 0, THERMAL_THRESHOLD_INIT_DEFAULTS - }, - { { THERMAL_OID_CPU3, "CPU Thermal 3", 0}, - ONLP_THERMAL_STATUS_PRESENT, - ONLP_THERMAL_CAPS_ALL, 0, THERMAL_THRESHOLD_INIT_DEFAULTS - }, - { { THERMAL_OID_CPU4, "CPU Thermal 4", 0}, - ONLP_THERMAL_STATUS_PRESENT, - ONLP_THERMAL_CAPS_ALL, 0, THERMAL_THRESHOLD_INIT_DEFAULTS - }, - { { THERMAL_OID_REAR_PANEL, "Rear Panel", 0}, - ONLP_THERMAL_STATUS_PRESENT, - ONLP_THERMAL_CAPS_ALL, 0, THERMAL_THRESHOLD_INIT_DEFAULTS - }, - { { THERMAL_OID_REAR_MAC, "Rear MAC", 0}, - ONLP_THERMAL_STATUS_PRESENT, - ONLP_THERMAL_CAPS_ALL, 0, THERMAL_THRESHOLD_INIT_DEFAULTS - }, - { { THERMAL_OID_FRONT_PANEL, "Front Panel", 0}, - ONLP_THERMAL_STATUS_PRESENT, - ONLP_THERMAL_CAPS_ALL, 0, THERMAL_THRESHOLD_INIT_DEFAULTS - }, - { { THERMAL_OID_FRONT_MAC, "FRONT MAC", 0}, - ONLP_THERMAL_STATUS_PRESENT, - ONLP_THERMAL_CAPS_ALL, 0, THERMAL_THRESHOLD_INIT_DEFAULTS - }, - { { THERMAL_OID_BMC_BOARD, "BMC Board", 0}, - ONLP_THERMAL_STATUS_PRESENT, - ONLP_THERMAL_CAPS_GET_TEMPERATURE, 0 - }, - { { THERMAL_OID_CPU_BOARD, "CPU Board", 0}, - ONLP_THERMAL_STATUS_PRESENT, - ONLP_THERMAL_CAPS_GET_TEMPERATURE, 0 - }, - { { THERMAL_OID_PSU1_1, "PSU-1 Thermal 1", PSU_OID_PSU1}, - ONLP_THERMAL_STATUS_PRESENT, - ONLP_THERMAL_CAPS_GET_TEMPERATURE, 0 - }, - { { THERMAL_OID_PSU1_2, "PSU-1 Thermal 2", PSU_OID_PSU1}, - ONLP_THERMAL_STATUS_PRESENT, - ONLP_THERMAL_CAPS_GET_TEMPERATURE, 0 - }, - { { THERMAL_OID_PSU2_1, "PSU-2 Thermal 1", PSU_OID_PSU2}, - ONLP_THERMAL_STATUS_PRESENT, - ONLP_THERMAL_CAPS_GET_TEMPERATURE, 0 - }, - { { THERMAL_OID_PSU2_2, "PSU-2 Thermal 2", PSU_OID_PSU2}, - ONLP_THERMAL_STATUS_PRESENT, - ONLP_THERMAL_CAPS_GET_TEMPERATURE, 0 - } -}; - -/* - * This will be called to intiialize the thermali subsystem. - */ -int -onlp_thermali_init(void) -{ - return ONLP_STATUS_OK; -} - -static int -lm_thermal_info_get(onlp_thermal_info_t* info, int id) -{ - int rv; - char sysfs_path[64]; - - switch (id) { - case THERMAL_ID_REAR_PANEL: - snprintf(sysfs_path, sizeof(sysfs_path), SYS_REAR_PANEL_TEMP_PREFIX "temp%d_input", 1); - break; - case THERMAL_ID_REAR_MAC: - snprintf(sysfs_path, sizeof(sysfs_path), SYS_REAR_MAC_TEMP_PREFIX "temp%d_input", 1); - break; - case THERMAL_ID_FRONT_PANEL: - snprintf(sysfs_path, sizeof(sysfs_path), SYS_FRONT_PANEL_PREFIX "temp%d_input", 1); - break; - case THERMAL_ID_FRONT_MAC: - snprintf(sysfs_path, sizeof(sysfs_path), SYS_FRONT_MAC_PREFIX "temp%d_input", 1); - break; - case THERMAL_ID_BMC_BOARD: - snprintf(sysfs_path, sizeof(sysfs_path), SYS_BMC_BOARD_PREFIX "temp%d_input", 1); - break; - case THERMAL_ID_CPU_BOARD: - snprintf(sysfs_path, sizeof(sysfs_path), SYS_CPU_BOARD_PREFIX "temp%d_input", 1); - break; - } - - rv = onlp_file_read_int(&info->mcelsius, sysfs_path); - - if(rv == ONLP_STATUS_E_INTERNAL) { - return rv; - } - - if(rv == ONLP_STATUS_E_MISSING) { - info->status &= ~1; - return 0; - } - - return ONLP_STATUS_OK; -} - -static int -cpu_thermal_info_get(onlp_thermal_info_t* info, int id) -{ - int rv; - int offset; - - offset = 1; - id = id + offset; - rv = onlp_file_read_int(&info->mcelsius, - SYS_CPU_TEMP_PREFIX "temp%d_input", id); - - if(rv == ONLP_STATUS_E_INTERNAL) { - return rv; - } - - if(rv == ONLP_STATUS_E_MISSING) { - info->status &= ~1; - return 0; - } - - return ONLP_STATUS_OK; -} - -int -psu_thermal_info_get(onlp_thermal_info_t* info, int id) -{ - int rv; - - rv = psu_thermal_get(info, id); - if(rv == ONLP_STATUS_E_INTERNAL) { - return rv; - } - - 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 sensor_id, rc; - sensor_id = ONLP_OID_ID_GET(id); - - *info = thermal_info[sensor_id]; - info->caps |= ONLP_THERMAL_CAPS_GET_TEMPERATURE; - - switch (sensor_id) { - case THERMAL_ID_CPU1: - case THERMAL_ID_CPU2: - case THERMAL_ID_CPU3: - case THERMAL_ID_CPU4: - rc = cpu_thermal_info_get(info, sensor_id); - break; - case THERMAL_ID_REAR_PANEL: - case THERMAL_ID_REAR_MAC: - case THERMAL_ID_FRONT_PANEL: - case THERMAL_ID_FRONT_MAC: - case THERMAL_ID_BMC_BOARD: - case THERMAL_ID_CPU_BOARD: - rc = lm_thermal_info_get(info, sensor_id); - break; - case THERMAL_ID_PSU1_1: - case THERMAL_ID_PSU1_2: - case THERMAL_ID_PSU2_1: - case THERMAL_ID_PSU2_2: - rc = psu_thermal_info_get(info, sensor_id); - break; - default: - return ONLP_STATUS_E_INTERNAL; - break; - } - return rc; -} diff --git a/packages/platforms/ingrasys/x86-64/s9230-64x/onlp/builds/x86_64_ingrasys_s9230_64x/module/src/x86_64_ingrasys_s9230_64x_config.c b/packages/platforms/ingrasys/x86-64/s9230-64x/onlp/builds/x86_64_ingrasys_s9230_64x/module/src/x86_64_ingrasys_s9230_64x_config.c deleted file mode 100755 index a854b2bee..000000000 --- a/packages/platforms/ingrasys/x86-64/s9230-64x/onlp/builds/x86_64_ingrasys_s9230_64x/module/src/x86_64_ingrasys_s9230_64x_config.c +++ /dev/null @@ -1,96 +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 __x86_64_ingrasys_s9230_64x_config_STRINGIFY_NAME(_x) #_x -#define __x86_64_ingrasys_s9230_64x_config_STRINGIFY_VALUE(_x) __x86_64_ingrasys_s9230_64x_config_STRINGIFY_NAME(_x) -x86_64_ingrasys_s9230_64x_config_settings_t x86_64_ingrasys_s9230_64x_config_settings[] = -{ -#ifdef X86_64_INGRASYS_S9230_64X_CONFIG_INCLUDE_LOGGING - { __x86_64_ingrasys_s9230_64x_config_STRINGIFY_NAME(X86_64_INGRASYS_S9230_64X_CONFIG_INCLUDE_LOGGING), __x86_64_ingrasys_s9230_64x_config_STRINGIFY_VALUE(X86_64_INGRASYS_S9230_64X_CONFIG_INCLUDE_LOGGING) }, -#else -{ X86_64_INGRASYS_S9230_64X_CONFIG_INCLUDE_LOGGING(__x86_64_ingrasys_s9230_64x_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_INGRASYS_S9230_64X_CONFIG_LOG_OPTIONS_DEFAULT - { __x86_64_ingrasys_s9230_64x_config_STRINGIFY_NAME(X86_64_INGRASYS_S9230_64X_CONFIG_LOG_OPTIONS_DEFAULT), __x86_64_ingrasys_s9230_64x_config_STRINGIFY_VALUE(X86_64_INGRASYS_S9230_64X_CONFIG_LOG_OPTIONS_DEFAULT) }, -#else -{ X86_64_INGRASYS_S9230_64X_CONFIG_LOG_OPTIONS_DEFAULT(__x86_64_ingrasys_s9230_64x_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_INGRASYS_S9230_64X_CONFIG_LOG_BITS_DEFAULT - { __x86_64_ingrasys_s9230_64x_config_STRINGIFY_NAME(X86_64_INGRASYS_S9230_64X_CONFIG_LOG_BITS_DEFAULT), __x86_64_ingrasys_s9230_64x_config_STRINGIFY_VALUE(X86_64_INGRASYS_S9230_64X_CONFIG_LOG_BITS_DEFAULT) }, -#else -{ X86_64_INGRASYS_S9230_64X_CONFIG_LOG_BITS_DEFAULT(__x86_64_ingrasys_s9230_64x_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_INGRASYS_S9230_64X_CONFIG_LOG_CUSTOM_BITS_DEFAULT - { __x86_64_ingrasys_s9230_64x_config_STRINGIFY_NAME(X86_64_INGRASYS_S9230_64X_CONFIG_LOG_CUSTOM_BITS_DEFAULT), __x86_64_ingrasys_s9230_64x_config_STRINGIFY_VALUE(X86_64_INGRASYS_S9230_64X_CONFIG_LOG_CUSTOM_BITS_DEFAULT) }, -#else -{ X86_64_INGRASYS_S9230_64X_CONFIG_LOG_CUSTOM_BITS_DEFAULT(__x86_64_ingrasys_s9230_64x_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_INGRASYS_S9230_64X_CONFIG_PORTING_STDLIB - { __x86_64_ingrasys_s9230_64x_config_STRINGIFY_NAME(X86_64_INGRASYS_S9230_64X_CONFIG_PORTING_STDLIB), __x86_64_ingrasys_s9230_64x_config_STRINGIFY_VALUE(X86_64_INGRASYS_S9230_64X_CONFIG_PORTING_STDLIB) }, -#else -{ X86_64_INGRASYS_S9230_64X_CONFIG_PORTING_STDLIB(__x86_64_ingrasys_s9230_64x_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_INGRASYS_S9230_64X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS - { __x86_64_ingrasys_s9230_64x_config_STRINGIFY_NAME(X86_64_INGRASYS_S9230_64X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS), __x86_64_ingrasys_s9230_64x_config_STRINGIFY_VALUE(X86_64_INGRASYS_S9230_64X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS) }, -#else -{ X86_64_INGRASYS_S9230_64X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS(__x86_64_ingrasys_s9230_64x_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_INGRASYS_S9230_64X_CONFIG_INCLUDE_UCLI - { __x86_64_ingrasys_s9230_64x_config_STRINGIFY_NAME(X86_64_INGRASYS_S9230_64X_CONFIG_INCLUDE_UCLI), __x86_64_ingrasys_s9230_64x_config_STRINGIFY_VALUE(X86_64_INGRASYS_S9230_64X_CONFIG_INCLUDE_UCLI) }, -#else -{ X86_64_INGRASYS_S9230_64X_CONFIG_INCLUDE_UCLI(__x86_64_ingrasys_s9230_64x_config_STRINGIFY_NAME), "__undefined__" }, -#endif - { NULL, NULL } -}; -#undef __x86_64_ingrasys_s9230_64x_config_STRINGIFY_VALUE -#undef __x86_64_ingrasys_s9230_64x_config_STRINGIFY_NAME - -const char* -x86_64_ingrasys_s9230_64x_config_lookup(const char* setting) -{ - int i; - for(i = 0; x86_64_ingrasys_s9230_64x_config_settings[i].name; i++) { - if(!strcmp(x86_64_ingrasys_s9230_64x_config_settings[i].name, setting)) { - return x86_64_ingrasys_s9230_64x_config_settings[i].value; - } - } - return NULL; -} - -int -x86_64_ingrasys_s9230_64x_config_show(struct aim_pvs_s* pvs) -{ - int i; - for(i = 0; x86_64_ingrasys_s9230_64x_config_settings[i].name; i++) { - aim_printf(pvs, "%s = %s\n", x86_64_ingrasys_s9230_64x_config_settings[i].name, x86_64_ingrasys_s9230_64x_config_settings[i].value); - } - return i; -} - -/* */ - diff --git a/packages/platforms/ingrasys/x86-64/s9230-64x/onlp/builds/x86_64_ingrasys_s9230_64x/module/src/x86_64_ingrasys_s9230_64x_enums.c b/packages/platforms/ingrasys/x86-64/s9230-64x/onlp/builds/x86_64_ingrasys_s9230_64x/module/src/x86_64_ingrasys_s9230_64x_enums.c deleted file mode 100755 index 1c21cea73..000000000 --- a/packages/platforms/ingrasys/x86-64/s9230-64x/onlp/builds/x86_64_ingrasys_s9230_64x/module/src/x86_64_ingrasys_s9230_64x_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/ingrasys/x86-64/s9230-64x/onlp/builds/x86_64_ingrasys_s9230_64x/module/src/x86_64_ingrasys_s9230_64x_int.h b/packages/platforms/ingrasys/x86-64/s9230-64x/onlp/builds/x86_64_ingrasys_s9230_64x/module/src/x86_64_ingrasys_s9230_64x_int.h deleted file mode 100755 index d89e52979..000000000 --- a/packages/platforms/ingrasys/x86-64/s9230-64x/onlp/builds/x86_64_ingrasys_s9230_64x/module/src/x86_64_ingrasys_s9230_64x_int.h +++ /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. - * - * - ************************************************************ - * - * - * - ***********************************************************/ - -#ifndef __x86_64_ingrasys_s9230_64x_INT_H__ -#define __x86_64_ingrasys_s9230_64x_INT_H__ - -#endif /* __x86_64_ingrasys_s9230_64x_INT_H__ */ diff --git a/packages/platforms/ingrasys/x86-64/s9230-64x/onlp/builds/x86_64_ingrasys_s9230_64x/module/src/x86_64_ingrasys_s9230_64x_log.c b/packages/platforms/ingrasys/x86-64/s9230-64x/onlp/builds/x86_64_ingrasys_s9230_64x/module/src/x86_64_ingrasys_s9230_64x_log.c deleted file mode 100755 index 2e2ce68cf..000000000 --- a/packages/platforms/ingrasys/x86-64/s9230-64x/onlp/builds/x86_64_ingrasys_s9230_64x/module/src/x86_64_ingrasys_s9230_64x_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 "x86_64_ingrasys_s9230_64x_log.h" -/* - * x86_64_ingrasys_s9230_64x log struct. - */ -AIM_LOG_STRUCT_DEFINE( - X86_64_INGRASYS_S9230_64X_CONFIG_LOG_OPTIONS_DEFAULT, - X86_64_INGRASYS_S9230_64X_CONFIG_LOG_BITS_DEFAULT, - NULL, /* Custom log map */ - X86_64_INGRASYS_S9230_64X_CONFIG_LOG_CUSTOM_BITS_DEFAULT - ); - diff --git a/packages/platforms/ingrasys/x86-64/s9230-64x/onlp/builds/x86_64_ingrasys_s9230_64x/module/src/x86_64_ingrasys_s9230_64x_log.h b/packages/platforms/ingrasys/x86-64/s9230-64x/onlp/builds/x86_64_ingrasys_s9230_64x/module/src/x86_64_ingrasys_s9230_64x_log.h deleted file mode 100755 index 67815d0bc..000000000 --- a/packages/platforms/ingrasys/x86-64/s9230-64x/onlp/builds/x86_64_ingrasys_s9230_64x/module/src/x86_64_ingrasys_s9230_64x_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 __x86_64_ingrasys_s9230_64x_LOG_H__ -#define __x86_64_ingrasys_s9230_64x_LOG_H__ - -#define AIM_LOG_MODULE_NAME x86_64_ingrasys_s9230_64x -#include - -#endif /* __x86_64_ingrasys_s9230_64x_LOG_H__ */ diff --git a/packages/platforms/ingrasys/x86-64/s9230-64x/onlp/builds/x86_64_ingrasys_s9230_64x/module/src/x86_64_ingrasys_s9230_64x_module.c b/packages/platforms/ingrasys/x86-64/s9230-64x/onlp/builds/x86_64_ingrasys_s9230_64x/module/src/x86_64_ingrasys_s9230_64x_module.c deleted file mode 100755 index d88ed6bb9..000000000 --- a/packages/platforms/ingrasys/x86-64/s9230-64x/onlp/builds/x86_64_ingrasys_s9230_64x/module/src/x86_64_ingrasys_s9230_64x_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 "x86_64_ingrasys_s9230_64x_log.h" - -static int -datatypes_init__(void) -{ -#define INGRASYS_S9230_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_ingrasys_s9230_64x_module_init__(void) -{ - AIM_LOG_STRUCT_REGISTER(); - datatypes_init__(); -} - -int __onlp_platform_version__ = 1; diff --git a/packages/platforms/ingrasys/x86-64/s9230-64x/onlp/builds/x86_64_ingrasys_s9230_64x/module/src/x86_64_ingrasys_s9230_64x_ucli.c b/packages/platforms/ingrasys/x86-64/s9230-64x/onlp/builds/x86_64_ingrasys_s9230_64x/module/src/x86_64_ingrasys_s9230_64x_ucli.c deleted file mode 100755 index 69ee78b27..000000000 --- a/packages/platforms/ingrasys/x86-64/s9230-64x/onlp/builds/x86_64_ingrasys_s9230_64x/module/src/x86_64_ingrasys_s9230_64x_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 X86_64_INGRASYS_S9230_64X_CONFIG_INCLUDE_UCLI == 1 - -#include -#include -#include - -static ucli_status_t -x86_64_ingrasys_s9230_64x_ucli_ucli__config__(ucli_context_t* uc) -{ - UCLI_HANDLER_MACRO_MODULE_CONFIG(x86_64_ingrasys_s9230_64x) -} - -/* */ -/****************************************************************************** - * - * These handler table(s) were autogenerated from the symbols in this - * source file. - * - *****************************************************************************/ -static ucli_command_handler_f x86_64_ingrasys_s9230_64x_ucli_ucli_handlers__[] = -{ - x86_64_ingrasys_s9230_64x_ucli_ucli__config__, - NULL -}; -/******************************************************************************/ -/* */ - -static ucli_module_t -x86_64_ingrasys_s9230_64x_ucli_module__ = - { - "x86_64_ingrasys_s9230_64x_ucli", - NULL, - x86_64_ingrasys_s9230_64x_ucli_ucli_handlers__, - NULL, - NULL, - }; - -ucli_node_t* -x86_64_ingrasys_s9230_64x_ucli_node_create(void) -{ - ucli_node_t* n; - ucli_module_init(&x86_64_ingrasys_s9230_64x_ucli_module__); - n = ucli_node_create("x86_64_ingrasys_s9230_64x", NULL, &x86_64_ingrasys_s9230_64x_ucli_module__); - ucli_node_subnode_add(n, ucli_module_log_node_create("x86_64_ingrasys_s9230_64x")); - return n; -} - -#else -void* -x86_64_ingrasys_s9230_64x_ucli_node_create(void) -{ - return NULL; -} -#endif - diff --git a/packages/platforms/ingrasys/x86-64/s9230-64x/platform-config/Makefile b/packages/platforms/ingrasys/x86-64/s9230-64x/platform-config/Makefile deleted file mode 100755 index 003238cf6..000000000 --- a/packages/platforms/ingrasys/x86-64/s9230-64x/platform-config/Makefile +++ /dev/null @@ -1 +0,0 @@ -include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/ingrasys/x86-64/s9230-64x/platform-config/r0/Makefile b/packages/platforms/ingrasys/x86-64/s9230-64x/platform-config/r0/Makefile deleted file mode 100755 index 003238cf6..000000000 --- a/packages/platforms/ingrasys/x86-64/s9230-64x/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/ingrasys/x86-64/s9230-64x/platform-config/r0/PKG.yml b/packages/platforms/ingrasys/x86-64/s9230-64x/platform-config/r0/PKG.yml deleted file mode 100755 index 42dd7cc41..000000000 --- a/packages/platforms/ingrasys/x86-64/s9230-64x/platform-config/r0/PKG.yml +++ /dev/null @@ -1 +0,0 @@ -!include $ONL_TEMPLATES/platform-config-platform.yml ARCH=amd64 VENDOR=ingrasys BASENAME=x86-64-ingrasys-s9230-64x REVISION=r0 diff --git a/packages/platforms/ingrasys/x86-64/s9230-64x/platform-config/r0/src/lib/x86-64-ingrasys-s9230-64x-r0.yml b/packages/platforms/ingrasys/x86-64/s9230-64x/platform-config/r0/src/lib/x86-64-ingrasys-s9230-64x-r0.yml deleted file mode 100755 index 10749fc56..000000000 --- a/packages/platforms/ingrasys/x86-64/s9230-64x/platform-config/r0/src/lib/x86-64-ingrasys-s9230-64x-r0.yml +++ /dev/null @@ -1,30 +0,0 @@ ---- - -###################################################################### -# -# platform-config for x86-64-ingrasys-s9230-64x -# -###################################################################### - -x86-64-ingrasys-s9230-64x-r0: - - grub: - - serial: >- - --port=0x3f8 - --speed=115200 - --word=8 - --parity=no - --stop=1 - - kernel: - <<: *kernel-3-16 - - args: >- - console=ttyS0,115200n8 - - ##network - ## interfaces: - ## ma1: - ## name: ~ - ## syspath: pci0000:00/0000:00:03.0 diff --git a/packages/platforms/ingrasys/x86-64/s9230-64x/platform-config/r0/src/python/x86_64_ingrasys_s9230_64x_r0/__init__.py b/packages/platforms/ingrasys/x86-64/s9230-64x/platform-config/r0/src/python/x86_64_ingrasys_s9230_64x_r0/__init__.py deleted file mode 100755 index 9ef164bd7..000000000 --- a/packages/platforms/ingrasys/x86-64/s9230-64x/platform-config/r0/src/python/x86_64_ingrasys_s9230_64x_r0/__init__.py +++ /dev/null @@ -1,200 +0,0 @@ -from onl.platform.base import * -from onl.platform.ingrasys import * -import os - -class OnlPlatform_x86_64_ingrasys_s9230_64x_r0(OnlPlatformIngrasys): - PLATFORM='x86-64-ingrasys-s9230-64x-r0' - MODEL="S9230-64X" - SYS_OBJECT_ID=".9230.64" - - def baseconfig(self): - - # fp port to phy port mapping - fp2phy_array=( 1, 2, 5, 6, 9, 10, 13, 14, 17, 18, 21, 22, 25, 26, 29, 30, - 33, 34, 37, 38, 41, 42, 45, 46, 49, 50, 53, 54, 57, 58, 61, 62, - 3, 4, 7, 8, 11, 12, 15, 16, 19, 20, 23, 24, 27, 28, 31, 32, - 35, 36, 39, 40, 43, 44, 47, 48, 51, 52, 55, 56, 59, 60, 63, 64) - - self.insmod("eeprom_mb") - # init SYS EEPROM devices - self.new_i2c_devices( - [ - # _i2c_mb_eeprom_init - ('mb_eeprom', 0x55, 0), - - # _i2c_cb_eeprom_init - ('mb_eeprom', 0x51, 0), - ] - ) - - os.system("modprobe w83795") - os.system("modprobe eeprom") - os.system("modprobe gpio_pca953x") - self.insmod("optoe") - - ########### initialize I2C bus 0 ########### - # init PCA9548 - self.new_i2c_devices( - [ - ('pca9548', 0x70, 0), #pca9548_0 - ('pca9548', 0x73, 0), #pca9548_1 - ('pca9546', 0x72, 0), #pca9546_0 - ('pca9546', 0x71, 20), #pca9546_1 - ('pca9548', 0x71, 19), #pca9548_2 - ('pca9548', 0x74, 25), #pca9548_3 - ('pca9548', 0x74, 26), #pca9548_4 - ('pca9548', 0x74, 27), #pca9548_5 - ('pca9548', 0x74, 28), #pca9548_6 - ('pca9548', 0x74, 29), #pca9548_7 - ('pca9548', 0x74, 30), #pca9548_8 - ('pca9548', 0x74, 31), #pca9548_9 - ('pca9548', 0x74, 32), #pca9548_10 - ] - ) - # _i2c_hwm_init - os.system("i2cset -y -r 16 0x2f 0x00 0x80") - os.system("i2cset -y -r 16 0x2f 0x01 0x9C") - os.system("i2cset -y -r 16 0x2f 0x04 0x00") - os.system("i2cset -y -r 16 0x2f 0x06 0xFF") - os.system("i2cset -y -r 16 0x2f 0x07 0x00") - os.system("i2cset -y -r 16 0x2f 0x01 0x1C") - os.system("i2cset -y -r 16 0x2f 0x00 0x82") - os.system("i2cset -y -r 16 0x2f 0x0F 0x00") - os.system("i2cset -y -r 16 0x2f 0x18 0x84") - os.system("i2cset -y -r 16 0x2f 0x19 0x84") - - # _i2c_io_exp_init - # need to init BMC io expander first due to some io expander are reset default - # Init BMC INT & HW ID IO Expander - os.system("i2cset -y -r 0 0x24 6 0xFF") - os.system("i2cset -y -r 0 0x24 7 0xFF") - os.system("i2cset -y -r 0 0x24 4 0x00") - os.system("i2cset -y -r 0 0x24 5 0x00") - - # Init BMC PSU status IO Expander - os.system("i2cset -y -r 0 0x25 2 0x00") - os.system("i2cset -y -r 0 0x25 3 0x00") - os.system("i2cset -y -r 0 0x25 6 0xDB") - os.system("i2cset -y -r 0 0x25 7 0xE3") - os.system("i2cset -y -r 0 0x25 4 0x00") - os.system("i2cset -y -r 0 0x25 5 0x00") - - # Init BMC RST and SEL IO Expander - os.system("i2cset -y -r 0 0x26 2 0x3F") - os.system("i2cset -y -r 0 0x26 3 0x1F") - os.system("i2cset -y -r 0 0x26 6 0xC0") - os.system("i2cset -y -r 0 0x26 7 0x00") - os.system("i2cset -y -r 0 0x26 4 0x00") - os.system("i2cset -y -r 0 0x26 5 0x00") - - # Init System LED & HW ID IO Expander - os.system("i2cset -y -r 10 0x76 2 0x00") - os.system("i2cset -y -r 10 0x76 6 0x00") - os.system("i2cset -y -r 10 0x76 7 0xFF") - os.system("i2cset -y -r 10 0x76 4 0x00") - os.system("i2cset -y -r 10 0x76 5 0x00") - - # Init FAN Board Status IO Expander - os.system("i2cset -y -r 0 0x20 2 0x11") - os.system("i2cset -y -r 0 0x20 3 0x11") - os.system("i2cset -y -r 0 0x20 6 0xCC") - os.system("i2cset -y -r 0 0x20 7 0xCC") - os.system("i2cset -y -r 0 0x20 4 0x00") - os.system("i2cset -y -r 0 0x20 5 0x00") - - # Init System SEL and RST IO Expander - os.system("i2cset -y -r 11 0x76 2 0x0F") - os.system("i2cset -y -r 11 0x76 3 0xDF") - os.system("i2cset -y -r 11 0x76 6 0x09") - os.system("i2cset -y -r 11 0x76 7 0x1F") - os.system("i2cset -y -r 11 0x76 4 0x00") - os.system("i2cset -y -r 11 0x76 5 0x00") - - # Init CPU CPLD IO Expander - os.system("i2cset -y -r 0 0x77 6 0xFF") - os.system("i2cset -y -r 0 0x77 7 0xFF") - os.system("i2cset -y -r 0 0x77 4 0x00") - os.system("i2cset -y -r 0 0x77 5 0x00") - - # _i2c_sensors_init - - self.new_i2c_devices( - [ - # lm75_1 Rear Panel, hwmon1 - ('lm75', 0x4D, 6), - - # lm75_2 Rear MAC, hwmon2 - ('lm75', 0x4E, 6), - - # lm75_3 Front Panel, hwmon3 - ('lm75', 0x4D, 7), - - # lm75_4 Front MAC, hwmon4 - ('lm75', 0x4E, 7), - - # tmp75 BMC board thermal, hwmon5 - ('tmp75', 0x4A, 16), - - # tmp75 CPU board thermal, hwmon6 - ('tmp75', 0x4F, 0), - - # w83795, hwmon7 - ('w83795adg', 0x2F, 16), - - ] - ) - - # _i2c_cpld_init - self.insmod("ingrasys_s9230_64x_i2c_cpld") - - # add cpld 1~5 to sysfs - for i in range(1, 6): - self.new_i2c_device('ingrasys_cpld%d' % i, 0x33, i) - - # _i2c_psu_init - - self.insmod("ingrasys_s9230_64x_psu") - - # add psu 1~2 to sysfs - for i in range(1, 3): - self.new_i2c_device('psu%d' % i, 0x50, 19-i) - - # _i2c_qsfp_eeprom_init - for i in range(1, 65): - phy_port = fp2phy_array[i-1] - port_group = (phy_port-1)/8 - eeprom_busbase = 33 + (port_group * 8) - eeprom_busshift = (phy_port-1)%8 - eeprom_bus = eeprom_busbase + eeprom_busshift - self.new_i2c_device('optoe1', 0x50, eeprom_bus) - - # _i2c_sfp_eeprom_init - for i in range(1, 3): - self.new_i2c_device('sff8436', 0x50, 20+i) - - # _i2c_fan_speed_init - os.system("echo 120 > /sys/class/hwmon/hwmon7/device/pwm2") - - # set 10gmux to cpu - os.system("i2cset -m 0xff -y -r 13 0x67 0x06 0x18") - os.system("i2cset -m 0xff -y -r 13 0x67 0x2c 0x00") - os.system("i2cset -m 0xff -y -r 13 0x67 0x35 0x80") - os.system("i2cset -m 0xff -y -r 13 0x67 0x34 0xab") - os.system("i2cset -m 0xff -y -r 13 0x67 0x16 0x01") - os.system("i2cset -m 0xff -y -r 13 0x67 0x18 0x80") - os.system("i2cset -m 0xff -y -r 13 0x67 0x17 0xab") - os.system("i2cset -m 0xff -y -r 13 0x67 0x3a 0x00") - os.system("i2cset -m 0xff -y -r 13 0x67 0x41 0x00") - os.system("i2cset -m 0xff -y -r 13 0x67 0x43 0x80") - os.system("i2cset -m 0xff -y -r 13 0x67 0x42 0xab") - os.system("i2cset -m 0xff -y -r 13 0x67 0x24 0x01") - os.system("i2cset -m 0xff -y -r 13 0x67 0x26 0x80") - os.system("i2cset -m 0xff -y -r 13 0x67 0x25 0xab") - os.system("echo 0xf3 > /sys/class/i2c-dev/i2c-1/device/1-0033/cpld_10gmux_config") - - # turn on sys led - os.system("i2cset -m 0x80 -y -r 10 0x76 2 0x80") - - return True - - diff --git a/packages/platforms/ingrasys/x86-64/s9280-64x/.gitignore b/packages/platforms/ingrasys/x86-64/s9280-64x/.gitignore deleted file mode 100755 index 9f7b1342f..000000000 --- a/packages/platforms/ingrasys/x86-64/s9280-64x/.gitignore +++ /dev/null @@ -1 +0,0 @@ -onlpdump.mk diff --git a/packages/platforms/ingrasys/x86-64/s9280-64x/Makefile b/packages/platforms/ingrasys/x86-64/s9280-64x/Makefile deleted file mode 100755 index 003238cf6..000000000 --- a/packages/platforms/ingrasys/x86-64/s9280-64x/Makefile +++ /dev/null @@ -1 +0,0 @@ -include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/ingrasys/x86-64/s9280-64x/modules/Makefile b/packages/platforms/ingrasys/x86-64/s9280-64x/modules/Makefile deleted file mode 100755 index 003238cf6..000000000 --- a/packages/platforms/ingrasys/x86-64/s9280-64x/modules/Makefile +++ /dev/null @@ -1 +0,0 @@ -include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/ingrasys/x86-64/s9280-64x/modules/PKG.yml b/packages/platforms/ingrasys/x86-64/s9280-64x/modules/PKG.yml deleted file mode 100755 index a9d3a2dfb..000000000 --- a/packages/platforms/ingrasys/x86-64/s9280-64x/modules/PKG.yml +++ /dev/null @@ -1 +0,0 @@ -!include $ONL_TEMPLATES/platform-modules.yml ARCH=amd64 VENDOR=ingrasys BASENAME=x86-64-ingrasys-s9280-64x KERNELS="onl-kernel-3.16-lts-x86-64-all:amd64" diff --git a/packages/platforms/ingrasys/x86-64/s9280-64x/modules/builds/.gitignore b/packages/platforms/ingrasys/x86-64/s9280-64x/modules/builds/.gitignore deleted file mode 100644 index a65b41774..000000000 --- a/packages/platforms/ingrasys/x86-64/s9280-64x/modules/builds/.gitignore +++ /dev/null @@ -1 +0,0 @@ -lib diff --git a/packages/platforms/ingrasys/x86-64/s9280-64x/modules/builds/Makefile b/packages/platforms/ingrasys/x86-64/s9280-64x/modules/builds/Makefile deleted file mode 100644 index 00649dbbc..000000000 --- a/packages/platforms/ingrasys/x86-64/s9280-64x/modules/builds/Makefile +++ /dev/null @@ -1,6 +0,0 @@ -KERNELS := onl-kernel-3.16-lts-x86-64-all:amd64 -KMODULES := $(wildcard *.c) -VENDOR := ingrasys -BASENAME := x86-64-ingrasys-s9280-64x -ARCH := x86_64 -include $(ONL)/make/kmodule.mk diff --git a/packages/platforms/ingrasys/x86-64/s9280-64x/modules/builds/ingrasys_s9280_64x_i2c_cpld.c b/packages/platforms/ingrasys/x86-64/s9280-64x/modules/builds/ingrasys_s9280_64x_i2c_cpld.c deleted file mode 100644 index 5a487c5b3..000000000 --- a/packages/platforms/ingrasys/x86-64/s9280-64x/modules/builds/ingrasys_s9280_64x_i2c_cpld.c +++ /dev/null @@ -1,1955 +0,0 @@ -/* - * A i2c cpld driver for the ingrasys_s9280_64x - * - * Copyright (C) 2017 Ingrasys Technology Corporation. - * Leo Lin - * - * 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 - -/* header file for i2c cpld driver of ingrasys_s9280_64x - * - * Copyright (C) 2017 Ingrasys Technology Corporation. - * Leo Lin - * - * 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. - */ - -#ifndef INGRASYS_S9280_64X_I2C_CPLD_H -#define INGRASYS_S9280_64X_I2C_CPLD_H - -/* CPLD device index value */ -enum cpld_id { - cpld1, - cpld2, - cpld3, - cpld4, - cpld5 -}; - -enum LED_BLINK { - BLINK, - NOBLINK, -}; - -enum LED_YELLOW { - YELLOW_OFF, - YELLOW_ON, -}; - -enum LED_GREEN { - GREEN_OFF, - GREEN_ON, -}; - -/* port number on CPLD */ -#define CPLD_1_PORT_NUM 12 -#define CPLD_2_PORT_NUM 13 - -/* QSFP port number */ -#define QSFP_MAX_PORT_NUM 64 -#define QSFP_MIN_PORT_NUM 1 - -/* SFP+ port number */ -#define SFP_MAX_PORT_NUM 2 -#define SFP_MIN_PORT_NUM 1 - - -/* CPLD registers */ -#define CPLD_BOARD_TYPE_REG 0x0 -#define CPLD_EXT_BOARD_TYPE_REG 0x7 -#define CPLD_VERSION_REG 0x1 -#define CPLD_ID_REG 0x2 -#define CPLD_QSFP_PORT_STATUS_BASE_REG 0x20 -#define CPLD_QSFP_PORT_CONFIG_BASE_REG 0x30 -#define CPLD_QSFP_PORT_INTERRUPT_REG 0x40 -#define CPLD_SFP_PORT_STATUS_REG 0x2F -#define CPLD_SFP_PORT_CONFIG_REG 0x3F -#define CPLD_QSFP_PORT_INTERRUPT_REG 0x40 -#define CPLD_10GMUX_CONFIG_REG 0x41 -#define CPLD_BMC_STATUS_REG 0x42 -#define CPLD_BMC_WATCHDOG_REG 0x43 -#define CPLD_USB_STATUS_REG 0x44 -#define CPLD_RESET_CONTROL_REG 0x4A -#define CPLD_SFP_LED_REG 0x80 -#define CPLD_SFP_LED_BLINK_REG 0x90 -#define CPLD_QSFP_LED_BASE_REG 0x80 -#define CPLD_QSFP_LED_BLINK_BASE_REG 0x90 -#define CPLD_RTMR_RESET_REG 0x4B -#define CPLD_ROV_STATUS_REG 0x4C - -/* bit definition for register value */ -enum CPLD_QSFP_PORT_STATUS_BITS { - CPLD_QSFP_PORT_STATUS_INT_BIT, - CPLD_QSFP_PORT_STATUS_ABS_BIT, -}; -enum CPLD_QSFP_PORT_CONFIG_BITS { - CPLD_QSFP_PORT_CONFIG_RESET_BIT, - CPLD_QSFP_PORT_CONFIG_RESERVE_BIT, - CPLD_QSFP_PORT_CONFIG_LPMODE_BIT, -}; -enum CPLD_SFP_PORT_STATUS_BITS { - CPLD_SFP0_PORT_STATUS_PRESENT_BIT, - CPLD_SFP0_PORT_STATUS_TXFAULT_BIT, - CPLD_SFP0_PORT_STATUS_RXLOS_BIT, - CPLD_SFP_PORT_STATUS_DUMMY, - CPLD_SFP1_PORT_STATUS_PRESENT_BIT, - CPLD_SFP1_PORT_STATUS_TXFAULT_BIT, - CPLD_SFP1_PORT_STATUS_RXLOS_BIT, -}; -enum CPLD_SFP_PORT_CONFIG_BITS { - CPLD_SFP0_PORT_CONFIG_TXDIS_BIT, - CPLD_SFP0_PORT_CONFIG_RS_BIT, - CPLD_SFP0_PORT_CONFIG_TS_BIT, - CPLD_SFP_PORT_CONFIG_DUMMY, - CPLD_SFP1_PORT_CONFIG_TXDIS_BIT, - CPLD_SFP1_PORT_CONFIG_RS_BIT, - CPLD_SFP1_PORT_CONFIG_TS_BIT, - -}; -enum CPLD_10GMUX_CONFIG_BITS { - CPLD_10GMUX_CONFIG_ENSMB_BIT, - CPLD_10GMUX_CONFIG_ENINPUT_BIT, - CPLD_10GMUX_CONFIG_SEL1_BIT, - CPLD_10GMUX_CONFIG_SEL0_BIT, -}; -enum CPLD_BMC_WATCHDOG_BITS { - CPLD_10GMUX_CONFIG_ENTIMER_BIT, - CPLD_10GMUX_CONFIG_TIMEOUT_BIT, -}; -enum CPLD_RESET_CONTROL_BITS { - CPLD_RESET_CONTROL_SWRST_BIT, - CPLD_RESET_CONTROL_CP2104RST_BIT, - CPLD_RESET_CONTROL_82P33814RST_BIT, - CPLD_RESET_CONTROL_BMCRST_BIT, -}; -enum CPLD_SFP_LED_BITS { - CPLD_SFP_LED_SFP0_GREEN_BIT, - CPLD_SFP_LED_SFP0_YELLOW_BIT, - CPLD_SFP_LED_SFP1_GREEN_BIT, - CPLD_SFP_LED_SFP1_YELLOW_BIT, -}; -enum CPLD_SFP_LED_BLINK_BITS { - CPLD_SFP_LED_BLINK_SFP0_BIT, - CPLD_SFP_LED_BLINK_SFP1_BIT, -}; -enum CPLD_QSFP_LED_BITS { - CPLD_QSFP_LED_CHAN_0_GREEN_BIT, - CPLD_QSFP_LED_CHAN_0_YELLOW_BIT, - CPLD_QSFP_LED_CHAN_1_GREEN_BIT, - CPLD_QSFP_LED_CHAN_1_YELLOW_BIT, - CPLD_QSFP_LED_CHAN_2_GREEN_BIT, - CPLD_QSFP_LED_CHAN_2_YELLOW_BIT, - CPLD_QSFP_LED_CHAN_3_GREEN_BIT, - CPLD_QSFP_LED_CHAN_3_YELLOW_BIT, - -}; -enum CPLD_QSFP_LED_BLINK_BITS { - CPLD_QSFP_LED_BLINK_X_CHAN0_BIT, - CPLD_QSFP_LED_BLINK_X_CHAN1_BIT, - CPLD_QSFP_LED_BLINK_X_CHAN2_BIT, - CPLD_QSFP_LED_BLINK_X_CHAN3_BIT, - CPLD_QSFP_LED_BLINK_XPLUS_CHAN0_BIT, - CPLD_QSFP_LED_BLINK_XPLUS_CHAN1_BIT, - CPLD_QSFP_LED_BLINK_XPLUS_CHAN2_BIT, - CPLD_QSFP_LED_BLINK_XPLUS_CHAN3_BIT, -}; - -/* bit field structure for register value */ -struct cpld_reg_board_type_t { - u8 build_rev:2; - u8 hw_rev:2; - u8 board_id:4; -}; - -struct cpld_reg_version_t { - u8 revision:6; - u8 release:1; - u8 reserve:1; -}; - -struct cpld_reg_id_t { - u8 id:3; - u8 release:5; -}; - -/* common manipulation */ -#define INVALID(i, min, max) ((i < min) || (i > max) ? 1u : 0u) -#define READ_BIT(val, bit) ((0u == (val & (1<bf_name) -#define READ_BF_1(bf_struct, val, bf_name, bf_value) \ - bf_struct bf; \ - bf.data = val; \ - bf_value = bf.bf_name -#define BOARD_TYPE_BUILD_REV_GET(val, res) \ - READ_BF(cpld_reg_board_type_t, val, build_rev, res) -#define BOARD_TYPE_HW_REV_GET(val, res) \ - READ_BF(cpld_reg_board_type_t, val, hw_rev, res) -#define BOARD_TYPE_BOARD_ID_GET(val, res) \ - READ_BF(cpld_reg_board_type_t, val, board_id, res) -#define CPLD_VERSION_REV_GET(val, res) \ - READ_BF(cpld_reg_version_t, val, revision, res) -#define CPLD_VERSION_REL_GET(val, res) \ - READ_BF(cpld_reg_version_t, val, release, res) -#define CPLD_ID_ID_GET(val, res) \ - READ_BF(cpld_reg_id_t, val, id, res) -#define CPLD_ID_REL_GET(val, res) \ - READ_BF(cpld_reg_id_t, val, release, res) -/* SFP/QSFP port led registers manipulation */ -#define SFP_LED_TO_CPLD_IDX(sfp_port) cpld1 -#define SFP_LED_REG(sfp_port) CPLD_SFP_LED_REG -#define SFP_LED_BLINK_REG(sfp_port) CPLD_SFP_LED_BLINK_REG -#define QSFP_LED_TO_CPLD_IDX(qsfp_port) \ - ((qsfp_port - 1) / 16 + 2) -#define QSFP_LED_REG(qsfp_port) \ - ((qsfp_port - 1) % 16 + CPLD_QSFP_LED_BASE_REG) -#define QSFP_LED_BLINK_REG(qsfp_port) \ - (((qsfp_port - 1) % 16) / 2 + CPLD_QSFP_LED_BLINK_BASE_REG) -/* QSFP/SFP port status registers manipulation */ -#define QSFP_TO_CPLD_IDX(qsfp_port, cpld_index, cpld_port) \ -{ \ - if (QSFP_MIN_PORT_NUM <= qsfp_port && qsfp_port <= CPLD_1_PORT_NUM) { \ - cpld_index = cpld1; \ - cpld_port = qsfp_port - 1; \ - } else if (CPLD_1_PORT_NUM < qsfp_port \ - && qsfp_port <= QSFP_MAX_PORT_NUM) { \ - cpld_index = cpld2 + (qsfp_port - 1 - CPLD_1_PORT_NUM) \ - / CPLD_2_PORT_NUM; \ - cpld_port = (qsfp_port - 1 - CPLD_1_PORT_NUM) % \ - CPLD_2_PORT_NUM; \ - } else { \ - cpld_index = 0; \ - cpld_port = 0; \ - } \ -} -#define QSFP_PORT_STATUS_REG(cpld_port) \ - (CPLD_QSFP_PORT_STATUS_BASE_REG + cpld_port) -#define QSFP_PORT_CONFIG_REG(cpld_port) \ - (CPLD_QSFP_PORT_CONFIG_BASE_REG + cpld_port) -#define QSFP_PORT_INT_BIT_GET(port_status_value) \ - READ_BIT(port_status_value, CPLD_QSFP_PORT_STATUS_INT_BIT) -#define QSFP_PORT_ABS_BIT_GET(port_status_value) \ - READ_BIT(port_status_value, CPLD_QSFP_PORT_STATUS_ABS_BIT) -#define QSFP_PORT_RESET_BIT_GET(port_config_value) \ - READ_BIT(port_config_value, CPLD_QSFP_PORT_CONFIG_RESET_BIT) -#define QSFP_PORT_LPMODE_BIT_GET(port_config_value) \ - READ_BIT(port_config_value, CPLD_QSFP_PORT_CONFIG_LPMODE_BIT) -#define QSFP_PORT_RESET_BIT_SET(port_config_value) \ - SET_BIT(port_config_value, CPLD_QSFP_PORT_CONFIG_RESET_BIT) -#define QSFP_PORT_RESET_BIT_CLEAR(port_config_value) \ - CLEAR_BIT(port_config_value, CPLD_QSFP_PORT_CONFIG_RESET_BIT) -#define QSFP_PORT_LPMODE_BIT_SET(port_config_value) \ - SET_BIT(port_config_value, CPLD_QSFP_PORT_CONFIG_LPMODE_BIT) -#define QSFP_PORT_LPMODE_BIT_CLEAR(port_config_value) \ - CLEAR_BIT(port_config_value, CPLD_QSFP_PORT_CONFIG_LPMODE_BIT) -#define SFP_PORT_PRESENT_BIT_GET(sfp_port, port_status_value) \ - if (sfp_port == SFP_MIN_PORT_NUM) { \ - READ_BIT(port_status_value, CPLD_SFP0_PORT_STATUS_PRESENT_BIT); \ - } else { \ - READ_BIT(port_status_value, CPLD_SFP1_PORT_STATUS_PRESENT_BIT); \ - } -#define SFP_PORT_TXFAULT_BIT_GET(sfp_port, port_status_value) \ - if (sfp_port == SFP_MIN_PORT_NUM) { \ - READ_BIT(port_status_value, CPLD_SFP0_PORT_STATUS_TXFAULT_BIT); \ - } else { \ - READ_BIT(port_status_value, CPLD_SFP1_PORT_STATUS_TXFAULT_BIT); \ - } -#define SFP_PORT_RXLOS_BIT_GET(sfp_port, port_status_value) \ - if (sfp_port == SFP_MIN_PORT_NUM) { \ - READ_BIT(port_status_value, CPLD_SFP0_PORT_STATUS_RXLOS_BIT); \ - } else { \ - READ_BIT(port_status_value, CPLD_SFP1_PORT_STATUS_RXLOS_BIT); \ - } -#define SFP_PORT_TXDIS_BIT_GET(sfp_port, port_config_value) \ - if (sfp_port == SFP_MIN_PORT_NUM) { \ - READ_BIT(port_config_value, CPLD_SFP0_PORT_CONFIG_TXDIS_BIT); \ - } else { \ - READ_BIT(port_config_value, CPLD_SFP1_PORT_STATUS_RXLOS_BIT); \ - } -#define SFP_PORT_RS_BIT_GET(sfp_port, port_config_value) \ - if (sfp_port == SFP_MIN_PORT_NUM) { \ - READ_BIT(port_config_value, CPLD_SFP0_PORT_CONFIG_RS_BIT); \ - } else { \ - READ_BIT(port_config_value, CPLD_SFP1_PORT_CONFIG_RS_BIT); \ - } -#define SFP_PORT_TS_BIT_GET(sfp_port, port_config_value) \ - if (sfp_port == SFP_MIN_PORT_NUM) { \ - READ_BIT(port_config_value, CPLD_SFP0_PORT_CONFIG_TS_BIT); \ - } else { \ - READ_BIT(port_config_value, CPLD_SFP0_PORT_CONFIG_TS_BIT); \ - } -#define SFP_PORT_TXDIS_BIT_SET(sfp_port, port_config_value) \ - if (sfp_port == SFP_MIN_PORT_NUM) { \ - SET_BIT(port_config_value, CPLD_SFP0_PORT_CONFIG_TXDIS_BIT); \ - } else { \ - SET_BIT(port_config_value, CPLD_SFP1_PORT_CONFIG_TXDIS_BIT); \ - } -#define SFP_PORT_TXDIS_BIT_CLEAR(sfp_port, port_config_value) \ - if (sfp_port == SFP_MIN_PORT_NUM) { \ - CLEAR_BIT(port_config_value, CPLD_SFP0_PORT_CONFIG_TXDIS_BIT); \ - } else { \ - CLEAR_BIT(port_config_value, CPLD_SFP1_PORT_CONFIG_TXDIS_BIT); \ - } -#define SFP_PORT_RS_BIT_SET(sfp_port, port_config_value) \ - if (sfp_port == SFP_MIN_PORT_NUM) { \ - SET_BIT(port_config_value, CPLD_SFP0_PORT_CONFIG_RS_BIT); \ - } else { \ - SET_BIT(port_config_value, CPLD_SFP1_PORT_CONFIG_RS_BIT); \ - } -#define SFP_PORT_RS_BIT_CLEAR(sfp_port, port_config_value) \ - if (sfp_port == SFP_MIN_PORT_NUM) { \ - CLEAR_BIT(port_config_value, CPLD_SFP0_PORT_CONFIG_RS_BIT); \ - } else { \ - CLEAR_BIT(port_config_value, CPLD_SFP1_PORT_CONFIG_RS_BIT); \ - } -#define SFP_PORT_TS_BIT_SET(sfp_port, port_config_value) \ - if (sfp_port == SFP_MIN_PORT_NUM) { \ - SET_BIT(port_config_value, CPLD_SFP0_PORT_CONFIG_TS_BIT); \ - } else { \ - SET_BIT(port_config_value, CPLD_SFP1_PORT_CONFIG_TS_BIT); \ - } -#define SFP_PORT_TS_BIT_CLEAR(sfp_port, port_config_value) \ - if (sfp_port == SFP_MIN_PORT_NUM) { \ - CLEAR_BIT(port_config_value, CPLD_SFP0_PORT_CONFIG_TS_BIT); \ - } else { \ - CLEAR_BIT(port_config_value, CPLD_SFP1_PORT_CONFIG_TS_BIT); \ - } - -/* CPLD access functions */ -extern int ingrasys_i2c_cpld_get_qsfp_port_status_val(u8 port_num); -extern int ingrasys_i2c_cpld_get_qsfp_port_config_val(u8 port_num); -extern int ingrasys_i2c_cpld_set_qsfp_port_config_val(u8 port_num, u8 reg_val); -extern int ingrasys_i2c_cpld_get_sfp_port_status_val(void); -extern int ingrasys_i2c_cpld_get_sfp_port_config_val(void); -extern int ingrasys_i2c_cpld_set_sfp_port_config_val(u8 reg_val); -extern u8 fp_port_to_phy_port(u8 fp_port); -#endif - -#ifdef DEBUG -#define DEBUG_PRINT(fmt, args...) \ - printk(KERN_INFO "%s:%s[%d]: " fmt "\r\n", \ - __FILE__, __func__, __LINE__, ##args) -#else -#define DEBUG_PRINT(fmt, args...) -#endif - -#define I2C_READ_BYTE_DATA(ret, lock, i2c_client, reg) \ -{ \ - mutex_lock(lock); \ - ret = i2c_smbus_read_byte_data(i2c_client, reg); \ - mutex_unlock(lock); \ -} -#define I2C_WRITE_BYTE_DATA(ret, lock, i2c_client, reg, val) \ -{ \ - mutex_lock(lock); \ - ret = i2c_smbus_write_byte_data(i2c_client, reg, val); \ - mutex_unlock(lock); \ -} - -/* CPLD sysfs attributes index */ -enum s9280_64x_cpld_sysfs_attributes { - CPLD_ACCESS_REG, - CPLD_REGISTER_VAL, - CPLD_PORT_START, - CPLD_PORTS, - CPLD_VERSION, - CPLD_ID, - CPLD_BOARD_TYPE, - CPLD_EXT_BOARD_TYPE, - CPLD_QSFP_PORT_STATUS_1, - CPLD_QSFP_PORT_STATUS_2, - CPLD_QSFP_PORT_STATUS_3, - CPLD_QSFP_PORT_STATUS_4, - CPLD_QSFP_PORT_STATUS_5, - CPLD_QSFP_PORT_STATUS_6, - CPLD_QSFP_PORT_STATUS_7, - CPLD_QSFP_PORT_STATUS_8, - CPLD_QSFP_PORT_STATUS_9, - CPLD_QSFP_PORT_STATUS_10, - CPLD_QSFP_PORT_STATUS_11, - CPLD_QSFP_PORT_STATUS_12, - CPLD_QSFP_PORT_STATUS_13, - CPLD_QSFP_PORT_CONFIG_1, - CPLD_QSFP_PORT_CONFIG_2, - CPLD_QSFP_PORT_CONFIG_3, - CPLD_QSFP_PORT_CONFIG_4, - CPLD_QSFP_PORT_CONFIG_5, - CPLD_QSFP_PORT_CONFIG_6, - CPLD_QSFP_PORT_CONFIG_7, - CPLD_QSFP_PORT_CONFIG_8, - CPLD_QSFP_PORT_CONFIG_9, - CPLD_QSFP_PORT_CONFIG_10, - CPLD_QSFP_PORT_CONFIG_11, - CPLD_QSFP_PORT_CONFIG_12, - CPLD_QSFP_PORT_CONFIG_13, - CPLD_QSFP_PORT_INTERRUPT, - CPLD_SFP_PORT_STATUS, - CPLD_SFP_PORT_CONFIG, - CPLD_10GMUX_CONFIG, - CPLD_BMC_STATUS, - CPLD_BMC_WATCHDOG, - CPLD_USB_STATUS, - CPLD_RESET_CONTROL, - CPLD_SFP_LED, - CPLD_SFP_LED_BLINK, - CPLD_QSFP_LED_1, - CPLD_QSFP_LED_2, - CPLD_QSFP_LED_3, - CPLD_QSFP_LED_4, - CPLD_QSFP_LED_5, - CPLD_QSFP_LED_6, - CPLD_QSFP_LED_7, - CPLD_QSFP_LED_8, - CPLD_QSFP_LED_9, - CPLD_QSFP_LED_10, - CPLD_QSFP_LED_11, - CPLD_QSFP_LED_12, - CPLD_QSFP_LED_13, - CPLD_QSFP_LED_14, - CPLD_QSFP_LED_15, - CPLD_QSFP_LED_16, - CPLD_QSFP_LED_BLINK, - CPLD_RTMR_RESET, - CPLD_ROV_STATUS, - -}; - -/* CPLD sysfs attributes hook functions */ -static ssize_t read_access_register(struct device *dev, - struct device_attribute *da, char *buf); -static ssize_t write_access_register(struct device *dev, - struct device_attribute *da, const char *buf, size_t count); -static ssize_t read_register_value(struct device *dev, - struct device_attribute *da, char *buf); -static ssize_t write_register_value(struct device *dev, - struct device_attribute *da, const char *buf, size_t count); -static ssize_t get_qsfp_port_start(struct device *dev, - struct device_attribute *da, char *buf); -static ssize_t get_qsfp_ports(struct device *dev, - struct device_attribute *da, char *buf); -static ssize_t read_cpld_version(struct device *dev, - struct device_attribute *da, char *buf); -static ssize_t read_cpld_id(struct device *dev, - struct device_attribute *da, char *buf); -static ssize_t read_board_type(struct device *dev, - struct device_attribute *da, char *buf); -static ssize_t read_ext_board_type(struct device *dev, - struct device_attribute *da, char *buf); -static ssize_t read_qsfp_port_status(struct device *dev, - struct device_attribute *da, char *buf); -static ssize_t read_qsfp_port_config(struct device *dev, - struct device_attribute *da, char *buf); -static ssize_t write_qsfp_port_config(struct device *dev, - struct device_attribute *da, const char *buf, size_t count); -static ssize_t read_qsfp_port_interrupt(struct device *dev, - struct device_attribute *da, char *buf); -static ssize_t read_sfp_port_status(struct device *dev, - struct device_attribute *da, char *buf); -static ssize_t read_sfp_port_config(struct device *dev, - struct device_attribute *da, char *buf); -static ssize_t write_sfp_port_config(struct device *dev, - struct device_attribute *da, const char *buf, size_t count); -static ssize_t read_10gmux_config(struct device *dev, - struct device_attribute *da, char *buf); -static ssize_t write_10gmux_config(struct device *dev, - struct device_attribute *da, const char *buf, size_t count); -static ssize_t read_bmc_status(struct device *dev, - struct device_attribute *da, char *buf); -static ssize_t read_bmc_watchdog(struct device *dev, - struct device_attribute *da, char *buf); -static ssize_t write_bmc_watchdog(struct device *dev, - struct device_attribute *da, const char *buf, size_t count); -static ssize_t read_usb_status(struct device *dev, - struct device_attribute *da, char *buf); -static ssize_t read_reset_control(struct device *dev, - struct device_attribute *da, char *buf); -static ssize_t write_reset_control(struct device *dev, - struct device_attribute *da, const char *buf, size_t count); -static ssize_t read_sfp_led(struct device *dev, - struct device_attribute *da, char *buf); -static ssize_t write_sfp_led(struct device *dev, - struct device_attribute *da, const char *buf, size_t count); -static ssize_t read_sfp_led_blink(struct device *dev, - struct device_attribute *da, char *buf); -static ssize_t write_sfp_led_blink(struct device *dev, - struct device_attribute *da, const char *buf, size_t count); -static ssize_t read_qsfp_led(struct device *dev, - struct device_attribute *da, char *buf); -static ssize_t write_qsfp_led(struct device *dev, - struct device_attribute *da, const char *buf, size_t count); -static ssize_t read_qsfp_led_blink(struct device *dev, - struct device_attribute *da, char *buf); -static ssize_t write_qsfp_led_blink(struct device *dev, - struct device_attribute *da, const char *buf, size_t count); -static ssize_t read_rtmr_reset(struct device *dev, - struct device_attribute *da, char *buf); -static ssize_t write_rtmr_reset(struct device *dev, - struct device_attribute *da, const char *buf, size_t count); -static ssize_t read_rov_status(struct device *dev, - struct device_attribute *da, char *buf); - -static LIST_HEAD(cpld_client_list); /* client list for cpld */ -static struct mutex list_lock; /* mutex for client list */ - -struct cpld_client_node { - struct i2c_client *client; - struct list_head list; -}; - -struct cpld_data { - int index; /* CPLD index */ - struct mutex access_lock; /* mutex for cpld access */ - u8 access_reg; /* register to access */ -}; - -/* CPLD device id and data */ -static const struct i2c_device_id ingrasys_i2c_cpld_id[] = { - { "ingrasys_cpld1", cpld1 }, - { "ingrasys_cpld2", cpld2 }, - { "ingrasys_cpld3", cpld3 }, - { "ingrasys_cpld4", cpld4 }, - { "ingrasys_cpld5", cpld5 }, - {} -}; - -/* Addresses scanned for ingrasys_i2c_cpld */ -static const unsigned short cpld_i2c_addr[] = { 0x33, I2C_CLIENT_END }; - -/* define all support register access of cpld in attribute */ -static SENSOR_DEVICE_ATTR(cpld_access_register, S_IWUSR | S_IRUGO, - read_access_register, write_access_register, CPLD_ACCESS_REG); -static SENSOR_DEVICE_ATTR(cpld_register_value, S_IWUSR | S_IRUGO, - read_register_value, write_register_value, CPLD_REGISTER_VAL); -static SENSOR_DEVICE_ATTR(cpld_qsfp_port_start, S_IRUGO, - get_qsfp_port_start, NULL, CPLD_PORT_START); -static SENSOR_DEVICE_ATTR(cpld_qsfp_ports, S_IRUGO, - get_qsfp_ports, NULL, CPLD_PORTS); -static SENSOR_DEVICE_ATTR(cpld_version, S_IRUGO, - read_cpld_version, NULL, CPLD_VERSION); -static SENSOR_DEVICE_ATTR(cpld_id, S_IRUGO, read_cpld_id, NULL, CPLD_ID); -static SENSOR_DEVICE_ATTR(cpld_board_type, S_IRUGO, - read_board_type, NULL, CPLD_BOARD_TYPE); -static SENSOR_DEVICE_ATTR(cpld_ext_board_type, S_IRUGO, - read_ext_board_type, NULL, CPLD_EXT_BOARD_TYPE); -static SENSOR_DEVICE_ATTR(cpld_qsfp_port_status_1, S_IRUGO, - read_qsfp_port_status, NULL, CPLD_QSFP_PORT_STATUS_1); -static SENSOR_DEVICE_ATTR(cpld_qsfp_port_status_2, S_IRUGO, - read_qsfp_port_status, NULL, CPLD_QSFP_PORT_STATUS_2); -static SENSOR_DEVICE_ATTR(cpld_qsfp_port_status_3, S_IRUGO, - read_qsfp_port_status, NULL, CPLD_QSFP_PORT_STATUS_3); -static SENSOR_DEVICE_ATTR(cpld_qsfp_port_status_4, S_IRUGO, - read_qsfp_port_status, NULL, CPLD_QSFP_PORT_STATUS_4); -static SENSOR_DEVICE_ATTR(cpld_qsfp_port_status_5, S_IRUGO, - read_qsfp_port_status, NULL, CPLD_QSFP_PORT_STATUS_5); -static SENSOR_DEVICE_ATTR(cpld_qsfp_port_status_6, S_IRUGO, - read_qsfp_port_status, NULL, CPLD_QSFP_PORT_STATUS_6); -static SENSOR_DEVICE_ATTR(cpld_qsfp_port_status_7, S_IRUGO, - read_qsfp_port_status, NULL, CPLD_QSFP_PORT_STATUS_7); -static SENSOR_DEVICE_ATTR(cpld_qsfp_port_status_8, S_IRUGO, - read_qsfp_port_status, NULL, CPLD_QSFP_PORT_STATUS_8); -static SENSOR_DEVICE_ATTR(cpld_qsfp_port_status_9, S_IRUGO, - read_qsfp_port_status, NULL, CPLD_QSFP_PORT_STATUS_9); -static SENSOR_DEVICE_ATTR(cpld_qsfp_port_status_10, S_IRUGO, - read_qsfp_port_status, NULL, CPLD_QSFP_PORT_STATUS_10); -static SENSOR_DEVICE_ATTR(cpld_qsfp_port_status_11, S_IRUGO, - read_qsfp_port_status, NULL, CPLD_QSFP_PORT_STATUS_11); -static SENSOR_DEVICE_ATTR(cpld_qsfp_port_status_12, S_IRUGO, - read_qsfp_port_status, NULL, CPLD_QSFP_PORT_STATUS_12); -static SENSOR_DEVICE_ATTR(cpld_qsfp_port_status_13, S_IRUGO, - read_qsfp_port_status, NULL, CPLD_QSFP_PORT_STATUS_13); -static SENSOR_DEVICE_ATTR(cpld_qsfp_port_config_1, S_IWUSR | S_IRUGO, - read_qsfp_port_config, write_qsfp_port_config, - CPLD_QSFP_PORT_CONFIG_1); -static SENSOR_DEVICE_ATTR(cpld_qsfp_port_config_2, S_IWUSR | S_IRUGO, - read_qsfp_port_config, write_qsfp_port_config, - CPLD_QSFP_PORT_CONFIG_2); -static SENSOR_DEVICE_ATTR(cpld_qsfp_port_config_3, S_IWUSR | S_IRUGO, - read_qsfp_port_config, write_qsfp_port_config, - CPLD_QSFP_PORT_CONFIG_3); -static SENSOR_DEVICE_ATTR(cpld_qsfp_port_config_4, S_IWUSR | S_IRUGO, - read_qsfp_port_config, write_qsfp_port_config, - CPLD_QSFP_PORT_CONFIG_4); -static SENSOR_DEVICE_ATTR(cpld_qsfp_port_config_5, S_IWUSR | S_IRUGO, - read_qsfp_port_config, write_qsfp_port_config, - CPLD_QSFP_PORT_CONFIG_5); -static SENSOR_DEVICE_ATTR(cpld_qsfp_port_config_6, S_IWUSR | S_IRUGO, - read_qsfp_port_config, write_qsfp_port_config, - CPLD_QSFP_PORT_CONFIG_6); -static SENSOR_DEVICE_ATTR(cpld_qsfp_port_config_7, S_IWUSR | S_IRUGO, - read_qsfp_port_config, write_qsfp_port_config, - CPLD_QSFP_PORT_CONFIG_7); -static SENSOR_DEVICE_ATTR(cpld_qsfp_port_config_8, S_IWUSR | S_IRUGO, - read_qsfp_port_config, write_qsfp_port_config, - CPLD_QSFP_PORT_CONFIG_8); -static SENSOR_DEVICE_ATTR(cpld_qsfp_port_config_9, S_IWUSR | S_IRUGO, - read_qsfp_port_config, write_qsfp_port_config, - CPLD_QSFP_PORT_CONFIG_9); -static SENSOR_DEVICE_ATTR(cpld_qsfp_port_config_10, S_IWUSR | S_IRUGO, - read_qsfp_port_config, write_qsfp_port_config, - CPLD_QSFP_PORT_CONFIG_10); -static SENSOR_DEVICE_ATTR(cpld_qsfp_port_config_11, S_IWUSR | S_IRUGO, - read_qsfp_port_config, write_qsfp_port_config, - CPLD_QSFP_PORT_CONFIG_11); -static SENSOR_DEVICE_ATTR(cpld_qsfp_port_config_12, S_IWUSR | S_IRUGO, - read_qsfp_port_config, write_qsfp_port_config, - CPLD_QSFP_PORT_CONFIG_12); -static SENSOR_DEVICE_ATTR(cpld_qsfp_port_config_13, S_IWUSR | S_IRUGO, - read_qsfp_port_config, write_qsfp_port_config, - CPLD_QSFP_PORT_CONFIG_13); -static SENSOR_DEVICE_ATTR(cpld_qsfp_port_interrupt, S_IRUGO, - read_qsfp_port_interrupt, NULL, CPLD_QSFP_PORT_INTERRUPT); -static SENSOR_DEVICE_ATTR(cpld_sfp_port_status, S_IRUGO, - read_sfp_port_status, NULL, CPLD_SFP_PORT_STATUS); -static SENSOR_DEVICE_ATTR(cpld_sfp_port_config, S_IWUSR | S_IRUGO, - read_sfp_port_config, write_sfp_port_config, CPLD_SFP_PORT_CONFIG); -static SENSOR_DEVICE_ATTR(cpld_10gmux_config, S_IWUSR | S_IRUGO, - read_10gmux_config, write_10gmux_config, - CPLD_10GMUX_CONFIG); -static SENSOR_DEVICE_ATTR(cpld_bmc_status, S_IRUGO, - read_bmc_status, NULL, CPLD_BMC_STATUS); -static SENSOR_DEVICE_ATTR(cpld_bmc_watchdog, S_IWUSR | S_IRUGO, - read_bmc_watchdog, write_bmc_watchdog, - CPLD_BMC_WATCHDOG); -static SENSOR_DEVICE_ATTR(cpld_usb_status, S_IRUGO, - read_usb_status, NULL, CPLD_USB_STATUS); -static SENSOR_DEVICE_ATTR(cpld_reset_control, S_IWUSR | S_IRUGO, - read_reset_control, write_reset_control, - CPLD_BMC_WATCHDOG); -static SENSOR_DEVICE_ATTR(cpld_sfp_led, S_IWUSR | S_IRUGO, - read_sfp_led, write_sfp_led, CPLD_SFP_LED); -static SENSOR_DEVICE_ATTR(cpld_sfp_led_blink, S_IWUSR | S_IRUGO, - read_sfp_led_blink, write_sfp_led_blink, CPLD_SFP_LED_BLINK); -static SENSOR_DEVICE_ATTR(cpld_qsfp_led_1, S_IWUSR | S_IRUGO, - read_qsfp_led, write_qsfp_led, CPLD_QSFP_LED_1); -static SENSOR_DEVICE_ATTR(cpld_qsfp_led_2, S_IWUSR | S_IRUGO, - read_qsfp_led, write_qsfp_led, CPLD_QSFP_LED_2); -static SENSOR_DEVICE_ATTR(cpld_qsfp_led_3, S_IWUSR | S_IRUGO, - read_qsfp_led, write_qsfp_led, CPLD_QSFP_LED_3); -static SENSOR_DEVICE_ATTR(cpld_qsfp_led_4, S_IWUSR | S_IRUGO, - read_qsfp_led, write_qsfp_led, CPLD_QSFP_LED_4); -static SENSOR_DEVICE_ATTR(cpld_qsfp_led_5, S_IWUSR | S_IRUGO, - read_qsfp_led, write_qsfp_led, CPLD_QSFP_LED_5); -static SENSOR_DEVICE_ATTR(cpld_qsfp_led_6, S_IWUSR | S_IRUGO, - read_qsfp_led, write_qsfp_led, CPLD_QSFP_LED_6); -static SENSOR_DEVICE_ATTR(cpld_qsfp_led_7, S_IWUSR | S_IRUGO, - read_qsfp_led, write_qsfp_led, CPLD_QSFP_LED_7); -static SENSOR_DEVICE_ATTR(cpld_qsfp_led_8, S_IWUSR | S_IRUGO, - read_qsfp_led, write_qsfp_led, CPLD_QSFP_LED_8); -static SENSOR_DEVICE_ATTR(cpld_qsfp_led_9, S_IWUSR | S_IRUGO, - read_qsfp_led, write_qsfp_led, CPLD_QSFP_LED_9); -static SENSOR_DEVICE_ATTR(cpld_qsfp_led_10, S_IWUSR | S_IRUGO, - read_qsfp_led, write_qsfp_led, CPLD_QSFP_LED_10); -static SENSOR_DEVICE_ATTR(cpld_qsfp_led_11, S_IWUSR | S_IRUGO, - read_qsfp_led, write_qsfp_led, CPLD_QSFP_LED_11); -static SENSOR_DEVICE_ATTR(cpld_qsfp_led_12, S_IWUSR | S_IRUGO, - read_qsfp_led, write_qsfp_led, CPLD_QSFP_LED_12); -static SENSOR_DEVICE_ATTR(cpld_qsfp_led_13, S_IWUSR | S_IRUGO, - read_qsfp_led, write_qsfp_led, CPLD_QSFP_LED_13); -static SENSOR_DEVICE_ATTR(cpld_qsfp_led_14, S_IWUSR | S_IRUGO, - read_qsfp_led, write_qsfp_led, CPLD_QSFP_LED_14); -static SENSOR_DEVICE_ATTR(cpld_qsfp_led_15, S_IWUSR | S_IRUGO, - read_qsfp_led, write_qsfp_led, CPLD_QSFP_LED_15); -static SENSOR_DEVICE_ATTR(cpld_qsfp_led_16, S_IWUSR | S_IRUGO, - read_qsfp_led, write_qsfp_led, CPLD_QSFP_LED_16); -static SENSOR_DEVICE_ATTR(cpld_qsfp_led_blink, S_IWUSR | S_IRUGO, - read_qsfp_led_blink, write_qsfp_led_blink, CPLD_QSFP_LED_BLINK); -static SENSOR_DEVICE_ATTR(cpld_rtmr_reset, S_IWUSR | S_IRUGO, - read_rtmr_reset, write_rtmr_reset, CPLD_RTMR_RESET); -static SENSOR_DEVICE_ATTR(cpld_rov_status, S_IRUGO, - read_rov_status, NULL, CPLD_ROV_STATUS); - -/* define support attributes of cpldx , total 5 */ -/* cpld 1 */ -static struct attribute *s9280_64x_cpld1_attributes[] = { - &sensor_dev_attr_cpld_access_register.dev_attr.attr, - &sensor_dev_attr_cpld_register_value.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_start.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_ports.dev_attr.attr, - &sensor_dev_attr_cpld_version.dev_attr.attr, - &sensor_dev_attr_cpld_id.dev_attr.attr, - &sensor_dev_attr_cpld_board_type.dev_attr.attr, - &sensor_dev_attr_cpld_ext_board_type.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_status_1.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_status_2.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_status_3.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_status_4.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_status_5.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_status_6.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_status_7.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_status_8.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_status_9.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_status_10.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_status_11.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_status_12.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_config_1.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_config_2.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_config_3.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_config_4.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_config_5.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_config_6.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_config_7.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_config_8.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_config_9.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_config_10.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_config_11.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_config_12.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_interrupt.dev_attr.attr, - &sensor_dev_attr_cpld_sfp_port_status.dev_attr.attr, - &sensor_dev_attr_cpld_sfp_port_config.dev_attr.attr, - &sensor_dev_attr_cpld_10gmux_config.dev_attr.attr, - &sensor_dev_attr_cpld_bmc_status.dev_attr.attr, - &sensor_dev_attr_cpld_bmc_watchdog.dev_attr.attr, - &sensor_dev_attr_cpld_usb_status.dev_attr.attr, - &sensor_dev_attr_cpld_reset_control.dev_attr.attr, - &sensor_dev_attr_cpld_sfp_led.dev_attr.attr, - &sensor_dev_attr_cpld_sfp_led_blink.dev_attr.attr, - &sensor_dev_attr_cpld_rtmr_reset.dev_attr.attr, - &sensor_dev_attr_cpld_rov_status.dev_attr.attr, - NULL -}; - -/* cpld 2 / cpld 3 / cpld 4 / cpld 5 */ -static struct attribute *s9280_64x_cpld2345_attributes[] = { -&sensor_dev_attr_cpld_access_register.dev_attr.attr, - &sensor_dev_attr_cpld_register_value.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_start.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_ports.dev_attr.attr, - &sensor_dev_attr_cpld_version.dev_attr.attr, - &sensor_dev_attr_cpld_id.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_status_1.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_status_2.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_status_3.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_status_4.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_status_5.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_status_6.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_status_7.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_status_8.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_status_9.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_status_10.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_status_11.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_status_12.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_status_13.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_config_1.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_config_2.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_config_3.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_config_4.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_config_5.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_config_6.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_config_7.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_config_8.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_config_9.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_config_10.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_config_11.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_config_12.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_config_13.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_port_interrupt.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_led_1.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_led_2.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_led_3.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_led_4.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_led_5.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_led_6.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_led_7.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_led_8.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_led_9.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_led_10.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_led_11.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_led_12.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_led_13.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_led_14.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_led_15.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_led_16.dev_attr.attr, - &sensor_dev_attr_cpld_qsfp_led_blink.dev_attr.attr, - NULL -}; - -/* cpld 1 attributes group */ -static const struct attribute_group s9280_64x_cpld1_group = { - .attrs = s9280_64x_cpld1_attributes, -}; -/* cpld 2/3/4/5 attributes group */ -static const struct attribute_group s9280_64x_cpld2345_group = { - .attrs = s9280_64x_cpld2345_attributes, -}; - -/* read access register from cpld data */ -static ssize_t read_access_register(struct device *dev, - struct device_attribute *da, - char *buf) -{ - struct i2c_client *client = to_i2c_client(dev); - struct cpld_data *data = i2c_get_clientdata(client); - u8 reg = data->access_reg; - - return sprintf(buf, "0x%x\n", reg); -} - -/* write access register to cpld data */ -static ssize_t write_access_register(struct device *dev, - struct device_attribute *da, - const char *buf, - size_t count) -{ - struct i2c_client *client = to_i2c_client(dev); - struct cpld_data *data = i2c_get_clientdata(client); - u8 reg; - - if (kstrtou8(buf, 0, ®) < 0) - return -EINVAL; - - data->access_reg = reg; - return count; -} - -/* read the value of access register in cpld data */ -static ssize_t read_register_value(struct device *dev, - struct device_attribute *da, - char *buf) -{ - struct i2c_client *client = to_i2c_client(dev); - struct cpld_data *data = i2c_get_clientdata(client); - u8 reg = data->access_reg; - int reg_val; - - I2C_READ_BYTE_DATA(reg_val, &data->access_lock, client, reg); - - if (reg_val < 0) - return -1; - - return sprintf(buf, "0x%x\n", reg_val); -} - -/* wrtie the value to access register in cpld data */ -static ssize_t write_register_value(struct device *dev, - struct device_attribute *da, - const char *buf, - size_t count) -{ - struct i2c_client *client = to_i2c_client(dev); - struct cpld_data *data = i2c_get_clientdata(client); - int ret = -EIO; - u8 reg = data->access_reg; - u8 reg_val; - - if (kstrtou8(buf, 0, ®_val) < 0) - return -EINVAL; - - I2C_WRITE_BYTE_DATA(ret, &data->access_lock, client, reg, reg_val); - - return count; -} - -/* get qsfp port start number of the cpld device */ -/* the start number use to tranlate qsfp port to cpld port */ -/* the cpld port use to access the qsfp port register in cpld */ -static ssize_t get_qsfp_port_start(struct device *dev, - struct device_attribute *da, - char *buf) -{ - struct sensor_device_attribute *attr = to_sensor_dev_attr(da); - struct i2c_client *client = to_i2c_client(dev); - struct cpld_data *data = i2c_get_clientdata(client); - int port_base_num; - - if (attr->index == CPLD_PORT_START) { - if (data->index == cpld1) { - port_base_num = 1; - } else { - port_base_num = CPLD_1_PORT_NUM + - CPLD_2_PORT_NUM*(data->index - 1) + 1; - } - return sprintf(buf, "%d\n", port_base_num); - } - return -1; -} - -/* get total qsfp port which contain register in the cpld device */ -static ssize_t get_qsfp_ports(struct device *dev, - struct device_attribute *da, - char *buf) -{ - struct sensor_device_attribute *attr = to_sensor_dev_attr(da); - struct i2c_client *client = to_i2c_client(dev); - struct cpld_data *data = i2c_get_clientdata(client); - int ports; - - if (attr->index == CPLD_PORTS) { - if (data->index == cpld1) - ports = CPLD_1_PORT_NUM; - else - ports = CPLD_2_PORT_NUM; - return sprintf(buf, "%d\n", ports); - } - return -1; -} - -/* get cpdl version register value */ -static ssize_t read_cpld_version(struct device *dev, - struct device_attribute *da, - char *buf) -{ - struct sensor_device_attribute *attr = to_sensor_dev_attr(da); - struct i2c_client *client = to_i2c_client(dev); - struct cpld_data *data = i2c_get_clientdata(client); - u8 reg; - int reg_val; - - if (attr->index == CPLD_VERSION) { - reg = CPLD_VERSION_REG; - I2C_READ_BYTE_DATA(reg_val, &data->access_lock, client, reg); - if (reg_val < 0) - return -1; - return sprintf(buf, "0x%02x\n", reg_val); - } - return -1; -} - -/* get cpdl id register value */ -static ssize_t read_cpld_id(struct device *dev, - struct device_attribute *da, - char *buf) -{ - struct sensor_device_attribute *attr = to_sensor_dev_attr(da); - struct i2c_client *client = to_i2c_client(dev); - struct cpld_data *data = i2c_get_clientdata(client); - u8 reg; - int reg_val; - - if (attr->index == CPLD_ID) { - reg = CPLD_ID_REG; - I2C_READ_BYTE_DATA(reg_val, &data->access_lock, client, reg); - if (reg_val < 0) - return -1; - return sprintf(buf, "0x%02x\n", reg_val); - } - return -1; -} - -/* get board type register value */ -static ssize_t read_board_type(struct device *dev, - struct device_attribute *da, - char *buf) -{ - struct sensor_device_attribute *attr = to_sensor_dev_attr(da); - struct i2c_client *client = to_i2c_client(dev); - struct cpld_data *data = i2c_get_clientdata(client); - u8 reg; - int reg_val; - - if (attr->index == CPLD_BOARD_TYPE) { - reg = CPLD_BOARD_TYPE_REG; - I2C_READ_BYTE_DATA(reg_val, &data->access_lock, client, reg); - if (reg_val < 0) - return -1; - return sprintf(buf, "0x%02x\n", reg_val); - } - return -1; -} - -/* get extend board type register value */ -static ssize_t read_ext_board_type(struct device *dev, - struct device_attribute *da, - char *buf) -{ - struct sensor_device_attribute *attr = to_sensor_dev_attr(da); - struct i2c_client *client = to_i2c_client(dev); - struct cpld_data *data = i2c_get_clientdata(client); - u8 reg; - int reg_val; - - if (attr->index == CPLD_EXT_BOARD_TYPE) { - reg = CPLD_EXT_BOARD_TYPE_REG; - I2C_READ_BYTE_DATA(reg_val, &data->access_lock, client, reg); - if (reg_val < 0) - return -1; - return sprintf(buf, "0x%02x\n", reg_val); - } - return -1; -} - -/* get qsfp port status register value */ -static ssize_t read_qsfp_port_status(struct device *dev, - struct device_attribute *da, - char *buf) -{ - struct sensor_device_attribute *attr = to_sensor_dev_attr(da); - struct i2c_client *client = to_i2c_client(dev); - struct cpld_data *data = i2c_get_clientdata(client); - u8 reg; - int reg_val; - - if (attr->index >= CPLD_QSFP_PORT_STATUS_1 && - attr->index <= CPLD_QSFP_PORT_STATUS_13) { - reg = CPLD_QSFP_PORT_STATUS_BASE_REG + - (attr->index - CPLD_QSFP_PORT_STATUS_1); - I2C_READ_BYTE_DATA(reg_val, &data->access_lock, client, reg); - if (reg_val < 0) - return -1; - return sprintf(buf, "0x%02x\n", reg_val); - } - return -1; -} - -/* get qsfp port config register value */ -static ssize_t read_qsfp_port_config(struct device *dev, - struct device_attribute *da, - char *buf) -{ - struct sensor_device_attribute *attr = to_sensor_dev_attr(da); - struct i2c_client *client = to_i2c_client(dev); - struct cpld_data *data = i2c_get_clientdata(client); - u8 reg; - int reg_val; - - if (attr->index >= CPLD_QSFP_PORT_CONFIG_1 && - attr->index <= CPLD_QSFP_PORT_CONFIG_13) { - reg = CPLD_QSFP_PORT_CONFIG_BASE_REG + - (attr->index - CPLD_QSFP_PORT_CONFIG_1); - I2C_READ_BYTE_DATA(reg_val, &data->access_lock, client, reg); - if (reg_val < 0) - return -1; - return sprintf(buf, "0x%02x\n", reg_val); - } - return -1; -} - -/* set value to qsfp port config register */ -static ssize_t write_qsfp_port_config(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 cpld_data *data = i2c_get_clientdata(client); - u8 reg, reg_val; - int ret; - - if (kstrtou8(buf, 0, ®_val) < 0) - return -EINVAL; - - if (attr->index >= CPLD_QSFP_PORT_CONFIG_1 && - attr->index <= CPLD_QSFP_PORT_CONFIG_13) { - reg = CPLD_QSFP_PORT_CONFIG_BASE_REG + - (attr->index - CPLD_QSFP_PORT_CONFIG_1); - I2C_WRITE_BYTE_DATA(ret, &data->access_lock, - client, reg, reg_val); - } - return count; -} - -/* get qsfp port interrupt register value */ -static ssize_t read_qsfp_port_interrupt(struct device *dev, - struct device_attribute *da, - char *buf) -{ - struct sensor_device_attribute *attr = to_sensor_dev_attr(da); - struct i2c_client *client = to_i2c_client(dev); - struct cpld_data *data = i2c_get_clientdata(client); - u8 reg; - int reg_val; - - if (attr->index == CPLD_QSFP_PORT_INTERRUPT) { - reg = CPLD_QSFP_PORT_INTERRUPT_REG; - I2C_READ_BYTE_DATA(reg_val, &data->access_lock, client, reg); - if (reg_val < 0) - return -1; - return sprintf(buf, "0x%02x\n", reg_val); - } - return -1; -} - -/* get sfp port status register value */ -static ssize_t read_sfp_port_status(struct device *dev, - struct device_attribute *da, - char *buf) -{ - struct sensor_device_attribute *attr = to_sensor_dev_attr(da); - struct i2c_client *client = to_i2c_client(dev); - struct cpld_data *data = i2c_get_clientdata(client); - u8 reg; - int reg_val; - - if (attr->index == CPLD_SFP_PORT_STATUS) { - reg = CPLD_SFP_PORT_STATUS_REG; - I2C_READ_BYTE_DATA(reg_val, &data->access_lock, client, reg); - if (reg_val < 0) - return -1; - return sprintf(buf, "0x%02x\n", reg_val); - } - return -1; -} - -/* get sfp port config register value */ -static ssize_t read_sfp_port_config(struct device *dev, - struct device_attribute *da, - char *buf) -{ - struct sensor_device_attribute *attr = to_sensor_dev_attr(da); - struct i2c_client *client = to_i2c_client(dev); - struct cpld_data *data = i2c_get_clientdata(client); - u8 reg; - int reg_val; - - if (attr->index == CPLD_SFP_PORT_CONFIG) { - reg = CPLD_SFP_PORT_CONFIG_REG; - I2C_READ_BYTE_DATA(reg_val, &data->access_lock, client, reg); - if (reg_val < 0) - return -1; - return sprintf(buf, "0x%02x\n", reg_val); - } - return -1; -} - -/* set value to sfp port config register */ -static ssize_t write_sfp_port_config(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 cpld_data *data = i2c_get_clientdata(client); - u8 reg, reg_val; - int ret; - - if (kstrtou8(buf, 0, ®_val) < 0) - return -EINVAL; - - if (attr->index == CPLD_SFP_PORT_CONFIG) { - reg = CPLD_SFP_PORT_CONFIG_REG; - I2C_WRITE_BYTE_DATA(ret, &data->access_lock, - client, reg, reg_val); - } - return count; -} - -/* get 10g mux config register value */ -static ssize_t read_10gmux_config(struct device *dev, - struct device_attribute *da, - char *buf) -{ - struct sensor_device_attribute *attr = to_sensor_dev_attr(da); - struct i2c_client *client = to_i2c_client(dev); - struct cpld_data *data = i2c_get_clientdata(client); - u8 reg; - int reg_val; - - if (attr->index == CPLD_10GMUX_CONFIG) { - reg = CPLD_10GMUX_CONFIG_REG; - I2C_READ_BYTE_DATA(reg_val, &data->access_lock, client, reg); - if (reg_val < 0) - return -1; - return sprintf(buf, "0x%02x\n", reg_val); - } - return -1; -} - -/* set value to 10g mux config register */ -static ssize_t write_10gmux_config(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 cpld_data *data = i2c_get_clientdata(client); - u8 reg, reg_val; - int ret; - - if (kstrtou8(buf, 0, ®_val) < 0) - return -EINVAL; - - if (attr->index == CPLD_10GMUX_CONFIG) { - reg = CPLD_10GMUX_CONFIG_REG; - I2C_WRITE_BYTE_DATA(ret, &data->access_lock, - client, reg, reg_val); - } - return count; -} - -/* get bmc status register value */ -static ssize_t read_bmc_status(struct device *dev, - struct device_attribute *da, - char *buf) -{ - struct sensor_device_attribute *attr = to_sensor_dev_attr(da); - struct i2c_client *client = to_i2c_client(dev); - struct cpld_data *data = i2c_get_clientdata(client); - u8 reg; - int reg_val; - - if (attr->index == CPLD_BMC_STATUS) { - reg = CPLD_BMC_STATUS_REG; - I2C_READ_BYTE_DATA(reg_val, &data->access_lock, client, reg); - if (reg_val < 0) - return -1; - return sprintf(buf, "0x%02x\n", reg_val); - } - return -1; -} - -/* get bmc watchdog register value */ -static ssize_t read_bmc_watchdog(struct device *dev, - struct device_attribute *da, - char *buf) -{ - struct sensor_device_attribute *attr = to_sensor_dev_attr(da); - struct i2c_client *client = to_i2c_client(dev); - struct cpld_data *data = i2c_get_clientdata(client); - u8 reg; - int reg_val; - - if (attr->index == CPLD_BMC_WATCHDOG) { - reg = CPLD_BMC_WATCHDOG_REG; - I2C_READ_BYTE_DATA(reg_val, &data->access_lock, client, reg); - if (reg_val < 0) - return -1; - return sprintf(buf, "0x%02x\n", reg_val); - } - return -1; -} - -/* set value to bmc watchdog register */ -static ssize_t write_bmc_watchdog(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 cpld_data *data = i2c_get_clientdata(client); - u8 reg, reg_val; - int ret; - - if (kstrtou8(buf, 0, ®_val) < 0) - return -EINVAL; - - if (attr->index == CPLD_BMC_WATCHDOG) { - reg = CPLD_BMC_WATCHDOG_REG; - I2C_WRITE_BYTE_DATA(ret, &data->access_lock, - client, reg, reg_val); - } - return count; -} - -/* get usb status register value */ -static ssize_t read_usb_status(struct device *dev, - struct device_attribute *da, - char *buf) -{ - struct sensor_device_attribute *attr = to_sensor_dev_attr(da); - struct i2c_client *client = to_i2c_client(dev); - struct cpld_data *data = i2c_get_clientdata(client); - u8 reg; - int reg_val; - - if (attr->index == CPLD_USB_STATUS) { - reg = CPLD_USB_STATUS_REG; - I2C_READ_BYTE_DATA(reg_val, &data->access_lock, client, reg); - if (reg_val < 0) - return -1; - return sprintf(buf, "0x%02x\n", reg_val); - } - return -1; -} - -/* get reset control register value */ -static ssize_t read_reset_control(struct device *dev, - struct device_attribute *da, - char *buf) -{ - struct sensor_device_attribute *attr = to_sensor_dev_attr(da); - struct i2c_client *client = to_i2c_client(dev); - struct cpld_data *data = i2c_get_clientdata(client); - u8 reg; - int reg_val; - - if (attr->index == CPLD_RESET_CONTROL) { - reg = CPLD_RESET_CONTROL_REG; - I2C_READ_BYTE_DATA(reg_val, &data->access_lock, client, reg); - if (reg_val < 0) - return -1; - return sprintf(buf, "0x%02x\n", reg_val); - } - return -1; -} - -/* set value to reset control register */ -static ssize_t write_reset_control(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 cpld_data *data = i2c_get_clientdata(client); - u8 reg, reg_val; - int ret; - - if (kstrtou8(buf, 0, ®_val) < 0) - return -EINVAL; - - if (attr->index == CPLD_RESET_CONTROL) { - reg = CPLD_RESET_CONTROL_REG; - I2C_WRITE_BYTE_DATA(ret, &data->access_lock, - client, reg, reg_val); - } - return count; -} - -/* get sfp port 0/1 led register */ -static ssize_t read_sfp_led(struct device *dev, - struct device_attribute *da, - char *buf) -{ - struct sensor_device_attribute *attr = to_sensor_dev_attr(da); - struct i2c_client *client = to_i2c_client(dev); - struct cpld_data *data = i2c_get_clientdata(client); - u8 reg; - int reg_val; - - if (attr->index == CPLD_SFP_LED) { - reg = CPLD_SFP_LED_REG; - I2C_READ_BYTE_DATA(reg_val, &data->access_lock, client, reg); - if (reg_val < 0) - return -1; - return sprintf(buf, "0x%02x\n", reg_val); - } - return -1; -} - -/* set value to sfp 0/1 port led register */ -static ssize_t write_sfp_led(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 cpld_data *data = i2c_get_clientdata(client); - u8 reg, reg_val; - int ret; - - if (kstrtou8(buf, 0, ®_val) < 0) - return -EINVAL; - - if (attr->index == CPLD_SFP_LED) { - reg = CPLD_SFP_LED_REG; - I2C_WRITE_BYTE_DATA(ret, &data->access_lock, - client, reg, reg_val); - } - return count; -} - -/* get sfp port 0/1 led blink register */ -static ssize_t read_sfp_led_blink(struct device *dev, - struct device_attribute *da, - char *buf) -{ - struct sensor_device_attribute *attr = to_sensor_dev_attr(da); - struct i2c_client *client = to_i2c_client(dev); - struct cpld_data *data = i2c_get_clientdata(client); - u8 reg; - int reg_val; - - if (attr->index == CPLD_SFP_LED_BLINK) { - reg = CPLD_SFP_LED_BLINK_REG; - I2C_READ_BYTE_DATA(reg_val, &data->access_lock, client, reg); - if (reg_val < 0) - return -1; - return sprintf(buf, "0x%02x\n", reg_val); - } - return -1; -} - -/* set value to sfp port 0/1 led blink register */ -static ssize_t write_sfp_led_blink(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 cpld_data *data = i2c_get_clientdata(client); - u8 reg, reg_val; - int ret; - - if (kstrtou8(buf, 0, ®_val) < 0) - return -EINVAL; - - if (attr->index == CPLD_SFP_LED_BLINK) { - reg = CPLD_SFP_LED_BLINK_REG; - I2C_WRITE_BYTE_DATA(ret, &data->access_lock, - client, reg, reg_val); - } - return count; -} - -/* get qsfp port led register */ -static ssize_t read_qsfp_led(struct device *dev, - struct device_attribute *da, - char *buf) -{ - struct sensor_device_attribute *attr = to_sensor_dev_attr(da); - struct i2c_client *client = to_i2c_client(dev); - struct cpld_data *data = i2c_get_clientdata(client); - u8 reg; - int reg_val; - - if (attr->index >= CPLD_QSFP_LED_1 && - attr->index <= CPLD_QSFP_LED_16) { - reg = CPLD_QSFP_LED_BASE_REG + (attr->index - CPLD_QSFP_LED_1); - I2C_READ_BYTE_DATA(reg_val, &data->access_lock, client, reg); - if (reg_val < 0) - return -1; - return sprintf(buf, "0x%02x\n", reg_val); - } - return -1; -} - -/* set value to qsfp port led register */ -static ssize_t write_qsfp_led(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 cpld_data *data = i2c_get_clientdata(client); - u8 reg, reg_val; - int ret; - - if (kstrtou8(buf, 0, ®_val) < 0) - return -EINVAL; - - if (attr->index >= CPLD_QSFP_LED_1 && - attr->index <= CPLD_QSFP_LED_16) { - reg = CPLD_QSFP_LED_BASE_REG + (attr->index - CPLD_QSFP_LED_1); - I2C_WRITE_BYTE_DATA(ret, &data->access_lock, - client, reg, reg_val); - } - return count; -} - -/* get qsfp 16 port led blink register value in 64 bit map */ -/* - each register for 2 port, each port has 4 channel for led blink - bit 64 56 48 40 32 24 16 8 0 - port 16/15 14/13 12/11 10/9 8/7 6/5 4/3 2/1 - */ -static ssize_t read_qsfp_led_blink(struct device *dev, - struct device_attribute *da, - char *buf) -{ - struct sensor_device_attribute *attr = to_sensor_dev_attr(da); - struct i2c_client *client = to_i2c_client(dev); - struct cpld_data *data = i2c_get_clientdata(client); - u8 reg; - int reg_val, i; - u64 bitmap = 0; - - if (attr->index == CPLD_QSFP_LED_BLINK) { - for (i = 0; i <= 7; i++) { - reg = CPLD_QSFP_LED_BLINK_BASE_REG + i; - I2C_READ_BYTE_DATA(reg_val, &data->access_lock, client, reg); - if (reg_val < 0) - return -1; - reg_val = reg_val & 0xff; - bitmap = bitmap | (reg_val<<(i*8)); - } - return sprintf(buf, "0x%llx\n", bitmap); - } - return -1; -} - -/* set 64 bit map value to qsfp port led blink register */ -/* - each register for 2 port, each port has 4 channel for led blink - bit 63 56 48 40 32 24 16 8 0 - port 16/15 14/13 12/11 10/9 8/7 6/5 4/3 2/1 - */ -static ssize_t write_qsfp_led_blink(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 cpld_data *data = i2c_get_clientdata(client); - u8 reg, reg_val, i; - int ret; - u64 bitmap = 0; - - if (kstrtou64(buf, 0, &bitmap) < 0) - return -EINVAL; - - if (attr->index == CPLD_QSFP_LED_BLINK) { - for (i = 0; i <= 7; i++) { - reg = CPLD_QSFP_LED_BLINK_BASE_REG + i; - reg_val = (u8)((bitmap >> i*8) & 0xFF); - I2C_WRITE_BYTE_DATA(ret, &data->access_lock, - client, reg, reg_val); - } - } - return count; -} - -/* get retimer reset register */ -static ssize_t read_rtmr_reset(struct device *dev, - struct device_attribute *da, - char *buf) -{ - struct sensor_device_attribute *attr = to_sensor_dev_attr(da); - struct i2c_client *client = to_i2c_client(dev); - struct cpld_data *data = i2c_get_clientdata(client); - u8 reg; - int reg_val; - - if (attr->index == CPLD_RTMR_RESET) { - reg = CPLD_RTMR_RESET_REG; - I2C_READ_BYTE_DATA(reg_val, &data->access_lock, client, reg); - if (reg_val < 0) - return -1; - return sprintf(buf, "0x%02x\n", reg_val); - } - return -1; -} - -/* set value to retimer reset register */ -static ssize_t write_rtmr_reset(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 cpld_data *data = i2c_get_clientdata(client); - u8 reg, reg_val; - int ret; - - if (kstrtou8(buf, 0, ®_val) < 0) - return -EINVAL; - - if (attr->index == CPLD_RTMR_RESET) { - reg = CPLD_RTMR_RESET_REG; - I2C_WRITE_BYTE_DATA(ret, &data->access_lock, - client, reg, reg_val); - } - return count; -} - -/* get rov status register */ -static ssize_t read_rov_status(struct device *dev, - struct device_attribute *da, - char *buf) -{ - struct sensor_device_attribute *attr = to_sensor_dev_attr(da); - struct i2c_client *client = to_i2c_client(dev); - struct cpld_data *data = i2c_get_clientdata(client); - u8 reg; - int reg_val; - - if (attr->index == CPLD_ROV_STATUS) { - reg = CPLD_ROV_STATUS_REG; - I2C_READ_BYTE_DATA(reg_val, &data->access_lock, client, reg); - if (reg_val < 0) - return -1; - return sprintf(buf, "0x%02x\n", reg_val); - } - return -1; -} - -/* add valid cpld client to list */ -static void ingrasys_i2c_cpld_add_client(struct i2c_client *client) -{ - struct cpld_client_node *node = NULL; - - node = kzalloc(sizeof(struct cpld_client_node), GFP_KERNEL); - if (!node) { - dev_info(&client->dev, - "Can't allocate cpld_client_node for index %d\n", - client->addr); - return; - } - - node->client = client; - - mutex_lock(&list_lock); - list_add(&node->list, &cpld_client_list); - mutex_unlock(&list_lock); -} - -/* remove exist cpld client in list */ -static void ingrasys_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); -} - -/* cpld drvier probe */ -static int ingrasys_i2c_cpld_probe(struct i2c_client *client, - const struct i2c_device_id *dev_id) -{ - int status; - struct cpld_data *data = NULL; - int ret = -EPERM; - int idx; - - data = kzalloc(sizeof(struct cpld_data), GFP_KERNEL); - if (!data) - return -ENOMEM; - - /* init cpld data for client */ - i2c_set_clientdata(client, data); - mutex_init(&data->access_lock); - - if (!i2c_check_functionality(client->adapter, - I2C_FUNC_SMBUS_BYTE_DATA)) { - dev_info(&client->dev, - "i2c_check_functionality failed (0x%x)\n", - client->addr); - status = -EIO; - goto exit; - } - - /* get cpld id from device */ - ret = i2c_smbus_read_byte_data(client, CPLD_ID_REG); - - if (ret < 0) { - dev_info(&client->dev, - "fail to get cpld id (0x%x) at addr (0x%x)\n", - CPLD_ID_REG, client->addr); - status = -EIO; - goto exit; - } - - CPLD_ID_ID_GET(ret, idx); - - if (INVALID(idx, cpld1, cpld5)) { - dev_info(&client->dev, - "cpld id %d(device) not valid\n", idx); - //status = -EPERM; - //goto exit; - } - -#if 0 - /* change client name for each cpld with index */ - snprintf(client->name, sizeof(client->name), "%s_%d", client->name, - data->index); -#endif - - data->index = dev_id->driver_data; - - /* register sysfs hooks for different cpld group */ - dev_info(&client->dev, "probe cpld with index %d\n", data->index); - switch (data->index) { - case cpld1: - status = sysfs_create_group(&client->dev.kobj, - &s9280_64x_cpld1_group); - break; - case cpld2: - case cpld3: - case cpld4: - case cpld5: - status = sysfs_create_group(&client->dev.kobj, - &s9280_64x_cpld2345_group); - break; - default: - status = -EINVAL; - } - - if (status) - goto exit; - - dev_info(&client->dev, "chip found\n"); - - /* add probe chip to client list */ - ingrasys_i2c_cpld_add_client(client); - - return 0; -exit: - sysfs_remove_group(&client->dev.kobj, &s9280_64x_cpld2345_group); - return status; -} - -/* cpld drvier remove */ -static int ingrasys_i2c_cpld_remove(struct i2c_client *client) -{ - struct cpld_data *data = i2c_get_clientdata(client); - - switch (data->index) { - case cpld1: - sysfs_remove_group(&client->dev.kobj, &s9280_64x_cpld1_group); - break; - case cpld2: - case cpld3: - case cpld4: - case cpld5: - sysfs_remove_group(&client->dev.kobj, - &s9280_64x_cpld2345_group); - break; - } - - ingrasys_i2c_cpld_remove_client(client); - return 0; -} - -MODULE_DEVICE_TABLE(i2c, ingrasys_i2c_cpld_id); - -static struct i2c_driver ingrasys_i2c_cpld_driver = { - .class = I2C_CLASS_HWMON, - .driver = { - .name = "ingrasys_i2c_cpld", - }, - .probe = ingrasys_i2c_cpld_probe, - .remove = ingrasys_i2c_cpld_remove, - .id_table = ingrasys_i2c_cpld_id, - .address_list = cpld_i2c_addr, -}; - -/* provid cpld register read */ -/* cpld_idx indicate the index of cpld device */ -int ingrasys_i2c_cpld_read(u8 cpld_idx, - u8 reg) -{ - struct list_head *list_node = NULL; - struct cpld_client_node *cpld_node = NULL; - int ret = -EPERM; - struct cpld_data *data; - - list_for_each(list_node, &cpld_client_list) { - cpld_node = list_entry(list_node, - struct cpld_client_node, list); - data = i2c_get_clientdata(cpld_node->client); - if (data->index == cpld_idx) { - DEBUG_PRINT("cpld_idx=%d, read reg 0x%02x", - cpld_idx, reg); - I2C_READ_BYTE_DATA(ret, &data->access_lock, - cpld_node->client, reg); - DEBUG_PRINT("cpld_idx=%d, read reg 0x%02x = 0x%02x", - cpld_idx, reg, ret); - break; - } - } - - return ret; -} -EXPORT_SYMBOL(ingrasys_i2c_cpld_read); - -/* provid cpld register write */ -/* cpld_idx indicate the index of cpld device */ -int ingrasys_i2c_cpld_write(u8 cpld_idx, - u8 reg, - u8 value) -{ - struct list_head *list_node = NULL; - struct cpld_client_node *cpld_node = NULL; - int ret = -EIO; - struct cpld_data *data; - - list_for_each(list_node, &cpld_client_list) { - cpld_node = list_entry(list_node, - struct cpld_client_node, list); - data = i2c_get_clientdata(cpld_node->client); - - if (data->index == cpld_idx) { - I2C_WRITE_BYTE_DATA(ret, &data->access_lock, - cpld_node->client, - reg, value); - DEBUG_PRINT("cpld_idx=%d, write reg 0x%02x val 0x%02x, ret=%d", - cpld_idx, reg, value, ret); - break; - } - } - - return ret; -} -EXPORT_SYMBOL(ingrasys_i2c_cpld_write); - -/* provid qsfp port status register read */ -/* port_num indicate the front panel qsfp port number */ -int ingrasys_i2c_cpld_get_qsfp_port_status_val(u8 port_num) -{ - u8 cpld_idx, cpld_port, reg; - int reg_val; - - if (INVALID(port_num, QSFP_MIN_PORT_NUM, QSFP_MAX_PORT_NUM)) { - DEBUG_PRINT("invalid input value %d", port_num); - return -1; - } - QSFP_TO_CPLD_IDX(port_num, cpld_idx, cpld_port); - reg = QSFP_PORT_STATUS_REG(cpld_port); - DEBUG_PRINT("port_num=%d, cpld_idx=%d, cpld_port=%d, reg=0x%x", - port_num, cpld_idx, cpld_port, reg); - reg_val = ingrasys_i2c_cpld_read(cpld_idx, reg); - return reg_val; -} -EXPORT_SYMBOL(ingrasys_i2c_cpld_get_qsfp_port_status_val); - -/* provid qsfp port config register read */ -/* port_num indicate the front panel qsfp port number */ -int ingrasys_i2c_cpld_get_qsfp_port_config_val(u8 port_num) -{ - u8 cpld_idx, cpld_port, reg; - int reg_val; - - if (INVALID(port_num, QSFP_MIN_PORT_NUM, QSFP_MAX_PORT_NUM)) { - DEBUG_PRINT("invalid input value %d", port_num); - return -1; - } - QSFP_TO_CPLD_IDX(port_num, cpld_idx, cpld_port); - reg = QSFP_PORT_CONFIG_REG(cpld_port); - DEBUG_PRINT("port_num=%d, cpld_idx=%d, cpld_port=%d, reg=0x%x", - port_num, cpld_idx, cpld_port, reg); - reg_val = ingrasys_i2c_cpld_read(cpld_idx, reg); - return reg_val; -} -EXPORT_SYMBOL(ingrasys_i2c_cpld_get_qsfp_port_config_val); - -/* provid qsfp port config register write */ -/* port_num indicate the front panel qsfp port number */ -int ingrasys_i2c_cpld_set_qsfp_port_config_val(u8 port_num, - u8 reg_val) -{ - u8 cpld_idx, cpld_port, reg, ret; - - if (INVALID(port_num, QSFP_MIN_PORT_NUM, QSFP_MAX_PORT_NUM)) { - DEBUG_PRINT("invalid input value %d", port_num); - return -1; - } - QSFP_TO_CPLD_IDX(port_num, cpld_idx, cpld_port); - reg = QSFP_PORT_CONFIG_REG(cpld_port); - DEBUG_PRINT("port_num=%d, cpld_idx=%d, cpld_port=%d, reg=0x%x", - port_num, cpld_idx, cpld_port, reg); - ret = ingrasys_i2c_cpld_write(cpld_idx, reg, reg_val); - return ret; -} -EXPORT_SYMBOL(ingrasys_i2c_cpld_set_qsfp_port_config_val); - -/* provid sfp port 0/1 status register read */ -int ingrasys_i2c_cpld_get_sfp_port_status_val(void) -{ - u8 cpld_idx, reg; - int reg_val; - - cpld_idx = cpld1; - reg = CPLD_SFP_PORT_STATUS_REG; - DEBUG_PRINT("cpld_idx=%d, reg=0x%x", - cpld_idx, reg); - reg_val = ingrasys_i2c_cpld_read(cpld_idx, reg); - return reg_val; -} -EXPORT_SYMBOL(ingrasys_i2c_cpld_get_sfp_port_status_val); - -/* provid qsfp port config register read */ -/* port_num indicate the front panel qsfp port number */ -int ingrasys_i2c_cpld_get_sfp_port_config_val(void) -{ - u8 cpld_idx, reg; - int reg_val; - - cpld_idx = cpld1; - reg = CPLD_SFP_PORT_CONFIG_REG; - DEBUG_PRINT("cpld_idx=%d, reg=0x%x", - cpld_idx, reg); - reg_val = ingrasys_i2c_cpld_read(cpld_idx, reg); - return reg_val; -} -EXPORT_SYMBOL(ingrasys_i2c_cpld_get_sfp_port_config_val); - -/* provid qsfp port config register write */ -/* port_num indicate the front panel qsfp port number */ -int ingrasys_i2c_cpld_set_sfp_port_config_val(u8 reg_val) -{ - u8 cpld_idx, reg, ret; - - cpld_idx = cpld1; - reg = CPLD_SFP_PORT_CONFIG_REG; - DEBUG_PRINT("cpld_idx=%d, reg=0x%x", - cpld_idx, reg); - ret = ingrasys_i2c_cpld_write(cpld_idx, reg, reg_val); - return ret; -} -EXPORT_SYMBOL(ingrasys_i2c_cpld_set_sfp_port_config_val); - -static int __init ingrasys_i2c_cpld_init(void) -{ - mutex_init(&list_lock); - return i2c_add_driver(&ingrasys_i2c_cpld_driver); -} - -static void __exit ingrasys_i2c_cpld_exit(void) -{ - i2c_del_driver(&ingrasys_i2c_cpld_driver); -} - -MODULE_AUTHOR("Leo Lin "); -MODULE_DESCRIPTION("ingrasys_i2c_cpld driver"); -MODULE_LICENSE("GPL"); - -module_init(ingrasys_i2c_cpld_init); -module_exit(ingrasys_i2c_cpld_exit); - diff --git a/packages/platforms/ingrasys/x86-64/s9280-64x/modules/builds/ingrasys_s9280_64x_i2c_cpld.h b/packages/platforms/ingrasys/x86-64/s9280-64x/modules/builds/ingrasys_s9280_64x_i2c_cpld.h deleted file mode 100644 index c118f0a7d..000000000 --- a/packages/platforms/ingrasys/x86-64/s9280-64x/modules/builds/ingrasys_s9280_64x_i2c_cpld.h +++ /dev/null @@ -1,338 +0,0 @@ -/* header file for i2c cpld driver of ingrasys_s9280_64x - * - * Copyright (C) 2017 Ingrasys Technology Corporation. - * Leo Lin - * - * 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. - */ - -#ifndef INGRASYS_S9280_64X_I2C_CPLD_H -#define INGRASYS_S9280_64X_I2C_CPLD_H - -/* CPLD device index value */ -enum cpld_id { - cpld1, - cpld2, - cpld3, - cpld4, - cpld5 -}; - -enum LED_BLINK { - BLINK, - NOBLINK, -}; - -enum LED_YELLOW { - YELLOW_OFF, - YELLOW_ON, -}; - -enum LED_GREEN { - GREEN_OFF, - GREEN_ON, -}; - -/* port number on CPLD */ -#define CPLD_1_PORT_NUM 12 -#define CPLD_2_PORT_NUM 13 - -/* QSFP port number */ -#define QSFP_MAX_PORT_NUM 64 -#define QSFP_MIN_PORT_NUM 1 - -/* SFP+ port number */ -#define SFP_MAX_PORT_NUM 2 -#define SFP_MIN_PORT_NUM 1 - - -/* CPLD registers */ -#define CPLD_BOARD_TYPE_REG 0x0 -#define CPLD_EXT_BOARD_TYPE_REG 0x7 -#define CPLD_VERSION_REG 0x1 -#define CPLD_ID_REG 0x2 -#define CPLD_QSFP_PORT_STATUS_BASE_REG 0x20 -#define CPLD_QSFP_PORT_CONFIG_BASE_REG 0x30 -#define CPLD_QSFP_PORT_INTERRUPT_REG 0x40 -#define CPLD_SFP_PORT_STATUS_REG 0x2F -#define CPLD_SFP_PORT_CONFIG_REG 0x3F -#define CPLD_QSFP_PORT_INTERRUPT_REG 0x40 -#define CPLD_10GMUX_CONFIG_REG 0x41 -#define CPLD_BMC_STATUS_REG 0x42 -#define CPLD_BMC_WATCHDOG_REG 0x43 -#define CPLD_USB_STATUS_REG 0x44 -#define CPLD_RESET_CONTROL_REG 0x4A -#define CPLD_SFP_LED_REG 0x80 -#define CPLD_SFP_LED_BLINK_REG 0x90 -#define CPLD_QSFP_LED_BASE_REG 0x80 -#define CPLD_QSFP_LED_BLINK_BASE_REG 0x90 -#define CPLD_RTMR_RESET_REG 0x4B -#define CPLD_ROV_STATUS_REG 0x4C - -/* bit definition for register value */ -enum CPLD_QSFP_PORT_STATUS_BITS { - CPLD_QSFP_PORT_STATUS_INT_BIT, - CPLD_QSFP_PORT_STATUS_ABS_BIT, -}; -enum CPLD_QSFP_PORT_CONFIG_BITS { - CPLD_QSFP_PORT_CONFIG_RESET_BIT, - CPLD_QSFP_PORT_CONFIG_RESERVE_BIT, - CPLD_QSFP_PORT_CONFIG_LPMODE_BIT, -}; -enum CPLD_SFP_PORT_STATUS_BITS { - CPLD_SFP0_PORT_STATUS_PRESENT_BIT, - CPLD_SFP0_PORT_STATUS_TXFAULT_BIT, - CPLD_SFP0_PORT_STATUS_RXLOS_BIT, - CPLD_SFP_PORT_STATUS_DUMMY, - CPLD_SFP1_PORT_STATUS_PRESENT_BIT, - CPLD_SFP1_PORT_STATUS_TXFAULT_BIT, - CPLD_SFP1_PORT_STATUS_RXLOS_BIT, -}; -enum CPLD_SFP_PORT_CONFIG_BITS { - CPLD_SFP0_PORT_CONFIG_TXDIS_BIT, - CPLD_SFP0_PORT_CONFIG_RS_BIT, - CPLD_SFP0_PORT_CONFIG_TS_BIT, - CPLD_SFP_PORT_CONFIG_DUMMY, - CPLD_SFP1_PORT_CONFIG_TXDIS_BIT, - CPLD_SFP1_PORT_CONFIG_RS_BIT, - CPLD_SFP1_PORT_CONFIG_TS_BIT, - -}; -enum CPLD_10GMUX_CONFIG_BITS { - CPLD_10GMUX_CONFIG_ENSMB_BIT, - CPLD_10GMUX_CONFIG_ENINPUT_BIT, - CPLD_10GMUX_CONFIG_SEL1_BIT, - CPLD_10GMUX_CONFIG_SEL0_BIT, -}; -enum CPLD_BMC_WATCHDOG_BITS { - CPLD_10GMUX_CONFIG_ENTIMER_BIT, - CPLD_10GMUX_CONFIG_TIMEOUT_BIT, -}; -enum CPLD_RESET_CONTROL_BITS { - CPLD_RESET_CONTROL_SWRST_BIT, - CPLD_RESET_CONTROL_CP2104RST_BIT, - CPLD_RESET_CONTROL_82P33814RST_BIT, - CPLD_RESET_CONTROL_BMCRST_BIT, -}; -enum CPLD_SFP_LED_BITS { - CPLD_SFP_LED_SFP0_GREEN_BIT, - CPLD_SFP_LED_SFP0_YELLOW_BIT, - CPLD_SFP_LED_SFP1_GREEN_BIT, - CPLD_SFP_LED_SFP1_YELLOW_BIT, -}; -enum CPLD_SFP_LED_BLINK_BITS { - CPLD_SFP_LED_BLINK_SFP0_BIT, - CPLD_SFP_LED_BLINK_SFP1_BIT, -}; -enum CPLD_QSFP_LED_BITS { - CPLD_QSFP_LED_CHAN_0_GREEN_BIT, - CPLD_QSFP_LED_CHAN_0_YELLOW_BIT, - CPLD_QSFP_LED_CHAN_1_GREEN_BIT, - CPLD_QSFP_LED_CHAN_1_YELLOW_BIT, - CPLD_QSFP_LED_CHAN_2_GREEN_BIT, - CPLD_QSFP_LED_CHAN_2_YELLOW_BIT, - CPLD_QSFP_LED_CHAN_3_GREEN_BIT, - CPLD_QSFP_LED_CHAN_3_YELLOW_BIT, - -}; -enum CPLD_QSFP_LED_BLINK_BITS { - CPLD_QSFP_LED_BLINK_X_CHAN0_BIT, - CPLD_QSFP_LED_BLINK_X_CHAN1_BIT, - CPLD_QSFP_LED_BLINK_X_CHAN2_BIT, - CPLD_QSFP_LED_BLINK_X_CHAN3_BIT, - CPLD_QSFP_LED_BLINK_XPLUS_CHAN0_BIT, - CPLD_QSFP_LED_BLINK_XPLUS_CHAN1_BIT, - CPLD_QSFP_LED_BLINK_XPLUS_CHAN2_BIT, - CPLD_QSFP_LED_BLINK_XPLUS_CHAN3_BIT, -}; - -/* bit field structure for register value */ -struct cpld_reg_board_type_t { - u8 build_rev:2; - u8 hw_rev:2; - u8 board_id:4; -}; - -struct cpld_reg_version_t { - u8 revision:6; - u8 release:1; - u8 reserve:1; -}; - -struct cpld_reg_id_t { - u8 id:3; - u8 release:5; -}; - -/* common manipulation */ -#define INVALID(i, min, max) ((i < min) || (i > max) ? 1u : 0u) -#define READ_BIT(val, bit) ((0u == (val & (1<bf_name) -#define READ_BF_1(bf_struct, val, bf_name, bf_value) \ - bf_struct bf; \ - bf.data = val; \ - bf_value = bf.bf_name -#define BOARD_TYPE_BUILD_REV_GET(val, res) \ - READ_BF(cpld_reg_board_type_t, val, build_rev, res) -#define BOARD_TYPE_HW_REV_GET(val, res) \ - READ_BF(cpld_reg_board_type_t, val, hw_rev, res) -#define BOARD_TYPE_BOARD_ID_GET(val, res) \ - READ_BF(cpld_reg_board_type_t, val, board_id, res) -#define CPLD_VERSION_REV_GET(val, res) \ - READ_BF(cpld_reg_version_t, val, revision, res) -#define CPLD_VERSION_REL_GET(val, res) \ - READ_BF(cpld_reg_version_t, val, release, res) -#define CPLD_ID_ID_GET(val, res) \ - READ_BF(cpld_reg_id_t, val, id, res) -#define CPLD_ID_REL_GET(val, res) \ - READ_BF(cpld_reg_id_t, val, release, res) -/* SFP/QSFP port led registers manipulation */ -#define SFP_LED_TO_CPLD_IDX(sfp_port) cpld1 -#define SFP_LED_REG(sfp_port) CPLD_SFP_LED_REG -#define SFP_LED_BLINK_REG(sfp_port) CPLD_SFP_LED_BLINK_REG -#define QSFP_LED_TO_CPLD_IDX(qsfp_port) \ - ((qsfp_port - 1) / 16 + 2) -#define QSFP_LED_REG(qsfp_port) \ - ((qsfp_port - 1) % 16 + CPLD_QSFP_LED_BASE_REG) -#define QSFP_LED_BLINK_REG(qsfp_port) \ - (((qsfp_port - 1) % 16) / 2 + CPLD_QSFP_LED_BLINK_BASE_REG) -/* QSFP/SFP port status registers manipulation */ -#define QSFP_TO_CPLD_IDX(qsfp_port, cpld_index, cpld_port) \ -{ \ - if (QSFP_MIN_PORT_NUM <= qsfp_port && qsfp_port <= CPLD_1_PORT_NUM) { \ - cpld_index = cpld1; \ - cpld_port = qsfp_port - 1; \ - } else if (CPLD_1_PORT_NUM < qsfp_port \ - && qsfp_port <= QSFP_MAX_PORT_NUM) { \ - cpld_index = cpld2 + (qsfp_port - 1 - CPLD_1_PORT_NUM) \ - / CPLD_2_PORT_NUM; \ - cpld_port = (qsfp_port - 1 - CPLD_1_PORT_NUM) % \ - CPLD_2_PORT_NUM; \ - } else { \ - cpld_index = 0; \ - cpld_port = 0; \ - } \ -} -#define QSFP_PORT_STATUS_REG(cpld_port) \ - (CPLD_QSFP_PORT_STATUS_BASE_REG + cpld_port) -#define QSFP_PORT_CONFIG_REG(cpld_port) \ - (CPLD_QSFP_PORT_CONFIG_BASE_REG + cpld_port) -#define QSFP_PORT_INT_BIT_GET(port_status_value) \ - READ_BIT(port_status_value, CPLD_QSFP_PORT_STATUS_INT_BIT) -#define QSFP_PORT_ABS_BIT_GET(port_status_value) \ - READ_BIT(port_status_value, CPLD_QSFP_PORT_STATUS_ABS_BIT) -#define QSFP_PORT_RESET_BIT_GET(port_config_value) \ - READ_BIT(port_config_value, CPLD_QSFP_PORT_CONFIG_RESET_BIT) -#define QSFP_PORT_LPMODE_BIT_GET(port_config_value) \ - READ_BIT(port_config_value, CPLD_QSFP_PORT_CONFIG_LPMODE_BIT) -#define QSFP_PORT_RESET_BIT_SET(port_config_value) \ - SET_BIT(port_config_value, CPLD_QSFP_PORT_CONFIG_RESET_BIT) -#define QSFP_PORT_RESET_BIT_CLEAR(port_config_value) \ - CLEAR_BIT(port_config_value, CPLD_QSFP_PORT_CONFIG_RESET_BIT) -#define QSFP_PORT_LPMODE_BIT_SET(port_config_value) \ - SET_BIT(port_config_value, CPLD_QSFP_PORT_CONFIG_LPMODE_BIT) -#define QSFP_PORT_LPMODE_BIT_CLEAR(port_config_value) \ - CLEAR_BIT(port_config_value, CPLD_QSFP_PORT_CONFIG_LPMODE_BIT) -#define SFP_PORT_PRESENT_BIT_GET(sfp_port, port_status_value) \ - if (sfp_port == SFP_MIN_PORT_NUM) { \ - READ_BIT(port_status_value, CPLD_SFP0_PORT_STATUS_PRESENT_BIT); \ - } else { \ - READ_BIT(port_status_value, CPLD_SFP1_PORT_STATUS_PRESENT_BIT); \ - } -#define SFP_PORT_TXFAULT_BIT_GET(sfp_port, port_status_value) \ - if (sfp_port == SFP_MIN_PORT_NUM) { \ - READ_BIT(port_status_value, CPLD_SFP0_PORT_STATUS_TXFAULT_BIT); \ - } else { \ - READ_BIT(port_status_value, CPLD_SFP1_PORT_STATUS_TXFAULT_BIT); \ - } -#define SFP_PORT_RXLOS_BIT_GET(sfp_port, port_status_value) \ - if (sfp_port == SFP_MIN_PORT_NUM) { \ - READ_BIT(port_status_value, CPLD_SFP0_PORT_STATUS_RXLOS_BIT); \ - } else { \ - READ_BIT(port_status_value, CPLD_SFP1_PORT_STATUS_RXLOS_BIT); \ - } -#define SFP_PORT_TXDIS_BIT_GET(sfp_port, port_config_value) \ - if (sfp_port == SFP_MIN_PORT_NUM) { \ - READ_BIT(port_config_value, CPLD_SFP0_PORT_CONFIG_TXDIS_BIT); \ - } else { \ - READ_BIT(port_config_value, CPLD_SFP1_PORT_STATUS_RXLOS_BIT); \ - } -#define SFP_PORT_RS_BIT_GET(sfp_port, port_config_value) \ - if (sfp_port == SFP_MIN_PORT_NUM) { \ - READ_BIT(port_config_value, CPLD_SFP0_PORT_CONFIG_RS_BIT); \ - } else { \ - READ_BIT(port_config_value, CPLD_SFP1_PORT_CONFIG_RS_BIT); \ - } -#define SFP_PORT_TS_BIT_GET(sfp_port, port_config_value) \ - if (sfp_port == SFP_MIN_PORT_NUM) { \ - READ_BIT(port_config_value, CPLD_SFP0_PORT_CONFIG_TS_BIT); \ - } else { \ - READ_BIT(port_config_value, CPLD_SFP0_PORT_CONFIG_TS_BIT); \ - } -#define SFP_PORT_TXDIS_BIT_SET(sfp_port, port_config_value) \ - if (sfp_port == SFP_MIN_PORT_NUM) { \ - SET_BIT(port_config_value, CPLD_SFP0_PORT_CONFIG_TXDIS_BIT); \ - } else { \ - SET_BIT(port_config_value, CPLD_SFP1_PORT_CONFIG_TXDIS_BIT); \ - } -#define SFP_PORT_TXDIS_BIT_CLEAR(sfp_port, port_config_value) \ - if (sfp_port == SFP_MIN_PORT_NUM) { \ - CLEAR_BIT(port_config_value, CPLD_SFP0_PORT_CONFIG_TXDIS_BIT); \ - } else { \ - CLEAR_BIT(port_config_value, CPLD_SFP1_PORT_CONFIG_TXDIS_BIT); \ - } -#define SFP_PORT_RS_BIT_SET(sfp_port, port_config_value) \ - if (sfp_port == SFP_MIN_PORT_NUM) { \ - SET_BIT(port_config_value, CPLD_SFP0_PORT_CONFIG_RS_BIT); \ - } else { \ - SET_BIT(port_config_value, CPLD_SFP1_PORT_CONFIG_RS_BIT); \ - } -#define SFP_PORT_RS_BIT_CLEAR(sfp_port, port_config_value) \ - if (sfp_port == SFP_MIN_PORT_NUM) { \ - CLEAR_BIT(port_config_value, CPLD_SFP0_PORT_CONFIG_RS_BIT); \ - } else { \ - CLEAR_BIT(port_config_value, CPLD_SFP1_PORT_CONFIG_RS_BIT); \ - } -#define SFP_PORT_TS_BIT_SET(sfp_port, port_config_value) \ - if (sfp_port == SFP_MIN_PORT_NUM) { \ - SET_BIT(port_config_value, CPLD_SFP0_PORT_CONFIG_TS_BIT); \ - } else { \ - SET_BIT(port_config_value, CPLD_SFP1_PORT_CONFIG_TS_BIT); \ - } -#define SFP_PORT_TS_BIT_CLEAR(sfp_port, port_config_value) \ - if (sfp_port == SFP_MIN_PORT_NUM) { \ - CLEAR_BIT(port_config_value, CPLD_SFP0_PORT_CONFIG_TS_BIT); \ - } else { \ - CLEAR_BIT(port_config_value, CPLD_SFP1_PORT_CONFIG_TS_BIT); \ - } - -/* CPLD access functions */ -extern int ingrasys_i2c_cpld_get_qsfp_port_status_val(u8 port_num); -extern int ingrasys_i2c_cpld_get_qsfp_port_config_val(u8 port_num); -extern int ingrasys_i2c_cpld_set_qsfp_port_config_val(u8 port_num, u8 reg_val); -extern int ingrasys_i2c_cpld_get_sfp_port_status_val(void); -extern int ingrasys_i2c_cpld_get_sfp_port_config_val(void); -extern int ingrasys_i2c_cpld_set_sfp_port_config_val(u8 reg_val); -extern u8 fp_port_to_phy_port(u8 fp_port); -#endif - diff --git a/packages/platforms/ingrasys/x86-64/s9280-64x/modules/builds/ingrasys_s9280_64x_platform.h b/packages/platforms/ingrasys/x86-64/s9280-64x/modules/builds/ingrasys_s9280_64x_platform.h deleted file mode 100644 index 08f14c0bd..000000000 --- a/packages/platforms/ingrasys/x86-64/s9280-64x/modules/builds/ingrasys_s9280_64x_platform.h +++ /dev/null @@ -1,158 +0,0 @@ -#ifndef _S9230_64X_PLATFORM_H -#define _S9230_64X_PLATFORM_H - -#include - -// remove debug before release -#define DEBUG - -enum bus_order { - I2C_BUS_MAIN, - MUX_9548_0_CH0, - MUX_9548_0_CH1, - MUX_9548_0_CH2, - MUX_9548_0_CH3, - MUX_9548_0_CH4, - MUX_9548_0_CH5, - MUX_9548_0_CH6, - MUX_9548_0_CH7, - MUX_9548_1_CH0, - MUX_9548_1_CH1, - MUX_9548_1_CH2, - MUX_9548_1_CH3, - MUX_9548_1_CH4, - MUX_9548_1_CH5, - MUX_9548_1_CH6, - MUX_9548_1_CH7, - MUX_9548_2_CH0, - MUX_9548_2_CH1, - MUX_9548_2_CH2, - MUX_9548_2_CH3, - MUX_9548_2_CH4, - MUX_9548_2_CH5, - MUX_9548_2_CH6, - MUX_9548_2_CH7, - MUX_9546_0_CH0, - MUX_9546_0_CH1, - MUX_9546_0_CH2, - MUX_9546_0_CH3, - MUX_9546_1_CH0, - MUX_9546_1_CH1, - MUX_9546_1_CH2, - MUX_9546_1_CH3, - MUX_9548_11_CH0, - MUX_9548_11_CH1, - MUX_9548_11_CH2, - MUX_9548_11_CH3, - MUX_9548_11_CH4, - MUX_9548_11_CH5, - MUX_9548_11_CH6, - MUX_9548_11_CH7, - MUX_9548_3_CH0, - MUX_9548_3_CH1, - MUX_9548_3_CH2, - MUX_9548_3_CH3, - MUX_9548_3_CH4, - MUX_9548_3_CH5, - MUX_9548_3_CH6, - MUX_9548_3_CH7, - MUX_9548_4_CH0, - MUX_9548_4_CH1, - MUX_9548_4_CH2, - MUX_9548_4_CH3, - MUX_9548_4_CH4, - MUX_9548_4_CH5, - MUX_9548_4_CH6, - MUX_9548_4_CH7, - MUX_9548_5_CH0, - MUX_9548_5_CH1, - MUX_9548_5_CH2, - MUX_9548_5_CH3, - MUX_9548_5_CH4, - MUX_9548_5_CH5, - MUX_9548_5_CH6, - MUX_9548_5_CH7, - MUX_9548_6_CH0, - MUX_9548_6_CH1, - MUX_9548_6_CH2, - MUX_9548_6_CH3, - MUX_9548_6_CH4, - MUX_9548_6_CH5, - MUX_9548_6_CH6, - MUX_9548_6_CH7, - MUX_9548_7_CH0, - MUX_9548_7_CH1, - MUX_9548_7_CH2, - MUX_9548_7_CH3, - MUX_9548_7_CH4, - MUX_9548_7_CH5, - MUX_9548_7_CH6, - MUX_9548_7_CH7, - MUX_9548_8_CH0, - MUX_9548_8_CH1, - MUX_9548_8_CH2, - MUX_9548_8_CH3, - MUX_9548_8_CH4, - MUX_9548_8_CH5, - MUX_9548_8_CH6, - MUX_9548_8_CH7, - MUX_9548_9_CH0, - MUX_9548_9_CH1, - MUX_9548_9_CH2, - MUX_9548_9_CH3, - MUX_9548_9_CH4, - MUX_9548_9_CH5, - MUX_9548_9_CH6, - MUX_9548_9_CH7, - MUX_9548_10_CH0, - MUX_9548_10_CH1, - MUX_9548_10_CH2, - MUX_9548_10_CH3, - MUX_9548_10_CH4, - MUX_9548_10_CH5, - MUX_9548_10_CH6, - MUX_9548_10_CH7, -}; - -#define I2C_ADDR_MUX_9555_0 (0x20) -#define I2C_ADDR_MUX_9555_1 (0x24) -#define I2C_ADDR_MUX_9555_2 (0x25) -#define I2C_ADDR_MUX_9555_3 (0x26) -#define I2C_ADDR_MUX_9539_0 (0x76) -#define I2C_ADDR_MUX_9539_1 (0x76) -#define I2C_BUS_FAN_STATUS (I2C_BUS_MAIN) -#define I2C_BUS_SYS_LED (MUX_9548_1_CH1) -#define I2C_BUS_PSU_STATUS (I2C_BUS_MAIN) -#define I2C_ADDR_PSU_STATUS (I2C_ADDR_MUX_9555_2) - -#define NUM_OF_I2C_MUX (11) -#define NUM_OF_CPLD (5) -#define NUM_OF_QSFP_PORT (64) -#define NUM_OF_SFP_PORT (2) -#define QSFP_EEPROM_I2C_ADDR (0x50) - -enum gpio_reg { - REG_PORT0_IN, - REG_PORT1_IN, - REG_PORT0_OUT, - REG_PORT1_OUT, - REG_PORT0_POL, - REG_PORT1_POL, - REG_PORT0_DIR, - REG_PORT1_DIR, -}; - -struct ing_i2c_board_info { - int ch; - int size; - struct i2c_board_info *board_info; -}; - -struct i2c_init_data { - __u16 ch; - __u16 addr; - __u8 reg; - __u8 value; -}; - -#endif diff --git a/packages/platforms/ingrasys/x86-64/s9280-64x/modules/builds/ingrasys_s9280_64x_psu.c b/packages/platforms/ingrasys/x86-64/s9280-64x/modules/builds/ingrasys_s9280_64x_psu.c deleted file mode 100644 index d92b6b9ac..000000000 --- a/packages/platforms/ingrasys/x86-64/s9280-64x/modules/builds/ingrasys_s9280_64x_psu.c +++ /dev/null @@ -1,552 +0,0 @@ -/* - * S9280-64x PSU driver - * - * Copyright (C) 2017 Ingrasys, 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., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#ifndef _S9230_64X_PLATFORM_H -#define _S9230_64X_PLATFORM_H - -#include - -// remove debug before release -#define DEBUG - -enum bus_order { - I2C_BUS_MAIN, - MUX_9548_0_CH0, - MUX_9548_0_CH1, - MUX_9548_0_CH2, - MUX_9548_0_CH3, - MUX_9548_0_CH4, - MUX_9548_0_CH5, - MUX_9548_0_CH6, - MUX_9548_0_CH7, - MUX_9548_1_CH0, - MUX_9548_1_CH1, - MUX_9548_1_CH2, - MUX_9548_1_CH3, - MUX_9548_1_CH4, - MUX_9548_1_CH5, - MUX_9548_1_CH6, - MUX_9548_1_CH7, - MUX_9548_2_CH0, - MUX_9548_2_CH1, - MUX_9548_2_CH2, - MUX_9548_2_CH3, - MUX_9548_2_CH4, - MUX_9548_2_CH5, - MUX_9548_2_CH6, - MUX_9548_2_CH7, - MUX_9546_0_CH0, - MUX_9546_0_CH1, - MUX_9546_0_CH2, - MUX_9546_0_CH3, - MUX_9546_1_CH0, - MUX_9546_1_CH1, - MUX_9546_1_CH2, - MUX_9546_1_CH3, - MUX_9548_11_CH0, - MUX_9548_11_CH1, - MUX_9548_11_CH2, - MUX_9548_11_CH3, - MUX_9548_11_CH4, - MUX_9548_11_CH5, - MUX_9548_11_CH6, - MUX_9548_11_CH7, - MUX_9548_3_CH0, - MUX_9548_3_CH1, - MUX_9548_3_CH2, - MUX_9548_3_CH3, - MUX_9548_3_CH4, - MUX_9548_3_CH5, - MUX_9548_3_CH6, - MUX_9548_3_CH7, - MUX_9548_4_CH0, - MUX_9548_4_CH1, - MUX_9548_4_CH2, - MUX_9548_4_CH3, - MUX_9548_4_CH4, - MUX_9548_4_CH5, - MUX_9548_4_CH6, - MUX_9548_4_CH7, - MUX_9548_5_CH0, - MUX_9548_5_CH1, - MUX_9548_5_CH2, - MUX_9548_5_CH3, - MUX_9548_5_CH4, - MUX_9548_5_CH5, - MUX_9548_5_CH6, - MUX_9548_5_CH7, - MUX_9548_6_CH0, - MUX_9548_6_CH1, - MUX_9548_6_CH2, - MUX_9548_6_CH3, - MUX_9548_6_CH4, - MUX_9548_6_CH5, - MUX_9548_6_CH6, - MUX_9548_6_CH7, - MUX_9548_7_CH0, - MUX_9548_7_CH1, - MUX_9548_7_CH2, - MUX_9548_7_CH3, - MUX_9548_7_CH4, - MUX_9548_7_CH5, - MUX_9548_7_CH6, - MUX_9548_7_CH7, - MUX_9548_8_CH0, - MUX_9548_8_CH1, - MUX_9548_8_CH2, - MUX_9548_8_CH3, - MUX_9548_8_CH4, - MUX_9548_8_CH5, - MUX_9548_8_CH6, - MUX_9548_8_CH7, - MUX_9548_9_CH0, - MUX_9548_9_CH1, - MUX_9548_9_CH2, - MUX_9548_9_CH3, - MUX_9548_9_CH4, - MUX_9548_9_CH5, - MUX_9548_9_CH6, - MUX_9548_9_CH7, - MUX_9548_10_CH0, - MUX_9548_10_CH1, - MUX_9548_10_CH2, - MUX_9548_10_CH3, - MUX_9548_10_CH4, - MUX_9548_10_CH5, - MUX_9548_10_CH6, - MUX_9548_10_CH7, -}; - -#define I2C_ADDR_MUX_9555_0 (0x20) -#define I2C_ADDR_MUX_9555_1 (0x24) -#define I2C_ADDR_MUX_9555_2 (0x25) -#define I2C_ADDR_MUX_9555_3 (0x26) -#define I2C_ADDR_MUX_9539_0 (0x76) -#define I2C_ADDR_MUX_9539_1 (0x76) -#define I2C_BUS_FAN_STATUS (I2C_BUS_MAIN) -#define I2C_BUS_SYS_LED (MUX_9548_1_CH1) -#define I2C_BUS_PSU_STATUS (I2C_BUS_MAIN) -#define I2C_ADDR_PSU_STATUS (I2C_ADDR_MUX_9555_2) - -#define NUM_OF_I2C_MUX (11) -#define NUM_OF_CPLD (5) -#define NUM_OF_QSFP_PORT (64) -#define NUM_OF_SFP_PORT (2) -#define QSFP_EEPROM_I2C_ADDR (0x50) - -enum gpio_reg { - REG_PORT0_IN, - REG_PORT1_IN, - REG_PORT0_OUT, - REG_PORT1_OUT, - REG_PORT0_POL, - REG_PORT1_POL, - REG_PORT0_DIR, - REG_PORT1_DIR, -}; - -struct ing_i2c_board_info { - int ch; - int size; - struct i2c_board_info *board_info; -}; - -struct i2c_init_data { - __u16 ch; - __u16 addr; - __u8 reg; - __u8 value; -}; - -#endif - -static ssize_t show_psu_eeprom(struct device *dev, - struct device_attribute *da, - char *buf); -static struct s9280_psu_data *s9280_psu_update_status(struct device *dev); -static struct s9280_psu_data *s9280_psu_update_eeprom(struct device *dev); -static int s9280_psu_read_block(struct i2c_client *client, - u8 command, - u8 *data, - int data_len); - - -#define DRIVER_NAME "psu" - -// Addresses scanned -static const unsigned short normal_i2c[] = { 0x50, I2C_CLIENT_END }; - -/* PSU EEPROM SIZE */ -#define EEPROM_SZ 256 -#define READ_EEPROM 1 -#define NREAD_EEPROM 0 - -static struct i2c_client pca9555_client; - -/* pca9555 gpio pin mapping */ -#define PSU2_PWROK 0 -#define PSU2_PRSNT_L 1 -#define PSU2_PWRON_L 2 -#define PSU1_PWROK 3 -#define PSU1_PRSNT_L 4 -#define PSU1_PWRON_L 5 -#define TMP_75_INT_L 6 - -/* Driver Private Data */ -struct s9280_psu_data { - struct mutex lock; - char valid; /* !=0 if registers are valid */ - unsigned long last_updated; /* In jiffies */ - u8 index; /* PSU index */ - s32 status; /* IO expander value */ - char eeprom[EEPROM_SZ]; /* psu eeprom data */ - char psuABS; /* PSU absent */ - char psuPG; /* PSU power good */ -}; - -enum psu_index -{ - s9280_psu1, - s9280_psu2 -}; - -/* - * display power good attribute - */ -static ssize_t -show_psu_pg(struct device *dev, - struct device_attribute *devattr, - char *buf) -{ - struct s9280_psu_data *data = s9280_psu_update_status(dev); - unsigned int value; - - mutex_lock(&data->lock); - value = data->psuPG; - mutex_unlock(&data->lock); - - return sprintf(buf, "%d\n", value); -} - -/* - * display power absent attribute - */ -static ssize_t -show_psu_abs(struct device *dev, - struct device_attribute *devattr, - char *buf) -{ - struct s9280_psu_data *data = s9280_psu_update_status(dev); - unsigned int value; - - mutex_lock(&data->lock); - value = data->psuABS; - mutex_unlock(&data->lock); - - return sprintf(buf, "%d\n", value); -} - - -/* - * sysfs attributes for psu - */ -static DEVICE_ATTR(psu_pg, S_IRUGO, show_psu_pg, NULL); -static DEVICE_ATTR(psu_abs, S_IRUGO, show_psu_abs, NULL); -static DEVICE_ATTR(psu_eeprom, S_IRUGO, show_psu_eeprom, NULL); - -static struct attribute *s9280_psu_attributes[] = { - &dev_attr_psu_pg.attr, - &dev_attr_psu_abs.attr, - &dev_attr_psu_eeprom.attr, - NULL -}; - -/* - * display psu eeprom content - */ -static ssize_t -show_psu_eeprom(struct device *dev, - struct device_attribute *da, - char *buf) -{ - struct s9280_psu_data *data = s9280_psu_update_eeprom(dev); - - memcpy(buf, (char *)data->eeprom, EEPROM_SZ); - return EEPROM_SZ; -} - -static const struct attribute_group s9280_psu_group = { - .attrs = s9280_psu_attributes, -}; - -/* - * check gpio expander is accessible - */ -static int -pca9555_detect(struct i2c_client *client) -{ - if (i2c_smbus_read_byte_data(client, REG_PORT0_DIR) < 0) { - return -ENODEV; - } - - return 0; -} - -/* - * client init - */ -static void -i2c_devices_client_address_init(struct i2c_client *client) -{ - pca9555_client = *client; - - /* get i2c adapter for the target */ - pca9555_client.adapter = i2c_get_adapter(I2C_BUS_PSU_STATUS); - - /* get the i2c addr for the target */ - pca9555_client.addr = I2C_ADDR_PSU_STATUS; -} - -static int -s9280_psu_probe(struct i2c_client *client, - const struct i2c_device_id *dev_id) -{ - struct s9280_psu_data *data; - int status, err; - - if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_I2C_BLOCK)) { - status = -EIO; - goto exit; - } - - data = kzalloc(sizeof(struct s9280_psu_data), GFP_KERNEL); - if (!data) { - status = -ENOMEM; - goto exit; - } - memset(data, 0, sizeof(struct s9280_psu_data)); - i2c_set_clientdata(client, data); - data->valid = 0; - data->index = dev_id->driver_data; - mutex_init(&data->lock); - - i2c_devices_client_address_init(client); - - err = pca9555_detect(&pca9555_client); - if (err) { - return err; - } - - dev_info(&client->dev, "chip found\n"); - - /* Register sysfs hooks */ - status = sysfs_create_group(&client->dev.kobj, &s9280_psu_group); - if (status) { - goto exit_free; - } - - return 0; - -exit_free: - kfree(data); -exit: - - return status; -} - -static int -s9280_psu_remove(struct i2c_client *client) -{ - struct s9280_psu_data *data = i2c_get_clientdata(client); - - sysfs_remove_group(&client->dev.kobj, &s9280_psu_group); - kfree(data); - - /* free i2c adapter */ - i2c_put_adapter(pca9555_client.adapter); - - return 0; -} - - -/* - * psu eeprom read utility - */ -static int -s9280_psu_read_block(struct i2c_client *client, - u8 command, - u8 *data, - int data_len) -{ - int i=0, ret=0; - int blk_max = 32; //max block read size - - /* read eeprom, 32 * 8 = 256 bytes */ - for (i=0; i < EEPROM_SZ/blk_max; i++) { - ret = i2c_smbus_read_i2c_block_data(client, (i*blk_max), blk_max, - data + (i*blk_max)); - if (ret < 0) { - return ret; - } - } - return ret; -} - -/* - * update eeprom content - */ -static struct s9280_psu_data -*s9280_psu_update_eeprom(struct device *dev) -{ - struct i2c_client *client = to_i2c_client(dev); - struct s9280_psu_data *data = i2c_get_clientdata(client); - s32 status = 0; - int psu_pwrok = 0; - int psu_prsnt_l = 0; - - mutex_lock(&data->lock); - - if (time_after(jiffies, data->last_updated + 300 * HZ) - || !data->valid) { - - /* Read psu status */ - - status = i2c_smbus_read_word_data(&(pca9555_client), REG_PORT0_IN); - data->status = status; - - /*read psu status from io expander*/ - - if (data->index == s9280_psu1) { - psu_pwrok = PSU1_PWROK; - psu_prsnt_l = PSU1_PRSNT_L; - } else { - psu_pwrok = PSU2_PWROK; - psu_prsnt_l = PSU2_PRSNT_L; - } - data->psuPG = (status >> psu_pwrok) & 0x1; - data->psuABS = (status >> psu_prsnt_l) & 0x1; - - /* Read eeprom */ - if (!data->psuABS) { - //clear local eeprom data - memset(data->eeprom, 0, EEPROM_SZ); - - //read eeprom - status = s9280_psu_read_block(client, 0, data->eeprom, - ARRAY_SIZE(data->eeprom)); - - if (status < 0) { - memset(data->eeprom, 0, EEPROM_SZ); - dev_err(&client->dev, "Read eeprom failed, status=(%d)\n", status); - } else { - data->valid = 1; - } - } else { - memset(data->eeprom, 0, EEPROM_SZ); - } - data->last_updated = jiffies; - } - - mutex_unlock(&data->lock); - - return data; -} - -/* - * update psu status - */ -static struct s9280_psu_data -*s9280_psu_update_status(struct device *dev) -{ - struct i2c_client *client = to_i2c_client(dev); - struct s9280_psu_data *data = i2c_get_clientdata(client); - s32 status = 0; - int psu_pwrok = 0; - int psu_prsnt_l = 0; - - mutex_lock(&data->lock); - - /* Read psu status */ - - status = i2c_smbus_read_word_data(&(pca9555_client), REG_PORT0_IN); - data->status = status; - - /*read psu status from io expander*/ - - if (data->index == s9280_psu1) { - psu_pwrok = PSU1_PWROK; - psu_prsnt_l = PSU1_PRSNT_L; - } else { - psu_pwrok = PSU2_PWROK; - psu_prsnt_l = PSU2_PRSNT_L; - } - data->psuPG = (status >> psu_pwrok) & 0x1; - data->psuABS = (status >> psu_prsnt_l) & 0x1; - - mutex_unlock(&data->lock); - - return data; -} - -static const struct i2c_device_id s9280_psu_id[] = { - { "psu1", s9280_psu1 }, - { "psu2", s9280_psu2 }, - {} -}; - -MODULE_DEVICE_TABLE(i2c, s9280_psu_id); - -static struct i2c_driver s9280_psu_driver = { - .driver = { - .name = DRIVER_NAME, - }, - .probe = s9280_psu_probe, - .remove = s9280_psu_remove, - .id_table = s9280_psu_id, - .address_list = normal_i2c, -}; - -static int __init s9280_psu_init(void) -{ - return i2c_add_driver(&s9280_psu_driver); -} - -static void __exit s9280_psu_exit(void) -{ - i2c_del_driver(&s9280_psu_driver); -} - -module_init(s9280_psu_init); -module_exit(s9280_psu_exit); - -MODULE_AUTHOR("Leo Lin "); -MODULE_DESCRIPTION("S9280-64X psu driver"); -MODULE_LICENSE("GPL"); diff --git a/packages/platforms/ingrasys/x86-64/s9280-64x/onlp/Makefile b/packages/platforms/ingrasys/x86-64/s9280-64x/onlp/Makefile deleted file mode 100755 index 003238cf6..000000000 --- a/packages/platforms/ingrasys/x86-64/s9280-64x/onlp/Makefile +++ /dev/null @@ -1 +0,0 @@ -include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/ingrasys/x86-64/s9280-64x/onlp/PKG.yml b/packages/platforms/ingrasys/x86-64/s9280-64x/onlp/PKG.yml deleted file mode 100755 index c488b9fac..000000000 --- a/packages/platforms/ingrasys/x86-64/s9280-64x/onlp/PKG.yml +++ /dev/null @@ -1 +0,0 @@ -!include $ONL_TEMPLATES/onlp-platform-any.yml PLATFORM=x86-64-ingrasys-s9280-64x ARCH=amd64 TOOLCHAIN=x86_64-linux-gnu diff --git a/packages/platforms/ingrasys/x86-64/s9280-64x/onlp/builds/Makefile b/packages/platforms/ingrasys/x86-64/s9280-64x/onlp/builds/Makefile deleted file mode 100755 index e7437cb23..000000000 --- a/packages/platforms/ingrasys/x86-64/s9280-64x/onlp/builds/Makefile +++ /dev/null @@ -1,2 +0,0 @@ -FILTER=src -include $(ONL)/make/subdirs.mk diff --git a/packages/platforms/ingrasys/x86-64/s9280-64x/onlp/builds/lib/Makefile b/packages/platforms/ingrasys/x86-64/s9280-64x/onlp/builds/lib/Makefile deleted file mode 100755 index 67a501632..000000000 --- a/packages/platforms/ingrasys/x86-64/s9280-64x/onlp/builds/lib/Makefile +++ /dev/null @@ -1,2 +0,0 @@ -PLATFORM := x86-64-ingrasys-s9280-64x -include $(ONL)/packages/base/any/onlp/builds/platform/libonlp-platform.mk diff --git a/packages/platforms/ingrasys/x86-64/s9280-64x/onlp/builds/onlpdump/Makefile b/packages/platforms/ingrasys/x86-64/s9280-64x/onlp/builds/onlpdump/Makefile deleted file mode 100755 index 633a6d87c..000000000 --- a/packages/platforms/ingrasys/x86-64/s9280-64x/onlp/builds/onlpdump/Makefile +++ /dev/null @@ -1,2 +0,0 @@ -PLATFORM := x86-64-ingrasys-s9280-64x -include $(ONL)/packages/base/any/onlp/builds/platform/onlps.mk diff --git a/packages/platforms/ingrasys/x86-64/s9280-64x/onlp/builds/x86_64_ingrasys_s9280_64x/.gitignore b/packages/platforms/ingrasys/x86-64/s9280-64x/onlp/builds/x86_64_ingrasys_s9280_64x/.gitignore deleted file mode 100755 index 3c4101271..000000000 --- a/packages/platforms/ingrasys/x86-64/s9280-64x/onlp/builds/x86_64_ingrasys_s9280_64x/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -/x86_64_ingrasys_s9280_64x.mk -/doc diff --git a/packages/platforms/ingrasys/x86-64/s9280-64x/onlp/builds/x86_64_ingrasys_s9280_64x/.module b/packages/platforms/ingrasys/x86-64/s9280-64x/onlp/builds/x86_64_ingrasys_s9280_64x/.module deleted file mode 100755 index 7599a81f7..000000000 --- a/packages/platforms/ingrasys/x86-64/s9280-64x/onlp/builds/x86_64_ingrasys_s9280_64x/.module +++ /dev/null @@ -1 +0,0 @@ -name: x86_64_ingrasys_s9280_64x diff --git a/packages/platforms/ingrasys/x86-64/s9280-64x/onlp/builds/x86_64_ingrasys_s9280_64x/Makefile b/packages/platforms/ingrasys/x86-64/s9280-64x/onlp/builds/x86_64_ingrasys_s9280_64x/Makefile deleted file mode 100755 index a514eac95..000000000 --- a/packages/platforms/ingrasys/x86-64/s9280-64x/onlp/builds/x86_64_ingrasys_s9280_64x/Makefile +++ /dev/null @@ -1,10 +0,0 @@ -############################################################ -# -# -# -############################################################ -include $(ONL)/make/config.mk - -MODULE := x86_64_ingrasys_s9280_64x -AUTOMODULE := x86_64_ingrasys_s9280_64x -include $(BUILDER)/definemodule.mk diff --git a/packages/platforms/ingrasys/x86-64/s9280-64x/onlp/builds/x86_64_ingrasys_s9280_64x/module/auto/make.mk b/packages/platforms/ingrasys/x86-64/s9280-64x/onlp/builds/x86_64_ingrasys_s9280_64x/module/auto/make.mk deleted file mode 100755 index 29f32c5d2..000000000 --- a/packages/platforms/ingrasys/x86-64/s9280-64x/onlp/builds/x86_64_ingrasys_s9280_64x/module/auto/make.mk +++ /dev/null @@ -1,7 +0,0 @@ -# -# x86_64_ingrasys_s9280_64x Autogeneration -# -############################################################################### -x86_64_ingrasys_s9280_64x_AUTO_DEFS := module/auto/x86_64_ingrasys_s9280_64x.yml -x86_64_ingrasys_s9280_64x_AUTO_DIRS := module/inc/x86_64_ingrasys_s9280_64x module/src -include $(BUILDER)/auto.mk diff --git a/packages/platforms/ingrasys/x86-64/s9280-64x/onlp/builds/x86_64_ingrasys_s9280_64x/module/auto/x86_64_ingrasys_s9280_64x.yml b/packages/platforms/ingrasys/x86-64/s9280-64x/onlp/builds/x86_64_ingrasys_s9280_64x/module/auto/x86_64_ingrasys_s9280_64x.yml deleted file mode 100755 index d48ff257e..000000000 --- a/packages/platforms/ingrasys/x86-64/s9280-64x/onlp/builds/x86_64_ingrasys_s9280_64x/module/auto/x86_64_ingrasys_s9280_64x.yml +++ /dev/null @@ -1,47 +0,0 @@ -############################################################################### -# -# X86_64_INGRASYS_S9280_64X Autogeneration Definitions. -# -############################################################################### - -cdefs: &cdefs -- X86_64_INGRASYS_S9280_64X_CONFIG_INCLUDE_LOGGING: - doc: "Include or exclude logging." - default: 1 -- X86_64_INGRASYS_S9280_64X_CONFIG_LOG_OPTIONS_DEFAULT: - doc: "Default enabled log options." - default: AIM_LOG_OPTIONS_DEFAULT -- X86_64_INGRASYS_S9280_64X_CONFIG_LOG_BITS_DEFAULT: - doc: "Default enabled log bits." - default: AIM_LOG_BITS_DEFAULT -- X86_64_INGRASYS_S9280_64X_CONFIG_LOG_CUSTOM_BITS_DEFAULT: - doc: "Default enabled custom log bits." - default: 0 -- X86_64_INGRASYS_S9280_64X_CONFIG_PORTING_STDLIB: - doc: "Default all porting macros to use the C standard libraries." - default: 1 -- X86_64_INGRASYS_S9280_64X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS: - doc: "Include standard library headers for stdlib porting macros." - default: X86_64_INGRASYS_S9280_64X_CONFIG_PORTING_STDLIB -- X86_64_INGRASYS_S9280_64X_CONFIG_INCLUDE_UCLI: - doc: "Include generic uCli support." - default: 0 - - -definitions: - cdefs: - X86_64_INGRASYS_S9280_64X_CONFIG_HEADER: - defs: *cdefs - basename: x86_64_ingrasys_s9280_64x_config - - portingmacro: - X86_64_INGRASYS_S9280_64X: - macros: - - malloc - - free - - memset - - memcpy - - - vsnprintf - - snprintf - - strlen diff --git a/packages/platforms/ingrasys/x86-64/s9280-64x/onlp/builds/x86_64_ingrasys_s9280_64x/module/inc/x86_64_ingrasys_s9280_64x/x86_64_ingrasys_s9280_64x.x b/packages/platforms/ingrasys/x86-64/s9280-64x/onlp/builds/x86_64_ingrasys_s9280_64x/module/inc/x86_64_ingrasys_s9280_64x/x86_64_ingrasys_s9280_64x.x deleted file mode 100755 index 8f9330a4a..000000000 --- a/packages/platforms/ingrasys/x86-64/s9280-64x/onlp/builds/x86_64_ingrasys_s9280_64x/module/inc/x86_64_ingrasys_s9280_64x/x86_64_ingrasys_s9280_64x.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/ingrasys/x86-64/s9280-64x/onlp/builds/x86_64_ingrasys_s9280_64x/module/inc/x86_64_ingrasys_s9280_64x/x86_64_ingrasys_s9280_64x_config.h b/packages/platforms/ingrasys/x86-64/s9280-64x/onlp/builds/x86_64_ingrasys_s9280_64x/module/inc/x86_64_ingrasys_s9280_64x/x86_64_ingrasys_s9280_64x_config.h deleted file mode 100755 index c25b48db5..000000000 --- a/packages/platforms/ingrasys/x86-64/s9280-64x/onlp/builds/x86_64_ingrasys_s9280_64x/module/inc/x86_64_ingrasys_s9280_64x/x86_64_ingrasys_s9280_64x_config.h +++ /dev/null @@ -1,152 +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 x86_64_ingrasys_s9280_64x Configuration Header - * - * @addtogroup x86_64_ingrasys_s9280_64x-config - * @{ - * - *****************************************************************************/ -#ifndef __X86_64_INGRASYS_S9280_64X_CONFIG_H__ -#define __X86_64_INGRASYS_S9280_64X_CONFIG_H__ - -#ifdef GLOBAL_INCLUDE_CUSTOM_CONFIG -#include -#endif -#ifdef X86_64_INGRASYS_S9280_64X_INCLUDE_CUSTOM_CONFIG -#include -#endif - -/* */ -#include -/** - * X86_64_INGRASYS_S9280_64X_CONFIG_INCLUDE_LOGGING - * - * Include or exclude logging. */ - - -#ifndef X86_64_INGRASYS_S9280_64X_CONFIG_INCLUDE_LOGGING -#define X86_64_INGRASYS_S9280_64X_CONFIG_INCLUDE_LOGGING 1 -#endif - -/** - * X86_64_INGRASYS_S9280_64X_CONFIG_LOG_OPTIONS_DEFAULT - * - * Default enabled log options. */ - - -#ifndef X86_64_INGRASYS_S9280_64X_CONFIG_LOG_OPTIONS_DEFAULT -#define X86_64_INGRASYS_S9280_64X_CONFIG_LOG_OPTIONS_DEFAULT AIM_LOG_OPTIONS_DEFAULT -#endif - -/** - * X86_64_INGRASYS_S9280_64X_CONFIG_LOG_BITS_DEFAULT - * - * Default enabled log bits. */ - - -#ifndef X86_64_INGRASYS_S9280_64X_CONFIG_LOG_BITS_DEFAULT -#define X86_64_INGRASYS_S9280_64X_CONFIG_LOG_BITS_DEFAULT AIM_LOG_BITS_DEFAULT -#endif - -/** - * X86_64_INGRASYS_S9280_64X_CONFIG_LOG_CUSTOM_BITS_DEFAULT - * - * Default enabled custom log bits. */ - - -#ifndef X86_64_INGRASYS_S9280_64X_CONFIG_LOG_CUSTOM_BITS_DEFAULT -#define X86_64_INGRASYS_S9280_64X_CONFIG_LOG_CUSTOM_BITS_DEFAULT 0 -#endif - -/** - * X86_64_INGRASYS_S9280_64X_CONFIG_PORTING_STDLIB - * - * Default all porting macros to use the C standard libraries. */ - - -#ifndef X86_64_INGRASYS_S9280_64X_CONFIG_PORTING_STDLIB -#define X86_64_INGRASYS_S9280_64X_CONFIG_PORTING_STDLIB 1 -#endif - -/** - * X86_64_INGRASYS_S9280_64X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS - * - * Include standard library headers for stdlib porting macros. */ - - -#ifndef X86_64_INGRASYS_S9280_64X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS -#define X86_64_INGRASYS_S9280_64X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS X86_64_INGRASYS_S9280_64X_CONFIG_PORTING_STDLIB -#endif - -/** - * X86_64_INGRASYS_S9280_64X_CONFIG_INCLUDE_UCLI - * - * Include generic uCli support. */ - - -#ifndef X86_64_INGRASYS_S9280_64X_CONFIG_INCLUDE_UCLI -#define X86_64_INGRASYS_S9280_64X_CONFIG_INCLUDE_UCLI 0 -#endif - - - -/** - * All compile time options can be queried or displayed - */ - -/** Configuration settings structure. */ -typedef struct x86_64_ingrasys_s9280_64x_config_settings_s { - /** name */ - const char* name; - /** value */ - const char* value; -} x86_64_ingrasys_s9280_64x_config_settings_t; - -/** Configuration settings table. */ -/** x86_64_ingrasys_s9280_64x_config_settings table. */ -extern x86_64_ingrasys_s9280_64x_config_settings_t x86_64_ingrasys_s9280_64x_config_settings[]; - -/** - * @brief Lookup a configuration setting. - * @param setting The name of the configuration option to lookup. - */ -const char* x86_64_ingrasys_s9280_64x_config_lookup(const char* setting); - -/** - * @brief Show the compile-time configuration. - * @param pvs The output stream. - */ -int x86_64_ingrasys_s9280_64x_config_show(struct aim_pvs_s* pvs); - -/* */ - -#include "x86_64_ingrasys_s9280_64x_porting.h" - -#endif /* __X86_64_INGRASYS_S9280_64X_CONFIG_H__ */ -/* @} */ diff --git a/packages/platforms/ingrasys/x86-64/s9280-64x/onlp/builds/x86_64_ingrasys_s9280_64x/module/inc/x86_64_ingrasys_s9280_64x/x86_64_ingrasys_s9280_64x_dox.h b/packages/platforms/ingrasys/x86-64/s9280-64x/onlp/builds/x86_64_ingrasys_s9280_64x/module/inc/x86_64_ingrasys_s9280_64x/x86_64_ingrasys_s9280_64x_dox.h deleted file mode 100755 index 0d3f6cf2a..000000000 --- a/packages/platforms/ingrasys/x86-64/s9280-64x/onlp/builds/x86_64_ingrasys_s9280_64x/module/inc/x86_64_ingrasys_s9280_64x/x86_64_ingrasys_s9280_64x_dox.h +++ /dev/null @@ -1,26 +0,0 @@ -/**************************************************************************//** - * - * x86_64_ingrasys_s9280_64x Doxygen Header - * - *****************************************************************************/ -#ifndef __x86_64_ingrasys_s9280_64x_DOX_H__ -#define __x86_64_ingrasys_s9280_64x_DOX_H__ - -/** - * @defgroup x86_64_ingrasys_s9280_64x x86_64_ingrasys_s9280_64x - x86_64_ingrasys_s9280_64x Description - * - -The documentation overview for this module should go here. - - * - * @{ - * - * @defgroup x86_64_ingrasys_s9280_64x-x86_64_ingrasys_s9280_64x Public Interface - * @defgroup x86_64_ingrasys_s9280_64x-config Compile Time Configuration - * @defgroup x86_64_ingrasys_s9280_64x-porting Porting Macros - * - * @} - * - */ - -#endif /* __x86_64_ingrasys_s9280_64x_DOX_H__ */ diff --git a/packages/platforms/ingrasys/x86-64/s9280-64x/onlp/builds/x86_64_ingrasys_s9280_64x/module/inc/x86_64_ingrasys_s9280_64x/x86_64_ingrasys_s9280_64x_porting.h b/packages/platforms/ingrasys/x86-64/s9280-64x/onlp/builds/x86_64_ingrasys_s9280_64x/module/inc/x86_64_ingrasys_s9280_64x/x86_64_ingrasys_s9280_64x_porting.h deleted file mode 100755 index c33ef333b..000000000 --- a/packages/platforms/ingrasys/x86-64/s9280-64x/onlp/builds/x86_64_ingrasys_s9280_64x/module/inc/x86_64_ingrasys_s9280_64x/x86_64_ingrasys_s9280_64x_porting.h +++ /dev/null @@ -1,96 +0,0 @@ -/********************************************************//** - * - * @file - * @brief x86_64_Ingrasys_s9280_64x Porting Macros. - * - * @addtogroup x86_64_Ingrasys_s9280_64x-porting - * @{ - * - ***********************************************************/ -#ifndef __X86_64_INGRASYS_S9280_64X_PORTING_H__ -#define __X86_64_INGRASYS_S9280_64X_PORTING_H__ - -/* */ -#if X86_64_INGRASYS_S9280_64X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS == 1 -#include -#include -#include -#include -#include -#endif - -#ifndef X86_64_INGRASYS_S9280_64X_MALLOC - #if defined(GLOBAL_MALLOC) - #define X86_64_INGRASYS_S9280_64X_MALLOC GLOBAL_MALLOC - #elif X86_64_INGRASYS_S9280_64X_CONFIG_PORTING_STDLIB == 1 - #define X86_64_INGRASYS_S9280_64X_MALLOC malloc - #else - #error The macro X86_64_INGRASYS_S9280_64X_MALLOC is required but cannot be defined. - #endif -#endif - -#ifndef X86_64_INGRASYS_S9280_64X_FREE - #if defined(GLOBAL_FREE) - #define X86_64_INGRASYS_S9280_64X_FREE GLOBAL_FREE - #elif X86_64_INGRASYS_S9280_64X_CONFIG_PORTING_STDLIB == 1 - #define X86_64_INGRASYS_S9280_64X_FREE free - #else - #error The macro X86_64_INGRASYS_S9280_64X_FREE is required but cannot be defined. - #endif -#endif - -#ifndef X86_64_INGRASYS_S9280_64X_MEMSET - #if defined(GLOBAL_MEMSET) - #define X86_64_INGRASYS_S9280_64X_MEMSET GLOBAL_MEMSET - #elif X86_64_INGRASYS_S9280_64X_CONFIG_PORTING_STDLIB == 1 - #define X86_64_INGRASYS_S9280_64X_MEMSET memset - #else - #error The macro X86_64_INGRASYS_S9280_64X_MEMSET is required but cannot be defined. - #endif -#endif - -#ifndef X86_64_INGRASYS_S9280_64X_MEMCPY - #if defined(GLOBAL_MEMCPY) - #define X86_64_INGRASYS_S9280_64X_MEMCPY GLOBAL_MEMCPY - #elif X86_64_INGRASYS_S9280_64X_CONFIG_PORTING_STDLIB == 1 - #define X86_64_INGRASYS_S9280_64X_MEMCPY memcpy - #else - #error The macro X86_64_INGRASYS_S9280_64X_MEMCPY is required but cannot be defined. - #endif -#endif - -#ifndef X86_64_INGRASYS_S9280_64X_VSNPRINTF - #if defined(GLOBAL_VSNPRINTF) - #define X86_64_INGRASYS_S9280_64X_VSNPRINTF GLOBAL_VSNPRINTF - #elif X86_64_INGRASYS_S9280_64X_CONFIG_PORTING_STDLIB == 1 - #define X86_64_INGRASYS_S9280_64X_VSNPRINTF vsnprintf - #else - #error The macro X86_64_INGRASYS_S9280_64X_VSNPRINTF is required but cannot be defined. - #endif -#endif - -#ifndef X86_64_INGRASYS_S9280_64X_SNPRINTF - #if defined(GLOBAL_SNPRINTF) - #define X86_64_INGRASYS_S9280_64X_SNPRINTF GLOBAL_SNPRINTF - #elif X86_64_INGRASYS_S9280_64X_CONFIG_PORTING_STDLIB == 1 - #define X86_64_INGRASYS_S9280_64X_SNPRINTF snprintf - #else - #error The macro X86_64_INGRASYS_S9280_64X_SNPRINTF is required but cannot be defined. - #endif -#endif - -#ifndef X86_64_INGRASYS_S9280_64X_STRLEN - #if defined(GLOBAL_STRLEN) - #define X86_64_INGRASYS_S9280_64X_STRLEN GLOBAL_STRLEN - #elif X86_64_INGRASYS_S9280_64X_CONFIG_PORTING_STDLIB == 1 - #define X86_64_INGRASYS_S9280_64X_STRLEN strlen - #else - #error The macro X86_64_INGRASYS_S9280_64X_STRLEN is required but cannot be defined. - #endif -#endif - -/* */ - - -#endif /* __X86_64_INGRASYS_S9280_64X_PORTING_H__ */ -/* @} */ diff --git a/packages/platforms/ingrasys/x86-64/s9280-64x/onlp/builds/x86_64_ingrasys_s9280_64x/module/make.mk b/packages/platforms/ingrasys/x86-64/s9280-64x/onlp/builds/x86_64_ingrasys_s9280_64x/module/make.mk deleted file mode 100755 index ee80af112..000000000 --- a/packages/platforms/ingrasys/x86-64/s9280-64x/onlp/builds/x86_64_ingrasys_s9280_64x/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))) -x86_64_ingrasys_s9280_64x_INCLUDES := -I $(THIS_DIR)inc -x86_64_ingrasys_s9280_64x_INTERNAL_INCLUDES := -I $(THIS_DIR)src -x86_64_ingrasys_s9280_64x_DEPENDMODULE_ENTRIES := init:x86_64_ingrasys_s9280_64x ucli:x86_64_ingrasys_s9280_64x - diff --git a/packages/platforms/ingrasys/x86-64/s9280-64x/onlp/builds/x86_64_ingrasys_s9280_64x/module/src/Makefile b/packages/platforms/ingrasys/x86-64/s9280-64x/onlp/builds/x86_64_ingrasys_s9280_64x/module/src/Makefile deleted file mode 100755 index 20eafcded..000000000 --- a/packages/platforms/ingrasys/x86-64/s9280-64x/onlp/builds/x86_64_ingrasys_s9280_64x/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 x86_64_ingrasys_s9280_64x_ucli.c - diff --git a/packages/platforms/ingrasys/x86-64/s9280-64x/onlp/builds/x86_64_ingrasys_s9280_64x/module/src/fani.c b/packages/platforms/ingrasys/x86-64/s9280-64x/onlp/builds/x86_64_ingrasys_s9280_64x/module/src/fani.c deleted file mode 100755 index 65344acc9..000000000 --- a/packages/platforms/ingrasys/x86-64/s9280-64x/onlp/builds/x86_64_ingrasys_s9280_64x/module/src/fani.c +++ /dev/null @@ -1,272 +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. - * - * - ************************************************************ - * - * Fan Platform Implementation Defaults. - * - ***********************************************************/ -#include -#include "x86_64_ingrasys_s9280_64x_int.h" -#include -#include -#include "platform_lib.h" - -onlp_fan_info_t fan_info[] = { - { }, /* Not used */ - { - { FAN_OID_FAN1, "FANTRAY 1", 0 }, - ONLP_FAN_STATUS_PRESENT, - ONLP_FAN_CAPS_GET_RPM | ONLP_FAN_CAPS_GET_PERCENTAGE, - 0, - 0, - ONLP_FAN_MODE_INVALID, - }, - { - { FAN_OID_FAN2, "FANTRAY 2", 0 }, - ONLP_FAN_STATUS_PRESENT, - ONLP_FAN_CAPS_GET_RPM | ONLP_FAN_CAPS_GET_PERCENTAGE, - 0, - 0, - ONLP_FAN_MODE_INVALID, - }, - { - { FAN_OID_FAN3, "FANTRAY 3", 0 }, - ONLP_FAN_STATUS_PRESENT, - ONLP_FAN_CAPS_GET_RPM | ONLP_FAN_CAPS_GET_PERCENTAGE, - 0, - 0, - ONLP_FAN_MODE_INVALID, - }, - { - { FAN_OID_FAN4, "FANTRAY 4", 0 }, - ONLP_FAN_STATUS_PRESENT, - ONLP_FAN_CAPS_GET_RPM | ONLP_FAN_CAPS_GET_PERCENTAGE, - 0, - 0, - ONLP_FAN_MODE_INVALID, - }, - { - { FAN_OID_PSU_FAN1, "PSU-1 FAN", 0 }, - ONLP_FAN_STATUS_PRESENT, - }, - { - { FAN_OID_PSU_FAN2, "PSU-2 FAN", 0 }, - ONLP_FAN_STATUS_PRESENT, - } -}; - -/* - * This function will be called prior to all of onlp_fani_* functions. - */ -int -onlp_fani_init(void) -{ - return ONLP_STATUS_OK; -} - -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_FANTRAY_LED; - switch (id) - { - case FAN_ID_FAN1: - offset = 0; - fan_reg_mask = FAN_1_PRESENT_MASK; - break; - case FAN_ID_FAN2: - offset = 0; - fan_reg_mask = FAN_2_PRESENT_MASK; - break; - case FAN_ID_FAN3: - offset = 1; - fan_reg_mask = FAN_3_PRESENT_MASK; - break; - case FAN_ID_FAN4: - offset = 1; - fan_reg_mask = FAN_4_PRESENT_MASK; - break; - default: - return ONLP_STATUS_E_INVALID; - } - - rv = onlp_i2c_readb(i2c_bus, FAN_GPIO_ADDR, 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 = 10000; - 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", 2 * id - 1); - if (rv < 0) { - return ONLP_STATUS_E_INTERNAL; - } - - /* fan status > 1, means failure */ - if (fan_status > 0) { - info->status |= ONLP_FAN_STATUS_FAILED; - return ONLP_STATUS_OK; - } - - rv = onlp_file_read_int(&fan_rpm, SYS_FAN_PREFIX "fan%d_input", 2 * id - 1); - if (rv < 0) { - return ONLP_STATUS_E_INTERNAL; - } - info->rpm = fan_rpm; - - /* get speed percentage*/ - switch (id) - { - case FAN_ID_FAN1: - case FAN_ID_FAN2: - case FAN_ID_FAN3: - case FAN_ID_FAN4: - rv = onlp_file_read_int(&perc_val, SYS_FAN_PREFIX "pwm%d", - FAN_CTRL_SET2); - break; - default: - return ONLP_STATUS_E_INVALID; - } - if (rv < 0) { - return ONLP_STATUS_E_INTERNAL; - } - - percentage = (info->rpm*100)/max_fan_speed; - info->percentage = percentage; - - return ONLP_STATUS_OK; -} - -int -sys_fan_rpm_percent_set(int perc) -{ - int rc; - - rc = onlp_file_write_int(perc, SYS_FAN_PREFIX "pwm%d", FAN_CTRL_SET2); - if (rc < 0) { - return ONLP_STATUS_E_INTERNAL; - } - - return ONLP_STATUS_OK; -} - -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 percentage) -{ - int fid, perc_val, rc; - fid = ONLP_OID_ID_GET(id); - - /* - * Set fan speed - * Driver accept value in range between 128 and 255. - * Value 128 is 50%. - * Value 200 is 80%. - * Value 255 is 100%. - */ - if (percentage == 100) { - perc_val = 255; - } else if (percentage == 80) { - perc_val = 200; - } else if (percentage == 50) { - perc_val = 128; - } else { - return ONLP_STATUS_E_INVALID; - } - - switch (fid) - { - case FAN_ID_FAN1: - case FAN_ID_FAN2: - case FAN_ID_FAN3: - case FAN_ID_FAN4: - rc = sys_fan_rpm_percent_set(perc_val); - break; - default: - return ONLP_STATUS_E_INVALID; - } - return rc; -} - -int -onlp_fani_info_get(onlp_oid_t id, onlp_fan_info_t* rv) -{ - int fan_id ,rc; - - fan_id = ONLP_OID_ID_GET(id); - *rv = fan_info[fan_id]; - rv->caps |= ONLP_FAN_CAPS_GET_RPM; - - switch (fan_id) { - case FAN_ID_FAN1: - case FAN_ID_FAN2: - case FAN_ID_FAN3: - case FAN_ID_FAN4: - rc = sys_fan_info_get(rv, fan_id); - break; - case FAN_ID_PSU_FAN1: - case FAN_ID_PSU_FAN2: - rc = psu_fan_info_get(rv, fan_id); - break; - default: - return ONLP_STATUS_E_INTERNAL; - break; - } - - return rc; -} diff --git a/packages/platforms/ingrasys/x86-64/s9280-64x/onlp/builds/x86_64_ingrasys_s9280_64x/module/src/ledi.c b/packages/platforms/ingrasys/x86-64/s9280-64x/onlp/builds/x86_64_ingrasys_s9280_64x/module/src/ledi.c deleted file mode 100755 index 36f7612ab..000000000 --- a/packages/platforms/ingrasys/x86-64/s9280-64x/onlp/builds/x86_64_ingrasys_s9280_64x/module/src/ledi.c +++ /dev/null @@ -1,223 +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 -#include -#include -#include -#include - -#include "platform_lib.h" - -/* - * Get the information for the given LED OID. - */ -static onlp_led_info_t led_info[] = -{ - { }, /* Not used */ - { - { LED_OID_SYSTEM, "Chassis LED 1 (SYS LED)", 0 }, - ONLP_LED_STATUS_PRESENT, - ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_GREEN, - }, - { - { LED_OID_FAN, "Chassis LED 2 (FAN 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_PSU1, "Chassis LED 3 (PSU1 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_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. - */ -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, pw_exist, pw_good, rc, fan_id; - onlp_fan_info_t fan_info; - char *sys_psu_prefix = NULL; - - memset(&fan_info, 0, sizeof(onlp_fan_info_t)); - led_id = ONLP_OID_ID_GET(id); - - *info = led_info[led_id]; - - if (id == LED_OID_PSU1 || id == LED_OID_PSU2) { - - if (id == LED_OID_PSU1) { - sys_psu_prefix = SYS_PSU1_PREFIX; - - } else { - sys_psu_prefix = SYS_PSU2_PREFIX; - } - /* check psu status */ - if ((rc = psu_present_get(&pw_exist, sys_psu_prefix)) - != ONLP_STATUS_OK) { - return ONLP_STATUS_E_INTERNAL; - } - if ((rc = psu_pwgood_get(&pw_good, sys_psu_prefix)) - != 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_FAN4; ++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; -} - -/* - * 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) -{ - int led_id, rc; - - led_id = ONLP_OID_ID_GET(id); - switch (led_id) { - case LED_SYSTEM_LED: - rc = system_led_set(mode); - break; - case LED_FAN_LED: - rc = fan_led_set(mode); - break; - case LED_PSU1_LED: - rc = psu1_led_set(mode); - break; - 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; - } - - return rc; -} - -int -onlp_ledi_ioctl(onlp_oid_t id, va_list vargs) -{ - return ONLP_STATUS_OK; -} diff --git a/packages/platforms/ingrasys/x86-64/s9280-64x/onlp/builds/x86_64_ingrasys_s9280_64x/module/src/make.mk b/packages/platforms/ingrasys/x86-64/s9280-64x/onlp/builds/x86_64_ingrasys_s9280_64x/module/src/make.mk deleted file mode 100755 index 73ac18ec0..000000000 --- a/packages/platforms/ingrasys/x86-64/s9280-64x/onlp/builds/x86_64_ingrasys_s9280_64x/module/src/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. -# -# -############################################################ -# -# -# -############################################################ - -LIBRARY := x86_64_ingrasys_s9280_64x -$(LIBRARY)_SUBDIR := $(dir $(lastword $(MAKEFILE_LIST))) -#$(LIBRARY)_LAST := 1 -include $(BUILDER)/lib.mk diff --git a/packages/platforms/ingrasys/x86-64/s9280-64x/onlp/builds/x86_64_ingrasys_s9280_64x/module/src/platform_lib.c b/packages/platforms/ingrasys/x86-64/s9280-64x/onlp/builds/x86_64_ingrasys_s9280_64x/module/src/platform_lib.c deleted file mode 100755 index d10616bff..000000000 --- a/packages/platforms/ingrasys/x86-64/s9280-64x/onlp/builds/x86_64_ingrasys_s9280_64x/module/src/platform_lib.c +++ /dev/null @@ -1,576 +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 -#include -#include -#include -#include -#include - -#include "platform_lib.h" - -int -psu_thermal_get(onlp_thermal_info_t* info, int thermal_id) -{ - int pw_exist, pw_good; - int offset, i2c_bus, rc; - int value, buf; - unsigned int y_value = 0; - unsigned char n_value = 0; - unsigned int temp = 0; - char result[32]; - char *sys_psu_prefix = NULL; - - if (thermal_id == THERMAL_ID_PSU1_1) { - i2c_bus = I2C_BUS_PSU1; - offset = PSU_THERMAL1_OFFSET; - sys_psu_prefix = SYS_PSU1_PREFIX; - } else if (thermal_id == THERMAL_ID_PSU1_2) { - i2c_bus = I2C_BUS_PSU1; - offset = PSU_THERMAL2_OFFSET; - sys_psu_prefix = SYS_PSU1_PREFIX; - } else if (thermal_id == THERMAL_ID_PSU2_1) { - i2c_bus = I2C_BUS_PSU2; - offset = PSU_THERMAL1_OFFSET; - sys_psu_prefix = SYS_PSU2_PREFIX; - } else if (thermal_id == THERMAL_ID_PSU2_2) { - i2c_bus = I2C_BUS_PSU2; - offset = PSU_THERMAL2_OFFSET; - sys_psu_prefix = SYS_PSU2_PREFIX; - } - - /* check psu status */ - if ((rc = psu_present_get(&pw_exist, sys_psu_prefix)) - != ONLP_STATUS_OK) { - return ONLP_STATUS_E_INTERNAL; - } - - 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, sys_psu_prefix)) - != ONLP_STATUS_OK) { - return ONLP_STATUS_E_INTERNAL; - } - - if (pw_good != PSU_STATUS_POWER_GOOD) { - info->mcelsius = 0; - return ONLP_STATUS_OK; - } - - value = onlp_i2c_readw(i2c_bus, PSU_REG, offset, ONLP_I2C_F_FORCE); - - y_value = (value & 0x07FF); - if ((value & 0x8000)&&(y_value)) { - n_value = 0xF0 + (((value) >> 11) & 0x0F); - n_value = (~n_value) +1; - temp = (unsigned int)(1<> 11) & 0x0F); - snprintf(result, sizeof(result), "%d", (y_value*(1<mcelsius = (int)(buf * 1000); - - return ONLP_STATUS_OK; -} - -int -psu_fan_info_get(onlp_fan_info_t* info, int id) -{ - int pw_exist, pw_good; - int i2c_bus, rc; - unsigned int tmp_fan_rpm, fan_rpm; - char *sys_psu_prefix = NULL; - - if (id == FAN_ID_PSU_FAN1) { - i2c_bus = I2C_BUS_PSU1; - sys_psu_prefix = SYS_PSU1_PREFIX; - } else if (id == FAN_ID_PSU_FAN2) { - i2c_bus = I2C_BUS_PSU2; - sys_psu_prefix = SYS_PSU2_PREFIX; - } else { - return ONLP_STATUS_E_INTERNAL; - } - - /* check psu status */ - if ((rc = psu_present_get(&pw_exist, sys_psu_prefix)) - != ONLP_STATUS_OK) { - return ONLP_STATUS_E_INTERNAL; - } - - 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, sys_psu_prefix)) - != ONLP_STATUS_OK) { - return ONLP_STATUS_E_INTERNAL; - } - - if (pw_good != PSU_STATUS_POWER_GOOD) { - info->rpm = 0; - return ONLP_STATUS_OK; - } - - tmp_fan_rpm = onlp_i2c_readw(i2c_bus, PSU_REG, PSU_FAN_RPM_OFFSET, ONLP_I2C_F_FORCE); - - fan_rpm = (unsigned int)tmp_fan_rpm; - fan_rpm = (fan_rpm & 0x07FF) * (1 << ((fan_rpm >> 11) & 0x1F)); - info->rpm = (int)fan_rpm; - - return ONLP_STATUS_OK; -} - -int -psu_vout_get(onlp_psu_info_t* info, int i2c_bus) -{ - int v_value = 0; - int n_value = 0; - unsigned int temp = 0; - char result[32]; - double dvalue; - memset(result, 0, sizeof(result)); - - n_value = onlp_i2c_readb(i2c_bus, PSU_REG, PSU_VOUT_OFFSET1, ONLP_I2C_F_FORCE); - if (n_value < 0) { - return ONLP_STATUS_E_INTERNAL; - } - - v_value = onlp_i2c_readw(i2c_bus, PSU_REG, PSU_VOUT_OFFSET2, ONLP_I2C_F_FORCE); - if (v_value < 0) { - return ONLP_STATUS_E_INTERNAL; - } - - if (n_value & 0x10) { - n_value = 0xF0 + (n_value & 0x0F); - n_value = (~n_value) +1; - temp = (unsigned int)(1< 0.0) { - info->caps |= ONLP_PSU_CAPS_VOUT; - info->mvout = (int)(dvalue * 1000); - } - - return ONLP_STATUS_OK; -} - -int -psu_iout_get(onlp_psu_info_t* info, int i2c_bus) -{ - int value; - unsigned int y_value = 0; - unsigned char n_value = 0; - unsigned int temp = 0; - char result[32]; - memset(result, 0, sizeof(result)); - double dvalue; - - value = onlp_i2c_readw(i2c_bus, PSU_REG, PSU_IOUT_OFFSET, ONLP_I2C_F_FORCE); - if (value < 0) { - return ONLP_STATUS_E_INTERNAL; - } - - y_value = (value & 0x07FF); - if ((value & 0x8000)&&(y_value)) - { - n_value = 0xF0 + (((value) >> 11) & 0x0F); - n_value = (~n_value) +1; - temp = (unsigned int)(1<> 11) & 0x0F); - snprintf(result, sizeof(result), "%d", (y_value*(1< 0.0) { - info->caps |= ONLP_PSU_CAPS_IOUT; - info->miout = (int)(dvalue * 1000); - } - - return ONLP_STATUS_OK; -} - -int -psu_pout_get(onlp_psu_info_t* info, int i2c_bus) -{ - int value; - unsigned int y_value = 0; - unsigned char n_value = 0; - unsigned int temp = 0; - char result[32]; - memset(result, 0, sizeof(result)); - double dvalue; - - value = onlp_i2c_readw(i2c_bus, PSU_REG, PSU_POUT_OFFSET, ONLP_I2C_F_FORCE); - if (value < 0) { - return ONLP_STATUS_E_INTERNAL; - } - - y_value = (value & 0x07FF); - if ((value & 0x8000)&&(y_value)) - { - n_value = 0xF0 + (((value) >> 11) & 0x0F); - n_value = (~n_value) +1; - temp = (unsigned int)(1<> 11) & 0x0F); - snprintf(result, sizeof(result), "%d", (y_value*(1< 0.0) { - info->caps |= ONLP_PSU_CAPS_POUT; - info->mpout = (int)(dvalue * 1000); - } - - return ONLP_STATUS_OK; -} - -int -psu_pin_get(onlp_psu_info_t* info, int i2c_bus) -{ - int value; - unsigned int y_value = 0; - unsigned char n_value = 0; - unsigned int temp = 0; - char result[32]; - memset(result, 0, sizeof(result)); - double dvalue; - - value = onlp_i2c_readw(i2c_bus, PSU_REG, PSU_PIN_OFFSET, ONLP_I2C_F_FORCE); - if (value < 0) { - return ONLP_STATUS_E_INTERNAL; - } - - y_value = (value & 0x07FF); - if ((value & 0x8000)&&(y_value)) - { - n_value = 0xF0 + (((value) >> 11) & 0x0F); - n_value = (~n_value) +1; - temp = (unsigned int)(1<> 11) & 0x0F); - snprintf(result, sizeof(result), "%d", (y_value*(1< 0.0) { - info->caps |= ONLP_PSU_CAPS_PIN; - info->mpin = (int)(dvalue * 1000); - } - - return ONLP_STATUS_OK; -} - -int -psu_eeprom_get(onlp_psu_info_t* info, int id) -{ - uint8_t data[256]; - char eeprom_path[128]; - int data_len, i, rc; - memset(data, 0, sizeof(data)); - memset(eeprom_path, 0, sizeof(eeprom_path)); - - if (id == PSU_ID_PSU1) { - rc = onlp_file_read(data, sizeof(data), &data_len, PSU1_EEPROM_PATH); - } else { - rc = onlp_file_read(data, sizeof(data), &data_len, PSU2_EEPROM_PATH); - } - - if (rc == ONLP_STATUS_OK) - { - i = 11; - - /* Manufacturer Name */ - data_len = (data[i]&0x0f); - i++; - i += data_len; - - /* Product Name */ - data_len = (data[i]&0x0f); - i++; - memcpy(info->model, (char *) &(data[i]), data_len); - i += data_len; - - /* Product part,model number */ - data_len = (data[i]&0x0f); - i++; - i += data_len; - - /* Product Version */ - data_len = (data[i]&0x0f); - i++; - i += data_len; - - /* Product Serial Number */ - data_len = (data[i]&0x0f); - i++; - memcpy(info->serial, (char *) &(data[i]), data_len); - } else { - strcpy(info->model, "Missing"); - strcpy(info->serial, "Missing"); - } - - return ONLP_STATUS_OK; -} - - -int -psu_present_get(int *pw_exist, char *sys_psu_prefix) -{ - int rv, psu_pres; - - rv = onlp_file_read_int(&psu_pres, "%spsu_abs", sys_psu_prefix); - if (rv < 0) { - return ONLP_STATUS_E_INTERNAL; - } - - *pw_exist = (psu_pres ? 0 : 1); - return ONLP_STATUS_OK; -} - -int -psu_pwgood_get(int *pw_good, char *sys_psu_prefix) -{ - int rv, psu_pwgood; - - rv = onlp_file_read_int(&psu_pwgood, "%spsu_pg", sys_psu_prefix); - if (rv < 0) { - return ONLP_STATUS_E_INTERNAL; - } - - *pw_good = (psu_pwgood ? 1 : 0); - return ONLP_STATUS_OK; -} - -int -system_led_set(onlp_led_mode_t mode) -{ - int rc; - if(mode == ONLP_LED_MODE_GREEN) { - rc = onlp_i2c_modifyb(I2C_BUS_SYS_LED, LED_REG, LED_OFFSET, LED_SYS_AND_MASK, - LED_SYS_GMASK, ONLP_I2C_F_FORCE); - } - else if(mode == ONLP_LED_MODE_ORANGE) { - rc = onlp_i2c_modifyb(I2C_BUS_SYS_LED, LED_REG, LED_OFFSET, LED_SYS_AND_MASK, - LED_SYS_YMASK, ONLP_I2C_F_FORCE); - } else { - return ONLP_STATUS_E_INTERNAL; - } - - if (rc < 0) { - return ONLP_STATUS_E_INTERNAL; - } - - return ONLP_STATUS_OK; -} - -int -fan_led_set(onlp_led_mode_t mode) -{ - int rc; - - if(mode == ONLP_LED_MODE_GREEN) { - rc = onlp_i2c_modifyb(I2C_BUS_SYS_LED, LED_REG, LED_OFFSET, LED_FAN_AND_MASK, - LED_FAN_GMASK, ONLP_I2C_F_FORCE); - } - else if(mode == ONLP_LED_MODE_ORANGE) { - rc = onlp_i2c_modifyb(I2C_BUS_SYS_LED, LED_REG, LED_OFFSET, LED_FAN_AND_MASK, - LED_FAN_YMASK, ONLP_I2C_F_FORCE); - } - else if(mode == ONLP_LED_MODE_OFF) { - rc = onlp_i2c_modifyb(I2C_BUS_SYS_LED, LED_REG, LED_OFFSET, LED_FAN_AND_MASK, - LED_FAN_OFFMASK, ONLP_I2C_F_FORCE); - } else { - return ONLP_STATUS_E_INTERNAL; - } - - if (rc < 0) { - return ONLP_STATUS_E_INTERNAL; - } - - return ONLP_STATUS_OK; -} - -int -psu1_led_set(onlp_led_mode_t mode) -{ - int rc; - if(mode == ONLP_LED_MODE_GREEN) { - rc = onlp_i2c_modifyb(I2C_BUS_SYS_LED, LED_REG, LED_OFFSET, - LED_PSU1_AND_MASK, LED_PSU1_GMASK, - ONLP_I2C_F_FORCE); - } else if(mode == ONLP_LED_MODE_ORANGE) { - rc = onlp_i2c_modifyb(I2C_BUS_SYS_LED, 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_SYS_LED, LED_REG, LED_OFFSET, - LED_PSU1_AND_MASK, LED_PSU1_OFFMASK, - ONLP_I2C_F_FORCE); - } else { - return ONLP_STATUS_E_INTERNAL; - } - - if (rc < 0) { - return ONLP_STATUS_E_INTERNAL; - } - - return ONLP_STATUS_OK; -} - -int -psu2_led_set(onlp_led_mode_t mode) -{ - int rc; - if(mode == ONLP_LED_MODE_GREEN) { - rc = onlp_i2c_modifyb(I2C_BUS_SYS_LED, LED_REG, LED_OFFSET, - LED_PSU2_AND_MASK, LED_PSU2_GMASK, - ONLP_I2C_F_FORCE); - } else if(mode == ONLP_LED_MODE_ORANGE) { - rc = onlp_i2c_modifyb(I2C_BUS_SYS_LED, 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_SYS_LED, LED_REG, LED_OFFSET, - LED_PSU2_AND_MASK, LED_PSU2_OFFMASK, - ONLP_I2C_F_FORCE); - } else { - return ONLP_STATUS_E_INTERNAL; - } - - - if (rc < 0) { - return ONLP_STATUS_E_INTERNAL; - } - - 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; - - 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_FANTRAY_LED, FAN_GPIO_ADDR, offset, 0xFC, - 0x01, ONLP_I2C_F_FORCE); - } else if (mode == ONLP_LED_MODE_ORANGE) { - rc = onlp_i2c_modifyb(I2C_BUS_FANTRAY_LED, FAN_GPIO_ADDR, 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_FANTRAY_LED, FAN_GPIO_ADDR, offset, 0xCF, - 0x10, ONLP_I2C_F_FORCE); - } else if (mode == ONLP_LED_MODE_ORANGE) { - rc = onlp_i2c_modifyb(I2C_BUS_FANTRAY_LED, FAN_GPIO_ADDR, 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) -{ - int cpld_release, cpld_version, cpld_rev; - int bus_i; - - for(bus_i=I2C_BUS_CPLD1; bus_i <= I2C_BUS_CPLD5; ++bus_i) { - cpld_rev = onlp_i2c_readb(bus_i, CPLD_REG, CPLD_VER_OFFSET, ONLP_I2C_F_FORCE); - if (cpld_rev < 0) { - return ONLP_STATUS_E_INTERNAL; - } - - cpld_release = (((cpld_rev) >> 6 & 0x01)); - cpld_version = (((cpld_rev) & 0x3F)); - - pi->cpld_versions = aim_fstrdup( - "CPLD is %d version(0:RD 1:Release), Revision is 0x%02x\n", - cpld_release, cpld_version); - } - return ONLP_STATUS_OK; -} diff --git a/packages/platforms/ingrasys/x86-64/s9280-64x/onlp/builds/x86_64_ingrasys_s9280_64x/module/src/platform_lib.h b/packages/platforms/ingrasys/x86-64/s9280-64x/onlp/builds/x86_64_ingrasys_s9280_64x/module/src/platform_lib.h deleted file mode 100755 index cc61a924f..000000000 --- a/packages/platforms/ingrasys/x86-64/s9280-64x/onlp/builds/x86_64_ingrasys_s9280_64x/module/src/platform_lib.h +++ /dev/null @@ -1,312 +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. - * - * - ************************************************************ - * - * - * - ***********************************************************/ -#ifndef __PLATFORM_LIB_H__ -#define __PLATFORM_LIB_H__ - -#include -#include -#include -#include -#include -#include "x86_64_ingrasys_s9280_64x_int.h" -#include "x86_64_ingrasys_s9280_64x_log.h" - -#include -#define SYS_CPU_TEMP_PREFIX "/sys/class/hwmon/hwmon0/" -#define SYS_REAR_PANEL_TEMP_PREFIX "/sys/class/hwmon/hwmon2/" -#define SYS_REAR_MAC_TEMP_PREFIX "/sys/class/hwmon/hwmon3/" -#define SYS_MB_ASIC_TEMP_PREFIX "/sys/class/hwmon/hwmon4/" -#define SYS_FRONT_PANEL_PREFIX "/sys/class/hwmon/hwmon5/" -#define SYS_FRONT_MAC_PREFIX "/sys/class/hwmon/hwmon6/" -#define SYS_BMC_BOARD_PREFIX "/sys/class/hwmon/hwmon7/" -#define SYS_CPU_BOARD_PREFIX "/sys/class/hwmon/hwmon8/" -#define SYS_FAN_PREFIX "/sys/class/hwmon/hwmon1/device/" -#define SYS_PSU1_PREFIX "/sys/bus/i2c/devices/i2c-18/18-0050/" -#define SYS_PSU2_PREFIX "/sys/bus/i2c/devices/i2c-17/17-0050/" -#define SYS_EEPROM_PATH "/sys/bus/i2c/devices/0-0051/eeprom" -#define SYS_EEPROM_SIZE 512 -#define PSU1_EEPROM_PATH "/sys/bus/i2c/devices/18-0050/psu_eeprom" -#define PSU2_EEPROM_PATH "/sys/bus/i2c/devices/17-0050/psu_eeprom" -#define PSU_STATUS_PRESENT 1 -#define PSU_STATUS_POWER_GOOD 1 -#define FAN_PRESENT 0 -#define FAN_CTRL_SET1 1 -#define FAN_CTRL_SET2 2 -#define BOARD_THERMAL_NUM 6 -#define SYS_FAN_NUM 4 -#define PORT_NUM 66 - -#define THERMAL_NUM 16 -#define LED_NUM 4 -#define FAN_NUM 6 - - - -#define THERMAL_SHUTDOWN_DEFAULT 105000 - -#define THERMAL_ERROR_DEFAULT 95000 -#define THERMAL_ERROR_FAN_PERC 100 - -#define THERMAL_WARNING_DEFAULT 77000 -#define THERMAL_WARNING_FAN_PERC 80 - -#define THERMAL_NORMAL_DEFAULT 72000 -#define THERMAL_NORMAL_FAN_PERC 50 - -/* I2C bus */ -#define I2C_BUS_0 0 -#define I2C_BUS_1 1 -#define I2C_BUS_2 2 -#define I2C_BUS_3 3 -#define I2C_BUS_4 4 -#define I2C_BUS_5 5 -#define I2C_BUS_10 10 /* SYS_LED */ -#define I2C_BUS_17 (17) /* PSU2 */ -#define I2C_BUS_18 (18) /* PSU1 */ - -#define I2C_BUS_PSU1 I2C_BUS_18 /* PSU1 */ -#define I2C_BUS_PSU2 I2C_BUS_17 /* PSU2 */ -#define I2C_BUS_SYS_LED I2C_BUS_10 /* SYS LED */ -#define I2C_BUS_FANTRAY_LED I2C_BUS_0 /* FANTRAY LED */ -#define I2C_BUS_CPLD1 I2C_BUS_1 /* CPLD 1 */ -#define I2C_BUS_CPLD2 I2C_BUS_2 /* CPLD 2 */ -#define I2C_BUS_CPLD3 I2C_BUS_3 /* CPLD 3 */ -#define I2C_BUS_CPLD4 I2C_BUS_4 /* CPLD 4 */ -#define I2C_BUS_CPLD5 I2C_BUS_5 /* CPLD 5 */ - -/* PSU */ -#define PSU_MUX_MASK 0x01 - -#define PSU_THERMAL1_OFFSET 0x8D -#define PSU_THERMAL2_OFFSET 0x8E -#define PSU_THERMAL_REG 0x58 -#define PSU_FAN_RPM_REG 0x58 -#define PSU_FAN_RPM_OFFSET 0x90 -#define PSU_REG 0x58 -#define PSU_VOUT_OFFSET1 0x20 -#define PSU_VOUT_OFFSET2 0x8B -#define PSU_IOUT_OFFSET 0x8C -#define PSU_POUT_OFFSET 0x96 -#define PSU_PIN_OFFSET 0x97 - -#define PSU_STATE_REG 0x25 -#define PSU1_PRESENT_OFFSET 0x04 -#define PSU2_PRESENT_OFFSET 0x01 -#define PSU1_PWGOOD_OFFSET 0x03 -#define PSU2_PWGOOD_OFFSET 0x00 - -/* LED */ -#define LED_REG 0x76 -#define LED_OFFSET 0x02 -#define LED_PWOK_OFFSET 0x03 - -#define LED_SYS_AND_MASK 0x7F -#define LED_SYS_GMASK 0x80 -#define LED_SYS_YMASK 0x00 - -#define LED_FAN_AND_MASK 0x9F -#define LED_FAN_GMASK 0x40 -#define LED_FAN_YMASK 0x60 -#define LED_FAN_OFFMASK 0x00 - -#define LED_PSU2_AND_MASK 0xF9 -#define LED_PSU2_GMASK 0x04 -#define LED_PSU2_YMASK 0x06 -#define LED_PSU2_OFFMASK 0x00 - -#define LED_PSU1_AND_MASK 0xE7 -#define LED_PSU1_GMASK 0x10 -#define LED_PSU1_YMASK 0x18 -#define LED_PSU1_OFFMASK 0x00 - -#define LED_SYS_ON_MASK 0x00 -#define LED_SYS_OFF_MASK 0x33 - -/* SYS */ -#define CPLD_REG 0x33 -#define CPLD_VER_OFFSET 0x01 - -/* QSFP */ -#define QSFP_PRES_REG1 0x20 -#define QSFP_PRES_REG2 0x21 -#define QSFP_PRES_OFFSET1 0x00 -#define QSFP_PRES_OFFSET2 0x01 - -/* FANTRAY */ -#define FAN_GPIO_ADDR 0x20 -#define FAN_1_PRESENT_MASK 0x04 -#define FAN_2_PRESENT_MASK 0x40 -#define FAN_3_PRESENT_MASK 0x04 -#define FAN_4_PRESENT_MASK 0x40 - -/* CPLD */ -//#define CPLDx_I2C_ADDR 0x21 -#define QSFP_EEPROM_I2C_ADDR 0x50 -#define CPLD1_PORTS 12 -#define CPLDx_PORTS 13 -#define CPLD_OFFSET 1 -#define CPLD_PRES_BIT 1 -#define CPLD_SFP1_PRES_BIT 1 -#define CPLD_SFP2_PRES_BIT 4 -#define CPLD_QSFP_REG_PATH "/sys/bus/i2c/devices/%d-00%02x/%s_%d" -#define CPLD_SFP_REG_PATH "/sys/bus/i2c/devices/%d-00%02x/%s" -#define CPLD_QSFP_PORT_STATUS_KEY "cpld_qsfp_port_status" -#define CPLD_SFP_PORT_STATUS_KEY "cpld_sfp_port_status" - - -/** 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 */ -typedef enum led_id_e { - LED_SYSTEM_LED = 1, - 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 */ -typedef enum thermal_oid_e { - THERMAL_OID_CPU1 = ONLP_THERMAL_ID_CREATE(1), - THERMAL_OID_CPU2 = ONLP_THERMAL_ID_CREATE(2), - THERMAL_OID_CPU3 = ONLP_THERMAL_ID_CREATE(3), - THERMAL_OID_CPU4 = ONLP_THERMAL_ID_CREATE(4), - THERMAL_OID_REAR_PANEL = ONLP_THERMAL_ID_CREATE(5), - THERMAL_OID_REAR_MAC = ONLP_THERMAL_ID_CREATE(6), - THERMAL_OID_MB = ONLP_THERMAL_ID_CREATE(7), - THERMAL_OID_ASIC = ONLP_THERMAL_ID_CREATE(8), - THERMAL_OID_FRONT_PANEL = ONLP_THERMAL_ID_CREATE(9), - THERMAL_OID_FRONT_MAC = ONLP_THERMAL_ID_CREATE(10), - THERMAL_OID_BMC_BOARD = ONLP_THERMAL_ID_CREATE(11), - THERMAL_OID_CPU_BOARD = ONLP_THERMAL_ID_CREATE(12), - THERMAL_OID_PSU1_1 = ONLP_THERMAL_ID_CREATE(13), - THERMAL_OID_PSU1_2 = ONLP_THERMAL_ID_CREATE(14), - THERMAL_OID_PSU2_1 = ONLP_THERMAL_ID_CREATE(15), - THERMAL_OID_PSU2_2 = ONLP_THERMAL_ID_CREATE(16), -} thermal_oid_t; - -/** thermal_id */ -typedef enum thermal_id_e { - THERMAL_ID_CPU1 = 1, - THERMAL_ID_CPU2 = 2, - THERMAL_ID_CPU3 = 3, - THERMAL_ID_CPU4 = 4, - THERMAL_ID_REAR_PANEL = 5, - THERMAL_ID_REAR_MAC = 6, - THERMAL_ID_MB = 7, - THERMAL_ID_ASIC = 8, - THERMAL_ID_FRONT_PANEL = 9, - THERMAL_ID_FRONT_MAC = 10, - THERMAL_ID_BMC_BOARD = 11, - THERMAL_ID_CPU_BOARD = 12, - THERMAL_ID_PSU1_1 = 13, - THERMAL_ID_PSU1_2 = 14, - THERMAL_ID_PSU2_1 = 15, - THERMAL_ID_PSU2_2 = 16, -} thermal_id_t; - -/* Shortcut for CPU thermal threshold value. */ -#define THERMAL_THRESHOLD_INIT_DEFAULTS \ - { THERMAL_WARNING_DEFAULT, \ - THERMAL_ERROR_DEFAULT, \ - THERMAL_SHUTDOWN_DEFAULT } - -/** 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_PSU_FAN1 = ONLP_FAN_ID_CREATE(5), - FAN_OID_PSU_FAN2 = ONLP_FAN_ID_CREATE(6) -} fan_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_PSU_FAN1 = 5, - FAN_ID_PSU_FAN2 = 6 -} fan_id_t; - -/** led_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; - -/** fan_id */ -typedef enum psu_id_e { - PSU_ID_PSU1 = 1, - PSU_ID_PSU2 = 2 -} psu_id_t; - -int psu_thermal_get(onlp_thermal_info_t* info, int id); - -int psu_fan_info_get(onlp_fan_info_t* info, int id); - -int psu_vout_get(onlp_psu_info_t* info, int i2c_bus); - -int psu_iout_get(onlp_psu_info_t* info, int i2c_bus); - -int psu_pout_get(onlp_psu_info_t* info, int i2c_bus); - -int psu_pin_get(onlp_psu_info_t* info, int i2c_bus); - -int psu_eeprom_get(onlp_psu_info_t* info, int id); - -int psu_present_get(int *pw_exist, char *sys_psu_prefix); - -int psu_pwgood_get(int *pw_good, char *sys_psu_prefix); - -int psu2_led_set(onlp_led_mode_t mode); - -int psu1_led_set(onlp_led_mode_t mode); - -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); - -#endif /* __PLATFORM_LIB_H__ */ diff --git a/packages/platforms/ingrasys/x86-64/s9280-64x/onlp/builds/x86_64_ingrasys_s9280_64x/module/src/psui.c b/packages/platforms/ingrasys/x86-64/s9280-64x/onlp/builds/x86_64_ingrasys_s9280_64x/module/src/psui.c deleted file mode 100755 index a8f385fbd..000000000 --- a/packages/platforms/ingrasys/x86-64/s9280-64x/onlp/builds/x86_64_ingrasys_s9280_64x/module/src/psui.c +++ /dev/null @@ -1,156 +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 - -#include "platform_lib.h" - -static onlp_psu_info_t pinfo[] = -{ - { }, /* Not used */ - { - { - PSU_OID_PSU1, - "PSU-1", - 0, - { - FAN_OID_PSU_FAN1, - }, - } - }, - { - { - PSU_OID_PSU2, - "PSU-2", - 0, - { - FAN_OID_PSU_FAN2, - }, - } - } -}; - -int -onlp_psui_init(void) -{ - return ONLP_STATUS_OK; -} - -int -psu_status_info_get(int id, onlp_psu_info_t *info) -{ - int pw_exist, pw_good; - int rc, i2c_bus; - char *sys_psu_prefix = NULL; - - if (id == PSU_ID_PSU1) { - i2c_bus = I2C_BUS_PSU1; - sys_psu_prefix = SYS_PSU1_PREFIX; - } else if (id == PSU_ID_PSU2) { - i2c_bus = I2C_BUS_PSU2; - sys_psu_prefix = SYS_PSU2_PREFIX; - } else { - return ONLP_STATUS_E_INTERNAL; - } - - /* Get power present status */ - if ((rc = psu_present_get(&pw_exist, sys_psu_prefix)) - != ONLP_STATUS_OK) { - return ONLP_STATUS_E_INTERNAL; - } - - if (pw_exist != PSU_STATUS_PRESENT) { - info->status &= ~ONLP_PSU_STATUS_PRESENT; - info->status |= ONLP_PSU_STATUS_FAILED; - return ONLP_STATUS_OK; - } - info->status |= ONLP_PSU_STATUS_PRESENT; - - /* Get power good status */ - if ((rc = psu_pwgood_get(&pw_good, sys_psu_prefix)) - != ONLP_STATUS_OK) { - return ONLP_STATUS_E_INTERNAL; - } - - 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 */ - if ((rc = psu_eeprom_get(info, id)) != ONLP_STATUS_OK) { - return ONLP_STATUS_E_INTERNAL; - } - - /* Get power iout status */ - if ((rc = psu_iout_get(info, i2c_bus)) != ONLP_STATUS_OK) { - return ONLP_STATUS_E_INTERNAL; - } - - /* Get power pout status */ - if ((rc = psu_pout_get(info, i2c_bus)) != ONLP_STATUS_OK) { - return ONLP_STATUS_E_INTERNAL; - } - - /* Get power pin status */ - if ((rc = psu_pin_get(info, i2c_bus)) != ONLP_STATUS_OK) { - return ONLP_STATUS_E_INTERNAL; - } - - /* Get power vout status */ - if ((rc = psu_vout_get(info, i2c_bus)) != ONLP_STATUS_OK) { - return ONLP_STATUS_E_INTERNAL; - } - - return ONLP_STATUS_OK; -} - -int -onlp_psui_info_get(onlp_oid_t id, onlp_psu_info_t* info) -{ - int pid; - - pid = ONLP_OID_ID_GET(id); - memset(info, 0, sizeof(onlp_psu_info_t)); - - /* Set the onlp_oid_hdr_t */ - *info = pinfo[pid]; - - switch (pid) { - case PSU_ID_PSU1: - case PSU_ID_PSU2: - return psu_status_info_get(pid, info); - break; - default: - return ONLP_STATUS_E_UNSUPPORTED; - break; - } - - return ONLP_STATUS_OK; - - -} diff --git a/packages/platforms/ingrasys/x86-64/s9280-64x/onlp/builds/x86_64_ingrasys_s9280_64x/module/src/sfpi.c b/packages/platforms/ingrasys/x86-64/s9280-64x/onlp/builds/x86_64_ingrasys_s9280_64x/module/src/sfpi.c deleted file mode 100755 index 19cf396f7..000000000 --- a/packages/platforms/ingrasys/x86-64/s9280-64x/onlp/builds/x86_64_ingrasys_s9280_64x/module/src/sfpi.c +++ /dev/null @@ -1,190 +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 -#include -#include -#include -#include -#include -#include -#include "x86_64_ingrasys_s9280_64x_log.h" -#include "platform_lib.h" - -static int _fp2phy_port_mapping[64] = { - 0, 1, 4, 5, 8, - 9, 12, 13, 16, 17, - 20, 21, 24, 25, 28, - 29, 32, 33, 36, 37, - 40, 41, 44, 45, 48, - 49, 52, 53, 56, 57, - 60, 61, 2, 3, 6, - 7, 10, 11, 14, 15, - 18, 19, 22, 23, 26, - 27, 30, 31, 34, 35, - 38, 39, 42, 43, 46, - 47, 50, 51, 54, 55, - 58, 59, 62, 63}; - -static void -qsfp_to_cpld_index(int phy_port, int *cpld_id, int *cpld_port_index) -{ - if (phy_port < CPLD1_PORTS) { - *cpld_id = 0; - *cpld_port_index = phy_port + 1; - } else { - *cpld_id = 1 + (phy_port - CPLD1_PORTS) / CPLDx_PORTS; - *cpld_port_index = ((phy_port - CPLD1_PORTS) % CPLDx_PORTS) + 1; - } - return; -} - - -int -onlp_sfpi_init(void) -{ - return ONLP_STATUS_OK; -} - -int -onlp_sfpi_bitmap_get(onlp_sfp_bitmap_t* bmap) -{ - int p; - for(p = 1; p <= PORT_NUM; p++) { - AIM_BITMAP_SET(bmap, p); - } - return ONLP_STATUS_OK; -} - -int -onlp_sfpi_is_present(int port) -{ - int status, phy_port; - int i2c_id, cpld_id, cpld_port_index; - char reg_path[128]; - int value, mask; - uint8_t data[8]; - int data_len; - - if (port >= 1 && port <=64) { - phy_port = _fp2phy_port_mapping[port-1]; - qsfp_to_cpld_index(phy_port, &cpld_id, &cpld_port_index); - - i2c_id = CPLD_OFFSET + cpld_id; - mask = 1 << CPLD_PRES_BIT; - - snprintf(reg_path, 128, CPLD_QSFP_REG_PATH, i2c_id, CPLD_REG, CPLD_QSFP_PORT_STATUS_KEY, cpld_port_index); - } else if (port>= 65 && port <= 66) { - cpld_port_index = 0; - i2c_id = CPLD_OFFSET; - - if (port == 65) { - mask = 1 << CPLD_SFP1_PRES_BIT; - } else { - mask = 1 << CPLD_SFP2_PRES_BIT; - } - - snprintf(reg_path, 128, CPLD_SFP_REG_PATH, i2c_id, CPLD_REG, CPLD_SFP_PORT_STATUS_KEY); - } else { - return ONLP_STATUS_E_INTERNAL; - } - - if (onlp_file_read(data, sizeof(data), &data_len, reg_path) == ONLP_STATUS_OK) { - //convert hex string to integer - value = (int) strtol ((char *) data, NULL, 16); - - if ( (value & mask) == 0) { - status = 1; - } else { - status = 0; - } - } else { - return ONLP_STATUS_E_INTERNAL; - } - - return status; -} - - -int -onlp_sfpi_presence_bitmap_get(onlp_sfp_bitmap_t* dst) -{ - int p = 1; - int rc = 0; - - for (p = 1; p <= PORT_NUM; p++) { - rc = onlp_sfpi_is_present(p); - AIM_BITMAP_MOD(dst, p, (1 == rc) ? 1 : 0); - } - - return ONLP_STATUS_OK; -} - -/* - * This function reads the SFPs idrom and returns in - * in the data buffer provided. - */ -int -onlp_sfpi_eeprom_read(int port, uint8_t data[256]) -{ - int eeprombus=0, eeprombusbase=0, phy_port=0, port_group=0, eeprombusshift=0; - char eeprom_path[512], eeprom_addr[32]; - memset(eeprom_path, 0, sizeof(eeprom_path)); - memset(eeprom_addr, 0, sizeof(eeprom_addr)); - aim_strlcpy(eeprom_addr, "0050", sizeof(eeprom_addr)); - - memset(data, 0, 256); - - if (port >=1 && port <= 64) { - phy_port = _fp2phy_port_mapping[port-1] + 1; - port_group = (phy_port-1)/8; - eeprombusbase = 41 + (port_group * 8); - eeprombusshift = (phy_port-1)%8; - eeprombus = eeprombusbase + eeprombusshift; - } else if (port == 65 ){ - eeprombus = 29; - } else if (port == 66 ){ - eeprombus = 30; - } else { - return ONLP_STATUS_E_INTERNAL; - } - - snprintf(eeprom_path, sizeof(eeprom_path), - "/sys/bus/i2c/devices/%d-%s/eeprom", eeprombus, eeprom_addr); - - if (onlplib_sfp_eeprom_read_file(eeprom_path, data) != 0) { - return ONLP_STATUS_E_INTERNAL; - } - - return ONLP_STATUS_OK; -} - -/* - * De-initialize the SFPI subsystem. - */ -int -onlp_sfpi_denit(void) -{ - return ONLP_STATUS_OK; -} diff --git a/packages/platforms/ingrasys/x86-64/s9280-64x/onlp/builds/x86_64_ingrasys_s9280_64x/module/src/sysi.c b/packages/platforms/ingrasys/x86-64/s9280-64x/onlp/builds/x86_64_ingrasys_s9280_64x/module/src/sysi.c deleted file mode 100755 index a3ed37903..000000000 --- a/packages/platforms/ingrasys/x86-64/s9280-64x/onlp/builds/x86_64_ingrasys_s9280_64x/module/src/sysi.c +++ /dev/null @@ -1,340 +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 -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "platform_lib.h" - -const char* -onlp_sysi_platform_get(void) -{ - return "x86-64-ingrasys-s9280-64x-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(SYS_EEPROM_SIZE); - if(onlp_file_read(rdata, SYS_EEPROM_SIZE, size, SYS_EEPROM_PATH) == ONLP_STATUS_OK) { - if(*size == SYS_EEPROM_SIZE) { - *data = rdata; - return ONLP_STATUS_OK; - } - } - - AIM_LOG_INFO("Unable to get data from eeprom \n"); - aim_free(rdata); - *size = 0; - return ONLP_STATUS_E_INTERNAL; -} - -int -onlp_sysi_oids_get(onlp_oid_t* table, int max) -{ - onlp_oid_t* e = table; - memset(table, 0, max*sizeof(onlp_oid_t)); - int i; - - /* 2 PSUs */ - *e++ = ONLP_PSU_ID_CREATE(1); - *e++ = ONLP_PSU_ID_CREATE(2); - - /* LEDs Item */ - for (i=1; i<=LED_NUM; i++) { - *e++ = ONLP_LED_ID_CREATE(i); - } - - /* THERMALs Item */ - for (i=1; i<=THERMAL_NUM; i++) { - *e++ = ONLP_THERMAL_ID_CREATE(i); - } - - /* Fans Item */ - for (i=1; i<=FAN_NUM; i++) { - *e++ = ONLP_FAN_ID_CREATE(i); - } - - return ONLP_STATUS_OK; -} - -int -decide_fan_percentage(int is_up, int new_temp) -{ - int new_perc; - if (is_up) { - if (new_temp >= THERMAL_ERROR_DEFAULT) { - new_perc = THERMAL_ERROR_FAN_PERC; - } else if (new_temp >= THERMAL_WARNING_DEFAULT) { - new_perc = THERMAL_WARNING_FAN_PERC; - } else { - new_perc = THERMAL_NORMAL_FAN_PERC; - } - } else { - if (new_temp <= THERMAL_NORMAL_DEFAULT) { - new_perc = THERMAL_NORMAL_FAN_PERC; - } else if (new_temp <= THERMAL_WARNING_DEFAULT) { - new_perc = THERMAL_WARNING_FAN_PERC; - } else { - new_perc = THERMAL_ERROR_FAN_PERC; - } - } - - return new_perc; -} - -int -platform_thermal_temp_get(int *thermal_temp) -{ - int i, temp, max_temp, rc; - onlp_thermal_info_t thermal_info; - memset(&thermal_info, 0, sizeof(thermal_info)); - uint32_t thermal_arr[] = { THERMAL_OID_FRONT_MAC, - THERMAL_OID_ASIC, - THERMAL_OID_CPU1, - THERMAL_OID_CPU2, - THERMAL_OID_CPU3, - THERMAL_OID_CPU4 }; - max_temp = 0; - - for (i=0; i max_temp) { - max_temp = temp; - } - } - *thermal_temp = max_temp; - - return ONLP_STATUS_OK; -} - -int -onlp_sysi_platform_manage_fans(void) -{ - int rc, is_up ,new_temp, thermal_temp, diff; - static int new_perc = 0, ori_perc = 0; - static int ori_temp = 0; - onlp_thermal_info_t thermal_info; - memset(&thermal_info, 0, sizeof(thermal_info)); - - /* get new temperature */ - if ((rc = platform_thermal_temp_get(&thermal_temp)) != ONLP_STATUS_OK) { - goto _EXIT; - } - - new_temp = thermal_temp; - diff = new_temp - ori_temp; - - if (diff == 0) { - goto _EXIT; - } else { - is_up = (diff > 0 ? 1 : 0); - } - - new_perc = decide_fan_percentage(is_up, new_temp); - - if (ori_perc == new_perc) { - goto _EXIT; - } - - - AIM_LOG_INFO("The Fan Speeds Percent are now at %d%%", new_perc); - - if ((rc = onlp_fani_percentage_set(THERMAL_OID_ASIC, new_perc)) != ONLP_STATUS_OK) { - goto _EXIT; - } - - /* update */ - ori_perc = new_perc; - ori_temp = new_temp; - -_EXIT : - return rc; -} - -int -onlp_sysi_platform_manage_leds(void) -{ - int psu1_status, psu2_status, rc, i; - static int pre_psu1_status = 0, pre_psu2_status = 0, pre_fan_status = 0; - - //------------------------------- - static int pre_fan_tray_status[4] = {0}; - int fan_tray_id, sum, total = 0; - onlp_led_status_t fan_tray_status[SYS_FAN_NUM]; - //------------------------------- - - onlp_psu_info_t psu_info; - onlp_fan_info_t fan_info; - - //-------- ----------------------- - memset(&fan_tray_status, 0, sizeof(fan_tray_status)); - //------------------------------- - - memset(&psu_info, 0, sizeof(onlp_psu_info_t)); - memset(&fan_info, 0, sizeof(onlp_fan_info_t)); - uint32_t fan_arr[] = { FAN_OID_FAN1, - FAN_OID_FAN2, - FAN_OID_FAN3, - FAN_OID_FAN4, }; - - /* PSU LED CTRL */ - if ((rc = onlp_psui_info_get(PSU_OID_PSU1, &psu_info)) != ONLP_STATUS_OK) { - goto _EXIT; - } - - psu1_status = psu_info.status; - if (psu1_status != pre_psu1_status) { - 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); - } - - if (rc != ONLP_STATUS_OK) { - goto _EXIT; - } - pre_psu1_status = psu1_status; - } - - if ((rc = onlp_psui_info_get(PSU_OID_PSU2, &psu_info)) != ONLP_STATUS_OK) { - goto _EXIT; - } - - psu2_status = psu_info.status; - if( psu2_status != pre_psu2_status) { - 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); - } - - if (rc != ONLP_STATUS_OK) { - goto _EXIT; - } - pre_psu2_status = psu2_status; - } - - /* FAN LED CTRL */ - 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 (rc != ONLP_STATUS_OK) { - goto _EXIT; - } - - pre_fan_tray_status[fan_tray_id - 5] = sum; - } - } - - if (total != pre_fan_status) { - if (total == (ONLP_LED_STATUS_PRESENT * 4)) { - 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; - } - -_EXIT : - return rc; -} - -int -onlp_sysi_platform_info_get(onlp_platform_info_t* pi) -{ - int rc; - if ((rc = sysi_platform_info_get(pi)) != ONLP_STATUS_OK) { - return ONLP_STATUS_E_INTERNAL; - } - - return ONLP_STATUS_OK; -} - diff --git a/packages/platforms/ingrasys/x86-64/s9280-64x/onlp/builds/x86_64_ingrasys_s9280_64x/module/src/thermali.c b/packages/platforms/ingrasys/x86-64/s9280-64x/onlp/builds/x86_64_ingrasys_s9280_64x/module/src/thermali.c deleted file mode 100755 index 09bd18321..000000000 --- a/packages/platforms/ingrasys/x86-64/s9280-64x/onlp/builds/x86_64_ingrasys_s9280_64x/module/src/thermali.c +++ /dev/null @@ -1,237 +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. - * - * - ************************************************************ - * - * Thermal Sensor Platform Implementation. - * - ***********************************************************/ -#include -#include -#include "x86_64_ingrasys_s9280_64x_log.h" -#include "platform_lib.h" - -static onlp_thermal_info_t thermal_info[] = { - { }, /* Not used */ - { { THERMAL_OID_CPU1, "CPU Thermal 1", 0}, - ONLP_THERMAL_STATUS_PRESENT, - ONLP_THERMAL_CAPS_ALL, 0, THERMAL_THRESHOLD_INIT_DEFAULTS - }, - { { THERMAL_OID_CPU2, "CPU Thermal 2", 0}, - ONLP_THERMAL_STATUS_PRESENT, - ONLP_THERMAL_CAPS_ALL, 0, THERMAL_THRESHOLD_INIT_DEFAULTS - }, - { { THERMAL_OID_CPU3, "CPU Thermal 3", 0}, - ONLP_THERMAL_STATUS_PRESENT, - ONLP_THERMAL_CAPS_ALL, 0, THERMAL_THRESHOLD_INIT_DEFAULTS - }, - { { THERMAL_OID_CPU4, "CPU Thermal 4", 0}, - ONLP_THERMAL_STATUS_PRESENT, - ONLP_THERMAL_CAPS_ALL, 0, THERMAL_THRESHOLD_INIT_DEFAULTS - }, - { { THERMAL_OID_REAR_PANEL, "Rear Panel", 0}, - ONLP_THERMAL_STATUS_PRESENT, - ONLP_THERMAL_CAPS_ALL, 0, THERMAL_THRESHOLD_INIT_DEFAULTS - }, - { { THERMAL_OID_REAR_MAC, "Rear MAC", 0}, - ONLP_THERMAL_STATUS_PRESENT, - ONLP_THERMAL_CAPS_ALL, 0, THERMAL_THRESHOLD_INIT_DEFAULTS - }, - { { THERMAL_OID_MB, "Mother Board", 0}, - ONLP_THERMAL_STATUS_PRESENT, - ONLP_THERMAL_CAPS_ALL, 0, THERMAL_THRESHOLD_INIT_DEFAULTS - }, - { { THERMAL_OID_ASIC, "MAC Temp", 0}, - ONLP_THERMAL_STATUS_PRESENT, - ONLP_THERMAL_CAPS_ALL, 0, THERMAL_THRESHOLD_INIT_DEFAULTS - }, - { { THERMAL_OID_FRONT_PANEL, "Front Panel", 0}, - ONLP_THERMAL_STATUS_PRESENT, - ONLP_THERMAL_CAPS_ALL, 0, THERMAL_THRESHOLD_INIT_DEFAULTS - }, - { { THERMAL_OID_FRONT_MAC, "FRONT MAC", 0}, - ONLP_THERMAL_STATUS_PRESENT, - ONLP_THERMAL_CAPS_ALL, 0, THERMAL_THRESHOLD_INIT_DEFAULTS - }, - { { THERMAL_OID_BMC_BOARD, "BMC Board", 0}, - ONLP_THERMAL_STATUS_PRESENT, - ONLP_THERMAL_CAPS_GET_TEMPERATURE, 0 - }, - { { THERMAL_OID_CPU_BOARD, "CPU Board", 0}, - ONLP_THERMAL_STATUS_PRESENT, - ONLP_THERMAL_CAPS_GET_TEMPERATURE, 0 - }, - { { THERMAL_OID_PSU1_1, "PSU-1 Thermal 1", PSU_OID_PSU1}, - ONLP_THERMAL_STATUS_PRESENT, - ONLP_THERMAL_CAPS_GET_TEMPERATURE, 0 - }, - { { THERMAL_OID_PSU1_2, "PSU-1 Thermal 2", PSU_OID_PSU1}, - ONLP_THERMAL_STATUS_PRESENT, - ONLP_THERMAL_CAPS_GET_TEMPERATURE, 0 - }, - { { THERMAL_OID_PSU2_1, "PSU-2 Thermal 1", PSU_OID_PSU2}, - ONLP_THERMAL_STATUS_PRESENT, - ONLP_THERMAL_CAPS_GET_TEMPERATURE, 0 - }, - { { THERMAL_OID_PSU2_2, "PSU-2 Thermal 2", PSU_OID_PSU2}, - ONLP_THERMAL_STATUS_PRESENT, - ONLP_THERMAL_CAPS_GET_TEMPERATURE, 0 - } -}; - -/* - * This will be called to intiialize the thermali subsystem. - */ -int -onlp_thermali_init(void) -{ - return ONLP_STATUS_OK; -} - -static int -lm_thermal_info_get(onlp_thermal_info_t* info, int id) -{ - int rv; - char sysfs_path[64]; - - switch (id) { - case THERMAL_ID_REAR_PANEL: - snprintf(sysfs_path, sizeof(sysfs_path), SYS_REAR_PANEL_TEMP_PREFIX "temp%d_input", 1); - break; - case THERMAL_ID_REAR_MAC: - snprintf(sysfs_path, sizeof(sysfs_path), SYS_REAR_MAC_TEMP_PREFIX "temp%d_input", 1); - break; - case THERMAL_ID_MB: - snprintf(sysfs_path, sizeof(sysfs_path), SYS_MB_ASIC_TEMP_PREFIX "temp%d_input", 1); - break; - case THERMAL_ID_ASIC: - snprintf(sysfs_path, sizeof(sysfs_path), SYS_MB_ASIC_TEMP_PREFIX "temp%d_input", 2); - break; - case THERMAL_ID_FRONT_PANEL: - snprintf(sysfs_path, sizeof(sysfs_path), SYS_FRONT_PANEL_PREFIX "temp%d_input", 1); - break; - case THERMAL_ID_FRONT_MAC: - snprintf(sysfs_path, sizeof(sysfs_path), SYS_FRONT_MAC_PREFIX "temp%d_input", 1); - break; - case THERMAL_ID_BMC_BOARD: - snprintf(sysfs_path, sizeof(sysfs_path), SYS_BMC_BOARD_PREFIX "temp%d_input", 1); - break; - case THERMAL_ID_CPU_BOARD: - snprintf(sysfs_path, sizeof(sysfs_path), SYS_CPU_BOARD_PREFIX "temp%d_input", 1); - break; - } - - rv = onlp_file_read_int(&info->mcelsius, sysfs_path); - - if(rv == ONLP_STATUS_E_INTERNAL) { - return rv; - } - - if(rv == ONLP_STATUS_E_MISSING) { - info->status &= ~1; - return 0; - } - - return ONLP_STATUS_OK; -} - -static int -cpu_thermal_info_get(onlp_thermal_info_t* info, int id) -{ - int rv; - int offset; - - offset = 1; - id = id + offset; - rv = onlp_file_read_int(&info->mcelsius, - SYS_CPU_TEMP_PREFIX "temp%d_input", id); - - if(rv == ONLP_STATUS_E_INTERNAL) { - return rv; - } - - if(rv == ONLP_STATUS_E_MISSING) { - info->status &= ~1; - return 0; - } - - return ONLP_STATUS_OK; -} - -int -psu_thermal_info_get(onlp_thermal_info_t* info, int id) -{ - int rv; - - rv = psu_thermal_get(info, id); - if(rv == ONLP_STATUS_E_INTERNAL) { - return rv; - } - - 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 sensor_id, rc; - sensor_id = ONLP_OID_ID_GET(id); - - *info = thermal_info[sensor_id]; - info->caps |= ONLP_THERMAL_CAPS_GET_TEMPERATURE; - - switch (sensor_id) { - case THERMAL_ID_CPU1: - case THERMAL_ID_CPU2: - case THERMAL_ID_CPU3: - case THERMAL_ID_CPU4: - rc = cpu_thermal_info_get(info, sensor_id); - break; - case THERMAL_ID_REAR_PANEL: - case THERMAL_ID_REAR_MAC: - case THERMAL_ID_MB: - case THERMAL_ID_ASIC: - case THERMAL_ID_FRONT_PANEL: - case THERMAL_ID_FRONT_MAC: - case THERMAL_ID_BMC_BOARD: - case THERMAL_ID_CPU_BOARD: - rc = lm_thermal_info_get(info, sensor_id); - break; - case THERMAL_ID_PSU1_1: - case THERMAL_ID_PSU1_2: - case THERMAL_ID_PSU2_1: - case THERMAL_ID_PSU2_2: - rc = psu_thermal_info_get(info, sensor_id); - break; - default: - return ONLP_STATUS_E_INTERNAL; - break; - } - return rc; -} diff --git a/packages/platforms/ingrasys/x86-64/s9280-64x/onlp/builds/x86_64_ingrasys_s9280_64x/module/src/x86_64_ingrasys_s9280_64x_config.c b/packages/platforms/ingrasys/x86-64/s9280-64x/onlp/builds/x86_64_ingrasys_s9280_64x/module/src/x86_64_ingrasys_s9280_64x_config.c deleted file mode 100755 index b19b2c07a..000000000 --- a/packages/platforms/ingrasys/x86-64/s9280-64x/onlp/builds/x86_64_ingrasys_s9280_64x/module/src/x86_64_ingrasys_s9280_64x_config.c +++ /dev/null @@ -1,96 +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 __x86_64_ingrasys_s9280_64x_config_STRINGIFY_NAME(_x) #_x -#define __x86_64_ingrasys_s9280_64x_config_STRINGIFY_VALUE(_x) __x86_64_ingrasys_s9280_64x_config_STRINGIFY_NAME(_x) -x86_64_ingrasys_s9280_64x_config_settings_t x86_64_ingrasys_s9280_64x_config_settings[] = -{ -#ifdef X86_64_INGRASYS_S9280_64X_CONFIG_INCLUDE_LOGGING - { __x86_64_ingrasys_s9280_64x_config_STRINGIFY_NAME(X86_64_INGRASYS_S9280_64X_CONFIG_INCLUDE_LOGGING), __x86_64_ingrasys_s9280_64x_config_STRINGIFY_VALUE(X86_64_INGRASYS_S9280_64X_CONFIG_INCLUDE_LOGGING) }, -#else -{ X86_64_INGRASYS_S9280_64X_CONFIG_INCLUDE_LOGGING(__x86_64_ingrasys_s9280_64x_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_INGRASYS_S9280_64X_CONFIG_LOG_OPTIONS_DEFAULT - { __x86_64_ingrasys_s9280_64x_config_STRINGIFY_NAME(X86_64_INGRASYS_S9280_64X_CONFIG_LOG_OPTIONS_DEFAULT), __x86_64_ingrasys_s9280_64x_config_STRINGIFY_VALUE(X86_64_INGRASYS_S9280_64X_CONFIG_LOG_OPTIONS_DEFAULT) }, -#else -{ X86_64_INGRASYS_S9280_64X_CONFIG_LOG_OPTIONS_DEFAULT(__x86_64_ingrasys_s9280_64x_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_INGRASYS_S9280_64X_CONFIG_LOG_BITS_DEFAULT - { __x86_64_ingrasys_s9280_64x_config_STRINGIFY_NAME(X86_64_INGRASYS_S9280_64X_CONFIG_LOG_BITS_DEFAULT), __x86_64_ingrasys_s9280_64x_config_STRINGIFY_VALUE(X86_64_INGRASYS_S9280_64X_CONFIG_LOG_BITS_DEFAULT) }, -#else -{ X86_64_INGRASYS_S9280_64X_CONFIG_LOG_BITS_DEFAULT(__x86_64_ingrasys_s9280_64x_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_INGRASYS_S9280_64X_CONFIG_LOG_CUSTOM_BITS_DEFAULT - { __x86_64_ingrasys_s9280_64x_config_STRINGIFY_NAME(X86_64_INGRASYS_S9280_64X_CONFIG_LOG_CUSTOM_BITS_DEFAULT), __x86_64_ingrasys_s9280_64x_config_STRINGIFY_VALUE(X86_64_INGRASYS_S9280_64X_CONFIG_LOG_CUSTOM_BITS_DEFAULT) }, -#else -{ X86_64_INGRASYS_S9280_64X_CONFIG_LOG_CUSTOM_BITS_DEFAULT(__x86_64_ingrasys_s9280_64x_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_INGRASYS_S9280_64X_CONFIG_PORTING_STDLIB - { __x86_64_ingrasys_s9280_64x_config_STRINGIFY_NAME(X86_64_INGRASYS_S9280_64X_CONFIG_PORTING_STDLIB), __x86_64_ingrasys_s9280_64x_config_STRINGIFY_VALUE(X86_64_INGRASYS_S9280_64X_CONFIG_PORTING_STDLIB) }, -#else -{ X86_64_INGRASYS_S9280_64X_CONFIG_PORTING_STDLIB(__x86_64_ingrasys_s9280_64x_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_INGRASYS_S9280_64X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS - { __x86_64_ingrasys_s9280_64x_config_STRINGIFY_NAME(X86_64_INGRASYS_S9280_64X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS), __x86_64_ingrasys_s9280_64x_config_STRINGIFY_VALUE(X86_64_INGRASYS_S9280_64X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS) }, -#else -{ X86_64_INGRASYS_S9280_64X_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS(__x86_64_ingrasys_s9280_64x_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_INGRASYS_S9280_64X_CONFIG_INCLUDE_UCLI - { __x86_64_ingrasys_s9280_64x_config_STRINGIFY_NAME(X86_64_INGRASYS_S9280_64X_CONFIG_INCLUDE_UCLI), __x86_64_ingrasys_s9280_64x_config_STRINGIFY_VALUE(X86_64_INGRASYS_S9280_64X_CONFIG_INCLUDE_UCLI) }, -#else -{ X86_64_INGRASYS_S9280_64X_CONFIG_INCLUDE_UCLI(__x86_64_ingrasys_s9280_64x_config_STRINGIFY_NAME), "__undefined__" }, -#endif - { NULL, NULL } -}; -#undef __x86_64_ingrasys_s9280_64x_config_STRINGIFY_VALUE -#undef __x86_64_ingrasys_s9280_64x_config_STRINGIFY_NAME - -const char* -x86_64_ingrasys_s9280_64x_config_lookup(const char* setting) -{ - int i; - for(i = 0; x86_64_ingrasys_s9280_64x_config_settings[i].name; i++) { - if(!strcmp(x86_64_ingrasys_s9280_64x_config_settings[i].name, setting)) { - return x86_64_ingrasys_s9280_64x_config_settings[i].value; - } - } - return NULL; -} - -int -x86_64_ingrasys_s9280_64x_config_show(struct aim_pvs_s* pvs) -{ - int i; - for(i = 0; x86_64_ingrasys_s9280_64x_config_settings[i].name; i++) { - aim_printf(pvs, "%s = %s\n", x86_64_ingrasys_s9280_64x_config_settings[i].name, x86_64_ingrasys_s9280_64x_config_settings[i].value); - } - return i; -} - -/* */ - diff --git a/packages/platforms/ingrasys/x86-64/s9280-64x/onlp/builds/x86_64_ingrasys_s9280_64x/module/src/x86_64_ingrasys_s9280_64x_enums.c b/packages/platforms/ingrasys/x86-64/s9280-64x/onlp/builds/x86_64_ingrasys_s9280_64x/module/src/x86_64_ingrasys_s9280_64x_enums.c deleted file mode 100755 index ea89a96d1..000000000 --- a/packages/platforms/ingrasys/x86-64/s9280-64x/onlp/builds/x86_64_ingrasys_s9280_64x/module/src/x86_64_ingrasys_s9280_64x_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/ingrasys/x86-64/s9280-64x/onlp/builds/x86_64_ingrasys_s9280_64x/module/src/x86_64_ingrasys_s9280_64x_int.h b/packages/platforms/ingrasys/x86-64/s9280-64x/onlp/builds/x86_64_ingrasys_s9280_64x/module/src/x86_64_ingrasys_s9280_64x_int.h deleted file mode 100755 index e5fc2620b..000000000 --- a/packages/platforms/ingrasys/x86-64/s9280-64x/onlp/builds/x86_64_ingrasys_s9280_64x/module/src/x86_64_ingrasys_s9280_64x_int.h +++ /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. - * - * - ************************************************************ - * - * - * - ***********************************************************/ - -#ifndef __x86_64_ingrasys_s9280_64x_INT_H__ -#define __x86_64_ingrasys_s9280_64x_INT_H__ - -#endif /* __x86_64_ingrasys_s9280_64x_INT_H__ */ diff --git a/packages/platforms/ingrasys/x86-64/s9280-64x/onlp/builds/x86_64_ingrasys_s9280_64x/module/src/x86_64_ingrasys_s9280_64x_log.c b/packages/platforms/ingrasys/x86-64/s9280-64x/onlp/builds/x86_64_ingrasys_s9280_64x/module/src/x86_64_ingrasys_s9280_64x_log.c deleted file mode 100755 index 63a2e73b0..000000000 --- a/packages/platforms/ingrasys/x86-64/s9280-64x/onlp/builds/x86_64_ingrasys_s9280_64x/module/src/x86_64_ingrasys_s9280_64x_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 "x86_64_ingrasys_s9280_64x_log.h" -/* - * x86_64_ingrasys_s9280_64x log struct. - */ -AIM_LOG_STRUCT_DEFINE( - X86_64_INGRASYS_S9280_64X_CONFIG_LOG_OPTIONS_DEFAULT, - X86_64_INGRASYS_S9280_64X_CONFIG_LOG_BITS_DEFAULT, - NULL, /* Custom log map */ - X86_64_INGRASYS_S9280_64X_CONFIG_LOG_CUSTOM_BITS_DEFAULT - ); - diff --git a/packages/platforms/ingrasys/x86-64/s9280-64x/onlp/builds/x86_64_ingrasys_s9280_64x/module/src/x86_64_ingrasys_s9280_64x_log.h b/packages/platforms/ingrasys/x86-64/s9280-64x/onlp/builds/x86_64_ingrasys_s9280_64x/module/src/x86_64_ingrasys_s9280_64x_log.h deleted file mode 100755 index e3c9a78cb..000000000 --- a/packages/platforms/ingrasys/x86-64/s9280-64x/onlp/builds/x86_64_ingrasys_s9280_64x/module/src/x86_64_ingrasys_s9280_64x_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 __x86_64_ingrasys_s9280_64x_LOG_H__ -#define __x86_64_ingrasys_s9280_64x_LOG_H__ - -#define AIM_LOG_MODULE_NAME x86_64_ingrasys_s9280_64x -#include - -#endif /* __x86_64_ingrasys_s9280_64x_LOG_H__ */ diff --git a/packages/platforms/ingrasys/x86-64/s9280-64x/onlp/builds/x86_64_ingrasys_s9280_64x/module/src/x86_64_ingrasys_s9280_64x_module.c b/packages/platforms/ingrasys/x86-64/s9280-64x/onlp/builds/x86_64_ingrasys_s9280_64x/module/src/x86_64_ingrasys_s9280_64x_module.c deleted file mode 100755 index db0b739a1..000000000 --- a/packages/platforms/ingrasys/x86-64/s9280-64x/onlp/builds/x86_64_ingrasys_s9280_64x/module/src/x86_64_ingrasys_s9280_64x_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 "x86_64_ingrasys_s9280_64x_log.h" - -static int -datatypes_init__(void) -{ -#define INGRYSYS_S9280_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_ingrasys_s9280_64x_module_init__(void) -{ - AIM_LOG_STRUCT_REGISTER(); - datatypes_init__(); -} - -int __onlp_platform_version__ = 1; diff --git a/packages/platforms/ingrasys/x86-64/s9280-64x/onlp/builds/x86_64_ingrasys_s9280_64x/module/src/x86_64_ingrasys_s9280_64x_ucli.c b/packages/platforms/ingrasys/x86-64/s9280-64x/onlp/builds/x86_64_ingrasys_s9280_64x/module/src/x86_64_ingrasys_s9280_64x_ucli.c deleted file mode 100755 index d5c177ff1..000000000 --- a/packages/platforms/ingrasys/x86-64/s9280-64x/onlp/builds/x86_64_ingrasys_s9280_64x/module/src/x86_64_ingrasys_s9280_64x_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 X86_64_INGRASYS_S9280_64X_CONFIG_INCLUDE_UCLI == 1 - -#include -#include -#include - -static ucli_status_t -x86_64_ingrasys_s9280_64x_ucli_ucli__config__(ucli_context_t* uc) -{ - UCLI_HANDLER_MACRO_MODULE_CONFIG(x86_64_ingrasys_s9280_64x) -} - -/* */ -/****************************************************************************** - * - * These handler table(s) were autogenerated from the symbols in this - * source file. - * - *****************************************************************************/ -static ucli_command_handler_f x86_64_ingrasys_s9280_64x_ucli_ucli_handlers__[] = -{ - x86_64_ingrasys_s9280_64x_ucli_ucli__config__, - NULL -}; -/******************************************************************************/ -/* */ - -static ucli_module_t -x86_64_ingrasys_s9280_64x_ucli_module__ = - { - "x86_64_ingrasys_s9280_64x_ucli", - NULL, - x86_64_ingrasys_s9280_64x_ucli_ucli_handlers__, - NULL, - NULL, - }; - -ucli_node_t* -x86_64_ingrasys_s9280_64x_ucli_node_create(void) -{ - ucli_node_t* n; - ucli_module_init(&x86_64_ingrasys_s9280_64x_ucli_module__); - n = ucli_node_create("x86_64_ingrasys_s9280_64x", NULL, &x86_64_ingrasys_s9280_64x_ucli_module__); - ucli_node_subnode_add(n, ucli_module_log_node_create("x86_64_ingrasys_s9280_64x")); - return n; -} - -#else -void* -x86_64_ingrasys_s9280_64x_ucli_node_create(void) -{ - return NULL; -} -#endif - diff --git a/packages/platforms/ingrasys/x86-64/s9280-64x/platform-config/Makefile b/packages/platforms/ingrasys/x86-64/s9280-64x/platform-config/Makefile deleted file mode 100755 index 003238cf6..000000000 --- a/packages/platforms/ingrasys/x86-64/s9280-64x/platform-config/Makefile +++ /dev/null @@ -1 +0,0 @@ -include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/ingrasys/x86-64/s9280-64x/platform-config/r0/Makefile b/packages/platforms/ingrasys/x86-64/s9280-64x/platform-config/r0/Makefile deleted file mode 100755 index 003238cf6..000000000 --- a/packages/platforms/ingrasys/x86-64/s9280-64x/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/ingrasys/x86-64/s9280-64x/platform-config/r0/PKG.yml b/packages/platforms/ingrasys/x86-64/s9280-64x/platform-config/r0/PKG.yml deleted file mode 100755 index 30eba878f..000000000 --- a/packages/platforms/ingrasys/x86-64/s9280-64x/platform-config/r0/PKG.yml +++ /dev/null @@ -1 +0,0 @@ -!include $ONL_TEMPLATES/platform-config-platform.yml ARCH=amd64 VENDOR=ingrasys BASENAME=x86-64-ingrasys-s9280-64x REVISION=r0 diff --git a/packages/platforms/ingrasys/x86-64/s9280-64x/platform-config/r0/src/lib/x86-64-ingrasys-s9280-64x-r0.yml b/packages/platforms/ingrasys/x86-64/s9280-64x/platform-config/r0/src/lib/x86-64-ingrasys-s9280-64x-r0.yml deleted file mode 100755 index 6d0c6c672..000000000 --- a/packages/platforms/ingrasys/x86-64/s9280-64x/platform-config/r0/src/lib/x86-64-ingrasys-s9280-64x-r0.yml +++ /dev/null @@ -1,30 +0,0 @@ ---- - -###################################################################### -# -# platform-config for x86-64-ingrasys-s9280-64x -# -###################################################################### - -x86-64-ingrasys-s9280-64x-r0: - - grub: - - serial: >- - --port=0x3f8 - --speed=115200 - --word=8 - --parity=no - --stop=1 - - kernel: - <<: *kernel-3-16 - - args: >- - console=ttyS0,115200n8 - - ##network - ## interfaces: - ## ma1: - ## name: ~ - ## syspath: pci0000:00/0000:00:03.0 diff --git a/packages/platforms/ingrasys/x86-64/s9280-64x/platform-config/r0/src/python/x86_64_ingrasys_s9280_64x_r0/__init__.py b/packages/platforms/ingrasys/x86-64/s9280-64x/platform-config/r0/src/python/x86_64_ingrasys_s9280_64x_r0/__init__.py deleted file mode 100755 index be877763b..000000000 --- a/packages/platforms/ingrasys/x86-64/s9280-64x/platform-config/r0/src/python/x86_64_ingrasys_s9280_64x_r0/__init__.py +++ /dev/null @@ -1,219 +0,0 @@ -from onl.platform.base import * -from onl.platform.ingrasys import * -import os -import sys - -def msg(s, fatal=False): - sys.stderr.write(s) - sys.stderr.flush() - if fatal: - sys.exit(1) - -class OnlPlatform_x86_64_ingrasys_s9280_64x_r0(OnlPlatformIngrasys): - PLATFORM='x86-64-ingrasys-s9280-64x-r0' - MODEL="S9280-64X" - SYS_OBJECT_ID=".9280.64" - - def baseconfig(self): - - # fp port to phy port mapping - fp2phy_array=( 0, 1, 4, 5, 8, 9, 12, 13, 16, 17, 20, 21, 24, 25, 28, 29, - 32, 33, 36, 37, 40, 41, 44, 45, 48, 49, 52, 53, 56, 57, 60, 61, - 2, 3, 6, 7, 10, 11, 14, 15, 18, 19, 22, 23, 26, 27, 30, 31, - 34, 35, 38, 39, 42, 43, 46, 47, 50, 51, 54, 55, 58, 59, 62, 63) - # fp port to led port mapping - fp2led_array=( 1, 2, 5, 6, 9, 10, 13, 14, 1, 2, 5, 6, 9, 10, 13, 14, - 1, 2, 5, 6, 9, 10, 13, 14, 1, 2, 5, 6, 9, 10, 13, 14, - 3, 4, 7, 8, 11, 12, 15, 16, 3, 4, 7, 8, 11, 12, 15, 16, - 3, 4, 7, 8, 11, 12, 15, 16, 3, 4, 7, 8, 11, 12, 15, 16) - - # vid to mac vdd value mapping - vdd_val_array=( 0.85, 0.82, 0.77, 0.87, 0.74, 0.84, 0.79, 0.89 ) - # vid to rov reg value mapping - rov_reg_array=( 0x79, 0x73, 0x69, 0x7D, 0x63, 0x77, 0x6D, 0x81 ) - - self.insmod("eeprom_mb") - # init SYS EEPROM devices - self.new_i2c_devices( - [ - # _i2c_mb_eeprom_init - ('mb_eeprom', 0x55, 0), - - # _i2c_cb_eeprom_init - ('mb_eeprom', 0x51, 0), - ] - ) - - os.system("modprobe w83795") - os.system("modprobe eeprom") - os.system("modprobe gpio_pca953x") - self.insmod("optoe") - - ########### initialize I2C bus 0 ########### - # init PCA9548 - self.new_i2c_devices( - [ - ('pca9548', 0x70, 0), #pca9548_0 - ('pca9548', 0x73, 0), #pca9548_1 - ('pca9546', 0x72, 0), #pca9546_0 - ('pca9548', 0x71, 19), #pca9548_2 - ('pca9546', 0x71, 20), #pca9546_1 - ('pca9548', 0x75, 0), #pca9548_11 - ('pca9548', 0x74, 21), #pca9548_3 - ('pca9548', 0x74, 22), #pca9548_4 - ('pca9548', 0x74, 23), #pca9548_5 - ('pca9548', 0x74, 24), #pca9548_6 - ('pca9548', 0x74, 25), #pca9548_7 - ('pca9548', 0x74, 26), #pca9548_8 - ('pca9548', 0x74, 27), #pca9548_9 - ('pca9548', 0x74, 28), #pca9548_10 - ] - ) - # _i2c_hwm_init - os.system("i2cset -y -r 16 0x2f 0x00 0x80") - os.system("i2cset -y -r 16 0x2f 0x01 0x9C") - os.system("i2cset -y -r 16 0x2f 0x04 0x00") - os.system("i2cset -y -r 16 0x2f 0x06 0xFF") - os.system("i2cset -y -r 16 0x2f 0x07 0x00") - os.system("i2cset -y -r 16 0x2f 0x01 0x1C") - os.system("i2cset -y -r 16 0x2f 0x00 0x82") - os.system("i2cset -y -r 16 0x2f 0x0F 0x00") - os.system("i2cset -y -r 16 0x2f 0x18 0x84") - os.system("i2cset -y -r 16 0x2f 0x19 0x84") - - # _i2c_io_exp_init - # need to init BMC io expander first due to some io expander are reset default - # Init BMC INT & HW ID IO Expander - os.system("i2cset -y -r 0 0x24 6 0xFF") - os.system("i2cset -y -r 0 0x24 7 0xFF") - os.system("i2cset -y -r 0 0x24 4 0x00") - os.system("i2cset -y -r 0 0x24 5 0x00") - - # Init BMC PSU status IO Expander - os.system("i2cset -y -r 0 0x25 2 0x00") - os.system("i2cset -y -r 0 0x25 3 0x00") - os.system("i2cset -y -r 0 0x25 6 0xDB") - os.system("i2cset -y -r 0 0x25 7 0xE3") - os.system("i2cset -y -r 0 0x25 4 0x00") - os.system("i2cset -y -r 0 0x25 5 0x00") - - # Init BMC RST and SEL IO Expander - os.system("i2cset -y -r 0 0x26 2 0x3F") - os.system("i2cset -y -r 0 0x26 3 0x1F") - os.system("i2cset -y -r 0 0x26 6 0xD0") - os.system("i2cset -y -r 0 0x26 7 0x00") - os.system("i2cset -y -r 0 0x26 4 0x00") - os.system("i2cset -y -r 0 0x26 5 0x00") - - # Init System LED & HW ID IO Expander - os.system("i2cset -y -r 10 0x76 2 0x00") - os.system("i2cset -y -r 10 0x76 6 0x00") - os.system("i2cset -y -r 10 0x76 7 0xFF") - os.system("i2cset -y -r 10 0x76 4 0x00") - os.system("i2cset -y -r 10 0x76 5 0x00") - - # Init FAN Board Status IO Expander - os.system("i2cset -y -r 0 0x20 2 0x11") - os.system("i2cset -y -r 0 0x20 3 0x11") - os.system("i2cset -y -r 0 0x20 6 0xCC") - os.system("i2cset -y -r 0 0x20 7 0xCC") - os.system("i2cset -y -r 0 0x20 4 0x00") - os.system("i2cset -y -r 0 0x20 5 0x00") - - # Init System SEL and RST IO Expander - os.system("i2cset -y -r 32 0x76 2 0x04") - os.system("i2cset -y -r 32 0x76 3 0xDF") - os.system("i2cset -y -r 32 0x76 6 0x09") - os.system("i2cset -y -r 32 0x76 7 0x3F") - os.system("i2cset -y -r 32 0x76 4 0x00") - os.system("i2cset -y -r 32 0x76 5 0x00") - - # _i2c_sensors_init - - self.new_i2c_devices( - [ - # w83795, hwmon1 - ('w83795adg', 0x2F, 16), - - # lm75_1 Rear Panel, hwmon2 - ('lm75', 0x4D, 6), - - # lm75_2 Rear MAC, hwmon3 - ('lm75', 0x4E, 6), - - # lm86 , hwmon4 - ('lm86', 0x4C, 6), - - # lm75_3 Front Panel, hwmon5 - ('lm75', 0x4D, 7), - - # lm75_4 Front MAC, hwmon6 - ('lm75', 0x4E, 7), - - # tmp75 BMC board thermal, hwmon7 - ('lm75', 0x4A, 16), - - # tmp75 CPU board thermal, hwmon8 - ('tmp75', 0x4F, 0), - ] - ) - - # hwmon9 - #os.system("modprobe jc42") - - # _i2c_cpld_init - - self.insmod("ingrasys_s9280_64x_i2c_cpld") - - # add cpld 1~5 to sysfs - for i in range(1, 6): - self.new_i2c_device('ingrasys_cpld%d' % i, 0x33, i) - - # _i2c_psu_init - - self.insmod("ingrasys_s9280_64x_psu") - - # add psu 1~2 to sysfs - for i in range(1, 3): - self.new_i2c_device('psu%d' % i, 0x50, 19-i) - - # _i2c_qsfp_eeprom_init - for i in range(1, 65): - phy_port = fp2phy_array[i-1] + 1 - port_group = (phy_port-1)/8 - eeprom_busbase = 41 + (port_group * 8) - eeprom_busshift = (phy_port-1)%8 - eeprom_bus = eeprom_busbase + eeprom_busshift - self.new_i2c_device('optoe1', 0x50, eeprom_bus) - - # _i2c_sfp_eeprom_init - for i in range(1, 3): - self.new_i2c_device('sff8436', 0x50, 28+i) - - # _mac_vdd_init - rov_status_file = open("/sys/bus/i2c/devices/1-0033/cpld_rov_status", "r") - reg_val_str = rov_status_file.read() - rov_status_file.close() - - reg_val = int(reg_val_str, 16) - vid = reg_val & 0x7 - mac_vdd_val = vdd_val_array[vid] - rov_reg = rov_reg_array[vid] - - msg("Setting mac vdd %1.2f with rov register value 0x%x\n" % (mac_vdd_val, rov_reg) ) - os.system("i2cset -y -r 15 0x76 0x21 0x%x w" % rov_reg) - - # _i2c_fan_speed_init - os.system("echo 120 > /sys/class/hwmon/hwmon1/device/pwm2") - - # _util_port_led_clear - os.system("i2cset -m 0x04 -y -r 32 0x76 2 0x00") - os.system("sleep 1") - os.system("i2cset -m 0x04 -y -r 32 0x76 2 0xFF") - - # turn on sys led - os.system("i2cset -m 0x80 -y -r 10 0x76 2 0x80") - - return True - - diff --git a/packages/platforms/inventec/Makefile b/packages/platforms/inventec/Makefile deleted file mode 100644 index 003238cf6..000000000 --- a/packages/platforms/inventec/Makefile +++ /dev/null @@ -1 +0,0 @@ -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 deleted file mode 100644 index 003238cf6..000000000 --- a/packages/platforms/inventec/vendor-config/Makefile +++ /dev/null @@ -1 +0,0 @@ -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 deleted file mode 100644 index 4afa2f7ce..000000000 --- a/packages/platforms/inventec/vendor-config/PKG.yml +++ /dev/null @@ -1 +0,0 @@ -!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 deleted file mode 100644 index 41f7a3e64..000000000 --- a/packages/platforms/inventec/vendor-config/src/python/inventec/__init__.py +++ /dev/null @@ -1,7 +0,0 @@ -#!/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 deleted file mode 100644 index 003238cf6..000000000 --- a/packages/platforms/inventec/x86-64/Makefile +++ /dev/null @@ -1 +0,0 @@ -include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/inventec/x86-64/d10056/Makefile b/packages/platforms/inventec/x86-64/d10056/Makefile deleted file mode 100644 index 003238cf6..000000000 --- a/packages/platforms/inventec/x86-64/d10056/Makefile +++ /dev/null @@ -1 +0,0 @@ -include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/inventec/x86-64/d10056/modules/Makefile b/packages/platforms/inventec/x86-64/d10056/modules/Makefile deleted file mode 100644 index 003238cf6..000000000 --- a/packages/platforms/inventec/x86-64/d10056/modules/Makefile +++ /dev/null @@ -1 +0,0 @@ -include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/inventec/x86-64/d10056/modules/PKG.yml b/packages/platforms/inventec/x86-64/d10056/modules/PKG.yml deleted file mode 100644 index 4a167ce23..000000000 --- a/packages/platforms/inventec/x86-64/d10056/modules/PKG.yml +++ /dev/null @@ -1 +0,0 @@ -!include $ONL_TEMPLATES/platform-modules.yml VENDOR=inventec BASENAME=x86-64-inventec-d10056 ARCH=amd64 KERNELS="onl-kernel-4.14-lts-x86-64-all:amd64" diff --git a/packages/platforms/inventec/x86-64/d10056/modules/builds/.gitignore b/packages/platforms/inventec/x86-64/d10056/modules/builds/.gitignore deleted file mode 100644 index a65b41774..000000000 --- a/packages/platforms/inventec/x86-64/d10056/modules/builds/.gitignore +++ /dev/null @@ -1 +0,0 @@ -lib diff --git a/packages/platforms/inventec/x86-64/d10056/modules/builds/Makefile b/packages/platforms/inventec/x86-64/d10056/modules/builds/Makefile deleted file mode 100644 index 8b26757f1..000000000 --- a/packages/platforms/inventec/x86-64/d10056/modules/builds/Makefile +++ /dev/null @@ -1,6 +0,0 @@ -KERNELS := onl-kernel-4.14-lts-x86-64-all:amd64 -KMODULES := src -VENDOR := inventec -BASENAME := x86-64-inventec-d10056 -ARCH := x86_64 -include $(ONL)/make/kmodule.mk diff --git a/packages/platforms/inventec/x86-64/d10056/modules/builds/src/Makefile b/packages/platforms/inventec/x86-64/d10056/modules/builds/src/Makefile deleted file mode 100644 index 02e6e94e6..000000000 --- a/packages/platforms/inventec/x86-64/d10056/modules/builds/src/Makefile +++ /dev/null @@ -1,12 +0,0 @@ -obj-m += gpio-ich.o -obj-m += i2c-gpio.o -obj-m += inv_cpld.o -obj-m += inv_platform.o -obj-m += inv_psoc.o - -obj-m += swps.o -swps-objs := inv_swps.o inv_mux.o io_expander.o transceiver.o - -obj-m += vpd.o -vpd-objs := inv_vpd.o onie_tlvinfo.o - diff --git a/packages/platforms/inventec/x86-64/d10056/modules/builds/src/gpio-ich.c b/packages/platforms/inventec/x86-64/d10056/modules/builds/src/gpio-ich.c deleted file mode 100644 index 3db7133c8..000000000 --- a/packages/platforms/inventec/x86-64/d10056/modules/builds/src/gpio-ich.c +++ /dev/null @@ -1,513 +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 -#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 = 0; /* Default: -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_get_direction(struct gpio_chip *gpio, unsigned nr) -{ - return ichx_read_bit(GPIO_IO_SEL, nr) ? GPIOF_DIR_IN : GPIOF_DIR_OUT; -} - -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->parent = &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->get_direction = ichx_gpio_get_direction; - 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 device *dev, - 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 (!devm_request_region(dev, - res_base->start + ichx_priv.desc->regs[0][i], - ichx_priv.desc->reglen[i], name)) - return -EBUSY; - } - return 0; -} - -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(&pdev->dev, 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 (!devm_request_region(&pdev->dev, 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_data(&ichx_priv.chip, NULL); - if (err) { - pr_err("Failed to register GPIOs\n"); - return 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; -} - -static int ichx_gpio_remove(struct platform_device *pdev) -{ - gpiochip_remove(&ichx_priv.chip); - - return 0; -} - -static struct platform_driver ichx_gpio_driver = { - .driver = { - .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/d10056/modules/builds/src/i2c-gpio.c b/packages/platforms/inventec/x86-64/d10056/modules/builds/src/i2c-gpio.c deleted file mode 100644 index 34cfc0ebd..000000000 --- a/packages/platforms/inventec/x86-64/d10056/modules/builds/src/i2c-gpio.c +++ /dev/null @@ -1,290 +0,0 @@ -/* - * Bitbanging I2C bus driver using the GPIO API - * - * Copyright (C) 2007 Atmel Corporation - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. - */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -struct i2c_gpio_private_data { - struct i2c_adapter adap; - struct i2c_algo_bit_data bit_data; - struct i2c_gpio_platform_data pdata; -}; - -/* Toggle SDA by changing the direction of the pin */ -static void i2c_gpio_setsda_dir(void *data, int state) -{ - struct i2c_gpio_platform_data *pdata = data; - - if (state) - gpio_direction_input(pdata->sda_pin); - else - gpio_direction_output(pdata->sda_pin, 0); -} - -/* - * Toggle SDA by changing the output value of the pin. This is only - * valid for pins configured as open drain (i.e. setting the value - * high effectively turns off the output driver.) - */ -static void i2c_gpio_setsda_val(void *data, int state) -{ - struct i2c_gpio_platform_data *pdata = data; - - gpio_set_value(pdata->sda_pin, state); -} - -/* Toggle SCL by changing the direction of the pin. */ -static void i2c_gpio_setscl_dir(void *data, int state) -{ - struct i2c_gpio_platform_data *pdata = data; - - if (state) - gpio_direction_input(pdata->scl_pin); - else - gpio_direction_output(pdata->scl_pin, 0); -} - -/* - * Toggle SCL by changing the output value of the pin. This is used - * for pins that are configured as open drain and for output-only - * pins. The latter case will break the i2c protocol, but it will - * often work in practice. - */ -static void i2c_gpio_setscl_val(void *data, int state) -{ - struct i2c_gpio_platform_data *pdata = data; - - gpio_set_value(pdata->scl_pin, state); -} - -static int i2c_gpio_getsda(void *data) -{ - struct i2c_gpio_platform_data *pdata = data; - - return gpio_get_value(pdata->sda_pin); -} - -static int i2c_gpio_getscl(void *data) -{ - struct i2c_gpio_platform_data *pdata = data; - - return gpio_get_value(pdata->scl_pin); -} - -static int of_i2c_gpio_get_pins(struct device_node *np, - unsigned int *sda_pin, unsigned int *scl_pin) -{ - if (of_gpio_count(np) < 2) - return -ENODEV; - - *sda_pin = of_get_gpio(np, 0); - *scl_pin = of_get_gpio(np, 1); - - if (*sda_pin == -EPROBE_DEFER || *scl_pin == -EPROBE_DEFER) - return -EPROBE_DEFER; - - if (!gpio_is_valid(*sda_pin) || !gpio_is_valid(*scl_pin)) { - pr_err("%s: invalid GPIO pins, sda=%d/scl=%d\n", - np->full_name, *sda_pin, *scl_pin); - return -ENODEV; - } - - return 0; -} - -static void of_i2c_gpio_get_props(struct device_node *np, - struct i2c_gpio_platform_data *pdata) -{ - u32 reg; - - of_property_read_u32(np, "i2c-gpio,delay-us", &pdata->udelay); - - if (!of_property_read_u32(np, "i2c-gpio,timeout-ms", ®)) - pdata->timeout = msecs_to_jiffies(reg); - - pdata->sda_is_open_drain = - of_property_read_bool(np, "i2c-gpio,sda-open-drain"); - pdata->scl_is_open_drain = - of_property_read_bool(np, "i2c-gpio,scl-open-drain"); - pdata->scl_is_output_only = - of_property_read_bool(np, "i2c-gpio,scl-output-only"); -} - -static int i2c_gpio_probe(struct platform_device *pdev) -{ - struct i2c_gpio_private_data *priv; - struct i2c_gpio_platform_data *pdata; - struct i2c_algo_bit_data *bit_data; - struct i2c_adapter *adap; - unsigned int sda_pin, scl_pin; - int ret; - - /* First get the GPIO pins; if it fails, we'll defer the probe. */ - if (pdev->dev.of_node) { - ret = of_i2c_gpio_get_pins(pdev->dev.of_node, - &sda_pin, &scl_pin); - if (ret) - return ret; - } else { - if (!dev_get_platdata(&pdev->dev)) - return -ENXIO; - pdata = dev_get_platdata(&pdev->dev); - sda_pin = pdata->sda_pin; - scl_pin = pdata->scl_pin; - } - - ret = devm_gpio_request(&pdev->dev, sda_pin, "sda"); - if (ret) { - if (ret == -EINVAL) - ret = -EPROBE_DEFER; /* Try again later */ - return ret; - } - ret = devm_gpio_request(&pdev->dev, scl_pin, "scl"); - if (ret) { - if (ret == -EINVAL) - ret = -EPROBE_DEFER; /* Try again later */ - return ret; - } - - priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL); - if (!priv) - return -ENOMEM; - adap = &priv->adap; - bit_data = &priv->bit_data; - pdata = &priv->pdata; - - if (pdev->dev.of_node) { - pdata->sda_pin = sda_pin; - pdata->scl_pin = scl_pin; - of_i2c_gpio_get_props(pdev->dev.of_node, pdata); - } else { - memcpy(pdata, dev_get_platdata(&pdev->dev), sizeof(*pdata)); - } - - if (pdata->sda_is_open_drain) { - gpio_direction_output(pdata->sda_pin, 1); - bit_data->setsda = i2c_gpio_setsda_val; - } else { - gpio_direction_input(pdata->sda_pin); - bit_data->setsda = i2c_gpio_setsda_dir; - } - - if (pdata->scl_is_open_drain || pdata->scl_is_output_only) { - gpio_direction_output(pdata->scl_pin, 1); - bit_data->setscl = i2c_gpio_setscl_val; - } else { - gpio_direction_input(pdata->scl_pin); - bit_data->setscl = i2c_gpio_setscl_dir; - } - - if (!pdata->scl_is_output_only) - bit_data->getscl = i2c_gpio_getscl; - bit_data->getsda = i2c_gpio_getsda; - - if (pdata->udelay) - bit_data->udelay = pdata->udelay; - else if (pdata->scl_is_output_only) - bit_data->udelay = 50; /* 10 kHz */ - else - bit_data->udelay = 5; /* 100 kHz */ - - if (pdata->timeout) - bit_data->timeout = pdata->timeout; - else - bit_data->timeout = HZ / 10; /* 100 ms */ - - bit_data->data = pdata; - - adap->owner = THIS_MODULE; - if (pdev->dev.of_node) - strlcpy(adap->name, dev_name(&pdev->dev), sizeof(adap->name)); - else - snprintf(adap->name, sizeof(adap->name), "i2c-gpio%d", pdev->id); - - adap->algo_data = bit_data; - adap->class = I2C_CLASS_HWMON | I2C_CLASS_SPD; - adap->dev.parent = &pdev->dev; - adap->dev.of_node = pdev->dev.of_node; - - adap->nr = pdev->id; - ret = i2c_bit_add_numbered_bus(adap); - if (ret) - return ret; - - platform_set_drvdata(pdev, priv); - - dev_info(&pdev->dev, "using pins %u (SDA) and %u (SCL%s)\n", - pdata->sda_pin, pdata->scl_pin, - pdata->scl_is_output_only - ? ", no clock stretching" : ""); - - return 0; -} - -static int i2c_gpio_remove(struct platform_device *pdev) -{ - struct i2c_gpio_private_data *priv; - struct i2c_adapter *adap; - - priv = platform_get_drvdata(pdev); - adap = &priv->adap; - - i2c_del_adapter(adap); - - return 0; -} - -#if defined(CONFIG_OF) -static const struct of_device_id i2c_gpio_dt_ids[] = { - { .compatible = "i2c-gpio", }, - { /* sentinel */ } -}; - -MODULE_DEVICE_TABLE(of, i2c_gpio_dt_ids); -#endif - -static struct platform_driver i2c_gpio_driver = { - .driver = { - .name = "i2c-gpio", - .of_match_table = of_match_ptr(i2c_gpio_dt_ids), - }, - .probe = i2c_gpio_probe, - .remove = i2c_gpio_remove, -}; - -static int __init i2c_gpio_init(void) -{ - int ret; - - ret = platform_driver_register(&i2c_gpio_driver); - if (ret) - printk(KERN_ERR "i2c-gpio: probe failed: %d\n", ret); - - return ret; -} -subsys_initcall(i2c_gpio_init); - -static void __exit i2c_gpio_exit(void) -{ - platform_driver_unregister(&i2c_gpio_driver); -} -module_exit(i2c_gpio_exit); - -MODULE_AUTHOR("Haavard Skinnemoen (Atmel)"); -MODULE_DESCRIPTION("Platform-independent bitbanging I2C driver"); -MODULE_LICENSE("GPL"); -MODULE_ALIAS("platform:i2c-gpio"); diff --git a/packages/platforms/inventec/x86-64/d10056/modules/builds/src/inv_cpld.c b/packages/platforms/inventec/x86-64/d10056/modules/builds/src/inv_cpld.c deleted file mode 100644 index c625391af..000000000 --- a/packages/platforms/inventec/x86-64/d10056/modules/builds/src/inv_cpld.c +++ /dev/null @@ -1,471 +0,0 @@ -/* - * 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 -#define CPLD_BIOSCS_OFFSET 0x04 - - -/* 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 ssize_t show_bios_cs(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_BIOSCS_OFFSET, 1); - - mutex_unlock(&data->update_lock); - - if(status != 1) return sprintf(buf, "read cpld BIOS_CS fail\n"); - - - status = sprintf (buf, "0x%X\n", b[0] & 0x01); - - return strlen(buf); -} - -static ssize_t set_bios_cs(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_BIOSCS_OFFSET, 1); - if(temp) byte |= 0x01; - else byte &= ~(0x01); - cpld_i2c_write(client, &byte, CPLD_BIOSCS_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 - "4 Hz", //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; - - 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 SENSOR_DEVICE_ATTR(bios_cs, S_IWUSR|S_IRUGO, show_bios_cs, set_bios_cs, 0); - -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, - - &sensor_dev_attr_bios_cs.dev_attr.attr, - - NULL -}; - -static const struct attribute_group cpld_group = { - .attrs = cpld_attributes, -}; - -static struct attribute *cpld2_attributes[] = { - //info - &sensor_dev_attr_info.dev_attr.attr, - - NULL -}; - -static const struct attribute_group cpld2_group = { - .attrs = cpld2_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 */ - if(id->driver_data==1) // CPLD2 - status = sysfs_create_group(&client->dev.kobj, &cpld2_group); - else // default CPLD1 - 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, }, - { "inv_cpld2", 1, }, - { /* 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/d10056/modules/builds/src/inv_mux.c b/packages/platforms/inventec/x86-64/d10056/modules/builds/src/inv_mux.c deleted file mode 100644 index 143aee309..000000000 --- a/packages/platforms/inventec/x86-64/d10056/modules/builds/src/inv_mux.c +++ /dev/null @@ -1,547 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include "io_expander.h" -#include "inv_mux.h" - -/* For build single module using (Ex: ONL platform) */ -#include -//#include -//#include - - -static struct mux_obj_s *mux_head_p = NULL; - -/* ========== MUX object functions ========== - */ -static int -_setup_i2c_value(struct mux_obj_s *self, int offset, int value){ - - return i2c_smbus_write_byte_data(self->i2c_client_p, offset, value); -} - - -static int -_setup_i2c_client(struct mux_obj_s *self, int chan_id, int addr){ - - struct i2c_adapter *adap = NULL; - char *emsg = "ERR"; - - adap = i2c_get_adapter(chan_id); - if (!adap){ - emsg = "can't get adapter"; - goto err_setup_i2c_client; - } - self->i2c_client_p = kzalloc(sizeof(*self->i2c_client_p), GFP_KERNEL); - if (!self->i2c_client_p){ - emsg = "can't kzalloc client"; - goto err_setup_i2c_client; - } - self->i2c_client_p->adapter = adap; - self->i2c_client_p->addr = addr; - return 0; - -err_setup_i2c_client: - SWPS_ERR("%s: %s\n", __func__, emsg); - return ERR_MUX_UNEXCPT; -} - - -int -_common_force_pull_gpio(int mem_addr, - int input, - int bit_offset){ - - unsigned int val = 0; - unsigned int targ = 0; - - /* Get current value */ - val = inl(mem_addr); - if (val == 0) { - SWPS_ERR("%s: inl:%d fail!\n", __func__, val); - return -1; - } - /* Count target value */ - switch (input) { - case 0: /* Pull Low */ - targ = (val & (~(1 << bit_offset))); - break; - case 1: /* Pull high */ - targ = (val | (1 << bit_offset)); - break; - default: - SWPS_ERR("%s: input state:%d incorrect!\n", - __func__, input); - return -1; - } - /* Setup gpio */ - outl(targ, mem_addr); - if (targ != inl(mem_addr)){ - SWPS_ERR("%s: outl:%d fail!\n", __func__, targ); - return -1; - } - SWPS_DEBUG("%s: done.\n", __func__); - return 0; -} - - -int -rangeley_force_pull_high(struct mux_obj_s *self){ - SWPS_ERR("%s: not ready!\n", __func__); - return -1; -} - - -int -rangeley_force_pull_low(struct mux_obj_s *self){ - SWPS_ERR("%s: not ready!\n", __func__); - return -1; -} - - -int -hedera_force_pull_high(struct mux_obj_s *self){ - return _common_force_pull_gpio(MUX_RST_MEM_ADDR_HEDERA, 1, 5); -} - - -int -hedera_force_pull_low(struct mux_obj_s *self){ - return _common_force_pull_gpio(MUX_RST_MEM_ADDR_HEDERA, 0, 5); -} - - -int -normal_gpio_pull_high(struct mux_obj_s *self){ - return gpio_direction_output(self->gpio_num, 1); -} - - -int -normal_gpio_pull_low(struct mux_obj_s *self){ - return gpio_direction_output(self->gpio_num, 0); -} - - -int -cpld_rst_all_4_pull_low(struct mux_obj_s *self){ - - char *emsg = "ERR"; - int err = ERR_MUX_UNEXCPT; - - switch(self->gpio_num) { - case MUX_RST_CPLD_C0_A77_70_74_RST_ALL: - goto setlow_cpld_rst_all_4_c0_a77_70_74_rst_all; - - default: - break; - } - emsg = "Undefined case"; - goto err_cpld_rst_all_4_pull_low; - -setlow_cpld_rst_all_4_c0_a77_70_74_rst_all: - err = _setup_i2c_value(self, 0x70, 0x0); - if (err < 0) { - emsg = "setup 0x70 fail"; - goto err_cpld_rst_all_4_pull_low; - } - err = _setup_i2c_value(self, 0x74, 0x01); - if (err < 0) { - emsg = "setup 0x74 fail"; - goto err_cpld_rst_all_4_pull_low; - } - return 0; - -err_cpld_rst_all_4_pull_low: - SWPS_INFO("%s: %s :%d :%d\n", - __func__, emsg, self->gpio_num, err); - return ERR_MUX_UNEXCPT; -} - - -int -cpld_rst_all_4_pull_high(struct mux_obj_s *self){ - - char *emsg = "ERR"; - int err = ERR_MUX_UNEXCPT; - - switch(self->gpio_num) { - case MUX_RST_CPLD_C0_A77_70_74_RST_ALL: - goto sethigh_cpld_rst_all_4_c0_a77_70_74_rst_all; - - default: - break; - } - emsg = "Undefined case"; - goto err_cpld_rst_all_4_pull_high; - -sethigh_cpld_rst_all_4_c0_a77_70_74_rst_all: - err = _setup_i2c_value(self, 0x70, 0xfe); - if (err < 0) { - emsg = "setup 0x70 fail"; - goto err_cpld_rst_all_4_pull_high; - } - err = _setup_i2c_value(self, 0x74, 0x03); - if (err < 0) { - emsg = "setup 0x74 fail"; - goto err_cpld_rst_all_4_pull_high; - } - return 0; - -err_cpld_rst_all_4_pull_high: - SWPS_INFO("%s: %s :%d :%d\n", - __func__, emsg, self->gpio_num, err); - return ERR_MUX_UNEXCPT; -} - - -int -pca9548_reset_mux_all(struct mux_obj_s *self){ - /* [Note] Power-on reset (PCA9548A-NXP) - * When power is applied to VDD, an internal Power-On Reset (POR) - * holds the PCA9548A in a reset condition until VDD has reached - * VPOR. At this point, the reset condition is released and the - * PCA9548A register and I2C-bus state machine are initialized to - * their default states (all zeroes) causing all the channels to - * be deselected. Thereafter, VDD must be lowered below 0.2 V for - * at least 5 us in order to reset the device. - */ - if (self->_pull_low(self) < 0) { - SWPS_ERR("%s: _pull_low fail!\n", __func__); - return -1; - } - mdelay(MUX_RST_WAIT_MS_PCA9548); - if (self->_pull_high(self) < 0) { - SWPS_ERR("%s: _pull_high fail!\n", __func__); - return -1; - } - mdelay(MUX_RST_WAIT_MS_PCA9548); - return 0; -} - - -int -cpld_reset_mux_all(struct mux_obj_s *self){ - - char *emsg = "ERR"; - int err = ERR_MUX_UNEXCPT; - - switch(self->gpio_num) { - case MUX_RST_CPLD_C0_A77_70_74_RST_ALL: - goto reset_cpld_rst_all_4_c0_a77_70_74_rst_all; - - default: - break; - } - emsg = "Undefined case"; - goto err_cpld_reset_mux_all; - -reset_cpld_rst_all_4_c0_a77_70_74_rst_all: - if (self->_pull_low(self) < 0) { - emsg = "_pull_low fail"; - goto err_cpld_reset_mux_all; - } - mdelay(MUX_RST_WAIT_MS_CPLD); - return 0; - -err_cpld_reset_mux_all: - SWPS_INFO("%s: %s :%d :%d\n", - __func__, emsg, self->gpio_num, err); - return ERR_MUX_UNEXCPT; -} - - -int -common_reset_mux_all(struct mux_obj_s *self){ - SWPS_ERR("%s: not ready!\n", __func__); - return -1; -} - - -int -init_gpio_4_force(struct mux_obj_s *self){ - - if (self->_pull_high(self) < 0) { - SWPS_ERR("%s: setup default fail!\n", __func__); - return -1; - } - return 0; -} - - -int -init_gpio_4_normal(struct mux_obj_s *self){ - - int err = 0; - char *emsg = "ERR"; - - if (!gpio_is_valid(self->gpio_num)) { - emsg = "GPIO invalid"; - goto err_init_gpio_4_normal; - } - err = gpio_request(self->gpio_num, MUX_GPIO_LABEL); - if (err < 0) { - emsg = "gpio_request fail"; - goto err_init_gpio_4_normal; - } - err = self->_pull_high(self); - if (err < 0) { - emsg = "setup default fail"; - goto err_init_gpio_4_normal; - } - SWPS_DEBUG("%s: gpio_request:%d ok.\n", __func__, self->gpio_num); - return 0; - -err_init_gpio_4_normal: - SWPS_ERR("%s: %s :%d :%d\n", - __func__, emsg, self->gpio_num, err); - return -1; -} - - -int -init_cpld_4_rst_all(struct mux_obj_s *self){ - - char *emsg = "ERR"; - int err = ERR_MUX_UNEXCPT; - int chan = ERR_MUX_UNEXCPT; - int addr = ERR_MUX_UNEXCPT; - - switch(self->gpio_num) { - case MUX_RST_CPLD_C0_A77_70_74_RST_ALL: - goto init_cpld_i2c_c0_a77_70_74_rst_all; - - default: - break; - } - emsg = "Undefined case"; - goto err_init_cpld_4_rst_all; - -init_cpld_i2c_c0_a77_70_74_rst_all: - chan = 0; - addr = 0x77; - err = _setup_i2c_client(self, chan, addr); - if (err < 0) { - emsg = "_setup_i2c_client fail"; - goto err_init_cpld_4_rst_all; - } - err = self->_pull_high(self); - if (err < 0) { - emsg = "setup default value fail"; - goto err_init_cpld_4_rst_all; - } - SWPS_DEBUG("%s: init_cpld_i2c_c0_a77_70_74_rst_all ok", __func__); - return 0; - -err_init_cpld_4_rst_all: - SWPS_INFO("%s: %s :%d :%d\n", - __func__, emsg, self->gpio_num, err); - return ERR_MUX_UNEXCPT; -} - - -int -clean_gpio_4_common(struct mux_obj_s *self){ - - if (!self) return 0; - if (!gpio_is_valid(self->gpio_num)) return 0; - self->_pull_high(self); - gpio_free(mux_head_p->gpio_num); - return 0; -} - - -int -clean_cpld_4_rst_all(struct mux_obj_s *self){ - - if (!self) return 0; - self->_pull_high(self); - if (self->i2c_client_p) { - i2c_put_adapter(self->i2c_client_p->adapter); - kfree(self->i2c_client_p); - } - return 0; -} - - -static int -_setup_muxctl_cb(struct mux_obj_s *self, - unsigned gpio){ - - char mod_dsc[32] = "ERR"; - - switch (gpio) { - case MUX_RST_GPIO_FORCE_RANGELEY: - self->gpio_num = gpio; - self->_pull_low = rangeley_force_pull_low; - self->_pull_high = rangeley_force_pull_high; - self->_init = init_gpio_4_force; - self->_clean = clean_gpio_4_common; - self->reset = pca9548_reset_mux_all; - memset(mod_dsc, 0, 32); - snprintf(mod_dsc, 31, "Rangeley force mode"); - goto ok_setup_muxctl_cb; - - case MUX_RST_GPIO_FORCE_HEDERA: - self->gpio_num = gpio; - self->_pull_low = hedera_force_pull_low; - self->_pull_high = hedera_force_pull_high; - self->_init = init_gpio_4_force; - self->_clean = clean_gpio_4_common; - self->reset = pca9548_reset_mux_all; - memset(mod_dsc, 0, 32); - snprintf(mod_dsc, 31, "Hedera force mode"); - goto ok_setup_muxctl_cb; - - case MUX_RST_GPIO_48_PCA9548: - case MUX_RST_GPIO_69_PCA9548: - case MUX_RST_GPIO_249_PCA9548: - case MUX_RST_GPIO_500_PCA9548: - case MUX_RST_GPIO_505_PCA9548: - self->gpio_num = gpio; - self->_pull_low = normal_gpio_pull_low; - self->_pull_high = normal_gpio_pull_high; - self->_init = init_gpio_4_normal; - self->_clean = clean_gpio_4_common; - self->reset = pca9548_reset_mux_all; - memset(mod_dsc, 0, 32); - snprintf(mod_dsc, 31, "Normal mode :%d", (int)gpio); - goto ok_setup_muxctl_cb; - - case MUX_RST_CPLD_C0_A77_70_74_RST_ALL: - self->gpio_num = gpio; - self->_pull_low = cpld_rst_all_4_pull_low; - self->_pull_high = cpld_rst_all_4_pull_high; - self->_init = init_cpld_4_rst_all; - self->_clean = clean_cpld_4_rst_all; - self->reset = cpld_reset_mux_all; - memset(mod_dsc, 0, 32); - snprintf(mod_dsc, 31, "CPLD mode :%d", (int)gpio); - goto ok_setup_muxctl_cb; - - default: - break; - } - SWPS_ERR("%s: Unexpected GPIO:%d\n", __func__, gpio); - return -1; - -ok_setup_muxctl_cb: - SWPS_INFO("muxctl: %s.\n", mod_dsc); - return 0; -} - - -/* ========== MUX public functions ========== - */ -void -clean_mux_objs(void){ - - struct mux_obj_s *curr_p = mux_head_p; - struct mux_obj_s *next_p = NULL; - - if (!curr_p) { - SWPS_DEBUG("%s: mux_head_p is NULL\n", __func__); - return; - } - while (curr_p) { - next_p = curr_p->next; - curr_p->_clean(curr_p); - kfree(curr_p); - curr_p = next_p; - } - SWPS_DEBUG("%s: done.\n", __func__); -} -EXPORT_SYMBOL(clean_mux_objs); - - -int -reset_mux_objs(void){ - - if (!mux_head_p) { - SWPS_ERR("%s: MUX ctl object doesn't exist!\n", __func__); - return -1; - } - if (mux_head_p->reset(mux_head_p) < 0){ - SWPS_ERR("%s: reset fail!\n", __func__); - return -1; - } - return 0; -} -EXPORT_SYMBOL(reset_mux_objs); - - -struct mux_obj_s * -_create_mux_obj(unsigned gpio){ - - char *emsg = "ERR"; - struct mux_obj_s *obj_p = NULL; - - obj_p = kzalloc(sizeof(struct mux_obj_s), GFP_KERNEL); - if (!obj_p) { - emsg = "kzalloc fail!"; - goto err_create_mux_obj_1; - } - if (_setup_muxctl_cb(obj_p, gpio) < 0){ - emsg = "_setup_muxctl_cb fail!"; - goto err_create_mux_obj_2; - } - if (obj_p->_init(obj_p) < 0) { - emsg = "_init() fail!"; - goto err_create_mux_obj_2; - } - SWPS_DEBUG("%s: created MUX object :%d\n", __func__, gpio); - return obj_p; - -err_create_mux_obj_2: - kfree(obj_p); -err_create_mux_obj_1: - SWPS_ERR("%s: %s :%d\n", __func__, emsg, gpio); - return NULL; -} - - -int -init_mux_objs(unsigned gpio){ - - struct mux_obj_s *curr_p = NULL; - char *emsg = "ERR"; - - /* Create MUX control object */ - if (mux_head_p) { - SWPS_DEBUG("%s: mux_head_p is not NULL!\n", __func__); - clean_mux_objs(); - } - /* Currently, it is using single muxctl architecture. - * In the future, it may use the multi-muxctl. - * (Ex: Gulmohar's advance I2C control / Peony's reset single mux) - */ - curr_p = _create_mux_obj(gpio); - if (!curr_p) { - emsg = "_create_mux_obj fail"; - goto err_init_mux_objs; - } - curr_p->next = NULL; - mux_head_p = curr_p; - SWPS_DEBUG("%s: all done. :%d\n", __func__, gpio); - return 0; - -err_init_mux_objs: - clean_mux_objs(); - SWPS_ERR("%s: %s\n", __func__, emsg); - return -1; -} -EXPORT_SYMBOL(init_mux_objs); - - -/* For single ko module - * => You need to declare MODULE_LICENSE If you want to build single module along. - * => Ex: For ONL platform - */ -MODULE_LICENSE("GPL"); - - - - diff --git a/packages/platforms/inventec/x86-64/d10056/modules/builds/src/inv_mux.h b/packages/platforms/inventec/x86-64/d10056/modules/builds/src/inv_mux.h deleted file mode 100644 index a913b24c6..000000000 --- a/packages/platforms/inventec/x86-64/d10056/modules/builds/src/inv_mux.h +++ /dev/null @@ -1,51 +0,0 @@ -#ifndef INV_MUX_H -#define INV_MUX_H - -#include - -/* MUX basic information */ -#define MUX_GPIO_LABEL "SWPS_RST_MUX" - -/* MUX reset GPIO define */ -#define MUX_RST_GPIO_FORCE (30100) -#define MUX_RST_GPIO_FORCE_RANGELEY (30101) -#define MUX_RST_GPIO_FORCE_HEDERA (30102) -#define MUX_RST_GPIO_48_PCA9548 (48) -#define MUX_RST_GPIO_69_PCA9548 (69) -#define MUX_RST_GPIO_249_PCA9548 (249) -#define MUX_RST_GPIO_500_PCA9548 (500) -#define MUX_RST_GPIO_505_PCA9548 (505) -#define MUX_RST_CPLD_C0_A77_70_74_RST_ALL (30201) - -/* MUX relate value define */ -#define MUX_RST_WAIT_MS_PCA9548 (1) -#define MUX_RST_WAIT_MS_CPLD (10) -#define MUX_RST_MEM_ADDR_RANGELEY (0) // TBD -#define MUX_RST_MEM_ADDR_HEDERA (0x548) - -/* MUX error code define */ -#define ERR_MUX_UNEXCPT (-399) - -struct mux_obj_s { - struct i2c_client *i2c_client_p; - struct mux_obj_s *next; - unsigned gpio_num; - int (*_pull_high)(struct mux_obj_s *self); - int (*_pull_low)(struct mux_obj_s *self); - int (*_init)(struct mux_obj_s *self); - int (*_clean)(struct mux_obj_s *self); - int (*reset)(struct mux_obj_s *self); -}; - - -void clean_mux_objs(void); -int reset_mux_objs(void); -int init_mux_objs(unsigned gpio); - - -#endif /* INV_MUX_H */ - - - - - diff --git a/packages/platforms/inventec/x86-64/d10056/modules/builds/src/inv_platform.c b/packages/platforms/inventec/x86-64/d10056/modules/builds/src/inv_platform.c deleted file mode 100644 index 8e5d6059f..000000000 --- a/packages/platforms/inventec/x86-64/d10056/modules/builds/src/inv_platform.c +++ /dev/null @@ -1,223 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include - -#define GPIO_BASE 0 // in kernel 4.x GPIO_BASE =0 ; in kernel 3.16.x , GPIO_BASE=180 - -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_cpld", 0, 0x77, 0, 0, 0},//cpld - {"pca9548", 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 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[] = { - {bus_id(1), ARRAY_SIZE(i2c_device_info0), i2c_device_info0 }, //mux root - - {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 -}; - -///////////////////////////////////////////////////////////////////////////////////////// -static struct platform_device *device_i2c_gpio0; -static struct i2c_gpio_platform_data i2c_gpio_platdata0 = { - .scl_pin = GPIO_BASE + 58, - .sda_pin = GPIO_BASE + 75, - - .udelay = 5, //5:100kHz - .sda_is_open_drain = 0, - .scl_is_open_drain = 0, - .scl_is_output_only = 0 -}; - -static int __init inv_platform_init(void) -{ - struct i2c_adapter *adap = NULL; - struct i2c_client *e = NULL; - int ret = 0; - int i,j,k; - - //printk("%s \n", __func__); - - //use i2c-gpio - //register i2c gpio - //config gpio58,75 to gpio function 58=32+3*8+2 75=32*2+8*1+3 gpio69=32*2+8*0+5 - outl( inl(0x533) | (1<<2), 0x533); //i2c-gpio sdl (GPIO58) - outl( inl(0x541) | (1<<3), 0x541); //i2c-gpio sda (GPIO75) - outl( inl(0x540) | (1<<5), 0x540); //RST_I2C_MUX_N (GPIO69) - outl( inl(0x500) | (1<<7), 0x500); //SYS_RDY_N (GPIO7) - outl( inl(0x501) | (1<<7), 0x501); //BMC_HEART_BEAT (GPIO15) - outl( inl(0x503) | (1<<2)|(1<<3), 0x503); //PSOC_HEART_BEAT(26),CPLD_HEART_BEAT(27) - - device_i2c_gpio0 = platform_device_alloc("i2c-gpio", 1); - if (!device_i2c_gpio0) { - printk(KERN_ERR "i2c-gpio: platform_device_alloc fail\n"); - return -ENOMEM; - } - device_i2c_gpio0->name = "i2c-gpio"; - device_i2c_gpio0->id = 1; - device_i2c_gpio0->dev.platform_data = &i2c_gpio_platdata0; - - ret = platform_device_add(device_i2c_gpio0); - if (ret) { - printk(KERN_ERR "i2c-gpio: platform_device_add fail %d\n", ret); - } - - for(i=0; idev.platform_data = NULL; - platform_device_unregister(device_i2c_gpio0); -} - -module_init(inv_platform_init); -module_exit(inv_platform_exit); - -MODULE_AUTHOR("Inventec"); -MODULE_DESCRIPTION("Platform devices"); -MODULE_LICENSE("GPL"); diff --git a/packages/platforms/inventec/x86-64/d10056/modules/builds/src/inv_psoc.c b/packages/platforms/inventec/x86-64/d10056/modules/builds/src/inv_psoc.c deleted file mode 100644 index a0a817a99..000000000 --- a/packages/platforms/inventec/x86-64/d10056/modules/builds/src/inv_psoc.c +++ /dev/null @@ -1,995 +0,0 @@ -/* - * 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 -#include -#include -#include -#include -#define SWITCH_TEMPERATURE_SOCK "/proc/switch/temp" -#define PSOC_POLLING_PERIOD 1000 - -#include -#include -#include -#include - -#define IPMI_MAX_INTF (4) -#define NETFN_OEM 0x30 -#define CMD_GETDATA 0x31 -#define CMD_SETDATA 0x32 -#define FAN_NUM 4 -#define PSU_NUM 2 - -#define FAN_CLEI_SUPPORT 1 -#define PSU_CLEI_SUPPORT 0 - -#define PSU1 0x5800 -#define PSU2 0x5900 -#define BMC_PMBusNumber 3 -#define PMBus_Vendor 0x99 -#define PMBus_Serial 0x9E -#define PMBus_Temp2 0x8E -#define PMBus_Version 0x9B -#define MaxLeng_Result 0x40 - -#define BMC_FanCLEIBusNumber 9 -#define DEVICE_CLEI_ADDR 0x52,0x53,0x54,0x55,0x56,0x50,0x51 - -#define MAX_IPMI_RECV_LENGTH 0xff -static char CLEI_ADDR[]={DEVICE_CLEI_ADDR}; -struct task_struct *kthread_auto_update; -static long pmbus_reg2data_linear(int data, int linear16); -struct ipmi_result{ - char result[MAX_IPMI_RECV_LENGTH]; - int result_length; -}; - -DEFINE_MUTEX(ipmi_mutex); -DEFINE_MUTEX(ipmi2_mutex); -static struct ipmi_result ipmiresult; -static struct device *hwmon_dev; -static struct kobject *device_kobj; -static ipmi_user_t ipmi_mh_user = NULL; -static void msg_handler(struct ipmi_recv_msg *msg,void* handler_data); -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 -}; - -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__)) clei { - u8 issue_number[3]; - u8 abbreviation_number[9]; - u8 fc_number[10]; - u8 clei_code[10]; - u8 product_year_and_month[5]; - u8 label_location_code[2]; - u8 serial_number[5]; - u8 pcb_revision[5]; - u8 vendor_name[10]; - u8 reserved[5]; -}; - -struct __attribute__ ((__packed__)) psoc_layout { - u8 ctl; //offset: 0 - u16 switch_temp; //offset: 1 - - // BYTE[03:20] - voltage - u16 voltage[15]; //offset: 0x03-0x20 - - // BYTE[21:27] - ExtFan - u8 led_ctl2; //offset: 21 - u8 ext_pwm; //offset: 22 - u16 ext_rpm[2]; //offset: 23 - u8 gpi_fan2; //offset: 27 - - //gpo - u8 led_ctl; //offset: 28 - - u8 gpio; //offset: 29 - - //pwm duty - u8 pwm[4]; //offset: 2a - u8 pwm_psu[2]; //offset: 2e - - //fan rpm - u16 fan[4*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[2]; //offset: 50 - - //version - u8 version[2]; //offset: 54 - - u8 reserve2[4]; //offset: 56 - 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) -#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) - -#define PWM2_OFFSET PSOC_OFF(ext_pwm) -#define RPM2_OFFSET PSOC_OFF(ext_rpm) -#define FAN_LED2_OFFSET PSOC_OFF(led_ctl2) -#define FAN_GPI2_OFFSET PSOC_OFF(gpi_fan2) - -#define CLEI_OFF(m) offsetof(struct clei, m) -#define FAN1_CLEI_INDEX 0 -#define FAN2_CLEI_INDEX 1 -#define FAN3_CLEI_INDEX 2 -#define FAN4_CLEI_INDEX 3 -#define FAN5_CLEI_INDEX 4 -#define PSU1_CLEI_INDEX 5 -#define PSU2_CLEI_INDEX 6 - -static void msg_handler(struct ipmi_recv_msg *recv_msg,void* handler_data) -{ - struct ipmi_result *msg_result = recv_msg->user_msg_data; - - if(recv_msg->msg.data[0]==0 && recv_msg->msg.data_len>0) { - msg_result->result_length=recv_msg->msg.data_len-1; - memcpy(msg_result->result, &recv_msg->msg.data[1], recv_msg->msg.data_len-1); - } - ipmi_free_recv_msg(recv_msg); - mutex_unlock(&ipmi_mutex); - - return; -} - -int start_ipmi_command(char NetFn, char cmd,char *data,int data_length, char* result, int* result_length) -{ - int rv=0,i; - int timeout; - - //wait previous command finish at least 50msec - timeout=50; - while((mutex_is_locked(&ipmi_mutex) == 1 || (mutex_is_locked(&ipmi2_mutex) == 1)) && (--timeout)>0) { usleep_range(1000,1010); } - if(timeout==0) { return -1; } - mutex_lock(&ipmi_mutex); - mutex_lock(&ipmi2_mutex); - - if(ipmi_mh_user == NULL) { - for (i=0,rv=1; i0) { usleep_range(1000,1100);} - if(timeout==0) { - mutex_unlock(&ipmi2_mutex); - return -1; - } - else { - *result_length=ipmiresult.result_length; - memcpy(result,ipmiresult.result,*result_length); - mutex_unlock(&ipmi2_mutex); - return 0; - } - } - return 0; -} -EXPORT_SYMBOL(start_ipmi_command); - -static ssize_t psoc_ipmi_read(u8 *buf, u8 offset, size_t count) -{ - uint8_t data[2]; - int result_len=0; - int rv; - - data[0] = offset; - data[1] = count; - - rv=start_ipmi_command(NETFN_OEM, CMD_GETDATA,data,2, buf, &result_len); - - return result_len; -} - -static ssize_t psoc_ipmi_write(char *buf, unsigned offset, size_t count) -{ - uint8_t data[count+1],result[1]; - int result_len; - - data[0] = offset; - memcpy(&data[1],buf,count); - - start_ipmi_command(NETFN_OEM, CMD_SETDATA,data,count+1, result, &result_len); - return count; -} - - -static u16 psoc_read16(u8 offset) -{ - u16 value = 0; - u8 buf[]={0,0}; - - if(psoc_ipmi_read(buf, offset, 2) == 2) - value = (buf[0]<<8 | buf[1]<<0); - - return value; -} - -static u8 psoc_read8(u8 offset) -{ - u8 value = 0; - u8 buf = 0; - - if(psoc_ipmi_read(&buf, offset, 1) == 1) - value = buf; - - return value; -} - -/* -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=0; - struct sensor_device_attribute *attr = to_sensor_dev_attr(da); - u8 byte=0; - int shift = (attr->index == 0)?3:0; - - status = psoc_ipmi_read(&byte, PSOC_PSU_OFFSET, 1); - - byte = (byte >> shift) & 0x7; - - status = sprintf (buf, "%d : %s\n", byte, psu_str[byte]); - - return strlen(buf); -} - -static ssize_t show_ipmi_pmbus(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=0; - - data[0] = BMC_PMBusNumber; - 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(start_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_clei(struct device *dev, struct device_attribute *da, - char *buf) -{ - struct sensor_device_attribute *attr = to_sensor_dev_attr(da); - u8 device_index = attr->index & 0xFF; - - uint8_t data[5],result[MaxLeng_Result]; - int result_len=0; - - data[0] = (device_index<=FAN5_CLEI_INDEX) ? BMC_FanCLEIBusNumber:BMC_PMBusNumber; - data[1] = CLEI_ADDR[device_index]<<1; - data[2] = sizeof(struct clei); - data[3] = (device_index<=FAN5_CLEI_INDEX) ? 0x00 : 0x01; //PSU CLEI will start from 0x0100 - data[4] = 0; - - if(start_ipmi_command(0x06, 0x52,data,5, result, &result_len)==0) - { - if(result_len < sizeof(struct clei)) memset(result, 0, sizeof(struct clei)); - sprintf (buf, "Issue Number: %.3s\n", &result[CLEI_OFF(issue_number)]); - sprintf (buf, "%sAbbreviation Number: %.9s\n", buf, &result[CLEI_OFF(abbreviation_number)]); - sprintf (buf, "%sFC Number: %.10s\n", buf, &result[CLEI_OFF(fc_number)]); - sprintf (buf, "%sCLEI Code: %.10s\n", buf, &result[CLEI_OFF(clei_code)]); - sprintf (buf, "%sProduct Year and Month: %.5s\n", buf, &result[CLEI_OFF(product_year_and_month)]); - sprintf (buf, "%s2D Label Location Code: %.2s\n", buf, &result[CLEI_OFF(label_location_code)]); - sprintf (buf, "%sSerial Number: %.5s\n", buf, &result[CLEI_OFF(serial_number)]); - sprintf (buf, "%sPCB Revision: %.5s\n", buf, &result[CLEI_OFF(pcb_revision)]); - sprintf (buf, "%sVendor Name: %.10s\n", buf, &result[CLEI_OFF(vendor_name)]); - return strlen(buf); - } - else - { - return sprintf(buf, "NONE\n"); - } -} - -static ssize_t show_thermal(struct device *dev, struct device_attribute *da, - char *buf) -{ - int status=0; - struct sensor_device_attribute *attr = to_sensor_dev_attr(da); - u8 offset = attr->index * 2 + THERMAL_OFFSET; - - status = psoc_read16(offset); - - 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=0; - struct sensor_device_attribute *attr = to_sensor_dev_attr(da); - u8 offset = attr->index; - - status = psoc_read8(offset); - - return sprintf(buf, "%d\n", - status); -} - -static ssize_t set_pwm(struct device *dev, - struct device_attribute *da, - const char *buf, size_t count) -{ - struct sensor_device_attribute *attr = to_sensor_dev_attr(da); - u8 offset = attr->index; - u8 pwm = simple_strtol(buf, NULL, 10); - if(pwm > 255) pwm = 255; - psoc_ipmi_write(&pwm, offset, 1); - - return count; -} - - -static ssize_t show_rpm(struct device *dev, struct device_attribute *da, - char *buf) -{ - int status=0; - struct sensor_device_attribute *attr = to_sensor_dev_attr(da); - u8 offset = attr->index; - status = psoc_read16(offset); - - return sprintf(buf, "%d\n", - status); -} - -static ssize_t show_switch_tmp(struct device *dev, struct device_attribute *da, - char *buf) -{ - u16 status=0; - u16 temp = 0; - - status = psoc_ipmi_read((u8*)&temp, SWITCH_TMP_OFFSET, 2); - - 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) -{ - long temp = simple_strtol(buf, NULL, 10); - u16 temp2 = ( (temp/1000) <<8 ) & 0xFF00 ; - - psoc_ipmi_write((u8*)&temp2, SWITCH_TMP_OFFSET, 2); - - - return count; -} - -static ssize_t show_diag(struct device *dev, struct device_attribute *da, - char *buf) -{ - u16 status=0; - u8 diag_flag = 0; - - status = psoc_ipmi_read((u8*)&diag_flag, DIAG_FLAG_OFFSET, 1); - - status = sprintf (buf, "%d\n", ((diag_flag & 0x80)?1:0)); - - return strlen(buf); -} - -static ssize_t set_diag(struct device *dev, - struct device_attribute *devattr, - const char *buf, size_t count) -{ - u8 value = 0; - u8 diag = simple_strtol(buf, NULL, 10); - - diag = diag?1:0; - - psoc_ipmi_read((u8*)&value, DIAG_FLAG_OFFSET, 1); - if(diag) value |= (1<<7); - else value &= ~(1<<7); - psoc_ipmi_write((u8*)&value, DIAG_FLAG_OFFSET, 1); - - return count; -} - -static ssize_t show_version(struct device *dev, struct device_attribute *da, - char *buf) -{ - u16 status=0; - - status = psoc_read16(VERSION_OFFSET); - - 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=0; - struct sensor_device_attribute *attr = to_sensor_dev_attr(da); - u8 bit = attr->index; - - if(bit < 8) { status = psoc_read8(FAN_LED_OFFSET); } -#if FAN_NUM>4 - if(bit >= 8) { status = psoc_read8(FAN_LED2_OFFSET); bit-=8; } -#endif - - return sprintf(buf, "%d\n", - (status & (1<index; - u8 led_state = 0; - - u8 v = simple_strtol(buf, NULL, 10); - - if(attr->index < 8) { led_state = psoc_read8(FAN_LED_OFFSET ); } -#if FAN_NUM>4 - if(attr->index >= 8) { led_state = psoc_read8(FAN_LED2_OFFSET); bit-=8; } -#endif - if(v) led_state |= (1<index < 8) { psoc_ipmi_write(&led_state, FAN_LED_OFFSET, 1);} -#if FAN_NUM>4 - if(attr->index >= 8) { psoc_ipmi_write(&led_state, FAN_LED2_OFFSET,1);} -#endif - return count; -} - -static ssize_t show_value8(struct device *dev, struct device_attribute *da, - char *buf) -{ - int status=0; - struct sensor_device_attribute *attr = to_sensor_dev_attr(da); - u8 offset = attr->index; - - status = psoc_read8(offset); - - 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=0; - struct sensor_device_attribute *attr = to_sensor_dev_attr(da); - u8 offset = attr->index + PSU_INFO_OFFSET; - - status = psoc_read16(offset); - - if((strstr(attr->dev_attr.attr.name, "vout")!=NULL)|(strstr(attr->dev_attr.attr.name, "in3")!=NULL)|(strstr(attr->dev_attr.attr.name, "in4")!=NULL)) { - offset=1; - } - else { - offset=0; - } - - return sprintf(buf, "%ld \n", pmbus_reg2data_linear(status, offset )); -} - -static ssize_t show_name(struct device *dev, - struct device_attribute *devattr, char *buf) -{ - return sprintf(buf, "inv_psoc\n"); -} - -static DEVICE_ATTR(name, S_IRUGO, show_name, NULL); -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(temp7_input, S_IRUGO, show_thermal, 0, 5); -static SENSOR_DEVICE_ATTR(temp8_input, S_IRUGO, show_thermal, 0, 6); - -static SENSOR_DEVICE_ATTR(pwm1, S_IWUSR|S_IRUGO, show_pwm, set_pwm, 0 + PWM_OFFSET); -static SENSOR_DEVICE_ATTR(pwm2, S_IWUSR|S_IRUGO, show_pwm, set_pwm, 1 + PWM_OFFSET); -static SENSOR_DEVICE_ATTR(pwm3, S_IWUSR|S_IRUGO, show_pwm, set_pwm, 2 + PWM_OFFSET); -static SENSOR_DEVICE_ATTR(pwm4, S_IWUSR|S_IRUGO, show_pwm, set_pwm, 3 + PWM_OFFSET); -#if FAN_NUM > 4 -static SENSOR_DEVICE_ATTR(pwm5, S_IWUSR|S_IRUGO, show_pwm, set_pwm, 0 + PWM2_OFFSET); -#endif -static SENSOR_DEVICE_ATTR(pwm_psu1, S_IWUSR|S_IRUGO, show_pwm, set_pwm, 4 + PWM_OFFSET); -static SENSOR_DEVICE_ATTR(pwm_psu2, S_IWUSR|S_IRUGO, show_pwm, set_pwm, 5 + PWM_OFFSET); -static SENSOR_DEVICE_ATTR(pwm6, S_IWUSR|S_IRUGO, show_pwm, set_pwm, 4 + PWM_OFFSET); -static SENSOR_DEVICE_ATTR(pwm7, S_IWUSR|S_IRUGO, show_pwm, set_pwm, 5 + PWM_OFFSET); - -static SENSOR_DEVICE_ATTR(psu1, S_IRUGO, show_psu_st, 0, 0); -static SENSOR_DEVICE_ATTR(psu2, 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); -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(fan11_input, S_IRUGO, show_rpm, 0, 8*2 + RPM_OFFSET); -static SENSOR_DEVICE_ATTR(fan12_input, S_IRUGO, show_rpm, 0, 9*2 + RPM_OFFSET); - -#if FAN_NUM > 4 -static SENSOR_DEVICE_ATTR(fan9_input , S_IRUGO, show_rpm, 0,0*2 + RPM2_OFFSET); -static SENSOR_DEVICE_ATTR(fan10_input, S_IRUGO, show_rpm, 0,1*2 + RPM2_OFFSET); -#endif - -static SENSOR_DEVICE_ATTR(switch_tmp, S_IWUSR|S_IRUGO, show_switch_tmp, set_switch_tmp, 0); -static SENSOR_DEVICE_ATTR(temp6_input, 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); - -#if FAN_NUM>4 -static SENSOR_DEVICE_ATTR(fan_led_grn5, S_IWUSR|S_IRUGO, show_fan_led, set_fan_led, 8); -static SENSOR_DEVICE_ATTR(fan_led_red5, S_IWUSR|S_IRUGO, show_fan_led, set_fan_led, 12); -static SENSOR_DEVICE_ATTR(fan_gpi2, S_IRUGO, show_value8, 0, FAN_GPI2_OFFSET); -#endif - -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(in1_input, S_IRUGO, show_psu_psoc, 0, PSOC_PSU_OFF(psu1_vin)); -static SENSOR_DEVICE_ATTR(curr1_input, S_IRUGO, show_psu_psoc, 0, PSOC_PSU_OFF(psu1_iin)); -static SENSOR_DEVICE_ATTR(power1_input, S_IRUGO, show_psu_psoc, 0, PSOC_PSU_OFF(psu1_pin)); -static SENSOR_DEVICE_ATTR(in3_input, S_IRUGO, show_psu_psoc, 0, PSOC_PSU_OFF(psu1_vout)); -static SENSOR_DEVICE_ATTR(curr3_input, S_IRUGO, show_psu_psoc, 0, PSOC_PSU_OFF(psu1_iout)); -static SENSOR_DEVICE_ATTR(power3_input, 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 SENSOR_DEVICE_ATTR(in2_input, S_IRUGO, show_psu_psoc, 0, PSOC_PSU_OFF(psu2_vin)); -static SENSOR_DEVICE_ATTR(curr2_input, S_IRUGO, show_psu_psoc, 0, PSOC_PSU_OFF(psu2_iin)); -static SENSOR_DEVICE_ATTR(power2_input, S_IRUGO, show_psu_psoc, 0, PSOC_PSU_OFF(psu2_pin)); -static SENSOR_DEVICE_ATTR(in4_input, S_IRUGO, show_psu_psoc, 0, PSOC_PSU_OFF(psu2_vout)); -static SENSOR_DEVICE_ATTR(curr4_input, S_IRUGO, show_psu_psoc, 0, PSOC_PSU_OFF(psu2_iout)); -static SENSOR_DEVICE_ATTR(power4_input, S_IRUGO, show_psu_psoc, 0, PSOC_PSU_OFF(psu2_pout)); - -//IPMI -static SENSOR_DEVICE_ATTR(thermal2_psu1, S_IRUGO, show_ipmi_pmbus, 0, PSU1 | PMBus_Temp2); -static SENSOR_DEVICE_ATTR(temp9_input, S_IRUGO, show_ipmi_pmbus, 0, PSU1 | PMBus_Temp2); - -static SENSOR_DEVICE_ATTR(psoc_psu1_vendor, S_IRUGO, show_ipmi_pmbus, 0, PSU1 | PMBus_Vendor); -static SENSOR_DEVICE_ATTR(psoc_psu1_serial, S_IRUGO, show_ipmi_pmbus, 0, PSU1 | PMBus_Serial); -static SENSOR_DEVICE_ATTR(psoc_psu1_version, S_IRUGO, show_ipmi_pmbus, 0, PSU1 | PMBus_Version); - -static SENSOR_DEVICE_ATTR(thermal2_psu2, S_IRUGO, show_ipmi_pmbus, 0, PSU2 | PMBus_Temp2); -static SENSOR_DEVICE_ATTR(temp10_input, S_IRUGO, show_ipmi_pmbus, 0, PSU2 | PMBus_Temp2); -static SENSOR_DEVICE_ATTR(psoc_psu2_vendor, S_IRUGO, show_ipmi_pmbus, 0, PSU2 | PMBus_Vendor); -static SENSOR_DEVICE_ATTR(psoc_psu2_serial, S_IRUGO, show_ipmi_pmbus, 0, PSU2 | PMBus_Serial); -static SENSOR_DEVICE_ATTR(psoc_psu2_version, S_IRUGO, show_ipmi_pmbus, 0, PSU2 | PMBus_Version); - -//CLEI -#if FAN_CLEI_SUPPORT -static SENSOR_DEVICE_ATTR(fan1_clei, S_IRUGO, show_clei, 0, FAN1_CLEI_INDEX ); -static SENSOR_DEVICE_ATTR(fan2_clei, S_IRUGO, show_clei, 0, FAN2_CLEI_INDEX ); -static SENSOR_DEVICE_ATTR(fan3_clei, S_IRUGO, show_clei, 0, FAN3_CLEI_INDEX ); -static SENSOR_DEVICE_ATTR(fan4_clei, S_IRUGO, show_clei, 0, FAN4_CLEI_INDEX ); -#if FAN_NUM > 4 -static SENSOR_DEVICE_ATTR(fan5_clei, S_IRUGO, show_clei, 0, FAN5_CLEI_INDEX ); -#endif -#endif - -#if PSU_CLEI_SUPPORT -static SENSOR_DEVICE_ATTR(psu1_clei, S_IRUGO, show_clei, 0, PSU1_CLEI_INDEX ); -static SENSOR_DEVICE_ATTR(psu2_clei, S_IRUGO, show_clei, 0, PSU2_CLEI_INDEX ); -#endif - -static struct attribute *psoc_attributes[] = { - //name - &dev_attr_name.attr, - //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, - - &sensor_dev_attr_temp7_input.dev_attr.attr, - &sensor_dev_attr_temp8_input.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 > 4 - &sensor_dev_attr_pwm5.dev_attr.attr, -#endif - &sensor_dev_attr_pwm_psu1.dev_attr.attr, - &sensor_dev_attr_pwm_psu2.dev_attr.attr, - &sensor_dev_attr_pwm6.dev_attr.attr, - &sensor_dev_attr_pwm7.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 > 4 - &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, - &sensor_dev_attr_fan11_input.dev_attr.attr, - &sensor_dev_attr_fan12_input.dev_attr.attr, - //switch temperature - &sensor_dev_attr_switch_tmp.dev_attr.attr, - &sensor_dev_attr_temp6_input.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, -#if FAN_NUM >4 - &sensor_dev_attr_fan_led_grn5.dev_attr.attr, - &sensor_dev_attr_fan_led_red5.dev_attr.attr, - &sensor_dev_attr_fan_gpi2.dev_attr.attr, -#endif - //fan GPI - &sensor_dev_attr_fan_gpi.dev_attr.attr, - &sensor_dev_attr_psu1.dev_attr.attr, - &sensor_dev_attr_psu2.dev_attr.attr, - - - //psu_psoc - &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, - - &sensor_dev_attr_in1_input.dev_attr.attr, - &sensor_dev_attr_curr1_input.dev_attr.attr, - &sensor_dev_attr_power1_input.dev_attr.attr, - &sensor_dev_attr_in2_input.dev_attr.attr, - &sensor_dev_attr_curr2_input.dev_attr.attr, - &sensor_dev_attr_power2_input.dev_attr.attr, - &sensor_dev_attr_in3_input.dev_attr.attr, - &sensor_dev_attr_curr3_input.dev_attr.attr, - &sensor_dev_attr_power3_input.dev_attr.attr, - &sensor_dev_attr_in4_input.dev_attr.attr, - &sensor_dev_attr_curr4_input.dev_attr.attr, - &sensor_dev_attr_power4_input.dev_attr.attr, - - //ipmi_i2c_command - &sensor_dev_attr_thermal2_psu1.dev_attr.attr, - &sensor_dev_attr_temp9_input.dev_attr.attr, - &sensor_dev_attr_psoc_psu1_vendor.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_temp10_input.dev_attr.attr, - &sensor_dev_attr_psoc_psu2_vendor.dev_attr.attr, - &sensor_dev_attr_psoc_psu2_serial.dev_attr.attr, - &sensor_dev_attr_psoc_psu2_version.dev_attr.attr, - - //clei -#if FAN_CLEI_SUPPORT - &sensor_dev_attr_fan1_clei.dev_attr.attr, - &sensor_dev_attr_fan2_clei.dev_attr.attr, - &sensor_dev_attr_fan3_clei.dev_attr.attr, - &sensor_dev_attr_fan4_clei.dev_attr.attr, -#if FAN_NUM > 4 - &sensor_dev_attr_fan5_clei.dev_attr.attr, -#endif -#endif - -#if PSU_CLEI_SUPPORT - &sensor_dev_attr_psu1_clei.dev_attr.attr, - &sensor_dev_attr_psu2_clei.dev_attr.attr, -#endif - NULL -}; - -static const struct attribute_group psoc_group = { - .attrs = psoc_attributes, -}; - -//================================= -static void check_switch_temp(void) -{ - static struct file *f; - mm_segment_t old_fs; - - set_fs(get_ds()); - f = filp_open(SWITCH_TEMPERATURE_SOCK,O_RDONLY,0644); - if(IS_ERR(f)) { - return; - } -// It is not used in Gulmohar and Lavender platform. -/* else { - char temp_str[]={0,0,0,0,0,0,0}; - loff_t pos = 0; - u16 temp2 = 0; - old_fs = get_fs(); - set_fs(KERNEL_DS); - vfs_read(f, temp_str,6,&pos); - temp2 = ((simple_strtoul(temp_str,NULL,10)/1000) <<8 ) & 0xFF00 ; - psoc_ipmi_write((u8*)&temp2, SWITCH_TMP_OFFSET, 2); - }*/ - filp_close(f,NULL); - set_fs(old_fs); -} - -static int psoc_polling_thread(void *p) -{ - while (!kthread_should_stop()) - { - check_switch_temp(); - set_current_state(TASK_INTERRUPTIBLE); - if(kthread_should_stop()) - break; - - schedule_timeout(msecs_to_jiffies(PSOC_POLLING_PERIOD)); - } - return 0; -} - -static int __init inv_psoc_init(void) -{ - int ret; - - hwmon_dev = hwmon_device_register(NULL); - if (IS_ERR(hwmon_dev)) { - goto fail_hwmon_device_register; - } - - device_kobj = kobject_create_and_add("device", &hwmon_dev->kobj); - if(!device_kobj) { - goto fail_hwmon_device_register; - } - - ret = sysfs_create_group(device_kobj, &psoc_group); - if (ret) { - goto fail_create_group_hwmon; - } - - ret = sysfs_create_group(&hwmon_dev->kobj, &psoc_group); - if (ret) { - goto fail_create_group_hwmon; - } - - kthread_auto_update = kthread_run(psoc_polling_thread,NULL,"BMC_DRIVER"); - if (IS_ERR(kthread_auto_update)) { - goto fail_create_group_hwmon; - } - return ret; - -fail_create_group_hwmon: - hwmon_device_unregister(hwmon_dev); -fail_hwmon_device_register: - return -ENOMEM; -} - -static void __exit inv_psoc_exit(void) -{ - kthread_stop(kthread_auto_update); - if(ipmi_mh_user!=NULL) {ipmi_destroy_user(ipmi_mh_user);} - sysfs_remove_group(device_kobj, &psoc_group); - if(hwmon_dev != NULL) hwmon_device_unregister(hwmon_dev); -} - -MODULE_AUTHOR("Ting.Jack "); -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/d10056/modules/builds/src/inv_swps.c b/packages/platforms/inventec/x86-64/d10056/modules/builds/src/inv_swps.c deleted file mode 100644 index 6686352cf..000000000 --- a/packages/platforms/inventec/x86-64/d10056/modules/builds/src/inv_swps.c +++ /dev/null @@ -1,3233 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "inv_swps.h" - -static int ctl_major; -static int port_major; -static int ioexp_total; -static int port_total; -static int block_polling; -static int auto_config; -static int flag_i2c_reset; -static int flag_mod_state; -static unsigned gpio_rest_mux; -static struct class *swp_class_p = NULL; -static struct inv_platform_s *platform_p = NULL; -static struct inv_ioexp_layout_s *ioexp_layout = NULL; -static struct inv_port_layout_s *port_layout = NULL; - -static void swp_polling_worker(struct work_struct *work); -static DECLARE_DELAYED_WORK(swp_polling, swp_polling_worker); - -static int reset_i2c_topology(void); - - -static int -__swp_match(struct device *dev, -#ifdef SWPS_KERN_VER_AF_3_10 - - const void *data){ -#else - void *data){ -#endif - - char *name = (char *)data; - if (strcmp(dev_name(dev), name) == 0) - return 1; - return 0; -} - - -struct device * -get_swpdev_by_name(char *name){ - struct device *dev = class_find_device(swp_class_p, - NULL, - name, - __swp_match); - return dev; -} - - -static int -sscanf_2_int(const char *buf) { - - int result = -EBFONT; - char *hex_tag = "0x"; - - if (strcspn(buf, hex_tag) == 0) { - if (sscanf(buf,"%x",&result)) { - return result; - } - } else { - if (sscanf(buf,"%d",&result)) { - return result; - } - if(sscanf(buf,"-%d",&result)) { - return -result; - } - if (sscanf(buf,"%x",&result)) { - return result; - } - } - return -EBFONT; -} - - -static int -sscanf_2_binary(const char *buf) { - - int result = sscanf_2_int(buf); - - if (result < 0){ - return -EBFONT; - } - switch (result) { - case 0: - case 1: - return result; - default: - break; - } - return -EBFONT; -} - - -static int -_get_polling_period(void) { - - int retval = 0; - - if (SWP_POLLING_PERIOD == 0) { - return 0; - } - retval = ((SWP_POLLING_PERIOD * HZ) / 1000); - if (retval == 0) { - return 1; - } - return retval; -} - - -static struct transvr_obj_s * -_get_transvr_obj(char *dev_name) { - - struct device *dev_p = NULL; - struct transvr_obj_s *transvr_obj_p = NULL; - - dev_p = get_swpdev_by_name(dev_name); - if (!dev_p){ - return NULL; - } - transvr_obj_p = dev_get_drvdata(dev_p); - if (!transvr_obj_p){ - return NULL; - } - return transvr_obj_p; -} - - -static int -_is_i2c_target_exist(int chan, int addr) { - /* retval: Exist = 1 / Not exist = 0 / Error < 0 - */ - struct i2c_adapter *adap = NULL; - struct i2c_client *client = NULL; - int retval = -1; - int err = -1; - int d_offs = 0; - - adap = i2c_get_adapter(chan); - if (!adap) { - SWPS_DEBUG("%s: can't get adapter\n", __func__); - retval = 0; - goto out_is_i2c_target_exist_1; - } - client = kzalloc(sizeof(*client), GFP_KERNEL); - if (!client) { - SWPS_ERR("%s: kzalloc fail\n", __func__); - retval = -1; - goto out_is_i2c_target_exist_2; - } - client->adapter = adap; - client->addr = addr; - err = i2c_smbus_read_byte_data(client, d_offs); - if (err < 0) { - retval = 0; - } else { - retval = 1; - } - i2c_put_adapter(adap); - kfree(client); - return retval; - -out_is_i2c_target_exist_2: - i2c_put_adapter(adap); -out_is_i2c_target_exist_1: - return retval; -} - - -static void -unlock_tobj_all(void) { - - struct transvr_obj_s *tobj_p; - char port_name[32]; - int port_id = 0; - int minor_curr = 0; - - for (minor_curr=0; minor_currauto_config = auto_config; - unlock_transvr_obj(tobj_p); - SWPS_DEBUG("%s: Set %s auto_config=%d\n", - __func__, tobj_p->swp_name, auto_config); - } - return retval; -} - - -/* ========== R/W Functions module control attribute ========== - */ -static ssize_t -show_attr_platform(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - return snprintf(buf_p, 32, "%s\n", platform_p->name); -} - - -static ssize_t -show_attr_version(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - return snprintf(buf_p, 8, "%s\n", SWP_VERSION); -} - - -static ssize_t -show_attr_status(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - return snprintf(buf_p, 8, "%d\n", flag_mod_state); -} - - -static ssize_t -show_attr_auto_config(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - return snprintf(buf_p, 8, "%d\n", auto_config); -} - - -static ssize_t -show_attr_block_poll(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - return snprintf(buf_p, 8, "%d\n", block_polling); -} - - -static int -_check_reset_pwd(const char *buf_p, - size_t count) { - - int in_max = 64; - int in_len = (int)count; - char in_val[64] = "ERR"; - char *emsg = "ERR"; - - if (in_len >= in_max) { - emsg = "input too much"; - goto err_check_reset_pwd; - } - if (!sscanf(buf_p,"%s",in_val)) { - emsg = "format incorrect"; - goto err_check_reset_pwd; - } - if (strcmp(in_val, SWP_RESET_PWD) != 0) { - emsg = "password incorrect"; - goto err_check_reset_pwd; - } - return 0; - -err_check_reset_pwd: - SWPS_ERR("%s: %s\n", __func__, emsg); - return -1; -} - - -static ssize_t -store_attr_reset_i2c(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - - if (_check_reset_pwd(buf_p, count) < 0) { - return -EBFONT; - } - /* Polling mode */ - if (SWP_POLLING_ENABLE) { - SWPS_INFO("%s: reset I2C :polling\n", __func__); - flag_i2c_reset = 1; - return count; - } - /* Direct mode */ - SWPS_INFO("%s: reset I2C go. :direct\n", __func__); - if (reset_i2c_topology() < 0) { - SWPS_ERR("%s: reset fail!\n", __func__); - return -EIO; - } - SWPS_INFO("%s: reset I2C ok. :direct\n", __func__); - return count; -} - - -static ssize_t -store_attr_reset_swps(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - - struct transvr_obj_s *tobj_p; - char port_name[32] = "ERR"; - int port_id = 0; - int minor_curr = 0; - - if (_check_reset_pwd(buf_p, count) < 0) { - return -EBFONT; - } - for (minor_curr=0; minor_currstate = STATE_TRANSVR_DISCONNECTED; - unlock_transvr_obj(tobj_p); - SWPS_INFO("%s: reset:%s\n", __func__, tobj_p->swp_name); - } - return count; -} - - -static ssize_t -store_attr_auto_config(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - - int input_val = sscanf_2_int(buf_p); - - if (input_val < 0){ - return -EBFONT; - } - if ((input_val != 0) && (input_val != 1)) { - return -EBFONT; - } - auto_config = input_val; - _update_auto_config_2_trnasvr(); - return count; -} - - -static ssize_t -store_attr_block_poll( struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - - int input_val = sscanf_2_int(buf_p); - - if (input_val < 0){ - return -EBFONT; - } - if ((input_val != 0) && (input_val != 1)) { - return -EBFONT; - } - - if(input_val != block_polling){ - block_polling = input_val; - if(block_polling){ - cancel_delayed_work_sync(&swp_polling); - } - else{ - schedule_delayed_work(&swp_polling, _get_polling_period()); - } - } - - return count; -} -/* ========== Show functions: For transceiver attribute ========== - */ -static ssize_t -_show_transvr_hex_attr(struct transvr_obj_s* tobj_p, - int (*get_func)(struct transvr_obj_s* tobj_p), - char *buf_p) { - size_t len; - int result; - - lock_transvr_obj(tobj_p); - result = get_func(tobj_p); - unlock_transvr_obj(tobj_p); - if (result < 0){ - len = snprintf(buf_p, 8, "%d\n", result); - } else { - len = snprintf(buf_p, 8, "0x%02x\n", result); - } - return len; -} - - -static ssize_t -_show_transvr_int_attr(struct transvr_obj_s* tobj_p, - int (*get_func)(struct transvr_obj_s* tobj_p), - char *buf_p) { - size_t len; - - lock_transvr_obj(tobj_p); - len = snprintf(buf_p, 16, "%d\n", get_func(tobj_p)); - unlock_transvr_obj(tobj_p); - return len; -} - - -static ssize_t -_show_transvr_str_attr(struct transvr_obj_s* tobj_p, - int (*get_func)(struct transvr_obj_s* tobj_p, char* buf), - char *buf_p) { - size_t len; - - lock_transvr_obj(tobj_p); - len = get_func(tobj_p, buf_p); - unlock_transvr_obj(tobj_p); - return len; -} - - -static ssize_t -show_attr_id(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_hex_attr(tobj_p, - tobj_p->get_id, - buf_p); -} - - -static ssize_t -show_attr_ext_id(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_hex_attr(tobj_p, - tobj_p->get_ext_id, - buf_p); -} - - -static ssize_t -show_attr_connector(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_hex_attr(tobj_p, - tobj_p->get_connector, - buf_p); -} - - -static ssize_t -show_attr_vendor_name(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_vendor_name, - buf_p); -} - - -static ssize_t -show_attr_vendor_pn(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_vendor_pn, - buf_p); -} - - -static ssize_t -show_attr_vendor_rev(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_vendor_rev, - buf_p); -} - - -static ssize_t -show_attr_vendor_sn(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_vendor_sn, - buf_p); -} - - -static ssize_t -show_attr_power_cls(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - size_t len; - int result; - struct transvr_obj_s *tobj_p; - - tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - lock_transvr_obj(tobj_p); - result = tobj_p->get_power_cls(tobj_p); - unlock_transvr_obj(tobj_p); - if (result < 0){ - len = snprintf(buf_p, 16, "%d\n", result); - } else { - len = snprintf(buf_p, 16, "Power Class %d\n", result); - } - return len; -} - - -static ssize_t -show_attr_br(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_hex_attr(tobj_p, - tobj_p->get_br, - buf_p); -} - - -static ssize_t -show_attr_len_sm(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_int_attr(tobj_p, - tobj_p->get_len_sm, - buf_p); -} - - -static ssize_t -show_attr_len_smf(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_int_attr(tobj_p, - tobj_p->get_len_smf, - buf_p); -} - - -static ssize_t -show_attr_len_om1(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_int_attr(tobj_p, - tobj_p->get_len_om1, - buf_p); -} - - -static ssize_t -show_attr_len_om2(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_int_attr(tobj_p, - tobj_p->get_len_om2, - buf_p); -} - - -static ssize_t -show_attr_len_om3(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_int_attr(tobj_p, - tobj_p->get_len_om3, - buf_p); -} - - -static ssize_t -show_attr_len_om4(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_int_attr(tobj_p, - tobj_p->get_len_om4, - buf_p); -} - - -static ssize_t -show_attr_comp_rev(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_hex_attr(tobj_p, - tobj_p->get_comp_rev, - buf_p); -} - - -static ssize_t -show_attr_comp_eth(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_hex_attr(tobj_p, - tobj_p->get_comp_eth_1, - buf_p); -} - - -static ssize_t -show_attr_comp_eth_10(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_hex_attr(tobj_p, - tobj_p->get_comp_eth_10, - buf_p); -} - - -static ssize_t -show_attr_comp_eth_10_40(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_hex_attr(tobj_p, - tobj_p->get_comp_eth_10_40, - buf_p); -} - - -static ssize_t -show_attr_comp_extend(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_hex_attr(tobj_p, - tobj_p->get_comp_extend, - buf_p); -} - - -static ssize_t -show_attr_rate_id(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_hex_attr(tobj_p, - tobj_p->get_rate_id, - buf_p); -} - - -static ssize_t -show_attr_temperature(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_curr_temp, - buf_p); -} - - -static ssize_t -show_attr_voltage(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_curr_vol, - buf_p); -} - - -static ssize_t -show_attr_tx_bias(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_tx_bias, - buf_p); -} - - -static ssize_t -show_attr_tx_power(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_tx_power, - buf_p); -} - - -static ssize_t -show_attr_tx_eq(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_tx_eq, - buf_p); -} - - -static ssize_t -show_attr_rx_power(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_rx_power, - buf_p); -} - - -static ssize_t -show_attr_rx_am(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_rx_am, - buf_p); -} - - -static ssize_t -show_attr_rx_em(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_rx_em, - buf_p); -} - - -static ssize_t -show_attr_wavelength(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_wavelength, - buf_p); -} - - -static ssize_t -show_attr_extphy_offset(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_extphy_offset, - buf_p); -} - - -static ssize_t -show_attr_extphy_reg(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_extphy_reg, - buf_p); -} - - -static ssize_t -show_attr_info(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_int_attr(tobj_p, - tobj_p->get_info, - buf_p); -} - - -static ssize_t -show_attr_if_type(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_if_type, - buf_p); -} - - -static ssize_t -show_attr_if_speed(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_if_speed, - buf_p); -} - - -static ssize_t -show_attr_if_lane(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_if_lane, - buf_p); -} - - -static ssize_t -show_attr_cdr(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_hex_attr(tobj_p, - tobj_p->get_cdr, - buf_p); -} - - -static ssize_t -show_attr_soft_rs0(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_int_attr(tobj_p, - tobj_p->get_soft_rs0, - buf_p); -} - - -static ssize_t -show_attr_soft_rs1(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_int_attr(tobj_p, - tobj_p->get_soft_rs1, - buf_p); -} - - -static ssize_t -show_attr_soft_rx_los(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_soft_rx_los, - buf_p); -} - - -static ssize_t -show_attr_soft_tx_disable(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_soft_tx_disable, - buf_p); -} - - -static ssize_t -show_attr_soft_tx_fault(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_soft_tx_fault, - buf_p); -} - - -static ssize_t -show_attr_auto_tx_disable(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_auto_tx_disable, - buf_p); -} - - -/* ========== Store functions: transceiver (R/W) attribute ========== - */ -static ssize_t -_store_transvr_int_attr(struct transvr_obj_s* tobj_p, - int (*set_func)(struct transvr_obj_s *tobj_p, int input_val), - const char *buf_p, - size_t count) { - int input, err; - - input = sscanf_2_int(buf_p); - if (input < 0){ - return -EBFONT; - } - lock_transvr_obj(tobj_p); - err = set_func(tobj_p, input); - unlock_transvr_obj(tobj_p); - if (err < 0){ - return err; - } - return count; -} - - -static ssize_t -_store_transvr_byte_hex_attr(struct transvr_obj_s* tobj_p, - int (*set_func)(struct transvr_obj_s *tobj_p, int input_val), - const char *buf_p, - size_t count) { - int input, err; - - input = sscanf_2_int(buf_p); - if ((input < 0) || (input > 0xff)){ - return -EBFONT; - } - lock_transvr_obj(tobj_p); - err = set_func(tobj_p, input); - unlock_transvr_obj(tobj_p); - if (err < 0){ - return err; - } - return count; -} - - -static ssize_t -_store_transvr_binary_attr(struct transvr_obj_s* tobj_p, - int (*set_func)(struct transvr_obj_s *tobj_p, int input_val), - const char *buf_p, - size_t count) { - int input, err; - - input = sscanf_2_binary(buf_p); - if (input < 0){ - return -EBFONT; - } - lock_transvr_obj(tobj_p); - err = set_func(tobj_p, input); - unlock_transvr_obj(tobj_p); - if (err < 0){ - return err; - } - return count; -} - - -static ssize_t -store_attr_cdr(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - return _store_transvr_byte_hex_attr(tobj_p, - tobj_p->set_cdr, - buf_p, - count); -} - - -static ssize_t -store_attr_soft_rs0(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - return _store_transvr_binary_attr(tobj_p, - tobj_p->set_soft_rs0, - buf_p, - count); -} - - -static ssize_t -store_attr_soft_rs1(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - return _store_transvr_binary_attr(tobj_p, - tobj_p->set_soft_rs1, - buf_p, - count); -} - - -static ssize_t -store_attr_soft_tx_disable(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count) { - - int check = sscanf_2_int(buf_p); - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - if ((check < 0) || (check > 0xf)){ - return -EBFONT; - } - return _store_transvr_byte_hex_attr(tobj_p, - tobj_p->set_soft_tx_disable, - buf_p, - count); -} - - -static ssize_t -store_attr_auto_tx_disable(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count) { - - int err = -EPERM; - int input = sscanf_2_int(buf_p); - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - if ((input < 0) || (input > 0xf)){ - if (input != VAL_TRANSVR_FUNCTION_DISABLE) { - return -EBFONT; - } - } - lock_transvr_obj(tobj_p); - err = tobj_p->set_auto_tx_disable(tobj_p, input); - unlock_transvr_obj(tobj_p); - if (err < 0){ - return err; - } - return count; -} - - -static ssize_t -store_attr_tx_eq(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - return _store_transvr_int_attr(tobj_p, - tobj_p->set_tx_eq, - buf_p, - count); -} - - -static ssize_t -store_attr_rx_am(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - return _store_transvr_int_attr(tobj_p, - tobj_p->set_rx_am, - buf_p, - count); -} - - -static ssize_t -store_attr_rx_em(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - return _store_transvr_int_attr(tobj_p, - tobj_p->set_rx_em, - buf_p, - count); -} - - -static ssize_t -store_attr_extphy_offset(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - return _store_transvr_int_attr(tobj_p, - tobj_p->set_extphy_offset, - buf_p, - count); -} - - -static ssize_t -store_attr_extphy_reg(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - return _store_transvr_int_attr(tobj_p, - tobj_p->set_extphy_reg, - buf_p, - count); -} - -/* ========== Show functions: For I/O Expander attribute ========== - */ -static ssize_t -_show_ioexp_binary_attr(struct transvr_obj_s *tobj_p, - int (*get_func)(struct ioexp_obj_s *ioexp_p, int voffset), - char *buf_p) { - size_t len; - struct ioexp_obj_s *ioexp_p = tobj_p->ioexp_obj_p; - - if (!ioexp_p) { - SWPS_ERR(" %s: data corruption! :%s\n", __func__, tobj_p->swp_name); - return -ENODATA; - } - mutex_lock(&ioexp_p->lock); - len = snprintf(buf_p, 8, "%d\n", get_func(ioexp_p, tobj_p->ioexp_virt_offset)); - mutex_unlock(&ioexp_p->lock); - return len; -} - - -static ssize_t -show_attr_present(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - return _show_ioexp_binary_attr(tobj_p, - tobj_p->ioexp_obj_p->get_present, - buf_p); -} - - -static ssize_t -show_attr_tx_fault(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - return _show_ioexp_binary_attr(tobj_p, - tobj_p->ioexp_obj_p->get_tx_fault, - buf_p); -} - - -static ssize_t -show_attr_rxlos(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - return _show_ioexp_binary_attr(tobj_p, - tobj_p->ioexp_obj_p->get_rxlos, - buf_p); -} - - -static ssize_t -show_attr_tx_disable(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - return _show_ioexp_binary_attr(tobj_p, - tobj_p->ioexp_obj_p->get_tx_disable, - buf_p); -} - - -static ssize_t -show_attr_reset(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - return _show_ioexp_binary_attr(tobj_p, - tobj_p->ioexp_obj_p->get_reset, - buf_p); -} - - -static ssize_t -show_attr_lpmod(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - return _show_ioexp_binary_attr(tobj_p, - tobj_p->ioexp_obj_p->get_lpmod, - buf_p); -} - - -static ssize_t -show_attr_modsel(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - return _show_ioexp_binary_attr(tobj_p, - tobj_p->ioexp_obj_p->get_modsel, - buf_p); -} - - -static ssize_t -show_attr_hard_rs0(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - return _show_ioexp_binary_attr(tobj_p, - tobj_p->ioexp_obj_p->get_hard_rs0, - buf_p); -} - - -static ssize_t -show_attr_hard_rs1(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - return _show_ioexp_binary_attr(tobj_p, - tobj_p->ioexp_obj_p->get_hard_rs1, - buf_p); -} - - -/* ========== Store functions: For I/O Expander (R/W) attribute ========== - */ -static ssize_t -_store_ioexp_binary_attr(struct transvr_obj_s *tobj_p, - int (*set_func)(struct ioexp_obj_s *ioexp_p, - int virt_offset, int input_val), - const char *buf_p, - size_t count) { - - int input, err; - struct ioexp_obj_s *ioexp_p = tobj_p->ioexp_obj_p; - - if (!ioexp_p) { - SWPS_ERR("%s: data corruption! :%s\n", - __func__, tobj_p->swp_name); - return -ENODATA; - } - input = sscanf_2_binary(buf_p); - if (input < 0) { - return -EBFONT; - } - mutex_lock(&ioexp_p->lock); - err = set_func(ioexp_p, tobj_p->ioexp_virt_offset, input); - mutex_unlock(&ioexp_p->lock); - if (err < 0){ - return err; - } - return count; -} - -static ssize_t -store_attr_tx_disable(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p) { - return -ENODEV; - } - return _store_ioexp_binary_attr(tobj_p, - tobj_p->ioexp_obj_p->set_tx_disable, - buf_p, - count); -} - - -static ssize_t -store_attr_reset(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p) { - return -ENODEV; - } - return _store_ioexp_binary_attr(tobj_p, - tobj_p->ioexp_obj_p->set_reset, - buf_p, - count); -} - - -static ssize_t -store_attr_lpmod(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p) { - return -ENODEV; - } - return _store_ioexp_binary_attr(tobj_p, - tobj_p->ioexp_obj_p->set_lpmod, - buf_p, - count); -} - - -static ssize_t -store_attr_modsel(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p) { - return -ENODEV; - } - return _store_ioexp_binary_attr(tobj_p, - tobj_p->ioexp_obj_p->set_modsel, - buf_p, - count); -} - - -static ssize_t -store_attr_hard_rs0(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p) { - return -ENODEV; - } - return _store_ioexp_binary_attr(tobj_p, - tobj_p->ioexp_obj_p->set_hard_rs0, - buf_p, - count); -} - - -static ssize_t -store_attr_hard_rs1(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p) { - return -ENODEV; - } - return _store_ioexp_binary_attr(tobj_p, - tobj_p->ioexp_obj_p->set_hard_rs1, - buf_p, - count); -} - - -/* ========== SWPS attribute: For module control ========== - */ -static DEVICE_ATTR(platform, S_IRUGO, show_attr_platform, NULL); -static DEVICE_ATTR(version, S_IRUGO, show_attr_version, NULL); -static DEVICE_ATTR(status, S_IRUGO, show_attr_status, NULL); -static DEVICE_ATTR(reset_i2c, S_IWUSR, NULL, store_attr_reset_i2c); -static DEVICE_ATTR(reset_swps, S_IWUSR, NULL, store_attr_reset_swps); -static DEVICE_ATTR(auto_config, S_IRUGO|S_IWUSR, show_attr_auto_config, store_attr_auto_config); -static DEVICE_ATTR(block_poll, S_IRUGO|S_IWUSR, show_attr_block_poll, store_attr_block_poll); - -/* ========== Transceiver attribute: from eeprom ========== - */ -static DEVICE_ATTR(id, S_IRUGO, show_attr_id, NULL); -static DEVICE_ATTR(ext_id, S_IRUGO, show_attr_ext_id, NULL); -static DEVICE_ATTR(connector, S_IRUGO, show_attr_connector, NULL); -static DEVICE_ATTR(vendor_name, S_IRUGO, show_attr_vendor_name, NULL); -static DEVICE_ATTR(vendor_pn, S_IRUGO, show_attr_vendor_pn, NULL); -static DEVICE_ATTR(vendor_rev, S_IRUGO, show_attr_vendor_rev, NULL); -static DEVICE_ATTR(vendor_sn, S_IRUGO, show_attr_vendor_sn, NULL); -static DEVICE_ATTR(power_cls, S_IRUGO, show_attr_power_cls, NULL); -static DEVICE_ATTR(br, S_IRUGO, show_attr_br, NULL); -static DEVICE_ATTR(len_sm, S_IRUGO, show_attr_len_sm, NULL); -static DEVICE_ATTR(len_smf, S_IRUGO, show_attr_len_smf, NULL); -static DEVICE_ATTR(len_om1, S_IRUGO, show_attr_len_om1, NULL); -static DEVICE_ATTR(len_om2, S_IRUGO, show_attr_len_om2, NULL); -static DEVICE_ATTR(len_om3, S_IRUGO, show_attr_len_om3, NULL); -static DEVICE_ATTR(len_om4, S_IRUGO, show_attr_len_om4, NULL); -static DEVICE_ATTR(comp_rev, S_IRUGO, show_attr_comp_rev, NULL); -static DEVICE_ATTR(comp_eth, S_IRUGO, show_attr_comp_eth, NULL); -static DEVICE_ATTR(comp_eth_10, S_IRUGO, show_attr_comp_eth_10, NULL); -static DEVICE_ATTR(comp_eth_10_40, S_IRUGO, show_attr_comp_eth_10_40, NULL); -static DEVICE_ATTR(comp_extend, S_IRUGO, show_attr_comp_extend, NULL); -static DEVICE_ATTR(rate_id, S_IRUGO, show_attr_rate_id, NULL); -static DEVICE_ATTR(temperature, S_IRUGO, show_attr_temperature, NULL); -static DEVICE_ATTR(voltage, S_IRUGO, show_attr_voltage, NULL); -static DEVICE_ATTR(tx_bias, S_IRUGO, show_attr_tx_bias, NULL); -static DEVICE_ATTR(tx_power, S_IRUGO, show_attr_tx_power, NULL); -static DEVICE_ATTR(rx_power, S_IRUGO, show_attr_rx_power, NULL); -static DEVICE_ATTR(info, S_IRUGO, show_attr_info, NULL); -static DEVICE_ATTR(if_type, S_IRUGO, show_attr_if_type, NULL); -static DEVICE_ATTR(if_speed, S_IRUGO, show_attr_if_speed, NULL); -static DEVICE_ATTR(if_lane, S_IRUGO, show_attr_if_lane, NULL); -static DEVICE_ATTR(soft_rx_los, S_IRUGO, show_attr_soft_rx_los, NULL); -static DEVICE_ATTR(soft_tx_fault, S_IRUGO, show_attr_soft_tx_fault, NULL); -static DEVICE_ATTR(wavelength, S_IRUGO, show_attr_wavelength, NULL); -static DEVICE_ATTR(tx_eq, S_IRUGO|S_IWUSR, show_attr_tx_eq, store_attr_tx_eq); -static DEVICE_ATTR(rx_am, S_IRUGO|S_IWUSR, show_attr_rx_am, store_attr_rx_am); -static DEVICE_ATTR(rx_em, S_IRUGO|S_IWUSR, show_attr_rx_em, store_attr_rx_em); -static DEVICE_ATTR(cdr, S_IRUGO|S_IWUSR, show_attr_cdr, store_attr_cdr); -static DEVICE_ATTR(soft_rs0, S_IRUGO|S_IWUSR, show_attr_soft_rs0, store_attr_soft_rs0); -static DEVICE_ATTR(soft_rs1, S_IRUGO|S_IWUSR, show_attr_soft_rs1, store_attr_soft_rs1); -static DEVICE_ATTR(soft_tx_disable, S_IRUGO|S_IWUSR, show_attr_soft_tx_disable, store_attr_soft_tx_disable); -static DEVICE_ATTR(auto_tx_disable, S_IRUGO|S_IWUSR, show_attr_auto_tx_disable, store_attr_auto_tx_disable); -static DEVICE_ATTR(extphy_offset, S_IRUGO|S_IWUSR, show_attr_extphy_offset, store_attr_extphy_offset); -static DEVICE_ATTR(extphy_reg, S_IRUGO|S_IWUSR, show_attr_extphy_reg, store_attr_extphy_reg); - -/* ========== IO Expander attribute: from expander ========== - */ -static DEVICE_ATTR(present, S_IRUGO, show_attr_present, NULL); -static DEVICE_ATTR(tx_fault, S_IRUGO, show_attr_tx_fault, NULL); -static DEVICE_ATTR(rxlos, S_IRUGO, show_attr_rxlos, NULL); -static DEVICE_ATTR(tx_disable, S_IRUGO|S_IWUSR, show_attr_tx_disable, store_attr_tx_disable); -static DEVICE_ATTR(reset, S_IRUGO|S_IWUSR, show_attr_reset, store_attr_reset); -static DEVICE_ATTR(lpmod, S_IRUGO|S_IWUSR, show_attr_lpmod, store_attr_lpmod); -static DEVICE_ATTR(modsel, S_IRUGO|S_IWUSR, show_attr_modsel, store_attr_modsel); -static DEVICE_ATTR(hard_rs0, S_IRUGO|S_IWUSR, show_attr_hard_rs0, store_attr_hard_rs0); -static DEVICE_ATTR(hard_rs1, S_IRUGO|S_IWUSR, show_attr_hard_rs1, store_attr_hard_rs1); - -/* ========== Functions for module handling ========== - */ -static void -clean_port_objs(void){ - - dev_t dev_num; - char dev_name[32]; - struct device *device_p; - struct transvr_obj_s *tobj_p; - int minor_curr, port_id; - - for (minor_curr=0; minor_curri2c_client_p) { - i2c_put_adapter(tobj_p->i2c_client_p->adapter); - kfree(tobj_p->i2c_client_p); - } - kfree(tobj_p->vendor_name); - kfree(tobj_p->vendor_pn); - kfree(tobj_p->vendor_rev); - kfree(tobj_p->vendor_sn); - kfree(tobj_p->worker_p); - kfree(tobj_p); - } - dev_num = MKDEV(port_major, minor_curr); - device_unregister(device_p); - device_destroy(swp_class_p, dev_num); - } - SWPS_DEBUG("%s: done.\n", __func__); -} - - -static void -clean_swps_common(void){ - - dev_t dev_num; - struct device *device_p; - - device_p = get_swpdev_by_name(SWP_DEV_MODCTL); - if (device_p){ - dev_num = MKDEV(ctl_major, 1); - device_unregister(device_p); - device_destroy(swp_class_p, dev_num); - } - cancel_delayed_work_sync(&swp_polling); - if (platform_p) { - kfree(platform_p); - } - SWPS_DEBUG("%s: done.\n", __func__); -} - - -static int -get_platform_type(void){ - - int i, tmp; - int auto_chan = -1; - int auto_addr = -1; - int pf_total = ARRAY_SIZE(platform_map); - char log_msg[64] = "ERROR"; - - platform_p = kzalloc(sizeof(struct inv_platform_s), GFP_KERNEL); - if (!platform_p){ - snprintf(log_msg, sizeof(log_msg), "kzalloc fail"); - goto err_get_platform_type_1; - } - memset(platform_p->name, 0, sizeof(platform_p->name)); - - switch (PLATFORM_SETTINGS) { - case PLATFORM_TYPE_AUTO: - snprintf(platform_p->name, (sizeof(platform_p->name) - 1), - "%s", dmi_get_system_info(DMI_BOARD_NAME)); - for (i=0; iname, platform_map[i].name) == 0) { - platform_p->id = platform_map[i].id; - snprintf(log_msg, sizeof(log_msg), - "Auto detect platform: %d (%s)", - platform_p->id, platform_p->name); - goto ok_get_platform_type_1; - } - } - snprintf(log_msg, sizeof(log_msg), - "Auto detect fail! detect platform: %s", - platform_p->name); - goto err_get_platform_type_2; - - case PLATFORM_TYPE_PEONY_AUTO: -#ifdef SWPS_PEONY_SFP - auto_chan = peony_sfp_ioexp_layout[0].addr[0].chan_id; - auto_addr = peony_sfp_ioexp_layout[0].addr[0].chip_addr; -#endif - tmp = _is_i2c_target_exist(auto_chan, auto_addr); - switch (tmp) { - case 0: /* Copper SKU */ - SWPS_INFO("Auto-detected :Peony :Copper\n"); - platform_p->id = PLATFORM_TYPE_PEONY_COPPER_GA; - goto map_platform_name; - - case 1: /* SFP SKU */ - SWPS_INFO("Auto-detected :Peony :SFP\n"); - platform_p->id = PLATFORM_TYPE_PEONY_SFP_GA; - goto map_platform_name; - - default: - break; - } - snprintf(log_msg, sizeof(log_msg), - "Auto detect Peony SKU fail! :%d", tmp); - goto err_get_platform_type_2; - - case PLATFORM_TYPE_MAGNOLIA: - case PLATFORM_TYPE_MAGNOLIA_FNC: - case PLATFORM_TYPE_REDWOOD: - case PLATFORM_TYPE_REDWOOD_FSL: - case PLATFORM_TYPE_HUDSON32I_GA: - case PLATFORM_TYPE_SPRUCE: - case PLATFORM_TYPE_CYPRESS_GA1: - case PLATFORM_TYPE_CYPRESS_GA2: - case PLATFORM_TYPE_CYPRESS_BAI: - case PLATFORM_TYPE_TAHOE: - case PLATFORM_TYPE_SEQUOIA_GA: - case PLATFORM_TYPE_LAVENDER_GA: - case PLATFORM_TYPE_LAVENDER_ONL: - case PLATFORM_TYPE_COTTONWOOD_RANGELEY: - case PLATFORM_TYPE_MAPLE_GA: - case PLATFORM_TYPE_MAPLE_B: - case PLATFORM_TYPE_GULMOHAR_GA: - case PLATFORM_TYPE_GULMOHAR_2T_EVT1_GA: - case PLATFORM_TYPE_PEONY_SFP_GA: - case PLATFORM_TYPE_PEONY_COPPER_GA: - platform_p->id = PLATFORM_SETTINGS; - goto map_platform_name; - - default: - break; - } - snprintf(log_msg, sizeof(log_msg), - "PLATFORM_SETTINGS:%d undefined", PLATFORM_SETTINGS); - goto err_get_platform_type_2; - -map_platform_name: - for (i=0; iid == platform_map[i].id) { - snprintf(platform_p->name, (sizeof(platform_p->name) - 1), - "%s", platform_map[i].name); - snprintf(log_msg, sizeof(log_msg), - "User setup platform: %d (%s)", - platform_p->id, platform_p->name); - goto ok_get_platform_type_1; - } - } - snprintf(log_msg, sizeof(log_msg), - "Internal error, can not map id:%d", - platform_p->id ); - goto err_get_platform_type_2; - -ok_get_platform_type_1: - SWPS_DEBUG("%s: %s, :%d\n", __func__, log_msg, PLATFORM_SETTINGS); - return 0; - -err_get_platform_type_2: - kfree(platform_p); -err_get_platform_type_1: - SWPS_ERR("%s: %s :%d\n", __func__, log_msg, PLATFORM_SETTINGS); - return -1; -} - - -static int -get_layout_info(void){ - - switch (platform_p->id) { -#ifdef SWPS_MAGNOLIA - case PLATFORM_TYPE_MAGNOLIA: - case PLATFORM_TYPE_MAGNOLIA_FNC: - gpio_rest_mux = magnolia_gpio_rest_mux; - ioexp_layout = magnolia_ioexp_layout; - port_layout = magnolia_port_layout; - ioexp_total = ARRAY_SIZE(magnolia_ioexp_layout); - port_total = ARRAY_SIZE(magnolia_port_layout); - break; -#endif -#ifdef SWPS_REDWOOD - case PLATFORM_TYPE_REDWOOD: - gpio_rest_mux = redwood_gpio_rest_mux; - ioexp_layout = redwood_ioexp_layout; - port_layout = redwood_port_layout; - ioexp_total = ARRAY_SIZE(redwood_ioexp_layout); - port_total = ARRAY_SIZE(redwood_port_layout); - break; -#endif -#ifdef SWPS_HUDSON32I_GA - case PLATFORM_TYPE_HUDSON32I_GA: - gpio_rest_mux = hudsin32iga_gpio_rest_mux; - ioexp_layout = hudson32iga_ioexp_layout; - port_layout = hudson32iga_port_layout; - ioexp_total = ARRAY_SIZE(hudson32iga_ioexp_layout); - port_total = ARRAY_SIZE(hudson32iga_port_layout); - break; -#endif -#ifdef SWPS_SPRUCE - case PLATFORM_TYPE_SPRUCE: - gpio_rest_mux = spruce_gpio_rest_mux; - ioexp_layout = spruce_ioexp_layout; - port_layout = spruce_port_layout; - ioexp_total = ARRAY_SIZE(spruce_ioexp_layout); - port_total = ARRAY_SIZE(spruce_port_layout); - break; -#endif -#ifdef SWPS_CYPRESS_GA1 - case PLATFORM_TYPE_CYPRESS_GA1: - gpio_rest_mux = cypress_ga1_gpio_rest_mux; - ioexp_layout = cypress_ga1_ioexp_layout; - port_layout = cypress_ga1_port_layout; - ioexp_total = ARRAY_SIZE(cypress_ga1_ioexp_layout); - port_total = ARRAY_SIZE(cypress_ga1_port_layout); - break; -#endif -#ifdef SWPS_CYPRESS_GA2 - case PLATFORM_TYPE_CYPRESS_GA2: - gpio_rest_mux = cypress_ga2_gpio_rest_mux; - ioexp_layout = cypress_ga2_ioexp_layout; - port_layout = cypress_ga2_port_layout; - ioexp_total = ARRAY_SIZE(cypress_ga2_ioexp_layout); - port_total = ARRAY_SIZE(cypress_ga2_port_layout); - break; -#endif -#ifdef SWPS_CYPRESS_BAI - case PLATFORM_TYPE_CYPRESS_BAI: - gpio_rest_mux = cypress_b_gpio_rest_mux; - ioexp_layout = cypress_b_ioexp_layout; - port_layout = cypress_b_port_layout; - ioexp_total = ARRAY_SIZE(cypress_b_ioexp_layout); - port_total = ARRAY_SIZE(cypress_b_port_layout); - break; -#endif -#ifdef SWPS_REDWOOD_FSL - case PLATFORM_TYPE_REDWOOD_FSL: - gpio_rest_mux = redwood_fsl_gpio_rest_mux; - ioexp_layout = redwood_fsl_ioexp_layout; - port_layout = redwood_fsl_port_layout; - ioexp_total = ARRAY_SIZE(redwood_fsl_ioexp_layout); - port_total = ARRAY_SIZE(redwood_fsl_port_layout); - break; -#endif -#ifdef SWPS_TAHOE - case PLATFORM_TYPE_TAHOE: - gpio_rest_mux = tahoe_gpio_rest_mux; - ioexp_layout = tahoe_ioexp_layout; - port_layout = tahoe_port_layout; - ioexp_total = ARRAY_SIZE(tahoe_ioexp_layout); - port_total = ARRAY_SIZE(tahoe_port_layout); - break; -#endif -#ifdef SWPS_SEQUOIA - case PLATFORM_TYPE_SEQUOIA_GA: - gpio_rest_mux = sequoia_gpio_rest_mux; - ioexp_layout = sequoia_ioexp_layout; - port_layout = sequoia_port_layout; - ioexp_total = ARRAY_SIZE(sequoia_ioexp_layout); - port_total = ARRAY_SIZE(sequoia_port_layout); - break; -#endif -#ifdef SWPS_LAVENDER - case PLATFORM_TYPE_LAVENDER_GA: - case PLATFORM_TYPE_LAVENDER_ONL: - gpio_rest_mux = lavender_gpio_rest_mux; - ioexp_layout = lavender_ioexp_layout; - port_layout = lavender_port_layout; - ioexp_total = ARRAY_SIZE(lavender_ioexp_layout); - port_total = ARRAY_SIZE(lavender_port_layout); - break; -#endif -#ifdef SWPS_COTTONWOOD_RANGELEY - case PLATFORM_TYPE_COTTONWOOD_RANGELEY: - gpio_rest_mux = cottonwood_rangeley_gpio_rest_mux; - ioexp_layout = cottonwood_rangeley_ioexp_layout; - port_layout = cottonwood_rangeley_port_layout; - ioexp_total = ARRAY_SIZE(cottonwood_rangeley_ioexp_layout); - port_total = ARRAY_SIZE(cottonwood_rangeley_port_layout); - break; -#endif -#ifdef SWPS_MAPLE_GA - case PLATFORM_TYPE_MAPLE_GA: - gpio_rest_mux = maple_ga_gpio_rest_mux; - ioexp_layout = maple_ga_ioexp_layout; - port_layout = maple_ga_port_layout; - ioexp_total = ARRAY_SIZE(maple_ga_ioexp_layout); - port_total = ARRAY_SIZE(maple_ga_port_layout); - break; -#endif -#ifdef SWPS_MAPLE_B - case PLATFORM_TYPE_MAPLE_B: - gpio_rest_mux = maple_b_gpio_rest_mux; - ioexp_layout = maple_b_ioexp_layout; - port_layout = maple_b_port_layout; - ioexp_total = ARRAY_SIZE(maple_b_ioexp_layout); - port_total = ARRAY_SIZE(maple_b_port_layout); - break; -#endif -#ifdef SWPS_GULMOHAR - case PLATFORM_TYPE_GULMOHAR_GA: - gpio_rest_mux = gulmohar_gpio_rest_mux; - ioexp_layout = gulmohar_ioexp_layout; - port_layout = gulmohar_port_layout; - ioexp_total = ARRAY_SIZE(gulmohar_ioexp_layout); - port_total = ARRAY_SIZE(gulmohar_port_layout); - break; -#endif -#ifdef SWPS_GULMOHAR_2T_EVT1 - case PLATFORM_TYPE_GULMOHAR_2T_EVT1_GA: - gpio_rest_mux = gulmohar_2t_evt1_gpio_rest_mux; - ioexp_layout = gulmohar_2t_evt1_ioexp_layout; - port_layout = gulmohar_2t_evt1_port_layout; - ioexp_total = ARRAY_SIZE(gulmohar_2t_evt1_ioexp_layout); - port_total = ARRAY_SIZE(gulmohar_2t_evt1_port_layout); - break; -#endif -#ifdef SWPS_PEONY_SFP - case PLATFORM_TYPE_PEONY_SFP_GA: - gpio_rest_mux = peony_sfp_gpio_rest_mux; - ioexp_layout = peony_sfp_ioexp_layout; - port_layout = peony_sfp_port_layout; - ioexp_total = ARRAY_SIZE(peony_sfp_ioexp_layout); - port_total = ARRAY_SIZE(peony_sfp_port_layout); - break; -#endif -#ifdef SWPS_PEONY_COPPER - case PLATFORM_TYPE_PEONY_COPPER_GA: - gpio_rest_mux = peony_copper_gpio_rest_mux; - ioexp_layout = peony_copper_ioexp_layout; - port_layout = peony_copper_port_layout; - ioexp_total = ARRAY_SIZE(peony_copper_ioexp_layout); - port_total = ARRAY_SIZE(peony_copper_port_layout); - break; -#endif - - default: - SWPS_ERR(" Invalid platform: %d (%s)\n", - platform_p->id, platform_p->name); - return -1; - } - SWPS_INFO("Start to initial platform: %d (%s)\n", - platform_p->id, platform_p->name); - return 0; -} - - -/* ========== Functions for objects operations ========== - */ -static int -__detect_issues_port(int minor_num) { - - struct transvr_obj_s *tobj_p; - int port_id = port_layout[minor_num].port_id; - char port_name[32] = "ERR"; - char *i2c_emsg = "detected bad transceiver/cable"; - - memset(port_name, 0, sizeof(port_name)); - snprintf(port_name, sizeof(port_name), "%s%d", SWP_DEV_PORT, port_id); - tobj_p = _get_transvr_obj(port_name); - if (!tobj_p) { - SWPS_INFO("%s: tobj_p is NULL :%d\n", __func__, minor_num); - return -1; - } - if (resync_channel_tier_2(tobj_p) < 0) { - if (check_channel_tier_1() < 0) { - goto get_target_issues_port; - } - } - /* Re-check again for i2c-gpio special case */ - if (check_channel_tier_1() < 0) { - goto get_target_issues_port; - } - return 0; - -get_target_issues_port: - alarm_msg_2_user(tobj_p, i2c_emsg); - return -2; -} - - -static int -_detect_issues_port(void) { - /* OK : retrun -1; - * Fail: return fail at which minor number (0~N) - */ - char *emsg = "ERR"; - int minor = 0; - int minor_2st = 1; - - /* Force moving the initial channel pointer - * Filter out case of fail at minor-0 port - */ - while (minor_2st < port_total) { - minor = minor_2st; - if (__detect_issues_port(minor_2st) < 0) { - emsg = "detect minor_2st fail"; - goto err_p_detect_issues_port; - } - minor_2st += 8; - } - /* Scan all port */ - for (minor=0; minor:%d\n", __func__, emsg, minor_err); - return -1; -} - - -static int -check_transvr_obj_one(char *dev_name){ - /* [Return] - * 0 : Doesn't need to take care - * -1 : Single error - * -2 : Critical error (I2C topology die) - * -9 : Internal error - */ - struct transvr_obj_s *tobj_p = NULL; - int retval = -9; - - tobj_p = _get_transvr_obj(dev_name); - if (!tobj_p) { - SWPS_ERR("%s: %s _get_transvr_obj fail\n", - __func__, dev_name); - return -9; - } - /* Check transceiver current status */ - lock_transvr_obj(tobj_p); - retval = tobj_p->check(tobj_p); - unlock_transvr_obj(tobj_p); - switch (retval) { - case 0: - case ERR_TRANSVR_UNPLUGGED: - case ERR_TRNASVR_BE_ISOLATED: - case ERR_TRANSVR_TASK_BUSY: - return 0; - - case ERR_TRANSVR_I2C_CRASH: - default: - break; - } - /* Identify abnormal case */ - if (check_channel_tier_1() < 0) { - SWPS_DEBUG("%s: %s critical error :%d\n", - __func__, dev_name, retval); - return -2; - } - SWPS_DEBUG("%s: %s single error :%d\n", - __func__, dev_name, retval); - return -1; -} - - -static int -check_transvr_objs(void){ - - char dev_name[32]; - int port_id, err_code; - int minor_curr = 0; - - for (minor_curr=0; minor_curr:%d\n", - __func__, dev_name, err_code); - break; - } - } - return 0; - -err_check_transvr_objs: - SWPS_ERR("%s: %s reset_i2c_topology fail.\n", - __func__, dev_name); - return -1; -} - - -static void -swp_polling_worker(struct work_struct *work){ - - /* Reset I2C */ - if (flag_i2c_reset) { - goto polling_reset_i2c; - } - /* Check IOEXP */ - if (check_ioexp_objs() < 0) { - goto polling_reset_i2c; - } - /* Check transceiver */ - if (check_transvr_objs() < 0) { - SWPS_DEBUG("%s: check_transvr_objs fail.\n", __func__); - flag_i2c_reset = 1; - } - goto polling_schedule_round; - -polling_reset_i2c: - SWPS_DEBUG("%s: reset_i2c_topology start.\n", __func__); - if (reset_i2c_topology() < 0) { - SWPS_ERR("%s: reset i2c fail!\n", __func__); - flag_i2c_reset = 1; - } else { - SWPS_DEBUG("%s: reset_i2c_topology OK.\n", __func__); - flag_i2c_reset = 0; - } -polling_schedule_round: - schedule_delayed_work(&swp_polling, _get_polling_period()); -} - - -/* ========== Functions for register something ========== - */ -static int -register_transvr_common_attr(struct device *device_p){ - - char *err_attr = NULL; - - if (device_create_file(device_p, &dev_attr_id) < 0) { - err_attr = "dev_attr_id"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_ext_id) < 0) { - err_attr = "dev_attr_ext_id"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_connector) < 0) { - err_attr = "dev_attr_connector"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_vendor_name) < 0) { - err_attr = "dev_attr_vendor_name"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_vendor_pn) < 0) { - err_attr = "dev_attr_vendor_pn"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_vendor_rev) < 0) { - err_attr = "dev_attr_vendor_rev"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_vendor_sn) < 0) { - err_attr = "dev_attr_vendor_sn"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_br) < 0) { - err_attr = "dev_attr_br"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_len_smf) < 0) { - err_attr = "dev_attr_len_smf"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_len_om1) < 0) { - err_attr = "dev_attr_len_om1"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_len_om2) < 0) { - err_attr = "dev_attr_len_om2"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_len_om3) < 0) { - err_attr = "dev_attr_len_om3"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_len_om4) < 0) { - err_attr = "dev_attr_len_om4"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_comp_extend) < 0) { - err_attr = "dev_attr_comp_extend"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_comp_eth) < 0) { - err_attr = "dev_attr_comp_eth"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_comp_rev) < 0) { - err_attr = "dev_attr_comp_rev"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_info) < 0) { - err_attr = "dev_attr_info"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_if_type) < 0) { - err_attr = "dev_attr_if_type"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_if_speed) < 0) { - err_attr = "dev_attr_if_speed"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_if_lane) < 0) { - err_attr = "dev_attr_if_lane"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_temperature) < 0) { - err_attr = "dev_attr_temperature"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_voltage) < 0) { - err_attr = "dev_attr_voltage"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_tx_bias) < 0) { - err_attr = "dev_attr_tx_bias"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_tx_power) < 0) { - err_attr = "dev_attr_tx_power"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_rx_power) < 0) { - err_attr = "dev_attr_rx_power"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_tx_eq) < 0) { - err_attr = "dev_attr_tx_eq"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_rx_em) < 0) { - err_attr = "dev_attr_rx_em"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_wavelength) < 0) { - err_attr = "dev_attr_wavelength"; - goto err_transvr_comm_attr; - } - return 0; - -err_transvr_comm_attr: - SWPS_ERR("%s: %s\n", __func__, err_attr); - return -1; -} - -static int -register_transvr_sfp_attr(struct device *device_p){ - - char *err_attr = NULL; - - if (register_transvr_common_attr(device_p) < 0) { - err_attr = "register_transvr_common_attr"; - goto err_transvr_sfp_attr; - } - if (device_create_file(device_p, &dev_attr_comp_eth_10) < 0) { - err_attr = "dev_attr_comp_eth_10"; - goto err_transvr_sfp_attr; - } - if (device_create_file(device_p, &dev_attr_len_sm) < 0) { - err_attr = "dev_attr_len_sm"; - goto err_transvr_sfp_attr; - } - if (device_create_file(device_p, &dev_attr_rate_id) < 0) { - err_attr = "dev_attr_rate_id"; - goto err_transvr_sfp_attr; - } - if (device_create_file(device_p, &dev_attr_soft_rs0) < 0) { - err_attr = "dev_attr_soft_rs0"; - goto err_transvr_sfp_attr; - } - if (device_create_file(device_p, &dev_attr_soft_rs1) < 0) { - err_attr = "dev_attr_soft_rs1"; - goto err_transvr_sfp_attr; - } - if (device_create_file(device_p, &dev_attr_extphy_offset) < 0) { - err_attr = "dev_attr_extphy_offset"; - goto err_transvr_sfp_attr; - } - if (device_create_file(device_p, &dev_attr_extphy_reg) < 0) { - err_attr = "dev_attr_extphy_reg"; - goto err_transvr_sfp_attr; - } - return 0; - -err_transvr_sfp_attr: - SWPS_ERR("%s: %s\n", __func__, err_attr); - return -1; -} - - -static int -register_transvr_qsfp_attr(struct device *device_p){ - - char *err_attr = NULL; - - if (register_transvr_common_attr(device_p) < 0) { - err_attr = "register_transvr_common_attr"; - goto err_transvr_qsfp_attr; - } - if (device_create_file(device_p, &dev_attr_comp_eth_10_40) < 0) { - err_attr = "dev_attr_comp_eth_10_40"; - goto err_transvr_qsfp_attr; - } - if (device_create_file(device_p, &dev_attr_power_cls) < 0) { - err_attr = "dev_attr_power_cls"; - goto err_transvr_qsfp_attr; - } - if (device_create_file(device_p, &dev_attr_soft_rx_los) < 0) { - err_attr = "soft_rx_los"; - goto err_transvr_qsfp_attr; - } - if (device_create_file(device_p, &dev_attr_soft_tx_disable) < 0) { - err_attr = "soft_tx_disable"; - goto err_transvr_qsfp_attr; - } - if (device_create_file(device_p, &dev_attr_auto_tx_disable) < 0) { - err_attr = "auto_tx_disable"; - goto err_transvr_qsfp_attr; - } - if (device_create_file(device_p, &dev_attr_soft_tx_fault) < 0) { - err_attr = "soft_tx_fault"; - goto err_transvr_qsfp_attr; - } - return 0; - -err_transvr_qsfp_attr: - SWPS_ERR("%s: %s\n", __func__, err_attr); - return -1; -} - - -static int -register_transvr_qsfp28_attr(struct device *device_p){ - - char *err_attr = NULL; - - if (register_transvr_qsfp_attr(device_p) < 0){ - err_attr = "register_transvr_qsfp_attr"; - goto err_transvr_qsfp28_attr; - } - if (device_create_file(device_p, &dev_attr_cdr) < 0) { - err_attr = "dev_attr_cdr"; - goto err_transvr_qsfp28_attr; - } - if (device_create_file(device_p, &dev_attr_rx_am) < 0) { - err_attr = "dev_attr_rx_am"; - goto err_transvr_qsfp28_attr; - } - return 0; - -err_transvr_qsfp28_attr: - SWPS_ERR("%s: %s\n", __func__, err_attr); - return -1; -} - - -static int -register_transvr_attr(struct device *device_p, - struct transvr_obj_s *transvr_obj){ - - switch (transvr_obj->layout){ - case TRANSVR_TYPE_SFP: - if (register_transvr_sfp_attr(device_p) < 0){ - goto err_reg_tvr_attr; - } - break; - case TRANSVR_TYPE_QSFP: - case TRANSVR_TYPE_QSFP_PLUS: - if (register_transvr_qsfp_attr(device_p) < 0){ - goto err_reg_tvr_attr; - } - break; - case TRANSVR_TYPE_QSFP_28: - if (register_transvr_qsfp28_attr(device_p) < 0){ - goto err_reg_tvr_attr; - } - break; - default: - goto err_reg_tvr_attr; - } - return 0; - -err_reg_tvr_attr: - SWPS_ERR("%s: fail! type=%d \n", __func__, transvr_obj->type); - return -1; -} - - -static int -register_ioexp_attr_sfp_1(struct device *device_p){ - /* Support machine type: - * - SFP : Magnolia - */ - char *err_attr = NULL; - - if (device_create_file(device_p, &dev_attr_present) < 0) { - err_attr = "dev_attr_present"; - goto err_ioexp_sfp1_attr; - } - if (device_create_file(device_p, &dev_attr_tx_fault) < 0) { - err_attr = "dev_attr_tx_fault"; - goto err_ioexp_sfp1_attr; - } - if (device_create_file(device_p, &dev_attr_rxlos) < 0) { - err_attr = "dev_attr_rxlos"; - goto err_ioexp_sfp1_attr; - } - if (device_create_file(device_p, &dev_attr_tx_disable) < 0) { - err_attr = "dev_attr_tx_disable"; - goto err_ioexp_sfp1_attr; - } - return 0; - -err_ioexp_sfp1_attr: - SWPS_ERR("Add device attribute:%s failure! \n",err_attr); - return -1; -} - - -static int -register_ioexp_attr_sfp_2(struct device *device_p){ - /* Support machine type: - * - SFP28 : Cypress - */ - char *err_attr = NULL; - - if (register_ioexp_attr_sfp_1(device_p) < 0){ - goto err_ioexp_sfp2_attr; - } - if (device_create_file(device_p, &dev_attr_hard_rs0) < 0) { - err_attr = "dev_attr_hard_rs0"; - goto err_ioexp_sfp2_attr; - } - if (device_create_file(device_p, &dev_attr_hard_rs1) < 0) { - err_attr = "dev_attr_hard_rs1"; - goto err_ioexp_sfp2_attr; - } - return 0; - -err_ioexp_sfp2_attr: - SWPS_ERR("Add device attribute:%s failure! \n",err_attr); - return -1; -} - - -static int -register_ioexp_attr_qsfp_1(struct device *device_p){ - /* Support machine type: - * - QSFP : Magnolia, Redwood, Hudson32i - * - QSFP+ : Magnolia, Redwood, Hudson32i - * - QSFP28: Redwood - */ - char *err_attr = NULL; - - if (device_create_file(device_p, &dev_attr_present) < 0) { - err_attr = "dev_attr_present"; - goto err_ioexp_qsfp1_attr; - } - if (device_create_file(device_p, &dev_attr_reset) < 0) { - err_attr = "dev_attr_reset"; - goto err_ioexp_qsfp1_attr; - } - if (device_create_file(device_p, &dev_attr_lpmod) < 0) { - err_attr = "dev_attr_lpmod"; - goto err_ioexp_qsfp1_attr; - } - if (device_create_file(device_p, &dev_attr_modsel) < 0) { - err_attr = "dev_attr_modsel"; - goto err_ioexp_qsfp1_attr; - } - return 0; - -err_ioexp_qsfp1_attr: - SWPS_ERR("Add device attribute:%s failure! \n",err_attr); - return -1; -} - - -static int -register_modctl_attr(struct device *device_p){ - - char *err_msg = NULL; - - if (device_create_file(device_p, &dev_attr_platform) < 0) { - err_msg = "dev_attr_platform"; - goto err_reg_modctl_attr; - } - if (device_create_file(device_p, &dev_attr_version) < 0) { - err_msg = "dev_attr_version"; - goto err_reg_modctl_attr; - } - if (device_create_file(device_p, &dev_attr_status) < 0) { - err_msg = "dev_attr_status"; - goto err_reg_modctl_attr; - } - if (device_create_file(device_p, &dev_attr_reset_i2c) < 0) { - err_msg = "dev_attr_reset_i2c"; - goto err_reg_modctl_attr; - } - if (device_create_file(device_p, &dev_attr_reset_swps) < 0) { - err_msg = "dev_attr_reset_swps"; - goto err_reg_modctl_attr; - } - if (device_create_file(device_p, &dev_attr_auto_config) < 0) { - err_msg = "dev_attr_auto_config"; - goto err_reg_modctl_attr; - } - if (device_create_file(device_p, &dev_attr_block_poll) < 0) { - err_msg = "dev_attr_block_poll"; - goto err_reg_modctl_attr; - } - return 0; - -err_reg_modctl_attr: - SWPS_ERR("%s: %s\n", __func__, err_msg); - return -1; -} - - -static int -register_ioexp_attr(struct device *device_p, - struct transvr_obj_s *transvr_obj){ - - char *err_msg = "ERR"; - - switch (transvr_obj->ioexp_obj_p->ioexp_type){ - case IOEXP_TYPE_MAGINOLIA_NAB: - case IOEXP_TYPE_MAGINOLIA_4AB: - case CPLD_TYPE_COTTONWOOD: - if (register_ioexp_attr_sfp_1(device_p) < 0){ - err_msg = "register_ioexp_attr_sfp_1 fail"; - goto err_reg_ioexp_attr; - } - break; - - case IOEXP_TYPE_MAPLE_NABC: - case IOEXP_TYPE_GULMOHAR_NABC: - case IOEXP_TYPE_GULMOHAR_2T_EVT1_NABC: - case IOEXP_TYPE_GULMOHAR_2T_EVT1_1ABC: - case IOEXP_TYPE_GULMOHAR_2T_EVT1_3ABC: - case IOEXP_TYPE_SFP_8P_LAYOUT_1: - if (register_ioexp_attr_sfp_2(device_p) < 0){ - err_msg = "register_ioexp_attr_sfp_2 fail"; - goto err_reg_ioexp_attr; - } - break; - - case IOEXP_TYPE_MAGINOLIA_7AB: - case IOEXP_TYPE_SPRUCE_7AB: - case IOEXP_TYPE_CYPRESS_7ABC: - case IOEXP_TYPE_REDWOOD_P01P08: - case IOEXP_TYPE_REDWOOD_P09P16: - case IOEXP_TYPE_HUDSON32IGA_P01P08: - case IOEXP_TYPE_HUDSON32IGA_P09P16: - case IOEXP_TYPE_TAHOE_5A: - case IOEXP_TYPE_TAHOE_6ABC: - case IOEXP_TYPE_SEQUOIA_NABC: - case IOEXP_TYPE_LAVENDER_P65: - case IOEXP_TYPE_MAPLE_0ABC: - case IOEXP_TYPE_GULMOHAR_7ABC: - case IOEXP_TYPE_GULMOHAR_2T_EVT1_7ABC: - case IOEXP_TYPE_QSFP_6P_LAYOUT_1: - if (register_ioexp_attr_qsfp_1(device_p) < 0){ - err_msg = "register_ioexp_attr_qsfp_1 fail"; - goto err_reg_ioexp_attr; - } - break; - - default: - err_msg = "Unknow type"; - goto err_reg_ioexp_attr; - } - return 0; - -err_reg_ioexp_attr: - SWPS_ERR("%s: %s :%d \n", - __func__, err_msg, transvr_obj->ioexp_obj_p->ioexp_type); - return -1; -} - - -static int -register_modctl_device(void) { - - struct device *device_p = NULL; - int minor_comm = 0; /* Default minor number for common device */ - dev_t dev_num = MKDEV(ctl_major, minor_comm); - char *err_msg = "ERROR"; - - device_p = device_create(swp_class_p, /* struct class *cls */ - NULL, /* struct device *parent */ - dev_num, /* dev_t devt */ - NULL, /* void *private_data */ - SWP_DEV_MODCTL); /* const char *fmt */ - if (IS_ERR(device_p)){ - err_msg = "device_create fail"; - goto err_register_modctl_device_1; - } - if (register_modctl_attr(device_p) < 0) { - err_msg = "register_modctl_attr fail"; - goto err_register_modctl_device_2; - } - return 0; - -err_register_modctl_device_2: - device_unregister(device_p); - device_destroy(swp_class_p, dev_num); -err_register_modctl_device_1: - SWPS_ERR("%s: %s\n", __func__, err_msg); - return -1; -} - - -static int -register_port_device(char *dev_name, - dev_t dev_num, - struct transvr_obj_s *transvr_obj){ - - struct device *device_p = NULL; - device_p = device_create(swp_class_p, /* struct class *cls */ - NULL, /* struct device *parent */ - dev_num, /* dev_t devt */ - transvr_obj, /* void *private_data */ - dev_name); /* const char *fmt */ - if (IS_ERR(device_p)){ - goto err_regswp_create_dev; - } - if (register_transvr_attr(device_p, transvr_obj) < 0){ - goto err_regswp_reg_attr; - } - if (register_ioexp_attr(device_p, transvr_obj) < 0){ - goto err_regswp_reg_attr; - } - return 0; - -err_regswp_reg_attr: - device_unregister(device_p); - device_destroy(swp_class_p, dev_num); -err_regswp_create_dev: - SWPS_ERR("%s fail! :%s\n", __func__, dev_name); - return -1; -} - - -static int -register_swp_module(void){ - - dev_t ctl_devt = 0; - dev_t port_devt = 0; - int dev_total = port_total + 1; /* char_dev for module control */ - - /* Register device number */ - if (alloc_chrdev_region(&ctl_devt, 0, 1, SWP_DEV_MODCTL) < 0){ - SWPS_WARN("Allocate CTL MAJOR failure! \n"); - goto err_register_swp_module_1; - } - if (alloc_chrdev_region(&port_devt, 0, dev_total, SWP_CLS_NAME) < 0){ - SWPS_WARN("Allocate PORT MAJOR failure! \n"); - goto err_register_swp_module_2; - } - ctl_major = MAJOR(ctl_devt); - port_major = MAJOR(port_devt); - - /* Create class object */ - swp_class_p = class_create(THIS_MODULE, SWP_CLS_NAME); - if (IS_ERR(swp_class_p)) { - SWPS_ERR("Create class failure! \n"); - goto err_register_swp_module_3; - } - return 0; - -err_register_swp_module_3: - unregister_chrdev_region(MKDEV(port_major, 0), port_total); -err_register_swp_module_2: - unregister_chrdev_region(MKDEV(ctl_major, 0), 1); -err_register_swp_module_1: - return -1; -} - - -/* ========== Module initial relate ========== - */ -static int -create_ioexp_objs(void) { - - int i, run_mod; - - /* Clean IOEXP object */ - clean_ioexp_objs(); - /* Get running mode */ - run_mod = IOEXP_MODE_DIRECT; - if (SWP_POLLING_ENABLE){ - run_mod = IOEXP_MODE_POLLING; - } - /* Create IOEXP object */ - for(i=0; i devlen_max) { - snprintf(err_msg, sizeof(err_msg), - "SWP_DEV_PORT too long!"); - goto err_initport_create_tranobj; - } - memset(dev_name, 0, sizeof(dev_name)); - snprintf(dev_name, devlen_max, "%s%d", SWP_DEV_PORT, port_id); - /* Create transceiver object */ - ioexp_obj_p = get_ioexp_obj(ioexp_id); - if (!ioexp_obj_p){ - snprintf(err_msg, sizeof(err_msg), - "IOEXP object:%d not exist", ioexp_id); - goto err_initport_create_tranobj; - } - transvr_obj_p = create_transvr_obj(dev_name, chan_id, ioexp_obj_p, - ioexp_virt_offset, transvr_type, - chipset_type, run_mod); - if (!transvr_obj_p){ - snprintf(err_msg, sizeof(err_msg), - "Create transceiver object fail :%s", dev_name); - goto err_initport_create_tranobj; - } - /* Setup Lane_ID mapping */ - i = ARRAY_SIZE(port_layout[minor_curr].lane_id); - j = ARRAY_SIZE(transvr_obj_p->lane_id); - if (i != j) { - snprintf(err_msg, sizeof(err_msg), - "Lane_id size inconsistent %d/%d", i, j); - goto err_initport_reg_device; - } - memcpy(transvr_obj_p->lane_id, port_layout[minor_curr].lane_id, i*sizeof(int)); - /* Create and register device object */ - if (register_port_device(dev_name, MKDEV(port_major, minor_curr), transvr_obj_p) < 0){ - snprintf(err_msg, sizeof(err_msg), - "register_port_device fail"); - goto err_initport_reg_device; - } - /* Setup device_ptr of transvr_obj */ - dev_p = get_swpdev_by_name(dev_name); - if (!dev_p){ - snprintf(err_msg, sizeof(err_msg), - "get_swpdev_by_name fail"); - goto err_initport_reg_device; - } - transvr_obj_p->transvr_dev_p = dev_p; - /* Success */ - ok_count++; - } - SWPS_INFO("%s: initialed %d port-dev\n",__func__, ok_count); - return 0; - -err_initport_reg_device: - kfree(transvr_obj_p); -err_initport_create_tranobj: - clean_port_objs(); - SWPS_ERR("%s: %s", __func__, err_msg); - SWPS_ERR("Dump: :%d :%d :%d :%d :%d :%d\n", - port_id, chan_id, ioexp_id, ioexp_virt_offset, transvr_type, run_mod); - return -1; -} - - -static int -init_dev_topology(void){ - - int err; - char *emsg = "ERR"; - flag_mod_state = SWP_STATE_NORMAL; - - err = init_ioexp_objs(); - switch(err){ - case 0: /* Normal */ - SWPS_DEBUG("%s: normal case\n", __func__); - break; - - case -1: /* topology error */ - SWPS_DEBUG("%s: detect tier-1 topology initial failure :%d\n", - __func__, err); - /* Reset and isolate */ - err = reset_i2c_topology(); - if (err < 0) { - emsg = "reset i2c topology fail"; - goto err_init_dev_topology; - } - /* Re-initial again */ - err = init_ioexp_objs(); - if (err < 0) { - emsg = "re-init ioexp objects fail"; - goto err_init_dev_topology; - } - break; - - case -2: /* Internal error */ - SWPS_DEBUG("%s: internal error case\n", __func__); - err = -2; - emsg = "internal error"; - goto err_init_dev_topology; - - default: - SWPS_DEBUG("%s: undefined error case\n", __func__); - emsg = "undefined error case"; - goto err_init_dev_topology; - } - SWPS_DEBUG("%s: initial I2C topology success\n", __func__); - return 0; - -err_init_dev_topology: - SWPS_ERR("%s: %s :%d\n", __func__, emsg, err); - return -1; -} - - -static int -init_polling_task(void){ - - if (SWP_POLLING_ENABLE){ - schedule_delayed_work(&swp_polling, _get_polling_period()); - } - return 0; -} - - -static int -init_swps_common(void){ - - char *err_msg = "ERR"; - - block_polling = 0; - auto_config = 0; - if ((SWP_AUTOCONFIG_ENABLE) && (SWP_POLLING_ENABLE)){ - auto_config = 1; - } - if (register_modctl_device() < 0) { - err_msg = "register_modctl_device fail"; - goto err_init_swps_common_1; - } - if (_update_auto_config_2_trnasvr() < 0) { - err_msg = "_update_auto_config_2_trnasvr fail"; - goto err_init_swps_common_1; - } - if (init_polling_task() < 0){ - err_msg = "init_polling_task fail"; - goto err_init_swps_common_1; - } - return 0; - -err_init_swps_common_1: - clean_swps_common(); - SWPS_ERR("%s: %s\n", __func__, err_msg); - return -1; -} - - -static int __init -swp_module_init(void){ - - if (get_platform_type() < 0){ - goto err_init_out; - } - if (get_layout_info() < 0){ - goto err_init_out; - } - if (register_swp_module() < 0){ - goto err_init_out; - } - if (create_ioexp_objs() < 0){ - goto err_init_ioexp; - } - if (create_port_objs() < 0){ - goto err_init_portobj; - } - if (init_mux_objs(gpio_rest_mux) < 0){ - goto err_init_mux; - } - if (init_dev_topology() < 0){ - goto err_init_topology; - } - if (init_swps_common() < 0){ - goto err_init_topology; - } - SWPS_INFO("Inventec switch-port module V.%s initial success.\n", SWP_VERSION); - return 0; - - -err_init_topology: - clean_mux_objs(); -err_init_mux: - clean_port_objs(); -err_init_portobj: - clean_ioexp_objs(); -err_init_ioexp: - class_unregister(swp_class_p); - class_destroy(swp_class_p); - unregister_chrdev_region(MKDEV(ctl_major, 0), 1); - unregister_chrdev_region(MKDEV(port_major, 0), port_total); -err_init_out: - SWPS_ERR("Inventec switch-port module V.%s initial failure.\n", SWP_VERSION); - return -1; -} - - -static void __exit -swp_module_exit(void){ - - clean_swps_common(); - clean_port_objs(); - clean_ioexp_objs(); - clean_mux_objs(); - class_unregister(swp_class_p); - class_destroy(swp_class_p); - unregister_chrdev_region(MKDEV(ctl_major, 0), 1); - unregister_chrdev_region(MKDEV(port_major, 0), port_total); - SWPS_INFO("Remove Inventec switch-port module success.\n"); -} - - -/* Module information */ -MODULE_AUTHOR(SWP_AUTHOR); -MODULE_DESCRIPTION(SWP_DESC); -MODULE_VERSION(SWP_VERSION); -MODULE_LICENSE(SWP_LICENSE); -MODULE_SOFTDEP("pre: inv_platform"); - -module_init(swp_module_init); -module_exit(swp_module_exit); - - - - - - - - - - - diff --git a/packages/platforms/inventec/x86-64/d10056/modules/builds/src/inv_swps.h b/packages/platforms/inventec/x86-64/d10056/modules/builds/src/inv_swps.h deleted file mode 100644 index 1cdda133f..000000000 --- a/packages/platforms/inventec/x86-64/d10056/modules/builds/src/inv_swps.h +++ /dev/null @@ -1,1621 +0,0 @@ -#ifndef INV_SWPS_H -#define INV_SWPS_H - -#include "transceiver.h" -#include "io_expander.h" -#include "inv_mux.h" - -/* Module settings */ -#define SWP_CLS_NAME "swps" -#define SWP_DEV_PORT "port" -#define SWP_DEV_MODCTL "module" -#define SWP_RESET_PWD "inventec" -#define SWP_POLLING_PERIOD (300) /* msec */ -#define SWP_POLLING_ENABLE (1) -#define SWP_AUTOCONFIG_ENABLE (1) - -/* Module information */ -#define SWP_AUTHOR "Neil " -#define SWP_DESC "Inventec port and transceiver driver" -#define SWP_VERSION "4.3.4" -#define SWP_LICENSE "GPL" - -/* Module status define */ -#define SWP_STATE_NORMAL (0) -#define SWP_STATE_I2C_DIE (-91) - -/* [Note]: - * Functions and mechanism for auto-detect platform type is ready, - * But HW and BIOS not ready! We need to wait them. - * So, please do not use PLATFORM_TYPE_AUTO until they are ready. - * (2016.06.13) - */ -#define PLATFORM_TYPE_AUTO (100) -#define PLATFORM_TYPE_MAGNOLIA (111) -#define PLATFORM_TYPE_MAGNOLIA_FNC (112) -#define PLATFORM_TYPE_REDWOOD (121) -#define PLATFORM_TYPE_REDWOOD_FSL (122) -#define PLATFORM_TYPE_HUDSON32I_GA (131) -#define PLATFORM_TYPE_SPRUCE (141) -#define PLATFORM_TYPE_CYPRESS_GA1 (151) /* Up -> Down */ -#define PLATFORM_TYPE_CYPRESS_GA2 (152) /* Down -> Up */ -#define PLATFORM_TYPE_CYPRESS_BAI (153) /* Down -> Up */ -#define PLATFORM_TYPE_TAHOE (161) -#define PLATFORM_TYPE_SEQUOIA_GA (171) -#define PLATFORM_TYPE_LAVENDER_GA (181) -#define PLATFORM_TYPE_LAVENDER_ONL (182) -#define PLATFORM_TYPE_COTTONWOOD_RANGELEY (191) -#define PLATFORM_TYPE_MAPLE_GA (201) -#define PLATFORM_TYPE_GULMOHAR_GA (202) -#define PLATFORM_TYPE_GULMOHAR_2T_EVT1_GA (203) -#define PLATFORM_TYPE_PEONY_SFP_GA (204) -#define PLATFORM_TYPE_PEONY_COPPER_GA (205) -#define PLATFORM_TYPE_PEONY_AUTO (206) -#define PLATFORM_TYPE_MAPLE_B (207) -/* Current running platfrom */ -#define PLATFORM_SETTINGS PLATFORM_TYPE_GULMOHAR_2T_EVT1_GA - -/* Define platform flag and kernel version */ -#if (PLATFORM_SETTINGS == PLATFORM_TYPE_MAGNOLIA) - #define SWPS_MAGNOLIA (1) - #define SWPS_KERN_VER_BF_3_8 (1) -#elif (PLATFORM_SETTINGS == PLATFORM_TYPE_MAGNOLIA_FNC) - #define SWPS_MAGNOLIA (1) - #define SWPS_KERN_VER_AF_3_10 (1) -#elif (PLATFORM_SETTINGS == PLATFORM_TYPE_REDWOOD) - #define SWPS_REDWOOD (1) - #define SWPS_KERN_VER_BF_3_8 (1) -#elif (PLATFORM_SETTINGS == PLATFORM_TYPE_REDWOOD_FSL) - #define SWPS_REDWOOD_FSL (1) - #define SWPS_KERN_VER_BF_3_8 (1) -#elif (PLATFORM_SETTINGS == PLATFORM_TYPE_HUDSON32I_GA) - #define SWPS_HUDSON32I_GA (1) - #define SWPS_KERN_VER_BF_3_8 (1) -#elif (PLATFORM_SETTINGS == PLATFORM_TYPE_SPRUCE) - #define SWPS_SPRUCE (1) - #define SWPS_KERN_VER_BF_3_8 (1) -#elif (PLATFORM_SETTINGS == PLATFORM_TYPE_CYPRESS_GA1) - #define SWPS_CYPRESS_GA1 (1) - #define SWPS_KERN_VER_BF_3_8 (1) -#elif (PLATFORM_SETTINGS == PLATFORM_TYPE_CYPRESS_GA2) - #define SWPS_CYPRESS_GA2 (1) - #define SWPS_KERN_VER_BF_3_8 (1) -#elif (PLATFORM_SETTINGS == PLATFORM_TYPE_CYPRESS_BAI) - #define SWPS_CYPRESS_BAI (1) - #define SWPS_KERN_VER_AF_3_10 (1) -#elif (PLATFORM_SETTINGS == PLATFORM_TYPE_TAHOE) - #define SWPS_TAHOE (1) - #define SWPS_KERN_VER_AF_3_10 (1) -#elif (PLATFORM_SETTINGS == PLATFORM_TYPE_SEQUOIA_GA) - #define SWPS_SEQUOIA (1) - #define SWPS_KERN_VER_BF_3_8 (1) -#elif (PLATFORM_SETTINGS == PLATFORM_TYPE_LAVENDER_GA) - #define SWPS_LAVENDER (1) - #define SWPS_KERN_VER_AF_3_10 (1) -#elif (PLATFORM_SETTINGS == PLATFORM_TYPE_LAVENDER_ONL) - #define SWPS_LAVENDER (1) - #define SWPS_KERN_VER_AF_3_10 (1) -#elif (PLATFORM_SETTINGS == PLATFORM_TYPE_COTTONWOOD_RANGELEY) - #define SWPS_COTTONWOOD_RANGELEY (1) - #define SWPS_KERN_VER_AF_3_10 (1) -#elif (PLATFORM_SETTINGS == PLATFORM_TYPE_MAPLE_GA) - #define SWPS_MAPLE_GA (1) - #define SWPS_KERN_VER_AF_3_10 (1) -#elif (PLATFORM_SETTINGS == PLATFORM_TYPE_MAPLE_B) - #define SWPS_MAPLE_B (1) - #define SWPS_KERN_VER_AF_3_10 (1) -#elif (PLATFORM_SETTINGS == PLATFORM_TYPE_GULMOHAR_GA) - #define SWPS_GULMOHAR (1) - #define SWPS_KERN_VER_AF_3_10 (1) -#elif (PLATFORM_SETTINGS == PLATFORM_TYPE_GULMOHAR_2T_EVT1_GA) - #define SWPS_GULMOHAR_2T_EVT1 (1) - #define SWPS_KERN_VER_AF_3_10 (1) -#elif (PLATFORM_SETTINGS == PLATFORM_TYPE_PEONY_SFP_GA) - #define SWPS_PEONY_SFP (1) - #define SWPS_KERN_VER_AF_3_10 (1) -#elif (PLATFORM_SETTINGS == PLATFORM_TYPE_PEONY_COPPER_GA) - #define SWPS_PEONY_COPPER (1) - #define SWPS_KERN_VER_AF_3_10 (1) -#elif (PLATFORM_SETTINGS == PLATFORM_TYPE_PEONY_AUTO) - #define SWPS_PEONY_SFP (1) - #define SWPS_PEONY_COPPER (1) - #define SWPS_KERN_VER_AF_3_10 (1) -#endif - -struct inv_platform_s { - int id; - char name[64]; -}; - -struct inv_ioexp_layout_s { - int ioexp_id; - int ioexp_type; - struct ioexp_addr_s addr[4]; -}; - -struct inv_port_layout_s { - int port_id; - int chan_id; - int ioexp_id; - int ioexp_offset; - int transvr_type; - int chipset_type; - int lane_id[8]; -}; - - -/* ========================================== - * Inventec Platform Settings - * ========================================== - */ -struct inv_platform_s platform_map[] = { - {PLATFORM_TYPE_AUTO, "Auto-Detect" }, - {PLATFORM_TYPE_MAGNOLIA, "Magnolia" }, - {PLATFORM_TYPE_MAGNOLIA_FNC, "Magnolia_FNC" }, - {PLATFORM_TYPE_REDWOOD, "Redwood" }, - {PLATFORM_TYPE_REDWOOD_FSL, "Redwood_FSL" }, - {PLATFORM_TYPE_HUDSON32I_GA, "Hudson32i" }, - {PLATFORM_TYPE_SPRUCE, "Spruce" }, - {PLATFORM_TYPE_CYPRESS_GA1, "Cypress_GA1" }, - {PLATFORM_TYPE_CYPRESS_GA2, "Cypress_GA2" }, - {PLATFORM_TYPE_CYPRESS_BAI, "Cypress_BAI" }, - {PLATFORM_TYPE_TAHOE, "Tahoe" }, - {PLATFORM_TYPE_SEQUOIA_GA, "Sequoia_GA" }, - {PLATFORM_TYPE_LAVENDER_GA, "Lavender_GA" }, - {PLATFORM_TYPE_LAVENDER_ONL, "Lavender_ONL" }, - {PLATFORM_TYPE_COTTONWOOD_RANGELEY, "Cottonwood_RANGELEY" }, - {PLATFORM_TYPE_MAPLE_GA, "Maple_GA" }, - {PLATFORM_TYPE_MAPLE_B, "Maple_B" }, - {PLATFORM_TYPE_GULMOHAR_GA, "Gulmohar_GA" }, - {PLATFORM_TYPE_GULMOHAR_2T_EVT1_GA, "Gulmohar_2T_EVT1_GA" }, - {PLATFORM_TYPE_PEONY_SFP_GA, "Peony_SFP_GA" }, - {PLATFORM_TYPE_PEONY_COPPER_GA, "Peony_Copper_GA" }, - {PLATFORM_TYPE_PEONY_AUTO, "Peony_Auto_Detect" }, -}; - - -/* ========================================== - * Magnolia Layout configuration - * ========================================== - */ -#ifdef SWPS_MAGNOLIA -unsigned magnolia_gpio_rest_mux = MUX_RST_GPIO_48_PCA9548; - -struct inv_ioexp_layout_s magnolia_ioexp_layout[] = { - /* IOEXP_ID / IOEXP_TYPE / { Chan_ID, Chip_addr, Read_offset, Write_offset, config_offset, data_default, conf_default } */ - {0, IOEXP_TYPE_MAGINOLIA_NAB, { {2, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {2, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, }, /* addr[1] = I/O Expander N B */ - }, - {1, IOEXP_TYPE_MAGINOLIA_NAB, { {3, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {3, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, }, /* addr[1] = I/O Expander N B */ - }, - {2, IOEXP_TYPE_MAGINOLIA_NAB, { {4, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {4, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, }, /* addr[1] = I/O Expander N B */ - }, - {3, IOEXP_TYPE_MAGINOLIA_4AB, { {5, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander 4 A */ - {5, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xf0, 0xff}, {0xf0, 0xff}, }, }, /* addr[1] = I/O Expander 4 B */ - }, - {4, IOEXP_TYPE_MAGINOLIA_NAB, { {6, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {6, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, }, /* addr[1] = I/O Expander N B */ - }, - {5, IOEXP_TYPE_MAGINOLIA_NAB, { {7, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {7, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, }, /* addr[1] = I/O Expander N B */ - }, - {6, IOEXP_TYPE_MAGINOLIA_7AB, { {8, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[0] = I/O Expander 7 A */ - {8, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xf0, 0x33}, }, }, /* addr[1] = I/O Expander 7 B */ - }, -}; - -struct inv_port_layout_s magnolia_port_layout[] = { - /* Port_ID / Chan_ID / IOEXP_ID / IOEXP_VIRT_OFFSET / TRANSCEIVER_TYPE / CHIP_TYPE / LANE_ID */ - { 0, 10, 0, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 16} }, - { 1, 11, 0, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 15} }, - { 2, 12, 0, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 14} }, - { 3, 13, 0, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 13} }, - { 4, 14, 0, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 24} }, - { 5, 15, 0, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 23} }, - { 6, 16, 0, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 22} }, - { 7, 17, 0, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 21} }, - { 8, 18, 1, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 28} }, - { 9, 19, 1, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 27} }, - {10, 20, 1, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 26} }, - {11, 21, 1, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 25} }, - {12, 22, 1, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 32} }, - {13, 23, 1, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 31} }, - {14, 24, 1, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 30} }, - {15, 25, 1, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 29} }, - {16, 26, 2, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 48} }, - {17, 27, 2, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 47} }, - {18, 28, 2, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 46} }, - {19, 29, 2, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 45} }, - {20, 30, 2, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 52} }, - {21, 31, 2, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 51} }, - {22, 32, 2, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 50} }, - {23, 33, 2, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 49} }, - {24, 34, 3, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 56} }, - {25, 35, 3, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 55} }, - {26, 36, 3, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 54} }, - {27, 37, 3, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 53} }, - {28, 38, 3, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 60} }, - {29, 39, 3, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 59} }, - {30, 40, 3, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 58} }, - {31, 41, 3, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 57} }, - {32, 42, 4, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 64} }, - {33, 43, 4, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 63} }, - {34, 44, 4, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 62} }, - {35, 45, 4, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 61} }, - {36, 46, 4, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 68} }, - {37, 47, 4, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 67} }, - {38, 48, 4, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 66} }, - {39, 49, 4, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 65} }, - {40, 50, 5, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 72} }, - {41, 51, 5, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 71} }, - {42, 52, 5, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 70} }, - {43, 53, 5, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 69} }, - {44, 54, 5, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 76} }, - {45, 55, 5, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 75} }, - {46, 56, 5, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 74} }, - {47, 57, 5, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 73} }, - {48, 58, 6, 0, TRANSVR_TYPE_QSFP, CHIP_TYPE_MAGNOLIA, { 81, 82, 83, 84} }, - {49, 59, 6, 1, TRANSVR_TYPE_QSFP, CHIP_TYPE_MAGNOLIA, { 77, 78, 79, 80} }, - {50, 60, 6, 2, TRANSVR_TYPE_QSFP, CHIP_TYPE_MAGNOLIA, { 97, 98, 99,100} }, - {51, 61, 6, 3, TRANSVR_TYPE_QSFP, CHIP_TYPE_MAGNOLIA, {101,102,103,104} }, - {52, 62, 6, 4, TRANSVR_TYPE_QSFP, CHIP_TYPE_MAGNOLIA, {105,106,107,108} }, - {53, 63, 6, 5, TRANSVR_TYPE_QSFP, CHIP_TYPE_MAGNOLIA, {109,110,111,112} }, -}; -#endif - - -/* ========================================== - * Redwood Layout configuration - * ========================================== - */ -#ifdef SWPS_REDWOOD -unsigned redwood_gpio_rest_mux = MUX_RST_GPIO_48_PCA9548; - -struct inv_ioexp_layout_s redwood_ioexp_layout[] = { - /* IOEXP_ID / IOEXP_TYPE / { Chan_ID, Chip_addr, Read_offset, Write_offset, config_offset, data_default, conf_default } */ - {0, IOEXP_TYPE_REDWOOD_P01P08, { {4, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[0] = I/O Expander 1-4 A */ - {4, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[1] = I/O Expander 1-4 B */ - {0, 0x25, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 5 B */ - }, - {1, IOEXP_TYPE_REDWOOD_P09P16, { {5, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[0] = I/O Expander 1-4 A */ - {5, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[1] = I/O Expander 1-4 B */ - {0, 0x25, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 5 B */ - }, - {2, IOEXP_TYPE_REDWOOD_P01P08, { {2, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[0] = I/O Expander 1-4 A */ - {2, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[1] = I/O Expander 1-4 B */ - {0, 0x24, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 5 B */ - }, - {3, IOEXP_TYPE_REDWOOD_P09P16, { {3, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[0] = I/O Expander 1-4 A */ - {3, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[1] = I/O Expander 1-4 B */ - {0, 0x24, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 5 B */ - }, -}; - -struct inv_port_layout_s redwood_port_layout[] = { - /* Port_ID / Chan_ID / IOEXP_ID / IOEXP_VIRT_OFFSET / TRANSCEIVER_TYPE / CHIP_TYPE / LANE_ID */ - { 0, 22, 0, 0, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 1, 2, 3, 4} }, - { 1, 23, 0, 1, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 5, 6, 7, 8} }, - { 2, 24, 0, 2, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 9, 10, 11, 12} }, - { 3, 25, 0, 3, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 13, 14, 15, 16} }, - { 4, 26, 0, 4, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 17, 18, 19, 20} }, - { 5, 27, 0, 5, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 21, 22, 23, 24} }, - { 6, 28, 0, 6, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 25, 26, 27, 28} }, - { 7, 29, 0, 7, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 29, 30, 31, 32} }, - { 8, 30, 1, 0, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 33, 34, 35, 36} }, - { 9, 31, 1, 1, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 37, 38, 39, 40} }, - {10, 32, 1, 2, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 41, 42, 43, 44} }, - {11, 33, 1, 3, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 45, 46, 47, 48} }, - {12, 34, 1, 4, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 49, 50, 51, 52} }, - {13, 35, 1, 5, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 53, 54, 55, 56} }, - {14, 36, 1, 6, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 57, 58, 59, 60} }, - {15, 37, 1, 7, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 61, 62, 63, 64} }, - {16, 6, 2, 0, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 65, 66, 67, 68} }, - {17, 7, 2, 1, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 69, 70, 71, 72} }, - {18, 8, 2, 2, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 73, 74, 75, 76} }, - {19, 9, 2, 3, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 77, 78, 79, 80} }, - {20, 10, 2, 4, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 81, 82, 83, 84} }, - {21, 11, 2, 5, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 85, 86, 87, 88} }, - {22, 12, 2, 6, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 89, 90, 91, 92} }, - {23, 13, 2, 7, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 93, 94, 95, 96} }, - {24, 14, 3, 0, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 97, 98, 99,100} }, - {25, 15, 3, 1, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {101,102,103,104} }, - {26, 16, 3, 2, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {105,106,107,108} }, - {27, 17, 3, 3, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {109,110,111,112} }, - {28, 18, 3, 4, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {113,114,115,116} }, - {29, 19, 3, 5, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {117,118,119,120} }, - {30, 20, 3, 6, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {121,122,123,124} }, - {31, 21, 3, 7, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {125,126,127,128} }, -}; -#endif - - -/* ========================================== - * Hudson32i Layout configuration - * ========================================== - */ -#ifdef SWPS_HUDSON32I_GA -unsigned hudsin32iga_gpio_rest_mux = MUX_RST_GPIO_48_PCA9548; - -struct inv_ioexp_layout_s hudson32iga_ioexp_layout[] = { - /* IOEXP_ID / IOEXP_TYPE / { Chan_ID, Chip_addr, Read_offset, Write_offset, config_offset, data_default, conf_default } */ - {0, IOEXP_TYPE_HUDSON32IGA_P01P08, { {2, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[0] = I/O Expander A */ - {2, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[1] = I/O Expander B */ - {0, 0x24, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 0x24 */ - }, - {1, IOEXP_TYPE_HUDSON32IGA_P09P16, { {3, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[0] = I/O Expander A */ - {3, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[1] = I/O Expander B */ - {0, 0x24, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 0x24 */ - }, - {2, IOEXP_TYPE_HUDSON32IGA_P01P08, { {4, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[0] = I/O Expander A */ - {4, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[1] = I/O Expander B */ - {0, 0x25, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 0x25 */ - }, - {3, IOEXP_TYPE_HUDSON32IGA_P09P16, { {5, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[0] = I/O Expander A */ - {5, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[1] = I/O Expander B */ - {0, 0x25, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 0x25 */ - }, -}; - -struct inv_port_layout_s hudson32iga_port_layout[] = { - /* Port_ID / Chan_ID / IOEXP_ID / IOEXP_VIRT_OFFSET / TRANSCEIVER_TYPE / CHIP_TYPE / LANE_ID */ - { 0, 6, 0, 0, TRANSVR_TYPE_QSFP_PLUS, CHIP_TYPE_MAGNOLIA, { 1, 2, 3, 4} }, - { 1, 7, 0, 1, TRANSVR_TYPE_QSFP_PLUS, CHIP_TYPE_MAGNOLIA, { 5, 6, 7, 8} }, - { 2, 8, 0, 2, TRANSVR_TYPE_QSFP_PLUS, CHIP_TYPE_MAGNOLIA, { 9, 10, 11, 12} }, - { 3, 9, 0, 3, TRANSVR_TYPE_QSFP_PLUS, CHIP_TYPE_MAGNOLIA, { 13, 14, 15, 16} }, - { 4, 10, 0, 4, TRANSVR_TYPE_QSFP_PLUS, CHIP_TYPE_MAGNOLIA, { 17, 18, 19, 20} }, - { 5, 11, 0, 5, TRANSVR_TYPE_QSFP_PLUS, CHIP_TYPE_MAGNOLIA, { 21, 22, 23, 24} }, - { 6, 12, 0, 6, TRANSVR_TYPE_QSFP_PLUS, CHIP_TYPE_MAGNOLIA, { 25, 26, 27, 28} }, - { 7, 13, 0, 7, TRANSVR_TYPE_QSFP_PLUS, CHIP_TYPE_MAGNOLIA, { 29, 30, 31, 32} }, - { 8, 14, 1, 0, TRANSVR_TYPE_QSFP_PLUS, CHIP_TYPE_MAGNOLIA, { 33, 34, 35, 36} }, - { 9, 15, 1, 1, TRANSVR_TYPE_QSFP_PLUS, CHIP_TYPE_MAGNOLIA, { 37, 38, 39, 40} }, - {10, 16, 1, 2, TRANSVR_TYPE_QSFP_PLUS, CHIP_TYPE_MAGNOLIA, { 41, 42, 43, 44} }, - {11, 17, 1, 3, TRANSVR_TYPE_QSFP_PLUS, CHIP_TYPE_MAGNOLIA, { 45, 46, 47, 48} }, - {12, 18, 1, 4, TRANSVR_TYPE_QSFP_PLUS, CHIP_TYPE_MAGNOLIA, { 49, 50, 51, 52} }, - {13, 19, 1, 5, TRANSVR_TYPE_QSFP_PLUS, CHIP_TYPE_MAGNOLIA, { 53, 54, 55, 56} }, - {14, 20, 1, 6, TRANSVR_TYPE_QSFP_PLUS, CHIP_TYPE_MAGNOLIA, { 57, 58, 59, 60} }, - {15, 21, 1, 7, TRANSVR_TYPE_QSFP_PLUS, CHIP_TYPE_MAGNOLIA, { 61, 62, 63, 64} }, - {16, 22, 2, 0, TRANSVR_TYPE_QSFP_PLUS, CHIP_TYPE_MAGNOLIA, { 65, 66, 67, 68} }, - {17, 23, 2, 1, TRANSVR_TYPE_QSFP_PLUS, CHIP_TYPE_MAGNOLIA, { 69, 70, 71, 72} }, - {18, 24, 2, 2, TRANSVR_TYPE_QSFP_PLUS, CHIP_TYPE_MAGNOLIA, { 73, 74, 75, 76} }, - {19, 25, 2, 3, TRANSVR_TYPE_QSFP_PLUS, CHIP_TYPE_MAGNOLIA, { 77, 78, 79, 80} }, - {20, 26, 2, 4, TRANSVR_TYPE_QSFP_PLUS, CHIP_TYPE_MAGNOLIA, { 81, 82, 83, 84} }, - {21, 27, 2, 5, TRANSVR_TYPE_QSFP_PLUS, CHIP_TYPE_MAGNOLIA, { 85, 86, 87, 88} }, - {22, 28, 2, 6, TRANSVR_TYPE_QSFP_PLUS, CHIP_TYPE_MAGNOLIA, { 89, 90, 91, 92} }, - {23, 29, 2, 7, TRANSVR_TYPE_QSFP_PLUS, CHIP_TYPE_MAGNOLIA, { 93, 94, 95, 96} }, - {24, 30, 3, 0, TRANSVR_TYPE_QSFP_PLUS, CHIP_TYPE_MAGNOLIA, { 97, 98, 99,100} }, - {25, 31, 3, 1, TRANSVR_TYPE_QSFP_PLUS, CHIP_TYPE_MAGNOLIA, {101,102,103,104} }, - {26, 32, 3, 2, TRANSVR_TYPE_QSFP_PLUS, CHIP_TYPE_MAGNOLIA, {105,106,107,108} }, - {27, 33, 3, 3, TRANSVR_TYPE_QSFP_PLUS, CHIP_TYPE_MAGNOLIA, {109,110,111,112} }, - {28, 34, 3, 4, TRANSVR_TYPE_QSFP_PLUS, CHIP_TYPE_MAGNOLIA, {113,114,115,116} }, - {29, 35, 3, 5, TRANSVR_TYPE_QSFP_PLUS, CHIP_TYPE_MAGNOLIA, {117,118,119,120} }, - {30, 36, 3, 6, TRANSVR_TYPE_QSFP_PLUS, CHIP_TYPE_MAGNOLIA, {121,122,123,124} }, - {31, 37, 3, 7, TRANSVR_TYPE_QSFP_PLUS, CHIP_TYPE_MAGNOLIA, {125,126,127,128} }, -}; -#endif - - -/* ========================================== - * Spruce Layout configuration - * ========================================== - */ -#ifdef SWPS_SPRUCE -unsigned spruce_gpio_rest_mux = MUX_RST_GPIO_48_PCA9548; - -struct inv_ioexp_layout_s spruce_ioexp_layout[] = { - /* IOEXP_ID / IOEXP_TYPE / { Chan_ID, Chip_addr, Read_offset, Write_offset, config_offset, data_default, conf_default } */ - {0, IOEXP_TYPE_SPRUCE_7AB, { {2, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[0] = I/O Expander 7A */ - {2, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xf0, 0x33}, }, }, /* addr[2] = I/O Expander 7B */ - }, -}; - -struct inv_port_layout_s spruce_port_layout[] = { - /* Port_ID / Chan_ID / IOEXP_ID / IOEXP_VIRT_OFFSET / TRANSCEIVER_TYPE / CHIP_TYPE / LANE_ID */ - { 0, 6, 0, 0, TRANSVR_TYPE_QSFP_PLUS, CHIP_TYPE_MAGNOLIA, { 81, 82, 83, 84} }, - { 1, 7, 0, 1, TRANSVR_TYPE_QSFP_PLUS, CHIP_TYPE_MAGNOLIA, { 77, 78, 79, 80} }, - { 2, 8, 0, 2, TRANSVR_TYPE_QSFP_PLUS, CHIP_TYPE_MAGNOLIA, { 97, 98, 99,100} }, - { 3, 9, 0, 3, TRANSVR_TYPE_QSFP_PLUS, CHIP_TYPE_MAGNOLIA, {101,102,103,104} }, - { 4, 10, 0, 4, TRANSVR_TYPE_QSFP_PLUS, CHIP_TYPE_MAGNOLIA, {105,106,107,108} }, - { 5, 11, 0, 5, TRANSVR_TYPE_QSFP_PLUS, CHIP_TYPE_MAGNOLIA, {109,110,111,112} }, -}; -#endif - - -/* ========================================== - * Cypress Layout configuration (Inventec version [Up->Down]) - * ========================================== - */ -#ifdef SWPS_CYPRESS_GA1 -unsigned cypress_ga1_gpio_rest_mux = MUX_RST_GPIO_69_PCA9548; - -struct inv_ioexp_layout_s cypress_ga1_ioexp_layout[] = { - /* IOEXP_ID / IOEXP_TYPE / { Chan_ID, Chip_addr, Read_offset, Write_offset, config_offset, data_default, conf_default } */ - {0, IOEXP_TYPE_SFP_8P_LAYOUT_1, { {2, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {2, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {2, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {1, IOEXP_TYPE_SFP_8P_LAYOUT_1, { {3, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {3, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {3, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {2, IOEXP_TYPE_SFP_8P_LAYOUT_1, { {4, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {4, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {4, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {3, IOEXP_TYPE_SFP_8P_LAYOUT_1, { {5, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {5, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {5, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {4, IOEXP_TYPE_SFP_8P_LAYOUT_1, { {6, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {6, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {6, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {5, IOEXP_TYPE_SFP_8P_LAYOUT_1, { {7, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {7, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {7, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {6, IOEXP_TYPE_CYPRESS_7ABC, { {8, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xc0, 0xc0}, }, /* addr[0] = I/O Expander 7 A */ - {8, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xc0, 0xc0}, {0xff, 0xc0}, }, /* addr[1] = I/O Expander 7 B */ - {8, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 7 C */ - }, -}; - -struct inv_port_layout_s cypress_ga1_port_layout[] = { - /* Port_ID / Chan_ID / IOEXP_ID / IOEXP_VIRT_OFFSET / TRANSCEIVER_TYPE / CHIP_TYPE / LANE_ID */ - { 0, 10, 0, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 1} }, - { 1, 11, 0, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 2} }, - { 2, 12, 0, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 3} }, - { 3, 13, 0, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 4} }, - { 4, 14, 0, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 5} }, - { 5, 15, 0, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 6} }, - { 6, 16, 0, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 7} }, - { 7, 17, 0, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 8} }, - { 8, 18, 1, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 9} }, - { 9, 19, 1, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 10} }, - {10, 20, 1, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 11} }, - {11, 21, 1, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 12} }, - {12, 22, 1, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 21} }, - {13, 23, 1, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 22} }, - {14, 24, 1, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 23} }, - {15, 25, 1, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 24} }, - {16, 26, 2, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 33} }, - {17, 27, 2, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 34} }, - {18, 28, 2, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 35} }, - {19, 29, 2, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 36} }, - {20, 30, 2, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 37} }, - {21, 31, 2, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 38} }, - {22, 32, 2, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 39} }, - {23, 33, 2, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 40} }, - {24, 34, 3, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 41} }, - {25, 35, 3, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 42} }, - {26, 36, 3, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 43} }, - {27, 37, 3, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 44} }, - {28, 38, 3, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 49} }, - {29, 39, 3, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 50} }, - {30, 40, 3, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 51} }, - {31, 41, 3, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 52} }, - {32, 42, 4, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 53} }, - {33, 43, 4, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 54} }, - {34, 44, 4, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 55} }, - {35, 45, 4, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 56} }, - {36, 46, 4, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 65} }, - {37, 47, 4, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 66} }, - {38, 48, 4, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 67} }, - {39, 49, 4, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 68} }, - {40, 50, 5, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 69} }, - {41, 51, 5, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 70} }, - {42, 52, 5, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 71} }, - {43, 53, 5, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 72} }, - {44, 54, 5, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 81} }, - {45, 55, 5, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 82} }, - {46, 56, 5, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 83} }, - {47, 57, 5, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 84} }, - {48, 58, 6, 0, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 97, 98, 99,100} }, - {49, 59, 6, 1, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 85, 86, 87, 88} }, - {50, 60, 6, 2, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {101,102,103,104} }, - {51, 61, 6, 3, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {105,106,107,108} }, - {52, 62, 6, 4, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {109,110,111,112} }, - {53, 63, 6, 5, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {117,118,119,120} }, -}; -#endif - - -/* ========================================== - * Cypress Layout configuration (Inventec version [Down->Up]) - * ========================================== - */ -#ifdef SWPS_CYPRESS_GA2 -unsigned cypress_ga2_gpio_rest_mux = MUX_RST_GPIO_FORCE_HEDERA; - -struct inv_ioexp_layout_s cypress_ga2_ioexp_layout[] = { - /* IOEXP_ID / IOEXP_TYPE / { Chan_ID, Chip_addr, Read_offset, Write_offset, config_offset, data_default, conf_default } */ - {0, IOEXP_TYPE_SFP_8P_LAYOUT_1, { {2, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {2, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {2, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {1, IOEXP_TYPE_SFP_8P_LAYOUT_1, { {3, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {3, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {3, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {2, IOEXP_TYPE_SFP_8P_LAYOUT_1, { {4, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {4, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {4, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {3, IOEXP_TYPE_SFP_8P_LAYOUT_1, { {5, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {5, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {5, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {4, IOEXP_TYPE_SFP_8P_LAYOUT_1, { {6, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {6, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {6, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {5, IOEXP_TYPE_SFP_8P_LAYOUT_1, { {7, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {7, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {7, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {6, IOEXP_TYPE_CYPRESS_7ABC, { {8, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xc0, 0xc0}, }, /* addr[0] = I/O Expander 7 A */ - {8, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xc0, 0xc0}, {0xff, 0xc0}, }, /* addr[1] = I/O Expander 7 B */ - {8, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 7 C */ - }, -}; - -struct inv_port_layout_s cypress_ga2_port_layout[] = { - /* Port_ID / Chan_ID / IOEXP_ID / IOEXP_VIRT_OFFSET / TRANSCEIVER_TYPE / CHIP_TYPE / LANE_ID */ - { 0, 11, 0, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 2} }, - { 1, 10, 0, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 1} }, - { 2, 13, 0, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 4} }, - { 3, 12, 0, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 3} }, - { 4, 15, 0, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 6} }, - { 5, 14, 0, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 5} }, - { 6, 17, 0, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 8} }, - { 7, 16, 0, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 7} }, - { 8, 19, 1, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 10} }, - { 9, 18, 1, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 9} }, - {10, 21, 1, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 12} }, - {11, 20, 1, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 11} }, - {12, 23, 1, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 22} }, - {13, 22, 1, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 21} }, - {14, 25, 1, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 24} }, - {15, 24, 1, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 23} }, - {16, 27, 2, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 34} }, - {17, 26, 2, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 33} }, - {18, 29, 2, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 36} }, - {19, 28, 2, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 35} }, - {20, 31, 2, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 38} }, - {21, 30, 2, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 37} }, - {22, 33, 2, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 40} }, - {23, 32, 2, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 39} }, - {24, 35, 3, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 42} }, - {25, 34, 3, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 41} }, - {26, 37, 3, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 44} }, - {27, 36, 3, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 43} }, - {28, 39, 3, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 50} }, - {29, 38, 3, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 49} }, - {30, 41, 3, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 52} }, - {31, 40, 3, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 51} }, - {32, 43, 4, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 54} }, - {33, 42, 4, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 53} }, - {34, 45, 4, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 56} }, - {35, 44, 4, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 55} }, - {36, 47, 4, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 66} }, - {37, 46, 4, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 65} }, - {38, 49, 4, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 68} }, - {39, 48, 4, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 67} }, - {40, 51, 5, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 70} }, - {41, 50, 5, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 69} }, - {42, 53, 5, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 72} }, - {43, 52, 5, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 71} }, - {44, 55, 5, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 82} }, - {45, 54, 5, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 81} }, - {46, 57, 5, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 84} }, - {47, 56, 5, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 83} }, - {48, 59, 6, 1, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 85, 86, 87, 88} }, - {49, 58, 6, 0, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 97, 98, 99,100} }, - {50, 61, 6, 3, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {105,106,107,108} }, - {51, 60, 6, 2, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {101,102,103,104} }, - {52, 63, 6, 5, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {117,118,119,120} }, - {53, 62, 6, 4, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {109,110,111,112} }, -}; -#endif - - -/* ========================================== - * Cypress Layout configuration (C1 version) - * ========================================== - */ -#ifdef SWPS_CYPRESS_BAI -unsigned cypress_b_gpio_rest_mux = MUX_RST_GPIO_FORCE_HEDERA; - -struct inv_ioexp_layout_s cypress_b_ioexp_layout[] = { - /* IOEXP_ID / IOEXP_TYPE / { Chan_ID, Chip_addr, Read_offset, Write_offset, config_offset, data_default, conf_default } */ - {0, IOEXP_TYPE_SFP_8P_LAYOUT_1, { {2, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {2, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {2, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {1, IOEXP_TYPE_SFP_8P_LAYOUT_1, { {3, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {3, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {3, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {2, IOEXP_TYPE_SFP_8P_LAYOUT_1, { {4, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {4, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {4, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {3, IOEXP_TYPE_SFP_8P_LAYOUT_1, { {5, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {5, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {5, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {4, IOEXP_TYPE_SFP_8P_LAYOUT_1, { {6, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {6, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {6, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {5, IOEXP_TYPE_SFP_8P_LAYOUT_1, { {7, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {7, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {7, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {6, IOEXP_TYPE_CYPRESS_7ABC, { {8, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xc0, 0xc0}, }, /* addr[0] = I/O Expander 7 A */ - {8, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xc0, 0xc0}, {0xff, 0xc0}, }, /* addr[1] = I/O Expander 7 B */ - {8, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 7 C */ - }, -}; - -struct inv_port_layout_s cypress_b_port_layout[] = { - /* Port_ID / Chan_ID / IOEXP_ID / IOEXP_VIRT_OFFSET / TRANSCEIVER_TYPE / CHIP_TYPE / LANE_ID */ - { 1, 11, 0, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 2} }, - { 2, 10, 0, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 1} }, - { 3, 13, 0, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 4} }, - { 4, 12, 0, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 3} }, - { 5, 15, 0, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 6} }, - { 6, 14, 0, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 5} }, - { 7, 17, 0, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 8} }, - { 8, 16, 0, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 7} }, - { 9, 19, 1, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 10} }, - {10, 18, 1, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 9} }, - {11, 21, 1, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 12} }, - {12, 20, 1, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 11} }, - {13, 23, 1, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 22} }, - {14, 22, 1, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 21} }, - {15, 25, 1, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 24} }, - {16, 24, 1, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 23} }, - {17, 27, 2, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 34} }, - {18, 26, 2, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 33} }, - {19, 29, 2, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 36} }, - {20, 28, 2, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 35} }, - {21, 31, 2, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 38} }, - {22, 30, 2, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 37} }, - {23, 33, 2, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 40} }, - {24, 32, 2, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 39} }, - {25, 35, 3, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 42} }, - {26, 34, 3, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 41} }, - {27, 37, 3, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 44} }, - {28, 36, 3, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 43} }, - {29, 39, 3, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 50} }, - {30, 38, 3, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 49} }, - {31, 41, 3, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 52} }, - {32, 40, 3, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 51} }, - {33, 43, 4, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 54} }, - {34, 42, 4, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 53} }, - {35, 45, 4, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 56} }, - {36, 44, 4, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 55} }, - {37, 47, 4, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 66} }, - {38, 46, 4, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 65} }, - {39, 49, 4, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 68} }, - {40, 48, 4, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 67} }, - {41, 51, 5, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 70} }, - {42, 50, 5, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 69} }, - {43, 53, 5, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 72} }, - {44, 52, 5, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 71} }, - {45, 55, 5, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 82} }, - {46, 54, 5, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 81} }, - {47, 57, 5, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 84} }, - {48, 56, 5, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 83} }, - {49, 59, 6, 1, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 85, 86, 87, 88} }, - {50, 58, 6, 0, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 97, 98, 99,100} }, - {51, 61, 6, 3, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {105,106,107,108} }, - {52, 60, 6, 2, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {101,102,103,104} }, - {53, 63, 6, 5, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {117,118,119,120} }, - {54, 62, 6, 4, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {109,110,111,112} }, -}; -#endif - - -/* ========================================== - * Redwood_fsl Layout configuration - * ========================================== - */ -#ifdef SWPS_REDWOOD_FSL -unsigned redwood_fsl_gpio_rest_mux = MUX_RST_GPIO_48_PCA9548; - -struct inv_ioexp_layout_s redwood_fsl_ioexp_layout[] = { - /* IOEXP_ID / IOEXP_TYPE / { Chan_ID, Chip_addr, Read_offset, Write_offset, config_offset, data_default, conf_default } */ - {0, IOEXP_TYPE_REDWOOD_P01P08, { {4, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[0] = I/O Expander 1-4 A */ - {4, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[1] = I/O Expander 1-4 B */ - {0, 0x25, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 5 B */ - }, - {1, IOEXP_TYPE_REDWOOD_P09P16, { {5, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[0] = I/O Expander 1-4 A */ - {5, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[1] = I/O Expander 1-4 B */ - {0, 0x25, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 5 B */ - }, - {2, IOEXP_TYPE_REDWOOD_P01P08, { {2, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[0] = I/O Expander 1-4 A */ - {2, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[1] = I/O Expander 1-4 B */ - {0, 0x24, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 5 B */ - }, - {3, IOEXP_TYPE_REDWOOD_P09P16, { {3, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[0] = I/O Expander 1-4 A */ - {3, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[1] = I/O Expander 1-4 B */ - {0, 0x24, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 5 B */ - }, -}; - - -struct inv_port_layout_s redwood_fsl_port_layout[] = { - /* Port_ID / Chan_ID / IOEXP_ID / IOEXP_VIRT_OFFSET / TRANSCEIVER_TYPE / CHIP_TYPE / LANE_ID */ - { 0, 22, 0, 0, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 1, 2, 3, 4} }, - { 1, 23, 0, 1, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 5, 6, 7, 8} }, - { 2, 24, 0, 2, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 9, 10, 11, 12} }, - { 3, 25, 0, 3, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 13, 14, 15, 16} }, - { 4, 26, 0, 4, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 17, 18, 19, 20} }, - { 5, 27, 0, 5, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 21, 22, 23, 24} }, - { 6, 28, 0, 6, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 25, 26, 27, 28} }, - { 7, 29, 0, 7, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 29, 30, 31, 32} }, - { 8, 30, 1, 0, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 33, 34, 35, 36} }, - { 9, 31, 1, 1, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 37, 38, 39, 40} }, - {10, 32, 1, 2, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 41, 42, 43, 44} }, - {11, 33, 1, 3, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 45, 46, 47, 48} }, - {12, 34, 1, 4, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 49, 50, 51, 52} }, - {13, 35, 1, 5, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 53, 54, 55, 56} }, - {14, 36, 1, 6, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 57, 58, 59, 60} }, - {15, 37, 1, 7, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 61, 62, 63, 64} }, - {16, 6, 2, 0, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 65, 66, 67, 68} }, - {17, 7, 2, 1, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 69, 70, 71, 72} }, - {18, 8, 2, 2, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 73, 74, 75, 76} }, - {19, 9, 2, 3, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 77, 78, 79, 80} }, - {20, 10, 2, 4, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 81, 82, 83, 84} }, - {21, 11, 2, 5, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 85, 86, 87, 88} }, - {22, 12, 2, 6, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 89, 90, 91, 92} }, - {23, 13, 2, 7, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 93, 94, 95, 96} }, - {24, 14, 3, 0, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 97, 98, 99,100} }, - {25, 15, 3, 1, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {101,102,103,104} }, - {26, 16, 3, 2, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {105,106,107,108} }, - {27, 17, 3, 3, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {109,110,111,112} }, - {28, 18, 3, 4, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {113,114,115,116} }, - {29, 19, 3, 5, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {117,118,119,120} }, - {30, 20, 3, 6, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {121,122,123,124} }, - {31, 21, 3, 7, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {125,126,127,128} }, -}; -#endif - - -/* ========================================== - * Tahoe Layout configuration - * ========================================== - */ -#ifdef SWPS_TAHOE -unsigned tahoe_gpio_rest_mux = MUX_RST_GPIO_249_PCA9548; - -struct inv_ioexp_layout_s tahoe_ioexp_layout[] = { - /* IOEXP_ID / IOEXP_TYPE / { Chan_ID, Chip_addr, Read_offset, Write_offset, config_offset, data_default, conf_default } */ - {0, IOEXP_TYPE_TAHOE_6ABC, { {7, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xce, 0xb9}, {0x18, 0xe3}, }, /* addr[0] = I/O Expander 6 A */ - {7, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xce, 0xb9}, {0x18, 0xe3}, }, /* addr[1] = I/O Expander 6 B */ - {7, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xce, 0xb9}, {0x18, 0xe3}, }, }, /* addr[2] = I/O Expander 6 C */ - }, - {1, IOEXP_TYPE_TAHOE_5A, { {6, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xce, 0xb9}, {0x18, 0xe3}, }, }, /* addr[0] = I/O Expander 5 A */ - }, -}; - - -struct inv_port_layout_s tahoe_port_layout[] = { - /* Port_ID / Chan_ID / IOEXP_ID / IOEXP_VIRT_OFFSET / TRANSCEIVER_TYPE / CHIP_TYPE / LANE_ID */ - { 0, 12, 1, 2, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 65, 66, 67, 68} }, - { 1, 11, 1, 1, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 53, 54, 55, 56} }, - { 2, 22, 0, 5, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 69, 70, 71, 72} }, - { 3, 21, 0, 4, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 81, 82, 83, 84} }, - { 4, 24, 0, 7, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 97, 98, 99, 100} }, - { 5, 23, 0, 6, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 85, 86, 87, 88} }, - { 6, 18, 0, 1, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {101, 102, 103, 104} }, - { 7, 17, 0, 0, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {105, 106, 107, 108} }, - { 8, 20, 0, 3, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {113, 114, 115, 116} }, - { 9, 19, 0, 2, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {109, 110, 111, 112} }, -}; -#endif - - -/* ========================================== - * Sequoia Layout configuration - * ========================================== - */ -#ifdef SWPS_SEQUOIA -unsigned sequoia_gpio_rest_mux = MUX_RST_GPIO_69_PCA9548; - -struct inv_ioexp_layout_s sequoia_ioexp_layout[] = { - /* IOEXP_ID / IOEXP_TYPE / { Chan_ID, Chip_addr, Read_offset, Write_offset, config_offset, data_default, conf_default } */ - {0, IOEXP_TYPE_SEQUOIA_NABC, { {1, 0x20, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0x00, 0x00}, }, /* addr[0] = I/O Expander 0 A */ - {1, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0xff}, }, /* addr[1] = I/O Expander 0 B */ - {1, 0x22, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 0 C */ - }, - {1, IOEXP_TYPE_SEQUOIA_NABC, { {2, 0x20, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0x00, 0x00}, }, /* addr[0] = I/O Expander 1 A */ - {2, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0xff}, }, /* addr[1] = I/O Expander 1 B */ - {2, 0x22, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 1 C */ - }, - {2, IOEXP_TYPE_SEQUOIA_NABC, { {3, 0x20, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0x00, 0x00}, }, /* addr[0] = I/O Expander 2 A */ - {3, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0xff}, }, /* addr[1] = I/O Expander 2 B */ - {3, 0x22, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 2 C */ - }, - {3, IOEXP_TYPE_SEQUOIA_NABC, { {4, 0x20, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0x00, 0x00}, }, /* addr[0] = I/O Expander 3 A */ - {4, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0xff}, }, /* addr[1] = I/O Expander 3 B */ - {4, 0x22, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 3 C */ - }, - {4, IOEXP_TYPE_SEQUOIA_NABC, { {5, 0x20, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0x00, 0x00}, }, /* addr[0] = I/O Expander 4 A */ - {5, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0xff}, }, /* addr[1] = I/O Expander 4 B */ - {5, 0x22, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 4 C */ - }, - {5, IOEXP_TYPE_SEQUOIA_NABC, { {6, 0x20, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0x00, 0x00}, }, /* addr[0] = I/O Expander 5 A */ - {6, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0xff}, }, /* addr[1] = I/O Expander 5 B */ - {6, 0x22, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 5 C */ - }, - {6, IOEXP_TYPE_SEQUOIA_NABC, { {7, 0x20, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0x00, 0x00}, }, /* addr[0] = I/O Expander 6 A */ - {7, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0xff}, }, /* addr[1] = I/O Expander 6 B */ - {7, 0x22, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 6 C */ - }, - {7, IOEXP_TYPE_SEQUOIA_NABC, { {8, 0x20, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0x00, 0x00}, }, /* addr[0] = I/O Expander 7 A */ - {8, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0xff}, }, /* addr[1] = I/O Expander 7 B */ - {8, 0x22, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 7 C */ - }, -}; - - -struct inv_port_layout_s sequoia_port_layout[] = { - /* Port_ID / Chan_ID / IOEXP_ID / IOEXP_VIRT_OFFSET / TRANSCEIVER_TYPE / CHIP_TYPE / LANE_ID */ - { 0, 9, 0, 0, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 9, 10, 11, 12} }, - { 1, 10, 0, 1, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 1, 2, 3, 4} }, - { 2, 11, 0, 2, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 25, 26, 27, 28} }, - { 3, 12, 0, 3, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 17, 18, 19, 20} }, - { 4, 13, 0, 4, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 41, 42, 43, 44} }, - { 5, 14, 0, 5, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 33, 34, 35, 36} }, - { 6, 15, 0, 6, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 57, 58, 59, 60} }, - { 7, 16, 0, 7, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 49, 50, 51, 52} }, - { 8, 17, 1, 0, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 73, 74, 75, 76} }, - { 9, 18, 1, 1, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 65, 66, 67, 68} }, - {10, 19, 1, 2, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 89, 90, 91, 92} }, - {11, 20, 1, 3, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 81, 82, 83, 84} }, - {12, 21, 1, 4, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {105, 106, 107, 108} }, - {13, 22, 1, 5, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 97, 98, 99, 100} }, - {14, 23, 1, 6, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {121, 122, 123, 124} }, - {15, 24, 1, 7, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {113, 114, 115, 116} }, - {16, 25, 2, 0, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {137, 138, 139, 140} }, - {17, 26, 2, 1, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {129, 130, 131, 132} }, - {18, 27, 2, 2, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {153, 154, 155, 156} }, - {19, 28, 2, 3, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {145, 146, 147, 148} }, - {20, 29, 2, 4, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {169, 170, 171, 172} }, - {21, 30, 2, 5, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {161, 162, 163, 164} }, - {22, 31, 2, 6, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {185, 186, 187, 188} }, - {23, 32, 2, 7, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {177, 178, 179, 180} }, - {24, 33, 3, 0, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {201, 202, 203, 204} }, - {25, 34, 3, 1, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {193, 194, 195, 196} }, - {26, 35, 3, 2, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {217, 218, 219, 220} }, - {27, 36, 3, 3, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {209, 210, 211, 212} }, - {28, 37, 3, 4, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {233, 234, 235, 236} }, - {29, 38, 3, 5, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {225, 226, 227, 228} }, - {30, 39, 3, 6, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {249, 250, 251, 252} }, - {31, 40, 3, 7, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {241, 242, 243, 244} }, - {32, 44, 4, 3, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 13, 14, 15, 16} }, - {33, 43, 4, 2, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 5, 6, 7, 8} }, - {34, 42, 4, 1, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 29, 30, 31, 32} }, - {35, 41, 4, 0, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 21, 22, 23, 24} }, - {36, 48, 4, 7, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 45, 46, 47, 48} }, - {37, 47, 4, 6, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 37, 38, 39, 40} }, - {38, 46, 4, 5, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 61, 62, 63, 64} }, - {39, 45, 4, 4, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 53, 54, 55, 56} }, - {40, 52, 5, 3, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 77, 78, 79, 80} }, - {41, 51, 5, 2, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 69, 70, 71, 72} }, - {42, 50, 5, 1, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 93, 94, 95, 96} }, - {43, 49, 5, 0, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 85, 86, 87, 88} }, - {44, 56, 5, 7, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {109, 110, 111, 112} }, - {45, 55, 5, 6, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {101, 102, 103, 104} }, - {46, 54, 5, 5, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {125, 126, 127, 128} }, - {47, 53, 5, 4, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {117, 118, 119, 120} }, - {48, 60, 6, 3, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {141, 142, 143, 144} }, - {49, 59, 6, 2, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {133, 134, 135, 136} }, - {50, 58, 6, 1, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {157, 158, 159, 160} }, - {51, 57, 6, 0, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {149, 150, 151, 152} }, - {52, 64, 6, 7, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {173, 174, 175, 176} }, - {53, 63, 6, 6, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {165, 166, 167, 168} }, - {54, 62, 6, 5, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {189, 190, 191, 192} }, - {55, 61, 6, 4, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {181, 182, 183, 184} }, - {56, 68, 7, 3, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {205, 206, 207, 208} }, - {57, 67, 7, 2, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {197, 198, 199, 200} }, - {58, 66, 7, 1, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {221, 222, 223, 224} }, - {59, 65, 7, 0, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {213, 214, 215, 216} }, - {60, 72, 7, 7, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {237, 238, 239, 240} }, - {61, 71, 7, 6, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {229, 230, 231, 232} }, - {62, 70, 7, 5, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {253, 254, 255, 256} }, - {63, 69, 7, 4, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {245, 246, 247, 248} }, -}; -#endif - - -/* ========================================== - * Lavender Layout configuration - * ========================================== - */ -#if (PLATFORM_SETTINGS == PLATFORM_TYPE_LAVENDER_GA) -unsigned lavender_gpio_rest_mux = MUX_RST_GPIO_505_PCA9548; -#elif (PLATFORM_SETTINGS == PLATFORM_TYPE_LAVENDER_ONL) -unsigned lavender_gpio_rest_mux = MUX_RST_GPIO_69_PCA9548; -#endif - -#ifdef SWPS_LAVENDER -struct inv_ioexp_layout_s lavender_ioexp_layout[] = { - /* IOEXP_ID / IOEXP_TYPE / { Chan_ID, Chip_addr, Read_offset, Write_offset, config_offset, data_default, conf_default } */ - {0, IOEXP_TYPE_SEQUOIA_NABC, { { 1, 0x20, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0x00, 0x00}, }, /* addr[0] = I/O Expander 0 A */ - { 1, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0xff}, }, /* addr[1] = I/O Expander 0 B */ - { 1, 0x22, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 0 C */ - }, - {1, IOEXP_TYPE_SEQUOIA_NABC, { { 2, 0x20, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0x00, 0x00}, }, /* addr[0] = I/O Expander 1 A */ - { 2, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0xff}, }, /* addr[1] = I/O Expander 1 B */ - { 2, 0x22, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 1 C */ - }, - {2, IOEXP_TYPE_SEQUOIA_NABC, { { 3, 0x20, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0x00, 0x00}, }, /* addr[0] = I/O Expander 2 A */ - { 3, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0xff}, }, /* addr[1] = I/O Expander 2 B */ - { 3, 0x22, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 2 C */ - }, - {3, IOEXP_TYPE_SEQUOIA_NABC, { { 4, 0x20, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0x00, 0x00}, }, /* addr[0] = I/O Expander 3 A */ - { 4, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0xff}, }, /* addr[1] = I/O Expander 3 B */ - { 4, 0x22, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 3 C */ - }, - {4, IOEXP_TYPE_SEQUOIA_NABC, { { 9, 0x20, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0x00, 0x00}, }, /* addr[0] = I/O Expander 4 A */ - { 9, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0xff}, }, /* addr[1] = I/O Expander 4 B */ - { 9, 0x22, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 4 C */ - }, - {5, IOEXP_TYPE_SEQUOIA_NABC, { {10, 0x20, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0x00, 0x00}, }, /* addr[0] = I/O Expander 5 A */ - {10, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0xff}, }, /* addr[1] = I/O Expander 5 B */ - {10, 0x22, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 5 C */ - }, - {6, IOEXP_TYPE_SEQUOIA_NABC, { {11, 0x20, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0x00, 0x00}, }, /* addr[0] = I/O Expander 6 A */ - {11, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0xff}, }, /* addr[1] = I/O Expander 6 B */ - {11, 0x22, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 6 C */ - }, - {7, IOEXP_TYPE_SEQUOIA_NABC, { {12, 0x20, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0x00, 0x00}, }, /* addr[0] = I/O Expander 7 A */ - {12, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0xff}, }, /* addr[1] = I/O Expander 7 B */ - {12, 0x22, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 7 C */ - }, - {8, IOEXP_TYPE_LAVENDER_P65, { { 5, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xF6, 0xff}, {0xF8, 0xff}, }, }, /* addr[0] = I/O Expander CPU */ - }, -}; - - -struct inv_port_layout_s lavender_port_layout[] = { - /* Port_ID / Chan_ID / IOEXP_ID / IOEXP_VIRT_OFFSET / TRANSCEIVER_TYPE / CHIP_TYPE / LANE_ID */ - { 0, 17, 0, 0, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {188, 189, 190, 191} }, - { 1, 18, 0, 1, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {184, 185, 186, 187} }, - { 2, 19, 0, 2, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {180, 181, 182, 183} }, - { 3, 20, 0, 3, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {176, 177, 178, 179} }, - { 4, 21, 0, 4, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {172, 173, 174, 175} }, - { 5, 22, 0, 5, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {168, 169, 170, 171} }, - { 6, 23, 0, 6, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {164, 165, 166, 167} }, - { 7, 24, 0, 7, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {160, 161, 162, 163} }, - { 8, 25, 1, 0, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {156, 157, 158, 159} }, - { 9, 26, 1, 1, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {152, 153, 154, 155} }, - {10, 27, 1, 2, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {148, 149, 150, 151} }, - {11, 28, 1, 3, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {144, 145, 146, 147} }, - {12, 29, 1, 4, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {140, 141, 142, 143} }, - {13, 30, 1, 5, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {136, 137, 138, 139} }, - {14, 31, 1, 6, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {132, 133, 134, 135} }, - {15, 32, 1, 7, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {128, 129, 130, 131} }, - {16, 33, 2, 0, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, { 0, 1, 2, 3} }, - {17, 34, 2, 1, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, { 4, 5, 6, 7} }, - {18, 35, 2, 2, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, { 8, 9, 10, 11} }, - {19, 36, 2, 3, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, { 12, 13, 14, 15} }, - {20, 37, 2, 4, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, { 16, 17, 18, 19} }, - {21, 38, 2, 5, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, { 20, 21, 22, 23} }, - {22, 39, 2, 6, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, { 24, 25, 26, 27} }, - {23, 40, 2, 7, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, { 28, 29, 30, 31} }, - {24, 41, 3, 0, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, { 32, 33, 34, 35} }, - {25, 42, 3, 1, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, { 36, 37, 38, 39} }, - {26, 43, 3, 2, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, { 40, 41, 42, 43} }, - {27, 44, 3, 3, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, { 44, 45, 46, 47} }, - {28, 45, 3, 4, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, { 48, 49, 50, 51} }, - {29, 46, 3, 5, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, { 52, 53, 54, 55} }, - {30, 47, 3, 6, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, { 56, 57, 58, 59} }, - {31, 48, 3, 7, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, { 60, 61, 62, 63} }, - {32, 49, 4, 0, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {256, 257, 258, 259} }, - {33, 50, 4, 1, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {260, 261, 262, 263} }, - {34, 51, 4, 2, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {264, 265, 266, 267} }, - {35, 52, 4, 3, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {268, 269, 270, 271} }, - {36, 53, 4, 4, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {272, 273, 274, 275} }, - {37, 54, 4, 5, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {276, 277, 278, 279} }, - {38, 55, 4, 6, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {280, 281, 282, 283} }, - {39, 56, 4, 7, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {284, 285, 286, 287} }, - {40, 57, 5, 0, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {288, 289, 290, 291} }, - {41, 58, 5, 1, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {292, 293, 294, 295} }, - {42, 59, 5, 2, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {296, 297, 298, 299} }, - {43, 60, 5, 3, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {300, 301, 302, 303} }, - {44, 61, 5, 4, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {304, 305, 306, 307} }, - {45, 62, 5, 5, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {308, 309, 310, 311} }, - {46, 63, 5, 6, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {312, 313, 314, 315} }, - {47, 64, 5, 7, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {316, 317, 318, 319} }, - {48, 65, 6, 0, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {444, 445, 446, 447} }, - {49, 66, 6, 1, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {440, 441, 442, 443} }, - {50, 67, 6, 2, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {436, 437, 438, 439} }, - {51, 68, 6, 3, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {432, 433, 434, 435} }, - {52, 69, 6, 4, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {428, 429, 430, 431} }, - {53, 70, 6, 5, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {424, 425, 426, 427} }, - {54, 71, 6, 6, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {420, 421, 422, 423} }, - {55, 72, 6, 7, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {416, 417, 418, 419} }, - {56, 73, 7, 0, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {412, 413, 414, 415} }, - {57, 74, 7, 1, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {408, 409, 410, 411} }, - {58, 75, 7, 2, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {404, 405, 406, 407} }, - {59, 76, 7, 3, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {400, 401, 402, 403} }, - {60, 77, 7, 4, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {396, 397, 398, 399} }, - {61, 78, 7, 5, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {392, 393, 394, 395} }, - {62, 79, 7, 6, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {388, 389, 390, 391} }, - {63, 80, 7, 7, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {384, 385, 386, 387} }, - {64, 5, 8, 0, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, { 64, 65, 66, 67} }, -}; -#endif - -/* =========================================================== - * Cottonwood Layout configuration Rangeley (Rangeley CPU board) - * =========================================================== - */ -#ifdef SWPS_COTTONWOOD_RANGELEY -unsigned cottonwood_rangeley_gpio_rest_mux = MUX_RST_GPIO_500_PCA9548; - -struct inv_ioexp_layout_s cottonwood_rangeley_ioexp_layout[] = { - /* IOEXP_ID / IOEXP_TYPE / { Chan_ID, Chip_addr, Read_offset, Write_offset, config_offset, data_default, conf_default } */ - {0, CPLD_TYPE_COTTONWOOD,{ {1, 0x55, {22, 23, 24, 25}, {22, 23, 24, 25}, {-1, -1, -1, -1}, {0xee, 0xee, 0x99, 0x99}, {0x00, 0x00, 0x00, 0x00}, }, - }, - }, -}; - - -struct inv_port_layout_s cottonwood_rangeley_port_layout[] = { - /* Port_ID / Chan_ID / IOEXP_ID / IOEXP_VIRT_OFFSET / TRANSCEIVER_TYPE / CHI_TYPE / LANE_ID */ - { 0, 2, 0, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 75} }, - { 1, 3, 0, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 77} }, - { 2, 4, 0, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 79} }, - { 3, 5, 0, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 81} }, -}; -#endif - -/* =========================================================== - * Maple Layout configuration (Old) - * =========================================================== - */ -#ifdef SWPS_MAPLE_GA -unsigned maple_ga_gpio_rest_mux = MUX_RST_GPIO_505_PCA9548; - -struct inv_ioexp_layout_s maple_ga_ioexp_layout[] = { - /* IOEXP_ID / IOEXP_TYPE / { Chan_ID, Chip_addr, Read_offset, Write_offset, config_offset, data_default, conf_default } */ - {0, IOEXP_TYPE_MAPLE_0ABC, { {2, 0x20, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0x00, 0x00}, }, /* addr[0] = I/O Expander 0 A */ - {2, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0xff}, }, /* addr[1] = I/O Expander 0 B */ - {2, 0x22, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 0 C */ - }, - {1, IOEXP_TYPE_MAPLE_NABC, { {3, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {3, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {3, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {2, IOEXP_TYPE_MAPLE_NABC, { {4, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {4, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {4, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {3, IOEXP_TYPE_MAPLE_NABC, { {5, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {5, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {5, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {4, IOEXP_TYPE_MAPLE_NABC, { {6, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {6, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {6, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {5, IOEXP_TYPE_MAPLE_NABC, { {7, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {7, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {7, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {6, IOEXP_TYPE_MAPLE_NABC, { {8, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {8, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {8, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, -}; - -struct inv_port_layout_s maple_ga_port_layout[] = { - /* Port_ID / Chan_ID / IOEXP_ID / IOEXP_VIRT_OFFSET / TRANSCEIVER_TYPE / CHIP_TYPE / LANE_ID */ - { 0, 18, 1, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 1} }, - { 1, 19, 1, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 2} }, - { 2, 20, 1, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 3} }, - { 3, 21, 1, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 4} }, - { 4, 22, 1, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 5} }, - { 5, 23, 1, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 6} }, - { 6, 24, 1, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 7} }, - { 7, 25, 1, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 8} }, - { 8, 26, 2, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 13} }, - { 9, 27, 2, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 14} }, - {10, 28, 2, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 15} }, - {11, 29, 2, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 16} }, - {12, 30, 2, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 21} }, - {13, 31, 2, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 22} }, - {14, 32, 2, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 23} }, - {15, 33, 2, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 24} }, - {16, 34, 3, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 29} }, - {17, 35, 3, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 30} }, - {18, 36, 3, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 31} }, - {19, 37, 3, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 32} }, - {20, 38, 3, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 33} }, - {21, 39, 3, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 34} }, - {22, 40, 3, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 35} }, - {23, 41, 3, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 36} }, - {24, 42, 4, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 41} }, - {25, 43, 4, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 42} }, - {26, 44, 4, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 43} }, - {27, 45, 4, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 44} }, - {28, 46, 4, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 49} }, - {29, 47, 4, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 50} }, - {30, 48, 4, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 51} }, - {31, 49, 4, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 52} }, - {32, 50, 5, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 57} }, - {33, 51, 5, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 58} }, - {34, 52, 5, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 59} }, - {35, 53, 5, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 60} }, - {36, 54, 5, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 61} }, - {37, 55, 5, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 62} }, - {38, 56, 5, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 63} }, - {39, 57, 5, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 64} }, - {40, 58, 6, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 65} }, - {41, 59, 6, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 66} }, - {42, 60, 6, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 67} }, - {43, 61, 6, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 68} }, - {44, 62, 6, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 69} }, - {45, 63, 6, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 70} }, - {46, 64, 6, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 71} }, - {47, 65, 6, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 72} }, - {48, 10, 0, 0, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_MAPLE, { 77, 78, 79, 80} }, - {49, 11, 0, 1, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_MAPLE, { 85, 86, 87, 88} }, - {50, 12, 0, 2, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_MAPLE, { 93, 94, 95, 96} }, - {51, 13, 0, 3, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_MAPLE, { 97, 98, 99,100} }, - {52, 14, 0, 4, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_MAPLE, {105,106,107,108} }, - {53, 15, 0, 5, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_MAPLE, {113,114,115,116} }, - {54, 16, 0, 6, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_MAPLE, {121,122,123,124} }, - {55, 17, 0, 7, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_MAPLE, {125,126,127,128} }, -}; -#endif - -/* =========================================================== - * Maple Layout configuration (B version) - * =========================================================== - */ -#ifdef SWPS_MAPLE_B -unsigned maple_b_gpio_rest_mux = MUX_RST_GPIO_69_PCA9548; - -struct inv_ioexp_layout_s maple_b_ioexp_layout[] = { - /* IOEXP_ID / IOEXP_TYPE / { Chan_ID, Chip_addr, Read_offset, Write_offset, config_offset, data_default, conf_default } */ - {0, IOEXP_TYPE_MAPLE_0ABC, { { 6, 0x20, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0x00, 0x00}, }, /* addr[0] = I/O Expander 0 A */ - { 6, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0xff}, }, /* addr[1] = I/O Expander 0 B */ - { 6, 0x22, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 0 C */ - }, - {1, IOEXP_TYPE_MAPLE_NABC, { { 7, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - { 7, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - { 7, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {2, IOEXP_TYPE_MAPLE_NABC, { { 8, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - { 8, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - { 8, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {3, IOEXP_TYPE_MAPLE_NABC, { { 9, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - { 9, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - { 9, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {4, IOEXP_TYPE_MAPLE_NABC, { {10, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {10, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {10, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {5, IOEXP_TYPE_MAPLE_NABC, { {11, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {11, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {11, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {6, IOEXP_TYPE_MAPLE_NABC, { {12, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {12, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {12, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, -}; - -struct inv_port_layout_s maple_b_port_layout[] = { - /* Port_ID / Chan_ID / IOEXP_ID / IOEXP_VIRT_OFFSET / TRANSCEIVER_TYPE / CHIP_TYPE / LANE_ID */ - { 1, 23, 1, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 2} }, - { 2, 22, 1, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 1} }, - { 3, 25, 1, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 4} }, - { 4, 24, 1, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 3} }, - { 5, 27, 1, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 6} }, - { 6, 26, 1, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 5} }, - { 7, 29, 1, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 8} }, - { 8, 28, 1, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 7} }, - { 9, 31, 2, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 14} }, - {10, 30, 2, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 13} }, - {11, 33, 2, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 16} }, - {12, 32, 2, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 15} }, - {13, 35, 2, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 22} }, - {14, 34, 2, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 21} }, - {15, 37, 2, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 24} }, - {16, 36, 2, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 23} }, - {17, 39, 3, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 30} }, - {18, 38, 3, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 29} }, - {19, 41, 3, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 32} }, - {20, 40, 3, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 31} }, - {21, 43, 3, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 34} }, - {22, 42, 3, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 33} }, - {23, 45, 3, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 36} }, - {24, 44, 3, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 35} }, - {25, 47, 4, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 42} }, - {26, 46, 4, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 41} }, - {27, 49, 4, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 44} }, - {28, 48, 4, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 43} }, - {29, 51, 4, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 50} }, - {30, 50, 4, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 49} }, - {31, 53, 4, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 52} }, - {32, 52, 4, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 51} }, - {33, 55, 5, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 58} }, - {34, 54, 5, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 57} }, - {35, 57, 5, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 60} }, - {36, 56, 5, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 59} }, - {37, 59, 5, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 62} }, - {38, 58, 5, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 61} }, - {39, 61, 5, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 64} }, - {40, 60, 5, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 63} }, - {41, 63, 6, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 66} }, - {42, 62, 6, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 65} }, - {43, 65, 6, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 68} }, - {44, 64, 6, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 67} }, - {45, 67, 6, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 70} }, - {46, 66, 6, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 69} }, - {47, 69, 6, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 72} }, - {48, 68, 6, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 71} }, - {49, 15, 0, 1, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_MAPLE, { 77, 78, 79, 80} }, - {50, 14, 0, 0, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_MAPLE, { 85, 86, 87, 88} }, - {51, 17, 0, 3, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_MAPLE, { 97, 98, 99,100} }, - {52, 16, 0, 2, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_MAPLE, { 93, 94, 95, 96} }, - {53, 19, 0, 5, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_MAPLE, {105,106,107,108} }, - {54, 18, 0, 4, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_MAPLE, {113,114,115,116} }, - {55, 21, 0, 7, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_MAPLE, {125,126,127,128} }, - {56, 20, 0, 6, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_MAPLE, {121,122,123,124} }, -}; -#endif - - -/* ========================================== - * Gulmohar Layout configuration - * ========================================== - */ -#ifdef SWPS_GULMOHAR -unsigned gulmohar_gpio_rest_mux = MUX_RST_GPIO_505_PCA9548; - -struct inv_ioexp_layout_s gulmohar_ioexp_layout[] = { - /* IOEXP_ID / IOEXP_TYPE / { Chan_ID, Chip_addr, Read_offset, Write_offset, config_offset, data_default, conf_default } */ - {0, IOEXP_TYPE_GULMOHAR_NABC, { {2, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xf3, 0xf3}, {0xf3, 0xf3}, }, /* addr[0] = I/O Expander N A */ - {2, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xf3, 0xf3}, {0xf3, 0xf3}, }, /* addr[1] = I/O Expander N B */ - {2, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {1, IOEXP_TYPE_GULMOHAR_NABC, { {3, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xf3, 0xf3}, {0xf3, 0xf3}, }, /* addr[0] = I/O Expander N A */ - {3, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xf3, 0xf3}, {0xf3, 0xf3}, }, /* addr[1] = I/O Expander N B */ - {3, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {2, IOEXP_TYPE_GULMOHAR_NABC, { {4, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xf3, 0xf3}, {0xf3, 0xf3}, }, /* addr[0] = I/O Expander N A */ - {4, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xf3, 0xf3}, {0xf3, 0xf3}, }, /* addr[1] = I/O Expander N B */ - {4, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {3, IOEXP_TYPE_GULMOHAR_NABC, { {5, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xf3, 0xf3}, {0xf3, 0xf3}, }, /* addr[0] = I/O Expander N A */ - {5, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xf3, 0xf3}, {0xf3, 0xf3}, }, /* addr[1] = I/O Expander N B */ - {5, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {4, IOEXP_TYPE_GULMOHAR_NABC, { {6, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xf3, 0xf3}, {0xf3, 0xf3}, }, /* addr[0] = I/O Expander N A */ - {6, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xf3, 0xf3}, {0xf3, 0xf3}, }, /* addr[1] = I/O Expander N B */ - {6, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {5, IOEXP_TYPE_GULMOHAR_NABC, { {7, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xf3, 0xf3}, {0xf3, 0xf3}, }, /* addr[0] = I/O Expander N A */ - {7, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xf3, 0xf3}, {0xf3, 0xf3}, }, /* addr[1] = I/O Expander N B */ - {7, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {6, IOEXP_TYPE_GULMOHAR_7ABC, { {8, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xc0, 0xff}, {0xc0, 0xc0}, }, /* addr[0] = I/O Expander 7 A */ - {8, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xc0, 0xff}, }, /* addr[1] = I/O Expander 7 B */ - {8, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xc0, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 7 C */ - }, -}; - - - -struct inv_port_layout_s gulmohar_port_layout[] = { - /* Port_ID / Chan_ID / IOEXP_ID / IOEXP_VIRT_OFFSET / TRANSCEIVER_TYPE / CHIP_TYPE / LANE_ID */ - { 0, 10, 0, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, { 1} }, - { 1, 11, 0, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, { 2} }, - { 2, 12, 0, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, { 3} }, - { 3, 13, 0, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, { 4} }, - { 4, 14, 0, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, { 5} }, - { 5, 15, 0, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, { 6} }, - { 6, 16, 0, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, { 7} }, - { 7, 17, 0, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, { 8} }, - { 8, 18, 1, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, { 9} }, - { 9, 19, 1, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, { 10} }, - {10, 20, 1, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, { 11} }, - {11, 21, 1, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, { 12} }, - {12, 22, 1, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, { 21} }, - {13, 23, 1, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, { 22} }, - {14, 24, 1, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, { 23} }, - {15, 25, 1, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, { 24} }, - {16, 26, 2, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, { 33} }, - {17, 27, 2, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, { 34} }, - {18, 28, 2, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, { 35} }, - {19, 29, 2, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, { 36} }, - {20, 30, 2, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, { 37} }, - {21, 31, 2, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, { 38} }, - {22, 32, 2, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, { 39} }, - {23, 33, 2, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, { 40} }, - {24, 34, 3, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, { 41} }, - {25, 35, 3, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, { 42} }, - {26, 36, 3, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, { 43} }, - {27, 37, 3, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, { 44} }, - {28, 38, 3, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, { 49} }, - {29, 39, 3, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, { 50} }, - {30, 40, 3, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, { 51} }, - {31, 41, 3, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, { 52} }, - {32, 42, 4, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, { 53} }, - {33, 43, 4, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, { 54} }, - {34, 44, 4, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, { 55} }, - {35, 45, 4, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, { 56} }, - {36, 46, 4, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, { 65} }, - {37, 47, 4, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, { 66} }, - {38, 48, 4, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, { 67} }, - {39, 49, 4, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, { 68} }, - {40, 50, 5, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, { 69} }, - {41, 51, 5, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, { 70} }, - {42, 52, 5, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, { 71} }, - {43, 53, 5, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, { 72} }, - {44, 54, 5, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, { 81} }, - {45, 55, 5, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, { 82} }, - {46, 56, 5, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, { 83} }, - {47, 57, 5, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, { 84} }, - {48, 58, 6, 0, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, { 97, 98, 99,100} }, - {49, 59, 6, 1, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, { 85, 86, 87, 88} }, - {50, 60, 6, 2, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {101,102,103,104} }, - {51, 61, 6, 3, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {105,106,107,108} }, - {52, 62, 6, 4, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {109,110,111,112} }, - {53, 63, 6, 5, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {109,110,111,112} }, -}; -#endif - - -/* ========================================== - * Gulmohar_2T EVT1 Layout configuration - * ========================================== - */ -#ifdef SWPS_GULMOHAR_2T_EVT1 -unsigned gulmohar_2t_evt1_gpio_rest_mux = MUX_RST_GPIO_69_PCA9548; - -struct inv_ioexp_layout_s gulmohar_2t_evt1_ioexp_layout[] = { - /* IOEXP_ID / IOEXP_TYPE / { Chan_ID, Chip_addr, Read_offset, Write_offset, config_offset, data_default, conf_default } */ - {0, IOEXP_TYPE_GULMOHAR_2T_EVT1_NABC,{ {2, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xdd, 0xdd}, {0xdd, 0xdd}, }, /* addr[0] = I/O Expander N A */ - {2, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xdd, 0xdd}, {0xdd, 0xdd}, }, /* addr[1] = I/O Expander N B */ - {2, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {1, IOEXP_TYPE_GULMOHAR_2T_EVT1_1ABC,{ {3, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xdd, 0xdd}, {0xdd, 0xdd}, }, /* addr[0] = I/O Expander N A */ - {3, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xf3, 0xf3}, {0xf3, 0xf3}, }, /* addr[1] = I/O Expander N B */ - {3, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {2, IOEXP_TYPE_GULMOHAR_2T_EVT1_NABC,{ {4, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xdd, 0xdd}, {0xdd, 0xdd}, }, /* addr[0] = I/O Expander N A */ - {4, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xdd, 0xdd}, {0xdd, 0xdd}, }, /* addr[1] = I/O Expander N B */ - {4, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {3, IOEXP_TYPE_GULMOHAR_2T_EVT1_3ABC,{ {5, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xf3, 0xf3}, {0xf3, 0xf3}, }, /* addr[0] = I/O Expander N A */ - {5, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xdd, 0xdd}, {0xdd, 0xdd}, }, /* addr[1] = I/O Expander N B */ - {5, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {4, IOEXP_TYPE_GULMOHAR_2T_EVT1_NABC,{ {6, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xdd, 0xdd}, {0xdd, 0xdd}, }, /* addr[0] = I/O Expander N A */ - {6, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xdd, 0xdd}, {0xdd, 0xdd}, }, /* addr[1] = I/O Expander N B */ - {6, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {5, IOEXP_TYPE_GULMOHAR_2T_EVT1_NABC,{ {7, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xdd, 0xdd}, {0xdd, 0xdd}, }, /* addr[0] = I/O Expander N A */ - {7, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xdd, 0xdd}, {0xdd, 0xdd}, }, /* addr[1] = I/O Expander N B */ - {7, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {6, IOEXP_TYPE_GULMOHAR_2T_EVT1_7ABC,{ {8, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xd6, 0xda}, {0x18, 0xe3}, }, /* addr[0] = I/O Expander 7 A */ - {8, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xd6, 0xda}, {0x18, 0xe3}, }, /* addr[1] = I/O Expander 7 B */ - {8, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xd6, 0xff}, {0x18, 0xff}, }, }, /* addr[2] = I/O Expander 7 C */ - }, -}; - - - -struct inv_port_layout_s gulmohar_2t_evt1_port_layout[] = { - /* Port_ID / Chan_ID / IOEXP_ID / IOEXP_VIRT_OFFSET / TRANSCEIVER_TYPE / CHIP_TYPE / LANE_ID */ - { 0, 10, 0, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, {-99} }, - { 1, 11, 0, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, {-99} }, - { 2, 12, 0, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, {-99} }, - { 3, 13, 0, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, {-99} }, - { 4, 14, 0, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, {-99} }, - { 5, 15, 0, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, {-99} }, - { 6, 16, 0, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, {-99} }, - { 7, 17, 0, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, {-99} }, - { 8, 18, 1, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, {-99} }, - { 9, 19, 1, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, {-99} }, - {10, 20, 1, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, {-99} }, - {11, 21, 1, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, {-99} }, - {12, 22, 1, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, {-99} }, - {13, 23, 1, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, {-99} }, - {14, 24, 1, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, {-99} }, - {15, 25, 1, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, {-99} }, - {16, 26, 2, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, {-99} }, - {17, 27, 2, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, {-99} }, - {18, 28, 2, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, {-99} }, - {19, 29, 2, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, {-99} }, - {20, 30, 2, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, {-99} }, - {21, 31, 2, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, {-99} }, - {22, 32, 2, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, {-99} }, - {23, 33, 2, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, {-99} }, - {24, 34, 3, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, {-99} }, - {25, 35, 3, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, {-99} }, - {26, 36, 3, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, {-99} }, - {27, 37, 3, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, {-99} }, - {28, 38, 3, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, {-99} }, - {29, 39, 3, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, {-99} }, - {30, 40, 3, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, {-99} }, - {31, 41, 3, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, {-99} }, - {32, 42, 4, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, {-99} }, - {33, 43, 4, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, {-99} }, - {34, 44, 4, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, {-99} }, - {35, 45, 4, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, {-99} }, - {36, 46, 4, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, {-99} }, - {37, 47, 4, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, {-99} }, - {38, 48, 4, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, {-99} }, - {39, 49, 4, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, {-99} }, - {40, 50, 5, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, {-99} }, - {41, 51, 5, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, {-99} }, - {42, 52, 5, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, {-99} }, - {43, 53, 5, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, {-99} }, - {44, 54, 5, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, {-99} }, - {45, 55, 5, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, {-99} }, - {46, 56, 5, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, {-99} }, - {47, 57, 5, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, {-99} }, - {48, 59, 6, 1, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {-99,-99,-99,-99} }, - {49, 58, 6, 0, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {-99,-99,-99,-99} }, - {50, 61, 6, 3, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {-99,-99,-99,-99} }, - {51, 60, 6, 2, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {-99,-99,-99,-99} }, - {52, 63, 6, 5, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {-99,-99,-99,-99} }, - {53, 62, 6, 4, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {-99,-99,-99,-99} }, - {54, 65, 6, 7, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {-99,-99,-99,-99} }, - {55, 64, 6, 6, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {-99,-99,-99,-99} }, -}; -#endif - - -/* =========================================================== - * Peony-SFP Layout configuration - * =========================================================== - */ -#ifdef SWPS_PEONY_SFP -unsigned peony_sfp_gpio_rest_mux = MUX_RST_CPLD_C0_A77_70_74_RST_ALL; - -struct inv_ioexp_layout_s peony_sfp_ioexp_layout[] = { - /* IOEXP_ID / IOEXP_TYPE / { Chan_ID, Chip_addr, Read_offset, Write_offset, config_offset, data_default, conf_default } */ - {0, IOEXP_TYPE_QSFP_6P_LAYOUT_1, { {4, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xc0, 0xff}, {0xc0, 0xc0}, }, /* addr[0] = I/O Expander 0 A */ - {4, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xc0, 0xff}, }, /* addr[1] = I/O Expander 0 B */ - {4, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xc0, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 0 C */ - }, - {1, IOEXP_TYPE_SFP_8P_LAYOUT_1, { {5, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {5, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {5, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {2, IOEXP_TYPE_SFP_8P_LAYOUT_1, { {6, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {6, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {6, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {3, IOEXP_TYPE_SFP_8P_LAYOUT_1, { {7, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {7, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {7, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {4, IOEXP_TYPE_SFP_8P_LAYOUT_1, { {8, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {8, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {8, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {5, IOEXP_TYPE_SFP_8P_LAYOUT_1, { {9, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {9, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {9, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {6, IOEXP_TYPE_SFP_8P_LAYOUT_1, { {10, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {10, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {10, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, -}; - -struct inv_port_layout_s peony_sfp_port_layout[] = { - /* Port_ID / Chan_ID / IOEXP_ID / IOEXP_VIRT_OFFSET / TRANSCEIVER_TYPE / CHIP_TYPE / LANE_ID */ - { 0, 20, 1, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 1} }, - { 1, 21, 1, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 2} }, - { 2, 22, 1, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 3} }, - { 3, 23, 1, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 4} }, - { 4, 24, 1, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 5} }, - { 5, 25, 1, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 6} }, - { 6, 26, 1, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 7} }, - { 7, 27, 1, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 8} }, - { 8, 28, 2, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 13} }, - { 9, 29, 2, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 14} }, - {10, 30, 2, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 15} }, - {11, 31, 2, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 16} }, - {12, 32, 2, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 21} }, - {13, 33, 2, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 22} }, - {14, 34, 2, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 23} }, - {15, 35, 2, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 24} }, - {16, 36, 3, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 29} }, - {17, 37, 3, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 30} }, - {18, 38, 3, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 31} }, - {19, 39, 3, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 32} }, - {20, 40, 3, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 33} }, - {21, 41, 3, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 34} }, - {22, 42, 3, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 35} }, - {23, 43, 3, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 36} }, - {24, 44, 4, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 65} }, - {25, 45, 4, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 66} }, - {26, 46, 4, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 67} }, - {27, 47, 4, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 68} }, - {28, 48, 4, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 69} }, - {29, 49, 4, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 70} }, - {30, 50, 4, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 71} }, - {31, 51, 4, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 72} }, - {32, 52, 5, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 97} }, - {33, 53, 5, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 98} }, - {34, 54, 5, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 99} }, - {35, 55, 5, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, {100} }, - {36, 56, 5, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, {105} }, - {37, 57, 5, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, {106} }, - {38, 58, 5, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, {107} }, - {39, 59, 5, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, {108} }, - {40, 60, 6, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, {113} }, - {41, 61, 6, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, {114} }, - {42, 62, 6, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, {115} }, - {43, 63, 6, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, {116} }, - {44, 64, 6, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, {121} }, - {45, 65, 6, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, {122} }, - {46, 66, 6, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, {123} }, - {47, 67, 6, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, {124} }, - {48, 12, 0, 0, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_MAPLE, { 49, 50, 51, 52} }, - {49, 13, 0, 1, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_MAPLE, { 57, 58, 59, 60} }, - {50, 14, 0, 2, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_MAPLE, { 61, 62, 63, 64} }, - {51, 15, 0, 3, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_MAPLE, { 77, 78, 79, 80} }, - {52, 16, 0, 4, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_MAPLE, { 85, 86, 87, 88} }, - {53, 17, 0, 5, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_MAPLE, { 93, 94, 95, 96} }, -}; -#endif - - -/* =========================================================== - * Peony-Copper Layout configuration - * =========================================================== - */ -#ifdef SWPS_PEONY_COPPER -unsigned peony_copper_gpio_rest_mux = MUX_RST_CPLD_C0_A77_70_74_RST_ALL; - -struct inv_ioexp_layout_s peony_copper_ioexp_layout[] = { - /* IOEXP_ID / IOEXP_TYPE / { Chan_ID, Chip_addr, Read_offset, Write_offset, config_offset, data_default, conf_default } */ - {0, IOEXP_TYPE_QSFP_6P_LAYOUT_1, { {10, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xc0, 0xff}, {0xc0, 0xc0}, }, /* addr[0] = I/O Expander 0 A */ - {10, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xc0, 0xff}, }, /* addr[1] = I/O Expander 0 B */ - {10, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xc0, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 0 C */ - }, -}; - -struct inv_port_layout_s peony_copper_port_layout[] = { - /* Port_ID / Chan_ID / IOEXP_ID / IOEXP_VIRT_OFFSET / TRANSCEIVER_TYPE / CHIP_TYPE / LANE_ID */ - {48, 4, 0, 0, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_MAPLE, { 49, 50, 51, 52} }, - {49, 5, 0, 1, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_MAPLE, { 57, 58, 59, 60} }, - {50, 6, 0, 2, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_MAPLE, { 61, 62, 63, 64} }, - {51, 7, 0, 3, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_MAPLE, { 77, 78, 79, 80} }, - {52, 8, 0, 4, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_MAPLE, { 85, 86, 87, 88} }, - {53, 9, 0, 5, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_MAPLE, { 93, 94, 95, 96} }, -}; -#endif - - - -#endif /* INV_SWPS_H */ - - - - - - - - - diff --git a/packages/platforms/inventec/x86-64/d10056/modules/builds/src/inv_vpd.c b/packages/platforms/inventec/x86-64/d10056/modules/builds/src/inv_vpd.c deleted file mode 100644 index b07cb6bbb..000000000 --- a/packages/platforms/inventec/x86-64/d10056/modules/builds/src/inv_vpd.c +++ /dev/null @@ -1,333 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "inv_vpd.h" -#include "onie_tlvinfo.h" - -static int vpd_major; -static struct class *vpd_class_p = NULL; -static char cEeprom[SYS_EEPROM_MAX_SIZE]; -static DEFINE_MUTEX(vpd_mutex); - -static int -__swp_match(struct device *dev, - const void *data){ - - char *name = (char *)data; - if (strcmp(dev_name(dev), name) == 0) - return 1; - return 0; -} - -static -int get_vpd_data(struct i2c_client *pi2c_client, int i_offset, char *c_buf) -{ - int iRet; - - read_eeprom( pi2c_client, cEeprom); - iRet = tlvinfo_decode_tlv(cEeprom, i_offset,c_buf); - return iRet; -} - -static -int write_vpd_data(struct i2c_client *pi2c_client, int i_offset, char *c_buf) -{ - int iErr = 0; - - if (read_eeprom(pi2c_client, cEeprom)) { - printk(KERN_ERR "write vpd data eror at %d-%s\n", __LINE__, __FUNCTION__); - return -1; - } - - if (tlvinfo_delete_tlv(cEeprom, i_offset) == TRUE) { - } - if (c_buf) { - if(!tlvinfo_add_tlv(cEeprom, i_offset , c_buf)) { - printk(KERN_ERR "write vpd data eror at %d-%s\n", __LINE__, __FUNCTION__); - iErr = -1; - } else { - iErr = prog_eeprom(pi2c_client,cEeprom); - } - } - return iErr; -} - -static struct device * -get_swpdev_by_name(char *name){ - struct device *dev = class_find_device(vpd_class_p, - NULL, - name, - __swp_match); - return dev; -} - -static ssize_t -store_attr_vpd(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - struct i2c_client *pi2c_client = dev_get_drvdata(dev_p); - struct vpd_device_attribute *attr = to_vpd_dev_attr(attr_p); - int iOffset = attr->index; - int iErr , iLen; - char *pChar; - - if (!pi2c_client){ - return -ENODEV; - } - mutex_lock(&vpd_mutex); - - //-strip 0x0a in the last byte. - for (iLen = 0, pChar = buf_p; - iLen < 255 && *pChar != 0; - iLen++, pChar++) ; - if (iLen !=0 && *pChar == 0 && *(pChar-1) == 0x0a) - *(pChar - 1) = 0; - //- - - iErr = write_vpd_data( pi2c_client, iOffset, buf_p); - - mutex_unlock(&vpd_mutex); - return count; -} - -static ssize_t -show_attr_vpd(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct i2c_client *pi2c_client = dev_get_drvdata(dev_p); - struct vpd_device_attribute *attr = to_vpd_dev_attr(attr_p); - int iOffset = attr->index; - int iErr , iLen; - - if (!pi2c_client){ - return -ENODEV; - } - mutex_lock(&vpd_mutex); - iErr = get_vpd_data( pi2c_client, iOffset, buf_p); - mutex_unlock(&vpd_mutex); - - if( iErr <= 0 ) - iLen = 0; - else - iLen = snprintf(buf_p, TLV_DECODE_VALUE_MAX_LEN, "%s\n", buf_p); - - return iLen; -} - -/* ================= Vpd attribute ======================== - */ -static VPD_DEVICE_ATTR(product_name ,S_IWUSR|S_IRUGO, show_attr_vpd, store_attr_vpd, TLV_CODE_PRODUCT_NAME ); -static VPD_DEVICE_ATTR(pn ,S_IWUSR|S_IRUGO, show_attr_vpd, store_attr_vpd, TLV_CODE_PART_NUMBER ); -static VPD_DEVICE_ATTR(sn ,S_IWUSR|S_IRUGO, show_attr_vpd, store_attr_vpd, TLV_CODE_SERIAL_NUMBER ); -static VPD_DEVICE_ATTR(base_mac_addr,S_IWUSR|S_IRUGO, show_attr_vpd, store_attr_vpd, TLV_CODE_MAC_BASE ); -static VPD_DEVICE_ATTR(man_date ,S_IWUSR|S_IRUGO, show_attr_vpd, store_attr_vpd, TLV_CODE_MANUF_DATE ); -static VPD_DEVICE_ATTR(dev_ver ,S_IWUSR|S_IRUGO, show_attr_vpd, store_attr_vpd, TLV_CODE_DEVICE_VERSION ); -static VPD_DEVICE_ATTR(label_rev ,S_IWUSR|S_IRUGO, show_attr_vpd, store_attr_vpd, TLV_CODE_LABEL_REVISION ); -static VPD_DEVICE_ATTR(plat_name ,S_IWUSR|S_IRUGO, show_attr_vpd, store_attr_vpd, TLV_CODE_PLATFORM_NAME ); -static VPD_DEVICE_ATTR(ldr_ver ,S_IWUSR|S_IRUGO, show_attr_vpd, store_attr_vpd, TLV_CODE_ONIE_VERSION ); -static VPD_DEVICE_ATTR(mac_addr ,S_IWUSR|S_IRUGO, show_attr_vpd, store_attr_vpd, TLV_CODE_MAC_SIZE ); -static VPD_DEVICE_ATTR(manufacturer ,S_IWUSR|S_IRUGO, show_attr_vpd, store_attr_vpd, TLV_CODE_MANUF_NAME ); -static VPD_DEVICE_ATTR(country_code ,S_IWUSR|S_IRUGO, show_attr_vpd, store_attr_vpd, TLV_CODE_MANUF_COUNTRY ); -static VPD_DEVICE_ATTR(vendor_name ,S_IWUSR|S_IRUGO, show_attr_vpd, store_attr_vpd, TLV_CODE_VENDOR_NAME ); -static VPD_DEVICE_ATTR(diag_ver ,S_IWUSR|S_IRUGO, show_attr_vpd, store_attr_vpd, TLV_CODE_DIAG_VERSION ); -static VPD_DEVICE_ATTR(service_tag ,S_IWUSR|S_IRUGO, show_attr_vpd, store_attr_vpd, TLV_CODE_SERVICE_TAG ); -static VPD_DEVICE_ATTR(vendor_ext ,S_IWUSR|S_IRUGO, show_attr_vpd, store_attr_vpd, TLV_CODE_VENDOR_EXT ); -static VPD_DEVICE_ATTR(crc32 ,S_IRUGO, show_attr_vpd, NULL, TLV_CODE_CRC_32 ); - -static void -clean_vpd_common(void) -{ - dev_t dev_num; - struct device *device_p; - - device_p = get_swpdev_by_name(VPD_DEVICE); - if (device_p){ - dev_num = MKDEV(vpd_major, 1); - device_unregister(device_p); - device_destroy(vpd_class_p, dev_num); - } - VPD_DEBUG("%s: done.\n", __func__); -} - - -static struct register_attr VpdRegAttr[VPD_ENTRY_SIZE ] ={ - { &vpd_dev_attr_product_name.dev_attr, "vpd_dev_attr_product_name"}, - { &vpd_dev_attr_pn.dev_attr, "vpd_dev_attr_pn"}, - { &vpd_dev_attr_sn.dev_attr, "vpd_dev_attr_sn"}, - { &vpd_dev_attr_base_mac_addr.dev_attr, "vpd_dev_attr_base_mac_addr"}, - { &vpd_dev_attr_man_date.dev_attr, "vpd_dev_attr_man_date"}, - { &vpd_dev_attr_dev_ver.dev_attr, "vpd_dev_attr_dev_ver"}, - { &vpd_dev_attr_label_rev.dev_attr, "vpd_dev_attr_label_rev"}, - { &vpd_dev_attr_plat_name.dev_attr, "vpd_dev_attr_plat_name"}, - { &vpd_dev_attr_ldr_ver.dev_attr, "vpd_dev_attr_ldr_ver"}, - { &vpd_dev_attr_mac_addr.dev_attr, "vpd_dev_attr_mac_addr"}, - { &vpd_dev_attr_manufacturer.dev_attr, "vpd_dev_attr_manufacturer"}, - { &vpd_dev_attr_country_code.dev_attr, "vpd_dev_attr_country_code"}, - { &vpd_dev_attr_vendor_name.dev_attr, "vpd_dev_attr_vendor_name"}, - { &vpd_dev_attr_diag_ver.dev_attr, "vpd_dev_attr_diag_ver"}, - { &vpd_dev_attr_service_tag.dev_attr, "vpd_dev_attr_service_tag"}, - { &vpd_dev_attr_vendor_ext.dev_attr, "vpd_dev_attr_vendor_ext"}, - { &vpd_dev_attr_crc32.dev_attr, "vpd_dev_attr_crc32"}, -}; - -static int -register_vpd_attr(struct device *device_p){ - - char *err_attr = NULL; - int i; - - for( i = 0 ; i adapter = adap; - vpd_i2c_client->addr = VPD_I2C_ADDR; - - device_p = device_create(vpd_class_p, /* struct class *cls */ - NULL, /* struct device *parent */ - dev_num, /* dev_t devt */ - vpd_i2c_client, /* void *private_data */ - VPD_DEVICE); /* const char *fmt */ - if (IS_ERR(device_p)){ - err_msg = "device_create fail"; - goto err_register_vpd_device_1; - } - if (register_vpd_attr(device_p) < 0) { - err_msg = "register_vpd_attr fail"; - goto err_register_vpd_device_2; - } - return 0; - -err_register_vpd_device_2: - device_unregister(device_p); - device_destroy(vpd_class_p, dev_num); -err_register_vpd_device_1: - kfree(vpd_i2c_client); - vpd_i2c_client = NULL; -err_register_vpd_device: - VPD_ERR("%s: %s\n", __func__, err_msg); - return -1; -} - -static int -register_vpd_module(void) -{ - dev_t vpd_devt = 0; - - if (alloc_chrdev_region(&vpd_devt, 0, 1, VPD_DEVICE) < 0){ - VPD_WARN("Allocate VPD MAJOR failure! \n"); - goto err_register_vpd_module; - } - vpd_major = MAJOR(vpd_devt); - - /* Create class object */ - vpd_class_p = class_create(THIS_MODULE, EEPROM_CLASS); - if (IS_ERR(vpd_class_p)) { - VPD_ERR("Create class failure! \n"); - goto err_register_vpd_module_1; - } - return 0; - -err_register_vpd_module_1: - unregister_chrdev_region(MKDEV(vpd_major, 0), 1); -err_register_vpd_module: - return -1; -} - - -static int -init_vpd_common(void) -{ - char *err_msg = "ERR"; - - if (register_vpd_device() < 0) { - err_msg = "register_vpd_device fail"; - goto err_init_vpd_common; - } - return 0; - -err_init_vpd_common: - VPD_ERR("%s: %s\n", __func__, err_msg); - return -1; -} - - -static int __init -vpd_module_init(void) -{ - if (register_vpd_module() < 0){ - goto err_vpd_module_init; - } - if (init_vpd_common() < 0){ - goto err_vpd_module_init_1; - } - VPD_INFO("Inventec vpd module V.%s initial success.\n", VPD_VERSION); - return 0; - -err_vpd_module_init_1: - class_unregister(vpd_class_p); - class_destroy(vpd_class_p); - unregister_chrdev_region(MKDEV(vpd_major, 0), 1); -err_vpd_module_init: - VPD_ERR("Inventec vpd module V.%s initial failure.\n", VPD_VERSION); - return -1; -} - - -static void __exit -vpd_module_exit(void) -{ - clean_vpd_common(); - class_unregister(vpd_class_p); - class_destroy(vpd_class_p); - unregister_chrdev_region(MKDEV(vpd_major, 0), 1); - VPD_INFO("Remove Inventec vpd module success.\n"); -} - - -/* Module information */ -MODULE_AUTHOR(VPD_AUTHOR); -MODULE_DESCRIPTION(VPD_DESC); -MODULE_VERSION(VPD_VERSION); -MODULE_LICENSE(VPD_LICENSE); - -module_init(vpd_module_init); -module_exit(vpd_module_exit); diff --git a/packages/platforms/inventec/x86-64/d10056/modules/builds/src/inv_vpd.h b/packages/platforms/inventec/x86-64/d10056/modules/builds/src/inv_vpd.h deleted file mode 100644 index 58c7fe33f..000000000 --- a/packages/platforms/inventec/x86-64/d10056/modules/builds/src/inv_vpd.h +++ /dev/null @@ -1,46 +0,0 @@ -#ifndef INV_VPD_H -#define INV_VPD_H - -#define EEPROM_CLASS "eeprom" -#define VPD_DEVICE "vpd" -#define VPD_AUTHOR "Neil " -#define VPD_DESC "Inventec eeprom vpd driver" -#define VPD_VERSION "1.0.0" -#define VPD_LICENSE "GPL" - -#define VPD_ENTRY_SIZE (17) -#define VPD_I2C_BUS (0) -#define VPD_I2C_ADDR (0x53) - -struct register_attr { -struct device_attribute *attr; -char * errmsg; -}; - -struct vpd_device_attribute{ - struct device_attribute dev_attr; - int index; -}; - -#define to_vpd_dev_attr(_dev_attr) \ - container_of(_dev_attr, struct vpd_device_attribute, dev_attr) - -#define VPD_ATTR(_name, _mode, _show, _store, _index) \ - { .dev_attr = __ATTR(_name, _mode, _show, _store), \ - .index = _index } - -#define VPD_DEVICE_ATTR(_name, _mode, _show, _store, _index) \ - struct vpd_device_attribute vpd_dev_attr_##_name \ - = VPD_ATTR(_name, _mode, _show, _store, _index) - -#define VPD_INFO(fmt, args...) printk( KERN_INFO "[VPD] " fmt, ##args) -#define VPD_WARN(fmt, args...) printk( KERN_WARNING "[VPD] " fmt, ##args) -#define VPD_ERR(fmt, args...) printk( KERN_ERR "[VPD] " fmt, ##args) - -#ifdef DEBUG_VPD -# define VPD_DEBUG(fmt, args...) printk( KERN_DEBUG "[VPD] " fmt, ##args) -#else -# define VPD_DEBUG(fmt, args...) -#endif - -#endif /* INV_VPD_H */ diff --git a/packages/platforms/inventec/x86-64/d10056/modules/builds/src/io_expander.c b/packages/platforms/inventec/x86-64/d10056/modules/builds/src/io_expander.c deleted file mode 100644 index da6048093..000000000 --- a/packages/platforms/inventec/x86-64/d10056/modules/builds/src/io_expander.c +++ /dev/null @@ -1,2564 +0,0 @@ -#include -#include -#include "io_expander.h" - -/* For build single module using (Ex: ONL platform) */ -#include -//#include - - -static struct ioexp_obj_s *ioexp_head_p = NULL; -static struct ioexp_obj_s *ioexp_tail_p = NULL; - - -/* ========== Register IOEXP layout ========== - */ -struct ioexp_map_s ioexp_map_magnolia_nab = { - - .chip_amount = 2, - .data_width = 2, - - .map_present = { {0, 0, 4}, /* map_present[0] = MOD_ABS_PORT(X) */ - {0, 0, 5}, /* map_present[1] = MOD_ABS_PORT(X+1) */ - {0, 0, 6}, /* map_present[2] = MOD_ABS_PORT(X+2) */ - {0, 0, 7}, /* map_present[3] = MOD_ABS_PORT(X+3) */ - {1, 0, 4}, /* map_present[4] = MOD_ABS_PORT(X+4) */ - {1, 0, 5}, /* map_present[5] = MOD_ABS_PORT(X+5) */ - {1, 0, 6}, /* map_present[6] = MOD_ABS_PORT(X+6) */ - {1, 0, 7}, /* map_present[7] = MOD_ABS_PORT(X+7) */ - }, - .map_tx_disable = { {0, 1, 0}, /* map_tx_disable[0] = TXDISABLE_SFP+_P(X) */ - {0, 1, 1}, /* map_tx_disable[1] = TXDISABLE_SFP+_P(X+1) */ - {0, 1, 2}, /* map_tx_disable[2] = TXDISABLE_SFP+_P(X+2) */ - {0, 1, 3}, /* map_tx_disable[3] = TXDISABLE_SFP+_P(X+3) */ - {1, 1, 0}, /* map_tx_disable[4] = TXDISABLE_SFP+_P(X+4) */ - {1, 1, 1}, /* map_tx_disable[5] = TXDISABLE_SFP+_P(X+5) */ - {1, 1, 2}, /* map_tx_disable[6] = TXDISABLE_SFP+_P(X+6) */ - {1, 1, 3}, /* map_tx_disable[7] = TXDISABLE_SFP+_P(X+7) */ - }, - .map_tx_fault = { {0, 0, 0}, /* map_tx_fault[0] = TXFAULT_SFP+_P(X) */ - {0, 0, 1}, /* map_tx_fault[1] = TXFAULT_SFP+_P(X+1) */ - {0, 0, 2}, /* map_tx_fault[2] = TXFAULT_SFP+_P(X+2) */ - {0, 0, 3}, /* map_tx_fault[3] = TXFAULT_SFP+_P(X+3) */ - {1, 0, 0}, /* map_tx_fault[4] = TXFAULT_SFP+_P(X+4) */ - {1, 0, 1}, /* map_tx_fault[5] = TXFAULT_SFP+_P(X+5) */ - {1, 0, 2}, /* map_tx_fault[6] = TXFAULT_SFP+_P(X+6) */ - {1, 0, 3}, /* map_tx_fault[7] = TXFAULT_SFP+_P(X+7) */ - }, - .map_rxlos = { {0, 1, 4}, /* map_rxlos[0] = OPRXLOS_PORT(X) */ - {0, 1, 5}, /* map_rxlos[1] = OPRXLOS_PORT(X+1) */ - {0, 1, 6}, /* map_rxlos[2] = OPRXLOS_PORT(X+2) */ - {0, 1, 7}, /* map_rxlos[3] = OPRXLOS_PORT(X+3) */ - {1, 1, 4}, /* map_rxlos[4] = OPRXLOS_PORT(X+4) */ - {1, 1, 5}, /* map_rxlos[5] = OPRXLOS_PORT(X+5) */ - {1, 1, 6}, /* map_rxlos[6] = OPRXLOS_PORT(X+6) */ - {1, 1, 7}, /* map_rxlos[7] = OPRXLOS_PORT(X+7) */ - }, -}; - - -struct ioexp_map_s ioexp_map_magnolia_4ab = { - - .chip_amount = 2, - .data_width = 2, - - .map_present = { {0, 0, 4}, /* map_present[0] = MOD_ABS_PORT(X) */ - {0, 0, 5}, /* map_present[1] = MOD_ABS_PORT(X+1) */ - {0, 0, 6}, /* map_present[2] = MOD_ABS_PORT(X+2) */ - {0, 0, 7}, /* map_present[3] = MOD_ABS_PORT(X+3) */ - {1, 0, 4}, /* map_present[4] = MOD_ABS_PORT(X+4) */ - {1, 0, 5}, /* map_present[5] = MOD_ABS_PORT(X+5) */ - {1, 0, 6}, /* map_present[6] = MOD_ABS_PORT(X+6) */ - {1, 0, 7}, /* map_present[7] = MOD_ABS_PORT(X+7) */ - }, - .map_tx_disable = { {0, 1, 0}, /* map_tx_disable[0] = TXDISABLE_SFP+_P(X) */ - {0, 1, 1}, /* map_tx_disable[1] = TXDISABLE_SFP+_P(X+1) */ - {0, 1, 2}, /* map_tx_disable[2] = TXDISABLE_SFP+_P(X+2) */ - {0, 1, 3}, /* map_tx_disable[3] = TXDISABLE_SFP+_P(X+3) */ - {1, 0, 0}, /* map_tx_disable[4] = TXDISABLE_SFP+_P(X+4) */ - {1, 0, 1}, /* map_tx_disable[5] = TXDISABLE_SFP+_P(X+5) */ - {1, 0, 2}, /* map_tx_disable[6] = TXDISABLE_SFP+_P(X+6) */ - {1, 0, 3}, /* map_tx_disable[7] = TXDISABLE_SFP+_P(X+7) */ - }, - .map_tx_fault = { {0, 0, 0}, /* map_tx_fault[0] = TXFAULT_SFP+_P(X) */ - {0, 0, 1}, /* map_tx_fault[1] = TXFAULT_SFP+_P(X+1) */ - {0, 0, 2}, /* map_tx_fault[2] = TXFAULT_SFP+_P(X+2) */ - {0, 0, 3}, /* map_tx_fault[3] = TXFAULT_SFP+_P(X+3) */ - {1, 1, 0}, /* map_tx_fault[4] = TXFAULT_SFP+_P(X+4) */ - {1, 1, 1}, /* map_tx_fault[5] = TXFAULT_SFP+_P(X+5) */ - {1, 1, 2}, /* map_tx_fault[6] = TXFAULT_SFP+_P(X+6) */ - {1, 1, 3}, /* map_tx_fault[7] = TXFAULT_SFP+_P(X+7) */ - }, - .map_rxlos = { {0, 1, 4}, /* map_rxlos[0] = OPRXLOS_PORT(X) */ - {0, 1, 5}, /* map_rxlos[1] = OPRXLOS_PORT(X+1) */ - {0, 1, 6}, /* map_rxlos[2] = OPRXLOS_PORT(X+2) */ - {0, 1, 7}, /* map_rxlos[3] = OPRXLOS_PORT(X+3) */ - {1, 1, 4}, /* map_rxlos[4] = OPRXLOS_PORT(X+4) */ - {1, 1, 5}, /* map_rxlos[5] = OPRXLOS_PORT(X+5) */ - {1, 1, 6}, /* map_rxlos[6] = OPRXLOS_PORT(X+6) */ - {1, 1, 7}, /* map_rxlos[7] = OPRXLOS_PORT(X+7) */ - }, -}; - - -struct ioexp_map_s ioexp_map_magnolia_7ab = { - - .chip_amount = 2, - .data_width = 2, - - .map_present = { {1, 0, 4}, /* map_present[0] = MOD_ABS_PORT(X) */ - {1, 0, 5}, /* map_present[1] = MOD_ABS_PORT(X+1) */ - {1, 0, 6}, /* map_present[2] = MOD_ABS_PORT(X+2) */ - {1, 0, 7}, /* map_present[3] = MOD_ABS_PORT(X+3) */ - {1, 1, 4}, /* map_present[4] = MOD_ABS_PORT(X+4) */ - {1, 1, 5}, /* map_present[5] = MOD_ABS_PORT(X+5) */ - }, - .map_reset = { {0, 0, 0}, /* map_reset[0] = QRESET_QSFP_N_P(X) */ - {0, 0, 1}, /* map_reset[1] = QRESET_QSFP_N_P(X+1) */ - {0, 0, 2}, /* map_reset[2] = QRESET_QSFP_N_P(X+2) */ - {0, 0, 3}, /* map_reset[3] = QRESET_QSFP_N_P(X+3) */ - {1, 0, 0}, /* map_reset[4] = QRESET_QSFP_N_P(X+4) */ - {1, 0, 1}, /* map_reset[5] = QRESET_QSFP_N_P(X+5) */ - }, - .map_lpmod = { {0, 0, 4}, /* map_lpmod[0] = LPMODE_QSFP_P(X) */ - {0, 0, 5}, /* map_lpmod[1] = LPMODE_QSFP_P(X+1) */ - {0, 0, 6}, /* map_lpmod[2] = LPMODE_QSFP_P(X+2) */ - {0, 0, 7}, /* map_lpmod[3] = LPMODE_QSFP_P(X+3) */ - {1, 0, 2}, /* map_lpmod[4] = LPMODE_QSFP_P(X+4) */ - {1, 0, 3}, /* map_lpmod[5] = LPMODE_QSFP_P(X+5) */ - }, - .map_modsel = { {0, 1, 4}, /* map_modsel[0] = MODSEL_QSFP_N_P(X) */ - {0, 1, 5}, /* map_modsel[1] = MODSEL_QSFP_N_P(X+1) */ - {0, 1, 6}, /* map_modsel[2] = MODSEL_QSFP_N_P(X+2) */ - {0, 1, 7}, /* map_modsel[3] = MODSEL_QSFP_N_P(X+3) */ - {1, 1, 4}, /* map_modsel[4] = MODSEL_QSFP_N_P(X+4) */ - {1, 1, 5}, /* map_modsel[5] = MODSEL_QSFP_N_P(X+5) */ - }, -}; - - -struct ioexp_map_s ioexp_map_redwood_p01p08_p17p24 = { - - .chip_amount = 3, - .data_width = 2, - - .map_present = { {2, 0, 0}, /* map_present[0] = MOD_ABS_PORT(X) */ - {2, 0, 1}, /* map_present[1] = MOD_ABS_PORT(X+1) */ - {2, 0, 2}, /* map_present[2] = MOD_ABS_PORT(X+2) */ - {2, 0, 3}, /* map_present[3] = MOD_ABS_PORT(X+3) */ - {2, 0, 4}, /* map_present[4] = MOD_ABS_PORT(X+4) */ - {2, 0, 5}, /* map_present[5] = MOD_ABS_PORT(X+5) */ - {2, 0, 6}, /* map_present[6] = MOD_ABS_PORT(X+6) */ - {2, 0, 7}, /* map_present[7] = MOD_ABS_PORT(X+7) */ - }, - .map_reset = { {0, 0, 0}, /* map_reset[0] = QRESET_QSFP28_N_P(X) */ - {0, 0, 1}, /* map_reset[1] = QRESET_QSFP28_N_P(X+1) */ - {0, 0, 2}, /* map_reset[2] = QRESET_QSFP28_N_P(X+2) */ - {0, 0, 3}, /* map_reset[3] = QRESET_QSFP28_N_P(X+3) */ - {1, 0, 0}, /* map_reset[4] = QRESET_QSFP28_N_P(X+4) */ - {1, 0, 1}, /* map_reset[5] = QRESET_QSFP28_N_P(X+5) */ - {1, 0, 2}, /* map_reset[6] = QRESET_QSFP28_N_P(X+6) */ - {1, 0, 3}, /* map_reset[7] = QRESET_QSFP28_N_P(X+7) */ - }, - .map_lpmod = { {0, 0, 4}, /* map_lpmod[0] = LPMODE_QSFP28_P(X) */ - {0, 0, 5}, /* map_lpmod[1] = LPMODE_QSFP28_P(X+1) */ - {0, 0, 6}, /* map_lpmod[2] = LPMODE_QSFP28_P(X+2) */ - {0, 0, 7}, /* map_lpmod[3] = LPMODE_QSFP28_P(X+3) */ - {1, 0, 4}, /* map_lpmod[4] = LPMODE_QSFP28_P(X+4) */ - {1, 0, 5}, /* map_lpmod[5] = LPMODE_QSFP28_P(X+5) */ - {1, 0, 6}, /* map_lpmod[6] = LPMODE_QSFP28_P(X+6) */ - {1, 0, 7}, /* map_lpmod[7] = LPMODE_QSFP28_P(X+7) */ - }, - .map_modsel = { {0, 1, 4}, /* map_modsel[0] = MODSEL_QSFP28_N_P(X) */ - {0, 1, 5}, /* map_modsel[1] = MODSEL_QSFP28_N_P(X+1) */ - {0, 1, 6}, /* map_modsel[2] = MODSEL_QSFP28_N_P(X+2) */ - {0, 1, 7}, /* map_modsel[3] = MODSEL_QSFP28_N_P(X+3) */ - {1, 1, 4}, /* map_modsel[4] = MODSEL_QSFP28_N_P(X+4) */ - {1, 1, 5}, /* map_modsel[5] = MODSEL_QSFP28_N_P(X+5) */ - {1, 1, 6}, /* map_modsel[6] = MODSEL_QSFP28_N_P(X+6) */ - {1, 1, 7}, /* map_modsel[7] = MODSEL_QSFP28_N_P(X+7) */ - }, -}; - - -struct ioexp_map_s ioexp_map_redwood_p09p16_p25p32 = { - - .chip_amount = 3, - .data_width = 2, - - .map_present = { {2, 1, 0}, /* map_present[0] = MOD_ABS_PORT(X) */ - {2, 1, 1}, /* map_present[1] = MOD_ABS_PORT(X+1) */ - {2, 1, 2}, /* map_present[2] = MOD_ABS_PORT(X+2) */ - {2, 1, 3}, /* map_present[3] = MOD_ABS_PORT(X+3) */ - {2, 1, 4}, /* map_present[4] = MOD_ABS_PORT(X+4) */ - {2, 1, 5}, /* map_present[5] = MOD_ABS_PORT(X+5) */ - {2, 1, 6}, /* map_present[6] = MOD_ABS_PORT(X+6) */ - {2, 1, 7}, /* map_present[7] = MOD_ABS_PORT(X+7) */ - }, - .map_reset = { {0, 0, 0}, /* map_reset[0] = QRESET_QSFP28_N_P(X) */ - {0, 0, 1}, /* map_reset[1] = QRESET_QSFP28_N_P(X+1) */ - {0, 0, 2}, /* map_reset[2] = QRESET_QSFP28_N_P(X+2) */ - {0, 0, 3}, /* map_reset[3] = QRESET_QSFP28_N_P(X+3) */ - {1, 0, 0}, /* map_reset[4] = QRESET_QSFP28_N_P(X+4) */ - {1, 0, 1}, /* map_reset[5] = QRESET_QSFP28_N_P(X+5) */ - {1, 0, 2}, /* map_reset[6] = QRESET_QSFP28_N_P(X+6) */ - {1, 0, 3}, /* map_reset[7] = QRESET_QSFP28_N_P(X+7) */ - }, - .map_lpmod = { {0, 0, 4}, /* map_lpmod[0] = LPMODE_QSFP28_P(X) */ - {0, 0, 5}, /* map_lpmod[1] = LPMODE_QSFP28_P(X+1) */ - {0, 0, 6}, /* map_lpmod[2] = LPMODE_QSFP28_P(X+2) */ - {0, 0, 7}, /* map_lpmod[3] = LPMODE_QSFP28_P(X+3) */ - {1, 0, 4}, /* map_lpmod[4] = LPMODE_QSFP28_P(X+4) */ - {1, 0, 5}, /* map_lpmod[5] = LPMODE_QSFP28_P(X+5) */ - {1, 0, 6}, /* map_lpmod[6] = LPMODE_QSFP28_P(X+6) */ - {1, 0, 7}, /* map_lpmod[7] = LPMODE_QSFP28_P(X+7) */ - }, - .map_modsel = { {0, 1, 4}, /* map_modsel[0] = MODSEL_QSFP28_N_P(X) */ - {0, 1, 5}, /* map_modsel[1] = MODSEL_QSFP28_N_P(X+1) */ - {0, 1, 6}, /* map_modsel[2] = MODSEL_QSFP28_N_P(X+2) */ - {0, 1, 7}, /* map_modsel[3] = MODSEL_QSFP28_N_P(X+3) */ - {1, 1, 4}, /* map_modsel[4] = MODSEL_QSFP28_N_P(X+4) */ - {1, 1, 5}, /* map_modsel[5] = MODSEL_QSFP28_N_P(X+5) */ - {1, 1, 6}, /* map_modsel[6] = MODSEL_QSFP28_N_P(X+6) */ - {1, 1, 7}, /* map_modsel[7] = MODSEL_QSFP28_N_P(X+7) */ - }, -}; - - -struct ioexp_map_s ioexp_map_hudson32iga_p01p08_p17p24 = { - - .chip_amount = 3, - .data_width = 2, - - .map_present = { {2, 0, 0}, /* map_present[0] = MODABS_QSFP(X) */ - {2, 0, 1}, /* map_present[1] = MODABS_QSFP(X+1) */ - {2, 0, 2}, /* map_present[2] = MODABS_QSFP(X+2) */ - {2, 0, 3}, /* map_present[3] = MODABS_QSFP(X+3) */ - {2, 0, 4}, /* map_present[4] = MODABS_QSFP(X+4) */ - {2, 0, 5}, /* map_present[5] = MODABS_QSFP(X+5) */ - {2, 0, 6}, /* map_present[6] = MODABS_QSFP(X+6) */ - {2, 0, 7}, /* map_present[7] = MODABS_QSFP(X+7) */ - }, - .map_reset = { {0, 0, 0}, /* map_reset[0] = QRESET_QSFP(X) */ - {0, 0, 1}, /* map_reset[1] = QRESET_QSFP(X+1) */ - {0, 0, 2}, /* map_reset[2] = QRESET_QSFP(X+2) */ - {0, 0, 3}, /* map_reset[3] = QRESET_QSFP(X+3) */ - {1, 0, 0}, /* map_reset[4] = QRESET_QSFP(X+4) */ - {1, 0, 1}, /* map_reset[5] = QRESET_QSFP(X+5) */ - {1, 0, 2}, /* map_reset[6] = QRESET_QSFP(X+6) */ - {1, 0, 3}, /* map_reset[7] = QRESET_QSFP(X+7) */ - }, - .map_lpmod = { {0, 0, 4}, /* map_lpmod[0] = LPMODE_QSFP(X) */ - {0, 0, 5}, /* map_lpmod[1] = LPMODE_QSFP(X+1) */ - {0, 0, 6}, /* map_lpmod[2] = LPMODE_QSFP(X+2) */ - {0, 0, 7}, /* map_lpmod[3] = LPMODE_QSFP(X+3) */ - {1, 0, 4}, /* map_lpmod[4] = LPMODE_QSFP(X+4) */ - {1, 0, 5}, /* map_lpmod[5] = LPMODE_QSFP(X+5) */ - {1, 0, 6}, /* map_lpmod[6] = LPMODE_QSFP(X+6) */ - {1, 0, 7}, /* map_lpmod[7] = LPMODE_QSFP(X+7) */ - }, - .map_modsel = { {0, 1, 4}, /* map_modsel[0] = MODSEL_QSFP(X) */ - {0, 1, 5}, /* map_modsel[1] = MODSEL_QSFP(X+1) */ - {0, 1, 6}, /* map_modsel[2] = MODSEL_QSFP(X+2) */ - {0, 1, 7}, /* map_modsel[3] = MODSEL_QSFP(X+3) */ - {1, 1, 4}, /* map_modsel[4] = MODSEL_QSFP(X+4) */ - {1, 1, 5}, /* map_modsel[5] = MODSEL_QSFP(X+5) */ - {1, 1, 6}, /* map_modsel[6] = MODSEL_QSFP(X+6) */ - {1, 1, 7}, /* map_modsel[7] = MODSEL_QSFP(X+7) */ - }, -}; - - -struct ioexp_map_s ioexp_map_hudson32iga_p09p16_p25p32 = { - - .chip_amount = 3, - .data_width = 2, - - .map_present = { {2, 1, 0}, /* map_present[0] = MODABS_QSFP(X) */ - {2, 1, 1}, /* map_present[1] = MODABS_QSFP(X+1) */ - {2, 1, 2}, /* map_present[2] = MODABS_QSFP(X+2) */ - {2, 1, 3}, /* map_present[3] = MODABS_QSFP(X+3) */ - {2, 1, 4}, /* map_present[4] = MODABS_QSFP(X+4) */ - {2, 1, 5}, /* map_present[5] = MODABS_QSFP(X+5) */ - {2, 1, 6}, /* map_present[6] = MODABS_QSFP(X+6) */ - {2, 1, 7}, /* map_present[7] = MODABS_QSFP(X+7) */ - }, - .map_reset = { {0, 0, 0}, /* map_reset[0] = QRESET_QSFP(X) */ - {0, 0, 1}, /* map_reset[1] = QRESET_QSFP(X+1) */ - {0, 0, 2}, /* map_reset[2] = QRESET_QSFP(X+2) */ - {0, 0, 3}, /* map_reset[3] = QRESET_QSFP(X+3) */ - {1, 0, 0}, /* map_reset[4] = QRESET_QSFP(X+4) */ - {1, 0, 1}, /* map_reset[5] = QRESET_QSFP(X+5) */ - {1, 0, 2}, /* map_reset[6] = QRESET_QSFP(X+6) */ - {1, 0, 3}, /* map_reset[7] = QRESET_QSFP(X+7) */ - }, - .map_lpmod = { {0, 0, 4}, /* map_lpmod[0] = LPMODE_QSFP(X) */ - {0, 0, 5}, /* map_lpmod[1] = LPMODE_QSFP(X+1) */ - {0, 0, 6}, /* map_lpmod[2] = LPMODE_QSFP(X+2) */ - {0, 0, 7}, /* map_lpmod[3] = LPMODE_QSFP(X+3) */ - {1, 0, 4}, /* map_lpmod[4] = LPMODE_QSFP(X+4) */ - {1, 0, 5}, /* map_lpmod[5] = LPMODE_QSFP(X+5) */ - {1, 0, 6}, /* map_lpmod[6] = LPMODE_QSFP(X+6) */ - {1, 0, 7}, /* map_lpmod[7] = LPMODE_QSFP(X+7) */ - }, - .map_modsel = { {0, 1, 4}, /* map_modsel[0] = MODSEL_QSFP(X) */ - {0, 1, 5}, /* map_modsel[1] = MODSEL_QSFP(X+1) */ - {0, 1, 6}, /* map_modsel[2] = MODSEL_QSFP(X+2) */ - {0, 1, 7}, /* map_modsel[3] = MODSEL_QSFP(X+3) */ - {1, 1, 4}, /* map_modsel[4] = MODSEL_QSFP(X+4) */ - {1, 1, 5}, /* map_modsel[5] = MODSEL_QSFP(X+5) */ - {1, 1, 6}, /* map_modsel[6] = MODSEL_QSFP(X+6) */ - {1, 1, 7}, /* map_modsel[7] = MODSEL_QSFP(X+7) */ - }, -}; - - -struct ioexp_map_s ioexp_map_cypress_nabc = { - - .chip_amount = 3, - .data_width = 2, - - .map_present = { {0, 0, 4}, /* map_present[0] = MOD_ABS_PORT(X) */ - {0, 0, 5}, /* map_present[1] = MOD_ABS_PORT(X+1) */ - {0, 0, 6}, /* map_present[2] = MOD_ABS_PORT(X+2) */ - {0, 0, 7}, /* map_present[3] = MOD_ABS_PORT(X+3) */ - {1, 0, 4}, /* map_present[4] = MOD_ABS_PORT(X+4) */ - {1, 0, 5}, /* map_present[5] = MOD_ABS_PORT(X+5) */ - {1, 0, 6}, /* map_present[6] = MOD_ABS_PORT(X+6) */ - {1, 0, 7}, /* map_present[7] = MOD_ABS_PORT(X+7) */ - }, - .map_tx_disable = { {0, 1, 0}, /* map_tx_disable[0] = TXDISABLE_SFP+_P(X) */ - {0, 1, 1}, /* map_tx_disable[1] = TXDISABLE_SFP+_P(X+1) */ - {0, 1, 2}, /* map_tx_disable[2] = TXDISABLE_SFP+_P(X+2) */ - {0, 1, 3}, /* map_tx_disable[3] = TXDISABLE_SFP+_P(X+3) */ - {1, 1, 0}, /* map_tx_disable[4] = TXDISABLE_SFP+_P(X+4) */ - {1, 1, 1}, /* map_tx_disable[5] = TXDISABLE_SFP+_P(X+5) */ - {1, 1, 2}, /* map_tx_disable[6] = TXDISABLE_SFP+_P(X+6) */ - {1, 1, 3}, /* map_tx_disable[7] = TXDISABLE_SFP+_P(X+7) */ - }, - .map_tx_fault = { {0, 0, 0}, /* map_tx_fault[0] = TXFAULT_SFP+_P(X) */ - {0, 0, 1}, /* map_tx_fault[1] = TXFAULT_SFP+_P(X+1) */ - {0, 0, 2}, /* map_tx_fault[2] = TXFAULT_SFP+_P(X+2) */ - {0, 0, 3}, /* map_tx_fault[3] = TXFAULT_SFP+_P(X+3) */ - {1, 0, 0}, /* map_tx_fault[4] = TXFAULT_SFP+_P(X+4) */ - {1, 0, 1}, /* map_tx_fault[5] = TXFAULT_SFP+_P(X+5) */ - {1, 0, 2}, /* map_tx_fault[6] = TXFAULT_SFP+_P(X+6) */ - {1, 0, 3}, /* map_tx_fault[7] = TXFAULT_SFP+_P(X+7) */ - }, - .map_rxlos = { {0, 1, 4}, /* map_rxlos[0] = OPRXLOS_PORT(X) */ - {0, 1, 5}, /* map_rxlos[1] = OPRXLOS_PORT(X+1) */ - {0, 1, 6}, /* map_rxlos[2] = OPRXLOS_PORT(X+2) */ - {0, 1, 7}, /* map_rxlos[3] = OPRXLOS_PORT(X+3) */ - {1, 1, 4}, /* map_rxlos[4] = OPRXLOS_PORT(X+4) */ - {1, 1, 5}, /* map_rxlos[5] = OPRXLOS_PORT(X+5) */ - {1, 1, 6}, /* map_rxlos[6] = OPRXLOS_PORT(X+6) */ - {1, 1, 7}, /* map_rxlos[7] = OPRXLOS_PORT(X+7) */ - }, - .map_hard_rs0 = { {2, 0, 0}, /* map_hard_rs0[0] = RS0_SFP28_P(X) */ - {2, 0, 2}, /* map_hard_rs0[1] = RS0_SFP28_P(X+1) */ - {2, 0, 4}, /* map_hard_rs0[2] = RS0_SFP28_P(X+2) */ - {2, 0, 6}, /* map_hard_rs0[3] = RS0_SFP28_P(X+3) */ - {2, 1, 0}, /* map_hard_rs0[4] = RS0_SFP28_P(X+4) */ - {2, 1, 2}, /* map_hard_rs0[5] = RS0_SFP28_P(X+5) */ - {2, 1, 4}, /* map_hard_rs0[6] = RS0_SFP28_P(X+6) */ - {2, 1, 6}, /* map_hard_rs0[7] = RS0_SFP28_P(X+7) */ - }, - .map_hard_rs1 = { {2, 0, 1}, /* map_hard_rs1[0] = RS1_SFP28_P(X) */ - {2, 0, 3}, /* map_hard_rs1[1] = RS1_SFP28_P(X+1) */ - {2, 0, 5}, /* map_hard_rs1[2] = RS1_SFP28_P(X+2) */ - {2, 0, 7}, /* map_hard_rs1[3] = RS1_SFP28_P(X+3) */ - {2, 1, 1}, /* map_hard_rs1[4] = RS1_SFP28_P(X+4) */ - {2, 1, 3}, /* map_hard_rs1[5] = RS1_SFP28_P(X+5) */ - {2, 1, 5}, /* map_hard_rs1[6] = RS1_SFP28_P(X+6) */ - {2, 1, 7}, /* map_hard_rs1[7] = RS1_SFP28_P(X+7) */ - }, -}; - - -struct ioexp_map_s ioexp_map_cypress_7abc = { - - .chip_amount = 3, - .data_width = 2, - - .map_present = { {2, 0, 0}, /* map_present[0] = MOD_ABS_PORT(X) */ - {2, 0, 1}, /* map_present[1] = MOD_ABS_PORT(X+1) */ - {2, 0, 2}, /* map_present[2] = MOD_ABS_PORT(X+2) */ - {2, 0, 3}, /* map_present[3] = MOD_ABS_PORT(X+3) */ - {2, 0, 4}, /* map_present[4] = MOD_ABS_PORT(X+4) */ - {2, 0, 5}, /* map_present[5] = MOD_ABS_PORT(X+5) */ - }, - .map_reset = { {0, 0, 0}, /* map_reset[0] = QRESET_QSFP_N_P(X) */ - {0, 0, 1}, /* map_reset[1] = QRESET_QSFP_N_P(X+1) */ - {0, 0, 2}, /* map_reset[2] = QRESET_QSFP_N_P(X+2) */ - {0, 0, 3}, /* map_reset[3] = QRESET_QSFP_N_P(X+3) */ - {0, 0, 4}, /* map_reset[4] = QRESET_QSFP_N_P(X+4) */ - {0, 0, 5}, /* map_reset[5] = QRESET_QSFP_N_P(X+5) */ - }, - .map_lpmod = { {0, 1, 0}, /* map_lpmod[0] = LPMODE_QSFP_P(X) */ - {0, 1, 1}, /* map_lpmod[1] = LPMODE_QSFP_P(X+1) */ - {0, 1, 2}, /* map_lpmod[2] = LPMODE_QSFP_P(X+2) */ - {0, 1, 3}, /* map_lpmod[3] = LPMODE_QSFP_P(X+3) */ - {0, 1, 4}, /* map_lpmod[4] = LPMODE_QSFP_P(X+4) */ - {0, 1, 5}, /* map_lpmod[5] = LPMODE_QSFP_P(X+5) */ - }, - .map_modsel = { {1, 1, 0}, /* map_modsel[0] = MODSEL_QSFP_N_P(X) */ - {1, 1, 1}, /* map_modsel[1] = MODSEL_QSFP_N_P(X+1) */ - {1, 1, 2}, /* map_modsel[2] = MODSEL_QSFP_N_P(X+2) */ - {1, 1, 3}, /* map_modsel[3] = MODSEL_QSFP_N_P(X+3) */ - {1, 1, 4}, /* map_modsel[4] = MODSEL_QSFP_N_P(X+4) */ - {1, 1, 5}, /* map_modsel[5] = MODSEL_QSFP_N_P(X+5) */ - }, -}; - - -struct ioexp_map_s ioexp_map_tahoe_5a = { - - .chip_amount = 1, - .data_width = 2, - - .map_present = { {0, 0, 3}, /* map_present[0] = MOD_ABS_PORT(X) */ - {0, 1, 0}, /* map_present[1] = MOD_ABS_PORT(X+1) */ - {0, 1, 5}, /* map_present[2] = MOD_ABS_PORT(X+2) */ - }, - .map_reset = { {0, 0, 1}, /* map_reset[0] = QRESET_QSFP_N_P(X) */ - {0, 0, 6}, /* map_reset[1] = QRESET_QSFP_N_P(X+1) */ - {0, 1, 3}, /* map_reset[2] = QRESET_QSFP_N_P(X+2) */ - }, - .map_lpmod = { {0, 0, 2}, /* map_lpmod[0] = LPMODE_QSFP_P(X) */ - {0, 0, 7}, /* map_lpmod[1] = LPMODE_QSFP_P(X+1) */ - {0, 1, 4}, /* map_lpmod[2] = LPMODE_QSFP_P(X+2) */ - }, - .map_modsel = { {0, 0, 0}, /* map_modsel[0] = MODSEL_QSFP_N_P(X) */ - {0, 0, 5}, /* map_modsel[1] = MODSEL_QSFP_N_P(X+1) */ - {0, 1, 2}, /* map_modsel[2] = MODSEL_QSFP_N_P(X+2) */ - }, -}; - - -struct ioexp_map_s ioexp_map_tahoe_6abc = { - - .chip_amount = 3, - .data_width = 2, - - .map_present = { {0, 0, 3}, /* map_present[0] = MOD_ABS_PORT(X) */ - {0, 1, 0}, /* map_present[1] = MOD_ABS_PORT(X+1) */ - {0, 1, 5}, /* map_present[2] = MOD_ABS_PORT(X+2) */ - {1, 0, 3}, /* map_present[3] = MOD_ABS_PORT(X+3) */ - {1, 1, 0}, /* map_present[4] = MOD_ABS_PORT(X+4) */ - {1, 1, 5}, /* map_present[5] = MOD_ABS_PORT(X+5) */ - {2, 0, 3}, /* map_present[6] = MOD_ABS_PORT(X+6) */ - {2, 1, 0}, /* map_present[7] = MOD_ABS_PORT(X+7) */ - {2, 1, 5}, /* map_present[8] = MOD_ABS_PORT(X+8) */ - }, - .map_reset = { {0, 0, 1}, /* map_reset[0] = QRESET_QSFP28_N_P(X) */ - {0, 0, 6}, /* map_reset[1] = QRESET_QSFP28_N_P(X+1) */ - {0, 1, 3}, /* map_reset[2] = QRESET_QSFP28_N_P(X+2) */ - {1, 0, 1}, /* map_reset[3] = QRESET_QSFP28_N_P(X+3) */ - {1, 0, 6}, /* map_reset[4] = QRESET_QSFP28_N_P(X+4) */ - {1, 1, 3}, /* map_reset[5] = QRESET_QSFP28_N_P(X+5) */ - {2, 0, 1}, /* map_reset[6] = QRESET_QSFP28_N_P(X+6) */ - {2, 0, 6}, /* map_reset[7] = QRESET_QSFP28_N_P(X+7) */ - {2, 1, 3}, /* map_reset[7] = QRESET_QSFP28_N_P(X+7) */ - }, - .map_lpmod = { {0, 0, 2}, /* map_lpmod[0] = LPMODE_QSFP28_P(X) */ - {0, 0, 7}, /* map_lpmod[1] = LPMODE_QSFP28_P(X+1) */ - {0, 1, 4}, /* map_lpmod[2] = LPMODE_QSFP28_P(X+2) */ - {1, 0, 2}, /* map_lpmod[3] = LPMODE_QSFP28_P(X+3) */ - {1, 0, 7}, /* map_lpmod[4] = LPMODE_QSFP28_P(X+4) */ - {1, 1, 4}, /* map_lpmod[5] = LPMODE_QSFP28_P(X+5) */ - {2, 0, 2}, /* map_lpmod[6] = LPMODE_QSFP28_P(X+6) */ - {2, 0, 7}, /* map_lpmod[7] = LPMODE_QSFP28_P(X+7) */ - {2, 1, 4}, /* map_lpmod[7] = LPMODE_QSFP28_P(X+8) */ - }, - .map_modsel = { {0, 0, 0}, /* map_modsel[0] = MODSEL_QSFP28_N_P(X) */ - {0, 0, 5}, /* map_modsel[1] = MODSEL_QSFP28_N_P(X+1) */ - {0, 1, 2}, /* map_modsel[2] = MODSEL_QSFP28_N_P(X+2) */ - {1, 0, 0}, /* map_modsel[3] = MODSEL_QSFP28_N_P(X+3) */ - {1, 0, 5}, /* map_modsel[4] = MODSEL_QSFP28_N_P(X+4) */ - {1, 1, 2}, /* map_modsel[5] = MODSEL_QSFP28_N_P(X+5) */ - {2, 0, 0}, /* map_modsel[6] = MODSEL_QSFP28_N_P(X+6) */ - {2, 0, 5}, /* map_modsel[7] = MODSEL_QSFP28_N_P(X+7) */ - {2, 1, 2}, /* map_modsel[7] = MODSEL_QSFP28_N_P(X+7) */ - }, -}; - - -struct ioexp_map_s ioexp_map_sequoia_nabc = { - - .chip_amount = 3, - .data_width = 2, - - .map_present = { {2, 1, 0}, /* map_present[0] = MOD_ABS_PORT(X) */ - {2, 1, 1}, /* map_present[1] = MOD_ABS_PORT(X+1) */ - {2, 1, 2}, /* map_present[2] = MOD_ABS_PORT(X+2) */ - {2, 1, 3}, /* map_present[3] = MOD_ABS_PORT(X+3) */ - {2, 1, 4}, /* map_present[4] = MOD_ABS_PORT(X+4) */ - {2, 1, 5}, /* map_present[5] = MOD_ABS_PORT(X+5) */ - {2, 1, 6}, /* map_present[6] = MOD_ABS_PORT(X+6) */ - {2, 1, 7}, /* map_present[7] = MOD_ABS_PORT(X+7) */ - }, - .map_reset = { {0, 1, 0}, /* map_reset[0] = QRESET_QSFP28_N_P(X) */ - {0, 1, 1}, /* map_reset[1] = QRESET_QSFP28_N_P(X+1) */ - {0, 1, 2}, /* map_reset[2] = QRESET_QSFP28_N_P(X+2) */ - {0, 1, 3}, /* map_reset[3] = QRESET_QSFP28_N_P(X+3) */ - {0, 1, 4}, /* map_reset[4] = QRESET_QSFP28_N_P(X+4) */ - {0, 1, 5}, /* map_reset[5] = QRESET_QSFP28_N_P(X+5) */ - {0, 1, 6}, /* map_reset[6] = QRESET_QSFP28_N_P(X+6) */ - {0, 1, 7}, /* map_reset[7] = QRESET_QSFP28_N_P(X+7) */ - }, - .map_lpmod = { {1, 0, 0}, /* map_lpmod[0] = LPMODE_QSFP28_P(X) */ - {1, 0, 1}, /* map_lpmod[1] = LPMODE_QSFP28_P(X+1) */ - {1, 0, 2}, /* map_lpmod[2] = LPMODE_QSFP28_P(X+2) */ - {1, 0, 3}, /* map_lpmod[3] = LPMODE_QSFP28_P(X+3) */ - {1, 0, 4}, /* map_lpmod[4] = LPMODE_QSFP28_P(X+4) */ - {1, 0, 5}, /* map_lpmod[5] = LPMODE_QSFP28_P(X+5) */ - {1, 0, 6}, /* map_lpmod[6] = LPMODE_QSFP28_P(X+6) */ - {1, 0, 7}, /* map_lpmod[7] = LPMODE_QSFP28_P(X+7) */ - }, - .map_modsel = { {0, 0, 0}, /* map_modsel[0] = MODSEL_QSFP28_N_P(X) */ - {0, 0, 1}, /* map_modsel[1] = MODSEL_QSFP28_N_P(X+1) */ - {0, 0, 2}, /* map_modsel[2] = MODSEL_QSFP28_N_P(X+2) */ - {0, 0, 3}, /* map_modsel[3] = MODSEL_QSFP28_N_P(X+3) */ - {0, 0, 4}, /* map_modsel[4] = MODSEL_QSFP28_N_P(X+4) */ - {0, 0, 5}, /* map_modsel[5] = MODSEL_QSFP28_N_P(X+5) */ - {0, 0, 6}, /* map_modsel[6] = MODSEL_QSFP28_N_P(X+6) */ - {0, 0, 7}, /* map_modsel[7] = MODSEL_QSFP28_N_P(X+7) */ - }, -}; - - -struct ioexp_map_s ioexp_map_lavender_p65 = { - - .chip_amount = 1, - .data_width = 1, - - .map_present = { {0, 0, 4}, }, /* map_present[0] = MOD_ABS_PORT(X) */ - .map_reset = { {0, 0, 1}, }, /* map_reset[0] = QRESET_QSFP28_N_P(X) */ - .map_lpmod = { {0, 0, 2}, }, /* map_lpmod[0] = LPMODE_QSFP28_P(X) */ - .map_modsel = { {0, 0, 0}, }, /* map_modsel[0] = MODSEL_QSFP28_N_P(X) */ -}; - - -struct ioexp_map_s cpld_map_cottonwood = { - - .chip_amount = 1, - .data_width = 4, - - .map_present = { {0, 2, 0}, /* map_present[0] = MOD_ABS_PORT(X) */ - {0, 2, 4}, /* map_present[1] = MOD_ABS_PORT(X+1) */ - {0, 3, 0}, /* map_present[2] = MOD_ABS_PORT(X+2) */ - {0, 3, 4}, /* map_present[3] = MOD_ABS_PORT(X+3) */ - }, - .map_tx_disable = { {0, 0, 0}, /* map_tx_disable[0] = TXDISABLE_SFP+_P(X) */ - {0, 0, 4}, /* map_tx_disable[1] = TXDISABLE_SFP+_P(X+1) */ - {0, 1, 0}, /* map_tx_disable[2] = TXDISABLE_SFP+_P(X+2) */ - {0, 1, 4}, /* map_tx_disable[3] = TXDISABLE_SFP+_P(X+3) */ - }, - .map_tx_fault = { {0, 2, 2}, /* map_tx_fault[0] = TXFAULT_SFP+_P(X) */ - {0, 2, 6}, /* map_tx_fault[1] = TXFAULT_SFP+_P(X+1) */ - {0, 3, 2}, /* map_tx_fault[2] = TXFAULT_SFP+_P(X+2) */ - {0, 3, 6}, /* map_tx_fault[3] = TXFAULT_SFP+_P(X+3) */ - }, - .map_rxlos = { {0, 2, 1}, /* map_rxlos[0] = OPRXLOS_PORT(X) */ - {0, 2, 5}, /* map_rxlos[1] = OPRXLOS_PORT(X+1) */ - {0, 3, 1}, /* map_rxlos[2] = OPRXLOS_PORT(X+2) */ - {0, 3, 5}, /* map_rxlos[3] = OPRXLOS_PORT(X+3) */ - }, - .map_hard_rs0 = { {0, 0, 2}, /* map_hard_rs0[0] = RS0_SFP28_P(X) */ - {0, 0, 6}, /* map_hard_rs0[1] = RS0_SFP28_P(X+1) */ - {0, 1, 2}, /* map_hard_rs0[2] = RS0_SFP28_P(X+2) */ - {0, 1, 6}, /* map_hard_rs0[3] = RS0_SFP28_P(X+3) */ - }, - .map_hard_rs1 = { {0, 0, 2}, /* map_hard_rs1[0] = RS1_SFP28_P(X) */ - {0, 0, 6}, /* map_hard_rs1[1] = RS1_SFP28_P(X+1) */ - {0, 1, 2}, /* map_hard_rs1[2] = RS1_SFP28_P(X+2) */ - {0, 1, 6}, /* map_hard_rs1[3] = RS1_SFP28_P(X+3) */ - }, -}; - - -struct ioexp_map_s ioexp_map_maple_0abc = { - - .chip_amount = 3, - .data_width = 2, - - .map_present = { {2, 1, 0}, /* map_present[0] = MOD_ABS_PORT(X) */ - {2, 1, 1}, /* map_present[1] = MOD_ABS_PORT(X+1) */ - {2, 1, 2}, /* map_present[2] = MOD_ABS_PORT(X+2) */ - {2, 1, 3}, /* map_present[3] = MOD_ABS_PORT(X+3) */ - {2, 1, 4}, /* map_present[4] = MOD_ABS_PORT(X+4) */ - {2, 1, 5}, /* map_present[5] = MOD_ABS_PORT(X+5) */ - {2, 1, 6}, /* map_present[6] = MOD_ABS_PORT(X+6) */ - {2, 1, 7}, /* map_present[7] = MOD_ABS_PORT(X+7) */ - }, - .map_reset = { {0, 1, 0}, /* map_reset[0] = QRESET_QSFP_N_P(X) */ - {0, 1, 1}, /* map_reset[1] = QRESET_QSFP_N_P(X+1) */ - {0, 1, 2}, /* map_reset[2] = QRESET_QSFP_N_P(X+2) */ - {0, 1, 3}, /* map_reset[3] = QRESET_QSFP_N_P(X+3) */ - {0, 1, 4}, /* map_reset[4] = QRESET_QSFP_N_P(X+4) */ - {0, 1, 5}, /* map_reset[5] = QRESET_QSFP_N_P(X+5) */ - {0, 1, 6}, /* map_reset[6] = QRESET_QSFP_N_P(X+6) */ - {0, 1, 7}, /* map_reset[7] = QRESET_QSFP_N_P(X+7) */ - }, - .map_lpmod = { {1, 0, 0}, /* map_lpmod[0] = LPMODE_QSFP_P(X) */ - {1, 0, 1}, /* map_lpmod[1] = LPMODE_QSFP_P(X+1) */ - {1, 0, 2}, /* map_lpmod[2] = LPMODE_QSFP_P(X+2) */ - {1, 0, 3}, /* map_lpmod[3] = LPMODE_QSFP_P(X+3) */ - {1, 0, 4}, /* map_lpmod[4] = LPMODE_QSFP_P(X+4) */ - {1, 0, 5}, /* map_lpmod[5] = LPMODE_QSFP_P(X+5) */ - {1, 0, 6}, /* map_lpmod[6] = LPMODE_QSFP_P(X+6) */ - {1, 0, 7}, /* map_lpmod[7] = LPMODE_QSFP_P(X+7) */ - }, - .map_modsel = { {0, 0, 0}, /* map_modsel[0] = MODSEL_QSFP_N_P(X) */ - {0, 0, 1}, /* map_modsel[1] = MODSEL_QSFP_N_P(X+1) */ - {0, 0, 2}, /* map_modsel[2] = MODSEL_QSFP_N_P(X+2) */ - {0, 0, 3}, /* map_modsel[3] = MODSEL_QSFP_N_P(X+3) */ - {0, 0, 4}, /* map_modsel[4] = MODSEL_QSFP_N_P(X+4) */ - {0, 0, 5}, /* map_modsel[5] = MODSEL_QSFP_N_P(X+5) */ - {0, 0, 6}, /* map_modsel[6] = MODSEL_QSFP_N_P(X+6) */ - {0, 0, 7}, /* map_modsel[7] = MODSEL_QSFP_N_P(X+7) */ - }, -}; - - -struct ioexp_map_s ioexp_map_maple_nabc = { - - .chip_amount = 3, - .data_width = 2, - - .map_present = { {0, 0, 4}, /* map_present[0] = MOD_ABS_PORT(X) */ - {0, 0, 5}, /* map_present[1] = MOD_ABS_PORT(X+1) */ - {0, 0, 6}, /* map_present[2] = MOD_ABS_PORT(X+2) */ - {0, 0, 7}, /* map_present[3] = MOD_ABS_PORT(X+3) */ - {1, 0, 4}, /* map_present[4] = MOD_ABS_PORT(X+4) */ - {1, 0, 5}, /* map_present[5] = MOD_ABS_PORT(X+5) */ - {1, 0, 6}, /* map_present[6] = MOD_ABS_PORT(X+6) */ - {1, 0, 7}, /* map_present[7] = MOD_ABS_PORT(X+7) */ - }, - .map_tx_disable = { {0, 1, 0}, /* map_tx_disable[0] = TXDISABLE_SFP+_P(X) */ - {0, 1, 1}, /* map_tx_disable[1] = TXDISABLE_SFP+_P(X+1) */ - {0, 1, 2}, /* map_tx_disable[2] = TXDISABLE_SFP+_P(X+2) */ - {0, 1, 3}, /* map_tx_disable[3] = TXDISABLE_SFP+_P(X+3) */ - {1, 1, 0}, /* map_tx_disable[4] = TXDISABLE_SFP+_P(X+4) */ - {1, 1, 1}, /* map_tx_disable[5] = TXDISABLE_SFP+_P(X+5) */ - {1, 1, 2}, /* map_tx_disable[6] = TXDISABLE_SFP+_P(X+6) */ - {1, 1, 3}, /* map_tx_disable[7] = TXDISABLE_SFP+_P(X+7) */ - }, - .map_tx_fault = { {0, 0, 0}, /* map_tx_fault[0] = TXFAULT_SFP+_P(X) */ - {0, 0, 1}, /* map_tx_fault[1] = TXFAULT_SFP+_P(X+1) */ - {0, 0, 2}, /* map_tx_fault[2] = TXFAULT_SFP+_P(X+2) */ - {0, 0, 3}, /* map_tx_fault[3] = TXFAULT_SFP+_P(X+3) */ - {1, 0, 0}, /* map_tx_fault[4] = TXFAULT_SFP+_P(X+4) */ - {1, 0, 1}, /* map_tx_fault[5] = TXFAULT_SFP+_P(X+5) */ - {1, 0, 2}, /* map_tx_fault[6] = TXFAULT_SFP+_P(X+6) */ - {1, 0, 3}, /* map_tx_fault[7] = TXFAULT_SFP+_P(X+7) */ - }, - .map_rxlos = { {0, 1, 4}, /* map_rxlos[0] = OPRXLOS_PORT(X) */ - {0, 1, 5}, /* map_rxlos[1] = OPRXLOS_PORT(X+1) */ - {0, 1, 6}, /* map_rxlos[2] = OPRXLOS_PORT(X+2) */ - {0, 1, 7}, /* map_rxlos[3] = OPRXLOS_PORT(X+3) */ - {1, 1, 4}, /* map_rxlos[4] = OPRXLOS_PORT(X+4) */ - {1, 1, 5}, /* map_rxlos[5] = OPRXLOS_PORT(X+5) */ - {1, 1, 6}, /* map_rxlos[6] = OPRXLOS_PORT(X+6) */ - {1, 1, 7}, /* map_rxlos[7] = OPRXLOS_PORT(X+7) */ - }, - .map_hard_rs0 = { {2, 0, 0}, /* map_hard_rs0[0] = RS0_SFP28_P(X) */ - {2, 0, 2}, /* map_hard_rs0[1] = RS0_SFP28_P(X+1) */ - {2, 0, 4}, /* map_hard_rs0[2] = RS0_SFP28_P(X+2) */ - {2, 0, 6}, /* map_hard_rs0[3] = RS0_SFP28_P(X+3) */ - {2, 1, 0}, /* map_hard_rs0[4] = RS0_SFP28_P(X+4) */ - {2, 1, 2}, /* map_hard_rs0[5] = RS0_SFP28_P(X+5) */ - {2, 1, 4}, /* map_hard_rs0[6] = RS0_SFP28_P(X+6) */ - {2, 1, 6}, /* map_hard_rs0[7] = RS0_SFP28_P(X+7) */ - }, - .map_hard_rs1 = { {2, 0, 1}, /* map_hard_rs1[0] = RS1_SFP28_P(X) */ - {2, 0, 3}, /* map_hard_rs1[1] = RS1_SFP28_P(X+1) */ - {2, 0, 5}, /* map_hard_rs1[2] = RS1_SFP28_P(X+2) */ - {2, 0, 7}, /* map_hard_rs1[3] = RS1_SFP28_P(X+3) */ - {2, 1, 1}, /* map_hard_rs1[4] = RS1_SFP28_P(X+4) */ - {2, 1, 3}, /* map_hard_rs1[5] = RS1_SFP28_P(X+5) */ - {2, 1, 5}, /* map_hard_rs1[6] = RS1_SFP28_P(X+6) */ - {2, 1, 7}, /* map_hard_rs1[7] = RS1_SFP28_P(X+7) */ - }, -}; - - -struct ioexp_map_s ioexp_map_gulmohar_nabc = { - - .chip_amount = 3, - .data_width = 2, - - .map_present = { {0, 0, 4}, /* map_present[0] = MOD_ABS_PORT(X) */ - {0, 0, 5}, /* map_present[1] = MOD_ABS_PORT(X+1) */ - {0, 1, 4}, /* map_present[2] = MOD_ABS_PORT(X+2) */ - {0, 1, 5}, /* map_present[3] = MOD_ABS_PORT(X+3) */ - {1, 0, 4}, /* map_present[4] = MOD_ABS_PORT(X+4) */ - {1, 0, 5}, /* map_present[5] = MOD_ABS_PORT(X+5) */ - {1, 1, 4}, /* map_present[6] = MOD_ABS_PORT(X+6) */ - {1, 1, 5}, /* map_present[7] = MOD_ABS_PORT(X+7) */ - }, - .map_tx_disable = { {0, 0, 2}, /* map_tx_disable[0] = TXDISABLE_SFP+_P(X) */ - {0, 0, 3}, /* map_tx_disable[1] = TXDISABLE_SFP+_P(X+1) */ - {0, 1, 2}, /* map_tx_disable[2] = TXDISABLE_SFP+_P(X+2) */ - {0, 1, 3}, /* map_tx_disable[3] = TXDISABLE_SFP+_P(X+3) */ - {1, 0, 2}, /* map_tx_disable[4] = TXDISABLE_SFP+_P(X+4) */ - {1, 0, 3}, /* map_tx_disable[5] = TXDISABLE_SFP+_P(X+5) */ - {1, 1, 2}, /* map_tx_disable[6] = TXDISABLE_SFP+_P(X+6) */ - {1, 1, 3}, /* map_tx_disable[7] = TXDISABLE_SFP+_P(X+7) */ - }, - .map_tx_fault = { {0, 0, 0}, /* map_tx_fault[0] = TXFAULT_SFP+_P(X) */ - {0, 0, 1}, /* map_tx_fault[1] = TXFAULT_SFP+_P(X+1) */ - {0, 1, 0}, /* map_tx_fault[2] = TXFAULT_SFP+_P(X+2) */ - {0, 1, 1}, /* map_tx_fault[3] = TXFAULT_SFP+_P(X+3) */ - {1, 0, 0}, /* map_tx_fault[4] = TXFAULT_SFP+_P(X+4) */ - {1, 0, 1}, /* map_tx_fault[5] = TXFAULT_SFP+_P(X+5) */ - {1, 1, 0}, /* map_tx_fault[6] = TXFAULT_SFP+_P(X+6) */ - {1, 1, 1}, /* map_tx_fault[7] = TXFAULT_SFP+_P(X+7) */ - }, - .map_rxlos = { {0, 0, 6}, /* map_rxlos[0] = OPRXLOS_PORT(X) */ - {0, 0, 7}, /* map_rxlos[1] = OPRXLOS_PORT(X+1) */ - {0, 1, 6}, /* map_rxlos[2] = OPRXLOS_PORT(X+2) */ - {0, 1, 7}, /* map_rxlos[3] = OPRXLOS_PORT(X+3) */ - {1, 0, 6}, /* map_rxlos[4] = OPRXLOS_PORT(X+4) */ - {1, 0, 7}, /* map_rxlos[5] = OPRXLOS_PORT(X+5) */ - {1, 1, 6}, /* map_rxlos[6] = OPRXLOS_PORT(X+6) */ - {1, 1, 7}, /* map_rxlos[7] = OPRXLOS_PORT(X+7) */ - }, - .map_hard_rs0 = { {2, 0, 0}, /* map_hard_rs0[0] = RS0_SFP28_P(X) */ - {2, 0, 2}, /* map_hard_rs0[1] = RS0_SFP28_P(X+1) */ - {2, 0, 4}, /* map_hard_rs0[2] = RS0_SFP28_P(X+2) */ - {2, 0, 6}, /* map_hard_rs0[3] = RS0_SFP28_P(X+3) */ - {2, 1, 0}, /* map_hard_rs0[4] = RS0_SFP28_P(X+4) */ - {2, 1, 2}, /* map_hard_rs0[5] = RS0_SFP28_P(X+5) */ - {2, 1, 4}, /* map_hard_rs0[6] = RS0_SFP28_P(X+6) */ - {2, 1, 6}, /* map_hard_rs0[7] = RS0_SFP28_P(X+7) */ - }, - .map_hard_rs1 = { {2, 0, 1}, /* map_hard_rs1[0] = RS1_SFP28_P(X) */ - {2, 0, 3}, /* map_hard_rs1[1] = RS1_SFP28_P(X+1) */ - {2, 0, 5}, /* map_hard_rs1[2] = RS1_SFP28_P(X+2) */ - {2, 0, 7}, /* map_hard_rs1[3] = RS1_SFP28_P(X+3) */ - {2, 1, 1}, /* map_hard_rs1[4] = RS1_SFP28_P(X+4) */ - {2, 1, 3}, /* map_hard_rs1[5] = RS1_SFP28_P(X+5) */ - {2, 1, 5}, /* map_hard_rs1[6] = RS1_SFP28_P(X+6) */ - {2, 1, 7}, /* map_hard_rs1[7] = RS1_SFP28_P(X+7) */ - }, -}; - - -struct ioexp_map_s ioexp_map_gulmohar_7abc = { - - .chip_amount = 3, - .data_width = 2, - - .map_present = { {2, 1, 0}, /* map_present[0] = MOD_ABS_PORT(X) */ - {2, 1, 1}, /* map_present[1] = MOD_ABS_PORT(X+1) */ - {2, 1, 2}, /* map_present[2] = MOD_ABS_PORT(X+2) */ - {2, 1, 3}, /* map_present[3] = MOD_ABS_PORT(X+3) */ - {2, 1, 4}, /* map_present[4] = MOD_ABS_PORT(X+4) */ - {2, 1, 5}, /* map_present[5] = MOD_ABS_PORT(X+5) */ - }, - .map_reset = { {0, 1, 0}, /* map_reset[0] = QRESET_QSFP_N_P(X) */ - {0, 1, 1}, /* map_reset[1] = QRESET_QSFP_N_P(X+1) */ - {0, 1, 2}, /* map_reset[2] = QRESET_QSFP_N_P(X+2) */ - {0, 1, 3}, /* map_reset[3] = QRESET_QSFP_N_P(X+3) */ - {0, 1, 4}, /* map_reset[4] = QRESET_QSFP_N_P(X+4) */ - {0, 1, 5}, /* map_reset[5] = QRESET_QSFP_N_P(X+5) */ - }, - .map_lpmod = { {1, 0, 0}, /* map_lpmod[0] = LPMODE_QSFP_P(X) */ - {1, 0, 1}, /* map_lpmod[1] = LPMODE_QSFP_P(X+1) */ - {1, 0, 2}, /* map_lpmod[2] = LPMODE_QSFP_P(X+2) */ - {1, 0, 3}, /* map_lpmod[3] = LPMODE_QSFP_P(X+3) */ - {1, 0, 4}, /* map_lpmod[4] = LPMODE_QSFP_P(X+4) */ - {1, 0, 5}, /* map_lpmod[5] = LPMODE_QSFP_P(X+5) */ - }, - .map_modsel = { {0, 0, 0}, /* map_modsel[0] = MODSEL_QSFP_N_P(X) */ - {0, 0, 1}, /* map_modsel[1] = MODSEL_QSFP_N_P(X+1) */ - {0, 0, 2}, /* map_modsel[2] = MODSEL_QSFP_N_P(X+2) */ - {0, 0, 3}, /* map_modsel[3] = MODSEL_QSFP_N_P(X+3) */ - {0, 0, 4}, /* map_modsel[4] = MODSEL_QSFP_N_P(X+4) */ - {0, 0, 5}, /* map_modsel[5] = MODSEL_QSFP_N_P(X+5) */ - }, -}; - - -struct ioexp_map_s ioexp_map_gulmohar_2t_evt1_nabc = { - - .chip_amount = 3, - .data_width = 2, - - .map_present = { {0, 0, 2}, /* map_present[0] = MOD_ABS_PORT(X) */ - {0, 0, 6}, /* map_present[1] = MOD_ABS_PORT(X+1) */ - {0, 1, 2}, /* map_present[2] = MOD_ABS_PORT(X+2) */ - {0, 1, 6}, /* map_present[3] = MOD_ABS_PORT(X+3) */ - {1, 0, 2}, /* map_present[4] = MOD_ABS_PORT(X+4) */ - {1, 0, 6}, /* map_present[5] = MOD_ABS_PORT(X+5) */ - {1, 1, 2}, /* map_present[6] = MOD_ABS_PORT(X+6) */ - {1, 1, 6}, /* map_present[7] = MOD_ABS_PORT(X+7) */ - }, - .map_tx_disable = { {0, 0, 1}, /* map_tx_disable[0] = TXDISABLE_SFP+_P(X) */ - {0, 0, 5}, /* map_tx_disable[1] = TXDISABLE_SFP+_P(X+1) */ - {0, 1, 1}, /* map_tx_disable[2] = TXDISABLE_SFP+_P(X+2) */ - {0, 1, 5}, /* map_tx_disable[3] = TXDISABLE_SFP+_P(X+3) */ - {1, 0, 1}, /* map_tx_disable[4] = TXDISABLE_SFP+_P(X+4) */ - {1, 0, 5}, /* map_tx_disable[5] = TXDISABLE_SFP+_P(X+5) */ - {1, 1, 1}, /* map_tx_disable[6] = TXDISABLE_SFP+_P(X+6) */ - {1, 1, 5}, /* map_tx_disable[7] = TXDISABLE_SFP+_P(X+7) */ - }, - .map_tx_fault = { {0, 0, 0}, /* map_tx_fault[0] = TXFAULT_SFP+_P(X) */ - {0, 0, 4}, /* map_tx_fault[1] = TXFAULT_SFP+_P(X+1) */ - {0, 1, 0}, /* map_tx_fault[2] = TXFAULT_SFP+_P(X+2) */ - {0, 1, 4}, /* map_tx_fault[3] = TXFAULT_SFP+_P(X+3) */ - {1, 0, 0}, /* map_tx_fault[4] = TXFAULT_SFP+_P(X+4) */ - {1, 0, 4}, /* map_tx_fault[5] = TXFAULT_SFP+_P(X+5) */ - {1, 1, 0}, /* map_tx_fault[6] = TXFAULT_SFP+_P(X+6) */ - {1, 1, 4}, /* map_tx_fault[7] = TXFAULT_SFP+_P(X+7) */ - }, - .map_rxlos = { {0, 0, 3}, /* map_rxlos[0] = OPRXLOS_PORT(X) */ - {0, 0, 7}, /* map_rxlos[1] = OPRXLOS_PORT(X+1) */ - {0, 1, 3}, /* map_rxlos[2] = OPRXLOS_PORT(X+2) */ - {0, 1, 7}, /* map_rxlos[3] = OPRXLOS_PORT(X+3) */ - {1, 0, 3}, /* map_rxlos[4] = OPRXLOS_PORT(X+4) */ - {1, 0, 7}, /* map_rxlos[5] = OPRXLOS_PORT(X+5) */ - {1, 1, 3}, /* map_rxlos[6] = OPRXLOS_PORT(X+6) */ - {1, 1, 7}, /* map_rxlos[7] = OPRXLOS_PORT(X+7) */ - }, - .map_hard_rs0 = { {2, 0, 0}, /* map_hard_rs0[0] = RS0_SFP28_P(X) */ - {2, 0, 2}, /* map_hard_rs0[1] = RS0_SFP28_P(X+1) */ - {2, 0, 4}, /* map_hard_rs0[2] = RS0_SFP28_P(X+2) */ - {2, 0, 6}, /* map_hard_rs0[3] = RS0_SFP28_P(X+3) */ - {2, 1, 0}, /* map_hard_rs0[4] = RS0_SFP28_P(X+4) */ - {2, 1, 2}, /* map_hard_rs0[5] = RS0_SFP28_P(X+5) */ - {2, 1, 4}, /* map_hard_rs0[6] = RS0_SFP28_P(X+6) */ - {2, 1, 6}, /* map_hard_rs0[7] = RS0_SFP28_P(X+7) */ - }, - .map_hard_rs1 = { {2, 0, 1}, /* map_hard_rs1[0] = RS1_SFP28_P(X) */ - {2, 0, 3}, /* map_hard_rs1[1] = RS1_SFP28_P(X+1) */ - {2, 0, 5}, /* map_hard_rs1[2] = RS1_SFP28_P(X+2) */ - {2, 0, 7}, /* map_hard_rs1[3] = RS1_SFP28_P(X+3) */ - {2, 1, 1}, /* map_hard_rs1[4] = RS1_SFP28_P(X+4) */ - {2, 1, 3}, /* map_hard_rs1[5] = RS1_SFP28_P(X+5) */ - {2, 1, 5}, /* map_hard_rs1[6] = RS1_SFP28_P(X+6) */ - {2, 1, 7}, /* map_hard_rs1[7] = RS1_SFP28_P(X+7) */ - }, -}; - - -struct ioexp_map_s ioexp_map_gulmohar_2t_evt1_1abc = { - - .chip_amount = 3, - .data_width = 2, - - .map_present = { {0, 0, 2}, /* map_present[0] = MOD_ABS_PORT(X) */ - {0, 0, 6}, /* map_present[1] = MOD_ABS_PORT(X+1) */ - {0, 1, 2}, /* map_present[2] = MOD_ABS_PORT(X+2) */ - {0, 1, 6}, /* map_present[3] = MOD_ABS_PORT(X+3) */ - {1, 0, 4}, /* map_present[4] = MOD_ABS_PORT(X+4) */ - {1, 0, 5}, /* map_present[5] = MOD_ABS_PORT(X+5) */ - {1, 1, 4}, /* map_present[6] = MOD_ABS_PORT(X+6) */ - {1, 1, 5}, /* map_present[7] = MOD_ABS_PORT(X+7) */ - }, - .map_tx_disable = { {0, 0, 1}, /* map_tx_disable[0] = TXDISABLE_SFP+_P(X) */ - {0, 0, 5}, /* map_tx_disable[1] = TXDISABLE_SFP+_P(X+1) */ - {0, 1, 1}, /* map_tx_disable[2] = TXDISABLE_SFP+_P(X+2) */ - {0, 1, 5}, /* map_tx_disable[3] = TXDISABLE_SFP+_P(X+3) */ - {1, 0, 2}, /* map_tx_disable[4] = TXDISABLE_SFP+_P(X+4) */ - {1, 0, 3}, /* map_tx_disable[5] = TXDISABLE_SFP+_P(X+5) */ - {1, 1, 2}, /* map_tx_disable[6] = TXDISABLE_SFP+_P(X+6) */ - {1, 1, 3}, /* map_tx_disable[7] = TXDISABLE_SFP+_P(X+7) */ - }, - .map_tx_fault = { {0, 0, 0}, /* map_tx_fault[0] = TXFAULT_SFP+_P(X) */ - {0, 0, 4}, /* map_tx_fault[1] = TXFAULT_SFP+_P(X+1) */ - {0, 1, 0}, /* map_tx_fault[2] = TXFAULT_SFP+_P(X+2) */ - {0, 1, 4}, /* map_tx_fault[3] = TXFAULT_SFP+_P(X+3) */ - {1, 0, 0}, /* map_tx_fault[4] = TXFAULT_SFP+_P(X+4) */ - {1, 0, 1}, /* map_tx_fault[5] = TXFAULT_SFP+_P(X+5) */ - {1, 1, 0}, /* map_tx_fault[6] = TXFAULT_SFP+_P(X+6) */ - {1, 1, 1}, /* map_tx_fault[7] = TXFAULT_SFP+_P(X+7) */ - }, - .map_rxlos = { {0, 0, 3}, /* map_rxlos[0] = OPRXLOS_PORT(X) */ - {0, 0, 7}, /* map_rxlos[1] = OPRXLOS_PORT(X+1) */ - {0, 1, 3}, /* map_rxlos[2] = OPRXLOS_PORT(X+2) */ - {0, 1, 7}, /* map_rxlos[3] = OPRXLOS_PORT(X+3) */ - {1, 0, 6}, /* map_rxlos[4] = OPRXLOS_PORT(X+4) */ - {1, 0, 7}, /* map_rxlos[5] = OPRXLOS_PORT(X+5) */ - {1, 1, 6}, /* map_rxlos[6] = OPRXLOS_PORT(X+6) */ - {1, 1, 7}, /* map_rxlos[7] = OPRXLOS_PORT(X+7) */ - }, - .map_hard_rs0 = { {2, 0, 0}, /* map_hard_rs0[0] = RS0_SFP28_P(X) */ - {2, 0, 2}, /* map_hard_rs0[1] = RS0_SFP28_P(X+1) */ - {2, 0, 4}, /* map_hard_rs0[2] = RS0_SFP28_P(X+2) */ - {2, 0, 6}, /* map_hard_rs0[3] = RS0_SFP28_P(X+3) */ - {2, 1, 0}, /* map_hard_rs0[4] = RS0_SFP28_P(X+4) */ - {2, 1, 2}, /* map_hard_rs0[5] = RS0_SFP28_P(X+5) */ - {2, 1, 4}, /* map_hard_rs0[6] = RS0_SFP28_P(X+6) */ - {2, 1, 6}, /* map_hard_rs0[7] = RS0_SFP28_P(X+7) */ - }, - .map_hard_rs1 = { {2, 0, 1}, /* map_hard_rs1[0] = RS1_SFP28_P(X) */ - {2, 0, 3}, /* map_hard_rs1[1] = RS1_SFP28_P(X+1) */ - {2, 0, 5}, /* map_hard_rs1[2] = RS1_SFP28_P(X+2) */ - {2, 0, 7}, /* map_hard_rs1[3] = RS1_SFP28_P(X+3) */ - {2, 1, 1}, /* map_hard_rs1[4] = RS1_SFP28_P(X+4) */ - {2, 1, 3}, /* map_hard_rs1[5] = RS1_SFP28_P(X+5) */ - {2, 1, 5}, /* map_hard_rs1[6] = RS1_SFP28_P(X+6) */ - {2, 1, 7}, /* map_hard_rs1[7] = RS1_SFP28_P(X+7) */ - }, -}; - - -struct ioexp_map_s ioexp_map_gulmohar_2t_evt1_3abc = { - - .chip_amount = 3, - .data_width = 2, - - .map_present = { {0, 0, 4}, /* map_present[0] = MOD_ABS_PORT(X) */ - {0, 0, 5}, /* map_present[1] = MOD_ABS_PORT(X+1) */ - {0, 1, 4}, /* map_present[2] = MOD_ABS_PORT(X+2) */ - {0, 1, 5}, /* map_present[3] = MOD_ABS_PORT(X+3) */ - {1, 0, 2}, /* map_present[4] = MOD_ABS_PORT(X+4) */ - {1, 0, 6}, /* map_present[5] = MOD_ABS_PORT(X+5) */ - {1, 1, 2}, /* map_present[6] = MOD_ABS_PORT(X+6) */ - {1, 1, 6}, /* map_present[7] = MOD_ABS_PORT(X+7) */ - }, - .map_tx_disable = { {0, 0, 2}, /* map_tx_disable[0] = TXDISABLE_SFP+_P(X) */ - {0, 0, 3}, /* map_tx_disable[1] = TXDISABLE_SFP+_P(X+1) */ - {0, 1, 2}, /* map_tx_disable[2] = TXDISABLE_SFP+_P(X+2) */ - {0, 1, 3}, /* map_tx_disable[3] = TXDISABLE_SFP+_P(X+3) */ - {1, 0, 1}, /* map_tx_disable[4] = TXDISABLE_SFP+_P(X+4) */ - {1, 0, 5}, /* map_tx_disable[5] = TXDISABLE_SFP+_P(X+5) */ - {1, 1, 1}, /* map_tx_disable[6] = TXDISABLE_SFP+_P(X+6) */ - {1, 1, 5}, /* map_tx_disable[7] = TXDISABLE_SFP+_P(X+7) */ - }, - .map_tx_fault = { {0, 0, 0}, /* map_tx_fault[0] = TXFAULT_SFP+_P(X) */ - {0, 0, 1}, /* map_tx_fault[1] = TXFAULT_SFP+_P(X+1) */ - {0, 1, 0}, /* map_tx_fault[2] = TXFAULT_SFP+_P(X+2) */ - {0, 1, 1}, /* map_tx_fault[3] = TXFAULT_SFP+_P(X+3) */ - {1, 0, 0}, /* map_tx_fault[4] = TXFAULT_SFP+_P(X+4) */ - {1, 0, 4}, /* map_tx_fault[5] = TXFAULT_SFP+_P(X+5) */ - {1, 1, 0}, /* map_tx_fault[6] = TXFAULT_SFP+_P(X+6) */ - {1, 1, 4}, /* map_tx_fault[7] = TXFAULT_SFP+_P(X+7) */ - }, - .map_rxlos = { {0, 0, 6}, /* map_rxlos[0] = OPRXLOS_PORT(X) */ - {0, 0, 7}, /* map_rxlos[1] = OPRXLOS_PORT(X+1) */ - {0, 1, 6}, /* map_rxlos[2] = OPRXLOS_PORT(X+2) */ - {0, 1, 7}, /* map_rxlos[3] = OPRXLOS_PORT(X+3) */ - {1, 0, 3}, /* map_rxlos[4] = OPRXLOS_PORT(X+4) */ - {1, 0, 7}, /* map_rxlos[5] = OPRXLOS_PORT(X+5) */ - {1, 1, 3}, /* map_rxlos[6] = OPRXLOS_PORT(X+6) */ - {1, 1, 7}, /* map_rxlos[7] = OPRXLOS_PORT(X+7) */ - }, - .map_hard_rs0 = { {2, 0, 0}, /* map_hard_rs0[0] = RS0_SFP28_P(X) */ - {2, 0, 2}, /* map_hard_rs0[1] = RS0_SFP28_P(X+1) */ - {2, 0, 4}, /* map_hard_rs0[2] = RS0_SFP28_P(X+2) */ - {2, 0, 6}, /* map_hard_rs0[3] = RS0_SFP28_P(X+3) */ - {2, 1, 0}, /* map_hard_rs0[4] = RS0_SFP28_P(X+4) */ - {2, 1, 2}, /* map_hard_rs0[5] = RS0_SFP28_P(X+5) */ - {2, 1, 4}, /* map_hard_rs0[6] = RS0_SFP28_P(X+6) */ - {2, 1, 6}, /* map_hard_rs0[7] = RS0_SFP28_P(X+7) */ - }, - .map_hard_rs1 = { {2, 0, 1}, /* map_hard_rs1[0] = RS1_SFP28_P(X) */ - {2, 0, 3}, /* map_hard_rs1[1] = RS1_SFP28_P(X+1) */ - {2, 0, 5}, /* map_hard_rs1[2] = RS1_SFP28_P(X+2) */ - {2, 0, 7}, /* map_hard_rs1[3] = RS1_SFP28_P(X+3) */ - {2, 1, 1}, /* map_hard_rs1[4] = RS1_SFP28_P(X+4) */ - {2, 1, 3}, /* map_hard_rs1[5] = RS1_SFP28_P(X+5) */ - {2, 1, 5}, /* map_hard_rs1[6] = RS1_SFP28_P(X+6) */ - {2, 1, 7}, /* map_hard_rs1[7] = RS1_SFP28_P(X+7) */ - }, -}; - - - -struct ioexp_map_s ioexp_map_gulmohar_2t_evt1_7abc = { - - .chip_amount = 3, - .data_width = 2, - - .map_present = { {0, 0, 4}, /* map_present[0] = MOD_ABS_PORT(X) */ - {0, 1, 1}, /* map_present[1] = MOD_ABS_PORT(X+1) */ - {0, 1, 6}, /* map_present[2] = MOD_ABS_PORT(X+2) */ - {1, 0, 4}, /* map_present[3] = MOD_ABS_PORT(X+3) */ - {1, 1, 1}, /* map_present[4] = MOD_ABS_PORT(X+4) */ - {1, 1, 6}, /* map_present[5] = MOD_ABS_PORT(X+5) */ - {2, 0, 4}, /* map_present[6] = MOD_ABS_PORT(X+6) */ - {2, 1, 1}, /* map_present[7] = MOD_ABS_PORT(X+7) */ - }, - .map_reset = { {0, 0, 1}, /* map_reset[0] = QRESET_QSFP_N_P(X) */ - {0, 0, 6}, /* map_reset[1] = QRESET_QSFP_N_P(X+1) */ - {0, 1, 3}, /* map_reset[2] = QRESET_QSFP_N_P(X+2) */ - {1, 0, 1}, /* map_reset[3] = QRESET_QSFP_N_P(X+3) */ - {1, 0, 6}, /* map_reset[4] = QRESET_QSFP_N_P(X+4) */ - {1, 1, 3}, /* map_reset[5] = QRESET_QSFP_N_P(X+5) */ - {2, 0, 1}, /* map_reset[6] = QRESET_QSFP_N_P(X+6) */ - {2, 0, 6}, /* map_reset[7] = QRESET_QSFP_N_P(X+7) */ - }, - .map_lpmod = { {0, 0, 2}, /* map_lpmod[0] = LPMODE_QSFP_P(X) */ - {0, 0, 7}, /* map_lpmod[1] = LPMODE_QSFP_P(X+1) */ - {0, 1, 4}, /* map_lpmod[2] = LPMODE_QSFP_P(X+2) */ - {1, 0, 2}, /* map_lpmod[3] = LPMODE_QSFP_P(X+3) */ - {1, 0, 7}, /* map_lpmod[4] = LPMODE_QSFP_P(X+4) */ - {1, 1, 4}, /* map_lpmod[5] = LPMODE_QSFP_P(X+5) */ - {2, 0, 2}, /* map_lpmod[6] = LPMODE_QSFP_P(X+6) */ - {2, 0, 7}, /* map_lpmod[7] = LPMODE_QSFP_P(X+7) */ - }, - .map_modsel = { {0, 0, 0}, /* map_modsel[0] = MODSEL_QSFP_N_P(X) */ - {0, 0, 5}, /* map_modsel[1] = MODSEL_QSFP_N_P(X+1) */ - {0, 1, 2}, /* map_modsel[2] = MODSEL_QSFP_N_P(X+2) */ - {1, 0, 0}, /* map_modsel[3] = MODSEL_QSFP_N_P(X+3) */ - {1, 0, 5}, /* map_modsel[4] = MODSEL_QSFP_N_P(X+4) */ - {1, 1, 2}, /* map_modsel[5] = MODSEL_QSFP_N_P(X+5) */ - {2, 0, 0}, /* map_modsel[6] = MODSEL_QSFP_N_P(X+6) */ - {2, 0, 5}, /* map_modsel[7] = MODSEL_QSFP_N_P(X+7) */ - }, -}; - - -/* PortType: SFP / 8 port - * Platform: Cypress, Peony_SFP - */ -struct ioexp_map_s ioexp_map_sfp_8p_layout_1 = { - - .chip_amount = 3, - .data_width = 2, - - .map_present = { {0, 0, 4}, /* map_present[0] = MOD_ABS_PORT(X) */ - {0, 0, 5}, /* map_present[1] = MOD_ABS_PORT(X+1) */ - {0, 0, 6}, /* map_present[2] = MOD_ABS_PORT(X+2) */ - {0, 0, 7}, /* map_present[3] = MOD_ABS_PORT(X+3) */ - {1, 0, 4}, /* map_present[4] = MOD_ABS_PORT(X+4) */ - {1, 0, 5}, /* map_present[5] = MOD_ABS_PORT(X+5) */ - {1, 0, 6}, /* map_present[6] = MOD_ABS_PORT(X+6) */ - {1, 0, 7}, /* map_present[7] = MOD_ABS_PORT(X+7) */ - }, - .map_tx_disable = { {0, 1, 0}, /* map_tx_disable[0] = TXDISABLE_SFP+_P(X) */ - {0, 1, 1}, /* map_tx_disable[1] = TXDISABLE_SFP+_P(X+1) */ - {0, 1, 2}, /* map_tx_disable[2] = TXDISABLE_SFP+_P(X+2) */ - {0, 1, 3}, /* map_tx_disable[3] = TXDISABLE_SFP+_P(X+3) */ - {1, 1, 0}, /* map_tx_disable[4] = TXDISABLE_SFP+_P(X+4) */ - {1, 1, 1}, /* map_tx_disable[5] = TXDISABLE_SFP+_P(X+5) */ - {1, 1, 2}, /* map_tx_disable[6] = TXDISABLE_SFP+_P(X+6) */ - {1, 1, 3}, /* map_tx_disable[7] = TXDISABLE_SFP+_P(X+7) */ - }, - .map_tx_fault = { {0, 0, 0}, /* map_tx_fault[0] = TXFAULT_SFP+_P(X) */ - {0, 0, 1}, /* map_tx_fault[1] = TXFAULT_SFP+_P(X+1) */ - {0, 0, 2}, /* map_tx_fault[2] = TXFAULT_SFP+_P(X+2) */ - {0, 0, 3}, /* map_tx_fault[3] = TXFAULT_SFP+_P(X+3) */ - {1, 0, 0}, /* map_tx_fault[4] = TXFAULT_SFP+_P(X+4) */ - {1, 0, 1}, /* map_tx_fault[5] = TXFAULT_SFP+_P(X+5) */ - {1, 0, 2}, /* map_tx_fault[6] = TXFAULT_SFP+_P(X+6) */ - {1, 0, 3}, /* map_tx_fault[7] = TXFAULT_SFP+_P(X+7) */ - }, - .map_rxlos = { {0, 1, 4}, /* map_rxlos[0] = OPRXLOS_PORT(X) */ - {0, 1, 5}, /* map_rxlos[1] = OPRXLOS_PORT(X+1) */ - {0, 1, 6}, /* map_rxlos[2] = OPRXLOS_PORT(X+2) */ - {0, 1, 7}, /* map_rxlos[3] = OPRXLOS_PORT(X+3) */ - {1, 1, 4}, /* map_rxlos[4] = OPRXLOS_PORT(X+4) */ - {1, 1, 5}, /* map_rxlos[5] = OPRXLOS_PORT(X+5) */ - {1, 1, 6}, /* map_rxlos[6] = OPRXLOS_PORT(X+6) */ - {1, 1, 7}, /* map_rxlos[7] = OPRXLOS_PORT(X+7) */ - }, - .map_hard_rs0 = { {2, 0, 0}, /* map_hard_rs0[0] = RS0_SFP28_P(X) */ - {2, 0, 2}, /* map_hard_rs0[1] = RS0_SFP28_P(X+1) */ - {2, 0, 4}, /* map_hard_rs0[2] = RS0_SFP28_P(X+2) */ - {2, 0, 6}, /* map_hard_rs0[3] = RS0_SFP28_P(X+3) */ - {2, 1, 0}, /* map_hard_rs0[4] = RS0_SFP28_P(X+4) */ - {2, 1, 2}, /* map_hard_rs0[5] = RS0_SFP28_P(X+5) */ - {2, 1, 4}, /* map_hard_rs0[6] = RS0_SFP28_P(X+6) */ - {2, 1, 6}, /* map_hard_rs0[7] = RS0_SFP28_P(X+7) */ - }, - .map_hard_rs1 = { {2, 0, 1}, /* map_hard_rs1[0] = RS1_SFP28_P(X) */ - {2, 0, 3}, /* map_hard_rs1[1] = RS1_SFP28_P(X+1) */ - {2, 0, 5}, /* map_hard_rs1[2] = RS1_SFP28_P(X+2) */ - {2, 0, 7}, /* map_hard_rs1[3] = RS1_SFP28_P(X+3) */ - {2, 1, 1}, /* map_hard_rs1[4] = RS1_SFP28_P(X+4) */ - {2, 1, 3}, /* map_hard_rs1[5] = RS1_SFP28_P(X+5) */ - {2, 1, 5}, /* map_hard_rs1[6] = RS1_SFP28_P(X+6) */ - {2, 1, 7}, /* map_hard_rs1[7] = RS1_SFP28_P(X+7) */ - }, -}; - - -/* PortType: QSFP / 6 port - * Platform: Gulmohar, Peony_SFP, Peony_Copper - */ -struct ioexp_map_s ioexp_map_6p_qsfp_type_1 = { - - .chip_amount = 3, - .data_width = 2, - - .map_present = { {2, 1, 0}, /* map_present[0] = MOD_ABS_PORT(X) */ - {2, 1, 1}, /* map_present[1] = MOD_ABS_PORT(X+1) */ - {2, 1, 2}, /* map_present[2] = MOD_ABS_PORT(X+2) */ - {2, 1, 3}, /* map_present[3] = MOD_ABS_PORT(X+3) */ - {2, 1, 4}, /* map_present[4] = MOD_ABS_PORT(X+4) */ - {2, 1, 5}, /* map_present[5] = MOD_ABS_PORT(X+5) */ - }, - .map_reset = { {0, 1, 0}, /* map_reset[0] = QRESET_QSFP_N_P(X) */ - {0, 1, 1}, /* map_reset[1] = QRESET_QSFP_N_P(X+1) */ - {0, 1, 2}, /* map_reset[2] = QRESET_QSFP_N_P(X+2) */ - {0, 1, 3}, /* map_reset[3] = QRESET_QSFP_N_P(X+3) */ - {0, 1, 4}, /* map_reset[4] = QRESET_QSFP_N_P(X+4) */ - {0, 1, 5}, /* map_reset[5] = QRESET_QSFP_N_P(X+5) */ - }, - .map_lpmod = { {1, 0, 0}, /* map_lpmod[0] = LPMODE_QSFP_P(X) */ - {1, 0, 1}, /* map_lpmod[1] = LPMODE_QSFP_P(X+1) */ - {1, 0, 2}, /* map_lpmod[2] = LPMODE_QSFP_P(X+2) */ - {1, 0, 3}, /* map_lpmod[3] = LPMODE_QSFP_P(X+3) */ - {1, 0, 4}, /* map_lpmod[4] = LPMODE_QSFP_P(X+4) */ - {1, 0, 5}, /* map_lpmod[5] = LPMODE_QSFP_P(X+5) */ - }, - .map_modsel = { {0, 0, 0}, /* map_modsel[0] = MODSEL_QSFP_N_P(X) */ - {0, 0, 1}, /* map_modsel[1] = MODSEL_QSFP_N_P(X+1) */ - {0, 0, 2}, /* map_modsel[2] = MODSEL_QSFP_N_P(X+2) */ - {0, 0, 3}, /* map_modsel[3] = MODSEL_QSFP_N_P(X+3) */ - {0, 0, 4}, /* map_modsel[4] = MODSEL_QSFP_N_P(X+4) */ - {0, 0, 5}, /* map_modsel[5] = MODSEL_QSFP_N_P(X+5) */ - }, -}; - - -/* ========== Private functions ========== - */ -int check_channel_tier_1(void); - -struct i2c_client * -_get_i2c_client(struct ioexp_obj_s *self, - int chip_id){ - - struct ioexp_i2c_s *i2c_curr_p = self->i2c_head_p; - - if (!(i2c_curr_p)){ - SWPS_ERR("%s: i2c_curr_p is NULL\n", __func__); - return NULL; - } - while (i2c_curr_p){ - if ((i2c_curr_p->chip_id) == chip_id){ - return i2c_curr_p->i2c_client_p; - } - i2c_curr_p = i2c_curr_p->next; - } - SWPS_ERR("%s: not exist! :%d\n", __func__, chip_id); - return NULL; -} - - -static int -_common_ioexp_update_one(struct ioexp_obj_s *self, - struct ioexp_addr_s *ioexp_addr, - int chip_id, - int data_width, - int show_err, - char *caller_name) { - int buf = 0; - int err = 0; - int data_id = 0; - int r_offset = 0; - - for(data_id=0; data_idread_offset[data_id]; - buf = i2c_smbus_read_byte_data(_get_i2c_client(self, chip_id), r_offset); - /* Check error */ - if (buf < 0) { - err = 1; - if (show_err) { - SWPS_INFO("IOEXP-%d read fail! :%d \n", self->ioexp_id, buf); - SWPS_INFO("Dump: :%d :0x%02x :%d, :%s\n", - ioexp_addr->chan_id, ioexp_addr->chip_addr, - ioexp_addr->read_offset[data_id], caller_name); - } - continue; - } - /* Update IOEXP object */ - self->chip_data[chip_id].data[data_id] = (uint8_t)buf; - } - if (err) { - return ERR_IOEXP_UNEXCPT; - } - return 0; -} - - -static int -common_ioexp_update_all(struct ioexp_obj_s *self, - int show_err, - char *caller_name){ - - int err = 0; - int chip_id = 0; - int chip_amount = self->ioexp_map_p->chip_amount; - - for (chip_id=0; chip_idioexp_map_p->map_addr[chip_id]), - chip_id, - self->ioexp_map_p->data_width, - show_err, - caller_name) < 0) { - err = 1; - } - } - if (err) { - return ERR_IOEXP_UNEXCPT; - } - return 0; -} - - -static int -_common_check_by_mode(struct ioexp_obj_s *self){ - - switch (self->mode){ - case IOEXP_MODE_DIRECT: - return self->fsm_4_direct(self); - - case IOEXP_MODE_POLLING: - if (self->state >= 0){ - return 0; - } - switch (self->state){ - case STATE_IOEXP_INIT: - return ERR_IOEXP_UNINIT; - case STATE_IOEXP_ABNORMAL: - return ERR_IOEXP_ABNORMAL; - default: - return ERR_IOEXP_NOSTATE; - } - break; - - default: - break; - } - SWPS_ERR("%s: Exception occurs. :%d \n", __func__, self->mode); - return ERR_IOEXP_UNEXCPT; -} - - -static int -_common_get_bit(struct ioexp_obj_s *self, - struct ioexp_bitmap_s *bitmap_obj_p, - char *func_mane){ - uint8_t buf; - int err_code; - - /* Check and get address */ - err_code = _common_check_by_mode(self); - if (err_code < 0){ - return err_code; - } - if (!bitmap_obj_p){ - SWPS_ERR("Layout config incorrect! :%d :%s\n", - self->ioexp_id, func_mane); - return ERR_IOEXP_BADCONF; - } - /* Get data form cache */ - buf = self->chip_data[bitmap_obj_p->chip_id].data[bitmap_obj_p->ioexp_voffset]; - return (int)(buf >> bitmap_obj_p->bit_shift & 0x01); -} - - -static int -_common_set_bit(struct ioexp_obj_s *self, - struct ioexp_bitmap_s *bitmap_obj_p, - int input_val, - char *func_mane){ - int err_code, target_offset; - uint8_t origin_byte; - uint8_t modify_byte; - - /* Check and get address */ - err_code = _common_check_by_mode(self); - if (err_code < 0){ - return err_code; - } - if (!bitmap_obj_p){ - SWPS_ERR("Layout config incorrect! :%d :%s\n", - self->ioexp_id, func_mane); - return ERR_IOEXP_BADCONF; - } - /* Prepare write date */ - origin_byte = self->chip_data[bitmap_obj_p->chip_id].data[bitmap_obj_p->ioexp_voffset]; - switch (input_val) { - case 0: - modify_byte = origin_byte; - SWP_BIT_CLEAR(modify_byte, bitmap_obj_p->bit_shift); - break; - case 1: - modify_byte = origin_byte; - SWP_BIT_SET(modify_byte, bitmap_obj_p->bit_shift); - break; - default: - SWPS_ERR("Input value incorrect! :%d :%d :%s\n", - input_val, self->ioexp_id, func_mane); - return ERR_IOEXP_BADINPUT; - } - /* Setup i2c client */ - target_offset = self->ioexp_map_p->map_addr[bitmap_obj_p->chip_id].write_offset[bitmap_obj_p->ioexp_voffset]; - /* Write byte to chip via I2C */ - err_code = i2c_smbus_write_byte_data(_get_i2c_client(self, bitmap_obj_p->chip_id), - target_offset, - modify_byte); - /* Update or bollback object */ - if (err_code < 0){ - self->chip_data[bitmap_obj_p->chip_id].data[bitmap_obj_p->ioexp_voffset] = origin_byte; - SWPS_ERR("I2C write fail! :%d :%d :%s :%d\n", - input_val, self->ioexp_id, func_mane, err_code); - return err_code; - } - self->chip_data[bitmap_obj_p->chip_id].data[bitmap_obj_p->ioexp_voffset] = modify_byte; - return 0; -} - - -/* ========== Object public functions ========== - */ -int -common_get_present(struct ioexp_obj_s *self, - int virt_offset){ - - int UNPLUG = 1; - int retval = ERR_IOEXP_UNEXCPT; - - retval = _common_get_bit(self, - &(self->ioexp_map_p->map_present[virt_offset]), - "common_get_present"); - if (retval < 0) { - /* [Note] - * => Transceiver object does not need to handle IOEXP layer issues. - */ - return UNPLUG; - } - return retval; -} - - -int -common_get_tx_fault(struct ioexp_obj_s *self, - int virt_offset){ - /* [Transmit Fault (Tx_Fault)] - * A catastrophic laser fault will activate the transmitter signal, - * TX_FAULT, and disable the laser. This signal is an open collector - * output (pull-up required on the host board). A low signal indicates - * normal laser operation and a high signal indicates a fault. The - * TX_FAULT will be latched high when a laser fault occurs and is - * cleared by toggling the TX_DISABLE input or power cycling the - * transceiver. The transmitter fault condition can also be monitored - * via the two-wire serial interface. - * (address A2, byte 110, bit 2). - * - * 0: Normal - * 1: Abnormal - */ - return _common_get_bit(self, - &(self->ioexp_map_p->map_tx_fault[virt_offset]), - "common_get_tx_fault"); -} - - -int -common_get_rxlos(struct ioexp_obj_s *self, - int virt_offset){ - /* [Receiver Loss of Signal (Rx_LOS)] - * The post-amplification IC also includes transition detection circuitry - * which monitors the ac level of incoming optical signals and provides a - * TTL/CMOS compatible status signal to the host (pin 8). An adequate optical - * input results in a low Rx_LOS output while a high Rx_LOS output indicates - * an unusable optical input. The Rx_LOS thresholds are factory set so that - * a high output indicates a definite optical fault has occurred. Rx_LOS can - * also be monitored via the two-wire serial interface - * (address A2h, byte 110, bit 1). - * - * 0: Normal - * 1: Abnormal - */ - return _common_get_bit(self, - &(self->ioexp_map_p->map_rxlos[virt_offset]), - "common_get_rxlos"); -} - - -int -common_get_tx_disable(struct ioexp_obj_s *self, - int virt_offset){ - - return _common_get_bit(self, - &(self->ioexp_map_p->map_tx_disable[virt_offset]), - "common_get_tx_disable"); -} - - -int -common_get_reset(struct ioexp_obj_s *self, - int virt_offset){ - - return _common_get_bit(self, - &(self->ioexp_map_p->map_reset[virt_offset]), - "common_get_reset"); -} - - -int -common_get_lpmod(struct ioexp_obj_s *self, - int virt_offset){ - - return _common_get_bit(self, - &(self->ioexp_map_p->map_lpmod[virt_offset]), - "common_get_lpmod"); -} - - -int -common_get_modsel(struct ioexp_obj_s *self, - int virt_offset){ - - return _common_get_bit(self, - &(self->ioexp_map_p->map_modsel[virt_offset]), - "common_get_modsel"); -} - - -int -common_get_hard_rs0(struct ioexp_obj_s *self, - int virt_offset){ - - return _common_get_bit(self, - &(self->ioexp_map_p->map_hard_rs0[virt_offset]), - "common_get_hard_rs0"); -} - - -int -common_get_hard_rs1(struct ioexp_obj_s *self, - int virt_offset){ - - return _common_get_bit(self, - &(self->ioexp_map_p->map_hard_rs1[virt_offset]), - "common_get_hard_rs1"); -} - - -int -common_set_tx_disable(struct ioexp_obj_s *self, - int virt_offset, - int input_val){ - - return _common_set_bit(self, - &(self->ioexp_map_p->map_tx_disable[virt_offset]), - input_val, - "common_set_tx_disable"); -} - - -int -common_set_reset(struct ioexp_obj_s *self, - int virt_offset, - int input_val){ - - return _common_set_bit(self, - &(self->ioexp_map_p->map_reset[virt_offset]), - input_val, - "common_set_reset"); -} - - -int -common_set_lpmod(struct ioexp_obj_s *self, - int virt_offset, - int input_val){ - - return _common_set_bit(self, - &(self->ioexp_map_p->map_lpmod[virt_offset]), - input_val, - "common_set_lpmod"); -} - - -int -common_set_modsel(struct ioexp_obj_s *self, - int virt_offset, - int input_val){ - - return _common_set_bit(self, - &(self->ioexp_map_p->map_modsel[virt_offset]), - input_val, - "common_set_modsel"); -} - - -int -common_set_hard_rs0(struct ioexp_obj_s *self, - int virt_offset, - int input_val){ - - return _common_set_bit(self, - &(self->ioexp_map_p->map_hard_rs0[virt_offset]), - input_val, - "common_set_hard_rs0"); -} - - -int -common_set_hard_rs1(struct ioexp_obj_s *self, - int virt_offset, - int input_val){ - - return _common_set_bit(self, - &(self->ioexp_map_p->map_hard_rs1[virt_offset]), - input_val, - "common_set_hard_rs1"); -} - - -int -ioexp_get_not_support(struct ioexp_obj_s *self, - int virt_offset){ - return ERR_IOEXP_NOTSUPPORT; -} - - -int -ioexp_set_not_support(struct ioexp_obj_s *self, - int virt_offset, - int input_val){ - return ERR_IOEXP_NOTSUPPORT; -} - - -int -fake_ioexp_init(struct ioexp_obj_s *self){ - return 1; -} - -int -fake_ioexp_update(struct ioexp_obj_s *self){ - return 1; -} - - -int -fake_update_func(struct ioexp_obj_s *self){ - return 1; -} - -int -fake_get_func(struct ioexp_obj_s *self, - int virt_offset){ - SWPS_WARN("Someone called fake_get_func\n"); - return -1; -} - -int -fake_set_func(struct ioexp_obj_s *self, - int virt_offset, - int input_val){ - SWPS_WARN("Someone called fake_set_func\n"); - return -1; -} - - -/* ========== Initial functions for IO Expander ========== - */ -int -common_ioexp_init(struct ioexp_obj_s *self) { - - int chip_id, offset, err_code; - struct ioexp_addr_s *addr_p; - - if (self->mode == IOEXP_MODE_DIRECT) { - goto update_common_ioexp_init; - } - /* Setup default value to each physical IO Expander */ - for (chip_id=0; chip_id<(self->ioexp_map_p->chip_amount); chip_id++){ - /* Get address mapping */ - addr_p = &(self->ioexp_map_p->map_addr[chip_id]); - if (!addr_p){ - SWPS_ERR("%s: IOEXP config incorrect! :%d \n", - __func__, chip_id); - return -1; - } - /* Setup default value */ - for (offset=0; offset<(self->ioexp_map_p->data_width); offset++){ - - /* [Desc] Skip the setup default value behavior - [Note] Setup default value = -1 if you don't want to write the value to IOEXP or CPLD - */ - if(addr_p->write_offset[offset] < 0){ - SWPS_DEBUG("skip a write_offset <%d>\n", addr_p->conf_offset[offset]); - continue; - } - err_code = i2c_smbus_write_byte_data(_get_i2c_client(self, chip_id), - addr_p->write_offset[offset], - addr_p->data_default[offset]); - if (err_code < 0){ - SWPS_ERR("%s: set default fail! :%d \n", - __func__, err_code); - return ERR_IOEXP_UNEXCPT; - } - } - } -update_common_ioexp_init: - /* Check and update info to object */ - err_code = self->update_all(self, 1, "common_ioexp_init"); - if (err_code < 0) { - SWPS_ERR("%s: update_all() fail! :%d \n", - __func__, err_code); - return ERR_IOEXP_UNEXCPT; - } - return 0; -} - - -/* ========== Object functions for Final State Machine ========== - */ -int -_is_channel_ready(struct ioexp_obj_s *self){ - - int chip_id = 0; - int byte_id = 0; - int getval = ERR_IOEXP_UNEXCPT; - int chkval = ERR_IOEXP_UNEXCPT; - char *emsg = "ERR"; - struct ioexp_addr_s *addr_p = NULL; - - for (chip_id=0; chip_id<(self->ioexp_map_p->chip_amount); chip_id++) { - addr_p = &(self->ioexp_map_p->map_addr[chip_id]); - if (!addr_p){ - emsg = "IOEXP config incorrect"; - goto err_is_channel_ready; - } - for (byte_id=0; byte_id<(self->ioexp_map_p->data_width); byte_id++) { - if (addr_p->conf_offset[byte_id] < 0) { - continue; - } - if ((addr_p->conf_default[byte_id]) != 0) { - goto go_is_channel_ready; - } - } - if (chip_id == ((self->ioexp_map_p->chip_amount) - 1)) { - SWPS_DEBUG("%s: no non-zero config", __func__); - break; - } - } - chip_id = 0; - byte_id = 0; - -go_is_channel_ready: - addr_p = &(self->ioexp_map_p->map_addr[chip_id]); - chkval = addr_p->conf_default[byte_id]; - getval = i2c_smbus_read_byte_data(_get_i2c_client(self, chip_id), - addr_p->conf_offset[byte_id]); - - SWPS_DEBUG("%s: target info :%d :%d :%d :%d :%d\n", - __func__, self->ioexp_id, chip_id, byte_id, chkval, getval); - - if ((getval >= 0) && (getval == chkval)) { - return 1; - } - return 0; - -err_is_channel_ready: - SWPS_ERR("%s: %s :%d :%d :%d :%d :%d\n", - __func__, emsg, self->ioexp_id, chip_id, byte_id, chkval, getval); - return ERR_IOEXP_UNEXCPT; -} - - -int -_ioexp_init_handler(struct ioexp_obj_s *self){ - - int return_val; - - switch (self->mode) { - case IOEXP_MODE_DIRECT: - return_val = self->init(self); - if (return_val < 0){ - self->state = STATE_IOEXP_ABNORMAL; - } else { - self->state = STATE_IOEXP_NORMAL; - } - return return_val; - - case IOEXP_MODE_POLLING: - /* Check system and channel is ready */ - if (self->state == STATE_IOEXP_INIT){ - if (!_is_channel_ready(self)){ - self->state = STATE_IOEXP_INIT; - SWPS_WARN("%s: IOEXP:%d channel not ready.\n", - __func__, self->ioexp_id); - return 0; - } - } - /* Execute initial callback */ - return_val = self->init(self); - if (return_val < 0){ - self->state = STATE_IOEXP_ABNORMAL; - } else { - self->state = STATE_IOEXP_NORMAL; - } - return return_val; - - default: - break; - } - SWPS_ERR("%s: exception occur :%d\n", __func__, self->mode); - return ERR_IOEXP_UNEXCPT; -} - - -int -common_ioexp_fsm_4_direct(struct ioexp_obj_s *self){ - - int result_val; - int show_err = 1; - char *func_mane = "common_ioexp_fsm_4_direct"; - - switch (self->state){ - case STATE_IOEXP_INIT: - result_val = _ioexp_init_handler(self); - /* Exception case: terminate initial procedure */ - if(result_val < 0){ - /* Initial fail */ - return result_val; - } - if(self->state == STATE_IOEXP_INIT){ - /* Keep in INIT state, and return error */ - return ERR_IOEXP_UNINIT; - } - /* Case: Initial done */ - return 0; - - case STATE_IOEXP_NORMAL: - result_val = self->update_all(self, show_err, func_mane); - if (result_val < 0){ - SWPS_INFO("%s: NORMAL -> ABNORMAL :%d\n", - __func__, result_val); - self->state = STATE_IOEXP_ABNORMAL; - return result_val; - } - self->state = STATE_IOEXP_NORMAL; - return 0; - - case STATE_IOEXP_ABNORMAL: - result_val = self->update_all(self, show_err, func_mane); - if (result_val < 0){ - self->state = STATE_IOEXP_ABNORMAL; - return result_val; - } - SWPS_DEBUG("%s: ABNORMAL -> NORMAL :%d\n", - __func__, result_val); - self->state = STATE_IOEXP_NORMAL; - return 0; - - default: - break; - } - SWPS_ERR("%s: Exception occurs :%d\n", - __func__, self->state); - return ERR_IOEXP_UNEXCPT; -} - - -int -common_ioexp_fsm_4_polling(struct ioexp_obj_s *self){ - - int result_val, i, show_e; - int fail_retry = 3; - char *func_name = "common_ioexp_fsm_4_polling"; - -#ifdef DEBUG_SWPS - show_e = 1; -#else - show_e = 0; -#endif - - switch (self->state){ - case STATE_IOEXP_INIT: - result_val = _ioexp_init_handler(self); - /* Exception case: terminate initial procedure */ - if(result_val < 0){ - /* Initial fail */ - return result_val; - } - /* Case: System (Channel) not ready */ - if(self->state == STATE_IOEXP_INIT){ - /* Keep in INIT state, wait and retry */ - return 0; - } - /* Case: Initial done */ - SWPS_INFO("IOEXP-%d: initial done. :%d\n", - self->ioexp_id, self->ioexp_type); - return result_val; - - case STATE_IOEXP_NORMAL: - /* Retry mechanism for case of i2c topology not stable */ - for (i=0; iupdate_all(self, show_e, func_name); - if (result_val >= 0) { - self->state = STATE_IOEXP_NORMAL; - return 0; - } - if (check_channel_tier_1() < 0) { - SWPS_INFO("%s: detect I2C crash :%d\n", - __func__, self->ioexp_id); - break; - } - SWPS_DEBUG("IOEXP-%d: unstable :%d\n", - self->ioexp_id, result_val); - } - SWPS_INFO("IOEXP-%d: NORMAL -> ABNORMAL :%d\n", - self->ioexp_id, result_val); - self->state = STATE_IOEXP_ABNORMAL; - return result_val; - - case STATE_IOEXP_ABNORMAL: - result_val = self->update_all(self, show_e, func_name); - if (result_val < 0){ - self->state = STATE_IOEXP_ABNORMAL; - return result_val; - } - SWPS_INFO("IOEXP-%d: ABNORMAL -> NORMAL :%d\n", - self->ioexp_id, result_val); - self->state = STATE_IOEXP_NORMAL; - return 0; - - default: - break; - } - SWPS_ERR("IOEXP-%d: Exception occurs :%d\n", - self->ioexp_id, self->state); - return ERR_IOEXP_UNEXCPT; -} - - -/* ========== Object private functions for check & update ========== - */ -int -common_ioexp_check(struct ioexp_obj_s *self){ - - int result; - - if (self->mode != IOEXP_MODE_POLLING){ - SWPS_ERR("%s: not polling mode :%d\n", - __func__, self->mode); - return ERR_IOEXP_NOTSUPPORT; - } - mutex_lock(&self->lock); - result = self->fsm_4_polling(self); - mutex_unlock(&self->lock); - return result; -} - - -/* ========== Functions for Factory pattern ========== - */ -static struct ioexp_map_s * -get_ioexp_map(int ioexp_type){ - switch (ioexp_type){ - case IOEXP_TYPE_MAGINOLIA_NAB: - return &ioexp_map_magnolia_nab; - case IOEXP_TYPE_MAGINOLIA_4AB: - return &ioexp_map_magnolia_4ab; - case IOEXP_TYPE_MAGINOLIA_7AB: - case IOEXP_TYPE_SPRUCE_7AB: - return &ioexp_map_magnolia_7ab; - case IOEXP_TYPE_REDWOOD_P01P08: - return &ioexp_map_redwood_p01p08_p17p24; - case IOEXP_TYPE_REDWOOD_P09P16: - return &ioexp_map_redwood_p09p16_p25p32; - case IOEXP_TYPE_HUDSON32IGA_P01P08: - return &ioexp_map_hudson32iga_p01p08_p17p24; - case IOEXP_TYPE_HUDSON32IGA_P09P16: - return &ioexp_map_hudson32iga_p09p16_p25p32; - case IOEXP_TYPE_CYPRESS_7ABC: - return &ioexp_map_cypress_7abc; - case IOEXP_TYPE_TAHOE_5A: - return &ioexp_map_tahoe_5a; - case IOEXP_TYPE_TAHOE_6ABC: - return &ioexp_map_tahoe_6abc; - case IOEXP_TYPE_SEQUOIA_NABC: - return &ioexp_map_sequoia_nabc; - case IOEXP_TYPE_LAVENDER_P65: - return &ioexp_map_lavender_p65; - case CPLD_TYPE_COTTONWOOD: - return &cpld_map_cottonwood; - case IOEXP_TYPE_MAPLE_0ABC: - return &ioexp_map_maple_0abc; - case IOEXP_TYPE_MAPLE_NABC: - return &ioexp_map_maple_nabc; - case IOEXP_TYPE_GULMOHAR_NABC: - return &ioexp_map_gulmohar_nabc; - case IOEXP_TYPE_GULMOHAR_7ABC: - return &ioexp_map_gulmohar_7abc; - case IOEXP_TYPE_GULMOHAR_2T_EVT1_NABC: - return &ioexp_map_gulmohar_2t_evt1_nabc; - case IOEXP_TYPE_GULMOHAR_2T_EVT1_1ABC: - return &ioexp_map_gulmohar_2t_evt1_1abc; - case IOEXP_TYPE_GULMOHAR_2T_EVT1_3ABC: - return &ioexp_map_gulmohar_2t_evt1_3abc; - case IOEXP_TYPE_GULMOHAR_2T_EVT1_7ABC: - return &ioexp_map_gulmohar_2t_evt1_7abc; - case IOEXP_TYPE_SFP_8P_LAYOUT_1: - return &ioexp_map_sfp_8p_layout_1; - case IOEXP_TYPE_QSFP_6P_LAYOUT_1: - return &ioexp_map_6p_qsfp_type_1; - default: - return NULL; - } -} - - -int -setup_ioexp_ssize_attr(struct ioexp_obj_s *self, - struct ioexp_map_s *ioexp_map_p, - int ioexp_id, - int ioexp_type, - int run_mode){ - switch (run_mode){ - case IOEXP_MODE_POLLING: /* Direct access device mode */ - case IOEXP_MODE_DIRECT: /* Polling mode, read from cache */ - self->mode = run_mode; - break; - default: - SWPS_ERR("%s: non-defined run_mode:%d\n", - __func__, run_mode); - self->mode = ERR_IOEXP_UNEXCPT; - return ERR_IOEXP_UNEXCPT; - } - /* Setup mapping structure */ - self->ioexp_map_p = kzalloc(sizeof(*ioexp_map_p), GFP_KERNEL); - if (!(self->ioexp_map_p)) { - SWPS_ERR("%s: kzalloc ioexp_map_p fail\n", __func__); - return -1; - } - memcpy(self->ioexp_map_p, ioexp_map_p, sizeof(*ioexp_map_p)); - /* Setup attributes */ - self->ioexp_id = ioexp_id; - self->ioexp_type = ioexp_type; - self->state = STATE_IOEXP_INIT; - mutex_init(&self->lock); - return 0; -} - - -static int -setup_addr_mapping(struct ioexp_obj_s *self, - struct ioexp_addr_s *addr_map_p, - int chip_amount){ - struct ioexp_addr_s *tmp_p; - if (!addr_map_p){ - SWPS_ERR("%s: map is null\n", __func__); - return -1; - } - tmp_p = kzalloc((sizeof(*addr_map_p) * chip_amount), GFP_KERNEL); - if (!tmp_p){ - SWPS_ERR("%s: kzalloc fail.\n", __func__); - return -1; - } - memcpy(tmp_p, addr_map_p, (sizeof(*addr_map_p) * chip_amount)); - self->ioexp_map_p->map_addr = tmp_p; - - return 0; -} - - -static int -setup_ioexp_public_cb(struct ioexp_obj_s *self, - int ioexp_type){ - - switch (ioexp_type){ - case IOEXP_TYPE_MAGINOLIA_NAB: - case IOEXP_TYPE_MAGINOLIA_4AB: - case CPLD_TYPE_COTTONWOOD: - self->get_present = common_get_present; - self->get_tx_fault = common_get_tx_fault; - self->get_rxlos = common_get_rxlos; - self->get_tx_disable = common_get_tx_disable; - self->get_reset = ioexp_get_not_support; - self->get_lpmod = ioexp_get_not_support; - self->get_modsel = ioexp_get_not_support; - self->get_hard_rs0 = ioexp_get_not_support; - self->get_hard_rs1 = ioexp_get_not_support; - self->set_tx_disable = common_set_tx_disable; - self->set_reset = ioexp_set_not_support; - self->set_lpmod = ioexp_set_not_support; - self->set_modsel = ioexp_set_not_support; - self->set_hard_rs0 = ioexp_set_not_support; - self->set_hard_rs1 = ioexp_set_not_support; - return 0; - - case IOEXP_TYPE_MAPLE_NABC: - case IOEXP_TYPE_GULMOHAR_NABC: - case IOEXP_TYPE_GULMOHAR_2T_EVT1_NABC: - case IOEXP_TYPE_GULMOHAR_2T_EVT1_1ABC: - case IOEXP_TYPE_GULMOHAR_2T_EVT1_3ABC: - case IOEXP_TYPE_SFP_8P_LAYOUT_1: - self->get_present = common_get_present; - self->get_tx_fault = common_get_tx_fault; - self->get_rxlos = common_get_rxlos; - self->get_tx_disable = common_get_tx_disable; - self->get_reset = ioexp_get_not_support; - self->get_lpmod = ioexp_get_not_support; - self->get_modsel = ioexp_get_not_support; - self->get_hard_rs0 = common_get_hard_rs0; - self->get_hard_rs1 = common_get_hard_rs1; - self->set_tx_disable = common_set_tx_disable; - self->set_reset = ioexp_set_not_support; - self->set_lpmod = ioexp_set_not_support; - self->set_modsel = ioexp_set_not_support; - self->set_hard_rs0 = common_set_hard_rs0; - self->set_hard_rs1 = common_set_hard_rs1; - return 0; - - case IOEXP_TYPE_MAGINOLIA_7AB: - case IOEXP_TYPE_SPRUCE_7AB: - case IOEXP_TYPE_REDWOOD_P01P08: - case IOEXP_TYPE_REDWOOD_P09P16: - case IOEXP_TYPE_HUDSON32IGA_P01P08: - case IOEXP_TYPE_HUDSON32IGA_P09P16: - case IOEXP_TYPE_CYPRESS_7ABC: - case IOEXP_TYPE_TAHOE_5A: - case IOEXP_TYPE_TAHOE_6ABC: - case IOEXP_TYPE_SEQUOIA_NABC: - case IOEXP_TYPE_LAVENDER_P65: - case IOEXP_TYPE_MAPLE_0ABC: - case IOEXP_TYPE_GULMOHAR_7ABC: - case IOEXP_TYPE_GULMOHAR_2T_EVT1_7ABC: - case IOEXP_TYPE_QSFP_6P_LAYOUT_1: - self->get_present = common_get_present; - self->get_tx_fault = ioexp_get_not_support; - self->get_rxlos = ioexp_get_not_support; - self->get_tx_disable = ioexp_get_not_support; - self->get_reset = common_get_reset; - self->get_lpmod = common_get_lpmod; - self->get_modsel = common_get_modsel; - self->get_hard_rs0 = ioexp_get_not_support; - self->get_hard_rs1 = ioexp_get_not_support; - self->set_tx_disable = ioexp_set_not_support; - self->set_reset = common_set_reset; - self->set_lpmod = common_set_lpmod; - self->set_modsel = common_set_modsel; - self->set_hard_rs0 = ioexp_set_not_support; - self->set_hard_rs1 = ioexp_set_not_support; - return 0; - - default: - SWPS_ERR("%s: type:%d incorrect!\n", __func__, ioexp_type); - break; - } - return ERR_IOEXP_UNEXCPT; -} - - -static int -setup_ioexp_private_cb(struct ioexp_obj_s *self, - int ioexp_type){ - - switch (ioexp_type){ - case IOEXP_TYPE_MAGINOLIA_NAB: - case IOEXP_TYPE_MAGINOLIA_4AB: - case IOEXP_TYPE_MAGINOLIA_7AB: - case IOEXP_TYPE_SPRUCE_7AB: - case IOEXP_TYPE_REDWOOD_P01P08: - case IOEXP_TYPE_REDWOOD_P09P16: - case IOEXP_TYPE_HUDSON32IGA_P01P08: - case IOEXP_TYPE_HUDSON32IGA_P09P16: - case IOEXP_TYPE_CYPRESS_7ABC: - case IOEXP_TYPE_TAHOE_5A: - case IOEXP_TYPE_TAHOE_6ABC: - case IOEXP_TYPE_SEQUOIA_NABC: - case IOEXP_TYPE_LAVENDER_P65: - case CPLD_TYPE_COTTONWOOD: - case IOEXP_TYPE_MAPLE_NABC: - case IOEXP_TYPE_MAPLE_0ABC: - case IOEXP_TYPE_GULMOHAR_NABC: - case IOEXP_TYPE_GULMOHAR_7ABC: - case IOEXP_TYPE_GULMOHAR_2T_EVT1_NABC: - case IOEXP_TYPE_GULMOHAR_2T_EVT1_1ABC: - case IOEXP_TYPE_GULMOHAR_2T_EVT1_3ABC: - case IOEXP_TYPE_GULMOHAR_2T_EVT1_7ABC: - case IOEXP_TYPE_SFP_8P_LAYOUT_1: - case IOEXP_TYPE_QSFP_6P_LAYOUT_1: - self->init = common_ioexp_init; - self->check = common_ioexp_check; - self->update_all = common_ioexp_update_all; - self->fsm_4_direct = common_ioexp_fsm_4_direct; - self->fsm_4_polling = common_ioexp_fsm_4_polling; - return 0; - - default: - SWPS_ERR("%s: type:%d incorrect!\n", __func__, ioexp_type); - break; - } - return ERR_IOEXP_UNEXCPT; -} - - -static int -setup_i2c_client_one(struct ioexp_obj_s *self, - int chip_id){ - - char *err_msg = "ERROR"; - struct i2c_adapter *adap = NULL; - struct i2c_client *client = NULL; - struct ioexp_i2c_s *i2c_obj_p = NULL; - struct ioexp_i2c_s *i2c_curr_p = NULL; - - int chan_id = self->ioexp_map_p->map_addr[chip_id].chan_id; - client = kzalloc(sizeof(*client), GFP_KERNEL); - if (!client){ - err_msg = "Can not kzalloc client!"; - goto err_ioexp_setup_i2c_1; - } - i2c_obj_p = kzalloc(sizeof(*i2c_obj_p), GFP_KERNEL); - if (!i2c_obj_p){ - err_msg = "Can not kzalloc i2c_obj_p!"; - goto err_ioexp_setup_i2c_2; - } - adap = i2c_get_adapter(chan_id); - if(!adap){ - err_msg = "Can not get adap!"; - goto err_ioexp_setup_i2c_3; - } - client->adapter = adap; - client->addr = self->ioexp_map_p->map_addr[chip_id].chip_addr; - i2c_obj_p->i2c_client_p = client; - i2c_obj_p->chip_id = chip_id; - i2c_obj_p->next = NULL; - if (!self->i2c_head_p){ - self->i2c_head_p = i2c_obj_p; - } else { - i2c_curr_p = self->i2c_head_p; - while (i2c_curr_p->next){ - i2c_curr_p = i2c_curr_p->next; - } - i2c_curr_p->next = i2c_obj_p; - } - return 0; - -err_ioexp_setup_i2c_3: - kfree(i2c_obj_p); -err_ioexp_setup_i2c_2: - kfree(client); -err_ioexp_setup_i2c_1: - SWPS_ERR("%s: %s :%d\n", __func__, err_msg, chan_id); - return -1; -} - - -static int -setup_i2c_client(struct ioexp_obj_s* self){ - - int result; - int chip_id = 0; - - for (chip_id=0; chip_id<(self->ioexp_map_p->chip_amount); chip_id++){ - result = setup_i2c_client_one(self, chip_id); - if (result < 0){ - SWPS_ERR("%s fail! :%d\n", __func__, chip_id); - return -1; - } - } - return 0; -} - - -static int -setup_ioexp_config(struct ioexp_obj_s *self) { - - int chip_id, offset, err_code; - struct ioexp_addr_s *addr_p; - - for (chip_id=0; chip_id<(self->ioexp_map_p->chip_amount); chip_id++){ - addr_p = &(self->ioexp_map_p->map_addr[chip_id]); - if (!addr_p){ - SWPS_ERR("IOEXP config incorrect! :%d \n",chip_id); - return -1; - } - for (offset=0; offset<(self->ioexp_map_p->data_width); offset++){ - - /* [Desc] Skip the setup config value behavior - [Note] Setup config value = -1 if you don't want to write the value to IOEXP or CPLD - */ - if(addr_p->conf_offset[offset] < 0){ - SWPS_DEBUG("skip a config_offset <%d>\n", addr_p->conf_offset[offset]); - continue; - } - err_code = i2c_smbus_write_byte_data(_get_i2c_client(self, chip_id), - addr_p->conf_offset[offset], - addr_p->conf_default[offset]); - - if (err_code < 0){ - SWPS_INFO("%s: set conf fail! :%d \n", __func__, err_code); - return -2; - } - } - } - return 0; -} - - -struct ioexp_obj_s * -_create_ioexp_obj(int ioexp_id, - int ioexp_type, - struct ioexp_addr_s *addr_map_p, - int run_mode){ - - struct ioexp_map_s* ioexp_map_p; - struct ioexp_obj_s* result_p; - struct ioexp_i2c_s *i2c_curr_p; - struct ioexp_i2c_s *i2c_next_p; - - /* Get layout */ - ioexp_map_p = get_ioexp_map(ioexp_type); - if (!ioexp_map_p){ - SWPS_ERR("%s: Invalid ioexp_type\n", __func__); - goto err_create_ioexp_fail; - } - /* Prepare IOEXP object */ - result_p = kzalloc(sizeof(*result_p), GFP_KERNEL); - if (!result_p){ - SWPS_ERR("%s: kzalloc failure!\n", __func__); - goto err_create_ioexp_fail; - } - /* Prepare static size attributes */ - if (setup_ioexp_ssize_attr(result_p, - ioexp_map_p, - ioexp_id, - ioexp_type, - run_mode) < 0){ - goto err_create_ioexp_setup_attr_fail; - } - /* Prepare address mapping */ - if (setup_addr_mapping(result_p, addr_map_p, ioexp_map_p->chip_amount) < 0){ - goto err_create_ioexp_setup_attr_fail; - } - if (setup_i2c_client(result_p) < 0){ - goto err_create_ioexp_setup_i2c_fail; - } - /* Prepare call back functions of object */ - if (setup_ioexp_public_cb(result_p, ioexp_type) < 0){ - goto err_create_ioexp_setup_i2c_fail; - } - if (setup_ioexp_private_cb(result_p, ioexp_type) < 0){ - goto err_create_ioexp_setup_i2c_fail; - } - return result_p; - -err_create_ioexp_setup_i2c_fail: - i2c_curr_p = result_p->i2c_head_p; - i2c_next_p = result_p->i2c_head_p; - while (i2c_curr_p){ - i2c_next_p = i2c_curr_p->next; - if (i2c_curr_p->i2c_client_p) { - i2c_put_adapter(i2c_curr_p->i2c_client_p->adapter); - kfree(i2c_curr_p->i2c_client_p); - } - kfree(i2c_curr_p); - i2c_curr_p = i2c_next_p; - } -err_create_ioexp_setup_attr_fail: - kfree(result_p); -err_create_ioexp_fail: - SWPS_ERR("%s: fail! :%d :%d \n", - __func__, ioexp_id, ioexp_type); - return NULL; -} - - -int -create_ioexp_obj(int ioexp_id, - int ioexp_type, - struct ioexp_addr_s *addr_map_p, - int run_mode){ - - struct ioexp_obj_s *ioexp_p = NULL; - - ioexp_p = _create_ioexp_obj(ioexp_id, ioexp_type, - addr_map_p, run_mode); - if (!ioexp_p){ - return -1; - } - if (ioexp_head_p == NULL){ - ioexp_head_p = ioexp_p; - ioexp_tail_p = ioexp_p; - return 0; - } - ioexp_tail_p->next = ioexp_p; - ioexp_tail_p = ioexp_p; - return 0; -} -EXPORT_SYMBOL(create_ioexp_obj); - - -static int -_init_ioexp_obj(struct ioexp_obj_s* self) { - - char *err_msg = "ERR"; - char *func_name = "_init_ioexp_obj"; - - /* Setup IOEXP configure byte */ - if (setup_ioexp_config(self) < 0){ - err_msg = "setup_ioexp_config fail"; - goto err_init_ioexp_obj; - } - /* Setup default data */ - if (_ioexp_init_handler(self) < 0){ - err_msg = "_ioexp_init_handler fail"; - goto err_init_ioexp_obj; - } - /* Update all */ - if (self->state == STATE_IOEXP_NORMAL){ - if (self->update_all(self, 1, func_name) < 0){ - err_msg = "update_all() fail"; - goto err_init_ioexp_obj; - } - } - return 0; - -err_init_ioexp_obj: - SWPS_DEBUG("%s: %s\n", __func__, err_msg); - return -1; -} - - -int -init_ioexp_objs(void){ - /* Return value: - * 0: Success - * -1: Detect topology error - * -2: SWPS internal error - */ - struct ioexp_obj_s *curr_p = ioexp_head_p; - - if (!curr_p) { - SWPS_ERR("%s: ioexp_head_p is NULL\n", __func__); - return -2; - } - while (curr_p) { - if (_init_ioexp_obj(curr_p) < 0) { - SWPS_DEBUG("%s: _init_ioexp_obj() fail\n", __func__); - return -1; - } - curr_p = curr_p->next; - } - SWPS_DEBUG("%s: done.\n", __func__); - return 0; -} -EXPORT_SYMBOL(init_ioexp_objs); - - -void -clean_ioexp_objs(void){ - - struct ioexp_i2c_s *i2c_curr_p = NULL; - struct ioexp_i2c_s *i2c_next_p = NULL; - struct ioexp_obj_s *ioexp_next_p = NULL; - struct ioexp_obj_s *ioexp_curr_p = ioexp_head_p; - - if (ioexp_head_p == NULL){ - ioexp_tail_p = NULL; - return; - } - while(ioexp_curr_p){ - ioexp_next_p = ioexp_curr_p->next; - if (ioexp_curr_p->ioexp_map_p) { - if (ioexp_curr_p->ioexp_map_p->map_addr) { - kfree(ioexp_curr_p->ioexp_map_p->map_addr); - } - kfree(ioexp_curr_p->ioexp_map_p); - } - - i2c_curr_p = ioexp_curr_p->i2c_head_p; - while (i2c_curr_p) { - i2c_next_p = i2c_curr_p->next; - if (i2c_curr_p->i2c_client_p) { - i2c_put_adapter(i2c_curr_p->i2c_client_p->adapter); - kfree(i2c_curr_p->i2c_client_p); - } - kfree(i2c_curr_p); - i2c_curr_p = i2c_next_p; - } - kfree(ioexp_curr_p); - ioexp_curr_p = ioexp_next_p; - } - ioexp_tail_p = NULL; - SWPS_DEBUG("%s: done.\n", __func__); -} -EXPORT_SYMBOL(clean_ioexp_objs); - - -int -check_ioexp_objs(void){ - - struct ioexp_obj_s *ioexp_curr_p = ioexp_head_p; - - while (ioexp_curr_p){ - if ( (ioexp_curr_p->check(ioexp_curr_p)) < 0){ - SWPS_INFO("check IOEXP-%d fail! :%d\n", - ioexp_curr_p->ioexp_id, ioexp_curr_p->ioexp_type); - return -1; - } - ioexp_curr_p = ioexp_curr_p->next; - } - return 0; -} -EXPORT_SYMBOL(check_ioexp_objs); - - -struct ioexp_obj_s * -get_ioexp_obj(int ioexp_id){ - - struct ioexp_obj_s *result_p = NULL; - struct ioexp_obj_s *ioexp_curr_p = ioexp_head_p; - - while(ioexp_curr_p){ - if (ioexp_curr_p->ioexp_id == ioexp_id){ - result_p = ioexp_curr_p; - break; - } - ioexp_curr_p = ioexp_curr_p->next; - } - return result_p; -} -EXPORT_SYMBOL(get_ioexp_obj); - - -void -unlock_ioexp_all(void) { - - struct ioexp_obj_s *ioexp_curr_p = ioexp_head_p; - - while(ioexp_curr_p){ - mutex_unlock(&ioexp_curr_p->lock); - ioexp_curr_p = ioexp_curr_p->next; - } -} -EXPORT_SYMBOL(unlock_ioexp_all); - -int -lock_ioexp_all(void) { - - struct ioexp_obj_s *ioexp_curr_p = ioexp_head_p; - - while(ioexp_curr_p){ - mutex_lock(&ioexp_curr_p->lock); - ioexp_curr_p = ioexp_curr_p->next; - } - return 0; -} -EXPORT_SYMBOL(lock_ioexp_all); - - -int -check_channel_tier_1(void) { - - if ( (!_is_channel_ready(ioexp_head_p)) && - (!_is_channel_ready(ioexp_tail_p)) ){ - return -1; - } - return 0; -} -EXPORT_SYMBOL(check_channel_tier_1); - - -static int -_scan_channel_tier_1(int force, - int show_err) { - - struct ioexp_obj_s *ioexp_curr_p = ioexp_head_p; - int ready = 0; - - if (!ioexp_curr_p) { - goto err_scan_tier_1_channel; - } - while(ioexp_curr_p) { - ready = _is_channel_ready(ioexp_curr_p); - if ((!ready) && (!force)) { - goto err_scan_tier_1_channel; - } - ioexp_curr_p = ioexp_curr_p->next; - } - return 0; - -err_scan_tier_1_channel: - if (show_err) { - if (ioexp_curr_p) { - SWPS_INFO("%s: IOEXP-%d fail\n", __func__, ioexp_curr_p->ioexp_id); - } else { - SWPS_INFO("%s: IOEXP is null.\n", __func__); - } - } - return -1; -} - - -static int -_scan_channel_tier_1_single(void) { - - int ret = 0; - int chan_id = 0; - int fake_cid = 0; - int fake_offs = 0; - int fake_addr = 0; - struct i2c_adapter *adap = NULL; - struct i2c_client *client = NULL; - - if (ioexp_head_p->ioexp_id != ioexp_tail_p->ioexp_id) { - return 0; - } - /* Setup i2c_client */ - chan_id = ioexp_head_p->ioexp_map_p->map_addr[fake_cid].chan_id; - fake_addr = ioexp_head_p->ioexp_map_p->map_addr[fake_cid].chip_addr; - adap = i2c_get_adapter((chan_id + 1)); - if(!adap){ - SWPS_INFO("%s: Can not get adap!\n", __func__); - return 0; - } - client = kzalloc(sizeof(*client), GFP_KERNEL); - if (!client){ - SWPS_INFO("%s: Can not kzalloc client!\n", __func__); - return 0; - } - client->adapter = adap; - client->addr = fake_addr; - /* Fouce move ioexp ptr to next */ - ret = i2c_smbus_read_byte_data(client, fake_offs); - SWPS_DEBUG("%s: move ioexp_ptr done. :%d\n", __func__, ret); - kfree(client); - return 1; -} - - -int -resync_channel_tier_1(void) { - - char *emsg = "ERR"; - - if (!ioexp_head_p) { - emsg = "ioexp_head_p is NULL"; - goto err_resync_ioexp_status_1; - } - /* Run all */ - if (ioexp_head_p->ioexp_id == ioexp_tail_p->ioexp_id) { - _scan_channel_tier_1_single(); - } else { - _scan_channel_tier_1(1, 0); - } - /* Check all */ - if (_scan_channel_tier_1(0, 1) < 0) { - emsg = "resync tier-1 channel fail"; - goto err_resync_ioexp_status_1; - } - return 0; - -err_resync_ioexp_status_1: - SWPS_ERR("%s: %s\n", __func__, emsg); - return -1; -} -EXPORT_SYMBOL(resync_channel_tier_1); - - -/* For build single module using (Ex: ONL platform) */ -MODULE_LICENSE("GPL"); - - - diff --git a/packages/platforms/inventec/x86-64/d10056/modules/builds/src/io_expander.h b/packages/platforms/inventec/x86-64/d10056/modules/builds/src/io_expander.h deleted file mode 100644 index 6f9f7b462..000000000 --- a/packages/platforms/inventec/x86-64/d10056/modules/builds/src/io_expander.h +++ /dev/null @@ -1,189 +0,0 @@ -#ifndef IO_EXPANDER_H -#define IO_EXPANDER_H - -#include - - -/* IOEXP type define (SFP series) */ -#define IOEXP_TYPE_MAGINOLIA_NAB (10101) -#define IOEXP_TYPE_MAGINOLIA_4AB (10102) -#define IOEXP_TYPE_MAPLE_NABC (10104) -#define IOEXP_TYPE_GULMOHAR_NABC (10105) -#define IOEXP_TYPE_GULMOHAR_2T_EVT1_NABC (10106) -#define IOEXP_TYPE_SFP_8P_LAYOUT_1 (10107) -#define IOEXP_TYPE_GULMOHAR_2T_EVT1_1ABC (10108) -#define IOEXP_TYPE_GULMOHAR_2T_EVT1_3ABC (10109) - -/* IOEXP type define (QSFP series) */ -#define IOEXP_TYPE_MAGINOLIA_7AB (10201) -#define IOEXP_TYPE_REDWOOD_P01P08 (10202) -#define IOEXP_TYPE_REDWOOD_P09P16 (10203) -#define IOEXP_TYPE_HUDSON32IGA_P01P08 (10204) -#define IOEXP_TYPE_HUDSON32IGA_P09P16 (10205) -#define IOEXP_TYPE_SPRUCE_7AB (10206) -#define IOEXP_TYPE_CYPRESS_7ABC (10207) -#define IOEXP_TYPE_TAHOE_5A (10208) -#define IOEXP_TYPE_TAHOE_6ABC (10209) -#define IOEXP_TYPE_SEQUOIA_NABC (10210) -#define IOEXP_TYPE_LAVENDER_P65 (10211) -#define IOEXP_TYPE_MAPLE_0ABC (10212) -#define IOEXP_TYPE_GULMOHAR_7ABC (10213) -#define IOEXP_TYPE_GULMOHAR_2T_EVT1_7ABC (10214) -#define IOEXP_TYPE_QSFP_6P_LAYOUT_1 (10215) - -/* CPLD type define */ -#define CPLD_TYPE_COTTONWOOD (10301) - -/* IOEXP mode define */ -#define IOEXP_MODE_POLLING (19000) -#define IOEXP_MODE_DIRECT (19001) - -/* IOEXP state define */ -#define STATE_IOEXP_NORMAL (0) -#define STATE_IOEXP_INIT (-1) -#define STATE_IOEXP_ABNORMAL (-2) - -/* IOEXP error code define */ -#define ERR_IOEXP_NOTSUPPORT (-100) -#define ERR_IOEXP_UNINIT (-101) -#define ERR_IOEXP_BADCONF (-102) -#define ERR_IOEXP_ABNORMAL (-103) -#define ERR_IOEXP_NOSTATE (-104) -#define ERR_IOEXP_BADINPUT (-105) -#define ERR_IOEXP_UNEXCPT (-199) - -#define SWPS_INFO(fmt, args...) printk( KERN_INFO "[SWPS] " fmt, ##args) -#define SWPS_WARN(fmt, args...) printk( KERN_WARNING "[SWPS] " fmt, ##args) -#define SWPS_ERR(fmt, args...) printk( KERN_ERR "[SWPS] " fmt, ##args) - -#ifdef DEBUG_SWPS -# define SWPS_DEBUG(fmt, args...) printk( KERN_DEBUG "[SWPS] " fmt, ##args) -#else -# define SWPS_DEBUG(fmt, args...) -#endif - - -struct ioexp_addr_s { - int chan_id; - int chip_addr; - int read_offset[8]; - int write_offset[8]; - int conf_offset[8]; - uint8_t data_default[8]; - uint8_t conf_default[8]; -}; - -struct ioexp_i2c_s { - int chip_id; - struct i2c_client *i2c_client_p; - struct ioexp_i2c_s *next; -}; - - -struct ioexp_bitmap_s { - int chip_id; /* IOEXP chip id */ - int ioexp_voffset; /* IOEXP virtual offset */ - int bit_shift; -}; - -struct ioexp_map_s { - int chip_amount; /* Number of chips that IOEXP object content */ - int data_width; /* Number of (Read/Write/Config) bytes */ - struct ioexp_addr_s *map_addr; /* Chip address info */ - struct ioexp_bitmap_s map_present[10]; /* IOEXP for SFP / QSFP */ - struct ioexp_bitmap_s map_tx_disable[10]; /* IOEXP for SFP */ - struct ioexp_bitmap_s map_tx_fault[10]; /* IOEXP for SFP */ - struct ioexp_bitmap_s map_rxlos[10]; /* IOEXP for SFP */ - struct ioexp_bitmap_s map_reset[10]; /* IOEXP for QSFP */ - struct ioexp_bitmap_s map_lpmod[10]; /* IOEXP for QSFP */ - struct ioexp_bitmap_s map_modsel[10]; /* IOEXP for QSFP */ - struct ioexp_bitmap_s map_hard_rs0[10]; /* IOEXP for QSFP */ - struct ioexp_bitmap_s map_hard_rs1[10]; /* IOEXP for QSFP */ -}; - -struct ioexp_data_s { - uint8_t data[8]; -}; - -struct ioexp_obj_s { - - /* ============================ - * Object public property - * ============================ - */ - int ioexp_id; - int ioexp_type; - - /* ============================ - * Object private property - * ============================ - */ - struct ioexp_data_s chip_data[16]; /* Max: 8-ioexp in one virt-ioexp(ioexp_obj) */ - struct ioexp_map_s *ioexp_map_p; - struct ioexp_obj_s *next; - struct ioexp_i2c_s *i2c_head_p; - struct mutex lock; - int mode; - int state; - - /* =========================================== - * Object public functions - * =========================================== - */ - int (*get_present)(struct ioexp_obj_s *self, int virt_offset); - int (*get_tx_fault)(struct ioexp_obj_s *self, int virt_offset); - int (*get_rxlos)(struct ioexp_obj_s *self, int virt_offset); - int (*get_tx_disable)(struct ioexp_obj_s *self, int virt_offset); - int (*get_reset)(struct ioexp_obj_s *self, int virt_offset); - int (*get_lpmod)(struct ioexp_obj_s *self, int virt_offset); - int (*get_modsel)(struct ioexp_obj_s *self, int virt_offset); - int (*get_hard_rs0)(struct ioexp_obj_s *self, int virt_offset); - int (*get_hard_rs1)(struct ioexp_obj_s *self, int virt_offset); - int (*set_tx_disable)(struct ioexp_obj_s *self, int virt_offset, int input_val); - int (*set_reset)(struct ioexp_obj_s *self, int virt_offset, int input_val); - int (*set_lpmod)(struct ioexp_obj_s *self, int virt_offset, int input_val); - int (*set_modsel)(struct ioexp_obj_s *self, int virt_offset, int input_val); - int (*set_hard_rs0)(struct ioexp_obj_s *self, int virt_offset, int input_val); - int (*set_hard_rs1)(struct ioexp_obj_s *self, int virt_offset, int input_val); - - /* =========================================== - * Object private functions - * =========================================== - */ - int (*init)(struct ioexp_obj_s *self); - int (*check)(struct ioexp_obj_s *self); - int (*update_all)(struct ioexp_obj_s *self, int show_err, char *caller_name); - int (*fsm_4_direct)(struct ioexp_obj_s* self); - int (*fsm_4_polling)(struct ioexp_obj_s* self); -}; - - -struct ioexp_obj_s* get_ioexp_obj(int ioexp_id); -int create_ioexp_obj(int ioexp_id, - int ioexp_type, - struct ioexp_addr_s *addr_map_p, - int run_mode); -int init_ioexp_objs(void); -int check_ioexp_objs(void); -void clean_ioexp_objs(void); - -void unlock_ioexp_all(void); -int lock_ioexp_all(void); - -int check_channel_tier_1(void); -int resync_channel_tier_1(void); - -/* Macro for bit control */ -#define SWP_BIT_SET(byte_val,bit_shift) ((byte_val) |= (1<<(bit_shift))) -#define SWP_BIT_CLEAR(byte_val,bit_shift) ((byte_val) &= ~(1<<(bit_shift))) - - -#endif /* IO_EXPANDER_H */ - - - - - - - - diff --git a/packages/platforms/inventec/x86-64/d10056/modules/builds/src/onie_tlvinfo.c b/packages/platforms/inventec/x86-64/d10056/modules/builds/src/onie_tlvinfo.c deleted file mode 100644 index 303ffde76..000000000 --- a/packages/platforms/inventec/x86-64/d10056/modules/builds/src/onie_tlvinfo.c +++ /dev/null @@ -1,820 +0,0 @@ -#include -#include -#include -#include -//#include -#include - -//#include -//#include -#include "onie_tlvinfo.h" - -/* Set to 1 if we've read EEPROM into memory */ -static int has_been_read = 0; - -int read_sys_eeprom(struct i2c_client *pi2c_client,void *eeprom_data, int offset, int len); -int write_sys_eeprom(struct i2c_client *pi2c_client, void *eeprom_data, int len); - -static inline int is_multicast_ether_addr(const u_int8_t *addr) -{ - return 0x01 & addr[0]; -} - -static inline int is_zero_ether_addr(const u_int8_t *addr) -{ - return !(addr[0] | addr[1] | addr[2] | addr[3] | addr[4] | addr[5]); -} - -static inline int is_valid_ether_addr(const u_int8_t *addr) -{ - return !is_multicast_ether_addr(addr) && !is_zero_ether_addr(addr); -} - -#if 0 -static unsigned int crc32(unsigned char const *p, unsigned int len) -{ - int i; - unsigned int crc = 0; - while (len--) { - crc ^= *p++; - for (i = 0; i < 8; i++) - crc = (crc >> 1) ^ ((crc & 1) ? 0xedb88320 : 0); - } - return crc; -} -#else -static unsigned long crc32_tab[] = { - 0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f, - 0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988, - 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91, 0x1db71064, 0x6ab020f2, - 0xf3b97148, 0x84be41de, 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7, - 0x136c9856, 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, 0x14015c4f, 0x63066cd9, - 0xfa0f3d63, 0x8d080df5, 0x3b6e20c8, 0x4c69105e, 0xd56041e4, 0xa2677172, - 0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b, 0x35b5a8fa, 0x42b2986c, - 0xdbbbc9d6, 0xacbcf940, 0x32d86ce3, 0x45df5c75, 0xdcd60dcf, 0xabd13d59, - 0x26d930ac, 0x51de003a, 0xc8d75180, 0xbfd06116, 0x21b4f4b5, 0x56b3c423, - 0xcfba9599, 0xb8bda50f, 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924, - 0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d, 0x76dc4190, 0x01db7106, - 0x98d220bc, 0xefd5102a, 0x71b18589, 0x06b6b51f, 0x9fbfe4a5, 0xe8b8d433, - 0x7807c9a2, 0x0f00f934, 0x9609a88e, 0xe10e9818, 0x7f6a0dbb, 0x086d3d2d, - 0x91646c97, 0xe6635c01, 0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e, - 0x6c0695ed, 0x1b01a57b, 0x8208f4c1, 0xf50fc457, 0x65b0d9c6, 0x12b7e950, - 0x8bbeb8ea, 0xfcb9887c, 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, 0xfbd44c65, - 0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2, 0x4adfa541, 0x3dd895d7, - 0xa4d1c46d, 0xd3d6f4fb, 0x4369e96a, 0x346ed9fc, 0xad678846, 0xda60b8d0, - 0x44042d73, 0x33031de5, 0xaa0a4c5f, 0xdd0d7cc9, 0x5005713c, 0x270241aa, - 0xbe0b1010, 0xc90c2086, 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f, - 0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, 0x59b33d17, 0x2eb40d81, - 0xb7bd5c3b, 0xc0ba6cad, 0xedb88320, 0x9abfb3b6, 0x03b6e20c, 0x74b1d29a, - 0xead54739, 0x9dd277af, 0x04db2615, 0x73dc1683, 0xe3630b12, 0x94643b84, - 0x0d6d6a3e, 0x7a6a5aa8, 0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1, - 0xf00f9344, 0x8708a3d2, 0x1e01f268, 0x6906c2fe, 0xf762575d, 0x806567cb, - 0x196c3671, 0x6e6b06e7, 0xfed41b76, 0x89d32be0, 0x10da7a5a, 0x67dd4acc, - 0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5, 0xd6d6a3e8, 0xa1d1937e, - 0x38d8c2c4, 0x4fdff252, 0xd1bb67f1, 0xa6bc5767, 0x3fb506dd, 0x48b2364b, - 0xd80d2bda, 0xaf0a1b4c, 0x36034af6, 0x41047a60, 0xdf60efc3, 0xa867df55, - 0x316e8eef, 0x4669be79, 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236, - 0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f, 0xc5ba3bbe, 0xb2bd0b28, - 0x2bb45a92, 0x5cb36a04, 0xc2d7ffa7, 0xb5d0cf31, 0x2cd99e8b, 0x5bdeae1d, - 0x9b64c2b0, 0xec63f226, 0x756aa39c, 0x026d930a, 0x9c0906a9, 0xeb0e363f, - 0x72076785, 0x05005713, 0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38, - 0x92d28e9b, 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21, 0x86d3d2d4, 0xf1d4e242, - 0x68ddb3f8, 0x1fda836e, 0x81be16cd, 0xf6b9265b, 0x6fb077e1, 0x18b74777, - 0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c, 0x8f659eff, 0xf862ae69, - 0x616bffd3, 0x166ccf45, 0xa00ae278, 0xd70dd2ee, 0x4e048354, 0x3903b3c2, - 0xa7672661, 0xd06016f7, 0x4969474d, 0x3e6e77db, 0xaed16a4a, 0xd9d65adc, - 0x40df0b66, 0x37d83bf0, 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9, - 0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605, 0xcdd70693, - 0x54de5729, 0x23d967bf, 0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94, - 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d -}; - -static unsigned long crc32(unsigned char const *buf, unsigned int size) -{ - unsigned char *p = buf; - unsigned long crc = 0; - - crc = crc ^ ~0U; - - while (size--) - crc = crc32_tab[(crc ^ *p++) & 0xFF] ^ (crc >> 8); - - return crc ^ ~0U; -} -#endif - -static int set_bytes(char *buf, const char *string, int * converted_accum) -{ - char *p = (char *) string; - int i; - uint byte; - - if (!p) { - printk("ERROR: NULL string passed in.\n"); - return -1; - } - /* Convert string to bytes */ - for (i = 0, p = (char *)string; (i < TLV_VALUE_MAX_LEN) && (*p != 0); - i++) { - while ((*p == ' ') || (*p == '\t') || (*p == ',') || - (*p == ';')) { - p++; - } - if (*p != 0) { - if (!isdigit(*p)) { - printk("ERROR: Non-digit found in byte string: (%s)\n", string); - return -1; - } - byte = strtoul(p, &p, 0); - if (byte >= 256) { - printk("ERROR: The value specified is greater than 255: (%u) " \ - "in string: %s\n", byte, string); - return -1; - } - buf[i] = byte & 0xFF; - } - } - if ((i == TLV_VALUE_MAX_LEN) && (*p != 0)) { - printk("ERROR: Trying to assign too many bytes " - "(max: %d) in string: %s\n", TLV_VALUE_MAX_LEN, string); - return -1; - } - *converted_accum = i; - return 0; -} - -/* - * set_date - * - * Validates the format of the data string - * - * This function takes a pointer to a date string (i.e. MM/DD/YYYY hh:mm:ss) - * and validates that the format is correct. If so the string is copied - * to the supplied buffer. - */ -static int set_date(char *buf, const char *string) -{ - int i; - - if (!string) { - printk("ERROR: NULL date string passed in.\n"); - return -1; - } - if (strlen(string) != 19) { - printk("ERROR: Date strlen() != 19 -- %d\n", strlen(string)); - printk("ERROR: Bad date format (MM/DD/YYYY hh:mm:ss): %s\n", string); - return -1; - } - for (i = 0; string[i] != 0; i++) { - switch (i) { - case 2: - case 5: - if (string[i] != '/') { - printk("ERROR: Bad date format (MM/DD/YYYY hh:mm:ss): %s\n", - string); - return -1; - } - break; - case 10: - if (string[i] != ' ') { - printk("ERROR: Bad date format (MM/DD/YYYY hh:mm:ss): %s\n", - string); - return -1; - } - break; - case 13: - case 16: - if (string[i] != ':') { - printk("ERROR: Bad date format (MM/DD/YYYY hh:mm:ss): %s\n", - string); - return -1; - } - break; - default: - if (!isdigit(string[i])) { - printk("ERROR: Bad date format (MM/DD/YYYY hh:mm:ss): %s\n", - string); - return -1; - } - break; - } - } - strcpy(buf, string); - return 0; -} - -/* - * is_valid_tlv - * - * Perform basic sanity checks on a TLV field. The TLV is pointed to - * by the parameter provided. - * 1. The type code is not reserved (0x00 or 0xFF) - */ -static inline bool is_valid_tlv(tlvinfo_tlv_t *tlv) -{ - return((tlv->type != 0x00) && (tlv->type != 0xFF)); -} - -/* - * set_mac - * - * Converts a string MAC address into a binary buffer. - * - * This function takes a pointer to a MAC address string - * (i.e."XX:XX:XX:XX:XX:XX", where "XX" is a two-digit hex number). - * The string format is verified and then converted to binary and - * stored in a buffer. - */ -static int set_mac(char *buf, const char *string) -{ - char *p = (char *) string; - int i; - int err = 0; - char *end; - - if (!p) { - printk("ERROR: NULL mac addr string passed in.\n"); - return -1; - } - if (strlen(p) != 17) { - printk("ERROR: MAC address strlen() != 17 -- %d\n", strlen(p)); - printk("ERROR: Bad MAC address format: %s\n", string); - return -1; - } - for (i = 0; i < 17; i++) { - if ((i % 3) == 2) { - if (p[i] != ':') { - err++; - printk("ERROR: mac: p[%i] != :, found: `%c'\n", - i, p[i]); - break; - } - continue; - } else if (!isxdigit(p[i])) { - err++; - printk("ERROR: mac: p[%i] != hex digit, found: `%c'\n", - i, p[i]); - break; - } - } - if (err != 0) { - printk("ERROR: Bad MAC address format: %s\n", string); - return -1; - } - /* Convert string to binary */ - for (i = 0, p = (char *)string; i < 6; i++) { - buf[i] = p ? strtoul(p, &end, 16) : 0; - if (p) { - p = (*end) ? end + 1 : end; - } - } - if (!is_valid_ether_addr((char *)buf)) { - printk("ERROR: MAC address must not be 00:00:00:00:00:00, " - "a multicast address or FF:FF:FF:FF:FF:FF.\n"); - printk("ERROR: Bad MAC address format: %s\n", string); - return -1; - } - return 0; -} - -/* - * is_valid_tlvinfo_header - * - * Perform sanity checks on the first 11 bytes of the TlvInfo EEPROM - * data pointed to by the parameter: - * 1. First 8 bytes contain null-terminated ASCII string "TlvInfo" - * 2. Version byte is 1 - * 3. Total length bytes contain value which is less than or equal - * to the allowed maximum (2048-11) - * - */ -static inline bool is_valid_tlvinfo_header(tlvinfo_header_t *hdr) -{ - int max_size = TLV_TOTAL_LEN_MAX; - return((strcmp(hdr->signature, TLV_INFO_ID_STRING) == 0) && - (hdr->version == TLV_INFO_VERSION) && - (be16_to_cpu(hdr->totallen) <= max_size) ); -} - -/* - * decode_tlv_value - * - * Decode a single TLV value into a string. - - * The validity of EEPROM contents and the TLV field have been verified - * prior to calling this function. - */ -#define DECODE_NAME_MAX 20 - -static void decode_tlv_value(tlvinfo_tlv_t * tlv, char* value) -{ - int i; - - switch (tlv->type) { - case TLV_CODE_PRODUCT_NAME: - case TLV_CODE_PART_NUMBER: - case TLV_CODE_SERIAL_NUMBER: - case TLV_CODE_MANUF_DATE: - case TLV_CODE_LABEL_REVISION: - case TLV_CODE_PLATFORM_NAME: - case TLV_CODE_ONIE_VERSION: - case TLV_CODE_MANUF_NAME: - case TLV_CODE_MANUF_COUNTRY: - case TLV_CODE_VENDOR_NAME: - case TLV_CODE_DIAG_VERSION: - case TLV_CODE_SERVICE_TAG: - memcpy(value, tlv->value, tlv->length); - value[tlv->length] = 0; - break; - case TLV_CODE_MAC_BASE: - snprintf(value, MAX_STRING_SIZE, "%02X:%02X:%02X:%02X:%02X:%02X", - tlv->value[0], tlv->value[1], tlv->value[2], - tlv->value[3], tlv->value[4], tlv->value[5]); - break; - case TLV_CODE_DEVICE_VERSION: - snprintf(value, MAX_STRING_SIZE, "%u", tlv->value[0]); - break; - case TLV_CODE_MAC_SIZE: - snprintf(value, MAX_STRING_SIZE, "%u", (tlv->value[0] << 8) | tlv->value[1]); - break; - case TLV_CODE_VENDOR_EXT: - value[0] = 0; - for (i = 0; (i < (TLV_DECODE_VALUE_MAX_LEN/5)) && (i < tlv->length); - i++) { - snprintf(value, MAX_STRING_SIZE, "%s 0x%02X", value, tlv->value[i]); - } - break; - case TLV_CODE_CRC_32: - snprintf(value, MAX_STRING_SIZE, "0x%02X%02X%02X%02X", - tlv->value[0], tlv->value[1], tlv->value[2], - tlv->value[3]); - break; - default: - value[0] = 0; - for (i = 0; (i < (TLV_DECODE_VALUE_MAX_LEN/5)) && (i < tlv->length); - i++) { - snprintf(value, MAX_STRING_SIZE, "%s 0x%02X", value, tlv->value[i]); - } - break; - } - -} - -/* - * is_checksum_valid - * - * Validate the checksum in the provided TlvInfo EEPROM data. First, - * verify that the TlvInfo header is valid, then make sure the last - * TLV is a CRC-32 TLV. Then calculate the CRC over the EEPROM data - * and compare it to the value stored in the EEPROM CRC-32 TLV. - */ -static bool is_checksum_valid(u_int8_t *eeprom) -{ - tlvinfo_header_t * eeprom_hdr = (tlvinfo_header_t *) eeprom; - tlvinfo_tlv_t * eeprom_crc; - unsigned int calc_crc; - unsigned int stored_crc; - - // Is the eeprom header valid? - if (!is_valid_tlvinfo_header(eeprom_hdr)) { - return(FALSE); - } - - // Is the last TLV a CRC? - eeprom_crc = (tlvinfo_tlv_t *) &eeprom[sizeof(tlvinfo_header_t) + - be16_to_cpu(eeprom_hdr->totallen) - - (sizeof(tlvinfo_tlv_t) + 4)]; - if ((eeprom_crc->type != TLV_CODE_CRC_32) || (eeprom_crc->length != 4)) { - return(FALSE); - } - - // Calculate the checksum - calc_crc = crc32((void *)eeprom, sizeof(tlvinfo_header_t) + - be16_to_cpu(eeprom_hdr->totallen) - 4); - stored_crc = ((eeprom_crc->value[0] << 24) | (eeprom_crc->value[1] << 16) | - (eeprom_crc->value[2] << 8) | eeprom_crc->value[3]); - - //printk(KERN_ERR "[SWPS] cal_crc =0x%x, stored_crc =0x%x\n", calc_crc, stored_crc); - //return(calc_crc == stored_crc); - return 1; -} - -/* - * update_crc - * - * This function updates the CRC-32 TLV. If there is no CRC-32 TLV, then - * one is added. This function should be called after each update to the - * EEPROM structure, to make sure the CRC is always correct. - */ -static void update_crc(u_int8_t *eeprom) -{ - tlvinfo_header_t * eeprom_hdr = (tlvinfo_header_t *) eeprom; - tlvinfo_tlv_t * eeprom_crc; - unsigned int calc_crc; - - // Is the eeprom header valid? - if (!is_valid_tlvinfo_header(eeprom_hdr)) { - return; - } - // Is the last TLV a CRC? - eeprom_crc = (tlvinfo_tlv_t *) &eeprom[sizeof(tlvinfo_header_t) + - be16_to_cpu(eeprom_hdr->totallen) - - (sizeof(tlvinfo_tlv_t) + 4)]; - if (eeprom_crc->type != TLV_CODE_CRC_32) { - if ((be16_to_cpu(eeprom_hdr->totallen) + sizeof(tlvinfo_tlv_t) + 4) > - TLV_TOTAL_LEN_MAX) { - return; - } - eeprom_crc = (tlvinfo_tlv_t *) &eeprom[sizeof(tlvinfo_header_t) + - be16_to_cpu( - eeprom_hdr->totallen)]; - eeprom_hdr->totallen = cpu_to_be16(be16_to_cpu(eeprom_hdr->totallen) + - sizeof(tlvinfo_tlv_t) + 4); - eeprom_crc->type = TLV_CODE_CRC_32; - } - eeprom_crc->length = 4; - - // Calculate the checksum - calc_crc = crc32((void *)eeprom, - sizeof(tlvinfo_header_t) + - be16_to_cpu(eeprom_hdr->totallen) - 4); - - eeprom_crc->value[0] = (calc_crc >> 24) & 0xFF; - eeprom_crc->value[1] = (calc_crc >> 16) & 0xFF; - eeprom_crc->value[2] = (calc_crc >> 8) & 0xFF; - eeprom_crc->value[3] = (calc_crc >> 0) & 0xFF; -} - -/* - * show_eeprom - * - * Display the contents of the EEPROM - */ - -/* - * read_eeprom - * - * Read the EEPROM into memory, if it hasn't already been read. - */ -int read_eeprom( struct i2c_client *pi2c_client, u_int8_t *eeprom) -{ - int ret; - tlvinfo_header_t *eeprom_hdr = (tlvinfo_header_t *) eeprom; - tlvinfo_tlv_t *eeprom_tlv = (tlvinfo_tlv_t *)&eeprom[ - sizeof(tlvinfo_header_t)]; - - if (has_been_read) - return 0; - - /* Read the header */ - ret = read_sys_eeprom( pi2c_client,(void *)eeprom_hdr, 0, sizeof(tlvinfo_header_t)); - /* If the header was successfully read, read the TLVs */ - if ((ret == 0) && is_valid_tlvinfo_header(eeprom_hdr)) { - ret = read_sys_eeprom( pi2c_client, (void *)eeprom_tlv, sizeof(tlvinfo_header_t), - be16_to_cpu(eeprom_hdr->totallen)); - } - // If the contents are invalid, start over with default contents - if(!is_valid_tlvinfo_header(eeprom_hdr)) - printk(KERN_ERR - "Notice: Invalid TLV header found. Using default contents--1.\n"); - if(!is_checksum_valid(eeprom)) - printk(KERN_ERR - "Notice: Invalid TLV checksum found. Using default contents--2.\n"); - if ( !is_valid_tlvinfo_header(eeprom_hdr) || !is_checksum_valid(eeprom) ){ - strcpy(eeprom_hdr->signature, TLV_INFO_ID_STRING); - eeprom_hdr->version = TLV_INFO_VERSION; - eeprom_hdr->totallen = cpu_to_be16(0); - update_crc(eeprom); - } - has_been_read = 1; - - return ret; -} -EXPORT_SYMBOL(read_eeprom); - -/* - * prog_eeprom - * Write the EEPROM data from CPU memory to the hardware. - */ -int prog_eeprom(struct i2c_client *pi2c_client, u_int8_t * eeprom) -{ - int ret = 0; - tlvinfo_header_t * eeprom_hdr = (tlvinfo_header_t *) eeprom; - int eeprom_len; - - eeprom_len = sizeof(tlvinfo_header_t) + be16_to_cpu(eeprom_hdr->totallen); - ret = write_sys_eeprom( pi2c_client, eeprom, eeprom_len); - if (ret) { - printk("Programming failed.\n"); - return -1; - } - has_been_read = 0; - return 0; -} -EXPORT_SYMBOL(prog_eeprom); - -/* - * tlvinfo_find_tlv - * - * This function finds the TLV with the supplied code in the EERPOM. - * An offset from the beginning of the EEPROM is returned in the - * eeprom_index parameter if the TLV is found. - */ -bool tlvinfo_find_tlv(u_int8_t *eeprom, u_int8_t tcode, - int *eeprom_index) -{ - tlvinfo_header_t * eeprom_hdr = (tlvinfo_header_t *) eeprom; - tlvinfo_tlv_t * eeprom_tlv; - int eeprom_end; - - // Make sure the EEPROM contents are valid - if (!is_valid_tlvinfo_header(eeprom_hdr) || !is_checksum_valid(eeprom)) { - return(FALSE); - } - // Search through the TLVs, looking for the first one which matches the - // supplied type code. - *eeprom_index = sizeof(tlvinfo_header_t); - eeprom_end = sizeof(tlvinfo_header_t) + be16_to_cpu(eeprom_hdr->totallen); - - while (*eeprom_index < eeprom_end) { - eeprom_tlv = (tlvinfo_tlv_t *) &eeprom[*eeprom_index]; - if (!is_valid_tlv(eeprom_tlv)) { - return(FALSE); - } - if (eeprom_tlv->type == tcode) { - return(TRUE); - } - *eeprom_index += sizeof(tlvinfo_tlv_t) + eeprom_tlv->length; - } - return(FALSE); -} - -/* - * tlvinfo_decode_tlv - * - * This function finds the TLV with the supplied code in the EERPOM - * and decodes the value into the buffer provided. - */ -bool tlvinfo_decode_tlv(u_int8_t *eeprom, u_int8_t tcode, char* value) -{ - int eeprom_index; - tlvinfo_tlv_t * eeprom_tlv; - - // Find the TLV and then decode it - - if (tlvinfo_find_tlv(eeprom, tcode, &eeprom_index)) { - eeprom_tlv = (tlvinfo_tlv_t *) &eeprom[eeprom_index]; - decode_tlv_value(eeprom_tlv, value); - return TRUE; - } - - return FALSE; -} -EXPORT_SYMBOL(tlvinfo_decode_tlv); - -/* - * tlvinfo_delete_tlv - * - * This function deletes the TLV with the specified type code from the - * EEPROM. - */ -bool tlvinfo_delete_tlv(u_int8_t * eeprom, u_int8_t code) -{ - int eeprom_index; - int tlength; - tlvinfo_header_t * eeprom_hdr = (tlvinfo_header_t *) eeprom; - tlvinfo_tlv_t * eeprom_tlv; - - // Find the TLV and then move all following TLVs "forward" - if (tlvinfo_find_tlv(eeprom, code, &eeprom_index)) { - eeprom_tlv = (tlvinfo_tlv_t *) &eeprom[eeprom_index]; - tlength = sizeof(tlvinfo_tlv_t) + eeprom_tlv->length; - memcpy(&eeprom[eeprom_index], &eeprom[eeprom_index+tlength], - sizeof(tlvinfo_header_t) + be16_to_cpu(eeprom_hdr->totallen) - - eeprom_index - tlength); - eeprom_hdr->totallen = cpu_to_be16(be16_to_cpu(eeprom_hdr->totallen) - - tlength); - update_crc(eeprom); - return(TRUE); - } - return(FALSE); -} -EXPORT_SYMBOL(tlvinfo_delete_tlv); - -/* - * tlvinfo_add_tlv - * - * This function adds a TLV to the EEPROM, converting the value (a string) to - * the format in which it will be stored in the EEPROM. - */ -#define MAX_TLV_VALUE_LEN 256 -bool tlvinfo_add_tlv(u_int8_t * eeprom, int tcode, char * strval) -{ - tlvinfo_header_t * eeprom_hdr = (tlvinfo_header_t *) eeprom; - tlvinfo_tlv_t * eeprom_tlv; - int new_tlv_len = 0; - u_int32_t value; - char data[MAX_TLV_VALUE_LEN]; - int eeprom_index; - int max_size = TLV_TOTAL_LEN_MAX; - - // Encode each TLV type into the format to be stored in the EERPOM - switch (tcode) { - case TLV_CODE_PRODUCT_NAME: - case TLV_CODE_PART_NUMBER: - case TLV_CODE_SERIAL_NUMBER: - case TLV_CODE_LABEL_REVISION: - case TLV_CODE_PLATFORM_NAME: - case TLV_CODE_ONIE_VERSION: - case TLV_CODE_MANUF_NAME: - case TLV_CODE_MANUF_COUNTRY: - case TLV_CODE_VENDOR_NAME: - case TLV_CODE_DIAG_VERSION: - case TLV_CODE_SERVICE_TAG: - strncpy(data, strval, MAX_TLV_VALUE_LEN); - - if( strlen(strval) >= MAX_TLV_VALUE_LEN ) - new_tlv_len = MAX_TLV_VALUE_LEN; - else - new_tlv_len = strlen(strval); - - break; - case TLV_CODE_DEVICE_VERSION: - value = strtoul(strval, NULL, 0); - if (value >= 256) { - printk("ERROR: Device version must be 255 or less. Value " \ - "supplied: %u", value); - return(FALSE); - } - data[0] = value & 0xFF; - new_tlv_len = 1; - break; - case TLV_CODE_MAC_SIZE: - value = strtoul(strval, NULL, 0); - if (value >= 65536) { - printk("ERROR: MAC Size must be 65535 or less. Value " \ - "supplied: %u", value); - return(FALSE); - } - data[0] = (value >> 8) & 0xFF; - data[1] = value & 0xFF; - new_tlv_len = 2; - break; - case TLV_CODE_MANUF_DATE: - if (set_date(data, strval) != 0) { - return(FALSE); - } - new_tlv_len = 19; - break; - case TLV_CODE_MAC_BASE: - if (set_mac(data, strval) != 0) { - return(FALSE); - } - new_tlv_len = 6; - break; - case TLV_CODE_CRC_32: - printk("WARNING: The CRC TLV is set automatically and cannot be set " \ - "manually.\n"); - return(FALSE); - case TLV_CODE_VENDOR_EXT: - default: - if (set_bytes(data, strval, &new_tlv_len) != 0 ) { - return(FALSE); - } - break; - } - - // Is there room for this TLV? - if ((be16_to_cpu(eeprom_hdr->totallen) + sizeof(tlvinfo_tlv_t) + - new_tlv_len) > max_size) { - printk("ERROR: There is not enough room in the EERPOM to save data.\n"); - return(FALSE); - } - - // Add TLV at the end, overwriting CRC TLV if it exists - if (tlvinfo_find_tlv(eeprom, TLV_CODE_CRC_32, &eeprom_index)) { - eeprom_hdr->totallen = cpu_to_be16(be16_to_cpu(eeprom_hdr->totallen) - - sizeof(tlvinfo_tlv_t) - 4); - } else { - eeprom_index = sizeof(tlvinfo_header_t) + - be16_to_cpu(eeprom_hdr->totallen); - } - eeprom_tlv = (tlvinfo_tlv_t *) &eeprom[eeprom_index]; - eeprom_tlv->type = tcode; - eeprom_tlv->length = new_tlv_len; - memcpy(eeprom_tlv->value, data, new_tlv_len); - - // Update the total length and calculate (add) a new CRC-32 TLV - eeprom_hdr->totallen = cpu_to_be16(be16_to_cpu(eeprom_hdr->totallen) + - sizeof(tlvinfo_tlv_t) + new_tlv_len); - update_crc(eeprom); - - return(TRUE); -} -EXPORT_SYMBOL(tlvinfo_add_tlv); - -/* - * read_sys_eeprom - read the hwinfo from i2c EEPROM - */ -int read_sys_eeprom(struct i2c_client *pi2c_client,void *eeprom_data, int offset, int len) -{ - int iRet = 0; - int i = 0; - unsigned char ucBuf[2]; - u_int8_t *c; - unsigned short usAddr = SYS_EEPROM_OFFSET + offset; - - c = eeprom_data; - for (i = 0; i < len; i++) { - ucBuf[0] = (usAddr & 0xFF00) >> 8; - ucBuf[1] = (usAddr & 0x00FF); - - iRet = i2c_smbus_write_byte_data(pi2c_client, ucBuf[0], ucBuf[1]); - if( iRet < 0 ){ - printk(KERN_ERR"Error!! VPD data read error\n"); - return -1; - } - - *c = i2c_smbus_read_byte(pi2c_client); - c++; usAddr++; - } - return 0; -} - -/* - * write_sys_eeprom - write the hwinfo to i2c EEPROM - */ -int write_sys_eeprom(struct i2c_client *pi2c_client, void *eeprom_data, int len) -{ - int iRet = 0; - int i = 0; - u_int8_t *c; - unsigned short usAddr = SYS_EEPROM_OFFSET; - unsigned char ucBuf[3]; - - c = eeprom_data; - for (i = 0; i < len; i++) { - ucBuf[ 0 ] = (usAddr & 0xFF00) >>8 ; - ucBuf[ 1 ] = (usAddr & 0x00FF); - ucBuf[ 2 ] = *c; - - iRet = i2c_smbus_write_word_data( pi2c_client, ucBuf[0], (ucBuf[2] << 8 | ucBuf[1])); - if (iRet < 0 ){ - printk(KERN_ERR"Error!! VPD data write error . \n"); - return -1; - } - - c++; usAddr++; - msleep_interruptible(10); - } - - return 0; -} - -void update_eeprom_header(u_int8_t *eeprom) -{ - tlvinfo_header_t * eeprom_hdr = (tlvinfo_header_t *) eeprom; - - strcpy(eeprom_hdr->signature, TLV_INFO_ID_STRING); - eeprom_hdr->version = TLV_INFO_VERSION; - eeprom_hdr->totallen = cpu_to_be16(0); - update_crc(eeprom); -} -#if 0 -int find_vpd_data(u_int8_t *eeprom, int i_offset, char *c_buf) -{ - int tlv_end; - int curr_tlv; - tlvinfo_header_t * eeprom_hdr = (tlvinfo_header_t *) eeprom; - tlvinfo_tlv_t * eeprom_tlv; - int iFind = 0; - - if( !is_valid_tlvinfo_header(eeprom_hdr) ) { - printk(KERN_ERR"EEPROM does not contain data in a valid TlvInfo format.\n"); - return -1; - } - - curr_tlv = sizeof(tlvinfo_header_t); - tlv_end = sizeof(tlvinfo_header_t) + be16_to_cpu(eeprom_hdr->totallen); - while(curr_tlv < tlv_end){ - eeprom_tlv = (tlvinfo_tlv_t *) &eeprom[curr_tlv]; - if (!is_valid_tlv(eeprom_tlv)) { - printk(KERN_ERR"Invalid TLV field starting at EEPROM offset %d\n", - curr_tlv); - return -1; - } - - decode_tlv_value(eeprom_tlv, c_buf); - if( eeprom_tlv->type == i_offset){ - iFind = 1; - break; - } - curr_tlv += sizeof(tlvinfo_tlv_t) + eeprom_tlv->length; - } - - if( iFind == 0 ) - return -1; - else - return 0; -} -#endif diff --git a/packages/platforms/inventec/x86-64/d10056/modules/builds/src/onie_tlvinfo.h b/packages/platforms/inventec/x86-64/d10056/modules/builds/src/onie_tlvinfo.h deleted file mode 100644 index 74f3c9604..000000000 --- a/packages/platforms/inventec/x86-64/d10056/modules/builds/src/onie_tlvinfo.h +++ /dev/null @@ -1,150 +0,0 @@ -/* - * The Definition of the TlvInfo EEPROM format can be found at onie.org or - * github.com/onie - */ -#include -#define strtoul simple_strtoul - -#define FALSE 0 -#define TRUE (!FALSE) -#define MAX_STRING_SIZE 128 -/* - * Tlvinf header: Layout of the header for the TlvInfo format - * - * See the end of this file for details of this eeprom format - */ -struct __attribute__ ((__packed__)) tlvinfo_header_s { - char signature[8]; /* 0x00 - 0x07 EEPROM Tag "TlvInfo" */ - u_int8_t version; /* 0x08 Structure version */ - u_int16_t totallen; /* 0x09 - 0x0A Length of all data which follows */ -}; -typedef struct tlvinfo_header_s tlvinfo_header_t; - -// Header Field Constants -#define TLV_INFO_ID_STRING "TlvInfo" -#define TLV_INFO_VERSION 0x01 -#define TLV_TOTAL_LEN_MAX (SYS_EEPROM_SIZE - sizeof(tlvinfo_header_t)) - -/* - * TlvInfo TLV: Layout of a TLV field - */ -struct __attribute__ ((__packed__)) tlvinfo_tlv_s { - u_int8_t type; - u_int8_t length; - u_int8_t value[0]; -}; -typedef struct tlvinfo_tlv_s tlvinfo_tlv_t; - -/* Maximum length of a TLV value in bytes */ -#define TLV_VALUE_MAX_LEN 255 - -/** - * The TLV Types. - * - * Keep these in sync with tlv_code_list in cmd_sys_eeprom.c - */ -#define TLV_CODE_PRODUCT_NAME 0x21 -#define TLV_CODE_PART_NUMBER 0x22 -#define TLV_CODE_SERIAL_NUMBER 0x23 -#define TLV_CODE_MAC_BASE 0x24 -#define TLV_CODE_MANUF_DATE 0x25 -#define TLV_CODE_DEVICE_VERSION 0x26 -#define TLV_CODE_LABEL_REVISION 0x27 -#define TLV_CODE_PLATFORM_NAME 0x28 -#define TLV_CODE_ONIE_VERSION 0x29 -#define TLV_CODE_MAC_SIZE 0x2A -#define TLV_CODE_MANUF_NAME 0x2B -#define TLV_CODE_MANUF_COUNTRY 0x2C -#define TLV_CODE_VENDOR_NAME 0x2D -#define TLV_CODE_DIAG_VERSION 0x2E -#define TLV_CODE_SERVICE_TAG 0x2F -#define TLV_CODE_VENDOR_EXT 0xFD -#define TLV_CODE_CRC_32 0xFE - -/* - * Struct for displaying the TLV codes and names. - */ -struct tlv_code_desc { - u_int8_t m_code; - char* m_name; -}; - -/* - * List of TLV codes and names. - */ -static const struct tlv_code_desc tlv_code_list[] = { - { TLV_CODE_PRODUCT_NAME , "Product Name"}, - { TLV_CODE_PART_NUMBER , "Part Number"}, - { TLV_CODE_SERIAL_NUMBER , "Serial Number"}, - { TLV_CODE_MAC_BASE , "Base MAC Address"}, - { TLV_CODE_MANUF_DATE , "Manufacture Date"}, - { TLV_CODE_DEVICE_VERSION , "Device Version"}, - { TLV_CODE_LABEL_REVISION , "Label Revision"}, - { TLV_CODE_PLATFORM_NAME , "Platform Name"}, - { TLV_CODE_ONIE_VERSION , "Loader Version"}, - { TLV_CODE_MAC_SIZE , "MAC Addresses"}, - { TLV_CODE_MANUF_NAME , "Manufacturer"}, - { TLV_CODE_MANUF_COUNTRY , "Country Code"}, - { TLV_CODE_VENDOR_NAME , "Vendor Name"}, - { TLV_CODE_DIAG_VERSION , "Diag Version"}, - { TLV_CODE_SERVICE_TAG , "Service Tag"}, - { TLV_CODE_VENDOR_EXT , "Vendor Extension"}, - { TLV_CODE_CRC_32 , "CRC-32"}, -}; - -static inline const char* tlv_type2name(u_int8_t type) -{ - char* name = "Unknown"; - int i; - - for (i = 0; i < sizeof(tlv_code_list)/sizeof(tlv_code_list[0]); i++) { - if (tlv_code_list[i].m_code == type) { - name = tlv_code_list[i].m_name; - break; - } - } - return name; -} - -/* - * The max decode value is currently for the 'raw' type or the 'vendor - * extension' type, both of which have the same decode format. The - * max decode string size is computed as follows: - * - * strlen(" 0xFF") * TLV_VALUE_MAX_LEN + 1 - * - */ -#define TLV_DECODE_VALUE_MAX_LEN ((5 * TLV_VALUE_MAX_LEN) + 1) - - -/* - * Each platform must define the following platform-specific macros - * in sys_eeprom_platform.h: - * SYS_EEPROM_SIZE: size of usable eeprom - * SYS_EEPROM_I2C_DEVICE: i2c-bus - * SYS_EEPROM_I2C_ADDR: address on the bus - * The following may also be defined in sys_eeprom_platform.h, else - * the defaults with take over: - * SYS_EEPROM_MAX_SIZE: Total size of the eeprom - * SYS_EEPROM_OFFSET: offset from where the ONIE header starts - */ -#define SYS_EEPROM_MAX_SIZE 2048 -#define SYS_EEPROM_OFFSET 0 -#define SYS_EEPROM_SIZE SYS_EEPROM_MAX_SIZE -#define SYS_EEPROM_I2C_DEVICE "/dev/i2c-0" -#define SYS_EEPROM_I2C_ADDR 0x53 - -#if (SYS_EEPROM_SIZE + SYS_EEPROM_OFFSET > SYS_EEPROM_MAX_SIZE) - #error SYS_EEPROM_SIZE + SYS_EEPROM_OFFSET is greater than SYS_EEPROM_MAX_SIZE -#endif - -// Access functions to onie_tlvinfo -void show_eeprom(u_int8_t *eeprom); -int read_eeprom(struct i2c_client *pi2c_client, u_int8_t *eeprom); -int prog_eeprom(struct i2c_client *pi2c_client,u_int8_t * eeprom); -void update_eeprom_header(u_int8_t *eeprom); -bool tlvinfo_find_tlv(u_int8_t *eeprom, u_int8_t tcode, int *eeprom_index); -bool tlvinfo_delete_tlv(u_int8_t * eeprom, u_int8_t code); -bool tlvinfo_add_tlv(u_int8_t * eeprom, int tcode, char * strval); -bool tlvinfo_decode_tlv(u_int8_t *eeprom, u_int8_t tcode, char* value); -//int find_vpd_data(u_int8_t *eeprom, int i_offset, char *c_buf); diff --git a/packages/platforms/inventec/x86-64/d10056/modules/builds/src/transceiver.c b/packages/platforms/inventec/x86-64/d10056/modules/builds/src/transceiver.c deleted file mode 100644 index a361d8bb1..000000000 --- a/packages/platforms/inventec/x86-64/d10056/modules/builds/src/transceiver.c +++ /dev/null @@ -1,8403 +0,0 @@ -#include -#include -#include -#include -#include "io_expander.h" -#include "transceiver.h" - -/* For build single module using (Ex: ONL platform) */ -#include -//#include -//#include - - -/* ========== Register EEPROM address mapping ========== - */ -struct eeprom_map_s eeprom_map_sfp = { - .addr_br =0x50, .page_br =-1, .offset_br =12, .length_br =1, - .addr_cdr =-1, .page_cdr =-1, .offset_cdr =-1, .length_cdr =-1, - .addr_comp_rev =0x50, .page_comp_rev =-1, .offset_comp_rev =94, .length_comp_rev =1, - .addr_connector =0x50, .page_connector =-1, .offset_connector =2, .length_connector =1, - .addr_diag_type =0x50, .page_diag_type =-1, .offset_diag_type =92 , .length_diag_type =1, - .addr_extbr =-1, .page_extbr =-1, .offset_extbr =-1, .length_extbr =-1, - .addr_ext_id =0x50, .page_ext_id =-1, .offset_ext_id =1, .length_ext_id =1, - .addr_id =0x50, .page_id =-1, .offset_id =0, .length_id =1, - .addr_len_sm =0x50, .page_len_sm =-1, .offset_len_sm =15, .length_len_sm =1, - .addr_len_smf =0x50, .page_len_smf =-1, .offset_len_smf =14, .length_len_smf =1, - .addr_len_om1 =0x50, .page_len_om1 =-1, .offset_len_om1 =17, .length_len_om1 =1, - .addr_len_om2 =0x50, .page_len_om2 =-1, .offset_len_om2 =16, .length_len_om2 =1, - .addr_len_om3 =0x50, .page_len_om3 =-1, .offset_len_om3 =19, .length_len_om3 =1, - .addr_len_om4 =0x50, .page_len_om4 =-1, .offset_len_om4 =18, .length_len_om4 =1, - .addr_option =0x50, .page_option =-1, .offset_option =64, .length_option =2, - .addr_rate_id =0x50, .page_rate_id =-1, .offset_rate_id =13, .length_rate_id =1, - .addr_rx_am =-1, .page_rx_am =-1, .offset_rx_am =-1, .length_rx_am =-1, - .addr_rx_em =0x51, .page_rx_em =-1, .offset_rx_em =115, .length_rx_em =1, - .addr_rx_los =-1, .page_rx_los =-1, .offset_rx_los =-1, .length_rx_los =-1, - .addr_rx_power =0x51, .page_rx_power =-1, .offset_rx_power =104, .length_rx_power =2, - .addr_soft_rs0 =0x51, .page_soft_rs0 =-1, .offset_soft_rs0 =110, .length_soft_rs0 =1, - .addr_soft_rs1 =0x51, .page_soft_rs1 =-1, .offset_soft_rs1 =118, .length_soft_rs0 =1, - .addr_temp =0x51, .page_temp =-1, .offset_temp =96, .length_temp =2, - .addr_trancomp =0x50, .page_trancomp =-1, .offset_trancomp =3, .length_trancomp =8, - .addr_trancomp_ext =0x50, .page_trancomp_ext =-1, .offset_trancomp_ext =36, .length_trancomp_ext =1, - .addr_tx_bias =0x51, .page_tx_bias =-1, .offset_tx_bias =100, .length_tx_bias =2, - .addr_tx_disable =-1, .page_tx_disable =-1, .offset_tx_disable =-1, .length_tx_disable =-1, - .addr_tx_eq =0x51, .page_tx_eq =-1, .offset_tx_eq =114, .length_tx_eq =1, - .addr_tx_fault =-1, .page_tx_fault =-1, .offset_tx_fault =-1, .length_tx_fault =-1, - .addr_tx_power =0x51, .page_tx_power =-1, .offset_tx_power =102, .length_tx_power =2, - .addr_vendor_name =0x50, .page_vendor_name =-1, .offset_vendor_name =20, .length_vendor_name =16, - .addr_vendor_pn =0x50, .page_vendor_pn =-1, .offset_vendor_pn =40, .length_vendor_pn =16, - .addr_vendor_rev =0x50, .page_vendor_rev =-1, .offset_vendor_rev =56, .length_vendor_rev =4, - .addr_vendor_sn =0x50, .page_vendor_sn =-1, .offset_vendor_sn =68, .length_vendor_sn =16, - .addr_voltage =0x51, .page_voltage =-1, .offset_voltage =98, .length_voltage =2, - .addr_wavelength =0x50, .page_wavelength =-1, .offset_wavelength =60, .length_wavelength =2, -}; - -struct eeprom_map_s eeprom_map_qsfp = { - .addr_br =0x50, .page_br =0, .offset_br =140, .length_br =1, - .addr_cdr =-1, .page_cdr =-1, .offset_cdr =-1, .length_cdr =-1, - .addr_comp_rev =0x50, .page_comp_rev =-1, .offset_comp_rev =1, .length_comp_rev =1, - .addr_connector =0x50, .page_connector =0, .offset_connector =130, .length_connector =1, - .addr_diag_type =0x50, .page_diag_type =0, .offset_diag_type =220, .length_diag_type =1, - .addr_extbr =0x50, .page_extbr =0, .offset_extbr =222, .length_extbr =1, - .addr_ext_id =0x50, .page_ext_id =0, .offset_ext_id =129, .length_ext_id =1, - .addr_id =0x50, .page_id =0, .offset_id =128, .length_id =1, - .addr_len_sm =-1, .page_len_sm =-1, .offset_len_sm =-1, .length_len_sm =-1, - .addr_len_smf =0x50, .page_len_smf =0, .offset_len_smf =142, .length_len_smf =1, - .addr_len_om1 =0x50, .page_len_om1 =0, .offset_len_om1 =145, .length_len_om1 =1, - .addr_len_om2 =0x50, .page_len_om2 =0, .offset_len_om2 =144, .length_len_om2 =1, - .addr_len_om3 =0x50, .page_len_om3 =0, .offset_len_om3 =143, .length_len_om3 =1, - .addr_len_om4 =0x50, .page_len_om4 =0, .offset_len_om4 =146, .length_len_om4 =1, - .addr_option =0x50, .page_option =0, .offset_option =193, .length_option =3, - .addr_rate_id =-1, .page_rate_id =-1, .offset_rate_id =-1, .length_rate_id =-1, - .addr_rx_am =-1, .page_rx_am =-1, .offset_rx_am =-1, .length_rx_am =-1, - .addr_rx_em =-1, .page_rx_em =-1, .offset_rx_em =-1, .length_rx_em =-1, - .addr_rx_los =0x50, .page_rx_los =-1, .offset_rx_los =3, .length_rx_los =1, - .addr_rx_power =0x50, .page_rx_power =-1, .offset_rx_power =34, .length_rx_power =8, - .addr_soft_rs0 =-1, .page_soft_rs0 =-1, .offset_soft_rs0 =-1, .length_soft_rs0 =-1, - .addr_soft_rs1 =-1, .page_soft_rs1 =-1, .offset_soft_rs1 =-1, .length_soft_rs0 =-1, - .addr_temp =0x50, .page_temp =-1, .offset_temp =22, .length_temp =2, - .addr_trancomp =0x50, .page_trancomp =0, .offset_trancomp =131, .length_trancomp =8, - .addr_trancomp_ext =0x50, .page_trancomp_ext =0, .offset_trancomp_ext =192, .length_trancomp_ext =1, - .addr_tx_bias =0x50, .page_tx_bias =-1, .offset_tx_bias =42, .length_tx_bias =8, - .addr_tx_disable =0x50, .page_tx_disable =-1, .offset_tx_disable =86, .length_tx_disable =1, - .addr_tx_eq =-1, .page_tx_eq =-1, .offset_tx_eq =-1, .length_tx_eq =-1, - .addr_tx_fault =0x50, .page_tx_fault =-1, .offset_tx_fault =4, .length_tx_fault =1, - .addr_tx_power =0x50, .page_tx_power =-1, .offset_tx_power =50, .length_tx_power =8, - .addr_vendor_name =0x50, .page_vendor_name =0, .offset_vendor_name =148, .length_vendor_name =16, - .addr_vendor_pn =0x50, .page_vendor_pn =0, .offset_vendor_pn =168, .length_vendor_pn =16, - .addr_vendor_rev =0x50, .page_vendor_rev =0, .offset_vendor_rev =184, .length_vendor_rev =2, - .addr_vendor_sn =0x50, .page_vendor_sn =0, .offset_vendor_sn =196, .length_vendor_sn =16, - .addr_voltage =0x50, .page_voltage =-1, .offset_voltage =26, .length_voltage =2, - .addr_wavelength =0x50, .page_wavelength =0, .offset_wavelength =186, .length_wavelength =2, -}; - -struct eeprom_map_s eeprom_map_qsfp28 = { - .addr_br =0x50, .page_br =0, .offset_br =140, .length_br =1, - .addr_cdr =0x50, .page_cdr =-1, .offset_cdr =98, .length_cdr =1, - .addr_comp_rev =0x50, .page_comp_rev =-1, .offset_comp_rev =1, .length_comp_rev =1, - .addr_connector =0x50, .page_connector =0, .offset_connector =130, .length_connector =1, - .addr_diag_type =0x50, .page_diag_type =0, .offset_diag_type =220, .length_diag_type =1, - .addr_extbr =0x50, .page_extbr =0, .offset_extbr =222, .length_extbr =1, - .addr_ext_id =0x50, .page_ext_id =0, .offset_ext_id =129, .length_ext_id =1, - .addr_id =0x50, .page_id =0, .offset_id =128, .length_id =1, - .addr_len_sm =-1, .page_len_sm =-1, .offset_len_sm =-1, .length_len_sm =-1, - .addr_len_smf =0x50, .page_len_smf =0, .offset_len_smf =142, .length_len_smf =1, - .addr_len_om1 =0x50, .page_len_om1 =0, .offset_len_om1 =145, .length_len_om1 =1, - .addr_len_om2 =0x50, .page_len_om2 =0, .offset_len_om2 =144, .length_len_om2 =1, - .addr_len_om3 =0x50, .page_len_om3 =0, .offset_len_om3 =143, .length_len_om3 =1, - .addr_len_om4 =0x50, .page_len_om4 =0, .offset_len_om4 =146, .length_len_om4 =1, - .addr_option =0x50, .page_option =0, .offset_option =193, .length_option =3, - .addr_rate_id =-1, .page_rate_id =-1, .offset_rate_id =-1, .length_rate_id =-1, - .addr_rx_am =0x50, .page_rx_am =3, .offset_rx_am =238, .length_rx_am =2, - .addr_rx_em =0x50, .page_rx_em =3, .offset_rx_em =236, .length_rx_em =2, - .addr_rx_los =0x50, .page_rx_los =-1, .offset_rx_los =3, .length_rx_los =1, - .addr_rx_power =0x50, .page_rx_power =-1, .offset_rx_power =34, .length_rx_power =8, - .addr_soft_rs0 =-1, .page_soft_rs0 =-1, .offset_soft_rs0 =-1, .length_soft_rs0 =-1, - .addr_soft_rs1 =-1, .page_soft_rs1 =-1, .offset_soft_rs1 =-1, .length_soft_rs0 =-1, - .addr_temp =0x50, .page_temp =-1, .offset_temp =22, .length_temp =2, - .addr_trancomp =0x50, .page_trancomp =0, .offset_trancomp =131, .length_trancomp =8, - .addr_trancomp_ext =0x50, .page_trancomp_ext =0, .offset_trancomp_ext =192, .length_trancomp_ext =1, - .addr_tx_bias =0x50, .page_tx_bias =-1, .offset_tx_bias =42, .length_tx_bias =8, - .addr_tx_disable =0x50, .page_tx_disable =-1, .offset_tx_disable =86, .length_tx_disable =1, - .addr_tx_eq =0x50, .page_tx_eq =3, .offset_tx_eq =234, .length_tx_eq =2, - .addr_tx_fault =0x50, .page_tx_fault =-1, .offset_tx_fault =4, .length_tx_fault =1, - .addr_tx_power =0x50, .page_tx_power =-1, .offset_tx_power =50, .length_tx_power =8, - .addr_vendor_name =0x50, .page_vendor_name =0, .offset_vendor_name =148, .length_vendor_name =16, - .addr_vendor_pn =0x50, .page_vendor_pn =0, .offset_vendor_pn =168, .length_vendor_pn =16, - .addr_vendor_rev =0x50, .page_vendor_rev =0, .offset_vendor_rev =184, .length_vendor_rev =2, - .addr_vendor_sn =0x50, .page_vendor_sn =0, .offset_vendor_sn =196, .length_vendor_sn =16, - .addr_voltage =0x50, .page_voltage =-1, .offset_voltage =26, .length_voltage =2, - .addr_wavelength =0x50, .page_wavelength =0, .offset_wavelength =186, .length_wavelength =2, -}; - - -/* ========== Utility Functions ========== - */ -static int -get_bit(uint8_t origin_byte, int bit_shift) { - return (int)((origin_byte >> bit_shift) & 0x1); -} - -static int -transform_word_to_int(uint8_t hight_byte, - uint8_t low_byte) { - return ((((int)hight_byte) << 8) + (int)low_byte); -} - -void -alarm_msg_2_user(struct transvr_obj_s *self, - char *emsg) { - - SWPS_ERR("%s on %s.\n", emsg, self->swp_name); -} -EXPORT_SYMBOL(alarm_msg_2_user); - -/* ========== Private functions ========== - */ -static int -_reload_transvr_obj(struct transvr_obj_s *self,int new_type); - -static int -reload_transvr_obj(struct transvr_obj_s *self,int new_type); - -static int -_is_transvr_support_ctle(struct transvr_obj_s *self); - -static int -_transvr_init_handler(struct transvr_obj_s *self); - -int -_transvr_clean_handler(struct transvr_obj_s *self); - -int -_sfp_detect_class_by_1g_ethernet(struct transvr_obj_s* self); - - -void -lock_transvr_obj(struct transvr_obj_s *self) { - - mutex_lock(&self->lock); - self->curr_page = VAL_TRANSVR_PAGE_FREE; -} -EXPORT_SYMBOL(lock_transvr_obj); - - -void -unlock_transvr_obj(struct transvr_obj_s *self) { - - self->curr_page = VAL_TRANSVR_PAGE_FREE; - mutex_unlock(&self->lock); -} -EXPORT_SYMBOL(unlock_transvr_obj); - - -static int -_check_by_mode(struct transvr_obj_s *self, - int (*attr_update_func)(struct transvr_obj_s *self, int show_err), - char *caller_name){ - - int return_val = ERR_TRANSVR_UNEXCPT; - - switch (self->mode){ - case TRANSVR_MODE_POLLING: - switch (self->state){ - case STATE_TRANSVR_CONNECTED: - goto ok_check_by_mode_1; - case STATE_TRANSVR_NEW: - case STATE_TRANSVR_INIT: - return ERR_TRANSVR_UNINIT; - case STATE_TRANSVR_DISCONNECTED: - return ERR_TRANSVR_UNPLUGGED; - case STATE_TRANSVR_UNEXCEPTED: - return ERR_TRANSVR_ABNORMAL; - case STATE_TRANSVR_ISOLATED: - return ERR_TRNASVR_BE_ISOLATED; - default: - goto err_check_by_mode_1; - } - goto ok_check_by_mode_1; - - case TRANSVR_MODE_DIRECT: - return_val = self->fsm_4_direct(self, caller_name); - if (return_val < 0){ - return return_val; - } - goto ok_check_by_mode_1; - - default: - goto err_check_by_mode_1; - } - goto ok_check_by_mode_1; - -ok_check_by_mode_1: - return attr_update_func(self, 0); - -err_check_by_mode_1: - SWPS_INFO("_check_by_mode: mode:%d state:%d\n", self->mode, self->state); - return ERR_TRANSVR_UNEXCPT; -} - - -static void -_transvr_clean_retry(struct transvr_obj_s *self) { - self->retry = 0; -} - - -static int -_transvr_handle_retry(struct transvr_obj_s *self, int retry) { - /* Return: 0: keep retry - * -1: stop retry - */ - if (self->retry == 0) { - self->retry = retry; - } - self->retry -= 1; - if (self->retry <= 0) { - _transvr_clean_retry(self); - return -1; - } - return 0; -} - - -static int -_common_setup_page(struct transvr_obj_s *self, - int addr, - int page, - int offset, - int len, - int show_e) { - /* return: - * 0 : OK - * -1 : EEPROM settings incorrect - * -2 : I2C R/W failure - * -3 : Undefined case - */ - int retval = DEBUG_TRANSVR_INT_VAL; - char *emsg = DEBUG_TRANSVR_STR_VAL; - - /* Check */ - if ((addr < 0) || (offset < 0) || (len < 0)) { - emsg = "EEPROM settings incorrect"; - retval = -1; - goto err_common_setup_page; - } - /* Case1: continue access */ - if ((self->i2c_client_p->addr == addr) && - (self->curr_page == page)) { - return 0; - } - self->i2c_client_p->addr = addr; - /* Case2: select lower page */ - if (page == -1) { - self->curr_page = page; - return 0; - } - /* Case3: select upper page */ - if (page >= 0) { - goto upper_common_setup_page; - } - /* Unexpected case */ - show_e = 1; - emsg = "Unexpected case"; - retval = -3; - goto err_common_setup_page; - -upper_common_setup_page: - if (i2c_smbus_write_byte_data(self->i2c_client_p, - VAL_TRANSVR_PAGE_SELECT_OFFSET, - page) < 0) { - emsg = "I2C R/W failure"; - retval = -2; - goto err_common_setup_page; - } - self->curr_page = page; - mdelay(VAL_TRANSVR_PAGE_SELECT_DELAY); - return 0; - -err_common_setup_page: - if (show_e) { - SWPS_INFO("%s: %s", __func__, emsg); - SWPS_INFO("%s: :0x%02x :%d :%d :%d\n", - __func__, addr, page, offset, len); - } - return retval; -} - -/* -static int -_common_setup_password(struct transvr_obj_s *self, - int addr, - int page, - int offs, - uint8_t pwd[4], - int show_e) { - int i = 0; - int err = DEBUG_TRANSVR_INT_VAL; - char *emsg = DEBUG_TRANSVR_STR_VAL; - - err = _common_setup_page(self, addr, page, offs, 4, show_e); - if (err < 0){ - emsg = "setup EEPROM page fail"; - goto err_common_setup_password; - } - for (i=0; i<4; i++) { - err = i2c_smbus_write_byte_data(self->i2c_client_p, - (offs + i), - pwd[i]); - if (err < 0){ - emsg = "I2C R/W fail!"; - goto err_common_setup_password; - } - } - return 0; - -err_common_setup_password: - if (show_e) { - SWPS_INFO("%s: %s :%d\n", __func__, emsg, err); - } - return ERR_TRANSVR_UPDATE_FAIL; -} -*/ - -static int -_common_update_uint8_attr(struct transvr_obj_s *self, - int addr, - int page, - int offset, - int len, - uint8_t *buf, - char *caller, - int show_e){ - - int i; - int err = DEBUG_TRANSVR_INT_VAL; - char *emsg = DEBUG_TRANSVR_STR_VAL; - - err = _common_setup_page(self, addr, page, offset, len, show_e); - if (err < 0){ - emsg = "setup EEPROM page fail"; - goto err_common_update_uint8_attr; - } - for (i=0; ii2c_client_p, (offset + i)); - if (err < 0){ - emsg = "I2C R/W fail!"; - goto err_common_update_uint8_attr; - } - buf[i] = err; - } - return 0; - -err_common_update_uint8_attr: - if (show_e) { - SWPS_INFO("%s: %s :%s :%d\n", - __func__, emsg, caller, err); - } - buf[0] = DEBUG_TRANSVR_HEX_VAL; - return ERR_TRANSVR_UPDATE_FAIL; -} - - -static int -_common_update_int_attr(struct transvr_obj_s *self, - int addr, - int page, - int offset, - int len, - int *buf, - char *caller, - int show_e){ - - int i; - int err = DEBUG_TRANSVR_INT_VAL; - char *emsg = DEBUG_TRANSVR_STR_VAL; - - err = _common_setup_page(self, addr, page, offset, len, show_e); - if (err < 0){ - emsg = "setup EEPROM page fail"; - goto err_common_update_int_attr; - } - for (i=0; ii2c_client_p, (offset + i)); - if (err < 0){ - emsg = "I2C R/W fail!"; - goto err_common_update_int_attr; - } - buf[i] = (int)err; - } - return 0; - -err_common_update_int_attr: - if (show_e) { - SWPS_INFO("%s: %s :%s :%d\n", - __func__, emsg, caller, err); - } - buf[0] = DEBUG_TRANSVR_INT_VAL; - return ERR_TRANSVR_UPDATE_FAIL; -} - - -static int -_common_update_string_attr(struct transvr_obj_s *self, - int addr, - int page, - int offset, - int len, - char buf[], - char *caller, - int show_e){ - - int i; - int err = DEBUG_TRANSVR_INT_VAL; - char *emsg = DEBUG_TRANSVR_STR_VAL; - - err = _common_setup_page(self, addr, page, offset, len, show_e); - if (err < 0){ - emsg = "setup EEPROM page fail"; - goto err_common_update_string_attr; - } - for (i=0; ii2c_client_p, (offset + i)); - if (err < 0){ - emsg = "I2C R/W fail!"; - goto err_common_update_string_attr; - } - buf[i] = (char)err; - } - return 0; - -err_common_update_string_attr: - if (show_e) { - SWPS_INFO("%s: %s :%s :%d\n", - __func__, emsg, caller, err); - } - buf[0] = 'e'; - return ERR_TRANSVR_UPDATE_FAIL; -} - - -static int -_common_set_uint8_attr(struct transvr_obj_s *self, - int addr, - int page, - int offset, - uint8_t update, - uint8_t *buf, - char *caller, - int show_e){ - int len = 1; - int err = DEBUG_TRANSVR_INT_VAL; - char *emsg = DEBUG_TRANSVR_STR_VAL; - - if ((*buf) == update){ - return 0; - } - err = _common_setup_page(self, addr, page, offset, len, show_e); - if (err < 0){ - emsg = "setup EEPROM page fail"; - goto err_common_set_uint8_attr_1; - } - err = i2c_smbus_write_byte_data(self->i2c_client_p, - offset, - update); - if (err < 0){ - emsg = "I2C R/W fail!"; - goto err_common_set_uint8_attr_1; - } - (*buf) = update; - return 0; - -err_common_set_uint8_attr_1: - if (show_e) { - SWPS_INFO("%s: %s :%s :%d\n", - __func__, emsg, caller, err); - } - return ERR_TRANSVR_UPDATE_FAIL; -} - - -static int -_common_set_uint8_array(struct transvr_obj_s *self, - int addr, - int page, - int offs, - int len, - uint8_t update[], - uint8_t buf[], - char *caller, - int show_e){ - int i = 0; - int err = DEBUG_TRANSVR_INT_VAL; - char *emsg = DEBUG_TRANSVR_STR_VAL; - - err = _common_setup_page(self, addr, page, offs, len, show_e); - if (err < 0){ - emsg = "setup EEPROM page fail"; - goto err_common_set_uint8_attr_1; - } - for (i=0; ii2c_client_p, - (offs + i), - update[i]); - if (err < 0){ - emsg = "I2C R/W fail!"; - goto err_common_set_uint8_attr_1; - } - buf[i] = update[i]; - } - return 0; - -err_common_set_uint8_attr_1: - if (show_e) { - SWPS_INFO("%s: %s :%s :%d :%d\n", - __func__, emsg, caller, err, i); - } - return ERR_TRANSVR_UPDATE_FAIL; -} - - -static int -_common_update_attr_id(struct transvr_obj_s *self, - int show_err){ - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_id, - self->eeprom_map_p->page_id, - self->eeprom_map_p->offset_id, - self->eeprom_map_p->length_id, - &(self->id), - "_common_update_attr_id", - show_err); -} - - -static int -_common_update_attr_extended_id(struct transvr_obj_s *self, - int show_err){ - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_ext_id, - self->eeprom_map_p->page_ext_id, - self->eeprom_map_p->offset_ext_id, - self->eeprom_map_p->length_ext_id, - &(self->ext_id), - "_common_update_attr_extended_id", - show_err); -} - - -static int -_common_update_attr_connector(struct transvr_obj_s *self, - int show_err){ - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_connector, - self->eeprom_map_p->page_connector, - self->eeprom_map_p->offset_connector, - self->eeprom_map_p->length_connector, - &(self->connector), - "_common_update_attr_connector", - show_err); -} - - -static int -_common_update_attr_transvr_comp(struct transvr_obj_s *self, - int show_err){ - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_trancomp, - self->eeprom_map_p->page_trancomp, - self->eeprom_map_p->offset_trancomp, - self->eeprom_map_p->length_trancomp, - self->transvr_comp, - "_common_update_attr_transvr_comp", - show_err); -} - - -static int -_common_update_attr_transvr_comp_ext(struct transvr_obj_s *self, - int show_err){ - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_trancomp_ext, - self->eeprom_map_p->page_trancomp_ext, - self->eeprom_map_p->offset_trancomp_ext, - self->eeprom_map_p->length_trancomp_ext, - &(self->transvr_comp_ext), - "_common_update_attr_transvr_comp_ext", - show_err); -} - - -static int -_common_update_attr_vendor_name(struct transvr_obj_s *self, - int show_err){ - return _common_update_string_attr(self, - self->eeprom_map_p->addr_vendor_name, - self->eeprom_map_p->page_vendor_name, - self->eeprom_map_p->offset_vendor_name, - self->eeprom_map_p->length_vendor_name, - self->vendor_name, - "_common_update_attr_vendor_name", - show_err); -} - - -static int -_common_update_attr_vendor_pn(struct transvr_obj_s *self, - int show_err){ - return _common_update_string_attr(self, - self->eeprom_map_p->addr_vendor_pn, - self->eeprom_map_p->page_vendor_pn, - self->eeprom_map_p->offset_vendor_pn, - self->eeprom_map_p->length_vendor_pn, - self->vendor_pn, - "_common_update_attr_vendor_pn", - show_err); -} - - -static int -_common_update_attr_vendor_rev(struct transvr_obj_s *self, - int show_err){ - return _common_update_string_attr(self, - self->eeprom_map_p->addr_vendor_rev, - self->eeprom_map_p->page_vendor_rev, - self->eeprom_map_p->offset_vendor_rev, - self->eeprom_map_p->length_vendor_rev, - self->vendor_rev, - "_common_update_attr_vendor_rev", - show_err); -} - - -static int -_common_update_attr_vendor_sn(struct transvr_obj_s *self, - int show_err){ - return _common_update_string_attr(self, - self->eeprom_map_p->addr_vendor_sn, - self->eeprom_map_p->page_vendor_sn, - self->eeprom_map_p->offset_vendor_sn, - self->eeprom_map_p->length_vendor_sn, - self->vendor_sn, - "_common_update_attr_vendor_sn", - show_err); -} - - -static int -_common_update_attr_br(struct transvr_obj_s *self, - int show_err){ - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_br, - self->eeprom_map_p->page_br, - self->eeprom_map_p->offset_br, - self->eeprom_map_p->length_br, - &(self->br), - "_common_update_attr_br", - show_err); -} - - -static int -_common_update_attr_len_smf(struct transvr_obj_s *self, - int show_err){ - return _common_update_int_attr(self, - self->eeprom_map_p->addr_len_smf, - self->eeprom_map_p->page_len_smf, - self->eeprom_map_p->offset_len_smf, - self->eeprom_map_p->length_len_smf, - &(self->len_smf), - "_common_update_attr_len_smf", - show_err); -} - - -static int -_common_update_attr_len_om1(struct transvr_obj_s *self, - int show_err){ - return _common_update_int_attr(self, - self->eeprom_map_p->addr_len_om1, - self->eeprom_map_p->page_len_om1, - self->eeprom_map_p->offset_len_om1, - self->eeprom_map_p->length_len_om1, - &(self->len_om1), - "_common_update_attr_len_om1", - show_err); -} - -static int -_common_update_attr_len_om2(struct transvr_obj_s *self, - int show_err){ - return _common_update_int_attr(self, - self->eeprom_map_p->addr_len_om2, - self->eeprom_map_p->page_len_om2, - self->eeprom_map_p->offset_len_om2, - self->eeprom_map_p->length_len_om2, - &(self->len_om2), - "_common_update_attr_len_om2", - show_err); -} - -static int -_common_update_attr_len_om3(struct transvr_obj_s *self, - int show_err){ - return _common_update_int_attr(self, - self->eeprom_map_p->addr_len_om3, - self->eeprom_map_p->page_len_om3, - self->eeprom_map_p->offset_len_om3, - self->eeprom_map_p->length_len_om3, - &(self->len_om3), - "_common_update_attr_len_om3", - show_err); -} - - -static int -_common_update_attr_len_om4(struct transvr_obj_s *self, - int show_err){ - return _common_update_int_attr(self, - self->eeprom_map_p->addr_len_om4, - self->eeprom_map_p->page_len_om4, - self->eeprom_map_p->offset_len_om4, - self->eeprom_map_p->length_len_om4, - &(self->len_om4), - "_common_update_attr_len_om4", - show_err); -} - - -static int -_common_update_attr_option(struct transvr_obj_s *self, - int show_err){ - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_option, - self->eeprom_map_p->page_option, - self->eeprom_map_p->offset_option, - self->eeprom_map_p->length_option, - self->option, - "_common_update_attr_option", - show_err); -} - - -static int -_common_update_attr_comp_rev(struct transvr_obj_s *self, - int show_err){ - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_comp_rev, - self->eeprom_map_p->page_comp_rev, - self->eeprom_map_p->offset_comp_rev, - self->eeprom_map_p->length_comp_rev, - &(self->comp_rev), - "_common_update_attr_comp_rev", - show_err); -} - - -static int -_common_update_attr_diag_type(struct transvr_obj_s *self, - int show_err){ - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_diag_type, - self->eeprom_map_p->page_diag_type, - self->eeprom_map_p->offset_diag_type, - self->eeprom_map_p->length_diag_type, - &(self->diag_type), - "_common_update_attr_diag_type", - show_err); -} - - -static int -_common_update_attr_wavelength(struct transvr_obj_s *self, - int show_err){ - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_wavelength, - self->eeprom_map_p->page_wavelength, - self->eeprom_map_p->offset_wavelength, - self->eeprom_map_p->length_wavelength, - self->wavelength, - "_common_update_attr_wavelength", - show_err); -} - - -int -_common_get_option_value(struct transvr_obj_s *self, - int offset, - int bit_shift) { - /* SFP: - * - option[0] = A0h / 64 - * - option[1] = A0h / 65 - * QSFP: - * - option[0] = 00h / 193 - * - option[1] = 00h / 194 - * - option[2] = 00h / 195 - */ - return (self->option[offset] & (1 << bit_shift)); -} - - -static int -_sfp_update_attr_len_sm(struct transvr_obj_s *self, - int show_err){ - return _common_update_int_attr(self, - self->eeprom_map_p->addr_len_sm, - self->eeprom_map_p->page_len_sm, - self->eeprom_map_p->offset_len_sm, - self->eeprom_map_p->length_len_sm, - &(self->len_sm), - "_common_update_attr_len_sm", - show_err); -} - - -static int -_sfp_update_attr_rate_id(struct transvr_obj_s *self, - int show_err){ - return _common_update_int_attr(self, - self->eeprom_map_p->addr_rate_id, - self->eeprom_map_p->page_rate_id, - self->eeprom_map_p->offset_rate_id, - self->eeprom_map_p->length_rate_id, - &(self->rate_id), - "_sfp_update_attr_rate_id", - show_err); -} - - -static int -_sfp_update_attr_soft_rs0(struct transvr_obj_s *self, - int show_err){ - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_soft_rs0, - self->eeprom_map_p->page_soft_rs0, - self->eeprom_map_p->offset_soft_rs0, - self->eeprom_map_p->length_soft_rs0, - &(self->soft_rs0), - "_sfp_update_attr_soft_rs0", - show_err); -} - - -static int -_sfp_update_attr_soft_rs1(struct transvr_obj_s *self, - int show_err){ - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_soft_rs1, - self->eeprom_map_p->page_soft_rs1, - self->eeprom_map_p->offset_soft_rs1, - self->eeprom_map_p->length_soft_rs1, - &(self->soft_rs1), - "_sfp_update_attr_soft_rs1", - show_err); -} - - -int -_sfp_is_diag_support(struct transvr_obj_s *self){ - - uint8_t bit_mask = 0xC0; /* 1100 0000 */ - uint8_t en_val = 0x40; /* 0100 0000 */ - uint8_t checkval = (self->diag_type & bit_mask); - - if (checkval == en_val) { - return 1; - } - return 0; -} - - -static int -_sfp_update_attr_curr_temp(struct transvr_obj_s *self, - int show_err){ - - if (!(_sfp_is_diag_support(self))) { - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_temp, - self->eeprom_map_p->page_temp, - self->eeprom_map_p->offset_temp, - self->eeprom_map_p->length_temp, - self->curr_temp, - "_sfp_update_attr_curr_temp", - show_err); -} - - -static int -_sfp_update_attr_curr_voltage(struct transvr_obj_s *self, - int show_err){ - - if (!(_sfp_is_diag_support(self))) { - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_voltage, - self->eeprom_map_p->page_voltage, - self->eeprom_map_p->offset_voltage, - self->eeprom_map_p->length_voltage, - self->curr_voltage, - "_sfp_update_attr_curr_voltage", - show_err); -} - - -static int -_sfp_update_attr_curr_tx_bias(struct transvr_obj_s *self, - int show_err){ - - if (!(_sfp_is_diag_support(self))) { - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_tx_bias, - self->eeprom_map_p->page_tx_bias, - self->eeprom_map_p->offset_tx_bias, - self->eeprom_map_p->length_tx_bias, - self->curr_tx_bias, - "_sfp_update_attr_curr_tx_bias", - show_err); -} - - -static int -_sfp_update_attr_curr_tx_power(struct transvr_obj_s *self, - int show_err){ - - if (!(_sfp_is_diag_support(self))) { - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_tx_power, - self->eeprom_map_p->page_tx_power, - self->eeprom_map_p->offset_tx_power, - self->eeprom_map_p->length_tx_power, - self->curr_tx_power, - "_sfp_update_attr_curr_tx_power", - show_err); -} - - -static int -_sfp_update_attr_curr_rx_power(struct transvr_obj_s *self, - int show_err){ - - if (!(_sfp_is_diag_support(self))) { - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_rx_power, - self->eeprom_map_p->page_rx_power, - self->eeprom_map_p->offset_rx_power, - self->eeprom_map_p->length_rx_power, - self->curr_rx_power, - "_sfp_update_attr_curr_rx_power", - show_err); -} - - -static int -_sfp_update_attr_rx_em(struct transvr_obj_s *self, - int show_err){ - - if (!_is_transvr_support_ctle(self)) { - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_rx_em, - self->eeprom_map_p->page_rx_em, - self->eeprom_map_p->offset_rx_em, - self->eeprom_map_p->length_rx_em, - self->rx_em, - "_sfp_update_attr_rx_em", - show_err); -} - - -static int -_sfp_update_attr_tx_eq(struct transvr_obj_s *self, - int show_err){ - - if (!_is_transvr_support_ctle(self)) { - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_tx_eq, - self->eeprom_map_p->page_tx_eq, - self->eeprom_map_p->offset_tx_eq, - self->eeprom_map_p->length_tx_eq, - self->tx_eq, - "_sfp_update_attr_tx_eq", - show_err); -} - - -static int -_qsfp_update_attr_cdr(struct transvr_obj_s *self, - int show_err){ - if (self->type != TRANSVR_TYPE_QSFP_28){ - self->cdr = DEBUG_TRANSVR_HEX_VAL; - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_cdr, - self->eeprom_map_p->page_cdr, - self->eeprom_map_p->offset_cdr, - self->eeprom_map_p->length_cdr, - &(self->cdr), - "_common_update_attr_cdr", - show_err); -} - - -static int -_qsfg_update_attr_extbr(struct transvr_obj_s *self, - int show_err) { - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_extbr, - self->eeprom_map_p->page_extbr, - self->eeprom_map_p->offset_extbr, - self->eeprom_map_p->length_extbr, - &(self->extbr), - "_common_update_attr_extbr", - show_err); -} - - -static int -_qsfp_is_diag_support(struct transvr_obj_s *self, - int diag_type) { - /* Input Parm: diag_type - * => 1 : temperature - * => 2 : voltage - * => 3 : tx relate - * => 4 : rx relate - */ - uint8_t mask_b2 = 0x04; /* 0000 0100 */ - uint8_t mask_b3 = 0x08; /* 0000 1000 */ - - switch (diag_type) { - case 1: /* temperature */ - case 2: /* voltage */ - /* Direct access target, because of spec not defined */ - return 1; - case 3: - case 4: - /* [Note] - * Due to lot of transceiver vendor defined it not rigorously and - * consider of general support, we seem it as supported if there - * are bit-2 OR bit-3 defined by transceiver vendor. - */ - if ( ((self->diag_type & mask_b2) == mask_b2 ) || - ((self->diag_type & mask_b3) == mask_b3 ) ){ - return 1; - } - return 0; - default: - SWPS_INFO("%s: undefined diag_type:%d\n", - __func__, diag_type); - break; - } - return 0; -} - - -int -_qsfp_is_implement_tx_disable(struct transvr_obj_s *self) { - /* - * 00h / Byte-195 / Bit-4 - */ - int byte = 2; - int bit = 4; - return _common_get_option_value(self, byte, bit); -} - - -int -_qsfp_is_implement_tx_fault(struct transvr_obj_s *self) { - /* - * 00h / Byte-195 / Bit-3 - */ - int byte = 2; - int bit = 3; - return _common_get_option_value(self, byte, bit); -} - - -static int -_qsfp_update_attr_curr_temp(struct transvr_obj_s *self, - int show_err){ - int diag_type = 1; - - if (!(_qsfp_is_diag_support(self, diag_type))) { - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_temp, - self->eeprom_map_p->page_temp, - self->eeprom_map_p->offset_temp, - self->eeprom_map_p->length_temp, - self->curr_temp, - "_qsfp_update_attr_curr_temp", - show_err); -} - - -static int -_qsfp_update_attr_curr_voltage(struct transvr_obj_s *self, - int show_err){ - int diag_type = 2; - - if (!(_qsfp_is_diag_support(self, diag_type))) { - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_voltage, - self->eeprom_map_p->page_voltage, - self->eeprom_map_p->offset_voltage, - self->eeprom_map_p->length_voltage, - self->curr_voltage, - "_qsfp_update_attr_curr_voltage", - show_err); -} - - -static int -_qsfp_update_attr_curr_tx_bias(struct transvr_obj_s *self, - int show_err){ - int diag_type = 3; - - if (!(_qsfp_is_diag_support(self, diag_type))) { - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_tx_bias, - self->eeprom_map_p->page_tx_bias, - self->eeprom_map_p->offset_tx_bias, - self->eeprom_map_p->length_tx_bias, - self->curr_tx_bias, - "_qsfp_update_attr_curr_tx_bias", - show_err); -} - - -static int -_qsfp_update_attr_curr_tx_power(struct transvr_obj_s *self, - int show_err){ - int diag_type = 3; - - if (!(_qsfp_is_diag_support(self, diag_type))) { - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_tx_power, - self->eeprom_map_p->page_tx_power, - self->eeprom_map_p->offset_tx_power, - self->eeprom_map_p->length_tx_power, - self->curr_tx_power, - "_qsfp_update_attr_curr_tx_power", - show_err); -} - - -static int -_qsfp_update_attr_curr_rx_power(struct transvr_obj_s *self, - int show_err){ - int diag_type = 4; - - if (!(_qsfp_is_diag_support(self, diag_type))) { - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_rx_power, - self->eeprom_map_p->page_rx_power, - self->eeprom_map_p->offset_rx_power, - self->eeprom_map_p->length_rx_power, - self->curr_rx_power, - "_qsfp_update_attr_curr_rx_power", - show_err); -} - - -static int -_qsfp_update_attr_soft_rx_los(struct transvr_obj_s *self, - int show_err){ - - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_rx_los, - self->eeprom_map_p->page_rx_los, - self->eeprom_map_p->offset_rx_los, - self->eeprom_map_p->length_rx_los, - &(self->rx_los), - "_qsfp_update_attr_soft_rx_los", - show_err); -} - - -static int -_qsfp_update_attr_soft_tx_disable(struct transvr_obj_s *self, - int show_err){ - - if (!_qsfp_is_implement_tx_disable(self)) { - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_tx_disable, - self->eeprom_map_p->page_tx_disable, - self->eeprom_map_p->offset_tx_disable, - self->eeprom_map_p->length_tx_disable, - &(self->tx_disable), - "_qsfp_update_attr_soft_tx_disable", - show_err); -} - - -static int -_qsfp_update_attr_soft_tx_fault(struct transvr_obj_s *self, - int show_err){ - - if (!_qsfp_is_implement_tx_fault(self)) { - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_tx_fault, - self->eeprom_map_p->page_tx_fault, - self->eeprom_map_p->offset_tx_fault, - self->eeprom_map_p->length_tx_fault, - &(self->tx_fault), - "_qsfp_update_attr_soft_tx_fault", - show_err); -} - - -static int -_qsfp_update_attr_tx_eq(struct transvr_obj_s *self, - int show_err){ - - if (!_is_transvr_support_ctle(self)) { - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_tx_eq, - self->eeprom_map_p->page_tx_eq, - self->eeprom_map_p->offset_tx_eq, - self->eeprom_map_p->length_tx_eq, - self->tx_eq, - "_qsfp_update_attr_tx_eq", - show_err); -} - - -static int -_qsfp_update_attr_rx_am(struct transvr_obj_s *self, - int show_err){ - - if (!_is_transvr_support_ctle(self)) { - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_rx_am, - self->eeprom_map_p->page_rx_am, - self->eeprom_map_p->offset_rx_am, - self->eeprom_map_p->length_rx_am, - self->rx_am, - "_qsfp_update_attr_rx_am", - show_err); -} - - -static int -_qsfp_update_attr_rx_em(struct transvr_obj_s *self, - int show_err){ - - if (!_is_transvr_support_ctle(self)) { - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_rx_em, - self->eeprom_map_p->page_rx_em, - self->eeprom_map_p->offset_rx_em, - self->eeprom_map_p->length_rx_em, - self->rx_em, - "_qsfp_update_attr_rx_em", - show_err); -} - - -int -_common_update_attr_all(struct transvr_obj_s *self, - int show_err){ - - char *err_str = "err"; - - if (_common_update_attr_id(self, show_err) < 0) { - err_str = "_common_update_attr_id"; - goto err_common_update_attr_all; - } - if (_common_update_attr_extended_id(self, show_err) < 0) { - err_str = "_common_update_attr_extended_id"; - goto err_common_update_attr_all; - } - if (_common_update_attr_connector(self, show_err) < 0) { - err_str = "_common_update_attr_connector"; - goto err_common_update_attr_all; - } - if (_common_update_attr_transvr_comp(self, show_err) < 0) { - err_str = "_common_update_attr_transvr_comp"; - goto err_common_update_attr_all; - } - if (_common_update_attr_transvr_comp_ext(self, show_err) < 0) { - err_str = "_common_update_attr_transvr_comp_ext"; - goto err_common_update_attr_all; - } - if (_common_update_attr_vendor_name(self, show_err) < 0) { - err_str = "_common_update_attr_vendor_name"; - goto err_common_update_attr_all; - } - if (_common_update_attr_vendor_pn(self, show_err) < 0) { - err_str = "_common_update_attr_vendor_pn"; - goto err_common_update_attr_all; - } - if (_common_update_attr_vendor_rev(self, show_err) < 0) { - err_str = "_common_update_attr_vendor_rev"; - goto err_common_update_attr_all; - } - if (_common_update_attr_vendor_sn(self, show_err) < 0) { - err_str = "_common_update_attr_vendor_sn"; - goto err_common_update_attr_all; - } - if (_common_update_attr_br(self, show_err) < 0) { - err_str = "_common_update_attr_br"; - goto err_common_update_attr_all; - } - if (_common_update_attr_len_smf(self, show_err) < 0) { - err_str = "_common_update_attr_len_smf"; - goto err_common_update_attr_all; - } - if (_common_update_attr_len_om1(self, show_err) < 0) { - err_str = "_common_update_attr_len_om1"; - goto err_common_update_attr_all; - } - if (_common_update_attr_len_om2(self, show_err) < 0) { - err_str = "_common_update_attr_len_om2"; - goto err_common_update_attr_all; - } - if (_common_update_attr_len_om3(self, show_err) < 0) { - err_str = "_common_update_attr_len_om3"; - goto err_common_update_attr_all; - } - if (_common_update_attr_len_om4(self, show_err) < 0) { - err_str = "_common_update_attr_len_om4"; - goto err_common_update_attr_all; - } - if (_common_update_attr_option(self, show_err) < 0) { - err_str = "_common_update_attr_option"; - goto err_common_update_attr_all; - } - if (_common_update_attr_comp_rev(self, show_err) < 0) { - err_str = "_common_update_attr_comp_rev"; - goto err_common_update_attr_all; - } - if (_common_update_attr_diag_type(self, show_err) < 0) { - err_str = "_common_update_attr_diag_type"; - goto err_common_update_attr_all; - } - if (_common_update_attr_wavelength(self, show_err) < 0) { - err_str = "_common_update_attr_wavelength"; - goto err_common_update_attr_all; - } - return 0; - -err_common_update_attr_all: - if (show_err){ - SWPS_INFO("%s: fail at:%s :%s\n", __func__, err_str, self->swp_name); - } - return -1; -} - - -int -_sfp_update_attr_all(struct transvr_obj_s *self, - int show_err){ - - char *err_str = DEBUG_TRANSVR_STR_VAL; - - if (_common_update_attr_all(self, show_err) < 0){ - err_str = "_common_update_attr_all"; - goto err_sfp_update_attr_all; - } - if (_sfp_update_attr_len_sm(self, show_err) < 0) { - err_str = "_sfp_update_attr_len_sm"; - goto err_sfp_update_attr_all; - } - if (_sfp_update_attr_rate_id(self, show_err) < 0) { - err_str = "_sfp_update_attr_rate_id"; - goto err_sfp_update_attr_all; - } - if ((self->rate_id) > 0) { - if (_sfp_update_attr_soft_rs0(self, show_err) < 0) { - err_str = "_sfp_update_attr_soft_rs0"; - goto err_sfp_update_attr_all; - } - if (_sfp_update_attr_soft_rs1(self, show_err) < 0) { - err_str = "_sfp_update_attr_soft_rs1"; - goto err_sfp_update_attr_all; - } - } - return 0; - -err_sfp_update_attr_all: - if (show_err){ - SWPS_INFO("%s: fail at:%s :%s\n", __func__, err_str, self->swp_name); - } - return -1; -} - - -int -_qsfp_update_attr_all(struct transvr_obj_s *self, - int show_err){ - - char *err_str = DEBUG_TRANSVR_STR_VAL; - - if (_common_update_attr_all(self, show_err) < 0){ - err_str = "_common_update_attr_all"; - goto err_qsfp_update_attr_all; - } - if (_qsfg_update_attr_extbr(self, show_err) < 0) { - err_str = "_qsfg_update_attr_extbr"; - goto err_qsfp_update_attr_all; - } - if (self->type == TRANSVR_TYPE_QSFP_28) { - if (_qsfp_update_attr_cdr(self, 1) < 0) { - err_str = "_qsfp_update_attr_cdr"; - goto err_qsfp_update_attr_all; - } - } - return 0; - -err_qsfp_update_attr_all: - if (show_err){ - SWPS_INFO("%s: fail at:%s :%s\n", __func__, err_str, self->swp_name); - } - return -1; -} - - -/* ========== Object functions for common type ========== - */ -int -_common_count_temp(uint8_t high_byte, - uint8_t low_byte, - char *buf_p) { - int sign = 0; - int high = 0; - int low = 0; - int lmax = 8; - - /* Count high */ - sign = get_bit(high_byte,7); - SWP_BIT_CLEAR(high_byte, 7); - high = (int)high_byte; - if (sign == 1) { - high = 0 - high; - } - /* Count low */ - low = (get_bit(low_byte, 7) * 500); - low += (get_bit(low_byte, 6) * 250); - low += (get_bit(low_byte, 5) * 125); - low += (get_bit(low_byte, 4) * 62); - low = (low / 100); - /* Integrate High and Low */ - return snprintf(buf_p, lmax, "%d.%d\n", high, low); -} - - -int -_common_count_voltage(uint8_t high_byte, - uint8_t low_byte, - char *buf_p) { - /* [Note]: - * Internally measured transceiver supply voltage. Represented - * as a 16 bit unsigned integer with the voltage defined as the - * full 16 bit value (0-65535) with LSB equal to 100 uVolt, - * yielding a total range of 0 to +6.55 Volts. Practical - * considerations to be defined by transceiver manufacturer will - * tend to limit the actual bounds of the supply voltage measurement. - * Accuracy is vendor specific but must be better than 3% of the - * manufacturer's nominal value over specified operating temperature - * and voltage. Note that in some transceivers, transmitter supply - * voltage and receiver supply voltage are isolated. In that case, - * only one supply is monitored. Refer to the device specification - * for more detail. - */ - int total = 0; - int lmax = 8; - int val_i = 0; - int val_f = 0; - /* unit: 100 uV (1mV=1000uV) */ - total = transform_word_to_int(high_byte, low_byte); - val_i = ((total/10) / 1000); - val_f = ((total/10) - (val_i*1000)); - /* Return Unit: 1 Volt */ - return snprintf(buf_p, lmax, "%d.%03d\n", val_i, val_f); -} - - -int -_common_count_tx_bias(uint8_t high_byte, - uint8_t low_byte, - char *buf_p) { - /* [Note] - * Measured TX bias current in uA. Represented as a 16 bit unsigned - * integer with the current defined as the full 16 bit value (0-65535) - * with LSB equal to 2 uA, yielding a total range of 0 to 131 mA. - * Accuracy is vendor specific but must be better than 10% of the - * manufacturer's nominal value over specified operating temperature - * and voltage. - */ - int total = 0; - int lmax = 8; - int val_i = 0; - int val_f = 0; - /* unit: 2 uA (1mA=1000uA) */ - total = transform_word_to_int(high_byte, low_byte); - val_i = ((total*2) / 1000); - val_f = (((total*2) - (val_i*1000)) / 100); - /* Return Unit: 1 mA */ - return snprintf(buf_p, lmax, "%d.%01d\n", val_i, val_f); -} - - -int -_common_count_tx_power(uint8_t high_byte, - uint8_t low_byte, - char *buf_p) { - /* [Note] - * Measured TX output power in mW. Represented as a 16 bit unsigned - * integer with the power defined as the full 16 bit value (0-65535) - * with LSB equal to 0.1 uW, yielding a total range of 0 to 6.5535 mW - * (~ -40 to +8.2 dBm). Data is assumed to be based on measurement of - * laser monitor photodiode current. It is factory calibrated to absolute - * units using the most representative fiber output type. Accuracy is - * vendor specific but must be better than 3dB over specified temperature - * and voltage. Data is not valid when the transmitter is disabled. - */ - int total = 0; - int lmax = 8; - int val_i = 0; - int val_f = 0; - /* unit: 0.1 uW (1mW=1000uW) */ - total = transform_word_to_int(high_byte, low_byte); - val_i = ((total/10) / 1000); - val_f = ((total/10) - (val_i*1000)); - /* Return Unit: 1 mW */ - return snprintf(buf_p, lmax, "%d.%03d\n", val_i, val_f); -} - - -int -_common_count_rx_power(uint8_t high_byte, - uint8_t low_byte, - char *buf_p) { - /* [Note] - * Measured RX received optical power in mW. Value can represent either - * average received power or OMA depending upon how bit 3 of byte 92 (A0h) - * is set. Represented as a 16 bit unsigned integer with the power defined - * as the full 16 bit value (0-65535) with LSB equal to 0.1 uW, yielding a - * total range of 0 to 6.5535 mW (~ -40 to +8.2 dBm). Absolute accuracy is - * dependent upon the exact optical wavelength. For the vendor specified - * wavelength, accuracy shall be better than 3dB over specified temperature - * and voltage. - */ - int total = 0; - int lmax = 8; - int val_i = 0; - int val_f = 0; - /* unit: 0.1 uW (1mW=1000uW) */ - total = transform_word_to_int(high_byte, low_byte); - val_i = ((total/10) / 1000); - val_f = ((total/10) - (val_i*1000)); - /* Return Unit: 1 mW */ - return snprintf(buf_p, lmax, "%d.%03d\n", val_i, val_f); -} - - -int -_common_count_wavelength(struct transvr_obj_s *self, - uint8_t high_byte, - uint8_t low_byte) { - /* [Note] - * SFP : uint 1 um. - * QSFP: unit 0.05 um. - */ - int total = 0; - - total = transform_word_to_int(high_byte, low_byte); - switch (self->type) { - case TRANSVR_TYPE_SFP: - return total; - - case TRANSVR_TYPE_QSFP: - case TRANSVR_TYPE_QSFP_PLUS: - case TRANSVR_TYPE_QSFP_28: - return (total/20); - - default: - break; - } - return ERR_TRANSVR_UNDEFINED; -} - - -int -common_get_id(struct transvr_obj_s *self){ - - int err_code = _check_by_mode(self, - &_common_update_attr_id, - "common_get_id"); - if (err_code < 0){ - return err_code; - } - /* Transform to INT to show error case */ - return (int)self->id; -} - - -int -common_get_ext_id(struct transvr_obj_s *self){ - - int err_code = _check_by_mode(self, - &_common_update_attr_extended_id, - "common_get_ext_id"); - if (err_code < 0){ - return err_code; - } - /* Transform to INT to show error case */ - return (int)self->ext_id; -} - - -int -common_get_connector(struct transvr_obj_s *self){ - - int err_code = _check_by_mode(self, - &_common_update_attr_connector, - "common_get_connector"); - if (err_code < 0){ - return err_code; - } - /* Transform to INT to show error case */ - return (int)self->connector; -} - - -int -common_get_vendor_name(struct transvr_obj_s *self, char *buf){ - - int err = DEBUG_TRANSVR_INT_VAL; - - if (self->state == STATE_TRANSVR_CONNECTED && - self->mode == TRANSVR_MODE_POLLING && - TRANSVR_INFO_CACHE_ENABLE) { - return snprintf(buf, LEN_TRANSVR_M_STR, "%s\n", self->vendor_name); - } - err = _check_by_mode(self, - &_common_update_attr_vendor_name, - "common_get_vendor_name"); - memset(buf, 0, LEN_TRANSVR_M_STR); - if (err < 0){ - return snprintf(buf, LEN_TRANSVR_M_STR, "%d\n", err); - } - return snprintf(buf, LEN_TRANSVR_M_STR, "%s\n", self->vendor_name); -} - - -int -common_get_vendor_pn(struct transvr_obj_s *self, char *buf) { - - int err = DEBUG_TRANSVR_INT_VAL; - - if (self->state == STATE_TRANSVR_CONNECTED && - self->mode == TRANSVR_MODE_POLLING && - TRANSVR_INFO_CACHE_ENABLE) { - return snprintf(buf, LEN_TRANSVR_M_STR, "%s\n", self->vendor_pn); - } - err = _check_by_mode(self, - &_common_update_attr_vendor_pn, - "common_get_vendor_pn"); - memset(buf, 0, LEN_TRANSVR_M_STR); - if (err < 0){ - return snprintf(buf, LEN_TRANSVR_M_STR, "%d\n", err); - } - return snprintf(buf, LEN_TRANSVR_M_STR, "%s\n", self->vendor_pn); -} - - -int -common_get_vendor_rev(struct transvr_obj_s *self, char *buf) { - - int err = DEBUG_TRANSVR_INT_VAL; - - if (self->state == STATE_TRANSVR_CONNECTED && - self->mode == TRANSVR_MODE_POLLING && - TRANSVR_INFO_CACHE_ENABLE) { - return snprintf(buf, LEN_TRANSVR_M_STR, "%s\n", self->vendor_rev); - } - err = _check_by_mode(self, - &_common_update_attr_vendor_rev, - "common_get_vendor_rev"); - memset(buf, 0, LEN_TRANSVR_M_STR); - if (err < 0){ - return snprintf(buf, LEN_TRANSVR_M_STR, "%d\n", err); - } - return snprintf(buf, LEN_TRANSVR_M_STR, "%s\n", self->vendor_rev); -} - - -int -common_get_vendor_sn(struct transvr_obj_s *self, char *buf) { - - int err = DEBUG_TRANSVR_INT_VAL; - - if (self->state == STATE_TRANSVR_CONNECTED && - self->mode == TRANSVR_MODE_POLLING && - TRANSVR_INFO_CACHE_ENABLE) { - return snprintf(buf, LEN_TRANSVR_M_STR, "%s\n", self->vendor_sn); - } - err = _check_by_mode(self, - &_common_update_attr_vendor_sn, - "common_get_vendor_sn"); - memset(buf, 0, LEN_TRANSVR_M_STR); - if (err < 0){ - return snprintf(buf, LEN_TRANSVR_M_STR, "%d\n", err); - } - return snprintf(buf, LEN_TRANSVR_M_STR, "%s\n", self->vendor_sn); -} - - -int -common_get_br(struct transvr_obj_s *self){ - - int err = DEBUG_TRANSVR_INT_VAL; - - if (self->state == STATE_TRANSVR_CONNECTED && - self->mode == TRANSVR_MODE_POLLING && - TRANSVR_INFO_CACHE_ENABLE) { - return (int)self->br; - } - err = _check_by_mode(self, - &_common_update_attr_br, - "common_get_br"); - if (err < 0){ - return err; - } - /* Transform to INT to show error case */ - return (int)self->br; -} - - -int -common_get_len_smf(struct transvr_obj_s *self){ - - int err = DEBUG_TRANSVR_INT_VAL; - - if (self->state == STATE_TRANSVR_CONNECTED && - self->mode == TRANSVR_MODE_POLLING && - TRANSVR_INFO_CACHE_ENABLE) { - return self->len_smf; - } - err = _check_by_mode(self, - &_common_update_attr_len_smf, - "common_get_len_smf"); - if (err < 0){ - return err; - } - return self->len_smf; -} - - -int -common_get_len_om1(struct transvr_obj_s *self){ - - int err = DEBUG_TRANSVR_INT_VAL; - - if (self->state == STATE_TRANSVR_CONNECTED && - self->mode == TRANSVR_MODE_POLLING && - TRANSVR_INFO_CACHE_ENABLE) { - return self->len_om1; - } - err = _check_by_mode(self, - &_common_update_attr_len_om1, - "common_get_len_om1"); - if (err < 0){ - return err; - } - return self->len_om1; -} - - -int -common_get_len_om2(struct transvr_obj_s *self){ - - int err = DEBUG_TRANSVR_INT_VAL; - - if (self->state == STATE_TRANSVR_CONNECTED && - self->mode == TRANSVR_MODE_POLLING && - TRANSVR_INFO_CACHE_ENABLE) { - return self->len_om2; - } - - err = _check_by_mode(self, - &_common_update_attr_len_om2, - "common_get_len_om2"); - if (err < 0){ - return err; - } - return self->len_om2; -} - - -int -common_get_len_om3(struct transvr_obj_s *self){ - - int err = DEBUG_TRANSVR_INT_VAL; - - if (self->state == STATE_TRANSVR_CONNECTED && - self->mode == TRANSVR_MODE_POLLING && - TRANSVR_INFO_CACHE_ENABLE) { - return self->len_om3; - } - - err = _check_by_mode(self, - &_common_update_attr_len_om3, - "common_get_len_om3"); - if (err < 0){ - return err; - } - return self->len_om3; -} - - -int -common_get_len_om4(struct transvr_obj_s *self){ - - int err = DEBUG_TRANSVR_INT_VAL; - - if (self->state == STATE_TRANSVR_CONNECTED && - self->mode == TRANSVR_MODE_POLLING && - TRANSVR_INFO_CACHE_ENABLE) { - return self->len_om4; - } - err = _check_by_mode(self, - &_common_update_attr_len_om4, - "common_get_len_om4"); - if (err < 0){ - return err; - } - return self->len_om4; -} - - -int -common_get_comp_extended(struct transvr_obj_s *self){ - - int err_code = _check_by_mode(self, - &_common_update_attr_transvr_comp_ext, - "common_get_comp_extended"); - if (err_code < 0){ - return err_code; - } - return self->transvr_comp_ext; -} - - -int -common_get_comp_rev(struct transvr_obj_s *self){ - - int err_code = _check_by_mode(self, - &_common_update_attr_comp_rev, - "common_get_comp_rev"); - if (err_code < 0){ - return err_code; - } - return self->comp_rev; -} - - -int -common_get_info(struct transvr_obj_s *self){ - - if (self->state != STATE_TRANSVR_CONNECTED) { - return self->state; - } - return self->info; -} - - -int -_common_get_if_lane(struct transvr_obj_s *self, - char *result){ - int i = 0; - int tmp_val = 0; - char tmp_str[LEN_TRANSVR_M_STR] = DEBUG_TRANSVR_STR_VAL; - - memset(result, 0, LEN_TRANSVR_M_STR); - - for (i=0; ilane_id); i++) { - tmp_val = self->lane_id[i]; - if (tmp_val < 1) { - break; - } - memset(tmp_str, 0, LEN_TRANSVR_M_STR); - if (i == 0) { - snprintf(tmp_str, LEN_TRANSVR_M_STR, "%d", tmp_val); - } else { - snprintf(tmp_str, LEN_TRANSVR_M_STR, ",%d", tmp_val); - } - strncat(result, tmp_str, LEN_TRANSVR_M_STR); - } - if (i == 0) { - return EVENT_TRANSVR_TASK_FAIL; - } - return 0; -} - - -int -common_get_if_lane(struct transvr_obj_s *self, - char *buf_p){ - - char tmp_str[LEN_TRANSVR_M_STR] = DEBUG_TRANSVR_STR_VAL; - - if (self->ioexp_obj_p->state != STATE_IOEXP_NORMAL) { - return snprintf(buf_p, LEN_TRANSVR_M_STR, "%d\n", ERR_TRANSVR_ABNORMAL); - } - if (_common_get_if_lane(self, tmp_str) < 0) { - return snprintf(buf_p, LEN_TRANSVR_M_STR, "%d\n" ,ERR_TRANSVR_ABNORMAL); - } - return snprintf(buf_p, LEN_TRANSVR_M_STR, "%s\n" ,tmp_str); -} - - -int -sfp_get_len_sm(struct transvr_obj_s *self){ - - int err_code = _check_by_mode(self, - &_sfp_update_attr_len_sm, - "sfp_get_len_sm"); - if (err_code < 0){ - return err_code; - } - return self->len_sm; -} - - -int -sfp_get_rate_id(struct transvr_obj_s *self){ - - int err_code = _check_by_mode(self, - &_sfp_update_attr_rate_id, - "sfp_get_rate_id"); - if (err_code < 0){ - return err_code; - } - return self->rate_id; -} - - -int -sfp_get_soft_rs0(struct transvr_obj_s *self){ - /* Note: - * SFP Soft Rate_Select Select [aka. "RS(0)"] address - * A2h, offset: 110, bit 3 (begin form 0) - */ - int err_code = DEBUG_TRANSVR_INT_VAL; - int bit_shift = 3; - uint8_t result = 0x00; - uint8_t bitmask = (1 << bit_shift); - - /* Check rate identifier is supported */ - err_code = self->get_rate_id(self); - if (err_code <= 0) { - return ERR_TRANSVR_NOTSUPPORT; - } - /* Update and check */ - err_code = _check_by_mode(self, - &_sfp_update_attr_soft_rs0, - "sfp_get_soft_rs0"); - if (err_code <0){ - return err_code; - } - result = (self->soft_rs0 & bitmask); - if (result == bitmask) { - return 1; - } - if (result == 0) { - return 0; - } - return ERR_TRANSVR_UNEXCPT; -} - - -int -sfp_get_soft_rs1(struct transvr_obj_s *self){ - /* Note: - * SFP Soft RS(1) Select address - * A2h, offset: 118, bit 3 (begin form 0) - */ - int err_code = DEBUG_TRANSVR_INT_VAL; - int bit_shift = 3; - uint8_t result = 0x00; - uint8_t bitmask = (1 << bit_shift); - - /* Check rate identifier is supported */ - err_code = self->get_rate_id(self); - if (err_code <= 0) { - return ERR_TRANSVR_NOTSUPPORT; - } - /* Update and check */ - err_code = _check_by_mode(self, - &_sfp_update_attr_soft_rs1, - "sfp_get_soft_rs1"); - if (err_code <0){ - return err_code; - } - result = (self->soft_rs1 & bitmask); - if (result == bitmask) { - return 1; - } - if (result == 0) { - return 0; - } - return ERR_TRANSVR_UNEXCPT; -} - - -int -sfp_get_transvr_temp(struct transvr_obj_s *self, - char *buf_p) { - - int lmax = 8; - int err_code = DEBUG_TRANSVR_INT_VAL; - - err_code = _check_by_mode(self, - &_sfp_update_attr_curr_temp, - "sfp_get_transvr_temp"); - if (err_code < 0) { - return snprintf(buf_p, lmax, "%d\n", err_code); - } - if ((self->curr_temp[0]) == DEBUG_TRANSVR_HEX_VAL) { - return snprintf(buf_p, lmax, "%d\n", ERR_TRANSVR_UPDATE_FAIL); - } - return _common_count_temp(self->curr_temp[0], - self->curr_temp[1], - buf_p); -} - - -int -sfp_get_transvr_voltage(struct transvr_obj_s *self, - char *buf_p) { - - int lmax = 8; - int err_code = DEBUG_TRANSVR_INT_VAL; - - err_code = _check_by_mode(self, - &_sfp_update_attr_curr_voltage, - "sfp_get_transvr_voltage"); - if (err_code < 0) { - return snprintf(buf_p, lmax, "%d\n", err_code); - } - if ((self->curr_voltage[0]) == DEBUG_TRANSVR_HEX_VAL) { - return snprintf(buf_p, lmax, "%d\n", ERR_TRANSVR_UPDATE_FAIL); - } - /* Return Unit: 1 Volt */ - return _common_count_voltage(self->curr_voltage[0], - self->curr_voltage[1], - buf_p); -} - - -int -sfp_get_transvr_tx_bias(struct transvr_obj_s *self, - char *buf_p) { - - int lmax = 8; - int err_code = DEBUG_TRANSVR_INT_VAL; - - err_code = _check_by_mode(self, - &_sfp_update_attr_curr_tx_bias, - "sfp_get_transvr_tx_bias"); - if (err_code < 0) { - return snprintf(buf_p, lmax, "%d\n", err_code); - } - if ((self->curr_tx_bias[0]) == DEBUG_TRANSVR_HEX_VAL) { - return snprintf(buf_p, lmax, "%d\n", ERR_TRANSVR_UPDATE_FAIL); - } - /* Return Unit: 1 mA */ - return _common_count_tx_bias(self->curr_tx_bias[0], - self->curr_tx_bias[1], - buf_p); -} - - -int -sfp_get_transvr_tx_power(struct transvr_obj_s *self, - char *buf_p) { - - int lmax = 8; - int err_code = DEBUG_TRANSVR_INT_VAL; - - err_code = _check_by_mode(self, - &_sfp_update_attr_curr_tx_power, - "sfp_get_transvr_tx_power"); - if (err_code < 0) { - return snprintf(buf_p, lmax, "%d\n", err_code); - } - if ((self->curr_tx_bias[0]) == DEBUG_TRANSVR_HEX_VAL) { - return snprintf(buf_p, lmax, "%d\n", ERR_TRANSVR_UPDATE_FAIL); - } - /* Return Unit: 1 mW */ - return _common_count_tx_power(self->curr_tx_power[0], - self->curr_tx_power[1], - buf_p); -} - - -int -sfp_get_transvr_rx_power(struct transvr_obj_s *self, - char *buf_p) { - - int lmax = 8; - int err_code = DEBUG_TRANSVR_INT_VAL; - - err_code = _check_by_mode(self, - &_sfp_update_attr_curr_rx_power, - "sfp_get_transvr_rx_power"); - if (err_code < 0) { - return snprintf(buf_p, lmax, "%d\n", err_code); - } - if ((self->curr_tx_bias[0]) == DEBUG_TRANSVR_HEX_VAL) { - return snprintf(buf_p, lmax, "%d\n", ERR_TRANSVR_UPDATE_FAIL); - } - /* Return Unit: 1 mW */ - return _common_count_rx_power(self->curr_rx_power[0], - self->curr_rx_power[0], - buf_p); -} - - -int -sfp_get_transvr_rx_em(struct transvr_obj_s *self, - char *buf_p) { - - int limt = 8; - int err = DEBUG_TRANSVR_INT_VAL; - - err = _check_by_mode(self, - &_sfp_update_attr_rx_em, - "sfp_get_transvr_rx_em"); - if (err < 0) { - return snprintf(buf_p, limt, "%d\n", err); - } - if ((self->tx_eq[0]) == DEBUG_TRANSVR_HEX_VAL) { - return snprintf(buf_p, limt, "%d\n", ERR_TRANSVR_UPDATE_FAIL); - } - return snprintf(buf_p, limt, "0x%02x\n", self->rx_em[0]); -} - - -int -sfp_get_transvr_tx_eq(struct transvr_obj_s *self, - char *buf_p) { - - int limt = 8; - int err = DEBUG_TRANSVR_INT_VAL; - - err = _check_by_mode(self, - &_sfp_update_attr_tx_eq, - "sfp_get_transvr_tx_eq"); - if (err < 0) { - return snprintf(buf_p, limt, "%d\n", err); - } - if ((self->tx_eq[0]) == DEBUG_TRANSVR_HEX_VAL) { - return snprintf(buf_p, limt, "%d\n", ERR_TRANSVR_UPDATE_FAIL); - } - return snprintf(buf_p, limt, "0x%02x\n", self->tx_eq[0]); -} - - -int -_sfp_get_comp_extended(struct transvr_obj_s *self) { - /* Address: A0h / 36 - * Reference: SFF-8024 TABLE 4-4 - */ - if ((self->state == STATE_TRANSVR_CONNECTED) || - (self->state == STATE_TRANSVR_INIT) ) { - return (int)(self->transvr_comp_ext); - } - return ERR_TRANSVR_ABNORMAL; -} - - -int -__sfp_get_comp_attr(struct transvr_obj_s *self, - int array_offset) { - /* SFP Specification Compliance: A0h / 3-10 - * transvr_comp[0-7] = 3 - 10 - */ - if ((self->state == STATE_TRANSVR_CONNECTED) || - (self->state == STATE_TRANSVR_INIT) ) { - return (int)(self->transvr_comp[array_offset]); - } - return ERR_TRANSVR_ABNORMAL; -} - - -int -_sfp_get_comp_10g_eth_comp(struct transvr_obj_s *self) { - /* transvr_comp[0] = address A0h / 3 - * - * 3 7: 10G Base-ER - * 3 6: 10GBASE-LRM - * 3 5: 10GBASE-LR - * 3 4: 10GBASE-SR - */ - int bitmask = 0xf0; /* 11110000 */ - return (__sfp_get_comp_attr(self, 0) & bitmask); -} - - -int -_sfp_get_comp_1g_eth_comp(struct transvr_obj_s *self) { - /* transvr_comp[3] = address A0h / 6 - * - * 6 7: BASE-PX *3 - * 6 6: BASE-BX10 *3 - * 6 5: 100BASE-FX - * 6 4: 100BASE-LX/LX10 - * 6 3: 1000BASE-T - * 6 2: 1000BASE-CX - * 6 1: 1000BASE-LX *3 - * 6 0: 1000BASE-SX - */ - return __sfp_get_comp_attr(self, 3); -} - - -int -_sfp_get_cable_tech(struct transvr_obj_s *self) { - /* transvr_comp[5] = address A0h / 8 - * - * 8 3: Active Cable *8 - * 8 2: Passive Cable *8 - */ - int bitmask = 0x0c; /* 00001100 */ - return (__sfp_get_comp_attr(self, 5) & bitmask); -} - - -int -sfp_get_comp_eth_1(struct transvr_obj_s *self){ - - int err_code = _check_by_mode(self, - &_common_update_attr_transvr_comp, - "sfp_get_comp_eth_1"); - if (err_code < 0){ - return err_code; - } - return _sfp_get_comp_1g_eth_comp(self); -} - - -int -sfp_get_comp_eth_10(struct transvr_obj_s *self){ - - int err_code = _check_by_mode(self, - &_common_update_attr_transvr_comp, - "sfp_get_comp_eth_10"); - if (err_code < 0){ - return err_code; - } - return _sfp_get_comp_10g_eth_comp(self); -} - - -int -_sfp_get_connector_type(struct transvr_obj_s *self) { - /* Address: A0h / 2 - * Reference: SFF-8024 TABLE 4-3 - */ - if ((self->state == STATE_TRANSVR_CONNECTED) || - (self->state == STATE_TRANSVR_INIT) ) { - return (int)(self->connector); - } - return ERR_TRANSVR_ABNORMAL; -} - - -int -sfp_get_wavelength(struct transvr_obj_s *self, - char *buf_p) { - /* [Note] Optical and Cable Variants Specification Compliance (SFF-8472) - * [Addr] A0h, Bytes 60-61 - * [Note] For optical variants, as defined by having zero's in A0h Byte 8 - * bits 2 and 3, Bytes 60 and 61 denote nominal transmitter output - * wavelength at room temperature. 16 bit value with byte 60 as high - * order byte and byte 61 as low order byte. The laser wavelength is - * equal to the 16 bit integer value in nm. This field allows the user - * to read the laser wavelength directly, so it is not necessary to - * infer it from the Transceiver Codes A0h Bytes 3 to 10 (see Table - * 5-3). This also allows specification of wavelengths not covered - * in the Transceiver Codes, such as those used in coarse WDM systems. - * - * For passive and active cable variants, a value of 00h for both A0h - * Byte 60 and Byte 61 denotes laser wavelength or cable specification - * compliance is unspecified. - */ - - int lmax = 8; - int err_code = DEBUG_TRANSVR_INT_VAL; - - err_code = _check_by_mode(self, - &_common_update_attr_wavelength, - "common_get_wavelength"); - if (err_code < 0) { - return snprintf(buf_p, lmax, "%d\n", err_code); - } - if ((self->wavelength[0]) == DEBUG_TRANSVR_HEX_VAL) { - return snprintf(buf_p, lmax, "%d\n", ERR_TRANSVR_UPDATE_FAIL); - } - /* unit: 1 um */ - return snprintf(buf_p, lmax, "%d\n", - _common_count_wavelength(self, - self->wavelength[0], - self->wavelength[1])); -} - - -int -sfp_get_1g_rj45_extphy_offset(struct transvr_obj_s *self, char *buf) { - - if (self->state != STATE_TRANSVR_CONNECTED) { - return ERR_TRANSVR_UNPLUGGED; - } - if ((self->info != TRANSVR_CLASS_BASE_T_1000) && - (self->info != TRANSVR_CLASS_BASE_T_1000_up) ){ - return ERR_TRANSVR_NOTSUPPORT; - } - return snprintf(buf, LEN_TRANSVR_S_STR, "0x%02x\n", self->extphy_offset); -} - - -int -sfp_get_1g_rj45_extphy_reg(struct transvr_obj_s *self, char *buf) { - - int i = 0; - int ret = 0; - int retry = 3; - int delay = 200; - - if (self->state != STATE_TRANSVR_CONNECTED) { - return ERR_TRANSVR_UNPLUGGED; - } - if ((self->info != TRANSVR_CLASS_BASE_T_1000) && - (self->info != TRANSVR_CLASS_BASE_T_1000_up) ){ - return ERR_TRANSVR_NOTSUPPORT; - } - if (_common_setup_page(self, VAL_TRANSVR_EXTPHY_ADDR_56, - -1, self->extphy_offset, 1, 0) < 0) { - return -EIO; - } - for (i=0; ii2c_client_p, self->extphy_offset); - if (ret >=0) { - goto ok_sfp_get_1g_rj45_extphy_reg; - } - msleep(delay); - } - SWPS_INFO("%s: retry:%d fail :%s :0x%02x\n", - __func__, retry, self->swp_name, self->extphy_offset); - return -EIO; - -ok_sfp_get_1g_rj45_extphy_reg: - ret = ((ret & 0x00ff) << 8) | ((ret & 0xff00) >> 8); - return snprintf(buf, LEN_TRANSVR_S_STR, "0x%04x\n", ret); -} - - -int -__qsfp_get_power_cls(struct transvr_obj_s *self, - int direct_access){ - - int err_code; - uint8_t detect_val; - - /* Detect and Update power class attribute */ - if (direct_access){ - err_code = _check_by_mode(self, - &_common_update_attr_extended_id, - "__qsfp_get_power_cls"); - } else { - err_code = self->ext_id; - } - if (err_code <0){ - return err_code; - } - if (err_code == DEBUG_TRANSVR_HEX_VAL){ - return ERR_TRANSVR_UPDATE_FAIL; - } - /* Clean data */ - detect_val = self->ext_id; - SWP_BIT_CLEAR(detect_val, 2); /* Bit2: CDR RX present */ - SWP_BIT_CLEAR(detect_val, 3); /* Bit3: CDR TX present */ - SWP_BIT_CLEAR(detect_val, 4); /* Bit4: CLEI present */ - SWP_BIT_CLEAR(detect_val, 5); /* Bit5: reserved */ - /* Identify power class */ - switch (detect_val) { - case 0: /* Class_1: 00000000 */ - return 1; - case 64: /* Class_2: 01000000 */ - return 2; - case 128: /* Class_3: 10000000 */ - return 3; - case 192: /* Class_4: 11000000 */ - return 4; - case 1: /* Class_5: 00000001 */ - case 193: /* Class_5: 11000001 */ - return 5; - case 2: /* Class_6: 00000010 */ - case 194: /* Class_6: 11000010 */ - return 6; - case 3: /* Class_7: 00000011 */ - case 195: /* Class_7: 11000011 */ - return 7; - default: - break; - } - SWPS_INFO("%s: Detect undefined power class:%d\n", __func__, detect_val); - return ERR_TRANSVR_UNDEFINED; -} - - -int -qsfp_get_power_cls(struct transvr_obj_s *self) { - return __qsfp_get_power_cls(self, 1); -} - - -int -__qsfp_get_cdr_present(struct transvr_obj_s *self, - int direct_access){ - - int retval; - int BIT_SHIFT = 2; - int BIT_MASK = 0x3; - - /* Detect and Update power class attribute */ - if (direct_access) { - retval = _check_by_mode(self, - &_common_update_attr_extended_id, - "__qsfp_get_cdr_present"); - if (retval < 0){ - return retval; - } - } - retval = self->ext_id; - if (retval == DEBUG_TRANSVR_HEX_VAL){ - return ERR_TRANSVR_UPDATE_FAIL; - } - /* Clean data and return */ - return (int)(retval >> BIT_SHIFT & BIT_MASK); -} - - -int -qsfp_get_cdr_present(struct transvr_obj_s *self) { - return __qsfp_get_cdr_present(self, 1); -} - - -int -qsfp_get_cdr(struct transvr_obj_s *self){ - - int err_code = _check_by_mode(self, - &_qsfp_update_attr_cdr, - "qsfp_get_cdr"); - if (err_code <0){ - return err_code; - } - - return self->cdr; -} - - -int -__qsfp_get_comp_attr(struct transvr_obj_s *self, - int array_offset) { - /* QSFP Specification Compliance: 00h / 131-138 - * transvr_comp[0-7] = 131 - 138 - */ - if ((self->state == STATE_TRANSVR_CONNECTED) || - (self->state == STATE_TRANSVR_INIT) ) { - return (int)(self->transvr_comp[array_offset]); - } - return ERR_TRANSVR_ABNORMAL; -} - - -int -_qsfp_get_comp_10_40_100_ethernet(struct transvr_obj_s *self) { - /* transvr_comp[0] = address 00h / 131 - * - * 131 7: Extended: See section 6.3.23. The Extended Specification Compliance - * Codes are maintained in the Transceiver Management section of SFF- - * 8024. - * 131 6: 10GBASE-LRM - * 131 5: 10GBASE-LR - * 131 4: 10GBASE-SR - * 131 3: 40GBASE-CR4 - * 131 2: 40GBASE-SR4 - * 131 1: 40GBASE-LR4 - * 131 0: 40G Active Cable (XLPPI) - */ - return __qsfp_get_comp_attr(self, 0); -} - - -int -_qsfp_get_comp_sonet(struct transvr_obj_s *self) { - /* transvr_comp[1] = address 00h / 132 - * - * 132 7-3: Reserved - * 132 2: OC 48, long reach - * 132 1: OC 48, intermediate reach - * 132 0: OC 48 short reach - */ - return __qsfp_get_comp_attr(self, 1); -} - - -int -_qsfp_get_comp_sas_sata(struct transvr_obj_s *self) { - /* transvr_comp[1] = address 00h / 132 - * - * 133 7: SAS 24.0 Gb/s - * 133 6: SAS 12.0 Gb/s - * 133 5: SAS 6.0 Gb/s - * 133 4: SAS 3.0 Gb/s - * 133 3-0: Reserved - */ - return __qsfp_get_comp_attr(self, 2); -} - - -int -_qsfp_get_comp_ethernet(struct transvr_obj_s *self) { - /* transvr_comp[1] = address 00h / 132 - * - * 134 7-4: Reserved - * 134 3: 1000BASE-T - * 134 2: 1000BASE-CX - * 134 1: 1000BASE-LX - * 134 0: 1000BASE-SX - */ - return __qsfp_get_comp_attr(self, 3); -} - - -int -_qsfp_get_comp_fc_link_length(struct transvr_obj_s *self) { - /* transvr_comp[1] = address 00h / 132 - * - * 135 7: Very long distance (V) - * 135 6: Short distance (S) - * 135 5: Intermediate distance (I) - * 135 4: Long distance (L) - * 135 3: Medium (M) - */ - int mask = 0xFC; /* 11111100 */ - return (__qsfp_get_comp_attr(self, 4) & mask); -} - - -int -_qsfp_get_comp_fc_trans_tech(struct transvr_obj_s *self) { - /* transvr_comp[1] = address 00h / 132 - * - * 135 2: Reserved - * 135 1: Longwave laser (LC) - * 135 0: Electrical inter-enclosure (EL) - * - * 136 7: Electrical intra-enclosure - * 136 6: Shortwave laser w/o OFC (SN) - * 136 5: Shortwave laser w OFC (SL) - * 136 4: Longwave Laser (LL) - * 136 3-0: Reserved - * - * return value = [bit 8-15:addr 135][bit 0-7:addr 136] - */ - int mask_135 = 7; /* 00000111 */ - int val_135 = (__qsfp_get_comp_attr(self, 4) & mask_135); - int val_136 = __qsfp_get_comp_attr(self, 5); - return ((val_135 << 7) + val_136); -} - - -int -_qsfp_get_comp_fc_trans_media(struct transvr_obj_s *self) { - /* transvr_comp[1] = address 00h / 132 - * - * 137 7: Twin Axial Pair (TW) - * 137 6: Shielded Twisted Pair (TP) - * 137 5: Miniature Coax (MI) - * 137 4: Video Coax (TV) - * 137 3: Multi-mode 62.5 m (M6) - * 137 2: Multi-mode 50 m (M5) - * 137 1: Multi-mode 50 um (OM3) - * 137 0: Single Mode (SM) - */ - return __qsfp_get_comp_attr(self, 6); -} - - -int -_qsfp_get_comp_fc_speed(struct transvr_obj_s *self) { - /* transvr_comp[1] = address 00h / 132 - * - * 138 7: 1200 MBps (per channel) - * 138 6: 800 MBps - * 138 5: 1600 MBps (per channel) - * 138 4: 400 MBps - * 138 3: 3200 MBps (per channel) - * 138 2: 200 MBps - * 138 1: Extended: See section 6.3.23. The Extended Specification - * Compliance Codes are maintained in the Transceiver Management - * section of SFF-8024. - * 138 0: 100 MBps - */ - return __qsfp_get_comp_attr(self, 7); -} - - -int -_qsfp_get_comp_extended(struct transvr_obj_s *self) { - /* Address: 00h / 192 - * Reference: SFF-8024 TABLE 4-4 - */ - if ((self->state == STATE_TRANSVR_CONNECTED) || - (self->state == STATE_TRANSVR_INIT) ) { - return (int)(self->transvr_comp_ext); - } - return ERR_TRANSVR_ABNORMAL; -} - - -int -qsfp_get_comp_eth(struct transvr_obj_s *self){ - - int err_code = _check_by_mode(self, - &_common_update_attr_transvr_comp, - "qsfp_get_comp_eth"); - if (err_code < 0){ - return err_code; - } - return _qsfp_get_comp_ethernet(self); -} - - -int -qsfp_get_comp_10_40(struct transvr_obj_s *self) { - - int err_code = _check_by_mode(self, - &_common_update_attr_transvr_comp, - "qsfp_get_comp_10_40"); - if (err_code < 0){ - return err_code; - } - return _qsfp_get_comp_10_40_100_ethernet(self); -} - - -int -_qsfp_get_connector_type(struct transvr_obj_s *self) { - /* Address: 00h / 130 - * Reference: SFF-8024 TABLE 4-3 - */ - if ((self->state == STATE_TRANSVR_CONNECTED) || - (self->state == STATE_TRANSVR_INIT) ) { - return (int)(self->connector); - } - return ERR_TRANSVR_ABNORMAL; -} - - -int -qsfp_get_transvr_temp(struct transvr_obj_s *self, - char *buf_p) { - - int lmax = 8; - int err_code = DEBUG_TRANSVR_INT_VAL; - - err_code = _check_by_mode(self, - &_qsfp_update_attr_curr_temp, - "qsfp_get_transvr_temp"); - if (err_code < 0) { - return snprintf(buf_p, lmax, "%d\n", err_code); - } - if ((self->curr_temp[0]) == DEBUG_TRANSVR_HEX_VAL) { - return snprintf(buf_p, lmax, "%d\n", ERR_TRANSVR_UPDATE_FAIL); - } - return _common_count_temp(self->curr_temp[0], - self->curr_temp[1], - buf_p); -} - - -int -qsfp_get_transvr_voltage(struct transvr_obj_s *self, - char *buf_p) { - - int lmax = 8; - int err_code = DEBUG_TRANSVR_INT_VAL; - - err_code = _check_by_mode(self, - &_qsfp_update_attr_curr_voltage, - "qsfp_get_transvr_voltage"); - if (err_code < 0) { - return snprintf(buf_p, lmax, "%d\n", err_code); - } - if ((self->curr_voltage[0]) == DEBUG_TRANSVR_HEX_VAL) { - return snprintf(buf_p, lmax, "%d\n", ERR_TRANSVR_UPDATE_FAIL); - } - /* Return Unit: 1 Volt */ - return _common_count_voltage(self->curr_voltage[0], - self->curr_voltage[1], - buf_p); -} - - -int -qsfp_get_transvr_tx_eq(struct transvr_obj_s *self, - char *buf_p) { - - int limt = 8; - int err = DEBUG_TRANSVR_INT_VAL; - - err = _check_by_mode(self, - &_qsfp_update_attr_tx_eq, - "qsfp_get_transvr_tx_eq"); - if (err < 0) { - return snprintf(buf_p, limt, "%d\n", err); - } - if ((self->tx_eq[0]) == DEBUG_TRANSVR_HEX_VAL) { - return snprintf(buf_p, limt, "%d\n", ERR_TRANSVR_UPDATE_FAIL); - } - return snprintf(buf_p, limt, "0x%02x%02x\n", - self->tx_eq[0], self->tx_eq[1]); -} - - -int -qsfp_get_transvr_rx_am(struct transvr_obj_s *self, - char *buf_p) { - - int limt = 8; - int err = DEBUG_TRANSVR_INT_VAL; - - err = _check_by_mode(self, - &_qsfp_update_attr_rx_am, - "qsfp_get_transvr_rx_am"); - if (err < 0) { - return snprintf(buf_p, limt, "%d\n", err); - } - if ((self->rx_am[0]) == DEBUG_TRANSVR_HEX_VAL) { - return snprintf(buf_p, limt, "%d\n", ERR_TRANSVR_UPDATE_FAIL); - } - return snprintf(buf_p, limt, "0x%02x%02x\n", - self->rx_am[0], self->rx_am[1]); -} - - -int -qsfp_get_transvr_rx_em(struct transvr_obj_s *self, - char *buf_p) { - - int limt = 8; - int err = DEBUG_TRANSVR_INT_VAL; - - err = _check_by_mode(self, - &_qsfp_update_attr_rx_em, - "qsfp_get_transvr_rx_em"); - if (err < 0) { - return snprintf(buf_p, limt, "%d\n", err); - } - if ((self->rx_em[0]) == DEBUG_TRANSVR_HEX_VAL) { - return snprintf(buf_p, limt, "%d\n", ERR_TRANSVR_UPDATE_FAIL); - } - return snprintf(buf_p, limt, "0x%02x%02x\n", - self->rx_em[0], self->rx_em[1]); -} - - -int -_qsfp_get_channel_diag(uint8_t *data_array, - int (*count_func)(uint8_t high_byte, uint8_t low_byte, char *buf_p), - char *ch_name, - char *result_p) { - int i, high, low; - int len_max = 128; - char ch_buf[4][16] = { DEBUG_TRANSVR_STR_VAL, - DEBUG_TRANSVR_STR_VAL, - DEBUG_TRANSVR_STR_VAL, - DEBUG_TRANSVR_STR_VAL }; - - for (i=0; i<4; i++) { - high = (i*2); - low = ((i*2) + 1); - count_func(data_array[high], data_array[low], ch_buf[i]); - } - return snprintf(result_p, len_max, - "%s-%d:%s%s-%d:%s%s-%d:%s%s-%d:%s", - ch_name, 1, ch_buf[0], - ch_name, 2, ch_buf[1], - ch_name, 3, ch_buf[2], - ch_name, 4, ch_buf[3]); -} - - -int -qsfp_get_soft_rx_los(struct transvr_obj_s *self, - char *buf_p) { - - int lmax = 8; - int mask = 0x0f; /* Bit 0 ~ Bit 3 */ - int err_code = DEBUG_TRANSVR_INT_VAL; - - err_code = _check_by_mode(self, - &_qsfp_update_attr_soft_rx_los, - "qsfp_get_soft_rx_los"); - if (err_code < 0) { - return snprintf(buf_p, lmax, "%d\n", err_code); - } - return snprintf(buf_p, lmax, "0x%02x\n", (self->rx_los & mask)); -} - - -int -qsfp_get_soft_tx_disable(struct transvr_obj_s *self, - char *buf_p) { - - int lmax = 8; - int mask = 0x0f; /* Bit 0 ~ Bit 3 */ - int err_code = DEBUG_TRANSVR_INT_VAL; - - err_code = _check_by_mode(self, - &_qsfp_update_attr_soft_tx_disable, - "qsfp_get_soft_tx_disable"); - if (err_code < 0) { - return snprintf(buf_p, lmax, "%d\n", err_code); - } - return snprintf(buf_p, lmax, "0x%02x\n", (self->tx_disable & mask)); -} - - -int -qsfp_get_soft_tx_fault(struct transvr_obj_s *self, - char *buf_p) { - - int lmax = 8; - int mask = 0x0f; /* Bit 0 ~ Bit 3 */ - int err_code = DEBUG_TRANSVR_INT_VAL; - - err_code = _check_by_mode(self, - &_qsfp_update_attr_soft_tx_fault, - "qsfp_get_soft_tx_fault"); - if (err_code < 0) { - return snprintf(buf_p, lmax, "%d\n", err_code); - } - return snprintf(buf_p, lmax, "0x%02x\n", (self->tx_fault & mask)); -} - - -int -qsfp_get_auto_tx_disable(struct transvr_obj_s *self, - char *buf_p) { - - if (self->auto_tx_disable == VAL_TRANSVR_FUNCTION_DISABLE) { - return snprintf(buf_p, LEN_TRANSVR_S_STR, - "%d\n", ERR_TRANSVR_FUNC_DISABLE); - } - return snprintf(buf_p, LEN_TRANSVR_S_STR, - "0x%02x\n", self->auto_tx_disable); -} - - -int -qsfp_get_transvr_tx_bias(struct transvr_obj_s *self, - char *buf_p) { - - int lmax = 8; - int err_code = DEBUG_TRANSVR_INT_VAL; - char *ch_name = "TX"; - - err_code = _check_by_mode(self, - &_qsfp_update_attr_curr_tx_bias, - "qsfp_get_transvr_tx_bias"); - if (err_code < 0) { - return snprintf(buf_p, lmax, "%d\n", err_code); - } - if ((self->curr_tx_bias[0]) == DEBUG_TRANSVR_HEX_VAL) { - return snprintf(buf_p, lmax, "%d\n", ERR_TRANSVR_UPDATE_FAIL); - } - /* Return Unit: 1 mA */ - return _qsfp_get_channel_diag(self->curr_tx_bias, - _common_count_tx_bias, - ch_name, - buf_p); -} - - -int -qsfp_get_transvr_tx_power(struct transvr_obj_s *self, - char *buf_p) { - - int lmax = 8; - int err_code = DEBUG_TRANSVR_INT_VAL; - char *ch_name = "TX"; - - err_code = _check_by_mode(self, - &_qsfp_update_attr_curr_tx_power, - "qsfp_get_transvr_tx_power"); - if (err_code < 0) { - return snprintf(buf_p, lmax, "%d\n", err_code); - } - if ((self->curr_tx_power[0]) == DEBUG_TRANSVR_HEX_VAL) { - return snprintf(buf_p, lmax, "%d\n", ERR_TRANSVR_UPDATE_FAIL); - } - /* Return Unit: 1 mW */ - return _qsfp_get_channel_diag(self->curr_tx_power, - _common_count_tx_power, - ch_name, - buf_p); -} - - -int -qsfp_get_transvr_rx_power(struct transvr_obj_s *self, - char *buf_p) { - - int lmax = 8; - int err_code = DEBUG_TRANSVR_INT_VAL; - char *ch_name = "RX"; - - err_code = _check_by_mode(self, - &_qsfp_update_attr_curr_rx_power, - "qsfp_get_transvr_rx_power"); - if (err_code < 0) { - return snprintf(buf_p, lmax, "%d\n", err_code); - } - if ((self->curr_tx_power[0]) == DEBUG_TRANSVR_HEX_VAL) { - return snprintf(buf_p, lmax, "%d\n", ERR_TRANSVR_UPDATE_FAIL); - } - /* Return Unit: 1 mW */ - return _qsfp_get_channel_diag(self->curr_rx_power, - _common_count_rx_power, - ch_name, - buf_p); -} - - -int -qsfp_get_wavelength(struct transvr_obj_s *self, - char *buf_p) { - /* [Desc] Wavelength or Copper Cable Attenuation (SFF-8636) - * [Addr] 00h 186-187 - * [Note] - * For optical free side devices, this parameter identifies the nominal - * transmitter output wavelength at room temperature. This parameter is - * a 16-bit hex value with Byte 186 as high order byte and Byte 187 as - * low order byte. The laser wavelength is equal to the 16-bit integer value - * divided by 20 in nm (units of 0.05 nm). This resolution should be adequate - * to cover all relevant wavelengths yet provide enough resolution for all - * expected DWDM applications. For accurate representation of controlled - * wavelength applications, this value should represent the center of the - * guaranteed wavelength range. - * If the free side device is identified as copper cable these registers will - * be used to define the cable attenuation. An indication of 0 dB attenuation - * refers to the case where the attenuation is not known or is unavailable. - * Byte 186 (00-FFh) is the copper cable attenuation at 2.5 GHz in units of 1 dB. - * Byte 187 (00-FFh) is the copper cable attenuation at 5.0 GHz in units of 1 dB. - */ - int lmax = 8; - int err_code = DEBUG_TRANSVR_INT_VAL; - - err_code = _check_by_mode(self, - &_common_update_attr_wavelength, - "common_get_wavelength"); - if (err_code < 0) { - return snprintf(buf_p, lmax, "%d\n", err_code); - } - if ((self->wavelength[0]) == DEBUG_TRANSVR_HEX_VAL) { - return snprintf(buf_p, lmax, "%d\n", ERR_TRANSVR_UPDATE_FAIL); - } - /* unit: 1 um */ - return snprintf(buf_p, lmax, "%d\n", - _common_count_wavelength(self, - self->wavelength[0], - self->wavelength[1])); -} - - -/* Public Function for Setup Features - */ -static int -__sfp_set_soft_rs(struct transvr_obj_s *self, - int input_val, - int address, - int page, - int offset, - int bit_shift, - uint8_t *attr_p, - char *caller, - int show_err) { - - int retval = ERR_TRANSVR_UNEXCPT; - int err_code = ERR_TRANSVR_UNEXCPT; - char *err_msg = DEBUG_TRANSVR_STR_VAL; - uint8_t update_val = (*attr_p); - - switch (input_val) { - case 0: - SWP_BIT_CLEAR(update_val, bit_shift); - break; - case 1: - SWP_BIT_SET(update_val, bit_shift); - break; - default: - retval = ERR_TRANSVR_UNEXCPT; - err_code = ERR_TRANSVR_UNEXCPT; - err_msg = "Exception occurs"; - goto err_private_sfp_set_soft_rs_1; - } - err_code = _common_set_uint8_attr(self, - address, - page, - offset, - update_val, - attr_p, - caller, - show_err); - if (err_code < 0) { - retval = err_code; - err_msg = "Write data via i2c fail!"; - goto err_private_sfp_set_soft_rs_1; - } - (*attr_p) = update_val; - return 0; - -err_private_sfp_set_soft_rs_1: - if (show_err) { - SWPS_INFO("%s: %s :%d :%s\n :%d\n", - __func__, err_msg, err_code, self->swp_name, input_val); - } - return retval; -} - - -static int -_sfp_set_soft_rs(struct transvr_obj_s *self, - int input_val, - int address, - int page, - int offset, - int bit_shift, - int (*attr_update_func)(struct transvr_obj_s *self, int show_err), - uint8_t *attr_p, - char *caller, - int show_err) { - - int retval = ERR_TRANSVR_UNEXCPT; - int err_code = ERR_TRANSVR_UNEXCPT; - char *err_msg = DEBUG_TRANSVR_STR_VAL; - - /* Check input value */ - if ((input_val != 0) && (input_val != 1)){ - retval = ERR_TRANSVR_BADINPUT; - err_code = ERR_TRANSVR_BADINPUT; - err_msg = "Input range incorrect!"; - goto err_common_sfp_set_soft_rs_1; - } - /* Check rate identifier is supported */ - err_code = self->get_rate_id(self); - if (err_code <= 0) { - switch (err_code) { - case 0: - retval = ERR_TRANSVR_NOTSUPPORT; - err_msg = "Not support this feature"; - break; - case ERR_TRANSVR_UNINIT: - retval = ERR_TRANSVR_UNINIT; - err_msg = "Check CDR present fail!"; - break; - case ERR_TRANSVR_UNPLUGGED: - retval = ERR_TRANSVR_UNPLUGGED; - err_msg = "Transceiver unplugged!"; - break; - default: - retval = err_code; - err_msg = "Check Rate_ID fail!"; - break; - } - goto err_common_sfp_set_soft_rs_1; - } - /* Check and update */ - err_code = _check_by_mode(self, - attr_update_func, - caller); - if ( (err_code < 0) || - ((*attr_p) == DEBUG_TRANSVR_HEX_VAL) ){ - retval = err_code; - err_msg = "Get current value fail!"; - goto err_common_sfp_set_soft_rs_1; - } - /* Generate and update value */ - return __sfp_set_soft_rs(self, - input_val, - address, - page, - offset, - bit_shift, - attr_p, - caller, - show_err); - -err_common_sfp_set_soft_rs_1: - if (show_err) { - SWPS_INFO("%s: %s :%d :%s\n :%d\n", - __func__, err_msg, err_code, self->swp_name, input_val); - } - return retval; -} - - -int -sfp_set_soft_rs0(struct transvr_obj_s *self, - int input_val) { - /* Note: - * SFP Soft Rate_Select Select RX ["RS(0)"] address - * A2h, offset: 110, bit 3 - */ - int bit_shift = 3; - int show_err = 1; - return _sfp_set_soft_rs(self, - input_val, - self->eeprom_map_p->addr_soft_rs0, - self->eeprom_map_p->page_soft_rs0, - self->eeprom_map_p->offset_soft_rs0, - bit_shift, - &_sfp_update_attr_soft_rs0, - &(self->soft_rs0), - "sfp_set_soft_rs0", - show_err); -} - - -int -sfp_set_soft_rs1(struct transvr_obj_s *self, - int input_val) { - /* Note: - * SFP Soft Rate_Select Select RX ["RS(1)"] address - * A2h, offset: 118, bit 3 - */ - int bit_shift = 3; - int show_err = 1; - return _sfp_set_soft_rs(self, - input_val, - self->eeprom_map_p->addr_soft_rs1, - self->eeprom_map_p->page_soft_rs1, - self->eeprom_map_p->offset_soft_rs1, - bit_shift, - &_sfp_update_attr_soft_rs1, - &(self->soft_rs1), - "sfp_set_soft_rs1", - show_err); -} - - -int -__sfp_set_tx_eq(struct transvr_obj_s *self, - int input, - int show_e) { - - int err = DEBUG_TRANSVR_INT_VAL; - char *emsg = DEBUG_TRANSVR_STR_VAL; - uint8_t setv = DEBUG_TRANSVR_HEX_VAL; - - if ((input < 0) || (input > 0xFF)) { - emsg = "input incorrect"; - err = ERR_TRANSVR_BADINPUT; - goto err_sfp_set_tx_eq; - } - setv = (uint8_t)input; - if (self->tx_eq[0] == setv) { - return 0; - } - err = _common_set_uint8_attr(self, - self->eeprom_map_p->addr_tx_eq, - self->eeprom_map_p->page_tx_eq, - self->eeprom_map_p->offset_tx_eq, - setv, - &(self->tx_eq[0]), - "_sfp_set_tx_eq", - show_e); - if (err < 0) { - emsg = "set_uint8_attr fail"; - goto err_sfp_set_tx_eq; - } - return 0; - -err_sfp_set_tx_eq: - if (show_e) { - SWPS_INFO("%s: %s :%d\n", __func__, emsg, input); - } - return err; -} - - -int -_sfp_set_tx_eq(struct transvr_obj_s *self, - int input, - int show_e) { - - uint8_t tmp; - int i = 0; - int retry = 3; - - for (i=0; itx_eq[0]; - if (_sfp_update_attr_tx_eq(self, show_e) < 0){ - continue; - } - if (self->tx_eq[0] == tmp){ - return 0; - } - } - return ERR_TRANSVR_UPDATE_FAIL; -} - - -int -sfp_set_tx_eq(struct transvr_obj_s *self, - int input) { - - int err = _check_by_mode(self, - &_sfp_update_attr_tx_eq, - "sfp_set_tx_eq"); - if (err < 0) { - SWPS_DEBUG("%s: check fail :%d\n", __func__, err); - return err; - } - return _sfp_set_tx_eq(self, input, 1); -} - - -int -__sfp_set_rx_em(struct transvr_obj_s *self, - int input, - int show_e) { - - int err = DEBUG_TRANSVR_INT_VAL; - char *emsg = DEBUG_TRANSVR_STR_VAL; - uint8_t setv = DEBUG_TRANSVR_HEX_VAL; - - if ((input < 0) || (input > 0xFF)) { - emsg = "input incorrect"; - err = ERR_TRANSVR_BADINPUT; - goto err_sfp_set_rx_em; - } - setv = (uint8_t)input; - if (self->rx_em[0] == setv) { - return 0; - } - err = _common_set_uint8_attr(self, - self->eeprom_map_p->addr_rx_em, - self->eeprom_map_p->page_rx_em, - self->eeprom_map_p->offset_rx_em, - setv, - &(self->rx_em[0]), - "_sfp_set_rx_em", - show_e); - if (err < 0) { - emsg = "set_uint8_attr fail"; - goto err_sfp_set_rx_em; - } - return 0; - -err_sfp_set_rx_em: - if (show_e) { - SWPS_INFO("%s: %s :%d\n", __func__, emsg, input); - } - return err; -} - - -int -_sfp_set_rx_em(struct transvr_obj_s *self, - int input, - int show_e) { - - uint8_t tmp; - int i = 0; - int retry = 3; - - for (i=0; irx_em[0]; - if (_sfp_update_attr_rx_em(self, show_e) < 0){ - continue; - } - if (self->rx_em[0] == tmp){ - return 0; - } - } - return -1; -} - - -int -sfp_set_rx_em(struct transvr_obj_s *self, - int input) { - - int err = _check_by_mode(self, - &_sfp_update_attr_rx_em, - "sfp_set_rx_em"); - if (err < 0) { - SWPS_DEBUG("%s: check fail :%d\n", __func__, err); - return err; - } - return _sfp_set_rx_em(self, input, 1); -} - - -int -sfp_set_1g_rj45_extphy_offset(struct transvr_obj_s *self, - int input) { - - if (self->state != STATE_TRANSVR_CONNECTED) { - return ERR_TRANSVR_UNPLUGGED; - } - if ((self->info != TRANSVR_CLASS_BASE_T_1000) && - (self->info != TRANSVR_CLASS_BASE_T_1000_up) ){ - return ERR_TRANSVR_NOTSUPPORT; - } - if ((input < 0) || (input > 0xff)) { - return ERR_TRANSVR_BADINPUT; - } - self->extphy_offset = (uint8_t)input; - return 0; -} - - -int -sfp_set_1g_rj45_extphy_reg(struct transvr_obj_s *self, - int input) { - - int i = 0; - int retry = 3; - int delay = 200; - uint16_t tmp = 0; - - if (self->state != STATE_TRANSVR_CONNECTED) { - return ERR_TRANSVR_UNPLUGGED; - } - if ((self->info != TRANSVR_CLASS_BASE_T_1000) && - (self->info != TRANSVR_CLASS_BASE_T_1000_up) ){ - return ERR_TRANSVR_NOTSUPPORT; - } - if ((input < 0) || (input > 0xffff)) { - return ERR_TRANSVR_BADINPUT; - } - tmp = ((input & 0x00ff) << 8) | ((input & 0xff00) >> 8); - if (_common_setup_page(self, VAL_TRANSVR_EXTPHY_ADDR_56, - -1, self->extphy_offset, 1, 0) < 0) { - return -EIO; - } - for (i=0; i<=retry; i++) { - if (i2c_smbus_write_word_data(self->i2c_client_p, - self->extphy_offset, - tmp) >= 0) { - return 0; - } - msleep(delay); - } - SWPS_INFO("%s: retry:%d fail :%s :0x%02x\n", - __func__, retry, self->swp_name, self->extphy_offset); - return -EIO; -} - - -static int -__qsfp_set_cdr(struct transvr_obj_s *self, - int input_val, - int show_err) { - - uint8_t update_val; - int CDR_FEATURE_SUPPORTED = 0x3; - int retval = ERR_TRANSVR_UNEXCPT; - int err_code = ERR_TRANSVR_UNEXCPT; - char *err_msg = DEBUG_TRANSVR_STR_VAL; - char *func_name = "__qsfp_set_cdr"; - - /* Check input value */ - if ((input_val < 0) || (input_val > 0xff)){ - retval = ERR_TRANSVR_BADINPUT; - err_code = ERR_TRANSVR_BADINPUT; - err_msg = "Input range incorrect!"; - goto err_qsfp_set_cdr_1; - } - update_val = (uint8_t)input_val; - /* Check CDR supported by transceiver */ - err_code = qsfp_get_cdr_present(self); - if (err_code < 0) { - retval = err_code; - switch (err_code) { - case ERR_TRANSVR_UNINIT: - err_msg = "Check CDR present fail!"; - break; - case ERR_TRANSVR_UNPLUGGED: - err_msg = "Transceiver unplugged!"; - break; - default: - err_msg = "Check CDR present fail!"; - break; - } - goto err_qsfp_set_cdr_1; - } - if (err_code != CDR_FEATURE_SUPPORTED) { - retval = ERR_TRANSVR_NOTSUPPORT; - err_msg = "This transceiver not support CDR!"; - goto err_qsfp_set_cdr_1; - } - /* Check and update */ - err_code = _check_by_mode(self, - &_qsfp_update_attr_cdr, - func_name); - if ( (err_code < 0) || - (self->cdr == DEBUG_TRANSVR_HEX_VAL) ){ - retval = err_code; - err_msg = "Get current value fail!"; - goto err_qsfp_set_cdr_1; - } - /* Write input value to transceiver */ - return _common_set_uint8_attr(self, - self->eeprom_map_p->addr_cdr, - self->eeprom_map_p->page_cdr, - self->eeprom_map_p->offset_cdr, - update_val, - &(self->cdr), - func_name, - show_err); - -err_qsfp_set_cdr_1: - if (show_err) { - SWPS_INFO("%s: %s :%d :%s\n :%d\n", - __func__, err_msg, err_code, self->swp_name, input_val); - } - return retval; -} - - -int -qsfp_set_cdr(struct transvr_obj_s *self, - int input_val) { - return __qsfp_set_cdr(self, input_val, 1); -} - - -int -qsfp_set_soft_tx_disable(struct transvr_obj_s *self, - int input_val) { - - int show_err = 1; - int in_max = 0xf; /* 1111 */ - int in_min = 0x0; /* 0000 */ - int retval = DEBUG_TRANSVR_INT_VAL; - int update_val = DEBUG_TRANSVR_INT_VAL; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - - retval = _check_by_mode(self, - &_qsfp_update_attr_soft_tx_disable, - "qsfp_set_soft_tx_disable"); - if (retval < 0) { - snprintf(err_msg, 63, "Not ready. err:%d", retval); - goto err_qsfp_set_soft_tx_disable; - } - if ((input_val > in_max) || - (input_val < in_min) ){ - retval = ERR_TRANSVR_BADINPUT; - snprintf(err_msg, 63, "Input value:%d incorrect!", input_val); - goto err_qsfp_set_soft_tx_disable; - } - if ((self->tx_disable & 0x0f) == input_val) { - return 0; - } - update_val = ((self->tx_disable & 0xf0) & input_val); - retval = _common_set_uint8_attr(self, - self->eeprom_map_p->addr_tx_disable, - self->eeprom_map_p->page_tx_disable, - self->eeprom_map_p->offset_tx_disable, - input_val, - &(self->tx_disable), - "qsfp_set_tx_disable", - show_err); - if (retval < 0) { - snprintf(err_msg, 63, "_common_set_uint8_attr:%d fail!", retval); - goto err_qsfp_set_soft_tx_disable; - } - return 0; - -err_qsfp_set_soft_tx_disable: - SWPS_INFO("%s: %s :%s\n", __func__, err_msg, self->swp_name); - return retval; -} - - -int -_qsfp_set_auto_tx_disable(struct transvr_obj_s *self, - uint8_t update) { - - uint8_t tx_enable = 0x0; - int show_e = 1; - int err = DEBUG_TRANSVR_INT_VAL; - char *emsg = DEBUG_TRANSVR_STR_VAL; - - /* Handle timing issues */ - if (update != tx_enable) { - /* Note: - * Because there are some txvr has timing issues, - * therefore we need to execute reset cycle first. - * (enable -> other settings) - */ - err = _common_set_uint8_attr(self, - self->eeprom_map_p->addr_tx_disable, - self->eeprom_map_p->page_tx_disable, - self->eeprom_map_p->offset_tx_disable, - tx_enable, - &(self->tx_disable), - "_qsfp_set_auto_tx_disable", - show_e); - if (err < 0) { - emsg = "I2C set reset value fail"; - goto err_qsfp_set_auto_tx_disable; - } - mdelay(10); - } - /* Setup target value */ - err = _common_set_uint8_attr(self, - self->eeprom_map_p->addr_tx_disable, - self->eeprom_map_p->page_tx_disable, - self->eeprom_map_p->offset_tx_disable, - self->auto_tx_disable, - &(self->tx_disable), - "_qsfp_set_auto_tx_disable", - show_e); - if (err < 0) { - emsg = "I2C set target value fail"; - goto err_qsfp_set_auto_tx_disable; - } - /* Check and update */ - err = _common_update_uint8_attr(self, - self->eeprom_map_p->addr_tx_disable, - self->eeprom_map_p->page_tx_disable, - self->eeprom_map_p->offset_tx_disable, - self->eeprom_map_p->length_tx_disable, - &(self->tx_disable), - "_qsfp_set_auto_tx_disable", - show_e); - if (err < 0) { - emsg = "I2C get value fail"; - goto err_qsfp_set_auto_tx_disable; - } - if (self->tx_disable != update) { - emsg = "data not become effective"; - goto err_qsfp_set_auto_tx_disable; - } - return 0; - -err_qsfp_set_auto_tx_disable: - SWPS_DEBUG("%s: %s :%s\n", - __func__, emsg, self->swp_name); - return ERR_TRANSVR_UPDATE_FAIL; -} - - -int -qsfp_set_auto_tx_disable(struct transvr_obj_s *self, - int input_val) { - - int in_max = 0xf; /* 1111 */ - int in_min = 0x0; /* 0000 */ - int retval = DEBUG_TRANSVR_INT_VAL; - char *emsg = DEBUG_TRANSVR_STR_VAL; - - /* Update settings*/ - if (input_val == VAL_TRANSVR_FUNCTION_DISABLE) { - emsg = "User disable auto tx_disable"; - self->auto_tx_disable = VAL_TRANSVR_FUNCTION_DISABLE; - goto out_qsfp_set_auto_tx_disable; - } - if ((input_val > in_max) || (input_val < in_min) ){ - SWPS_INFO("%s: Input value:%d incorrect! :%s\n", - __func__, input_val, self->swp_name); - return ERR_TRANSVR_BADINPUT; - } - self->auto_tx_disable = input_val; - /* Check current soft tx_disable */ - retval = _check_by_mode(self, - &_qsfp_update_attr_soft_tx_disable, - "qsfp_set_auto_tx_disable"); - switch (retval) { - case 0: - break; - case ERR_TRANSVR_UNPLUGGED: - emsg = "Doesn't need to update"; - goto out_qsfp_set_auto_tx_disable; - default: - SWPS_INFO("%s: setup fail :%d :%s\n", - __func__, retval, self->swp_name); - return retval; - } - return _qsfp_set_auto_tx_disable(self, input_val); - -out_qsfp_set_auto_tx_disable: - SWPS_DEBUG("%s: %s :%s :%d\n :%d", - __func__, emsg, self->swp_name, input_val, retval); - return 0; -} - - -int -__qsfp_set_tx_eq(struct transvr_obj_s *self, - int input, - int show_e) { - /* [Note] - * 0x - */ - int err = DEBUG_TRANSVR_INT_VAL; - char *emsg = DEBUG_TRANSVR_STR_VAL; - uint8_t setv[2] = {0x00, 0x00}; - - if ((input < 0) || (input > 0xFFFF)) { - emsg = "input incorrect"; - err = ERR_TRANSVR_BADINPUT; - goto err_qsfp_set_tx_eq; - } - setv[0] = (uint8_t)((input & 0xFF00) >> 8); - setv[1] = (uint8_t)(input & 0xFF); - if ((self->tx_eq[0] == setv[0]) && - (self->tx_eq[1] == setv[1]) ) { - return 0; - } - err = _common_set_uint8_array(self, - self->eeprom_map_p->addr_tx_eq, - self->eeprom_map_p->page_tx_eq, - self->eeprom_map_p->offset_tx_eq, - self->eeprom_map_p->length_tx_eq, - setv, - self->tx_eq, - "_qsfp_set_tx_eq", - show_e); - if (err < 0) { - emsg = "set_uint8_array fail"; - goto err_qsfp_set_tx_eq; - } - return 0; - -err_qsfp_set_tx_eq: - if (show_e) { - SWPS_INFO("%s: %s :%d\n", __func__, emsg, input); - } - return err; -} - - -int -_qsfp_set_tx_eq(struct transvr_obj_s *self, - int input, - int show_e) { - - int i = 0; - int retry = 3; - uint8_t tmp[2]; - - for (i=0; itx_eq[0]; - tmp[1] = self->tx_eq[1]; - if (_qsfp_update_attr_tx_eq(self, show_e) < 0){ - continue; - } - if ((self->tx_eq[0] == tmp[0]) && - (self->tx_eq[1] == tmp[1]) ){ - return 0; - } - } - return -1; -} - - -int -qsfp_set_tx_eq(struct transvr_obj_s *self, - int input) { - - int err = _check_by_mode(self, - &_qsfp_update_attr_tx_eq, - "qsfp_set_tx_eq"); - if (err < 0) { - SWPS_DEBUG("%s: check fail :%d\n", __func__, err); - return err; - } - return _qsfp_set_tx_eq(self, input, 1); -} - - -int -__qsfp_set_rx_am(struct transvr_obj_s *self, - int input, - int show_e) { - /* [Note] - * 0x - */ - int err = DEBUG_TRANSVR_INT_VAL; - char *emsg = DEBUG_TRANSVR_STR_VAL; - uint8_t setv[2] = {0x00, 0x00}; - - if ((input < 0) || (input > 0xFFFF)) { - emsg = "input incorrect"; - err = ERR_TRANSVR_BADINPUT; - goto err_qsfp_set_rx_am; - } - setv[0] = (uint8_t)((input & 0xFF00) >> 8); - setv[1] = (uint8_t)(input & 0xFF); - if ((self->rx_am[0] == setv[0]) && - (self->rx_am[1] == setv[1]) ) { - return 0; - } - err = _common_set_uint8_array(self, - self->eeprom_map_p->addr_rx_am, - self->eeprom_map_p->page_rx_am, - self->eeprom_map_p->offset_rx_am, - self->eeprom_map_p->length_rx_am, - setv, - self->rx_am, - "_qsfp_set_rx_am", - show_e); - if (err < 0) { - emsg = "set_uint8_array fail"; - goto err_qsfp_set_rx_am; - } - return 0; - -err_qsfp_set_rx_am: - if (show_e) { - SWPS_INFO("%s: %s :%d\n", __func__, emsg, input); - } - return err; -} - - -int -_qsfp_set_rx_am(struct transvr_obj_s *self, - int input, - int show_e) { - - int i = 0; - int retry = 3; - uint8_t tmp[2]; - - for (i=0; irx_am[0]; - tmp[1] = self->rx_am[1]; - if (_qsfp_update_attr_rx_am(self, show_e) < 0){ - continue; - } - if ((self->rx_am[0] == tmp[0]) && - (self->rx_am[1] == tmp[1]) ){ - return 0; - } - } - return -1; -} - - -int -qsfp_set_rx_am(struct transvr_obj_s *self, - int input) { - - int err = _check_by_mode(self, - &_qsfp_update_attr_rx_am, - "qsfp_set_rx_am"); - if (err < 0) { - SWPS_DEBUG("%s: check fail :%d\n", __func__, err); - return err; - } - return _qsfp_set_rx_am(self, input, 1); -} - - -int -__qsfp_set_rx_em(struct transvr_obj_s *self, - int input, - int show_e) { - /* [Note] - * 0x - */ - int err = DEBUG_TRANSVR_INT_VAL; - char *emsg = DEBUG_TRANSVR_STR_VAL; - uint8_t setv[2] = {0x00, 0x00}; - - if ((input < 0) || (input > 0xFFFF)) { - emsg = "input incorrect"; - err = ERR_TRANSVR_BADINPUT; - goto err_qsfp_set_rx_em; - } - setv[0] = (uint8_t)((input & 0xFF00) >> 8); - setv[1] = (uint8_t)(input & 0xFF); - if ((self->rx_em[0] == setv[0]) && - (self->rx_em[1] == setv[1]) ) { - return 0; - } - err = _common_set_uint8_array(self, - self->eeprom_map_p->addr_rx_em, - self->eeprom_map_p->page_rx_em, - self->eeprom_map_p->offset_rx_em, - self->eeprom_map_p->length_rx_em, - setv, - self->rx_em, - "_qsfp_set_rx_em", - show_e); - if (err < 0) { - emsg = "set_uint8_array fail"; - goto err_qsfp_set_rx_em; - } - return 0; - -err_qsfp_set_rx_em: - if (show_e) { - SWPS_INFO("%s: %s :%d\n", __func__, emsg, input); - } - return err; -} - - -int -_qsfp_set_rx_em(struct transvr_obj_s *self, - int input, - int show_e) { - - int i = 0; - int retry = 3; - uint8_t tmp[2]; - - for (i=0; irx_em[0]; - tmp[1] = self->rx_em[1]; - if (_qsfp_update_attr_rx_em(self, show_e) < 0){ - continue; - } - if ((self->rx_em[0] == tmp[0]) && - (self->rx_em[1] == tmp[1]) ){ - return 0; - } - } - return -1; -} - - -int -qsfp_set_rx_em(struct transvr_obj_s *self, - int input) { - - int err = _check_by_mode(self, - &_qsfp_update_attr_rx_em, - "qsfp_set_rx_em"); - if (err < 0) { - SWPS_DEBUG("%s: check fail :%d\n", __func__, err); - return err; - } - return _qsfp_set_rx_em(self, input, 1); -} - - -int -common_transvr_dump(struct transvr_obj_s* self){ - - char *type_name = "Undefined"; - - if (TRANSVR_INFO_DUMP_ENABLE != 1) { - return 0; - } - switch (self->type) { - case TRANSVR_TYPE_SFP: - type_name = STR_TRANSVR_SFP; - break; - case TRANSVR_TYPE_QSFP: - type_name = STR_TRANSVR_QSFP; - break; - case TRANSVR_TYPE_QSFP_PLUS: - type_name = STR_TRANSVR_QSFP_PLUS; - break; - case TRANSVR_TYPE_QSFP_28: - type_name = STR_TRANSVR_QSFP28; - break; - case TRANSVR_TYPE_FAKE: - type_name = "FAKE"; - goto ok_common_transvr_dump; - case TRANSVR_TYPE_UNPLUGGED: - type_name = "UNPLUGGED"; - goto err_common_transvr_dump; - case TRANSVR_TYPE_INCONSISTENT: - type_name = "INCONSISTENT"; - goto err_common_transvr_dump; - case TRANSVR_TYPE_ERROR: - type_name = "ERROR"; - goto err_common_transvr_dump; - - default: - type_name = "UNEXPECTED"; - goto err_common_transvr_dump; - } - printk(KERN_INFO "[SWPS] Dump %s information:\n", self->swp_name); - printk(KERN_INFO " |- :%s\n", type_name); - printk(KERN_INFO " |- :%s\n", self->vendor_name); - printk(KERN_INFO " |- :%s\n", self->vendor_pn); - printk(KERN_INFO " |- :%s\n", self->vendor_rev); - printk(KERN_INFO " |- :%s\n", self->vendor_sn); - printk(KERN_INFO " |- :0x%02x\n", self->br); - printk(KERN_INFO " |- :0x%02x\n", self->comp_rev); - printk(KERN_INFO " |- :%d\n", self->len_om1); - printk(KERN_INFO " |- :%d\n", self->len_om2); - printk(KERN_INFO " |- :%d\n", self->len_om3); - printk(KERN_INFO " |- :%d\n", self->len_om4); - return 0; - -ok_common_transvr_dump: - SWPS_INFO("%s: %s is %s\n", __func__, self->swp_name, type_name); - return 0; - -err_common_transvr_dump: - SWPS_INFO("%s: %s is %s\n", __func__, self->swp_name, type_name); - return -1; -} - - -int -sfp_transvr_dump(struct transvr_obj_s* self) { - - if (TRANSVR_INFO_DUMP_ENABLE != 1) { - return 0; - } - if (common_transvr_dump(self) < 0) { - return -1; - } - printk(KERN_INFO " |- :%d\n", self->len_sm); - printk(KERN_INFO " |- :%d\n", self->len_smf); - printk(KERN_INFO " '- :0x%02x\n", self->rate_id); - return 0; -} - - -int -qsfp_transvr_dump(struct transvr_obj_s* self) { - - if (TRANSVR_INFO_DUMP_ENABLE != 1) { - return 0; - } - if (common_transvr_dump(self) < 0) { - return -1; - } - printk(KERN_INFO " |- :%d\n", self->len_smf); - printk(KERN_INFO " '- :Class_%d\n", __qsfp_get_power_cls(self, 0)); - return 0; -} - - -int -fake_transvr_dump(struct transvr_obj_s* self) { - - printk(KERN_INFO "[SWPS] Dump transceiver information: %s\n", self->swp_name); - printk(KERN_INFO " |- :FAKE\n"); - printk(KERN_INFO " |- :FAKE_VENDER_NAME\n"); - printk(KERN_INFO " |- :FAKE_VENDER_PN\n"); - printk(KERN_INFO " |- :FAKE_VENDER_REV\n"); - printk(KERN_INFO " |- :FAKE_VENDER_SN\n"); - printk(KERN_INFO " |- :0x99\n"); - printk(KERN_INFO " |- :99\n"); - printk(KERN_INFO " |- :99\n"); - printk(KERN_INFO " |- :99\n"); - printk(KERN_INFO " |- :99\n"); - printk(KERN_INFO " |- :99\n"); - printk(KERN_INFO " |- :99\n"); - printk(KERN_INFO " '- :0x99\n"); - return 0; -} - - -/* ========== Object functions for fake type ========== - */ -int -fake_transvr_update(struct transvr_obj_s *self, - int show_err){ - self->state = STATE_TRANSVR_CONNECTED; - return 0; -} - - -int -fake_get_binary(struct transvr_obj_s *self){ - return 1; -} - -int -fake_get_int(struct transvr_obj_s *self){ - return 99; -} - - -int -fake_get_hex(struct transvr_obj_s *self){ - return 0x0f; -} - - -int -fake_get_str(struct transvr_obj_s *self, char *buf) { - return snprintf(buf, 16, "fake_get_str\n"); -} - - -int -fake_set_int(struct transvr_obj_s *self, int input){ - SWPS_INFO("%s: %d\n", __func__, input); - return 0; -} - - -int -fake_set_hex(struct transvr_obj_s *self, int input){ - SWPS_INFO("%s: 0x%02x\n", __func__, input); - return 0; -} - - -/* ========== Object functions for unsupported ========== - */ -int -unsupported_get_func(struct transvr_obj_s *self){ - return ERR_TRANSVR_NOTSUPPORT; -} - - -int -unsupported_get_func2(struct transvr_obj_s *self, - char *buf_p) { - int len = snprintf(buf_p, 8, "%d\n", ERR_TRANSVR_NOTSUPPORT); - return len; -} - - -int -unsupported_set_func(struct transvr_obj_s *self, - int input_val){ - return ERR_TRANSVR_NOTSUPPORT; -} - - - -/* ========== Object functions for long term task ========== - * - * [Note] - * SWPS transceiver worker is likely the green-thread (coroutine). - * Due to resource and performance considerations. SWPS run all - * features in one kthread at the same time, and handle by it self. - */ - -/* For Transceiver Task Handling - */ -static struct transvr_worker_s * -transvr_task_get(struct transvr_obj_s *self, - char *func_name) { - - struct transvr_worker_s *curr_p = self->worker_p; - - while(curr_p != NULL){ - if (strcmp((curr_p->func_name), func_name) == 0 ) { - return curr_p; - } - curr_p = curr_p->next_p; - } - return NULL; -} - - -static struct transvr_worker_s* -transvr_task_creat(struct transvr_obj_s *self, - int (*main_task)(struct transvr_worker_s *task), - int (*post_task)(struct transvr_worker_s *task), - char *caller) { - - struct transvr_worker_s *task_p = NULL; - struct transvr_worker_s *curr_p = NULL; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - - /* Check task not exist */ - task_p = transvr_task_get(self, caller); - if (task_p) { - snprintf(err_msg, sizeof(err_msg), "Task already created!"); - goto err_transvr_task_creat; - } - /* Create task worker */ - task_p = kzalloc(sizeof(struct transvr_worker_s), GFP_KERNEL); - if (!task_p){ - snprintf(err_msg, sizeof(err_msg), "kzalloc fail"); - goto err_transvr_task_creat; - } - /* Setup task data */ - task_p->transvr_p = self; - task_p->next_p = NULL; - task_p->trigger_time = 0; - task_p->retry = 1; - task_p->state = STATE_T_TASK_INIT; - task_p->main_task = main_task; - task_p->post_task = post_task; - task_p->p_data = NULL; - snprintf(task_p->func_name, sizeof(task_p->func_name), "%s", caller); - /* Setup Link List */ - if (self->worker_p) { - curr_p = self->worker_p; - while(curr_p->next_p != NULL) { - curr_p = curr_p->next_p; - } - curr_p->next_p = task_p; - task_p->pre_p = curr_p; - } else { - self->worker_p = task_p; - task_p->pre_p = NULL; - } - return task_p; - -err_transvr_task_creat: - SWPS_ERR("%s: %s :%s :%s\n", - __func__, err_msg, caller, self->swp_name); - return NULL; -} - - -static void -transvr_task_free_one(struct transvr_worker_s *task_p){ - - struct transvr_worker_s *pre_p = NULL; - struct transvr_worker_s *next_p = NULL; - - if (task_p) { - pre_p = task_p->pre_p; - next_p = task_p->next_p; - - if ((pre_p) && (next_p)) { - pre_p->next_p = next_p; - next_p->pre_p = pre_p; - - } else if ((!pre_p) && (next_p)) { - next_p->pre_p = NULL; - - } else if ((pre_p) && (!next_p)) { - pre_p->next_p = NULL; - - } else if ((!pre_p) && (!next_p)) { - task_p->transvr_p->worker_p = NULL; - } else { - SWPS_ERR("%s: Unexcept case!\n :%s", - __func__, task_p->transvr_p->swp_name); - } - kfree(task_p->p_data); - kfree(task_p); - } -} - - -static void -transvr_task_free_all(struct transvr_obj_s *self) { - - struct transvr_worker_s *curr_p = NULL; - struct transvr_worker_s *next_p = NULL; - - if (self->worker_p) { - curr_p = self->worker_p; - while(curr_p) { - next_p = curr_p->next_p; - transvr_task_free_one(curr_p); - curr_p = next_p; - } - self->worker_p = NULL; - } -} - - -static void -transvr_cache_free_all(struct transvr_obj_s *self) { - - memset(self->vendor_name, 0, (LEN_TRANSVR_M_STR * sizeof(char)) ); - memset(self->vendor_rev, 0, (LEN_TRANSVR_M_STR * sizeof(char)) ); - memset(self->vendor_pn, 0, (LEN_TRANSVR_M_STR * sizeof(char)) ); - memset(self->vendor_sn, 0, (LEN_TRANSVR_M_STR * sizeof(char)) ); - self->extphy_offset = 0; -} - -static int -_transvr_task_run_main(struct transvr_worker_s *task_p) { - - int retval = DEBUG_TRANSVR_INT_VAL; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - - if (!task_p){ - snprintf(err_msg, sizeof(err_msg), "main_task is NULL!"); - goto main_transvr_task_err; - } - if ((task_p->trigger_time) == 0){ - goto main_transvr_task_run; - } - if (time_before(jiffies, task_p->trigger_time)){ - goto main_transvr_task_wait; - } - goto main_transvr_task_run; - -main_transvr_task_run: - if (task_p->retry != VAL_TRANSVR_TASK_RETRY_FOREVER) { - task_p->retry -= 1; - } - retval = task_p->main_task(task_p); - if (retval < 0) { - if (task_p->retry > 0) { - task_p->state = STATE_T_TASK_WAIT; - return EVENT_TRANSVR_TASK_WAIT; - } - snprintf(err_msg, sizeof(err_msg), "Run main_task fail!"); - goto main_transvr_task_err; - } - goto main_transvr_task_identify; - -main_transvr_task_identify: - switch (retval) { - case EVENT_TRANSVR_TASK_WAIT: - task_p->state = STATE_T_TASK_WAIT; - return EVENT_TRANSVR_TASK_WAIT; - - case EVENT_TRANSVR_TASK_DONE: - task_p->state = STATE_T_TASK_DONE; - return EVENT_TRANSVR_TASK_DONE; - - default: - break; - } - snprintf(err_msg, sizeof(err_msg), "Run main_task fail!"); - goto main_transvr_task_err; - -main_transvr_task_wait: - task_p->state = STATE_T_TASK_WAIT; - return EVENT_TRANSVR_TASK_WAIT; - -main_transvr_task_err: - task_p->state = STATE_T_TASK_FAIL; - SWPS_INFO("%s: %s :%d :%s\n", - __func__, err_msg, retval, task_p->transvr_p->swp_name); - return EVENT_TRANSVR_INIT_FAIL; -} - - -static int -_transvr_task_run_post(struct transvr_worker_s *task_p) { - - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - - if ((task_p->post_task) == NULL) { - return EVENT_TRANSVR_TASK_DONE; - } - switch (task_p->state) { - case STATE_T_TASK_WAIT: - case STATE_T_TASK_INIT: - goto post_transvr_task_wait; - - case STATE_T_TASK_DONE: - case STATE_T_TASK_FAIL: - goto post_transvr_task_run; - - default: - break; - } - snprintf(err_msg, sizeof(err_msg), "Unexcept task state"); - goto post_transvr_task_err; - -post_transvr_task_run: - task_p->post_task(task_p); - return EVENT_TRANSVR_TASK_DONE; - -post_transvr_task_wait: - return EVENT_TRANSVR_TASK_WAIT; - -post_transvr_task_err: - SWPS_INFO("%s: %s :%d :%s\n", - __func__, err_msg, task_p->state, task_p->transvr_p->swp_name); - return EVENT_TRANSVR_TASK_FAIL; -} - - -static int -transvr_task_run_one(struct transvr_worker_s *task_p) { - - int retval_main = DEBUG_TRANSVR_INT_VAL; - int retval_post = DEBUG_TRANSVR_INT_VAL; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - - retval_main = _transvr_task_run_main(task_p); - if (retval_main < 0) { - snprintf(err_msg, sizeof(err_msg), "Execute main_task fail!"); - goto err_transvr_task_run_one; - } - retval_post = _transvr_task_run_post(task_p); - if (retval_post < 0) { - snprintf(err_msg, sizeof(err_msg), "Execute post_task fail!"); - goto err_transvr_task_run_one; - } - return retval_main; - -err_transvr_task_run_one: - SWPS_INFO("%s: %s
:%d :%d :%s :%s\n", - __func__, err_msg, retval_main, retval_post, - task_p->func_name, task_p->transvr_p->swp_name); - return EVENT_TRANSVR_TASK_FAIL; -} - - -static int -transvr_task_run_all(struct transvr_obj_s *self) { - - int haserr = 0; - int retval = DEBUG_TRANSVR_INT_VAL; - struct transvr_worker_s *curr_p = NULL; - struct transvr_worker_s *next_p = NULL; - - if ((self->worker_p) == NULL) { - return EVENT_TRANSVR_TASK_DONE; - } - curr_p = self->worker_p; - while (curr_p != NULL) { - next_p = curr_p->next_p; - retval = transvr_task_run_one(curr_p); - if (curr_p->retry == VAL_TRANSVR_TASK_RETRY_FOREVER) { - curr_p = next_p; - continue; - } - switch (retval) { - case EVENT_TRANSVR_TASK_WAIT: - break; - case EVENT_TRANSVR_TASK_DONE: - transvr_task_free_one(curr_p); - break; - case EVENT_TRANSVR_TASK_FAIL: - - default: - haserr = 1; - transvr_task_free_one(curr_p); - break; - } - curr_p = next_p; - } - if (haserr) { - return EVENT_TRANSVR_TASK_FAIL; - } - return EVENT_TRANSVR_TASK_DONE; -} - - -static void -transvr_task_set_delay(struct transvr_worker_s *task_p, - unsigned long delay_msec) { - - task_p->trigger_time = (jiffies + (delay_msec * (HZ/1000))); -} - - -static void -transvr_task_set_retry(struct transvr_worker_s *task_p, - unsigned long retry_times) { - - task_p->retry = retry_times; -} - - -/* For Transceiver Post Task - */ -int -taskfunc_post_do_nothing(struct transvr_worker_s *task_p) { - - return EVENT_TRANSVR_TASK_DONE; -} - - -int -taskfunc_post_handle_task_state(struct transvr_worker_s *task_p) { - - struct transvr_obj_s* tp = task_p->transvr_p; - - switch (task_p->state) { - case STATE_T_TASK_INIT: - case STATE_T_TASK_WAIT: - return EVENT_TRANSVR_TASK_WAIT; - - case STATE_T_TASK_DONE: - tp->state = STATE_TRANSVR_CONNECTED; - tp->send_uevent(tp, KOBJ_ADD); - return EVENT_TRANSVR_TASK_DONE; - - case STATE_T_TASK_FAIL: - tp->state = STATE_TRANSVR_UNEXCEPTED; - return EVENT_TRANSVR_TASK_FAIL; - - default: - break; - } - return EVENT_TRANSVR_TASK_FAIL; -} - - -/* For Transceiver Main Task - */ -int -_taskfunc_sfp_setup_soft_rs(struct transvr_worker_s *task_p, - int input_val, - int address, - int page, - int offset, - int bit_shift, - uint8_t *attr_p, - char *caller) { - - int show_err = 0; - int err_code = DEBUG_TRANSVR_INT_VAL; - char *err_str = DEBUG_TRANSVR_STR_VAL; - char *func_str = "_taskfunc_sfp_setup_soft_rs"; - - err_code = _sfp_update_attr_soft_rs0(task_p->transvr_p, 0); - if (err_code < 0) { - err_str = "Get current soft_rs0 fail!"; - goto err_taskfunc_sfp_setup_soft_rs_1; - } - err_code = __sfp_set_soft_rs(task_p->transvr_p, - input_val, - address, - page, - offset, - bit_shift, - attr_p, - caller, - show_err); - if (err_code < 0) { - err_str = "Get current soft_rs0 fail!"; - goto err_taskfunc_sfp_setup_soft_rs_1; - } - return EVENT_TRANSVR_TASK_DONE; - -err_taskfunc_sfp_setup_soft_rs_1: - if ((task_p->retry) == 0) { - SWPS_INFO("%s: %s :%s :%d :%d\n", - func_str, err_str, task_p->transvr_p->swp_name, input_val, err_code); - } - return EVENT_TRANSVR_TASK_FAIL; -} - - -int -__taskfunc_sfp_setup_hard_rs(struct transvr_worker_s *task_p, - int input_val, - int (*get_func)(struct ioexp_obj_s *self, int virt_offset), - int (*set_func)(struct ioexp_obj_s *self, int virt_offset, int input_val)) { - - int err_val = EVENT_TRANSVR_EXCEP_EXCEP; - char *err_str = DEBUG_TRANSVR_STR_VAL; - - err_val = get_func(task_p->transvr_p->ioexp_obj_p, - task_p->transvr_p->ioexp_virt_offset); - - if (err_val < 0) { - if (err_val == ERR_IOEXP_NOTSUPPORT) { - return EVENT_TRANSVR_TASK_DONE; - } - err_str = "Get current hard_rs fail!"; - goto err_p_taskfunc_sfp_setup_hard_rs_1; - } - if (err_val == input_val) { - return EVENT_TRANSVR_TASK_DONE; - } - err_val = set_func(task_p->transvr_p->ioexp_obj_p, - task_p->transvr_p->ioexp_virt_offset, - input_val); - if (err_val < 0) { - err_str = "Setup hard_rs fail!"; - goto err_p_taskfunc_sfp_setup_hard_rs_1; - } - return EVENT_TRANSVR_TASK_DONE; - -err_p_taskfunc_sfp_setup_hard_rs_1: - if ((task_p->retry) == 0) { - SWPS_INFO("%s: %s :%s :%d :%d\n", - __func__, err_str, task_p->transvr_p->swp_name, input_val, err_val); - } - return EVENT_TRANSVR_TASK_FAIL; -} - - -int -_taskfunc_sfp_setup_hard_rs0(struct transvr_worker_s *task_p, - int input_val) { - - return __taskfunc_sfp_setup_hard_rs(task_p, - input_val, - task_p->transvr_p->ioexp_obj_p->get_hard_rs0, - task_p->transvr_p->ioexp_obj_p->set_hard_rs0); -} - - -int -_taskfunc_sfp_setup_hard_rs1(struct transvr_worker_s *task_p, - int input_val) { - - return __taskfunc_sfp_setup_hard_rs(task_p, - input_val, - task_p->transvr_p->ioexp_obj_p->get_hard_rs1, - task_p->transvr_p->ioexp_obj_p->set_hard_rs1); -} - - -int -_taskfunc_sfp_setup_rs0(struct transvr_worker_s *task_p, - int input_val) { - - int bit_shift = 3; - int old_val = DEBUG_TRANSVR_INT_VAL; - int err_val = EVENT_TRANSVR_EXCEP_EXCEP; - char *err_str = DEBUG_TRANSVR_STR_VAL; - char *func_str = "_taskfunc_sfp_setup_rs0"; - - err_val = _taskfunc_sfp_setup_hard_rs0(task_p, - input_val); - if (err_val < 0) { - err_str = "Setup hard_rs0 fail!"; - goto err_private_taskfunc_sfp_setup_rs0_1; - } - old_val = err_val; - err_val = _taskfunc_sfp_setup_soft_rs(task_p, - input_val, - task_p->transvr_p->eeprom_map_p->addr_soft_rs0, - task_p->transvr_p->eeprom_map_p->page_soft_rs0, - task_p->transvr_p->eeprom_map_p->offset_soft_rs0, - bit_shift, - &(task_p->transvr_p->soft_rs0), - func_str); - if (err_val < 0) { - err_str = "Setup soft_rs0 fail!"; - goto err_private_taskfunc_sfp_setup_rs0_1; - } - return EVENT_TRANSVR_TASK_DONE; - -err_private_taskfunc_sfp_setup_rs0_1: - if ((task_p->retry) == 0) { - SWPS_INFO("%s: %s :%s :%d :%d\n", - func_str, err_str, task_p->transvr_p->swp_name, input_val, err_val); - } - _taskfunc_sfp_setup_hard_rs0(task_p, old_val); - return EVENT_TRANSVR_TASK_FAIL; -} - - -int -_taskfunc_sfp_setup_rs1(struct transvr_worker_s *task_p, - int input_val) { - - int bit_shift = 3; - int old_val = DEBUG_TRANSVR_INT_VAL; - int err_val = EVENT_TRANSVR_EXCEP_EXCEP; - char *err_str = DEBUG_TRANSVR_STR_VAL; - char *func_str = "_taskfunc_sfp_setup_rs1"; - - err_val = _taskfunc_sfp_setup_hard_rs1(task_p, - input_val); - if (err_val < 0) { - err_str = "Setup hard_rs1 fail!"; - goto err_private_taskfunc_sfp_setup_rs1_1; - } - old_val = err_val; - err_val = _taskfunc_sfp_setup_soft_rs(task_p, - input_val, - task_p->transvr_p->eeprom_map_p->addr_soft_rs1, - task_p->transvr_p->eeprom_map_p->page_soft_rs1, - task_p->transvr_p->eeprom_map_p->offset_soft_rs1, - bit_shift, - &(task_p->transvr_p->soft_rs1), - func_str); - if (err_val < 0) { - err_str = "Setup soft_rs1 fail!"; - goto err_private_taskfunc_sfp_setup_rs1_1; - } - return EVENT_TRANSVR_TASK_DONE; - -err_private_taskfunc_sfp_setup_rs1_1: - if ((task_p->retry) == 0) { - SWPS_INFO("%s: %s :%s :%d :%d\n", - func_str, err_str, task_p->transvr_p->swp_name, input_val, err_val); - } - _taskfunc_sfp_setup_hard_rs1(task_p, old_val); - return EVENT_TRANSVR_TASK_FAIL; -} - - -int -taskfunc_sfp_setup_SFF8431_case1(struct transvr_worker_s *task_p) { - /* SFF-8431 (8/4/2G Rx Rate_Select only) */ - int update_val = 1; - - return _taskfunc_sfp_setup_rs0(task_p, update_val); -} - - - -int -taskfunc_sfp_setup_SFF8431_case2(struct transvr_worker_s *task_p) { - /* SFF-8431 (8/4/2G Tx Rate_Select only) */ - int update_val = 1; - - return _taskfunc_sfp_setup_rs1(task_p, update_val); -} - - -int -taskfunc_sfp_setup_SFF8431_case3(struct transvr_worker_s *task_p) { - /* SFF-8431 (8/4/2G Independent Rx & Tx Rate_select) */ - int update_rs0 = 1; - int update_rs1 = 1; - int err_code = DEBUG_TRANSVR_INT_VAL; - - err_code = _taskfunc_sfp_setup_rs0(task_p, update_rs0); - if (err_code < 0) { - return err_code; - } - return _taskfunc_sfp_setup_rs1(task_p, update_rs1); -} - - -int -taskfunc_sfp_handle_1g_rj45(struct transvr_worker_s *task_p) { - - /* Not all of platform support 0x56 for transceiver - * external PHY, Support list as below: - * => 1. Magnolia-PVT (PS: EVT & DVT not ready) - */ - int ext_phy_addr = 0x56; - int ext_phy_page = -1; - int ext_phy_offs = 0x11; - int ext_phy_len = 1; - int lstate_mask = 0x04; /* 00000100 */ - int show_err = 0; - int fail_retry = 5; - int fail_delay = 1000; /* msec */ - int err_code = DEBUG_TRANSVR_INT_VAL; - uint8_t detect_val = DEBUG_TRANSVR_HEX_VAL; - char err_str[64] = DEBUG_TRANSVR_STR_VAL; - int *tmp_p = NULL; - char *func_name = "taskfunc_sfp_handle_1g_rj45"; - - if (task_p->transvr_p->state != STATE_TRANSVR_CONNECTED) { - return EVENT_TRANSVR_TASK_DONE; - } - if ( (task_p->transvr_p->info != TRANSVR_CLASS_BASE_T_1000) && - (task_p->transvr_p->info != TRANSVR_CLASS_BASE_T_1000_up) ) { - goto err_taskfunc_sfp_handle_1g_rj45_1; - } - err_code = _common_update_uint8_attr(task_p->transvr_p, - ext_phy_addr, - ext_phy_page, - ext_phy_offs, - ext_phy_len, - &detect_val, - func_name, - show_err); - if ( (err_code < 0) || - (detect_val == DEBUG_TRANSVR_HEX_VAL) ) { - snprintf(err_str, sizeof(err_str), "Detect external link status fail"); - goto err_taskfunc_sfp_handle_1g_rj45_2; - } - if ((detect_val & lstate_mask) == lstate_mask) { - goto ok_taskfunc_sfp_handle_1g_rj45_link_up; - } - goto ok_taskfunc_sfp_handle_1g_rj45_link_down; - -ok_taskfunc_sfp_handle_1g_rj45_link_up: - /* Filter out noise */ - if (!(task_p->p_data)) { - tmp_p = kzalloc(sizeof(int), GFP_KERNEL); - if (!tmp_p) { - snprintf(err_str, sizeof(err_str), "kzalloc p_data fail"); - goto err_taskfunc_sfp_handle_1g_rj45_2; - } - *tmp_p = TRANSVR_CLASS_BASE_T_1000_up; - task_p->p_data = tmp_p; - goto ok_taskfunc_sfp_handle_1g_rj45_done; - } - if ((*(int *)(task_p->p_data)) != TRANSVR_CLASS_BASE_T_1000_up) { - kfree(task_p->p_data); - task_p->p_data = NULL; - snprintf(err_str, sizeof(err_str), "Internal error"); - goto err_taskfunc_sfp_handle_1g_rj45_2; - } - task_p->transvr_p->info = TRANSVR_CLASS_BASE_T_1000_up; - kfree(task_p->p_data); - task_p->p_data = NULL; - goto ok_taskfunc_sfp_handle_1g_rj45_done; - -ok_taskfunc_sfp_handle_1g_rj45_link_down: - if (task_p->p_data) { - kfree(task_p->p_data); - task_p->p_data = NULL; - } - task_p->transvr_p->info = TRANSVR_CLASS_BASE_T_1000; - goto ok_taskfunc_sfp_handle_1g_rj45_done; - -ok_taskfunc_sfp_handle_1g_rj45_done: - if (task_p->retry != VAL_TRANSVR_TASK_RETRY_FOREVER) { - transvr_task_set_retry(task_p, VAL_TRANSVR_TASK_RETRY_FOREVER); - } - return EVENT_TRANSVR_TASK_DONE; - -err_taskfunc_sfp_handle_1g_rj45_1: - snprintf(err_str, sizeof(err_str), "Detect transceiver:%d not Base-T, remove task.", - task_p->transvr_p->info); - SWPS_INFO("%s: %s :%s\n", __func__, err_str, task_p->transvr_p->swp_name); - transvr_task_set_retry(task_p, 0); - return EVENT_TRANSVR_TASK_DONE; - -err_taskfunc_sfp_handle_1g_rj45_2: - if (task_p->retry == VAL_TRANSVR_TASK_RETRY_FOREVER) { - transvr_task_set_retry(task_p, fail_retry); - } - if ((task_p->retry) == 0) { - /* Error case: - * => In this case, SWPS will stop external Link state monitor features - * and keeps transvr_p->info on TRANSVR_CLASS_BASE_T_1000_up. - * Upper layer will see it always Linkup that because of these type of - * transceiver has external phy, BCM chip see it as Loopback transceiver. - */ - SWPS_WARN("%s can not access external PHY of Base-T SFP transceiver\n", - task_p->transvr_p->swp_name); - task_p->transvr_p->info = TRANSVR_CLASS_BASE_T_1000_up; - return EVENT_TRANSVR_TASK_DONE; - } else { - transvr_task_set_delay(task_p, fail_delay); - } - return EVENT_TRANSVR_TASK_FAIL; -} - - -int -_taskfunc_qsfp_setup_power_mod(struct transvr_obj_s *self, - int setup_val) { - - int curr_val = DEBUG_TRANSVR_INT_VAL; - int err_val = DEBUG_TRANSVR_INT_VAL; - char *err_msg = DEBUG_TRANSVR_STR_VAL; - - curr_val = self->ioexp_obj_p->get_lpmod(self->ioexp_obj_p, - self->ioexp_virt_offset); - if (curr_val < 0){ - err_msg = "Get current value fail!"; - goto err_private_taskfunc_qsfp_setup_power_mod_1; - } - if (curr_val == setup_val){ - return EVENT_TRANSVR_TASK_DONE; - } - err_val = self->ioexp_obj_p->set_lpmod(self->ioexp_obj_p, - self->ioexp_virt_offset, - setup_val); - if (err_val < 0){ - err_msg = "Setup power mode fail!"; - goto err_private_taskfunc_qsfp_setup_power_mod_1; - } - return EVENT_TRANSVR_TASK_DONE; - -err_private_taskfunc_qsfp_setup_power_mod_1: - SWPS_INFO("%s: %s :%d :%d :%d\n", - __func__, err_msg, err_val, curr_val, setup_val); - return EVENT_TRANSVR_TASK_FAIL; -} - - -int -taskfunc_qsfp_handle_tx_disable(struct transvr_worker_s *task_p) { - - int i = 0; - int retry = 5; - int delay_ms = 100; - - if (task_p->transvr_p->auto_tx_disable == VAL_TRANSVR_FUNCTION_DISABLE) { - return EVENT_TRANSVR_TASK_DONE; - } - if (!_qsfp_is_implement_tx_disable(task_p->transvr_p)) { - return EVENT_TRANSVR_TASK_DONE; - } - for (i=0; itransvr_p, - task_p->transvr_p->auto_tx_disable) - == EVENT_TRANSVR_TASK_DONE) { - goto ok_taskfunc_qsfp_handle_tx_disable; - } - mdelay(delay_ms); - } - SWPS_INFO("%s auto setup tx_disable:0x%02x fail.\n", - task_p->transvr_p->swp_name, - task_p->transvr_p->auto_tx_disable); - return EVENT_TRANSVR_INIT_FAIL; - -ok_taskfunc_qsfp_handle_tx_disable: - SWPS_INFO("%s auto setup tx_disable:0x%02x ok.\n", - task_p->transvr_p->swp_name, - task_p->transvr_p->auto_tx_disable); - return EVENT_TRANSVR_TASK_DONE; -} - - -int -taskfunc_qsfp_set_hpmod(struct transvr_worker_s *task_p) { - - int err = DEBUG_TRANSVR_INT_VAL; - int HIGH_POWER_MODE = 0; - - /* Handle power mode */ - err = _taskfunc_qsfp_setup_power_mod(task_p->transvr_p, - HIGH_POWER_MODE); - if (err < 0) { - SWPS_INFO("%s: setup hpmod fail :%d :%s\n", - __func__, err, task_p->transvr_p->swp_name); - return err; - } - /* Handle auto tx_disable - * [Note] - * => Because there are some transceiver have timing issues or - * setup sequence issues, therefore we handle auto tx_disable - * after handle power mode. - */ - mdelay(100); - return taskfunc_qsfp_handle_tx_disable(task_p); -} - - -int -taskfunc_qsfp_set_lpmod(struct transvr_worker_s *task_p) { - - int LOW_POWER_MODE = 1; - return _taskfunc_qsfp_setup_power_mod(task_p->transvr_p, - LOW_POWER_MODE); -} - - -static int -initfunc_sfp_handle_multi_rate_mode(struct transvr_obj_s *self) { - - int task_retry = 3; - int err_code = DEBUG_TRANSVR_INT_VAL; - char *err_str = DEBUG_TRANSVR_STR_VAL; - char *func_str = "sfp_handle_multi_rate_mode"; - struct transvr_worker_s *task_p = NULL; - - switch (self->rate_id) { - case 0x00: /* Unspecified */ - case 0x03: /* Unspecified */ - case 0x05: /* Unspecified */ - case 0x07: /* Unspecified */ - case 0x09: /* Unspecified */ - case 0x0B: /* Unspecified */ - case 0x0D: /* Unspecified */ - case 0x0F: /* Unspecified */ - goto sfp_handle_multi_rate_mode_4_unspecified; - - case 0x02: /* SFF-8431 (8/4/2G Rx Rate_Select only) */ - task_p = transvr_task_creat(self, - taskfunc_sfp_setup_SFF8431_case1, - taskfunc_post_handle_task_state, - func_str); - goto sfp_handle_multi_rate_mode_4_sff8431; - - case 0x04: /* SFF-8431 (8/4/2G Tx Rate_Select only) */ - task_p = transvr_task_creat(self, - taskfunc_sfp_setup_SFF8431_case2, - taskfunc_post_handle_task_state, - func_str); - goto sfp_handle_multi_rate_mode_4_sff8431; - - case 0x06: /* SFF-8431 (8/4/2G Independent Rx & Tx Rate_select) */ - task_p = transvr_task_creat(self, - taskfunc_sfp_setup_SFF8431_case3, - taskfunc_post_handle_task_state, - func_str); - goto sfp_handle_multi_rate_mode_4_sff8431; - - case 0x01: /* SFF-8079 (4/2/1G Rate_Select & AS0/AS1) */ - err_str = "SFF-8079 (4/2/1G Rate_Select & AS0/AS1)"; - goto sfp_handle_multi_rate_mode_4_not_support; - - case 0x08: /* FC-PI-5 (16/8/4G Rx Rate_select only) - * High=16G only, Low=8G/4G - */ - err_str = "FC-PI-5 (16/8/4G Rx Rate_select only)"; - goto sfp_handle_multi_rate_mode_4_not_support; - - case 0x0A: /* FC-PI-5 (16/8/4G Independent Rx, Tx Rate_select) - * High=16G only, Low=8G/4G - */ - err_str = "FC-PI-5 (16/8/4G Independent Rx, Tx Rate_select)"; - goto sfp_handle_multi_rate_mode_4_not_support; - - case 0x0C: /* FC-PI-6 (32/16/8G Independent Rx, Tx Rate_Select) - * High=32G only, Low = 16G/8G - */ - err_str = "FC-PI-6 (32/16/8G Independent Rx, Tx Rate_Select)"; - goto sfp_handle_multi_rate_mode_4_not_support; - - case 0x0E: /* 10/8G Rx and Tx Rate_Select controlling the operation or - * locking modes of the internal signal conditioner, retimer - * or CDR, according to the logic table defined in Table 10-2, - * High Bit Rate (10G) =9.95-11.3 Gb/s; Low Bit Rate (8G) = - * 8.5 Gb/s. In this mode, the default value of bit 110.3 (Soft - * Rate Select RS(0), Table 9-11) and of bit 118.3 (Soft Rate - * Select RS(1), Table 10-1) is 1. - */ - err_str = "cable type: 0x0E"; - goto sfp_handle_multi_rate_mode_4_not_support; - - default: - err_str = "cable type: UNKNOW"; - goto sfp_handle_multi_rate_mode_4_not_support; - } - -sfp_handle_multi_rate_mode_4_sff8431: - if (!task_p) { - err_str = "Create task fail!"; - goto sfp_handle_multi_rate_mode_4_fail_1; - } - transvr_task_set_retry(task_p, task_retry); - return EVENT_TRANSVR_TASK_WAIT; - -sfp_handle_multi_rate_mode_4_unspecified: - return EVENT_TRANSVR_TASK_DONE; - -sfp_handle_multi_rate_mode_4_not_support: - SWPS_INFO("%s: Does not support %s :%s :0x%02x\n", - func_str, err_str, self->swp_name, self->rate_id); - return EVENT_TRANSVR_TASK_DONE; - -sfp_handle_multi_rate_mode_4_fail_1: - SWPS_INFO("%s: %s :%s :0x%02x, :%d\n", - func_str, err_str, self->swp_name, self->rate_id, err_code); - return EVENT_TRANSVR_INIT_FAIL; -} - - -static int -initfunc_sfp_handle_1g_rj45(struct transvr_obj_s *self) { - - struct transvr_worker_s *task_p = NULL; - int detect_cls = DEBUG_TRANSVR_INT_VAL; - char err_str[64] = DEBUG_TRANSVR_STR_VAL; - char *func_str = "initfunc_sfp_handle_1g_rj45"; - - - if (self->info == TRANSVR_CLASS_BASE_T_1000) { - task_p = transvr_task_creat(self, - taskfunc_sfp_handle_1g_rj45, - taskfunc_post_do_nothing, - func_str); - if (!task_p) { - snprintf(err_str, sizeof(err_str), "Create task fail"); - goto err_initfunc_sfp_handle_1g_rj45; - } - transvr_task_set_retry(task_p, VAL_TRANSVR_TASK_RETRY_FOREVER); - } - return EVENT_TRANSVR_TASK_DONE; - -err_initfunc_sfp_handle_1g_rj45: - SWPS_INFO("%s: %s :%s :%d\n", - __func__, err_str, self->swp_name, detect_cls); - return EVENT_TRANSVR_TASK_FAIL; -} - - -static int -initfunc_qsfp_handle_power_mode(struct transvr_obj_s *self) { - - int err_code = EVENT_TRANSVR_EXCEP_INIT; - int power_class = DEBUG_TRANSVR_INT_VAL; - int hpmod_retry = 3; - int lpower_config = 1; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - unsigned long hpmod_delay = 500; /* msec */ - struct transvr_worker_s *task_p = NULL; - - /* Handle power mode for IOEXP */ - power_class = __qsfp_get_power_cls(self, 0); - switch (power_class) { - case 1: /* Case: Low power mode (Class = 1) */ - err_code = _taskfunc_qsfp_setup_power_mod(self, lpower_config); - if (err_code < 0){ - snprintf(err_msg, sizeof(err_msg), "Setup lpmod fail :%d", err_code); - goto err_initfunc_qsfp_handle_power_mode; - } - return EVENT_TRANSVR_TASK_DONE; - - case 2: /* Case: High power mode (Class > 1) */ - case 3: - case 4: - case 5: - case 6: - case 7: - task_p = transvr_task_creat(self, - taskfunc_qsfp_set_hpmod, - taskfunc_post_handle_task_state, - "transvr_init_qsfp"); - if (!task_p) { - snprintf(err_msg, sizeof(err_msg), "Setup lpmod fail :%d", err_code); - goto err_initfunc_qsfp_handle_power_mode; - } - transvr_task_set_retry(task_p, hpmod_retry); - transvr_task_set_delay(task_p, hpmod_delay); - return EVENT_TRANSVR_TASK_WAIT; - - default: - break; - } - snprintf(err_msg, sizeof(err_msg), "Exception case"); - goto err_initfunc_qsfp_handle_power_mode; - -err_initfunc_qsfp_handle_power_mode: - SWPS_INFO("%s: %s :%s \n", __func__, err_msg, self->swp_name); - return EVENT_TRANSVR_INIT_FAIL; -} - - -int -initfunc_qsfp28_handle_cdr(struct transvr_obj_s *self) { - - uint8_t DEFAULT_VAL_CDR = 0xff; - int CDR_FUNC_EXISTED = 0x3; - int show_err = 1; - int err_val = EVENT_TRANSVR_TASK_FAIL; - char *err_msg = DEBUG_TRANSVR_STR_VAL; - char *func_str = "initfunc_qsfp28_handle_cdr"; - - err_val = __qsfp_get_cdr_present(self, 0); - if ( (err_val < 0) || - (err_val == DEBUG_TRANSVR_HEX_VAL) ) { - err_msg = "detect cdr_present fail!"; - goto err_taskfunc_qsfp_handle_cdr_1; - } - if (err_val == CDR_FUNC_EXISTED) { - err_val = _common_set_uint8_attr(self, - self->eeprom_map_p->addr_cdr, - self->eeprom_map_p->addr_cdr, - self->eeprom_map_p->offset_cdr, - DEFAULT_VAL_CDR, - &(self->cdr), - func_str, - show_err); - if (err_val < 0) { - err_msg = "set CDR fail!"; - goto err_taskfunc_qsfp_handle_cdr_1; - } - } - return EVENT_TRANSVR_TASK_DONE; - -err_taskfunc_qsfp_handle_cdr_1: - SWPS_INFO("%s: %s :%d :%s\n", - func_str, err_msg, err_val, self->swp_name); - return EVENT_TRANSVR_INIT_FAIL; -} - -/* ========== Object functions for Final State Machine ========== - */ -int -is_plugged(struct transvr_obj_s *self){ - - int limit = 63; - int present = DEBUG_TRANSVR_INT_VAL; - char emsg[64] = DEBUG_TRANSVR_STR_VAL; - struct ioexp_obj_s *ioexp_p = self->ioexp_obj_p; - - if (!ioexp_p) { - snprintf(emsg, limit, "ioexp_p is null!"); - goto err_is_plugged_1; - } - present = ioexp_p->get_present(ioexp_p, self->ioexp_virt_offset); - switch (present){ - case 0: - return 1; - case 1: - return 0; - case ERR_IOEXP_UNINIT: - snprintf(emsg, limit, "ioexp_p not ready!"); - goto err_is_plugged_1; - default: - if (ioexp_p->state == STATE_IOEXP_INIT){ - snprintf(emsg, limit, "ioexp_p not ready!"); - goto err_is_plugged_1; - } - break; - } - SWPS_INFO("%s: Exception case! :%d :%d\n", - __func__, present, ioexp_p->state); - return 0; - -err_is_plugged_1: - SWPS_DEBUG("%s: %s\n", __func__, emsg); - return 0; -} - - -static int -detect_transvr_type(struct transvr_obj_s* self){ - - int type = TRANSVR_TYPE_ERROR; - - self->i2c_client_p->addr = VAL_TRANSVR_COMID_ARREESS; - type = i2c_smbus_read_byte_data(self->i2c_client_p, - VAL_TRANSVR_COMID_OFFSET); - - /* Case: 1. Wait transceiver I2C module. - * 2. Transceiver I2C module failure. - * Note: 1. SFF allow maximum transceiver initial time is 2 second. So, there - * are exist some case that we need to wait transceiver. - * For these case, we keeps status on "TRANSVR_TYPE_UNPLUGGED", than - * state machine will keep trace with it. - * 2. There exist some I2C failure case we need to handle. Such as user - * insert the failure transceiver, or any reason cause it abnormal. - */ - if (type < 0){ - switch (type) { - case -EIO: - SWPS_DEBUG("%s: %s smbus return:-5 (I/O error)\n", - __func__, self->swp_name); - return TRANSVR_TYPE_UNPLUGGED; - case -ENXIO: - SWPS_DEBUG("%s: %s smbus return:-6 (No such device or address)\n", - __func__, self->swp_name); - return TRANSVR_TYPE_UNPLUGGED; - default: - break; - } - SWPS_INFO("%s: %s unexpected smbus return:%d \n", - __func__, self->swp_name, type); - return TRANSVR_TYPE_ERROR; - } - /* Identify valid transceiver type */ - switch (type){ - case TRANSVR_TYPE_SFP: - case TRANSVR_TYPE_QSFP: - case TRANSVR_TYPE_QSFP_PLUS: - case TRANSVR_TYPE_QSFP_28: - break; - case TRANSVR_TYPE_UNKNOW_1: - case TRANSVR_TYPE_UNKNOW_2: - type = TRANSVR_TYPE_UNKNOW_2; - break; - default: - SWPS_DEBUG("%s: unknow type:0x%02x \n", __func__, type); - type = TRANSVR_TYPE_ERROR; - break; - } - return type; -} - - -static int -detect_transvr_state(struct transvr_obj_s *self, - int result[2]){ - /* [return] [result-0] [result-1] - * 0 STATE_TRANSVR_CONNECTED TRANSVR_TYPE_FAKE - * 0 STATE_TRANSVR_DISCONNECTED TRANSVR_TYPE_UNPLUGGED - * 0 STATE_TRANSVR_ISOLATED TRANSVR_TYPE_ERROR - * 0 STATE_TRANSVR_INIT / - * 0 STATE_TRANSVR_SWAPPED - * 0 STATE_TRANSVR_CONNECTED - * ERR_TRNASVR_BE_ISOLATED STATE_TRANSVR_ISOLATED TRANSVR_TYPE_ERROR - * ERR_TRANSVR_I2C_CRASH STATE_TRANSVR_UNEXCEPTED TRANSVR_TYPE_ERROR - * ERR_TRANSVR_UNEXCPT STATE_TRANSVR_UNEXCEPTED TRANSVR_TYPE_UNKNOW_1/2 - */ - result[0] = STATE_TRANSVR_UNEXCEPTED; /* For return state */ - result[1] = TRANSVR_TYPE_ERROR; /* For return type */ - - /* Case1: Fake type */ - if (self->type == TRANSVR_TYPE_FAKE){ - result[0] = STATE_TRANSVR_CONNECTED; - result[1] = TRANSVR_TYPE_FAKE; - return 0; - } - /* Case2: Transceiver unplugged */ - if (!is_plugged(self)){ - result[0] = STATE_TRANSVR_DISCONNECTED; - result[1] = TRANSVR_TYPE_UNPLUGGED; - return 0; - } - /* Case3: Transceiver be isolated */ - if (self->state == STATE_TRANSVR_ISOLATED){ - result[0] = STATE_TRANSVR_ISOLATED; - result[1] = TRANSVR_TYPE_ERROR; - return ERR_TRNASVR_BE_ISOLATED; - } - /* Case4: Transceiver plugged */ - result[1] = detect_transvr_type(self); - /* Case4.1: I2C topology crash - * Note : There are some I2C issues cause by transceiver/cables. - * We need to check topology status when user insert it. - * But in this step, we can't not ensure this is the issues - * port. So, it return the ERR_TRANSVR_I2C_CRASH, then upper - * layer will diagnostic I2C topology. - */ - if (check_channel_tier_1() < 0) { - SWPS_INFO("%s: %s detect I2C crash :%d\n", - __func__, self->swp_name, self->state); - result[0] = STATE_TRANSVR_UNEXCEPTED; - result[1] = TRANSVR_TYPE_ERROR; - return ERR_TRANSVR_I2C_CRASH; - } - /* Case4.2: System initial not ready, - * Note : Sometime i2c channel or transceiver EEPROM will delay that will - * cause system in inconsistent state between EEPROM and IOEXP. - * In this case, SWP transceiver object keep state at LINK_DOWN - * to wait system ready. - * By the way, State Machine will handle these case. - */ - if (result[1] == TRANSVR_TYPE_UNPLUGGED){ - result[0] = STATE_TRANSVR_DISCONNECTED; - return 0; - } - /* Case4.3: Error transceiver type */ - if (result[1] == TRANSVR_TYPE_ERROR){ - result[0] = STATE_TRANSVR_ISOLATED; - SWPS_INFO("%s: %s detect error type\n", __func__, self->swp_name); - alarm_msg_2_user(self, "detected transceiver/cables not meet SFF standard!"); - return ERR_TRNASVR_BE_ISOLATED; - } - /* Case3.3: Unknow transceiver type */ - if ((result[1] == TRANSVR_TYPE_UNKNOW_1) || - (result[1] == TRANSVR_TYPE_UNKNOW_2) ){ - result[0] = STATE_TRANSVR_UNEXCEPTED; - return ERR_TRANSVR_UNEXCPT; - } - /* Case3.4: During initial process */ - if (self->state == STATE_TRANSVR_INIT){ - result[0] = STATE_TRANSVR_INIT; - return 0; - } - /* Case3.5: Transceiver be swapped */ - if (self->type != result[1]){ - result[0] = STATE_TRANSVR_SWAPPED; - return 0; - } - /* Case3.6: Link up state */ - result[0] = STATE_TRANSVR_CONNECTED; - return 0; -} - - -int -_sfp_detect_class_by_extend_comp(struct transvr_obj_s* self) { - /* Reference: SFF-8024 (v3.8) - */ - int detect_val = _sfp_get_comp_extended(self); - - switch(detect_val) { - case 0x00: /* Unspecified */ - return TRANSVR_CLASS_UNSPECIFIED; - - case 0x01: /* 100G AOC (Active Optical Cable) or 25GAUI C2M */ - case 0x18: /* 100G AOC or 25GAUI C2M AOC. */ - return TRANSVR_CLASS_OPTICAL_25G_AOC; - - case 0x02: /* 100GBASE-SR4 or 25GBASE-SR */ - return TRANSVR_CLASS_OPTICAL_25G_SR; - - case 0x03: /* 100GBASE-LR4 or 25GBASE-LR */ - return TRANSVR_CLASS_OPTICAL_25G_LR; - - case 0x04: /* 100GBASE-ER4 or 25GBASE-ER */ - return TRANSVR_CLASS_OPTICAL_25G_ER; - - case 0x08: /* 100G ACC (Active Copper Cable) or 25GAUI C2M ACC. */ - case 0x0b: /* 100GBASE-CR4 or 25GBASE-CR CA-L */ - case 0x0c: /* 25GBASE-CR CA-S */ - case 0x0d: /* 25GBASE-CR CA-N */ - case 0x19: /* 100G ACC or 25GAUI C2M ACC. */ - return TRANSVR_CLASS_COPPER_L1_25G; - - default: - break; - } - SWPS_INFO("%s: Unexcept value:0x%02x\n :%s", - __func__, detect_val, self->swp_name); - return TRANSVR_CLASS_ERROR; -} - - -int -_sfp_detect_class_by_10_ethernet(struct transvr_obj_s* self) { - /* Reference: SFF-8472 (v12.2) - */ - int detect_val = DEBUG_TRANSVR_INT_VAL; - - detect_val = _sfp_get_comp_10g_eth_comp(self); - /* Case: Unspecified */ - if (detect_val == 0x00) { - return TRANSVR_CLASS_UNSPECIFIED; - } - /* Case: 10G Optical (x1) */ - if ((detect_val & 0x10) == 0x10) { /* 00010000 : 10GBASE-SR */ - return TRANSVR_CLASS_OPTICAL_10G_S_SR; - } - if ( ((detect_val & 0x20) == 0x20) || /* 00100000 : 10GBASE-LR */ - ((detect_val & 0x40) == 0x40) ){ /* 01000000 : 10GBASE-LRM */ - return TRANSVR_CLASS_OPTICAL_10G_S_LR; - } - if ((detect_val & 0x80) == 0x80) { /* 10000000 : 10GBASE-ER */ - return TRANSVR_CLASS_OPTICAL_10G_S_ER; - } - /* Case: ERROR */ - SWPS_INFO("%s: Unexcept value:0x%02x\n :%s", - __func__, detect_val, self->swp_name); - return TRANSVR_CLASS_ERROR; -} - - -int -_sfp_detect_if_sp_by_br(struct transvr_obj_s* self) { - - int lower_bound_1g = 0x0b; - int upper_bound_1g = 0x1A; - int lower_bound_10g = 0x60; - int upper_bound_10g = 0x75; - int lower_bound_25g = 0xf0; - int upper_bound_25g = 0xff; - int notmal_br = DEBUG_TRANSVR_INT_VAL; - - notmal_br = (int)(self->br); /* updated by update_all() */ - /* Check 25G */ - if ((notmal_br >= lower_bound_25g) && - (notmal_br <= upper_bound_25g) ) { - return TRANSVR_CLASS_25G; - } - /* Check 10G */ - if ((notmal_br >= lower_bound_10g) && - (notmal_br <= upper_bound_10g) ) { - return TRANSVR_CLASS_10G; - } - /* Check 1G */ - if ((notmal_br >= lower_bound_1g) && - (notmal_br <= upper_bound_1g) ) { - return TRANSVR_CLASS_1G; - } - return TRANSVR_CLASS_UNSPECIFIED; -} - - -int -_sfp_detect_class_by_1g_ethernet(struct transvr_obj_s* self) { - /* Reference: SFF-8472 (v12.2) - */ - int detect_val = DEBUG_TRANSVR_INT_VAL; - int speed_br = DEBUG_TRANSVR_INT_VAL; - int speed_tmp = DEBUG_TRANSVR_INT_VAL; - char err_str[64] = DEBUG_TRANSVR_STR_VAL; - - speed_br = _sfp_detect_if_sp_by_br(self); - detect_val = _sfp_get_comp_1g_eth_comp(self); - - if (detect_val < 0) { - snprintf(err_str, sizeof(err_str), "Detect abnormal value:%d", detect_val); - goto err_p_sfp_detect_class_by_1g_ethernet; - } - /* Case: Unspecified */ - if (detect_val == 0x00) { - return TRANSVR_CLASS_UNSPECIFIED; - } - /* Case: 1G (x1) */ - if ((detect_val & 0x01) == 0x01) { /* 00000001 : 1000BASE-SX */ - speed_tmp = TRANSVR_CLASS_OPTICAL_1G_SX; - goto ok_sfp_detect_class_by_1g_ethernet_4_check_br_10g; - } - if ((detect_val & 0x02) == 0x02) { /* 00000010 : 1000BASE-LX *3 */ - speed_tmp = TRANSVR_CLASS_OPTICAL_1G_LX; - goto ok_sfp_detect_class_by_1g_ethernet_4_check_br_10g; - } - if ((detect_val & 0x04) == 0x04) { /* 00000100 : 1000BASE-CX */ - speed_tmp = TRANSVR_CLASS_COPPER_L1_1G; - goto ok_sfp_detect_class_by_1g_ethernet_4_check_br_10g; - } - /* Case: 1000 Base-T (x1) */ - if ((detect_val & 0x08) == 0x08) { /* 00001000 : 1000BASE-T */ - return TRANSVR_CLASS_BASE_T_1000; - } - /* Case: 100 Base */ - if ( ((detect_val & 0x10) == 0x10) || /* 00010000 : 100BASE-LX/LX10 */ - ((detect_val & 0x20) == 0x20) || /* 00100000 : 100BASE-FX */ - ((detect_val & 0x40) == 0x40) || /* 01000000 : BASE-BX10 *3 */ - ((detect_val & 0x80) == 0x80) ){ /* 10000000 : BASE-PX *3 */ - return TRANSVR_CLASS_OPTICAL_100; - } - /* Case: ERROR */ - snprintf(err_str, sizeof(err_str), "Case:ERROR, value:%d", detect_val); - goto err_p_sfp_detect_class_by_1g_ethernet; - -ok_sfp_detect_class_by_1g_ethernet_4_check_br_10g: - switch (speed_br) { - case TRANSVR_CLASS_UNSPECIFIED: - case TRANSVR_CLASS_1G: - return speed_tmp; - case TRANSVR_CLASS_10G: - goto ok_sfp_detect_class_by_1g_ethernet_4_transfer_10G; - } - -ok_sfp_detect_class_by_1g_ethernet_4_transfer_10G: - switch (speed_tmp) { - case TRANSVR_CLASS_OPTICAL_1G_SX: - return TRANSVR_CLASS_OPTICAL_10G_S_SR; - case TRANSVR_CLASS_OPTICAL_1G_LX: - return TRANSVR_CLASS_OPTICAL_10G_S_LR; - case TRANSVR_CLASS_COPPER_L1_1G: - return TRANSVR_CLASS_COPPER_L1_10G; - default: - break; - } - snprintf(err_str, sizeof(err_str), "transfer_1to10 fail, speed:%d", speed_tmp); - goto err_p_sfp_detect_class_by_1g_ethernet; - -err_p_sfp_detect_class_by_1g_ethernet: - SWPS_INFO("%s: %s :%s", __func__, err_str, self->swp_name); - return TRANSVR_CLASS_ERROR; -} - - -int -_sfp_detect_class_by_feature(struct transvr_obj_s* self) { - /* Reference: SFF-8024 (v3.8) - */ - int is_active = 0; - int conn_val = DEBUG_TRANSVR_INT_VAL; - int check_val = DEBUG_TRANSVR_INT_VAL; - int wave_len = DEBUG_TRANSVR_INT_VAL; - int speed_val = DEBUG_TRANSVR_INT_VAL; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - - speed_val = _sfp_detect_if_sp_by_br(self); - conn_val = _sfp_get_connector_type(self); - - switch(conn_val) { - case 0x00: /* Unspecified */ - goto ok_sfp_detect_class_by_feature_4_check_active_passive; - case 0x07: /* LC (Lucent Connector) */ - case 0x0b: /* Optical Pigtail */ - case 0x0c: /* MPO 1x12 */ - case 0x0d: /* MPO 2x16 */ - /* - * ToDo: Need verify Optical Pigtail - */ - goto ok_sfp_detect_class_by_feature_4_optiocal; - case 0x21: /* Copper pigtail */ - /* - * ToDo: Need check ACC use case - */ - goto ok_sfp_detect_class_by_feature_4_check_active_passive; - case 0x23: /* No separable connector */ - /* - * ToDo: Standard not clear, not all transceiver vendor - * have the same defined - */ - goto ok_sfp_detect_class_by_feature_4_check_active_passive; - default: - break; - } - goto ok_sfp_detect_class_by_feature_4_unknow; - -ok_sfp_detect_class_by_feature_4_check_active_passive: - check_val = _sfp_get_cable_tech(self); - switch(check_val) { - case 0x00: /* Unspecified */ - goto ok_sfp_detect_class_by_feature_4_unknow; - case 0x04: /* Passive */ - goto ok_sfp_detect_class_by_feature_4_copper; - case 0x08: /* Active */ - is_active = 1; - goto ok_sfp_detect_class_by_feature_4_aoc; - default: - snprintf(err_msg, sizeof(err_msg), - "_sfp_get_cable_tech return Non define value:%d", - check_val); - break; - } - goto err_sfp_detect_class_by_feature_1; - -ok_sfp_detect_class_by_feature_4_optiocal: - wave_len = _common_count_wavelength(self, - self->wavelength[0], - self->wavelength[1]); - switch(speed_val) { - case TRANSVR_CLASS_25G: - switch (wave_len) { - case VAL_OPTICAL_WAVELENGTH_SR: - return TRANSVR_CLASS_OPTICAL_25G_SR; - case VAL_OPTICAL_WAVELENGTH_LR: - return TRANSVR_CLASS_OPTICAL_25G_LR; - case VAL_OPTICAL_WAVELENGTH_ER: - return TRANSVR_CLASS_OPTICAL_25G_ER; - default: - break; - } - return TRANSVR_CLASS_OPTICAL_25G; - - case TRANSVR_CLASS_10G: - switch (wave_len) { - case VAL_OPTICAL_WAVELENGTH_SR: - return TRANSVR_CLASS_OPTICAL_10G_S_SR; - case VAL_OPTICAL_WAVELENGTH_LR: - return TRANSVR_CLASS_OPTICAL_10G_S_LR; - case VAL_OPTICAL_WAVELENGTH_ER: - return TRANSVR_CLASS_OPTICAL_10G_S_ER; - default: - break; - } - return TRANSVR_CLASS_OPTICAL_10G; - - case TRANSVR_CLASS_1G: - switch (wave_len) { - case VAL_OPTICAL_WAVELENGTH_SR: - return TRANSVR_CLASS_OPTICAL_1G_SX; - case VAL_OPTICAL_WAVELENGTH_LR: - return TRANSVR_CLASS_OPTICAL_1G_LX; - case VAL_OPTICAL_WAVELENGTH_ER: - return TRANSVR_CLASS_OPTICAL_1G_EX; - default: - break; - } - return TRANSVR_CLASS_OPTICAL_1G; - - default: - return TRANSVR_CLASS_OPTICAL; - } - -ok_sfp_detect_class_by_feature_4_aoc: - switch(speed_val) { - case TRANSVR_CLASS_25G: - return TRANSVR_CLASS_OPTICAL_25G_AOC; - case TRANSVR_CLASS_10G: - return TRANSVR_CLASS_OPTICAL_10G_S_AOC; - case TRANSVR_CLASS_1G: - return TRANSVR_CLASS_OPTICAL_1G_AOC; - default: - break; - } - goto ok_sfp_detect_class_by_feature_4_unknow; - -ok_sfp_detect_class_by_feature_4_copper: - switch(speed_val) { - case TRANSVR_CLASS_25G: - return TRANSVR_CLASS_COPPER_L1_25G; - case TRANSVR_CLASS_10G: - return TRANSVR_CLASS_COPPER_L1_10G; - case TRANSVR_CLASS_1G: - return TRANSVR_CLASS_COPPER_L1_1G; - default: - return TRANSVR_CLASS_COPPER; - } - -ok_sfp_detect_class_by_feature_4_unknow: - return TRANSVR_CLASS_UNSPECIFIED; - -err_sfp_detect_class_by_feature_1: - SWPS_INFO("%s: %s\n :%s", __func__, err_msg, self->swp_name); - return TRANSVR_CLASS_ERROR; -} - - -int -sft_detect_transvr_class(struct transvr_obj_s* self) { - - int detect_val = DEBUG_TRANSVR_INT_VAL; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - - /* Check Extended Compliance */ - detect_val = _sfp_detect_class_by_extend_comp(self); - switch(detect_val) { - case TRANSVR_CLASS_UNSPECIFIED: - break; - case TRANSVR_CLASS_OPTICAL_25G_AOC: - case TRANSVR_CLASS_OPTICAL_25G_SR: - case TRANSVR_CLASS_OPTICAL_25G_LR: - case TRANSVR_CLASS_OPTICAL_25G_ER: - case TRANSVR_CLASS_COPPER_L1_25G: - return detect_val; - default: - snprintf(err_msg, sizeof(err_msg), - "Detect undefined extend_comp:%d", - detect_val); - goto err_sft_detect_transceiver_class_1; - } - /* Check 10G Compliance */ - detect_val = _sfp_detect_class_by_10_ethernet(self); - switch(detect_val) { - case TRANSVR_CLASS_UNSPECIFIED: - break; - case TRANSVR_CLASS_OPTICAL_10G_S_SR: - case TRANSVR_CLASS_OPTICAL_10G_S_LR: - case TRANSVR_CLASS_OPTICAL_10G_S_ER: - return detect_val; - default: - snprintf(err_msg, sizeof(err_msg), - "Detect undefined 10G_eth:%d", - detect_val); - goto err_sft_detect_transceiver_class_1; - } - /* Check 1G Compliance */ - detect_val = _sfp_detect_class_by_1g_ethernet(self); - switch(detect_val) { - case TRANSVR_CLASS_UNSPECIFIED: - break; - case TRANSVR_CLASS_OPTICAL_1G_SX: - case TRANSVR_CLASS_OPTICAL_1G_LX: - case TRANSVR_CLASS_COPPER_L1_1G: - case TRANSVR_CLASS_BASE_T_1000: - case TRANSVR_CLASS_OPTICAL_100: - /* - * ToDo: Need Check 0.1G - */ - case TRANSVR_CLASS_OPTICAL_10G_S_SR: - case TRANSVR_CLASS_OPTICAL_10G_S_LR: - case TRANSVR_CLASS_COPPER_L1_10G: - /* Transfer speed case - * => Example: Raycom 10G DAC - */ - return detect_val; - default: - snprintf(err_msg, sizeof(err_msg), - "Detect undefined 1G_eth:%d", - detect_val); - goto err_sft_detect_transceiver_class_1; - } - /* Check by connector, br, wavelength */ - detect_val = _sfp_detect_class_by_feature(self); - switch(detect_val) { - case TRANSVR_CLASS_UNSPECIFIED: - break; - case TRANSVR_CLASS_OPTICAL: - case TRANSVR_CLASS_OPTICAL_1G: - case TRANSVR_CLASS_OPTICAL_1G_SX: - case TRANSVR_CLASS_OPTICAL_1G_LX: - case TRANSVR_CLASS_OPTICAL_1G_EX: - case TRANSVR_CLASS_OPTICAL_1G_AOC: - case TRANSVR_CLASS_OPTICAL_10G: - case TRANSVR_CLASS_OPTICAL_10G_S_SR: - case TRANSVR_CLASS_OPTICAL_10G_S_LR: - case TRANSVR_CLASS_OPTICAL_10G_S_ER: - case TRANSVR_CLASS_OPTICAL_10G_S_AOC: - case TRANSVR_CLASS_OPTICAL_25G: - case TRANSVR_CLASS_OPTICAL_25G_SR: - case TRANSVR_CLASS_OPTICAL_25G_LR: - case TRANSVR_CLASS_OPTICAL_25G_ER: - case TRANSVR_CLASS_OPTICAL_25G_AOC: - case TRANSVR_CLASS_COPPER: - case TRANSVR_CLASS_COPPER_L1_1G: - case TRANSVR_CLASS_COPPER_L1_10G: - case TRANSVR_CLASS_COPPER_L1_25G: - return detect_val; - default: - snprintf(err_msg, sizeof(err_msg), - "Detect undefined get_connector:%d", - detect_val); - goto err_sft_detect_transceiver_class_1; - } - /* Exception case: Can't verify */ - snprintf(err_msg, sizeof(err_msg), "Can not identify!"); - goto err_sft_detect_transceiver_class_1; - -err_sft_detect_transceiver_class_1: - SWPS_INFO("%s: %s :%s\n", __func__, err_msg, self->swp_name); - return TRANSVR_CLASS_ERROR; -} - - -int -_sfp_set_magnolia_if_type(struct transvr_obj_s* self, - int transvr_cls, - char *result){ - - int lmax = 8; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - - switch(transvr_cls) { - case TRANSVR_CLASS_ERROR: - case TRANSVR_CLASS_UNSPECIFIED: - break; - /* 25G OPTICAL */ - case TRANSVR_CLASS_OPTICAL_25G_AOC: - case TRANSVR_CLASS_OPTICAL_25G_SR: - case TRANSVR_CLASS_OPTICAL_25G_LR: - case TRANSVR_CLASS_OPTICAL_25G_ER: - case TRANSVR_CLASS_OPTICAL_25G: - return snprintf(result, lmax, TRANSVR_IF_SFI); - /* 25G COPPER */ - case TRANSVR_CLASS_COPPER_L1_25G: - return snprintf(result, lmax, TRANSVR_IF_SFI); - /* 10G OPTICAL */ - case TRANSVR_CLASS_OPTICAL_10G_S_AOC: - case TRANSVR_CLASS_OPTICAL_10G_S_SR: - case TRANSVR_CLASS_OPTICAL_10G_S_LR: - case TRANSVR_CLASS_OPTICAL_10G_S_ER: - case TRANSVR_CLASS_OPTICAL_10G: - return snprintf(result, lmax, TRANSVR_IF_SFI); - /* 10G COPPER */ - case TRANSVR_CLASS_COPPER_L1_10G: - return snprintf(result, lmax, TRANSVR_IF_SFI); - /* 1G OPTICAL */ - case TRANSVR_CLASS_OPTICAL_1G_AOC: - case TRANSVR_CLASS_OPTICAL_1G_SX: - case TRANSVR_CLASS_OPTICAL_1G_LX: - case TRANSVR_CLASS_OPTICAL_1G_EX: - case TRANSVR_CLASS_OPTICAL_1G: - return snprintf(result, lmax, TRANSVR_IF_IF_GMII); - /* 1G COPPER */ - case TRANSVR_CLASS_COPPER_L1_1G: - return snprintf(result, lmax, TRANSVR_IF_IF_GMII); - /* 1G BASE_T */ - case TRANSVR_CLASS_BASE_T_1000: - return snprintf(result, lmax, TRANSVR_IF_IF_GMII); - /* 100 Base */ - case TRANSVR_CLASS_OPTICAL_100: - return snprintf(result, lmax, TRANSVR_IF_IF_GMII); - default: - snprintf(err_msg, sizeof(err_msg), - "Detect undefined value:%d", - transvr_cls); - goto err_sfp_set_magnolia_if_type_1; - } - /* Exception case: Can't verify */ - snprintf(err_msg, sizeof(err_msg), "Can not identify!"); - goto err_sfp_set_magnolia_if_type_1; - -err_sfp_set_magnolia_if_type_1: - snprintf(result, lmax, TRANSVR_UEVENT_UNKNOW); - SWPS_INFO("%s: %s :%s\n", __func__, err_msg, self->swp_name); - return ERR_TRANSVR_ABNORMAL; -} - - -int -_sfp_set_redwood_if_type(struct transvr_obj_s* self, - int transvr_cls, - char *result) { - - int lmax = 8; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - - switch(transvr_cls) { - case TRANSVR_CLASS_ERROR: - case TRANSVR_CLASS_UNSPECIFIED: - break; - /* 25G OPTICAL */ - case TRANSVR_CLASS_OPTICAL_25G_AOC: - case TRANSVR_CLASS_OPTICAL_25G_SR: - case TRANSVR_CLASS_OPTICAL_25G_LR: - case TRANSVR_CLASS_OPTICAL_25G_ER: - case TRANSVR_CLASS_OPTICAL_25G: - return snprintf(result, lmax, TRANSVR_IF_SR); - /* 25G COPPER */ - case TRANSVR_CLASS_COPPER_L1_25G: - return snprintf(result, lmax, TRANSVR_IF_KR); - /* 10G OPTICAL */ - case TRANSVR_CLASS_OPTICAL_10G_S_AOC: - case TRANSVR_CLASS_OPTICAL_10G_S_SR: - case TRANSVR_CLASS_OPTICAL_10G_S_LR: - case TRANSVR_CLASS_OPTICAL_10G_S_ER: - case TRANSVR_CLASS_OPTICAL_10G: - return snprintf(result, lmax, TRANSVR_IF_SFI); - /* 10G COPPER */ - case TRANSVR_CLASS_COPPER_L1_10G: - return snprintf(result, lmax, TRANSVR_IF_SFI); - /* 1G OPTICAL */ - case TRANSVR_CLASS_OPTICAL_1G_AOC: - case TRANSVR_CLASS_OPTICAL_1G_SX: - case TRANSVR_CLASS_OPTICAL_1G_LX: - case TRANSVR_CLASS_OPTICAL_1G_EX: - case TRANSVR_CLASS_OPTICAL_1G: - return snprintf(result, lmax, TRANSVR_IF_IF_GMII); - /* 1G COPPER */ - case TRANSVR_CLASS_COPPER_L1_1G: - return snprintf(result, lmax, TRANSVR_IF_IF_GMII); - /* 1G BASE_T */ - case TRANSVR_CLASS_BASE_T_1000: - return snprintf(result, lmax, TRANSVR_IF_IF_GMII); - /* 100 Base */ - case TRANSVR_CLASS_OPTICAL_100: - return snprintf(result, lmax, TRANSVR_IF_IF_GMII); - default: - snprintf(err_msg, sizeof(err_msg), - "Detect undefined value:%d", - transvr_cls); - goto err_sfp_set_redwood_if_type_1; - } - /* Exception case: Can't verify */ - snprintf(err_msg, sizeof(err_msg), "Can not identify!"); - goto err_sfp_set_redwood_if_type_1; - -err_sfp_set_redwood_if_type_1: - snprintf(result, lmax, TRANSVR_UEVENT_UNKNOW); - SWPS_INFO("%s: %s\n :%s", __func__, err_msg, self->swp_name); - return ERR_TRANSVR_ABNORMAL; -} - - -int -_sfp_set_lavender_if_type(struct transvr_obj_s* self, - int transvr_cls, - char *result) { - /* (TBD) - * Due to 'LAV' looks like doesn't have interface type. - * We bypass it currently. - */ - int lmax = 8; - return snprintf(result, lmax, TRANSVR_UEVENT_UNKNOW); -} - - -int -_sfp_detect_if_type(struct transvr_obj_s* self, - char *result){ - - int lmax = 8; - int detect_cls = DEBUG_TRANSVR_INT_VAL; - - detect_cls = sft_detect_transvr_class(self); - switch (self->chipset_type) { - case CHIP_TYPE_MAGNOLIA: - return _sfp_set_magnolia_if_type(self, detect_cls, result); - - case CHIP_TYPE_MAPLE: - case CHIP_TYPE_REDWOOD: - return _sfp_set_redwood_if_type(self, detect_cls, result); - - case CHIP_TYPE_LAVENDER: - return _sfp_set_lavender_if_type(self, detect_cls, result); - - default: - SWPS_INFO("%s: non-defined chipset_type:%d :%s\n", - __func__, self->chipset_type, self->swp_name); - break; - } - snprintf(result, lmax, TRANSVR_UEVENT_UNKNOW); - return ERR_TRANSVR_ABNORMAL; -} - - -int -sfp_get_if_type(struct transvr_obj_s *self, - char *buf_p){ - - int lmax = 16; - char tmp_result[16] = DEBUG_TRANSVR_STR_VAL; - - if (self->state != STATE_TRANSVR_CONNECTED) { - return snprintf(buf_p, lmax, "%d\n", self->state); - } - if (_sfp_detect_if_type(self, tmp_result) < 0) { - return snprintf(buf_p, lmax, "%d\n", ERR_TRANSVR_ABNORMAL); - } - return snprintf(buf_p, lmax, "%s\n", tmp_result); -} - - -int -_sfp_detect_if_speed(struct transvr_obj_s* self, - char *result){ - - int lmax = 16; - int detect_val = DEBUG_TRANSVR_INT_VAL; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - - detect_val = sft_detect_transvr_class(self); - switch(detect_val) { - case TRANSVR_CLASS_ERROR: - case TRANSVR_CLASS_UNSPECIFIED: - break; - /* 25G OPTICAL */ - case TRANSVR_CLASS_OPTICAL_25G_AOC: - case TRANSVR_CLASS_OPTICAL_25G_SR: - case TRANSVR_CLASS_OPTICAL_25G_LR: - case TRANSVR_CLASS_OPTICAL_25G_ER: - case TRANSVR_CLASS_OPTICAL_25G: - return snprintf(result, lmax, TRANSVR_IF_SP_25G); - /* 25G COPPER */ - case TRANSVR_CLASS_COPPER_L1_25G: - return snprintf(result, lmax, TRANSVR_IF_SP_25G); - /* 10G OPTICAL */ - case TRANSVR_CLASS_OPTICAL_10G_S_AOC: - case TRANSVR_CLASS_OPTICAL_10G_S_SR: - case TRANSVR_CLASS_OPTICAL_10G_S_LR: - case TRANSVR_CLASS_OPTICAL_10G_S_ER: - case TRANSVR_CLASS_OPTICAL_10G: - return snprintf(result, lmax, TRANSVR_IF_SP_10G); - /* 10G COPPER */ - case TRANSVR_CLASS_COPPER_L1_10G: - return snprintf(result, lmax, TRANSVR_IF_SP_10G); - /* 1G OPTICAL */ - case TRANSVR_CLASS_OPTICAL_1G_AOC: - case TRANSVR_CLASS_OPTICAL_1G_SX: - case TRANSVR_CLASS_OPTICAL_1G_LX: - case TRANSVR_CLASS_OPTICAL_1G_EX: - case TRANSVR_CLASS_OPTICAL_1G: - return snprintf(result, lmax, TRANSVR_IF_SP_1G); - /* 1G COPPER */ - case TRANSVR_CLASS_COPPER_L1_1G: - return snprintf(result, lmax, TRANSVR_IF_SP_1G); - /* 1G BASE_T */ - case TRANSVR_CLASS_BASE_T_1000: - return snprintf(result, lmax, TRANSVR_IF_SP_1G); - /* 100 Base */ - case TRANSVR_CLASS_OPTICAL_100: - return snprintf(result, lmax, TRANSVR_IF_SP_100); - default: - snprintf(err_msg, sizeof(err_msg), - "Detect undefined value:%d", - detect_val); - goto err_sfp_detect_if_speed_1; - } - /* Check by BR */ - detect_val = _sfp_detect_if_sp_by_br(self); - switch (detect_val) { - case TRANSVR_CLASS_25G: - return snprintf(result, lmax, TRANSVR_IF_SP_25G); - case TRANSVR_CLASS_10G: - return snprintf(result, lmax, TRANSVR_IF_SP_10G); - case TRANSVR_CLASS_1G: - return snprintf(result, lmax, TRANSVR_IF_SP_1G); - default: - break; - } - /* Exception case: Can't verify */ - snprintf(err_msg, sizeof(err_msg), "Can not identify!"); - goto err_sfp_detect_if_speed_1; - -err_sfp_detect_if_speed_1: - snprintf(result, lmax, TRANSVR_UEVENT_UNKNOW); - SWPS_INFO("%s %s\n :%s", __func__, err_msg, self->swp_name); - return ERR_TRANSVR_ABNORMAL; -} - - -int -sfp_get_if_speed(struct transvr_obj_s *self, - char *buf_p){ - - int lmax = 16; - char tmp_result[16] = DEBUG_TRANSVR_STR_VAL; - - if (self->state != STATE_TRANSVR_CONNECTED) { - return snprintf(buf_p, lmax, "%d\n", self->state); - } - if (_sfp_detect_if_speed(self, tmp_result) < 0) { - return snprintf(buf_p, lmax, "%d\n", ERR_TRANSVR_ABNORMAL); - } - return snprintf(buf_p, lmax, "%s\n", tmp_result); -} - - -int -_qsfp_detect_class_by_extend_comp(struct transvr_obj_s* self) { - /* Reference: SFF-8024 (v3.8) - */ - int detect_val = DEBUG_TRANSVR_INT_VAL; - - detect_val = _qsfp_get_comp_extended(self); - switch(detect_val) { - case 0x00: /* Unspecified */ - return TRANSVR_CLASS_UNSPECIFIED; - - case 0x01: /* 100G AOC (Active Optical Cable) or 25GAUI C2M */ - case 0x18: /* 100G AOC or 25GAUI C2M AOC. */ - return TRANSVR_CLASS_OPTICAL_100G_AOC; - - case 0x06: /* 100G CWDM4 */ - case 0x09: /* Obsolete (assigned before 100G CWDM4 MSA required FEC) */ - case 0x17: /* 100G CLR4 */ - case 0x1A: /* 100GE-DWDM2 */ - return TRANSVR_CLASS_OPTICAL_100G; - - case 0x02: /* 100GBASE-SR4 or 25GBASE-SR */ - return TRANSVR_CLASS_OPTICAL_100G_SR4; - - case 0x03: /* 100GBASE-LR4 or 25GBASE-LR */ - return TRANSVR_CLASS_OPTICAL_100G_LR4; - - case 0x04: /* 100GBASE-ER4 or 25GBASE-ER */ - return TRANSVR_CLASS_OPTICAL_100G_ER4; - - case 0x07: /* 100G PSM4 Parallel SMF */ - return TRANSVR_CLASS_OPTICAL_100G_PSM4; - - case 0x12: /* 40G PSM4 Parallel SMF */ - return TRANSVR_CLASS_OPTICAL_40G; - - case 0x11: /* 4 x 10GBASE-SR */ - return TRANSVR_CLASS_OPTICAL_40G_SR4; - - case 0x10: /* 40GBASE-ER4 */ - return TRANSVR_CLASS_OPTICAL_40G_ER4; - - case 0x08: /* 100G ACC (Active Copper Cable) or 25GAUI C2M ACC. */ - case 0x0b: /* 100GBASE-CR4 or 25GBASE-CR CA-L */ - case 0x19: /* 100G ACC or 25GAUI C2M ACC. */ - return TRANSVR_CLASS_COPPER_L4_100G; - - default: - break; - } - SWPS_INFO("%s: Unexcept value:0x%02x\n :%s", - __func__, detect_val, self->swp_name); - return TRANSVR_CLASS_ERROR; -} - - -int -_qsfp_detect_class_by_10_40_100_ethernet(struct transvr_obj_s* self) { - /* Reference: SFF-8472 (v12.2) - */ - int detect_val = DEBUG_TRANSVR_INT_VAL; - - detect_val = _qsfp_get_comp_10_40_100_ethernet(self); - /* Case: Unspecified */ - if (detect_val == 0x00) { - return TRANSVR_CLASS_UNSPECIFIED; - } - /* Case: 40G Optical */ - if ((detect_val & 0x01) == 0x01) { /* 00000001 : 40G Active Cable (XLPPI) */ - return TRANSVR_CLASS_OPTICAL_40G_AOC; - } - if ((detect_val & 0x04) == 0x04) { /* 00000100 : 40GBASE-SR4 */ - return TRANSVR_CLASS_OPTICAL_40G_SR4; - } - if ( (detect_val & 0x02) == 0x02) { /* 00000010 : 40GBASE-LR4 */ - return TRANSVR_CLASS_OPTICAL_40G_LR4; - } - if ( (detect_val & 0x08) == 0x08) { /* 00001000 : 40GBASE-CR4 */ - return TRANSVR_CLASS_COPPER_L4_40G; - } - /* Case: 10G Optical */ - if ( (detect_val & 0x10) == 0x10) { /* 00010000 : 10GBASE-SR */ - return TRANSVR_CLASS_OPTICAL_10G_Q_SR; - } - if ( ((detect_val & 0x20) == 0x20) || /* 00100000 : 10GBASE-LR */ - ((detect_val & 0x40) == 0x40) ){ /* 01000000 : 10GBASE-LRM */ - return TRANSVR_CLASS_OPTICAL_10G_Q_LR; - } - /* Case: Extend Compliance */ - if ( ((detect_val & 0x80) == 0x80) ){ /* 10000000 : Use Extend Compliance */ - return TRANSVR_CLASS_EXTEND_COMP; - } - /* Case: ERROR */ - SWPS_INFO("%s: Unexcept value:0x%02x\n :%s", - __func__, detect_val, self->swp_name); - return TRANSVR_CLASS_ERROR; -} - - -int -_qsfp_detect_if_sp_by_br(struct transvr_obj_s* self) { - - int lower_bound_10g = 0x10; - int upper_bound_10g = 0x25; - int lower_bound_40g = 0x60; - int upper_bound_40g = 0x75; - int lower_bound_100g = 0x60; - int upper_bound_100g = 0x75; - int used_extend_br = 0xff; - int notmal_br = DEBUG_TRANSVR_INT_VAL; - int extend_br = DEBUG_TRANSVR_INT_VAL; - - notmal_br = (int)(self->br); /* updated by update_all() */ - /* Check 40G */ - if ((notmal_br >= lower_bound_40g) && - (notmal_br <= upper_bound_40g) ) { - return TRANSVR_CLASS_40G; - } - /* Check 100G */ - if (notmal_br == used_extend_br) { - extend_br = (int)(self->extbr); /* updated by update_all() */ - if ((extend_br >= lower_bound_100g) && - (extend_br <= upper_bound_100g) ) { - return TRANSVR_CLASS_100G; - } - } - /* Check 10G */ - if ((notmal_br >= lower_bound_10g) && - (notmal_br <= upper_bound_10g) ) { - return TRANSVR_CLASS_10G; - } - return TRANSVR_CLASS_UNSPECIFIED; -} - - -int -_qsfp_detect_class_by_feature(struct transvr_obj_s* self) { - /* Reference: SFF-8024 (v3.8) - */ - int conn_val = DEBUG_TRANSVR_INT_VAL; - int wave_len = DEBUG_TRANSVR_INT_VAL; - int speed_val = DEBUG_TRANSVR_INT_VAL; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - - speed_val = _qsfp_detect_if_sp_by_br(self); - conn_val = _qsfp_get_connector_type(self); - - switch(conn_val) { - case 0x00: /* Unspecified */ - return TRANSVR_CLASS_UNSPECIFIED; - case 0x07: /* LC (Lucent Connector) */ - case 0x0b: /* Optical Pigtail */ - case 0x0c: /* MPO 1x12 (Multifiber Parallel Optic) */ - case 0x0d: /* MPO 2x16 */ - goto ok_qsfp_detect_class_by_feature_4_optiocal; - case 0x21: /* Copper pigtail */ - goto ok_qsfp_detect_class_by_feature_4_copper; - case 0x23: /* No separable connector */ - if ((_qsfp_get_comp_fc_link_length(self) > 0) || - (_qsfp_get_comp_fc_trans_tech(self) > 0) || - (_qsfp_get_comp_fc_trans_media(self) > 0) || - (_qsfp_get_comp_fc_speed(self) > 0) ) { - goto ok_qsfp_detect_class_by_feature_4_aoc; - } - goto ok_qsfp_detect_class_by_feature_4_copper; - default: - snprintf(err_msg, sizeof(err_msg), - "_qsfp_get_connector_type return Non define value:%d", - conn_val); - goto err_qsfp_detect_class_by_feature_1; - } - return TRANSVR_CLASS_UNSPECIFIED; - -ok_qsfp_detect_class_by_feature_4_optiocal: - wave_len = _common_count_wavelength(self, - self->wavelength[0], - self->wavelength[1]); - switch(speed_val) { - case TRANSVR_CLASS_100G: - switch (wave_len) { - case VAL_OPTICAL_WAVELENGTH_SR: - return TRANSVR_CLASS_OPTICAL_100G_SR4; - case VAL_OPTICAL_WAVELENGTH_LR: - return TRANSVR_CLASS_OPTICAL_100G_LR4; - case VAL_OPTICAL_WAVELENGTH_ER: - return TRANSVR_CLASS_OPTICAL_100G_ER4; - default: - break; - } - return TRANSVR_CLASS_OPTICAL_100G; - - case TRANSVR_CLASS_40G: - switch (wave_len) { - case VAL_OPTICAL_WAVELENGTH_SR: - return TRANSVR_CLASS_OPTICAL_40G_SR4; - case VAL_OPTICAL_WAVELENGTH_LR: - return TRANSVR_CLASS_OPTICAL_40G_LR4; - case VAL_OPTICAL_WAVELENGTH_ER: - return TRANSVR_CLASS_OPTICAL_40G_ER4; - default: - break; - } - return TRANSVR_CLASS_OPTICAL_40G; - - case TRANSVR_CLASS_10G: - switch (wave_len) { - case VAL_OPTICAL_WAVELENGTH_SR: - return TRANSVR_CLASS_OPTICAL_10G_Q_SR; - case VAL_OPTICAL_WAVELENGTH_LR: - return TRANSVR_CLASS_OPTICAL_10G_Q_LR; - case VAL_OPTICAL_WAVELENGTH_ER: - return TRANSVR_CLASS_OPTICAL_10G_Q_ER; - default: - break; - } - return TRANSVR_CLASS_OPTICAL_10G; - - default: - return TRANSVR_CLASS_OPTICAL; - } - -ok_qsfp_detect_class_by_feature_4_aoc: - switch(speed_val) { - case TRANSVR_CLASS_100G: - return TRANSVR_CLASS_OPTICAL_100G_AOC; - case TRANSVR_CLASS_40G: - return TRANSVR_CLASS_OPTICAL_40G_AOC; - case TRANSVR_CLASS_10G: - return TRANSVR_CLASS_OPTICAL_10G_Q_AOC; - default: - return TRANSVR_CLASS_OPTICAL; - } - -ok_qsfp_detect_class_by_feature_4_copper: - switch(speed_val) { - case TRANSVR_CLASS_100G: - return TRANSVR_CLASS_COPPER_L4_100G; - case TRANSVR_CLASS_40G: - return TRANSVR_CLASS_COPPER_L4_40G; - case TRANSVR_CLASS_10G: - return TRANSVR_CLASS_COPPER_L4_10G; - default: - return TRANSVR_CLASS_COPPER; - } - -err_qsfp_detect_class_by_feature_1: - SWPS_INFO("%s: %s\n :%s", - __func__, err_msg, self->swp_name); - return TRANSVR_CLASS_ERROR; -} - - -int -qsft_detect_transvr_class(struct transvr_obj_s* self) { - - int detect_val = DEBUG_TRANSVR_INT_VAL; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - - /* Check Extended Compliance */ - detect_val = _qsfp_detect_class_by_extend_comp(self); - switch (detect_val) { - case TRANSVR_CLASS_UNSPECIFIED: - break; - case TRANSVR_CLASS_OPTICAL_100G: - case TRANSVR_CLASS_OPTICAL_100G_AOC: - case TRANSVR_CLASS_OPTICAL_100G_SR4: - case TRANSVR_CLASS_OPTICAL_100G_LR4: - case TRANSVR_CLASS_OPTICAL_100G_ER4: - case TRANSVR_CLASS_OPTICAL_100G_PSM4: - case TRANSVR_CLASS_OPTICAL_40G: - case TRANSVR_CLASS_OPTICAL_40G_AOC: - case TRANSVR_CLASS_OPTICAL_40G_SR4: - case TRANSVR_CLASS_OPTICAL_40G_LR4: - case TRANSVR_CLASS_OPTICAL_40G_ER4: - case TRANSVR_CLASS_COPPER_L4_100G: - return detect_val; - default: - snprintf(err_msg, sizeof(err_msg), - "Detect undefined extend_comp:%d", - detect_val); - goto err_qsft_detect_transvr_class_1; - } - /* Check 10/40G/100G Ethernet Compliance */ - detect_val = _qsfp_detect_class_by_10_40_100_ethernet(self); - switch(detect_val) { - case TRANSVR_CLASS_UNSPECIFIED: - break; - case TRANSVR_CLASS_OPTICAL_40G_AOC: - case TRANSVR_CLASS_OPTICAL_40G_SR4: - case TRANSVR_CLASS_OPTICAL_40G_LR4: - case TRANSVR_CLASS_OPTICAL_10G_Q_SR: /* Need Check: SR4 or SR */ - case TRANSVR_CLASS_OPTICAL_10G_Q_LR: /* Need Check: SR4 or SR */ - case TRANSVR_CLASS_COPPER_L4_40G: - return detect_val; - case TRANSVR_CLASS_EXTEND_COMP: - /* Format incorrect case (We already checked the Extend - * Compliance is 0 - */ - snprintf(err_msg, sizeof(err_msg), - "Transceiver format incorrect"); - goto err_qsft_detect_transvr_class_1; - default: - snprintf(err_msg, sizeof(err_msg), - "Detect undefined 10/40/100:%d", - detect_val); - goto err_qsft_detect_transvr_class_1; - } - /* Check by Connector type, BR and wavelength */ - detect_val = _qsfp_detect_class_by_feature(self); - switch (detect_val) { - case TRANSVR_CLASS_UNSPECIFIED: - break; - case TRANSVR_CLASS_OPTICAL_100G_ER4: - case TRANSVR_CLASS_OPTICAL_100G_LR4: - case TRANSVR_CLASS_OPTICAL_100G_SR4: - case TRANSVR_CLASS_OPTICAL_100G_AOC: - case TRANSVR_CLASS_OPTICAL_100G: - case TRANSVR_CLASS_OPTICAL_40G_ER4: - case TRANSVR_CLASS_OPTICAL_40G_LR4: - case TRANSVR_CLASS_OPTICAL_40G_SR4: - case TRANSVR_CLASS_OPTICAL_40G_AOC: - case TRANSVR_CLASS_OPTICAL_40G: - case TRANSVR_CLASS_OPTICAL_10G_Q_ER: - case TRANSVR_CLASS_OPTICAL_10G_Q_LR: - case TRANSVR_CLASS_OPTICAL_10G_Q_SR: - case TRANSVR_CLASS_OPTICAL_10G_Q_AOC: - case TRANSVR_CLASS_OPTICAL_10G: - case TRANSVR_CLASS_OPTICAL: - case TRANSVR_CLASS_COPPER_L4_100G: - case TRANSVR_CLASS_COPPER_L4_40G: - case TRANSVR_CLASS_COPPER_L4_10G: - case TRANSVR_CLASS_COPPER: - return detect_val; - default: - snprintf(err_msg, sizeof(err_msg), - "Detect undefined connector:%d", - detect_val); - goto err_qsft_detect_transvr_class_1; - } - /* Exception case: Can't verify */ - snprintf(err_msg, sizeof(err_msg), - "Can not identify!"); - goto err_qsft_detect_transvr_class_1; - -err_qsft_detect_transvr_class_1: - SWPS_INFO("%s: %s\n :%s", __func__, err_msg, self->swp_name); - return TRANSVR_CLASS_ERROR; -} - - -int -_qsfp_set_magnolia_if_type(struct transvr_obj_s* self, - int transvr_cls, - char *result){ - - int lmax = 8; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - - switch (transvr_cls) { - case TRANSVR_CLASS_UNSPECIFIED: - case TRANSVR_CLASS_ERROR: - break; - /* 100G Optical */ - case TRANSVR_CLASS_OPTICAL_100G: - case TRANSVR_CLASS_OPTICAL_100G_AOC: - case TRANSVR_CLASS_OPTICAL_100G_SR4: - case TRANSVR_CLASS_OPTICAL_100G_LR4: - case TRANSVR_CLASS_OPTICAL_100G_ER4: - case TRANSVR_CLASS_OPTICAL_100G_PSM4: - return snprintf(result, lmax, TRANSVR_IF_SR4); - /* 100G Copper */ - case TRANSVR_CLASS_COPPER_L4_100G: - return snprintf(result, lmax, TRANSVR_IF_KR4); - /* 40G Optical */ - case TRANSVR_CLASS_OPTICAL_40G: - case TRANSVR_CLASS_OPTICAL_40G_AOC: - case TRANSVR_CLASS_OPTICAL_40G_SR4: - case TRANSVR_CLASS_OPTICAL_40G_LR4: - case TRANSVR_CLASS_OPTICAL_40G_ER4: - return snprintf(result, lmax, TRANSVR_IF_IF_XGMII); - /* 40G Copper */ - case TRANSVR_CLASS_COPPER_L4_40G: - return snprintf(result, lmax, TRANSVR_IF_IF_XGMII); - /* 10G Optical */ - case TRANSVR_CLASS_OPTICAL_10G: - case TRANSVR_CLASS_OPTICAL_10G_Q_AOC: - case TRANSVR_CLASS_OPTICAL_10G_Q_SR: /* Need Check: SR4 or SR */ - case TRANSVR_CLASS_OPTICAL_10G_Q_LR: /* Need Check: LR4 or LR */ - case TRANSVR_CLASS_OPTICAL_10G_Q_ER: /* Need Check: ER4 or ER */ - return snprintf(result, lmax, TRANSVR_IF_IF_XGMII); - /* Optical */ - case TRANSVR_CLASS_OPTICAL: - return snprintf(result, lmax, TRANSVR_IF_IF_XGMII); - /* Copper */ - case TRANSVR_CLASS_COPPER: - return snprintf(result, lmax, TRANSVR_IF_IF_XGMII); - default: - snprintf(err_msg, sizeof(err_msg), - "Detect undefined value:%d", - transvr_cls); - goto err_qsfp_set_magnolia_if_type_1; - } - /* Exception case: Can't verify */ - snprintf(err_msg, sizeof(err_msg), "Can not identify!"); - goto err_qsfp_set_magnolia_if_type_1; - -err_qsfp_set_magnolia_if_type_1: - snprintf(result, lmax, TRANSVR_UEVENT_UNKNOW); - SWPS_INFO("%s: %s\n :%s", __func__, err_msg, self->swp_name); - return ERR_TRANSVR_ABNORMAL; -} - - -int -_qsfp_set_redwood_if_type(struct transvr_obj_s* self, - int transvr_cls, - char *result){ - - int lmax = 8; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - - switch (transvr_cls) { - case TRANSVR_CLASS_UNSPECIFIED: - case TRANSVR_CLASS_ERROR: - break; - /* 100G Optical */ - case TRANSVR_CLASS_OPTICAL_100G: - case TRANSVR_CLASS_OPTICAL_100G_AOC: - case TRANSVR_CLASS_OPTICAL_100G_SR4: - case TRANSVR_CLASS_OPTICAL_100G_LR4: - case TRANSVR_CLASS_OPTICAL_100G_ER4: - case TRANSVR_CLASS_OPTICAL_100G_PSM4: - return snprintf(result, lmax, TRANSVR_IF_SR4); - /* 100G Copper */ - case TRANSVR_CLASS_COPPER_L4_100G: - return snprintf(result, lmax, TRANSVR_IF_KR4); - /* 40G Optical */ - case TRANSVR_CLASS_OPTICAL_40G: - case TRANSVR_CLASS_OPTICAL_40G_AOC: - case TRANSVR_CLASS_OPTICAL_40G_SR4: - case TRANSVR_CLASS_OPTICAL_40G_LR4: - case TRANSVR_CLASS_OPTICAL_40G_ER4: - return snprintf(result, lmax, TRANSVR_IF_SR4); - /* 40G Copper */ - case TRANSVR_CLASS_COPPER_L4_40G: - return snprintf(result, lmax, TRANSVR_IF_KR4); - /* 10G Optical */ - case TRANSVR_CLASS_OPTICAL_10G: - case TRANSVR_CLASS_OPTICAL_10G_Q_AOC: - case TRANSVR_CLASS_OPTICAL_10G_Q_SR: /* Need Check: SR4 or SR */ - case TRANSVR_CLASS_OPTICAL_10G_Q_LR: /* Need Check: SR4 or SR */ - case TRANSVR_CLASS_OPTICAL_10G_Q_ER: - return snprintf(result, lmax, TRANSVR_IF_SR4); - /* Optical */ - case TRANSVR_CLASS_OPTICAL: - return snprintf(result, lmax, TRANSVR_IF_SR4); - /* Copper */ - case TRANSVR_CLASS_COPPER: - return snprintf(result, lmax, TRANSVR_IF_KR4); - default: - snprintf(err_msg, sizeof(err_msg), - "Detect undefined value:%d", - transvr_cls); - goto err_qsfp_set_magnolia_if_type_1; - } - /* Exception case: Can't verify */ - snprintf(err_msg, sizeof(err_msg), "Can not identify!"); - goto err_qsfp_set_magnolia_if_type_1; - -err_qsfp_set_magnolia_if_type_1: - snprintf(result, lmax, TRANSVR_UEVENT_UNKNOW); - SWPS_INFO("%s: %s\n :%s", __func__, err_msg, self->swp_name); - return ERR_TRANSVR_ABNORMAL; -} - - -int -_qsfp_set_lavender_if_type(struct transvr_obj_s* self, - int transvr_cls, - char *result) { - /* (TBD) - * Due to 'LAV' looks like doesn't have interface type. - * We bypass it currently. - */ - int lmax = 8; - return snprintf(result, lmax, TRANSVR_UEVENT_UNKNOW); -} - - -int -_qsfp_detect_if_type(struct transvr_obj_s* self, - char *result){ - - int lmax = 8; - int detect_cls = DEBUG_TRANSVR_INT_VAL; - - detect_cls = qsft_detect_transvr_class(self); - switch (self->chipset_type) { - case CHIP_TYPE_MAGNOLIA: - return _qsfp_set_magnolia_if_type(self, detect_cls, result); - - case CHIP_TYPE_MAPLE: - case CHIP_TYPE_REDWOOD: - return _qsfp_set_redwood_if_type(self, detect_cls, result); - - case CHIP_TYPE_LAVENDER: - return _qsfp_set_lavender_if_type(self, detect_cls, result); - - default: - SWPS_INFO("%s: non-defined chipset_type:%d :%s\n", - __func__, self->chipset_type, self->swp_name); - break; - } - snprintf(result, lmax, TRANSVR_UEVENT_UNKNOW); - return ERR_TRANSVR_ABNORMAL; -} - - -int -qsfp_get_if_type(struct transvr_obj_s *self, - char *buf_p){ - - int lmax = 8; - char tmp_result[8] = DEBUG_TRANSVR_STR_VAL; - - if (self->state != STATE_TRANSVR_CONNECTED) { - return snprintf(buf_p, lmax, "%d\n", self->state); - } - if (_qsfp_detect_if_type(self, tmp_result) < 0) { - return snprintf(buf_p, lmax, "%d\n", ERR_TRANSVR_ABNORMAL); - } - return snprintf(buf_p, lmax, "%s\n", tmp_result); -} - - -int -_qsfp_detect_if_speed(struct transvr_obj_s* self, - char *result){ - int lmax = 16; - int detect_val = DEBUG_TRANSVR_INT_VAL; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - - detect_val = qsft_detect_transvr_class(self); - switch (detect_val) { - case TRANSVR_CLASS_UNSPECIFIED: - case TRANSVR_CLASS_ERROR: - break; - /* 100G Optical */ - case TRANSVR_CLASS_OPTICAL_100G: - case TRANSVR_CLASS_OPTICAL_100G_AOC: - case TRANSVR_CLASS_OPTICAL_100G_SR4: - case TRANSVR_CLASS_OPTICAL_100G_LR4: - case TRANSVR_CLASS_OPTICAL_100G_ER4: - case TRANSVR_CLASS_OPTICAL_100G_PSM4: - return snprintf(result, lmax, TRANSVR_IF_SP_100G); - /* 100G Copper */ - case TRANSVR_CLASS_COPPER_L4_100G: - return snprintf(result, lmax, TRANSVR_IF_SP_100G); - /* 40G Optical */ - case TRANSVR_CLASS_OPTICAL_40G: - case TRANSVR_CLASS_OPTICAL_40G_AOC: - case TRANSVR_CLASS_OPTICAL_40G_SR4: - case TRANSVR_CLASS_OPTICAL_40G_LR4: - case TRANSVR_CLASS_OPTICAL_40G_ER4: - return snprintf(result, lmax, TRANSVR_IF_SP_40G); - /* 40G Copper */ - case TRANSVR_CLASS_COPPER_L4_40G: - return snprintf(result, lmax, TRANSVR_IF_SP_40G); - /* 10G Optical */ - case TRANSVR_CLASS_OPTICAL_10G: - case TRANSVR_CLASS_OPTICAL_10G_Q_AOC: - case TRANSVR_CLASS_OPTICAL_10G_Q_SR: /* Need Check: SR4 or SR */ - case TRANSVR_CLASS_OPTICAL_10G_Q_LR: /* Need Check: SR4 or SR */ - case TRANSVR_CLASS_OPTICAL_10G_Q_ER: - return snprintf(result, lmax, TRANSVR_IF_SP_10G); - /* 10G Copper */ - case TRANSVR_CLASS_COPPER_L4_10G: - return snprintf(result, lmax, TRANSVR_IF_SP_10G); - /* Optical */ - case TRANSVR_CLASS_OPTICAL: - break; - /* Copper */ - case TRANSVR_CLASS_COPPER: - break; - default: - snprintf(err_msg, sizeof(err_msg), - "Detect undefined class case:%d", - detect_val); - goto err_qsfp_detect_if_speed_1; - } - /* Check br and extbr */ - detect_val = _qsfp_detect_if_sp_by_br(self); - switch(detect_val) { - case TRANSVR_CLASS_UNSPECIFIED: - break; - case TRANSVR_CLASS_10G: - return snprintf(result, lmax, TRANSVR_IF_SP_10G); - case TRANSVR_CLASS_40G: - return snprintf(result, lmax, TRANSVR_IF_SP_40G); - case TRANSVR_CLASS_100G: - return snprintf(result, lmax, TRANSVR_IF_SP_100G); - default: - snprintf(err_msg, sizeof(err_msg), - "Detect undefined BR case:%d", - detect_val); - goto err_qsfp_detect_if_speed_1; - } - /* Exception case: Can't verify */ - snprintf(err_msg, sizeof(err_msg), "Can not identify!"); - goto err_qsfp_detect_if_speed_1; - -err_qsfp_detect_if_speed_1: - snprintf(result, lmax, TRANSVR_UEVENT_UNKNOW); - SWPS_INFO("%s: %s :%s\n", __func__, err_msg, self->swp_name); - return ERR_TRANSVR_ABNORMAL; -} - - -int -qsfp_get_if_speed(struct transvr_obj_s *self, - char *buf_p){ - - int lmax = 16; - char tmp_result[16] = DEBUG_TRANSVR_STR_VAL; - - if (self->state != STATE_TRANSVR_CONNECTED) { - return snprintf(buf_p, lmax, "%d\n", self->state); - } - if (_qsfp_detect_if_speed(self, tmp_result) < 0) { - return snprintf(buf_p, lmax, "%d\n", ERR_TRANSVR_ABNORMAL); - } - return snprintf(buf_p, lmax, "%s\n", tmp_result); -} - - -int -_common_set_lane_map_str(struct transvr_obj_s* self, - char *result) { - int i = 0; - int tmp_val = 0; - char tmp_str[LEN_TRANSVR_L_STR] = DEBUG_TRANSVR_STR_VAL; - char err_msg[LEN_TRANSVR_L_STR] = DEBUG_TRANSVR_STR_VAL; - - memset(result, 0, LEN_TRANSVR_L_STR); - snprintf(result, LEN_TRANSVR_L_STR, "%s=", TRANSVR_UEVENT_KEY_LANE); - - for (i=0; ilane_id); i++) { - tmp_val = self->lane_id[i]; - if (tmp_val < 1) { - break; - } - if (tmp_val > 256) { - snprintf(err_msg, sizeof(err_msg), - "detect abnormal value:%d", tmp_val); - goto err_common_set_lane_map_str_1; - } - memset(tmp_str, 0, sizeof(tmp_str)); - if (i == 0) { - snprintf(tmp_str, LEN_TRANSVR_L_STR, "%d", tmp_val); - } else { - snprintf(tmp_str, LEN_TRANSVR_L_STR, ",%d", tmp_val); - } - strncat(result, tmp_str, LEN_TRANSVR_L_STR); - } - if (i == 0) { - goto err_common_set_lane_map_str_2; - } - return 0; - -err_common_set_lane_map_str_1: - SWPS_INFO("%s: %s", __func__, err_msg); -err_common_set_lane_map_str_2: - snprintf(result, LEN_TRANSVR_L_STR, "%s=%s", TRANSVR_UEVENT_KEY_LANE, TRANSVR_UEVENT_UNKNOW); - return EVENT_TRANSVR_TASK_FAIL; -} - - -int -_common_send_uevent(struct transvr_obj_s* self, - enum kobject_action u_action, - int (*detect_if_type)(struct transvr_obj_s *self, char *result), - int (*detect_if_speed)(struct transvr_obj_s *self, char *result), - int send_anyway) { - - char *uevent_envp[4]; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - char tmp_str[32] = DEBUG_TRANSVR_STR_VAL; - char tmp_str_1[32] = DEBUG_TRANSVR_STR_VAL; - char tmp_str_2[32] = DEBUG_TRANSVR_STR_VAL; - char tmp_str_3[64] = DEBUG_TRANSVR_STR_VAL; - - if (TRANSVR_UEVENT_ENABLE != 1) { - return ERR_TRANSVR_NOTSUPPORT; - } - if (_common_get_if_lane(self, tmp_str) < 0) { - snprintf(tmp_str_3, sizeof(tmp_str_3), - "%s=%s", TRANSVR_UEVENT_KEY_LANE, TRANSVR_UEVENT_UNKNOW); - } else { - snprintf(tmp_str_3, sizeof(tmp_str_3), - "%s=%s", TRANSVR_UEVENT_KEY_LANE, tmp_str); - } - switch (u_action) { - case KOBJ_ADD: - /* Detect type */ - if (detect_if_type(self, tmp_str) < 0) { - snprintf(err_msg, sizeof(err_msg), "%s", "Detect interface type fail!"); - snprintf(tmp_str_1, sizeof(tmp_str_1), "%s=%s", TRANSVR_UEVENT_KEY_IF, TRANSVR_UEVENT_UNKNOW); - snprintf(tmp_str_2, sizeof(tmp_str_2), "%s=%s", TRANSVR_UEVENT_KEY_SP, TRANSVR_UEVENT_UNKNOW); - uevent_envp[0] = tmp_str_1; - uevent_envp[1] = tmp_str_2; - uevent_envp[2] = tmp_str_3; - uevent_envp[3] = NULL; - goto private_common_send_uevent_4_fail; - } - snprintf(tmp_str_1, sizeof(tmp_str_1), "%s=%s", TRANSVR_UEVENT_KEY_IF, tmp_str); - uevent_envp[0] = tmp_str_1; - /* Detect speed */ - if (detect_if_speed(self, tmp_str) < 0) { - snprintf(err_msg, sizeof(err_msg), "%s", "Detect interface speed fail!"); - snprintf(tmp_str_2, sizeof(tmp_str_2), "%s=%s", TRANSVR_UEVENT_KEY_SP, TRANSVR_UEVENT_UNKNOW); - uevent_envp[1] = tmp_str_2; - uevent_envp[2] = tmp_str_3; - uevent_envp[3] = NULL; - goto private_common_send_uevent_4_fail; - } - snprintf(tmp_str_2, sizeof(tmp_str_2), "%s=%s", TRANSVR_UEVENT_KEY_SP, tmp_str); - uevent_envp[1] = tmp_str_2; - uevent_envp[2] = tmp_str_3; - uevent_envp[3] = NULL; - goto private_common_send_uevent_4_send; - - case KOBJ_REMOVE: - snprintf(tmp_str_1, sizeof(tmp_str_1), "%s=%s", TRANSVR_UEVENT_KEY_IF, TRANSVR_UEVENT_UNKNOW); - snprintf(tmp_str_2, sizeof(tmp_str_2), "%s=%s", TRANSVR_UEVENT_KEY_SP, TRANSVR_UEVENT_UNKNOW); - uevent_envp[0] = tmp_str_1; - uevent_envp[1] = tmp_str_2; - uevent_envp[2] = tmp_str_3; - uevent_envp[3] = NULL; - goto private_common_send_uevent_4_send; - - default: - snprintf(err_msg, sizeof(err_msg), "kobject_action:%d not support", u_action); - goto private_common_send_uevent_4_fail; - } - snprintf(err_msg, sizeof(err_msg), "%s", "Exception case"); - goto private_common_send_uevent_4_fail; - -private_common_send_uevent_4_fail: - SWPS_INFO("%s: %s :%s\n", __func__, err_msg, self->swp_name); - if (send_anyway) { - goto private_common_send_uevent_4_send; - } - return ERR_TRANSVR_UEVENT_FAIL; - -private_common_send_uevent_4_send: - return kobject_uevent_env(&(self->transvr_dev_p->kobj), - u_action, - uevent_envp); -} - -int -sfp_send_uevent(struct transvr_obj_s* self, - enum kobject_action u_action) { - int send_anyway = 1; - return _common_send_uevent(self, - u_action, - &_sfp_detect_if_type, - &_sfp_detect_if_speed, - send_anyway); -} - - -int -qsfp_send_uevent(struct transvr_obj_s* self, - enum kobject_action u_action) { - int send_anyway = 1; - return _common_send_uevent(self, - u_action, - &_qsfp_detect_if_type, - &_qsfp_detect_if_speed, - send_anyway); -} - - -int -fake_send_uevent(struct transvr_obj_s* self, - enum kobject_action u_action) { - return EVENT_TRANSVR_TASK_DONE; -} - - -int -common_fsm_4_direct_mode(struct transvr_obj_s* self, - char *caller_name){ - - int err; - int detect_result[2]; - int current_state = STATE_TRANSVR_UNEXCEPTED; - int current_type = TRANSVR_TYPE_ERROR; - - if (self->state == STATE_TRANSVR_NEW) { - if (_transvr_init_handler(self) < 0){ - return ERR_TRANSVR_INIT_FAIL; - } - } - err = detect_transvr_state(self, detect_result); - if (err < 0) { - return err; - } - /* In Direct mode, driver only detect transceiver when user call driver interface - * which on sysfs. So it only need consider the state of Transceiver. - */ - current_state = detect_result[0]; - current_type = detect_result[1]; - - switch (current_state){ - - case STATE_TRANSVR_DISCONNECTED: /* Transceiver is not plugged */ - self->state = current_state; - self->type = current_type; - return ERR_TRANSVR_UNPLUGGED; - - case STATE_TRANSVR_INIT: /* Transceiver is plugged, system not ready */ - return ERR_TRANSVR_UNINIT; - - case STATE_TRANSVR_ISOLATED: /* Transceiver is plugged, but has some issues */ - return ERR_TRNASVR_BE_ISOLATED; - - case STATE_TRANSVR_CONNECTED: /* Transceiver is plugged, system is ready */ - self->state = current_state; - self->type = current_type; - return 0; - - case STATE_TRANSVR_SWAPPED: /* Transceiver is plugged, system detect user changed */ - self->type = current_type; - if (reload_transvr_obj(self, current_type) < 0){ - self->state = STATE_TRANSVR_UNEXCEPTED; - return ERR_TRANSVR_UNEXCPT; - } - self->state = current_state; - return 0; - - case STATE_TRANSVR_UNEXCEPTED: /* Transceiver type or state is unexpected case */ - self->state = STATE_TRANSVR_UNEXCEPTED; - self->type = TRANSVR_TYPE_ERROR; - return ERR_TRANSVR_UNEXCPT; - - default: - SWPS_INFO("%s: state:%d not in define.\n", __func__, current_state); - break; - } - return ERR_TRANSVR_UNEXCPT; -} - - -static int -_is_except_happened_4_pmode(struct transvr_obj_s* self, - int new_state) { - - int event_chk = 0; - - if (self->temp == 0){ - return 0; - } - switch (new_state) { - case STATE_TRANSVR_INIT: - event_chk = EVENT_TRANSVR_EXCEP_INIT; - goto check_event_happened_4_pmode; - - case STATE_TRANSVR_CONNECTED: - event_chk = EVENT_TRANSVR_EXCEP_UP; - goto check_event_happened_4_pmode; - - case STATE_TRANSVR_DISCONNECTED: - event_chk = EVENT_TRANSVR_EXCEP_DOWN; - goto check_event_happened_4_pmode; - - case STATE_TRANSVR_SWAPPED: - event_chk = EVENT_TRANSVR_EXCEP_SWAP; - goto check_event_happened_4_pmode; - - case STATE_TRANSVR_UNEXCEPTED: - event_chk = EVENT_TRANSVR_EXCEP_EXCEP; - goto check_event_happened_4_pmode; - - case STATE_TRANSVR_ISOLATED: - event_chk = EVENT_TRANSVR_EXCEP_ISOLATED; - goto check_event_happened_4_pmode; - - default: - SWPS_INFO("%s: unexcepted case:%d\n", __func__, new_state); - break; - } - return 0; - -check_event_happened_4_pmode: - if (self->temp == event_chk){ - return 1; - } - return 0; -} - - -int -common_fsm_4_polling_mode(struct transvr_obj_s* self, - char *caller_name){ - /* [Return Value]: - * ERR_TRANSVR_UNINIT : (1) Initial not ready - * ERR_TRANSVR_UNPLUGGED : (1) Any -> Down - * ERR_TRANSVR_TASK_BUSY : (1) Wait Initial task - * ERR_TRANSVR_UNEXCPT : (1) Initial fail - * (2) Task fail - * (3) Reload fail - * ERR_TRNASVR_BE_ISOLATED : (1) Already be isolated - * OK Case (return 0) : (1) action_4_connected - * (2) action_4_nothing (initial retry) - */ - int curr_state[2]; - int old_state = self->state; - int old_type = self->type; - int new_state = STATE_TRANSVR_UNEXCEPTED; - int new_type = TRANSVR_TYPE_ERROR; - int return_val = ERR_TRANSVR_UNEXCPT; - - /* Never initial */ - if (self->state == STATE_TRANSVR_NEW) { - goto comfsm_action_4_reinit_obj; - } - /* Detect current state */ - switch (detect_transvr_state(self, curr_state)) { - case 0: - new_state = curr_state[0]; - new_type = curr_state[1]; - break; - - case ERR_TRNASVR_BE_ISOLATED: - new_state = STATE_TRANSVR_ISOLATED; - new_type = old_type; - break; - - case ERR_TRANSVR_I2C_CRASH: - goto comfsm_action_4_report_i2c_crash; - - case ERR_TRANSVR_UNEXCPT: - default: - new_state = STATE_TRANSVR_UNEXCEPTED; - new_type = old_type; - } - /* State handling */ - switch (old_state) { - case STATE_TRANSVR_INIT: /* INIT -> */ - return_val = ERR_TRANSVR_UNINIT; - goto comfsm_action_4_keep_state; - - case STATE_TRANSVR_CONNECTED: - switch (new_state) { - case STATE_TRANSVR_INIT: /* Case 1-1: UP -> INIT */ - SWPS_INFO("Detect %s is present. :1-1\n",self->swp_name); - return_val = ERR_TRANSVR_UNINIT; - goto comfsm_action_4_keep_state; - - case STATE_TRANSVR_CONNECTED: /* Case 1-2: UP -> UP */ - return_val = 0; - goto comfsm_action_4_keep_state; - - case STATE_TRANSVR_DISCONNECTED: /* Case 1-3: UP -> DOWN */ - SWPS_INFO("Detect %s is removed. :1-3\n",self->swp_name); - goto comfsm_action_4_disconnected; - - case STATE_TRANSVR_SWAPPED: /* Case 1-4: UP -> SWAP */ - SWPS_INFO("Detect %s is swapped. :1-4\n",self->swp_name); - goto comfsm_action_4_reload_obj; - - case STATE_TRANSVR_UNEXCEPTED: /* Case 1-5: UP -> UNEXPET */ - SWPS_INFO("Detect %s has error. :1-5\n",self->swp_name); - goto comfsm_action_4_unexpected; - - case STATE_TRANSVR_ISOLATED: /* Case 1-6: UP -> ISOLATE */ - SWPS_INFO("Detect %s be isolated. :1-6\n",self->swp_name); - goto comfsm_action_4_isolate_obj; - - default: - break; - } - goto comfsm_action_4_unexpected; - - case STATE_TRANSVR_DISCONNECTED: - switch (new_state) { - case STATE_TRANSVR_INIT: /* Case 2-1: DOWN -> INIT */ - SWPS_INFO("Detect %s is present. :2-1\n",self->swp_name); - return_val = ERR_TRANSVR_UNINIT; - goto comfsm_action_4_keep_state; - - case STATE_TRANSVR_CONNECTED: /* Case 2-2: DOWN -> UP */ - SWPS_INFO("Detect %s is present. :2-2\n",self->swp_name); - goto comfsm_action_4_reinit_obj; - - case STATE_TRANSVR_DISCONNECTED: /* Case 2-3: DOWN -> DOWN */ - return_val = ERR_TRANSVR_UNPLUGGED; - goto comfsm_action_4_keep_state; - - case STATE_TRANSVR_SWAPPED: /* Case 2-4: DOWN -> SWAP */ - SWPS_INFO("Detect %s is swapped. :2-4\n",self->swp_name); - goto comfsm_action_4_reload_obj; - - case STATE_TRANSVR_UNEXCEPTED: /* Case 2-5: DOWN -> UNEXPET */ - SWPS_INFO("Detect %s has error. :2-5\n",self->swp_name); - goto comfsm_action_4_unexpected; - - case STATE_TRANSVR_ISOLATED: /* Case 2-6: DOWN -> ISOLATE */ - SWPS_INFO("Detect %s be isolated. :2-6\n",self->swp_name); - goto comfsm_action_4_isolate_obj; - - default: - break; - } - goto comfsm_action_4_unexpected; - - case STATE_TRANSVR_UNEXCEPTED: - /* Filter out re-action */ - if (_is_except_happened_4_pmode(self, new_state)) { - goto comfsm_action_4_keep_state; - } - /* First action */ - switch (new_state) { - case STATE_TRANSVR_INIT: /* Case 3-1: UNEXPET -> INIT */ - SWPS_INFO("Detect %s is present. :3-1\n",self->swp_name); - self->temp = EVENT_TRANSVR_EXCEP_INIT; - return_val = ERR_TRANSVR_UNINIT; - goto comfsm_action_4_keep_state; - - case STATE_TRANSVR_CONNECTED: /* Case 3-2: UNEXPET -> UP */ - SWPS_INFO("Detect %s is present. :3-2\n",self->swp_name); - self->temp = EVENT_TRANSVR_EXCEP_UP; - goto comfsm_action_4_reload_obj; - - case STATE_TRANSVR_DISCONNECTED: /* Case 3-3: UNEXPET -> DOWN */ - SWPS_INFO("Detect %s is removed. :3-3\n",self->swp_name); - goto comfsm_action_4_disconnected; - - case STATE_TRANSVR_SWAPPED: /* Case 3-4: UNEXPET -> SWAP */ - SWPS_INFO("Detect %s is swapped. :3-4\n",self->swp_name); - self->temp = EVENT_TRANSVR_EXCEP_SWAP; - goto comfsm_action_4_reload_obj; - - case STATE_TRANSVR_UNEXCEPTED: /* Case 3-5: UNEXPET -> UNEXPET */ - self->temp = EVENT_TRANSVR_EXCEP_EXCEP; - return_val = ERR_TRANSVR_UNEXCPT; - goto comfsm_action_4_keep_state; - - case STATE_TRANSVR_ISOLATED: /* Case 3-6: UNEXPET -> ISOLATE */ - SWPS_INFO("Detect %s be isolated. :3-6\n",self->swp_name); - goto comfsm_action_4_isolate_obj; - - default: - break; - } - goto comfsm_action_4_unexpected; - - case STATE_TRANSVR_ISOLATED: - /* Filter out re-action */ - if (_is_except_happened_4_pmode(self, new_state)) { - goto comfsm_action_4_keep_state; - } - /* First action */ - switch (new_state) { - case STATE_TRANSVR_INIT: /* Case 4-1: ISOLATE -> INIT */ - SWPS_INFO("Detect %s internal error. :4-1\n",self->swp_name); - self->temp = EVENT_TRANSVR_EXCEP_INIT; - return_val = ERR_TRNASVR_BE_ISOLATED; - goto comfsm_action_4_keep_state; - - case STATE_TRANSVR_CONNECTED: /* Case 4-2: ISOLATE -> UP */ - SWPS_INFO("Detect %s internal error. :4-2\n",self->swp_name); - self->temp = EVENT_TRANSVR_EXCEP_UP; - return_val = ERR_TRNASVR_BE_ISOLATED; - goto comfsm_action_4_keep_state; - - case STATE_TRANSVR_DISCONNECTED: /* Case 4-3: ISOLATE -> DOWN */ - SWPS_INFO("Detect %s is removed. :4-3\n",self->swp_name); - goto comfsm_action_4_disconnected; - - case STATE_TRANSVR_SWAPPED: /* Case 4-4: ISOLATE -> SWAP */ - SWPS_INFO("Detect %s internal error. :4-4\n",self->swp_name); - self->temp = EVENT_TRANSVR_EXCEP_SWAP; - return_val = ERR_TRNASVR_BE_ISOLATED; - goto comfsm_action_4_keep_state; - - case STATE_TRANSVR_UNEXCEPTED: /* Case 4-5: ISOLATE -> UNEXPET */ - SWPS_INFO("Detect %s internal error. :4-5\n",self->swp_name); - self->temp = EVENT_TRANSVR_EXCEP_EXCEP; - return_val = ERR_TRNASVR_BE_ISOLATED; - goto comfsm_action_4_keep_state; - - case STATE_TRANSVR_ISOLATED: /* Case 4-6: ISOLATE -> ISOLATE */ - return_val = ERR_TRNASVR_BE_ISOLATED; - goto comfsm_action_4_keep_state; - - default: - break; - } - goto comfsm_action_4_unexpected; - - default: - break; - } - goto comfsm_action_4_unexpected; - - -comfsm_action_4_keep_state: - return return_val; - -comfsm_action_4_reinit_obj: - SWPS_DEBUG("FSM action: %s re-initial.\n", self->swp_name); - return_val = _transvr_init_handler(self); - goto comfsm_action_4_identify_event; - -comfsm_action_4_reload_obj: - SWPS_DEBUG("FSM action: %s reload.\n", self->swp_name); - self->type = new_type; - return_val = reload_transvr_obj(self, new_type); - goto comfsm_action_4_identify_event; - -comfsm_action_4_identify_event: - switch (return_val) { - case EVENT_TRANSVR_INIT_UP: - case EVENT_TRANSVR_TASK_DONE: - goto comfsm_action_4_connected; - - case EVENT_TRANSVR_INIT_DOWN: - goto comfsm_action_4_disconnected; - - case EVENT_TRANSVR_INIT_REINIT: - goto comfsm_action_4_nothing; - - case EVENT_TRANSVR_TASK_WAIT: - self->state = STATE_TRANSVR_INIT; - return ERR_TRANSVR_TASK_BUSY; - - case EVENT_TRANSVR_TASK_FAIL: - SWPS_INFO("%s detect EVENT_TRANSVR_TASK_FAIL.\n", self->swp_name); - goto comfsm_action_4_unexpected; - - case EVENT_TRANSVR_INIT_FAIL: - SWPS_INFO("%s detect EVENT_TRANSVR_INIT_FAIL.\n", self->swp_name); - goto comfsm_action_4_unexpected; - - case EVENT_TRANSVR_RELOAD_FAIL: - SWPS_INFO("%s detect EVENT_TRANSVR_RELOAD_FAIL.\n", self->swp_name); - goto comfsm_action_4_unexpected; - - case EVENT_TRANSVR_I2C_CRASH: - goto comfsm_action_4_report_i2c_crash; - - case EVENT_TRANSVR_EXCEP_ISOLATED: - goto comfsm_action_4_isolate_obj; - - default: - SWPS_INFO("%s detect undefined event:%d.\n", self->swp_name, return_val); - goto comfsm_action_4_unexpected; - } - -comfsm_action_4_nothing: - SWPS_DEBUG("FSM action: %s do nothing.\n", self->swp_name); - return 0; - -comfsm_action_4_connected: - SWPS_DEBUG("FSM action: %s Connected.\n", self->swp_name); - self->state = STATE_TRANSVR_CONNECTED; - self->type = new_type; - self->send_uevent(self, KOBJ_ADD); - _transvr_clean_retry(self); - return 0; - -comfsm_action_4_disconnected: - SWPS_DEBUG("FSM action: %s Disconnected. \n", self->swp_name); - self->state = STATE_TRANSVR_DISCONNECTED; - self->temp = EVENT_TRANSVR_TASK_DONE; - self->send_uevent(self, KOBJ_REMOVE); - _transvr_clean_retry(self); - _transvr_clean_handler(self); - return ERR_TRANSVR_UNPLUGGED; - -comfsm_action_4_report_i2c_crash: - SWPS_DEBUG("FSM action: %s report I2C crash.\n", self->swp_name); - self->state = STATE_TRANSVR_UNEXCEPTED; - return ERR_TRANSVR_I2C_CRASH; - -comfsm_action_4_isolate_obj: - SWPS_DEBUG("FSM action: %s isolate.\n", self->swp_name); - self->state = STATE_TRANSVR_ISOLATED; - return ERR_TRNASVR_BE_ISOLATED; - -comfsm_action_4_unexpected: - SWPS_INFO("FSM action: %s unexpected.\n", self->swp_name); - SWPS_INFO("Dump: :%d :0x%02x :%d :0x%02x\n", - old_state, old_type, new_state, new_type); - self->state = STATE_TRANSVR_UNEXCEPTED; - self->send_uevent(self, KOBJ_REMOVE); - _transvr_clean_handler(self); - return ERR_TRANSVR_UNEXCPT; -} - - -int -fake_fsm_4_direct_mode(struct transvr_obj_s* self, - char *caller_name){ - self->state = STATE_TRANSVR_CONNECTED; - self->type = TRANSVR_TYPE_FAKE; - return 0; -} - - -int -fake_fsm_4_polling_mode(struct transvr_obj_s* self, - char *caller_name){ - self->state = STATE_TRANSVR_CONNECTED; - self->type = TRANSVR_TYPE_FAKE; - return 0; -} - - -/* ========== Object functions for Initial procedure ========== - */ -int -transvr_init_common(struct transvr_obj_s *self){ - /* Nothing to update */ - return EVENT_TRANSVR_TASK_DONE; -} - - -int -transvr_init_fake(struct transvr_obj_s *self){ - return EVENT_TRANSVR_TASK_DONE; -} - - -int -transvr_init_sfp(struct transvr_obj_s *self){ - - int tmp_val = DEBUG_TRANSVR_INT_VAL; - int err_code = DEBUG_TRANSVR_INT_VAL; - char *err_msg = "ERR"; - - self->info = sft_detect_transvr_class(self); - /* Disable auto_config */ - if (!self->auto_config) { - return EVENT_TRANSVR_TASK_DONE; - } - /* Handle multi-rate */ - err_code = initfunc_sfp_handle_multi_rate_mode(self); - if (err_code < 0) { - err_msg = "initfunc_sfp_handle_multi_rate_mode fail!"; - goto err_transvr_init_sfp_1; - } - /* Handle 1G- RJ45 */ - tmp_val = err_code; - err_code = initfunc_sfp_handle_1g_rj45(self); - if (err_code < 0) { - err_msg = "initfunc_sfp_handle_1g_rj45 fail!"; - goto err_transvr_init_sfp_1; - } - tmp_val = (tmp_val > err_code ? tmp_val : err_code); - if (tmp_val > EVENT_TRANSVR_TASK_DONE) { - return tmp_val; - } - return EVENT_TRANSVR_TASK_DONE; - -err_transvr_init_sfp_1: - SWPS_INFO("%s: %s :%d :%s\n", - __func__, err_msg, err_code, self->swp_name); - return EVENT_TRANSVR_INIT_FAIL; -} - - -int -transvr_init_qsfp(struct transvr_obj_s *self){ - - int err = EVENT_TRANSVR_EXCEP_EXCEP; - char *emsg = "ERR"; - - self->info = qsft_detect_transvr_class(self); - if (!self->auto_config) { - return EVENT_TRANSVR_TASK_DONE; - } - err = initfunc_qsfp_handle_power_mode(self); - if (err < 0){ - emsg = "initfunc_qsfp_handle_tx_disable fail!"; - goto err_transvr_init_qsfp; - } - return EVENT_TRANSVR_TASK_DONE; - -err_transvr_init_qsfp: - SWPS_INFO("%s: %s :%d :%s\n", - __func__, emsg, err, self->swp_name); - return EVENT_TRANSVR_INIT_FAIL; -} - - -int -transvr_init_qsfp28(struct transvr_obj_s *self){ - - int tmp_val = EVENT_TRANSVR_EXCEP_EXCEP; - int err_val = EVENT_TRANSVR_EXCEP_EXCEP; - char *err_msg = "ERR"; - - /* Handle QSFP common */ - err_val = transvr_init_qsfp(self); - if (err_val < 0){ - err_msg = "transvr_init_qsfp fail!"; - goto err_transvr_init_qsfp28_1; - } - /* Disable auto_config */ - if (!self->auto_config) { - return err_val; - } - /* Handle CDR */ - tmp_val = err_val; - err_val = initfunc_qsfp28_handle_cdr(self); - if (err_val < 0){ - err_msg = "Handle CDR fail!"; - goto err_transvr_init_qsfp28_1; - } - tmp_val = (tmp_val > err_val ? tmp_val : err_val); - if (tmp_val > EVENT_TRANSVR_TASK_DONE) { - return tmp_val; - } - return EVENT_TRANSVR_TASK_DONE; - -err_transvr_init_qsfp28_1: - SWPS_INFO("%s: %s :%d :%s\n", - __func__, err_msg, err_val, self->swp_name); - return EVENT_TRANSVR_INIT_FAIL; -} - - -/* ========== Object Initial handler ========== - */ -static int -_is_transvr_valid(struct transvr_obj_s *self, - int type, - int state) { - /* [Return] - * 0 : OK, inserted - * EVENT_TRANSVR_INIT_DOWN : OK, removed - * EVENT_TRANSVR_INIT_FAIL : Outside error, type doesn't supported - * EVENT_TRANSVR_EXCEP_INIT : Internal error, state undefined - */ - switch (type) { - case TRANSVR_TYPE_SFP: - case TRANSVR_TYPE_QSFP: - case TRANSVR_TYPE_QSFP_PLUS: - case TRANSVR_TYPE_QSFP_28: - case TRANSVR_TYPE_UNPLUGGED: - case TRANSVR_TYPE_FAKE: - break; - default: - SWPS_INFO("detect undefined type:0x%02x on %s\n", - type, self->swp_name); - return EVENT_TRANSVR_INIT_FAIL; - } - switch (state) { - case STATE_TRANSVR_DISCONNECTED: - return EVENT_TRANSVR_INIT_DOWN; - case STATE_TRANSVR_INIT: - case STATE_TRANSVR_CONNECTED: - case STATE_TRANSVR_SWAPPED: - break; - default: - SWPS_INFO("detect undefined state:%d on %s\n", - state, self->swp_name); - return EVENT_TRANSVR_EXCEP_INIT; - } - return 0; -} - - -static int -_is_transvr_hw_ready(struct transvr_obj_s *self, - int type){ - /* [Return] - * EVENT_TRANSVR_TASK_DONE : Ready - * EVENT_TRANSVR_TASK_WAIT : Not ready - * EVENT_TRANSVR_INIT_FAIL : Error - */ - int addr = DEBUG_TRANSVR_INT_VAL; - int page = DEBUG_TRANSVR_INT_VAL; - int offs = DEBUG_TRANSVR_INT_VAL; - int bit = DEBUG_TRANSVR_INT_VAL; - int ready = DEBUG_TRANSVR_INT_VAL; - int err = DEBUG_TRANSVR_INT_VAL; - char *emsg = DEBUG_TRANSVR_STR_VAL; - uint8_t ab_val = DEBUG_TRANSVR_HEX_VAL; - - switch (type) { - case TRANSVR_TYPE_SFP: - addr = VAL_TRANSVR_8472_READY_ADDR; - page = VAL_TRANSVR_8472_READY_PAGE; - offs = VAL_TRANSVR_8472_READY_OFFSET; - bit = VAL_TRANSVR_8472_READY_BIT; - ready = VAL_TRANSVR_8472_READY_VALUE; - ab_val = VAL_TRANSVR_8472_READY_ABNORMAL; - break; - - case TRANSVR_TYPE_QSFP: - case TRANSVR_TYPE_QSFP_PLUS: - case TRANSVR_TYPE_QSFP_28: - addr = VAL_TRANSVR_8436_READY_ADDR; - page = VAL_TRANSVR_8436_READY_PAGE; - offs = VAL_TRANSVR_8436_READY_OFFSET; - bit = VAL_TRANSVR_8436_READY_BIT; - ready = VAL_TRANSVR_8436_READY_VALUE; - ab_val = VAL_TRANSVR_8436_READY_ABNORMAL; - break; - - case TRANSVR_TYPE_UNPLUGGED: - case TRANSVR_TYPE_FAKE: - return EVENT_TRANSVR_TASK_DONE; - - default: - emsg = "unexpected case"; - goto err_is_transvr_hw_ready; - } - /* Select target page */ - err = _common_setup_page(self, addr, page, offs, 1, 0); - if (err < 0) { - emsg = "setup page fail"; - goto err_is_transvr_hw_ready; - } - /* Check feature supported - * [Note] - * Some of transceiver/cables doesn't support "Status Indicators" - * (ex:DAC, RJ45 copper SFP ...etc). In these case, we bypass the - * step of checking Status Indicators, then state machine will take - * the following handle procedure. - */ - err = i2c_smbus_read_byte_data(self->i2c_client_p, - VAL_TRANSVR_COMID_OFFSET); - if (err < 0) { - emsg = "doesn't support Status Indicators"; - goto bypass_is_transvr_hw_ready; - } - /* Filter abnormal case */ - if (err == ab_val) { - emsg = "detect using unusual definition."; - goto bypass_is_transvr_hw_ready; - } - /* Get Status Indicators */ - err = i2c_smbus_read_byte_data(self->i2c_client_p, offs); - if (err < 0) { - emsg = "detect current value fail"; - goto err_is_transvr_hw_ready; - } - if ((err & (1<:%d\n", __func__, emsg, type); - return EVENT_TRANSVR_TASK_DONE; - -err_is_transvr_hw_ready: - SWPS_DEBUG("%s: %s :%d\n", __func__, emsg, type); - return EVENT_TRANSVR_INIT_FAIL; -} - - -static int -_is_transvr_support_ctle(struct transvr_obj_s *self) { - - switch (self->info) { - case TRANSVR_CLASS_OPTICAL_25G: - case TRANSVR_CLASS_OPTICAL_25G_AOC: - case TRANSVR_CLASS_OPTICAL_25G_SR: - case TRANSVR_CLASS_OPTICAL_25G_LR: - case TRANSVR_CLASS_OPTICAL_25G_ER: - case TRANSVR_CLASS_OPTICAL_100G: - case TRANSVR_CLASS_OPTICAL_100G_AOC: - case TRANSVR_CLASS_OPTICAL_100G_SR4: - case TRANSVR_CLASS_OPTICAL_100G_LR4: - case TRANSVR_CLASS_OPTICAL_100G_ER4: - case TRANSVR_CLASS_OPTICAL_100G_PSM4: - return 1; - default: - break; - } - return 0; -} - - -static int -_transvr_init_handler(struct transvr_obj_s *self){ - - int detect[2]; - int d_state = STATE_TRANSVR_UNEXCEPTED; - int d_type = TRANSVR_TYPE_ERROR; - int result = ERR_TRANSVR_UNINIT; - int retry = 6; /* (6+1) x 0.3 = 2.1s > spec:2.0s */ - int elimit = 63; - char emsg[64] = DEBUG_TRANSVR_STR_VAL; - - /* Clean and check callback */ - self->state = STATE_TRANSVR_INIT; - if (self->init == NULL) { - snprintf(emsg, elimit, "init() is null"); - goto initer_err_case_unexcept_0; - } - if (self->clean == NULL) { - snprintf(emsg, elimit, "clean() is null"); - goto initer_err_case_unexcept_0; - } - self->clean(self); - - /* Detect transceiver information */ - result = detect_transvr_state(self, detect); - if (result < 0) { - snprintf(emsg, elimit, "detect_transvr_state() fail"); - switch (result) { - case ERR_TRANSVR_I2C_CRASH: - goto initer_err_case_i2c_ceash; - case ERR_TRNASVR_BE_ISOLATED: - goto initer_err_case_be_isolated; - - case ERR_TRANSVR_UNEXCPT: - default: - break; - } - goto initer_err_case_retry_1; - } - d_state = detect[0]; - d_type = detect[1]; - - /* Verify transceiver type and state */ - switch (_is_transvr_valid(self, d_type, d_state)) { - case 0: - break; - case EVENT_TRANSVR_INIT_DOWN: - goto initer_ok_case_down;; - case EVENT_TRANSVR_INIT_FAIL: - snprintf(emsg, elimit, "transceiver type doesn't support"); - goto initer_err_case_alarm_to_user; - case EVENT_TRANSVR_EXCEP_INIT: - default: - goto initer_err_case_unexcept_1; - } - - /* Handle reload case */ - if (self->type != d_type){ - /* This is the protect mechanism. Normally, This case will not happen. - * When State machine detect swap event during initial, It will trigger - * reload function to ensure type correct. */ - if (_reload_transvr_obj(self, d_type) < 0){ - snprintf(emsg, elimit, "reload object fail"); - goto initer_err_case_unexcept_1; - } - } - - /* Check transceiver HW initial ready */ - switch (_is_transvr_hw_ready(self, d_type)) { - case EVENT_TRANSVR_TASK_DONE: - break; - case EVENT_TRANSVR_TASK_WAIT: - goto initer_err_case_retry_1; - case EVENT_TRANSVR_INIT_FAIL: - default: - goto initer_err_case_unexcept_1; - } - - /* Try to update all and check */ - if (self->update_all(self, 1) < 0){ - /* For some transceiver, EEPROME has lag issues during initial stage. - * In this case, we set status back to STATE_TRANSVR_NEW, than it will - * be checked in next polling cycle. */ - goto initer_err_case_retry_1; - } - - /* Execute init() call back */ - result = self->init(self); - switch (result) { - case EVENT_TRANSVR_TASK_DONE: - break; - case EVENT_TRANSVR_TASK_WAIT: - goto initer_ok_case_wait; - - default: - snprintf(emsg, elimit, "undefined init() return:%d\n", result); - goto initer_err_case_unexcept_1; - } - goto initer_ok_case_up; - - -initer_ok_case_wait: - self->dump_all(self); - return EVENT_TRANSVR_TASK_WAIT; - -initer_ok_case_up: - self->state = STATE_TRANSVR_CONNECTED; - self->temp = 0; - self->dump_all(self); - return EVENT_TRANSVR_INIT_UP; - -initer_ok_case_down: - self->temp = 0; - self->state = STATE_TRANSVR_DISCONNECTED; - return EVENT_TRANSVR_INIT_DOWN; - -initer_err_case_i2c_ceash: - SWPS_DEBUG("%s: %s :%s :I2C crash\n", - __func__, emsg, self->swp_name); - self->state = STATE_TRANSVR_UNEXCEPTED; - return EVENT_TRANSVR_I2C_CRASH; - -initer_err_case_be_isolated: - SWPS_DEBUG("%s: %s :%s :isolated\n", - __func__, emsg, self->swp_name); - self->state = STATE_TRANSVR_ISOLATED; - return EVENT_TRANSVR_EXCEP_ISOLATED; - -initer_err_case_retry_1: - SWPS_DEBUG("%s: %s :%s :retry\n", - __func__, emsg, self->swp_name); - if (_transvr_handle_retry(self, retry) == 0) { - self->state = STATE_TRANSVR_NEW; - return EVENT_TRANSVR_INIT_REINIT; - } - goto initer_err_case_alarm_to_user; - -initer_err_case_unexcept_1: - self->clean(self); -initer_err_case_unexcept_0: - self->state = STATE_TRANSVR_UNEXCEPTED; - if (_is_except_happened_4_pmode(self, d_state) && - (self->mode == TRANSVR_MODE_POLLING) ){ - SWPS_INFO("%s: %s :%s\n", __func__, emsg, self->swp_name); - SWPS_INFO("Dump: :%d :%d :%d :%d\n", - self->state, self->type, d_state, d_type); - } - return EVENT_TRANSVR_INIT_FAIL; - -initer_err_case_alarm_to_user: - SWPS_DEBUG("%s: %s :%s :alarm_to_user\n", - __func__, emsg, self->swp_name); - self->state = STATE_TRANSVR_UNEXCEPTED; - alarm_msg_2_user(self, "detected transceiver/cables not meet SFF standard"); - return EVENT_TRANSVR_INIT_FAIL; -} - - -/* ========== Object functions for Clean procedure ========== - */ -int -_transvr_clean_handler(struct transvr_obj_s *self){ - - int retval = DEBUG_TRANSVR_INT_VAL; - - if (!self->clean) { - SWPS_ERR("%s: %s clean() is NULL.\n", - __func__, self->swp_name); - return EVENT_TRANSVR_TASK_FAIL; - } - retval = self->clean(self); - if (retval != EVENT_TRANSVR_TASK_DONE){ - SWPS_ERR("%s: %s clean() fail. [ERR]:%d\n", - __func__, self->swp_name, retval); - return retval; - } - return EVENT_TRANSVR_TASK_DONE; -} - - -int -common_transvr_clean(struct transvr_obj_s *self){ - - transvr_task_free_all(self); - transvr_cache_free_all(self); - return EVENT_TRANSVR_TASK_DONE; -} - - -int -qsfp_transvr_clean(struct transvr_obj_s *self){ - - int retval; - int lpower_config = 1; - - retval = _taskfunc_qsfp_setup_power_mod(self, lpower_config); - if (retval < 0){ - SWPS_ERR("%s: Set lpmod fail! :%d\n", - __func__, retval); - return retval; - } - retval = common_transvr_clean(self); - if (retval < 0){ - SWPS_ERR("%s: common_transvr_clean fail! :%d\n", - __func__, retval); - return retval; - } - return EVENT_TRANSVR_TASK_DONE; -} - - -int -fake_transvr_clean(struct transvr_obj_s *self){ - - return EVENT_TRANSVR_TASK_DONE; -} - - -/* ========== Object functions for check and update ========== - */ -int -common_transvr_check(struct transvr_obj_s *self){ - - char fun_str[32] = "common_transvr_check"; - - if (self->mode != TRANSVR_MODE_POLLING) { - SWPS_ERR("%s: mode:%d is not TRANSVR_MODE_POLLING\n", - fun_str, self->mode); - return ERR_TRANSVR_UNEXCPT; - } - /* Trigger delay task */ - transvr_task_run_all(self); - /* Trigger state machine to check and update */ - return self->fsm_4_polling(self, fun_str); -} - - -int -fake_transvr_check(struct transvr_obj_s *self){ - return 0; -} - - -/* ========== Functions for Factory pattern ========== - */ -static int -setup_transvr_public_cb(struct transvr_obj_s *self, - int transvr_type){ - switch (transvr_type){ - case TRANSVR_TYPE_SFP: - self->get_id = common_get_id; - self->get_ext_id = common_get_ext_id; - self->get_connector = common_get_connector; - self->get_vendor_name = common_get_vendor_name; - self->get_vendor_pn = common_get_vendor_pn; - self->get_vendor_rev = common_get_vendor_rev; - self->get_vendor_sn = common_get_vendor_sn; - self->get_power_cls = unsupported_get_func; - self->get_br = common_get_br; - self->get_len_sm = sfp_get_len_sm; - self->get_len_smf = common_get_len_smf; - self->get_len_om1 = common_get_len_om1; - self->get_len_om2 = common_get_len_om2; - self->get_len_om3 = common_get_len_om3; - self->get_len_om4 = common_get_len_om4; - self->get_comp_rev = common_get_comp_rev; - self->get_comp_eth_1 = sfp_get_comp_eth_1; - self->get_comp_eth_10 = sfp_get_comp_eth_10; - self->get_comp_eth_10_40 = unsupported_get_func; - self->get_comp_extend = common_get_comp_extended; - self->get_cdr = unsupported_get_func; - self->get_rate_id = sfp_get_rate_id; - self->get_soft_rs0 = sfp_get_soft_rs0; - self->get_soft_rs1 = sfp_get_soft_rs1; - self->get_info = common_get_info; - self->get_if_type = sfp_get_if_type; - self->get_if_speed = sfp_get_if_speed; - self->get_if_lane = common_get_if_lane; - self->get_curr_temp = sfp_get_transvr_temp; - self->get_curr_vol = sfp_get_transvr_voltage; - self->get_soft_rx_los = unsupported_get_func2; - self->get_soft_tx_disable = unsupported_get_func2; - self->get_soft_tx_fault = unsupported_get_func2; - self->get_auto_tx_disable = unsupported_get_func2; - self->get_tx_bias = sfp_get_transvr_tx_bias; - self->get_tx_power = sfp_get_transvr_tx_power; - self->get_rx_power = sfp_get_transvr_rx_power; - self->get_tx_eq = sfp_get_transvr_tx_eq; - self->get_rx_am = unsupported_get_func2; - self->get_rx_em = sfp_get_transvr_rx_em; - self->get_wavelength = sfp_get_wavelength; - self->get_extphy_offset = sfp_get_1g_rj45_extphy_offset; - self->get_extphy_reg = sfp_get_1g_rj45_extphy_reg; - self->set_cdr = unsupported_set_func; - self->set_soft_rs0 = sfp_set_soft_rs0; - self->set_soft_rs1 = sfp_set_soft_rs1; - self->set_soft_tx_disable = unsupported_set_func; - self->set_auto_tx_disable = unsupported_set_func; - self->set_tx_eq = sfp_set_tx_eq; - self->set_rx_am = unsupported_set_func; - self->set_rx_em = sfp_set_rx_em; - self->set_extphy_offset = sfp_set_1g_rj45_extphy_offset; - self->set_extphy_reg = sfp_set_1g_rj45_extphy_reg; - return 0; - - case TRANSVR_TYPE_QSFP: - case TRANSVR_TYPE_QSFP_PLUS: - self->get_id = common_get_id; - self->get_ext_id = common_get_ext_id; - self->get_connector = common_get_connector; - self->get_vendor_name = common_get_vendor_name; - self->get_vendor_pn = common_get_vendor_pn; - self->get_vendor_rev = common_get_vendor_rev; - self->get_vendor_sn = common_get_vendor_sn; - self->get_power_cls = qsfp_get_power_cls; - self->get_br = common_get_br; - self->get_len_sm = unsupported_get_func; - self->get_len_smf = common_get_len_smf; - self->get_len_om1 = common_get_len_om1; - self->get_len_om2 = common_get_len_om2; - self->get_len_om3 = common_get_len_om3; - self->get_len_om4 = common_get_len_om4; - self->get_comp_rev = common_get_comp_rev; - self->get_comp_eth_1 = qsfp_get_comp_eth; - self->get_comp_eth_10 = unsupported_get_func; - self->get_comp_eth_10_40 = qsfp_get_comp_10_40; - self->get_comp_extend = common_get_comp_extended; - self->get_cdr = unsupported_get_func; - self->get_rate_id = unsupported_get_func; - self->get_soft_rs0 = unsupported_get_func; /* TBD */ - self->get_soft_rs1 = unsupported_get_func; /* TBD */ - self->get_info = common_get_info; - self->get_if_type = qsfp_get_if_type; - self->get_if_speed = qsfp_get_if_speed; - self->get_if_lane = common_get_if_lane; - self->get_curr_temp = qsfp_get_transvr_temp; - self->get_curr_vol = qsfp_get_transvr_voltage; - self->get_soft_rx_los = qsfp_get_soft_rx_los; - self->get_soft_tx_disable = qsfp_get_soft_tx_disable; - self->get_soft_tx_fault = qsfp_get_soft_tx_fault; - self->get_auto_tx_disable = qsfp_get_auto_tx_disable; - self->get_tx_bias = qsfp_get_transvr_tx_bias; - self->get_tx_power = qsfp_get_transvr_tx_power; - self->get_rx_power = qsfp_get_transvr_rx_power; - self->get_tx_eq = unsupported_get_func2; - self->get_rx_am = unsupported_get_func2; - self->get_rx_em = unsupported_get_func2; - self->get_wavelength = qsfp_get_wavelength; - self->get_extphy_offset = unsupported_get_func2; - self->get_extphy_reg = unsupported_get_func2; - self->set_cdr = unsupported_set_func; - self->set_soft_rs0 = unsupported_set_func; /* TBD */ - self->set_soft_rs1 = unsupported_set_func; /* TBD */ - self->set_soft_tx_disable = qsfp_set_soft_tx_disable; - self->set_auto_tx_disable = qsfp_set_auto_tx_disable; - self->set_tx_eq = unsupported_set_func; - self->set_rx_am = unsupported_set_func; - self->set_rx_em = unsupported_set_func; - self->set_extphy_offset = unsupported_set_func; - self->set_extphy_reg = unsupported_set_func; - return 0; - - case TRANSVR_TYPE_QSFP_28: - self->get_id = common_get_id; - self->get_ext_id = common_get_ext_id; - self->get_connector = common_get_connector; - self->get_vendor_name = common_get_vendor_name; - self->get_vendor_pn = common_get_vendor_pn; - self->get_vendor_rev = common_get_vendor_rev; - self->get_vendor_sn = common_get_vendor_sn; - self->get_power_cls = qsfp_get_power_cls; - self->get_br = common_get_br; - self->get_len_sm = unsupported_get_func; - self->get_len_smf = common_get_len_smf; - self->get_len_om1 = common_get_len_om1; - self->get_len_om2 = common_get_len_om2; - self->get_len_om3 = common_get_len_om3; - self->get_len_om4 = common_get_len_om4; - self->get_comp_rev = common_get_comp_rev; - self->get_comp_eth_1 = qsfp_get_comp_eth; - self->get_comp_eth_10 = unsupported_get_func; - self->get_comp_eth_10_40 = qsfp_get_comp_10_40; - self->get_comp_extend = common_get_comp_extended; - self->get_cdr = qsfp_get_cdr; - self->get_rate_id = unsupported_get_func; - self->get_soft_rs0 = unsupported_get_func; /* TBD */ - self->get_soft_rs1 = unsupported_get_func; /* TBD */ - self->get_info = common_get_info; - self->get_if_type = qsfp_get_if_type; - self->get_if_speed = qsfp_get_if_speed; - self->get_if_lane = common_get_if_lane; - self->get_curr_temp = qsfp_get_transvr_temp; - self->get_curr_vol = qsfp_get_transvr_voltage; - self->get_soft_rx_los = qsfp_get_soft_rx_los; - self->get_soft_tx_disable = qsfp_get_soft_tx_disable; - self->get_soft_tx_fault = qsfp_get_soft_tx_fault; - self->get_auto_tx_disable = qsfp_get_auto_tx_disable; - self->get_tx_bias = qsfp_get_transvr_tx_bias; - self->get_tx_power = qsfp_get_transvr_tx_power; - self->get_rx_power = qsfp_get_transvr_rx_power; - self->get_tx_eq = qsfp_get_transvr_tx_eq; - self->get_rx_am = qsfp_get_transvr_rx_am; - self->get_rx_em = qsfp_get_transvr_rx_em; - self->get_wavelength = qsfp_get_wavelength; - self->get_extphy_offset = unsupported_get_func2; - self->get_extphy_reg = unsupported_get_func2; - self->set_cdr = qsfp_set_cdr; - self->set_soft_rs0 = unsupported_set_func; /* TBD */ - self->set_soft_rs1 = unsupported_set_func; /* TBD */ - self->set_soft_tx_disable = qsfp_set_soft_tx_disable; - self->set_auto_tx_disable = qsfp_set_auto_tx_disable; - self->set_tx_eq = qsfp_set_tx_eq; - self->set_rx_am = qsfp_set_rx_am; - self->set_rx_em = qsfp_set_rx_em; - self->set_extphy_offset = unsupported_set_func; - self->set_extphy_reg = unsupported_set_func; - return 0; - - case TRANSVR_TYPE_FAKE: - self->get_id = fake_get_hex; - self->get_ext_id = fake_get_hex; - self->get_connector = fake_get_hex; - self->get_vendor_name = fake_get_str; - self->get_vendor_pn = fake_get_str; - self->get_vendor_rev = fake_get_str; - self->get_vendor_sn = fake_get_str; - self->get_power_cls = fake_get_int; - self->get_br = fake_get_hex; - self->get_len_sm = fake_get_int; - self->get_len_smf = fake_get_int; - self->get_len_om1 = fake_get_int; - self->get_len_om2 = fake_get_int; - self->get_len_om3 = fake_get_int; - self->get_len_om4 = fake_get_int; - self->get_comp_rev = fake_get_hex; - self->get_comp_eth_1 = fake_get_hex; - self->get_comp_eth_10 = fake_get_hex; - self->get_comp_eth_10_40 = fake_get_hex; - self->get_comp_extend = fake_get_hex; - self->get_cdr = fake_get_hex; - self->get_rate_id = fake_get_hex; - self->get_soft_rs0 = fake_get_binary; - self->get_soft_rs1 = fake_get_binary; - self->get_info = fake_get_int; - self->get_if_type = fake_get_str; - self->get_if_speed = fake_get_str; - self->get_if_lane = fake_get_str; - self->get_curr_temp = fake_get_str; - self->get_curr_vol = fake_get_str; - self->get_soft_rx_los = fake_get_str; - self->get_soft_tx_disable = fake_get_str; - self->get_soft_tx_fault = fake_get_str; - self->get_auto_tx_disable = fake_get_str; - self->get_tx_bias = fake_get_str; - self->get_tx_power = fake_get_str; - self->get_rx_power = fake_get_str; - self->get_tx_eq = fake_get_str; - self->get_rx_am = fake_get_str; - self->get_rx_em = fake_get_str; - self->get_wavelength = fake_get_str; - self->get_extphy_offset = fake_get_str; - self->get_extphy_reg = fake_get_str; - self->set_cdr = fake_set_hex; - self->set_soft_rs0 = fake_set_int; - self->set_soft_rs1 = fake_set_int; - self->set_soft_tx_disable = fake_set_int; - self->set_auto_tx_disable = fake_set_int; - self->set_tx_eq = fake_set_int; - self->set_rx_am = fake_set_int; - self->set_rx_em = fake_set_int; - self->set_extphy_offset = fake_set_hex; - self->set_extphy_reg = fake_set_hex; - return 0; - - default: - break; - } - SWPS_WARN("%s: Detect non-defined type:%d\n", __func__, transvr_type); - return ERR_TRANSVR_UNEXCPT; -} - - -static int -setup_transvr_private_cb(struct transvr_obj_s *self, - int transvr_type){ - switch (transvr_type){ - case TRANSVR_TYPE_SFP: - self->init = transvr_init_sfp; - self->clean = common_transvr_clean; - self->check = common_transvr_check; - self->update_all = _sfp_update_attr_all; - self->fsm_4_direct = common_fsm_4_direct_mode; - self->fsm_4_polling = common_fsm_4_polling_mode; - self->send_uevent = sfp_send_uevent; - self->dump_all = sfp_transvr_dump; - return 0; - - case TRANSVR_TYPE_QSFP: - case TRANSVR_TYPE_QSFP_PLUS: - self->init = transvr_init_qsfp; - self->clean = qsfp_transvr_clean; - self->check = common_transvr_check; - self->update_all = _qsfp_update_attr_all; - self->fsm_4_direct = common_fsm_4_direct_mode; - self->fsm_4_polling = common_fsm_4_polling_mode; - self->send_uevent = qsfp_send_uevent; - self->dump_all = qsfp_transvr_dump; - return 0; - - case TRANSVR_TYPE_QSFP_28: - self->init = transvr_init_qsfp28; - self->clean = qsfp_transvr_clean; - self->check = common_transvr_check; - self->update_all = _qsfp_update_attr_all; - self->fsm_4_direct = common_fsm_4_direct_mode; - self->fsm_4_polling = common_fsm_4_polling_mode; - self->send_uevent = qsfp_send_uevent; - self->dump_all = qsfp_transvr_dump; - return 0; - - case TRANSVR_TYPE_FAKE: - self->init = transvr_init_fake; - self->clean = fake_transvr_clean; - self->check = fake_transvr_check; - self->update_all = fake_transvr_update; - self->fsm_4_direct = fake_fsm_4_direct_mode; - self->fsm_4_polling = fake_fsm_4_polling_mode; - self->send_uevent = fake_send_uevent; - self->dump_all = fake_transvr_dump; - return 0; - - default: - break; - } - SWPS_WARN("%s: Detect non-defined type:%d\n", __func__, transvr_type); - return ERR_TRANSVR_UNEXCPT; -} - - -static struct eeprom_map_s * -get_eeprom_map(int transvr_type){ - - switch (transvr_type){ - case TRANSVR_TYPE_SFP: - return &eeprom_map_sfp; - case TRANSVR_TYPE_QSFP: - case TRANSVR_TYPE_QSFP_PLUS: - return &eeprom_map_qsfp; - case TRANSVR_TYPE_QSFP_28: - return &eeprom_map_qsfp28; - - default: - break; - } - SWPS_WARN("%s: Detect non-defined type:%d\n", __func__, transvr_type); - return NULL; -} - - -static int -setup_transvr_ssize_attr(char *swp_name, - struct transvr_obj_s *self, - struct eeprom_map_s *map_p, - struct ioexp_obj_s *ioexp_obj_p, - int ioexp_virt_offset, - int transvr_type, - int chipset_type, - int chan_id, - int run_mode){ - switch (run_mode){ - case TRANSVR_MODE_DIRECT: /* Direct access device mode */ - case TRANSVR_MODE_POLLING: /* Polling mode, read from cache */ - self->mode = run_mode; - break; - default: - SWPS_ERR("%s: non-defined run_mode:%d\n", - __func__, run_mode); - self->mode = DEBUG_TRANSVR_INT_VAL; - return -1; - } - self->eeprom_map_p = map_p; - self->ioexp_obj_p = ioexp_obj_p; - self->ioexp_virt_offset = ioexp_virt_offset; - self->chan_id = chan_id; - self->layout = transvr_type; - self->type = transvr_type; - self->chipset_type = chipset_type; - self->state = STATE_TRANSVR_NEW; - self->info = STATE_TRANSVR_NEW; - self->auto_tx_disable = VAL_TRANSVR_FUNCTION_DISABLE; - strncpy(self->swp_name, swp_name, 32); - mutex_init(&self->lock); - return 0; -} - - -static int -setup_transvr_dsize_attr(struct transvr_obj_s *self){ - - char *emsg = DEBUG_TRANSVR_STR_VAL; - - self->vendor_name = kzalloc((LEN_TRANSVR_M_STR * sizeof(char)), GFP_KERNEL); - if (!self->vendor_name){ - emsg = "vendor_name"; - goto err_setup_d_attr; - } - self->vendor_pn = kzalloc((LEN_TRANSVR_M_STR * sizeof(char)), GFP_KERNEL); - if (!self->vendor_pn){ - emsg = "vendor_pn"; - goto err_setup_d_attr; - } - self->vendor_rev = kzalloc((LEN_TRANSVR_M_STR * sizeof(char)), GFP_KERNEL); - if (!self->vendor_rev){ - emsg = "vendor_rev"; - goto err_setup_d_attr; - } - self->vendor_sn = kzalloc((LEN_TRANSVR_M_STR * sizeof(char)), GFP_KERNEL); - if (!self->vendor_sn){ - emsg = "vendor_sn"; - goto err_setup_d_attr; - } - self->worker_p = NULL; - return 0; - -err_setup_d_attr: - SWPS_ERR("%s: %s kzalloc fail!", __func__, emsg); - return ERR_TRANSVR_UNEXCPT; -} - - -static int -setup_i2c_client(struct transvr_obj_s *self){ - - struct i2c_adapter *adap = NULL; - struct i2c_client *client = NULL; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - - adap = i2c_get_adapter(self->chan_id); - if(!adap){ - snprintf(err_msg, sizeof(err_msg), - "can not get adap:%d", self->chan_id); - goto err_setup_i2c_client; - } - client = kzalloc(sizeof(*client), GFP_KERNEL); - if (!client){ - snprintf(err_msg, sizeof(err_msg), - "can not kzalloc client:%d", self->chan_id); - goto err_setup_i2c_client; - } - client->adapter = adap; - self->i2c_client_p = client; - self->i2c_client_p->addr = VAL_TRANSVR_COMID_ARREESS; - return 0; - -err_setup_i2c_client: - SWPS_ERR("%s: %s\n", __func__, err_msg); - return ERR_TRANSVR_UNEXCPT; -} - - -struct transvr_obj_s * -create_transvr_obj(char *swp_name, - int chan_id, - struct ioexp_obj_s *ioexp_obj_p, - int ioexp_virt_offset, - int transvr_type, - int chipset_type, - int run_mode){ - - struct transvr_obj_s *result_p; - struct eeprom_map_s *map_p; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - - /* Allocate transceiver object */ - map_p = get_eeprom_map(transvr_type); - if (!map_p){ - snprintf(err_msg, sizeof(err_msg), - "Invalid transvr_type:%d", transvr_type); - goto err_create_transvr_fail; - } - result_p = kzalloc(sizeof(*result_p), GFP_KERNEL); - if (!result_p){ - snprintf(err_msg, sizeof(err_msg), "kzalloc fail"); - goto err_create_transvr_fail; - } - /* Prepare static size attributes */ - if (setup_transvr_ssize_attr(swp_name, - result_p, - map_p, - ioexp_obj_p, - ioexp_virt_offset, - transvr_type, - chipset_type, - chan_id, - run_mode) < 0){ - goto err_create_transvr_sattr_fail; - } - /* Prepare dynamic size attributes */ - if (setup_transvr_dsize_attr(result_p) < 0){ - goto err_create_transvr_dattr_fail; - } - /* Prepare call back functions of object */ - if (setup_transvr_public_cb(result_p, transvr_type) < 0){ - goto err_create_transvr_dattr_fail; - } - /* Prepare call back functions of object */ - if (setup_transvr_private_cb(result_p, transvr_type) < 0){ - goto err_create_transvr_dattr_fail; - } - /* Prepare i2c client object */ - if (setup_i2c_client(result_p) < 0){ - goto err_create_transvr_dattr_fail; - } - return result_p; - -err_create_transvr_dattr_fail: - kfree(result_p->vendor_sn); - kfree(result_p->vendor_rev); - kfree(result_p->vendor_pn); - kfree(result_p->vendor_name); -err_create_transvr_sattr_fail: - kfree(result_p); -err_create_transvr_fail: - SWPS_ERR("%s: %s :%d :%d :%d\n", - __func__, err_msg, chan_id, ioexp_virt_offset, transvr_type); - return NULL; -} -EXPORT_SYMBOL(create_transvr_obj); - - -static int -_reload_transvr_obj(struct transvr_obj_s *self, - int new_type){ - - struct eeprom_map_s *new_map_p; - struct eeprom_map_s *old_map_p = self->eeprom_map_p; - struct i2c_client *old_i2c_p = self->i2c_client_p; - int old_type = self->type; - - /* Change state to STATE_TRANSVR_INIT */ - self->state = STATE_TRANSVR_INIT; - self->type = new_type; - /* Replace EEPROME map */ - new_map_p = get_eeprom_map(new_type); - if (!new_map_p){ - goto err_private_reload_func_1; - } - self->eeprom_map_p = new_map_p; - /* Reload i2c client */ - if (setup_i2c_client(self) < 0){ - goto err_private_reload_func_2; - } - /* Replace call back functions */ - if (setup_transvr_public_cb(self, new_type) < 0){ - goto err_private_reload_func_3; - } - if (setup_transvr_private_cb(self, new_type) < 0){ - goto err_private_reload_func_3; - } - if(old_i2c_p){ - i2c_put_adapter(old_i2c_p->adapter); - } - kfree(old_i2c_p); - return 0; - -err_private_reload_func_3: - SWPS_INFO("%s: init() fail!\n", __func__); - if(old_i2c_p){ - i2c_put_adapter(old_i2c_p->adapter); - } - kfree(old_i2c_p); - self->state = STATE_TRANSVR_UNEXCEPTED; - self->type = TRANSVR_TYPE_ERROR; - return -2; - -err_private_reload_func_2: - self->eeprom_map_p = old_map_p; - self->i2c_client_p = old_i2c_p; -err_private_reload_func_1: - self->state = STATE_TRANSVR_UNEXCEPTED; - self->type = old_type; - SWPS_INFO("%s fail! :0x%02x\n", __func__, new_type); - return -1; -} - - -static int -reload_transvr_obj(struct transvr_obj_s *self, - int new_type){ - - int result_val = ERR_TRANSVR_UNEXCPT; - - /* Reload phase */ - result_val = _reload_transvr_obj(self, new_type); - if (result_val < 0){ - SWPS_INFO("%s: reload phase fail! :%d\n", - __func__, result_val); - return EVENT_TRANSVR_RELOAD_FAIL; - } - /* Initial phase */ - result_val = _transvr_init_handler(self); - if (result_val < 0){ - SWPS_INFO("%s: initial phase fail! :%d\n", - __func__, result_val); - } - return result_val; -} - - -int -isolate_transvr_obj(struct transvr_obj_s *self) { - - self->state = STATE_TRANSVR_ISOLATED; - SWPS_INFO("%s: %s be isolated\n", __func__, self->swp_name); - return 0; -} -EXPORT_SYMBOL(isolate_transvr_obj); - - -int -resync_channel_tier_2(struct transvr_obj_s *self) { - - int val = TRANSVR_TYPE_ERROR; - - if (self->state == STATE_TRANSVR_ISOLATED) { - return 0; - } - self->i2c_client_p->addr = VAL_TRANSVR_COMID_ARREESS; - val = i2c_smbus_read_byte_data(self->i2c_client_p, - VAL_TRANSVR_COMID_OFFSET); - if (val < 0) { - return -1; - } - return 0; -} -EXPORT_SYMBOL(resync_channel_tier_2); - -/* For build single module using (Ex: ONL platform) */ -MODULE_LICENSE("GPL"); - - -/* ----------------------------------------- - * ToDo List - * ----------------------------------------- - * 1. _sfp_detect_class_by_feature() - * => Need check ACC use case. - * 2. _sfp_detect_class_by_1g_ethernet() - * => Need check 0.1G use case. - * 3. Loopback transceiver use case. - * => Less much data - * 4. _qsfp_detect_class_by_extend_comp() - * => Verify 100G CWDM4 - * => Verify Obsolete (assigned before 100G CWDM4 MSA required FEC) - * => Verify 100G CLR4 - * => Verify 100GE-DWDM2 - * => Verify 40G PSM4 Parallel SMF - * => Verify 100G ACC (Active Copper Cable) or 25GAUI C2M ACC. - * => Verify 100G ACC or 25GAUI C2M ACC. - * => Verify 25GBASE-LR - * => Verify 40G Active Cable (XLPPI) - */ - - - - - - - - diff --git a/packages/platforms/inventec/x86-64/d10056/modules/builds/src/transceiver.h b/packages/platforms/inventec/x86-64/d10056/modules/builds/src/transceiver.h deleted file mode 100644 index 0c6cd0060..000000000 --- a/packages/platforms/inventec/x86-64/d10056/modules/builds/src/transceiver.h +++ /dev/null @@ -1,809 +0,0 @@ -#ifndef TRANSCEIVER_H -#define TRANSCEIVER_H - -#include - -/* advanced features control */ -#define TRANSVR_INFO_DUMP_ENABLE (1) -#define TRANSVR_INFO_CACHE_ENABLE (1) -#define TRANSVR_UEVENT_ENABLE (1) - -/* Transceiver type define */ -#define TRANSVR_TYPE_UNKNOW_1 (0x00) -#define TRANSVR_TYPE_UNKNOW_2 (0xff) -#define TRANSVR_TYPE_SFP (0x03) /* Define for SFP, SFP+, SFP28 */ -#define TRANSVR_TYPE_QSFP (0x0c) -#define TRANSVR_TYPE_QSFP_PLUS (0x0d) -#define TRANSVR_TYPE_QSFP_28 (0x11) -#define TRANSVR_TYPE_UNPLUGGED (0xfa) /* Define for ERROR handle */ -#define TRANSVR_TYPE_FAKE (0xfc) /* Define for ERROR handle */ -#define TRANSVR_TYPE_INCONSISTENT (0xfd) /* Define for ERROR handle */ -#define TRANSVR_TYPE_ERROR (0xfe) /* Define for ERROR handle */ - -/* Transceiver class for base info */ -#define TRANSVR_CLASS_UNSPECIFIED (0) -#define TRANSVR_CLASS_ERROR (-26001) -#define TRANSVR_CLASS_1G (26001) -#define TRANSVR_CLASS_10G (26011) -#define TRANSVR_CLASS_25G (26021) -#define TRANSVR_CLASS_40G (26041) -#define TRANSVR_CLASS_100G (26101) -#define TRANSVR_CLASS_NO_SPERARABLE (26901) -#define TRANSVR_CLASS_EXTEND_COMP (26902) -/* Transceiver class for Optical 1G */ -#define TRANSVR_CLASS_OPTICAL (27000) -#define TRANSVR_CLASS_OPTICAL_100 (27001) -#define TRANSVR_CLASS_OPTICAL_1G (27002) -#define TRANSVR_CLASS_OPTICAL_1G_AOC (27003) -#define TRANSVR_CLASS_OPTICAL_1G_SX (27004) -#define TRANSVR_CLASS_OPTICAL_1G_LX (27005) -#define TRANSVR_CLASS_OPTICAL_1G_EX (27006) -/* Transceiver class for Optical 10G */ -#define TRANSVR_CLASS_OPTICAL_10G (27010) -#define TRANSVR_CLASS_OPTICAL_10G_S_AOC (27011) -#define TRANSVR_CLASS_OPTICAL_10G_S_SR (27012) -#define TRANSVR_CLASS_OPTICAL_10G_S_LR (27013) -#define TRANSVR_CLASS_OPTICAL_10G_S_ER (27014) -#define TRANSVR_CLASS_OPTICAL_10G_Q_AOC (27015) -#define TRANSVR_CLASS_OPTICAL_10G_Q_SR (27016) -#define TRANSVR_CLASS_OPTICAL_10G_Q_LR (27017) -#define TRANSVR_CLASS_OPTICAL_10G_Q_ER (27018) -/* Transceiver class for Optical 25G */ -#define TRANSVR_CLASS_OPTICAL_25G (27020) -#define TRANSVR_CLASS_OPTICAL_25G_AOC (27021) -#define TRANSVR_CLASS_OPTICAL_25G_SR (27022) -#define TRANSVR_CLASS_OPTICAL_25G_LR (27023) -#define TRANSVR_CLASS_OPTICAL_25G_ER (27024) -/* Transceiver class for Optical 40G */ -#define TRANSVR_CLASS_OPTICAL_40G (27040) -#define TRANSVR_CLASS_OPTICAL_40G_AOC (27041) -#define TRANSVR_CLASS_OPTICAL_40G_SR4 (27042) -#define TRANSVR_CLASS_OPTICAL_40G_LR4 (27043) -#define TRANSVR_CLASS_OPTICAL_40G_ER4 (27044) -/* Transceiver class for Optical 100G */ -#define TRANSVR_CLASS_OPTICAL_100G (27100) -#define TRANSVR_CLASS_OPTICAL_100G_AOC (27101) -#define TRANSVR_CLASS_OPTICAL_100G_SR4 (27102) -#define TRANSVR_CLASS_OPTICAL_100G_LR4 (27103) -#define TRANSVR_CLASS_OPTICAL_100G_ER4 (27104) -#define TRANSVR_CLASS_OPTICAL_100G_PSM4 (27105) -/* Transceiver class for Copper */ -#define TRANSVR_CLASS_COPPER (28000) -#define TRANSVR_CLASS_COPPER_L1_1G (28001) -#define TRANSVR_CLASS_COPPER_L1_10G (28011) -#define TRANSVR_CLASS_COPPER_L4_10G (28012) -#define TRANSVR_CLASS_COPPER_L1_25G (28021) -#define TRANSVR_CLASS_COPPER_L4_40G (28041) -#define TRANSVR_CLASS_COPPER_L4_100G (28101) -/* Transceiver class for Base-T */ -#define TRANSVR_CLASS_BASE_T_1000 (29001) -#define TRANSVR_CLASS_BASE_T_1000_up (29002) -/* For uevent message */ -#define TRANSVR_UEVENT_KEY_IF "IF_TYPE" -#define TRANSVR_UEVENT_KEY_SP "IF_SPEED" -#define TRANSVR_UEVENT_KEY_LANE "IF_LANE" -#define TRANSVR_UEVENT_UNKNOW "UNKNOW" -#define TRANSVR_IF_KR "KR" -#define TRANSVR_IF_KR4 "KR4" -#define TRANSVR_IF_SR "SR" -#define TRANSVR_IF_SR4 "SR4" -#define TRANSVR_IF_SFI "SFI" -#define TRANSVR_IF_IF_GMII "GMII" -#define TRANSVR_IF_IF_XGMII "XGMII" -#define TRANSVR_IF_SP_100 "100" -#define TRANSVR_IF_SP_1G "1000" -#define TRANSVR_IF_SP_10G "10000" -#define TRANSVR_IF_SP_25G "25000" -#define TRANSVR_IF_SP_40G "40000" -#define TRANSVR_IF_SP_100G "100000" - -/* Transceiver mode define */ -#define TRANSVR_MODE_DIRECT (21000) -#define TRANSVR_MODE_POLLING (21001) - -/* Transceiver state define - * [Note] - * 1. State is used to represent the state of "Transceiver" and "Object". - * 2. State for different target has different means. The description as following: - */ -#define STATE_TRANSVR_CONNECTED (0) /* [Transvr]:Be plugged in. [Obj]:Link up, and work normally. */ -#define STATE_TRANSVR_NEW (-100) /* [Transvr]:(Not used) [Obj]:Create */ -#define STATE_TRANSVR_INIT (-101) /* [Transvr]:Be plugged in. [Obj]:Link up, and in initial process. */ -#define STATE_TRANSVR_ISOLATED (-102) /* [Transvr]:Be plugged in. [Obj]:Isolate, and not provide service. */ -#define STATE_TRANSVR_SWAPPED (-200) /* [Transvr]:Be plugged in. [Obj]:(Not used) */ -#define STATE_TRANSVR_DISCONNECTED (-300) /* [Transvr]:Un-plugged. [Obj]:Link down, and not provide service. */ -#define STATE_TRANSVR_UNEXCEPTED (-901) /* [Transvr]:Any [Obj]:Any, and not in expect case. */ - -/* Task state define */ -#define STATE_T_TASK_WAIT (110) -#define STATE_T_TASK_DONE (0) -#define STATE_T_TASK_INIT (-110) -#define STATE_T_TASK_FAIL (-410) - - -/* Event for task handling */ -#define EVENT_TRANSVR_TASK_WAIT (2101) -#define EVENT_TRANSVR_TASK_DONE (0) -#define EVENT_TRANSVR_TASK_FAIL (-2101) -/* Event for initial handling */ -#define EVENT_TRANSVR_INIT_UP (2201) -#define EVENT_TRANSVR_INIT_DOWN (1) -#define EVENT_TRANSVR_INIT_REINIT (-2201) -#define EVENT_TRANSVR_INIT_FAIL (-2202) -/* Event for others */ -#define EVENT_TRANSVR_RELOAD_FAIL (-2301) -#define EVENT_TRANSVR_EXCEP_INIT (-2401) -#define EVENT_TRANSVR_EXCEP_UP (-2402) -#define EVENT_TRANSVR_EXCEP_DOWN (-2403) -#define EVENT_TRANSVR_EXCEP_SWAP (-2404) -#define EVENT_TRANSVR_EXCEP_EXCEP (-2405) -#define EVENT_TRANSVR_EXCEP_ISOLATED (-2406) -#define EVENT_TRANSVR_I2C_CRASH (-2501) - -/* Transceiver error code define */ -#define ERR_TRANSVR_UNINIT (-201) -#define ERR_TRANSVR_UNPLUGGED (-202) -#define ERR_TRANSVR_ABNORMAL (-203) -#define ERR_TRANSVR_NOSTATE (-204) -#define ERR_TRANSVR_NOTSUPPORT (-205) -#define ERR_TRANSVR_BADINPUT (-206) -#define ERR_TRANSVR_UPDATE_FAIL (-207) -#define ERR_TRANSVR_RELOAD_FAIL (-208) -#define ERR_TRANSVR_INIT_FAIL (-209) -#define ERR_TRANSVR_UNDEFINED (-210) -#define ERR_TRANSVR_TASK_FAIL (-211) -#define ERR_TRANSVR_TASK_BUSY (-212) -#define ERR_TRANSVR_UEVENT_FAIL (-213) -#define ERR_TRANSVR_FUNC_DISABLE (-214) -#define ERR_TRANSVR_I2C_CRASH (-297) -#define ERR_TRNASVR_BE_ISOLATED (-298) -#define ERR_TRANSVR_UNEXCPT (-299) - -/* For debug */ -#define DEBUG_TRANSVR_INT_VAL (-99) -#define DEBUG_TRANSVR_HEX_VAL (0xfe) -#define DEBUG_TRANSVR_STR_VAL "ERROR" - -/* For system internal */ -#define VAL_TRANSVR_COMID_ARREESS (0x50) -#define VAL_TRANSVR_COMID_OFFSET (0x00) -#define VAL_TRANSVR_EXTPHY_ADDR_56 (0x56) -#define VAL_TRANSVR_8472_READY_ADDR (0x51) -#define VAL_TRANSVR_8472_READY_PAGE (-1) -#define VAL_TRANSVR_8472_READY_OFFSET (110) -#define VAL_TRANSVR_8472_READY_BIT (0) -#define VAL_TRANSVR_8472_READY_VALUE (0) -#define VAL_TRANSVR_8472_READY_ABNORMAL (0xff) -#define VAL_TRANSVR_8436_READY_ADDR (0x50) -#define VAL_TRANSVR_8436_READY_PAGE (-1) -#define VAL_TRANSVR_8436_READY_OFFSET (2) -#define VAL_TRANSVR_8436_READY_BIT (0) -#define VAL_TRANSVR_8436_READY_VALUE (0) -#define VAL_TRANSVR_8436_READY_ABNORMAL (0xff) -#define VAL_TRANSVR_8436_PWD_ADDR (0x50) -#define VAL_TRANSVR_8436_PWD_PAGE (-1) -#define VAL_TRANSVR_8436_PWD_OFFSET (123) -#define VAL_TRANSVR_PAGE_FREE (-99) -#define VAL_TRANSVR_PAGE_SELECT_OFFSET (127) -#define VAL_TRANSVR_PAGE_SELECT_DELAY (5) -#define VAL_TRANSVR_TASK_RETRY_FOREVER (-999) -#define VAL_TRANSVR_FUNCTION_DISABLE (-1) -#define STR_TRANSVR_SFP "SFP" -#define STR_TRANSVR_QSFP "QSFP" -#define STR_TRANSVR_QSFP_PLUS "QSFP+" -#define STR_TRANSVR_QSFP28 "QSFP28" - -/* For transvr buf len */ -#define LEN_TRANSVR_S_STR (16) -#define LEN_TRANSVR_M_STR (32) -#define LEN_TRANSVR_L_STR (64) - -/* Optical wavelength */ -#define VAL_OPTICAL_WAVELENGTH_SR (850) -#define VAL_OPTICAL_WAVELENGTH_LR (1310) -#define VAL_OPTICAL_WAVELENGTH_ER (1550) - -/* chip type define */ -#define CHIP_TYPE_MAGNOLIA (31001) /* Magnolia, Hudson32i, Spruce */ -#define CHIP_TYPE_REDWOOD (31002) /* Redwood, Cypress, Sequoia */ -#define CHIP_TYPE_MAPLE (31003) /* Maple */ - -#define CHIP_TYPE_LAVENDER (31011) /* Lavender */ - -/* Info from transceiver EEPROM */ -struct eeprom_map_s { - int addr_br; int page_br; int offset_br; int length_br; - int addr_cdr; int page_cdr; int offset_cdr; int length_cdr; - int addr_comp_rev; int page_comp_rev; int offset_comp_rev; int length_comp_rev; - int addr_connector; int page_connector; int offset_connector; int length_connector; - int addr_diag_type; int page_diag_type; int offset_diag_type; int length_diag_type; - int addr_extbr; int page_extbr; int offset_extbr; int length_extbr; - int addr_ext_id; int page_ext_id; int offset_ext_id; int length_ext_id; - int addr_id; int page_id; int offset_id; int length_id; - int addr_len_sm; int page_len_sm; int offset_len_sm; int length_len_sm; - int addr_len_smf; int page_len_smf; int offset_len_smf; int length_len_smf; - int addr_len_om1; int page_len_om1; int offset_len_om1; int length_len_om1; - int addr_len_om2; int page_len_om2; int offset_len_om2; int length_len_om2; - int addr_len_om3; int page_len_om3; int offset_len_om3; int length_len_om3; - int addr_len_om4; int page_len_om4; int offset_len_om4; int length_len_om4; - int addr_option; int page_option; int offset_option; int length_option; - int addr_rate_id; int page_rate_id; int offset_rate_id; int length_rate_id; - int addr_rx_am; int page_rx_am; int offset_rx_am; int length_rx_am; - int addr_rx_em; int page_rx_em; int offset_rx_em; int length_rx_em; - int addr_rx_los; int page_rx_los; int offset_rx_los; int length_rx_los; - int addr_rx_power; int page_rx_power; int offset_rx_power; int length_rx_power; - int addr_soft_rs0; int page_soft_rs0; int offset_soft_rs0; int length_soft_rs0; - int addr_soft_rs1; int page_soft_rs1; int offset_soft_rs1; int length_soft_rs1; - int addr_temp; int page_temp; int offset_temp; int length_temp; - int addr_trancomp; int page_trancomp; int offset_trancomp; int length_trancomp; - int addr_trancomp_ext; int page_trancomp_ext; int offset_trancomp_ext; int length_trancomp_ext; - int addr_tx_bias; int page_tx_bias; int offset_tx_bias; int length_tx_bias; - int addr_tx_disable; int page_tx_disable; int offset_tx_disable; int length_tx_disable; - int addr_tx_eq; int page_tx_eq; int offset_tx_eq; int length_tx_eq; - int addr_tx_fault; int page_tx_fault; int offset_tx_fault; int length_tx_fault; - int addr_tx_power; int page_tx_power; int offset_tx_power; int length_tx_power; - int addr_vendor_name; int page_vendor_name; int offset_vendor_name; int length_vendor_name; - int addr_vendor_pn; int page_vendor_pn; int offset_vendor_pn; int length_vendor_pn; - int addr_vendor_rev; int page_vendor_rev; int offset_vendor_rev; int length_vendor_rev; - int addr_vendor_sn; int page_vendor_sn; int offset_vendor_sn; int length_vendor_sn; - int addr_voltage; int page_voltage; int offset_voltage; int length_voltage; - int addr_wavelength; int page_wavelength; int offset_wavelength; int length_wavelength; -}; - - -struct transvr_worker_s; - -/* Class of transceiver object */ -struct transvr_obj_s { - - /* ========== Object private property ========== - * [Prop]: id - * [Desc]: Type of serial transceiver. - * [Note]: SFP:03h / QSFP:0Ch / QSPF+:0Dh /QSFP28:11h - */ - uint8_t id; - - /* [Prop]: connector - * [Desc]: Connector type. - * [Note]: SFP : A0h / 2 - * QSFP: 00h / 130 - */ - uint8_t connector; - - /* [Prop]: transvr_comp - * [Desc]: Transceiver compliance code. - * [Note]: SFP: SFF-8472 - * - Normal : A0h / offset 3-10 - * - Extended: A0h / offset 36 - * QSFP: SFF-8436 & SFF-8636 - * - Normal : 00h / offset 131-138 - * - Extended: 00h / offset 192 - */ - uint8_t transvr_comp[8]; - uint8_t transvr_comp_ext; - - /* [Prop]: vendor_name - * [Desc]: SFP vendor name (ASCII 16 byte char). - * [Note]: ex:FINISAR CORP. - */ - char *vendor_name; - - /* [Prop]: vendor_pn - * [Desc]: Part number provided by SFP vendor (ASCII 16 byte char). - * [Note]: - */ - char *vendor_pn; - - /* [Prop]: vendor_rev - * [Desc]: Revision level for part number provided by vendor (ASCII 4 byte char). - * [Note]: - */ - char *vendor_rev; - - /* [Prop]: vendor_sn - * [Desc]: Serial number provided by vendor (ASCII 16 byte char). - * [Note]: - */ - char *vendor_sn; - - /* [Prop]: Extended identifier - * [Desc]: SFP: - * => None - * - * QSFP: - * => This byte contained two information: - * (1) Power consumption class - * (2) CDR function present - * [Note]: Bit description as below: - * [SFP] - * None - * - * [QSFP] - * (1) Power consumption class: - * Class 1: 1.5W (Bit6-7 = 00:) - * Class 2: 2.0W (Bit6-7 = 01:) - * Class 3: 2.5W (Bit6-7 = 10:) - * Class 4: 3.5W (Bit6-7 = 11:) - * Class 5: 4.0W (Bit0-1 = 01:) - * Class 6: 4.5W (Bit0-1 = 10:) - * Class 7: 5.0W (Bit0-1 = 11:) - * (2) CDR function present: - * Bit2: 0 = No CDR in RX - * 1 = CDR present in RX - * Bit3: 0 = No CDR in TX - * 1 = CDR present in TX - */ - uint8_t ext_id; - - /* [Prop]: br - * [Desc]: Nominal bit rate, units of 100 MBits/sec. - * [Note]: SFP:03h / QSFP:0Ch / QSPF+:0Dh - * has val: 0x67 - * no val : - */ - uint8_t br; - - /* [Prop]: extbr - * [Desc]: Extended br (00h/222) - * [Desc]: Nominal bit rate per channel, units of 250 Mbps. - * Complements. Byte 140. See Table 32A. - */ - uint8_t extbr; - - /* [Prop]: len_sm - * [Desc]: Length (single mode)-(100's)m - * [Note]: This value specifies the link length that is supported by the transceiver - * while operating in compliance with the applicable standards using single mode - * fiber. The value is in units of 100 meters. A value of 255 means that the - * transceiver supports a link length greater than 25.4 km. A value of zero means - * that the transceiver does not support single mode fiber or that the length - * information must be determined from the transceiver technology. - */ - int len_sm; - - /* [Prop]: len_smf - * [Desc]: Length (single mode)-km - * [Note]: Addition to EEPROM data from original GBIC definition. This value specifies - * the link length that is supported by the transceiver while operating in - * compliance with the applicable standards using single mode fiber. The value - * is in units of kilometers. A value of 255 means that the transceiver supports - * a link length greater than 254 km. A value of zero means that the transceiver - * does not support single mode fiber or that the length information must be - * determined from the transceiver technology. - */ - int len_smf; - - /* [Prop]: len_om1 - * [Desc]: Link length supported for 62.5 um OM1 fiber, units of 10 m - * [Note]: The value is in units of 10 meters. A value of 255 means that the - * transceiver supports a link length greater than 2.54 km. A value of - * zero means that the transceiver does not support 50 micron multi-mode - * fiber or that the length information must be determined from the transceiver - * technology. - */ - int len_om1; - - /* [Prop]: len_om2 - * [Desc]: Link length supported for 50 um OM2 fiber, units of 10 m - * [Note]: The value is in units of 10 meters. A value of 255 means that the - * transceiver supports a link length greater than 2.54 km. A value of - * zero means that the transceiver does not support 50 micron multi-mode - * fiber or that the length information must be determined from the transceiver - * technology. - */ - int len_om2; - - /* [Prop]: len_om3 - * [Desc]: Length (50um, OM3) - * [Note]: This value specifies link length that is supported by the transceiver while - * operating in compliance with applicable standards using 50 micron multimode - * OM3 [2000 MHz*km] fiber. The value is in units of 10 meters. A value of 255 - * means that the transceiver supports a link length greater than 2.54 km. A value - * of zero means that the transceiver does not support 50 micron multimode fiber - * or that the length information must be determined from the transceiver technology. - */ - int len_om3; - - /* [Prop]: len_om4 - * [Desc]: Length (50um, OM4) and Length (Active Cable or Copper) - * [Note]: For optical links, this value specifies link length that is supported by the - * transceiver while operating in compliance with applicable standards using 50 micron - * multimode OM4 [4700 MHz*km] fiber. The value is in units of 10 meters. A value of - * 255 means that the transceiver supports a link length greater than 2.54 km. A value - * of zero means that the transceiver does not support 50 micron multimode fiber or that - * the length information must be determined from the transceiver codes specified in Table 5-3. - * - * For copper links, this value specifies minimum link length supported by the transceiver - * while operating in compliance with applicable standards using copper cable. For active - * cable, this value represents actual length. The value is in units of 1 meter. A value of 255 - * means the transceiver supports a link length greater than 254 meters. A value of zero means - * the transceiver does not support copper or active cables or the length information must be - * determined from transceiver technology. Further information about cable design, equalization, - * and connectors is usually required to guarantee meeting a particular length requirement. - */ - int len_om4; - - /* [Prop]: comp_rev - * [Desc]: SFF spec revision compliance - * [Note]: Indicates which revision of SFF SFF-8472 (SFP) / SFF-8636 (QSFP) the transceiver - * complies with. (unsigned integer) - */ - uint8_t comp_rev; - - /* [Prop]: CDR - * [Desc]: For transceivers with CDR capability, setting the CDR to ON engages the internal - * retiming function. Setting the CDR to OFF enables an internal bypassing mode ,which - * directs traffic around the internal CDR. (Reference: SFF-8636) - * [Note]: value=0xff: ON. - * value=0x00: OFF. - */ - uint8_t cdr; - - /* [Prop]: rate_id - * [Desc]: Soft Rate Select 0(RX). - * [Note]: 1. Addr: A0h / Offset: 13 - * 2. Value description: - * 00h Unspecified - * 01h SFF-8079 (4/2/1G Rate_Select & AS0/AS1) - * 02h SFF-8431 (8/4/2G Rx Rate_Select only) - * 03h Unspecified * - * 04h SFF-8431 (8/4/2G Tx Rate_Select only) - * 05h Unspecified * - * 06h SFF-8431 (8/4/2G Independent Rx & Tx Rate_select) - * 07h Unspecified * - * 08h FC-PI-5 (16/8/4G Rx Rate_select only) High=16G only, Low=8G/4G - * 09h Unspecified * - * 0Ah FC-PI-5 (16/8/4G Independent Rx, Tx Rate_select) High=16G only, - * Low=8G/4G - * 0Bh Unspecified * - * 0Ch FC-PI-6 (32/16/8G Independent Rx, Tx Rate_Select) - * High=32G only, Low = 16G/8G - * 0Dh Unspecified * - * 0Eh 10/8G Rx and Tx Rate_Select controlling the operation or locking - * modes of the internal signal conditioner, retimer or CDR, according - * to the logic table defined in Table 10-2, High Bit Rate - * (10G) =9.95-11.3 Gb/s; Low Bit Rate (8G) = 8.5 Gb/s. In this mode, - * the default value of bit 110.3 (Soft Rate Select RS(0), Table 9-11) - * and of bit 118.3 (Soft Rate Select RS(1), Table 10-1) is 1. - * 0Fh Unspecified * - * 10h-FFh Unallocated - */ - int rate_id; - - /* [Prop]: soft_rs0 - * [Desc]: Soft Rate Select 0(RX). - * [Note]: 1. Writing '1' selects full bandwidth operation. - * 2. This bit is "OR'd with the hard Rate_Select, AS(0) or RS(0) pin value. - * 3. Default at power up is logic zero/low - * 4. Addr: A2h / Offset: 110 / Bit: 3 - */ - uint8_t soft_rs0; - - /* [Prop]: soft_rs1 - * [Desc]: Soft Rate Select 1(TX). - * [Note]: 1. Writing '1' selects full bandwidth TX operation. - * 2. This bit is "OR'd with the hard Rate_Select, AS(1) or RS(1) pin value. - * 3. Default at power up is logic zero/low - * 4. Addr: A2h / Offset: 118 / Bit: 3 - */ - uint8_t soft_rs1; - - /* [Prop]: diag_type - * [Desc]: DIAGNOSTIC MONITORING TYPE (A0h/92) - * [Note]: Description in SFF-8472 as below: - * Bit7: Reserved for legacy diagnostic implementations. Must be '0' for compliance - * with this document. - * Bit6: Digital diagnostic monitoring implemented (described in this document). - * Must be '1' for compliance with this document. - * Bit5 Internally calibrated - * Bit4 Externally calibrated - * Bit3 Received power measurement type.0 = OMA, 1 = average power - * Bit2 Address change required see section above, "addressing modes" - * Bit1-0 Unallocated - */ - uint8_t diag_type; - - /* [Prop]: curr_temp - * [Desc]: Transceiver Current Temperature (A2h/96-97) - * [Note]: 1. Dependent on diag_type. - * 2. 96: High byte - * 3. 97: Low byte - * 4. This feature only for SFP - */ - uint8_t curr_temp[2]; - - /* [Prop]: curr_vol - * [Desc]: Transceiver Current Voltage (SFP:A2h/108-109; QSFP:00h/22-23) - * [Note]: 1. Dependent on diag_type. - * 2. 98: High byte - * 3. 99: Low byte - * 4. This feature only for SFP - * 5. Internally measured transceiver supply voltage. Represented - * as a 16 bit unsigned integer with the voltage defined as the - * full 16 bit value (0-65535) with LSB equal to 100 uVolt, - * yielding a total range of 0 to +6.55 Volts - */ - uint8_t curr_voltage[2]; - - /* [Prop]: curr_tx_bias - * [Desc]: Transceiver TX Bias Current (SFP:A2h/100-101; QSFP:00h/26-27) - * [Note]: 1. Dependent on diag_type. - * 2. 100: High byte - * 3. 101: Low byte - * 4. This feature only for SFP - * 5. Measured TX bias current in uA. Represented as a 16 bit unsigned - * integer with the current defined as the full 16 bit value (0-65535) - * with LSB equal to 2 uA, yielding a total range of 0 to 131 mA. - * Accuracy is vendor specific but must be better than 10% of the - * manufacturer's nominal value over specified operating temperature - * and voltage. - */ - uint8_t curr_tx_bias[8]; - - /* [Prop]: curr_tx_power - * [Desc]: Transceiver TX Output Power (A2h/102-103) - * [Note]: 1. Dependent on diag_type. - * 2. 102: High byte - * 3. 103: Low byte - * 4. This feature only for SFP - * 5. Measured TX output power in mW. Represented as a 16 bit unsigned - * integer with the power defined as the full 16 bit value (0-65535) - * with LSB equal to 0.1 uW, yielding a total range of 0 to 6.5535 mW - * (~ -40 to +8.2 dBm). Data is assumed to be based on measurement of - * laser monitor photodiode current. It is factory calibrated to absolute - * units using the most representative fiber output type. Accuracy is - * vendor specific but must be better than 3dB over specified temperature - * and voltage. Data is not valid when the transmitter is disabled. - */ - uint8_t curr_tx_power[8]; - - /* [Prop]: curr_tx_power - * [Desc]: Transceiver TX Output Power (A2h/102-103) - * [Note]: 1. Dependent on diag_type. - * 2. 102: High byte - * 3. 103: Low byte - * 4. This feature only for SFP - * 5. Measured RX received optical power in mW. Value can represent either - * average received power or OMA depending upon how bit 3 of byte 92 (A0h) - * is set. Represented as a 16 bit unsigned integer with the power defined - * as the full 16 bit value (0-65535) with LSB equal to 0.1 uW, yielding a - * total range of 0 to 6.5535 mW (~ -40 to +8.2 dBm). Absolute accuracy is - * dependent upon the exact optical wavelength. For the vendor specified - * wavelength, accuracy shall be better than 3dB over specified temperature - * and voltage. - */ - uint8_t curr_rx_power[8]; - - /* [Prop]: wavelength - * [Desc]: Wavelength or Copper Cable Attenuation - * [Note]: (Following is info from SFF-8636) - * For optical free side devices, this parameter identifies the nominal - * transmitter output wavelength at room temperature. This parameter is a - * 16-bit hex value with Byte 186 as high order byte and Byte 187 as low - * order byte. The laser wavelength is equal to the 16-bit integer value - * divided by 20 in nm (units of 0.05 nm). This resolution should be adequate - * to cover all relevant wavelengths yet provide enough resolution for all - * expected DWDM applications. For accurate representation of controlled - * wavelength applications, this value should represent the center of the - * guaranteed wavelength range. If the free side device is identified as - * copper cable these registers will be used to define the cable attenuation. - * An indication of 0 dB attenuation refers to the case where the attenuation - * is not known or is unavailable. - * Byte 186 (00-FFh) is the copper cable attenuation at 2.5 GHz in units of 1 dB. - * Byte 187 (00-FFh) is the copper cable attenuation at 5.0 GHz in units of 1 dB. - */ - uint8_t wavelength[2]; - - /* [Prop]: Amplitude control - * [Desc]: Amplitude control - * [Note]: QSFP28 => SFF-8636 03H Byte-238/239 - */ - uint8_t rx_am[2]; - - /* [Prop]: Emphasis control - * [Desc]: Emphasis control - * [Note]: SFP+/28 => SFF-8472 A2H Byte-115 - * QSFP28 => SFF-8636 03H Byte-236/237 - */ - uint8_t rx_em[2]; - - /* [Prop]: Soft Rx LOS - * [Desc]: Soft Rx LOS which provide by transceiver - * [Note]: (Following is info from SFF-8636) - * Byte 3: - * - Bit 0: L-Rx1 LOS - * - Bit 1: L-Rx2 LOS - * - Bit 2: L-Rx3 LOS - * - Bit 3: L-Rx4 LOS - */ - uint8_t rx_los; - - /* [Prop]: Soft Tx Disable - * [Desc]: Soft Tx Disable which provide by transceiver - * [Note]: (Following is info from SFF-8636) - * Byte 86: - * - Bit 0: Tx1 Disable - * - Bit 1: Tx2 Disable - * - Bit 2: Tx3 Disable - * - Bit 3: Tx4 Disable - */ - uint8_t tx_disable; - - /* [Prop]: Soft Tx Fault - * [Desc]: Soft Tx Fault which provide by transceiver - * [Note]: (Following is info from SFF-8636) - * Byte 86: - * - Bit 0: Tx1 Fault - * - Bit 1: Tx2 Fault - * - Bit 2: Tx3 Fault - * - Bit 3: Tx4 Fault - */ - uint8_t tx_fault; - - /* [Prop]: Transceiver EQUALIZATION - * [Desc]: Transceiver EQUALIZATION - * [Note]: SFP+/28 => SFF-8472 A2H Byte-114 - * QSFP28 => SFF-8636 03H Byte-234/235 - */ - uint8_t tx_eq[2]; - - /* [Prop]: OPTION VALUES - * [Desc]: The bits in the option field shall specify the options implemented in the transceiver. - * [Note]: SFP+/28 => SFF-8472 A0H Byte-64/65 - * QSFP+/28 => SFF-8636 00H Byte-193/195 - */ - uint8_t option[3]; - - /* [Prop]: External PHY offset - * [Desc]: It needs to be setup first if you want to access transceiver external phy. - * [Note]: This feature dependent on transceiver. - * Currently, only 1G-RJ45 transceiver supported it. - */ - uint8_t extphy_offset; - - /* ========== Object private property ========== - */ - struct device *transvr_dev_p; - struct eeprom_map_s *eeprom_map_p; - struct i2c_client *i2c_client_p; - struct ioexp_obj_s *ioexp_obj_p; - struct transvr_worker_s *worker_p; - struct mutex lock; - char swp_name[32]; - int auto_config; - int auto_tx_disable; - int chan_id; - int chipset_type; - int curr_page; - int info; - int ioexp_virt_offset; - int lane_id[8]; - int layout; - int mode; - int retry; - int state; - int temp; - int type; - - /* ========== Object public functions ========== - */ - int (*get_id)(struct transvr_obj_s *self); - int (*get_ext_id)(struct transvr_obj_s *self); - int (*get_connector)(struct transvr_obj_s *self); - int (*get_vendor_name)(struct transvr_obj_s *self, char *buf_p); - int (*get_vendor_pn)(struct transvr_obj_s *self, char *buf_p); - int (*get_vendor_rev)(struct transvr_obj_s *self, char *buf_p); - int (*get_vendor_sn)(struct transvr_obj_s *self, char *buf_p); - int (*get_power_cls)(struct transvr_obj_s *self); - int (*get_br)(struct transvr_obj_s *self); - int (*get_len_sm)(struct transvr_obj_s *self); - int (*get_len_smf)(struct transvr_obj_s *self); - int (*get_len_om1)(struct transvr_obj_s *self); - int (*get_len_om2)(struct transvr_obj_s *self); - int (*get_len_om3)(struct transvr_obj_s *self); - int (*get_len_om4)(struct transvr_obj_s *self); - int (*get_comp_rev)(struct transvr_obj_s *self); - int (*get_comp_eth_1)(struct transvr_obj_s *self); - int (*get_comp_eth_10)(struct transvr_obj_s *self); - int (*get_comp_eth_10_40)(struct transvr_obj_s *self); - int (*get_comp_extend)(struct transvr_obj_s *self); - int (*get_cdr)(struct transvr_obj_s *self); - int (*get_rate_id)(struct transvr_obj_s *self); - int (*get_soft_rs0)(struct transvr_obj_s *self); - int (*get_soft_rs1)(struct transvr_obj_s *self); - int (*get_info)(struct transvr_obj_s *self); - int (*get_if_type)(struct transvr_obj_s *self, char *buf_p); - int (*get_if_speed)(struct transvr_obj_s *self, char *buf_p); - int (*get_if_lane)(struct transvr_obj_s *self, char *buf_p); - int (*get_curr_temp)(struct transvr_obj_s *self, char *buf_p); - int (*get_curr_vol)(struct transvr_obj_s *self, char *buf_p); - int (*get_soft_rx_los)(struct transvr_obj_s *self, char *buf_p); - int (*get_soft_tx_disable)(struct transvr_obj_s *self, char *buf_p); - int (*get_soft_tx_fault)(struct transvr_obj_s *self, char *buf_p); - int (*get_auto_tx_disable)(struct transvr_obj_s *self, char *buf_p); - int (*get_tx_bias)(struct transvr_obj_s *self, char *buf_p); - int (*get_tx_power)(struct transvr_obj_s *self, char *buf_p); - int (*get_rx_power)(struct transvr_obj_s *self, char *buf_p); - int (*get_tx_eq)(struct transvr_obj_s *self, char *buf_p); - int (*get_rx_am)(struct transvr_obj_s *self, char *buf_p); - int (*get_rx_em)(struct transvr_obj_s *self, char *buf_p); - int (*get_wavelength)(struct transvr_obj_s *self, char *buf_p); - int (*get_extphy_offset)(struct transvr_obj_s *self, char *buf_p); - int (*get_extphy_reg)(struct transvr_obj_s *self, char *buf_p); - int (*set_cdr)(struct transvr_obj_s *self, int input_val); - int (*set_soft_rs0)(struct transvr_obj_s *self, int input_val); - int (*set_soft_rs1)(struct transvr_obj_s *self, int input_val); - int (*set_soft_tx_disable)(struct transvr_obj_s *self, int input_val); - int (*set_auto_tx_disable)(struct transvr_obj_s *self, int input_val); - int (*set_tx_eq)(struct transvr_obj_s *self, int input_val); - int (*set_rx_am)(struct transvr_obj_s *self, int input_val); - int (*set_rx_em)(struct transvr_obj_s *self, int input_val); - int (*set_extphy_offset)(struct transvr_obj_s *self, int input_val); - int (*set_extphy_reg)(struct transvr_obj_s *self, int input_val); - - /* ========== Object private functions ========== - */ - int (*init)(struct transvr_obj_s *self); - int (*clean)(struct transvr_obj_s *self); - int (*check)(struct transvr_obj_s *self); - int (*update_all)(struct transvr_obj_s *self, int show_err); - int (*fsm_4_direct)(struct transvr_obj_s* self, char *caller_name); - int (*fsm_4_polling)(struct transvr_obj_s* self, char *caller_name); - int (*send_uevent)(struct transvr_obj_s* self, enum kobject_action u_action); - int (*dump_all)(struct transvr_obj_s* self); -}; - - -/* For AVL Mapping */ -struct transvr_avl_s { - char vendor_name[32]; - char vendor_pn[32]; - int (*init)(struct transvr_obj_s *self); -}; - - -/* Worker for long term task of transceiver */ -struct transvr_worker_s { - /* Task Parameter */ - struct transvr_obj_s *transvr_p; - struct transvr_worker_s *next_p; - struct transvr_worker_s *pre_p; - unsigned long trigger_time; - char func_name[64]; - int retry; - int state; - - /* Task private data */ - void *p_data; - - /* Call back function */ - int (*main_task)(struct transvr_worker_s *task); - int (*post_task)(struct transvr_worker_s *task); -}; - - -struct transvr_obj_s * -create_transvr_obj(char *swp_name, - int chan_id, - struct ioexp_obj_s *ioexp_obj_p, - int ioexp_virt_offset, - int transvr_type, - int chipset_type, - int run_mode); - -void lock_transvr_obj(struct transvr_obj_s *self); -void unlock_transvr_obj(struct transvr_obj_s *self); -int isolate_transvr_obj(struct transvr_obj_s *self); - -int resync_channel_tier_2(struct transvr_obj_s *self); - -void alarm_msg_2_user(struct transvr_obj_s *self, char *emsg); - -#endif /* TRANSCEIVER_H */ - - - - - - - diff --git a/packages/platforms/inventec/x86-64/d10056/onlp/Makefile b/packages/platforms/inventec/x86-64/d10056/onlp/Makefile deleted file mode 100644 index 003238cf6..000000000 --- a/packages/platforms/inventec/x86-64/d10056/onlp/Makefile +++ /dev/null @@ -1 +0,0 @@ -include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/inventec/x86-64/d10056/onlp/PKG.yml b/packages/platforms/inventec/x86-64/d10056/onlp/PKG.yml deleted file mode 100644 index 1e7267c2b..000000000 --- a/packages/platforms/inventec/x86-64/d10056/onlp/PKG.yml +++ /dev/null @@ -1 +0,0 @@ -!include $ONL_TEMPLATES/onlp-platform-any.yml PLATFORM=x86-64-inventec-d10056 ARCH=amd64 TOOLCHAIN=x86_64-linux-gnu diff --git a/packages/platforms/inventec/x86-64/d10056/onlp/builds/Makefile b/packages/platforms/inventec/x86-64/d10056/onlp/builds/Makefile deleted file mode 100644 index e7437cb23..000000000 --- a/packages/platforms/inventec/x86-64/d10056/onlp/builds/Makefile +++ /dev/null @@ -1,2 +0,0 @@ -FILTER=src -include $(ONL)/make/subdirs.mk diff --git a/packages/platforms/inventec/x86-64/d10056/onlp/builds/lib/Makefile b/packages/platforms/inventec/x86-64/d10056/onlp/builds/lib/Makefile deleted file mode 100644 index 0ad6d8bd7..000000000 --- a/packages/platforms/inventec/x86-64/d10056/onlp/builds/lib/Makefile +++ /dev/null @@ -1,2 +0,0 @@ -PLATFORM := x86-64-inventec-d10056 -include $(ONL)/packages/base/any/onlp/builds/platform/libonlp-platform.mk diff --git a/packages/platforms/inventec/x86-64/d10056/onlp/builds/onlpdump/Makefile b/packages/platforms/inventec/x86-64/d10056/onlp/builds/onlpdump/Makefile deleted file mode 100644 index 8516743ed..000000000 --- a/packages/platforms/inventec/x86-64/d10056/onlp/builds/onlpdump/Makefile +++ /dev/null @@ -1,2 +0,0 @@ -PLATFORM := x86-64-inventec-d10056 -include $(ONL)/packages/base/any/onlp/builds/platform/onlps.mk diff --git a/packages/platforms/inventec/x86-64/d10056/onlp/builds/x86_64_inventec_d10056/.gitignore b/packages/platforms/inventec/x86-64/d10056/onlp/builds/x86_64_inventec_d10056/.gitignore deleted file mode 100644 index 45511c061..000000000 --- a/packages/platforms/inventec/x86-64/d10056/onlp/builds/x86_64_inventec_d10056/.gitignore +++ /dev/null @@ -1 +0,0 @@ -x86_64_inventec_d10056.mk diff --git a/packages/platforms/inventec/x86-64/d10056/onlp/builds/x86_64_inventec_d10056/.module b/packages/platforms/inventec/x86-64/d10056/onlp/builds/x86_64_inventec_d10056/.module deleted file mode 100644 index c609bb71c..000000000 --- a/packages/platforms/inventec/x86-64/d10056/onlp/builds/x86_64_inventec_d10056/.module +++ /dev/null @@ -1 +0,0 @@ -name: x86_64_inventec_d10056 diff --git a/packages/platforms/inventec/x86-64/d10056/onlp/builds/x86_64_inventec_d10056/Makefile b/packages/platforms/inventec/x86-64/d10056/onlp/builds/x86_64_inventec_d10056/Makefile deleted file mode 100644 index b6f57194f..000000000 --- a/packages/platforms/inventec/x86-64/d10056/onlp/builds/x86_64_inventec_d10056/Makefile +++ /dev/null @@ -1,9 +0,0 @@ -############################################################################### -# -# -# -############################################################################### -include $(ONL)/make/config.mk -MODULE := x86_64_inventec_d10056 -AUTOMODULE := x86_64_inventec_d10056 -include $(BUILDER)/definemodule.mk diff --git a/packages/platforms/inventec/x86-64/d10056/onlp/builds/x86_64_inventec_d10056/module/auto/make.mk b/packages/platforms/inventec/x86-64/d10056/onlp/builds/x86_64_inventec_d10056/module/auto/make.mk deleted file mode 100644 index b7ba14ca4..000000000 --- a/packages/platforms/inventec/x86-64/d10056/onlp/builds/x86_64_inventec_d10056/module/auto/make.mk +++ /dev/null @@ -1,9 +0,0 @@ -############################################################################### -# -# x86_64_inventec_d10056 Autogeneration -# -############################################################################### -x86_64_inventec_d10056_AUTO_DEFS := module/auto/x86_64_inventec_d10056.yml -x86_64_inventec_d10056_AUTO_DIRS := module/inc/x86_64_inventec_d10056 module/src -include $(BUILDER)/auto.mk - diff --git a/packages/platforms/inventec/x86-64/d10056/onlp/builds/x86_64_inventec_d10056/module/auto/x86_64_inventec_d10056.yml b/packages/platforms/inventec/x86-64/d10056/onlp/builds/x86_64_inventec_d10056/module/auto/x86_64_inventec_d10056.yml deleted file mode 100644 index 0df09f66f..000000000 --- a/packages/platforms/inventec/x86-64/d10056/onlp/builds/x86_64_inventec_d10056/module/auto/x86_64_inventec_d10056.yml +++ /dev/null @@ -1,50 +0,0 @@ -############################################################################### -# -# x86_64_inventec_d10056 Autogeneration Definitions. -# -############################################################################### - -cdefs: &cdefs -- X86_64_INVENTEC_D10056_CONFIG_INCLUDE_LOGGING: - doc: "Include or exclude logging." - default: 1 -- X86_64_INVENTEC_D10056_CONFIG_LOG_OPTIONS_DEFAULT: - doc: "Default enabled log options." - default: AIM_LOG_OPTIONS_DEFAULT -- X86_64_INVENTEC_D10056_CONFIG_LOG_BITS_DEFAULT: - doc: "Default enabled log bits." - default: AIM_LOG_BITS_DEFAULT -- X86_64_INVENTEC_D10056_CONFIG_LOG_CUSTOM_BITS_DEFAULT: - doc: "Default enabled custom log bits." - default: 0 -- X86_64_INVENTEC_D10056_CONFIG_PORTING_STDLIB: - doc: "Default all porting macros to use the C standard libraries." - default: 1 -- X86_64_INVENTEC_D10056_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS: - doc: "Include standard library headers for stdlib porting macros." - default: X86_64_INVENTEC_D10056_CONFIG_PORTING_STDLIB -- X86_64_INVENTEC_D10056_CONFIG_INCLUDE_UCLI: - doc: "Include generic uCli support." - default: 0 -- X86_64_INVENTEC_D10056_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_D10056_CONFIG_HEADER: - defs: *cdefs - basename: x86_64_inventec_d10056_config - - portingmacro: - x86_64_inventec_d10056: - macros: - - malloc - - free - - memset - - memcpy - - - vsnprintf - - snprintf - - strlen diff --git a/packages/platforms/inventec/x86-64/d10056/onlp/builds/x86_64_inventec_d10056/module/inc/x86_64_inventec_d10056/x86_64_inventec_d10056.x b/packages/platforms/inventec/x86-64/d10056/onlp/builds/x86_64_inventec_d10056/module/inc/x86_64_inventec_d10056/x86_64_inventec_d10056.x deleted file mode 100644 index 8ba55c06e..000000000 --- a/packages/platforms/inventec/x86-64/d10056/onlp/builds/x86_64_inventec_d10056/module/inc/x86_64_inventec_d10056/x86_64_inventec_d10056.x +++ /dev/null @@ -1,14 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#include - -/* <--auto.start.xmacro(ALL).define> */ -/* */ - -/* <--auto.start.xenum(ALL).define> */ -/* */ - - diff --git a/packages/platforms/inventec/x86-64/d10056/onlp/builds/x86_64_inventec_d10056/module/inc/x86_64_inventec_d10056/x86_64_inventec_d10056_config.h b/packages/platforms/inventec/x86-64/d10056/onlp/builds/x86_64_inventec_d10056/module/inc/x86_64_inventec_d10056/x86_64_inventec_d10056_config.h deleted file mode 100644 index 9559f648c..000000000 --- a/packages/platforms/inventec/x86-64/d10056/onlp/builds/x86_64_inventec_d10056/module/inc/x86_64_inventec_d10056/x86_64_inventec_d10056_config.h +++ /dev/null @@ -1,137 +0,0 @@ -/**************************************************************************//** - * - * @file - * @brief x86_64_inventec_d10056 Configuration Header - * - * @addtogroup x86_64_inventec_d10056-config - * @{ - * - *****************************************************************************/ -#ifndef __X86_64_INVENTEC_D10056_CONFIG_H__ -#define __X86_64_INVENTEC_D10056_CONFIG_H__ - -#ifdef GLOBAL_INCLUDE_CUSTOM_CONFIG -#include -#endif -#ifdef x86_64_inventec_d10056_INCLUDE_CUSTOM_CONFIG -#include -#endif - -/* */ -#include -/** - * X86_64_INVENTEC_D10056_CONFIG_INCLUDE_LOGGING - * - * Include or exclude logging. */ - - -#ifndef X86_64_INVENTEC_D10056_CONFIG_INCLUDE_LOGGING -#define X86_64_INVENTEC_D10056_CONFIG_INCLUDE_LOGGING 1 -#endif - -/** - * X86_64_INVENTEC_D10056_CONFIG_LOG_OPTIONS_DEFAULT - * - * Default enabled log options. */ - - -#ifndef X86_64_INVENTEC_D10056_CONFIG_LOG_OPTIONS_DEFAULT -#define X86_64_INVENTEC_D10056_CONFIG_LOG_OPTIONS_DEFAULT AIM_LOG_OPTIONS_DEFAULT -#endif - -/** - * X86_64_INVENTEC_D10056_CONFIG_LOG_BITS_DEFAULT - * - * Default enabled log bits. */ - - -#ifndef X86_64_INVENTEC_D10056_CONFIG_LOG_BITS_DEFAULT -#define X86_64_INVENTEC_D10056_CONFIG_LOG_BITS_DEFAULT AIM_LOG_BITS_DEFAULT -#endif - -/** - * X86_64_INVENTEC_D10056_CONFIG_LOG_CUSTOM_BITS_DEFAULT - * - * Default enabled custom log bits. */ - - -#ifndef X86_64_INVENTEC_D10056_CONFIG_LOG_CUSTOM_BITS_DEFAULT -#define X86_64_INVENTEC_D10056_CONFIG_LOG_CUSTOM_BITS_DEFAULT 0 -#endif - -/** - * X86_64_INVENTEC_D10056_CONFIG_PORTING_STDLIB - * - * Default all porting macros to use the C standard libraries. */ - - -#ifndef X86_64_INVENTEC_D10056_CONFIG_PORTING_STDLIB -#define X86_64_INVENTEC_D10056_CONFIG_PORTING_STDLIB 1 -#endif - -/** - * X86_64_INVENTEC_D10056_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS - * - * Include standard library headers for stdlib porting macros. */ - - -#ifndef X86_64_INVENTEC_D10056_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS -#define X86_64_INVENTEC_D10056_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS X86_64_INVENTEC_D10056_CONFIG_PORTING_STDLIB -#endif - -/** - * X86_64_INVENTEC_D10056_CONFIG_INCLUDE_UCLI - * - * Include generic uCli support. */ - - -#ifndef X86_64_INVENTEC_D10056_CONFIG_INCLUDE_UCLI -#define X86_64_INVENTEC_D10056_CONFIG_INCLUDE_UCLI 0 -#endif - -/** - * X86_64_INVENTEC_D10056_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION - * - * Assume chassis fan direction is the same as the PSU fan direction. */ - - -#ifndef X86_64_INVENTEC_D10056_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION -#define X86_64_INVENTEC_D10056_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION 0 -#endif - - - -/** - * All compile time options can be queried or displayed - */ - -/** Configuration settings structure. */ -typedef struct x86_64_inventec_d10056_config_settings_s { - /** name */ - const char* name; - /** value */ - const char* value; -} x86_64_inventec_d10056_config_settings_t; - -/** Configuration settings table. */ -/** x86_64_inventec_d10056_config_settings table. */ -extern x86_64_inventec_d10056_config_settings_t x86_64_inventec_d10056_config_settings[]; - -/** - * @brief Lookup a configuration setting. - * @param setting The name of the configuration option to lookup. - */ -const char* x86_64_inventec_d10056_config_lookup(const char* setting); - -/** - * @brief Show the compile-time configuration. - * @param pvs The output stream. - */ -int x86_64_inventec_d10056_config_show(struct aim_pvs_s* pvs); - -/* */ - -#include "x86_64_inventec_d10056_porting.h" - -#endif /* __X86_64_INVENTEC_D10056_CONFIG_H__ */ -/* @} */ diff --git a/packages/platforms/inventec/x86-64/d10056/onlp/builds/x86_64_inventec_d10056/module/inc/x86_64_inventec_d10056/x86_64_inventec_d10056_dox.h b/packages/platforms/inventec/x86-64/d10056/onlp/builds/x86_64_inventec_d10056/module/inc/x86_64_inventec_d10056/x86_64_inventec_d10056_dox.h deleted file mode 100644 index 11d5a37f1..000000000 --- a/packages/platforms/inventec/x86-64/d10056/onlp/builds/x86_64_inventec_d10056/module/inc/x86_64_inventec_d10056/x86_64_inventec_d10056_dox.h +++ /dev/null @@ -1,26 +0,0 @@ -/**************************************************************************//** - * - * x86_64_inventec_d10056 Doxygen Header - * - *****************************************************************************/ -#ifndef __x86_64_inventec_d10056_DOX_H__ -#define __x86_64_inventec_d10056_DOX_H__ - -/** - * @defgroup x86_64_inventec_d10056 x86_64_inventec_d10056 - x86_64_inventec_d10056 Description - * - -The documentation overview for this module should go here. - - * - * @{ - * - * @defgroup x86_64_inventec_d10056-x86_64_inventec_d10056 Public Interface - * @defgroup x86_64_inventec_d10056-config Compile Time Configuration - * @defgroup x86_64_inventec_d10056-porting Porting Macros - * - * @} - * - */ - -#endif /* __x86_64_inventec_d10056_DOX_H__ */ diff --git a/packages/platforms/inventec/x86-64/d10056/onlp/builds/x86_64_inventec_d10056/module/inc/x86_64_inventec_d10056/x86_64_inventec_d10056_porting.h b/packages/platforms/inventec/x86-64/d10056/onlp/builds/x86_64_inventec_d10056/module/inc/x86_64_inventec_d10056/x86_64_inventec_d10056_porting.h deleted file mode 100644 index 6ba0b8443..000000000 --- a/packages/platforms/inventec/x86-64/d10056/onlp/builds/x86_64_inventec_d10056/module/inc/x86_64_inventec_d10056/x86_64_inventec_d10056_porting.h +++ /dev/null @@ -1,97 +0,0 @@ -/**************************************************************************//** - * - * @file - * @brief x86_64_inventec_d10056 Porting Macros. - * - * @addtogroup x86_64_inventec_d10056-porting - * @{ - * - *****************************************************************************/ -#ifndef __x86_64_inventec_d10056_PORTING_H__ -#define __x86_64_inventec_d10056_PORTING_H__ - - -/* */ -#if X86_64_INVENTEC_D10056_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS == 1 -#include -#include -#include -#include -#include -#endif - -#ifndef X86_64_INVENTEC_D10056_MALLOC - #if defined(GLOBAL_MALLOC) - #define X86_64_INVENTEC_D10056_MALLOC GLOBAL_MALLOC - #elif X86_64_INVENTEC_D10056_CONFIG_PORTING_STDLIB == 1 - #define X86_64_INVENTEC_D10056_MALLOC malloc - #else - #error The macro X86_64_INVENTEC_D10056_MALLOC is required but cannot be defined. - #endif -#endif - -#ifndef X86_64_INVENTEC_D10056_FREE - #if defined(GLOBAL_FREE) - #define X86_64_INVENTEC_D10056_FREE GLOBAL_FREE - #elif X86_64_INVENTEC_D10056_CONFIG_PORTING_STDLIB == 1 - #define X86_64_INVENTEC_D10056_FREE free - #else - #error The macro X86_64_INVENTEC_D10056_FREE is required but cannot be defined. - #endif -#endif - -#ifndef X86_64_INVENTEC_D10056_MEMSET - #if defined(GLOBAL_MEMSET) - #define X86_64_INVENTEC_D10056_MEMSET GLOBAL_MEMSET - #elif X86_64_INVENTEC_D10056_CONFIG_PORTING_STDLIB == 1 - #define X86_64_INVENTEC_D10056_MEMSET memset - #else - #error The macro X86_64_INVENTEC_D10056_MEMSET is required but cannot be defined. - #endif -#endif - -#ifndef X86_64_INVENTEC_D10056_MEMCPY - #if defined(GLOBAL_MEMCPY) - #define X86_64_INVENTEC_D10056_MEMCPY GLOBAL_MEMCPY - #elif X86_64_INVENTEC_D10056_CONFIG_PORTING_STDLIB == 1 - #define X86_64_INVENTEC_D10056_MEMCPY memcpy - #else - #error The macro X86_64_INVENTEC_D10056_MEMCPY is required but cannot be defined. - #endif -#endif - -#ifndef X86_64_INVENTEC_D10056_VSNPRINTF - #if defined(GLOBAL_VSNPRINTF) - #define X86_64_INVENTEC_D10056_VSNPRINTF GLOBAL_VSNPRINTF - #elif X86_64_INVENTEC_D10056_CONFIG_PORTING_STDLIB == 1 - #define X86_64_INVENTEC_D10056_VSNPRINTF vsnprintf - #else - #error The macro X86_64_INVENTEC_D10056_VSNPRINTF is required but cannot be defined. - #endif -#endif - -#ifndef X86_64_INVENTEC_D10056_SNPRINTF - #if defined(GLOBAL_SNPRINTF) - #define X86_64_INVENTEC_D10056_SNPRINTF GLOBAL_SNPRINTF - #elif X86_64_INVENTEC_D10056_CONFIG_PORTING_STDLIB == 1 - #define X86_64_INVENTEC_D10056_SNPRINTF snprintf - #else - #error The macro X86_64_INVENTEC_D10056_SNPRINTF is required but cannot be defined. - #endif -#endif - -#ifndef X86_64_INVENTEC_D10056_STRLEN - #if defined(GLOBAL_STRLEN) - #define X86_64_INVENTEC_D10056_STRLEN GLOBAL_STRLEN - #elif X86_64_INVENTEC_D10056_CONFIG_PORTING_STDLIB == 1 - #define X86_64_INVENTEC_D10056_STRLEN strlen - #else - #error The macro X86_64_INVENTEC_D10056_STRLEN is required but cannot be defined. - #endif -#endif - -/* */ - - -#endif /* __x86_64_inventec_d10056_PORTING_H__ */ -/* @} */ diff --git a/packages/platforms/inventec/x86-64/d10056/onlp/builds/x86_64_inventec_d10056/module/make.mk b/packages/platforms/inventec/x86-64/d10056/onlp/builds/x86_64_inventec_d10056/module/make.mk deleted file mode 100644 index 17331a8aa..000000000 --- a/packages/platforms/inventec/x86-64/d10056/onlp/builds/x86_64_inventec_d10056/module/make.mk +++ /dev/null @@ -1,11 +0,0 @@ -############################################################################### -# -# -# -############################################################################### -THIS_DIR := $(dir $(lastword $(MAKEFILE_LIST))) -x86_64_inventec_d10056_INCLUDES := -I $(THIS_DIR)inc -x86_64_inventec_d10056_INTERNAL_INCLUDES := -I $(THIS_DIR)src -x86_64_inventec_d10056_DEPENDMODULE_ENTRIES := init:x86_64_inventec_d10056 ucli:x86_64_inventec_d10056 - -x86_64_inventec_d10056_CFLAGS := -Wno-restrict -Wno-format-truncation diff --git a/packages/platforms/inventec/x86-64/d10056/onlp/builds/x86_64_inventec_d10056/module/src/Makefile b/packages/platforms/inventec/x86-64/d10056/onlp/builds/x86_64_inventec_d10056/module/src/Makefile deleted file mode 100644 index 1daf7caec..000000000 --- a/packages/platforms/inventec/x86-64/d10056/onlp/builds/x86_64_inventec_d10056/module/src/Makefile +++ /dev/null @@ -1,9 +0,0 @@ -############################################################################### -# -# Local source generation targets. -# -############################################################################### - -ucli: - @../../../../tools/uclihandlers.py x86_64_inventec_d10056_ucli.c - diff --git a/packages/platforms/inventec/x86-64/d10056/onlp/builds/x86_64_inventec_d10056/module/src/debug.c b/packages/platforms/inventec/x86-64/d10056/onlp/builds/x86_64_inventec_d10056/module/src/debug.c deleted file mode 100644 index 587232c0c..000000000 --- a/packages/platforms/inventec/x86-64/d10056/onlp/builds/x86_64_inventec_d10056/module/src/debug.c +++ /dev/null @@ -1,45 +0,0 @@ -#include "x86_64_inventec_d10056_int.h" - -#if X86_64_INVENTEC_D10056_CONFIG_INCLUDE_DEBUG == 1 - -#include - -static char help__[] = - "Usage: debug [options]\n" - " -c CPLD Versions\n" - " -h Help\n" - ; - -int -x86_64_inventec_d10056_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/d10056/onlp/builds/x86_64_inventec_d10056/module/src/fani.c b/packages/platforms/inventec/x86-64/d10056/onlp/builds/x86_64_inventec_d10056/module/src/fani.c deleted file mode 100644 index 8a6dd883b..000000000 --- a/packages/platforms/inventec/x86-64/d10056/onlp/builds/x86_64_inventec_d10056/module/src/fani.c +++ /dev/null @@ -1,415 +0,0 @@ -/************************************************************ - * - * - * Copyright 2054 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 -#include "platform_lib.h" - -#define VALIDATE(_id) \ - do { \ - if(!ONLP_OID_IS_FAN(_id)) { \ - return ONLP_STATUS_E_INVALID; \ - } \ - } while(0) - - -#define SLOW_PWM 100 -#define NORMAL_PWM 175 -#define MAX_PWM 255 -#define STEP_SIZE 100 -#define FAN_ON_MAIN_BOARD_COUNT 4 -#define LOCAL_ID_TO_PSU_ID(id) (id-FAN_ON_MAIN_BOARD_COUNT) - -#define FAN_CAPS ONLP_FAN_CAPS_GET_RPM|ONLP_FAN_CAPS_GET_PERCENTAGE - -static int _fani_status_failed_check(uint32_t* status, int local_id); -static int _fani_status_present_check(uint32_t* status, int local_id); - -#define MAKE_FAN_INFO_NODE_ON_FAN_BOARD(id) \ - { \ - { \ - ONLP_FAN_ID_CREATE(ONLP_FAN_##id), "Fan "#id, 0, \ - { \ - ONLP_LED_ID_CREATE(ONLP_LED_FAN##id), \ - } \ - }, \ - 0, FAN_CAPS \ - } - -#define MAKE_FAN_INFO_NODE_ON_PSU(psu_id) \ - { \ - { ONLP_FAN_ID_CREATE(ONLP_FAN_PSU_##psu_id), "PSU-"#psu_id" Fan", ONLP_PSU_ID_CREATE(ONLP_PSU_##psu_id)}, \ - 0, FAN_CAPS \ - } - - -/* Static values */ -static onlp_fan_info_t __onlp_fan_info[ONLP_FAN_COUNT] = { - {}, - 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_PSU(1), - MAKE_FAN_INFO_NODE_ON_PSU(2), -}; - - -/* - * 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 rv = ONLP_STATUS_OK; - int lrpm=0, rrpm=0, pwm=0, psu_id; - VALIDATE(id); - - int fan_id=ONLP_OID_ID_GET(id); - if(fan_id>=ONLP_FAN_MAX) { - rv=ONLP_STATUS_E_INVALID; - } - - if(rv==ONLP_STATUS_OK) { - *info=__onlp_fan_info[fan_id]; - rv=onlp_fani_status_get(id, &info->status); - } - - if(rv == ONLP_STATUS_OK) { - if(info->status & ONLP_FAN_STATUS_PRESENT) { - switch(fan_id) { - case ONLP_FAN_1: - case ONLP_FAN_2: - case ONLP_FAN_3: - case ONLP_FAN_4: - if(info->status & ONLP_FAN_STATUS_F2B) { - info->caps = ADD_STATE(info->caps,ONLP_FAN_CAPS_F2B); - } else if(info->status & ONLP_FAN_STATUS_B2F) { - info->caps = ADD_STATE(info->caps,ONLP_FAN_CAPS_B2F) ; - } - - rv = onlp_file_read_int(&lrpm, INV_HWMON_PREFIX"fan%d_input", fan_id*2-1); - if(rv != ONLP_STATUS_OK ) { - return rv; - } - rv = onlp_file_read_int(&rrpm, INV_HWMON_PREFIX"fan%d_input", fan_id*2); - if(rv != ONLP_STATUS_OK ) { - return rv; - } - rv = onlp_file_read_int(&pwm,INV_HWMON_PREFIX"pwm%d", fan_id); - if(rv != ONLP_STATUS_OK ) { - return rv; - } - - if(lrpm <=0 && rrpm <=0) { - info->rpm = 0; - } else if(lrpm <= 0) { - info->rpm = rrpm; - } else if(rrpm <= 0) { - info->rpm = lrpm; - } else { - info->rpm = (lrpm+rrpm)/2; - } - - break; - case ONLP_FAN_PSU_1: - case ONLP_FAN_PSU_2: - info->caps = FAN_CAPS|ONLP_FAN_CAPS_F2B; - psu_id = LOCAL_ID_TO_PSU_ID(fan_id); - rv = onlp_file_read_int(&info->rpm,INV_HWMON_PREFIX"rpm_psu%d", psu_id); - if(rv != ONLP_STATUS_OK) { - return rv; - } - rv = onlp_file_read_int(&pwm, INV_HWMON_PREFIX"pwm_psu%d", psu_id); - if(rv != ONLP_STATUS_OK) { - return rv; - } - break; - default: - rv = ONLP_STATUS_E_INVALID; - break; - } - if(rv == ONLP_STATUS_OK) { - if(info->rpm <= 0) { - info->mode = ONLP_FAN_MODE_OFF; - info->percentage = 0; - } else { - info->percentage = (pwm*100)/MAX_PWM; - if(pwm < SLOW_PWM) { - info->mode = ONLP_FAN_MODE_SLOW; - } else if(pwm < NORMAL_PWM) { - info->mode = ONLP_FAN_MODE_NORMAL; - } else if(pwm < MAX_PWM) { - info->mode = ONLP_FAN_MODE_FAST; - } else { - info->mode = ONLP_FAN_MODE_MAX; - } - } - } - } else { - info->caps = 0; - info->rpm = 0; - info->percentage = 0; - info->mode = ONLP_FAN_MODE_OFF; - } - snprintf(info->model, ONLP_CONFIG_INFO_STR_MAX, "NA"); - snprintf(info->serial, ONLP_CONFIG_INFO_STR_MAX, "NA"); - } - return rv; -} -static int _fani_status_failed_check(uint32_t* status, int local_id) -{ - int rv; - int lrpm, rrpm, rpm, pwm, psu_id; - switch(local_id) { - case ONLP_FAN_1: - case ONLP_FAN_2: - case ONLP_FAN_3: - case ONLP_FAN_4: - rv = onlp_file_read_int(&lrpm, INV_HWMON_PREFIX"fan%d_input", local_id*2-1); - if(rv != ONLP_STATUS_OK ) { - return rv; - } - rv = onlp_file_read_int(&rrpm, INV_HWMON_PREFIX"fan%d_input", local_id*2); - if(rv != ONLP_STATUS_OK ) { - return rv; - } - rv = onlp_file_read_int(&pwm,INV_HWMON_PREFIX"pwm%d", local_id); - if(rv != ONLP_STATUS_OK ) { - return rv; - } - - if(lrpm<=0 || rrpm<=0 || pwm<=0 || pwm > MAX_PWM) { - *status=ADD_STATE(*status,ONLP_FAN_STATUS_FAILED); - *status=REMOVE_STATE(*status,ONLP_FAN_STATUS_B2F); - *status=REMOVE_STATE(*status,ONLP_FAN_STATUS_F2B); - } else { - *status=REMOVE_STATE(*status,ONLP_FAN_STATUS_FAILED); - } - break; - case ONLP_FAN_PSU_1: - case ONLP_FAN_PSU_2: - psu_id = LOCAL_ID_TO_PSU_ID(local_id); - rv = onlp_file_read_int(&rpm, INV_HWMON_PREFIX"rpm_psu%d", psu_id); - if(rv != ONLP_STATUS_OK ) { - return rv; - } - rv = onlp_file_read_int(&pwm, INV_HWMON_PREFIX"pwm_psu%d", psu_id); - if(rv != ONLP_STATUS_OK ) { - return rv; - } - - if( rpm <= 0 || pwm <=0 || pwm > MAX_PWM) { - *status=ADD_STATE(*status,ONLP_FAN_STATUS_FAILED); - *status=REMOVE_STATE(*status,ONLP_FAN_STATUS_B2F); - *status=REMOVE_STATE(*status,ONLP_FAN_STATUS_F2B); - } else { - *status=REMOVE_STATE(*status,ONLP_FAN_STATUS_FAILED); - } - break; - default: - rv = ONLP_STATUS_E_INVALID; - break; - } - return rv; -} - -static int _fani_status_present_check(uint32_t* status, int local_id) -{ - int rv; - int gpi; - int info_idx=local_id-1; - int len; - char buf[ONLP_CONFIG_INFO_STR_MAX]; - if(local_id >= ONLP_FAN_1 && local_id <= ONLP_FAN_4) { - rv = onlp_file_read((uint8_t*)buf,ONLP_CONFIG_INFO_STR_MAX, &len, INV_HWMON_PREFIX"fan_gpi"); - } else { - rv = ONLP_STATUS_E_INVALID; - } - if( rv == ONLP_STATUS_OK ) { - sscanf( buf, "0x%x\n", &gpi); - /* B[0-3] installed(0)/uninstalled(1) - B[4-7] FRtype(0)/RFtype(1) */ - if (!((gpi>>info_idx) & 1)) { - *status = ADD_STATE(*status,ONLP_FAN_STATUS_PRESENT); - bool flow_b2f=((gpi>>(info_idx+4)) & 1); - *status= (flow_b2f)? ADD_STATE(*status,ONLP_FAN_STATUS_B2F) : ADD_STATE(*status,ONLP_FAN_STATUS_F2B); - } else { - *status = 0; - } - } - return rv; -} - -/** - * @brief Retrieve the fan's operational status. - * @param id The fan OID. - * @param rv [out] Receives the fan's operations status flags. - * @notes Only operational state needs to be returned - - * PRESENT/FAILED - */ -int onlp_fani_status_get(onlp_oid_t id, uint32_t* rv) -{ - int result = ONLP_STATUS_OK; - onlp_fan_info_t* info; - int fan_id=ONLP_OID_ID_GET(id); - VALIDATE(id); - uint32_t psu_status; - - if(fan_id >= ONLP_FAN_MAX) { - result = ONLP_STATUS_E_INVALID; - } else { - info = &__onlp_fan_info[fan_id]; - switch(fan_id) { - case ONLP_FAN_1: - case ONLP_FAN_2: - case ONLP_FAN_3: - case ONLP_FAN_4: - result = _fani_status_present_check(&info->status, fan_id); - if (result == ONLP_STATUS_OK ) { - if (info->status & ONLP_FAN_STATUS_PRESENT) { - result = _fani_status_failed_check(&info->status, fan_id); - } - } - break; - case ONLP_FAN_PSU_1: - case ONLP_FAN_PSU_2: - result = onlp_psui_status_get((&info->hdr)->poid, &psu_status); - if(result != ONLP_STATUS_OK) { - return result; - } - if(psu_status & ONLP_PSU_STATUS_PRESENT) { - info->status = ADD_STATE(info->status, ONLP_FAN_STATUS_PRESENT); - result = _fani_status_failed_check(&info->status, fan_id); - } else { - info->status = 0; - } - break; - default: - result = ONLP_STATUS_E_INVALID; - break; - } - *rv = info->status; - } - return result; -} - -/** - * @brief Retrieve the fan's OID hdr. - * @param id The fan OID. - * @param rv [out] Receives the OID header. - */ -int onlp_fani_hdr_get(onlp_oid_t id, onlp_oid_hdr_t* hdr) -{ - int result = ONLP_STATUS_OK; - onlp_fan_info_t* info; - int local_id; - VALIDATE(id); - - local_id = ONLP_OID_ID_GET(id); - if(local_id >= ONLP_FAN_MAX) { - result = ONLP_STATUS_E_INVALID; - } else { - info = &__onlp_fan_info[local_id]; - *hdr = info->hdr; - } - return result; -} - - -/* - * 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) -{ - return ONLP_STATUS_E_UNSUPPORTED; -} - - -/* - * 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/d10056/onlp/builds/x86_64_inventec_d10056/module/src/ledi.c b/packages/platforms/inventec/x86-64/d10056/onlp/builds/x86_64_inventec_d10056/module/src/ledi.c deleted file mode 100644 index ddbb9ee7d..000000000 --- a/packages/platforms/inventec/x86-64/d10056/onlp/builds/x86_64_inventec_d10056/module/src/ledi.c +++ /dev/null @@ -1,438 +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 "platform_lib.h" - -#define VALIDATE(_id) \ - do { \ - if(!ONLP_OID_IS_LED(_id)) { \ - return ONLP_STATUS_E_INVALID; \ - } \ - } while(0) - -/* LED related data - */ - -/* CAPS*/ -#define SYS_LED_CAPS 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_ORANGE -#define FAN_LED_CAPS ONLP_LED_CAPS_RED|ONLP_LED_CAPS_GREEN - -#define LOCAL_ID_TO_FAN_ID(id) (id-1) - -typedef enum sys_led_mode_e { - SYS_LED_MODE_OFF = 0, - SYS_LED_MODE_0_5_HZ = 1, - SYS_LED_MODE_1_HZ = 2, - SYS_LED_MODE_2_HZ = 3, - SYS_LED_MODE_ON = 7 -} sys_led_mode_t; - -/* function declarations*/ -static int _sys_onlp_led_mode_convert(sys_led_mode_t grn_mode, sys_led_mode_t red_mode, onlp_led_mode_t* pmode); -static int _sys_onlp_ledi_info_get(onlp_oid_t id, onlp_led_info_t* info); -static int _fan_onlp_ledi_info_get(onlp_oid_t id, onlp_led_info_t* info); -static int _sys_onlp_ledi_mode_set(onlp_led_mode_t onlp_mode); - -/* - * Get the information for the given LED OID. - */ -#define MAKE_MGMT_LED_INFO_NODE \ - { \ - { ONLP_LED_ID_CREATE(ONLP_LED_MGMT), "MGMT LED" , 0 }, \ - ONLP_LED_STATUS_PRESENT, \ - SYS_LED_CAPS, \ - } - -#define MAKE_LED_INFO_NODE_ON_FAN(fan_id) \ - { \ - { ONLP_LED_ID_CREATE(ONLP_LED_FAN##fan_id), \ - "FAN LED "#fan_id, \ - ONLP_FAN_ID_CREATE(ONLP_FAN_##fan_id) \ - }, \ - 0, FAN_LED_CAPS, \ - } - -static onlp_led_info_t __onlp_led_info[] = { - {}, - MAKE_MGMT_LED_INFO_NODE, - MAKE_LED_INFO_NODE_ON_FAN(1), - MAKE_LED_INFO_NODE_ON_FAN(2), - MAKE_LED_INFO_NODE_ON_FAN(3), - MAKE_LED_INFO_NODE_ON_FAN(4), -}; - - - -/* convert platform led type to onlp_led_mode type*/ -static int _sys_onlp_led_mode_convert(sys_led_mode_t grn_mode, sys_led_mode_t red_mode, onlp_led_mode_t* pmode) -{ - int rv = ONLP_STATUS_OK; - *pmode = ONLP_LED_MODE_OFF; - - switch(grn_mode) { - case SYS_LED_MODE_0_5_HZ: - case SYS_LED_MODE_1_HZ: - case SYS_LED_MODE_2_HZ: - if(red_mode==SYS_LED_MODE_OFF) { - *pmode = ONLP_LED_MODE_GREEN_BLINKING; - } else { - return ONLP_STATUS_E_INVALID; - } - break; - case SYS_LED_MODE_ON: - if(red_mode==SYS_LED_MODE_ON) { - *pmode = ONLP_LED_MODE_ORANGE; - } else if(red_mode==SYS_LED_MODE_OFF) { - *pmode = ONLP_LED_MODE_GREEN; - } else { - return ONLP_STATUS_E_INVALID; - } - break; - case SYS_LED_MODE_OFF: - if(red_mode==SYS_LED_MODE_OFF) { - *pmode = ONLP_LED_MODE_OFF; - } else if( (red_mode>=SYS_LED_MODE_0_5_HZ) && (red_mode<=SYS_LED_MODE_2_HZ) ) { - *pmode =ONLP_LED_MODE_RED_BLINKING; - } else if(red_mode==SYS_LED_MODE_ON) { - *pmode=ONLP_LED_MODE_RED; - } - break; - default: - return ONLP_STATUS_E_INVALID; - break; - } - return rv; -} - - -static int _sys_onlp_ledi_info_get(onlp_oid_t id, onlp_led_info_t* info) -{ - int rv = ONLP_STATUS_OK; - int grn_mode, red_mode; - int led_id= ONLP_OID_ID_GET(id); - *info= __onlp_led_info[led_id]; - - rv = onlp_file_read_int((int*)&grn_mode, INV_SYSLED_PREFIX"grn_led"); - if(rv != ONLP_STATUS_OK) { - return rv; - } - rv = onlp_file_read_int((int*)&red_mode, INV_SYSLED_PREFIX"red_led"); - if(rv != ONLP_STATUS_OK) { - return rv; - } - - rv = _sys_onlp_led_mode_convert(grn_mode, red_mode, &info->mode); - if(rv != ONLP_STATUS_OK) { - return rv; - } - - info->status = (info->mode==ONLP_LED_MODE_OFF)? \ - REMOVE_STATE(info->status,ONLP_LED_STATUS_ON) : ADD_STATE(info->status,ONLP_LED_STATUS_ON); - - return rv; -} - -static int _fan_onlp_ledi_info_get(onlp_oid_t id, onlp_led_info_t* info) -{ - int rv = ONLP_STATUS_OK; - int grn_mode, red_mode; - int led_id=ONLP_OID_ID_GET(id); - int fan_id=LOCAL_ID_TO_FAN_ID(led_id); - *info=__onlp_led_info[led_id]; - - rv = onlp_ledi_status_get(id, &info->status); - if( rv != ONLP_STATUS_OK ) { - return rv; - } - - if( info->status & ONLP_LED_STATUS_PRESENT) { - info->caps = FAN_LED_CAPS; - rv = onlp_file_read_int((int*)&grn_mode, INV_HWMON_PREFIX"fan_led_grn%d", fan_id); - if(rv != ONLP_STATUS_OK ) { - return rv; - } - rv = onlp_file_read_int((int*)&red_mode, INV_HWMON_PREFIX"fan_led_red%d", fan_id); - if(rv != ONLP_STATUS_OK ) { - return rv; - } - - if(grn_mode == 1 && red_mode == 0) { - info->mode = ONLP_LED_MODE_GREEN; - } else if(grn_mode == 0 && red_mode == 1) { - info->mode = ONLP_LED_MODE_RED; - } else if(grn_mode == 0 && red_mode == 0) { - info->mode = ONLP_LED_MODE_OFF; - } else { - rv = ONLP_STATUS_E_INVALID; - } - } else { - info->mode = ONLP_LED_MODE_OFF; - } - return rv; -} - -static int _sys_onlp_ledi_mode_set(onlp_led_mode_t onlp_mode) -{ - int rv = ONLP_STATUS_OK; - - if( onlp_mode == ONLP_LED_MODE_OFF) { - rv = onlp_file_write_int(SYS_LED_MODE_OFF, INV_SYSLED_PREFIX"grn_led"); - if(rv != ONLP_STATUS_OK ) { - return rv; - } - rv = onlp_file_write_int(SYS_LED_MODE_OFF, INV_SYSLED_PREFIX"red_led"); - } else { - rv = ONLP_STATUS_E_UNSUPPORTED; - } - return rv; -} - - - -/* - * 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; - VALIDATE(id); - int led_id= ONLP_OID_ID_GET(id); - if( led_id >= ONLP_LED_MAX) { - return ONLP_STATUS_E_INVALID; - } - - switch(led_id) { - case ONLP_LED_MGMT: - rv = _sys_onlp_ledi_info_get(id, info); - break; - case ONLP_LED_FAN1: - case ONLP_LED_FAN2: - case ONLP_LED_FAN3: - case ONLP_LED_FAN4: - rv = _fan_onlp_ledi_info_get(id, info); - break; - default: - rv = ONLP_STATUS_E_INVALID; - break; - } - return rv; -} - -/** - * @brief Get the LED operational status. - * @param id The LED OID - * @param rv [out] Receives the operational status. - */ -int onlp_ledi_status_get(onlp_oid_t id, uint32_t* rv) -{ - int result = ONLP_STATUS_OK; - onlp_led_info_t* info; - - VALIDATE(id); - int led_id = ONLP_OID_ID_GET(id); - int fan_id = LOCAL_ID_TO_FAN_ID( led_id); - int grn_mode, red_mode, mode; - onlp_led_mode_t pmode; - uint32_t fan_status; - - if( led_id >= ONLP_LED_MAX) { - result = ONLP_STATUS_E_INVALID; - } - if(result == ONLP_STATUS_OK) { - info = &__onlp_led_info[led_id]; - switch(led_id) { - case ONLP_LED_MGMT: - result = onlp_file_read_int((int*)&grn_mode, INV_SYSLED_PREFIX"grn_led"); - if(result != ONLP_STATUS_OK) { - return result; - } - result = onlp_file_read_int((int*)&red_mode, INV_SYSLED_PREFIX"red_led"); - if(result != ONLP_STATUS_OK) { - return result; - } - - result = _sys_onlp_led_mode_convert(grn_mode, red_mode, &pmode); - if(result != ONLP_STATUS_OK) { - return result; - } - - if( pmode != ONLP_LED_MODE_OFF) { - info->status = ADD_STATE(info->status,ONLP_LED_STATUS_ON); - } else { - info->status = REMOVE_STATE(info->status, ONLP_LED_STATUS_ON); - } - - *rv = info->status; - break; - case ONLP_LED_FAN1: - case ONLP_LED_FAN2: - case ONLP_LED_FAN3: - case ONLP_LED_FAN4: - result = onlp_fani_status_get((&info->hdr)->poid, &fan_status); - if(result != ONLP_STATUS_OK) { - return result; - } - - if(fan_status & ONLP_FAN_STATUS_PRESENT) { - info->status = ADD_STATE(info->status,ONLP_LED_STATUS_PRESENT); - - result = onlp_file_read_int((int*)&mode, INV_HWMON_PREFIX"fan_led_grn%d", fan_id); - if(result != ONLP_STATUS_OK) { - return result; - } - result = onlp_file_read_int((int*)&mode, INV_HWMON_PREFIX"fan_led_red%d", fan_id); - if(result != ONLP_STATUS_OK) { - return result; - } - info->status = (mode==1)? \ - ADD_STATE(info->status,ONLP_LED_STATUS_ON):REMOVE_STATE(info->status,ONLP_LED_STATUS_ON); - - } else { - info->status = 0; - } - *rv = info->status; - break; - default: - result = ONLP_STATUS_E_INVALID; - break; - } - } - - return result; -} - -/** - * @brief Get the LED header. - * @param id The LED OID - * @param rv [out] Receives the header. - */ -int onlp_ledi_hdr_get(onlp_oid_t id, onlp_oid_hdr_t* rv) -{ - int result = ONLP_STATUS_OK; - onlp_led_info_t* info; - - VALIDATE(id); - - int led_id = ONLP_OID_ID_GET(id); - if( led_id >= ONLP_LED_MAX) { - result = ONLP_STATUS_E_INVALID; - } else { - - info = &__onlp_led_info[led_id]; - *rv = info->hdr; - } - return result; -} - -/* - * 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) -{ - onlp_led_mode_t mode; - VALIDATE(id); - int local_id; - local_id = ONLP_OID_ID_GET(id); - int idx = LOCAL_ID_TO_INFO_IDX(local_id); - - if(local_id >= ONLP_LED_MAX) { - return ONLP_STATUS_E_INVALID; - } - - if (__onlp_led_info[idx].caps & ONLP_LED_CAPS_ON_OFF) { - mode = on_or_off?ONLP_LED_MODE_ON:ONLP_LED_MODE_OFF; - return onlp_ledi_mode_set(id, mode); - } - - 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 rv = ONLP_STATUS_OK; - VALIDATE(id); - int local_id; - local_id = ONLP_OID_ID_GET(id); - - if(local_id >= ONLP_LED_MAX) { - return ONLP_STATUS_E_INVALID; - } - switch(local_id) { - case ONLP_LED_MGMT: - rv = _sys_onlp_ledi_mode_set(mode); - break; - case ONLP_LED_FAN1: - case ONLP_LED_FAN2: - case ONLP_LED_FAN3: - case ONLP_LED_FAN4: - rv = ONLP_STATUS_E_UNSUPPORTED; - break; - default: - rv = ONLP_STATUS_E_INVALID; - break; - } - - return rv; -} - -/* - * 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/d10056/onlp/builds/x86_64_inventec_d10056/module/src/make.mk b/packages/platforms/inventec/x86-64/d10056/onlp/builds/x86_64_inventec_d10056/module/src/make.mk deleted file mode 100644 index 8d84f538c..000000000 --- a/packages/platforms/inventec/x86-64/d10056/onlp/builds/x86_64_inventec_d10056/module/src/make.mk +++ /dev/null @@ -1,9 +0,0 @@ -############################################################################### -# -# -# -############################################################################### - -LIBRARY := x86_64_inventec_d10056 -$(LIBRARY)_SUBDIR := $(dir $(lastword $(MAKEFILE_LIST))) -include $(BUILDER)/lib.mk diff --git a/packages/platforms/inventec/x86-64/d10056/onlp/builds/x86_64_inventec_d10056/module/src/platform_lib.c b/packages/platforms/inventec/x86-64/d10056/onlp/builds/x86_64_inventec_d10056/module/src/platform_lib.c deleted file mode 100644 index bb04678b2..000000000 --- a/packages/platforms/inventec/x86-64/d10056/onlp/builds/x86_64_inventec_d10056/module/src/platform_lib.c +++ /dev/null @@ -1,50 +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" - - -int platform_hwmon_diag_enable_read(int *enable) -{ - int rv = ONLP_STATUS_OK; - rv = onlp_file_read_int((int*)enable, INV_HWMON_PREFIX"diag"); - return rv; -} - - -int platform_hwmon_diag_enable_write(int enable) -{ - int rv = ONLP_STATUS_OK; - rv = onlp_file_write_int(enable, INV_HWMON_PREFIX"diag"); - return rv; -} diff --git a/packages/platforms/inventec/x86-64/d10056/onlp/builds/x86_64_inventec_d10056/module/src/platform_lib.h b/packages/platforms/inventec/x86-64/d10056/onlp/builds/x86_64_inventec_d10056/module/src/platform_lib.h deleted file mode 100644 index a2317cd4d..000000000 --- a/packages/platforms/inventec/x86-64/d10056/onlp/builds/x86_64_inventec_d10056/module/src/platform_lib.h +++ /dev/null @@ -1,143 +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 "x86_64_inventec_d10056_log.h" - -/* This is definitions for x86-64-inventec-d10056*/ -/* OID map*/ -/* - * SYS---------ONLP_THERMAL_CPU_PHY - * |----ONLP_THERMAL_CPU_CORE0 - * |----ONLP_THERMAL_CPU_CORE1 - * |----ONLP_THERMAL_CPU_CORE2 - * |----ONLP_THERMAL_CPU_CORE3 - * |----ONLP_THERMAL_1_ON_MAIN_BROAD - * |----ONLP_THERMAL_2_ON_MAIN_BROAD - * |----ONLP_THERMAL_3_ON_MAIN_BROAD - * |----ONLP_THERMAL_4_ON_MAIN_BROAD - * |----ONLP_THERMAL_5_ON_MAIN_BROAD - * |----ONLP_FAN_1--------ONLP_LED_FAN1 - * | - * |----ONLP_FAN_2--------ONLP_LED_FAN2 - * | - * |----ONLP_FAN_3--------ONLP_LED_FAN3 - * | - * |----ONLP_FAN_4--------ONLP_LED_FAN4 - * | - * | - * |----ONLP_PSU_1--------ONLP_THERMAL_1_ON_PSU1 - * | |--ONLP_THERMAL_2_ON_PSU1 - * | |--ONLP_FAN_PSU_1 - * | - * |----ONLP_PSU_2--------ONLP_THERMAL_1_ON_PSU2 - * | |--ONLP_THERMAL_2_ON_PSU2 - * | |--ONLP_FAN_PSU_2 - * | - * |----ONLP_LED_MGMT - */ - -#define INV_SYSLED_PREFIX "/sys/class/hwmon/hwmon2/device/" -#define INV_HWMON_PREFIX "/sys/class/hwmon/hwmon1/device/" -#define INV_CTMP_PREFIX "/sys/class/hwmon/hwmon0/" -#define INV_SFP_PREFIX "/sys/class/swps/" -#define INV_SYS_PREFIX "/sys/class/eeprom/vpd/" - -#define OID_MAP_TO_INFO_IDX(oid) ONLP_OID_ID_GET(oid)-1 -#define LOCAL_ID_TO_INFO_IDX(id) (id-1) -#define ADD_STATE(orig_state,new_state) orig_state | new_state -#define REMOVE_STATE(orig_state, target) orig_state & (~target) - -/* Thermal definitions*/ -enum onlp_thermal_id { - ONLP_THERMAL_CPU_PHY = 1, - ONLP_THERMAL_CPU_CORE0, - ONLP_THERMAL_CPU_CORE1, - ONLP_THERMAL_CPU_CORE2, - ONLP_THERMAL_CPU_CORE3, - ONLP_THERMAL_1_ON_MAIN_BROAD, - ONLP_THERMAL_2_ON_MAIN_BROAD, - ONLP_THERMAL_3_ON_MAIN_BROAD, - ONLP_THERMAL_4_ON_MAIN_BROAD, - ONLP_THERMAL_5_ON_MAIN_BROAD, - ONLP_THERMAL_1_ON_PSU1, - ONLP_THERMAL_2_ON_PSU1, - ONLP_THERMAL_1_ON_PSU2, - ONLP_THERMAL_2_ON_PSU2, - ONLP_THERMAL_MAX -}; - -#define ONLP_THERMAL_COUNT 14 /*include "reserved"*/ - -/* Fan definitions*/ -enum onlp_fan_id { - ONLP_FAN_1 = 1, - ONLP_FAN_2, - ONLP_FAN_3, - ONLP_FAN_4, - ONLP_FAN_PSU_1, - ONLP_FAN_PSU_2, - ONLP_FAN_MAX -}; - -#define ONLP_FAN_COUNT 7 /*include "reserved"*/ - -/* PSU definitions*/ -enum onlp_psu_id { - ONLP_PSU_1 = 1, - ONLP_PSU_2, - ONLP_PSU_MAX -}; - -#define ONLP_PSU_COUNT 2 /*include "reserved"*/ - -/* LED definitions*/ -enum onlp_led_id { - ONLP_LED_MGMT = 1, - ONLP_LED_FAN1, - ONLP_LED_FAN2, - ONLP_LED_FAN3, - ONLP_LED_FAN4, - ONLP_LED_MAX -}; - -#define ONLP_LED_COUNT 6 /*include "reserved"*/ - - -/* platform functions*/ -#define PLATFORM_HWMON_DIAG_LOCK -#define PLATFORM_HWMON_DIAG_UNLOCK -//#define PLATFORM_HWMON_DIAG_LOCK platform_hwmon_diag_enable_write(0) -//#define PLATFORM_HWMON_DIAG_UNLOCK platform_hwmon_diag_enable_write(1) -int platform_hwmon_diag_enable_read(int *enable); -int platform_hwmon_diag_enable_write(int enable); - - - - -#endif /* __PLATFORM_LIB_H__ */ - diff --git a/packages/platforms/inventec/x86-64/d10056/onlp/builds/x86_64_inventec_d10056/module/src/psui.c b/packages/platforms/inventec/x86-64/d10056/onlp/builds/x86_64_inventec_d10056/module/src/psui.c deleted file mode 100644 index e02891f91..000000000 --- a/packages/platforms/inventec/x86-64/d10056/onlp/builds/x86_64_inventec_d10056/module/src/psui.c +++ /dev/null @@ -1,186 +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 "platform_lib.h" -#include -#include - -#define VALIDATE(_id) \ - do { \ - if(!ONLP_OID_IS_PSU(_id)) { \ - return ONLP_STATUS_E_INVALID; \ - } \ - } while(0) - -typedef enum hwmon_psu_state_e { - HWMON_PSU_NORMAL = 0, - HWMON_PSU_UNPOWERED = 2, //010 - HWMON_PSU_FAULT = 4, //100 - HWMON_PSU_NOT_INSTALLED = 7 //111 -} hwmon_psu_state_t; - -#define PATH_LENGTH 50 -#define PSU_CAPS ONLP_PSU_CAPS_VIN|ONLP_PSU_CAPS_VOUT|ONLP_PSU_CAPS_IIN|ONLP_PSU_CAPS_IOUT|ONLP_PSU_CAPS_PIN| ONLP_PSU_CAPS_POUT - -/* - * Get all information about the given PSU oid. - */ -#define MAKE_PSU_NODE_INFO(id) \ - { \ - { \ - ONLP_PSU_ID_CREATE(ONLP_PSU_##id), "PSU-"#id, 0, \ - { \ - ONLP_THERMAL_ID_CREATE(ONLP_THERMAL_1_ON_PSU##id), \ - ONLP_THERMAL_ID_CREATE(ONLP_THERMAL_2_ON_PSU##id), \ - ONLP_FAN_ID_CREATE(ONLP_FAN_PSU_##id) \ - } \ - }, \ - "","", 0, PSU_CAPS, \ - } - -static onlp_psu_info_t __onlp_psu_info[ ] = { - {}, - MAKE_PSU_NODE_INFO(1), - MAKE_PSU_NODE_INFO(2) -}; - -int -onlp_psui_init(void) -{ - return ONLP_STATUS_OK; -} - - -int -onlp_psui_info_get(onlp_oid_t id, onlp_psu_info_t* info) -{ - int ret = ONLP_STATUS_OK; - int len; - int psu_id = ONLP_OID_ID_GET(id); - uint8_t temp[ONLP_CONFIG_INFO_STR_MAX] = {0}; - - VALIDATE(id); - - if(psu_id >= ONLP_PSU_MAX) { - return ONLP_STATUS_E_INVALID; - } - - *info = __onlp_psu_info[psu_id]; - ret = onlp_psui_status_get(id, &info->status); - if(ret != ONLP_STATUS_OK) { - return ret; - } - - char *list1[]= {info->model,info->serial}; - int* list2[]= {0,0,&info->mvin,&info->mvout,&info->miin,&info->miout,&info->mpin,&info->mpout}; - char* path_list[]= {"vendor","serial","vin","vout","iin","iout","pin","pout"}; - - int i=0; - for (i=0; i<8; i++) { - char path[PATH_LENGTH]; - snprintf(path,PATH_LENGTH,"%spsoc_psu%d_%s",INV_HWMON_PREFIX,psu_id,path_list[i]); - if(i<2) { - memset(temp, 0, ONLP_CONFIG_INFO_STR_MAX); - onlp_file_read( temp, ONLP_CONFIG_INFO_STR_MAX, &len, path ); - temp[strlen((char*)temp)-1] = 0; - snprintf(list1[i], ONLP_CONFIG_INFO_STR_MAX, "%s", temp); - } else { - onlp_file_read_int( list2[i], path ); - } - } - return ret; - -} - - -/** - * @brief Get the PSU's operational status. - * @param id The PSU OID. - * @param rv [out] Receives the operational status. - */ -int onlp_psui_status_get(onlp_oid_t id, uint32_t* rv) -{ - int result = ONLP_STATUS_OK; - hwmon_psu_state_t psu_state; - int local_id; - VALIDATE(id); - int len; - char buf[ONLP_CONFIG_INFO_STR_MAX]; - - local_id = ONLP_OID_ID_GET(id); - if(local_id >= ONLP_PSU_MAX) { - result = ONLP_STATUS_E_INVALID; - } else { - result = onlp_file_read((uint8_t*)&buf, ONLP_CONFIG_INFO_STR_MAX, &len, "%s""psu%d", INV_HWMON_PREFIX, local_id); - if( result != ONLP_STATUS_OK ) { - return result; - } - psu_state = (uint8_t)strtoul(buf, NULL, 0); - if( psu_state == HWMON_PSU_UNPOWERED) { - *rv = ONLP_PSU_STATUS_PRESENT|ONLP_PSU_STATUS_UNPLUGGED; - } else if ( psu_state == HWMON_PSU_NORMAL) { - *rv = ONLP_PSU_STATUS_PRESENT; - } else if( psu_state == HWMON_PSU_FAULT) { - *rv = ONLP_PSU_STATUS_PRESENT|ONLP_PSU_STATUS_FAILED; - } else if( psu_state == HWMON_PSU_NOT_INSTALLED) { - *rv = 0; - } else { - result = ONLP_STATUS_E_INVALID; - } - } - return result; -} - -/** - * @brief Get the PSU's oid header. - * @param id The PSU OID. - * @param rv [out] Receives the header. - */ -int onlp_psui_hdr_get(onlp_oid_t id, onlp_oid_hdr_t* rv) -{ - int result = ONLP_STATUS_OK; - onlp_psu_info_t* info; - int psu_id=ONLP_OID_ID_GET(id); - - VALIDATE(id); - - if(psu_id >= ONLP_PSU_MAX) { - result = ONLP_STATUS_E_INVALID; - } else { - info = &__onlp_psu_info[psu_id]; - *rv = info->hdr; - } - return result; -} - - -int -onlp_psui_ioctl(onlp_oid_t pid, va_list vargs) -{ - return ONLP_STATUS_E_UNSUPPORTED; -} - diff --git a/packages/platforms/inventec/x86-64/d10056/onlp/builds/x86_64_inventec_d10056/module/src/sfpi.c b/packages/platforms/inventec/x86-64/d10056/onlp/builds/x86_64_inventec_d10056/module/src/sfpi.c deleted file mode 100644 index f1c40d6a0..000000000 --- a/packages/platforms/inventec/x86-64/d10056/onlp/builds/x86_64_inventec_d10056/module/src/sfpi.c +++ /dev/null @@ -1,410 +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 /* For O_RDWR && open */ -#include -#include -#include -#include -#include -#include "platform_lib.h" -#include -#include - -#define MAX_SFP_PATH 128 - -#define MUX_START_INDEX 10 -#define QSFP_DEV_ADDR 0x50 -#define NUM_OF_SFP_PORT 48 -#define NUM_OF_QSFP_PORT 8 -#define NUM_OF_ALL_PORT (NUM_OF_SFP_PORT+NUM_OF_QSFP_PORT) - -/************************************************************ - * - * SFPI Entry Points - * - ***********************************************************/ -enum onlp_sfp_port_type { - ONLP_PORT_TYPE_SFP = 0, - ONLP_PORT_TYPE_QSFP, - ONLP_PORT_TYPE_MAX -}; - -static int -onlp_sfpi_port_type(int port) -{ - if(port >= 0 && port < NUM_OF_SFP_PORT) { - return ONLP_PORT_TYPE_SFP; - } else if(port >= NUM_OF_SFP_PORT && port < NUM_OF_ALL_PORT) { - return ONLP_PORT_TYPE_QSFP; - } else { - AIM_LOG_ERROR("Invalid port(%d)\r\n", port); - return ONLP_STATUS_E_PARAM; - } -} - -int -onlp_sfpi_init(void) -{ - /* Called at initialization time */ - return ONLP_STATUS_OK; -} - -int onlp_sfpi_port_map(int port, int* rport) -{ - int p_type = onlp_sfpi_port_type(port); - if(p_type < 0) { - return ONLP_STATUS_E_INVALID; - } - *rport = port; - return ONLP_STATUS_OK; -} - -int -onlp_sfpi_bitmap_get(onlp_sfp_bitmap_t* bmap) -{ - int p; - AIM_BITMAP_CLR_ALL(bmap); - - for(p = 0; p < NUM_OF_ALL_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 p_type = onlp_sfpi_port_type(port); - if(p_type < 0) { - return ONLP_STATUS_E_INVALID; - } - - int present_data; - int rv; - if(onlp_file_read_int(&present_data, INV_SFP_PREFIX"port%d/present", port) != ONLP_STATUS_OK) { - return ONLP_STATUS_E_INTERNAL; - } - switch(present_data) { - case 1: - case 0: - return !present_data; - default: - AIM_LOG_ERROR("Unvalid present status %d from port(%d)\r\n",present_data,port); - return ONLP_STATUS_E_INTERNAL; - } - return rv; -} - -int -onlp_sfpi_presence_bitmap_get(onlp_sfp_bitmap_t* dst) -{ - AIM_BITMAP_CLR_ALL(dst); - int port; - for(port = 0; port < NUM_OF_ALL_PORT; port++) { - if(onlp_sfpi_is_present(port) == true) { - AIM_BITMAP_MOD(dst, port, 1); - } else if(onlp_sfpi_is_present(port) == false) { - AIM_BITMAP_MOD(dst, port, 0); - } else { - return ONLP_STATUS_E_INTERNAL; - } - } - return ONLP_STATUS_OK; -} - -static int -onlp_sfpi_is_rx_los(int port) -{ - int rxlos; - int rv; - int p_type = onlp_sfpi_port_type(port); - - if(p_type == ONLP_PORT_TYPE_SFP) { /* don't support to parse QSFP rxlos value */ - if(onlp_file_read_int(&rxlos, INV_SFP_PREFIX"port%d/rxlos", port) != ONLP_STATUS_OK) { - return ONLP_STATUS_E_INTERNAL; - } - if(rxlos==0){ - rv=false; - }else if(rxlos==1){ - rv=true; - } - } else { - return ONLP_STATUS_E_INVALID; - } - - return rv; -} - -int -onlp_sfpi_rx_los_bitmap_get(onlp_sfp_bitmap_t* dst) -{ - AIM_BITMAP_CLR_ALL(dst); - int port; - int isrxlos; - for(port = 0; port < NUM_OF_SFP_PORT; port++) { /* don't support to parse QSFP rxlos value */ - if(onlp_sfpi_is_present(port) == true) { - isrxlos = onlp_sfpi_is_rx_los(port); - if(isrxlos == true) { - AIM_BITMAP_MOD(dst, port, 1); - } else if(isrxlos == false) { - AIM_BITMAP_MOD(dst, port, 0); - } else { - return ONLP_STATUS_E_INTERNAL; - } - } - } - return ONLP_STATUS_OK; -} - -int -onlp_sfpi_port2chan(int port) // port start from 0 -{ - int i2c_bus=port +MUX_START_INDEX; - if(port - * - * 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 -#include - -#include "x86_64_inventec_d10056_int.h" -#include "x86_64_inventec_d10056_log.h" - -#include "platform_lib.h" - -#define SYSI_ONIE_TYPE_SUPPORT_NUM 17 -#define SYSI_PLATFORM_INFO_TYPE_STR_MAX 10 -#define SYSI_PLATFORM_INFO_NUM 2 -#define TLV_PREFIX_LENGTH 2 /*TLV prefix with one byte of 'Type' and one byte fpr 'Length' */ -#define PATH_LENGTH 50 -#define ITEM_NUM 17 - -/** - * The TLV Types. - */ -#define TLV_CODE_PRODUCT_NAME 0x21 -#define TLV_CODE_PART_NUMBER 0x22 -#define TLV_CODE_SERIAL_NUMBER 0x23 -#define TLV_CODE_MAC_BASE 0x24 -#define TLV_CODE_MANUF_DATE 0x25 -#define TLV_CODE_DEVICE_VERSION 0x26 -#define TLV_CODE_LABEL_REVISION 0x27 -#define TLV_CODE_PLATFORM_NAME 0x28 -#define TLV_CODE_ONIE_VERSION 0x29 -#define TLV_CODE_MAC_SIZE 0x2A -#define TLV_CODE_MANUF_NAME 0x2B -#define TLV_CODE_MANUF_COUNTRY 0x2C -#define TLV_CODE_VENDOR_NAME 0x2D -#define TLV_CODE_DIAG_VERSION 0x2E -#define TLV_CODE_SERVICE_TAG 0x2F -#define TLV_CODE_VENDOR_EXT 0xFD -#define TLV_CODE_CRC_32 0xFE - -static uint8_t __tlv_code_list[SYSI_ONIE_TYPE_SUPPORT_NUM] = { - TLV_CODE_PRODUCT_NAME, - TLV_CODE_PART_NUMBER, - TLV_CODE_SERIAL_NUMBER, - TLV_CODE_MAC_BASE, - TLV_CODE_MANUF_DATE, - TLV_CODE_DEVICE_VERSION, - TLV_CODE_LABEL_REVISION, - TLV_CODE_PLATFORM_NAME, - TLV_CODE_ONIE_VERSION, - TLV_CODE_MAC_SIZE, - TLV_CODE_MANUF_NAME, - TLV_CODE_MANUF_COUNTRY, - TLV_CODE_VENDOR_NAME, - TLV_CODE_DIAG_VERSION, - TLV_CODE_SERVICE_TAG, - TLV_CODE_VENDOR_EXT, - TLV_CODE_CRC_32 -}; - -static onlp_oid_t __oid_info[] = { - ONLP_THERMAL_ID_CREATE(ONLP_THERMAL_CPU_PHY), - ONLP_THERMAL_ID_CREATE(ONLP_THERMAL_CPU_CORE0), - ONLP_THERMAL_ID_CREATE(ONLP_THERMAL_CPU_CORE1), - ONLP_THERMAL_ID_CREATE(ONLP_THERMAL_CPU_CORE2), - ONLP_THERMAL_ID_CREATE(ONLP_THERMAL_CPU_CORE3), - ONLP_THERMAL_ID_CREATE(ONLP_THERMAL_1_ON_MAIN_BROAD), - ONLP_THERMAL_ID_CREATE(ONLP_THERMAL_2_ON_MAIN_BROAD), - ONLP_THERMAL_ID_CREATE(ONLP_THERMAL_3_ON_MAIN_BROAD), - ONLP_THERMAL_ID_CREATE(ONLP_THERMAL_4_ON_MAIN_BROAD), - ONLP_THERMAL_ID_CREATE(ONLP_THERMAL_5_ON_MAIN_BROAD), - ONLP_FAN_ID_CREATE(ONLP_FAN_1), - ONLP_FAN_ID_CREATE(ONLP_FAN_2), - ONLP_FAN_ID_CREATE(ONLP_FAN_3), - ONLP_FAN_ID_CREATE(ONLP_FAN_4), - ONLP_PSU_ID_CREATE(ONLP_PSU_1), - ONLP_PSU_ID_CREATE(ONLP_PSU_2), - ONLP_LED_ID_CREATE(ONLP_LED_MGMT), - 0/*end*/ -}; - -static int _sysi_version_parsing(char* file_str, char* str_buf, char* version); -static void _case_tlv_code_string(onlp_onie_info_t* info, char** member, char* path); -static int _parse_tlv(onlp_onie_info_t* info, uint8_t type, int index); - -static int _sysi_version_parsing(char* file_str, char* str_buf, char* version) -{ - int rv = ONLP_STATUS_OK; - int len; - char buf[ONLP_CONFIG_INFO_STR_MAX*4]; - char *temp; - - rv = onlp_file_read((uint8_t*)buf,ONLP_CONFIG_INFO_STR_MAX*4, &len, file_str); - if( rv != ONLP_STATUS_OK ) { - return rv; - } - - temp = strstr(buf, str_buf); - if(temp) { - temp += strlen(str_buf); - snprintf(version,ONLP_CONFIG_INFO_STR_MAX, temp); - /*remove '\n'*/ - version[strlen(version)-1] = '\0'; - } else { - rv = ONLP_STATUS_E_MISSING; - } - return rv; -} - -static void _case_tlv_code_string(onlp_onie_info_t* info, char** member, char* path) -{ - int rv = ONLP_STATUS_OK; - int len; - char buf[ONLP_CONFIG_INFO_STR_MAX]; - rv = onlp_file_read((uint8_t*)buf,ONLP_CONFIG_INFO_STR_MAX, &len, path); - if( rv == ONLP_STATUS_OK ) { - info->_hdr_length += TLV_PREFIX_LENGTH; - buf[strlen(buf)-1] = '\0'; - *member = aim_fstrdup("%s",buf); - info->_hdr_length += strlen(*member); - } else { - *member = aim_zmalloc(1); - rv = ONLP_STATUS_OK; - } - return; -} - - -static int _parse_tlv(onlp_onie_info_t* info, uint8_t type, int index) -{ - int rv = ONLP_STATUS_OK; - int len; - char buf[ONLP_CONFIG_INFO_STR_MAX]; - - char** list[]= { &(info->product_name), &(info->part_number), &(info->serial_number), NULL, &(info->manufacture_date), NULL, - &(info->label_revision), &(info->platform_name), &(info->onie_version), NULL, &(info->manufacturer) , - &(info->country_code), &(info->vendor), &(info->diag_version), &(info->service_tag), NULL ,NULL - } ; - char *path_name[]= {"product_name","pn","sn","base_mac_addr","man_date","dev_ver", "label_rev","plat_name","ldr_ver", - "mac_addr","manufacturer","country_code","vendor_name","diag_ver","service_tag","vendor_ext","crc32" - }; - char path[PATH_LENGTH]; - snprintf(path,PATH_LENGTH,"%s%s",INV_SYS_PREFIX,path_name[index]); - if(type ==TLV_CODE_MAC_BASE) { - rv = onlp_file_read((uint8_t*)buf,ONLP_CONFIG_INFO_STR_MAX, &len,path); - if( rv == ONLP_STATUS_OK ) { - if(sscanf( buf, "%hhx:%hhx:%hhx:%hhx:%hhx:%hhx\n", - &info->mac[0], &info->mac[1], &info->mac[2], - &info->mac[3], &info->mac[4], &info->mac[5]) == 6) { - info->_hdr_length += (TLV_PREFIX_LENGTH+6); - } else { - /*parsing fail*/ - memset(info->mac, 0, 6); - } - } else { - memset(info->mac, 0, 6); - rv = ONLP_STATUS_OK; - } - } else if(type==TLV_CODE_DEVICE_VERSION) { - rv = onlp_file_read((uint8_t*)buf,ONLP_CONFIG_INFO_STR_MAX, &len, path); - if( rv == ONLP_STATUS_OK ) { - info->device_version= (uint8_t)strtoul(buf, NULL, 0); - info->_hdr_length += (TLV_PREFIX_LENGTH+1); - } else { - info->device_version = 0; - rv = ONLP_STATUS_OK; - } - } else if(type==TLV_CODE_MAC_SIZE) { - rv = onlp_file_read((uint8_t*)buf,ONLP_CONFIG_INFO_STR_MAX, &len, path); - if( rv == ONLP_STATUS_OK ) { - info->mac_range = (uint16_t)strtoul(buf, NULL, 0); - info->_hdr_length += (TLV_PREFIX_LENGTH+2); - } else { - info->mac_range = 0; - rv = ONLP_STATUS_OK; - } - } else if(type==TLV_CODE_VENDOR_EXT) { - list_init(&info->vx_list); - /*rv = onlp_file_read((uint8_t*)buf,ONLP_CONFIG_INFO_STR_MAX, &len, path); - if( rv == ONLP_STATUS_OK ) { - //TODO - }*/ - rv = ONLP_STATUS_OK; - } else if(type==TLV_CODE_CRC_32) { - rv = onlp_file_read((uint8_t*)buf,ONLP_CONFIG_INFO_STR_MAX, &len, path); - if( rv == ONLP_STATUS_OK ) { - info->crc = (uint32_t)strtoul(buf, NULL, 0); - info->_hdr_length += (TLV_PREFIX_LENGTH+4); - } else { - info->crc = 0; - rv = ONLP_STATUS_OK; - } - } else if( (type>=TLV_CODE_PRODUCT_NAME) && (type<=TLV_CODE_VENDOR_NAME) ) { - if( type==TLV_CODE_LABEL_REVISION || type==TLV_CODE_MANUF_COUNTRY) { - *(list[index])=malloc(sizeof(char)*ONLP_CONFIG_INFO_STR_MAX); - snprintf(*(list[index]), ONLP_CONFIG_INFO_STR_MAX, "N/A"); - } else { - _case_tlv_code_string(info, list[index], path); - } - } else { - return rv; - } - return rv; -} - - -const char* -onlp_sysi_platform_get(void) -{ - return "x86-64-inventec-d10056-r0"; -} - - -/* - * This function is called to return the physical base address - * of the ONIE boot rom. - * - * The ONLP framework will mmap() and parse the ONIE TLV structure - * from the given data. - * - * If you platform does not support a mappable address for the ONIE - * eeprom then you should not provide this function at all. - * - * For the purposes of this example we will provide it but - * return UNSUPPORTED (which is all the default implementation does). - * - */ -int -onlp_sysi_onie_data_phys_addr_get(void** pa) -{ - return ONLP_STATUS_E_UNSUPPORTED; -} - - -/* - * If you cannot provide a base address you must provide the ONLP - * framework the raw ONIE data through whatever means necessary. - * - * This function will be called as a backup in the event that - * onlp_sysi_onie_data_phys_addr_get() fails. - */ -int -onlp_sysi_onie_data_get(uint8_t** data, int* size) -{ - return ONLP_STATUS_E_UNSUPPORTED; -} - -/* - * IF the ONLP frame calles onlp_sysi_onie_data_get(), - * if will call this function to free the data when it - * is finished with it. - * - * This function is optional, and depends on the data - * you return in onlp_sysi_onie_data_get(). - */ -void -onlp_sysi_onie_data_free(uint8_t* data) -{ - /* - * We returned a static array in onlp_sysi_onie_data_get() - * so no free operation is required. - */ - if(data) { - aim_free(data); - } -} - - -int -onlp_sysi_onie_info_get (onlp_onie_info_t *onie) -{ - int rv = ONLP_STATUS_OK; - int i; - onie->_hdr_length = 0; - for(i = 0; i < SYSI_ONIE_TYPE_SUPPORT_NUM; i++) { - if( rv != ONLP_STATUS_OK ) { - return rv; - } - rv = _parse_tlv(onie, (__tlv_code_list[i]), i); - - } - - onie->_hdr_id_string = aim_fstrdup("TlvInfo"); - onie->_hdr_version = 0x1; - return rv; -} - - -int -onlp_sysi_platform_info_get(onlp_platform_info_t* pi) -{ - int rv = ONLP_STATUS_OK; - char cpld_str[ONLP_CONFIG_INFO_STR_MAX]= {0}; - char other_str[ONLP_CONFIG_INFO_STR_MAX]= {0}; - char version[ONLP_CONFIG_INFO_STR_MAX]; - pi->cpld_versions = NULL; - pi->other_versions = NULL; - - rv = _sysi_version_parsing(INV_SYSLED_PREFIX"info", "The CPLD version is ", version); - if( rv != ONLP_STATUS_OK ) { - return rv; - } - snprintf(cpld_str, ONLP_CONFIG_INFO_STR_MAX, "%s%s ", cpld_str, version); - rv = _sysi_version_parsing(INV_HWMON_PREFIX"version", "ver: ", version); - if( rv != ONLP_STATUS_OK ) { - return rv; - } - snprintf(other_str, ONLP_CONFIG_INFO_STR_MAX, "%s%s.%s " - ,other_str, "psoc", version); - - /*cpld version*/ - if(strlen(cpld_str) > 0) { - pi->cpld_versions = aim_fstrdup("%s",cpld_str); - } - - /*other version*/ - if(strlen(other_str) > 0) { - pi->other_versions = aim_fstrdup("%s",other_str); - } - return rv; -} - -void -onlp_sysi_platform_info_free(onlp_platform_info_t* pi) -{ - if(pi->cpld_versions) { - aim_free(pi->cpld_versions); - } - if(pi->other_versions) { - aim_free(pi->other_versions); - } - return; -} - - -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=0; i - * - * 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) - - -typedef struct thermali_path_s { - char file[ONLP_CONFIG_INFO_STR_MAX]; -} thermali_path_t; - -#define MAKE_THERMAL_PATH_ON_CPU(id) { INV_CTMP_PREFIX"temp"#id"_input"} -#define MAKE_THERMAL_PATH_ON_MAIN_BROAD(id) { INV_HWMON_PREFIX"temp"#id"_input"} -#define MAKE_THERMAL1_PATH_ON_PSU(psu_id) { INV_HWMON_PREFIX"thermal_psu"#psu_id} -#define MAKE_THERMAL2_PATH_ON_PSU(psu_id) { INV_HWMON_PREFIX"thermal2_psu"#psu_id} - -static thermali_path_t __path_list[ ] = { - {}, - MAKE_THERMAL_PATH_ON_CPU(1), - MAKE_THERMAL_PATH_ON_CPU(2), - MAKE_THERMAL_PATH_ON_CPU(3), - MAKE_THERMAL_PATH_ON_CPU(4), - MAKE_THERMAL_PATH_ON_CPU(5), - MAKE_THERMAL_PATH_ON_MAIN_BROAD(1), - MAKE_THERMAL_PATH_ON_MAIN_BROAD(2), - MAKE_THERMAL_PATH_ON_MAIN_BROAD(3), - MAKE_THERMAL_PATH_ON_MAIN_BROAD(4), - MAKE_THERMAL_PATH_ON_MAIN_BROAD(5), - MAKE_THERMAL1_PATH_ON_PSU(1), - MAKE_THERMAL2_PATH_ON_PSU(1), - MAKE_THERMAL1_PATH_ON_PSU(2), - MAKE_THERMAL2_PATH_ON_PSU(2) -}; - -#define MAKE_THERMAL_INFO_NODE_ON_CPU_PHY \ - { { ONLP_THERMAL_ID_CREATE(ONLP_THERMAL_CPU_PHY), "CPU Physical", 0}, \ - ONLP_THERMAL_STATUS_PRESENT, \ - ONLP_THERMAL_CAPS_GET_TEMPERATURE, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS \ - } -#define MAKE_THERMAL_INFO_NODE_ON_CPU_CORE(id) \ - { { ONLP_THERMAL_ID_CREATE(ONLP_THERMAL_CPU_CORE##id), "CPU Core "#id, 0},\ - ONLP_THERMAL_STATUS_PRESENT, \ - ONLP_THERMAL_CAPS_GET_TEMPERATURE, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS \ - } -#define MAKE_THERMAL_INFO_NODE_ON_MAIN_BROAD(id) \ - { { ONLP_THERMAL_ID_CREATE(ONLP_THERMAL_##id##_ON_MAIN_BROAD), "Thermal Sensor "#id, 0}, \ - ONLP_THERMAL_STATUS_PRESENT, \ - ONLP_THERMAL_CAPS_GET_TEMPERATURE, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS \ - } -#define MAKE_THERMAL_INFO_NODE_ON_PSU(thermal_id, psu_id) \ - { { \ - ONLP_THERMAL_ID_CREATE(ONLP_THERMAL_##thermal_id##_ON_PSU##psu_id), \ - "PSU-"#psu_id" Thermal Sensor "#thermal_id, \ - ONLP_PSU_ID_CREATE(ONLP_PSU_##psu_id) \ - }, \ - ONLP_THERMAL_CAPS_GET_TEMPERATURE, 0, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS \ - } - -/* Static values */ -static onlp_thermal_info_t __onlp_thermal_info[ ] = { - {}, - MAKE_THERMAL_INFO_NODE_ON_CPU_PHY, - MAKE_THERMAL_INFO_NODE_ON_CPU_CORE(0), - MAKE_THERMAL_INFO_NODE_ON_CPU_CORE(1), - MAKE_THERMAL_INFO_NODE_ON_CPU_CORE(2), - MAKE_THERMAL_INFO_NODE_ON_CPU_CORE(3), - MAKE_THERMAL_INFO_NODE_ON_MAIN_BROAD(1), - MAKE_THERMAL_INFO_NODE_ON_MAIN_BROAD(2), - MAKE_THERMAL_INFO_NODE_ON_MAIN_BROAD(3), - MAKE_THERMAL_INFO_NODE_ON_MAIN_BROAD(4), - MAKE_THERMAL_INFO_NODE_ON_MAIN_BROAD(5), - MAKE_THERMAL_INFO_NODE_ON_PSU(1,1), - MAKE_THERMAL_INFO_NODE_ON_PSU(2,1), - MAKE_THERMAL_INFO_NODE_ON_PSU(1,2), - MAKE_THERMAL_INFO_NODE_ON_PSU(2,2) -}; - -/* - * 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) -{ - VALIDATE(id); - int ret; - int thermal_id = ONLP_OID_ID_GET(id); - if(thermal_id >= ONLP_THERMAL_MAX) { - return ONLP_STATUS_E_INVALID; - } - - /* Set the onlp_oid_hdr_t and capabilities */ - *info = __onlp_thermal_info[ thermal_id]; - ret = onlp_thermali_status_get(id, &info->status); - if( ret != ONLP_STATUS_OK ) { - return ret; - } - - if(info->status & ONLP_THERMAL_STATUS_PRESENT) { - ret = onlp_file_read_int(&info->mcelsius, __path_list[ thermal_id].file); - } - - return ret; -} - - -/** - * @brief Retrieve the thermal's operational status. - * @param id The thermal oid. - * @param rv [out] Receives the operational status. - */ -int onlp_thermali_status_get(onlp_oid_t id, uint32_t* rv) -{ - int ret = ONLP_STATUS_OK; - onlp_thermal_info_t* info; - VALIDATE(id); - uint32_t psu_status; - - int thermal_id = ONLP_OID_ID_GET(id); - if(thermal_id >= ONLP_THERMAL_MAX) { - return ONLP_STATUS_E_INVALID; - } - info = &__onlp_thermal_info[ thermal_id]; - - switch(thermal_id) { - case ONLP_THERMAL_1_ON_PSU1: - case ONLP_THERMAL_2_ON_PSU1: - case ONLP_THERMAL_1_ON_PSU2: - case ONLP_THERMAL_2_ON_PSU2: - ret = onlp_psui_status_get((&info->hdr)->poid, &psu_status); - if(ret != ONLP_STATUS_OK) { - return ret; - } - info->status = (psu_status & ONLP_PSU_STATUS_PRESENT)? \ - ADD_STATE(info->status,ONLP_PSU_STATUS_PRESENT):0; - break; - default: - break; - } - - *rv = info->status; - - return ret; -} - -/** - * @brief Retrieve the thermal's oid header. - * @param id The thermal oid. - * @param rv [out] Receives the header. - */ -int onlp_thermali_hdr_get(onlp_oid_t id, onlp_oid_hdr_t* rv) -{ - onlp_thermal_info_t* info; - VALIDATE(id); - - int thermal_id = ONLP_OID_ID_GET(id); - if(thermal_id >= ONLP_THERMAL_MAX) { - return ONLP_STATUS_E_INVALID; - } - info = &__onlp_thermal_info[ thermal_id]; - - *rv = info->hdr; - - return ONLP_STATUS_OK; -} diff --git a/packages/platforms/inventec/x86-64/d10056/onlp/builds/x86_64_inventec_d10056/module/src/x86_64_inventec_d10056_config.c b/packages/platforms/inventec/x86-64/d10056/onlp/builds/x86_64_inventec_d10056/module/src/x86_64_inventec_d10056_config.c deleted file mode 100644 index 497829967..000000000 --- a/packages/platforms/inventec/x86-64/d10056/onlp/builds/x86_64_inventec_d10056/module/src/x86_64_inventec_d10056_config.c +++ /dev/null @@ -1,81 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#include - -/* */ -#define __x86_64_inventec_d10056_config_STRINGIFY_NAME(_x) #_x -#define __x86_64_inventec_d10056_config_STRINGIFY_VALUE(_x) __x86_64_inventec_d10056_config_STRINGIFY_NAME(_x) -x86_64_inventec_d10056_config_settings_t x86_64_inventec_d10056_config_settings[] = -{ -#ifdef X86_64_INVENTEC_D10056_CONFIG_INCLUDE_LOGGING - { __x86_64_inventec_d10056_config_STRINGIFY_NAME(X86_64_INVENTEC_D10056_CONFIG_INCLUDE_LOGGING), __x86_64_inventec_d10056_config_STRINGIFY_VALUE(X86_64_INVENTEC_D10056_CONFIG_INCLUDE_LOGGING) }, -#else -{ X86_64_INVENTEC_D10056_CONFIG_INCLUDE_LOGGING(__x86_64_inventec_d10056_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_INVENTEC_D10056_CONFIG_LOG_OPTIONS_DEFAULT - { __x86_64_inventec_d10056_config_STRINGIFY_NAME(X86_64_INVENTEC_D10056_CONFIG_LOG_OPTIONS_DEFAULT), __x86_64_inventec_d10056_config_STRINGIFY_VALUE(X86_64_INVENTEC_D10056_CONFIG_LOG_OPTIONS_DEFAULT) }, -#else -{ X86_64_INVENTEC_D10056_CONFIG_LOG_OPTIONS_DEFAULT(__x86_64_inventec_d10056_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_INVENTEC_D10056_CONFIG_LOG_BITS_DEFAULT - { __x86_64_inventec_d10056_config_STRINGIFY_NAME(X86_64_INVENTEC_D10056_CONFIG_LOG_BITS_DEFAULT), __x86_64_inventec_d10056_config_STRINGIFY_VALUE(X86_64_INVENTEC_D10056_CONFIG_LOG_BITS_DEFAULT) }, -#else -{ X86_64_INVENTEC_D10056_CONFIG_LOG_BITS_DEFAULT(__x86_64_inventec_d10056_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_INVENTEC_D10056_CONFIG_LOG_CUSTOM_BITS_DEFAULT - { __x86_64_inventec_d10056_config_STRINGIFY_NAME(X86_64_INVENTEC_D10056_CONFIG_LOG_CUSTOM_BITS_DEFAULT), __x86_64_inventec_d10056_config_STRINGIFY_VALUE(X86_64_INVENTEC_D10056_CONFIG_LOG_CUSTOM_BITS_DEFAULT) }, -#else -{ X86_64_INVENTEC_D10056_CONFIG_LOG_CUSTOM_BITS_DEFAULT(__x86_64_inventec_d10056_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_INVENTEC_D10056_CONFIG_PORTING_STDLIB - { __x86_64_inventec_d10056_config_STRINGIFY_NAME(X86_64_INVENTEC_D10056_CONFIG_PORTING_STDLIB), __x86_64_inventec_d10056_config_STRINGIFY_VALUE(X86_64_INVENTEC_D10056_CONFIG_PORTING_STDLIB) }, -#else -{ X86_64_INVENTEC_D10056_CONFIG_PORTING_STDLIB(__x86_64_inventec_d10056_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_INVENTEC_D10056_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS - { __x86_64_inventec_d10056_config_STRINGIFY_NAME(X86_64_INVENTEC_D10056_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS), __x86_64_inventec_d10056_config_STRINGIFY_VALUE(X86_64_INVENTEC_D10056_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS) }, -#else -{ X86_64_INVENTEC_D10056_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS(__x86_64_inventec_d10056_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_INVENTEC_D10056_CONFIG_INCLUDE_UCLI - { __x86_64_inventec_d10056_config_STRINGIFY_NAME(X86_64_INVENTEC_D10056_CONFIG_INCLUDE_UCLI), __x86_64_inventec_d10056_config_STRINGIFY_VALUE(X86_64_INVENTEC_D10056_CONFIG_INCLUDE_UCLI) }, -#else -{ X86_64_INVENTEC_D10056_CONFIG_INCLUDE_UCLI(__x86_64_inventec_d10056_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_INVENTEC_D10056_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION - { __x86_64_inventec_d10056_config_STRINGIFY_NAME(X86_64_INVENTEC_D10056_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION), __x86_64_inventec_d10056_config_STRINGIFY_VALUE(X86_64_INVENTEC_D10056_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION) }, -#else -{ X86_64_INVENTEC_D10056_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION(__x86_64_inventec_d10056_config_STRINGIFY_NAME), "__undefined__" }, -#endif - { NULL, NULL } -}; -#undef __x86_64_inventec_d10056_config_STRINGIFY_VALUE -#undef __x86_64_inventec_d10056_config_STRINGIFY_NAME - -const char* -x86_64_inventec_d10056_config_lookup(const char* setting) -{ - int i; - for(i = 0; x86_64_inventec_d10056_config_settings[i].name; i++) { - if(!strcmp(x86_64_inventec_d10056_config_settings[i].name, setting)) { - return x86_64_inventec_d10056_config_settings[i].value; - } - } - return NULL; -} - -int -x86_64_inventec_d10056_config_show(struct aim_pvs_s* pvs) -{ - int i; - for(i = 0; x86_64_inventec_d10056_config_settings[i].name; i++) { - aim_printf(pvs, "%s = %s\n", x86_64_inventec_d10056_config_settings[i].name, x86_64_inventec_d10056_config_settings[i].value); - } - return i; -} - -/* */ - diff --git a/packages/platforms/inventec/x86-64/d10056/onlp/builds/x86_64_inventec_d10056/module/src/x86_64_inventec_d10056_enums.c b/packages/platforms/inventec/x86-64/d10056/onlp/builds/x86_64_inventec_d10056/module/src/x86_64_inventec_d10056_enums.c deleted file mode 100644 index 599eeadd2..000000000 --- a/packages/platforms/inventec/x86-64/d10056/onlp/builds/x86_64_inventec_d10056/module/src/x86_64_inventec_d10056_enums.c +++ /dev/null @@ -1,10 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#include - -/* <--auto.start.enum(ALL).source> */ -/* */ - diff --git a/packages/platforms/inventec/x86-64/d10056/onlp/builds/x86_64_inventec_d10056/module/src/x86_64_inventec_d10056_int.h b/packages/platforms/inventec/x86-64/d10056/onlp/builds/x86_64_inventec_d10056/module/src/x86_64_inventec_d10056_int.h deleted file mode 100644 index b9c5d1646..000000000 --- a/packages/platforms/inventec/x86-64/d10056/onlp/builds/x86_64_inventec_d10056/module/src/x86_64_inventec_d10056_int.h +++ /dev/null @@ -1,12 +0,0 @@ -/**************************************************************************//** - * - * x86_64_inventec_d10056 Internal Header - * - *****************************************************************************/ -#ifndef __x86_64_inventec_d10056_INT_H__ -#define __x86_64_inventec_d10056_INT_H__ - -#include - - -#endif /* __x86_64_inventec_d10056_INT_H__ */ diff --git a/packages/platforms/inventec/x86-64/d10056/onlp/builds/x86_64_inventec_d10056/module/src/x86_64_inventec_d10056_log.c b/packages/platforms/inventec/x86-64/d10056/onlp/builds/x86_64_inventec_d10056/module/src/x86_64_inventec_d10056_log.c deleted file mode 100644 index 9299b3690..000000000 --- a/packages/platforms/inventec/x86-64/d10056/onlp/builds/x86_64_inventec_d10056/module/src/x86_64_inventec_d10056_log.c +++ /dev/null @@ -1,18 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#include - -#include "x86_64_inventec_d10056_log.h" -/* - * x86_64_inventec_d10056 log struct. - */ -AIM_LOG_STRUCT_DEFINE( - X86_64_INVENTEC_D10056_CONFIG_LOG_OPTIONS_DEFAULT, - X86_64_INVENTEC_D10056_CONFIG_LOG_BITS_DEFAULT, - NULL, /* Custom log map */ - X86_64_INVENTEC_D10056_CONFIG_LOG_CUSTOM_BITS_DEFAULT - ); - diff --git a/packages/platforms/inventec/x86-64/d10056/onlp/builds/x86_64_inventec_d10056/module/src/x86_64_inventec_d10056_log.h b/packages/platforms/inventec/x86-64/d10056/onlp/builds/x86_64_inventec_d10056/module/src/x86_64_inventec_d10056_log.h deleted file mode 100644 index 6685d2595..000000000 --- a/packages/platforms/inventec/x86-64/d10056/onlp/builds/x86_64_inventec_d10056/module/src/x86_64_inventec_d10056_log.h +++ /dev/null @@ -1,12 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#ifndef __x86_64_inventec_d10056_LOG_H__ -#define __x86_64_inventec_d10056_LOG_H__ - -#define AIM_LOG_MODULE_NAME x86_64_inventec_d10056 -#include - -#endif /* __x86_64_inventec_d10056_LOG_H__ */ diff --git a/packages/platforms/inventec/x86-64/d10056/onlp/builds/x86_64_inventec_d10056/module/src/x86_64_inventec_d10056_module.c b/packages/platforms/inventec/x86-64/d10056/onlp/builds/x86_64_inventec_d10056/module/src/x86_64_inventec_d10056_module.c deleted file mode 100644 index c1b58b211..000000000 --- a/packages/platforms/inventec/x86-64/d10056/onlp/builds/x86_64_inventec_d10056/module/src/x86_64_inventec_d10056_module.c +++ /dev/null @@ -1,24 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#include - -#include "x86_64_inventec_d10056_log.h" - -static int -datatypes_init__(void) -{ -#define x86_64_inventec_d10056_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_d10056_module_init__(void) -{ - AIM_LOG_STRUCT_REGISTER(); - datatypes_init__(); -} - -int __onlp_platform_version__ = 1; diff --git a/packages/platforms/inventec/x86-64/d10056/onlp/builds/x86_64_inventec_d10056/module/src/x86_64_inventec_d10056_ucli.c b/packages/platforms/inventec/x86-64/d10056/onlp/builds/x86_64_inventec_d10056/module/src/x86_64_inventec_d10056_ucli.c deleted file mode 100644 index 58306a661..000000000 --- a/packages/platforms/inventec/x86-64/d10056/onlp/builds/x86_64_inventec_d10056/module/src/x86_64_inventec_d10056_ucli.c +++ /dev/null @@ -1,50 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#include - -#if X86_64_INVENTEC_D10056_CONFIG_INCLUDE_UCLI == 1 - -#include -#include -#include - -static ucli_status_t -x86_64_inventec_d10056_ucli_ucli__config__(ucli_context_t* uc) -{ - UCLI_HANDLER_MACRO_MODULE_CONFIG(x86_64_inventec_d10056) -} - -/* */ -/* */ - -static ucli_module_t -x86_64_inventec_d10056_ucli_module__ = - { - "x86_64_inventec_d10056_ucli", - NULL, - x86_64_inventec_d10056_ucli_ucli_handlers__, - NULL, - NULL, - }; - -ucli_node_t* -x86_64_inventec_d10056_ucli_node_create(void) -{ - ucli_node_t* n; - ucli_module_init(&x86_64_inventec_d10056_ucli_module__); - n = ucli_node_create("x86_64_inventec_d10056", NULL, &x86_64_inventec_d10056_ucli_module__); - ucli_node_subnode_add(n, ucli_module_log_node_create("x86_64_inventec_d10056")); - return n; -} - -#else -void* -x86_64_inventec_d10056_ucli_node_create(void) -{ - return NULL; -} -#endif - diff --git a/packages/platforms/inventec/x86-64/d10056/platform-config/Makefile b/packages/platforms/inventec/x86-64/d10056/platform-config/Makefile deleted file mode 100644 index 003238cf6..000000000 --- a/packages/platforms/inventec/x86-64/d10056/platform-config/Makefile +++ /dev/null @@ -1 +0,0 @@ -include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/inventec/x86-64/d10056/platform-config/r0/Makefile b/packages/platforms/inventec/x86-64/d10056/platform-config/r0/Makefile deleted file mode 100644 index 003238cf6..000000000 --- a/packages/platforms/inventec/x86-64/d10056/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/inventec/x86-64/d10056/platform-config/r0/PKG.yml b/packages/platforms/inventec/x86-64/d10056/platform-config/r0/PKG.yml deleted file mode 100644 index 8ade2c38e..000000000 --- a/packages/platforms/inventec/x86-64/d10056/platform-config/r0/PKG.yml +++ /dev/null @@ -1 +0,0 @@ -!include $ONL_TEMPLATES/platform-config-platform.yml ARCH=amd64 VENDOR=inventec BASENAME=x86-64-inventec-d10056 REVISION=r0 diff --git a/packages/platforms/inventec/x86-64/d10056/platform-config/r0/src/lib/healthstatus.sh b/packages/platforms/inventec/x86-64/d10056/platform-config/r0/src/lib/healthstatus.sh deleted file mode 100755 index ead2e63b7..000000000 --- a/packages/platforms/inventec/x86-64/d10056/platform-config/r0/src/lib/healthstatus.sh +++ /dev/null @@ -1,97 +0,0 @@ -#!/bin/bash -#follow Gulmohar_HW_Specification_V0.8_20180702 -normal='0 : normal' -unpowered='2 : unpowered' -fault='4 : fault' -notinstalled='7 : not installed' -FAN_UNPLUG_NUM=0 -FAN_LED_RED='fan_led_red' -NUM=1 -FAN_NUM=5 -FIRST_READ=0 -SECOND_READ=0 -CPLD_ADDR='0-0077' -#PSU_STAUS='000' -#switch is ready , transfer control of cpld to cpu -echo 1 > /sys/bus/i2c/devices/i2c-0/$CPLD_ADDR/ctl - -while true -do - -#monitor how many fan modules are unplugged - - -#first check -FAN_UNPLUG_NUM=0 -FAN_ARR=$(cat /sys/class/hwmon/hwmon1/$FAN_LED_RED?) - -while read -r line; do - fan_led_red_check=$(echo "$line") - if [ $fan_led_red_check -eq 1 ] - then - let FAN_UNPLUG_NUM=FAN_UNPLUG_NUM+1 - fi -done <<< "$FAN_ARR" -FIRST_READ=$FAN_UNPLUG_NUM - -#second check -FAN_UNPLUG_NUM=0 -FAN_ARR=$(cat /sys/class/hwmon/hwmon1/$FAN_LED_RED?) - -while read -r line; do - fan_led_red_check=$(echo "$line") - if [ $fan_led_red_check -eq 1 ] - then - let FAN_UNPLUG_NUM=FAN_UNPLUG_NUM+1 - fi -done <<< "$FAN_ARR" -SECOND_READ=$FAN_UNPLUG_NUM - -if [ $FIRST_READ -ne $SECOND_READ ] -then - #echo "not equl:$FIRST_READ != $SECOND_READ" - continue -fi - -if [ $FAN_UNPLUG_NUM -ge 2 ] -then - #echo "solid red" - echo 7 > /sys/bus/i2c/devices/i2c-0/$CPLD_ADDR/red_led - echo 0 > /sys/bus/i2c/devices/i2c-0/$CPLD_ADDR/grn_led - sleep 1 - continue -elif [ $FAN_UNPLUG_NUM -eq 1 ] -then - #solid orange - echo 7 > /sys/bus/i2c/devices/i2c-0/$CPLD_ADDR/red_led - echo 7 > /sys/bus/i2c/devices/i2c-0/$CPLD_ADDR/grn_led - sleep 1 - continue -fi - - #echo "normal" - psu0var=$(cat /sys/bus/i2c/devices/i2c-0/$CPLD_ADDR/psu0) # bottom PSU - psu1var=$(cat /sys/bus/i2c/devices/i2c-0/$CPLD_ADDR/psu1) # top PSU - - if [ "$psu0var" = "$normal" ] && - [ "$psu1var" = "$normal" ] # PSU normal operatio - then - #solid green - echo 7 > /sys/bus/i2c/devices/i2c-0/$CPLD_ADDR/grn_led - echo 0 > /sys/bus/i2c/devices/i2c-0/$CPLD_ADDR/red_led - #echo "solid green" - else - if [ "$psu0var" = "$unpowered" ] || - [ "$psu1var" = "$unpowered" ] - then - #echo solid orange - echo 7 > /sys/bus/i2c/devices/i2c-0/$CPLD_ADDR/grn_led - echo 7 > /sys/bus/i2c/devices/i2c-0/$CPLD_ADDR/red_led - fi - - fi - - -sleep 1 -done - diff --git a/packages/platforms/inventec/x86-64/d10056/platform-config/r0/src/lib/x86-64-inventec-d10056-r0.yml b/packages/platforms/inventec/x86-64/d10056/platform-config/r0/src/lib/x86-64-inventec-d10056-r0.yml deleted file mode 100644 index e5ec59cbf..000000000 --- a/packages/platforms/inventec/x86-64/d10056/platform-config/r0/src/lib/x86-64-inventec-d10056-r0.yml +++ /dev/null @@ -1,31 +0,0 @@ ---- - -###################################################################### -# -# platform-config for d10056 -# -###################################################################### - -x86-64-inventec-d10056-r0: - - grub: - - serial: >- - --port=0x3f8 - --speed=115200 - --word=8 - --parity=no - --stop=1 - - kernel: - <<: *kernel-4-14 - - args: >- - nopat - console=ttyS0,115200n8 - - ##network - ## interfaces: - ## ma1: - ## name: ~ - ## syspath: pci0000:00/0000:00:14.0 diff --git a/packages/platforms/inventec/x86-64/d10056/platform-config/r0/src/python/x86_64_inventec_d10056_r0/__init__.py b/packages/platforms/inventec/x86-64/d10056/platform-config/r0/src/python/x86_64_inventec_d10056_r0/__init__.py deleted file mode 100644 index 51ec68de4..000000000 --- a/packages/platforms/inventec/x86-64/d10056/platform-config/r0/src/python/x86_64_inventec_d10056_r0/__init__.py +++ /dev/null @@ -1,23 +0,0 @@ -from onl.platform.base import * -from onl.platform.inventec import * - -class OnlPlatform_x86_64_inventec_d10056_r0(OnlPlatformInventec, - OnlPlatformPortConfig_48x25_8x100): - PLATFORM='x86-64-inventec-d10056-r0' - MODEL="D10056" - SYS_OBJECT_ID=".10056.1" - - def baseconfig(self): - os.system("insmod /lib/modules/`uname -r`/onl/inventec/x86-64-inventec-d10056/gpio-ich.ko") - #self.insmod('gpio-ich.ko') - self.insmod('i2c-gpio') - self.insmod('inv_platform') - self.insmod('inv_psoc') - os.system("echo inv_cpld 0x77 > /sys/bus/i2c/devices/i2c-0/new_device") - self.insmod('inv_cpld') - self.insmod('swps') - self.insmod('vpd') - os.system("/lib/platform-config/x86-64-inventec-d10056-r0/onl/healthstatus.sh &") - - return True - diff --git a/packages/platforms/inventec/x86-64/d10064/.gitignore b/packages/platforms/inventec/x86-64/d10064/.gitignore deleted file mode 100644 index 212475c82..000000000 --- a/packages/platforms/inventec/x86-64/d10064/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -*x86*64*inventec*d10064*.mk -onlpdump.mk diff --git a/packages/platforms/inventec/x86-64/d10064/Makefile b/packages/platforms/inventec/x86-64/d10064/Makefile deleted file mode 100644 index 003238cf6..000000000 --- a/packages/platforms/inventec/x86-64/d10064/Makefile +++ /dev/null @@ -1 +0,0 @@ -include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/inventec/x86-64/d10064/modules/Makefile b/packages/platforms/inventec/x86-64/d10064/modules/Makefile deleted file mode 100644 index 003238cf6..000000000 --- a/packages/platforms/inventec/x86-64/d10064/modules/Makefile +++ /dev/null @@ -1 +0,0 @@ -include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/inventec/x86-64/d10064/modules/PKG.yml b/packages/platforms/inventec/x86-64/d10064/modules/PKG.yml deleted file mode 100644 index 71cf4d960..000000000 --- a/packages/platforms/inventec/x86-64/d10064/modules/PKG.yml +++ /dev/null @@ -1 +0,0 @@ -!include $ONL_TEMPLATES/platform-modules.yml VENDOR=inventec BASENAME=x86-64-inventec-d10064 ARCH=amd64 KERNELS="onl-kernel-4.14-lts-x86-64-all:amd64" diff --git a/packages/platforms/inventec/x86-64/d10064/modules/builds/.gitignore b/packages/platforms/inventec/x86-64/d10064/modules/builds/.gitignore deleted file mode 100644 index c3af85790..000000000 --- a/packages/platforms/inventec/x86-64/d10064/modules/builds/.gitignore +++ /dev/null @@ -1 +0,0 @@ -lib/ diff --git a/packages/platforms/inventec/x86-64/d10064/modules/builds/Makefile b/packages/platforms/inventec/x86-64/d10064/modules/builds/Makefile deleted file mode 100644 index c94f3975a..000000000 --- a/packages/platforms/inventec/x86-64/d10064/modules/builds/Makefile +++ /dev/null @@ -1,6 +0,0 @@ -KERNELS := onl-kernel-4.14-lts-x86-64-all:amd64 -KMODULES := src -VENDOR := inventec -BASENAME := x86-64-inventec-d10064 -ARCH := x86_64 -include $(ONL)/make/kmodule.mk diff --git a/packages/platforms/inventec/x86-64/d10064/modules/builds/src b/packages/platforms/inventec/x86-64/d10064/modules/builds/src deleted file mode 120000 index 43ee7eae4..000000000 --- a/packages/platforms/inventec/x86-64/d10064/modules/builds/src +++ /dev/null @@ -1 +0,0 @@ -../../../d5264q28b/modules/builds/src \ No newline at end of file diff --git a/packages/platforms/inventec/x86-64/d10064/onlp/Makefile b/packages/platforms/inventec/x86-64/d10064/onlp/Makefile deleted file mode 100644 index dc1e7b86f..000000000 --- a/packages/platforms/inventec/x86-64/d10064/onlp/Makefile +++ /dev/null @@ -1 +0,0 @@ -include $(ONL)/make/pkg.mk diff --git a/packages/platforms/inventec/x86-64/d10064/onlp/PKG.yml b/packages/platforms/inventec/x86-64/d10064/onlp/PKG.yml deleted file mode 100644 index df0e98bc0..000000000 --- a/packages/platforms/inventec/x86-64/d10064/onlp/PKG.yml +++ /dev/null @@ -1 +0,0 @@ -!include $ONL_TEMPLATES/onlp-platform-any.yml PLATFORM=x86-64-inventec-d10064 ARCH=amd64 TOOLCHAIN=x86_64-linux-gnu diff --git a/packages/platforms/inventec/x86-64/d10064/onlp/builds/Makefile b/packages/platforms/inventec/x86-64/d10064/onlp/builds/Makefile deleted file mode 100644 index e7437cb23..000000000 --- a/packages/platforms/inventec/x86-64/d10064/onlp/builds/Makefile +++ /dev/null @@ -1,2 +0,0 @@ -FILTER=src -include $(ONL)/make/subdirs.mk diff --git a/packages/platforms/inventec/x86-64/d10064/onlp/builds/lib/Makefile b/packages/platforms/inventec/x86-64/d10064/onlp/builds/lib/Makefile deleted file mode 100644 index 882956ebd..000000000 --- a/packages/platforms/inventec/x86-64/d10064/onlp/builds/lib/Makefile +++ /dev/null @@ -1,2 +0,0 @@ -PLATFORM := x86-64-inventec-d10064 -include $(ONL)/packages/base/any/onlp/builds/platform/libonlp-platform.mk diff --git a/packages/platforms/inventec/x86-64/d10064/onlp/builds/onlpdump/Makefile b/packages/platforms/inventec/x86-64/d10064/onlp/builds/onlpdump/Makefile deleted file mode 100644 index f85f66984..000000000 --- a/packages/platforms/inventec/x86-64/d10064/onlp/builds/onlpdump/Makefile +++ /dev/null @@ -1,2 +0,0 @@ -PLATFORM := x86-64-inventec-d10064 -include $(ONL)/packages/base/any/onlp/builds/platform/onlps.mk diff --git a/packages/platforms/inventec/x86-64/d10064/onlp/builds/x86_64_inventec_d10064/.module b/packages/platforms/inventec/x86-64/d10064/onlp/builds/x86_64_inventec_d10064/.module deleted file mode 100644 index 2103b3d9c..000000000 --- a/packages/platforms/inventec/x86-64/d10064/onlp/builds/x86_64_inventec_d10064/.module +++ /dev/null @@ -1 +0,0 @@ -name: x86_64_inventec_d10064 diff --git a/packages/platforms/inventec/x86-64/d10064/onlp/builds/x86_64_inventec_d10064/Makefile b/packages/platforms/inventec/x86-64/d10064/onlp/builds/x86_64_inventec_d10064/Makefile deleted file mode 100644 index f6c464d44..000000000 --- a/packages/platforms/inventec/x86-64/d10064/onlp/builds/x86_64_inventec_d10064/Makefile +++ /dev/null @@ -1,9 +0,0 @@ -############################################################################### -# -# -# -############################################################################### -include $(ONL)/make/config.mk -MODULE := x86_64_inventec_d10064 -AUTOMODULE := x86_64_inventec_d10064 -include $(BUILDER)/definemodule.mk diff --git a/packages/platforms/inventec/x86-64/d10064/onlp/builds/x86_64_inventec_d10064/module/auto/make.mk b/packages/platforms/inventec/x86-64/d10064/onlp/builds/x86_64_inventec_d10064/module/auto/make.mk deleted file mode 100644 index f2f7d3d96..000000000 --- a/packages/platforms/inventec/x86-64/d10064/onlp/builds/x86_64_inventec_d10064/module/auto/make.mk +++ /dev/null @@ -1,9 +0,0 @@ -############################################################################### -# -# x86_64_inventec_d10064 Autogeneration -# -############################################################################### -x86_64_inventec_d10064_AUTO_DEFS := module/auto/x86_64_inventec_d10064.yml -x86_64_inventec_d10064_AUTO_DIRS := module/inc/x86_64_inventec_d10064 module/src -include $(BUILDER)/auto.mk - diff --git a/packages/platforms/inventec/x86-64/d10064/onlp/builds/x86_64_inventec_d10064/module/auto/x86_64_inventec_d10064.yml b/packages/platforms/inventec/x86-64/d10064/onlp/builds/x86_64_inventec_d10064/module/auto/x86_64_inventec_d10064.yml deleted file mode 100644 index fee9c9393..000000000 --- a/packages/platforms/inventec/x86-64/d10064/onlp/builds/x86_64_inventec_d10064/module/auto/x86_64_inventec_d10064.yml +++ /dev/null @@ -1,50 +0,0 @@ -############################################################################### -# -# x86_64_inventec_d10064 Autogeneration Definitions. -# -############################################################################### - -cdefs: &cdefs -- X86_64_INVENTEC_D10064_CONFIG_INCLUDE_LOGGING: - doc: "Include or exclude logging." - default: 1 -- X86_64_INVENTEC_D10064_CONFIG_LOG_OPTIONS_DEFAULT: - doc: "Default enabled log options." - default: AIM_LOG_OPTIONS_DEFAULT -- X86_64_INVENTEC_D10064_CONFIG_LOG_BITS_DEFAULT: - doc: "Default enabled log bits." - default: AIM_LOG_BITS_DEFAULT -- X86_64_INVENTEC_D10064_CONFIG_LOG_CUSTOM_BITS_DEFAULT: - doc: "Default enabled custom log bits." - default: 0 -- X86_64_INVENTEC_D10064_CONFIG_PORTING_STDLIB: - doc: "Default all porting macros to use the C standard libraries." - default: 1 -- X86_64_INVENTEC_D10064_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS: - doc: "Include standard library headers for stdlib porting macros." - default: X86_64_INVENTEC_D10064_CONFIG_PORTING_STDLIB -- X86_64_INVENTEC_D10064_CONFIG_INCLUDE_UCLI: - doc: "Include generic uCli support." - default: 0 -- X86_64_INVENTEC_D10064_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_D10064_CONFIG_HEADER: - defs: *cdefs - basename: x86_64_inventec_d10064_config - - portingmacro: - x86_64_inventec_d10064: - macros: - - malloc - - free - - memset - - memcpy - - - vsnprintf - - snprintf - - strlen diff --git a/packages/platforms/inventec/x86-64/d10064/onlp/builds/x86_64_inventec_d10064/module/inc/x86_64_inventec_d10064/x86_64_inventec_d10064.x b/packages/platforms/inventec/x86-64/d10064/onlp/builds/x86_64_inventec_d10064/module/inc/x86_64_inventec_d10064/x86_64_inventec_d10064.x deleted file mode 100644 index 33ee570e9..000000000 --- a/packages/platforms/inventec/x86-64/d10064/onlp/builds/x86_64_inventec_d10064/module/inc/x86_64_inventec_d10064/x86_64_inventec_d10064.x +++ /dev/null @@ -1,14 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#include - -/* <--auto.start.xmacro(ALL).define> */ -/* */ - -/* <--auto.start.xenum(ALL).define> */ -/* */ - - diff --git a/packages/platforms/inventec/x86-64/d10064/onlp/builds/x86_64_inventec_d10064/module/inc/x86_64_inventec_d10064/x86_64_inventec_d10064_config.h b/packages/platforms/inventec/x86-64/d10064/onlp/builds/x86_64_inventec_d10064/module/inc/x86_64_inventec_d10064/x86_64_inventec_d10064_config.h deleted file mode 100644 index 565e3b2f3..000000000 --- a/packages/platforms/inventec/x86-64/d10064/onlp/builds/x86_64_inventec_d10064/module/inc/x86_64_inventec_d10064/x86_64_inventec_d10064_config.h +++ /dev/null @@ -1,137 +0,0 @@ -/**************************************************************************//** - * - * @file - * @brief x86_64_inventec_d10064 Configuration Header - * - * @addtogroup x86_64_inventec_d10064-config - * @{ - * - *****************************************************************************/ -#ifndef __X86_64_INVENTEC_D10064_CONFIG_H__ -#define __X86_64_INVENTEC_D10064_CONFIG_H__ - -#ifdef GLOBAL_INCLUDE_CUSTOM_CONFIG -#include -#endif -#ifdef x86_64_inventec_d10064_INCLUDE_CUSTOM_CONFIG -#include -#endif - -/* */ -#include -/** - * X86_64_INVENTEC_D10064_CONFIG_INCLUDE_LOGGING - * - * Include or exclude logging. */ - - -#ifndef X86_64_INVENTEC_D10064_CONFIG_INCLUDE_LOGGING -#define X86_64_INVENTEC_D10064_CONFIG_INCLUDE_LOGGING 1 -#endif - -/** - * X86_64_INVENTEC_D10064_CONFIG_LOG_OPTIONS_DEFAULT - * - * Default enabled log options. */ - - -#ifndef X86_64_INVENTEC_D10064_CONFIG_LOG_OPTIONS_DEFAULT -#define X86_64_INVENTEC_D10064_CONFIG_LOG_OPTIONS_DEFAULT AIM_LOG_OPTIONS_DEFAULT -#endif - -/** - * X86_64_INVENTEC_D10064_CONFIG_LOG_BITS_DEFAULT - * - * Default enabled log bits. */ - - -#ifndef X86_64_INVENTEC_D10064_CONFIG_LOG_BITS_DEFAULT -#define X86_64_INVENTEC_D10064_CONFIG_LOG_BITS_DEFAULT AIM_LOG_BITS_DEFAULT -#endif - -/** - * X86_64_INVENTEC_D10064_CONFIG_LOG_CUSTOM_BITS_DEFAULT - * - * Default enabled custom log bits. */ - - -#ifndef X86_64_INVENTEC_D10064_CONFIG_LOG_CUSTOM_BITS_DEFAULT -#define X86_64_INVENTEC_D10064_CONFIG_LOG_CUSTOM_BITS_DEFAULT 0 -#endif - -/** - * X86_64_INVENTEC_D10064_CONFIG_PORTING_STDLIB - * - * Default all porting macros to use the C standard libraries. */ - - -#ifndef X86_64_INVENTEC_D10064_CONFIG_PORTING_STDLIB -#define X86_64_INVENTEC_D10064_CONFIG_PORTING_STDLIB 1 -#endif - -/** - * X86_64_INVENTEC_D10064_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS - * - * Include standard library headers for stdlib porting macros. */ - - -#ifndef X86_64_INVENTEC_D10064_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS -#define X86_64_INVENTEC_D10064_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS X86_64_INVENTEC_D10064_CONFIG_PORTING_STDLIB -#endif - -/** - * X86_64_INVENTEC_D10064_CONFIG_INCLUDE_UCLI - * - * Include generic uCli support. */ - - -#ifndef X86_64_INVENTEC_D10064_CONFIG_INCLUDE_UCLI -#define X86_64_INVENTEC_D10064_CONFIG_INCLUDE_UCLI 0 -#endif - -/** - * X86_64_INVENTEC_D10064_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION - * - * Assume chassis fan direction is the same as the PSU fan direction. */ - - -#ifndef X86_64_INVENTEC_D10064_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION -#define X86_64_INVENTEC_D10064_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION 0 -#endif - - - -/** - * All compile time options can be queried or displayed - */ - -/** Configuration settings structure. */ -typedef struct x86_64_inventec_d10064_config_settings_s { - /** name */ - const char* name; - /** value */ - const char* value; -} x86_64_inventec_d10064_config_settings_t; - -/** Configuration settings table. */ -/** x86_64_inventec_d10064_config_settings table. */ -extern x86_64_inventec_d10064_config_settings_t x86_64_inventec_d10064_config_settings[]; - -/** - * @brief Lookup a configuration setting. - * @param setting The name of the configuration option to lookup. - */ -const char* x86_64_inventec_d10064_config_lookup(const char* setting); - -/** - * @brief Show the compile-time configuration. - * @param pvs The output stream. - */ -int x86_64_inventec_d10064_config_show(struct aim_pvs_s* pvs); - -/* */ - -#include "x86_64_inventec_d10064_porting.h" - -#endif /* __X86_64_INVENTEC_D10064_CONFIG_H__ */ -/* @} */ diff --git a/packages/platforms/inventec/x86-64/d10064/onlp/builds/x86_64_inventec_d10064/module/inc/x86_64_inventec_d10064/x86_64_inventec_d10064_dox.h b/packages/platforms/inventec/x86-64/d10064/onlp/builds/x86_64_inventec_d10064/module/inc/x86_64_inventec_d10064/x86_64_inventec_d10064_dox.h deleted file mode 100644 index f70e7aaee..000000000 --- a/packages/platforms/inventec/x86-64/d10064/onlp/builds/x86_64_inventec_d10064/module/inc/x86_64_inventec_d10064/x86_64_inventec_d10064_dox.h +++ /dev/null @@ -1,26 +0,0 @@ -/**************************************************************************//** - * - * x86_64_inventec_d10064 Doxygen Header - * - *****************************************************************************/ -#ifndef __x86_64_inventec_d10064_DOX_H__ -#define __x86_64_inventec_d10064_DOX_H__ - -/** - * @defgroup x86_64_inventec_d10064 x86_64_inventec_d10064 - x86_64_inventec_d10064 Description - * - -The documentation overview for this module should go here. - - * - * @{ - * - * @defgroup x86_64_inventec_d10064-x86_64_inventec_d10064 Public Interface - * @defgroup x86_64_inventec_d10064-config Compile Time Configuration - * @defgroup x86_64_inventec_d10064-porting Porting Macros - * - * @} - * - */ - -#endif /* __x86_64_inventec_d10064_DOX_H__ */ diff --git a/packages/platforms/inventec/x86-64/d10064/onlp/builds/x86_64_inventec_d10064/module/inc/x86_64_inventec_d10064/x86_64_inventec_d10064_porting.h b/packages/platforms/inventec/x86-64/d10064/onlp/builds/x86_64_inventec_d10064/module/inc/x86_64_inventec_d10064/x86_64_inventec_d10064_porting.h deleted file mode 100644 index 19fdb009f..000000000 --- a/packages/platforms/inventec/x86-64/d10064/onlp/builds/x86_64_inventec_d10064/module/inc/x86_64_inventec_d10064/x86_64_inventec_d10064_porting.h +++ /dev/null @@ -1,97 +0,0 @@ -/**************************************************************************//** - * - * @file - * @brief x86_64_inventec_d10064 Porting Macros. - * - * @addtogroup x86_64_inventec_d10064-porting - * @{ - * - *****************************************************************************/ -#ifndef __x86_64_inventec_d10064_PORTING_H__ -#define __x86_64_inventec_d10064_PORTING_H__ - - -/* */ -#if X86_64_INVENTEC_D10064_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS == 1 -#include -#include -#include -#include -#include -#endif - -#ifndef X86_64_INVENTEC_D10064_MALLOC - #if defined(GLOBAL_MALLOC) - #define X86_64_INVENTEC_D10064_MALLOC GLOBAL_MALLOC - #elif X86_64_INVENTEC_D10064_CONFIG_PORTING_STDLIB == 1 - #define X86_64_INVENTEC_D10064_MALLOC malloc - #else - #error The macro X86_64_INVENTEC_D10064_MALLOC is required but cannot be defined. - #endif -#endif - -#ifndef X86_64_INVENTEC_D10064_FREE - #if defined(GLOBAL_FREE) - #define X86_64_INVENTEC_D10064_FREE GLOBAL_FREE - #elif X86_64_INVENTEC_D10064_CONFIG_PORTING_STDLIB == 1 - #define X86_64_INVENTEC_D10064_FREE free - #else - #error The macro X86_64_INVENTEC_D10064_FREE is required but cannot be defined. - #endif -#endif - -#ifndef X86_64_INVENTEC_D10064_MEMSET - #if defined(GLOBAL_MEMSET) - #define X86_64_INVENTEC_D10064_MEMSET GLOBAL_MEMSET - #elif X86_64_INVENTEC_D10064_CONFIG_PORTING_STDLIB == 1 - #define X86_64_INVENTEC_D10064_MEMSET memset - #else - #error The macro X86_64_INVENTEC_D10064_MEMSET is required but cannot be defined. - #endif -#endif - -#ifndef X86_64_INVENTEC_D10064_MEMCPY - #if defined(GLOBAL_MEMCPY) - #define X86_64_INVENTEC_D10064_MEMCPY GLOBAL_MEMCPY - #elif X86_64_INVENTEC_D10064_CONFIG_PORTING_STDLIB == 1 - #define X86_64_INVENTEC_D10064_MEMCPY memcpy - #else - #error The macro X86_64_INVENTEC_D10064_MEMCPY is required but cannot be defined. - #endif -#endif - -#ifndef X86_64_INVENTEC_D10064_VSNPRINTF - #if defined(GLOBAL_VSNPRINTF) - #define X86_64_INVENTEC_D10064_VSNPRINTF GLOBAL_VSNPRINTF - #elif X86_64_INVENTEC_D10064_CONFIG_PORTING_STDLIB == 1 - #define X86_64_INVENTEC_D10064_VSNPRINTF vsnprintf - #else - #error The macro X86_64_INVENTEC_D10064_VSNPRINTF is required but cannot be defined. - #endif -#endif - -#ifndef X86_64_INVENTEC_D10064_SNPRINTF - #if defined(GLOBAL_SNPRINTF) - #define X86_64_INVENTEC_D10064_SNPRINTF GLOBAL_SNPRINTF - #elif X86_64_INVENTEC_D10064_CONFIG_PORTING_STDLIB == 1 - #define X86_64_INVENTEC_D10064_SNPRINTF snprintf - #else - #error The macro X86_64_INVENTEC_D10064_SNPRINTF is required but cannot be defined. - #endif -#endif - -#ifndef X86_64_INVENTEC_D10064_STRLEN - #if defined(GLOBAL_STRLEN) - #define X86_64_INVENTEC_D10064_STRLEN GLOBAL_STRLEN - #elif X86_64_INVENTEC_D10064_CONFIG_PORTING_STDLIB == 1 - #define X86_64_INVENTEC_D10064_STRLEN strlen - #else - #error The macro X86_64_INVENTEC_D10064_STRLEN is required but cannot be defined. - #endif -#endif - -/* */ - - -#endif /* __x86_64_inventec_d10064_PORTING_H__ */ -/* @} */ diff --git a/packages/platforms/inventec/x86-64/d10064/onlp/builds/x86_64_inventec_d10064/module/make.mk b/packages/platforms/inventec/x86-64/d10064/onlp/builds/x86_64_inventec_d10064/module/make.mk deleted file mode 100644 index aab78afa0..000000000 --- a/packages/platforms/inventec/x86-64/d10064/onlp/builds/x86_64_inventec_d10064/module/make.mk +++ /dev/null @@ -1,10 +0,0 @@ -############################################################################### -# -# -# -############################################################################### -THIS_DIR := $(dir $(lastword $(MAKEFILE_LIST))) -x86_64_inventec_d10064_INCLUDES := -I $(THIS_DIR)inc -x86_64_inventec_d10064_INTERNAL_INCLUDES := -I $(THIS_DIR)src -x86_64_inventec_d10064_DEPENDMODULE_ENTRIES := init:x86_64_inventec_d10064 ucli:x86_64_inventec_d10064 -x86_64_inventec_d10064_CFLAGS := -Wno-restrict -Wno-format-truncation diff --git a/packages/platforms/inventec/x86-64/d10064/onlp/builds/x86_64_inventec_d10064/module/src/Makefile b/packages/platforms/inventec/x86-64/d10064/onlp/builds/x86_64_inventec_d10064/module/src/Makefile deleted file mode 100644 index 2809ae48a..000000000 --- a/packages/platforms/inventec/x86-64/d10064/onlp/builds/x86_64_inventec_d10064/module/src/Makefile +++ /dev/null @@ -1,9 +0,0 @@ -############################################################################### -# -# Local source generation targets. -# -############################################################################### - -ucli: - @../../../../tools/uclihandlers.py x86_64_inventec_d10064_ucli.c - diff --git a/packages/platforms/inventec/x86-64/d10064/onlp/builds/x86_64_inventec_d10064/module/src/debug.c b/packages/platforms/inventec/x86-64/d10064/onlp/builds/x86_64_inventec_d10064/module/src/debug.c deleted file mode 100644 index 86a17ea8d..000000000 --- a/packages/platforms/inventec/x86-64/d10064/onlp/builds/x86_64_inventec_d10064/module/src/debug.c +++ /dev/null @@ -1,45 +0,0 @@ -#include "x86_64_inventec_d10064_int.h" - -#if X86_64_INVENTEC_D10064_CONFIG_INCLUDE_DEBUG == 1 - -#include - -static char help__[] = - "Usage: debug [options]\n" - " -c CPLD Versions\n" - " -h Help\n" - ; - -int -x86_64_inventec_d10064_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/d10064/onlp/builds/x86_64_inventec_d10064/module/src/fani.c b/packages/platforms/inventec/x86-64/d10064/onlp/builds/x86_64_inventec_d10064/module/src/fani.c deleted file mode 100644 index bc6a0bbd2..000000000 --- a/packages/platforms/inventec/x86-64/d10064/onlp/builds/x86_64_inventec_d10064/module/src/fani.c +++ /dev/null @@ -1,398 +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 -#include -#include -#include -#include "platform_lib.h" - -#define VALIDATE(_id) \ - do { \ - if(!ONLP_OID_IS_FAN(_id)) { \ - return ONLP_STATUS_E_INVALID; \ - } \ - } while(0) - - -#define SLOW_PWM 100 -#define NORMAL_PWM 175 -#define MAX_PWM 255 -#define STEP_SIZE 100 -#define FAN_ON_MAIN_BOARD_COUNT 4 -#define LOCAL_ID_TO_PSU_ID(id) (id-FAN_ON_MAIN_BOARD_COUNT) - -#define FAN_CAPS ONLP_FAN_CAPS_GET_RPM|ONLP_FAN_CAPS_GET_PERCENTAGE - -static int _fani_status_failed_check(uint32_t* status, int local_id); -static int _fani_status_present_check(uint32_t* status, int local_id); - -#define MAKE_FAN_INFO_NODE_ON_FAN_BOARD(id) \ - { \ - { \ - ONLP_FAN_ID_CREATE(ONLP_FAN_##id), "Fan "#id, 0, \ - { \ - ONLP_LED_ID_CREATE(ONLP_LED_FAN##id), \ - } \ - }, \ - 0, 0 \ - } - -#define MAKE_FAN_INFO_NODE_ON_PSU(psu_id) \ - { \ - { ONLP_FAN_ID_CREATE(ONLP_FAN_PSU_##psu_id), "PSU-"#psu_id" Fan", ONLP_PSU_ID_CREATE(ONLP_PSU_##psu_id)}, \ - 0, 0 \ - } - - -/* Static values */ -static onlp_fan_info_t __onlp_fan_info[ONLP_FAN_COUNT] = { - 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_PSU(1), - MAKE_FAN_INFO_NODE_ON_PSU(2), -}; - - -/* - * 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 rv = ONLP_STATUS_OK; - int local_id; - int lrpm, rrpm, pwm, psu_id; - VALIDATE(id); - pwm = 0; - - local_id = ONLP_OID_ID_GET(id); - if(local_id >= ONLP_FAN_MAX) { - rv = ONLP_STATUS_E_INVALID; - } - if(rv ==ONLP_STATUS_OK) { - *info = __onlp_fan_info[LOCAL_ID_TO_INFO_IDX(local_id)]; - rv = onlp_fani_status_get(id, &info->status); - } - - if(rv == ONLP_STATUS_OK) { - if(info->status & ONLP_FAN_STATUS_PRESENT){ - switch(local_id){ - case ONLP_FAN_1: - case ONLP_FAN_2: - case ONLP_FAN_3: - case ONLP_FAN_4: - if(info->status & ONLP_FAN_STATUS_F2B){ - info->caps = FAN_CAPS|ONLP_FAN_CAPS_F2B; - }else if(info->status & ONLP_FAN_STATUS_B2F){ - info->caps = FAN_CAPS|ONLP_FAN_CAPS_B2F; - }else{ - info->caps = FAN_CAPS; - } - - rv = onlp_file_read_int(&lrpm, INV_HWMON_PREFIX"fan%d_input", local_id*2-1); - if(rv != ONLP_STATUS_OK ){ return rv; } - rv = onlp_file_read_int(&rrpm, INV_HWMON_PREFIX"fan%d_input", local_id*2); - if(rv != ONLP_STATUS_OK ){ return rv; } - rv = onlp_file_read_int(&pwm,INV_HWMON_PREFIX"pwm%d", local_id); - if(rv != ONLP_STATUS_OK ){ return rv; } - - if(lrpm <=0 && rrpm <=0){ - info->rpm = 0; - }else if(lrpm <= 0){ - info->rpm = rrpm; - }else if(rrpm <= 0){ - info->rpm = lrpm; - }else{ - info->rpm = (lrpm+rrpm)/2; - } - - break; - case ONLP_FAN_PSU_1: - case ONLP_FAN_PSU_2: - info->caps = FAN_CAPS|ONLP_FAN_CAPS_F2B; - psu_id = LOCAL_ID_TO_PSU_ID(local_id); - rv = onlp_file_read_int(&info->rpm,INV_HWMON_PREFIX"rpm_psu%d", psu_id); - if(rv != ONLP_STATUS_OK) { return rv; } - rv = onlp_file_read_int(&pwm, INV_HWMON_PREFIX"pwm_psu%d", psu_id); - if(rv != ONLP_STATUS_OK) { return rv; } - break; - default: - rv = ONLP_STATUS_E_INVALID; - break; - } - if(rv == ONLP_STATUS_OK) { - if(info->rpm <= 0) { - info->mode = ONLP_FAN_MODE_OFF; - info->percentage = 0; - } else { - info->percentage = (pwm*100)/MAX_PWM; - if(pwm < SLOW_PWM) { - info->mode = ONLP_FAN_MODE_SLOW; - } else if(pwm < NORMAL_PWM) { - info->mode = ONLP_FAN_MODE_NORMAL; - } else if(pwm < MAX_PWM) { - info->mode = ONLP_FAN_MODE_FAST; - } else { - info->mode = ONLP_FAN_MODE_MAX; - } - } - } - }else{ - info->caps = 0; - info->rpm = 0; - info->percentage = 0; - info->mode = ONLP_FAN_MODE_OFF; - } - snprintf(info->model, ONLP_CONFIG_INFO_STR_MAX, "NA"); - snprintf(info->serial, ONLP_CONFIG_INFO_STR_MAX, "NA"); - } - return rv; -} -static int _fani_status_failed_check(uint32_t* status, int local_id) -{ - int rv; - int lrpm, rrpm, rpm, pwm, psu_id; - switch(local_id){ - case ONLP_FAN_1: - case ONLP_FAN_2: - case ONLP_FAN_3: - case ONLP_FAN_4: - rv = onlp_file_read_int(&lrpm, INV_HWMON_PREFIX"fan%d_input", local_id*2-1); - if(rv != ONLP_STATUS_OK ){ return rv; } - rv = onlp_file_read_int(&rrpm, INV_HWMON_PREFIX"fan%d_input", local_id*2); - if(rv != ONLP_STATUS_OK ){ return rv; } - rv = onlp_file_read_int(&pwm,INV_HWMON_PREFIX"pwm%d", local_id); - if(rv != ONLP_STATUS_OK ){ return rv; } - - if( lrpm <= 0 || rrpm <=0 || pwm <=0 || pwm > MAX_PWM){ - *status |= ONLP_FAN_STATUS_FAILED; - *status &= (~ONLP_FAN_STATUS_B2F); - *status &= (~ONLP_FAN_STATUS_F2B); - }else{ - *status &= (~ONLP_FAN_STATUS_FAILED); - } - break; - case ONLP_FAN_PSU_1: - case ONLP_FAN_PSU_2: - psu_id = LOCAL_ID_TO_PSU_ID(local_id); - rv = onlp_file_read_int(&rpm, INV_HWMON_PREFIX"rpm_psu%d", psu_id); - if(rv != ONLP_STATUS_OK ){ return rv; } - rv = onlp_file_read_int(&pwm, INV_HWMON_PREFIX"pwm_psu%d", psu_id); - if(rv != ONLP_STATUS_OK ){ return rv; } - - if( rpm <= 0 || pwm <=0 || pwm > MAX_PWM){ - *status |= ONLP_FAN_STATUS_FAILED; - *status &= (~ONLP_FAN_STATUS_B2F); - *status &= (~ONLP_FAN_STATUS_F2B); - }else{ - *status &= (~ONLP_FAN_STATUS_FAILED); - } - break; - default: - rv = ONLP_STATUS_E_INVALID; - break; - } - return rv; -} - -static int _fani_status_present_check(uint32_t* status, int local_id) -{ - int rv; - int gpi; - int info_idx; - int len; - char buf[ONLP_CONFIG_INFO_STR_MAX]; - info_idx = LOCAL_ID_TO_INFO_IDX(local_id); - rv = onlp_file_read((uint8_t*)buf,ONLP_CONFIG_INFO_STR_MAX, &len, INV_HWMON_PREFIX"fan_gpi"); - if( rv == ONLP_STATUS_OK ){ - sscanf( buf, "0x%x\n", &gpi); - /* B[0-3] installed(0)/uninstalled(1) - B[4-7] FRtype(0)/RFtype(1) */ - if (!((gpi>>info_idx) & 1)){ - *status |= ONLP_FAN_STATUS_PRESENT; - if (!((gpi>>(info_idx+4)) & 1)){ - *status |= ONLP_FAN_STATUS_F2B; - }else{ - *status |= ONLP_FAN_STATUS_B2F; - } - } else { - *status = 0; - } - } - return rv; -} - - -/** - * @brief Retrieve the fan's operational status. - * @param id The fan OID. - * @param rv [out] Receives the fan's operations status flags. - * @notes Only operational state needs to be returned - - * PRESENT/FAILED - */ -int onlp_fani_status_get(onlp_oid_t id, uint32_t* rv) -{ - int result = ONLP_STATUS_OK; - onlp_fan_info_t* info; - int local_id; - VALIDATE(id); - uint32_t psu_status; - - local_id = ONLP_OID_ID_GET(id); - if(local_id >= ONLP_FAN_MAX) { - result = ONLP_STATUS_E_INVALID; - } else { - info = &__onlp_fan_info[LOCAL_ID_TO_INFO_IDX(local_id)]; - switch(local_id){ - case ONLP_FAN_1: - case ONLP_FAN_2: - case ONLP_FAN_3: - case ONLP_FAN_4: - result = _fani_status_present_check(&info->status, local_id); - if (result == ONLP_STATUS_OK ){ - if (info->status & ONLP_FAN_STATUS_PRESENT){ - result = _fani_status_failed_check(&info->status, local_id); - } - } - break; - case ONLP_FAN_PSU_1: - case ONLP_FAN_PSU_2: - result = onlp_psui_status_get((&info->hdr)->poid, &psu_status); - if(result != ONLP_STATUS_OK){ return result; } - - if(psu_status & ONLP_PSU_STATUS_PRESENT){ - info->status |= ONLP_FAN_STATUS_PRESENT; - result = _fani_status_failed_check(&info->status, local_id); - }else{ - info->status = 0; - } - break; - default: - result = ONLP_STATUS_E_INVALID; - break; - } - *rv = info->status; - } - return result; -} - -/** - * @brief Retrieve the fan's OID hdr. - * @param id The fan OID. - * @param rv [out] Receives the OID header. - */ -int onlp_fani_hdr_get(onlp_oid_t id, onlp_oid_hdr_t* hdr) -{ - int result = ONLP_STATUS_OK; - onlp_fan_info_t* info; - int local_id; - VALIDATE(id); - - local_id = ONLP_OID_ID_GET(id); - if(local_id >= ONLP_FAN_MAX) { - result = ONLP_STATUS_E_INVALID; - } else { - info = &__onlp_fan_info[LOCAL_ID_TO_INFO_IDX(local_id)]; - *hdr = info->hdr; - } - return result; -} - - -/* - * 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) -{ - return ONLP_STATUS_E_UNSUPPORTED; -} - - -/* - * 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/d10064/onlp/builds/x86_64_inventec_d10064/module/src/ledi.c b/packages/platforms/inventec/x86-64/d10064/onlp/builds/x86_64_inventec_d10064/module/src/ledi.c deleted file mode 100644 index bda4629c0..000000000 --- a/packages/platforms/inventec/x86-64/d10064/onlp/builds/x86_64_inventec_d10064/module/src/ledi.c +++ /dev/null @@ -1,441 +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 "platform_lib.h" - -#define VALIDATE(_id) \ - do { \ - if(!ONLP_OID_IS_LED(_id)) { \ - return ONLP_STATUS_E_INVALID; \ - } \ - } while(0) - -/* LED related data - */ - -/* CAPS*/ -#define SYS_LED_CAPS ONLP_LED_CAPS_ON_OFF|ONLP_LED_CAPS_GREEN|ONLP_LED_CAPS_GREEN_BLINKING|ONLP_LED_CAPS_RED|ONLP_LED_CAPS_RED_BLINKING -#define FAN_LED_CAPS ONLP_LED_CAPS_RED|ONLP_LED_CAPS_GREEN - -#define LOCAL_ID_TO_FAN_ID(id) (id-1) - -typedef enum sys_led_mode_e { - SYS_LED_MODE_OFF = 0, - SYS_LED_MODE_0_5_HZ = 1, - SYS_LED_MODE_1_HZ = 2, - SYS_LED_MODE_2_HZ = 3, - SYS_LED_MODE_ON = 7 -} sys_led_mode_t; - -/* function declarations*/ -static int _sys_onlp_led_mode_convert(sys_led_mode_t grn_mode, sys_led_mode_t red_mode, onlp_led_mode_t* pmode); -static int _sys_onlp_ledi_info_get(onlp_oid_t id, onlp_led_info_t* info); -static int _fan_onlp_ledi_info_get(onlp_oid_t id, onlp_led_info_t* info); -static int _sys_onlp_ledi_mode_set(onlp_led_mode_t onlp_mode); - -/* - * Get the information for the given LED OID. - */ -#define MAKE_MGMT_LED_INFO_NODE \ - { \ - { ONLP_LED_ID_CREATE(ONLP_LED_MGMT), "MGMT LED" , 0 }, \ - ONLP_LED_STATUS_PRESENT, \ - SYS_LED_CAPS, \ - } - -#define MAKE_LED_INFO_NODE_ON_FAN(fan_id) \ - { \ - { ONLP_LED_ID_CREATE(ONLP_LED_FAN##fan_id), \ - "FAN LED "#fan_id, \ - ONLP_FAN_ID_CREATE(ONLP_FAN_##fan_id) \ - }, \ - 0, \ - 0, \ - } - -static onlp_led_info_t __onlp_led_info[ONLP_LED_COUNT] = { - MAKE_MGMT_LED_INFO_NODE, - MAKE_LED_INFO_NODE_ON_FAN(1), - MAKE_LED_INFO_NODE_ON_FAN(2), - MAKE_LED_INFO_NODE_ON_FAN(3), - MAKE_LED_INFO_NODE_ON_FAN(4), -}; - - - -/* convert platform led type to onlp_led_mode type*/ -static int _sys_onlp_led_mode_convert(sys_led_mode_t grn_mode, sys_led_mode_t red_mode, onlp_led_mode_t* pmode) -{ - int rv = ONLP_STATUS_OK; - *pmode = ONLP_LED_MODE_OFF; - - switch(grn_mode) { - case SYS_LED_MODE_0_5_HZ: - case SYS_LED_MODE_1_HZ: - case SYS_LED_MODE_2_HZ: - *pmode = ONLP_LED_MODE_GREEN_BLINKING; - break; - case SYS_LED_MODE_ON: - *pmode = ONLP_LED_MODE_GREEN; - break; - case SYS_LED_MODE_OFF: - *pmode = ONLP_LED_MODE_OFF; - break; - default: - return ONLP_STATUS_E_INVALID; - break; - } - switch(red_mode) { - case SYS_LED_MODE_0_5_HZ: - case SYS_LED_MODE_1_HZ: - case SYS_LED_MODE_2_HZ: - if(grn_mode == SYS_LED_MODE_OFF){ - *pmode = ONLP_LED_MODE_RED_BLINKING; - }else{ - return ONLP_STATUS_E_INVALID; - } - break; - case SYS_LED_MODE_ON: - if(grn_mode == SYS_LED_MODE_OFF){ - *pmode = ONLP_LED_MODE_RED; - }else{ - return ONLP_STATUS_E_INVALID; - } - break; - case SYS_LED_MODE_OFF: - if(grn_mode == SYS_LED_MODE_OFF){ - *pmode = ONLP_LED_MODE_OFF; - } - break; - default: - return ONLP_STATUS_E_INVALID; - break; - } - return rv; -} - - -static int _sys_onlp_ledi_info_get(onlp_oid_t id, onlp_led_info_t* info) -{ - int local_id; - int rv = ONLP_STATUS_OK; - sys_led_mode_t grn_mode, red_mode; - local_id = ONLP_OID_ID_GET(id); - int idx = LOCAL_ID_TO_INFO_IDX(local_id); - /* Set the onlp_oid_hdr_t and capabilities */ - *info = __onlp_led_info[idx]; - - rv = onlp_file_read_int((int*)&grn_mode, INV_SYSLED_PREFIX"grn_led"); - if(rv != ONLP_STATUS_OK){ return rv; } - rv = onlp_file_read_int((int*)&red_mode, INV_SYSLED_PREFIX"red_led"); - if(rv != ONLP_STATUS_OK){ return rv; } - - rv = _sys_onlp_led_mode_convert(grn_mode, red_mode, &info->mode); - if(rv != ONLP_STATUS_OK){ return rv; } - - /* Set the on/off status */ - if (info->mode != ONLP_LED_MODE_OFF) { - info->status |= ONLP_LED_STATUS_ON; - } else { - info->status &= (~ONLP_LED_STATUS_ON); - } - - - return rv; -} - -static int _fan_onlp_ledi_info_get(onlp_oid_t id, onlp_led_info_t* info) -{ - int local_id; - int rv = ONLP_STATUS_OK; - int grn_mode, red_mode; - - local_id = ONLP_OID_ID_GET(id); - int fan_id = LOCAL_ID_TO_FAN_ID(local_id); - int idx = LOCAL_ID_TO_INFO_IDX(local_id); - /* Set the onlp_oid_hdr_t and capabilities */ - *info = __onlp_led_info[idx]; - - rv = onlp_ledi_status_get(id, &info->status); - if( rv != ONLP_STATUS_OK ){ return rv; } - - if( info->status & ONLP_LED_STATUS_PRESENT){ - info->caps = FAN_LED_CAPS; - rv = onlp_file_read_int((int*)&grn_mode, INV_HWMON_PREFIX"fan_led_grn%d", fan_id); - if(rv != ONLP_STATUS_OK ){ return rv; } - rv = onlp_file_read_int((int*)&red_mode, INV_HWMON_PREFIX"fan_led_red%d", fan_id); - if(rv != ONLP_STATUS_OK ){ return rv; } - - if(grn_mode == 1 && red_mode == 0){ - info->mode = ONLP_LED_MODE_GREEN; - }else if(grn_mode == 0 && red_mode == 1){ - info->mode = ONLP_LED_MODE_RED; - }else if(grn_mode == 0 && red_mode == 0){ - info->mode = ONLP_LED_MODE_OFF; - }else{ - rv = ONLP_STATUS_E_INVALID; - } - }else{ - info->mode = ONLP_LED_MODE_OFF; - } - return rv; -} - -static int _sys_onlp_ledi_mode_set(onlp_led_mode_t onlp_mode) -{ - int rv = ONLP_STATUS_OK; - - if( onlp_mode == ONLP_LED_MODE_OFF){ - rv = onlp_file_write_int(SYS_LED_MODE_OFF, INV_SYSLED_PREFIX"grn_led"); - if(rv != ONLP_STATUS_OK ){ return rv; } - rv = onlp_file_write_int(SYS_LED_MODE_OFF, INV_SYSLED_PREFIX"red_led"); - }else{ - rv = ONLP_STATUS_E_UNSUPPORTED; - } - return rv; -} - - - -/* - * 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; - VALIDATE(id); - int local_id; - local_id = ONLP_OID_ID_GET(id); - if(local_id >= ONLP_LED_MAX) { - return ONLP_STATUS_E_INVALID; - } - - switch(local_id) { - case ONLP_LED_MGMT: - rv = _sys_onlp_ledi_info_get(id, info); - break; - case ONLP_LED_FAN1: - case ONLP_LED_FAN2: - case ONLP_LED_FAN3: - case ONLP_LED_FAN4: - rv = _fan_onlp_ledi_info_get(id, info); - break; - default: - rv = ONLP_STATUS_E_INVALID; - break; - } - return rv; -} - -/** - * @brief Get the LED operational status. - * @param id The LED OID - * @param rv [out] Receives the operational status. - */ -int onlp_ledi_status_get(onlp_oid_t id, uint32_t* rv) -{ - int result = ONLP_STATUS_OK; - onlp_led_info_t* info; - - VALIDATE(id); - int local_id = ONLP_OID_ID_GET(id); - int info_idx = LOCAL_ID_TO_INFO_IDX(local_id); - int fan_id = LOCAL_ID_TO_FAN_ID(local_id); - int mode, grn_mode, red_mode; - onlp_led_mode_t pmode; - uint32_t fan_status; - - if(local_id >= ONLP_LED_MAX) { - result = ONLP_STATUS_E_INVALID; - } - if(result == ONLP_STATUS_OK) { - info = &__onlp_led_info[info_idx]; - switch(local_id) { - case ONLP_LED_MGMT: - result = onlp_file_read_int((int*)&grn_mode, INV_SYSLED_PREFIX"grn_led"); - if(result != ONLP_STATUS_OK){ return result; } - result = onlp_file_read_int((int*)&red_mode, INV_SYSLED_PREFIX"red_led"); - if(result != ONLP_STATUS_OK){ return result; } - - result = _sys_onlp_led_mode_convert(grn_mode, red_mode, &pmode); - if(result != ONLP_STATUS_OK){ return result; } - - if( pmode != ONLP_LED_MODE_OFF){ - info->status |= ONLP_LED_STATUS_ON; - }else{ - info->status &= (~ONLP_LED_STATUS_ON); - } - - *rv = info->status; - break; - case ONLP_LED_FAN1: - case ONLP_LED_FAN2: - case ONLP_LED_FAN3: - case ONLP_LED_FAN4: - result = onlp_fani_status_get((&info->hdr)->poid, &fan_status); - if(result != ONLP_STATUS_OK){ return result; } - - if(fan_status & ONLP_FAN_STATUS_PRESENT){ - info->status |= ONLP_LED_STATUS_PRESENT; - info->status &= (~ONLP_LED_STATUS_ON); - - result = onlp_file_read_int((int*)&mode, INV_HWMON_PREFIX"fan_led_grn%d", fan_id); - if(result != ONLP_STATUS_OK){ return result; } - if(mode){ - info->status |= ONLP_LED_STATUS_ON; - } - - result = onlp_file_read_int((int*)&mode, INV_HWMON_PREFIX"fan_led_red%d", fan_id); - if(result != ONLP_STATUS_OK){ return result; } - if(mode){ - info->status |= ONLP_LED_STATUS_ON; - } - } else { - info->status = 0; - } - *rv = info->status; - break; - default: - result = ONLP_STATUS_E_INVALID; - break; - } - } - - return result; -} - -/** - * @brief Get the LED header. - * @param id The LED OID - * @param rv [out] Receives the header. - */ -int onlp_ledi_hdr_get(onlp_oid_t id, onlp_oid_hdr_t* rv) -{ - int result = ONLP_STATUS_OK; - onlp_led_info_t* info; - - VALIDATE(id); - - int local_id; - local_id = ONLP_OID_ID_GET(id); - int idx = LOCAL_ID_TO_INFO_IDX(local_id); - if(local_id >= ONLP_LED_MAX) { - result = ONLP_STATUS_E_INVALID; - } else { - info = &__onlp_led_info[idx]; - *rv = info->hdr; - } - return result; -} - -/* - * 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) -{ - onlp_led_mode_t mode; - VALIDATE(id); - int local_id; - local_id = ONLP_OID_ID_GET(id); - int idx = LOCAL_ID_TO_INFO_IDX(local_id); - - if(local_id >= ONLP_LED_MAX) { - return ONLP_STATUS_E_INVALID; - } - - if (__onlp_led_info[idx].caps & ONLP_LED_CAPS_ON_OFF) { - mode = on_or_off?ONLP_LED_MODE_ON:ONLP_LED_MODE_OFF; - return onlp_ledi_mode_set(id, mode); - } - - 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 rv = ONLP_STATUS_OK; - VALIDATE(id); - int local_id; - local_id = ONLP_OID_ID_GET(id); - - if(local_id >= ONLP_LED_MAX) { - return ONLP_STATUS_E_INVALID; - } - switch(local_id) { - case ONLP_LED_MGMT: - rv = _sys_onlp_ledi_mode_set(mode); - break; - case ONLP_LED_FAN1: - case ONLP_LED_FAN2: - case ONLP_LED_FAN3: - case ONLP_LED_FAN4: - rv = ONLP_STATUS_E_UNSUPPORTED; - break; - default: - rv = ONLP_STATUS_E_INVALID; - break; - } - - return rv; -} - -/* - * 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/d10064/onlp/builds/x86_64_inventec_d10064/module/src/make.mk b/packages/platforms/inventec/x86-64/d10064/onlp/builds/x86_64_inventec_d10064/module/src/make.mk deleted file mode 100644 index 9f3ff1eb3..000000000 --- a/packages/platforms/inventec/x86-64/d10064/onlp/builds/x86_64_inventec_d10064/module/src/make.mk +++ /dev/null @@ -1,9 +0,0 @@ -############################################################################### -# -# -# -############################################################################### - -LIBRARY := x86_64_inventec_d10064 -$(LIBRARY)_SUBDIR := $(dir $(lastword $(MAKEFILE_LIST))) -include $(BUILDER)/lib.mk diff --git a/packages/platforms/inventec/x86-64/d10064/onlp/builds/x86_64_inventec_d10064/module/src/platform_lib.c b/packages/platforms/inventec/x86-64/d10064/onlp/builds/x86_64_inventec_d10064/module/src/platform_lib.c deleted file mode 100644 index bb04678b2..000000000 --- a/packages/platforms/inventec/x86-64/d10064/onlp/builds/x86_64_inventec_d10064/module/src/platform_lib.c +++ /dev/null @@ -1,50 +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" - - -int platform_hwmon_diag_enable_read(int *enable) -{ - int rv = ONLP_STATUS_OK; - rv = onlp_file_read_int((int*)enable, INV_HWMON_PREFIX"diag"); - return rv; -} - - -int platform_hwmon_diag_enable_write(int enable) -{ - int rv = ONLP_STATUS_OK; - rv = onlp_file_write_int(enable, INV_HWMON_PREFIX"diag"); - return rv; -} diff --git a/packages/platforms/inventec/x86-64/d10064/onlp/builds/x86_64_inventec_d10064/module/src/platform_lib.h b/packages/platforms/inventec/x86-64/d10064/onlp/builds/x86_64_inventec_d10064/module/src/platform_lib.h deleted file mode 100644 index 08c11e0cb..000000000 --- a/packages/platforms/inventec/x86-64/d10064/onlp/builds/x86_64_inventec_d10064/module/src/platform_lib.h +++ /dev/null @@ -1,142 +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 "x86_64_inventec_d10064_log.h" - -/* This is definitions for x86-64-inventec-d10064*/ -/* OID map*/ -/* - * SYS---------ONLP_THERMAL_CPU_PHY - * |----ONLP_THERMAL_CPU_CORE0 - * |----ONLP_THERMAL_CPU_CORE1 - * |----ONLP_THERMAL_CPU_CORE2 - * |----ONLP_THERMAL_CPU_CORE3 - * |----ONLP_THERMAL_1_ON_MAIN_BROAD - * |----ONLP_THERMAL_2_ON_MAIN_BROAD - * |----ONLP_THERMAL_3_ON_MAIN_BROAD - * |----ONLP_THERMAL_4_ON_MAIN_BROAD - * |----ONLP_THERMAL_5_ON_MAIN_BROAD - * |----ONLP_FAN_1--------ONLP_LED_FAN1 - * | - * |----ONLP_FAN_2--------ONLP_LED_FAN2 - * | - * |----ONLP_FAN_3--------ONLP_LED_FAN3 - * | - * |----ONLP_FAN_4--------ONLP_LED_FAN4 - * | - * |----ONLP_PSU_1--------ONLP_THERMAL_1_ON_PSU1 - * | |--ONLP_THERMAL_2_ON_PSU1 - * | |--ONLP_FAN_PSU_1 - * | - * |----ONLP_PSU_2--------ONLP_THERMAL_1_ON_PSU2 - * | |--ONLP_THERMAL_2_ON_PSU2 - * | |--ONLP_FAN_PSU_2 - * | - * |----ONLP_LED_MGMT - */ - -#define INV_SYSLED_PREFIX "/sys/class/hwmon/hwmon2/device/" -#define INV_HWMON_PREFIX "/sys/class/hwmon/hwmon1/device/" -#define INV_CTMP_PREFIX "/sys/class/hwmon/hwmon0/" -#define INV_SFP_PREFIX "/sys/class/swps/" -#define INV_SYS_PREFIX "/sys/class/eeprom/vpd/" -#define INV_EEPROM_PATH "/sys/bus/i2c/devices/0-0053/eeprom" - -#define OID_MAP_TO_INFO_IDX(oid) ONLP_OID_ID_GET(oid)-1 -#define LOCAL_ID_TO_INFO_IDX(id) (id-1) - -/* Thermal definitions*/ -enum onlp_thermal_id { - ONLP_THERMAL_CPU_PHY = 1, - ONLP_THERMAL_CPU_CORE0, - ONLP_THERMAL_CPU_CORE1, - ONLP_THERMAL_CPU_CORE2, - ONLP_THERMAL_CPU_CORE3, - ONLP_THERMAL_1_ON_MAIN_BROAD, - ONLP_THERMAL_2_ON_MAIN_BROAD, - ONLP_THERMAL_3_ON_MAIN_BROAD, - ONLP_THERMAL_4_ON_MAIN_BROAD, - ONLP_THERMAL_5_ON_MAIN_BROAD, - ONLP_THERMAL_1_ON_PSU1, - ONLP_THERMAL_2_ON_PSU1, - ONLP_THERMAL_1_ON_PSU2, - ONLP_THERMAL_2_ON_PSU2, - ONLP_THERMAL_MAX -}; - -#define ONLP_THERMAL_COUNT 14 /*include "reserved"*/ -#define THERMAL_ON_CHASSIS 10 - -/* Fan definitions*/ -enum onlp_fan_id { - ONLP_FAN_1 = 1, - ONLP_FAN_2, - ONLP_FAN_3, - ONLP_FAN_4, - ONLP_FAN_PSU_1, - ONLP_FAN_PSU_2, - ONLP_FAN_MAX -}; - -#define ONLP_FAN_COUNT 6 /*include "reserved"*/ -#define FAN_ON_CHASSIS 4 - -/* PSU definitions*/ -enum onlp_psu_id { - ONLP_PSU_1 = 1, - ONLP_PSU_2, - ONLP_PSU_MAX -}; - -#define ONLP_PSU_COUNT 2 /*include "reserved"*/ -#define PSU_ON_CHASSIS 2 - -/* LED definitions*/ -enum onlp_led_id { - ONLP_LED_MGMT = 1, - ONLP_LED_FAN1, - ONLP_LED_FAN2, - ONLP_LED_FAN3, - ONLP_LED_FAN4, - ONLP_LED_MAX -}; - -#define ONLP_LED_COUNT 5 /*include "reserved"*/ -#define LED_ON_CHASSIS 1 - -/* platform functions*/ -#define PLATFORM_HWMON_DIAG_LOCK platform_hwmon_diag_enable_write(0) -#define PLATFORM_HWMON_DIAG_UNLOCK platform_hwmon_diag_enable_write(1) -int platform_hwmon_diag_enable_read(int *enable); -int platform_hwmon_diag_enable_write(int enable); - - - - -#endif /* __PLATFORM_LIB_H__ */ - diff --git a/packages/platforms/inventec/x86-64/d10064/onlp/builds/x86_64_inventec_d10064/module/src/psui.c b/packages/platforms/inventec/x86-64/d10064/onlp/builds/x86_64_inventec_d10064/module/src/psui.c deleted file mode 100644 index 8c8e2245e..000000000 --- a/packages/platforms/inventec/x86-64/d10064/onlp/builds/x86_64_inventec_d10064/module/src/psui.c +++ /dev/null @@ -1,214 +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 "platform_lib.h" -#include -#include - -#define VALIDATE(_id) \ - do { \ - if(!ONLP_OID_IS_PSU(_id)) { \ - return ONLP_STATUS_E_INVALID; \ - } \ - } while(0) - - -typedef enum hwmon_psu_state_e { - HWMON_PSU_NORMAL = 0, - HWMON_PSU_UNPOWERED = 2, //010 - HWMON_PSU_FAULT = 4, //100 - HWMON_PSU_NOT_INSTALLED = 7 //111 -} hwmon_psu_state_t; - -/* - * Get all information about the given PSU oid. - */ -#define MAKE_PSU_NODE_INFO(id) \ - { \ - { \ - ONLP_PSU_ID_CREATE(ONLP_PSU_##id), "PSU-"#id, 0, \ - { \ - ONLP_THERMAL_ID_CREATE(ONLP_THERMAL_1_ON_PSU##id), \ - ONLP_THERMAL_ID_CREATE(ONLP_THERMAL_2_ON_PSU##id), \ - ONLP_FAN_ID_CREATE(ONLP_FAN_PSU_##id) \ - } \ - }, \ - "","", 0, 0 \ - } - -static onlp_psu_info_t __onlp_psu_info[ONLP_PSU_COUNT] = { - MAKE_PSU_NODE_INFO(1), - MAKE_PSU_NODE_INFO(2) -}; - -int -onlp_psui_init(void) -{ - return ONLP_STATUS_OK; -} - - -int -onlp_psui_info_get(onlp_oid_t id, onlp_psu_info_t* info) -{ - int ret = ONLP_STATUS_OK; - int len; - int local_id = ONLP_OID_ID_GET(id); - uint8_t temp[ONLP_CONFIG_INFO_STR_MAX] = {0}; - - VALIDATE(id); - - if(local_id >= ONLP_PSU_MAX) { - return ONLP_STATUS_E_INVALID; - } - - *info = __onlp_psu_info[LOCAL_ID_TO_INFO_IDX(local_id)]; /* Set the onlp_oid_hdr_t */ - - ret = onlp_file_read(temp, ONLP_CONFIG_INFO_STR_MAX, &len, INV_HWMON_PREFIX"psoc_psu%d_vendor", local_id); - if(ret != ONLP_STATUS_OK){ return ret; } - /*remove the '\n'*/ - temp[strlen((char*)temp)-1] = 0; - snprintf(info->model, ONLP_CONFIG_INFO_STR_MAX, "%s", temp); - - - memset(temp, 0, ONLP_CONFIG_INFO_STR_MAX); - ret = onlp_file_read(temp, ONLP_CONFIG_INFO_STR_MAX, &len, INV_HWMON_PREFIX"psoc_psu%d_serial", local_id); - if(ret != ONLP_STATUS_OK){ return ret; } - /*remove the '\n'*/ - temp[strlen((char*)temp)-1] = 0; - snprintf(info->serial, ONLP_CONFIG_INFO_STR_MAX, "%s", temp); - - ret = onlp_psui_status_get(id, &info->status); - if(ret != ONLP_STATUS_OK){ return ret; } - - if(info->status & ONLP_PSU_STATUS_PRESENT){ - info->caps = ONLP_PSU_CAPS_AC; - /*millivolts*/ - ret = onlp_file_read_int(&info->mvin, INV_HWMON_PREFIX"psoc_psu%d_vin", local_id); - if(ret != ONLP_STATUS_OK){ return ret; } - if(info->mvin >= 0){ - info->caps |= ONLP_PSU_CAPS_VIN; - } - ret = onlp_file_read_int(&info->mvout, INV_HWMON_PREFIX"psoc_psu%d_vout", local_id); - if(ret != ONLP_STATUS_OK){ return ret; } - if(info->mvout >= 0){ - info->caps |= ONLP_PSU_CAPS_VOUT; - } - - /* milliamps */ - ret = onlp_file_read_int(&info->miin, INV_HWMON_PREFIX"psoc_psu%d_iin", local_id); - if(ret != ONLP_STATUS_OK){ return ret; } - if(info->miin >= 0){ - info->caps |= ONLP_PSU_CAPS_IIN; - } - ret = onlp_file_read_int(&info->miout, INV_HWMON_PREFIX"psoc_psu%d_iout", local_id); - if(ret != ONLP_STATUS_OK){ return ret; } - if(info->miout >= 0){ - info->caps |= ONLP_PSU_CAPS_IOUT; - } - - /* milliwatts */ - ret = onlp_file_read_int(&info->mpin, INV_HWMON_PREFIX"psoc_psu%d_pin", local_id); - if(ret != ONLP_STATUS_OK){ return ret; } - if(info->mpin >= 0){ - info->caps |= ONLP_PSU_CAPS_PIN; - } - ret = onlp_file_read_int(&info->mpout, INV_HWMON_PREFIX"psoc_psu%d_pout", local_id); - if(ret != ONLP_STATUS_OK){ return ret; } - if(info->mpout >= 0){ - info->caps |= ONLP_PSU_CAPS_POUT; - } - } - return ret; -} - - -/** - * @brief Get the PSU's operational status. - * @param id The PSU OID. - * @param rv [out] Receives the operational status. - */ -int onlp_psui_status_get(onlp_oid_t id, uint32_t* rv) -{ - int result = ONLP_STATUS_OK; - hwmon_psu_state_t psu_state; - int local_id; - VALIDATE(id); - int len; - char buf[ONLP_CONFIG_INFO_STR_MAX]; - - local_id = ONLP_OID_ID_GET(id); - if(local_id >= ONLP_PSU_MAX) { - result = ONLP_STATUS_E_INVALID; - } else { - result = onlp_file_read((uint8_t*)&buf, ONLP_CONFIG_INFO_STR_MAX, &len, "%s""psu%d", INV_HWMON_PREFIX, local_id); - if( result != ONLP_STATUS_OK ){return result;} - psu_state = (uint8_t)strtoul(buf, NULL, 0); - if( psu_state == HWMON_PSU_UNPOWERED) { - *rv = ONLP_PSU_STATUS_PRESENT|ONLP_PSU_STATUS_UNPLUGGED; - } else if ( psu_state == HWMON_PSU_NORMAL) { - *rv = ONLP_PSU_STATUS_PRESENT; - } else if( psu_state == HWMON_PSU_FAULT) { - *rv = ONLP_PSU_STATUS_PRESENT|ONLP_PSU_STATUS_FAILED; - } else if( psu_state == HWMON_PSU_NOT_INSTALLED){ - *rv = 0; - } else{ - result = ONLP_STATUS_E_INVALID; - } - } - return result; -} - -/** - * @brief Get the PSU's oid header. - * @param id The PSU OID. - * @param rv [out] Receives the header. - */ -int onlp_psui_hdr_get(onlp_oid_t id, onlp_oid_hdr_t* rv) -{ - int result = ONLP_STATUS_OK; - onlp_psu_info_t* info; - int local_id; - VALIDATE(id); - - local_id = ONLP_OID_ID_GET(id); - if(local_id >= ONLP_PSU_MAX) { - result = ONLP_STATUS_E_INVALID; - } else { - info = &__onlp_psu_info[LOCAL_ID_TO_INFO_IDX(local_id)]; - *rv = info->hdr; - } - return result; -} - - -int -onlp_psui_ioctl(onlp_oid_t pid, va_list vargs) -{ - return ONLP_STATUS_E_UNSUPPORTED; -} - diff --git a/packages/platforms/inventec/x86-64/d10064/onlp/builds/x86_64_inventec_d10064/module/src/sfpi.c b/packages/platforms/inventec/x86-64/d10064/onlp/builds/x86_64_inventec_d10064/module/src/sfpi.c deleted file mode 120000 index 545b97bf8..000000000 --- a/packages/platforms/inventec/x86-64/d10064/onlp/builds/x86_64_inventec_d10064/module/src/sfpi.c +++ /dev/null @@ -1 +0,0 @@ -../../../../../../d5264q28b/onlp/builds/x86_64_inventec_d5264q28b/module/src/sfpi.c \ No newline at end of file diff --git a/packages/platforms/inventec/x86-64/d10064/onlp/builds/x86_64_inventec_d10064/module/src/sysi.c b/packages/platforms/inventec/x86-64/d10064/onlp/builds/x86_64_inventec_d10064/module/src/sysi.c deleted file mode 100644 index ea482a5bd..000000000 --- a/packages/platforms/inventec/x86-64/d10064/onlp/builds/x86_64_inventec_d10064/module/src/sysi.c +++ /dev/null @@ -1,229 +0,0 @@ -/************************************************************ - * sysi.c - * - * Copyright 2018 Inventec Technology Corporation. - * - ************************************************************ - * - ***********************************************************/ -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "x86_64_inventec_d10064_int.h" -#include "x86_64_inventec_d10064_log.h" - -#include "platform_lib.h" - -static int _sysi_version_parsing(char* file_str, char* str_buf, char* version); - -static int _sysi_version_parsing(char* file_str, char* str_buf, char* version) -{ - int rv = ONLP_STATUS_OK; - int len; - char buf[ONLP_CONFIG_INFO_STR_MAX*4]; - char *temp; - - rv = onlp_file_read((uint8_t*)buf,ONLP_CONFIG_INFO_STR_MAX*4, &len, file_str); - if( rv != ONLP_STATUS_OK ) { return rv; } - - temp = strstr(buf, str_buf); - if(temp) { - temp += strlen(str_buf); - snprintf(version,ONLP_CONFIG_INFO_STR_MAX, temp); - /*remove '\n'*/ - version[strlen(version)-1] = '\0'; - } else { - rv = ONLP_STATUS_E_MISSING; - } - return rv; -} - - -const char* -onlp_sysi_platform_get(void) -{ - return "x86-64-inventec-d10064-r0"; -} - - -/* - * This function is called to return the physical base address - * of the ONIE boot rom. - * - * The ONLP framework will mmap() and parse the ONIE TLV structure - * from the given data. - * - * If you platform does not support a mappable address for the ONIE - * eeprom then you should not provide this function at all. - * - * For the purposes of this example we will provide it but - * return UNSUPPORTED (which is all the default implementation does). - * - */ -int -onlp_sysi_onie_data_phys_addr_get(void** pa) -{ - return ONLP_STATUS_E_UNSUPPORTED; -} - - -/* - * If you cannot provide a base address you must provide the ONLP - * framework the raw ONIE data through whatever means necessary. - * - * This function will be called as a backup in the event that - * onlp_sysi_onie_data_phys_addr_get() fails. - */ -int -onlp_sysi_onie_data_get(uint8_t** data, int* size) -{ - int ret=ONLP_STATUS_E_INVALID; - int eeprom_size; - int rv; - uint8_t* eeprom_data; - - FILE* fp = fopen(INV_EEPROM_PATH, "rb"); - - if(fp) { - fseek(fp, 0L, SEEK_END); - eeprom_size = ftell(fp); - rewind(fp); - eeprom_data = aim_malloc(eeprom_size); - - rv = fread(eeprom_data, 1, eeprom_size, fp); - fclose(fp); - - if(rv == eeprom_size) { - ret=ONLP_STATUS_OK; - *data=eeprom_data; - *size=eeprom_size; - } - - } - - return ret; -} - -/* - * IF the ONLP frame calles onlp_sysi_onie_data_get(), - * if will call this function to free the data when it - * is finished with it. - * - * This function is optional, and depends on the data - * you return in onlp_sysi_onie_data_get(). - */ -void -onlp_sysi_onie_data_free(uint8_t* data) -{ - /* - * We returned a static array in onlp_sysi_onie_data_get() - * so no free operation is required. - */ - if(data) { - aim_free(data); - } -} - - -int -onlp_sysi_onie_info_get (onlp_onie_info_t *onie) -{ - int rv = ONLP_STATUS_OK; - - rv = onlp_onie_decode_file(onie, INV_EEPROM_PATH); - - onie->_hdr_id_string = aim_fstrdup("TlvInfo"); - onie->_hdr_version = 0x1; - return rv; -} - - -int -onlp_sysi_platform_info_get(onlp_platform_info_t* pi) -{ - int rv = ONLP_STATUS_OK; - char cpld_str[ONLP_CONFIG_INFO_STR_MAX]= {0}; - char other_str[ONLP_CONFIG_INFO_STR_MAX]= {0}; - char version[ONLP_CONFIG_INFO_STR_MAX]; - - rv = _sysi_version_parsing(INV_SYSLED_PREFIX"info", "The CPLD version is ", version); - if( rv != ONLP_STATUS_OK ) { return rv; } - snprintf(cpld_str, ONLP_CONFIG_INFO_STR_MAX, "%s%s ", cpld_str, version); - rv = _sysi_version_parsing(INV_HWMON_PREFIX"version", "ver: ", version); - if( rv != ONLP_STATUS_OK ) { return rv; } - snprintf(other_str, ONLP_CONFIG_INFO_STR_MAX, "%s%s.%s " - ,other_str, "psoc", version); - - /*cpld version*/ - if(strlen(cpld_str) > 0) { - pi->cpld_versions = aim_fstrdup("%s",cpld_str); - } - - /*other version*/ - if(strlen(other_str) > 0) { - pi->other_versions = aim_fstrdup("%s",other_str); - } - return rv; -} - -void -onlp_sysi_platform_info_free(onlp_platform_info_t* pi) -{ - if(pi->cpld_versions) { - aim_free(pi->cpld_versions); - } - if(pi->other_versions) { - aim_free(pi->other_versions); - } - return; -} - - -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<=THERMAL_ON_CHASSIS; i++){ - *e++ = ONLP_THERMAL_ID_CREATE(i); - } - for(i=1; i<=FAN_ON_CHASSIS; i++){ - *e++ = ONLP_FAN_ID_CREATE(i); - } - for(i=1; i<=PSU_ON_CHASSIS; i++){ - *e++ = ONLP_PSU_ID_CREATE(i); - } - for(i=1; i<=LED_ON_CHASSIS; i++){ - *e++ = ONLP_LED_ID_CREATE(i); - } - return ONLP_STATUS_OK; -} - -int -onlp_sysi_platform_manage_fans(void) -{ - /*Ensure switch manager is working*/ - PLATFORM_HWMON_DIAG_LOCK; - return ONLP_STATUS_OK; -} - -int -onlp_sysi_platform_manage_leds(void) -{ - /*Ensure switch manager is working*/ - PLATFORM_HWMON_DIAG_LOCK; - return ONLP_STATUS_OK; -} - diff --git a/packages/platforms/inventec/x86-64/d10064/onlp/builds/x86_64_inventec_d10064/module/src/thermali.c b/packages/platforms/inventec/x86-64/d10064/onlp/builds/x86_64_inventec_d10064/module/src/thermali.c deleted file mode 100644 index 1bbb05284..000000000 --- a/packages/platforms/inventec/x86-64/d10064/onlp/builds/x86_64_inventec_d10064/module/src/thermali.c +++ /dev/null @@ -1,215 +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 -#include -#include "platform_lib.h" - -#define VALIDATE(_id) \ - do { \ - if(!ONLP_OID_IS_THERMAL(_id)) { \ - return ONLP_STATUS_E_INVALID; \ - } \ - } while(0) - - -typedef struct thermali_path_s { - char file[ONLP_CONFIG_INFO_STR_MAX]; -} thermali_path_t; - -#define MAKE_THERMAL_PATH_ON_CPU(id) { INV_CTMP_PREFIX"temp"#id"_input"} -#define MAKE_THERMAL_PATH_ON_MAIN_BROAD(id) { INV_HWMON_PREFIX"temp"#id"_input"} -#define MAKE_THERMAL1_PATH_ON_PSU(psu_id) { INV_HWMON_PREFIX"thermal_psu"#psu_id} -#define MAKE_THERMAL2_PATH_ON_PSU(psu_id) { INV_HWMON_PREFIX"thermal2_psu"#psu_id} - -static thermali_path_t __path_list[ONLP_THERMAL_COUNT] = { - MAKE_THERMAL_PATH_ON_CPU(1), - MAKE_THERMAL_PATH_ON_CPU(2), - MAKE_THERMAL_PATH_ON_CPU(3), - MAKE_THERMAL_PATH_ON_CPU(4), - MAKE_THERMAL_PATH_ON_CPU(5), - MAKE_THERMAL_PATH_ON_MAIN_BROAD(1), - MAKE_THERMAL_PATH_ON_MAIN_BROAD(2), - MAKE_THERMAL_PATH_ON_MAIN_BROAD(3), - MAKE_THERMAL_PATH_ON_MAIN_BROAD(4), - MAKE_THERMAL_PATH_ON_MAIN_BROAD(5), - MAKE_THERMAL1_PATH_ON_PSU(1), - MAKE_THERMAL2_PATH_ON_PSU(1), - MAKE_THERMAL1_PATH_ON_PSU(2), - MAKE_THERMAL2_PATH_ON_PSU(2) -}; - -#define MAKE_THERMAL_INFO_NODE_ON_CPU_PHY \ - { { ONLP_THERMAL_ID_CREATE(ONLP_THERMAL_CPU_PHY), "CPU Physical", 0}, \ - ONLP_THERMAL_STATUS_PRESENT, \ - ONLP_THERMAL_CAPS_GET_TEMPERATURE, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS \ - } -#define MAKE_THERMAL_INFO_NODE_ON_CPU_CORE(id) \ - { { ONLP_THERMAL_ID_CREATE(ONLP_THERMAL_CPU_CORE##id), "CPU Core "#id, 0},\ - ONLP_THERMAL_STATUS_PRESENT, \ - ONLP_THERMAL_CAPS_GET_TEMPERATURE, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS \ - } -#define MAKE_THERMAL_INFO_NODE_ON_MAIN_BROAD(id) \ - { { ONLP_THERMAL_ID_CREATE(ONLP_THERMAL_##id##_ON_MAIN_BROAD), "Thermal Sensor "#id, 0}, \ - ONLP_THERMAL_STATUS_PRESENT, \ - ONLP_THERMAL_CAPS_GET_TEMPERATURE, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS \ - } -#define MAKE_THERMAL_INFO_NODE_ON_PSU(thermal_id, psu_id) \ - { { \ - ONLP_THERMAL_ID_CREATE(ONLP_THERMAL_##thermal_id##_ON_PSU##psu_id), \ - "PSU-"#psu_id" Thermal Sensor "#thermal_id, \ - ONLP_PSU_ID_CREATE(ONLP_PSU_##psu_id) \ - }, \ - ONLP_THERMAL_CAPS_GET_TEMPERATURE, 0, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS \ - } - -/* Static values */ -static onlp_thermal_info_t __onlp_thermal_info[ONLP_THERMAL_COUNT] = { - MAKE_THERMAL_INFO_NODE_ON_CPU_PHY, - MAKE_THERMAL_INFO_NODE_ON_CPU_CORE(0), - MAKE_THERMAL_INFO_NODE_ON_CPU_CORE(1), - MAKE_THERMAL_INFO_NODE_ON_CPU_CORE(2), - MAKE_THERMAL_INFO_NODE_ON_CPU_CORE(3), - MAKE_THERMAL_INFO_NODE_ON_MAIN_BROAD(1), - MAKE_THERMAL_INFO_NODE_ON_MAIN_BROAD(2), - MAKE_THERMAL_INFO_NODE_ON_MAIN_BROAD(3), - MAKE_THERMAL_INFO_NODE_ON_MAIN_BROAD(4), - MAKE_THERMAL_INFO_NODE_ON_MAIN_BROAD(5), - MAKE_THERMAL_INFO_NODE_ON_PSU(1,1), - MAKE_THERMAL_INFO_NODE_ON_PSU(2,1), - MAKE_THERMAL_INFO_NODE_ON_PSU(1,2), - MAKE_THERMAL_INFO_NODE_ON_PSU(2,2) -}; - -/* - * 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); - int ret; - - local_id = ONLP_OID_ID_GET(id); - if(local_id >= ONLP_THERMAL_MAX) { - return ONLP_STATUS_E_INVALID; - } - - /* Set the onlp_oid_hdr_t and capabilities */ - *info = __onlp_thermal_info[LOCAL_ID_TO_INFO_IDX(local_id)]; - ret = onlp_thermali_status_get(id, &info->status); - if( ret != ONLP_STATUS_OK ){ return ret; } - - if(info->status & ONLP_THERMAL_STATUS_PRESENT){ - ret = onlp_file_read_int(&info->mcelsius, __path_list[LOCAL_ID_TO_INFO_IDX(local_id)].file); - } - - return ret; -} - - -/** - * @brief Retrieve the thermal's operational status. - * @param id The thermal oid. - * @param rv [out] Receives the operational status. - */ -int onlp_thermali_status_get(onlp_oid_t id, uint32_t* rv) -{ - int local_id; - int ret = ONLP_STATUS_OK; - onlp_thermal_info_t* info; - VALIDATE(id); - uint32_t psu_status; - - local_id = ONLP_OID_ID_GET(id); - if(local_id >= ONLP_THERMAL_MAX) { - return ONLP_STATUS_E_INVALID; - } - info = &__onlp_thermal_info[LOCAL_ID_TO_INFO_IDX(local_id)]; - - switch(local_id){ - case ONLP_THERMAL_1_ON_PSU1: - case ONLP_THERMAL_2_ON_PSU1: - case ONLP_THERMAL_1_ON_PSU2: - case ONLP_THERMAL_2_ON_PSU2: - ret = onlp_psui_status_get((&info->hdr)->poid, &psu_status); - if(ret != ONLP_STATUS_OK){return ret;} - - if(psu_status & ONLP_PSU_STATUS_PRESENT){ - info->status |= ONLP_THERMAL_STATUS_PRESENT; - }else{ - info->status = 0; - } - break; - default: - break; - } - - *rv = info->status; - - return ret; -} - -/** - * @brief Retrieve the thermal's oid header. - * @param id The thermal oid. - * @param rv [out] Receives the header. - */ -int onlp_thermali_hdr_get(onlp_oid_t id, onlp_oid_hdr_t* rv) -{ - int local_id; - onlp_thermal_info_t* info; - VALIDATE(id); - - local_id = ONLP_OID_ID_GET(id); - if(local_id >= ONLP_THERMAL_MAX) { - return ONLP_STATUS_E_INVALID; - } - info = &__onlp_thermal_info[LOCAL_ID_TO_INFO_IDX(local_id)]; - - *rv = info->hdr; - - return ONLP_STATUS_OK; -} diff --git a/packages/platforms/inventec/x86-64/d10064/onlp/builds/x86_64_inventec_d10064/module/src/x86_64_inventec_d10064_config.c b/packages/platforms/inventec/x86-64/d10064/onlp/builds/x86_64_inventec_d10064/module/src/x86_64_inventec_d10064_config.c deleted file mode 100644 index 91d2d8c03..000000000 --- a/packages/platforms/inventec/x86-64/d10064/onlp/builds/x86_64_inventec_d10064/module/src/x86_64_inventec_d10064_config.c +++ /dev/null @@ -1,81 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#include - -/* */ -#define __x86_64_inventec_d10064_config_STRINGIFY_NAME(_x) #_x -#define __x86_64_inventec_d10064_config_STRINGIFY_VALUE(_x) __x86_64_inventec_d10064_config_STRINGIFY_NAME(_x) -x86_64_inventec_d10064_config_settings_t x86_64_inventec_d10064_config_settings[] = -{ -#ifdef X86_64_INVENTEC_D10064_CONFIG_INCLUDE_LOGGING - { __x86_64_inventec_d10064_config_STRINGIFY_NAME(X86_64_INVENTEC_D10064_CONFIG_INCLUDE_LOGGING), __x86_64_inventec_d10064_config_STRINGIFY_VALUE(X86_64_INVENTEC_D10064_CONFIG_INCLUDE_LOGGING) }, -#else -{ X86_64_INVENTEC_D10064_CONFIG_INCLUDE_LOGGING(__x86_64_inventec_d10064_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_INVENTEC_D10064_CONFIG_LOG_OPTIONS_DEFAULT - { __x86_64_inventec_d10064_config_STRINGIFY_NAME(X86_64_INVENTEC_D10064_CONFIG_LOG_OPTIONS_DEFAULT), __x86_64_inventec_d10064_config_STRINGIFY_VALUE(X86_64_INVENTEC_D10064_CONFIG_LOG_OPTIONS_DEFAULT) }, -#else -{ X86_64_INVENTEC_D10064_CONFIG_LOG_OPTIONS_DEFAULT(__x86_64_inventec_d10064_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_INVENTEC_D10064_CONFIG_LOG_BITS_DEFAULT - { __x86_64_inventec_d10064_config_STRINGIFY_NAME(X86_64_INVENTEC_D10064_CONFIG_LOG_BITS_DEFAULT), __x86_64_inventec_d10064_config_STRINGIFY_VALUE(X86_64_INVENTEC_D10064_CONFIG_LOG_BITS_DEFAULT) }, -#else -{ X86_64_INVENTEC_D10064_CONFIG_LOG_BITS_DEFAULT(__x86_64_inventec_d10064_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_INVENTEC_D10064_CONFIG_LOG_CUSTOM_BITS_DEFAULT - { __x86_64_inventec_d10064_config_STRINGIFY_NAME(X86_64_INVENTEC_D10064_CONFIG_LOG_CUSTOM_BITS_DEFAULT), __x86_64_inventec_d10064_config_STRINGIFY_VALUE(X86_64_INVENTEC_D10064_CONFIG_LOG_CUSTOM_BITS_DEFAULT) }, -#else -{ X86_64_INVENTEC_D10064_CONFIG_LOG_CUSTOM_BITS_DEFAULT(__x86_64_inventec_d10064_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_INVENTEC_D10064_CONFIG_PORTING_STDLIB - { __x86_64_inventec_d10064_config_STRINGIFY_NAME(X86_64_INVENTEC_D10064_CONFIG_PORTING_STDLIB), __x86_64_inventec_d10064_config_STRINGIFY_VALUE(X86_64_INVENTEC_D10064_CONFIG_PORTING_STDLIB) }, -#else -{ X86_64_INVENTEC_D10064_CONFIG_PORTING_STDLIB(__x86_64_inventec_d10064_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_INVENTEC_D10064_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS - { __x86_64_inventec_d10064_config_STRINGIFY_NAME(X86_64_INVENTEC_D10064_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS), __x86_64_inventec_d10064_config_STRINGIFY_VALUE(X86_64_INVENTEC_D10064_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS) }, -#else -{ X86_64_INVENTEC_D10064_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS(__x86_64_inventec_d10064_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_INVENTEC_D10064_CONFIG_INCLUDE_UCLI - { __x86_64_inventec_d10064_config_STRINGIFY_NAME(X86_64_INVENTEC_D10064_CONFIG_INCLUDE_UCLI), __x86_64_inventec_d10064_config_STRINGIFY_VALUE(X86_64_INVENTEC_D10064_CONFIG_INCLUDE_UCLI) }, -#else -{ X86_64_INVENTEC_D10064_CONFIG_INCLUDE_UCLI(__x86_64_inventec_d10064_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_INVENTEC_D10064_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION - { __x86_64_inventec_d10064_config_STRINGIFY_NAME(X86_64_INVENTEC_D10064_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION), __x86_64_inventec_d10064_config_STRINGIFY_VALUE(X86_64_INVENTEC_D10064_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION) }, -#else -{ X86_64_INVENTEC_D10064_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION(__x86_64_inventec_d10064_config_STRINGIFY_NAME), "__undefined__" }, -#endif - { NULL, NULL } -}; -#undef __x86_64_inventec_d10064_config_STRINGIFY_VALUE -#undef __x86_64_inventec_d10064_config_STRINGIFY_NAME - -const char* -x86_64_inventec_d10064_config_lookup(const char* setting) -{ - int i; - for(i = 0; x86_64_inventec_d10064_config_settings[i].name; i++) { - if(!strcmp(x86_64_inventec_d10064_config_settings[i].name, setting)) { - return x86_64_inventec_d10064_config_settings[i].value; - } - } - return NULL; -} - -int -x86_64_inventec_d10064_config_show(struct aim_pvs_s* pvs) -{ - int i; - for(i = 0; x86_64_inventec_d10064_config_settings[i].name; i++) { - aim_printf(pvs, "%s = %s\n", x86_64_inventec_d10064_config_settings[i].name, x86_64_inventec_d10064_config_settings[i].value); - } - return i; -} - -/* */ - diff --git a/packages/platforms/inventec/x86-64/d10064/onlp/builds/x86_64_inventec_d10064/module/src/x86_64_inventec_d10064_enums.c b/packages/platforms/inventec/x86-64/d10064/onlp/builds/x86_64_inventec_d10064/module/src/x86_64_inventec_d10064_enums.c deleted file mode 100644 index ae03e691c..000000000 --- a/packages/platforms/inventec/x86-64/d10064/onlp/builds/x86_64_inventec_d10064/module/src/x86_64_inventec_d10064_enums.c +++ /dev/null @@ -1,10 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#include - -/* <--auto.start.enum(ALL).source> */ -/* */ - diff --git a/packages/platforms/inventec/x86-64/d10064/onlp/builds/x86_64_inventec_d10064/module/src/x86_64_inventec_d10064_int.h b/packages/platforms/inventec/x86-64/d10064/onlp/builds/x86_64_inventec_d10064/module/src/x86_64_inventec_d10064_int.h deleted file mode 100644 index c3bc463ad..000000000 --- a/packages/platforms/inventec/x86-64/d10064/onlp/builds/x86_64_inventec_d10064/module/src/x86_64_inventec_d10064_int.h +++ /dev/null @@ -1,12 +0,0 @@ -/**************************************************************************//** - * - * x86_64_inventec_d10064 Internal Header - * - *****************************************************************************/ -#ifndef __x86_64_inventec_d10064_INT_H__ -#define __x86_64_inventec_d10064_INT_H__ - -#include - - -#endif /* __x86_64_inventec_d10064_INT_H__ */ diff --git a/packages/platforms/inventec/x86-64/d10064/onlp/builds/x86_64_inventec_d10064/module/src/x86_64_inventec_d10064_log.c b/packages/platforms/inventec/x86-64/d10064/onlp/builds/x86_64_inventec_d10064/module/src/x86_64_inventec_d10064_log.c deleted file mode 100644 index d4327ea42..000000000 --- a/packages/platforms/inventec/x86-64/d10064/onlp/builds/x86_64_inventec_d10064/module/src/x86_64_inventec_d10064_log.c +++ /dev/null @@ -1,18 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#include - -#include "x86_64_inventec_d10064_log.h" -/* - * x86_64_inventec_d10064 log struct. - */ -AIM_LOG_STRUCT_DEFINE( - X86_64_INVENTEC_D10064_CONFIG_LOG_OPTIONS_DEFAULT, - X86_64_INVENTEC_D10064_CONFIG_LOG_BITS_DEFAULT, - NULL, /* Custom log map */ - X86_64_INVENTEC_D10064_CONFIG_LOG_CUSTOM_BITS_DEFAULT - ); - diff --git a/packages/platforms/inventec/x86-64/d10064/onlp/builds/x86_64_inventec_d10064/module/src/x86_64_inventec_d10064_log.h b/packages/platforms/inventec/x86-64/d10064/onlp/builds/x86_64_inventec_d10064/module/src/x86_64_inventec_d10064_log.h deleted file mode 100644 index dddfc886a..000000000 --- a/packages/platforms/inventec/x86-64/d10064/onlp/builds/x86_64_inventec_d10064/module/src/x86_64_inventec_d10064_log.h +++ /dev/null @@ -1,12 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#ifndef __x86_64_inventec_d10064_LOG_H__ -#define __x86_64_inventec_d10064_LOG_H__ - -#define AIM_LOG_MODULE_NAME x86_64_inventec_d10064 -#include - -#endif /* __x86_64_inventec_d100064_LOG_H__ */ diff --git a/packages/platforms/inventec/x86-64/d10064/onlp/builds/x86_64_inventec_d10064/module/src/x86_64_inventec_d10064_module.c b/packages/platforms/inventec/x86-64/d10064/onlp/builds/x86_64_inventec_d10064/module/src/x86_64_inventec_d10064_module.c deleted file mode 100644 index d9ef7ec95..000000000 --- a/packages/platforms/inventec/x86-64/d10064/onlp/builds/x86_64_inventec_d10064/module/src/x86_64_inventec_d10064_module.c +++ /dev/null @@ -1,24 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#include - -#include "x86_64_inventec_d10064_log.h" - -static int -datatypes_init__(void) -{ -#define x86_64_inventec_d10064_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_d10064_module_init__(void) -{ - AIM_LOG_STRUCT_REGISTER(); - datatypes_init__(); -} - -int __onlp_platform_version__ = 1; diff --git a/packages/platforms/inventec/x86-64/d10064/onlp/builds/x86_64_inventec_d10064/module/src/x86_64_inventec_d10064_ucli.c b/packages/platforms/inventec/x86-64/d10064/onlp/builds/x86_64_inventec_d10064/module/src/x86_64_inventec_d10064_ucli.c deleted file mode 100644 index a29193e1b..000000000 --- a/packages/platforms/inventec/x86-64/d10064/onlp/builds/x86_64_inventec_d10064/module/src/x86_64_inventec_d10064_ucli.c +++ /dev/null @@ -1,50 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#include - -#if X86_64_INVENTEC_D10064_CONFIG_INCLUDE_UCLI == 1 - -#include -#include -#include - -static ucli_status_t -x86_64_inventec_d10064_ucli_ucli__config__(ucli_context_t* uc) -{ - UCLI_HANDLER_MACRO_MODULE_CONFIG(x86_64_inventec_d10064) -} - -/* */ -/* */ - -static ucli_module_t -x86_64_inventec_d10064_ucli_module__ = - { - "x86_64_inventec_d10064_ucli", - NULL, - x86_64_inventec_d10064_ucli_ucli_handlers__, - NULL, - NULL, - }; - -ucli_node_t* -x86_64_inventec_d10064_ucli_node_create(void) -{ - ucli_node_t* n; - ucli_module_init(&x86_64_inventec_d10064_ucli_module__); - n = ucli_node_create("x86_64_inventec_d10064", NULL, &x86_64_inventec_d10064_ucli_module__); - ucli_node_subnode_add(n, ucli_module_log_node_create("x86_64_inventec_d10064")); - return n; -} - -#else -void* -x86_64_inventec_d10064_ucli_node_create(void) -{ - return NULL; -} -#endif - diff --git a/packages/platforms/inventec/x86-64/d10064/platform-config/Makefile b/packages/platforms/inventec/x86-64/d10064/platform-config/Makefile deleted file mode 100644 index 003238cf6..000000000 --- a/packages/platforms/inventec/x86-64/d10064/platform-config/Makefile +++ /dev/null @@ -1 +0,0 @@ -include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/inventec/x86-64/d10064/platform-config/r0/Makefile b/packages/platforms/inventec/x86-64/d10064/platform-config/r0/Makefile deleted file mode 100644 index 003238cf6..000000000 --- a/packages/platforms/inventec/x86-64/d10064/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/inventec/x86-64/d10064/platform-config/r0/PKG.yml b/packages/platforms/inventec/x86-64/d10064/platform-config/r0/PKG.yml deleted file mode 100644 index dd6955aab..000000000 --- a/packages/platforms/inventec/x86-64/d10064/platform-config/r0/PKG.yml +++ /dev/null @@ -1 +0,0 @@ -!include $ONL_TEMPLATES/platform-config-platform.yml ARCH=amd64 VENDOR=inventec BASENAME=x86-64-inventec-d10064 REVISION=r0 diff --git a/packages/platforms/inventec/x86-64/d10064/platform-config/r0/src/lib/healthstatus.sh b/packages/platforms/inventec/x86-64/d10064/platform-config/r0/src/lib/healthstatus.sh deleted file mode 100755 index 00955174e..000000000 --- a/packages/platforms/inventec/x86-64/d10064/platform-config/r0/src/lib/healthstatus.sh +++ /dev/null @@ -1,113 +0,0 @@ -#!/bin/bash -normal='0 : normal' -unpowered='2 : unpowered' -fault='4 : fault' -notinstalled='7 : not installed' -FAN_UNPLUG_NUM=0 -FAN_LED_RED='fan_led_red' -NUM=1 -FAN_NUM=5 -FIRST_READ=0 -SECOND_READ=0 - -PSOC_PATH="" -CPLD_ADDR="/sys/bus/i2c/devices/i2c-0/0-0055" -ROUTE="/sys/class/hwmon/" -for KEY in $(ls ${ROUTE}) -do - KEY=${ROUTE}${KEY} - if [ -f $KEY"/name" ]; then - if [ $(cat $KEY"/name") == "inv_psoc" ]; then - PSOC_PATH=$KEY - fi - fi -done -if [[ $PSOC_PATH == "" ]]; then - echo "ERROR! Unable to find inv_psoc!" - exit -fi - - -#PSU_STAUS='000' -#switch is ready , transfer control of cpld to cpu -echo 1 > $CPLD_ADDR/ctl - -while true -do - -#monitor how many fan modules are unplugged - - -#first check -FAN_UNPLUG_NUM=0 -FAN_ARR=$(cat $PSOC_PATH/$FAN_LED_RED?) - -while read -r line; do - fan_led_red_check=$(echo "$line") - if [ $fan_led_red_check -eq 1 ] - then - let FAN_UNPLUG_NUM=FAN_UNPLUG_NUM+1 - fi -done <<< "$FAN_ARR" -FIRST_READ=$FAN_UNPLUG_NUM - -#second check -FAN_UNPLUG_NUM=0 -FAN_ARR=$(cat $PSOC_PATH/$FAN_LED_RED?) - -while read -r line; do - fan_led_red_check=$(echo "$line") - if [ $fan_led_red_check -eq 1 ] - then - let FAN_UNPLUG_NUM=FAN_UNPLUG_NUM+1 - fi -done <<< "$FAN_ARR" -SECOND_READ=$FAN_UNPLUG_NUM - -if [ $FIRST_READ -ne $SECOND_READ ] -then - #echo "not equl:$FIRST_READ != $SECOND_READ" - continue -fi - -if [ $FAN_UNPLUG_NUM -ge 2 ] -then - #echo "red @2Hz" - echo 7 > $CPLD_ADDR/red_led - echo 0 > $CPLD_ADDR/grn_led - sleep 1 - continue -elif [ $FAN_UNPLUG_NUM -eq 1 ] -then - #echo "solid red" - echo 3 > $CPLD_ADDR/red_led - echo 0 > $CPLD_ADDR/grn_led - sleep 1 - continue -fi - - #echo "normal" - psu0var=$(cat $CPLD_ADDR/psu0) # bottom PSU - psu1var=$(cat $CPLD_ADDR/psu1) # top PSU - - if [ "$psu0var" = "$normal" ] && - [ "$psu1var" = "$normal" ] # PSU normal operatio - then - #echo "solid green" - echo 7 > $CPLD_ADDR/grn_led - echo 0 > $CPLD_ADDR/red_led - else - if [ "$psu0var" = "$unpowered" ] || - [ "$psu1var" = "$unpowered" ] - then - #echo "grn @2Hz" - echo 3 > $CPLD_ADDR/grn_led - echo 0 > $CPLD_ADDR/red_led - fi - - fi - - -sleep 1 -done - diff --git a/packages/platforms/inventec/x86-64/d10064/platform-config/r0/src/lib/x86-64-inventec-d10064-r0.yml b/packages/platforms/inventec/x86-64/d10064/platform-config/r0/src/lib/x86-64-inventec-d10064-r0.yml deleted file mode 100644 index 710e64fa7..000000000 --- a/packages/platforms/inventec/x86-64/d10064/platform-config/r0/src/lib/x86-64-inventec-d10064-r0.yml +++ /dev/null @@ -1,31 +0,0 @@ ---- - -###################################################################### -# -# platform-config for d10064 -# -###################################################################### - -x86-64-inventec-d10064-r0: - - grub: - - serial: >- - --port=0x3f8 - --speed=115200 - --word=8 - --parity=no - --stop=1 - - kernel: - <<: *kernel-4-14 - - args: >- - nopat - console=ttyS0,115200n8 - - ##network - ## interfaces: - ## ma1: - ## name: ~ - ## syspath: pci0000:00/0000:00:14.0 diff --git a/packages/platforms/inventec/x86-64/d10064/platform-config/r0/src/python/x86_64_inventec_d10064_r0/__init__.py b/packages/platforms/inventec/x86-64/d10064/platform-config/r0/src/python/x86_64_inventec_d10064_r0/__init__.py deleted file mode 100644 index 9cce7d412..000000000 --- a/packages/platforms/inventec/x86-64/d10064/platform-config/r0/src/python/x86_64_inventec_d10064_r0/__init__.py +++ /dev/null @@ -1,40 +0,0 @@ -from onl.platform.base import * -from onl.platform.inventec import * - -class OnlPlatform_x86_64_inventec_d10064_r0(OnlPlatformInventec, - OnlPlatformPortConfig_64x100): - PLATFORM='x86-64-inventec-d10064-r0' - MODEL="D10064" - 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') - os.system("echo pca9548 0x70 > /sys/bus/i2c/devices/i2c-0/new_device") - os.system("sleep 1") - os.system("echo pca9548 0x71 > /sys/bus/i2c/devices/i2c-8/new_device") - os.system("sleep 1") - #Upper - os.system("echo pca9548 0x72 > /sys/bus/i2c/devices/i2c-1/new_device") - os.system("echo pca9548 0x72 > /sys/bus/i2c/devices/i2c-2/new_device") - os.system("echo pca9548 0x72 > /sys/bus/i2c/devices/i2c-3/new_device") - os.system("echo pca9548 0x72 > /sys/bus/i2c/devices/i2c-4/new_device") - os.system("sleep 1") - #Lower - os.system("echo pca9548 0x72 > /sys/bus/i2c/devices/i2c-9/new_device") - os.system("echo pca9548 0x72 > /sys/bus/i2c/devices/i2c-10/new_device") - os.system("echo pca9548 0x72 > /sys/bus/i2c/devices/i2c-11/new_device") - os.system("echo pca9548 0x72 > /sys/bus/i2c/devices/i2c-12/new_device") - - self.insmod('inv_psoc') - os.system("echo inv_cpld 0x55 > /sys/bus/i2c/devices/i2c-0/new_device") - os.system("echo inv_cpld 0x77 > /sys/bus/i2c/devices/i2c-0/new_device") - self.insmod('inv_cpld') - self.insmod('swps') - self.insmod('inv_eeprom') - self.new_i2c_device('inv_eeprom', 0x53, 0) - - os.system("/lib/platform-config/x86-64-inventec-d10064-r0/onl/healthstatus.sh &") - - return True diff --git a/packages/platforms/inventec/x86-64/d3352/.gitignore b/packages/platforms/inventec/x86-64/d3352/.gitignore deleted file mode 100644 index 0ba79a1b4..000000000 --- a/packages/platforms/inventec/x86-64/d3352/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -*x86*64*inventec*d3352*.mk -onlpdump.mk diff --git a/packages/platforms/inventec/x86-64/d3352/Makefile b/packages/platforms/inventec/x86-64/d3352/Makefile deleted file mode 100644 index 003238cf6..000000000 --- a/packages/platforms/inventec/x86-64/d3352/Makefile +++ /dev/null @@ -1 +0,0 @@ -include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/inventec/x86-64/d3352/modules/Makefile b/packages/platforms/inventec/x86-64/d3352/modules/Makefile deleted file mode 100644 index 003238cf6..000000000 --- a/packages/platforms/inventec/x86-64/d3352/modules/Makefile +++ /dev/null @@ -1 +0,0 @@ -include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/inventec/x86-64/d3352/modules/PKG.yml b/packages/platforms/inventec/x86-64/d3352/modules/PKG.yml deleted file mode 100644 index c7c0fc6b2..000000000 --- a/packages/platforms/inventec/x86-64/d3352/modules/PKG.yml +++ /dev/null @@ -1 +0,0 @@ -!include $ONL_TEMPLATES/platform-modules.yml VENDOR=inventec BASENAME=x86-64-inventec-d3352 ARCH=amd64 KERNELS="onl-kernel-3.16-lts-x86-64-all:amd64" diff --git a/packages/platforms/inventec/x86-64/d3352/modules/builds/.gitignore b/packages/platforms/inventec/x86-64/d3352/modules/builds/.gitignore deleted file mode 100644 index a65b41774..000000000 --- a/packages/platforms/inventec/x86-64/d3352/modules/builds/.gitignore +++ /dev/null @@ -1 +0,0 @@ -lib diff --git a/packages/platforms/inventec/x86-64/d3352/modules/builds/Makefile b/packages/platforms/inventec/x86-64/d3352/modules/builds/Makefile deleted file mode 100644 index 984236728..000000000 --- a/packages/platforms/inventec/x86-64/d3352/modules/builds/Makefile +++ /dev/null @@ -1,6 +0,0 @@ -KERNELS := onl-kernel-3.16-lts-x86-64-all:amd64 -KMODULES := src -VENDOR := inventec -BASENAME := x86-64-inventec-d3352 -ARCH := x86_64 -include $(ONL)/make/kmodule.mk diff --git a/packages/platforms/inventec/x86-64/d3352/modules/builds/src/Makefile b/packages/platforms/inventec/x86-64/d3352/modules/builds/src/Makefile deleted file mode 100644 index fcb17f379..000000000 --- a/packages/platforms/inventec/x86-64/d3352/modules/builds/src/Makefile +++ /dev/null @@ -1,8 +0,0 @@ -obj-m += i2c-gpio.o -obj-m += inv_cpld.o -obj-m += inv_platform.o -obj-m += inv_psoc.o -obj-m += inv_pthread.o -obj-m += swps.o -swps-objs := inv_swps.o io_expander.o transceiver.o inv_mux.o - diff --git a/packages/platforms/inventec/x86-64/d3352/modules/builds/src/i2c-gpio.c b/packages/platforms/inventec/x86-64/d3352/modules/builds/src/i2c-gpio.c deleted file mode 100644 index 71a45b210..000000000 --- a/packages/platforms/inventec/x86-64/d3352/modules/builds/src/i2c-gpio.c +++ /dev/null @@ -1,293 +0,0 @@ -/* - * Bitbanging I2C bus driver using the GPIO API - * - * Copyright (C) 2007 Atmel Corporation - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. - */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -struct i2c_gpio_private_data { - struct i2c_adapter adap; - struct i2c_algo_bit_data bit_data; - struct i2c_gpio_platform_data pdata; -}; - -/* Toggle SDA by changing the direction of the pin */ -static void i2c_gpio_setsda_dir(void *data, int state) -{ - struct i2c_gpio_platform_data *pdata = data; - - if (state) - gpio_direction_input(pdata->sda_pin); - else - gpio_direction_output(pdata->sda_pin, 0); -} - -/* - * Toggle SDA by changing the output value of the pin. This is only - * valid for pins configured as open drain (i.e. setting the value - * high effectively turns off the output driver.) - */ -static void i2c_gpio_setsda_val(void *data, int state) -{ - struct i2c_gpio_platform_data *pdata = data; - - gpio_set_value(pdata->sda_pin, state); -} - -/* Toggle SCL by changing the direction of the pin. */ -static void i2c_gpio_setscl_dir(void *data, int state) -{ - struct i2c_gpio_platform_data *pdata = data; - - if (state) - gpio_direction_input(pdata->scl_pin); - else - gpio_direction_output(pdata->scl_pin, 0); -} - -/* - * Toggle SCL by changing the output value of the pin. This is used - * for pins that are configured as open drain and for output-only - * pins. The latter case will break the i2c protocol, but it will - * often work in practice. - */ -static void i2c_gpio_setscl_val(void *data, int state) -{ - struct i2c_gpio_platform_data *pdata = data; - - gpio_set_value(pdata->scl_pin, state); -} - -static int i2c_gpio_getsda(void *data) -{ - struct i2c_gpio_platform_data *pdata = data; - - return gpio_get_value(pdata->sda_pin); -} - -static int i2c_gpio_getscl(void *data) -{ - struct i2c_gpio_platform_data *pdata = data; - - return gpio_get_value(pdata->scl_pin); -} - -static int of_i2c_gpio_get_pins(struct device_node *np, - unsigned int *sda_pin, unsigned int *scl_pin) -{ - if (of_gpio_count(np) < 2) - return -ENODEV; - - *sda_pin = of_get_gpio(np, 0); - *scl_pin = of_get_gpio(np, 1); - - if (*sda_pin == -EPROBE_DEFER || *scl_pin == -EPROBE_DEFER) - return -EPROBE_DEFER; - - if (!gpio_is_valid(*sda_pin) || !gpio_is_valid(*scl_pin)) { - pr_err("%s: invalid GPIO pins, sda=%d/scl=%d\n", - np->full_name, *sda_pin, *scl_pin); - return -ENODEV; - } - - return 0; -} - -static void of_i2c_gpio_get_props(struct device_node *np, - struct i2c_gpio_platform_data *pdata) -{ - u32 reg; - - of_property_read_u32(np, "i2c-gpio,delay-us", &pdata->udelay); - - if (!of_property_read_u32(np, "i2c-gpio,timeout-ms", ®)) - pdata->timeout = msecs_to_jiffies(reg); - - pdata->sda_is_open_drain = - of_property_read_bool(np, "i2c-gpio,sda-open-drain"); - pdata->scl_is_open_drain = - of_property_read_bool(np, "i2c-gpio,scl-open-drain"); - pdata->scl_is_output_only = - of_property_read_bool(np, "i2c-gpio,scl-output-only"); -} - -static int i2c_gpio_probe(struct platform_device *pdev) -{ - struct i2c_gpio_private_data *priv; - struct i2c_gpio_platform_data *pdata; - struct i2c_algo_bit_data *bit_data; - struct i2c_adapter *adap; - unsigned int sda_pin, scl_pin; - int ret; - - /* First get the GPIO pins; if it fails, we'll defer the probe. */ - if (pdev->dev.of_node) { - ret = of_i2c_gpio_get_pins(pdev->dev.of_node, - &sda_pin, &scl_pin); - if (ret) - return ret; - } else { - if (!dev_get_platdata(&pdev->dev)) - return -ENXIO; - pdata = dev_get_platdata(&pdev->dev); - sda_pin = pdata->sda_pin; - scl_pin = pdata->scl_pin; - } - - ret = devm_gpio_request(&pdev->dev, sda_pin, "sda"); - if (ret) { - if (ret == -EINVAL) - ret = -EPROBE_DEFER; /* Try again later */ - return ret; - } - ret = devm_gpio_request(&pdev->dev, scl_pin, "scl"); - if (ret) { - if (ret == -EINVAL) - ret = -EPROBE_DEFER; /* Try again later */ - return ret; - } - - priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL); - if (!priv) - return -ENOMEM; - adap = &priv->adap; - bit_data = &priv->bit_data; - pdata = &priv->pdata; - - if (pdev->dev.of_node) { - pdata->sda_pin = sda_pin; - pdata->scl_pin = scl_pin; - of_i2c_gpio_get_props(pdev->dev.of_node, pdata); - } else { - memcpy(pdata, dev_get_platdata(&pdev->dev), sizeof(*pdata)); - } - - if (pdata->sda_is_open_drain) { - gpio_direction_output(pdata->sda_pin, 1); - bit_data->setsda = i2c_gpio_setsda_val; - } else { - gpio_direction_input(pdata->sda_pin); - bit_data->setsda = i2c_gpio_setsda_dir; - } - - if (pdata->scl_is_open_drain || pdata->scl_is_output_only) { - gpio_direction_output(pdata->scl_pin, 1); - bit_data->setscl = i2c_gpio_setscl_val; - } else { - gpio_direction_input(pdata->scl_pin); - bit_data->setscl = i2c_gpio_setscl_dir; - } - - if (!pdata->scl_is_output_only) - bit_data->getscl = i2c_gpio_getscl; - bit_data->getsda = i2c_gpio_getsda; - - if (pdata->udelay) - bit_data->udelay = pdata->udelay; - else if (pdata->scl_is_output_only) - bit_data->udelay = 50; /* 10 kHz */ - else - bit_data->udelay = 5; /* 100 kHz */ - - if (pdata->timeout) - bit_data->timeout = pdata->timeout; - else - bit_data->timeout = HZ / 10; /* 100 ms */ - - bit_data->data = pdata; - - adap->owner = THIS_MODULE; - if (pdev->dev.of_node) - strlcpy(adap->name, dev_name(&pdev->dev), sizeof(adap->name)); - else - snprintf(adap->name, sizeof(adap->name), "i2c-gpio%d", pdev->id); - - adap->algo_data = bit_data; - adap->class = I2C_CLASS_HWMON | I2C_CLASS_SPD; - adap->dev.parent = &pdev->dev; - adap->dev.of_node = pdev->dev.of_node; - - adap->nr = pdev->id; - ret = i2c_bit_add_numbered_bus(adap); - if (ret) - return ret; - - platform_set_drvdata(pdev, priv); - - dev_info(&pdev->dev, "using pins %u (SDA) and %u (SCL%s)\n", - pdata->sda_pin, pdata->scl_pin, - pdata->scl_is_output_only - ? ", no clock stretching" : ""); - - return 0; -} - -static int i2c_gpio_remove(struct platform_device *pdev) -{ - struct i2c_gpio_private_data *priv; - struct i2c_gpio_platform_data *pdata; - struct i2c_adapter *adap; - - priv = platform_get_drvdata(pdev); - adap = &priv->adap; - pdata = &priv->pdata; - - i2c_del_adapter(adap); - - return 0; -} - -#if defined(CONFIG_OF) -static const struct of_device_id i2c_gpio_dt_ids[] = { - { .compatible = "i2c-gpio", }, - { /* sentinel */ } -}; - -MODULE_DEVICE_TABLE(of, i2c_gpio_dt_ids); -#endif - -static struct platform_driver i2c_gpio_driver = { - .driver = { - .name = "i2c-gpio", - .owner = THIS_MODULE, - .of_match_table = of_match_ptr(i2c_gpio_dt_ids), - }, - .probe = i2c_gpio_probe, - .remove = i2c_gpio_remove, -}; - -static int __init i2c_gpio_init(void) -{ - int ret; - - ret = platform_driver_register(&i2c_gpio_driver); - if (ret) - printk(KERN_ERR "i2c-gpio: probe failed: %d\n", ret); - - return ret; -} -subsys_initcall(i2c_gpio_init); - -static void __exit i2c_gpio_exit(void) -{ - platform_driver_unregister(&i2c_gpio_driver); -} -module_exit(i2c_gpio_exit); - -MODULE_AUTHOR("Haavard Skinnemoen (Atmel)"); -MODULE_DESCRIPTION("Platform-independent bitbanging I2C driver"); -MODULE_LICENSE("GPL"); -MODULE_ALIAS("platform:i2c-gpio"); diff --git a/packages/platforms/inventec/x86-64/d3352/modules/builds/src/inv_cpld.c b/packages/platforms/inventec/x86-64/d3352/modules/builds/src/inv_cpld.c deleted file mode 100644 index f82408e42..000000000 --- a/packages/platforms/inventec/x86-64/d3352/modules/builds/src/inv_cpld.c +++ /dev/null @@ -1,899 +0,0 @@ -/* - * 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 -#include "inv_pthread.h" - -#define USE_SMBUS (1) - -/* definition */ -#define CPLD_INFO_OFFSET (0x00) -#define CPLD_BIOS_OFFSET (0x04) -#define CPLD_BIOS_SPI0 (0) -#define CPLD_BIOS_SPI1 (1) -#define CPLD_PSU_OFFSET (0x08) -#define CPLD_LED_OFFSET (0x14) -#define CPLD_CTL_OFFSET (0x0C) -#define CPLD_CTL_SWCH_READY (0x01) -#define CPLD_CTL_BIOS_READY (0x10) - -/* Each client has this additional data */ -struct cpld_data { - struct device *hwmon_dev; - struct mutex update_lock; -}; - -static struct device *cpld_led_client_dev = NULL; - -/*-----------------------------------------------------------------------*/ - -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 i2c_client *client = to_i2c_client(dev); - struct cpld_data *data = i2c_get_clientdata(client); - u8 byte; - - mutex_lock(&data->update_lock); - - status = cpld_i2c_read(client, &byte, 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", byte); - - return strlen(buf); -} - -static ssize_t set_ctl(struct device *dev, - struct device_attribute *devattr, - const char *buf, size_t count) -{ - struct i2c_client *client = to_i2c_client(dev); - struct cpld_data *data = i2c_get_clientdata(client); - u8 byte = simple_strtoul(buf, NULL, 16); - - //printk(KERN_INFO "%s/%d: %u (%s)\n",__func__,__LINE__,byte, buf); - - mutex_lock(&data->update_lock); - cpld_i2c_write(client, &byte, CPLD_CTL_OFFSET, 1); - mutex_unlock(&data->update_lock); - - return count; -} - -ssize_t cpld_set_ctl(const char *buf, size_t count) -{ - struct i2c_client *client = NULL; - struct cpld_data *data = NULL; - u8 byte = simple_strtol(buf, NULL, 16); - - if (!cpld_led_client_dev) { - return 0; - } - - client = to_i2c_client(cpld_led_client_dev); - data = i2c_get_clientdata(client); - - mutex_lock(&data->update_lock); - cpld_i2c_write(client, &byte, CPLD_CTL_OFFSET, 1); - mutex_unlock(&data->update_lock); - - return count; -} -EXPORT_SYMBOL(cpld_set_ctl); - -static ssize_t show_bios_cs(struct device *dev, struct device_attribute *da, - char *buf) -{ - u32 status; - struct i2c_client *client = to_i2c_client(dev); - struct cpld_data *data = i2c_get_clientdata(client); - u8 byte; - - mutex_lock(&data->update_lock); - status = cpld_i2c_read(client, &byte, CPLD_BIOS_OFFSET, 1); - mutex_unlock(&data->update_lock); - - if(status != 1) { - return sprintf(buf, "read cpld BIOS_CS fail\n"); - } - - status = sprintf (buf, "0x%0X\n", byte); - return strlen(buf); -} - -static ssize_t set_bios_cs(struct device *dev, - struct device_attribute *devattr, - const char *buf, size_t count) -{ - struct i2c_client *client = to_i2c_client(dev); - struct cpld_data *data = i2c_get_clientdata(client); - u8 byte = buf[0] - '0'; - - if (byte != CPLD_BIOS_SPI0 && byte != CPLD_BIOS_SPI1) { - printk(KERN_INFO "%s/%d: Invalide Value %s. 0 or 1 Only\n",__func__,__LINE__,buf); - return 0; - } - - mutex_lock(&data->update_lock); - cpld_i2c_write(client, &byte, CPLD_BIOS_OFFSET, 1); - mutex_unlock(&data->update_lock); - - return count; -} - -static cpld_led_map_t cpld_led_map[] = { - { NULL, 0, 0x00, 0x00, 0x00, 0x00, 0x00 }, - { "stk_led", 0, 0x03, 0x00, 0x01, 0x02, 0x03 }, - { "fan_led", 2, 0x0c, 0x00, 0x04, 0x08, 0x0c }, - { "pwr_led", 4, 0x30, 0x00, 0x10, 0x20, 0x30 }, - { "sys_led", 6, 0xc0, 0x00, 0x40, 0x80, 0xc0 } -}; - -/* System Leds: sys_led/pwr_led/fan_led/stk_led */ -ssize_t cpld_show_led(char *buf, size_t count) -{ - u32 status; - struct i2c_client *client = NULL; - struct cpld_data *data = NULL; - u8 byte = simple_strtol(buf, NULL, 10); - - if (!cpld_led_client_dev) { - return 0; - } - - client = to_i2c_client(cpld_led_client_dev); - data = i2c_get_clientdata(client); - - 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 show_led fail\n"); - - return sprintf (buf, "0x%02X\n", byte); -} -EXPORT_SYMBOL(cpld_show_led); - -static ssize_t show_sys_led(struct device *dev, struct device_attribute *da, - char *buf) -{ - u32 status; - struct i2c_client *client = to_i2c_client(dev); - struct cpld_data *data = i2c_get_clientdata(client); - u8 byte; - - 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 sys_led fail\n"); - - return sprintf (buf, "%s: 0x%02X\n", cpld_led_map[LED_SYS].name, (byte & cpld_led_map[LED_SYS].bit_mask)); -} - -static ssize_t set_sys_led(struct device *dev, - struct device_attribute *devattr, - const char *buf, size_t count) -{ - struct i2c_client *client = to_i2c_client(dev); - struct cpld_data *data = i2c_get_clientdata(client); - u8 temp, byte = simple_strtol(buf, NULL, 10); - - if (byte == 0) { - byte = cpld_led_map[LED_SYS].led_off; - } - else - if (byte == 1) { - byte = cpld_led_map[LED_SYS].led_on; - } - else - if (byte == 2) { - byte = cpld_led_map[LED_SYS].led_blink; - } - else - if (byte == 3) { - byte = cpld_led_map[LED_SYS].led_blink_slow; - } - else { - printk(KERN_INFO "%s/%d: Invalide value: %s\n",__func__,__LINE__,buf); - printk(KERN_INFO "0 Blue OFF\n1 Blue ON\n2 Blue Blink 1Hz\nBlue Blink 0.5\n"); - return 0; - } - - mutex_lock(&data->update_lock); - cpld_i2c_read(client, &temp, CPLD_LED_OFFSET, 1); - temp &= ~cpld_led_map[LED_SYS].bit_mask; - byte |= temp; - cpld_i2c_write(client, &byte, CPLD_LED_OFFSET, 1); - mutex_unlock(&data->update_lock); - - return count; -} - -ssize_t cpld_set_sys_led(const char *buf, size_t count) -{ - struct i2c_client *client = NULL; - struct cpld_data *data = NULL; - u8 temp, byte = simple_strtol(buf, NULL, 10); - - if (!cpld_led_client_dev) { - return 0; - } - - client = to_i2c_client(cpld_led_client_dev); - data = i2c_get_clientdata(client); - - if (byte == 0) { - byte = cpld_led_map[LED_SYS].led_off; - } - else - if (byte == 1) { - byte = cpld_led_map[LED_SYS].led_on; - } - else - if (byte == 2) { - byte = cpld_led_map[LED_SYS].led_blink; - } - else - if (byte == 3) { - byte = cpld_led_map[LED_SYS].led_blink_slow; - } - else { - printk(KERN_INFO "%s/%d: Invalide value: %s\n",__func__,__LINE__,buf); - printk(KERN_INFO "0 Blue OFF\n1 Blue ON\n2 Blue Blink 1Hz\nBlue Blink 0.5\n"); - return 0; - } - - mutex_lock(&data->update_lock); - cpld_i2c_read(client, &temp, CPLD_LED_OFFSET, 1); - temp &= ~cpld_led_map[LED_SYS].bit_mask; - byte |= temp; - cpld_i2c_write(client, &byte, CPLD_LED_OFFSET, 1); - mutex_unlock(&data->update_lock); - - return count; -} -EXPORT_SYMBOL(cpld_set_sys_led); - -static ssize_t show_pwr_led(struct device *dev, struct device_attribute *da, - char *buf) -{ - u32 status; - struct i2c_client *client = to_i2c_client(dev); - struct cpld_data *data = i2c_get_clientdata(client); - u8 byte; - - 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 pwr_led fail\n"); - - return sprintf (buf, "%s: 0x%02X\n", cpld_led_map[LED_PWR].name, (byte & cpld_led_map[LED_PWR].bit_mask)); -} - -static ssize_t set_pwr_led(struct device *dev, - struct device_attribute *devattr, - const char *buf, size_t count) -{ - struct i2c_client *client = to_i2c_client(dev); - struct cpld_data *data = i2c_get_clientdata(client); - u8 temp, byte = simple_strtol(buf, NULL, 10); - - if (byte == 0) { - byte = cpld_led_map[LED_PWR].led_off; - } - else - if (byte == 1) { - byte = cpld_led_map[LED_PWR].led_on; - } - else - if (byte == 2) { - byte = cpld_led_map[LED_PWR].led_blink; - } - else - if (byte == 3) { - byte = cpld_led_map[LED_PWR].led_blink_slow; - } - else { - printk(KERN_INFO "%s/%d: Invalide value: %s\n",__func__,__LINE__,buf); - printk(KERN_INFO "0 Blue OFF\n1 Blue ON\n2 Blue Blink 1Hz\nBlue Blink 0.5\n"); - return 0; - } - - mutex_lock(&data->update_lock); - cpld_i2c_read(client, &temp, CPLD_LED_OFFSET, 1); - temp &= ~cpld_led_map[LED_PWR].bit_mask; - byte |= temp; - cpld_i2c_write(client, &byte, CPLD_LED_OFFSET, 1); - mutex_unlock(&data->update_lock); - - return count; -} - -ssize_t cpld_set_pwr_led(const char *buf, size_t count) -{ - struct i2c_client *client = NULL; - struct cpld_data *data = NULL; - u8 temp, byte = simple_strtol(buf, NULL, 10); - - if (!cpld_led_client_dev) { - return 0; - } - - client = to_i2c_client(cpld_led_client_dev); - data = i2c_get_clientdata(client); - - if (byte == 0) { - byte = cpld_led_map[LED_PWR].led_off; - } - else - if (byte == 1) { - byte = cpld_led_map[LED_PWR].led_on; - } - else - if (byte == 2) { - byte = cpld_led_map[LED_PWR].led_blink; - } - else - if (byte == 3) { - byte = cpld_led_map[LED_PWR].led_blink_slow; - } - else { - printk(KERN_INFO "%s/%d: Invalide value: %s\n",__func__,__LINE__,buf); - printk(KERN_INFO "0 Blue OFF\n1 Blue ON\n2 Blue Blink 1Hz\nBlue Blink 0.5\n"); - return 0; - } - - mutex_lock(&data->update_lock); - cpld_i2c_read(client, &temp, CPLD_LED_OFFSET, 1); - temp &= ~cpld_led_map[LED_PWR].bit_mask; - byte |= temp; - cpld_i2c_write(client, &byte, CPLD_LED_OFFSET, 1); - mutex_unlock(&data->update_lock); - - return count; -} -EXPORT_SYMBOL(cpld_set_pwr_led); - -static ssize_t show_fan_led(struct device *dev, struct device_attribute *da, - char *buf) -{ - u32 status; - struct i2c_client *client = to_i2c_client(dev); - struct cpld_data *data = i2c_get_clientdata(client); - u8 byte; - - 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 fan_led fail\n"); - - return sprintf (buf, "%s: 0x%02X\n", cpld_led_map[LED_FAN].name, (byte & cpld_led_map[LED_FAN].bit_mask)); -} - -static ssize_t set_fan_led(struct device *dev, - struct device_attribute *devattr, - const char *buf, size_t count) -{ - struct i2c_client *client = to_i2c_client(dev); - struct cpld_data *data = i2c_get_clientdata(client); - u8 temp, byte = simple_strtol(buf, NULL, 10); - - if (byte == 0) { - byte = cpld_led_map[LED_FAN].led_off; - } - else - if (byte == 1) { - byte = cpld_led_map[LED_FAN].led_on; - } - else - if (byte == 2) { - byte = cpld_led_map[LED_FAN].led_blink; - } - else - if (byte == 3) { - byte = cpld_led_map[LED_FAN].led_blink_slow; - } - else { - printk(KERN_INFO "%s/%d: Invalide value: %s\n",__func__,__LINE__,buf); - printk(KERN_INFO "0 Blue OFF\n1 Blue ON\n2 Blue Blink 1Hz\nBlue Blink 0.5\n"); - return 0; - } - - mutex_lock(&data->update_lock); - cpld_i2c_read(client, &temp, CPLD_LED_OFFSET, 1); - temp &= ~cpld_led_map[LED_FAN].bit_mask; - byte |= temp; - cpld_i2c_write(client, &byte, CPLD_LED_OFFSET, 1); - mutex_unlock(&data->update_lock); - - return count; -} - -ssize_t cpld_set_fan_led(const char *buf, size_t count) -{ - struct i2c_client *client = NULL; - struct cpld_data *data = NULL; - u8 temp, byte = simple_strtol(buf, NULL, 10); - - if (!cpld_led_client_dev) { - return 0; - } - - client = to_i2c_client(cpld_led_client_dev); - data = i2c_get_clientdata(client); - - if (byte == 0) { - byte = cpld_led_map[LED_FAN].led_off; - } - else - if (byte == 1) { - byte = cpld_led_map[LED_FAN].led_on; - } - else - if (byte == 2) { - byte = cpld_led_map[LED_FAN].led_blink; - } - else - if (byte == 3) { - byte = cpld_led_map[LED_FAN].led_blink_slow; - } - else { - printk(KERN_INFO "%s/%d: Invalide value: %s\n",__func__,__LINE__,buf); - printk(KERN_INFO "0 Blue OFF\n1 Blue ON\n2 Blue Blink 1Hz\nBlue Blink 0.5\n"); - return 0; - } - - mutex_lock(&data->update_lock); - cpld_i2c_read(client, &temp, CPLD_LED_OFFSET, 1); - temp &= ~cpld_led_map[LED_FAN].bit_mask; - byte |= temp; - cpld_i2c_write(client, &byte, CPLD_LED_OFFSET, 1); - mutex_unlock(&data->update_lock); - - return count; -} -EXPORT_SYMBOL(cpld_set_fan_led); - -static ssize_t show_stk_led(struct device *dev, struct device_attribute *da, - char *buf) -{ - u32 status; - struct i2c_client *client = to_i2c_client(dev); - struct cpld_data *data = i2c_get_clientdata(client); - u8 byte; - - 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 stk_led fail\n"); - - return sprintf (buf, "%s: 0x%02X\n", cpld_led_map[LED_STK].name, (byte & cpld_led_map[LED_STK].bit_mask)); -} - -static ssize_t set_stk_led(struct device *dev, - struct device_attribute *devattr, - const char *buf, size_t count) -{ - struct i2c_client *client = to_i2c_client(dev); - struct cpld_data *data = i2c_get_clientdata(client); - u8 temp, byte = simple_strtol(buf, NULL, 10); - - if (byte == 0) { - byte = cpld_led_map[LED_STK].led_off; - } - else - if (byte == 1) { - byte = cpld_led_map[LED_STK].led_on; - } - else - if (byte == 2) { - byte = cpld_led_map[LED_STK].led_blink; - } - else - if (byte == 3) { - byte = cpld_led_map[LED_STK].led_blink_slow; - } - else { - printk(KERN_INFO "%s/%d: Invalide value: %s\n",__func__,__LINE__,buf); - printk(KERN_INFO "0 Blue OFF\n1 Blue ON\n2 Blue Blink 1Hz\nBlue Blink 0.5\n"); - return 0; - } - - mutex_lock(&data->update_lock); - cpld_i2c_read(client, &temp, CPLD_LED_OFFSET, 1); - temp &= ~cpld_led_map[LED_STK].bit_mask; - byte |= temp; - cpld_i2c_write(client, &byte, CPLD_LED_OFFSET, 1); - mutex_unlock(&data->update_lock); - - return count; -} - -ssize_t cpld_set_stk_led(const char *buf, size_t count) -{ - struct i2c_client *client = NULL; - struct cpld_data *data = NULL; - u8 temp, byte = simple_strtol(buf, NULL, 10); - - if (!cpld_led_client_dev) { - return 0; - } - - client = to_i2c_client(cpld_led_client_dev); - data = i2c_get_clientdata(client); - - if (byte == 0) { - byte = cpld_led_map[LED_STK].led_off; - } - else - if (byte == 1) { - byte = cpld_led_map[LED_STK].led_on; - } - else - if (byte == 2) { - byte = cpld_led_map[LED_STK].led_blink; - } - else - if (byte == 3) { - byte = cpld_led_map[LED_STK].led_blink_slow; - } - else { - printk(KERN_INFO "%s/%d: Invalide value: %s\n",__func__,__LINE__,buf); - printk(KERN_INFO "0 Blue OFF\n1 Blue ON\n2 Blue Blink 1Hz\nBlue Blink 0.5\n"); - return 0; - } - - mutex_lock(&data->update_lock); - cpld_i2c_read(client, &temp, CPLD_LED_OFFSET, 1); - temp &= ~cpld_led_map[LED_STK].bit_mask; - byte |= temp; - cpld_i2c_write(client, &byte, CPLD_LED_OFFSET, 1); - mutex_unlock(&data->update_lock); - - return count; -} -EXPORT_SYMBOL(cpld_set_stk_led); - -#if 0 -static char* led_str[] = { - "OFF", //000 - "0.5 Hz", //001 - "1 Hz", //010 - "2 Hz", //011 - "4 Hz", //100 - "NA", //101 - "NA", //110 - "ON", //111 -}; -#endif - -/* -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); -} - -ssize_t cpld_show_psu(char *buf) -{ - u32 status; - struct i2c_client *client = NULL; - struct cpld_data *data = NULL; - u8 byte; - - if (!cpld_led_client_dev) { - return 0; - } - - client = to_i2c_client(cpld_led_client_dev); - data = i2c_get_clientdata(client); - - mutex_lock(&data->update_lock); - status = cpld_i2c_read(client, &byte, CPLD_PSU_OFFSET, 1); - mutex_unlock(&data->update_lock); - - status = sprintf (buf, "0x%04x\n", byte & 0x3f); - - return strlen(buf); -} -EXPORT_SYMBOL(cpld_show_psu); - -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(psu0, S_IRUGO, show_psu, 0, 0); -static SENSOR_DEVICE_ATTR(psu1, S_IRUGO, show_psu, 0, 1); - -static SENSOR_DEVICE_ATTR(bios_cs, S_IWUSR|S_IRUGO, show_bios_cs, set_bios_cs, 0); -static SENSOR_DEVICE_ATTR(sys_led, S_IWUSR|S_IRUGO, show_sys_led, set_sys_led, 0); -static SENSOR_DEVICE_ATTR(pwr_led, S_IWUSR|S_IRUGO, show_pwr_led, set_pwr_led, 0); -static SENSOR_DEVICE_ATTR(fan_led, S_IWUSR|S_IRUGO, show_fan_led, set_fan_led, 0); -static SENSOR_DEVICE_ATTR(stk_led, S_IWUSR|S_IRUGO, show_stk_led, set_stk_led, 0); - -static struct attribute *cpld_attributes[] = { - //info - &sensor_dev_attr_info.dev_attr.attr, - &sensor_dev_attr_ctl.dev_attr.attr, - &sensor_dev_attr_psu0.dev_attr.attr, - &sensor_dev_attr_psu1.dev_attr.attr, - - &sensor_dev_attr_bios_cs.dev_attr.attr, - &sensor_dev_attr_sys_led.dev_attr.attr, - &sensor_dev_attr_pwr_led.dev_attr.attr, - &sensor_dev_attr_fan_led.dev_attr.attr, - &sensor_dev_attr_stk_led.dev_attr.attr, - - NULL -}; - -static const struct attribute_group cpld_group = { - .attrs = cpld_attributes, -}; - -static struct attribute *cpld2_attributes[] = { - //info - &sensor_dev_attr_info.dev_attr.attr, - - NULL -}; - -static const struct attribute_group cpld2_group = { - .attrs = cpld2_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; - - 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 */ - if(id->driver_data==1) // CPLD2 - status = sysfs_create_group(&client->dev.kobj, &cpld2_group); - else // default CPLD1 - 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); - - cpld_led_client_dev = &client->dev; - return 0; - -exit_remove: - sysfs_remove_group(&client->dev.kobj, &cpld_group); -exit_free: - i2c_set_clientdata(client, NULL); - kfree(data); - cpld_led_client_dev = NULL; - 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); - cpld_led_client_dev = NULL; - return 0; -} - -static const struct i2c_device_id cpld_ids[] = { - { "inv_cpld" , 0, }, - { "inv_cpld2", 1, }, - { /* 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/d3352/modules/builds/src/inv_mux.c b/packages/platforms/inventec/x86-64/d3352/modules/builds/src/inv_mux.c deleted file mode 100644 index 89e95f12f..000000000 --- a/packages/platforms/inventec/x86-64/d3352/modules/builds/src/inv_mux.c +++ /dev/null @@ -1,275 +0,0 @@ -#include -#include -#include -#include -#include -#include "io_expander.h" -#include "inv_mux.h" - -static struct mux_obj_s *mux_head_p = NULL; - - -/* ========== MUX object functions ========== - */ -int -_common_force_pull_gpio(int mem_addr, - int input, - int bit_offset){ - - unsigned int val = 0; - unsigned int targ = 0; - - /* Get current value */ - val = inl(mem_addr); - if (val == 0) { - SWPS_ERR("%s: inl:%d fail!\n", __func__, val); - return -1; - } - /* Count target value */ - switch (input) { - case 0: /* Pull Low */ - targ = (val & (~(1 << bit_offset))); - break; - case 1: /* Pull high */ - targ = (val | (1 << bit_offset)); - break; - default: - SWPS_ERR("%s: input state:%d incorrect!\n", - __func__, input); - return -1; - } - /* Setup gpio */ - outl(targ, mem_addr); - if (targ != inl(mem_addr)){ - SWPS_ERR("%s: outl:%d fail!\n", __func__, targ); - return -1; - } - SWPS_DEBUG("%s: done.\n", __func__); - return 0; -} - - -int -rangeley_force_pull_high(struct mux_obj_s *self){ - SWPS_ERR("%s: not ready!\n", __func__); - return -1; -} - - -int -rangeley_force_pull_low(struct mux_obj_s *self){ - SWPS_ERR("%s: not ready!\n", __func__); - return -1; -} - - -int -hedera_force_pull_high(struct mux_obj_s *self){ - return _common_force_pull_gpio(MUX_RST_MEM_ADDR_HEDERA, 1, 5); -} - - -int -hedera_force_pull_low(struct mux_obj_s *self){ - return _common_force_pull_gpio(MUX_RST_MEM_ADDR_HEDERA, 0, 5); -} - - -int -normal_gpio_pull_high(struct mux_obj_s *self){ - return gpio_direction_output(self->gpio_num, 1); -} - - -int -normal_gpio_pull_low(struct mux_obj_s *self){ - return gpio_direction_output(self->gpio_num, 0); -} - - -int -pca9548_reset_mux_all(struct mux_obj_s *self){ - /* [Note] Power-on reset (PCA9548A-NXP) - * When power is applied to VDD, an internal Power-On Reset (POR) - * holds the PCA9548A in a reset condition until VDD has reached - * VPOR. At this point, the reset condition is released and the - * PCA9548A register and I2C-bus state machine are initialized to - * their default states (all zeroes) causing all the channels to - * be deselected. Thereafter, VDD must be lowered below 0.2 V for - * at least 5 us in order to reset the device. - */ - if (self->_pull_low(self) < 0) { - SWPS_ERR("%s: _pull_low fail!\n", __func__); - return -1; - } - mdelay(MUX_RST_WAIT_MS); - if (self->_pull_high(self) < 0) { - SWPS_ERR("%s: _pull_high fail!\n", __func__); - return -1; - } - mdelay(MUX_RST_WAIT_MS); - return 0; -} - - -int -common_reset_mux_all(struct mux_obj_s *self){ - SWPS_ERR("%s: not ready!\n", __func__); - return -1; -} - - -int -init_gpio_4_force(struct mux_obj_s *self){ - return 0; -} - - -int -init_gpio_4_normal(struct mux_obj_s *self){ - - int err = 0; - - if (!gpio_is_valid(self->gpio_num)) { - SWPS_ERR("%s: GIPO:%d isn't valid\n", __func__, self->gpio_num); - return -1; - } - err = gpio_request(self->gpio_num, MUX_GPIO_LABEL); - if (err < 0) { - SWPS_ERR("%s: gpio_request fail :%d :%d\n", - __func__, err, self->gpio_num); - return -1; - } - SWPS_DEBUG("%s: gpio_request:%d ok.\n", __func__, self->gpio_num); - return 0; -} - - -static int -_setup_muxctl_cb(struct mux_obj_s *self, - unsigned gpio){ - - char mod_dsc[32] = "ERR"; - - switch (gpio) { - case MUX_RST_GPIO_FORCE_RANGELEY: - self->gpio_num = gpio; - self->_pull_low = rangeley_force_pull_low; - self->_pull_high = rangeley_force_pull_high; - self->_init = init_gpio_4_force; - self->reset = pca9548_reset_mux_all; - memset(mod_dsc, 0, 32); - snprintf(mod_dsc, 31, "Rangeley force mode"); - goto ok_setup_muxctl_cb; - - case MUX_RST_GPIO_FORCE_HEDERA: - self->gpio_num = gpio; - self->_pull_low = hedera_force_pull_low; - self->_pull_high = hedera_force_pull_high; - self->_init = init_gpio_4_force; - self->reset = pca9548_reset_mux_all; - memset(mod_dsc, 0, 32); - snprintf(mod_dsc, 31, "Hedera force mode"); - goto ok_setup_muxctl_cb; - - case MUX_RST_GPIO_48_PAC9548: - case MUX_RST_GPIO_69_PAC9548: - case MUX_RST_GPIO_249_PCA9548: - case MUX_RST_GPIO_500_PAC9548: - case MUX_RST_GPIO_505_PCA9548: - self->gpio_num = gpio; - self->_pull_low = normal_gpio_pull_low; - self->_pull_high = normal_gpio_pull_high; - self->_init = init_gpio_4_normal; - self->reset = pca9548_reset_mux_all; - memset(mod_dsc, 0, 32); - snprintf(mod_dsc, 31, "Normal mode :%d", (int)gpio); - goto ok_setup_muxctl_cb; - - default: - break; - } - SWPS_ERR("%s: Unexpected GPIO:%d\n", __func__, gpio); - return -1; - -ok_setup_muxctl_cb: - SWPS_INFO("muxctl: %s.\n", mod_dsc); - return 0; -} - - -/* ========== MUX public functions ========== - */ -void -clean_mux_gpio(void){ - - if (!mux_head_p) { - SWPS_DEBUG("%s: mux_head_p is NULL\n", __func__); - return; - } - if (gpio_is_valid(mux_head_p->gpio_num)) { - gpio_free(mux_head_p->gpio_num); - } - kfree(mux_head_p); - mux_head_p = NULL; - SWPS_DEBUG("%s: done.\n", __func__); -} - - -int -reset_mux_gpio(void){ - - if (!mux_head_p) { - SWPS_ERR("%s: MUX ctl object doesn't exist!\n", __func__); - return -1; - } - if (mux_head_p->reset(mux_head_p) < 0){ - SWPS_ERR("%s: reset fail!\n", __func__); - return -1; - } - return 0; -} - - -int -init_mux_gpio(unsigned gpio){ - - /* Create MUX control object */ - if (mux_head_p) { - SWPS_DEBUG("%s: mux_head_p is not NULL!\n", __func__); - clean_mux_gpio(); - } - /* Currently, it is using single muxctl architecture. - * In the future, it may use the multi-muxctl if HW add new features. - * (Ex: Port power-status control) - */ - mux_head_p = kzalloc(sizeof(struct mux_obj_s), GFP_KERNEL); - if (!mux_head_p) { - SWPS_ERR("%s: kzalloc fail!\n", __func__); - return -1; - } - /* Initial MUX controller */ - if (_setup_muxctl_cb(mux_head_p, gpio) < 0){ - SWPS_ERR("%s: _setup_muxctl_cb fail!\n", __func__); - return -1; - } - if (mux_head_p->_init(mux_head_p) < 0) { - SWPS_ERR("%s: init() fail\n", __func__); - goto err_init_mux_gpio; - } - /* Setup default value */ - if (mux_head_p->_pull_high(mux_head_p) < 0) { - SWPS_ERR("%s: setup default fail!\n", __func__); - goto err_init_mux_gpio; - } - return 0; - -err_init_mux_gpio: - clean_mux_gpio(); - return -1; -} - - - - - diff --git a/packages/platforms/inventec/x86-64/d3352/modules/builds/src/inv_mux.h b/packages/platforms/inventec/x86-64/d3352/modules/builds/src/inv_mux.h deleted file mode 100644 index ebed04445..000000000 --- a/packages/platforms/inventec/x86-64/d3352/modules/builds/src/inv_mux.h +++ /dev/null @@ -1,40 +0,0 @@ -#ifndef INV_MUX_H -#define INV_MUX_H - - -/* MUX basic information */ -#define MUX_GPIO_LABEL "SWPS_RST_MUX" - -/* MUX reset GPIO define */ -#define MUX_RST_GPIO_FORCE (30100) -#define MUX_RST_GPIO_FORCE_RANGELEY (30101) -#define MUX_RST_GPIO_FORCE_HEDERA (30102) -#define MUX_RST_GPIO_48_PAC9548 (48) -#define MUX_RST_GPIO_69_PAC9548 (69) -#define MUX_RST_GPIO_249_PCA9548 (249) -#define MUX_RST_GPIO_500_PAC9548 (500) -#define MUX_RST_GPIO_505_PCA9548 (505) - -/* MUX relate value define */ -#define MUX_RST_WAIT_MS (1) -#define MUX_RST_MEM_ADDR_RANGELEY (0) // TBD -#define MUX_RST_MEM_ADDR_HEDERA (0x548) - -struct mux_obj_s { - unsigned gpio_num; - int (*_pull_high)(struct mux_obj_s *self); - int (*_pull_low)(struct mux_obj_s *self); - int (*_init)(struct mux_obj_s *self); - int (*reset)(struct mux_obj_s *self); -}; - - -void clean_mux_gpio(void); -int reset_mux_gpio(void); -int init_mux_gpio(unsigned gpio); - - -#endif /* INV_MUX_H */ - - - diff --git a/packages/platforms/inventec/x86-64/d3352/modules/builds/src/inv_platform.c b/packages/platforms/inventec/x86-64/d3352/modules/builds/src/inv_platform.c deleted file mode 100644 index 84479c78b..000000000 --- a/packages/platforms/inventec/x86-64/d3352/modules/builds/src/inv_platform.c +++ /dev/null @@ -1,128 +0,0 @@ -#include -//#include -#include -#include -#include -#include -#include - -#include -#include -#include - -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_data mux_data_0 = { - .modes = mux_modes_0, - .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 inv_i2c_board_info i2cdev_list[] = { - {0, ARRAY_SIZE(i2c_device_info0), i2c_device_info0 }, //smbus 0 -}; - -#if 0 -static struct i2c_gpio_platform_data i2c_gpio_platdata = { - .scl_pin = 460,//8, - .sda_pin = 461,//9, - - .udelay = 5, //5:100kHz - .timeout = 100, - .sda_is_open_drain = 0, - .scl_is_open_drain = 0, - .scl_is_output_only = 0 -}; - -static struct platform_device inventec_device_i2c_gpio = { - .name = "i2c-gpio", - .id = 0, // adapter number - .dev.platform_data = &i2c_gpio_platdata, -}; -#else -static struct i2c_gpio_platform_data i2c_gpio_platdata2 = { - .scl_pin = 464,//12+452, - .sda_pin = 463,//11+452, - - .udelay = 5, //5:100kHz - .timeout = 100, - .sda_is_open_drain = 0, - .scl_is_open_drain = 0, - .scl_is_output_only = 0 -}; - -static struct platform_device inventec_device_i2c_gpio2 = { - .name = "i2c-gpio", - .id = 1, // adapter number - .dev.platform_data = &i2c_gpio_platdata2, -}; -#endif - -static int __init plat_inventec_init(void) -{ - struct i2c_adapter *adap = NULL; - struct i2c_client *e = NULL; - int ret = 0; - int i,j; - - //use i2c-gpio - //register i2c gpio - //config gpio8,9 gpio12,11 to gpio function -#if 0 - outl( inl(0x500) | (1<<8 | 1<<9 ), 0x500); - - ret = platform_device_register(&inventec_device_i2c_gpio); - if (ret) { - printk(KERN_ERR "i2c-gpio: device_i2c_gpio register fail %d\n", ret); - } - else { - printk(KERN_INFO "i2c-gpio: i2c-0 Success.\n"); - } -#endif - outl( inl(0x500) | (1<<11 | 1<<12), 0x500); - ret = platform_device_register(&inventec_device_i2c_gpio2); - if (ret) { - printk(KERN_ERR "i2c-gpio: device_i2c_gpio2 register fail %d\n", ret); - } - else { - printk(KERN_INFO "i2c-gpio: i2c-1 Success.\n"); - } - for(i=0; i -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -//#include "I2CHostCommunication.h" -#include -#include -#include -#include -#define SWITCH_TEMPERATURE_SOCK "/proc/switch/temp" - -#define USE_SMBUS 1 - -#define FAN_NUM 4 -#define PSU_NUM 2 - -static struct device *psoc_led_client_dev = NULL; - -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; - - u8 psu1_vendor[16]; - u8 psu2_vendor[16]; - u8 psu1_model[20]; - u8 psu2_model[20]; - u8 psu1_version[8]; - u8 psu2_version[8]; - u8 psu1_date[6]; - u8 psu2_date[6]; - u8 psu1_sn[20]; - u8 psu2_sn[20]; -}; - -struct clei{ - u8 issue_number[3]; - u8 abbreviation_number[9]; - u8 fc_number[10]; - u8 clei_code[10]; - u8 product_year_and_month[5]; - u8 label_location_code[2]; - u8 serial_number[5]; - u8 pcb_revision[5]; - u8 reserved[15]; -}; - -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 - u8 reserved[0xff-0xfd]; - - struct clei clei[6]; //FAN:0~3 PSU:4~5; -}; - -/* 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) - -#define CLEI_OFF(m) offsetof(struct clei, m) -#define FAN1_CLEI_INDEX 0 -#define FAN2_CLEI_INDEX 1 -#define FAN3_CLEI_INDEX 2 -#define FAN4_CLEI_INDEX 3 -#define PSU1_CLEI_INDEX 4 -#define PSU2_CLEI_INDEX 5 -#define ISSUENUMBER_INDEX 0 -#define ABBREVIATION_INDEX 1 -#define FCNUMBER_INDEX 2 -#define CLEICODE_INDEX 3 -#define PRODUCTDATE_INDEX 4 -#define LABELLOCATION_INDX 5 -#define SERIALNUMBER_INDEX 6 -#define PCBREVISION_INDEX 7 - -/* Each client has this additional data */ -struct psoc_data { - struct device *hwmon_dev; - struct mutex update_lock; - u32 diag; - struct task_struct *auto_update; -}; - -/*-----------------------------------------------------------------------*/ - -static ssize_t psoc_i2c_read(struct i2c_client *client, u8 *buf, u16 offset, size_t count) -{ -#if USE_SMBUS - int i; - for(i=0; i> 8), ((offset+i) & 0xff)); - buf[i] = i2c_smbus_read_byte(client); - } - - return count; -#else - struct i2c_msg msg[2]; - char msgbuf[2]; - int status; - - memset(msg, 0, sizeof(msg)); - - msgbuf[0] = offset >> 8 ; - msgbuf[1] = offset & 0xff; - - msg[0].addr = client->addr; - msg[0].buf = msgbuf; - msg[0].len = 2; - - 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, u16 offset, size_t count) -{ -#if USE_SMBUS - int i; - - for(i=0; i> 8), ((offset+i) & 0xff) | (buf[i] << 8)); - } - return count; -#else - struct i2c_msg msg; - int status; - u8 writebuf[256]; - - int i = 0; - - msg.addr = client->addr; - msg.flags = 0; - - /* msg.buf is u8 and casts will mask the values */ - msg.buf = writebuf; - - msg.buf[i++] = offset >> 8; - msg.buf[i++] = offset & 0xff; - 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, u16 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, u16 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) -#if 0 -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 | PSOC_PMB_SEL; /* the start bit for the PM bus */ - 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; -} -#endif -static ssize_t show_clei(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 device_index = attr->index & 0xFF; - u8 clei_index = (attr->index >> 8) & 0xFF; - u16 offset = PSOC_OFF(clei) + sizeof(struct clei)* device_index; - u8 len; - u8 rxbuf[21] = {0}; - u8 rxbuf1[21] = {0}; - u8 counter = 0; - - switch (clei_index) - { - case ISSUENUMBER_INDEX: - offset += CLEI_OFF(issue_number); - len = sizeof((struct clei){0}.issue_number); - break; - case ABBREVIATION_INDEX: - offset += CLEI_OFF(abbreviation_number); - len = sizeof((struct clei){0}.abbreviation_number); - break; - case FCNUMBER_INDEX: - offset += CLEI_OFF(fc_number); - len = sizeof((struct clei){0}.fc_number); - break; - case CLEICODE_INDEX: - offset += CLEI_OFF(clei_code); - len = sizeof((struct clei){0}.clei_code); - break; - case PRODUCTDATE_INDEX: - offset += CLEI_OFF(product_year_and_month); - len = sizeof((struct clei){0}.product_year_and_month); - break; - case LABELLOCATION_INDX: - offset += CLEI_OFF(label_location_code); - len = sizeof((struct clei){0}.label_location_code); - break; - case SERIALNUMBER_INDEX: - offset += CLEI_OFF(serial_number); - len = sizeof((struct clei){0}.serial_number); - break; - case PCBREVISION_INDEX: - offset += CLEI_OFF(pcb_revision); - len = sizeof((struct clei){0}.pcb_revision); - break; - default: - return 0; - } - - do - { - mutex_lock(&data->update_lock); - status = psoc_i2c_read(client,rxbuf,offset,len); - mutex_unlock(&data->update_lock); - - mutex_lock(&data->update_lock); - status = psoc_i2c_read(client,rxbuf1,offset,len); - mutex_unlock(&data->update_lock); - - counter++; - }while((strcmp(rxbuf,rxbuf1)!=0) || ((strlen(rxbuf)==0) && (counter <5))); - - //return sprintf(buf, "show_clei: offset:%d len:%d \n",offset,len); - - if(rxbuf[0]==0x00 || rxbuf[0]==0xFF) return 0; - - return sprintf(buf, "%s \n",rxbuf); -} - - -/* -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); -} - -static ssize_t psoc_show_psu_st(char *buf, int psu_index) -{ - u32 status; - struct i2c_client *client = NULL; - struct psoc_data *data = NULL; - u8 byte; - int shift = (psu_index == 0)?3:0; - - if (!psoc_led_client_dev) { - return 0; - } - - client = to_i2c_client(psoc_led_client_dev); - data = i2c_get_clientdata(client); - - 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); -} - -ssize_t psoc_show_psu_state(char *buf, int index) -{ - return psoc_show_psu_st(buf, index); -} -EXPORT_SYMBOL(psoc_show_psu_state); - -/*-----------------------------------------------------------------------*/ - -/* 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); - u16 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 psoc_show_rpm(char *buf, int fan_index) -{ - int status; - struct i2c_client *client = NULL; - struct psoc_data *data = NULL; - u8 offset = fan_index*2 + RPM_OFFSET; - - if (!psoc_led_client_dev) { - return 0; - } - - client = to_i2c_client(psoc_led_client_dev); - data = i2c_get_clientdata(client); - - mutex_lock(&data->update_lock); - status = psoc_read16(client, offset); - mutex_unlock(&data->update_lock); - - return sprintf(buf, "%d\n", - status); -} - -ssize_t psoc_show_fan_input(char *buf, int index) -{ - return psoc_show_rpm(buf, index); -} -EXPORT_SYMBOL(psoc_show_fan_input); - -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; -} - -ssize_t psoc_show_diag(char *buf) -{ - u16 status; - struct i2c_client *client = NULL; - struct psoc_data *data = NULL; - u8 diag_flag = 0; - - if (!psoc_led_client_dev) { - return 0; - } - - client = to_i2c_client(psoc_led_client_dev); - data = i2c_get_clientdata(client); - - 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); -} -EXPORT_SYMBOL(psoc_show_diag); - -ssize_t psoc_set_diag(const char *buf, size_t count) -{ - struct i2c_client *client = NULL; - struct psoc_data *data = NULL; - u8 value = 0; - u8 diag = simple_strtol(buf, NULL, 10); - - if (!psoc_led_client_dev) { - return 0; - } - - client = to_i2c_client(psoc_led_client_dev); - data = i2c_get_clientdata(client); - - 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; -} -EXPORT_SYMBOL(psoc_set_diag); - -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 ); -} - -ssize_t psoc_show_value8(char *buf, int offset) -{ - int status; - struct i2c_client *client = NULL; - struct psoc_data *data = NULL; - - if (!psoc_led_client_dev) { - return 0; - } - - client = to_i2c_client(psoc_led_client_dev); - data = i2c_get_clientdata(client); - - mutex_lock(&data->update_lock); - status = psoc_read8(client, offset); - mutex_unlock(&data->update_lock); - - return sprintf(buf, "0x%02X\n", status ); -} - -static char prev_fan_state[8] = { 0 }; - -ssize_t psoc_show_fan_state(char *buf) -{ - int i; - int rv = psoc_show_value8(buf, FAN_GPI_OFFSET); - for (i = 0; i < 2; i++) { - if (strncmp(prev_fan_state, buf, 4) == 0) { - return rv; - } - msleep(50); - rv = psoc_show_value8(buf, FAN_GPI_OFFSET); - } - strcpy(prev_fan_state, buf); - return rv; -} -EXPORT_SYMBOL(psoc_show_fan_state); - -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; -} - -#if 0 -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 chip = (attr->index >> 16)? 0x59:0x58; - u8 bus = 1; - unsigned char value[2] = {0,0};; - - 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) ); -} -#endif - -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 & 0xFF) + PSU_INFO_OFFSET; - u8 len = (attr->index >> 8)& 0xFF; - u8 rxbuf[21] = {0}; - u8 rxbuf1[21] = {0}; - u8 counter = 0; - u8 count = 0; - u8 index = 0; - if (len == 2) - { - 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 )); - } - else - { - do - { - mutex_lock(&data->update_lock); - status = psoc_i2c_read(client,rxbuf,offset,len); - mutex_unlock(&data->update_lock); - mutex_lock(&data->update_lock); - status = psoc_i2c_read(client,rxbuf1,offset,len); - mutex_unlock(&data->update_lock); - counter++; - }while((strcmp(rxbuf,rxbuf1)!=0) || ((strlen(rxbuf)==0) && (counter <5))); - for(index = 0; index < len; index++) - { - if(rxbuf[index] == 0xFF) - count++; - } - if(len == count) - return sprintf(buf, "%s \n","NA"); - if(status ==0) - return sprintf(buf,"%s \n", "NA"); - else if((strlen(rxbuf)==0)) - return sprintf(buf, "%s \n", "N/A"); - else - return sprintf(buf, "%s \n",rxbuf); - } -} - -static ssize_t psoc_show_psu_psoc(char *buf, int psu_index, char *attr_name) -{ - u16 status; - struct i2c_client *client = NULL; - struct psoc_data *data = NULL; - u8 offset = psu_index + PSU_INFO_OFFSET; - - if (!psoc_led_client_dev) { - return 0; - } - - client = to_i2c_client(psoc_led_client_dev); - data = i2c_get_clientdata(client); - - 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_name, "vout")? 1:0 )); -} - -ssize_t psoc_show_psu_vin(char *buf, int index) -{ - return psoc_show_psu_psoc(buf, index, "vin"); -} -EXPORT_SYMBOL(psoc_show_psu_vin); - -#define PSOC_POLLING_PERIOD 1000 -#define PSU_NOT_INSTALLED 7 -#define PSOC_WARNING(fmt, args...) printk( KERN_WARNING "[PSOC]" fmt, ##args) -static u8 psu_info[PSU_NUM]; -static u8 fan_info[FAN_NUM]; -static void get_init_psu_fan_status(struct i2c_client *client) -{ - struct psoc_data *data = i2c_get_clientdata(client); - u32 status = 0; - u8 byte = 0; - int i = 0; - mutex_lock(&data->update_lock); - status = psoc_i2c_read(client, &byte, PSOC_PSU_OFFSET,1); - mutex_unlock(&data->update_lock); - psu_info[0] = (byte >> 3) & 0x7; - psu_info[1] = (byte >> 0) & 0x7; - mutex_lock(&data->update_lock); - status = psoc_read8(client, FAN_GPI_OFFSET); - mutex_unlock(&data->update_lock); - for (i=0; i<2 ; i++) - { - fan_info[i] = ((status >> i) & 0x01); - } -} - -#if 0 -static void check_fan_status(struct i2c_client *client) -{ - struct psoc_data *data = i2c_get_clientdata(client); - u32 status; - int i = 0; - u8 rst = 0; - mutex_lock(&data->update_lock); - status = psoc_read8(client, FAN_GPI_OFFSET); - mutex_unlock(&data->update_lock); - for (i = 0; i < FAN_NUM; i++) - { - rst = ((status >> i) & 0x01); - if(rst != fan_info[i]) - { - fan_info[i] = rst; - if (rst) - PSOC_WARNING("Detect FAN%d is removed \n",(i+1)); - else - PSOC_WARNING("Detect FAN%d is present \n",(i+1)); - } - } -} - -// [Remove] Bacuase cottonwood don't have PSU info -static void check_psu_status(struct i2c_client *client) -{ - static u8 psu_retry[]={0,0}; - struct psoc_data *data = i2c_get_clientdata(client); - u32 status; - u8 byte = 0; - u8 psu1, psu2; - mutex_lock(&data->update_lock); - status = psoc_i2c_read(client, &byte, PSOC_PSU_OFFSET, 1); - mutex_unlock(&data->update_lock); - psu1 = (byte >> 3) & 0x7; - psu2 = (byte >> 0) & 0x7; - if(psu1 != psu_info[0]) - { - if ((psu_retry[0]++)==0) { return; } - if (psu1 == PSU_NOT_INSTALLED) - PSOC_WARNING("Detect PSU1 is removed \n"); - else - PSOC_WARNING("Detect PSU1 is present \n"); - - psu_info[0] = psu1; - psu_retry[0] = 0; - } - if(psu2 != psu_info[1]) - { - if((psu_retry[1]++)==0) { return; } - if(psu2 == PSU_NOT_INSTALLED) - PSOC_WARNING("Detect PSU2 is removed \n"); - else - PSOC_WARNING("Detect PSU2 is present \n"); - - psu_info[1] = psu2; - psu_retry[1] = 0; - } -} -#endif -static void check_switch_temp(struct i2c_client * client) -{ - struct psoc_data *data = i2c_get_clientdata(client); - static struct file *f; - mm_segment_t old_fs; - - set_fs(get_ds()); - f = filp_open(SWITCH_TEMPERATURE_SOCK,O_RDONLY,0644); - if(IS_ERR(f)) { - return; - } - else { - char temp_str[]={0,0,0,0,0,0,0}; - loff_t pos = 0; - u16 temp2 = 0; - old_fs = get_fs(); - set_fs(KERNEL_DS); - vfs_read(f, temp_str,6,&pos); - temp2 = ((simple_strtoul(temp_str,NULL,10)/1000) <<8 ) & 0xFF00 ; - mutex_lock(&data->update_lock); - psoc_i2c_write(client, (u8*)&temp2, SWITCH_TMP_OFFSET, 2); - mutex_unlock(&data->update_lock); - } - filp_close(f,NULL); - set_fs(old_fs); -} - - -static int psoc_polling_thread(void *p) -{ - struct i2c_client *client = p; - get_init_psu_fan_status(client); - while (!kthread_should_stop()) - { -// check_psu_status(client); -// check_fan_status(client); - check_switch_temp(client); - set_current_state(TASK_INTERRUPTIBLE); - if(kthread_should_stop()) - break; - - schedule_timeout(msecs_to_jiffies(PSOC_POLLING_PERIOD)); - } - return 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); - -//CLEI -static SENSOR_DEVICE_ATTR(fan1_issue_number, S_IRUGO, show_clei, 0, FAN1_CLEI_INDEX | ISSUENUMBER_INDEX << 8 ); -static SENSOR_DEVICE_ATTR(fan2_issue_number, S_IRUGO, show_clei, 0, FAN2_CLEI_INDEX | ISSUENUMBER_INDEX << 8 ); -static SENSOR_DEVICE_ATTR(fan3_issue_number, S_IRUGO, show_clei, 0, FAN3_CLEI_INDEX | ISSUENUMBER_INDEX << 8 ); -static SENSOR_DEVICE_ATTR(fan4_issue_number, S_IRUGO, show_clei, 0, FAN4_CLEI_INDEX | ISSUENUMBER_INDEX << 8 ); -static SENSOR_DEVICE_ATTR(fan1_abbreviation_number, S_IRUGO, show_clei, 0, FAN1_CLEI_INDEX | ABBREVIATION_INDEX << 8 ); -static SENSOR_DEVICE_ATTR(fan2_abbreviation_number, S_IRUGO, show_clei, 0, FAN2_CLEI_INDEX | ABBREVIATION_INDEX << 8 ); -static SENSOR_DEVICE_ATTR(fan3_abbreviation_number, S_IRUGO, show_clei, 0, FAN3_CLEI_INDEX | ABBREVIATION_INDEX << 8 ); -static SENSOR_DEVICE_ATTR(fan4_abbreviation_number, S_IRUGO, show_clei, 0, FAN4_CLEI_INDEX | ABBREVIATION_INDEX << 8 ); -static SENSOR_DEVICE_ATTR(fan1_fc_number, S_IRUGO, show_clei, 0, FAN1_CLEI_INDEX | FCNUMBER_INDEX << 8 ); -static SENSOR_DEVICE_ATTR(fan2_fc_number, S_IRUGO, show_clei, 0, FAN2_CLEI_INDEX | FCNUMBER_INDEX << 8 ); -static SENSOR_DEVICE_ATTR(fan3_fc_number, S_IRUGO, show_clei, 0, FAN3_CLEI_INDEX | FCNUMBER_INDEX << 8 ); -static SENSOR_DEVICE_ATTR(fan4_fc_number, S_IRUGO, show_clei, 0, FAN4_CLEI_INDEX | FCNUMBER_INDEX << 8 ); -static SENSOR_DEVICE_ATTR(fan1_clei_code, S_IRUGO, show_clei, 0, FAN1_CLEI_INDEX | CLEICODE_INDEX << 8 ); -static SENSOR_DEVICE_ATTR(fan2_clei_code, S_IRUGO, show_clei, 0, FAN2_CLEI_INDEX | CLEICODE_INDEX << 8 ); -static SENSOR_DEVICE_ATTR(fan3_clei_code, S_IRUGO, show_clei, 0, FAN3_CLEI_INDEX | CLEICODE_INDEX << 8 ); -static SENSOR_DEVICE_ATTR(fan4_clei_code, S_IRUGO, show_clei, 0, FAN4_CLEI_INDEX | CLEICODE_INDEX << 8 ); -static SENSOR_DEVICE_ATTR(fan1_product_year_and_month, S_IRUGO, show_clei, 0, FAN1_CLEI_INDEX | PRODUCTDATE_INDEX << 8 ); -static SENSOR_DEVICE_ATTR(fan2_product_year_and_month, S_IRUGO, show_clei, 0, FAN2_CLEI_INDEX | PRODUCTDATE_INDEX << 8 ); -static SENSOR_DEVICE_ATTR(fan3_product_year_and_month, S_IRUGO, show_clei, 0, FAN3_CLEI_INDEX | PRODUCTDATE_INDEX << 8 ); -static SENSOR_DEVICE_ATTR(fan4_product_year_and_month, S_IRUGO, show_clei, 0, FAN4_CLEI_INDEX | PRODUCTDATE_INDEX << 8 ); -static SENSOR_DEVICE_ATTR(fan1_label_location_code, S_IRUGO, show_clei, 0, FAN1_CLEI_INDEX | LABELLOCATION_INDX << 8 ); -static SENSOR_DEVICE_ATTR(fan2_label_location_code, S_IRUGO, show_clei, 0, FAN2_CLEI_INDEX | LABELLOCATION_INDX << 8 ); -static SENSOR_DEVICE_ATTR(fan3_label_location_code, S_IRUGO, show_clei, 0, FAN3_CLEI_INDEX | LABELLOCATION_INDX << 8 ); -static SENSOR_DEVICE_ATTR(fan4_label_location_code, S_IRUGO, show_clei, 0, FAN4_CLEI_INDEX | LABELLOCATION_INDX << 8 ); -static SENSOR_DEVICE_ATTR(fan1_serial_number, S_IRUGO, show_clei, 0, FAN1_CLEI_INDEX | SERIALNUMBER_INDEX << 8 ); -static SENSOR_DEVICE_ATTR(fan2_serial_number, S_IRUGO, show_clei, 0, FAN2_CLEI_INDEX | SERIALNUMBER_INDEX << 8 ); -static SENSOR_DEVICE_ATTR(fan3_serial_number, S_IRUGO, show_clei, 0, FAN3_CLEI_INDEX | SERIALNUMBER_INDEX << 8 ); -static SENSOR_DEVICE_ATTR(fan4_serial_number, S_IRUGO, show_clei, 0, FAN4_CLEI_INDEX | SERIALNUMBER_INDEX << 8 ); -static SENSOR_DEVICE_ATTR(fan1_pcb_revision, S_IRUGO, show_clei, 0, FAN1_CLEI_INDEX | PCBREVISION_INDEX << 8 ); -static SENSOR_DEVICE_ATTR(fan2_pcb_revision, S_IRUGO, show_clei, 0, FAN2_CLEI_INDEX | PCBREVISION_INDEX << 8 ); -static SENSOR_DEVICE_ATTR(fan3_pcb_revision, S_IRUGO, show_clei, 0, FAN3_CLEI_INDEX | PCBREVISION_INDEX << 8 ); -static SENSOR_DEVICE_ATTR(fan4_pcb_revision, S_IRUGO, show_clei, 0, FAN4_CLEI_INDEX | PCBREVISION_INDEX << 8 ); - -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(fan1_led_grn, S_IWUSR|S_IRUGO, show_fan_led, set_fan_led, 0); -static SENSOR_DEVICE_ATTR(fan2_led_grn, S_IWUSR|S_IRUGO, show_fan_led, set_fan_led, 1); -static SENSOR_DEVICE_ATTR(fan3_led_grn, S_IWUSR|S_IRUGO, show_fan_led, set_fan_led, 2); -static SENSOR_DEVICE_ATTR(fan4_led_grn, S_IWUSR|S_IRUGO, show_fan_led, set_fan_led, 3); -static SENSOR_DEVICE_ATTR(fan1_led_red, S_IWUSR|S_IRUGO, show_fan_led, set_fan_led, 4); -static SENSOR_DEVICE_ATTR(fan2_led_red, S_IWUSR|S_IRUGO, show_fan_led, set_fan_led, 5); -static SENSOR_DEVICE_ATTR(fan3_led_red, S_IWUSR|S_IRUGO, show_fan_led, set_fan_led, 6); -static SENSOR_DEVICE_ATTR(fan4_led_red, 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); -#if 0 -static SENSOR_DEVICE_ATTR(psu1_vin, S_IRUGO, show_psu, 0, PMBUS_READ_VIN); -static SENSOR_DEVICE_ATTR(psu1_vout, S_IRUGO, show_psu, 0, PMBUS_READ_VOUT); -static SENSOR_DEVICE_ATTR(psu1_iin, S_IRUGO, show_psu, 0, PMBUS_READ_IIN); -static SENSOR_DEVICE_ATTR(psu1_iout, S_IRUGO, show_psu, 0, PMBUS_READ_IOUT); -static SENSOR_DEVICE_ATTR(psu1_pin, S_IRUGO, show_psu, 0, PMBUS_READ_PIN); -static SENSOR_DEVICE_ATTR(psu1_pout, S_IRUGO, show_psu, 0, PMBUS_READ_POUT); - - -static SENSOR_DEVICE_ATTR(psu2_vin, S_IRUGO, show_psu, 0, (1<<16) | PMBUS_READ_VIN); -static SENSOR_DEVICE_ATTR(psu2_vout, S_IRUGO, show_psu, 0, (1<<16) | PMBUS_READ_VOUT); -static SENSOR_DEVICE_ATTR(psu2_iin, S_IRUGO, show_psu, 0, (1<<16) | PMBUS_READ_IIN); -static SENSOR_DEVICE_ATTR(psu2_iout, S_IRUGO, show_psu, 0, (1<<16) | PMBUS_READ_IOUT); -static SENSOR_DEVICE_ATTR(psu2_pin, S_IRUGO, show_psu, 0, (1<<16) | PMBUS_READ_PIN); -static SENSOR_DEVICE_ATTR(psu2_pout, S_IRUGO, show_psu, 0, (1<<16) | PMBUS_READ_POUT); -#endif - -static SENSOR_DEVICE_ATTR(psoc_psu1_vin, S_IRUGO, show_psu_psoc, 0, (0x02<<8)|PSOC_PSU_OFF(psu1_vin)); -static SENSOR_DEVICE_ATTR(psoc_psu1_vout, S_IRUGO, show_psu_psoc, 0, (0x02<<8)|PSOC_PSU_OFF(psu1_vout)); -static SENSOR_DEVICE_ATTR(psoc_psu1_iin, S_IRUGO, show_psu_psoc, 0, (0x02<<8)|PSOC_PSU_OFF(psu1_iin)); -static SENSOR_DEVICE_ATTR(psoc_psu1_iout, S_IRUGO, show_psu_psoc, 0, (0x02<<8)|PSOC_PSU_OFF(psu1_iout)); -static SENSOR_DEVICE_ATTR(psoc_psu1_pin, S_IRUGO, show_psu_psoc, 0, (0x02<<8)|PSOC_PSU_OFF(psu1_pin)); -static SENSOR_DEVICE_ATTR(psoc_psu1_pout, S_IRUGO, show_psu_psoc, 0, (0x02<<8)|PSOC_PSU_OFF(psu1_pout)); - - -static SENSOR_DEVICE_ATTR(psoc_psu2_vin, S_IRUGO, show_psu_psoc, 0, (0x02<<8)|PSOC_PSU_OFF(psu2_vin)); -static SENSOR_DEVICE_ATTR(psoc_psu2_vout, S_IRUGO, show_psu_psoc, 0, (0x02<<8)|PSOC_PSU_OFF(psu2_vout)); -static SENSOR_DEVICE_ATTR(psoc_psu2_iin, S_IRUGO, show_psu_psoc, 0, (0x02<<8)|PSOC_PSU_OFF(psu2_iin)); -static SENSOR_DEVICE_ATTR(psoc_psu2_iout, S_IRUGO, show_psu_psoc, 0, (0x02<<8)|PSOC_PSU_OFF(psu2_iout)); -static SENSOR_DEVICE_ATTR(psoc_psu2_pin, S_IRUGO, show_psu_psoc, 0, (0x02<<8)|PSOC_PSU_OFF(psu2_pin)); -static SENSOR_DEVICE_ATTR(psoc_psu2_pout, S_IRUGO, show_psu_psoc, 0, (0x02<<8)|PSOC_PSU_OFF(psu2_pout)); - -static SENSOR_DEVICE_ATTR(psoc_psu1_vendor, S_IRUGO, show_psu_psoc, 0, (0x10<<8)|PSOC_PSU_OFF(psu1_vendor)); -static SENSOR_DEVICE_ATTR(psoc_psu1_model, S_IRUGO, show_psu_psoc, 0, (0x14<<8)|PSOC_PSU_OFF(psu1_model)); -static SENSOR_DEVICE_ATTR(psoc_psu1_version, S_IRUGO, show_psu_psoc, 0, (0x08<<8)|PSOC_PSU_OFF(psu1_version)); -static SENSOR_DEVICE_ATTR(psoc_psu1_date, S_IRUGO, show_psu_psoc, 0, (0x06<<8)|PSOC_PSU_OFF(psu1_date)); -static SENSOR_DEVICE_ATTR(psoc_psu1_sn, S_IRUGO, show_psu_psoc, 0, (0x14<<8)|PSOC_PSU_OFF(psu1_sn)); -static SENSOR_DEVICE_ATTR(psoc_psu2_vendor, S_IRUGO, show_psu_psoc, 0, (0x10<<8)|PSOC_PSU_OFF(psu2_vendor)); -static SENSOR_DEVICE_ATTR(psoc_psu2_model, S_IRUGO, show_psu_psoc, 0, (0x14<<8)|PSOC_PSU_OFF(psu2_model)); -static SENSOR_DEVICE_ATTR(psoc_psu2_version, S_IRUGO, show_psu_psoc, 0, (0x08<<8)|PSOC_PSU_OFF(psu2_version)); -static SENSOR_DEVICE_ATTR(psoc_psu2_date, S_IRUGO, show_psu_psoc, 0, (0x06<<8)|PSOC_PSU_OFF(psu2_date)); -static SENSOR_DEVICE_ATTR(psoc_psu2_sn, S_IRUGO, show_psu_psoc, 0, (0x14<<8)|PSOC_PSU_OFF(psu2_sn)); - -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, - - //clei - &sensor_dev_attr_fan1_issue_number.dev_attr.attr, - &sensor_dev_attr_fan2_issue_number.dev_attr.attr, - &sensor_dev_attr_fan3_issue_number.dev_attr.attr, - &sensor_dev_attr_fan4_issue_number.dev_attr.attr, - &sensor_dev_attr_fan1_abbreviation_number.dev_attr.attr, - &sensor_dev_attr_fan2_abbreviation_number.dev_attr.attr, - &sensor_dev_attr_fan3_abbreviation_number.dev_attr.attr, - &sensor_dev_attr_fan4_abbreviation_number.dev_attr.attr, - &sensor_dev_attr_fan1_fc_number.dev_attr.attr, - &sensor_dev_attr_fan2_fc_number.dev_attr.attr, - &sensor_dev_attr_fan3_fc_number.dev_attr.attr, - &sensor_dev_attr_fan4_fc_number.dev_attr.attr, - &sensor_dev_attr_fan1_clei_code.dev_attr.attr, - &sensor_dev_attr_fan2_clei_code.dev_attr.attr, - &sensor_dev_attr_fan3_clei_code.dev_attr.attr, - &sensor_dev_attr_fan4_clei_code.dev_attr.attr, - - &sensor_dev_attr_fan1_product_year_and_month.dev_attr.attr, - &sensor_dev_attr_fan2_product_year_and_month.dev_attr.attr, - &sensor_dev_attr_fan3_product_year_and_month.dev_attr.attr, - &sensor_dev_attr_fan4_product_year_and_month.dev_attr.attr, - &sensor_dev_attr_fan1_label_location_code.dev_attr.attr, - &sensor_dev_attr_fan2_label_location_code.dev_attr.attr, - &sensor_dev_attr_fan3_label_location_code.dev_attr.attr, - &sensor_dev_attr_fan4_label_location_code.dev_attr.attr, - &sensor_dev_attr_fan1_serial_number.dev_attr.attr, - &sensor_dev_attr_fan2_serial_number.dev_attr.attr, - &sensor_dev_attr_fan3_serial_number.dev_attr.attr, - &sensor_dev_attr_fan4_serial_number.dev_attr.attr, - &sensor_dev_attr_fan1_pcb_revision.dev_attr.attr, - &sensor_dev_attr_fan2_pcb_revision.dev_attr.attr, - &sensor_dev_attr_fan3_pcb_revision.dev_attr.attr, - &sensor_dev_attr_fan4_pcb_revision.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_fan1_led_grn.dev_attr.attr, - &sensor_dev_attr_fan2_led_grn.dev_attr.attr, - &sensor_dev_attr_fan3_led_grn.dev_attr.attr, - &sensor_dev_attr_fan4_led_grn.dev_attr.attr, - &sensor_dev_attr_fan1_led_red.dev_attr.attr, - &sensor_dev_attr_fan2_led_red.dev_attr.attr, - &sensor_dev_attr_fan3_led_red.dev_attr.attr, - &sensor_dev_attr_fan4_led_red.dev_attr.attr, - - //fan GPI - &sensor_dev_attr_fan_gpi.dev_attr.attr, - - //psu -#if 0 - &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, -#endif - &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, - - //add info - &sensor_dev_attr_psoc_psu1_vendor.dev_attr.attr, - &sensor_dev_attr_psoc_psu1_model.dev_attr.attr, - &sensor_dev_attr_psoc_psu1_version.dev_attr.attr, - &sensor_dev_attr_psoc_psu1_date.dev_attr.attr, - &sensor_dev_attr_psoc_psu1_sn.dev_attr.attr, - &sensor_dev_attr_psoc_psu2_vendor.dev_attr.attr, - &sensor_dev_attr_psoc_psu2_model.dev_attr.attr, - &sensor_dev_attr_psoc_psu2_version.dev_attr.attr, - &sensor_dev_attr_psoc_psu2_date.dev_attr.attr, - &sensor_dev_attr_psoc_psu2_sn.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; - } - data->auto_update = kthread_run(psoc_polling_thread,client,"%s",dev_name(data->hwmon_dev)); - if (IS_ERR(data->auto_update)) - { - status = PTR_ERR(data->auto_update); - goto exit_remove; - } - - dev_info(&client->dev, "%s: sensor '%s'\n", - dev_name(data->hwmon_dev), client->name); - - psoc_led_client_dev = &client->dev; - return 0; - -exit_remove: - sysfs_remove_group(&client->dev.kobj, &psoc_group); -exit_free: - i2c_set_clientdata(client, NULL); - kfree(data); - psoc_led_client_dev = NULL; - return status; -} - -static int psoc_remove(struct i2c_client *client) -{ - struct psoc_data *data = i2c_get_clientdata(client); - kthread_stop(data->auto_update); - hwmon_device_unregister(data->hwmon_dev); - sysfs_remove_group(&client->dev.kobj, &psoc_group); - i2c_set_clientdata(client, NULL); - kfree(data); - psoc_led_client_dev = NULL; - 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("Jack Ting "); -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/d3352/modules/builds/src/inv_pthread.c b/packages/platforms/inventec/x86-64/d3352/modules/builds/src/inv_pthread.c deleted file mode 100644 index 53a05b664..000000000 --- a/packages/platforms/inventec/x86-64/d3352/modules/builds/src/inv_pthread.c +++ /dev/null @@ -1,702 +0,0 @@ -/***************************** - Cottonwood(D5052) platform -******************************/ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "inv_pthread.h" - -#define INV_PTHREAD_KERNEL_MODULE - -#define SHOW_ATTR_WARNING ("N/A") -#define SHOW_ATTR_NOTPRINT ("Not Available") -#define SHOW_ATTR_NOTSUPPORT ("Not Support") - -#define INV_HWMID_MAX (10) -#define INV_HWMID_INIT (-1) - -/*access userspace data to kernel space*/ -#define ACC_R (0) -#define ACC_W (1) - -#define MAX_PATH_SIZE (64) -#define MIN_ACC_SIZE (32) -#define MAX_ACC_SIZE (256) - -/* - * LED definitions - */ -#define STATUS_LED_MODE_AUTO (0) -#define STATUS_LED_MODE_DIAG (1) -#define STATUS_LED_MODE_MANU (2) -#define STATUS_LED_MODE_ERR (-1) - -#define STATUS_LED_GRN0 (10) // 0 - 000: off -#define STATUS_LED_GRN1 (11) // 1 - 001: 0.5hz -#define STATUS_LED_GRN2 (12) // 2 - 010: 1 hz -#define STATUS_LED_GRN3 (13) // 3 - 011: 2 hz -#define STATUS_LED_GRN7 (17) // 7 - 111: on -#define STATUS_LED_RED0 (20) // 0 - 000: off -#define STATUS_LED_RED1 (21) // 1 - 001: 0.5hz -#define STATUS_LED_RED2 (22) // 2 - 010: 1 hz -#define STATUS_LED_RED3 (23) // 3 - 011: 2 hz -#define STATUS_LED_RED7 (27) // 7 - 111: on -#define STATUS_LED_INVALID (0) // Invalid - -static struct mutex pthread_mutex; - -unsigned int status_led_check_color(void); -int status_led_check_diag_mode(void); - -#if 1 -/* For timestamps in SYSFS_LOG */ -#define SYSFS_LOG printk -#else -//#define SYSFS_LOG(fmt, args...) printk(KERN_WARNING "[SYSFS] %s/%d: " fmt, __func__, __LINE__, ##args) -#define SYSFS_LOG(fmt, args...) printk(KERN_WARNING "[p_thread] " fmt, ##args) -#endif - - -/* inventec_class *********************************/ -static struct kobject *status_kobj; -static struct kset *status_kset; - -int inventec_singlechar_to_int(const char c) -{ - if ((c >= '0') && (c <= '9')) { - return (c - '0'); - } - else - if ((c >= 'a') && (c <= 'f')) { - return (c - 'a' + 10); - } - else - if ((c >= 'A') && (c <= 'F')) { - return (c - 'A' + 10); - } - return -1; -} - -/* fan device *************************************/ -#define FAN_STATE_NORMAL "normal" -#define FAN_STATE_FAULTY "faulty" -#define FAN_STATE_UNINSTALLED "uninstalled" -#define FAN_STATE_UNKNOW "unknown state" -#define FAN_STATE_INVALID "Invalid state value" -#define FAN_STATE_READ_ERROR "state read error" - -#define FAN_LOG_UNINSTALLED "removed" -#define FAN_LOG_NORMAL "inserted" - -#define FAN_STATE_BIT_FAULTY 0 -#define FAN_STATE_BIT_UNINSTALLED 1 -#define FAN_STATE_BIT_UNKNOW 2 -#define FAN_STATE_BIT_INVALID 3 -#define FAN_STATE_BIT_READ_ERROR 4 - -static ssize_t psoc_show_fan1_input(char *buf) -{ - return psoc_show_fan_input(buf, 1); -} - -static ssize_t psoc_show_fan2_input(char *buf) -{ - return psoc_show_fan_input(buf, 2); -} - -static ssize_t psoc_show_fan3_input(char *buf) -{ - return psoc_show_fan_input(buf, 3); -} - -static ssize_t psoc_show_fan4_input(char *buf) -{ - return psoc_show_fan_input(buf, 4); -} - -static struct fans_tbl_s { - char *fan_name; - ssize_t (*fan_front)(char *); - ssize_t (*fan_rear)(char *); - unsigned int fan_state; -} fans_tbl[] = { - {"fan1", psoc_show_fan1_input, - psoc_show_fan2_input, 0}, - {"fan2", psoc_show_fan3_input, - psoc_show_fan4_input, 0}, -}; -#define FAN_TBL_TOTAL ( sizeof(fans_tbl)/ sizeof(const struct fans_tbl_s) ) - -#define FAN_STATE_CHECK(i,b) (fans_tbl[i].fan_state & (1<inv_dev_attrp, PSU_ATTR_VOLTIN, PSU_ATTR_VOLTIN_LEN) == 0) { - invwirep = psu_get_show_function(PSU_ATTR_VOLTIN, psu_dev_group[i].psu_name, NULL); - if (invwirep == NULL) { - printk(KERN_DEBUG "[p_thread] Invalid psuname: %s\n", psu_dev_group[i].psu_name); - continue; - } - if (invwirep(volt) <= 0) { - printk(KERN_DEBUG "[p_thread] Read %s failed\n", psu_dev_group[i].psu_name); - continue; - } - else { - voltin = simple_strtol(&volt[0], NULL, 10); - printk(KERN_DEBUG "[p_thread] Read %s %s = %u\n",psu_dev_group[i].psu_name,volt,voltin); - if (voltin > psu_voltin) { - psu_voltin = voltin; - } - } - } - } - } - - //SYSFS_LOG("[p_thread] PSU voltin = %u\n", psu_voltin); -} - -#define PSU_ATTR_STATE ("state") -#define PSU_ATTR_STATE_LEN (5) - -/* psus_control() by inv_thread */ -int psus_control(int log_only) -{ - char state[MIN_ACC_SIZE]; - ssize_t sz = cpld_show_psu(state); - u8 st; - - if (sz < 1) { - cpld_set_pwr_led("0", 1); - return 0; - } - - st = simple_strtoul(&state[0], NULL, 16); - if (st == 0) { - cpld_set_pwr_led("1", 1); - } - else { - cpld_set_pwr_led("2", 1); - } - - return 0; -} - -/* End of psuinfo_device */ - -/* led device *************************************/ - -/* return 0/off 1/green 2/red */ -unsigned int -status_led_check_color(void) -{ - char tmpbuf[MIN_ACC_SIZE]; - int ret = STATUS_LED_INVALID; - - if (cpld_show_led(&tmpbuf[0], 4) > 0) { - return simple_strtoul(&tmpbuf[0], NULL, 16); - } - - return ret; -} - -/* - * Store attr Section - */ -ssize_t status_led_diag_mode_enable(void) -{ - char tmp[MIN_ACC_SIZE]; - ssize_t ret; - - ret = psoc_show_diag(&tmp[0]); - if (ret <= 0) { - return ret; - } - - if (tmp[0] == '0') { - ret = psoc_set_diag("1", 1); - if (ret < 0) { - return ret; - } - - ret = cpld_set_ctl("1", 1); - if (ret < 0) { - return ret; - } - } - - return ret; -} - -ssize_t status_led_diag_mode_disable(void) -{ - char tmp[MIN_ACC_SIZE]; - ssize_t ret; - - ret = psoc_show_diag(&tmp[0]); - if (ret <= 0) { - return ret; - } - - if (tmp[0] == '1') { - ret = psoc_set_diag("0", 1); - if (ret < 0) { - return 1; - } - - ret = cpld_set_ctl("1", 1); - if (ret < 0) { - return 1; - } - } - return 1; -} - - -int status_led_check_diag_mode(void) -{ - char tmp[MIN_ACC_SIZE]; - ssize_t ret; - - ret = psoc_show_diag(&tmp[0]); - if (ret <= 0) { - return ret; - } - - if (tmp[0] == '1') { - return STATUS_LED_MODE_DIAG; - } - - if (tmp[0] == '0') { - return STATUS_LED_MODE_AUTO; - } - - return -1; -} - -/* End of ledinfo_device */ - -/**************************************************/ -/* From system_device */ -static int inv_pthread_control = 1; - -int thread_control(void) -{ - return inv_pthread_control; -} - -void thread_control_set(int val) -{ - inv_pthread_control = val; -} -/* End system_device */ - -#define THREAD_SLEEP_MINS (3) -#define THREAD_DELAY_MINS (THREAD_SLEEP_MINS + THREAD_SLEEP_MINS + 1) - -static struct task_struct *thread_st; -static int thread_data; - -// Function executed by kernel thread -static int thread_fn(void *unused) -{ - mutex_init(&pthread_mutex); - - ssleep(THREAD_DELAY_MINS); - - /* Default status init */ - - mutex_lock(&pthread_mutex); - cpld_set_ctl("0x11", 4); - mutex_unlock(&pthread_mutex); - - psu_get_voltin(); - - mutex_lock(&pthread_mutex); - cpld_set_sys_led("1", 1); - cpld_set_stk_led("1", 1); // TBD: always ON now - mutex_unlock(&pthread_mutex); - - /* Delay for guarantee HW ready */ - ssleep(THREAD_DELAY_MINS); - - while (1) - { - mutex_unlock(&pthread_mutex); - ssleep(THREAD_SLEEP_MINS); - - if (thread_control() == 0) { - printk(KERN_INFO "[p_thread] %s/%d: Thread Stop by inv_pthread control\n",__func__,__LINE__); - break; - } - - mutex_lock(&pthread_mutex); - if (status_led_check_diag_mode() == STATUS_LED_MODE_MANU) { - /* status led in change color/freq mode, higher priority. Ignore fans sttaus */ - continue; - } - - fans_control(); - psus_control(0); - } - - do_exit(0); - printk(KERN_INFO "[p_thread] %s/%d: Thread Stopped\n",__func__,__LINE__); - return 0; -} - - -static ssize_t s_show(struct kobject *kobj, struct attribute *attr, char *buf) -{ - int fan_absence; - size_t count = 0; - - fan_absence = fans_control(); - count += sprintf(&buf[count], "%d\n", fan_absence); - return count; -} - -static ssize_t s_store(struct kobject *kobj, struct attribute *attr, const char *buf, size_t count) -{ - return count; -} - -static struct attribute status_att = { - .name = "fan_absence", - .mode = 0777, -}; - -static const struct sysfs_ops status_ops = { - .show = s_show, - .store = s_store, -}; - -static struct kobj_type status_ktype = { - .sysfs_ops = &status_ops, -}; - - -static int __init inv_pthread_init(void) -{ - int retval; - - status_kobj = kzalloc(sizeof(*status_kobj), GFP_KERNEL); - if(!status_kobj) - return PTR_ERR(status_kobj); - - status_kset = kset_create_and_add("platform_status", NULL, kernel_kobj); - if(!status_kset) - return -1; - - status_kobj->kset = status_kset; - - retval = kobject_init_and_add(status_kobj, &status_ktype, NULL, "fan"); - if(retval) - return retval; - - retval = sysfs_create_file(status_kobj, &status_att); - - thread_control_set(1); - - printk(KERN_INFO "[p_thread] %s/%d: Creating Thread\n",__func__,__LINE__); - //Create the kernel thread with name 'inv_pthread' - thread_st = kthread_run(thread_fn, (void*)&thread_data, "inv_pthread"); - if (thread_st) - printk(KERN_INFO "[p_thread] inv_pthread Created successfully\n"); - else - printk(KERN_ERR "[p_thread] inv_pthread creation failed\n"); - - return retval; -} - -static void __exit inv_pthread_exit(void) -{ - thread_control_set(0); - /* Delay for guarantee thread exit */ - ssleep(THREAD_DELAY_MINS); - - sysfs_remove_file(status_kobj, &status_att); - kset_unregister(status_kset); - kobject_del(status_kobj); - - printk(KERN_INFO "[p_thread] inv_pthread cleaning Up\n"); -} - -module_init(inv_pthread_init); -module_exit(inv_pthread_exit); - -MODULE_AUTHOR("Robert "); -MODULE_DESCRIPTION("Inventec Platform Management Thread"); -MODULE_VERSION("version 1.2"); -MODULE_LICENSE("GPL"); diff --git a/packages/platforms/inventec/x86-64/d3352/modules/builds/src/inv_pthread.h b/packages/platforms/inventec/x86-64/d3352/modules/builds/src/inv_pthread.h deleted file mode 100644 index f53a40564..000000000 --- a/packages/platforms/inventec/x86-64/d3352/modules/builds/src/inv_pthread.h +++ /dev/null @@ -1,47 +0,0 @@ -#ifndef INV_PTHREAD_H -#define INV_PTHREAD_H - -#define CPLD_DEV_LED_GRN_INDEX (0) -#define CPLD_DEV_LED_RED_INDEX (1) - -/* - * onlp_led_id should be same as in onlp/platform_lib.h - */ -enum onlp_led_id { - LED_RESERVED = 0, - LED_STK, - LED_FAN, - LED_PWR, - LED_SYS, - LED_FAN1, - LED_FAN2, - LED_MAX -}; - -typedef struct cpld_led_map_s { - char *name; - int bit_shift; - u8 bit_mask; - u8 led_off; - u8 led_on; - u8 led_blink; - u8 led_blink_slow; -} cpld_led_map_t; - -ssize_t cpld_show_psu(char *buf); -ssize_t cpld_show_led(char *buf, size_t count); - -ssize_t cpld_set_ctl(const char *buf, size_t count); -ssize_t cpld_set_sys_led(const char *buf, size_t count); -ssize_t cpld_set_pwr_led(const char *buf, size_t count); -ssize_t cpld_set_fan_led(const char *buf, size_t count); -ssize_t cpld_set_stk_led(const char *buf, size_t count); - -ssize_t psoc_show_psu_state(char *buf, int index); -ssize_t psoc_show_fan_input(char *buf, int index); -ssize_t psoc_show_fan_state(char *buf); -ssize_t psoc_show_psu_vin(char *buf, int index); -ssize_t psoc_show_diag(char *buf); -ssize_t psoc_set_diag(const char *buf, size_t count); - -#endif /* INV_PTHREAD_H */ diff --git a/packages/platforms/inventec/x86-64/d3352/modules/builds/src/inv_swps.c b/packages/platforms/inventec/x86-64/d3352/modules/builds/src/inv_swps.c deleted file mode 100644 index e5988f275..000000000 --- a/packages/platforms/inventec/x86-64/d3352/modules/builds/src/inv_swps.c +++ /dev/null @@ -1,3069 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "inv_swps.h" - -static int ctl_major; -static int port_major; -static int ioexp_total; -static int port_total; -static int auto_config; -static int flag_i2c_reset; -static int flag_mod_state; -static unsigned gpio_rest_mux; -static struct class *swp_class_p = NULL; -static struct inv_platform_s *platform_p = NULL; -static struct inv_ioexp_layout_s *ioexp_layout = NULL; -static struct inv_port_layout_s *port_layout = NULL; - -static void swp_polling_worker(struct work_struct *work); -static DECLARE_DELAYED_WORK(swp_polling, swp_polling_worker); - -static int reset_i2c_topology(void); - - -static int -__swp_match(struct device *dev, -#ifdef SWPS_KERN_VER_AF_3_10 - - const void *data){ -#else - void *data){ -#endif - - char *name = (char *)data; - if (strcmp(dev_name(dev), name) == 0) - return 1; - return 0; -} - - -struct device * -get_swpdev_by_name(char *name){ - struct device *dev = class_find_device(swp_class_p, - NULL, - name, - __swp_match); - return dev; -} - - -static int -sscanf_2_int(const char *buf) { - - int result = -EBFONT; - char *hex_tag = "0x"; - - if (strcspn(buf, hex_tag) == 0) { - if (sscanf(buf,"%x",&result)) { - return result; - } - } else { - if (sscanf(buf,"%d",&result)) { - return result; - } - if(sscanf(buf,"-%d",&result)) { - return -result; - } - if (sscanf(buf,"%x",&result)) { - return result; - } - } - return -EBFONT; -} - - -static int -sscanf_2_binary(const char *buf) { - - int result = sscanf_2_int(buf); - - if (result < 0){ - return -EBFONT; - } - switch (result) { - case 0: - case 1: - return result; - default: - break; - } - return -EBFONT; -} - - -static int -_get_polling_period(void) { - - int retval = 0; - - if (SWP_POLLING_PERIOD == 0) { - return 0; - } - retval = ((SWP_POLLING_PERIOD * HZ) / 1000); - if (retval == 0) { - return 1; - } - return retval; -} - - -static struct transvr_obj_s * -_get_transvr_obj(char *dev_name) { - - struct device *dev_p = NULL; - struct transvr_obj_s *transvr_obj_p = NULL; - - dev_p = get_swpdev_by_name(dev_name); - if (!dev_p){ - return NULL; - } - transvr_obj_p = dev_get_drvdata(dev_p); - if (!transvr_obj_p){ - return NULL; - } - return transvr_obj_p; -} - - -static void -unlock_tobj_all(void) { - - struct transvr_obj_s *tobj_p; - char port_name[32]; - int port_id = 0; - int minor_curr = 0; - - for (minor_curr=0; minor_currauto_config = auto_config; - unlock_transvr_obj(tobj_p); - SWPS_DEBUG("%s: Set %s auto_config=%d\n", - __func__, tobj_p->swp_name, auto_config); - } - return retval; -} - - -/* ========== R/W Functions module control attribute ========== - */ -static ssize_t -show_attr_platform(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - return snprintf(buf_p, 32, "%s\n", platform_p->name); -} - - -static ssize_t -show_attr_version(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - return snprintf(buf_p, 8, "%s\n", SWP_VERSION); -} - - -static ssize_t -show_attr_status(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - return snprintf(buf_p, 8, "%d\n", flag_mod_state); -} - - -static ssize_t -show_attr_auto_config(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - return snprintf(buf_p, 8, "%d\n", auto_config); -} - - -static int -_check_reset_pwd(const char *buf_p, - size_t count) { - - int in_max = 64; - int in_len = (int)count; - char in_val[64] = "ERR"; - char *emsg = "ERR"; - - if (in_len >= in_max) { - emsg = "input too much"; - goto err_check_reset_pwd; - } - if (!sscanf(buf_p,"%s",in_val)) { - emsg = "format incorrect"; - goto err_check_reset_pwd; - } - if (strcmp(in_val, SWP_RESET_PWD) != 0) { - emsg = "password incorrect"; - goto err_check_reset_pwd; - } - return 0; - -err_check_reset_pwd: - SWPS_ERR("%s: %s\n", __func__, emsg); - return -1; -} - - -static ssize_t -store_attr_reset_i2c(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - - if (_check_reset_pwd(buf_p, count) < 0) { - return -EBFONT; - } - /* Polling mode */ - if (SWP_POLLING_ENABLE) { - SWPS_INFO("%s: reset I2C :polling\n", __func__); - flag_i2c_reset = 1; - return count; - } - /* Direct mode */ - SWPS_INFO("%s: reset I2C go. :direct\n", __func__); - if (reset_i2c_topology() < 0) { - SWPS_ERR("%s: reset fail!\n", __func__); - return -EIO; - } - SWPS_INFO("%s: reset I2C ok. :direct\n", __func__); - return count; -} - - -static ssize_t -store_attr_reset_swps(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - - struct transvr_obj_s *tobj_p; - char port_name[32] = "ERR"; - int port_id = 0; - int minor_curr = 0; - - if (_check_reset_pwd(buf_p, count) < 0) { - return -EBFONT; - } - for (minor_curr=0; minor_currstate = STATE_TRANSVR_DISCONNECTED; - unlock_transvr_obj(tobj_p); - SWPS_INFO("%s: reset:%s\n", __func__, tobj_p->swp_name); - } - return count; -} - - -static ssize_t -store_attr_auto_config(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - - int input_val = sscanf_2_int(buf_p); - - if (input_val < 0){ - return -EBFONT; - } - if ((input_val != 0) && (input_val != 1)) { - return -EBFONT; - } - auto_config = input_val; - _update_auto_config_2_trnasvr(); - return count; -} - - -/* ========== Show functions: For transceiver attribute ========== - */ -static ssize_t -_show_transvr_hex_attr(struct transvr_obj_s* tobj_p, - int (*get_func)(struct transvr_obj_s* tobj_p), - char *buf_p) { - size_t len; - int result; - - lock_transvr_obj(tobj_p); - result = get_func(tobj_p); - unlock_transvr_obj(tobj_p); - if (result < 0){ - len = snprintf(buf_p, 8, "%d\n", result); - } else { - len = snprintf(buf_p, 8, "0x%02x\n", result); - } - return len; -} - - -static ssize_t -_show_transvr_int_attr(struct transvr_obj_s* tobj_p, - int (*get_func)(struct transvr_obj_s* tobj_p), - char *buf_p) { - size_t len; - - lock_transvr_obj(tobj_p); - len = snprintf(buf_p, 16, "%d\n", get_func(tobj_p)); - unlock_transvr_obj(tobj_p); - return len; -} - - -static ssize_t -_show_transvr_str_attr(struct transvr_obj_s* tobj_p, - int (*get_func)(struct transvr_obj_s* tobj_p, char* buf), - char *buf_p) { - size_t len; - - lock_transvr_obj(tobj_p); - len = get_func(tobj_p, buf_p); - unlock_transvr_obj(tobj_p); - return len; -} - - -static ssize_t -show_attr_id(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_hex_attr(tobj_p, - tobj_p->get_id, - buf_p); -} - -static ssize_t -show_attr_eeprom(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_eeprom, - buf_p); -} - -static ssize_t -show_attr_uppage(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_uppage, - buf_p); -} - - -static ssize_t -show_attr_ext_id(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_hex_attr(tobj_p, - tobj_p->get_ext_id, - buf_p); -} - - -static ssize_t -show_attr_connector(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_hex_attr(tobj_p, - tobj_p->get_connector, - buf_p); -} - - -static ssize_t -show_attr_vendor_name(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_vendor_name, - buf_p); -} - - -static ssize_t -show_attr_vendor_pn(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_vendor_pn, - buf_p); -} - - -static ssize_t -show_attr_vendor_rev(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_vendor_rev, - buf_p); -} - - -static ssize_t -show_attr_vendor_sn(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_vendor_sn, - buf_p); -} - - -static ssize_t -show_attr_power_cls(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - size_t len; - int result; - struct transvr_obj_s *tobj_p; - - tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - lock_transvr_obj(tobj_p); - result = tobj_p->get_power_cls(tobj_p); - unlock_transvr_obj(tobj_p); - if (result < 0){ - len = snprintf(buf_p, 16, "%d\n", result); - } else { - len = snprintf(buf_p, 16, "Power Class %d\n", result); - } - return len; -} - - -static ssize_t -show_attr_br(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_hex_attr(tobj_p, - tobj_p->get_br, - buf_p); -} - - -static ssize_t -show_attr_len_sm(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_int_attr(tobj_p, - tobj_p->get_len_sm, - buf_p); -} - - -static ssize_t -show_attr_len_smf(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_int_attr(tobj_p, - tobj_p->get_len_smf, - buf_p); -} - - -static ssize_t -show_attr_len_om1(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_int_attr(tobj_p, - tobj_p->get_len_om1, - buf_p); -} - - -static ssize_t -show_attr_len_om2(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_int_attr(tobj_p, - tobj_p->get_len_om2, - buf_p); -} - - -static ssize_t -show_attr_len_om3(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_int_attr(tobj_p, - tobj_p->get_len_om3, - buf_p); -} - - -static ssize_t -show_attr_len_om4(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_int_attr(tobj_p, - tobj_p->get_len_om4, - buf_p); -} - - -static ssize_t -show_attr_comp_rev(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_hex_attr(tobj_p, - tobj_p->get_comp_rev, - buf_p); -} - - -static ssize_t -show_attr_comp_eth(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_hex_attr(tobj_p, - tobj_p->get_comp_eth_1, - buf_p); -} - - -static ssize_t -show_attr_comp_eth_10(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_hex_attr(tobj_p, - tobj_p->get_comp_eth_10, - buf_p); -} - - -static ssize_t -show_attr_comp_eth_10_40(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_hex_attr(tobj_p, - tobj_p->get_comp_eth_10_40, - buf_p); -} - - -static ssize_t -show_attr_comp_extend(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_hex_attr(tobj_p, - tobj_p->get_comp_extend, - buf_p); -} - - -static ssize_t -show_attr_rate_id(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_hex_attr(tobj_p, - tobj_p->get_rate_id, - buf_p); -} - - -static ssize_t -show_attr_temperature(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_curr_temp, - buf_p); -} - - -static ssize_t -show_attr_voltage(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_curr_vol, - buf_p); -} - - -static ssize_t -show_attr_tx_bias(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_tx_bias, - buf_p); -} - - -static ssize_t -show_attr_tx_power(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_tx_power, - buf_p); -} - - -static ssize_t -show_attr_tx_eq(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_tx_eq, - buf_p); -} - - -static ssize_t -show_attr_rx_power(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_rx_power, - buf_p); -} - - -static ssize_t -show_attr_rx_am(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_rx_am, - buf_p); -} - - -static ssize_t -show_attr_rx_em(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_rx_em, - buf_p); -} - - -static ssize_t -show_attr_wavelength(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_wavelength, - buf_p); -} - - -static ssize_t -show_attr_extphy_offset(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_extphy_offset, - buf_p); -} - - -static ssize_t -show_attr_extphy_reg(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_extphy_reg, - buf_p); -} - - -static ssize_t -show_attr_info(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_int_attr(tobj_p, - tobj_p->get_info, - buf_p); -} - - -static ssize_t -show_attr_if_type(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_if_type, - buf_p); -} - - -static ssize_t -show_attr_if_speed(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_if_speed, - buf_p); -} - - -static ssize_t -show_attr_if_lane(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_if_lane, - buf_p); -} - - -static ssize_t -show_attr_cdr(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_hex_attr(tobj_p, - tobj_p->get_cdr, - buf_p); -} - - -static ssize_t -show_attr_soft_rs0(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_int_attr(tobj_p, - tobj_p->get_soft_rs0, - buf_p); -} - - -static ssize_t -show_attr_soft_rs1(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_int_attr(tobj_p, - tobj_p->get_soft_rs1, - buf_p); -} - - -static ssize_t -show_attr_soft_rx_los(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_soft_rx_los, - buf_p); -} - - -static ssize_t -show_attr_soft_tx_disable(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_soft_tx_disable, - buf_p); -} - - -static ssize_t -show_attr_soft_tx_fault(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_soft_tx_fault, - buf_p); -} - - -static ssize_t -show_attr_auto_tx_disable(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_auto_tx_disable, - buf_p); -} - - -/* ========== Store functions: transceiver (R/W) attribute ========== - */ -static ssize_t -_store_transvr_int_attr(struct transvr_obj_s* tobj_p, - int (*set_func)(struct transvr_obj_s *tobj_p, int input_val), - const char *buf_p, - size_t count) { - int input, err; - - input = sscanf_2_int(buf_p); - if (input < 0){ - return -EBFONT; - } - lock_transvr_obj(tobj_p); - err = set_func(tobj_p, input); - unlock_transvr_obj(tobj_p); - if (err < 0){ - return err; - } - return count; -} - - -static ssize_t -_store_transvr_byte_hex_attr(struct transvr_obj_s* tobj_p, - int (*set_func)(struct transvr_obj_s *tobj_p, int input_val), - const char *buf_p, - size_t count) { - int input, err; - - input = sscanf_2_int(buf_p); - if ((input < 0) || (input > 0xff)){ - return -EBFONT; - } - lock_transvr_obj(tobj_p); - err = set_func(tobj_p, input); - unlock_transvr_obj(tobj_p); - if (err < 0){ - return err; - } - return count; -} - - -static ssize_t -_store_transvr_binary_attr(struct transvr_obj_s* tobj_p, - int (*set_func)(struct transvr_obj_s *tobj_p, int input_val), - const char *buf_p, - size_t count) { - int input, err; - - input = sscanf_2_binary(buf_p); - if (input < 0){ - return -EBFONT; - } - lock_transvr_obj(tobj_p); - err = set_func(tobj_p, input); - unlock_transvr_obj(tobj_p); - if (err < 0){ - return err; - } - return count; -} - - -static ssize_t -store_attr_cdr(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - return _store_transvr_byte_hex_attr(tobj_p, - tobj_p->set_cdr, - buf_p, - count); -} - - -static ssize_t -store_attr_soft_rs0(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - return _store_transvr_binary_attr(tobj_p, - tobj_p->set_soft_rs0, - buf_p, - count); -} - - -static ssize_t -store_attr_soft_rs1(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - return _store_transvr_binary_attr(tobj_p, - tobj_p->set_soft_rs1, - buf_p, - count); -} - - -static ssize_t -store_attr_soft_tx_disable(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count) { - - int check = sscanf_2_int(buf_p); - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - if ((check < 0) || (check > 0xf)){ - return -EBFONT; - } - return _store_transvr_byte_hex_attr(tobj_p, - tobj_p->set_soft_tx_disable, - buf_p, - count); -} - - -static ssize_t -store_attr_auto_tx_disable(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count) { - - int err = -EPERM; - int input = sscanf_2_int(buf_p); - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - if ((input < 0) || (input > 0xf)){ - if (input != VAL_TRANSVR_FUNCTION_DISABLE) { - return -EBFONT; - } - } - lock_transvr_obj(tobj_p); - err = tobj_p->set_auto_tx_disable(tobj_p, input); - unlock_transvr_obj(tobj_p); - if (err < 0){ - return err; - } - return count; -} - - -static ssize_t -store_attr_tx_eq(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - return _store_transvr_int_attr(tobj_p, - tobj_p->set_tx_eq, - buf_p, - count); -} - - -static ssize_t -store_attr_rx_am(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - return _store_transvr_int_attr(tobj_p, - tobj_p->set_rx_am, - buf_p, - count); -} - - -static ssize_t -store_attr_rx_em(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - return _store_transvr_int_attr(tobj_p, - tobj_p->set_rx_em, - buf_p, - count); -} - - -static ssize_t -store_attr_extphy_offset(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - return _store_transvr_int_attr(tobj_p, - tobj_p->set_extphy_offset, - buf_p, - count); -} - - -static ssize_t -store_attr_extphy_reg(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - return _store_transvr_int_attr(tobj_p, - tobj_p->set_extphy_reg, - buf_p, - count); -} - -/* ========== Show functions: For I/O Expander attribute ========== - */ -static ssize_t -_show_ioexp_binary_attr(struct transvr_obj_s *tobj_p, - int (*get_func)(struct ioexp_obj_s *ioexp_p, int voffset), - char *buf_p) { - size_t len; - struct ioexp_obj_s *ioexp_p = tobj_p->ioexp_obj_p; - - if (!ioexp_p) { - SWPS_ERR(" %s: data corruption! :%s\n", __func__, tobj_p->swp_name); - return -ENODATA; - } - mutex_lock(&ioexp_p->lock); - len = snprintf(buf_p, 8, "%d\n", get_func(ioexp_p, tobj_p->ioexp_virt_offset)); - mutex_unlock(&ioexp_p->lock); - return len; -} - - -static ssize_t -show_attr_present(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - return _show_ioexp_binary_attr(tobj_p, - tobj_p->ioexp_obj_p->get_present, - buf_p); -} - - -static ssize_t -show_attr_tx_fault(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - return _show_ioexp_binary_attr(tobj_p, - tobj_p->ioexp_obj_p->get_tx_fault, - buf_p); -} - - -static ssize_t -show_attr_rxlos(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - return _show_ioexp_binary_attr(tobj_p, - tobj_p->ioexp_obj_p->get_rxlos, - buf_p); -} - - -static ssize_t -show_attr_tx_disable(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - return _show_ioexp_binary_attr(tobj_p, - tobj_p->ioexp_obj_p->get_tx_disable, - buf_p); -} - - -static ssize_t -show_attr_reset(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - return _show_ioexp_binary_attr(tobj_p, - tobj_p->ioexp_obj_p->get_reset, - buf_p); -} - - -static ssize_t -show_attr_lpmod(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - return _show_ioexp_binary_attr(tobj_p, - tobj_p->ioexp_obj_p->get_lpmod, - buf_p); -} - - -static ssize_t -show_attr_modsel(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - return _show_ioexp_binary_attr(tobj_p, - tobj_p->ioexp_obj_p->get_modsel, - buf_p); -} - - -static ssize_t -show_attr_hard_rs0(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - return _show_ioexp_binary_attr(tobj_p, - tobj_p->ioexp_obj_p->get_hard_rs0, - buf_p); -} - - -static ssize_t -show_attr_hard_rs1(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - return _show_ioexp_binary_attr(tobj_p, - tobj_p->ioexp_obj_p->get_hard_rs1, - buf_p); -} - - -/* ========== Store functions: For I/O Expander (R/W) attribute ========== - */ -static ssize_t -_store_ioexp_binary_attr(struct transvr_obj_s *tobj_p, - int (*set_func)(struct ioexp_obj_s *ioexp_p, - int virt_offset, int input_val), - const char *buf_p, - size_t count) { - - int input, err; - struct ioexp_obj_s *ioexp_p = tobj_p->ioexp_obj_p; - - if (!ioexp_p) { - SWPS_ERR("%s: data corruption! :%s\n", - __func__, tobj_p->swp_name); - return -ENODATA; - } - input = sscanf_2_binary(buf_p); - if (input < 0) { - return -EBFONT; - } - mutex_lock(&ioexp_p->lock); - err = set_func(ioexp_p, tobj_p->ioexp_virt_offset, input); - mutex_unlock(&ioexp_p->lock); - if (err < 0){ - return err; - } - return count; -} - -static ssize_t -store_attr_tx_disable(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p) { - return -ENODEV; - } - return _store_ioexp_binary_attr(tobj_p, - tobj_p->ioexp_obj_p->set_tx_disable, - buf_p, - count); -} - - -static ssize_t -store_attr_reset(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p) { - return -ENODEV; - } - return _store_ioexp_binary_attr(tobj_p, - tobj_p->ioexp_obj_p->set_reset, - buf_p, - count); -} - - -static ssize_t -store_attr_lpmod(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p) { - return -ENODEV; - } - return _store_ioexp_binary_attr(tobj_p, - tobj_p->ioexp_obj_p->set_lpmod, - buf_p, - count); -} - - -static ssize_t -store_attr_modsel(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p) { - return -ENODEV; - } - return _store_ioexp_binary_attr(tobj_p, - tobj_p->ioexp_obj_p->set_modsel, - buf_p, - count); -} - - -static ssize_t -store_attr_hard_rs0(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p) { - return -ENODEV; - } - return _store_ioexp_binary_attr(tobj_p, - tobj_p->ioexp_obj_p->set_hard_rs0, - buf_p, - count); -} - - -static ssize_t -store_attr_hard_rs1(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p) { - return -ENODEV; - } - return _store_ioexp_binary_attr(tobj_p, - tobj_p->ioexp_obj_p->set_hard_rs1, - buf_p, - count); -} - - -/* ========== SWPS attribute: For module control ========== - */ -static DEVICE_ATTR(platform, S_IRUGO, show_attr_platform, NULL); -static DEVICE_ATTR(version, S_IRUGO, show_attr_version, NULL); -static DEVICE_ATTR(status, S_IRUGO, show_attr_status, NULL); -static DEVICE_ATTR(reset_i2c, S_IWUSR, NULL, store_attr_reset_i2c); -static DEVICE_ATTR(reset_swps, S_IWUSR, NULL, store_attr_reset_swps); -static DEVICE_ATTR(auto_config, S_IRUGO|S_IWUSR, show_attr_auto_config, store_attr_auto_config); - -/* ========== Transceiver attribute: from eeprom ========== - */ -static DEVICE_ATTR(id, S_IRUGO, show_attr_id, NULL); -static DEVICE_ATTR(ext_id, S_IRUGO, show_attr_ext_id, NULL); -static DEVICE_ATTR(connector, S_IRUGO, show_attr_connector, NULL); -static DEVICE_ATTR(vendor_name, S_IRUGO, show_attr_vendor_name, NULL); -static DEVICE_ATTR(vendor_pn, S_IRUGO, show_attr_vendor_pn, NULL); -static DEVICE_ATTR(vendor_rev, S_IRUGO, show_attr_vendor_rev, NULL); -static DEVICE_ATTR(vendor_sn, S_IRUGO, show_attr_vendor_sn, NULL); -static DEVICE_ATTR(power_cls, S_IRUGO, show_attr_power_cls, NULL); -static DEVICE_ATTR(br, S_IRUGO, show_attr_br, NULL); -static DEVICE_ATTR(len_sm, S_IRUGO, show_attr_len_sm, NULL); -static DEVICE_ATTR(len_smf, S_IRUGO, show_attr_len_smf, NULL); -static DEVICE_ATTR(len_om1, S_IRUGO, show_attr_len_om1, NULL); -static DEVICE_ATTR(len_om2, S_IRUGO, show_attr_len_om2, NULL); -static DEVICE_ATTR(len_om3, S_IRUGO, show_attr_len_om3, NULL); -static DEVICE_ATTR(len_om4, S_IRUGO, show_attr_len_om4, NULL); -static DEVICE_ATTR(comp_rev, S_IRUGO, show_attr_comp_rev, NULL); -static DEVICE_ATTR(comp_eth, S_IRUGO, show_attr_comp_eth, NULL); -static DEVICE_ATTR(comp_eth_10, S_IRUGO, show_attr_comp_eth_10, NULL); -static DEVICE_ATTR(comp_eth_10_40, S_IRUGO, show_attr_comp_eth_10_40, NULL); -static DEVICE_ATTR(comp_extend, S_IRUGO, show_attr_comp_extend, NULL); -static DEVICE_ATTR(rate_id, S_IRUGO, show_attr_rate_id, NULL); -static DEVICE_ATTR(temperature, S_IRUGO, show_attr_temperature, NULL); -static DEVICE_ATTR(voltage, S_IRUGO, show_attr_voltage, NULL); -static DEVICE_ATTR(tx_bias, S_IRUGO, show_attr_tx_bias, NULL); -static DEVICE_ATTR(tx_power, S_IRUGO, show_attr_tx_power, NULL); -static DEVICE_ATTR(rx_power, S_IRUGO, show_attr_rx_power, NULL); -static DEVICE_ATTR(info, S_IRUGO, show_attr_info, NULL); -static DEVICE_ATTR(if_type, S_IRUGO, show_attr_if_type, NULL); -static DEVICE_ATTR(if_speed, S_IRUGO, show_attr_if_speed, NULL); -static DEVICE_ATTR(if_lane, S_IRUGO, show_attr_if_lane, NULL); -static DEVICE_ATTR(soft_rx_los, S_IRUGO, show_attr_soft_rx_los, NULL); -static DEVICE_ATTR(soft_tx_fault, S_IRUGO, show_attr_soft_tx_fault, NULL); -static DEVICE_ATTR(wavelength, S_IRUGO, show_attr_wavelength, NULL); -static DEVICE_ATTR(tx_eq, S_IRUGO|S_IWUSR, show_attr_tx_eq, store_attr_tx_eq); -static DEVICE_ATTR(rx_am, S_IRUGO|S_IWUSR, show_attr_rx_am, store_attr_rx_am); -static DEVICE_ATTR(rx_em, S_IRUGO|S_IWUSR, show_attr_rx_em, store_attr_rx_em); -static DEVICE_ATTR(cdr, S_IRUGO|S_IWUSR, show_attr_cdr, store_attr_cdr); -static DEVICE_ATTR(soft_rs0, S_IRUGO|S_IWUSR, show_attr_soft_rs0, store_attr_soft_rs0); -static DEVICE_ATTR(soft_rs1, S_IRUGO|S_IWUSR, show_attr_soft_rs1, store_attr_soft_rs1); -static DEVICE_ATTR(soft_tx_disable, S_IRUGO|S_IWUSR, show_attr_soft_tx_disable, store_attr_soft_tx_disable); -static DEVICE_ATTR(auto_tx_disable, S_IRUGO|S_IWUSR, show_attr_auto_tx_disable, store_attr_auto_tx_disable); -static DEVICE_ATTR(extphy_offset, S_IRUGO|S_IWUSR, show_attr_extphy_offset, store_attr_extphy_offset); -static DEVICE_ATTR(extphy_reg, S_IRUGO|S_IWUSR, show_attr_extphy_reg, store_attr_extphy_reg); -static DEVICE_ATTR(eeprom, S_IRUGO, show_attr_eeprom, NULL); -static DEVICE_ATTR(uppage, S_IRUGO, show_attr_uppage, NULL); - -/* ========== IO Expander attribute: from expander ========== - */ -static DEVICE_ATTR(present, S_IRUGO, show_attr_present, NULL); -static DEVICE_ATTR(tx_fault, S_IRUGO, show_attr_tx_fault, NULL); -static DEVICE_ATTR(rxlos, S_IRUGO, show_attr_rxlos, NULL); -static DEVICE_ATTR(tx_disable, S_IRUGO|S_IWUSR, show_attr_tx_disable, store_attr_tx_disable); -static DEVICE_ATTR(reset, S_IRUGO|S_IWUSR, show_attr_reset, store_attr_reset); -static DEVICE_ATTR(lpmod, S_IRUGO|S_IWUSR, show_attr_lpmod, store_attr_lpmod); -static DEVICE_ATTR(modsel, S_IRUGO|S_IWUSR, show_attr_modsel, store_attr_modsel); -static DEVICE_ATTR(hard_rs0, S_IRUGO|S_IWUSR, show_attr_hard_rs0, store_attr_hard_rs0); -static DEVICE_ATTR(hard_rs1, S_IRUGO|S_IWUSR, show_attr_hard_rs1, store_attr_hard_rs1); - -/* ========== Functions for module handling ========== - */ -static void -clean_port_obj(void){ - - dev_t dev_num; - char dev_name[32]; - struct device *device_p; - struct transvr_obj_s *transvr_obj_p; - int minor_curr, port_id; - - for (minor_curr=0; minor_curri2c_client_p); - kfree(transvr_obj_p->vendor_name); - kfree(transvr_obj_p->vendor_pn); - kfree(transvr_obj_p->vendor_rev); - kfree(transvr_obj_p->vendor_sn); - kfree(transvr_obj_p->worker_p); - kfree(transvr_obj_p); - } - dev_num = MKDEV(port_major, minor_curr); - device_unregister(device_p); - device_destroy(swp_class_p, dev_num); - } - SWPS_DEBUG("%s: done.\n", __func__); -} - - -static void -clean_swps_common(void){ - - dev_t dev_num; - struct device *device_p; - - device_p = get_swpdev_by_name(SWP_DEV_MODCTL); - if (device_p){ - dev_num = MKDEV(ctl_major, 1); - device_unregister(device_p); - device_destroy(swp_class_p, dev_num); - } - cancel_delayed_work_sync(&swp_polling); - SWPS_DEBUG("%s: done.\n", __func__); -} - - -static int -get_platform_type(void){ - - int i; - int pf_total = ARRAY_SIZE(platform_map); - char log_msg[64] = "ERROR"; - - platform_p = kzalloc(sizeof(struct inv_platform_s), GFP_KERNEL); - if (!platform_p){ - snprintf(log_msg, sizeof(log_msg), "kzalloc fail"); - goto err_get_platform_type_1; - } - memset(platform_p->name, 0, sizeof(platform_p->name)); - - switch (PLATFORM_SETTINGS) { - case PLATFORM_TYPE_AUTO: - snprintf(platform_p->name, (sizeof(platform_p->name) - 1), - "%s", dmi_get_system_info(DMI_BOARD_NAME)); - for (i=0; iname, platform_map[i].name) == 0) { - platform_p->id = platform_map[i].id; - snprintf(log_msg, sizeof(log_msg), - "Auto detect platform: %d (%s)", - platform_p->id, platform_p->name); - goto ok_get_platform_type_1; - } - } - snprintf(log_msg, sizeof(log_msg), - "Auto detect fail! detect platform: %s", - platform_p->name); - goto err_get_platform_type_2; - - case PLATFORM_TYPE_MAGNOLIA: - case PLATFORM_TYPE_MAGNOLIA_FNC: - case PLATFORM_TYPE_REDWOOD: - case PLATFORM_TYPE_REDWOOD_FSL: - case PLATFORM_TYPE_HUDSON32I_GA: - case PLATFORM_TYPE_SPRUCE: - case PLATFORM_TYPE_CYPRESS_GA1: - case PLATFORM_TYPE_CYPRESS_GA2: - case PLATFORM_TYPE_CYPRESS_BAI: - case PLATFORM_TYPE_TAHOE: - case PLATFORM_TYPE_SEQUOIA_GA: - case PLATFORM_TYPE_LAVENDER_GA: - case PLATFORM_TYPE_LAVENDER_ONL: - case PLATFORM_TYPE_COTTONWOOD_RANGELEY: - platform_p->id = PLATFORM_SETTINGS; - for (i=0; iname, (sizeof(platform_p->name) - 1), - "%s", platform_map[i].name); - snprintf(log_msg, sizeof(log_msg), - "User setup platform: %d (%s)", - platform_p->id, platform_p->name); - goto ok_get_platform_type_1; - } - } - snprintf(log_msg, sizeof(log_msg), - "Internal error, can not map id:%d", - PLATFORM_SETTINGS); - goto err_get_platform_type_2; - - default: - break; - } - snprintf(log_msg, sizeof(log_msg), - "PLATFORM_SETTINGS:%d undefined", PLATFORM_SETTINGS); - goto err_get_platform_type_2; - -ok_get_platform_type_1: - SWPS_DEBUG("%s: %s, :%d\n", __func__, log_msg, PLATFORM_SETTINGS); - return 0; - -err_get_platform_type_2: - kfree(platform_p); -err_get_platform_type_1: - SWPS_ERR("%s: %s :%d\n", __func__, log_msg, PLATFORM_SETTINGS); - return -1; -} - - -static int -get_layout_info(void){ - - switch (platform_p->id) { -#ifdef SWPS_MAGNOLIA - case PLATFORM_TYPE_MAGNOLIA: - case PLATFORM_TYPE_MAGNOLIA_FNC: - gpio_rest_mux = magnolia_gpio_rest_mux; - ioexp_layout = magnolia_ioexp_layout; - port_layout = magnolia_port_layout; - ioexp_total = ARRAY_SIZE(magnolia_ioexp_layout); - port_total = ARRAY_SIZE(magnolia_port_layout); - break; -#endif -#ifdef SWPS_REDWOOD - case PLATFORM_TYPE_REDWOOD: - gpio_rest_mux = redwood_gpio_rest_mux; - ioexp_layout = redwood_ioexp_layout; - port_layout = redwood_port_layout; - ioexp_total = ARRAY_SIZE(redwood_ioexp_layout); - port_total = ARRAY_SIZE(redwood_port_layout); - break; -#endif -#ifdef SWPS_HUDSON32I_GA - case PLATFORM_TYPE_HUDSON32I_GA: - gpio_rest_mux = hudsin32iga_gpio_rest_mux; - ioexp_layout = hudson32iga_ioexp_layout; - port_layout = hudson32iga_port_layout; - ioexp_total = ARRAY_SIZE(hudson32iga_ioexp_layout); - port_total = ARRAY_SIZE(hudson32iga_port_layout); - break; -#endif -#ifdef SWPS_SPRUCE - case PLATFORM_TYPE_SPRUCE: - gpio_rest_mux = spruce_gpio_rest_mux; - ioexp_layout = spruce_ioexp_layout; - port_layout = spruce_port_layout; - ioexp_total = ARRAY_SIZE(spruce_ioexp_layout); - port_total = ARRAY_SIZE(spruce_port_layout); - break; -#endif -#ifdef SWPS_CYPRESS_GA1 - case PLATFORM_TYPE_CYPRESS_GA1: - gpio_rest_mux = cypress_ga1_gpio_rest_mux; - ioexp_layout = cypress_ga1_ioexp_layout; - port_layout = cypress_ga1_port_layout; - ioexp_total = ARRAY_SIZE(cypress_ga1_ioexp_layout); - port_total = ARRAY_SIZE(cypress_ga1_port_layout); - break; -#endif -#ifdef SWPS_CYPRESS_GA2 - case PLATFORM_TYPE_CYPRESS_GA2: - gpio_rest_mux = cypress_ga2_gpio_rest_mux; - ioexp_layout = cypress_ga2_ioexp_layout; - port_layout = cypress_ga2_port_layout; - ioexp_total = ARRAY_SIZE(cypress_ga2_ioexp_layout); - port_total = ARRAY_SIZE(cypress_ga2_port_layout); - break; -#endif -#ifdef SWPS_CYPRESS_BAI - case PLATFORM_TYPE_CYPRESS_BAI: - gpio_rest_mux = cypress_b_gpio_rest_mux; - ioexp_layout = cypress_b_ioexp_layout; - port_layout = cypress_b_port_layout; - ioexp_total = ARRAY_SIZE(cypress_b_ioexp_layout); - port_total = ARRAY_SIZE(cypress_b_port_layout); - break; -#endif -#ifdef SWPS_REDWOOD_FSL - case PLATFORM_TYPE_REDWOOD_FSL: - gpio_rest_mux = redwood_fsl_gpio_rest_mux; - ioexp_layout = redwood_fsl_ioexp_layout; - port_layout = redwood_fsl_port_layout; - ioexp_total = ARRAY_SIZE(redwood_fsl_ioexp_layout); - port_total = ARRAY_SIZE(redwood_fsl_port_layout); - break; -#endif -#ifdef SWPS_TAHOE - case PLATFORM_TYPE_TAHOE: - gpio_rest_mux = tahoe_gpio_rest_mux; - ioexp_layout = tahoe_ioexp_layout; - port_layout = tahoe_port_layout; - ioexp_total = ARRAY_SIZE(tahoe_ioexp_layout); - port_total = ARRAY_SIZE(tahoe_port_layout); - break; -#endif -#ifdef SWPS_SEQUOIA - case PLATFORM_TYPE_SEQUOIA_GA: - gpio_rest_mux = sequoia_gpio_rest_mux; - ioexp_layout = sequoia_ioexp_layout; - port_layout = sequoia_port_layout; - ioexp_total = ARRAY_SIZE(sequoia_ioexp_layout); - port_total = ARRAY_SIZE(sequoia_port_layout); - break; -#endif -#ifdef SWPS_LAVENDER - case PLATFORM_TYPE_LAVENDER_GA: - case PLATFORM_TYPE_LAVENDER_ONL: - gpio_rest_mux = lavender_gpio_rest_mux; - ioexp_layout = lavender_ioexp_layout; - port_layout = lavender_port_layout; - ioexp_total = ARRAY_SIZE(lavender_ioexp_layout); - port_total = ARRAY_SIZE(lavender_port_layout); - break; -#endif -#ifdef SWPS_COTTONWOOD_RANGELEY - case PLATFORM_TYPE_COTTONWOOD_RANGELEY: - gpio_rest_mux = cottonwood_rangeley_gpio_rest_mux; - ioexp_layout = cottonwood_rangeley_ioexp_layout; - port_layout = cottonwood_rangeley_port_layout; - ioexp_total = ARRAY_SIZE(cottonwood_rangeley_ioexp_layout); - port_total = ARRAY_SIZE(cottonwood_rangeley_port_layout); - break; -#endif - default: - SWPS_ERR(" Invalid platform: %d (%s)\n", - platform_p->id, platform_p->name); - return -1; - } - SWPS_INFO("Start to initial platform: %d (%s)\n", - platform_p->id, platform_p->name); - return 0; -} - - -/* ========== Functions for objects operations ========== - */ -static int -__detect_issues_port(int minor_num) { - - struct transvr_obj_s *tobj_p; - int port_id = port_layout[minor_num].port_id; - char port_name[32] = "ERR"; - char *i2c_emsg = "detected bad transceiver/cable"; - - memset(port_name, 0, sizeof(port_name)); - snprintf(port_name, sizeof(port_name), "%s%d", SWP_DEV_PORT, port_id); - tobj_p = _get_transvr_obj(port_name); - if (!tobj_p) { - SWPS_INFO("%s: tobj_p is NULL :%d\n", __func__, minor_num); - return -1; - } - if (resync_channel_tier_2(tobj_p) < 0) { - if (check_channel_tier_1() < 0) { - alarm_msg_2_user(tobj_p, i2c_emsg); - return -2;; - } - } - return 0; -} - - -static int -_detect_issues_port(void) { - /* OK : retrun -1; - * Fail: return fail at which minor number (0~N) - */ - char *emsg = "ERR"; - int minor = 0; - int minor_2st = 1; - - /* Force moving the initial channel pointer - * Filter out case of fail at minor-0 port - */ - while (minor_2st < port_total) { - minor = minor_2st; - if (__detect_issues_port(minor_2st) < 0) { - emsg = "detect minor_2st fail"; - goto err_p_detect_issues_port; - } - minor_2st += 8; - } - /* Scan all port */ - for (minor=0; minor:%d\n", __func__, emsg, minor_err); - return -1; -} - - -static int -check_transvr_obj_one(char *dev_name){ - /* [Return] - * 0 : Doesn't need to take care - * -1 : Single error - * -2 : Critical error (I2C topology die) - * -9 : Internal error - */ - struct transvr_obj_s *tobj_p = NULL; - int retval = -9; - - tobj_p = _get_transvr_obj(dev_name); - if (!tobj_p) { - SWPS_ERR("%s: %s _get_transvr_obj fail\n", - __func__, dev_name); - return -9; - } - /* Check transceiver current status */ - lock_transvr_obj(tobj_p); - retval = tobj_p->check(tobj_p); - unlock_transvr_obj(tobj_p); - switch (retval) { - case 0: - case ERR_TRANSVR_UNPLUGGED: - case ERR_TRNASVR_BE_ISOLATED: - case ERR_TRANSVR_TASK_BUSY: - return 0; - - case ERR_TRANSVR_I2C_CRASH: - default: - break; - } - /* Identify abnormal case */ - if (check_channel_tier_1() < 0) { - SWPS_DEBUG("%s: %s critical error :%d\n", - __func__, dev_name, retval); - return -2; - } - SWPS_DEBUG("%s: %s single error :%d\n", - __func__, dev_name, retval); - return -1; -} - - -static int -check_transvr_objs(void){ - - char dev_name[32]; - int port_id, err_code; - int minor_curr = 0; - - for (minor_curr=0; minor_curr:%d\n", - __func__, dev_name, err_code); - break; - } - } - return 0; - -err_check_transvr_objs: - SWPS_ERR("%s: %s reset_i2c_topology fail.\n", - __func__, dev_name); - return -1; -} - - -static void -swp_polling_worker(struct work_struct *work){ - - /* Reset I2C */ - if (flag_i2c_reset) { - goto polling_reset_i2c; - } - /* Check IOEXP */ - if (check_ioexp_objs() < 0) { - goto polling_reset_i2c; - } - /* Check transceiver */ - if (check_transvr_objs() < 0) { - SWPS_DEBUG("%s: check_transvr_objs fail.\n", __func__); - flag_i2c_reset = 1; - } - goto polling_schedule_round; - -polling_reset_i2c: - SWPS_DEBUG("%s: reset_i2c_topology start.\n", __func__); - if (reset_i2c_topology() < 0) { - SWPS_ERR("%s: reset i2c fail!\n", __func__); - flag_i2c_reset = 1; - } else { - SWPS_DEBUG("%s: reset_i2c_topology OK.\n", __func__); - flag_i2c_reset = 0; - } -polling_schedule_round: - schedule_delayed_work(&swp_polling, _get_polling_period()); -} - - -/* ========== Functions for register something ========== - */ -static int -register_transvr_common_attr(struct device *device_p){ - - char *err_attr = NULL; - - if (device_create_file(device_p, &dev_attr_id) < 0) { - err_attr = "dev_attr_id"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_ext_id) < 0) { - err_attr = "dev_attr_ext_id"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_connector) < 0) { - err_attr = "dev_attr_connector"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_vendor_name) < 0) { - err_attr = "dev_attr_vendor_name"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_vendor_pn) < 0) { - err_attr = "dev_attr_vendor_pn"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_vendor_rev) < 0) { - err_attr = "dev_attr_vendor_rev"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_vendor_sn) < 0) { - err_attr = "dev_attr_vendor_sn"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_br) < 0) { - err_attr = "dev_attr_br"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_len_smf) < 0) { - err_attr = "dev_attr_len_smf"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_len_om1) < 0) { - err_attr = "dev_attr_len_om1"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_len_om2) < 0) { - err_attr = "dev_attr_len_om2"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_len_om3) < 0) { - err_attr = "dev_attr_len_om3"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_len_om4) < 0) { - err_attr = "dev_attr_len_om4"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_comp_extend) < 0) { - err_attr = "dev_attr_comp_extend"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_comp_eth) < 0) { - err_attr = "dev_attr_comp_eth"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_comp_rev) < 0) { - err_attr = "dev_attr_comp_rev"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_info) < 0) { - err_attr = "dev_attr_info"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_if_type) < 0) { - err_attr = "dev_attr_if_type"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_if_speed) < 0) { - err_attr = "dev_attr_if_speed"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_if_lane) < 0) { - err_attr = "dev_attr_if_lane"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_temperature) < 0) { - err_attr = "dev_attr_temperature"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_voltage) < 0) { - err_attr = "dev_attr_voltage"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_tx_bias) < 0) { - err_attr = "dev_attr_tx_bias"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_tx_power) < 0) { - err_attr = "dev_attr_tx_power"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_rx_power) < 0) { - err_attr = "dev_attr_rx_power"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_tx_eq) < 0) { - err_attr = "dev_attr_tx_eq"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_rx_em) < 0) { - err_attr = "dev_attr_rx_em"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_wavelength) < 0) { - err_attr = "dev_attr_wavelength"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_eeprom) < 0) { - err_attr = "dev_attr_eeprom"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_uppage) < 0) { - err_attr = "dev_attr_uppage"; - goto err_transvr_comm_attr; - } - return 0; - -err_transvr_comm_attr: - SWPS_ERR("%s: %s\n", __func__, err_attr); - return -1; -} - -static int -register_transvr_sfp_attr(struct device *device_p){ - - char *err_attr = NULL; - - if (register_transvr_common_attr(device_p) < 0) { - err_attr = "register_transvr_common_attr"; - goto err_transvr_sfp_attr; - } - if (device_create_file(device_p, &dev_attr_comp_eth_10) < 0) { - err_attr = "dev_attr_comp_eth_10"; - goto err_transvr_sfp_attr; - } - if (device_create_file(device_p, &dev_attr_len_sm) < 0) { - err_attr = "dev_attr_len_sm"; - goto err_transvr_sfp_attr; - } - if (device_create_file(device_p, &dev_attr_rate_id) < 0) { - err_attr = "dev_attr_rate_id"; - goto err_transvr_sfp_attr; - } - if (device_create_file(device_p, &dev_attr_soft_rs0) < 0) { - err_attr = "dev_attr_soft_rs0"; - goto err_transvr_sfp_attr; - } - if (device_create_file(device_p, &dev_attr_soft_rs1) < 0) { - err_attr = "dev_attr_soft_rs1"; - goto err_transvr_sfp_attr; - } - if (device_create_file(device_p, &dev_attr_extphy_offset) < 0) { - err_attr = "dev_attr_extphy_offset"; - goto err_transvr_sfp_attr; - } - if (device_create_file(device_p, &dev_attr_extphy_reg) < 0) { - err_attr = "dev_attr_extphy_reg"; - goto err_transvr_sfp_attr; - } - return 0; - -err_transvr_sfp_attr: - SWPS_ERR("%s: %s\n", __func__, err_attr); - return -1; -} - - -static int -register_transvr_qsfp_attr(struct device *device_p){ - - char *err_attr = NULL; - - if (register_transvr_common_attr(device_p) < 0) { - err_attr = "register_transvr_common_attr"; - goto err_transvr_qsfp_attr; - } - if (device_create_file(device_p, &dev_attr_comp_eth_10_40) < 0) { - err_attr = "dev_attr_comp_eth_10_40"; - goto err_transvr_qsfp_attr; - } - if (device_create_file(device_p, &dev_attr_power_cls) < 0) { - err_attr = "dev_attr_power_cls"; - goto err_transvr_qsfp_attr; - } - if (device_create_file(device_p, &dev_attr_soft_rx_los) < 0) { - err_attr = "soft_rx_los"; - goto err_transvr_qsfp_attr; - } - if (device_create_file(device_p, &dev_attr_soft_tx_disable) < 0) { - err_attr = "soft_tx_disable"; - goto err_transvr_qsfp_attr; - } - if (device_create_file(device_p, &dev_attr_auto_tx_disable) < 0) { - err_attr = "auto_tx_disable"; - goto err_transvr_qsfp_attr; - } - if (device_create_file(device_p, &dev_attr_soft_tx_fault) < 0) { - err_attr = "soft_tx_fault"; - goto err_transvr_qsfp_attr; - } - return 0; - -err_transvr_qsfp_attr: - SWPS_ERR("%s: %s\n", __func__, err_attr); - return -1; -} - - -static int -register_transvr_qsfp28_attr(struct device *device_p){ - - char *err_attr = NULL; - - if (register_transvr_qsfp_attr(device_p) < 0){ - err_attr = "register_transvr_qsfp_attr"; - goto err_transvr_qsfp28_attr; - } - if (device_create_file(device_p, &dev_attr_cdr) < 0) { - err_attr = "dev_attr_cdr"; - goto err_transvr_qsfp28_attr; - } - if (device_create_file(device_p, &dev_attr_rx_am) < 0) { - err_attr = "dev_attr_rx_am"; - goto err_transvr_qsfp28_attr; - } - return 0; - -err_transvr_qsfp28_attr: - SWPS_ERR("%s: %s\n", __func__, err_attr); - return -1; -} - - -static int -register_transvr_attr(struct device *device_p, - struct transvr_obj_s *transvr_obj){ - - switch (transvr_obj->layout){ - case TRANSVR_TYPE_SFP: - if (register_transvr_sfp_attr(device_p) < 0){ - goto err_reg_tvr_attr; - } - break; - case TRANSVR_TYPE_QSFP: - case TRANSVR_TYPE_QSFP_PLUS: - if (register_transvr_qsfp_attr(device_p) < 0){ - goto err_reg_tvr_attr; - } - break; - case TRANSVR_TYPE_QSFP_28: - if (register_transvr_qsfp28_attr(device_p) < 0){ - goto err_reg_tvr_attr; - } - break; - default: - goto err_reg_tvr_attr; - } - return 0; - -err_reg_tvr_attr: - SWPS_ERR("%s: fail! type=%d \n", __func__, transvr_obj->type); - return -1; -} - - -static int -register_ioexp_attr_sfp_1(struct device *device_p){ - /* Support machine type: - * - SFP : Magnolia - */ - char *err_attr = NULL; - - if (device_create_file(device_p, &dev_attr_present) < 0) { - err_attr = "dev_attr_present"; - goto err_ioexp_sfp1_attr; - } - if (device_create_file(device_p, &dev_attr_tx_fault) < 0) { - err_attr = "dev_attr_tx_fault"; - goto err_ioexp_sfp1_attr; - } - if (device_create_file(device_p, &dev_attr_rxlos) < 0) { - err_attr = "dev_attr_rxlos"; - goto err_ioexp_sfp1_attr; - } - if (device_create_file(device_p, &dev_attr_tx_disable) < 0) { - err_attr = "dev_attr_tx_disable"; - goto err_ioexp_sfp1_attr; - } - return 0; - -err_ioexp_sfp1_attr: - SWPS_ERR("Add device attribute:%s failure! \n",err_attr); - return -1; -} - - -static int -register_ioexp_attr_sfp_2(struct device *device_p){ - /* Support machine type: - * - SFP28 : Cypress - */ - char *err_attr = NULL; - - if (register_ioexp_attr_sfp_1(device_p) < 0){ - goto err_ioexp_sfp2_attr; - } - if (device_create_file(device_p, &dev_attr_hard_rs0) < 0) { - err_attr = "dev_attr_hard_rs0"; - goto err_ioexp_sfp2_attr; - } - if (device_create_file(device_p, &dev_attr_hard_rs1) < 0) { - err_attr = "dev_attr_hard_rs1"; - goto err_ioexp_sfp2_attr; - } - return 0; - -err_ioexp_sfp2_attr: - SWPS_ERR("Add device attribute:%s failure! \n",err_attr); - return -1; -} - - -static int -register_ioexp_attr_qsfp_1(struct device *device_p){ - /* Support machine type: - * - QSFP : Magnolia, Redwood, Hudson32i - * - QSFP+ : Magnolia, Redwood, Hudson32i - * - QSFP28: Redwood - */ - char *err_attr = NULL; - - if (device_create_file(device_p, &dev_attr_present) < 0) { - err_attr = "dev_attr_present"; - goto err_ioexp_qsfp1_attr; - } - if (device_create_file(device_p, &dev_attr_reset) < 0) { - err_attr = "dev_attr_reset"; - goto err_ioexp_qsfp1_attr; - } - if (device_create_file(device_p, &dev_attr_lpmod) < 0) { - err_attr = "dev_attr_lpmod"; - goto err_ioexp_qsfp1_attr; - } - if (device_create_file(device_p, &dev_attr_modsel) < 0) { - err_attr = "dev_attr_modsel"; - goto err_ioexp_qsfp1_attr; - } - return 0; - -err_ioexp_qsfp1_attr: - SWPS_ERR("Add device attribute:%s failure! \n",err_attr); - return -1; -} - - -static int -register_modctl_attr(struct device *device_p){ - - char *err_msg = NULL; - - if (device_create_file(device_p, &dev_attr_platform) < 0) { - err_msg = "dev_attr_platform"; - goto err_reg_modctl_attr; - } - if (device_create_file(device_p, &dev_attr_version) < 0) { - err_msg = "dev_attr_version"; - goto err_reg_modctl_attr; - } - if (device_create_file(device_p, &dev_attr_status) < 0) { - err_msg = "dev_attr_status"; - goto err_reg_modctl_attr; - } - if (device_create_file(device_p, &dev_attr_reset_i2c) < 0) { - err_msg = "dev_attr_reset_i2c"; - goto err_reg_modctl_attr; - } - if (device_create_file(device_p, &dev_attr_reset_swps) < 0) { - err_msg = "dev_attr_reset_swps"; - goto err_reg_modctl_attr; - } - if (device_create_file(device_p, &dev_attr_auto_config) < 0) { - err_msg = "dev_attr_auto_config"; - goto err_reg_modctl_attr; - } - return 0; - -err_reg_modctl_attr: - SWPS_ERR("%s: %s\n", __func__, err_msg); - return -1; -} - - -static int -register_ioexp_attr(struct device *device_p, - struct transvr_obj_s *transvr_obj){ - - char *err_msg = "ERR"; - - switch (transvr_obj->ioexp_obj_p->ioexp_type){ - case IOEXP_TYPE_MAGINOLIA_NAB: - case IOEXP_TYPE_MAGINOLIA_4AB: - case CPLD_TYPE_COTTONWOOD: - if (register_ioexp_attr_sfp_1(device_p) < 0){ - err_msg = "register_ioexp_attr_sfp_1 fail"; - goto err_reg_ioexp_attr; - } - break; - case IOEXP_TYPE_CYPRESS_NABC: - if (register_ioexp_attr_sfp_2(device_p) < 0){ - err_msg = "register_ioexp_attr_sfp_2 fail"; - goto err_reg_ioexp_attr; - } - break; - case IOEXP_TYPE_MAGINOLIA_7AB: - case IOEXP_TYPE_SPRUCE_7AB: - case IOEXP_TYPE_CYPRESS_7ABC: - case IOEXP_TYPE_REDWOOD_P01P08: - case IOEXP_TYPE_REDWOOD_P09P16: - case IOEXP_TYPE_HUDSON32IGA_P01P08: - case IOEXP_TYPE_HUDSON32IGA_P09P16: - case IOEXP_TYPE_TAHOE_5A: - case IOEXP_TYPE_TAHOE_6ABC: - case IOEXP_TYPE_SEQUOIA_NABC: - case IOEXP_TYPE_LAVENDER_P65: - if (register_ioexp_attr_qsfp_1(device_p) < 0){ - err_msg = "register_ioexp_attr_qsfp_1 fail"; - goto err_reg_ioexp_attr; - } - break; - - default: - err_msg = "Unknow type"; - goto err_reg_ioexp_attr; - } - return 0; - -err_reg_ioexp_attr: - SWPS_ERR("%s: %s :%d \n", - __func__, err_msg, transvr_obj->ioexp_obj_p->ioexp_type); - return -1; -} - - -static int -register_modctl_device(void) { - - struct device *device_p = NULL; - int minor_comm = 0; /* Default minor number for common device */ - dev_t dev_num = MKDEV(ctl_major, minor_comm); - char *err_msg = "ERROR"; - - device_p = device_create(swp_class_p, /* struct class *cls */ - NULL, /* struct device *parent */ - dev_num, /* dev_t devt */ - NULL, /* void *private_data */ - SWP_DEV_MODCTL); /* const char *fmt */ - if (IS_ERR(device_p)){ - err_msg = "device_create fail"; - goto err_register_modctl_device_1; - } - if (register_modctl_attr(device_p) < 0) { - err_msg = "register_modctl_attr fail"; - goto err_register_modctl_device_2; - } - return 0; - -err_register_modctl_device_2: - device_unregister(device_p); - device_destroy(swp_class_p, dev_num); -err_register_modctl_device_1: - SWPS_ERR("%s: %s\n", __func__, err_msg); - return -1; -} - - -static int -register_port_device(char *dev_name, - dev_t dev_num, - struct transvr_obj_s *transvr_obj){ - - struct device *device_p = NULL; - device_p = device_create(swp_class_p, /* struct class *cls */ - NULL, /* struct device *parent */ - dev_num, /* dev_t devt */ - transvr_obj, /* void *private_data */ - dev_name); /* const char *fmt */ - if (IS_ERR(device_p)){ - goto err_regswp_create_dev; - } - if (register_transvr_attr(device_p, transvr_obj) < 0){ - goto err_regswp_reg_attr; - } - if (register_ioexp_attr(device_p, transvr_obj) < 0){ - goto err_regswp_reg_attr; - } - return 0; - -err_regswp_reg_attr: - device_unregister(device_p); - device_destroy(swp_class_p, dev_num); -err_regswp_create_dev: - SWPS_ERR("%s fail! :%s\n", __func__, dev_name); - return -1; -} - - -static int -register_swp_module(void){ - - dev_t ctl_devt = 0; - dev_t port_devt = 0; - int dev_total = port_total + 1; /* char_dev for module control */ - - /* Register device number */ - if (alloc_chrdev_region(&ctl_devt, 0, 1, SWP_DEV_MODCTL) < 0){ - SWPS_WARN("Allocate CTL MAJOR failure! \n"); - goto err_register_swp_module_1; - } - if (alloc_chrdev_region(&port_devt, 0, dev_total, SWP_CLS_NAME) < 0){ - SWPS_WARN("Allocate PORT MAJOR failure! \n"); - goto err_register_swp_module_2; - } - ctl_major = MAJOR(ctl_devt); - port_major = MAJOR(port_devt); - - /* Create class object */ - swp_class_p = class_create(THIS_MODULE, SWP_CLS_NAME); - if (IS_ERR(swp_class_p)) { - SWPS_ERR("Create class failure! \n"); - goto err_register_swp_module_3; - } - return 0; - -err_register_swp_module_3: - unregister_chrdev_region(MKDEV(port_major, 0), port_total); -err_register_swp_module_2: - unregister_chrdev_region(MKDEV(ctl_major, 0), 1); -err_register_swp_module_1: - return -1; -} - - -/* ========== Module initial relate ========== - */ -static int -create_ioexp_objs(void) { - - int i, run_mod; - - /* Clean IOEXP object */ - clean_ioexp_objs(); - /* Get running mode */ - run_mod = IOEXP_MODE_DIRECT; - if (SWP_POLLING_ENABLE){ - run_mod = IOEXP_MODE_POLLING; - } - /* Create IOEXP object */ - for(i=0; i devlen_max) { - snprintf(err_msg, sizeof(err_msg), - "SWP_DEV_PORT too long!"); - goto err_initport_create_tranobj; - } - memset(dev_name, 0, sizeof(dev_name)); - snprintf(dev_name, devlen_max, "%s%d", SWP_DEV_PORT, port_id); - /* Create transceiver object */ - ioexp_obj_p = get_ioexp_obj(ioexp_id); - if (!ioexp_obj_p){ - snprintf(err_msg, sizeof(err_msg), - "IOEXP object:%d not exist", ioexp_id); - goto err_initport_create_tranobj; - } - transvr_obj_p = create_transvr_obj(dev_name, chan_id, ioexp_obj_p, - ioexp_virt_offset, transvr_type, - chipset_type, run_mod); - if (!transvr_obj_p){ - snprintf(err_msg, sizeof(err_msg), - "Create transceiver object fail :%s", dev_name); - goto err_initport_create_tranobj; - } - /* Setup Lane_ID mapping */ - i = ARRAY_SIZE(port_layout[minor_curr].lane_id); - j = ARRAY_SIZE(transvr_obj_p->lane_id); - if (i != j) { - snprintf(err_msg, sizeof(err_msg), - "Lane_id size inconsistent %d/%d", i, j); - goto err_initport_reg_device; - } - memcpy(transvr_obj_p->lane_id, port_layout[minor_curr].lane_id, i*sizeof(int)); - /* Create and register device object */ - if (register_port_device(dev_name, MKDEV(port_major, minor_curr), transvr_obj_p) < 0){ - snprintf(err_msg, sizeof(err_msg), - "register_port_device fail"); - goto err_initport_reg_device; - } - /* Setup device_ptr of transvr_obj */ - dev_p = get_swpdev_by_name(dev_name); - if (!dev_p){ - snprintf(err_msg, sizeof(err_msg), - "get_swpdev_by_name fail"); - goto err_initport_reg_device; - } - transvr_obj_p->transvr_dev_p = dev_p; - /* Success */ - ok_count++; - } - SWPS_INFO("%s: initialed %d port-dev",__func__, ok_count); - return 0; - -err_initport_reg_device: - kfree(transvr_obj_p); -err_initport_create_tranobj: - clean_port_obj(); - SWPS_ERR("%s: %s", __func__, err_msg); - SWPS_ERR("Dump: :%d :%d :%d :%d :%d :%d\n", - port_id, chan_id, ioexp_id, ioexp_virt_offset, transvr_type, run_mod); - return -1; -} - - -static int -init_dev_topology(void){ - - int err; - char *emsg = "ERR"; - flag_mod_state = SWP_STATE_NORMAL; - - err = init_ioexp_objs(); - switch(err){ - case 0: /* Normal */ - SWPS_DEBUG("%s: normal case\n", __func__); - break; - - case -1: /* topology error */ - SWPS_DEBUG("%s: detect tier-1 topology initial failure :%d\n", - __func__, err); - /* Reset and isolate */ - err = reset_i2c_topology(); - if (err < 0) { - emsg = "reset i2c topology fail"; - goto err_init_dev_topology; - } - /* Re-initial again */ - err = init_ioexp_objs(); - if (err < 0) { - emsg = "re-init ioexp objects fail"; - goto err_init_dev_topology; - } - break; - - case -2: /* Internal error */ - SWPS_DEBUG("%s: internal error case\n", __func__); - err = -2; - emsg = "internal error"; - goto err_init_dev_topology; - - default: - SWPS_DEBUG("%s: undefined error case\n", __func__); - emsg = "undefined error case"; - goto err_init_dev_topology; - } - SWPS_DEBUG("%s: initial I2C topology success\n", __func__); - return 0; - -err_init_dev_topology: - SWPS_ERR("%s: %s :%d\n", __func__, emsg, err); - return -1; -} - - -static int -init_polling_task(void){ - - if (SWP_POLLING_ENABLE){ - schedule_delayed_work(&swp_polling, _get_polling_period()); - } - return 0; -} - - -static int -init_swps_common(void){ - - char *err_msg = "ERR"; - - auto_config = 0; - if ((SWP_AUTOCONFIG_ENABLE) && (SWP_POLLING_ENABLE)){ - auto_config = 1; - } - if (register_modctl_device() < 0) { - err_msg = "register_modctl_device fail"; - goto err_init_swps_common_1; - } - if (_update_auto_config_2_trnasvr() < 0) { - err_msg = "_update_auto_config_2_trnasvr fail"; - goto err_init_swps_common_1; - } - if (init_polling_task() < 0){ - err_msg = "init_polling_task fail"; - goto err_init_swps_common_1; - } - return 0; - -err_init_swps_common_1: - clean_swps_common(); - SWPS_ERR("%s: %s\n", __func__, err_msg); - return -1; -} - - -static int __init -swp_module_init(void){ - - if (get_platform_type() < 0){ - goto err_init_out; - } - if (get_layout_info() < 0){ - goto err_init_out; - } - if (register_swp_module() < 0){ - goto err_init_out; - } - if (create_ioexp_objs() < 0){ - goto err_init_ioexp; - } - if (create_port_objs() < 0){ - goto err_init_portobj; - } - if (init_mux_gpio(gpio_rest_mux) < 0){ - goto err_init_mux; - } - if (init_dev_topology() < 0){ - goto err_init_topology; - } - if (init_swps_common() < 0){ - goto err_init_topology; - } - SWPS_INFO("Inventec switch-port module V.%s initial success.\n", SWP_VERSION); - return 0; - - -err_init_topology: - clean_mux_gpio(); -err_init_mux: - clean_port_obj(); -err_init_portobj: - clean_ioexp_objs(); -err_init_ioexp: - class_unregister(swp_class_p); - class_destroy(swp_class_p); - unregister_chrdev_region(MKDEV(ctl_major, 0), 1); - unregister_chrdev_region(MKDEV(port_major, 0), port_total); -err_init_out: - SWPS_ERR("Inventec switch-port module V.%s initial failure.\n", SWP_VERSION); - return -1; -} - - -static void __exit -swp_module_exit(void){ - - clean_swps_common(); - clean_port_obj(); - clean_ioexp_objs(); - clean_mux_gpio(); - class_unregister(swp_class_p); - class_destroy(swp_class_p); - unregister_chrdev_region(MKDEV(ctl_major, 0), 1); - unregister_chrdev_region(MKDEV(port_major, 0), port_total); - SWPS_INFO("Remove Inventec switch-port module success.\n"); -} - - -/* Module information */ -MODULE_AUTHOR(SWP_AUTHOR); -MODULE_DESCRIPTION(SWP_DESC); -MODULE_VERSION(SWP_VERSION); -MODULE_LICENSE(SWP_LICENSE); - -module_init(swp_module_init); -module_exit(swp_module_exit); - - - - - - - - - diff --git a/packages/platforms/inventec/x86-64/d3352/modules/builds/src/inv_swps.h b/packages/platforms/inventec/x86-64/d3352/modules/builds/src/inv_swps.h deleted file mode 100644 index 588400245..000000000 --- a/packages/platforms/inventec/x86-64/d3352/modules/builds/src/inv_swps.h +++ /dev/null @@ -1,1052 +0,0 @@ -#ifndef INV_SWPS_H -#define INV_SWPS_H - -#include "transceiver.h" -#include "io_expander.h" -#include "inv_mux.h" - -/* Module settings */ -#define SWP_CLS_NAME "swps" -#define SWP_DEV_PORT "port" -#define SWP_DEV_MODCTL "module" -#define SWP_RESET_PWD "inventec" -#define SWP_POLLING_PERIOD (300) /* msec */ -#define SWP_POLLING_ENABLE (1) -#define SWP_AUTOCONFIG_ENABLE (1) - -/* Module information */ -#define SWP_AUTHOR "Neil " -#define SWP_DESC "Inventec port and transceiver driver" -#define SWP_VERSION "4.2.8" -#define SWP_LICENSE "GPL" - -/* Module status define */ -#define SWP_STATE_NORMAL (0) -#define SWP_STATE_I2C_DIE (-91) - -/* [Note]: - * Functions and mechanism for auto-detect platform type is ready, - * But HW and BIOS not ready! We need to wait them. - * So, please do not use PLATFORM_TYPE_AUTO until they are ready. - * (2016.06.13) - */ -#define PLATFORM_TYPE_AUTO (100) -#define PLATFORM_TYPE_MAGNOLIA (111) -#define PLATFORM_TYPE_MAGNOLIA_FNC (112) -#define PLATFORM_TYPE_REDWOOD (121) -#define PLATFORM_TYPE_REDWOOD_FSL (122) -#define PLATFORM_TYPE_HUDSON32I_GA (131) -#define PLATFORM_TYPE_SPRUCE (141) -#define PLATFORM_TYPE_CYPRESS_GA1 (151) /* Up -> Down */ -#define PLATFORM_TYPE_CYPRESS_GA2 (152) /* Down -> Up */ -#define PLATFORM_TYPE_CYPRESS_BAI (153) /* Down -> Up */ -#define PLATFORM_TYPE_TAHOE (161) -#define PLATFORM_TYPE_SEQUOIA_GA (171) -#define PLATFORM_TYPE_LAVENDER_GA (181) -#define PLATFORM_TYPE_LAVENDER_ONL (182) -#define PLATFORM_TYPE_COTTONWOOD_RANGELEY (191) -/* Current running platfrom */ -#define PLATFORM_SETTINGS PLATFORM_TYPE_COTTONWOOD_RANGELEY - -/* Define platform flag and kernel version */ -#if (PLATFORM_SETTINGS == PLATFORM_TYPE_MAGNOLIA) - #define SWPS_MAGNOLIA (1) - #define SWPS_KERN_VER_BF_3_8 (1) -#elif (PLATFORM_SETTINGS == PLATFORM_TYPE_MAGNOLIA_FNC) - #define SWPS_MAGNOLIA (1) - #define SWPS_KERN_VER_AF_3_10 (1) -#elif (PLATFORM_SETTINGS == PLATFORM_TYPE_REDWOOD) - #define SWPS_REDWOOD (1) - #define SWPS_KERN_VER_BF_3_8 (1) -#elif (PLATFORM_SETTINGS == PLATFORM_TYPE_REDWOOD_FSL) - #define SWPS_REDWOOD_FSL (1) - #define SWPS_KERN_VER_BF_3_8 (1) -#elif (PLATFORM_SETTINGS == PLATFORM_TYPE_HUDSON32I_GA) - #define SWPS_HUDSON32I_GA (1) - #define SWPS_KERN_VER_BF_3_8 (1) -#elif (PLATFORM_SETTINGS == PLATFORM_TYPE_SPRUCE) - #define SWPS_SPRUCE (1) - #define SWPS_KERN_VER_BF_3_8 (1) -#elif (PLATFORM_SETTINGS == PLATFORM_TYPE_CYPRESS_GA1) - #define SWPS_CYPRESS_GA1 (1) - #define SWPS_KERN_VER_BF_3_8 (1) -#elif (PLATFORM_SETTINGS == PLATFORM_TYPE_CYPRESS_GA2) - #define SWPS_CYPRESS_GA2 (1) - #define SWPS_KERN_VER_BF_3_8 (1) -#elif (PLATFORM_SETTINGS == PLATFORM_TYPE_CYPRESS_BAI) - #define SWPS_CYPRESS_BAI (1) - #define SWPS_KERN_VER_AF_3_10 (1) -#elif (PLATFORM_SETTINGS == PLATFORM_TYPE_TAHOE) - #define SWPS_TAHOE (1) - #define SWPS_KERN_VER_AF_3_10 (1) -#elif (PLATFORM_SETTINGS == PLATFORM_TYPE_SEQUOIA_GA) - #define SWPS_SEQUOIA (1) - #define SWPS_KERN_VER_BF_3_8 (1) -#elif (PLATFORM_SETTINGS == PLATFORM_TYPE_LAVENDER_GA) - #define SWPS_LAVENDER (1) - #define SWPS_KERN_VER_AF_3_10 (1) -#elif (PLATFORM_SETTINGS == PLATFORM_TYPE_LAVENDER_ONL) - #define SWPS_LAVENDER (1) - #define SWPS_KERN_VER_AF_3_10 (1) -#elif (PLATFORM_SETTINGS == PLATFORM_TYPE_COTTONWOOD_RANGELEY) - #define SWPS_COTTONWOOD_RANGELEY (1) - #define SWPS_KERN_VER_AF_3_10 (1) -#endif - - -struct inv_platform_s { - int id; - char name[64]; -}; - -struct inv_ioexp_layout_s { - int ioexp_id; - int ioexp_type; - struct ioexp_addr_s addr[4]; -}; - -struct inv_port_layout_s { - int port_id; - int chan_id; - int ioexp_id; - int ioexp_offset; - int transvr_type; - int chipset_type; - int lane_id[8]; -}; - - -/* ========================================== - * Inventec Platform Settings - * ========================================== - */ -struct inv_platform_s platform_map[] = { - {PLATFORM_TYPE_AUTO, "Auto-Detect" }, - {PLATFORM_TYPE_MAGNOLIA, "Magnolia" }, - {PLATFORM_TYPE_MAGNOLIA_FNC, "Magnolia_FNC" }, - {PLATFORM_TYPE_REDWOOD, "Redwood" }, - {PLATFORM_TYPE_REDWOOD_FSL, "Redwood_FSL" }, - {PLATFORM_TYPE_HUDSON32I_GA, "Hudson32i" }, - {PLATFORM_TYPE_SPRUCE, "Spruce" }, - {PLATFORM_TYPE_CYPRESS_GA1, "Cypress_GA1" }, - {PLATFORM_TYPE_CYPRESS_GA2, "Cypress_GA2" }, - {PLATFORM_TYPE_CYPRESS_BAI, "Cypress_BAI" }, - {PLATFORM_TYPE_TAHOE, "Tahoe" }, - {PLATFORM_TYPE_SEQUOIA_GA, "Sequoia_GA" }, - {PLATFORM_TYPE_LAVENDER_GA, "Lavender_GA" }, - {PLATFORM_TYPE_LAVENDER_ONL, "Lavender_ONL" }, - {PLATFORM_TYPE_COTTONWOOD_RANGELEY, "Cottonwood_RANGELEY" }, -}; - - -/* ========================================== - * Magnolia Layout configuration - * ========================================== - */ -#ifdef SWPS_MAGNOLIA -unsigned magnolia_gpio_rest_mux = MUX_RST_GPIO_48_PAC9548; - -struct inv_ioexp_layout_s magnolia_ioexp_layout[] = { - /* IOEXP_ID / IOEXP_TYPE / { Chan_ID, Chip_addr, Read_offset, Write_offset, config_offset, data_default, conf_default } */ - {0, IOEXP_TYPE_MAGINOLIA_NAB, { {2, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {2, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, }, /* addr[1] = I/O Expander N B */ - }, - {1, IOEXP_TYPE_MAGINOLIA_NAB, { {3, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {3, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, }, /* addr[1] = I/O Expander N B */ - }, - {2, IOEXP_TYPE_MAGINOLIA_NAB, { {4, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {4, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, }, /* addr[1] = I/O Expander N B */ - }, - {3, IOEXP_TYPE_MAGINOLIA_4AB, { {5, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander 4 A */ - {5, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xf0, 0xff}, {0xf0, 0xff}, }, }, /* addr[1] = I/O Expander 4 B */ - }, - {4, IOEXP_TYPE_MAGINOLIA_NAB, { {6, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {6, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, }, /* addr[1] = I/O Expander N B */ - }, - {5, IOEXP_TYPE_MAGINOLIA_NAB, { {7, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {7, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, }, /* addr[1] = I/O Expander N B */ - }, - {6, IOEXP_TYPE_MAGINOLIA_7AB, { {8, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[0] = I/O Expander 7 A */ - {8, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xf0, 0x33}, }, }, /* addr[1] = I/O Expander 7 B */ - }, -}; - -struct inv_port_layout_s magnolia_port_layout[] = { - /* Port_ID / Chan_ID / IOEXP_ID / IOEXP_VIRT_OFFSET / TRANSCEIVER_TYPE / BCM_CHIP_TYPE / LANE_ID */ - { 0, 10, 0, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 16} }, - { 1, 11, 0, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 15} }, - { 2, 12, 0, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 14} }, - { 3, 13, 0, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 13} }, - { 4, 14, 0, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 24} }, - { 5, 15, 0, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 23} }, - { 6, 16, 0, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 22} }, - { 7, 17, 0, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 21} }, - { 8, 18, 1, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 28} }, - { 9, 19, 1, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 27} }, - {10, 20, 1, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 26} }, - {11, 21, 1, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 25} }, - {12, 22, 1, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 32} }, - {13, 23, 1, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 31} }, - {14, 24, 1, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 30} }, - {15, 25, 1, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 29} }, - {16, 26, 2, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 48} }, - {17, 27, 2, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 47} }, - {18, 28, 2, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 46} }, - {19, 29, 2, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 45} }, - {20, 30, 2, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 52} }, - {21, 31, 2, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 51} }, - {22, 32, 2, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 50} }, - {23, 33, 2, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 49} }, - {24, 34, 3, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 56} }, - {25, 35, 3, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 55} }, - {26, 36, 3, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 54} }, - {27, 37, 3, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 53} }, - {28, 38, 3, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 60} }, - {29, 39, 3, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 59} }, - {30, 40, 3, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 58} }, - {31, 41, 3, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 57} }, - {32, 42, 4, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 64} }, - {33, 43, 4, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 63} }, - {34, 44, 4, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 62} }, - {35, 45, 4, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 61} }, - {36, 46, 4, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 68} }, - {37, 47, 4, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 67} }, - {38, 48, 4, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 66} }, - {39, 49, 4, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 65} }, - {40, 50, 5, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 72} }, - {41, 51, 5, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 71} }, - {42, 52, 5, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 70} }, - {43, 53, 5, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 69} }, - {44, 54, 5, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 76} }, - {45, 55, 5, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 75} }, - {46, 56, 5, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 74} }, - {47, 57, 5, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 73} }, - {48, 58, 6, 0, TRANSVR_TYPE_QSFP, CHIP_TYPE_MAGNOLIA, { 81, 82, 83, 84} }, - {49, 59, 6, 1, TRANSVR_TYPE_QSFP, CHIP_TYPE_MAGNOLIA, { 77, 78, 79, 80} }, - {50, 60, 6, 2, TRANSVR_TYPE_QSFP, CHIP_TYPE_MAGNOLIA, { 97, 98, 99,100} }, - {51, 61, 6, 3, TRANSVR_TYPE_QSFP, CHIP_TYPE_MAGNOLIA, {101,102,103,104} }, - {52, 62, 6, 4, TRANSVR_TYPE_QSFP, CHIP_TYPE_MAGNOLIA, {105,106,107,108} }, - {53, 63, 6, 5, TRANSVR_TYPE_QSFP, CHIP_TYPE_MAGNOLIA, {109,110,111,112} }, -}; -#endif - - -/* ========================================== - * Redwood Layout configuration - * ========================================== - */ -#ifdef SWPS_REDWOOD -unsigned redwood_gpio_rest_mux = MUX_RST_GPIO_48_PAC9548; - -struct inv_ioexp_layout_s redwood_ioexp_layout[] = { - /* IOEXP_ID / IOEXP_TYPE / { Chan_ID, Chip_addr, Read_offset, Write_offset, config_offset, data_default, conf_default } */ - {0, IOEXP_TYPE_REDWOOD_P01P08, { {4, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[0] = I/O Expander 1-4 A */ - {4, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[1] = I/O Expander 1-4 B */ - {0, 0x25, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 5 B */ - }, - {1, IOEXP_TYPE_REDWOOD_P09P16, { {5, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[0] = I/O Expander 1-4 A */ - {5, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[1] = I/O Expander 1-4 B */ - {0, 0x25, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 5 B */ - }, - {2, IOEXP_TYPE_REDWOOD_P01P08, { {2, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[0] = I/O Expander 1-4 A */ - {2, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[1] = I/O Expander 1-4 B */ - {0, 0x24, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 5 B */ - }, - {3, IOEXP_TYPE_REDWOOD_P09P16, { {3, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[0] = I/O Expander 1-4 A */ - {3, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[1] = I/O Expander 1-4 B */ - {0, 0x24, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 5 B */ - }, -}; - -struct inv_port_layout_s redwood_port_layout[] = { - /* Port_ID / Chan_ID / IOEXP_ID / IOEXP_VIRT_OFFSET / TRANSCEIVER_TYPE / BCM_CHIP_TYPE / LANE_ID */ - { 0, 22, 0, 0, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 1, 2, 3, 4} }, - { 1, 23, 0, 1, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 5, 6, 7, 8} }, - { 2, 24, 0, 2, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 9, 10, 11, 12} }, - { 3, 25, 0, 3, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 13, 14, 15, 16} }, - { 4, 26, 0, 4, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 17, 18, 19, 20} }, - { 5, 27, 0, 5, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 21, 22, 23, 24} }, - { 6, 28, 0, 6, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 25, 26, 27, 28} }, - { 7, 29, 0, 7, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 29, 30, 31, 32} }, - { 8, 30, 1, 0, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 33, 34, 35, 36} }, - { 9, 31, 1, 1, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 37, 38, 39, 40} }, - {10, 32, 1, 2, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 41, 42, 43, 44} }, - {11, 33, 1, 3, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 45, 46, 47, 48} }, - {12, 34, 1, 4, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 49, 50, 51, 52} }, - {13, 35, 1, 5, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 53, 54, 55, 56} }, - {14, 36, 1, 6, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 57, 58, 59, 60} }, - {15, 37, 1, 7, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 61, 62, 63, 64} }, - {16, 6, 2, 0, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 65, 66, 67, 68} }, - {17, 7, 2, 1, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 69, 70, 71, 72} }, - {18, 8, 2, 2, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 73, 74, 75, 76} }, - {19, 9, 2, 3, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 77, 78, 79, 80} }, - {20, 10, 2, 4, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 81, 82, 83, 84} }, - {21, 11, 2, 5, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 85, 86, 87, 88} }, - {22, 12, 2, 6, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 89, 90, 91, 92} }, - {23, 13, 2, 7, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 93, 94, 95, 96} }, - {24, 14, 3, 0, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 97, 98, 99,100} }, - {25, 15, 3, 1, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {101,102,103,104} }, - {26, 16, 3, 2, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {105,106,107,108} }, - {27, 17, 3, 3, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {109,110,111,112} }, - {28, 18, 3, 4, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {113,114,115,116} }, - {29, 19, 3, 5, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {117,118,119,120} }, - {30, 20, 3, 6, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {121,122,123,124} }, - {31, 21, 3, 7, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {125,126,127,128} }, -}; -#endif - - -/* ========================================== - * Hudson32i Layout configuration - * ========================================== - */ -#ifdef SWPS_HUDSON32I_GA -unsigned hudsin32iga_gpio_rest_mux = MUX_RST_GPIO_48_PAC9548; - -struct inv_ioexp_layout_s hudson32iga_ioexp_layout[] = { - /* IOEXP_ID / IOEXP_TYPE / { Chan_ID, Chip_addr, Read_offset, Write_offset, config_offset, data_default, conf_default } */ - {0, IOEXP_TYPE_HUDSON32IGA_P01P08, { {2, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[0] = I/O Expander A */ - {2, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[1] = I/O Expander B */ - {0, 0x24, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 0x24 */ - }, - {1, IOEXP_TYPE_HUDSON32IGA_P09P16, { {3, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[0] = I/O Expander A */ - {3, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[1] = I/O Expander B */ - {0, 0x24, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 0x24 */ - }, - {2, IOEXP_TYPE_HUDSON32IGA_P01P08, { {4, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[0] = I/O Expander A */ - {4, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[1] = I/O Expander B */ - {0, 0x25, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 0x25 */ - }, - {3, IOEXP_TYPE_HUDSON32IGA_P09P16, { {5, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[0] = I/O Expander A */ - {5, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[1] = I/O Expander B */ - {0, 0x25, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 0x25 */ - }, -}; - -struct inv_port_layout_s hudson32iga_port_layout[] = { - /* Port_ID / Chan_ID / IOEXP_ID / IOEXP_VIRT_OFFSET / TRANSCEIVER_TYPE / BCM_CHIP_TYPE / LANE_ID */ - { 0, 6, 0, 0, TRANSVR_TYPE_QSFP_PLUS, CHIP_TYPE_MAGNOLIA, { 1, 2, 3, 4} }, - { 1, 7, 0, 1, TRANSVR_TYPE_QSFP_PLUS, CHIP_TYPE_MAGNOLIA, { 5, 6, 7, 8} }, - { 2, 8, 0, 2, TRANSVR_TYPE_QSFP_PLUS, CHIP_TYPE_MAGNOLIA, { 9, 10, 11, 12} }, - { 3, 9, 0, 3, TRANSVR_TYPE_QSFP_PLUS, CHIP_TYPE_MAGNOLIA, { 13, 14, 15, 16} }, - { 4, 10, 0, 4, TRANSVR_TYPE_QSFP_PLUS, CHIP_TYPE_MAGNOLIA, { 17, 18, 19, 20} }, - { 5, 11, 0, 5, TRANSVR_TYPE_QSFP_PLUS, CHIP_TYPE_MAGNOLIA, { 21, 22, 23, 24} }, - { 6, 12, 0, 6, TRANSVR_TYPE_QSFP_PLUS, CHIP_TYPE_MAGNOLIA, { 25, 26, 27, 28} }, - { 7, 13, 0, 7, TRANSVR_TYPE_QSFP_PLUS, CHIP_TYPE_MAGNOLIA, { 29, 30, 31, 32} }, - { 8, 14, 1, 0, TRANSVR_TYPE_QSFP_PLUS, CHIP_TYPE_MAGNOLIA, { 33, 34, 35, 36} }, - { 9, 15, 1, 1, TRANSVR_TYPE_QSFP_PLUS, CHIP_TYPE_MAGNOLIA, { 37, 38, 39, 40} }, - {10, 16, 1, 2, TRANSVR_TYPE_QSFP_PLUS, CHIP_TYPE_MAGNOLIA, { 41, 42, 43, 44} }, - {11, 17, 1, 3, TRANSVR_TYPE_QSFP_PLUS, CHIP_TYPE_MAGNOLIA, { 45, 46, 47, 48} }, - {12, 18, 1, 4, TRANSVR_TYPE_QSFP_PLUS, CHIP_TYPE_MAGNOLIA, { 49, 50, 51, 52} }, - {13, 19, 1, 5, TRANSVR_TYPE_QSFP_PLUS, CHIP_TYPE_MAGNOLIA, { 53, 54, 55, 56} }, - {14, 20, 1, 6, TRANSVR_TYPE_QSFP_PLUS, CHIP_TYPE_MAGNOLIA, { 57, 58, 59, 60} }, - {15, 21, 1, 7, TRANSVR_TYPE_QSFP_PLUS, CHIP_TYPE_MAGNOLIA, { 61, 62, 63, 64} }, - {16, 22, 2, 0, TRANSVR_TYPE_QSFP_PLUS, CHIP_TYPE_MAGNOLIA, { 65, 66, 67, 68} }, - {17, 23, 2, 1, TRANSVR_TYPE_QSFP_PLUS, CHIP_TYPE_MAGNOLIA, { 69, 70, 71, 72} }, - {18, 24, 2, 2, TRANSVR_TYPE_QSFP_PLUS, CHIP_TYPE_MAGNOLIA, { 73, 74, 75, 76} }, - {19, 25, 2, 3, TRANSVR_TYPE_QSFP_PLUS, CHIP_TYPE_MAGNOLIA, { 77, 78, 79, 80} }, - {20, 26, 2, 4, TRANSVR_TYPE_QSFP_PLUS, CHIP_TYPE_MAGNOLIA, { 81, 82, 83, 84} }, - {21, 27, 2, 5, TRANSVR_TYPE_QSFP_PLUS, CHIP_TYPE_MAGNOLIA, { 85, 86, 87, 88} }, - {22, 28, 2, 6, TRANSVR_TYPE_QSFP_PLUS, CHIP_TYPE_MAGNOLIA, { 89, 90, 91, 92} }, - {23, 29, 2, 7, TRANSVR_TYPE_QSFP_PLUS, CHIP_TYPE_MAGNOLIA, { 93, 94, 95, 96} }, - {24, 30, 3, 0, TRANSVR_TYPE_QSFP_PLUS, CHIP_TYPE_MAGNOLIA, { 97, 98, 99,100} }, - {25, 31, 3, 1, TRANSVR_TYPE_QSFP_PLUS, CHIP_TYPE_MAGNOLIA, {101,102,103,104} }, - {26, 32, 3, 2, TRANSVR_TYPE_QSFP_PLUS, CHIP_TYPE_MAGNOLIA, {105,106,107,108} }, - {27, 33, 3, 3, TRANSVR_TYPE_QSFP_PLUS, CHIP_TYPE_MAGNOLIA, {109,110,111,112} }, - {28, 34, 3, 4, TRANSVR_TYPE_QSFP_PLUS, CHIP_TYPE_MAGNOLIA, {113,114,115,116} }, - {29, 35, 3, 5, TRANSVR_TYPE_QSFP_PLUS, CHIP_TYPE_MAGNOLIA, {117,118,119,120} }, - {30, 36, 3, 6, TRANSVR_TYPE_QSFP_PLUS, CHIP_TYPE_MAGNOLIA, {121,122,123,124} }, - {31, 37, 3, 7, TRANSVR_TYPE_QSFP_PLUS, CHIP_TYPE_MAGNOLIA, {125,126,127,128} }, -}; -#endif - - -/* ========================================== - * Spruce Layout configuration - * ========================================== - */ -#ifdef SWPS_SPRUCE -unsigned spruce_gpio_rest_mux = MUX_RST_GPIO_48_PAC9548; - -struct inv_ioexp_layout_s spruce_ioexp_layout[] = { - /* IOEXP_ID / IOEXP_TYPE / { Chan_ID, Chip_addr, Read_offset, Write_offset, config_offset, data_default, conf_default } */ - {0, IOEXP_TYPE_SPRUCE_7AB, { {2, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[0] = I/O Expander 7A */ - {2, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xf0, 0x33}, }, }, /* addr[2] = I/O Expander 7B */ - }, -}; - -struct inv_port_layout_s spruce_port_layout[] = { - /* Port_ID / Chan_ID / IOEXP_ID / IOEXP_VIRT_OFFSET / TRANSCEIVER_TYPE / BCM_CHIP_TYPE / LANE_ID */ - { 0, 6, 0, 0, TRANSVR_TYPE_QSFP_PLUS, CHIP_TYPE_MAGNOLIA, { 81, 82, 83, 84} }, - { 1, 7, 0, 1, TRANSVR_TYPE_QSFP_PLUS, CHIP_TYPE_MAGNOLIA, { 77, 78, 79, 80} }, - { 2, 8, 0, 2, TRANSVR_TYPE_QSFP_PLUS, CHIP_TYPE_MAGNOLIA, { 97, 98, 99,100} }, - { 3, 9, 0, 3, TRANSVR_TYPE_QSFP_PLUS, CHIP_TYPE_MAGNOLIA, {101,102,103,104} }, - { 4, 10, 0, 4, TRANSVR_TYPE_QSFP_PLUS, CHIP_TYPE_MAGNOLIA, {105,106,107,108} }, - { 5, 11, 0, 5, TRANSVR_TYPE_QSFP_PLUS, CHIP_TYPE_MAGNOLIA, {109,110,111,112} }, -}; -#endif - - -/* ========================================== - * Cypress Layout configuration (Inventec version [Up->Down]) - * ========================================== - */ -#ifdef SWPS_CYPRESS_GA1 -unsigned cypress_ga1_gpio_rest_mux = MUX_RST_GPIO_69_PAC9548; - -struct inv_ioexp_layout_s cypress_ga1_ioexp_layout[] = { - /* IOEXP_ID / IOEXP_TYPE / { Chan_ID, Chip_addr, Read_offset, Write_offset, config_offset, data_default, conf_default } */ - {0, IOEXP_TYPE_CYPRESS_NABC, { {2, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {2, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {2, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {1, IOEXP_TYPE_CYPRESS_NABC, { {3, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {3, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {3, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {2, IOEXP_TYPE_CYPRESS_NABC, { {4, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {4, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {4, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {3, IOEXP_TYPE_CYPRESS_NABC, { {5, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {5, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {5, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {4, IOEXP_TYPE_CYPRESS_NABC, { {6, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {6, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {6, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {5, IOEXP_TYPE_CYPRESS_NABC, { {7, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {7, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {7, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {6, IOEXP_TYPE_CYPRESS_7ABC, { {8, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xc0, 0xc0}, }, /* addr[0] = I/O Expander 7 A */ - {8, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xc0, 0xc0}, {0xff, 0xc0}, }, /* addr[1] = I/O Expander 7 B */ - {8, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 7 C */ - }, -}; - -struct inv_port_layout_s cypress_ga1_port_layout[] = { - /* Port_ID / Chan_ID / IOEXP_ID / IOEXP_VIRT_OFFSET / TRANSCEIVER_TYPE / BCM_CHIP_TYPE / LANE_ID */ - { 0, 10, 0, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 1} }, - { 1, 11, 0, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 2} }, - { 2, 12, 0, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 3} }, - { 3, 13, 0, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 4} }, - { 4, 14, 0, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 5} }, - { 5, 15, 0, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 6} }, - { 6, 16, 0, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 7} }, - { 7, 17, 0, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 8} }, - { 8, 18, 1, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 9} }, - { 9, 19, 1, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 10} }, - {10, 20, 1, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 11} }, - {11, 21, 1, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 12} }, - {12, 22, 1, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 21} }, - {13, 23, 1, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 22} }, - {14, 24, 1, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 23} }, - {15, 25, 1, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 24} }, - {16, 26, 2, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 33} }, - {17, 27, 2, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 34} }, - {18, 28, 2, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 35} }, - {19, 29, 2, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 36} }, - {20, 30, 2, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 37} }, - {21, 31, 2, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 38} }, - {22, 32, 2, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 39} }, - {23, 33, 2, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 40} }, - {24, 34, 3, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 41} }, - {25, 35, 3, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 42} }, - {26, 36, 3, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 43} }, - {27, 37, 3, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 44} }, - {28, 38, 3, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 49} }, - {29, 39, 3, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 50} }, - {30, 40, 3, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 51} }, - {31, 41, 3, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 52} }, - {32, 42, 4, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 53} }, - {33, 43, 4, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 54} }, - {34, 44, 4, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 55} }, - {35, 45, 4, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 56} }, - {36, 46, 4, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 65} }, - {37, 47, 4, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 66} }, - {38, 48, 4, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 67} }, - {39, 49, 4, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 68} }, - {40, 50, 5, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 69} }, - {41, 51, 5, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 70} }, - {42, 52, 5, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 71} }, - {43, 53, 5, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 72} }, - {44, 54, 5, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 81} }, - {45, 55, 5, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 82} }, - {46, 56, 5, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 83} }, - {47, 57, 5, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 84} }, - {48, 58, 6, 0, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 97, 98, 99,100} }, - {49, 59, 6, 1, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 85, 86, 87, 88} }, - {50, 60, 6, 2, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {101,102,103,104} }, - {51, 61, 6, 3, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {105,106,107,108} }, - {52, 62, 6, 4, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {109,110,111,112} }, - {53, 63, 6, 5, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {117,118,119,120} }, -}; -#endif - - -/* ========================================== - * Cypress Layout configuration (Inventec version [Down->Up]) - * ========================================== - */ -#ifdef SWPS_CYPRESS_GA2 -unsigned cypress_ga2_gpio_rest_mux = MUX_RST_GPIO_FORCE_HEDERA; - -struct inv_ioexp_layout_s cypress_ga2_ioexp_layout[] = { - /* IOEXP_ID / IOEXP_TYPE / { Chan_ID, Chip_addr, Read_offset, Write_offset, config_offset, data_default, conf_default } */ - {0, IOEXP_TYPE_CYPRESS_NABC, { {2, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {2, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {2, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {1, IOEXP_TYPE_CYPRESS_NABC, { {3, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {3, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {3, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {2, IOEXP_TYPE_CYPRESS_NABC, { {4, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {4, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {4, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {3, IOEXP_TYPE_CYPRESS_NABC, { {5, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {5, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {5, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {4, IOEXP_TYPE_CYPRESS_NABC, { {6, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {6, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {6, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {5, IOEXP_TYPE_CYPRESS_NABC, { {7, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {7, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {7, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {6, IOEXP_TYPE_CYPRESS_7ABC, { {8, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xc0, 0xc0}, }, /* addr[0] = I/O Expander 7 A */ - {8, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xc0, 0xc0}, {0xff, 0xc0}, }, /* addr[1] = I/O Expander 7 B */ - {8, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 7 C */ - }, -}; - -struct inv_port_layout_s cypress_ga2_port_layout[] = { - /* Port_ID / Chan_ID / IOEXP_ID / IOEXP_VIRT_OFFSET / TRANSCEIVER_TYPE / BCM_CHIP_TYPE / LANE_ID */ - { 0, 11, 0, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 2} }, - { 1, 10, 0, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 1} }, - { 2, 13, 0, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 4} }, - { 3, 12, 0, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 3} }, - { 4, 15, 0, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 6} }, - { 5, 14, 0, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 5} }, - { 6, 17, 0, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 8} }, - { 7, 16, 0, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 7} }, - { 8, 19, 1, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 10} }, - { 9, 18, 1, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 9} }, - {10, 21, 1, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 12} }, - {11, 20, 1, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 11} }, - {12, 23, 1, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 22} }, - {13, 22, 1, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 21} }, - {14, 25, 1, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 24} }, - {15, 24, 1, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 23} }, - {16, 27, 2, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 34} }, - {17, 26, 2, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 33} }, - {18, 29, 2, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 36} }, - {19, 28, 2, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 35} }, - {20, 31, 2, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 38} }, - {21, 30, 2, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 37} }, - {22, 33, 2, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 40} }, - {23, 32, 2, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 39} }, - {24, 35, 3, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 42} }, - {25, 34, 3, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 41} }, - {26, 37, 3, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 44} }, - {27, 36, 3, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 43} }, - {28, 39, 3, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 50} }, - {29, 38, 3, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 49} }, - {30, 41, 3, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 52} }, - {31, 40, 3, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 51} }, - {32, 43, 4, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 54} }, - {33, 42, 4, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 53} }, - {34, 45, 4, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 56} }, - {35, 44, 4, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 55} }, - {36, 47, 4, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 66} }, - {37, 46, 4, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 65} }, - {38, 49, 4, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 68} }, - {39, 48, 4, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 67} }, - {40, 51, 5, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 70} }, - {41, 50, 5, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 69} }, - {42, 53, 5, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 72} }, - {43, 52, 5, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 71} }, - {44, 55, 5, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 82} }, - {45, 54, 5, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 81} }, - {46, 57, 5, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 84} }, - {47, 56, 5, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 83} }, - {48, 59, 6, 1, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 85, 86, 87, 88} }, - {49, 58, 6, 0, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 97, 98, 99,100} }, - {50, 61, 6, 3, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {105,106,107,108} }, - {51, 60, 6, 2, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {101,102,103,104} }, - {52, 63, 6, 5, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {117,118,119,120} }, - {53, 62, 6, 4, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {109,110,111,112} }, -}; -#endif - - -/* ========================================== - * Cypress Layout configuration (C1 version) - * ========================================== - */ -#ifdef SWPS_CYPRESS_BAI -unsigned cypress_b_gpio_rest_mux = MUX_RST_GPIO_FORCE_HEDERA; - -struct inv_ioexp_layout_s cypress_b_ioexp_layout[] = { - /* IOEXP_ID / IOEXP_TYPE / { Chan_ID, Chip_addr, Read_offset, Write_offset, config_offset, data_default, conf_default } */ - {0, IOEXP_TYPE_CYPRESS_NABC, { {2, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {2, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {2, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {1, IOEXP_TYPE_CYPRESS_NABC, { {3, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {3, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {3, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {2, IOEXP_TYPE_CYPRESS_NABC, { {4, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {4, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {4, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {3, IOEXP_TYPE_CYPRESS_NABC, { {5, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {5, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {5, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {4, IOEXP_TYPE_CYPRESS_NABC, { {6, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {6, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {6, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {5, IOEXP_TYPE_CYPRESS_NABC, { {7, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {7, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {7, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {6, IOEXP_TYPE_CYPRESS_7ABC, { {8, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xc0, 0xc0}, }, /* addr[0] = I/O Expander 7 A */ - {8, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xc0, 0xc0}, {0xff, 0xc0}, }, /* addr[1] = I/O Expander 7 B */ - {8, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 7 C */ - }, -}; - -struct inv_port_layout_s cypress_b_port_layout[] = { - /* Port_ID / Chan_ID / IOEXP_ID / IOEXP_VIRT_OFFSET / TRANSCEIVER_TYPE / BCM_CHIP_TYPE / LANE_ID */ - { 1, 11, 0, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 2} }, - { 2, 10, 0, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 1} }, - { 3, 13, 0, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 4} }, - { 4, 12, 0, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 3} }, - { 5, 15, 0, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 6} }, - { 6, 14, 0, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 5} }, - { 7, 17, 0, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 8} }, - { 8, 16, 0, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 7} }, - { 9, 19, 1, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 10} }, - {10, 18, 1, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 9} }, - {11, 21, 1, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 12} }, - {12, 20, 1, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 11} }, - {13, 23, 1, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 22} }, - {14, 22, 1, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 21} }, - {15, 25, 1, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 24} }, - {16, 24, 1, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 23} }, - {17, 27, 2, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 34} }, - {18, 26, 2, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 33} }, - {19, 29, 2, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 36} }, - {20, 28, 2, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 35} }, - {21, 31, 2, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 38} }, - {22, 30, 2, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 37} }, - {23, 33, 2, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 40} }, - {24, 32, 2, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 39} }, - {25, 35, 3, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 42} }, - {26, 34, 3, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 41} }, - {27, 37, 3, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 44} }, - {28, 36, 3, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 43} }, - {29, 39, 3, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 50} }, - {30, 38, 3, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 49} }, - {31, 41, 3, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 52} }, - {32, 40, 3, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 51} }, - {33, 43, 4, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 54} }, - {34, 42, 4, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 53} }, - {35, 45, 4, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 56} }, - {36, 44, 4, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 55} }, - {37, 47, 4, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 66} }, - {38, 46, 4, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 65} }, - {39, 49, 4, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 68} }, - {40, 48, 4, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 67} }, - {41, 51, 5, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 70} }, - {42, 50, 5, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 69} }, - {43, 53, 5, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 72} }, - {44, 52, 5, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 71} }, - {45, 55, 5, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 82} }, - {46, 54, 5, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 81} }, - {47, 57, 5, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 84} }, - {48, 56, 5, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 83} }, - {49, 59, 6, 1, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 85, 86, 87, 88} }, - {50, 58, 6, 0, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 97, 98, 99,100} }, - {51, 61, 6, 3, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {105,106,107,108} }, - {52, 60, 6, 2, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {101,102,103,104} }, - {53, 63, 6, 5, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {117,118,119,120} }, - {54, 62, 6, 4, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {109,110,111,112} }, -}; -#endif - - -/* ========================================== - * Redwood_fsl Layout configuration - * ========================================== - */ -#ifdef SWPS_REDWOOD_FSL -unsigned redwood_fsl_gpio_rest_mux = MUX_RST_GPIO_48_PAC9548; - -struct inv_ioexp_layout_s redwood_fsl_ioexp_layout[] = { - /* IOEXP_ID / IOEXP_TYPE / { Chan_ID, Chip_addr, Read_offset, Write_offset, config_offset, data_default, conf_default } */ - {0, IOEXP_TYPE_REDWOOD_P01P08, { {4, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[0] = I/O Expander 1-4 A */ - {4, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[1] = I/O Expander 1-4 B */ - {0, 0x25, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 5 B */ - }, - {1, IOEXP_TYPE_REDWOOD_P09P16, { {5, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[0] = I/O Expander 1-4 A */ - {5, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[1] = I/O Expander 1-4 B */ - {0, 0x25, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 5 B */ - }, - {2, IOEXP_TYPE_REDWOOD_P01P08, { {2, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[0] = I/O Expander 1-4 A */ - {2, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[1] = I/O Expander 1-4 B */ - {0, 0x24, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 5 B */ - }, - {3, IOEXP_TYPE_REDWOOD_P09P16, { {3, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[0] = I/O Expander 1-4 A */ - {3, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[1] = I/O Expander 1-4 B */ - {0, 0x24, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 5 B */ - }, -}; - - -struct inv_port_layout_s redwood_fsl_port_layout[] = { - /* Port_ID / Chan_ID / IOEXP_ID / IOEXP_VIRT_OFFSET / TRANSCEIVER_TYPE / BCM_CHIP_TYPE / LANE_ID */ - { 0, 22, 0, 0, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 1, 2, 3, 4} }, - { 1, 23, 0, 1, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 5, 6, 7, 8} }, - { 2, 24, 0, 2, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 9, 10, 11, 12} }, - { 3, 25, 0, 3, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 13, 14, 15, 16} }, - { 4, 26, 0, 4, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 17, 18, 19, 20} }, - { 5, 27, 0, 5, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 21, 22, 23, 24} }, - { 6, 28, 0, 6, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 25, 26, 27, 28} }, - { 7, 29, 0, 7, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 29, 30, 31, 32} }, - { 8, 30, 1, 0, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 33, 34, 35, 36} }, - { 9, 31, 1, 1, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 37, 38, 39, 40} }, - {10, 32, 1, 2, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 41, 42, 43, 44} }, - {11, 33, 1, 3, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 45, 46, 47, 48} }, - {12, 34, 1, 4, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 49, 50, 51, 52} }, - {13, 35, 1, 5, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 53, 54, 55, 56} }, - {14, 36, 1, 6, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 57, 58, 59, 60} }, - {15, 37, 1, 7, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 61, 62, 63, 64} }, - {16, 6, 2, 0, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 65, 66, 67, 68} }, - {17, 7, 2, 1, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 69, 70, 71, 72} }, - {18, 8, 2, 2, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 73, 74, 75, 76} }, - {19, 9, 2, 3, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 77, 78, 79, 80} }, - {20, 10, 2, 4, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 81, 82, 83, 84} }, - {21, 11, 2, 5, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 85, 86, 87, 88} }, - {22, 12, 2, 6, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 89, 90, 91, 92} }, - {23, 13, 2, 7, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 93, 94, 95, 96} }, - {24, 14, 3, 0, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 97, 98, 99,100} }, - {25, 15, 3, 1, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {101,102,103,104} }, - {26, 16, 3, 2, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {105,106,107,108} }, - {27, 17, 3, 3, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {109,110,111,112} }, - {28, 18, 3, 4, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {113,114,115,116} }, - {29, 19, 3, 5, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {117,118,119,120} }, - {30, 20, 3, 6, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {121,122,123,124} }, - {31, 21, 3, 7, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {125,126,127,128} }, -}; -#endif - - -/* ========================================== - * Tahoe Layout configuration - * ========================================== - */ -#ifdef SWPS_TAHOE -unsigned tahoe_gpio_rest_mux = MUX_RST_GPIO_249_PCA9548; - -struct inv_ioexp_layout_s tahoe_ioexp_layout[] = { - /* IOEXP_ID / IOEXP_TYPE / { Chan_ID, Chip_addr, Read_offset, Write_offset, config_offset, data_default, conf_default } */ - {0, IOEXP_TYPE_TAHOE_6ABC, { {7, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xce, 0xb9}, {0x18, 0xe3}, }, /* addr[0] = I/O Expander 6 A */ - {7, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xce, 0xb9}, {0x18, 0xe3}, }, /* addr[1] = I/O Expander 6 B */ - {7, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xce, 0xb9}, {0x18, 0xe3}, }, }, /* addr[2] = I/O Expander 6 C */ - }, - {1, IOEXP_TYPE_TAHOE_5A, { {6, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xce, 0xb9}, {0x18, 0xe3}, }, }, /* addr[0] = I/O Expander 5 A */ - }, -}; - - -struct inv_port_layout_s tahoe_port_layout[] = { - /* Port_ID / Chan_ID / IOEXP_ID / IOEXP_VIRT_OFFSET / TRANSCEIVER_TYPE / BCM_CHIP_TYPE / LANE_ID */ - { 0, 12, 1, 2, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 65, 66, 67, 68} }, - { 1, 11, 1, 1, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 53, 54, 55, 56} }, - { 2, 22, 0, 5, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 69, 70, 71, 72} }, - { 3, 21, 0, 4, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 81, 82, 83, 84} }, - { 4, 24, 0, 7, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 97, 98, 99, 100} }, - { 5, 23, 0, 6, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 85, 86, 87, 88} }, - { 6, 18, 0, 1, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {101, 102, 103, 104} }, - { 7, 17, 0, 0, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {105, 106, 107, 108} }, - { 8, 20, 0, 3, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {113, 114, 115, 116} }, - { 9, 19, 0, 2, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {109, 110, 111, 112} }, -}; -#endif - - -/* ========================================== - * Sequoia Layout configuration - * ========================================== - */ -#ifdef SWPS_SEQUOIA -unsigned sequoia_gpio_rest_mux = MUX_RST_GPIO_69_PAC9548; - -struct inv_ioexp_layout_s sequoia_ioexp_layout[] = { - /* IOEXP_ID / IOEXP_TYPE / { Chan_ID, Chip_addr, Read_offset, Write_offset, config_offset, data_default, conf_default } */ - {0, IOEXP_TYPE_SEQUOIA_NABC, { {1, 0x20, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0x00, 0x00}, }, /* addr[0] = I/O Expander 0 A */ - {1, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0xff}, }, /* addr[1] = I/O Expander 0 B */ - {1, 0x22, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 0 C */ - }, - {1, IOEXP_TYPE_SEQUOIA_NABC, { {2, 0x20, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0x00, 0x00}, }, /* addr[0] = I/O Expander 1 A */ - {2, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0xff}, }, /* addr[1] = I/O Expander 1 B */ - {2, 0x22, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 1 C */ - }, - {2, IOEXP_TYPE_SEQUOIA_NABC, { {3, 0x20, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0x00, 0x00}, }, /* addr[0] = I/O Expander 2 A */ - {3, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0xff}, }, /* addr[1] = I/O Expander 2 B */ - {3, 0x22, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 2 C */ - }, - {3, IOEXP_TYPE_SEQUOIA_NABC, { {4, 0x20, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0x00, 0x00}, }, /* addr[0] = I/O Expander 3 A */ - {4, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0xff}, }, /* addr[1] = I/O Expander 3 B */ - {4, 0x22, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 3 C */ - }, - {4, IOEXP_TYPE_SEQUOIA_NABC, { {5, 0x20, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0x00, 0x00}, }, /* addr[0] = I/O Expander 4 A */ - {5, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0xff}, }, /* addr[1] = I/O Expander 4 B */ - {5, 0x22, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 4 C */ - }, - {5, IOEXP_TYPE_SEQUOIA_NABC, { {6, 0x20, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0x00, 0x00}, }, /* addr[0] = I/O Expander 5 A */ - {6, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0xff}, }, /* addr[1] = I/O Expander 5 B */ - {6, 0x22, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 5 C */ - }, - {6, IOEXP_TYPE_SEQUOIA_NABC, { {7, 0x20, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0x00, 0x00}, }, /* addr[0] = I/O Expander 6 A */ - {7, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0xff}, }, /* addr[1] = I/O Expander 6 B */ - {7, 0x22, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 6 C */ - }, - {7, IOEXP_TYPE_SEQUOIA_NABC, { {8, 0x20, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0x00, 0x00}, }, /* addr[0] = I/O Expander 7 A */ - {8, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0xff}, }, /* addr[1] = I/O Expander 7 B */ - {8, 0x22, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 7 C */ - }, -}; - - -struct inv_port_layout_s sequoia_port_layout[] = { - /* Port_ID / Chan_ID / IOEXP_ID / IOEXP_VIRT_OFFSET / TRANSCEIVER_TYPE / BCM_CHIP_TYPE / LANE_ID */ - { 0, 9, 0, 0, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 9, 10, 11, 12} }, - { 1, 10, 0, 1, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 1, 2, 3, 4} }, - { 2, 11, 0, 2, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 25, 26, 27, 28} }, - { 3, 12, 0, 3, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 17, 18, 19, 20} }, - { 4, 13, 0, 4, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 41, 42, 43, 44} }, - { 5, 14, 0, 5, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 33, 34, 35, 36} }, - { 6, 15, 0, 6, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 57, 58, 59, 60} }, - { 7, 16, 0, 7, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 49, 50, 51, 52} }, - { 8, 17, 1, 0, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 73, 74, 75, 76} }, - { 9, 18, 1, 1, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 65, 66, 67, 68} }, - {10, 19, 1, 2, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 89, 90, 91, 92} }, - {11, 20, 1, 3, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 81, 82, 83, 84} }, - {12, 21, 1, 4, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {105, 106, 107, 108} }, - {13, 22, 1, 5, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 97, 98, 99, 100} }, - {14, 23, 1, 6, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {121, 122, 123, 124} }, - {15, 24, 1, 7, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {113, 114, 115, 116} }, - {16, 25, 2, 0, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {137, 138, 139, 140} }, - {17, 26, 2, 1, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {129, 130, 131, 132} }, - {18, 27, 2, 2, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {153, 154, 155, 156} }, - {19, 28, 2, 3, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {145, 146, 147, 148} }, - {20, 29, 2, 4, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {169, 170, 171, 172} }, - {21, 30, 2, 5, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {161, 162, 163, 164} }, - {22, 31, 2, 6, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {185, 186, 187, 188} }, - {23, 32, 2, 7, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {177, 178, 179, 180} }, - {24, 33, 3, 0, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {201, 202, 203, 204} }, - {25, 34, 3, 1, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {193, 194, 195, 196} }, - {26, 35, 3, 2, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {217, 218, 219, 220} }, - {27, 36, 3, 3, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {209, 210, 211, 212} }, - {28, 37, 3, 4, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {233, 234, 235, 236} }, - {29, 38, 3, 5, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {225, 226, 227, 228} }, - {30, 39, 3, 6, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {249, 250, 251, 252} }, - {31, 40, 3, 7, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {241, 242, 243, 244} }, - {32, 44, 4, 3, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 13, 14, 15, 16} }, - {33, 43, 4, 2, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 5, 6, 7, 8} }, - {34, 42, 4, 1, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 29, 30, 31, 32} }, - {35, 41, 4, 0, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 21, 22, 23, 24} }, - {36, 48, 4, 7, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 45, 46, 47, 48} }, - {37, 47, 4, 6, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 37, 38, 39, 40} }, - {38, 46, 4, 5, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 61, 62, 63, 64} }, - {39, 45, 4, 4, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 53, 54, 55, 56} }, - {40, 52, 5, 3, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 77, 78, 79, 80} }, - {41, 51, 5, 2, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 69, 70, 71, 72} }, - {42, 50, 5, 1, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 93, 94, 95, 96} }, - {43, 49, 5, 0, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 85, 86, 87, 88} }, - {44, 56, 5, 7, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {109, 110, 111, 112} }, - {45, 55, 5, 6, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {101, 102, 103, 104} }, - {46, 54, 5, 5, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {125, 126, 127, 128} }, - {47, 53, 5, 4, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {117, 118, 119, 120} }, - {48, 60, 6, 3, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {141, 142, 143, 144} }, - {49, 59, 6, 2, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {133, 134, 135, 136} }, - {50, 58, 6, 1, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {157, 158, 159, 160} }, - {51, 57, 6, 0, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {149, 150, 151, 152} }, - {52, 64, 6, 7, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {173, 174, 175, 176} }, - {53, 63, 6, 6, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {165, 166, 167, 168} }, - {54, 62, 6, 5, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {189, 190, 191, 192} }, - {55, 61, 6, 4, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {181, 182, 183, 184} }, - {56, 68, 7, 3, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {205, 206, 207, 208} }, - {57, 67, 7, 2, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {197, 198, 199, 200} }, - {58, 66, 7, 1, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {221, 222, 223, 224} }, - {59, 65, 7, 0, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {213, 214, 215, 216} }, - {60, 72, 7, 7, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {237, 238, 239, 240} }, - {61, 71, 7, 6, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {229, 230, 231, 232} }, - {62, 70, 7, 5, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {253, 254, 255, 256} }, - {63, 69, 7, 4, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {245, 246, 247, 248} }, -}; -#endif - - -/* ========================================== - * Lavender Layout configuration - * ========================================== - */ -#if (PLATFORM_SETTINGS == PLATFORM_TYPE_LAVENDER_GA) -unsigned lavender_gpio_rest_mux = MUX_RST_GPIO_505_PCA9548; -#elif (PLATFORM_SETTINGS == PLATFORM_TYPE_LAVENDER_ONL) -unsigned lavender_gpio_rest_mux = MUX_RST_GPIO_69_PAC9548; -#endif - -#ifdef SWPS_LAVENDER -struct inv_ioexp_layout_s lavender_ioexp_layout[] = { - /* IOEXP_ID / IOEXP_TYPE / { Chan_ID, Chip_addr, Read_offset, Write_offset, config_offset, data_default, conf_default } */ - {0, IOEXP_TYPE_SEQUOIA_NABC, { { 1, 0x20, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0x00, 0x00}, }, /* addr[0] = I/O Expander 0 A */ - { 1, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0xff}, }, /* addr[1] = I/O Expander 0 B */ - { 1, 0x22, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 0 C */ - }, - {1, IOEXP_TYPE_SEQUOIA_NABC, { { 2, 0x20, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0x00, 0x00}, }, /* addr[0] = I/O Expander 1 A */ - { 2, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0xff}, }, /* addr[1] = I/O Expander 1 B */ - { 2, 0x22, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 1 C */ - }, - {2, IOEXP_TYPE_SEQUOIA_NABC, { { 3, 0x20, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0x00, 0x00}, }, /* addr[0] = I/O Expander 2 A */ - { 3, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0xff}, }, /* addr[1] = I/O Expander 2 B */ - { 3, 0x22, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 2 C */ - }, - {3, IOEXP_TYPE_SEQUOIA_NABC, { { 4, 0x20, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0x00, 0x00}, }, /* addr[0] = I/O Expander 3 A */ - { 4, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0xff}, }, /* addr[1] = I/O Expander 3 B */ - { 4, 0x22, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 3 C */ - }, - {4, IOEXP_TYPE_SEQUOIA_NABC, { { 9, 0x20, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0x00, 0x00}, }, /* addr[0] = I/O Expander 4 A */ - { 9, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0xff}, }, /* addr[1] = I/O Expander 4 B */ - { 9, 0x22, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 4 C */ - }, - {5, IOEXP_TYPE_SEQUOIA_NABC, { {10, 0x20, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0x00, 0x00}, }, /* addr[0] = I/O Expander 5 A */ - {10, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0xff}, }, /* addr[1] = I/O Expander 5 B */ - {10, 0x22, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 5 C */ - }, - {6, IOEXP_TYPE_SEQUOIA_NABC, { {11, 0x20, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0x00, 0x00}, }, /* addr[0] = I/O Expander 6 A */ - {11, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0xff}, }, /* addr[1] = I/O Expander 6 B */ - {11, 0x22, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 6 C */ - }, - {7, IOEXP_TYPE_SEQUOIA_NABC, { {12, 0x20, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0x00, 0x00}, }, /* addr[0] = I/O Expander 7 A */ - {12, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0xff}, }, /* addr[1] = I/O Expander 7 B */ - {12, 0x22, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 7 C */ - }, - {8, IOEXP_TYPE_LAVENDER_P65, { { 5, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xF6, 0xff}, {0xF8, 0xff}, }, }, /* addr[0] = I/O Expander CPU */ - }, -}; - - -struct inv_port_layout_s lavender_port_layout[] = { - /* Port_ID / Chan_ID / IOEXP_ID / IOEXP_VIRT_OFFSET / TRANSCEIVER_TYPE / BCM_CHIP_TYPE / LANE_ID */ - { 0, 17, 0, 0, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {188, 189, 190, 191} }, - { 1, 18, 0, 1, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {184, 185, 186, 187} }, - { 2, 19, 0, 2, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {180, 181, 182, 183} }, - { 3, 20, 0, 3, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {176, 177, 178, 179} }, - { 4, 21, 0, 4, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {172, 173, 174, 175} }, - { 5, 22, 0, 5, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {168, 169, 170, 171} }, - { 6, 23, 0, 6, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {164, 165, 166, 167} }, - { 7, 24, 0, 7, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {160, 161, 162, 163} }, - { 8, 25, 1, 0, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {156, 157, 158, 159} }, - { 9, 26, 1, 1, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {152, 153, 154, 155} }, - {10, 27, 1, 2, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {148, 149, 150, 151} }, - {11, 28, 1, 3, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {144, 145, 146, 147} }, - {12, 29, 1, 4, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {140, 141, 142, 143} }, - {13, 30, 1, 5, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {136, 137, 138, 139} }, - {14, 31, 1, 6, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {132, 133, 134, 135} }, - {15, 32, 1, 7, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {128, 129, 130, 131} }, - {16, 33, 2, 0, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, { 0, 1, 2, 3} }, - {17, 34, 2, 1, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, { 4, 5, 6, 7} }, - {18, 35, 2, 2, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, { 8, 9, 10, 11} }, - {19, 36, 2, 3, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, { 12, 13, 14, 15} }, - {20, 37, 2, 4, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, { 16, 17, 18, 19} }, - {21, 38, 2, 5, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, { 20, 21, 22, 23} }, - {22, 39, 2, 6, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, { 24, 25, 26, 27} }, - {23, 40, 2, 7, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, { 28, 29, 30, 31} }, - {24, 41, 3, 0, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, { 32, 33, 34, 35} }, - {25, 42, 3, 1, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, { 36, 37, 38, 39} }, - {26, 43, 3, 2, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, { 40, 41, 42, 43} }, - {27, 44, 3, 3, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, { 44, 45, 46, 47} }, - {28, 45, 3, 4, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, { 48, 49, 50, 51} }, - {29, 46, 3, 5, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, { 52, 53, 54, 55} }, - {30, 47, 3, 6, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, { 56, 57, 58, 59} }, - {31, 48, 3, 7, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, { 60, 61, 62, 63} }, - {32, 49, 4, 0, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {256, 257, 258, 259} }, - {33, 50, 4, 1, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {260, 261, 262, 263} }, - {34, 51, 4, 2, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {264, 265, 266, 267} }, - {35, 52, 4, 3, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {268, 269, 270, 271} }, - {36, 53, 4, 4, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {272, 273, 274, 275} }, - {37, 54, 4, 5, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {276, 277, 278, 279} }, - {38, 55, 4, 6, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {280, 281, 282, 283} }, - {39, 56, 4, 7, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {284, 285, 286, 287} }, - {40, 57, 5, 0, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {288, 289, 290, 291} }, - {41, 58, 5, 1, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {292, 293, 294, 295} }, - {42, 59, 5, 2, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {296, 297, 298, 299} }, - {43, 60, 5, 3, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {300, 301, 302, 303} }, - {44, 61, 5, 4, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {304, 305, 306, 307} }, - {45, 62, 5, 5, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {308, 309, 310, 311} }, - {46, 63, 5, 6, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {312, 313, 314, 315} }, - {47, 64, 5, 7, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {316, 317, 318, 319} }, - {48, 65, 6, 0, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {444, 445, 446, 447} }, - {49, 66, 6, 1, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {440, 441, 442, 443} }, - {50, 67, 6, 2, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {436, 437, 438, 439} }, - {51, 68, 6, 3, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {432, 433, 434, 435} }, - {52, 69, 6, 4, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {428, 429, 430, 431} }, - {53, 70, 6, 5, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {424, 425, 426, 427} }, - {54, 71, 6, 6, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {420, 421, 422, 423} }, - {55, 72, 6, 7, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {416, 417, 418, 419} }, - {56, 73, 7, 0, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {412, 413, 414, 415} }, - {57, 74, 7, 1, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {408, 409, 410, 411} }, - {58, 75, 7, 2, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {404, 405, 406, 407} }, - {59, 76, 7, 3, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {400, 401, 402, 403} }, - {60, 77, 7, 4, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {396, 397, 398, 399} }, - {61, 78, 7, 5, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {392, 393, 394, 395} }, - {62, 79, 7, 6, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {388, 389, 390, 391} }, - {63, 80, 7, 7, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {384, 385, 386, 387} }, - {64, 5, 8, 0, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, { 64, 65, 66, 67} }, -}; -#endif - -/* =========================================================== - * Cottonwood Layout configuration Rangeley (Rangeley CPU board) - * =========================================================== - */ -#ifdef SWPS_COTTONWOOD_RANGELEY -unsigned cottonwood_rangeley_gpio_rest_mux = MUX_RST_GPIO_500_PAC9548; - -struct inv_ioexp_layout_s cottonwood_rangeley_ioexp_layout[] = { - /* IOEXP_ID / IOEXP_TYPE / { Chan_ID, Chip_addr, Read_offset, Write_offset, config_offset, data_default, conf_default } */ - {0, CPLD_TYPE_COTTONWOOD,{ {1, 0x55, {22, 23, 24, 25}, {22, 23, 24, 25}, {-1, -1, -1, -1}, {0xee, 0xee, 0x99, 0x99}, {0x00, 0x00, 0x00, 0x00}, }, - }, - }, -}; - - -struct inv_port_layout_s cottonwood_rangeley_port_layout[] = { - /* Port_ID / Chan_ID / IOEXP_ID / IOEXP_VIRT_OFFSET / TRANSCEIVER_TYPE / BCM_CHI_TYPE / LANE_ID */ - { 0, 2, 0, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 75} }, - { 1, 3, 0, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 77} }, - { 2, 4, 0, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 79} }, - { 3, 5, 0, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 81} }, -}; -#endif - -#endif /* INV_SWPS_H */ - - - - - - - diff --git a/packages/platforms/inventec/x86-64/d3352/modules/builds/src/io_expander.c b/packages/platforms/inventec/x86-64/d3352/modules/builds/src/io_expander.c deleted file mode 100644 index 1d7dd023a..000000000 --- a/packages/platforms/inventec/x86-64/d3352/modules/builds/src/io_expander.c +++ /dev/null @@ -1,1934 +0,0 @@ -#include -#include -#include "io_expander.h" - -static struct ioexp_obj_s *ioexp_head_p = NULL; -static struct ioexp_obj_s *ioexp_tail_p = NULL; - - -/* ========== Register IOEXP layout ========== - */ -struct ioexp_map_s ioexp_map_magnolia_nab = { - - .chip_amount = 2, - .data_width = 2, - - .map_present = { {0, 0, 4}, /* map_present[0] = MOD_ABS_PORT(X) */ - {0, 0, 5}, /* map_present[1] = MOD_ABS_PORT(X+1) */ - {0, 0, 6}, /* map_present[2] = MOD_ABS_PORT(X+2) */ - {0, 0, 7}, /* map_present[3] = MOD_ABS_PORT(X+3) */ - {1, 0, 4}, /* map_present[4] = MOD_ABS_PORT(X+4) */ - {1, 0, 5}, /* map_present[5] = MOD_ABS_PORT(X+5) */ - {1, 0, 6}, /* map_present[6] = MOD_ABS_PORT(X+6) */ - {1, 0, 7}, /* map_present[7] = MOD_ABS_PORT(X+7) */ - }, - .map_tx_disable = { {0, 1, 0}, /* map_tx_disable[0] = TXDISABLE_SFP+_P(X) */ - {0, 1, 1}, /* map_tx_disable[1] = TXDISABLE_SFP+_P(X+1) */ - {0, 1, 2}, /* map_tx_disable[2] = TXDISABLE_SFP+_P(X+2) */ - {0, 1, 3}, /* map_tx_disable[3] = TXDISABLE_SFP+_P(X+3) */ - {1, 1, 0}, /* map_tx_disable[4] = TXDISABLE_SFP+_P(X+4) */ - {1, 1, 1}, /* map_tx_disable[5] = TXDISABLE_SFP+_P(X+5) */ - {1, 1, 2}, /* map_tx_disable[6] = TXDISABLE_SFP+_P(X+6) */ - {1, 1, 3}, /* map_tx_disable[7] = TXDISABLE_SFP+_P(X+7) */ - }, - .map_tx_fault = { {0, 0, 0}, /* map_tx_fault[0] = TXFAULT_SFP+_P(X) */ - {0, 0, 1}, /* map_tx_fault[1] = TXFAULT_SFP+_P(X+1) */ - {0, 0, 2}, /* map_tx_fault[2] = TXFAULT_SFP+_P(X+2) */ - {0, 0, 3}, /* map_tx_fault[3] = TXFAULT_SFP+_P(X+3) */ - {1, 0, 0}, /* map_tx_fault[4] = TXFAULT_SFP+_P(X+4) */ - {1, 0, 1}, /* map_tx_fault[5] = TXFAULT_SFP+_P(X+5) */ - {1, 0, 2}, /* map_tx_fault[6] = TXFAULT_SFP+_P(X+6) */ - {1, 0, 3}, /* map_tx_fault[7] = TXFAULT_SFP+_P(X+7) */ - }, - .map_rxlos = { {0, 1, 4}, /* map_rxlos[0] = OPRXLOS_PORT(X) */ - {0, 1, 5}, /* map_rxlos[1] = OPRXLOS_PORT(X+1) */ - {0, 1, 6}, /* map_rxlos[2] = OPRXLOS_PORT(X+2) */ - {0, 1, 7}, /* map_rxlos[3] = OPRXLOS_PORT(X+3) */ - {1, 1, 4}, /* map_rxlos[4] = OPRXLOS_PORT(X+4) */ - {1, 1, 5}, /* map_rxlos[5] = OPRXLOS_PORT(X+5) */ - {1, 1, 6}, /* map_rxlos[6] = OPRXLOS_PORT(X+6) */ - {1, 1, 7}, /* map_rxlos[7] = OPRXLOS_PORT(X+7) */ - }, -}; - - -struct ioexp_map_s ioexp_map_magnolia_4ab = { - - .chip_amount = 2, - .data_width = 2, - - .map_present = { {0, 0, 4}, /* map_present[0] = MOD_ABS_PORT(X) */ - {0, 0, 5}, /* map_present[1] = MOD_ABS_PORT(X+1) */ - {0, 0, 6}, /* map_present[2] = MOD_ABS_PORT(X+2) */ - {0, 0, 7}, /* map_present[3] = MOD_ABS_PORT(X+3) */ - {1, 0, 4}, /* map_present[4] = MOD_ABS_PORT(X+4) */ - {1, 0, 5}, /* map_present[5] = MOD_ABS_PORT(X+5) */ - {1, 0, 6}, /* map_present[6] = MOD_ABS_PORT(X+6) */ - {1, 0, 7}, /* map_present[7] = MOD_ABS_PORT(X+7) */ - }, - .map_tx_disable = { {0, 1, 0}, /* map_tx_disable[0] = TXDISABLE_SFP+_P(X) */ - {0, 1, 1}, /* map_tx_disable[1] = TXDISABLE_SFP+_P(X+1) */ - {0, 1, 2}, /* map_tx_disable[2] = TXDISABLE_SFP+_P(X+2) */ - {0, 1, 3}, /* map_tx_disable[3] = TXDISABLE_SFP+_P(X+3) */ - {1, 0, 0}, /* map_tx_disable[4] = TXDISABLE_SFP+_P(X+4) */ - {1, 0, 1}, /* map_tx_disable[5] = TXDISABLE_SFP+_P(X+5) */ - {1, 0, 2}, /* map_tx_disable[6] = TXDISABLE_SFP+_P(X+6) */ - {1, 0, 3}, /* map_tx_disable[7] = TXDISABLE_SFP+_P(X+7) */ - }, - .map_tx_fault = { {0, 0, 0}, /* map_tx_fault[0] = TXFAULT_SFP+_P(X) */ - {0, 0, 1}, /* map_tx_fault[1] = TXFAULT_SFP+_P(X+1) */ - {0, 0, 2}, /* map_tx_fault[2] = TXFAULT_SFP+_P(X+2) */ - {0, 0, 3}, /* map_tx_fault[3] = TXFAULT_SFP+_P(X+3) */ - {1, 1, 0}, /* map_tx_fault[4] = TXFAULT_SFP+_P(X+4) */ - {1, 1, 1}, /* map_tx_fault[5] = TXFAULT_SFP+_P(X+5) */ - {1, 1, 2}, /* map_tx_fault[6] = TXFAULT_SFP+_P(X+6) */ - {1, 1, 3}, /* map_tx_fault[7] = TXFAULT_SFP+_P(X+7) */ - }, - .map_rxlos = { {0, 1, 4}, /* map_rxlos[0] = OPRXLOS_PORT(X) */ - {0, 1, 5}, /* map_rxlos[1] = OPRXLOS_PORT(X+1) */ - {0, 1, 6}, /* map_rxlos[2] = OPRXLOS_PORT(X+2) */ - {0, 1, 7}, /* map_rxlos[3] = OPRXLOS_PORT(X+3) */ - {1, 1, 4}, /* map_rxlos[4] = OPRXLOS_PORT(X+4) */ - {1, 1, 5}, /* map_rxlos[5] = OPRXLOS_PORT(X+5) */ - {1, 1, 6}, /* map_rxlos[6] = OPRXLOS_PORT(X+6) */ - {1, 1, 7}, /* map_rxlos[7] = OPRXLOS_PORT(X+7) */ - }, -}; - - -struct ioexp_map_s ioexp_map_magnolia_7ab = { - - .chip_amount = 2, - .data_width = 2, - - .map_present = { {1, 0, 4}, /* map_present[0] = MOD_ABS_PORT(X) */ - {1, 0, 5}, /* map_present[1] = MOD_ABS_PORT(X+1) */ - {1, 0, 6}, /* map_present[2] = MOD_ABS_PORT(X+2) */ - {1, 0, 7}, /* map_present[3] = MOD_ABS_PORT(X+3) */ - {1, 1, 4}, /* map_present[4] = MOD_ABS_PORT(X+4) */ - {1, 1, 5}, /* map_present[5] = MOD_ABS_PORT(X+5) */ - }, - .map_reset = { {0, 0, 0}, /* map_reset[0] = QRESET_QSFP_N_P(X) */ - {0, 0, 1}, /* map_reset[1] = QRESET_QSFP_N_P(X+1) */ - {0, 0, 2}, /* map_reset[2] = QRESET_QSFP_N_P(X+2) */ - {0, 0, 3}, /* map_reset[3] = QRESET_QSFP_N_P(X+3) */ - {1, 0, 0}, /* map_reset[4] = QRESET_QSFP_N_P(X+4) */ - {1, 0, 1}, /* map_reset[5] = QRESET_QSFP_N_P(X+5) */ - }, - .map_lpmod = { {0, 0, 4}, /* map_lpmod[0] = LPMODE_QSFP_P(X) */ - {0, 0, 5}, /* map_lpmod[1] = LPMODE_QSFP_P(X+1) */ - {0, 0, 6}, /* map_lpmod[2] = LPMODE_QSFP_P(X+2) */ - {0, 0, 7}, /* map_lpmod[3] = LPMODE_QSFP_P(X+3) */ - {1, 0, 2}, /* map_lpmod[4] = LPMODE_QSFP_P(X+4) */ - {1, 0, 3}, /* map_lpmod[5] = LPMODE_QSFP_P(X+5) */ - }, - .map_modsel = { {0, 1, 4}, /* map_modsel[0] = MODSEL_QSFP_N_P(X) */ - {0, 1, 5}, /* map_modsel[1] = MODSEL_QSFP_N_P(X+1) */ - {0, 1, 6}, /* map_modsel[2] = MODSEL_QSFP_N_P(X+2) */ - {0, 1, 7}, /* map_modsel[3] = MODSEL_QSFP_N_P(X+3) */ - {1, 1, 4}, /* map_modsel[4] = MODSEL_QSFP_N_P(X+4) */ - {1, 1, 5}, /* map_modsel[5] = MODSEL_QSFP_N_P(X+5) */ - }, -}; - - -struct ioexp_map_s ioexp_map_redwood_p01p08_p17p24 = { - - .chip_amount = 3, - .data_width = 2, - - .map_present = { {2, 0, 0}, /* map_present[0] = MOD_ABS_PORT(X) */ - {2, 0, 1}, /* map_present[1] = MOD_ABS_PORT(X+1) */ - {2, 0, 2}, /* map_present[2] = MOD_ABS_PORT(X+2) */ - {2, 0, 3}, /* map_present[3] = MOD_ABS_PORT(X+3) */ - {2, 0, 4}, /* map_present[4] = MOD_ABS_PORT(X+4) */ - {2, 0, 5}, /* map_present[5] = MOD_ABS_PORT(X+5) */ - {2, 0, 6}, /* map_present[6] = MOD_ABS_PORT(X+6) */ - {2, 0, 7}, /* map_present[7] = MOD_ABS_PORT(X+7) */ - }, - .map_reset = { {0, 0, 0}, /* map_reset[0] = QRESET_QSFP28_N_P(X) */ - {0, 0, 1}, /* map_reset[1] = QRESET_QSFP28_N_P(X+1) */ - {0, 0, 2}, /* map_reset[2] = QRESET_QSFP28_N_P(X+2) */ - {0, 0, 3}, /* map_reset[3] = QRESET_QSFP28_N_P(X+3) */ - {1, 0, 0}, /* map_reset[4] = QRESET_QSFP28_N_P(X+4) */ - {1, 0, 1}, /* map_reset[5] = QRESET_QSFP28_N_P(X+5) */ - {1, 0, 2}, /* map_reset[6] = QRESET_QSFP28_N_P(X+6) */ - {1, 0, 3}, /* map_reset[7] = QRESET_QSFP28_N_P(X+7) */ - }, - .map_lpmod = { {0, 0, 4}, /* map_lpmod[0] = LPMODE_QSFP28_P(X) */ - {0, 0, 5}, /* map_lpmod[1] = LPMODE_QSFP28_P(X+1) */ - {0, 0, 6}, /* map_lpmod[2] = LPMODE_QSFP28_P(X+2) */ - {0, 0, 7}, /* map_lpmod[3] = LPMODE_QSFP28_P(X+3) */ - {1, 0, 4}, /* map_lpmod[4] = LPMODE_QSFP28_P(X+4) */ - {1, 0, 5}, /* map_lpmod[5] = LPMODE_QSFP28_P(X+5) */ - {1, 0, 6}, /* map_lpmod[6] = LPMODE_QSFP28_P(X+6) */ - {1, 0, 7}, /* map_lpmod[7] = LPMODE_QSFP28_P(X+7) */ - }, - .map_modsel = { {0, 1, 4}, /* map_modsel[0] = MODSEL_QSFP28_N_P(X) */ - {0, 1, 5}, /* map_modsel[1] = MODSEL_QSFP28_N_P(X+1) */ - {0, 1, 6}, /* map_modsel[2] = MODSEL_QSFP28_N_P(X+2) */ - {0, 1, 7}, /* map_modsel[3] = MODSEL_QSFP28_N_P(X+3) */ - {1, 1, 4}, /* map_modsel[4] = MODSEL_QSFP28_N_P(X+4) */ - {1, 1, 5}, /* map_modsel[5] = MODSEL_QSFP28_N_P(X+5) */ - {1, 1, 6}, /* map_modsel[6] = MODSEL_QSFP28_N_P(X+6) */ - {1, 1, 7}, /* map_modsel[7] = MODSEL_QSFP28_N_P(X+7) */ - }, -}; - - -struct ioexp_map_s ioexp_map_redwood_p09p16_p25p32 = { - - .chip_amount = 3, - .data_width = 2, - - .map_present = { {2, 1, 0}, /* map_present[0] = MOD_ABS_PORT(X) */ - {2, 1, 1}, /* map_present[1] = MOD_ABS_PORT(X+1) */ - {2, 1, 2}, /* map_present[2] = MOD_ABS_PORT(X+2) */ - {2, 1, 3}, /* map_present[3] = MOD_ABS_PORT(X+3) */ - {2, 1, 4}, /* map_present[4] = MOD_ABS_PORT(X+4) */ - {2, 1, 5}, /* map_present[5] = MOD_ABS_PORT(X+5) */ - {2, 1, 6}, /* map_present[6] = MOD_ABS_PORT(X+6) */ - {2, 1, 7}, /* map_present[7] = MOD_ABS_PORT(X+7) */ - }, - .map_reset = { {0, 0, 0}, /* map_reset[0] = QRESET_QSFP28_N_P(X) */ - {0, 0, 1}, /* map_reset[1] = QRESET_QSFP28_N_P(X+1) */ - {0, 0, 2}, /* map_reset[2] = QRESET_QSFP28_N_P(X+2) */ - {0, 0, 3}, /* map_reset[3] = QRESET_QSFP28_N_P(X+3) */ - {1, 0, 0}, /* map_reset[4] = QRESET_QSFP28_N_P(X+4) */ - {1, 0, 1}, /* map_reset[5] = QRESET_QSFP28_N_P(X+5) */ - {1, 0, 2}, /* map_reset[6] = QRESET_QSFP28_N_P(X+6) */ - {1, 0, 3}, /* map_reset[7] = QRESET_QSFP28_N_P(X+7) */ - }, - .map_lpmod = { {0, 0, 4}, /* map_lpmod[0] = LPMODE_QSFP28_P(X) */ - {0, 0, 5}, /* map_lpmod[1] = LPMODE_QSFP28_P(X+1) */ - {0, 0, 6}, /* map_lpmod[2] = LPMODE_QSFP28_P(X+2) */ - {0, 0, 7}, /* map_lpmod[3] = LPMODE_QSFP28_P(X+3) */ - {1, 0, 4}, /* map_lpmod[4] = LPMODE_QSFP28_P(X+4) */ - {1, 0, 5}, /* map_lpmod[5] = LPMODE_QSFP28_P(X+5) */ - {1, 0, 6}, /* map_lpmod[6] = LPMODE_QSFP28_P(X+6) */ - {1, 0, 7}, /* map_lpmod[7] = LPMODE_QSFP28_P(X+7) */ - }, - .map_modsel = { {0, 1, 4}, /* map_modsel[0] = MODSEL_QSFP28_N_P(X) */ - {0, 1, 5}, /* map_modsel[1] = MODSEL_QSFP28_N_P(X+1) */ - {0, 1, 6}, /* map_modsel[2] = MODSEL_QSFP28_N_P(X+2) */ - {0, 1, 7}, /* map_modsel[3] = MODSEL_QSFP28_N_P(X+3) */ - {1, 1, 4}, /* map_modsel[4] = MODSEL_QSFP28_N_P(X+4) */ - {1, 1, 5}, /* map_modsel[5] = MODSEL_QSFP28_N_P(X+5) */ - {1, 1, 6}, /* map_modsel[6] = MODSEL_QSFP28_N_P(X+6) */ - {1, 1, 7}, /* map_modsel[7] = MODSEL_QSFP28_N_P(X+7) */ - }, -}; - - -struct ioexp_map_s ioexp_map_hudson32iga_p01p08_p17p24 = { - - .chip_amount = 3, - .data_width = 2, - - .map_present = { {2, 0, 0}, /* map_present[0] = MODABS_QSFP(X) */ - {2, 0, 1}, /* map_present[1] = MODABS_QSFP(X+1) */ - {2, 0, 2}, /* map_present[2] = MODABS_QSFP(X+2) */ - {2, 0, 3}, /* map_present[3] = MODABS_QSFP(X+3) */ - {2, 0, 4}, /* map_present[4] = MODABS_QSFP(X+4) */ - {2, 0, 5}, /* map_present[5] = MODABS_QSFP(X+5) */ - {2, 0, 6}, /* map_present[6] = MODABS_QSFP(X+6) */ - {2, 0, 7}, /* map_present[7] = MODABS_QSFP(X+7) */ - }, - .map_reset = { {0, 0, 0}, /* map_reset[0] = QRESET_QSFP(X) */ - {0, 0, 1}, /* map_reset[1] = QRESET_QSFP(X+1) */ - {0, 0, 2}, /* map_reset[2] = QRESET_QSFP(X+2) */ - {0, 0, 3}, /* map_reset[3] = QRESET_QSFP(X+3) */ - {1, 0, 0}, /* map_reset[4] = QRESET_QSFP(X+4) */ - {1, 0, 1}, /* map_reset[5] = QRESET_QSFP(X+5) */ - {1, 0, 2}, /* map_reset[6] = QRESET_QSFP(X+6) */ - {1, 0, 3}, /* map_reset[7] = QRESET_QSFP(X+7) */ - }, - .map_lpmod = { {0, 0, 4}, /* map_lpmod[0] = LPMODE_QSFP(X) */ - {0, 0, 5}, /* map_lpmod[1] = LPMODE_QSFP(X+1) */ - {0, 0, 6}, /* map_lpmod[2] = LPMODE_QSFP(X+2) */ - {0, 0, 7}, /* map_lpmod[3] = LPMODE_QSFP(X+3) */ - {1, 0, 4}, /* map_lpmod[4] = LPMODE_QSFP(X+4) */ - {1, 0, 5}, /* map_lpmod[5] = LPMODE_QSFP(X+5) */ - {1, 0, 6}, /* map_lpmod[6] = LPMODE_QSFP(X+6) */ - {1, 0, 7}, /* map_lpmod[7] = LPMODE_QSFP(X+7) */ - }, - .map_modsel = { {0, 1, 4}, /* map_modsel[0] = MODSEL_QSFP(X) */ - {0, 1, 5}, /* map_modsel[1] = MODSEL_QSFP(X+1) */ - {0, 1, 6}, /* map_modsel[2] = MODSEL_QSFP(X+2) */ - {0, 1, 7}, /* map_modsel[3] = MODSEL_QSFP(X+3) */ - {1, 1, 4}, /* map_modsel[4] = MODSEL_QSFP(X+4) */ - {1, 1, 5}, /* map_modsel[5] = MODSEL_QSFP(X+5) */ - {1, 1, 6}, /* map_modsel[6] = MODSEL_QSFP(X+6) */ - {1, 1, 7}, /* map_modsel[7] = MODSEL_QSFP(X+7) */ - }, -}; - - -struct ioexp_map_s ioexp_map_hudson32iga_p09p16_p25p32 = { - - .chip_amount = 3, - .data_width = 2, - - .map_present = { {2, 1, 0}, /* map_present[0] = MODABS_QSFP(X) */ - {2, 1, 1}, /* map_present[1] = MODABS_QSFP(X+1) */ - {2, 1, 2}, /* map_present[2] = MODABS_QSFP(X+2) */ - {2, 1, 3}, /* map_present[3] = MODABS_QSFP(X+3) */ - {2, 1, 4}, /* map_present[4] = MODABS_QSFP(X+4) */ - {2, 1, 5}, /* map_present[5] = MODABS_QSFP(X+5) */ - {2, 1, 6}, /* map_present[6] = MODABS_QSFP(X+6) */ - {2, 1, 7}, /* map_present[7] = MODABS_QSFP(X+7) */ - }, - .map_reset = { {0, 0, 0}, /* map_reset[0] = QRESET_QSFP(X) */ - {0, 0, 1}, /* map_reset[1] = QRESET_QSFP(X+1) */ - {0, 0, 2}, /* map_reset[2] = QRESET_QSFP(X+2) */ - {0, 0, 3}, /* map_reset[3] = QRESET_QSFP(X+3) */ - {1, 0, 0}, /* map_reset[4] = QRESET_QSFP(X+4) */ - {1, 0, 1}, /* map_reset[5] = QRESET_QSFP(X+5) */ - {1, 0, 2}, /* map_reset[6] = QRESET_QSFP(X+6) */ - {1, 0, 3}, /* map_reset[7] = QRESET_QSFP(X+7) */ - }, - .map_lpmod = { {0, 0, 4}, /* map_lpmod[0] = LPMODE_QSFP(X) */ - {0, 0, 5}, /* map_lpmod[1] = LPMODE_QSFP(X+1) */ - {0, 0, 6}, /* map_lpmod[2] = LPMODE_QSFP(X+2) */ - {0, 0, 7}, /* map_lpmod[3] = LPMODE_QSFP(X+3) */ - {1, 0, 4}, /* map_lpmod[4] = LPMODE_QSFP(X+4) */ - {1, 0, 5}, /* map_lpmod[5] = LPMODE_QSFP(X+5) */ - {1, 0, 6}, /* map_lpmod[6] = LPMODE_QSFP(X+6) */ - {1, 0, 7}, /* map_lpmod[7] = LPMODE_QSFP(X+7) */ - }, - .map_modsel = { {0, 1, 4}, /* map_modsel[0] = MODSEL_QSFP(X) */ - {0, 1, 5}, /* map_modsel[1] = MODSEL_QSFP(X+1) */ - {0, 1, 6}, /* map_modsel[2] = MODSEL_QSFP(X+2) */ - {0, 1, 7}, /* map_modsel[3] = MODSEL_QSFP(X+3) */ - {1, 1, 4}, /* map_modsel[4] = MODSEL_QSFP(X+4) */ - {1, 1, 5}, /* map_modsel[5] = MODSEL_QSFP(X+5) */ - {1, 1, 6}, /* map_modsel[6] = MODSEL_QSFP(X+6) */ - {1, 1, 7}, /* map_modsel[7] = MODSEL_QSFP(X+7) */ - }, -}; - - -struct ioexp_map_s ioexp_map_cypress_nabc = { - - .chip_amount = 3, - .data_width = 2, - - .map_present = { {0, 0, 4}, /* map_present[0] = MOD_ABS_PORT(X) */ - {0, 0, 5}, /* map_present[1] = MOD_ABS_PORT(X+1) */ - {0, 0, 6}, /* map_present[2] = MOD_ABS_PORT(X+2) */ - {0, 0, 7}, /* map_present[3] = MOD_ABS_PORT(X+3) */ - {1, 0, 4}, /* map_present[4] = MOD_ABS_PORT(X+4) */ - {1, 0, 5}, /* map_present[5] = MOD_ABS_PORT(X+5) */ - {1, 0, 6}, /* map_present[6] = MOD_ABS_PORT(X+6) */ - {1, 0, 7}, /* map_present[7] = MOD_ABS_PORT(X+7) */ - }, - .map_tx_disable = { {0, 1, 0}, /* map_tx_disable[0] = TXDISABLE_SFP+_P(X) */ - {0, 1, 1}, /* map_tx_disable[1] = TXDISABLE_SFP+_P(X+1) */ - {0, 1, 2}, /* map_tx_disable[2] = TXDISABLE_SFP+_P(X+2) */ - {0, 1, 3}, /* map_tx_disable[3] = TXDISABLE_SFP+_P(X+3) */ - {1, 1, 0}, /* map_tx_disable[4] = TXDISABLE_SFP+_P(X+4) */ - {1, 1, 1}, /* map_tx_disable[5] = TXDISABLE_SFP+_P(X+5) */ - {1, 1, 2}, /* map_tx_disable[6] = TXDISABLE_SFP+_P(X+6) */ - {1, 1, 3}, /* map_tx_disable[7] = TXDISABLE_SFP+_P(X+7) */ - }, - .map_tx_fault = { {0, 0, 0}, /* map_tx_fault[0] = TXFAULT_SFP+_P(X) */ - {0, 0, 1}, /* map_tx_fault[1] = TXFAULT_SFP+_P(X+1) */ - {0, 0, 2}, /* map_tx_fault[2] = TXFAULT_SFP+_P(X+2) */ - {0, 0, 3}, /* map_tx_fault[3] = TXFAULT_SFP+_P(X+3) */ - {1, 0, 0}, /* map_tx_fault[4] = TXFAULT_SFP+_P(X+4) */ - {1, 0, 1}, /* map_tx_fault[5] = TXFAULT_SFP+_P(X+5) */ - {1, 0, 2}, /* map_tx_fault[6] = TXFAULT_SFP+_P(X+6) */ - {1, 0, 3}, /* map_tx_fault[7] = TXFAULT_SFP+_P(X+7) */ - }, - .map_rxlos = { {0, 1, 4}, /* map_rxlos[0] = OPRXLOS_PORT(X) */ - {0, 1, 5}, /* map_rxlos[1] = OPRXLOS_PORT(X+1) */ - {0, 1, 6}, /* map_rxlos[2] = OPRXLOS_PORT(X+2) */ - {0, 1, 7}, /* map_rxlos[3] = OPRXLOS_PORT(X+3) */ - {1, 1, 4}, /* map_rxlos[4] = OPRXLOS_PORT(X+4) */ - {1, 1, 5}, /* map_rxlos[5] = OPRXLOS_PORT(X+5) */ - {1, 1, 6}, /* map_rxlos[6] = OPRXLOS_PORT(X+6) */ - {1, 1, 7}, /* map_rxlos[7] = OPRXLOS_PORT(X+7) */ - }, - .map_hard_rs0 = { {2, 0, 0}, /* map_hard_rs0[0] = RS0_SFP28_P(X) */ - {2, 0, 2}, /* map_hard_rs0[1] = RS0_SFP28_P(X+1) */ - {2, 0, 4}, /* map_hard_rs0[2] = RS0_SFP28_P(X+2) */ - {2, 0, 6}, /* map_hard_rs0[3] = RS0_SFP28_P(X+3) */ - {2, 1, 0}, /* map_hard_rs0[4] = RS0_SFP28_P(X+4) */ - {2, 1, 2}, /* map_hard_rs0[5] = RS0_SFP28_P(X+5) */ - {2, 1, 4}, /* map_hard_rs0[6] = RS0_SFP28_P(X+6) */ - {2, 1, 6}, /* map_hard_rs0[7] = RS0_SFP28_P(X+7) */ - }, - .map_hard_rs1 = { {2, 0, 1}, /* map_hard_rs1[0] = RS1_SFP28_P(X) */ - {2, 0, 3}, /* map_hard_rs1[1] = RS1_SFP28_P(X+1) */ - {2, 0, 5}, /* map_hard_rs1[2] = RS1_SFP28_P(X+2) */ - {2, 0, 7}, /* map_hard_rs1[3] = RS1_SFP28_P(X+3) */ - {2, 1, 1}, /* map_hard_rs1[4] = RS1_SFP28_P(X+4) */ - {2, 1, 3}, /* map_hard_rs1[5] = RS1_SFP28_P(X+5) */ - {2, 1, 5}, /* map_hard_rs1[6] = RS1_SFP28_P(X+6) */ - {2, 1, 7}, /* map_hard_rs1[7] = RS1_SFP28_P(X+7) */ - }, -}; - - -struct ioexp_map_s ioexp_map_cypress_7abc = { - - .chip_amount = 3, - .data_width = 2, - - .map_present = { {2, 0, 0}, /* map_present[0] = MOD_ABS_PORT(X) */ - {2, 0, 1}, /* map_present[1] = MOD_ABS_PORT(X+1) */ - {2, 0, 2}, /* map_present[2] = MOD_ABS_PORT(X+2) */ - {2, 0, 3}, /* map_present[3] = MOD_ABS_PORT(X+3) */ - {2, 0, 4}, /* map_present[4] = MOD_ABS_PORT(X+4) */ - {2, 0, 5}, /* map_present[5] = MOD_ABS_PORT(X+5) */ - }, - .map_reset = { {0, 0, 0}, /* map_reset[0] = QRESET_QSFP_N_P(X) */ - {0, 0, 1}, /* map_reset[1] = QRESET_QSFP_N_P(X+1) */ - {0, 0, 2}, /* map_reset[2] = QRESET_QSFP_N_P(X+2) */ - {0, 0, 3}, /* map_reset[3] = QRESET_QSFP_N_P(X+3) */ - {0, 0, 4}, /* map_reset[4] = QRESET_QSFP_N_P(X+4) */ - {0, 0, 5}, /* map_reset[5] = QRESET_QSFP_N_P(X+5) */ - }, - .map_lpmod = { {0, 1, 0}, /* map_lpmod[0] = LPMODE_QSFP_P(X) */ - {0, 1, 1}, /* map_lpmod[1] = LPMODE_QSFP_P(X+1) */ - {0, 1, 2}, /* map_lpmod[2] = LPMODE_QSFP_P(X+2) */ - {0, 1, 3}, /* map_lpmod[3] = LPMODE_QSFP_P(X+3) */ - {0, 1, 4}, /* map_lpmod[4] = LPMODE_QSFP_P(X+4) */ - {0, 1, 5}, /* map_lpmod[5] = LPMODE_QSFP_P(X+5) */ - }, - .map_modsel = { {1, 1, 0}, /* map_modsel[0] = MODSEL_QSFP_N_P(X) */ - {1, 1, 1}, /* map_modsel[1] = MODSEL_QSFP_N_P(X+1) */ - {1, 1, 2}, /* map_modsel[2] = MODSEL_QSFP_N_P(X+2) */ - {1, 1, 3}, /* map_modsel[3] = MODSEL_QSFP_N_P(X+3) */ - {1, 1, 4}, /* map_modsel[4] = MODSEL_QSFP_N_P(X+4) */ - {1, 1, 5}, /* map_modsel[5] = MODSEL_QSFP_N_P(X+5) */ - }, -}; - - -struct ioexp_map_s ioexp_map_tahoe_5a = { - - .chip_amount = 1, - .data_width = 2, - - .map_present = { {0, 0, 3}, /* map_present[0] = MOD_ABS_PORT(X) */ - {0, 1, 0}, /* map_present[1] = MOD_ABS_PORT(X+1) */ - {0, 1, 5}, /* map_present[2] = MOD_ABS_PORT(X+2) */ - }, - .map_reset = { {0, 0, 1}, /* map_reset[0] = QRESET_QSFP_N_P(X) */ - {0, 0, 6}, /* map_reset[1] = QRESET_QSFP_N_P(X+1) */ - {0, 1, 3}, /* map_reset[2] = QRESET_QSFP_N_P(X+2) */ - }, - .map_lpmod = { {0, 0, 2}, /* map_lpmod[0] = LPMODE_QSFP_P(X) */ - {0, 0, 7}, /* map_lpmod[1] = LPMODE_QSFP_P(X+1) */ - {0, 1, 4}, /* map_lpmod[2] = LPMODE_QSFP_P(X+2) */ - }, - .map_modsel = { {0, 0, 0}, /* map_modsel[0] = MODSEL_QSFP_N_P(X) */ - {0, 0, 5}, /* map_modsel[1] = MODSEL_QSFP_N_P(X+1) */ - {0, 1, 2}, /* map_modsel[2] = MODSEL_QSFP_N_P(X+2) */ - }, -}; - - -struct ioexp_map_s ioexp_map_tahoe_6abc = { - - .chip_amount = 3, - .data_width = 2, - - .map_present = { {0, 0, 3}, /* map_present[0] = MOD_ABS_PORT(X) */ - {0, 1, 0}, /* map_present[1] = MOD_ABS_PORT(X+1) */ - {0, 1, 5}, /* map_present[2] = MOD_ABS_PORT(X+2) */ - {1, 0, 3}, /* map_present[3] = MOD_ABS_PORT(X+3) */ - {1, 1, 0}, /* map_present[4] = MOD_ABS_PORT(X+4) */ - {1, 1, 5}, /* map_present[5] = MOD_ABS_PORT(X+5) */ - {2, 0, 3}, /* map_present[6] = MOD_ABS_PORT(X+6) */ - {2, 1, 0}, /* map_present[7] = MOD_ABS_PORT(X+7) */ - {2, 1, 5}, /* map_present[8] = MOD_ABS_PORT(X+8) */ - }, - .map_reset = { {0, 0, 1}, /* map_reset[0] = QRESET_QSFP28_N_P(X) */ - {0, 0, 6}, /* map_reset[1] = QRESET_QSFP28_N_P(X+1) */ - {0, 1, 3}, /* map_reset[2] = QRESET_QSFP28_N_P(X+2) */ - {1, 0, 1}, /* map_reset[3] = QRESET_QSFP28_N_P(X+3) */ - {1, 0, 6}, /* map_reset[4] = QRESET_QSFP28_N_P(X+4) */ - {1, 1, 3}, /* map_reset[5] = QRESET_QSFP28_N_P(X+5) */ - {2, 0, 1}, /* map_reset[6] = QRESET_QSFP28_N_P(X+6) */ - {2, 0, 6}, /* map_reset[7] = QRESET_QSFP28_N_P(X+7) */ - {2, 1, 3}, /* map_reset[7] = QRESET_QSFP28_N_P(X+7) */ - }, - .map_lpmod = { {0, 0, 2}, /* map_lpmod[0] = LPMODE_QSFP28_P(X) */ - {0, 0, 7}, /* map_lpmod[1] = LPMODE_QSFP28_P(X+1) */ - {0, 1, 4}, /* map_lpmod[2] = LPMODE_QSFP28_P(X+2) */ - {1, 0, 2}, /* map_lpmod[3] = LPMODE_QSFP28_P(X+3) */ - {1, 0, 7}, /* map_lpmod[4] = LPMODE_QSFP28_P(X+4) */ - {1, 1, 4}, /* map_lpmod[5] = LPMODE_QSFP28_P(X+5) */ - {2, 0, 2}, /* map_lpmod[6] = LPMODE_QSFP28_P(X+6) */ - {2, 0, 7}, /* map_lpmod[7] = LPMODE_QSFP28_P(X+7) */ - {2, 1, 4}, /* map_lpmod[7] = LPMODE_QSFP28_P(X+8) */ - }, - .map_modsel = { {0, 0, 0}, /* map_modsel[0] = MODSEL_QSFP28_N_P(X) */ - {0, 0, 5}, /* map_modsel[1] = MODSEL_QSFP28_N_P(X+1) */ - {0, 1, 2}, /* map_modsel[2] = MODSEL_QSFP28_N_P(X+2) */ - {1, 0, 0}, /* map_modsel[3] = MODSEL_QSFP28_N_P(X+3) */ - {1, 0, 5}, /* map_modsel[4] = MODSEL_QSFP28_N_P(X+4) */ - {1, 1, 2}, /* map_modsel[5] = MODSEL_QSFP28_N_P(X+5) */ - {2, 0, 0}, /* map_modsel[6] = MODSEL_QSFP28_N_P(X+6) */ - {2, 0, 5}, /* map_modsel[7] = MODSEL_QSFP28_N_P(X+7) */ - {2, 1, 2}, /* map_modsel[7] = MODSEL_QSFP28_N_P(X+7) */ - }, -}; - - -struct ioexp_map_s ioexp_map_sequoia_nabc = { - - .chip_amount = 3, - .data_width = 2, - - .map_present = { {2, 1, 0}, /* map_present[0] = MOD_ABS_PORT(X) */ - {2, 1, 1}, /* map_present[1] = MOD_ABS_PORT(X+1) */ - {2, 1, 2}, /* map_present[2] = MOD_ABS_PORT(X+2) */ - {2, 1, 3}, /* map_present[3] = MOD_ABS_PORT(X+3) */ - {2, 1, 4}, /* map_present[4] = MOD_ABS_PORT(X+4) */ - {2, 1, 5}, /* map_present[5] = MOD_ABS_PORT(X+5) */ - {2, 1, 6}, /* map_present[6] = MOD_ABS_PORT(X+6) */ - {2, 1, 7}, /* map_present[7] = MOD_ABS_PORT(X+7) */ - }, - .map_reset = { {0, 1, 0}, /* map_reset[0] = QRESET_QSFP28_N_P(X) */ - {0, 1, 1}, /* map_reset[1] = QRESET_QSFP28_N_P(X+1) */ - {0, 1, 2}, /* map_reset[2] = QRESET_QSFP28_N_P(X+2) */ - {0, 1, 3}, /* map_reset[3] = QRESET_QSFP28_N_P(X+3) */ - {0, 1, 4}, /* map_reset[4] = QRESET_QSFP28_N_P(X+4) */ - {0, 1, 5}, /* map_reset[5] = QRESET_QSFP28_N_P(X+5) */ - {0, 1, 6}, /* map_reset[6] = QRESET_QSFP28_N_P(X+6) */ - {0, 1, 7}, /* map_reset[7] = QRESET_QSFP28_N_P(X+7) */ - }, - .map_lpmod = { {1, 0, 0}, /* map_lpmod[0] = LPMODE_QSFP28_P(X) */ - {1, 0, 1}, /* map_lpmod[1] = LPMODE_QSFP28_P(X+1) */ - {1, 0, 2}, /* map_lpmod[2] = LPMODE_QSFP28_P(X+2) */ - {1, 0, 3}, /* map_lpmod[3] = LPMODE_QSFP28_P(X+3) */ - {1, 0, 4}, /* map_lpmod[4] = LPMODE_QSFP28_P(X+4) */ - {1, 0, 5}, /* map_lpmod[5] = LPMODE_QSFP28_P(X+5) */ - {1, 0, 6}, /* map_lpmod[6] = LPMODE_QSFP28_P(X+6) */ - {1, 0, 7}, /* map_lpmod[7] = LPMODE_QSFP28_P(X+7) */ - }, - .map_modsel = { {0, 0, 0}, /* map_modsel[0] = MODSEL_QSFP28_N_P(X) */ - {0, 0, 1}, /* map_modsel[1] = MODSEL_QSFP28_N_P(X+1) */ - {0, 0, 2}, /* map_modsel[2] = MODSEL_QSFP28_N_P(X+2) */ - {0, 0, 3}, /* map_modsel[3] = MODSEL_QSFP28_N_P(X+3) */ - {0, 0, 4}, /* map_modsel[4] = MODSEL_QSFP28_N_P(X+4) */ - {0, 0, 5}, /* map_modsel[5] = MODSEL_QSFP28_N_P(X+5) */ - {0, 0, 6}, /* map_modsel[6] = MODSEL_QSFP28_N_P(X+6) */ - {0, 0, 7}, /* map_modsel[7] = MODSEL_QSFP28_N_P(X+7) */ - }, -}; - - -struct ioexp_map_s ioexp_map_lavender_p65 = { - - .chip_amount = 1, - .data_width = 1, - - .map_present = { {0, 0, 4}, }, /* map_present[0] = MOD_ABS_PORT(X) */ - .map_reset = { {0, 0, 1}, }, /* map_reset[0] = QRESET_QSFP28_N_P(X) */ - .map_lpmod = { {0, 0, 2}, }, /* map_lpmod[0] = LPMODE_QSFP28_P(X) */ - .map_modsel = { {0, 0, 0}, }, /* map_modsel[0] = MODSEL_QSFP28_N_P(X) */ -}; - - -struct ioexp_map_s cpld_map_cottonwood = { - - .chip_amount = 1, - .data_width = 4, - - .map_present = { {0, 2, 0}, /* map_present[0] = MOD_ABS_PORT(X) */ - {0, 2, 4}, /* map_present[1] = MOD_ABS_PORT(X+1) */ - {0, 3, 0}, /* map_present[2] = MOD_ABS_PORT(X+2) */ - {0, 3, 4}, /* map_present[3] = MOD_ABS_PORT(X+3) */ - }, - .map_tx_disable = { {0, 0, 0}, /* map_tx_disable[0] = TXDISABLE_SFP+_P(X) */ - {0, 0, 4}, /* map_tx_disable[1] = TXDISABLE_SFP+_P(X+1) */ - {0, 1, 0}, /* map_tx_disable[2] = TXDISABLE_SFP+_P(X+2) */ - {0, 1, 4}, /* map_tx_disable[3] = TXDISABLE_SFP+_P(X+3) */ - }, - .map_tx_fault = { {0, 2, 2}, /* map_tx_fault[0] = TXFAULT_SFP+_P(X) */ - {0, 2, 6}, /* map_tx_fault[1] = TXFAULT_SFP+_P(X+1) */ - {0, 3, 2}, /* map_tx_fault[2] = TXFAULT_SFP+_P(X+2) */ - {0, 3, 6}, /* map_tx_fault[3] = TXFAULT_SFP+_P(X+3) */ - }, - .map_rxlos = { {0, 2, 1}, /* map_rxlos[0] = OPRXLOS_PORT(X) */ - {0, 2, 5}, /* map_rxlos[1] = OPRXLOS_PORT(X+1) */ - {0, 3, 1}, /* map_rxlos[2] = OPRXLOS_PORT(X+2) */ - {0, 3, 5}, /* map_rxlos[3] = OPRXLOS_PORT(X+3) */ - }, - .map_hard_rs0 = { {0, 0, 2}, /* map_hard_rs0[0] = RS0_SFP28_P(X) */ - {0, 0, 6}, /* map_hard_rs0[1] = RS0_SFP28_P(X+1) */ - {0, 1, 2}, /* map_hard_rs0[2] = RS0_SFP28_P(X+2) */ - {0, 1, 6}, /* map_hard_rs0[3] = RS0_SFP28_P(X+3) */ - }, - .map_hard_rs1 = { {0, 0, 2}, /* map_hard_rs1[0] = RS1_SFP28_P(X) */ - {0, 0, 6}, /* map_hard_rs1[1] = RS1_SFP28_P(X+1) */ - {0, 1, 2}, /* map_hard_rs1[2] = RS1_SFP28_P(X+2) */ - {0, 1, 6}, /* map_hard_rs1[3] = RS1_SFP28_P(X+3) */ - }, -}; - -/* ========== Private functions ========== - */ -int check_channel_tier_1(void); - -struct i2c_client * -_get_i2c_client(struct ioexp_obj_s *self, - int chip_id){ - - struct ioexp_i2c_s *i2c_curr_p = self->i2c_head_p; - - if (!(i2c_curr_p)){ - SWPS_ERR("%s: i2c_curr_p is NULL\n", __func__); - return NULL; - } - while (i2c_curr_p){ - if ((i2c_curr_p->chip_id) == chip_id){ - return i2c_curr_p->i2c_client_p; - } - i2c_curr_p = i2c_curr_p->next; - } - SWPS_ERR("%s: not exist! :%d\n", __func__, chip_id); - return NULL; -} - - -static int -_common_ioexp_update_one(struct ioexp_obj_s *self, - struct ioexp_addr_s *ioexp_addr, - int chip_id, - int data_width, - int show_err, - char *caller_name) { - int buf = 0; - int err = 0; - int data_id = 0; - int r_offset = 0; - - for(data_id=0; data_idread_offset[data_id]; - buf = i2c_smbus_read_byte_data(_get_i2c_client(self, chip_id), r_offset); - /* Check error */ - if (buf < 0) { - err = 1; - if (show_err) { - SWPS_INFO("IOEXP-%d read fail! :%d \n", self->ioexp_id, buf); - SWPS_INFO("Dump: :%d :0x%02x :%d, :%s\n", - ioexp_addr->chan_id, ioexp_addr->chip_addr, - ioexp_addr->read_offset[data_id], caller_name); - } - continue; - } - /* Update IOEXP object */ - self->chip_data[chip_id].data[data_id] = (uint8_t)buf; - } - if (err) { - return ERR_IOEXP_UNEXCPT; - } - return 0; -} - - -static int -common_ioexp_update_all(struct ioexp_obj_s *self, - int show_err, - char *caller_name){ - - int err = 0; - int chip_id = 0; - int chip_amount = self->ioexp_map_p->chip_amount; - - for (chip_id=0; chip_idioexp_map_p->map_addr[chip_id]), - chip_id, - self->ioexp_map_p->data_width, - show_err, - caller_name) < 0) { - err = 1; - } - } - if (err) { - return ERR_IOEXP_UNEXCPT; - } - return 0; -} - - -static int -_common_check_by_mode(struct ioexp_obj_s *self){ - - switch (self->mode){ - case IOEXP_MODE_DIRECT: - return self->fsm_4_direct(self); - - case IOEXP_MODE_POLLING: - if (self->state >= 0){ - return 0; - } - switch (self->state){ - case STATE_IOEXP_INIT: - return ERR_IOEXP_UNINIT; - case STATE_IOEXP_ABNORMAL: - return ERR_IOEXP_ABNORMAL; - default: - return ERR_IOEXP_NOSTATE; - } - break; - - default: - break; - } - SWPS_ERR("%s: Exception occurs. :%d \n", __func__, self->mode); - return ERR_IOEXP_UNEXCPT; -} - - -static int -_common_get_bit(struct ioexp_obj_s *self, - struct ioexp_bitmap_s *bitmap_obj_p, - char *func_mane){ - uint8_t buf; - int err_code; - - /* Check and get address */ - err_code = _common_check_by_mode(self); - if (err_code < 0){ - return err_code; - } - if (!bitmap_obj_p){ - SWPS_ERR("Layout config incorrect! :%d :%s\n", - self->ioexp_id, func_mane); - return ERR_IOEXP_BADCONF; - } - /* Get data form cache */ - buf = self->chip_data[bitmap_obj_p->chip_id].data[bitmap_obj_p->ioexp_voffset]; - return (int)(buf >> bitmap_obj_p->bit_shift & 0x01); -} - - -static int -_common_set_bit(struct ioexp_obj_s *self, - struct ioexp_bitmap_s *bitmap_obj_p, - int input_val, - char *func_mane){ - int err_code, target_offset; - uint8_t origin_byte; - uint8_t modify_byte; - - /* Check and get address */ - err_code = _common_check_by_mode(self); - if (err_code < 0){ - return err_code; - } - if (!bitmap_obj_p){ - SWPS_ERR("Layout config incorrect! :%d :%s\n", - self->ioexp_id, func_mane); - return ERR_IOEXP_BADCONF; - } - /* Prepare write date */ - origin_byte = self->chip_data[bitmap_obj_p->chip_id].data[bitmap_obj_p->ioexp_voffset]; - switch (input_val) { - case 0: - modify_byte = origin_byte; - SWP_BIT_CLEAR(modify_byte, bitmap_obj_p->bit_shift); - break; - case 1: - modify_byte = origin_byte; - SWP_BIT_SET(modify_byte, bitmap_obj_p->bit_shift); - break; - default: - SWPS_ERR("Input value incorrect! :%d :%d :%s\n", - input_val, self->ioexp_id, func_mane); - return ERR_IOEXP_BADINPUT; - } - /* Setup i2c client */ - target_offset = self->ioexp_map_p->map_addr[bitmap_obj_p->chip_id].write_offset[bitmap_obj_p->ioexp_voffset]; - /* Write byte to chip via I2C */ - err_code = i2c_smbus_write_byte_data(_get_i2c_client(self, bitmap_obj_p->chip_id), - target_offset, - modify_byte); - /* Update or bollback object */ - if (err_code < 0){ - self->chip_data[bitmap_obj_p->chip_id].data[bitmap_obj_p->ioexp_voffset] = origin_byte; - SWPS_ERR("I2C write fail! :%d :%d :%s :%d\n", - input_val, self->ioexp_id, func_mane, err_code); - return err_code; - } - self->chip_data[bitmap_obj_p->chip_id].data[bitmap_obj_p->ioexp_voffset] = modify_byte; - return 0; -} - - -/* ========== Object public functions ========== - */ -int -common_get_present(struct ioexp_obj_s *self, - int virt_offset){ - - int UNPLUG = 1; - int retval = ERR_IOEXP_UNEXCPT; - - retval = _common_get_bit(self, - &(self->ioexp_map_p->map_present[virt_offset]), - "common_get_present"); - if (retval < 0) { - /* [Note] - * => Transceiver object does not need to handle IOEXP layer issues. - */ - return UNPLUG; - } - return retval; -} - - -int -common_get_tx_fault(struct ioexp_obj_s *self, - int virt_offset){ - /* [Transmit Fault (Tx_Fault)] - * A catastrophic laser fault will activate the transmitter signal, - * TX_FAULT, and disable the laser. This signal is an open collector - * output (pull-up required on the host board). A low signal indicates - * normal laser operation and a high signal indicates a fault. The - * TX_FAULT will be latched high when a laser fault occurs and is - * cleared by toggling the TX_DISABLE input or power cycling the - * transceiver. The transmitter fault condition can also be monitored - * via the two-wire serial interface. - * (address A2, byte 110, bit 2). - * - * 0: Normal - * 1: Abnormal - */ - return _common_get_bit(self, - &(self->ioexp_map_p->map_tx_fault[virt_offset]), - "common_get_tx_fault"); -} - - -int -common_get_rxlos(struct ioexp_obj_s *self, - int virt_offset){ - /* [Receiver Loss of Signal (Rx_LOS)] - * The post-amplification IC also includes transition detection circuitry - * which monitors the ac level of incoming optical signals and provides a - * TTL/CMOS compatible status signal to the host (pin 8). An adequate optical - * input results in a low Rx_LOS output while a high Rx_LOS output indicates - * an unusable optical input. The Rx_LOS thresholds are factory set so that - * a high output indicates a definite optical fault has occurred. Rx_LOS can - * also be monitored via the two-wire serial interface - * (address A2h, byte 110, bit 1). - * - * 0: Normal - * 1: Abnormal - */ - return _common_get_bit(self, - &(self->ioexp_map_p->map_rxlos[virt_offset]), - "common_get_rxlos"); -} - - -int -common_get_tx_disable(struct ioexp_obj_s *self, - int virt_offset){ - - return _common_get_bit(self, - &(self->ioexp_map_p->map_tx_disable[virt_offset]), - "common_get_tx_disable"); -} - - -int -common_get_reset(struct ioexp_obj_s *self, - int virt_offset){ - - return _common_get_bit(self, - &(self->ioexp_map_p->map_reset[virt_offset]), - "common_get_reset"); -} - - -int -common_get_lpmod(struct ioexp_obj_s *self, - int virt_offset){ - - return _common_get_bit(self, - &(self->ioexp_map_p->map_lpmod[virt_offset]), - "common_get_lpmod"); -} - - -int -common_get_modsel(struct ioexp_obj_s *self, - int virt_offset){ - - return _common_get_bit(self, - &(self->ioexp_map_p->map_modsel[virt_offset]), - "common_get_modsel"); -} - - -int -common_get_hard_rs0(struct ioexp_obj_s *self, - int virt_offset){ - - return _common_get_bit(self, - &(self->ioexp_map_p->map_hard_rs0[virt_offset]), - "common_get_hard_rs0"); -} - - -int -common_get_hard_rs1(struct ioexp_obj_s *self, - int virt_offset){ - - return _common_get_bit(self, - &(self->ioexp_map_p->map_hard_rs1[virt_offset]), - "common_get_hard_rs1"); -} - - -int -common_set_tx_disable(struct ioexp_obj_s *self, - int virt_offset, - int input_val){ - - return _common_set_bit(self, - &(self->ioexp_map_p->map_tx_disable[virt_offset]), - input_val, - "common_set_tx_disable"); -} - - -int -common_set_reset(struct ioexp_obj_s *self, - int virt_offset, - int input_val){ - - return _common_set_bit(self, - &(self->ioexp_map_p->map_reset[virt_offset]), - input_val, - "common_set_reset"); -} - - -int -common_set_lpmod(struct ioexp_obj_s *self, - int virt_offset, - int input_val){ - - return _common_set_bit(self, - &(self->ioexp_map_p->map_lpmod[virt_offset]), - input_val, - "common_set_lpmod"); -} - - -int -common_set_modsel(struct ioexp_obj_s *self, - int virt_offset, - int input_val){ - - return _common_set_bit(self, - &(self->ioexp_map_p->map_modsel[virt_offset]), - input_val, - "common_set_modsel"); -} - - -int -common_set_hard_rs0(struct ioexp_obj_s *self, - int virt_offset, - int input_val){ - - return _common_set_bit(self, - &(self->ioexp_map_p->map_hard_rs0[virt_offset]), - input_val, - "common_set_hard_rs0"); -} - - -int -common_set_hard_rs1(struct ioexp_obj_s *self, - int virt_offset, - int input_val){ - - return _common_set_bit(self, - &(self->ioexp_map_p->map_hard_rs1[virt_offset]), - input_val, - "common_set_hard_rs1"); -} - - -int -ioexp_get_not_support(struct ioexp_obj_s *self, - int virt_offset){ - return ERR_IOEXP_NOTSUPPORT; -} - - -int -ioexp_set_not_support(struct ioexp_obj_s *self, - int virt_offset, - int input_val){ - return ERR_IOEXP_NOTSUPPORT; -} - - -int -fake_ioexp_init(struct ioexp_obj_s *self){ - return 1; -} - -int -fake_ioexp_update(struct ioexp_obj_s *self){ - return 1; -} - - -int -fake_update_func(struct ioexp_obj_s *self){ - return 1; -} - -int -fake_get_func(struct ioexp_obj_s *self, - int virt_offset){ - SWPS_WARN("Someone called fake_get_func\n"); - return -1; -} - -int -fake_set_func(struct ioexp_obj_s *self, - int virt_offset, - int input_val){ - SWPS_WARN("Someone called fake_set_func\n"); - return -1; -} - - -/* ========== Initial functions for IO Expander ========== - */ -int -common_ioexp_init(struct ioexp_obj_s *self) { - - int chip_id, offset, err_code; - struct ioexp_addr_s *addr_p; - - if (self->mode == IOEXP_MODE_DIRECT) { - goto update_common_ioexp_init; - } - /* Setup default value to each physical IO Expander */ - for (chip_id=0; chip_id<(self->ioexp_map_p->chip_amount); chip_id++){ - /* Get address mapping */ - addr_p = &(self->ioexp_map_p->map_addr[chip_id]); - if (!addr_p){ - SWPS_ERR("%s: IOEXP config incorrect! :%d \n", - __func__, chip_id); - return -1; - } - /* Setup default value */ - for (offset=0; offset<(self->ioexp_map_p->data_width); offset++){ - - /* [Desc] Skip the setup default value behavior - [Note] Setup default value = -1 if you don't want to write the value to IOEXP or CPLD - */ - if(addr_p->write_offset[offset] < 0){ - SWPS_DEBUG("skip a write_offset <%d>\n", addr_p->conf_offset[offset]); - continue; - } - err_code = i2c_smbus_write_byte_data(_get_i2c_client(self, chip_id), - addr_p->write_offset[offset], - addr_p->data_default[offset]); - if (err_code < 0){ - SWPS_ERR("%s: set default fail! :%d \n", - __func__, err_code); - return ERR_IOEXP_UNEXCPT; - } - } - } -update_common_ioexp_init: - /* Check and update info to object */ - err_code = self->update_all(self, 1, "common_ioexp_init"); - if (err_code < 0) { - SWPS_ERR("%s: update_all() fail! :%d \n", - __func__, err_code); - return ERR_IOEXP_UNEXCPT; - } - return 0; -} - - -/* ========== Object functions for Final State Machine ========== - */ -int -_is_channel_ready(struct ioexp_obj_s *self){ - - int buf = 0; - int chip_id = 0; /* Use first chip which be registered */ - int data_id = 0; /* Use first byte which be registered */ - struct ioexp_addr_s *ioexp_addr = NULL; - - ioexp_addr = &(self->ioexp_map_p->map_addr[chip_id]); - if (!ioexp_addr){ - SWPS_ERR("%s: config incorrect!\n", __func__); - return ERR_IOEXP_UNEXCPT; - } - buf = i2c_smbus_read_byte_data(_get_i2c_client(self, chip_id), - ioexp_addr->read_offset[data_id]); - if (buf >= 0){ - return 1; - } - return 0; -} - -int -_ioexp_init_handler(struct ioexp_obj_s *self){ - - int return_val; - - switch (self->mode) { - case IOEXP_MODE_DIRECT: - return_val = self->init(self); - if (return_val < 0){ - self->state = STATE_IOEXP_ABNORMAL; - } else { - self->state = STATE_IOEXP_NORMAL; - } - return return_val; - - case IOEXP_MODE_POLLING: - /* Check system and channel is ready */ - if (self->state == STATE_IOEXP_INIT){ - if (!_is_channel_ready(self)){ - self->state = STATE_IOEXP_INIT; - SWPS_WARN("%s: IOEXP:%d channel not ready.\n", - __func__, self->ioexp_id); - return 0; - } - } - /* Execute initial callback */ - return_val = self->init(self); - if (return_val < 0){ - self->state = STATE_IOEXP_ABNORMAL; - } else { - self->state = STATE_IOEXP_NORMAL; - } - return return_val; - - default: - break; - } - SWPS_ERR("%s: exception occur :%d\n", __func__, self->mode); - return ERR_IOEXP_UNEXCPT; -} - - -int -common_ioexp_fsm_4_direct(struct ioexp_obj_s *self){ - - int result_val; - int show_err = 1; - char *func_mane = "common_ioexp_fsm_4_direct"; - - switch (self->state){ - case STATE_IOEXP_INIT: - result_val = _ioexp_init_handler(self); - /* Exception case: terminate initial procedure */ - if(result_val < 0){ - /* Initial fail */ - return result_val; - } - if(self->state == STATE_IOEXP_INIT){ - /* Keep in INIT state, and return error */ - return ERR_IOEXP_UNINIT; - } - /* Case: Initial done */ - return 0; - - case STATE_IOEXP_NORMAL: - result_val = self->update_all(self, show_err, func_mane); - if (result_val < 0){ - SWPS_INFO("%s: NORMAL -> ABNORMAL :%d\n", - __func__, result_val); - self->state = STATE_IOEXP_ABNORMAL; - return result_val; - } - self->state = STATE_IOEXP_NORMAL; - return 0; - - case STATE_IOEXP_ABNORMAL: - result_val = self->update_all(self, show_err, func_mane); - if (result_val < 0){ - self->state = STATE_IOEXP_ABNORMAL; - return result_val; - } - SWPS_DEBUG("%s: ABNORMAL -> NORMAL :%d\n", - __func__, result_val); - self->state = STATE_IOEXP_NORMAL; - return 0; - - default: - break; - } - SWPS_ERR("%s: Exception occurs :%d\n", - __func__, self->state); - return ERR_IOEXP_UNEXCPT; -} - - -int -common_ioexp_fsm_4_polling(struct ioexp_obj_s *self){ - - int result_val, i, show_e; - int fail_retry = 3; - char *func_name = "common_ioexp_fsm_4_polling"; - -#ifdef DEBUG_SWPS - show_e = 1; -#else - show_e = 0; -#endif - - switch (self->state){ - case STATE_IOEXP_INIT: - result_val = _ioexp_init_handler(self); - /* Exception case: terminate initial procedure */ - if(result_val < 0){ - /* Initial fail */ - return result_val; - } - /* Case: System (Channel) not ready */ - if(self->state == STATE_IOEXP_INIT){ - /* Keep in INIT state, wait and retry */ - return 0; - } - /* Case: Initial done */ - SWPS_INFO("IOEXP-%d: initial done. :%d\n", - self->ioexp_id, self->ioexp_type); - return result_val; - - case STATE_IOEXP_NORMAL: - /* Retry mechanism for case of i2c topology not stable */ - for (i=0; iupdate_all(self, show_e, func_name); - if (result_val >= 0) { - self->state = STATE_IOEXP_NORMAL; - return 0; - } - if (check_channel_tier_1() < 0) { - SWPS_INFO("%s: detect I2C crash :%d\n", - __func__, self->ioexp_id); - break; - } - SWPS_DEBUG("IOEXP-%d: unstable :%d\n", - self->ioexp_id, result_val); - } - SWPS_INFO("IOEXP-%d: NORMAL -> ABNORMAL :%d\n", - self->ioexp_id, result_val); - self->state = STATE_IOEXP_ABNORMAL; - return result_val; - - case STATE_IOEXP_ABNORMAL: - result_val = self->update_all(self, show_e, func_name); - if (result_val < 0){ - self->state = STATE_IOEXP_ABNORMAL; - return result_val; - } - SWPS_INFO("IOEXP-%d: ABNORMAL -> NORMAL :%d\n", - self->ioexp_id, result_val); - self->state = STATE_IOEXP_NORMAL; - return 0; - - default: - break; - } - SWPS_ERR("IOEXP-%d: Exception occurs :%d\n", - self->ioexp_id, self->state); - return ERR_IOEXP_UNEXCPT; -} - - -/* ========== Object private functions for check & update ========== - */ -int -common_ioexp_check(struct ioexp_obj_s *self){ - - int result; - - if (self->mode != IOEXP_MODE_POLLING){ - SWPS_ERR("%s: not polling mode :%d\n", - __func__, self->mode); - return ERR_IOEXP_NOTSUPPORT; - } - mutex_lock(&self->lock); - result = self->fsm_4_polling(self); - mutex_unlock(&self->lock); - return result; -} - - -/* ========== Functions for Factory pattern ========== - */ -static struct ioexp_map_s * -get_ioexp_map(int ioexp_type){ - switch (ioexp_type){ - case IOEXP_TYPE_MAGINOLIA_NAB: - return &ioexp_map_magnolia_nab; - case IOEXP_TYPE_MAGINOLIA_4AB: - return &ioexp_map_magnolia_4ab; - case IOEXP_TYPE_MAGINOLIA_7AB: - case IOEXP_TYPE_SPRUCE_7AB: - return &ioexp_map_magnolia_7ab; - case IOEXP_TYPE_REDWOOD_P01P08: - return &ioexp_map_redwood_p01p08_p17p24; - case IOEXP_TYPE_REDWOOD_P09P16: - return &ioexp_map_redwood_p09p16_p25p32; - case IOEXP_TYPE_HUDSON32IGA_P01P08: - return &ioexp_map_hudson32iga_p01p08_p17p24; - case IOEXP_TYPE_HUDSON32IGA_P09P16: - return &ioexp_map_hudson32iga_p09p16_p25p32; - case IOEXP_TYPE_CYPRESS_NABC: - return &ioexp_map_cypress_nabc; - case IOEXP_TYPE_CYPRESS_7ABC: - return &ioexp_map_cypress_7abc; - case IOEXP_TYPE_TAHOE_5A: - return &ioexp_map_tahoe_5a; - case IOEXP_TYPE_TAHOE_6ABC: - return &ioexp_map_tahoe_6abc; - case IOEXP_TYPE_SEQUOIA_NABC: - return &ioexp_map_sequoia_nabc; - case IOEXP_TYPE_LAVENDER_P65: - return &ioexp_map_lavender_p65; - case CPLD_TYPE_COTTONWOOD: - return &cpld_map_cottonwood; - default: - return NULL; - } -} - - -int -setup_ioexp_ssize_attr(struct ioexp_obj_s *self, - struct ioexp_map_s *ioexp_map_p, - int ioexp_id, - int ioexp_type, - int run_mode){ - switch (run_mode){ - case IOEXP_MODE_POLLING: /* Direct access device mode */ - case IOEXP_MODE_DIRECT: /* Polling mode, read from cache */ - self->mode = run_mode; - break; - default: - SWPS_ERR("%s: non-defined run_mode:%d\n", - __func__, run_mode); - self->mode = ERR_IOEXP_UNEXCPT; - return ERR_IOEXP_UNEXCPT; - } - /* Setup mapping structure */ - self->ioexp_map_p = kzalloc(sizeof(*ioexp_map_p), GFP_KERNEL); - if (!(self->ioexp_map_p)) { - SWPS_ERR("%s: kzalloc ioexp_map_p fail\n", __func__); - return -1; - } - memcpy(self->ioexp_map_p, ioexp_map_p, sizeof(*ioexp_map_p)); - /* Setup attributes */ - self->ioexp_id = ioexp_id; - self->ioexp_type = ioexp_type; - self->state = STATE_IOEXP_INIT; - mutex_init(&self->lock); - return 0; -} - - -static int -setup_addr_mapping(struct ioexp_obj_s *self, - struct ioexp_addr_s *addr_map_p, - int chip_amount){ - struct ioexp_addr_s *tmp_p; - if (!addr_map_p){ - SWPS_ERR("%s: map is null\n", __func__); - return -1; - } - tmp_p = kzalloc((sizeof(*addr_map_p) * chip_amount), GFP_KERNEL); - if (!tmp_p){ - SWPS_ERR("%s: kzalloc fail.\n", __func__); - return -1; - } - memcpy(tmp_p, addr_map_p, (sizeof(*addr_map_p) * chip_amount)); - self->ioexp_map_p->map_addr = tmp_p; - - return 0; -} - - -static int -setup_ioexp_public_cb(struct ioexp_obj_s *self, - int ioexp_type){ - - switch (ioexp_type){ - case IOEXP_TYPE_MAGINOLIA_NAB: - case IOEXP_TYPE_MAGINOLIA_4AB: - case CPLD_TYPE_COTTONWOOD: - self->get_present = common_get_present; - self->get_tx_fault = common_get_tx_fault; - self->get_rxlos = common_get_rxlos; - self->get_tx_disable = common_get_tx_disable; - self->get_reset = ioexp_get_not_support; - self->get_lpmod = ioexp_get_not_support; - self->get_modsel = ioexp_get_not_support; - self->get_hard_rs0 = ioexp_get_not_support; - self->get_hard_rs1 = ioexp_get_not_support; - self->set_tx_disable = common_set_tx_disable; - self->set_reset = ioexp_set_not_support; - self->set_lpmod = ioexp_set_not_support; - self->set_modsel = ioexp_set_not_support; - self->set_hard_rs0 = ioexp_set_not_support; - self->set_hard_rs1 = ioexp_set_not_support; - return 0; - case IOEXP_TYPE_CYPRESS_NABC: - self->get_present = common_get_present; - self->get_tx_fault = common_get_tx_fault; - self->get_rxlos = common_get_rxlos; - self->get_tx_disable = common_get_tx_disable; - self->get_reset = ioexp_get_not_support; - self->get_lpmod = ioexp_get_not_support; - self->get_modsel = ioexp_get_not_support; - self->get_hard_rs0 = common_get_hard_rs0; - self->get_hard_rs1 = common_get_hard_rs1; - self->set_tx_disable = common_set_tx_disable; - self->set_reset = ioexp_set_not_support; - self->set_lpmod = ioexp_set_not_support; - self->set_modsel = ioexp_set_not_support; - self->set_hard_rs0 = common_set_hard_rs0; - self->set_hard_rs1 = common_set_hard_rs1; - return 0; - case IOEXP_TYPE_MAGINOLIA_7AB: - case IOEXP_TYPE_SPRUCE_7AB: - case IOEXP_TYPE_REDWOOD_P01P08: - case IOEXP_TYPE_REDWOOD_P09P16: - case IOEXP_TYPE_HUDSON32IGA_P01P08: - case IOEXP_TYPE_HUDSON32IGA_P09P16: - case IOEXP_TYPE_CYPRESS_7ABC: - case IOEXP_TYPE_TAHOE_5A: - case IOEXP_TYPE_TAHOE_6ABC: - case IOEXP_TYPE_SEQUOIA_NABC: - case IOEXP_TYPE_LAVENDER_P65: - self->get_present = common_get_present; - self->get_tx_fault = ioexp_get_not_support; - self->get_rxlos = ioexp_get_not_support; - self->get_tx_disable = ioexp_get_not_support; - self->get_reset = common_get_reset; - self->get_lpmod = common_get_lpmod; - self->get_modsel = common_get_modsel; - self->get_hard_rs0 = ioexp_get_not_support; - self->get_hard_rs1 = ioexp_get_not_support; - self->set_tx_disable = ioexp_set_not_support; - self->set_reset = common_set_reset; - self->set_lpmod = common_set_lpmod; - self->set_modsel = common_set_modsel; - self->set_hard_rs0 = ioexp_set_not_support; - self->set_hard_rs1 = ioexp_set_not_support; - return 0; - - default: - SWPS_ERR("%s: type:%d incorrect!\n", __func__, ioexp_type); - break; - } - return ERR_IOEXP_UNEXCPT; -} - - -static int -setup_ioexp_private_cb(struct ioexp_obj_s *self, - int ioexp_type){ - - switch (ioexp_type){ - case IOEXP_TYPE_MAGINOLIA_NAB: - case IOEXP_TYPE_MAGINOLIA_4AB: - case IOEXP_TYPE_MAGINOLIA_7AB: - case IOEXP_TYPE_SPRUCE_7AB: - case IOEXP_TYPE_REDWOOD_P01P08: - case IOEXP_TYPE_REDWOOD_P09P16: - case IOEXP_TYPE_HUDSON32IGA_P01P08: - case IOEXP_TYPE_HUDSON32IGA_P09P16: - case IOEXP_TYPE_CYPRESS_NABC: - case IOEXP_TYPE_CYPRESS_7ABC: - case IOEXP_TYPE_TAHOE_5A: - case IOEXP_TYPE_TAHOE_6ABC: - case IOEXP_TYPE_SEQUOIA_NABC: - case IOEXP_TYPE_LAVENDER_P65: - case CPLD_TYPE_COTTONWOOD: - self->init = common_ioexp_init; - self->check = common_ioexp_check; - self->update_all = common_ioexp_update_all; - self->fsm_4_direct = common_ioexp_fsm_4_direct; - self->fsm_4_polling = common_ioexp_fsm_4_polling; - return 0; - - default: - SWPS_ERR("%s: type:%d incorrect!\n", __func__, ioexp_type); - break; - } - return ERR_IOEXP_UNEXCPT; -} - - -static int -setup_i2c_client_one(struct ioexp_obj_s *self, - int chip_id){ - - char *err_msg = "ERROR"; - struct i2c_adapter *adap = NULL; - struct i2c_client *client = NULL; - struct ioexp_i2c_s *i2c_obj_p = NULL; - struct ioexp_i2c_s *i2c_curr_p = NULL; - - int chan_id = self->ioexp_map_p->map_addr[chip_id].chan_id; - adap = i2c_get_adapter(chan_id); - if(!adap){ - err_msg = "Can not get adap!"; - goto err_ioexp_setup_i2c_1; - } - client = kzalloc(sizeof(*client), GFP_KERNEL); - if (!client){ - err_msg = "Can not kzalloc client!"; - goto err_ioexp_setup_i2c_1; - } - i2c_obj_p = kzalloc(sizeof(*i2c_obj_p), GFP_KERNEL); - if (!i2c_obj_p){ - err_msg = "Can not kzalloc i2c_obj_p!"; - goto err_ioexp_setup_i2c_2; - } - client->adapter = adap; - client->addr = self->ioexp_map_p->map_addr[chip_id].chip_addr; - i2c_obj_p->i2c_client_p = client; - i2c_obj_p->chip_id = chip_id; - i2c_obj_p->next = NULL; - if (!self->i2c_head_p){ - self->i2c_head_p = i2c_obj_p; - } else { - i2c_curr_p = self->i2c_head_p; - while (i2c_curr_p->next){ - i2c_curr_p = i2c_curr_p->next; - } - i2c_curr_p->next = i2c_obj_p; - } - return 0; - -err_ioexp_setup_i2c_2: - kfree(client); -err_ioexp_setup_i2c_1: - SWPS_ERR("%s: %s :%d\n", __func__, err_msg, chan_id); - return -1; -} - - -static int -setup_i2c_client(struct ioexp_obj_s* self){ - - int result; - int chip_id = 0; - - for (chip_id=0; chip_id<(self->ioexp_map_p->chip_amount); chip_id++){ - result = setup_i2c_client_one(self, chip_id); - if (result < 0){ - SWPS_ERR("%s fail! :%d\n", __func__, chip_id); - return -1; - } - } - return 0; -} - - -static int -setup_ioexp_config(struct ioexp_obj_s *self) { - - int chip_id, offset, err_code; - struct ioexp_addr_s *addr_p; - - for (chip_id=0; chip_id<(self->ioexp_map_p->chip_amount); chip_id++){ - addr_p = &(self->ioexp_map_p->map_addr[chip_id]); - if (!addr_p){ - SWPS_ERR("IOEXP config incorrect! :%d \n",chip_id); - return -1; - } - for (offset=0; offset<(self->ioexp_map_p->data_width); offset++){ - - /* [Desc] Skip the setup config value behavior - [Note] Setup config value = -1 if you don't want to write the value to IOEXP or CPLD - */ - if(addr_p->conf_offset[offset] < 0){ - SWPS_DEBUG("skip a config_offset <%d>\n", addr_p->conf_offset[offset]); - continue; - } - err_code = i2c_smbus_write_byte_data(_get_i2c_client(self, chip_id), - addr_p->conf_offset[offset], - addr_p->conf_default[offset]); - - if (err_code < 0){ - SWPS_INFO("%s: set conf fail! :%d \n", __func__, err_code); - return -2; - } - } - } - return 0; -} - - -struct ioexp_obj_s * -_create_ioexp_obj(int ioexp_id, - int ioexp_type, - struct ioexp_addr_s *addr_map_p, - int run_mode){ - - struct ioexp_map_s* ioexp_map_p; - struct ioexp_obj_s* result_p; - struct ioexp_i2c_s *i2c_curr_p; - struct ioexp_i2c_s *i2c_next_p; - - /* Get layout */ - ioexp_map_p = get_ioexp_map(ioexp_type); - if (!ioexp_map_p){ - SWPS_ERR("%s: Invalid ioexp_type\n", __func__); - goto err_create_ioexp_fail; - } - /* Prepare IOEXP object */ - result_p = kzalloc(sizeof(*result_p), GFP_KERNEL); - if (!result_p){ - SWPS_ERR("%s: kzalloc failure!\n", __func__); - goto err_create_ioexp_fail; - } - /* Prepare static size attributes */ - if (setup_ioexp_ssize_attr(result_p, - ioexp_map_p, - ioexp_id, - ioexp_type, - run_mode) < 0){ - goto err_create_ioexp_setup_attr_fail; - } - /* Prepare address mapping */ - if (setup_addr_mapping(result_p, addr_map_p, ioexp_map_p->chip_amount) < 0){ - goto err_create_ioexp_setup_attr_fail; - } - if (setup_i2c_client(result_p) < 0){ - goto err_create_ioexp_setup_i2c_fail; - } - /* Prepare call back functions of object */ - if (setup_ioexp_public_cb(result_p, ioexp_type) < 0){ - goto err_create_ioexp_setup_i2c_fail; - } - if (setup_ioexp_private_cb(result_p, ioexp_type) < 0){ - goto err_create_ioexp_setup_i2c_fail; - } - return result_p; - -err_create_ioexp_setup_i2c_fail: - i2c_curr_p = result_p->i2c_head_p; - i2c_next_p = result_p->i2c_head_p; - while (i2c_curr_p){ - i2c_next_p = i2c_curr_p->next; - kfree(i2c_curr_p->i2c_client_p); - kfree(i2c_curr_p); - i2c_curr_p = i2c_next_p; - } -err_create_ioexp_setup_attr_fail: - kfree(result_p); -err_create_ioexp_fail: - SWPS_ERR("%s: fail! :%d :%d \n", - __func__, ioexp_id, ioexp_type); - return NULL; -} - - -int -create_ioexp_obj(int ioexp_id, - int ioexp_type, - struct ioexp_addr_s *addr_map_p, - int run_mode){ - - struct ioexp_obj_s *ioexp_p = NULL; - - ioexp_p = _create_ioexp_obj(ioexp_id, ioexp_type, - addr_map_p, run_mode); - if (!ioexp_p){ - return -1; - } - if (ioexp_head_p == NULL){ - ioexp_head_p = ioexp_p; - ioexp_tail_p = ioexp_p; - return 0; - } - ioexp_tail_p->next = ioexp_p; - ioexp_tail_p = ioexp_p; - return 0; -} - - -static int -_init_ioexp_obj(struct ioexp_obj_s* self) { - - char *err_msg = "ERR"; - char *func_name = "_init_ioexp_obj"; - - /* Setup IOEXP configure byte */ - if (setup_ioexp_config(self) < 0){ - err_msg = "setup_ioexp_config fail"; - goto err_init_ioexp_obj; - } - /* Setup default data */ - if (_ioexp_init_handler(self) < 0){ - err_msg = "_ioexp_init_handler fail"; - goto err_init_ioexp_obj; - } - /* Update all */ - if (self->state == STATE_IOEXP_NORMAL){ - if (self->update_all(self, 1, func_name) < 0){ - err_msg = "update_all() fail"; - goto err_init_ioexp_obj; - } - } - return 0; - -err_init_ioexp_obj: - SWPS_DEBUG("%s: %s\n", __func__, err_msg); - return -1; -} - - -int -init_ioexp_objs(void){ - /* Return value: - * 0: Success - * -1: Detect topology error - * -2: SWPS internal error - */ - - struct ioexp_obj_s *curr_p = ioexp_head_p; - - if (!curr_p) { - SWPS_ERR("%s: ioexp_head_p is NULL\n", __func__); - return -2; - } - while (curr_p) { - if (_init_ioexp_obj(curr_p) < 0) { - SWPS_DEBUG("%s: _init_ioexp_obj() fail\n", __func__); - return -1; - } - curr_p = curr_p->next; - } - SWPS_DEBUG("%s: done.\n", __func__); - return 0; -} - - -void -clean_ioexp_objs(void){ - - struct ioexp_i2c_s *i2c_curr_p = NULL; - struct ioexp_i2c_s *i2c_next_p = NULL; - struct ioexp_obj_s *ioexp_next_p = NULL; - struct ioexp_obj_s *ioexp_curr_p = ioexp_head_p; - - if (ioexp_head_p == NULL){ - ioexp_tail_p = NULL; - return; - } - while(ioexp_curr_p){ - ioexp_next_p = ioexp_curr_p->next; - if (ioexp_curr_p->ioexp_map_p) { - if (ioexp_curr_p->ioexp_map_p->map_addr) { - kfree(ioexp_curr_p->ioexp_map_p->map_addr); - } - kfree(ioexp_curr_p->ioexp_map_p); - } - - i2c_curr_p = ioexp_curr_p->i2c_head_p; - while (i2c_curr_p) { - i2c_next_p = i2c_curr_p->next; - kfree(i2c_curr_p->i2c_client_p); - kfree(i2c_curr_p); - i2c_curr_p = i2c_next_p; - } - kfree(ioexp_curr_p); - ioexp_curr_p = ioexp_next_p; - } - ioexp_tail_p = NULL; - SWPS_DEBUG("%s: done.\n", __func__); -} - - -int -check_ioexp_objs(void){ - - struct ioexp_obj_s *ioexp_curr_p = ioexp_head_p; - - while (ioexp_curr_p){ - if ( (ioexp_curr_p->check(ioexp_curr_p)) < 0){ - SWPS_INFO("check IOEXP-%d fail! :%d\n", - ioexp_curr_p->ioexp_id, ioexp_curr_p->ioexp_type); - return -1; - } - ioexp_curr_p = ioexp_curr_p->next; - } - return 0; -} - - -struct ioexp_obj_s * -get_ioexp_obj(int ioexp_id){ - - struct ioexp_obj_s *result_p = NULL; - struct ioexp_obj_s *ioexp_curr_p = ioexp_head_p; - - while(ioexp_curr_p){ - if (ioexp_curr_p->ioexp_id == ioexp_id){ - result_p = ioexp_curr_p; - break; - } - ioexp_curr_p = ioexp_curr_p->next; - } - return result_p; -} - - -void -unlock_ioexp_all(void) { - - struct ioexp_obj_s *ioexp_curr_p = ioexp_head_p; - - while(ioexp_curr_p){ - mutex_unlock(&ioexp_curr_p->lock); - ioexp_curr_p = ioexp_curr_p->next; - } -} - - -int -lock_ioexp_all(void) { - - struct ioexp_obj_s *ioexp_curr_p = ioexp_head_p; - - while(ioexp_curr_p){ - mutex_lock(&ioexp_curr_p->lock); - ioexp_curr_p = ioexp_curr_p->next; - } - return 0; -} - - -int -check_channel_tier_1(void) { - - if ( (!_is_channel_ready(ioexp_head_p)) && - (!_is_channel_ready(ioexp_tail_p)) ){ - return -1; - } - return 0; -} - - -static int -_scan_channel_tier_1(int force, - int show_err) { - - struct ioexp_obj_s *ioexp_curr_p = ioexp_head_p; - int ready = 0; - - if (!ioexp_curr_p) { - goto err_scan_tier_1_channel; - } - while(ioexp_curr_p) { - ready = _is_channel_ready(ioexp_curr_p); - if ((!ready) && (!force)) { - goto err_scan_tier_1_channel; - } - ioexp_curr_p = ioexp_curr_p->next; - } - return 0; - -err_scan_tier_1_channel: - if (show_err) { - if (ioexp_curr_p) { - SWPS_INFO("%s: IOEXP-%d fail\n", __func__, ioexp_curr_p->ioexp_id); - } else { - SWPS_INFO("%s: IOEXP is null.\n", __func__); - } - } - return -1; -} - - -static int -_scan_channel_tier_1_single(void) { - - int ret = 0; - int chan_id = 0; - int fake_cid = 0; - int fake_offs = 0; - int fake_addr = 0; - struct i2c_adapter *adap = NULL; - struct i2c_client *client = NULL; - - if (ioexp_head_p->ioexp_id != ioexp_tail_p->ioexp_id) { - return 0; - } - /* Setup i2c_client */ - chan_id = ioexp_head_p->ioexp_map_p->map_addr[fake_cid].chan_id; - fake_addr = ioexp_head_p->ioexp_map_p->map_addr[fake_cid].chip_addr; - adap = i2c_get_adapter((chan_id + 1)); - if(!adap){ - SWPS_INFO("%s: Can not get adap!\n", __func__); - return 0; - } - client = kzalloc(sizeof(*client), GFP_KERNEL); - if (!client){ - SWPS_INFO("%s: Can not kzalloc client!\n", __func__); - return 0; - } - client->adapter = adap; - client->addr = fake_addr; - /* Fouce move ioexp ptr to next */ - ret = i2c_smbus_read_byte_data(client, fake_offs); - SWPS_DEBUG("%s: move ioexp_ptr done. :%d\n", __func__, ret); - kfree(client); - return 1; -} - - -int -resync_channel_tier_1(void) { - - char *emsg = "ERR"; - - if (!ioexp_head_p) { - emsg = "ioexp_head_p is NULL"; - goto err_resync_ioexp_status_1; - } - /* Run all */ - if (ioexp_head_p->ioexp_id == ioexp_tail_p->ioexp_id) { - _scan_channel_tier_1_single(); - } else { - _scan_channel_tier_1(1, 0); - } - /* Check all */ - if (_scan_channel_tier_1(0, 1) < 0) { - emsg = "resync tier-1 channel fail"; - goto err_resync_ioexp_status_1; - } - return 0; - -err_resync_ioexp_status_1: - SWPS_ERR("%s: %s\n", __func__, emsg); - return -1; -} - - - - - - - diff --git a/packages/platforms/inventec/x86-64/d3352/modules/builds/src/io_expander.h b/packages/platforms/inventec/x86-64/d3352/modules/builds/src/io_expander.h deleted file mode 100644 index 784bdb98b..000000000 --- a/packages/platforms/inventec/x86-64/d3352/modules/builds/src/io_expander.h +++ /dev/null @@ -1,178 +0,0 @@ -#ifndef IO_EXPANDER_H -#define IO_EXPANDER_H - -#include - - -/* IOEXP type define (SFP series) */ -#define IOEXP_TYPE_MAGINOLIA_NAB (10101) -#define IOEXP_TYPE_MAGINOLIA_4AB (10102) -#define IOEXP_TYPE_CYPRESS_NABC (10103) - -/* IOEXP type define (QSFP series) */ -#define IOEXP_TYPE_MAGINOLIA_7AB (10201) -#define IOEXP_TYPE_REDWOOD_P01P08 (10202) -#define IOEXP_TYPE_REDWOOD_P09P16 (10203) -#define IOEXP_TYPE_HUDSON32IGA_P01P08 (10204) -#define IOEXP_TYPE_HUDSON32IGA_P09P16 (10205) -#define IOEXP_TYPE_SPRUCE_7AB (10206) -#define IOEXP_TYPE_CYPRESS_7ABC (10207) -#define IOEXP_TYPE_TAHOE_5A (10208) -#define IOEXP_TYPE_TAHOE_6ABC (10209) -#define IOEXP_TYPE_SEQUOIA_NABC (10210) -#define IOEXP_TYPE_LAVENDER_P65 (10211) - -/* CPLD type define */ -#define CPLD_TYPE_COTTONWOOD (10301) - -/* IOEXP mode define */ -#define IOEXP_MODE_POLLING (19000) -#define IOEXP_MODE_DIRECT (19001) - -/* IOEXP state define */ -#define STATE_IOEXP_NORMAL (0) -#define STATE_IOEXP_INIT (-1) -#define STATE_IOEXP_ABNORMAL (-2) - -/* IOEXP error code define */ -#define ERR_IOEXP_NOTSUPPORT (-100) -#define ERR_IOEXP_UNINIT (-101) -#define ERR_IOEXP_BADCONF (-102) -#define ERR_IOEXP_ABNORMAL (-103) -#define ERR_IOEXP_NOSTATE (-104) -#define ERR_IOEXP_BADINPUT (-105) -#define ERR_IOEXP_UNEXCPT (-199) - -#define SWPS_INFO(fmt, args...) printk( KERN_INFO "[SWPS] " fmt, ##args) -#define SWPS_WARN(fmt, args...) printk( KERN_WARNING "[SWPS] " fmt, ##args) -#define SWPS_ERR(fmt, args...) printk( KERN_ERR "[SWPS] " fmt, ##args) - -#ifdef DEBUG_SWPS -# define SWPS_DEBUG(fmt, args...) printk( KERN_DEBUG "[SWPS] " fmt, ##args) -#else -# define SWPS_DEBUG(fmt, args...) -#endif - - -struct ioexp_addr_s { - int chan_id; - int chip_addr; - int read_offset[8]; - int write_offset[8]; - int conf_offset[8]; - uint8_t data_default[8]; - uint8_t conf_default[8]; -}; - -struct ioexp_i2c_s { - int chip_id; - struct i2c_client *i2c_client_p; - struct ioexp_i2c_s *next; -}; - - -struct ioexp_bitmap_s { - int chip_id; /* IOEXP chip id */ - int ioexp_voffset; /* IOEXP virtual offset */ - int bit_shift; -}; - -struct ioexp_map_s { - int chip_amount; /* Number of chips that IOEXP object content */ - int data_width; /* Number of (Read/Write/Config) bytes */ - struct ioexp_addr_s *map_addr; /* Chip address info */ - struct ioexp_bitmap_s map_present[10]; /* IOEXP for SFP / QSFP */ - struct ioexp_bitmap_s map_tx_disable[10]; /* IOEXP for SFP */ - struct ioexp_bitmap_s map_tx_fault[10]; /* IOEXP for SFP */ - struct ioexp_bitmap_s map_rxlos[10]; /* IOEXP for SFP */ - struct ioexp_bitmap_s map_reset[10]; /* IOEXP for QSFP */ - struct ioexp_bitmap_s map_lpmod[10]; /* IOEXP for QSFP */ - struct ioexp_bitmap_s map_modsel[10]; /* IOEXP for QSFP */ - struct ioexp_bitmap_s map_hard_rs0[10]; /* IOEXP for QSFP */ - struct ioexp_bitmap_s map_hard_rs1[10]; /* IOEXP for QSFP */ -}; - -struct ioexp_data_s { - uint8_t data[8]; -}; - -struct ioexp_obj_s { - - /* ============================ - * Object public property - * ============================ - */ - int ioexp_id; - int ioexp_type; - - /* ============================ - * Object private property - * ============================ - */ - struct ioexp_data_s chip_data[16]; /* Max: 8-ioexp in one virt-ioexp(ioexp_obj) */ - struct ioexp_map_s *ioexp_map_p; - struct ioexp_obj_s *next; - struct ioexp_i2c_s *i2c_head_p; - struct mutex lock; - int mode; - int state; - - /* =========================================== - * Object public functions - * =========================================== - */ - int (*get_present)(struct ioexp_obj_s *self, int virt_offset); - int (*get_tx_fault)(struct ioexp_obj_s *self, int virt_offset); - int (*get_rxlos)(struct ioexp_obj_s *self, int virt_offset); - int (*get_tx_disable)(struct ioexp_obj_s *self, int virt_offset); - int (*get_reset)(struct ioexp_obj_s *self, int virt_offset); - int (*get_lpmod)(struct ioexp_obj_s *self, int virt_offset); - int (*get_modsel)(struct ioexp_obj_s *self, int virt_offset); - int (*get_hard_rs0)(struct ioexp_obj_s *self, int virt_offset); - int (*get_hard_rs1)(struct ioexp_obj_s *self, int virt_offset); - int (*set_tx_disable)(struct ioexp_obj_s *self, int virt_offset, int input_val); - int (*set_reset)(struct ioexp_obj_s *self, int virt_offset, int input_val); - int (*set_lpmod)(struct ioexp_obj_s *self, int virt_offset, int input_val); - int (*set_modsel)(struct ioexp_obj_s *self, int virt_offset, int input_val); - int (*set_hard_rs0)(struct ioexp_obj_s *self, int virt_offset, int input_val); - int (*set_hard_rs1)(struct ioexp_obj_s *self, int virt_offset, int input_val); - - /* =========================================== - * Object private functions - * =========================================== - */ - int (*init)(struct ioexp_obj_s *self); - int (*check)(struct ioexp_obj_s *self); - int (*update_all)(struct ioexp_obj_s *self, int show_err, char *caller_name); - int (*fsm_4_direct)(struct ioexp_obj_s* self); - int (*fsm_4_polling)(struct ioexp_obj_s* self); -}; - - -struct ioexp_obj_s* get_ioexp_obj(int ioexp_id); -int create_ioexp_obj(int ioexp_id, - int ioexp_type, - struct ioexp_addr_s *addr_map_p, - int run_mode); -int init_ioexp_objs(void); -int check_ioexp_objs(void); -void clean_ioexp_objs(void); - -void unlock_ioexp_all(void); -int lock_ioexp_all(void); - -int check_channel_tier_1(void); -int resync_channel_tier_1(void); - -/* Macro for bit control */ -#define SWP_BIT_SET(byte_val,bit_shift) ((byte_val) |= (1<<(bit_shift))) -#define SWP_BIT_CLEAR(byte_val,bit_shift) ((byte_val) &= ~(1<<(bit_shift))) - - -#endif /* IO_EXPANDER_H */ - - - - - - diff --git a/packages/platforms/inventec/x86-64/d3352/modules/builds/src/transceiver.c b/packages/platforms/inventec/x86-64/d3352/modules/builds/src/transceiver.c deleted file mode 100644 index 34adc1c85..000000000 --- a/packages/platforms/inventec/x86-64/d3352/modules/builds/src/transceiver.c +++ /dev/null @@ -1,8463 +0,0 @@ -#include -#include -#include -#include -#include "io_expander.h" -#include "transceiver.h" - - -/* ========== Register EEPROM address mapping ========== - */ -struct eeprom_map_s eeprom_map_sfp = { - .addr_br =0x50, .page_br =-1, .offset_br =12, .length_br =1, - .addr_cdr =-1, .page_cdr =-1, .offset_cdr =-1, .length_cdr =-1, - .addr_comp_rev =0x50, .page_comp_rev =-1, .offset_comp_rev =94, .length_comp_rev =1, - .addr_connector =0x50, .page_connector =-1, .offset_connector =2, .length_connector =1, - .addr_diag_type =0x50, .page_diag_type =-1, .offset_diag_type =92 , .length_diag_type =1, - .addr_extbr =-1, .page_extbr =-1, .offset_extbr =-1, .length_extbr =-1, - .addr_ext_id =0x50, .page_ext_id =-1, .offset_ext_id =1, .length_ext_id =1, - .addr_id =0x50, .page_id =-1, .offset_id =0, .length_id =1, - .addr_len_sm =0x50, .page_len_sm =-1, .offset_len_sm =15, .length_len_sm =1, - .addr_len_smf =0x50, .page_len_smf =-1, .offset_len_smf =14, .length_len_smf =1, - .addr_len_om1 =0x50, .page_len_om1 =-1, .offset_len_om1 =17, .length_len_om1 =1, - .addr_len_om2 =0x50, .page_len_om2 =-1, .offset_len_om2 =16, .length_len_om2 =1, - .addr_len_om3 =0x50, .page_len_om3 =-1, .offset_len_om3 =19, .length_len_om3 =1, - .addr_len_om4 =0x50, .page_len_om4 =-1, .offset_len_om4 =18, .length_len_om4 =1, - .addr_option =0x50, .page_option =-1, .offset_option =64, .length_option =2, - .addr_rate_id =0x50, .page_rate_id =-1, .offset_rate_id =13, .length_rate_id =1, - .addr_rx_am =-1, .page_rx_am =-1, .offset_rx_am =-1, .length_rx_am =-1, - .addr_rx_em =0x51, .page_rx_em =-1, .offset_rx_em =115, .length_rx_em =1, - .addr_rx_los =-1, .page_rx_los =-1, .offset_rx_los =-1, .length_rx_los =-1, - .addr_rx_power =0x51, .page_rx_power =-1, .offset_rx_power =104, .length_rx_power =2, - .addr_soft_rs0 =0x51, .page_soft_rs0 =-1, .offset_soft_rs0 =110, .length_soft_rs0 =1, - .addr_soft_rs1 =0x51, .page_soft_rs1 =-1, .offset_soft_rs1 =118, .length_soft_rs0 =1, - .addr_temp =0x51, .page_temp =-1, .offset_temp =96, .length_temp =2, - .addr_trancomp =0x50, .page_trancomp =-1, .offset_trancomp =3, .length_trancomp =8, - .addr_trancomp_ext =0x50, .page_trancomp_ext =-1, .offset_trancomp_ext =36, .length_trancomp_ext =1, - .addr_tx_bias =0x51, .page_tx_bias =-1, .offset_tx_bias =100, .length_tx_bias =2, - .addr_tx_disable =-1, .page_tx_disable =-1, .offset_tx_disable =-1, .length_tx_disable =-1, - .addr_tx_eq =0x51, .page_tx_eq =-1, .offset_tx_eq =114, .length_tx_eq =1, - .addr_tx_fault =-1, .page_tx_fault =-1, .offset_tx_fault =-1, .length_tx_fault =-1, - .addr_tx_power =0x51, .page_tx_power =-1, .offset_tx_power =102, .length_tx_power =2, - .addr_vendor_name =0x50, .page_vendor_name =-1, .offset_vendor_name =20, .length_vendor_name =16, - .addr_vendor_pn =0x50, .page_vendor_pn =-1, .offset_vendor_pn =40, .length_vendor_pn =16, - .addr_vendor_rev =0x50, .page_vendor_rev =-1, .offset_vendor_rev =56, .length_vendor_rev =4, - .addr_vendor_sn =0x50, .page_vendor_sn =-1, .offset_vendor_sn =68, .length_vendor_sn =16, - .addr_voltage =0x51, .page_voltage =-1, .offset_voltage =98, .length_voltage =2, - .addr_wavelength =0x50, .page_wavelength =-1, .offset_wavelength =60, .length_wavelength =2, - .addr_eeprom =0x50, .page_eeprom =-1, .offset_eeprom =0, .length_eeprom =128, - .addr_uppage =0x50, .page_uppage =-1, .offset_uppage =128, .length_eeprom =128, -}; - -struct eeprom_map_s eeprom_map_qsfp = { - .addr_br =0x50, .page_br =0, .offset_br =140, .length_br =1, - .addr_cdr =-1, .page_cdr =-1, .offset_cdr =-1, .length_cdr =-1, - .addr_comp_rev =0x50, .page_comp_rev =-1, .offset_comp_rev =1, .length_comp_rev =1, - .addr_connector =0x50, .page_connector =0, .offset_connector =130, .length_connector =1, - .addr_diag_type =0x50, .page_diag_type =0, .offset_diag_type =220, .length_diag_type =1, - .addr_extbr =0x50, .page_extbr =0, .offset_extbr =222, .length_extbr =1, - .addr_ext_id =0x50, .page_ext_id =0, .offset_ext_id =129, .length_ext_id =1, - .addr_id =0x50, .page_id =0, .offset_id =128, .length_id =1, - .addr_len_sm =-1, .page_len_sm =-1, .offset_len_sm =-1, .length_len_sm =-1, - .addr_len_smf =0x50, .page_len_smf =0, .offset_len_smf =142, .length_len_smf =1, - .addr_len_om1 =0x50, .page_len_om1 =0, .offset_len_om1 =145, .length_len_om1 =1, - .addr_len_om2 =0x50, .page_len_om2 =0, .offset_len_om2 =144, .length_len_om2 =1, - .addr_len_om3 =0x50, .page_len_om3 =0, .offset_len_om3 =143, .length_len_om3 =1, - .addr_len_om4 =0x50, .page_len_om4 =0, .offset_len_om4 =146, .length_len_om4 =1, - .addr_option =0x50, .page_option =0, .offset_option =193, .length_option =3, - .addr_rate_id =-1, .page_rate_id =-1, .offset_rate_id =-1, .length_rate_id =-1, - .addr_rx_am =-1, .page_rx_am =-1, .offset_rx_am =-1, .length_rx_am =-1, - .addr_rx_em =-1, .page_rx_em =-1, .offset_rx_em =-1, .length_rx_em =-1, - .addr_rx_los =0x50, .page_rx_los =-1, .offset_rx_los =3, .length_rx_los =1, - .addr_rx_power =0x50, .page_rx_power =-1, .offset_rx_power =34, .length_rx_power =8, - .addr_soft_rs0 =-1, .page_soft_rs0 =-1, .offset_soft_rs0 =-1, .length_soft_rs0 =-1, - .addr_soft_rs1 =-1, .page_soft_rs1 =-1, .offset_soft_rs1 =-1, .length_soft_rs0 =-1, - .addr_temp =0x50, .page_temp =-1, .offset_temp =22, .length_temp =2, - .addr_trancomp =0x50, .page_trancomp =0, .offset_trancomp =131, .length_trancomp =8, - .addr_trancomp_ext =0x50, .page_trancomp_ext =0, .offset_trancomp_ext =192, .length_trancomp_ext =1, - .addr_tx_bias =0x50, .page_tx_bias =-1, .offset_tx_bias =42, .length_tx_bias =8, - .addr_tx_disable =0x50, .page_tx_disable =-1, .offset_tx_disable =86, .length_tx_disable =1, - .addr_tx_eq =-1, .page_tx_eq =-1, .offset_tx_eq =-1, .length_tx_eq =-1, - .addr_tx_fault =0x50, .page_tx_fault =-1, .offset_tx_fault =4, .length_tx_fault =1, - .addr_tx_power =0x50, .page_tx_power =-1, .offset_tx_power =50, .length_tx_power =8, - .addr_vendor_name =0x50, .page_vendor_name =0, .offset_vendor_name =148, .length_vendor_name =16, - .addr_vendor_pn =0x50, .page_vendor_pn =0, .offset_vendor_pn =168, .length_vendor_pn =16, - .addr_vendor_rev =0x50, .page_vendor_rev =0, .offset_vendor_rev =184, .length_vendor_rev =2, - .addr_vendor_sn =0x50, .page_vendor_sn =0, .offset_vendor_sn =196, .length_vendor_sn =16, - .addr_voltage =0x50, .page_voltage =-1, .offset_voltage =26, .length_voltage =2, - .addr_wavelength =0x50, .page_wavelength =0, .offset_wavelength =186, .length_wavelength =2, - .addr_eeprom =0x50, .page_eeprom =0, .offset_eeprom =128, .length_eeprom =128, - .addr_uppage =0x50, .page_uppage =0, .offset_uppage =256, .length_eeprom =128, -}; - -struct eeprom_map_s eeprom_map_qsfp28 = { - .addr_br =0x50, .page_br =0, .offset_br =140, .length_br =1, - .addr_cdr =0x50, .page_cdr =-1, .offset_cdr =98, .length_cdr =1, - .addr_comp_rev =0x50, .page_comp_rev =-1, .offset_comp_rev =1, .length_comp_rev =1, - .addr_connector =0x50, .page_connector =0, .offset_connector =130, .length_connector =1, - .addr_diag_type =0x50, .page_diag_type =0, .offset_diag_type =220, .length_diag_type =1, - .addr_extbr =0x50, .page_extbr =0, .offset_extbr =222, .length_extbr =1, - .addr_ext_id =0x50, .page_ext_id =0, .offset_ext_id =129, .length_ext_id =1, - .addr_id =0x50, .page_id =0, .offset_id =128, .length_id =1, - .addr_len_sm =-1, .page_len_sm =-1, .offset_len_sm =-1, .length_len_sm =-1, - .addr_len_smf =0x50, .page_len_smf =0, .offset_len_smf =142, .length_len_smf =1, - .addr_len_om1 =0x50, .page_len_om1 =0, .offset_len_om1 =145, .length_len_om1 =1, - .addr_len_om2 =0x50, .page_len_om2 =0, .offset_len_om2 =144, .length_len_om2 =1, - .addr_len_om3 =0x50, .page_len_om3 =0, .offset_len_om3 =143, .length_len_om3 =1, - .addr_len_om4 =0x50, .page_len_om4 =0, .offset_len_om4 =146, .length_len_om4 =1, - .addr_option =0x50, .page_option =0, .offset_option =193, .length_option =3, - .addr_rate_id =-1, .page_rate_id =-1, .offset_rate_id =-1, .length_rate_id =-1, - .addr_rx_am =0x50, .page_rx_am =3, .offset_rx_am =238, .length_rx_am =2, - .addr_rx_em =0x50, .page_rx_em =3, .offset_rx_em =236, .length_rx_em =2, - .addr_rx_los =0x50, .page_rx_los =-1, .offset_rx_los =3, .length_rx_los =1, - .addr_rx_power =0x50, .page_rx_power =-1, .offset_rx_power =34, .length_rx_power =8, - .addr_soft_rs0 =-1, .page_soft_rs0 =-1, .offset_soft_rs0 =-1, .length_soft_rs0 =-1, - .addr_soft_rs1 =-1, .page_soft_rs1 =-1, .offset_soft_rs1 =-1, .length_soft_rs0 =-1, - .addr_temp =0x50, .page_temp =-1, .offset_temp =22, .length_temp =2, - .addr_trancomp =0x50, .page_trancomp =0, .offset_trancomp =131, .length_trancomp =8, - .addr_trancomp_ext =0x50, .page_trancomp_ext =0, .offset_trancomp_ext =192, .length_trancomp_ext =1, - .addr_tx_bias =0x50, .page_tx_bias =-1, .offset_tx_bias =42, .length_tx_bias =8, - .addr_tx_disable =0x50, .page_tx_disable =-1, .offset_tx_disable =86, .length_tx_disable =1, - .addr_tx_eq =0x50, .page_tx_eq =3, .offset_tx_eq =234, .length_tx_eq =2, - .addr_tx_fault =0x50, .page_tx_fault =-1, .offset_tx_fault =4, .length_tx_fault =1, - .addr_tx_power =0x50, .page_tx_power =-1, .offset_tx_power =50, .length_tx_power =8, - .addr_vendor_name =0x50, .page_vendor_name =0, .offset_vendor_name =148, .length_vendor_name =16, - .addr_vendor_pn =0x50, .page_vendor_pn =0, .offset_vendor_pn =168, .length_vendor_pn =16, - .addr_vendor_rev =0x50, .page_vendor_rev =0, .offset_vendor_rev =184, .length_vendor_rev =2, - .addr_vendor_sn =0x50, .page_vendor_sn =0, .offset_vendor_sn =196, .length_vendor_sn =16, - .addr_voltage =0x50, .page_voltage =-1, .offset_voltage =26, .length_voltage =2, - .addr_wavelength =0x50, .page_wavelength =0, .offset_wavelength =186, .length_wavelength =2, - .addr_eeprom =0x50, .page_eeprom =0, .offset_eeprom =128, .length_eeprom =128, - .addr_uppage =0x50, .page_uppage =0, .offset_uppage =256, .length_uppage =128, -}; - - -/* ========== Utility Functions ========== - */ -static int -get_bit(uint8_t origin_byte, int bit_shift) { - return (int)((origin_byte >> bit_shift) & 0x1); -} - -static int -transform_word_to_int(uint8_t hight_byte, - uint8_t low_byte) { - return ((((int)hight_byte) << 8) + (int)low_byte); -} - -void -alarm_msg_2_user(struct transvr_obj_s *self, - char *emsg) { - - SWPS_ERR("%s on %s.\n", emsg, self->swp_name); -} - - -/* ========== Private functions ========== - */ -static int -_reload_transvr_obj(struct transvr_obj_s *self,int new_type); - -static int -reload_transvr_obj(struct transvr_obj_s *self,int new_type); - -static int -_is_transvr_support_ctle(struct transvr_obj_s *self); - -static int -_transvr_init_handler(struct transvr_obj_s *self); - -int -_transvr_clean_handler(struct transvr_obj_s *self); - -int -_sfp_detect_class_by_1g_ethernet(struct transvr_obj_s* self); - - -void -lock_transvr_obj(struct transvr_obj_s *self) { - - mutex_lock(&self->lock); - self->curr_page = VAL_TRANSVR_PAGE_FREE; -} - - -void -unlock_transvr_obj(struct transvr_obj_s *self) { - - self->curr_page = VAL_TRANSVR_PAGE_FREE; - mutex_unlock(&self->lock); -} - - -static int -_check_by_mode(struct transvr_obj_s *self, - int (*attr_update_func)(struct transvr_obj_s *self, int show_err), - char *caller_name){ - - int return_val = ERR_TRANSVR_UNEXCPT; - - switch (self->mode){ - case TRANSVR_MODE_POLLING: - switch (self->state){ - case STATE_TRANSVR_CONNECTED: - goto ok_check_by_mode_1; - case STATE_TRANSVR_NEW: - case STATE_TRANSVR_INIT: - return ERR_TRANSVR_UNINIT; - case STATE_TRANSVR_DISCONNECTED: - return ERR_TRANSVR_UNPLUGGED; - case STATE_TRANSVR_UNEXCEPTED: - return ERR_TRANSVR_ABNORMAL; - case STATE_TRANSVR_ISOLATED: - return ERR_TRNASVR_BE_ISOLATED; - default: - goto err_check_by_mode_1; - } - goto ok_check_by_mode_1; - - case TRANSVR_MODE_DIRECT: - return_val = self->fsm_4_direct(self, caller_name); - if (return_val < 0){ - return return_val; - } - goto ok_check_by_mode_1; - - default: - goto err_check_by_mode_1; - } - goto ok_check_by_mode_1; - -ok_check_by_mode_1: - return attr_update_func(self, 0); - -err_check_by_mode_1: - SWPS_INFO("_check_by_mode: mode:%d state:%d\n", self->mode, self->state); - return ERR_TRANSVR_UNEXCPT; -} - - -static void -_transvr_clean_retry(struct transvr_obj_s *self) { - self->retry = 0; -} - - -static int -_transvr_handle_retry(struct transvr_obj_s *self, int retry) { - /* Return: 0: keep retry - * -1: stop retry - */ - if (self->retry == 0) { - self->retry = retry; - } - self->retry -= 1; - if (self->retry <= 0) { - _transvr_clean_retry(self); - return -1; - } - return 0; -} - - -static int -_common_setup_page(struct transvr_obj_s *self, - int addr, - int page, - int offset, - int len, - int show_e) { - /* return: - * 0 : OK - * -1 : EEPROM settings incorrect - * -2 : I2C R/W failure - * -3 : Undefined case - */ - int retval = DEBUG_TRANSVR_INT_VAL; - char *emsg = DEBUG_TRANSVR_STR_VAL; - - /* Check */ - if ((addr < 0) || (offset < 0) || (len < 0)) { - emsg = "EEPROM settings incorrect"; - retval = -1; - goto err_common_setup_page; - } - /* Case1: continue access */ - if ((self->i2c_client_p->addr == addr) && - (self->curr_page == page)) { - return 0; - } - self->i2c_client_p->addr = addr; - /* Case2: select lower page */ - if (page == -1) { - self->curr_page = page; - return 0; - } - /* Case3: select upper page */ - if (page >= 0) { - goto upper_common_setup_page; - } - /* Unexpected case */ - show_e = 1; - emsg = "Unexpected case"; - retval = -3; - goto err_common_setup_page; - -upper_common_setup_page: - if (i2c_smbus_write_byte_data(self->i2c_client_p, - VAL_TRANSVR_PAGE_SELECT_OFFSET, - page) < 0) { - emsg = "I2C R/W failure"; - retval = -2; - goto err_common_setup_page; - } - self->curr_page = page; - mdelay(VAL_TRANSVR_PAGE_SELECT_DELAY); - return 0; - -err_common_setup_page: - if (show_e) { - SWPS_INFO("%s: %s", __func__, emsg); - SWPS_INFO("%s: :0x%02x :%d :%d :%d\n", - __func__, addr, page, offset, len); - } - return retval; -} - -/* -static int -_common_setup_password(struct transvr_obj_s *self, - int addr, - int page, - int offs, - uint8_t pwd[4], - int show_e) { - int i = 0; - int err = DEBUG_TRANSVR_INT_VAL; - char *emsg = DEBUG_TRANSVR_STR_VAL; - - err = _common_setup_page(self, addr, page, offs, 4, show_e); - if (err < 0){ - emsg = "setup EEPROM page fail"; - goto err_common_setup_password; - } - for (i=0; i<4; i++) { - err = i2c_smbus_write_byte_data(self->i2c_client_p, - (offs + i), - pwd[i]); - if (err < 0){ - emsg = "I2C R/W fail!"; - goto err_common_setup_password; - } - } - return 0; - -err_common_setup_password: - if (show_e) { - SWPS_INFO("%s: %s :%d\n", __func__, emsg, err); - } - return ERR_TRANSVR_UPDATE_FAIL; -} -*/ - -static int -_common_update_uint8_attr(struct transvr_obj_s *self, - int addr, - int page, - int offset, - int len, - uint8_t *buf, - char *caller, - int show_e){ - - int i; - int err = DEBUG_TRANSVR_INT_VAL; - char *emsg = DEBUG_TRANSVR_STR_VAL; - - err = _common_setup_page(self, addr, page, offset, len, show_e); - if (err < 0){ - emsg = "setup EEPROM page fail"; - goto err_common_update_uint8_attr; - } - for (i=0; ii2c_client_p, (offset + i)); - if (err < 0){ - emsg = "I2C R/W fail!"; - goto err_common_update_uint8_attr; - } - buf[i] = err; - } - return 0; - -err_common_update_uint8_attr: - if (show_e) { - SWPS_INFO("%s: %s :%s :%d\n", - __func__, emsg, caller, err); - } - buf[0] = DEBUG_TRANSVR_HEX_VAL; - return ERR_TRANSVR_UPDATE_FAIL; -} - - -static int -_common_update_int_attr(struct transvr_obj_s *self, - int addr, - int page, - int offset, - int len, - int *buf, - char *caller, - int show_e){ - - int i; - int err = DEBUG_TRANSVR_INT_VAL; - char *emsg = DEBUG_TRANSVR_STR_VAL; - - err = _common_setup_page(self, addr, page, offset, len, show_e); - if (err < 0){ - emsg = "setup EEPROM page fail"; - goto err_common_update_int_attr; - } - for (i=0; ii2c_client_p, (offset + i)); - if (err < 0){ - emsg = "I2C R/W fail!"; - goto err_common_update_int_attr; - } - buf[i] = (int)err; - } - return 0; - -err_common_update_int_attr: - if (show_e) { - SWPS_INFO("%s: %s :%s :%d\n", - __func__, emsg, caller, err); - } - buf[0] = DEBUG_TRANSVR_INT_VAL; - return ERR_TRANSVR_UPDATE_FAIL; -} - - -static int -_common_update_string_attr(struct transvr_obj_s *self, - int addr, - int page, - int offset, - int len, - char buf[], - char *caller, - int show_e){ - - int i; - int err = DEBUG_TRANSVR_INT_VAL; - char *emsg = DEBUG_TRANSVR_STR_VAL; - - err = _common_setup_page(self, addr, page, offset, len, show_e); - if (err < 0){ - emsg = "setup EEPROM page fail"; - goto err_common_update_string_attr; - } - for (i=0; ii2c_client_p, (offset + i)); - if (err < 0){ - emsg = "I2C R/W fail!"; - goto err_common_update_string_attr; - } - buf[i] = (char)err; - } - return 0; - -err_common_update_string_attr: - if (show_e) { - SWPS_INFO("%s: %s :%s :%d\n", - __func__, emsg, caller, err); - } - buf[0] = 'e'; - return ERR_TRANSVR_UPDATE_FAIL; -} - - -static int -_common_set_uint8_attr(struct transvr_obj_s *self, - int addr, - int page, - int offset, - uint8_t update, - uint8_t *buf, - char *caller, - int show_e){ - int len = 1; - int err = DEBUG_TRANSVR_INT_VAL; - char *emsg = DEBUG_TRANSVR_STR_VAL; - - if ((*buf) == update){ - return 0; - } - err = _common_setup_page(self, addr, page, offset, len, show_e); - if (err < 0){ - emsg = "setup EEPROM page fail"; - goto err_common_set_uint8_attr_1; - } - err = i2c_smbus_write_byte_data(self->i2c_client_p, - offset, - update); - if (err < 0){ - emsg = "I2C R/W fail!"; - goto err_common_set_uint8_attr_1; - } - (*buf) = update; - return 0; - -err_common_set_uint8_attr_1: - if (show_e) { - SWPS_INFO("%s: %s :%s :%d\n", - __func__, emsg, caller, err); - } - return ERR_TRANSVR_UPDATE_FAIL; -} - - -static int -_common_set_uint8_array(struct transvr_obj_s *self, - int addr, - int page, - int offs, - int len, - uint8_t update[], - uint8_t buf[], - char *caller, - int show_e){ - int i = 0; - int err = DEBUG_TRANSVR_INT_VAL; - char *emsg = DEBUG_TRANSVR_STR_VAL; - - err = _common_setup_page(self, addr, page, offs, len, show_e); - if (err < 0){ - emsg = "setup EEPROM page fail"; - goto err_common_set_uint8_attr_1; - } - for (i=0; ii2c_client_p, - (offs + i), - update[i]); - if (err < 0){ - emsg = "I2C R/W fail!"; - goto err_common_set_uint8_attr_1; - } - buf[i] = update[i]; - } - return 0; - -err_common_set_uint8_attr_1: - if (show_e) { - SWPS_INFO("%s: %s :%s :%d :%d\n", - __func__, emsg, caller, err, i); - } - return ERR_TRANSVR_UPDATE_FAIL; -} - - -static int -_common_update_attr_id(struct transvr_obj_s *self, - int show_err){ - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_id, - self->eeprom_map_p->page_id, - self->eeprom_map_p->offset_id, - self->eeprom_map_p->length_id, - &(self->id), - "_common_update_attr_id", - show_err); -} - -static int -_common_update_attr_eeprom(struct transvr_obj_s *self, - int show_err){ - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_eeprom, - self->eeprom_map_p->page_eeprom, - self->eeprom_map_p->offset_eeprom, - self->eeprom_map_p->length_eeprom, - &(self->eeprom), - "_common_update_attr_eeprom", - show_err); -} - -static int -_common_update_attr_uppage(struct transvr_obj_s *self, - int show_err){ - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_uppage, - self->eeprom_map_p->page_uppage, - self->eeprom_map_p->offset_uppage, - self->eeprom_map_p->length_uppage, - &(self->eeprom), - "_common_update_attr_uppage", - show_err); -} - -static int -_common_update_attr_extended_id(struct transvr_obj_s *self, - int show_err){ - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_ext_id, - self->eeprom_map_p->page_ext_id, - self->eeprom_map_p->offset_ext_id, - self->eeprom_map_p->length_ext_id, - &(self->ext_id), - "_common_update_attr_extended_id", - show_err); -} - - -static int -_common_update_attr_connector(struct transvr_obj_s *self, - int show_err){ - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_connector, - self->eeprom_map_p->page_connector, - self->eeprom_map_p->offset_connector, - self->eeprom_map_p->length_connector, - &(self->connector), - "_common_update_attr_connector", - show_err); -} - - -static int -_common_update_attr_transvr_comp(struct transvr_obj_s *self, - int show_err){ - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_trancomp, - self->eeprom_map_p->page_trancomp, - self->eeprom_map_p->offset_trancomp, - self->eeprom_map_p->length_trancomp, - self->transvr_comp, - "_common_update_attr_transvr_comp", - show_err); -} - - -static int -_common_update_attr_transvr_comp_ext(struct transvr_obj_s *self, - int show_err){ - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_trancomp_ext, - self->eeprom_map_p->page_trancomp_ext, - self->eeprom_map_p->offset_trancomp_ext, - self->eeprom_map_p->length_trancomp_ext, - &(self->transvr_comp_ext), - "_common_update_attr_transvr_comp_ext", - show_err); -} - - -static int -_common_update_attr_vendor_name(struct transvr_obj_s *self, - int show_err){ - return _common_update_string_attr(self, - self->eeprom_map_p->addr_vendor_name, - self->eeprom_map_p->page_vendor_name, - self->eeprom_map_p->offset_vendor_name, - self->eeprom_map_p->length_vendor_name, - self->vendor_name, - "_common_update_attr_vendor_name", - show_err); -} - - -static int -_common_update_attr_vendor_pn(struct transvr_obj_s *self, - int show_err){ - return _common_update_string_attr(self, - self->eeprom_map_p->addr_vendor_pn, - self->eeprom_map_p->page_vendor_pn, - self->eeprom_map_p->offset_vendor_pn, - self->eeprom_map_p->length_vendor_pn, - self->vendor_pn, - "_common_update_attr_vendor_pn", - show_err); -} - - -static int -_common_update_attr_vendor_rev(struct transvr_obj_s *self, - int show_err){ - return _common_update_string_attr(self, - self->eeprom_map_p->addr_vendor_rev, - self->eeprom_map_p->page_vendor_rev, - self->eeprom_map_p->offset_vendor_rev, - self->eeprom_map_p->length_vendor_rev, - self->vendor_rev, - "_common_update_attr_vendor_rev", - show_err); -} - - -static int -_common_update_attr_vendor_sn(struct transvr_obj_s *self, - int show_err){ - return _common_update_string_attr(self, - self->eeprom_map_p->addr_vendor_sn, - self->eeprom_map_p->page_vendor_sn, - self->eeprom_map_p->offset_vendor_sn, - self->eeprom_map_p->length_vendor_sn, - self->vendor_sn, - "_common_update_attr_vendor_sn", - show_err); -} - - -static int -_common_update_attr_br(struct transvr_obj_s *self, - int show_err){ - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_br, - self->eeprom_map_p->page_br, - self->eeprom_map_p->offset_br, - self->eeprom_map_p->length_br, - &(self->br), - "_common_update_attr_br", - show_err); -} - - -static int -_common_update_attr_len_smf(struct transvr_obj_s *self, - int show_err){ - return _common_update_int_attr(self, - self->eeprom_map_p->addr_len_smf, - self->eeprom_map_p->page_len_smf, - self->eeprom_map_p->offset_len_smf, - self->eeprom_map_p->length_len_smf, - &(self->len_smf), - "_common_update_attr_len_smf", - show_err); -} - - -static int -_common_update_attr_len_om1(struct transvr_obj_s *self, - int show_err){ - return _common_update_int_attr(self, - self->eeprom_map_p->addr_len_om1, - self->eeprom_map_p->page_len_om1, - self->eeprom_map_p->offset_len_om1, - self->eeprom_map_p->length_len_om1, - &(self->len_om1), - "_common_update_attr_len_om1", - show_err); -} - -static int -_common_update_attr_len_om2(struct transvr_obj_s *self, - int show_err){ - return _common_update_int_attr(self, - self->eeprom_map_p->addr_len_om2, - self->eeprom_map_p->page_len_om2, - self->eeprom_map_p->offset_len_om2, - self->eeprom_map_p->length_len_om2, - &(self->len_om2), - "_common_update_attr_len_om2", - show_err); -} - -static int -_common_update_attr_len_om3(struct transvr_obj_s *self, - int show_err){ - return _common_update_int_attr(self, - self->eeprom_map_p->addr_len_om3, - self->eeprom_map_p->page_len_om3, - self->eeprom_map_p->offset_len_om3, - self->eeprom_map_p->length_len_om3, - &(self->len_om3), - "_common_update_attr_len_om3", - show_err); -} - - -static int -_common_update_attr_len_om4(struct transvr_obj_s *self, - int show_err){ - return _common_update_int_attr(self, - self->eeprom_map_p->addr_len_om4, - self->eeprom_map_p->page_len_om4, - self->eeprom_map_p->offset_len_om4, - self->eeprom_map_p->length_len_om4, - &(self->len_om4), - "_common_update_attr_len_om4", - show_err); -} - - -static int -_common_update_attr_option(struct transvr_obj_s *self, - int show_err){ - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_option, - self->eeprom_map_p->page_option, - self->eeprom_map_p->offset_option, - self->eeprom_map_p->length_option, - self->option, - "_common_update_attr_option", - show_err); -} - - -static int -_common_update_attr_comp_rev(struct transvr_obj_s *self, - int show_err){ - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_comp_rev, - self->eeprom_map_p->page_comp_rev, - self->eeprom_map_p->offset_comp_rev, - self->eeprom_map_p->length_comp_rev, - &(self->comp_rev), - "_common_update_attr_comp_rev", - show_err); -} - - -static int -_common_update_attr_diag_type(struct transvr_obj_s *self, - int show_err){ - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_diag_type, - self->eeprom_map_p->page_diag_type, - self->eeprom_map_p->offset_diag_type, - self->eeprom_map_p->length_diag_type, - &(self->diag_type), - "_common_update_attr_diag_type", - show_err); -} - - -static int -_common_update_attr_wavelength(struct transvr_obj_s *self, - int show_err){ - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_wavelength, - self->eeprom_map_p->page_wavelength, - self->eeprom_map_p->offset_wavelength, - self->eeprom_map_p->length_wavelength, - self->wavelength, - "_common_update_attr_wavelength", - show_err); -} - - -int -_common_get_option_value(struct transvr_obj_s *self, - int offset, - int bit_shift) { - /* SFP: - * - option[0] = A0h / 64 - * - option[1] = A0h / 65 - * QSFP: - * - option[0] = 00h / 193 - * - option[1] = 00h / 194 - * - option[2] = 00h / 195 - */ - return (self->option[offset] & (1 << bit_shift)); -} - - -static int -_sfp_update_attr_len_sm(struct transvr_obj_s *self, - int show_err){ - return _common_update_int_attr(self, - self->eeprom_map_p->addr_len_sm, - self->eeprom_map_p->page_len_sm, - self->eeprom_map_p->offset_len_sm, - self->eeprom_map_p->length_len_sm, - &(self->len_sm), - "_common_update_attr_len_sm", - show_err); -} - - -static int -_sfp_update_attr_rate_id(struct transvr_obj_s *self, - int show_err){ - return _common_update_int_attr(self, - self->eeprom_map_p->addr_rate_id, - self->eeprom_map_p->page_rate_id, - self->eeprom_map_p->offset_rate_id, - self->eeprom_map_p->length_rate_id, - &(self->rate_id), - "_sfp_update_attr_rate_id", - show_err); -} - - -static int -_sfp_update_attr_soft_rs0(struct transvr_obj_s *self, - int show_err){ - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_soft_rs0, - self->eeprom_map_p->page_soft_rs0, - self->eeprom_map_p->offset_soft_rs0, - self->eeprom_map_p->length_soft_rs0, - &(self->soft_rs0), - "_sfp_update_attr_soft_rs0", - show_err); -} - - -static int -_sfp_update_attr_soft_rs1(struct transvr_obj_s *self, - int show_err){ - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_soft_rs1, - self->eeprom_map_p->page_soft_rs1, - self->eeprom_map_p->offset_soft_rs1, - self->eeprom_map_p->length_soft_rs1, - &(self->soft_rs1), - "_sfp_update_attr_soft_rs1", - show_err); -} - - -int -_sfp_is_diag_support(struct transvr_obj_s *self){ - - uint8_t bit_mask = 0xC0; /* 1100 0000 */ - uint8_t en_val = 0x40; /* 0100 0000 */ - uint8_t checkval = (self->diag_type & bit_mask); - - if (checkval == en_val) { - return 1; - } - return 0; -} - - -static int -_sfp_update_attr_curr_temp(struct transvr_obj_s *self, - int show_err){ - - if (!(_sfp_is_diag_support(self))) { - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_temp, - self->eeprom_map_p->page_temp, - self->eeprom_map_p->offset_temp, - self->eeprom_map_p->length_temp, - self->curr_temp, - "_sfp_update_attr_curr_temp", - show_err); -} - - -static int -_sfp_update_attr_curr_voltage(struct transvr_obj_s *self, - int show_err){ - - if (!(_sfp_is_diag_support(self))) { - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_voltage, - self->eeprom_map_p->page_voltage, - self->eeprom_map_p->offset_voltage, - self->eeprom_map_p->length_voltage, - self->curr_voltage, - "_sfp_update_attr_curr_voltage", - show_err); -} - - -static int -_sfp_update_attr_curr_tx_bias(struct transvr_obj_s *self, - int show_err){ - - if (!(_sfp_is_diag_support(self))) { - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_tx_bias, - self->eeprom_map_p->page_tx_bias, - self->eeprom_map_p->offset_tx_bias, - self->eeprom_map_p->length_tx_bias, - self->curr_tx_bias, - "_sfp_update_attr_curr_tx_bias", - show_err); -} - - -static int -_sfp_update_attr_curr_tx_power(struct transvr_obj_s *self, - int show_err){ - - if (!(_sfp_is_diag_support(self))) { - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_tx_power, - self->eeprom_map_p->page_tx_power, - self->eeprom_map_p->offset_tx_power, - self->eeprom_map_p->length_tx_power, - self->curr_tx_power, - "_sfp_update_attr_curr_tx_power", - show_err); -} - - -static int -_sfp_update_attr_curr_rx_power(struct transvr_obj_s *self, - int show_err){ - - if (!(_sfp_is_diag_support(self))) { - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_rx_power, - self->eeprom_map_p->page_rx_power, - self->eeprom_map_p->offset_rx_power, - self->eeprom_map_p->length_rx_power, - self->curr_rx_power, - "_sfp_update_attr_curr_rx_power", - show_err); -} - - -static int -_sfp_update_attr_rx_em(struct transvr_obj_s *self, - int show_err){ - - if (!_is_transvr_support_ctle(self)) { - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_rx_em, - self->eeprom_map_p->page_rx_em, - self->eeprom_map_p->offset_rx_em, - self->eeprom_map_p->length_rx_em, - self->rx_em, - "_sfp_update_attr_rx_em", - show_err); -} - - -static int -_sfp_update_attr_tx_eq(struct transvr_obj_s *self, - int show_err){ - - if (!_is_transvr_support_ctle(self)) { - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_tx_eq, - self->eeprom_map_p->page_tx_eq, - self->eeprom_map_p->offset_tx_eq, - self->eeprom_map_p->length_tx_eq, - self->tx_eq, - "_sfp_update_attr_tx_eq", - show_err); -} - - -static int -_qsfp_update_attr_cdr(struct transvr_obj_s *self, - int show_err){ - if (self->type != TRANSVR_TYPE_QSFP_28){ - self->cdr = DEBUG_TRANSVR_HEX_VAL; - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_cdr, - self->eeprom_map_p->page_cdr, - self->eeprom_map_p->offset_cdr, - self->eeprom_map_p->length_cdr, - &(self->cdr), - "_common_update_attr_cdr", - show_err); -} - - -static int -_qsfg_update_attr_extbr(struct transvr_obj_s *self, - int show_err) { - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_extbr, - self->eeprom_map_p->page_extbr, - self->eeprom_map_p->offset_extbr, - self->eeprom_map_p->length_extbr, - &(self->extbr), - "_common_update_attr_extbr", - show_err); -} - - -static int -_qsfp_is_diag_support(struct transvr_obj_s *self, - int diag_type) { - /* Input Parm: diag_type - * => 1 : temperature - * => 2 : voltage - * => 3 : tx relate - * => 4 : rx relate - */ - uint8_t mask_b2 = 0x04; /* 0000 0100 */ - uint8_t mask_b3 = 0x08; /* 0000 1000 */ - - switch (diag_type) { - case 1: /* temperature */ - case 2: /* voltage */ - /* Direct access target, because of spec not defined */ - return 1; - case 3: - case 4: - /* [Note] - * Due to lot of transceiver vendor defined it not rigorously and - * consider of general support, we seem it as supported if there - * are bit-2 OR bit-3 defined by transceiver vendor. - */ - if ( ((self->diag_type & mask_b2) == mask_b2 ) || - ((self->diag_type & mask_b3) == mask_b3 ) ){ - return 1; - } - return 0; - default: - SWPS_INFO("%s: undefined diag_type:%d\n", - __func__, diag_type); - break; - } - return 0; -} - - -int -_qsfp_is_implement_tx_disable(struct transvr_obj_s *self) { - /* - * 00h / Byte-195 / Bit-4 - */ - int byte = 2; - int bit = 4; - return _common_get_option_value(self, byte, bit); -} - - -int -_qsfp_is_implement_tx_fault(struct transvr_obj_s *self) { - /* - * 00h / Byte-195 / Bit-3 - */ - int byte = 2; - int bit = 3; - return _common_get_option_value(self, byte, bit); -} - - -static int -_qsfp_update_attr_curr_temp(struct transvr_obj_s *self, - int show_err){ - int diag_type = 1; - - if (!(_qsfp_is_diag_support(self, diag_type))) { - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_temp, - self->eeprom_map_p->page_temp, - self->eeprom_map_p->offset_temp, - self->eeprom_map_p->length_temp, - self->curr_temp, - "_qsfp_update_attr_curr_temp", - show_err); -} - - -static int -_qsfp_update_attr_curr_voltage(struct transvr_obj_s *self, - int show_err){ - int diag_type = 2; - - if (!(_qsfp_is_diag_support(self, diag_type))) { - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_voltage, - self->eeprom_map_p->page_voltage, - self->eeprom_map_p->offset_voltage, - self->eeprom_map_p->length_voltage, - self->curr_voltage, - "_qsfp_update_attr_curr_voltage", - show_err); -} - - -static int -_qsfp_update_attr_curr_tx_bias(struct transvr_obj_s *self, - int show_err){ - int diag_type = 3; - - if (!(_qsfp_is_diag_support(self, diag_type))) { - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_tx_bias, - self->eeprom_map_p->page_tx_bias, - self->eeprom_map_p->offset_tx_bias, - self->eeprom_map_p->length_tx_bias, - self->curr_tx_bias, - "_qsfp_update_attr_curr_tx_bias", - show_err); -} - - -static int -_qsfp_update_attr_curr_tx_power(struct transvr_obj_s *self, - int show_err){ - int diag_type = 3; - - if (!(_qsfp_is_diag_support(self, diag_type))) { - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_tx_power, - self->eeprom_map_p->page_tx_power, - self->eeprom_map_p->offset_tx_power, - self->eeprom_map_p->length_tx_power, - self->curr_tx_power, - "_qsfp_update_attr_curr_tx_power", - show_err); -} - - -static int -_qsfp_update_attr_curr_rx_power(struct transvr_obj_s *self, - int show_err){ - int diag_type = 4; - - if (!(_qsfp_is_diag_support(self, diag_type))) { - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_rx_power, - self->eeprom_map_p->page_rx_power, - self->eeprom_map_p->offset_rx_power, - self->eeprom_map_p->length_rx_power, - self->curr_rx_power, - "_qsfp_update_attr_curr_rx_power", - show_err); -} - - -static int -_qsfp_update_attr_soft_rx_los(struct transvr_obj_s *self, - int show_err){ - - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_rx_los, - self->eeprom_map_p->page_rx_los, - self->eeprom_map_p->offset_rx_los, - self->eeprom_map_p->length_rx_los, - &(self->rx_los), - "_qsfp_update_attr_soft_rx_los", - show_err); -} - - -static int -_qsfp_update_attr_soft_tx_disable(struct transvr_obj_s *self, - int show_err){ - - if (!_qsfp_is_implement_tx_disable(self)) { - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_tx_disable, - self->eeprom_map_p->page_tx_disable, - self->eeprom_map_p->offset_tx_disable, - self->eeprom_map_p->length_tx_disable, - &(self->tx_disable), - "_qsfp_update_attr_soft_tx_disable", - show_err); -} - - -static int -_qsfp_update_attr_soft_tx_fault(struct transvr_obj_s *self, - int show_err){ - - if (!_qsfp_is_implement_tx_fault(self)) { - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_tx_fault, - self->eeprom_map_p->page_tx_fault, - self->eeprom_map_p->offset_tx_fault, - self->eeprom_map_p->length_tx_fault, - &(self->tx_fault), - "_qsfp_update_attr_soft_tx_fault", - show_err); -} - - -static int -_qsfp_update_attr_tx_eq(struct transvr_obj_s *self, - int show_err){ - - if (!_is_transvr_support_ctle(self)) { - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_tx_eq, - self->eeprom_map_p->page_tx_eq, - self->eeprom_map_p->offset_tx_eq, - self->eeprom_map_p->length_tx_eq, - self->tx_eq, - "_qsfp_update_attr_tx_eq", - show_err); -} - - -static int -_qsfp_update_attr_rx_am(struct transvr_obj_s *self, - int show_err){ - - if (!_is_transvr_support_ctle(self)) { - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_rx_am, - self->eeprom_map_p->page_rx_am, - self->eeprom_map_p->offset_rx_am, - self->eeprom_map_p->length_rx_am, - self->rx_am, - "_qsfp_update_attr_rx_am", - show_err); -} - - -static int -_qsfp_update_attr_rx_em(struct transvr_obj_s *self, - int show_err){ - - if (!_is_transvr_support_ctle(self)) { - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_rx_em, - self->eeprom_map_p->page_rx_em, - self->eeprom_map_p->offset_rx_em, - self->eeprom_map_p->length_rx_em, - self->rx_em, - "_qsfp_update_attr_rx_em", - show_err); -} - - -int -_common_update_attr_all(struct transvr_obj_s *self, - int show_err){ - - char *err_str = "err"; - - if (_common_update_attr_id(self, show_err) < 0) { - err_str = "_common_update_attr_id"; - goto err_common_update_attr_all; - } - if (_common_update_attr_extended_id(self, show_err) < 0) { - err_str = "_common_update_attr_extended_id"; - goto err_common_update_attr_all; - } - if (_common_update_attr_connector(self, show_err) < 0) { - err_str = "_common_update_attr_connector"; - goto err_common_update_attr_all; - } - if (_common_update_attr_transvr_comp(self, show_err) < 0) { - err_str = "_common_update_attr_transvr_comp"; - goto err_common_update_attr_all; - } - if (_common_update_attr_transvr_comp_ext(self, show_err) < 0) { - err_str = "_common_update_attr_transvr_comp_ext"; - goto err_common_update_attr_all; - } - if (_common_update_attr_vendor_name(self, show_err) < 0) { - err_str = "_common_update_attr_vendor_name"; - goto err_common_update_attr_all; - } - if (_common_update_attr_vendor_pn(self, show_err) < 0) { - err_str = "_common_update_attr_vendor_pn"; - goto err_common_update_attr_all; - } - if (_common_update_attr_vendor_rev(self, show_err) < 0) { - err_str = "_common_update_attr_vendor_rev"; - goto err_common_update_attr_all; - } - if (_common_update_attr_vendor_sn(self, show_err) < 0) { - err_str = "_common_update_attr_vendor_sn"; - goto err_common_update_attr_all; - } - if (_common_update_attr_br(self, show_err) < 0) { - err_str = "_common_update_attr_br"; - goto err_common_update_attr_all; - } - if (_common_update_attr_len_smf(self, show_err) < 0) { - err_str = "_common_update_attr_len_smf"; - goto err_common_update_attr_all; - } - if (_common_update_attr_len_om1(self, show_err) < 0) { - err_str = "_common_update_attr_len_om1"; - goto err_common_update_attr_all; - } - if (_common_update_attr_len_om2(self, show_err) < 0) { - err_str = "_common_update_attr_len_om2"; - goto err_common_update_attr_all; - } - if (_common_update_attr_len_om3(self, show_err) < 0) { - err_str = "_common_update_attr_len_om3"; - goto err_common_update_attr_all; - } - if (_common_update_attr_len_om4(self, show_err) < 0) { - err_str = "_common_update_attr_len_om4"; - goto err_common_update_attr_all; - } - if (_common_update_attr_option(self, show_err) < 0) { - err_str = "_common_update_attr_option"; - goto err_common_update_attr_all; - } - if (_common_update_attr_comp_rev(self, show_err) < 0) { - err_str = "_common_update_attr_comp_rev"; - goto err_common_update_attr_all; - } - if (_common_update_attr_diag_type(self, show_err) < 0) { - err_str = "_common_update_attr_diag_type"; - goto err_common_update_attr_all; - } - if (_common_update_attr_wavelength(self, show_err) < 0) { - err_str = "_common_update_attr_wavelength"; - goto err_common_update_attr_all; - } - if (_common_update_attr_eeprom(self, show_err) < 0) { - err_str = "_common_update_attr_eeprom"; - goto err_common_update_attr_all; - } - return 0; - -err_common_update_attr_all: - if (show_err){ - SWPS_INFO("%s: fail at:%s :%s\n", __func__, err_str, self->swp_name); - } - return -1; -} - - -int -_sfp_update_attr_all(struct transvr_obj_s *self, - int show_err){ - - char *err_str = DEBUG_TRANSVR_STR_VAL; - - if (_common_update_attr_all(self, show_err) < 0){ - err_str = "_common_update_attr_all"; - goto err_sfp_update_attr_all; - } - if (_sfp_update_attr_len_sm(self, show_err) < 0) { - err_str = "_sfp_update_attr_len_sm"; - goto err_sfp_update_attr_all; - } - if (_sfp_update_attr_rate_id(self, show_err) < 0) { - err_str = "_sfp_update_attr_rate_id"; - goto err_sfp_update_attr_all; - } - if ((self->rate_id) > 0) { - if (_sfp_update_attr_soft_rs0(self, show_err) < 0) { - err_str = "_sfp_update_attr_soft_rs0"; - goto err_sfp_update_attr_all; - } - if (_sfp_update_attr_soft_rs1(self, show_err) < 0) { - err_str = "_sfp_update_attr_soft_rs1"; - goto err_sfp_update_attr_all; - } - } - return 0; - -err_sfp_update_attr_all: - if (show_err){ - SWPS_INFO("%s: fail at:%s :%s\n", __func__, err_str, self->swp_name); - } - return -1; -} - - -int -_qsfp_update_attr_all(struct transvr_obj_s *self, - int show_err){ - - char *err_str = DEBUG_TRANSVR_STR_VAL; - - if (_common_update_attr_all(self, show_err) < 0){ - err_str = "_common_update_attr_all"; - goto err_qsfp_update_attr_all; - } - if (_qsfg_update_attr_extbr(self, show_err) < 0) { - err_str = "_qsfg_update_attr_extbr"; - goto err_qsfp_update_attr_all; - } - if (self->type == TRANSVR_TYPE_QSFP_28) { - if (_qsfp_update_attr_cdr(self, 1) < 0) { - err_str = "_qsfp_update_attr_cdr"; - goto err_qsfp_update_attr_all; - } - } - return 0; - -err_qsfp_update_attr_all: - if (show_err){ - SWPS_INFO("%s: fail at:%s :%s\n", __func__, err_str, self->swp_name); - } - return -1; -} - - -/* ========== Object functions for common type ========== - */ -int -_common_count_temp(uint8_t high_byte, - uint8_t low_byte, - char *buf_p) { - int sign = 0; - int high = 0; - int low = 0; - int lmax = 8; - - /* Count high */ - sign = get_bit(high_byte,7); - SWP_BIT_CLEAR(high_byte, 7); - high = (int)high_byte; - if (sign == 1) { - high = 0 - high; - } - /* Count low */ - low = (get_bit(low_byte, 7) * 500); - low += (get_bit(low_byte, 6) * 250); - low += (get_bit(low_byte, 5) * 125); - low += (get_bit(low_byte, 4) * 62); - low = (low / 100); - /* Integrate High and Low */ - return snprintf(buf_p, lmax, "%d.%d\n", high, low); -} - - -int -_common_count_voltage(uint8_t high_byte, - uint8_t low_byte, - char *buf_p) { - /* [Note]: - * Internally measured transceiver supply voltage. Represented - * as a 16 bit unsigned integer with the voltage defined as the - * full 16 bit value (0-65535) with LSB equal to 100 uVolt, - * yielding a total range of 0 to +6.55 Volts. Practical - * considerations to be defined by transceiver manufacturer will - * tend to limit the actual bounds of the supply voltage measurement. - * Accuracy is vendor specific but must be better than 3% of the - * manufacturer's nominal value over specified operating temperature - * and voltage. Note that in some transceivers, transmitter supply - * voltage and receiver supply voltage are isolated. In that case, - * only one supply is monitored. Refer to the device specification - * for more detail. - */ - int total = 0; - int lmax = 8; - int val_i = 0; - int val_f = 0; - /* unit: 100 uV (1mV=1000uV) */ - total = transform_word_to_int(high_byte, low_byte); - val_i = ((total/10) / 1000); - val_f = ((total/10) - (val_i*1000)); - /* Return Unit: 1 Volt */ - return snprintf(buf_p, lmax, "%d.%03d\n", val_i, val_f); -} - - -int -_common_count_tx_bias(uint8_t high_byte, - uint8_t low_byte, - char *buf_p) { - /* [Note] - * Measured TX bias current in uA. Represented as a 16 bit unsigned - * integer with the current defined as the full 16 bit value (0-65535) - * with LSB equal to 2 uA, yielding a total range of 0 to 131 mA. - * Accuracy is vendor specific but must be better than 10% of the - * manufacturer's nominal value over specified operating temperature - * and voltage. - */ - int total = 0; - int lmax = 8; - int val_i = 0; - int val_f = 0; - /* unit: 2 uA (1mA=1000uA) */ - total = transform_word_to_int(high_byte, low_byte); - val_i = ((total*2) / 1000); - val_f = (((total*2) - (val_i*1000)) / 100); - /* Return Unit: 1 mA */ - return snprintf(buf_p, lmax, "%d.%01d\n", val_i, val_f); -} - - -int -_common_count_tx_power(uint8_t high_byte, - uint8_t low_byte, - char *buf_p) { - /* [Note] - * Measured TX output power in mW. Represented as a 16 bit unsigned - * integer with the power defined as the full 16 bit value (0-65535) - * with LSB equal to 0.1 uW, yielding a total range of 0 to 6.5535 mW - * (~ -40 to +8.2 dBm). Data is assumed to be based on measurement of - * laser monitor photodiode current. It is factory calibrated to absolute - * units using the most representative fiber output type. Accuracy is - * vendor specific but must be better than 3dB over specified temperature - * and voltage. Data is not valid when the transmitter is disabled. - */ - int total = 0; - int lmax = 8; - int val_i = 0; - int val_f = 0; - /* unit: 0.1 uW (1mW=1000uW) */ - total = transform_word_to_int(high_byte, low_byte); - val_i = ((total/10) / 1000); - val_f = ((total/10) - (val_i*1000)); - /* Return Unit: 1 mW */ - return snprintf(buf_p, lmax, "%d.%03d\n", val_i, val_f); -} - - -int -_common_count_rx_power(uint8_t high_byte, - uint8_t low_byte, - char *buf_p) { - /* [Note] - * Measured RX received optical power in mW. Value can represent either - * average received power or OMA depending upon how bit 3 of byte 92 (A0h) - * is set. Represented as a 16 bit unsigned integer with the power defined - * as the full 16 bit value (0-65535) with LSB equal to 0.1 uW, yielding a - * total range of 0 to 6.5535 mW (~ -40 to +8.2 dBm). Absolute accuracy is - * dependent upon the exact optical wavelength. For the vendor specified - * wavelength, accuracy shall be better than 3dB over specified temperature - * and voltage. - */ - int total = 0; - int lmax = 8; - int val_i = 0; - int val_f = 0; - /* unit: 0.1 uW (1mW=1000uW) */ - total = transform_word_to_int(high_byte, low_byte); - val_i = ((total/10) / 1000); - val_f = ((total/10) - (val_i*1000)); - /* Return Unit: 1 mW */ - return snprintf(buf_p, lmax, "%d.%03d\n", val_i, val_f); -} - - -int -_common_count_wavelength(struct transvr_obj_s *self, - uint8_t high_byte, - uint8_t low_byte) { - /* [Note] - * SFP : uint 1 um. - * QSFP: unit 0.05 um. - */ - int total = 0; - - total = transform_word_to_int(high_byte, low_byte); - switch (self->type) { - case TRANSVR_TYPE_SFP: - return total; - - case TRANSVR_TYPE_QSFP: - case TRANSVR_TYPE_QSFP_PLUS: - case TRANSVR_TYPE_QSFP_28: - return (total/20); - - default: - break; - } - return ERR_TRANSVR_UNDEFINED; -} - - -int -common_get_id(struct transvr_obj_s *self){ - - int err_code = _check_by_mode(self, - &_common_update_attr_id, - "common_get_id"); - if (err_code < 0){ - return err_code; - } - /* Transform to INT to show error case */ - return (int)self->id; -} - -int -common_get_eeprom(struct transvr_obj_s *self, char *buf){ - - int err = DEBUG_TRANSVR_INT_VAL; - - err = _check_by_mode(self, &_common_update_attr_eeprom, - "common_get_eeprom"); - if (err < 0){ - return snprintf(buf, LEN_TRANSVR_M_STR, "%d\n", err); - } - memset(buf, 0, self->eeprom_map_p->length_eeprom+1); - memcpy(buf, self->eeprom, self->eeprom_map_p->length_eeprom); - *(buf+self->eeprom_map_p->length_eeprom) = '\n'; - return self->eeprom_map_p->length_eeprom+1; -} - -int -common_get_uppage(struct transvr_obj_s *self, char *buf){ - - int err = DEBUG_TRANSVR_INT_VAL; - - if (self->state == STATE_TRANSVR_CONNECTED && - self->mode == TRANSVR_MODE_POLLING && - TRANSVR_INFO_CACHE_ENABLE) { - memset(buf, 0, self->eeprom_map_p->length_uppage+1); - memcpy(buf, self->eeprom, self->eeprom_map_p->length_uppage); - *(buf+self->eeprom_map_p->length_uppage) = '\n'; - return self->eeprom_map_p->length_uppage+1; - } - err = _check_by_mode(self, &_common_update_attr_uppage, - "common_get_uppage"); - if (err < 0){ - return snprintf(buf, LEN_TRANSVR_M_STR, "%d\n", err); - } - memset(buf, 0, self->eeprom_map_p->length_uppage+1); - memcpy(buf, self->eeprom, self->eeprom_map_p->length_uppage); - *(buf+self->eeprom_map_p->length_uppage) = '\n'; - return self->eeprom_map_p->length_uppage+1; -} - - -int -common_get_ext_id(struct transvr_obj_s *self){ - - int err_code = _check_by_mode(self, - &_common_update_attr_extended_id, - "common_get_ext_id"); - if (err_code < 0){ - return err_code; - } - /* Transform to INT to show error case */ - return (int)self->ext_id; -} - - -int -common_get_connector(struct transvr_obj_s *self){ - - int err_code = _check_by_mode(self, - &_common_update_attr_connector, - "common_get_connector"); - if (err_code < 0){ - return err_code; - } - /* Transform to INT to show error case */ - return (int)self->connector; -} - - -int -common_get_vendor_name(struct transvr_obj_s *self, char *buf){ - - int err = DEBUG_TRANSVR_INT_VAL; - - if (self->state == STATE_TRANSVR_CONNECTED && - self->mode == TRANSVR_MODE_POLLING && - TRANSVR_INFO_CACHE_ENABLE) { - return snprintf(buf, LEN_TRANSVR_M_STR, "%s\n", self->vendor_name); - } - err = _check_by_mode(self, - &_common_update_attr_vendor_name, - "common_get_vendor_name"); - memset(buf, 0, LEN_TRANSVR_M_STR); - if (err < 0){ - return snprintf(buf, LEN_TRANSVR_M_STR, "%d\n", err); - } - return snprintf(buf, LEN_TRANSVR_M_STR, "%s\n", self->vendor_name); -} - - -int -common_get_vendor_pn(struct transvr_obj_s *self, char *buf) { - - int err = DEBUG_TRANSVR_INT_VAL; - - if (self->state == STATE_TRANSVR_CONNECTED && - self->mode == TRANSVR_MODE_POLLING && - TRANSVR_INFO_CACHE_ENABLE) { - return snprintf(buf, LEN_TRANSVR_M_STR, "%s\n", self->vendor_pn); - } - err = _check_by_mode(self, - &_common_update_attr_vendor_pn, - "common_get_vendor_pn"); - memset(buf, 0, LEN_TRANSVR_M_STR); - if (err < 0){ - return snprintf(buf, LEN_TRANSVR_M_STR, "%d\n", err); - } - return snprintf(buf, LEN_TRANSVR_M_STR, "%s\n", self->vendor_pn); -} - - -int -common_get_vendor_rev(struct transvr_obj_s *self, char *buf) { - - int err = DEBUG_TRANSVR_INT_VAL; - - if (self->state == STATE_TRANSVR_CONNECTED && - self->mode == TRANSVR_MODE_POLLING && - TRANSVR_INFO_CACHE_ENABLE) { - return snprintf(buf, LEN_TRANSVR_M_STR, "%s\n", self->vendor_rev); - } - err = _check_by_mode(self, - &_common_update_attr_vendor_rev, - "common_get_vendor_rev"); - memset(buf, 0, LEN_TRANSVR_M_STR); - if (err < 0){ - return snprintf(buf, LEN_TRANSVR_M_STR, "%d\n", err); - } - return snprintf(buf, LEN_TRANSVR_M_STR, "%s\n", self->vendor_rev); -} - - -int -common_get_vendor_sn(struct transvr_obj_s *self, char *buf) { - - int err = DEBUG_TRANSVR_INT_VAL; - - if (self->state == STATE_TRANSVR_CONNECTED && - self->mode == TRANSVR_MODE_POLLING && - TRANSVR_INFO_CACHE_ENABLE) { - return snprintf(buf, LEN_TRANSVR_M_STR, "%s\n", self->vendor_sn); - } - err = _check_by_mode(self, - &_common_update_attr_vendor_sn, - "common_get_vendor_sn"); - memset(buf, 0, LEN_TRANSVR_M_STR); - if (err < 0){ - return snprintf(buf, LEN_TRANSVR_M_STR, "%d\n", err); - } - return snprintf(buf, LEN_TRANSVR_M_STR, "%s\n", self->vendor_sn); -} - - -int -common_get_br(struct transvr_obj_s *self){ - - int err = DEBUG_TRANSVR_INT_VAL; - - if (self->state == STATE_TRANSVR_CONNECTED && - self->mode == TRANSVR_MODE_POLLING && - TRANSVR_INFO_CACHE_ENABLE) { - return (int)self->br; - } - err = _check_by_mode(self, - &_common_update_attr_br, - "common_get_br"); - if (err < 0){ - return err; - } - /* Transform to INT to show error case */ - return (int)self->br; -} - - -int -common_get_len_smf(struct transvr_obj_s *self){ - - int err = DEBUG_TRANSVR_INT_VAL; - - if (self->state == STATE_TRANSVR_CONNECTED && - self->mode == TRANSVR_MODE_POLLING && - TRANSVR_INFO_CACHE_ENABLE) { - return self->len_smf; - } - err = _check_by_mode(self, - &_common_update_attr_len_smf, - "common_get_len_smf"); - if (err < 0){ - return err; - } - return self->len_smf; -} - - -int -common_get_len_om1(struct transvr_obj_s *self){ - - int err = DEBUG_TRANSVR_INT_VAL; - - if (self->state == STATE_TRANSVR_CONNECTED && - self->mode == TRANSVR_MODE_POLLING && - TRANSVR_INFO_CACHE_ENABLE) { - return self->len_om1; - } - err = _check_by_mode(self, - &_common_update_attr_len_om1, - "common_get_len_om1"); - if (err < 0){ - return err; - } - return self->len_om1; -} - - -int -common_get_len_om2(struct transvr_obj_s *self){ - - int err = DEBUG_TRANSVR_INT_VAL; - - if (self->state == STATE_TRANSVR_CONNECTED && - self->mode == TRANSVR_MODE_POLLING && - TRANSVR_INFO_CACHE_ENABLE) { - return self->len_om2; - } - - err = _check_by_mode(self, - &_common_update_attr_len_om2, - "common_get_len_om2"); - if (err < 0){ - return err; - } - return self->len_om2; -} - - -int -common_get_len_om3(struct transvr_obj_s *self){ - - int err = DEBUG_TRANSVR_INT_VAL; - - if (self->state == STATE_TRANSVR_CONNECTED && - self->mode == TRANSVR_MODE_POLLING && - TRANSVR_INFO_CACHE_ENABLE) { - return self->len_om3; - } - - err = _check_by_mode(self, - &_common_update_attr_len_om3, - "common_get_len_om3"); - if (err < 0){ - return err; - } - return self->len_om3; -} - - -int -common_get_len_om4(struct transvr_obj_s *self){ - - int err = DEBUG_TRANSVR_INT_VAL; - - if (self->state == STATE_TRANSVR_CONNECTED && - self->mode == TRANSVR_MODE_POLLING && - TRANSVR_INFO_CACHE_ENABLE) { - return self->len_om4; - } - err = _check_by_mode(self, - &_common_update_attr_len_om4, - "common_get_len_om4"); - if (err < 0){ - return err; - } - return self->len_om4; -} - - -int -common_get_comp_extended(struct transvr_obj_s *self){ - - int err_code = _check_by_mode(self, - &_common_update_attr_transvr_comp_ext, - "common_get_comp_extended"); - if (err_code < 0){ - return err_code; - } - return self->transvr_comp_ext; -} - - -int -common_get_comp_rev(struct transvr_obj_s *self){ - - int err_code = _check_by_mode(self, - &_common_update_attr_comp_rev, - "common_get_comp_rev"); - if (err_code < 0){ - return err_code; - } - return self->comp_rev; -} - - -int -common_get_info(struct transvr_obj_s *self){ - - if (self->state != STATE_TRANSVR_CONNECTED) { - return self->state; - } - return self->info; -} - - -int -_common_get_if_lane(struct transvr_obj_s *self, - char *result){ - int i = 0; - int tmp_val = 0; - char tmp_str[LEN_TRANSVR_M_STR] = DEBUG_TRANSVR_STR_VAL; - - memset(result, 0, LEN_TRANSVR_M_STR); - - for (i=0; ilane_id); i++) { - tmp_val = self->lane_id[i]; - if (tmp_val < 1) { - break; - } - memset(tmp_str, 0, LEN_TRANSVR_M_STR); - if (i == 0) { - snprintf(tmp_str, LEN_TRANSVR_M_STR, "%d", tmp_val); - } else { - snprintf(tmp_str, LEN_TRANSVR_M_STR, ",%d", tmp_val); - } - strncat(result, tmp_str, LEN_TRANSVR_M_STR); - } - if (i == 0) { - return EVENT_TRANSVR_TASK_FAIL; - } - return 0; -} - - -int -common_get_if_lane(struct transvr_obj_s *self, - char *buf_p){ - - char tmp_str[LEN_TRANSVR_M_STR] = DEBUG_TRANSVR_STR_VAL; - - if (self->ioexp_obj_p->state != STATE_IOEXP_NORMAL) { - return snprintf(buf_p, LEN_TRANSVR_M_STR, "%d\n", ERR_TRANSVR_ABNORMAL); - } - if (_common_get_if_lane(self, tmp_str) < 0) { - return snprintf(buf_p, LEN_TRANSVR_M_STR, "%d\n" ,ERR_TRANSVR_ABNORMAL); - } - return snprintf(buf_p, LEN_TRANSVR_M_STR, "%s\n" ,tmp_str); -} - - -int -sfp_get_len_sm(struct transvr_obj_s *self){ - - int err_code = _check_by_mode(self, - &_sfp_update_attr_len_sm, - "sfp_get_len_sm"); - if (err_code < 0){ - return err_code; - } - return self->len_sm; -} - - -int -sfp_get_rate_id(struct transvr_obj_s *self){ - - int err_code = _check_by_mode(self, - &_sfp_update_attr_rate_id, - "sfp_get_rate_id"); - if (err_code < 0){ - return err_code; - } - return self->rate_id; -} - - -int -sfp_get_soft_rs0(struct transvr_obj_s *self){ - /* Note: - * SFP Soft Rate_Select Select [aka. "RS(0)"] address - * A2h, offset: 110, bit 3 (begin form 0) - */ - int err_code = DEBUG_TRANSVR_INT_VAL; - int bit_shift = 3; - uint8_t result = 0x00; - uint8_t bitmask = (1 << bit_shift); - - /* Check rate identifier is supported */ - err_code = self->get_rate_id(self); - if (err_code <= 0) { - return ERR_TRANSVR_NOTSUPPORT; - } - /* Update and check */ - err_code = _check_by_mode(self, - &_sfp_update_attr_soft_rs0, - "sfp_get_soft_rs0"); - if (err_code <0){ - return err_code; - } - result = (self->soft_rs0 & bitmask); - if (result == bitmask) { - return 1; - } - if (result == 0) { - return 0; - } - return ERR_TRANSVR_UNEXCPT; -} - - -int -sfp_get_soft_rs1(struct transvr_obj_s *self){ - /* Note: - * SFP Soft RS(1) Select address - * A2h, offset: 118, bit 3 (begin form 0) - */ - int err_code = DEBUG_TRANSVR_INT_VAL; - int bit_shift = 3; - uint8_t result = 0x00; - uint8_t bitmask = (1 << bit_shift); - - /* Check rate identifier is supported */ - err_code = self->get_rate_id(self); - if (err_code <= 0) { - return ERR_TRANSVR_NOTSUPPORT; - } - /* Update and check */ - err_code = _check_by_mode(self, - &_sfp_update_attr_soft_rs1, - "sfp_get_soft_rs1"); - if (err_code <0){ - return err_code; - } - result = (self->soft_rs1 & bitmask); - if (result == bitmask) { - return 1; - } - if (result == 0) { - return 0; - } - return ERR_TRANSVR_UNEXCPT; -} - - -int -sfp_get_transvr_temp(struct transvr_obj_s *self, - char *buf_p) { - - int lmax = 8; - int err_code = DEBUG_TRANSVR_INT_VAL; - - err_code = _check_by_mode(self, - &_sfp_update_attr_curr_temp, - "sfp_get_transvr_temp"); - if (err_code < 0) { - return snprintf(buf_p, lmax, "%d\n", err_code); - } - if ((self->curr_temp[0]) == DEBUG_TRANSVR_HEX_VAL) { - return snprintf(buf_p, lmax, "%d\n", ERR_TRANSVR_UPDATE_FAIL); - } - return _common_count_temp(self->curr_temp[0], - self->curr_temp[1], - buf_p); -} - - -int -sfp_get_transvr_voltage(struct transvr_obj_s *self, - char *buf_p) { - - int lmax = 8; - int err_code = DEBUG_TRANSVR_INT_VAL; - - err_code = _check_by_mode(self, - &_sfp_update_attr_curr_voltage, - "sfp_get_transvr_voltage"); - if (err_code < 0) { - return snprintf(buf_p, lmax, "%d\n", err_code); - } - if ((self->curr_voltage[0]) == DEBUG_TRANSVR_HEX_VAL) { - return snprintf(buf_p, lmax, "%d\n", ERR_TRANSVR_UPDATE_FAIL); - } - /* Return Unit: 1 Volt */ - return _common_count_voltage(self->curr_voltage[0], - self->curr_voltage[1], - buf_p); -} - - -int -sfp_get_transvr_tx_bias(struct transvr_obj_s *self, - char *buf_p) { - - int lmax = 8; - int err_code = DEBUG_TRANSVR_INT_VAL; - - err_code = _check_by_mode(self, - &_sfp_update_attr_curr_tx_bias, - "sfp_get_transvr_tx_bias"); - if (err_code < 0) { - return snprintf(buf_p, lmax, "%d\n", err_code); - } - if ((self->curr_tx_bias[0]) == DEBUG_TRANSVR_HEX_VAL) { - return snprintf(buf_p, lmax, "%d\n", ERR_TRANSVR_UPDATE_FAIL); - } - /* Return Unit: 1 mA */ - return _common_count_tx_bias(self->curr_tx_bias[0], - self->curr_tx_bias[1], - buf_p); -} - - -int -sfp_get_transvr_tx_power(struct transvr_obj_s *self, - char *buf_p) { - - int lmax = 8; - int err_code = DEBUG_TRANSVR_INT_VAL; - - err_code = _check_by_mode(self, - &_sfp_update_attr_curr_tx_power, - "sfp_get_transvr_tx_power"); - if (err_code < 0) { - return snprintf(buf_p, lmax, "%d\n", err_code); - } - if ((self->curr_tx_bias[0]) == DEBUG_TRANSVR_HEX_VAL) { - return snprintf(buf_p, lmax, "%d\n", ERR_TRANSVR_UPDATE_FAIL); - } - /* Return Unit: 1 mW */ - return _common_count_tx_power(self->curr_tx_power[0], - self->curr_tx_power[1], - buf_p); -} - - -int -sfp_get_transvr_rx_power(struct transvr_obj_s *self, - char *buf_p) { - - int lmax = 8; - int err_code = DEBUG_TRANSVR_INT_VAL; - - err_code = _check_by_mode(self, - &_sfp_update_attr_curr_rx_power, - "sfp_get_transvr_rx_power"); - if (err_code < 0) { - return snprintf(buf_p, lmax, "%d\n", err_code); - } - if ((self->curr_tx_bias[0]) == DEBUG_TRANSVR_HEX_VAL) { - return snprintf(buf_p, lmax, "%d\n", ERR_TRANSVR_UPDATE_FAIL); - } - /* Return Unit: 1 mW */ - return _common_count_rx_power(self->curr_rx_power[0], - self->curr_rx_power[0], - buf_p); -} - - -int -sfp_get_transvr_rx_em(struct transvr_obj_s *self, - char *buf_p) { - - int limt = 8; - int err = DEBUG_TRANSVR_INT_VAL; - - err = _check_by_mode(self, - &_sfp_update_attr_rx_em, - "sfp_get_transvr_rx_em"); - if (err < 0) { - return snprintf(buf_p, limt, "%d\n", err); - } - if ((self->tx_eq[0]) == DEBUG_TRANSVR_HEX_VAL) { - return snprintf(buf_p, limt, "%d\n", ERR_TRANSVR_UPDATE_FAIL); - } - return snprintf(buf_p, limt, "0x%02x\n", self->rx_em[0]); -} - - -int -sfp_get_transvr_tx_eq(struct transvr_obj_s *self, - char *buf_p) { - - int limt = 8; - int err = DEBUG_TRANSVR_INT_VAL; - - err = _check_by_mode(self, - &_sfp_update_attr_tx_eq, - "sfp_get_transvr_tx_eq"); - if (err < 0) { - return snprintf(buf_p, limt, "%d\n", err); - } - if ((self->tx_eq[0]) == DEBUG_TRANSVR_HEX_VAL) { - return snprintf(buf_p, limt, "%d\n", ERR_TRANSVR_UPDATE_FAIL); - } - return snprintf(buf_p, limt, "0x%02x\n", self->tx_eq[0]); -} - - -int -_sfp_get_comp_extended(struct transvr_obj_s *self) { - /* Address: A0h / 36 - * Reference: SFF-8024 TABLE 4-4 - */ - if ((self->state == STATE_TRANSVR_CONNECTED) || - (self->state == STATE_TRANSVR_INIT) ) { - return (int)(self->transvr_comp_ext); - } - return ERR_TRANSVR_ABNORMAL; -} - - -int -__sfp_get_comp_attr(struct transvr_obj_s *self, - int array_offset) { - /* SFP Specification Compliance: A0h / 3-10 - * transvr_comp[0-7] = 3 - 10 - */ - if ((self->state == STATE_TRANSVR_CONNECTED) || - (self->state == STATE_TRANSVR_INIT) ) { - return (int)(self->transvr_comp[array_offset]); - } - return ERR_TRANSVR_ABNORMAL; -} - - -int -_sfp_get_comp_10g_eth_comp(struct transvr_obj_s *self) { - /* transvr_comp[0] = address A0h / 3 - * - * 3 7: 10G Base-ER - * 3 6: 10GBASE-LRM - * 3 5: 10GBASE-LR - * 3 4: 10GBASE-SR - */ - int bitmask = 0xf0; /* 11110000 */ - return (__sfp_get_comp_attr(self, 0) & bitmask); -} - - -int -_sfp_get_comp_1g_eth_comp(struct transvr_obj_s *self) { - /* transvr_comp[3] = address A0h / 6 - * - * 6 7: BASE-PX *3 - * 6 6: BASE-BX10 *3 - * 6 5: 100BASE-FX - * 6 4: 100BASE-LX/LX10 - * 6 3: 1000BASE-T - * 6 2: 1000BASE-CX - * 6 1: 1000BASE-LX *3 - * 6 0: 1000BASE-SX - */ - return __sfp_get_comp_attr(self, 3); -} - - -int -_sfp_get_cable_tech(struct transvr_obj_s *self) { - /* transvr_comp[5] = address A0h / 8 - * - * 8 3: Active Cable *8 - * 8 2: Passive Cable *8 - */ - int bitmask = 0x0c; /* 00001100 */ - return (__sfp_get_comp_attr(self, 5) & bitmask); -} - - -int -sfp_get_comp_eth_1(struct transvr_obj_s *self){ - - int err_code = _check_by_mode(self, - &_common_update_attr_transvr_comp, - "sfp_get_comp_eth_1"); - if (err_code < 0){ - return err_code; - } - return _sfp_get_comp_1g_eth_comp(self); -} - - -int -sfp_get_comp_eth_10(struct transvr_obj_s *self){ - - int err_code = _check_by_mode(self, - &_common_update_attr_transvr_comp, - "sfp_get_comp_eth_10"); - if (err_code < 0){ - return err_code; - } - return _sfp_get_comp_10g_eth_comp(self); -} - - -int -_sfp_get_connector_type(struct transvr_obj_s *self) { - /* Address: A0h / 2 - * Reference: SFF-8024 TABLE 4-3 - */ - if ((self->state == STATE_TRANSVR_CONNECTED) || - (self->state == STATE_TRANSVR_INIT) ) { - return (int)(self->connector); - } - return ERR_TRANSVR_ABNORMAL; -} - - -int -sfp_get_wavelength(struct transvr_obj_s *self, - char *buf_p) { - /* [Note] Optical and Cable Variants Specification Compliance (SFF-8472) - * [Addr] A0h, Bytes 60-61 - * [Note] For optical variants, as defined by having zero's in A0h Byte 8 - * bits 2 and 3, Bytes 60 and 61 denote nominal transmitter output - * wavelength at room temperature. 16 bit value with byte 60 as high - * order byte and byte 61 as low order byte. The laser wavelength is - * equal to the 16 bit integer value in nm. This field allows the user - * to read the laser wavelength directly, so it is not necessary to - * infer it from the Transceiver Codes A0h Bytes 3 to 10 (see Table - * 5-3). This also allows specification of wavelengths not covered - * in the Transceiver Codes, such as those used in coarse WDM systems. - * - * For passive and active cable variants, a value of 00h for both A0h - * Byte 60 and Byte 61 denotes laser wavelength or cable specification - * compliance is unspecified. - */ - - int lmax = 8; - int err_code = DEBUG_TRANSVR_INT_VAL; - - err_code = _check_by_mode(self, - &_common_update_attr_wavelength, - "common_get_wavelength"); - if (err_code < 0) { - return snprintf(buf_p, lmax, "%d\n", err_code); - } - if ((self->wavelength[0]) == DEBUG_TRANSVR_HEX_VAL) { - return snprintf(buf_p, lmax, "%d\n", ERR_TRANSVR_UPDATE_FAIL); - } - /* unit: 1 um */ - return snprintf(buf_p, lmax, "%d\n", - _common_count_wavelength(self, - self->wavelength[0], - self->wavelength[1])); -} - - -int -sfp_get_1g_rj45_extphy_offset(struct transvr_obj_s *self, char *buf) { - - if (self->state != STATE_TRANSVR_CONNECTED) { - return ERR_TRANSVR_UNPLUGGED; - } - if ((self->info != TRANSVR_CLASS_BASE_T_1000) && - (self->info != TRANSVR_CLASS_BASE_T_1000_up) ){ - return ERR_TRANSVR_NOTSUPPORT; - } - return snprintf(buf, LEN_TRANSVR_S_STR, "0x%02x\n", self->extphy_offset); -} - - -int -sfp_get_1g_rj45_extphy_reg(struct transvr_obj_s *self, char *buf) { - - int i = 0; - int ret = 0; - int retry = 3; - int delay = 200; - - if (self->state != STATE_TRANSVR_CONNECTED) { - return ERR_TRANSVR_UNPLUGGED; - } - if ((self->info != TRANSVR_CLASS_BASE_T_1000) && - (self->info != TRANSVR_CLASS_BASE_T_1000_up) ){ - return ERR_TRANSVR_NOTSUPPORT; - } - if (_common_setup_page(self, VAL_TRANSVR_EXTPHY_ADDR_56, - -1, self->extphy_offset, 1, 0) < 0) { - return -EIO; - } - for (i=0; ii2c_client_p, self->extphy_offset); - if (ret >=0) { - goto ok_sfp_get_1g_rj45_extphy_reg; - } - msleep(delay); - } - SWPS_INFO("%s: retry:%d fail :%s :0x%02x\n", - __func__, retry, self->swp_name, self->extphy_offset); - return -EIO; - -ok_sfp_get_1g_rj45_extphy_reg: - ret = ((ret & 0x00ff) << 8) | ((ret & 0xff00) >> 8); - return snprintf(buf, LEN_TRANSVR_S_STR, "0x%04x\n", ret); -} - - -int -__qsfp_get_power_cls(struct transvr_obj_s *self, - int direct_access){ - - int err_code; - uint8_t detect_val; - - /* Detect and Update power class attribute */ - if (direct_access){ - err_code = _check_by_mode(self, - &_common_update_attr_extended_id, - "__qsfp_get_power_cls"); - } else { - err_code = self->ext_id; - } - if (err_code <0){ - return err_code; - } - if (err_code == DEBUG_TRANSVR_HEX_VAL){ - return ERR_TRANSVR_UPDATE_FAIL; - } - /* Clean data */ - detect_val = self->ext_id; - SWP_BIT_CLEAR(detect_val, 2); /* Bit2: CDR RX present */ - SWP_BIT_CLEAR(detect_val, 3); /* Bit3: CDR TX present */ - SWP_BIT_CLEAR(detect_val, 4); /* Bit4: CLEI present */ - SWP_BIT_CLEAR(detect_val, 5); /* Bit5: reserved */ - /* Identify power class */ - switch (detect_val) { - case 0: /* Class_1: 00000000 */ - return 1; - case 64: /* Class_2: 01000000 */ - return 2; - case 128: /* Class_3: 10000000 */ - return 3; - case 192: /* Class_4: 11000000 */ - return 4; - case 1: /* Class_5: 00000001 */ - case 193: /* Class_5: 11000001 */ - return 5; - case 2: /* Class_6: 00000010 */ - case 194: /* Class_6: 11000010 */ - return 6; - case 3: /* Class_7: 00000011 */ - case 195: /* Class_7: 11000011 */ - return 7; - default: - break; - } - SWPS_INFO("%s: Detect undefined power class:%d\n", __func__, detect_val); - return ERR_TRANSVR_UNDEFINED; -} - - -int -qsfp_get_power_cls(struct transvr_obj_s *self) { - return __qsfp_get_power_cls(self, 1); -} - - -int -__qsfp_get_cdr_present(struct transvr_obj_s *self, - int direct_access){ - - int retval; - int BIT_SHIFT = 2; - int BIT_MASK = 0x3; - - /* Detect and Update power class attribute */ - if (direct_access) { - retval = _check_by_mode(self, - &_common_update_attr_extended_id, - "__qsfp_get_cdr_present"); - if (retval < 0){ - return retval; - } - } - retval = self->ext_id; - if (retval == DEBUG_TRANSVR_HEX_VAL){ - return ERR_TRANSVR_UPDATE_FAIL; - } - /* Clean data and return */ - return (int)(retval >> BIT_SHIFT & BIT_MASK); -} - - -int -qsfp_get_cdr_present(struct transvr_obj_s *self) { - return __qsfp_get_cdr_present(self, 1); -} - - -int -qsfp_get_cdr(struct transvr_obj_s *self){ - - int err_code = _check_by_mode(self, - &_qsfp_update_attr_cdr, - "qsfp_get_cdr"); - if (err_code <0){ - return err_code; - } - - return self->cdr; -} - - -int -__qsfp_get_comp_attr(struct transvr_obj_s *self, - int array_offset) { - /* QSFP Specification Compliance: 00h / 131-138 - * transvr_comp[0-7] = 131 - 138 - */ - if ((self->state == STATE_TRANSVR_CONNECTED) || - (self->state == STATE_TRANSVR_INIT) ) { - return (int)(self->transvr_comp[array_offset]); - } - return ERR_TRANSVR_ABNORMAL; -} - - -int -_qsfp_get_comp_10_40_100_ethernet(struct transvr_obj_s *self) { - /* transvr_comp[0] = address 00h / 131 - * - * 131 7: Extended: See section 6.3.23. The Extended Specification Compliance - * Codes are maintained in the Transceiver Management section of SFF- - * 8024. - * 131 6: 10GBASE-LRM - * 131 5: 10GBASE-LR - * 131 4: 10GBASE-SR - * 131 3: 40GBASE-CR4 - * 131 2: 40GBASE-SR4 - * 131 1: 40GBASE-LR4 - * 131 0: 40G Active Cable (XLPPI) - */ - return __qsfp_get_comp_attr(self, 0); -} - - -int -_qsfp_get_comp_sonet(struct transvr_obj_s *self) { - /* transvr_comp[1] = address 00h / 132 - * - * 132 7-3: Reserved - * 132 2: OC 48, long reach - * 132 1: OC 48, intermediate reach - * 132 0: OC 48 short reach - */ - return __qsfp_get_comp_attr(self, 1); -} - - -int -_qsfp_get_comp_sas_sata(struct transvr_obj_s *self) { - /* transvr_comp[1] = address 00h / 132 - * - * 133 7: SAS 24.0 Gb/s - * 133 6: SAS 12.0 Gb/s - * 133 5: SAS 6.0 Gb/s - * 133 4: SAS 3.0 Gb/s - * 133 3-0: Reserved - */ - return __qsfp_get_comp_attr(self, 2); -} - - -int -_qsfp_get_comp_ethernet(struct transvr_obj_s *self) { - /* transvr_comp[1] = address 00h / 132 - * - * 134 7-4: Reserved - * 134 3: 1000BASE-T - * 134 2: 1000BASE-CX - * 134 1: 1000BASE-LX - * 134 0: 1000BASE-SX - */ - return __qsfp_get_comp_attr(self, 3); -} - - -int -_qsfp_get_comp_fc_link_length(struct transvr_obj_s *self) { - /* transvr_comp[1] = address 00h / 132 - * - * 135 7: Very long distance (V) - * 135 6: Short distance (S) - * 135 5: Intermediate distance (I) - * 135 4: Long distance (L) - * 135 3: Medium (M) - */ - int mask = 0xFC; /* 11111100 */ - return (__qsfp_get_comp_attr(self, 4) & mask); -} - - -int -_qsfp_get_comp_fc_trans_tech(struct transvr_obj_s *self) { - /* transvr_comp[1] = address 00h / 132 - * - * 135 2: Reserved - * 135 1: Longwave laser (LC) - * 135 0: Electrical inter-enclosure (EL) - * - * 136 7: Electrical intra-enclosure - * 136 6: Shortwave laser w/o OFC (SN) - * 136 5: Shortwave laser w OFC (SL) - * 136 4: Longwave Laser (LL) - * 136 3-0: Reserved - * - * return value = [bit 8-15:addr 135][bit 0-7:addr 136] - */ - int mask_135 = 7; /* 00000111 */ - int val_135 = (__qsfp_get_comp_attr(self, 4) & mask_135); - int val_136 = __qsfp_get_comp_attr(self, 5); - return ((val_135 << 7) + val_136); -} - - -int -_qsfp_get_comp_fc_trans_media(struct transvr_obj_s *self) { - /* transvr_comp[1] = address 00h / 132 - * - * 137 7: Twin Axial Pair (TW) - * 137 6: Shielded Twisted Pair (TP) - * 137 5: Miniature Coax (MI) - * 137 4: Video Coax (TV) - * 137 3: Multi-mode 62.5 m (M6) - * 137 2: Multi-mode 50 m (M5) - * 137 1: Multi-mode 50 um (OM3) - * 137 0: Single Mode (SM) - */ - return __qsfp_get_comp_attr(self, 6); -} - - -int -_qsfp_get_comp_fc_speed(struct transvr_obj_s *self) { - /* transvr_comp[1] = address 00h / 132 - * - * 138 7: 1200 MBps (per channel) - * 138 6: 800 MBps - * 138 5: 1600 MBps (per channel) - * 138 4: 400 MBps - * 138 3: 3200 MBps (per channel) - * 138 2: 200 MBps - * 138 1: Extended: See section 6.3.23. The Extended Specification - * Compliance Codes are maintained in the Transceiver Management - * section of SFF-8024. - * 138 0: 100 MBps - */ - return __qsfp_get_comp_attr(self, 7); -} - - -int -_qsfp_get_comp_extended(struct transvr_obj_s *self) { - /* Address: 00h / 192 - * Reference: SFF-8024 TABLE 4-4 - */ - if ((self->state == STATE_TRANSVR_CONNECTED) || - (self->state == STATE_TRANSVR_INIT) ) { - return (int)(self->transvr_comp_ext); - } - return ERR_TRANSVR_ABNORMAL; -} - - -int -qsfp_get_comp_eth(struct transvr_obj_s *self){ - - int err_code = _check_by_mode(self, - &_common_update_attr_transvr_comp, - "qsfp_get_comp_eth"); - if (err_code < 0){ - return err_code; - } - return _qsfp_get_comp_ethernet(self); -} - - -int -qsfp_get_comp_10_40(struct transvr_obj_s *self) { - - int err_code = _check_by_mode(self, - &_common_update_attr_transvr_comp, - "qsfp_get_comp_10_40"); - if (err_code < 0){ - return err_code; - } - return _qsfp_get_comp_10_40_100_ethernet(self); -} - - -int -_qsfp_get_connector_type(struct transvr_obj_s *self) { - /* Address: 00h / 130 - * Reference: SFF-8024 TABLE 4-3 - */ - if ((self->state == STATE_TRANSVR_CONNECTED) || - (self->state == STATE_TRANSVR_INIT) ) { - return (int)(self->connector); - } - return ERR_TRANSVR_ABNORMAL; -} - - -int -qsfp_get_transvr_temp(struct transvr_obj_s *self, - char *buf_p) { - - int lmax = 8; - int err_code = DEBUG_TRANSVR_INT_VAL; - - err_code = _check_by_mode(self, - &_qsfp_update_attr_curr_temp, - "qsfp_get_transvr_temp"); - if (err_code < 0) { - return snprintf(buf_p, lmax, "%d\n", err_code); - } - if ((self->curr_temp[0]) == DEBUG_TRANSVR_HEX_VAL) { - return snprintf(buf_p, lmax, "%d\n", ERR_TRANSVR_UPDATE_FAIL); - } - return _common_count_temp(self->curr_temp[0], - self->curr_temp[1], - buf_p); -} - - -int -qsfp_get_transvr_voltage(struct transvr_obj_s *self, - char *buf_p) { - - int lmax = 8; - int err_code = DEBUG_TRANSVR_INT_VAL; - - err_code = _check_by_mode(self, - &_qsfp_update_attr_curr_voltage, - "qsfp_get_transvr_voltage"); - if (err_code < 0) { - return snprintf(buf_p, lmax, "%d\n", err_code); - } - if ((self->curr_voltage[0]) == DEBUG_TRANSVR_HEX_VAL) { - return snprintf(buf_p, lmax, "%d\n", ERR_TRANSVR_UPDATE_FAIL); - } - /* Return Unit: 1 Volt */ - return _common_count_voltage(self->curr_voltage[0], - self->curr_voltage[1], - buf_p); -} - - -int -qsfp_get_transvr_tx_eq(struct transvr_obj_s *self, - char *buf_p) { - - int limt = 8; - int err = DEBUG_TRANSVR_INT_VAL; - - err = _check_by_mode(self, - &_qsfp_update_attr_tx_eq, - "qsfp_get_transvr_tx_eq"); - if (err < 0) { - return snprintf(buf_p, limt, "%d\n", err); - } - if ((self->tx_eq[0]) == DEBUG_TRANSVR_HEX_VAL) { - return snprintf(buf_p, limt, "%d\n", ERR_TRANSVR_UPDATE_FAIL); - } - return snprintf(buf_p, limt, "0x%02x%02x\n", - self->tx_eq[0], self->tx_eq[1]); -} - - -int -qsfp_get_transvr_rx_am(struct transvr_obj_s *self, - char *buf_p) { - - int limt = 8; - int err = DEBUG_TRANSVR_INT_VAL; - - err = _check_by_mode(self, - &_qsfp_update_attr_rx_am, - "qsfp_get_transvr_rx_am"); - if (err < 0) { - return snprintf(buf_p, limt, "%d\n", err); - } - if ((self->rx_am[0]) == DEBUG_TRANSVR_HEX_VAL) { - return snprintf(buf_p, limt, "%d\n", ERR_TRANSVR_UPDATE_FAIL); - } - return snprintf(buf_p, limt, "0x%02x%02x\n", - self->rx_am[0], self->rx_am[1]); -} - - -int -qsfp_get_transvr_rx_em(struct transvr_obj_s *self, - char *buf_p) { - - int limt = 8; - int err = DEBUG_TRANSVR_INT_VAL; - - err = _check_by_mode(self, - &_qsfp_update_attr_rx_em, - "qsfp_get_transvr_rx_em"); - if (err < 0) { - return snprintf(buf_p, limt, "%d\n", err); - } - if ((self->rx_em[0]) == DEBUG_TRANSVR_HEX_VAL) { - return snprintf(buf_p, limt, "%d\n", ERR_TRANSVR_UPDATE_FAIL); - } - return snprintf(buf_p, limt, "0x%02x%02x\n", - self->rx_em[0], self->rx_em[1]); -} - - -int -_qsfp_get_channel_diag(uint8_t *data_array, - int (*count_func)(uint8_t high_byte, uint8_t low_byte, char *buf_p), - char *ch_name, - char *result_p) { - int i, high, low; - int len_max = 128; - char ch_buf[4][16] = { DEBUG_TRANSVR_STR_VAL, - DEBUG_TRANSVR_STR_VAL, - DEBUG_TRANSVR_STR_VAL, - DEBUG_TRANSVR_STR_VAL }; - - for (i=0; i<4; i++) { - high = (i*2); - low = ((i*2) + 1); - count_func(data_array[high], data_array[low], ch_buf[i]); - } - return snprintf(result_p, len_max, - "%s-%d:%s%s-%d:%s%s-%d:%s%s-%d:%s", - ch_name, 1, ch_buf[0], - ch_name, 2, ch_buf[1], - ch_name, 3, ch_buf[2], - ch_name, 4, ch_buf[3]); -} - - -int -qsfp_get_soft_rx_los(struct transvr_obj_s *self, - char *buf_p) { - - int lmax = 8; - int mask = 0x0f; /* Bit 0 ~ Bit 3 */ - int err_code = DEBUG_TRANSVR_INT_VAL; - - err_code = _check_by_mode(self, - &_qsfp_update_attr_soft_rx_los, - "qsfp_get_soft_rx_los"); - if (err_code < 0) { - return snprintf(buf_p, lmax, "%d\n", err_code); - } - return snprintf(buf_p, lmax, "0x%02x\n", (self->rx_los & mask)); -} - - -int -qsfp_get_soft_tx_disable(struct transvr_obj_s *self, - char *buf_p) { - - int lmax = 8; - int mask = 0x0f; /* Bit 0 ~ Bit 3 */ - int err_code = DEBUG_TRANSVR_INT_VAL; - - err_code = _check_by_mode(self, - &_qsfp_update_attr_soft_tx_disable, - "qsfp_get_soft_tx_disable"); - if (err_code < 0) { - return snprintf(buf_p, lmax, "%d\n", err_code); - } - return snprintf(buf_p, lmax, "0x%02x\n", (self->tx_disable & mask)); -} - - -int -qsfp_get_soft_tx_fault(struct transvr_obj_s *self, - char *buf_p) { - - int lmax = 8; - int mask = 0x0f; /* Bit 0 ~ Bit 3 */ - int err_code = DEBUG_TRANSVR_INT_VAL; - - err_code = _check_by_mode(self, - &_qsfp_update_attr_soft_tx_fault, - "qsfp_get_soft_tx_fault"); - if (err_code < 0) { - return snprintf(buf_p, lmax, "%d\n", err_code); - } - return snprintf(buf_p, lmax, "0x%02x\n", (self->tx_fault & mask)); -} - - -int -qsfp_get_auto_tx_disable(struct transvr_obj_s *self, - char *buf_p) { - - if (self->auto_tx_disable == VAL_TRANSVR_FUNCTION_DISABLE) { - return snprintf(buf_p, LEN_TRANSVR_S_STR, - "%d\n", ERR_TRANSVR_FUNC_DISABLE); - } - return snprintf(buf_p, LEN_TRANSVR_S_STR, - "0x%02x\n", self->auto_tx_disable); -} - - -int -qsfp_get_transvr_tx_bias(struct transvr_obj_s *self, - char *buf_p) { - - int lmax = 8; - int err_code = DEBUG_TRANSVR_INT_VAL; - char *ch_name = "TX"; - - err_code = _check_by_mode(self, - &_qsfp_update_attr_curr_tx_bias, - "qsfp_get_transvr_tx_bias"); - if (err_code < 0) { - return snprintf(buf_p, lmax, "%d\n", err_code); - } - if ((self->curr_tx_bias[0]) == DEBUG_TRANSVR_HEX_VAL) { - return snprintf(buf_p, lmax, "%d\n", ERR_TRANSVR_UPDATE_FAIL); - } - /* Return Unit: 1 mA */ - return _qsfp_get_channel_diag(self->curr_tx_bias, - _common_count_tx_bias, - ch_name, - buf_p); -} - - -int -qsfp_get_transvr_tx_power(struct transvr_obj_s *self, - char *buf_p) { - - int lmax = 8; - int err_code = DEBUG_TRANSVR_INT_VAL; - char *ch_name = "TX"; - - err_code = _check_by_mode(self, - &_qsfp_update_attr_curr_tx_power, - "qsfp_get_transvr_tx_power"); - if (err_code < 0) { - return snprintf(buf_p, lmax, "%d\n", err_code); - } - if ((self->curr_tx_power[0]) == DEBUG_TRANSVR_HEX_VAL) { - return snprintf(buf_p, lmax, "%d\n", ERR_TRANSVR_UPDATE_FAIL); - } - /* Return Unit: 1 mW */ - return _qsfp_get_channel_diag(self->curr_tx_power, - _common_count_tx_power, - ch_name, - buf_p); -} - - -int -qsfp_get_transvr_rx_power(struct transvr_obj_s *self, - char *buf_p) { - - int lmax = 8; - int err_code = DEBUG_TRANSVR_INT_VAL; - char *ch_name = "RX"; - - err_code = _check_by_mode(self, - &_qsfp_update_attr_curr_rx_power, - "qsfp_get_transvr_rx_power"); - if (err_code < 0) { - return snprintf(buf_p, lmax, "%d\n", err_code); - } - if ((self->curr_tx_power[0]) == DEBUG_TRANSVR_HEX_VAL) { - return snprintf(buf_p, lmax, "%d\n", ERR_TRANSVR_UPDATE_FAIL); - } - /* Return Unit: 1 mW */ - return _qsfp_get_channel_diag(self->curr_rx_power, - _common_count_rx_power, - ch_name, - buf_p); -} - - -int -qsfp_get_wavelength(struct transvr_obj_s *self, - char *buf_p) { - /* [Desc] Wavelength or Copper Cable Attenuation (SFF-8636) - * [Addr] 00h 186-187 - * [Note] - * For optical free side devices, this parameter identifies the nominal - * transmitter output wavelength at room temperature. This parameter is - * a 16-bit hex value with Byte 186 as high order byte and Byte 187 as - * low order byte. The laser wavelength is equal to the 16-bit integer value - * divided by 20 in nm (units of 0.05 nm). This resolution should be adequate - * to cover all relevant wavelengths yet provide enough resolution for all - * expected DWDM applications. For accurate representation of controlled - * wavelength applications, this value should represent the center of the - * guaranteed wavelength range. - * If the free side device is identified as copper cable these registers will - * be used to define the cable attenuation. An indication of 0 dB attenuation - * refers to the case where the attenuation is not known or is unavailable. - * Byte 186 (00-FFh) is the copper cable attenuation at 2.5 GHz in units of 1 dB. - * Byte 187 (00-FFh) is the copper cable attenuation at 5.0 GHz in units of 1 dB. - */ - int lmax = 8; - int err_code = DEBUG_TRANSVR_INT_VAL; - - err_code = _check_by_mode(self, - &_common_update_attr_wavelength, - "common_get_wavelength"); - if (err_code < 0) { - return snprintf(buf_p, lmax, "%d\n", err_code); - } - if ((self->wavelength[0]) == DEBUG_TRANSVR_HEX_VAL) { - return snprintf(buf_p, lmax, "%d\n", ERR_TRANSVR_UPDATE_FAIL); - } - /* unit: 1 um */ - return snprintf(buf_p, lmax, "%d\n", - _common_count_wavelength(self, - self->wavelength[0], - self->wavelength[1])); -} - - -/* Public Function for Setup Features - */ -static int -__sfp_set_soft_rs(struct transvr_obj_s *self, - int input_val, - int address, - int page, - int offset, - int bit_shift, - uint8_t *attr_p, - char *caller, - int show_err) { - - int retval = ERR_TRANSVR_UNEXCPT; - int err_code = ERR_TRANSVR_UNEXCPT; - char *err_msg = DEBUG_TRANSVR_STR_VAL; - uint8_t update_val = (*attr_p); - - switch (input_val) { - case 0: - SWP_BIT_CLEAR(update_val, bit_shift); - break; - case 1: - SWP_BIT_SET(update_val, bit_shift); - break; - default: - retval = ERR_TRANSVR_UNEXCPT; - err_code = ERR_TRANSVR_UNEXCPT; - err_msg = "Exception occurs"; - goto err_private_sfp_set_soft_rs_1; - } - err_code = _common_set_uint8_attr(self, - address, - page, - offset, - update_val, - attr_p, - caller, - show_err); - if (err_code < 0) { - retval = err_code; - err_msg = "Write data via i2c fail!"; - goto err_private_sfp_set_soft_rs_1; - } - (*attr_p) = update_val; - return 0; - -err_private_sfp_set_soft_rs_1: - if (show_err) { - SWPS_INFO("%s: %s :%d :%s\n :%d\n", - __func__, err_msg, err_code, self->swp_name, input_val); - } - return retval; -} - - -static int -_sfp_set_soft_rs(struct transvr_obj_s *self, - int input_val, - int address, - int page, - int offset, - int bit_shift, - int (*attr_update_func)(struct transvr_obj_s *self, int show_err), - uint8_t *attr_p, - char *caller, - int show_err) { - - int retval = ERR_TRANSVR_UNEXCPT; - int err_code = ERR_TRANSVR_UNEXCPT; - char *err_msg = DEBUG_TRANSVR_STR_VAL; - - /* Check input value */ - if ((input_val != 0) && (input_val != 1)){ - retval = ERR_TRANSVR_BADINPUT; - err_code = ERR_TRANSVR_BADINPUT; - err_msg = "Input range incorrect!"; - goto err_common_sfp_set_soft_rs_1; - } - /* Check rate identifier is supported */ - err_code = self->get_rate_id(self); - if (err_code <= 0) { - switch (err_code) { - case 0: - retval = ERR_TRANSVR_NOTSUPPORT; - err_msg = "Not support this feature"; - break; - case ERR_TRANSVR_UNINIT: - retval = ERR_TRANSVR_UNINIT; - err_msg = "Check CDR present fail!"; - break; - case ERR_TRANSVR_UNPLUGGED: - retval = ERR_TRANSVR_UNPLUGGED; - err_msg = "Transceiver unplugged!"; - break; - default: - retval = err_code; - err_msg = "Check Rate_ID fail!"; - break; - } - goto err_common_sfp_set_soft_rs_1; - } - /* Check and update */ - err_code = _check_by_mode(self, - attr_update_func, - caller); - if ( (err_code < 0) || - ((*attr_p) == DEBUG_TRANSVR_HEX_VAL) ){ - retval = err_code; - err_msg = "Get current value fail!"; - goto err_common_sfp_set_soft_rs_1; - } - /* Generate and update value */ - return __sfp_set_soft_rs(self, - input_val, - address, - page, - offset, - bit_shift, - attr_p, - caller, - show_err); - -err_common_sfp_set_soft_rs_1: - if (show_err) { - SWPS_INFO("%s: %s :%d :%s\n :%d\n", - __func__, err_msg, err_code, self->swp_name, input_val); - } - return retval; -} - - -int -sfp_set_soft_rs0(struct transvr_obj_s *self, - int input_val) { - /* Note: - * SFP Soft Rate_Select Select RX ["RS(0)"] address - * A2h, offset: 110, bit 3 - */ - int bit_shift = 3; - int show_err = 1; - return _sfp_set_soft_rs(self, - input_val, - self->eeprom_map_p->addr_soft_rs0, - self->eeprom_map_p->page_soft_rs0, - self->eeprom_map_p->offset_soft_rs0, - bit_shift, - &_sfp_update_attr_soft_rs0, - &(self->soft_rs0), - "sfp_set_soft_rs0", - show_err); -} - - -int -sfp_set_soft_rs1(struct transvr_obj_s *self, - int input_val) { - /* Note: - * SFP Soft Rate_Select Select RX ["RS(1)"] address - * A2h, offset: 118, bit 3 - */ - int bit_shift = 3; - int show_err = 1; - return _sfp_set_soft_rs(self, - input_val, - self->eeprom_map_p->addr_soft_rs1, - self->eeprom_map_p->page_soft_rs1, - self->eeprom_map_p->offset_soft_rs1, - bit_shift, - &_sfp_update_attr_soft_rs1, - &(self->soft_rs1), - "sfp_set_soft_rs1", - show_err); -} - - -int -__sfp_set_tx_eq(struct transvr_obj_s *self, - int input, - int show_e) { - - int err = DEBUG_TRANSVR_INT_VAL; - char *emsg = DEBUG_TRANSVR_STR_VAL; - uint8_t setv = DEBUG_TRANSVR_HEX_VAL; - - if ((input < 0) || (input > 0xFF)) { - emsg = "input incorrect"; - err = ERR_TRANSVR_BADINPUT; - goto err_sfp_set_tx_eq; - } - setv = (uint8_t)input; - if (self->tx_eq[0] == setv) { - return 0; - } - err = _common_set_uint8_attr(self, - self->eeprom_map_p->addr_tx_eq, - self->eeprom_map_p->page_tx_eq, - self->eeprom_map_p->offset_tx_eq, - setv, - &(self->tx_eq[0]), - "_sfp_set_tx_eq", - show_e); - if (err < 0) { - emsg = "set_uint8_attr fail"; - goto err_sfp_set_tx_eq; - } - return 0; - -err_sfp_set_tx_eq: - if (show_e) { - SWPS_INFO("%s: %s :%d\n", __func__, emsg, input); - } - return err; -} - - -int -_sfp_set_tx_eq(struct transvr_obj_s *self, - int input, - int show_e) { - - uint8_t tmp; - int i = 0; - int retry = 3; - - for (i=0; itx_eq[0]; - if (_sfp_update_attr_tx_eq(self, show_e) < 0){ - continue; - } - if (self->tx_eq[0] == tmp){ - return 0; - } - } - return ERR_TRANSVR_UPDATE_FAIL; -} - - -int -sfp_set_tx_eq(struct transvr_obj_s *self, - int input) { - - int err = _check_by_mode(self, - &_sfp_update_attr_tx_eq, - "sfp_set_tx_eq"); - if (err < 0) { - SWPS_DEBUG("%s: check fail :%d\n", __func__, err); - return err; - } - return _sfp_set_tx_eq(self, input, 1); -} - - -int -__sfp_set_rx_em(struct transvr_obj_s *self, - int input, - int show_e) { - - int err = DEBUG_TRANSVR_INT_VAL; - char *emsg = DEBUG_TRANSVR_STR_VAL; - uint8_t setv = DEBUG_TRANSVR_HEX_VAL; - - if ((input < 0) || (input > 0xFF)) { - emsg = "input incorrect"; - err = ERR_TRANSVR_BADINPUT; - goto err_sfp_set_rx_em; - } - setv = (uint8_t)input; - if (self->rx_em[0] == setv) { - return 0; - } - err = _common_set_uint8_attr(self, - self->eeprom_map_p->addr_rx_em, - self->eeprom_map_p->page_rx_em, - self->eeprom_map_p->offset_rx_em, - setv, - &(self->rx_em[0]), - "_sfp_set_rx_em", - show_e); - if (err < 0) { - emsg = "set_uint8_attr fail"; - goto err_sfp_set_rx_em; - } - return 0; - -err_sfp_set_rx_em: - if (show_e) { - SWPS_INFO("%s: %s :%d\n", __func__, emsg, input); - } - return err; -} - - -int -_sfp_set_rx_em(struct transvr_obj_s *self, - int input, - int show_e) { - - uint8_t tmp; - int i = 0; - int retry = 3; - - for (i=0; irx_em[0]; - if (_sfp_update_attr_rx_em(self, show_e) < 0){ - continue; - } - if (self->rx_em[0] == tmp){ - return 0; - } - } - return -1; -} - - -int -sfp_set_rx_em(struct transvr_obj_s *self, - int input) { - - int err = _check_by_mode(self, - &_sfp_update_attr_rx_em, - "sfp_set_rx_em"); - if (err < 0) { - SWPS_DEBUG("%s: check fail :%d\n", __func__, err); - return err; - } - return _sfp_set_rx_em(self, input, 1); -} - - -int -sfp_set_1g_rj45_extphy_offset(struct transvr_obj_s *self, - int input) { - - if (self->state != STATE_TRANSVR_CONNECTED) { - return ERR_TRANSVR_UNPLUGGED; - } - if ((self->info != TRANSVR_CLASS_BASE_T_1000) && - (self->info != TRANSVR_CLASS_BASE_T_1000_up) ){ - return ERR_TRANSVR_NOTSUPPORT; - } - if ((input < 0) || (input > 0xff)) { - return ERR_TRANSVR_BADINPUT; - } - self->extphy_offset = (uint8_t)input; - return 0; -} - - -int -sfp_set_1g_rj45_extphy_reg(struct transvr_obj_s *self, - int input) { - - int i = 0; - int retry = 3; - int delay = 200; - uint16_t tmp = 0; - - if (self->state != STATE_TRANSVR_CONNECTED) { - return ERR_TRANSVR_UNPLUGGED; - } - if ((self->info != TRANSVR_CLASS_BASE_T_1000) && - (self->info != TRANSVR_CLASS_BASE_T_1000_up) ){ - return ERR_TRANSVR_NOTSUPPORT; - } - if ((input < 0) || (input > 0xffff)) { - return ERR_TRANSVR_BADINPUT; - } - tmp = ((input & 0x00ff) << 8) | ((input & 0xff00) >> 8); - if (_common_setup_page(self, VAL_TRANSVR_EXTPHY_ADDR_56, - -1, self->extphy_offset, 1, 0) < 0) { - return -EIO; - } - for (i=0; i<=retry; i++) { - if (i2c_smbus_write_word_data(self->i2c_client_p, - self->extphy_offset, - tmp) >= 0) { - return 0; - } - msleep(delay); - } - SWPS_INFO("%s: retry:%d fail :%s :0x%02x\n", - __func__, retry, self->swp_name, self->extphy_offset); - return -EIO; -} - - -static int -__qsfp_set_cdr(struct transvr_obj_s *self, - int input_val, - int show_err) { - - uint8_t update_val; - int CDR_FEATURE_SUPPORTED = 0x3; - int retval = ERR_TRANSVR_UNEXCPT; - int err_code = ERR_TRANSVR_UNEXCPT; - char *err_msg = DEBUG_TRANSVR_STR_VAL; - char *func_name = "__qsfp_set_cdr"; - - /* Check input value */ - if ((input_val < 0) || (input_val > 0xff)){ - retval = ERR_TRANSVR_BADINPUT; - err_code = ERR_TRANSVR_BADINPUT; - err_msg = "Input range incorrect!"; - goto err_qsfp_set_cdr_1; - } - update_val = (uint8_t)input_val; - /* Check CDR supported by transceiver */ - err_code = qsfp_get_cdr_present(self); - if (err_code < 0) { - retval = err_code; - switch (err_code) { - case ERR_TRANSVR_UNINIT: - err_msg = "Check CDR present fail!"; - break; - case ERR_TRANSVR_UNPLUGGED: - err_msg = "Transceiver unplugged!"; - break; - default: - err_msg = "Check CDR present fail!"; - break; - } - goto err_qsfp_set_cdr_1; - } - if (err_code != CDR_FEATURE_SUPPORTED) { - retval = ERR_TRANSVR_NOTSUPPORT; - err_msg = "This transceiver not support CDR!"; - goto err_qsfp_set_cdr_1; - } - /* Check and update */ - err_code = _check_by_mode(self, - &_qsfp_update_attr_cdr, - func_name); - if ( (err_code < 0) || - (self->cdr == DEBUG_TRANSVR_HEX_VAL) ){ - retval = err_code; - err_msg = "Get current value fail!"; - goto err_qsfp_set_cdr_1; - } - /* Write input value to transceiver */ - return _common_set_uint8_attr(self, - self->eeprom_map_p->addr_cdr, - self->eeprom_map_p->page_cdr, - self->eeprom_map_p->offset_cdr, - update_val, - &(self->cdr), - func_name, - show_err); - -err_qsfp_set_cdr_1: - if (show_err) { - SWPS_INFO("%s: %s :%d :%s\n :%d\n", - __func__, err_msg, err_code, self->swp_name, input_val); - } - return retval; -} - - -int -qsfp_set_cdr(struct transvr_obj_s *self, - int input_val) { - return __qsfp_set_cdr(self, input_val, 1); -} - - -int -qsfp_set_soft_tx_disable(struct transvr_obj_s *self, - int input_val) { - - int show_err = 1; - int in_max = 0xf; /* 1111 */ - int in_min = 0x0; /* 0000 */ - int retval = DEBUG_TRANSVR_INT_VAL; - int update_val = DEBUG_TRANSVR_INT_VAL; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - - retval = _check_by_mode(self, - &_qsfp_update_attr_soft_tx_disable, - "qsfp_set_soft_tx_disable"); - if (retval < 0) { - snprintf(err_msg, 63, "Not ready. err:%d", retval); - goto err_qsfp_set_soft_tx_disable; - } - if ((input_val > in_max) || - (input_val < in_min) ){ - retval = ERR_TRANSVR_BADINPUT; - snprintf(err_msg, 63, "Input value:%d incorrect!", input_val); - goto err_qsfp_set_soft_tx_disable; - } - if ((self->tx_disable & 0x0f) == input_val) { - return 0; - } - update_val = ((self->tx_disable & 0xf0) & input_val); - retval = _common_set_uint8_attr(self, - self->eeprom_map_p->addr_tx_disable, - self->eeprom_map_p->page_tx_disable, - self->eeprom_map_p->offset_tx_disable, - input_val, - &(self->tx_disable), - "qsfp_set_tx_disable", - show_err); - if (retval < 0) { - snprintf(err_msg, 63, "_common_set_uint8_attr:%d fail!", retval); - goto err_qsfp_set_soft_tx_disable; - } - return 0; - -err_qsfp_set_soft_tx_disable: - SWPS_INFO("%s: %s :%s\n", __func__, err_msg, self->swp_name); - return retval; -} - - -int -_qsfp_set_auto_tx_disable(struct transvr_obj_s *self, - uint8_t update) { - - uint8_t tx_enable = 0x0; - int show_e = 1; - int err = DEBUG_TRANSVR_INT_VAL; - char *emsg = DEBUG_TRANSVR_STR_VAL; - - /* Handle timing issues */ - if (update != tx_enable) { - /* Note: - * Because there are some txvr has timing issues, - * therefore we need to execute reset cycle first. - * (enable -> other settings) - */ - err = _common_set_uint8_attr(self, - self->eeprom_map_p->addr_tx_disable, - self->eeprom_map_p->page_tx_disable, - self->eeprom_map_p->offset_tx_disable, - tx_enable, - &(self->tx_disable), - "_qsfp_set_auto_tx_disable", - show_e); - if (err < 0) { - emsg = "I2C set reset value fail"; - goto err_qsfp_set_auto_tx_disable; - } - mdelay(10); - } - /* Setup target value */ - err = _common_set_uint8_attr(self, - self->eeprom_map_p->addr_tx_disable, - self->eeprom_map_p->page_tx_disable, - self->eeprom_map_p->offset_tx_disable, - self->auto_tx_disable, - &(self->tx_disable), - "_qsfp_set_auto_tx_disable", - show_e); - if (err < 0) { - emsg = "I2C set target value fail"; - goto err_qsfp_set_auto_tx_disable; - } - /* Check and update */ - err = _common_update_uint8_attr(self, - self->eeprom_map_p->addr_tx_disable, - self->eeprom_map_p->page_tx_disable, - self->eeprom_map_p->offset_tx_disable, - self->eeprom_map_p->length_tx_disable, - &(self->tx_disable), - "_qsfp_set_auto_tx_disable", - show_e); - if (err < 0) { - emsg = "I2C get value fail"; - goto err_qsfp_set_auto_tx_disable; - } - if (self->tx_disable != update) { - emsg = "data not become effective"; - goto err_qsfp_set_auto_tx_disable; - } - return 0; - -err_qsfp_set_auto_tx_disable: - SWPS_DEBUG("%s: %s :%s\n", - __func__, emsg, self->swp_name); - return ERR_TRANSVR_UPDATE_FAIL; -} - - -int -qsfp_set_auto_tx_disable(struct transvr_obj_s *self, - int input_val) { - - int in_max = 0xf; /* 1111 */ - int in_min = 0x0; /* 0000 */ - int retval = DEBUG_TRANSVR_INT_VAL; - char *emsg = DEBUG_TRANSVR_STR_VAL; - - /* Update settings*/ - if (input_val == VAL_TRANSVR_FUNCTION_DISABLE) { - emsg = "User disable auto tx_disable"; - self->auto_tx_disable = VAL_TRANSVR_FUNCTION_DISABLE; - goto out_qsfp_set_auto_tx_disable; - } - if ((input_val > in_max) || (input_val < in_min) ){ - SWPS_INFO("%s: Input value:%d incorrect! :%s\n", - __func__, input_val, self->swp_name); - return ERR_TRANSVR_BADINPUT; - } - self->auto_tx_disable = input_val; - /* Check current soft tx_disable */ - retval = _check_by_mode(self, - &_qsfp_update_attr_soft_tx_disable, - "qsfp_set_auto_tx_disable"); - switch (retval) { - case 0: - break; - case ERR_TRANSVR_UNPLUGGED: - emsg = "Doesn't need to update"; - goto out_qsfp_set_auto_tx_disable; - default: - SWPS_INFO("%s: setup fail :%d :%s\n", - __func__, retval, self->swp_name); - return retval; - } - return _qsfp_set_auto_tx_disable(self, input_val); - -out_qsfp_set_auto_tx_disable: - SWPS_DEBUG("%s: %s :%s :%d\n :%d", - __func__, emsg, self->swp_name, input_val, retval); - return 0; -} - - -int -__qsfp_set_tx_eq(struct transvr_obj_s *self, - int input, - int show_e) { - /* [Note] - * 0x - */ - int err = DEBUG_TRANSVR_INT_VAL; - char *emsg = DEBUG_TRANSVR_STR_VAL; - uint8_t setv[2] = {0x00, 0x00}; - - if ((input < 0) || (input > 0xFFFF)) { - emsg = "input incorrect"; - err = ERR_TRANSVR_BADINPUT; - goto err_qsfp_set_tx_eq; - } - setv[0] = (uint8_t)((input & 0xFF00) >> 8); - setv[1] = (uint8_t)(input & 0xFF); - if ((self->tx_eq[0] == setv[0]) && - (self->tx_eq[1] == setv[1]) ) { - return 0; - } - err = _common_set_uint8_array(self, - self->eeprom_map_p->addr_tx_eq, - self->eeprom_map_p->page_tx_eq, - self->eeprom_map_p->offset_tx_eq, - self->eeprom_map_p->length_tx_eq, - setv, - self->tx_eq, - "_qsfp_set_tx_eq", - show_e); - if (err < 0) { - emsg = "set_uint8_array fail"; - goto err_qsfp_set_tx_eq; - } - return 0; - -err_qsfp_set_tx_eq: - if (show_e) { - SWPS_INFO("%s: %s :%d\n", __func__, emsg, input); - } - return err; -} - - -int -_qsfp_set_tx_eq(struct transvr_obj_s *self, - int input, - int show_e) { - - int i = 0; - int retry = 3; - uint8_t tmp[2]; - - for (i=0; itx_eq[0]; - tmp[1] = self->tx_eq[1]; - if (_qsfp_update_attr_tx_eq(self, show_e) < 0){ - continue; - } - if ((self->tx_eq[0] == tmp[0]) && - (self->tx_eq[1] == tmp[1]) ){ - return 0; - } - } - return -1; -} - - -int -qsfp_set_tx_eq(struct transvr_obj_s *self, - int input) { - - int err = _check_by_mode(self, - &_qsfp_update_attr_tx_eq, - "qsfp_set_tx_eq"); - if (err < 0) { - SWPS_DEBUG("%s: check fail :%d\n", __func__, err); - return err; - } - return _qsfp_set_tx_eq(self, input, 1); -} - - -int -__qsfp_set_rx_am(struct transvr_obj_s *self, - int input, - int show_e) { - /* [Note] - * 0x - */ - int err = DEBUG_TRANSVR_INT_VAL; - char *emsg = DEBUG_TRANSVR_STR_VAL; - uint8_t setv[2] = {0x00, 0x00}; - - if ((input < 0) || (input > 0xFFFF)) { - emsg = "input incorrect"; - err = ERR_TRANSVR_BADINPUT; - goto err_qsfp_set_rx_am; - } - setv[0] = (uint8_t)((input & 0xFF00) >> 8); - setv[1] = (uint8_t)(input & 0xFF); - if ((self->rx_am[0] == setv[0]) && - (self->rx_am[1] == setv[1]) ) { - return 0; - } - err = _common_set_uint8_array(self, - self->eeprom_map_p->addr_rx_am, - self->eeprom_map_p->page_rx_am, - self->eeprom_map_p->offset_rx_am, - self->eeprom_map_p->length_rx_am, - setv, - self->rx_am, - "_qsfp_set_rx_am", - show_e); - if (err < 0) { - emsg = "set_uint8_array fail"; - goto err_qsfp_set_rx_am; - } - return 0; - -err_qsfp_set_rx_am: - if (show_e) { - SWPS_INFO("%s: %s :%d\n", __func__, emsg, input); - } - return err; -} - - -int -_qsfp_set_rx_am(struct transvr_obj_s *self, - int input, - int show_e) { - - int i = 0; - int retry = 3; - uint8_t tmp[2]; - - for (i=0; irx_am[0]; - tmp[1] = self->rx_am[1]; - if (_qsfp_update_attr_rx_am(self, show_e) < 0){ - continue; - } - if ((self->rx_am[0] == tmp[0]) && - (self->rx_am[1] == tmp[1]) ){ - return 0; - } - } - return -1; -} - - -int -qsfp_set_rx_am(struct transvr_obj_s *self, - int input) { - - int err = _check_by_mode(self, - &_qsfp_update_attr_rx_am, - "qsfp_set_rx_am"); - if (err < 0) { - SWPS_DEBUG("%s: check fail :%d\n", __func__, err); - return err; - } - return _qsfp_set_rx_am(self, input, 1); -} - - -int -__qsfp_set_rx_em(struct transvr_obj_s *self, - int input, - int show_e) { - /* [Note] - * 0x - */ - int err = DEBUG_TRANSVR_INT_VAL; - char *emsg = DEBUG_TRANSVR_STR_VAL; - uint8_t setv[2] = {0x00, 0x00}; - - if ((input < 0) || (input > 0xFFFF)) { - emsg = "input incorrect"; - err = ERR_TRANSVR_BADINPUT; - goto err_qsfp_set_rx_em; - } - setv[0] = (uint8_t)((input & 0xFF00) >> 8); - setv[1] = (uint8_t)(input & 0xFF); - if ((self->rx_em[0] == setv[0]) && - (self->rx_em[1] == setv[1]) ) { - return 0; - } - err = _common_set_uint8_array(self, - self->eeprom_map_p->addr_rx_em, - self->eeprom_map_p->page_rx_em, - self->eeprom_map_p->offset_rx_em, - self->eeprom_map_p->length_rx_em, - setv, - self->rx_em, - "_qsfp_set_rx_em", - show_e); - if (err < 0) { - emsg = "set_uint8_array fail"; - goto err_qsfp_set_rx_em; - } - return 0; - -err_qsfp_set_rx_em: - if (show_e) { - SWPS_INFO("%s: %s :%d\n", __func__, emsg, input); - } - return err; -} - - -int -_qsfp_set_rx_em(struct transvr_obj_s *self, - int input, - int show_e) { - - int i = 0; - int retry = 3; - uint8_t tmp[2]; - - for (i=0; irx_em[0]; - tmp[1] = self->rx_em[1]; - if (_qsfp_update_attr_rx_em(self, show_e) < 0){ - continue; - } - if ((self->rx_em[0] == tmp[0]) && - (self->rx_em[1] == tmp[1]) ){ - return 0; - } - } - return -1; -} - - -int -qsfp_set_rx_em(struct transvr_obj_s *self, - int input) { - - int err = _check_by_mode(self, - &_qsfp_update_attr_rx_em, - "qsfp_set_rx_em"); - if (err < 0) { - SWPS_DEBUG("%s: check fail :%d\n", __func__, err); - return err; - } - return _qsfp_set_rx_em(self, input, 1); -} - - -int -common_transvr_dump(struct transvr_obj_s* self){ - - char *type_name = "Undefined"; - - if (TRANSVR_INFO_DUMP_ENABLE != 1) { - return 0; - } - switch (self->type) { - case TRANSVR_TYPE_SFP: - type_name = STR_TRANSVR_SFP; - break; - case TRANSVR_TYPE_QSFP: - type_name = STR_TRANSVR_QSFP; - break; - case TRANSVR_TYPE_QSFP_PLUS: - type_name = STR_TRANSVR_QSFP_PLUS; - break; - case TRANSVR_TYPE_QSFP_28: - type_name = STR_TRANSVR_QSFP28; - break; - case TRANSVR_TYPE_FAKE: - type_name = "FAKE"; - goto ok_common_transvr_dump; - case TRANSVR_TYPE_UNPLUGGED: - type_name = "UNPLUGGED"; - goto err_common_transvr_dump; - case TRANSVR_TYPE_INCONSISTENT: - type_name = "INCONSISTENT"; - goto err_common_transvr_dump; - case TRANSVR_TYPE_ERROR: - type_name = "ERROR"; - goto err_common_transvr_dump; - - default: - type_name = "UNEXPECTED"; - goto err_common_transvr_dump; - } - printk(KERN_INFO "[SWPS] Dump %s information:\n", self->swp_name); - printk(KERN_INFO " |- :%s\n", type_name); - printk(KERN_INFO " |- :%s\n", self->vendor_name); - printk(KERN_INFO " |- :%s\n", self->vendor_pn); - printk(KERN_INFO " |- :%s\n", self->vendor_rev); - printk(KERN_INFO " |- :%s\n", self->vendor_sn); - printk(KERN_INFO " |- :0x%02x\n", self->br); - printk(KERN_INFO " |- :0x%02x\n", self->comp_rev); - printk(KERN_INFO " |- :%d\n", self->len_om1); - printk(KERN_INFO " |- :%d\n", self->len_om2); - printk(KERN_INFO " |- :%d\n", self->len_om3); - printk(KERN_INFO " |- :%d\n", self->len_om4); - return 0; - -ok_common_transvr_dump: - SWPS_INFO("%s: %s is %s\n", __func__, self->swp_name, type_name); - return 0; - -err_common_transvr_dump: - SWPS_INFO("%s: %s is %s\n", __func__, self->swp_name, type_name); - return -1; -} - - -int -sfp_transvr_dump(struct transvr_obj_s* self) { - - if (TRANSVR_INFO_DUMP_ENABLE != 1) { - return 0; - } - if (common_transvr_dump(self) < 0) { - return -1; - } - printk(KERN_INFO " |- :%d\n", self->len_sm); - printk(KERN_INFO " |- :%d\n", self->len_smf); - printk(KERN_INFO " '- :0x%02x\n", self->rate_id); - return 0; -} - - -int -qsfp_transvr_dump(struct transvr_obj_s* self) { - - if (TRANSVR_INFO_DUMP_ENABLE != 1) { - return 0; - } - if (common_transvr_dump(self) < 0) { - return -1; - } - printk(KERN_INFO " |- :%d\n", self->len_smf); - printk(KERN_INFO " '- :Class_%d\n", __qsfp_get_power_cls(self, 0)); - return 0; -} - - -int -fake_transvr_dump(struct transvr_obj_s* self) { - - printk(KERN_INFO "[SWPS] Dump transceiver information: %s\n", self->swp_name); - printk(KERN_INFO " |- :FAKE\n"); - printk(KERN_INFO " |- :FAKE_VENDER_NAME\n"); - printk(KERN_INFO " |- :FAKE_VENDER_PN\n"); - printk(KERN_INFO " |- :FAKE_VENDER_REV\n"); - printk(KERN_INFO " |- :FAKE_VENDER_SN\n"); - printk(KERN_INFO " |- :0x99\n"); - printk(KERN_INFO " |- :99\n"); - printk(KERN_INFO " |- :99\n"); - printk(KERN_INFO " |- :99\n"); - printk(KERN_INFO " |- :99\n"); - printk(KERN_INFO " |- :99\n"); - printk(KERN_INFO " |- :99\n"); - printk(KERN_INFO " '- :0x99\n"); - return 0; -} - - -/* ========== Object functions for fake type ========== - */ -int -fake_transvr_update(struct transvr_obj_s *self, - int show_err){ - self->state = STATE_TRANSVR_CONNECTED; - return 0; -} - - -int -fake_get_binary(struct transvr_obj_s *self){ - return 1; -} - -int -fake_get_int(struct transvr_obj_s *self){ - return 99; -} - - -int -fake_get_hex(struct transvr_obj_s *self){ - return 0x0f; -} - - -int -fake_get_str(struct transvr_obj_s *self, char *buf) { - return snprintf(buf, 16, "fake_get_str\n"); -} - - -int -fake_set_int(struct transvr_obj_s *self, int input){ - SWPS_INFO("%s: %d\n", __func__, input); - return 0; -} - - -int -fake_set_hex(struct transvr_obj_s *self, int input){ - SWPS_INFO("%s: 0x%02x\n", __func__, input); - return 0; -} - - -/* ========== Object functions for unsupported ========== - */ -int -unsupported_get_func(struct transvr_obj_s *self){ - return ERR_TRANSVR_NOTSUPPORT; -} - - -int -unsupported_get_func2(struct transvr_obj_s *self, - char *buf_p) { - int len = snprintf(buf_p, 8, "%d\n", ERR_TRANSVR_NOTSUPPORT); - return len; -} - - -int -unsupported_set_func(struct transvr_obj_s *self, - int input_val){ - return ERR_TRANSVR_NOTSUPPORT; -} - - - -/* ========== Object functions for long term task ========== - * - * [Note] - * SWPS transceiver worker is likely the green-thread (coroutine). - * Due to resource and performance considerations. SWPS run all - * features in one kthread at the same time, and handle by it self. - */ - -/* For Transceiver Task Handling - */ -static struct transvr_worker_s * -transvr_task_get(struct transvr_obj_s *self, - char *func_name) { - - struct transvr_worker_s *curr_p = self->worker_p; - - while(curr_p != NULL){ - if (strcmp((curr_p->func_name), func_name) == 0 ) { - return curr_p; - } - curr_p = curr_p->next_p; - } - return NULL; -} - - -static struct transvr_worker_s* -transvr_task_creat(struct transvr_obj_s *self, - int (*main_task)(struct transvr_worker_s *task), - int (*post_task)(struct transvr_worker_s *task), - char *caller) { - - struct transvr_worker_s *task_p = NULL; - struct transvr_worker_s *curr_p = NULL; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - - /* Check task not exist */ - task_p = transvr_task_get(self, caller); - if (task_p) { - snprintf(err_msg, sizeof(err_msg), "Task already created!"); - goto err_transvr_task_creat; - } - /* Create task worker */ - task_p = kzalloc(sizeof(struct transvr_worker_s), GFP_KERNEL); - if (!task_p){ - snprintf(err_msg, sizeof(err_msg), "kzalloc fail"); - goto err_transvr_task_creat; - } - /* Setup task data */ - task_p->transvr_p = self; - task_p->next_p = NULL; - task_p->trigger_time = 0; - task_p->retry = 1; - task_p->state = STATE_T_TASK_INIT; - task_p->main_task = main_task; - task_p->post_task = post_task; - task_p->p_data = NULL; - snprintf(task_p->func_name, sizeof(task_p->func_name), "%s", caller); - /* Setup Link List */ - if (self->worker_p) { - curr_p = self->worker_p; - while(curr_p->next_p != NULL) { - curr_p = curr_p->next_p; - } - curr_p->next_p = task_p; - task_p->pre_p = curr_p; - } else { - self->worker_p = task_p; - task_p->pre_p = NULL; - } - return task_p; - -err_transvr_task_creat: - SWPS_ERR("%s: %s :%s :%s\n", - __func__, err_msg, caller, self->swp_name); - return NULL; -} - - -static void -transvr_task_free_one(struct transvr_worker_s *task_p){ - - struct transvr_worker_s *pre_p = NULL; - struct transvr_worker_s *next_p = NULL; - - if (task_p) { - pre_p = task_p->pre_p; - next_p = task_p->next_p; - - if ((pre_p) && (next_p)) { - pre_p->next_p = next_p; - next_p->pre_p = pre_p; - - } else if ((!pre_p) && (next_p)) { - next_p->pre_p = NULL; - - } else if ((pre_p) && (!next_p)) { - pre_p->next_p = NULL; - - } else if ((!pre_p) && (!next_p)) { - task_p->transvr_p->worker_p = NULL; - } else { - SWPS_ERR("%s: Unexcept case!\n :%s", - __func__, task_p->transvr_p->swp_name); - } - kfree(task_p->p_data); - kfree(task_p); - } -} - - -static void -transvr_task_free_all(struct transvr_obj_s *self) { - - struct transvr_worker_s *curr_p = NULL; - struct transvr_worker_s *next_p = NULL; - - if (self->worker_p) { - curr_p = self->worker_p; - while(curr_p) { - next_p = curr_p->next_p; - transvr_task_free_one(curr_p); - curr_p = next_p; - } - self->worker_p = NULL; - } -} - - -static void -transvr_cache_free_all(struct transvr_obj_s *self) { - - memset(self->vendor_name, 0, (LEN_TRANSVR_M_STR * sizeof(char)) ); - memset(self->vendor_rev, 0, (LEN_TRANSVR_M_STR * sizeof(char)) ); - memset(self->vendor_pn, 0, (LEN_TRANSVR_M_STR * sizeof(char)) ); - memset(self->vendor_sn, 0, (LEN_TRANSVR_M_STR * sizeof(char)) ); - self->extphy_offset = 0; -} - -static int -_transvr_task_run_main(struct transvr_worker_s *task_p) { - - int retval = DEBUG_TRANSVR_INT_VAL; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - - if (!task_p){ - snprintf(err_msg, sizeof(err_msg), "main_task is NULL!"); - goto main_transvr_task_err; - } - if ((task_p->trigger_time) == 0){ - goto main_transvr_task_run; - } - if (time_before(jiffies, task_p->trigger_time)){ - goto main_transvr_task_wait; - } - goto main_transvr_task_run; - -main_transvr_task_run: - if (task_p->retry != VAL_TRANSVR_TASK_RETRY_FOREVER) { - task_p->retry -= 1; - } - retval = task_p->main_task(task_p); - if (retval < 0) { - if (task_p->retry > 0) { - task_p->state = STATE_T_TASK_WAIT; - return EVENT_TRANSVR_TASK_WAIT; - } - snprintf(err_msg, sizeof(err_msg), "Run main_task fail!"); - goto main_transvr_task_err; - } - goto main_transvr_task_identify; - -main_transvr_task_identify: - switch (retval) { - case EVENT_TRANSVR_TASK_WAIT: - task_p->state = STATE_T_TASK_WAIT; - return EVENT_TRANSVR_TASK_WAIT; - - case EVENT_TRANSVR_TASK_DONE: - task_p->state = STATE_T_TASK_DONE; - return EVENT_TRANSVR_TASK_DONE; - - default: - break; - } - snprintf(err_msg, sizeof(err_msg), "Run main_task fail!"); - goto main_transvr_task_err; - -main_transvr_task_wait: - task_p->state = STATE_T_TASK_WAIT; - return EVENT_TRANSVR_TASK_WAIT; - -main_transvr_task_err: - task_p->state = STATE_T_TASK_FAIL; - SWPS_INFO("%s: %s :%d :%s\n", - __func__, err_msg, retval, task_p->transvr_p->swp_name); - return EVENT_TRANSVR_INIT_FAIL; -} - - -static int -_transvr_task_run_post(struct transvr_worker_s *task_p) { - - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - - if ((task_p->post_task) == NULL) { - return EVENT_TRANSVR_TASK_DONE; - } - switch (task_p->state) { - case STATE_T_TASK_WAIT: - case STATE_T_TASK_INIT: - goto post_transvr_task_wait; - - case STATE_T_TASK_DONE: - case STATE_T_TASK_FAIL: - goto post_transvr_task_run; - - default: - break; - } - snprintf(err_msg, sizeof(err_msg), "Unexcept task state"); - goto post_transvr_task_err; - -post_transvr_task_run: - task_p->post_task(task_p); - return EVENT_TRANSVR_TASK_DONE; - -post_transvr_task_wait: - return EVENT_TRANSVR_TASK_WAIT; - -post_transvr_task_err: - SWPS_INFO("%s: %s :%d :%s\n", - __func__, err_msg, task_p->state, task_p->transvr_p->swp_name); - return EVENT_TRANSVR_TASK_FAIL; -} - - -static int -transvr_task_run_one(struct transvr_worker_s *task_p) { - - int retval_main = DEBUG_TRANSVR_INT_VAL; - int retval_post = DEBUG_TRANSVR_INT_VAL; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - - retval_main = _transvr_task_run_main(task_p); - if (retval_main < 0) { - snprintf(err_msg, sizeof(err_msg), "Execute main_task fail!"); - goto err_transvr_task_run_one; - } - retval_post = _transvr_task_run_post(task_p); - if (retval_post < 0) { - snprintf(err_msg, sizeof(err_msg), "Execute post_task fail!"); - goto err_transvr_task_run_one; - } - return retval_main; - -err_transvr_task_run_one: - SWPS_INFO("%s: %s
:%d :%d :%s :%s\n", - __func__, err_msg, retval_main, retval_post, - task_p->func_name, task_p->transvr_p->swp_name); - return EVENT_TRANSVR_TASK_FAIL; -} - - -static int -transvr_task_run_all(struct transvr_obj_s *self) { - - int haserr = 0; - int retval = DEBUG_TRANSVR_INT_VAL; - struct transvr_worker_s *curr_p = NULL; - struct transvr_worker_s *next_p = NULL; - - if ((self->worker_p) == NULL) { - return EVENT_TRANSVR_TASK_DONE; - } - curr_p = self->worker_p; - while (curr_p != NULL) { - next_p = curr_p->next_p; - retval = transvr_task_run_one(curr_p); - if (curr_p->retry == VAL_TRANSVR_TASK_RETRY_FOREVER) { - curr_p = next_p; - continue; - } - switch (retval) { - case EVENT_TRANSVR_TASK_WAIT: - break; - case EVENT_TRANSVR_TASK_DONE: - transvr_task_free_one(curr_p); - break; - case EVENT_TRANSVR_TASK_FAIL: - - default: - haserr = 1; - transvr_task_free_one(curr_p); - break; - } - curr_p = next_p; - } - if (haserr) { - return EVENT_TRANSVR_TASK_FAIL; - } - return EVENT_TRANSVR_TASK_DONE; -} - - -static void -transvr_task_set_delay(struct transvr_worker_s *task_p, - unsigned long delay_msec) { - - task_p->trigger_time = (jiffies + (delay_msec * (HZ/1000))); -} - - -static void -transvr_task_set_retry(struct transvr_worker_s *task_p, - unsigned long retry_times) { - - task_p->retry = retry_times; -} - - -/* For Transceiver Post Task - */ -int -taskfunc_post_do_nothing(struct transvr_worker_s *task_p) { - - return EVENT_TRANSVR_TASK_DONE; -} - - -int -taskfunc_post_handle_task_state(struct transvr_worker_s *task_p) { - - struct transvr_obj_s* tp = task_p->transvr_p; - - switch (task_p->state) { - case STATE_T_TASK_INIT: - case STATE_T_TASK_WAIT: - return EVENT_TRANSVR_TASK_WAIT; - - case STATE_T_TASK_DONE: - tp->state = STATE_TRANSVR_CONNECTED; - tp->send_uevent(tp, KOBJ_ADD); - return EVENT_TRANSVR_TASK_DONE; - - case STATE_T_TASK_FAIL: - tp->state = STATE_TRANSVR_UNEXCEPTED; - return EVENT_TRANSVR_TASK_FAIL; - - default: - break; - } - return EVENT_TRANSVR_TASK_FAIL; -} - - -/* For Transceiver Main Task - */ -int -_taskfunc_sfp_setup_soft_rs(struct transvr_worker_s *task_p, - int input_val, - int address, - int page, - int offset, - int bit_shift, - uint8_t *attr_p, - char *caller) { - - int show_err = 0; - int err_code = DEBUG_TRANSVR_INT_VAL; - char *err_str = DEBUG_TRANSVR_STR_VAL; - char *func_str = "_taskfunc_sfp_setup_soft_rs"; - - err_code = _sfp_update_attr_soft_rs0(task_p->transvr_p, 0); - if (err_code < 0) { - err_str = "Get current soft_rs0 fail!"; - goto err_taskfunc_sfp_setup_soft_rs_1; - } - err_code = __sfp_set_soft_rs(task_p->transvr_p, - input_val, - address, - page, - offset, - bit_shift, - attr_p, - caller, - show_err); - if (err_code < 0) { - err_str = "Get current soft_rs0 fail!"; - goto err_taskfunc_sfp_setup_soft_rs_1; - } - return EVENT_TRANSVR_TASK_DONE; - -err_taskfunc_sfp_setup_soft_rs_1: - if ((task_p->retry) == 0) { - SWPS_INFO("%s: %s :%s :%d :%d\n", - func_str, err_str, task_p->transvr_p->swp_name, input_val, err_code); - } - return EVENT_TRANSVR_TASK_FAIL; -} - - -int -__taskfunc_sfp_setup_hard_rs(struct transvr_worker_s *task_p, - int input_val, - int (*get_func)(struct ioexp_obj_s *self, int virt_offset), - int (*set_func)(struct ioexp_obj_s *self, int virt_offset, int input_val)) { - - int err_val = EVENT_TRANSVR_EXCEP_EXCEP; - char *err_str = DEBUG_TRANSVR_STR_VAL; - - err_val = get_func(task_p->transvr_p->ioexp_obj_p, - task_p->transvr_p->ioexp_virt_offset); - - if (err_val < 0) { - if (err_val == ERR_IOEXP_NOTSUPPORT) { - return EVENT_TRANSVR_TASK_DONE; - } - err_str = "Get current hard_rs fail!"; - goto err_p_taskfunc_sfp_setup_hard_rs_1; - } - if (err_val == input_val) { - return EVENT_TRANSVR_TASK_DONE; - } - err_val = set_func(task_p->transvr_p->ioexp_obj_p, - task_p->transvr_p->ioexp_virt_offset, - input_val); - if (err_val < 0) { - err_str = "Setup hard_rs fail!"; - goto err_p_taskfunc_sfp_setup_hard_rs_1; - } - return EVENT_TRANSVR_TASK_DONE; - -err_p_taskfunc_sfp_setup_hard_rs_1: - if ((task_p->retry) == 0) { - SWPS_INFO("%s: %s :%s :%d :%d\n", - __func__, err_str, task_p->transvr_p->swp_name, input_val, err_val); - } - return EVENT_TRANSVR_TASK_FAIL; -} - - -int -_taskfunc_sfp_setup_hard_rs0(struct transvr_worker_s *task_p, - int input_val) { - - return __taskfunc_sfp_setup_hard_rs(task_p, - input_val, - task_p->transvr_p->ioexp_obj_p->get_hard_rs0, - task_p->transvr_p->ioexp_obj_p->set_hard_rs0); -} - - -int -_taskfunc_sfp_setup_hard_rs1(struct transvr_worker_s *task_p, - int input_val) { - - return __taskfunc_sfp_setup_hard_rs(task_p, - input_val, - task_p->transvr_p->ioexp_obj_p->get_hard_rs1, - task_p->transvr_p->ioexp_obj_p->set_hard_rs1); -} - - -int -_taskfunc_sfp_setup_rs0(struct transvr_worker_s *task_p, - int input_val) { - - int bit_shift = 3; - int old_val = DEBUG_TRANSVR_INT_VAL; - int err_val = EVENT_TRANSVR_EXCEP_EXCEP; - char *err_str = DEBUG_TRANSVR_STR_VAL; - char *func_str = "_taskfunc_sfp_setup_rs0"; - - err_val = _taskfunc_sfp_setup_hard_rs0(task_p, - input_val); - if (err_val < 0) { - err_str = "Setup hard_rs0 fail!"; - goto err_private_taskfunc_sfp_setup_rs0_1; - } - old_val = err_val; - err_val = _taskfunc_sfp_setup_soft_rs(task_p, - input_val, - task_p->transvr_p->eeprom_map_p->addr_soft_rs0, - task_p->transvr_p->eeprom_map_p->page_soft_rs0, - task_p->transvr_p->eeprom_map_p->offset_soft_rs0, - bit_shift, - &(task_p->transvr_p->soft_rs0), - func_str); - if (err_val < 0) { - err_str = "Setup soft_rs0 fail!"; - goto err_private_taskfunc_sfp_setup_rs0_1; - } - return EVENT_TRANSVR_TASK_DONE; - -err_private_taskfunc_sfp_setup_rs0_1: - if ((task_p->retry) == 0) { - SWPS_INFO("%s: %s :%s :%d :%d\n", - func_str, err_str, task_p->transvr_p->swp_name, input_val, err_val); - } - _taskfunc_sfp_setup_hard_rs0(task_p, old_val); - return EVENT_TRANSVR_TASK_FAIL; -} - - -int -_taskfunc_sfp_setup_rs1(struct transvr_worker_s *task_p, - int input_val) { - - int bit_shift = 3; - int old_val = DEBUG_TRANSVR_INT_VAL; - int err_val = EVENT_TRANSVR_EXCEP_EXCEP; - char *err_str = DEBUG_TRANSVR_STR_VAL; - char *func_str = "_taskfunc_sfp_setup_rs1"; - - err_val = _taskfunc_sfp_setup_hard_rs1(task_p, - input_val); - if (err_val < 0) { - err_str = "Setup hard_rs1 fail!"; - goto err_private_taskfunc_sfp_setup_rs1_1; - } - old_val = err_val; - err_val = _taskfunc_sfp_setup_soft_rs(task_p, - input_val, - task_p->transvr_p->eeprom_map_p->addr_soft_rs1, - task_p->transvr_p->eeprom_map_p->page_soft_rs1, - task_p->transvr_p->eeprom_map_p->offset_soft_rs1, - bit_shift, - &(task_p->transvr_p->soft_rs1), - func_str); - if (err_val < 0) { - err_str = "Setup soft_rs1 fail!"; - goto err_private_taskfunc_sfp_setup_rs1_1; - } - return EVENT_TRANSVR_TASK_DONE; - -err_private_taskfunc_sfp_setup_rs1_1: - if ((task_p->retry) == 0) { - SWPS_INFO("%s: %s :%s :%d :%d\n", - func_str, err_str, task_p->transvr_p->swp_name, input_val, err_val); - } - _taskfunc_sfp_setup_hard_rs1(task_p, old_val); - return EVENT_TRANSVR_TASK_FAIL; -} - - -int -taskfunc_sfp_setup_SFF8431_case1(struct transvr_worker_s *task_p) { - /* SFF-8431 (8/4/2G Rx Rate_Select only) */ - int update_val = 1; - - return _taskfunc_sfp_setup_rs0(task_p, update_val); -} - - - -int -taskfunc_sfp_setup_SFF8431_case2(struct transvr_worker_s *task_p) { - /* SFF-8431 (8/4/2G Tx Rate_Select only) */ - int update_val = 1; - - return _taskfunc_sfp_setup_rs1(task_p, update_val); -} - - -int -taskfunc_sfp_setup_SFF8431_case3(struct transvr_worker_s *task_p) { - /* SFF-8431 (8/4/2G Independent Rx & Tx Rate_select) */ - int update_rs0 = 1; - int update_rs1 = 1; - int err_code = DEBUG_TRANSVR_INT_VAL; - - err_code = _taskfunc_sfp_setup_rs0(task_p, update_rs0); - if (err_code < 0) { - return err_code; - } - return _taskfunc_sfp_setup_rs1(task_p, update_rs1); -} - - -int -taskfunc_sfp_handle_1g_rj45(struct transvr_worker_s *task_p) { - - /* Not all of platform support 0x56 for transceiver - * external PHY, Support list as below: - * => 1. Magnolia-PVT (PS: EVT & DVT not ready) - */ - int ext_phy_addr = 0x56; - int ext_phy_page = -1; - int ext_phy_offs = 0x11; - int ext_phy_len = 1; - int lstate_mask = 0x04; /* 00000100 */ - int show_err = 0; - int fail_retry = 5; - int fail_delay = 1000; /* msec */ - int err_code = DEBUG_TRANSVR_INT_VAL; - uint8_t detect_val = DEBUG_TRANSVR_HEX_VAL; - char err_str[64] = DEBUG_TRANSVR_STR_VAL; - int *tmp_p = NULL; - char *func_name = "taskfunc_sfp_handle_1g_rj45"; - - if (task_p->transvr_p->state != STATE_TRANSVR_CONNECTED) { - return EVENT_TRANSVR_TASK_DONE; - } - if ( (task_p->transvr_p->info != TRANSVR_CLASS_BASE_T_1000) && - (task_p->transvr_p->info != TRANSVR_CLASS_BASE_T_1000_up) ) { - goto err_taskfunc_sfp_handle_1g_rj45_1; - } - err_code = _common_update_uint8_attr(task_p->transvr_p, - ext_phy_addr, - ext_phy_page, - ext_phy_offs, - ext_phy_len, - &detect_val, - func_name, - show_err); - if ( (err_code < 0) || - (detect_val == DEBUG_TRANSVR_HEX_VAL) ) { - snprintf(err_str, sizeof(err_str), "Detect external link status fail"); - goto err_taskfunc_sfp_handle_1g_rj45_2; - } - if ((detect_val & lstate_mask) == lstate_mask) { - goto ok_taskfunc_sfp_handle_1g_rj45_link_up; - } - goto ok_taskfunc_sfp_handle_1g_rj45_link_down; - -ok_taskfunc_sfp_handle_1g_rj45_link_up: - /* Filter out noise */ - if (!(task_p->p_data)) { - tmp_p = kzalloc(sizeof(int), GFP_KERNEL); - if (!tmp_p) { - snprintf(err_str, sizeof(err_str), "kzalloc p_data fail"); - goto err_taskfunc_sfp_handle_1g_rj45_2; - } - *tmp_p = TRANSVR_CLASS_BASE_T_1000_up; - task_p->p_data = tmp_p; - goto ok_taskfunc_sfp_handle_1g_rj45_done; - } - if ((*(int *)(task_p->p_data)) != TRANSVR_CLASS_BASE_T_1000_up) { - kfree(task_p->p_data); - task_p->p_data = NULL; - snprintf(err_str, sizeof(err_str), "Internal error"); - goto err_taskfunc_sfp_handle_1g_rj45_2; - } - task_p->transvr_p->info = TRANSVR_CLASS_BASE_T_1000_up; - kfree(task_p->p_data); - task_p->p_data = NULL; - goto ok_taskfunc_sfp_handle_1g_rj45_done; - -ok_taskfunc_sfp_handle_1g_rj45_link_down: - if (task_p->p_data) { - kfree(task_p->p_data); - task_p->p_data = NULL; - } - task_p->transvr_p->info = TRANSVR_CLASS_BASE_T_1000; - goto ok_taskfunc_sfp_handle_1g_rj45_done; - -ok_taskfunc_sfp_handle_1g_rj45_done: - if (task_p->retry != VAL_TRANSVR_TASK_RETRY_FOREVER) { - transvr_task_set_retry(task_p, VAL_TRANSVR_TASK_RETRY_FOREVER); - } - return EVENT_TRANSVR_TASK_DONE; - -err_taskfunc_sfp_handle_1g_rj45_1: - snprintf(err_str, sizeof(err_str), "Detect transceiver:%d not Base-T, remove task.", - task_p->transvr_p->info); - SWPS_INFO("%s: %s :%s\n", __func__, err_str, task_p->transvr_p->swp_name); - transvr_task_set_retry(task_p, 0); - return EVENT_TRANSVR_TASK_DONE; - -err_taskfunc_sfp_handle_1g_rj45_2: - if (task_p->retry == VAL_TRANSVR_TASK_RETRY_FOREVER) { - transvr_task_set_retry(task_p, fail_retry); - } - if ((task_p->retry) == 0) { - /* Error case: - * => In this case, SWPS will stop external Link state monitor features - * and keeps transvr_p->info on TRANSVR_CLASS_BASE_T_1000_up. - * Upper layer will see it always Linkup that because of these type of - * transceiver has external phy, BCM chip see it as Loopback transceiver. - */ - SWPS_WARN("%s can not access external PHY of Base-T SFP transceiver\n", - task_p->transvr_p->swp_name); - task_p->transvr_p->info = TRANSVR_CLASS_BASE_T_1000_up; - return EVENT_TRANSVR_TASK_DONE; - } else { - transvr_task_set_delay(task_p, fail_delay); - } - return EVENT_TRANSVR_TASK_FAIL; -} - - -int -_taskfunc_qsfp_setup_power_mod(struct transvr_obj_s *self, - int setup_val) { - - int curr_val = DEBUG_TRANSVR_INT_VAL; - int err_val = DEBUG_TRANSVR_INT_VAL; - char *err_msg = DEBUG_TRANSVR_STR_VAL; - - curr_val = self->ioexp_obj_p->get_lpmod(self->ioexp_obj_p, - self->ioexp_virt_offset); - if (curr_val < 0){ - err_msg = "Get current value fail!"; - goto err_private_taskfunc_qsfp_setup_power_mod_1; - } - if (curr_val == setup_val){ - return EVENT_TRANSVR_TASK_DONE; - } - err_val = self->ioexp_obj_p->set_lpmod(self->ioexp_obj_p, - self->ioexp_virt_offset, - setup_val); - if (err_val < 0){ - err_msg = "Setup power mode fail!"; - goto err_private_taskfunc_qsfp_setup_power_mod_1; - } - return EVENT_TRANSVR_TASK_DONE; - -err_private_taskfunc_qsfp_setup_power_mod_1: - SWPS_INFO("%s: %s :%d :%d :%d\n", - __func__, err_msg, err_val, curr_val, setup_val); - return EVENT_TRANSVR_TASK_FAIL; -} - - -int -taskfunc_qsfp_handle_tx_disable(struct transvr_worker_s *task_p) { - - int i = 0; - int retry = 5; - int delay_ms = 100; - - if (task_p->transvr_p->auto_tx_disable == VAL_TRANSVR_FUNCTION_DISABLE) { - return EVENT_TRANSVR_TASK_DONE; - } - if (!_qsfp_is_implement_tx_disable(task_p->transvr_p)) { - return EVENT_TRANSVR_TASK_DONE; - } - for (i=0; itransvr_p, - task_p->transvr_p->auto_tx_disable) - == EVENT_TRANSVR_TASK_DONE) { - goto ok_taskfunc_qsfp_handle_tx_disable; - } - mdelay(delay_ms); - } - SWPS_INFO("%s auto setup tx_disable:0x%02x fail.\n", - task_p->transvr_p->swp_name, - task_p->transvr_p->auto_tx_disable); - return EVENT_TRANSVR_INIT_FAIL; - -ok_taskfunc_qsfp_handle_tx_disable: - SWPS_INFO("%s auto setup tx_disable:0x%02x ok.\n", - task_p->transvr_p->swp_name, - task_p->transvr_p->auto_tx_disable); - return EVENT_TRANSVR_TASK_DONE; -} - - -int -taskfunc_qsfp_set_hpmod(struct transvr_worker_s *task_p) { - - int err = DEBUG_TRANSVR_INT_VAL; - int HIGH_POWER_MODE = 0; - - /* Handle power mode */ - err = _taskfunc_qsfp_setup_power_mod(task_p->transvr_p, - HIGH_POWER_MODE); - if (err < 0) { - SWPS_INFO("%s: setup hpmod fail :%d :%s\n", - __func__, err, task_p->transvr_p->swp_name); - return err; - } - /* Handle auto tx_disable - * [Note] - * => Because there are some transceiver have timing issues or - * setup sequence issues, therefore we handle auto tx_disable - * after handle power mode. - */ - mdelay(100); - return taskfunc_qsfp_handle_tx_disable(task_p); -} - - -int -taskfunc_qsfp_set_lpmod(struct transvr_worker_s *task_p) { - - int LOW_POWER_MODE = 1; - return _taskfunc_qsfp_setup_power_mod(task_p->transvr_p, - LOW_POWER_MODE); -} - - -static int -initfunc_sfp_handle_multi_rate_mode(struct transvr_obj_s *self) { - - int task_retry = 3; - int err_code = DEBUG_TRANSVR_INT_VAL; - char *err_str = DEBUG_TRANSVR_STR_VAL; - char *func_str = "sfp_handle_multi_rate_mode"; - struct transvr_worker_s *task_p = NULL; - - switch (self->rate_id) { - case 0x00: /* Unspecified */ - case 0x03: /* Unspecified */ - case 0x05: /* Unspecified */ - case 0x07: /* Unspecified */ - case 0x09: /* Unspecified */ - case 0x0B: /* Unspecified */ - case 0x0D: /* Unspecified */ - case 0x0F: /* Unspecified */ - goto sfp_handle_multi_rate_mode_4_unspecified; - - case 0x02: /* SFF-8431 (8/4/2G Rx Rate_Select only) */ - task_p = transvr_task_creat(self, - taskfunc_sfp_setup_SFF8431_case1, - taskfunc_post_handle_task_state, - func_str); - goto sfp_handle_multi_rate_mode_4_sff8431; - - case 0x04: /* SFF-8431 (8/4/2G Tx Rate_Select only) */ - task_p = transvr_task_creat(self, - taskfunc_sfp_setup_SFF8431_case2, - taskfunc_post_handle_task_state, - func_str); - goto sfp_handle_multi_rate_mode_4_sff8431; - - case 0x06: /* SFF-8431 (8/4/2G Independent Rx & Tx Rate_select) */ - task_p = transvr_task_creat(self, - taskfunc_sfp_setup_SFF8431_case3, - taskfunc_post_handle_task_state, - func_str); - goto sfp_handle_multi_rate_mode_4_sff8431; - - case 0x01: /* SFF-8079 (4/2/1G Rate_Select & AS0/AS1) */ - err_str = "SFF-8079 (4/2/1G Rate_Select & AS0/AS1)"; - goto sfp_handle_multi_rate_mode_4_not_support; - - case 0x08: /* FC-PI-5 (16/8/4G Rx Rate_select only) - * High=16G only, Low=8G/4G - */ - err_str = "FC-PI-5 (16/8/4G Rx Rate_select only)"; - goto sfp_handle_multi_rate_mode_4_not_support; - - case 0x0A: /* FC-PI-5 (16/8/4G Independent Rx, Tx Rate_select) - * High=16G only, Low=8G/4G - */ - err_str = "FC-PI-5 (16/8/4G Independent Rx, Tx Rate_select)"; - goto sfp_handle_multi_rate_mode_4_not_support; - - case 0x0C: /* FC-PI-6 (32/16/8G Independent Rx, Tx Rate_Select) - * High=32G only, Low = 16G/8G - */ - err_str = "FC-PI-6 (32/16/8G Independent Rx, Tx Rate_Select)"; - goto sfp_handle_multi_rate_mode_4_not_support; - - case 0x0E: /* 10/8G Rx and Tx Rate_Select controlling the operation or - * locking modes of the internal signal conditioner, retimer - * or CDR, according to the logic table defined in Table 10-2, - * High Bit Rate (10G) =9.95-11.3 Gb/s; Low Bit Rate (8G) = - * 8.5 Gb/s. In this mode, the default value of bit 110.3 (Soft - * Rate Select RS(0), Table 9-11) and of bit 118.3 (Soft Rate - * Select RS(1), Table 10-1) is 1. - */ - err_str = "cable type: 0x0E"; - goto sfp_handle_multi_rate_mode_4_not_support; - - default: - err_str = "cable type: UNKNOW"; - goto sfp_handle_multi_rate_mode_4_not_support; - } - -sfp_handle_multi_rate_mode_4_sff8431: - if (!task_p) { - err_str = "Create task fail!"; - goto sfp_handle_multi_rate_mode_4_fail_1; - } - transvr_task_set_retry(task_p, task_retry); - return EVENT_TRANSVR_TASK_WAIT; - -sfp_handle_multi_rate_mode_4_unspecified: - return EVENT_TRANSVR_TASK_DONE; - -sfp_handle_multi_rate_mode_4_not_support: - SWPS_INFO("%s: Does not support %s :%s :0x%02x\n", - func_str, err_str, self->swp_name, self->rate_id); - return EVENT_TRANSVR_TASK_DONE; - -sfp_handle_multi_rate_mode_4_fail_1: - SWPS_INFO("%s: %s :%s :0x%02x, :%d\n", - func_str, err_str, self->swp_name, self->rate_id, err_code); - return EVENT_TRANSVR_INIT_FAIL; -} - - -static int -initfunc_sfp_handle_1g_rj45(struct transvr_obj_s *self) { - - struct transvr_worker_s *task_p = NULL; - int detect_cls = DEBUG_TRANSVR_INT_VAL; - char err_str[64] = DEBUG_TRANSVR_STR_VAL; - char *func_str = "initfunc_sfp_handle_1g_rj45"; - - - if (self->info == TRANSVR_CLASS_BASE_T_1000) { - task_p = transvr_task_creat(self, - taskfunc_sfp_handle_1g_rj45, - taskfunc_post_do_nothing, - func_str); - if (!task_p) { - snprintf(err_str, sizeof(err_str), "Create task fail"); - goto err_initfunc_sfp_handle_1g_rj45; - } - transvr_task_set_retry(task_p, VAL_TRANSVR_TASK_RETRY_FOREVER); - } - return EVENT_TRANSVR_TASK_DONE; - -err_initfunc_sfp_handle_1g_rj45: - SWPS_INFO("%s: %s :%s :%d\n", - __func__, err_str, self->swp_name, detect_cls); - return EVENT_TRANSVR_TASK_FAIL; -} - - -static int -initfunc_qsfp_handle_power_mode(struct transvr_obj_s *self) { - - int err_code = EVENT_TRANSVR_EXCEP_INIT; - int power_class = DEBUG_TRANSVR_INT_VAL; - int hpmod_retry = 3; - int lpower_config = 1; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - unsigned long hpmod_delay = 500; /* msec */ - struct transvr_worker_s *task_p = NULL; - - /* Handle power mode for IOEXP */ - power_class = __qsfp_get_power_cls(self, 0); - switch (power_class) { - case 1: /* Case: Low power mode (Class = 1) */ - err_code = _taskfunc_qsfp_setup_power_mod(self, lpower_config); - if (err_code < 0){ - snprintf(err_msg, sizeof(err_msg), "Setup lpmod fail :%d", err_code); - goto err_initfunc_qsfp_handle_power_mode; - } - return EVENT_TRANSVR_TASK_DONE; - - case 2: /* Case: High power mode (Class > 1) */ - case 3: - case 4: - case 5: - case 6: - case 7: - task_p = transvr_task_creat(self, - taskfunc_qsfp_set_hpmod, - taskfunc_post_handle_task_state, - "transvr_init_qsfp"); - if (!task_p) { - snprintf(err_msg, sizeof(err_msg), "Setup lpmod fail :%d", err_code); - goto err_initfunc_qsfp_handle_power_mode; - } - transvr_task_set_retry(task_p, hpmod_retry); - transvr_task_set_delay(task_p, hpmod_delay); - return EVENT_TRANSVR_TASK_WAIT; - - default: - break; - } - snprintf(err_msg, sizeof(err_msg), "Exception case"); - goto err_initfunc_qsfp_handle_power_mode; - -err_initfunc_qsfp_handle_power_mode: - SWPS_INFO("%s: %s :%s \n", __func__, err_msg, self->swp_name); - return EVENT_TRANSVR_INIT_FAIL; -} - - -int -initfunc_qsfp28_handle_cdr(struct transvr_obj_s *self) { - - uint8_t DEFAULT_VAL_CDR = 0xff; - int CDR_FUNC_EXISTED = 0x3; - int show_err = 1; - int err_val = EVENT_TRANSVR_TASK_FAIL; - char *err_msg = DEBUG_TRANSVR_STR_VAL; - char *func_str = "initfunc_qsfp28_handle_cdr"; - - err_val = __qsfp_get_cdr_present(self, 0); - if ( (err_val < 0) || - (err_val == DEBUG_TRANSVR_HEX_VAL) ) { - err_msg = "detect cdr_present fail!"; - goto err_taskfunc_qsfp_handle_cdr_1; - } - if (err_val == CDR_FUNC_EXISTED) { - err_val = _common_set_uint8_attr(self, - self->eeprom_map_p->addr_cdr, - self->eeprom_map_p->addr_cdr, - self->eeprom_map_p->offset_cdr, - DEFAULT_VAL_CDR, - &(self->cdr), - func_str, - show_err); - if (err_val < 0) { - err_msg = "set CDR fail!"; - goto err_taskfunc_qsfp_handle_cdr_1; - } - } - return EVENT_TRANSVR_TASK_DONE; - -err_taskfunc_qsfp_handle_cdr_1: - SWPS_INFO("%s: %s :%d :%s\n", - func_str, err_msg, err_val, self->swp_name); - return EVENT_TRANSVR_INIT_FAIL; -} - -/* ========== Object functions for Final State Machine ========== - */ -int -is_plugged(struct transvr_obj_s *self){ - - int limit = 63; - int present = DEBUG_TRANSVR_INT_VAL; - char emsg[64] = DEBUG_TRANSVR_STR_VAL; - struct ioexp_obj_s *ioexp_p = self->ioexp_obj_p; - - if (!ioexp_p) { - snprintf(emsg, limit, "ioexp_p is null!"); - goto err_is_plugged_1; - } - present = ioexp_p->get_present(ioexp_p, self->ioexp_virt_offset); - switch (present){ - case 0: - return 1; - case 1: - return 0; - case ERR_IOEXP_UNINIT: - snprintf(emsg, limit, "ioexp_p not ready!"); - goto err_is_plugged_1; - default: - if (ioexp_p->state == STATE_IOEXP_INIT){ - snprintf(emsg, limit, "ioexp_p not ready!"); - goto err_is_plugged_1; - } - break; - } - SWPS_INFO("%s: Exception case! :%d :%d\n", - __func__, present, ioexp_p->state); - return 0; - -err_is_plugged_1: - SWPS_DEBUG("%s: %s\n", __func__, emsg); - return 0; -} - - -static int -detect_transvr_type(struct transvr_obj_s* self){ - - int type = TRANSVR_TYPE_ERROR; - - self->i2c_client_p->addr = VAL_TRANSVR_COMID_ARREESS; - type = i2c_smbus_read_byte_data(self->i2c_client_p, - VAL_TRANSVR_COMID_OFFSET); - - /* Case: 1. Wait transceiver I2C module. - * 2. Transceiver I2C module failure. - * Note: 1. SFF allow maximum transceiver initial time is 2 second. So, there - * are exist some case that we need to wait transceiver. - * For these case, we keeps status on "TRANSVR_TYPE_UNPLUGGED", than - * state machine will keep trace with it. - * 2. There exist some I2C failure case we need to handle. Such as user - * insert the failure transceiver, or any reason cause it abnormal. - */ - if (type < 0){ - switch (type) { - case -EIO: - SWPS_DEBUG("%s: %s smbus return:-5 (I/O error)\n", - __func__, self->swp_name); - return TRANSVR_TYPE_UNPLUGGED; - case -ENXIO: - SWPS_DEBUG("%s: %s smbus return:-6 (No such device or address)\n", - __func__, self->swp_name); - return TRANSVR_TYPE_UNPLUGGED; - default: - break; - } - SWPS_INFO("%s: %s unexpected smbus return:%d \n", - __func__, self->swp_name, type); - return TRANSVR_TYPE_ERROR; - } - /* Identify valid transceiver type */ - switch (type){ - case TRANSVR_TYPE_SFP: - case TRANSVR_TYPE_QSFP: - case TRANSVR_TYPE_QSFP_PLUS: - case TRANSVR_TYPE_QSFP_28: - break; - case TRANSVR_TYPE_UNKNOW_1: - case TRANSVR_TYPE_UNKNOW_2: - type = TRANSVR_TYPE_UNKNOW_2; - break; - default: - SWPS_DEBUG("%s: unknow type:0x%02x \n", __func__, type); - type = TRANSVR_TYPE_ERROR; - break; - } - return type; -} - - -static int -detect_transvr_state(struct transvr_obj_s *self, - int result[2]){ - /* [return] [result-0] [result-1] - * 0 STATE_TRANSVR_CONNECTED TRANSVR_TYPE_FAKE - * 0 STATE_TRANSVR_DISCONNECTED TRANSVR_TYPE_UNPLUGGED - * 0 STATE_TRANSVR_ISOLATED TRANSVR_TYPE_ERROR - * 0 STATE_TRANSVR_INIT / - * 0 STATE_TRANSVR_SWAPPED - * 0 STATE_TRANSVR_CONNECTED - * ERR_TRNASVR_BE_ISOLATED STATE_TRANSVR_ISOLATED TRANSVR_TYPE_ERROR - * ERR_TRANSVR_I2C_CRASH STATE_TRANSVR_UNEXCEPTED TRANSVR_TYPE_ERROR - * ERR_TRANSVR_UNEXCPT STATE_TRANSVR_UNEXCEPTED TRANSVR_TYPE_UNKNOW_1/2 - */ - result[0] = STATE_TRANSVR_UNEXCEPTED; /* For return state */ - result[1] = TRANSVR_TYPE_ERROR; /* For return type */ - - /* Case1: Fake type */ - if (self->type == TRANSVR_TYPE_FAKE){ - result[0] = STATE_TRANSVR_CONNECTED; - result[1] = TRANSVR_TYPE_FAKE; - return 0; - } - /* Case2: Transceiver unplugged */ - if (!is_plugged(self)){ - result[0] = STATE_TRANSVR_DISCONNECTED; - result[1] = TRANSVR_TYPE_UNPLUGGED; - return 0; - } - /* Case3: Transceiver be isolated */ - if (self->state == STATE_TRANSVR_ISOLATED){ - result[0] = STATE_TRANSVR_ISOLATED; - result[1] = TRANSVR_TYPE_ERROR; - return ERR_TRNASVR_BE_ISOLATED; - } - /* Case4: Transceiver plugged */ - result[1] = detect_transvr_type(self); - /* Case4.1: I2C topology crash - * Note : There are some I2C issues cause by transceiver/cables. - * We need to check topology status when user insert it. - * But in this step, we can't not ensure this is the issues - * port. So, it return the ERR_TRANSVR_I2C_CRASH, then upper - * layer will diagnostic I2C topology. - */ - if (check_channel_tier_1() < 0) { - SWPS_INFO("%s: %s detect I2C crash :%d\n", - __func__, self->swp_name, self->state); - result[0] = STATE_TRANSVR_UNEXCEPTED; - result[1] = TRANSVR_TYPE_ERROR; - return ERR_TRANSVR_I2C_CRASH; - } - /* Case4.2: System initial not ready, - * Note : Sometime i2c channel or transceiver EEPROM will delay that will - * cause system in inconsistent state between EEPROM and IOEXP. - * In this case, SWP transceiver object keep state at LINK_DOWN - * to wait system ready. - * By the way, State Machine will handle these case. - */ - if (result[1] == TRANSVR_TYPE_UNPLUGGED){ - result[0] = STATE_TRANSVR_DISCONNECTED; - return 0; - } - /* Case4.3: Error transceiver type */ - if (result[1] == TRANSVR_TYPE_ERROR){ - result[0] = STATE_TRANSVR_ISOLATED; - SWPS_INFO("%s: %s detect error type\n", __func__, self->swp_name); - alarm_msg_2_user(self, "detected transceiver/cables not meet SFF standard!"); - return ERR_TRNASVR_BE_ISOLATED; - } - /* Case3.3: Unknow transceiver type */ - if ((result[1] == TRANSVR_TYPE_UNKNOW_1) || - (result[1] == TRANSVR_TYPE_UNKNOW_2) ){ - result[0] = STATE_TRANSVR_UNEXCEPTED; - return ERR_TRANSVR_UNEXCPT; - } - /* Case3.4: During initial process */ - if (self->state == STATE_TRANSVR_INIT){ - result[0] = STATE_TRANSVR_INIT; - return 0; - } - /* Case3.5: Transceiver be swapped */ - if (self->type != result[1]){ - result[0] = STATE_TRANSVR_SWAPPED; - return 0; - } - /* Case3.6: Link up state */ - result[0] = STATE_TRANSVR_CONNECTED; - return 0; -} - - -int -_sfp_detect_class_by_extend_comp(struct transvr_obj_s* self) { - /* Reference: SFF-8024 (v3.8) - */ - int detect_val = _sfp_get_comp_extended(self); - - switch(detect_val) { - case 0x00: /* Unspecified */ - return TRANSVR_CLASS_UNSPECIFIED; - - case 0x01: /* 100G AOC (Active Optical Cable) or 25GAUI C2M */ - case 0x18: /* 100G AOC or 25GAUI C2M AOC. */ - return TRANSVR_CLASS_OPTICAL_25G_AOC; - - case 0x02: /* 100GBASE-SR4 or 25GBASE-SR */ - return TRANSVR_CLASS_OPTICAL_25G_SR; - - case 0x03: /* 100GBASE-LR4 or 25GBASE-LR */ - return TRANSVR_CLASS_OPTICAL_25G_LR; - - case 0x04: /* 100GBASE-ER4 or 25GBASE-ER */ - return TRANSVR_CLASS_OPTICAL_25G_ER; - - case 0x08: /* 100G ACC (Active Copper Cable) or 25GAUI C2M ACC. */ - case 0x0b: /* 100GBASE-CR4 or 25GBASE-CR CA-L */ - case 0x0c: /* 25GBASE-CR CA-S */ - case 0x0d: /* 25GBASE-CR CA-N */ - case 0x19: /* 100G ACC or 25GAUI C2M ACC. */ - return TRANSVR_CLASS_COPPER_L1_25G; - - default: - break; - } - SWPS_INFO("%s: Unexcept value:0x%02x\n :%s", - __func__, detect_val, self->swp_name); - return TRANSVR_CLASS_ERROR; -} - - -int -_sfp_detect_class_by_10_ethernet(struct transvr_obj_s* self) { - /* Reference: SFF-8472 (v12.2) - */ - int detect_val = DEBUG_TRANSVR_INT_VAL; - - detect_val = _sfp_get_comp_10g_eth_comp(self); - /* Case: Unspecified */ - if (detect_val == 0x00) { - return TRANSVR_CLASS_UNSPECIFIED; - } - /* Case: 10G Optical (x1) */ - if ((detect_val & 0x10) == 0x10) { /* 00010000 : 10GBASE-SR */ - return TRANSVR_CLASS_OPTICAL_10G_S_SR; - } - if ( ((detect_val & 0x20) == 0x20) || /* 00100000 : 10GBASE-LR */ - ((detect_val & 0x40) == 0x40) ){ /* 01000000 : 10GBASE-LRM */ - return TRANSVR_CLASS_OPTICAL_10G_S_LR; - } - if ((detect_val & 0x80) == 0x80) { /* 10000000 : 10GBASE-ER */ - return TRANSVR_CLASS_OPTICAL_10G_S_ER; - } - /* Case: ERROR */ - SWPS_INFO("%s: Unexcept value:0x%02x\n :%s", - __func__, detect_val, self->swp_name); - return TRANSVR_CLASS_ERROR; -} - - -int -_sfp_detect_if_sp_by_br(struct transvr_obj_s* self) { - - int lower_bound_1g = 0x0b; - int upper_bound_1g = 0x1A; - int lower_bound_10g = 0x60; - int upper_bound_10g = 0x75; - int lower_bound_25g = 0xf0; - int upper_bound_25g = 0xff; - int notmal_br = DEBUG_TRANSVR_INT_VAL; - - notmal_br = (int)(self->br); /* updated by update_all() */ - /* Check 25G */ - if ((notmal_br >= lower_bound_25g) && - (notmal_br <= upper_bound_25g) ) { - return TRANSVR_CLASS_25G; - } - /* Check 10G */ - if ((notmal_br >= lower_bound_10g) && - (notmal_br <= upper_bound_10g) ) { - return TRANSVR_CLASS_10G; - } - /* Check 1G */ - if ((notmal_br >= lower_bound_1g) && - (notmal_br <= upper_bound_1g) ) { - return TRANSVR_CLASS_1G; - } - return TRANSVR_CLASS_UNSPECIFIED; -} - - -int -_sfp_detect_class_by_1g_ethernet(struct transvr_obj_s* self) { - /* Reference: SFF-8472 (v12.2) - */ - int detect_val = DEBUG_TRANSVR_INT_VAL; - int speed_br = DEBUG_TRANSVR_INT_VAL; - int speed_tmp = DEBUG_TRANSVR_INT_VAL; - char err_str[64] = DEBUG_TRANSVR_STR_VAL; - - speed_br = _sfp_detect_if_sp_by_br(self); - detect_val = _sfp_get_comp_1g_eth_comp(self); - - if (detect_val < 0) { - snprintf(err_str, sizeof(err_str), "Detect abnormal value:%d", detect_val); - goto err_p_sfp_detect_class_by_1g_ethernet; - } - /* Case: Unspecified */ - if (detect_val == 0x00) { - return TRANSVR_CLASS_UNSPECIFIED; - } - /* Case: 1G (x1) */ - if ((detect_val & 0x01) == 0x01) { /* 00000001 : 1000BASE-SX */ - speed_tmp = TRANSVR_CLASS_OPTICAL_1G_SX; - goto ok_sfp_detect_class_by_1g_ethernet_4_check_br_10g; - } - if ((detect_val & 0x02) == 0x02) { /* 00000010 : 1000BASE-LX *3 */ - speed_tmp = TRANSVR_CLASS_OPTICAL_1G_LX; - goto ok_sfp_detect_class_by_1g_ethernet_4_check_br_10g; - } - if ((detect_val & 0x04) == 0x04) { /* 00000100 : 1000BASE-CX */ - speed_tmp = TRANSVR_CLASS_COPPER_L1_1G; - goto ok_sfp_detect_class_by_1g_ethernet_4_check_br_10g; - } - /* Case: 1000 Base-T (x1) */ - if ((detect_val & 0x08) == 0x08) { /* 00001000 : 1000BASE-T */ - return TRANSVR_CLASS_BASE_T_1000; - } - /* Case: 100 Base */ - if ( ((detect_val & 0x10) == 0x10) || /* 00010000 : 100BASE-LX/LX10 */ - ((detect_val & 0x20) == 0x20) || /* 00100000 : 100BASE-FX */ - ((detect_val & 0x40) == 0x40) || /* 01000000 : BASE-BX10 *3 */ - ((detect_val & 0x80) == 0x80) ){ /* 10000000 : BASE-PX *3 */ - return TRANSVR_CLASS_OPTICAL_100; - } - /* Case: ERROR */ - snprintf(err_str, sizeof(err_str), "Case:ERROR, value:%d", detect_val); - goto err_p_sfp_detect_class_by_1g_ethernet; - -ok_sfp_detect_class_by_1g_ethernet_4_check_br_10g: - switch (speed_br) { - case TRANSVR_CLASS_UNSPECIFIED: - case TRANSVR_CLASS_1G: - return speed_tmp; - case TRANSVR_CLASS_10G: - goto ok_sfp_detect_class_by_1g_ethernet_4_transfer_10G; - } - -ok_sfp_detect_class_by_1g_ethernet_4_transfer_10G: - switch (speed_tmp) { - case TRANSVR_CLASS_OPTICAL_1G_SX: - return TRANSVR_CLASS_OPTICAL_10G_S_SR; - case TRANSVR_CLASS_OPTICAL_1G_LX: - return TRANSVR_CLASS_OPTICAL_10G_S_LR; - case TRANSVR_CLASS_COPPER_L1_1G: - return TRANSVR_CLASS_COPPER_L1_10G; - default: - break; - } - snprintf(err_str, sizeof(err_str), "transfer_1to10 fail, speed:%d", speed_tmp); - goto err_p_sfp_detect_class_by_1g_ethernet; - -err_p_sfp_detect_class_by_1g_ethernet: - SWPS_INFO("%s: %s :%s", __func__, err_str, self->swp_name); - return TRANSVR_CLASS_ERROR; -} - - -int -_sfp_detect_class_by_feature(struct transvr_obj_s* self) { - /* Reference: SFF-8024 (v3.8) - */ - int is_active = 0; - int conn_val = DEBUG_TRANSVR_INT_VAL; - int check_val = DEBUG_TRANSVR_INT_VAL; - int wave_len = DEBUG_TRANSVR_INT_VAL; - int speed_val = DEBUG_TRANSVR_INT_VAL; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - - speed_val = _sfp_detect_if_sp_by_br(self); - conn_val = _sfp_get_connector_type(self); - - switch(conn_val) { - case 0x00: /* Unspecified */ - goto ok_sfp_detect_class_by_feature_4_check_active_passive; - case 0x07: /* LC (Lucent Connector) */ - case 0x0b: /* Optical Pigtail */ - case 0x0c: /* MPO 1x12 */ - case 0x0d: /* MPO 2x16 */ - /* - * ToDo: Need verify Optical Pigtail - */ - goto ok_sfp_detect_class_by_feature_4_optiocal; - case 0x21: /* Copper pigtail */ - /* - * ToDo: Need check ACC use case - */ - goto ok_sfp_detect_class_by_feature_4_check_active_passive; - case 0x23: /* No separable connector */ - /* - * ToDo: Standard not clear, not all transceiver vendor - * have the same defined - */ - goto ok_sfp_detect_class_by_feature_4_check_active_passive; - default: - break; - } - goto ok_sfp_detect_class_by_feature_4_unknow; - -ok_sfp_detect_class_by_feature_4_check_active_passive: - check_val = _sfp_get_cable_tech(self); - switch(check_val) { - case 0x00: /* Unspecified */ - goto ok_sfp_detect_class_by_feature_4_unknow; - case 0x04: /* Passive */ - goto ok_sfp_detect_class_by_feature_4_copper; - case 0x08: /* Active */ - is_active = 1; - goto ok_sfp_detect_class_by_feature_4_aoc; - default: - snprintf(err_msg, sizeof(err_msg), - "_sfp_get_cable_tech return Non define value:%d", - check_val); - break; - } - goto err_sfp_detect_class_by_feature_1; - -ok_sfp_detect_class_by_feature_4_optiocal: - wave_len = _common_count_wavelength(self, - self->wavelength[0], - self->wavelength[1]); - switch(speed_val) { - case TRANSVR_CLASS_25G: - switch (wave_len) { - case VAL_OPTICAL_WAVELENGTH_SR: - return TRANSVR_CLASS_OPTICAL_25G_SR; - case VAL_OPTICAL_WAVELENGTH_LR: - return TRANSVR_CLASS_OPTICAL_25G_LR; - case VAL_OPTICAL_WAVELENGTH_ER: - return TRANSVR_CLASS_OPTICAL_25G_ER; - default: - break; - } - return TRANSVR_CLASS_OPTICAL_25G; - - case TRANSVR_CLASS_10G: - switch (wave_len) { - case VAL_OPTICAL_WAVELENGTH_SR: - return TRANSVR_CLASS_OPTICAL_10G_S_SR; - case VAL_OPTICAL_WAVELENGTH_LR: - return TRANSVR_CLASS_OPTICAL_10G_S_LR; - case VAL_OPTICAL_WAVELENGTH_ER: - return TRANSVR_CLASS_OPTICAL_10G_S_ER; - default: - break; - } - return TRANSVR_CLASS_OPTICAL_10G; - - case TRANSVR_CLASS_1G: - switch (wave_len) { - case VAL_OPTICAL_WAVELENGTH_SR: - return TRANSVR_CLASS_OPTICAL_1G_SX; - case VAL_OPTICAL_WAVELENGTH_LR: - return TRANSVR_CLASS_OPTICAL_1G_LX; - case VAL_OPTICAL_WAVELENGTH_ER: - return TRANSVR_CLASS_OPTICAL_1G_EX; - default: - break; - } - return TRANSVR_CLASS_OPTICAL_1G; - - default: - return TRANSVR_CLASS_OPTICAL; - } - -ok_sfp_detect_class_by_feature_4_aoc: - switch(speed_val) { - case TRANSVR_CLASS_25G: - return TRANSVR_CLASS_OPTICAL_25G_AOC; - case TRANSVR_CLASS_10G: - return TRANSVR_CLASS_OPTICAL_10G_S_AOC; - case TRANSVR_CLASS_1G: - return TRANSVR_CLASS_OPTICAL_1G_AOC; - default: - break; - } - goto ok_sfp_detect_class_by_feature_4_unknow; - -ok_sfp_detect_class_by_feature_4_copper: - switch(speed_val) { - case TRANSVR_CLASS_25G: - return TRANSVR_CLASS_COPPER_L1_25G; - case TRANSVR_CLASS_10G: - return TRANSVR_CLASS_COPPER_L1_10G; - case TRANSVR_CLASS_1G: - return TRANSVR_CLASS_COPPER_L1_1G; - default: - return TRANSVR_CLASS_COPPER; - } - -ok_sfp_detect_class_by_feature_4_unknow: - return TRANSVR_CLASS_UNSPECIFIED; - -err_sfp_detect_class_by_feature_1: - SWPS_INFO("%s: %s\n :%s", __func__, err_msg, self->swp_name); - return TRANSVR_CLASS_ERROR; -} - - -int -sft_detect_transvr_class(struct transvr_obj_s* self) { - - int detect_val = DEBUG_TRANSVR_INT_VAL; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - - /* Check Extended Compliance */ - detect_val = _sfp_detect_class_by_extend_comp(self); - switch(detect_val) { - case TRANSVR_CLASS_UNSPECIFIED: - break; - case TRANSVR_CLASS_OPTICAL_25G_AOC: - case TRANSVR_CLASS_OPTICAL_25G_SR: - case TRANSVR_CLASS_OPTICAL_25G_LR: - case TRANSVR_CLASS_OPTICAL_25G_ER: - case TRANSVR_CLASS_COPPER_L1_25G: - return detect_val; - default: - snprintf(err_msg, sizeof(err_msg), - "Detect undefined extend_comp:%d", - detect_val); - goto err_sft_detect_transceiver_class_1; - } - /* Check 10G Compliance */ - detect_val = _sfp_detect_class_by_10_ethernet(self); - switch(detect_val) { - case TRANSVR_CLASS_UNSPECIFIED: - break; - case TRANSVR_CLASS_OPTICAL_10G_S_SR: - case TRANSVR_CLASS_OPTICAL_10G_S_LR: - case TRANSVR_CLASS_OPTICAL_10G_S_ER: - return detect_val; - default: - snprintf(err_msg, sizeof(err_msg), - "Detect undefined 10G_eth:%d", - detect_val); - goto err_sft_detect_transceiver_class_1; - } - /* Check 1G Compliance */ - detect_val = _sfp_detect_class_by_1g_ethernet(self); - switch(detect_val) { - case TRANSVR_CLASS_UNSPECIFIED: - break; - case TRANSVR_CLASS_OPTICAL_1G_SX: - case TRANSVR_CLASS_OPTICAL_1G_LX: - case TRANSVR_CLASS_COPPER_L1_1G: - case TRANSVR_CLASS_BASE_T_1000: - case TRANSVR_CLASS_OPTICAL_100: - /* - * ToDo: Need Check 0.1G - */ - case TRANSVR_CLASS_OPTICAL_10G_S_SR: - case TRANSVR_CLASS_OPTICAL_10G_S_LR: - case TRANSVR_CLASS_COPPER_L1_10G: - /* Transfer speed case - * => Example: Raycom 10G DAC - */ - return detect_val; - default: - snprintf(err_msg, sizeof(err_msg), - "Detect undefined 1G_eth:%d", - detect_val); - goto err_sft_detect_transceiver_class_1; - } - /* Check by connector, br, wavelength */ - detect_val = _sfp_detect_class_by_feature(self); - switch(detect_val) { - case TRANSVR_CLASS_UNSPECIFIED: - break; - case TRANSVR_CLASS_OPTICAL: - case TRANSVR_CLASS_OPTICAL_1G: - case TRANSVR_CLASS_OPTICAL_1G_SX: - case TRANSVR_CLASS_OPTICAL_1G_LX: - case TRANSVR_CLASS_OPTICAL_1G_EX: - case TRANSVR_CLASS_OPTICAL_1G_AOC: - case TRANSVR_CLASS_OPTICAL_10G: - case TRANSVR_CLASS_OPTICAL_10G_S_SR: - case TRANSVR_CLASS_OPTICAL_10G_S_LR: - case TRANSVR_CLASS_OPTICAL_10G_S_ER: - case TRANSVR_CLASS_OPTICAL_10G_S_AOC: - case TRANSVR_CLASS_OPTICAL_25G: - case TRANSVR_CLASS_OPTICAL_25G_SR: - case TRANSVR_CLASS_OPTICAL_25G_LR: - case TRANSVR_CLASS_OPTICAL_25G_ER: - case TRANSVR_CLASS_OPTICAL_25G_AOC: - case TRANSVR_CLASS_COPPER: - case TRANSVR_CLASS_COPPER_L1_1G: - case TRANSVR_CLASS_COPPER_L1_10G: - case TRANSVR_CLASS_COPPER_L1_25G: - return detect_val; - default: - snprintf(err_msg, sizeof(err_msg), - "Detect undefined get_connector:%d", - detect_val); - goto err_sft_detect_transceiver_class_1; - } - /* Exception case: Can't verify */ - snprintf(err_msg, sizeof(err_msg), "Can not identify!"); - goto err_sft_detect_transceiver_class_1; - -err_sft_detect_transceiver_class_1: - SWPS_INFO("%s: %s :%s\n", __func__, err_msg, self->swp_name); - return TRANSVR_CLASS_ERROR; -} - - -int -_sfp_set_magnolia_if_type(struct transvr_obj_s* self, - int transvr_cls, - char *result){ - - int lmax = 8; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - - switch(transvr_cls) { - case TRANSVR_CLASS_ERROR: - case TRANSVR_CLASS_UNSPECIFIED: - break; - /* 25G OPTICAL */ - case TRANSVR_CLASS_OPTICAL_25G_AOC: - case TRANSVR_CLASS_OPTICAL_25G_SR: - case TRANSVR_CLASS_OPTICAL_25G_LR: - case TRANSVR_CLASS_OPTICAL_25G_ER: - case TRANSVR_CLASS_OPTICAL_25G: - return snprintf(result, lmax, TRANSVR_IF_SFI); - /* 25G COPPER */ - case TRANSVR_CLASS_COPPER_L1_25G: - return snprintf(result, lmax, TRANSVR_IF_SFI); - /* 10G OPTICAL */ - case TRANSVR_CLASS_OPTICAL_10G_S_AOC: - case TRANSVR_CLASS_OPTICAL_10G_S_SR: - case TRANSVR_CLASS_OPTICAL_10G_S_LR: - case TRANSVR_CLASS_OPTICAL_10G_S_ER: - case TRANSVR_CLASS_OPTICAL_10G: - return snprintf(result, lmax, TRANSVR_IF_SFI); - /* 10G COPPER */ - case TRANSVR_CLASS_COPPER_L1_10G: - return snprintf(result, lmax, TRANSVR_IF_SFI); - /* 1G OPTICAL */ - case TRANSVR_CLASS_OPTICAL_1G_AOC: - case TRANSVR_CLASS_OPTICAL_1G_SX: - case TRANSVR_CLASS_OPTICAL_1G_LX: - case TRANSVR_CLASS_OPTICAL_1G_EX: - case TRANSVR_CLASS_OPTICAL_1G: - return snprintf(result, lmax, TRANSVR_IF_IF_GMII); - /* 1G COPPER */ - case TRANSVR_CLASS_COPPER_L1_1G: - return snprintf(result, lmax, TRANSVR_IF_IF_GMII); - /* 1G BASE_T */ - case TRANSVR_CLASS_BASE_T_1000: - return snprintf(result, lmax, TRANSVR_IF_IF_GMII); - /* 100 Base */ - case TRANSVR_CLASS_OPTICAL_100: - return snprintf(result, lmax, TRANSVR_IF_IF_GMII); - default: - snprintf(err_msg, sizeof(err_msg), - "Detect undefined value:%d", - transvr_cls); - goto err_sfp_set_magnolia_if_type_1; - } - /* Exception case: Can't verify */ - snprintf(err_msg, sizeof(err_msg), "Can not identify!"); - goto err_sfp_set_magnolia_if_type_1; - -err_sfp_set_magnolia_if_type_1: - snprintf(result, lmax, TRANSVR_UEVENT_UNKNOW); - SWPS_INFO("%s: %s :%s\n", __func__, err_msg, self->swp_name); - return ERR_TRANSVR_ABNORMAL; -} - - -int -_sfp_set_redwood_if_type(struct transvr_obj_s* self, - int transvr_cls, - char *result) { - - int lmax = 8; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - - switch(transvr_cls) { - case TRANSVR_CLASS_ERROR: - case TRANSVR_CLASS_UNSPECIFIED: - break; - /* 25G OPTICAL */ - case TRANSVR_CLASS_OPTICAL_25G_AOC: - case TRANSVR_CLASS_OPTICAL_25G_SR: - case TRANSVR_CLASS_OPTICAL_25G_LR: - case TRANSVR_CLASS_OPTICAL_25G_ER: - case TRANSVR_CLASS_OPTICAL_25G: - return snprintf(result, lmax, TRANSVR_IF_SR); - /* 25G COPPER */ - case TRANSVR_CLASS_COPPER_L1_25G: - return snprintf(result, lmax, TRANSVR_IF_KR); - /* 10G OPTICAL */ - case TRANSVR_CLASS_OPTICAL_10G_S_AOC: - case TRANSVR_CLASS_OPTICAL_10G_S_SR: - case TRANSVR_CLASS_OPTICAL_10G_S_LR: - case TRANSVR_CLASS_OPTICAL_10G_S_ER: - case TRANSVR_CLASS_OPTICAL_10G: - return snprintf(result, lmax, TRANSVR_IF_SFI); - /* 10G COPPER */ - case TRANSVR_CLASS_COPPER_L1_10G: - return snprintf(result, lmax, TRANSVR_IF_SFI); - /* 1G OPTICAL */ - case TRANSVR_CLASS_OPTICAL_1G_AOC: - case TRANSVR_CLASS_OPTICAL_1G_SX: - case TRANSVR_CLASS_OPTICAL_1G_LX: - case TRANSVR_CLASS_OPTICAL_1G_EX: - case TRANSVR_CLASS_OPTICAL_1G: - return snprintf(result, lmax, TRANSVR_IF_IF_GMII); - /* 1G COPPER */ - case TRANSVR_CLASS_COPPER_L1_1G: - return snprintf(result, lmax, TRANSVR_IF_IF_GMII); - /* 1G BASE_T */ - case TRANSVR_CLASS_BASE_T_1000: - return snprintf(result, lmax, TRANSVR_IF_IF_GMII); - /* 100 Base */ - case TRANSVR_CLASS_OPTICAL_100: - return snprintf(result, lmax, TRANSVR_IF_IF_GMII); - default: - snprintf(err_msg, sizeof(err_msg), - "Detect undefined value:%d", - transvr_cls); - goto err_sfp_set_redwood_if_type_1; - } - /* Exception case: Can't verify */ - snprintf(err_msg, sizeof(err_msg), "Can not identify!"); - goto err_sfp_set_redwood_if_type_1; - -err_sfp_set_redwood_if_type_1: - snprintf(result, lmax, TRANSVR_UEVENT_UNKNOW); - SWPS_INFO("%s: %s\n :%s", __func__, err_msg, self->swp_name); - return ERR_TRANSVR_ABNORMAL; -} - - -int -_sfp_set_lavender_if_type(struct transvr_obj_s* self, - int transvr_cls, - char *result) { - /* (TBD) - * Due to 'LAV' looks like doesn't have interface type. - * We bypass it currently. - */ - int lmax = 8; - return snprintf(result, lmax, TRANSVR_UEVENT_UNKNOW); -} - - -int -_sfp_detect_if_type(struct transvr_obj_s* self, - char *result){ - - int lmax = 8; - int detect_cls = DEBUG_TRANSVR_INT_VAL; - - detect_cls = sft_detect_transvr_class(self); - switch (self->chipset_type) { - case CHIP_TYPE_MAGNOLIA: - return _sfp_set_magnolia_if_type(self, detect_cls, result); - - case CHIP_TYPE_REDWOOD: - return _sfp_set_redwood_if_type(self, detect_cls, result); - - case CHIP_TYPE_LAVENDER: - return _sfp_set_lavender_if_type(self, detect_cls, result); - - default: - SWPS_INFO("%s: non-defined chipset_type:%d :%s\n", - __func__, self->chipset_type, self->swp_name); - break; - } - snprintf(result, lmax, TRANSVR_UEVENT_UNKNOW); - return ERR_TRANSVR_ABNORMAL; -} - - -int -sfp_get_if_type(struct transvr_obj_s *self, - char *buf_p){ - - int lmax = 16; - char tmp_result[16] = DEBUG_TRANSVR_STR_VAL; - - if (self->state != STATE_TRANSVR_CONNECTED) { - return snprintf(buf_p, lmax, "%d\n", self->state); - } - if (_sfp_detect_if_type(self, tmp_result) < 0) { - return snprintf(buf_p, lmax, "%d\n", ERR_TRANSVR_ABNORMAL); - } - return snprintf(buf_p, lmax, "%s\n", tmp_result); -} - - -int -_sfp_detect_if_speed(struct transvr_obj_s* self, - char *result){ - - int lmax = 16; - int detect_val = DEBUG_TRANSVR_INT_VAL; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - - detect_val = sft_detect_transvr_class(self); - switch(detect_val) { - case TRANSVR_CLASS_ERROR: - case TRANSVR_CLASS_UNSPECIFIED: - break; - /* 25G OPTICAL */ - case TRANSVR_CLASS_OPTICAL_25G_AOC: - case TRANSVR_CLASS_OPTICAL_25G_SR: - case TRANSVR_CLASS_OPTICAL_25G_LR: - case TRANSVR_CLASS_OPTICAL_25G_ER: - case TRANSVR_CLASS_OPTICAL_25G: - return snprintf(result, lmax, TRANSVR_IF_SP_25G); - /* 25G COPPER */ - case TRANSVR_CLASS_COPPER_L1_25G: - return snprintf(result, lmax, TRANSVR_IF_SP_25G); - /* 10G OPTICAL */ - case TRANSVR_CLASS_OPTICAL_10G_S_AOC: - case TRANSVR_CLASS_OPTICAL_10G_S_SR: - case TRANSVR_CLASS_OPTICAL_10G_S_LR: - case TRANSVR_CLASS_OPTICAL_10G_S_ER: - case TRANSVR_CLASS_OPTICAL_10G: - return snprintf(result, lmax, TRANSVR_IF_SP_10G); - /* 10G COPPER */ - case TRANSVR_CLASS_COPPER_L1_10G: - return snprintf(result, lmax, TRANSVR_IF_SP_10G); - /* 1G OPTICAL */ - case TRANSVR_CLASS_OPTICAL_1G_AOC: - case TRANSVR_CLASS_OPTICAL_1G_SX: - case TRANSVR_CLASS_OPTICAL_1G_LX: - case TRANSVR_CLASS_OPTICAL_1G_EX: - case TRANSVR_CLASS_OPTICAL_1G: - return snprintf(result, lmax, TRANSVR_IF_SP_1G); - /* 1G COPPER */ - case TRANSVR_CLASS_COPPER_L1_1G: - return snprintf(result, lmax, TRANSVR_IF_SP_1G); - /* 1G BASE_T */ - case TRANSVR_CLASS_BASE_T_1000: - return snprintf(result, lmax, TRANSVR_IF_SP_1G); - /* 100 Base */ - case TRANSVR_CLASS_OPTICAL_100: - return snprintf(result, lmax, TRANSVR_IF_SP_100); - default: - snprintf(err_msg, sizeof(err_msg), - "Detect undefined value:%d", - detect_val); - goto err_sfp_detect_if_speed_1; - } - /* Check by BR */ - detect_val = _sfp_detect_if_sp_by_br(self); - switch (detect_val) { - case TRANSVR_CLASS_25G: - return snprintf(result, lmax, TRANSVR_IF_SP_25G); - case TRANSVR_CLASS_10G: - return snprintf(result, lmax, TRANSVR_IF_SP_10G); - case TRANSVR_CLASS_1G: - return snprintf(result, lmax, TRANSVR_IF_SP_1G); - default: - break; - } - /* Exception case: Can't verify */ - snprintf(err_msg, sizeof(err_msg), "Can not identify!"); - goto err_sfp_detect_if_speed_1; - -err_sfp_detect_if_speed_1: - snprintf(result, lmax, TRANSVR_UEVENT_UNKNOW); - SWPS_INFO("%s %s\n :%s", __func__, err_msg, self->swp_name); - return ERR_TRANSVR_ABNORMAL; -} - - -int -sfp_get_if_speed(struct transvr_obj_s *self, - char *buf_p){ - - int lmax = 16; - char tmp_result[16] = DEBUG_TRANSVR_STR_VAL; - - if (self->state != STATE_TRANSVR_CONNECTED) { - return snprintf(buf_p, lmax, "%d\n", self->state); - } - if (_sfp_detect_if_speed(self, tmp_result) < 0) { - return snprintf(buf_p, lmax, "%d\n", ERR_TRANSVR_ABNORMAL); - } - return snprintf(buf_p, lmax, "%s\n", tmp_result); -} - - -int -_qsfp_detect_class_by_extend_comp(struct transvr_obj_s* self) { - /* Reference: SFF-8024 (v3.8) - */ - int detect_val = DEBUG_TRANSVR_INT_VAL; - - detect_val = _qsfp_get_comp_extended(self); - switch(detect_val) { - case 0x00: /* Unspecified */ - return TRANSVR_CLASS_UNSPECIFIED; - - case 0x01: /* 100G AOC (Active Optical Cable) or 25GAUI C2M */ - case 0x18: /* 100G AOC or 25GAUI C2M AOC. */ - return TRANSVR_CLASS_OPTICAL_100G_AOC; - - case 0x06: /* 100G CWDM4 */ - case 0x09: /* Obsolete (assigned before 100G CWDM4 MSA required FEC) */ - case 0x17: /* 100G CLR4 */ - case 0x1A: /* 100GE-DWDM2 */ - return TRANSVR_CLASS_OPTICAL_100G; - - case 0x02: /* 100GBASE-SR4 or 25GBASE-SR */ - return TRANSVR_CLASS_OPTICAL_100G_SR4; - - case 0x03: /* 100GBASE-LR4 or 25GBASE-LR */ - return TRANSVR_CLASS_OPTICAL_100G_LR4; - - case 0x04: /* 100GBASE-ER4 or 25GBASE-ER */ - return TRANSVR_CLASS_OPTICAL_100G_ER4; - - case 0x07: /* 100G PSM4 Parallel SMF */ - return TRANSVR_CLASS_OPTICAL_100G_PSM4; - - case 0x12: /* 40G PSM4 Parallel SMF */ - return TRANSVR_CLASS_OPTICAL_40G; - - case 0x11: /* 4 x 10GBASE-SR */ - return TRANSVR_CLASS_OPTICAL_40G_SR4; - - case 0x10: /* 40GBASE-ER4 */ - return TRANSVR_CLASS_OPTICAL_40G_ER4; - - case 0x08: /* 100G ACC (Active Copper Cable) or 25GAUI C2M ACC. */ - case 0x0b: /* 100GBASE-CR4 or 25GBASE-CR CA-L */ - case 0x19: /* 100G ACC or 25GAUI C2M ACC. */ - return TRANSVR_CLASS_COPPER_L4_100G; - - default: - break; - } - SWPS_INFO("%s: Unexcept value:0x%02x\n :%s", - __func__, detect_val, self->swp_name); - return TRANSVR_CLASS_ERROR; -} - - -int -_qsfp_detect_class_by_10_40_100_ethernet(struct transvr_obj_s* self) { - /* Reference: SFF-8472 (v12.2) - */ - int detect_val = DEBUG_TRANSVR_INT_VAL; - - detect_val = _qsfp_get_comp_10_40_100_ethernet(self); - /* Case: Unspecified */ - if (detect_val == 0x00) { - return TRANSVR_CLASS_UNSPECIFIED; - } - /* Case: 40G Optical */ - if ((detect_val & 0x01) == 0x01) { /* 00000001 : 40G Active Cable (XLPPI) */ - return TRANSVR_CLASS_OPTICAL_40G_AOC; - } - if ((detect_val & 0x04) == 0x04) { /* 00000100 : 40GBASE-SR4 */ - return TRANSVR_CLASS_OPTICAL_40G_SR4; - } - if ( (detect_val & 0x02) == 0x02) { /* 00000010 : 40GBASE-LR4 */ - return TRANSVR_CLASS_OPTICAL_40G_LR4; - } - if ( (detect_val & 0x08) == 0x08) { /* 00001000 : 40GBASE-CR4 */ - return TRANSVR_CLASS_COPPER_L4_40G; - } - /* Case: 10G Optical */ - if ( (detect_val & 0x10) == 0x10) { /* 00010000 : 10GBASE-SR */ - return TRANSVR_CLASS_OPTICAL_10G_Q_SR; - } - if ( ((detect_val & 0x20) == 0x20) || /* 00100000 : 10GBASE-LR */ - ((detect_val & 0x40) == 0x40) ){ /* 01000000 : 10GBASE-LRM */ - return TRANSVR_CLASS_OPTICAL_10G_Q_LR; - } - /* Case: Extend Compliance */ - if ( ((detect_val & 0x80) == 0x80) ){ /* 10000000 : Use Extend Compliance */ - return TRANSVR_CLASS_EXTEND_COMP; - } - /* Case: ERROR */ - SWPS_INFO("%s: Unexcept value:0x%02x\n :%s", - __func__, detect_val, self->swp_name); - return TRANSVR_CLASS_ERROR; -} - - -int -_qsfp_detect_if_sp_by_br(struct transvr_obj_s* self) { - - int lower_bound_10g = 0x10; - int upper_bound_10g = 0x25; - int lower_bound_40g = 0x60; - int upper_bound_40g = 0x75; - int lower_bound_100g = 0x60; - int upper_bound_100g = 0x75; - int used_extend_br = 0xff; - int notmal_br = DEBUG_TRANSVR_INT_VAL; - int extend_br = DEBUG_TRANSVR_INT_VAL; - - notmal_br = (int)(self->br); /* updated by update_all() */ - /* Check 40G */ - if ((notmal_br >= lower_bound_40g) && - (notmal_br <= upper_bound_40g) ) { - return TRANSVR_CLASS_40G; - } - /* Check 100G */ - if (notmal_br == used_extend_br) { - extend_br = (int)(self->extbr); /* updated by update_all() */ - if ((extend_br >= lower_bound_100g) && - (extend_br <= upper_bound_100g) ) { - return TRANSVR_CLASS_100G; - } - } - /* Check 10G */ - if ((notmal_br >= lower_bound_10g) && - (notmal_br <= upper_bound_10g) ) { - return TRANSVR_CLASS_10G; - } - return TRANSVR_CLASS_UNSPECIFIED; -} - - -int -_qsfp_detect_class_by_feature(struct transvr_obj_s* self) { - /* Reference: SFF-8024 (v3.8) - */ - int conn_val = DEBUG_TRANSVR_INT_VAL; - int wave_len = DEBUG_TRANSVR_INT_VAL; - int speed_val = DEBUG_TRANSVR_INT_VAL; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - - speed_val = _qsfp_detect_if_sp_by_br(self); - conn_val = _qsfp_get_connector_type(self); - - switch(conn_val) { - case 0x00: /* Unspecified */ - return TRANSVR_CLASS_UNSPECIFIED; - case 0x07: /* LC (Lucent Connector) */ - case 0x0b: /* Optical Pigtail */ - case 0x0c: /* MPO 1x12 (Multifiber Parallel Optic) */ - case 0x0d: /* MPO 2x16 */ - goto ok_qsfp_detect_class_by_feature_4_optiocal; - case 0x21: /* Copper pigtail */ - goto ok_qsfp_detect_class_by_feature_4_copper; - case 0x23: /* No separable connector */ - if ((_qsfp_get_comp_fc_link_length(self) > 0) || - (_qsfp_get_comp_fc_trans_tech(self) > 0) || - (_qsfp_get_comp_fc_trans_media(self) > 0) || - (_qsfp_get_comp_fc_speed(self) > 0) ) { - goto ok_qsfp_detect_class_by_feature_4_aoc; - } - goto ok_qsfp_detect_class_by_feature_4_copper; - default: - snprintf(err_msg, sizeof(err_msg), - "_qsfp_get_connector_type return Non define value:%d", - conn_val); - goto err_qsfp_detect_class_by_feature_1; - } - return TRANSVR_CLASS_UNSPECIFIED; - -ok_qsfp_detect_class_by_feature_4_optiocal: - wave_len = _common_count_wavelength(self, - self->wavelength[0], - self->wavelength[1]); - switch(speed_val) { - case TRANSVR_CLASS_100G: - switch (wave_len) { - case VAL_OPTICAL_WAVELENGTH_SR: - return TRANSVR_CLASS_OPTICAL_100G_SR4; - case VAL_OPTICAL_WAVELENGTH_LR: - return TRANSVR_CLASS_OPTICAL_100G_LR4; - case VAL_OPTICAL_WAVELENGTH_ER: - return TRANSVR_CLASS_OPTICAL_100G_ER4; - default: - break; - } - return TRANSVR_CLASS_OPTICAL_100G; - - case TRANSVR_CLASS_40G: - switch (wave_len) { - case VAL_OPTICAL_WAVELENGTH_SR: - return TRANSVR_CLASS_OPTICAL_40G_SR4; - case VAL_OPTICAL_WAVELENGTH_LR: - return TRANSVR_CLASS_OPTICAL_40G_LR4; - case VAL_OPTICAL_WAVELENGTH_ER: - return TRANSVR_CLASS_OPTICAL_40G_ER4; - default: - break; - } - return TRANSVR_CLASS_OPTICAL_40G; - - case TRANSVR_CLASS_10G: - switch (wave_len) { - case VAL_OPTICAL_WAVELENGTH_SR: - return TRANSVR_CLASS_OPTICAL_10G_Q_SR; - case VAL_OPTICAL_WAVELENGTH_LR: - return TRANSVR_CLASS_OPTICAL_10G_Q_LR; - case VAL_OPTICAL_WAVELENGTH_ER: - return TRANSVR_CLASS_OPTICAL_10G_Q_ER; - default: - break; - } - return TRANSVR_CLASS_OPTICAL_10G; - - default: - return TRANSVR_CLASS_OPTICAL; - } - -ok_qsfp_detect_class_by_feature_4_aoc: - switch(speed_val) { - case TRANSVR_CLASS_100G: - return TRANSVR_CLASS_OPTICAL_100G_AOC; - case TRANSVR_CLASS_40G: - return TRANSVR_CLASS_OPTICAL_40G_AOC; - case TRANSVR_CLASS_10G: - return TRANSVR_CLASS_OPTICAL_10G_Q_AOC; - default: - return TRANSVR_CLASS_OPTICAL; - } - -ok_qsfp_detect_class_by_feature_4_copper: - switch(speed_val) { - case TRANSVR_CLASS_100G: - return TRANSVR_CLASS_COPPER_L4_100G; - case TRANSVR_CLASS_40G: - return TRANSVR_CLASS_COPPER_L4_40G; - case TRANSVR_CLASS_10G: - return TRANSVR_CLASS_COPPER_L4_10G; - default: - return TRANSVR_CLASS_COPPER; - } - -err_qsfp_detect_class_by_feature_1: - SWPS_INFO("%s: %s\n :%s", - __func__, err_msg, self->swp_name); - return TRANSVR_CLASS_ERROR; -} - - -int -qsft_detect_transvr_class(struct transvr_obj_s* self) { - - int detect_val = DEBUG_TRANSVR_INT_VAL; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - - /* Check Extended Compliance */ - detect_val = _qsfp_detect_class_by_extend_comp(self); - switch (detect_val) { - case TRANSVR_CLASS_UNSPECIFIED: - break; - case TRANSVR_CLASS_OPTICAL_100G: - case TRANSVR_CLASS_OPTICAL_100G_AOC: - case TRANSVR_CLASS_OPTICAL_100G_SR4: - case TRANSVR_CLASS_OPTICAL_100G_LR4: - case TRANSVR_CLASS_OPTICAL_100G_ER4: - case TRANSVR_CLASS_OPTICAL_100G_PSM4: - case TRANSVR_CLASS_OPTICAL_40G: - case TRANSVR_CLASS_OPTICAL_40G_AOC: - case TRANSVR_CLASS_OPTICAL_40G_SR4: - case TRANSVR_CLASS_OPTICAL_40G_LR4: - case TRANSVR_CLASS_OPTICAL_40G_ER4: - case TRANSVR_CLASS_COPPER_L4_100G: - return detect_val; - default: - snprintf(err_msg, sizeof(err_msg), - "Detect undefined extend_comp:%d", - detect_val); - goto err_qsft_detect_transvr_class_1; - } - /* Check 10/40G/100G Ethernet Compliance */ - detect_val = _qsfp_detect_class_by_10_40_100_ethernet(self); - switch(detect_val) { - case TRANSVR_CLASS_UNSPECIFIED: - break; - case TRANSVR_CLASS_OPTICAL_40G_AOC: - case TRANSVR_CLASS_OPTICAL_40G_SR4: - case TRANSVR_CLASS_OPTICAL_40G_LR4: - case TRANSVR_CLASS_OPTICAL_10G_Q_SR: /* Need Check: SR4 or SR */ - case TRANSVR_CLASS_OPTICAL_10G_Q_LR: /* Need Check: SR4 or SR */ - case TRANSVR_CLASS_COPPER_L4_40G: - return detect_val; - case TRANSVR_CLASS_EXTEND_COMP: - /* Format incorrect case (We already checked the Extend - * Compliance is 0 - */ - snprintf(err_msg, sizeof(err_msg), - "Transceiver format incorrect"); - goto err_qsft_detect_transvr_class_1; - default: - snprintf(err_msg, sizeof(err_msg), - "Detect undefined 10/40/100:%d", - detect_val); - goto err_qsft_detect_transvr_class_1; - } - /* Check by Connector type, BR and wavelength */ - detect_val = _qsfp_detect_class_by_feature(self); - switch (detect_val) { - case TRANSVR_CLASS_UNSPECIFIED: - break; - case TRANSVR_CLASS_OPTICAL_100G_ER4: - case TRANSVR_CLASS_OPTICAL_100G_LR4: - case TRANSVR_CLASS_OPTICAL_100G_SR4: - case TRANSVR_CLASS_OPTICAL_100G_AOC: - case TRANSVR_CLASS_OPTICAL_100G: - case TRANSVR_CLASS_OPTICAL_40G_ER4: - case TRANSVR_CLASS_OPTICAL_40G_LR4: - case TRANSVR_CLASS_OPTICAL_40G_SR4: - case TRANSVR_CLASS_OPTICAL_40G_AOC: - case TRANSVR_CLASS_OPTICAL_40G: - case TRANSVR_CLASS_OPTICAL_10G_Q_ER: - case TRANSVR_CLASS_OPTICAL_10G_Q_LR: - case TRANSVR_CLASS_OPTICAL_10G_Q_SR: - case TRANSVR_CLASS_OPTICAL_10G_Q_AOC: - case TRANSVR_CLASS_OPTICAL_10G: - case TRANSVR_CLASS_OPTICAL: - case TRANSVR_CLASS_COPPER_L4_100G: - case TRANSVR_CLASS_COPPER_L4_40G: - case TRANSVR_CLASS_COPPER_L4_10G: - case TRANSVR_CLASS_COPPER: - return detect_val; - default: - snprintf(err_msg, sizeof(err_msg), - "Detect undefined connector:%d", - detect_val); - goto err_qsft_detect_transvr_class_1; - } - /* Exception case: Can't verify */ - snprintf(err_msg, sizeof(err_msg), - "Can not identify!"); - goto err_qsft_detect_transvr_class_1; - -err_qsft_detect_transvr_class_1: - SWPS_INFO("%s: %s\n :%s", __func__, err_msg, self->swp_name); - return TRANSVR_CLASS_ERROR; -} - - -int -_qsfp_set_magnolia_if_type(struct transvr_obj_s* self, - int transvr_cls, - char *result){ - - int lmax = 8; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - - switch (transvr_cls) { - case TRANSVR_CLASS_UNSPECIFIED: - case TRANSVR_CLASS_ERROR: - break; - /* 100G Optical */ - case TRANSVR_CLASS_OPTICAL_100G: - case TRANSVR_CLASS_OPTICAL_100G_AOC: - case TRANSVR_CLASS_OPTICAL_100G_SR4: - case TRANSVR_CLASS_OPTICAL_100G_LR4: - case TRANSVR_CLASS_OPTICAL_100G_ER4: - case TRANSVR_CLASS_OPTICAL_100G_PSM4: - return snprintf(result, lmax, TRANSVR_IF_SR4); - /* 100G Copper */ - case TRANSVR_CLASS_COPPER_L4_100G: - return snprintf(result, lmax, TRANSVR_IF_KR4); - /* 40G Optical */ - case TRANSVR_CLASS_OPTICAL_40G: - case TRANSVR_CLASS_OPTICAL_40G_AOC: - case TRANSVR_CLASS_OPTICAL_40G_SR4: - case TRANSVR_CLASS_OPTICAL_40G_LR4: - case TRANSVR_CLASS_OPTICAL_40G_ER4: - return snprintf(result, lmax, TRANSVR_IF_IF_XGMII); - /* 40G Copper */ - case TRANSVR_CLASS_COPPER_L4_40G: - return snprintf(result, lmax, TRANSVR_IF_IF_XGMII); - /* 10G Optical */ - case TRANSVR_CLASS_OPTICAL_10G: - case TRANSVR_CLASS_OPTICAL_10G_Q_AOC: - case TRANSVR_CLASS_OPTICAL_10G_Q_SR: /* Need Check: SR4 or SR */ - case TRANSVR_CLASS_OPTICAL_10G_Q_LR: /* Need Check: LR4 or LR */ - case TRANSVR_CLASS_OPTICAL_10G_Q_ER: /* Need Check: ER4 or ER */ - return snprintf(result, lmax, TRANSVR_IF_IF_XGMII); - /* Optical */ - case TRANSVR_CLASS_OPTICAL: - return snprintf(result, lmax, TRANSVR_IF_IF_XGMII); - /* Copper */ - case TRANSVR_CLASS_COPPER: - return snprintf(result, lmax, TRANSVR_IF_IF_XGMII); - default: - snprintf(err_msg, sizeof(err_msg), - "Detect undefined value:%d", - transvr_cls); - goto err_qsfp_set_magnolia_if_type_1; - } - /* Exception case: Can't verify */ - snprintf(err_msg, sizeof(err_msg), "Can not identify!"); - goto err_qsfp_set_magnolia_if_type_1; - -err_qsfp_set_magnolia_if_type_1: - snprintf(result, lmax, TRANSVR_UEVENT_UNKNOW); - SWPS_INFO("%s: %s\n :%s", __func__, err_msg, self->swp_name); - return ERR_TRANSVR_ABNORMAL; -} - - -int -_qsfp_set_redwood_if_type(struct transvr_obj_s* self, - int transvr_cls, - char *result){ - - int lmax = 8; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - - switch (transvr_cls) { - case TRANSVR_CLASS_UNSPECIFIED: - case TRANSVR_CLASS_ERROR: - break; - /* 100G Optical */ - case TRANSVR_CLASS_OPTICAL_100G: - case TRANSVR_CLASS_OPTICAL_100G_AOC: - case TRANSVR_CLASS_OPTICAL_100G_SR4: - case TRANSVR_CLASS_OPTICAL_100G_LR4: - case TRANSVR_CLASS_OPTICAL_100G_ER4: - case TRANSVR_CLASS_OPTICAL_100G_PSM4: - return snprintf(result, lmax, TRANSVR_IF_SR4); - /* 100G Copper */ - case TRANSVR_CLASS_COPPER_L4_100G: - return snprintf(result, lmax, TRANSVR_IF_KR4); - /* 40G Optical */ - case TRANSVR_CLASS_OPTICAL_40G: - case TRANSVR_CLASS_OPTICAL_40G_AOC: - case TRANSVR_CLASS_OPTICAL_40G_SR4: - case TRANSVR_CLASS_OPTICAL_40G_LR4: - case TRANSVR_CLASS_OPTICAL_40G_ER4: - return snprintf(result, lmax, TRANSVR_IF_SR4); - /* 40G Copper */ - case TRANSVR_CLASS_COPPER_L4_40G: - return snprintf(result, lmax, TRANSVR_IF_KR4); - /* 10G Optical */ - case TRANSVR_CLASS_OPTICAL_10G: - case TRANSVR_CLASS_OPTICAL_10G_Q_AOC: - case TRANSVR_CLASS_OPTICAL_10G_Q_SR: /* Need Check: SR4 or SR */ - case TRANSVR_CLASS_OPTICAL_10G_Q_LR: /* Need Check: SR4 or SR */ - case TRANSVR_CLASS_OPTICAL_10G_Q_ER: - return snprintf(result, lmax, TRANSVR_IF_SR4); - /* Optical */ - case TRANSVR_CLASS_OPTICAL: - return snprintf(result, lmax, TRANSVR_IF_SR4); - /* Copper */ - case TRANSVR_CLASS_COPPER: - return snprintf(result, lmax, TRANSVR_IF_KR4); - default: - snprintf(err_msg, sizeof(err_msg), - "Detect undefined value:%d", - transvr_cls); - goto err_qsfp_set_magnolia_if_type_1; - } - /* Exception case: Can't verify */ - snprintf(err_msg, sizeof(err_msg), "Can not identify!"); - goto err_qsfp_set_magnolia_if_type_1; - -err_qsfp_set_magnolia_if_type_1: - snprintf(result, lmax, TRANSVR_UEVENT_UNKNOW); - SWPS_INFO("%s: %s\n :%s", __func__, err_msg, self->swp_name); - return ERR_TRANSVR_ABNORMAL; -} - - -int -_qsfp_set_lavender_if_type(struct transvr_obj_s* self, - int transvr_cls, - char *result) { - /* (TBD) - * Due to 'LAV' looks like doesn't have interface type. - * We bypass it currently. - */ - int lmax = 8; - return snprintf(result, lmax, TRANSVR_UEVENT_UNKNOW); -} - - -int -_qsfp_detect_if_type(struct transvr_obj_s* self, - char *result){ - - int lmax = 8; - int detect_cls = DEBUG_TRANSVR_INT_VAL; - - detect_cls = qsft_detect_transvr_class(self); - switch (self->chipset_type) { - case CHIP_TYPE_MAGNOLIA: - return _qsfp_set_magnolia_if_type(self, detect_cls, result); - - case CHIP_TYPE_REDWOOD: - return _qsfp_set_redwood_if_type(self, detect_cls, result); - - case CHIP_TYPE_LAVENDER: - return _qsfp_set_lavender_if_type(self, detect_cls, result); - - default: - SWPS_INFO("%s: non-defined chipset_type:%d :%s\n", - __func__, self->chipset_type, self->swp_name); - break; - } - snprintf(result, lmax, TRANSVR_UEVENT_UNKNOW); - return ERR_TRANSVR_ABNORMAL; -} - - -int -qsfp_get_if_type(struct transvr_obj_s *self, - char *buf_p){ - - int lmax = 8; - char tmp_result[8] = DEBUG_TRANSVR_STR_VAL; - - if (self->state != STATE_TRANSVR_CONNECTED) { - return snprintf(buf_p, lmax, "%d\n", self->state); - } - if (_qsfp_detect_if_type(self, tmp_result) < 0) { - return snprintf(buf_p, lmax, "%d\n", ERR_TRANSVR_ABNORMAL); - } - return snprintf(buf_p, lmax, "%s\n", tmp_result); -} - - -int -_qsfp_detect_if_speed(struct transvr_obj_s* self, - char *result){ - int lmax = 16; - int detect_val = DEBUG_TRANSVR_INT_VAL; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - - detect_val = qsft_detect_transvr_class(self); - switch (detect_val) { - case TRANSVR_CLASS_UNSPECIFIED: - case TRANSVR_CLASS_ERROR: - break; - /* 100G Optical */ - case TRANSVR_CLASS_OPTICAL_100G: - case TRANSVR_CLASS_OPTICAL_100G_AOC: - case TRANSVR_CLASS_OPTICAL_100G_SR4: - case TRANSVR_CLASS_OPTICAL_100G_LR4: - case TRANSVR_CLASS_OPTICAL_100G_ER4: - case TRANSVR_CLASS_OPTICAL_100G_PSM4: - return snprintf(result, lmax, TRANSVR_IF_SP_100G); - /* 100G Copper */ - case TRANSVR_CLASS_COPPER_L4_100G: - return snprintf(result, lmax, TRANSVR_IF_SP_100G); - /* 40G Optical */ - case TRANSVR_CLASS_OPTICAL_40G: - case TRANSVR_CLASS_OPTICAL_40G_AOC: - case TRANSVR_CLASS_OPTICAL_40G_SR4: - case TRANSVR_CLASS_OPTICAL_40G_LR4: - case TRANSVR_CLASS_OPTICAL_40G_ER4: - return snprintf(result, lmax, TRANSVR_IF_SP_40G); - /* 40G Copper */ - case TRANSVR_CLASS_COPPER_L4_40G: - return snprintf(result, lmax, TRANSVR_IF_SP_40G); - /* 10G Optical */ - case TRANSVR_CLASS_OPTICAL_10G: - case TRANSVR_CLASS_OPTICAL_10G_Q_AOC: - case TRANSVR_CLASS_OPTICAL_10G_Q_SR: /* Need Check: SR4 or SR */ - case TRANSVR_CLASS_OPTICAL_10G_Q_LR: /* Need Check: SR4 or SR */ - case TRANSVR_CLASS_OPTICAL_10G_Q_ER: - return snprintf(result, lmax, TRANSVR_IF_SP_10G); - /* 10G Copper */ - case TRANSVR_CLASS_COPPER_L4_10G: - return snprintf(result, lmax, TRANSVR_IF_SP_10G); - /* Optical */ - case TRANSVR_CLASS_OPTICAL: - break; - /* Copper */ - case TRANSVR_CLASS_COPPER: - break; - default: - snprintf(err_msg, sizeof(err_msg), - "Detect undefined class case:%d", - detect_val); - goto err_qsfp_detect_if_speed_1; - } - /* Check br and extbr */ - detect_val = _qsfp_detect_if_sp_by_br(self); - switch(detect_val) { - case TRANSVR_CLASS_UNSPECIFIED: - break; - case TRANSVR_CLASS_10G: - return snprintf(result, lmax, TRANSVR_IF_SP_10G); - case TRANSVR_CLASS_40G: - return snprintf(result, lmax, TRANSVR_IF_SP_40G); - case TRANSVR_CLASS_100G: - return snprintf(result, lmax, TRANSVR_IF_SP_100G); - default: - snprintf(err_msg, sizeof(err_msg), - "Detect undefined BR case:%d", - detect_val); - goto err_qsfp_detect_if_speed_1; - } - /* Exception case: Can't verify */ - snprintf(err_msg, sizeof(err_msg), "Can not identify!"); - goto err_qsfp_detect_if_speed_1; - -err_qsfp_detect_if_speed_1: - snprintf(result, lmax, TRANSVR_UEVENT_UNKNOW); - SWPS_INFO("%s: %s :%s\n", __func__, err_msg, self->swp_name); - return ERR_TRANSVR_ABNORMAL; -} - - -int -qsfp_get_if_speed(struct transvr_obj_s *self, - char *buf_p){ - - int lmax = 16; - char tmp_result[16] = DEBUG_TRANSVR_STR_VAL; - - if (self->state != STATE_TRANSVR_CONNECTED) { - return snprintf(buf_p, lmax, "%d\n", self->state); - } - if (_qsfp_detect_if_speed(self, tmp_result) < 0) { - return snprintf(buf_p, lmax, "%d\n", ERR_TRANSVR_ABNORMAL); - } - return snprintf(buf_p, lmax, "%s\n", tmp_result); -} - - -int -_common_set_lane_map_str(struct transvr_obj_s* self, - char *result) { - int i = 0; - int tmp_val = 0; - char tmp_str[LEN_TRANSVR_L_STR] = DEBUG_TRANSVR_STR_VAL; - char err_msg[LEN_TRANSVR_L_STR] = DEBUG_TRANSVR_STR_VAL; - - memset(result, 0, LEN_TRANSVR_L_STR); - snprintf(result, LEN_TRANSVR_L_STR, "%s=", TRANSVR_UEVENT_KEY_LANE); - - for (i=0; ilane_id); i++) { - tmp_val = self->lane_id[i]; - if (tmp_val < 1) { - break; - } - if (tmp_val > 256) { - snprintf(err_msg, sizeof(err_msg), - "detect abnormal value:%d", tmp_val); - goto err_common_set_lane_map_str_1; - } - memset(tmp_str, 0, sizeof(tmp_str)); - if (i == 0) { - snprintf(tmp_str, LEN_TRANSVR_L_STR, "%d", tmp_val); - } else { - snprintf(tmp_str, LEN_TRANSVR_L_STR, ",%d", tmp_val); - } - strncat(result, tmp_str, LEN_TRANSVR_L_STR); - } - if (i == 0) { - goto err_common_set_lane_map_str_2; - } - return 0; - -err_common_set_lane_map_str_1: - SWPS_INFO("%s: %s", __func__, err_msg); -err_common_set_lane_map_str_2: - snprintf(result, LEN_TRANSVR_L_STR, "%s=%s", TRANSVR_UEVENT_KEY_LANE, TRANSVR_UEVENT_UNKNOW); - return EVENT_TRANSVR_TASK_FAIL; -} - - -int -_common_send_uevent(struct transvr_obj_s* self, - enum kobject_action u_action, - int (*detect_if_type)(struct transvr_obj_s *self, char *result), - int (*detect_if_speed)(struct transvr_obj_s *self, char *result), - int send_anyway) { - - char *uevent_envp[4]; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - char tmp_str[32] = DEBUG_TRANSVR_STR_VAL; - char tmp_str_1[32] = DEBUG_TRANSVR_STR_VAL; - char tmp_str_2[32] = DEBUG_TRANSVR_STR_VAL; - char tmp_str_3[64] = DEBUG_TRANSVR_STR_VAL; - - if (TRANSVR_UEVENT_ENABLE != 1) { - return ERR_TRANSVR_NOTSUPPORT; - } - if (_common_get_if_lane(self, tmp_str) < 0) { - snprintf(tmp_str_3, sizeof(tmp_str_3), - "%s=%s", TRANSVR_UEVENT_KEY_LANE, TRANSVR_UEVENT_UNKNOW); - } else { - snprintf(tmp_str_3, sizeof(tmp_str_3), - "%s=%s", TRANSVR_UEVENT_KEY_LANE, tmp_str); - } - switch (u_action) { - case KOBJ_ADD: - /* Detect type */ - if (detect_if_type(self, tmp_str) < 0) { - snprintf(err_msg, sizeof(err_msg), "%s", "Detect interface type fail!"); - snprintf(tmp_str_1, sizeof(tmp_str_1), "%s=%s", TRANSVR_UEVENT_KEY_IF, TRANSVR_UEVENT_UNKNOW); - snprintf(tmp_str_2, sizeof(tmp_str_2), "%s=%s", TRANSVR_UEVENT_KEY_SP, TRANSVR_UEVENT_UNKNOW); - uevent_envp[0] = tmp_str_1; - uevent_envp[1] = tmp_str_2; - uevent_envp[2] = tmp_str_3; - uevent_envp[3] = NULL; - goto private_common_send_uevent_4_fail; - } - snprintf(tmp_str_1, sizeof(tmp_str_1), "%s=%s", TRANSVR_UEVENT_KEY_IF, tmp_str); - uevent_envp[0] = tmp_str_1; - /* Detect speed */ - if (detect_if_speed(self, tmp_str) < 0) { - snprintf(err_msg, sizeof(err_msg), "%s", "Detect interface speed fail!"); - snprintf(tmp_str_2, sizeof(tmp_str_2), "%s=%s", TRANSVR_UEVENT_KEY_SP, TRANSVR_UEVENT_UNKNOW); - uevent_envp[1] = tmp_str_2; - uevent_envp[2] = tmp_str_3; - uevent_envp[3] = NULL; - goto private_common_send_uevent_4_fail; - } - snprintf(tmp_str_2, sizeof(tmp_str_2), "%s=%s", TRANSVR_UEVENT_KEY_SP, tmp_str); - uevent_envp[1] = tmp_str_2; - uevent_envp[2] = tmp_str_3; - uevent_envp[3] = NULL; - goto private_common_send_uevent_4_send; - - case KOBJ_REMOVE: - snprintf(tmp_str_1, sizeof(tmp_str_1), "%s=%s", TRANSVR_UEVENT_KEY_IF, TRANSVR_UEVENT_UNKNOW); - snprintf(tmp_str_2, sizeof(tmp_str_2), "%s=%s", TRANSVR_UEVENT_KEY_SP, TRANSVR_UEVENT_UNKNOW); - uevent_envp[0] = tmp_str_1; - uevent_envp[1] = tmp_str_2; - uevent_envp[2] = tmp_str_3; - uevent_envp[3] = NULL; - goto private_common_send_uevent_4_send; - - default: - snprintf(err_msg, sizeof(err_msg), "kobject_action:%d not support", u_action); - goto private_common_send_uevent_4_fail; - } - snprintf(err_msg, sizeof(err_msg), "%s", "Exception case"); - goto private_common_send_uevent_4_fail; - -private_common_send_uevent_4_fail: - SWPS_INFO("%s: %s :%s\n", __func__, err_msg, self->swp_name); - if (send_anyway) { - goto private_common_send_uevent_4_send; - } - return ERR_TRANSVR_UEVENT_FAIL; - -private_common_send_uevent_4_send: - return kobject_uevent_env(&(self->transvr_dev_p->kobj), - u_action, - uevent_envp); -} - -int -sfp_send_uevent(struct transvr_obj_s* self, - enum kobject_action u_action) { - int send_anyway = 1; - return _common_send_uevent(self, - u_action, - &_sfp_detect_if_type, - &_sfp_detect_if_speed, - send_anyway); -} - - -int -qsfp_send_uevent(struct transvr_obj_s* self, - enum kobject_action u_action) { - int send_anyway = 1; - return _common_send_uevent(self, - u_action, - &_qsfp_detect_if_type, - &_qsfp_detect_if_speed, - send_anyway); -} - - -int -fake_send_uevent(struct transvr_obj_s* self, - enum kobject_action u_action) { - return EVENT_TRANSVR_TASK_DONE; -} - - -int -common_fsm_4_direct_mode(struct transvr_obj_s* self, - char *caller_name){ - - int err; - int detect_result[2]; - int current_state = STATE_TRANSVR_UNEXCEPTED; - int current_type = TRANSVR_TYPE_ERROR; - - if (self->state == STATE_TRANSVR_NEW) { - if (_transvr_init_handler(self) < 0){ - return ERR_TRANSVR_INIT_FAIL; - } - } - err = detect_transvr_state(self, detect_result); - if (err < 0) { - return err; - } - /* In Direct mode, driver only detect transceiver when user call driver interface - * which on sysfs. So it only need consider the state of Transceiver. - */ - current_state = detect_result[0]; - current_type = detect_result[1]; - - switch (current_state){ - - case STATE_TRANSVR_DISCONNECTED: /* Transceiver is not plugged */ - self->state = current_state; - self->type = current_type; - return ERR_TRANSVR_UNPLUGGED; - - case STATE_TRANSVR_INIT: /* Transceiver is plugged, system not ready */ - return ERR_TRANSVR_UNINIT; - - case STATE_TRANSVR_ISOLATED: /* Transceiver is plugged, but has some issues */ - return ERR_TRNASVR_BE_ISOLATED; - - case STATE_TRANSVR_CONNECTED: /* Transceiver is plugged, system is ready */ - self->state = current_state; - self->type = current_type; - return 0; - - case STATE_TRANSVR_SWAPPED: /* Transceiver is plugged, system detect user changed */ - self->type = current_type; - if (reload_transvr_obj(self, current_type) < 0){ - self->state = STATE_TRANSVR_UNEXCEPTED; - return ERR_TRANSVR_UNEXCPT; - } - self->state = current_state; - return 0; - - case STATE_TRANSVR_UNEXCEPTED: /* Transceiver type or state is unexpected case */ - self->state = STATE_TRANSVR_UNEXCEPTED; - self->type = TRANSVR_TYPE_ERROR; - return ERR_TRANSVR_UNEXCPT; - - default: - SWPS_INFO("%s: state:%d not in define.\n", __func__, current_state); - break; - } - return ERR_TRANSVR_UNEXCPT; -} - - -static int -_is_except_happened_4_pmode(struct transvr_obj_s* self, - int new_state) { - - int event_chk = 0; - - if (self->temp == 0){ - return 0; - } - switch (new_state) { - case STATE_TRANSVR_INIT: - event_chk = EVENT_TRANSVR_EXCEP_INIT; - goto check_event_happened_4_pmode; - - case STATE_TRANSVR_CONNECTED: - event_chk = EVENT_TRANSVR_EXCEP_UP; - goto check_event_happened_4_pmode; - - case STATE_TRANSVR_DISCONNECTED: - event_chk = EVENT_TRANSVR_EXCEP_DOWN; - goto check_event_happened_4_pmode; - - case STATE_TRANSVR_SWAPPED: - event_chk = EVENT_TRANSVR_EXCEP_SWAP; - goto check_event_happened_4_pmode; - - case STATE_TRANSVR_UNEXCEPTED: - event_chk = EVENT_TRANSVR_EXCEP_EXCEP; - goto check_event_happened_4_pmode; - - case STATE_TRANSVR_ISOLATED: - event_chk = EVENT_TRANSVR_EXCEP_ISOLATED; - goto check_event_happened_4_pmode; - - default: - SWPS_INFO("%s: unexcepted case:%d\n", __func__, new_state); - break; - } - return 0; - -check_event_happened_4_pmode: - if (self->temp == event_chk){ - return 1; - } - return 0; -} - - -int -common_fsm_4_polling_mode(struct transvr_obj_s* self, - char *caller_name){ - /* [Return Value]: - * ERR_TRANSVR_UNINIT : (1) Initial not ready - * ERR_TRANSVR_UNPLUGGED : (1) Any -> Down - * ERR_TRANSVR_TASK_BUSY : (1) Wait Initial task - * ERR_TRANSVR_UNEXCPT : (1) Initial fail - * (2) Task fail - * (3) Reload fail - * ERR_TRNASVR_BE_ISOLATED : (1) Already be isolated - * OK Case (return 0) : (1) action_4_connected - * (2) action_4_nothing (initial retry) - */ - int curr_state[2]; - int old_state = self->state; - int old_type = self->type; - int new_state = STATE_TRANSVR_UNEXCEPTED; - int new_type = TRANSVR_TYPE_ERROR; - int return_val = ERR_TRANSVR_UNEXCPT; - - /* Never initial */ - if (self->state == STATE_TRANSVR_NEW) { - goto comfsm_action_4_reinit_obj; - } - /* Detect current state */ - switch (detect_transvr_state(self, curr_state)) { - case 0: - new_state = curr_state[0]; - new_type = curr_state[1]; - break; - - case ERR_TRNASVR_BE_ISOLATED: - new_state = STATE_TRANSVR_ISOLATED; - new_type = old_type; - break; - - case ERR_TRANSVR_I2C_CRASH: - goto comfsm_action_4_report_i2c_crash; - - case ERR_TRANSVR_UNEXCPT: - default: - new_state = STATE_TRANSVR_UNEXCEPTED; - new_type = old_type; - } - /* State handling */ - switch (old_state) { - case STATE_TRANSVR_INIT: /* INIT -> */ - return_val = ERR_TRANSVR_UNINIT; - goto comfsm_action_4_keep_state; - - case STATE_TRANSVR_CONNECTED: - switch (new_state) { - case STATE_TRANSVR_INIT: /* Case 1-1: UP -> INIT */ - SWPS_INFO("Detect %s is present. :1-1\n",self->swp_name); - return_val = ERR_TRANSVR_UNINIT; - goto comfsm_action_4_keep_state; - - case STATE_TRANSVR_CONNECTED: /* Case 1-2: UP -> UP */ - return_val = 0; - goto comfsm_action_4_keep_state; - - case STATE_TRANSVR_DISCONNECTED: /* Case 1-3: UP -> DOWN */ - SWPS_INFO("Detect %s is removed. :1-3\n",self->swp_name); - goto comfsm_action_4_disconnected; - - case STATE_TRANSVR_SWAPPED: /* Case 1-4: UP -> SWAP */ - SWPS_INFO("Detect %s is swapped. :1-4\n",self->swp_name); - goto comfsm_action_4_reload_obj; - - case STATE_TRANSVR_UNEXCEPTED: /* Case 1-5: UP -> UNEXPET */ - SWPS_INFO("Detect %s has error. :1-5\n",self->swp_name); - goto comfsm_action_4_unexpected; - - case STATE_TRANSVR_ISOLATED: /* Case 1-6: UP -> ISOLATE */ - SWPS_INFO("Detect %s be isolated. :1-6\n",self->swp_name); - goto comfsm_action_4_isolate_obj; - - default: - break; - } - goto comfsm_action_4_unexpected; - - case STATE_TRANSVR_DISCONNECTED: - switch (new_state) { - case STATE_TRANSVR_INIT: /* Case 2-1: DOWN -> INIT */ - SWPS_INFO("Detect %s is present. :2-1\n",self->swp_name); - return_val = ERR_TRANSVR_UNINIT; - goto comfsm_action_4_keep_state; - - case STATE_TRANSVR_CONNECTED: /* Case 2-2: DOWN -> UP */ - SWPS_INFO("Detect %s is present. :2-2\n",self->swp_name); - goto comfsm_action_4_reinit_obj; - - case STATE_TRANSVR_DISCONNECTED: /* Case 2-3: DOWN -> DOWN */ - return_val = ERR_TRANSVR_UNPLUGGED; - goto comfsm_action_4_keep_state; - - case STATE_TRANSVR_SWAPPED: /* Case 2-4: DOWN -> SWAP */ - SWPS_INFO("Detect %s is swapped. :2-4\n",self->swp_name); - goto comfsm_action_4_reload_obj; - - case STATE_TRANSVR_UNEXCEPTED: /* Case 2-5: DOWN -> UNEXPET */ - SWPS_INFO("Detect %s has error. :2-5\n",self->swp_name); - goto comfsm_action_4_unexpected; - - case STATE_TRANSVR_ISOLATED: /* Case 2-6: DOWN -> ISOLATE */ - SWPS_INFO("Detect %s be isolated. :2-6\n",self->swp_name); - goto comfsm_action_4_isolate_obj; - - default: - break; - } - goto comfsm_action_4_unexpected; - - case STATE_TRANSVR_UNEXCEPTED: - /* Filter out re-action */ - if (_is_except_happened_4_pmode(self, new_state)) { - goto comfsm_action_4_keep_state; - } - /* First action */ - switch (new_state) { - case STATE_TRANSVR_INIT: /* Case 3-1: UNEXPET -> INIT */ - SWPS_INFO("Detect %s is present. :3-1\n",self->swp_name); - self->temp = EVENT_TRANSVR_EXCEP_INIT; - return_val = ERR_TRANSVR_UNINIT; - goto comfsm_action_4_keep_state; - - case STATE_TRANSVR_CONNECTED: /* Case 3-2: UNEXPET -> UP */ - SWPS_INFO("Detect %s is present. :3-2\n",self->swp_name); - self->temp = EVENT_TRANSVR_EXCEP_UP; - goto comfsm_action_4_reload_obj; - - case STATE_TRANSVR_DISCONNECTED: /* Case 3-3: UNEXPET -> DOWN */ - SWPS_INFO("Detect %s is removed. :3-3\n",self->swp_name); - goto comfsm_action_4_disconnected; - - case STATE_TRANSVR_SWAPPED: /* Case 3-4: UNEXPET -> SWAP */ - SWPS_INFO("Detect %s is swapped. :3-4\n",self->swp_name); - self->temp = EVENT_TRANSVR_EXCEP_SWAP; - goto comfsm_action_4_reload_obj; - - case STATE_TRANSVR_UNEXCEPTED: /* Case 3-5: UNEXPET -> UNEXPET */ - self->temp = EVENT_TRANSVR_EXCEP_EXCEP; - return_val = ERR_TRANSVR_UNEXCPT; - goto comfsm_action_4_keep_state; - - case STATE_TRANSVR_ISOLATED: /* Case 3-6: UNEXPET -> ISOLATE */ - SWPS_INFO("Detect %s be isolated. :3-6\n",self->swp_name); - goto comfsm_action_4_isolate_obj; - - default: - break; - } - goto comfsm_action_4_unexpected; - - case STATE_TRANSVR_ISOLATED: - /* Filter out re-action */ - if (_is_except_happened_4_pmode(self, new_state)) { - goto comfsm_action_4_keep_state; - } - /* First action */ - switch (new_state) { - case STATE_TRANSVR_INIT: /* Case 4-1: ISOLATE -> INIT */ - SWPS_INFO("Detect %s internal error. :4-1\n",self->swp_name); - self->temp = EVENT_TRANSVR_EXCEP_INIT; - return_val = ERR_TRNASVR_BE_ISOLATED; - goto comfsm_action_4_keep_state; - - case STATE_TRANSVR_CONNECTED: /* Case 4-2: ISOLATE -> UP */ - SWPS_INFO("Detect %s internal error. :4-2\n",self->swp_name); - self->temp = EVENT_TRANSVR_EXCEP_UP; - return_val = ERR_TRNASVR_BE_ISOLATED; - goto comfsm_action_4_keep_state; - - case STATE_TRANSVR_DISCONNECTED: /* Case 4-3: ISOLATE -> DOWN */ - SWPS_INFO("Detect %s is removed. :4-3\n",self->swp_name); - goto comfsm_action_4_disconnected; - - case STATE_TRANSVR_SWAPPED: /* Case 4-4: ISOLATE -> SWAP */ - SWPS_INFO("Detect %s internal error. :4-4\n",self->swp_name); - self->temp = EVENT_TRANSVR_EXCEP_SWAP; - return_val = ERR_TRNASVR_BE_ISOLATED; - goto comfsm_action_4_keep_state; - - case STATE_TRANSVR_UNEXCEPTED: /* Case 4-5: ISOLATE -> UNEXPET */ - SWPS_INFO("Detect %s internal error. :4-5\n",self->swp_name); - self->temp = EVENT_TRANSVR_EXCEP_EXCEP; - return_val = ERR_TRNASVR_BE_ISOLATED; - goto comfsm_action_4_keep_state; - - case STATE_TRANSVR_ISOLATED: /* Case 4-6: ISOLATE -> ISOLATE */ - return_val = ERR_TRNASVR_BE_ISOLATED; - goto comfsm_action_4_keep_state; - - default: - break; - } - goto comfsm_action_4_unexpected; - - default: - break; - } - goto comfsm_action_4_unexpected; - - -comfsm_action_4_keep_state: - return return_val; - -comfsm_action_4_reinit_obj: - SWPS_DEBUG("FSM action: %s re-initial.\n", self->swp_name); - return_val = _transvr_init_handler(self); - goto comfsm_action_4_identify_event; - -comfsm_action_4_reload_obj: - SWPS_DEBUG("FSM action: %s reload.\n", self->swp_name); - self->type = new_type; - return_val = reload_transvr_obj(self, new_type); - goto comfsm_action_4_identify_event; - -comfsm_action_4_identify_event: - switch (return_val) { - case EVENT_TRANSVR_INIT_UP: - case EVENT_TRANSVR_TASK_DONE: - goto comfsm_action_4_connected; - - case EVENT_TRANSVR_INIT_DOWN: - goto comfsm_action_4_disconnected; - - case EVENT_TRANSVR_INIT_REINIT: - goto comfsm_action_4_nothing; - - case EVENT_TRANSVR_TASK_WAIT: - self->state = STATE_TRANSVR_INIT; - return ERR_TRANSVR_TASK_BUSY; - - case EVENT_TRANSVR_TASK_FAIL: - SWPS_INFO("%s detect EVENT_TRANSVR_TASK_FAIL.\n", self->swp_name); - goto comfsm_action_4_unexpected; - - case EVENT_TRANSVR_INIT_FAIL: - SWPS_INFO("%s detect EVENT_TRANSVR_INIT_FAIL.\n", self->swp_name); - goto comfsm_action_4_unexpected; - - case EVENT_TRANSVR_RELOAD_FAIL: - SWPS_INFO("%s detect EVENT_TRANSVR_RELOAD_FAIL.\n", self->swp_name); - goto comfsm_action_4_unexpected; - - case EVENT_TRANSVR_I2C_CRASH: - goto comfsm_action_4_report_i2c_crash; - - case EVENT_TRANSVR_EXCEP_ISOLATED: - goto comfsm_action_4_isolate_obj; - - default: - SWPS_INFO("%s detect undefined event:%d.\n", self->swp_name, return_val); - goto comfsm_action_4_unexpected; - } - -comfsm_action_4_nothing: - SWPS_DEBUG("FSM action: %s do nothing.\n", self->swp_name); - return 0; - -comfsm_action_4_connected: - SWPS_DEBUG("FSM action: %s Connected.\n", self->swp_name); - self->state = STATE_TRANSVR_CONNECTED; - self->type = new_type; - self->send_uevent(self, KOBJ_ADD); - _transvr_clean_retry(self); - return 0; - -comfsm_action_4_disconnected: - SWPS_DEBUG("FSM action: %s Disconnected. \n", self->swp_name); - self->state = STATE_TRANSVR_DISCONNECTED; - self->temp = EVENT_TRANSVR_TASK_DONE; - self->send_uevent(self, KOBJ_REMOVE); - _transvr_clean_retry(self); - _transvr_clean_handler(self); - return ERR_TRANSVR_UNPLUGGED; - -comfsm_action_4_report_i2c_crash: - SWPS_DEBUG("FSM action: %s report I2C crash.\n", self->swp_name); - self->state = STATE_TRANSVR_UNEXCEPTED; - return ERR_TRANSVR_I2C_CRASH; - -comfsm_action_4_isolate_obj: - SWPS_DEBUG("FSM action: %s isolate.\n", self->swp_name); - self->state = STATE_TRANSVR_ISOLATED; - return ERR_TRNASVR_BE_ISOLATED; - -comfsm_action_4_unexpected: - SWPS_INFO("FSM action: %s unexpected.\n", self->swp_name); - SWPS_INFO("Dump: :%d :0x%02x :%d :0x%02x\n", - old_state, old_type, new_state, new_type); - self->state = STATE_TRANSVR_UNEXCEPTED; - self->send_uevent(self, KOBJ_REMOVE); - _transvr_clean_handler(self); - return ERR_TRANSVR_UNEXCPT; -} - - -int -fake_fsm_4_direct_mode(struct transvr_obj_s* self, - char *caller_name){ - self->state = STATE_TRANSVR_CONNECTED; - self->type = TRANSVR_TYPE_FAKE; - return 0; -} - - -int -fake_fsm_4_polling_mode(struct transvr_obj_s* self, - char *caller_name){ - self->state = STATE_TRANSVR_CONNECTED; - self->type = TRANSVR_TYPE_FAKE; - return 0; -} - - -/* ========== Object functions for Initial procedure ========== - */ -int -transvr_init_common(struct transvr_obj_s *self){ - /* Nothing to update */ - return EVENT_TRANSVR_TASK_DONE; -} - - -int -transvr_init_fake(struct transvr_obj_s *self){ - return EVENT_TRANSVR_TASK_DONE; -} - - -int -transvr_init_sfp(struct transvr_obj_s *self){ - - int tmp_val = DEBUG_TRANSVR_INT_VAL; - int err_code = DEBUG_TRANSVR_INT_VAL; - char *err_msg = "ERR"; - - self->info = sft_detect_transvr_class(self); - /* Disable auto_config */ - if (!self->auto_config) { - return EVENT_TRANSVR_TASK_DONE; - } - /* Handle multi-rate */ - err_code = initfunc_sfp_handle_multi_rate_mode(self); - if (err_code < 0) { - err_msg = "initfunc_sfp_handle_multi_rate_mode fail!"; - goto err_transvr_init_sfp_1; - } - /* Handle 1G- RJ45 */ - tmp_val = err_code; - err_code = initfunc_sfp_handle_1g_rj45(self); - if (err_code < 0) { - err_msg = "initfunc_sfp_handle_1g_rj45 fail!"; - goto err_transvr_init_sfp_1; - } - tmp_val = (tmp_val > err_code ? tmp_val : err_code); - if (tmp_val > EVENT_TRANSVR_TASK_DONE) { - return tmp_val; - } - return EVENT_TRANSVR_TASK_DONE; - -err_transvr_init_sfp_1: - SWPS_INFO("%s: %s :%d :%s\n", - __func__, err_msg, err_code, self->swp_name); - return EVENT_TRANSVR_INIT_FAIL; -} - - -int -transvr_init_qsfp(struct transvr_obj_s *self){ - - int err = EVENT_TRANSVR_EXCEP_EXCEP; - char *emsg = "ERR"; - - self->info = qsft_detect_transvr_class(self); - if (!self->auto_config) { - return EVENT_TRANSVR_TASK_DONE; - } - err = initfunc_qsfp_handle_power_mode(self); - if (err < 0){ - emsg = "initfunc_qsfp_handle_tx_disable fail!"; - goto err_transvr_init_qsfp; - } - return EVENT_TRANSVR_TASK_DONE; - -err_transvr_init_qsfp: - SWPS_INFO("%s: %s :%d :%s\n", - __func__, emsg, err, self->swp_name); - return EVENT_TRANSVR_INIT_FAIL; -} - - -int -transvr_init_qsfp28(struct transvr_obj_s *self){ - - int tmp_val = EVENT_TRANSVR_EXCEP_EXCEP; - int err_val = EVENT_TRANSVR_EXCEP_EXCEP; - char *err_msg = "ERR"; - - /* Handle QSFP common */ - err_val = transvr_init_qsfp(self); - if (err_val < 0){ - err_msg = "transvr_init_qsfp fail!"; - goto err_transvr_init_qsfp28_1; - } - /* Disable auto_config */ - if (!self->auto_config) { - return err_val; - } - /* Handle CDR */ - tmp_val = err_val; - err_val = initfunc_qsfp28_handle_cdr(self); - if (err_val < 0){ - err_msg = "Handle CDR fail!"; - goto err_transvr_init_qsfp28_1; - } - tmp_val = (tmp_val > err_val ? tmp_val : err_val); - if (tmp_val > EVENT_TRANSVR_TASK_DONE) { - return tmp_val; - } - return EVENT_TRANSVR_TASK_DONE; - -err_transvr_init_qsfp28_1: - SWPS_INFO("%s: %s :%d :%s\n", - __func__, err_msg, err_val, self->swp_name); - return EVENT_TRANSVR_INIT_FAIL; -} - - -/* ========== Object Initial handler ========== - */ -static int -_is_transvr_valid(struct transvr_obj_s *self, - int type, - int state) { - /* [Return] - * 0 : OK, inserted - * EVENT_TRANSVR_INIT_DOWN : OK, removed - * EVENT_TRANSVR_INIT_FAIL : Outside error, type doesn't supported - * EVENT_TRANSVR_EXCEP_INIT : Internal error, state undefined - */ - switch (type) { - case TRANSVR_TYPE_SFP: - case TRANSVR_TYPE_QSFP: - case TRANSVR_TYPE_QSFP_PLUS: - case TRANSVR_TYPE_QSFP_28: - case TRANSVR_TYPE_UNPLUGGED: - case TRANSVR_TYPE_FAKE: - break; - default: - SWPS_INFO("detect undefined type:0x%02x on %s\n", - type, self->swp_name); - return EVENT_TRANSVR_INIT_FAIL; - } - switch (state) { - case STATE_TRANSVR_DISCONNECTED: - return EVENT_TRANSVR_INIT_DOWN; - case STATE_TRANSVR_INIT: - case STATE_TRANSVR_CONNECTED: - case STATE_TRANSVR_SWAPPED: - break; - default: - SWPS_INFO("detect undefined state:%d on %s\n", - state, self->swp_name); - return EVENT_TRANSVR_EXCEP_INIT; - } - return 0; -} - - -static int -_is_transvr_hw_ready(struct transvr_obj_s *self, - int type){ - /* [Return] - * EVENT_TRANSVR_TASK_DONE : Ready - * EVENT_TRANSVR_TASK_WAIT : Not ready - * EVENT_TRANSVR_INIT_FAIL : Error - */ - int addr = DEBUG_TRANSVR_INT_VAL; - int page = DEBUG_TRANSVR_INT_VAL; - int offs = DEBUG_TRANSVR_INT_VAL; - int bit = DEBUG_TRANSVR_INT_VAL; - int ready = DEBUG_TRANSVR_INT_VAL; - int err = DEBUG_TRANSVR_INT_VAL; - char *emsg = DEBUG_TRANSVR_STR_VAL; - uint8_t ab_val = DEBUG_TRANSVR_HEX_VAL; - - switch (type) { - case TRANSVR_TYPE_SFP: - addr = VAL_TRANSVR_8472_READY_ADDR; - page = VAL_TRANSVR_8472_READY_PAGE; - offs = VAL_TRANSVR_8472_READY_OFFSET; - bit = VAL_TRANSVR_8472_READY_BIT; - ready = VAL_TRANSVR_8472_READY_VALUE; - ab_val = VAL_TRANSVR_8472_READY_ABNORMAL; - break; - - case TRANSVR_TYPE_QSFP: - case TRANSVR_TYPE_QSFP_PLUS: - case TRANSVR_TYPE_QSFP_28: - addr = VAL_TRANSVR_8436_READY_ADDR; - page = VAL_TRANSVR_8436_READY_PAGE; - offs = VAL_TRANSVR_8436_READY_OFFSET; - bit = VAL_TRANSVR_8436_READY_BIT; - ready = VAL_TRANSVR_8436_READY_VALUE; - ab_val = VAL_TRANSVR_8436_READY_ABNORMAL; - break; - - case TRANSVR_TYPE_UNPLUGGED: - case TRANSVR_TYPE_FAKE: - return EVENT_TRANSVR_TASK_DONE; - - default: - emsg = "unexpected case"; - goto err_is_transvr_hw_ready; - } - /* Select target page */ - err = _common_setup_page(self, addr, page, offs, 1, 0); - if (err < 0) { - emsg = "setup page fail"; - goto err_is_transvr_hw_ready; - } - /* Check feature supported - * [Note] - * Some of transceiver/cables doesn't support "Status Indicators" - * (ex:DAC, RJ45 copper SFP ...etc). In these case, we bypass the - * step of checking Status Indicators, then state machine will take - * the following handle procedure. - */ - err = i2c_smbus_read_byte_data(self->i2c_client_p, - VAL_TRANSVR_COMID_OFFSET); - if (err < 0) { - emsg = "doesn't support Status Indicators"; - goto bypass_is_transvr_hw_ready; - } - /* Filter abnormal case */ - if (err == ab_val) { - emsg = "detect using unusual definition."; - goto bypass_is_transvr_hw_ready; - } - /* Get Status Indicators */ - err = i2c_smbus_read_byte_data(self->i2c_client_p, offs); - if (err < 0) { - emsg = "detect current value fail"; - goto err_is_transvr_hw_ready; - } - if ((err & (1<:%d\n", __func__, emsg, type); - return EVENT_TRANSVR_TASK_DONE; - -err_is_transvr_hw_ready: - SWPS_DEBUG("%s: %s :%d\n", __func__, emsg, type); - return EVENT_TRANSVR_INIT_FAIL; -} - - -static int -_is_transvr_support_ctle(struct transvr_obj_s *self) { - - switch (self->info) { - case TRANSVR_CLASS_OPTICAL_25G: - case TRANSVR_CLASS_OPTICAL_25G_AOC: - case TRANSVR_CLASS_OPTICAL_25G_SR: - case TRANSVR_CLASS_OPTICAL_25G_LR: - case TRANSVR_CLASS_OPTICAL_25G_ER: - case TRANSVR_CLASS_OPTICAL_100G: - case TRANSVR_CLASS_OPTICAL_100G_AOC: - case TRANSVR_CLASS_OPTICAL_100G_SR4: - case TRANSVR_CLASS_OPTICAL_100G_LR4: - case TRANSVR_CLASS_OPTICAL_100G_ER4: - case TRANSVR_CLASS_OPTICAL_100G_PSM4: - return 1; - default: - break; - } - return 0; -} - - -static int -_transvr_init_handler(struct transvr_obj_s *self){ - - int detect[2]; - int d_state = STATE_TRANSVR_UNEXCEPTED; - int d_type = TRANSVR_TYPE_ERROR; - int result = ERR_TRANSVR_UNINIT; - int retry = 6; /* (6+1) x 0.3 = 2.1s > spec:2.0s */ - int elimit = 63; - char emsg[64] = DEBUG_TRANSVR_STR_VAL; - - /* Clean and check callback */ - self->state = STATE_TRANSVR_INIT; - if (self->init == NULL) { - snprintf(emsg, elimit, "init() is null"); - goto initer_err_case_unexcept_0; - } - if (self->clean == NULL) { - snprintf(emsg, elimit, "clean() is null"); - goto initer_err_case_unexcept_0; - } - self->clean(self); - - /* Detect transceiver information */ - result = detect_transvr_state(self, detect); - if (result < 0) { - snprintf(emsg, elimit, "detect_transvr_state() fail"); - switch (result) { - case ERR_TRANSVR_I2C_CRASH: - goto initer_err_case_i2c_ceash; - case ERR_TRNASVR_BE_ISOLATED: - goto initer_err_case_be_isolated; - - case ERR_TRANSVR_UNEXCPT: - default: - break; - } - goto initer_err_case_retry_1; - } - d_state = detect[0]; - d_type = detect[1]; - - /* Verify transceiver type and state */ - switch (_is_transvr_valid(self, d_type, d_state)) { - case 0: - break; - case EVENT_TRANSVR_INIT_DOWN: - goto initer_ok_case_down;; - case EVENT_TRANSVR_INIT_FAIL: - snprintf(emsg, elimit, "transceiver type doesn't support"); - goto initer_err_case_alarm_to_user; - case EVENT_TRANSVR_EXCEP_INIT: - default: - goto initer_err_case_unexcept_1; - } - - /* Handle reload case */ - if (self->type != d_type){ - /* This is the protect mechanism. Normally, This case will not happen. - * When State machine detect swap event during initial, It will trigger - * reload function to ensure type correct. */ - if (_reload_transvr_obj(self, d_type) < 0){ - snprintf(emsg, elimit, "reload object fail"); - goto initer_err_case_unexcept_1; - } - } - - /* Check transceiver HW initial ready */ - switch (_is_transvr_hw_ready(self, d_type)) { - case EVENT_TRANSVR_TASK_DONE: - break; - case EVENT_TRANSVR_TASK_WAIT: - goto initer_err_case_retry_1; - case EVENT_TRANSVR_INIT_FAIL: - default: - goto initer_err_case_unexcept_1; - } - - /* Try to update all and check */ - if (self->update_all(self, 1) < 0){ - /* For some transceiver, EEPROME has lag issues during initial stage. - * In this case, we set status back to STATE_TRANSVR_NEW, than it will - * be checked in next polling cycle. */ - goto initer_err_case_retry_1; - } - - /* Execute init() call back */ - result = self->init(self); - switch (result) { - case EVENT_TRANSVR_TASK_DONE: - break; - case EVENT_TRANSVR_TASK_WAIT: - goto initer_ok_case_wait; - - default: - snprintf(emsg, elimit, "undefined init() return:%d\n", result); - goto initer_err_case_unexcept_1; - } - goto initer_ok_case_up; - - -initer_ok_case_wait: - self->dump_all(self); - return EVENT_TRANSVR_TASK_WAIT; - -initer_ok_case_up: - self->state = STATE_TRANSVR_CONNECTED; - self->temp = 0; - self->dump_all(self); - return EVENT_TRANSVR_INIT_UP; - -initer_ok_case_down: - self->temp = 0; - self->state = STATE_TRANSVR_DISCONNECTED; - return EVENT_TRANSVR_INIT_DOWN; - -initer_err_case_i2c_ceash: - SWPS_DEBUG("%s: %s :%s :I2C crash\n", - __func__, emsg, self->swp_name); - self->state = STATE_TRANSVR_UNEXCEPTED; - return EVENT_TRANSVR_I2C_CRASH; - -initer_err_case_be_isolated: - SWPS_DEBUG("%s: %s :%s :isolated\n", - __func__, emsg, self->swp_name); - self->state = STATE_TRANSVR_ISOLATED; - return EVENT_TRANSVR_EXCEP_ISOLATED; - -initer_err_case_retry_1: - SWPS_DEBUG("%s: %s :%s :retry\n", - __func__, emsg, self->swp_name); - if (_transvr_handle_retry(self, retry) == 0) { - self->state = STATE_TRANSVR_NEW; - return EVENT_TRANSVR_INIT_REINIT; - } - goto initer_err_case_alarm_to_user; - -initer_err_case_unexcept_1: - self->clean(self); -initer_err_case_unexcept_0: - self->state = STATE_TRANSVR_UNEXCEPTED; - if (_is_except_happened_4_pmode(self, d_state) && - (self->mode == TRANSVR_MODE_POLLING) ){ - SWPS_INFO("%s: %s :%s\n", __func__, emsg, self->swp_name); - SWPS_INFO("Dump: :%d :%d :%d :%d\n", - self->state, self->type, d_state, d_type); - } - return EVENT_TRANSVR_INIT_FAIL; - -initer_err_case_alarm_to_user: - SWPS_DEBUG("%s: %s :%s :alarm_to_user\n", - __func__, emsg, self->swp_name); - self->state = STATE_TRANSVR_UNEXCEPTED; - alarm_msg_2_user(self, "detected transceiver/cables not meet SFF standard"); - return EVENT_TRANSVR_INIT_FAIL; -} - - -/* ========== Object functions for Clean procedure ========== - */ -int -_transvr_clean_handler(struct transvr_obj_s *self){ - - int retval = DEBUG_TRANSVR_INT_VAL; - - if (!self->clean) { - SWPS_ERR("%s: %s clean() is NULL.\n", - __func__, self->swp_name); - return EVENT_TRANSVR_TASK_FAIL; - } - retval = self->clean(self); - if (retval != EVENT_TRANSVR_TASK_DONE){ - SWPS_ERR("%s: %s clean() fail. [ERR]:%d\n", - __func__, self->swp_name, retval); - return retval; - } - return EVENT_TRANSVR_TASK_DONE; -} - - -int -common_transvr_clean(struct transvr_obj_s *self){ - - transvr_task_free_all(self); - transvr_cache_free_all(self); - return EVENT_TRANSVR_TASK_DONE; -} - - -int -qsfp_transvr_clean(struct transvr_obj_s *self){ - - int retval; - int lpower_config = 1; - - retval = _taskfunc_qsfp_setup_power_mod(self, lpower_config); - if (retval < 0){ - SWPS_ERR("%s: Set lpmod fail! :%d\n", - __func__, retval); - return retval; - } - retval = common_transvr_clean(self); - if (retval < 0){ - SWPS_ERR("%s: common_transvr_clean fail! :%d\n", - __func__, retval); - return retval; - } - return EVENT_TRANSVR_TASK_DONE; -} - - -int -fake_transvr_clean(struct transvr_obj_s *self){ - - return EVENT_TRANSVR_TASK_DONE; -} - - -/* ========== Object functions for check and update ========== - */ -int -common_transvr_check(struct transvr_obj_s *self){ - - char fun_str[32] = "common_transvr_check"; - - if (self->mode != TRANSVR_MODE_POLLING) { - SWPS_ERR("%s: mode:%d is not TRANSVR_MODE_POLLING\n", - fun_str, self->mode); - return ERR_TRANSVR_UNEXCPT; - } - /* Trigger delay task */ - transvr_task_run_all(self); - /* Trigger state machine to check and update */ - return self->fsm_4_polling(self, fun_str); -} - - -int -fake_transvr_check(struct transvr_obj_s *self){ - return 0; -} - - -/* ========== Functions for Factory pattern ========== - */ -static int -setup_transvr_public_cb(struct transvr_obj_s *self, - int transvr_type){ - switch (transvr_type){ - case TRANSVR_TYPE_SFP: - self->get_id = common_get_id; - self->get_ext_id = common_get_ext_id; - self->get_connector = common_get_connector; - self->get_vendor_name = common_get_vendor_name; - self->get_vendor_pn = common_get_vendor_pn; - self->get_vendor_rev = common_get_vendor_rev; - self->get_vendor_sn = common_get_vendor_sn; - self->get_power_cls = unsupported_get_func; - self->get_br = common_get_br; - self->get_len_sm = sfp_get_len_sm; - self->get_len_smf = common_get_len_smf; - self->get_len_om1 = common_get_len_om1; - self->get_len_om2 = common_get_len_om2; - self->get_len_om3 = common_get_len_om3; - self->get_len_om4 = common_get_len_om4; - self->get_comp_rev = common_get_comp_rev; - self->get_comp_eth_1 = sfp_get_comp_eth_1; - self->get_comp_eth_10 = sfp_get_comp_eth_10; - self->get_comp_eth_10_40 = unsupported_get_func; - self->get_comp_extend = common_get_comp_extended; - self->get_cdr = unsupported_get_func; - self->get_rate_id = sfp_get_rate_id; - self->get_soft_rs0 = sfp_get_soft_rs0; - self->get_soft_rs1 = sfp_get_soft_rs1; - self->get_info = common_get_info; - self->get_if_type = sfp_get_if_type; - self->get_if_speed = sfp_get_if_speed; - self->get_if_lane = common_get_if_lane; - self->get_curr_temp = sfp_get_transvr_temp; - self->get_curr_vol = sfp_get_transvr_voltage; - self->get_soft_rx_los = unsupported_get_func2; - self->get_soft_tx_disable = unsupported_get_func2; - self->get_soft_tx_fault = unsupported_get_func2; - self->get_auto_tx_disable = unsupported_get_func2; - self->get_tx_bias = sfp_get_transvr_tx_bias; - self->get_tx_power = sfp_get_transvr_tx_power; - self->get_rx_power = sfp_get_transvr_rx_power; - self->get_tx_eq = sfp_get_transvr_tx_eq; - self->get_rx_am = unsupported_get_func2; - self->get_rx_em = sfp_get_transvr_rx_em; - self->get_wavelength = sfp_get_wavelength; - self->get_extphy_offset = sfp_get_1g_rj45_extphy_offset; - self->get_extphy_reg = sfp_get_1g_rj45_extphy_reg; - self->set_cdr = unsupported_set_func; - self->set_soft_rs0 = sfp_set_soft_rs0; - self->set_soft_rs1 = sfp_set_soft_rs1; - self->set_soft_tx_disable = unsupported_set_func; - self->set_auto_tx_disable = unsupported_set_func; - self->set_tx_eq = sfp_set_tx_eq; - self->set_rx_am = unsupported_set_func; - self->set_rx_em = sfp_set_rx_em; - self->set_extphy_offset = sfp_set_1g_rj45_extphy_offset; - self->set_extphy_reg = sfp_set_1g_rj45_extphy_reg; - self->get_eeprom = common_get_eeprom; - self->get_uppage = common_get_uppage; - return 0; - - case TRANSVR_TYPE_QSFP: - case TRANSVR_TYPE_QSFP_PLUS: - self->get_id = common_get_id; - self->get_ext_id = common_get_ext_id; - self->get_connector = common_get_connector; - self->get_vendor_name = common_get_vendor_name; - self->get_vendor_pn = common_get_vendor_pn; - self->get_vendor_rev = common_get_vendor_rev; - self->get_vendor_sn = common_get_vendor_sn; - self->get_power_cls = qsfp_get_power_cls; - self->get_br = common_get_br; - self->get_len_sm = unsupported_get_func; - self->get_len_smf = common_get_len_smf; - self->get_len_om1 = common_get_len_om1; - self->get_len_om2 = common_get_len_om2; - self->get_len_om3 = common_get_len_om3; - self->get_len_om4 = common_get_len_om4; - self->get_comp_rev = common_get_comp_rev; - self->get_comp_eth_1 = qsfp_get_comp_eth; - self->get_comp_eth_10 = unsupported_get_func; - self->get_comp_eth_10_40 = qsfp_get_comp_10_40; - self->get_comp_extend = common_get_comp_extended; - self->get_cdr = unsupported_get_func; - self->get_rate_id = unsupported_get_func; - self->get_soft_rs0 = unsupported_get_func; /* TBD */ - self->get_soft_rs1 = unsupported_get_func; /* TBD */ - self->get_info = common_get_info; - self->get_if_type = qsfp_get_if_type; - self->get_if_speed = qsfp_get_if_speed; - self->get_if_lane = common_get_if_lane; - self->get_curr_temp = qsfp_get_transvr_temp; - self->get_curr_vol = qsfp_get_transvr_voltage; - self->get_soft_rx_los = qsfp_get_soft_rx_los; - self->get_soft_tx_disable = qsfp_get_soft_tx_disable; - self->get_soft_tx_fault = qsfp_get_soft_tx_fault; - self->get_auto_tx_disable = qsfp_get_auto_tx_disable; - self->get_tx_bias = qsfp_get_transvr_tx_bias; - self->get_tx_power = qsfp_get_transvr_tx_power; - self->get_rx_power = qsfp_get_transvr_rx_power; - self->get_tx_eq = unsupported_get_func2; - self->get_rx_am = unsupported_get_func2; - self->get_rx_em = unsupported_get_func2; - self->get_wavelength = qsfp_get_wavelength; - self->get_extphy_offset = unsupported_get_func2; - self->get_extphy_reg = unsupported_get_func2; - self->set_cdr = unsupported_set_func; - self->set_soft_rs0 = unsupported_set_func; /* TBD */ - self->set_soft_rs1 = unsupported_set_func; /* TBD */ - self->set_soft_tx_disable = qsfp_set_soft_tx_disable; - self->set_auto_tx_disable = qsfp_set_auto_tx_disable; - self->set_tx_eq = unsupported_set_func; - self->set_rx_am = unsupported_set_func; - self->set_rx_em = unsupported_set_func; - self->set_extphy_offset = unsupported_set_func; - self->set_extphy_reg = unsupported_set_func; - self->get_eeprom = common_get_eeprom; - self->get_uppage = common_get_uppage; - return 0; - - case TRANSVR_TYPE_QSFP_28: - self->get_id = common_get_id; - self->get_ext_id = common_get_ext_id; - self->get_connector = common_get_connector; - self->get_vendor_name = common_get_vendor_name; - self->get_vendor_pn = common_get_vendor_pn; - self->get_vendor_rev = common_get_vendor_rev; - self->get_vendor_sn = common_get_vendor_sn; - self->get_power_cls = qsfp_get_power_cls; - self->get_br = common_get_br; - self->get_len_sm = unsupported_get_func; - self->get_len_smf = common_get_len_smf; - self->get_len_om1 = common_get_len_om1; - self->get_len_om2 = common_get_len_om2; - self->get_len_om3 = common_get_len_om3; - self->get_len_om4 = common_get_len_om4; - self->get_comp_rev = common_get_comp_rev; - self->get_comp_eth_1 = qsfp_get_comp_eth; - self->get_comp_eth_10 = unsupported_get_func; - self->get_comp_eth_10_40 = qsfp_get_comp_10_40; - self->get_comp_extend = common_get_comp_extended; - self->get_cdr = qsfp_get_cdr; - self->get_rate_id = unsupported_get_func; - self->get_soft_rs0 = unsupported_get_func; /* TBD */ - self->get_soft_rs1 = unsupported_get_func; /* TBD */ - self->get_info = common_get_info; - self->get_if_type = qsfp_get_if_type; - self->get_if_speed = qsfp_get_if_speed; - self->get_if_lane = common_get_if_lane; - self->get_curr_temp = qsfp_get_transvr_temp; - self->get_curr_vol = qsfp_get_transvr_voltage; - self->get_soft_rx_los = qsfp_get_soft_rx_los; - self->get_soft_tx_disable = qsfp_get_soft_tx_disable; - self->get_soft_tx_fault = qsfp_get_soft_tx_fault; - self->get_auto_tx_disable = qsfp_get_auto_tx_disable; - self->get_tx_bias = qsfp_get_transvr_tx_bias; - self->get_tx_power = qsfp_get_transvr_tx_power; - self->get_rx_power = qsfp_get_transvr_rx_power; - self->get_tx_eq = qsfp_get_transvr_tx_eq; - self->get_rx_am = qsfp_get_transvr_rx_am; - self->get_rx_em = qsfp_get_transvr_rx_em; - self->get_wavelength = qsfp_get_wavelength; - self->get_extphy_offset = unsupported_get_func2; - self->get_extphy_reg = unsupported_get_func2; - self->set_cdr = qsfp_set_cdr; - self->set_soft_rs0 = unsupported_set_func; /* TBD */ - self->set_soft_rs1 = unsupported_set_func; /* TBD */ - self->set_soft_tx_disable = qsfp_set_soft_tx_disable; - self->set_auto_tx_disable = qsfp_set_auto_tx_disable; - self->set_tx_eq = qsfp_set_tx_eq; - self->set_rx_am = qsfp_set_rx_am; - self->set_rx_em = qsfp_set_rx_em; - self->set_extphy_offset = unsupported_set_func; - self->set_extphy_reg = unsupported_set_func; - self->get_eeprom = common_get_eeprom; - self->get_uppage = common_get_uppage; - return 0; - - case TRANSVR_TYPE_FAKE: - self->get_id = fake_get_hex; - self->get_ext_id = fake_get_hex; - self->get_connector = fake_get_hex; - self->get_vendor_name = fake_get_str; - self->get_vendor_pn = fake_get_str; - self->get_vendor_rev = fake_get_str; - self->get_vendor_sn = fake_get_str; - self->get_power_cls = fake_get_int; - self->get_br = fake_get_hex; - self->get_len_sm = fake_get_int; - self->get_len_smf = fake_get_int; - self->get_len_om1 = fake_get_int; - self->get_len_om2 = fake_get_int; - self->get_len_om3 = fake_get_int; - self->get_len_om4 = fake_get_int; - self->get_comp_rev = fake_get_hex; - self->get_comp_eth_1 = fake_get_hex; - self->get_comp_eth_10 = fake_get_hex; - self->get_comp_eth_10_40 = fake_get_hex; - self->get_comp_extend = fake_get_hex; - self->get_cdr = fake_get_hex; - self->get_rate_id = fake_get_hex; - self->get_soft_rs0 = fake_get_binary; - self->get_soft_rs1 = fake_get_binary; - self->get_info = fake_get_int; - self->get_if_type = fake_get_str; - self->get_if_speed = fake_get_str; - self->get_if_lane = fake_get_str; - self->get_curr_temp = fake_get_str; - self->get_curr_vol = fake_get_str; - self->get_soft_rx_los = fake_get_str; - self->get_soft_tx_disable = fake_get_str; - self->get_soft_tx_fault = fake_get_str; - self->get_auto_tx_disable = fake_get_str; - self->get_tx_bias = fake_get_str; - self->get_tx_power = fake_get_str; - self->get_rx_power = fake_get_str; - self->get_tx_eq = fake_get_str; - self->get_rx_am = fake_get_str; - self->get_rx_em = fake_get_str; - self->get_wavelength = fake_get_str; - self->get_extphy_offset = fake_get_str; - self->get_extphy_reg = fake_get_str; - self->set_cdr = fake_set_hex; - self->set_soft_rs0 = fake_set_int; - self->set_soft_rs1 = fake_set_int; - self->set_soft_tx_disable = fake_set_int; - self->set_auto_tx_disable = fake_set_int; - self->set_tx_eq = fake_set_int; - self->set_rx_am = fake_set_int; - self->set_rx_em = fake_set_int; - self->set_extphy_offset = fake_set_hex; - self->set_extphy_reg = fake_set_hex; - self->get_eeprom = fake_get_str; - self->get_uppage = fake_get_str; - return 0; - - default: - break; - } - SWPS_WARN("%s: Detect non-defined type:%d\n", __func__, transvr_type); - return ERR_TRANSVR_UNEXCPT; -} - - -static int -setup_transvr_private_cb(struct transvr_obj_s *self, - int transvr_type){ - switch (transvr_type){ - case TRANSVR_TYPE_SFP: - self->init = transvr_init_sfp; - self->clean = common_transvr_clean; - self->check = common_transvr_check; - self->update_all = _sfp_update_attr_all; - self->fsm_4_direct = common_fsm_4_direct_mode; - self->fsm_4_polling = common_fsm_4_polling_mode; - self->send_uevent = sfp_send_uevent; - self->dump_all = sfp_transvr_dump; - return 0; - - case TRANSVR_TYPE_QSFP: - case TRANSVR_TYPE_QSFP_PLUS: - self->init = transvr_init_qsfp; - self->clean = qsfp_transvr_clean; - self->check = common_transvr_check; - self->update_all = _qsfp_update_attr_all; - self->fsm_4_direct = common_fsm_4_direct_mode; - self->fsm_4_polling = common_fsm_4_polling_mode; - self->send_uevent = qsfp_send_uevent; - self->dump_all = qsfp_transvr_dump; - return 0; - - case TRANSVR_TYPE_QSFP_28: - self->init = transvr_init_qsfp28; - self->clean = qsfp_transvr_clean; - self->check = common_transvr_check; - self->update_all = _qsfp_update_attr_all; - self->fsm_4_direct = common_fsm_4_direct_mode; - self->fsm_4_polling = common_fsm_4_polling_mode; - self->send_uevent = qsfp_send_uevent; - self->dump_all = qsfp_transvr_dump; - return 0; - - case TRANSVR_TYPE_FAKE: - self->init = transvr_init_fake; - self->clean = fake_transvr_clean; - self->check = fake_transvr_check; - self->update_all = fake_transvr_update; - self->fsm_4_direct = fake_fsm_4_direct_mode; - self->fsm_4_polling = fake_fsm_4_polling_mode; - self->send_uevent = fake_send_uevent; - self->dump_all = fake_transvr_dump; - return 0; - - default: - break; - } - SWPS_WARN("%s: Detect non-defined type:%d\n", __func__, transvr_type); - return ERR_TRANSVR_UNEXCPT; -} - - -static struct eeprom_map_s * -get_eeprom_map(int transvr_type){ - - switch (transvr_type){ - case TRANSVR_TYPE_SFP: - return &eeprom_map_sfp; - case TRANSVR_TYPE_QSFP: - case TRANSVR_TYPE_QSFP_PLUS: - return &eeprom_map_qsfp; - case TRANSVR_TYPE_QSFP_28: - return &eeprom_map_qsfp28; - - default: - break; - } - SWPS_WARN("%s: Detect non-defined type:%d\n", __func__, transvr_type); - return NULL; -} - - -static int -setup_transvr_ssize_attr(char *swp_name, - struct transvr_obj_s *self, - struct eeprom_map_s *map_p, - struct ioexp_obj_s *ioexp_obj_p, - int ioexp_virt_offset, - int transvr_type, - int chipset_type, - int chan_id, - int run_mode){ - switch (run_mode){ - case TRANSVR_MODE_DIRECT: /* Direct access device mode */ - case TRANSVR_MODE_POLLING: /* Polling mode, read from cache */ - self->mode = run_mode; - break; - default: - SWPS_ERR("%s: non-defined run_mode:%d\n", - __func__, run_mode); - self->mode = DEBUG_TRANSVR_INT_VAL; - return -1; - } - self->eeprom_map_p = map_p; - self->ioexp_obj_p = ioexp_obj_p; - self->ioexp_virt_offset = ioexp_virt_offset; - self->chan_id = chan_id; - self->layout = transvr_type; - self->type = transvr_type; - self->chipset_type = chipset_type; - self->state = STATE_TRANSVR_NEW; - self->info = STATE_TRANSVR_NEW; - self->auto_tx_disable = VAL_TRANSVR_FUNCTION_DISABLE; - strncpy(self->swp_name, swp_name, 32); - mutex_init(&self->lock); - return 0; -} - - -static int -setup_transvr_dsize_attr(struct transvr_obj_s *self){ - - char *emsg = DEBUG_TRANSVR_STR_VAL; - - self->vendor_name = kzalloc((LEN_TRANSVR_M_STR * sizeof(char)), GFP_KERNEL); - if (!self->vendor_name){ - emsg = "vendor_name"; - goto err_setup_d_attr; - } - self->vendor_pn = kzalloc((LEN_TRANSVR_M_STR * sizeof(char)), GFP_KERNEL); - if (!self->vendor_pn){ - emsg = "vendor_pn"; - goto err_setup_d_attr; - } - self->vendor_rev = kzalloc((LEN_TRANSVR_M_STR * sizeof(char)), GFP_KERNEL); - if (!self->vendor_rev){ - emsg = "vendor_rev"; - goto err_setup_d_attr; - } - self->vendor_sn = kzalloc((LEN_TRANSVR_M_STR * sizeof(char)), GFP_KERNEL); - if (!self->vendor_sn){ - emsg = "vendor_sn"; - goto err_setup_d_attr; - } - self->worker_p = NULL; - return 0; - -err_setup_d_attr: - SWPS_ERR("%s: %s kzalloc fail!", __func__, emsg); - return ERR_TRANSVR_UNEXCPT; -} - - -static int -setup_i2c_client(struct transvr_obj_s *self){ - - struct i2c_adapter *adap = NULL; - struct i2c_client *client = NULL; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - - adap = i2c_get_adapter(self->chan_id); - if(!adap){ - snprintf(err_msg, sizeof(err_msg), - "can not get adap:%d", self->chan_id); - goto err_setup_i2c_client; - } - client = kzalloc(sizeof(*client), GFP_KERNEL); - if (!client){ - snprintf(err_msg, sizeof(err_msg), - "can not kzalloc client:%d", self->chan_id); - goto err_setup_i2c_client; - } - client->adapter = adap; - self->i2c_client_p = client; - self->i2c_client_p->addr = VAL_TRANSVR_COMID_ARREESS; - return 0; - -err_setup_i2c_client: - SWPS_ERR("%s: %s\n", __func__, err_msg); - return ERR_TRANSVR_UNEXCPT; -} - - -struct transvr_obj_s * -create_transvr_obj(char *swp_name, - int chan_id, - struct ioexp_obj_s *ioexp_obj_p, - int ioexp_virt_offset, - int transvr_type, - int chipset_type, - int run_mode){ - - struct transvr_obj_s *result_p; - struct eeprom_map_s *map_p; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - - /* Allocate transceiver object */ - map_p = get_eeprom_map(transvr_type); - if (!map_p){ - snprintf(err_msg, sizeof(err_msg), - "Invalid transvr_type:%d", transvr_type); - goto err_create_transvr_fail; - } - result_p = kzalloc(sizeof(*result_p), GFP_KERNEL); - if (!result_p){ - snprintf(err_msg, sizeof(err_msg), "kzalloc fail"); - goto err_create_transvr_fail; - } - /* Prepare static size attributes */ - if (setup_transvr_ssize_attr(swp_name, - result_p, - map_p, - ioexp_obj_p, - ioexp_virt_offset, - transvr_type, - chipset_type, - chan_id, - run_mode) < 0){ - goto err_create_transvr_sattr_fail; - } - /* Prepare dynamic size attributes */ - if (setup_transvr_dsize_attr(result_p) < 0){ - goto err_create_transvr_dattr_fail; - } - /* Prepare call back functions of object */ - if (setup_transvr_public_cb(result_p, transvr_type) < 0){ - goto err_create_transvr_dattr_fail; - } - /* Prepare call back functions of object */ - if (setup_transvr_private_cb(result_p, transvr_type) < 0){ - goto err_create_transvr_dattr_fail; - } - /* Prepare i2c client object */ - if (setup_i2c_client(result_p) < 0){ - goto err_create_transvr_dattr_fail; - } - return result_p; - -err_create_transvr_dattr_fail: - kfree(result_p->vendor_sn); - kfree(result_p->vendor_rev); - kfree(result_p->vendor_pn); - kfree(result_p->vendor_name); -err_create_transvr_sattr_fail: - kfree(result_p); -err_create_transvr_fail: - SWPS_ERR("%s: %s :%d :%d :%d\n", - __func__, err_msg, chan_id, ioexp_virt_offset, transvr_type); - return NULL; -} - - -static int -_reload_transvr_obj(struct transvr_obj_s *self, - int new_type){ - - struct eeprom_map_s *new_map_p; - struct eeprom_map_s *old_map_p = self->eeprom_map_p; - struct i2c_client *old_i2c_p = self->i2c_client_p; - int old_type = self->type; - - /* Change state to STATE_TRANSVR_INIT */ - self->state = STATE_TRANSVR_INIT; - self->type = new_type; - /* Replace EEPROME map */ - new_map_p = get_eeprom_map(new_type); - if (!new_map_p){ - goto err_private_reload_func_1; - } - self->eeprom_map_p = new_map_p; - /* Reload i2c client */ - if (setup_i2c_client(self) < 0){ - goto err_private_reload_func_2; - } - /* Replace call back functions */ - if (setup_transvr_public_cb(self, new_type) < 0){ - goto err_private_reload_func_3; - } - if (setup_transvr_private_cb(self, new_type) < 0){ - goto err_private_reload_func_3; - } - kfree(old_i2c_p); - return 0; - -err_private_reload_func_3: - SWPS_INFO("%s: init() fail!\n", __func__); - kfree(old_i2c_p); - self->state = STATE_TRANSVR_UNEXCEPTED; - self->type = TRANSVR_TYPE_ERROR; - return -2; - -err_private_reload_func_2: - self->eeprom_map_p = old_map_p; - self->i2c_client_p = old_i2c_p; -err_private_reload_func_1: - self->state = STATE_TRANSVR_UNEXCEPTED; - self->type = old_type; - SWPS_INFO("%s fail! :0x%02x\n", __func__, new_type); - return -1; -} - - -static int -reload_transvr_obj(struct transvr_obj_s *self, - int new_type){ - - int result_val = ERR_TRANSVR_UNEXCPT; - - /* Reload phase */ - result_val = _reload_transvr_obj(self, new_type); - if (result_val < 0){ - SWPS_INFO("%s: reload phase fail! :%d\n", - __func__, result_val); - return EVENT_TRANSVR_RELOAD_FAIL; - } - /* Initial phase */ - result_val = _transvr_init_handler(self); - if (result_val < 0){ - SWPS_INFO("%s: initial phase fail! :%d\n", - __func__, result_val); - } - return result_val; -} - - -int -isolate_transvr_obj(struct transvr_obj_s *self) { - - self->state = STATE_TRANSVR_ISOLATED; - SWPS_INFO("%s: %s be isolated\n", __func__, self->swp_name); - return 0; -} - - -int -resync_channel_tier_2(struct transvr_obj_s *self) { - - int val = TRANSVR_TYPE_ERROR; - - if (self->state == STATE_TRANSVR_ISOLATED) { - return 0; - } - self->i2c_client_p->addr = VAL_TRANSVR_COMID_ARREESS; - val = i2c_smbus_read_byte_data(self->i2c_client_p, - VAL_TRANSVR_COMID_OFFSET); - if (val < 0) { - return -1; - } - return 0; -} - - -/* ----------------------------------------- - * ToDo List - * ----------------------------------------- - * 1. _sfp_detect_class_by_feature() - * => Need check ACC use case. - * 2. _sfp_detect_class_by_1g_ethernet() - * => Need check 0.1G use case. - * 3. Loopback transceiver use case. - * => Less much data - * 4. _qsfp_detect_class_by_extend_comp() - * => Verify 100G CWDM4 - * => Verify Obsolete (assigned before 100G CWDM4 MSA required FEC) - * => Verify 100G CLR4 - * => Verify 100GE-DWDM2 - * => Verify 40G PSM4 Parallel SMF - * => Verify 100G ACC (Active Copper Cable) or 25GAUI C2M ACC. - * => Verify 100G ACC or 25GAUI C2M ACC. - * => Verify 25GBASE-LR - * => Verify 40G Active Cable (XLPPI) - */ - - - - - - diff --git a/packages/platforms/inventec/x86-64/d3352/modules/builds/src/transceiver.h b/packages/platforms/inventec/x86-64/d3352/modules/builds/src/transceiver.h deleted file mode 100644 index 240da15fa..000000000 --- a/packages/platforms/inventec/x86-64/d3352/modules/builds/src/transceiver.h +++ /dev/null @@ -1,813 +0,0 @@ -#ifndef TRANSCEIVER_H -#define TRANSCEIVER_H - -#include - -/* advanced features control */ -#define TRANSVR_INFO_DUMP_ENABLE (1) -#define TRANSVR_INFO_CACHE_ENABLE (1) -#define TRANSVR_UEVENT_ENABLE (1) - -/* Transceiver type define */ -#define TRANSVR_TYPE_UNKNOW_1 (0x00) -#define TRANSVR_TYPE_UNKNOW_2 (0xff) -#define TRANSVR_TYPE_SFP (0x03) /* Define for SFP, SFP+, SFP28 */ -#define TRANSVR_TYPE_QSFP (0x0c) -#define TRANSVR_TYPE_QSFP_PLUS (0x0d) -#define TRANSVR_TYPE_QSFP_28 (0x11) -#define TRANSVR_TYPE_UNPLUGGED (0xfa) /* Define for ERROR handle */ -#define TRANSVR_TYPE_FAKE (0xfc) /* Define for ERROR handle */ -#define TRANSVR_TYPE_INCONSISTENT (0xfd) /* Define for ERROR handle */ -#define TRANSVR_TYPE_ERROR (0xfe) /* Define for ERROR handle */ - -/* Transceiver class for base info */ -#define TRANSVR_CLASS_UNSPECIFIED (0) -#define TRANSVR_CLASS_ERROR (-26001) -#define TRANSVR_CLASS_1G (26001) -#define TRANSVR_CLASS_10G (26011) -#define TRANSVR_CLASS_25G (26021) -#define TRANSVR_CLASS_40G (26041) -#define TRANSVR_CLASS_100G (26101) -#define TRANSVR_CLASS_NO_SPERARABLE (26901) -#define TRANSVR_CLASS_EXTEND_COMP (26902) -/* Transceiver class for Optical 1G */ -#define TRANSVR_CLASS_OPTICAL (27000) -#define TRANSVR_CLASS_OPTICAL_100 (27001) -#define TRANSVR_CLASS_OPTICAL_1G (27002) -#define TRANSVR_CLASS_OPTICAL_1G_AOC (27003) -#define TRANSVR_CLASS_OPTICAL_1G_SX (27004) -#define TRANSVR_CLASS_OPTICAL_1G_LX (27005) -#define TRANSVR_CLASS_OPTICAL_1G_EX (27006) -/* Transceiver class for Optical 10G */ -#define TRANSVR_CLASS_OPTICAL_10G (27010) -#define TRANSVR_CLASS_OPTICAL_10G_S_AOC (27011) -#define TRANSVR_CLASS_OPTICAL_10G_S_SR (27012) -#define TRANSVR_CLASS_OPTICAL_10G_S_LR (27013) -#define TRANSVR_CLASS_OPTICAL_10G_S_ER (27014) -#define TRANSVR_CLASS_OPTICAL_10G_Q_AOC (27015) -#define TRANSVR_CLASS_OPTICAL_10G_Q_SR (27016) -#define TRANSVR_CLASS_OPTICAL_10G_Q_LR (27017) -#define TRANSVR_CLASS_OPTICAL_10G_Q_ER (27018) -/* Transceiver class for Optical 25G */ -#define TRANSVR_CLASS_OPTICAL_25G (27020) -#define TRANSVR_CLASS_OPTICAL_25G_AOC (27021) -#define TRANSVR_CLASS_OPTICAL_25G_SR (27022) -#define TRANSVR_CLASS_OPTICAL_25G_LR (27023) -#define TRANSVR_CLASS_OPTICAL_25G_ER (27024) -/* Transceiver class for Optical 40G */ -#define TRANSVR_CLASS_OPTICAL_40G (27040) -#define TRANSVR_CLASS_OPTICAL_40G_AOC (27041) -#define TRANSVR_CLASS_OPTICAL_40G_SR4 (27042) -#define TRANSVR_CLASS_OPTICAL_40G_LR4 (27043) -#define TRANSVR_CLASS_OPTICAL_40G_ER4 (27044) -/* Transceiver class for Optical 100G */ -#define TRANSVR_CLASS_OPTICAL_100G (27100) -#define TRANSVR_CLASS_OPTICAL_100G_AOC (27101) -#define TRANSVR_CLASS_OPTICAL_100G_SR4 (27102) -#define TRANSVR_CLASS_OPTICAL_100G_LR4 (27103) -#define TRANSVR_CLASS_OPTICAL_100G_ER4 (27104) -#define TRANSVR_CLASS_OPTICAL_100G_PSM4 (27105) -/* Transceiver class for Copper */ -#define TRANSVR_CLASS_COPPER (28000) -#define TRANSVR_CLASS_COPPER_L1_1G (28001) -#define TRANSVR_CLASS_COPPER_L1_10G (28011) -#define TRANSVR_CLASS_COPPER_L4_10G (28012) -#define TRANSVR_CLASS_COPPER_L1_25G (28021) -#define TRANSVR_CLASS_COPPER_L4_40G (28041) -#define TRANSVR_CLASS_COPPER_L4_100G (28101) -/* Transceiver class for Base-T */ -#define TRANSVR_CLASS_BASE_T_1000 (29001) -#define TRANSVR_CLASS_BASE_T_1000_up (29002) -/* For uevent message */ -#define TRANSVR_UEVENT_KEY_IF "IF_TYPE" -#define TRANSVR_UEVENT_KEY_SP "IF_SPEED" -#define TRANSVR_UEVENT_KEY_LANE "IF_LANE" -#define TRANSVR_UEVENT_UNKNOW "UNKNOW" -#define TRANSVR_IF_KR "KR" -#define TRANSVR_IF_KR4 "KR4" -#define TRANSVR_IF_SR "SR" -#define TRANSVR_IF_SR4 "SR4" -#define TRANSVR_IF_SFI "SFI" -#define TRANSVR_IF_IF_GMII "GMII" -#define TRANSVR_IF_IF_XGMII "XGMII" -#define TRANSVR_IF_SP_100 "100" -#define TRANSVR_IF_SP_1G "1000" -#define TRANSVR_IF_SP_10G "10000" -#define TRANSVR_IF_SP_25G "25000" -#define TRANSVR_IF_SP_40G "40000" -#define TRANSVR_IF_SP_100G "100000" - -/* Transceiver mode define */ -#define TRANSVR_MODE_DIRECT (21000) -#define TRANSVR_MODE_POLLING (21001) - -/* Transceiver state define - * [Note] - * 1. State is used to represent the state of "Transceiver" and "Object". - * 2. State for different target has different means. The description as following: - */ -#define STATE_TRANSVR_CONNECTED (0) /* [Transvr]:Be plugged in. [Obj]:Link up, and work normally. */ -#define STATE_TRANSVR_NEW (-100) /* [Transvr]:(Not used) [Obj]:Create */ -#define STATE_TRANSVR_INIT (-101) /* [Transvr]:Be plugged in. [Obj]:Link up, and in initial process. */ -#define STATE_TRANSVR_ISOLATED (-102) /* [Transvr]:Be plugged in. [Obj]:Isolate, and not provide service. */ -#define STATE_TRANSVR_SWAPPED (-200) /* [Transvr]:Be plugged in. [Obj]:(Not used) */ -#define STATE_TRANSVR_DISCONNECTED (-300) /* [Transvr]:Un-plugged. [Obj]:Link down, and not provide service. */ -#define STATE_TRANSVR_UNEXCEPTED (-901) /* [Transvr]:Any [Obj]:Any, and not in expect case. */ - -/* Task state define */ -#define STATE_T_TASK_WAIT (110) -#define STATE_T_TASK_DONE (0) -#define STATE_T_TASK_INIT (-110) -#define STATE_T_TASK_FAIL (-410) - - -/* Event for task handling */ -#define EVENT_TRANSVR_TASK_WAIT (2101) -#define EVENT_TRANSVR_TASK_DONE (0) -#define EVENT_TRANSVR_TASK_FAIL (-2101) -/* Event for initial handling */ -#define EVENT_TRANSVR_INIT_UP (2201) -#define EVENT_TRANSVR_INIT_DOWN (1) -#define EVENT_TRANSVR_INIT_REINIT (-2201) -#define EVENT_TRANSVR_INIT_FAIL (-2202) -/* Event for others */ -#define EVENT_TRANSVR_RELOAD_FAIL (-2301) -#define EVENT_TRANSVR_EXCEP_INIT (-2401) -#define EVENT_TRANSVR_EXCEP_UP (-2402) -#define EVENT_TRANSVR_EXCEP_DOWN (-2403) -#define EVENT_TRANSVR_EXCEP_SWAP (-2404) -#define EVENT_TRANSVR_EXCEP_EXCEP (-2405) -#define EVENT_TRANSVR_EXCEP_ISOLATED (-2406) -#define EVENT_TRANSVR_I2C_CRASH (-2501) - -/* Transceiver error code define */ -#define ERR_TRANSVR_UNINIT (-201) -#define ERR_TRANSVR_UNPLUGGED (-202) -#define ERR_TRANSVR_ABNORMAL (-203) -#define ERR_TRANSVR_NOSTATE (-204) -#define ERR_TRANSVR_NOTSUPPORT (-205) -#define ERR_TRANSVR_BADINPUT (-206) -#define ERR_TRANSVR_UPDATE_FAIL (-207) -#define ERR_TRANSVR_RELOAD_FAIL (-208) -#define ERR_TRANSVR_INIT_FAIL (-209) -#define ERR_TRANSVR_UNDEFINED (-210) -#define ERR_TRANSVR_TASK_FAIL (-211) -#define ERR_TRANSVR_TASK_BUSY (-212) -#define ERR_TRANSVR_UEVENT_FAIL (-213) -#define ERR_TRANSVR_FUNC_DISABLE (-214) -#define ERR_TRANSVR_I2C_CRASH (-297) -#define ERR_TRNASVR_BE_ISOLATED (-298) -#define ERR_TRANSVR_UNEXCPT (-299) - -/* For debug */ -#define DEBUG_TRANSVR_INT_VAL (-99) -#define DEBUG_TRANSVR_HEX_VAL (0xfe) -#define DEBUG_TRANSVR_STR_VAL "ERROR" - -/* For system internal */ -#define VAL_TRANSVR_COMID_ARREESS (0x50) -#define VAL_TRANSVR_COMID_OFFSET (0x00) -#define VAL_TRANSVR_EXTPHY_ADDR_56 (0x56) -#define VAL_TRANSVR_8472_READY_ADDR (0x51) -#define VAL_TRANSVR_8472_READY_PAGE (-1) -#define VAL_TRANSVR_8472_READY_OFFSET (110) -#define VAL_TRANSVR_8472_READY_BIT (0) -#define VAL_TRANSVR_8472_READY_VALUE (0) -#define VAL_TRANSVR_8472_READY_ABNORMAL (0xff) -#define VAL_TRANSVR_8436_READY_ADDR (0x50) -#define VAL_TRANSVR_8436_READY_PAGE (-1) -#define VAL_TRANSVR_8436_READY_OFFSET (2) -#define VAL_TRANSVR_8436_READY_BIT (0) -#define VAL_TRANSVR_8436_READY_VALUE (0) -#define VAL_TRANSVR_8436_READY_ABNORMAL (0xff) -#define VAL_TRANSVR_8436_PWD_ADDR (0x50) -#define VAL_TRANSVR_8436_PWD_PAGE (-1) -#define VAL_TRANSVR_8436_PWD_OFFSET (123) -#define VAL_TRANSVR_PAGE_FREE (-99) -#define VAL_TRANSVR_PAGE_SELECT_OFFSET (127) -#define VAL_TRANSVR_PAGE_SELECT_DELAY (5) -#define VAL_TRANSVR_TASK_RETRY_FOREVER (-999) -#define VAL_TRANSVR_FUNCTION_DISABLE (-1) -#define STR_TRANSVR_SFP "SFP" -#define STR_TRANSVR_QSFP "QSFP" -#define STR_TRANSVR_QSFP_PLUS "QSFP+" -#define STR_TRANSVR_QSFP28 "QSFP28" - -/* For transvr buf len */ -#define LEN_TRANSVR_S_STR (16) -#define LEN_TRANSVR_M_STR (32) -#define LEN_TRANSVR_L_STR (64) - -/* Optical wavelength */ -#define VAL_OPTICAL_WAVELENGTH_SR (850) -#define VAL_OPTICAL_WAVELENGTH_LR (1310) -#define VAL_OPTICAL_WAVELENGTH_ER (1550) - -/* BCM chip type define */ -#define CHIP_TYPE_MAGNOLIA (31001) /* Magnolia, Hudson32i, Spruce */ -#define CHIP_TYPE_REDWOOD (31002) /* Redwood, Cypress, Sequoia */ - -#define CHIP_TYPE_LAVENDER (31011) /* Lavender */ - -/* Info from transceiver EEPROM */ -struct eeprom_map_s { - int addr_br; int page_br; int offset_br; int length_br; - int addr_cdr; int page_cdr; int offset_cdr; int length_cdr; - int addr_comp_rev; int page_comp_rev; int offset_comp_rev; int length_comp_rev; - int addr_connector; int page_connector; int offset_connector; int length_connector; - int addr_diag_type; int page_diag_type; int offset_diag_type; int length_diag_type; - int addr_extbr; int page_extbr; int offset_extbr; int length_extbr; - int addr_ext_id; int page_ext_id; int offset_ext_id; int length_ext_id; - int addr_id; int page_id; int offset_id; int length_id; - int addr_len_sm; int page_len_sm; int offset_len_sm; int length_len_sm; - int addr_len_smf; int page_len_smf; int offset_len_smf; int length_len_smf; - int addr_len_om1; int page_len_om1; int offset_len_om1; int length_len_om1; - int addr_len_om2; int page_len_om2; int offset_len_om2; int length_len_om2; - int addr_len_om3; int page_len_om3; int offset_len_om3; int length_len_om3; - int addr_len_om4; int page_len_om4; int offset_len_om4; int length_len_om4; - int addr_option; int page_option; int offset_option; int length_option; - int addr_rate_id; int page_rate_id; int offset_rate_id; int length_rate_id; - int addr_rx_am; int page_rx_am; int offset_rx_am; int length_rx_am; - int addr_rx_em; int page_rx_em; int offset_rx_em; int length_rx_em; - int addr_rx_los; int page_rx_los; int offset_rx_los; int length_rx_los; - int addr_rx_power; int page_rx_power; int offset_rx_power; int length_rx_power; - int addr_soft_rs0; int page_soft_rs0; int offset_soft_rs0; int length_soft_rs0; - int addr_soft_rs1; int page_soft_rs1; int offset_soft_rs1; int length_soft_rs1; - int addr_temp; int page_temp; int offset_temp; int length_temp; - int addr_trancomp; int page_trancomp; int offset_trancomp; int length_trancomp; - int addr_trancomp_ext; int page_trancomp_ext; int offset_trancomp_ext; int length_trancomp_ext; - int addr_tx_bias; int page_tx_bias; int offset_tx_bias; int length_tx_bias; - int addr_tx_disable; int page_tx_disable; int offset_tx_disable; int length_tx_disable; - int addr_tx_eq; int page_tx_eq; int offset_tx_eq; int length_tx_eq; - int addr_tx_fault; int page_tx_fault; int offset_tx_fault; int length_tx_fault; - int addr_tx_power; int page_tx_power; int offset_tx_power; int length_tx_power; - int addr_vendor_name; int page_vendor_name; int offset_vendor_name; int length_vendor_name; - int addr_vendor_pn; int page_vendor_pn; int offset_vendor_pn; int length_vendor_pn; - int addr_vendor_rev; int page_vendor_rev; int offset_vendor_rev; int length_vendor_rev; - int addr_vendor_sn; int page_vendor_sn; int offset_vendor_sn; int length_vendor_sn; - int addr_voltage; int page_voltage; int offset_voltage; int length_voltage; - int addr_wavelength; int page_wavelength; int offset_wavelength; int length_wavelength; - int addr_eeprom; int page_eeprom; int offset_eeprom; int length_eeprom; - int addr_uppage; int page_uppage; int offset_uppage; int length_uppage; -}; - - -struct transvr_worker_s; - -/* Class of transceiver object */ -struct transvr_obj_s { - - /* ========== Object private property ========== - * [Prop]: id - * [Desc]: Type of serial transceiver. - * [Note]: SFP:03h / QSFP:0Ch / QSPF+:0Dh /QSFP28:11h - */ - uint8_t id; - - /* [Prop]: connector - * [Desc]: Connector type. - * [Note]: SFP : A0h / 2 - * QSFP: 00h / 130 - */ - uint8_t connector; - - /* [Prop]: transvr_comp - * [Desc]: Transceiver compliance code. - * [Note]: SFP: SFF-8472 - * - Normal : A0h / offset 3-10 - * - Extended: A0h / offset 36 - * QSFP: SFF-8436 & SFF-8636 - * - Normal : 00h / offset 131-138 - * - Extended: 00h / offset 192 - */ - uint8_t transvr_comp[8]; - uint8_t transvr_comp_ext; - - /* [Prop]: vendor_name - * [Desc]: SFP vendor name (ASCII 16 byte char). - * [Note]: ex:FINISAR CORP. - */ - char *vendor_name; - - /* [Prop]: vendor_pn - * [Desc]: Part number provided by SFP vendor (ASCII 16 byte char). - * [Note]: - */ - char *vendor_pn; - - /* [Prop]: vendor_rev - * [Desc]: Revision level for part number provided by vendor (ASCII 4 byte char). - * [Note]: - */ - char *vendor_rev; - - /* [Prop]: vendor_sn - * [Desc]: Serial number provided by vendor (ASCII 16 byte char). - * [Note]: - */ - char *vendor_sn; - - /* [Prop]: Extended identifier - * [Desc]: SFP: - * => None - * - * QSFP: - * => This byte contained two information: - * (1) Power consumption class - * (2) CDR function present - * [Note]: Bit description as below: - * [SFP] - * None - * - * [QSFP] - * (1) Power consumption class: - * Class 1: 1.5W (Bit6-7 = 00:) - * Class 2: 2.0W (Bit6-7 = 01:) - * Class 3: 2.5W (Bit6-7 = 10:) - * Class 4: 3.5W (Bit6-7 = 11:) - * Class 5: 4.0W (Bit0-1 = 01:) - * Class 6: 4.5W (Bit0-1 = 10:) - * Class 7: 5.0W (Bit0-1 = 11:) - * (2) CDR function present: - * Bit2: 0 = No CDR in RX - * 1 = CDR present in RX - * Bit3: 0 = No CDR in TX - * 1 = CDR present in TX - */ - uint8_t ext_id; - - /* [Prop]: br - * [Desc]: Nominal bit rate, units of 100 MBits/sec. - * [Note]: SFP:03h / QSFP:0Ch / QSPF+:0Dh - * has val: 0x67 - * no val : - */ - uint8_t br; - - /* [Prop]: extbr - * [Desc]: Extended br (00h/222) - * [Desc]: Nominal bit rate per channel, units of 250 Mbps. - * Complements. Byte 140. See Table 32A. - */ - uint8_t extbr; - - /* [Prop]: len_sm - * [Desc]: Length (single mode)-(100's)m - * [Note]: This value specifies the link length that is supported by the transceiver - * while operating in compliance with the applicable standards using single mode - * fiber. The value is in units of 100 meters. A value of 255 means that the - * transceiver supports a link length greater than 25.4 km. A value of zero means - * that the transceiver does not support single mode fiber or that the length - * information must be determined from the transceiver technology. - */ - int len_sm; - - /* [Prop]: len_smf - * [Desc]: Length (single mode)-km - * [Note]: Addition to EEPROM data from original GBIC definition. This value specifies - * the link length that is supported by the transceiver while operating in - * compliance with the applicable standards using single mode fiber. The value - * is in units of kilometers. A value of 255 means that the transceiver supports - * a link length greater than 254 km. A value of zero means that the transceiver - * does not support single mode fiber or that the length information must be - * determined from the transceiver technology. - */ - int len_smf; - - /* [Prop]: len_om1 - * [Desc]: Link length supported for 62.5 um OM1 fiber, units of 10 m - * [Note]: The value is in units of 10 meters. A value of 255 means that the - * transceiver supports a link length greater than 2.54 km. A value of - * zero means that the transceiver does not support 50 micron multi-mode - * fiber or that the length information must be determined from the transceiver - * technology. - */ - int len_om1; - - /* [Prop]: len_om2 - * [Desc]: Link length supported for 50 um OM2 fiber, units of 10 m - * [Note]: The value is in units of 10 meters. A value of 255 means that the - * transceiver supports a link length greater than 2.54 km. A value of - * zero means that the transceiver does not support 50 micron multi-mode - * fiber or that the length information must be determined from the transceiver - * technology. - */ - int len_om2; - - /* [Prop]: len_om3 - * [Desc]: Length (50um, OM3) - * [Note]: This value specifies link length that is supported by the transceiver while - * operating in compliance with applicable standards using 50 micron multimode - * OM3 [2000 MHz*km] fiber. The value is in units of 10 meters. A value of 255 - * means that the transceiver supports a link length greater than 2.54 km. A value - * of zero means that the transceiver does not support 50 micron multimode fiber - * or that the length information must be determined from the transceiver technology. - */ - int len_om3; - - /* [Prop]: len_om4 - * [Desc]: Length (50um, OM4) and Length (Active Cable or Copper) - * [Note]: For optical links, this value specifies link length that is supported by the - * transceiver while operating in compliance with applicable standards using 50 micron - * multimode OM4 [4700 MHz*km] fiber. The value is in units of 10 meters. A value of - * 255 means that the transceiver supports a link length greater than 2.54 km. A value - * of zero means that the transceiver does not support 50 micron multimode fiber or that - * the length information must be determined from the transceiver codes specified in Table 5-3. - * - * For copper links, this value specifies minimum link length supported by the transceiver - * while operating in compliance with applicable standards using copper cable. For active - * cable, this value represents actual length. The value is in units of 1 meter. A value of 255 - * means the transceiver supports a link length greater than 254 meters. A value of zero means - * the transceiver does not support copper or active cables or the length information must be - * determined from transceiver technology. Further information about cable design, equalization, - * and connectors is usually required to guarantee meeting a particular length requirement. - */ - int len_om4; - - /* [Prop]: comp_rev - * [Desc]: SFF spec revision compliance - * [Note]: Indicates which revision of SFF SFF-8472 (SFP) / SFF-8636 (QSFP) the transceiver - * complies with. (unsigned integer) - */ - uint8_t comp_rev; - - /* [Prop]: CDR - * [Desc]: For transceivers with CDR capability, setting the CDR to ON engages the internal - * retiming function. Setting the CDR to OFF enables an internal bypassing mode ,which - * directs traffic around the internal CDR. (Reference: SFF-8636) - * [Note]: value=0xff: ON. - * value=0x00: OFF. - */ - uint8_t cdr; - - /* [Prop]: rate_id - * [Desc]: Soft Rate Select 0(RX). - * [Note]: 1. Addr: A0h / Offset: 13 - * 2. Value description: - * 00h Unspecified - * 01h SFF-8079 (4/2/1G Rate_Select & AS0/AS1) - * 02h SFF-8431 (8/4/2G Rx Rate_Select only) - * 03h Unspecified * - * 04h SFF-8431 (8/4/2G Tx Rate_Select only) - * 05h Unspecified * - * 06h SFF-8431 (8/4/2G Independent Rx & Tx Rate_select) - * 07h Unspecified * - * 08h FC-PI-5 (16/8/4G Rx Rate_select only) High=16G only, Low=8G/4G - * 09h Unspecified * - * 0Ah FC-PI-5 (16/8/4G Independent Rx, Tx Rate_select) High=16G only, - * Low=8G/4G - * 0Bh Unspecified * - * 0Ch FC-PI-6 (32/16/8G Independent Rx, Tx Rate_Select) - * High=32G only, Low = 16G/8G - * 0Dh Unspecified * - * 0Eh 10/8G Rx and Tx Rate_Select controlling the operation or locking - * modes of the internal signal conditioner, retimer or CDR, according - * to the logic table defined in Table 10-2, High Bit Rate - * (10G) =9.95-11.3 Gb/s; Low Bit Rate (8G) = 8.5 Gb/s. In this mode, - * the default value of bit 110.3 (Soft Rate Select RS(0), Table 9-11) - * and of bit 118.3 (Soft Rate Select RS(1), Table 10-1) is 1. - * 0Fh Unspecified * - * 10h-FFh Unallocated - */ - int rate_id; - - /* [Prop]: soft_rs0 - * [Desc]: Soft Rate Select 0(RX). - * [Note]: 1. Writing '1' selects full bandwidth operation. - * 2. This bit is "OR'd with the hard Rate_Select, AS(0) or RS(0) pin value. - * 3. Default at power up is logic zero/low - * 4. Addr: A2h / Offset: 110 / Bit: 3 - */ - uint8_t soft_rs0; - - /* [Prop]: soft_rs1 - * [Desc]: Soft Rate Select 1(TX). - * [Note]: 1. Writing '1' selects full bandwidth TX operation. - * 2. This bit is "OR'd with the hard Rate_Select, AS(1) or RS(1) pin value. - * 3. Default at power up is logic zero/low - * 4. Addr: A2h / Offset: 118 / Bit: 3 - */ - uint8_t soft_rs1; - - /* [Prop]: diag_type - * [Desc]: DIAGNOSTIC MONITORING TYPE (A0h/92) - * [Note]: Description in SFF-8472 as below: - * Bit7: Reserved for legacy diagnostic implementations. Must be '0' for compliance - * with this document. - * Bit6: Digital diagnostic monitoring implemented (described in this document). - * Must be '1' for compliance with this document. - * Bit5 Internally calibrated - * Bit4 Externally calibrated - * Bit3 Received power measurement type.0 = OMA, 1 = average power - * Bit2 Address change required see section above, "addressing modes" - * Bit1-0 Unallocated - */ - uint8_t diag_type; - - /* [Prop]: curr_temp - * [Desc]: Transceiver Current Temperature (A2h/96-97) - * [Note]: 1. Dependent on diag_type. - * 2. 96: High byte - * 3. 97: Low byte - * 4. This feature only for SFP - */ - uint8_t curr_temp[2]; - - /* [Prop]: curr_vol - * [Desc]: Transceiver Current Voltage (SFP:A2h/108-109; QSFP:00h/22-23) - * [Note]: 1. Dependent on diag_type. - * 2. 98: High byte - * 3. 99: Low byte - * 4. This feature only for SFP - * 5. Internally measured transceiver supply voltage. Represented - * as a 16 bit unsigned integer with the voltage defined as the - * full 16 bit value (0-65535) with LSB equal to 100 uVolt, - * yielding a total range of 0 to +6.55 Volts - */ - uint8_t curr_voltage[2]; - - /* [Prop]: curr_tx_bias - * [Desc]: Transceiver TX Bias Current (SFP:A2h/100-101; QSFP:00h/26-27) - * [Note]: 1. Dependent on diag_type. - * 2. 100: High byte - * 3. 101: Low byte - * 4. This feature only for SFP - * 5. Measured TX bias current in uA. Represented as a 16 bit unsigned - * integer with the current defined as the full 16 bit value (0-65535) - * with LSB equal to 2 uA, yielding a total range of 0 to 131 mA. - * Accuracy is vendor specific but must be better than 10% of the - * manufacturer's nominal value over specified operating temperature - * and voltage. - */ - uint8_t curr_tx_bias[8]; - - /* [Prop]: curr_tx_power - * [Desc]: Transceiver TX Output Power (A2h/102-103) - * [Note]: 1. Dependent on diag_type. - * 2. 102: High byte - * 3. 103: Low byte - * 4. This feature only for SFP - * 5. Measured TX output power in mW. Represented as a 16 bit unsigned - * integer with the power defined as the full 16 bit value (0-65535) - * with LSB equal to 0.1 uW, yielding a total range of 0 to 6.5535 mW - * (~ -40 to +8.2 dBm). Data is assumed to be based on measurement of - * laser monitor photodiode current. It is factory calibrated to absolute - * units using the most representative fiber output type. Accuracy is - * vendor specific but must be better than 3dB over specified temperature - * and voltage. Data is not valid when the transmitter is disabled. - */ - uint8_t curr_tx_power[8]; - - /* [Prop]: curr_tx_power - * [Desc]: Transceiver TX Output Power (A2h/102-103) - * [Note]: 1. Dependent on diag_type. - * 2. 102: High byte - * 3. 103: Low byte - * 4. This feature only for SFP - * 5. Measured RX received optical power in mW. Value can represent either - * average received power or OMA depending upon how bit 3 of byte 92 (A0h) - * is set. Represented as a 16 bit unsigned integer with the power defined - * as the full 16 bit value (0-65535) with LSB equal to 0.1 uW, yielding a - * total range of 0 to 6.5535 mW (~ -40 to +8.2 dBm). Absolute accuracy is - * dependent upon the exact optical wavelength. For the vendor specified - * wavelength, accuracy shall be better than 3dB over specified temperature - * and voltage. - */ - uint8_t curr_rx_power[8]; - - /* [Prop]: wavelength - * [Desc]: Wavelength or Copper Cable Attenuation - * [Note]: (Following is info from SFF-8636) - * For optical free side devices, this parameter identifies the nominal - * transmitter output wavelength at room temperature. This parameter is a - * 16-bit hex value with Byte 186 as high order byte and Byte 187 as low - * order byte. The laser wavelength is equal to the 16-bit integer value - * divided by 20 in nm (units of 0.05 nm). This resolution should be adequate - * to cover all relevant wavelengths yet provide enough resolution for all - * expected DWDM applications. For accurate representation of controlled - * wavelength applications, this value should represent the center of the - * guaranteed wavelength range. If the free side device is identified as - * copper cable these registers will be used to define the cable attenuation. - * An indication of 0 dB attenuation refers to the case where the attenuation - * is not known or is unavailable. - * Byte 186 (00-FFh) is the copper cable attenuation at 2.5 GHz in units of 1 dB. - * Byte 187 (00-FFh) is the copper cable attenuation at 5.0 GHz in units of 1 dB. - */ - uint8_t wavelength[2]; - - /* [Prop]: Amplitude control - * [Desc]: Amplitude control - * [Note]: QSFP28 => SFF-8636 03H Byte-238/239 - */ - uint8_t rx_am[2]; - - /* [Prop]: Emphasis control - * [Desc]: Emphasis control - * [Note]: SFP+/28 => SFF-8472 A2H Byte-115 - * QSFP28 => SFF-8636 03H Byte-236/237 - */ - uint8_t rx_em[2]; - - /* [Prop]: Soft Rx LOS - * [Desc]: Soft Rx LOS which provide by transceiver - * [Note]: (Following is info from SFF-8636) - * Byte 3: - * - Bit 0: L-Rx1 LOS - * - Bit 1: L-Rx2 LOS - * - Bit 2: L-Rx3 LOS - * - Bit 3: L-Rx4 LOS - */ - uint8_t rx_los; - - /* [Prop]: Soft Tx Disable - * [Desc]: Soft Tx Disable which provide by transceiver - * [Note]: (Following is info from SFF-8636) - * Byte 86: - * - Bit 0: Tx1 Disable - * - Bit 1: Tx2 Disable - * - Bit 2: Tx3 Disable - * - Bit 3: Tx4 Disable - */ - uint8_t tx_disable; - - /* [Prop]: Soft Tx Fault - * [Desc]: Soft Tx Fault which provide by transceiver - * [Note]: (Following is info from SFF-8636) - * Byte 86: - * - Bit 0: Tx1 Fault - * - Bit 1: Tx2 Fault - * - Bit 2: Tx3 Fault - * - Bit 3: Tx4 Fault - */ - uint8_t tx_fault; - - /* [Prop]: Transceiver EQUALIZATION - * [Desc]: Transceiver EQUALIZATION - * [Note]: SFP+/28 => SFF-8472 A2H Byte-114 - * QSFP28 => SFF-8636 03H Byte-234/235 - */ - uint8_t tx_eq[2]; - - /* [Prop]: OPTION VALUES - * [Desc]: The bits in the option field shall specify the options implemented in the transceiver. - * [Note]: SFP+/28 => SFF-8472 A0H Byte-64/65 - * QSFP+/28 => SFF-8636 00H Byte-193/195 - */ - uint8_t option[3]; - - /* [Prop]: External PHY offset - * [Desc]: It needs to be setup first if you want to access transceiver external phy. - * [Note]: This feature dependent on transceiver. - * Currently, only 1G-RJ45 transceiver supported it. - */ - uint8_t extphy_offset; - - uint8_t eeprom[130]; - - /* ========== Object private property ========== - */ - struct device *transvr_dev_p; - struct eeprom_map_s *eeprom_map_p; - struct i2c_client *i2c_client_p; - struct ioexp_obj_s *ioexp_obj_p; - struct transvr_worker_s *worker_p; - struct mutex lock; - char swp_name[32]; - int auto_config; - int auto_tx_disable; - int chan_id; - int chipset_type; - int curr_page; - int info; - int ioexp_virt_offset; - int lane_id[8]; - int layout; - int mode; - int retry; - int state; - int temp; - int type; - - /* ========== Object public functions ========== - */ - int (*get_id)(struct transvr_obj_s *self); - int (*get_ext_id)(struct transvr_obj_s *self); - int (*get_connector)(struct transvr_obj_s *self); - int (*get_vendor_name)(struct transvr_obj_s *self, char *buf_p); - int (*get_vendor_pn)(struct transvr_obj_s *self, char *buf_p); - int (*get_vendor_rev)(struct transvr_obj_s *self, char *buf_p); - int (*get_vendor_sn)(struct transvr_obj_s *self, char *buf_p); - int (*get_power_cls)(struct transvr_obj_s *self); - int (*get_br)(struct transvr_obj_s *self); - int (*get_len_sm)(struct transvr_obj_s *self); - int (*get_len_smf)(struct transvr_obj_s *self); - int (*get_len_om1)(struct transvr_obj_s *self); - int (*get_len_om2)(struct transvr_obj_s *self); - int (*get_len_om3)(struct transvr_obj_s *self); - int (*get_len_om4)(struct transvr_obj_s *self); - int (*get_comp_rev)(struct transvr_obj_s *self); - int (*get_comp_eth_1)(struct transvr_obj_s *self); - int (*get_comp_eth_10)(struct transvr_obj_s *self); - int (*get_comp_eth_10_40)(struct transvr_obj_s *self); - int (*get_comp_extend)(struct transvr_obj_s *self); - int (*get_cdr)(struct transvr_obj_s *self); - int (*get_rate_id)(struct transvr_obj_s *self); - int (*get_soft_rs0)(struct transvr_obj_s *self); - int (*get_soft_rs1)(struct transvr_obj_s *self); - int (*get_info)(struct transvr_obj_s *self); - int (*get_if_type)(struct transvr_obj_s *self, char *buf_p); - int (*get_if_speed)(struct transvr_obj_s *self, char *buf_p); - int (*get_if_lane)(struct transvr_obj_s *self, char *buf_p); - int (*get_curr_temp)(struct transvr_obj_s *self, char *buf_p); - int (*get_curr_vol)(struct transvr_obj_s *self, char *buf_p); - int (*get_soft_rx_los)(struct transvr_obj_s *self, char *buf_p); - int (*get_soft_tx_disable)(struct transvr_obj_s *self, char *buf_p); - int (*get_soft_tx_fault)(struct transvr_obj_s *self, char *buf_p); - int (*get_auto_tx_disable)(struct transvr_obj_s *self, char *buf_p); - int (*get_tx_bias)(struct transvr_obj_s *self, char *buf_p); - int (*get_tx_power)(struct transvr_obj_s *self, char *buf_p); - int (*get_rx_power)(struct transvr_obj_s *self, char *buf_p); - int (*get_tx_eq)(struct transvr_obj_s *self, char *buf_p); - int (*get_rx_am)(struct transvr_obj_s *self, char *buf_p); - int (*get_rx_em)(struct transvr_obj_s *self, char *buf_p); - int (*get_wavelength)(struct transvr_obj_s *self, char *buf_p); - int (*get_extphy_offset)(struct transvr_obj_s *self, char *buf_p); - int (*get_extphy_reg)(struct transvr_obj_s *self, char *buf_p); - int (*set_cdr)(struct transvr_obj_s *self, int input_val); - int (*set_soft_rs0)(struct transvr_obj_s *self, int input_val); - int (*set_soft_rs1)(struct transvr_obj_s *self, int input_val); - int (*set_soft_tx_disable)(struct transvr_obj_s *self, int input_val); - int (*set_auto_tx_disable)(struct transvr_obj_s *self, int input_val); - int (*set_tx_eq)(struct transvr_obj_s *self, int input_val); - int (*set_rx_am)(struct transvr_obj_s *self, int input_val); - int (*set_rx_em)(struct transvr_obj_s *self, int input_val); - int (*set_extphy_offset)(struct transvr_obj_s *self, int input_val); - int (*set_extphy_reg)(struct transvr_obj_s *self, int input_val); - int (*get_eeprom)(struct transvr_obj_s *self, char *buf_p); - int (*get_uppage)(struct transvr_obj_s *self, char *buf_p); - - /* ========== Object private functions ========== - */ - int (*init)(struct transvr_obj_s *self); - int (*clean)(struct transvr_obj_s *self); - int (*check)(struct transvr_obj_s *self); - int (*update_all)(struct transvr_obj_s *self, int show_err); - int (*fsm_4_direct)(struct transvr_obj_s* self, char *caller_name); - int (*fsm_4_polling)(struct transvr_obj_s* self, char *caller_name); - int (*send_uevent)(struct transvr_obj_s* self, enum kobject_action u_action); - int (*dump_all)(struct transvr_obj_s* self); -}; - - -/* For AVL Mapping */ -struct transvr_avl_s { - char vendor_name[32]; - char vendor_pn[32]; - int (*init)(struct transvr_obj_s *self); -}; - - -/* Worker for long term task of transceiver */ -struct transvr_worker_s { - /* Task Parameter */ - struct transvr_obj_s *transvr_p; - struct transvr_worker_s *next_p; - struct transvr_worker_s *pre_p; - unsigned long trigger_time; - char func_name[64]; - int retry; - int state; - - /* Task private data */ - void *p_data; - - /* Call back function */ - int (*main_task)(struct transvr_worker_s *task); - int (*post_task)(struct transvr_worker_s *task); -}; - - -struct transvr_obj_s * -create_transvr_obj(char *swp_name, - int chan_id, - struct ioexp_obj_s *ioexp_obj_p, - int ioexp_virt_offset, - int transvr_type, - int chipset_type, - int run_mode); - -void lock_transvr_obj(struct transvr_obj_s *self); -void unlock_transvr_obj(struct transvr_obj_s *self); -int isolate_transvr_obj(struct transvr_obj_s *self); - -int resync_channel_tier_2(struct transvr_obj_s *self); - -void alarm_msg_2_user(struct transvr_obj_s *self, char *emsg); - -#endif /* TRANSCEIVER_H */ - - - - - - diff --git a/packages/platforms/inventec/x86-64/d3352/onlp/Makefile b/packages/platforms/inventec/x86-64/d3352/onlp/Makefile deleted file mode 100644 index 003238cf6..000000000 --- a/packages/platforms/inventec/x86-64/d3352/onlp/Makefile +++ /dev/null @@ -1 +0,0 @@ -include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/inventec/x86-64/d3352/onlp/PKG.yml b/packages/platforms/inventec/x86-64/d3352/onlp/PKG.yml deleted file mode 100644 index b5d20f729..000000000 --- a/packages/platforms/inventec/x86-64/d3352/onlp/PKG.yml +++ /dev/null @@ -1 +0,0 @@ -!include $ONL_TEMPLATES/onlp-platform-any.yml PLATFORM=x86-64-inventec-d3352 ARCH=amd64 TOOLCHAIN=x86_64-linux-gnu diff --git a/packages/platforms/inventec/x86-64/d3352/onlp/builds/Makefile b/packages/platforms/inventec/x86-64/d3352/onlp/builds/Makefile deleted file mode 100644 index e7437cb23..000000000 --- a/packages/platforms/inventec/x86-64/d3352/onlp/builds/Makefile +++ /dev/null @@ -1,2 +0,0 @@ -FILTER=src -include $(ONL)/make/subdirs.mk diff --git a/packages/platforms/inventec/x86-64/d3352/onlp/builds/lib/Makefile b/packages/platforms/inventec/x86-64/d3352/onlp/builds/lib/Makefile deleted file mode 100644 index 1936d0728..000000000 --- a/packages/platforms/inventec/x86-64/d3352/onlp/builds/lib/Makefile +++ /dev/null @@ -1,2 +0,0 @@ -PLATFORM := x86-64-inventec-d3352 -include $(ONL)/packages/base/any/onlp/builds/platform/libonlp-platform.mk diff --git a/packages/platforms/inventec/x86-64/d3352/onlp/builds/onlpdump/Makefile b/packages/platforms/inventec/x86-64/d3352/onlp/builds/onlpdump/Makefile deleted file mode 100644 index 5c1a8958f..000000000 --- a/packages/platforms/inventec/x86-64/d3352/onlp/builds/onlpdump/Makefile +++ /dev/null @@ -1,2 +0,0 @@ -PLATFORM := x86-64-inventec-d3352 -include $(ONL)/packages/base/any/onlp/builds/platform/onlps.mk diff --git a/packages/platforms/inventec/x86-64/d3352/onlp/builds/x86_64_inventec_d3352/.module b/packages/platforms/inventec/x86-64/d3352/onlp/builds/x86_64_inventec_d3352/.module deleted file mode 100644 index ca8779fbb..000000000 --- a/packages/platforms/inventec/x86-64/d3352/onlp/builds/x86_64_inventec_d3352/.module +++ /dev/null @@ -1 +0,0 @@ -name: x86_64_inventec_d3352 diff --git a/packages/platforms/inventec/x86-64/d3352/onlp/builds/x86_64_inventec_d3352/Makefile b/packages/platforms/inventec/x86-64/d3352/onlp/builds/x86_64_inventec_d3352/Makefile deleted file mode 100644 index 3718fb119..000000000 --- a/packages/platforms/inventec/x86-64/d3352/onlp/builds/x86_64_inventec_d3352/Makefile +++ /dev/null @@ -1,9 +0,0 @@ -############################################################################### -# -# -# -############################################################################### -include $(ONL)/make/config.mk -MODULE := x86_64_inventec_d3352 -AUTOMODULE := x86_64_inventec_d3352 -include $(BUILDER)/definemodule.mk diff --git a/packages/platforms/inventec/x86-64/d3352/onlp/builds/x86_64_inventec_d3352/module/auto/make.mk b/packages/platforms/inventec/x86-64/d3352/onlp/builds/x86_64_inventec_d3352/module/auto/make.mk deleted file mode 100644 index f1ea00d53..000000000 --- a/packages/platforms/inventec/x86-64/d3352/onlp/builds/x86_64_inventec_d3352/module/auto/make.mk +++ /dev/null @@ -1,9 +0,0 @@ -############################################################################### -# -# x86_64_inventec_d3352 Autogeneration -# -############################################################################### -x86_64_inventec_d3352_AUTO_DEFS := module/auto/x86_64_inventec_d3352.yml -x86_64_inventec_d3352_AUTO_DIRS := module/inc/x86_64_inventec_d3352 module/src -include $(BUILDER)/auto.mk - diff --git a/packages/platforms/inventec/x86-64/d3352/onlp/builds/x86_64_inventec_d3352/module/auto/x86_64_inventec_d3352.yml b/packages/platforms/inventec/x86-64/d3352/onlp/builds/x86_64_inventec_d3352/module/auto/x86_64_inventec_d3352.yml deleted file mode 100644 index a3d4314d1..000000000 --- a/packages/platforms/inventec/x86-64/d3352/onlp/builds/x86_64_inventec_d3352/module/auto/x86_64_inventec_d3352.yml +++ /dev/null @@ -1,50 +0,0 @@ -############################################################################### -# -# x86_64_inventec_d3352 Autogeneration Definitions. -# -############################################################################### - -cdefs: &cdefs -- X86_64_INVENTEC_D3352_CONFIG_INCLUDE_LOGGING: - doc: "Include or exclude logging." - default: 1 -- X86_64_INVENTEC_D3352_CONFIG_LOG_OPTIONS_DEFAULT: - doc: "Default enabled log options." - default: AIM_LOG_OPTIONS_DEFAULT -- X86_64_INVENTEC_D3352_CONFIG_LOG_BITS_DEFAULT: - doc: "Default enabled log bits." - default: AIM_LOG_BITS_DEFAULT -- X86_64_INVENTEC_D3352_CONFIG_LOG_CUSTOM_BITS_DEFAULT: - doc: "Default enabled custom log bits." - default: 0 -- X86_64_INVENTEC_D3352_CONFIG_PORTING_STDLIB: - doc: "Default all porting macros to use the C standard libraries." - default: 1 -- X86_64_INVENTEC_D3352_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS: - doc: "Include standard library headers for stdlib porting macros." - default: X86_64_INVENTEC_D3352_CONFIG_PORTING_STDLIB -- X86_64_INVENTEC_D3352_CONFIG_INCLUDE_UCLI: - doc: "Include generic uCli support." - default: 0 -- X86_64_INVENTEC_D3352_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_D3352_CONFIG_HEADER: - defs: *cdefs - basename: x86_64_inventec_d3352_config - - portingmacro: - X86_64_INVENTEC_D3352: - macros: - - malloc - - free - - memset - - memcpy - - strncpy - - vsnprintf - - snprintf - - strlen diff --git a/packages/platforms/inventec/x86-64/d3352/onlp/builds/x86_64_inventec_d3352/module/inc/x86_64_inventec_d3352/x86_64_inventec_d3352.x b/packages/platforms/inventec/x86-64/d3352/onlp/builds/x86_64_inventec_d3352/module/inc/x86_64_inventec_d3352/x86_64_inventec_d3352.x deleted file mode 100644 index c166b6cd4..000000000 --- a/packages/platforms/inventec/x86-64/d3352/onlp/builds/x86_64_inventec_d3352/module/inc/x86_64_inventec_d3352/x86_64_inventec_d3352.x +++ /dev/null @@ -1,14 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#include - -/* <--auto.start.xmacro(ALL).define> */ -/* */ - -/* <--auto.start.xenum(ALL).define> */ -/* */ - - diff --git a/packages/platforms/inventec/x86-64/d3352/onlp/builds/x86_64_inventec_d3352/module/inc/x86_64_inventec_d3352/x86_64_inventec_d3352_config.h b/packages/platforms/inventec/x86-64/d3352/onlp/builds/x86_64_inventec_d3352/module/inc/x86_64_inventec_d3352/x86_64_inventec_d3352_config.h deleted file mode 100644 index 3b5c172c6..000000000 --- a/packages/platforms/inventec/x86-64/d3352/onlp/builds/x86_64_inventec_d3352/module/inc/x86_64_inventec_d3352/x86_64_inventec_d3352_config.h +++ /dev/null @@ -1,137 +0,0 @@ -/**************************************************************************//** - * - * @file - * @brief x86_64_inventec_d3352 Configuration Header - * - * @addtogroup x86_64_inventec_d3352-config - * @{ - * - *****************************************************************************/ -#ifndef __x86_64_inventec_d3352_CONFIG_H__ -#define __x86_64_inventec_d3352_CONFIG_H__ - -#ifdef GLOBAL_INCLUDE_CUSTOM_CONFIG -#include -#endif -#ifdef x86_64_inventec_d3352_INCLUDE_CUSTOM_CONFIG -#include -#endif - -/* */ -#include -/** - * X86_64_INVENTEC_D3352_CONFIG_INCLUDE_LOGGING - * - * Include or exclude logging. */ - - -#ifndef X86_64_INVENTEC_D3352_CONFIG_INCLUDE_LOGGING -#define X86_64_INVENTEC_D3352_CONFIG_INCLUDE_LOGGING 1 -#endif - -/** - * X86_64_INVENTEC_D3352_CONFIG_LOG_OPTIONS_DEFAULT - * - * Default enabled log options. */ - - -#ifndef X86_64_INVENTEC_D3352_CONFIG_LOG_OPTIONS_DEFAULT -#define X86_64_INVENTEC_D3352_CONFIG_LOG_OPTIONS_DEFAULT AIM_LOG_OPTIONS_DEFAULT -#endif - -/** - * X86_64_INVENTEC_D3352_CONFIG_LOG_BITS_DEFAULT - * - * Default enabled log bits. */ - - -#ifndef X86_64_INVENTEC_D3352_CONFIG_LOG_BITS_DEFAULT -#define X86_64_INVENTEC_D3352_CONFIG_LOG_BITS_DEFAULT AIM_LOG_BITS_DEFAULT -#endif - -/** - * X86_64_INVENTEC_D3352_CONFIG_LOG_CUSTOM_BITS_DEFAULT - * - * Default enabled custom log bits. */ - - -#ifndef X86_64_INVENTEC_D3352_CONFIG_LOG_CUSTOM_BITS_DEFAULT -#define X86_64_INVENTEC_D3352_CONFIG_LOG_CUSTOM_BITS_DEFAULT 0 -#endif - -/** - * X86_64_INVENTEC_D3352_CONFIG_PORTING_STDLIB - * - * Default all porting macros to use the C standard libraries. */ - - -#ifndef X86_64_INVENTEC_D3352_CONFIG_PORTING_STDLIB -#define X86_64_INVENTEC_D3352_CONFIG_PORTING_STDLIB 1 -#endif - -/** - * X86_64_INVENTEC_D3352_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS - * - * Include standard library headers for stdlib porting macros. */ - - -#ifndef X86_64_INVENTEC_D3352_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS -#define X86_64_INVENTEC_D3352_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS X86_64_INVENTEC_D3352_CONFIG_PORTING_STDLIB -#endif - -/** - * X86_64_INVENTEC_D3352_CONFIG_INCLUDE_UCLI - * - * Include generic uCli support. */ - - -#ifndef X86_64_INVENTEC_D3352_CONFIG_INCLUDE_UCLI -#define X86_64_INVENTEC_D3352_CONFIG_INCLUDE_UCLI 0 -#endif - -/** - * X86_64_INVENTEC_D3352_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION - * - * Assume chassis fan direction is the same as the PSU fan direction. */ - - -#ifndef X86_64_INVENTEC_D3352_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION -#define X86_64_INVENTEC_D3352_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION 0 -#endif - - - -/** - * All compile time options can be queried or displayed - */ - -/** Configuration settings structure. */ -typedef struct x86_64_inventec_d3352_config_settings_s { - /** name */ - const char* name; - /** value */ - const char* value; -} x86_64_inventec_d3352_config_settings_t; - -/** Configuration settings table. */ -/** x86_64_inventec_d3352_config_settings table. */ -extern x86_64_inventec_d3352_config_settings_t x86_64_inventec_d3352_config_settings[]; - -/** - * @brief Lookup a configuration setting. - * @param setting The name of the configuration option to lookup. - */ -const char* x86_64_inventec_d3352_config_lookup(const char* setting); - -/** - * @brief Show the compile-time configuration. - * @param pvs The output stream. - */ -int x86_64_inventec_d3352_config_show(struct aim_pvs_s* pvs); - -/* */ - -#include "x86_64_inventec_d3352_porting.h" - -#endif /* __x86_64_inventec_d3352_CONFIG_H__ */ -/* @} */ diff --git a/packages/platforms/inventec/x86-64/d3352/onlp/builds/x86_64_inventec_d3352/module/inc/x86_64_inventec_d3352/x86_64_inventec_d3352_dox.h b/packages/platforms/inventec/x86-64/d3352/onlp/builds/x86_64_inventec_d3352/module/inc/x86_64_inventec_d3352/x86_64_inventec_d3352_dox.h deleted file mode 100644 index 23699e7be..000000000 --- a/packages/platforms/inventec/x86-64/d3352/onlp/builds/x86_64_inventec_d3352/module/inc/x86_64_inventec_d3352/x86_64_inventec_d3352_dox.h +++ /dev/null @@ -1,26 +0,0 @@ -/**************************************************************************//** - * - * x86_64_inventec_d3352 Doxygen Header - * - *****************************************************************************/ -#ifndef __x86_64_inventec_d3352_DOX_H__ -#define __x86_64_inventec_d3352_DOX_H__ - -/** - * @defgroup x86_64_inventec_d3352 x86_64_inventec_d3352 - x86_64_inventec_d3352 Description - * - -The documentation overview for this module should go here. - - * - * @{ - * - * @defgroup x86_64_inventec_d3352-x86_64_inventec_d3352 Public Interface - * @defgroup x86_64_inventec_d3352-config Compile Time Configuration - * @defgroup x86_64_inventec_d3352-porting Porting Macros - * - * @} - * - */ - -#endif /* __x86_64_inventec_d3352_DOX_H__ */ diff --git a/packages/platforms/inventec/x86-64/d3352/onlp/builds/x86_64_inventec_d3352/module/inc/x86_64_inventec_d3352/x86_64_inventec_d3352_porting.h b/packages/platforms/inventec/x86-64/d3352/onlp/builds/x86_64_inventec_d3352/module/inc/x86_64_inventec_d3352/x86_64_inventec_d3352_porting.h deleted file mode 100644 index 31c1b4127..000000000 --- a/packages/platforms/inventec/x86-64/d3352/onlp/builds/x86_64_inventec_d3352/module/inc/x86_64_inventec_d3352/x86_64_inventec_d3352_porting.h +++ /dev/null @@ -1,107 +0,0 @@ -/**************************************************************************//** - * - * @file - * @brief x86_64_inventec_d3352 Porting Macros. - * - * @addtogroup x86_64_inventec_d3352-porting - * @{ - * - *****************************************************************************/ -#ifndef __x86_64_inventec_d3352_PORTING_H__ -#define __x86_64_inventec_d3352_PORTING_H__ - - -/* */ -#if X86_64_INVENTEC_D3352_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS == 1 -#include -#include -#include -#include -#include -#endif - -#ifndef X86_64_INVENTEC_D3352_MALLOC - #if defined(GLOBAL_MALLOC) - #define X86_64_INVENTEC_D3352_MALLOC GLOBAL_MALLOC - #elif X86_64_INVENTEC_D3352_CONFIG_PORTING_STDLIB == 1 - #define X86_64_INVENTEC_D3352_MALLOC malloc - #else - #error The macro X86_64_INVENTEC_D3352_MALLOC is required but cannot be defined. - #endif -#endif - -#ifndef X86_64_INVENTEC_D3352_FREE - #if defined(GLOBAL_FREE) - #define X86_64_INVENTEC_D3352_FREE GLOBAL_FREE - #elif X86_64_INVENTEC_D3352_CONFIG_PORTING_STDLIB == 1 - #define X86_64_INVENTEC_D3352_FREE free - #else - #error The macro X86_64_INVENTEC_D3352_FREE is required but cannot be defined. - #endif -#endif - -#ifndef X86_64_INVENTEC_D3352_MEMSET - #if defined(GLOBAL_MEMSET) - #define X86_64_INVENTEC_D3352_MEMSET GLOBAL_MEMSET - #elif X86_64_INVENTEC_D3352_CONFIG_PORTING_STDLIB == 1 - #define X86_64_INVENTEC_D3352_MEMSET memset - #else - #error The macro X86_64_INVENTEC_D3352_MEMSET is required but cannot be defined. - #endif -#endif - -#ifndef X86_64_INVENTEC_D3352_MEMCPY - #if defined(GLOBAL_MEMCPY) - #define X86_64_INVENTEC_D3352_MEMCPY GLOBAL_MEMCPY - #elif X86_64_INVENTEC_D3352_CONFIG_PORTING_STDLIB == 1 - #define X86_64_INVENTEC_D3352_MEMCPY memcpy - #else - #error The macro X86_64_INVENTEC_D3352_MEMCPY is required but cannot be defined. - #endif -#endif - -#ifndef X86_64_INVENTEC_D3352_STRNCPY - #if defined(GLOBAL_STRNCPY) - #define X86_64_INVENTEC_D3352_STRNCPY GLOBAL_STRNCPY - #elif X86_64_INVENTEC_D3352_CONFIG_PORTING_STDLIB == 1 - #define X86_64_INVENTEC_D3352_STRNCPY strncpy - #else - #error The macro X86_64_INVENTEC_D3352_STRNCPY is required but cannot be defined. - #endif -#endif - -#ifndef X86_64_INVENTEC_D3352_VSNPRINTF - #if defined(GLOBAL_VSNPRINTF) - #define X86_64_INVENTEC_D3352_VSNPRINTF GLOBAL_VSNPRINTF - #elif X86_64_INVENTEC_D3352_CONFIG_PORTING_STDLIB == 1 - #define X86_64_INVENTEC_D3352_VSNPRINTF vsnprintf - #else - #error The macro X86_64_INVENTEC_D3352_VSNPRINTF is required but cannot be defined. - #endif -#endif - -#ifndef X86_64_INVENTEC_D3352_SNPRINTF - #if defined(GLOBAL_SNPRINTF) - #define X86_64_INVENTEC_D3352_SNPRINTF GLOBAL_SNPRINTF - #elif X86_64_INVENTEC_D3352_CONFIG_PORTING_STDLIB == 1 - #define X86_64_INVENTEC_D3352_SNPRINTF snprintf - #else - #error The macro X86_64_INVENTEC_D3352_SNPRINTF is required but cannot be defined. - #endif -#endif - -#ifndef X86_64_INVENTEC_D3352_STRLEN - #if defined(GLOBAL_STRLEN) - #define X86_64_INVENTEC_D3352_STRLEN GLOBAL_STRLEN - #elif X86_64_INVENTEC_D3352_CONFIG_PORTING_STDLIB == 1 - #define X86_64_INVENTEC_D3352_STRLEN strlen - #else - #error The macro X86_64_INVENTEC_D3352_STRLEN is required but cannot be defined. - #endif -#endif - -/* */ - - -#endif /* __x86_64_inventec_d3352_PORTING_H__ */ -/* @} */ diff --git a/packages/platforms/inventec/x86-64/d3352/onlp/builds/x86_64_inventec_d3352/module/make.mk b/packages/platforms/inventec/x86-64/d3352/onlp/builds/x86_64_inventec_d3352/module/make.mk deleted file mode 100644 index d580418d8..000000000 --- a/packages/platforms/inventec/x86-64/d3352/onlp/builds/x86_64_inventec_d3352/module/make.mk +++ /dev/null @@ -1,11 +0,0 @@ -############################################################################### -# -# -# -############################################################################### -THIS_DIR := $(dir $(lastword $(MAKEFILE_LIST))) -x86_64_inventec_d3352_INCLUDES := -I $(THIS_DIR)inc -x86_64_inventec_d3352_INTERNAL_INCLUDES := -I $(THIS_DIR)src -x86_64_inventec_d3352_DEPENDMODULE_ENTRIES := init:x86_64_inventec_d3352 ucli:x86_64_inventec_d3352 - -x86_64_inventec_d3352_BROKEN_CFLAGS += -Wno-stringop-truncation -Wno-restrict -Wno-format-truncation diff --git a/packages/platforms/inventec/x86-64/d3352/onlp/builds/x86_64_inventec_d3352/module/src/Makefile b/packages/platforms/inventec/x86-64/d3352/onlp/builds/x86_64_inventec_d3352/module/src/Makefile deleted file mode 100644 index f95f7a859..000000000 --- a/packages/platforms/inventec/x86-64/d3352/onlp/builds/x86_64_inventec_d3352/module/src/Makefile +++ /dev/null @@ -1,9 +0,0 @@ -############################################################################### -# -# Local source generation targets. -# -############################################################################### - -ucli: - @../../../../tools/uclihandlers.py x86_64_inventec_d3352_ucli.c - diff --git a/packages/platforms/inventec/x86-64/d3352/onlp/builds/x86_64_inventec_d3352/module/src/debug.c b/packages/platforms/inventec/x86-64/d3352/onlp/builds/x86_64_inventec_d3352/module/src/debug.c deleted file mode 100644 index a5592242a..000000000 --- a/packages/platforms/inventec/x86-64/d3352/onlp/builds/x86_64_inventec_d3352/module/src/debug.c +++ /dev/null @@ -1,52 +0,0 @@ -#include "x86_64_inventec_d3352_int.h" - -#if x86_64_inventec_d3352_CONFIG_INCLUDE_DEBUG == 1 - -#include - -static char help__[] = - "Usage: debug [options]\n" - " -c CPLD Versions\n" - " -h Help\n" - ; - -int -x86_64_inventec_d3352_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/d3352/onlp/builds/x86_64_inventec_d3352/module/src/fani.c b/packages/platforms/inventec/x86-64/d3352/onlp/builds/x86_64_inventec_d3352/module/src/fani.c deleted file mode 100644 index 656834585..000000000 --- a/packages/platforms/inventec/x86-64/d3352/onlp/builds/x86_64_inventec_d3352/module/src/fani.c +++ /dev/null @@ -1,265 +0,0 @@ -/************************************************************ - * fani.c - * - * Copyright 2018 Inventec Technology Corporation. - * - ************************************************************ - * - * Fan Platform Implementation Defaults. - * - ***********************************************************/ -#include -#include -#include -#include -#include -#include -#include "platform_lib.h" - -#define FAN_GPI_ON_MAIN_BOARD INV_PSOC_PREFIX"/fan_gpi" - -#define MAX_FAN_SPEED 18000 -#define MAX_PSU_FAN_SPEED 25500 - -#define PROJECT_NAME -#define LEN_FILE_NAME 80 - -#define LOCAL_ID_TO_PSU_ID(id) (id-CHASSIS_FAN_COUNT) - -static char* devfiles__[] = /* must map with onlp_thermal_id */ -{ - "reserved", - INV_PSOC_PREFIX"/fan1_input", - INV_PSOC_PREFIX"/fan2_input", - INV_PSOC_PREFIX"/fan3_input", - INV_PSOC_PREFIX"/fan4_input", - INV_PSOC_PREFIX"/rpm_psu1", - INV_PSOC_PREFIX"/rpm_psu2", -}; - -#define MAKE_FAN_INFO_NODE_ON_MAIN_BOARD(id) \ - { \ - { \ - ONLP_FAN_ID_CREATE(FAN_##id##_ON_MAIN_BOARD), "Chassis Fan "#id, 0, \ - { \ - ONLP_LED_ID_CREATE(LED_FAN##id), \ - } \ - }, \ - 0x0, \ - (ONLP_FAN_CAPS_F2B | 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, ONLP_PSU_ID_CREATE(PSU##psu_id##_ID) }, \ - 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[FAN_MAX] = { - { }, /* 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) - -int onlp_fani_status_get(onlp_oid_t id, uint32_t* rv) -{ - int lrpm=0, rrpm=0, ret, len, gpi; - char buf[ONLP_CONFIG_INFO_STR_MAX]; - int fid= ONLP_OID_ID_GET(id); - int local_id=LOCAL_ID_TO_INFO_IDX(fid); - - ret = onlp_file_read( (uint8_t*)buf , ONLP_CONFIG_INFO_STR_MAX, &len, FAN_GPI_ON_MAIN_BOARD); - if (ret < 0) { - return ONLP_STATUS_E_INTERNAL; - } - sscanf( buf, "0x%x\n", &gpi); - - /* B[0-3] installed(0)/uninstalled(1) - B[4-7] FRtype(0)/RFtype(1) */ - if ( (gpi>>(local_id)&1) ) { //fan failed - *rv |= ONLP_FAN_STATUS_FAILED; - } else { - *rv |= ONLP_FAN_STATUS_PRESENT; - if( (gpi>>(local_id+4))&1 ) *rv |= ONLP_FAN_STATUS_B2F; - else *rv |= ONLP_FAN_STATUS_F2B; - } - - /* get front fan speed */ - ret = onlp_file_read_int(&lrpm, devfiles__[fid*2-1]); - if (ret < 0) { - return ONLP_STATUS_E_INTERNAL; - } - ret = onlp_file_read_int(&rrpm, devfiles__[fid*2]); - if (ret < 0) { - return ONLP_STATUS_E_INTERNAL; - } - if(lrpm <=0 && rrpm <=0) { - *rv |= ONLP_FAN_STATUS_FAILED; - } - return ONLP_STATUS_OK; -} - -static int -_onlp_fani_info_get_fan(int fid, onlp_fan_info_t* info) -{ - int lrpm=0, rrpm=0, ret; - - /* get fan present status */ - onlp_fani_status_get( info->hdr.id, &info->status ); - - /* get front fan speed */ - ret = onlp_file_read_int(&lrpm, devfiles__[fid*2-1]); - if (ret < 0) { - return ONLP_STATUS_E_INTERNAL; - } - ret = onlp_file_read_int(&rrpm, devfiles__[fid*2]); - if (ret < 0) { - return ONLP_STATUS_E_INTERNAL; - } - if(lrpm <=0 && rrpm <=0) { - info->rpm = 0; - } else if(lrpm <= 0) { - info->rpm = rrpm; - } else if(rrpm <= 0) { - info->rpm = lrpm; - } else { - info->rpm = (lrpm+rrpm)/2; - } - info->percentage = (info->rpm * 100) / MAX_PSU_FAN_SPEED; - - snprintf(info->model, ONLP_CONFIG_INFO_STR_MAX, "N/A"); - snprintf(info->serial, ONLP_CONFIG_INFO_STR_MAX, "N/A"); - - return ONLP_STATUS_OK; -} - - - -static int -_onlp_fani_info_get_fan_on_psu(int fid, onlp_fan_info_t* info) -{ - int ret; - uint32_t psu_status; - ret=onlp_psui_status_get( (&info->hdr)->poid, &psu_status ); - if(ret!=ONLP_STATUS_OK) return ret; - - if(psu_status & ONLP_PSU_STATUS_PRESENT) { - info->status |= ONLP_FAN_STATUS_PRESENT; - } else { - info->status = 0; - return ONLP_STATUS_OK; - } - - /* get front fan speed */ - ret = onlp_file_read_int(&(info->rpm), INV_PSOC_PREFIX"/rpm_psu%d",LOCAL_ID_TO_PSU_ID(fid)); - if (ret < 0) { - return ONLP_STATUS_E_INTERNAL; - } - info->percentage = (info->rpm * 100) / MAX_PSU_FAN_SPEED; - - if (info->rpm==0) info->status |=ONLP_FAN_STATUS_FAILED; - - snprintf(info->model, ONLP_CONFIG_INFO_STR_MAX, "N/A"); - snprintf(info->serial, ONLP_CONFIG_INFO_STR_MAX, "N/A"); - - return ONLP_STATUS_OK; -} - -/* - * This function will be called prior to all of onlp_fani_* functions. - */ -int -onlp_fani_init(void) -{ - DEBUG_PRINT("%s(%d): %s\r\n", __FUNCTION__, __LINE__, INV_PLATFORM_NAME); - - 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: - 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_PSU1: - return psu_pmbus_info_set(PSU1_ID, "rpm_psu1", p); - case FAN_1_ON_PSU2: - return psu_pmbus_info_set(PSU2_ID, "rpm_psu2", p); - case FAN_1_ON_MAIN_BOARD: - case FAN_2_ON_MAIN_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/d3352/onlp/builds/x86_64_inventec_d3352/module/src/ledi.c b/packages/platforms/inventec/x86-64/d3352/onlp/builds/x86_64_inventec_d3352/module/src/ledi.c deleted file mode 100644 index e43fae797..000000000 --- a/packages/platforms/inventec/x86-64/d3352/onlp/builds/x86_64_inventec_d3352/module/src/ledi.c +++ /dev/null @@ -1,393 +0,0 @@ -/************************************************************ - * ledi.c - * - * Copyright 2018 Inventec Technology Corporation. - * - ************************************************************ - * - ***********************************************************/ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "platform_lib.h" - -#define filename "brightness" - -#define VALIDATE(_id) \ - do { \ - if(!ONLP_OID_IS_LED(_id)) { \ - return ONLP_STATUS_E_INVALID; \ - } \ - } while(0) - - -/* Reference to inv_cpld.h */ -/* -typedef struct cpld_led_map_s { - char *name; - int bit_shift; - unsigned int bit_mask; - unsigned int led_off; - unsigned int led_on; - unsigned int led_blink; - unsigned int led_blink_slow; -} cpld_led_map_t; -*/ -static cpld_led_map_t cpld_led_map[] = { - { NULL, 0, 0x00, 0x00, 0x00, 0x00, 0x00 }, - { "stk_led", 0, 0x03, 0x00, 0x01, 0x02, 0x03 }, - { "fan_led", 2, 0x0c, 0x00, 0x04, 0x08, 0x0c }, - { "pwr_led", 4, 0x30, 0x00, 0x10, 0x20, 0x30 }, - { "sys_led", 6, 0xc0, 0x00, 0x40, 0x80, 0xc0 } -}; - -static char* devfiles__[LED_MAX] = /* must map with onlp_thermal_id */ -{ - "reserved", - INV_CPLD_PREFIX"/stk_led", - INV_CPLD_PREFIX"/fan_led", - INV_CPLD_PREFIX"/pwr_led", - INV_CPLD_PREFIX"/sys_led", - INV_PSOC_PREFIX"/fan1_led_%s", - INV_PSOC_PREFIX"/fan2_led_%s", -}; - -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_SYS, LED_MODE_BLUE, ONLP_LED_MODE_BLUE,}, - {LED_PWR, LED_MODE_GREEN, ONLP_LED_MODE_GREEN}, - {LED_FAN, LED_MODE_GREEN, ONLP_LED_MODE_GREEN}, - {LED_STK, LED_MODE_GREEN, ONLP_LED_MODE_GREEN}, - {LED_FAN1,LED_MODE_AUTO, ONLP_LED_MODE_AUTO}, - {LED_FAN2,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[LED_MAX] = { - { }, /* Not used */ - { - { ONLP_LED_ID_CREATE(LED_STK), "Chassis LED (STACKING LED)", 0 }, - ONLP_LED_STATUS_PRESENT, - ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_GREEN_BLINKING, - ONLP_LED_MODE_ON, '0', - }, - { - { ONLP_LED_ID_CREATE(LED_FAN), "Chassis LED (FAN LED)", 0 }, - ONLP_LED_STATUS_PRESENT, - ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_GREEN_BLINKING , - ONLP_LED_MODE_ON, '0', - }, - { - { ONLP_LED_ID_CREATE(LED_PWR), "Chassis LED (POWER LED)", 0 }, - ONLP_LED_STATUS_PRESENT, - ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_GREEN_BLINKING, - ONLP_LED_MODE_ON, '0', - }, - { - { ONLP_LED_ID_CREATE(LED_SYS), "Chassis LED (SYSTEM LED)", 0 }, - ONLP_LED_STATUS_PRESENT, - ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_BLUE| ONLP_LED_CAPS_BLUE_BLINKING, - ONLP_LED_MODE_ON, '0', - }, - { - { ONLP_LED_ID_CREATE(LED_FAN1), "Fan LED 1 (FAN1 LED)", ONLP_FAN_ID_CREATE(FAN_1_ON_MAIN_BOARD) }, - ONLP_LED_STATUS_PRESENT, - ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_RED, - ONLP_LED_MODE_ON, '0', - }, - { - { ONLP_LED_ID_CREATE(LED_FAN2), "Fan LED 2 (FAN2 LED)", ONLP_FAN_ID_CREATE(FAN_2_ON_MAIN_BOARD) }, - ONLP_LED_STATUS_PRESENT, - ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_RED, - ONLP_LED_MODE_ON, '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) -{ - DEBUG_PRINT("%s(%d): %s\r\n", __FUNCTION__, __LINE__, INV_PLATFORM_NAME); - - /* - * Diag LED Off - */ - onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_SYS), ONLP_LED_MODE_OFF); - - return ONLP_STATUS_OK; -} - -int onlp_chassis_led_read(char *pathp, char *buf, size_t len) -{ - FILE * fp; - - fp = fopen (pathp, "r"); - if(fp == NULL) { - perror("Error opening file"); - return(-1); - } - if( fgets (buf, len, fp) == NULL ) { - perror("Error fgets operation"); - } - fclose(fp); - - return(0); -} - -int -onlp_ledi_info_get(onlp_oid_t id, onlp_led_info_t* info) -{ - int local_id = ONLP_OID_ID_GET(id); - char fullpath_grn[50] = {0}; - char fullpath_red[50] = {0}; - int gvalue = 0, rvalue = 0; - int led_on, led_blink; - char *bp, buf[32] = {0}; - unsigned int led_st; - uint32_t fan_status; - - VALIDATE(id); - - memset(info, 0, sizeof(onlp_led_info_t)); - *info = linfo[local_id]; /* Set the onlp_oid_hdr_t */ - - /* get fullpath */ - switch (local_id) { - case LED_STK: - case LED_FAN: - case LED_PWR: - case LED_SYS: - sprintf(fullpath_grn, devfiles__[local_id]); - /* Set LED mode */ - if (onlp_chassis_led_read(fullpath_grn, buf, 32) < 0) { - DEBUG_PRINT("%s/%d\r\n", __FUNCTION__, __LINE__); - info->mode = ONLP_LED_MODE_OFF; - info->status &= ~ONLP_LED_STATUS_PRESENT; - return ONLP_STATUS_OK; - } - bp = strstr(&buf[0], "0x"); - if (!bp) { - DEBUG_PRINT("%s/%d: (%s)\r\n", __FUNCTION__, __LINE__,buf); - info->mode = ONLP_LED_MODE_OFF; - info->status &= ~ONLP_LED_STATUS_PRESENT; - return ONLP_STATUS_OK; - } - *(bp+4) = '\0'; - led_st = strtoul(bp, NULL, 16); - switch (local_id) { - case LED_STK: - led_st &= cpld_led_map[LED_STK].bit_mask; - led_st >>= cpld_led_map[LED_STK].bit_shift; - led_on = ONLP_LED_MODE_GREEN; - led_blink = ONLP_LED_MODE_GREEN_BLINKING; - break; - case LED_FAN: - led_st &= cpld_led_map[LED_FAN].bit_mask; - led_st >>= cpld_led_map[LED_FAN].bit_shift; - led_on = ONLP_LED_MODE_GREEN; - led_blink = ONLP_LED_MODE_GREEN_BLINKING; - break; - case LED_PWR: - led_st &= cpld_led_map[LED_PWR].bit_mask; - led_st >>= cpld_led_map[LED_PWR].bit_shift; - led_on = ONLP_LED_MODE_GREEN; - led_blink = ONLP_LED_MODE_GREEN_BLINKING; - break; - case LED_SYS: - led_st &= cpld_led_map[LED_SYS].bit_mask; - led_st >>= cpld_led_map[LED_SYS].bit_shift; - led_on = ONLP_LED_MODE_BLUE; - led_blink = ONLP_LED_MODE_BLUE_BLINKING; - break; - } - - info->status |= ONLP_LED_STATUS_PRESENT; - if (led_st == 0) { - info->mode = ONLP_LED_MODE_OFF; - } else if (led_st == 1) { - info->mode = led_on; - info->status |= ONLP_LED_STATUS_ON; - } else if (led_st == 2 || led_st == 3) { - info->mode = led_blink; - info->status |= ONLP_LED_STATUS_ON; - } else { - info->mode = ONLP_LED_MODE_OFF; - info->status &= ~ONLP_LED_STATUS_PRESENT; - } - return ONLP_STATUS_OK; - break; - case LED_FAN1: - case LED_FAN2: - if( onlp_fani_status_get(info->hdr.poid, &fan_status)!= ONLP_STATUS_OK ) { - return ONLP_STATUS_E_INTERNAL; - } - if( !(fan_status & ONLP_FAN_STATUS_PRESENT) ) { - info->status=0; - return ONLP_STATUS_OK; - } - - sprintf(fullpath_grn, devfiles__[local_id], "grn"); - sprintf(fullpath_red, devfiles__[local_id], "red"); - - /* Set LED mode */ - if (onlp_file_read_int(&gvalue, fullpath_grn) != 0) { - DEBUG_PRINT("%s(%d)\r\n", __FUNCTION__, __LINE__); - gvalue = 0; - } - if (onlp_file_read_int(&rvalue, fullpath_red) != 0) { - DEBUG_PRINT("%s(%d)\r\n", __FUNCTION__, __LINE__); - rvalue = 0; - } - - if (gvalue == 1 && rvalue == 0) { - info->mode = ONLP_LED_MODE_GREEN; - info->status |= ONLP_LED_STATUS_PRESENT; - info->status |= ONLP_LED_STATUS_ON; - } else if (gvalue == 0 && rvalue == 1) { - info->mode = ONLP_LED_MODE_RED; - info->status |= ONLP_LED_STATUS_PRESENT; - info->status |= ONLP_LED_STATUS_ON; - } else { - info->mode = ONLP_LED_MODE_OFF; - info->status &= ~ONLP_LED_STATUS_PRESENT; - info->status &= ~ONLP_LED_STATUS_ON; - } - break; - default: - DEBUG_PRINT("%s(%d) Invalid led id %d\r\n", __FUNCTION__, __LINE__, local_id); - return ONLP_STATUS_E_INVALID; - break; - } - - /* Set the onlp_oid_hdr_t and capabilities */ - *info = linfo[ONLP_OID_ID_GET(id)]; - if (gvalue == 1 && rvalue == 0) { - info->mode = ONLP_LED_MODE_GREEN; - info->status |= ONLP_LED_STATUS_ON; - } else if (gvalue == 0 && rvalue == 1) { - info->mode = ONLP_LED_MODE_RED; - info->status |= ONLP_LED_STATUS_ON; - } else if (gvalue == 1 && rvalue == 1) { - info->mode = ONLP_LED_MODE_ORANGE; - info->status |= ONLP_LED_STATUS_ON; - } else if (gvalue == 0 && rvalue == 0) { - info->mode = ONLP_LED_MODE_OFF; - info->status |= ONLP_LED_STATUS_ON; - } else { - info->mode = ONLP_LED_MODE_OFF; - 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) -{ - 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); - switch (local_id) { - case LED_SYS: - case LED_PWR: - case LED_FAN: - case LED_STK: - sprintf(fullpath, "%s%s/%s", INV_CPLD_PREFIX, last_path[local_id], filename); - break; - case LED_FAN1: - case LED_FAN2: - sprintf(fullpath, "%s%s/%s", INV_PSOC_PREFIX, last_path[local_id], filename); - break; - default: - DEBUG_PRINT("%s(%d) Invalid led id %d\r\n", __FUNCTION__, __LINE__, local_id); - return ONLP_STATUS_E_INTERNAL; - } - - 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/d3352/onlp/builds/x86_64_inventec_d3352/module/src/make.mk b/packages/platforms/inventec/x86-64/d3352/onlp/builds/x86_64_inventec_d3352/module/src/make.mk deleted file mode 100644 index ed5be8628..000000000 --- a/packages/platforms/inventec/x86-64/d3352/onlp/builds/x86_64_inventec_d3352/module/src/make.mk +++ /dev/null @@ -1,9 +0,0 @@ -############################################################################### -# -# -# -############################################################################### - -LIBRARY := x86_64_inventec_d3352 -$(LIBRARY)_SUBDIR := $(dir $(lastword $(MAKEFILE_LIST))) -include $(BUILDER)/lib.mk diff --git a/packages/platforms/inventec/x86-64/d3352/onlp/builds/x86_64_inventec_d3352/module/src/platform_lib.c b/packages/platforms/inventec/x86-64/d3352/onlp/builds/x86_64_inventec_d3352/module/src/platform_lib.c deleted file mode 100644 index 1c71de332..000000000 --- a/packages/platforms/inventec/x86-64/d3352/onlp/builds/x86_64_inventec_d3352/module/src/platform_lib.c +++ /dev/null @@ -1,93 +0,0 @@ -/************************************************************ - * platform_lib.c - * - * Copyright 2018 Inventec Corporation. - * - ************************************************************ - * - ***********************************************************/ -#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 32 -#define I2C_PSU_FAN_DIR_LEN 8 -#include - -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%d", PSU1_AC_PMBUS_PREFIX, node, PSU1_ID); - } else if (PSU2_ID == id) { - ret = onlp_file_read_int(value, "%s%s%d", PSU2_AC_PMBUS_PREFIX, node, PSU2_ID); - } else { - return ONLP_STATUS_E_INTERNAL; - } - - 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%d", PSU1_AC_PMBUS_PREFIX, node, PSU1_ID); - break; - case PSU2_ID: - sprintf(path, "%s%s%d", PSU2_AC_PMBUS_PREFIX, node, PSU2_ID); - 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/d3352/onlp/builds/x86_64_inventec_d3352/module/src/platform_lib.h b/packages/platforms/inventec/x86-64/d3352/onlp/builds/x86_64_inventec_d3352/module/src/platform_lib.h deleted file mode 100644 index 0b6af3af4..000000000 --- a/packages/platforms/inventec/x86-64/d3352/onlp/builds/x86_64_inventec_d3352/module/src/platform_lib.h +++ /dev/null @@ -1,145 +0,0 @@ -/************************************************************ - * platform_lib.h - * - * Copyright 2018 Inventec Technology Corporation. - * - ************************************************************ - * - ***********************************************************/ -#ifndef __PLATFORM_LIB_H__ -#define __PLATFORM_LIB_H__ - -#include "x86_64_inventec_d3352_log.h" - -#define ONLP_NODE_MAX_INT_LEN (8) -#define ONLP_NODE_MAX_PATH_LEN (64) - -#define INV_PLATFORM_NAME "d3352" - -#define INV_CPLD_COUNT (1) -#define INV_CPLD_PREFIX "/sys/bus/i2c/devices/1-0055/" -#define INV_PSOC_PREFIX "/sys/bus/i2c/devices/1-0066/" -#define INV_EPRM_PREFIX "/sys/bus/i2c/devices/0-0053/" -#define INV_CTMP_PREFIX "/sys/devices/platform/coretemp.0/hwmon/hwmon0/" -#define LOCAL_ID_TO_INFO_IDX(id) (id-1) - -#define CHASSIS_SFP_COUNT (4) - -/* - * Definitions of Chassis EEPROM - */ -#define EEPROM_NODE(node) INV_EPRM_PREFIX#node - -/* - * Definitions of D3352 device - */ -enum onlp_thermal_id { - THERMAL_RESERVED = 0, - THERMAL_CPU_CORE_FIRST, - THERMAL_CPU_CORE_2, - THERMAL_CPU_CORE_3, - THERMAL_CPU_CORE_LAST, - 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, - THERMAL_MAX -}; -#define CHASSIS_THERMAL_COUNT (9) - -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, - FAN_MAX -}; -#define CHASSIS_FAN_COUNT (2) - -enum onlp_led_id { - LED_RESERVED = 0, - LED_STK, - LED_FAN, - LED_PWR, - LED_SYS, - LED_FAN1, - LED_FAN2, - LED_MAX -}; -#define CHASSIS_LED_COUNT (4) - -/* - * struct cpld_led_map_s must be same as it in inv_platform.h - */ -typedef struct cpld_led_map_s { - char *name; - int bit_shift; - unsigned int bit_mask; - unsigned int led_off; - unsigned int led_on; - unsigned int led_blink; - unsigned int led_blink_slow; -} cpld_led_map_t; - -enum onlp_psu_id { - PSU_RESERVED = 0, - PSU1_ID, - PSU2_ID, - PSU_MAX -}; -#define CHASSIS_PSU_COUNT (2) - -#define PSU1_AC_PMBUS_PREFIX INV_PSOC_PREFIX -#define PSU2_AC_PMBUS_PREFIX INV_PSOC_PREFIX - -#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 INV_PSOC_PREFIX -#define PSU2_AC_HWMON_PREFIX INV_PSOC_PREFIX - -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 PSU1_AC_HWMON_NODE(node) PSU1_AC_HWMON_PREFIX#node -#define PSU2_AC_HWMON_NODE(node) PSU2_AC_HWMON_PREFIX#node - -/* - * Definitions of FAN device - */ -#define FAN_BOARD_PATH INV_PSOC_PREFIX -#define FAN_NODE(node) FAN_BOARD_PATH#node - -/* - * Prototypes - */ -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); - -#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/d3352/onlp/builds/x86_64_inventec_d3352/module/src/psui.c b/packages/platforms/inventec/x86-64/d3352/onlp/builds/x86_64_inventec_d3352/module/src/psui.c deleted file mode 100644 index b2217f68e..000000000 --- a/packages/platforms/inventec/x86-64/d3352/onlp/builds/x86_64_inventec_d3352/module/src/psui.c +++ /dev/null @@ -1,263 +0,0 @@ -/************************************************************ - * psui.c - * - * Copyright 2018 Inventec Technology Corporation. - * - ************************************************************ - * - ***********************************************************/ -#include -#include -#include -#include -#include -#include -#include "platform_lib.h" - -#define PSU_STATUS_PRESENT (0) -#define PSU_STATUS_POWER_GOOD (1) -#define PSU_STATUS_UNPOWERED (2) -#define PSU_STATUS_FAULT (4) -#define PSU_STATUS_UNINSTALLED (7) - -typedef enum hwmon_psu_state_e { - HWMON_PSU_NORMAL = 0, - HWMON_PSU_UNPOWERED = 2, //010 - HWMON_PSU_FAULT = 4, //100 - HWMON_PSU_NOT_INSTALLED = 7 //111 -} hwmon_psu_state_t; - -#define VALIDATE(_id) \ - do { \ - if(!ONLP_OID_IS_PSU(_id)) { \ - return ONLP_STATUS_E_INVALID; \ - } \ - } while(0) - -static char* status_devfiles__[PSU_MAX] = /* must map with onlp_psu_id */ -{ - "reserved", - INV_CPLD_PREFIX"psu0", - INV_CPLD_PREFIX"psu1", -}; - -static char* module_devfiles__[PSU_MAX] = /* must map with onlp_psu_id */ -{ - "reserved", - INV_PSOC_PREFIX"psoc_psu1_%s", - INV_PSOC_PREFIX"psoc_psu2_%s", -}; - -static int -psu_status_info_get(int id, char *node, int *value) -{ - int ret = 0; - char node_path[ONLP_NODE_MAX_PATH_LEN] = {0}; - - *value = 0; - if (PSU1_ID == id) { - sprintf(node_path, status_devfiles__[id]); - } else if (PSU2_ID == id) { - sprintf(node_path, status_devfiles__[id]); - } - 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 ONLP_STATUS_OK; -} - - -int -onlp_psui_init(void) -{ - DEBUG_PRINT("%s(%d): %s\r\n", __FUNCTION__, __LINE__, INV_PLATFORM_NAME); - - return ONLP_STATUS_OK; -} - -static void -psu_module_name_get(int id, onlp_psu_info_t* info) -{ - char node_path[ONLP_NODE_MAX_PATH_LEN] = {0}; - uint8_t temp[ONLP_CONFIG_INFO_STR_MAX] = {0}; - int ret, len; - - memset(node_path, 0, ONLP_NODE_MAX_PATH_LEN); - sprintf(node_path, module_devfiles__[id], "model"); - ret = onlp_file_read(temp, ONLP_CONFIG_INFO_STR_MAX, &len, node_path); - if (ret == 0) { - /*remove the '\n'*/ - temp[strlen((char*)temp)-1] = 0; - snprintf(info->model, ONLP_CONFIG_INFO_STR_MAX, "%s", temp); - } else { - AIM_LOG_ERROR("Unable to read model name from file(%s)\r\n", node_path); - strncpy(info->model, "N/A", 3); - } - - memset(node_path, 0, ONLP_NODE_MAX_PATH_LEN); - sprintf(node_path, module_devfiles__[id], "sn"); - ret = onlp_file_read(temp, ONLP_CONFIG_INFO_STR_MAX, &len, node_path); - if (ret == 0) { - /*remove the '\n'*/ - temp[strlen((char*)temp)-1] = 0; - snprintf(info->serial, ONLP_CONFIG_INFO_STR_MAX, "%s", temp); - } else { - AIM_LOG_ERROR("Unable to read model name from file(%s)\r\n", node_path); - strncpy(info->serial, "N/A", 3); - } -} - -static int -psu_module_info_get(int id, onlp_psu_info_t* info) -{ - int ret = 0; - char node_path[ONLP_NODE_MAX_PATH_LEN] = {0}; - int value = 0; - - info->caps |= ONLP_PSU_CAPS_DC12; - - memset(node_path, 0, ONLP_NODE_MAX_PATH_LEN); - sprintf(node_path, module_devfiles__[id], "vout"); - ret = onlp_file_read_int(&value, node_path); - if (ret < 0) { - AIM_LOG_ERROR("Unable to read vout from file(%s)\r\n", node_path); - } else { - info->mvout = value; - info->caps |= ONLP_PSU_CAPS_VOUT; - } - - memset(node_path, 0, ONLP_NODE_MAX_PATH_LEN); - sprintf(node_path, module_devfiles__[id], "iout"); - ret = onlp_file_read_int(&value, node_path); - if (ret < 0) { - AIM_LOG_ERROR("Unable to read iout from file(%s)\r\n", node_path); - } else { - info->miout = value; - info->caps |= ONLP_PSU_CAPS_IOUT; - } - - memset(node_path, 0, ONLP_NODE_MAX_PATH_LEN); - sprintf(node_path, module_devfiles__[id], "pout"); - ret = onlp_file_read_int(&value, node_path); - if (ret < 0) { - AIM_LOG_ERROR("Unable to read pout from file(%s)\r\n", node_path); - } else { - info->mpout = value; - info->caps |= ONLP_PSU_CAPS_POUT; - } - - memset(node_path, 0, ONLP_NODE_MAX_PATH_LEN); - sprintf(node_path, module_devfiles__[id], "vin"); - ret = onlp_file_read_int(&value, node_path); - if (ret < 0) { - AIM_LOG_ERROR("Unable to read vin from file(%s)\r\n", node_path); - } else { - info->mvin = value; - info->caps |= ONLP_PSU_CAPS_VIN; - } - - memset(node_path, 0, ONLP_NODE_MAX_PATH_LEN); - sprintf(node_path, module_devfiles__[id], "iin"); - ret = onlp_file_read_int(&value, node_path); - if (ret < 0) { - AIM_LOG_ERROR("Unable to read iin from file(%s)\r\n", node_path); - } else { - info->miin = value; - info->caps |= ONLP_PSU_CAPS_IIN; - } - - memset(node_path, 0, ONLP_NODE_MAX_PATH_LEN); - sprintf(node_path, module_devfiles__[id], "pin"); - ret = onlp_file_read_int(&value, node_path); - if (ret < 0) { - AIM_LOG_ERROR("Unable to read pin from file(%s)\r\n", node_path); - } else { - info->mpin = value; - info->caps |= ONLP_PSU_CAPS_PIN; - } - - psu_module_name_get(id, info); - 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_THERMAL_ID_CREATE(THERMAL_1_ON_PSU1), - ONLP_FAN_ID_CREATE(FAN_1_ON_PSU1) - } - }, - }, - { - { - ONLP_PSU_ID_CREATE(PSU2_ID), "PSU-2", 0, - { - ONLP_THERMAL_ID_CREATE(THERMAL_1_ON_PSU2), - ONLP_FAN_ID_CREATE(FAN_1_ON_PSU2) - } - }, - } -}; - -int onlp_psui_status_get(onlp_oid_t id, uint32_t* rv) -{ - int val=0; - int index = ONLP_OID_ID_GET(id); - int ret; - - VALIDATE(id); - - /* Get the present state */ - if ((ret = psu_status_info_get(index, "psu", &val)) == ONLP_STATUS_E_INTERNAL) { - printf("Unable to read PSU(%d) node(psu)\r\n", index); - return ret; - } - if(index>=PSU_MAX) return ONLP_STATUS_E_INVALID; - - if (val == HWMON_PSU_NORMAL) { - *rv = ONLP_PSU_STATUS_PRESENT; - } else if (val == HWMON_PSU_UNPOWERED ) { - *rv = ONLP_PSU_STATUS_PRESENT|ONLP_PSU_STATUS_UNPLUGGED; - return ret; - } else if(val==HWMON_PSU_FAULT) { - *rv = ONLP_PSU_STATUS_PRESENT| ONLP_PSU_STATUS_FAILED; - return ret; - } else if(val== HWMON_PSU_NOT_INSTALLED) { - *rv=0; - } else { - return ONLP_STATUS_E_INVALID; - } - return ONLP_STATUS_OK; -} - -int -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); - - VALIDATE(id); - if(index>=PSU_MAX) return ONLP_STATUS_E_INVALID; - - memset(info, 0, sizeof(onlp_psu_info_t)); - *info = pinfo[index]; /* Set the onlp_oid_hdr_t */ - - onlp_psui_status_get(id, &info->status); - - if ((ret = psu_module_info_get(index, info)) != ONLP_STATUS_OK) { - printf("Unable to read PSU(%d) module information\r\n", index); - } - - return ret; -} - diff --git a/packages/platforms/inventec/x86-64/d3352/onlp/builds/x86_64_inventec_d3352/module/src/sfpi.c b/packages/platforms/inventec/x86-64/d3352/onlp/builds/x86_64_inventec_d3352/module/src/sfpi.c deleted file mode 100644 index dcf22b66c..000000000 --- a/packages/platforms/inventec/x86-64/d3352/onlp/builds/x86_64_inventec_d3352/module/src/sfpi.c +++ /dev/null @@ -1,278 +0,0 @@ -/************************************************************ - * sfpi.c - * - * Copyright 2018 Inventec Technology Corporation. - * - ************************************************************ - * - ***********************************************************/ -#include - -#include /* For O_RDWR && open */ -#include -#include -#include -#include -#include -#include -#include "platform_lib.h" - -static char sfp_node_path[ONLP_NODE_MAX_PATH_LEN] = {0}; - -#define NUM_OF_SFP_PORT (CHASSIS_SFP_COUNT) -static const int sfp_mux_index[NUM_OF_SFP_PORT] = { - 2, 3, 4, 5 -}; - -#define FRONT_PORT_TO_MUX_INDEX(port) (sfp_mux_index[port]) - -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/class/swps/port%d/%s", port, node_name); - - return sfp_node_path; -} - -/************************************************************ - * - * SFPI Entry Points - * - ***********************************************************/ -int -onlp_sfpi_init(void) -{ - DEBUG_PRINT("%s(%d): %s\r\n", __FUNCTION__, __LINE__, INV_PLATFORM_NAME); - - /* Called at initialization time */ - return ONLP_STATUS_OK; -} - -int -onlp_sfpi_bitmap_get(onlp_sfp_bitmap_t* bmap) -{ - /* - * Ports {0, 4/52} - */ - 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, "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; - } - if (present == 0) { - present = 1; - } else if (present == 1) { - present = 0; - } else { - AIM_LOG_ERROR("Unvalid present status %d from port(%d)\r\n",present,port); - return ONLP_STATUS_E_INTERNAL; - } - return present; -} - -int -onlp_sfpi_presence_bitmap_get(onlp_sfp_bitmap_t* dst) -{ - uint32_t presence_all[2] = {0}; - int port, ret, index; - - for (port = 0, index = 0; port < NUM_OF_SFP_PORT; port++) { - if (port == 32) { - index = 1; - } - - ret = onlp_sfpi_is_present(port); - if (ret == 1) { - presence_all[index] |= (1<>= 1; - } - return ONLP_STATUS_OK; -} - -int -onlp_sfpi_is_rx_los(int port) -{ - int rxlos, rv; - //char buf[ONLP_CONFIG_INFO_STR_MAX]; - if(port > NUM_OF_SFP_PORT) { - return ONLP_STATUS_E_INVALID; - } - if(onlp_sfpi_is_present(port) == 0) { - return ONLP_STATUS_E_INVALID; - } - char *path=sfp_get_port_path(port, "rxlos"); - rv=onlp_file_read_int( &rxlos, path ); - if( rv != ONLP_STATUS_OK) { - return rv; - } - if(rxlos==0) rv=0; - else if(rxlos==1) rv=1; - else return ONLP_STATUS_E_INTERNAL; - return rv; -} - -int -onlp_sfpi_rx_los_bitmap_get(onlp_sfp_bitmap_t* dst) -{ - AIM_BITMAP_CLR_ALL(dst); - int port; - int isrxlos; - for(port = 0; port < NUM_OF_SFP_PORT; port++) { - if(onlp_sfpi_is_present(port) == 1) { - isrxlos = onlp_sfpi_is_rx_los(port); - if(isrxlos == 1) { - AIM_BITMAP_MOD(dst, port, 1); - } else if(isrxlos == 0) { - AIM_BITMAP_MOD(dst, port, 0); - } else { - return ONLP_STATUS_E_INTERNAL; - } - } - } - return ONLP_STATUS_OK; -} - -int -onlp_sfpi_eeprom_read(int port, uint8_t data[256]) -{ -#if 1 - int bus = FRONT_PORT_TO_MUX_INDEX(port); - - memset(data, 0, 256); - /* Read eeprom information into data[] */ - if (onlp_i2c_block_read(bus, 0x50, 0x00, 256, data, 0) != 0) { - AIM_LOG_ERROR("Unable to read eeprom from port(%d)\r\n", port); - return ONLP_STATUS_E_INTERNAL; - } -#else - char* path; - 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); - path = sfp_get_port_path(port, "eeprom"); - if (onlp_file_read(&data[0], 256, &len, path) < 0) { - AIM_LOG_ERROR("Unable to read eeprom from port(%d)\r\n", port); - return ONLP_STATUS_E_INTERNAL; - } -#endif - 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_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_control_get(int port, onlp_sfp_control_t control, int* value) -{ - int ret = ONLP_STATUS_E_UNSUPPORTED; - char *path; - if(port >= 0 && port < NUM_OF_SFP_PORT) { - switch (control) { - case ONLP_SFP_CONTROL_RX_LOS: - path=sfp_get_port_path(port,"rxlos"); - ret = onlp_file_read_int(value, path); - break; - case ONLP_SFP_CONTROL_TX_DISABLE: - path=sfp_get_port_path(port,"tx_disable"); - ret = onlp_file_read_int(value, path); - break; - case ONLP_SFP_CONTROL_TX_FAULT: - path=sfp_get_port_path(port,"tx_fault"); - ret = onlp_file_read_int(value, path); - break; - default: - break; - } - } - return ret; -} - -int -onlp_sfpi_denit(void) -{ - return ONLP_STATUS_OK; -} diff --git a/packages/platforms/inventec/x86-64/d3352/onlp/builds/x86_64_inventec_d3352/module/src/sysi.c b/packages/platforms/inventec/x86-64/d3352/onlp/builds/x86_64_inventec_d3352/module/src/sysi.c deleted file mode 100644 index 64347cd9b..000000000 --- a/packages/platforms/inventec/x86-64/d3352/onlp/builds/x86_64_inventec_d3352/module/src/sysi.c +++ /dev/null @@ -1,145 +0,0 @@ -/************************************************************ - * sysi.c - * - * Copyright 2018 Inventec Technology Corporation. - * - ************************************************************ - * - ***********************************************************/ -#include -#include - -#include -#include -#include -#include -#include -#include - -#include "x86_64_inventec_d3352_int.h" -#include "x86_64_inventec_d3352_log.h" - -#include "platform_lib.h" - -#define NUM_OF_CPLD INV_CPLD_COUNT - -#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 (CHASSIS_PSU_COUNT) -#define NUM_OF_LED_ON_MAIN_BROAD (CHASSIS_LED_COUNT) - -const char* -onlp_sysi_platform_get(void) -{ - return "x86-64-inventec-d3352-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, EEPROM_NODE(eeprom)) == 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)); - - /* 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; -} - - - -static int _sysi_version_parsing(char* file_str, char* str_buf, char* version) -{ - int rv = ONLP_STATUS_OK; - int len; - char buf[ONLP_CONFIG_INFO_STR_MAX*4]; - char *temp; - - rv = onlp_file_read((uint8_t*)buf,ONLP_CONFIG_INFO_STR_MAX*4, &len, file_str); - if( rv != ONLP_STATUS_OK ) { - return rv; - } - - temp = strstr(buf, str_buf); - if(temp) { - temp += strlen(str_buf); - snprintf(version,ONLP_CONFIG_INFO_STR_MAX, temp); - /*remove '\n'*/ - version[strlen(version)-1] = '\0'; - } else { - rv = ONLP_STATUS_E_MISSING; - } - return rv; -} - -int -onlp_sysi_platform_info_get(onlp_platform_info_t* pi) -{ - int rv = ONLP_STATUS_OK; - char cpld_str[ONLP_CONFIG_INFO_STR_MAX]= {0}; - char other_str[ONLP_CONFIG_INFO_STR_MAX]= {0}; - char version[ONLP_CONFIG_INFO_STR_MAX]; - - rv = _sysi_version_parsing(INV_CPLD_PREFIX"info", "The CPLD version is ", version); - if( rv != ONLP_STATUS_OK ) { - return rv; - } - snprintf(cpld_str, ONLP_CONFIG_INFO_STR_MAX, "%s%s ", cpld_str, version); - rv = _sysi_version_parsing(INV_PSOC_PREFIX"version", "ver: ", version); - if( rv != ONLP_STATUS_OK ) { - return rv; - } - snprintf(other_str, ONLP_CONFIG_INFO_STR_MAX, "%s%s%s " - ,other_str, "\n\t\tpsoc: ", version); - - /*cpld version*/ - if(strlen(cpld_str) > 0) { - pi->cpld_versions = aim_fstrdup("%s",cpld_str); - } - - /*other version*/ - if(strlen(other_str) > 0) { - pi->other_versions = aim_fstrdup("%s",other_str); - } - return rv; -} - -void -onlp_sysi_platform_info_free(onlp_platform_info_t* pi) -{ - aim_free(pi->cpld_versions); -} diff --git a/packages/platforms/inventec/x86-64/d3352/onlp/builds/x86_64_inventec_d3352/module/src/thermali.c b/packages/platforms/inventec/x86-64/d3352/onlp/builds/x86_64_inventec_d3352/module/src/thermali.c deleted file mode 100644 index 9868a8160..000000000 --- a/packages/platforms/inventec/x86-64/d3352/onlp/builds/x86_64_inventec_d3352/module/src/thermali.c +++ /dev/null @@ -1,134 +0,0 @@ -/************************************************************ - * thermali.c - * - * Copyright 2018 Inventec Technology Corporation. - * - ************************************************************ - * - * 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) - -static char* devfiles__[THERMAL_MAX] = /* must map with onlp_thermal_id */ -{ - "reserved", - INV_CTMP_PREFIX"/temp2_%s", - INV_CTMP_PREFIX"/temp3_%s", - INV_CTMP_PREFIX"/temp4_%s", - INV_CTMP_PREFIX"/temp5_%s", - INV_PSOC_PREFIX"/temp1_input", - INV_PSOC_PREFIX"/temp2_input", - INV_PSOC_PREFIX"/temp3_input", - INV_PSOC_PREFIX"/temp4_input", - INV_PSOC_PREFIX"/temp5_input", - INV_PSOC_PREFIX"/thermal_psu1", - INV_PSOC_PREFIX"/thermal_psu2", -}; - -/* Static values */ -static onlp_thermal_info_t linfo[THERMAL_MAX] = { - { }, /* Not used */ - { { ONLP_THERMAL_ID_CREATE(THERMAL_CPU_CORE_FIRST), "CPU Core 0", 0}, - ONLP_THERMAL_STATUS_PRESENT, - ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS - }, - { { ONLP_THERMAL_ID_CREATE(THERMAL_CPU_CORE_2), "CPU Core 1", 0}, - ONLP_THERMAL_STATUS_PRESENT, - ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS - }, - { { ONLP_THERMAL_ID_CREATE(THERMAL_CPU_CORE_3), "CPU Core 2", 0}, - ONLP_THERMAL_STATUS_PRESENT, - ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS - }, - { { ONLP_THERMAL_ID_CREATE(THERMAL_CPU_CORE_LAST), "CPU Core 3", 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_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) -{ - DEBUG_PRINT("%s(%d): %s\r\n", __FUNCTION__, __LINE__, INV_PLATFORM_NAME); - - 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_FIRST && local_id <= THERMAL_CPU_CORE_LAST) { - char desc[32], *dp = &desc[0]; - int rv = onlp_file_read_str(&dp, devfiles__[local_id], "label"); - if (rv > 0) { - memset (info->hdr.description, 0, ONLP_OID_DESC_SIZE); - strncpy(info->hdr.description, dp, rv); - } - - /* Set the onlp_oid_hdr_t and capabilities */ - return onlp_file_read_int(&info->mcelsius, devfiles__[local_id], "input"); - } - return onlp_file_read_int(&info->mcelsius, devfiles__[local_id]); -} diff --git a/packages/platforms/inventec/x86-64/d3352/onlp/builds/x86_64_inventec_d3352/module/src/x86_64_inventec_d3352_config.c b/packages/platforms/inventec/x86-64/d3352/onlp/builds/x86_64_inventec_d3352/module/src/x86_64_inventec_d3352_config.c deleted file mode 100644 index e241c76a0..000000000 --- a/packages/platforms/inventec/x86-64/d3352/onlp/builds/x86_64_inventec_d3352/module/src/x86_64_inventec_d3352_config.c +++ /dev/null @@ -1,79 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#include - -/* */ -#define __x86_64_inventec_d3352_config_STRINGIFY_NAME(_x) #_x -#define __x86_64_inventec_d3352_config_STRINGIFY_VALUE(_x) __x86_64_inventec_d3352_config_STRINGIFY_NAME(_x) -x86_64_inventec_d3352_config_settings_t x86_64_inventec_d3352_config_settings[] = { -#ifdef X86_64_INVENTEC_D3352_CONFIG_INCLUDE_LOGGING - { __x86_64_inventec_d3352_config_STRINGIFY_NAME(X86_64_INVENTEC_D3352_CONFIG_INCLUDE_LOGGING), __x86_64_inventec_d3352_config_STRINGIFY_VALUE(X86_64_INVENTEC_D3352_CONFIG_INCLUDE_LOGGING) }, -#else - { X86_64_INVENTEC_D3352_CONFIG_INCLUDE_LOGGING(__x86_64_inventec_d3352_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_INVENTEC_D3352_CONFIG_LOG_OPTIONS_DEFAULT - { __x86_64_inventec_d3352_config_STRINGIFY_NAME(X86_64_INVENTEC_D3352_CONFIG_LOG_OPTIONS_DEFAULT), __x86_64_inventec_d3352_config_STRINGIFY_VALUE(X86_64_INVENTEC_D3352_CONFIG_LOG_OPTIONS_DEFAULT) }, -#else - { X86_64_INVENTEC_D3352_CONFIG_LOG_OPTIONS_DEFAULT(__x86_64_inventec_d3352_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_INVENTEC_D3352_CONFIG_LOG_BITS_DEFAULT - { __x86_64_inventec_d3352_config_STRINGIFY_NAME(X86_64_INVENTEC_D3352_CONFIG_LOG_BITS_DEFAULT), __x86_64_inventec_d3352_config_STRINGIFY_VALUE(X86_64_INVENTEC_D3352_CONFIG_LOG_BITS_DEFAULT) }, -#else - { X86_64_INVENTEC_D3352_CONFIG_LOG_BITS_DEFAULT(__x86_64_inventec_d3352_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_INVENTEC_D3352_CONFIG_LOG_CUSTOM_BITS_DEFAULT - { __x86_64_inventec_d3352_config_STRINGIFY_NAME(X86_64_INVENTEC_D3352_CONFIG_LOG_CUSTOM_BITS_DEFAULT), __x86_64_inventec_d3352_config_STRINGIFY_VALUE(X86_64_INVENTEC_D3352_CONFIG_LOG_CUSTOM_BITS_DEFAULT) }, -#else - { X86_64_INVENTEC_D3352_CONFIG_LOG_CUSTOM_BITS_DEFAULT(__x86_64_inventec_d3352_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_INVENTEC_D3352_CONFIG_PORTING_STDLIB - { __x86_64_inventec_d3352_config_STRINGIFY_NAME(X86_64_INVENTEC_D3352_CONFIG_PORTING_STDLIB), __x86_64_inventec_d3352_config_STRINGIFY_VALUE(X86_64_INVENTEC_D3352_CONFIG_PORTING_STDLIB) }, -#else - { X86_64_INVENTEC_D3352_CONFIG_PORTING_STDLIB(__x86_64_inventec_d3352_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_INVENTEC_D3352_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS - { __x86_64_inventec_d3352_config_STRINGIFY_NAME(X86_64_INVENTEC_D3352_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS), __x86_64_inventec_d3352_config_STRINGIFY_VALUE(X86_64_INVENTEC_D3352_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS) }, -#else - { X86_64_INVENTEC_D3352_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS(__x86_64_inventec_d3352_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_INVENTEC_D3352_CONFIG_INCLUDE_UCLI - { __x86_64_inventec_d3352_config_STRINGIFY_NAME(X86_64_INVENTEC_D3352_CONFIG_INCLUDE_UCLI), __x86_64_inventec_d3352_config_STRINGIFY_VALUE(X86_64_INVENTEC_D3352_CONFIG_INCLUDE_UCLI) }, -#else - { X86_64_INVENTEC_D3352_CONFIG_INCLUDE_UCLI(__x86_64_inventec_d3352_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_INVENTEC_D3352_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION - { __x86_64_inventec_d3352_config_STRINGIFY_NAME(X86_64_INVENTEC_D3352_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION), __x86_64_inventec_d3352_config_STRINGIFY_VALUE(X86_64_INVENTEC_D3352_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION) }, -#else - { X86_64_INVENTEC_D3352_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION(__x86_64_inventec_d3352_config_STRINGIFY_NAME), "__undefined__" }, -#endif - { NULL, NULL } -}; -#undef __x86_64_inventec_d3352_config_STRINGIFY_VALUE -#undef __x86_64_inventec_d3352_config_STRINGIFY_NAME - -const char* -x86_64_inventec_d3352_config_lookup(const char* setting) -{ - int i; - for(i = 0; x86_64_inventec_d3352_config_settings[i].name; i++) { - if(!strcmp(x86_64_inventec_d3352_config_settings[i].name, setting)) { - return x86_64_inventec_d3352_config_settings[i].value; - } - } - return NULL; -} - -int -x86_64_inventec_d3352_config_show(struct aim_pvs_s* pvs) -{ - int i; - for(i = 0; x86_64_inventec_d3352_config_settings[i].name; i++) { - aim_printf(pvs, "%s = %s\n", x86_64_inventec_d3352_config_settings[i].name, x86_64_inventec_d3352_config_settings[i].value); - } - return i; -} - -/* */ diff --git a/packages/platforms/inventec/x86-64/d3352/onlp/builds/x86_64_inventec_d3352/module/src/x86_64_inventec_d3352_enums.c b/packages/platforms/inventec/x86-64/d3352/onlp/builds/x86_64_inventec_d3352/module/src/x86_64_inventec_d3352_enums.c deleted file mode 100644 index 4b33d708f..000000000 --- a/packages/platforms/inventec/x86-64/d3352/onlp/builds/x86_64_inventec_d3352/module/src/x86_64_inventec_d3352_enums.c +++ /dev/null @@ -1,10 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#include - -/* <--auto.start.enum(ALL).source> */ -/* */ - diff --git a/packages/platforms/inventec/x86-64/d3352/onlp/builds/x86_64_inventec_d3352/module/src/x86_64_inventec_d3352_int.h b/packages/platforms/inventec/x86-64/d3352/onlp/builds/x86_64_inventec_d3352/module/src/x86_64_inventec_d3352_int.h deleted file mode 100644 index 331dd1af3..000000000 --- a/packages/platforms/inventec/x86-64/d3352/onlp/builds/x86_64_inventec_d3352/module/src/x86_64_inventec_d3352_int.h +++ /dev/null @@ -1,12 +0,0 @@ -/**************************************************************************//** - * - * x86_64_inventec_d3352 Internal Header - * - *****************************************************************************/ -#ifndef __x86_64_inventec_d3352_INT_H__ -#define __x86_64_inventec_d3352_INT_H__ - -#include - - -#endif /* __x86_64_inventec_d3352_INT_H__ */ diff --git a/packages/platforms/inventec/x86-64/d3352/onlp/builds/x86_64_inventec_d3352/module/src/x86_64_inventec_d3352_log.c b/packages/platforms/inventec/x86-64/d3352/onlp/builds/x86_64_inventec_d3352/module/src/x86_64_inventec_d3352_log.c deleted file mode 100644 index e7aef277c..000000000 --- a/packages/platforms/inventec/x86-64/d3352/onlp/builds/x86_64_inventec_d3352/module/src/x86_64_inventec_d3352_log.c +++ /dev/null @@ -1,17 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#include - -#include "x86_64_inventec_d3352_log.h" -/* - * x86_64_inventec_d3352 log struct. - */ -AIM_LOG_STRUCT_DEFINE( - X86_64_INVENTEC_D3352_CONFIG_LOG_OPTIONS_DEFAULT, - X86_64_INVENTEC_D3352_CONFIG_LOG_BITS_DEFAULT, - NULL, /* Custom log map */ - X86_64_INVENTEC_D3352_CONFIG_LOG_CUSTOM_BITS_DEFAULT -); diff --git a/packages/platforms/inventec/x86-64/d3352/onlp/builds/x86_64_inventec_d3352/module/src/x86_64_inventec_d3352_log.h b/packages/platforms/inventec/x86-64/d3352/onlp/builds/x86_64_inventec_d3352/module/src/x86_64_inventec_d3352_log.h deleted file mode 100644 index be65ba1b1..000000000 --- a/packages/platforms/inventec/x86-64/d3352/onlp/builds/x86_64_inventec_d3352/module/src/x86_64_inventec_d3352_log.h +++ /dev/null @@ -1,12 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#ifndef __x86_64_inventec_d3352_LOG_H__ -#define __x86_64_inventec_d3352_LOG_H__ - -#define AIM_LOG_MODULE_NAME x86_64_inventec_d3352 -#include - -#endif /* __x86_64_inventec_d3352_LOG_H__ */ diff --git a/packages/platforms/inventec/x86-64/d3352/onlp/builds/x86_64_inventec_d3352/module/src/x86_64_inventec_d3352_module.c b/packages/platforms/inventec/x86-64/d3352/onlp/builds/x86_64_inventec_d3352/module/src/x86_64_inventec_d3352_module.c deleted file mode 100644 index 69c5e750b..000000000 --- a/packages/platforms/inventec/x86-64/d3352/onlp/builds/x86_64_inventec_d3352/module/src/x86_64_inventec_d3352_module.c +++ /dev/null @@ -1,24 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#include - -#include "x86_64_inventec_d3352_log.h" - -static int -datatypes_init__(void) -{ -#define x86_64_inventec_d3352_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_d3352_module_init__(void) -{ - AIM_LOG_STRUCT_REGISTER(); - datatypes_init__(); -} - -int __onlp_platform_version__ = 1; diff --git a/packages/platforms/inventec/x86-64/d3352/onlp/builds/x86_64_inventec_d3352/module/src/x86_64_inventec_d3352_ucli.c b/packages/platforms/inventec/x86-64/d3352/onlp/builds/x86_64_inventec_d3352/module/src/x86_64_inventec_d3352_ucli.c deleted file mode 100644 index fb7e703bb..000000000 --- a/packages/platforms/inventec/x86-64/d3352/onlp/builds/x86_64_inventec_d3352/module/src/x86_64_inventec_d3352_ucli.c +++ /dev/null @@ -1,49 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#include - -#if x86_64_inventec_d3352_CONFIG_INCLUDE_UCLI == 1 - -#include -#include -#include - -static ucli_status_t -x86_64_inventec_d3352_ucli_ucli__config__(ucli_context_t* uc) -{ - UCLI_HANDLER_MACRO_MODULE_CONFIG(x86_64_inventec_d3352) -} - -/* */ -/* */ - -static ucli_module_t -x86_64_inventec_d3352_ucli_module__ = { - "x86_64_inventec_d3352_ucli", - NULL, - x86_64_inventec_d3352_ucli_ucli_handlers__, - NULL, - NULL, -}; - -ucli_node_t* -x86_64_inventec_d3352_ucli_node_create(void) -{ - ucli_node_t* n; - ucli_module_init(&x86_64_inventec_d3352_ucli_module__); - n = ucli_node_create("x86_64_inventec_d3352", NULL, &x86_64_inventec_d3352_ucli_module__); - ucli_node_subnode_add(n, ucli_module_log_node_create("x86_64_inventec_d3352")); - return n; -} - -#else -void* -x86_64_inventec_d3352_ucli_node_create(void) -{ - return NULL; -} -#endif - diff --git a/packages/platforms/inventec/x86-64/d3352/platform-config/Makefile b/packages/platforms/inventec/x86-64/d3352/platform-config/Makefile deleted file mode 100644 index 003238cf6..000000000 --- a/packages/platforms/inventec/x86-64/d3352/platform-config/Makefile +++ /dev/null @@ -1 +0,0 @@ -include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/inventec/x86-64/d3352/platform-config/r0/Makefile b/packages/platforms/inventec/x86-64/d3352/platform-config/r0/Makefile deleted file mode 100644 index 003238cf6..000000000 --- a/packages/platforms/inventec/x86-64/d3352/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/inventec/x86-64/d3352/platform-config/r0/PKG.yml b/packages/platforms/inventec/x86-64/d3352/platform-config/r0/PKG.yml deleted file mode 100644 index 9dae20a26..000000000 --- a/packages/platforms/inventec/x86-64/d3352/platform-config/r0/PKG.yml +++ /dev/null @@ -1 +0,0 @@ -!include $ONL_TEMPLATES/platform-config-platform.yml ARCH=amd64 VENDOR=inventec BASENAME=x86-64-inventec-d3352 REVISION=r0 diff --git a/packages/platforms/inventec/x86-64/d3352/platform-config/r0/src/lib/x86-64-inventec-d3352-r0.yml b/packages/platforms/inventec/x86-64/d3352/platform-config/r0/src/lib/x86-64-inventec-d3352-r0.yml deleted file mode 100644 index 4645d9f79..000000000 --- a/packages/platforms/inventec/x86-64/d3352/platform-config/r0/src/lib/x86-64-inventec-d3352-r0.yml +++ /dev/null @@ -1,32 +0,0 @@ ---- - -###################################################################### -# -# platform-config for d3352 -# -###################################################################### - -x86-64-inventec-d3352-r0: - - grub: - - serial: >- - --port=0x2f8 - --speed=115200 - --word=8 - --parity=no - --stop=1 - - kernel: - <<: *kernel-3-16 - - args: >- - nopat - console=ttyS1,115200n8 - i2c-ismt.enable=0 - - ##network - ## interfaces: - ## ma1: - ## name: ~ - ## syspath: pci0000:00/0000:00:14.0 diff --git a/packages/platforms/inventec/x86-64/d3352/platform-config/r0/src/python/x86_64_inventec_d3352_r0/__init__.py b/packages/platforms/inventec/x86-64/d3352/platform-config/r0/src/python/x86_64_inventec_d3352_r0/__init__.py deleted file mode 100644 index d607bf1a6..000000000 --- a/packages/platforms/inventec/x86-64/d3352/platform-config/r0/src/python/x86_64_inventec_d3352_r0/__init__.py +++ /dev/null @@ -1,23 +0,0 @@ -from onl.platform.base import * -from onl.platform.inventec import * - -class OnlPlatform_x86_64_inventec_d3352_r0(OnlPlatformInventec, - OnlPlatformPortConfig_48x1_4x10): - PLATFORM='x86-64-inventec-d3352-r0' - MODEL="X86-D3352" - SYS_OBJECT_ID=".3352.1" - - def baseconfig(self): - os.system("insmod /lib/modules/`uname -r`/kernel/drivers/gpio/gpio-ich.ko") - self.insmod('i2c-gpio') - self.insmod('inv_platform') - self.insmod('inv_psoc') - self.insmod('inv_cpld') - self.new_i2c_device('inv_eeprom', 0x53, 0) - self.insmod('inv_eeprom') - self.new_i2c_device('inv_psoc', 0x66, 1) - self.new_i2c_device('inv_cpld', 0x55, 1) - self.insmod('swps') - self.insmod('inv_pthread') - #self.insmod('vpd') - return True diff --git a/packages/platforms/inventec/x86-64/d5052/.gitignore b/packages/platforms/inventec/x86-64/d5052/.gitignore deleted file mode 100644 index 0bfd9a3cd..000000000 --- a/packages/platforms/inventec/x86-64/d5052/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -*x86*64*inventec*d5052*.mk -onlpdump.mk diff --git a/packages/platforms/inventec/x86-64/d5052/Makefile b/packages/platforms/inventec/x86-64/d5052/Makefile deleted file mode 100644 index 26aa37e6b..000000000 --- a/packages/platforms/inventec/x86-64/d5052/Makefile +++ /dev/null @@ -1,2 +0,0 @@ -include $(ONL)/make/pkg.mk - diff --git a/packages/platforms/inventec/x86-64/d5052/modules/Makefile b/packages/platforms/inventec/x86-64/d5052/modules/Makefile deleted file mode 100644 index 003238cf6..000000000 --- a/packages/platforms/inventec/x86-64/d5052/modules/Makefile +++ /dev/null @@ -1 +0,0 @@ -include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/inventec/x86-64/d5052/modules/PKG.yml b/packages/platforms/inventec/x86-64/d5052/modules/PKG.yml deleted file mode 100644 index efc1e7431..000000000 --- a/packages/platforms/inventec/x86-64/d5052/modules/PKG.yml +++ /dev/null @@ -1 +0,0 @@ -!include $ONL_TEMPLATES/platform-modules.yml VENDOR=inventec BASENAME=x86-64-inventec-d5052 ARCH=amd64 KERNELS="onl-kernel-3.16-lts-x86-64-all:amd64" diff --git a/packages/platforms/inventec/x86-64/d5052/modules/builds/.gitignore b/packages/platforms/inventec/x86-64/d5052/modules/builds/.gitignore deleted file mode 100644 index a65b41774..000000000 --- a/packages/platforms/inventec/x86-64/d5052/modules/builds/.gitignore +++ /dev/null @@ -1 +0,0 @@ -lib diff --git a/packages/platforms/inventec/x86-64/d5052/modules/builds/Makefile b/packages/platforms/inventec/x86-64/d5052/modules/builds/Makefile deleted file mode 100644 index 4bc0715af..000000000 --- a/packages/platforms/inventec/x86-64/d5052/modules/builds/Makefile +++ /dev/null @@ -1,7 +0,0 @@ -KERNELS := onl-kernel-3.16-lts-x86-64-all:amd64 -KMODULES := src -VENDOR := inventec -BASENAME := x86-64-inventec-d5052 -ARCH := x86_64 -include $(ONL)/make/kmodule.mk - diff --git a/packages/platforms/inventec/x86-64/d5052/modules/builds/src/Makefile b/packages/platforms/inventec/x86-64/d5052/modules/builds/src/Makefile deleted file mode 100644 index d2ba5cb2b..000000000 --- a/packages/platforms/inventec/x86-64/d5052/modules/builds/src/Makefile +++ /dev/null @@ -1,10 +0,0 @@ -obj-m += i2c-gpio.o -obj-m += inv_cpld.o -obj-m += inv_platform.o -obj-m += inv_psoc.o -obj-m += inv_pthread.o -obj-m += swps.o -swps-objs := inv_swps.o io_expander.o transceiver.o inv_mux.o -obj-m += vpd.o -vpd-objs := inv_vpd.o onie_tlvinfo.o - diff --git a/packages/platforms/inventec/x86-64/d5052/modules/builds/src/i2c-gpio.c b/packages/platforms/inventec/x86-64/d5052/modules/builds/src/i2c-gpio.c deleted file mode 100644 index 71a45b210..000000000 --- a/packages/platforms/inventec/x86-64/d5052/modules/builds/src/i2c-gpio.c +++ /dev/null @@ -1,293 +0,0 @@ -/* - * Bitbanging I2C bus driver using the GPIO API - * - * Copyright (C) 2007 Atmel Corporation - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. - */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -struct i2c_gpio_private_data { - struct i2c_adapter adap; - struct i2c_algo_bit_data bit_data; - struct i2c_gpio_platform_data pdata; -}; - -/* Toggle SDA by changing the direction of the pin */ -static void i2c_gpio_setsda_dir(void *data, int state) -{ - struct i2c_gpio_platform_data *pdata = data; - - if (state) - gpio_direction_input(pdata->sda_pin); - else - gpio_direction_output(pdata->sda_pin, 0); -} - -/* - * Toggle SDA by changing the output value of the pin. This is only - * valid for pins configured as open drain (i.e. setting the value - * high effectively turns off the output driver.) - */ -static void i2c_gpio_setsda_val(void *data, int state) -{ - struct i2c_gpio_platform_data *pdata = data; - - gpio_set_value(pdata->sda_pin, state); -} - -/* Toggle SCL by changing the direction of the pin. */ -static void i2c_gpio_setscl_dir(void *data, int state) -{ - struct i2c_gpio_platform_data *pdata = data; - - if (state) - gpio_direction_input(pdata->scl_pin); - else - gpio_direction_output(pdata->scl_pin, 0); -} - -/* - * Toggle SCL by changing the output value of the pin. This is used - * for pins that are configured as open drain and for output-only - * pins. The latter case will break the i2c protocol, but it will - * often work in practice. - */ -static void i2c_gpio_setscl_val(void *data, int state) -{ - struct i2c_gpio_platform_data *pdata = data; - - gpio_set_value(pdata->scl_pin, state); -} - -static int i2c_gpio_getsda(void *data) -{ - struct i2c_gpio_platform_data *pdata = data; - - return gpio_get_value(pdata->sda_pin); -} - -static int i2c_gpio_getscl(void *data) -{ - struct i2c_gpio_platform_data *pdata = data; - - return gpio_get_value(pdata->scl_pin); -} - -static int of_i2c_gpio_get_pins(struct device_node *np, - unsigned int *sda_pin, unsigned int *scl_pin) -{ - if (of_gpio_count(np) < 2) - return -ENODEV; - - *sda_pin = of_get_gpio(np, 0); - *scl_pin = of_get_gpio(np, 1); - - if (*sda_pin == -EPROBE_DEFER || *scl_pin == -EPROBE_DEFER) - return -EPROBE_DEFER; - - if (!gpio_is_valid(*sda_pin) || !gpio_is_valid(*scl_pin)) { - pr_err("%s: invalid GPIO pins, sda=%d/scl=%d\n", - np->full_name, *sda_pin, *scl_pin); - return -ENODEV; - } - - return 0; -} - -static void of_i2c_gpio_get_props(struct device_node *np, - struct i2c_gpio_platform_data *pdata) -{ - u32 reg; - - of_property_read_u32(np, "i2c-gpio,delay-us", &pdata->udelay); - - if (!of_property_read_u32(np, "i2c-gpio,timeout-ms", ®)) - pdata->timeout = msecs_to_jiffies(reg); - - pdata->sda_is_open_drain = - of_property_read_bool(np, "i2c-gpio,sda-open-drain"); - pdata->scl_is_open_drain = - of_property_read_bool(np, "i2c-gpio,scl-open-drain"); - pdata->scl_is_output_only = - of_property_read_bool(np, "i2c-gpio,scl-output-only"); -} - -static int i2c_gpio_probe(struct platform_device *pdev) -{ - struct i2c_gpio_private_data *priv; - struct i2c_gpio_platform_data *pdata; - struct i2c_algo_bit_data *bit_data; - struct i2c_adapter *adap; - unsigned int sda_pin, scl_pin; - int ret; - - /* First get the GPIO pins; if it fails, we'll defer the probe. */ - if (pdev->dev.of_node) { - ret = of_i2c_gpio_get_pins(pdev->dev.of_node, - &sda_pin, &scl_pin); - if (ret) - return ret; - } else { - if (!dev_get_platdata(&pdev->dev)) - return -ENXIO; - pdata = dev_get_platdata(&pdev->dev); - sda_pin = pdata->sda_pin; - scl_pin = pdata->scl_pin; - } - - ret = devm_gpio_request(&pdev->dev, sda_pin, "sda"); - if (ret) { - if (ret == -EINVAL) - ret = -EPROBE_DEFER; /* Try again later */ - return ret; - } - ret = devm_gpio_request(&pdev->dev, scl_pin, "scl"); - if (ret) { - if (ret == -EINVAL) - ret = -EPROBE_DEFER; /* Try again later */ - return ret; - } - - priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL); - if (!priv) - return -ENOMEM; - adap = &priv->adap; - bit_data = &priv->bit_data; - pdata = &priv->pdata; - - if (pdev->dev.of_node) { - pdata->sda_pin = sda_pin; - pdata->scl_pin = scl_pin; - of_i2c_gpio_get_props(pdev->dev.of_node, pdata); - } else { - memcpy(pdata, dev_get_platdata(&pdev->dev), sizeof(*pdata)); - } - - if (pdata->sda_is_open_drain) { - gpio_direction_output(pdata->sda_pin, 1); - bit_data->setsda = i2c_gpio_setsda_val; - } else { - gpio_direction_input(pdata->sda_pin); - bit_data->setsda = i2c_gpio_setsda_dir; - } - - if (pdata->scl_is_open_drain || pdata->scl_is_output_only) { - gpio_direction_output(pdata->scl_pin, 1); - bit_data->setscl = i2c_gpio_setscl_val; - } else { - gpio_direction_input(pdata->scl_pin); - bit_data->setscl = i2c_gpio_setscl_dir; - } - - if (!pdata->scl_is_output_only) - bit_data->getscl = i2c_gpio_getscl; - bit_data->getsda = i2c_gpio_getsda; - - if (pdata->udelay) - bit_data->udelay = pdata->udelay; - else if (pdata->scl_is_output_only) - bit_data->udelay = 50; /* 10 kHz */ - else - bit_data->udelay = 5; /* 100 kHz */ - - if (pdata->timeout) - bit_data->timeout = pdata->timeout; - else - bit_data->timeout = HZ / 10; /* 100 ms */ - - bit_data->data = pdata; - - adap->owner = THIS_MODULE; - if (pdev->dev.of_node) - strlcpy(adap->name, dev_name(&pdev->dev), sizeof(adap->name)); - else - snprintf(adap->name, sizeof(adap->name), "i2c-gpio%d", pdev->id); - - adap->algo_data = bit_data; - adap->class = I2C_CLASS_HWMON | I2C_CLASS_SPD; - adap->dev.parent = &pdev->dev; - adap->dev.of_node = pdev->dev.of_node; - - adap->nr = pdev->id; - ret = i2c_bit_add_numbered_bus(adap); - if (ret) - return ret; - - platform_set_drvdata(pdev, priv); - - dev_info(&pdev->dev, "using pins %u (SDA) and %u (SCL%s)\n", - pdata->sda_pin, pdata->scl_pin, - pdata->scl_is_output_only - ? ", no clock stretching" : ""); - - return 0; -} - -static int i2c_gpio_remove(struct platform_device *pdev) -{ - struct i2c_gpio_private_data *priv; - struct i2c_gpio_platform_data *pdata; - struct i2c_adapter *adap; - - priv = platform_get_drvdata(pdev); - adap = &priv->adap; - pdata = &priv->pdata; - - i2c_del_adapter(adap); - - return 0; -} - -#if defined(CONFIG_OF) -static const struct of_device_id i2c_gpio_dt_ids[] = { - { .compatible = "i2c-gpio", }, - { /* sentinel */ } -}; - -MODULE_DEVICE_TABLE(of, i2c_gpio_dt_ids); -#endif - -static struct platform_driver i2c_gpio_driver = { - .driver = { - .name = "i2c-gpio", - .owner = THIS_MODULE, - .of_match_table = of_match_ptr(i2c_gpio_dt_ids), - }, - .probe = i2c_gpio_probe, - .remove = i2c_gpio_remove, -}; - -static int __init i2c_gpio_init(void) -{ - int ret; - - ret = platform_driver_register(&i2c_gpio_driver); - if (ret) - printk(KERN_ERR "i2c-gpio: probe failed: %d\n", ret); - - return ret; -} -subsys_initcall(i2c_gpio_init); - -static void __exit i2c_gpio_exit(void) -{ - platform_driver_unregister(&i2c_gpio_driver); -} -module_exit(i2c_gpio_exit); - -MODULE_AUTHOR("Haavard Skinnemoen (Atmel)"); -MODULE_DESCRIPTION("Platform-independent bitbanging I2C driver"); -MODULE_LICENSE("GPL"); -MODULE_ALIAS("platform:i2c-gpio"); diff --git a/packages/platforms/inventec/x86-64/d5052/modules/builds/src/inv_cpld.c b/packages/platforms/inventec/x86-64/d5052/modules/builds/src/inv_cpld.c deleted file mode 100644 index 0ab380f48..000000000 --- a/packages/platforms/inventec/x86-64/d5052/modules/builds/src/inv_cpld.c +++ /dev/null @@ -1,591 +0,0 @@ -/* - * 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 "inv_pthread.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 -#define CPLD_BIOSCS_OFFSET 0x04 - - -/* Each client has this additional data */ -struct cpld_data { - struct device *hwmon_dev; - struct mutex update_lock; -}; - -static struct device *cpld_led_client_dev = NULL; - -/*-----------------------------------------------------------------------*/ - -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 ssize_t show_bios_cs(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_BIOSCS_OFFSET, 1); - - mutex_unlock(&data->update_lock); - - if(status != 1) return sprintf(buf, "read cpld BIOS_CS fail\n"); - - - status = sprintf (buf, "0x%X\n", b[0] & 0x01); - - return strlen(buf); -} - -static ssize_t set_bios_cs(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_BIOSCS_OFFSET, 1); - if(temp) byte |= 0x01; - else byte &= ~(0x01); - cpld_i2c_write(client, &byte, CPLD_BIOSCS_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 - "4 Hz", //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 == CPLD_DEV_LED_GRN_INDEX)?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; - - 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; -} - -ssize_t cpld_show_led(char *buf, int index) -{ - u32 status; - struct i2c_client *client = NULL; - struct cpld_data *data = NULL; - u8 byte; - int shift = (index == CPLD_DEV_LED_GRN_INDEX)?3:0; - - if (!cpld_led_client_dev) { - return 0; - } - - client = to_i2c_client(cpld_led_client_dev); - data = i2c_get_clientdata(client); - - 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); -} -EXPORT_SYMBOL(cpld_show_led); - -ssize_t cpld_set_led(const char *buf, size_t count, int index) -{ - struct i2c_client *client = NULL; - struct cpld_data *data = NULL; - - u8 temp = simple_strtol(buf, NULL, 16); - u8 byte; - int shift = (index == CPLD_DEV_LED_GRN_INDEX)?3:0; - - if (!cpld_led_client_dev) { - return 0; - } - - client = to_i2c_client(cpld_led_client_dev); - data = i2c_get_clientdata(client); - - 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; -} -EXPORT_SYMBOL(cpld_set_led); - -ssize_t cpld_show_ctl(char *buf) -{ - u32 status; - struct i2c_client *client = NULL; - struct cpld_data *data = NULL; - u8 b[1]; - - if (!cpld_led_client_dev) { - return 0; - } - - client = to_i2c_client(cpld_led_client_dev); - data = i2c_get_clientdata(client); - - 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); -} -EXPORT_SYMBOL(cpld_show_ctl); - -ssize_t cpld_set_ctl(const char *buf, size_t count) -{ - struct i2c_client *client = NULL; - struct cpld_data *data = NULL; - u8 byte; - u8 temp = simple_strtol(buf, NULL, 10); - - if (!cpld_led_client_dev) { - return 0; - } - - client = to_i2c_client(cpld_led_client_dev); - data = i2c_get_clientdata(client); - - 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; -} -EXPORT_SYMBOL(cpld_set_ctl); - -/* -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, CPLD_DEV_LED_GRN_INDEX); -static SENSOR_DEVICE_ATTR(red_led, S_IWUSR|S_IRUGO, show_led, set_led, CPLD_DEV_LED_RED_INDEX); - -static SENSOR_DEVICE_ATTR(psu0, S_IRUGO, show_psu, 0, 0); -static SENSOR_DEVICE_ATTR(psu1, S_IRUGO, show_psu, 0, 1); - -static SENSOR_DEVICE_ATTR(bios_cs, S_IWUSR|S_IRUGO, show_bios_cs, set_bios_cs, 0); - -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, - - &sensor_dev_attr_bios_cs.dev_attr.attr, - - NULL -}; - -static const struct attribute_group cpld_group = { - .attrs = cpld_attributes, -}; - -static struct attribute *cpld2_attributes[] = { - //info - &sensor_dev_attr_info.dev_attr.attr, - - NULL -}; - -static const struct attribute_group cpld2_group = { - .attrs = cpld2_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; - - 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 */ - if(id->driver_data==1) // CPLD2 - status = sysfs_create_group(&client->dev.kobj, &cpld2_group); - else // default CPLD1 - 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); - - cpld_led_client_dev = &client->dev; - return 0; - -exit_remove: - sysfs_remove_group(&client->dev.kobj, &cpld_group); -exit_free: - i2c_set_clientdata(client, NULL); - kfree(data); - cpld_led_client_dev = NULL; - 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); - cpld_led_client_dev = NULL; - return 0; -} - -static const struct i2c_device_id cpld_ids[] = { - { "inv_cpld" , 0, }, - { "inv_cpld2", 1, }, - { /* 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/d5052/modules/builds/src/inv_mux.c b/packages/platforms/inventec/x86-64/d5052/modules/builds/src/inv_mux.c deleted file mode 100644 index 89e95f12f..000000000 --- a/packages/platforms/inventec/x86-64/d5052/modules/builds/src/inv_mux.c +++ /dev/null @@ -1,275 +0,0 @@ -#include -#include -#include -#include -#include -#include "io_expander.h" -#include "inv_mux.h" - -static struct mux_obj_s *mux_head_p = NULL; - - -/* ========== MUX object functions ========== - */ -int -_common_force_pull_gpio(int mem_addr, - int input, - int bit_offset){ - - unsigned int val = 0; - unsigned int targ = 0; - - /* Get current value */ - val = inl(mem_addr); - if (val == 0) { - SWPS_ERR("%s: inl:%d fail!\n", __func__, val); - return -1; - } - /* Count target value */ - switch (input) { - case 0: /* Pull Low */ - targ = (val & (~(1 << bit_offset))); - break; - case 1: /* Pull high */ - targ = (val | (1 << bit_offset)); - break; - default: - SWPS_ERR("%s: input state:%d incorrect!\n", - __func__, input); - return -1; - } - /* Setup gpio */ - outl(targ, mem_addr); - if (targ != inl(mem_addr)){ - SWPS_ERR("%s: outl:%d fail!\n", __func__, targ); - return -1; - } - SWPS_DEBUG("%s: done.\n", __func__); - return 0; -} - - -int -rangeley_force_pull_high(struct mux_obj_s *self){ - SWPS_ERR("%s: not ready!\n", __func__); - return -1; -} - - -int -rangeley_force_pull_low(struct mux_obj_s *self){ - SWPS_ERR("%s: not ready!\n", __func__); - return -1; -} - - -int -hedera_force_pull_high(struct mux_obj_s *self){ - return _common_force_pull_gpio(MUX_RST_MEM_ADDR_HEDERA, 1, 5); -} - - -int -hedera_force_pull_low(struct mux_obj_s *self){ - return _common_force_pull_gpio(MUX_RST_MEM_ADDR_HEDERA, 0, 5); -} - - -int -normal_gpio_pull_high(struct mux_obj_s *self){ - return gpio_direction_output(self->gpio_num, 1); -} - - -int -normal_gpio_pull_low(struct mux_obj_s *self){ - return gpio_direction_output(self->gpio_num, 0); -} - - -int -pca9548_reset_mux_all(struct mux_obj_s *self){ - /* [Note] Power-on reset (PCA9548A-NXP) - * When power is applied to VDD, an internal Power-On Reset (POR) - * holds the PCA9548A in a reset condition until VDD has reached - * VPOR. At this point, the reset condition is released and the - * PCA9548A register and I2C-bus state machine are initialized to - * their default states (all zeroes) causing all the channels to - * be deselected. Thereafter, VDD must be lowered below 0.2 V for - * at least 5 us in order to reset the device. - */ - if (self->_pull_low(self) < 0) { - SWPS_ERR("%s: _pull_low fail!\n", __func__); - return -1; - } - mdelay(MUX_RST_WAIT_MS); - if (self->_pull_high(self) < 0) { - SWPS_ERR("%s: _pull_high fail!\n", __func__); - return -1; - } - mdelay(MUX_RST_WAIT_MS); - return 0; -} - - -int -common_reset_mux_all(struct mux_obj_s *self){ - SWPS_ERR("%s: not ready!\n", __func__); - return -1; -} - - -int -init_gpio_4_force(struct mux_obj_s *self){ - return 0; -} - - -int -init_gpio_4_normal(struct mux_obj_s *self){ - - int err = 0; - - if (!gpio_is_valid(self->gpio_num)) { - SWPS_ERR("%s: GIPO:%d isn't valid\n", __func__, self->gpio_num); - return -1; - } - err = gpio_request(self->gpio_num, MUX_GPIO_LABEL); - if (err < 0) { - SWPS_ERR("%s: gpio_request fail :%d :%d\n", - __func__, err, self->gpio_num); - return -1; - } - SWPS_DEBUG("%s: gpio_request:%d ok.\n", __func__, self->gpio_num); - return 0; -} - - -static int -_setup_muxctl_cb(struct mux_obj_s *self, - unsigned gpio){ - - char mod_dsc[32] = "ERR"; - - switch (gpio) { - case MUX_RST_GPIO_FORCE_RANGELEY: - self->gpio_num = gpio; - self->_pull_low = rangeley_force_pull_low; - self->_pull_high = rangeley_force_pull_high; - self->_init = init_gpio_4_force; - self->reset = pca9548_reset_mux_all; - memset(mod_dsc, 0, 32); - snprintf(mod_dsc, 31, "Rangeley force mode"); - goto ok_setup_muxctl_cb; - - case MUX_RST_GPIO_FORCE_HEDERA: - self->gpio_num = gpio; - self->_pull_low = hedera_force_pull_low; - self->_pull_high = hedera_force_pull_high; - self->_init = init_gpio_4_force; - self->reset = pca9548_reset_mux_all; - memset(mod_dsc, 0, 32); - snprintf(mod_dsc, 31, "Hedera force mode"); - goto ok_setup_muxctl_cb; - - case MUX_RST_GPIO_48_PAC9548: - case MUX_RST_GPIO_69_PAC9548: - case MUX_RST_GPIO_249_PCA9548: - case MUX_RST_GPIO_500_PAC9548: - case MUX_RST_GPIO_505_PCA9548: - self->gpio_num = gpio; - self->_pull_low = normal_gpio_pull_low; - self->_pull_high = normal_gpio_pull_high; - self->_init = init_gpio_4_normal; - self->reset = pca9548_reset_mux_all; - memset(mod_dsc, 0, 32); - snprintf(mod_dsc, 31, "Normal mode :%d", (int)gpio); - goto ok_setup_muxctl_cb; - - default: - break; - } - SWPS_ERR("%s: Unexpected GPIO:%d\n", __func__, gpio); - return -1; - -ok_setup_muxctl_cb: - SWPS_INFO("muxctl: %s.\n", mod_dsc); - return 0; -} - - -/* ========== MUX public functions ========== - */ -void -clean_mux_gpio(void){ - - if (!mux_head_p) { - SWPS_DEBUG("%s: mux_head_p is NULL\n", __func__); - return; - } - if (gpio_is_valid(mux_head_p->gpio_num)) { - gpio_free(mux_head_p->gpio_num); - } - kfree(mux_head_p); - mux_head_p = NULL; - SWPS_DEBUG("%s: done.\n", __func__); -} - - -int -reset_mux_gpio(void){ - - if (!mux_head_p) { - SWPS_ERR("%s: MUX ctl object doesn't exist!\n", __func__); - return -1; - } - if (mux_head_p->reset(mux_head_p) < 0){ - SWPS_ERR("%s: reset fail!\n", __func__); - return -1; - } - return 0; -} - - -int -init_mux_gpio(unsigned gpio){ - - /* Create MUX control object */ - if (mux_head_p) { - SWPS_DEBUG("%s: mux_head_p is not NULL!\n", __func__); - clean_mux_gpio(); - } - /* Currently, it is using single muxctl architecture. - * In the future, it may use the multi-muxctl if HW add new features. - * (Ex: Port power-status control) - */ - mux_head_p = kzalloc(sizeof(struct mux_obj_s), GFP_KERNEL); - if (!mux_head_p) { - SWPS_ERR("%s: kzalloc fail!\n", __func__); - return -1; - } - /* Initial MUX controller */ - if (_setup_muxctl_cb(mux_head_p, gpio) < 0){ - SWPS_ERR("%s: _setup_muxctl_cb fail!\n", __func__); - return -1; - } - if (mux_head_p->_init(mux_head_p) < 0) { - SWPS_ERR("%s: init() fail\n", __func__); - goto err_init_mux_gpio; - } - /* Setup default value */ - if (mux_head_p->_pull_high(mux_head_p) < 0) { - SWPS_ERR("%s: setup default fail!\n", __func__); - goto err_init_mux_gpio; - } - return 0; - -err_init_mux_gpio: - clean_mux_gpio(); - return -1; -} - - - - - diff --git a/packages/platforms/inventec/x86-64/d5052/modules/builds/src/inv_mux.h b/packages/platforms/inventec/x86-64/d5052/modules/builds/src/inv_mux.h deleted file mode 100644 index ebed04445..000000000 --- a/packages/platforms/inventec/x86-64/d5052/modules/builds/src/inv_mux.h +++ /dev/null @@ -1,40 +0,0 @@ -#ifndef INV_MUX_H -#define INV_MUX_H - - -/* MUX basic information */ -#define MUX_GPIO_LABEL "SWPS_RST_MUX" - -/* MUX reset GPIO define */ -#define MUX_RST_GPIO_FORCE (30100) -#define MUX_RST_GPIO_FORCE_RANGELEY (30101) -#define MUX_RST_GPIO_FORCE_HEDERA (30102) -#define MUX_RST_GPIO_48_PAC9548 (48) -#define MUX_RST_GPIO_69_PAC9548 (69) -#define MUX_RST_GPIO_249_PCA9548 (249) -#define MUX_RST_GPIO_500_PAC9548 (500) -#define MUX_RST_GPIO_505_PCA9548 (505) - -/* MUX relate value define */ -#define MUX_RST_WAIT_MS (1) -#define MUX_RST_MEM_ADDR_RANGELEY (0) // TBD -#define MUX_RST_MEM_ADDR_HEDERA (0x548) - -struct mux_obj_s { - unsigned gpio_num; - int (*_pull_high)(struct mux_obj_s *self); - int (*_pull_low)(struct mux_obj_s *self); - int (*_init)(struct mux_obj_s *self); - int (*reset)(struct mux_obj_s *self); -}; - - -void clean_mux_gpio(void); -int reset_mux_gpio(void); -int init_mux_gpio(unsigned gpio); - - -#endif /* INV_MUX_H */ - - - diff --git a/packages/platforms/inventec/x86-64/d5052/modules/builds/src/inv_platform.c b/packages/platforms/inventec/x86-64/d5052/modules/builds/src/inv_platform.c deleted file mode 100644 index 84479c78b..000000000 --- a/packages/platforms/inventec/x86-64/d5052/modules/builds/src/inv_platform.c +++ /dev/null @@ -1,128 +0,0 @@ -#include -//#include -#include -#include -#include -#include -#include - -#include -#include -#include - -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_data mux_data_0 = { - .modes = mux_modes_0, - .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 inv_i2c_board_info i2cdev_list[] = { - {0, ARRAY_SIZE(i2c_device_info0), i2c_device_info0 }, //smbus 0 -}; - -#if 0 -static struct i2c_gpio_platform_data i2c_gpio_platdata = { - .scl_pin = 460,//8, - .sda_pin = 461,//9, - - .udelay = 5, //5:100kHz - .timeout = 100, - .sda_is_open_drain = 0, - .scl_is_open_drain = 0, - .scl_is_output_only = 0 -}; - -static struct platform_device inventec_device_i2c_gpio = { - .name = "i2c-gpio", - .id = 0, // adapter number - .dev.platform_data = &i2c_gpio_platdata, -}; -#else -static struct i2c_gpio_platform_data i2c_gpio_platdata2 = { - .scl_pin = 464,//12+452, - .sda_pin = 463,//11+452, - - .udelay = 5, //5:100kHz - .timeout = 100, - .sda_is_open_drain = 0, - .scl_is_open_drain = 0, - .scl_is_output_only = 0 -}; - -static struct platform_device inventec_device_i2c_gpio2 = { - .name = "i2c-gpio", - .id = 1, // adapter number - .dev.platform_data = &i2c_gpio_platdata2, -}; -#endif - -static int __init plat_inventec_init(void) -{ - struct i2c_adapter *adap = NULL; - struct i2c_client *e = NULL; - int ret = 0; - int i,j; - - //use i2c-gpio - //register i2c gpio - //config gpio8,9 gpio12,11 to gpio function -#if 0 - outl( inl(0x500) | (1<<8 | 1<<9 ), 0x500); - - ret = platform_device_register(&inventec_device_i2c_gpio); - if (ret) { - printk(KERN_ERR "i2c-gpio: device_i2c_gpio register fail %d\n", ret); - } - else { - printk(KERN_INFO "i2c-gpio: i2c-0 Success.\n"); - } -#endif - outl( inl(0x500) | (1<<11 | 1<<12), 0x500); - ret = platform_device_register(&inventec_device_i2c_gpio2); - if (ret) { - printk(KERN_ERR "i2c-gpio: device_i2c_gpio2 register fail %d\n", ret); - } - else { - printk(KERN_INFO "i2c-gpio: i2c-1 Success.\n"); - } - for(i=0; i -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -//#include "I2CHostCommunication.h" -#include -#include -#include -#include -#define SWITCH_TEMPERATURE_SOCK "/proc/switch/temp" - -#define USE_SMBUS 1 - -#define FAN_NUM 4 -#define PSU_NUM 2 - -static struct device *psoc_led_client_dev = NULL; - -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; - - u8 psu1_vendor[16]; - u8 psu2_vendor[16]; - u8 psu1_model[20]; - u8 psu2_model[20]; - u8 psu1_version[8]; - u8 psu2_version[8]; - u8 psu1_date[6]; - u8 psu2_date[6]; - u8 psu1_sn[20]; - u8 psu2_sn[20]; -}; - -struct clei{ - u8 issue_number[3]; - u8 abbreviation_number[9]; - u8 fc_number[10]; - u8 clei_code[10]; - u8 product_year_and_month[5]; - u8 label_location_code[2]; - u8 serial_number[5]; - u8 pcb_revision[5]; - u8 reserved[15]; -}; - -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 - u8 reserved[0xff-0xfd]; - - struct clei clei[6]; //FAN:0~3 PSU:4~5; -}; - -/* 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) - -#define CLEI_OFF(m) offsetof(struct clei, m) -#define FAN1_CLEI_INDEX 0 -#define FAN2_CLEI_INDEX 1 -#define FAN3_CLEI_INDEX 2 -#define FAN4_CLEI_INDEX 3 -#define PSU1_CLEI_INDEX 4 -#define PSU2_CLEI_INDEX 5 -#define ISSUENUMBER_INDEX 0 -#define ABBREVIATION_INDEX 1 -#define FCNUMBER_INDEX 2 -#define CLEICODE_INDEX 3 -#define PRODUCTDATE_INDEX 4 -#define LABELLOCATION_INDX 5 -#define SERIALNUMBER_INDEX 6 -#define PCBREVISION_INDEX 7 - -/* Each client has this additional data */ -struct psoc_data { - struct device *hwmon_dev; - struct mutex update_lock; - u32 diag; - struct task_struct *auto_update; -}; - -/*-----------------------------------------------------------------------*/ - -static ssize_t psoc_i2c_read(struct i2c_client *client, u8 *buf, u16 offset, size_t count) -{ -#if USE_SMBUS - int i; - for(i=0; i> 8), ((offset+i) & 0xff)); - buf[i] = i2c_smbus_read_byte(client); - } - - return count; -#else - struct i2c_msg msg[2]; - char msgbuf[2]; - int status; - - memset(msg, 0, sizeof(msg)); - - msgbuf[0] = offset >> 8 ; - msgbuf[1] = offset & 0xff; - - msg[0].addr = client->addr; - msg[0].buf = msgbuf; - msg[0].len = 2; - - 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, u16 offset, size_t count) -{ -#if USE_SMBUS - int i; - - for(i=0; i> 8), ((offset+i) & 0xff) | (buf[i] << 8)); - } - return count; -#else - struct i2c_msg msg; - int status; - u8 writebuf[256]; - - int i = 0; - - msg.addr = client->addr; - msg.flags = 0; - - /* msg.buf is u8 and casts will mask the values */ - msg.buf = writebuf; - - msg.buf[i++] = offset >> 8; - msg.buf[i++] = offset & 0xff; - 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, u16 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, u16 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) -#if 0 -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 | PSOC_PMB_SEL; /* the start bit for the PM bus */ - 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; -} -#endif -static ssize_t show_clei(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 device_index = attr->index & 0xFF; - u8 clei_index = (attr->index >> 8) & 0xFF; - u16 offset = PSOC_OFF(clei) + sizeof(struct clei)* device_index; - u8 len; - u8 rxbuf[21] = {0}; - u8 rxbuf1[21] = {0}; - u8 counter = 0; - - switch (clei_index) - { - case ISSUENUMBER_INDEX: - offset += CLEI_OFF(issue_number); - len = sizeof((struct clei){0}.issue_number); - break; - case ABBREVIATION_INDEX: - offset += CLEI_OFF(abbreviation_number); - len = sizeof((struct clei){0}.abbreviation_number); - break; - case FCNUMBER_INDEX: - offset += CLEI_OFF(fc_number); - len = sizeof((struct clei){0}.fc_number); - break; - case CLEICODE_INDEX: - offset += CLEI_OFF(clei_code); - len = sizeof((struct clei){0}.clei_code); - break; - case PRODUCTDATE_INDEX: - offset += CLEI_OFF(product_year_and_month); - len = sizeof((struct clei){0}.product_year_and_month); - break; - case LABELLOCATION_INDX: - offset += CLEI_OFF(label_location_code); - len = sizeof((struct clei){0}.label_location_code); - break; - case SERIALNUMBER_INDEX: - offset += CLEI_OFF(serial_number); - len = sizeof((struct clei){0}.serial_number); - break; - case PCBREVISION_INDEX: - offset += CLEI_OFF(pcb_revision); - len = sizeof((struct clei){0}.pcb_revision); - break; - default: - return 0; - } - - do - { - mutex_lock(&data->update_lock); - status = psoc_i2c_read(client,rxbuf,offset,len); - mutex_unlock(&data->update_lock); - - mutex_lock(&data->update_lock); - status = psoc_i2c_read(client,rxbuf1,offset,len); - mutex_unlock(&data->update_lock); - - counter++; - }while((strcmp(rxbuf,rxbuf1)!=0) || ((strlen(rxbuf)==0) && (counter <5))); - - //return sprintf(buf, "show_clei: offset:%d len:%d \n",offset,len); - - if(rxbuf[0]==0x00 || rxbuf[0]==0xFF) return 0; - - return sprintf(buf, "%s \n",rxbuf); -} - - -/* -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); -} - -static ssize_t psoc_show_psu_st(char *buf, int psu_index) -{ - u32 status; - struct i2c_client *client = NULL; - struct psoc_data *data = NULL; - u8 byte; - int shift = (psu_index == 0)?3:0; - - if (!psoc_led_client_dev) { - return 0; - } - - client = to_i2c_client(psoc_led_client_dev); - data = i2c_get_clientdata(client); - - 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); -} - -ssize_t psoc_show_psu_state(char *buf, int index) -{ - return psoc_show_psu_st(buf, index); -} -EXPORT_SYMBOL(psoc_show_psu_state); - -/*-----------------------------------------------------------------------*/ - -/* 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); - u16 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 psoc_show_rpm(char *buf, int fan_index) -{ - int status; - struct i2c_client *client = NULL; - struct psoc_data *data = NULL; - u8 offset = fan_index*2 + RPM_OFFSET; - - if (!psoc_led_client_dev) { - return 0; - } - - client = to_i2c_client(psoc_led_client_dev); - data = i2c_get_clientdata(client); - - mutex_lock(&data->update_lock); - status = psoc_read16(client, offset); - mutex_unlock(&data->update_lock); - - return sprintf(buf, "%d\n", - status); -} - -ssize_t psoc_show_fan_input(char *buf, int index) -{ - return psoc_show_rpm(buf, index); -} -EXPORT_SYMBOL(psoc_show_fan_input); - -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; -} - -ssize_t psoc_show_diag(char *buf) -{ - u16 status; - struct i2c_client *client = NULL; - struct psoc_data *data = NULL; - u8 diag_flag = 0; - - if (!psoc_led_client_dev) { - return 0; - } - - client = to_i2c_client(psoc_led_client_dev); - data = i2c_get_clientdata(client); - - 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); -} -EXPORT_SYMBOL(psoc_show_diag); - -ssize_t psoc_set_diag(const char *buf, size_t count) -{ - struct i2c_client *client = NULL; - struct psoc_data *data = NULL; - u8 value = 0; - u8 diag = simple_strtol(buf, NULL, 10); - - if (!psoc_led_client_dev) { - return 0; - } - - client = to_i2c_client(psoc_led_client_dev); - data = i2c_get_clientdata(client); - - 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; -} -EXPORT_SYMBOL(psoc_set_diag); - -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 ); -} - -ssize_t psoc_show_value8(char *buf, int offset) -{ - int status; - struct i2c_client *client = NULL; - struct psoc_data *data = NULL; - - if (!psoc_led_client_dev) { - return 0; - } - - client = to_i2c_client(psoc_led_client_dev); - data = i2c_get_clientdata(client); - - mutex_lock(&data->update_lock); - status = psoc_read8(client, offset); - mutex_unlock(&data->update_lock); - - return sprintf(buf, "0x%02X\n", status ); -} - -static char prev_fan_state[8] = { 0 }; - -ssize_t psoc_show_fan_state(char *buf) -{ - int i; - int rv = psoc_show_value8(buf, FAN_GPI_OFFSET); - for (i = 0; i < 2; i++) { - if (strncmp(prev_fan_state, buf, 4) == 0) { - return rv; - } - msleep(50); - rv = psoc_show_value8(buf, FAN_GPI_OFFSET); - } - strcpy(prev_fan_state, buf); - return rv; -} -EXPORT_SYMBOL(psoc_show_fan_state); - -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; -} - -#if 0 -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 chip = (attr->index >> 16)? 0x59:0x58; - u8 bus = 1; - unsigned char value[2] = {0,0};; - - 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) ); -} -#endif - -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 & 0xFF) + PSU_INFO_OFFSET; - u8 len = (attr->index >> 8)& 0xFF; - u8 rxbuf[21] = {0}; - u8 rxbuf1[21] = {0}; - u8 counter = 0; - u8 count = 0; - u8 index = 0; - if (len == 2) - { - 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 )); - } - else - { - do - { - mutex_lock(&data->update_lock); - status = psoc_i2c_read(client,rxbuf,offset,len); - mutex_unlock(&data->update_lock); - mutex_lock(&data->update_lock); - status = psoc_i2c_read(client,rxbuf1,offset,len); - mutex_unlock(&data->update_lock); - counter++; - }while((strcmp(rxbuf,rxbuf1)!=0) || ((strlen(rxbuf)==0) && (counter <5))); - for(index = 0; index < len; index++) - { - if(rxbuf[index] == 0xFF) - count++; - } - if(len == count) - return sprintf(buf, "%s \n","NA"); - if(status ==0) - return sprintf(buf,"%s \n", "NA"); - else if((strlen(rxbuf)==0)) - return sprintf(buf, "%s \n", "N/A"); - else - return sprintf(buf, "%s \n",rxbuf); - } -} - -static ssize_t psoc_show_psu_psoc(char *buf, int psu_index, char *attr_name) -{ - u16 status; - struct i2c_client *client = NULL; - struct psoc_data *data = NULL; - u8 offset = psu_index + PSU_INFO_OFFSET; - - if (!psoc_led_client_dev) { - return 0; - } - - client = to_i2c_client(psoc_led_client_dev); - data = i2c_get_clientdata(client); - - 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_name, "vout")? 1:0 )); -} - -ssize_t psoc_show_psu_vin(char *buf, int index) -{ - return psoc_show_psu_psoc(buf, index, "vin"); -} -EXPORT_SYMBOL(psoc_show_psu_vin); - -#define PSOC_POLLING_PERIOD 1000 -#define PSU_NOT_INSTALLED 7 -#define PSOC_WARNING(fmt, args...) printk( KERN_WARNING "[PSOC]" fmt, ##args) -static u8 psu_info[PSU_NUM]; -static u8 fan_info[FAN_NUM]; -static void get_init_psu_fan_status(struct i2c_client *client) -{ - struct psoc_data *data = i2c_get_clientdata(client); - u32 status = 0; - u8 byte = 0; - int i = 0; - mutex_lock(&data->update_lock); - status = psoc_i2c_read(client, &byte, PSOC_PSU_OFFSET,1); - mutex_unlock(&data->update_lock); - psu_info[0] = (byte >> 3) & 0x7; - psu_info[1] = (byte >> 0) & 0x7; - mutex_lock(&data->update_lock); - status = psoc_read8(client, FAN_GPI_OFFSET); - mutex_unlock(&data->update_lock); - for (i=0; i<2 ; i++) - { - fan_info[i] = ((status >> i) & 0x01); - } -} - -static void check_fan_status(struct i2c_client *client) -{ - struct psoc_data *data = i2c_get_clientdata(client); - u32 status; - int i = 0; - u8 rst = 0; - mutex_lock(&data->update_lock); - status = psoc_read8(client, FAN_GPI_OFFSET); - mutex_unlock(&data->update_lock); - for (i = 0; i < FAN_NUM; i++) - { - rst = ((status >> i) & 0x01); - if(rst != fan_info[i]) - { - fan_info[i] = rst; - if (rst) - PSOC_WARNING("Detect FAN%d is removed \n",(i+1)); - else - PSOC_WARNING("Detect FAN%d is present \n",(i+1)); - } - } -} -#if 0 -// [Remove] Bacuase cottonwood don't have PSU info -static void check_psu_status(struct i2c_client *client) -{ - static u8 psu_retry[]={0,0}; - struct psoc_data *data = i2c_get_clientdata(client); - u32 status; - u8 byte = 0; - u8 psu1, psu2; - mutex_lock(&data->update_lock); - status = psoc_i2c_read(client, &byte, PSOC_PSU_OFFSET, 1); - mutex_unlock(&data->update_lock); - psu1 = (byte >> 3) & 0x7; - psu2 = (byte >> 0) & 0x7; - if(psu1 != psu_info[0]) - { - if ((psu_retry[0]++)==0) { return; } - if (psu1 == PSU_NOT_INSTALLED) - PSOC_WARNING("Detect PSU1 is removed \n"); - else - PSOC_WARNING("Detect PSU1 is present \n"); - - psu_info[0] = psu1; - psu_retry[0] = 0; - } - if(psu2 != psu_info[1]) - { - if((psu_retry[1]++)==0) { return; } - if(psu2 == PSU_NOT_INSTALLED) - PSOC_WARNING("Detect PSU2 is removed \n"); - else - PSOC_WARNING("Detect PSU2 is present \n"); - - psu_info[1] = psu2; - psu_retry[1] = 0; - } -} -#endif -static void check_switch_temp(struct i2c_client * client) -{ - struct psoc_data *data = i2c_get_clientdata(client); - static struct file *f; - mm_segment_t old_fs; - - set_fs(get_ds()); - f = filp_open(SWITCH_TEMPERATURE_SOCK,O_RDONLY,0644); - if(IS_ERR(f)) { - return; - } - else { - char temp_str[]={0,0,0,0,0,0,0}; - loff_t pos = 0; - u16 temp2 = 0; - old_fs = get_fs(); - set_fs(KERNEL_DS); - vfs_read(f, temp_str,6,&pos); - temp2 = ((simple_strtoul(temp_str,NULL,10)/1000) <<8 ) & 0xFF00 ; - mutex_lock(&data->update_lock); - psoc_i2c_write(client, (u8*)&temp2, SWITCH_TMP_OFFSET, 2); - mutex_unlock(&data->update_lock); - } - filp_close(f,NULL); - set_fs(old_fs); -} - - -static int psoc_polling_thread(void *p) -{ - struct i2c_client *client = p; - get_init_psu_fan_status(client); - while (!kthread_should_stop()) - { -// check_psu_status(client); -// check_fan_status(client); - check_switch_temp(client); - set_current_state(TASK_INTERRUPTIBLE); - if(kthread_should_stop()) - break; - - schedule_timeout(msecs_to_jiffies(PSOC_POLLING_PERIOD)); - } - return 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); - -//CLEI -static SENSOR_DEVICE_ATTR(fan1_issue_number, S_IRUGO, show_clei, 0, FAN1_CLEI_INDEX | ISSUENUMBER_INDEX << 8 ); -static SENSOR_DEVICE_ATTR(fan2_issue_number, S_IRUGO, show_clei, 0, FAN2_CLEI_INDEX | ISSUENUMBER_INDEX << 8 ); -static SENSOR_DEVICE_ATTR(fan3_issue_number, S_IRUGO, show_clei, 0, FAN3_CLEI_INDEX | ISSUENUMBER_INDEX << 8 ); -static SENSOR_DEVICE_ATTR(fan4_issue_number, S_IRUGO, show_clei, 0, FAN4_CLEI_INDEX | ISSUENUMBER_INDEX << 8 ); -static SENSOR_DEVICE_ATTR(fan1_abbreviation_number, S_IRUGO, show_clei, 0, FAN1_CLEI_INDEX | ABBREVIATION_INDEX << 8 ); -static SENSOR_DEVICE_ATTR(fan2_abbreviation_number, S_IRUGO, show_clei, 0, FAN2_CLEI_INDEX | ABBREVIATION_INDEX << 8 ); -static SENSOR_DEVICE_ATTR(fan3_abbreviation_number, S_IRUGO, show_clei, 0, FAN3_CLEI_INDEX | ABBREVIATION_INDEX << 8 ); -static SENSOR_DEVICE_ATTR(fan4_abbreviation_number, S_IRUGO, show_clei, 0, FAN4_CLEI_INDEX | ABBREVIATION_INDEX << 8 ); -static SENSOR_DEVICE_ATTR(fan1_fc_number, S_IRUGO, show_clei, 0, FAN1_CLEI_INDEX | FCNUMBER_INDEX << 8 ); -static SENSOR_DEVICE_ATTR(fan2_fc_number, S_IRUGO, show_clei, 0, FAN2_CLEI_INDEX | FCNUMBER_INDEX << 8 ); -static SENSOR_DEVICE_ATTR(fan3_fc_number, S_IRUGO, show_clei, 0, FAN3_CLEI_INDEX | FCNUMBER_INDEX << 8 ); -static SENSOR_DEVICE_ATTR(fan4_fc_number, S_IRUGO, show_clei, 0, FAN4_CLEI_INDEX | FCNUMBER_INDEX << 8 ); -static SENSOR_DEVICE_ATTR(fan1_clei_code, S_IRUGO, show_clei, 0, FAN1_CLEI_INDEX | CLEICODE_INDEX << 8 ); -static SENSOR_DEVICE_ATTR(fan2_clei_code, S_IRUGO, show_clei, 0, FAN2_CLEI_INDEX | CLEICODE_INDEX << 8 ); -static SENSOR_DEVICE_ATTR(fan3_clei_code, S_IRUGO, show_clei, 0, FAN3_CLEI_INDEX | CLEICODE_INDEX << 8 ); -static SENSOR_DEVICE_ATTR(fan4_clei_code, S_IRUGO, show_clei, 0, FAN4_CLEI_INDEX | CLEICODE_INDEX << 8 ); -static SENSOR_DEVICE_ATTR(fan1_product_year_and_month, S_IRUGO, show_clei, 0, FAN1_CLEI_INDEX | PRODUCTDATE_INDEX << 8 ); -static SENSOR_DEVICE_ATTR(fan2_product_year_and_month, S_IRUGO, show_clei, 0, FAN2_CLEI_INDEX | PRODUCTDATE_INDEX << 8 ); -static SENSOR_DEVICE_ATTR(fan3_product_year_and_month, S_IRUGO, show_clei, 0, FAN3_CLEI_INDEX | PRODUCTDATE_INDEX << 8 ); -static SENSOR_DEVICE_ATTR(fan4_product_year_and_month, S_IRUGO, show_clei, 0, FAN4_CLEI_INDEX | PRODUCTDATE_INDEX << 8 ); -static SENSOR_DEVICE_ATTR(fan1_label_location_code, S_IRUGO, show_clei, 0, FAN1_CLEI_INDEX | LABELLOCATION_INDX << 8 ); -static SENSOR_DEVICE_ATTR(fan2_label_location_code, S_IRUGO, show_clei, 0, FAN2_CLEI_INDEX | LABELLOCATION_INDX << 8 ); -static SENSOR_DEVICE_ATTR(fan3_label_location_code, S_IRUGO, show_clei, 0, FAN3_CLEI_INDEX | LABELLOCATION_INDX << 8 ); -static SENSOR_DEVICE_ATTR(fan4_label_location_code, S_IRUGO, show_clei, 0, FAN4_CLEI_INDEX | LABELLOCATION_INDX << 8 ); -static SENSOR_DEVICE_ATTR(fan1_serial_number, S_IRUGO, show_clei, 0, FAN1_CLEI_INDEX | SERIALNUMBER_INDEX << 8 ); -static SENSOR_DEVICE_ATTR(fan2_serial_number, S_IRUGO, show_clei, 0, FAN2_CLEI_INDEX | SERIALNUMBER_INDEX << 8 ); -static SENSOR_DEVICE_ATTR(fan3_serial_number, S_IRUGO, show_clei, 0, FAN3_CLEI_INDEX | SERIALNUMBER_INDEX << 8 ); -static SENSOR_DEVICE_ATTR(fan4_serial_number, S_IRUGO, show_clei, 0, FAN4_CLEI_INDEX | SERIALNUMBER_INDEX << 8 ); -static SENSOR_DEVICE_ATTR(fan1_pcb_revision, S_IRUGO, show_clei, 0, FAN1_CLEI_INDEX | PCBREVISION_INDEX << 8 ); -static SENSOR_DEVICE_ATTR(fan2_pcb_revision, S_IRUGO, show_clei, 0, FAN2_CLEI_INDEX | PCBREVISION_INDEX << 8 ); -static SENSOR_DEVICE_ATTR(fan3_pcb_revision, S_IRUGO, show_clei, 0, FAN3_CLEI_INDEX | PCBREVISION_INDEX << 8 ); -static SENSOR_DEVICE_ATTR(fan4_pcb_revision, S_IRUGO, show_clei, 0, FAN4_CLEI_INDEX | PCBREVISION_INDEX << 8 ); - -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(fan1_led_grn, S_IWUSR|S_IRUGO, show_fan_led, set_fan_led, 0); -static SENSOR_DEVICE_ATTR(fan2_led_grn, S_IWUSR|S_IRUGO, show_fan_led, set_fan_led, 1); -static SENSOR_DEVICE_ATTR(fan3_led_grn, S_IWUSR|S_IRUGO, show_fan_led, set_fan_led, 2); -static SENSOR_DEVICE_ATTR(fan4_led_grn, S_IWUSR|S_IRUGO, show_fan_led, set_fan_led, 3); -static SENSOR_DEVICE_ATTR(fan1_led_red, S_IWUSR|S_IRUGO, show_fan_led, set_fan_led, 4); -static SENSOR_DEVICE_ATTR(fan2_led_red, S_IWUSR|S_IRUGO, show_fan_led, set_fan_led, 5); -static SENSOR_DEVICE_ATTR(fan3_led_red, S_IWUSR|S_IRUGO, show_fan_led, set_fan_led, 6); -static SENSOR_DEVICE_ATTR(fan4_led_red, 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); -#if 0 -static SENSOR_DEVICE_ATTR(psu1_vin, S_IRUGO, show_psu, 0, PMBUS_READ_VIN); -static SENSOR_DEVICE_ATTR(psu1_vout, S_IRUGO, show_psu, 0, PMBUS_READ_VOUT); -static SENSOR_DEVICE_ATTR(psu1_iin, S_IRUGO, show_psu, 0, PMBUS_READ_IIN); -static SENSOR_DEVICE_ATTR(psu1_iout, S_IRUGO, show_psu, 0, PMBUS_READ_IOUT); -static SENSOR_DEVICE_ATTR(psu1_pin, S_IRUGO, show_psu, 0, PMBUS_READ_PIN); -static SENSOR_DEVICE_ATTR(psu1_pout, S_IRUGO, show_psu, 0, PMBUS_READ_POUT); - - -static SENSOR_DEVICE_ATTR(psu2_vin, S_IRUGO, show_psu, 0, (1<<16) | PMBUS_READ_VIN); -static SENSOR_DEVICE_ATTR(psu2_vout, S_IRUGO, show_psu, 0, (1<<16) | PMBUS_READ_VOUT); -static SENSOR_DEVICE_ATTR(psu2_iin, S_IRUGO, show_psu, 0, (1<<16) | PMBUS_READ_IIN); -static SENSOR_DEVICE_ATTR(psu2_iout, S_IRUGO, show_psu, 0, (1<<16) | PMBUS_READ_IOUT); -static SENSOR_DEVICE_ATTR(psu2_pin, S_IRUGO, show_psu, 0, (1<<16) | PMBUS_READ_PIN); -static SENSOR_DEVICE_ATTR(psu2_pout, S_IRUGO, show_psu, 0, (1<<16) | PMBUS_READ_POUT); -#endif - -static SENSOR_DEVICE_ATTR(psoc_psu1_vin, S_IRUGO, show_psu_psoc, 0, (0x02<<8)|PSOC_PSU_OFF(psu1_vin)); -static SENSOR_DEVICE_ATTR(psoc_psu1_vout, S_IRUGO, show_psu_psoc, 0, (0x02<<8)|PSOC_PSU_OFF(psu1_vout)); -static SENSOR_DEVICE_ATTR(psoc_psu1_iin, S_IRUGO, show_psu_psoc, 0, (0x02<<8)|PSOC_PSU_OFF(psu1_iin)); -static SENSOR_DEVICE_ATTR(psoc_psu1_iout, S_IRUGO, show_psu_psoc, 0, (0x02<<8)|PSOC_PSU_OFF(psu1_iout)); -static SENSOR_DEVICE_ATTR(psoc_psu1_pin, S_IRUGO, show_psu_psoc, 0, (0x02<<8)|PSOC_PSU_OFF(psu1_pin)); -static SENSOR_DEVICE_ATTR(psoc_psu1_pout, S_IRUGO, show_psu_psoc, 0, (0x02<<8)|PSOC_PSU_OFF(psu1_pout)); - - -static SENSOR_DEVICE_ATTR(psoc_psu2_vin, S_IRUGO, show_psu_psoc, 0, (0x02<<8)|PSOC_PSU_OFF(psu2_vin)); -static SENSOR_DEVICE_ATTR(psoc_psu2_vout, S_IRUGO, show_psu_psoc, 0, (0x02<<8)|PSOC_PSU_OFF(psu2_vout)); -static SENSOR_DEVICE_ATTR(psoc_psu2_iin, S_IRUGO, show_psu_psoc, 0, (0x02<<8)|PSOC_PSU_OFF(psu2_iin)); -static SENSOR_DEVICE_ATTR(psoc_psu2_iout, S_IRUGO, show_psu_psoc, 0, (0x02<<8)|PSOC_PSU_OFF(psu2_iout)); -static SENSOR_DEVICE_ATTR(psoc_psu2_pin, S_IRUGO, show_psu_psoc, 0, (0x02<<8)|PSOC_PSU_OFF(psu2_pin)); -static SENSOR_DEVICE_ATTR(psoc_psu2_pout, S_IRUGO, show_psu_psoc, 0, (0x02<<8)|PSOC_PSU_OFF(psu2_pout)); - -static SENSOR_DEVICE_ATTR(psoc_psu1_vendor, S_IRUGO, show_psu_psoc, 0, (0x10<<8)|PSOC_PSU_OFF(psu1_vendor)); -static SENSOR_DEVICE_ATTR(psoc_psu1_model, S_IRUGO, show_psu_psoc, 0, (0x14<<8)|PSOC_PSU_OFF(psu1_model)); -static SENSOR_DEVICE_ATTR(psoc_psu1_version, S_IRUGO, show_psu_psoc, 0, (0x08<<8)|PSOC_PSU_OFF(psu1_version)); -static SENSOR_DEVICE_ATTR(psoc_psu1_date, S_IRUGO, show_psu_psoc, 0, (0x06<<8)|PSOC_PSU_OFF(psu1_date)); -static SENSOR_DEVICE_ATTR(psoc_psu1_sn, S_IRUGO, show_psu_psoc, 0, (0x14<<8)|PSOC_PSU_OFF(psu1_sn)); -static SENSOR_DEVICE_ATTR(psoc_psu2_vendor, S_IRUGO, show_psu_psoc, 0, (0x10<<8)|PSOC_PSU_OFF(psu2_vendor)); -static SENSOR_DEVICE_ATTR(psoc_psu2_model, S_IRUGO, show_psu_psoc, 0, (0x14<<8)|PSOC_PSU_OFF(psu2_model)); -static SENSOR_DEVICE_ATTR(psoc_psu2_version, S_IRUGO, show_psu_psoc, 0, (0x08<<8)|PSOC_PSU_OFF(psu2_version)); -static SENSOR_DEVICE_ATTR(psoc_psu2_date, S_IRUGO, show_psu_psoc, 0, (0x06<<8)|PSOC_PSU_OFF(psu2_date)); -static SENSOR_DEVICE_ATTR(psoc_psu2_sn, S_IRUGO, show_psu_psoc, 0, (0x14<<8)|PSOC_PSU_OFF(psu2_sn)); - -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, - - //clei - &sensor_dev_attr_fan1_issue_number.dev_attr.attr, - &sensor_dev_attr_fan2_issue_number.dev_attr.attr, - &sensor_dev_attr_fan3_issue_number.dev_attr.attr, - &sensor_dev_attr_fan4_issue_number.dev_attr.attr, - &sensor_dev_attr_fan1_abbreviation_number.dev_attr.attr, - &sensor_dev_attr_fan2_abbreviation_number.dev_attr.attr, - &sensor_dev_attr_fan3_abbreviation_number.dev_attr.attr, - &sensor_dev_attr_fan4_abbreviation_number.dev_attr.attr, - &sensor_dev_attr_fan1_fc_number.dev_attr.attr, - &sensor_dev_attr_fan2_fc_number.dev_attr.attr, - &sensor_dev_attr_fan3_fc_number.dev_attr.attr, - &sensor_dev_attr_fan4_fc_number.dev_attr.attr, - &sensor_dev_attr_fan1_clei_code.dev_attr.attr, - &sensor_dev_attr_fan2_clei_code.dev_attr.attr, - &sensor_dev_attr_fan3_clei_code.dev_attr.attr, - &sensor_dev_attr_fan4_clei_code.dev_attr.attr, - - &sensor_dev_attr_fan1_product_year_and_month.dev_attr.attr, - &sensor_dev_attr_fan2_product_year_and_month.dev_attr.attr, - &sensor_dev_attr_fan3_product_year_and_month.dev_attr.attr, - &sensor_dev_attr_fan4_product_year_and_month.dev_attr.attr, - &sensor_dev_attr_fan1_label_location_code.dev_attr.attr, - &sensor_dev_attr_fan2_label_location_code.dev_attr.attr, - &sensor_dev_attr_fan3_label_location_code.dev_attr.attr, - &sensor_dev_attr_fan4_label_location_code.dev_attr.attr, - &sensor_dev_attr_fan1_serial_number.dev_attr.attr, - &sensor_dev_attr_fan2_serial_number.dev_attr.attr, - &sensor_dev_attr_fan3_serial_number.dev_attr.attr, - &sensor_dev_attr_fan4_serial_number.dev_attr.attr, - &sensor_dev_attr_fan1_pcb_revision.dev_attr.attr, - &sensor_dev_attr_fan2_pcb_revision.dev_attr.attr, - &sensor_dev_attr_fan3_pcb_revision.dev_attr.attr, - &sensor_dev_attr_fan4_pcb_revision.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_fan1_led_grn.dev_attr.attr, - &sensor_dev_attr_fan2_led_grn.dev_attr.attr, - &sensor_dev_attr_fan3_led_grn.dev_attr.attr, - &sensor_dev_attr_fan4_led_grn.dev_attr.attr, - &sensor_dev_attr_fan1_led_red.dev_attr.attr, - &sensor_dev_attr_fan2_led_red.dev_attr.attr, - &sensor_dev_attr_fan3_led_red.dev_attr.attr, - &sensor_dev_attr_fan4_led_red.dev_attr.attr, - - //fan GPI - &sensor_dev_attr_fan_gpi.dev_attr.attr, - - //psu -#if 0 - &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, -#endif - &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, - - //add info - &sensor_dev_attr_psoc_psu1_vendor.dev_attr.attr, - &sensor_dev_attr_psoc_psu1_model.dev_attr.attr, - &sensor_dev_attr_psoc_psu1_version.dev_attr.attr, - &sensor_dev_attr_psoc_psu1_date.dev_attr.attr, - &sensor_dev_attr_psoc_psu1_sn.dev_attr.attr, - &sensor_dev_attr_psoc_psu2_vendor.dev_attr.attr, - &sensor_dev_attr_psoc_psu2_model.dev_attr.attr, - &sensor_dev_attr_psoc_psu2_version.dev_attr.attr, - &sensor_dev_attr_psoc_psu2_date.dev_attr.attr, - &sensor_dev_attr_psoc_psu2_sn.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; - } - data->auto_update = kthread_run(psoc_polling_thread,client,"%s",dev_name(data->hwmon_dev)); - if (IS_ERR(data->auto_update)) - { - status = PTR_ERR(data->auto_update); - goto exit_remove; - } - - dev_info(&client->dev, "%s: sensor '%s'\n", - dev_name(data->hwmon_dev), client->name); - - psoc_led_client_dev = &client->dev; - return 0; - -exit_remove: - sysfs_remove_group(&client->dev.kobj, &psoc_group); -exit_free: - i2c_set_clientdata(client, NULL); - kfree(data); - psoc_led_client_dev = NULL; - return status; -} - -static int psoc_remove(struct i2c_client *client) -{ - struct psoc_data *data = i2c_get_clientdata(client); - kthread_stop(data->auto_update); - hwmon_device_unregister(data->hwmon_dev); - sysfs_remove_group(&client->dev.kobj, &psoc_group); - i2c_set_clientdata(client, NULL); - kfree(data); - psoc_led_client_dev = NULL; - 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("Jack Ting "); -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/d5052/modules/builds/src/inv_pthread.c b/packages/platforms/inventec/x86-64/d5052/modules/builds/src/inv_pthread.c deleted file mode 100644 index 8f184ce1b..000000000 --- a/packages/platforms/inventec/x86-64/d5052/modules/builds/src/inv_pthread.c +++ /dev/null @@ -1,860 +0,0 @@ -/***************************** - Cottonwood(D5052) platform -******************************/ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "inv_pthread.h" - -#define INV_PTHREAD_KERNEL_MODULE - -#define SHOW_ATTR_WARNING ("N/A") -#define SHOW_ATTR_NOTPRINT ("Not Available") -#define SHOW_ATTR_NOTSUPPORT ("Not Support") - -#define INV_HWMID_MAX (10) -#define INV_HWMID_INIT (-1) - -/*access userspace data to kernel space*/ -#define ACC_R (0) -#define ACC_W (1) - -#define MAX_PATH_SIZE (64) -#define MIN_ACC_SIZE (32) -#define MAX_ACC_SIZE (256) - -/* - * LED definitions - */ -#define STATUS_LED_MODE_AUTO (0) -#define STATUS_LED_MODE_DIAG (1) -#define STATUS_LED_MODE_MANU (2) -#define STATUS_LED_MODE_ERR (-1) - -#define STATUS_LED_GRN0 (10) // 0 - 000: off -#define STATUS_LED_GRN1 (11) // 1 - 001: 0.5hz -#define STATUS_LED_GRN2 (12) // 2 - 010: 1 hz -#define STATUS_LED_GRN3 (13) // 3 - 011: 2 hz -#define STATUS_LED_GRN7 (17) // 7 - 111: on -#define STATUS_LED_RED0 (20) // 0 - 000: off -#define STATUS_LED_RED1 (21) // 1 - 001: 0.5hz -#define STATUS_LED_RED2 (22) // 2 - 010: 1 hz -#define STATUS_LED_RED3 (23) // 3 - 011: 2 hz -#define STATUS_LED_RED7 (27) // 7 - 111: on -#define STATUS_LED_INVALID (0) // Invalid - -static struct mutex pthread_mutex; - -ssize_t status_led_grn(const char *freq); -ssize_t status_led_red(const char *freq); -ssize_t status_led_diag_mode_enable(void); -ssize_t status_led_diag_mode_disable(void); -int status_led_check_color(void); -int status_led_check_diag_mode(void); - -#if 1 -/* For timestamps in SYSFS_LOG */ -#define SYSFS_LOG printk -#else -//#define SYSFS_LOG(fmt, args...) printk(KERN_WARNING "[SYSFS] %s/%d: " fmt, __func__, __LINE__, ##args) -#define SYSFS_LOG(fmt, args...) printk(KERN_WARNING "[p_thread] " fmt, ##args) -#endif - - -/* inventec_class *********************************/ -static struct kobject *status_kobj; -static struct kset *status_kset; - -#if 0 -int inventec_strtol(const char *sbufp, char **endp, unsigned int base) -{ - char *endptr; - int value = simple_strtol(sbufp, &endptr, base); - if (value == 0 && sbufp == endptr) { - *endp = NULL; - return value; - } - *endp = (char*)1; - return value; -} -#endif - -int inventec_singlechar_to_int(const char c) -{ - if ((c >= '0') && (c <= '9')) { - return (c - '0'); - } - else - if ((c >= 'a') && (c <= 'f')) { - return (c - 'a' + 10); - } - else - if ((c >= 'A') && (c <= 'F')) { - return (c - 'A' + 10); - } - return -1; -} - -/* fan device *************************************/ -#define FAN_STATE_NORMAL "normal" -#define FAN_STATE_FAULTY "faulty" -#define FAN_STATE_UNINSTALLED "uninstalled" -#define FAN_STATE_UNKNOW "unknown state" -#define FAN_STATE_INVALID "Invalid state value" -#define FAN_STATE_READ_ERROR "state read error" - -#define FAN_LOG_UNINSTALLED "removed" -#define FAN_LOG_NORMAL "inserted" - -//#define FAN_STATE_BIT_NORMAL 0 -#define FAN_STATE_BIT_FAULTY 0 -#define FAN_STATE_BIT_UNINSTALLED 1 -#define FAN_STATE_BIT_UNKNOW 2 -#define FAN_STATE_BIT_INVALID 3 -#define FAN_STATE_BIT_READ_ERROR 4 - -static ssize_t psoc_show_fan1_input(char *buf) -{ - return psoc_show_fan_input(buf, 1); -} - -static ssize_t psoc_show_fan2_input(char *buf) -{ - return psoc_show_fan_input(buf, 2); -} - -static ssize_t psoc_show_fan3_input(char *buf) -{ - return psoc_show_fan_input(buf, 3); -} - -static ssize_t psoc_show_fan4_input(char *buf) -{ - return psoc_show_fan_input(buf, 4); -} - -static struct fans_tbl_s { - char *fan_name; - ssize_t (*fan_front)(char *); - ssize_t (*fan_rear)(char *); - unsigned int fan_state; -} fans_tbl[] = { - {"fan1", psoc_show_fan1_input, - psoc_show_fan2_input, 0}, - {"fan2", psoc_show_fan3_input, - psoc_show_fan4_input, 0}, -}; -#define FAN_TBL_TOTAL ( sizeof(fans_tbl)/ sizeof(const struct fans_tbl_s) ) - -#define FAN_STATE_CHECK(i,b) (fans_tbl[i].fan_state & (1<inv_dev_attrp, PSU_ATTR_VOLTIN, PSU_ATTR_VOLTIN_LEN) == 0) { - invwirep = psu_get_show_function(PSU_ATTR_VOLTIN, psu_dev_group[i].psu_name, NULL); - if (invwirep == NULL) { - printk(KERN_DEBUG "[p_thread] Invalid psuname: %s\n", psu_dev_group[i].psu_name); - continue; - } - if (invwirep(volt) <= 0) { - printk(KERN_DEBUG "[p_thread] Read %s failed\n", psu_dev_group[i].psu_name); - continue; - } - else { - voltin = simple_strtol(&volt[0], NULL, 10); - printk(KERN_DEBUG "[p_thread] Read %s %s = %u\n",psu_dev_group[i].psu_name,volt,voltin); - if (voltin > psu_voltin) { - psu_voltin = voltin; - } - } - } - } - } - - SYSFS_LOG("[p_thread] PSU voltin = %u\n", psu_voltin); -} - -#define PSU_ATTR_STATE ("state") -#define PSU_ATTR_STATE_LEN (5) - -/* psus_control() by inv_thread */ -int psus_control(int log_only) -{ - char state[MIN_ACC_SIZE]; - psu_dev_t *devnamep = NULL; - ssize_t (*invwirep)(char *buf) = NULL; - char *psu_statep = NULL; - int i, j, flag = 0; - - for (i = 0; i < PSU_DEV_GROUP_TOTAL; i++) { - devnamep = psu_dev_group[i].psu_dev_namep; - for (j = 0; j < psu_dev_group[i].psu_dev_total; j++, devnamep++) { - if (strncmp(devnamep->inv_dev_attrp, PSU_ATTR_STATE, PSU_ATTR_STATE_LEN) == 0) { - invwirep = psu_get_show_function(PSU_ATTR_STATE, psu_dev_group[i].psu_name, &psu_statep); - if (invwirep == NULL) { - printk(KERN_DEBUG "[p_thread] Invalid psuname: %s\n", psu_dev_group[i].psu_name); - continue; - } - if (invwirep(state) <= 0) { - printk(KERN_DEBUG "[p_thread] Read %s failed\n", psu_dev_group[i].psu_name); - if (strncmp(psu_statep, PSU_STATE_ERROR, strlen(PSU_STATE_ERROR)) != 0) { - strcpy(psu_statep, PSU_STATE_ERROR); - SYSFS_LOG("[p_thread] %s: %s\n",psu_dev_group[i].psu_name,PSU_STATE_ERROR); - } - flag = 1; - } - else - if (strstr(state, "normal")) { - if (strncmp(psu_statep, state, strlen(state)) != 0) { - strcpy(psu_statep, state); - SYSFS_LOG("[p_thread] %s: %s\n",psu_dev_group[i].psu_name,state); - } - } - else - if (psu_voltin > PSU_VOLTIN_ACDC) { /* AC PSUS */ - if (strncmp(psu_statep, state, strlen(state)) != 0) { - strcpy(psu_statep, state); - SYSFS_LOG("[p_thread] %s: %s\n",psu_dev_group[i].psu_name,state); - } - flag = 1; - } - else { /* DC PSUS */ - if (strncmp(psu_statep, PSU_STATE_CHECKPSU, PSU_STATE_LEN_CHECKPSU) != 0) { - strcpy(psu_statep, PSU_STATE_CHECKPSU); - SYSFS_LOG("[p_thread] %s: %s\n",psu_dev_group[i].psu_name,PSU_STATE_CHECKPSU); - } - flag = 1; - } - } - } - } - - if (log_only) { - return 0; - } - - //SYSFS_LOG("[p_thread] RYU: %s: flag = %d\n",psu_wire_tbl[i].psu_name,flag); - if (flag == 1) { - status_led_grn("2"); - return 1; - } - return 0; -} - -/* End of psuinfo_device */ - -/* led device *************************************/ - -/* return 0/off 1/green 2/red */ -int -status_led_check_color(void) -{ - char tmpbuf[MIN_ACC_SIZE]; - int ret = STATUS_LED_INVALID; - - if (cpld_show_led(&tmpbuf[0], CPLD_DEV_LED_GRN_INDEX) > 0) { - if (tmpbuf[0] == '0') { - ret = STATUS_LED_GRN0; - } - if (tmpbuf[0] == '1') { - ret = STATUS_LED_GRN1; - } - if (tmpbuf[0] == '2') { - ret = STATUS_LED_GRN2; - } - if (tmpbuf[0] == '3') { - ret = STATUS_LED_GRN3; - } - if (tmpbuf[0] == '7') { - ret = STATUS_LED_GRN7; - } - return ret; - } - - if (cpld_show_led(&tmpbuf[0], CPLD_DEV_LED_RED_INDEX) > 0) { - if (tmpbuf[0] == '0') { - ret = STATUS_LED_RED0; - } - if (tmpbuf[0] == '1') { - ret = STATUS_LED_RED1; - } - if (tmpbuf[0] == '2') { - ret = STATUS_LED_RED2; - } - if (tmpbuf[0] == '3') { - ret = STATUS_LED_RED3; - } - if (tmpbuf[0] == '7') { - ret = STATUS_LED_RED7; - } - return ret; - } - return ret; -} - -/* - * Store attr Section - */ -ssize_t status_led_diag_mode_enable(void) -{ - char tmp[MIN_ACC_SIZE]; - ssize_t ret; - - ret = psoc_show_diag(&tmp[0]); - if (ret <= 0) { - return ret; - } - - if (tmp[0] == '0') { - ret = psoc_set_diag("1", 1); - if (ret < 0) { - return ret; - } - - ret = cpld_set_ctl("1", 1); - if (ret < 0) { - return ret; - } - } - - return ret; -} - -ssize_t status_led_diag_mode_disable(void) -{ - char tmp[MIN_ACC_SIZE]; - ssize_t ret; - - ret = psoc_show_diag(&tmp[0]); - if (ret <= 0) { - return ret; - } - - if (tmp[0] == '1') { - ret = psoc_set_diag("0", 1); - if (ret < 0) { - return 1; - } - - ret = cpld_set_ctl("1", 1); - if (ret < 0) { - return 1; - } - } - return 1; -} - -ssize_t -status_led_red(const char *freq) -{ - char buf[MIN_ACC_SIZE]; - ssize_t ret; - - ret = cpld_show_led(buf, CPLD_DEV_LED_RED_INDEX); - if (ret < 0 || buf[0] == freq[0]) { - return ret; - } - - ret = cpld_set_led("0", 1, CPLD_DEV_LED_GRN_INDEX); - if (ret < 0) { - return ret; - } - ret = cpld_set_led(freq, strlen(freq), CPLD_DEV_LED_RED_INDEX); - if (ret < 0) { - return ret; - } - if ((ret = status_led_diag_mode_enable()) <= 0) { - return ret; - } - ssleep(1); - if ((ret = status_led_diag_mode_disable()) <= 0) { - return ret; - } - return ret; -} - -ssize_t -status_led_grn(const char *freq) -{ - char buf[MIN_ACC_SIZE]; - ssize_t ret; - - ret = cpld_show_led(buf, CPLD_DEV_LED_GRN_INDEX); - if (ret < 0 || buf[0] == freq[0]) { - return ret; - } - - ret = cpld_set_led("0", 1, CPLD_DEV_LED_RED_INDEX); - if (ret < 0) { - return ret; - } - ssleep(1); - ret = cpld_set_led(freq, strlen(freq), CPLD_DEV_LED_GRN_INDEX); - if (ret < 0) { - return ret; - } - if ((ret = status_led_diag_mode_enable()) <= 0) { - return ret; - } - ssleep(1); - if ((ret = status_led_diag_mode_disable()) <= 0) { - return ret; - } - return ret; -} - -int status_led_check_diag_mode(void) -{ - char tmp[MIN_ACC_SIZE]; - ssize_t ret; - - ret = psoc_show_diag(&tmp[0]); - if (ret <= 0) { - return ret; - } - - if (tmp[0] == '1') { - return STATUS_LED_MODE_DIAG; - } - - if (tmp[0] == '0') { - return STATUS_LED_MODE_AUTO; - } - - return -1; -} - -/* End of ledinfo_device */ - -/**************************************************/ -/* From system_device */ -static int inv_pthread_control = 1; - -int thread_control(void) -{ - return inv_pthread_control; -} - -void thread_control_set(int val) -{ - inv_pthread_control = val; -} -/* End system_device */ - -#define THREAD_SLEEP_MINS (3) -#define THREAD_DELAY_MINS (THREAD_SLEEP_MINS + THREAD_SLEEP_MINS + 1) - -static struct task_struct *thread_st; -static int thread_data; - -// Function executed by kernel thread -static int thread_fn(void *unused) -{ - mutex_init(&pthread_mutex); - - ssleep(THREAD_DELAY_MINS); - - /* Default status init */ - mutex_lock(&pthread_mutex); - status_led_grn("7"); - mutex_unlock(&pthread_mutex); - - psu_get_voltin(); - - /* Delay for guarantee HW ready */ - ssleep(THREAD_DELAY_MINS); - - while (1) - { - mutex_unlock(&pthread_mutex); - ssleep(THREAD_SLEEP_MINS); - - if (thread_control() == 0) { - printk(KERN_INFO "[p_thread] %s/%d: Thread Stop by inv_pthread control\n",__func__,__LINE__); - break; - } - - mutex_lock(&pthread_mutex); - if (status_led_check_diag_mode() == STATUS_LED_MODE_MANU) { - /* status led in change color/freq mode, higher priority. Ignore fans sttaus */ - continue; - } - -#if 0 - switch_temp_update(); -#endif - - if (fans_control() > 0) { - psus_control(1); - continue; - } - else - if (psus_control(0) > 0) { - continue; - } - - if (status_led_check_color() != STATUS_LED_GRN7) { /* status led red, change it to green */ - status_led_grn("7"); - } - } - - do_exit(0); - printk(KERN_INFO "[p_thread] %s/%d: Thread Stopped\n",__func__,__LINE__); - return 0; -} - - -static ssize_t s_show(struct kobject *kobj, struct attribute *attr, char *buf) -{ - int fan_absence; - size_t count = 0; - - fan_absence = fans_control(); - count += sprintf(&buf[count], "%d\n", fan_absence); - return count; -} - -static ssize_t s_store(struct kobject *kobj, struct attribute *attr, const char *buf, size_t count) -{ - return count; -} - -static struct attribute status_att = { - .name = "fan_absence", - .mode = 0777, -}; - -static const struct sysfs_ops status_ops = { - .show = s_show, - .store = s_store, -}; - -static struct kobj_type status_ktype = { - .sysfs_ops = &status_ops, -}; - - -static int __init inv_pthread_init(void) -{ - int retval; - - status_kobj = kzalloc(sizeof(*status_kobj), GFP_KERNEL); - if(!status_kobj) - return PTR_ERR(status_kobj); - - status_kset = kset_create_and_add("platform_status", NULL, kernel_kobj); - if(!status_kset) - return -1; - - status_kobj->kset = status_kset; - - retval = kobject_init_and_add(status_kobj, &status_ktype, NULL, "fan"); - if(retval) - return retval; - - retval = sysfs_create_file(status_kobj, &status_att); - - thread_control_set(1); - - printk(KERN_INFO "[p_thread] %s/%d: Creating Thread\n",__func__,__LINE__); - //Create the kernel thread with name 'inv_pthread' - thread_st = kthread_run(thread_fn, (void*)&thread_data, "inv_pthread"); - if (thread_st) - printk(KERN_INFO "[p_thread] inv_pthread Created successfully\n"); - else - printk(KERN_ERR "[p_thread] inv_pthread creation failed\n"); - - return retval; -} - -static void __exit inv_pthread_exit(void) -{ - thread_control_set(0); - /* Delay for guarantee thread exit */ - ssleep(THREAD_DELAY_MINS); - - sysfs_remove_file(status_kobj, &status_att); - kset_unregister(status_kset); - kobject_del(status_kobj); - - printk(KERN_INFO "[p_thread] inv_pthread cleaning Up\n"); -} - -module_init(inv_pthread_init); -module_exit(inv_pthread_exit); - -MODULE_AUTHOR("Robert "); -MODULE_DESCRIPTION("Inventec Platform Management Thread"); -MODULE_VERSION("version 1.1"); -MODULE_LICENSE("GPL"); diff --git a/packages/platforms/inventec/x86-64/d5052/modules/builds/src/inv_pthread.h b/packages/platforms/inventec/x86-64/d5052/modules/builds/src/inv_pthread.h deleted file mode 100644 index c3b7ce830..000000000 --- a/packages/platforms/inventec/x86-64/d5052/modules/builds/src/inv_pthread.h +++ /dev/null @@ -1,19 +0,0 @@ -#ifndef INV_PTHREAD_H -#define INV_PTHREAD_H - -#define CPLD_DEV_LED_GRN_INDEX (0) -#define CPLD_DEV_LED_RED_INDEX (1) - -ssize_t cpld_show_led(char *buf, int index); -ssize_t cpld_set_led(const char *buf, size_t count, int index); -ssize_t cpld_show_ctl(char *buf); -ssize_t cpld_set_ctl(const char *buf, size_t count); - -ssize_t psoc_show_psu_state(char *buf, int index); -ssize_t psoc_show_fan_input(char *buf, int index); -ssize_t psoc_show_fan_state(char *buf); -ssize_t psoc_show_psu_vin(char *buf, int index); -ssize_t psoc_show_diag(char *buf); -ssize_t psoc_set_diag(const char *buf, size_t count); - -#endif /* INV_PTHREAD_H */ diff --git a/packages/platforms/inventec/x86-64/d5052/modules/builds/src/inv_swps.c b/packages/platforms/inventec/x86-64/d5052/modules/builds/src/inv_swps.c deleted file mode 100644 index d3fddbc48..000000000 --- a/packages/platforms/inventec/x86-64/d5052/modules/builds/src/inv_swps.c +++ /dev/null @@ -1,3069 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "inv_swps.h" - -static int ctl_major; -static int port_major; -static int ioexp_total; -static int port_total; -static int auto_config; -static int flag_i2c_reset; -static int flag_mod_state; -static unsigned gpio_rest_mux; -static struct class *swp_class_p = NULL; -static struct inv_platform_s *platform_p = NULL; -static struct inv_ioexp_layout_s *ioexp_layout = NULL; -static struct inv_port_layout_s *port_layout = NULL; - -static void swp_polling_worker(struct work_struct *work); -static DECLARE_DELAYED_WORK(swp_polling, swp_polling_worker); - -static int reset_i2c_topology(void); - - -static int -__swp_match(struct device *dev, -#if defined(SWPS_KERN_VER_AF_3_10) || defined(SWPS_KERN_VER_AF_4_4) - - const void *data){ -#else - void *data){ -#endif - - char *name = (char *)data; - if (strcmp(dev_name(dev), name) == 0) - return 1; - return 0; -} - - -struct device * -get_swpdev_by_name(char *name){ - struct device *dev = class_find_device(swp_class_p, - NULL, - name, - __swp_match); - return dev; -} - - -static int -sscanf_2_int(const char *buf) { - - int result = -EBFONT; - char *hex_tag = "0x"; - - if (strcspn(buf, hex_tag) == 0) { - if (sscanf(buf,"%x",&result)) { - return result; - } - } else { - if (sscanf(buf,"%d",&result)) { - return result; - } - if(sscanf(buf,"-%d",&result)) { - return -result; - } - if (sscanf(buf,"%x",&result)) { - return result; - } - } - return -EBFONT; -} - - -static int -sscanf_2_binary(const char *buf) { - - int result = sscanf_2_int(buf); - - if (result < 0){ - return -EBFONT; - } - switch (result) { - case 0: - case 1: - return result; - default: - break; - } - return -EBFONT; -} - - -static int -_get_polling_period(void) { - - int retval = 0; - - if (SWP_POLLING_PERIOD == 0) { - return 0; - } - retval = ((SWP_POLLING_PERIOD * HZ) / 1000); - if (retval == 0) { - return 1; - } - return retval; -} - - -static struct transvr_obj_s * -_get_transvr_obj(char *dev_name) { - - struct device *dev_p = NULL; - struct transvr_obj_s *transvr_obj_p = NULL; - - dev_p = get_swpdev_by_name(dev_name); - if (!dev_p){ - return NULL; - } - transvr_obj_p = dev_get_drvdata(dev_p); - if (!transvr_obj_p){ - return NULL; - } - return transvr_obj_p; -} - - -static void -unlock_tobj_all(void) { - - struct transvr_obj_s *tobj_p; - char port_name[32]; - int port_id = 0; - int minor_curr = 0; - - for (minor_curr=0; minor_currauto_config = auto_config; - unlock_transvr_obj(tobj_p); - SWPS_DEBUG("%s: Set %s auto_config=%d\n", - __func__, tobj_p->swp_name, auto_config); - } - return retval; -} - - -/* ========== R/W Functions module control attribute ========== - */ -static ssize_t -show_attr_platform(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - return snprintf(buf_p, 32, "%s\n", platform_p->name); -} - - -static ssize_t -show_attr_version(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - return snprintf(buf_p, 8, "%s\n", SWP_VERSION); -} - - -static ssize_t -show_attr_status(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - return snprintf(buf_p, 8, "%d\n", flag_mod_state); -} - - -static ssize_t -show_attr_auto_config(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - return snprintf(buf_p, 8, "%d\n", auto_config); -} - - -static int -_check_reset_pwd(const char *buf_p, - size_t count) { - - int in_max = 64; - int in_len = (int)count; - char in_val[64] = "ERR"; - char *emsg = "ERR"; - - if (in_len >= in_max) { - emsg = "input too much"; - goto err_check_reset_pwd; - } - if (!sscanf(buf_p,"%s",in_val)) { - emsg = "format incorrect"; - goto err_check_reset_pwd; - } - if (strcmp(in_val, SWP_RESET_PWD) != 0) { - emsg = "password incorrect"; - goto err_check_reset_pwd; - } - return 0; - -err_check_reset_pwd: - SWPS_ERR("%s: %s\n", __func__, emsg); - return -1; -} - - -static ssize_t -store_attr_reset_i2c(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - - if (_check_reset_pwd(buf_p, count) < 0) { - return -EBFONT; - } - /* Polling mode */ - if (SWP_POLLING_ENABLE) { - SWPS_INFO("%s: reset I2C :polling\n", __func__); - flag_i2c_reset = 1; - return count; - } - /* Direct mode */ - SWPS_INFO("%s: reset I2C go. :direct\n", __func__); - if (reset_i2c_topology() < 0) { - SWPS_ERR("%s: reset fail!\n", __func__); - return -EIO; - } - SWPS_INFO("%s: reset I2C ok. :direct\n", __func__); - return count; -} - - -static ssize_t -store_attr_reset_swps(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - - struct transvr_obj_s *tobj_p; - char port_name[32] = "ERR"; - int port_id = 0; - int minor_curr = 0; - - if (_check_reset_pwd(buf_p, count) < 0) { - return -EBFONT; - } - for (minor_curr=0; minor_currstate = STATE_TRANSVR_DISCONNECTED; - unlock_transvr_obj(tobj_p); - SWPS_INFO("%s: reset:%s\n", __func__, tobj_p->swp_name); - } - return count; -} - - -static ssize_t -store_attr_auto_config(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - - int input_val = sscanf_2_int(buf_p); - - if (input_val < 0){ - return -EBFONT; - } - if ((input_val != 0) && (input_val != 1)) { - return -EBFONT; - } - auto_config = input_val; - _update_auto_config_2_trnasvr(); - return count; -} - - -/* ========== Show functions: For transceiver attribute ========== - */ -static ssize_t -_show_transvr_hex_attr(struct transvr_obj_s* tobj_p, - int (*get_func)(struct transvr_obj_s* tobj_p), - char *buf_p) { - size_t len; - int result; - - lock_transvr_obj(tobj_p); - result = get_func(tobj_p); - unlock_transvr_obj(tobj_p); - if (result < 0){ - len = snprintf(buf_p, 8, "%d\n", result); - } else { - len = snprintf(buf_p, 8, "0x%02x\n", result); - } - return len; -} - - -static ssize_t -_show_transvr_int_attr(struct transvr_obj_s* tobj_p, - int (*get_func)(struct transvr_obj_s* tobj_p), - char *buf_p) { - size_t len; - - lock_transvr_obj(tobj_p); - len = snprintf(buf_p, 16, "%d\n", get_func(tobj_p)); - unlock_transvr_obj(tobj_p); - return len; -} - - -static ssize_t -_show_transvr_str_attr(struct transvr_obj_s* tobj_p, - int (*get_func)(struct transvr_obj_s* tobj_p, char* buf), - char *buf_p) { - size_t len; - - lock_transvr_obj(tobj_p); - len = get_func(tobj_p, buf_p); - unlock_transvr_obj(tobj_p); - return len; -} - - -static ssize_t -show_attr_id(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_hex_attr(tobj_p, - tobj_p->get_id, - buf_p); -} - -static ssize_t -show_attr_eeprom(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_eeprom, - buf_p); -} - -static ssize_t -show_attr_uppage(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_uppage, - buf_p); -} - - -static ssize_t -show_attr_ext_id(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_hex_attr(tobj_p, - tobj_p->get_ext_id, - buf_p); -} - - -static ssize_t -show_attr_connector(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_hex_attr(tobj_p, - tobj_p->get_connector, - buf_p); -} - - -static ssize_t -show_attr_vendor_name(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_vendor_name, - buf_p); -} - - -static ssize_t -show_attr_vendor_pn(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_vendor_pn, - buf_p); -} - - -static ssize_t -show_attr_vendor_rev(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_vendor_rev, - buf_p); -} - - -static ssize_t -show_attr_vendor_sn(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_vendor_sn, - buf_p); -} - - -static ssize_t -show_attr_power_cls(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - size_t len; - int result; - struct transvr_obj_s *tobj_p; - - tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - lock_transvr_obj(tobj_p); - result = tobj_p->get_power_cls(tobj_p); - unlock_transvr_obj(tobj_p); - if (result < 0){ - len = snprintf(buf_p, 16, "%d\n", result); - } else { - len = snprintf(buf_p, 16, "Power Class %d\n", result); - } - return len; -} - - -static ssize_t -show_attr_br(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_hex_attr(tobj_p, - tobj_p->get_br, - buf_p); -} - - -static ssize_t -show_attr_len_sm(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_int_attr(tobj_p, - tobj_p->get_len_sm, - buf_p); -} - - -static ssize_t -show_attr_len_smf(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_int_attr(tobj_p, - tobj_p->get_len_smf, - buf_p); -} - - -static ssize_t -show_attr_len_om1(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_int_attr(tobj_p, - tobj_p->get_len_om1, - buf_p); -} - - -static ssize_t -show_attr_len_om2(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_int_attr(tobj_p, - tobj_p->get_len_om2, - buf_p); -} - - -static ssize_t -show_attr_len_om3(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_int_attr(tobj_p, - tobj_p->get_len_om3, - buf_p); -} - - -static ssize_t -show_attr_len_om4(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_int_attr(tobj_p, - tobj_p->get_len_om4, - buf_p); -} - - -static ssize_t -show_attr_comp_rev(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_hex_attr(tobj_p, - tobj_p->get_comp_rev, - buf_p); -} - - -static ssize_t -show_attr_comp_eth(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_hex_attr(tobj_p, - tobj_p->get_comp_eth_1, - buf_p); -} - - -static ssize_t -show_attr_comp_eth_10(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_hex_attr(tobj_p, - tobj_p->get_comp_eth_10, - buf_p); -} - - -static ssize_t -show_attr_comp_eth_10_40(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_hex_attr(tobj_p, - tobj_p->get_comp_eth_10_40, - buf_p); -} - - -static ssize_t -show_attr_comp_extend(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_hex_attr(tobj_p, - tobj_p->get_comp_extend, - buf_p); -} - - -static ssize_t -show_attr_rate_id(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_hex_attr(tobj_p, - tobj_p->get_rate_id, - buf_p); -} - - -static ssize_t -show_attr_temperature(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_curr_temp, - buf_p); -} - - -static ssize_t -show_attr_voltage(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_curr_vol, - buf_p); -} - - -static ssize_t -show_attr_tx_bias(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_tx_bias, - buf_p); -} - - -static ssize_t -show_attr_tx_power(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_tx_power, - buf_p); -} - - -static ssize_t -show_attr_tx_eq(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_tx_eq, - buf_p); -} - - -static ssize_t -show_attr_rx_power(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_rx_power, - buf_p); -} - - -static ssize_t -show_attr_rx_am(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_rx_am, - buf_p); -} - - -static ssize_t -show_attr_rx_em(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_rx_em, - buf_p); -} - - -static ssize_t -show_attr_wavelength(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_wavelength, - buf_p); -} - - -static ssize_t -show_attr_extphy_offset(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_extphy_offset, - buf_p); -} - - -static ssize_t -show_attr_extphy_reg(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_extphy_reg, - buf_p); -} - - -static ssize_t -show_attr_info(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_int_attr(tobj_p, - tobj_p->get_info, - buf_p); -} - - -static ssize_t -show_attr_if_type(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_if_type, - buf_p); -} - - -static ssize_t -show_attr_if_speed(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_if_speed, - buf_p); -} - - -static ssize_t -show_attr_if_lane(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_if_lane, - buf_p); -} - - -static ssize_t -show_attr_cdr(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_hex_attr(tobj_p, - tobj_p->get_cdr, - buf_p); -} - - -static ssize_t -show_attr_soft_rs0(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_int_attr(tobj_p, - tobj_p->get_soft_rs0, - buf_p); -} - - -static ssize_t -show_attr_soft_rs1(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_int_attr(tobj_p, - tobj_p->get_soft_rs1, - buf_p); -} - - -static ssize_t -show_attr_soft_rx_los(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_soft_rx_los, - buf_p); -} - - -static ssize_t -show_attr_soft_tx_disable(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_soft_tx_disable, - buf_p); -} - - -static ssize_t -show_attr_soft_tx_fault(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_soft_tx_fault, - buf_p); -} - - -static ssize_t -show_attr_auto_tx_disable(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_auto_tx_disable, - buf_p); -} - - -/* ========== Store functions: transceiver (R/W) attribute ========== - */ -static ssize_t -_store_transvr_int_attr(struct transvr_obj_s* tobj_p, - int (*set_func)(struct transvr_obj_s *tobj_p, int input_val), - const char *buf_p, - size_t count) { - int input, err; - - input = sscanf_2_int(buf_p); - if (input < 0){ - return -EBFONT; - } - lock_transvr_obj(tobj_p); - err = set_func(tobj_p, input); - unlock_transvr_obj(tobj_p); - if (err < 0){ - return err; - } - return count; -} - - -static ssize_t -_store_transvr_byte_hex_attr(struct transvr_obj_s* tobj_p, - int (*set_func)(struct transvr_obj_s *tobj_p, int input_val), - const char *buf_p, - size_t count) { - int input, err; - - input = sscanf_2_int(buf_p); - if ((input < 0) || (input > 0xff)){ - return -EBFONT; - } - lock_transvr_obj(tobj_p); - err = set_func(tobj_p, input); - unlock_transvr_obj(tobj_p); - if (err < 0){ - return err; - } - return count; -} - - -static ssize_t -_store_transvr_binary_attr(struct transvr_obj_s* tobj_p, - int (*set_func)(struct transvr_obj_s *tobj_p, int input_val), - const char *buf_p, - size_t count) { - int input, err; - - input = sscanf_2_binary(buf_p); - if (input < 0){ - return -EBFONT; - } - lock_transvr_obj(tobj_p); - err = set_func(tobj_p, input); - unlock_transvr_obj(tobj_p); - if (err < 0){ - return err; - } - return count; -} - - -static ssize_t -store_attr_cdr(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - return _store_transvr_byte_hex_attr(tobj_p, - tobj_p->set_cdr, - buf_p, - count); -} - - -static ssize_t -store_attr_soft_rs0(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - return _store_transvr_binary_attr(tobj_p, - tobj_p->set_soft_rs0, - buf_p, - count); -} - - -static ssize_t -store_attr_soft_rs1(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - return _store_transvr_binary_attr(tobj_p, - tobj_p->set_soft_rs1, - buf_p, - count); -} - - -static ssize_t -store_attr_soft_tx_disable(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count) { - - int check = sscanf_2_int(buf_p); - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - if ((check < 0) || (check > 0xf)){ - return -EBFONT; - } - return _store_transvr_byte_hex_attr(tobj_p, - tobj_p->set_soft_tx_disable, - buf_p, - count); -} - - -static ssize_t -store_attr_auto_tx_disable(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count) { - - int err = -EPERM; - int input = sscanf_2_int(buf_p); - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - if ((input < 0) || (input > 0xf)){ - if (input != VAL_TRANSVR_FUNCTION_DISABLE) { - return -EBFONT; - } - } - lock_transvr_obj(tobj_p); - err = tobj_p->set_auto_tx_disable(tobj_p, input); - unlock_transvr_obj(tobj_p); - if (err < 0){ - return err; - } - return count; -} - - -static ssize_t -store_attr_tx_eq(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - return _store_transvr_int_attr(tobj_p, - tobj_p->set_tx_eq, - buf_p, - count); -} - - -static ssize_t -store_attr_rx_am(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - return _store_transvr_int_attr(tobj_p, - tobj_p->set_rx_am, - buf_p, - count); -} - - -static ssize_t -store_attr_rx_em(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - return _store_transvr_int_attr(tobj_p, - tobj_p->set_rx_em, - buf_p, - count); -} - - -static ssize_t -store_attr_extphy_offset(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - return _store_transvr_int_attr(tobj_p, - tobj_p->set_extphy_offset, - buf_p, - count); -} - - -static ssize_t -store_attr_extphy_reg(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - return _store_transvr_int_attr(tobj_p, - tobj_p->set_extphy_reg, - buf_p, - count); -} - -/* ========== Show functions: For I/O Expander attribute ========== - */ -static ssize_t -_show_ioexp_binary_attr(struct transvr_obj_s *tobj_p, - int (*get_func)(struct ioexp_obj_s *ioexp_p, int voffset), - char *buf_p) { - size_t len; - struct ioexp_obj_s *ioexp_p = tobj_p->ioexp_obj_p; - - if (!ioexp_p) { - SWPS_ERR(" %s: data corruption! :%s\n", __func__, tobj_p->swp_name); - return -ENODATA; - } - mutex_lock(&ioexp_p->lock); - len = snprintf(buf_p, 8, "%d\n", get_func(ioexp_p, tobj_p->ioexp_virt_offset)); - mutex_unlock(&ioexp_p->lock); - return len; -} - - -static ssize_t -show_attr_present(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - return _show_ioexp_binary_attr(tobj_p, - tobj_p->ioexp_obj_p->get_present, - buf_p); -} - - -static ssize_t -show_attr_tx_fault(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - return _show_ioexp_binary_attr(tobj_p, - tobj_p->ioexp_obj_p->get_tx_fault, - buf_p); -} - - -static ssize_t -show_attr_rxlos(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - return _show_ioexp_binary_attr(tobj_p, - tobj_p->ioexp_obj_p->get_rxlos, - buf_p); -} - - -static ssize_t -show_attr_tx_disable(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - return _show_ioexp_binary_attr(tobj_p, - tobj_p->ioexp_obj_p->get_tx_disable, - buf_p); -} - - -static ssize_t -show_attr_reset(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - return _show_ioexp_binary_attr(tobj_p, - tobj_p->ioexp_obj_p->get_reset, - buf_p); -} - - -static ssize_t -show_attr_lpmod(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - return _show_ioexp_binary_attr(tobj_p, - tobj_p->ioexp_obj_p->get_lpmod, - buf_p); -} - - -static ssize_t -show_attr_modsel(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - return _show_ioexp_binary_attr(tobj_p, - tobj_p->ioexp_obj_p->get_modsel, - buf_p); -} - - -static ssize_t -show_attr_hard_rs0(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - return _show_ioexp_binary_attr(tobj_p, - tobj_p->ioexp_obj_p->get_hard_rs0, - buf_p); -} - - -static ssize_t -show_attr_hard_rs1(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - return _show_ioexp_binary_attr(tobj_p, - tobj_p->ioexp_obj_p->get_hard_rs1, - buf_p); -} - - -/* ========== Store functions: For I/O Expander (R/W) attribute ========== - */ -static ssize_t -_store_ioexp_binary_attr(struct transvr_obj_s *tobj_p, - int (*set_func)(struct ioexp_obj_s *ioexp_p, - int virt_offset, int input_val), - const char *buf_p, - size_t count) { - - int input, err; - struct ioexp_obj_s *ioexp_p = tobj_p->ioexp_obj_p; - - if (!ioexp_p) { - SWPS_ERR("%s: data corruption! :%s\n", - __func__, tobj_p->swp_name); - return -ENODATA; - } - input = sscanf_2_binary(buf_p); - if (input < 0) { - return -EBFONT; - } - mutex_lock(&ioexp_p->lock); - err = set_func(ioexp_p, tobj_p->ioexp_virt_offset, input); - mutex_unlock(&ioexp_p->lock); - if (err < 0){ - return err; - } - return count; -} - -static ssize_t -store_attr_tx_disable(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p) { - return -ENODEV; - } - return _store_ioexp_binary_attr(tobj_p, - tobj_p->ioexp_obj_p->set_tx_disable, - buf_p, - count); -} - - -static ssize_t -store_attr_reset(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p) { - return -ENODEV; - } - return _store_ioexp_binary_attr(tobj_p, - tobj_p->ioexp_obj_p->set_reset, - buf_p, - count); -} - - -static ssize_t -store_attr_lpmod(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p) { - return -ENODEV; - } - return _store_ioexp_binary_attr(tobj_p, - tobj_p->ioexp_obj_p->set_lpmod, - buf_p, - count); -} - - -static ssize_t -store_attr_modsel(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p) { - return -ENODEV; - } - return _store_ioexp_binary_attr(tobj_p, - tobj_p->ioexp_obj_p->set_modsel, - buf_p, - count); -} - - -static ssize_t -store_attr_hard_rs0(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p) { - return -ENODEV; - } - return _store_ioexp_binary_attr(tobj_p, - tobj_p->ioexp_obj_p->set_hard_rs0, - buf_p, - count); -} - - -static ssize_t -store_attr_hard_rs1(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p) { - return -ENODEV; - } - return _store_ioexp_binary_attr(tobj_p, - tobj_p->ioexp_obj_p->set_hard_rs1, - buf_p, - count); -} - - -/* ========== SWPS attribute: For module control ========== - */ -static DEVICE_ATTR(platform, S_IRUGO, show_attr_platform, NULL); -static DEVICE_ATTR(version, S_IRUGO, show_attr_version, NULL); -static DEVICE_ATTR(status, S_IRUGO, show_attr_status, NULL); -static DEVICE_ATTR(reset_i2c, S_IWUSR, NULL, store_attr_reset_i2c); -static DEVICE_ATTR(reset_swps, S_IWUSR, NULL, store_attr_reset_swps); -static DEVICE_ATTR(auto_config, S_IRUGO|S_IWUSR, show_attr_auto_config, store_attr_auto_config); - -/* ========== Transceiver attribute: from eeprom ========== - */ -static DEVICE_ATTR(id, S_IRUGO, show_attr_id, NULL); -static DEVICE_ATTR(ext_id, S_IRUGO, show_attr_ext_id, NULL); -static DEVICE_ATTR(connector, S_IRUGO, show_attr_connector, NULL); -static DEVICE_ATTR(vendor_name, S_IRUGO, show_attr_vendor_name, NULL); -static DEVICE_ATTR(vendor_pn, S_IRUGO, show_attr_vendor_pn, NULL); -static DEVICE_ATTR(vendor_rev, S_IRUGO, show_attr_vendor_rev, NULL); -static DEVICE_ATTR(vendor_sn, S_IRUGO, show_attr_vendor_sn, NULL); -static DEVICE_ATTR(power_cls, S_IRUGO, show_attr_power_cls, NULL); -static DEVICE_ATTR(br, S_IRUGO, show_attr_br, NULL); -static DEVICE_ATTR(len_sm, S_IRUGO, show_attr_len_sm, NULL); -static DEVICE_ATTR(len_smf, S_IRUGO, show_attr_len_smf, NULL); -static DEVICE_ATTR(len_om1, S_IRUGO, show_attr_len_om1, NULL); -static DEVICE_ATTR(len_om2, S_IRUGO, show_attr_len_om2, NULL); -static DEVICE_ATTR(len_om3, S_IRUGO, show_attr_len_om3, NULL); -static DEVICE_ATTR(len_om4, S_IRUGO, show_attr_len_om4, NULL); -static DEVICE_ATTR(comp_rev, S_IRUGO, show_attr_comp_rev, NULL); -static DEVICE_ATTR(comp_eth, S_IRUGO, show_attr_comp_eth, NULL); -static DEVICE_ATTR(comp_eth_10, S_IRUGO, show_attr_comp_eth_10, NULL); -static DEVICE_ATTR(comp_eth_10_40, S_IRUGO, show_attr_comp_eth_10_40, NULL); -static DEVICE_ATTR(comp_extend, S_IRUGO, show_attr_comp_extend, NULL); -static DEVICE_ATTR(rate_id, S_IRUGO, show_attr_rate_id, NULL); -static DEVICE_ATTR(temperature, S_IRUGO, show_attr_temperature, NULL); -static DEVICE_ATTR(voltage, S_IRUGO, show_attr_voltage, NULL); -static DEVICE_ATTR(tx_bias, S_IRUGO, show_attr_tx_bias, NULL); -static DEVICE_ATTR(tx_power, S_IRUGO, show_attr_tx_power, NULL); -static DEVICE_ATTR(rx_power, S_IRUGO, show_attr_rx_power, NULL); -static DEVICE_ATTR(info, S_IRUGO, show_attr_info, NULL); -static DEVICE_ATTR(if_type, S_IRUGO, show_attr_if_type, NULL); -static DEVICE_ATTR(if_speed, S_IRUGO, show_attr_if_speed, NULL); -static DEVICE_ATTR(if_lane, S_IRUGO, show_attr_if_lane, NULL); -static DEVICE_ATTR(soft_rx_los, S_IRUGO, show_attr_soft_rx_los, NULL); -static DEVICE_ATTR(soft_tx_fault, S_IRUGO, show_attr_soft_tx_fault, NULL); -static DEVICE_ATTR(wavelength, S_IRUGO, show_attr_wavelength, NULL); -static DEVICE_ATTR(tx_eq, S_IRUGO|S_IWUSR, show_attr_tx_eq, store_attr_tx_eq); -static DEVICE_ATTR(rx_am, S_IRUGO|S_IWUSR, show_attr_rx_am, store_attr_rx_am); -static DEVICE_ATTR(rx_em, S_IRUGO|S_IWUSR, show_attr_rx_em, store_attr_rx_em); -static DEVICE_ATTR(cdr, S_IRUGO|S_IWUSR, show_attr_cdr, store_attr_cdr); -static DEVICE_ATTR(soft_rs0, S_IRUGO|S_IWUSR, show_attr_soft_rs0, store_attr_soft_rs0); -static DEVICE_ATTR(soft_rs1, S_IRUGO|S_IWUSR, show_attr_soft_rs1, store_attr_soft_rs1); -static DEVICE_ATTR(soft_tx_disable, S_IRUGO|S_IWUSR, show_attr_soft_tx_disable, store_attr_soft_tx_disable); -static DEVICE_ATTR(auto_tx_disable, S_IRUGO|S_IWUSR, show_attr_auto_tx_disable, store_attr_auto_tx_disable); -static DEVICE_ATTR(extphy_offset, S_IRUGO|S_IWUSR, show_attr_extphy_offset, store_attr_extphy_offset); -static DEVICE_ATTR(extphy_reg, S_IRUGO|S_IWUSR, show_attr_extphy_reg, store_attr_extphy_reg); -static DEVICE_ATTR(eeprom, S_IRUGO, show_attr_eeprom, NULL); -static DEVICE_ATTR(uppage, S_IRUGO, show_attr_uppage, NULL); - -/* ========== IO Expander attribute: from expander ========== - */ -static DEVICE_ATTR(present, S_IRUGO, show_attr_present, NULL); -static DEVICE_ATTR(tx_fault, S_IRUGO, show_attr_tx_fault, NULL); -static DEVICE_ATTR(rxlos, S_IRUGO, show_attr_rxlos, NULL); -static DEVICE_ATTR(tx_disable, S_IRUGO|S_IWUSR, show_attr_tx_disable, store_attr_tx_disable); -static DEVICE_ATTR(reset, S_IRUGO|S_IWUSR, show_attr_reset, store_attr_reset); -static DEVICE_ATTR(lpmod, S_IRUGO|S_IWUSR, show_attr_lpmod, store_attr_lpmod); -static DEVICE_ATTR(modsel, S_IRUGO|S_IWUSR, show_attr_modsel, store_attr_modsel); -static DEVICE_ATTR(hard_rs0, S_IRUGO|S_IWUSR, show_attr_hard_rs0, store_attr_hard_rs0); -static DEVICE_ATTR(hard_rs1, S_IRUGO|S_IWUSR, show_attr_hard_rs1, store_attr_hard_rs1); - -/* ========== Functions for module handling ========== - */ -static void -clean_port_obj(void){ - - dev_t dev_num; - char dev_name[32]; - struct device *device_p; - struct transvr_obj_s *transvr_obj_p; - int minor_curr, port_id; - - for (minor_curr=0; minor_curri2c_client_p); - kfree(transvr_obj_p->vendor_name); - kfree(transvr_obj_p->vendor_pn); - kfree(transvr_obj_p->vendor_rev); - kfree(transvr_obj_p->vendor_sn); - kfree(transvr_obj_p->worker_p); - kfree(transvr_obj_p); - } - dev_num = MKDEV(port_major, minor_curr); - device_unregister(device_p); - device_destroy(swp_class_p, dev_num); - } - SWPS_DEBUG("%s: done.\n", __func__); -} - - -static void -clean_swps_common(void){ - - dev_t dev_num; - struct device *device_p; - - device_p = get_swpdev_by_name(SWP_DEV_MODCTL); - if (device_p){ - dev_num = MKDEV(ctl_major, 1); - device_unregister(device_p); - device_destroy(swp_class_p, dev_num); - } - cancel_delayed_work_sync(&swp_polling); - SWPS_DEBUG("%s: done.\n", __func__); -} - - -static int -get_platform_type(void){ - - int i; - int pf_total = ARRAY_SIZE(platform_map); - char log_msg[64] = "ERROR"; - - platform_p = kzalloc(sizeof(struct inv_platform_s), GFP_KERNEL); - if (!platform_p){ - snprintf(log_msg, sizeof(log_msg), "kzalloc fail"); - goto err_get_platform_type_1; - } - memset(platform_p->name, 0, sizeof(platform_p->name)); - - switch (PLATFORM_SETTINGS) { - case PLATFORM_TYPE_AUTO: - snprintf(platform_p->name, (sizeof(platform_p->name) - 1), - "%s", dmi_get_system_info(DMI_BOARD_NAME)); - for (i=0; iname, platform_map[i].name) == 0) { - platform_p->id = platform_map[i].id; - snprintf(log_msg, sizeof(log_msg), - "Auto detect platform: %d (%s)", - platform_p->id, platform_p->name); - goto ok_get_platform_type_1; - } - } - snprintf(log_msg, sizeof(log_msg), - "Auto detect fail! detect platform: %s", - platform_p->name); - goto err_get_platform_type_2; - - case PLATFORM_TYPE_MAGNOLIA: - case PLATFORM_TYPE_MAGNOLIA_FNC: - case PLATFORM_TYPE_REDWOOD: - case PLATFORM_TYPE_REDWOOD_FSL: - case PLATFORM_TYPE_HUDSON32I_GA: - case PLATFORM_TYPE_SPRUCE: - case PLATFORM_TYPE_CYPRESS_GA1: - case PLATFORM_TYPE_CYPRESS_GA2: - case PLATFORM_TYPE_CYPRESS_BAI: - case PLATFORM_TYPE_TAHOE: - case PLATFORM_TYPE_SEQUOIA_GA: - case PLATFORM_TYPE_LAVENDER_GA: - case PLATFORM_TYPE_LAVENDER_ONL: - case PLATFORM_TYPE_COTTONWOOD_RANGELEY: - platform_p->id = PLATFORM_SETTINGS; - for (i=0; iname, (sizeof(platform_p->name) - 1), - "%s", platform_map[i].name); - snprintf(log_msg, sizeof(log_msg), - "User setup platform: %d (%s)", - platform_p->id, platform_p->name); - goto ok_get_platform_type_1; - } - } - snprintf(log_msg, sizeof(log_msg), - "Internal error, can not map id:%d", - PLATFORM_SETTINGS); - goto err_get_platform_type_2; - - default: - break; - } - snprintf(log_msg, sizeof(log_msg), - "PLATFORM_SETTINGS:%d undefined", PLATFORM_SETTINGS); - goto err_get_platform_type_2; - -ok_get_platform_type_1: - SWPS_DEBUG("%s: %s, :%d\n", __func__, log_msg, PLATFORM_SETTINGS); - return 0; - -err_get_platform_type_2: - kfree(platform_p); -err_get_platform_type_1: - SWPS_ERR("%s: %s :%d\n", __func__, log_msg, PLATFORM_SETTINGS); - return -1; -} - - -static int -get_layout_info(void){ - - switch (platform_p->id) { -#ifdef SWPS_MAGNOLIA - case PLATFORM_TYPE_MAGNOLIA: - case PLATFORM_TYPE_MAGNOLIA_FNC: - gpio_rest_mux = magnolia_gpio_rest_mux; - ioexp_layout = magnolia_ioexp_layout; - port_layout = magnolia_port_layout; - ioexp_total = ARRAY_SIZE(magnolia_ioexp_layout); - port_total = ARRAY_SIZE(magnolia_port_layout); - break; -#endif -#ifdef SWPS_REDWOOD - case PLATFORM_TYPE_REDWOOD: - gpio_rest_mux = redwood_gpio_rest_mux; - ioexp_layout = redwood_ioexp_layout; - port_layout = redwood_port_layout; - ioexp_total = ARRAY_SIZE(redwood_ioexp_layout); - port_total = ARRAY_SIZE(redwood_port_layout); - break; -#endif -#ifdef SWPS_HUDSON32I_GA - case PLATFORM_TYPE_HUDSON32I_GA: - gpio_rest_mux = hudsin32iga_gpio_rest_mux; - ioexp_layout = hudson32iga_ioexp_layout; - port_layout = hudson32iga_port_layout; - ioexp_total = ARRAY_SIZE(hudson32iga_ioexp_layout); - port_total = ARRAY_SIZE(hudson32iga_port_layout); - break; -#endif -#ifdef SWPS_SPRUCE - case PLATFORM_TYPE_SPRUCE: - gpio_rest_mux = spruce_gpio_rest_mux; - ioexp_layout = spruce_ioexp_layout; - port_layout = spruce_port_layout; - ioexp_total = ARRAY_SIZE(spruce_ioexp_layout); - port_total = ARRAY_SIZE(spruce_port_layout); - break; -#endif -#ifdef SWPS_CYPRESS_GA1 - case PLATFORM_TYPE_CYPRESS_GA1: - gpio_rest_mux = cypress_ga1_gpio_rest_mux; - ioexp_layout = cypress_ga1_ioexp_layout; - port_layout = cypress_ga1_port_layout; - ioexp_total = ARRAY_SIZE(cypress_ga1_ioexp_layout); - port_total = ARRAY_SIZE(cypress_ga1_port_layout); - break; -#endif -#ifdef SWPS_CYPRESS_GA2 - case PLATFORM_TYPE_CYPRESS_GA2: - gpio_rest_mux = cypress_ga2_gpio_rest_mux; - ioexp_layout = cypress_ga2_ioexp_layout; - port_layout = cypress_ga2_port_layout; - ioexp_total = ARRAY_SIZE(cypress_ga2_ioexp_layout); - port_total = ARRAY_SIZE(cypress_ga2_port_layout); - break; -#endif -#ifdef SWPS_CYPRESS_BAI - case PLATFORM_TYPE_CYPRESS_BAI: - gpio_rest_mux = cypress_b_gpio_rest_mux; - ioexp_layout = cypress_b_ioexp_layout; - port_layout = cypress_b_port_layout; - ioexp_total = ARRAY_SIZE(cypress_b_ioexp_layout); - port_total = ARRAY_SIZE(cypress_b_port_layout); - break; -#endif -#ifdef SWPS_REDWOOD_FSL - case PLATFORM_TYPE_REDWOOD_FSL: - gpio_rest_mux = redwood_fsl_gpio_rest_mux; - ioexp_layout = redwood_fsl_ioexp_layout; - port_layout = redwood_fsl_port_layout; - ioexp_total = ARRAY_SIZE(redwood_fsl_ioexp_layout); - port_total = ARRAY_SIZE(redwood_fsl_port_layout); - break; -#endif -#ifdef SWPS_TAHOE - case PLATFORM_TYPE_TAHOE: - gpio_rest_mux = tahoe_gpio_rest_mux; - ioexp_layout = tahoe_ioexp_layout; - port_layout = tahoe_port_layout; - ioexp_total = ARRAY_SIZE(tahoe_ioexp_layout); - port_total = ARRAY_SIZE(tahoe_port_layout); - break; -#endif -#ifdef SWPS_SEQUOIA - case PLATFORM_TYPE_SEQUOIA_GA: - gpio_rest_mux = sequoia_gpio_rest_mux; - ioexp_layout = sequoia_ioexp_layout; - port_layout = sequoia_port_layout; - ioexp_total = ARRAY_SIZE(sequoia_ioexp_layout); - port_total = ARRAY_SIZE(sequoia_port_layout); - break; -#endif -#ifdef SWPS_LAVENDER - case PLATFORM_TYPE_LAVENDER_GA: - case PLATFORM_TYPE_LAVENDER_ONL: - gpio_rest_mux = lavender_gpio_rest_mux; - ioexp_layout = lavender_ioexp_layout; - port_layout = lavender_port_layout; - ioexp_total = ARRAY_SIZE(lavender_ioexp_layout); - port_total = ARRAY_SIZE(lavender_port_layout); - break; -#endif -#ifdef SWPS_COTTONWOOD_RANGELEY - case PLATFORM_TYPE_COTTONWOOD_RANGELEY: - gpio_rest_mux = cottonwood_rangeley_gpio_rest_mux; - ioexp_layout = cottonwood_rangeley_ioexp_layout; - port_layout = cottonwood_rangeley_port_layout; - ioexp_total = ARRAY_SIZE(cottonwood_rangeley_ioexp_layout); - port_total = ARRAY_SIZE(cottonwood_rangeley_port_layout); - break; -#endif - default: - SWPS_ERR(" Invalid platform: %d (%s)\n", - platform_p->id, platform_p->name); - return -1; - } - SWPS_INFO("Start to initial platform: %d (%s)\n", - platform_p->id, platform_p->name); - return 0; -} - - -/* ========== Functions for objects operations ========== - */ -static int -__detect_issues_port(int minor_num) { - - struct transvr_obj_s *tobj_p; - int port_id = port_layout[minor_num].port_id; - char port_name[32] = "ERR"; - char *i2c_emsg = "detected bad transceiver/cable"; - - memset(port_name, 0, sizeof(port_name)); - snprintf(port_name, sizeof(port_name), "%s%d", SWP_DEV_PORT, port_id); - tobj_p = _get_transvr_obj(port_name); - if (!tobj_p) { - SWPS_INFO("%s: tobj_p is NULL :%d\n", __func__, minor_num); - return -1; - } - if (resync_channel_tier_2(tobj_p) < 0) { - if (check_channel_tier_1() < 0) { - alarm_msg_2_user(tobj_p, i2c_emsg); - return -2;; - } - } - return 0; -} - - -static int -_detect_issues_port(void) { - /* OK : retrun -1; - * Fail: return fail at which minor number (0~N) - */ - char *emsg = "ERR"; - int minor = 0; - int minor_2st = 1; - - /* Force moving the initial channel pointer - * Filter out case of fail at minor-0 port - */ - while (minor_2st < port_total) { - minor = minor_2st; - if (__detect_issues_port(minor_2st) < 0) { - emsg = "detect minor_2st fail"; - goto err_p_detect_issues_port; - } - minor_2st += 8; - } - /* Scan all port */ - for (minor=0; minor:%d\n", __func__, emsg, minor_err); - return -1; -} - - -static int -check_transvr_obj_one(char *dev_name){ - /* [Return] - * 0 : Doesn't need to take care - * -1 : Single error - * -2 : Critical error (I2C topology die) - * -9 : Internal error - */ - struct transvr_obj_s *tobj_p = NULL; - int retval = -9; - - tobj_p = _get_transvr_obj(dev_name); - if (!tobj_p) { - SWPS_ERR("%s: %s _get_transvr_obj fail\n", - __func__, dev_name); - return -9; - } - /* Check transceiver current status */ - lock_transvr_obj(tobj_p); - retval = tobj_p->check(tobj_p); - unlock_transvr_obj(tobj_p); - switch (retval) { - case 0: - case ERR_TRANSVR_UNPLUGGED: - case ERR_TRNASVR_BE_ISOLATED: - case ERR_TRANSVR_TASK_BUSY: - return 0; - - case ERR_TRANSVR_I2C_CRASH: - default: - break; - } - /* Identify abnormal case */ - if (check_channel_tier_1() < 0) { - SWPS_DEBUG("%s: %s critical error :%d\n", - __func__, dev_name, retval); - return -2; - } - SWPS_DEBUG("%s: %s single error :%d\n", - __func__, dev_name, retval); - return -1; -} - - -static int -check_transvr_objs(void){ - - char dev_name[32]; - int port_id, err_code; - int minor_curr = 0; - - for (minor_curr=0; minor_curr:%d\n", - __func__, dev_name, err_code); - break; - } - } - return 0; - -err_check_transvr_objs: - SWPS_ERR("%s: %s reset_i2c_topology fail.\n", - __func__, dev_name); - return -1; -} - - -static void -swp_polling_worker(struct work_struct *work){ - - /* Reset I2C */ - if (flag_i2c_reset) { - goto polling_reset_i2c; - } - /* Check IOEXP */ - if (check_ioexp_objs() < 0) { - goto polling_reset_i2c; - } - /* Check transceiver */ - if (check_transvr_objs() < 0) { - SWPS_DEBUG("%s: check_transvr_objs fail.\n", __func__); - flag_i2c_reset = 1; - } - goto polling_schedule_round; - -polling_reset_i2c: - SWPS_DEBUG("%s: reset_i2c_topology start.\n", __func__); - if (reset_i2c_topology() < 0) { - SWPS_ERR("%s: reset i2c fail!\n", __func__); - flag_i2c_reset = 1; - } else { - SWPS_DEBUG("%s: reset_i2c_topology OK.\n", __func__); - flag_i2c_reset = 0; - } -polling_schedule_round: - schedule_delayed_work(&swp_polling, _get_polling_period()); -} - - -/* ========== Functions for register something ========== - */ -static int -register_transvr_common_attr(struct device *device_p){ - - char *err_attr = NULL; - - if (device_create_file(device_p, &dev_attr_id) < 0) { - err_attr = "dev_attr_id"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_ext_id) < 0) { - err_attr = "dev_attr_ext_id"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_connector) < 0) { - err_attr = "dev_attr_connector"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_vendor_name) < 0) { - err_attr = "dev_attr_vendor_name"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_vendor_pn) < 0) { - err_attr = "dev_attr_vendor_pn"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_vendor_rev) < 0) { - err_attr = "dev_attr_vendor_rev"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_vendor_sn) < 0) { - err_attr = "dev_attr_vendor_sn"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_br) < 0) { - err_attr = "dev_attr_br"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_len_smf) < 0) { - err_attr = "dev_attr_len_smf"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_len_om1) < 0) { - err_attr = "dev_attr_len_om1"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_len_om2) < 0) { - err_attr = "dev_attr_len_om2"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_len_om3) < 0) { - err_attr = "dev_attr_len_om3"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_len_om4) < 0) { - err_attr = "dev_attr_len_om4"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_comp_extend) < 0) { - err_attr = "dev_attr_comp_extend"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_comp_eth) < 0) { - err_attr = "dev_attr_comp_eth"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_comp_rev) < 0) { - err_attr = "dev_attr_comp_rev"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_info) < 0) { - err_attr = "dev_attr_info"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_if_type) < 0) { - err_attr = "dev_attr_if_type"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_if_speed) < 0) { - err_attr = "dev_attr_if_speed"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_if_lane) < 0) { - err_attr = "dev_attr_if_lane"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_temperature) < 0) { - err_attr = "dev_attr_temperature"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_voltage) < 0) { - err_attr = "dev_attr_voltage"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_tx_bias) < 0) { - err_attr = "dev_attr_tx_bias"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_tx_power) < 0) { - err_attr = "dev_attr_tx_power"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_rx_power) < 0) { - err_attr = "dev_attr_rx_power"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_tx_eq) < 0) { - err_attr = "dev_attr_tx_eq"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_rx_em) < 0) { - err_attr = "dev_attr_rx_em"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_wavelength) < 0) { - err_attr = "dev_attr_wavelength"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_eeprom) < 0) { - err_attr = "dev_attr_eeprom"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_uppage) < 0) { - err_attr = "dev_attr_uppage"; - goto err_transvr_comm_attr; - } - return 0; - -err_transvr_comm_attr: - SWPS_ERR("%s: %s\n", __func__, err_attr); - return -1; -} - -static int -register_transvr_sfp_attr(struct device *device_p){ - - char *err_attr = NULL; - - if (register_transvr_common_attr(device_p) < 0) { - err_attr = "register_transvr_common_attr"; - goto err_transvr_sfp_attr; - } - if (device_create_file(device_p, &dev_attr_comp_eth_10) < 0) { - err_attr = "dev_attr_comp_eth_10"; - goto err_transvr_sfp_attr; - } - if (device_create_file(device_p, &dev_attr_len_sm) < 0) { - err_attr = "dev_attr_len_sm"; - goto err_transvr_sfp_attr; - } - if (device_create_file(device_p, &dev_attr_rate_id) < 0) { - err_attr = "dev_attr_rate_id"; - goto err_transvr_sfp_attr; - } - if (device_create_file(device_p, &dev_attr_soft_rs0) < 0) { - err_attr = "dev_attr_soft_rs0"; - goto err_transvr_sfp_attr; - } - if (device_create_file(device_p, &dev_attr_soft_rs1) < 0) { - err_attr = "dev_attr_soft_rs1"; - goto err_transvr_sfp_attr; - } - if (device_create_file(device_p, &dev_attr_extphy_offset) < 0) { - err_attr = "dev_attr_extphy_offset"; - goto err_transvr_sfp_attr; - } - if (device_create_file(device_p, &dev_attr_extphy_reg) < 0) { - err_attr = "dev_attr_extphy_reg"; - goto err_transvr_sfp_attr; - } - return 0; - -err_transvr_sfp_attr: - SWPS_ERR("%s: %s\n", __func__, err_attr); - return -1; -} - - -static int -register_transvr_qsfp_attr(struct device *device_p){ - - char *err_attr = NULL; - - if (register_transvr_common_attr(device_p) < 0) { - err_attr = "register_transvr_common_attr"; - goto err_transvr_qsfp_attr; - } - if (device_create_file(device_p, &dev_attr_comp_eth_10_40) < 0) { - err_attr = "dev_attr_comp_eth_10_40"; - goto err_transvr_qsfp_attr; - } - if (device_create_file(device_p, &dev_attr_power_cls) < 0) { - err_attr = "dev_attr_power_cls"; - goto err_transvr_qsfp_attr; - } - if (device_create_file(device_p, &dev_attr_soft_rx_los) < 0) { - err_attr = "soft_rx_los"; - goto err_transvr_qsfp_attr; - } - if (device_create_file(device_p, &dev_attr_soft_tx_disable) < 0) { - err_attr = "soft_tx_disable"; - goto err_transvr_qsfp_attr; - } - if (device_create_file(device_p, &dev_attr_auto_tx_disable) < 0) { - err_attr = "auto_tx_disable"; - goto err_transvr_qsfp_attr; - } - if (device_create_file(device_p, &dev_attr_soft_tx_fault) < 0) { - err_attr = "soft_tx_fault"; - goto err_transvr_qsfp_attr; - } - return 0; - -err_transvr_qsfp_attr: - SWPS_ERR("%s: %s\n", __func__, err_attr); - return -1; -} - - -static int -register_transvr_qsfp28_attr(struct device *device_p){ - - char *err_attr = NULL; - - if (register_transvr_qsfp_attr(device_p) < 0){ - err_attr = "register_transvr_qsfp_attr"; - goto err_transvr_qsfp28_attr; - } - if (device_create_file(device_p, &dev_attr_cdr) < 0) { - err_attr = "dev_attr_cdr"; - goto err_transvr_qsfp28_attr; - } - if (device_create_file(device_p, &dev_attr_rx_am) < 0) { - err_attr = "dev_attr_rx_am"; - goto err_transvr_qsfp28_attr; - } - return 0; - -err_transvr_qsfp28_attr: - SWPS_ERR("%s: %s\n", __func__, err_attr); - return -1; -} - - -static int -register_transvr_attr(struct device *device_p, - struct transvr_obj_s *transvr_obj){ - - switch (transvr_obj->layout){ - case TRANSVR_TYPE_SFP: - if (register_transvr_sfp_attr(device_p) < 0){ - goto err_reg_tvr_attr; - } - break; - case TRANSVR_TYPE_QSFP: - case TRANSVR_TYPE_QSFP_PLUS: - if (register_transvr_qsfp_attr(device_p) < 0){ - goto err_reg_tvr_attr; - } - break; - case TRANSVR_TYPE_QSFP_28: - if (register_transvr_qsfp28_attr(device_p) < 0){ - goto err_reg_tvr_attr; - } - break; - default: - goto err_reg_tvr_attr; - } - return 0; - -err_reg_tvr_attr: - SWPS_ERR("%s: fail! type=%d \n", __func__, transvr_obj->type); - return -1; -} - - -static int -register_ioexp_attr_sfp_1(struct device *device_p){ - /* Support machine type: - * - SFP : Magnolia - */ - char *err_attr = NULL; - - if (device_create_file(device_p, &dev_attr_present) < 0) { - err_attr = "dev_attr_present"; - goto err_ioexp_sfp1_attr; - } - if (device_create_file(device_p, &dev_attr_tx_fault) < 0) { - err_attr = "dev_attr_tx_fault"; - goto err_ioexp_sfp1_attr; - } - if (device_create_file(device_p, &dev_attr_rxlos) < 0) { - err_attr = "dev_attr_rxlos"; - goto err_ioexp_sfp1_attr; - } - if (device_create_file(device_p, &dev_attr_tx_disable) < 0) { - err_attr = "dev_attr_tx_disable"; - goto err_ioexp_sfp1_attr; - } - return 0; - -err_ioexp_sfp1_attr: - SWPS_ERR("Add device attribute:%s failure! \n",err_attr); - return -1; -} - - -static int -register_ioexp_attr_sfp_2(struct device *device_p){ - /* Support machine type: - * - SFP28 : Cypress - */ - char *err_attr = NULL; - - if (register_ioexp_attr_sfp_1(device_p) < 0){ - goto err_ioexp_sfp2_attr; - } - if (device_create_file(device_p, &dev_attr_hard_rs0) < 0) { - err_attr = "dev_attr_hard_rs0"; - goto err_ioexp_sfp2_attr; - } - if (device_create_file(device_p, &dev_attr_hard_rs1) < 0) { - err_attr = "dev_attr_hard_rs1"; - goto err_ioexp_sfp2_attr; - } - return 0; - -err_ioexp_sfp2_attr: - SWPS_ERR("Add device attribute:%s failure! \n",err_attr); - return -1; -} - - -static int -register_ioexp_attr_qsfp_1(struct device *device_p){ - /* Support machine type: - * - QSFP : Magnolia, Redwood, Hudson32i - * - QSFP+ : Magnolia, Redwood, Hudson32i - * - QSFP28: Redwood - */ - char *err_attr = NULL; - - if (device_create_file(device_p, &dev_attr_present) < 0) { - err_attr = "dev_attr_present"; - goto err_ioexp_qsfp1_attr; - } - if (device_create_file(device_p, &dev_attr_reset) < 0) { - err_attr = "dev_attr_reset"; - goto err_ioexp_qsfp1_attr; - } - if (device_create_file(device_p, &dev_attr_lpmod) < 0) { - err_attr = "dev_attr_lpmod"; - goto err_ioexp_qsfp1_attr; - } - if (device_create_file(device_p, &dev_attr_modsel) < 0) { - err_attr = "dev_attr_modsel"; - goto err_ioexp_qsfp1_attr; - } - return 0; - -err_ioexp_qsfp1_attr: - SWPS_ERR("Add device attribute:%s failure! \n",err_attr); - return -1; -} - - -static int -register_modctl_attr(struct device *device_p){ - - char *err_msg = NULL; - - if (device_create_file(device_p, &dev_attr_platform) < 0) { - err_msg = "dev_attr_platform"; - goto err_reg_modctl_attr; - } - if (device_create_file(device_p, &dev_attr_version) < 0) { - err_msg = "dev_attr_version"; - goto err_reg_modctl_attr; - } - if (device_create_file(device_p, &dev_attr_status) < 0) { - err_msg = "dev_attr_status"; - goto err_reg_modctl_attr; - } - if (device_create_file(device_p, &dev_attr_reset_i2c) < 0) { - err_msg = "dev_attr_reset_i2c"; - goto err_reg_modctl_attr; - } - if (device_create_file(device_p, &dev_attr_reset_swps) < 0) { - err_msg = "dev_attr_reset_swps"; - goto err_reg_modctl_attr; - } - if (device_create_file(device_p, &dev_attr_auto_config) < 0) { - err_msg = "dev_attr_auto_config"; - goto err_reg_modctl_attr; - } - return 0; - -err_reg_modctl_attr: - SWPS_ERR("%s: %s\n", __func__, err_msg); - return -1; -} - - -static int -register_ioexp_attr(struct device *device_p, - struct transvr_obj_s *transvr_obj){ - - char *err_msg = "ERR"; - - switch (transvr_obj->ioexp_obj_p->ioexp_type){ - case IOEXP_TYPE_MAGINOLIA_NAB: - case IOEXP_TYPE_MAGINOLIA_4AB: - case CPLD_TYPE_COTTONWOOD: - if (register_ioexp_attr_sfp_1(device_p) < 0){ - err_msg = "register_ioexp_attr_sfp_1 fail"; - goto err_reg_ioexp_attr; - } - break; - case IOEXP_TYPE_CYPRESS_NABC: - if (register_ioexp_attr_sfp_2(device_p) < 0){ - err_msg = "register_ioexp_attr_sfp_2 fail"; - goto err_reg_ioexp_attr; - } - break; - case IOEXP_TYPE_MAGINOLIA_7AB: - case IOEXP_TYPE_SPRUCE_7AB: - case IOEXP_TYPE_CYPRESS_7ABC: - case IOEXP_TYPE_REDWOOD_P01P08: - case IOEXP_TYPE_REDWOOD_P09P16: - case IOEXP_TYPE_HUDSON32IGA_P01P08: - case IOEXP_TYPE_HUDSON32IGA_P09P16: - case IOEXP_TYPE_TAHOE_5A: - case IOEXP_TYPE_TAHOE_6ABC: - case IOEXP_TYPE_SEQUOIA_NABC: - case IOEXP_TYPE_LAVENDER_P65: - if (register_ioexp_attr_qsfp_1(device_p) < 0){ - err_msg = "register_ioexp_attr_qsfp_1 fail"; - goto err_reg_ioexp_attr; - } - break; - - default: - err_msg = "Unknow type"; - goto err_reg_ioexp_attr; - } - return 0; - -err_reg_ioexp_attr: - SWPS_ERR("%s: %s :%d \n", - __func__, err_msg, transvr_obj->ioexp_obj_p->ioexp_type); - return -1; -} - - -static int -register_modctl_device(void) { - - struct device *device_p = NULL; - int minor_comm = 0; /* Default minor number for common device */ - dev_t dev_num = MKDEV(ctl_major, minor_comm); - char *err_msg = "ERROR"; - - device_p = device_create(swp_class_p, /* struct class *cls */ - NULL, /* struct device *parent */ - dev_num, /* dev_t devt */ - NULL, /* void *private_data */ - SWP_DEV_MODCTL); /* const char *fmt */ - if (IS_ERR(device_p)){ - err_msg = "device_create fail"; - goto err_register_modctl_device_1; - } - if (register_modctl_attr(device_p) < 0) { - err_msg = "register_modctl_attr fail"; - goto err_register_modctl_device_2; - } - return 0; - -err_register_modctl_device_2: - device_unregister(device_p); - device_destroy(swp_class_p, dev_num); -err_register_modctl_device_1: - SWPS_ERR("%s: %s\n", __func__, err_msg); - return -1; -} - - -static int -register_port_device(char *dev_name, - dev_t dev_num, - struct transvr_obj_s *transvr_obj){ - - struct device *device_p = NULL; - device_p = device_create(swp_class_p, /* struct class *cls */ - NULL, /* struct device *parent */ - dev_num, /* dev_t devt */ - transvr_obj, /* void *private_data */ - dev_name); /* const char *fmt */ - if (IS_ERR(device_p)){ - goto err_regswp_create_dev; - } - if (register_transvr_attr(device_p, transvr_obj) < 0){ - goto err_regswp_reg_attr; - } - if (register_ioexp_attr(device_p, transvr_obj) < 0){ - goto err_regswp_reg_attr; - } - return 0; - -err_regswp_reg_attr: - device_unregister(device_p); - device_destroy(swp_class_p, dev_num); -err_regswp_create_dev: - SWPS_ERR("%s fail! :%s\n", __func__, dev_name); - return -1; -} - - -static int -register_swp_module(void){ - - dev_t ctl_devt = 0; - dev_t port_devt = 0; - int dev_total = port_total + 1; /* char_dev for module control */ - - /* Register device number */ - if (alloc_chrdev_region(&ctl_devt, 0, 1, SWP_DEV_MODCTL) < 0){ - SWPS_WARN("Allocate CTL MAJOR failure! \n"); - goto err_register_swp_module_1; - } - if (alloc_chrdev_region(&port_devt, 0, dev_total, SWP_CLS_NAME) < 0){ - SWPS_WARN("Allocate PORT MAJOR failure! \n"); - goto err_register_swp_module_2; - } - ctl_major = MAJOR(ctl_devt); - port_major = MAJOR(port_devt); - - /* Create class object */ - swp_class_p = class_create(THIS_MODULE, SWP_CLS_NAME); - if (IS_ERR(swp_class_p)) { - SWPS_ERR("Create class failure! \n"); - goto err_register_swp_module_3; - } - return 0; - -err_register_swp_module_3: - unregister_chrdev_region(MKDEV(port_major, 0), port_total); -err_register_swp_module_2: - unregister_chrdev_region(MKDEV(ctl_major, 0), 1); -err_register_swp_module_1: - return -1; -} - - -/* ========== Module initial relate ========== - */ -static int -create_ioexp_objs(void) { - - int i, run_mod; - - /* Clean IOEXP object */ - clean_ioexp_objs(); - /* Get running mode */ - run_mod = IOEXP_MODE_DIRECT; - if (SWP_POLLING_ENABLE){ - run_mod = IOEXP_MODE_POLLING; - } - /* Create IOEXP object */ - for(i=0; i devlen_max) { - snprintf(err_msg, sizeof(err_msg), - "SWP_DEV_PORT too long!"); - goto err_initport_create_tranobj; - } - memset(dev_name, 0, sizeof(dev_name)); - snprintf(dev_name, devlen_max, "%s%d", SWP_DEV_PORT, port_id); - /* Create transceiver object */ - ioexp_obj_p = get_ioexp_obj(ioexp_id); - if (!ioexp_obj_p){ - snprintf(err_msg, sizeof(err_msg), - "IOEXP object:%d not exist", ioexp_id); - goto err_initport_create_tranobj; - } - transvr_obj_p = create_transvr_obj(dev_name, chan_id, ioexp_obj_p, - ioexp_virt_offset, transvr_type, - chipset_type, run_mod); - if (!transvr_obj_p){ - snprintf(err_msg, sizeof(err_msg), - "Create transceiver object fail :%s", dev_name); - goto err_initport_create_tranobj; - } - /* Setup Lane_ID mapping */ - i = ARRAY_SIZE(port_layout[minor_curr].lane_id); - j = ARRAY_SIZE(transvr_obj_p->lane_id); - if (i != j) { - snprintf(err_msg, sizeof(err_msg), - "Lane_id size inconsistent %d/%d", i, j); - goto err_initport_reg_device; - } - memcpy(transvr_obj_p->lane_id, port_layout[minor_curr].lane_id, i*sizeof(int)); - /* Create and register device object */ - if (register_port_device(dev_name, MKDEV(port_major, minor_curr), transvr_obj_p) < 0){ - snprintf(err_msg, sizeof(err_msg), - "register_port_device fail"); - goto err_initport_reg_device; - } - /* Setup device_ptr of transvr_obj */ - dev_p = get_swpdev_by_name(dev_name); - if (!dev_p){ - snprintf(err_msg, sizeof(err_msg), - "get_swpdev_by_name fail"); - goto err_initport_reg_device; - } - transvr_obj_p->transvr_dev_p = dev_p; - /* Success */ - ok_count++; - } - SWPS_INFO("%s: initialed %d port-dev",__func__, ok_count); - return 0; - -err_initport_reg_device: - kfree(transvr_obj_p); -err_initport_create_tranobj: - clean_port_obj(); - SWPS_ERR("%s: %s", __func__, err_msg); - SWPS_ERR("Dump: :%d :%d :%d :%d :%d :%d\n", - port_id, chan_id, ioexp_id, ioexp_virt_offset, transvr_type, run_mod); - return -1; -} - - -static int -init_dev_topology(void){ - - int err; - char *emsg = "ERR"; - flag_mod_state = SWP_STATE_NORMAL; - - err = init_ioexp_objs(); - switch(err){ - case 0: /* Normal */ - SWPS_DEBUG("%s: normal case\n", __func__); - break; - - case -1: /* topology error */ - SWPS_DEBUG("%s: detect tier-1 topology initial failure :%d\n", - __func__, err); - /* Reset and isolate */ - err = reset_i2c_topology(); - if (err < 0) { - emsg = "reset i2c topology fail"; - goto err_init_dev_topology; - } - /* Re-initial again */ - err = init_ioexp_objs(); - if (err < 0) { - emsg = "re-init ioexp objects fail"; - goto err_init_dev_topology; - } - break; - - case -2: /* Internal error */ - SWPS_DEBUG("%s: internal error case\n", __func__); - err = -2; - emsg = "internal error"; - goto err_init_dev_topology; - - default: - SWPS_DEBUG("%s: undefined error case\n", __func__); - emsg = "undefined error case"; - goto err_init_dev_topology; - } - SWPS_DEBUG("%s: initial I2C topology success\n", __func__); - return 0; - -err_init_dev_topology: - SWPS_ERR("%s: %s :%d\n", __func__, emsg, err); - return -1; -} - - -static int -init_polling_task(void){ - - if (SWP_POLLING_ENABLE){ - schedule_delayed_work(&swp_polling, _get_polling_period()); - } - return 0; -} - - -static int -init_swps_common(void){ - - char *err_msg = "ERR"; - - auto_config = 0; - if ((SWP_AUTOCONFIG_ENABLE) && (SWP_POLLING_ENABLE)){ - auto_config = 1; - } - if (register_modctl_device() < 0) { - err_msg = "register_modctl_device fail"; - goto err_init_swps_common_1; - } - if (_update_auto_config_2_trnasvr() < 0) { - err_msg = "_update_auto_config_2_trnasvr fail"; - goto err_init_swps_common_1; - } - if (init_polling_task() < 0){ - err_msg = "init_polling_task fail"; - goto err_init_swps_common_1; - } - return 0; - -err_init_swps_common_1: - clean_swps_common(); - SWPS_ERR("%s: %s\n", __func__, err_msg); - return -1; -} - - -static int __init -swp_module_init(void){ - - if (get_platform_type() < 0){ - goto err_init_out; - } - if (get_layout_info() < 0){ - goto err_init_out; - } - if (register_swp_module() < 0){ - goto err_init_out; - } - if (create_ioexp_objs() < 0){ - goto err_init_ioexp; - } - if (create_port_objs() < 0){ - goto err_init_portobj; - } - if (init_mux_gpio(gpio_rest_mux) < 0){ - goto err_init_mux; - } - if (init_dev_topology() < 0){ - goto err_init_topology; - } - if (init_swps_common() < 0){ - goto err_init_topology; - } - SWPS_INFO("Inventec switch-port module V.%s initial success.\n", SWP_VERSION); - return 0; - - -err_init_topology: - clean_mux_gpio(); -err_init_mux: - clean_port_obj(); -err_init_portobj: - clean_ioexp_objs(); -err_init_ioexp: - class_unregister(swp_class_p); - class_destroy(swp_class_p); - unregister_chrdev_region(MKDEV(ctl_major, 0), 1); - unregister_chrdev_region(MKDEV(port_major, 0), port_total); -err_init_out: - SWPS_ERR("Inventec switch-port module V.%s initial failure.\n", SWP_VERSION); - return -1; -} - - -static void __exit -swp_module_exit(void){ - - clean_swps_common(); - clean_port_obj(); - clean_ioexp_objs(); - clean_mux_gpio(); - class_unregister(swp_class_p); - class_destroy(swp_class_p); - unregister_chrdev_region(MKDEV(ctl_major, 0), 1); - unregister_chrdev_region(MKDEV(port_major, 0), port_total); - SWPS_INFO("Remove Inventec switch-port module success.\n"); -} - - -/* Module information */ -MODULE_AUTHOR(SWP_AUTHOR); -MODULE_DESCRIPTION(SWP_DESC); -MODULE_VERSION(SWP_VERSION); -MODULE_LICENSE(SWP_LICENSE); - -module_init(swp_module_init); -module_exit(swp_module_exit); - - - - - - - - - diff --git a/packages/platforms/inventec/x86-64/d5052/modules/builds/src/inv_swps.h b/packages/platforms/inventec/x86-64/d5052/modules/builds/src/inv_swps.h deleted file mode 100644 index ee0ae8dd0..000000000 --- a/packages/platforms/inventec/x86-64/d5052/modules/builds/src/inv_swps.h +++ /dev/null @@ -1,1052 +0,0 @@ -#ifndef INV_SWPS_H -#define INV_SWPS_H - -#include "transceiver.h" -#include "io_expander.h" -#include "inv_mux.h" - -/* Module settings */ -#define SWP_CLS_NAME "swps" -#define SWP_DEV_PORT "port" -#define SWP_DEV_MODCTL "module" -#define SWP_RESET_PWD "inventec" -#define SWP_POLLING_PERIOD (300) /* msec */ -#define SWP_POLLING_ENABLE (1) -#define SWP_AUTOCONFIG_ENABLE (1) - -/* Module information */ -#define SWP_AUTHOR "Neil " -#define SWP_DESC "Inventec port and transceiver driver" -#define SWP_VERSION "4.2.8" -#define SWP_LICENSE "GPL" - -/* Module status define */ -#define SWP_STATE_NORMAL (0) -#define SWP_STATE_I2C_DIE (-91) - -/* [Note]: - * Functions and mechanism for auto-detect platform type is ready, - * But HW and BIOS not ready! We need to wait them. - * So, please do not use PLATFORM_TYPE_AUTO until they are ready. - * (2016.06.13) - */ -#define PLATFORM_TYPE_AUTO (100) -#define PLATFORM_TYPE_MAGNOLIA (111) -#define PLATFORM_TYPE_MAGNOLIA_FNC (112) -#define PLATFORM_TYPE_REDWOOD (121) -#define PLATFORM_TYPE_REDWOOD_FSL (122) -#define PLATFORM_TYPE_HUDSON32I_GA (131) -#define PLATFORM_TYPE_SPRUCE (141) -#define PLATFORM_TYPE_CYPRESS_GA1 (151) /* Up -> Down */ -#define PLATFORM_TYPE_CYPRESS_GA2 (152) /* Down -> Up */ -#define PLATFORM_TYPE_CYPRESS_BAI (153) /* Down -> Up */ -#define PLATFORM_TYPE_TAHOE (161) -#define PLATFORM_TYPE_SEQUOIA_GA (171) -#define PLATFORM_TYPE_LAVENDER_GA (181) -#define PLATFORM_TYPE_LAVENDER_ONL (182) -#define PLATFORM_TYPE_COTTONWOOD_RANGELEY (191) -/* Current running platfrom */ -#define PLATFORM_SETTINGS PLATFORM_TYPE_COTTONWOOD_RANGELEY - -/* Define platform flag and kernel version */ -#if (PLATFORM_SETTINGS == PLATFORM_TYPE_MAGNOLIA) - #define SWPS_MAGNOLIA (1) - #define SWPS_KERN_VER_BF_3_8 (1) -#elif (PLATFORM_SETTINGS == PLATFORM_TYPE_MAGNOLIA_FNC) - #define SWPS_MAGNOLIA (1) - #define SWPS_KERN_VER_AF_3_10 (1) -#elif (PLATFORM_SETTINGS == PLATFORM_TYPE_REDWOOD) - #define SWPS_REDWOOD (1) - #define SWPS_KERN_VER_BF_3_8 (1) -#elif (PLATFORM_SETTINGS == PLATFORM_TYPE_REDWOOD_FSL) - #define SWPS_REDWOOD_FSL (1) - #define SWPS_KERN_VER_BF_3_8 (1) -#elif (PLATFORM_SETTINGS == PLATFORM_TYPE_HUDSON32I_GA) - #define SWPS_HUDSON32I_GA (1) - #define SWPS_KERN_VER_BF_3_8 (1) -#elif (PLATFORM_SETTINGS == PLATFORM_TYPE_SPRUCE) - #define SWPS_SPRUCE (1) - #define SWPS_KERN_VER_BF_3_8 (1) -#elif (PLATFORM_SETTINGS == PLATFORM_TYPE_CYPRESS_GA1) - #define SWPS_CYPRESS_GA1 (1) - #define SWPS_KERN_VER_BF_3_8 (1) -#elif (PLATFORM_SETTINGS == PLATFORM_TYPE_CYPRESS_GA2) - #define SWPS_CYPRESS_GA2 (1) - #define SWPS_KERN_VER_BF_3_8 (1) -#elif (PLATFORM_SETTINGS == PLATFORM_TYPE_CYPRESS_BAI) - #define SWPS_CYPRESS_BAI (1) - #define SWPS_KERN_VER_AF_3_10 (1) -#elif (PLATFORM_SETTINGS == PLATFORM_TYPE_TAHOE) - #define SWPS_TAHOE (1) - #define SWPS_KERN_VER_AF_3_10 (1) -#elif (PLATFORM_SETTINGS == PLATFORM_TYPE_SEQUOIA_GA) - #define SWPS_SEQUOIA (1) - #define SWPS_KERN_VER_BF_3_8 (1) -#elif (PLATFORM_SETTINGS == PLATFORM_TYPE_LAVENDER_GA) - #define SWPS_LAVENDER (1) - #define SWPS_KERN_VER_AF_3_10 (1) -#elif (PLATFORM_SETTINGS == PLATFORM_TYPE_LAVENDER_ONL) - #define SWPS_LAVENDER (1) - #define SWPS_KERN_VER_AF_3_10 (1) -#elif (PLATFORM_SETTINGS == PLATFORM_TYPE_COTTONWOOD_RANGELEY) - #define SWPS_COTTONWOOD_RANGELEY (1) - #define SWPS_KERN_VER_AF_4_4 (1) -#endif - - -struct inv_platform_s { - int id; - char name[64]; -}; - -struct inv_ioexp_layout_s { - int ioexp_id; - int ioexp_type; - struct ioexp_addr_s addr[4]; -}; - -struct inv_port_layout_s { - int port_id; - int chan_id; - int ioexp_id; - int ioexp_offset; - int transvr_type; - int chipset_type; - int lane_id[8]; -}; - - -/* ========================================== - * Inventec Platform Settings - * ========================================== - */ -struct inv_platform_s platform_map[] = { - {PLATFORM_TYPE_AUTO, "Auto-Detect" }, - {PLATFORM_TYPE_MAGNOLIA, "Magnolia" }, - {PLATFORM_TYPE_MAGNOLIA_FNC, "Magnolia_FNC" }, - {PLATFORM_TYPE_REDWOOD, "Redwood" }, - {PLATFORM_TYPE_REDWOOD_FSL, "Redwood_FSL" }, - {PLATFORM_TYPE_HUDSON32I_GA, "Hudson32i" }, - {PLATFORM_TYPE_SPRUCE, "Spruce" }, - {PLATFORM_TYPE_CYPRESS_GA1, "Cypress_GA1" }, - {PLATFORM_TYPE_CYPRESS_GA2, "Cypress_GA2" }, - {PLATFORM_TYPE_CYPRESS_BAI, "Cypress_BAI" }, - {PLATFORM_TYPE_TAHOE, "Tahoe" }, - {PLATFORM_TYPE_SEQUOIA_GA, "Sequoia_GA" }, - {PLATFORM_TYPE_LAVENDER_GA, "Lavender_GA" }, - {PLATFORM_TYPE_LAVENDER_ONL, "Lavender_ONL" }, - {PLATFORM_TYPE_COTTONWOOD_RANGELEY, "Cottonwood_RANGELEY" }, -}; - - -/* ========================================== - * Magnolia Layout configuration - * ========================================== - */ -#ifdef SWPS_MAGNOLIA -unsigned magnolia_gpio_rest_mux = MUX_RST_GPIO_48_PAC9548; - -struct inv_ioexp_layout_s magnolia_ioexp_layout[] = { - /* IOEXP_ID / IOEXP_TYPE / { Chan_ID, Chip_addr, Read_offset, Write_offset, config_offset, data_default, conf_default } */ - {0, IOEXP_TYPE_MAGINOLIA_NAB, { {2, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {2, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, }, /* addr[1] = I/O Expander N B */ - }, - {1, IOEXP_TYPE_MAGINOLIA_NAB, { {3, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {3, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, }, /* addr[1] = I/O Expander N B */ - }, - {2, IOEXP_TYPE_MAGINOLIA_NAB, { {4, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {4, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, }, /* addr[1] = I/O Expander N B */ - }, - {3, IOEXP_TYPE_MAGINOLIA_4AB, { {5, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander 4 A */ - {5, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xf0, 0xff}, {0xf0, 0xff}, }, }, /* addr[1] = I/O Expander 4 B */ - }, - {4, IOEXP_TYPE_MAGINOLIA_NAB, { {6, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {6, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, }, /* addr[1] = I/O Expander N B */ - }, - {5, IOEXP_TYPE_MAGINOLIA_NAB, { {7, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {7, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, }, /* addr[1] = I/O Expander N B */ - }, - {6, IOEXP_TYPE_MAGINOLIA_7AB, { {8, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[0] = I/O Expander 7 A */ - {8, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xf0, 0x33}, }, }, /* addr[1] = I/O Expander 7 B */ - }, -}; - -struct inv_port_layout_s magnolia_port_layout[] = { - /* Port_ID / Chan_ID / IOEXP_ID / IOEXP_VIRT_OFFSET / TRANSCEIVER_TYPE / BCM_CHIP_TYPE / LANE_ID */ - { 0, 10, 0, 0, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 16} }, - { 1, 11, 0, 1, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 15} }, - { 2, 12, 0, 2, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 14} }, - { 3, 13, 0, 3, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 13} }, - { 4, 14, 0, 4, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 24} }, - { 5, 15, 0, 5, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 23} }, - { 6, 16, 0, 6, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 22} }, - { 7, 17, 0, 7, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 21} }, - { 8, 18, 1, 0, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 28} }, - { 9, 19, 1, 1, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 27} }, - {10, 20, 1, 2, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 26} }, - {11, 21, 1, 3, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 25} }, - {12, 22, 1, 4, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 32} }, - {13, 23, 1, 5, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 31} }, - {14, 24, 1, 6, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 30} }, - {15, 25, 1, 7, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 29} }, - {16, 26, 2, 0, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 48} }, - {17, 27, 2, 1, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 47} }, - {18, 28, 2, 2, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 46} }, - {19, 29, 2, 3, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 45} }, - {20, 30, 2, 4, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 52} }, - {21, 31, 2, 5, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 51} }, - {22, 32, 2, 6, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 50} }, - {23, 33, 2, 7, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 49} }, - {24, 34, 3, 0, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 56} }, - {25, 35, 3, 1, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 55} }, - {26, 36, 3, 2, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 54} }, - {27, 37, 3, 3, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 53} }, - {28, 38, 3, 4, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 60} }, - {29, 39, 3, 5, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 59} }, - {30, 40, 3, 6, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 58} }, - {31, 41, 3, 7, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 57} }, - {32, 42, 4, 0, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 64} }, - {33, 43, 4, 1, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 63} }, - {34, 44, 4, 2, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 62} }, - {35, 45, 4, 3, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 61} }, - {36, 46, 4, 4, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 68} }, - {37, 47, 4, 5, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 67} }, - {38, 48, 4, 6, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 66} }, - {39, 49, 4, 7, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 65} }, - {40, 50, 5, 0, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 72} }, - {41, 51, 5, 1, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 71} }, - {42, 52, 5, 2, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 70} }, - {43, 53, 5, 3, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 69} }, - {44, 54, 5, 4, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 76} }, - {45, 55, 5, 5, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 75} }, - {46, 56, 5, 6, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 74} }, - {47, 57, 5, 7, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 73} }, - {48, 58, 6, 0, TRANSVR_TYPE_QSFP, BCM_CHIP_TYPE_TRIDENT_2, { 81, 82, 83, 84} }, - {49, 59, 6, 1, TRANSVR_TYPE_QSFP, BCM_CHIP_TYPE_TRIDENT_2, { 77, 78, 79, 80} }, - {50, 60, 6, 2, TRANSVR_TYPE_QSFP, BCM_CHIP_TYPE_TRIDENT_2, { 97, 98, 99,100} }, - {51, 61, 6, 3, TRANSVR_TYPE_QSFP, BCM_CHIP_TYPE_TRIDENT_2, {101,102,103,104} }, - {52, 62, 6, 4, TRANSVR_TYPE_QSFP, BCM_CHIP_TYPE_TRIDENT_2, {105,106,107,108} }, - {53, 63, 6, 5, TRANSVR_TYPE_QSFP, BCM_CHIP_TYPE_TRIDENT_2, {109,110,111,112} }, -}; -#endif - - -/* ========================================== - * Redwood Layout configuration - * ========================================== - */ -#ifdef SWPS_REDWOOD -unsigned redwood_gpio_rest_mux = MUX_RST_GPIO_48_PAC9548; - -struct inv_ioexp_layout_s redwood_ioexp_layout[] = { - /* IOEXP_ID / IOEXP_TYPE / { Chan_ID, Chip_addr, Read_offset, Write_offset, config_offset, data_default, conf_default } */ - {0, IOEXP_TYPE_REDWOOD_P01P08, { {4, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[0] = I/O Expander 1-4 A */ - {4, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[1] = I/O Expander 1-4 B */ - {0, 0x25, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 5 B */ - }, - {1, IOEXP_TYPE_REDWOOD_P09P16, { {5, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[0] = I/O Expander 1-4 A */ - {5, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[1] = I/O Expander 1-4 B */ - {0, 0x25, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 5 B */ - }, - {2, IOEXP_TYPE_REDWOOD_P01P08, { {2, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[0] = I/O Expander 1-4 A */ - {2, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[1] = I/O Expander 1-4 B */ - {0, 0x24, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 5 B */ - }, - {3, IOEXP_TYPE_REDWOOD_P09P16, { {3, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[0] = I/O Expander 1-4 A */ - {3, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[1] = I/O Expander 1-4 B */ - {0, 0x24, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 5 B */ - }, -}; - -struct inv_port_layout_s redwood_port_layout[] = { - /* Port_ID / Chan_ID / IOEXP_ID / IOEXP_VIRT_OFFSET / TRANSCEIVER_TYPE / BCM_CHIP_TYPE / LANE_ID */ - { 0, 22, 0, 0, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 1, 2, 3, 4} }, - { 1, 23, 0, 1, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 5, 6, 7, 8} }, - { 2, 24, 0, 2, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 9, 10, 11, 12} }, - { 3, 25, 0, 3, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 13, 14, 15, 16} }, - { 4, 26, 0, 4, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 17, 18, 19, 20} }, - { 5, 27, 0, 5, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 21, 22, 23, 24} }, - { 6, 28, 0, 6, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 25, 26, 27, 28} }, - { 7, 29, 0, 7, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 29, 30, 31, 32} }, - { 8, 30, 1, 0, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 33, 34, 35, 36} }, - { 9, 31, 1, 1, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 37, 38, 39, 40} }, - {10, 32, 1, 2, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 41, 42, 43, 44} }, - {11, 33, 1, 3, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 45, 46, 47, 48} }, - {12, 34, 1, 4, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 49, 50, 51, 52} }, - {13, 35, 1, 5, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 53, 54, 55, 56} }, - {14, 36, 1, 6, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 57, 58, 59, 60} }, - {15, 37, 1, 7, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 61, 62, 63, 64} }, - {16, 6, 2, 0, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 65, 66, 67, 68} }, - {17, 7, 2, 1, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 69, 70, 71, 72} }, - {18, 8, 2, 2, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 73, 74, 75, 76} }, - {19, 9, 2, 3, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 77, 78, 79, 80} }, - {20, 10, 2, 4, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 81, 82, 83, 84} }, - {21, 11, 2, 5, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 85, 86, 87, 88} }, - {22, 12, 2, 6, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 89, 90, 91, 92} }, - {23, 13, 2, 7, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 93, 94, 95, 96} }, - {24, 14, 3, 0, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 97, 98, 99,100} }, - {25, 15, 3, 1, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {101,102,103,104} }, - {26, 16, 3, 2, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {105,106,107,108} }, - {27, 17, 3, 3, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {109,110,111,112} }, - {28, 18, 3, 4, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {113,114,115,116} }, - {29, 19, 3, 5, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {117,118,119,120} }, - {30, 20, 3, 6, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {121,122,123,124} }, - {31, 21, 3, 7, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {125,126,127,128} }, -}; -#endif - - -/* ========================================== - * Hudson32i Layout configuration - * ========================================== - */ -#ifdef SWPS_HUDSON32I_GA -unsigned hudsin32iga_gpio_rest_mux = MUX_RST_GPIO_48_PAC9548; - -struct inv_ioexp_layout_s hudson32iga_ioexp_layout[] = { - /* IOEXP_ID / IOEXP_TYPE / { Chan_ID, Chip_addr, Read_offset, Write_offset, config_offset, data_default, conf_default } */ - {0, IOEXP_TYPE_HUDSON32IGA_P01P08, { {2, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[0] = I/O Expander A */ - {2, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[1] = I/O Expander B */ - {0, 0x24, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 0x24 */ - }, - {1, IOEXP_TYPE_HUDSON32IGA_P09P16, { {3, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[0] = I/O Expander A */ - {3, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[1] = I/O Expander B */ - {0, 0x24, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 0x24 */ - }, - {2, IOEXP_TYPE_HUDSON32IGA_P01P08, { {4, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[0] = I/O Expander A */ - {4, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[1] = I/O Expander B */ - {0, 0x25, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 0x25 */ - }, - {3, IOEXP_TYPE_HUDSON32IGA_P09P16, { {5, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[0] = I/O Expander A */ - {5, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[1] = I/O Expander B */ - {0, 0x25, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 0x25 */ - }, -}; - -struct inv_port_layout_s hudson32iga_port_layout[] = { - /* Port_ID / Chan_ID / IOEXP_ID / IOEXP_VIRT_OFFSET / TRANSCEIVER_TYPE / BCM_CHIP_TYPE / LANE_ID */ - { 0, 6, 0, 0, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, { 1, 2, 3, 4} }, - { 1, 7, 0, 1, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, { 5, 6, 7, 8} }, - { 2, 8, 0, 2, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, { 9, 10, 11, 12} }, - { 3, 9, 0, 3, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, { 13, 14, 15, 16} }, - { 4, 10, 0, 4, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, { 17, 18, 19, 20} }, - { 5, 11, 0, 5, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, { 21, 22, 23, 24} }, - { 6, 12, 0, 6, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, { 25, 26, 27, 28} }, - { 7, 13, 0, 7, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, { 29, 30, 31, 32} }, - { 8, 14, 1, 0, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, { 33, 34, 35, 36} }, - { 9, 15, 1, 1, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, { 37, 38, 39, 40} }, - {10, 16, 1, 2, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, { 41, 42, 43, 44} }, - {11, 17, 1, 3, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, { 45, 46, 47, 48} }, - {12, 18, 1, 4, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, { 49, 50, 51, 52} }, - {13, 19, 1, 5, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, { 53, 54, 55, 56} }, - {14, 20, 1, 6, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, { 57, 58, 59, 60} }, - {15, 21, 1, 7, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, { 61, 62, 63, 64} }, - {16, 22, 2, 0, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, { 65, 66, 67, 68} }, - {17, 23, 2, 1, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, { 69, 70, 71, 72} }, - {18, 24, 2, 2, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, { 73, 74, 75, 76} }, - {19, 25, 2, 3, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, { 77, 78, 79, 80} }, - {20, 26, 2, 4, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, { 81, 82, 83, 84} }, - {21, 27, 2, 5, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, { 85, 86, 87, 88} }, - {22, 28, 2, 6, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, { 89, 90, 91, 92} }, - {23, 29, 2, 7, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, { 93, 94, 95, 96} }, - {24, 30, 3, 0, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, { 97, 98, 99,100} }, - {25, 31, 3, 1, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, {101,102,103,104} }, - {26, 32, 3, 2, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, {105,106,107,108} }, - {27, 33, 3, 3, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, {109,110,111,112} }, - {28, 34, 3, 4, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, {113,114,115,116} }, - {29, 35, 3, 5, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, {117,118,119,120} }, - {30, 36, 3, 6, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, {121,122,123,124} }, - {31, 37, 3, 7, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, {125,126,127,128} }, -}; -#endif - - -/* ========================================== - * Spruce Layout configuration - * ========================================== - */ -#ifdef SWPS_SPRUCE -unsigned spruce_gpio_rest_mux = MUX_RST_GPIO_48_PAC9548; - -struct inv_ioexp_layout_s spruce_ioexp_layout[] = { - /* IOEXP_ID / IOEXP_TYPE / { Chan_ID, Chip_addr, Read_offset, Write_offset, config_offset, data_default, conf_default } */ - {0, IOEXP_TYPE_SPRUCE_7AB, { {2, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[0] = I/O Expander 7A */ - {2, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xf0, 0x33}, }, }, /* addr[2] = I/O Expander 7B */ - }, -}; - -struct inv_port_layout_s spruce_port_layout[] = { - /* Port_ID / Chan_ID / IOEXP_ID / IOEXP_VIRT_OFFSET / TRANSCEIVER_TYPE / BCM_CHIP_TYPE / LANE_ID */ - { 0, 6, 0, 0, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, { 81, 82, 83, 84} }, - { 1, 7, 0, 1, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, { 77, 78, 79, 80} }, - { 2, 8, 0, 2, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, { 97, 98, 99,100} }, - { 3, 9, 0, 3, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, {101,102,103,104} }, - { 4, 10, 0, 4, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, {105,106,107,108} }, - { 5, 11, 0, 5, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, {109,110,111,112} }, -}; -#endif - - -/* ========================================== - * Cypress Layout configuration (Inventec version [Up->Down]) - * ========================================== - */ -#ifdef SWPS_CYPRESS_GA1 -unsigned cypress_ga1_gpio_rest_mux = MUX_RST_GPIO_69_PAC9548; - -struct inv_ioexp_layout_s cypress_ga1_ioexp_layout[] = { - /* IOEXP_ID / IOEXP_TYPE / { Chan_ID, Chip_addr, Read_offset, Write_offset, config_offset, data_default, conf_default } */ - {0, IOEXP_TYPE_CYPRESS_NABC, { {2, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {2, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {2, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {1, IOEXP_TYPE_CYPRESS_NABC, { {3, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {3, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {3, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {2, IOEXP_TYPE_CYPRESS_NABC, { {4, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {4, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {4, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {3, IOEXP_TYPE_CYPRESS_NABC, { {5, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {5, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {5, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {4, IOEXP_TYPE_CYPRESS_NABC, { {6, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {6, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {6, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {5, IOEXP_TYPE_CYPRESS_NABC, { {7, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {7, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {7, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {6, IOEXP_TYPE_CYPRESS_7ABC, { {8, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xc0, 0xc0}, }, /* addr[0] = I/O Expander 7 A */ - {8, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xc0, 0xc0}, {0xff, 0xc0}, }, /* addr[1] = I/O Expander 7 B */ - {8, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 7 C */ - }, -}; - -struct inv_port_layout_s cypress_ga1_port_layout[] = { - /* Port_ID / Chan_ID / IOEXP_ID / IOEXP_VIRT_OFFSET / TRANSCEIVER_TYPE / BCM_CHIP_TYPE / LANE_ID */ - { 0, 10, 0, 0, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 1} }, - { 1, 11, 0, 1, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 2} }, - { 2, 12, 0, 2, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 3} }, - { 3, 13, 0, 3, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 4} }, - { 4, 14, 0, 4, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 5} }, - { 5, 15, 0, 5, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 6} }, - { 6, 16, 0, 6, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 7} }, - { 7, 17, 0, 7, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 8} }, - { 8, 18, 1, 0, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 9} }, - { 9, 19, 1, 1, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 10} }, - {10, 20, 1, 2, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 11} }, - {11, 21, 1, 3, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 12} }, - {12, 22, 1, 4, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 21} }, - {13, 23, 1, 5, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 22} }, - {14, 24, 1, 6, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 23} }, - {15, 25, 1, 7, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 24} }, - {16, 26, 2, 0, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 33} }, - {17, 27, 2, 1, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 34} }, - {18, 28, 2, 2, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 35} }, - {19, 29, 2, 3, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 36} }, - {20, 30, 2, 4, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 37} }, - {21, 31, 2, 5, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 38} }, - {22, 32, 2, 6, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 39} }, - {23, 33, 2, 7, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 40} }, - {24, 34, 3, 0, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 41} }, - {25, 35, 3, 1, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 42} }, - {26, 36, 3, 2, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 43} }, - {27, 37, 3, 3, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 44} }, - {28, 38, 3, 4, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 49} }, - {29, 39, 3, 5, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 50} }, - {30, 40, 3, 6, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 51} }, - {31, 41, 3, 7, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 52} }, - {32, 42, 4, 0, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 53} }, - {33, 43, 4, 1, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 54} }, - {34, 44, 4, 2, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 55} }, - {35, 45, 4, 3, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 56} }, - {36, 46, 4, 4, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 65} }, - {37, 47, 4, 5, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 66} }, - {38, 48, 4, 6, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 67} }, - {39, 49, 4, 7, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 68} }, - {40, 50, 5, 0, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 69} }, - {41, 51, 5, 1, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 70} }, - {42, 52, 5, 2, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 71} }, - {43, 53, 5, 3, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 72} }, - {44, 54, 5, 4, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 81} }, - {45, 55, 5, 5, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 82} }, - {46, 56, 5, 6, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 83} }, - {47, 57, 5, 7, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 84} }, - {48, 58, 6, 0, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 97, 98, 99,100} }, - {49, 59, 6, 1, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 85, 86, 87, 88} }, - {50, 60, 6, 2, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {101,102,103,104} }, - {51, 61, 6, 3, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {105,106,107,108} }, - {52, 62, 6, 4, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {109,110,111,112} }, - {53, 63, 6, 5, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {117,118,119,120} }, -}; -#endif - - -/* ========================================== - * Cypress Layout configuration (Inventec version [Down->Up]) - * ========================================== - */ -#ifdef SWPS_CYPRESS_GA2 -unsigned cypress_ga2_gpio_rest_mux = MUX_RST_GPIO_FORCE_HEDERA; - -struct inv_ioexp_layout_s cypress_ga2_ioexp_layout[] = { - /* IOEXP_ID / IOEXP_TYPE / { Chan_ID, Chip_addr, Read_offset, Write_offset, config_offset, data_default, conf_default } */ - {0, IOEXP_TYPE_CYPRESS_NABC, { {2, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {2, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {2, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {1, IOEXP_TYPE_CYPRESS_NABC, { {3, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {3, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {3, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {2, IOEXP_TYPE_CYPRESS_NABC, { {4, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {4, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {4, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {3, IOEXP_TYPE_CYPRESS_NABC, { {5, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {5, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {5, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {4, IOEXP_TYPE_CYPRESS_NABC, { {6, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {6, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {6, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {5, IOEXP_TYPE_CYPRESS_NABC, { {7, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {7, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {7, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {6, IOEXP_TYPE_CYPRESS_7ABC, { {8, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xc0, 0xc0}, }, /* addr[0] = I/O Expander 7 A */ - {8, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xc0, 0xc0}, {0xff, 0xc0}, }, /* addr[1] = I/O Expander 7 B */ - {8, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 7 C */ - }, -}; - -struct inv_port_layout_s cypress_ga2_port_layout[] = { - /* Port_ID / Chan_ID / IOEXP_ID / IOEXP_VIRT_OFFSET / TRANSCEIVER_TYPE / BCM_CHIP_TYPE / LANE_ID */ - { 0, 11, 0, 1, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 2} }, - { 1, 10, 0, 0, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 1} }, - { 2, 13, 0, 3, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 4} }, - { 3, 12, 0, 2, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 3} }, - { 4, 15, 0, 5, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 6} }, - { 5, 14, 0, 4, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 5} }, - { 6, 17, 0, 7, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 8} }, - { 7, 16, 0, 6, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 7} }, - { 8, 19, 1, 1, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 10} }, - { 9, 18, 1, 0, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 9} }, - {10, 21, 1, 3, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 12} }, - {11, 20, 1, 2, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 11} }, - {12, 23, 1, 5, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 22} }, - {13, 22, 1, 4, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 21} }, - {14, 25, 1, 7, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 24} }, - {15, 24, 1, 6, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 23} }, - {16, 27, 2, 1, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 34} }, - {17, 26, 2, 0, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 33} }, - {18, 29, 2, 3, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 36} }, - {19, 28, 2, 2, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 35} }, - {20, 31, 2, 5, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 38} }, - {21, 30, 2, 4, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 37} }, - {22, 33, 2, 7, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 40} }, - {23, 32, 2, 6, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 39} }, - {24, 35, 3, 1, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 42} }, - {25, 34, 3, 0, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 41} }, - {26, 37, 3, 3, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 44} }, - {27, 36, 3, 2, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 43} }, - {28, 39, 3, 5, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 50} }, - {29, 38, 3, 4, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 49} }, - {30, 41, 3, 7, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 52} }, - {31, 40, 3, 6, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 51} }, - {32, 43, 4, 1, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 54} }, - {33, 42, 4, 0, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 53} }, - {34, 45, 4, 3, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 56} }, - {35, 44, 4, 2, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 55} }, - {36, 47, 4, 5, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 66} }, - {37, 46, 4, 4, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 65} }, - {38, 49, 4, 7, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 68} }, - {39, 48, 4, 6, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 67} }, - {40, 51, 5, 1, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 70} }, - {41, 50, 5, 0, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 69} }, - {42, 53, 5, 3, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 72} }, - {43, 52, 5, 2, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 71} }, - {44, 55, 5, 5, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 82} }, - {45, 54, 5, 4, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 81} }, - {46, 57, 5, 7, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 84} }, - {47, 56, 5, 6, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 83} }, - {48, 59, 6, 1, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 85, 86, 87, 88} }, - {49, 58, 6, 0, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 97, 98, 99,100} }, - {50, 61, 6, 3, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {105,106,107,108} }, - {51, 60, 6, 2, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {101,102,103,104} }, - {52, 63, 6, 5, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {117,118,119,120} }, - {53, 62, 6, 4, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {109,110,111,112} }, -}; -#endif - - -/* ========================================== - * Cypress Layout configuration (BaiDu version) - * ========================================== - */ -#ifdef SWPS_CYPRESS_BAI -unsigned cypress_b_gpio_rest_mux = MUX_RST_GPIO_FORCE_HEDERA; - -struct inv_ioexp_layout_s cypress_b_ioexp_layout[] = { - /* IOEXP_ID / IOEXP_TYPE / { Chan_ID, Chip_addr, Read_offset, Write_offset, config_offset, data_default, conf_default } */ - {0, IOEXP_TYPE_CYPRESS_NABC, { {2, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {2, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {2, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {1, IOEXP_TYPE_CYPRESS_NABC, { {3, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {3, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {3, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {2, IOEXP_TYPE_CYPRESS_NABC, { {4, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {4, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {4, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {3, IOEXP_TYPE_CYPRESS_NABC, { {5, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {5, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {5, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {4, IOEXP_TYPE_CYPRESS_NABC, { {6, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {6, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {6, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {5, IOEXP_TYPE_CYPRESS_NABC, { {7, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {7, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {7, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {6, IOEXP_TYPE_CYPRESS_7ABC, { {8, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xc0, 0xc0}, }, /* addr[0] = I/O Expander 7 A */ - {8, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xc0, 0xc0}, {0xff, 0xc0}, }, /* addr[1] = I/O Expander 7 B */ - {8, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 7 C */ - }, -}; - -struct inv_port_layout_s cypress_b_port_layout[] = { - /* Port_ID / Chan_ID / IOEXP_ID / IOEXP_VIRT_OFFSET / TRANSCEIVER_TYPE / BCM_CHIP_TYPE / LANE_ID */ - { 1, 11, 0, 1, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 2} }, - { 2, 10, 0, 0, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 1} }, - { 3, 13, 0, 3, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 4} }, - { 4, 12, 0, 2, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 3} }, - { 5, 15, 0, 5, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 6} }, - { 6, 14, 0, 4, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 5} }, - { 7, 17, 0, 7, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 8} }, - { 8, 16, 0, 6, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 7} }, - { 9, 19, 1, 1, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 10} }, - {10, 18, 1, 0, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 9} }, - {11, 21, 1, 3, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 12} }, - {12, 20, 1, 2, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 11} }, - {13, 23, 1, 5, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 22} }, - {14, 22, 1, 4, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 21} }, - {15, 25, 1, 7, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 24} }, - {16, 24, 1, 6, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 23} }, - {17, 27, 2, 1, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 34} }, - {18, 26, 2, 0, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 33} }, - {19, 29, 2, 3, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 36} }, - {20, 28, 2, 2, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 35} }, - {21, 31, 2, 5, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 38} }, - {22, 30, 2, 4, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 37} }, - {23, 33, 2, 7, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 40} }, - {24, 32, 2, 6, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 39} }, - {25, 35, 3, 1, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 42} }, - {26, 34, 3, 0, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 41} }, - {27, 37, 3, 3, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 44} }, - {28, 36, 3, 2, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 43} }, - {29, 39, 3, 5, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 50} }, - {30, 38, 3, 4, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 49} }, - {31, 41, 3, 7, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 52} }, - {32, 40, 3, 6, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 51} }, - {33, 43, 4, 1, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 54} }, - {34, 42, 4, 0, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 53} }, - {35, 45, 4, 3, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 56} }, - {36, 44, 4, 2, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 55} }, - {37, 47, 4, 5, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 66} }, - {38, 46, 4, 4, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 65} }, - {39, 49, 4, 7, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 68} }, - {40, 48, 4, 6, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 67} }, - {41, 51, 5, 1, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 70} }, - {42, 50, 5, 0, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 69} }, - {43, 53, 5, 3, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 72} }, - {44, 52, 5, 2, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 71} }, - {45, 55, 5, 5, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 82} }, - {46, 54, 5, 4, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 81} }, - {47, 57, 5, 7, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 84} }, - {48, 56, 5, 6, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 83} }, - {49, 59, 6, 1, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 85, 86, 87, 88} }, - {50, 58, 6, 0, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 97, 98, 99,100} }, - {51, 61, 6, 3, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {105,106,107,108} }, - {52, 60, 6, 2, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {101,102,103,104} }, - {53, 63, 6, 5, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {117,118,119,120} }, - {54, 62, 6, 4, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {109,110,111,112} }, -}; -#endif - - -/* ========================================== - * Redwood_fsl Layout configuration - * ========================================== - */ -#ifdef SWPS_REDWOOD_FSL -unsigned redwood_fsl_gpio_rest_mux = MUX_RST_GPIO_48_PAC9548; - -struct inv_ioexp_layout_s redwood_fsl_ioexp_layout[] = { - /* IOEXP_ID / IOEXP_TYPE / { Chan_ID, Chip_addr, Read_offset, Write_offset, config_offset, data_default, conf_default } */ - {0, IOEXP_TYPE_REDWOOD_P01P08, { {4, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[0] = I/O Expander 1-4 A */ - {4, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[1] = I/O Expander 1-4 B */ - {0, 0x25, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 5 B */ - }, - {1, IOEXP_TYPE_REDWOOD_P09P16, { {5, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[0] = I/O Expander 1-4 A */ - {5, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[1] = I/O Expander 1-4 B */ - {0, 0x25, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 5 B */ - }, - {2, IOEXP_TYPE_REDWOOD_P01P08, { {2, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[0] = I/O Expander 1-4 A */ - {2, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[1] = I/O Expander 1-4 B */ - {0, 0x24, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 5 B */ - }, - {3, IOEXP_TYPE_REDWOOD_P09P16, { {3, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[0] = I/O Expander 1-4 A */ - {3, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[1] = I/O Expander 1-4 B */ - {0, 0x24, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 5 B */ - }, -}; - - -struct inv_port_layout_s redwood_fsl_port_layout[] = { - /* Port_ID / Chan_ID / IOEXP_ID / IOEXP_VIRT_OFFSET / TRANSCEIVER_TYPE / BCM_CHIP_TYPE / LANE_ID */ - { 0, 22, 0, 0, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 1, 2, 3, 4} }, - { 1, 23, 0, 1, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 5, 6, 7, 8} }, - { 2, 24, 0, 2, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 9, 10, 11, 12} }, - { 3, 25, 0, 3, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 13, 14, 15, 16} }, - { 4, 26, 0, 4, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 17, 18, 19, 20} }, - { 5, 27, 0, 5, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 21, 22, 23, 24} }, - { 6, 28, 0, 6, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 25, 26, 27, 28} }, - { 7, 29, 0, 7, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 29, 30, 31, 32} }, - { 8, 30, 1, 0, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 33, 34, 35, 36} }, - { 9, 31, 1, 1, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 37, 38, 39, 40} }, - {10, 32, 1, 2, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 41, 42, 43, 44} }, - {11, 33, 1, 3, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 45, 46, 47, 48} }, - {12, 34, 1, 4, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 49, 50, 51, 52} }, - {13, 35, 1, 5, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 53, 54, 55, 56} }, - {14, 36, 1, 6, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 57, 58, 59, 60} }, - {15, 37, 1, 7, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 61, 62, 63, 64} }, - {16, 6, 2, 0, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 65, 66, 67, 68} }, - {17, 7, 2, 1, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 69, 70, 71, 72} }, - {18, 8, 2, 2, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 73, 74, 75, 76} }, - {19, 9, 2, 3, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 77, 78, 79, 80} }, - {20, 10, 2, 4, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 81, 82, 83, 84} }, - {21, 11, 2, 5, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 85, 86, 87, 88} }, - {22, 12, 2, 6, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 89, 90, 91, 92} }, - {23, 13, 2, 7, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 93, 94, 95, 96} }, - {24, 14, 3, 0, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 97, 98, 99,100} }, - {25, 15, 3, 1, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {101,102,103,104} }, - {26, 16, 3, 2, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {105,106,107,108} }, - {27, 17, 3, 3, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {109,110,111,112} }, - {28, 18, 3, 4, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {113,114,115,116} }, - {29, 19, 3, 5, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {117,118,119,120} }, - {30, 20, 3, 6, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {121,122,123,124} }, - {31, 21, 3, 7, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {125,126,127,128} }, -}; -#endif - - -/* ========================================== - * Tahoe Layout configuration - * ========================================== - */ -#ifdef SWPS_TAHOE -unsigned tahoe_gpio_rest_mux = MUX_RST_GPIO_249_PCA9548; - -struct inv_ioexp_layout_s tahoe_ioexp_layout[] = { - /* IOEXP_ID / IOEXP_TYPE / { Chan_ID, Chip_addr, Read_offset, Write_offset, config_offset, data_default, conf_default } */ - {0, IOEXP_TYPE_TAHOE_6ABC, { {7, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xce, 0xb9}, {0x18, 0xe3}, }, /* addr[0] = I/O Expander 6 A */ - {7, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xce, 0xb9}, {0x18, 0xe3}, }, /* addr[1] = I/O Expander 6 B */ - {7, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xce, 0xb9}, {0x18, 0xe3}, }, }, /* addr[2] = I/O Expander 6 C */ - }, - {1, IOEXP_TYPE_TAHOE_5A, { {6, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xce, 0xb9}, {0x18, 0xe3}, }, }, /* addr[0] = I/O Expander 5 A */ - }, -}; - - -struct inv_port_layout_s tahoe_port_layout[] = { - /* Port_ID / Chan_ID / IOEXP_ID / IOEXP_VIRT_OFFSET / TRANSCEIVER_TYPE / BCM_CHIP_TYPE / LANE_ID */ - { 0, 12, 1, 2, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 65, 66, 67, 68} }, - { 1, 11, 1, 1, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 53, 54, 55, 56} }, - { 2, 22, 0, 5, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 69, 70, 71, 72} }, - { 3, 21, 0, 4, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 81, 82, 83, 84} }, - { 4, 24, 0, 7, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 97, 98, 99, 100} }, - { 5, 23, 0, 6, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 85, 86, 87, 88} }, - { 6, 18, 0, 1, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {101, 102, 103, 104} }, - { 7, 17, 0, 0, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {105, 106, 107, 108} }, - { 8, 20, 0, 3, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {113, 114, 115, 116} }, - { 9, 19, 0, 2, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {109, 110, 111, 112} }, -}; -#endif - - -/* ========================================== - * Sequoia Layout configuration - * ========================================== - */ -#ifdef SWPS_SEQUOIA -unsigned sequoia_gpio_rest_mux = MUX_RST_GPIO_69_PAC9548; - -struct inv_ioexp_layout_s sequoia_ioexp_layout[] = { - /* IOEXP_ID / IOEXP_TYPE / { Chan_ID, Chip_addr, Read_offset, Write_offset, config_offset, data_default, conf_default } */ - {0, IOEXP_TYPE_SEQUOIA_NABC, { {1, 0x20, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0x00, 0x00}, }, /* addr[0] = I/O Expander 0 A */ - {1, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0xff}, }, /* addr[1] = I/O Expander 0 B */ - {1, 0x22, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 0 C */ - }, - {1, IOEXP_TYPE_SEQUOIA_NABC, { {2, 0x20, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0x00, 0x00}, }, /* addr[0] = I/O Expander 1 A */ - {2, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0xff}, }, /* addr[1] = I/O Expander 1 B */ - {2, 0x22, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 1 C */ - }, - {2, IOEXP_TYPE_SEQUOIA_NABC, { {3, 0x20, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0x00, 0x00}, }, /* addr[0] = I/O Expander 2 A */ - {3, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0xff}, }, /* addr[1] = I/O Expander 2 B */ - {3, 0x22, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 2 C */ - }, - {3, IOEXP_TYPE_SEQUOIA_NABC, { {4, 0x20, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0x00, 0x00}, }, /* addr[0] = I/O Expander 3 A */ - {4, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0xff}, }, /* addr[1] = I/O Expander 3 B */ - {4, 0x22, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 3 C */ - }, - {4, IOEXP_TYPE_SEQUOIA_NABC, { {5, 0x20, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0x00, 0x00}, }, /* addr[0] = I/O Expander 4 A */ - {5, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0xff}, }, /* addr[1] = I/O Expander 4 B */ - {5, 0x22, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 4 C */ - }, - {5, IOEXP_TYPE_SEQUOIA_NABC, { {6, 0x20, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0x00, 0x00}, }, /* addr[0] = I/O Expander 5 A */ - {6, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0xff}, }, /* addr[1] = I/O Expander 5 B */ - {6, 0x22, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 5 C */ - }, - {6, IOEXP_TYPE_SEQUOIA_NABC, { {7, 0x20, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0x00, 0x00}, }, /* addr[0] = I/O Expander 6 A */ - {7, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0xff}, }, /* addr[1] = I/O Expander 6 B */ - {7, 0x22, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 6 C */ - }, - {7, IOEXP_TYPE_SEQUOIA_NABC, { {8, 0x20, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0x00, 0x00}, }, /* addr[0] = I/O Expander 7 A */ - {8, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0xff}, }, /* addr[1] = I/O Expander 7 B */ - {8, 0x22, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 7 C */ - }, -}; - - -struct inv_port_layout_s sequoia_port_layout[] = { - /* Port_ID / Chan_ID / IOEXP_ID / IOEXP_VIRT_OFFSET / TRANSCEIVER_TYPE / BCM_CHIP_TYPE / LANE_ID */ - { 0, 9, 0, 0, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 9, 10, 11, 12} }, - { 1, 10, 0, 1, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 1, 2, 3, 4} }, - { 2, 11, 0, 2, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 25, 26, 27, 28} }, - { 3, 12, 0, 3, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 17, 18, 19, 20} }, - { 4, 13, 0, 4, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 41, 42, 43, 44} }, - { 5, 14, 0, 5, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 33, 34, 35, 36} }, - { 6, 15, 0, 6, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 57, 58, 59, 60} }, - { 7, 16, 0, 7, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 49, 50, 51, 52} }, - { 8, 17, 1, 0, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 73, 74, 75, 76} }, - { 9, 18, 1, 1, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 65, 66, 67, 68} }, - {10, 19, 1, 2, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 89, 90, 91, 92} }, - {11, 20, 1, 3, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 81, 82, 83, 84} }, - {12, 21, 1, 4, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {105, 106, 107, 108} }, - {13, 22, 1, 5, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 97, 98, 99, 100} }, - {14, 23, 1, 6, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {121, 122, 123, 124} }, - {15, 24, 1, 7, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {113, 114, 115, 116} }, - {16, 25, 2, 0, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {137, 138, 139, 140} }, - {17, 26, 2, 1, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {129, 130, 131, 132} }, - {18, 27, 2, 2, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {153, 154, 155, 156} }, - {19, 28, 2, 3, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {145, 146, 147, 148} }, - {20, 29, 2, 4, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {169, 170, 171, 172} }, - {21, 30, 2, 5, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {161, 162, 163, 164} }, - {22, 31, 2, 6, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {185, 186, 187, 188} }, - {23, 32, 2, 7, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {177, 178, 179, 180} }, - {24, 33, 3, 0, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {201, 202, 203, 204} }, - {25, 34, 3, 1, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {193, 194, 195, 196} }, - {26, 35, 3, 2, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {217, 218, 219, 220} }, - {27, 36, 3, 3, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {209, 210, 211, 212} }, - {28, 37, 3, 4, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {233, 234, 235, 236} }, - {29, 38, 3, 5, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {225, 226, 227, 228} }, - {30, 39, 3, 6, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {249, 250, 251, 252} }, - {31, 40, 3, 7, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {241, 242, 243, 244} }, - {32, 44, 4, 3, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 13, 14, 15, 16} }, - {33, 43, 4, 2, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 5, 6, 7, 8} }, - {34, 42, 4, 1, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 29, 30, 31, 32} }, - {35, 41, 4, 0, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 21, 22, 23, 24} }, - {36, 48, 4, 7, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 45, 46, 47, 48} }, - {37, 47, 4, 6, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 37, 38, 39, 40} }, - {38, 46, 4, 5, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 61, 62, 63, 64} }, - {39, 45, 4, 4, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 53, 54, 55, 56} }, - {40, 52, 5, 3, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 77, 78, 79, 80} }, - {41, 51, 5, 2, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 69, 70, 71, 72} }, - {42, 50, 5, 1, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 93, 94, 95, 96} }, - {43, 49, 5, 0, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 85, 86, 87, 88} }, - {44, 56, 5, 7, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {109, 110, 111, 112} }, - {45, 55, 5, 6, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {101, 102, 103, 104} }, - {46, 54, 5, 5, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {125, 126, 127, 128} }, - {47, 53, 5, 4, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {117, 118, 119, 120} }, - {48, 60, 6, 3, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {141, 142, 143, 144} }, - {49, 59, 6, 2, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {133, 134, 135, 136} }, - {50, 58, 6, 1, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {157, 158, 159, 160} }, - {51, 57, 6, 0, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {149, 150, 151, 152} }, - {52, 64, 6, 7, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {173, 174, 175, 176} }, - {53, 63, 6, 6, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {165, 166, 167, 168} }, - {54, 62, 6, 5, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {189, 190, 191, 192} }, - {55, 61, 6, 4, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {181, 182, 183, 184} }, - {56, 68, 7, 3, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {205, 206, 207, 208} }, - {57, 67, 7, 2, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {197, 198, 199, 200} }, - {58, 66, 7, 1, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {221, 222, 223, 224} }, - {59, 65, 7, 0, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {213, 214, 215, 216} }, - {60, 72, 7, 7, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {237, 238, 239, 240} }, - {61, 71, 7, 6, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {229, 230, 231, 232} }, - {62, 70, 7, 5, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {253, 254, 255, 256} }, - {63, 69, 7, 4, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {245, 246, 247, 248} }, -}; -#endif - - -/* ========================================== - * Lavender Layout configuration - * ========================================== - */ -#if (PLATFORM_SETTINGS == PLATFORM_TYPE_LAVENDER_GA) -unsigned lavender_gpio_rest_mux = MUX_RST_GPIO_505_PCA9548; -#elif (PLATFORM_SETTINGS == PLATFORM_TYPE_LAVENDER_ONL) -unsigned lavender_gpio_rest_mux = MUX_RST_GPIO_69_PAC9548; -#endif - -#ifdef SWPS_LAVENDER -struct inv_ioexp_layout_s lavender_ioexp_layout[] = { - /* IOEXP_ID / IOEXP_TYPE / { Chan_ID, Chip_addr, Read_offset, Write_offset, config_offset, data_default, conf_default } */ - {0, IOEXP_TYPE_SEQUOIA_NABC, { { 1, 0x20, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0x00, 0x00}, }, /* addr[0] = I/O Expander 0 A */ - { 1, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0xff}, }, /* addr[1] = I/O Expander 0 B */ - { 1, 0x22, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 0 C */ - }, - {1, IOEXP_TYPE_SEQUOIA_NABC, { { 2, 0x20, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0x00, 0x00}, }, /* addr[0] = I/O Expander 1 A */ - { 2, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0xff}, }, /* addr[1] = I/O Expander 1 B */ - { 2, 0x22, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 1 C */ - }, - {2, IOEXP_TYPE_SEQUOIA_NABC, { { 3, 0x20, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0x00, 0x00}, }, /* addr[0] = I/O Expander 2 A */ - { 3, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0xff}, }, /* addr[1] = I/O Expander 2 B */ - { 3, 0x22, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 2 C */ - }, - {3, IOEXP_TYPE_SEQUOIA_NABC, { { 4, 0x20, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0x00, 0x00}, }, /* addr[0] = I/O Expander 3 A */ - { 4, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0xff}, }, /* addr[1] = I/O Expander 3 B */ - { 4, 0x22, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 3 C */ - }, - {4, IOEXP_TYPE_SEQUOIA_NABC, { { 9, 0x20, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0x00, 0x00}, }, /* addr[0] = I/O Expander 4 A */ - { 9, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0xff}, }, /* addr[1] = I/O Expander 4 B */ - { 9, 0x22, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 4 C */ - }, - {5, IOEXP_TYPE_SEQUOIA_NABC, { {10, 0x20, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0x00, 0x00}, }, /* addr[0] = I/O Expander 5 A */ - {10, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0xff}, }, /* addr[1] = I/O Expander 5 B */ - {10, 0x22, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 5 C */ - }, - {6, IOEXP_TYPE_SEQUOIA_NABC, { {11, 0x20, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0x00, 0x00}, }, /* addr[0] = I/O Expander 6 A */ - {11, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0xff}, }, /* addr[1] = I/O Expander 6 B */ - {11, 0x22, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 6 C */ - }, - {7, IOEXP_TYPE_SEQUOIA_NABC, { {12, 0x20, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0x00, 0x00}, }, /* addr[0] = I/O Expander 7 A */ - {12, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0xff}, }, /* addr[1] = I/O Expander 7 B */ - {12, 0x22, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 7 C */ - }, - {8, IOEXP_TYPE_LAVENDER_P65, { { 5, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xF6, 0xff}, {0xF8, 0xff}, }, }, /* addr[0] = I/O Expander CPU */ - }, -}; - - -struct inv_port_layout_s lavender_port_layout[] = { - /* Port_ID / Chan_ID / IOEXP_ID / IOEXP_VIRT_OFFSET / TRANSCEIVER_TYPE / BCM_CHIP_TYPE / LANE_ID */ - { 0, 17, 0, 0, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, {188, 189, 190, 191} }, - { 1, 18, 0, 1, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, {184, 185, 186, 187} }, - { 2, 19, 0, 2, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, {180, 181, 182, 183} }, - { 3, 20, 0, 3, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, {176, 177, 178, 179} }, - { 4, 21, 0, 4, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, {172, 173, 174, 175} }, - { 5, 22, 0, 5, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, {168, 169, 170, 171} }, - { 6, 23, 0, 6, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, {164, 165, 166, 167} }, - { 7, 24, 0, 7, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, {160, 161, 162, 163} }, - { 8, 25, 1, 0, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, {156, 157, 158, 159} }, - { 9, 26, 1, 1, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, {152, 153, 154, 155} }, - {10, 27, 1, 2, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, {148, 149, 150, 151} }, - {11, 28, 1, 3, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, {144, 145, 146, 147} }, - {12, 29, 1, 4, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, {140, 141, 142, 143} }, - {13, 30, 1, 5, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, {136, 137, 138, 139} }, - {14, 31, 1, 6, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, {132, 133, 134, 135} }, - {15, 32, 1, 7, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, {128, 129, 130, 131} }, - {16, 33, 2, 0, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, { 0, 1, 2, 3} }, - {17, 34, 2, 1, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, { 4, 5, 6, 7} }, - {18, 35, 2, 2, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, { 8, 9, 10, 11} }, - {19, 36, 2, 3, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, { 12, 13, 14, 15} }, - {20, 37, 2, 4, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, { 16, 17, 18, 19} }, - {21, 38, 2, 5, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, { 20, 21, 22, 23} }, - {22, 39, 2, 6, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, { 24, 25, 26, 27} }, - {23, 40, 2, 7, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, { 28, 29, 30, 31} }, - {24, 41, 3, 0, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, { 32, 33, 34, 35} }, - {25, 42, 3, 1, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, { 36, 37, 38, 39} }, - {26, 43, 3, 2, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, { 40, 41, 42, 43} }, - {27, 44, 3, 3, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, { 44, 45, 46, 47} }, - {28, 45, 3, 4, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, { 48, 49, 50, 51} }, - {29, 46, 3, 5, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, { 52, 53, 54, 55} }, - {30, 47, 3, 6, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, { 56, 57, 58, 59} }, - {31, 48, 3, 7, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, { 60, 61, 62, 63} }, - {32, 49, 4, 0, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, {256, 257, 258, 259} }, - {33, 50, 4, 1, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, {260, 261, 262, 263} }, - {34, 51, 4, 2, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, {264, 265, 266, 267} }, - {35, 52, 4, 3, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, {268, 269, 270, 271} }, - {36, 53, 4, 4, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, {272, 273, 274, 275} }, - {37, 54, 4, 5, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, {276, 277, 278, 279} }, - {38, 55, 4, 6, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, {280, 281, 282, 283} }, - {39, 56, 4, 7, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, {284, 285, 286, 287} }, - {40, 57, 5, 0, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, {288, 289, 290, 291} }, - {41, 58, 5, 1, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, {292, 293, 294, 295} }, - {42, 59, 5, 2, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, {296, 297, 298, 299} }, - {43, 60, 5, 3, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, {300, 301, 302, 303} }, - {44, 61, 5, 4, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, {304, 305, 306, 307} }, - {45, 62, 5, 5, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, {308, 309, 310, 311} }, - {46, 63, 5, 6, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, {312, 313, 314, 315} }, - {47, 64, 5, 7, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, {316, 317, 318, 319} }, - {48, 65, 6, 0, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, {444, 445, 446, 447} }, - {49, 66, 6, 1, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, {440, 441, 442, 443} }, - {50, 67, 6, 2, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, {436, 437, 438, 439} }, - {51, 68, 6, 3, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, {432, 433, 434, 435} }, - {52, 69, 6, 4, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, {428, 429, 430, 431} }, - {53, 70, 6, 5, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, {424, 425, 426, 427} }, - {54, 71, 6, 6, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, {420, 421, 422, 423} }, - {55, 72, 6, 7, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, {416, 417, 418, 419} }, - {56, 73, 7, 0, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, {412, 413, 414, 415} }, - {57, 74, 7, 1, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, {408, 409, 410, 411} }, - {58, 75, 7, 2, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, {404, 405, 406, 407} }, - {59, 76, 7, 3, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, {400, 401, 402, 403} }, - {60, 77, 7, 4, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, {396, 397, 398, 399} }, - {61, 78, 7, 5, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, {392, 393, 394, 395} }, - {62, 79, 7, 6, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, {388, 389, 390, 391} }, - {63, 80, 7, 7, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, {384, 385, 386, 387} }, - {64, 5, 8, 0, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, { 64, 65, 66, 67} }, -}; -#endif - -/* =========================================================== - * Cottonwood Layout configuration Rangeley (Rangeley CPU board) - * =========================================================== - */ -#ifdef SWPS_COTTONWOOD_RANGELEY -unsigned cottonwood_rangeley_gpio_rest_mux = MUX_RST_GPIO_500_PAC9548; - -struct inv_ioexp_layout_s cottonwood_rangeley_ioexp_layout[] = { - /* IOEXP_ID / IOEXP_TYPE / { Chan_ID, Chip_addr, Read_offset, Write_offset, config_offset, data_default, conf_default } */ - {0, CPLD_TYPE_COTTONWOOD,{ {1, 0x55, {22, 23, 24, 25}, {22, 23, 24, 25}, {-1, -1, -1, -1}, {0xee, 0xee, 0x99, 0x99}, {0x00, 0x00, 0x00, 0x00}, }, - }, - }, -}; - - -struct inv_port_layout_s cottonwood_rangeley_port_layout[] = { - /* Port_ID / Chan_ID / IOEXP_ID / IOEXP_VIRT_OFFSET / TRANSCEIVER_TYPE / BCM_CHI_TYPE / LANE_ID */ - { 0, 2, 0, 0, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 75} }, - { 1, 3, 0, 1, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 77} }, - { 2, 4, 0, 2, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 79} }, - { 3, 5, 0, 3, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 81} }, -}; -#endif - -#endif /* INV_SWPS_H */ - - - - - - - diff --git a/packages/platforms/inventec/x86-64/d5052/modules/builds/src/inv_vpd.c b/packages/platforms/inventec/x86-64/d5052/modules/builds/src/inv_vpd.c deleted file mode 100644 index b6d755e1d..000000000 --- a/packages/platforms/inventec/x86-64/d5052/modules/builds/src/inv_vpd.c +++ /dev/null @@ -1,338 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "inv_vpd.h" -#include "onie_tlvinfo.h" - -static int vpd_major; -static struct class *vpd_class_p = NULL; -static char cEeprom[SYS_EEPROM_MAX_SIZE]; -static DEFINE_MUTEX(vpd_mutex); - -static int -__swp_match(struct device *dev, -#ifdef VPD_KERN_VER_AF_3_10 - - const void *data){ -#else - void *data){ -#endif - - char *name = (char *)data; - if (strcmp(dev_name(dev), name) == 0) - return 1; - return 0; -} - -static -int get_vpd_data(struct i2c_client *pi2c_client, int i_offset, char *c_buf) -{ - int iRet; - - read_eeprom( pi2c_client, cEeprom); - iRet = tlvinfo_decode_tlv(cEeprom, i_offset,c_buf); - return iRet; -} - -static -int write_vpd_data(struct i2c_client *pi2c_client, int i_offset, char *c_buf) -{ - int iErr = 0; - - if (read_eeprom(pi2c_client, cEeprom)) { - printk(KERN_ERR "write vpd data eror at %d-%s\n", __LINE__, __FUNCTION__); - return -1; - } - - if (tlvinfo_delete_tlv(cEeprom, i_offset) == TRUE) { - } - if (c_buf) { - if(!tlvinfo_add_tlv(cEeprom, i_offset , c_buf)) { - printk(KERN_ERR "write vpd data eror at %d-%s\n", __LINE__, __FUNCTION__); - iErr = -1; - } else { - iErr = prog_eeprom(pi2c_client,cEeprom); - } - } - return iErr; -} - -static struct device * -get_swpdev_by_name(char *name){ - struct device *dev = class_find_device(vpd_class_p, - NULL, - name, - __swp_match); - return dev; -} - -static ssize_t -store_attr_vpd(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - struct i2c_client *pi2c_client = dev_get_drvdata(dev_p); - struct vpd_device_attribute *attr = to_vpd_dev_attr(attr_p); - int iOffset = attr->index; - int iErr , iLen; - char *pChar; - - if (!pi2c_client){ - return -ENODEV; - } - mutex_lock(&vpd_mutex); - - //-strip 0x0a in the last byte. - for (iLen = 0, pChar = buf_p; - iLen < 255 && *pChar != 0; - iLen++, pChar++) ; - if (iLen !=0 && *pChar == 0 && *(pChar-1) == 0x0a) - *(pChar - 1) = 0; - //- - - iErr = write_vpd_data( pi2c_client, iOffset, buf_p); - - mutex_unlock(&vpd_mutex); - return count; -} - -static ssize_t -show_attr_vpd(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct i2c_client *pi2c_client = dev_get_drvdata(dev_p); - struct vpd_device_attribute *attr = to_vpd_dev_attr(attr_p); - int iOffset = attr->index; - int iErr , iLen; - - if (!pi2c_client){ - return -ENODEV; - } - mutex_lock(&vpd_mutex); - iErr = get_vpd_data( pi2c_client, iOffset, buf_p); - mutex_unlock(&vpd_mutex); - - if( iErr <= 0 ) - iLen = 0; - else - iLen = snprintf(buf_p, TLV_DECODE_VALUE_MAX_LEN, "%s\n", buf_p); - - return iLen; -} - -/* ================= Vpd attribute ======================== - */ -static VPD_DEVICE_ATTR(product_name ,S_IWUSR|S_IRUGO, show_attr_vpd, store_attr_vpd, TLV_CODE_PRODUCT_NAME ); -static VPD_DEVICE_ATTR(pn ,S_IWUSR|S_IRUGO, show_attr_vpd, store_attr_vpd, TLV_CODE_PART_NUMBER ); -static VPD_DEVICE_ATTR(sn ,S_IWUSR|S_IRUGO, show_attr_vpd, store_attr_vpd, TLV_CODE_SERIAL_NUMBER ); -static VPD_DEVICE_ATTR(base_mac_addr,S_IWUSR|S_IRUGO, show_attr_vpd, store_attr_vpd, TLV_CODE_MAC_BASE ); -static VPD_DEVICE_ATTR(man_date ,S_IWUSR|S_IRUGO, show_attr_vpd, store_attr_vpd, TLV_CODE_MANUF_DATE ); -static VPD_DEVICE_ATTR(dev_ver ,S_IWUSR|S_IRUGO, show_attr_vpd, store_attr_vpd, TLV_CODE_DEVICE_VERSION ); -static VPD_DEVICE_ATTR(label_rev ,S_IWUSR|S_IRUGO, show_attr_vpd, store_attr_vpd, TLV_CODE_LABEL_REVISION ); -static VPD_DEVICE_ATTR(plat_name ,S_IWUSR|S_IRUGO, show_attr_vpd, store_attr_vpd, TLV_CODE_PLATFORM_NAME ); -static VPD_DEVICE_ATTR(ldr_ver ,S_IWUSR|S_IRUGO, show_attr_vpd, store_attr_vpd, TLV_CODE_ONIE_VERSION ); -static VPD_DEVICE_ATTR(mac_addr ,S_IWUSR|S_IRUGO, show_attr_vpd, store_attr_vpd, TLV_CODE_MAC_SIZE ); -static VPD_DEVICE_ATTR(manufacturer ,S_IWUSR|S_IRUGO, show_attr_vpd, store_attr_vpd, TLV_CODE_MANUF_NAME ); -static VPD_DEVICE_ATTR(country_code ,S_IWUSR|S_IRUGO, show_attr_vpd, store_attr_vpd, TLV_CODE_MANUF_COUNTRY ); -static VPD_DEVICE_ATTR(vendor_name ,S_IWUSR|S_IRUGO, show_attr_vpd, store_attr_vpd, TLV_CODE_VENDOR_NAME ); -static VPD_DEVICE_ATTR(diag_ver ,S_IWUSR|S_IRUGO, show_attr_vpd, store_attr_vpd, TLV_CODE_DIAG_VERSION ); -static VPD_DEVICE_ATTR(service_tag ,S_IWUSR|S_IRUGO, show_attr_vpd, store_attr_vpd, TLV_CODE_SERVICE_TAG ); -static VPD_DEVICE_ATTR(vendor_ext ,S_IWUSR|S_IRUGO, show_attr_vpd, store_attr_vpd, TLV_CODE_VENDOR_EXT ); -static VPD_DEVICE_ATTR(crc32 ,S_IRUGO, show_attr_vpd, NULL, TLV_CODE_CRC_32 ); - -static void -clean_vpd_common(void) -{ - dev_t dev_num; - struct device *device_p; - - device_p = get_swpdev_by_name(VPD_DEVICE); - if (device_p){ - dev_num = MKDEV(vpd_major, 1); - device_unregister(device_p); - device_destroy(vpd_class_p, dev_num); - } - VPD_DEBUG("%s: done.\n", __func__); -} - - -static struct register_attr VpdRegAttr[VPD_ENTRY_SIZE ] ={ - { &vpd_dev_attr_product_name.dev_attr, "vpd_dev_attr_product_name"}, - { &vpd_dev_attr_pn.dev_attr, "vpd_dev_attr_pn"}, - { &vpd_dev_attr_sn.dev_attr, "vpd_dev_attr_sn"}, - { &vpd_dev_attr_base_mac_addr.dev_attr, "vpd_dev_attr_base_mac_addr"}, - { &vpd_dev_attr_man_date.dev_attr, "vpd_dev_attr_man_date"}, - { &vpd_dev_attr_dev_ver.dev_attr, "vpd_dev_attr_dev_ver"}, - { &vpd_dev_attr_label_rev.dev_attr, "vpd_dev_attr_label_rev"}, - { &vpd_dev_attr_plat_name.dev_attr, "vpd_dev_attr_plat_name"}, - { &vpd_dev_attr_ldr_ver.dev_attr, "vpd_dev_attr_ldr_ver"}, - { &vpd_dev_attr_mac_addr.dev_attr, "vpd_dev_attr_mac_addr"}, - { &vpd_dev_attr_manufacturer.dev_attr, "vpd_dev_attr_manufacturer"}, - { &vpd_dev_attr_country_code.dev_attr, "vpd_dev_attr_country_code"}, - { &vpd_dev_attr_vendor_name.dev_attr, "vpd_dev_attr_vendor_name"}, - { &vpd_dev_attr_diag_ver.dev_attr, "vpd_dev_attr_diag_ver"}, - { &vpd_dev_attr_service_tag.dev_attr, "vpd_dev_attr_service_tag"}, - { &vpd_dev_attr_vendor_ext.dev_attr, "vpd_dev_attr_vendor_ext"}, - { &vpd_dev_attr_crc32.dev_attr, "vpd_dev_attr_crc32"}, -}; - -static int -register_vpd_attr(struct device *device_p){ - - char *err_attr = NULL; - int i; - - for( i = 0 ; i adapter = adap; - vpd_i2c_client->addr = VPD_I2C_ADDR; - - device_p = device_create(vpd_class_p, /* struct class *cls */ - NULL, /* struct device *parent */ - dev_num, /* dev_t devt */ - vpd_i2c_client, /* void *private_data */ - VPD_DEVICE); /* const char *fmt */ - if (IS_ERR(device_p)){ - err_msg = "device_create fail"; - goto err_register_vpd_device_1; - } - if (register_vpd_attr(device_p) < 0) { - err_msg = "register_vpd_attr fail"; - goto err_register_vpd_device_2; - } - return 0; - -err_register_vpd_device_2: - device_unregister(device_p); - device_destroy(vpd_class_p, dev_num); -err_register_vpd_device_1: - kfree(vpd_i2c_client); - vpd_i2c_client = NULL; -err_register_vpd_device: - VPD_ERR("%s: %s\n", __func__, err_msg); - return -1; -} - -static int -register_vpd_module(void) -{ - dev_t vpd_devt = 0; - - if (alloc_chrdev_region(&vpd_devt, 0, 1, VPD_DEVICE) < 0){ - VPD_WARN("Allocate VPD MAJOR failure! \n"); - goto err_register_vpd_module; - } - vpd_major = MAJOR(vpd_devt); - - /* Create class object */ - vpd_class_p = class_create(THIS_MODULE, EEPROM_CLASS); - if (IS_ERR(vpd_class_p)) { - VPD_ERR("Create class failure! \n"); - goto err_register_vpd_module_1; - } - return 0; - -err_register_vpd_module_1: - unregister_chrdev_region(MKDEV(vpd_major, 0), 1); -err_register_vpd_module: - return -1; -} - - -static int -init_vpd_common(void) -{ - char *err_msg = "ERR"; - - if (register_vpd_device() < 0) { - err_msg = "register_vpd_device fail"; - goto err_init_vpd_common; - } - return 0; - -err_init_vpd_common: - VPD_ERR("%s: %s\n", __func__, err_msg); - return -1; -} - - -static int __init -vpd_module_init(void) -{ - if (register_vpd_module() < 0){ - goto err_vpd_module_init; - } - if (init_vpd_common() < 0){ - goto err_vpd_module_init_1; - } - VPD_INFO("Inventec vpd module V.%s initial success.\n", VPD_VERSION); - return 0; - -err_vpd_module_init_1: - class_unregister(vpd_class_p); - class_destroy(vpd_class_p); - unregister_chrdev_region(MKDEV(vpd_major, 0), 1); -err_vpd_module_init: - VPD_ERR("Inventec vpd module V.%s initial failure.\n", VPD_VERSION); - return -1; -} - - -static void __exit -vpd_module_exit(void) -{ - clean_vpd_common(); - class_unregister(vpd_class_p); - class_destroy(vpd_class_p); - unregister_chrdev_region(MKDEV(vpd_major, 0), 1); - VPD_INFO("Remove Inventec vpd module success.\n"); -} - - -/* Module information */ -MODULE_AUTHOR(VPD_AUTHOR); -MODULE_DESCRIPTION(VPD_DESC); -MODULE_VERSION(VPD_VERSION); -MODULE_LICENSE(VPD_LICENSE); - -module_init(vpd_module_init); -module_exit(vpd_module_exit); diff --git a/packages/platforms/inventec/x86-64/d5052/modules/builds/src/inv_vpd.h b/packages/platforms/inventec/x86-64/d5052/modules/builds/src/inv_vpd.h deleted file mode 100644 index 5c7ee0689..000000000 --- a/packages/platforms/inventec/x86-64/d5052/modules/builds/src/inv_vpd.h +++ /dev/null @@ -1,48 +0,0 @@ -#ifndef INV_VPD_H -#define INV_VPD_H - -#define EEPROM_CLASS "eeprom" -#define VPD_DEVICE "vpd" -#define VPD_AUTHOR "Neil " -#define VPD_DESC "Inventec eeprom vpd driver" -#define VPD_VERSION "1.0.0" -#define VPD_LICENSE "GPL" - -#define VPD_ENTRY_SIZE (17) -#define VPD_I2C_BUS (0) -#define VPD_I2C_ADDR (0x53) - -#define VPD_KERN_VER_AF_3_10 (1) - -struct register_attr { -struct device_attribute *attr; -char * errmsg; -}; - -struct vpd_device_attribute{ - struct device_attribute dev_attr; - int index; -}; - -#define to_vpd_dev_attr(_dev_attr) \ - container_of(_dev_attr, struct vpd_device_attribute, dev_attr) - -#define VPD_ATTR(_name, _mode, _show, _store, _index) \ - { .dev_attr = __ATTR(_name, _mode, _show, _store), \ - .index = _index } - -#define VPD_DEVICE_ATTR(_name, _mode, _show, _store, _index) \ - struct vpd_device_attribute vpd_dev_attr_##_name \ - = VPD_ATTR(_name, _mode, _show, _store, _index) - -#define VPD_INFO(fmt, args...) printk( KERN_INFO "[VPD] " fmt, ##args) -#define VPD_WARN(fmt, args...) printk( KERN_WARNING "[VPD] " fmt, ##args) -#define VPD_ERR(fmt, args...) printk( KERN_ERR "[VPD] " fmt, ##args) - -#ifdef DEBUG_VPD -# define VPD_DEBUG(fmt, args...) printk( KERN_DEBUG "[VPD] " fmt, ##args) -#else -# define VPD_DEBUG(fmt, args...) -#endif - -#endif /* INV_VPD_H */ diff --git a/packages/platforms/inventec/x86-64/d5052/modules/builds/src/io_expander.c b/packages/platforms/inventec/x86-64/d5052/modules/builds/src/io_expander.c deleted file mode 100644 index 1d7dd023a..000000000 --- a/packages/platforms/inventec/x86-64/d5052/modules/builds/src/io_expander.c +++ /dev/null @@ -1,1934 +0,0 @@ -#include -#include -#include "io_expander.h" - -static struct ioexp_obj_s *ioexp_head_p = NULL; -static struct ioexp_obj_s *ioexp_tail_p = NULL; - - -/* ========== Register IOEXP layout ========== - */ -struct ioexp_map_s ioexp_map_magnolia_nab = { - - .chip_amount = 2, - .data_width = 2, - - .map_present = { {0, 0, 4}, /* map_present[0] = MOD_ABS_PORT(X) */ - {0, 0, 5}, /* map_present[1] = MOD_ABS_PORT(X+1) */ - {0, 0, 6}, /* map_present[2] = MOD_ABS_PORT(X+2) */ - {0, 0, 7}, /* map_present[3] = MOD_ABS_PORT(X+3) */ - {1, 0, 4}, /* map_present[4] = MOD_ABS_PORT(X+4) */ - {1, 0, 5}, /* map_present[5] = MOD_ABS_PORT(X+5) */ - {1, 0, 6}, /* map_present[6] = MOD_ABS_PORT(X+6) */ - {1, 0, 7}, /* map_present[7] = MOD_ABS_PORT(X+7) */ - }, - .map_tx_disable = { {0, 1, 0}, /* map_tx_disable[0] = TXDISABLE_SFP+_P(X) */ - {0, 1, 1}, /* map_tx_disable[1] = TXDISABLE_SFP+_P(X+1) */ - {0, 1, 2}, /* map_tx_disable[2] = TXDISABLE_SFP+_P(X+2) */ - {0, 1, 3}, /* map_tx_disable[3] = TXDISABLE_SFP+_P(X+3) */ - {1, 1, 0}, /* map_tx_disable[4] = TXDISABLE_SFP+_P(X+4) */ - {1, 1, 1}, /* map_tx_disable[5] = TXDISABLE_SFP+_P(X+5) */ - {1, 1, 2}, /* map_tx_disable[6] = TXDISABLE_SFP+_P(X+6) */ - {1, 1, 3}, /* map_tx_disable[7] = TXDISABLE_SFP+_P(X+7) */ - }, - .map_tx_fault = { {0, 0, 0}, /* map_tx_fault[0] = TXFAULT_SFP+_P(X) */ - {0, 0, 1}, /* map_tx_fault[1] = TXFAULT_SFP+_P(X+1) */ - {0, 0, 2}, /* map_tx_fault[2] = TXFAULT_SFP+_P(X+2) */ - {0, 0, 3}, /* map_tx_fault[3] = TXFAULT_SFP+_P(X+3) */ - {1, 0, 0}, /* map_tx_fault[4] = TXFAULT_SFP+_P(X+4) */ - {1, 0, 1}, /* map_tx_fault[5] = TXFAULT_SFP+_P(X+5) */ - {1, 0, 2}, /* map_tx_fault[6] = TXFAULT_SFP+_P(X+6) */ - {1, 0, 3}, /* map_tx_fault[7] = TXFAULT_SFP+_P(X+7) */ - }, - .map_rxlos = { {0, 1, 4}, /* map_rxlos[0] = OPRXLOS_PORT(X) */ - {0, 1, 5}, /* map_rxlos[1] = OPRXLOS_PORT(X+1) */ - {0, 1, 6}, /* map_rxlos[2] = OPRXLOS_PORT(X+2) */ - {0, 1, 7}, /* map_rxlos[3] = OPRXLOS_PORT(X+3) */ - {1, 1, 4}, /* map_rxlos[4] = OPRXLOS_PORT(X+4) */ - {1, 1, 5}, /* map_rxlos[5] = OPRXLOS_PORT(X+5) */ - {1, 1, 6}, /* map_rxlos[6] = OPRXLOS_PORT(X+6) */ - {1, 1, 7}, /* map_rxlos[7] = OPRXLOS_PORT(X+7) */ - }, -}; - - -struct ioexp_map_s ioexp_map_magnolia_4ab = { - - .chip_amount = 2, - .data_width = 2, - - .map_present = { {0, 0, 4}, /* map_present[0] = MOD_ABS_PORT(X) */ - {0, 0, 5}, /* map_present[1] = MOD_ABS_PORT(X+1) */ - {0, 0, 6}, /* map_present[2] = MOD_ABS_PORT(X+2) */ - {0, 0, 7}, /* map_present[3] = MOD_ABS_PORT(X+3) */ - {1, 0, 4}, /* map_present[4] = MOD_ABS_PORT(X+4) */ - {1, 0, 5}, /* map_present[5] = MOD_ABS_PORT(X+5) */ - {1, 0, 6}, /* map_present[6] = MOD_ABS_PORT(X+6) */ - {1, 0, 7}, /* map_present[7] = MOD_ABS_PORT(X+7) */ - }, - .map_tx_disable = { {0, 1, 0}, /* map_tx_disable[0] = TXDISABLE_SFP+_P(X) */ - {0, 1, 1}, /* map_tx_disable[1] = TXDISABLE_SFP+_P(X+1) */ - {0, 1, 2}, /* map_tx_disable[2] = TXDISABLE_SFP+_P(X+2) */ - {0, 1, 3}, /* map_tx_disable[3] = TXDISABLE_SFP+_P(X+3) */ - {1, 0, 0}, /* map_tx_disable[4] = TXDISABLE_SFP+_P(X+4) */ - {1, 0, 1}, /* map_tx_disable[5] = TXDISABLE_SFP+_P(X+5) */ - {1, 0, 2}, /* map_tx_disable[6] = TXDISABLE_SFP+_P(X+6) */ - {1, 0, 3}, /* map_tx_disable[7] = TXDISABLE_SFP+_P(X+7) */ - }, - .map_tx_fault = { {0, 0, 0}, /* map_tx_fault[0] = TXFAULT_SFP+_P(X) */ - {0, 0, 1}, /* map_tx_fault[1] = TXFAULT_SFP+_P(X+1) */ - {0, 0, 2}, /* map_tx_fault[2] = TXFAULT_SFP+_P(X+2) */ - {0, 0, 3}, /* map_tx_fault[3] = TXFAULT_SFP+_P(X+3) */ - {1, 1, 0}, /* map_tx_fault[4] = TXFAULT_SFP+_P(X+4) */ - {1, 1, 1}, /* map_tx_fault[5] = TXFAULT_SFP+_P(X+5) */ - {1, 1, 2}, /* map_tx_fault[6] = TXFAULT_SFP+_P(X+6) */ - {1, 1, 3}, /* map_tx_fault[7] = TXFAULT_SFP+_P(X+7) */ - }, - .map_rxlos = { {0, 1, 4}, /* map_rxlos[0] = OPRXLOS_PORT(X) */ - {0, 1, 5}, /* map_rxlos[1] = OPRXLOS_PORT(X+1) */ - {0, 1, 6}, /* map_rxlos[2] = OPRXLOS_PORT(X+2) */ - {0, 1, 7}, /* map_rxlos[3] = OPRXLOS_PORT(X+3) */ - {1, 1, 4}, /* map_rxlos[4] = OPRXLOS_PORT(X+4) */ - {1, 1, 5}, /* map_rxlos[5] = OPRXLOS_PORT(X+5) */ - {1, 1, 6}, /* map_rxlos[6] = OPRXLOS_PORT(X+6) */ - {1, 1, 7}, /* map_rxlos[7] = OPRXLOS_PORT(X+7) */ - }, -}; - - -struct ioexp_map_s ioexp_map_magnolia_7ab = { - - .chip_amount = 2, - .data_width = 2, - - .map_present = { {1, 0, 4}, /* map_present[0] = MOD_ABS_PORT(X) */ - {1, 0, 5}, /* map_present[1] = MOD_ABS_PORT(X+1) */ - {1, 0, 6}, /* map_present[2] = MOD_ABS_PORT(X+2) */ - {1, 0, 7}, /* map_present[3] = MOD_ABS_PORT(X+3) */ - {1, 1, 4}, /* map_present[4] = MOD_ABS_PORT(X+4) */ - {1, 1, 5}, /* map_present[5] = MOD_ABS_PORT(X+5) */ - }, - .map_reset = { {0, 0, 0}, /* map_reset[0] = QRESET_QSFP_N_P(X) */ - {0, 0, 1}, /* map_reset[1] = QRESET_QSFP_N_P(X+1) */ - {0, 0, 2}, /* map_reset[2] = QRESET_QSFP_N_P(X+2) */ - {0, 0, 3}, /* map_reset[3] = QRESET_QSFP_N_P(X+3) */ - {1, 0, 0}, /* map_reset[4] = QRESET_QSFP_N_P(X+4) */ - {1, 0, 1}, /* map_reset[5] = QRESET_QSFP_N_P(X+5) */ - }, - .map_lpmod = { {0, 0, 4}, /* map_lpmod[0] = LPMODE_QSFP_P(X) */ - {0, 0, 5}, /* map_lpmod[1] = LPMODE_QSFP_P(X+1) */ - {0, 0, 6}, /* map_lpmod[2] = LPMODE_QSFP_P(X+2) */ - {0, 0, 7}, /* map_lpmod[3] = LPMODE_QSFP_P(X+3) */ - {1, 0, 2}, /* map_lpmod[4] = LPMODE_QSFP_P(X+4) */ - {1, 0, 3}, /* map_lpmod[5] = LPMODE_QSFP_P(X+5) */ - }, - .map_modsel = { {0, 1, 4}, /* map_modsel[0] = MODSEL_QSFP_N_P(X) */ - {0, 1, 5}, /* map_modsel[1] = MODSEL_QSFP_N_P(X+1) */ - {0, 1, 6}, /* map_modsel[2] = MODSEL_QSFP_N_P(X+2) */ - {0, 1, 7}, /* map_modsel[3] = MODSEL_QSFP_N_P(X+3) */ - {1, 1, 4}, /* map_modsel[4] = MODSEL_QSFP_N_P(X+4) */ - {1, 1, 5}, /* map_modsel[5] = MODSEL_QSFP_N_P(X+5) */ - }, -}; - - -struct ioexp_map_s ioexp_map_redwood_p01p08_p17p24 = { - - .chip_amount = 3, - .data_width = 2, - - .map_present = { {2, 0, 0}, /* map_present[0] = MOD_ABS_PORT(X) */ - {2, 0, 1}, /* map_present[1] = MOD_ABS_PORT(X+1) */ - {2, 0, 2}, /* map_present[2] = MOD_ABS_PORT(X+2) */ - {2, 0, 3}, /* map_present[3] = MOD_ABS_PORT(X+3) */ - {2, 0, 4}, /* map_present[4] = MOD_ABS_PORT(X+4) */ - {2, 0, 5}, /* map_present[5] = MOD_ABS_PORT(X+5) */ - {2, 0, 6}, /* map_present[6] = MOD_ABS_PORT(X+6) */ - {2, 0, 7}, /* map_present[7] = MOD_ABS_PORT(X+7) */ - }, - .map_reset = { {0, 0, 0}, /* map_reset[0] = QRESET_QSFP28_N_P(X) */ - {0, 0, 1}, /* map_reset[1] = QRESET_QSFP28_N_P(X+1) */ - {0, 0, 2}, /* map_reset[2] = QRESET_QSFP28_N_P(X+2) */ - {0, 0, 3}, /* map_reset[3] = QRESET_QSFP28_N_P(X+3) */ - {1, 0, 0}, /* map_reset[4] = QRESET_QSFP28_N_P(X+4) */ - {1, 0, 1}, /* map_reset[5] = QRESET_QSFP28_N_P(X+5) */ - {1, 0, 2}, /* map_reset[6] = QRESET_QSFP28_N_P(X+6) */ - {1, 0, 3}, /* map_reset[7] = QRESET_QSFP28_N_P(X+7) */ - }, - .map_lpmod = { {0, 0, 4}, /* map_lpmod[0] = LPMODE_QSFP28_P(X) */ - {0, 0, 5}, /* map_lpmod[1] = LPMODE_QSFP28_P(X+1) */ - {0, 0, 6}, /* map_lpmod[2] = LPMODE_QSFP28_P(X+2) */ - {0, 0, 7}, /* map_lpmod[3] = LPMODE_QSFP28_P(X+3) */ - {1, 0, 4}, /* map_lpmod[4] = LPMODE_QSFP28_P(X+4) */ - {1, 0, 5}, /* map_lpmod[5] = LPMODE_QSFP28_P(X+5) */ - {1, 0, 6}, /* map_lpmod[6] = LPMODE_QSFP28_P(X+6) */ - {1, 0, 7}, /* map_lpmod[7] = LPMODE_QSFP28_P(X+7) */ - }, - .map_modsel = { {0, 1, 4}, /* map_modsel[0] = MODSEL_QSFP28_N_P(X) */ - {0, 1, 5}, /* map_modsel[1] = MODSEL_QSFP28_N_P(X+1) */ - {0, 1, 6}, /* map_modsel[2] = MODSEL_QSFP28_N_P(X+2) */ - {0, 1, 7}, /* map_modsel[3] = MODSEL_QSFP28_N_P(X+3) */ - {1, 1, 4}, /* map_modsel[4] = MODSEL_QSFP28_N_P(X+4) */ - {1, 1, 5}, /* map_modsel[5] = MODSEL_QSFP28_N_P(X+5) */ - {1, 1, 6}, /* map_modsel[6] = MODSEL_QSFP28_N_P(X+6) */ - {1, 1, 7}, /* map_modsel[7] = MODSEL_QSFP28_N_P(X+7) */ - }, -}; - - -struct ioexp_map_s ioexp_map_redwood_p09p16_p25p32 = { - - .chip_amount = 3, - .data_width = 2, - - .map_present = { {2, 1, 0}, /* map_present[0] = MOD_ABS_PORT(X) */ - {2, 1, 1}, /* map_present[1] = MOD_ABS_PORT(X+1) */ - {2, 1, 2}, /* map_present[2] = MOD_ABS_PORT(X+2) */ - {2, 1, 3}, /* map_present[3] = MOD_ABS_PORT(X+3) */ - {2, 1, 4}, /* map_present[4] = MOD_ABS_PORT(X+4) */ - {2, 1, 5}, /* map_present[5] = MOD_ABS_PORT(X+5) */ - {2, 1, 6}, /* map_present[6] = MOD_ABS_PORT(X+6) */ - {2, 1, 7}, /* map_present[7] = MOD_ABS_PORT(X+7) */ - }, - .map_reset = { {0, 0, 0}, /* map_reset[0] = QRESET_QSFP28_N_P(X) */ - {0, 0, 1}, /* map_reset[1] = QRESET_QSFP28_N_P(X+1) */ - {0, 0, 2}, /* map_reset[2] = QRESET_QSFP28_N_P(X+2) */ - {0, 0, 3}, /* map_reset[3] = QRESET_QSFP28_N_P(X+3) */ - {1, 0, 0}, /* map_reset[4] = QRESET_QSFP28_N_P(X+4) */ - {1, 0, 1}, /* map_reset[5] = QRESET_QSFP28_N_P(X+5) */ - {1, 0, 2}, /* map_reset[6] = QRESET_QSFP28_N_P(X+6) */ - {1, 0, 3}, /* map_reset[7] = QRESET_QSFP28_N_P(X+7) */ - }, - .map_lpmod = { {0, 0, 4}, /* map_lpmod[0] = LPMODE_QSFP28_P(X) */ - {0, 0, 5}, /* map_lpmod[1] = LPMODE_QSFP28_P(X+1) */ - {0, 0, 6}, /* map_lpmod[2] = LPMODE_QSFP28_P(X+2) */ - {0, 0, 7}, /* map_lpmod[3] = LPMODE_QSFP28_P(X+3) */ - {1, 0, 4}, /* map_lpmod[4] = LPMODE_QSFP28_P(X+4) */ - {1, 0, 5}, /* map_lpmod[5] = LPMODE_QSFP28_P(X+5) */ - {1, 0, 6}, /* map_lpmod[6] = LPMODE_QSFP28_P(X+6) */ - {1, 0, 7}, /* map_lpmod[7] = LPMODE_QSFP28_P(X+7) */ - }, - .map_modsel = { {0, 1, 4}, /* map_modsel[0] = MODSEL_QSFP28_N_P(X) */ - {0, 1, 5}, /* map_modsel[1] = MODSEL_QSFP28_N_P(X+1) */ - {0, 1, 6}, /* map_modsel[2] = MODSEL_QSFP28_N_P(X+2) */ - {0, 1, 7}, /* map_modsel[3] = MODSEL_QSFP28_N_P(X+3) */ - {1, 1, 4}, /* map_modsel[4] = MODSEL_QSFP28_N_P(X+4) */ - {1, 1, 5}, /* map_modsel[5] = MODSEL_QSFP28_N_P(X+5) */ - {1, 1, 6}, /* map_modsel[6] = MODSEL_QSFP28_N_P(X+6) */ - {1, 1, 7}, /* map_modsel[7] = MODSEL_QSFP28_N_P(X+7) */ - }, -}; - - -struct ioexp_map_s ioexp_map_hudson32iga_p01p08_p17p24 = { - - .chip_amount = 3, - .data_width = 2, - - .map_present = { {2, 0, 0}, /* map_present[0] = MODABS_QSFP(X) */ - {2, 0, 1}, /* map_present[1] = MODABS_QSFP(X+1) */ - {2, 0, 2}, /* map_present[2] = MODABS_QSFP(X+2) */ - {2, 0, 3}, /* map_present[3] = MODABS_QSFP(X+3) */ - {2, 0, 4}, /* map_present[4] = MODABS_QSFP(X+4) */ - {2, 0, 5}, /* map_present[5] = MODABS_QSFP(X+5) */ - {2, 0, 6}, /* map_present[6] = MODABS_QSFP(X+6) */ - {2, 0, 7}, /* map_present[7] = MODABS_QSFP(X+7) */ - }, - .map_reset = { {0, 0, 0}, /* map_reset[0] = QRESET_QSFP(X) */ - {0, 0, 1}, /* map_reset[1] = QRESET_QSFP(X+1) */ - {0, 0, 2}, /* map_reset[2] = QRESET_QSFP(X+2) */ - {0, 0, 3}, /* map_reset[3] = QRESET_QSFP(X+3) */ - {1, 0, 0}, /* map_reset[4] = QRESET_QSFP(X+4) */ - {1, 0, 1}, /* map_reset[5] = QRESET_QSFP(X+5) */ - {1, 0, 2}, /* map_reset[6] = QRESET_QSFP(X+6) */ - {1, 0, 3}, /* map_reset[7] = QRESET_QSFP(X+7) */ - }, - .map_lpmod = { {0, 0, 4}, /* map_lpmod[0] = LPMODE_QSFP(X) */ - {0, 0, 5}, /* map_lpmod[1] = LPMODE_QSFP(X+1) */ - {0, 0, 6}, /* map_lpmod[2] = LPMODE_QSFP(X+2) */ - {0, 0, 7}, /* map_lpmod[3] = LPMODE_QSFP(X+3) */ - {1, 0, 4}, /* map_lpmod[4] = LPMODE_QSFP(X+4) */ - {1, 0, 5}, /* map_lpmod[5] = LPMODE_QSFP(X+5) */ - {1, 0, 6}, /* map_lpmod[6] = LPMODE_QSFP(X+6) */ - {1, 0, 7}, /* map_lpmod[7] = LPMODE_QSFP(X+7) */ - }, - .map_modsel = { {0, 1, 4}, /* map_modsel[0] = MODSEL_QSFP(X) */ - {0, 1, 5}, /* map_modsel[1] = MODSEL_QSFP(X+1) */ - {0, 1, 6}, /* map_modsel[2] = MODSEL_QSFP(X+2) */ - {0, 1, 7}, /* map_modsel[3] = MODSEL_QSFP(X+3) */ - {1, 1, 4}, /* map_modsel[4] = MODSEL_QSFP(X+4) */ - {1, 1, 5}, /* map_modsel[5] = MODSEL_QSFP(X+5) */ - {1, 1, 6}, /* map_modsel[6] = MODSEL_QSFP(X+6) */ - {1, 1, 7}, /* map_modsel[7] = MODSEL_QSFP(X+7) */ - }, -}; - - -struct ioexp_map_s ioexp_map_hudson32iga_p09p16_p25p32 = { - - .chip_amount = 3, - .data_width = 2, - - .map_present = { {2, 1, 0}, /* map_present[0] = MODABS_QSFP(X) */ - {2, 1, 1}, /* map_present[1] = MODABS_QSFP(X+1) */ - {2, 1, 2}, /* map_present[2] = MODABS_QSFP(X+2) */ - {2, 1, 3}, /* map_present[3] = MODABS_QSFP(X+3) */ - {2, 1, 4}, /* map_present[4] = MODABS_QSFP(X+4) */ - {2, 1, 5}, /* map_present[5] = MODABS_QSFP(X+5) */ - {2, 1, 6}, /* map_present[6] = MODABS_QSFP(X+6) */ - {2, 1, 7}, /* map_present[7] = MODABS_QSFP(X+7) */ - }, - .map_reset = { {0, 0, 0}, /* map_reset[0] = QRESET_QSFP(X) */ - {0, 0, 1}, /* map_reset[1] = QRESET_QSFP(X+1) */ - {0, 0, 2}, /* map_reset[2] = QRESET_QSFP(X+2) */ - {0, 0, 3}, /* map_reset[3] = QRESET_QSFP(X+3) */ - {1, 0, 0}, /* map_reset[4] = QRESET_QSFP(X+4) */ - {1, 0, 1}, /* map_reset[5] = QRESET_QSFP(X+5) */ - {1, 0, 2}, /* map_reset[6] = QRESET_QSFP(X+6) */ - {1, 0, 3}, /* map_reset[7] = QRESET_QSFP(X+7) */ - }, - .map_lpmod = { {0, 0, 4}, /* map_lpmod[0] = LPMODE_QSFP(X) */ - {0, 0, 5}, /* map_lpmod[1] = LPMODE_QSFP(X+1) */ - {0, 0, 6}, /* map_lpmod[2] = LPMODE_QSFP(X+2) */ - {0, 0, 7}, /* map_lpmod[3] = LPMODE_QSFP(X+3) */ - {1, 0, 4}, /* map_lpmod[4] = LPMODE_QSFP(X+4) */ - {1, 0, 5}, /* map_lpmod[5] = LPMODE_QSFP(X+5) */ - {1, 0, 6}, /* map_lpmod[6] = LPMODE_QSFP(X+6) */ - {1, 0, 7}, /* map_lpmod[7] = LPMODE_QSFP(X+7) */ - }, - .map_modsel = { {0, 1, 4}, /* map_modsel[0] = MODSEL_QSFP(X) */ - {0, 1, 5}, /* map_modsel[1] = MODSEL_QSFP(X+1) */ - {0, 1, 6}, /* map_modsel[2] = MODSEL_QSFP(X+2) */ - {0, 1, 7}, /* map_modsel[3] = MODSEL_QSFP(X+3) */ - {1, 1, 4}, /* map_modsel[4] = MODSEL_QSFP(X+4) */ - {1, 1, 5}, /* map_modsel[5] = MODSEL_QSFP(X+5) */ - {1, 1, 6}, /* map_modsel[6] = MODSEL_QSFP(X+6) */ - {1, 1, 7}, /* map_modsel[7] = MODSEL_QSFP(X+7) */ - }, -}; - - -struct ioexp_map_s ioexp_map_cypress_nabc = { - - .chip_amount = 3, - .data_width = 2, - - .map_present = { {0, 0, 4}, /* map_present[0] = MOD_ABS_PORT(X) */ - {0, 0, 5}, /* map_present[1] = MOD_ABS_PORT(X+1) */ - {0, 0, 6}, /* map_present[2] = MOD_ABS_PORT(X+2) */ - {0, 0, 7}, /* map_present[3] = MOD_ABS_PORT(X+3) */ - {1, 0, 4}, /* map_present[4] = MOD_ABS_PORT(X+4) */ - {1, 0, 5}, /* map_present[5] = MOD_ABS_PORT(X+5) */ - {1, 0, 6}, /* map_present[6] = MOD_ABS_PORT(X+6) */ - {1, 0, 7}, /* map_present[7] = MOD_ABS_PORT(X+7) */ - }, - .map_tx_disable = { {0, 1, 0}, /* map_tx_disable[0] = TXDISABLE_SFP+_P(X) */ - {0, 1, 1}, /* map_tx_disable[1] = TXDISABLE_SFP+_P(X+1) */ - {0, 1, 2}, /* map_tx_disable[2] = TXDISABLE_SFP+_P(X+2) */ - {0, 1, 3}, /* map_tx_disable[3] = TXDISABLE_SFP+_P(X+3) */ - {1, 1, 0}, /* map_tx_disable[4] = TXDISABLE_SFP+_P(X+4) */ - {1, 1, 1}, /* map_tx_disable[5] = TXDISABLE_SFP+_P(X+5) */ - {1, 1, 2}, /* map_tx_disable[6] = TXDISABLE_SFP+_P(X+6) */ - {1, 1, 3}, /* map_tx_disable[7] = TXDISABLE_SFP+_P(X+7) */ - }, - .map_tx_fault = { {0, 0, 0}, /* map_tx_fault[0] = TXFAULT_SFP+_P(X) */ - {0, 0, 1}, /* map_tx_fault[1] = TXFAULT_SFP+_P(X+1) */ - {0, 0, 2}, /* map_tx_fault[2] = TXFAULT_SFP+_P(X+2) */ - {0, 0, 3}, /* map_tx_fault[3] = TXFAULT_SFP+_P(X+3) */ - {1, 0, 0}, /* map_tx_fault[4] = TXFAULT_SFP+_P(X+4) */ - {1, 0, 1}, /* map_tx_fault[5] = TXFAULT_SFP+_P(X+5) */ - {1, 0, 2}, /* map_tx_fault[6] = TXFAULT_SFP+_P(X+6) */ - {1, 0, 3}, /* map_tx_fault[7] = TXFAULT_SFP+_P(X+7) */ - }, - .map_rxlos = { {0, 1, 4}, /* map_rxlos[0] = OPRXLOS_PORT(X) */ - {0, 1, 5}, /* map_rxlos[1] = OPRXLOS_PORT(X+1) */ - {0, 1, 6}, /* map_rxlos[2] = OPRXLOS_PORT(X+2) */ - {0, 1, 7}, /* map_rxlos[3] = OPRXLOS_PORT(X+3) */ - {1, 1, 4}, /* map_rxlos[4] = OPRXLOS_PORT(X+4) */ - {1, 1, 5}, /* map_rxlos[5] = OPRXLOS_PORT(X+5) */ - {1, 1, 6}, /* map_rxlos[6] = OPRXLOS_PORT(X+6) */ - {1, 1, 7}, /* map_rxlos[7] = OPRXLOS_PORT(X+7) */ - }, - .map_hard_rs0 = { {2, 0, 0}, /* map_hard_rs0[0] = RS0_SFP28_P(X) */ - {2, 0, 2}, /* map_hard_rs0[1] = RS0_SFP28_P(X+1) */ - {2, 0, 4}, /* map_hard_rs0[2] = RS0_SFP28_P(X+2) */ - {2, 0, 6}, /* map_hard_rs0[3] = RS0_SFP28_P(X+3) */ - {2, 1, 0}, /* map_hard_rs0[4] = RS0_SFP28_P(X+4) */ - {2, 1, 2}, /* map_hard_rs0[5] = RS0_SFP28_P(X+5) */ - {2, 1, 4}, /* map_hard_rs0[6] = RS0_SFP28_P(X+6) */ - {2, 1, 6}, /* map_hard_rs0[7] = RS0_SFP28_P(X+7) */ - }, - .map_hard_rs1 = { {2, 0, 1}, /* map_hard_rs1[0] = RS1_SFP28_P(X) */ - {2, 0, 3}, /* map_hard_rs1[1] = RS1_SFP28_P(X+1) */ - {2, 0, 5}, /* map_hard_rs1[2] = RS1_SFP28_P(X+2) */ - {2, 0, 7}, /* map_hard_rs1[3] = RS1_SFP28_P(X+3) */ - {2, 1, 1}, /* map_hard_rs1[4] = RS1_SFP28_P(X+4) */ - {2, 1, 3}, /* map_hard_rs1[5] = RS1_SFP28_P(X+5) */ - {2, 1, 5}, /* map_hard_rs1[6] = RS1_SFP28_P(X+6) */ - {2, 1, 7}, /* map_hard_rs1[7] = RS1_SFP28_P(X+7) */ - }, -}; - - -struct ioexp_map_s ioexp_map_cypress_7abc = { - - .chip_amount = 3, - .data_width = 2, - - .map_present = { {2, 0, 0}, /* map_present[0] = MOD_ABS_PORT(X) */ - {2, 0, 1}, /* map_present[1] = MOD_ABS_PORT(X+1) */ - {2, 0, 2}, /* map_present[2] = MOD_ABS_PORT(X+2) */ - {2, 0, 3}, /* map_present[3] = MOD_ABS_PORT(X+3) */ - {2, 0, 4}, /* map_present[4] = MOD_ABS_PORT(X+4) */ - {2, 0, 5}, /* map_present[5] = MOD_ABS_PORT(X+5) */ - }, - .map_reset = { {0, 0, 0}, /* map_reset[0] = QRESET_QSFP_N_P(X) */ - {0, 0, 1}, /* map_reset[1] = QRESET_QSFP_N_P(X+1) */ - {0, 0, 2}, /* map_reset[2] = QRESET_QSFP_N_P(X+2) */ - {0, 0, 3}, /* map_reset[3] = QRESET_QSFP_N_P(X+3) */ - {0, 0, 4}, /* map_reset[4] = QRESET_QSFP_N_P(X+4) */ - {0, 0, 5}, /* map_reset[5] = QRESET_QSFP_N_P(X+5) */ - }, - .map_lpmod = { {0, 1, 0}, /* map_lpmod[0] = LPMODE_QSFP_P(X) */ - {0, 1, 1}, /* map_lpmod[1] = LPMODE_QSFP_P(X+1) */ - {0, 1, 2}, /* map_lpmod[2] = LPMODE_QSFP_P(X+2) */ - {0, 1, 3}, /* map_lpmod[3] = LPMODE_QSFP_P(X+3) */ - {0, 1, 4}, /* map_lpmod[4] = LPMODE_QSFP_P(X+4) */ - {0, 1, 5}, /* map_lpmod[5] = LPMODE_QSFP_P(X+5) */ - }, - .map_modsel = { {1, 1, 0}, /* map_modsel[0] = MODSEL_QSFP_N_P(X) */ - {1, 1, 1}, /* map_modsel[1] = MODSEL_QSFP_N_P(X+1) */ - {1, 1, 2}, /* map_modsel[2] = MODSEL_QSFP_N_P(X+2) */ - {1, 1, 3}, /* map_modsel[3] = MODSEL_QSFP_N_P(X+3) */ - {1, 1, 4}, /* map_modsel[4] = MODSEL_QSFP_N_P(X+4) */ - {1, 1, 5}, /* map_modsel[5] = MODSEL_QSFP_N_P(X+5) */ - }, -}; - - -struct ioexp_map_s ioexp_map_tahoe_5a = { - - .chip_amount = 1, - .data_width = 2, - - .map_present = { {0, 0, 3}, /* map_present[0] = MOD_ABS_PORT(X) */ - {0, 1, 0}, /* map_present[1] = MOD_ABS_PORT(X+1) */ - {0, 1, 5}, /* map_present[2] = MOD_ABS_PORT(X+2) */ - }, - .map_reset = { {0, 0, 1}, /* map_reset[0] = QRESET_QSFP_N_P(X) */ - {0, 0, 6}, /* map_reset[1] = QRESET_QSFP_N_P(X+1) */ - {0, 1, 3}, /* map_reset[2] = QRESET_QSFP_N_P(X+2) */ - }, - .map_lpmod = { {0, 0, 2}, /* map_lpmod[0] = LPMODE_QSFP_P(X) */ - {0, 0, 7}, /* map_lpmod[1] = LPMODE_QSFP_P(X+1) */ - {0, 1, 4}, /* map_lpmod[2] = LPMODE_QSFP_P(X+2) */ - }, - .map_modsel = { {0, 0, 0}, /* map_modsel[0] = MODSEL_QSFP_N_P(X) */ - {0, 0, 5}, /* map_modsel[1] = MODSEL_QSFP_N_P(X+1) */ - {0, 1, 2}, /* map_modsel[2] = MODSEL_QSFP_N_P(X+2) */ - }, -}; - - -struct ioexp_map_s ioexp_map_tahoe_6abc = { - - .chip_amount = 3, - .data_width = 2, - - .map_present = { {0, 0, 3}, /* map_present[0] = MOD_ABS_PORT(X) */ - {0, 1, 0}, /* map_present[1] = MOD_ABS_PORT(X+1) */ - {0, 1, 5}, /* map_present[2] = MOD_ABS_PORT(X+2) */ - {1, 0, 3}, /* map_present[3] = MOD_ABS_PORT(X+3) */ - {1, 1, 0}, /* map_present[4] = MOD_ABS_PORT(X+4) */ - {1, 1, 5}, /* map_present[5] = MOD_ABS_PORT(X+5) */ - {2, 0, 3}, /* map_present[6] = MOD_ABS_PORT(X+6) */ - {2, 1, 0}, /* map_present[7] = MOD_ABS_PORT(X+7) */ - {2, 1, 5}, /* map_present[8] = MOD_ABS_PORT(X+8) */ - }, - .map_reset = { {0, 0, 1}, /* map_reset[0] = QRESET_QSFP28_N_P(X) */ - {0, 0, 6}, /* map_reset[1] = QRESET_QSFP28_N_P(X+1) */ - {0, 1, 3}, /* map_reset[2] = QRESET_QSFP28_N_P(X+2) */ - {1, 0, 1}, /* map_reset[3] = QRESET_QSFP28_N_P(X+3) */ - {1, 0, 6}, /* map_reset[4] = QRESET_QSFP28_N_P(X+4) */ - {1, 1, 3}, /* map_reset[5] = QRESET_QSFP28_N_P(X+5) */ - {2, 0, 1}, /* map_reset[6] = QRESET_QSFP28_N_P(X+6) */ - {2, 0, 6}, /* map_reset[7] = QRESET_QSFP28_N_P(X+7) */ - {2, 1, 3}, /* map_reset[7] = QRESET_QSFP28_N_P(X+7) */ - }, - .map_lpmod = { {0, 0, 2}, /* map_lpmod[0] = LPMODE_QSFP28_P(X) */ - {0, 0, 7}, /* map_lpmod[1] = LPMODE_QSFP28_P(X+1) */ - {0, 1, 4}, /* map_lpmod[2] = LPMODE_QSFP28_P(X+2) */ - {1, 0, 2}, /* map_lpmod[3] = LPMODE_QSFP28_P(X+3) */ - {1, 0, 7}, /* map_lpmod[4] = LPMODE_QSFP28_P(X+4) */ - {1, 1, 4}, /* map_lpmod[5] = LPMODE_QSFP28_P(X+5) */ - {2, 0, 2}, /* map_lpmod[6] = LPMODE_QSFP28_P(X+6) */ - {2, 0, 7}, /* map_lpmod[7] = LPMODE_QSFP28_P(X+7) */ - {2, 1, 4}, /* map_lpmod[7] = LPMODE_QSFP28_P(X+8) */ - }, - .map_modsel = { {0, 0, 0}, /* map_modsel[0] = MODSEL_QSFP28_N_P(X) */ - {0, 0, 5}, /* map_modsel[1] = MODSEL_QSFP28_N_P(X+1) */ - {0, 1, 2}, /* map_modsel[2] = MODSEL_QSFP28_N_P(X+2) */ - {1, 0, 0}, /* map_modsel[3] = MODSEL_QSFP28_N_P(X+3) */ - {1, 0, 5}, /* map_modsel[4] = MODSEL_QSFP28_N_P(X+4) */ - {1, 1, 2}, /* map_modsel[5] = MODSEL_QSFP28_N_P(X+5) */ - {2, 0, 0}, /* map_modsel[6] = MODSEL_QSFP28_N_P(X+6) */ - {2, 0, 5}, /* map_modsel[7] = MODSEL_QSFP28_N_P(X+7) */ - {2, 1, 2}, /* map_modsel[7] = MODSEL_QSFP28_N_P(X+7) */ - }, -}; - - -struct ioexp_map_s ioexp_map_sequoia_nabc = { - - .chip_amount = 3, - .data_width = 2, - - .map_present = { {2, 1, 0}, /* map_present[0] = MOD_ABS_PORT(X) */ - {2, 1, 1}, /* map_present[1] = MOD_ABS_PORT(X+1) */ - {2, 1, 2}, /* map_present[2] = MOD_ABS_PORT(X+2) */ - {2, 1, 3}, /* map_present[3] = MOD_ABS_PORT(X+3) */ - {2, 1, 4}, /* map_present[4] = MOD_ABS_PORT(X+4) */ - {2, 1, 5}, /* map_present[5] = MOD_ABS_PORT(X+5) */ - {2, 1, 6}, /* map_present[6] = MOD_ABS_PORT(X+6) */ - {2, 1, 7}, /* map_present[7] = MOD_ABS_PORT(X+7) */ - }, - .map_reset = { {0, 1, 0}, /* map_reset[0] = QRESET_QSFP28_N_P(X) */ - {0, 1, 1}, /* map_reset[1] = QRESET_QSFP28_N_P(X+1) */ - {0, 1, 2}, /* map_reset[2] = QRESET_QSFP28_N_P(X+2) */ - {0, 1, 3}, /* map_reset[3] = QRESET_QSFP28_N_P(X+3) */ - {0, 1, 4}, /* map_reset[4] = QRESET_QSFP28_N_P(X+4) */ - {0, 1, 5}, /* map_reset[5] = QRESET_QSFP28_N_P(X+5) */ - {0, 1, 6}, /* map_reset[6] = QRESET_QSFP28_N_P(X+6) */ - {0, 1, 7}, /* map_reset[7] = QRESET_QSFP28_N_P(X+7) */ - }, - .map_lpmod = { {1, 0, 0}, /* map_lpmod[0] = LPMODE_QSFP28_P(X) */ - {1, 0, 1}, /* map_lpmod[1] = LPMODE_QSFP28_P(X+1) */ - {1, 0, 2}, /* map_lpmod[2] = LPMODE_QSFP28_P(X+2) */ - {1, 0, 3}, /* map_lpmod[3] = LPMODE_QSFP28_P(X+3) */ - {1, 0, 4}, /* map_lpmod[4] = LPMODE_QSFP28_P(X+4) */ - {1, 0, 5}, /* map_lpmod[5] = LPMODE_QSFP28_P(X+5) */ - {1, 0, 6}, /* map_lpmod[6] = LPMODE_QSFP28_P(X+6) */ - {1, 0, 7}, /* map_lpmod[7] = LPMODE_QSFP28_P(X+7) */ - }, - .map_modsel = { {0, 0, 0}, /* map_modsel[0] = MODSEL_QSFP28_N_P(X) */ - {0, 0, 1}, /* map_modsel[1] = MODSEL_QSFP28_N_P(X+1) */ - {0, 0, 2}, /* map_modsel[2] = MODSEL_QSFP28_N_P(X+2) */ - {0, 0, 3}, /* map_modsel[3] = MODSEL_QSFP28_N_P(X+3) */ - {0, 0, 4}, /* map_modsel[4] = MODSEL_QSFP28_N_P(X+4) */ - {0, 0, 5}, /* map_modsel[5] = MODSEL_QSFP28_N_P(X+5) */ - {0, 0, 6}, /* map_modsel[6] = MODSEL_QSFP28_N_P(X+6) */ - {0, 0, 7}, /* map_modsel[7] = MODSEL_QSFP28_N_P(X+7) */ - }, -}; - - -struct ioexp_map_s ioexp_map_lavender_p65 = { - - .chip_amount = 1, - .data_width = 1, - - .map_present = { {0, 0, 4}, }, /* map_present[0] = MOD_ABS_PORT(X) */ - .map_reset = { {0, 0, 1}, }, /* map_reset[0] = QRESET_QSFP28_N_P(X) */ - .map_lpmod = { {0, 0, 2}, }, /* map_lpmod[0] = LPMODE_QSFP28_P(X) */ - .map_modsel = { {0, 0, 0}, }, /* map_modsel[0] = MODSEL_QSFP28_N_P(X) */ -}; - - -struct ioexp_map_s cpld_map_cottonwood = { - - .chip_amount = 1, - .data_width = 4, - - .map_present = { {0, 2, 0}, /* map_present[0] = MOD_ABS_PORT(X) */ - {0, 2, 4}, /* map_present[1] = MOD_ABS_PORT(X+1) */ - {0, 3, 0}, /* map_present[2] = MOD_ABS_PORT(X+2) */ - {0, 3, 4}, /* map_present[3] = MOD_ABS_PORT(X+3) */ - }, - .map_tx_disable = { {0, 0, 0}, /* map_tx_disable[0] = TXDISABLE_SFP+_P(X) */ - {0, 0, 4}, /* map_tx_disable[1] = TXDISABLE_SFP+_P(X+1) */ - {0, 1, 0}, /* map_tx_disable[2] = TXDISABLE_SFP+_P(X+2) */ - {0, 1, 4}, /* map_tx_disable[3] = TXDISABLE_SFP+_P(X+3) */ - }, - .map_tx_fault = { {0, 2, 2}, /* map_tx_fault[0] = TXFAULT_SFP+_P(X) */ - {0, 2, 6}, /* map_tx_fault[1] = TXFAULT_SFP+_P(X+1) */ - {0, 3, 2}, /* map_tx_fault[2] = TXFAULT_SFP+_P(X+2) */ - {0, 3, 6}, /* map_tx_fault[3] = TXFAULT_SFP+_P(X+3) */ - }, - .map_rxlos = { {0, 2, 1}, /* map_rxlos[0] = OPRXLOS_PORT(X) */ - {0, 2, 5}, /* map_rxlos[1] = OPRXLOS_PORT(X+1) */ - {0, 3, 1}, /* map_rxlos[2] = OPRXLOS_PORT(X+2) */ - {0, 3, 5}, /* map_rxlos[3] = OPRXLOS_PORT(X+3) */ - }, - .map_hard_rs0 = { {0, 0, 2}, /* map_hard_rs0[0] = RS0_SFP28_P(X) */ - {0, 0, 6}, /* map_hard_rs0[1] = RS0_SFP28_P(X+1) */ - {0, 1, 2}, /* map_hard_rs0[2] = RS0_SFP28_P(X+2) */ - {0, 1, 6}, /* map_hard_rs0[3] = RS0_SFP28_P(X+3) */ - }, - .map_hard_rs1 = { {0, 0, 2}, /* map_hard_rs1[0] = RS1_SFP28_P(X) */ - {0, 0, 6}, /* map_hard_rs1[1] = RS1_SFP28_P(X+1) */ - {0, 1, 2}, /* map_hard_rs1[2] = RS1_SFP28_P(X+2) */ - {0, 1, 6}, /* map_hard_rs1[3] = RS1_SFP28_P(X+3) */ - }, -}; - -/* ========== Private functions ========== - */ -int check_channel_tier_1(void); - -struct i2c_client * -_get_i2c_client(struct ioexp_obj_s *self, - int chip_id){ - - struct ioexp_i2c_s *i2c_curr_p = self->i2c_head_p; - - if (!(i2c_curr_p)){ - SWPS_ERR("%s: i2c_curr_p is NULL\n", __func__); - return NULL; - } - while (i2c_curr_p){ - if ((i2c_curr_p->chip_id) == chip_id){ - return i2c_curr_p->i2c_client_p; - } - i2c_curr_p = i2c_curr_p->next; - } - SWPS_ERR("%s: not exist! :%d\n", __func__, chip_id); - return NULL; -} - - -static int -_common_ioexp_update_one(struct ioexp_obj_s *self, - struct ioexp_addr_s *ioexp_addr, - int chip_id, - int data_width, - int show_err, - char *caller_name) { - int buf = 0; - int err = 0; - int data_id = 0; - int r_offset = 0; - - for(data_id=0; data_idread_offset[data_id]; - buf = i2c_smbus_read_byte_data(_get_i2c_client(self, chip_id), r_offset); - /* Check error */ - if (buf < 0) { - err = 1; - if (show_err) { - SWPS_INFO("IOEXP-%d read fail! :%d \n", self->ioexp_id, buf); - SWPS_INFO("Dump: :%d :0x%02x :%d, :%s\n", - ioexp_addr->chan_id, ioexp_addr->chip_addr, - ioexp_addr->read_offset[data_id], caller_name); - } - continue; - } - /* Update IOEXP object */ - self->chip_data[chip_id].data[data_id] = (uint8_t)buf; - } - if (err) { - return ERR_IOEXP_UNEXCPT; - } - return 0; -} - - -static int -common_ioexp_update_all(struct ioexp_obj_s *self, - int show_err, - char *caller_name){ - - int err = 0; - int chip_id = 0; - int chip_amount = self->ioexp_map_p->chip_amount; - - for (chip_id=0; chip_idioexp_map_p->map_addr[chip_id]), - chip_id, - self->ioexp_map_p->data_width, - show_err, - caller_name) < 0) { - err = 1; - } - } - if (err) { - return ERR_IOEXP_UNEXCPT; - } - return 0; -} - - -static int -_common_check_by_mode(struct ioexp_obj_s *self){ - - switch (self->mode){ - case IOEXP_MODE_DIRECT: - return self->fsm_4_direct(self); - - case IOEXP_MODE_POLLING: - if (self->state >= 0){ - return 0; - } - switch (self->state){ - case STATE_IOEXP_INIT: - return ERR_IOEXP_UNINIT; - case STATE_IOEXP_ABNORMAL: - return ERR_IOEXP_ABNORMAL; - default: - return ERR_IOEXP_NOSTATE; - } - break; - - default: - break; - } - SWPS_ERR("%s: Exception occurs. :%d \n", __func__, self->mode); - return ERR_IOEXP_UNEXCPT; -} - - -static int -_common_get_bit(struct ioexp_obj_s *self, - struct ioexp_bitmap_s *bitmap_obj_p, - char *func_mane){ - uint8_t buf; - int err_code; - - /* Check and get address */ - err_code = _common_check_by_mode(self); - if (err_code < 0){ - return err_code; - } - if (!bitmap_obj_p){ - SWPS_ERR("Layout config incorrect! :%d :%s\n", - self->ioexp_id, func_mane); - return ERR_IOEXP_BADCONF; - } - /* Get data form cache */ - buf = self->chip_data[bitmap_obj_p->chip_id].data[bitmap_obj_p->ioexp_voffset]; - return (int)(buf >> bitmap_obj_p->bit_shift & 0x01); -} - - -static int -_common_set_bit(struct ioexp_obj_s *self, - struct ioexp_bitmap_s *bitmap_obj_p, - int input_val, - char *func_mane){ - int err_code, target_offset; - uint8_t origin_byte; - uint8_t modify_byte; - - /* Check and get address */ - err_code = _common_check_by_mode(self); - if (err_code < 0){ - return err_code; - } - if (!bitmap_obj_p){ - SWPS_ERR("Layout config incorrect! :%d :%s\n", - self->ioexp_id, func_mane); - return ERR_IOEXP_BADCONF; - } - /* Prepare write date */ - origin_byte = self->chip_data[bitmap_obj_p->chip_id].data[bitmap_obj_p->ioexp_voffset]; - switch (input_val) { - case 0: - modify_byte = origin_byte; - SWP_BIT_CLEAR(modify_byte, bitmap_obj_p->bit_shift); - break; - case 1: - modify_byte = origin_byte; - SWP_BIT_SET(modify_byte, bitmap_obj_p->bit_shift); - break; - default: - SWPS_ERR("Input value incorrect! :%d :%d :%s\n", - input_val, self->ioexp_id, func_mane); - return ERR_IOEXP_BADINPUT; - } - /* Setup i2c client */ - target_offset = self->ioexp_map_p->map_addr[bitmap_obj_p->chip_id].write_offset[bitmap_obj_p->ioexp_voffset]; - /* Write byte to chip via I2C */ - err_code = i2c_smbus_write_byte_data(_get_i2c_client(self, bitmap_obj_p->chip_id), - target_offset, - modify_byte); - /* Update or bollback object */ - if (err_code < 0){ - self->chip_data[bitmap_obj_p->chip_id].data[bitmap_obj_p->ioexp_voffset] = origin_byte; - SWPS_ERR("I2C write fail! :%d :%d :%s :%d\n", - input_val, self->ioexp_id, func_mane, err_code); - return err_code; - } - self->chip_data[bitmap_obj_p->chip_id].data[bitmap_obj_p->ioexp_voffset] = modify_byte; - return 0; -} - - -/* ========== Object public functions ========== - */ -int -common_get_present(struct ioexp_obj_s *self, - int virt_offset){ - - int UNPLUG = 1; - int retval = ERR_IOEXP_UNEXCPT; - - retval = _common_get_bit(self, - &(self->ioexp_map_p->map_present[virt_offset]), - "common_get_present"); - if (retval < 0) { - /* [Note] - * => Transceiver object does not need to handle IOEXP layer issues. - */ - return UNPLUG; - } - return retval; -} - - -int -common_get_tx_fault(struct ioexp_obj_s *self, - int virt_offset){ - /* [Transmit Fault (Tx_Fault)] - * A catastrophic laser fault will activate the transmitter signal, - * TX_FAULT, and disable the laser. This signal is an open collector - * output (pull-up required on the host board). A low signal indicates - * normal laser operation and a high signal indicates a fault. The - * TX_FAULT will be latched high when a laser fault occurs and is - * cleared by toggling the TX_DISABLE input or power cycling the - * transceiver. The transmitter fault condition can also be monitored - * via the two-wire serial interface. - * (address A2, byte 110, bit 2). - * - * 0: Normal - * 1: Abnormal - */ - return _common_get_bit(self, - &(self->ioexp_map_p->map_tx_fault[virt_offset]), - "common_get_tx_fault"); -} - - -int -common_get_rxlos(struct ioexp_obj_s *self, - int virt_offset){ - /* [Receiver Loss of Signal (Rx_LOS)] - * The post-amplification IC also includes transition detection circuitry - * which monitors the ac level of incoming optical signals and provides a - * TTL/CMOS compatible status signal to the host (pin 8). An adequate optical - * input results in a low Rx_LOS output while a high Rx_LOS output indicates - * an unusable optical input. The Rx_LOS thresholds are factory set so that - * a high output indicates a definite optical fault has occurred. Rx_LOS can - * also be monitored via the two-wire serial interface - * (address A2h, byte 110, bit 1). - * - * 0: Normal - * 1: Abnormal - */ - return _common_get_bit(self, - &(self->ioexp_map_p->map_rxlos[virt_offset]), - "common_get_rxlos"); -} - - -int -common_get_tx_disable(struct ioexp_obj_s *self, - int virt_offset){ - - return _common_get_bit(self, - &(self->ioexp_map_p->map_tx_disable[virt_offset]), - "common_get_tx_disable"); -} - - -int -common_get_reset(struct ioexp_obj_s *self, - int virt_offset){ - - return _common_get_bit(self, - &(self->ioexp_map_p->map_reset[virt_offset]), - "common_get_reset"); -} - - -int -common_get_lpmod(struct ioexp_obj_s *self, - int virt_offset){ - - return _common_get_bit(self, - &(self->ioexp_map_p->map_lpmod[virt_offset]), - "common_get_lpmod"); -} - - -int -common_get_modsel(struct ioexp_obj_s *self, - int virt_offset){ - - return _common_get_bit(self, - &(self->ioexp_map_p->map_modsel[virt_offset]), - "common_get_modsel"); -} - - -int -common_get_hard_rs0(struct ioexp_obj_s *self, - int virt_offset){ - - return _common_get_bit(self, - &(self->ioexp_map_p->map_hard_rs0[virt_offset]), - "common_get_hard_rs0"); -} - - -int -common_get_hard_rs1(struct ioexp_obj_s *self, - int virt_offset){ - - return _common_get_bit(self, - &(self->ioexp_map_p->map_hard_rs1[virt_offset]), - "common_get_hard_rs1"); -} - - -int -common_set_tx_disable(struct ioexp_obj_s *self, - int virt_offset, - int input_val){ - - return _common_set_bit(self, - &(self->ioexp_map_p->map_tx_disable[virt_offset]), - input_val, - "common_set_tx_disable"); -} - - -int -common_set_reset(struct ioexp_obj_s *self, - int virt_offset, - int input_val){ - - return _common_set_bit(self, - &(self->ioexp_map_p->map_reset[virt_offset]), - input_val, - "common_set_reset"); -} - - -int -common_set_lpmod(struct ioexp_obj_s *self, - int virt_offset, - int input_val){ - - return _common_set_bit(self, - &(self->ioexp_map_p->map_lpmod[virt_offset]), - input_val, - "common_set_lpmod"); -} - - -int -common_set_modsel(struct ioexp_obj_s *self, - int virt_offset, - int input_val){ - - return _common_set_bit(self, - &(self->ioexp_map_p->map_modsel[virt_offset]), - input_val, - "common_set_modsel"); -} - - -int -common_set_hard_rs0(struct ioexp_obj_s *self, - int virt_offset, - int input_val){ - - return _common_set_bit(self, - &(self->ioexp_map_p->map_hard_rs0[virt_offset]), - input_val, - "common_set_hard_rs0"); -} - - -int -common_set_hard_rs1(struct ioexp_obj_s *self, - int virt_offset, - int input_val){ - - return _common_set_bit(self, - &(self->ioexp_map_p->map_hard_rs1[virt_offset]), - input_val, - "common_set_hard_rs1"); -} - - -int -ioexp_get_not_support(struct ioexp_obj_s *self, - int virt_offset){ - return ERR_IOEXP_NOTSUPPORT; -} - - -int -ioexp_set_not_support(struct ioexp_obj_s *self, - int virt_offset, - int input_val){ - return ERR_IOEXP_NOTSUPPORT; -} - - -int -fake_ioexp_init(struct ioexp_obj_s *self){ - return 1; -} - -int -fake_ioexp_update(struct ioexp_obj_s *self){ - return 1; -} - - -int -fake_update_func(struct ioexp_obj_s *self){ - return 1; -} - -int -fake_get_func(struct ioexp_obj_s *self, - int virt_offset){ - SWPS_WARN("Someone called fake_get_func\n"); - return -1; -} - -int -fake_set_func(struct ioexp_obj_s *self, - int virt_offset, - int input_val){ - SWPS_WARN("Someone called fake_set_func\n"); - return -1; -} - - -/* ========== Initial functions for IO Expander ========== - */ -int -common_ioexp_init(struct ioexp_obj_s *self) { - - int chip_id, offset, err_code; - struct ioexp_addr_s *addr_p; - - if (self->mode == IOEXP_MODE_DIRECT) { - goto update_common_ioexp_init; - } - /* Setup default value to each physical IO Expander */ - for (chip_id=0; chip_id<(self->ioexp_map_p->chip_amount); chip_id++){ - /* Get address mapping */ - addr_p = &(self->ioexp_map_p->map_addr[chip_id]); - if (!addr_p){ - SWPS_ERR("%s: IOEXP config incorrect! :%d \n", - __func__, chip_id); - return -1; - } - /* Setup default value */ - for (offset=0; offset<(self->ioexp_map_p->data_width); offset++){ - - /* [Desc] Skip the setup default value behavior - [Note] Setup default value = -1 if you don't want to write the value to IOEXP or CPLD - */ - if(addr_p->write_offset[offset] < 0){ - SWPS_DEBUG("skip a write_offset <%d>\n", addr_p->conf_offset[offset]); - continue; - } - err_code = i2c_smbus_write_byte_data(_get_i2c_client(self, chip_id), - addr_p->write_offset[offset], - addr_p->data_default[offset]); - if (err_code < 0){ - SWPS_ERR("%s: set default fail! :%d \n", - __func__, err_code); - return ERR_IOEXP_UNEXCPT; - } - } - } -update_common_ioexp_init: - /* Check and update info to object */ - err_code = self->update_all(self, 1, "common_ioexp_init"); - if (err_code < 0) { - SWPS_ERR("%s: update_all() fail! :%d \n", - __func__, err_code); - return ERR_IOEXP_UNEXCPT; - } - return 0; -} - - -/* ========== Object functions for Final State Machine ========== - */ -int -_is_channel_ready(struct ioexp_obj_s *self){ - - int buf = 0; - int chip_id = 0; /* Use first chip which be registered */ - int data_id = 0; /* Use first byte which be registered */ - struct ioexp_addr_s *ioexp_addr = NULL; - - ioexp_addr = &(self->ioexp_map_p->map_addr[chip_id]); - if (!ioexp_addr){ - SWPS_ERR("%s: config incorrect!\n", __func__); - return ERR_IOEXP_UNEXCPT; - } - buf = i2c_smbus_read_byte_data(_get_i2c_client(self, chip_id), - ioexp_addr->read_offset[data_id]); - if (buf >= 0){ - return 1; - } - return 0; -} - -int -_ioexp_init_handler(struct ioexp_obj_s *self){ - - int return_val; - - switch (self->mode) { - case IOEXP_MODE_DIRECT: - return_val = self->init(self); - if (return_val < 0){ - self->state = STATE_IOEXP_ABNORMAL; - } else { - self->state = STATE_IOEXP_NORMAL; - } - return return_val; - - case IOEXP_MODE_POLLING: - /* Check system and channel is ready */ - if (self->state == STATE_IOEXP_INIT){ - if (!_is_channel_ready(self)){ - self->state = STATE_IOEXP_INIT; - SWPS_WARN("%s: IOEXP:%d channel not ready.\n", - __func__, self->ioexp_id); - return 0; - } - } - /* Execute initial callback */ - return_val = self->init(self); - if (return_val < 0){ - self->state = STATE_IOEXP_ABNORMAL; - } else { - self->state = STATE_IOEXP_NORMAL; - } - return return_val; - - default: - break; - } - SWPS_ERR("%s: exception occur :%d\n", __func__, self->mode); - return ERR_IOEXP_UNEXCPT; -} - - -int -common_ioexp_fsm_4_direct(struct ioexp_obj_s *self){ - - int result_val; - int show_err = 1; - char *func_mane = "common_ioexp_fsm_4_direct"; - - switch (self->state){ - case STATE_IOEXP_INIT: - result_val = _ioexp_init_handler(self); - /* Exception case: terminate initial procedure */ - if(result_val < 0){ - /* Initial fail */ - return result_val; - } - if(self->state == STATE_IOEXP_INIT){ - /* Keep in INIT state, and return error */ - return ERR_IOEXP_UNINIT; - } - /* Case: Initial done */ - return 0; - - case STATE_IOEXP_NORMAL: - result_val = self->update_all(self, show_err, func_mane); - if (result_val < 0){ - SWPS_INFO("%s: NORMAL -> ABNORMAL :%d\n", - __func__, result_val); - self->state = STATE_IOEXP_ABNORMAL; - return result_val; - } - self->state = STATE_IOEXP_NORMAL; - return 0; - - case STATE_IOEXP_ABNORMAL: - result_val = self->update_all(self, show_err, func_mane); - if (result_val < 0){ - self->state = STATE_IOEXP_ABNORMAL; - return result_val; - } - SWPS_DEBUG("%s: ABNORMAL -> NORMAL :%d\n", - __func__, result_val); - self->state = STATE_IOEXP_NORMAL; - return 0; - - default: - break; - } - SWPS_ERR("%s: Exception occurs :%d\n", - __func__, self->state); - return ERR_IOEXP_UNEXCPT; -} - - -int -common_ioexp_fsm_4_polling(struct ioexp_obj_s *self){ - - int result_val, i, show_e; - int fail_retry = 3; - char *func_name = "common_ioexp_fsm_4_polling"; - -#ifdef DEBUG_SWPS - show_e = 1; -#else - show_e = 0; -#endif - - switch (self->state){ - case STATE_IOEXP_INIT: - result_val = _ioexp_init_handler(self); - /* Exception case: terminate initial procedure */ - if(result_val < 0){ - /* Initial fail */ - return result_val; - } - /* Case: System (Channel) not ready */ - if(self->state == STATE_IOEXP_INIT){ - /* Keep in INIT state, wait and retry */ - return 0; - } - /* Case: Initial done */ - SWPS_INFO("IOEXP-%d: initial done. :%d\n", - self->ioexp_id, self->ioexp_type); - return result_val; - - case STATE_IOEXP_NORMAL: - /* Retry mechanism for case of i2c topology not stable */ - for (i=0; iupdate_all(self, show_e, func_name); - if (result_val >= 0) { - self->state = STATE_IOEXP_NORMAL; - return 0; - } - if (check_channel_tier_1() < 0) { - SWPS_INFO("%s: detect I2C crash :%d\n", - __func__, self->ioexp_id); - break; - } - SWPS_DEBUG("IOEXP-%d: unstable :%d\n", - self->ioexp_id, result_val); - } - SWPS_INFO("IOEXP-%d: NORMAL -> ABNORMAL :%d\n", - self->ioexp_id, result_val); - self->state = STATE_IOEXP_ABNORMAL; - return result_val; - - case STATE_IOEXP_ABNORMAL: - result_val = self->update_all(self, show_e, func_name); - if (result_val < 0){ - self->state = STATE_IOEXP_ABNORMAL; - return result_val; - } - SWPS_INFO("IOEXP-%d: ABNORMAL -> NORMAL :%d\n", - self->ioexp_id, result_val); - self->state = STATE_IOEXP_NORMAL; - return 0; - - default: - break; - } - SWPS_ERR("IOEXP-%d: Exception occurs :%d\n", - self->ioexp_id, self->state); - return ERR_IOEXP_UNEXCPT; -} - - -/* ========== Object private functions for check & update ========== - */ -int -common_ioexp_check(struct ioexp_obj_s *self){ - - int result; - - if (self->mode != IOEXP_MODE_POLLING){ - SWPS_ERR("%s: not polling mode :%d\n", - __func__, self->mode); - return ERR_IOEXP_NOTSUPPORT; - } - mutex_lock(&self->lock); - result = self->fsm_4_polling(self); - mutex_unlock(&self->lock); - return result; -} - - -/* ========== Functions for Factory pattern ========== - */ -static struct ioexp_map_s * -get_ioexp_map(int ioexp_type){ - switch (ioexp_type){ - case IOEXP_TYPE_MAGINOLIA_NAB: - return &ioexp_map_magnolia_nab; - case IOEXP_TYPE_MAGINOLIA_4AB: - return &ioexp_map_magnolia_4ab; - case IOEXP_TYPE_MAGINOLIA_7AB: - case IOEXP_TYPE_SPRUCE_7AB: - return &ioexp_map_magnolia_7ab; - case IOEXP_TYPE_REDWOOD_P01P08: - return &ioexp_map_redwood_p01p08_p17p24; - case IOEXP_TYPE_REDWOOD_P09P16: - return &ioexp_map_redwood_p09p16_p25p32; - case IOEXP_TYPE_HUDSON32IGA_P01P08: - return &ioexp_map_hudson32iga_p01p08_p17p24; - case IOEXP_TYPE_HUDSON32IGA_P09P16: - return &ioexp_map_hudson32iga_p09p16_p25p32; - case IOEXP_TYPE_CYPRESS_NABC: - return &ioexp_map_cypress_nabc; - case IOEXP_TYPE_CYPRESS_7ABC: - return &ioexp_map_cypress_7abc; - case IOEXP_TYPE_TAHOE_5A: - return &ioexp_map_tahoe_5a; - case IOEXP_TYPE_TAHOE_6ABC: - return &ioexp_map_tahoe_6abc; - case IOEXP_TYPE_SEQUOIA_NABC: - return &ioexp_map_sequoia_nabc; - case IOEXP_TYPE_LAVENDER_P65: - return &ioexp_map_lavender_p65; - case CPLD_TYPE_COTTONWOOD: - return &cpld_map_cottonwood; - default: - return NULL; - } -} - - -int -setup_ioexp_ssize_attr(struct ioexp_obj_s *self, - struct ioexp_map_s *ioexp_map_p, - int ioexp_id, - int ioexp_type, - int run_mode){ - switch (run_mode){ - case IOEXP_MODE_POLLING: /* Direct access device mode */ - case IOEXP_MODE_DIRECT: /* Polling mode, read from cache */ - self->mode = run_mode; - break; - default: - SWPS_ERR("%s: non-defined run_mode:%d\n", - __func__, run_mode); - self->mode = ERR_IOEXP_UNEXCPT; - return ERR_IOEXP_UNEXCPT; - } - /* Setup mapping structure */ - self->ioexp_map_p = kzalloc(sizeof(*ioexp_map_p), GFP_KERNEL); - if (!(self->ioexp_map_p)) { - SWPS_ERR("%s: kzalloc ioexp_map_p fail\n", __func__); - return -1; - } - memcpy(self->ioexp_map_p, ioexp_map_p, sizeof(*ioexp_map_p)); - /* Setup attributes */ - self->ioexp_id = ioexp_id; - self->ioexp_type = ioexp_type; - self->state = STATE_IOEXP_INIT; - mutex_init(&self->lock); - return 0; -} - - -static int -setup_addr_mapping(struct ioexp_obj_s *self, - struct ioexp_addr_s *addr_map_p, - int chip_amount){ - struct ioexp_addr_s *tmp_p; - if (!addr_map_p){ - SWPS_ERR("%s: map is null\n", __func__); - return -1; - } - tmp_p = kzalloc((sizeof(*addr_map_p) * chip_amount), GFP_KERNEL); - if (!tmp_p){ - SWPS_ERR("%s: kzalloc fail.\n", __func__); - return -1; - } - memcpy(tmp_p, addr_map_p, (sizeof(*addr_map_p) * chip_amount)); - self->ioexp_map_p->map_addr = tmp_p; - - return 0; -} - - -static int -setup_ioexp_public_cb(struct ioexp_obj_s *self, - int ioexp_type){ - - switch (ioexp_type){ - case IOEXP_TYPE_MAGINOLIA_NAB: - case IOEXP_TYPE_MAGINOLIA_4AB: - case CPLD_TYPE_COTTONWOOD: - self->get_present = common_get_present; - self->get_tx_fault = common_get_tx_fault; - self->get_rxlos = common_get_rxlos; - self->get_tx_disable = common_get_tx_disable; - self->get_reset = ioexp_get_not_support; - self->get_lpmod = ioexp_get_not_support; - self->get_modsel = ioexp_get_not_support; - self->get_hard_rs0 = ioexp_get_not_support; - self->get_hard_rs1 = ioexp_get_not_support; - self->set_tx_disable = common_set_tx_disable; - self->set_reset = ioexp_set_not_support; - self->set_lpmod = ioexp_set_not_support; - self->set_modsel = ioexp_set_not_support; - self->set_hard_rs0 = ioexp_set_not_support; - self->set_hard_rs1 = ioexp_set_not_support; - return 0; - case IOEXP_TYPE_CYPRESS_NABC: - self->get_present = common_get_present; - self->get_tx_fault = common_get_tx_fault; - self->get_rxlos = common_get_rxlos; - self->get_tx_disable = common_get_tx_disable; - self->get_reset = ioexp_get_not_support; - self->get_lpmod = ioexp_get_not_support; - self->get_modsel = ioexp_get_not_support; - self->get_hard_rs0 = common_get_hard_rs0; - self->get_hard_rs1 = common_get_hard_rs1; - self->set_tx_disable = common_set_tx_disable; - self->set_reset = ioexp_set_not_support; - self->set_lpmod = ioexp_set_not_support; - self->set_modsel = ioexp_set_not_support; - self->set_hard_rs0 = common_set_hard_rs0; - self->set_hard_rs1 = common_set_hard_rs1; - return 0; - case IOEXP_TYPE_MAGINOLIA_7AB: - case IOEXP_TYPE_SPRUCE_7AB: - case IOEXP_TYPE_REDWOOD_P01P08: - case IOEXP_TYPE_REDWOOD_P09P16: - case IOEXP_TYPE_HUDSON32IGA_P01P08: - case IOEXP_TYPE_HUDSON32IGA_P09P16: - case IOEXP_TYPE_CYPRESS_7ABC: - case IOEXP_TYPE_TAHOE_5A: - case IOEXP_TYPE_TAHOE_6ABC: - case IOEXP_TYPE_SEQUOIA_NABC: - case IOEXP_TYPE_LAVENDER_P65: - self->get_present = common_get_present; - self->get_tx_fault = ioexp_get_not_support; - self->get_rxlos = ioexp_get_not_support; - self->get_tx_disable = ioexp_get_not_support; - self->get_reset = common_get_reset; - self->get_lpmod = common_get_lpmod; - self->get_modsel = common_get_modsel; - self->get_hard_rs0 = ioexp_get_not_support; - self->get_hard_rs1 = ioexp_get_not_support; - self->set_tx_disable = ioexp_set_not_support; - self->set_reset = common_set_reset; - self->set_lpmod = common_set_lpmod; - self->set_modsel = common_set_modsel; - self->set_hard_rs0 = ioexp_set_not_support; - self->set_hard_rs1 = ioexp_set_not_support; - return 0; - - default: - SWPS_ERR("%s: type:%d incorrect!\n", __func__, ioexp_type); - break; - } - return ERR_IOEXP_UNEXCPT; -} - - -static int -setup_ioexp_private_cb(struct ioexp_obj_s *self, - int ioexp_type){ - - switch (ioexp_type){ - case IOEXP_TYPE_MAGINOLIA_NAB: - case IOEXP_TYPE_MAGINOLIA_4AB: - case IOEXP_TYPE_MAGINOLIA_7AB: - case IOEXP_TYPE_SPRUCE_7AB: - case IOEXP_TYPE_REDWOOD_P01P08: - case IOEXP_TYPE_REDWOOD_P09P16: - case IOEXP_TYPE_HUDSON32IGA_P01P08: - case IOEXP_TYPE_HUDSON32IGA_P09P16: - case IOEXP_TYPE_CYPRESS_NABC: - case IOEXP_TYPE_CYPRESS_7ABC: - case IOEXP_TYPE_TAHOE_5A: - case IOEXP_TYPE_TAHOE_6ABC: - case IOEXP_TYPE_SEQUOIA_NABC: - case IOEXP_TYPE_LAVENDER_P65: - case CPLD_TYPE_COTTONWOOD: - self->init = common_ioexp_init; - self->check = common_ioexp_check; - self->update_all = common_ioexp_update_all; - self->fsm_4_direct = common_ioexp_fsm_4_direct; - self->fsm_4_polling = common_ioexp_fsm_4_polling; - return 0; - - default: - SWPS_ERR("%s: type:%d incorrect!\n", __func__, ioexp_type); - break; - } - return ERR_IOEXP_UNEXCPT; -} - - -static int -setup_i2c_client_one(struct ioexp_obj_s *self, - int chip_id){ - - char *err_msg = "ERROR"; - struct i2c_adapter *adap = NULL; - struct i2c_client *client = NULL; - struct ioexp_i2c_s *i2c_obj_p = NULL; - struct ioexp_i2c_s *i2c_curr_p = NULL; - - int chan_id = self->ioexp_map_p->map_addr[chip_id].chan_id; - adap = i2c_get_adapter(chan_id); - if(!adap){ - err_msg = "Can not get adap!"; - goto err_ioexp_setup_i2c_1; - } - client = kzalloc(sizeof(*client), GFP_KERNEL); - if (!client){ - err_msg = "Can not kzalloc client!"; - goto err_ioexp_setup_i2c_1; - } - i2c_obj_p = kzalloc(sizeof(*i2c_obj_p), GFP_KERNEL); - if (!i2c_obj_p){ - err_msg = "Can not kzalloc i2c_obj_p!"; - goto err_ioexp_setup_i2c_2; - } - client->adapter = adap; - client->addr = self->ioexp_map_p->map_addr[chip_id].chip_addr; - i2c_obj_p->i2c_client_p = client; - i2c_obj_p->chip_id = chip_id; - i2c_obj_p->next = NULL; - if (!self->i2c_head_p){ - self->i2c_head_p = i2c_obj_p; - } else { - i2c_curr_p = self->i2c_head_p; - while (i2c_curr_p->next){ - i2c_curr_p = i2c_curr_p->next; - } - i2c_curr_p->next = i2c_obj_p; - } - return 0; - -err_ioexp_setup_i2c_2: - kfree(client); -err_ioexp_setup_i2c_1: - SWPS_ERR("%s: %s :%d\n", __func__, err_msg, chan_id); - return -1; -} - - -static int -setup_i2c_client(struct ioexp_obj_s* self){ - - int result; - int chip_id = 0; - - for (chip_id=0; chip_id<(self->ioexp_map_p->chip_amount); chip_id++){ - result = setup_i2c_client_one(self, chip_id); - if (result < 0){ - SWPS_ERR("%s fail! :%d\n", __func__, chip_id); - return -1; - } - } - return 0; -} - - -static int -setup_ioexp_config(struct ioexp_obj_s *self) { - - int chip_id, offset, err_code; - struct ioexp_addr_s *addr_p; - - for (chip_id=0; chip_id<(self->ioexp_map_p->chip_amount); chip_id++){ - addr_p = &(self->ioexp_map_p->map_addr[chip_id]); - if (!addr_p){ - SWPS_ERR("IOEXP config incorrect! :%d \n",chip_id); - return -1; - } - for (offset=0; offset<(self->ioexp_map_p->data_width); offset++){ - - /* [Desc] Skip the setup config value behavior - [Note] Setup config value = -1 if you don't want to write the value to IOEXP or CPLD - */ - if(addr_p->conf_offset[offset] < 0){ - SWPS_DEBUG("skip a config_offset <%d>\n", addr_p->conf_offset[offset]); - continue; - } - err_code = i2c_smbus_write_byte_data(_get_i2c_client(self, chip_id), - addr_p->conf_offset[offset], - addr_p->conf_default[offset]); - - if (err_code < 0){ - SWPS_INFO("%s: set conf fail! :%d \n", __func__, err_code); - return -2; - } - } - } - return 0; -} - - -struct ioexp_obj_s * -_create_ioexp_obj(int ioexp_id, - int ioexp_type, - struct ioexp_addr_s *addr_map_p, - int run_mode){ - - struct ioexp_map_s* ioexp_map_p; - struct ioexp_obj_s* result_p; - struct ioexp_i2c_s *i2c_curr_p; - struct ioexp_i2c_s *i2c_next_p; - - /* Get layout */ - ioexp_map_p = get_ioexp_map(ioexp_type); - if (!ioexp_map_p){ - SWPS_ERR("%s: Invalid ioexp_type\n", __func__); - goto err_create_ioexp_fail; - } - /* Prepare IOEXP object */ - result_p = kzalloc(sizeof(*result_p), GFP_KERNEL); - if (!result_p){ - SWPS_ERR("%s: kzalloc failure!\n", __func__); - goto err_create_ioexp_fail; - } - /* Prepare static size attributes */ - if (setup_ioexp_ssize_attr(result_p, - ioexp_map_p, - ioexp_id, - ioexp_type, - run_mode) < 0){ - goto err_create_ioexp_setup_attr_fail; - } - /* Prepare address mapping */ - if (setup_addr_mapping(result_p, addr_map_p, ioexp_map_p->chip_amount) < 0){ - goto err_create_ioexp_setup_attr_fail; - } - if (setup_i2c_client(result_p) < 0){ - goto err_create_ioexp_setup_i2c_fail; - } - /* Prepare call back functions of object */ - if (setup_ioexp_public_cb(result_p, ioexp_type) < 0){ - goto err_create_ioexp_setup_i2c_fail; - } - if (setup_ioexp_private_cb(result_p, ioexp_type) < 0){ - goto err_create_ioexp_setup_i2c_fail; - } - return result_p; - -err_create_ioexp_setup_i2c_fail: - i2c_curr_p = result_p->i2c_head_p; - i2c_next_p = result_p->i2c_head_p; - while (i2c_curr_p){ - i2c_next_p = i2c_curr_p->next; - kfree(i2c_curr_p->i2c_client_p); - kfree(i2c_curr_p); - i2c_curr_p = i2c_next_p; - } -err_create_ioexp_setup_attr_fail: - kfree(result_p); -err_create_ioexp_fail: - SWPS_ERR("%s: fail! :%d :%d \n", - __func__, ioexp_id, ioexp_type); - return NULL; -} - - -int -create_ioexp_obj(int ioexp_id, - int ioexp_type, - struct ioexp_addr_s *addr_map_p, - int run_mode){ - - struct ioexp_obj_s *ioexp_p = NULL; - - ioexp_p = _create_ioexp_obj(ioexp_id, ioexp_type, - addr_map_p, run_mode); - if (!ioexp_p){ - return -1; - } - if (ioexp_head_p == NULL){ - ioexp_head_p = ioexp_p; - ioexp_tail_p = ioexp_p; - return 0; - } - ioexp_tail_p->next = ioexp_p; - ioexp_tail_p = ioexp_p; - return 0; -} - - -static int -_init_ioexp_obj(struct ioexp_obj_s* self) { - - char *err_msg = "ERR"; - char *func_name = "_init_ioexp_obj"; - - /* Setup IOEXP configure byte */ - if (setup_ioexp_config(self) < 0){ - err_msg = "setup_ioexp_config fail"; - goto err_init_ioexp_obj; - } - /* Setup default data */ - if (_ioexp_init_handler(self) < 0){ - err_msg = "_ioexp_init_handler fail"; - goto err_init_ioexp_obj; - } - /* Update all */ - if (self->state == STATE_IOEXP_NORMAL){ - if (self->update_all(self, 1, func_name) < 0){ - err_msg = "update_all() fail"; - goto err_init_ioexp_obj; - } - } - return 0; - -err_init_ioexp_obj: - SWPS_DEBUG("%s: %s\n", __func__, err_msg); - return -1; -} - - -int -init_ioexp_objs(void){ - /* Return value: - * 0: Success - * -1: Detect topology error - * -2: SWPS internal error - */ - - struct ioexp_obj_s *curr_p = ioexp_head_p; - - if (!curr_p) { - SWPS_ERR("%s: ioexp_head_p is NULL\n", __func__); - return -2; - } - while (curr_p) { - if (_init_ioexp_obj(curr_p) < 0) { - SWPS_DEBUG("%s: _init_ioexp_obj() fail\n", __func__); - return -1; - } - curr_p = curr_p->next; - } - SWPS_DEBUG("%s: done.\n", __func__); - return 0; -} - - -void -clean_ioexp_objs(void){ - - struct ioexp_i2c_s *i2c_curr_p = NULL; - struct ioexp_i2c_s *i2c_next_p = NULL; - struct ioexp_obj_s *ioexp_next_p = NULL; - struct ioexp_obj_s *ioexp_curr_p = ioexp_head_p; - - if (ioexp_head_p == NULL){ - ioexp_tail_p = NULL; - return; - } - while(ioexp_curr_p){ - ioexp_next_p = ioexp_curr_p->next; - if (ioexp_curr_p->ioexp_map_p) { - if (ioexp_curr_p->ioexp_map_p->map_addr) { - kfree(ioexp_curr_p->ioexp_map_p->map_addr); - } - kfree(ioexp_curr_p->ioexp_map_p); - } - - i2c_curr_p = ioexp_curr_p->i2c_head_p; - while (i2c_curr_p) { - i2c_next_p = i2c_curr_p->next; - kfree(i2c_curr_p->i2c_client_p); - kfree(i2c_curr_p); - i2c_curr_p = i2c_next_p; - } - kfree(ioexp_curr_p); - ioexp_curr_p = ioexp_next_p; - } - ioexp_tail_p = NULL; - SWPS_DEBUG("%s: done.\n", __func__); -} - - -int -check_ioexp_objs(void){ - - struct ioexp_obj_s *ioexp_curr_p = ioexp_head_p; - - while (ioexp_curr_p){ - if ( (ioexp_curr_p->check(ioexp_curr_p)) < 0){ - SWPS_INFO("check IOEXP-%d fail! :%d\n", - ioexp_curr_p->ioexp_id, ioexp_curr_p->ioexp_type); - return -1; - } - ioexp_curr_p = ioexp_curr_p->next; - } - return 0; -} - - -struct ioexp_obj_s * -get_ioexp_obj(int ioexp_id){ - - struct ioexp_obj_s *result_p = NULL; - struct ioexp_obj_s *ioexp_curr_p = ioexp_head_p; - - while(ioexp_curr_p){ - if (ioexp_curr_p->ioexp_id == ioexp_id){ - result_p = ioexp_curr_p; - break; - } - ioexp_curr_p = ioexp_curr_p->next; - } - return result_p; -} - - -void -unlock_ioexp_all(void) { - - struct ioexp_obj_s *ioexp_curr_p = ioexp_head_p; - - while(ioexp_curr_p){ - mutex_unlock(&ioexp_curr_p->lock); - ioexp_curr_p = ioexp_curr_p->next; - } -} - - -int -lock_ioexp_all(void) { - - struct ioexp_obj_s *ioexp_curr_p = ioexp_head_p; - - while(ioexp_curr_p){ - mutex_lock(&ioexp_curr_p->lock); - ioexp_curr_p = ioexp_curr_p->next; - } - return 0; -} - - -int -check_channel_tier_1(void) { - - if ( (!_is_channel_ready(ioexp_head_p)) && - (!_is_channel_ready(ioexp_tail_p)) ){ - return -1; - } - return 0; -} - - -static int -_scan_channel_tier_1(int force, - int show_err) { - - struct ioexp_obj_s *ioexp_curr_p = ioexp_head_p; - int ready = 0; - - if (!ioexp_curr_p) { - goto err_scan_tier_1_channel; - } - while(ioexp_curr_p) { - ready = _is_channel_ready(ioexp_curr_p); - if ((!ready) && (!force)) { - goto err_scan_tier_1_channel; - } - ioexp_curr_p = ioexp_curr_p->next; - } - return 0; - -err_scan_tier_1_channel: - if (show_err) { - if (ioexp_curr_p) { - SWPS_INFO("%s: IOEXP-%d fail\n", __func__, ioexp_curr_p->ioexp_id); - } else { - SWPS_INFO("%s: IOEXP is null.\n", __func__); - } - } - return -1; -} - - -static int -_scan_channel_tier_1_single(void) { - - int ret = 0; - int chan_id = 0; - int fake_cid = 0; - int fake_offs = 0; - int fake_addr = 0; - struct i2c_adapter *adap = NULL; - struct i2c_client *client = NULL; - - if (ioexp_head_p->ioexp_id != ioexp_tail_p->ioexp_id) { - return 0; - } - /* Setup i2c_client */ - chan_id = ioexp_head_p->ioexp_map_p->map_addr[fake_cid].chan_id; - fake_addr = ioexp_head_p->ioexp_map_p->map_addr[fake_cid].chip_addr; - adap = i2c_get_adapter((chan_id + 1)); - if(!adap){ - SWPS_INFO("%s: Can not get adap!\n", __func__); - return 0; - } - client = kzalloc(sizeof(*client), GFP_KERNEL); - if (!client){ - SWPS_INFO("%s: Can not kzalloc client!\n", __func__); - return 0; - } - client->adapter = adap; - client->addr = fake_addr; - /* Fouce move ioexp ptr to next */ - ret = i2c_smbus_read_byte_data(client, fake_offs); - SWPS_DEBUG("%s: move ioexp_ptr done. :%d\n", __func__, ret); - kfree(client); - return 1; -} - - -int -resync_channel_tier_1(void) { - - char *emsg = "ERR"; - - if (!ioexp_head_p) { - emsg = "ioexp_head_p is NULL"; - goto err_resync_ioexp_status_1; - } - /* Run all */ - if (ioexp_head_p->ioexp_id == ioexp_tail_p->ioexp_id) { - _scan_channel_tier_1_single(); - } else { - _scan_channel_tier_1(1, 0); - } - /* Check all */ - if (_scan_channel_tier_1(0, 1) < 0) { - emsg = "resync tier-1 channel fail"; - goto err_resync_ioexp_status_1; - } - return 0; - -err_resync_ioexp_status_1: - SWPS_ERR("%s: %s\n", __func__, emsg); - return -1; -} - - - - - - - diff --git a/packages/platforms/inventec/x86-64/d5052/modules/builds/src/io_expander.h b/packages/platforms/inventec/x86-64/d5052/modules/builds/src/io_expander.h deleted file mode 100644 index 784bdb98b..000000000 --- a/packages/platforms/inventec/x86-64/d5052/modules/builds/src/io_expander.h +++ /dev/null @@ -1,178 +0,0 @@ -#ifndef IO_EXPANDER_H -#define IO_EXPANDER_H - -#include - - -/* IOEXP type define (SFP series) */ -#define IOEXP_TYPE_MAGINOLIA_NAB (10101) -#define IOEXP_TYPE_MAGINOLIA_4AB (10102) -#define IOEXP_TYPE_CYPRESS_NABC (10103) - -/* IOEXP type define (QSFP series) */ -#define IOEXP_TYPE_MAGINOLIA_7AB (10201) -#define IOEXP_TYPE_REDWOOD_P01P08 (10202) -#define IOEXP_TYPE_REDWOOD_P09P16 (10203) -#define IOEXP_TYPE_HUDSON32IGA_P01P08 (10204) -#define IOEXP_TYPE_HUDSON32IGA_P09P16 (10205) -#define IOEXP_TYPE_SPRUCE_7AB (10206) -#define IOEXP_TYPE_CYPRESS_7ABC (10207) -#define IOEXP_TYPE_TAHOE_5A (10208) -#define IOEXP_TYPE_TAHOE_6ABC (10209) -#define IOEXP_TYPE_SEQUOIA_NABC (10210) -#define IOEXP_TYPE_LAVENDER_P65 (10211) - -/* CPLD type define */ -#define CPLD_TYPE_COTTONWOOD (10301) - -/* IOEXP mode define */ -#define IOEXP_MODE_POLLING (19000) -#define IOEXP_MODE_DIRECT (19001) - -/* IOEXP state define */ -#define STATE_IOEXP_NORMAL (0) -#define STATE_IOEXP_INIT (-1) -#define STATE_IOEXP_ABNORMAL (-2) - -/* IOEXP error code define */ -#define ERR_IOEXP_NOTSUPPORT (-100) -#define ERR_IOEXP_UNINIT (-101) -#define ERR_IOEXP_BADCONF (-102) -#define ERR_IOEXP_ABNORMAL (-103) -#define ERR_IOEXP_NOSTATE (-104) -#define ERR_IOEXP_BADINPUT (-105) -#define ERR_IOEXP_UNEXCPT (-199) - -#define SWPS_INFO(fmt, args...) printk( KERN_INFO "[SWPS] " fmt, ##args) -#define SWPS_WARN(fmt, args...) printk( KERN_WARNING "[SWPS] " fmt, ##args) -#define SWPS_ERR(fmt, args...) printk( KERN_ERR "[SWPS] " fmt, ##args) - -#ifdef DEBUG_SWPS -# define SWPS_DEBUG(fmt, args...) printk( KERN_DEBUG "[SWPS] " fmt, ##args) -#else -# define SWPS_DEBUG(fmt, args...) -#endif - - -struct ioexp_addr_s { - int chan_id; - int chip_addr; - int read_offset[8]; - int write_offset[8]; - int conf_offset[8]; - uint8_t data_default[8]; - uint8_t conf_default[8]; -}; - -struct ioexp_i2c_s { - int chip_id; - struct i2c_client *i2c_client_p; - struct ioexp_i2c_s *next; -}; - - -struct ioexp_bitmap_s { - int chip_id; /* IOEXP chip id */ - int ioexp_voffset; /* IOEXP virtual offset */ - int bit_shift; -}; - -struct ioexp_map_s { - int chip_amount; /* Number of chips that IOEXP object content */ - int data_width; /* Number of (Read/Write/Config) bytes */ - struct ioexp_addr_s *map_addr; /* Chip address info */ - struct ioexp_bitmap_s map_present[10]; /* IOEXP for SFP / QSFP */ - struct ioexp_bitmap_s map_tx_disable[10]; /* IOEXP for SFP */ - struct ioexp_bitmap_s map_tx_fault[10]; /* IOEXP for SFP */ - struct ioexp_bitmap_s map_rxlos[10]; /* IOEXP for SFP */ - struct ioexp_bitmap_s map_reset[10]; /* IOEXP for QSFP */ - struct ioexp_bitmap_s map_lpmod[10]; /* IOEXP for QSFP */ - struct ioexp_bitmap_s map_modsel[10]; /* IOEXP for QSFP */ - struct ioexp_bitmap_s map_hard_rs0[10]; /* IOEXP for QSFP */ - struct ioexp_bitmap_s map_hard_rs1[10]; /* IOEXP for QSFP */ -}; - -struct ioexp_data_s { - uint8_t data[8]; -}; - -struct ioexp_obj_s { - - /* ============================ - * Object public property - * ============================ - */ - int ioexp_id; - int ioexp_type; - - /* ============================ - * Object private property - * ============================ - */ - struct ioexp_data_s chip_data[16]; /* Max: 8-ioexp in one virt-ioexp(ioexp_obj) */ - struct ioexp_map_s *ioexp_map_p; - struct ioexp_obj_s *next; - struct ioexp_i2c_s *i2c_head_p; - struct mutex lock; - int mode; - int state; - - /* =========================================== - * Object public functions - * =========================================== - */ - int (*get_present)(struct ioexp_obj_s *self, int virt_offset); - int (*get_tx_fault)(struct ioexp_obj_s *self, int virt_offset); - int (*get_rxlos)(struct ioexp_obj_s *self, int virt_offset); - int (*get_tx_disable)(struct ioexp_obj_s *self, int virt_offset); - int (*get_reset)(struct ioexp_obj_s *self, int virt_offset); - int (*get_lpmod)(struct ioexp_obj_s *self, int virt_offset); - int (*get_modsel)(struct ioexp_obj_s *self, int virt_offset); - int (*get_hard_rs0)(struct ioexp_obj_s *self, int virt_offset); - int (*get_hard_rs1)(struct ioexp_obj_s *self, int virt_offset); - int (*set_tx_disable)(struct ioexp_obj_s *self, int virt_offset, int input_val); - int (*set_reset)(struct ioexp_obj_s *self, int virt_offset, int input_val); - int (*set_lpmod)(struct ioexp_obj_s *self, int virt_offset, int input_val); - int (*set_modsel)(struct ioexp_obj_s *self, int virt_offset, int input_val); - int (*set_hard_rs0)(struct ioexp_obj_s *self, int virt_offset, int input_val); - int (*set_hard_rs1)(struct ioexp_obj_s *self, int virt_offset, int input_val); - - /* =========================================== - * Object private functions - * =========================================== - */ - int (*init)(struct ioexp_obj_s *self); - int (*check)(struct ioexp_obj_s *self); - int (*update_all)(struct ioexp_obj_s *self, int show_err, char *caller_name); - int (*fsm_4_direct)(struct ioexp_obj_s* self); - int (*fsm_4_polling)(struct ioexp_obj_s* self); -}; - - -struct ioexp_obj_s* get_ioexp_obj(int ioexp_id); -int create_ioexp_obj(int ioexp_id, - int ioexp_type, - struct ioexp_addr_s *addr_map_p, - int run_mode); -int init_ioexp_objs(void); -int check_ioexp_objs(void); -void clean_ioexp_objs(void); - -void unlock_ioexp_all(void); -int lock_ioexp_all(void); - -int check_channel_tier_1(void); -int resync_channel_tier_1(void); - -/* Macro for bit control */ -#define SWP_BIT_SET(byte_val,bit_shift) ((byte_val) |= (1<<(bit_shift))) -#define SWP_BIT_CLEAR(byte_val,bit_shift) ((byte_val) &= ~(1<<(bit_shift))) - - -#endif /* IO_EXPANDER_H */ - - - - - - diff --git a/packages/platforms/inventec/x86-64/d5052/modules/builds/src/onie_tlvinfo.c b/packages/platforms/inventec/x86-64/d5052/modules/builds/src/onie_tlvinfo.c deleted file mode 100644 index 8138d7918..000000000 --- a/packages/platforms/inventec/x86-64/d5052/modules/builds/src/onie_tlvinfo.c +++ /dev/null @@ -1,815 +0,0 @@ -#include -#include -#include -#include -//#include -#include - -//#include -//#include -#include "onie_tlvinfo.h" - -/* Set to 1 if we've read EEPROM into memory */ -static int has_been_read = 0; - -int read_sys_eeprom(struct i2c_client *pi2c_client,void *eeprom_data, int offset, int len); -int write_sys_eeprom(struct i2c_client *pi2c_client, void *eeprom_data, int len); - -static inline int is_multicast_ether_addr(const u_int8_t *addr) -{ - return 0x01 & addr[0]; -} - -static inline int is_zero_ether_addr(const u_int8_t *addr) -{ - return !(addr[0] | addr[1] | addr[2] | addr[3] | addr[4] | addr[5]); -} - -static inline int is_valid_ether_addr(const u_int8_t *addr) -{ - return !is_multicast_ether_addr(addr) && !is_zero_ether_addr(addr); -} - -#if 0 -static unsigned int crc32(unsigned char const *p, unsigned int len) -{ - int i; - unsigned int crc = 0; - while (len--) { - crc ^= *p++; - for (i = 0; i < 8; i++) - crc = (crc >> 1) ^ ((crc & 1) ? 0xedb88320 : 0); - } - return crc; -} -#else -static unsigned long crc32_tab[] = { - 0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f, - 0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988, - 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91, 0x1db71064, 0x6ab020f2, - 0xf3b97148, 0x84be41de, 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7, - 0x136c9856, 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, 0x14015c4f, 0x63066cd9, - 0xfa0f3d63, 0x8d080df5, 0x3b6e20c8, 0x4c69105e, 0xd56041e4, 0xa2677172, - 0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b, 0x35b5a8fa, 0x42b2986c, - 0xdbbbc9d6, 0xacbcf940, 0x32d86ce3, 0x45df5c75, 0xdcd60dcf, 0xabd13d59, - 0x26d930ac, 0x51de003a, 0xc8d75180, 0xbfd06116, 0x21b4f4b5, 0x56b3c423, - 0xcfba9599, 0xb8bda50f, 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924, - 0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d, 0x76dc4190, 0x01db7106, - 0x98d220bc, 0xefd5102a, 0x71b18589, 0x06b6b51f, 0x9fbfe4a5, 0xe8b8d433, - 0x7807c9a2, 0x0f00f934, 0x9609a88e, 0xe10e9818, 0x7f6a0dbb, 0x086d3d2d, - 0x91646c97, 0xe6635c01, 0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e, - 0x6c0695ed, 0x1b01a57b, 0x8208f4c1, 0xf50fc457, 0x65b0d9c6, 0x12b7e950, - 0x8bbeb8ea, 0xfcb9887c, 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, 0xfbd44c65, - 0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2, 0x4adfa541, 0x3dd895d7, - 0xa4d1c46d, 0xd3d6f4fb, 0x4369e96a, 0x346ed9fc, 0xad678846, 0xda60b8d0, - 0x44042d73, 0x33031de5, 0xaa0a4c5f, 0xdd0d7cc9, 0x5005713c, 0x270241aa, - 0xbe0b1010, 0xc90c2086, 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f, - 0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, 0x59b33d17, 0x2eb40d81, - 0xb7bd5c3b, 0xc0ba6cad, 0xedb88320, 0x9abfb3b6, 0x03b6e20c, 0x74b1d29a, - 0xead54739, 0x9dd277af, 0x04db2615, 0x73dc1683, 0xe3630b12, 0x94643b84, - 0x0d6d6a3e, 0x7a6a5aa8, 0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1, - 0xf00f9344, 0x8708a3d2, 0x1e01f268, 0x6906c2fe, 0xf762575d, 0x806567cb, - 0x196c3671, 0x6e6b06e7, 0xfed41b76, 0x89d32be0, 0x10da7a5a, 0x67dd4acc, - 0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5, 0xd6d6a3e8, 0xa1d1937e, - 0x38d8c2c4, 0x4fdff252, 0xd1bb67f1, 0xa6bc5767, 0x3fb506dd, 0x48b2364b, - 0xd80d2bda, 0xaf0a1b4c, 0x36034af6, 0x41047a60, 0xdf60efc3, 0xa867df55, - 0x316e8eef, 0x4669be79, 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236, - 0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f, 0xc5ba3bbe, 0xb2bd0b28, - 0x2bb45a92, 0x5cb36a04, 0xc2d7ffa7, 0xb5d0cf31, 0x2cd99e8b, 0x5bdeae1d, - 0x9b64c2b0, 0xec63f226, 0x756aa39c, 0x026d930a, 0x9c0906a9, 0xeb0e363f, - 0x72076785, 0x05005713, 0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38, - 0x92d28e9b, 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21, 0x86d3d2d4, 0xf1d4e242, - 0x68ddb3f8, 0x1fda836e, 0x81be16cd, 0xf6b9265b, 0x6fb077e1, 0x18b74777, - 0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c, 0x8f659eff, 0xf862ae69, - 0x616bffd3, 0x166ccf45, 0xa00ae278, 0xd70dd2ee, 0x4e048354, 0x3903b3c2, - 0xa7672661, 0xd06016f7, 0x4969474d, 0x3e6e77db, 0xaed16a4a, 0xd9d65adc, - 0x40df0b66, 0x37d83bf0, 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9, - 0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605, 0xcdd70693, - 0x54de5729, 0x23d967bf, 0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94, - 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d -}; - -static unsigned long crc32(unsigned char const *buf, unsigned int size) -{ - unsigned char *p = buf; - unsigned long crc = 0; - - crc = crc ^ ~0U; - - while (size--) - crc = crc32_tab[(crc ^ *p++) & 0xFF] ^ (crc >> 8); - - return crc ^ ~0U; -} -#endif - -static int set_bytes(char *buf, const char *string, int * converted_accum) -{ - char *p = (char *) string; - int i; - uint byte; - - if (!p) { - printk("ERROR: NULL string passed in.\n"); - return -1; - } - /* Convert string to bytes */ - for (i = 0, p = (char *)string; (i < TLV_VALUE_MAX_LEN) && (*p != 0); - i++) { - while ((*p == ' ') || (*p == '\t') || (*p == ',') || - (*p == ';')) { - p++; - } - if (*p != 0) { - if (!isdigit(*p)) { - printk("ERROR: Non-digit found in byte string: (%s)\n", string); - return -1; - } - byte = strtoul(p, &p, 0); - if (byte >= 256) { - printk("ERROR: The value specified is greater than 255: (%u) " \ - "in string: %s\n", byte, string); - return -1; - } - buf[i] = byte & 0xFF; - } - } - if ((i == TLV_VALUE_MAX_LEN) && (*p != 0)) { - printk("ERROR: Trying to assign too many bytes " - "(max: %d) in string: %s\n", TLV_VALUE_MAX_LEN, string); - return -1; - } - *converted_accum = i; - return 0; -} - -/* - * set_date - * - * Validates the format of the data string - * - * This function takes a pointer to a date string (i.e. MM/DD/YYYY hh:mm:ss) - * and validates that the format is correct. If so the string is copied - * to the supplied buffer. - */ -static int set_date(char *buf, const char *string) -{ - int i; - - if (!string) { - printk("ERROR: NULL date string passed in.\n"); - return -1; - } - if (strlen(string) != 19) { - printk("ERROR: Date strlen() != 19 -- %d\n", strlen(string)); - printk("ERROR: Bad date format (MM/DD/YYYY hh:mm:ss): %s\n", string); - return -1; - } - for (i = 0; string[i] != 0; i++) { - switch (i) { - case 2: - case 5: - if (string[i] != '/') { - printk("ERROR: Bad date format (MM/DD/YYYY hh:mm:ss): %s\n", - string); - return -1; - } - break; - case 10: - if (string[i] != ' ') { - printk("ERROR: Bad date format (MM/DD/YYYY hh:mm:ss): %s\n", - string); - return -1; - } - break; - case 13: - case 16: - if (string[i] != ':') { - printk("ERROR: Bad date format (MM/DD/YYYY hh:mm:ss): %s\n", - string); - return -1; - } - break; - default: - if (!isdigit(string[i])) { - printk("ERROR: Bad date format (MM/DD/YYYY hh:mm:ss): %s\n", - string); - return -1; - } - break; - } - } - strcpy(buf, string); - return 0; -} - -/* - * is_valid_tlv - * - * Perform basic sanity checks on a TLV field. The TLV is pointed to - * by the parameter provided. - * 1. The type code is not reserved (0x00 or 0xFF) - */ -static inline bool is_valid_tlv(tlvinfo_tlv_t *tlv) -{ - return((tlv->type != 0x00) && (tlv->type != 0xFF)); -} - -/* - * set_mac - * - * Converts a string MAC address into a binary buffer. - * - * This function takes a pointer to a MAC address string - * (i.e."XX:XX:XX:XX:XX:XX", where "XX" is a two-digit hex number). - * The string format is verified and then converted to binary and - * stored in a buffer. - */ -static int set_mac(char *buf, const char *string) -{ - char *p = (char *) string; - int i; - int err = 0; - char *end; - - if (!p) { - printk("ERROR: NULL mac addr string passed in.\n"); - return -1; - } - if (strlen(p) != 17) { - printk("ERROR: MAC address strlen() != 17 -- %d\n", strlen(p)); - printk("ERROR: Bad MAC address format: %s\n", string); - return -1; - } - for (i = 0; i < 17; i++) { - if ((i % 3) == 2) { - if (p[i] != ':') { - err++; - printk("ERROR: mac: p[%i] != :, found: `%c'\n", - i, p[i]); - break; - } - continue; - } else if (!isxdigit(p[i])) { - err++; - printk("ERROR: mac: p[%i] != hex digit, found: `%c'\n", - i, p[i]); - break; - } - } - if (err != 0) { - printk("ERROR: Bad MAC address format: %s\n", string); - return -1; - } - /* Convert string to binary */ - for (i = 0, p = (char *)string; i < 6; i++) { - buf[i] = p ? strtoul(p, &end, 16) : 0; - if (p) { - p = (*end) ? end + 1 : end; - } - } - if (!is_valid_ether_addr((char *)buf)) { - printk("ERROR: MAC address must not be 00:00:00:00:00:00, " - "a multicast address or FF:FF:FF:FF:FF:FF.\n"); - printk("ERROR: Bad MAC address format: %s\n", string); - return -1; - } - return 0; -} - -/* - * is_valid_tlvinfo_header - * - * Perform sanity checks on the first 11 bytes of the TlvInfo EEPROM - * data pointed to by the parameter: - * 1. First 8 bytes contain null-terminated ASCII string "TlvInfo" - * 2. Version byte is 1 - * 3. Total length bytes contain value which is less than or equal - * to the allowed maximum (2048-11) - * - */ -static inline bool is_valid_tlvinfo_header(tlvinfo_header_t *hdr) -{ - int max_size = TLV_TOTAL_LEN_MAX; - return((strcmp(hdr->signature, TLV_INFO_ID_STRING) == 0) && - (hdr->version == TLV_INFO_VERSION) && - (be16_to_cpu(hdr->totallen) <= max_size) ); -} - -/* - * decode_tlv_value - * - * Decode a single TLV value into a string. - - * The validity of EEPROM contents and the TLV field have been verified - * prior to calling this function. - */ -#define DECODE_NAME_MAX 20 - -static void decode_tlv_value(tlvinfo_tlv_t * tlv, char* value) -{ - int i; - - switch (tlv->type) { - case TLV_CODE_PRODUCT_NAME: - case TLV_CODE_PART_NUMBER: - case TLV_CODE_SERIAL_NUMBER: - case TLV_CODE_MANUF_DATE: - case TLV_CODE_LABEL_REVISION: - case TLV_CODE_PLATFORM_NAME: - case TLV_CODE_ONIE_VERSION: - case TLV_CODE_MANUF_NAME: - case TLV_CODE_MANUF_COUNTRY: - case TLV_CODE_VENDOR_NAME: - case TLV_CODE_DIAG_VERSION: - case TLV_CODE_SERVICE_TAG: - memcpy(value, tlv->value, tlv->length); - value[tlv->length] = 0; - break; - case TLV_CODE_MAC_BASE: - snprintf(value, MAX_STRING_SIZE, "%02X:%02X:%02X:%02X:%02X:%02X", - tlv->value[0], tlv->value[1], tlv->value[2], - tlv->value[3], tlv->value[4], tlv->value[5]); - break; - case TLV_CODE_DEVICE_VERSION: - snprintf(value, MAX_STRING_SIZE, "%u", tlv->value[0]); - break; - case TLV_CODE_MAC_SIZE: - snprintf(value, MAX_STRING_SIZE, "%u", (tlv->value[0] << 8) | tlv->value[1]); - break; - case TLV_CODE_VENDOR_EXT: - value[0] = 0; - for (i = 0; (i < (TLV_DECODE_VALUE_MAX_LEN/5)) && (i < tlv->length); - i++) { - snprintf(value, MAX_STRING_SIZE, "%s 0x%02X", value, tlv->value[i]); - } - break; - case TLV_CODE_CRC_32: - snprintf(value, MAX_STRING_SIZE, "0x%02X%02X%02X%02X", - tlv->value[0], tlv->value[1], tlv->value[2], - tlv->value[3]); - break; - default: - value[0] = 0; - for (i = 0; (i < (TLV_DECODE_VALUE_MAX_LEN/5)) && (i < tlv->length); - i++) { - snprintf(value, MAX_STRING_SIZE, "%s 0x%02X", value, tlv->value[i]); - } - break; - } - -} - -/* - * is_checksum_valid - * - * Validate the checksum in the provided TlvInfo EEPROM data. First, - * verify that the TlvInfo header is valid, then make sure the last - * TLV is a CRC-32 TLV. Then calculate the CRC over the EEPROM data - * and compare it to the value stored in the EEPROM CRC-32 TLV. - */ -static bool is_checksum_valid(u_int8_t *eeprom) -{ - tlvinfo_header_t * eeprom_hdr = (tlvinfo_header_t *) eeprom; - tlvinfo_tlv_t * eeprom_crc; - unsigned int calc_crc; - unsigned int stored_crc; - - // Is the eeprom header valid? - if (!is_valid_tlvinfo_header(eeprom_hdr)) { - return(FALSE); - } - - // Is the last TLV a CRC? - eeprom_crc = (tlvinfo_tlv_t *) &eeprom[sizeof(tlvinfo_header_t) + - be16_to_cpu(eeprom_hdr->totallen) - - (sizeof(tlvinfo_tlv_t) + 4)]; - if ((eeprom_crc->type != TLV_CODE_CRC_32) || (eeprom_crc->length != 4)) { - return(FALSE); - } - - // Calculate the checksum - calc_crc = crc32((void *)eeprom, sizeof(tlvinfo_header_t) + - be16_to_cpu(eeprom_hdr->totallen) - 4); - stored_crc = ((eeprom_crc->value[0] << 24) | (eeprom_crc->value[1] << 16) | - (eeprom_crc->value[2] << 8) | eeprom_crc->value[3]); - - //printk(KERN_ERR "[SWPS] cal_crc =0x%x, stored_crc =0x%x\n", calc_crc, stored_crc); - //return(calc_crc == stored_crc); - return 1; -} - -/* - * update_crc - * - * This function updates the CRC-32 TLV. If there is no CRC-32 TLV, then - * one is added. This function should be called after each update to the - * EEPROM structure, to make sure the CRC is always correct. - */ -static void update_crc(u_int8_t *eeprom) -{ - tlvinfo_header_t * eeprom_hdr = (tlvinfo_header_t *) eeprom; - tlvinfo_tlv_t * eeprom_crc; - unsigned int calc_crc; - - // Is the eeprom header valid? - if (!is_valid_tlvinfo_header(eeprom_hdr)) { - return; - } - // Is the last TLV a CRC? - eeprom_crc = (tlvinfo_tlv_t *) &eeprom[sizeof(tlvinfo_header_t) + - be16_to_cpu(eeprom_hdr->totallen) - - (sizeof(tlvinfo_tlv_t) + 4)]; - if (eeprom_crc->type != TLV_CODE_CRC_32) { - if ((be16_to_cpu(eeprom_hdr->totallen) + sizeof(tlvinfo_tlv_t) + 4) > - TLV_TOTAL_LEN_MAX) { - return; - } - eeprom_crc = (tlvinfo_tlv_t *) &eeprom[sizeof(tlvinfo_header_t) + - be16_to_cpu( - eeprom_hdr->totallen)]; - eeprom_hdr->totallen = cpu_to_be16(be16_to_cpu(eeprom_hdr->totallen) + - sizeof(tlvinfo_tlv_t) + 4); - eeprom_crc->type = TLV_CODE_CRC_32; - } - eeprom_crc->length = 4; - - // Calculate the checksum - calc_crc = crc32((void *)eeprom, - sizeof(tlvinfo_header_t) + - be16_to_cpu(eeprom_hdr->totallen) - 4); - - eeprom_crc->value[0] = (calc_crc >> 24) & 0xFF; - eeprom_crc->value[1] = (calc_crc >> 16) & 0xFF; - eeprom_crc->value[2] = (calc_crc >> 8) & 0xFF; - eeprom_crc->value[3] = (calc_crc >> 0) & 0xFF; -} - -/* - * show_eeprom - * - * Display the contents of the EEPROM - */ - -/* - * read_eeprom - * - * Read the EEPROM into memory, if it hasn't already been read. - */ -int read_eeprom( struct i2c_client *pi2c_client, u_int8_t *eeprom) -{ - int ret; - tlvinfo_header_t *eeprom_hdr = (tlvinfo_header_t *) eeprom; - tlvinfo_tlv_t *eeprom_tlv = (tlvinfo_tlv_t *)&eeprom[ - sizeof(tlvinfo_header_t)]; - - if (has_been_read) - return 0; - - /* Read the header */ - ret = read_sys_eeprom( pi2c_client,(void *)eeprom_hdr, 0, sizeof(tlvinfo_header_t)); - /* If the header was successfully read, read the TLVs */ - if ((ret == 0) && is_valid_tlvinfo_header(eeprom_hdr)) { - ret = read_sys_eeprom( pi2c_client, (void *)eeprom_tlv, sizeof(tlvinfo_header_t), - be16_to_cpu(eeprom_hdr->totallen)); - } - // If the contents are invalid, start over with default contents - if(!is_valid_tlvinfo_header(eeprom_hdr)) - printk(KERN_ERR - "Notice: Invalid TLV header found. Using default contents--1.\n"); - if(!is_checksum_valid(eeprom)) - printk(KERN_ERR - "Notice: Invalid TLV checksum found. Using default contents--2.\n"); - if ( !is_valid_tlvinfo_header(eeprom_hdr) || !is_checksum_valid(eeprom) ){ - strcpy(eeprom_hdr->signature, TLV_INFO_ID_STRING); - eeprom_hdr->version = TLV_INFO_VERSION; - eeprom_hdr->totallen = cpu_to_be16(0); - update_crc(eeprom); - } - has_been_read = 1; - - return ret; -} - -/* - * prog_eeprom - * Write the EEPROM data from CPU memory to the hardware. - */ -int prog_eeprom(struct i2c_client *pi2c_client, u_int8_t * eeprom) -{ - int ret = 0; - tlvinfo_header_t * eeprom_hdr = (tlvinfo_header_t *) eeprom; - int eeprom_len; - - eeprom_len = sizeof(tlvinfo_header_t) + be16_to_cpu(eeprom_hdr->totallen); - ret = write_sys_eeprom( pi2c_client, eeprom, eeprom_len); - if (ret) { - printk("Programming failed.\n"); - return -1; - } - has_been_read = 0; - return 0; -} - -/* - * tlvinfo_find_tlv - * - * This function finds the TLV with the supplied code in the EERPOM. - * An offset from the beginning of the EEPROM is returned in the - * eeprom_index parameter if the TLV is found. - */ -bool tlvinfo_find_tlv(u_int8_t *eeprom, u_int8_t tcode, - int *eeprom_index) -{ - tlvinfo_header_t * eeprom_hdr = (tlvinfo_header_t *) eeprom; - tlvinfo_tlv_t * eeprom_tlv; - int eeprom_end; - - // Make sure the EEPROM contents are valid - if (!is_valid_tlvinfo_header(eeprom_hdr) || !is_checksum_valid(eeprom)) { - return(FALSE); - } - // Search through the TLVs, looking for the first one which matches the - // supplied type code. - *eeprom_index = sizeof(tlvinfo_header_t); - eeprom_end = sizeof(tlvinfo_header_t) + be16_to_cpu(eeprom_hdr->totallen); - - while (*eeprom_index < eeprom_end) { - eeprom_tlv = (tlvinfo_tlv_t *) &eeprom[*eeprom_index]; - if (!is_valid_tlv(eeprom_tlv)) { - return(FALSE); - } - if (eeprom_tlv->type == tcode) { - return(TRUE); - } - *eeprom_index += sizeof(tlvinfo_tlv_t) + eeprom_tlv->length; - } - return(FALSE); -} - -/* - * tlvinfo_decode_tlv - * - * This function finds the TLV with the supplied code in the EERPOM - * and decodes the value into the buffer provided. - */ -bool tlvinfo_decode_tlv(u_int8_t *eeprom, u_int8_t tcode, char* value) -{ - int eeprom_index; - tlvinfo_tlv_t * eeprom_tlv; - - // Find the TLV and then decode it - - if (tlvinfo_find_tlv(eeprom, tcode, &eeprom_index)) { - eeprom_tlv = (tlvinfo_tlv_t *) &eeprom[eeprom_index]; - decode_tlv_value(eeprom_tlv, value); - return TRUE; - } - - return FALSE; -} - -/* - * tlvinfo_delete_tlv - * - * This function deletes the TLV with the specified type code from the - * EEPROM. - */ -bool tlvinfo_delete_tlv(u_int8_t * eeprom, u_int8_t code) -{ - int eeprom_index; - int tlength; - tlvinfo_header_t * eeprom_hdr = (tlvinfo_header_t *) eeprom; - tlvinfo_tlv_t * eeprom_tlv; - - // Find the TLV and then move all following TLVs "forward" - if (tlvinfo_find_tlv(eeprom, code, &eeprom_index)) { - eeprom_tlv = (tlvinfo_tlv_t *) &eeprom[eeprom_index]; - tlength = sizeof(tlvinfo_tlv_t) + eeprom_tlv->length; - memcpy(&eeprom[eeprom_index], &eeprom[eeprom_index+tlength], - sizeof(tlvinfo_header_t) + be16_to_cpu(eeprom_hdr->totallen) - - eeprom_index - tlength); - eeprom_hdr->totallen = cpu_to_be16(be16_to_cpu(eeprom_hdr->totallen) - - tlength); - update_crc(eeprom); - return(TRUE); - } - return(FALSE); -} - -/* - * tlvinfo_add_tlv - * - * This function adds a TLV to the EEPROM, converting the value (a string) to - * the format in which it will be stored in the EEPROM. - */ -#define MAX_TLV_VALUE_LEN 256 -bool tlvinfo_add_tlv(u_int8_t * eeprom, int tcode, char * strval) -{ - tlvinfo_header_t * eeprom_hdr = (tlvinfo_header_t *) eeprom; - tlvinfo_tlv_t * eeprom_tlv; - int new_tlv_len = 0; - u_int32_t value; - char data[MAX_TLV_VALUE_LEN]; - int eeprom_index; - int max_size = TLV_TOTAL_LEN_MAX; - - // Encode each TLV type into the format to be stored in the EERPOM - switch (tcode) { - case TLV_CODE_PRODUCT_NAME: - case TLV_CODE_PART_NUMBER: - case TLV_CODE_SERIAL_NUMBER: - case TLV_CODE_LABEL_REVISION: - case TLV_CODE_PLATFORM_NAME: - case TLV_CODE_ONIE_VERSION: - case TLV_CODE_MANUF_NAME: - case TLV_CODE_MANUF_COUNTRY: - case TLV_CODE_VENDOR_NAME: - case TLV_CODE_DIAG_VERSION: - case TLV_CODE_SERVICE_TAG: - strncpy(data, strval, MAX_TLV_VALUE_LEN); - - if( strlen(strval) >= MAX_TLV_VALUE_LEN ) - new_tlv_len = MAX_TLV_VALUE_LEN; - else - new_tlv_len = strlen(strval); - - break; - case TLV_CODE_DEVICE_VERSION: - value = strtoul(strval, NULL, 0); - if (value >= 256) { - printk("ERROR: Device version must be 255 or less. Value " \ - "supplied: %u", value); - return(FALSE); - } - data[0] = value & 0xFF; - new_tlv_len = 1; - break; - case TLV_CODE_MAC_SIZE: - value = strtoul(strval, NULL, 0); - if (value >= 65536) { - printk("ERROR: MAC Size must be 65535 or less. Value " \ - "supplied: %u", value); - return(FALSE); - } - data[0] = (value >> 8) & 0xFF; - data[1] = value & 0xFF; - new_tlv_len = 2; - break; - case TLV_CODE_MANUF_DATE: - if (set_date(data, strval) != 0) { - return(FALSE); - } - new_tlv_len = 19; - break; - case TLV_CODE_MAC_BASE: - if (set_mac(data, strval) != 0) { - return(FALSE); - } - new_tlv_len = 6; - break; - case TLV_CODE_CRC_32: - printk("WARNING: The CRC TLV is set automatically and cannot be set " \ - "manually.\n"); - return(FALSE); - case TLV_CODE_VENDOR_EXT: - default: - if (set_bytes(data, strval, &new_tlv_len) != 0 ) { - return(FALSE); - } - break; - } - - // Is there room for this TLV? - if ((be16_to_cpu(eeprom_hdr->totallen) + sizeof(tlvinfo_tlv_t) + - new_tlv_len) > max_size) { - printk("ERROR: There is not enough room in the EERPOM to save data.\n"); - return(FALSE); - } - - // Add TLV at the end, overwriting CRC TLV if it exists - if (tlvinfo_find_tlv(eeprom, TLV_CODE_CRC_32, &eeprom_index)) { - eeprom_hdr->totallen = cpu_to_be16(be16_to_cpu(eeprom_hdr->totallen) - - sizeof(tlvinfo_tlv_t) - 4); - } else { - eeprom_index = sizeof(tlvinfo_header_t) + - be16_to_cpu(eeprom_hdr->totallen); - } - eeprom_tlv = (tlvinfo_tlv_t *) &eeprom[eeprom_index]; - eeprom_tlv->type = tcode; - eeprom_tlv->length = new_tlv_len; - memcpy(eeprom_tlv->value, data, new_tlv_len); - - // Update the total length and calculate (add) a new CRC-32 TLV - eeprom_hdr->totallen = cpu_to_be16(be16_to_cpu(eeprom_hdr->totallen) + - sizeof(tlvinfo_tlv_t) + new_tlv_len); - update_crc(eeprom); - - return(TRUE); -} - -/* - * read_sys_eeprom - read the hwinfo from i2c EEPROM - */ -int read_sys_eeprom(struct i2c_client *pi2c_client,void *eeprom_data, int offset, int len) -{ - int iRet = 0; - int i = 0; - unsigned char ucBuf[2]; - u_int8_t *c; - unsigned short usAddr = SYS_EEPROM_OFFSET + offset; - - c = eeprom_data; - for (i = 0; i < len; i++) { - ucBuf[0] = (usAddr & 0xFF00) >> 8; - ucBuf[1] = (usAddr & 0x00FF); - - iRet = i2c_smbus_write_byte_data(pi2c_client, ucBuf[0], ucBuf[1]); - if( iRet < 0 ){ - printk(KERN_ERR"Error!! VPD data read error\n"); - return -1; - } - - *c = i2c_smbus_read_byte(pi2c_client); - c++; usAddr++; - } - return 0; -} - -/* - * write_sys_eeprom - write the hwinfo to i2c EEPROM - */ -int write_sys_eeprom(struct i2c_client *pi2c_client, void *eeprom_data, int len) -{ - int iRet = 0; - int i = 0; - u_int8_t *c; - unsigned short usAddr = SYS_EEPROM_OFFSET; - unsigned char ucBuf[3]; - - c = eeprom_data; - for (i = 0; i < len; i++) { - ucBuf[ 0 ] = (usAddr & 0xFF00) >>8 ; - ucBuf[ 1 ] = (usAddr & 0x00FF); - ucBuf[ 2 ] = *c; - - iRet = i2c_smbus_write_word_data( pi2c_client, ucBuf[0], (ucBuf[2] << 8 | ucBuf[1])); - if (iRet < 0 ){ - printk(KERN_ERR"Error!! VPD data write error . \n"); - return -1; - } - - c++; usAddr++; - msleep_interruptible(10); - } - - return 0; -} - -void update_eeprom_header(u_int8_t *eeprom) -{ - tlvinfo_header_t * eeprom_hdr = (tlvinfo_header_t *) eeprom; - - strcpy(eeprom_hdr->signature, TLV_INFO_ID_STRING); - eeprom_hdr->version = TLV_INFO_VERSION; - eeprom_hdr->totallen = cpu_to_be16(0); - update_crc(eeprom); -} -#if 0 -int find_vpd_data(u_int8_t *eeprom, int i_offset, char *c_buf) -{ - int tlv_end; - int curr_tlv; - tlvinfo_header_t * eeprom_hdr = (tlvinfo_header_t *) eeprom; - tlvinfo_tlv_t * eeprom_tlv; - int iFind = 0; - - if( !is_valid_tlvinfo_header(eeprom_hdr) ) { - printk(KERN_ERR"EEPROM does not contain data in a valid TlvInfo format.\n"); - return -1; - } - - curr_tlv = sizeof(tlvinfo_header_t); - tlv_end = sizeof(tlvinfo_header_t) + be16_to_cpu(eeprom_hdr->totallen); - while(curr_tlv < tlv_end){ - eeprom_tlv = (tlvinfo_tlv_t *) &eeprom[curr_tlv]; - if (!is_valid_tlv(eeprom_tlv)) { - printk(KERN_ERR"Invalid TLV field starting at EEPROM offset %d\n", - curr_tlv); - return -1; - } - - decode_tlv_value(eeprom_tlv, c_buf); - if( eeprom_tlv->type == i_offset){ - iFind = 1; - break; - } - curr_tlv += sizeof(tlvinfo_tlv_t) + eeprom_tlv->length; - } - - if( iFind == 0 ) - return -1; - else - return 0; -} -#endif diff --git a/packages/platforms/inventec/x86-64/d5052/modules/builds/src/onie_tlvinfo.h b/packages/platforms/inventec/x86-64/d5052/modules/builds/src/onie_tlvinfo.h deleted file mode 100644 index 74f3c9604..000000000 --- a/packages/platforms/inventec/x86-64/d5052/modules/builds/src/onie_tlvinfo.h +++ /dev/null @@ -1,150 +0,0 @@ -/* - * The Definition of the TlvInfo EEPROM format can be found at onie.org or - * github.com/onie - */ -#include -#define strtoul simple_strtoul - -#define FALSE 0 -#define TRUE (!FALSE) -#define MAX_STRING_SIZE 128 -/* - * Tlvinf header: Layout of the header for the TlvInfo format - * - * See the end of this file for details of this eeprom format - */ -struct __attribute__ ((__packed__)) tlvinfo_header_s { - char signature[8]; /* 0x00 - 0x07 EEPROM Tag "TlvInfo" */ - u_int8_t version; /* 0x08 Structure version */ - u_int16_t totallen; /* 0x09 - 0x0A Length of all data which follows */ -}; -typedef struct tlvinfo_header_s tlvinfo_header_t; - -// Header Field Constants -#define TLV_INFO_ID_STRING "TlvInfo" -#define TLV_INFO_VERSION 0x01 -#define TLV_TOTAL_LEN_MAX (SYS_EEPROM_SIZE - sizeof(tlvinfo_header_t)) - -/* - * TlvInfo TLV: Layout of a TLV field - */ -struct __attribute__ ((__packed__)) tlvinfo_tlv_s { - u_int8_t type; - u_int8_t length; - u_int8_t value[0]; -}; -typedef struct tlvinfo_tlv_s tlvinfo_tlv_t; - -/* Maximum length of a TLV value in bytes */ -#define TLV_VALUE_MAX_LEN 255 - -/** - * The TLV Types. - * - * Keep these in sync with tlv_code_list in cmd_sys_eeprom.c - */ -#define TLV_CODE_PRODUCT_NAME 0x21 -#define TLV_CODE_PART_NUMBER 0x22 -#define TLV_CODE_SERIAL_NUMBER 0x23 -#define TLV_CODE_MAC_BASE 0x24 -#define TLV_CODE_MANUF_DATE 0x25 -#define TLV_CODE_DEVICE_VERSION 0x26 -#define TLV_CODE_LABEL_REVISION 0x27 -#define TLV_CODE_PLATFORM_NAME 0x28 -#define TLV_CODE_ONIE_VERSION 0x29 -#define TLV_CODE_MAC_SIZE 0x2A -#define TLV_CODE_MANUF_NAME 0x2B -#define TLV_CODE_MANUF_COUNTRY 0x2C -#define TLV_CODE_VENDOR_NAME 0x2D -#define TLV_CODE_DIAG_VERSION 0x2E -#define TLV_CODE_SERVICE_TAG 0x2F -#define TLV_CODE_VENDOR_EXT 0xFD -#define TLV_CODE_CRC_32 0xFE - -/* - * Struct for displaying the TLV codes and names. - */ -struct tlv_code_desc { - u_int8_t m_code; - char* m_name; -}; - -/* - * List of TLV codes and names. - */ -static const struct tlv_code_desc tlv_code_list[] = { - { TLV_CODE_PRODUCT_NAME , "Product Name"}, - { TLV_CODE_PART_NUMBER , "Part Number"}, - { TLV_CODE_SERIAL_NUMBER , "Serial Number"}, - { TLV_CODE_MAC_BASE , "Base MAC Address"}, - { TLV_CODE_MANUF_DATE , "Manufacture Date"}, - { TLV_CODE_DEVICE_VERSION , "Device Version"}, - { TLV_CODE_LABEL_REVISION , "Label Revision"}, - { TLV_CODE_PLATFORM_NAME , "Platform Name"}, - { TLV_CODE_ONIE_VERSION , "Loader Version"}, - { TLV_CODE_MAC_SIZE , "MAC Addresses"}, - { TLV_CODE_MANUF_NAME , "Manufacturer"}, - { TLV_CODE_MANUF_COUNTRY , "Country Code"}, - { TLV_CODE_VENDOR_NAME , "Vendor Name"}, - { TLV_CODE_DIAG_VERSION , "Diag Version"}, - { TLV_CODE_SERVICE_TAG , "Service Tag"}, - { TLV_CODE_VENDOR_EXT , "Vendor Extension"}, - { TLV_CODE_CRC_32 , "CRC-32"}, -}; - -static inline const char* tlv_type2name(u_int8_t type) -{ - char* name = "Unknown"; - int i; - - for (i = 0; i < sizeof(tlv_code_list)/sizeof(tlv_code_list[0]); i++) { - if (tlv_code_list[i].m_code == type) { - name = tlv_code_list[i].m_name; - break; - } - } - return name; -} - -/* - * The max decode value is currently for the 'raw' type or the 'vendor - * extension' type, both of which have the same decode format. The - * max decode string size is computed as follows: - * - * strlen(" 0xFF") * TLV_VALUE_MAX_LEN + 1 - * - */ -#define TLV_DECODE_VALUE_MAX_LEN ((5 * TLV_VALUE_MAX_LEN) + 1) - - -/* - * Each platform must define the following platform-specific macros - * in sys_eeprom_platform.h: - * SYS_EEPROM_SIZE: size of usable eeprom - * SYS_EEPROM_I2C_DEVICE: i2c-bus - * SYS_EEPROM_I2C_ADDR: address on the bus - * The following may also be defined in sys_eeprom_platform.h, else - * the defaults with take over: - * SYS_EEPROM_MAX_SIZE: Total size of the eeprom - * SYS_EEPROM_OFFSET: offset from where the ONIE header starts - */ -#define SYS_EEPROM_MAX_SIZE 2048 -#define SYS_EEPROM_OFFSET 0 -#define SYS_EEPROM_SIZE SYS_EEPROM_MAX_SIZE -#define SYS_EEPROM_I2C_DEVICE "/dev/i2c-0" -#define SYS_EEPROM_I2C_ADDR 0x53 - -#if (SYS_EEPROM_SIZE + SYS_EEPROM_OFFSET > SYS_EEPROM_MAX_SIZE) - #error SYS_EEPROM_SIZE + SYS_EEPROM_OFFSET is greater than SYS_EEPROM_MAX_SIZE -#endif - -// Access functions to onie_tlvinfo -void show_eeprom(u_int8_t *eeprom); -int read_eeprom(struct i2c_client *pi2c_client, u_int8_t *eeprom); -int prog_eeprom(struct i2c_client *pi2c_client,u_int8_t * eeprom); -void update_eeprom_header(u_int8_t *eeprom); -bool tlvinfo_find_tlv(u_int8_t *eeprom, u_int8_t tcode, int *eeprom_index); -bool tlvinfo_delete_tlv(u_int8_t * eeprom, u_int8_t code); -bool tlvinfo_add_tlv(u_int8_t * eeprom, int tcode, char * strval); -bool tlvinfo_decode_tlv(u_int8_t *eeprom, u_int8_t tcode, char* value); -//int find_vpd_data(u_int8_t *eeprom, int i_offset, char *c_buf); diff --git a/packages/platforms/inventec/x86-64/d5052/modules/builds/src/transceiver.c b/packages/platforms/inventec/x86-64/d5052/modules/builds/src/transceiver.c deleted file mode 100644 index 47469e8a2..000000000 --- a/packages/platforms/inventec/x86-64/d5052/modules/builds/src/transceiver.c +++ /dev/null @@ -1,8463 +0,0 @@ -#include -#include -#include -#include -#include "io_expander.h" -#include "transceiver.h" - - -/* ========== Register EEPROM address mapping ========== - */ -struct eeprom_map_s eeprom_map_sfp = { - .addr_br =0x50, .page_br =-1, .offset_br =12, .length_br =1, - .addr_cdr =-1, .page_cdr =-1, .offset_cdr =-1, .length_cdr =-1, - .addr_comp_rev =0x50, .page_comp_rev =-1, .offset_comp_rev =94, .length_comp_rev =1, - .addr_connector =0x50, .page_connector =-1, .offset_connector =2, .length_connector =1, - .addr_diag_type =0x50, .page_diag_type =-1, .offset_diag_type =92 , .length_diag_type =1, - .addr_extbr =-1, .page_extbr =-1, .offset_extbr =-1, .length_extbr =-1, - .addr_ext_id =0x50, .page_ext_id =-1, .offset_ext_id =1, .length_ext_id =1, - .addr_id =0x50, .page_id =-1, .offset_id =0, .length_id =1, - .addr_len_sm =0x50, .page_len_sm =-1, .offset_len_sm =15, .length_len_sm =1, - .addr_len_smf =0x50, .page_len_smf =-1, .offset_len_smf =14, .length_len_smf =1, - .addr_len_om1 =0x50, .page_len_om1 =-1, .offset_len_om1 =17, .length_len_om1 =1, - .addr_len_om2 =0x50, .page_len_om2 =-1, .offset_len_om2 =16, .length_len_om2 =1, - .addr_len_om3 =0x50, .page_len_om3 =-1, .offset_len_om3 =19, .length_len_om3 =1, - .addr_len_om4 =0x50, .page_len_om4 =-1, .offset_len_om4 =18, .length_len_om4 =1, - .addr_option =0x50, .page_option =-1, .offset_option =64, .length_option =2, - .addr_rate_id =0x50, .page_rate_id =-1, .offset_rate_id =13, .length_rate_id =1, - .addr_rx_am =-1, .page_rx_am =-1, .offset_rx_am =-1, .length_rx_am =-1, - .addr_rx_em =0x51, .page_rx_em =-1, .offset_rx_em =115, .length_rx_em =1, - .addr_rx_los =-1, .page_rx_los =-1, .offset_rx_los =-1, .length_rx_los =-1, - .addr_rx_power =0x51, .page_rx_power =-1, .offset_rx_power =104, .length_rx_power =2, - .addr_soft_rs0 =0x51, .page_soft_rs0 =-1, .offset_soft_rs0 =110, .length_soft_rs0 =1, - .addr_soft_rs1 =0x51, .page_soft_rs1 =-1, .offset_soft_rs1 =118, .length_soft_rs0 =1, - .addr_temp =0x51, .page_temp =-1, .offset_temp =96, .length_temp =2, - .addr_trancomp =0x50, .page_trancomp =-1, .offset_trancomp =3, .length_trancomp =8, - .addr_trancomp_ext =0x50, .page_trancomp_ext =-1, .offset_trancomp_ext =36, .length_trancomp_ext =1, - .addr_tx_bias =0x51, .page_tx_bias =-1, .offset_tx_bias =100, .length_tx_bias =2, - .addr_tx_disable =-1, .page_tx_disable =-1, .offset_tx_disable =-1, .length_tx_disable =-1, - .addr_tx_eq =0x51, .page_tx_eq =-1, .offset_tx_eq =114, .length_tx_eq =1, - .addr_tx_fault =-1, .page_tx_fault =-1, .offset_tx_fault =-1, .length_tx_fault =-1, - .addr_tx_power =0x51, .page_tx_power =-1, .offset_tx_power =102, .length_tx_power =2, - .addr_vendor_name =0x50, .page_vendor_name =-1, .offset_vendor_name =20, .length_vendor_name =16, - .addr_vendor_pn =0x50, .page_vendor_pn =-1, .offset_vendor_pn =40, .length_vendor_pn =16, - .addr_vendor_rev =0x50, .page_vendor_rev =-1, .offset_vendor_rev =56, .length_vendor_rev =4, - .addr_vendor_sn =0x50, .page_vendor_sn =-1, .offset_vendor_sn =68, .length_vendor_sn =16, - .addr_voltage =0x51, .page_voltage =-1, .offset_voltage =98, .length_voltage =2, - .addr_wavelength =0x50, .page_wavelength =-1, .offset_wavelength =60, .length_wavelength =2, - .addr_eeprom =0x50, .page_eeprom =-1, .offset_eeprom =0, .length_eeprom =128, - .addr_uppage =0x50, .page_uppage =-1, .offset_uppage =128, .length_eeprom =128, -}; - -struct eeprom_map_s eeprom_map_qsfp = { - .addr_br =0x50, .page_br =0, .offset_br =140, .length_br =1, - .addr_cdr =-1, .page_cdr =-1, .offset_cdr =-1, .length_cdr =-1, - .addr_comp_rev =0x50, .page_comp_rev =-1, .offset_comp_rev =1, .length_comp_rev =1, - .addr_connector =0x50, .page_connector =0, .offset_connector =130, .length_connector =1, - .addr_diag_type =0x50, .page_diag_type =0, .offset_diag_type =220, .length_diag_type =1, - .addr_extbr =0x50, .page_extbr =0, .offset_extbr =222, .length_extbr =1, - .addr_ext_id =0x50, .page_ext_id =0, .offset_ext_id =129, .length_ext_id =1, - .addr_id =0x50, .page_id =0, .offset_id =128, .length_id =1, - .addr_len_sm =-1, .page_len_sm =-1, .offset_len_sm =-1, .length_len_sm =-1, - .addr_len_smf =0x50, .page_len_smf =0, .offset_len_smf =142, .length_len_smf =1, - .addr_len_om1 =0x50, .page_len_om1 =0, .offset_len_om1 =145, .length_len_om1 =1, - .addr_len_om2 =0x50, .page_len_om2 =0, .offset_len_om2 =144, .length_len_om2 =1, - .addr_len_om3 =0x50, .page_len_om3 =0, .offset_len_om3 =143, .length_len_om3 =1, - .addr_len_om4 =0x50, .page_len_om4 =0, .offset_len_om4 =146, .length_len_om4 =1, - .addr_option =0x50, .page_option =0, .offset_option =193, .length_option =3, - .addr_rate_id =-1, .page_rate_id =-1, .offset_rate_id =-1, .length_rate_id =-1, - .addr_rx_am =-1, .page_rx_am =-1, .offset_rx_am =-1, .length_rx_am =-1, - .addr_rx_em =-1, .page_rx_em =-1, .offset_rx_em =-1, .length_rx_em =-1, - .addr_rx_los =0x50, .page_rx_los =-1, .offset_rx_los =3, .length_rx_los =1, - .addr_rx_power =0x50, .page_rx_power =-1, .offset_rx_power =34, .length_rx_power =8, - .addr_soft_rs0 =-1, .page_soft_rs0 =-1, .offset_soft_rs0 =-1, .length_soft_rs0 =-1, - .addr_soft_rs1 =-1, .page_soft_rs1 =-1, .offset_soft_rs1 =-1, .length_soft_rs0 =-1, - .addr_temp =0x50, .page_temp =-1, .offset_temp =22, .length_temp =2, - .addr_trancomp =0x50, .page_trancomp =0, .offset_trancomp =131, .length_trancomp =8, - .addr_trancomp_ext =0x50, .page_trancomp_ext =0, .offset_trancomp_ext =192, .length_trancomp_ext =1, - .addr_tx_bias =0x50, .page_tx_bias =-1, .offset_tx_bias =42, .length_tx_bias =8, - .addr_tx_disable =0x50, .page_tx_disable =-1, .offset_tx_disable =86, .length_tx_disable =1, - .addr_tx_eq =-1, .page_tx_eq =-1, .offset_tx_eq =-1, .length_tx_eq =-1, - .addr_tx_fault =0x50, .page_tx_fault =-1, .offset_tx_fault =4, .length_tx_fault =1, - .addr_tx_power =0x50, .page_tx_power =-1, .offset_tx_power =50, .length_tx_power =8, - .addr_vendor_name =0x50, .page_vendor_name =0, .offset_vendor_name =148, .length_vendor_name =16, - .addr_vendor_pn =0x50, .page_vendor_pn =0, .offset_vendor_pn =168, .length_vendor_pn =16, - .addr_vendor_rev =0x50, .page_vendor_rev =0, .offset_vendor_rev =184, .length_vendor_rev =2, - .addr_vendor_sn =0x50, .page_vendor_sn =0, .offset_vendor_sn =196, .length_vendor_sn =16, - .addr_voltage =0x50, .page_voltage =-1, .offset_voltage =26, .length_voltage =2, - .addr_wavelength =0x50, .page_wavelength =0, .offset_wavelength =186, .length_wavelength =2, - .addr_eeprom =0x50, .page_eeprom =0, .offset_eeprom =128, .length_eeprom =128, - .addr_uppage =0x50, .page_uppage =0, .offset_uppage =256, .length_eeprom =128, -}; - -struct eeprom_map_s eeprom_map_qsfp28 = { - .addr_br =0x50, .page_br =0, .offset_br =140, .length_br =1, - .addr_cdr =0x50, .page_cdr =-1, .offset_cdr =98, .length_cdr =1, - .addr_comp_rev =0x50, .page_comp_rev =-1, .offset_comp_rev =1, .length_comp_rev =1, - .addr_connector =0x50, .page_connector =0, .offset_connector =130, .length_connector =1, - .addr_diag_type =0x50, .page_diag_type =0, .offset_diag_type =220, .length_diag_type =1, - .addr_extbr =0x50, .page_extbr =0, .offset_extbr =222, .length_extbr =1, - .addr_ext_id =0x50, .page_ext_id =0, .offset_ext_id =129, .length_ext_id =1, - .addr_id =0x50, .page_id =0, .offset_id =128, .length_id =1, - .addr_len_sm =-1, .page_len_sm =-1, .offset_len_sm =-1, .length_len_sm =-1, - .addr_len_smf =0x50, .page_len_smf =0, .offset_len_smf =142, .length_len_smf =1, - .addr_len_om1 =0x50, .page_len_om1 =0, .offset_len_om1 =145, .length_len_om1 =1, - .addr_len_om2 =0x50, .page_len_om2 =0, .offset_len_om2 =144, .length_len_om2 =1, - .addr_len_om3 =0x50, .page_len_om3 =0, .offset_len_om3 =143, .length_len_om3 =1, - .addr_len_om4 =0x50, .page_len_om4 =0, .offset_len_om4 =146, .length_len_om4 =1, - .addr_option =0x50, .page_option =0, .offset_option =193, .length_option =3, - .addr_rate_id =-1, .page_rate_id =-1, .offset_rate_id =-1, .length_rate_id =-1, - .addr_rx_am =0x50, .page_rx_am =3, .offset_rx_am =238, .length_rx_am =2, - .addr_rx_em =0x50, .page_rx_em =3, .offset_rx_em =236, .length_rx_em =2, - .addr_rx_los =0x50, .page_rx_los =-1, .offset_rx_los =3, .length_rx_los =1, - .addr_rx_power =0x50, .page_rx_power =-1, .offset_rx_power =34, .length_rx_power =8, - .addr_soft_rs0 =-1, .page_soft_rs0 =-1, .offset_soft_rs0 =-1, .length_soft_rs0 =-1, - .addr_soft_rs1 =-1, .page_soft_rs1 =-1, .offset_soft_rs1 =-1, .length_soft_rs0 =-1, - .addr_temp =0x50, .page_temp =-1, .offset_temp =22, .length_temp =2, - .addr_trancomp =0x50, .page_trancomp =0, .offset_trancomp =131, .length_trancomp =8, - .addr_trancomp_ext =0x50, .page_trancomp_ext =0, .offset_trancomp_ext =192, .length_trancomp_ext =1, - .addr_tx_bias =0x50, .page_tx_bias =-1, .offset_tx_bias =42, .length_tx_bias =8, - .addr_tx_disable =0x50, .page_tx_disable =-1, .offset_tx_disable =86, .length_tx_disable =1, - .addr_tx_eq =0x50, .page_tx_eq =3, .offset_tx_eq =234, .length_tx_eq =2, - .addr_tx_fault =0x50, .page_tx_fault =-1, .offset_tx_fault =4, .length_tx_fault =1, - .addr_tx_power =0x50, .page_tx_power =-1, .offset_tx_power =50, .length_tx_power =8, - .addr_vendor_name =0x50, .page_vendor_name =0, .offset_vendor_name =148, .length_vendor_name =16, - .addr_vendor_pn =0x50, .page_vendor_pn =0, .offset_vendor_pn =168, .length_vendor_pn =16, - .addr_vendor_rev =0x50, .page_vendor_rev =0, .offset_vendor_rev =184, .length_vendor_rev =2, - .addr_vendor_sn =0x50, .page_vendor_sn =0, .offset_vendor_sn =196, .length_vendor_sn =16, - .addr_voltage =0x50, .page_voltage =-1, .offset_voltage =26, .length_voltage =2, - .addr_wavelength =0x50, .page_wavelength =0, .offset_wavelength =186, .length_wavelength =2, - .addr_eeprom =0x50, .page_eeprom =0, .offset_eeprom =128, .length_eeprom =128, - .addr_uppage =0x50, .page_uppage =0, .offset_uppage =256, .length_uppage =128, -}; - - -/* ========== Utility Functions ========== - */ -static int -get_bit(uint8_t origin_byte, int bit_shift) { - return (int)((origin_byte >> bit_shift) & 0x1); -} - -static int -transform_word_to_int(uint8_t hight_byte, - uint8_t low_byte) { - return ((((int)hight_byte) << 8) + (int)low_byte); -} - -void -alarm_msg_2_user(struct transvr_obj_s *self, - char *emsg) { - - SWPS_ERR("%s on %s.\n", emsg, self->swp_name); -} - - -/* ========== Private functions ========== - */ -static int -_reload_transvr_obj(struct transvr_obj_s *self,int new_type); - -static int -reload_transvr_obj(struct transvr_obj_s *self,int new_type); - -static int -_is_transvr_support_ctle(struct transvr_obj_s *self); - -static int -_transvr_init_handler(struct transvr_obj_s *self); - -int -_transvr_clean_handler(struct transvr_obj_s *self); - -int -_sfp_detect_class_by_1g_ethernet(struct transvr_obj_s* self); - - -void -lock_transvr_obj(struct transvr_obj_s *self) { - - mutex_lock(&self->lock); - self->curr_page = VAL_TRANSVR_PAGE_FREE; -} - - -void -unlock_transvr_obj(struct transvr_obj_s *self) { - - self->curr_page = VAL_TRANSVR_PAGE_FREE; - mutex_unlock(&self->lock); -} - - -static int -_check_by_mode(struct transvr_obj_s *self, - int (*attr_update_func)(struct transvr_obj_s *self, int show_err), - char *caller_name){ - - int return_val = ERR_TRANSVR_UNEXCPT; - - switch (self->mode){ - case TRANSVR_MODE_POLLING: - switch (self->state){ - case STATE_TRANSVR_CONNECTED: - goto ok_check_by_mode_1; - case STATE_TRANSVR_NEW: - case STATE_TRANSVR_INIT: - return ERR_TRANSVR_UNINIT; - case STATE_TRANSVR_DISCONNECTED: - return ERR_TRANSVR_UNPLUGGED; - case STATE_TRANSVR_UNEXCEPTED: - return ERR_TRANSVR_ABNORMAL; - case STATE_TRANSVR_ISOLATED: - return ERR_TRNASVR_BE_ISOLATED; - default: - goto err_check_by_mode_1; - } - goto ok_check_by_mode_1; - - case TRANSVR_MODE_DIRECT: - return_val = self->fsm_4_direct(self, caller_name); - if (return_val < 0){ - return return_val; - } - goto ok_check_by_mode_1; - - default: - goto err_check_by_mode_1; - } - goto ok_check_by_mode_1; - -ok_check_by_mode_1: - return attr_update_func(self, 0); - -err_check_by_mode_1: - SWPS_INFO("_check_by_mode: mode:%d state:%d\n", self->mode, self->state); - return ERR_TRANSVR_UNEXCPT; -} - - -static void -_transvr_clean_retry(struct transvr_obj_s *self) { - self->retry = 0; -} - - -static int -_transvr_handle_retry(struct transvr_obj_s *self, int retry) { - /* Return: 0: keep retry - * -1: stop retry - */ - if (self->retry == 0) { - self->retry = retry; - } - self->retry -= 1; - if (self->retry <= 0) { - _transvr_clean_retry(self); - return -1; - } - return 0; -} - - -static int -_common_setup_page(struct transvr_obj_s *self, - int addr, - int page, - int offset, - int len, - int show_e) { - /* return: - * 0 : OK - * -1 : EEPROM settings incorrect - * -2 : I2C R/W failure - * -3 : Undefined case - */ - int retval = DEBUG_TRANSVR_INT_VAL; - char *emsg = DEBUG_TRANSVR_STR_VAL; - - /* Check */ - if ((addr < 0) || (offset < 0) || (len < 0)) { - emsg = "EEPROM settings incorrect"; - retval = -1; - goto err_common_setup_page; - } - /* Case1: continue access */ - if ((self->i2c_client_p->addr == addr) && - (self->curr_page == page)) { - return 0; - } - self->i2c_client_p->addr = addr; - /* Case2: select lower page */ - if (page == -1) { - self->curr_page = page; - return 0; - } - /* Case3: select upper page */ - if (page >= 0) { - goto upper_common_setup_page; - } - /* Unexpected case */ - show_e = 1; - emsg = "Unexpected case"; - retval = -3; - goto err_common_setup_page; - -upper_common_setup_page: - if (i2c_smbus_write_byte_data(self->i2c_client_p, - VAL_TRANSVR_PAGE_SELECT_OFFSET, - page) < 0) { - emsg = "I2C R/W failure"; - retval = -2; - goto err_common_setup_page; - } - self->curr_page = page; - mdelay(VAL_TRANSVR_PAGE_SELECT_DELAY); - return 0; - -err_common_setup_page: - if (show_e) { - SWPS_INFO("%s: %s", __func__, emsg); - SWPS_INFO("%s: :0x%02x :%d :%d :%d\n", - __func__, addr, page, offset, len); - } - return retval; -} - -/* -static int -_common_setup_password(struct transvr_obj_s *self, - int addr, - int page, - int offs, - uint8_t pwd[4], - int show_e) { - int i = 0; - int err = DEBUG_TRANSVR_INT_VAL; - char *emsg = DEBUG_TRANSVR_STR_VAL; - - err = _common_setup_page(self, addr, page, offs, 4, show_e); - if (err < 0){ - emsg = "setup EEPROM page fail"; - goto err_common_setup_password; - } - for (i=0; i<4; i++) { - err = i2c_smbus_write_byte_data(self->i2c_client_p, - (offs + i), - pwd[i]); - if (err < 0){ - emsg = "I2C R/W fail!"; - goto err_common_setup_password; - } - } - return 0; - -err_common_setup_password: - if (show_e) { - SWPS_INFO("%s: %s :%d\n", __func__, emsg, err); - } - return ERR_TRANSVR_UPDATE_FAIL; -} -*/ - -static int -_common_update_uint8_attr(struct transvr_obj_s *self, - int addr, - int page, - int offset, - int len, - uint8_t *buf, - char *caller, - int show_e){ - - int i; - int err = DEBUG_TRANSVR_INT_VAL; - char *emsg = DEBUG_TRANSVR_STR_VAL; - - err = _common_setup_page(self, addr, page, offset, len, show_e); - if (err < 0){ - emsg = "setup EEPROM page fail"; - goto err_common_update_uint8_attr; - } - for (i=0; ii2c_client_p, (offset + i)); - if (err < 0){ - emsg = "I2C R/W fail!"; - goto err_common_update_uint8_attr; - } - buf[i] = err; - } - return 0; - -err_common_update_uint8_attr: - if (show_e) { - SWPS_INFO("%s: %s :%s :%d\n", - __func__, emsg, caller, err); - } - buf[0] = DEBUG_TRANSVR_HEX_VAL; - return ERR_TRANSVR_UPDATE_FAIL; -} - - -static int -_common_update_int_attr(struct transvr_obj_s *self, - int addr, - int page, - int offset, - int len, - int *buf, - char *caller, - int show_e){ - - int i; - int err = DEBUG_TRANSVR_INT_VAL; - char *emsg = DEBUG_TRANSVR_STR_VAL; - - err = _common_setup_page(self, addr, page, offset, len, show_e); - if (err < 0){ - emsg = "setup EEPROM page fail"; - goto err_common_update_int_attr; - } - for (i=0; ii2c_client_p, (offset + i)); - if (err < 0){ - emsg = "I2C R/W fail!"; - goto err_common_update_int_attr; - } - buf[i] = (int)err; - } - return 0; - -err_common_update_int_attr: - if (show_e) { - SWPS_INFO("%s: %s :%s :%d\n", - __func__, emsg, caller, err); - } - buf[0] = DEBUG_TRANSVR_INT_VAL; - return ERR_TRANSVR_UPDATE_FAIL; -} - - -static int -_common_update_string_attr(struct transvr_obj_s *self, - int addr, - int page, - int offset, - int len, - char buf[], - char *caller, - int show_e){ - - int i; - int err = DEBUG_TRANSVR_INT_VAL; - char *emsg = DEBUG_TRANSVR_STR_VAL; - - err = _common_setup_page(self, addr, page, offset, len, show_e); - if (err < 0){ - emsg = "setup EEPROM page fail"; - goto err_common_update_string_attr; - } - for (i=0; ii2c_client_p, (offset + i)); - if (err < 0){ - emsg = "I2C R/W fail!"; - goto err_common_update_string_attr; - } - buf[i] = (char)err; - } - return 0; - -err_common_update_string_attr: - if (show_e) { - SWPS_INFO("%s: %s :%s :%d\n", - __func__, emsg, caller, err); - } - buf[0] = 'e'; - return ERR_TRANSVR_UPDATE_FAIL; -} - - -static int -_common_set_uint8_attr(struct transvr_obj_s *self, - int addr, - int page, - int offset, - uint8_t update, - uint8_t *buf, - char *caller, - int show_e){ - int len = 1; - int err = DEBUG_TRANSVR_INT_VAL; - char *emsg = DEBUG_TRANSVR_STR_VAL; - - if ((*buf) == update){ - return 0; - } - err = _common_setup_page(self, addr, page, offset, len, show_e); - if (err < 0){ - emsg = "setup EEPROM page fail"; - goto err_common_set_uint8_attr_1; - } - err = i2c_smbus_write_byte_data(self->i2c_client_p, - offset, - update); - if (err < 0){ - emsg = "I2C R/W fail!"; - goto err_common_set_uint8_attr_1; - } - (*buf) = update; - return 0; - -err_common_set_uint8_attr_1: - if (show_e) { - SWPS_INFO("%s: %s :%s :%d\n", - __func__, emsg, caller, err); - } - return ERR_TRANSVR_UPDATE_FAIL; -} - - -static int -_common_set_uint8_array(struct transvr_obj_s *self, - int addr, - int page, - int offs, - int len, - uint8_t update[], - uint8_t buf[], - char *caller, - int show_e){ - int i = 0; - int err = DEBUG_TRANSVR_INT_VAL; - char *emsg = DEBUG_TRANSVR_STR_VAL; - - err = _common_setup_page(self, addr, page, offs, len, show_e); - if (err < 0){ - emsg = "setup EEPROM page fail"; - goto err_common_set_uint8_attr_1; - } - for (i=0; ii2c_client_p, - (offs + i), - update[i]); - if (err < 0){ - emsg = "I2C R/W fail!"; - goto err_common_set_uint8_attr_1; - } - buf[i] = update[i]; - } - return 0; - -err_common_set_uint8_attr_1: - if (show_e) { - SWPS_INFO("%s: %s :%s :%d :%d\n", - __func__, emsg, caller, err, i); - } - return ERR_TRANSVR_UPDATE_FAIL; -} - - -static int -_common_update_attr_id(struct transvr_obj_s *self, - int show_err){ - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_id, - self->eeprom_map_p->page_id, - self->eeprom_map_p->offset_id, - self->eeprom_map_p->length_id, - &(self->id), - "_common_update_attr_id", - show_err); -} - -static int -_common_update_attr_eeprom(struct transvr_obj_s *self, - int show_err){ - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_eeprom, - self->eeprom_map_p->page_eeprom, - self->eeprom_map_p->offset_eeprom, - self->eeprom_map_p->length_eeprom, - &(self->eeprom), - "_common_update_attr_eeprom", - show_err); -} - -static int -_common_update_attr_uppage(struct transvr_obj_s *self, - int show_err){ - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_uppage, - self->eeprom_map_p->page_uppage, - self->eeprom_map_p->offset_uppage, - self->eeprom_map_p->length_uppage, - &(self->eeprom), - "_common_update_attr_uppage", - show_err); -} - -static int -_common_update_attr_extended_id(struct transvr_obj_s *self, - int show_err){ - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_ext_id, - self->eeprom_map_p->page_ext_id, - self->eeprom_map_p->offset_ext_id, - self->eeprom_map_p->length_ext_id, - &(self->ext_id), - "_common_update_attr_extended_id", - show_err); -} - - -static int -_common_update_attr_connector(struct transvr_obj_s *self, - int show_err){ - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_connector, - self->eeprom_map_p->page_connector, - self->eeprom_map_p->offset_connector, - self->eeprom_map_p->length_connector, - &(self->connector), - "_common_update_attr_connector", - show_err); -} - - -static int -_common_update_attr_transvr_comp(struct transvr_obj_s *self, - int show_err){ - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_trancomp, - self->eeprom_map_p->page_trancomp, - self->eeprom_map_p->offset_trancomp, - self->eeprom_map_p->length_trancomp, - self->transvr_comp, - "_common_update_attr_transvr_comp", - show_err); -} - - -static int -_common_update_attr_transvr_comp_ext(struct transvr_obj_s *self, - int show_err){ - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_trancomp_ext, - self->eeprom_map_p->page_trancomp_ext, - self->eeprom_map_p->offset_trancomp_ext, - self->eeprom_map_p->length_trancomp_ext, - &(self->transvr_comp_ext), - "_common_update_attr_transvr_comp_ext", - show_err); -} - - -static int -_common_update_attr_vendor_name(struct transvr_obj_s *self, - int show_err){ - return _common_update_string_attr(self, - self->eeprom_map_p->addr_vendor_name, - self->eeprom_map_p->page_vendor_name, - self->eeprom_map_p->offset_vendor_name, - self->eeprom_map_p->length_vendor_name, - self->vendor_name, - "_common_update_attr_vendor_name", - show_err); -} - - -static int -_common_update_attr_vendor_pn(struct transvr_obj_s *self, - int show_err){ - return _common_update_string_attr(self, - self->eeprom_map_p->addr_vendor_pn, - self->eeprom_map_p->page_vendor_pn, - self->eeprom_map_p->offset_vendor_pn, - self->eeprom_map_p->length_vendor_pn, - self->vendor_pn, - "_common_update_attr_vendor_pn", - show_err); -} - - -static int -_common_update_attr_vendor_rev(struct transvr_obj_s *self, - int show_err){ - return _common_update_string_attr(self, - self->eeprom_map_p->addr_vendor_rev, - self->eeprom_map_p->page_vendor_rev, - self->eeprom_map_p->offset_vendor_rev, - self->eeprom_map_p->length_vendor_rev, - self->vendor_rev, - "_common_update_attr_vendor_rev", - show_err); -} - - -static int -_common_update_attr_vendor_sn(struct transvr_obj_s *self, - int show_err){ - return _common_update_string_attr(self, - self->eeprom_map_p->addr_vendor_sn, - self->eeprom_map_p->page_vendor_sn, - self->eeprom_map_p->offset_vendor_sn, - self->eeprom_map_p->length_vendor_sn, - self->vendor_sn, - "_common_update_attr_vendor_sn", - show_err); -} - - -static int -_common_update_attr_br(struct transvr_obj_s *self, - int show_err){ - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_br, - self->eeprom_map_p->page_br, - self->eeprom_map_p->offset_br, - self->eeprom_map_p->length_br, - &(self->br), - "_common_update_attr_br", - show_err); -} - - -static int -_common_update_attr_len_smf(struct transvr_obj_s *self, - int show_err){ - return _common_update_int_attr(self, - self->eeprom_map_p->addr_len_smf, - self->eeprom_map_p->page_len_smf, - self->eeprom_map_p->offset_len_smf, - self->eeprom_map_p->length_len_smf, - &(self->len_smf), - "_common_update_attr_len_smf", - show_err); -} - - -static int -_common_update_attr_len_om1(struct transvr_obj_s *self, - int show_err){ - return _common_update_int_attr(self, - self->eeprom_map_p->addr_len_om1, - self->eeprom_map_p->page_len_om1, - self->eeprom_map_p->offset_len_om1, - self->eeprom_map_p->length_len_om1, - &(self->len_om1), - "_common_update_attr_len_om1", - show_err); -} - -static int -_common_update_attr_len_om2(struct transvr_obj_s *self, - int show_err){ - return _common_update_int_attr(self, - self->eeprom_map_p->addr_len_om2, - self->eeprom_map_p->page_len_om2, - self->eeprom_map_p->offset_len_om2, - self->eeprom_map_p->length_len_om2, - &(self->len_om2), - "_common_update_attr_len_om2", - show_err); -} - -static int -_common_update_attr_len_om3(struct transvr_obj_s *self, - int show_err){ - return _common_update_int_attr(self, - self->eeprom_map_p->addr_len_om3, - self->eeprom_map_p->page_len_om3, - self->eeprom_map_p->offset_len_om3, - self->eeprom_map_p->length_len_om3, - &(self->len_om3), - "_common_update_attr_len_om3", - show_err); -} - - -static int -_common_update_attr_len_om4(struct transvr_obj_s *self, - int show_err){ - return _common_update_int_attr(self, - self->eeprom_map_p->addr_len_om4, - self->eeprom_map_p->page_len_om4, - self->eeprom_map_p->offset_len_om4, - self->eeprom_map_p->length_len_om4, - &(self->len_om4), - "_common_update_attr_len_om4", - show_err); -} - - -static int -_common_update_attr_option(struct transvr_obj_s *self, - int show_err){ - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_option, - self->eeprom_map_p->page_option, - self->eeprom_map_p->offset_option, - self->eeprom_map_p->length_option, - self->option, - "_common_update_attr_option", - show_err); -} - - -static int -_common_update_attr_comp_rev(struct transvr_obj_s *self, - int show_err){ - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_comp_rev, - self->eeprom_map_p->page_comp_rev, - self->eeprom_map_p->offset_comp_rev, - self->eeprom_map_p->length_comp_rev, - &(self->comp_rev), - "_common_update_attr_comp_rev", - show_err); -} - - -static int -_common_update_attr_diag_type(struct transvr_obj_s *self, - int show_err){ - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_diag_type, - self->eeprom_map_p->page_diag_type, - self->eeprom_map_p->offset_diag_type, - self->eeprom_map_p->length_diag_type, - &(self->diag_type), - "_common_update_attr_diag_type", - show_err); -} - - -static int -_common_update_attr_wavelength(struct transvr_obj_s *self, - int show_err){ - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_wavelength, - self->eeprom_map_p->page_wavelength, - self->eeprom_map_p->offset_wavelength, - self->eeprom_map_p->length_wavelength, - self->wavelength, - "_common_update_attr_wavelength", - show_err); -} - - -int -_common_get_option_value(struct transvr_obj_s *self, - int offset, - int bit_shift) { - /* SFP: - * - option[0] = A0h / 64 - * - option[1] = A0h / 65 - * QSFP: - * - option[0] = 00h / 193 - * - option[1] = 00h / 194 - * - option[2] = 00h / 195 - */ - return (self->option[offset] & (1 << bit_shift)); -} - - -static int -_sfp_update_attr_len_sm(struct transvr_obj_s *self, - int show_err){ - return _common_update_int_attr(self, - self->eeprom_map_p->addr_len_sm, - self->eeprom_map_p->page_len_sm, - self->eeprom_map_p->offset_len_sm, - self->eeprom_map_p->length_len_sm, - &(self->len_sm), - "_common_update_attr_len_sm", - show_err); -} - - -static int -_sfp_update_attr_rate_id(struct transvr_obj_s *self, - int show_err){ - return _common_update_int_attr(self, - self->eeprom_map_p->addr_rate_id, - self->eeprom_map_p->page_rate_id, - self->eeprom_map_p->offset_rate_id, - self->eeprom_map_p->length_rate_id, - &(self->rate_id), - "_sfp_update_attr_rate_id", - show_err); -} - - -static int -_sfp_update_attr_soft_rs0(struct transvr_obj_s *self, - int show_err){ - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_soft_rs0, - self->eeprom_map_p->page_soft_rs0, - self->eeprom_map_p->offset_soft_rs0, - self->eeprom_map_p->length_soft_rs0, - &(self->soft_rs0), - "_sfp_update_attr_soft_rs0", - show_err); -} - - -static int -_sfp_update_attr_soft_rs1(struct transvr_obj_s *self, - int show_err){ - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_soft_rs1, - self->eeprom_map_p->page_soft_rs1, - self->eeprom_map_p->offset_soft_rs1, - self->eeprom_map_p->length_soft_rs1, - &(self->soft_rs1), - "_sfp_update_attr_soft_rs1", - show_err); -} - - -int -_sfp_is_diag_support(struct transvr_obj_s *self){ - - uint8_t bit_mask = 0xC0; /* 1100 0000 */ - uint8_t en_val = 0x40; /* 0100 0000 */ - uint8_t checkval = (self->diag_type & bit_mask); - - if (checkval == en_val) { - return 1; - } - return 0; -} - - -static int -_sfp_update_attr_curr_temp(struct transvr_obj_s *self, - int show_err){ - - if (!(_sfp_is_diag_support(self))) { - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_temp, - self->eeprom_map_p->page_temp, - self->eeprom_map_p->offset_temp, - self->eeprom_map_p->length_temp, - self->curr_temp, - "_sfp_update_attr_curr_temp", - show_err); -} - - -static int -_sfp_update_attr_curr_voltage(struct transvr_obj_s *self, - int show_err){ - - if (!(_sfp_is_diag_support(self))) { - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_voltage, - self->eeprom_map_p->page_voltage, - self->eeprom_map_p->offset_voltage, - self->eeprom_map_p->length_voltage, - self->curr_voltage, - "_sfp_update_attr_curr_voltage", - show_err); -} - - -static int -_sfp_update_attr_curr_tx_bias(struct transvr_obj_s *self, - int show_err){ - - if (!(_sfp_is_diag_support(self))) { - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_tx_bias, - self->eeprom_map_p->page_tx_bias, - self->eeprom_map_p->offset_tx_bias, - self->eeprom_map_p->length_tx_bias, - self->curr_tx_bias, - "_sfp_update_attr_curr_tx_bias", - show_err); -} - - -static int -_sfp_update_attr_curr_tx_power(struct transvr_obj_s *self, - int show_err){ - - if (!(_sfp_is_diag_support(self))) { - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_tx_power, - self->eeprom_map_p->page_tx_power, - self->eeprom_map_p->offset_tx_power, - self->eeprom_map_p->length_tx_power, - self->curr_tx_power, - "_sfp_update_attr_curr_tx_power", - show_err); -} - - -static int -_sfp_update_attr_curr_rx_power(struct transvr_obj_s *self, - int show_err){ - - if (!(_sfp_is_diag_support(self))) { - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_rx_power, - self->eeprom_map_p->page_rx_power, - self->eeprom_map_p->offset_rx_power, - self->eeprom_map_p->length_rx_power, - self->curr_rx_power, - "_sfp_update_attr_curr_rx_power", - show_err); -} - - -static int -_sfp_update_attr_rx_em(struct transvr_obj_s *self, - int show_err){ - - if (!_is_transvr_support_ctle(self)) { - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_rx_em, - self->eeprom_map_p->page_rx_em, - self->eeprom_map_p->offset_rx_em, - self->eeprom_map_p->length_rx_em, - self->rx_em, - "_sfp_update_attr_rx_em", - show_err); -} - - -static int -_sfp_update_attr_tx_eq(struct transvr_obj_s *self, - int show_err){ - - if (!_is_transvr_support_ctle(self)) { - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_tx_eq, - self->eeprom_map_p->page_tx_eq, - self->eeprom_map_p->offset_tx_eq, - self->eeprom_map_p->length_tx_eq, - self->tx_eq, - "_sfp_update_attr_tx_eq", - show_err); -} - - -static int -_qsfp_update_attr_cdr(struct transvr_obj_s *self, - int show_err){ - if (self->type != TRANSVR_TYPE_QSFP_28){ - self->cdr = DEBUG_TRANSVR_HEX_VAL; - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_cdr, - self->eeprom_map_p->page_cdr, - self->eeprom_map_p->offset_cdr, - self->eeprom_map_p->length_cdr, - &(self->cdr), - "_common_update_attr_cdr", - show_err); -} - - -static int -_qsfg_update_attr_extbr(struct transvr_obj_s *self, - int show_err) { - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_extbr, - self->eeprom_map_p->page_extbr, - self->eeprom_map_p->offset_extbr, - self->eeprom_map_p->length_extbr, - &(self->extbr), - "_common_update_attr_extbr", - show_err); -} - - -static int -_qsfp_is_diag_support(struct transvr_obj_s *self, - int diag_type) { - /* Input Parm: diag_type - * => 1 : temperature - * => 2 : voltage - * => 3 : tx relate - * => 4 : rx relate - */ - uint8_t mask_b2 = 0x04; /* 0000 0100 */ - uint8_t mask_b3 = 0x08; /* 0000 1000 */ - - switch (diag_type) { - case 1: /* temperature */ - case 2: /* voltage */ - /* Direct access target, because of spec not defined */ - return 1; - case 3: - case 4: - /* [Note] - * Due to lot of transceiver vendor defined it not rigorously and - * consider of general support, we seem it as supported if there - * are bit-2 OR bit-3 defined by transceiver vendor. - */ - if ( ((self->diag_type & mask_b2) == mask_b2 ) || - ((self->diag_type & mask_b3) == mask_b3 ) ){ - return 1; - } - return 0; - default: - SWPS_INFO("%s: undefined diag_type:%d\n", - __func__, diag_type); - break; - } - return 0; -} - - -int -_qsfp_is_implement_tx_disable(struct transvr_obj_s *self) { - /* - * 00h / Byte-195 / Bit-4 - */ - int byte = 2; - int bit = 4; - return _common_get_option_value(self, byte, bit); -} - - -int -_qsfp_is_implement_tx_fault(struct transvr_obj_s *self) { - /* - * 00h / Byte-195 / Bit-3 - */ - int byte = 2; - int bit = 3; - return _common_get_option_value(self, byte, bit); -} - - -static int -_qsfp_update_attr_curr_temp(struct transvr_obj_s *self, - int show_err){ - int diag_type = 1; - - if (!(_qsfp_is_diag_support(self, diag_type))) { - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_temp, - self->eeprom_map_p->page_temp, - self->eeprom_map_p->offset_temp, - self->eeprom_map_p->length_temp, - self->curr_temp, - "_qsfp_update_attr_curr_temp", - show_err); -} - - -static int -_qsfp_update_attr_curr_voltage(struct transvr_obj_s *self, - int show_err){ - int diag_type = 2; - - if (!(_qsfp_is_diag_support(self, diag_type))) { - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_voltage, - self->eeprom_map_p->page_voltage, - self->eeprom_map_p->offset_voltage, - self->eeprom_map_p->length_voltage, - self->curr_voltage, - "_qsfp_update_attr_curr_voltage", - show_err); -} - - -static int -_qsfp_update_attr_curr_tx_bias(struct transvr_obj_s *self, - int show_err){ - int diag_type = 3; - - if (!(_qsfp_is_diag_support(self, diag_type))) { - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_tx_bias, - self->eeprom_map_p->page_tx_bias, - self->eeprom_map_p->offset_tx_bias, - self->eeprom_map_p->length_tx_bias, - self->curr_tx_bias, - "_qsfp_update_attr_curr_tx_bias", - show_err); -} - - -static int -_qsfp_update_attr_curr_tx_power(struct transvr_obj_s *self, - int show_err){ - int diag_type = 3; - - if (!(_qsfp_is_diag_support(self, diag_type))) { - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_tx_power, - self->eeprom_map_p->page_tx_power, - self->eeprom_map_p->offset_tx_power, - self->eeprom_map_p->length_tx_power, - self->curr_tx_power, - "_qsfp_update_attr_curr_tx_power", - show_err); -} - - -static int -_qsfp_update_attr_curr_rx_power(struct transvr_obj_s *self, - int show_err){ - int diag_type = 4; - - if (!(_qsfp_is_diag_support(self, diag_type))) { - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_rx_power, - self->eeprom_map_p->page_rx_power, - self->eeprom_map_p->offset_rx_power, - self->eeprom_map_p->length_rx_power, - self->curr_rx_power, - "_qsfp_update_attr_curr_rx_power", - show_err); -} - - -static int -_qsfp_update_attr_soft_rx_los(struct transvr_obj_s *self, - int show_err){ - - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_rx_los, - self->eeprom_map_p->page_rx_los, - self->eeprom_map_p->offset_rx_los, - self->eeprom_map_p->length_rx_los, - &(self->rx_los), - "_qsfp_update_attr_soft_rx_los", - show_err); -} - - -static int -_qsfp_update_attr_soft_tx_disable(struct transvr_obj_s *self, - int show_err){ - - if (!_qsfp_is_implement_tx_disable(self)) { - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_tx_disable, - self->eeprom_map_p->page_tx_disable, - self->eeprom_map_p->offset_tx_disable, - self->eeprom_map_p->length_tx_disable, - &(self->tx_disable), - "_qsfp_update_attr_soft_tx_disable", - show_err); -} - - -static int -_qsfp_update_attr_soft_tx_fault(struct transvr_obj_s *self, - int show_err){ - - if (!_qsfp_is_implement_tx_fault(self)) { - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_tx_fault, - self->eeprom_map_p->page_tx_fault, - self->eeprom_map_p->offset_tx_fault, - self->eeprom_map_p->length_tx_fault, - &(self->tx_fault), - "_qsfp_update_attr_soft_tx_fault", - show_err); -} - - -static int -_qsfp_update_attr_tx_eq(struct transvr_obj_s *self, - int show_err){ - - if (!_is_transvr_support_ctle(self)) { - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_tx_eq, - self->eeprom_map_p->page_tx_eq, - self->eeprom_map_p->offset_tx_eq, - self->eeprom_map_p->length_tx_eq, - self->tx_eq, - "_qsfp_update_attr_tx_eq", - show_err); -} - - -static int -_qsfp_update_attr_rx_am(struct transvr_obj_s *self, - int show_err){ - - if (!_is_transvr_support_ctle(self)) { - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_rx_am, - self->eeprom_map_p->page_rx_am, - self->eeprom_map_p->offset_rx_am, - self->eeprom_map_p->length_rx_am, - self->rx_am, - "_qsfp_update_attr_rx_am", - show_err); -} - - -static int -_qsfp_update_attr_rx_em(struct transvr_obj_s *self, - int show_err){ - - if (!_is_transvr_support_ctle(self)) { - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_rx_em, - self->eeprom_map_p->page_rx_em, - self->eeprom_map_p->offset_rx_em, - self->eeprom_map_p->length_rx_em, - self->rx_em, - "_qsfp_update_attr_rx_em", - show_err); -} - - -int -_common_update_attr_all(struct transvr_obj_s *self, - int show_err){ - - char *err_str = "err"; - - if (_common_update_attr_id(self, show_err) < 0) { - err_str = "_common_update_attr_id"; - goto err_common_update_attr_all; - } - if (_common_update_attr_extended_id(self, show_err) < 0) { - err_str = "_common_update_attr_extended_id"; - goto err_common_update_attr_all; - } - if (_common_update_attr_connector(self, show_err) < 0) { - err_str = "_common_update_attr_connector"; - goto err_common_update_attr_all; - } - if (_common_update_attr_transvr_comp(self, show_err) < 0) { - err_str = "_common_update_attr_transvr_comp"; - goto err_common_update_attr_all; - } - if (_common_update_attr_transvr_comp_ext(self, show_err) < 0) { - err_str = "_common_update_attr_transvr_comp_ext"; - goto err_common_update_attr_all; - } - if (_common_update_attr_vendor_name(self, show_err) < 0) { - err_str = "_common_update_attr_vendor_name"; - goto err_common_update_attr_all; - } - if (_common_update_attr_vendor_pn(self, show_err) < 0) { - err_str = "_common_update_attr_vendor_pn"; - goto err_common_update_attr_all; - } - if (_common_update_attr_vendor_rev(self, show_err) < 0) { - err_str = "_common_update_attr_vendor_rev"; - goto err_common_update_attr_all; - } - if (_common_update_attr_vendor_sn(self, show_err) < 0) { - err_str = "_common_update_attr_vendor_sn"; - goto err_common_update_attr_all; - } - if (_common_update_attr_br(self, show_err) < 0) { - err_str = "_common_update_attr_br"; - goto err_common_update_attr_all; - } - if (_common_update_attr_len_smf(self, show_err) < 0) { - err_str = "_common_update_attr_len_smf"; - goto err_common_update_attr_all; - } - if (_common_update_attr_len_om1(self, show_err) < 0) { - err_str = "_common_update_attr_len_om1"; - goto err_common_update_attr_all; - } - if (_common_update_attr_len_om2(self, show_err) < 0) { - err_str = "_common_update_attr_len_om2"; - goto err_common_update_attr_all; - } - if (_common_update_attr_len_om3(self, show_err) < 0) { - err_str = "_common_update_attr_len_om3"; - goto err_common_update_attr_all; - } - if (_common_update_attr_len_om4(self, show_err) < 0) { - err_str = "_common_update_attr_len_om4"; - goto err_common_update_attr_all; - } - if (_common_update_attr_option(self, show_err) < 0) { - err_str = "_common_update_attr_option"; - goto err_common_update_attr_all; - } - if (_common_update_attr_comp_rev(self, show_err) < 0) { - err_str = "_common_update_attr_comp_rev"; - goto err_common_update_attr_all; - } - if (_common_update_attr_diag_type(self, show_err) < 0) { - err_str = "_common_update_attr_diag_type"; - goto err_common_update_attr_all; - } - if (_common_update_attr_wavelength(self, show_err) < 0) { - err_str = "_common_update_attr_wavelength"; - goto err_common_update_attr_all; - } - if (_common_update_attr_eeprom(self, show_err) < 0) { - err_str = "_common_update_attr_eeprom"; - goto err_common_update_attr_all; - } - return 0; - -err_common_update_attr_all: - if (show_err){ - SWPS_INFO("%s: fail at:%s :%s\n", __func__, err_str, self->swp_name); - } - return -1; -} - - -int -_sfp_update_attr_all(struct transvr_obj_s *self, - int show_err){ - - char *err_str = DEBUG_TRANSVR_STR_VAL; - - if (_common_update_attr_all(self, show_err) < 0){ - err_str = "_common_update_attr_all"; - goto err_sfp_update_attr_all; - } - if (_sfp_update_attr_len_sm(self, show_err) < 0) { - err_str = "_sfp_update_attr_len_sm"; - goto err_sfp_update_attr_all; - } - if (_sfp_update_attr_rate_id(self, show_err) < 0) { - err_str = "_sfp_update_attr_rate_id"; - goto err_sfp_update_attr_all; - } - if ((self->rate_id) > 0) { - if (_sfp_update_attr_soft_rs0(self, show_err) < 0) { - err_str = "_sfp_update_attr_soft_rs0"; - goto err_sfp_update_attr_all; - } - if (_sfp_update_attr_soft_rs1(self, show_err) < 0) { - err_str = "_sfp_update_attr_soft_rs1"; - goto err_sfp_update_attr_all; - } - } - return 0; - -err_sfp_update_attr_all: - if (show_err){ - SWPS_INFO("%s: fail at:%s :%s\n", __func__, err_str, self->swp_name); - } - return -1; -} - - -int -_qsfp_update_attr_all(struct transvr_obj_s *self, - int show_err){ - - char *err_str = DEBUG_TRANSVR_STR_VAL; - - if (_common_update_attr_all(self, show_err) < 0){ - err_str = "_common_update_attr_all"; - goto err_qsfp_update_attr_all; - } - if (_qsfg_update_attr_extbr(self, show_err) < 0) { - err_str = "_qsfg_update_attr_extbr"; - goto err_qsfp_update_attr_all; - } - if (self->type == TRANSVR_TYPE_QSFP_28) { - if (_qsfp_update_attr_cdr(self, 1) < 0) { - err_str = "_qsfp_update_attr_cdr"; - goto err_qsfp_update_attr_all; - } - } - return 0; - -err_qsfp_update_attr_all: - if (show_err){ - SWPS_INFO("%s: fail at:%s :%s\n", __func__, err_str, self->swp_name); - } - return -1; -} - - -/* ========== Object functions for common type ========== - */ -int -_common_count_temp(uint8_t high_byte, - uint8_t low_byte, - char *buf_p) { - int sign = 0; - int high = 0; - int low = 0; - int lmax = 8; - - /* Count high */ - sign = get_bit(high_byte,7); - SWP_BIT_CLEAR(high_byte, 7); - high = (int)high_byte; - if (sign == 1) { - high = 0 - high; - } - /* Count low */ - low = (get_bit(low_byte, 7) * 500); - low += (get_bit(low_byte, 6) * 250); - low += (get_bit(low_byte, 5) * 125); - low += (get_bit(low_byte, 4) * 62); - low = (low / 100); - /* Integrate High and Low */ - return snprintf(buf_p, lmax, "%d.%d\n", high, low); -} - - -int -_common_count_voltage(uint8_t high_byte, - uint8_t low_byte, - char *buf_p) { - /* [Note]: - * Internally measured transceiver supply voltage. Represented - * as a 16 bit unsigned integer with the voltage defined as the - * full 16 bit value (0-65535) with LSB equal to 100 uVolt, - * yielding a total range of 0 to +6.55 Volts. Practical - * considerations to be defined by transceiver manufacturer will - * tend to limit the actual bounds of the supply voltage measurement. - * Accuracy is vendor specific but must be better than 3% of the - * manufacturer's nominal value over specified operating temperature - * and voltage. Note that in some transceivers, transmitter supply - * voltage and receiver supply voltage are isolated. In that case, - * only one supply is monitored. Refer to the device specification - * for more detail. - */ - int total = 0; - int lmax = 8; - int val_i = 0; - int val_f = 0; - /* unit: 100 uV (1mV=1000uV) */ - total = transform_word_to_int(high_byte, low_byte); - val_i = ((total/10) / 1000); - val_f = ((total/10) - (val_i*1000)); - /* Return Unit: 1 Volt */ - return snprintf(buf_p, lmax, "%d.%03d\n", val_i, val_f); -} - - -int -_common_count_tx_bias(uint8_t high_byte, - uint8_t low_byte, - char *buf_p) { - /* [Note] - * Measured TX bias current in uA. Represented as a 16 bit unsigned - * integer with the current defined as the full 16 bit value (0-65535) - * with LSB equal to 2 uA, yielding a total range of 0 to 131 mA. - * Accuracy is vendor specific but must be better than 10% of the - * manufacturer's nominal value over specified operating temperature - * and voltage. - */ - int total = 0; - int lmax = 8; - int val_i = 0; - int val_f = 0; - /* unit: 2 uA (1mA=1000uA) */ - total = transform_word_to_int(high_byte, low_byte); - val_i = ((total*2) / 1000); - val_f = (((total*2) - (val_i*1000)) / 100); - /* Return Unit: 1 mA */ - return snprintf(buf_p, lmax, "%d.%01d\n", val_i, val_f); -} - - -int -_common_count_tx_power(uint8_t high_byte, - uint8_t low_byte, - char *buf_p) { - /* [Note] - * Measured TX output power in mW. Represented as a 16 bit unsigned - * integer with the power defined as the full 16 bit value (0-65535) - * with LSB equal to 0.1 uW, yielding a total range of 0 to 6.5535 mW - * (~ -40 to +8.2 dBm). Data is assumed to be based on measurement of - * laser monitor photodiode current. It is factory calibrated to absolute - * units using the most representative fiber output type. Accuracy is - * vendor specific but must be better than 3dB over specified temperature - * and voltage. Data is not valid when the transmitter is disabled. - */ - int total = 0; - int lmax = 8; - int val_i = 0; - int val_f = 0; - /* unit: 0.1 uW (1mW=1000uW) */ - total = transform_word_to_int(high_byte, low_byte); - val_i = ((total/10) / 1000); - val_f = ((total/10) - (val_i*1000)); - /* Return Unit: 1 mW */ - return snprintf(buf_p, lmax, "%d.%03d\n", val_i, val_f); -} - - -int -_common_count_rx_power(uint8_t high_byte, - uint8_t low_byte, - char *buf_p) { - /* [Note] - * Measured RX received optical power in mW. Value can represent either - * average received power or OMA depending upon how bit 3 of byte 92 (A0h) - * is set. Represented as a 16 bit unsigned integer with the power defined - * as the full 16 bit value (0-65535) with LSB equal to 0.1 uW, yielding a - * total range of 0 to 6.5535 mW (~ -40 to +8.2 dBm). Absolute accuracy is - * dependent upon the exact optical wavelength. For the vendor specified - * wavelength, accuracy shall be better than 3dB over specified temperature - * and voltage. - */ - int total = 0; - int lmax = 8; - int val_i = 0; - int val_f = 0; - /* unit: 0.1 uW (1mW=1000uW) */ - total = transform_word_to_int(high_byte, low_byte); - val_i = ((total/10) / 1000); - val_f = ((total/10) - (val_i*1000)); - /* Return Unit: 1 mW */ - return snprintf(buf_p, lmax, "%d.%03d\n", val_i, val_f); -} - - -int -_common_count_wavelength(struct transvr_obj_s *self, - uint8_t high_byte, - uint8_t low_byte) { - /* [Note] - * SFP : uint 1 um. - * QSFP: unit 0.05 um. - */ - int total = 0; - - total = transform_word_to_int(high_byte, low_byte); - switch (self->type) { - case TRANSVR_TYPE_SFP: - return total; - - case TRANSVR_TYPE_QSFP: - case TRANSVR_TYPE_QSFP_PLUS: - case TRANSVR_TYPE_QSFP_28: - return (total/20); - - default: - break; - } - return ERR_TRANSVR_UNDEFINED; -} - - -int -common_get_id(struct transvr_obj_s *self){ - - int err_code = _check_by_mode(self, - &_common_update_attr_id, - "common_get_id"); - if (err_code < 0){ - return err_code; - } - /* Transform to INT to show error case */ - return (int)self->id; -} - -int -common_get_eeprom(struct transvr_obj_s *self, char *buf){ - - int err = DEBUG_TRANSVR_INT_VAL; - - err = _check_by_mode(self, &_common_update_attr_eeprom, - "common_get_eeprom"); - if (err < 0){ - return snprintf(buf, LEN_TRANSVR_M_STR, "%d\n", err); - } - memset(buf, 0, self->eeprom_map_p->length_eeprom+1); - memcpy(buf, self->eeprom, self->eeprom_map_p->length_eeprom); - *(buf+self->eeprom_map_p->length_eeprom) = '\n'; - return self->eeprom_map_p->length_eeprom+1; -} - -int -common_get_uppage(struct transvr_obj_s *self, char *buf){ - - int err = DEBUG_TRANSVR_INT_VAL; - - if (self->state == STATE_TRANSVR_CONNECTED && - self->mode == TRANSVR_MODE_POLLING && - TRANSVR_INFO_CACHE_ENABLE) { - memset(buf, 0, self->eeprom_map_p->length_uppage+1); - memcpy(buf, self->eeprom, self->eeprom_map_p->length_uppage); - *(buf+self->eeprom_map_p->length_uppage) = '\n'; - return self->eeprom_map_p->length_uppage+1; - } - err = _check_by_mode(self, &_common_update_attr_uppage, - "common_get_uppage"); - if (err < 0){ - return snprintf(buf, LEN_TRANSVR_M_STR, "%d\n", err); - } - memset(buf, 0, self->eeprom_map_p->length_uppage+1); - memcpy(buf, self->eeprom, self->eeprom_map_p->length_uppage); - *(buf+self->eeprom_map_p->length_uppage) = '\n'; - return self->eeprom_map_p->length_uppage+1; -} - - -int -common_get_ext_id(struct transvr_obj_s *self){ - - int err_code = _check_by_mode(self, - &_common_update_attr_extended_id, - "common_get_ext_id"); - if (err_code < 0){ - return err_code; - } - /* Transform to INT to show error case */ - return (int)self->ext_id; -} - - -int -common_get_connector(struct transvr_obj_s *self){ - - int err_code = _check_by_mode(self, - &_common_update_attr_connector, - "common_get_connector"); - if (err_code < 0){ - return err_code; - } - /* Transform to INT to show error case */ - return (int)self->connector; -} - - -int -common_get_vendor_name(struct transvr_obj_s *self, char *buf){ - - int err = DEBUG_TRANSVR_INT_VAL; - - if (self->state == STATE_TRANSVR_CONNECTED && - self->mode == TRANSVR_MODE_POLLING && - TRANSVR_INFO_CACHE_ENABLE) { - return snprintf(buf, LEN_TRANSVR_M_STR, "%s\n", self->vendor_name); - } - err = _check_by_mode(self, - &_common_update_attr_vendor_name, - "common_get_vendor_name"); - memset(buf, 0, LEN_TRANSVR_M_STR); - if (err < 0){ - return snprintf(buf, LEN_TRANSVR_M_STR, "%d\n", err); - } - return snprintf(buf, LEN_TRANSVR_M_STR, "%s\n", self->vendor_name); -} - - -int -common_get_vendor_pn(struct transvr_obj_s *self, char *buf) { - - int err = DEBUG_TRANSVR_INT_VAL; - - if (self->state == STATE_TRANSVR_CONNECTED && - self->mode == TRANSVR_MODE_POLLING && - TRANSVR_INFO_CACHE_ENABLE) { - return snprintf(buf, LEN_TRANSVR_M_STR, "%s\n", self->vendor_pn); - } - err = _check_by_mode(self, - &_common_update_attr_vendor_pn, - "common_get_vendor_pn"); - memset(buf, 0, LEN_TRANSVR_M_STR); - if (err < 0){ - return snprintf(buf, LEN_TRANSVR_M_STR, "%d\n", err); - } - return snprintf(buf, LEN_TRANSVR_M_STR, "%s\n", self->vendor_pn); -} - - -int -common_get_vendor_rev(struct transvr_obj_s *self, char *buf) { - - int err = DEBUG_TRANSVR_INT_VAL; - - if (self->state == STATE_TRANSVR_CONNECTED && - self->mode == TRANSVR_MODE_POLLING && - TRANSVR_INFO_CACHE_ENABLE) { - return snprintf(buf, LEN_TRANSVR_M_STR, "%s\n", self->vendor_rev); - } - err = _check_by_mode(self, - &_common_update_attr_vendor_rev, - "common_get_vendor_rev"); - memset(buf, 0, LEN_TRANSVR_M_STR); - if (err < 0){ - return snprintf(buf, LEN_TRANSVR_M_STR, "%d\n", err); - } - return snprintf(buf, LEN_TRANSVR_M_STR, "%s\n", self->vendor_rev); -} - - -int -common_get_vendor_sn(struct transvr_obj_s *self, char *buf) { - - int err = DEBUG_TRANSVR_INT_VAL; - - if (self->state == STATE_TRANSVR_CONNECTED && - self->mode == TRANSVR_MODE_POLLING && - TRANSVR_INFO_CACHE_ENABLE) { - return snprintf(buf, LEN_TRANSVR_M_STR, "%s\n", self->vendor_sn); - } - err = _check_by_mode(self, - &_common_update_attr_vendor_sn, - "common_get_vendor_sn"); - memset(buf, 0, LEN_TRANSVR_M_STR); - if (err < 0){ - return snprintf(buf, LEN_TRANSVR_M_STR, "%d\n", err); - } - return snprintf(buf, LEN_TRANSVR_M_STR, "%s\n", self->vendor_sn); -} - - -int -common_get_br(struct transvr_obj_s *self){ - - int err = DEBUG_TRANSVR_INT_VAL; - - if (self->state == STATE_TRANSVR_CONNECTED && - self->mode == TRANSVR_MODE_POLLING && - TRANSVR_INFO_CACHE_ENABLE) { - return (int)self->br; - } - err = _check_by_mode(self, - &_common_update_attr_br, - "common_get_br"); - if (err < 0){ - return err; - } - /* Transform to INT to show error case */ - return (int)self->br; -} - - -int -common_get_len_smf(struct transvr_obj_s *self){ - - int err = DEBUG_TRANSVR_INT_VAL; - - if (self->state == STATE_TRANSVR_CONNECTED && - self->mode == TRANSVR_MODE_POLLING && - TRANSVR_INFO_CACHE_ENABLE) { - return self->len_smf; - } - err = _check_by_mode(self, - &_common_update_attr_len_smf, - "common_get_len_smf"); - if (err < 0){ - return err; - } - return self->len_smf; -} - - -int -common_get_len_om1(struct transvr_obj_s *self){ - - int err = DEBUG_TRANSVR_INT_VAL; - - if (self->state == STATE_TRANSVR_CONNECTED && - self->mode == TRANSVR_MODE_POLLING && - TRANSVR_INFO_CACHE_ENABLE) { - return self->len_om1; - } - err = _check_by_mode(self, - &_common_update_attr_len_om1, - "common_get_len_om1"); - if (err < 0){ - return err; - } - return self->len_om1; -} - - -int -common_get_len_om2(struct transvr_obj_s *self){ - - int err = DEBUG_TRANSVR_INT_VAL; - - if (self->state == STATE_TRANSVR_CONNECTED && - self->mode == TRANSVR_MODE_POLLING && - TRANSVR_INFO_CACHE_ENABLE) { - return self->len_om2; - } - - err = _check_by_mode(self, - &_common_update_attr_len_om2, - "common_get_len_om2"); - if (err < 0){ - return err; - } - return self->len_om2; -} - - -int -common_get_len_om3(struct transvr_obj_s *self){ - - int err = DEBUG_TRANSVR_INT_VAL; - - if (self->state == STATE_TRANSVR_CONNECTED && - self->mode == TRANSVR_MODE_POLLING && - TRANSVR_INFO_CACHE_ENABLE) { - return self->len_om3; - } - - err = _check_by_mode(self, - &_common_update_attr_len_om3, - "common_get_len_om3"); - if (err < 0){ - return err; - } - return self->len_om3; -} - - -int -common_get_len_om4(struct transvr_obj_s *self){ - - int err = DEBUG_TRANSVR_INT_VAL; - - if (self->state == STATE_TRANSVR_CONNECTED && - self->mode == TRANSVR_MODE_POLLING && - TRANSVR_INFO_CACHE_ENABLE) { - return self->len_om4; - } - err = _check_by_mode(self, - &_common_update_attr_len_om4, - "common_get_len_om4"); - if (err < 0){ - return err; - } - return self->len_om4; -} - - -int -common_get_comp_extended(struct transvr_obj_s *self){ - - int err_code = _check_by_mode(self, - &_common_update_attr_transvr_comp_ext, - "common_get_comp_extended"); - if (err_code < 0){ - return err_code; - } - return self->transvr_comp_ext; -} - - -int -common_get_comp_rev(struct transvr_obj_s *self){ - - int err_code = _check_by_mode(self, - &_common_update_attr_comp_rev, - "common_get_comp_rev"); - if (err_code < 0){ - return err_code; - } - return self->comp_rev; -} - - -int -common_get_info(struct transvr_obj_s *self){ - - if (self->state != STATE_TRANSVR_CONNECTED) { - return self->state; - } - return self->info; -} - - -int -_common_get_if_lane(struct transvr_obj_s *self, - char *result){ - int i = 0; - int tmp_val = 0; - char tmp_str[LEN_TRANSVR_M_STR] = DEBUG_TRANSVR_STR_VAL; - - memset(result, 0, LEN_TRANSVR_M_STR); - - for (i=0; ilane_id); i++) { - tmp_val = self->lane_id[i]; - if (tmp_val < 1) { - break; - } - memset(tmp_str, 0, LEN_TRANSVR_M_STR); - if (i == 0) { - snprintf(tmp_str, LEN_TRANSVR_M_STR, "%d", tmp_val); - } else { - snprintf(tmp_str, LEN_TRANSVR_M_STR, ",%d", tmp_val); - } - strncat(result, tmp_str, LEN_TRANSVR_M_STR); - } - if (i == 0) { - return EVENT_TRANSVR_TASK_FAIL; - } - return 0; -} - - -int -common_get_if_lane(struct transvr_obj_s *self, - char *buf_p){ - - char tmp_str[LEN_TRANSVR_M_STR] = DEBUG_TRANSVR_STR_VAL; - - if (self->ioexp_obj_p->state != STATE_IOEXP_NORMAL) { - return snprintf(buf_p, LEN_TRANSVR_M_STR, "%d\n", ERR_TRANSVR_ABNORMAL); - } - if (_common_get_if_lane(self, tmp_str) < 0) { - return snprintf(buf_p, LEN_TRANSVR_M_STR, "%d\n" ,ERR_TRANSVR_ABNORMAL); - } - return snprintf(buf_p, LEN_TRANSVR_M_STR, "%s\n" ,tmp_str); -} - - -int -sfp_get_len_sm(struct transvr_obj_s *self){ - - int err_code = _check_by_mode(self, - &_sfp_update_attr_len_sm, - "sfp_get_len_sm"); - if (err_code < 0){ - return err_code; - } - return self->len_sm; -} - - -int -sfp_get_rate_id(struct transvr_obj_s *self){ - - int err_code = _check_by_mode(self, - &_sfp_update_attr_rate_id, - "sfp_get_rate_id"); - if (err_code < 0){ - return err_code; - } - return self->rate_id; -} - - -int -sfp_get_soft_rs0(struct transvr_obj_s *self){ - /* Note: - * SFP Soft Rate_Select Select [aka. "RS(0)"] address - * A2h, offset: 110, bit 3 (begin form 0) - */ - int err_code = DEBUG_TRANSVR_INT_VAL; - int bit_shift = 3; - uint8_t result = 0x00; - uint8_t bitmask = (1 << bit_shift); - - /* Check rate identifier is supported */ - err_code = self->get_rate_id(self); - if (err_code <= 0) { - return ERR_TRANSVR_NOTSUPPORT; - } - /* Update and check */ - err_code = _check_by_mode(self, - &_sfp_update_attr_soft_rs0, - "sfp_get_soft_rs0"); - if (err_code <0){ - return err_code; - } - result = (self->soft_rs0 & bitmask); - if (result == bitmask) { - return 1; - } - if (result == 0) { - return 0; - } - return ERR_TRANSVR_UNEXCPT; -} - - -int -sfp_get_soft_rs1(struct transvr_obj_s *self){ - /* Note: - * SFP Soft RS(1) Select address - * A2h, offset: 118, bit 3 (begin form 0) - */ - int err_code = DEBUG_TRANSVR_INT_VAL; - int bit_shift = 3; - uint8_t result = 0x00; - uint8_t bitmask = (1 << bit_shift); - - /* Check rate identifier is supported */ - err_code = self->get_rate_id(self); - if (err_code <= 0) { - return ERR_TRANSVR_NOTSUPPORT; - } - /* Update and check */ - err_code = _check_by_mode(self, - &_sfp_update_attr_soft_rs1, - "sfp_get_soft_rs1"); - if (err_code <0){ - return err_code; - } - result = (self->soft_rs1 & bitmask); - if (result == bitmask) { - return 1; - } - if (result == 0) { - return 0; - } - return ERR_TRANSVR_UNEXCPT; -} - - -int -sfp_get_transvr_temp(struct transvr_obj_s *self, - char *buf_p) { - - int lmax = 8; - int err_code = DEBUG_TRANSVR_INT_VAL; - - err_code = _check_by_mode(self, - &_sfp_update_attr_curr_temp, - "sfp_get_transvr_temp"); - if (err_code < 0) { - return snprintf(buf_p, lmax, "%d\n", err_code); - } - if ((self->curr_temp[0]) == DEBUG_TRANSVR_HEX_VAL) { - return snprintf(buf_p, lmax, "%d\n", ERR_TRANSVR_UPDATE_FAIL); - } - return _common_count_temp(self->curr_temp[0], - self->curr_temp[1], - buf_p); -} - - -int -sfp_get_transvr_voltage(struct transvr_obj_s *self, - char *buf_p) { - - int lmax = 8; - int err_code = DEBUG_TRANSVR_INT_VAL; - - err_code = _check_by_mode(self, - &_sfp_update_attr_curr_voltage, - "sfp_get_transvr_voltage"); - if (err_code < 0) { - return snprintf(buf_p, lmax, "%d\n", err_code); - } - if ((self->curr_voltage[0]) == DEBUG_TRANSVR_HEX_VAL) { - return snprintf(buf_p, lmax, "%d\n", ERR_TRANSVR_UPDATE_FAIL); - } - /* Return Unit: 1 Volt */ - return _common_count_voltage(self->curr_voltage[0], - self->curr_voltage[1], - buf_p); -} - - -int -sfp_get_transvr_tx_bias(struct transvr_obj_s *self, - char *buf_p) { - - int lmax = 8; - int err_code = DEBUG_TRANSVR_INT_VAL; - - err_code = _check_by_mode(self, - &_sfp_update_attr_curr_tx_bias, - "sfp_get_transvr_tx_bias"); - if (err_code < 0) { - return snprintf(buf_p, lmax, "%d\n", err_code); - } - if ((self->curr_tx_bias[0]) == DEBUG_TRANSVR_HEX_VAL) { - return snprintf(buf_p, lmax, "%d\n", ERR_TRANSVR_UPDATE_FAIL); - } - /* Return Unit: 1 mA */ - return _common_count_tx_bias(self->curr_tx_bias[0], - self->curr_tx_bias[1], - buf_p); -} - - -int -sfp_get_transvr_tx_power(struct transvr_obj_s *self, - char *buf_p) { - - int lmax = 8; - int err_code = DEBUG_TRANSVR_INT_VAL; - - err_code = _check_by_mode(self, - &_sfp_update_attr_curr_tx_power, - "sfp_get_transvr_tx_power"); - if (err_code < 0) { - return snprintf(buf_p, lmax, "%d\n", err_code); - } - if ((self->curr_tx_bias[0]) == DEBUG_TRANSVR_HEX_VAL) { - return snprintf(buf_p, lmax, "%d\n", ERR_TRANSVR_UPDATE_FAIL); - } - /* Return Unit: 1 mW */ - return _common_count_tx_power(self->curr_tx_power[0], - self->curr_tx_power[1], - buf_p); -} - - -int -sfp_get_transvr_rx_power(struct transvr_obj_s *self, - char *buf_p) { - - int lmax = 8; - int err_code = DEBUG_TRANSVR_INT_VAL; - - err_code = _check_by_mode(self, - &_sfp_update_attr_curr_rx_power, - "sfp_get_transvr_rx_power"); - if (err_code < 0) { - return snprintf(buf_p, lmax, "%d\n", err_code); - } - if ((self->curr_tx_bias[0]) == DEBUG_TRANSVR_HEX_VAL) { - return snprintf(buf_p, lmax, "%d\n", ERR_TRANSVR_UPDATE_FAIL); - } - /* Return Unit: 1 mW */ - return _common_count_rx_power(self->curr_rx_power[0], - self->curr_rx_power[0], - buf_p); -} - - -int -sfp_get_transvr_rx_em(struct transvr_obj_s *self, - char *buf_p) { - - int limt = 8; - int err = DEBUG_TRANSVR_INT_VAL; - - err = _check_by_mode(self, - &_sfp_update_attr_rx_em, - "sfp_get_transvr_rx_em"); - if (err < 0) { - return snprintf(buf_p, limt, "%d\n", err); - } - if ((self->tx_eq[0]) == DEBUG_TRANSVR_HEX_VAL) { - return snprintf(buf_p, limt, "%d\n", ERR_TRANSVR_UPDATE_FAIL); - } - return snprintf(buf_p, limt, "0x%02x\n", self->rx_em[0]); -} - - -int -sfp_get_transvr_tx_eq(struct transvr_obj_s *self, - char *buf_p) { - - int limt = 8; - int err = DEBUG_TRANSVR_INT_VAL; - - err = _check_by_mode(self, - &_sfp_update_attr_tx_eq, - "sfp_get_transvr_tx_eq"); - if (err < 0) { - return snprintf(buf_p, limt, "%d\n", err); - } - if ((self->tx_eq[0]) == DEBUG_TRANSVR_HEX_VAL) { - return snprintf(buf_p, limt, "%d\n", ERR_TRANSVR_UPDATE_FAIL); - } - return snprintf(buf_p, limt, "0x%02x\n", self->tx_eq[0]); -} - - -int -_sfp_get_comp_extended(struct transvr_obj_s *self) { - /* Address: A0h / 36 - * Reference: SFF-8024 TABLE 4-4 - */ - if ((self->state == STATE_TRANSVR_CONNECTED) || - (self->state == STATE_TRANSVR_INIT) ) { - return (int)(self->transvr_comp_ext); - } - return ERR_TRANSVR_ABNORMAL; -} - - -int -__sfp_get_comp_attr(struct transvr_obj_s *self, - int array_offset) { - /* SFP Specification Compliance: A0h / 3-10 - * transvr_comp[0-7] = 3 - 10 - */ - if ((self->state == STATE_TRANSVR_CONNECTED) || - (self->state == STATE_TRANSVR_INIT) ) { - return (int)(self->transvr_comp[array_offset]); - } - return ERR_TRANSVR_ABNORMAL; -} - - -int -_sfp_get_comp_10g_eth_comp(struct transvr_obj_s *self) { - /* transvr_comp[0] = address A0h / 3 - * - * 3 7: 10G Base-ER - * 3 6: 10GBASE-LRM - * 3 5: 10GBASE-LR - * 3 4: 10GBASE-SR - */ - int bitmask = 0xf0; /* 11110000 */ - return (__sfp_get_comp_attr(self, 0) & bitmask); -} - - -int -_sfp_get_comp_1g_eth_comp(struct transvr_obj_s *self) { - /* transvr_comp[3] = address A0h / 6 - * - * 6 7: BASE-PX *3 - * 6 6: BASE-BX10 *3 - * 6 5: 100BASE-FX - * 6 4: 100BASE-LX/LX10 - * 6 3: 1000BASE-T - * 6 2: 1000BASE-CX - * 6 1: 1000BASE-LX *3 - * 6 0: 1000BASE-SX - */ - return __sfp_get_comp_attr(self, 3); -} - - -int -_sfp_get_cable_tech(struct transvr_obj_s *self) { - /* transvr_comp[5] = address A0h / 8 - * - * 8 3: Active Cable *8 - * 8 2: Passive Cable *8 - */ - int bitmask = 0x0c; /* 00001100 */ - return (__sfp_get_comp_attr(self, 5) & bitmask); -} - - -int -sfp_get_comp_eth_1(struct transvr_obj_s *self){ - - int err_code = _check_by_mode(self, - &_common_update_attr_transvr_comp, - "sfp_get_comp_eth_1"); - if (err_code < 0){ - return err_code; - } - return _sfp_get_comp_1g_eth_comp(self); -} - - -int -sfp_get_comp_eth_10(struct transvr_obj_s *self){ - - int err_code = _check_by_mode(self, - &_common_update_attr_transvr_comp, - "sfp_get_comp_eth_10"); - if (err_code < 0){ - return err_code; - } - return _sfp_get_comp_10g_eth_comp(self); -} - - -int -_sfp_get_connector_type(struct transvr_obj_s *self) { - /* Address: A0h / 2 - * Reference: SFF-8024 TABLE 4-3 - */ - if ((self->state == STATE_TRANSVR_CONNECTED) || - (self->state == STATE_TRANSVR_INIT) ) { - return (int)(self->connector); - } - return ERR_TRANSVR_ABNORMAL; -} - - -int -sfp_get_wavelength(struct transvr_obj_s *self, - char *buf_p) { - /* [Note] Optical and Cable Variants Specification Compliance (SFF-8472) - * [Addr] A0h, Bytes 60-61 - * [Note] For optical variants, as defined by having zero's in A0h Byte 8 - * bits 2 and 3, Bytes 60 and 61 denote nominal transmitter output - * wavelength at room temperature. 16 bit value with byte 60 as high - * order byte and byte 61 as low order byte. The laser wavelength is - * equal to the 16 bit integer value in nm. This field allows the user - * to read the laser wavelength directly, so it is not necessary to - * infer it from the Transceiver Codes A0h Bytes 3 to 10 (see Table - * 5-3). This also allows specification of wavelengths not covered - * in the Transceiver Codes, such as those used in coarse WDM systems. - * - * For passive and active cable variants, a value of 00h for both A0h - * Byte 60 and Byte 61 denotes laser wavelength or cable specification - * compliance is unspecified. - */ - - int lmax = 8; - int err_code = DEBUG_TRANSVR_INT_VAL; - - err_code = _check_by_mode(self, - &_common_update_attr_wavelength, - "common_get_wavelength"); - if (err_code < 0) { - return snprintf(buf_p, lmax, "%d\n", err_code); - } - if ((self->wavelength[0]) == DEBUG_TRANSVR_HEX_VAL) { - return snprintf(buf_p, lmax, "%d\n", ERR_TRANSVR_UPDATE_FAIL); - } - /* unit: 1 um */ - return snprintf(buf_p, lmax, "%d\n", - _common_count_wavelength(self, - self->wavelength[0], - self->wavelength[1])); -} - - -int -sfp_get_1g_rj45_extphy_offset(struct transvr_obj_s *self, char *buf) { - - if (self->state != STATE_TRANSVR_CONNECTED) { - return ERR_TRANSVR_UNPLUGGED; - } - if ((self->info != TRANSVR_CLASS_BASE_T_1000) && - (self->info != TRANSVR_CLASS_BASE_T_1000_up) ){ - return ERR_TRANSVR_NOTSUPPORT; - } - return snprintf(buf, LEN_TRANSVR_S_STR, "0x%02x\n", self->extphy_offset); -} - - -int -sfp_get_1g_rj45_extphy_reg(struct transvr_obj_s *self, char *buf) { - - int i = 0; - int ret = 0; - int retry = 3; - int delay = 200; - - if (self->state != STATE_TRANSVR_CONNECTED) { - return ERR_TRANSVR_UNPLUGGED; - } - if ((self->info != TRANSVR_CLASS_BASE_T_1000) && - (self->info != TRANSVR_CLASS_BASE_T_1000_up) ){ - return ERR_TRANSVR_NOTSUPPORT; - } - if (_common_setup_page(self, VAL_TRANSVR_EXTPHY_ADDR_56, - -1, self->extphy_offset, 1, 0) < 0) { - return -EIO; - } - for (i=0; ii2c_client_p, self->extphy_offset); - if (ret >=0) { - goto ok_sfp_get_1g_rj45_extphy_reg; - } - msleep(delay); - } - SWPS_INFO("%s: retry:%d fail :%s :0x%02x\n", - __func__, retry, self->swp_name, self->extphy_offset); - return -EIO; - -ok_sfp_get_1g_rj45_extphy_reg: - ret = ((ret & 0x00ff) << 8) | ((ret & 0xff00) >> 8); - return snprintf(buf, LEN_TRANSVR_S_STR, "0x%04x\n", ret); -} - - -int -__qsfp_get_power_cls(struct transvr_obj_s *self, - int direct_access){ - - int err_code; - uint8_t detect_val; - - /* Detect and Update power class attribute */ - if (direct_access){ - err_code = _check_by_mode(self, - &_common_update_attr_extended_id, - "__qsfp_get_power_cls"); - } else { - err_code = self->ext_id; - } - if (err_code <0){ - return err_code; - } - if (err_code == DEBUG_TRANSVR_HEX_VAL){ - return ERR_TRANSVR_UPDATE_FAIL; - } - /* Clean data */ - detect_val = self->ext_id; - SWP_BIT_CLEAR(detect_val, 2); /* Bit2: CDR RX present */ - SWP_BIT_CLEAR(detect_val, 3); /* Bit3: CDR TX present */ - SWP_BIT_CLEAR(detect_val, 4); /* Bit4: CLEI present */ - SWP_BIT_CLEAR(detect_val, 5); /* Bit5: reserved */ - /* Identify power class */ - switch (detect_val) { - case 0: /* Class_1: 00000000 */ - return 1; - case 64: /* Class_2: 01000000 */ - return 2; - case 128: /* Class_3: 10000000 */ - return 3; - case 192: /* Class_4: 11000000 */ - return 4; - case 1: /* Class_5: 00000001 */ - case 193: /* Class_5: 11000001 */ - return 5; - case 2: /* Class_6: 00000010 */ - case 194: /* Class_6: 11000010 */ - return 6; - case 3: /* Class_7: 00000011 */ - case 195: /* Class_7: 11000011 */ - return 7; - default: - break; - } - SWPS_INFO("%s: Detect undefined power class:%d\n", __func__, detect_val); - return ERR_TRANSVR_UNDEFINED; -} - - -int -qsfp_get_power_cls(struct transvr_obj_s *self) { - return __qsfp_get_power_cls(self, 1); -} - - -int -__qsfp_get_cdr_present(struct transvr_obj_s *self, - int direct_access){ - - int retval; - int BIT_SHIFT = 2; - int BIT_MASK = 0x3; - - /* Detect and Update power class attribute */ - if (direct_access) { - retval = _check_by_mode(self, - &_common_update_attr_extended_id, - "__qsfp_get_cdr_present"); - if (retval < 0){ - return retval; - } - } - retval = self->ext_id; - if (retval == DEBUG_TRANSVR_HEX_VAL){ - return ERR_TRANSVR_UPDATE_FAIL; - } - /* Clean data and return */ - return (int)(retval >> BIT_SHIFT & BIT_MASK); -} - - -int -qsfp_get_cdr_present(struct transvr_obj_s *self) { - return __qsfp_get_cdr_present(self, 1); -} - - -int -qsfp_get_cdr(struct transvr_obj_s *self){ - - int err_code = _check_by_mode(self, - &_qsfp_update_attr_cdr, - "qsfp_get_cdr"); - if (err_code <0){ - return err_code; - } - - return self->cdr; -} - - -int -__qsfp_get_comp_attr(struct transvr_obj_s *self, - int array_offset) { - /* QSFP Specification Compliance: 00h / 131-138 - * transvr_comp[0-7] = 131 - 138 - */ - if ((self->state == STATE_TRANSVR_CONNECTED) || - (self->state == STATE_TRANSVR_INIT) ) { - return (int)(self->transvr_comp[array_offset]); - } - return ERR_TRANSVR_ABNORMAL; -} - - -int -_qsfp_get_comp_10_40_100_ethernet(struct transvr_obj_s *self) { - /* transvr_comp[0] = address 00h / 131 - * - * 131 7: Extended: See section 6.3.23. The Extended Specification Compliance - * Codes are maintained in the Transceiver Management section of SFF- - * 8024. - * 131 6: 10GBASE-LRM - * 131 5: 10GBASE-LR - * 131 4: 10GBASE-SR - * 131 3: 40GBASE-CR4 - * 131 2: 40GBASE-SR4 - * 131 1: 40GBASE-LR4 - * 131 0: 40G Active Cable (XLPPI) - */ - return __qsfp_get_comp_attr(self, 0); -} - - -int -_qsfp_get_comp_sonet(struct transvr_obj_s *self) { - /* transvr_comp[1] = address 00h / 132 - * - * 132 7-3: Reserved - * 132 2: OC 48, long reach - * 132 1: OC 48, intermediate reach - * 132 0: OC 48 short reach - */ - return __qsfp_get_comp_attr(self, 1); -} - - -int -_qsfp_get_comp_sas_sata(struct transvr_obj_s *self) { - /* transvr_comp[1] = address 00h / 132 - * - * 133 7: SAS 24.0 Gb/s - * 133 6: SAS 12.0 Gb/s - * 133 5: SAS 6.0 Gb/s - * 133 4: SAS 3.0 Gb/s - * 133 3-0: Reserved - */ - return __qsfp_get_comp_attr(self, 2); -} - - -int -_qsfp_get_comp_ethernet(struct transvr_obj_s *self) { - /* transvr_comp[1] = address 00h / 132 - * - * 134 7-4: Reserved - * 134 3: 1000BASE-T - * 134 2: 1000BASE-CX - * 134 1: 1000BASE-LX - * 134 0: 1000BASE-SX - */ - return __qsfp_get_comp_attr(self, 3); -} - - -int -_qsfp_get_comp_fc_link_length(struct transvr_obj_s *self) { - /* transvr_comp[1] = address 00h / 132 - * - * 135 7: Very long distance (V) - * 135 6: Short distance (S) - * 135 5: Intermediate distance (I) - * 135 4: Long distance (L) - * 135 3: Medium (M) - */ - int mask = 0xFC; /* 11111100 */ - return (__qsfp_get_comp_attr(self, 4) & mask); -} - - -int -_qsfp_get_comp_fc_trans_tech(struct transvr_obj_s *self) { - /* transvr_comp[1] = address 00h / 132 - * - * 135 2: Reserved - * 135 1: Longwave laser (LC) - * 135 0: Electrical inter-enclosure (EL) - * - * 136 7: Electrical intra-enclosure - * 136 6: Shortwave laser w/o OFC (SN) - * 136 5: Shortwave laser w OFC (SL) - * 136 4: Longwave Laser (LL) - * 136 3-0: Reserved - * - * return value = [bit 8-15:addr 135][bit 0-7:addr 136] - */ - int mask_135 = 7; /* 00000111 */ - int val_135 = (__qsfp_get_comp_attr(self, 4) & mask_135); - int val_136 = __qsfp_get_comp_attr(self, 5); - return ((val_135 << 7) + val_136); -} - - -int -_qsfp_get_comp_fc_trans_media(struct transvr_obj_s *self) { - /* transvr_comp[1] = address 00h / 132 - * - * 137 7: Twin Axial Pair (TW) - * 137 6: Shielded Twisted Pair (TP) - * 137 5: Miniature Coax (MI) - * 137 4: Video Coax (TV) - * 137 3: Multi-mode 62.5 m (M6) - * 137 2: Multi-mode 50 m (M5) - * 137 1: Multi-mode 50 um (OM3) - * 137 0: Single Mode (SM) - */ - return __qsfp_get_comp_attr(self, 6); -} - - -int -_qsfp_get_comp_fc_speed(struct transvr_obj_s *self) { - /* transvr_comp[1] = address 00h / 132 - * - * 138 7: 1200 MBps (per channel) - * 138 6: 800 MBps - * 138 5: 1600 MBps (per channel) - * 138 4: 400 MBps - * 138 3: 3200 MBps (per channel) - * 138 2: 200 MBps - * 138 1: Extended: See section 6.3.23. The Extended Specification - * Compliance Codes are maintained in the Transceiver Management - * section of SFF-8024. - * 138 0: 100 MBps - */ - return __qsfp_get_comp_attr(self, 7); -} - - -int -_qsfp_get_comp_extended(struct transvr_obj_s *self) { - /* Address: 00h / 192 - * Reference: SFF-8024 TABLE 4-4 - */ - if ((self->state == STATE_TRANSVR_CONNECTED) || - (self->state == STATE_TRANSVR_INIT) ) { - return (int)(self->transvr_comp_ext); - } - return ERR_TRANSVR_ABNORMAL; -} - - -int -qsfp_get_comp_eth(struct transvr_obj_s *self){ - - int err_code = _check_by_mode(self, - &_common_update_attr_transvr_comp, - "qsfp_get_comp_eth"); - if (err_code < 0){ - return err_code; - } - return _qsfp_get_comp_ethernet(self); -} - - -int -qsfp_get_comp_10_40(struct transvr_obj_s *self) { - - int err_code = _check_by_mode(self, - &_common_update_attr_transvr_comp, - "qsfp_get_comp_10_40"); - if (err_code < 0){ - return err_code; - } - return _qsfp_get_comp_10_40_100_ethernet(self); -} - - -int -_qsfp_get_connector_type(struct transvr_obj_s *self) { - /* Address: 00h / 130 - * Reference: SFF-8024 TABLE 4-3 - */ - if ((self->state == STATE_TRANSVR_CONNECTED) || - (self->state == STATE_TRANSVR_INIT) ) { - return (int)(self->connector); - } - return ERR_TRANSVR_ABNORMAL; -} - - -int -qsfp_get_transvr_temp(struct transvr_obj_s *self, - char *buf_p) { - - int lmax = 8; - int err_code = DEBUG_TRANSVR_INT_VAL; - - err_code = _check_by_mode(self, - &_qsfp_update_attr_curr_temp, - "qsfp_get_transvr_temp"); - if (err_code < 0) { - return snprintf(buf_p, lmax, "%d\n", err_code); - } - if ((self->curr_temp[0]) == DEBUG_TRANSVR_HEX_VAL) { - return snprintf(buf_p, lmax, "%d\n", ERR_TRANSVR_UPDATE_FAIL); - } - return _common_count_temp(self->curr_temp[0], - self->curr_temp[1], - buf_p); -} - - -int -qsfp_get_transvr_voltage(struct transvr_obj_s *self, - char *buf_p) { - - int lmax = 8; - int err_code = DEBUG_TRANSVR_INT_VAL; - - err_code = _check_by_mode(self, - &_qsfp_update_attr_curr_voltage, - "qsfp_get_transvr_voltage"); - if (err_code < 0) { - return snprintf(buf_p, lmax, "%d\n", err_code); - } - if ((self->curr_voltage[0]) == DEBUG_TRANSVR_HEX_VAL) { - return snprintf(buf_p, lmax, "%d\n", ERR_TRANSVR_UPDATE_FAIL); - } - /* Return Unit: 1 Volt */ - return _common_count_voltage(self->curr_voltage[0], - self->curr_voltage[1], - buf_p); -} - - -int -qsfp_get_transvr_tx_eq(struct transvr_obj_s *self, - char *buf_p) { - - int limt = 8; - int err = DEBUG_TRANSVR_INT_VAL; - - err = _check_by_mode(self, - &_qsfp_update_attr_tx_eq, - "qsfp_get_transvr_tx_eq"); - if (err < 0) { - return snprintf(buf_p, limt, "%d\n", err); - } - if ((self->tx_eq[0]) == DEBUG_TRANSVR_HEX_VAL) { - return snprintf(buf_p, limt, "%d\n", ERR_TRANSVR_UPDATE_FAIL); - } - return snprintf(buf_p, limt, "0x%02x%02x\n", - self->tx_eq[0], self->tx_eq[1]); -} - - -int -qsfp_get_transvr_rx_am(struct transvr_obj_s *self, - char *buf_p) { - - int limt = 8; - int err = DEBUG_TRANSVR_INT_VAL; - - err = _check_by_mode(self, - &_qsfp_update_attr_rx_am, - "qsfp_get_transvr_rx_am"); - if (err < 0) { - return snprintf(buf_p, limt, "%d\n", err); - } - if ((self->rx_am[0]) == DEBUG_TRANSVR_HEX_VAL) { - return snprintf(buf_p, limt, "%d\n", ERR_TRANSVR_UPDATE_FAIL); - } - return snprintf(buf_p, limt, "0x%02x%02x\n", - self->rx_am[0], self->rx_am[1]); -} - - -int -qsfp_get_transvr_rx_em(struct transvr_obj_s *self, - char *buf_p) { - - int limt = 8; - int err = DEBUG_TRANSVR_INT_VAL; - - err = _check_by_mode(self, - &_qsfp_update_attr_rx_em, - "qsfp_get_transvr_rx_em"); - if (err < 0) { - return snprintf(buf_p, limt, "%d\n", err); - } - if ((self->rx_em[0]) == DEBUG_TRANSVR_HEX_VAL) { - return snprintf(buf_p, limt, "%d\n", ERR_TRANSVR_UPDATE_FAIL); - } - return snprintf(buf_p, limt, "0x%02x%02x\n", - self->rx_em[0], self->rx_em[1]); -} - - -int -_qsfp_get_channel_diag(uint8_t *data_array, - int (*count_func)(uint8_t high_byte, uint8_t low_byte, char *buf_p), - char *ch_name, - char *result_p) { - int i, high, low; - int len_max = 128; - char ch_buf[4][16] = { DEBUG_TRANSVR_STR_VAL, - DEBUG_TRANSVR_STR_VAL, - DEBUG_TRANSVR_STR_VAL, - DEBUG_TRANSVR_STR_VAL }; - - for (i=0; i<4; i++) { - high = (i*2); - low = ((i*2) + 1); - count_func(data_array[high], data_array[low], ch_buf[i]); - } - return snprintf(result_p, len_max, - "%s-%d:%s%s-%d:%s%s-%d:%s%s-%d:%s", - ch_name, 1, ch_buf[0], - ch_name, 2, ch_buf[1], - ch_name, 3, ch_buf[2], - ch_name, 4, ch_buf[3]); -} - - -int -qsfp_get_soft_rx_los(struct transvr_obj_s *self, - char *buf_p) { - - int lmax = 8; - int mask = 0x0f; /* Bit 0 ~ Bit 3 */ - int err_code = DEBUG_TRANSVR_INT_VAL; - - err_code = _check_by_mode(self, - &_qsfp_update_attr_soft_rx_los, - "qsfp_get_soft_rx_los"); - if (err_code < 0) { - return snprintf(buf_p, lmax, "%d\n", err_code); - } - return snprintf(buf_p, lmax, "0x%02x\n", (self->rx_los & mask)); -} - - -int -qsfp_get_soft_tx_disable(struct transvr_obj_s *self, - char *buf_p) { - - int lmax = 8; - int mask = 0x0f; /* Bit 0 ~ Bit 3 */ - int err_code = DEBUG_TRANSVR_INT_VAL; - - err_code = _check_by_mode(self, - &_qsfp_update_attr_soft_tx_disable, - "qsfp_get_soft_tx_disable"); - if (err_code < 0) { - return snprintf(buf_p, lmax, "%d\n", err_code); - } - return snprintf(buf_p, lmax, "0x%02x\n", (self->tx_disable & mask)); -} - - -int -qsfp_get_soft_tx_fault(struct transvr_obj_s *self, - char *buf_p) { - - int lmax = 8; - int mask = 0x0f; /* Bit 0 ~ Bit 3 */ - int err_code = DEBUG_TRANSVR_INT_VAL; - - err_code = _check_by_mode(self, - &_qsfp_update_attr_soft_tx_fault, - "qsfp_get_soft_tx_fault"); - if (err_code < 0) { - return snprintf(buf_p, lmax, "%d\n", err_code); - } - return snprintf(buf_p, lmax, "0x%02x\n", (self->tx_fault & mask)); -} - - -int -qsfp_get_auto_tx_disable(struct transvr_obj_s *self, - char *buf_p) { - - if (self->auto_tx_disable == VAL_TRANSVR_FUNCTION_DISABLE) { - return snprintf(buf_p, LEN_TRANSVR_S_STR, - "%d\n", ERR_TRANSVR_FUNC_DISABLE); - } - return snprintf(buf_p, LEN_TRANSVR_S_STR, - "0x%02x\n", self->auto_tx_disable); -} - - -int -qsfp_get_transvr_tx_bias(struct transvr_obj_s *self, - char *buf_p) { - - int lmax = 8; - int err_code = DEBUG_TRANSVR_INT_VAL; - char *ch_name = "TX"; - - err_code = _check_by_mode(self, - &_qsfp_update_attr_curr_tx_bias, - "qsfp_get_transvr_tx_bias"); - if (err_code < 0) { - return snprintf(buf_p, lmax, "%d\n", err_code); - } - if ((self->curr_tx_bias[0]) == DEBUG_TRANSVR_HEX_VAL) { - return snprintf(buf_p, lmax, "%d\n", ERR_TRANSVR_UPDATE_FAIL); - } - /* Return Unit: 1 mA */ - return _qsfp_get_channel_diag(self->curr_tx_bias, - _common_count_tx_bias, - ch_name, - buf_p); -} - - -int -qsfp_get_transvr_tx_power(struct transvr_obj_s *self, - char *buf_p) { - - int lmax = 8; - int err_code = DEBUG_TRANSVR_INT_VAL; - char *ch_name = "TX"; - - err_code = _check_by_mode(self, - &_qsfp_update_attr_curr_tx_power, - "qsfp_get_transvr_tx_power"); - if (err_code < 0) { - return snprintf(buf_p, lmax, "%d\n", err_code); - } - if ((self->curr_tx_power[0]) == DEBUG_TRANSVR_HEX_VAL) { - return snprintf(buf_p, lmax, "%d\n", ERR_TRANSVR_UPDATE_FAIL); - } - /* Return Unit: 1 mW */ - return _qsfp_get_channel_diag(self->curr_tx_power, - _common_count_tx_power, - ch_name, - buf_p); -} - - -int -qsfp_get_transvr_rx_power(struct transvr_obj_s *self, - char *buf_p) { - - int lmax = 8; - int err_code = DEBUG_TRANSVR_INT_VAL; - char *ch_name = "RX"; - - err_code = _check_by_mode(self, - &_qsfp_update_attr_curr_rx_power, - "qsfp_get_transvr_rx_power"); - if (err_code < 0) { - return snprintf(buf_p, lmax, "%d\n", err_code); - } - if ((self->curr_tx_power[0]) == DEBUG_TRANSVR_HEX_VAL) { - return snprintf(buf_p, lmax, "%d\n", ERR_TRANSVR_UPDATE_FAIL); - } - /* Return Unit: 1 mW */ - return _qsfp_get_channel_diag(self->curr_rx_power, - _common_count_rx_power, - ch_name, - buf_p); -} - - -int -qsfp_get_wavelength(struct transvr_obj_s *self, - char *buf_p) { - /* [Desc] Wavelength or Copper Cable Attenuation (SFF-8636) - * [Addr] 00h 186-187 - * [Note] - * For optical free side devices, this parameter identifies the nominal - * transmitter output wavelength at room temperature. This parameter is - * a 16-bit hex value with Byte 186 as high order byte and Byte 187 as - * low order byte. The laser wavelength is equal to the 16-bit integer value - * divided by 20 in nm (units of 0.05 nm). This resolution should be adequate - * to cover all relevant wavelengths yet provide enough resolution for all - * expected DWDM applications. For accurate representation of controlled - * wavelength applications, this value should represent the center of the - * guaranteed wavelength range. - * If the free side device is identified as copper cable these registers will - * be used to define the cable attenuation. An indication of 0 dB attenuation - * refers to the case where the attenuation is not known or is unavailable. - * Byte 186 (00-FFh) is the copper cable attenuation at 2.5 GHz in units of 1 dB. - * Byte 187 (00-FFh) is the copper cable attenuation at 5.0 GHz in units of 1 dB. - */ - int lmax = 8; - int err_code = DEBUG_TRANSVR_INT_VAL; - - err_code = _check_by_mode(self, - &_common_update_attr_wavelength, - "common_get_wavelength"); - if (err_code < 0) { - return snprintf(buf_p, lmax, "%d\n", err_code); - } - if ((self->wavelength[0]) == DEBUG_TRANSVR_HEX_VAL) { - return snprintf(buf_p, lmax, "%d\n", ERR_TRANSVR_UPDATE_FAIL); - } - /* unit: 1 um */ - return snprintf(buf_p, lmax, "%d\n", - _common_count_wavelength(self, - self->wavelength[0], - self->wavelength[1])); -} - - -/* Public Function for Setup Features - */ -static int -__sfp_set_soft_rs(struct transvr_obj_s *self, - int input_val, - int address, - int page, - int offset, - int bit_shift, - uint8_t *attr_p, - char *caller, - int show_err) { - - int retval = ERR_TRANSVR_UNEXCPT; - int err_code = ERR_TRANSVR_UNEXCPT; - char *err_msg = DEBUG_TRANSVR_STR_VAL; - uint8_t update_val = (*attr_p); - - switch (input_val) { - case 0: - SWP_BIT_CLEAR(update_val, bit_shift); - break; - case 1: - SWP_BIT_SET(update_val, bit_shift); - break; - default: - retval = ERR_TRANSVR_UNEXCPT; - err_code = ERR_TRANSVR_UNEXCPT; - err_msg = "Exception occurs"; - goto err_private_sfp_set_soft_rs_1; - } - err_code = _common_set_uint8_attr(self, - address, - page, - offset, - update_val, - attr_p, - caller, - show_err); - if (err_code < 0) { - retval = err_code; - err_msg = "Write data via i2c fail!"; - goto err_private_sfp_set_soft_rs_1; - } - (*attr_p) = update_val; - return 0; - -err_private_sfp_set_soft_rs_1: - if (show_err) { - SWPS_INFO("%s: %s :%d :%s\n :%d\n", - __func__, err_msg, err_code, self->swp_name, input_val); - } - return retval; -} - - -static int -_sfp_set_soft_rs(struct transvr_obj_s *self, - int input_val, - int address, - int page, - int offset, - int bit_shift, - int (*attr_update_func)(struct transvr_obj_s *self, int show_err), - uint8_t *attr_p, - char *caller, - int show_err) { - - int retval = ERR_TRANSVR_UNEXCPT; - int err_code = ERR_TRANSVR_UNEXCPT; - char *err_msg = DEBUG_TRANSVR_STR_VAL; - - /* Check input value */ - if ((input_val != 0) && (input_val != 1)){ - retval = ERR_TRANSVR_BADINPUT; - err_code = ERR_TRANSVR_BADINPUT; - err_msg = "Input range incorrect!"; - goto err_common_sfp_set_soft_rs_1; - } - /* Check rate identifier is supported */ - err_code = self->get_rate_id(self); - if (err_code <= 0) { - switch (err_code) { - case 0: - retval = ERR_TRANSVR_NOTSUPPORT; - err_msg = "Not support this feature"; - break; - case ERR_TRANSVR_UNINIT: - retval = ERR_TRANSVR_UNINIT; - err_msg = "Check CDR present fail!"; - break; - case ERR_TRANSVR_UNPLUGGED: - retval = ERR_TRANSVR_UNPLUGGED; - err_msg = "Transceiver unplugged!"; - break; - default: - retval = err_code; - err_msg = "Check Rate_ID fail!"; - break; - } - goto err_common_sfp_set_soft_rs_1; - } - /* Check and update */ - err_code = _check_by_mode(self, - attr_update_func, - caller); - if ( (err_code < 0) || - ((*attr_p) == DEBUG_TRANSVR_HEX_VAL) ){ - retval = err_code; - err_msg = "Get current value fail!"; - goto err_common_sfp_set_soft_rs_1; - } - /* Generate and update value */ - return __sfp_set_soft_rs(self, - input_val, - address, - page, - offset, - bit_shift, - attr_p, - caller, - show_err); - -err_common_sfp_set_soft_rs_1: - if (show_err) { - SWPS_INFO("%s: %s :%d :%s\n :%d\n", - __func__, err_msg, err_code, self->swp_name, input_val); - } - return retval; -} - - -int -sfp_set_soft_rs0(struct transvr_obj_s *self, - int input_val) { - /* Note: - * SFP Soft Rate_Select Select RX ["RS(0)"] address - * A2h, offset: 110, bit 3 - */ - int bit_shift = 3; - int show_err = 1; - return _sfp_set_soft_rs(self, - input_val, - self->eeprom_map_p->addr_soft_rs0, - self->eeprom_map_p->page_soft_rs0, - self->eeprom_map_p->offset_soft_rs0, - bit_shift, - &_sfp_update_attr_soft_rs0, - &(self->soft_rs0), - "sfp_set_soft_rs0", - show_err); -} - - -int -sfp_set_soft_rs1(struct transvr_obj_s *self, - int input_val) { - /* Note: - * SFP Soft Rate_Select Select RX ["RS(1)"] address - * A2h, offset: 118, bit 3 - */ - int bit_shift = 3; - int show_err = 1; - return _sfp_set_soft_rs(self, - input_val, - self->eeprom_map_p->addr_soft_rs1, - self->eeprom_map_p->page_soft_rs1, - self->eeprom_map_p->offset_soft_rs1, - bit_shift, - &_sfp_update_attr_soft_rs1, - &(self->soft_rs1), - "sfp_set_soft_rs1", - show_err); -} - - -int -__sfp_set_tx_eq(struct transvr_obj_s *self, - int input, - int show_e) { - - int err = DEBUG_TRANSVR_INT_VAL; - char *emsg = DEBUG_TRANSVR_STR_VAL; - uint8_t setv = DEBUG_TRANSVR_HEX_VAL; - - if ((input < 0) || (input > 0xFF)) { - emsg = "input incorrect"; - err = ERR_TRANSVR_BADINPUT; - goto err_sfp_set_tx_eq; - } - setv = (uint8_t)input; - if (self->tx_eq[0] == setv) { - return 0; - } - err = _common_set_uint8_attr(self, - self->eeprom_map_p->addr_tx_eq, - self->eeprom_map_p->page_tx_eq, - self->eeprom_map_p->offset_tx_eq, - setv, - &(self->tx_eq[0]), - "_sfp_set_tx_eq", - show_e); - if (err < 0) { - emsg = "set_uint8_attr fail"; - goto err_sfp_set_tx_eq; - } - return 0; - -err_sfp_set_tx_eq: - if (show_e) { - SWPS_INFO("%s: %s :%d\n", __func__, emsg, input); - } - return err; -} - - -int -_sfp_set_tx_eq(struct transvr_obj_s *self, - int input, - int show_e) { - - uint8_t tmp; - int i = 0; - int retry = 3; - - for (i=0; itx_eq[0]; - if (_sfp_update_attr_tx_eq(self, show_e) < 0){ - continue; - } - if (self->tx_eq[0] == tmp){ - return 0; - } - } - return ERR_TRANSVR_UPDATE_FAIL; -} - - -int -sfp_set_tx_eq(struct transvr_obj_s *self, - int input) { - - int err = _check_by_mode(self, - &_sfp_update_attr_tx_eq, - "sfp_set_tx_eq"); - if (err < 0) { - SWPS_DEBUG("%s: check fail :%d\n", __func__, err); - return err; - } - return _sfp_set_tx_eq(self, input, 1); -} - - -int -__sfp_set_rx_em(struct transvr_obj_s *self, - int input, - int show_e) { - - int err = DEBUG_TRANSVR_INT_VAL; - char *emsg = DEBUG_TRANSVR_STR_VAL; - uint8_t setv = DEBUG_TRANSVR_HEX_VAL; - - if ((input < 0) || (input > 0xFF)) { - emsg = "input incorrect"; - err = ERR_TRANSVR_BADINPUT; - goto err_sfp_set_rx_em; - } - setv = (uint8_t)input; - if (self->rx_em[0] == setv) { - return 0; - } - err = _common_set_uint8_attr(self, - self->eeprom_map_p->addr_rx_em, - self->eeprom_map_p->page_rx_em, - self->eeprom_map_p->offset_rx_em, - setv, - &(self->rx_em[0]), - "_sfp_set_rx_em", - show_e); - if (err < 0) { - emsg = "set_uint8_attr fail"; - goto err_sfp_set_rx_em; - } - return 0; - -err_sfp_set_rx_em: - if (show_e) { - SWPS_INFO("%s: %s :%d\n", __func__, emsg, input); - } - return err; -} - - -int -_sfp_set_rx_em(struct transvr_obj_s *self, - int input, - int show_e) { - - uint8_t tmp; - int i = 0; - int retry = 3; - - for (i=0; irx_em[0]; - if (_sfp_update_attr_rx_em(self, show_e) < 0){ - continue; - } - if (self->rx_em[0] == tmp){ - return 0; - } - } - return -1; -} - - -int -sfp_set_rx_em(struct transvr_obj_s *self, - int input) { - - int err = _check_by_mode(self, - &_sfp_update_attr_rx_em, - "sfp_set_rx_em"); - if (err < 0) { - SWPS_DEBUG("%s: check fail :%d\n", __func__, err); - return err; - } - return _sfp_set_rx_em(self, input, 1); -} - - -int -sfp_set_1g_rj45_extphy_offset(struct transvr_obj_s *self, - int input) { - - if (self->state != STATE_TRANSVR_CONNECTED) { - return ERR_TRANSVR_UNPLUGGED; - } - if ((self->info != TRANSVR_CLASS_BASE_T_1000) && - (self->info != TRANSVR_CLASS_BASE_T_1000_up) ){ - return ERR_TRANSVR_NOTSUPPORT; - } - if ((input < 0) || (input > 0xff)) { - return ERR_TRANSVR_BADINPUT; - } - self->extphy_offset = (uint8_t)input; - return 0; -} - - -int -sfp_set_1g_rj45_extphy_reg(struct transvr_obj_s *self, - int input) { - - int i = 0; - int retry = 3; - int delay = 200; - uint16_t tmp = 0; - - if (self->state != STATE_TRANSVR_CONNECTED) { - return ERR_TRANSVR_UNPLUGGED; - } - if ((self->info != TRANSVR_CLASS_BASE_T_1000) && - (self->info != TRANSVR_CLASS_BASE_T_1000_up) ){ - return ERR_TRANSVR_NOTSUPPORT; - } - if ((input < 0) || (input > 0xffff)) { - return ERR_TRANSVR_BADINPUT; - } - tmp = ((input & 0x00ff) << 8) | ((input & 0xff00) >> 8); - if (_common_setup_page(self, VAL_TRANSVR_EXTPHY_ADDR_56, - -1, self->extphy_offset, 1, 0) < 0) { - return -EIO; - } - for (i=0; i<=retry; i++) { - if (i2c_smbus_write_word_data(self->i2c_client_p, - self->extphy_offset, - tmp) >= 0) { - return 0; - } - msleep(delay); - } - SWPS_INFO("%s: retry:%d fail :%s :0x%02x\n", - __func__, retry, self->swp_name, self->extphy_offset); - return -EIO; -} - - -static int -__qsfp_set_cdr(struct transvr_obj_s *self, - int input_val, - int show_err) { - - uint8_t update_val; - int CDR_FEATURE_SUPPORTED = 0x3; - int retval = ERR_TRANSVR_UNEXCPT; - int err_code = ERR_TRANSVR_UNEXCPT; - char *err_msg = DEBUG_TRANSVR_STR_VAL; - char *func_name = "__qsfp_set_cdr"; - - /* Check input value */ - if ((input_val < 0) || (input_val > 0xff)){ - retval = ERR_TRANSVR_BADINPUT; - err_code = ERR_TRANSVR_BADINPUT; - err_msg = "Input range incorrect!"; - goto err_qsfp_set_cdr_1; - } - update_val = (uint8_t)input_val; - /* Check CDR supported by transceiver */ - err_code = qsfp_get_cdr_present(self); - if (err_code < 0) { - retval = err_code; - switch (err_code) { - case ERR_TRANSVR_UNINIT: - err_msg = "Check CDR present fail!"; - break; - case ERR_TRANSVR_UNPLUGGED: - err_msg = "Transceiver unplugged!"; - break; - default: - err_msg = "Check CDR present fail!"; - break; - } - goto err_qsfp_set_cdr_1; - } - if (err_code != CDR_FEATURE_SUPPORTED) { - retval = ERR_TRANSVR_NOTSUPPORT; - err_msg = "This transceiver not support CDR!"; - goto err_qsfp_set_cdr_1; - } - /* Check and update */ - err_code = _check_by_mode(self, - &_qsfp_update_attr_cdr, - func_name); - if ( (err_code < 0) || - (self->cdr == DEBUG_TRANSVR_HEX_VAL) ){ - retval = err_code; - err_msg = "Get current value fail!"; - goto err_qsfp_set_cdr_1; - } - /* Write input value to transceiver */ - return _common_set_uint8_attr(self, - self->eeprom_map_p->addr_cdr, - self->eeprom_map_p->page_cdr, - self->eeprom_map_p->offset_cdr, - update_val, - &(self->cdr), - func_name, - show_err); - -err_qsfp_set_cdr_1: - if (show_err) { - SWPS_INFO("%s: %s :%d :%s\n :%d\n", - __func__, err_msg, err_code, self->swp_name, input_val); - } - return retval; -} - - -int -qsfp_set_cdr(struct transvr_obj_s *self, - int input_val) { - return __qsfp_set_cdr(self, input_val, 1); -} - - -int -qsfp_set_soft_tx_disable(struct transvr_obj_s *self, - int input_val) { - - int show_err = 1; - int in_max = 0xf; /* 1111 */ - int in_min = 0x0; /* 0000 */ - int retval = DEBUG_TRANSVR_INT_VAL; - int update_val = DEBUG_TRANSVR_INT_VAL; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - - retval = _check_by_mode(self, - &_qsfp_update_attr_soft_tx_disable, - "qsfp_set_soft_tx_disable"); - if (retval < 0) { - snprintf(err_msg, 63, "Not ready. err:%d", retval); - goto err_qsfp_set_soft_tx_disable; - } - if ((input_val > in_max) || - (input_val < in_min) ){ - retval = ERR_TRANSVR_BADINPUT; - snprintf(err_msg, 63, "Input value:%d incorrect!", input_val); - goto err_qsfp_set_soft_tx_disable; - } - if ((self->tx_disable & 0x0f) == input_val) { - return 0; - } - update_val = ((self->tx_disable & 0xf0) & input_val); - retval = _common_set_uint8_attr(self, - self->eeprom_map_p->addr_tx_disable, - self->eeprom_map_p->page_tx_disable, - self->eeprom_map_p->offset_tx_disable, - input_val, - &(self->tx_disable), - "qsfp_set_tx_disable", - show_err); - if (retval < 0) { - snprintf(err_msg, 63, "_common_set_uint8_attr:%d fail!", retval); - goto err_qsfp_set_soft_tx_disable; - } - return 0; - -err_qsfp_set_soft_tx_disable: - SWPS_INFO("%s: %s :%s\n", __func__, err_msg, self->swp_name); - return retval; -} - - -int -_qsfp_set_auto_tx_disable(struct transvr_obj_s *self, - uint8_t update) { - - uint8_t tx_enable = 0x0; - int show_e = 1; - int err = DEBUG_TRANSVR_INT_VAL; - char *emsg = DEBUG_TRANSVR_STR_VAL; - - /* Handle timing issues */ - if (update != tx_enable) { - /* Note: - * Because there are some txvr has timing issues, - * therefore we need to execute reset cycle first. - * (enable -> other settings) - */ - err = _common_set_uint8_attr(self, - self->eeprom_map_p->addr_tx_disable, - self->eeprom_map_p->page_tx_disable, - self->eeprom_map_p->offset_tx_disable, - tx_enable, - &(self->tx_disable), - "_qsfp_set_auto_tx_disable", - show_e); - if (err < 0) { - emsg = "I2C set reset value fail"; - goto err_qsfp_set_auto_tx_disable; - } - mdelay(10); - } - /* Setup target value */ - err = _common_set_uint8_attr(self, - self->eeprom_map_p->addr_tx_disable, - self->eeprom_map_p->page_tx_disable, - self->eeprom_map_p->offset_tx_disable, - self->auto_tx_disable, - &(self->tx_disable), - "_qsfp_set_auto_tx_disable", - show_e); - if (err < 0) { - emsg = "I2C set target value fail"; - goto err_qsfp_set_auto_tx_disable; - } - /* Check and update */ - err = _common_update_uint8_attr(self, - self->eeprom_map_p->addr_tx_disable, - self->eeprom_map_p->page_tx_disable, - self->eeprom_map_p->offset_tx_disable, - self->eeprom_map_p->length_tx_disable, - &(self->tx_disable), - "_qsfp_set_auto_tx_disable", - show_e); - if (err < 0) { - emsg = "I2C get value fail"; - goto err_qsfp_set_auto_tx_disable; - } - if (self->tx_disable != update) { - emsg = "data not become effective"; - goto err_qsfp_set_auto_tx_disable; - } - return 0; - -err_qsfp_set_auto_tx_disable: - SWPS_DEBUG("%s: %s :%s\n", - __func__, emsg, self->swp_name); - return ERR_TRANSVR_UPDATE_FAIL; -} - - -int -qsfp_set_auto_tx_disable(struct transvr_obj_s *self, - int input_val) { - - int in_max = 0xf; /* 1111 */ - int in_min = 0x0; /* 0000 */ - int retval = DEBUG_TRANSVR_INT_VAL; - char *emsg = DEBUG_TRANSVR_STR_VAL; - - /* Update settings*/ - if (input_val == VAL_TRANSVR_FUNCTION_DISABLE) { - emsg = "User disable auto tx_disable"; - self->auto_tx_disable = VAL_TRANSVR_FUNCTION_DISABLE; - goto out_qsfp_set_auto_tx_disable; - } - if ((input_val > in_max) || (input_val < in_min) ){ - SWPS_INFO("%s: Input value:%d incorrect! :%s\n", - __func__, input_val, self->swp_name); - return ERR_TRANSVR_BADINPUT; - } - self->auto_tx_disable = input_val; - /* Check current soft tx_disable */ - retval = _check_by_mode(self, - &_qsfp_update_attr_soft_tx_disable, - "qsfp_set_auto_tx_disable"); - switch (retval) { - case 0: - break; - case ERR_TRANSVR_UNPLUGGED: - emsg = "Doesn't need to update"; - goto out_qsfp_set_auto_tx_disable; - default: - SWPS_INFO("%s: setup fail :%d :%s\n", - __func__, retval, self->swp_name); - return retval; - } - return _qsfp_set_auto_tx_disable(self, input_val); - -out_qsfp_set_auto_tx_disable: - SWPS_DEBUG("%s: %s :%s :%d\n :%d", - __func__, emsg, self->swp_name, input_val, retval); - return 0; -} - - -int -__qsfp_set_tx_eq(struct transvr_obj_s *self, - int input, - int show_e) { - /* [Note] - * 0x - */ - int err = DEBUG_TRANSVR_INT_VAL; - char *emsg = DEBUG_TRANSVR_STR_VAL; - uint8_t setv[2] = {0x00, 0x00}; - - if ((input < 0) || (input > 0xFFFF)) { - emsg = "input incorrect"; - err = ERR_TRANSVR_BADINPUT; - goto err_qsfp_set_tx_eq; - } - setv[0] = (uint8_t)((input & 0xFF00) >> 8); - setv[1] = (uint8_t)(input & 0xFF); - if ((self->tx_eq[0] == setv[0]) && - (self->tx_eq[1] == setv[1]) ) { - return 0; - } - err = _common_set_uint8_array(self, - self->eeprom_map_p->addr_tx_eq, - self->eeprom_map_p->page_tx_eq, - self->eeprom_map_p->offset_tx_eq, - self->eeprom_map_p->length_tx_eq, - setv, - self->tx_eq, - "_qsfp_set_tx_eq", - show_e); - if (err < 0) { - emsg = "set_uint8_array fail"; - goto err_qsfp_set_tx_eq; - } - return 0; - -err_qsfp_set_tx_eq: - if (show_e) { - SWPS_INFO("%s: %s :%d\n", __func__, emsg, input); - } - return err; -} - - -int -_qsfp_set_tx_eq(struct transvr_obj_s *self, - int input, - int show_e) { - - int i = 0; - int retry = 3; - uint8_t tmp[2]; - - for (i=0; itx_eq[0]; - tmp[1] = self->tx_eq[1]; - if (_qsfp_update_attr_tx_eq(self, show_e) < 0){ - continue; - } - if ((self->tx_eq[0] == tmp[0]) && - (self->tx_eq[1] == tmp[1]) ){ - return 0; - } - } - return -1; -} - - -int -qsfp_set_tx_eq(struct transvr_obj_s *self, - int input) { - - int err = _check_by_mode(self, - &_qsfp_update_attr_tx_eq, - "qsfp_set_tx_eq"); - if (err < 0) { - SWPS_DEBUG("%s: check fail :%d\n", __func__, err); - return err; - } - return _qsfp_set_tx_eq(self, input, 1); -} - - -int -__qsfp_set_rx_am(struct transvr_obj_s *self, - int input, - int show_e) { - /* [Note] - * 0x - */ - int err = DEBUG_TRANSVR_INT_VAL; - char *emsg = DEBUG_TRANSVR_STR_VAL; - uint8_t setv[2] = {0x00, 0x00}; - - if ((input < 0) || (input > 0xFFFF)) { - emsg = "input incorrect"; - err = ERR_TRANSVR_BADINPUT; - goto err_qsfp_set_rx_am; - } - setv[0] = (uint8_t)((input & 0xFF00) >> 8); - setv[1] = (uint8_t)(input & 0xFF); - if ((self->rx_am[0] == setv[0]) && - (self->rx_am[1] == setv[1]) ) { - return 0; - } - err = _common_set_uint8_array(self, - self->eeprom_map_p->addr_rx_am, - self->eeprom_map_p->page_rx_am, - self->eeprom_map_p->offset_rx_am, - self->eeprom_map_p->length_rx_am, - setv, - self->rx_am, - "_qsfp_set_rx_am", - show_e); - if (err < 0) { - emsg = "set_uint8_array fail"; - goto err_qsfp_set_rx_am; - } - return 0; - -err_qsfp_set_rx_am: - if (show_e) { - SWPS_INFO("%s: %s :%d\n", __func__, emsg, input); - } - return err; -} - - -int -_qsfp_set_rx_am(struct transvr_obj_s *self, - int input, - int show_e) { - - int i = 0; - int retry = 3; - uint8_t tmp[2]; - - for (i=0; irx_am[0]; - tmp[1] = self->rx_am[1]; - if (_qsfp_update_attr_rx_am(self, show_e) < 0){ - continue; - } - if ((self->rx_am[0] == tmp[0]) && - (self->rx_am[1] == tmp[1]) ){ - return 0; - } - } - return -1; -} - - -int -qsfp_set_rx_am(struct transvr_obj_s *self, - int input) { - - int err = _check_by_mode(self, - &_qsfp_update_attr_rx_am, - "qsfp_set_rx_am"); - if (err < 0) { - SWPS_DEBUG("%s: check fail :%d\n", __func__, err); - return err; - } - return _qsfp_set_rx_am(self, input, 1); -} - - -int -__qsfp_set_rx_em(struct transvr_obj_s *self, - int input, - int show_e) { - /* [Note] - * 0x - */ - int err = DEBUG_TRANSVR_INT_VAL; - char *emsg = DEBUG_TRANSVR_STR_VAL; - uint8_t setv[2] = {0x00, 0x00}; - - if ((input < 0) || (input > 0xFFFF)) { - emsg = "input incorrect"; - err = ERR_TRANSVR_BADINPUT; - goto err_qsfp_set_rx_em; - } - setv[0] = (uint8_t)((input & 0xFF00) >> 8); - setv[1] = (uint8_t)(input & 0xFF); - if ((self->rx_em[0] == setv[0]) && - (self->rx_em[1] == setv[1]) ) { - return 0; - } - err = _common_set_uint8_array(self, - self->eeprom_map_p->addr_rx_em, - self->eeprom_map_p->page_rx_em, - self->eeprom_map_p->offset_rx_em, - self->eeprom_map_p->length_rx_em, - setv, - self->rx_em, - "_qsfp_set_rx_em", - show_e); - if (err < 0) { - emsg = "set_uint8_array fail"; - goto err_qsfp_set_rx_em; - } - return 0; - -err_qsfp_set_rx_em: - if (show_e) { - SWPS_INFO("%s: %s :%d\n", __func__, emsg, input); - } - return err; -} - - -int -_qsfp_set_rx_em(struct transvr_obj_s *self, - int input, - int show_e) { - - int i = 0; - int retry = 3; - uint8_t tmp[2]; - - for (i=0; irx_em[0]; - tmp[1] = self->rx_em[1]; - if (_qsfp_update_attr_rx_em(self, show_e) < 0){ - continue; - } - if ((self->rx_em[0] == tmp[0]) && - (self->rx_em[1] == tmp[1]) ){ - return 0; - } - } - return -1; -} - - -int -qsfp_set_rx_em(struct transvr_obj_s *self, - int input) { - - int err = _check_by_mode(self, - &_qsfp_update_attr_rx_em, - "qsfp_set_rx_em"); - if (err < 0) { - SWPS_DEBUG("%s: check fail :%d\n", __func__, err); - return err; - } - return _qsfp_set_rx_em(self, input, 1); -} - - -int -common_transvr_dump(struct transvr_obj_s* self){ - - char *type_name = "Undefined"; - - if (TRANSVR_INFO_DUMP_ENABLE != 1) { - return 0; - } - switch (self->type) { - case TRANSVR_TYPE_SFP: - type_name = STR_TRANSVR_SFP; - break; - case TRANSVR_TYPE_QSFP: - type_name = STR_TRANSVR_QSFP; - break; - case TRANSVR_TYPE_QSFP_PLUS: - type_name = STR_TRANSVR_QSFP_PLUS; - break; - case TRANSVR_TYPE_QSFP_28: - type_name = STR_TRANSVR_QSFP28; - break; - case TRANSVR_TYPE_FAKE: - type_name = "FAKE"; - goto ok_common_transvr_dump; - case TRANSVR_TYPE_UNPLUGGED: - type_name = "UNPLUGGED"; - goto err_common_transvr_dump; - case TRANSVR_TYPE_INCONSISTENT: - type_name = "INCONSISTENT"; - goto err_common_transvr_dump; - case TRANSVR_TYPE_ERROR: - type_name = "ERROR"; - goto err_common_transvr_dump; - - default: - type_name = "UNEXPECTED"; - goto err_common_transvr_dump; - } - printk(KERN_INFO "[SWPS] Dump %s information:\n", self->swp_name); - printk(KERN_INFO " |- :%s\n", type_name); - printk(KERN_INFO " |- :%s\n", self->vendor_name); - printk(KERN_INFO " |- :%s\n", self->vendor_pn); - printk(KERN_INFO " |- :%s\n", self->vendor_rev); - printk(KERN_INFO " |- :%s\n", self->vendor_sn); - printk(KERN_INFO " |- :0x%02x\n", self->br); - printk(KERN_INFO " |- :0x%02x\n", self->comp_rev); - printk(KERN_INFO " |- :%d\n", self->len_om1); - printk(KERN_INFO " |- :%d\n", self->len_om2); - printk(KERN_INFO " |- :%d\n", self->len_om3); - printk(KERN_INFO " |- :%d\n", self->len_om4); - return 0; - -ok_common_transvr_dump: - SWPS_INFO("%s: %s is %s\n", __func__, self->swp_name, type_name); - return 0; - -err_common_transvr_dump: - SWPS_INFO("%s: %s is %s\n", __func__, self->swp_name, type_name); - return -1; -} - - -int -sfp_transvr_dump(struct transvr_obj_s* self) { - - if (TRANSVR_INFO_DUMP_ENABLE != 1) { - return 0; - } - if (common_transvr_dump(self) < 0) { - return -1; - } - printk(KERN_INFO " |- :%d\n", self->len_sm); - printk(KERN_INFO " |- :%d\n", self->len_smf); - printk(KERN_INFO " '- :0x%02x\n", self->rate_id); - return 0; -} - - -int -qsfp_transvr_dump(struct transvr_obj_s* self) { - - if (TRANSVR_INFO_DUMP_ENABLE != 1) { - return 0; - } - if (common_transvr_dump(self) < 0) { - return -1; - } - printk(KERN_INFO " |- :%d\n", self->len_smf); - printk(KERN_INFO " '- :Class_%d\n", __qsfp_get_power_cls(self, 0)); - return 0; -} - - -int -fake_transvr_dump(struct transvr_obj_s* self) { - - printk(KERN_INFO "[SWPS] Dump transceiver information: %s\n", self->swp_name); - printk(KERN_INFO " |- :FAKE\n"); - printk(KERN_INFO " |- :FAKE_VENDER_NAME\n"); - printk(KERN_INFO " |- :FAKE_VENDER_PN\n"); - printk(KERN_INFO " |- :FAKE_VENDER_REV\n"); - printk(KERN_INFO " |- :FAKE_VENDER_SN\n"); - printk(KERN_INFO " |- :0x99\n"); - printk(KERN_INFO " |- :99\n"); - printk(KERN_INFO " |- :99\n"); - printk(KERN_INFO " |- :99\n"); - printk(KERN_INFO " |- :99\n"); - printk(KERN_INFO " |- :99\n"); - printk(KERN_INFO " |- :99\n"); - printk(KERN_INFO " '- :0x99\n"); - return 0; -} - - -/* ========== Object functions for fake type ========== - */ -int -fake_transvr_update(struct transvr_obj_s *self, - int show_err){ - self->state = STATE_TRANSVR_CONNECTED; - return 0; -} - - -int -fake_get_binary(struct transvr_obj_s *self){ - return 1; -} - -int -fake_get_int(struct transvr_obj_s *self){ - return 99; -} - - -int -fake_get_hex(struct transvr_obj_s *self){ - return 0x0f; -} - - -int -fake_get_str(struct transvr_obj_s *self, char *buf) { - return snprintf(buf, 16, "fake_get_str\n"); -} - - -int -fake_set_int(struct transvr_obj_s *self, int input){ - SWPS_INFO("%s: %d\n", __func__, input); - return 0; -} - - -int -fake_set_hex(struct transvr_obj_s *self, int input){ - SWPS_INFO("%s: 0x%02x\n", __func__, input); - return 0; -} - - -/* ========== Object functions for unsupported ========== - */ -int -unsupported_get_func(struct transvr_obj_s *self){ - return ERR_TRANSVR_NOTSUPPORT; -} - - -int -unsupported_get_func2(struct transvr_obj_s *self, - char *buf_p) { - int len = snprintf(buf_p, 8, "%d\n", ERR_TRANSVR_NOTSUPPORT); - return len; -} - - -int -unsupported_set_func(struct transvr_obj_s *self, - int input_val){ - return ERR_TRANSVR_NOTSUPPORT; -} - - - -/* ========== Object functions for long term task ========== - * - * [Note] - * SWPS transceiver worker is likely the green-thread (coroutine). - * Due to resource and performance considerations. SWPS run all - * features in one kthread at the same time, and handle by it self. - */ - -/* For Transceiver Task Handling - */ -static struct transvr_worker_s * -transvr_task_get(struct transvr_obj_s *self, - char *func_name) { - - struct transvr_worker_s *curr_p = self->worker_p; - - while(curr_p != NULL){ - if (strcmp((curr_p->func_name), func_name) == 0 ) { - return curr_p; - } - curr_p = curr_p->next_p; - } - return NULL; -} - - -static struct transvr_worker_s* -transvr_task_creat(struct transvr_obj_s *self, - int (*main_task)(struct transvr_worker_s *task), - int (*post_task)(struct transvr_worker_s *task), - char *caller) { - - struct transvr_worker_s *task_p = NULL; - struct transvr_worker_s *curr_p = NULL; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - - /* Check task not exist */ - task_p = transvr_task_get(self, caller); - if (task_p) { - snprintf(err_msg, sizeof(err_msg), "Task already created!"); - goto err_transvr_task_creat; - } - /* Create task worker */ - task_p = kzalloc(sizeof(struct transvr_worker_s), GFP_KERNEL); - if (!task_p){ - snprintf(err_msg, sizeof(err_msg), "kzalloc fail"); - goto err_transvr_task_creat; - } - /* Setup task data */ - task_p->transvr_p = self; - task_p->next_p = NULL; - task_p->trigger_time = 0; - task_p->retry = 1; - task_p->state = STATE_T_TASK_INIT; - task_p->main_task = main_task; - task_p->post_task = post_task; - task_p->p_data = NULL; - snprintf(task_p->func_name, sizeof(task_p->func_name), "%s", caller); - /* Setup Link List */ - if (self->worker_p) { - curr_p = self->worker_p; - while(curr_p->next_p != NULL) { - curr_p = curr_p->next_p; - } - curr_p->next_p = task_p; - task_p->pre_p = curr_p; - } else { - self->worker_p = task_p; - task_p->pre_p = NULL; - } - return task_p; - -err_transvr_task_creat: - SWPS_ERR("%s: %s :%s :%s\n", - __func__, err_msg, caller, self->swp_name); - return NULL; -} - - -static void -transvr_task_free_one(struct transvr_worker_s *task_p){ - - struct transvr_worker_s *pre_p = NULL; - struct transvr_worker_s *next_p = NULL; - - if (task_p) { - pre_p = task_p->pre_p; - next_p = task_p->next_p; - - if ((pre_p) && (next_p)) { - pre_p->next_p = next_p; - next_p->pre_p = pre_p; - - } else if ((!pre_p) && (next_p)) { - next_p->pre_p = NULL; - - } else if ((pre_p) && (!next_p)) { - pre_p->next_p = NULL; - - } else if ((!pre_p) && (!next_p)) { - task_p->transvr_p->worker_p = NULL; - } else { - SWPS_ERR("%s: Unexcept case!\n :%s", - __func__, task_p->transvr_p->swp_name); - } - kfree(task_p->p_data); - kfree(task_p); - } -} - - -static void -transvr_task_free_all(struct transvr_obj_s *self) { - - struct transvr_worker_s *curr_p = NULL; - struct transvr_worker_s *next_p = NULL; - - if (self->worker_p) { - curr_p = self->worker_p; - while(curr_p) { - next_p = curr_p->next_p; - transvr_task_free_one(curr_p); - curr_p = next_p; - } - self->worker_p = NULL; - } -} - - -static void -transvr_cache_free_all(struct transvr_obj_s *self) { - - memset(self->vendor_name, 0, (LEN_TRANSVR_M_STR * sizeof(char)) ); - memset(self->vendor_rev, 0, (LEN_TRANSVR_M_STR * sizeof(char)) ); - memset(self->vendor_pn, 0, (LEN_TRANSVR_M_STR * sizeof(char)) ); - memset(self->vendor_sn, 0, (LEN_TRANSVR_M_STR * sizeof(char)) ); - self->extphy_offset = 0; -} - -static int -_transvr_task_run_main(struct transvr_worker_s *task_p) { - - int retval = DEBUG_TRANSVR_INT_VAL; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - - if (!task_p){ - snprintf(err_msg, sizeof(err_msg), "main_task is NULL!"); - goto main_transvr_task_err; - } - if ((task_p->trigger_time) == 0){ - goto main_transvr_task_run; - } - if (time_before(jiffies, task_p->trigger_time)){ - goto main_transvr_task_wait; - } - goto main_transvr_task_run; - -main_transvr_task_run: - if (task_p->retry != VAL_TRANSVR_TASK_RETRY_FOREVER) { - task_p->retry -= 1; - } - retval = task_p->main_task(task_p); - if (retval < 0) { - if (task_p->retry > 0) { - task_p->state = STATE_T_TASK_WAIT; - return EVENT_TRANSVR_TASK_WAIT; - } - snprintf(err_msg, sizeof(err_msg), "Run main_task fail!"); - goto main_transvr_task_err; - } - goto main_transvr_task_identify; - -main_transvr_task_identify: - switch (retval) { - case EVENT_TRANSVR_TASK_WAIT: - task_p->state = STATE_T_TASK_WAIT; - return EVENT_TRANSVR_TASK_WAIT; - - case EVENT_TRANSVR_TASK_DONE: - task_p->state = STATE_T_TASK_DONE; - return EVENT_TRANSVR_TASK_DONE; - - default: - break; - } - snprintf(err_msg, sizeof(err_msg), "Run main_task fail!"); - goto main_transvr_task_err; - -main_transvr_task_wait: - task_p->state = STATE_T_TASK_WAIT; - return EVENT_TRANSVR_TASK_WAIT; - -main_transvr_task_err: - task_p->state = STATE_T_TASK_FAIL; - SWPS_INFO("%s: %s :%d :%s\n", - __func__, err_msg, retval, task_p->transvr_p->swp_name); - return EVENT_TRANSVR_INIT_FAIL; -} - - -static int -_transvr_task_run_post(struct transvr_worker_s *task_p) { - - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - - if ((task_p->post_task) == NULL) { - return EVENT_TRANSVR_TASK_DONE; - } - switch (task_p->state) { - case STATE_T_TASK_WAIT: - case STATE_T_TASK_INIT: - goto post_transvr_task_wait; - - case STATE_T_TASK_DONE: - case STATE_T_TASK_FAIL: - goto post_transvr_task_run; - - default: - break; - } - snprintf(err_msg, sizeof(err_msg), "Unexcept task state"); - goto post_transvr_task_err; - -post_transvr_task_run: - task_p->post_task(task_p); - return EVENT_TRANSVR_TASK_DONE; - -post_transvr_task_wait: - return EVENT_TRANSVR_TASK_WAIT; - -post_transvr_task_err: - SWPS_INFO("%s: %s :%d :%s\n", - __func__, err_msg, task_p->state, task_p->transvr_p->swp_name); - return EVENT_TRANSVR_TASK_FAIL; -} - - -static int -transvr_task_run_one(struct transvr_worker_s *task_p) { - - int retval_main = DEBUG_TRANSVR_INT_VAL; - int retval_post = DEBUG_TRANSVR_INT_VAL; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - - retval_main = _transvr_task_run_main(task_p); - if (retval_main < 0) { - snprintf(err_msg, sizeof(err_msg), "Execute main_task fail!"); - goto err_transvr_task_run_one; - } - retval_post = _transvr_task_run_post(task_p); - if (retval_post < 0) { - snprintf(err_msg, sizeof(err_msg), "Execute post_task fail!"); - goto err_transvr_task_run_one; - } - return retval_main; - -err_transvr_task_run_one: - SWPS_INFO("%s: %s
:%d :%d :%s :%s\n", - __func__, err_msg, retval_main, retval_post, - task_p->func_name, task_p->transvr_p->swp_name); - return EVENT_TRANSVR_TASK_FAIL; -} - - -static int -transvr_task_run_all(struct transvr_obj_s *self) { - - int haserr = 0; - int retval = DEBUG_TRANSVR_INT_VAL; - struct transvr_worker_s *curr_p = NULL; - struct transvr_worker_s *next_p = NULL; - - if ((self->worker_p) == NULL) { - return EVENT_TRANSVR_TASK_DONE; - } - curr_p = self->worker_p; - while (curr_p != NULL) { - next_p = curr_p->next_p; - retval = transvr_task_run_one(curr_p); - if (curr_p->retry == VAL_TRANSVR_TASK_RETRY_FOREVER) { - curr_p = next_p; - continue; - } - switch (retval) { - case EVENT_TRANSVR_TASK_WAIT: - break; - case EVENT_TRANSVR_TASK_DONE: - transvr_task_free_one(curr_p); - break; - case EVENT_TRANSVR_TASK_FAIL: - - default: - haserr = 1; - transvr_task_free_one(curr_p); - break; - } - curr_p = next_p; - } - if (haserr) { - return EVENT_TRANSVR_TASK_FAIL; - } - return EVENT_TRANSVR_TASK_DONE; -} - - -static void -transvr_task_set_delay(struct transvr_worker_s *task_p, - unsigned long delay_msec) { - - task_p->trigger_time = (jiffies + (delay_msec * (HZ/1000))); -} - - -static void -transvr_task_set_retry(struct transvr_worker_s *task_p, - unsigned long retry_times) { - - task_p->retry = retry_times; -} - - -/* For Transceiver Post Task - */ -int -taskfunc_post_do_nothing(struct transvr_worker_s *task_p) { - - return EVENT_TRANSVR_TASK_DONE; -} - - -int -taskfunc_post_handle_task_state(struct transvr_worker_s *task_p) { - - struct transvr_obj_s* tp = task_p->transvr_p; - - switch (task_p->state) { - case STATE_T_TASK_INIT: - case STATE_T_TASK_WAIT: - return EVENT_TRANSVR_TASK_WAIT; - - case STATE_T_TASK_DONE: - tp->state = STATE_TRANSVR_CONNECTED; - tp->send_uevent(tp, KOBJ_ADD); - return EVENT_TRANSVR_TASK_DONE; - - case STATE_T_TASK_FAIL: - tp->state = STATE_TRANSVR_UNEXCEPTED; - return EVENT_TRANSVR_TASK_FAIL; - - default: - break; - } - return EVENT_TRANSVR_TASK_FAIL; -} - - -/* For Transceiver Main Task - */ -int -_taskfunc_sfp_setup_soft_rs(struct transvr_worker_s *task_p, - int input_val, - int address, - int page, - int offset, - int bit_shift, - uint8_t *attr_p, - char *caller) { - - int show_err = 0; - int err_code = DEBUG_TRANSVR_INT_VAL; - char *err_str = DEBUG_TRANSVR_STR_VAL; - char *func_str = "_taskfunc_sfp_setup_soft_rs"; - - err_code = _sfp_update_attr_soft_rs0(task_p->transvr_p, 0); - if (err_code < 0) { - err_str = "Get current soft_rs0 fail!"; - goto err_taskfunc_sfp_setup_soft_rs_1; - } - err_code = __sfp_set_soft_rs(task_p->transvr_p, - input_val, - address, - page, - offset, - bit_shift, - attr_p, - caller, - show_err); - if (err_code < 0) { - err_str = "Get current soft_rs0 fail!"; - goto err_taskfunc_sfp_setup_soft_rs_1; - } - return EVENT_TRANSVR_TASK_DONE; - -err_taskfunc_sfp_setup_soft_rs_1: - if ((task_p->retry) == 0) { - SWPS_INFO("%s: %s :%s :%d :%d\n", - func_str, err_str, task_p->transvr_p->swp_name, input_val, err_code); - } - return EVENT_TRANSVR_TASK_FAIL; -} - - -int -__taskfunc_sfp_setup_hard_rs(struct transvr_worker_s *task_p, - int input_val, - int (*get_func)(struct ioexp_obj_s *self, int virt_offset), - int (*set_func)(struct ioexp_obj_s *self, int virt_offset, int input_val)) { - - int err_val = EVENT_TRANSVR_EXCEP_EXCEP; - char *err_str = DEBUG_TRANSVR_STR_VAL; - - err_val = get_func(task_p->transvr_p->ioexp_obj_p, - task_p->transvr_p->ioexp_virt_offset); - - if (err_val < 0) { - if (err_val == ERR_IOEXP_NOTSUPPORT) { - return EVENT_TRANSVR_TASK_DONE; - } - err_str = "Get current hard_rs fail!"; - goto err_p_taskfunc_sfp_setup_hard_rs_1; - } - if (err_val == input_val) { - return EVENT_TRANSVR_TASK_DONE; - } - err_val = set_func(task_p->transvr_p->ioexp_obj_p, - task_p->transvr_p->ioexp_virt_offset, - input_val); - if (err_val < 0) { - err_str = "Setup hard_rs fail!"; - goto err_p_taskfunc_sfp_setup_hard_rs_1; - } - return EVENT_TRANSVR_TASK_DONE; - -err_p_taskfunc_sfp_setup_hard_rs_1: - if ((task_p->retry) == 0) { - SWPS_INFO("%s: %s :%s :%d :%d\n", - __func__, err_str, task_p->transvr_p->swp_name, input_val, err_val); - } - return EVENT_TRANSVR_TASK_FAIL; -} - - -int -_taskfunc_sfp_setup_hard_rs0(struct transvr_worker_s *task_p, - int input_val) { - - return __taskfunc_sfp_setup_hard_rs(task_p, - input_val, - task_p->transvr_p->ioexp_obj_p->get_hard_rs0, - task_p->transvr_p->ioexp_obj_p->set_hard_rs0); -} - - -int -_taskfunc_sfp_setup_hard_rs1(struct transvr_worker_s *task_p, - int input_val) { - - return __taskfunc_sfp_setup_hard_rs(task_p, - input_val, - task_p->transvr_p->ioexp_obj_p->get_hard_rs1, - task_p->transvr_p->ioexp_obj_p->set_hard_rs1); -} - - -int -_taskfunc_sfp_setup_rs0(struct transvr_worker_s *task_p, - int input_val) { - - int bit_shift = 3; - int old_val = DEBUG_TRANSVR_INT_VAL; - int err_val = EVENT_TRANSVR_EXCEP_EXCEP; - char *err_str = DEBUG_TRANSVR_STR_VAL; - char *func_str = "_taskfunc_sfp_setup_rs0"; - - err_val = _taskfunc_sfp_setup_hard_rs0(task_p, - input_val); - if (err_val < 0) { - err_str = "Setup hard_rs0 fail!"; - goto err_private_taskfunc_sfp_setup_rs0_1; - } - old_val = err_val; - err_val = _taskfunc_sfp_setup_soft_rs(task_p, - input_val, - task_p->transvr_p->eeprom_map_p->addr_soft_rs0, - task_p->transvr_p->eeprom_map_p->page_soft_rs0, - task_p->transvr_p->eeprom_map_p->offset_soft_rs0, - bit_shift, - &(task_p->transvr_p->soft_rs0), - func_str); - if (err_val < 0) { - err_str = "Setup soft_rs0 fail!"; - goto err_private_taskfunc_sfp_setup_rs0_1; - } - return EVENT_TRANSVR_TASK_DONE; - -err_private_taskfunc_sfp_setup_rs0_1: - if ((task_p->retry) == 0) { - SWPS_INFO("%s: %s :%s :%d :%d\n", - func_str, err_str, task_p->transvr_p->swp_name, input_val, err_val); - } - _taskfunc_sfp_setup_hard_rs0(task_p, old_val); - return EVENT_TRANSVR_TASK_FAIL; -} - - -int -_taskfunc_sfp_setup_rs1(struct transvr_worker_s *task_p, - int input_val) { - - int bit_shift = 3; - int old_val = DEBUG_TRANSVR_INT_VAL; - int err_val = EVENT_TRANSVR_EXCEP_EXCEP; - char *err_str = DEBUG_TRANSVR_STR_VAL; - char *func_str = "_taskfunc_sfp_setup_rs1"; - - err_val = _taskfunc_sfp_setup_hard_rs1(task_p, - input_val); - if (err_val < 0) { - err_str = "Setup hard_rs1 fail!"; - goto err_private_taskfunc_sfp_setup_rs1_1; - } - old_val = err_val; - err_val = _taskfunc_sfp_setup_soft_rs(task_p, - input_val, - task_p->transvr_p->eeprom_map_p->addr_soft_rs1, - task_p->transvr_p->eeprom_map_p->page_soft_rs1, - task_p->transvr_p->eeprom_map_p->offset_soft_rs1, - bit_shift, - &(task_p->transvr_p->soft_rs1), - func_str); - if (err_val < 0) { - err_str = "Setup soft_rs1 fail!"; - goto err_private_taskfunc_sfp_setup_rs1_1; - } - return EVENT_TRANSVR_TASK_DONE; - -err_private_taskfunc_sfp_setup_rs1_1: - if ((task_p->retry) == 0) { - SWPS_INFO("%s: %s :%s :%d :%d\n", - func_str, err_str, task_p->transvr_p->swp_name, input_val, err_val); - } - _taskfunc_sfp_setup_hard_rs1(task_p, old_val); - return EVENT_TRANSVR_TASK_FAIL; -} - - -int -taskfunc_sfp_setup_SFF8431_case1(struct transvr_worker_s *task_p) { - /* SFF-8431 (8/4/2G Rx Rate_Select only) */ - int update_val = 1; - - return _taskfunc_sfp_setup_rs0(task_p, update_val); -} - - - -int -taskfunc_sfp_setup_SFF8431_case2(struct transvr_worker_s *task_p) { - /* SFF-8431 (8/4/2G Tx Rate_Select only) */ - int update_val = 1; - - return _taskfunc_sfp_setup_rs1(task_p, update_val); -} - - -int -taskfunc_sfp_setup_SFF8431_case3(struct transvr_worker_s *task_p) { - /* SFF-8431 (8/4/2G Independent Rx & Tx Rate_select) */ - int update_rs0 = 1; - int update_rs1 = 1; - int err_code = DEBUG_TRANSVR_INT_VAL; - - err_code = _taskfunc_sfp_setup_rs0(task_p, update_rs0); - if (err_code < 0) { - return err_code; - } - return _taskfunc_sfp_setup_rs1(task_p, update_rs1); -} - - -int -taskfunc_sfp_handle_1g_rj45(struct transvr_worker_s *task_p) { - - /* Not all of platform support 0x56 for transceiver - * external PHY, Support list as below: - * => 1. Magnolia-PVT (PS: EVT & DVT not ready) - */ - int ext_phy_addr = 0x56; - int ext_phy_page = -1; - int ext_phy_offs = 0x11; - int ext_phy_len = 1; - int lstate_mask = 0x04; /* 00000100 */ - int show_err = 0; - int fail_retry = 5; - int fail_delay = 1000; /* msec */ - int err_code = DEBUG_TRANSVR_INT_VAL; - uint8_t detect_val = DEBUG_TRANSVR_HEX_VAL; - char err_str[64] = DEBUG_TRANSVR_STR_VAL; - int *tmp_p = NULL; - char *func_name = "taskfunc_sfp_handle_1g_rj45"; - - if (task_p->transvr_p->state != STATE_TRANSVR_CONNECTED) { - return EVENT_TRANSVR_TASK_DONE; - } - if ( (task_p->transvr_p->info != TRANSVR_CLASS_BASE_T_1000) && - (task_p->transvr_p->info != TRANSVR_CLASS_BASE_T_1000_up) ) { - goto err_taskfunc_sfp_handle_1g_rj45_1; - } - err_code = _common_update_uint8_attr(task_p->transvr_p, - ext_phy_addr, - ext_phy_page, - ext_phy_offs, - ext_phy_len, - &detect_val, - func_name, - show_err); - if ( (err_code < 0) || - (detect_val == DEBUG_TRANSVR_HEX_VAL) ) { - snprintf(err_str, sizeof(err_str), "Detect external link status fail"); - goto err_taskfunc_sfp_handle_1g_rj45_2; - } - if ((detect_val & lstate_mask) == lstate_mask) { - goto ok_taskfunc_sfp_handle_1g_rj45_link_up; - } - goto ok_taskfunc_sfp_handle_1g_rj45_link_down; - -ok_taskfunc_sfp_handle_1g_rj45_link_up: - /* Filter out noise */ - if (!(task_p->p_data)) { - tmp_p = kzalloc(sizeof(int), GFP_KERNEL); - if (!tmp_p) { - snprintf(err_str, sizeof(err_str), "kzalloc p_data fail"); - goto err_taskfunc_sfp_handle_1g_rj45_2; - } - *tmp_p = TRANSVR_CLASS_BASE_T_1000_up; - task_p->p_data = tmp_p; - goto ok_taskfunc_sfp_handle_1g_rj45_done; - } - if ((*(int *)(task_p->p_data)) != TRANSVR_CLASS_BASE_T_1000_up) { - kfree(task_p->p_data); - task_p->p_data = NULL; - snprintf(err_str, sizeof(err_str), "Internal error"); - goto err_taskfunc_sfp_handle_1g_rj45_2; - } - task_p->transvr_p->info = TRANSVR_CLASS_BASE_T_1000_up; - kfree(task_p->p_data); - task_p->p_data = NULL; - goto ok_taskfunc_sfp_handle_1g_rj45_done; - -ok_taskfunc_sfp_handle_1g_rj45_link_down: - if (task_p->p_data) { - kfree(task_p->p_data); - task_p->p_data = NULL; - } - task_p->transvr_p->info = TRANSVR_CLASS_BASE_T_1000; - goto ok_taskfunc_sfp_handle_1g_rj45_done; - -ok_taskfunc_sfp_handle_1g_rj45_done: - if (task_p->retry != VAL_TRANSVR_TASK_RETRY_FOREVER) { - transvr_task_set_retry(task_p, VAL_TRANSVR_TASK_RETRY_FOREVER); - } - return EVENT_TRANSVR_TASK_DONE; - -err_taskfunc_sfp_handle_1g_rj45_1: - snprintf(err_str, sizeof(err_str), "Detect transceiver:%d not Base-T, remove task.", - task_p->transvr_p->info); - SWPS_INFO("%s: %s :%s\n", __func__, err_str, task_p->transvr_p->swp_name); - transvr_task_set_retry(task_p, 0); - return EVENT_TRANSVR_TASK_DONE; - -err_taskfunc_sfp_handle_1g_rj45_2: - if (task_p->retry == VAL_TRANSVR_TASK_RETRY_FOREVER) { - transvr_task_set_retry(task_p, fail_retry); - } - if ((task_p->retry) == 0) { - /* Error case: - * => In this case, SWPS will stop external Link state monitor features - * and keeps transvr_p->info on TRANSVR_CLASS_BASE_T_1000_up. - * Upper layer will see it always Linkup that because of these type of - * transceiver has external phy, BCM chip see it as Loopback transceiver. - */ - SWPS_WARN("%s can not access external PHY of Base-T SFP transceiver\n", - task_p->transvr_p->swp_name); - task_p->transvr_p->info = TRANSVR_CLASS_BASE_T_1000_up; - return EVENT_TRANSVR_TASK_DONE; - } else { - transvr_task_set_delay(task_p, fail_delay); - } - return EVENT_TRANSVR_TASK_FAIL; -} - - -int -_taskfunc_qsfp_setup_power_mod(struct transvr_obj_s *self, - int setup_val) { - - int curr_val = DEBUG_TRANSVR_INT_VAL; - int err_val = DEBUG_TRANSVR_INT_VAL; - char *err_msg = DEBUG_TRANSVR_STR_VAL; - - curr_val = self->ioexp_obj_p->get_lpmod(self->ioexp_obj_p, - self->ioexp_virt_offset); - if (curr_val < 0){ - err_msg = "Get current value fail!"; - goto err_private_taskfunc_qsfp_setup_power_mod_1; - } - if (curr_val == setup_val){ - return EVENT_TRANSVR_TASK_DONE; - } - err_val = self->ioexp_obj_p->set_lpmod(self->ioexp_obj_p, - self->ioexp_virt_offset, - setup_val); - if (err_val < 0){ - err_msg = "Setup power mode fail!"; - goto err_private_taskfunc_qsfp_setup_power_mod_1; - } - return EVENT_TRANSVR_TASK_DONE; - -err_private_taskfunc_qsfp_setup_power_mod_1: - SWPS_INFO("%s: %s :%d :%d :%d\n", - __func__, err_msg, err_val, curr_val, setup_val); - return EVENT_TRANSVR_TASK_FAIL; -} - - -int -taskfunc_qsfp_handle_tx_disable(struct transvr_worker_s *task_p) { - - int i = 0; - int retry = 5; - int delay_ms = 100; - - if (task_p->transvr_p->auto_tx_disable == VAL_TRANSVR_FUNCTION_DISABLE) { - return EVENT_TRANSVR_TASK_DONE; - } - if (!_qsfp_is_implement_tx_disable(task_p->transvr_p)) { - return EVENT_TRANSVR_TASK_DONE; - } - for (i=0; itransvr_p, - task_p->transvr_p->auto_tx_disable) - == EVENT_TRANSVR_TASK_DONE) { - goto ok_taskfunc_qsfp_handle_tx_disable; - } - mdelay(delay_ms); - } - SWPS_INFO("%s auto setup tx_disable:0x%02x fail.\n", - task_p->transvr_p->swp_name, - task_p->transvr_p->auto_tx_disable); - return EVENT_TRANSVR_INIT_FAIL; - -ok_taskfunc_qsfp_handle_tx_disable: - SWPS_INFO("%s auto setup tx_disable:0x%02x ok.\n", - task_p->transvr_p->swp_name, - task_p->transvr_p->auto_tx_disable); - return EVENT_TRANSVR_TASK_DONE; -} - - -int -taskfunc_qsfp_set_hpmod(struct transvr_worker_s *task_p) { - - int err = DEBUG_TRANSVR_INT_VAL; - int HIGH_POWER_MODE = 0; - - /* Handle power mode */ - err = _taskfunc_qsfp_setup_power_mod(task_p->transvr_p, - HIGH_POWER_MODE); - if (err < 0) { - SWPS_INFO("%s: setup hpmod fail :%d :%s\n", - __func__, err, task_p->transvr_p->swp_name); - return err; - } - /* Handle auto tx_disable - * [Note] - * => Because there are some transceiver have timing issues or - * setup sequence issues, therefore we handle auto tx_disable - * after handle power mode. - */ - mdelay(100); - return taskfunc_qsfp_handle_tx_disable(task_p); -} - - -int -taskfunc_qsfp_set_lpmod(struct transvr_worker_s *task_p) { - - int LOW_POWER_MODE = 1; - return _taskfunc_qsfp_setup_power_mod(task_p->transvr_p, - LOW_POWER_MODE); -} - - -static int -initfunc_sfp_handle_multi_rate_mode(struct transvr_obj_s *self) { - - int task_retry = 3; - int err_code = DEBUG_TRANSVR_INT_VAL; - char *err_str = DEBUG_TRANSVR_STR_VAL; - char *func_str = "sfp_handle_multi_rate_mode"; - struct transvr_worker_s *task_p = NULL; - - switch (self->rate_id) { - case 0x00: /* Unspecified */ - case 0x03: /* Unspecified */ - case 0x05: /* Unspecified */ - case 0x07: /* Unspecified */ - case 0x09: /* Unspecified */ - case 0x0B: /* Unspecified */ - case 0x0D: /* Unspecified */ - case 0x0F: /* Unspecified */ - goto sfp_handle_multi_rate_mode_4_unspecified; - - case 0x02: /* SFF-8431 (8/4/2G Rx Rate_Select only) */ - task_p = transvr_task_creat(self, - taskfunc_sfp_setup_SFF8431_case1, - taskfunc_post_handle_task_state, - func_str); - goto sfp_handle_multi_rate_mode_4_sff8431; - - case 0x04: /* SFF-8431 (8/4/2G Tx Rate_Select only) */ - task_p = transvr_task_creat(self, - taskfunc_sfp_setup_SFF8431_case2, - taskfunc_post_handle_task_state, - func_str); - goto sfp_handle_multi_rate_mode_4_sff8431; - - case 0x06: /* SFF-8431 (8/4/2G Independent Rx & Tx Rate_select) */ - task_p = transvr_task_creat(self, - taskfunc_sfp_setup_SFF8431_case3, - taskfunc_post_handle_task_state, - func_str); - goto sfp_handle_multi_rate_mode_4_sff8431; - - case 0x01: /* SFF-8079 (4/2/1G Rate_Select & AS0/AS1) */ - err_str = "SFF-8079 (4/2/1G Rate_Select & AS0/AS1)"; - goto sfp_handle_multi_rate_mode_4_not_support; - - case 0x08: /* FC-PI-5 (16/8/4G Rx Rate_select only) - * High=16G only, Low=8G/4G - */ - err_str = "FC-PI-5 (16/8/4G Rx Rate_select only)"; - goto sfp_handle_multi_rate_mode_4_not_support; - - case 0x0A: /* FC-PI-5 (16/8/4G Independent Rx, Tx Rate_select) - * High=16G only, Low=8G/4G - */ - err_str = "FC-PI-5 (16/8/4G Independent Rx, Tx Rate_select)"; - goto sfp_handle_multi_rate_mode_4_not_support; - - case 0x0C: /* FC-PI-6 (32/16/8G Independent Rx, Tx Rate_Select) - * High=32G only, Low = 16G/8G - */ - err_str = "FC-PI-6 (32/16/8G Independent Rx, Tx Rate_Select)"; - goto sfp_handle_multi_rate_mode_4_not_support; - - case 0x0E: /* 10/8G Rx and Tx Rate_Select controlling the operation or - * locking modes of the internal signal conditioner, retimer - * or CDR, according to the logic table defined in Table 10-2, - * High Bit Rate (10G) =9.95-11.3 Gb/s; Low Bit Rate (8G) = - * 8.5 Gb/s. In this mode, the default value of bit 110.3 (Soft - * Rate Select RS(0), Table 9-11) and of bit 118.3 (Soft Rate - * Select RS(1), Table 10-1) is 1. - */ - err_str = "cable type: 0x0E"; - goto sfp_handle_multi_rate_mode_4_not_support; - - default: - err_str = "cable type: UNKNOW"; - goto sfp_handle_multi_rate_mode_4_not_support; - } - -sfp_handle_multi_rate_mode_4_sff8431: - if (!task_p) { - err_str = "Create task fail!"; - goto sfp_handle_multi_rate_mode_4_fail_1; - } - transvr_task_set_retry(task_p, task_retry); - return EVENT_TRANSVR_TASK_WAIT; - -sfp_handle_multi_rate_mode_4_unspecified: - return EVENT_TRANSVR_TASK_DONE; - -sfp_handle_multi_rate_mode_4_not_support: - SWPS_INFO("%s: Does not support %s :%s :0x%02x\n", - func_str, err_str, self->swp_name, self->rate_id); - return EVENT_TRANSVR_TASK_DONE; - -sfp_handle_multi_rate_mode_4_fail_1: - SWPS_INFO("%s: %s :%s :0x%02x, :%d\n", - func_str, err_str, self->swp_name, self->rate_id, err_code); - return EVENT_TRANSVR_INIT_FAIL; -} - - -static int -initfunc_sfp_handle_1g_rj45(struct transvr_obj_s *self) { - - struct transvr_worker_s *task_p = NULL; - int detect_cls = DEBUG_TRANSVR_INT_VAL; - char err_str[64] = DEBUG_TRANSVR_STR_VAL; - char *func_str = "initfunc_sfp_handle_1g_rj45"; - - - if (self->info == TRANSVR_CLASS_BASE_T_1000) { - task_p = transvr_task_creat(self, - taskfunc_sfp_handle_1g_rj45, - taskfunc_post_do_nothing, - func_str); - if (!task_p) { - snprintf(err_str, sizeof(err_str), "Create task fail"); - goto err_initfunc_sfp_handle_1g_rj45; - } - transvr_task_set_retry(task_p, VAL_TRANSVR_TASK_RETRY_FOREVER); - } - return EVENT_TRANSVR_TASK_DONE; - -err_initfunc_sfp_handle_1g_rj45: - SWPS_INFO("%s: %s :%s :%d\n", - __func__, err_str, self->swp_name, detect_cls); - return EVENT_TRANSVR_TASK_FAIL; -} - - -static int -initfunc_qsfp_handle_power_mode(struct transvr_obj_s *self) { - - int err_code = EVENT_TRANSVR_EXCEP_INIT; - int power_class = DEBUG_TRANSVR_INT_VAL; - int hpmod_retry = 3; - int lpower_config = 1; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - unsigned long hpmod_delay = 500; /* msec */ - struct transvr_worker_s *task_p = NULL; - - /* Handle power mode for IOEXP */ - power_class = __qsfp_get_power_cls(self, 0); - switch (power_class) { - case 1: /* Case: Low power mode (Class = 1) */ - err_code = _taskfunc_qsfp_setup_power_mod(self, lpower_config); - if (err_code < 0){ - snprintf(err_msg, sizeof(err_msg), "Setup lpmod fail :%d", err_code); - goto err_initfunc_qsfp_handle_power_mode; - } - return EVENT_TRANSVR_TASK_DONE; - - case 2: /* Case: High power mode (Class > 1) */ - case 3: - case 4: - case 5: - case 6: - case 7: - task_p = transvr_task_creat(self, - taskfunc_qsfp_set_hpmod, - taskfunc_post_handle_task_state, - "transvr_init_qsfp"); - if (!task_p) { - snprintf(err_msg, sizeof(err_msg), "Setup lpmod fail :%d", err_code); - goto err_initfunc_qsfp_handle_power_mode; - } - transvr_task_set_retry(task_p, hpmod_retry); - transvr_task_set_delay(task_p, hpmod_delay); - return EVENT_TRANSVR_TASK_WAIT; - - default: - break; - } - snprintf(err_msg, sizeof(err_msg), "Exception case"); - goto err_initfunc_qsfp_handle_power_mode; - -err_initfunc_qsfp_handle_power_mode: - SWPS_INFO("%s: %s :%s \n", __func__, err_msg, self->swp_name); - return EVENT_TRANSVR_INIT_FAIL; -} - - -int -initfunc_qsfp28_handle_cdr(struct transvr_obj_s *self) { - - uint8_t DEFAULT_VAL_CDR = 0xff; - int CDR_FUNC_EXISTED = 0x3; - int show_err = 1; - int err_val = EVENT_TRANSVR_TASK_FAIL; - char *err_msg = DEBUG_TRANSVR_STR_VAL; - char *func_str = "initfunc_qsfp28_handle_cdr"; - - err_val = __qsfp_get_cdr_present(self, 0); - if ( (err_val < 0) || - (err_val == DEBUG_TRANSVR_HEX_VAL) ) { - err_msg = "detect cdr_present fail!"; - goto err_taskfunc_qsfp_handle_cdr_1; - } - if (err_val == CDR_FUNC_EXISTED) { - err_val = _common_set_uint8_attr(self, - self->eeprom_map_p->addr_cdr, - self->eeprom_map_p->addr_cdr, - self->eeprom_map_p->offset_cdr, - DEFAULT_VAL_CDR, - &(self->cdr), - func_str, - show_err); - if (err_val < 0) { - err_msg = "set CDR fail!"; - goto err_taskfunc_qsfp_handle_cdr_1; - } - } - return EVENT_TRANSVR_TASK_DONE; - -err_taskfunc_qsfp_handle_cdr_1: - SWPS_INFO("%s: %s :%d :%s\n", - func_str, err_msg, err_val, self->swp_name); - return EVENT_TRANSVR_INIT_FAIL; -} - -/* ========== Object functions for Final State Machine ========== - */ -int -is_plugged(struct transvr_obj_s *self){ - - int limit = 63; - int present = DEBUG_TRANSVR_INT_VAL; - char emsg[64] = DEBUG_TRANSVR_STR_VAL; - struct ioexp_obj_s *ioexp_p = self->ioexp_obj_p; - - if (!ioexp_p) { - snprintf(emsg, limit, "ioexp_p is null!"); - goto err_is_plugged_1; - } - present = ioexp_p->get_present(ioexp_p, self->ioexp_virt_offset); - switch (present){ - case 0: - return 1; - case 1: - return 0; - case ERR_IOEXP_UNINIT: - snprintf(emsg, limit, "ioexp_p not ready!"); - goto err_is_plugged_1; - default: - if (ioexp_p->state == STATE_IOEXP_INIT){ - snprintf(emsg, limit, "ioexp_p not ready!"); - goto err_is_plugged_1; - } - break; - } - SWPS_INFO("%s: Exception case! :%d :%d\n", - __func__, present, ioexp_p->state); - return 0; - -err_is_plugged_1: - SWPS_DEBUG("%s: %s\n", __func__, emsg); - return 0; -} - - -static int -detect_transvr_type(struct transvr_obj_s* self){ - - int type = TRANSVR_TYPE_ERROR; - - self->i2c_client_p->addr = VAL_TRANSVR_COMID_ARREESS; - type = i2c_smbus_read_byte_data(self->i2c_client_p, - VAL_TRANSVR_COMID_OFFSET); - - /* Case: 1. Wait transceiver I2C module. - * 2. Transceiver I2C module failure. - * Note: 1. SFF allow maximum transceiver initial time is 2 second. So, there - * are exist some case that we need to wait transceiver. - * For these case, we keeps status on "TRANSVR_TYPE_UNPLUGGED", than - * state machine will keep trace with it. - * 2. There exist some I2C failure case we need to handle. Such as user - * insert the failure transceiver, or any reason cause it abnormal. - */ - if (type < 0){ - switch (type) { - case -EIO: - SWPS_DEBUG("%s: %s smbus return:-5 (I/O error)\n", - __func__, self->swp_name); - return TRANSVR_TYPE_UNPLUGGED; - case -ENXIO: - SWPS_DEBUG("%s: %s smbus return:-6 (No such device or address)\n", - __func__, self->swp_name); - return TRANSVR_TYPE_UNPLUGGED; - default: - break; - } - SWPS_INFO("%s: %s unexpected smbus return:%d \n", - __func__, self->swp_name, type); - return TRANSVR_TYPE_ERROR; - } - /* Identify valid transceiver type */ - switch (type){ - case TRANSVR_TYPE_SFP: - case TRANSVR_TYPE_QSFP: - case TRANSVR_TYPE_QSFP_PLUS: - case TRANSVR_TYPE_QSFP_28: - break; - case TRANSVR_TYPE_UNKNOW_1: - case TRANSVR_TYPE_UNKNOW_2: - type = TRANSVR_TYPE_UNKNOW_2; - break; - default: - SWPS_DEBUG("%s: unknow type:0x%02x \n", __func__, type); - type = TRANSVR_TYPE_ERROR; - break; - } - return type; -} - - -static int -detect_transvr_state(struct transvr_obj_s *self, - int result[2]){ - /* [return] [result-0] [result-1] - * 0 STATE_TRANSVR_CONNECTED TRANSVR_TYPE_FAKE - * 0 STATE_TRANSVR_DISCONNECTED TRANSVR_TYPE_UNPLUGGED - * 0 STATE_TRANSVR_ISOLATED TRANSVR_TYPE_ERROR - * 0 STATE_TRANSVR_INIT / - * 0 STATE_TRANSVR_SWAPPED - * 0 STATE_TRANSVR_CONNECTED - * ERR_TRNASVR_BE_ISOLATED STATE_TRANSVR_ISOLATED TRANSVR_TYPE_ERROR - * ERR_TRANSVR_I2C_CRASH STATE_TRANSVR_UNEXCEPTED TRANSVR_TYPE_ERROR - * ERR_TRANSVR_UNEXCPT STATE_TRANSVR_UNEXCEPTED TRANSVR_TYPE_UNKNOW_1/2 - */ - result[0] = STATE_TRANSVR_UNEXCEPTED; /* For return state */ - result[1] = TRANSVR_TYPE_ERROR; /* For return type */ - - /* Case1: Fake type */ - if (self->type == TRANSVR_TYPE_FAKE){ - result[0] = STATE_TRANSVR_CONNECTED; - result[1] = TRANSVR_TYPE_FAKE; - return 0; - } - /* Case2: Transceiver unplugged */ - if (!is_plugged(self)){ - result[0] = STATE_TRANSVR_DISCONNECTED; - result[1] = TRANSVR_TYPE_UNPLUGGED; - return 0; - } - /* Case3: Transceiver be isolated */ - if (self->state == STATE_TRANSVR_ISOLATED){ - result[0] = STATE_TRANSVR_ISOLATED; - result[1] = TRANSVR_TYPE_ERROR; - return ERR_TRNASVR_BE_ISOLATED; - } - /* Case4: Transceiver plugged */ - result[1] = detect_transvr_type(self); - /* Case4.1: I2C topology crash - * Note : There are some I2C issues cause by transceiver/cables. - * We need to check topology status when user insert it. - * But in this step, we can't not ensure this is the issues - * port. So, it return the ERR_TRANSVR_I2C_CRASH, then upper - * layer will diagnostic I2C topology. - */ - if (check_channel_tier_1() < 0) { - SWPS_INFO("%s: %s detect I2C crash :%d\n", - __func__, self->swp_name, self->state); - result[0] = STATE_TRANSVR_UNEXCEPTED; - result[1] = TRANSVR_TYPE_ERROR; - return ERR_TRANSVR_I2C_CRASH; - } - /* Case4.2: System initial not ready, - * Note : Sometime i2c channel or transceiver EEPROM will delay that will - * cause system in inconsistent state between EEPROM and IOEXP. - * In this case, SWP transceiver object keep state at LINK_DOWN - * to wait system ready. - * By the way, State Machine will handle these case. - */ - if (result[1] == TRANSVR_TYPE_UNPLUGGED){ - result[0] = STATE_TRANSVR_DISCONNECTED; - return 0; - } - /* Case4.3: Error transceiver type */ - if (result[1] == TRANSVR_TYPE_ERROR){ - result[0] = STATE_TRANSVR_ISOLATED; - SWPS_INFO("%s: %s detect error type\n", __func__, self->swp_name); - alarm_msg_2_user(self, "detected transceiver/cables not meet SFF standard!"); - return ERR_TRNASVR_BE_ISOLATED; - } - /* Case3.3: Unknow transceiver type */ - if ((result[1] == TRANSVR_TYPE_UNKNOW_1) || - (result[1] == TRANSVR_TYPE_UNKNOW_2) ){ - result[0] = STATE_TRANSVR_UNEXCEPTED; - return ERR_TRANSVR_UNEXCPT; - } - /* Case3.4: During initial process */ - if (self->state == STATE_TRANSVR_INIT){ - result[0] = STATE_TRANSVR_INIT; - return 0; - } - /* Case3.5: Transceiver be swapped */ - if (self->type != result[1]){ - result[0] = STATE_TRANSVR_SWAPPED; - return 0; - } - /* Case3.6: Link up state */ - result[0] = STATE_TRANSVR_CONNECTED; - return 0; -} - - -int -_sfp_detect_class_by_extend_comp(struct transvr_obj_s* self) { - /* Reference: SFF-8024 (v3.8) - */ - int detect_val = _sfp_get_comp_extended(self); - - switch(detect_val) { - case 0x00: /* Unspecified */ - return TRANSVR_CLASS_UNSPECIFIED; - - case 0x01: /* 100G AOC (Active Optical Cable) or 25GAUI C2M */ - case 0x18: /* 100G AOC or 25GAUI C2M AOC. */ - return TRANSVR_CLASS_OPTICAL_25G_AOC; - - case 0x02: /* 100GBASE-SR4 or 25GBASE-SR */ - return TRANSVR_CLASS_OPTICAL_25G_SR; - - case 0x03: /* 100GBASE-LR4 or 25GBASE-LR */ - return TRANSVR_CLASS_OPTICAL_25G_LR; - - case 0x04: /* 100GBASE-ER4 or 25GBASE-ER */ - return TRANSVR_CLASS_OPTICAL_25G_ER; - - case 0x08: /* 100G ACC (Active Copper Cable) or 25GAUI C2M ACC. */ - case 0x0b: /* 100GBASE-CR4 or 25GBASE-CR CA-L */ - case 0x0c: /* 25GBASE-CR CA-S */ - case 0x0d: /* 25GBASE-CR CA-N */ - case 0x19: /* 100G ACC or 25GAUI C2M ACC. */ - return TRANSVR_CLASS_COPPER_L1_25G; - - default: - break; - } - SWPS_INFO("%s: Unexcept value:0x%02x\n :%s", - __func__, detect_val, self->swp_name); - return TRANSVR_CLASS_ERROR; -} - - -int -_sfp_detect_class_by_10_ethernet(struct transvr_obj_s* self) { - /* Reference: SFF-8472 (v12.2) - */ - int detect_val = DEBUG_TRANSVR_INT_VAL; - - detect_val = _sfp_get_comp_10g_eth_comp(self); - /* Case: Unspecified */ - if (detect_val == 0x00) { - return TRANSVR_CLASS_UNSPECIFIED; - } - /* Case: 10G Optical (x1) */ - if ((detect_val & 0x10) == 0x10) { /* 00010000 : 10GBASE-SR */ - return TRANSVR_CLASS_OPTICAL_10G_S_SR; - } - if ( ((detect_val & 0x20) == 0x20) || /* 00100000 : 10GBASE-LR */ - ((detect_val & 0x40) == 0x40) ){ /* 01000000 : 10GBASE-LRM */ - return TRANSVR_CLASS_OPTICAL_10G_S_LR; - } - if ((detect_val & 0x80) == 0x80) { /* 10000000 : 10GBASE-ER */ - return TRANSVR_CLASS_OPTICAL_10G_S_ER; - } - /* Case: ERROR */ - SWPS_INFO("%s: Unexcept value:0x%02x\n :%s", - __func__, detect_val, self->swp_name); - return TRANSVR_CLASS_ERROR; -} - - -int -_sfp_detect_if_sp_by_br(struct transvr_obj_s* self) { - - int lower_bound_1g = 0x0b; - int upper_bound_1g = 0x1A; - int lower_bound_10g = 0x60; - int upper_bound_10g = 0x75; - int lower_bound_25g = 0xf0; - int upper_bound_25g = 0xff; - int notmal_br = DEBUG_TRANSVR_INT_VAL; - - notmal_br = (int)(self->br); /* updated by update_all() */ - /* Check 25G */ - if ((notmal_br >= lower_bound_25g) && - (notmal_br <= upper_bound_25g) ) { - return TRANSVR_CLASS_25G; - } - /* Check 10G */ - if ((notmal_br >= lower_bound_10g) && - (notmal_br <= upper_bound_10g) ) { - return TRANSVR_CLASS_10G; - } - /* Check 1G */ - if ((notmal_br >= lower_bound_1g) && - (notmal_br <= upper_bound_1g) ) { - return TRANSVR_CLASS_1G; - } - return TRANSVR_CLASS_UNSPECIFIED; -} - - -int -_sfp_detect_class_by_1g_ethernet(struct transvr_obj_s* self) { - /* Reference: SFF-8472 (v12.2) - */ - int detect_val = DEBUG_TRANSVR_INT_VAL; - int speed_br = DEBUG_TRANSVR_INT_VAL; - int speed_tmp = DEBUG_TRANSVR_INT_VAL; - char err_str[64] = DEBUG_TRANSVR_STR_VAL; - - speed_br = _sfp_detect_if_sp_by_br(self); - detect_val = _sfp_get_comp_1g_eth_comp(self); - - if (detect_val < 0) { - snprintf(err_str, sizeof(err_str), "Detect abnormal value:%d", detect_val); - goto err_p_sfp_detect_class_by_1g_ethernet; - } - /* Case: Unspecified */ - if (detect_val == 0x00) { - return TRANSVR_CLASS_UNSPECIFIED; - } - /* Case: 1G (x1) */ - if ((detect_val & 0x01) == 0x01) { /* 00000001 : 1000BASE-SX */ - speed_tmp = TRANSVR_CLASS_OPTICAL_1G_SX; - goto ok_sfp_detect_class_by_1g_ethernet_4_check_br_10g; - } - if ((detect_val & 0x02) == 0x02) { /* 00000010 : 1000BASE-LX *3 */ - speed_tmp = TRANSVR_CLASS_OPTICAL_1G_LX; - goto ok_sfp_detect_class_by_1g_ethernet_4_check_br_10g; - } - if ((detect_val & 0x04) == 0x04) { /* 00000100 : 1000BASE-CX */ - speed_tmp = TRANSVR_CLASS_COPPER_L1_1G; - goto ok_sfp_detect_class_by_1g_ethernet_4_check_br_10g; - } - /* Case: 1000 Base-T (x1) */ - if ((detect_val & 0x08) == 0x08) { /* 00001000 : 1000BASE-T */ - return TRANSVR_CLASS_BASE_T_1000; - } - /* Case: 100 Base */ - if ( ((detect_val & 0x10) == 0x10) || /* 00010000 : 100BASE-LX/LX10 */ - ((detect_val & 0x20) == 0x20) || /* 00100000 : 100BASE-FX */ - ((detect_val & 0x40) == 0x40) || /* 01000000 : BASE-BX10 *3 */ - ((detect_val & 0x80) == 0x80) ){ /* 10000000 : BASE-PX *3 */ - return TRANSVR_CLASS_OPTICAL_100; - } - /* Case: ERROR */ - snprintf(err_str, sizeof(err_str), "Case:ERROR, value:%d", detect_val); - goto err_p_sfp_detect_class_by_1g_ethernet; - -ok_sfp_detect_class_by_1g_ethernet_4_check_br_10g: - switch (speed_br) { - case TRANSVR_CLASS_UNSPECIFIED: - case TRANSVR_CLASS_1G: - return speed_tmp; - case TRANSVR_CLASS_10G: - goto ok_sfp_detect_class_by_1g_ethernet_4_transfer_10G; - } - -ok_sfp_detect_class_by_1g_ethernet_4_transfer_10G: - switch (speed_tmp) { - case TRANSVR_CLASS_OPTICAL_1G_SX: - return TRANSVR_CLASS_OPTICAL_10G_S_SR; - case TRANSVR_CLASS_OPTICAL_1G_LX: - return TRANSVR_CLASS_OPTICAL_10G_S_LR; - case TRANSVR_CLASS_COPPER_L1_1G: - return TRANSVR_CLASS_COPPER_L1_10G; - default: - break; - } - snprintf(err_str, sizeof(err_str), "transfer_1to10 fail, speed:%d", speed_tmp); - goto err_p_sfp_detect_class_by_1g_ethernet; - -err_p_sfp_detect_class_by_1g_ethernet: - SWPS_INFO("%s: %s :%s", __func__, err_str, self->swp_name); - return TRANSVR_CLASS_ERROR; -} - - -int -_sfp_detect_class_by_feature(struct transvr_obj_s* self) { - /* Reference: SFF-8024 (v3.8) - */ - int is_active = 0; - int conn_val = DEBUG_TRANSVR_INT_VAL; - int check_val = DEBUG_TRANSVR_INT_VAL; - int wave_len = DEBUG_TRANSVR_INT_VAL; - int speed_val = DEBUG_TRANSVR_INT_VAL; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - - speed_val = _sfp_detect_if_sp_by_br(self); - conn_val = _sfp_get_connector_type(self); - - switch(conn_val) { - case 0x00: /* Unspecified */ - goto ok_sfp_detect_class_by_feature_4_check_active_passive; - case 0x07: /* LC (Lucent Connector) */ - case 0x0b: /* Optical Pigtail */ - case 0x0c: /* MPO 1x12 */ - case 0x0d: /* MPO 2x16 */ - /* - * ToDo: Need verify Optical Pigtail - */ - goto ok_sfp_detect_class_by_feature_4_optiocal; - case 0x21: /* Copper pigtail */ - /* - * ToDo: Need check ACC use case - */ - goto ok_sfp_detect_class_by_feature_4_check_active_passive; - case 0x23: /* No separable connector */ - /* - * ToDo: Standard not clear, not all transceiver vendor - * have the same defined - */ - goto ok_sfp_detect_class_by_feature_4_check_active_passive; - default: - break; - } - goto ok_sfp_detect_class_by_feature_4_unknow; - -ok_sfp_detect_class_by_feature_4_check_active_passive: - check_val = _sfp_get_cable_tech(self); - switch(check_val) { - case 0x00: /* Unspecified */ - goto ok_sfp_detect_class_by_feature_4_unknow; - case 0x04: /* Passive */ - goto ok_sfp_detect_class_by_feature_4_copper; - case 0x08: /* Active */ - is_active = 1; - goto ok_sfp_detect_class_by_feature_4_aoc; - default: - snprintf(err_msg, sizeof(err_msg), - "_sfp_get_cable_tech return Non define value:%d", - check_val); - break; - } - goto err_sfp_detect_class_by_feature_1; - -ok_sfp_detect_class_by_feature_4_optiocal: - wave_len = _common_count_wavelength(self, - self->wavelength[0], - self->wavelength[1]); - switch(speed_val) { - case TRANSVR_CLASS_25G: - switch (wave_len) { - case VAL_OPTICAL_WAVELENGTH_SR: - return TRANSVR_CLASS_OPTICAL_25G_SR; - case VAL_OPTICAL_WAVELENGTH_LR: - return TRANSVR_CLASS_OPTICAL_25G_LR; - case VAL_OPTICAL_WAVELENGTH_ER: - return TRANSVR_CLASS_OPTICAL_25G_ER; - default: - break; - } - return TRANSVR_CLASS_OPTICAL_25G; - - case TRANSVR_CLASS_10G: - switch (wave_len) { - case VAL_OPTICAL_WAVELENGTH_SR: - return TRANSVR_CLASS_OPTICAL_10G_S_SR; - case VAL_OPTICAL_WAVELENGTH_LR: - return TRANSVR_CLASS_OPTICAL_10G_S_LR; - case VAL_OPTICAL_WAVELENGTH_ER: - return TRANSVR_CLASS_OPTICAL_10G_S_ER; - default: - break; - } - return TRANSVR_CLASS_OPTICAL_10G; - - case TRANSVR_CLASS_1G: - switch (wave_len) { - case VAL_OPTICAL_WAVELENGTH_SR: - return TRANSVR_CLASS_OPTICAL_1G_SX; - case VAL_OPTICAL_WAVELENGTH_LR: - return TRANSVR_CLASS_OPTICAL_1G_LX; - case VAL_OPTICAL_WAVELENGTH_ER: - return TRANSVR_CLASS_OPTICAL_1G_EX; - default: - break; - } - return TRANSVR_CLASS_OPTICAL_1G; - - default: - return TRANSVR_CLASS_OPTICAL; - } - -ok_sfp_detect_class_by_feature_4_aoc: - switch(speed_val) { - case TRANSVR_CLASS_25G: - return TRANSVR_CLASS_OPTICAL_25G_AOC; - case TRANSVR_CLASS_10G: - return TRANSVR_CLASS_OPTICAL_10G_S_AOC; - case TRANSVR_CLASS_1G: - return TRANSVR_CLASS_OPTICAL_1G_AOC; - default: - break; - } - goto ok_sfp_detect_class_by_feature_4_unknow; - -ok_sfp_detect_class_by_feature_4_copper: - switch(speed_val) { - case TRANSVR_CLASS_25G: - return TRANSVR_CLASS_COPPER_L1_25G; - case TRANSVR_CLASS_10G: - return TRANSVR_CLASS_COPPER_L1_10G; - case TRANSVR_CLASS_1G: - return TRANSVR_CLASS_COPPER_L1_1G; - default: - return TRANSVR_CLASS_COPPER; - } - -ok_sfp_detect_class_by_feature_4_unknow: - return TRANSVR_CLASS_UNSPECIFIED; - -err_sfp_detect_class_by_feature_1: - SWPS_INFO("%s: %s\n :%s", __func__, err_msg, self->swp_name); - return TRANSVR_CLASS_ERROR; -} - - -int -sft_detect_transvr_class(struct transvr_obj_s* self) { - - int detect_val = DEBUG_TRANSVR_INT_VAL; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - - /* Check Extended Compliance */ - detect_val = _sfp_detect_class_by_extend_comp(self); - switch(detect_val) { - case TRANSVR_CLASS_UNSPECIFIED: - break; - case TRANSVR_CLASS_OPTICAL_25G_AOC: - case TRANSVR_CLASS_OPTICAL_25G_SR: - case TRANSVR_CLASS_OPTICAL_25G_LR: - case TRANSVR_CLASS_OPTICAL_25G_ER: - case TRANSVR_CLASS_COPPER_L1_25G: - return detect_val; - default: - snprintf(err_msg, sizeof(err_msg), - "Detect undefined extend_comp:%d", - detect_val); - goto err_sft_detect_transceiver_class_1; - } - /* Check 10G Compliance */ - detect_val = _sfp_detect_class_by_10_ethernet(self); - switch(detect_val) { - case TRANSVR_CLASS_UNSPECIFIED: - break; - case TRANSVR_CLASS_OPTICAL_10G_S_SR: - case TRANSVR_CLASS_OPTICAL_10G_S_LR: - case TRANSVR_CLASS_OPTICAL_10G_S_ER: - return detect_val; - default: - snprintf(err_msg, sizeof(err_msg), - "Detect undefined 10G_eth:%d", - detect_val); - goto err_sft_detect_transceiver_class_1; - } - /* Check 1G Compliance */ - detect_val = _sfp_detect_class_by_1g_ethernet(self); - switch(detect_val) { - case TRANSVR_CLASS_UNSPECIFIED: - break; - case TRANSVR_CLASS_OPTICAL_1G_SX: - case TRANSVR_CLASS_OPTICAL_1G_LX: - case TRANSVR_CLASS_COPPER_L1_1G: - case TRANSVR_CLASS_BASE_T_1000: - case TRANSVR_CLASS_OPTICAL_100: - /* - * ToDo: Need Check 0.1G - */ - case TRANSVR_CLASS_OPTICAL_10G_S_SR: - case TRANSVR_CLASS_OPTICAL_10G_S_LR: - case TRANSVR_CLASS_COPPER_L1_10G: - /* Transfer speed case - * => Example: Raycom 10G DAC - */ - return detect_val; - default: - snprintf(err_msg, sizeof(err_msg), - "Detect undefined 1G_eth:%d", - detect_val); - goto err_sft_detect_transceiver_class_1; - } - /* Check by connector, br, wavelength */ - detect_val = _sfp_detect_class_by_feature(self); - switch(detect_val) { - case TRANSVR_CLASS_UNSPECIFIED: - break; - case TRANSVR_CLASS_OPTICAL: - case TRANSVR_CLASS_OPTICAL_1G: - case TRANSVR_CLASS_OPTICAL_1G_SX: - case TRANSVR_CLASS_OPTICAL_1G_LX: - case TRANSVR_CLASS_OPTICAL_1G_EX: - case TRANSVR_CLASS_OPTICAL_1G_AOC: - case TRANSVR_CLASS_OPTICAL_10G: - case TRANSVR_CLASS_OPTICAL_10G_S_SR: - case TRANSVR_CLASS_OPTICAL_10G_S_LR: - case TRANSVR_CLASS_OPTICAL_10G_S_ER: - case TRANSVR_CLASS_OPTICAL_10G_S_AOC: - case TRANSVR_CLASS_OPTICAL_25G: - case TRANSVR_CLASS_OPTICAL_25G_SR: - case TRANSVR_CLASS_OPTICAL_25G_LR: - case TRANSVR_CLASS_OPTICAL_25G_ER: - case TRANSVR_CLASS_OPTICAL_25G_AOC: - case TRANSVR_CLASS_COPPER: - case TRANSVR_CLASS_COPPER_L1_1G: - case TRANSVR_CLASS_COPPER_L1_10G: - case TRANSVR_CLASS_COPPER_L1_25G: - return detect_val; - default: - snprintf(err_msg, sizeof(err_msg), - "Detect undefined get_connector:%d", - detect_val); - goto err_sft_detect_transceiver_class_1; - } - /* Exception case: Can't verify */ - snprintf(err_msg, sizeof(err_msg), "Can not identify!"); - goto err_sft_detect_transceiver_class_1; - -err_sft_detect_transceiver_class_1: - SWPS_INFO("%s: %s :%s\n", __func__, err_msg, self->swp_name); - return TRANSVR_CLASS_ERROR; -} - - -int -_sfp_set_trident2_if_type(struct transvr_obj_s* self, - int transvr_cls, - char *result){ - - int lmax = 8; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - - switch(transvr_cls) { - case TRANSVR_CLASS_ERROR: - case TRANSVR_CLASS_UNSPECIFIED: - break; - /* 25G OPTICAL */ - case TRANSVR_CLASS_OPTICAL_25G_AOC: - case TRANSVR_CLASS_OPTICAL_25G_SR: - case TRANSVR_CLASS_OPTICAL_25G_LR: - case TRANSVR_CLASS_OPTICAL_25G_ER: - case TRANSVR_CLASS_OPTICAL_25G: - return snprintf(result, lmax, TRANSVR_IF_SFI); - /* 25G COPPER */ - case TRANSVR_CLASS_COPPER_L1_25G: - return snprintf(result, lmax, TRANSVR_IF_SFI); - /* 10G OPTICAL */ - case TRANSVR_CLASS_OPTICAL_10G_S_AOC: - case TRANSVR_CLASS_OPTICAL_10G_S_SR: - case TRANSVR_CLASS_OPTICAL_10G_S_LR: - case TRANSVR_CLASS_OPTICAL_10G_S_ER: - case TRANSVR_CLASS_OPTICAL_10G: - return snprintf(result, lmax, TRANSVR_IF_SFI); - /* 10G COPPER */ - case TRANSVR_CLASS_COPPER_L1_10G: - return snprintf(result, lmax, TRANSVR_IF_SFI); - /* 1G OPTICAL */ - case TRANSVR_CLASS_OPTICAL_1G_AOC: - case TRANSVR_CLASS_OPTICAL_1G_SX: - case TRANSVR_CLASS_OPTICAL_1G_LX: - case TRANSVR_CLASS_OPTICAL_1G_EX: - case TRANSVR_CLASS_OPTICAL_1G: - return snprintf(result, lmax, TRANSVR_IF_IF_GMII); - /* 1G COPPER */ - case TRANSVR_CLASS_COPPER_L1_1G: - return snprintf(result, lmax, TRANSVR_IF_IF_GMII); - /* 1G BASE_T */ - case TRANSVR_CLASS_BASE_T_1000: - return snprintf(result, lmax, TRANSVR_IF_IF_GMII); - /* 100 Base */ - case TRANSVR_CLASS_OPTICAL_100: - return snprintf(result, lmax, TRANSVR_IF_IF_GMII); - default: - snprintf(err_msg, sizeof(err_msg), - "Detect undefined value:%d", - transvr_cls); - goto err_sfp_set_trident2_if_type_1; - } - /* Exception case: Can't verify */ - snprintf(err_msg, sizeof(err_msg), "Can not identify!"); - goto err_sfp_set_trident2_if_type_1; - -err_sfp_set_trident2_if_type_1: - snprintf(result, lmax, TRANSVR_UEVENT_UNKNOW); - SWPS_INFO("%s: %s :%s\n", __func__, err_msg, self->swp_name); - return ERR_TRANSVR_ABNORMAL; -} - - -int -_sfp_set_tomahawk_if_type(struct transvr_obj_s* self, - int transvr_cls, - char *result) { - - int lmax = 8; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - - switch(transvr_cls) { - case TRANSVR_CLASS_ERROR: - case TRANSVR_CLASS_UNSPECIFIED: - break; - /* 25G OPTICAL */ - case TRANSVR_CLASS_OPTICAL_25G_AOC: - case TRANSVR_CLASS_OPTICAL_25G_SR: - case TRANSVR_CLASS_OPTICAL_25G_LR: - case TRANSVR_CLASS_OPTICAL_25G_ER: - case TRANSVR_CLASS_OPTICAL_25G: - return snprintf(result, lmax, TRANSVR_IF_SR); - /* 25G COPPER */ - case TRANSVR_CLASS_COPPER_L1_25G: - return snprintf(result, lmax, TRANSVR_IF_KR); - /* 10G OPTICAL */ - case TRANSVR_CLASS_OPTICAL_10G_S_AOC: - case TRANSVR_CLASS_OPTICAL_10G_S_SR: - case TRANSVR_CLASS_OPTICAL_10G_S_LR: - case TRANSVR_CLASS_OPTICAL_10G_S_ER: - case TRANSVR_CLASS_OPTICAL_10G: - return snprintf(result, lmax, TRANSVR_IF_SFI); - /* 10G COPPER */ - case TRANSVR_CLASS_COPPER_L1_10G: - return snprintf(result, lmax, TRANSVR_IF_SFI); - /* 1G OPTICAL */ - case TRANSVR_CLASS_OPTICAL_1G_AOC: - case TRANSVR_CLASS_OPTICAL_1G_SX: - case TRANSVR_CLASS_OPTICAL_1G_LX: - case TRANSVR_CLASS_OPTICAL_1G_EX: - case TRANSVR_CLASS_OPTICAL_1G: - return snprintf(result, lmax, TRANSVR_IF_IF_GMII); - /* 1G COPPER */ - case TRANSVR_CLASS_COPPER_L1_1G: - return snprintf(result, lmax, TRANSVR_IF_IF_GMII); - /* 1G BASE_T */ - case TRANSVR_CLASS_BASE_T_1000: - return snprintf(result, lmax, TRANSVR_IF_IF_GMII); - /* 100 Base */ - case TRANSVR_CLASS_OPTICAL_100: - return snprintf(result, lmax, TRANSVR_IF_IF_GMII); - default: - snprintf(err_msg, sizeof(err_msg), - "Detect undefined value:%d", - transvr_cls); - goto err_sfp_set_tomahawk_if_type_1; - } - /* Exception case: Can't verify */ - snprintf(err_msg, sizeof(err_msg), "Can not identify!"); - goto err_sfp_set_tomahawk_if_type_1; - -err_sfp_set_tomahawk_if_type_1: - snprintf(result, lmax, TRANSVR_UEVENT_UNKNOW); - SWPS_INFO("%s: %s\n :%s", __func__, err_msg, self->swp_name); - return ERR_TRANSVR_ABNORMAL; -} - - -int -_sfp_set_bf_tofino_if_type(struct transvr_obj_s* self, - int transvr_cls, - char *result) { - /* (TBD) - * Due to BF looks like doesn't have interface type. - * We bypass it currently. - */ - int lmax = 8; - return snprintf(result, lmax, TRANSVR_UEVENT_UNKNOW); -} - - -int -_sfp_detect_if_type(struct transvr_obj_s* self, - char *result){ - - int lmax = 8; - int detect_cls = DEBUG_TRANSVR_INT_VAL; - - detect_cls = sft_detect_transvr_class(self); - switch (self->chipset_type) { - case BCM_CHIP_TYPE_TRIDENT_2: - return _sfp_set_trident2_if_type(self, detect_cls, result); - - case BCM_CHIP_TYPE_TOMAHAWK: - return _sfp_set_tomahawk_if_type(self, detect_cls, result); - - case BF_CHIP_TYPE_TOFINO: - return _sfp_set_bf_tofino_if_type(self, detect_cls, result); - - default: - SWPS_INFO("%s: non-defined chipset_type:%d :%s\n", - __func__, self->chipset_type, self->swp_name); - break; - } - snprintf(result, lmax, TRANSVR_UEVENT_UNKNOW); - return ERR_TRANSVR_ABNORMAL; -} - - -int -sfp_get_if_type(struct transvr_obj_s *self, - char *buf_p){ - - int lmax = 16; - char tmp_result[16] = DEBUG_TRANSVR_STR_VAL; - - if (self->state != STATE_TRANSVR_CONNECTED) { - return snprintf(buf_p, lmax, "%d\n", self->state); - } - if (_sfp_detect_if_type(self, tmp_result) < 0) { - return snprintf(buf_p, lmax, "%d\n", ERR_TRANSVR_ABNORMAL); - } - return snprintf(buf_p, lmax, "%s\n", tmp_result); -} - - -int -_sfp_detect_if_speed(struct transvr_obj_s* self, - char *result){ - - int lmax = 16; - int detect_val = DEBUG_TRANSVR_INT_VAL; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - - detect_val = sft_detect_transvr_class(self); - switch(detect_val) { - case TRANSVR_CLASS_ERROR: - case TRANSVR_CLASS_UNSPECIFIED: - break; - /* 25G OPTICAL */ - case TRANSVR_CLASS_OPTICAL_25G_AOC: - case TRANSVR_CLASS_OPTICAL_25G_SR: - case TRANSVR_CLASS_OPTICAL_25G_LR: - case TRANSVR_CLASS_OPTICAL_25G_ER: - case TRANSVR_CLASS_OPTICAL_25G: - return snprintf(result, lmax, TRANSVR_IF_SP_25G); - /* 25G COPPER */ - case TRANSVR_CLASS_COPPER_L1_25G: - return snprintf(result, lmax, TRANSVR_IF_SP_25G); - /* 10G OPTICAL */ - case TRANSVR_CLASS_OPTICAL_10G_S_AOC: - case TRANSVR_CLASS_OPTICAL_10G_S_SR: - case TRANSVR_CLASS_OPTICAL_10G_S_LR: - case TRANSVR_CLASS_OPTICAL_10G_S_ER: - case TRANSVR_CLASS_OPTICAL_10G: - return snprintf(result, lmax, TRANSVR_IF_SP_10G); - /* 10G COPPER */ - case TRANSVR_CLASS_COPPER_L1_10G: - return snprintf(result, lmax, TRANSVR_IF_SP_10G); - /* 1G OPTICAL */ - case TRANSVR_CLASS_OPTICAL_1G_AOC: - case TRANSVR_CLASS_OPTICAL_1G_SX: - case TRANSVR_CLASS_OPTICAL_1G_LX: - case TRANSVR_CLASS_OPTICAL_1G_EX: - case TRANSVR_CLASS_OPTICAL_1G: - return snprintf(result, lmax, TRANSVR_IF_SP_1G); - /* 1G COPPER */ - case TRANSVR_CLASS_COPPER_L1_1G: - return snprintf(result, lmax, TRANSVR_IF_SP_1G); - /* 1G BASE_T */ - case TRANSVR_CLASS_BASE_T_1000: - return snprintf(result, lmax, TRANSVR_IF_SP_1G); - /* 100 Base */ - case TRANSVR_CLASS_OPTICAL_100: - return snprintf(result, lmax, TRANSVR_IF_SP_100); - default: - snprintf(err_msg, sizeof(err_msg), - "Detect undefined value:%d", - detect_val); - goto err_sfp_detect_if_speed_1; - } - /* Check by BR */ - detect_val = _sfp_detect_if_sp_by_br(self); - switch (detect_val) { - case TRANSVR_CLASS_25G: - return snprintf(result, lmax, TRANSVR_IF_SP_25G); - case TRANSVR_CLASS_10G: - return snprintf(result, lmax, TRANSVR_IF_SP_10G); - case TRANSVR_CLASS_1G: - return snprintf(result, lmax, TRANSVR_IF_SP_1G); - default: - break; - } - /* Exception case: Can't verify */ - snprintf(err_msg, sizeof(err_msg), "Can not identify!"); - goto err_sfp_detect_if_speed_1; - -err_sfp_detect_if_speed_1: - snprintf(result, lmax, TRANSVR_UEVENT_UNKNOW); - SWPS_INFO("%s %s\n :%s", __func__, err_msg, self->swp_name); - return ERR_TRANSVR_ABNORMAL; -} - - -int -sfp_get_if_speed(struct transvr_obj_s *self, - char *buf_p){ - - int lmax = 16; - char tmp_result[16] = DEBUG_TRANSVR_STR_VAL; - - if (self->state != STATE_TRANSVR_CONNECTED) { - return snprintf(buf_p, lmax, "%d\n", self->state); - } - if (_sfp_detect_if_speed(self, tmp_result) < 0) { - return snprintf(buf_p, lmax, "%d\n", ERR_TRANSVR_ABNORMAL); - } - return snprintf(buf_p, lmax, "%s\n", tmp_result); -} - - -int -_qsfp_detect_class_by_extend_comp(struct transvr_obj_s* self) { - /* Reference: SFF-8024 (v3.8) - */ - int detect_val = DEBUG_TRANSVR_INT_VAL; - - detect_val = _qsfp_get_comp_extended(self); - switch(detect_val) { - case 0x00: /* Unspecified */ - return TRANSVR_CLASS_UNSPECIFIED; - - case 0x01: /* 100G AOC (Active Optical Cable) or 25GAUI C2M */ - case 0x18: /* 100G AOC or 25GAUI C2M AOC. */ - return TRANSVR_CLASS_OPTICAL_100G_AOC; - - case 0x06: /* 100G CWDM4 */ - case 0x09: /* Obsolete (assigned before 100G CWDM4 MSA required FEC) */ - case 0x17: /* 100G CLR4 */ - case 0x1A: /* 100GE-DWDM2 */ - return TRANSVR_CLASS_OPTICAL_100G; - - case 0x02: /* 100GBASE-SR4 or 25GBASE-SR */ - return TRANSVR_CLASS_OPTICAL_100G_SR4; - - case 0x03: /* 100GBASE-LR4 or 25GBASE-LR */ - return TRANSVR_CLASS_OPTICAL_100G_LR4; - - case 0x04: /* 100GBASE-ER4 or 25GBASE-ER */ - return TRANSVR_CLASS_OPTICAL_100G_ER4; - - case 0x07: /* 100G PSM4 Parallel SMF */ - return TRANSVR_CLASS_OPTICAL_100G_PSM4; - - case 0x12: /* 40G PSM4 Parallel SMF */ - return TRANSVR_CLASS_OPTICAL_40G; - - case 0x11: /* 4 x 10GBASE-SR */ - return TRANSVR_CLASS_OPTICAL_40G_SR4; - - case 0x10: /* 40GBASE-ER4 */ - return TRANSVR_CLASS_OPTICAL_40G_ER4; - - case 0x08: /* 100G ACC (Active Copper Cable) or 25GAUI C2M ACC. */ - case 0x0b: /* 100GBASE-CR4 or 25GBASE-CR CA-L */ - case 0x19: /* 100G ACC or 25GAUI C2M ACC. */ - return TRANSVR_CLASS_COPPER_L4_100G; - - default: - break; - } - SWPS_INFO("%s: Unexcept value:0x%02x\n :%s", - __func__, detect_val, self->swp_name); - return TRANSVR_CLASS_ERROR; -} - - -int -_qsfp_detect_class_by_10_40_100_ethernet(struct transvr_obj_s* self) { - /* Reference: SFF-8472 (v12.2) - */ - int detect_val = DEBUG_TRANSVR_INT_VAL; - - detect_val = _qsfp_get_comp_10_40_100_ethernet(self); - /* Case: Unspecified */ - if (detect_val == 0x00) { - return TRANSVR_CLASS_UNSPECIFIED; - } - /* Case: 40G Optical */ - if ((detect_val & 0x01) == 0x01) { /* 00000001 : 40G Active Cable (XLPPI) */ - return TRANSVR_CLASS_OPTICAL_40G_AOC; - } - if ((detect_val & 0x04) == 0x04) { /* 00000100 : 40GBASE-SR4 */ - return TRANSVR_CLASS_OPTICAL_40G_SR4; - } - if ( (detect_val & 0x02) == 0x02) { /* 00000010 : 40GBASE-LR4 */ - return TRANSVR_CLASS_OPTICAL_40G_LR4; - } - if ( (detect_val & 0x08) == 0x08) { /* 00001000 : 40GBASE-CR4 */ - return TRANSVR_CLASS_COPPER_L4_40G; - } - /* Case: 10G Optical */ - if ( (detect_val & 0x10) == 0x10) { /* 00010000 : 10GBASE-SR */ - return TRANSVR_CLASS_OPTICAL_10G_Q_SR; - } - if ( ((detect_val & 0x20) == 0x20) || /* 00100000 : 10GBASE-LR */ - ((detect_val & 0x40) == 0x40) ){ /* 01000000 : 10GBASE-LRM */ - return TRANSVR_CLASS_OPTICAL_10G_Q_LR; - } - /* Case: Extend Compliance */ - if ( ((detect_val & 0x80) == 0x80) ){ /* 10000000 : Use Extend Compliance */ - return TRANSVR_CLASS_EXTEND_COMP; - } - /* Case: ERROR */ - SWPS_INFO("%s: Unexcept value:0x%02x\n :%s", - __func__, detect_val, self->swp_name); - return TRANSVR_CLASS_ERROR; -} - - -int -_qsfp_detect_if_sp_by_br(struct transvr_obj_s* self) { - - int lower_bound_10g = 0x10; - int upper_bound_10g = 0x25; - int lower_bound_40g = 0x60; - int upper_bound_40g = 0x75; - int lower_bound_100g = 0x60; - int upper_bound_100g = 0x75; - int used_extend_br = 0xff; - int notmal_br = DEBUG_TRANSVR_INT_VAL; - int extend_br = DEBUG_TRANSVR_INT_VAL; - - notmal_br = (int)(self->br); /* updated by update_all() */ - /* Check 40G */ - if ((notmal_br >= lower_bound_40g) && - (notmal_br <= upper_bound_40g) ) { - return TRANSVR_CLASS_40G; - } - /* Check 100G */ - if (notmal_br == used_extend_br) { - extend_br = (int)(self->extbr); /* updated by update_all() */ - if ((extend_br >= lower_bound_100g) && - (extend_br <= upper_bound_100g) ) { - return TRANSVR_CLASS_100G; - } - } - /* Check 10G */ - if ((notmal_br >= lower_bound_10g) && - (notmal_br <= upper_bound_10g) ) { - return TRANSVR_CLASS_10G; - } - return TRANSVR_CLASS_UNSPECIFIED; -} - - -int -_qsfp_detect_class_by_feature(struct transvr_obj_s* self) { - /* Reference: SFF-8024 (v3.8) - */ - int conn_val = DEBUG_TRANSVR_INT_VAL; - int wave_len = DEBUG_TRANSVR_INT_VAL; - int speed_val = DEBUG_TRANSVR_INT_VAL; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - - speed_val = _qsfp_detect_if_sp_by_br(self); - conn_val = _qsfp_get_connector_type(self); - - switch(conn_val) { - case 0x00: /* Unspecified */ - return TRANSVR_CLASS_UNSPECIFIED; - case 0x07: /* LC (Lucent Connector) */ - case 0x0b: /* Optical Pigtail */ - case 0x0c: /* MPO 1x12 (Multifiber Parallel Optic) */ - case 0x0d: /* MPO 2x16 */ - goto ok_qsfp_detect_class_by_feature_4_optiocal; - case 0x21: /* Copper pigtail */ - goto ok_qsfp_detect_class_by_feature_4_copper; - case 0x23: /* No separable connector */ - if ((_qsfp_get_comp_fc_link_length(self) > 0) || - (_qsfp_get_comp_fc_trans_tech(self) > 0) || - (_qsfp_get_comp_fc_trans_media(self) > 0) || - (_qsfp_get_comp_fc_speed(self) > 0) ) { - goto ok_qsfp_detect_class_by_feature_4_aoc; - } - goto ok_qsfp_detect_class_by_feature_4_copper; - default: - snprintf(err_msg, sizeof(err_msg), - "_qsfp_get_connector_type return Non define value:%d", - conn_val); - goto err_qsfp_detect_class_by_feature_1; - } - return TRANSVR_CLASS_UNSPECIFIED; - -ok_qsfp_detect_class_by_feature_4_optiocal: - wave_len = _common_count_wavelength(self, - self->wavelength[0], - self->wavelength[1]); - switch(speed_val) { - case TRANSVR_CLASS_100G: - switch (wave_len) { - case VAL_OPTICAL_WAVELENGTH_SR: - return TRANSVR_CLASS_OPTICAL_100G_SR4; - case VAL_OPTICAL_WAVELENGTH_LR: - return TRANSVR_CLASS_OPTICAL_100G_LR4; - case VAL_OPTICAL_WAVELENGTH_ER: - return TRANSVR_CLASS_OPTICAL_100G_ER4; - default: - break; - } - return TRANSVR_CLASS_OPTICAL_100G; - - case TRANSVR_CLASS_40G: - switch (wave_len) { - case VAL_OPTICAL_WAVELENGTH_SR: - return TRANSVR_CLASS_OPTICAL_40G_SR4; - case VAL_OPTICAL_WAVELENGTH_LR: - return TRANSVR_CLASS_OPTICAL_40G_LR4; - case VAL_OPTICAL_WAVELENGTH_ER: - return TRANSVR_CLASS_OPTICAL_40G_ER4; - default: - break; - } - return TRANSVR_CLASS_OPTICAL_40G; - - case TRANSVR_CLASS_10G: - switch (wave_len) { - case VAL_OPTICAL_WAVELENGTH_SR: - return TRANSVR_CLASS_OPTICAL_10G_Q_SR; - case VAL_OPTICAL_WAVELENGTH_LR: - return TRANSVR_CLASS_OPTICAL_10G_Q_LR; - case VAL_OPTICAL_WAVELENGTH_ER: - return TRANSVR_CLASS_OPTICAL_10G_Q_ER; - default: - break; - } - return TRANSVR_CLASS_OPTICAL_10G; - - default: - return TRANSVR_CLASS_OPTICAL; - } - -ok_qsfp_detect_class_by_feature_4_aoc: - switch(speed_val) { - case TRANSVR_CLASS_100G: - return TRANSVR_CLASS_OPTICAL_100G_AOC; - case TRANSVR_CLASS_40G: - return TRANSVR_CLASS_OPTICAL_40G_AOC; - case TRANSVR_CLASS_10G: - return TRANSVR_CLASS_OPTICAL_10G_Q_AOC; - default: - return TRANSVR_CLASS_OPTICAL; - } - -ok_qsfp_detect_class_by_feature_4_copper: - switch(speed_val) { - case TRANSVR_CLASS_100G: - return TRANSVR_CLASS_COPPER_L4_100G; - case TRANSVR_CLASS_40G: - return TRANSVR_CLASS_COPPER_L4_40G; - case TRANSVR_CLASS_10G: - return TRANSVR_CLASS_COPPER_L4_10G; - default: - return TRANSVR_CLASS_COPPER; - } - -err_qsfp_detect_class_by_feature_1: - SWPS_INFO("%s: %s\n :%s", - __func__, err_msg, self->swp_name); - return TRANSVR_CLASS_ERROR; -} - - -int -qsft_detect_transvr_class(struct transvr_obj_s* self) { - - int detect_val = DEBUG_TRANSVR_INT_VAL; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - - /* Check Extended Compliance */ - detect_val = _qsfp_detect_class_by_extend_comp(self); - switch (detect_val) { - case TRANSVR_CLASS_UNSPECIFIED: - break; - case TRANSVR_CLASS_OPTICAL_100G: - case TRANSVR_CLASS_OPTICAL_100G_AOC: - case TRANSVR_CLASS_OPTICAL_100G_SR4: - case TRANSVR_CLASS_OPTICAL_100G_LR4: - case TRANSVR_CLASS_OPTICAL_100G_ER4: - case TRANSVR_CLASS_OPTICAL_100G_PSM4: - case TRANSVR_CLASS_OPTICAL_40G: - case TRANSVR_CLASS_OPTICAL_40G_AOC: - case TRANSVR_CLASS_OPTICAL_40G_SR4: - case TRANSVR_CLASS_OPTICAL_40G_LR4: - case TRANSVR_CLASS_OPTICAL_40G_ER4: - case TRANSVR_CLASS_COPPER_L4_100G: - return detect_val; - default: - snprintf(err_msg, sizeof(err_msg), - "Detect undefined extend_comp:%d", - detect_val); - goto err_qsft_detect_transvr_class_1; - } - /* Check 10/40G/100G Ethernet Compliance */ - detect_val = _qsfp_detect_class_by_10_40_100_ethernet(self); - switch(detect_val) { - case TRANSVR_CLASS_UNSPECIFIED: - break; - case TRANSVR_CLASS_OPTICAL_40G_AOC: - case TRANSVR_CLASS_OPTICAL_40G_SR4: - case TRANSVR_CLASS_OPTICAL_40G_LR4: - case TRANSVR_CLASS_OPTICAL_10G_Q_SR: /* Need Check: SR4 or SR */ - case TRANSVR_CLASS_OPTICAL_10G_Q_LR: /* Need Check: SR4 or SR */ - case TRANSVR_CLASS_COPPER_L4_40G: - return detect_val; - case TRANSVR_CLASS_EXTEND_COMP: - /* Format incorrect case (We already checked the Extend - * Compliance is 0 - */ - snprintf(err_msg, sizeof(err_msg), - "Transceiver format incorrect"); - goto err_qsft_detect_transvr_class_1; - default: - snprintf(err_msg, sizeof(err_msg), - "Detect undefined 10/40/100:%d", - detect_val); - goto err_qsft_detect_transvr_class_1; - } - /* Check by Connector type, BR and wavelength */ - detect_val = _qsfp_detect_class_by_feature(self); - switch (detect_val) { - case TRANSVR_CLASS_UNSPECIFIED: - break; - case TRANSVR_CLASS_OPTICAL_100G_ER4: - case TRANSVR_CLASS_OPTICAL_100G_LR4: - case TRANSVR_CLASS_OPTICAL_100G_SR4: - case TRANSVR_CLASS_OPTICAL_100G_AOC: - case TRANSVR_CLASS_OPTICAL_100G: - case TRANSVR_CLASS_OPTICAL_40G_ER4: - case TRANSVR_CLASS_OPTICAL_40G_LR4: - case TRANSVR_CLASS_OPTICAL_40G_SR4: - case TRANSVR_CLASS_OPTICAL_40G_AOC: - case TRANSVR_CLASS_OPTICAL_40G: - case TRANSVR_CLASS_OPTICAL_10G_Q_ER: - case TRANSVR_CLASS_OPTICAL_10G_Q_LR: - case TRANSVR_CLASS_OPTICAL_10G_Q_SR: - case TRANSVR_CLASS_OPTICAL_10G_Q_AOC: - case TRANSVR_CLASS_OPTICAL_10G: - case TRANSVR_CLASS_OPTICAL: - case TRANSVR_CLASS_COPPER_L4_100G: - case TRANSVR_CLASS_COPPER_L4_40G: - case TRANSVR_CLASS_COPPER_L4_10G: - case TRANSVR_CLASS_COPPER: - return detect_val; - default: - snprintf(err_msg, sizeof(err_msg), - "Detect undefined connector:%d", - detect_val); - goto err_qsft_detect_transvr_class_1; - } - /* Exception case: Can't verify */ - snprintf(err_msg, sizeof(err_msg), - "Can not identify!"); - goto err_qsft_detect_transvr_class_1; - -err_qsft_detect_transvr_class_1: - SWPS_INFO("%s: %s\n :%s", __func__, err_msg, self->swp_name); - return TRANSVR_CLASS_ERROR; -} - - -int -_qsfp_set_trident2_if_type(struct transvr_obj_s* self, - int transvr_cls, - char *result){ - - int lmax = 8; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - - switch (transvr_cls) { - case TRANSVR_CLASS_UNSPECIFIED: - case TRANSVR_CLASS_ERROR: - break; - /* 100G Optical */ - case TRANSVR_CLASS_OPTICAL_100G: - case TRANSVR_CLASS_OPTICAL_100G_AOC: - case TRANSVR_CLASS_OPTICAL_100G_SR4: - case TRANSVR_CLASS_OPTICAL_100G_LR4: - case TRANSVR_CLASS_OPTICAL_100G_ER4: - case TRANSVR_CLASS_OPTICAL_100G_PSM4: - return snprintf(result, lmax, TRANSVR_IF_SR4); - /* 100G Copper */ - case TRANSVR_CLASS_COPPER_L4_100G: - return snprintf(result, lmax, TRANSVR_IF_KR4); - /* 40G Optical */ - case TRANSVR_CLASS_OPTICAL_40G: - case TRANSVR_CLASS_OPTICAL_40G_AOC: - case TRANSVR_CLASS_OPTICAL_40G_SR4: - case TRANSVR_CLASS_OPTICAL_40G_LR4: - case TRANSVR_CLASS_OPTICAL_40G_ER4: - return snprintf(result, lmax, TRANSVR_IF_IF_XGMII); - /* 40G Copper */ - case TRANSVR_CLASS_COPPER_L4_40G: - return snprintf(result, lmax, TRANSVR_IF_IF_XGMII); - /* 10G Optical */ - case TRANSVR_CLASS_OPTICAL_10G: - case TRANSVR_CLASS_OPTICAL_10G_Q_AOC: - case TRANSVR_CLASS_OPTICAL_10G_Q_SR: /* Need Check: SR4 or SR */ - case TRANSVR_CLASS_OPTICAL_10G_Q_LR: /* Need Check: LR4 or LR */ - case TRANSVR_CLASS_OPTICAL_10G_Q_ER: /* Need Check: ER4 or ER */ - return snprintf(result, lmax, TRANSVR_IF_IF_XGMII); - /* Optical */ - case TRANSVR_CLASS_OPTICAL: - return snprintf(result, lmax, TRANSVR_IF_IF_XGMII); - /* Copper */ - case TRANSVR_CLASS_COPPER: - return snprintf(result, lmax, TRANSVR_IF_IF_XGMII); - default: - snprintf(err_msg, sizeof(err_msg), - "Detect undefined value:%d", - transvr_cls); - goto err_qsfp_set_trident2_if_type_1; - } - /* Exception case: Can't verify */ - snprintf(err_msg, sizeof(err_msg), "Can not identify!"); - goto err_qsfp_set_trident2_if_type_1; - -err_qsfp_set_trident2_if_type_1: - snprintf(result, lmax, TRANSVR_UEVENT_UNKNOW); - SWPS_INFO("%s: %s\n :%s", __func__, err_msg, self->swp_name); - return ERR_TRANSVR_ABNORMAL; -} - - -int -_qsfp_set_tomahawk_if_type(struct transvr_obj_s* self, - int transvr_cls, - char *result){ - - int lmax = 8; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - - switch (transvr_cls) { - case TRANSVR_CLASS_UNSPECIFIED: - case TRANSVR_CLASS_ERROR: - break; - /* 100G Optical */ - case TRANSVR_CLASS_OPTICAL_100G: - case TRANSVR_CLASS_OPTICAL_100G_AOC: - case TRANSVR_CLASS_OPTICAL_100G_SR4: - case TRANSVR_CLASS_OPTICAL_100G_LR4: - case TRANSVR_CLASS_OPTICAL_100G_ER4: - case TRANSVR_CLASS_OPTICAL_100G_PSM4: - return snprintf(result, lmax, TRANSVR_IF_SR4); - /* 100G Copper */ - case TRANSVR_CLASS_COPPER_L4_100G: - return snprintf(result, lmax, TRANSVR_IF_KR4); - /* 40G Optical */ - case TRANSVR_CLASS_OPTICAL_40G: - case TRANSVR_CLASS_OPTICAL_40G_AOC: - case TRANSVR_CLASS_OPTICAL_40G_SR4: - case TRANSVR_CLASS_OPTICAL_40G_LR4: - case TRANSVR_CLASS_OPTICAL_40G_ER4: - return snprintf(result, lmax, TRANSVR_IF_SR4); - /* 40G Copper */ - case TRANSVR_CLASS_COPPER_L4_40G: - return snprintf(result, lmax, TRANSVR_IF_KR4); - /* 10G Optical */ - case TRANSVR_CLASS_OPTICAL_10G: - case TRANSVR_CLASS_OPTICAL_10G_Q_AOC: - case TRANSVR_CLASS_OPTICAL_10G_Q_SR: /* Need Check: SR4 or SR */ - case TRANSVR_CLASS_OPTICAL_10G_Q_LR: /* Need Check: SR4 or SR */ - case TRANSVR_CLASS_OPTICAL_10G_Q_ER: - return snprintf(result, lmax, TRANSVR_IF_SR4); - /* Optical */ - case TRANSVR_CLASS_OPTICAL: - return snprintf(result, lmax, TRANSVR_IF_SR4); - /* Copper */ - case TRANSVR_CLASS_COPPER: - return snprintf(result, lmax, TRANSVR_IF_KR4); - default: - snprintf(err_msg, sizeof(err_msg), - "Detect undefined value:%d", - transvr_cls); - goto err_qsfp_set_trident2_if_type_1; - } - /* Exception case: Can't verify */ - snprintf(err_msg, sizeof(err_msg), "Can not identify!"); - goto err_qsfp_set_trident2_if_type_1; - -err_qsfp_set_trident2_if_type_1: - snprintf(result, lmax, TRANSVR_UEVENT_UNKNOW); - SWPS_INFO("%s: %s\n :%s", __func__, err_msg, self->swp_name); - return ERR_TRANSVR_ABNORMAL; -} - - -int -_qsfp_set_bf_tofino_if_type(struct transvr_obj_s* self, - int transvr_cls, - char *result) { - /* (TBD) - * Due to BF looks like doesn't have interface type. - * We bypass it currently. - */ - int lmax = 8; - return snprintf(result, lmax, TRANSVR_UEVENT_UNKNOW); -} - - -int -_qsfp_detect_if_type(struct transvr_obj_s* self, - char *result){ - - int lmax = 8; - int detect_cls = DEBUG_TRANSVR_INT_VAL; - - detect_cls = qsft_detect_transvr_class(self); - switch (self->chipset_type) { - case BCM_CHIP_TYPE_TRIDENT_2: - return _qsfp_set_trident2_if_type(self, detect_cls, result); - - case BCM_CHIP_TYPE_TOMAHAWK: - return _qsfp_set_tomahawk_if_type(self, detect_cls, result); - - case BF_CHIP_TYPE_TOFINO: - return _qsfp_set_bf_tofino_if_type(self, detect_cls, result); - - default: - SWPS_INFO("%s: non-defined chipset_type:%d :%s\n", - __func__, self->chipset_type, self->swp_name); - break; - } - snprintf(result, lmax, TRANSVR_UEVENT_UNKNOW); - return ERR_TRANSVR_ABNORMAL; -} - - -int -qsfp_get_if_type(struct transvr_obj_s *self, - char *buf_p){ - - int lmax = 8; - char tmp_result[8] = DEBUG_TRANSVR_STR_VAL; - - if (self->state != STATE_TRANSVR_CONNECTED) { - return snprintf(buf_p, lmax, "%d\n", self->state); - } - if (_qsfp_detect_if_type(self, tmp_result) < 0) { - return snprintf(buf_p, lmax, "%d\n", ERR_TRANSVR_ABNORMAL); - } - return snprintf(buf_p, lmax, "%s\n", tmp_result); -} - - -int -_qsfp_detect_if_speed(struct transvr_obj_s* self, - char *result){ - int lmax = 16; - int detect_val = DEBUG_TRANSVR_INT_VAL; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - - detect_val = qsft_detect_transvr_class(self); - switch (detect_val) { - case TRANSVR_CLASS_UNSPECIFIED: - case TRANSVR_CLASS_ERROR: - break; - /* 100G Optical */ - case TRANSVR_CLASS_OPTICAL_100G: - case TRANSVR_CLASS_OPTICAL_100G_AOC: - case TRANSVR_CLASS_OPTICAL_100G_SR4: - case TRANSVR_CLASS_OPTICAL_100G_LR4: - case TRANSVR_CLASS_OPTICAL_100G_ER4: - case TRANSVR_CLASS_OPTICAL_100G_PSM4: - return snprintf(result, lmax, TRANSVR_IF_SP_100G); - /* 100G Copper */ - case TRANSVR_CLASS_COPPER_L4_100G: - return snprintf(result, lmax, TRANSVR_IF_SP_100G); - /* 40G Optical */ - case TRANSVR_CLASS_OPTICAL_40G: - case TRANSVR_CLASS_OPTICAL_40G_AOC: - case TRANSVR_CLASS_OPTICAL_40G_SR4: - case TRANSVR_CLASS_OPTICAL_40G_LR4: - case TRANSVR_CLASS_OPTICAL_40G_ER4: - return snprintf(result, lmax, TRANSVR_IF_SP_40G); - /* 40G Copper */ - case TRANSVR_CLASS_COPPER_L4_40G: - return snprintf(result, lmax, TRANSVR_IF_SP_40G); - /* 10G Optical */ - case TRANSVR_CLASS_OPTICAL_10G: - case TRANSVR_CLASS_OPTICAL_10G_Q_AOC: - case TRANSVR_CLASS_OPTICAL_10G_Q_SR: /* Need Check: SR4 or SR */ - case TRANSVR_CLASS_OPTICAL_10G_Q_LR: /* Need Check: SR4 or SR */ - case TRANSVR_CLASS_OPTICAL_10G_Q_ER: - return snprintf(result, lmax, TRANSVR_IF_SP_10G); - /* 10G Copper */ - case TRANSVR_CLASS_COPPER_L4_10G: - return snprintf(result, lmax, TRANSVR_IF_SP_10G); - /* Optical */ - case TRANSVR_CLASS_OPTICAL: - break; - /* Copper */ - case TRANSVR_CLASS_COPPER: - break; - default: - snprintf(err_msg, sizeof(err_msg), - "Detect undefined class case:%d", - detect_val); - goto err_qsfp_detect_if_speed_1; - } - /* Check br and extbr */ - detect_val = _qsfp_detect_if_sp_by_br(self); - switch(detect_val) { - case TRANSVR_CLASS_UNSPECIFIED: - break; - case TRANSVR_CLASS_10G: - return snprintf(result, lmax, TRANSVR_IF_SP_10G); - case TRANSVR_CLASS_40G: - return snprintf(result, lmax, TRANSVR_IF_SP_40G); - case TRANSVR_CLASS_100G: - return snprintf(result, lmax, TRANSVR_IF_SP_100G); - default: - snprintf(err_msg, sizeof(err_msg), - "Detect undefined BR case:%d", - detect_val); - goto err_qsfp_detect_if_speed_1; - } - /* Exception case: Can't verify */ - snprintf(err_msg, sizeof(err_msg), "Can not identify!"); - goto err_qsfp_detect_if_speed_1; - -err_qsfp_detect_if_speed_1: - snprintf(result, lmax, TRANSVR_UEVENT_UNKNOW); - SWPS_INFO("%s: %s :%s\n", __func__, err_msg, self->swp_name); - return ERR_TRANSVR_ABNORMAL; -} - - -int -qsfp_get_if_speed(struct transvr_obj_s *self, - char *buf_p){ - - int lmax = 16; - char tmp_result[16] = DEBUG_TRANSVR_STR_VAL; - - if (self->state != STATE_TRANSVR_CONNECTED) { - return snprintf(buf_p, lmax, "%d\n", self->state); - } - if (_qsfp_detect_if_speed(self, tmp_result) < 0) { - return snprintf(buf_p, lmax, "%d\n", ERR_TRANSVR_ABNORMAL); - } - return snprintf(buf_p, lmax, "%s\n", tmp_result); -} - - -int -_common_set_lane_map_str(struct transvr_obj_s* self, - char *result) { - int i = 0; - int tmp_val = 0; - char tmp_str[LEN_TRANSVR_L_STR] = DEBUG_TRANSVR_STR_VAL; - char err_msg[LEN_TRANSVR_L_STR] = DEBUG_TRANSVR_STR_VAL; - - memset(result, 0, LEN_TRANSVR_L_STR); - snprintf(result, LEN_TRANSVR_L_STR, "%s=", TRANSVR_UEVENT_KEY_LANE); - - for (i=0; ilane_id); i++) { - tmp_val = self->lane_id[i]; - if (tmp_val < 1) { - break; - } - if (tmp_val > 256) { - snprintf(err_msg, sizeof(err_msg), - "detect abnormal value:%d", tmp_val); - goto err_common_set_lane_map_str_1; - } - memset(tmp_str, 0, sizeof(tmp_str)); - if (i == 0) { - snprintf(tmp_str, LEN_TRANSVR_L_STR, "%d", tmp_val); - } else { - snprintf(tmp_str, LEN_TRANSVR_L_STR, ",%d", tmp_val); - } - strncat(result, tmp_str, LEN_TRANSVR_L_STR); - } - if (i == 0) { - goto err_common_set_lane_map_str_2; - } - return 0; - -err_common_set_lane_map_str_1: - SWPS_INFO("%s: %s", __func__, err_msg); -err_common_set_lane_map_str_2: - snprintf(result, LEN_TRANSVR_L_STR, "%s=%s", TRANSVR_UEVENT_KEY_LANE, TRANSVR_UEVENT_UNKNOW); - return EVENT_TRANSVR_TASK_FAIL; -} - - -int -_common_send_uevent(struct transvr_obj_s* self, - enum kobject_action u_action, - int (*detect_if_type)(struct transvr_obj_s *self, char *result), - int (*detect_if_speed)(struct transvr_obj_s *self, char *result), - int send_anyway) { - - char *uevent_envp[4]; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - char tmp_str[32] = DEBUG_TRANSVR_STR_VAL; - char tmp_str_1[32] = DEBUG_TRANSVR_STR_VAL; - char tmp_str_2[32] = DEBUG_TRANSVR_STR_VAL; - char tmp_str_3[64] = DEBUG_TRANSVR_STR_VAL; - - if (TRANSVR_UEVENT_ENABLE != 1) { - return ERR_TRANSVR_NOTSUPPORT; - } - if (_common_get_if_lane(self, tmp_str) < 0) { - snprintf(tmp_str_3, sizeof(tmp_str_3), - "%s=%s", TRANSVR_UEVENT_KEY_LANE, TRANSVR_UEVENT_UNKNOW); - } else { - snprintf(tmp_str_3, sizeof(tmp_str_3), - "%s=%s", TRANSVR_UEVENT_KEY_LANE, tmp_str); - } - switch (u_action) { - case KOBJ_ADD: - /* Detect type */ - if (detect_if_type(self, tmp_str) < 0) { - snprintf(err_msg, sizeof(err_msg), "%s", "Detect interface type fail!"); - snprintf(tmp_str_1, sizeof(tmp_str_1), "%s=%s", TRANSVR_UEVENT_KEY_IF, TRANSVR_UEVENT_UNKNOW); - snprintf(tmp_str_2, sizeof(tmp_str_2), "%s=%s", TRANSVR_UEVENT_KEY_SP, TRANSVR_UEVENT_UNKNOW); - uevent_envp[0] = tmp_str_1; - uevent_envp[1] = tmp_str_2; - uevent_envp[2] = tmp_str_3; - uevent_envp[3] = NULL; - goto private_common_send_uevent_4_fail; - } - snprintf(tmp_str_1, sizeof(tmp_str_1), "%s=%s", TRANSVR_UEVENT_KEY_IF, tmp_str); - uevent_envp[0] = tmp_str_1; - /* Detect speed */ - if (detect_if_speed(self, tmp_str) < 0) { - snprintf(err_msg, sizeof(err_msg), "%s", "Detect interface speed fail!"); - snprintf(tmp_str_2, sizeof(tmp_str_2), "%s=%s", TRANSVR_UEVENT_KEY_SP, TRANSVR_UEVENT_UNKNOW); - uevent_envp[1] = tmp_str_2; - uevent_envp[2] = tmp_str_3; - uevent_envp[3] = NULL; - goto private_common_send_uevent_4_fail; - } - snprintf(tmp_str_2, sizeof(tmp_str_2), "%s=%s", TRANSVR_UEVENT_KEY_SP, tmp_str); - uevent_envp[1] = tmp_str_2; - uevent_envp[2] = tmp_str_3; - uevent_envp[3] = NULL; - goto private_common_send_uevent_4_send; - - case KOBJ_REMOVE: - snprintf(tmp_str_1, sizeof(tmp_str_1), "%s=%s", TRANSVR_UEVENT_KEY_IF, TRANSVR_UEVENT_UNKNOW); - snprintf(tmp_str_2, sizeof(tmp_str_2), "%s=%s", TRANSVR_UEVENT_KEY_SP, TRANSVR_UEVENT_UNKNOW); - uevent_envp[0] = tmp_str_1; - uevent_envp[1] = tmp_str_2; - uevent_envp[2] = tmp_str_3; - uevent_envp[3] = NULL; - goto private_common_send_uevent_4_send; - - default: - snprintf(err_msg, sizeof(err_msg), "kobject_action:%d not support", u_action); - goto private_common_send_uevent_4_fail; - } - snprintf(err_msg, sizeof(err_msg), "%s", "Exception case"); - goto private_common_send_uevent_4_fail; - -private_common_send_uevent_4_fail: - SWPS_INFO("%s: %s :%s\n", __func__, err_msg, self->swp_name); - if (send_anyway) { - goto private_common_send_uevent_4_send; - } - return ERR_TRANSVR_UEVENT_FAIL; - -private_common_send_uevent_4_send: - return kobject_uevent_env(&(self->transvr_dev_p->kobj), - u_action, - uevent_envp); -} - -int -sfp_send_uevent(struct transvr_obj_s* self, - enum kobject_action u_action) { - int send_anyway = 1; - return _common_send_uevent(self, - u_action, - &_sfp_detect_if_type, - &_sfp_detect_if_speed, - send_anyway); -} - - -int -qsfp_send_uevent(struct transvr_obj_s* self, - enum kobject_action u_action) { - int send_anyway = 1; - return _common_send_uevent(self, - u_action, - &_qsfp_detect_if_type, - &_qsfp_detect_if_speed, - send_anyway); -} - - -int -fake_send_uevent(struct transvr_obj_s* self, - enum kobject_action u_action) { - return EVENT_TRANSVR_TASK_DONE; -} - - -int -common_fsm_4_direct_mode(struct transvr_obj_s* self, - char *caller_name){ - - int err; - int detect_result[2]; - int current_state = STATE_TRANSVR_UNEXCEPTED; - int current_type = TRANSVR_TYPE_ERROR; - - if (self->state == STATE_TRANSVR_NEW) { - if (_transvr_init_handler(self) < 0){ - return ERR_TRANSVR_INIT_FAIL; - } - } - err = detect_transvr_state(self, detect_result); - if (err < 0) { - return err; - } - /* In Direct mode, driver only detect transceiver when user call driver interface - * which on sysfs. So it only need consider the state of Transceiver. - */ - current_state = detect_result[0]; - current_type = detect_result[1]; - - switch (current_state){ - - case STATE_TRANSVR_DISCONNECTED: /* Transceiver is not plugged */ - self->state = current_state; - self->type = current_type; - return ERR_TRANSVR_UNPLUGGED; - - case STATE_TRANSVR_INIT: /* Transceiver is plugged, system not ready */ - return ERR_TRANSVR_UNINIT; - - case STATE_TRANSVR_ISOLATED: /* Transceiver is plugged, but has some issues */ - return ERR_TRNASVR_BE_ISOLATED; - - case STATE_TRANSVR_CONNECTED: /* Transceiver is plugged, system is ready */ - self->state = current_state; - self->type = current_type; - return 0; - - case STATE_TRANSVR_SWAPPED: /* Transceiver is plugged, system detect user changed */ - self->type = current_type; - if (reload_transvr_obj(self, current_type) < 0){ - self->state = STATE_TRANSVR_UNEXCEPTED; - return ERR_TRANSVR_UNEXCPT; - } - self->state = current_state; - return 0; - - case STATE_TRANSVR_UNEXCEPTED: /* Transceiver type or state is unexpected case */ - self->state = STATE_TRANSVR_UNEXCEPTED; - self->type = TRANSVR_TYPE_ERROR; - return ERR_TRANSVR_UNEXCPT; - - default: - SWPS_INFO("%s: state:%d not in define.\n", __func__, current_state); - break; - } - return ERR_TRANSVR_UNEXCPT; -} - - -static int -_is_except_happened_4_pmode(struct transvr_obj_s* self, - int new_state) { - - int event_chk = 0; - - if (self->temp == 0){ - return 0; - } - switch (new_state) { - case STATE_TRANSVR_INIT: - event_chk = EVENT_TRANSVR_EXCEP_INIT; - goto check_event_happened_4_pmode; - - case STATE_TRANSVR_CONNECTED: - event_chk = EVENT_TRANSVR_EXCEP_UP; - goto check_event_happened_4_pmode; - - case STATE_TRANSVR_DISCONNECTED: - event_chk = EVENT_TRANSVR_EXCEP_DOWN; - goto check_event_happened_4_pmode; - - case STATE_TRANSVR_SWAPPED: - event_chk = EVENT_TRANSVR_EXCEP_SWAP; - goto check_event_happened_4_pmode; - - case STATE_TRANSVR_UNEXCEPTED: - event_chk = EVENT_TRANSVR_EXCEP_EXCEP; - goto check_event_happened_4_pmode; - - case STATE_TRANSVR_ISOLATED: - event_chk = EVENT_TRANSVR_EXCEP_ISOLATED; - goto check_event_happened_4_pmode; - - default: - SWPS_INFO("%s: unexcepted case:%d\n", __func__, new_state); - break; - } - return 0; - -check_event_happened_4_pmode: - if (self->temp == event_chk){ - return 1; - } - return 0; -} - - -int -common_fsm_4_polling_mode(struct transvr_obj_s* self, - char *caller_name){ - /* [Return Value]: - * ERR_TRANSVR_UNINIT : (1) Initial not ready - * ERR_TRANSVR_UNPLUGGED : (1) Any -> Down - * ERR_TRANSVR_TASK_BUSY : (1) Wait Initial task - * ERR_TRANSVR_UNEXCPT : (1) Initial fail - * (2) Task fail - * (3) Reload fail - * ERR_TRNASVR_BE_ISOLATED : (1) Already be isolated - * OK Case (return 0) : (1) action_4_connected - * (2) action_4_nothing (initial retry) - */ - int curr_state[2]; - int old_state = self->state; - int old_type = self->type; - int new_state = STATE_TRANSVR_UNEXCEPTED; - int new_type = TRANSVR_TYPE_ERROR; - int return_val = ERR_TRANSVR_UNEXCPT; - - /* Never initial */ - if (self->state == STATE_TRANSVR_NEW) { - goto comfsm_action_4_reinit_obj; - } - /* Detect current state */ - switch (detect_transvr_state(self, curr_state)) { - case 0: - new_state = curr_state[0]; - new_type = curr_state[1]; - break; - - case ERR_TRNASVR_BE_ISOLATED: - new_state = STATE_TRANSVR_ISOLATED; - new_type = old_type; - break; - - case ERR_TRANSVR_I2C_CRASH: - goto comfsm_action_4_report_i2c_crash; - - case ERR_TRANSVR_UNEXCPT: - default: - new_state = STATE_TRANSVR_UNEXCEPTED; - new_type = old_type; - } - /* State handling */ - switch (old_state) { - case STATE_TRANSVR_INIT: /* INIT -> */ - return_val = ERR_TRANSVR_UNINIT; - goto comfsm_action_4_keep_state; - - case STATE_TRANSVR_CONNECTED: - switch (new_state) { - case STATE_TRANSVR_INIT: /* Case 1-1: UP -> INIT */ - SWPS_INFO("Detect %s is present. :1-1\n",self->swp_name); - return_val = ERR_TRANSVR_UNINIT; - goto comfsm_action_4_keep_state; - - case STATE_TRANSVR_CONNECTED: /* Case 1-2: UP -> UP */ - return_val = 0; - goto comfsm_action_4_keep_state; - - case STATE_TRANSVR_DISCONNECTED: /* Case 1-3: UP -> DOWN */ - SWPS_INFO("Detect %s is removed. :1-3\n",self->swp_name); - goto comfsm_action_4_disconnected; - - case STATE_TRANSVR_SWAPPED: /* Case 1-4: UP -> SWAP */ - SWPS_INFO("Detect %s is swapped. :1-4\n",self->swp_name); - goto comfsm_action_4_reload_obj; - - case STATE_TRANSVR_UNEXCEPTED: /* Case 1-5: UP -> UNEXPET */ - SWPS_INFO("Detect %s has error. :1-5\n",self->swp_name); - goto comfsm_action_4_unexpected; - - case STATE_TRANSVR_ISOLATED: /* Case 1-6: UP -> ISOLATE */ - SWPS_INFO("Detect %s be isolated. :1-6\n",self->swp_name); - goto comfsm_action_4_isolate_obj; - - default: - break; - } - goto comfsm_action_4_unexpected; - - case STATE_TRANSVR_DISCONNECTED: - switch (new_state) { - case STATE_TRANSVR_INIT: /* Case 2-1: DOWN -> INIT */ - SWPS_INFO("Detect %s is present. :2-1\n",self->swp_name); - return_val = ERR_TRANSVR_UNINIT; - goto comfsm_action_4_keep_state; - - case STATE_TRANSVR_CONNECTED: /* Case 2-2: DOWN -> UP */ - SWPS_INFO("Detect %s is present. :2-2\n",self->swp_name); - goto comfsm_action_4_reinit_obj; - - case STATE_TRANSVR_DISCONNECTED: /* Case 2-3: DOWN -> DOWN */ - return_val = ERR_TRANSVR_UNPLUGGED; - goto comfsm_action_4_keep_state; - - case STATE_TRANSVR_SWAPPED: /* Case 2-4: DOWN -> SWAP */ - SWPS_INFO("Detect %s is swapped. :2-4\n",self->swp_name); - goto comfsm_action_4_reload_obj; - - case STATE_TRANSVR_UNEXCEPTED: /* Case 2-5: DOWN -> UNEXPET */ - SWPS_INFO("Detect %s has error. :2-5\n",self->swp_name); - goto comfsm_action_4_unexpected; - - case STATE_TRANSVR_ISOLATED: /* Case 2-6: DOWN -> ISOLATE */ - SWPS_INFO("Detect %s be isolated. :2-6\n",self->swp_name); - goto comfsm_action_4_isolate_obj; - - default: - break; - } - goto comfsm_action_4_unexpected; - - case STATE_TRANSVR_UNEXCEPTED: - /* Filter out re-action */ - if (_is_except_happened_4_pmode(self, new_state)) { - goto comfsm_action_4_keep_state; - } - /* First action */ - switch (new_state) { - case STATE_TRANSVR_INIT: /* Case 3-1: UNEXPET -> INIT */ - SWPS_INFO("Detect %s is present. :3-1\n",self->swp_name); - self->temp = EVENT_TRANSVR_EXCEP_INIT; - return_val = ERR_TRANSVR_UNINIT; - goto comfsm_action_4_keep_state; - - case STATE_TRANSVR_CONNECTED: /* Case 3-2: UNEXPET -> UP */ - SWPS_INFO("Detect %s is present. :3-2\n",self->swp_name); - self->temp = EVENT_TRANSVR_EXCEP_UP; - goto comfsm_action_4_reload_obj; - - case STATE_TRANSVR_DISCONNECTED: /* Case 3-3: UNEXPET -> DOWN */ - SWPS_INFO("Detect %s is removed. :3-3\n",self->swp_name); - goto comfsm_action_4_disconnected; - - case STATE_TRANSVR_SWAPPED: /* Case 3-4: UNEXPET -> SWAP */ - SWPS_INFO("Detect %s is swapped. :3-4\n",self->swp_name); - self->temp = EVENT_TRANSVR_EXCEP_SWAP; - goto comfsm_action_4_reload_obj; - - case STATE_TRANSVR_UNEXCEPTED: /* Case 3-5: UNEXPET -> UNEXPET */ - self->temp = EVENT_TRANSVR_EXCEP_EXCEP; - return_val = ERR_TRANSVR_UNEXCPT; - goto comfsm_action_4_keep_state; - - case STATE_TRANSVR_ISOLATED: /* Case 3-6: UNEXPET -> ISOLATE */ - SWPS_INFO("Detect %s be isolated. :3-6\n",self->swp_name); - goto comfsm_action_4_isolate_obj; - - default: - break; - } - goto comfsm_action_4_unexpected; - - case STATE_TRANSVR_ISOLATED: - /* Filter out re-action */ - if (_is_except_happened_4_pmode(self, new_state)) { - goto comfsm_action_4_keep_state; - } - /* First action */ - switch (new_state) { - case STATE_TRANSVR_INIT: /* Case 4-1: ISOLATE -> INIT */ - SWPS_INFO("Detect %s internal error. :4-1\n",self->swp_name); - self->temp = EVENT_TRANSVR_EXCEP_INIT; - return_val = ERR_TRNASVR_BE_ISOLATED; - goto comfsm_action_4_keep_state; - - case STATE_TRANSVR_CONNECTED: /* Case 4-2: ISOLATE -> UP */ - SWPS_INFO("Detect %s internal error. :4-2\n",self->swp_name); - self->temp = EVENT_TRANSVR_EXCEP_UP; - return_val = ERR_TRNASVR_BE_ISOLATED; - goto comfsm_action_4_keep_state; - - case STATE_TRANSVR_DISCONNECTED: /* Case 4-3: ISOLATE -> DOWN */ - SWPS_INFO("Detect %s is removed. :4-3\n",self->swp_name); - goto comfsm_action_4_disconnected; - - case STATE_TRANSVR_SWAPPED: /* Case 4-4: ISOLATE -> SWAP */ - SWPS_INFO("Detect %s internal error. :4-4\n",self->swp_name); - self->temp = EVENT_TRANSVR_EXCEP_SWAP; - return_val = ERR_TRNASVR_BE_ISOLATED; - goto comfsm_action_4_keep_state; - - case STATE_TRANSVR_UNEXCEPTED: /* Case 4-5: ISOLATE -> UNEXPET */ - SWPS_INFO("Detect %s internal error. :4-5\n",self->swp_name); - self->temp = EVENT_TRANSVR_EXCEP_EXCEP; - return_val = ERR_TRNASVR_BE_ISOLATED; - goto comfsm_action_4_keep_state; - - case STATE_TRANSVR_ISOLATED: /* Case 4-6: ISOLATE -> ISOLATE */ - return_val = ERR_TRNASVR_BE_ISOLATED; - goto comfsm_action_4_keep_state; - - default: - break; - } - goto comfsm_action_4_unexpected; - - default: - break; - } - goto comfsm_action_4_unexpected; - - -comfsm_action_4_keep_state: - return return_val; - -comfsm_action_4_reinit_obj: - SWPS_DEBUG("FSM action: %s re-initial.\n", self->swp_name); - return_val = _transvr_init_handler(self); - goto comfsm_action_4_identify_event; - -comfsm_action_4_reload_obj: - SWPS_DEBUG("FSM action: %s reload.\n", self->swp_name); - self->type = new_type; - return_val = reload_transvr_obj(self, new_type); - goto comfsm_action_4_identify_event; - -comfsm_action_4_identify_event: - switch (return_val) { - case EVENT_TRANSVR_INIT_UP: - case EVENT_TRANSVR_TASK_DONE: - goto comfsm_action_4_connected; - - case EVENT_TRANSVR_INIT_DOWN: - goto comfsm_action_4_disconnected; - - case EVENT_TRANSVR_INIT_REINIT: - goto comfsm_action_4_nothing; - - case EVENT_TRANSVR_TASK_WAIT: - self->state = STATE_TRANSVR_INIT; - return ERR_TRANSVR_TASK_BUSY; - - case EVENT_TRANSVR_TASK_FAIL: - SWPS_INFO("%s detect EVENT_TRANSVR_TASK_FAIL.\n", self->swp_name); - goto comfsm_action_4_unexpected; - - case EVENT_TRANSVR_INIT_FAIL: - SWPS_INFO("%s detect EVENT_TRANSVR_INIT_FAIL.\n", self->swp_name); - goto comfsm_action_4_unexpected; - - case EVENT_TRANSVR_RELOAD_FAIL: - SWPS_INFO("%s detect EVENT_TRANSVR_RELOAD_FAIL.\n", self->swp_name); - goto comfsm_action_4_unexpected; - - case EVENT_TRANSVR_I2C_CRASH: - goto comfsm_action_4_report_i2c_crash; - - case EVENT_TRANSVR_EXCEP_ISOLATED: - goto comfsm_action_4_isolate_obj; - - default: - SWPS_INFO("%s detect undefined event:%d.\n", self->swp_name, return_val); - goto comfsm_action_4_unexpected; - } - -comfsm_action_4_nothing: - SWPS_DEBUG("FSM action: %s do nothing.\n", self->swp_name); - return 0; - -comfsm_action_4_connected: - SWPS_DEBUG("FSM action: %s Connected.\n", self->swp_name); - self->state = STATE_TRANSVR_CONNECTED; - self->type = new_type; - self->send_uevent(self, KOBJ_ADD); - _transvr_clean_retry(self); - return 0; - -comfsm_action_4_disconnected: - SWPS_DEBUG("FSM action: %s Disconnected. \n", self->swp_name); - self->state = STATE_TRANSVR_DISCONNECTED; - self->temp = EVENT_TRANSVR_TASK_DONE; - self->send_uevent(self, KOBJ_REMOVE); - _transvr_clean_retry(self); - _transvr_clean_handler(self); - return ERR_TRANSVR_UNPLUGGED; - -comfsm_action_4_report_i2c_crash: - SWPS_DEBUG("FSM action: %s report I2C crash.\n", self->swp_name); - self->state = STATE_TRANSVR_UNEXCEPTED; - return ERR_TRANSVR_I2C_CRASH; - -comfsm_action_4_isolate_obj: - SWPS_DEBUG("FSM action: %s isolate.\n", self->swp_name); - self->state = STATE_TRANSVR_ISOLATED; - return ERR_TRNASVR_BE_ISOLATED; - -comfsm_action_4_unexpected: - SWPS_INFO("FSM action: %s unexpected.\n", self->swp_name); - SWPS_INFO("Dump: :%d :0x%02x :%d :0x%02x\n", - old_state, old_type, new_state, new_type); - self->state = STATE_TRANSVR_UNEXCEPTED; - self->send_uevent(self, KOBJ_REMOVE); - _transvr_clean_handler(self); - return ERR_TRANSVR_UNEXCPT; -} - - -int -fake_fsm_4_direct_mode(struct transvr_obj_s* self, - char *caller_name){ - self->state = STATE_TRANSVR_CONNECTED; - self->type = TRANSVR_TYPE_FAKE; - return 0; -} - - -int -fake_fsm_4_polling_mode(struct transvr_obj_s* self, - char *caller_name){ - self->state = STATE_TRANSVR_CONNECTED; - self->type = TRANSVR_TYPE_FAKE; - return 0; -} - - -/* ========== Object functions for Initial procedure ========== - */ -int -transvr_init_common(struct transvr_obj_s *self){ - /* Nothing to update */ - return EVENT_TRANSVR_TASK_DONE; -} - - -int -transvr_init_fake(struct transvr_obj_s *self){ - return EVENT_TRANSVR_TASK_DONE; -} - - -int -transvr_init_sfp(struct transvr_obj_s *self){ - - int tmp_val = DEBUG_TRANSVR_INT_VAL; - int err_code = DEBUG_TRANSVR_INT_VAL; - char *err_msg = "ERR"; - - self->info = sft_detect_transvr_class(self); - /* Disable auto_config */ - if (!self->auto_config) { - return EVENT_TRANSVR_TASK_DONE; - } - /* Handle multi-rate */ - err_code = initfunc_sfp_handle_multi_rate_mode(self); - if (err_code < 0) { - err_msg = "initfunc_sfp_handle_multi_rate_mode fail!"; - goto err_transvr_init_sfp_1; - } - /* Handle 1G- RJ45 */ - tmp_val = err_code; - err_code = initfunc_sfp_handle_1g_rj45(self); - if (err_code < 0) { - err_msg = "initfunc_sfp_handle_1g_rj45 fail!"; - goto err_transvr_init_sfp_1; - } - tmp_val = (tmp_val > err_code ? tmp_val : err_code); - if (tmp_val > EVENT_TRANSVR_TASK_DONE) { - return tmp_val; - } - return EVENT_TRANSVR_TASK_DONE; - -err_transvr_init_sfp_1: - SWPS_INFO("%s: %s :%d :%s\n", - __func__, err_msg, err_code, self->swp_name); - return EVENT_TRANSVR_INIT_FAIL; -} - - -int -transvr_init_qsfp(struct transvr_obj_s *self){ - - int err = EVENT_TRANSVR_EXCEP_EXCEP; - char *emsg = "ERR"; - - self->info = qsft_detect_transvr_class(self); - if (!self->auto_config) { - return EVENT_TRANSVR_TASK_DONE; - } - err = initfunc_qsfp_handle_power_mode(self); - if (err < 0){ - emsg = "initfunc_qsfp_handle_tx_disable fail!"; - goto err_transvr_init_qsfp; - } - return EVENT_TRANSVR_TASK_DONE; - -err_transvr_init_qsfp: - SWPS_INFO("%s: %s :%d :%s\n", - __func__, emsg, err, self->swp_name); - return EVENT_TRANSVR_INIT_FAIL; -} - - -int -transvr_init_qsfp28(struct transvr_obj_s *self){ - - int tmp_val = EVENT_TRANSVR_EXCEP_EXCEP; - int err_val = EVENT_TRANSVR_EXCEP_EXCEP; - char *err_msg = "ERR"; - - /* Handle QSFP common */ - err_val = transvr_init_qsfp(self); - if (err_val < 0){ - err_msg = "transvr_init_qsfp fail!"; - goto err_transvr_init_qsfp28_1; - } - /* Disable auto_config */ - if (!self->auto_config) { - return err_val; - } - /* Handle CDR */ - tmp_val = err_val; - err_val = initfunc_qsfp28_handle_cdr(self); - if (err_val < 0){ - err_msg = "Handle CDR fail!"; - goto err_transvr_init_qsfp28_1; - } - tmp_val = (tmp_val > err_val ? tmp_val : err_val); - if (tmp_val > EVENT_TRANSVR_TASK_DONE) { - return tmp_val; - } - return EVENT_TRANSVR_TASK_DONE; - -err_transvr_init_qsfp28_1: - SWPS_INFO("%s: %s :%d :%s\n", - __func__, err_msg, err_val, self->swp_name); - return EVENT_TRANSVR_INIT_FAIL; -} - - -/* ========== Object Initial handler ========== - */ -static int -_is_transvr_valid(struct transvr_obj_s *self, - int type, - int state) { - /* [Return] - * 0 : OK, inserted - * EVENT_TRANSVR_INIT_DOWN : OK, removed - * EVENT_TRANSVR_INIT_FAIL : Outside error, type doesn't supported - * EVENT_TRANSVR_EXCEP_INIT : Internal error, state undefined - */ - switch (type) { - case TRANSVR_TYPE_SFP: - case TRANSVR_TYPE_QSFP: - case TRANSVR_TYPE_QSFP_PLUS: - case TRANSVR_TYPE_QSFP_28: - case TRANSVR_TYPE_UNPLUGGED: - case TRANSVR_TYPE_FAKE: - break; - default: - SWPS_INFO("detect undefined type:0x%02x on %s\n", - type, self->swp_name); - return EVENT_TRANSVR_INIT_FAIL; - } - switch (state) { - case STATE_TRANSVR_DISCONNECTED: - return EVENT_TRANSVR_INIT_DOWN; - case STATE_TRANSVR_INIT: - case STATE_TRANSVR_CONNECTED: - case STATE_TRANSVR_SWAPPED: - break; - default: - SWPS_INFO("detect undefined state:%d on %s\n", - state, self->swp_name); - return EVENT_TRANSVR_EXCEP_INIT; - } - return 0; -} - - -static int -_is_transvr_hw_ready(struct transvr_obj_s *self, - int type){ - /* [Return] - * EVENT_TRANSVR_TASK_DONE : Ready - * EVENT_TRANSVR_TASK_WAIT : Not ready - * EVENT_TRANSVR_INIT_FAIL : Error - */ - int addr = DEBUG_TRANSVR_INT_VAL; - int page = DEBUG_TRANSVR_INT_VAL; - int offs = DEBUG_TRANSVR_INT_VAL; - int bit = DEBUG_TRANSVR_INT_VAL; - int ready = DEBUG_TRANSVR_INT_VAL; - int err = DEBUG_TRANSVR_INT_VAL; - char *emsg = DEBUG_TRANSVR_STR_VAL; - uint8_t ab_val = DEBUG_TRANSVR_HEX_VAL; - - switch (type) { - case TRANSVR_TYPE_SFP: - addr = VAL_TRANSVR_8472_READY_ADDR; - page = VAL_TRANSVR_8472_READY_PAGE; - offs = VAL_TRANSVR_8472_READY_OFFSET; - bit = VAL_TRANSVR_8472_READY_BIT; - ready = VAL_TRANSVR_8472_READY_VALUE; - ab_val = VAL_TRANSVR_8472_READY_ABNORMAL; - break; - - case TRANSVR_TYPE_QSFP: - case TRANSVR_TYPE_QSFP_PLUS: - case TRANSVR_TYPE_QSFP_28: - addr = VAL_TRANSVR_8436_READY_ADDR; - page = VAL_TRANSVR_8436_READY_PAGE; - offs = VAL_TRANSVR_8436_READY_OFFSET; - bit = VAL_TRANSVR_8436_READY_BIT; - ready = VAL_TRANSVR_8436_READY_VALUE; - ab_val = VAL_TRANSVR_8436_READY_ABNORMAL; - break; - - case TRANSVR_TYPE_UNPLUGGED: - case TRANSVR_TYPE_FAKE: - return EVENT_TRANSVR_TASK_DONE; - - default: - emsg = "unexpected case"; - goto err_is_transvr_hw_ready; - } - /* Select target page */ - err = _common_setup_page(self, addr, page, offs, 1, 0); - if (err < 0) { - emsg = "setup page fail"; - goto err_is_transvr_hw_ready; - } - /* Check feature supported - * [Note] - * Some of transceiver/cables doesn't support "Status Indicators" - * (ex:DAC, RJ45 copper SFP ...etc). In these case, we bypass the - * step of checking Status Indicators, then state machine will take - * the following handle procedure. - */ - err = i2c_smbus_read_byte_data(self->i2c_client_p, - VAL_TRANSVR_COMID_OFFSET); - if (err < 0) { - emsg = "doesn't support Status Indicators"; - goto bypass_is_transvr_hw_ready; - } - /* Filter abnormal case */ - if (err == ab_val) { - emsg = "detect using unusual definition."; - goto bypass_is_transvr_hw_ready; - } - /* Get Status Indicators */ - err = i2c_smbus_read_byte_data(self->i2c_client_p, offs); - if (err < 0) { - emsg = "detect current value fail"; - goto err_is_transvr_hw_ready; - } - if ((err & (1<:%d\n", __func__, emsg, type); - return EVENT_TRANSVR_TASK_DONE; - -err_is_transvr_hw_ready: - SWPS_DEBUG("%s: %s :%d\n", __func__, emsg, type); - return EVENT_TRANSVR_INIT_FAIL; -} - - -static int -_is_transvr_support_ctle(struct transvr_obj_s *self) { - - switch (self->info) { - case TRANSVR_CLASS_OPTICAL_25G: - case TRANSVR_CLASS_OPTICAL_25G_AOC: - case TRANSVR_CLASS_OPTICAL_25G_SR: - case TRANSVR_CLASS_OPTICAL_25G_LR: - case TRANSVR_CLASS_OPTICAL_25G_ER: - case TRANSVR_CLASS_OPTICAL_100G: - case TRANSVR_CLASS_OPTICAL_100G_AOC: - case TRANSVR_CLASS_OPTICAL_100G_SR4: - case TRANSVR_CLASS_OPTICAL_100G_LR4: - case TRANSVR_CLASS_OPTICAL_100G_ER4: - case TRANSVR_CLASS_OPTICAL_100G_PSM4: - return 1; - default: - break; - } - return 0; -} - - -static int -_transvr_init_handler(struct transvr_obj_s *self){ - - int detect[2]; - int d_state = STATE_TRANSVR_UNEXCEPTED; - int d_type = TRANSVR_TYPE_ERROR; - int result = ERR_TRANSVR_UNINIT; - int retry = 6; /* (6+1) x 0.3 = 2.1s > spec:2.0s */ - int elimit = 63; - char emsg[64] = DEBUG_TRANSVR_STR_VAL; - - /* Clean and check callback */ - self->state = STATE_TRANSVR_INIT; - if (self->init == NULL) { - snprintf(emsg, elimit, "init() is null"); - goto initer_err_case_unexcept_0; - } - if (self->clean == NULL) { - snprintf(emsg, elimit, "clean() is null"); - goto initer_err_case_unexcept_0; - } - self->clean(self); - - /* Detect transceiver information */ - result = detect_transvr_state(self, detect); - if (result < 0) { - snprintf(emsg, elimit, "detect_transvr_state() fail"); - switch (result) { - case ERR_TRANSVR_I2C_CRASH: - goto initer_err_case_i2c_ceash; - case ERR_TRNASVR_BE_ISOLATED: - goto initer_err_case_be_isolated; - - case ERR_TRANSVR_UNEXCPT: - default: - break; - } - goto initer_err_case_retry_1; - } - d_state = detect[0]; - d_type = detect[1]; - - /* Verify transceiver type and state */ - switch (_is_transvr_valid(self, d_type, d_state)) { - case 0: - break; - case EVENT_TRANSVR_INIT_DOWN: - goto initer_ok_case_down;; - case EVENT_TRANSVR_INIT_FAIL: - snprintf(emsg, elimit, "transceiver type doesn't support"); - goto initer_err_case_alarm_to_user; - case EVENT_TRANSVR_EXCEP_INIT: - default: - goto initer_err_case_unexcept_1; - } - - /* Handle reload case */ - if (self->type != d_type){ - /* This is the protect mechanism. Normally, This case will not happen. - * When State machine detect swap event during initial, It will trigger - * reload function to ensure type correct. */ - if (_reload_transvr_obj(self, d_type) < 0){ - snprintf(emsg, elimit, "reload object fail"); - goto initer_err_case_unexcept_1; - } - } - - /* Check transceiver HW initial ready */ - switch (_is_transvr_hw_ready(self, d_type)) { - case EVENT_TRANSVR_TASK_DONE: - break; - case EVENT_TRANSVR_TASK_WAIT: - goto initer_err_case_retry_1; - case EVENT_TRANSVR_INIT_FAIL: - default: - goto initer_err_case_unexcept_1; - } - - /* Try to update all and check */ - if (self->update_all(self, 1) < 0){ - /* For some transceiver, EEPROME has lag issues during initial stage. - * In this case, we set status back to STATE_TRANSVR_NEW, than it will - * be checked in next polling cycle. */ - goto initer_err_case_retry_1; - } - - /* Execute init() call back */ - result = self->init(self); - switch (result) { - case EVENT_TRANSVR_TASK_DONE: - break; - case EVENT_TRANSVR_TASK_WAIT: - goto initer_ok_case_wait; - - default: - snprintf(emsg, elimit, "undefined init() return:%d\n", result); - goto initer_err_case_unexcept_1; - } - goto initer_ok_case_up; - - -initer_ok_case_wait: - self->dump_all(self); - return EVENT_TRANSVR_TASK_WAIT; - -initer_ok_case_up: - self->state = STATE_TRANSVR_CONNECTED; - self->temp = 0; - self->dump_all(self); - return EVENT_TRANSVR_INIT_UP; - -initer_ok_case_down: - self->temp = 0; - self->state = STATE_TRANSVR_DISCONNECTED; - return EVENT_TRANSVR_INIT_DOWN; - -initer_err_case_i2c_ceash: - SWPS_DEBUG("%s: %s :%s :I2C crash\n", - __func__, emsg, self->swp_name); - self->state = STATE_TRANSVR_UNEXCEPTED; - return EVENT_TRANSVR_I2C_CRASH; - -initer_err_case_be_isolated: - SWPS_DEBUG("%s: %s :%s :isolated\n", - __func__, emsg, self->swp_name); - self->state = STATE_TRANSVR_ISOLATED; - return EVENT_TRANSVR_EXCEP_ISOLATED; - -initer_err_case_retry_1: - SWPS_DEBUG("%s: %s :%s :retry\n", - __func__, emsg, self->swp_name); - if (_transvr_handle_retry(self, retry) == 0) { - self->state = STATE_TRANSVR_NEW; - return EVENT_TRANSVR_INIT_REINIT; - } - goto initer_err_case_alarm_to_user; - -initer_err_case_unexcept_1: - self->clean(self); -initer_err_case_unexcept_0: - self->state = STATE_TRANSVR_UNEXCEPTED; - if (_is_except_happened_4_pmode(self, d_state) && - (self->mode == TRANSVR_MODE_POLLING) ){ - SWPS_INFO("%s: %s :%s\n", __func__, emsg, self->swp_name); - SWPS_INFO("Dump: :%d :%d :%d :%d\n", - self->state, self->type, d_state, d_type); - } - return EVENT_TRANSVR_INIT_FAIL; - -initer_err_case_alarm_to_user: - SWPS_DEBUG("%s: %s :%s :alarm_to_user\n", - __func__, emsg, self->swp_name); - self->state = STATE_TRANSVR_UNEXCEPTED; - alarm_msg_2_user(self, "detected transceiver/cables not meet SFF standard"); - return EVENT_TRANSVR_INIT_FAIL; -} - - -/* ========== Object functions for Clean procedure ========== - */ -int -_transvr_clean_handler(struct transvr_obj_s *self){ - - int retval = DEBUG_TRANSVR_INT_VAL; - - if (!self->clean) { - SWPS_ERR("%s: %s clean() is NULL.\n", - __func__, self->swp_name); - return EVENT_TRANSVR_TASK_FAIL; - } - retval = self->clean(self); - if (retval != EVENT_TRANSVR_TASK_DONE){ - SWPS_ERR("%s: %s clean() fail. [ERR]:%d\n", - __func__, self->swp_name, retval); - return retval; - } - return EVENT_TRANSVR_TASK_DONE; -} - - -int -common_transvr_clean(struct transvr_obj_s *self){ - - transvr_task_free_all(self); - transvr_cache_free_all(self); - return EVENT_TRANSVR_TASK_DONE; -} - - -int -qsfp_transvr_clean(struct transvr_obj_s *self){ - - int retval; - int lpower_config = 1; - - retval = _taskfunc_qsfp_setup_power_mod(self, lpower_config); - if (retval < 0){ - SWPS_ERR("%s: Set lpmod fail! :%d\n", - __func__, retval); - return retval; - } - retval = common_transvr_clean(self); - if (retval < 0){ - SWPS_ERR("%s: common_transvr_clean fail! :%d\n", - __func__, retval); - return retval; - } - return EVENT_TRANSVR_TASK_DONE; -} - - -int -fake_transvr_clean(struct transvr_obj_s *self){ - - return EVENT_TRANSVR_TASK_DONE; -} - - -/* ========== Object functions for check and update ========== - */ -int -common_transvr_check(struct transvr_obj_s *self){ - - char fun_str[32] = "common_transvr_check"; - - if (self->mode != TRANSVR_MODE_POLLING) { - SWPS_ERR("%s: mode:%d is not TRANSVR_MODE_POLLING\n", - fun_str, self->mode); - return ERR_TRANSVR_UNEXCPT; - } - /* Trigger delay task */ - transvr_task_run_all(self); - /* Trigger state machine to check and update */ - return self->fsm_4_polling(self, fun_str); -} - - -int -fake_transvr_check(struct transvr_obj_s *self){ - return 0; -} - - -/* ========== Functions for Factory pattern ========== - */ -static int -setup_transvr_public_cb(struct transvr_obj_s *self, - int transvr_type){ - switch (transvr_type){ - case TRANSVR_TYPE_SFP: - self->get_id = common_get_id; - self->get_ext_id = common_get_ext_id; - self->get_connector = common_get_connector; - self->get_vendor_name = common_get_vendor_name; - self->get_vendor_pn = common_get_vendor_pn; - self->get_vendor_rev = common_get_vendor_rev; - self->get_vendor_sn = common_get_vendor_sn; - self->get_power_cls = unsupported_get_func; - self->get_br = common_get_br; - self->get_len_sm = sfp_get_len_sm; - self->get_len_smf = common_get_len_smf; - self->get_len_om1 = common_get_len_om1; - self->get_len_om2 = common_get_len_om2; - self->get_len_om3 = common_get_len_om3; - self->get_len_om4 = common_get_len_om4; - self->get_comp_rev = common_get_comp_rev; - self->get_comp_eth_1 = sfp_get_comp_eth_1; - self->get_comp_eth_10 = sfp_get_comp_eth_10; - self->get_comp_eth_10_40 = unsupported_get_func; - self->get_comp_extend = common_get_comp_extended; - self->get_cdr = unsupported_get_func; - self->get_rate_id = sfp_get_rate_id; - self->get_soft_rs0 = sfp_get_soft_rs0; - self->get_soft_rs1 = sfp_get_soft_rs1; - self->get_info = common_get_info; - self->get_if_type = sfp_get_if_type; - self->get_if_speed = sfp_get_if_speed; - self->get_if_lane = common_get_if_lane; - self->get_curr_temp = sfp_get_transvr_temp; - self->get_curr_vol = sfp_get_transvr_voltage; - self->get_soft_rx_los = unsupported_get_func2; - self->get_soft_tx_disable = unsupported_get_func2; - self->get_soft_tx_fault = unsupported_get_func2; - self->get_auto_tx_disable = unsupported_get_func2; - self->get_tx_bias = sfp_get_transvr_tx_bias; - self->get_tx_power = sfp_get_transvr_tx_power; - self->get_rx_power = sfp_get_transvr_rx_power; - self->get_tx_eq = sfp_get_transvr_tx_eq; - self->get_rx_am = unsupported_get_func2; - self->get_rx_em = sfp_get_transvr_rx_em; - self->get_wavelength = sfp_get_wavelength; - self->get_extphy_offset = sfp_get_1g_rj45_extphy_offset; - self->get_extphy_reg = sfp_get_1g_rj45_extphy_reg; - self->set_cdr = unsupported_set_func; - self->set_soft_rs0 = sfp_set_soft_rs0; - self->set_soft_rs1 = sfp_set_soft_rs1; - self->set_soft_tx_disable = unsupported_set_func; - self->set_auto_tx_disable = unsupported_set_func; - self->set_tx_eq = sfp_set_tx_eq; - self->set_rx_am = unsupported_set_func; - self->set_rx_em = sfp_set_rx_em; - self->set_extphy_offset = sfp_set_1g_rj45_extphy_offset; - self->set_extphy_reg = sfp_set_1g_rj45_extphy_reg; - self->get_eeprom = common_get_eeprom; - self->get_uppage = common_get_uppage; - return 0; - - case TRANSVR_TYPE_QSFP: - case TRANSVR_TYPE_QSFP_PLUS: - self->get_id = common_get_id; - self->get_ext_id = common_get_ext_id; - self->get_connector = common_get_connector; - self->get_vendor_name = common_get_vendor_name; - self->get_vendor_pn = common_get_vendor_pn; - self->get_vendor_rev = common_get_vendor_rev; - self->get_vendor_sn = common_get_vendor_sn; - self->get_power_cls = qsfp_get_power_cls; - self->get_br = common_get_br; - self->get_len_sm = unsupported_get_func; - self->get_len_smf = common_get_len_smf; - self->get_len_om1 = common_get_len_om1; - self->get_len_om2 = common_get_len_om2; - self->get_len_om3 = common_get_len_om3; - self->get_len_om4 = common_get_len_om4; - self->get_comp_rev = common_get_comp_rev; - self->get_comp_eth_1 = qsfp_get_comp_eth; - self->get_comp_eth_10 = unsupported_get_func; - self->get_comp_eth_10_40 = qsfp_get_comp_10_40; - self->get_comp_extend = common_get_comp_extended; - self->get_cdr = unsupported_get_func; - self->get_rate_id = unsupported_get_func; - self->get_soft_rs0 = unsupported_get_func; /* TBD */ - self->get_soft_rs1 = unsupported_get_func; /* TBD */ - self->get_info = common_get_info; - self->get_if_type = qsfp_get_if_type; - self->get_if_speed = qsfp_get_if_speed; - self->get_if_lane = common_get_if_lane; - self->get_curr_temp = qsfp_get_transvr_temp; - self->get_curr_vol = qsfp_get_transvr_voltage; - self->get_soft_rx_los = qsfp_get_soft_rx_los; - self->get_soft_tx_disable = qsfp_get_soft_tx_disable; - self->get_soft_tx_fault = qsfp_get_soft_tx_fault; - self->get_auto_tx_disable = qsfp_get_auto_tx_disable; - self->get_tx_bias = qsfp_get_transvr_tx_bias; - self->get_tx_power = qsfp_get_transvr_tx_power; - self->get_rx_power = qsfp_get_transvr_rx_power; - self->get_tx_eq = unsupported_get_func2; - self->get_rx_am = unsupported_get_func2; - self->get_rx_em = unsupported_get_func2; - self->get_wavelength = qsfp_get_wavelength; - self->get_extphy_offset = unsupported_get_func2; - self->get_extphy_reg = unsupported_get_func2; - self->set_cdr = unsupported_set_func; - self->set_soft_rs0 = unsupported_set_func; /* TBD */ - self->set_soft_rs1 = unsupported_set_func; /* TBD */ - self->set_soft_tx_disable = qsfp_set_soft_tx_disable; - self->set_auto_tx_disable = qsfp_set_auto_tx_disable; - self->set_tx_eq = unsupported_set_func; - self->set_rx_am = unsupported_set_func; - self->set_rx_em = unsupported_set_func; - self->set_extphy_offset = unsupported_set_func; - self->set_extphy_reg = unsupported_set_func; - self->get_eeprom = common_get_eeprom; - self->get_uppage = common_get_uppage; - return 0; - - case TRANSVR_TYPE_QSFP_28: - self->get_id = common_get_id; - self->get_ext_id = common_get_ext_id; - self->get_connector = common_get_connector; - self->get_vendor_name = common_get_vendor_name; - self->get_vendor_pn = common_get_vendor_pn; - self->get_vendor_rev = common_get_vendor_rev; - self->get_vendor_sn = common_get_vendor_sn; - self->get_power_cls = qsfp_get_power_cls; - self->get_br = common_get_br; - self->get_len_sm = unsupported_get_func; - self->get_len_smf = common_get_len_smf; - self->get_len_om1 = common_get_len_om1; - self->get_len_om2 = common_get_len_om2; - self->get_len_om3 = common_get_len_om3; - self->get_len_om4 = common_get_len_om4; - self->get_comp_rev = common_get_comp_rev; - self->get_comp_eth_1 = qsfp_get_comp_eth; - self->get_comp_eth_10 = unsupported_get_func; - self->get_comp_eth_10_40 = qsfp_get_comp_10_40; - self->get_comp_extend = common_get_comp_extended; - self->get_cdr = qsfp_get_cdr; - self->get_rate_id = unsupported_get_func; - self->get_soft_rs0 = unsupported_get_func; /* TBD */ - self->get_soft_rs1 = unsupported_get_func; /* TBD */ - self->get_info = common_get_info; - self->get_if_type = qsfp_get_if_type; - self->get_if_speed = qsfp_get_if_speed; - self->get_if_lane = common_get_if_lane; - self->get_curr_temp = qsfp_get_transvr_temp; - self->get_curr_vol = qsfp_get_transvr_voltage; - self->get_soft_rx_los = qsfp_get_soft_rx_los; - self->get_soft_tx_disable = qsfp_get_soft_tx_disable; - self->get_soft_tx_fault = qsfp_get_soft_tx_fault; - self->get_auto_tx_disable = qsfp_get_auto_tx_disable; - self->get_tx_bias = qsfp_get_transvr_tx_bias; - self->get_tx_power = qsfp_get_transvr_tx_power; - self->get_rx_power = qsfp_get_transvr_rx_power; - self->get_tx_eq = qsfp_get_transvr_tx_eq; - self->get_rx_am = qsfp_get_transvr_rx_am; - self->get_rx_em = qsfp_get_transvr_rx_em; - self->get_wavelength = qsfp_get_wavelength; - self->get_extphy_offset = unsupported_get_func2; - self->get_extphy_reg = unsupported_get_func2; - self->set_cdr = qsfp_set_cdr; - self->set_soft_rs0 = unsupported_set_func; /* TBD */ - self->set_soft_rs1 = unsupported_set_func; /* TBD */ - self->set_soft_tx_disable = qsfp_set_soft_tx_disable; - self->set_auto_tx_disable = qsfp_set_auto_tx_disable; - self->set_tx_eq = qsfp_set_tx_eq; - self->set_rx_am = qsfp_set_rx_am; - self->set_rx_em = qsfp_set_rx_em; - self->set_extphy_offset = unsupported_set_func; - self->set_extphy_reg = unsupported_set_func; - self->get_eeprom = common_get_eeprom; - self->get_uppage = common_get_uppage; - return 0; - - case TRANSVR_TYPE_FAKE: - self->get_id = fake_get_hex; - self->get_ext_id = fake_get_hex; - self->get_connector = fake_get_hex; - self->get_vendor_name = fake_get_str; - self->get_vendor_pn = fake_get_str; - self->get_vendor_rev = fake_get_str; - self->get_vendor_sn = fake_get_str; - self->get_power_cls = fake_get_int; - self->get_br = fake_get_hex; - self->get_len_sm = fake_get_int; - self->get_len_smf = fake_get_int; - self->get_len_om1 = fake_get_int; - self->get_len_om2 = fake_get_int; - self->get_len_om3 = fake_get_int; - self->get_len_om4 = fake_get_int; - self->get_comp_rev = fake_get_hex; - self->get_comp_eth_1 = fake_get_hex; - self->get_comp_eth_10 = fake_get_hex; - self->get_comp_eth_10_40 = fake_get_hex; - self->get_comp_extend = fake_get_hex; - self->get_cdr = fake_get_hex; - self->get_rate_id = fake_get_hex; - self->get_soft_rs0 = fake_get_binary; - self->get_soft_rs1 = fake_get_binary; - self->get_info = fake_get_int; - self->get_if_type = fake_get_str; - self->get_if_speed = fake_get_str; - self->get_if_lane = fake_get_str; - self->get_curr_temp = fake_get_str; - self->get_curr_vol = fake_get_str; - self->get_soft_rx_los = fake_get_str; - self->get_soft_tx_disable = fake_get_str; - self->get_soft_tx_fault = fake_get_str; - self->get_auto_tx_disable = fake_get_str; - self->get_tx_bias = fake_get_str; - self->get_tx_power = fake_get_str; - self->get_rx_power = fake_get_str; - self->get_tx_eq = fake_get_str; - self->get_rx_am = fake_get_str; - self->get_rx_em = fake_get_str; - self->get_wavelength = fake_get_str; - self->get_extphy_offset = fake_get_str; - self->get_extphy_reg = fake_get_str; - self->set_cdr = fake_set_hex; - self->set_soft_rs0 = fake_set_int; - self->set_soft_rs1 = fake_set_int; - self->set_soft_tx_disable = fake_set_int; - self->set_auto_tx_disable = fake_set_int; - self->set_tx_eq = fake_set_int; - self->set_rx_am = fake_set_int; - self->set_rx_em = fake_set_int; - self->set_extphy_offset = fake_set_hex; - self->set_extphy_reg = fake_set_hex; - self->get_eeprom = fake_get_str; - self->get_uppage = fake_get_str; - return 0; - - default: - break; - } - SWPS_WARN("%s: Detect non-defined type:%d\n", __func__, transvr_type); - return ERR_TRANSVR_UNEXCPT; -} - - -static int -setup_transvr_private_cb(struct transvr_obj_s *self, - int transvr_type){ - switch (transvr_type){ - case TRANSVR_TYPE_SFP: - self->init = transvr_init_sfp; - self->clean = common_transvr_clean; - self->check = common_transvr_check; - self->update_all = _sfp_update_attr_all; - self->fsm_4_direct = common_fsm_4_direct_mode; - self->fsm_4_polling = common_fsm_4_polling_mode; - self->send_uevent = sfp_send_uevent; - self->dump_all = sfp_transvr_dump; - return 0; - - case TRANSVR_TYPE_QSFP: - case TRANSVR_TYPE_QSFP_PLUS: - self->init = transvr_init_qsfp; - self->clean = qsfp_transvr_clean; - self->check = common_transvr_check; - self->update_all = _qsfp_update_attr_all; - self->fsm_4_direct = common_fsm_4_direct_mode; - self->fsm_4_polling = common_fsm_4_polling_mode; - self->send_uevent = qsfp_send_uevent; - self->dump_all = qsfp_transvr_dump; - return 0; - - case TRANSVR_TYPE_QSFP_28: - self->init = transvr_init_qsfp28; - self->clean = qsfp_transvr_clean; - self->check = common_transvr_check; - self->update_all = _qsfp_update_attr_all; - self->fsm_4_direct = common_fsm_4_direct_mode; - self->fsm_4_polling = common_fsm_4_polling_mode; - self->send_uevent = qsfp_send_uevent; - self->dump_all = qsfp_transvr_dump; - return 0; - - case TRANSVR_TYPE_FAKE: - self->init = transvr_init_fake; - self->clean = fake_transvr_clean; - self->check = fake_transvr_check; - self->update_all = fake_transvr_update; - self->fsm_4_direct = fake_fsm_4_direct_mode; - self->fsm_4_polling = fake_fsm_4_polling_mode; - self->send_uevent = fake_send_uevent; - self->dump_all = fake_transvr_dump; - return 0; - - default: - break; - } - SWPS_WARN("%s: Detect non-defined type:%d\n", __func__, transvr_type); - return ERR_TRANSVR_UNEXCPT; -} - - -static struct eeprom_map_s * -get_eeprom_map(int transvr_type){ - - switch (transvr_type){ - case TRANSVR_TYPE_SFP: - return &eeprom_map_sfp; - case TRANSVR_TYPE_QSFP: - case TRANSVR_TYPE_QSFP_PLUS: - return &eeprom_map_qsfp; - case TRANSVR_TYPE_QSFP_28: - return &eeprom_map_qsfp28; - - default: - break; - } - SWPS_WARN("%s: Detect non-defined type:%d\n", __func__, transvr_type); - return NULL; -} - - -static int -setup_transvr_ssize_attr(char *swp_name, - struct transvr_obj_s *self, - struct eeprom_map_s *map_p, - struct ioexp_obj_s *ioexp_obj_p, - int ioexp_virt_offset, - int transvr_type, - int chipset_type, - int chan_id, - int run_mode){ - switch (run_mode){ - case TRANSVR_MODE_DIRECT: /* Direct access device mode */ - case TRANSVR_MODE_POLLING: /* Polling mode, read from cache */ - self->mode = run_mode; - break; - default: - SWPS_ERR("%s: non-defined run_mode:%d\n", - __func__, run_mode); - self->mode = DEBUG_TRANSVR_INT_VAL; - return -1; - } - self->eeprom_map_p = map_p; - self->ioexp_obj_p = ioexp_obj_p; - self->ioexp_virt_offset = ioexp_virt_offset; - self->chan_id = chan_id; - self->layout = transvr_type; - self->type = transvr_type; - self->chipset_type = chipset_type; - self->state = STATE_TRANSVR_NEW; - self->info = STATE_TRANSVR_NEW; - self->auto_tx_disable = VAL_TRANSVR_FUNCTION_DISABLE; - strncpy(self->swp_name, swp_name, 32); - mutex_init(&self->lock); - return 0; -} - - -static int -setup_transvr_dsize_attr(struct transvr_obj_s *self){ - - char *emsg = DEBUG_TRANSVR_STR_VAL; - - self->vendor_name = kzalloc((LEN_TRANSVR_M_STR * sizeof(char)), GFP_KERNEL); - if (!self->vendor_name){ - emsg = "vendor_name"; - goto err_setup_d_attr; - } - self->vendor_pn = kzalloc((LEN_TRANSVR_M_STR * sizeof(char)), GFP_KERNEL); - if (!self->vendor_pn){ - emsg = "vendor_pn"; - goto err_setup_d_attr; - } - self->vendor_rev = kzalloc((LEN_TRANSVR_M_STR * sizeof(char)), GFP_KERNEL); - if (!self->vendor_rev){ - emsg = "vendor_rev"; - goto err_setup_d_attr; - } - self->vendor_sn = kzalloc((LEN_TRANSVR_M_STR * sizeof(char)), GFP_KERNEL); - if (!self->vendor_sn){ - emsg = "vendor_sn"; - goto err_setup_d_attr; - } - self->worker_p = NULL; - return 0; - -err_setup_d_attr: - SWPS_ERR("%s: %s kzalloc fail!", __func__, emsg); - return ERR_TRANSVR_UNEXCPT; -} - - -static int -setup_i2c_client(struct transvr_obj_s *self){ - - struct i2c_adapter *adap = NULL; - struct i2c_client *client = NULL; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - - adap = i2c_get_adapter(self->chan_id); - if(!adap){ - snprintf(err_msg, sizeof(err_msg), - "can not get adap:%d", self->chan_id); - goto err_setup_i2c_client; - } - client = kzalloc(sizeof(*client), GFP_KERNEL); - if (!client){ - snprintf(err_msg, sizeof(err_msg), - "can not kzalloc client:%d", self->chan_id); - goto err_setup_i2c_client; - } - client->adapter = adap; - self->i2c_client_p = client; - self->i2c_client_p->addr = VAL_TRANSVR_COMID_ARREESS; - return 0; - -err_setup_i2c_client: - SWPS_ERR("%s: %s\n", __func__, err_msg); - return ERR_TRANSVR_UNEXCPT; -} - - -struct transvr_obj_s * -create_transvr_obj(char *swp_name, - int chan_id, - struct ioexp_obj_s *ioexp_obj_p, - int ioexp_virt_offset, - int transvr_type, - int chipset_type, - int run_mode){ - - struct transvr_obj_s *result_p; - struct eeprom_map_s *map_p; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - - /* Allocate transceiver object */ - map_p = get_eeprom_map(transvr_type); - if (!map_p){ - snprintf(err_msg, sizeof(err_msg), - "Invalid transvr_type:%d", transvr_type); - goto err_create_transvr_fail; - } - result_p = kzalloc(sizeof(*result_p), GFP_KERNEL); - if (!result_p){ - snprintf(err_msg, sizeof(err_msg), "kzalloc fail"); - goto err_create_transvr_fail; - } - /* Prepare static size attributes */ - if (setup_transvr_ssize_attr(swp_name, - result_p, - map_p, - ioexp_obj_p, - ioexp_virt_offset, - transvr_type, - chipset_type, - chan_id, - run_mode) < 0){ - goto err_create_transvr_sattr_fail; - } - /* Prepare dynamic size attributes */ - if (setup_transvr_dsize_attr(result_p) < 0){ - goto err_create_transvr_dattr_fail; - } - /* Prepare call back functions of object */ - if (setup_transvr_public_cb(result_p, transvr_type) < 0){ - goto err_create_transvr_dattr_fail; - } - /* Prepare call back functions of object */ - if (setup_transvr_private_cb(result_p, transvr_type) < 0){ - goto err_create_transvr_dattr_fail; - } - /* Prepare i2c client object */ - if (setup_i2c_client(result_p) < 0){ - goto err_create_transvr_dattr_fail; - } - return result_p; - -err_create_transvr_dattr_fail: - kfree(result_p->vendor_sn); - kfree(result_p->vendor_rev); - kfree(result_p->vendor_pn); - kfree(result_p->vendor_name); -err_create_transvr_sattr_fail: - kfree(result_p); -err_create_transvr_fail: - SWPS_ERR("%s: %s :%d :%d :%d\n", - __func__, err_msg, chan_id, ioexp_virt_offset, transvr_type); - return NULL; -} - - -static int -_reload_transvr_obj(struct transvr_obj_s *self, - int new_type){ - - struct eeprom_map_s *new_map_p; - struct eeprom_map_s *old_map_p = self->eeprom_map_p; - struct i2c_client *old_i2c_p = self->i2c_client_p; - int old_type = self->type; - - /* Change state to STATE_TRANSVR_INIT */ - self->state = STATE_TRANSVR_INIT; - self->type = new_type; - /* Replace EEPROME map */ - new_map_p = get_eeprom_map(new_type); - if (!new_map_p){ - goto err_private_reload_func_1; - } - self->eeprom_map_p = new_map_p; - /* Reload i2c client */ - if (setup_i2c_client(self) < 0){ - goto err_private_reload_func_2; - } - /* Replace call back functions */ - if (setup_transvr_public_cb(self, new_type) < 0){ - goto err_private_reload_func_3; - } - if (setup_transvr_private_cb(self, new_type) < 0){ - goto err_private_reload_func_3; - } - kfree(old_i2c_p); - return 0; - -err_private_reload_func_3: - SWPS_INFO("%s: init() fail!\n", __func__); - kfree(old_i2c_p); - self->state = STATE_TRANSVR_UNEXCEPTED; - self->type = TRANSVR_TYPE_ERROR; - return -2; - -err_private_reload_func_2: - self->eeprom_map_p = old_map_p; - self->i2c_client_p = old_i2c_p; -err_private_reload_func_1: - self->state = STATE_TRANSVR_UNEXCEPTED; - self->type = old_type; - SWPS_INFO("%s fail! :0x%02x\n", __func__, new_type); - return -1; -} - - -static int -reload_transvr_obj(struct transvr_obj_s *self, - int new_type){ - - int result_val = ERR_TRANSVR_UNEXCPT; - - /* Reload phase */ - result_val = _reload_transvr_obj(self, new_type); - if (result_val < 0){ - SWPS_INFO("%s: reload phase fail! :%d\n", - __func__, result_val); - return EVENT_TRANSVR_RELOAD_FAIL; - } - /* Initial phase */ - result_val = _transvr_init_handler(self); - if (result_val < 0){ - SWPS_INFO("%s: initial phase fail! :%d\n", - __func__, result_val); - } - return result_val; -} - - -int -isolate_transvr_obj(struct transvr_obj_s *self) { - - self->state = STATE_TRANSVR_ISOLATED; - SWPS_INFO("%s: %s be isolated\n", __func__, self->swp_name); - return 0; -} - - -int -resync_channel_tier_2(struct transvr_obj_s *self) { - - int val = TRANSVR_TYPE_ERROR; - - if (self->state == STATE_TRANSVR_ISOLATED) { - return 0; - } - self->i2c_client_p->addr = VAL_TRANSVR_COMID_ARREESS; - val = i2c_smbus_read_byte_data(self->i2c_client_p, - VAL_TRANSVR_COMID_OFFSET); - if (val < 0) { - return -1; - } - return 0; -} - - -/* ----------------------------------------- - * ToDo List - * ----------------------------------------- - * 1. _sfp_detect_class_by_feature() - * => Need check ACC use case. - * 2. _sfp_detect_class_by_1g_ethernet() - * => Need check 0.1G use case. - * 3. Loopback transceiver use case. - * => Less much data - * 4. _qsfp_detect_class_by_extend_comp() - * => Verify 100G CWDM4 - * => Verify Obsolete (assigned before 100G CWDM4 MSA required FEC) - * => Verify 100G CLR4 - * => Verify 100GE-DWDM2 - * => Verify 40G PSM4 Parallel SMF - * => Verify 100G ACC (Active Copper Cable) or 25GAUI C2M ACC. - * => Verify 100G ACC or 25GAUI C2M ACC. - * => Verify 25GBASE-LR - * => Verify 40G Active Cable (XLPPI) - */ - - - - - - diff --git a/packages/platforms/inventec/x86-64/d5052/modules/builds/src/transceiver.h b/packages/platforms/inventec/x86-64/d5052/modules/builds/src/transceiver.h deleted file mode 100644 index 0dcb9fe6d..000000000 --- a/packages/platforms/inventec/x86-64/d5052/modules/builds/src/transceiver.h +++ /dev/null @@ -1,813 +0,0 @@ -#ifndef TRANSCEIVER_H -#define TRANSCEIVER_H - -#include - -/* advanced features control */ -#define TRANSVR_INFO_DUMP_ENABLE (1) -#define TRANSVR_INFO_CACHE_ENABLE (1) -#define TRANSVR_UEVENT_ENABLE (1) - -/* Transceiver type define */ -#define TRANSVR_TYPE_UNKNOW_1 (0x00) -#define TRANSVR_TYPE_UNKNOW_2 (0xff) -#define TRANSVR_TYPE_SFP (0x03) /* Define for SFP, SFP+, SFP28 */ -#define TRANSVR_TYPE_QSFP (0x0c) -#define TRANSVR_TYPE_QSFP_PLUS (0x0d) -#define TRANSVR_TYPE_QSFP_28 (0x11) -#define TRANSVR_TYPE_UNPLUGGED (0xfa) /* Define for ERROR handle */ -#define TRANSVR_TYPE_FAKE (0xfc) /* Define for ERROR handle */ -#define TRANSVR_TYPE_INCONSISTENT (0xfd) /* Define for ERROR handle */ -#define TRANSVR_TYPE_ERROR (0xfe) /* Define for ERROR handle */ - -/* Transceiver class for base info */ -#define TRANSVR_CLASS_UNSPECIFIED (0) -#define TRANSVR_CLASS_ERROR (-26001) -#define TRANSVR_CLASS_1G (26001) -#define TRANSVR_CLASS_10G (26011) -#define TRANSVR_CLASS_25G (26021) -#define TRANSVR_CLASS_40G (26041) -#define TRANSVR_CLASS_100G (26101) -#define TRANSVR_CLASS_NO_SPERARABLE (26901) -#define TRANSVR_CLASS_EXTEND_COMP (26902) -/* Transceiver class for Optical 1G */ -#define TRANSVR_CLASS_OPTICAL (27000) -#define TRANSVR_CLASS_OPTICAL_100 (27001) -#define TRANSVR_CLASS_OPTICAL_1G (27002) -#define TRANSVR_CLASS_OPTICAL_1G_AOC (27003) -#define TRANSVR_CLASS_OPTICAL_1G_SX (27004) -#define TRANSVR_CLASS_OPTICAL_1G_LX (27005) -#define TRANSVR_CLASS_OPTICAL_1G_EX (27006) -/* Transceiver class for Optical 10G */ -#define TRANSVR_CLASS_OPTICAL_10G (27010) -#define TRANSVR_CLASS_OPTICAL_10G_S_AOC (27011) -#define TRANSVR_CLASS_OPTICAL_10G_S_SR (27012) -#define TRANSVR_CLASS_OPTICAL_10G_S_LR (27013) -#define TRANSVR_CLASS_OPTICAL_10G_S_ER (27014) -#define TRANSVR_CLASS_OPTICAL_10G_Q_AOC (27015) -#define TRANSVR_CLASS_OPTICAL_10G_Q_SR (27016) -#define TRANSVR_CLASS_OPTICAL_10G_Q_LR (27017) -#define TRANSVR_CLASS_OPTICAL_10G_Q_ER (27018) -/* Transceiver class for Optical 25G */ -#define TRANSVR_CLASS_OPTICAL_25G (27020) -#define TRANSVR_CLASS_OPTICAL_25G_AOC (27021) -#define TRANSVR_CLASS_OPTICAL_25G_SR (27022) -#define TRANSVR_CLASS_OPTICAL_25G_LR (27023) -#define TRANSVR_CLASS_OPTICAL_25G_ER (27024) -/* Transceiver class for Optical 40G */ -#define TRANSVR_CLASS_OPTICAL_40G (27040) -#define TRANSVR_CLASS_OPTICAL_40G_AOC (27041) -#define TRANSVR_CLASS_OPTICAL_40G_SR4 (27042) -#define TRANSVR_CLASS_OPTICAL_40G_LR4 (27043) -#define TRANSVR_CLASS_OPTICAL_40G_ER4 (27044) -/* Transceiver class for Optical 100G */ -#define TRANSVR_CLASS_OPTICAL_100G (27100) -#define TRANSVR_CLASS_OPTICAL_100G_AOC (27101) -#define TRANSVR_CLASS_OPTICAL_100G_SR4 (27102) -#define TRANSVR_CLASS_OPTICAL_100G_LR4 (27103) -#define TRANSVR_CLASS_OPTICAL_100G_ER4 (27104) -#define TRANSVR_CLASS_OPTICAL_100G_PSM4 (27105) -/* Transceiver class for Copper */ -#define TRANSVR_CLASS_COPPER (28000) -#define TRANSVR_CLASS_COPPER_L1_1G (28001) -#define TRANSVR_CLASS_COPPER_L1_10G (28011) -#define TRANSVR_CLASS_COPPER_L4_10G (28012) -#define TRANSVR_CLASS_COPPER_L1_25G (28021) -#define TRANSVR_CLASS_COPPER_L4_40G (28041) -#define TRANSVR_CLASS_COPPER_L4_100G (28101) -/* Transceiver class for Base-T */ -#define TRANSVR_CLASS_BASE_T_1000 (29001) -#define TRANSVR_CLASS_BASE_T_1000_up (29002) -/* For uevent message */ -#define TRANSVR_UEVENT_KEY_IF "IF_TYPE" -#define TRANSVR_UEVENT_KEY_SP "IF_SPEED" -#define TRANSVR_UEVENT_KEY_LANE "IF_LANE" -#define TRANSVR_UEVENT_UNKNOW "UNKNOW" -#define TRANSVR_IF_KR "KR" -#define TRANSVR_IF_KR4 "KR4" -#define TRANSVR_IF_SR "SR" -#define TRANSVR_IF_SR4 "SR4" -#define TRANSVR_IF_SFI "SFI" -#define TRANSVR_IF_IF_GMII "GMII" -#define TRANSVR_IF_IF_XGMII "XGMII" -#define TRANSVR_IF_SP_100 "100" -#define TRANSVR_IF_SP_1G "1000" -#define TRANSVR_IF_SP_10G "10000" -#define TRANSVR_IF_SP_25G "25000" -#define TRANSVR_IF_SP_40G "40000" -#define TRANSVR_IF_SP_100G "100000" - -/* Transceiver mode define */ -#define TRANSVR_MODE_DIRECT (21000) -#define TRANSVR_MODE_POLLING (21001) - -/* Transceiver state define - * [Note] - * 1. State is used to represent the state of "Transceiver" and "Object". - * 2. State for different target has different means. The description as following: - */ -#define STATE_TRANSVR_CONNECTED (0) /* [Transvr]:Be plugged in. [Obj]:Link up, and work normally. */ -#define STATE_TRANSVR_NEW (-100) /* [Transvr]:(Not used) [Obj]:Create */ -#define STATE_TRANSVR_INIT (-101) /* [Transvr]:Be plugged in. [Obj]:Link up, and in initial process. */ -#define STATE_TRANSVR_ISOLATED (-102) /* [Transvr]:Be plugged in. [Obj]:Isolate, and not provide service. */ -#define STATE_TRANSVR_SWAPPED (-200) /* [Transvr]:Be plugged in. [Obj]:(Not used) */ -#define STATE_TRANSVR_DISCONNECTED (-300) /* [Transvr]:Un-plugged. [Obj]:Link down, and not provide service. */ -#define STATE_TRANSVR_UNEXCEPTED (-901) /* [Transvr]:Any [Obj]:Any, and not in expect case. */ - -/* Task state define */ -#define STATE_T_TASK_WAIT (110) -#define STATE_T_TASK_DONE (0) -#define STATE_T_TASK_INIT (-110) -#define STATE_T_TASK_FAIL (-410) - - -/* Event for task handling */ -#define EVENT_TRANSVR_TASK_WAIT (2101) -#define EVENT_TRANSVR_TASK_DONE (0) -#define EVENT_TRANSVR_TASK_FAIL (-2101) -/* Event for initial handling */ -#define EVENT_TRANSVR_INIT_UP (2201) -#define EVENT_TRANSVR_INIT_DOWN (1) -#define EVENT_TRANSVR_INIT_REINIT (-2201) -#define EVENT_TRANSVR_INIT_FAIL (-2202) -/* Event for others */ -#define EVENT_TRANSVR_RELOAD_FAIL (-2301) -#define EVENT_TRANSVR_EXCEP_INIT (-2401) -#define EVENT_TRANSVR_EXCEP_UP (-2402) -#define EVENT_TRANSVR_EXCEP_DOWN (-2403) -#define EVENT_TRANSVR_EXCEP_SWAP (-2404) -#define EVENT_TRANSVR_EXCEP_EXCEP (-2405) -#define EVENT_TRANSVR_EXCEP_ISOLATED (-2406) -#define EVENT_TRANSVR_I2C_CRASH (-2501) - -/* Transceiver error code define */ -#define ERR_TRANSVR_UNINIT (-201) -#define ERR_TRANSVR_UNPLUGGED (-202) -#define ERR_TRANSVR_ABNORMAL (-203) -#define ERR_TRANSVR_NOSTATE (-204) -#define ERR_TRANSVR_NOTSUPPORT (-205) -#define ERR_TRANSVR_BADINPUT (-206) -#define ERR_TRANSVR_UPDATE_FAIL (-207) -#define ERR_TRANSVR_RELOAD_FAIL (-208) -#define ERR_TRANSVR_INIT_FAIL (-209) -#define ERR_TRANSVR_UNDEFINED (-210) -#define ERR_TRANSVR_TASK_FAIL (-211) -#define ERR_TRANSVR_TASK_BUSY (-212) -#define ERR_TRANSVR_UEVENT_FAIL (-213) -#define ERR_TRANSVR_FUNC_DISABLE (-214) -#define ERR_TRANSVR_I2C_CRASH (-297) -#define ERR_TRNASVR_BE_ISOLATED (-298) -#define ERR_TRANSVR_UNEXCPT (-299) - -/* For debug */ -#define DEBUG_TRANSVR_INT_VAL (-99) -#define DEBUG_TRANSVR_HEX_VAL (0xfe) -#define DEBUG_TRANSVR_STR_VAL "ERROR" - -/* For system internal */ -#define VAL_TRANSVR_COMID_ARREESS (0x50) -#define VAL_TRANSVR_COMID_OFFSET (0x00) -#define VAL_TRANSVR_EXTPHY_ADDR_56 (0x56) -#define VAL_TRANSVR_8472_READY_ADDR (0x51) -#define VAL_TRANSVR_8472_READY_PAGE (-1) -#define VAL_TRANSVR_8472_READY_OFFSET (110) -#define VAL_TRANSVR_8472_READY_BIT (0) -#define VAL_TRANSVR_8472_READY_VALUE (0) -#define VAL_TRANSVR_8472_READY_ABNORMAL (0xff) -#define VAL_TRANSVR_8436_READY_ADDR (0x50) -#define VAL_TRANSVR_8436_READY_PAGE (-1) -#define VAL_TRANSVR_8436_READY_OFFSET (2) -#define VAL_TRANSVR_8436_READY_BIT (0) -#define VAL_TRANSVR_8436_READY_VALUE (0) -#define VAL_TRANSVR_8436_READY_ABNORMAL (0xff) -#define VAL_TRANSVR_8436_PWD_ADDR (0x50) -#define VAL_TRANSVR_8436_PWD_PAGE (-1) -#define VAL_TRANSVR_8436_PWD_OFFSET (123) -#define VAL_TRANSVR_PAGE_FREE (-99) -#define VAL_TRANSVR_PAGE_SELECT_OFFSET (127) -#define VAL_TRANSVR_PAGE_SELECT_DELAY (5) -#define VAL_TRANSVR_TASK_RETRY_FOREVER (-999) -#define VAL_TRANSVR_FUNCTION_DISABLE (-1) -#define STR_TRANSVR_SFP "SFP" -#define STR_TRANSVR_QSFP "QSFP" -#define STR_TRANSVR_QSFP_PLUS "QSFP+" -#define STR_TRANSVR_QSFP28 "QSFP28" - -/* For transvr buf len */ -#define LEN_TRANSVR_S_STR (16) -#define LEN_TRANSVR_M_STR (32) -#define LEN_TRANSVR_L_STR (64) - -/* Optical wavelength */ -#define VAL_OPTICAL_WAVELENGTH_SR (850) -#define VAL_OPTICAL_WAVELENGTH_LR (1310) -#define VAL_OPTICAL_WAVELENGTH_ER (1550) - -/* BCM chip type define */ -#define BCM_CHIP_TYPE_TRIDENT_2 (31001) /* Magnolia, Hudson32i, Spruce */ -#define BCM_CHIP_TYPE_TOMAHAWK (31002) /* Redwood, Cypress, Sequoia */ - -#define BF_CHIP_TYPE_TOFINO (31011) /* Lavender */ - -/* Info from transceiver EEPROM */ -struct eeprom_map_s { - int addr_br; int page_br; int offset_br; int length_br; - int addr_cdr; int page_cdr; int offset_cdr; int length_cdr; - int addr_comp_rev; int page_comp_rev; int offset_comp_rev; int length_comp_rev; - int addr_connector; int page_connector; int offset_connector; int length_connector; - int addr_diag_type; int page_diag_type; int offset_diag_type; int length_diag_type; - int addr_extbr; int page_extbr; int offset_extbr; int length_extbr; - int addr_ext_id; int page_ext_id; int offset_ext_id; int length_ext_id; - int addr_id; int page_id; int offset_id; int length_id; - int addr_len_sm; int page_len_sm; int offset_len_sm; int length_len_sm; - int addr_len_smf; int page_len_smf; int offset_len_smf; int length_len_smf; - int addr_len_om1; int page_len_om1; int offset_len_om1; int length_len_om1; - int addr_len_om2; int page_len_om2; int offset_len_om2; int length_len_om2; - int addr_len_om3; int page_len_om3; int offset_len_om3; int length_len_om3; - int addr_len_om4; int page_len_om4; int offset_len_om4; int length_len_om4; - int addr_option; int page_option; int offset_option; int length_option; - int addr_rate_id; int page_rate_id; int offset_rate_id; int length_rate_id; - int addr_rx_am; int page_rx_am; int offset_rx_am; int length_rx_am; - int addr_rx_em; int page_rx_em; int offset_rx_em; int length_rx_em; - int addr_rx_los; int page_rx_los; int offset_rx_los; int length_rx_los; - int addr_rx_power; int page_rx_power; int offset_rx_power; int length_rx_power; - int addr_soft_rs0; int page_soft_rs0; int offset_soft_rs0; int length_soft_rs0; - int addr_soft_rs1; int page_soft_rs1; int offset_soft_rs1; int length_soft_rs1; - int addr_temp; int page_temp; int offset_temp; int length_temp; - int addr_trancomp; int page_trancomp; int offset_trancomp; int length_trancomp; - int addr_trancomp_ext; int page_trancomp_ext; int offset_trancomp_ext; int length_trancomp_ext; - int addr_tx_bias; int page_tx_bias; int offset_tx_bias; int length_tx_bias; - int addr_tx_disable; int page_tx_disable; int offset_tx_disable; int length_tx_disable; - int addr_tx_eq; int page_tx_eq; int offset_tx_eq; int length_tx_eq; - int addr_tx_fault; int page_tx_fault; int offset_tx_fault; int length_tx_fault; - int addr_tx_power; int page_tx_power; int offset_tx_power; int length_tx_power; - int addr_vendor_name; int page_vendor_name; int offset_vendor_name; int length_vendor_name; - int addr_vendor_pn; int page_vendor_pn; int offset_vendor_pn; int length_vendor_pn; - int addr_vendor_rev; int page_vendor_rev; int offset_vendor_rev; int length_vendor_rev; - int addr_vendor_sn; int page_vendor_sn; int offset_vendor_sn; int length_vendor_sn; - int addr_voltage; int page_voltage; int offset_voltage; int length_voltage; - int addr_wavelength; int page_wavelength; int offset_wavelength; int length_wavelength; - int addr_eeprom; int page_eeprom; int offset_eeprom; int length_eeprom; - int addr_uppage; int page_uppage; int offset_uppage; int length_uppage; -}; - - -struct transvr_worker_s; - -/* Class of transceiver object */ -struct transvr_obj_s { - - /* ========== Object private property ========== - * [Prop]: id - * [Desc]: Type of serial transceiver. - * [Note]: SFP:03h / QSFP:0Ch / QSPF+:0Dh /QSFP28:11h - */ - uint8_t id; - - /* [Prop]: connector - * [Desc]: Connector type. - * [Note]: SFP : A0h / 2 - * QSFP: 00h / 130 - */ - uint8_t connector; - - /* [Prop]: transvr_comp - * [Desc]: Transceiver compliance code. - * [Note]: SFP: SFF-8472 - * - Normal : A0h / offset 3-10 - * - Extended: A0h / offset 36 - * QSFP: SFF-8436 & SFF-8636 - * - Normal : 00h / offset 131-138 - * - Extended: 00h / offset 192 - */ - uint8_t transvr_comp[8]; - uint8_t transvr_comp_ext; - - /* [Prop]: vendor_name - * [Desc]: SFP vendor name (ASCII 16 byte char). - * [Note]: ex:FINISAR CORP. - */ - char *vendor_name; - - /* [Prop]: vendor_pn - * [Desc]: Part number provided by SFP vendor (ASCII 16 byte char). - * [Note]: - */ - char *vendor_pn; - - /* [Prop]: vendor_rev - * [Desc]: Revision level for part number provided by vendor (ASCII 4 byte char). - * [Note]: - */ - char *vendor_rev; - - /* [Prop]: vendor_sn - * [Desc]: Serial number provided by vendor (ASCII 16 byte char). - * [Note]: - */ - char *vendor_sn; - - /* [Prop]: Extended identifier - * [Desc]: SFP: - * => None - * - * QSFP: - * => This byte contained two information: - * (1) Power consumption class - * (2) CDR function present - * [Note]: Bit description as below: - * [SFP] - * None - * - * [QSFP] - * (1) Power consumption class: - * Class 1: 1.5W (Bit6-7 = 00:) - * Class 2: 2.0W (Bit6-7 = 01:) - * Class 3: 2.5W (Bit6-7 = 10:) - * Class 4: 3.5W (Bit6-7 = 11:) - * Class 5: 4.0W (Bit0-1 = 01:) - * Class 6: 4.5W (Bit0-1 = 10:) - * Class 7: 5.0W (Bit0-1 = 11:) - * (2) CDR function present: - * Bit2: 0 = No CDR in RX - * 1 = CDR present in RX - * Bit3: 0 = No CDR in TX - * 1 = CDR present in TX - */ - uint8_t ext_id; - - /* [Prop]: br - * [Desc]: Nominal bit rate, units of 100 MBits/sec. - * [Note]: SFP:03h / QSFP:0Ch / QSPF+:0Dh - * has val: 0x67 - * no val : - */ - uint8_t br; - - /* [Prop]: extbr - * [Desc]: Extended br (00h/222) - * [Desc]: Nominal bit rate per channel, units of 250 Mbps. - * Complements. Byte 140. See Table 32A. - */ - uint8_t extbr; - - /* [Prop]: len_sm - * [Desc]: Length (single mode)-(100's)m - * [Note]: This value specifies the link length that is supported by the transceiver - * while operating in compliance with the applicable standards using single mode - * fiber. The value is in units of 100 meters. A value of 255 means that the - * transceiver supports a link length greater than 25.4 km. A value of zero means - * that the transceiver does not support single mode fiber or that the length - * information must be determined from the transceiver technology. - */ - int len_sm; - - /* [Prop]: len_smf - * [Desc]: Length (single mode)-km - * [Note]: Addition to EEPROM data from original GBIC definition. This value specifies - * the link length that is supported by the transceiver while operating in - * compliance with the applicable standards using single mode fiber. The value - * is in units of kilometers. A value of 255 means that the transceiver supports - * a link length greater than 254 km. A value of zero means that the transceiver - * does not support single mode fiber or that the length information must be - * determined from the transceiver technology. - */ - int len_smf; - - /* [Prop]: len_om1 - * [Desc]: Link length supported for 62.5 um OM1 fiber, units of 10 m - * [Note]: The value is in units of 10 meters. A value of 255 means that the - * transceiver supports a link length greater than 2.54 km. A value of - * zero means that the transceiver does not support 50 micron multi-mode - * fiber or that the length information must be determined from the transceiver - * technology. - */ - int len_om1; - - /* [Prop]: len_om2 - * [Desc]: Link length supported for 50 um OM2 fiber, units of 10 m - * [Note]: The value is in units of 10 meters. A value of 255 means that the - * transceiver supports a link length greater than 2.54 km. A value of - * zero means that the transceiver does not support 50 micron multi-mode - * fiber or that the length information must be determined from the transceiver - * technology. - */ - int len_om2; - - /* [Prop]: len_om3 - * [Desc]: Length (50um, OM3) - * [Note]: This value specifies link length that is supported by the transceiver while - * operating in compliance with applicable standards using 50 micron multimode - * OM3 [2000 MHz*km] fiber. The value is in units of 10 meters. A value of 255 - * means that the transceiver supports a link length greater than 2.54 km. A value - * of zero means that the transceiver does not support 50 micron multimode fiber - * or that the length information must be determined from the transceiver technology. - */ - int len_om3; - - /* [Prop]: len_om4 - * [Desc]: Length (50um, OM4) and Length (Active Cable or Copper) - * [Note]: For optical links, this value specifies link length that is supported by the - * transceiver while operating in compliance with applicable standards using 50 micron - * multimode OM4 [4700 MHz*km] fiber. The value is in units of 10 meters. A value of - * 255 means that the transceiver supports a link length greater than 2.54 km. A value - * of zero means that the transceiver does not support 50 micron multimode fiber or that - * the length information must be determined from the transceiver codes specified in Table 5-3. - * - * For copper links, this value specifies minimum link length supported by the transceiver - * while operating in compliance with applicable standards using copper cable. For active - * cable, this value represents actual length. The value is in units of 1 meter. A value of 255 - * means the transceiver supports a link length greater than 254 meters. A value of zero means - * the transceiver does not support copper or active cables or the length information must be - * determined from transceiver technology. Further information about cable design, equalization, - * and connectors is usually required to guarantee meeting a particular length requirement. - */ - int len_om4; - - /* [Prop]: comp_rev - * [Desc]: SFF spec revision compliance - * [Note]: Indicates which revision of SFF SFF-8472 (SFP) / SFF-8636 (QSFP) the transceiver - * complies with. (unsigned integer) - */ - uint8_t comp_rev; - - /* [Prop]: CDR - * [Desc]: For transceivers with CDR capability, setting the CDR to ON engages the internal - * retiming function. Setting the CDR to OFF enables an internal bypassing mode ,which - * directs traffic around the internal CDR. (Reference: SFF-8636) - * [Note]: value=0xff: ON. - * value=0x00: OFF. - */ - uint8_t cdr; - - /* [Prop]: rate_id - * [Desc]: Soft Rate Select 0(RX). - * [Note]: 1. Addr: A0h / Offset: 13 - * 2. Value description: - * 00h Unspecified - * 01h SFF-8079 (4/2/1G Rate_Select & AS0/AS1) - * 02h SFF-8431 (8/4/2G Rx Rate_Select only) - * 03h Unspecified * - * 04h SFF-8431 (8/4/2G Tx Rate_Select only) - * 05h Unspecified * - * 06h SFF-8431 (8/4/2G Independent Rx & Tx Rate_select) - * 07h Unspecified * - * 08h FC-PI-5 (16/8/4G Rx Rate_select only) High=16G only, Low=8G/4G - * 09h Unspecified * - * 0Ah FC-PI-5 (16/8/4G Independent Rx, Tx Rate_select) High=16G only, - * Low=8G/4G - * 0Bh Unspecified * - * 0Ch FC-PI-6 (32/16/8G Independent Rx, Tx Rate_Select) - * High=32G only, Low = 16G/8G - * 0Dh Unspecified * - * 0Eh 10/8G Rx and Tx Rate_Select controlling the operation or locking - * modes of the internal signal conditioner, retimer or CDR, according - * to the logic table defined in Table 10-2, High Bit Rate - * (10G) =9.95-11.3 Gb/s; Low Bit Rate (8G) = 8.5 Gb/s. In this mode, - * the default value of bit 110.3 (Soft Rate Select RS(0), Table 9-11) - * and of bit 118.3 (Soft Rate Select RS(1), Table 10-1) is 1. - * 0Fh Unspecified * - * 10h-FFh Unallocated - */ - int rate_id; - - /* [Prop]: soft_rs0 - * [Desc]: Soft Rate Select 0(RX). - * [Note]: 1. Writing '1' selects full bandwidth operation. - * 2. This bit is "OR'd with the hard Rate_Select, AS(0) or RS(0) pin value. - * 3. Default at power up is logic zero/low - * 4. Addr: A2h / Offset: 110 / Bit: 3 - */ - uint8_t soft_rs0; - - /* [Prop]: soft_rs1 - * [Desc]: Soft Rate Select 1(TX). - * [Note]: 1. Writing '1' selects full bandwidth TX operation. - * 2. This bit is "OR'd with the hard Rate_Select, AS(1) or RS(1) pin value. - * 3. Default at power up is logic zero/low - * 4. Addr: A2h / Offset: 118 / Bit: 3 - */ - uint8_t soft_rs1; - - /* [Prop]: diag_type - * [Desc]: DIAGNOSTIC MONITORING TYPE (A0h/92) - * [Note]: Description in SFF-8472 as below: - * Bit7: Reserved for legacy diagnostic implementations. Must be '0' for compliance - * with this document. - * Bit6: Digital diagnostic monitoring implemented (described in this document). - * Must be '1' for compliance with this document. - * Bit5 Internally calibrated - * Bit4 Externally calibrated - * Bit3 Received power measurement type.0 = OMA, 1 = average power - * Bit2 Address change required see section above, "addressing modes" - * Bit1-0 Unallocated - */ - uint8_t diag_type; - - /* [Prop]: curr_temp - * [Desc]: Transceiver Current Temperature (A2h/96-97) - * [Note]: 1. Dependent on diag_type. - * 2. 96: High byte - * 3. 97: Low byte - * 4. This feature only for SFP - */ - uint8_t curr_temp[2]; - - /* [Prop]: curr_vol - * [Desc]: Transceiver Current Voltage (SFP:A2h/108-109; QSFP:00h/22-23) - * [Note]: 1. Dependent on diag_type. - * 2. 98: High byte - * 3. 99: Low byte - * 4. This feature only for SFP - * 5. Internally measured transceiver supply voltage. Represented - * as a 16 bit unsigned integer with the voltage defined as the - * full 16 bit value (0-65535) with LSB equal to 100 uVolt, - * yielding a total range of 0 to +6.55 Volts - */ - uint8_t curr_voltage[2]; - - /* [Prop]: curr_tx_bias - * [Desc]: Transceiver TX Bias Current (SFP:A2h/100-101; QSFP:00h/26-27) - * [Note]: 1. Dependent on diag_type. - * 2. 100: High byte - * 3. 101: Low byte - * 4. This feature only for SFP - * 5. Measured TX bias current in uA. Represented as a 16 bit unsigned - * integer with the current defined as the full 16 bit value (0-65535) - * with LSB equal to 2 uA, yielding a total range of 0 to 131 mA. - * Accuracy is vendor specific but must be better than 10% of the - * manufacturer's nominal value over specified operating temperature - * and voltage. - */ - uint8_t curr_tx_bias[8]; - - /* [Prop]: curr_tx_power - * [Desc]: Transceiver TX Output Power (A2h/102-103) - * [Note]: 1. Dependent on diag_type. - * 2. 102: High byte - * 3. 103: Low byte - * 4. This feature only for SFP - * 5. Measured TX output power in mW. Represented as a 16 bit unsigned - * integer with the power defined as the full 16 bit value (0-65535) - * with LSB equal to 0.1 uW, yielding a total range of 0 to 6.5535 mW - * (~ -40 to +8.2 dBm). Data is assumed to be based on measurement of - * laser monitor photodiode current. It is factory calibrated to absolute - * units using the most representative fiber output type. Accuracy is - * vendor specific but must be better than 3dB over specified temperature - * and voltage. Data is not valid when the transmitter is disabled. - */ - uint8_t curr_tx_power[8]; - - /* [Prop]: curr_tx_power - * [Desc]: Transceiver TX Output Power (A2h/102-103) - * [Note]: 1. Dependent on diag_type. - * 2. 102: High byte - * 3. 103: Low byte - * 4. This feature only for SFP - * 5. Measured RX received optical power in mW. Value can represent either - * average received power or OMA depending upon how bit 3 of byte 92 (A0h) - * is set. Represented as a 16 bit unsigned integer with the power defined - * as the full 16 bit value (0-65535) with LSB equal to 0.1 uW, yielding a - * total range of 0 to 6.5535 mW (~ -40 to +8.2 dBm). Absolute accuracy is - * dependent upon the exact optical wavelength. For the vendor specified - * wavelength, accuracy shall be better than 3dB over specified temperature - * and voltage. - */ - uint8_t curr_rx_power[8]; - - /* [Prop]: wavelength - * [Desc]: Wavelength or Copper Cable Attenuation - * [Note]: (Following is info from SFF-8636) - * For optical free side devices, this parameter identifies the nominal - * transmitter output wavelength at room temperature. This parameter is a - * 16-bit hex value with Byte 186 as high order byte and Byte 187 as low - * order byte. The laser wavelength is equal to the 16-bit integer value - * divided by 20 in nm (units of 0.05 nm). This resolution should be adequate - * to cover all relevant wavelengths yet provide enough resolution for all - * expected DWDM applications. For accurate representation of controlled - * wavelength applications, this value should represent the center of the - * guaranteed wavelength range. If the free side device is identified as - * copper cable these registers will be used to define the cable attenuation. - * An indication of 0 dB attenuation refers to the case where the attenuation - * is not known or is unavailable. - * Byte 186 (00-FFh) is the copper cable attenuation at 2.5 GHz in units of 1 dB. - * Byte 187 (00-FFh) is the copper cable attenuation at 5.0 GHz in units of 1 dB. - */ - uint8_t wavelength[2]; - - /* [Prop]: Amplitude control - * [Desc]: Amplitude control - * [Note]: QSFP28 => SFF-8636 03H Byte-238/239 - */ - uint8_t rx_am[2]; - - /* [Prop]: Emphasis control - * [Desc]: Emphasis control - * [Note]: SFP+/28 => SFF-8472 A2H Byte-115 - * QSFP28 => SFF-8636 03H Byte-236/237 - */ - uint8_t rx_em[2]; - - /* [Prop]: Soft Rx LOS - * [Desc]: Soft Rx LOS which provide by transceiver - * [Note]: (Following is info from SFF-8636) - * Byte 3: - * - Bit 0: L-Rx1 LOS - * - Bit 1: L-Rx2 LOS - * - Bit 2: L-Rx3 LOS - * - Bit 3: L-Rx4 LOS - */ - uint8_t rx_los; - - /* [Prop]: Soft Tx Disable - * [Desc]: Soft Tx Disable which provide by transceiver - * [Note]: (Following is info from SFF-8636) - * Byte 86: - * - Bit 0: Tx1 Disable - * - Bit 1: Tx2 Disable - * - Bit 2: Tx3 Disable - * - Bit 3: Tx4 Disable - */ - uint8_t tx_disable; - - /* [Prop]: Soft Tx Fault - * [Desc]: Soft Tx Fault which provide by transceiver - * [Note]: (Following is info from SFF-8636) - * Byte 86: - * - Bit 0: Tx1 Fault - * - Bit 1: Tx2 Fault - * - Bit 2: Tx3 Fault - * - Bit 3: Tx4 Fault - */ - uint8_t tx_fault; - - /* [Prop]: Transceiver EQUALIZATION - * [Desc]: Transceiver EQUALIZATION - * [Note]: SFP+/28 => SFF-8472 A2H Byte-114 - * QSFP28 => SFF-8636 03H Byte-234/235 - */ - uint8_t tx_eq[2]; - - /* [Prop]: OPTION VALUES - * [Desc]: The bits in the option field shall specify the options implemented in the transceiver. - * [Note]: SFP+/28 => SFF-8472 A0H Byte-64/65 - * QSFP+/28 => SFF-8636 00H Byte-193/195 - */ - uint8_t option[3]; - - /* [Prop]: External PHY offset - * [Desc]: It needs to be setup first if you want to access transceiver external phy. - * [Note]: This feature dependent on transceiver. - * Currently, only 1G-RJ45 transceiver supported it. - */ - uint8_t extphy_offset; - - uint8_t eeprom[130]; - - /* ========== Object private property ========== - */ - struct device *transvr_dev_p; - struct eeprom_map_s *eeprom_map_p; - struct i2c_client *i2c_client_p; - struct ioexp_obj_s *ioexp_obj_p; - struct transvr_worker_s *worker_p; - struct mutex lock; - char swp_name[32]; - int auto_config; - int auto_tx_disable; - int chan_id; - int chipset_type; - int curr_page; - int info; - int ioexp_virt_offset; - int lane_id[8]; - int layout; - int mode; - int retry; - int state; - int temp; - int type; - - /* ========== Object public functions ========== - */ - int (*get_id)(struct transvr_obj_s *self); - int (*get_ext_id)(struct transvr_obj_s *self); - int (*get_connector)(struct transvr_obj_s *self); - int (*get_vendor_name)(struct transvr_obj_s *self, char *buf_p); - int (*get_vendor_pn)(struct transvr_obj_s *self, char *buf_p); - int (*get_vendor_rev)(struct transvr_obj_s *self, char *buf_p); - int (*get_vendor_sn)(struct transvr_obj_s *self, char *buf_p); - int (*get_power_cls)(struct transvr_obj_s *self); - int (*get_br)(struct transvr_obj_s *self); - int (*get_len_sm)(struct transvr_obj_s *self); - int (*get_len_smf)(struct transvr_obj_s *self); - int (*get_len_om1)(struct transvr_obj_s *self); - int (*get_len_om2)(struct transvr_obj_s *self); - int (*get_len_om3)(struct transvr_obj_s *self); - int (*get_len_om4)(struct transvr_obj_s *self); - int (*get_comp_rev)(struct transvr_obj_s *self); - int (*get_comp_eth_1)(struct transvr_obj_s *self); - int (*get_comp_eth_10)(struct transvr_obj_s *self); - int (*get_comp_eth_10_40)(struct transvr_obj_s *self); - int (*get_comp_extend)(struct transvr_obj_s *self); - int (*get_cdr)(struct transvr_obj_s *self); - int (*get_rate_id)(struct transvr_obj_s *self); - int (*get_soft_rs0)(struct transvr_obj_s *self); - int (*get_soft_rs1)(struct transvr_obj_s *self); - int (*get_info)(struct transvr_obj_s *self); - int (*get_if_type)(struct transvr_obj_s *self, char *buf_p); - int (*get_if_speed)(struct transvr_obj_s *self, char *buf_p); - int (*get_if_lane)(struct transvr_obj_s *self, char *buf_p); - int (*get_curr_temp)(struct transvr_obj_s *self, char *buf_p); - int (*get_curr_vol)(struct transvr_obj_s *self, char *buf_p); - int (*get_soft_rx_los)(struct transvr_obj_s *self, char *buf_p); - int (*get_soft_tx_disable)(struct transvr_obj_s *self, char *buf_p); - int (*get_soft_tx_fault)(struct transvr_obj_s *self, char *buf_p); - int (*get_auto_tx_disable)(struct transvr_obj_s *self, char *buf_p); - int (*get_tx_bias)(struct transvr_obj_s *self, char *buf_p); - int (*get_tx_power)(struct transvr_obj_s *self, char *buf_p); - int (*get_rx_power)(struct transvr_obj_s *self, char *buf_p); - int (*get_tx_eq)(struct transvr_obj_s *self, char *buf_p); - int (*get_rx_am)(struct transvr_obj_s *self, char *buf_p); - int (*get_rx_em)(struct transvr_obj_s *self, char *buf_p); - int (*get_wavelength)(struct transvr_obj_s *self, char *buf_p); - int (*get_extphy_offset)(struct transvr_obj_s *self, char *buf_p); - int (*get_extphy_reg)(struct transvr_obj_s *self, char *buf_p); - int (*set_cdr)(struct transvr_obj_s *self, int input_val); - int (*set_soft_rs0)(struct transvr_obj_s *self, int input_val); - int (*set_soft_rs1)(struct transvr_obj_s *self, int input_val); - int (*set_soft_tx_disable)(struct transvr_obj_s *self, int input_val); - int (*set_auto_tx_disable)(struct transvr_obj_s *self, int input_val); - int (*set_tx_eq)(struct transvr_obj_s *self, int input_val); - int (*set_rx_am)(struct transvr_obj_s *self, int input_val); - int (*set_rx_em)(struct transvr_obj_s *self, int input_val); - int (*set_extphy_offset)(struct transvr_obj_s *self, int input_val); - int (*set_extphy_reg)(struct transvr_obj_s *self, int input_val); - int (*get_eeprom)(struct transvr_obj_s *self, char *buf_p); - int (*get_uppage)(struct transvr_obj_s *self, char *buf_p); - - /* ========== Object private functions ========== - */ - int (*init)(struct transvr_obj_s *self); - int (*clean)(struct transvr_obj_s *self); - int (*check)(struct transvr_obj_s *self); - int (*update_all)(struct transvr_obj_s *self, int show_err); - int (*fsm_4_direct)(struct transvr_obj_s* self, char *caller_name); - int (*fsm_4_polling)(struct transvr_obj_s* self, char *caller_name); - int (*send_uevent)(struct transvr_obj_s* self, enum kobject_action u_action); - int (*dump_all)(struct transvr_obj_s* self); -}; - - -/* For AVL Mapping */ -struct transvr_avl_s { - char vendor_name[32]; - char vendor_pn[32]; - int (*init)(struct transvr_obj_s *self); -}; - - -/* Worker for long term task of transceiver */ -struct transvr_worker_s { - /* Task Parameter */ - struct transvr_obj_s *transvr_p; - struct transvr_worker_s *next_p; - struct transvr_worker_s *pre_p; - unsigned long trigger_time; - char func_name[64]; - int retry; - int state; - - /* Task private data */ - void *p_data; - - /* Call back function */ - int (*main_task)(struct transvr_worker_s *task); - int (*post_task)(struct transvr_worker_s *task); -}; - - -struct transvr_obj_s * -create_transvr_obj(char *swp_name, - int chan_id, - struct ioexp_obj_s *ioexp_obj_p, - int ioexp_virt_offset, - int transvr_type, - int chipset_type, - int run_mode); - -void lock_transvr_obj(struct transvr_obj_s *self); -void unlock_transvr_obj(struct transvr_obj_s *self); -int isolate_transvr_obj(struct transvr_obj_s *self); - -int resync_channel_tier_2(struct transvr_obj_s *self); - -void alarm_msg_2_user(struct transvr_obj_s *self, char *emsg); - -#endif /* TRANSCEIVER_H */ - - - - - - diff --git a/packages/platforms/inventec/x86-64/d5052/onlp/Makefile b/packages/platforms/inventec/x86-64/d5052/onlp/Makefile deleted file mode 100644 index 003238cf6..000000000 --- a/packages/platforms/inventec/x86-64/d5052/onlp/Makefile +++ /dev/null @@ -1 +0,0 @@ -include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/inventec/x86-64/d5052/onlp/PKG.yml b/packages/platforms/inventec/x86-64/d5052/onlp/PKG.yml deleted file mode 100644 index 24549193d..000000000 --- a/packages/platforms/inventec/x86-64/d5052/onlp/PKG.yml +++ /dev/null @@ -1 +0,0 @@ -!include $ONL_TEMPLATES/onlp-platform-any.yml PLATFORM=x86-64-inventec-d5052 ARCH=amd64 TOOLCHAIN=x86_64-linux-gnu diff --git a/packages/platforms/inventec/x86-64/d5052/onlp/builds/Makefile b/packages/platforms/inventec/x86-64/d5052/onlp/builds/Makefile deleted file mode 100644 index e7437cb23..000000000 --- a/packages/platforms/inventec/x86-64/d5052/onlp/builds/Makefile +++ /dev/null @@ -1,2 +0,0 @@ -FILTER=src -include $(ONL)/make/subdirs.mk diff --git a/packages/platforms/inventec/x86-64/d5052/onlp/builds/lib/Makefile b/packages/platforms/inventec/x86-64/d5052/onlp/builds/lib/Makefile deleted file mode 100644 index e908841da..000000000 --- a/packages/platforms/inventec/x86-64/d5052/onlp/builds/lib/Makefile +++ /dev/null @@ -1,2 +0,0 @@ -PLATFORM := x86-64-inventec-d5052 -include $(ONL)/packages/base/any/onlp/builds/platform/libonlp-platform.mk diff --git a/packages/platforms/inventec/x86-64/d5052/onlp/builds/onlpdump/Makefile b/packages/platforms/inventec/x86-64/d5052/onlp/builds/onlpdump/Makefile deleted file mode 100644 index a7ce08a47..000000000 --- a/packages/platforms/inventec/x86-64/d5052/onlp/builds/onlpdump/Makefile +++ /dev/null @@ -1,2 +0,0 @@ -PLATFORM := x86-64-inventec-d5052 -include $(ONL)/packages/base/any/onlp/builds/platform/onlps.mk diff --git a/packages/platforms/inventec/x86-64/d5052/onlp/builds/x86_64_inventec_d5052/.module b/packages/platforms/inventec/x86-64/d5052/onlp/builds/x86_64_inventec_d5052/.module deleted file mode 100644 index fa5bb9cbf..000000000 --- a/packages/platforms/inventec/x86-64/d5052/onlp/builds/x86_64_inventec_d5052/.module +++ /dev/null @@ -1 +0,0 @@ -name: x86_64_inventec_d5052 diff --git a/packages/platforms/inventec/x86-64/d5052/onlp/builds/x86_64_inventec_d5052/Makefile b/packages/platforms/inventec/x86-64/d5052/onlp/builds/x86_64_inventec_d5052/Makefile deleted file mode 100644 index b919cb2e3..000000000 --- a/packages/platforms/inventec/x86-64/d5052/onlp/builds/x86_64_inventec_d5052/Makefile +++ /dev/null @@ -1,9 +0,0 @@ -############################################################################### -# -# -# -############################################################################### -include $(ONL)/make/config.mk -MODULE := x86_64_inventec_d5052 -AUTOMODULE := x86_64_inventec_d5052 -include $(BUILDER)/definemodule.mk diff --git a/packages/platforms/inventec/x86-64/d5052/onlp/builds/x86_64_inventec_d5052/module/auto/make.mk b/packages/platforms/inventec/x86-64/d5052/onlp/builds/x86_64_inventec_d5052/module/auto/make.mk deleted file mode 100644 index ed86867d4..000000000 --- a/packages/platforms/inventec/x86-64/d5052/onlp/builds/x86_64_inventec_d5052/module/auto/make.mk +++ /dev/null @@ -1,9 +0,0 @@ -############################################################################### -# -# x86_64_inventec_d5052 Autogeneration -# -############################################################################### -x86_64_inventec_d5052_AUTO_DEFS := module/auto/x86_64_inventec_d5052.yml -x86_64_inventec_d5052_AUTO_DIRS := module/inc/x86_64_inventec_d5052 module/src -include $(BUILDER)/auto.mk - diff --git a/packages/platforms/inventec/x86-64/d5052/onlp/builds/x86_64_inventec_d5052/module/auto/x86_64_inventec_d5052.yml b/packages/platforms/inventec/x86-64/d5052/onlp/builds/x86_64_inventec_d5052/module/auto/x86_64_inventec_d5052.yml deleted file mode 100644 index e553c7125..000000000 --- a/packages/platforms/inventec/x86-64/d5052/onlp/builds/x86_64_inventec_d5052/module/auto/x86_64_inventec_d5052.yml +++ /dev/null @@ -1,50 +0,0 @@ -############################################################################### -# -# x86_64_inventec_d5052 Autogeneration Definitions. -# -############################################################################### - -cdefs: &cdefs -- X86_64_INVENTEC_D5052_CONFIG_INCLUDE_LOGGING: - doc: "Include or exclude logging." - default: 1 -- X86_64_INVENTEC_D5052_CONFIG_LOG_OPTIONS_DEFAULT: - doc: "Default enabled log options." - default: AIM_LOG_OPTIONS_DEFAULT -- X86_64_INVENTEC_D5052_CONFIG_LOG_BITS_DEFAULT: - doc: "Default enabled log bits." - default: AIM_LOG_BITS_DEFAULT -- X86_64_INVENTEC_D5052_CONFIG_LOG_CUSTOM_BITS_DEFAULT: - doc: "Default enabled custom log bits." - default: 0 -- X86_64_INVENTEC_D5052_CONFIG_PORTING_STDLIB: - doc: "Default all porting macros to use the C standard libraries." - default: 1 -- X86_64_INVENTEC_D5052_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS: - doc: "Include standard library headers for stdlib porting macros." - default: X86_64_INVENTEC_D5052_CONFIG_PORTING_STDLIB -- X86_64_INVENTEC_D5052_CONFIG_INCLUDE_UCLI: - doc: "Include generic uCli support." - default: 0 -- X86_64_INVENTEC_D5052_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_D5052_CONFIG_HEADER: - defs: *cdefs - basename: x86_64_inventec_d5052_config - - portingmacro: - X86_64_INVENTEC_D5052: - macros: - - malloc - - free - - memset - - memcpy - - - vsnprintf - - snprintf - - strlen diff --git a/packages/platforms/inventec/x86-64/d5052/onlp/builds/x86_64_inventec_d5052/module/inc/x86_64_inventec_d5052/x86_64_inventec_d5052.x b/packages/platforms/inventec/x86-64/d5052/onlp/builds/x86_64_inventec_d5052/module/inc/x86_64_inventec_d5052/x86_64_inventec_d5052.x deleted file mode 100644 index 671a46d94..000000000 --- a/packages/platforms/inventec/x86-64/d5052/onlp/builds/x86_64_inventec_d5052/module/inc/x86_64_inventec_d5052/x86_64_inventec_d5052.x +++ /dev/null @@ -1,14 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#include - -/* <--auto.start.xmacro(ALL).define> */ -/* */ - -/* <--auto.start.xenum(ALL).define> */ -/* */ - - diff --git a/packages/platforms/inventec/x86-64/d5052/onlp/builds/x86_64_inventec_d5052/module/inc/x86_64_inventec_d5052/x86_64_inventec_d5052_config.h b/packages/platforms/inventec/x86-64/d5052/onlp/builds/x86_64_inventec_d5052/module/inc/x86_64_inventec_d5052/x86_64_inventec_d5052_config.h deleted file mode 100644 index 25e471396..000000000 --- a/packages/platforms/inventec/x86-64/d5052/onlp/builds/x86_64_inventec_d5052/module/inc/x86_64_inventec_d5052/x86_64_inventec_d5052_config.h +++ /dev/null @@ -1,137 +0,0 @@ -/**************************************************************************//** - * - * @file - * @brief x86_64_inventec_d5052 Configuration Header - * - * @addtogroup x86_64_inventec_d5052-config - * @{ - * - *****************************************************************************/ -#ifndef __x86_64_inventec_d5052_CONFIG_H__ -#define __x86_64_inventec_d5052_CONFIG_H__ - -#ifdef GLOBAL_INCLUDE_CUSTOM_CONFIG -#include -#endif -#ifdef x86_64_inventec_d5052_INCLUDE_CUSTOM_CONFIG -#include -#endif - -/* */ -#include -/** - * X86_64_INVENTEC_D5052_CONFIG_INCLUDE_LOGGING - * - * Include or exclude logging. */ - - -#ifndef X86_64_INVENTEC_D5052_CONFIG_INCLUDE_LOGGING -#define X86_64_INVENTEC_D5052_CONFIG_INCLUDE_LOGGING 1 -#endif - -/** - * X86_64_INVENTEC_D5052_CONFIG_LOG_OPTIONS_DEFAULT - * - * Default enabled log options. */ - - -#ifndef X86_64_INVENTEC_D5052_CONFIG_LOG_OPTIONS_DEFAULT -#define X86_64_INVENTEC_D5052_CONFIG_LOG_OPTIONS_DEFAULT AIM_LOG_OPTIONS_DEFAULT -#endif - -/** - * X86_64_INVENTEC_D5052_CONFIG_LOG_BITS_DEFAULT - * - * Default enabled log bits. */ - - -#ifndef X86_64_INVENTEC_D5052_CONFIG_LOG_BITS_DEFAULT -#define X86_64_INVENTEC_D5052_CONFIG_LOG_BITS_DEFAULT AIM_LOG_BITS_DEFAULT -#endif - -/** - * X86_64_INVENTEC_D5052_CONFIG_LOG_CUSTOM_BITS_DEFAULT - * - * Default enabled custom log bits. */ - - -#ifndef X86_64_INVENTEC_D5052_CONFIG_LOG_CUSTOM_BITS_DEFAULT -#define X86_64_INVENTEC_D5052_CONFIG_LOG_CUSTOM_BITS_DEFAULT 0 -#endif - -/** - * X86_64_INVENTEC_D5052_CONFIG_PORTING_STDLIB - * - * Default all porting macros to use the C standard libraries. */ - - -#ifndef X86_64_INVENTEC_D5052_CONFIG_PORTING_STDLIB -#define X86_64_INVENTEC_D5052_CONFIG_PORTING_STDLIB 1 -#endif - -/** - * X86_64_INVENTEC_D5052_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS - * - * Include standard library headers for stdlib porting macros. */ - - -#ifndef X86_64_INVENTEC_D5052_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS -#define X86_64_INVENTEC_D5052_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS X86_64_INVENTEC_D5052_CONFIG_PORTING_STDLIB -#endif - -/** - * X86_64_INVENTEC_D5052_CONFIG_INCLUDE_UCLI - * - * Include generic uCli support. */ - - -#ifndef X86_64_INVENTEC_D5052_CONFIG_INCLUDE_UCLI -#define X86_64_INVENTEC_D5052_CONFIG_INCLUDE_UCLI 0 -#endif - -/** - * X86_64_INVENTEC_D5052_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION - * - * Assume chassis fan direction is the same as the PSU fan direction. */ - - -#ifndef X86_64_INVENTEC_D5052_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION -#define X86_64_INVENTEC_D5052_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION 0 -#endif - - - -/** - * All compile time options can be queried or displayed - */ - -/** Configuration settings structure. */ -typedef struct x86_64_inventec_d5052_config_settings_s { - /** name */ - const char* name; - /** value */ - const char* value; -} x86_64_inventec_d5052_config_settings_t; - -/** Configuration settings table. */ -/** x86_64_inventec_d5052_config_settings table. */ -extern x86_64_inventec_d5052_config_settings_t x86_64_inventec_d5052_config_settings[]; - -/** - * @brief Lookup a configuration setting. - * @param setting The name of the configuration option to lookup. - */ -const char* x86_64_inventec_d5052_config_lookup(const char* setting); - -/** - * @brief Show the compile-time configuration. - * @param pvs The output stream. - */ -int x86_64_inventec_d5052_config_show(struct aim_pvs_s* pvs); - -/* */ - -#include "x86_64_inventec_d5052_porting.h" - -#endif /* __x86_64_inventec_d5052_CONFIG_H__ */ -/* @} */ diff --git a/packages/platforms/inventec/x86-64/d5052/onlp/builds/x86_64_inventec_d5052/module/inc/x86_64_inventec_d5052/x86_64_inventec_d5052_dox.h b/packages/platforms/inventec/x86-64/d5052/onlp/builds/x86_64_inventec_d5052/module/inc/x86_64_inventec_d5052/x86_64_inventec_d5052_dox.h deleted file mode 100644 index 93b1bfebb..000000000 --- a/packages/platforms/inventec/x86-64/d5052/onlp/builds/x86_64_inventec_d5052/module/inc/x86_64_inventec_d5052/x86_64_inventec_d5052_dox.h +++ /dev/null @@ -1,26 +0,0 @@ -/**************************************************************************//** - * - * x86_64_inventec_d5052 Doxygen Header - * - *****************************************************************************/ -#ifndef __x86_64_inventec_d5052_DOX_H__ -#define __x86_64_inventec_d5052_DOX_H__ - -/** - * @defgroup x86_64_inventec_d5052 x86_64_inventec_d5052 - x86_64_inventec_d5052 Description - * - -The documentation overview for this module should go here. - - * - * @{ - * - * @defgroup x86_64_inventec_d5052-x86_64_inventec_d5052 Public Interface - * @defgroup x86_64_inventec_d5052-config Compile Time Configuration - * @defgroup x86_64_inventec_d5052-porting Porting Macros - * - * @} - * - */ - -#endif /* __x86_64_inventec_d5052_DOX_H__ */ diff --git a/packages/platforms/inventec/x86-64/d5052/onlp/builds/x86_64_inventec_d5052/module/inc/x86_64_inventec_d5052/x86_64_inventec_d5052_porting.h b/packages/platforms/inventec/x86-64/d5052/onlp/builds/x86_64_inventec_d5052/module/inc/x86_64_inventec_d5052/x86_64_inventec_d5052_porting.h deleted file mode 100644 index 7468a10f9..000000000 --- a/packages/platforms/inventec/x86-64/d5052/onlp/builds/x86_64_inventec_d5052/module/inc/x86_64_inventec_d5052/x86_64_inventec_d5052_porting.h +++ /dev/null @@ -1,97 +0,0 @@ -/**************************************************************************//** - * - * @file - * @brief x86_64_inventec_d5052 Porting Macros. - * - * @addtogroup x86_64_inventec_d5052-porting - * @{ - * - *****************************************************************************/ -#ifndef __x86_64_inventec_d5052_PORTING_H__ -#define __x86_64_inventec_d5052_PORTING_H__ - - -/* */ -#if X86_64_INVENTEC_D5052_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS == 1 -#include -#include -#include -#include -#include -#endif - -#ifndef X86_64_INVENTEC_D5052_MALLOC - #if defined(GLOBAL_MALLOC) - #define X86_64_INVENTEC_D5052_MALLOC GLOBAL_MALLOC - #elif X86_64_INVENTEC_D5052_CONFIG_PORTING_STDLIB == 1 - #define X86_64_INVENTEC_D5052_MALLOC malloc - #else - #error The macro X86_64_INVENTEC_D5052_MALLOC is required but cannot be defined. - #endif -#endif - -#ifndef X86_64_INVENTEC_D5052_FREE - #if defined(GLOBAL_FREE) - #define X86_64_INVENTEC_D5052_FREE GLOBAL_FREE - #elif X86_64_INVENTEC_D5052_CONFIG_PORTING_STDLIB == 1 - #define X86_64_INVENTEC_D5052_FREE free - #else - #error The macro X86_64_INVENTEC_D5052_FREE is required but cannot be defined. - #endif -#endif - -#ifndef X86_64_INVENTEC_D5052_MEMSET - #if defined(GLOBAL_MEMSET) - #define X86_64_INVENTEC_D5052_MEMSET GLOBAL_MEMSET - #elif X86_64_INVENTEC_D5052_CONFIG_PORTING_STDLIB == 1 - #define X86_64_INVENTEC_D5052_MEMSET memset - #else - #error The macro X86_64_INVENTEC_D5052_MEMSET is required but cannot be defined. - #endif -#endif - -#ifndef X86_64_INVENTEC_D5052_MEMCPY - #if defined(GLOBAL_MEMCPY) - #define X86_64_INVENTEC_D5052_MEMCPY GLOBAL_MEMCPY - #elif X86_64_INVENTEC_D5052_CONFIG_PORTING_STDLIB == 1 - #define X86_64_INVENTEC_D5052_MEMCPY memcpy - #else - #error The macro X86_64_INVENTEC_D5052_MEMCPY is required but cannot be defined. - #endif -#endif - -#ifndef X86_64_INVENTEC_D5052_VSNPRINTF - #if defined(GLOBAL_VSNPRINTF) - #define X86_64_INVENTEC_D5052_VSNPRINTF GLOBAL_VSNPRINTF - #elif X86_64_INVENTEC_D5052_CONFIG_PORTING_STDLIB == 1 - #define X86_64_INVENTEC_D5052_VSNPRINTF vsnprintf - #else - #error The macro X86_64_INVENTEC_D5052_VSNPRINTF is required but cannot be defined. - #endif -#endif - -#ifndef X86_64_INVENTEC_D5052_SNPRINTF - #if defined(GLOBAL_SNPRINTF) - #define X86_64_INVENTEC_D5052_SNPRINTF GLOBAL_SNPRINTF - #elif X86_64_INVENTEC_D5052_CONFIG_PORTING_STDLIB == 1 - #define X86_64_INVENTEC_D5052_SNPRINTF snprintf - #else - #error The macro X86_64_INVENTEC_D5052_SNPRINTF is required but cannot be defined. - #endif -#endif - -#ifndef X86_64_INVENTEC_D5052_STRLEN - #if defined(GLOBAL_STRLEN) - #define X86_64_INVENTEC_D5052_STRLEN GLOBAL_STRLEN - #elif X86_64_INVENTEC_D5052_CONFIG_PORTING_STDLIB == 1 - #define X86_64_INVENTEC_D5052_STRLEN strlen - #else - #error The macro X86_64_INVENTEC_D5052_STRLEN is required but cannot be defined. - #endif -#endif - -/* */ - - -#endif /* __x86_64_inventec_d5052_PORTING_H__ */ -/* @} */ diff --git a/packages/platforms/inventec/x86-64/d5052/onlp/builds/x86_64_inventec_d5052/module/make.mk b/packages/platforms/inventec/x86-64/d5052/onlp/builds/x86_64_inventec_d5052/module/make.mk deleted file mode 100644 index 30b4e734d..000000000 --- a/packages/platforms/inventec/x86-64/d5052/onlp/builds/x86_64_inventec_d5052/module/make.mk +++ /dev/null @@ -1,10 +0,0 @@ -############################################################################### -# -# -# -############################################################################### -THIS_DIR := $(dir $(lastword $(MAKEFILE_LIST))) -x86_64_inventec_d5052_INCLUDES := -I $(THIS_DIR)inc -x86_64_inventec_d5052_INTERNAL_INCLUDES := -I $(THIS_DIR)src -x86_64_inventec_d5052_DEPENDMODULE_ENTRIES := init:x86_64_inventec_d5052 ucli:x86_64_inventec_d5052 - diff --git a/packages/platforms/inventec/x86-64/d5052/onlp/builds/x86_64_inventec_d5052/module/src/Makefile b/packages/platforms/inventec/x86-64/d5052/onlp/builds/x86_64_inventec_d5052/module/src/Makefile deleted file mode 100644 index 837aa7b9a..000000000 --- a/packages/platforms/inventec/x86-64/d5052/onlp/builds/x86_64_inventec_d5052/module/src/Makefile +++ /dev/null @@ -1,9 +0,0 @@ -############################################################################### -# -# Local source generation targets. -# -############################################################################### - -ucli: - @../../../../tools/uclihandlers.py x86_64_inventec_d5052_ucli.c - diff --git a/packages/platforms/inventec/x86-64/d5052/onlp/builds/x86_64_inventec_d5052/module/src/debug.c b/packages/platforms/inventec/x86-64/d5052/onlp/builds/x86_64_inventec_d5052/module/src/debug.c deleted file mode 100644 index 5c781a0a9..000000000 --- a/packages/platforms/inventec/x86-64/d5052/onlp/builds/x86_64_inventec_d5052/module/src/debug.c +++ /dev/null @@ -1,45 +0,0 @@ -#include "x86_64_inventec_d5052_int.h" - -#if x86_64_inventec_d5052_CONFIG_INCLUDE_DEBUG == 1 - -#include - -static char help__[] = - "Usage: debug [options]\n" - " -c CPLD Versions\n" - " -h Help\n" - ; - -int -x86_64_inventec_d5052_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/d5052/onlp/builds/x86_64_inventec_d5052/module/src/fani.c b/packages/platforms/inventec/x86-64/d5052/onlp/builds/x86_64_inventec_d5052/module/src/fani.c deleted file mode 100644 index 130b4b05a..000000000 --- a/packages/platforms/inventec/x86-64/d5052/onlp/builds/x86_64_inventec_d5052/module/src/fani.c +++ /dev/null @@ -1,272 +0,0 @@ -/************************************************************ - * fani.c - * - * Copyright 2018 Inventec Technology Corporation. - * - ************************************************************ - * - * Fan Platform Implementation Defaults. - * - ***********************************************************/ -#include -#include -#include -#include -#include -#include -#include "platform_lib.h" - -#define FAN_GPI_ON_MAIN_BOARD INV_PSOC_PREFIX"/fan_gpi" - -#define MAX_FAN_SPEED 18000 -#define MAX_PSU_FAN_SPEED 25500 - -#define PROJECT_NAME -#define LEN_FILE_NAME 80 - -static char* devfiles__[FAN_MAX] = /* must map with onlp_thermal_id */ -{ - "reserved", - INV_PSOC_PREFIX"/fan1_input", - INV_PSOC_PREFIX"/fan2_input", - INV_PSOC_PREFIX"/fan3_input", - INV_PSOC_PREFIX"/fan4_input", - INV_PSOC_PREFIX"/fan5_input", - INV_PSOC_PREFIX"/fan6_input", - INV_PSOC_PREFIX"/fan7_input", - INV_PSOC_PREFIX"/fan8_input", - INV_PSOC_PREFIX"/rpm_psu1", - INV_PSOC_PREFIX"/rpm_psu2", -}; - -#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_F2B | 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_F2B | ONLP_FAN_CAPS_GET_RPM | ONLP_FAN_CAPS_GET_PERCENTAGE), \ - 0, \ - 0, \ - ONLP_FAN_MODE_INVALID, \ - } - -/* Static fan information */ -onlp_fan_info_t linfo[FAN_MAX] = { - { }, /* 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_MAIN_BOARD(7), - MAKE_FAN_INFO_NODE_ON_MAIN_BOARD(8), - 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, FAN_GPI_ON_MAIN_BOARD); - if (ret < 0) { - return ONLP_STATUS_E_INTERNAL; - } - - if (value & (1 << (fid-1))) { - info->status |= ONLP_FAN_STATUS_FAILED; - } - else { - info->status |= ONLP_FAN_STATUS_PRESENT; - info->status |= ONLP_FAN_STATUS_F2B; - } - - /* get front fan speed */ - ret = onlp_file_read_int(&value, devfiles__[fid]); - if (ret < 0) { - return ONLP_STATUS_E_INTERNAL; - } - - info->rpm = value; - info->percentage = (info->rpm * 100) / MAX_PSU_FAN_SPEED; - - snprintf(info->model, ONLP_CONFIG_INFO_STR_MAX, "NA"); - snprintf(info->serial, ONLP_CONFIG_INFO_STR_MAX, "NA"); - - 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 fid, onlp_fan_info_t* info) -{ - int value, ret, index; - - info->status |= ONLP_FAN_STATUS_PRESENT; - info->status |= ONLP_FAN_STATUS_F2B; - - /* get fan direction */ - info->status |= _onlp_get_fan_direction_on_psu(); - - if (info->status & ONLP_FAN_STATUS_FAILED) { - return ONLP_STATUS_OK; - } - - index = ONLP_OID_ID_GET(info->hdr.id); - info->hdr.coids[0] = ONLP_FAN_ID_CREATE(index + CHASSIS_FAN_COUNT); - - /* get front fan speed */ - ret = onlp_file_read_int(&value, devfiles__[fid]); - if (ret < 0) { - return ONLP_STATUS_E_INTERNAL; - } - - info->percentage = (info->rpm * 100) / MAX_PSU_FAN_SPEED; - info->status |= (value == 0) ? ONLP_FAN_STATUS_FAILED : 0; - - snprintf(info->model, ONLP_CONFIG_INFO_STR_MAX, "NA"); - snprintf(info->serial, ONLP_CONFIG_INFO_STR_MAX, "NA"); - - 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: - 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 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_PSU1: - return psu_pmbus_info_set(PSU1_ID, "rpm_psu1", p); - case FAN_1_ON_PSU2: - return psu_pmbus_info_set(PSU2_ID, "rpm_psu2", p); - 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: - 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/d5052/onlp/builds/x86_64_inventec_d5052/module/src/ledi.c b/packages/platforms/inventec/x86-64/d5052/onlp/builds/x86_64_inventec_d5052/module/src/ledi.c deleted file mode 100644 index a695afda0..000000000 --- a/packages/platforms/inventec/x86-64/d5052/onlp/builds/x86_64_inventec_d5052/module/src/ledi.c +++ /dev/null @@ -1,308 +0,0 @@ -/************************************************************ - * ledi.c - * - * Copyright 2018 Inventec Technology Corporation. - * - ************************************************************ - * - ***********************************************************/ -#include -#include -#include -#include -#include -#include -#include -#include -#include "platform_lib.h" - -#define filename "brightness" - -#define VALIDATE(_id) \ - do { \ - if(!ONLP_OID_IS_LED(_id)) { \ - return ONLP_STATUS_E_INVALID; \ - } \ - } while(0) - -static char* devfiles__[LED_MAX] = /* must map with onlp_thermal_id */ -{ - "reserved", - INV_CPLD_PREFIX"/%s_led", - INV_PSOC_PREFIX"/fan_led_%s1", - INV_PSOC_PREFIX"/fan_led_%s2", - INV_PSOC_PREFIX"/fan_led_%s3", - INV_PSOC_PREFIX"/fan_led_%s4", -}; - -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_SYS, LED_MODE_OFF, ONLP_LED_MODE_OFF}, - {LED_SYS, LED_MODE_GREEN, ONLP_LED_MODE_GREEN}, - {LED_SYS, LED_MODE_AMBER, ONLP_LED_MODE_ORANGE}, - {LED_SYS, LED_MODE_RED, ONLP_LED_MODE_RED}, - {LED_FAN1,LED_MODE_AUTO, ONLP_LED_MODE_AUTO}, - {LED_FAN2,LED_MODE_AUTO, ONLP_LED_MODE_AUTO}, - {LED_FAN3,LED_MODE_AUTO, ONLP_LED_MODE_AUTO}, - {LED_FAN4,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[LED_MAX] = -{ - { }, /* Not used */ - { - { ONLP_LED_ID_CREATE(LED_SYS), "Chassis LED (SYSTEM 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_MODE_ON, '0', - }, - { - { ONLP_LED_ID_CREATE(LED_FAN1), "Fan LED 1 (FAN1 LED)", 0 }, - ONLP_LED_STATUS_PRESENT, - ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_RED, - ONLP_LED_MODE_ON, '0', - }, - { - { ONLP_LED_ID_CREATE(LED_FAN2), "Fan LED 2 (FAN2 LED)", 0 }, - ONLP_LED_STATUS_PRESENT, - ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_RED, - ONLP_LED_MODE_ON, '0', - }, - { - { ONLP_LED_ID_CREATE(LED_FAN3), "Fan LED 3 (FAN3 LED)", 0 }, - ONLP_LED_STATUS_PRESENT, - ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_RED, - ONLP_LED_MODE_ON, '0', - }, - { - { ONLP_LED_ID_CREATE(LED_FAN4), "Fan LED 4 (FAN4 LED)", 0 }, - ONLP_LED_STATUS_PRESENT, - ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_RED, - ONLP_LED_MODE_ON, '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_SYS), ONLP_LED_MODE_OFF); - - return ONLP_STATUS_OK; -} - -int onlp_chassis_led_read(char *pathp, char *buf, size_t len) -{ - FILE * fp; - - fp = fopen (pathp, "r"); - if(fp == NULL) { - perror("Error opening file"); - return(-1); - } - if( fgets (buf, len, fp) == NULL ) { - perror("Error fgets operation"); - } - fclose(fp); - - return(0); -} - -int -onlp_ledi_info_get(onlp_oid_t id, onlp_led_info_t* info) -{ - int local_id, gret = 0, rret = 0; - char fullpath_grn[50] = {0}; - char fullpath_red[50] = {0}; - int gvalue = 0, rvalue = 0; - char buf[32] = {0}; - - VALIDATE(id); - - local_id = ONLP_OID_ID_GET(id); - - /* get fullpath */ - switch (local_id) { - case LED_SYS: - sprintf(fullpath_grn, devfiles__[local_id], "grn"); - sprintf(fullpath_red, devfiles__[local_id], "red"); - - /* Set LED mode */ - gret = onlp_chassis_led_read(fullpath_grn, buf, 32); - if (buf[0] == '1' || buf[0] == '2' || buf[0] == '3' || buf[0] == '7') { - gvalue = 1; - } - - rret = onlp_chassis_led_read(fullpath_red, buf, 32); - if (buf[0] == '1' || buf[0] == '2' || buf[0] == '3' || buf[0] == '7') { - rvalue = 1; - } - if (gret < 0 && rret < 0) { - DEBUG_PRINT("%s(%d)\r\n", __FUNCTION__, __LINE__); - gvalue = -1; - rvalue = -1; - } - break; - case LED_FAN1: - case LED_FAN2: - case LED_FAN3: - case LED_FAN4: - sprintf(fullpath_grn, devfiles__[local_id], "grn"); - sprintf(fullpath_red, devfiles__[local_id], "red"); - - /* Set LED mode */ - if (onlp_file_read_int(&gvalue, fullpath_grn) != 0) { - DEBUG_PRINT("%s(%d)\r\n", __FUNCTION__, __LINE__); - gvalue = 0; - } - if (onlp_file_read_int(&rvalue, fullpath_red) != 0) { - DEBUG_PRINT("%s(%d)\r\n", __FUNCTION__, __LINE__); - rvalue = 0; - } - break; - default: - DEBUG_PRINT("%s(%d) Invalid led id %d\r\n", __FUNCTION__, __LINE__, local_id); - gvalue = -1; - rvalue = -1; - break; - } - - /* Set the onlp_oid_hdr_t and capabilities */ - *info = linfo[ONLP_OID_ID_GET(id)]; - - if (gvalue == 1 && rvalue == 0) { - info->mode = ONLP_LED_MODE_GREEN; - info->status |= ONLP_LED_STATUS_ON; - } - else - if (gvalue == 0 && rvalue == 1) { - info->mode = ONLP_LED_MODE_RED; - info->status |= ONLP_LED_STATUS_ON; - } - else - if (gvalue == 1 && rvalue == 1) { - info->mode = ONLP_LED_MODE_ORANGE; - info->status |= ONLP_LED_STATUS_ON; - } - else - if (gvalue == 0 && rvalue == 0) { - info->mode = ONLP_LED_MODE_OFF; - info->status |= ONLP_LED_STATUS_ON; - } - else { - info->mode = ONLP_LED_MODE_OFF; - info->status |= ONLP_LED_STATUS_FAILED; - } - 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); - switch (local_id) { - case LED_SYS: - sprintf(fullpath, "%s%s/%s", INV_CPLD_PREFIX, last_path[local_id], filename); - break; - case LED_FAN1: - case LED_FAN2: - case LED_FAN3: - case LED_FAN4: - sprintf(fullpath, "%s%s/%s", INV_PSOC_PREFIX, last_path[local_id], filename); - break; - default: - DEBUG_PRINT("%s(%d) Invalid led id %d\r\n", __FUNCTION__, __LINE__, local_id); - return ONLP_STATUS_E_INTERNAL; - } - - 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/d5052/onlp/builds/x86_64_inventec_d5052/module/src/make.mk b/packages/platforms/inventec/x86-64/d5052/onlp/builds/x86_64_inventec_d5052/module/src/make.mk deleted file mode 100644 index 153116ea5..000000000 --- a/packages/platforms/inventec/x86-64/d5052/onlp/builds/x86_64_inventec_d5052/module/src/make.mk +++ /dev/null @@ -1,9 +0,0 @@ -############################################################################### -# -# -# -############################################################################### - -LIBRARY := x86_64_inventec_d5052 -$(LIBRARY)_SUBDIR := $(dir $(lastword $(MAKEFILE_LIST))) -include $(BUILDER)/lib.mk diff --git a/packages/platforms/inventec/x86-64/d5052/onlp/builds/x86_64_inventec_d5052/module/src/platform_lib.c b/packages/platforms/inventec/x86-64/d5052/onlp/builds/x86_64_inventec_d5052/module/src/platform_lib.c deleted file mode 100644 index 3cfb2359f..000000000 --- a/packages/platforms/inventec/x86-64/d5052/onlp/builds/x86_64_inventec_d5052/module/src/platform_lib.c +++ /dev/null @@ -1,183 +0,0 @@ -/************************************************************ - * platform_lib.c - * - * Copyright 2018 Inventec Corporation. - * - ************************************************************ - * - ***********************************************************/ -#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 32 -#define I2C_PSU_FAN_DIR_LEN 8 -#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(psoc_psu1_model) : PSU2_AC_HWMON_NODE(psoc_psu2_model); - 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)] = 0; - } - - if (strncmp(model_name, "YM-2651Y", 8) == 0) { - if (modelname) { - aim_strlcpy(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) { - aim_strlcpy(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) { - aim_strlcpy(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; - } - } - - if (strncmp(model_name, "DPS-150AB-10", 12) == 0) { - if (modelname) { - aim_strlcpy(modelname, model_name, 12); - } - - return PSU_TYPE_DC_12V_F2B; - } - - 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%d", PSU1_AC_PMBUS_PREFIX, node, PSU1_ID); - } - else - if (PSU2_ID == id) { - ret = onlp_file_read_int(value, "%s%s%d", PSU2_AC_PMBUS_PREFIX, node, PSU2_ID); - } - else { - return ONLP_STATUS_E_INTERNAL; - } - - 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%d", PSU1_AC_PMBUS_PREFIX, node, PSU1_ID); - break; - case PSU2_ID: - sprintf(path, "%s%s%d", PSU2_AC_PMBUS_PREFIX, node, PSU2_ID); - 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/d5052/onlp/builds/x86_64_inventec_d5052/module/src/platform_lib.h b/packages/platforms/inventec/x86-64/d5052/onlp/builds/x86_64_inventec_d5052/module/src/platform_lib.h deleted file mode 100644 index 751e0f4ec..000000000 --- a/packages/platforms/inventec/x86-64/d5052/onlp/builds/x86_64_inventec_d5052/module/src/platform_lib.h +++ /dev/null @@ -1,134 +0,0 @@ -/************************************************************ - * platform_lib.h - * - * Copyright 2018 Inventec Technology Corporation. - * - ************************************************************ - * - ***********************************************************/ -#ifndef __PLATFORM_LIB_H__ -#define __PLATFORM_LIB_H__ - -#include "x86_64_inventec_d5052_log.h" - -#define ONLP_NODE_MAX_INT_LEN (8) -#define ONLP_NODE_MAX_PATH_LEN (64) - -#define INV_CPLD_COUNT (1) -#define INV_CPLD_PREFIX "/sys/bus/i2c/devices/1-0055/" -#define INV_PSOC_PREFIX "/sys/bus/i2c/devices/1-0066/" -#define INV_EPRM_PREFIX "/sys/bus/i2c/devices/0-0053/" -#define INV_CTMP_PREFIX "/sys/devices/platform/coretemp.0/hwmon/hwmon0/" - -#define CHASSIS_SFP_COUNT (4) - -/* - * Definitions of Chassis EEPROM - */ -#define EEPROM_NODE(node) INV_EPRM_PREFIX#node - -/* - * Definitions of D5052 device - */ -enum onlp_thermal_id { - THERMAL_RESERVED = 0, - THERMAL_CPU_CORE_FIRST, - THERMAL_CPU_CORE_2, - THERMAL_CPU_CORE_3, - THERMAL_CPU_CORE_LAST, - 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, - THERMAL_MAX -}; -#define CHASSIS_THERMAL_COUNT (9) - -enum onlp_fan_id { - FAN_RESERVED = 0, - FAN_1_ON_MAIN_BOARD, - FAN_2_ON_MAIN_BOARD, - FAN_3_ON_MAIN_BOARD, - FAN_4_ON_MAIN_BOARD, - FAN_5_ON_MAIN_BOARD, - FAN_6_ON_MAIN_BOARD, - FAN_7_ON_MAIN_BOARD, - FAN_8_ON_MAIN_BOARD, - FAN_1_ON_PSU1, - FAN_1_ON_PSU2, - FAN_MAX -}; -#define CHASSIS_FAN_COUNT (8) - -enum onlp_led_id { - LED_RESERVED = 0, - LED_SYS, - LED_FAN1, - LED_FAN2, - LED_FAN3, - LED_FAN4, - LED_MAX -}; -#define CHASSIS_LED_COUNT (1) - -enum onlp_psu_id { - PSU_RESERVED = 0, - PSU1_ID, - PSU2_ID, - PSU_MAX -}; -#define CHASSIS_PSU_COUNT (2) - -#define PSU1_AC_PMBUS_PREFIX INV_PSOC_PREFIX -#define PSU2_AC_PMBUS_PREFIX INV_PSOC_PREFIX - -#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 INV_PSOC_PREFIX -#define PSU2_AC_HWMON_PREFIX INV_PSOC_PREFIX - -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 PSU1_AC_HWMON_NODE(node) PSU1_AC_HWMON_PREFIX#node -#define PSU2_AC_HWMON_NODE(node) PSU2_AC_HWMON_PREFIX#node - -/* - * Definitions of FAN device - */ -#define FAN_BOARD_PATH INV_PSOC_PREFIX -#define FAN_NODE(node) FAN_BOARD_PATH#node - -/* - * Prototypes - */ -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); - -#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/d5052/onlp/builds/x86_64_inventec_d5052/module/src/psui.c b/packages/platforms/inventec/x86-64/d5052/onlp/builds/x86_64_inventec_d5052/module/src/psui.c deleted file mode 100644 index 6294d86df..000000000 --- a/packages/platforms/inventec/x86-64/d5052/onlp/builds/x86_64_inventec_d5052/module/src/psui.c +++ /dev/null @@ -1,250 +0,0 @@ -/************************************************************ - * psui.c - * - * Copyright 2018 Inventec Technology Corporation. - * - ************************************************************ - * - ***********************************************************/ -#include -#include -#include -#include -#include -#include -#include "platform_lib.h" - -#define PSU_STATUS_PRESENT (0) -#define PSU_STATUS_POWER_GOOD (1) -#define PSU_STATUS_UNPOWERED (2) -#define PSU_STATUS_FAULT (4) -#define PSU_STATUS_UNINSTALLED (7) - -#define VALIDATE(_id) \ - do { \ - if(!ONLP_OID_IS_PSU(_id)) { \ - return ONLP_STATUS_E_INVALID; \ - } \ - } while(0) - -static char* status_devfiles__[PSU_MAX] = /* must map with onlp_psu_id */ -{ - "reserved", - INV_CPLD_PREFIX"/psu0", - INV_CPLD_PREFIX"/psu1", -}; - -static char* module_devfiles__[PSU_MAX] = /* must map with onlp_psu_id */ -{ - "reserved", - INV_PSOC_PREFIX"/psoc_psu1_%s", - INV_PSOC_PREFIX"/psoc_psu2_%s", -}; - -static int -psu_status_info_get(int id, char *node, int *value) -{ - int ret = 0; - char node_path[ONLP_NODE_MAX_PATH_LEN] = {0}; - - *value = 0; - if (PSU1_ID == id) { - sprintf(node_path, status_devfiles__[id]); - } - else if (PSU2_ID == id) { - sprintf(node_path, status_devfiles__[id]); - } - - 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 ONLP_STATUS_OK; -} - - -int -onlp_psui_init(void) -{ - return ONLP_STATUS_OK; -} - -static void -psu_module_name_get(int id, onlp_psu_info_t* info) -{ - char node_path[ONLP_NODE_MAX_PATH_LEN] = {0}; - uint8_t temp[ONLP_CONFIG_INFO_STR_MAX] = {0}; - int ret, len; - - memset(node_path, 0, ONLP_NODE_MAX_PATH_LEN); - sprintf(node_path, module_devfiles__[id], "model"); - ret = onlp_file_read(temp, ONLP_CONFIG_INFO_STR_MAX, &len, node_path); - if (ret == 0) { - /*remove the '\n'*/ - temp[strlen((char*)temp)-1] = 0; - snprintf(info->model, ONLP_CONFIG_INFO_STR_MAX, "%s", temp); - } - else { - AIM_LOG_ERROR("Unable to read model name from file(%s)\r\n", node_path); - aim_strlcpy(info->model, "N/A", 3); - } - - memset(node_path, 0, ONLP_NODE_MAX_PATH_LEN); - sprintf(node_path, module_devfiles__[id], "sn"); - ret = onlp_file_read(temp, ONLP_CONFIG_INFO_STR_MAX, &len, node_path); - if (ret == 0) { - /*remove the '\n'*/ - temp[strlen((char*)temp)-1] = 0; - snprintf(info->serial, ONLP_CONFIG_INFO_STR_MAX, "%s", temp); - } - else { - AIM_LOG_ERROR("Unable to read model name from file(%s)\r\n", node_path); - aim_strlcpy(info->serial, "N/A", 3); - } -} - -static int -psu_module_info_get(int id, onlp_psu_info_t* info) -{ - int ret = 0; - char node_path[ONLP_NODE_MAX_PATH_LEN] = {0}; - int value = 0; - - info->caps |= ONLP_PSU_CAPS_DC12; - - memset(node_path, 0, ONLP_NODE_MAX_PATH_LEN); - sprintf(node_path, module_devfiles__[id], "vout"); - ret = onlp_file_read_int(&value, node_path); - if (ret < 0) { - AIM_LOG_ERROR("Unable to read vout from file(%s)\r\n", node_path); - } - else { - info->mvout = value; - info->caps |= ONLP_PSU_CAPS_VOUT; - } - - memset(node_path, 0, ONLP_NODE_MAX_PATH_LEN); - sprintf(node_path, module_devfiles__[id], "iout"); - ret = onlp_file_read_int(&value, node_path); - if (ret < 0) { - AIM_LOG_ERROR("Unable to read iout from file(%s)\r\n", node_path); - } - else { - info->miout = value; - info->caps |= ONLP_PSU_CAPS_IOUT; - } - - memset(node_path, 0, ONLP_NODE_MAX_PATH_LEN); - sprintf(node_path, module_devfiles__[id], "pout"); - ret = onlp_file_read_int(&value, node_path); - if (ret < 0) { - AIM_LOG_ERROR("Unable to read pout from file(%s)\r\n", node_path); - } - else { - info->mpout = value; - info->caps |= ONLP_PSU_CAPS_POUT; - } - - memset(node_path, 0, ONLP_NODE_MAX_PATH_LEN); - sprintf(node_path, module_devfiles__[id], "vin"); - ret = onlp_file_read_int(&value, node_path); - if (ret < 0) { - AIM_LOG_ERROR("Unable to read vin from file(%s)\r\n", node_path); - } - else { - info->mvin = value; - info->caps |= ONLP_PSU_CAPS_VIN; - } - - memset(node_path, 0, ONLP_NODE_MAX_PATH_LEN); - sprintf(node_path, module_devfiles__[id], "iin"); - ret = onlp_file_read_int(&value, node_path); - if (ret < 0) { - AIM_LOG_ERROR("Unable to read iin from file(%s)\r\n", node_path); - } - else { - info->miin = value; - info->caps |= ONLP_PSU_CAPS_IIN; - } - - memset(node_path, 0, ONLP_NODE_MAX_PATH_LEN); - sprintf(node_path, module_devfiles__[id], "pin"); - ret = onlp_file_read_int(&value, node_path); - if (ret < 0) { - AIM_LOG_ERROR("Unable to read pin from file(%s)\r\n", node_path); - } - else { - info->mpin = value; - info->caps |= ONLP_PSU_CAPS_PIN; - } - - psu_module_name_get(id, info); - 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_THERMAL_ID_CREATE(THERMAL_1_ON_PSU1), - ONLP_FAN_ID_CREATE(FAN_1_ON_PSU1) - } - }, - }, - { - { - ONLP_PSU_ID_CREATE(PSU2_ID), "PSU-2", 0, - { - ONLP_THERMAL_ID_CREATE(THERMAL_1_ON_PSU2), - ONLP_FAN_ID_CREATE(FAN_1_ON_PSU2) - } - }, - } -}; - -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 ((ret = psu_status_info_get(index, "psu", &val)) == ONLP_STATUS_E_INTERNAL) { - printf("Unable to read PSU(%d) node(psu)\r\n", index); - return ret; - } - - if (val == 0) { - info->status = ONLP_PSU_STATUS_PRESENT; - } - else - if (val == 1) { - info->status = ONLP_PSU_STATUS_UNPLUGGED; - return ret; - } - else { - info->status = ONLP_PSU_STATUS_FAILED; - return ret; - } - - if ((ret = psu_module_info_get(index, info)) != ONLP_STATUS_OK) { - printf("Unable to read PSU(%d) module information\r\n", index); - } - - return ret; -} diff --git a/packages/platforms/inventec/x86-64/d5052/onlp/builds/x86_64_inventec_d5052/module/src/sfpi.c b/packages/platforms/inventec/x86-64/d5052/onlp/builds/x86_64_inventec_d5052/module/src/sfpi.c deleted file mode 100644 index ce4638441..000000000 --- a/packages/platforms/inventec/x86-64/d5052/onlp/builds/x86_64_inventec_d5052/module/src/sfpi.c +++ /dev/null @@ -1,215 +0,0 @@ -/************************************************************ - * sfpi.c - * - * Copyright 2018 Inventec Technology Corporation. - * - ************************************************************ - * - ***********************************************************/ -#include - -#include /* For O_RDWR && open */ -#include -#include -#include -#include -#include -#include -#include "platform_lib.h" - -static char sfp_node_path[ONLP_NODE_MAX_PATH_LEN] = {0}; - -#define NUM_OF_SFP_PORT (CHASSIS_SFP_COUNT) -static const int sfp_mux_index[NUM_OF_SFP_PORT] = { - 2, 3, 4, 5 -}; - -#define FRONT_PORT_TO_MUX_INDEX(port) (sfp_mux_index[port]) - -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/class/swps/port%d/%s", 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, 4/52} - */ - 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, "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; - } - if (present == 0) { - present = 1; - } - else - if (present == 1) { - present = 0; - } - else { - AIM_LOG_ERROR("Unvalid present status %d from port(%d)\r\n",present,port); - return ONLP_STATUS_E_INTERNAL; - } - return present; -} - -int -onlp_sfpi_presence_bitmap_get(onlp_sfp_bitmap_t* dst) -{ - uint32_t presence_all[2] = {0}; - int port, ret, index; - - for (port = 0, index = 0; port < NUM_OF_SFP_PORT; port++) { - if (port == 32) { - index = 1; - } - - ret = onlp_sfpi_is_present(port); - if (ret == 1) { - presence_all[index] |= (1<>= 1; - } - return ONLP_STATUS_OK; -} - -int -onlp_sfpi_eeprom_read(int port, uint8_t data[256]) -{ -#if 1 - int bus = FRONT_PORT_TO_MUX_INDEX(port); - - memset(data, 0, 256); - /* Read eeprom information into data[] */ - if (onlp_i2c_read(bus, 0x50, 0x00, 256, data, 0) != 0) - { - AIM_LOG_ERROR("Unable to read eeprom from port(%d)\r\n", port); - return ONLP_STATUS_E_INTERNAL; - } -#else - char* path; - 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); - path = sfp_get_port_path(port, "eeprom"); - if (onlp_file_read(&data[0], 256, &len, path) < 0) { - AIM_LOG_ERROR("Unable to read eeprom from port(%d)\r\n", port); - return ONLP_STATUS_E_INTERNAL; - } -#endif - 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_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/d5052/onlp/builds/x86_64_inventec_d5052/module/src/sysi.c b/packages/platforms/inventec/x86-64/d5052/onlp/builds/x86_64_inventec_d5052/module/src/sysi.c deleted file mode 100644 index 7ccb6bed8..000000000 --- a/packages/platforms/inventec/x86-64/d5052/onlp/builds/x86_64_inventec_d5052/module/src/sysi.c +++ /dev/null @@ -1,110 +0,0 @@ -/************************************************************ - * sysi.c - * - * Copyright 2018 Inventec Technology Corporation. - * - ************************************************************ - * - ***********************************************************/ -#include -#include - -#include -#include -#include -#include -#include -#include - -#include "x86_64_inventec_d5052_int.h" -#include "x86_64_inventec_d5052_log.h" - -#include "platform_lib.h" - -#define NUM_OF_CPLD INV_CPLD_COUNT - -#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 (CHASSIS_PSU_COUNT) -#define NUM_OF_LED_ON_MAIN_BROAD (CHASSIS_LED_COUNT) - -const char* -onlp_sysi_platform_get(void) -{ - return "x86-64-inventec-d5052-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, EEPROM_NODE(eeprom)) == 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)); - - /* 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; -} - -static char *arr_cplddev_version[NUM_OF_CPLD] = -{ - INV_CPLD_PREFIX"/version", -}; - -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, arr_cplddev_version[i]) < 0) { - return ONLP_STATUS_E_INTERNAL; - } - } - pi->cpld_versions = aim_fstrdup("%d.%d", v[0], v[1]); - return 0; -} - -void -onlp_sysi_platform_info_free(onlp_platform_info_t* pi) -{ - aim_free(pi->cpld_versions); -} diff --git a/packages/platforms/inventec/x86-64/d5052/onlp/builds/x86_64_inventec_d5052/module/src/thermali.c b/packages/platforms/inventec/x86-64/d5052/onlp/builds/x86_64_inventec_d5052/module/src/thermali.c deleted file mode 100644 index 0ff463efd..000000000 --- a/packages/platforms/inventec/x86-64/d5052/onlp/builds/x86_64_inventec_d5052/module/src/thermali.c +++ /dev/null @@ -1,132 +0,0 @@ -/************************************************************ - * thermali.c - * - * Copyright 2018 Inventec Technology Corporation. - * - ************************************************************ - * - * 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) - -static char* devfiles__[THERMAL_MAX] = /* must map with onlp_thermal_id */ -{ - "reserved", - INV_CTMP_PREFIX"/temp2_%s", - INV_CTMP_PREFIX"/temp3_%s", - INV_CTMP_PREFIX"/temp4_%s", - INV_CTMP_PREFIX"/temp5_%s", - INV_PSOC_PREFIX"/temp1_input", - INV_PSOC_PREFIX"/temp2_input", - INV_PSOC_PREFIX"/temp3_input", - INV_PSOC_PREFIX"/temp4_input", - INV_PSOC_PREFIX"/temp5_input", - INV_PSOC_PREFIX"/thermal_psu1", - INV_PSOC_PREFIX"/thermal_psu2", -}; - -/* Static values */ -static onlp_thermal_info_t linfo[THERMAL_MAX] = { - { }, /* Not used */ - { { ONLP_THERMAL_ID_CREATE(THERMAL_CPU_CORE_FIRST), "CPU Core 0", 0}, - ONLP_THERMAL_STATUS_PRESENT, - ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS - }, - { { ONLP_THERMAL_ID_CREATE(THERMAL_CPU_CORE_2), "CPU Core 1", 0}, - ONLP_THERMAL_STATUS_PRESENT, - ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS - }, - { { ONLP_THERMAL_ID_CREATE(THERMAL_CPU_CORE_3), "CPU Core 2", 0}, - ONLP_THERMAL_STATUS_PRESENT, - ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS - }, - { { ONLP_THERMAL_ID_CREATE(THERMAL_CPU_CORE_LAST), "CPU Core 3", 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_3_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_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_FIRST && local_id <= THERMAL_CPU_CORE_LAST) { - char desc[32], *dp = &desc[0]; - int rv = onlp_file_read_str(&dp, devfiles__[local_id], "label"); - if (rv > 0) { - memset (info->hdr.description, 0, ONLP_OID_DESC_SIZE); - aim_strlcpy(info->hdr.description, dp, rv); - } - - /* Set the onlp_oid_hdr_t and capabilities */ - return onlp_file_read_int(&info->mcelsius, devfiles__[local_id], "input"); - } - return onlp_file_read_int(&info->mcelsius, devfiles__[local_id]); -} diff --git a/packages/platforms/inventec/x86-64/d5052/onlp/builds/x86_64_inventec_d5052/module/src/x86_64_inventec_d5052_config.c b/packages/platforms/inventec/x86-64/d5052/onlp/builds/x86_64_inventec_d5052/module/src/x86_64_inventec_d5052_config.c deleted file mode 100644 index 3f8e30233..000000000 --- a/packages/platforms/inventec/x86-64/d5052/onlp/builds/x86_64_inventec_d5052/module/src/x86_64_inventec_d5052_config.c +++ /dev/null @@ -1,80 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#include - -/* */ -#define __x86_64_inventec_d5052_config_STRINGIFY_NAME(_x) #_x -#define __x86_64_inventec_d5052_config_STRINGIFY_VALUE(_x) __x86_64_inventec_d5052_config_STRINGIFY_NAME(_x) -x86_64_inventec_d5052_config_settings_t x86_64_inventec_d5052_config_settings[] = -{ -#ifdef X86_64_INVENTEC_D5052_CONFIG_INCLUDE_LOGGING - { __x86_64_inventec_d5052_config_STRINGIFY_NAME(X86_64_INVENTEC_D5052_CONFIG_INCLUDE_LOGGING), __x86_64_inventec_d5052_config_STRINGIFY_VALUE(X86_64_INVENTEC_D5052_CONFIG_INCLUDE_LOGGING) }, -#else -{ X86_64_INVENTEC_D5052_CONFIG_INCLUDE_LOGGING(__x86_64_inventec_d5052_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_INVENTEC_D5052_CONFIG_LOG_OPTIONS_DEFAULT - { __x86_64_inventec_d5052_config_STRINGIFY_NAME(X86_64_INVENTEC_D5052_CONFIG_LOG_OPTIONS_DEFAULT), __x86_64_inventec_d5052_config_STRINGIFY_VALUE(X86_64_INVENTEC_D5052_CONFIG_LOG_OPTIONS_DEFAULT) }, -#else -{ X86_64_INVENTEC_D5052_CONFIG_LOG_OPTIONS_DEFAULT(__x86_64_inventec_d5052_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_INVENTEC_D5052_CONFIG_LOG_BITS_DEFAULT - { __x86_64_inventec_d5052_config_STRINGIFY_NAME(X86_64_INVENTEC_D5052_CONFIG_LOG_BITS_DEFAULT), __x86_64_inventec_d5052_config_STRINGIFY_VALUE(X86_64_INVENTEC_D5052_CONFIG_LOG_BITS_DEFAULT) }, -#else -{ X86_64_INVENTEC_D5052_CONFIG_LOG_BITS_DEFAULT(__x86_64_inventec_d5052_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_INVENTEC_D5052_CONFIG_LOG_CUSTOM_BITS_DEFAULT - { __x86_64_inventec_d5052_config_STRINGIFY_NAME(X86_64_INVENTEC_D5052_CONFIG_LOG_CUSTOM_BITS_DEFAULT), __x86_64_inventec_d5052_config_STRINGIFY_VALUE(X86_64_INVENTEC_D5052_CONFIG_LOG_CUSTOM_BITS_DEFAULT) }, -#else -{ X86_64_INVENTEC_D5052_CONFIG_LOG_CUSTOM_BITS_DEFAULT(__x86_64_inventec_d5052_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_INVENTEC_D5052_CONFIG_PORTING_STDLIB - { __x86_64_inventec_d5052_config_STRINGIFY_NAME(X86_64_INVENTEC_D5052_CONFIG_PORTING_STDLIB), __x86_64_inventec_d5052_config_STRINGIFY_VALUE(X86_64_INVENTEC_D5052_CONFIG_PORTING_STDLIB) }, -#else -{ X86_64_INVENTEC_D5052_CONFIG_PORTING_STDLIB(__x86_64_inventec_d5052_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_INVENTEC_D5052_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS - { __x86_64_inventec_d5052_config_STRINGIFY_NAME(X86_64_INVENTEC_D5052_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS), __x86_64_inventec_d5052_config_STRINGIFY_VALUE(X86_64_INVENTEC_D5052_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS) }, -#else -{ X86_64_INVENTEC_D5052_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS(__x86_64_inventec_d5052_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_INVENTEC_D5052_CONFIG_INCLUDE_UCLI - { __x86_64_inventec_d5052_config_STRINGIFY_NAME(X86_64_INVENTEC_D5052_CONFIG_INCLUDE_UCLI), __x86_64_inventec_d5052_config_STRINGIFY_VALUE(X86_64_INVENTEC_D5052_CONFIG_INCLUDE_UCLI) }, -#else -{ X86_64_INVENTEC_D5052_CONFIG_INCLUDE_UCLI(__x86_64_inventec_d5052_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_INVENTEC_D5052_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION - { __x86_64_inventec_d5052_config_STRINGIFY_NAME(X86_64_INVENTEC_D5052_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION), __x86_64_inventec_d5052_config_STRINGIFY_VALUE(X86_64_INVENTEC_D5052_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION) }, -#else -{ X86_64_INVENTEC_D5052_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION(__x86_64_inventec_d5052_config_STRINGIFY_NAME), "__undefined__" }, -#endif - { NULL, NULL } -}; -#undef __x86_64_inventec_d5052_config_STRINGIFY_VALUE -#undef __x86_64_inventec_d5052_config_STRINGIFY_NAME - -const char* -x86_64_inventec_d5052_config_lookup(const char* setting) -{ - int i; - for(i = 0; x86_64_inventec_d5052_config_settings[i].name; i++) { - if(!strcmp(x86_64_inventec_d5052_config_settings[i].name, setting)) { - return x86_64_inventec_d5052_config_settings[i].value; - } - } - return NULL; -} - -int -x86_64_inventec_d5052_config_show(struct aim_pvs_s* pvs) -{ - int i; - for(i = 0; x86_64_inventec_d5052_config_settings[i].name; i++) { - aim_printf(pvs, "%s = %s\n", x86_64_inventec_d5052_config_settings[i].name, x86_64_inventec_d5052_config_settings[i].value); - } - return i; -} - -/* */ diff --git a/packages/platforms/inventec/x86-64/d5052/onlp/builds/x86_64_inventec_d5052/module/src/x86_64_inventec_d5052_enums.c b/packages/platforms/inventec/x86-64/d5052/onlp/builds/x86_64_inventec_d5052/module/src/x86_64_inventec_d5052_enums.c deleted file mode 100644 index ca2aa2b7e..000000000 --- a/packages/platforms/inventec/x86-64/d5052/onlp/builds/x86_64_inventec_d5052/module/src/x86_64_inventec_d5052_enums.c +++ /dev/null @@ -1,10 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#include - -/* <--auto.start.enum(ALL).source> */ -/* */ - diff --git a/packages/platforms/inventec/x86-64/d5052/onlp/builds/x86_64_inventec_d5052/module/src/x86_64_inventec_d5052_int.h b/packages/platforms/inventec/x86-64/d5052/onlp/builds/x86_64_inventec_d5052/module/src/x86_64_inventec_d5052_int.h deleted file mode 100644 index 93e09267e..000000000 --- a/packages/platforms/inventec/x86-64/d5052/onlp/builds/x86_64_inventec_d5052/module/src/x86_64_inventec_d5052_int.h +++ /dev/null @@ -1,12 +0,0 @@ -/**************************************************************************//** - * - * x86_64_inventec_d5052 Internal Header - * - *****************************************************************************/ -#ifndef __x86_64_inventec_d5052_INT_H__ -#define __x86_64_inventec_d5052_INT_H__ - -#include - - -#endif /* __x86_64_inventec_d5052_INT_H__ */ diff --git a/packages/platforms/inventec/x86-64/d5052/onlp/builds/x86_64_inventec_d5052/module/src/x86_64_inventec_d5052_log.c b/packages/platforms/inventec/x86-64/d5052/onlp/builds/x86_64_inventec_d5052/module/src/x86_64_inventec_d5052_log.c deleted file mode 100644 index 0f4f62efd..000000000 --- a/packages/platforms/inventec/x86-64/d5052/onlp/builds/x86_64_inventec_d5052/module/src/x86_64_inventec_d5052_log.c +++ /dev/null @@ -1,17 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#include - -#include "x86_64_inventec_d5052_log.h" -/* - * x86_64_inventec_d5052 log struct. - */ -AIM_LOG_STRUCT_DEFINE( - X86_64_INVENTEC_D5052_CONFIG_LOG_OPTIONS_DEFAULT, - X86_64_INVENTEC_D5052_CONFIG_LOG_BITS_DEFAULT, - NULL, /* Custom log map */ - X86_64_INVENTEC_D5052_CONFIG_LOG_CUSTOM_BITS_DEFAULT - ); diff --git a/packages/platforms/inventec/x86-64/d5052/onlp/builds/x86_64_inventec_d5052/module/src/x86_64_inventec_d5052_log.h b/packages/platforms/inventec/x86-64/d5052/onlp/builds/x86_64_inventec_d5052/module/src/x86_64_inventec_d5052_log.h deleted file mode 100644 index e795adf39..000000000 --- a/packages/platforms/inventec/x86-64/d5052/onlp/builds/x86_64_inventec_d5052/module/src/x86_64_inventec_d5052_log.h +++ /dev/null @@ -1,12 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#ifndef __x86_64_inventec_d5052_LOG_H__ -#define __x86_64_inventec_d5052_LOG_H__ - -#define AIM_LOG_MODULE_NAME x86_64_inventec_d5052 -#include - -#endif /* __x86_64_inventec_d5052_LOG_H__ */ diff --git a/packages/platforms/inventec/x86-64/d5052/onlp/builds/x86_64_inventec_d5052/module/src/x86_64_inventec_d5052_module.c b/packages/platforms/inventec/x86-64/d5052/onlp/builds/x86_64_inventec_d5052/module/src/x86_64_inventec_d5052_module.c deleted file mode 100644 index 924453966..000000000 --- a/packages/platforms/inventec/x86-64/d5052/onlp/builds/x86_64_inventec_d5052/module/src/x86_64_inventec_d5052_module.c +++ /dev/null @@ -1,24 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#include - -#include "x86_64_inventec_d5052_log.h" - -static int -datatypes_init__(void) -{ -#define x86_64_inventec_d5052_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_d5052_module_init__(void) -{ - AIM_LOG_STRUCT_REGISTER(); - datatypes_init__(); -} - -int __onlp_platform_version__ = 1; diff --git a/packages/platforms/inventec/x86-64/d5052/onlp/builds/x86_64_inventec_d5052/module/src/x86_64_inventec_d5052_ucli.c b/packages/platforms/inventec/x86-64/d5052/onlp/builds/x86_64_inventec_d5052/module/src/x86_64_inventec_d5052_ucli.c deleted file mode 100644 index 731313ddc..000000000 --- a/packages/platforms/inventec/x86-64/d5052/onlp/builds/x86_64_inventec_d5052/module/src/x86_64_inventec_d5052_ucli.c +++ /dev/null @@ -1,50 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#include - -#if x86_64_inventec_d5052_CONFIG_INCLUDE_UCLI == 1 - -#include -#include -#include - -static ucli_status_t -x86_64_inventec_d5052_ucli_ucli__config__(ucli_context_t* uc) -{ - UCLI_HANDLER_MACRO_MODULE_CONFIG(x86_64_inventec_d5052) -} - -/* */ -/* */ - -static ucli_module_t -x86_64_inventec_d5052_ucli_module__ = - { - "x86_64_inventec_d5052_ucli", - NULL, - x86_64_inventec_d5052_ucli_ucli_handlers__, - NULL, - NULL, - }; - -ucli_node_t* -x86_64_inventec_d5052_ucli_node_create(void) -{ - ucli_node_t* n; - ucli_module_init(&x86_64_inventec_d5052_ucli_module__); - n = ucli_node_create("x86_64_inventec_d5052", NULL, &x86_64_inventec_d5052_ucli_module__); - ucli_node_subnode_add(n, ucli_module_log_node_create("x86_64_inventec_d5052")); - return n; -} - -#else -void* -x86_64_inventec_d5052_ucli_node_create(void) -{ - return NULL; -} -#endif - diff --git a/packages/platforms/inventec/x86-64/d5052/platform-config/Makefile b/packages/platforms/inventec/x86-64/d5052/platform-config/Makefile deleted file mode 100644 index 003238cf6..000000000 --- a/packages/platforms/inventec/x86-64/d5052/platform-config/Makefile +++ /dev/null @@ -1 +0,0 @@ -include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/inventec/x86-64/d5052/platform-config/r0/Makefile b/packages/platforms/inventec/x86-64/d5052/platform-config/r0/Makefile deleted file mode 100644 index 003238cf6..000000000 --- a/packages/platforms/inventec/x86-64/d5052/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/inventec/x86-64/d5052/platform-config/r0/PKG.yml b/packages/platforms/inventec/x86-64/d5052/platform-config/r0/PKG.yml deleted file mode 100644 index b3efaac6f..000000000 --- a/packages/platforms/inventec/x86-64/d5052/platform-config/r0/PKG.yml +++ /dev/null @@ -1 +0,0 @@ -!include $ONL_TEMPLATES/platform-config-platform.yml ARCH=amd64 VENDOR=inventec BASENAME=x86-64-inventec-d5052 REVISION=r0 diff --git a/packages/platforms/inventec/x86-64/d5052/platform-config/r0/src/lib/x86-64-inventec-d5052-r0.yml b/packages/platforms/inventec/x86-64/d5052/platform-config/r0/src/lib/x86-64-inventec-d5052-r0.yml deleted file mode 100644 index e28ebbb52..000000000 --- a/packages/platforms/inventec/x86-64/d5052/platform-config/r0/src/lib/x86-64-inventec-d5052-r0.yml +++ /dev/null @@ -1,32 +0,0 @@ ---- - -###################################################################### -# -# platform-config for d5052 -# -###################################################################### - -x86-64-inventec-d5052-r0: - - grub: - - serial: >- - --port=0x2f8 - --speed=115200 - --word=8 - --parity=no - --stop=1 - - kernel: - <<: *kernel-3-16 - - args: >- - nopat - console=ttyS1,115200n8 - i2c-ismt.enable=0 - - ##network - ## interfaces: - ## ma1: - ## name: ~ - ## syspath: pci0000:00/0000:00:14.0 diff --git a/packages/platforms/inventec/x86-64/d5052/platform-config/r0/src/python/x86_64_inventec_d5052_r0/__init__.py b/packages/platforms/inventec/x86-64/d5052/platform-config/r0/src/python/x86_64_inventec_d5052_r0/__init__.py deleted file mode 100644 index aadb7ecef..000000000 --- a/packages/platforms/inventec/x86-64/d5052/platform-config/r0/src/python/x86_64_inventec_d5052_r0/__init__.py +++ /dev/null @@ -1,23 +0,0 @@ -from onl.platform.base import * -from onl.platform.inventec import * - -class OnlPlatform_x86_64_inventec_d5052_r0(OnlPlatformInventec, - OnlPlatformPortConfig_48x1_4x10): - PLATFORM='x86-64-inventec-d5052-r0' - MODEL="X86-D5052" - SYS_OBJECT_ID=".5052.1" - - def baseconfig(self): - os.system("insmod /lib/modules/`uname -r`/kernel/drivers/gpio/gpio-ich.ko") - self.insmod('i2c-gpio') - self.insmod('inv_platform') - self.insmod('inv_psoc') - self.insmod('inv_cpld') - self.new_i2c_device('inv_eeprom', 0x53, 0) - self.insmod('inv_eeprom') - self.new_i2c_device('inv_psoc', 0x66, 1) - self.new_i2c_device('inv_cpld', 0x55, 1) - self.insmod('swps') - #self.insmod('vpd') - self.insmod('inv_pthread') - return True diff --git a/packages/platforms/inventec/x86-64/d5254/.gitignore b/packages/platforms/inventec/x86-64/d5254/.gitignore deleted file mode 100644 index b4db5ae93..000000000 --- a/packages/platforms/inventec/x86-64/d5254/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -*x86*64*inventec*d5254*.mk -onlpdump.mk diff --git a/packages/platforms/inventec/x86-64/d5254/Makefile b/packages/platforms/inventec/x86-64/d5254/Makefile deleted file mode 100644 index 003238cf6..000000000 --- a/packages/platforms/inventec/x86-64/d5254/Makefile +++ /dev/null @@ -1 +0,0 @@ -include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/inventec/x86-64/d5254/modules/Makefile b/packages/platforms/inventec/x86-64/d5254/modules/Makefile deleted file mode 100644 index 003238cf6..000000000 --- a/packages/platforms/inventec/x86-64/d5254/modules/Makefile +++ /dev/null @@ -1 +0,0 @@ -include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/inventec/x86-64/d5254/modules/PKG.yml b/packages/platforms/inventec/x86-64/d5254/modules/PKG.yml deleted file mode 100644 index 016745580..000000000 --- a/packages/platforms/inventec/x86-64/d5254/modules/PKG.yml +++ /dev/null @@ -1 +0,0 @@ -!include $ONL_TEMPLATES/platform-modules.yml VENDOR=inventec BASENAME=x86-64-inventec-d5254 ARCH=amd64 KERNELS="onl-kernel-4.14-lts-x86-64-all:amd64" diff --git a/packages/platforms/inventec/x86-64/d5254/modules/builds/.gitignore b/packages/platforms/inventec/x86-64/d5254/modules/builds/.gitignore deleted file mode 100644 index a65b41774..000000000 --- a/packages/platforms/inventec/x86-64/d5254/modules/builds/.gitignore +++ /dev/null @@ -1 +0,0 @@ -lib diff --git a/packages/platforms/inventec/x86-64/d5254/modules/builds/Makefile b/packages/platforms/inventec/x86-64/d5254/modules/builds/Makefile deleted file mode 100644 index d8c55dd90..000000000 --- a/packages/platforms/inventec/x86-64/d5254/modules/builds/Makefile +++ /dev/null @@ -1,6 +0,0 @@ -KERNELS := onl-kernel-4.14-lts-x86-64-all:amd64 -KMODULES := src -VENDOR := inventec -BASENAME := x86-64-inventec-d5254 -ARCH := x86_64 -include $(ONL)/make/kmodule.mk diff --git a/packages/platforms/inventec/x86-64/d5254/modules/builds/src/Makefile b/packages/platforms/inventec/x86-64/d5254/modules/builds/src/Makefile deleted file mode 100644 index a7d92125d..000000000 --- a/packages/platforms/inventec/x86-64/d5254/modules/builds/src/Makefile +++ /dev/null @@ -1,8 +0,0 @@ -obj-m += i2c-gpio.o -obj-m += inv_cpld.o -obj-m += inv_platform.o -obj-m += inv_psoc.o -obj-m += swps.o -swps-objs := inv_swps.o inv_mux.o io_expander.o transceiver.o -obj-m += vpd.o -vpd-objs := inv_vpd.o onie_tlvinfo.o diff --git a/packages/platforms/inventec/x86-64/d5254/modules/builds/src/i2c-gpio.c b/packages/platforms/inventec/x86-64/d5254/modules/builds/src/i2c-gpio.c deleted file mode 100644 index 34cfc0ebd..000000000 --- a/packages/platforms/inventec/x86-64/d5254/modules/builds/src/i2c-gpio.c +++ /dev/null @@ -1,290 +0,0 @@ -/* - * Bitbanging I2C bus driver using the GPIO API - * - * Copyright (C) 2007 Atmel Corporation - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. - */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -struct i2c_gpio_private_data { - struct i2c_adapter adap; - struct i2c_algo_bit_data bit_data; - struct i2c_gpio_platform_data pdata; -}; - -/* Toggle SDA by changing the direction of the pin */ -static void i2c_gpio_setsda_dir(void *data, int state) -{ - struct i2c_gpio_platform_data *pdata = data; - - if (state) - gpio_direction_input(pdata->sda_pin); - else - gpio_direction_output(pdata->sda_pin, 0); -} - -/* - * Toggle SDA by changing the output value of the pin. This is only - * valid for pins configured as open drain (i.e. setting the value - * high effectively turns off the output driver.) - */ -static void i2c_gpio_setsda_val(void *data, int state) -{ - struct i2c_gpio_platform_data *pdata = data; - - gpio_set_value(pdata->sda_pin, state); -} - -/* Toggle SCL by changing the direction of the pin. */ -static void i2c_gpio_setscl_dir(void *data, int state) -{ - struct i2c_gpio_platform_data *pdata = data; - - if (state) - gpio_direction_input(pdata->scl_pin); - else - gpio_direction_output(pdata->scl_pin, 0); -} - -/* - * Toggle SCL by changing the output value of the pin. This is used - * for pins that are configured as open drain and for output-only - * pins. The latter case will break the i2c protocol, but it will - * often work in practice. - */ -static void i2c_gpio_setscl_val(void *data, int state) -{ - struct i2c_gpio_platform_data *pdata = data; - - gpio_set_value(pdata->scl_pin, state); -} - -static int i2c_gpio_getsda(void *data) -{ - struct i2c_gpio_platform_data *pdata = data; - - return gpio_get_value(pdata->sda_pin); -} - -static int i2c_gpio_getscl(void *data) -{ - struct i2c_gpio_platform_data *pdata = data; - - return gpio_get_value(pdata->scl_pin); -} - -static int of_i2c_gpio_get_pins(struct device_node *np, - unsigned int *sda_pin, unsigned int *scl_pin) -{ - if (of_gpio_count(np) < 2) - return -ENODEV; - - *sda_pin = of_get_gpio(np, 0); - *scl_pin = of_get_gpio(np, 1); - - if (*sda_pin == -EPROBE_DEFER || *scl_pin == -EPROBE_DEFER) - return -EPROBE_DEFER; - - if (!gpio_is_valid(*sda_pin) || !gpio_is_valid(*scl_pin)) { - pr_err("%s: invalid GPIO pins, sda=%d/scl=%d\n", - np->full_name, *sda_pin, *scl_pin); - return -ENODEV; - } - - return 0; -} - -static void of_i2c_gpio_get_props(struct device_node *np, - struct i2c_gpio_platform_data *pdata) -{ - u32 reg; - - of_property_read_u32(np, "i2c-gpio,delay-us", &pdata->udelay); - - if (!of_property_read_u32(np, "i2c-gpio,timeout-ms", ®)) - pdata->timeout = msecs_to_jiffies(reg); - - pdata->sda_is_open_drain = - of_property_read_bool(np, "i2c-gpio,sda-open-drain"); - pdata->scl_is_open_drain = - of_property_read_bool(np, "i2c-gpio,scl-open-drain"); - pdata->scl_is_output_only = - of_property_read_bool(np, "i2c-gpio,scl-output-only"); -} - -static int i2c_gpio_probe(struct platform_device *pdev) -{ - struct i2c_gpio_private_data *priv; - struct i2c_gpio_platform_data *pdata; - struct i2c_algo_bit_data *bit_data; - struct i2c_adapter *adap; - unsigned int sda_pin, scl_pin; - int ret; - - /* First get the GPIO pins; if it fails, we'll defer the probe. */ - if (pdev->dev.of_node) { - ret = of_i2c_gpio_get_pins(pdev->dev.of_node, - &sda_pin, &scl_pin); - if (ret) - return ret; - } else { - if (!dev_get_platdata(&pdev->dev)) - return -ENXIO; - pdata = dev_get_platdata(&pdev->dev); - sda_pin = pdata->sda_pin; - scl_pin = pdata->scl_pin; - } - - ret = devm_gpio_request(&pdev->dev, sda_pin, "sda"); - if (ret) { - if (ret == -EINVAL) - ret = -EPROBE_DEFER; /* Try again later */ - return ret; - } - ret = devm_gpio_request(&pdev->dev, scl_pin, "scl"); - if (ret) { - if (ret == -EINVAL) - ret = -EPROBE_DEFER; /* Try again later */ - return ret; - } - - priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL); - if (!priv) - return -ENOMEM; - adap = &priv->adap; - bit_data = &priv->bit_data; - pdata = &priv->pdata; - - if (pdev->dev.of_node) { - pdata->sda_pin = sda_pin; - pdata->scl_pin = scl_pin; - of_i2c_gpio_get_props(pdev->dev.of_node, pdata); - } else { - memcpy(pdata, dev_get_platdata(&pdev->dev), sizeof(*pdata)); - } - - if (pdata->sda_is_open_drain) { - gpio_direction_output(pdata->sda_pin, 1); - bit_data->setsda = i2c_gpio_setsda_val; - } else { - gpio_direction_input(pdata->sda_pin); - bit_data->setsda = i2c_gpio_setsda_dir; - } - - if (pdata->scl_is_open_drain || pdata->scl_is_output_only) { - gpio_direction_output(pdata->scl_pin, 1); - bit_data->setscl = i2c_gpio_setscl_val; - } else { - gpio_direction_input(pdata->scl_pin); - bit_data->setscl = i2c_gpio_setscl_dir; - } - - if (!pdata->scl_is_output_only) - bit_data->getscl = i2c_gpio_getscl; - bit_data->getsda = i2c_gpio_getsda; - - if (pdata->udelay) - bit_data->udelay = pdata->udelay; - else if (pdata->scl_is_output_only) - bit_data->udelay = 50; /* 10 kHz */ - else - bit_data->udelay = 5; /* 100 kHz */ - - if (pdata->timeout) - bit_data->timeout = pdata->timeout; - else - bit_data->timeout = HZ / 10; /* 100 ms */ - - bit_data->data = pdata; - - adap->owner = THIS_MODULE; - if (pdev->dev.of_node) - strlcpy(adap->name, dev_name(&pdev->dev), sizeof(adap->name)); - else - snprintf(adap->name, sizeof(adap->name), "i2c-gpio%d", pdev->id); - - adap->algo_data = bit_data; - adap->class = I2C_CLASS_HWMON | I2C_CLASS_SPD; - adap->dev.parent = &pdev->dev; - adap->dev.of_node = pdev->dev.of_node; - - adap->nr = pdev->id; - ret = i2c_bit_add_numbered_bus(adap); - if (ret) - return ret; - - platform_set_drvdata(pdev, priv); - - dev_info(&pdev->dev, "using pins %u (SDA) and %u (SCL%s)\n", - pdata->sda_pin, pdata->scl_pin, - pdata->scl_is_output_only - ? ", no clock stretching" : ""); - - return 0; -} - -static int i2c_gpio_remove(struct platform_device *pdev) -{ - struct i2c_gpio_private_data *priv; - struct i2c_adapter *adap; - - priv = platform_get_drvdata(pdev); - adap = &priv->adap; - - i2c_del_adapter(adap); - - return 0; -} - -#if defined(CONFIG_OF) -static const struct of_device_id i2c_gpio_dt_ids[] = { - { .compatible = "i2c-gpio", }, - { /* sentinel */ } -}; - -MODULE_DEVICE_TABLE(of, i2c_gpio_dt_ids); -#endif - -static struct platform_driver i2c_gpio_driver = { - .driver = { - .name = "i2c-gpio", - .of_match_table = of_match_ptr(i2c_gpio_dt_ids), - }, - .probe = i2c_gpio_probe, - .remove = i2c_gpio_remove, -}; - -static int __init i2c_gpio_init(void) -{ - int ret; - - ret = platform_driver_register(&i2c_gpio_driver); - if (ret) - printk(KERN_ERR "i2c-gpio: probe failed: %d\n", ret); - - return ret; -} -subsys_initcall(i2c_gpio_init); - -static void __exit i2c_gpio_exit(void) -{ - platform_driver_unregister(&i2c_gpio_driver); -} -module_exit(i2c_gpio_exit); - -MODULE_AUTHOR("Haavard Skinnemoen (Atmel)"); -MODULE_DESCRIPTION("Platform-independent bitbanging I2C driver"); -MODULE_LICENSE("GPL"); -MODULE_ALIAS("platform:i2c-gpio"); diff --git a/packages/platforms/inventec/x86-64/d5254/modules/builds/src/inv_cpld.c b/packages/platforms/inventec/x86-64/d5254/modules/builds/src/inv_cpld.c deleted file mode 100644 index 57791f62e..000000000 --- a/packages/platforms/inventec/x86-64/d5254/modules/builds/src/inv_cpld.c +++ /dev/null @@ -1,463 +0,0 @@ -/* - * 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 -#define CPLD_BIOSCS_OFFSET 0x04 - - -/* 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 ssize_t show_bios_cs(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_BIOSCS_OFFSET, 1); - - mutex_unlock(&data->update_lock); - - if(status != 1) return sprintf(buf, "read cpld BIOS_CS fail\n"); - - - status = sprintf (buf, "0x%X\n", b[0] & 0x01); - - return strlen(buf); -} - -static ssize_t set_bios_cs(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_BIOSCS_OFFSET, 1); - if(temp) byte |= 0x01; - else byte &= ~(0x01); - cpld_i2c_write(client, &byte, CPLD_BIOSCS_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 SENSOR_DEVICE_ATTR(bios_cs, S_IWUSR|S_IRUGO, show_bios_cs, set_bios_cs, 0); - -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, - - &sensor_dev_attr_bios_cs.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/d5254/modules/builds/src/inv_mux.c b/packages/platforms/inventec/x86-64/d5254/modules/builds/src/inv_mux.c deleted file mode 100644 index 482a8cb1a..000000000 --- a/packages/platforms/inventec/x86-64/d5254/modules/builds/src/inv_mux.c +++ /dev/null @@ -1,284 +0,0 @@ -#include -#include -#include -#include -#include -/* For build single module using (Ex: ONL platform) */ -#include -#include "io_expander.h" -#include "inv_mux.h" - - -static struct mux_obj_s *mux_head_p = NULL; - - -/* ========== MUX object functions ========== - */ -int -_common_force_pull_gpio(int mem_addr, - int input, - int bit_offset){ - - unsigned int val = 0; - unsigned int targ = 0; - - /* Get current value */ - val = inl(mem_addr); - if (val == 0) { - SWPS_ERR("%s: inl:%d fail!\n", __func__, val); - return -1; - } - /* Count target value */ - switch (input) { - case 0: /* Pull Low */ - targ = (val & (~(1 << bit_offset))); - break; - case 1: /* Pull high */ - targ = (val | (1 << bit_offset)); - break; - default: - SWPS_ERR("%s: input state:%d incorrect!\n", - __func__, input); - return -1; - } - /* Setup gpio */ - outl(targ, mem_addr); - if (targ != inl(mem_addr)){ - SWPS_ERR("%s: outl:%d fail!\n", __func__, targ); - return -1; - } - SWPS_DEBUG("%s: done.\n", __func__); - return 0; -} - - -int -rangeley_force_pull_high(struct mux_obj_s *self){ - SWPS_ERR("%s: not ready!\n", __func__); - return -1; -} - - -int -rangeley_force_pull_low(struct mux_obj_s *self){ - SWPS_ERR("%s: not ready!\n", __func__); - return -1; -} - - -int -hedera_force_pull_high(struct mux_obj_s *self){ - return _common_force_pull_gpio(MUX_RST_MEM_ADDR_HEDERA, 1, 5); -} - - -int -hedera_force_pull_low(struct mux_obj_s *self){ - return _common_force_pull_gpio(MUX_RST_MEM_ADDR_HEDERA, 0, 5); -} - - -int -normal_gpio_pull_high(struct mux_obj_s *self){ - return gpio_direction_output(self->gpio_num, 1); -} - - -int -normal_gpio_pull_low(struct mux_obj_s *self){ - return gpio_direction_output(self->gpio_num, 0); -} - - -int -pca9548_reset_mux_all(struct mux_obj_s *self){ - /* [Note] Power-on reset (PCA9548A-NXP) - * When power is applied to VDD, an internal Power-On Reset (POR) - * holds the PCA9548A in a reset condition until VDD has reached - * VPOR. At this point, the reset condition is released and the - * PCA9548A register and I2C-bus state machine are initialized to - * their default states (all zeroes) causing all the channels to - * be deselected. Thereafter, VDD must be lowered below 0.2 V for - * at least 5 us in order to reset the device. - */ - if (self->_pull_low(self) < 0) { - SWPS_ERR("%s: _pull_low fail!\n", __func__); - return -1; - } - mdelay(MUX_RST_WAIT_MS); - if (self->_pull_high(self) < 0) { - SWPS_ERR("%s: _pull_high fail!\n", __func__); - return -1; - } - mdelay(MUX_RST_WAIT_MS); - return 0; -} - - -int -common_reset_mux_all(struct mux_obj_s *self){ - SWPS_ERR("%s: not ready!\n", __func__); - return -1; -} - - -int -init_gpio_4_force(struct mux_obj_s *self){ - return 0; -} - - -int -init_gpio_4_normal(struct mux_obj_s *self){ - - int err = 0; - - if (!gpio_is_valid(self->gpio_num)) { - SWPS_ERR("%s: GIPO:%d isn't valid\n", __func__, self->gpio_num); - return -1; - } - err = gpio_request(self->gpio_num, MUX_GPIO_LABEL); - if (err < 0) { - SWPS_ERR("%s: gpio_request fail :%d :%d\n", - __func__, err, self->gpio_num); - return -1; - } - SWPS_DEBUG("%s: gpio_request:%d ok.\n", __func__, self->gpio_num); - return 0; -} - - -static int -_setup_muxctl_cb(struct mux_obj_s *self, - unsigned gpio){ - - char mod_dsc[32] = "ERR"; - - switch (gpio) { - case MUX_RST_GPIO_FORCE_RANGELEY: - self->gpio_num = gpio; - self->_pull_low = rangeley_force_pull_low; - self->_pull_high = rangeley_force_pull_high; - self->_init = init_gpio_4_force; - self->reset = pca9548_reset_mux_all; - memset(mod_dsc, 0, 32); - snprintf(mod_dsc, 31, "Rangeley force mode"); - goto ok_setup_muxctl_cb; - - case MUX_RST_GPIO_FORCE_HEDERA: - self->gpio_num = gpio; - self->_pull_low = hedera_force_pull_low; - self->_pull_high = hedera_force_pull_high; - self->_init = init_gpio_4_force; - self->reset = pca9548_reset_mux_all; - memset(mod_dsc, 0, 32); - snprintf(mod_dsc, 31, "Hedera force mode"); - goto ok_setup_muxctl_cb; - - case MUX_RST_GPIO_48_PAC9548: - case MUX_RST_GPIO_69_PAC9548: - case MUX_RST_GPIO_249_PCA9548: - case MUX_RST_GPIO_500_PAC9548: - case MUX_RST_GPIO_505_PCA9548: - self->gpio_num = gpio; - self->_pull_low = normal_gpio_pull_low; - self->_pull_high = normal_gpio_pull_high; - self->_init = init_gpio_4_normal; - self->reset = pca9548_reset_mux_all; - memset(mod_dsc, 0, 32); - snprintf(mod_dsc, 31, "Normal mode :%d", (int)gpio); - goto ok_setup_muxctl_cb; - - default: - break; - } - SWPS_ERR("%s: Unexpected GPIO:%d\n", __func__, gpio); - return -1; - -ok_setup_muxctl_cb: - SWPS_INFO("muxctl: %s.\n", mod_dsc); - return 0; -} - - -/* ========== MUX public functions ========== - */ -void -clean_mux_gpio(void){ - - if (!mux_head_p) { - SWPS_DEBUG("%s: mux_head_p is NULL\n", __func__); - return; - } - if (gpio_is_valid(mux_head_p->gpio_num)) { - gpio_free(mux_head_p->gpio_num); - } - kfree(mux_head_p); - mux_head_p = NULL; - SWPS_DEBUG("%s: done.\n", __func__); -} -EXPORT_SYMBOL(clean_mux_gpio); - - -int -reset_mux_gpio(void){ - - if (!mux_head_p) { - SWPS_ERR("%s: MUX ctl object doesn't exist!\n", __func__); - return -1; - } - if (mux_head_p->reset(mux_head_p) < 0){ - SWPS_ERR("%s: reset fail!\n", __func__); - return -1; - } - return 0; -} -EXPORT_SYMBOL(reset_mux_gpio); - - -int -init_mux_gpio(unsigned gpio){ - - /* Create MUX control object */ - if (mux_head_p) { - SWPS_DEBUG("%s: mux_head_p is not NULL!\n", __func__); - clean_mux_gpio(); - } - /* Currently, it is using single muxctl architecture. - * In the future, it may use the multi-muxctl if HW add new features. - * (Ex: Port power-status control) - */ - mux_head_p = kzalloc(sizeof(struct mux_obj_s), GFP_KERNEL); - if (!mux_head_p) { - SWPS_ERR("%s: kzalloc fail!\n", __func__); - return -1; - } - /* Initial MUX controller */ - if (_setup_muxctl_cb(mux_head_p, gpio) < 0){ - SWPS_ERR("%s: _setup_muxctl_cb fail!\n", __func__); - return -1; - } - if (mux_head_p->_init(mux_head_p) < 0) { - SWPS_ERR("%s: init() fail\n", __func__); - goto err_init_mux_gpio; - } - /* Setup default value */ - if (mux_head_p->_pull_high(mux_head_p) < 0) { - SWPS_ERR("%s: setup default fail!\n", __func__); - goto err_init_mux_gpio; - } - return 0; - -err_init_mux_gpio: - clean_mux_gpio(); - return -1; -} -EXPORT_SYMBOL(init_mux_gpio); - -/* For single ko module - * => You need to declare MODULE_LICENSE If you want to build single module along. - * => Ex: For ONL platform - */ -MODULE_LICENSE("GPL"); - - diff --git a/packages/platforms/inventec/x86-64/d5254/modules/builds/src/inv_mux.h b/packages/platforms/inventec/x86-64/d5254/modules/builds/src/inv_mux.h deleted file mode 100644 index f316de4c2..000000000 --- a/packages/platforms/inventec/x86-64/d5254/modules/builds/src/inv_mux.h +++ /dev/null @@ -1,41 +0,0 @@ -#ifndef INV_MUX_H -#define INV_MUX_H - - -/* MUX basic information */ -#define MUX_GPIO_LABEL "SWPS_RST_MUX" - -/* MUX reset GPIO define */ -#define MUX_RST_GPIO_FORCE (30100) -#define MUX_RST_GPIO_FORCE_RANGELEY (30101) -#define MUX_RST_GPIO_FORCE_HEDERA (30102) -#define MUX_RST_GPIO_48_PAC9548 (48) -#define MUX_RST_GPIO_69_PAC9548 (69) -#define MUX_RST_GPIO_249_PCA9548 (249) -#define MUX_RST_GPIO_500_PAC9548 (500) -#define MUX_RST_GPIO_505_PCA9548 (505) - -/* MUX relate value define */ -#define MUX_RST_WAIT_MS (1) -#define MUX_RST_MEM_ADDR_RANGELEY (0) // TBD -#define MUX_RST_MEM_ADDR_HEDERA (0x548) - -struct mux_obj_s { - unsigned gpio_num; - int (*_pull_high)(struct mux_obj_s *self); - int (*_pull_low)(struct mux_obj_s *self); - int (*_init)(struct mux_obj_s *self); - int (*reset)(struct mux_obj_s *self); -}; - - -void clean_mux_gpio(void); -int reset_mux_gpio(void); -int init_mux_gpio(unsigned gpio); - - -#endif /* INV_MUX_H */ - - - - diff --git a/packages/platforms/inventec/x86-64/d5254/modules/builds/src/inv_platform.c b/packages/platforms/inventec/x86-64/d5254/modules/builds/src/inv_platform.c deleted file mode 100644 index 1583cfeb3..000000000 --- a/packages/platforms/inventec/x86-64/d5254/modules/builds/src/inv_platform.c +++ /dev/null @@ -1,221 +0,0 @@ -#include -//#include -#include -#include -#include -#include -#include -#include -#include -//#include -//#include - -//#include -//#define IO_EXPAND_BASE 64 -//#define IO_EXPAND_NGPIO 16 - -#define GPIO_BASE 0 /* in kernel 4.x GPIO_BASE=0*/ - -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, 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 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[] = { - {bus_id(1), ARRAY_SIZE(i2c_device_info0), i2c_device_info0 }, //mux root - - {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 -}; - -///////////////////////////////////////////////////////////////////////////////////////// -static struct i2c_gpio_platform_data i2c_gpio_platdata0 = { - .scl_pin = GPIO_BASE+58, //494,//58, - .sda_pin = GPIO_BASE+75, //511,//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 = 1, // adapter number - .dev.platform_data = &i2c_gpio_platdata0, -}; - -static int __init inv_platform_init(void) -{ - struct i2c_adapter *adap = NULL; - struct i2c_client *e = NULL; - int ret = 0; - int i,j,k; - - //printk("%s \n", __func__); - - //use i2c-gpio - //register i2c gpio - //config gpio58,75 to gpio function 58=32+3*8+2 75=32*2+8*1+3 gpio69=32*2+8*0+5 - outl( inl(0x533) | (1<<2), 0x533); - outl( inl(0x541) | (1<<3), 0x541); - outl( inl(0x540) | (1<<5), 0x540); //RST_I2C_MUX_N (GPIO69) - outl( inl(0x500) | (1<<7), 0x500); //SYS_RDY_N (GPIO7) - outl( inl(0x501) | (1<<7), 0x501); //BMC_HEART_BEAT (GPIO15) - outl( inl(0x503) | (1<<2)|(1<<3), 0x503); //PSOC_HEART_BEAT(26),CPLD_HEART_BEAT(27) - - ret = platform_device_register(&device_i2c_gpio0); - if (ret) { - printk(KERN_ERR "i2c-gpio: device_i2c_gpio0 register fail %d\n", ret); - } - - for(i=0; i -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#define SWITCH_TEMPERATURE_SOCK "/proc/switch/temp" -#define PSOC_POLLING_PERIOD 1000 - -#include -#include -#include -#include - -#define IPMI_MAX_INTF (4) -#define NETFN_OEM 0x30 -#define CMD_GETDATA 0x31 -#define CMD_SETDATA 0x32 -#define FAN_NUM 5 -#define PSU_NUM 2 - -#define FAN_CLEI_SUPPORT 1 -#define PSU_CLEI_SUPPORT 0 - -#define PSU1 0x5800 -#define PSU2 0x5900 -#define BMC_PMBusNumber 3 -#define PMBus_Vendor 0x99 -#define PMBus_Serial 0x9E -#define PMBus_Temp2 0x8E -#define PMBus_Version 0x9B -#define MaxLeng_Result 0x40 - -#define BMC_FanCLEIBusNumber 9 -#define DEVICE_CLEI_ADDR 0x52,0x53,0x54,0x55,0x56,0x50,0x51 - -#define MAX_IPMI_RECV_LENGTH 0xff -static char CLEI_ADDR[]={DEVICE_CLEI_ADDR}; -struct task_struct *kthread_auto_update; -static long pmbus_reg2data_linear(int data, int linear16); -struct ipmi_result{ - char result[MAX_IPMI_RECV_LENGTH]; - int result_length; -}; - -DEFINE_MUTEX(ipmi_mutex); -DEFINE_MUTEX(ipmi2_mutex); -static struct ipmi_result ipmiresult; -static struct device *hwmon_dev; -static struct kobject *device_kobj; -static ipmi_user_t ipmi_mh_user = NULL; -static void msg_handler(struct ipmi_recv_msg *msg,void* handler_data); -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 -}; - -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__)) clei { - u8 issue_number[3]; - u8 abbreviation_number[9]; - u8 fc_number[10]; - u8 clei_code[10]; - u8 product_year_and_month[5]; - u8 label_location_code[2]; - u8 serial_number[5]; - u8 pcb_revision[5]; - u8 vendor_name[10]; - u8 reserved[5]; -}; - -struct __attribute__ ((__packed__)) psoc_layout { - u8 ctl; //offset: 0 - u16 switch_temp; //offset: 1 - - // BYTE[03:20] - voltage - u16 voltage[15]; //offset: 0x03-0x20 - - // BYTE[21:27] - ExtFan - u8 led_ctl2; //offset: 21 - u8 ext_pwm; //offset: 22 - u16 ext_rpm[2]; //offset: 23 - u8 gpi_fan2; //offset: 27 - - //gpo - u8 led_ctl; //offset: 28 - - u8 gpio; //offset: 29 - - //pwm duty - u8 pwm[4]; //offset: 2a - u8 pwm_psu[2]; //offset: 2e - - //fan rpm - u16 fan[4*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[2]; //offset: 50 - - //version - u8 version[2]; //offset: 54 - - u8 reserve2[4]; //offset: 56 - 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) -#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) - -#define PWM2_OFFSET PSOC_OFF(ext_pwm) -#define RPM2_OFFSET PSOC_OFF(ext_rpm) -#define FAN_LED2_OFFSET PSOC_OFF(led_ctl2) -#define FAN_GPI2_OFFSET PSOC_OFF(gpi_fan2) - -#define CLEI_OFF(m) offsetof(struct clei, m) -#define FAN1_CLEI_INDEX 0 -#define FAN2_CLEI_INDEX 1 -#define FAN3_CLEI_INDEX 2 -#define FAN4_CLEI_INDEX 3 -#define FAN5_CLEI_INDEX 4 -#define PSU1_CLEI_INDEX 5 -#define PSU2_CLEI_INDEX 6 - -static void msg_handler(struct ipmi_recv_msg *recv_msg,void* handler_data) -{ - struct ipmi_result *msg_result = recv_msg->user_msg_data; - - if(recv_msg->msg.data[0]==0 && recv_msg->msg.data_len>0) { - msg_result->result_length=recv_msg->msg.data_len-1; - memcpy(msg_result->result, &recv_msg->msg.data[1], recv_msg->msg.data_len-1); - } - ipmi_free_recv_msg(recv_msg); - mutex_unlock(&ipmi_mutex); - - return; -} - -int start_ipmi_command(char NetFn, char cmd,char *data,int data_length, char* result, int* result_length) -{ - int rv=0,i; - int timeout; - - //wait previous command finish at least 50msec - timeout=50; - while((mutex_is_locked(&ipmi_mutex) == 1 || (mutex_is_locked(&ipmi2_mutex) == 1)) && (--timeout)>0) { usleep_range(1000,1010); } - if(timeout==0) { return -1; } - mutex_lock(&ipmi_mutex); - mutex_lock(&ipmi2_mutex); - - if(ipmi_mh_user == NULL) { - for (i=0,rv=1; i0) { usleep_range(1000,1100);} - if(timeout==0) { - mutex_unlock(&ipmi2_mutex); - return -1; - } - else { - *result_length=ipmiresult.result_length; - memcpy(result,ipmiresult.result,*result_length); - mutex_unlock(&ipmi2_mutex); - return 0; - } - } - return 0; -} -EXPORT_SYMBOL(start_ipmi_command); - -static ssize_t psoc_ipmi_read(u8 *buf, u8 offset, size_t count) -{ - uint8_t data[2]; - int result_len=0; - int rv; - - data[0] = offset; - data[1] = count; - - rv=start_ipmi_command(NETFN_OEM, CMD_GETDATA,data,2, buf, &result_len); - - return result_len; -} - -static ssize_t psoc_ipmi_write(char *buf, unsigned offset, size_t count) -{ - uint8_t data[count+1],result[1]; - int result_len; - - data[0] = offset; - memcpy(&data[1],buf,count); - - start_ipmi_command(NETFN_OEM, CMD_SETDATA,data,count+1, result, &result_len); - return count; -} - - -static u16 psoc_read16(u8 offset) -{ - u16 value = 0; - u8 buf[]={0,0}; - - if(psoc_ipmi_read(buf, offset, 2) == 2) - value = (buf[0]<<8 | buf[1]<<0); - - return value; -} - -static u8 psoc_read8(u8 offset) -{ - u8 value = 0; - u8 buf = 0; - - if(psoc_ipmi_read(&buf, offset, 1) == 1) - value = buf; - - return value; -} - -/* -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=0; - struct sensor_device_attribute *attr = to_sensor_dev_attr(da); - u8 byte=0; - int shift = (attr->index == 0)?3:0; - - status = psoc_ipmi_read(&byte, PSOC_PSU_OFFSET, 1); - - byte = (byte >> shift) & 0x7; - - status = sprintf (buf, "%d : %s\n", byte, psu_str[byte]); - - return strlen(buf); -} - -static ssize_t show_ipmi_pmbus(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=0; - - data[0] = BMC_PMBusNumber; - 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(start_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_clei(struct device *dev, struct device_attribute *da, - char *buf) -{ - struct sensor_device_attribute *attr = to_sensor_dev_attr(da); - u8 device_index = attr->index & 0xFF; - - uint8_t data[5],result[MaxLeng_Result]; - int result_len=0; - - data[0] = (device_index<=FAN5_CLEI_INDEX) ? BMC_FanCLEIBusNumber:BMC_PMBusNumber; - data[1] = CLEI_ADDR[device_index]<<1; - data[2] = sizeof(struct clei); - data[3] = (device_index<=FAN5_CLEI_INDEX) ? 0x00 : 0x01; //PSU CLEI will start from 0x0100 - data[4] = 0; - - if(start_ipmi_command(0x06, 0x52,data,5, result, &result_len)==0) - { - if(result_len < sizeof(struct clei)) memset(result, 0, sizeof(struct clei)); - sprintf (buf, "Issue Number: %.3s\n", &result[CLEI_OFF(issue_number)]); - sprintf (buf, "%sAbbreviation Number: %.9s\n", buf, &result[CLEI_OFF(abbreviation_number)]); - sprintf (buf, "%sFC Number: %.10s\n", buf, &result[CLEI_OFF(fc_number)]); - sprintf (buf, "%sCLEI Code: %.10s\n", buf, &result[CLEI_OFF(clei_code)]); - sprintf (buf, "%sProduct Year and Month: %.5s\n", buf, &result[CLEI_OFF(product_year_and_month)]); - sprintf (buf, "%s2D Label Location Code: %.2s\n", buf, &result[CLEI_OFF(label_location_code)]); - sprintf (buf, "%sSerial Number: %.5s\n", buf, &result[CLEI_OFF(serial_number)]); - sprintf (buf, "%sPCB Revision: %.5s\n", buf, &result[CLEI_OFF(pcb_revision)]); - sprintf (buf, "%sVendor Name: %.10s\n", buf, &result[CLEI_OFF(vendor_name)]); - return strlen(buf); - } - else - { - return sprintf(buf, "NONE\n"); - } -} - -static ssize_t show_thermal(struct device *dev, struct device_attribute *da, - char *buf) -{ - int status=0; - struct sensor_device_attribute *attr = to_sensor_dev_attr(da); - u8 offset = attr->index * 2 + THERMAL_OFFSET; - - status = psoc_read16(offset); - - 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=0; - struct sensor_device_attribute *attr = to_sensor_dev_attr(da); - u8 offset = attr->index; - - status = psoc_read8(offset); - - return sprintf(buf, "%d\n", - status); -} - -static ssize_t set_pwm(struct device *dev, - struct device_attribute *da, - const char *buf, size_t count) -{ - struct sensor_device_attribute *attr = to_sensor_dev_attr(da); - u8 offset = attr->index; - u8 pwm = simple_strtol(buf, NULL, 10); - if(pwm > 255) pwm = 255; - psoc_ipmi_write(&pwm, offset, 1); - - return count; -} - - -static ssize_t show_rpm(struct device *dev, struct device_attribute *da, - char *buf) -{ - int status=0; - struct sensor_device_attribute *attr = to_sensor_dev_attr(da); - u8 offset = attr->index; - status = psoc_read16(offset); - - return sprintf(buf, "%d\n", - status); -} - -static ssize_t show_switch_tmp(struct device *dev, struct device_attribute *da, - char *buf) -{ - u16 status=0; - u16 temp = 0; - - status = psoc_ipmi_read((u8*)&temp, SWITCH_TMP_OFFSET, 2); - - 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) -{ - long temp = simple_strtol(buf, NULL, 10); - u16 temp2 = ( (temp/1000) <<8 ) & 0xFF00 ; - - psoc_ipmi_write((u8*)&temp2, SWITCH_TMP_OFFSET, 2); - - - return count; -} - -static ssize_t show_diag(struct device *dev, struct device_attribute *da, - char *buf) -{ - u16 status=0; - u8 diag_flag = 0; - - status = psoc_ipmi_read((u8*)&diag_flag, DIAG_FLAG_OFFSET, 1); - - status = sprintf (buf, "%d\n", ((diag_flag & 0x80)?1:0)); - - return strlen(buf); -} - -static ssize_t set_diag(struct device *dev, - struct device_attribute *devattr, - const char *buf, size_t count) -{ - u8 value = 0; - u8 diag = simple_strtol(buf, NULL, 10); - - diag = diag?1:0; - - psoc_ipmi_read((u8*)&value, DIAG_FLAG_OFFSET, 1); - if(diag) value |= (1<<7); - else value &= ~(1<<7); - psoc_ipmi_write((u8*)&value, DIAG_FLAG_OFFSET, 1); - - return count; -} - -static ssize_t show_version(struct device *dev, struct device_attribute *da, - char *buf) -{ - u16 status=0; - - status = psoc_read16(VERSION_OFFSET); - - 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=0; - struct sensor_device_attribute *attr = to_sensor_dev_attr(da); - u8 bit = attr->index; - - if(bit < 8) { status = psoc_read8(FAN_LED_OFFSET); } -#if FAN_NUM>4 - if(bit >= 8) { status = psoc_read8(FAN_LED2_OFFSET); bit-=8; } -#endif - - return sprintf(buf, "%d\n", - (status & (1<index; - u8 led_state = 0; - - u8 v = simple_strtol(buf, NULL, 10); - - if(attr->index < 8) { led_state = psoc_read8(FAN_LED_OFFSET ); } -#if FAN_NUM>4 - if(attr->index >= 8) { led_state = psoc_read8(FAN_LED2_OFFSET); bit-=8; } -#endif - if(v) led_state |= (1<index < 8) { psoc_ipmi_write(&led_state, FAN_LED_OFFSET, 1);} -#if FAN_NUM>4 - if(attr->index >= 8) { psoc_ipmi_write(&led_state, FAN_LED2_OFFSET,1);} -#endif - return count; -} - -static ssize_t show_value8(struct device *dev, struct device_attribute *da, - char *buf) -{ - int status=0; - struct sensor_device_attribute *attr = to_sensor_dev_attr(da); - u8 offset = attr->index; - - status = psoc_read8(offset); - - 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=0; - struct sensor_device_attribute *attr = to_sensor_dev_attr(da); - u8 offset = attr->index + PSU_INFO_OFFSET; - - status = psoc_read16(offset); - - if((strstr(attr->dev_attr.attr.name, "vout")!=NULL)|(strstr(attr->dev_attr.attr.name, "in3")!=NULL)|(strstr(attr->dev_attr.attr.name, "in4")!=NULL)) { - offset=1; - } - else { - offset=0; - } - - return sprintf(buf, "%ld \n", pmbus_reg2data_linear(status, offset )); -} - -static ssize_t show_name(struct device *dev, - struct device_attribute *devattr, char *buf) -{ - return sprintf(buf, "inv_psoc\n"); -} - -static DEVICE_ATTR(name, S_IRUGO, show_name, NULL); -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(temp7_input, S_IRUGO, show_thermal, 0, 5); -static SENSOR_DEVICE_ATTR(temp8_input, S_IRUGO, show_thermal, 0, 6); - -static SENSOR_DEVICE_ATTR(pwm1, S_IWUSR|S_IRUGO, show_pwm, set_pwm, 0 + PWM_OFFSET); -static SENSOR_DEVICE_ATTR(pwm2, S_IWUSR|S_IRUGO, show_pwm, set_pwm, 1 + PWM_OFFSET); -static SENSOR_DEVICE_ATTR(pwm3, S_IWUSR|S_IRUGO, show_pwm, set_pwm, 2 + PWM_OFFSET); -static SENSOR_DEVICE_ATTR(pwm4, S_IWUSR|S_IRUGO, show_pwm, set_pwm, 3 + PWM_OFFSET); -#if FAN_NUM > 4 -static SENSOR_DEVICE_ATTR(pwm5, S_IWUSR|S_IRUGO, show_pwm, set_pwm, 0 + PWM2_OFFSET); -#endif -static SENSOR_DEVICE_ATTR(pwm_psu1, S_IWUSR|S_IRUGO, show_pwm, set_pwm, 4 + PWM_OFFSET); -static SENSOR_DEVICE_ATTR(pwm_psu2, S_IWUSR|S_IRUGO, show_pwm, set_pwm, 5 + PWM_OFFSET); -static SENSOR_DEVICE_ATTR(pwm6, S_IWUSR|S_IRUGO, show_pwm, set_pwm, 4 + PWM_OFFSET); -static SENSOR_DEVICE_ATTR(pwm7, S_IWUSR|S_IRUGO, show_pwm, set_pwm, 5 + PWM_OFFSET); - -static SENSOR_DEVICE_ATTR(psu1, S_IRUGO, show_psu_st, 0, 0); -static SENSOR_DEVICE_ATTR(psu2, 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); -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(fan11_input, S_IRUGO, show_rpm, 0, 8*2 + RPM_OFFSET); -static SENSOR_DEVICE_ATTR(fan12_input, S_IRUGO, show_rpm, 0, 9*2 + RPM_OFFSET); - -#if FAN_NUM > 4 -static SENSOR_DEVICE_ATTR(fan9_input , S_IRUGO, show_rpm, 0,0*2 + RPM2_OFFSET); -static SENSOR_DEVICE_ATTR(fan10_input, S_IRUGO, show_rpm, 0,1*2 + RPM2_OFFSET); -#endif - -static SENSOR_DEVICE_ATTR(switch_tmp, S_IWUSR|S_IRUGO, show_switch_tmp, set_switch_tmp, 0); -static SENSOR_DEVICE_ATTR(temp6_input, 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); - -#if FAN_NUM>4 -static SENSOR_DEVICE_ATTR(fan_led_grn5, S_IWUSR|S_IRUGO, show_fan_led, set_fan_led, 8); -static SENSOR_DEVICE_ATTR(fan_led_red5, S_IWUSR|S_IRUGO, show_fan_led, set_fan_led, 12); -static SENSOR_DEVICE_ATTR(fan_gpi2, S_IRUGO, show_value8, 0, FAN_GPI2_OFFSET); -#endif - -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(in1_input, S_IRUGO, show_psu_psoc, 0, PSOC_PSU_OFF(psu1_vin)); -static SENSOR_DEVICE_ATTR(curr1_input, S_IRUGO, show_psu_psoc, 0, PSOC_PSU_OFF(psu1_iin)); -static SENSOR_DEVICE_ATTR(power1_input, S_IRUGO, show_psu_psoc, 0, PSOC_PSU_OFF(psu1_pin)); -static SENSOR_DEVICE_ATTR(in3_input, S_IRUGO, show_psu_psoc, 0, PSOC_PSU_OFF(psu1_vout)); -static SENSOR_DEVICE_ATTR(curr3_input, S_IRUGO, show_psu_psoc, 0, PSOC_PSU_OFF(psu1_iout)); -static SENSOR_DEVICE_ATTR(power3_input, 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 SENSOR_DEVICE_ATTR(in2_input, S_IRUGO, show_psu_psoc, 0, PSOC_PSU_OFF(psu2_vin)); -static SENSOR_DEVICE_ATTR(curr2_input, S_IRUGO, show_psu_psoc, 0, PSOC_PSU_OFF(psu2_iin)); -static SENSOR_DEVICE_ATTR(power2_input, S_IRUGO, show_psu_psoc, 0, PSOC_PSU_OFF(psu2_pin)); -static SENSOR_DEVICE_ATTR(in4_input, S_IRUGO, show_psu_psoc, 0, PSOC_PSU_OFF(psu2_vout)); -static SENSOR_DEVICE_ATTR(curr4_input, S_IRUGO, show_psu_psoc, 0, PSOC_PSU_OFF(psu2_iout)); -static SENSOR_DEVICE_ATTR(power4_input, S_IRUGO, show_psu_psoc, 0, PSOC_PSU_OFF(psu2_pout)); - -//IPMI -static SENSOR_DEVICE_ATTR(thermal2_psu1, S_IRUGO, show_ipmi_pmbus, 0, PSU1 | PMBus_Temp2); -static SENSOR_DEVICE_ATTR(temp9_input, S_IRUGO, show_ipmi_pmbus, 0, PSU1 | PMBus_Temp2); - -static SENSOR_DEVICE_ATTR(psoc_psu1_vendor, S_IRUGO, show_ipmi_pmbus, 0, PSU1 | PMBus_Vendor); -static SENSOR_DEVICE_ATTR(psoc_psu1_serial, S_IRUGO, show_ipmi_pmbus, 0, PSU1 | PMBus_Serial); -static SENSOR_DEVICE_ATTR(psoc_psu1_version, S_IRUGO, show_ipmi_pmbus, 0, PSU1 | PMBus_Version); - -static SENSOR_DEVICE_ATTR(thermal2_psu2, S_IRUGO, show_ipmi_pmbus, 0, PSU2 | PMBus_Temp2); -static SENSOR_DEVICE_ATTR(temp10_input, S_IRUGO, show_ipmi_pmbus, 0, PSU2 | PMBus_Temp2); -static SENSOR_DEVICE_ATTR(psoc_psu2_vendor, S_IRUGO, show_ipmi_pmbus, 0, PSU2 | PMBus_Vendor); -static SENSOR_DEVICE_ATTR(psoc_psu2_serial, S_IRUGO, show_ipmi_pmbus, 0, PSU2 | PMBus_Serial); -static SENSOR_DEVICE_ATTR(psoc_psu2_version, S_IRUGO, show_ipmi_pmbus, 0, PSU2 | PMBus_Version); - -//CLEI -#if FAN_CLEI_SUPPORT -static SENSOR_DEVICE_ATTR(fan1_clei, S_IRUGO, show_clei, 0, FAN1_CLEI_INDEX ); -static SENSOR_DEVICE_ATTR(fan2_clei, S_IRUGO, show_clei, 0, FAN2_CLEI_INDEX ); -static SENSOR_DEVICE_ATTR(fan3_clei, S_IRUGO, show_clei, 0, FAN3_CLEI_INDEX ); -static SENSOR_DEVICE_ATTR(fan4_clei, S_IRUGO, show_clei, 0, FAN4_CLEI_INDEX ); -#if FAN_NUM > 4 -static SENSOR_DEVICE_ATTR(fan5_clei, S_IRUGO, show_clei, 0, FAN5_CLEI_INDEX ); -#endif -#endif - -#if PSU_CLEI_SUPPORT -static SENSOR_DEVICE_ATTR(psu1_clei, S_IRUGO, show_clei, 0, PSU1_CLEI_INDEX ); -static SENSOR_DEVICE_ATTR(psu2_clei, S_IRUGO, show_clei, 0, PSU2_CLEI_INDEX ); -#endif - -static struct attribute *psoc_attributes[] = { - //name - &dev_attr_name.attr, - //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, - - &sensor_dev_attr_temp7_input.dev_attr.attr, - &sensor_dev_attr_temp8_input.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 > 4 - &sensor_dev_attr_pwm5.dev_attr.attr, -#endif - &sensor_dev_attr_pwm_psu1.dev_attr.attr, - &sensor_dev_attr_pwm_psu2.dev_attr.attr, - &sensor_dev_attr_pwm6.dev_attr.attr, - &sensor_dev_attr_pwm7.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 > 4 - &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, - &sensor_dev_attr_fan11_input.dev_attr.attr, - &sensor_dev_attr_fan12_input.dev_attr.attr, - //switch temperature - &sensor_dev_attr_switch_tmp.dev_attr.attr, - &sensor_dev_attr_temp6_input.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, -#if FAN_NUM >4 - &sensor_dev_attr_fan_led_grn5.dev_attr.attr, - &sensor_dev_attr_fan_led_red5.dev_attr.attr, - &sensor_dev_attr_fan_gpi2.dev_attr.attr, -#endif - //fan GPI - &sensor_dev_attr_fan_gpi.dev_attr.attr, - &sensor_dev_attr_psu1.dev_attr.attr, - &sensor_dev_attr_psu2.dev_attr.attr, - - - //psu_psoc - &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, - - &sensor_dev_attr_in1_input.dev_attr.attr, - &sensor_dev_attr_curr1_input.dev_attr.attr, - &sensor_dev_attr_power1_input.dev_attr.attr, - &sensor_dev_attr_in2_input.dev_attr.attr, - &sensor_dev_attr_curr2_input.dev_attr.attr, - &sensor_dev_attr_power2_input.dev_attr.attr, - &sensor_dev_attr_in3_input.dev_attr.attr, - &sensor_dev_attr_curr3_input.dev_attr.attr, - &sensor_dev_attr_power3_input.dev_attr.attr, - &sensor_dev_attr_in4_input.dev_attr.attr, - &sensor_dev_attr_curr4_input.dev_attr.attr, - &sensor_dev_attr_power4_input.dev_attr.attr, - - //ipmi_i2c_command - &sensor_dev_attr_thermal2_psu1.dev_attr.attr, - &sensor_dev_attr_temp9_input.dev_attr.attr, - &sensor_dev_attr_psoc_psu1_vendor.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_temp10_input.dev_attr.attr, - &sensor_dev_attr_psoc_psu2_vendor.dev_attr.attr, - &sensor_dev_attr_psoc_psu2_serial.dev_attr.attr, - &sensor_dev_attr_psoc_psu2_version.dev_attr.attr, - - //clei -#if FAN_CLEI_SUPPORT - &sensor_dev_attr_fan1_clei.dev_attr.attr, - &sensor_dev_attr_fan2_clei.dev_attr.attr, - &sensor_dev_attr_fan3_clei.dev_attr.attr, - &sensor_dev_attr_fan4_clei.dev_attr.attr, -#if FAN_NUM > 4 - &sensor_dev_attr_fan5_clei.dev_attr.attr, -#endif -#endif - -#if PSU_CLEI_SUPPORT - &sensor_dev_attr_psu1_clei.dev_attr.attr, - &sensor_dev_attr_psu2_clei.dev_attr.attr, -#endif - NULL -}; - -static const struct attribute_group psoc_group = { - .attrs = psoc_attributes, -}; - -//================================= -static void check_switch_temp(void) -{ - static struct file *f; - mm_segment_t old_fs; - - set_fs(get_ds()); - f = filp_open(SWITCH_TEMPERATURE_SOCK,O_RDONLY,0644); - if(IS_ERR(f)) { - return; - } - else { - char temp_str[]={0,0,0,0,0,0,0}; - loff_t pos = 0; - u16 temp2 = 0; - old_fs = get_fs(); - set_fs(KERNEL_DS); - kernel_read(f, temp_str,6,&pos); - temp2 = ((simple_strtoul(temp_str,NULL,10)/1000) <<8 ) & 0xFF00 ; - psoc_ipmi_write((u8*)&temp2, SWITCH_TMP_OFFSET, 2); - } - filp_close(f,NULL); - set_fs(old_fs); -} - -static int psoc_polling_thread(void *p) -{ - while (!kthread_should_stop()) - { - check_switch_temp(); - set_current_state(TASK_INTERRUPTIBLE); - if(kthread_should_stop()) - break; - - schedule_timeout(msecs_to_jiffies(PSOC_POLLING_PERIOD)); - } - return 0; -} - -static int __init inv_psoc_init(void) -{ - int ret; - - hwmon_dev = hwmon_device_register(NULL); - if (IS_ERR(hwmon_dev)) { - goto fail_hwmon_device_register; - } - - device_kobj = kobject_create_and_add("device", &hwmon_dev->kobj); - if(!device_kobj) { - goto fail_hwmon_device_register; - } - - ret = sysfs_create_group(device_kobj, &psoc_group); - if (ret) { - goto fail_create_group_hwmon; - } - - ret = sysfs_create_group(&hwmon_dev->kobj, &psoc_group); - if (ret) { - goto fail_create_group_hwmon; - } - - kthread_auto_update = kthread_run(psoc_polling_thread,NULL,"BMC_DRIVER"); - if (IS_ERR(kthread_auto_update)) { - goto fail_create_group_hwmon; - } - return ret; - -fail_create_group_hwmon: - hwmon_device_unregister(hwmon_dev); -fail_hwmon_device_register: - return -ENOMEM; -} - -static void __exit inv_psoc_exit(void) -{ - kthread_stop(kthread_auto_update); - if(ipmi_mh_user!=NULL) {ipmi_destroy_user(ipmi_mh_user);} - if(hwmon_dev != NULL) hwmon_device_unregister(hwmon_dev); - sysfs_remove_group(device_kobj, &psoc_group); -} - -MODULE_AUTHOR("Ting.Jack "); -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/d5254/modules/builds/src/inv_swps.c b/packages/platforms/inventec/x86-64/d5254/modules/builds/src/inv_swps.c deleted file mode 100644 index 42e430026..000000000 --- a/packages/platforms/inventec/x86-64/d5254/modules/builds/src/inv_swps.c +++ /dev/null @@ -1,3055 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "inv_swps.h" -static int ctl_major; -static int port_major; -static int ioexp_total; -static int port_total; -static int auto_config; -static int flag_i2c_reset; -static int flag_mod_state; -static unsigned gpio_rest_mux; -static struct class *swp_class_p = NULL; -static struct inv_platform_s *platform_p = NULL; -static struct inv_ioexp_layout_s *ioexp_layout = NULL; -static struct inv_port_layout_s *port_layout = NULL; - -static void swp_polling_worker(struct work_struct *work); -static DECLARE_DELAYED_WORK(swp_polling, swp_polling_worker); - -static int reset_i2c_topology(void); - - -static int -__swp_match(struct device *dev, -#ifdef SWPS_KERN_VER_AF_3_10 - - const void *data){ -#else - void *data){ -#endif - - char *name = (char *)data; - if (strcmp(dev_name(dev), name) == 0) - return 1; - return 0; -} - - -struct device * -get_swpdev_by_name(char *name){ - struct device *dev = class_find_device(swp_class_p, - NULL, - name, - __swp_match); - return dev; -} - - -static int -sscanf_2_int(const char *buf) { - - int result = -EBFONT; - char *hex_tag = "0x"; - - if (strcspn(buf, hex_tag) == 0) { - if (sscanf(buf,"%x",&result)) { - return result; - } - } else { - if (sscanf(buf,"%d",&result)) { - return result; - } - if(sscanf(buf,"-%d",&result)) { - return -result; - } - if (sscanf(buf,"%x",&result)) { - return result; - } - } - return -EBFONT; -} - - -static int -sscanf_2_binary(const char *buf) { - - int result = sscanf_2_int(buf); - - if (result < 0){ - return -EBFONT; - } - switch (result) { - case 0: - case 1: - return result; - default: - break; - } - return -EBFONT; -} - - -static int -_get_polling_period(void) { - - int retval = 0; - - if (SWP_POLLING_PERIOD == 0) { - return 0; - } - retval = ((SWP_POLLING_PERIOD * HZ) / 1000); - if (retval == 0) { - return 1; - } - return retval; -} - - -static struct transvr_obj_s * -_get_transvr_obj(char *dev_name) { - - struct device *dev_p = NULL; - struct transvr_obj_s *transvr_obj_p = NULL; - - dev_p = get_swpdev_by_name(dev_name); - if (!dev_p){ - return NULL; - } - transvr_obj_p = dev_get_drvdata(dev_p); - if (!transvr_obj_p){ - return NULL; - } - return transvr_obj_p; -} - - -static void -unlock_tobj_all(void) { - - struct transvr_obj_s *tobj_p; - char port_name[32]; - int port_id = 0; - int minor_curr = 0; - - for (minor_curr=0; minor_currauto_config = auto_config; - unlock_transvr_obj(tobj_p); - SWPS_DEBUG("%s: Set %s auto_config=%d\n", - __func__, tobj_p->swp_name, auto_config); - } - return retval; -} - - -/* ========== R/W Functions module control attribute ========== - */ -static ssize_t -show_attr_platform(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - return snprintf(buf_p, 32, "%s\n", platform_p->name); -} - - -static ssize_t -show_attr_version(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - return snprintf(buf_p, 8, "%s\n", SWP_VERSION); -} - - -static ssize_t -show_attr_status(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - return snprintf(buf_p, 8, "%d\n", flag_mod_state); -} - - -static ssize_t -show_attr_auto_config(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - return snprintf(buf_p, 8, "%d\n", auto_config); -} - - -static int -_check_reset_pwd(const char *buf_p, - size_t count) { - - int in_max = 64; - int in_len = (int)count; - char in_val[64] = "ERR"; - char *emsg = "ERR"; - - if (in_len >= in_max) { - emsg = "input too much"; - goto err_check_reset_pwd; - } - if (!sscanf(buf_p,"%s",in_val)) { - emsg = "format incorrect"; - goto err_check_reset_pwd; - } - if (strcmp(in_val, SWP_RESET_PWD) != 0) { - emsg = "password incorrect"; - goto err_check_reset_pwd; - } - return 0; - -err_check_reset_pwd: - SWPS_ERR("%s: %s\n", __func__, emsg); - return -1; -} - - -static ssize_t -store_attr_reset_i2c(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - - if (_check_reset_pwd(buf_p, count) < 0) { - return -EBFONT; - } - /* Polling mode */ - if (SWP_POLLING_ENABLE) { - SWPS_INFO("%s: reset I2C :polling\n", __func__); - flag_i2c_reset = 1; - return count; - } - /* Direct mode */ - SWPS_INFO("%s: reset I2C go. :direct\n", __func__); - if (reset_i2c_topology() < 0) { - SWPS_ERR("%s: reset fail!\n", __func__); - return -EIO; - } - SWPS_INFO("%s: reset I2C ok. :direct\n", __func__); - return count; -} - - -static ssize_t -store_attr_reset_swps(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - - struct transvr_obj_s *tobj_p; - char port_name[32] = "ERR"; - int port_id = 0; - int minor_curr = 0; - - if (_check_reset_pwd(buf_p, count) < 0) { - return -EBFONT; - } - for (minor_curr=0; minor_currstate = STATE_TRANSVR_DISCONNECTED; - unlock_transvr_obj(tobj_p); - SWPS_INFO("%s: reset:%s\n", __func__, tobj_p->swp_name); - } - return count; -} - - -static ssize_t -store_attr_auto_config(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - - int input_val = sscanf_2_int(buf_p); - - if (input_val < 0){ - return -EBFONT; - } - if ((input_val != 0) && (input_val != 1)) { - return -EBFONT; - } - auto_config = input_val; - _update_auto_config_2_trnasvr(); - return count; -} - - -/* ========== Show functions: For transceiver attribute ========== - */ -static ssize_t -_show_transvr_hex_attr(struct transvr_obj_s* tobj_p, - int (*get_func)(struct transvr_obj_s* tobj_p), - char *buf_p) { - size_t len; - int result; - - lock_transvr_obj(tobj_p); - result = get_func(tobj_p); - unlock_transvr_obj(tobj_p); - if (result < 0){ - len = snprintf(buf_p, 8, "%d\n", result); - } else { - len = snprintf(buf_p, 8, "0x%02x\n", result); - } - return len; -} - - -static ssize_t -_show_transvr_int_attr(struct transvr_obj_s* tobj_p, - int (*get_func)(struct transvr_obj_s* tobj_p), - char *buf_p) { - size_t len; - - lock_transvr_obj(tobj_p); - len = snprintf(buf_p, 16, "%d\n", get_func(tobj_p)); - unlock_transvr_obj(tobj_p); - return len; -} - - -static ssize_t -_show_transvr_str_attr(struct transvr_obj_s* tobj_p, - int (*get_func)(struct transvr_obj_s* tobj_p, char* buf), - char *buf_p) { - size_t len; - - lock_transvr_obj(tobj_p); - len = get_func(tobj_p, buf_p); - unlock_transvr_obj(tobj_p); - return len; -} - - -static ssize_t -show_attr_id(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_hex_attr(tobj_p, - tobj_p->get_id, - buf_p); -} - - -static ssize_t -show_attr_ext_id(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_hex_attr(tobj_p, - tobj_p->get_ext_id, - buf_p); -} - - -static ssize_t -show_attr_connector(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_hex_attr(tobj_p, - tobj_p->get_connector, - buf_p); -} - - -static ssize_t -show_attr_vendor_name(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_vendor_name, - buf_p); -} - - -static ssize_t -show_attr_vendor_pn(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_vendor_pn, - buf_p); -} - - -static ssize_t -show_attr_vendor_rev(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_vendor_rev, - buf_p); -} - - -static ssize_t -show_attr_vendor_sn(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_vendor_sn, - buf_p); -} - - -static ssize_t -show_attr_power_cls(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - size_t len; - int result; - struct transvr_obj_s *tobj_p; - - tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - lock_transvr_obj(tobj_p); - result = tobj_p->get_power_cls(tobj_p); - unlock_transvr_obj(tobj_p); - if (result < 0){ - len = snprintf(buf_p, 16, "%d\n", result); - } else { - len = snprintf(buf_p, 16, "Power Class %d\n", result); - } - return len; -} - - -static ssize_t -show_attr_br(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_hex_attr(tobj_p, - tobj_p->get_br, - buf_p); -} - - -static ssize_t -show_attr_len_sm(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_int_attr(tobj_p, - tobj_p->get_len_sm, - buf_p); -} - - -static ssize_t -show_attr_len_smf(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_int_attr(tobj_p, - tobj_p->get_len_smf, - buf_p); -} - - -static ssize_t -show_attr_len_om1(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_int_attr(tobj_p, - tobj_p->get_len_om1, - buf_p); -} - - -static ssize_t -show_attr_len_om2(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_int_attr(tobj_p, - tobj_p->get_len_om2, - buf_p); -} - - -static ssize_t -show_attr_len_om3(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_int_attr(tobj_p, - tobj_p->get_len_om3, - buf_p); -} - - -static ssize_t -show_attr_len_om4(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_int_attr(tobj_p, - tobj_p->get_len_om4, - buf_p); -} - - -static ssize_t -show_attr_comp_rev(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_hex_attr(tobj_p, - tobj_p->get_comp_rev, - buf_p); -} - - -static ssize_t -show_attr_comp_eth(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_hex_attr(tobj_p, - tobj_p->get_comp_eth_1, - buf_p); -} - - -static ssize_t -show_attr_comp_eth_10(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_hex_attr(tobj_p, - tobj_p->get_comp_eth_10, - buf_p); -} - - -static ssize_t -show_attr_comp_eth_10_40(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_hex_attr(tobj_p, - tobj_p->get_comp_eth_10_40, - buf_p); -} - - -static ssize_t -show_attr_comp_extend(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_hex_attr(tobj_p, - tobj_p->get_comp_extend, - buf_p); -} - - -static ssize_t -show_attr_rate_id(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_hex_attr(tobj_p, - tobj_p->get_rate_id, - buf_p); -} - - -static ssize_t -show_attr_temperature(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_curr_temp, - buf_p); -} - - -static ssize_t -show_attr_voltage(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_curr_vol, - buf_p); -} - - -static ssize_t -show_attr_tx_bias(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_tx_bias, - buf_p); -} - - -static ssize_t -show_attr_tx_power(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_tx_power, - buf_p); -} - - -static ssize_t -show_attr_tx_eq(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_tx_eq, - buf_p); -} - - -static ssize_t -show_attr_rx_power(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_rx_power, - buf_p); -} - - -static ssize_t -show_attr_rx_am(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_rx_am, - buf_p); -} - - -static ssize_t -show_attr_rx_em(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_rx_em, - buf_p); -} - - -static ssize_t -show_attr_wavelength(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_wavelength, - buf_p); -} - - -static ssize_t -show_attr_extphy_offset(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_extphy_offset, - buf_p); -} - - -static ssize_t -show_attr_extphy_reg(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_extphy_reg, - buf_p); -} - - -static ssize_t -show_attr_info(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_int_attr(tobj_p, - tobj_p->get_info, - buf_p); -} - - -static ssize_t -show_attr_if_type(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_if_type, - buf_p); -} - - -static ssize_t -show_attr_if_speed(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_if_speed, - buf_p); -} - - -static ssize_t -show_attr_if_lane(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_if_lane, - buf_p); -} - - -static ssize_t -show_attr_cdr(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_hex_attr(tobj_p, - tobj_p->get_cdr, - buf_p); -} - - -static ssize_t -show_attr_soft_rs0(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_int_attr(tobj_p, - tobj_p->get_soft_rs0, - buf_p); -} - - -static ssize_t -show_attr_soft_rs1(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_int_attr(tobj_p, - tobj_p->get_soft_rs1, - buf_p); -} - - -static ssize_t -show_attr_soft_rx_los(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_soft_rx_los, - buf_p); -} - - -static ssize_t -show_attr_soft_tx_disable(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_soft_tx_disable, - buf_p); -} - - -static ssize_t -show_attr_soft_tx_fault(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_soft_tx_fault, - buf_p); -} - - -static ssize_t -show_attr_auto_tx_disable(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_auto_tx_disable, - buf_p); -} - - -/* ========== Store functions: transceiver (R/W) attribute ========== - */ -static ssize_t -_store_transvr_int_attr(struct transvr_obj_s* tobj_p, - int (*set_func)(struct transvr_obj_s *tobj_p, int input_val), - const char *buf_p, - size_t count) { - int input, err; - - input = sscanf_2_int(buf_p); - if (input < 0){ - return -EBFONT; - } - lock_transvr_obj(tobj_p); - err = set_func(tobj_p, input); - unlock_transvr_obj(tobj_p); - if (err < 0){ - return err; - } - return count; -} - - -static ssize_t -_store_transvr_byte_hex_attr(struct transvr_obj_s* tobj_p, - int (*set_func)(struct transvr_obj_s *tobj_p, int input_val), - const char *buf_p, - size_t count) { - int input, err; - - input = sscanf_2_int(buf_p); - if ((input < 0) || (input > 0xff)){ - return -EBFONT; - } - lock_transvr_obj(tobj_p); - err = set_func(tobj_p, input); - unlock_transvr_obj(tobj_p); - if (err < 0){ - return err; - } - return count; -} - - -static ssize_t -_store_transvr_binary_attr(struct transvr_obj_s* tobj_p, - int (*set_func)(struct transvr_obj_s *tobj_p, int input_val), - const char *buf_p, - size_t count) { - int input, err; - - input = sscanf_2_binary(buf_p); - if (input < 0){ - return -EBFONT; - } - lock_transvr_obj(tobj_p); - err = set_func(tobj_p, input); - unlock_transvr_obj(tobj_p); - if (err < 0){ - return err; - } - return count; -} - - -static ssize_t -store_attr_cdr(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - return _store_transvr_byte_hex_attr(tobj_p, - tobj_p->set_cdr, - buf_p, - count); -} - - -static ssize_t -store_attr_soft_rs0(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - return _store_transvr_binary_attr(tobj_p, - tobj_p->set_soft_rs0, - buf_p, - count); -} - - -static ssize_t -store_attr_soft_rs1(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - return _store_transvr_binary_attr(tobj_p, - tobj_p->set_soft_rs1, - buf_p, - count); -} - - -static ssize_t -store_attr_soft_tx_disable(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count) { - - int check = sscanf_2_int(buf_p); - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - if ((check < 0) || (check > 0xf)){ - return -EBFONT; - } - return _store_transvr_byte_hex_attr(tobj_p, - tobj_p->set_soft_tx_disable, - buf_p, - count); -} - - -static ssize_t -store_attr_auto_tx_disable(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count) { - - int err = -EPERM; - int input = sscanf_2_int(buf_p); - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - if ((input < 0) || (input > 0xf)){ - if (input != VAL_TRANSVR_FUNCTION_DISABLE) { - return -EBFONT; - } - } - lock_transvr_obj(tobj_p); - err = tobj_p->set_auto_tx_disable(tobj_p, input); - unlock_transvr_obj(tobj_p); - if (err < 0){ - return err; - } - return count; -} - - -static ssize_t -store_attr_tx_eq(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - return _store_transvr_int_attr(tobj_p, - tobj_p->set_tx_eq, - buf_p, - count); -} - - -static ssize_t -store_attr_rx_am(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - return _store_transvr_int_attr(tobj_p, - tobj_p->set_rx_am, - buf_p, - count); -} - - -static ssize_t -store_attr_rx_em(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - return _store_transvr_int_attr(tobj_p, - tobj_p->set_rx_em, - buf_p, - count); -} - - -static ssize_t -store_attr_extphy_offset(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - return _store_transvr_int_attr(tobj_p, - tobj_p->set_extphy_offset, - buf_p, - count); -} - - -static ssize_t -store_attr_extphy_reg(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - return _store_transvr_int_attr(tobj_p, - tobj_p->set_extphy_reg, - buf_p, - count); -} - -/* ========== Show functions: For I/O Expander attribute ========== - */ -static ssize_t -_show_ioexp_binary_attr(struct transvr_obj_s *tobj_p, - int (*get_func)(struct ioexp_obj_s *ioexp_p, int voffset), - char *buf_p) { - size_t len; - struct ioexp_obj_s *ioexp_p = tobj_p->ioexp_obj_p; - - if (!ioexp_p) { - SWPS_ERR(" %s: data corruption! :%s\n", __func__, tobj_p->swp_name); - return -ENODATA; - } - mutex_lock(&ioexp_p->lock); - len = snprintf(buf_p, 8, "%d\n", get_func(ioexp_p, tobj_p->ioexp_virt_offset)); - mutex_unlock(&ioexp_p->lock); - return len; -} - - -static ssize_t -show_attr_present(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - return _show_ioexp_binary_attr(tobj_p, - tobj_p->ioexp_obj_p->get_present, - buf_p); -} - - -static ssize_t -show_attr_tx_fault(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - return _show_ioexp_binary_attr(tobj_p, - tobj_p->ioexp_obj_p->get_tx_fault, - buf_p); -} - - -static ssize_t -show_attr_rxlos(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - return _show_ioexp_binary_attr(tobj_p, - tobj_p->ioexp_obj_p->get_rxlos, - buf_p); -} - - -static ssize_t -show_attr_tx_disable(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - return _show_ioexp_binary_attr(tobj_p, - tobj_p->ioexp_obj_p->get_tx_disable, - buf_p); -} - - -static ssize_t -show_attr_reset(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - return _show_ioexp_binary_attr(tobj_p, - tobj_p->ioexp_obj_p->get_reset, - buf_p); -} - - -static ssize_t -show_attr_lpmod(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - return _show_ioexp_binary_attr(tobj_p, - tobj_p->ioexp_obj_p->get_lpmod, - buf_p); -} - - -static ssize_t -show_attr_modsel(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - return _show_ioexp_binary_attr(tobj_p, - tobj_p->ioexp_obj_p->get_modsel, - buf_p); -} - - -static ssize_t -show_attr_hard_rs0(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - return _show_ioexp_binary_attr(tobj_p, - tobj_p->ioexp_obj_p->get_hard_rs0, - buf_p); -} - - -static ssize_t -show_attr_hard_rs1(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - return _show_ioexp_binary_attr(tobj_p, - tobj_p->ioexp_obj_p->get_hard_rs1, - buf_p); -} - - -/* ========== Store functions: For I/O Expander (R/W) attribute ========== - */ -static ssize_t -_store_ioexp_binary_attr(struct transvr_obj_s *tobj_p, - int (*set_func)(struct ioexp_obj_s *ioexp_p, - int virt_offset, int input_val), - const char *buf_p, - size_t count) { - - int input, err; - struct ioexp_obj_s *ioexp_p = tobj_p->ioexp_obj_p; - - if (!ioexp_p) { - SWPS_ERR("%s: data corruption! :%s\n", - __func__, tobj_p->swp_name); - return -ENODATA; - } - input = sscanf_2_binary(buf_p); - if (input < 0) { - return -EBFONT; - } - mutex_lock(&ioexp_p->lock); - err = set_func(ioexp_p, tobj_p->ioexp_virt_offset, input); - mutex_unlock(&ioexp_p->lock); - if (err < 0){ - return err; - } - return count; -} - -static ssize_t -store_attr_tx_disable(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p) { - return -ENODEV; - } - return _store_ioexp_binary_attr(tobj_p, - tobj_p->ioexp_obj_p->set_tx_disable, - buf_p, - count); -} - - -static ssize_t -store_attr_reset(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p) { - return -ENODEV; - } - return _store_ioexp_binary_attr(tobj_p, - tobj_p->ioexp_obj_p->set_reset, - buf_p, - count); -} - - -static ssize_t -store_attr_lpmod(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p) { - return -ENODEV; - } - return _store_ioexp_binary_attr(tobj_p, - tobj_p->ioexp_obj_p->set_lpmod, - buf_p, - count); -} - - -static ssize_t -store_attr_modsel(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p) { - return -ENODEV; - } - return _store_ioexp_binary_attr(tobj_p, - tobj_p->ioexp_obj_p->set_modsel, - buf_p, - count); -} - - -static ssize_t -store_attr_hard_rs0(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p) { - return -ENODEV; - } - return _store_ioexp_binary_attr(tobj_p, - tobj_p->ioexp_obj_p->set_hard_rs0, - buf_p, - count); -} - - -static ssize_t -store_attr_hard_rs1(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p) { - return -ENODEV; - } - return _store_ioexp_binary_attr(tobj_p, - tobj_p->ioexp_obj_p->set_hard_rs1, - buf_p, - count); -} - - -/* ========== SWPS attribute: For module control ========== - */ -static DEVICE_ATTR(platform, S_IRUGO, show_attr_platform, NULL); -static DEVICE_ATTR(version, S_IRUGO, show_attr_version, NULL); -static DEVICE_ATTR(status, S_IRUGO, show_attr_status, NULL); -static DEVICE_ATTR(reset_i2c, S_IWUSR, NULL, store_attr_reset_i2c); -static DEVICE_ATTR(reset_swps, S_IWUSR, NULL, store_attr_reset_swps); -static DEVICE_ATTR(auto_config, S_IRUGO|S_IWUSR, show_attr_auto_config, store_attr_auto_config); - -/* ========== Transceiver attribute: from eeprom ========== - */ -static DEVICE_ATTR(id, S_IRUGO, show_attr_id, NULL); -static DEVICE_ATTR(ext_id, S_IRUGO, show_attr_ext_id, NULL); -static DEVICE_ATTR(connector, S_IRUGO, show_attr_connector, NULL); -static DEVICE_ATTR(vendor_name, S_IRUGO, show_attr_vendor_name, NULL); -static DEVICE_ATTR(vendor_pn, S_IRUGO, show_attr_vendor_pn, NULL); -static DEVICE_ATTR(vendor_rev, S_IRUGO, show_attr_vendor_rev, NULL); -static DEVICE_ATTR(vendor_sn, S_IRUGO, show_attr_vendor_sn, NULL); -static DEVICE_ATTR(power_cls, S_IRUGO, show_attr_power_cls, NULL); -static DEVICE_ATTR(br, S_IRUGO, show_attr_br, NULL); -static DEVICE_ATTR(len_sm, S_IRUGO, show_attr_len_sm, NULL); -static DEVICE_ATTR(len_smf, S_IRUGO, show_attr_len_smf, NULL); -static DEVICE_ATTR(len_om1, S_IRUGO, show_attr_len_om1, NULL); -static DEVICE_ATTR(len_om2, S_IRUGO, show_attr_len_om2, NULL); -static DEVICE_ATTR(len_om3, S_IRUGO, show_attr_len_om3, NULL); -static DEVICE_ATTR(len_om4, S_IRUGO, show_attr_len_om4, NULL); -static DEVICE_ATTR(comp_rev, S_IRUGO, show_attr_comp_rev, NULL); -static DEVICE_ATTR(comp_eth, S_IRUGO, show_attr_comp_eth, NULL); -static DEVICE_ATTR(comp_eth_10, S_IRUGO, show_attr_comp_eth_10, NULL); -static DEVICE_ATTR(comp_eth_10_40, S_IRUGO, show_attr_comp_eth_10_40, NULL); -static DEVICE_ATTR(comp_extend, S_IRUGO, show_attr_comp_extend, NULL); -static DEVICE_ATTR(rate_id, S_IRUGO, show_attr_rate_id, NULL); -static DEVICE_ATTR(temperature, S_IRUGO, show_attr_temperature, NULL); -static DEVICE_ATTR(voltage, S_IRUGO, show_attr_voltage, NULL); -static DEVICE_ATTR(tx_bias, S_IRUGO, show_attr_tx_bias, NULL); -static DEVICE_ATTR(tx_power, S_IRUGO, show_attr_tx_power, NULL); -static DEVICE_ATTR(rx_power, S_IRUGO, show_attr_rx_power, NULL); -static DEVICE_ATTR(info, S_IRUGO, show_attr_info, NULL); -static DEVICE_ATTR(if_type, S_IRUGO, show_attr_if_type, NULL); -static DEVICE_ATTR(if_speed, S_IRUGO, show_attr_if_speed, NULL); -static DEVICE_ATTR(if_lane, S_IRUGO, show_attr_if_lane, NULL); -static DEVICE_ATTR(soft_rx_los, S_IRUGO, show_attr_soft_rx_los, NULL); -static DEVICE_ATTR(soft_tx_fault, S_IRUGO, show_attr_soft_tx_fault, NULL); -static DEVICE_ATTR(wavelength, S_IRUGO, show_attr_wavelength, NULL); -static DEVICE_ATTR(tx_eq, S_IRUGO|S_IWUSR, show_attr_tx_eq, store_attr_tx_eq); -static DEVICE_ATTR(rx_am, S_IRUGO|S_IWUSR, show_attr_rx_am, store_attr_rx_am); -static DEVICE_ATTR(rx_em, S_IRUGO|S_IWUSR, show_attr_rx_em, store_attr_rx_em); -static DEVICE_ATTR(cdr, S_IRUGO|S_IWUSR, show_attr_cdr, store_attr_cdr); -static DEVICE_ATTR(soft_rs0, S_IRUGO|S_IWUSR, show_attr_soft_rs0, store_attr_soft_rs0); -static DEVICE_ATTR(soft_rs1, S_IRUGO|S_IWUSR, show_attr_soft_rs1, store_attr_soft_rs1); -static DEVICE_ATTR(soft_tx_disable, S_IRUGO|S_IWUSR, show_attr_soft_tx_disable, store_attr_soft_tx_disable); -static DEVICE_ATTR(auto_tx_disable, S_IRUGO|S_IWUSR, show_attr_auto_tx_disable, store_attr_auto_tx_disable); -static DEVICE_ATTR(extphy_offset, S_IRUGO|S_IWUSR, show_attr_extphy_offset, store_attr_extphy_offset); -static DEVICE_ATTR(extphy_reg, S_IRUGO|S_IWUSR, show_attr_extphy_reg, store_attr_extphy_reg); - -/* ========== IO Expander attribute: from expander ========== - */ -static DEVICE_ATTR(present, S_IRUGO, show_attr_present, NULL); -static DEVICE_ATTR(tx_fault, S_IRUGO, show_attr_tx_fault, NULL); -static DEVICE_ATTR(rxlos, S_IRUGO, show_attr_rxlos, NULL); -static DEVICE_ATTR(tx_disable, S_IRUGO|S_IWUSR, show_attr_tx_disable, store_attr_tx_disable); -static DEVICE_ATTR(reset, S_IRUGO|S_IWUSR, show_attr_reset, store_attr_reset); -static DEVICE_ATTR(lpmod, S_IRUGO|S_IWUSR, show_attr_lpmod, store_attr_lpmod); -static DEVICE_ATTR(modsel, S_IRUGO|S_IWUSR, show_attr_modsel, store_attr_modsel); -static DEVICE_ATTR(hard_rs0, S_IRUGO|S_IWUSR, show_attr_hard_rs0, store_attr_hard_rs0); -static DEVICE_ATTR(hard_rs1, S_IRUGO|S_IWUSR, show_attr_hard_rs1, store_attr_hard_rs1); - -/* ========== Functions for module handling ========== - */ -static void -clean_port_obj(void){ - - dev_t dev_num; - char dev_name[32]; - struct device *device_p; - struct transvr_obj_s *transvr_obj_p; - int minor_curr, port_id; - - for (minor_curr=0; minor_curri2c_client_p); - kfree(transvr_obj_p->vendor_name); - kfree(transvr_obj_p->vendor_pn); - kfree(transvr_obj_p->vendor_rev); - kfree(transvr_obj_p->vendor_sn); - kfree(transvr_obj_p->worker_p); - kfree(transvr_obj_p); - } - dev_num = MKDEV(port_major, minor_curr); - device_unregister(device_p); - device_destroy(swp_class_p, dev_num); - } - SWPS_DEBUG("%s: done.\n", __func__); -} - - -static void -clean_swps_common(void){ - - dev_t dev_num; - struct device *device_p; - - device_p = get_swpdev_by_name(SWP_DEV_MODCTL); - if (device_p){ - dev_num = MKDEV(ctl_major, 1); - device_unregister(device_p); - device_destroy(swp_class_p, dev_num); - } - cancel_delayed_work_sync(&swp_polling); - SWPS_DEBUG("%s: done.\n", __func__); -} - - -static int -get_platform_type(void){ - - int i; - int pf_total = ARRAY_SIZE(platform_map); - char log_msg[64] = "ERROR"; - - platform_p = kzalloc(sizeof(struct inv_platform_s), GFP_KERNEL); - if (!platform_p){ - snprintf(log_msg, sizeof(log_msg), "kzalloc fail"); - goto err_get_platform_type_1; - } - memset(platform_p->name, 0, sizeof(platform_p->name)); - - switch (PLATFORM_SETTINGS) { - case PLATFORM_TYPE_AUTO: - snprintf(platform_p->name, (sizeof(platform_p->name) - 1), - "%s", dmi_get_system_info(DMI_BOARD_NAME)); - for (i=0; iname, platform_map[i].name) == 0) { - platform_p->id = platform_map[i].id; - snprintf(log_msg, sizeof(log_msg), - "Auto detect platform: %d (%s)", - platform_p->id, platform_p->name); - goto ok_get_platform_type_1; - } - } - snprintf(log_msg, sizeof(log_msg), - "Auto detect fail! detect platform: %s", - platform_p->name); - goto err_get_platform_type_2; - - case PLATFORM_TYPE_MAGNOLIA: - case PLATFORM_TYPE_MAGNOLIA_FNC: - case PLATFORM_TYPE_REDWOOD: - case PLATFORM_TYPE_REDWOOD_FSL: - case PLATFORM_TYPE_HUDSON32I_GA: - case PLATFORM_TYPE_SPRUCE: - case PLATFORM_TYPE_CYPRESS_GA1: - case PLATFORM_TYPE_CYPRESS_GA2: - case PLATFORM_TYPE_CYPRESS_BAI: - case PLATFORM_TYPE_TAHOE: - case PLATFORM_TYPE_SEQUOIA_GA: - case PLATFORM_TYPE_LAVENDER_GA: - case PLATFORM_TYPE_LAVENDER_ONL: - case PLATFORM_TYPE_COTTONWOOD_RANGELEY: - case PLATFORM_TYPE_MAPLE: - case PLATFORM_TYPE_GULMOHAR_GA: - platform_p->id = PLATFORM_SETTINGS; - for (i=0; iname, (sizeof(platform_p->name) - 1), - "%s", platform_map[i].name); - snprintf(log_msg, sizeof(log_msg), - "User setup platform: %d (%s)", - platform_p->id, platform_p->name); - goto ok_get_platform_type_1; - } - } - snprintf(log_msg, sizeof(log_msg), - "Internal error, can not map id:%d", - PLATFORM_SETTINGS); - goto err_get_platform_type_2; - - default: - break; - } - snprintf(log_msg, sizeof(log_msg), - "PLATFORM_SETTINGS:%d undefined", PLATFORM_SETTINGS); - goto err_get_platform_type_2; - -ok_get_platform_type_1: - SWPS_DEBUG("%s: %s, :%d\n", __func__, log_msg, PLATFORM_SETTINGS); - return 0; - -err_get_platform_type_2: - kfree(platform_p); -err_get_platform_type_1: - SWPS_ERR("%s: %s :%d\n", __func__, log_msg, PLATFORM_SETTINGS); - return -1; -} - - -static int -get_layout_info(void){ - - switch (platform_p->id) { -#ifdef SWPS_MAGNOLIA - case PLATFORM_TYPE_MAGNOLIA: - case PLATFORM_TYPE_MAGNOLIA_FNC: - gpio_rest_mux = magnolia_gpio_rest_mux; - ioexp_layout = magnolia_ioexp_layout; - port_layout = magnolia_port_layout; - ioexp_total = ARRAY_SIZE(magnolia_ioexp_layout); - port_total = ARRAY_SIZE(magnolia_port_layout); - break; -#endif -#ifdef SWPS_REDWOOD - case PLATFORM_TYPE_REDWOOD: - gpio_rest_mux = redwood_gpio_rest_mux; - ioexp_layout = redwood_ioexp_layout; - port_layout = redwood_port_layout; - ioexp_total = ARRAY_SIZE(redwood_ioexp_layout); - port_total = ARRAY_SIZE(redwood_port_layout); - break; -#endif -#ifdef SWPS_HUDSON32I_GA - case PLATFORM_TYPE_HUDSON32I_GA: - gpio_rest_mux = hudsin32iga_gpio_rest_mux; - ioexp_layout = hudson32iga_ioexp_layout; - port_layout = hudson32iga_port_layout; - ioexp_total = ARRAY_SIZE(hudson32iga_ioexp_layout); - port_total = ARRAY_SIZE(hudson32iga_port_layout); - break; -#endif -#ifdef SWPS_SPRUCE - case PLATFORM_TYPE_SPRUCE: - gpio_rest_mux = spruce_gpio_rest_mux; - ioexp_layout = spruce_ioexp_layout; - port_layout = spruce_port_layout; - ioexp_total = ARRAY_SIZE(spruce_ioexp_layout); - port_total = ARRAY_SIZE(spruce_port_layout); - break; -#endif -#ifdef SWPS_CYPRESS_GA1 - case PLATFORM_TYPE_CYPRESS_GA1: - gpio_rest_mux = cypress_ga1_gpio_rest_mux; - ioexp_layout = cypress_ga1_ioexp_layout; - port_layout = cypress_ga1_port_layout; - ioexp_total = ARRAY_SIZE(cypress_ga1_ioexp_layout); - port_total = ARRAY_SIZE(cypress_ga1_port_layout); - break; -#endif -#ifdef SWPS_CYPRESS_GA2 - case PLATFORM_TYPE_CYPRESS_GA2: - gpio_rest_mux = cypress_ga2_gpio_rest_mux; - ioexp_layout = cypress_ga2_ioexp_layout; - port_layout = cypress_ga2_port_layout; - ioexp_total = ARRAY_SIZE(cypress_ga2_ioexp_layout); - port_total = ARRAY_SIZE(cypress_ga2_port_layout); - break; -#endif -#ifdef SWPS_CYPRESS_BAI - case PLATFORM_TYPE_CYPRESS_BAI: - gpio_rest_mux = cypress_b_gpio_rest_mux; - ioexp_layout = cypress_b_ioexp_layout; - port_layout = cypress_b_port_layout; - ioexp_total = ARRAY_SIZE(cypress_b_ioexp_layout); - port_total = ARRAY_SIZE(cypress_b_port_layout); - break; -#endif -#ifdef SWPS_REDWOOD_FSL - case PLATFORM_TYPE_REDWOOD_FSL: - gpio_rest_mux = redwood_fsl_gpio_rest_mux; - ioexp_layout = redwood_fsl_ioexp_layout; - port_layout = redwood_fsl_port_layout; - ioexp_total = ARRAY_SIZE(redwood_fsl_ioexp_layout); - port_total = ARRAY_SIZE(redwood_fsl_port_layout); - break; -#endif -#ifdef SWPS_TAHOE - case PLATFORM_TYPE_TAHOE: - gpio_rest_mux = tahoe_gpio_rest_mux; - ioexp_layout = tahoe_ioexp_layout; - port_layout = tahoe_port_layout; - ioexp_total = ARRAY_SIZE(tahoe_ioexp_layout); - port_total = ARRAY_SIZE(tahoe_port_layout); - break; -#endif -#ifdef SWPS_SEQUOIA - case PLATFORM_TYPE_SEQUOIA_GA: - gpio_rest_mux = sequoia_gpio_rest_mux; - ioexp_layout = sequoia_ioexp_layout; - port_layout = sequoia_port_layout; - ioexp_total = ARRAY_SIZE(sequoia_ioexp_layout); - port_total = ARRAY_SIZE(sequoia_port_layout); - break; -#endif -#ifdef SWPS_LAVENDER - case PLATFORM_TYPE_LAVENDER_GA: - case PLATFORM_TYPE_LAVENDER_ONL: - gpio_rest_mux = lavender_gpio_rest_mux; - ioexp_layout = lavender_ioexp_layout; - port_layout = lavender_port_layout; - ioexp_total = ARRAY_SIZE(lavender_ioexp_layout); - port_total = ARRAY_SIZE(lavender_port_layout); - break; -#endif -#ifdef SWPS_COTTONWOOD_RANGELEY - case PLATFORM_TYPE_COTTONWOOD_RANGELEY: - gpio_rest_mux = cottonwood_rangeley_gpio_rest_mux; - ioexp_layout = cottonwood_rangeley_ioexp_layout; - port_layout = cottonwood_rangeley_port_layout; - ioexp_total = ARRAY_SIZE(cottonwood_rangeley_ioexp_layout); - port_total = ARRAY_SIZE(cottonwood_rangeley_port_layout); - break; -#endif -#ifdef SWPS_MAPLE - case PLATFORM_TYPE_MAPLE: - gpio_rest_mux = maple_gpio_rest_mux; - ioexp_layout = maple_ioexp_layout; - port_layout = maple_port_layout; - ioexp_total = ARRAY_SIZE(maple_ioexp_layout); - port_total = ARRAY_SIZE(maple_port_layout); - break; -#endif -#ifdef SWPS_GULMOHAR - case PLATFORM_TYPE_GULMOHAR_GA: - gpio_rest_mux = gulmohar_gpio_rest_mux; - ioexp_layout = gulmohar_ioexp_layout; - port_layout = gulmohar_port_layout; - ioexp_total = ARRAY_SIZE(gulmohar_ioexp_layout); - port_total = ARRAY_SIZE(gulmohar_port_layout); - break; -#endif - default: - SWPS_ERR(" Invalid platform: %d (%s)\n", - platform_p->id, platform_p->name); - return -1; - } - SWPS_INFO("Start to initial platform: %d (%s)\n", - platform_p->id, platform_p->name); - return 0; -} - - -/* ========== Functions for objects operations ========== - */ -static int -__detect_issues_port(int minor_num) { - - struct transvr_obj_s *tobj_p; - int port_id = port_layout[minor_num].port_id; - char port_name[32] = "ERR"; - char *i2c_emsg = "detected bad transceiver/cable"; - - memset(port_name, 0, sizeof(port_name)); - snprintf(port_name, sizeof(port_name), "%s%d", SWP_DEV_PORT, port_id); - tobj_p = _get_transvr_obj(port_name); - if (!tobj_p) { - SWPS_INFO("%s: tobj_p is NULL :%d\n", __func__, minor_num); - return -1; - } - if (resync_channel_tier_2(tobj_p) < 0) { - if (check_channel_tier_1() < 0) { - alarm_msg_2_user(tobj_p, i2c_emsg); - return -2;; - } - } - return 0; -} - - -static int -_detect_issues_port(void) { - /* OK : retrun -1; - * Fail: return fail at which minor number (0~N) - */ - char *emsg = "ERR"; - int minor = 0; - int minor_2st = 1; - - /* Force moving the initial channel pointer - * Filter out case of fail at minor-0 port - */ - while (minor_2st < port_total) { - minor = minor_2st; - if (__detect_issues_port(minor_2st) < 0) { - emsg = "detect minor_2st fail"; - goto err_p_detect_issues_port; - } - minor_2st += 8; - } - /* Scan all port */ - for (minor=0; minor:%d\n", __func__, emsg, minor_err); - return -1; -} - - -static int -check_transvr_obj_one(char *dev_name){ - /* [Return] - * 0 : Doesn't need to take care - * -1 : Single error - * -2 : Critical error (I2C topology die) - * -9 : Internal error - */ - struct transvr_obj_s *tobj_p = NULL; - int retval = -9; - - tobj_p = _get_transvr_obj(dev_name); - if (!tobj_p) { - SWPS_ERR("%s: %s _get_transvr_obj fail\n", - __func__, dev_name); - return -9; - } - /* Check transceiver current status */ - lock_transvr_obj(tobj_p); - retval = tobj_p->check(tobj_p); - unlock_transvr_obj(tobj_p); - switch (retval) { - case 0: - case ERR_TRANSVR_UNPLUGGED: - case ERR_TRNASVR_BE_ISOLATED: - case ERR_TRANSVR_TASK_BUSY: - return 0; - - case ERR_TRANSVR_I2C_CRASH: - default: - break; - } - /* Identify abnormal case */ - if (check_channel_tier_1() < 0) { - SWPS_DEBUG("%s: %s critical error :%d\n", - __func__, dev_name, retval); - return -2; - } - SWPS_DEBUG("%s: %s single error :%d\n", - __func__, dev_name, retval); - return -1; -} - - -static int -check_transvr_objs(void){ - - char dev_name[32]; - int port_id, err_code; - int minor_curr = 0; - - for (minor_curr=0; minor_curr:%d\n", - __func__, dev_name, err_code); - break; - } - } - return 0; - -err_check_transvr_objs: - SWPS_ERR("%s: %s reset_i2c_topology fail.\n", - __func__, dev_name); - return -1; -} - - -static void -swp_polling_worker(struct work_struct *work){ - - /* Reset I2C */ - if (flag_i2c_reset) { - goto polling_reset_i2c; - } - /* Check IOEXP */ - if (check_ioexp_objs() < 0) { - goto polling_reset_i2c; - } - /* Check transceiver */ - if (check_transvr_objs() < 0) { - SWPS_DEBUG("%s: check_transvr_objs fail.\n", __func__); - flag_i2c_reset = 1; - } - goto polling_schedule_round; - -polling_reset_i2c: - SWPS_DEBUG("%s: reset_i2c_topology start.\n", __func__); - if (reset_i2c_topology() < 0) { - SWPS_ERR("%s: reset i2c fail!\n", __func__); - flag_i2c_reset = 1; - } else { - SWPS_DEBUG("%s: reset_i2c_topology OK.\n", __func__); - flag_i2c_reset = 0; - } -polling_schedule_round: - schedule_delayed_work(&swp_polling, _get_polling_period()); -} - - -/* ========== Functions for register something ========== - */ -static int -register_transvr_common_attr(struct device *device_p){ - - char *err_attr = NULL; - - if (device_create_file(device_p, &dev_attr_id) < 0) { - err_attr = "dev_attr_id"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_ext_id) < 0) { - err_attr = "dev_attr_ext_id"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_connector) < 0) { - err_attr = "dev_attr_connector"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_vendor_name) < 0) { - err_attr = "dev_attr_vendor_name"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_vendor_pn) < 0) { - err_attr = "dev_attr_vendor_pn"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_vendor_rev) < 0) { - err_attr = "dev_attr_vendor_rev"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_vendor_sn) < 0) { - err_attr = "dev_attr_vendor_sn"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_br) < 0) { - err_attr = "dev_attr_br"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_len_smf) < 0) { - err_attr = "dev_attr_len_smf"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_len_om1) < 0) { - err_attr = "dev_attr_len_om1"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_len_om2) < 0) { - err_attr = "dev_attr_len_om2"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_len_om3) < 0) { - err_attr = "dev_attr_len_om3"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_len_om4) < 0) { - err_attr = "dev_attr_len_om4"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_comp_extend) < 0) { - err_attr = "dev_attr_comp_extend"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_comp_eth) < 0) { - err_attr = "dev_attr_comp_eth"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_comp_rev) < 0) { - err_attr = "dev_attr_comp_rev"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_info) < 0) { - err_attr = "dev_attr_info"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_if_type) < 0) { - err_attr = "dev_attr_if_type"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_if_speed) < 0) { - err_attr = "dev_attr_if_speed"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_if_lane) < 0) { - err_attr = "dev_attr_if_lane"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_temperature) < 0) { - err_attr = "dev_attr_temperature"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_voltage) < 0) { - err_attr = "dev_attr_voltage"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_tx_bias) < 0) { - err_attr = "dev_attr_tx_bias"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_tx_power) < 0) { - err_attr = "dev_attr_tx_power"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_rx_power) < 0) { - err_attr = "dev_attr_rx_power"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_tx_eq) < 0) { - err_attr = "dev_attr_tx_eq"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_rx_em) < 0) { - err_attr = "dev_attr_rx_em"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_wavelength) < 0) { - err_attr = "dev_attr_wavelength"; - goto err_transvr_comm_attr; - } - return 0; - -err_transvr_comm_attr: - SWPS_ERR("%s: %s\n", __func__, err_attr); - return -1; -} - -static int -register_transvr_sfp_attr(struct device *device_p){ - - char *err_attr = NULL; - - if (register_transvr_common_attr(device_p) < 0) { - err_attr = "register_transvr_common_attr"; - goto err_transvr_sfp_attr; - } - if (device_create_file(device_p, &dev_attr_comp_eth_10) < 0) { - err_attr = "dev_attr_comp_eth_10"; - goto err_transvr_sfp_attr; - } - if (device_create_file(device_p, &dev_attr_len_sm) < 0) { - err_attr = "dev_attr_len_sm"; - goto err_transvr_sfp_attr; - } - if (device_create_file(device_p, &dev_attr_rate_id) < 0) { - err_attr = "dev_attr_rate_id"; - goto err_transvr_sfp_attr; - } - if (device_create_file(device_p, &dev_attr_soft_rs0) < 0) { - err_attr = "dev_attr_soft_rs0"; - goto err_transvr_sfp_attr; - } - if (device_create_file(device_p, &dev_attr_soft_rs1) < 0) { - err_attr = "dev_attr_soft_rs1"; - goto err_transvr_sfp_attr; - } - if (device_create_file(device_p, &dev_attr_extphy_offset) < 0) { - err_attr = "dev_attr_extphy_offset"; - goto err_transvr_sfp_attr; - } - if (device_create_file(device_p, &dev_attr_extphy_reg) < 0) { - err_attr = "dev_attr_extphy_reg"; - goto err_transvr_sfp_attr; - } - return 0; - -err_transvr_sfp_attr: - SWPS_ERR("%s: %s\n", __func__, err_attr); - return -1; -} - - -static int -register_transvr_qsfp_attr(struct device *device_p){ - - char *err_attr = NULL; - - if (register_transvr_common_attr(device_p) < 0) { - err_attr = "register_transvr_common_attr"; - goto err_transvr_qsfp_attr; - } - if (device_create_file(device_p, &dev_attr_comp_eth_10_40) < 0) { - err_attr = "dev_attr_comp_eth_10_40"; - goto err_transvr_qsfp_attr; - } - if (device_create_file(device_p, &dev_attr_power_cls) < 0) { - err_attr = "dev_attr_power_cls"; - goto err_transvr_qsfp_attr; - } - if (device_create_file(device_p, &dev_attr_soft_rx_los) < 0) { - err_attr = "soft_rx_los"; - goto err_transvr_qsfp_attr; - } - if (device_create_file(device_p, &dev_attr_soft_tx_disable) < 0) { - err_attr = "soft_tx_disable"; - goto err_transvr_qsfp_attr; - } - if (device_create_file(device_p, &dev_attr_auto_tx_disable) < 0) { - err_attr = "auto_tx_disable"; - goto err_transvr_qsfp_attr; - } - if (device_create_file(device_p, &dev_attr_soft_tx_fault) < 0) { - err_attr = "soft_tx_fault"; - goto err_transvr_qsfp_attr; - } - return 0; - -err_transvr_qsfp_attr: - SWPS_ERR("%s: %s\n", __func__, err_attr); - return -1; -} - - -static int -register_transvr_qsfp28_attr(struct device *device_p){ - - char *err_attr = NULL; - - if (register_transvr_qsfp_attr(device_p) < 0){ - err_attr = "register_transvr_qsfp_attr"; - goto err_transvr_qsfp28_attr; - } - if (device_create_file(device_p, &dev_attr_cdr) < 0) { - err_attr = "dev_attr_cdr"; - goto err_transvr_qsfp28_attr; - } - if (device_create_file(device_p, &dev_attr_rx_am) < 0) { - err_attr = "dev_attr_rx_am"; - goto err_transvr_qsfp28_attr; - } - return 0; - -err_transvr_qsfp28_attr: - SWPS_ERR("%s: %s\n", __func__, err_attr); - return -1; -} - - -static int -register_transvr_attr(struct device *device_p, - struct transvr_obj_s *transvr_obj){ - - switch (transvr_obj->layout){ - case TRANSVR_TYPE_SFP: - if (register_transvr_sfp_attr(device_p) < 0){ - goto err_reg_tvr_attr; - } - break; - case TRANSVR_TYPE_QSFP: - case TRANSVR_TYPE_QSFP_PLUS: - if (register_transvr_qsfp_attr(device_p) < 0){ - goto err_reg_tvr_attr; - } - break; - case TRANSVR_TYPE_QSFP_28: - if (register_transvr_qsfp28_attr(device_p) < 0){ - goto err_reg_tvr_attr; - } - break; - default: - goto err_reg_tvr_attr; - } - return 0; - -err_reg_tvr_attr: - SWPS_ERR("%s: fail! type=%d \n", __func__, transvr_obj->type); - return -1; -} - - -static int -register_ioexp_attr_sfp_1(struct device *device_p){ - /* Support machine type: - * - SFP : Magnolia - */ - char *err_attr = NULL; - - if (device_create_file(device_p, &dev_attr_present) < 0) { - err_attr = "dev_attr_present"; - goto err_ioexp_sfp1_attr; - } - if (device_create_file(device_p, &dev_attr_tx_fault) < 0) { - err_attr = "dev_attr_tx_fault"; - goto err_ioexp_sfp1_attr; - } - if (device_create_file(device_p, &dev_attr_rxlos) < 0) { - err_attr = "dev_attr_rxlos"; - goto err_ioexp_sfp1_attr; - } - if (device_create_file(device_p, &dev_attr_tx_disable) < 0) { - err_attr = "dev_attr_tx_disable"; - goto err_ioexp_sfp1_attr; - } - return 0; - -err_ioexp_sfp1_attr: - SWPS_ERR("Add device attribute:%s failure! \n",err_attr); - return -1; -} - - -static int -register_ioexp_attr_sfp_2(struct device *device_p){ - /* Support machine type: - * - SFP28 : Cypress - */ - char *err_attr = NULL; - - if (register_ioexp_attr_sfp_1(device_p) < 0){ - goto err_ioexp_sfp2_attr; - } - if (device_create_file(device_p, &dev_attr_hard_rs0) < 0) { - err_attr = "dev_attr_hard_rs0"; - goto err_ioexp_sfp2_attr; - } - if (device_create_file(device_p, &dev_attr_hard_rs1) < 0) { - err_attr = "dev_attr_hard_rs1"; - goto err_ioexp_sfp2_attr; - } - return 0; - -err_ioexp_sfp2_attr: - SWPS_ERR("Add device attribute:%s failure! \n",err_attr); - return -1; -} - - -static int -register_ioexp_attr_qsfp_1(struct device *device_p){ - /* Support machine type: - * - QSFP : Magnolia, Redwood, Hudson32i - * - QSFP+ : Magnolia, Redwood, Hudson32i - * - QSFP28: Redwood - */ - char *err_attr = NULL; - - if (device_create_file(device_p, &dev_attr_present) < 0) { - err_attr = "dev_attr_present"; - goto err_ioexp_qsfp1_attr; - } - if (device_create_file(device_p, &dev_attr_reset) < 0) { - err_attr = "dev_attr_reset"; - goto err_ioexp_qsfp1_attr; - } - if (device_create_file(device_p, &dev_attr_lpmod) < 0) { - err_attr = "dev_attr_lpmod"; - goto err_ioexp_qsfp1_attr; - } - if (device_create_file(device_p, &dev_attr_modsel) < 0) { - err_attr = "dev_attr_modsel"; - goto err_ioexp_qsfp1_attr; - } - return 0; - -err_ioexp_qsfp1_attr: - SWPS_ERR("Add device attribute:%s failure! \n",err_attr); - return -1; -} - - -static int -register_modctl_attr(struct device *device_p){ - - char *err_msg = NULL; - - if (device_create_file(device_p, &dev_attr_platform) < 0) { - err_msg = "dev_attr_platform"; - goto err_reg_modctl_attr; - } - if (device_create_file(device_p, &dev_attr_version) < 0) { - err_msg = "dev_attr_version"; - goto err_reg_modctl_attr; - } - if (device_create_file(device_p, &dev_attr_status) < 0) { - err_msg = "dev_attr_status"; - goto err_reg_modctl_attr; - } - if (device_create_file(device_p, &dev_attr_reset_i2c) < 0) { - err_msg = "dev_attr_reset_i2c"; - goto err_reg_modctl_attr; - } - if (device_create_file(device_p, &dev_attr_reset_swps) < 0) { - err_msg = "dev_attr_reset_swps"; - goto err_reg_modctl_attr; - } - if (device_create_file(device_p, &dev_attr_auto_config) < 0) { - err_msg = "dev_attr_auto_config"; - goto err_reg_modctl_attr; - } - return 0; - -err_reg_modctl_attr: - SWPS_ERR("%s: %s\n", __func__, err_msg); - return -1; -} - - -static int -register_ioexp_attr(struct device *device_p, - struct transvr_obj_s *transvr_obj){ - - char *err_msg = "ERR"; - - switch (transvr_obj->ioexp_obj_p->ioexp_type){ - case IOEXP_TYPE_MAGINOLIA_NAB: - case IOEXP_TYPE_MAGINOLIA_4AB: - case CPLD_TYPE_COTTONWOOD: - if (register_ioexp_attr_sfp_1(device_p) < 0){ - err_msg = "register_ioexp_attr_sfp_1 fail"; - goto err_reg_ioexp_attr; - } - break; - case IOEXP_TYPE_CYPRESS_NABC: - case IOEXP_TYPE_MAPLE_NABC: - case IOEXP_TYPE_GULMOHAR_NABC: - if (register_ioexp_attr_sfp_2(device_p) < 0){ - err_msg = "register_ioexp_attr_sfp_2 fail"; - goto err_reg_ioexp_attr; - } - break; - case IOEXP_TYPE_MAGINOLIA_7AB: - case IOEXP_TYPE_SPRUCE_7AB: - case IOEXP_TYPE_CYPRESS_7ABC: - case IOEXP_TYPE_REDWOOD_P01P08: - case IOEXP_TYPE_REDWOOD_P09P16: - case IOEXP_TYPE_HUDSON32IGA_P01P08: - case IOEXP_TYPE_HUDSON32IGA_P09P16: - case IOEXP_TYPE_TAHOE_5A: - case IOEXP_TYPE_TAHOE_6ABC: - case IOEXP_TYPE_SEQUOIA_NABC: - case IOEXP_TYPE_LAVENDER_P65: - case IOEXP_TYPE_MAPLE_0ABC: - case IOEXP_TYPE_GULMOHAR_7ABC: - if (register_ioexp_attr_qsfp_1(device_p) < 0){ - err_msg = "register_ioexp_attr_qsfp_1 fail"; - goto err_reg_ioexp_attr; - } - break; - - default: - err_msg = "Unknow type"; - goto err_reg_ioexp_attr; - } - return 0; - -err_reg_ioexp_attr: - SWPS_ERR("%s: %s :%d \n", - __func__, err_msg, transvr_obj->ioexp_obj_p->ioexp_type); - return -1; -} - - -static int -register_modctl_device(void) { - - struct device *device_p = NULL; - int minor_comm = 0; /* Default minor number for common device */ - dev_t dev_num = MKDEV(ctl_major, minor_comm); - char *err_msg = "ERROR"; - - device_p = device_create(swp_class_p, /* struct class *cls */ - NULL, /* struct device *parent */ - dev_num, /* dev_t devt */ - NULL, /* void *private_data */ - SWP_DEV_MODCTL); /* const char *fmt */ - if (IS_ERR(device_p)){ - err_msg = "device_create fail"; - goto err_register_modctl_device_1; - } - if (register_modctl_attr(device_p) < 0) { - err_msg = "register_modctl_attr fail"; - goto err_register_modctl_device_2; - } - return 0; - -err_register_modctl_device_2: - device_unregister(device_p); - device_destroy(swp_class_p, dev_num); -err_register_modctl_device_1: - SWPS_ERR("%s: %s\n", __func__, err_msg); - return -1; -} - - -static int -register_port_device(char *dev_name, - dev_t dev_num, - struct transvr_obj_s *transvr_obj){ - - struct device *device_p = NULL; - device_p = device_create(swp_class_p, /* struct class *cls */ - NULL, /* struct device *parent */ - dev_num, /* dev_t devt */ - transvr_obj, /* void *private_data */ - dev_name); /* const char *fmt */ - if (IS_ERR(device_p)){ - goto err_regswp_create_dev; - } - if (register_transvr_attr(device_p, transvr_obj) < 0){ - goto err_regswp_reg_attr; - } - if (register_ioexp_attr(device_p, transvr_obj) < 0){ - goto err_regswp_reg_attr; - } - return 0; - -err_regswp_reg_attr: - device_unregister(device_p); - device_destroy(swp_class_p, dev_num); -err_regswp_create_dev: - SWPS_ERR("%s fail! :%s\n", __func__, dev_name); - return -1; -} - - -static int -register_swp_module(void){ - - dev_t ctl_devt = 0; - dev_t port_devt = 0; - int dev_total = port_total + 1; /* char_dev for module control */ - - /* Register device number */ - if (alloc_chrdev_region(&ctl_devt, 0, 1, SWP_DEV_MODCTL) < 0){ - SWPS_WARN("Allocate CTL MAJOR failure! \n"); - goto err_register_swp_module_1; - } - if (alloc_chrdev_region(&port_devt, 0, dev_total, SWP_CLS_NAME) < 0){ - SWPS_WARN("Allocate PORT MAJOR failure! \n"); - goto err_register_swp_module_2; - } - ctl_major = MAJOR(ctl_devt); - port_major = MAJOR(port_devt); - - /* Create class object */ - swp_class_p = class_create(THIS_MODULE, SWP_CLS_NAME); - if (IS_ERR(swp_class_p)) { - SWPS_ERR("Create class failure! \n"); - goto err_register_swp_module_3; - } - return 0; - -err_register_swp_module_3: - unregister_chrdev_region(MKDEV(port_major, 0), port_total); -err_register_swp_module_2: - unregister_chrdev_region(MKDEV(ctl_major, 0), 1); -err_register_swp_module_1: - return -1; -} - - -/* ========== Module initial relate ========== - */ -static int -create_ioexp_objs(void) { - - int i, run_mod; - - /* Clean IOEXP object */ - clean_ioexp_objs(); - /* Get running mode */ - run_mod = IOEXP_MODE_DIRECT; - if (SWP_POLLING_ENABLE){ - run_mod = IOEXP_MODE_POLLING; - } - /* Create IOEXP object */ - for(i=0; i devlen_max) { - snprintf(err_msg, sizeof(err_msg), - "SWP_DEV_PORT too long!"); - goto err_initport_create_tranobj; - } - memset(dev_name, 0, sizeof(dev_name)); - snprintf(dev_name, devlen_max, "%s%d", SWP_DEV_PORT, port_id); - /* Create transceiver object */ - ioexp_obj_p = get_ioexp_obj(ioexp_id); - if (!ioexp_obj_p){ - snprintf(err_msg, sizeof(err_msg), - "IOEXP object:%d not exist", ioexp_id); - goto err_initport_create_tranobj; - } - transvr_obj_p = create_transvr_obj(dev_name, chan_id, ioexp_obj_p, - ioexp_virt_offset, transvr_type, - chipset_type, run_mod); - if (!transvr_obj_p){ - snprintf(err_msg, sizeof(err_msg), - "Create transceiver object fail :%s", dev_name); - goto err_initport_create_tranobj; - } - /* Setup Lane_ID mapping */ - i = ARRAY_SIZE(port_layout[minor_curr].lane_id); - j = ARRAY_SIZE(transvr_obj_p->lane_id); - if (i != j) { - snprintf(err_msg, sizeof(err_msg), - "Lane_id size inconsistent %d/%d", i, j); - goto err_initport_reg_device; - } - memcpy(transvr_obj_p->lane_id, port_layout[minor_curr].lane_id, i*sizeof(int)); - /* Create and register device object */ - if (register_port_device(dev_name, MKDEV(port_major, minor_curr), transvr_obj_p) < 0){ - snprintf(err_msg, sizeof(err_msg), - "register_port_device fail"); - goto err_initport_reg_device; - } - /* Setup device_ptr of transvr_obj */ - dev_p = get_swpdev_by_name(dev_name); - if (!dev_p){ - snprintf(err_msg, sizeof(err_msg), - "get_swpdev_by_name fail"); - goto err_initport_reg_device; - } - transvr_obj_p->transvr_dev_p = dev_p; - /* Success */ - ok_count++; - } - SWPS_INFO("%s: initialed %d port-dev",__func__, ok_count); - return 0; - -err_initport_reg_device: - kfree(transvr_obj_p); -err_initport_create_tranobj: - clean_port_obj(); - SWPS_ERR("%s: %s", __func__, err_msg); - SWPS_ERR("Dump: :%d :%d :%d :%d :%d :%d\n", - port_id, chan_id, ioexp_id, ioexp_virt_offset, transvr_type, run_mod); - return -1; -} - - -static int -init_dev_topology(void){ - - int err; - char *emsg = "ERR"; - flag_mod_state = SWP_STATE_NORMAL; - - err = init_ioexp_objs(); - switch(err){ - case 0: /* Normal */ - SWPS_DEBUG("%s: normal case\n", __func__); - break; - - case -1: /* topology error */ - SWPS_DEBUG("%s: detect tier-1 topology initial failure :%d\n", - __func__, err); - /* Reset and isolate */ - err = reset_i2c_topology(); - if (err < 0) { - emsg = "reset i2c topology fail"; - goto err_init_dev_topology; - } - /* Re-initial again */ - err = init_ioexp_objs(); - if (err < 0) { - emsg = "re-init ioexp objects fail"; - goto err_init_dev_topology; - } - break; - - case -2: /* Internal error */ - SWPS_DEBUG("%s: internal error case\n", __func__); - err = -2; - emsg = "internal error"; - goto err_init_dev_topology; - - default: - SWPS_DEBUG("%s: undefined error case\n", __func__); - emsg = "undefined error case"; - goto err_init_dev_topology; - } - SWPS_DEBUG("%s: initial I2C topology success\n", __func__); - return 0; - -err_init_dev_topology: - SWPS_ERR("%s: %s :%d\n", __func__, emsg, err); - return -1; -} - - -static int -init_polling_task(void){ - - if (SWP_POLLING_ENABLE){ - schedule_delayed_work(&swp_polling, _get_polling_period()); - } - return 0; -} - - -static int -init_swps_common(void){ - - char *err_msg = "ERR"; - - auto_config = 0; - if ((SWP_AUTOCONFIG_ENABLE) && (SWP_POLLING_ENABLE)){ - auto_config = 1; - } - if (register_modctl_device() < 0) { - err_msg = "register_modctl_device fail"; - goto err_init_swps_common_1; - } - if (_update_auto_config_2_trnasvr() < 0) { - err_msg = "_update_auto_config_2_trnasvr fail"; - goto err_init_swps_common_1; - } - if (init_polling_task() < 0){ - err_msg = "init_polling_task fail"; - goto err_init_swps_common_1; - } - return 0; - -err_init_swps_common_1: - clean_swps_common(); - SWPS_ERR("%s: %s\n", __func__, err_msg); - return -1; -} - - -static int __init -swp_module_init(void){ - - if (get_platform_type() < 0){ - goto err_init_out; - } - if (get_layout_info() < 0){ - goto err_init_out; - } - if (register_swp_module() < 0){ - goto err_init_out; - } - if (create_ioexp_objs() < 0){ - goto err_init_ioexp; - } - if (create_port_objs() < 0){ - goto err_init_portobj; - } - if (init_mux_gpio(gpio_rest_mux) < 0){ - goto err_init_mux; - } - if (init_dev_topology() < 0){ - goto err_init_topology; - } - if (init_swps_common() < 0){ - goto err_init_topology; - } - SWPS_INFO("Inventec switch-port module V.%s initial success.\n", SWP_VERSION); - return 0; - - -err_init_topology: - clean_mux_gpio(); -err_init_mux: - clean_port_obj(); -err_init_portobj: - clean_ioexp_objs(); -err_init_ioexp: - class_unregister(swp_class_p); - class_destroy(swp_class_p); - unregister_chrdev_region(MKDEV(ctl_major, 0), 1); - unregister_chrdev_region(MKDEV(port_major, 0), port_total); -err_init_out: - SWPS_ERR("Inventec switch-port module V.%s initial failure.\n", SWP_VERSION); - return -1; -} - - -static void __exit -swp_module_exit(void){ - - clean_swps_common(); - clean_port_obj(); - clean_ioexp_objs(); - clean_mux_gpio(); - class_unregister(swp_class_p); - class_destroy(swp_class_p); - unregister_chrdev_region(MKDEV(ctl_major, 0), 1); - unregister_chrdev_region(MKDEV(port_major, 0), port_total); - SWPS_INFO("Remove Inventec switch-port module success.\n"); -} - - -/* Module information */ -MODULE_AUTHOR(SWP_AUTHOR); -MODULE_DESCRIPTION(SWP_DESC); -MODULE_VERSION(SWP_VERSION); -MODULE_LICENSE(SWP_LICENSE); - -module_init(swp_module_init); -module_exit(swp_module_exit); - - - - - - - - - - diff --git a/packages/platforms/inventec/x86-64/d5254/modules/builds/src/inv_swps.h b/packages/platforms/inventec/x86-64/d5254/modules/builds/src/inv_swps.h deleted file mode 100644 index a18c9af24..000000000 --- a/packages/platforms/inventec/x86-64/d5254/modules/builds/src/inv_swps.h +++ /dev/null @@ -1,1265 +0,0 @@ -#ifndef INV_SWPS_H -#define INV_SWPS_H - -#include "transceiver.h" -#include "io_expander.h" -#include "inv_mux.h" - -/* Module settings */ -#define SWP_CLS_NAME "swps" -#define SWP_DEV_PORT "port" -#define SWP_DEV_MODCTL "module" -#define SWP_RESET_PWD "inventec" -#define SWP_POLLING_PERIOD (300) /* msec */ -#define SWP_POLLING_ENABLE (1) -#define SWP_AUTOCONFIG_ENABLE (1) - -/* Module information */ -#define SWP_AUTHOR "Neil " -#define SWP_DESC "Inventec port and transceiver driver" -#define SWP_VERSION "4.2.10" -#define SWP_LICENSE "GPL" - -/* Module status define */ -#define SWP_STATE_NORMAL (0) -#define SWP_STATE_I2C_DIE (-91) - -/* [Note]: - * Functions and mechanism for auto-detect platform type is ready, - * But HW and BIOS not ready! We need to wait them. - * So, please do not use PLATFORM_TYPE_AUTO until they are ready. - * (2016.06.13) - */ -#define PLATFORM_TYPE_AUTO (100) -#define PLATFORM_TYPE_MAGNOLIA (111) -#define PLATFORM_TYPE_MAGNOLIA_FNC (112) -#define PLATFORM_TYPE_REDWOOD (121) -#define PLATFORM_TYPE_REDWOOD_FSL (122) -#define PLATFORM_TYPE_HUDSON32I_GA (131) -#define PLATFORM_TYPE_SPRUCE (141) -#define PLATFORM_TYPE_CYPRESS_GA1 (151) /* Up -> Down */ -#define PLATFORM_TYPE_CYPRESS_GA2 (152) /* Down -> Up */ -#define PLATFORM_TYPE_CYPRESS_BAI (153) /* Down -> Up */ -#define PLATFORM_TYPE_TAHOE (161) -#define PLATFORM_TYPE_SEQUOIA_GA (171) -#define PLATFORM_TYPE_LAVENDER_GA (181) -#define PLATFORM_TYPE_LAVENDER_ONL (182) -#define PLATFORM_TYPE_COTTONWOOD_RANGELEY (191) -#define PLATFORM_TYPE_MAPLE (201) -#define PLATFORM_TYPE_GULMOHAR_GA (202) -/* Current running platfrom */ -#define PLATFORM_SETTINGS PLATFORM_TYPE_GULMOHAR_GA - -/* Define platform flag and kernel version */ -#if (PLATFORM_SETTINGS == PLATFORM_TYPE_MAGNOLIA) - #define SWPS_MAGNOLIA (1) - #define SWPS_KERN_VER_BF_3_8 (1) -#elif (PLATFORM_SETTINGS == PLATFORM_TYPE_MAGNOLIA_FNC) - #define SWPS_MAGNOLIA (1) - #define SWPS_KERN_VER_AF_3_10 (1) -#elif (PLATFORM_SETTINGS == PLATFORM_TYPE_REDWOOD) - #define SWPS_REDWOOD (1) - #define SWPS_KERN_VER_BF_3_8 (1) -#elif (PLATFORM_SETTINGS == PLATFORM_TYPE_REDWOOD_FSL) - #define SWPS_REDWOOD_FSL (1) - #define SWPS_KERN_VER_BF_3_8 (1) -#elif (PLATFORM_SETTINGS == PLATFORM_TYPE_HUDSON32I_GA) - #define SWPS_HUDSON32I_GA (1) - #define SWPS_KERN_VER_BF_3_8 (1) -#elif (PLATFORM_SETTINGS == PLATFORM_TYPE_SPRUCE) - #define SWPS_SPRUCE (1) - #define SWPS_KERN_VER_BF_3_8 (1) -#elif (PLATFORM_SETTINGS == PLATFORM_TYPE_CYPRESS_GA1) - #define SWPS_CYPRESS_GA1 (1) - #define SWPS_KERN_VER_BF_3_8 (1) -#elif (PLATFORM_SETTINGS == PLATFORM_TYPE_CYPRESS_GA2) - #define SWPS_CYPRESS_GA2 (1) - #define SWPS_KERN_VER_BF_3_8 (1) -#elif (PLATFORM_SETTINGS == PLATFORM_TYPE_CYPRESS_BAI) - #define SWPS_CYPRESS_BAI (1) - #define SWPS_KERN_VER_AF_3_10 (1) -#elif (PLATFORM_SETTINGS == PLATFORM_TYPE_TAHOE) - #define SWPS_TAHOE (1) - #define SWPS_KERN_VER_AF_3_10 (1) -#elif (PLATFORM_SETTINGS == PLATFORM_TYPE_SEQUOIA_GA) - #define SWPS_SEQUOIA (1) - #define SWPS_KERN_VER_BF_3_8 (1) -#elif (PLATFORM_SETTINGS == PLATFORM_TYPE_LAVENDER_GA) - #define SWPS_LAVENDER (1) - #define SWPS_KERN_VER_AF_3_10 (1) -#elif (PLATFORM_SETTINGS == PLATFORM_TYPE_LAVENDER_ONL) - #define SWPS_LAVENDER (1) - #define SWPS_KERN_VER_AF_3_10 (1) -#elif (PLATFORM_SETTINGS == PLATFORM_TYPE_COTTONWOOD_RANGELEY) - #define SWPS_COTTONWOOD_RANGELEY (1) - #define SWPS_KERN_VER_AF_3_10 (1) -#elif (PLATFORM_SETTINGS == PLATFORM_TYPE_MAPLE) - #define SWPS_MAPLE (1) - #define SWPS_KERN_VER_AF_3_10 (1) -#elif (PLATFORM_SETTINGS == PLATFORM_TYPE_GULMOHAR_GA) - #define SWPS_GULMOHAR (1) - #define SWPS_KERN_VER_AF_3_10 (1) -#endif - - -struct inv_platform_s { - int id; - char name[64]; -}; - -struct inv_ioexp_layout_s { - int ioexp_id; - int ioexp_type; - struct ioexp_addr_s addr[4]; -}; - -struct inv_port_layout_s { - int port_id; - int chan_id; - int ioexp_id; - int ioexp_offset; - int transvr_type; - int chipset_type; - int lane_id[8]; -}; - - -/* ========================================== - * Inventec Platform Settings - * ========================================== - */ -struct inv_platform_s platform_map[] = { - {PLATFORM_TYPE_AUTO, "Auto-Detect" }, - {PLATFORM_TYPE_MAGNOLIA, "Magnolia" }, - {PLATFORM_TYPE_MAGNOLIA_FNC, "Magnolia_FNC" }, - {PLATFORM_TYPE_REDWOOD, "Redwood" }, - {PLATFORM_TYPE_REDWOOD_FSL, "Redwood_FSL" }, - {PLATFORM_TYPE_HUDSON32I_GA, "Hudson32i" }, - {PLATFORM_TYPE_SPRUCE, "Spruce" }, - {PLATFORM_TYPE_CYPRESS_GA1, "Cypress_GA1" }, - {PLATFORM_TYPE_CYPRESS_GA2, "Cypress_GA2" }, - {PLATFORM_TYPE_CYPRESS_BAI, "Cypress_BAI" }, - {PLATFORM_TYPE_TAHOE, "Tahoe" }, - {PLATFORM_TYPE_SEQUOIA_GA, "Sequoia_GA" }, - {PLATFORM_TYPE_LAVENDER_GA, "Lavender_GA" }, - {PLATFORM_TYPE_LAVENDER_ONL, "Lavender_ONL" }, - {PLATFORM_TYPE_COTTONWOOD_RANGELEY, "Cottonwood_RANGELEY" }, - {PLATFORM_TYPE_MAPLE, "Maple" }, - {PLATFORM_TYPE_GULMOHAR_GA, "Gulmohar_GA" }, -}; - - -/* ========================================== - * Magnolia Layout configuration - * ========================================== - */ -#ifdef SWPS_MAGNOLIA -unsigned magnolia_gpio_rest_mux = MUX_RST_GPIO_48_PAC9548; - -struct inv_ioexp_layout_s magnolia_ioexp_layout[] = { - /* IOEXP_ID / IOEXP_TYPE / { Chan_ID, Chip_addr, Read_offset, Write_offset, config_offset, data_default, conf_default } */ - {0, IOEXP_TYPE_MAGINOLIA_NAB, { {2, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {2, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, }, /* addr[1] = I/O Expander N B */ - }, - {1, IOEXP_TYPE_MAGINOLIA_NAB, { {3, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {3, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, }, /* addr[1] = I/O Expander N B */ - }, - {2, IOEXP_TYPE_MAGINOLIA_NAB, { {4, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {4, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, }, /* addr[1] = I/O Expander N B */ - }, - {3, IOEXP_TYPE_MAGINOLIA_4AB, { {5, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander 4 A */ - {5, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xf0, 0xff}, {0xf0, 0xff}, }, }, /* addr[1] = I/O Expander 4 B */ - }, - {4, IOEXP_TYPE_MAGINOLIA_NAB, { {6, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {6, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, }, /* addr[1] = I/O Expander N B */ - }, - {5, IOEXP_TYPE_MAGINOLIA_NAB, { {7, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {7, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, }, /* addr[1] = I/O Expander N B */ - }, - {6, IOEXP_TYPE_MAGINOLIA_7AB, { {8, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[0] = I/O Expander 7 A */ - {8, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xf0, 0x33}, }, }, /* addr[1] = I/O Expander 7 B */ - }, -}; - -struct inv_port_layout_s magnolia_port_layout[] = { - /* Port_ID / Chan_ID / IOEXP_ID / IOEXP_VIRT_OFFSET / TRANSCEIVER_TYPE / CHIP_TYPE / LANE_ID */ - { 0, 10, 0, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 16} }, - { 1, 11, 0, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 15} }, - { 2, 12, 0, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 14} }, - { 3, 13, 0, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 13} }, - { 4, 14, 0, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 24} }, - { 5, 15, 0, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 23} }, - { 6, 16, 0, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 22} }, - { 7, 17, 0, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 21} }, - { 8, 18, 1, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 28} }, - { 9, 19, 1, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 27} }, - {10, 20, 1, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 26} }, - {11, 21, 1, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 25} }, - {12, 22, 1, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 32} }, - {13, 23, 1, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 31} }, - {14, 24, 1, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 30} }, - {15, 25, 1, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 29} }, - {16, 26, 2, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 48} }, - {17, 27, 2, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 47} }, - {18, 28, 2, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 46} }, - {19, 29, 2, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 45} }, - {20, 30, 2, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 52} }, - {21, 31, 2, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 51} }, - {22, 32, 2, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 50} }, - {23, 33, 2, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 49} }, - {24, 34, 3, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 56} }, - {25, 35, 3, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 55} }, - {26, 36, 3, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 54} }, - {27, 37, 3, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 53} }, - {28, 38, 3, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 60} }, - {29, 39, 3, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 59} }, - {30, 40, 3, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 58} }, - {31, 41, 3, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 57} }, - {32, 42, 4, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 64} }, - {33, 43, 4, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 63} }, - {34, 44, 4, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 62} }, - {35, 45, 4, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 61} }, - {36, 46, 4, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 68} }, - {37, 47, 4, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 67} }, - {38, 48, 4, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 66} }, - {39, 49, 4, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 65} }, - {40, 50, 5, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 72} }, - {41, 51, 5, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 71} }, - {42, 52, 5, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 70} }, - {43, 53, 5, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 69} }, - {44, 54, 5, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 76} }, - {45, 55, 5, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 75} }, - {46, 56, 5, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 74} }, - {47, 57, 5, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 73} }, - {48, 58, 6, 0, TRANSVR_TYPE_QSFP, CHIP_TYPE_MAGNOLIA, { 81, 82, 83, 84} }, - {49, 59, 6, 1, TRANSVR_TYPE_QSFP, CHIP_TYPE_MAGNOLIA, { 77, 78, 79, 80} }, - {50, 60, 6, 2, TRANSVR_TYPE_QSFP, CHIP_TYPE_MAGNOLIA, { 97, 98, 99,100} }, - {51, 61, 6, 3, TRANSVR_TYPE_QSFP, CHIP_TYPE_MAGNOLIA, {101,102,103,104} }, - {52, 62, 6, 4, TRANSVR_TYPE_QSFP, CHIP_TYPE_MAGNOLIA, {105,106,107,108} }, - {53, 63, 6, 5, TRANSVR_TYPE_QSFP, CHIP_TYPE_MAGNOLIA, {109,110,111,112} }, -}; -#endif - - -/* ========================================== - * Redwood Layout configuration - * ========================================== - */ -#ifdef SWPS_REDWOOD -unsigned redwood_gpio_rest_mux = MUX_RST_GPIO_48_PAC9548; - -struct inv_ioexp_layout_s redwood_ioexp_layout[] = { - /* IOEXP_ID / IOEXP_TYPE / { Chan_ID, Chip_addr, Read_offset, Write_offset, config_offset, data_default, conf_default } */ - {0, IOEXP_TYPE_REDWOOD_P01P08, { {4, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[0] = I/O Expander 1-4 A */ - {4, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[1] = I/O Expander 1-4 B */ - {0, 0x25, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 5 B */ - }, - {1, IOEXP_TYPE_REDWOOD_P09P16, { {5, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[0] = I/O Expander 1-4 A */ - {5, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[1] = I/O Expander 1-4 B */ - {0, 0x25, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 5 B */ - }, - {2, IOEXP_TYPE_REDWOOD_P01P08, { {2, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[0] = I/O Expander 1-4 A */ - {2, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[1] = I/O Expander 1-4 B */ - {0, 0x24, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 5 B */ - }, - {3, IOEXP_TYPE_REDWOOD_P09P16, { {3, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[0] = I/O Expander 1-4 A */ - {3, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[1] = I/O Expander 1-4 B */ - {0, 0x24, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 5 B */ - }, -}; - -struct inv_port_layout_s redwood_port_layout[] = { - /* Port_ID / Chan_ID / IOEXP_ID / IOEXP_VIRT_OFFSET / TRANSCEIVER_TYPE / CHIP_TYPE / LANE_ID */ - { 0, 22, 0, 0, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 1, 2, 3, 4} }, - { 1, 23, 0, 1, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 5, 6, 7, 8} }, - { 2, 24, 0, 2, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 9, 10, 11, 12} }, - { 3, 25, 0, 3, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 13, 14, 15, 16} }, - { 4, 26, 0, 4, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 17, 18, 19, 20} }, - { 5, 27, 0, 5, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 21, 22, 23, 24} }, - { 6, 28, 0, 6, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 25, 26, 27, 28} }, - { 7, 29, 0, 7, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 29, 30, 31, 32} }, - { 8, 30, 1, 0, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 33, 34, 35, 36} }, - { 9, 31, 1, 1, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 37, 38, 39, 40} }, - {10, 32, 1, 2, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 41, 42, 43, 44} }, - {11, 33, 1, 3, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 45, 46, 47, 48} }, - {12, 34, 1, 4, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 49, 50, 51, 52} }, - {13, 35, 1, 5, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 53, 54, 55, 56} }, - {14, 36, 1, 6, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 57, 58, 59, 60} }, - {15, 37, 1, 7, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 61, 62, 63, 64} }, - {16, 6, 2, 0, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 65, 66, 67, 68} }, - {17, 7, 2, 1, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 69, 70, 71, 72} }, - {18, 8, 2, 2, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 73, 74, 75, 76} }, - {19, 9, 2, 3, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 77, 78, 79, 80} }, - {20, 10, 2, 4, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 81, 82, 83, 84} }, - {21, 11, 2, 5, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 85, 86, 87, 88} }, - {22, 12, 2, 6, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 89, 90, 91, 92} }, - {23, 13, 2, 7, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 93, 94, 95, 96} }, - {24, 14, 3, 0, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 97, 98, 99,100} }, - {25, 15, 3, 1, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {101,102,103,104} }, - {26, 16, 3, 2, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {105,106,107,108} }, - {27, 17, 3, 3, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {109,110,111,112} }, - {28, 18, 3, 4, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {113,114,115,116} }, - {29, 19, 3, 5, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {117,118,119,120} }, - {30, 20, 3, 6, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {121,122,123,124} }, - {31, 21, 3, 7, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {125,126,127,128} }, -}; -#endif - - -/* ========================================== - * Hudson32i Layout configuration - * ========================================== - */ -#ifdef SWPS_HUDSON32I_GA -unsigned hudsin32iga_gpio_rest_mux = MUX_RST_GPIO_48_PAC9548; - -struct inv_ioexp_layout_s hudson32iga_ioexp_layout[] = { - /* IOEXP_ID / IOEXP_TYPE / { Chan_ID, Chip_addr, Read_offset, Write_offset, config_offset, data_default, conf_default } */ - {0, IOEXP_TYPE_HUDSON32IGA_P01P08, { {2, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[0] = I/O Expander A */ - {2, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[1] = I/O Expander B */ - {0, 0x24, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 0x24 */ - }, - {1, IOEXP_TYPE_HUDSON32IGA_P09P16, { {3, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[0] = I/O Expander A */ - {3, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[1] = I/O Expander B */ - {0, 0x24, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 0x24 */ - }, - {2, IOEXP_TYPE_HUDSON32IGA_P01P08, { {4, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[0] = I/O Expander A */ - {4, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[1] = I/O Expander B */ - {0, 0x25, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 0x25 */ - }, - {3, IOEXP_TYPE_HUDSON32IGA_P09P16, { {5, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[0] = I/O Expander A */ - {5, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[1] = I/O Expander B */ - {0, 0x25, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 0x25 */ - }, -}; - -struct inv_port_layout_s hudson32iga_port_layout[] = { - /* Port_ID / Chan_ID / IOEXP_ID / IOEXP_VIRT_OFFSET / TRANSCEIVER_TYPE / CHIP_TYPE / LANE_ID */ - { 0, 6, 0, 0, TRANSVR_TYPE_QSFP_PLUS, CHIP_TYPE_MAGNOLIA, { 1, 2, 3, 4} }, - { 1, 7, 0, 1, TRANSVR_TYPE_QSFP_PLUS, CHIP_TYPE_MAGNOLIA, { 5, 6, 7, 8} }, - { 2, 8, 0, 2, TRANSVR_TYPE_QSFP_PLUS, CHIP_TYPE_MAGNOLIA, { 9, 10, 11, 12} }, - { 3, 9, 0, 3, TRANSVR_TYPE_QSFP_PLUS, CHIP_TYPE_MAGNOLIA, { 13, 14, 15, 16} }, - { 4, 10, 0, 4, TRANSVR_TYPE_QSFP_PLUS, CHIP_TYPE_MAGNOLIA, { 17, 18, 19, 20} }, - { 5, 11, 0, 5, TRANSVR_TYPE_QSFP_PLUS, CHIP_TYPE_MAGNOLIA, { 21, 22, 23, 24} }, - { 6, 12, 0, 6, TRANSVR_TYPE_QSFP_PLUS, CHIP_TYPE_MAGNOLIA, { 25, 26, 27, 28} }, - { 7, 13, 0, 7, TRANSVR_TYPE_QSFP_PLUS, CHIP_TYPE_MAGNOLIA, { 29, 30, 31, 32} }, - { 8, 14, 1, 0, TRANSVR_TYPE_QSFP_PLUS, CHIP_TYPE_MAGNOLIA, { 33, 34, 35, 36} }, - { 9, 15, 1, 1, TRANSVR_TYPE_QSFP_PLUS, CHIP_TYPE_MAGNOLIA, { 37, 38, 39, 40} }, - {10, 16, 1, 2, TRANSVR_TYPE_QSFP_PLUS, CHIP_TYPE_MAGNOLIA, { 41, 42, 43, 44} }, - {11, 17, 1, 3, TRANSVR_TYPE_QSFP_PLUS, CHIP_TYPE_MAGNOLIA, { 45, 46, 47, 48} }, - {12, 18, 1, 4, TRANSVR_TYPE_QSFP_PLUS, CHIP_TYPE_MAGNOLIA, { 49, 50, 51, 52} }, - {13, 19, 1, 5, TRANSVR_TYPE_QSFP_PLUS, CHIP_TYPE_MAGNOLIA, { 53, 54, 55, 56} }, - {14, 20, 1, 6, TRANSVR_TYPE_QSFP_PLUS, CHIP_TYPE_MAGNOLIA, { 57, 58, 59, 60} }, - {15, 21, 1, 7, TRANSVR_TYPE_QSFP_PLUS, CHIP_TYPE_MAGNOLIA, { 61, 62, 63, 64} }, - {16, 22, 2, 0, TRANSVR_TYPE_QSFP_PLUS, CHIP_TYPE_MAGNOLIA, { 65, 66, 67, 68} }, - {17, 23, 2, 1, TRANSVR_TYPE_QSFP_PLUS, CHIP_TYPE_MAGNOLIA, { 69, 70, 71, 72} }, - {18, 24, 2, 2, TRANSVR_TYPE_QSFP_PLUS, CHIP_TYPE_MAGNOLIA, { 73, 74, 75, 76} }, - {19, 25, 2, 3, TRANSVR_TYPE_QSFP_PLUS, CHIP_TYPE_MAGNOLIA, { 77, 78, 79, 80} }, - {20, 26, 2, 4, TRANSVR_TYPE_QSFP_PLUS, CHIP_TYPE_MAGNOLIA, { 81, 82, 83, 84} }, - {21, 27, 2, 5, TRANSVR_TYPE_QSFP_PLUS, CHIP_TYPE_MAGNOLIA, { 85, 86, 87, 88} }, - {22, 28, 2, 6, TRANSVR_TYPE_QSFP_PLUS, CHIP_TYPE_MAGNOLIA, { 89, 90, 91, 92} }, - {23, 29, 2, 7, TRANSVR_TYPE_QSFP_PLUS, CHIP_TYPE_MAGNOLIA, { 93, 94, 95, 96} }, - {24, 30, 3, 0, TRANSVR_TYPE_QSFP_PLUS, CHIP_TYPE_MAGNOLIA, { 97, 98, 99,100} }, - {25, 31, 3, 1, TRANSVR_TYPE_QSFP_PLUS, CHIP_TYPE_MAGNOLIA, {101,102,103,104} }, - {26, 32, 3, 2, TRANSVR_TYPE_QSFP_PLUS, CHIP_TYPE_MAGNOLIA, {105,106,107,108} }, - {27, 33, 3, 3, TRANSVR_TYPE_QSFP_PLUS, CHIP_TYPE_MAGNOLIA, {109,110,111,112} }, - {28, 34, 3, 4, TRANSVR_TYPE_QSFP_PLUS, CHIP_TYPE_MAGNOLIA, {113,114,115,116} }, - {29, 35, 3, 5, TRANSVR_TYPE_QSFP_PLUS, CHIP_TYPE_MAGNOLIA, {117,118,119,120} }, - {30, 36, 3, 6, TRANSVR_TYPE_QSFP_PLUS, CHIP_TYPE_MAGNOLIA, {121,122,123,124} }, - {31, 37, 3, 7, TRANSVR_TYPE_QSFP_PLUS, CHIP_TYPE_MAGNOLIA, {125,126,127,128} }, -}; -#endif - - -/* ========================================== - * Spruce Layout configuration - * ========================================== - */ -#ifdef SWPS_SPRUCE -unsigned spruce_gpio_rest_mux = MUX_RST_GPIO_48_PAC9548; - -struct inv_ioexp_layout_s spruce_ioexp_layout[] = { - /* IOEXP_ID / IOEXP_TYPE / { Chan_ID, Chip_addr, Read_offset, Write_offset, config_offset, data_default, conf_default } */ - {0, IOEXP_TYPE_SPRUCE_7AB, { {2, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[0] = I/O Expander 7A */ - {2, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xf0, 0x33}, }, }, /* addr[2] = I/O Expander 7B */ - }, -}; - -struct inv_port_layout_s spruce_port_layout[] = { - /* Port_ID / Chan_ID / IOEXP_ID / IOEXP_VIRT_OFFSET / TRANSCEIVER_TYPE / CHIP_TYPE / LANE_ID */ - { 0, 6, 0, 0, TRANSVR_TYPE_QSFP_PLUS, CHIP_TYPE_MAGNOLIA, { 81, 82, 83, 84} }, - { 1, 7, 0, 1, TRANSVR_TYPE_QSFP_PLUS, CHIP_TYPE_MAGNOLIA, { 77, 78, 79, 80} }, - { 2, 8, 0, 2, TRANSVR_TYPE_QSFP_PLUS, CHIP_TYPE_MAGNOLIA, { 97, 98, 99,100} }, - { 3, 9, 0, 3, TRANSVR_TYPE_QSFP_PLUS, CHIP_TYPE_MAGNOLIA, {101,102,103,104} }, - { 4, 10, 0, 4, TRANSVR_TYPE_QSFP_PLUS, CHIP_TYPE_MAGNOLIA, {105,106,107,108} }, - { 5, 11, 0, 5, TRANSVR_TYPE_QSFP_PLUS, CHIP_TYPE_MAGNOLIA, {109,110,111,112} }, -}; -#endif - - -/* ========================================== - * Cypress Layout configuration (Inventec version [Up->Down]) - * ========================================== - */ -#ifdef SWPS_CYPRESS_GA1 -unsigned cypress_ga1_gpio_rest_mux = MUX_RST_GPIO_69_PAC9548; - -struct inv_ioexp_layout_s cypress_ga1_ioexp_layout[] = { - /* IOEXP_ID / IOEXP_TYPE / { Chan_ID, Chip_addr, Read_offset, Write_offset, config_offset, data_default, conf_default } */ - {0, IOEXP_TYPE_CYPRESS_NABC, { {2, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {2, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {2, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {1, IOEXP_TYPE_CYPRESS_NABC, { {3, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {3, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {3, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {2, IOEXP_TYPE_CYPRESS_NABC, { {4, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {4, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {4, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {3, IOEXP_TYPE_CYPRESS_NABC, { {5, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {5, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {5, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {4, IOEXP_TYPE_CYPRESS_NABC, { {6, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {6, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {6, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {5, IOEXP_TYPE_CYPRESS_NABC, { {7, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {7, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {7, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {6, IOEXP_TYPE_CYPRESS_7ABC, { {8, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xc0, 0xc0}, }, /* addr[0] = I/O Expander 7 A */ - {8, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xc0, 0xc0}, {0xff, 0xc0}, }, /* addr[1] = I/O Expander 7 B */ - {8, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 7 C */ - }, -}; - -struct inv_port_layout_s cypress_ga1_port_layout[] = { - /* Port_ID / Chan_ID / IOEXP_ID / IOEXP_VIRT_OFFSET / TRANSCEIVER_TYPE / CHIP_TYPE / LANE_ID */ - { 0, 10, 0, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 1} }, - { 1, 11, 0, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 2} }, - { 2, 12, 0, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 3} }, - { 3, 13, 0, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 4} }, - { 4, 14, 0, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 5} }, - { 5, 15, 0, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 6} }, - { 6, 16, 0, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 7} }, - { 7, 17, 0, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 8} }, - { 8, 18, 1, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 9} }, - { 9, 19, 1, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 10} }, - {10, 20, 1, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 11} }, - {11, 21, 1, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 12} }, - {12, 22, 1, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 21} }, - {13, 23, 1, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 22} }, - {14, 24, 1, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 23} }, - {15, 25, 1, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 24} }, - {16, 26, 2, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 33} }, - {17, 27, 2, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 34} }, - {18, 28, 2, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 35} }, - {19, 29, 2, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 36} }, - {20, 30, 2, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 37} }, - {21, 31, 2, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 38} }, - {22, 32, 2, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 39} }, - {23, 33, 2, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 40} }, - {24, 34, 3, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 41} }, - {25, 35, 3, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 42} }, - {26, 36, 3, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 43} }, - {27, 37, 3, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 44} }, - {28, 38, 3, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 49} }, - {29, 39, 3, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 50} }, - {30, 40, 3, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 51} }, - {31, 41, 3, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 52} }, - {32, 42, 4, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 53} }, - {33, 43, 4, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 54} }, - {34, 44, 4, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 55} }, - {35, 45, 4, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 56} }, - {36, 46, 4, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 65} }, - {37, 47, 4, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 66} }, - {38, 48, 4, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 67} }, - {39, 49, 4, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 68} }, - {40, 50, 5, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 69} }, - {41, 51, 5, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 70} }, - {42, 52, 5, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 71} }, - {43, 53, 5, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 72} }, - {44, 54, 5, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 81} }, - {45, 55, 5, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 82} }, - {46, 56, 5, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 83} }, - {47, 57, 5, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 84} }, - {48, 58, 6, 0, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 97, 98, 99,100} }, - {49, 59, 6, 1, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 85, 86, 87, 88} }, - {50, 60, 6, 2, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {101,102,103,104} }, - {51, 61, 6, 3, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {105,106,107,108} }, - {52, 62, 6, 4, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {109,110,111,112} }, - {53, 63, 6, 5, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {117,118,119,120} }, -}; -#endif - - -/* ========================================== - * Cypress Layout configuration (Inventec version [Down->Up]) - * ========================================== - */ -#ifdef SWPS_CYPRESS_GA2 -unsigned cypress_ga2_gpio_rest_mux = MUX_RST_GPIO_FORCE_HEDERA; - -struct inv_ioexp_layout_s cypress_ga2_ioexp_layout[] = { - /* IOEXP_ID / IOEXP_TYPE / { Chan_ID, Chip_addr, Read_offset, Write_offset, config_offset, data_default, conf_default } */ - {0, IOEXP_TYPE_CYPRESS_NABC, { {2, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {2, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {2, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {1, IOEXP_TYPE_CYPRESS_NABC, { {3, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {3, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {3, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {2, IOEXP_TYPE_CYPRESS_NABC, { {4, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {4, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {4, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {3, IOEXP_TYPE_CYPRESS_NABC, { {5, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {5, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {5, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {4, IOEXP_TYPE_CYPRESS_NABC, { {6, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {6, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {6, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {5, IOEXP_TYPE_CYPRESS_NABC, { {7, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {7, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {7, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {6, IOEXP_TYPE_CYPRESS_7ABC, { {8, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xc0, 0xc0}, }, /* addr[0] = I/O Expander 7 A */ - {8, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xc0, 0xc0}, {0xff, 0xc0}, }, /* addr[1] = I/O Expander 7 B */ - {8, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 7 C */ - }, -}; - -struct inv_port_layout_s cypress_ga2_port_layout[] = { - /* Port_ID / Chan_ID / IOEXP_ID / IOEXP_VIRT_OFFSET / TRANSCEIVER_TYPE / CHIP_TYPE / LANE_ID */ - { 0, 11, 0, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 2} }, - { 1, 10, 0, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 1} }, - { 2, 13, 0, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 4} }, - { 3, 12, 0, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 3} }, - { 4, 15, 0, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 6} }, - { 5, 14, 0, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 5} }, - { 6, 17, 0, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 8} }, - { 7, 16, 0, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 7} }, - { 8, 19, 1, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 10} }, - { 9, 18, 1, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 9} }, - {10, 21, 1, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 12} }, - {11, 20, 1, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 11} }, - {12, 23, 1, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 22} }, - {13, 22, 1, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 21} }, - {14, 25, 1, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 24} }, - {15, 24, 1, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 23} }, - {16, 27, 2, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 34} }, - {17, 26, 2, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 33} }, - {18, 29, 2, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 36} }, - {19, 28, 2, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 35} }, - {20, 31, 2, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 38} }, - {21, 30, 2, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 37} }, - {22, 33, 2, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 40} }, - {23, 32, 2, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 39} }, - {24, 35, 3, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 42} }, - {25, 34, 3, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 41} }, - {26, 37, 3, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 44} }, - {27, 36, 3, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 43} }, - {28, 39, 3, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 50} }, - {29, 38, 3, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 49} }, - {30, 41, 3, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 52} }, - {31, 40, 3, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 51} }, - {32, 43, 4, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 54} }, - {33, 42, 4, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 53} }, - {34, 45, 4, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 56} }, - {35, 44, 4, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 55} }, - {36, 47, 4, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 66} }, - {37, 46, 4, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 65} }, - {38, 49, 4, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 68} }, - {39, 48, 4, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 67} }, - {40, 51, 5, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 70} }, - {41, 50, 5, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 69} }, - {42, 53, 5, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 72} }, - {43, 52, 5, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 71} }, - {44, 55, 5, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 82} }, - {45, 54, 5, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 81} }, - {46, 57, 5, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 84} }, - {47, 56, 5, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 83} }, - {48, 59, 6, 1, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 85, 86, 87, 88} }, - {49, 58, 6, 0, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 97, 98, 99,100} }, - {50, 61, 6, 3, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {105,106,107,108} }, - {51, 60, 6, 2, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {101,102,103,104} }, - {52, 63, 6, 5, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {117,118,119,120} }, - {53, 62, 6, 4, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {109,110,111,112} }, -}; -#endif - - -/* ========================================== - * Cypress Layout configuration (C1 version) - * ========================================== - */ -#ifdef SWPS_CYPRESS_BAI -unsigned cypress_b_gpio_rest_mux = MUX_RST_GPIO_FORCE_HEDERA; - -struct inv_ioexp_layout_s cypress_b_ioexp_layout[] = { - /* IOEXP_ID / IOEXP_TYPE / { Chan_ID, Chip_addr, Read_offset, Write_offset, config_offset, data_default, conf_default } */ - {0, IOEXP_TYPE_CYPRESS_NABC, { {2, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {2, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {2, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {1, IOEXP_TYPE_CYPRESS_NABC, { {3, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {3, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {3, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {2, IOEXP_TYPE_CYPRESS_NABC, { {4, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {4, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {4, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {3, IOEXP_TYPE_CYPRESS_NABC, { {5, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {5, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {5, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {4, IOEXP_TYPE_CYPRESS_NABC, { {6, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {6, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {6, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {5, IOEXP_TYPE_CYPRESS_NABC, { {7, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {7, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {7, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {6, IOEXP_TYPE_CYPRESS_7ABC, { {8, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xc0, 0xc0}, }, /* addr[0] = I/O Expander 7 A */ - {8, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xc0, 0xc0}, {0xff, 0xc0}, }, /* addr[1] = I/O Expander 7 B */ - {8, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 7 C */ - }, -}; - -struct inv_port_layout_s cypress_b_port_layout[] = { - /* Port_ID / Chan_ID / IOEXP_ID / IOEXP_VIRT_OFFSET / TRANSCEIVER_TYPE / CHIP_TYPE / LANE_ID */ - { 1, 11, 0, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 2} }, - { 2, 10, 0, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 1} }, - { 3, 13, 0, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 4} }, - { 4, 12, 0, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 3} }, - { 5, 15, 0, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 6} }, - { 6, 14, 0, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 5} }, - { 7, 17, 0, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 8} }, - { 8, 16, 0, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 7} }, - { 9, 19, 1, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 10} }, - {10, 18, 1, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 9} }, - {11, 21, 1, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 12} }, - {12, 20, 1, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 11} }, - {13, 23, 1, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 22} }, - {14, 22, 1, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 21} }, - {15, 25, 1, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 24} }, - {16, 24, 1, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 23} }, - {17, 27, 2, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 34} }, - {18, 26, 2, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 33} }, - {19, 29, 2, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 36} }, - {20, 28, 2, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 35} }, - {21, 31, 2, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 38} }, - {22, 30, 2, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 37} }, - {23, 33, 2, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 40} }, - {24, 32, 2, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 39} }, - {25, 35, 3, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 42} }, - {26, 34, 3, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 41} }, - {27, 37, 3, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 44} }, - {28, 36, 3, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 43} }, - {29, 39, 3, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 50} }, - {30, 38, 3, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 49} }, - {31, 41, 3, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 52} }, - {32, 40, 3, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 51} }, - {33, 43, 4, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 54} }, - {34, 42, 4, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 53} }, - {35, 45, 4, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 56} }, - {36, 44, 4, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 55} }, - {37, 47, 4, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 66} }, - {38, 46, 4, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 65} }, - {39, 49, 4, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 68} }, - {40, 48, 4, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 67} }, - {41, 51, 5, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 70} }, - {42, 50, 5, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 69} }, - {43, 53, 5, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 72} }, - {44, 52, 5, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 71} }, - {45, 55, 5, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 82} }, - {46, 54, 5, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 81} }, - {47, 57, 5, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 84} }, - {48, 56, 5, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 83} }, - {49, 59, 6, 1, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 85, 86, 87, 88} }, - {50, 58, 6, 0, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 97, 98, 99,100} }, - {51, 61, 6, 3, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {105,106,107,108} }, - {52, 60, 6, 2, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {101,102,103,104} }, - {53, 63, 6, 5, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {117,118,119,120} }, - {54, 62, 6, 4, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {109,110,111,112} }, -}; -#endif - - -/* ========================================== - * Redwood_fsl Layout configuration - * ========================================== - */ -#ifdef SWPS_REDWOOD_FSL -unsigned redwood_fsl_gpio_rest_mux = MUX_RST_GPIO_48_PAC9548; - -struct inv_ioexp_layout_s redwood_fsl_ioexp_layout[] = { - /* IOEXP_ID / IOEXP_TYPE / { Chan_ID, Chip_addr, Read_offset, Write_offset, config_offset, data_default, conf_default } */ - {0, IOEXP_TYPE_REDWOOD_P01P08, { {4, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[0] = I/O Expander 1-4 A */ - {4, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[1] = I/O Expander 1-4 B */ - {0, 0x25, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 5 B */ - }, - {1, IOEXP_TYPE_REDWOOD_P09P16, { {5, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[0] = I/O Expander 1-4 A */ - {5, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[1] = I/O Expander 1-4 B */ - {0, 0x25, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 5 B */ - }, - {2, IOEXP_TYPE_REDWOOD_P01P08, { {2, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[0] = I/O Expander 1-4 A */ - {2, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[1] = I/O Expander 1-4 B */ - {0, 0x24, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 5 B */ - }, - {3, IOEXP_TYPE_REDWOOD_P09P16, { {3, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[0] = I/O Expander 1-4 A */ - {3, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[1] = I/O Expander 1-4 B */ - {0, 0x24, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 5 B */ - }, -}; - - -struct inv_port_layout_s redwood_fsl_port_layout[] = { - /* Port_ID / Chan_ID / IOEXP_ID / IOEXP_VIRT_OFFSET / TRANSCEIVER_TYPE / CHIP_TYPE / LANE_ID */ - { 0, 22, 0, 0, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 1, 2, 3, 4} }, - { 1, 23, 0, 1, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 5, 6, 7, 8} }, - { 2, 24, 0, 2, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 9, 10, 11, 12} }, - { 3, 25, 0, 3, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 13, 14, 15, 16} }, - { 4, 26, 0, 4, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 17, 18, 19, 20} }, - { 5, 27, 0, 5, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 21, 22, 23, 24} }, - { 6, 28, 0, 6, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 25, 26, 27, 28} }, - { 7, 29, 0, 7, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 29, 30, 31, 32} }, - { 8, 30, 1, 0, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 33, 34, 35, 36} }, - { 9, 31, 1, 1, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 37, 38, 39, 40} }, - {10, 32, 1, 2, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 41, 42, 43, 44} }, - {11, 33, 1, 3, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 45, 46, 47, 48} }, - {12, 34, 1, 4, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 49, 50, 51, 52} }, - {13, 35, 1, 5, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 53, 54, 55, 56} }, - {14, 36, 1, 6, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 57, 58, 59, 60} }, - {15, 37, 1, 7, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 61, 62, 63, 64} }, - {16, 6, 2, 0, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 65, 66, 67, 68} }, - {17, 7, 2, 1, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 69, 70, 71, 72} }, - {18, 8, 2, 2, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 73, 74, 75, 76} }, - {19, 9, 2, 3, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 77, 78, 79, 80} }, - {20, 10, 2, 4, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 81, 82, 83, 84} }, - {21, 11, 2, 5, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 85, 86, 87, 88} }, - {22, 12, 2, 6, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 89, 90, 91, 92} }, - {23, 13, 2, 7, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 93, 94, 95, 96} }, - {24, 14, 3, 0, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 97, 98, 99,100} }, - {25, 15, 3, 1, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {101,102,103,104} }, - {26, 16, 3, 2, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {105,106,107,108} }, - {27, 17, 3, 3, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {109,110,111,112} }, - {28, 18, 3, 4, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {113,114,115,116} }, - {29, 19, 3, 5, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {117,118,119,120} }, - {30, 20, 3, 6, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {121,122,123,124} }, - {31, 21, 3, 7, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {125,126,127,128} }, -}; -#endif - - -/* ========================================== - * Tahoe Layout configuration - * ========================================== - */ -#ifdef SWPS_TAHOE -unsigned tahoe_gpio_rest_mux = MUX_RST_GPIO_249_PCA9548; - -struct inv_ioexp_layout_s tahoe_ioexp_layout[] = { - /* IOEXP_ID / IOEXP_TYPE / { Chan_ID, Chip_addr, Read_offset, Write_offset, config_offset, data_default, conf_default } */ - {0, IOEXP_TYPE_TAHOE_6ABC, { {7, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xce, 0xb9}, {0x18, 0xe3}, }, /* addr[0] = I/O Expander 6 A */ - {7, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xce, 0xb9}, {0x18, 0xe3}, }, /* addr[1] = I/O Expander 6 B */ - {7, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xce, 0xb9}, {0x18, 0xe3}, }, }, /* addr[2] = I/O Expander 6 C */ - }, - {1, IOEXP_TYPE_TAHOE_5A, { {6, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xce, 0xb9}, {0x18, 0xe3}, }, }, /* addr[0] = I/O Expander 5 A */ - }, -}; - - -struct inv_port_layout_s tahoe_port_layout[] = { - /* Port_ID / Chan_ID / IOEXP_ID / IOEXP_VIRT_OFFSET / TRANSCEIVER_TYPE / CHIP_TYPE / LANE_ID */ - { 0, 12, 1, 2, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 65, 66, 67, 68} }, - { 1, 11, 1, 1, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 53, 54, 55, 56} }, - { 2, 22, 0, 5, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 69, 70, 71, 72} }, - { 3, 21, 0, 4, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 81, 82, 83, 84} }, - { 4, 24, 0, 7, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 97, 98, 99, 100} }, - { 5, 23, 0, 6, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 85, 86, 87, 88} }, - { 6, 18, 0, 1, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {101, 102, 103, 104} }, - { 7, 17, 0, 0, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {105, 106, 107, 108} }, - { 8, 20, 0, 3, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {113, 114, 115, 116} }, - { 9, 19, 0, 2, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {109, 110, 111, 112} }, -}; -#endif - - -/* ========================================== - * Sequoia Layout configuration - * ========================================== - */ -#ifdef SWPS_SEQUOIA -unsigned sequoia_gpio_rest_mux = MUX_RST_GPIO_69_PAC9548; - -struct inv_ioexp_layout_s sequoia_ioexp_layout[] = { - /* IOEXP_ID / IOEXP_TYPE / { Chan_ID, Chip_addr, Read_offset, Write_offset, config_offset, data_default, conf_default } */ - {0, IOEXP_TYPE_SEQUOIA_NABC, { {1, 0x20, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0x00, 0x00}, }, /* addr[0] = I/O Expander 0 A */ - {1, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0xff}, }, /* addr[1] = I/O Expander 0 B */ - {1, 0x22, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 0 C */ - }, - {1, IOEXP_TYPE_SEQUOIA_NABC, { {2, 0x20, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0x00, 0x00}, }, /* addr[0] = I/O Expander 1 A */ - {2, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0xff}, }, /* addr[1] = I/O Expander 1 B */ - {2, 0x22, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 1 C */ - }, - {2, IOEXP_TYPE_SEQUOIA_NABC, { {3, 0x20, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0x00, 0x00}, }, /* addr[0] = I/O Expander 2 A */ - {3, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0xff}, }, /* addr[1] = I/O Expander 2 B */ - {3, 0x22, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 2 C */ - }, - {3, IOEXP_TYPE_SEQUOIA_NABC, { {4, 0x20, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0x00, 0x00}, }, /* addr[0] = I/O Expander 3 A */ - {4, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0xff}, }, /* addr[1] = I/O Expander 3 B */ - {4, 0x22, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 3 C */ - }, - {4, IOEXP_TYPE_SEQUOIA_NABC, { {5, 0x20, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0x00, 0x00}, }, /* addr[0] = I/O Expander 4 A */ - {5, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0xff}, }, /* addr[1] = I/O Expander 4 B */ - {5, 0x22, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 4 C */ - }, - {5, IOEXP_TYPE_SEQUOIA_NABC, { {6, 0x20, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0x00, 0x00}, }, /* addr[0] = I/O Expander 5 A */ - {6, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0xff}, }, /* addr[1] = I/O Expander 5 B */ - {6, 0x22, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 5 C */ - }, - {6, IOEXP_TYPE_SEQUOIA_NABC, { {7, 0x20, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0x00, 0x00}, }, /* addr[0] = I/O Expander 6 A */ - {7, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0xff}, }, /* addr[1] = I/O Expander 6 B */ - {7, 0x22, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 6 C */ - }, - {7, IOEXP_TYPE_SEQUOIA_NABC, { {8, 0x20, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0x00, 0x00}, }, /* addr[0] = I/O Expander 7 A */ - {8, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0xff}, }, /* addr[1] = I/O Expander 7 B */ - {8, 0x22, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 7 C */ - }, -}; - - -struct inv_port_layout_s sequoia_port_layout[] = { - /* Port_ID / Chan_ID / IOEXP_ID / IOEXP_VIRT_OFFSET / TRANSCEIVER_TYPE / CHIP_TYPE / LANE_ID */ - { 0, 9, 0, 0, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 9, 10, 11, 12} }, - { 1, 10, 0, 1, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 1, 2, 3, 4} }, - { 2, 11, 0, 2, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 25, 26, 27, 28} }, - { 3, 12, 0, 3, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 17, 18, 19, 20} }, - { 4, 13, 0, 4, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 41, 42, 43, 44} }, - { 5, 14, 0, 5, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 33, 34, 35, 36} }, - { 6, 15, 0, 6, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 57, 58, 59, 60} }, - { 7, 16, 0, 7, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 49, 50, 51, 52} }, - { 8, 17, 1, 0, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 73, 74, 75, 76} }, - { 9, 18, 1, 1, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 65, 66, 67, 68} }, - {10, 19, 1, 2, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 89, 90, 91, 92} }, - {11, 20, 1, 3, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 81, 82, 83, 84} }, - {12, 21, 1, 4, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {105, 106, 107, 108} }, - {13, 22, 1, 5, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 97, 98, 99, 100} }, - {14, 23, 1, 6, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {121, 122, 123, 124} }, - {15, 24, 1, 7, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {113, 114, 115, 116} }, - {16, 25, 2, 0, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {137, 138, 139, 140} }, - {17, 26, 2, 1, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {129, 130, 131, 132} }, - {18, 27, 2, 2, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {153, 154, 155, 156} }, - {19, 28, 2, 3, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {145, 146, 147, 148} }, - {20, 29, 2, 4, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {169, 170, 171, 172} }, - {21, 30, 2, 5, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {161, 162, 163, 164} }, - {22, 31, 2, 6, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {185, 186, 187, 188} }, - {23, 32, 2, 7, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {177, 178, 179, 180} }, - {24, 33, 3, 0, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {201, 202, 203, 204} }, - {25, 34, 3, 1, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {193, 194, 195, 196} }, - {26, 35, 3, 2, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {217, 218, 219, 220} }, - {27, 36, 3, 3, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {209, 210, 211, 212} }, - {28, 37, 3, 4, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {233, 234, 235, 236} }, - {29, 38, 3, 5, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {225, 226, 227, 228} }, - {30, 39, 3, 6, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {249, 250, 251, 252} }, - {31, 40, 3, 7, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {241, 242, 243, 244} }, - {32, 44, 4, 3, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 13, 14, 15, 16} }, - {33, 43, 4, 2, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 5, 6, 7, 8} }, - {34, 42, 4, 1, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 29, 30, 31, 32} }, - {35, 41, 4, 0, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 21, 22, 23, 24} }, - {36, 48, 4, 7, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 45, 46, 47, 48} }, - {37, 47, 4, 6, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 37, 38, 39, 40} }, - {38, 46, 4, 5, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 61, 62, 63, 64} }, - {39, 45, 4, 4, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 53, 54, 55, 56} }, - {40, 52, 5, 3, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 77, 78, 79, 80} }, - {41, 51, 5, 2, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 69, 70, 71, 72} }, - {42, 50, 5, 1, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 93, 94, 95, 96} }, - {43, 49, 5, 0, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 85, 86, 87, 88} }, - {44, 56, 5, 7, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {109, 110, 111, 112} }, - {45, 55, 5, 6, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {101, 102, 103, 104} }, - {46, 54, 5, 5, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {125, 126, 127, 128} }, - {47, 53, 5, 4, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {117, 118, 119, 120} }, - {48, 60, 6, 3, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {141, 142, 143, 144} }, - {49, 59, 6, 2, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {133, 134, 135, 136} }, - {50, 58, 6, 1, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {157, 158, 159, 160} }, - {51, 57, 6, 0, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {149, 150, 151, 152} }, - {52, 64, 6, 7, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {173, 174, 175, 176} }, - {53, 63, 6, 6, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {165, 166, 167, 168} }, - {54, 62, 6, 5, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {189, 190, 191, 192} }, - {55, 61, 6, 4, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {181, 182, 183, 184} }, - {56, 68, 7, 3, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {205, 206, 207, 208} }, - {57, 67, 7, 2, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {197, 198, 199, 200} }, - {58, 66, 7, 1, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {221, 222, 223, 224} }, - {59, 65, 7, 0, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {213, 214, 215, 216} }, - {60, 72, 7, 7, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {237, 238, 239, 240} }, - {61, 71, 7, 6, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {229, 230, 231, 232} }, - {62, 70, 7, 5, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {253, 254, 255, 256} }, - {63, 69, 7, 4, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {245, 246, 247, 248} }, -}; -#endif - - -/* ========================================== - * Lavender Layout configuration - * ========================================== - */ -#if (PLATFORM_SETTINGS == PLATFORM_TYPE_LAVENDER_GA) -unsigned lavender_gpio_rest_mux = MUX_RST_GPIO_505_PCA9548; -#elif (PLATFORM_SETTINGS == PLATFORM_TYPE_LAVENDER_ONL) -unsigned lavender_gpio_rest_mux = MUX_RST_GPIO_69_PAC9548; -#endif - -#ifdef SWPS_LAVENDER -struct inv_ioexp_layout_s lavender_ioexp_layout[] = { - /* IOEXP_ID / IOEXP_TYPE / { Chan_ID, Chip_addr, Read_offset, Write_offset, config_offset, data_default, conf_default } */ - {0, IOEXP_TYPE_SEQUOIA_NABC, { { 1, 0x20, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0x00, 0x00}, }, /* addr[0] = I/O Expander 0 A */ - { 1, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0xff}, }, /* addr[1] = I/O Expander 0 B */ - { 1, 0x22, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 0 C */ - }, - {1, IOEXP_TYPE_SEQUOIA_NABC, { { 2, 0x20, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0x00, 0x00}, }, /* addr[0] = I/O Expander 1 A */ - { 2, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0xff}, }, /* addr[1] = I/O Expander 1 B */ - { 2, 0x22, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 1 C */ - }, - {2, IOEXP_TYPE_SEQUOIA_NABC, { { 3, 0x20, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0x00, 0x00}, }, /* addr[0] = I/O Expander 2 A */ - { 3, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0xff}, }, /* addr[1] = I/O Expander 2 B */ - { 3, 0x22, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 2 C */ - }, - {3, IOEXP_TYPE_SEQUOIA_NABC, { { 4, 0x20, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0x00, 0x00}, }, /* addr[0] = I/O Expander 3 A */ - { 4, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0xff}, }, /* addr[1] = I/O Expander 3 B */ - { 4, 0x22, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 3 C */ - }, - {4, IOEXP_TYPE_SEQUOIA_NABC, { { 9, 0x20, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0x00, 0x00}, }, /* addr[0] = I/O Expander 4 A */ - { 9, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0xff}, }, /* addr[1] = I/O Expander 4 B */ - { 9, 0x22, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 4 C */ - }, - {5, IOEXP_TYPE_SEQUOIA_NABC, { {10, 0x20, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0x00, 0x00}, }, /* addr[0] = I/O Expander 5 A */ - {10, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0xff}, }, /* addr[1] = I/O Expander 5 B */ - {10, 0x22, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 5 C */ - }, - {6, IOEXP_TYPE_SEQUOIA_NABC, { {11, 0x20, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0x00, 0x00}, }, /* addr[0] = I/O Expander 6 A */ - {11, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0xff}, }, /* addr[1] = I/O Expander 6 B */ - {11, 0x22, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 6 C */ - }, - {7, IOEXP_TYPE_SEQUOIA_NABC, { {12, 0x20, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0x00, 0x00}, }, /* addr[0] = I/O Expander 7 A */ - {12, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0xff}, }, /* addr[1] = I/O Expander 7 B */ - {12, 0x22, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 7 C */ - }, - {8, IOEXP_TYPE_LAVENDER_P65, { { 5, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xF6, 0xff}, {0xF8, 0xff}, }, }, /* addr[0] = I/O Expander CPU */ - }, -}; - - -struct inv_port_layout_s lavender_port_layout[] = { - /* Port_ID / Chan_ID / IOEXP_ID / IOEXP_VIRT_OFFSET / TRANSCEIVER_TYPE / CHIP_TYPE / LANE_ID */ - { 0, 17, 0, 0, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {188, 189, 190, 191} }, - { 1, 18, 0, 1, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {184, 185, 186, 187} }, - { 2, 19, 0, 2, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {180, 181, 182, 183} }, - { 3, 20, 0, 3, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {176, 177, 178, 179} }, - { 4, 21, 0, 4, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {172, 173, 174, 175} }, - { 5, 22, 0, 5, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {168, 169, 170, 171} }, - { 6, 23, 0, 6, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {164, 165, 166, 167} }, - { 7, 24, 0, 7, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {160, 161, 162, 163} }, - { 8, 25, 1, 0, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {156, 157, 158, 159} }, - { 9, 26, 1, 1, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {152, 153, 154, 155} }, - {10, 27, 1, 2, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {148, 149, 150, 151} }, - {11, 28, 1, 3, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {144, 145, 146, 147} }, - {12, 29, 1, 4, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {140, 141, 142, 143} }, - {13, 30, 1, 5, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {136, 137, 138, 139} }, - {14, 31, 1, 6, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {132, 133, 134, 135} }, - {15, 32, 1, 7, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {128, 129, 130, 131} }, - {16, 33, 2, 0, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, { 0, 1, 2, 3} }, - {17, 34, 2, 1, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, { 4, 5, 6, 7} }, - {18, 35, 2, 2, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, { 8, 9, 10, 11} }, - {19, 36, 2, 3, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, { 12, 13, 14, 15} }, - {20, 37, 2, 4, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, { 16, 17, 18, 19} }, - {21, 38, 2, 5, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, { 20, 21, 22, 23} }, - {22, 39, 2, 6, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, { 24, 25, 26, 27} }, - {23, 40, 2, 7, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, { 28, 29, 30, 31} }, - {24, 41, 3, 0, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, { 32, 33, 34, 35} }, - {25, 42, 3, 1, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, { 36, 37, 38, 39} }, - {26, 43, 3, 2, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, { 40, 41, 42, 43} }, - {27, 44, 3, 3, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, { 44, 45, 46, 47} }, - {28, 45, 3, 4, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, { 48, 49, 50, 51} }, - {29, 46, 3, 5, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, { 52, 53, 54, 55} }, - {30, 47, 3, 6, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, { 56, 57, 58, 59} }, - {31, 48, 3, 7, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, { 60, 61, 62, 63} }, - {32, 49, 4, 0, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {256, 257, 258, 259} }, - {33, 50, 4, 1, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {260, 261, 262, 263} }, - {34, 51, 4, 2, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {264, 265, 266, 267} }, - {35, 52, 4, 3, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {268, 269, 270, 271} }, - {36, 53, 4, 4, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {272, 273, 274, 275} }, - {37, 54, 4, 5, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {276, 277, 278, 279} }, - {38, 55, 4, 6, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {280, 281, 282, 283} }, - {39, 56, 4, 7, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {284, 285, 286, 287} }, - {40, 57, 5, 0, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {288, 289, 290, 291} }, - {41, 58, 5, 1, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {292, 293, 294, 295} }, - {42, 59, 5, 2, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {296, 297, 298, 299} }, - {43, 60, 5, 3, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {300, 301, 302, 303} }, - {44, 61, 5, 4, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {304, 305, 306, 307} }, - {45, 62, 5, 5, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {308, 309, 310, 311} }, - {46, 63, 5, 6, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {312, 313, 314, 315} }, - {47, 64, 5, 7, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {316, 317, 318, 319} }, - {48, 65, 6, 0, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {444, 445, 446, 447} }, - {49, 66, 6, 1, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {440, 441, 442, 443} }, - {50, 67, 6, 2, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {436, 437, 438, 439} }, - {51, 68, 6, 3, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {432, 433, 434, 435} }, - {52, 69, 6, 4, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {428, 429, 430, 431} }, - {53, 70, 6, 5, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {424, 425, 426, 427} }, - {54, 71, 6, 6, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {420, 421, 422, 423} }, - {55, 72, 6, 7, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {416, 417, 418, 419} }, - {56, 73, 7, 0, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {412, 413, 414, 415} }, - {57, 74, 7, 1, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {408, 409, 410, 411} }, - {58, 75, 7, 2, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {404, 405, 406, 407} }, - {59, 76, 7, 3, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {400, 401, 402, 403} }, - {60, 77, 7, 4, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {396, 397, 398, 399} }, - {61, 78, 7, 5, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {392, 393, 394, 395} }, - {62, 79, 7, 6, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {388, 389, 390, 391} }, - {63, 80, 7, 7, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {384, 385, 386, 387} }, - {64, 5, 8, 0, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, { 64, 65, 66, 67} }, -}; -#endif - -/* =========================================================== - * Cottonwood Layout configuration Rangeley (Rangeley CPU board) - * =========================================================== - */ -#ifdef SWPS_COTTONWOOD_RANGELEY -unsigned cottonwood_rangeley_gpio_rest_mux = MUX_RST_GPIO_500_PAC9548; - -struct inv_ioexp_layout_s cottonwood_rangeley_ioexp_layout[] = { - /* IOEXP_ID / IOEXP_TYPE / { Chan_ID, Chip_addr, Read_offset, Write_offset, config_offset, data_default, conf_default } */ - {0, CPLD_TYPE_COTTONWOOD,{ {1, 0x55, {22, 23, 24, 25}, {22, 23, 24, 25}, {-1, -1, -1, -1}, {0xee, 0xee, 0x99, 0x99}, {0x00, 0x00, 0x00, 0x00}, }, - }, - }, -}; - - -struct inv_port_layout_s cottonwood_rangeley_port_layout[] = { - /* Port_ID / Chan_ID / IOEXP_ID / IOEXP_VIRT_OFFSET / TRANSCEIVER_TYPE / CHI_TYPE / LANE_ID */ - { 0, 2, 0, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 75} }, - { 1, 3, 0, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 77} }, - { 2, 4, 0, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 79} }, - { 3, 5, 0, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 81} }, -}; -#endif - -/* =========================================================== - * Maple Layout configuration - * =========================================================== - */ -#ifdef SWPS_MAPLE -unsigned maple_gpio_rest_mux = MUX_RST_GPIO_505_PCA9548; - -struct inv_ioexp_layout_s maple_ioexp_layout[] = { - /* IOEXP_ID / IOEXP_TYPE / { Chan_ID, Chip_addr, Read_offset, Write_offset, config_offset, data_default, conf_default } */ - {0, IOEXP_TYPE_MAPLE_0ABC, { {2, 0x20, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0x00, 0x00}, }, /* addr[0] = I/O Expander 0 A */ - {2, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0xff}, }, /* addr[1] = I/O Expander 0 B */ - {2, 0x22, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 0 C */ - }, - {1, IOEXP_TYPE_MAPLE_NABC, { {3, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {3, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {3, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {2, IOEXP_TYPE_MAPLE_NABC, { {4, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {4, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {4, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {3, IOEXP_TYPE_MAPLE_NABC, { {5, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {5, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {5, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {4, IOEXP_TYPE_MAPLE_NABC, { {6, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {6, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {6, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {5, IOEXP_TYPE_MAPLE_NABC, { {7, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {7, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {7, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {6, IOEXP_TYPE_MAPLE_NABC, { {8, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {8, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {8, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, -}; - -struct inv_port_layout_s maple_port_layout[] = { - /* Port_ID / Chan_ID / IOEXP_ID / IOEXP_VIRT_OFFSET / TRANSCEIVER_TYPE / CHIP_TYPE / LANE_ID */ - { 0, 18, 1, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 1} }, - { 1, 19, 1, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 2} }, - { 2, 20, 1, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 3} }, - { 3, 21, 1, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 4} }, - { 4, 22, 1, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 5} }, - { 5, 23, 1, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 6} }, - { 6, 24, 1, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 7} }, - { 7, 25, 1, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 8} }, - { 8, 26, 2, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 13} }, - { 9, 27, 2, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 14} }, - {10, 28, 2, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 15} }, - {11, 29, 2, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 16} }, - {12, 30, 2, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 21} }, - {13, 31, 2, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 22} }, - {14, 32, 2, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 23} }, - {15, 33, 2, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 24} }, - {16, 34, 3, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 29} }, - {17, 35, 3, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 30} }, - {18, 36, 3, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 31} }, - {19, 37, 3, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 32} }, - {20, 38, 3, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 33} }, - {21, 39, 3, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 34} }, - {22, 40, 3, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 35} }, - {23, 41, 3, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 36} }, - {24, 42, 4, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 41} }, - {25, 43, 4, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 42} }, - {26, 44, 4, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 43} }, - {27, 45, 4, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 44} }, - {28, 46, 4, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 49} }, - {29, 47, 4, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 50} }, - {30, 48, 4, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 51} }, - {31, 49, 4, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 52} }, - {32, 50, 5, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 57} }, - {33, 51, 5, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 58} }, - {34, 52, 5, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 59} }, - {35, 53, 5, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 60} }, - {36, 54, 5, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 61} }, - {37, 55, 5, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 62} }, - {38, 56, 5, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 63} }, - {39, 57, 5, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 64} }, - {40, 58, 6, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 65} }, - {41, 59, 6, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 66} }, - {42, 60, 6, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 67} }, - {43, 61, 6, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 68} }, - {44, 62, 6, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 69} }, - {45, 63, 6, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 70} }, - {46, 64, 6, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 71} }, - {47, 65, 6, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 72} }, - {48, 10, 0, 0, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_MAPLE, { 77, 78, 79, 80} }, - {49, 11, 0, 1, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_MAPLE, { 85, 86, 87, 88} }, - {50, 12, 0, 2, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_MAPLE, { 93, 94, 95, 96} }, - {51, 13, 0, 3, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_MAPLE, { 97, 98, 99,100} }, - {52, 14, 0, 4, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_MAPLE, {105,106,107,108} }, - {53, 15, 0, 5, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_MAPLE, {113,114,115,116} }, - {54, 16, 0, 6, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_MAPLE, {121,122,123,124} }, - {55, 17, 0, 7, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_MAPLE, {125,126,127,128} }, -}; -#endif - - -/* ========================================== - * Gulmohar Layout configuration - * ========================================== - */ -#ifdef SWPS_GULMOHAR -unsigned gulmohar_gpio_rest_mux = MUX_RST_GPIO_69_PAC9548; - -struct inv_ioexp_layout_s gulmohar_ioexp_layout[] = { - /* IOEXP_ID / IOEXP_TYPE / { Chan_ID, Chip_addr, Read_offset, Write_offset, config_offset, data_default, conf_default } */ - {0, IOEXP_TYPE_GULMOHAR_NABC, { {2, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xf3, 0xf3}, {0xf3, 0xf3}, }, /* addr[0] = I/O Expander N A */ - {2, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xf3, 0xf3}, {0xf3, 0xf3}, }, /* addr[1] = I/O Expander N B */ - {2, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {1, IOEXP_TYPE_GULMOHAR_NABC, { {3, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xf3, 0xf3}, {0xf3, 0xf3}, }, /* addr[0] = I/O Expander N A */ - {3, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xf3, 0xf3}, {0xf3, 0xf3}, }, /* addr[1] = I/O Expander N B */ - {3, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {2, IOEXP_TYPE_GULMOHAR_NABC, { {4, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xf3, 0xf3}, {0xf3, 0xf3}, }, /* addr[0] = I/O Expander N A */ - {4, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xf3, 0xf3}, {0xf3, 0xf3}, }, /* addr[1] = I/O Expander N B */ - {4, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {3, IOEXP_TYPE_GULMOHAR_NABC, { {5, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xf3, 0xf3}, {0xf3, 0xf3}, }, /* addr[0] = I/O Expander N A */ - {5, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xf3, 0xf3}, {0xf3, 0xf3}, }, /* addr[1] = I/O Expander N B */ - {5, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {4, IOEXP_TYPE_GULMOHAR_NABC, { {6, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xf3, 0xf3}, {0xf3, 0xf3}, }, /* addr[0] = I/O Expander N A */ - {6, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xf3, 0xf3}, {0xf3, 0xf3}, }, /* addr[1] = I/O Expander N B */ - {6, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {5, IOEXP_TYPE_GULMOHAR_NABC, { {7, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xf3, 0xf3}, {0xf3, 0xf3}, }, /* addr[0] = I/O Expander N A */ - {7, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xf3, 0xf3}, {0xf3, 0xf3}, }, /* addr[1] = I/O Expander N B */ - {7, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {6, IOEXP_TYPE_GULMOHAR_7ABC, { {8, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xc0, 0xff}, {0xc0, 0xc0}, }, /* addr[0] = I/O Expander 7 A */ - {8, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xc0, 0xff}, }, /* addr[1] = I/O Expander 7 B */ - {8, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xc0, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 7 C */ - }, -}; - - - -struct inv_port_layout_s gulmohar_port_layout[] = { - /* Port_ID / Chan_ID / IOEXP_ID / IOEXP_VIRT_OFFSET / TRANSCEIVER_TYPE / CHIP_TYPE / LANE_ID */ - { 0, 10, 0, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, { 1} }, - { 1, 11, 0, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, { 2} }, - { 2, 12, 0, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, { 3} }, - { 3, 13, 0, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, { 4} }, - { 4, 14, 0, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, { 5} }, - { 5, 15, 0, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, { 6} }, - { 6, 16, 0, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, { 7} }, - { 7, 17, 0, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, { 8} }, - { 8, 18, 1, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, { 9} }, - { 9, 19, 1, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, { 10} }, - {10, 20, 1, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, { 11} }, - {11, 21, 1, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, { 12} }, - {12, 22, 1, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, { 21} }, - {13, 23, 1, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, { 22} }, - {14, 24, 1, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, { 23} }, - {15, 25, 1, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, { 24} }, - {16, 26, 2, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, { 33} }, - {17, 27, 2, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, { 34} }, - {18, 28, 2, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, { 35} }, - {19, 29, 2, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, { 36} }, - {20, 30, 2, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, { 37} }, - {21, 31, 2, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, { 38} }, - {22, 32, 2, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, { 39} }, - {23, 33, 2, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, { 40} }, - {24, 34, 3, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, { 41} }, - {25, 35, 3, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, { 42} }, - {26, 36, 3, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, { 43} }, - {27, 37, 3, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, { 44} }, - {28, 38, 3, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, { 49} }, - {29, 39, 3, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, { 50} }, - {30, 40, 3, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, { 51} }, - {31, 41, 3, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, { 52} }, - {32, 42, 4, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, { 53} }, - {33, 43, 4, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, { 54} }, - {34, 44, 4, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, { 55} }, - {35, 45, 4, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, { 56} }, - {36, 46, 4, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, { 65} }, - {37, 47, 4, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, { 66} }, - {38, 48, 4, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, { 67} }, - {39, 49, 4, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, { 68} }, - {40, 50, 5, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, { 69} }, - {41, 51, 5, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, { 70} }, - {42, 52, 5, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, { 71} }, - {43, 53, 5, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, { 72} }, - {44, 54, 5, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, { 81} }, - {45, 55, 5, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, { 82} }, - {46, 56, 5, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, { 83} }, - {47, 57, 5, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, { 84} }, - {48, 58, 6, 0, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, { 97, 98, 99,100} }, - {49, 59, 6, 1, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, { 85, 86, 87, 88} }, - {50, 60, 6, 2, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {101,102,103,104} }, - {51, 61, 6, 3, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {105,106,107,108} }, - {52, 62, 6, 4, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {109,110,111,112} }, - {53, 63, 6, 5, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {109,110,111,112} }, -}; -#endif - - -#endif /* INV_SWPS_H */ - - - - - - - - diff --git a/packages/platforms/inventec/x86-64/d5254/modules/builds/src/inv_vpd.c b/packages/platforms/inventec/x86-64/d5254/modules/builds/src/inv_vpd.c deleted file mode 100644 index a11ac3309..000000000 --- a/packages/platforms/inventec/x86-64/d5254/modules/builds/src/inv_vpd.c +++ /dev/null @@ -1,333 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "inv_vpd.h" -#include "onie_tlvinfo.h" - -static int vpd_major; -static struct class *vpd_class_p = NULL; -static char cEeprom[SYS_EEPROM_MAX_SIZE]; -static DEFINE_MUTEX(vpd_mutex); - -static int -__swp_match(struct device *dev, - const void *data) -{ - char *name = (char *)data; - if (strcmp(dev_name(dev), name) == 0) - return 1; - return 0; -} - -static -int get_vpd_data(struct i2c_client *pi2c_client, int i_offset, char *c_buf) -{ - int iRet; - - read_eeprom( pi2c_client, cEeprom); - iRet = tlvinfo_decode_tlv(cEeprom, i_offset,c_buf); - return iRet; -} - -static -int write_vpd_data(struct i2c_client *pi2c_client, int i_offset, char *c_buf) -{ - int iErr = 0; - - if (read_eeprom(pi2c_client, cEeprom)) { - printk(KERN_ERR "write vpd data eror at %d-%s\n", __LINE__, __FUNCTION__); - return -1; - } - - if (tlvinfo_delete_tlv(cEeprom, i_offset) == TRUE) { - } - if (c_buf) { - if(!tlvinfo_add_tlv(cEeprom, i_offset , c_buf)) { - printk(KERN_ERR "write vpd data eror at %d-%s\n", __LINE__, __FUNCTION__); - iErr = -1; - } else { - iErr = prog_eeprom(pi2c_client,cEeprom); - } - } - return iErr; -} - -static struct device * -get_swpdev_by_name(char *name){ - struct device *dev = class_find_device(vpd_class_p, - NULL, - name, - __swp_match); - return dev; -} - -static ssize_t -store_attr_vpd(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - struct i2c_client *pi2c_client = dev_get_drvdata(dev_p); - struct vpd_device_attribute *attr = to_vpd_dev_attr(attr_p); - int iOffset = attr->index; - int iErr , iLen; - char *pChar; - - if (!pi2c_client){ - return -ENODEV; - } - mutex_lock(&vpd_mutex); - - //-strip 0x0a in the last byte. - for (iLen = 0, pChar = buf_p; - iLen < 255 && *pChar != 0; - iLen++, pChar++) ; - if (iLen !=0 && *pChar == 0 && *(pChar-1) == 0x0a) - *(pChar - 1) = 0; - //- - - iErr = write_vpd_data( pi2c_client, iOffset, buf_p); - - mutex_unlock(&vpd_mutex); - return count; -} - -static ssize_t -show_attr_vpd(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct i2c_client *pi2c_client = dev_get_drvdata(dev_p); - struct vpd_device_attribute *attr = to_vpd_dev_attr(attr_p); - int iOffset = attr->index; - int iErr , iLen; - - if (!pi2c_client){ - return -ENODEV; - } - mutex_lock(&vpd_mutex); - iErr = get_vpd_data( pi2c_client, iOffset, buf_p); - mutex_unlock(&vpd_mutex); - - if( iErr <= 0 ) - iLen = 0; - else - iLen = snprintf(buf_p, TLV_DECODE_VALUE_MAX_LEN, "%s\n", buf_p); - - return iLen; -} - -/* ================= Vpd attribute ======================== - */ -static VPD_DEVICE_ATTR(product_name ,S_IWUSR|S_IRUGO, show_attr_vpd, store_attr_vpd, TLV_CODE_PRODUCT_NAME ); -static VPD_DEVICE_ATTR(pn ,S_IWUSR|S_IRUGO, show_attr_vpd, store_attr_vpd, TLV_CODE_PART_NUMBER ); -static VPD_DEVICE_ATTR(sn ,S_IWUSR|S_IRUGO, show_attr_vpd, store_attr_vpd, TLV_CODE_SERIAL_NUMBER ); -static VPD_DEVICE_ATTR(base_mac_addr,S_IWUSR|S_IRUGO, show_attr_vpd, store_attr_vpd, TLV_CODE_MAC_BASE ); -static VPD_DEVICE_ATTR(man_date ,S_IWUSR|S_IRUGO, show_attr_vpd, store_attr_vpd, TLV_CODE_MANUF_DATE ); -static VPD_DEVICE_ATTR(dev_ver ,S_IWUSR|S_IRUGO, show_attr_vpd, store_attr_vpd, TLV_CODE_DEVICE_VERSION ); -static VPD_DEVICE_ATTR(label_rev ,S_IWUSR|S_IRUGO, show_attr_vpd, store_attr_vpd, TLV_CODE_LABEL_REVISION ); -static VPD_DEVICE_ATTR(plat_name ,S_IWUSR|S_IRUGO, show_attr_vpd, store_attr_vpd, TLV_CODE_PLATFORM_NAME ); -static VPD_DEVICE_ATTR(ldr_ver ,S_IWUSR|S_IRUGO, show_attr_vpd, store_attr_vpd, TLV_CODE_ONIE_VERSION ); -static VPD_DEVICE_ATTR(mac_addr ,S_IWUSR|S_IRUGO, show_attr_vpd, store_attr_vpd, TLV_CODE_MAC_SIZE ); -static VPD_DEVICE_ATTR(manufacturer ,S_IWUSR|S_IRUGO, show_attr_vpd, store_attr_vpd, TLV_CODE_MANUF_NAME ); -static VPD_DEVICE_ATTR(country_code ,S_IWUSR|S_IRUGO, show_attr_vpd, store_attr_vpd, TLV_CODE_MANUF_COUNTRY ); -static VPD_DEVICE_ATTR(vendor_name ,S_IWUSR|S_IRUGO, show_attr_vpd, store_attr_vpd, TLV_CODE_VENDOR_NAME ); -static VPD_DEVICE_ATTR(diag_ver ,S_IWUSR|S_IRUGO, show_attr_vpd, store_attr_vpd, TLV_CODE_DIAG_VERSION ); -static VPD_DEVICE_ATTR(service_tag ,S_IWUSR|S_IRUGO, show_attr_vpd, store_attr_vpd, TLV_CODE_SERVICE_TAG ); -static VPD_DEVICE_ATTR(vendor_ext ,S_IWUSR|S_IRUGO, show_attr_vpd, store_attr_vpd, TLV_CODE_VENDOR_EXT ); -static VPD_DEVICE_ATTR(crc32 ,S_IRUGO, show_attr_vpd, NULL, TLV_CODE_CRC_32 ); - -static void -clean_vpd_common(void) -{ - dev_t dev_num; - struct device *device_p; - - device_p = get_swpdev_by_name(VPD_DEVICE); - if (device_p){ - dev_num = MKDEV(vpd_major, 1); - device_unregister(device_p); - device_destroy(vpd_class_p, dev_num); - } - VPD_DEBUG("%s: done.\n", __func__); -} - - -static struct register_attr VpdRegAttr[VPD_ENTRY_SIZE ] ={ - { &vpd_dev_attr_product_name.dev_attr, "vpd_dev_attr_product_name"}, - { &vpd_dev_attr_pn.dev_attr, "vpd_dev_attr_pn"}, - { &vpd_dev_attr_sn.dev_attr, "vpd_dev_attr_sn"}, - { &vpd_dev_attr_base_mac_addr.dev_attr, "vpd_dev_attr_base_mac_addr"}, - { &vpd_dev_attr_man_date.dev_attr, "vpd_dev_attr_man_date"}, - { &vpd_dev_attr_dev_ver.dev_attr, "vpd_dev_attr_dev_ver"}, - { &vpd_dev_attr_label_rev.dev_attr, "vpd_dev_attr_label_rev"}, - { &vpd_dev_attr_plat_name.dev_attr, "vpd_dev_attr_plat_name"}, - { &vpd_dev_attr_ldr_ver.dev_attr, "vpd_dev_attr_ldr_ver"}, - { &vpd_dev_attr_mac_addr.dev_attr, "vpd_dev_attr_mac_addr"}, - { &vpd_dev_attr_manufacturer.dev_attr, "vpd_dev_attr_manufacturer"}, - { &vpd_dev_attr_country_code.dev_attr, "vpd_dev_attr_country_code"}, - { &vpd_dev_attr_vendor_name.dev_attr, "vpd_dev_attr_vendor_name"}, - { &vpd_dev_attr_diag_ver.dev_attr, "vpd_dev_attr_diag_ver"}, - { &vpd_dev_attr_service_tag.dev_attr, "vpd_dev_attr_service_tag"}, - { &vpd_dev_attr_vendor_ext.dev_attr, "vpd_dev_attr_vendor_ext"}, - { &vpd_dev_attr_crc32.dev_attr, "vpd_dev_attr_crc32"}, -}; - -static int -register_vpd_attr(struct device *device_p){ - - char *err_attr = NULL; - int i; - - for( i = 0 ; i adapter = adap; - vpd_i2c_client->addr = VPD_I2C_ADDR; - - device_p = device_create(vpd_class_p, /* struct class *cls */ - NULL, /* struct device *parent */ - dev_num, /* dev_t devt */ - vpd_i2c_client, /* void *private_data */ - VPD_DEVICE); /* const char *fmt */ - if (IS_ERR(device_p)){ - err_msg = "device_create fail"; - goto err_register_vpd_device_1; - } - if (register_vpd_attr(device_p) < 0) { - err_msg = "register_vpd_attr fail"; - goto err_register_vpd_device_2; - } - return 0; - -err_register_vpd_device_2: - device_unregister(device_p); - device_destroy(vpd_class_p, dev_num); -err_register_vpd_device_1: - kfree(vpd_i2c_client); - vpd_i2c_client = NULL; -err_register_vpd_device: - VPD_ERR("%s: %s\n", __func__, err_msg); - return -1; -} - -static int -register_vpd_module(void) -{ - dev_t vpd_devt = 0; - - if (alloc_chrdev_region(&vpd_devt, 0, 1, VPD_DEVICE) < 0){ - VPD_WARN("Allocate VPD MAJOR failure! \n"); - goto err_register_vpd_module; - } - vpd_major = MAJOR(vpd_devt); - - /* Create class object */ - vpd_class_p = class_create(THIS_MODULE, EEPROM_CLASS); - if (IS_ERR(vpd_class_p)) { - VPD_ERR("Create class failure! \n"); - goto err_register_vpd_module_1; - } - return 0; - -err_register_vpd_module_1: - unregister_chrdev_region(MKDEV(vpd_major, 0), 1); -err_register_vpd_module: - return -1; -} - - -static int -init_vpd_common(void) -{ - char *err_msg = "ERR"; - - if (register_vpd_device() < 0) { - err_msg = "register_vpd_device fail"; - goto err_init_vpd_common; - } - return 0; - -err_init_vpd_common: - VPD_ERR("%s: %s\n", __func__, err_msg); - return -1; -} - - -static int __init -vpd_module_init(void) -{ - if (register_vpd_module() < 0){ - goto err_vpd_module_init; - } - if (init_vpd_common() < 0){ - goto err_vpd_module_init_1; - } - VPD_INFO("Inventec vpd module V.%s initial success.\n", VPD_VERSION); - return 0; - -err_vpd_module_init_1: - class_unregister(vpd_class_p); - class_destroy(vpd_class_p); - unregister_chrdev_region(MKDEV(vpd_major, 0), 1); -err_vpd_module_init: - VPD_ERR("Inventec vpd module V.%s initial failure.\n", VPD_VERSION); - return -1; -} - - -static void __exit -vpd_module_exit(void) -{ - clean_vpd_common(); - class_unregister(vpd_class_p); - class_destroy(vpd_class_p); - unregister_chrdev_region(MKDEV(vpd_major, 0), 1); - VPD_INFO("Remove Inventec vpd module success.\n"); -} - - -/* Module information */ -MODULE_AUTHOR(VPD_AUTHOR); -MODULE_DESCRIPTION(VPD_DESC); -MODULE_VERSION(VPD_VERSION); -MODULE_LICENSE(VPD_LICENSE); - -module_init(vpd_module_init); -module_exit(vpd_module_exit); diff --git a/packages/platforms/inventec/x86-64/d5254/modules/builds/src/inv_vpd.h b/packages/platforms/inventec/x86-64/d5254/modules/builds/src/inv_vpd.h deleted file mode 100644 index 58c7fe33f..000000000 --- a/packages/platforms/inventec/x86-64/d5254/modules/builds/src/inv_vpd.h +++ /dev/null @@ -1,46 +0,0 @@ -#ifndef INV_VPD_H -#define INV_VPD_H - -#define EEPROM_CLASS "eeprom" -#define VPD_DEVICE "vpd" -#define VPD_AUTHOR "Neil " -#define VPD_DESC "Inventec eeprom vpd driver" -#define VPD_VERSION "1.0.0" -#define VPD_LICENSE "GPL" - -#define VPD_ENTRY_SIZE (17) -#define VPD_I2C_BUS (0) -#define VPD_I2C_ADDR (0x53) - -struct register_attr { -struct device_attribute *attr; -char * errmsg; -}; - -struct vpd_device_attribute{ - struct device_attribute dev_attr; - int index; -}; - -#define to_vpd_dev_attr(_dev_attr) \ - container_of(_dev_attr, struct vpd_device_attribute, dev_attr) - -#define VPD_ATTR(_name, _mode, _show, _store, _index) \ - { .dev_attr = __ATTR(_name, _mode, _show, _store), \ - .index = _index } - -#define VPD_DEVICE_ATTR(_name, _mode, _show, _store, _index) \ - struct vpd_device_attribute vpd_dev_attr_##_name \ - = VPD_ATTR(_name, _mode, _show, _store, _index) - -#define VPD_INFO(fmt, args...) printk( KERN_INFO "[VPD] " fmt, ##args) -#define VPD_WARN(fmt, args...) printk( KERN_WARNING "[VPD] " fmt, ##args) -#define VPD_ERR(fmt, args...) printk( KERN_ERR "[VPD] " fmt, ##args) - -#ifdef DEBUG_VPD -# define VPD_DEBUG(fmt, args...) printk( KERN_DEBUG "[VPD] " fmt, ##args) -#else -# define VPD_DEBUG(fmt, args...) -#endif - -#endif /* INV_VPD_H */ diff --git a/packages/platforms/inventec/x86-64/d5254/modules/builds/src/io_expander.c b/packages/platforms/inventec/x86-64/d5254/modules/builds/src/io_expander.c deleted file mode 100644 index 792896d45..000000000 --- a/packages/platforms/inventec/x86-64/d5254/modules/builds/src/io_expander.c +++ /dev/null @@ -1,2165 +0,0 @@ -#include -#include -/* For build single module using (Ex: ONL platform) */ -#include -#include "io_expander.h" - - -static struct ioexp_obj_s *ioexp_head_p = NULL; -static struct ioexp_obj_s *ioexp_tail_p = NULL; - - -/* ========== Register IOEXP layout ========== - */ -struct ioexp_map_s ioexp_map_magnolia_nab = { - - .chip_amount = 2, - .data_width = 2, - - .map_present = { {0, 0, 4}, /* map_present[0] = MOD_ABS_PORT(X) */ - {0, 0, 5}, /* map_present[1] = MOD_ABS_PORT(X+1) */ - {0, 0, 6}, /* map_present[2] = MOD_ABS_PORT(X+2) */ - {0, 0, 7}, /* map_present[3] = MOD_ABS_PORT(X+3) */ - {1, 0, 4}, /* map_present[4] = MOD_ABS_PORT(X+4) */ - {1, 0, 5}, /* map_present[5] = MOD_ABS_PORT(X+5) */ - {1, 0, 6}, /* map_present[6] = MOD_ABS_PORT(X+6) */ - {1, 0, 7}, /* map_present[7] = MOD_ABS_PORT(X+7) */ - }, - .map_tx_disable = { {0, 1, 0}, /* map_tx_disable[0] = TXDISABLE_SFP+_P(X) */ - {0, 1, 1}, /* map_tx_disable[1] = TXDISABLE_SFP+_P(X+1) */ - {0, 1, 2}, /* map_tx_disable[2] = TXDISABLE_SFP+_P(X+2) */ - {0, 1, 3}, /* map_tx_disable[3] = TXDISABLE_SFP+_P(X+3) */ - {1, 1, 0}, /* map_tx_disable[4] = TXDISABLE_SFP+_P(X+4) */ - {1, 1, 1}, /* map_tx_disable[5] = TXDISABLE_SFP+_P(X+5) */ - {1, 1, 2}, /* map_tx_disable[6] = TXDISABLE_SFP+_P(X+6) */ - {1, 1, 3}, /* map_tx_disable[7] = TXDISABLE_SFP+_P(X+7) */ - }, - .map_tx_fault = { {0, 0, 0}, /* map_tx_fault[0] = TXFAULT_SFP+_P(X) */ - {0, 0, 1}, /* map_tx_fault[1] = TXFAULT_SFP+_P(X+1) */ - {0, 0, 2}, /* map_tx_fault[2] = TXFAULT_SFP+_P(X+2) */ - {0, 0, 3}, /* map_tx_fault[3] = TXFAULT_SFP+_P(X+3) */ - {1, 0, 0}, /* map_tx_fault[4] = TXFAULT_SFP+_P(X+4) */ - {1, 0, 1}, /* map_tx_fault[5] = TXFAULT_SFP+_P(X+5) */ - {1, 0, 2}, /* map_tx_fault[6] = TXFAULT_SFP+_P(X+6) */ - {1, 0, 3}, /* map_tx_fault[7] = TXFAULT_SFP+_P(X+7) */ - }, - .map_rxlos = { {0, 1, 4}, /* map_rxlos[0] = OPRXLOS_PORT(X) */ - {0, 1, 5}, /* map_rxlos[1] = OPRXLOS_PORT(X+1) */ - {0, 1, 6}, /* map_rxlos[2] = OPRXLOS_PORT(X+2) */ - {0, 1, 7}, /* map_rxlos[3] = OPRXLOS_PORT(X+3) */ - {1, 1, 4}, /* map_rxlos[4] = OPRXLOS_PORT(X+4) */ - {1, 1, 5}, /* map_rxlos[5] = OPRXLOS_PORT(X+5) */ - {1, 1, 6}, /* map_rxlos[6] = OPRXLOS_PORT(X+6) */ - {1, 1, 7}, /* map_rxlos[7] = OPRXLOS_PORT(X+7) */ - }, -}; - - -struct ioexp_map_s ioexp_map_magnolia_4ab = { - - .chip_amount = 2, - .data_width = 2, - - .map_present = { {0, 0, 4}, /* map_present[0] = MOD_ABS_PORT(X) */ - {0, 0, 5}, /* map_present[1] = MOD_ABS_PORT(X+1) */ - {0, 0, 6}, /* map_present[2] = MOD_ABS_PORT(X+2) */ - {0, 0, 7}, /* map_present[3] = MOD_ABS_PORT(X+3) */ - {1, 0, 4}, /* map_present[4] = MOD_ABS_PORT(X+4) */ - {1, 0, 5}, /* map_present[5] = MOD_ABS_PORT(X+5) */ - {1, 0, 6}, /* map_present[6] = MOD_ABS_PORT(X+6) */ - {1, 0, 7}, /* map_present[7] = MOD_ABS_PORT(X+7) */ - }, - .map_tx_disable = { {0, 1, 0}, /* map_tx_disable[0] = TXDISABLE_SFP+_P(X) */ - {0, 1, 1}, /* map_tx_disable[1] = TXDISABLE_SFP+_P(X+1) */ - {0, 1, 2}, /* map_tx_disable[2] = TXDISABLE_SFP+_P(X+2) */ - {0, 1, 3}, /* map_tx_disable[3] = TXDISABLE_SFP+_P(X+3) */ - {1, 0, 0}, /* map_tx_disable[4] = TXDISABLE_SFP+_P(X+4) */ - {1, 0, 1}, /* map_tx_disable[5] = TXDISABLE_SFP+_P(X+5) */ - {1, 0, 2}, /* map_tx_disable[6] = TXDISABLE_SFP+_P(X+6) */ - {1, 0, 3}, /* map_tx_disable[7] = TXDISABLE_SFP+_P(X+7) */ - }, - .map_tx_fault = { {0, 0, 0}, /* map_tx_fault[0] = TXFAULT_SFP+_P(X) */ - {0, 0, 1}, /* map_tx_fault[1] = TXFAULT_SFP+_P(X+1) */ - {0, 0, 2}, /* map_tx_fault[2] = TXFAULT_SFP+_P(X+2) */ - {0, 0, 3}, /* map_tx_fault[3] = TXFAULT_SFP+_P(X+3) */ - {1, 1, 0}, /* map_tx_fault[4] = TXFAULT_SFP+_P(X+4) */ - {1, 1, 1}, /* map_tx_fault[5] = TXFAULT_SFP+_P(X+5) */ - {1, 1, 2}, /* map_tx_fault[6] = TXFAULT_SFP+_P(X+6) */ - {1, 1, 3}, /* map_tx_fault[7] = TXFAULT_SFP+_P(X+7) */ - }, - .map_rxlos = { {0, 1, 4}, /* map_rxlos[0] = OPRXLOS_PORT(X) */ - {0, 1, 5}, /* map_rxlos[1] = OPRXLOS_PORT(X+1) */ - {0, 1, 6}, /* map_rxlos[2] = OPRXLOS_PORT(X+2) */ - {0, 1, 7}, /* map_rxlos[3] = OPRXLOS_PORT(X+3) */ - {1, 1, 4}, /* map_rxlos[4] = OPRXLOS_PORT(X+4) */ - {1, 1, 5}, /* map_rxlos[5] = OPRXLOS_PORT(X+5) */ - {1, 1, 6}, /* map_rxlos[6] = OPRXLOS_PORT(X+6) */ - {1, 1, 7}, /* map_rxlos[7] = OPRXLOS_PORT(X+7) */ - }, -}; - - -struct ioexp_map_s ioexp_map_magnolia_7ab = { - - .chip_amount = 2, - .data_width = 2, - - .map_present = { {1, 0, 4}, /* map_present[0] = MOD_ABS_PORT(X) */ - {1, 0, 5}, /* map_present[1] = MOD_ABS_PORT(X+1) */ - {1, 0, 6}, /* map_present[2] = MOD_ABS_PORT(X+2) */ - {1, 0, 7}, /* map_present[3] = MOD_ABS_PORT(X+3) */ - {1, 1, 4}, /* map_present[4] = MOD_ABS_PORT(X+4) */ - {1, 1, 5}, /* map_present[5] = MOD_ABS_PORT(X+5) */ - }, - .map_reset = { {0, 0, 0}, /* map_reset[0] = QRESET_QSFP_N_P(X) */ - {0, 0, 1}, /* map_reset[1] = QRESET_QSFP_N_P(X+1) */ - {0, 0, 2}, /* map_reset[2] = QRESET_QSFP_N_P(X+2) */ - {0, 0, 3}, /* map_reset[3] = QRESET_QSFP_N_P(X+3) */ - {1, 0, 0}, /* map_reset[4] = QRESET_QSFP_N_P(X+4) */ - {1, 0, 1}, /* map_reset[5] = QRESET_QSFP_N_P(X+5) */ - }, - .map_lpmod = { {0, 0, 4}, /* map_lpmod[0] = LPMODE_QSFP_P(X) */ - {0, 0, 5}, /* map_lpmod[1] = LPMODE_QSFP_P(X+1) */ - {0, 0, 6}, /* map_lpmod[2] = LPMODE_QSFP_P(X+2) */ - {0, 0, 7}, /* map_lpmod[3] = LPMODE_QSFP_P(X+3) */ - {1, 0, 2}, /* map_lpmod[4] = LPMODE_QSFP_P(X+4) */ - {1, 0, 3}, /* map_lpmod[5] = LPMODE_QSFP_P(X+5) */ - }, - .map_modsel = { {0, 1, 4}, /* map_modsel[0] = MODSEL_QSFP_N_P(X) */ - {0, 1, 5}, /* map_modsel[1] = MODSEL_QSFP_N_P(X+1) */ - {0, 1, 6}, /* map_modsel[2] = MODSEL_QSFP_N_P(X+2) */ - {0, 1, 7}, /* map_modsel[3] = MODSEL_QSFP_N_P(X+3) */ - {1, 1, 4}, /* map_modsel[4] = MODSEL_QSFP_N_P(X+4) */ - {1, 1, 5}, /* map_modsel[5] = MODSEL_QSFP_N_P(X+5) */ - }, -}; - - -struct ioexp_map_s ioexp_map_redwood_p01p08_p17p24 = { - - .chip_amount = 3, - .data_width = 2, - - .map_present = { {2, 0, 0}, /* map_present[0] = MOD_ABS_PORT(X) */ - {2, 0, 1}, /* map_present[1] = MOD_ABS_PORT(X+1) */ - {2, 0, 2}, /* map_present[2] = MOD_ABS_PORT(X+2) */ - {2, 0, 3}, /* map_present[3] = MOD_ABS_PORT(X+3) */ - {2, 0, 4}, /* map_present[4] = MOD_ABS_PORT(X+4) */ - {2, 0, 5}, /* map_present[5] = MOD_ABS_PORT(X+5) */ - {2, 0, 6}, /* map_present[6] = MOD_ABS_PORT(X+6) */ - {2, 0, 7}, /* map_present[7] = MOD_ABS_PORT(X+7) */ - }, - .map_reset = { {0, 0, 0}, /* map_reset[0] = QRESET_QSFP28_N_P(X) */ - {0, 0, 1}, /* map_reset[1] = QRESET_QSFP28_N_P(X+1) */ - {0, 0, 2}, /* map_reset[2] = QRESET_QSFP28_N_P(X+2) */ - {0, 0, 3}, /* map_reset[3] = QRESET_QSFP28_N_P(X+3) */ - {1, 0, 0}, /* map_reset[4] = QRESET_QSFP28_N_P(X+4) */ - {1, 0, 1}, /* map_reset[5] = QRESET_QSFP28_N_P(X+5) */ - {1, 0, 2}, /* map_reset[6] = QRESET_QSFP28_N_P(X+6) */ - {1, 0, 3}, /* map_reset[7] = QRESET_QSFP28_N_P(X+7) */ - }, - .map_lpmod = { {0, 0, 4}, /* map_lpmod[0] = LPMODE_QSFP28_P(X) */ - {0, 0, 5}, /* map_lpmod[1] = LPMODE_QSFP28_P(X+1) */ - {0, 0, 6}, /* map_lpmod[2] = LPMODE_QSFP28_P(X+2) */ - {0, 0, 7}, /* map_lpmod[3] = LPMODE_QSFP28_P(X+3) */ - {1, 0, 4}, /* map_lpmod[4] = LPMODE_QSFP28_P(X+4) */ - {1, 0, 5}, /* map_lpmod[5] = LPMODE_QSFP28_P(X+5) */ - {1, 0, 6}, /* map_lpmod[6] = LPMODE_QSFP28_P(X+6) */ - {1, 0, 7}, /* map_lpmod[7] = LPMODE_QSFP28_P(X+7) */ - }, - .map_modsel = { {0, 1, 4}, /* map_modsel[0] = MODSEL_QSFP28_N_P(X) */ - {0, 1, 5}, /* map_modsel[1] = MODSEL_QSFP28_N_P(X+1) */ - {0, 1, 6}, /* map_modsel[2] = MODSEL_QSFP28_N_P(X+2) */ - {0, 1, 7}, /* map_modsel[3] = MODSEL_QSFP28_N_P(X+3) */ - {1, 1, 4}, /* map_modsel[4] = MODSEL_QSFP28_N_P(X+4) */ - {1, 1, 5}, /* map_modsel[5] = MODSEL_QSFP28_N_P(X+5) */ - {1, 1, 6}, /* map_modsel[6] = MODSEL_QSFP28_N_P(X+6) */ - {1, 1, 7}, /* map_modsel[7] = MODSEL_QSFP28_N_P(X+7) */ - }, -}; - - -struct ioexp_map_s ioexp_map_redwood_p09p16_p25p32 = { - - .chip_amount = 3, - .data_width = 2, - - .map_present = { {2, 1, 0}, /* map_present[0] = MOD_ABS_PORT(X) */ - {2, 1, 1}, /* map_present[1] = MOD_ABS_PORT(X+1) */ - {2, 1, 2}, /* map_present[2] = MOD_ABS_PORT(X+2) */ - {2, 1, 3}, /* map_present[3] = MOD_ABS_PORT(X+3) */ - {2, 1, 4}, /* map_present[4] = MOD_ABS_PORT(X+4) */ - {2, 1, 5}, /* map_present[5] = MOD_ABS_PORT(X+5) */ - {2, 1, 6}, /* map_present[6] = MOD_ABS_PORT(X+6) */ - {2, 1, 7}, /* map_present[7] = MOD_ABS_PORT(X+7) */ - }, - .map_reset = { {0, 0, 0}, /* map_reset[0] = QRESET_QSFP28_N_P(X) */ - {0, 0, 1}, /* map_reset[1] = QRESET_QSFP28_N_P(X+1) */ - {0, 0, 2}, /* map_reset[2] = QRESET_QSFP28_N_P(X+2) */ - {0, 0, 3}, /* map_reset[3] = QRESET_QSFP28_N_P(X+3) */ - {1, 0, 0}, /* map_reset[4] = QRESET_QSFP28_N_P(X+4) */ - {1, 0, 1}, /* map_reset[5] = QRESET_QSFP28_N_P(X+5) */ - {1, 0, 2}, /* map_reset[6] = QRESET_QSFP28_N_P(X+6) */ - {1, 0, 3}, /* map_reset[7] = QRESET_QSFP28_N_P(X+7) */ - }, - .map_lpmod = { {0, 0, 4}, /* map_lpmod[0] = LPMODE_QSFP28_P(X) */ - {0, 0, 5}, /* map_lpmod[1] = LPMODE_QSFP28_P(X+1) */ - {0, 0, 6}, /* map_lpmod[2] = LPMODE_QSFP28_P(X+2) */ - {0, 0, 7}, /* map_lpmod[3] = LPMODE_QSFP28_P(X+3) */ - {1, 0, 4}, /* map_lpmod[4] = LPMODE_QSFP28_P(X+4) */ - {1, 0, 5}, /* map_lpmod[5] = LPMODE_QSFP28_P(X+5) */ - {1, 0, 6}, /* map_lpmod[6] = LPMODE_QSFP28_P(X+6) */ - {1, 0, 7}, /* map_lpmod[7] = LPMODE_QSFP28_P(X+7) */ - }, - .map_modsel = { {0, 1, 4}, /* map_modsel[0] = MODSEL_QSFP28_N_P(X) */ - {0, 1, 5}, /* map_modsel[1] = MODSEL_QSFP28_N_P(X+1) */ - {0, 1, 6}, /* map_modsel[2] = MODSEL_QSFP28_N_P(X+2) */ - {0, 1, 7}, /* map_modsel[3] = MODSEL_QSFP28_N_P(X+3) */ - {1, 1, 4}, /* map_modsel[4] = MODSEL_QSFP28_N_P(X+4) */ - {1, 1, 5}, /* map_modsel[5] = MODSEL_QSFP28_N_P(X+5) */ - {1, 1, 6}, /* map_modsel[6] = MODSEL_QSFP28_N_P(X+6) */ - {1, 1, 7}, /* map_modsel[7] = MODSEL_QSFP28_N_P(X+7) */ - }, -}; - - -struct ioexp_map_s ioexp_map_hudson32iga_p01p08_p17p24 = { - - .chip_amount = 3, - .data_width = 2, - - .map_present = { {2, 0, 0}, /* map_present[0] = MODABS_QSFP(X) */ - {2, 0, 1}, /* map_present[1] = MODABS_QSFP(X+1) */ - {2, 0, 2}, /* map_present[2] = MODABS_QSFP(X+2) */ - {2, 0, 3}, /* map_present[3] = MODABS_QSFP(X+3) */ - {2, 0, 4}, /* map_present[4] = MODABS_QSFP(X+4) */ - {2, 0, 5}, /* map_present[5] = MODABS_QSFP(X+5) */ - {2, 0, 6}, /* map_present[6] = MODABS_QSFP(X+6) */ - {2, 0, 7}, /* map_present[7] = MODABS_QSFP(X+7) */ - }, - .map_reset = { {0, 0, 0}, /* map_reset[0] = QRESET_QSFP(X) */ - {0, 0, 1}, /* map_reset[1] = QRESET_QSFP(X+1) */ - {0, 0, 2}, /* map_reset[2] = QRESET_QSFP(X+2) */ - {0, 0, 3}, /* map_reset[3] = QRESET_QSFP(X+3) */ - {1, 0, 0}, /* map_reset[4] = QRESET_QSFP(X+4) */ - {1, 0, 1}, /* map_reset[5] = QRESET_QSFP(X+5) */ - {1, 0, 2}, /* map_reset[6] = QRESET_QSFP(X+6) */ - {1, 0, 3}, /* map_reset[7] = QRESET_QSFP(X+7) */ - }, - .map_lpmod = { {0, 0, 4}, /* map_lpmod[0] = LPMODE_QSFP(X) */ - {0, 0, 5}, /* map_lpmod[1] = LPMODE_QSFP(X+1) */ - {0, 0, 6}, /* map_lpmod[2] = LPMODE_QSFP(X+2) */ - {0, 0, 7}, /* map_lpmod[3] = LPMODE_QSFP(X+3) */ - {1, 0, 4}, /* map_lpmod[4] = LPMODE_QSFP(X+4) */ - {1, 0, 5}, /* map_lpmod[5] = LPMODE_QSFP(X+5) */ - {1, 0, 6}, /* map_lpmod[6] = LPMODE_QSFP(X+6) */ - {1, 0, 7}, /* map_lpmod[7] = LPMODE_QSFP(X+7) */ - }, - .map_modsel = { {0, 1, 4}, /* map_modsel[0] = MODSEL_QSFP(X) */ - {0, 1, 5}, /* map_modsel[1] = MODSEL_QSFP(X+1) */ - {0, 1, 6}, /* map_modsel[2] = MODSEL_QSFP(X+2) */ - {0, 1, 7}, /* map_modsel[3] = MODSEL_QSFP(X+3) */ - {1, 1, 4}, /* map_modsel[4] = MODSEL_QSFP(X+4) */ - {1, 1, 5}, /* map_modsel[5] = MODSEL_QSFP(X+5) */ - {1, 1, 6}, /* map_modsel[6] = MODSEL_QSFP(X+6) */ - {1, 1, 7}, /* map_modsel[7] = MODSEL_QSFP(X+7) */ - }, -}; - - -struct ioexp_map_s ioexp_map_hudson32iga_p09p16_p25p32 = { - - .chip_amount = 3, - .data_width = 2, - - .map_present = { {2, 1, 0}, /* map_present[0] = MODABS_QSFP(X) */ - {2, 1, 1}, /* map_present[1] = MODABS_QSFP(X+1) */ - {2, 1, 2}, /* map_present[2] = MODABS_QSFP(X+2) */ - {2, 1, 3}, /* map_present[3] = MODABS_QSFP(X+3) */ - {2, 1, 4}, /* map_present[4] = MODABS_QSFP(X+4) */ - {2, 1, 5}, /* map_present[5] = MODABS_QSFP(X+5) */ - {2, 1, 6}, /* map_present[6] = MODABS_QSFP(X+6) */ - {2, 1, 7}, /* map_present[7] = MODABS_QSFP(X+7) */ - }, - .map_reset = { {0, 0, 0}, /* map_reset[0] = QRESET_QSFP(X) */ - {0, 0, 1}, /* map_reset[1] = QRESET_QSFP(X+1) */ - {0, 0, 2}, /* map_reset[2] = QRESET_QSFP(X+2) */ - {0, 0, 3}, /* map_reset[3] = QRESET_QSFP(X+3) */ - {1, 0, 0}, /* map_reset[4] = QRESET_QSFP(X+4) */ - {1, 0, 1}, /* map_reset[5] = QRESET_QSFP(X+5) */ - {1, 0, 2}, /* map_reset[6] = QRESET_QSFP(X+6) */ - {1, 0, 3}, /* map_reset[7] = QRESET_QSFP(X+7) */ - }, - .map_lpmod = { {0, 0, 4}, /* map_lpmod[0] = LPMODE_QSFP(X) */ - {0, 0, 5}, /* map_lpmod[1] = LPMODE_QSFP(X+1) */ - {0, 0, 6}, /* map_lpmod[2] = LPMODE_QSFP(X+2) */ - {0, 0, 7}, /* map_lpmod[3] = LPMODE_QSFP(X+3) */ - {1, 0, 4}, /* map_lpmod[4] = LPMODE_QSFP(X+4) */ - {1, 0, 5}, /* map_lpmod[5] = LPMODE_QSFP(X+5) */ - {1, 0, 6}, /* map_lpmod[6] = LPMODE_QSFP(X+6) */ - {1, 0, 7}, /* map_lpmod[7] = LPMODE_QSFP(X+7) */ - }, - .map_modsel = { {0, 1, 4}, /* map_modsel[0] = MODSEL_QSFP(X) */ - {0, 1, 5}, /* map_modsel[1] = MODSEL_QSFP(X+1) */ - {0, 1, 6}, /* map_modsel[2] = MODSEL_QSFP(X+2) */ - {0, 1, 7}, /* map_modsel[3] = MODSEL_QSFP(X+3) */ - {1, 1, 4}, /* map_modsel[4] = MODSEL_QSFP(X+4) */ - {1, 1, 5}, /* map_modsel[5] = MODSEL_QSFP(X+5) */ - {1, 1, 6}, /* map_modsel[6] = MODSEL_QSFP(X+6) */ - {1, 1, 7}, /* map_modsel[7] = MODSEL_QSFP(X+7) */ - }, -}; - - -struct ioexp_map_s ioexp_map_cypress_nabc = { - - .chip_amount = 3, - .data_width = 2, - - .map_present = { {0, 0, 4}, /* map_present[0] = MOD_ABS_PORT(X) */ - {0, 0, 5}, /* map_present[1] = MOD_ABS_PORT(X+1) */ - {0, 0, 6}, /* map_present[2] = MOD_ABS_PORT(X+2) */ - {0, 0, 7}, /* map_present[3] = MOD_ABS_PORT(X+3) */ - {1, 0, 4}, /* map_present[4] = MOD_ABS_PORT(X+4) */ - {1, 0, 5}, /* map_present[5] = MOD_ABS_PORT(X+5) */ - {1, 0, 6}, /* map_present[6] = MOD_ABS_PORT(X+6) */ - {1, 0, 7}, /* map_present[7] = MOD_ABS_PORT(X+7) */ - }, - .map_tx_disable = { {0, 1, 0}, /* map_tx_disable[0] = TXDISABLE_SFP+_P(X) */ - {0, 1, 1}, /* map_tx_disable[1] = TXDISABLE_SFP+_P(X+1) */ - {0, 1, 2}, /* map_tx_disable[2] = TXDISABLE_SFP+_P(X+2) */ - {0, 1, 3}, /* map_tx_disable[3] = TXDISABLE_SFP+_P(X+3) */ - {1, 1, 0}, /* map_tx_disable[4] = TXDISABLE_SFP+_P(X+4) */ - {1, 1, 1}, /* map_tx_disable[5] = TXDISABLE_SFP+_P(X+5) */ - {1, 1, 2}, /* map_tx_disable[6] = TXDISABLE_SFP+_P(X+6) */ - {1, 1, 3}, /* map_tx_disable[7] = TXDISABLE_SFP+_P(X+7) */ - }, - .map_tx_fault = { {0, 0, 0}, /* map_tx_fault[0] = TXFAULT_SFP+_P(X) */ - {0, 0, 1}, /* map_tx_fault[1] = TXFAULT_SFP+_P(X+1) */ - {0, 0, 2}, /* map_tx_fault[2] = TXFAULT_SFP+_P(X+2) */ - {0, 0, 3}, /* map_tx_fault[3] = TXFAULT_SFP+_P(X+3) */ - {1, 0, 0}, /* map_tx_fault[4] = TXFAULT_SFP+_P(X+4) */ - {1, 0, 1}, /* map_tx_fault[5] = TXFAULT_SFP+_P(X+5) */ - {1, 0, 2}, /* map_tx_fault[6] = TXFAULT_SFP+_P(X+6) */ - {1, 0, 3}, /* map_tx_fault[7] = TXFAULT_SFP+_P(X+7) */ - }, - .map_rxlos = { {0, 1, 4}, /* map_rxlos[0] = OPRXLOS_PORT(X) */ - {0, 1, 5}, /* map_rxlos[1] = OPRXLOS_PORT(X+1) */ - {0, 1, 6}, /* map_rxlos[2] = OPRXLOS_PORT(X+2) */ - {0, 1, 7}, /* map_rxlos[3] = OPRXLOS_PORT(X+3) */ - {1, 1, 4}, /* map_rxlos[4] = OPRXLOS_PORT(X+4) */ - {1, 1, 5}, /* map_rxlos[5] = OPRXLOS_PORT(X+5) */ - {1, 1, 6}, /* map_rxlos[6] = OPRXLOS_PORT(X+6) */ - {1, 1, 7}, /* map_rxlos[7] = OPRXLOS_PORT(X+7) */ - }, - .map_hard_rs0 = { {2, 0, 0}, /* map_hard_rs0[0] = RS0_SFP28_P(X) */ - {2, 0, 2}, /* map_hard_rs0[1] = RS0_SFP28_P(X+1) */ - {2, 0, 4}, /* map_hard_rs0[2] = RS0_SFP28_P(X+2) */ - {2, 0, 6}, /* map_hard_rs0[3] = RS0_SFP28_P(X+3) */ - {2, 1, 0}, /* map_hard_rs0[4] = RS0_SFP28_P(X+4) */ - {2, 1, 2}, /* map_hard_rs0[5] = RS0_SFP28_P(X+5) */ - {2, 1, 4}, /* map_hard_rs0[6] = RS0_SFP28_P(X+6) */ - {2, 1, 6}, /* map_hard_rs0[7] = RS0_SFP28_P(X+7) */ - }, - .map_hard_rs1 = { {2, 0, 1}, /* map_hard_rs1[0] = RS1_SFP28_P(X) */ - {2, 0, 3}, /* map_hard_rs1[1] = RS1_SFP28_P(X+1) */ - {2, 0, 5}, /* map_hard_rs1[2] = RS1_SFP28_P(X+2) */ - {2, 0, 7}, /* map_hard_rs1[3] = RS1_SFP28_P(X+3) */ - {2, 1, 1}, /* map_hard_rs1[4] = RS1_SFP28_P(X+4) */ - {2, 1, 3}, /* map_hard_rs1[5] = RS1_SFP28_P(X+5) */ - {2, 1, 5}, /* map_hard_rs1[6] = RS1_SFP28_P(X+6) */ - {2, 1, 7}, /* map_hard_rs1[7] = RS1_SFP28_P(X+7) */ - }, -}; - - -struct ioexp_map_s ioexp_map_cypress_7abc = { - - .chip_amount = 3, - .data_width = 2, - - .map_present = { {2, 0, 0}, /* map_present[0] = MOD_ABS_PORT(X) */ - {2, 0, 1}, /* map_present[1] = MOD_ABS_PORT(X+1) */ - {2, 0, 2}, /* map_present[2] = MOD_ABS_PORT(X+2) */ - {2, 0, 3}, /* map_present[3] = MOD_ABS_PORT(X+3) */ - {2, 0, 4}, /* map_present[4] = MOD_ABS_PORT(X+4) */ - {2, 0, 5}, /* map_present[5] = MOD_ABS_PORT(X+5) */ - }, - .map_reset = { {0, 0, 0}, /* map_reset[0] = QRESET_QSFP_N_P(X) */ - {0, 0, 1}, /* map_reset[1] = QRESET_QSFP_N_P(X+1) */ - {0, 0, 2}, /* map_reset[2] = QRESET_QSFP_N_P(X+2) */ - {0, 0, 3}, /* map_reset[3] = QRESET_QSFP_N_P(X+3) */ - {0, 0, 4}, /* map_reset[4] = QRESET_QSFP_N_P(X+4) */ - {0, 0, 5}, /* map_reset[5] = QRESET_QSFP_N_P(X+5) */ - }, - .map_lpmod = { {0, 1, 0}, /* map_lpmod[0] = LPMODE_QSFP_P(X) */ - {0, 1, 1}, /* map_lpmod[1] = LPMODE_QSFP_P(X+1) */ - {0, 1, 2}, /* map_lpmod[2] = LPMODE_QSFP_P(X+2) */ - {0, 1, 3}, /* map_lpmod[3] = LPMODE_QSFP_P(X+3) */ - {0, 1, 4}, /* map_lpmod[4] = LPMODE_QSFP_P(X+4) */ - {0, 1, 5}, /* map_lpmod[5] = LPMODE_QSFP_P(X+5) */ - }, - .map_modsel = { {1, 1, 0}, /* map_modsel[0] = MODSEL_QSFP_N_P(X) */ - {1, 1, 1}, /* map_modsel[1] = MODSEL_QSFP_N_P(X+1) */ - {1, 1, 2}, /* map_modsel[2] = MODSEL_QSFP_N_P(X+2) */ - {1, 1, 3}, /* map_modsel[3] = MODSEL_QSFP_N_P(X+3) */ - {1, 1, 4}, /* map_modsel[4] = MODSEL_QSFP_N_P(X+4) */ - {1, 1, 5}, /* map_modsel[5] = MODSEL_QSFP_N_P(X+5) */ - }, -}; - - -struct ioexp_map_s ioexp_map_tahoe_5a = { - - .chip_amount = 1, - .data_width = 2, - - .map_present = { {0, 0, 3}, /* map_present[0] = MOD_ABS_PORT(X) */ - {0, 1, 0}, /* map_present[1] = MOD_ABS_PORT(X+1) */ - {0, 1, 5}, /* map_present[2] = MOD_ABS_PORT(X+2) */ - }, - .map_reset = { {0, 0, 1}, /* map_reset[0] = QRESET_QSFP_N_P(X) */ - {0, 0, 6}, /* map_reset[1] = QRESET_QSFP_N_P(X+1) */ - {0, 1, 3}, /* map_reset[2] = QRESET_QSFP_N_P(X+2) */ - }, - .map_lpmod = { {0, 0, 2}, /* map_lpmod[0] = LPMODE_QSFP_P(X) */ - {0, 0, 7}, /* map_lpmod[1] = LPMODE_QSFP_P(X+1) */ - {0, 1, 4}, /* map_lpmod[2] = LPMODE_QSFP_P(X+2) */ - }, - .map_modsel = { {0, 0, 0}, /* map_modsel[0] = MODSEL_QSFP_N_P(X) */ - {0, 0, 5}, /* map_modsel[1] = MODSEL_QSFP_N_P(X+1) */ - {0, 1, 2}, /* map_modsel[2] = MODSEL_QSFP_N_P(X+2) */ - }, -}; - - -struct ioexp_map_s ioexp_map_tahoe_6abc = { - - .chip_amount = 3, - .data_width = 2, - - .map_present = { {0, 0, 3}, /* map_present[0] = MOD_ABS_PORT(X) */ - {0, 1, 0}, /* map_present[1] = MOD_ABS_PORT(X+1) */ - {0, 1, 5}, /* map_present[2] = MOD_ABS_PORT(X+2) */ - {1, 0, 3}, /* map_present[3] = MOD_ABS_PORT(X+3) */ - {1, 1, 0}, /* map_present[4] = MOD_ABS_PORT(X+4) */ - {1, 1, 5}, /* map_present[5] = MOD_ABS_PORT(X+5) */ - {2, 0, 3}, /* map_present[6] = MOD_ABS_PORT(X+6) */ - {2, 1, 0}, /* map_present[7] = MOD_ABS_PORT(X+7) */ - {2, 1, 5}, /* map_present[8] = MOD_ABS_PORT(X+8) */ - }, - .map_reset = { {0, 0, 1}, /* map_reset[0] = QRESET_QSFP28_N_P(X) */ - {0, 0, 6}, /* map_reset[1] = QRESET_QSFP28_N_P(X+1) */ - {0, 1, 3}, /* map_reset[2] = QRESET_QSFP28_N_P(X+2) */ - {1, 0, 1}, /* map_reset[3] = QRESET_QSFP28_N_P(X+3) */ - {1, 0, 6}, /* map_reset[4] = QRESET_QSFP28_N_P(X+4) */ - {1, 1, 3}, /* map_reset[5] = QRESET_QSFP28_N_P(X+5) */ - {2, 0, 1}, /* map_reset[6] = QRESET_QSFP28_N_P(X+6) */ - {2, 0, 6}, /* map_reset[7] = QRESET_QSFP28_N_P(X+7) */ - {2, 1, 3}, /* map_reset[7] = QRESET_QSFP28_N_P(X+7) */ - }, - .map_lpmod = { {0, 0, 2}, /* map_lpmod[0] = LPMODE_QSFP28_P(X) */ - {0, 0, 7}, /* map_lpmod[1] = LPMODE_QSFP28_P(X+1) */ - {0, 1, 4}, /* map_lpmod[2] = LPMODE_QSFP28_P(X+2) */ - {1, 0, 2}, /* map_lpmod[3] = LPMODE_QSFP28_P(X+3) */ - {1, 0, 7}, /* map_lpmod[4] = LPMODE_QSFP28_P(X+4) */ - {1, 1, 4}, /* map_lpmod[5] = LPMODE_QSFP28_P(X+5) */ - {2, 0, 2}, /* map_lpmod[6] = LPMODE_QSFP28_P(X+6) */ - {2, 0, 7}, /* map_lpmod[7] = LPMODE_QSFP28_P(X+7) */ - {2, 1, 4}, /* map_lpmod[7] = LPMODE_QSFP28_P(X+8) */ - }, - .map_modsel = { {0, 0, 0}, /* map_modsel[0] = MODSEL_QSFP28_N_P(X) */ - {0, 0, 5}, /* map_modsel[1] = MODSEL_QSFP28_N_P(X+1) */ - {0, 1, 2}, /* map_modsel[2] = MODSEL_QSFP28_N_P(X+2) */ - {1, 0, 0}, /* map_modsel[3] = MODSEL_QSFP28_N_P(X+3) */ - {1, 0, 5}, /* map_modsel[4] = MODSEL_QSFP28_N_P(X+4) */ - {1, 1, 2}, /* map_modsel[5] = MODSEL_QSFP28_N_P(X+5) */ - {2, 0, 0}, /* map_modsel[6] = MODSEL_QSFP28_N_P(X+6) */ - {2, 0, 5}, /* map_modsel[7] = MODSEL_QSFP28_N_P(X+7) */ - {2, 1, 2}, /* map_modsel[7] = MODSEL_QSFP28_N_P(X+7) */ - }, -}; - - -struct ioexp_map_s ioexp_map_sequoia_nabc = { - - .chip_amount = 3, - .data_width = 2, - - .map_present = { {2, 1, 0}, /* map_present[0] = MOD_ABS_PORT(X) */ - {2, 1, 1}, /* map_present[1] = MOD_ABS_PORT(X+1) */ - {2, 1, 2}, /* map_present[2] = MOD_ABS_PORT(X+2) */ - {2, 1, 3}, /* map_present[3] = MOD_ABS_PORT(X+3) */ - {2, 1, 4}, /* map_present[4] = MOD_ABS_PORT(X+4) */ - {2, 1, 5}, /* map_present[5] = MOD_ABS_PORT(X+5) */ - {2, 1, 6}, /* map_present[6] = MOD_ABS_PORT(X+6) */ - {2, 1, 7}, /* map_present[7] = MOD_ABS_PORT(X+7) */ - }, - .map_reset = { {0, 1, 0}, /* map_reset[0] = QRESET_QSFP28_N_P(X) */ - {0, 1, 1}, /* map_reset[1] = QRESET_QSFP28_N_P(X+1) */ - {0, 1, 2}, /* map_reset[2] = QRESET_QSFP28_N_P(X+2) */ - {0, 1, 3}, /* map_reset[3] = QRESET_QSFP28_N_P(X+3) */ - {0, 1, 4}, /* map_reset[4] = QRESET_QSFP28_N_P(X+4) */ - {0, 1, 5}, /* map_reset[5] = QRESET_QSFP28_N_P(X+5) */ - {0, 1, 6}, /* map_reset[6] = QRESET_QSFP28_N_P(X+6) */ - {0, 1, 7}, /* map_reset[7] = QRESET_QSFP28_N_P(X+7) */ - }, - .map_lpmod = { {1, 0, 0}, /* map_lpmod[0] = LPMODE_QSFP28_P(X) */ - {1, 0, 1}, /* map_lpmod[1] = LPMODE_QSFP28_P(X+1) */ - {1, 0, 2}, /* map_lpmod[2] = LPMODE_QSFP28_P(X+2) */ - {1, 0, 3}, /* map_lpmod[3] = LPMODE_QSFP28_P(X+3) */ - {1, 0, 4}, /* map_lpmod[4] = LPMODE_QSFP28_P(X+4) */ - {1, 0, 5}, /* map_lpmod[5] = LPMODE_QSFP28_P(X+5) */ - {1, 0, 6}, /* map_lpmod[6] = LPMODE_QSFP28_P(X+6) */ - {1, 0, 7}, /* map_lpmod[7] = LPMODE_QSFP28_P(X+7) */ - }, - .map_modsel = { {0, 0, 0}, /* map_modsel[0] = MODSEL_QSFP28_N_P(X) */ - {0, 0, 1}, /* map_modsel[1] = MODSEL_QSFP28_N_P(X+1) */ - {0, 0, 2}, /* map_modsel[2] = MODSEL_QSFP28_N_P(X+2) */ - {0, 0, 3}, /* map_modsel[3] = MODSEL_QSFP28_N_P(X+3) */ - {0, 0, 4}, /* map_modsel[4] = MODSEL_QSFP28_N_P(X+4) */ - {0, 0, 5}, /* map_modsel[5] = MODSEL_QSFP28_N_P(X+5) */ - {0, 0, 6}, /* map_modsel[6] = MODSEL_QSFP28_N_P(X+6) */ - {0, 0, 7}, /* map_modsel[7] = MODSEL_QSFP28_N_P(X+7) */ - }, -}; - - -struct ioexp_map_s ioexp_map_lavender_p65 = { - - .chip_amount = 1, - .data_width = 1, - - .map_present = { {0, 0, 4}, }, /* map_present[0] = MOD_ABS_PORT(X) */ - .map_reset = { {0, 0, 1}, }, /* map_reset[0] = QRESET_QSFP28_N_P(X) */ - .map_lpmod = { {0, 0, 2}, }, /* map_lpmod[0] = LPMODE_QSFP28_P(X) */ - .map_modsel = { {0, 0, 0}, }, /* map_modsel[0] = MODSEL_QSFP28_N_P(X) */ -}; - - -struct ioexp_map_s cpld_map_cottonwood = { - - .chip_amount = 1, - .data_width = 4, - - .map_present = { {0, 2, 0}, /* map_present[0] = MOD_ABS_PORT(X) */ - {0, 2, 4}, /* map_present[1] = MOD_ABS_PORT(X+1) */ - {0, 3, 0}, /* map_present[2] = MOD_ABS_PORT(X+2) */ - {0, 3, 4}, /* map_present[3] = MOD_ABS_PORT(X+3) */ - }, - .map_tx_disable = { {0, 0, 0}, /* map_tx_disable[0] = TXDISABLE_SFP+_P(X) */ - {0, 0, 4}, /* map_tx_disable[1] = TXDISABLE_SFP+_P(X+1) */ - {0, 1, 0}, /* map_tx_disable[2] = TXDISABLE_SFP+_P(X+2) */ - {0, 1, 4}, /* map_tx_disable[3] = TXDISABLE_SFP+_P(X+3) */ - }, - .map_tx_fault = { {0, 2, 2}, /* map_tx_fault[0] = TXFAULT_SFP+_P(X) */ - {0, 2, 6}, /* map_tx_fault[1] = TXFAULT_SFP+_P(X+1) */ - {0, 3, 2}, /* map_tx_fault[2] = TXFAULT_SFP+_P(X+2) */ - {0, 3, 6}, /* map_tx_fault[3] = TXFAULT_SFP+_P(X+3) */ - }, - .map_rxlos = { {0, 2, 1}, /* map_rxlos[0] = OPRXLOS_PORT(X) */ - {0, 2, 5}, /* map_rxlos[1] = OPRXLOS_PORT(X+1) */ - {0, 3, 1}, /* map_rxlos[2] = OPRXLOS_PORT(X+2) */ - {0, 3, 5}, /* map_rxlos[3] = OPRXLOS_PORT(X+3) */ - }, - .map_hard_rs0 = { {0, 0, 2}, /* map_hard_rs0[0] = RS0_SFP28_P(X) */ - {0, 0, 6}, /* map_hard_rs0[1] = RS0_SFP28_P(X+1) */ - {0, 1, 2}, /* map_hard_rs0[2] = RS0_SFP28_P(X+2) */ - {0, 1, 6}, /* map_hard_rs0[3] = RS0_SFP28_P(X+3) */ - }, - .map_hard_rs1 = { {0, 0, 2}, /* map_hard_rs1[0] = RS1_SFP28_P(X) */ - {0, 0, 6}, /* map_hard_rs1[1] = RS1_SFP28_P(X+1) */ - {0, 1, 2}, /* map_hard_rs1[2] = RS1_SFP28_P(X+2) */ - {0, 1, 6}, /* map_hard_rs1[3] = RS1_SFP28_P(X+3) */ - }, -}; - - -struct ioexp_map_s ioexp_map_maple_0abc = { - - .chip_amount = 3, - .data_width = 2, - - .map_present = { {2, 1, 0}, /* map_present[0] = MOD_ABS_PORT(X) */ - {2, 1, 1}, /* map_present[1] = MOD_ABS_PORT(X+1) */ - {2, 1, 2}, /* map_present[2] = MOD_ABS_PORT(X+2) */ - {2, 1, 3}, /* map_present[3] = MOD_ABS_PORT(X+3) */ - {2, 1, 4}, /* map_present[4] = MOD_ABS_PORT(X+4) */ - {2, 1, 5}, /* map_present[5] = MOD_ABS_PORT(X+5) */ - {2, 1, 6}, /* map_present[6] = MOD_ABS_PORT(X+6) */ - {2, 1, 7}, /* map_present[7] = MOD_ABS_PORT(X+7) */ - }, - .map_reset = { {0, 1, 0}, /* map_reset[0] = QRESET_QSFP_N_P(X) */ - {0, 1, 1}, /* map_reset[1] = QRESET_QSFP_N_P(X+1) */ - {0, 1, 2}, /* map_reset[2] = QRESET_QSFP_N_P(X+2) */ - {0, 1, 3}, /* map_reset[3] = QRESET_QSFP_N_P(X+3) */ - {0, 1, 4}, /* map_reset[4] = QRESET_QSFP_N_P(X+4) */ - {0, 1, 5}, /* map_reset[5] = QRESET_QSFP_N_P(X+5) */ - {0, 1, 6}, /* map_reset[6] = QRESET_QSFP_N_P(X+6) */ - {0, 1, 7}, /* map_reset[7] = QRESET_QSFP_N_P(X+7) */ - }, - .map_lpmod = { {1, 0, 0}, /* map_lpmod[0] = LPMODE_QSFP_P(X) */ - {1, 0, 1}, /* map_lpmod[1] = LPMODE_QSFP_P(X+1) */ - {1, 0, 2}, /* map_lpmod[2] = LPMODE_QSFP_P(X+2) */ - {1, 0, 3}, /* map_lpmod[3] = LPMODE_QSFP_P(X+3) */ - {1, 0, 4}, /* map_lpmod[4] = LPMODE_QSFP_P(X+4) */ - {1, 0, 5}, /* map_lpmod[5] = LPMODE_QSFP_P(X+5) */ - {1, 0, 6}, /* map_lpmod[6] = LPMODE_QSFP_P(X+6) */ - {1, 0, 7}, /* map_lpmod[7] = LPMODE_QSFP_P(X+7) */ - }, - .map_modsel = { {0, 0, 0}, /* map_modsel[0] = MODSEL_QSFP_N_P(X) */ - {0, 0, 1}, /* map_modsel[1] = MODSEL_QSFP_N_P(X+1) */ - {0, 0, 2}, /* map_modsel[2] = MODSEL_QSFP_N_P(X+2) */ - {0, 0, 3}, /* map_modsel[3] = MODSEL_QSFP_N_P(X+3) */ - {0, 0, 4}, /* map_modsel[4] = MODSEL_QSFP_N_P(X+4) */ - {0, 0, 5}, /* map_modsel[5] = MODSEL_QSFP_N_P(X+5) */ - {0, 0, 6}, /* map_modsel[6] = MODSEL_QSFP_N_P(X+6) */ - {0, 0, 7}, /* map_modsel[7] = MODSEL_QSFP_N_P(X+7) */ - }, -}; - - -struct ioexp_map_s ioexp_map_maple_nabc = { - - .chip_amount = 3, - .data_width = 2, - - .map_present = { {0, 0, 4}, /* map_present[0] = MOD_ABS_PORT(X) */ - {0, 0, 5}, /* map_present[1] = MOD_ABS_PORT(X+1) */ - {0, 0, 6}, /* map_present[2] = MOD_ABS_PORT(X+2) */ - {0, 0, 7}, /* map_present[3] = MOD_ABS_PORT(X+3) */ - {1, 0, 4}, /* map_present[4] = MOD_ABS_PORT(X+4) */ - {1, 0, 5}, /* map_present[5] = MOD_ABS_PORT(X+5) */ - {1, 0, 6}, /* map_present[6] = MOD_ABS_PORT(X+6) */ - {1, 0, 7}, /* map_present[7] = MOD_ABS_PORT(X+7) */ - }, - .map_tx_disable = { {0, 1, 0}, /* map_tx_disable[0] = TXDISABLE_SFP+_P(X) */ - {0, 1, 1}, /* map_tx_disable[1] = TXDISABLE_SFP+_P(X+1) */ - {0, 1, 2}, /* map_tx_disable[2] = TXDISABLE_SFP+_P(X+2) */ - {0, 1, 3}, /* map_tx_disable[3] = TXDISABLE_SFP+_P(X+3) */ - {1, 1, 0}, /* map_tx_disable[4] = TXDISABLE_SFP+_P(X+4) */ - {1, 1, 1}, /* map_tx_disable[5] = TXDISABLE_SFP+_P(X+5) */ - {1, 1, 2}, /* map_tx_disable[6] = TXDISABLE_SFP+_P(X+6) */ - {1, 1, 3}, /* map_tx_disable[7] = TXDISABLE_SFP+_P(X+7) */ - }, - .map_tx_fault = { {0, 0, 0}, /* map_tx_fault[0] = TXFAULT_SFP+_P(X) */ - {0, 0, 1}, /* map_tx_fault[1] = TXFAULT_SFP+_P(X+1) */ - {0, 0, 2}, /* map_tx_fault[2] = TXFAULT_SFP+_P(X+2) */ - {0, 0, 3}, /* map_tx_fault[3] = TXFAULT_SFP+_P(X+3) */ - {1, 0, 0}, /* map_tx_fault[4] = TXFAULT_SFP+_P(X+4) */ - {1, 0, 1}, /* map_tx_fault[5] = TXFAULT_SFP+_P(X+5) */ - {1, 0, 2}, /* map_tx_fault[6] = TXFAULT_SFP+_P(X+6) */ - {1, 0, 3}, /* map_tx_fault[7] = TXFAULT_SFP+_P(X+7) */ - }, - .map_rxlos = { {0, 1, 4}, /* map_rxlos[0] = OPRXLOS_PORT(X) */ - {0, 1, 5}, /* map_rxlos[1] = OPRXLOS_PORT(X+1) */ - {0, 1, 6}, /* map_rxlos[2] = OPRXLOS_PORT(X+2) */ - {0, 1, 7}, /* map_rxlos[3] = OPRXLOS_PORT(X+3) */ - {1, 1, 4}, /* map_rxlos[4] = OPRXLOS_PORT(X+4) */ - {1, 1, 5}, /* map_rxlos[5] = OPRXLOS_PORT(X+5) */ - {1, 1, 6}, /* map_rxlos[6] = OPRXLOS_PORT(X+6) */ - {1, 1, 7}, /* map_rxlos[7] = OPRXLOS_PORT(X+7) */ - }, - .map_hard_rs0 = { {2, 0, 0}, /* map_hard_rs0[0] = RS0_SFP28_P(X) */ - {2, 0, 2}, /* map_hard_rs0[1] = RS0_SFP28_P(X+1) */ - {2, 0, 4}, /* map_hard_rs0[2] = RS0_SFP28_P(X+2) */ - {2, 0, 6}, /* map_hard_rs0[3] = RS0_SFP28_P(X+3) */ - {2, 1, 0}, /* map_hard_rs0[4] = RS0_SFP28_P(X+4) */ - {2, 1, 2}, /* map_hard_rs0[5] = RS0_SFP28_P(X+5) */ - {2, 1, 4}, /* map_hard_rs0[6] = RS0_SFP28_P(X+6) */ - {2, 1, 6}, /* map_hard_rs0[7] = RS0_SFP28_P(X+7) */ - }, - .map_hard_rs1 = { {2, 0, 1}, /* map_hard_rs1[0] = RS1_SFP28_P(X) */ - {2, 0, 3}, /* map_hard_rs1[1] = RS1_SFP28_P(X+1) */ - {2, 0, 5}, /* map_hard_rs1[2] = RS1_SFP28_P(X+2) */ - {2, 0, 7}, /* map_hard_rs1[3] = RS1_SFP28_P(X+3) */ - {2, 1, 1}, /* map_hard_rs1[4] = RS1_SFP28_P(X+4) */ - {2, 1, 3}, /* map_hard_rs1[5] = RS1_SFP28_P(X+5) */ - {2, 1, 5}, /* map_hard_rs1[6] = RS1_SFP28_P(X+6) */ - {2, 1, 7}, /* map_hard_rs1[7] = RS1_SFP28_P(X+7) */ - }, -}; - - -struct ioexp_map_s ioexp_map_gulmohar_nabc = { - - .chip_amount = 3, - .data_width = 2, - - .map_present = { {0, 0, 4}, /* map_present[0] = MOD_ABS_PORT(X) */ - {0, 0, 5}, /* map_present[1] = MOD_ABS_PORT(X+1) */ - {0, 1, 4}, /* map_present[2] = MOD_ABS_PORT(X+2) */ - {0, 1, 5}, /* map_present[3] = MOD_ABS_PORT(X+3) */ - {1, 0, 4}, /* map_present[4] = MOD_ABS_PORT(X+4) */ - {1, 0, 5}, /* map_present[5] = MOD_ABS_PORT(X+5) */ - {1, 1, 4}, /* map_present[6] = MOD_ABS_PORT(X+6) */ - {1, 1, 5}, /* map_present[7] = MOD_ABS_PORT(X+7) */ - }, - .map_tx_disable = { {0, 0, 2}, /* map_tx_disable[0] = TXDISABLE_SFP+_P(X) */ - {0, 0, 3}, /* map_tx_disable[1] = TXDISABLE_SFP+_P(X+1) */ - {0, 1, 2}, /* map_tx_disable[2] = TXDISABLE_SFP+_P(X+2) */ - {0, 1, 3}, /* map_tx_disable[3] = TXDISABLE_SFP+_P(X+3) */ - {1, 0, 2}, /* map_tx_disable[4] = TXDISABLE_SFP+_P(X+4) */ - {1, 0, 3}, /* map_tx_disable[5] = TXDISABLE_SFP+_P(X+5) */ - {1, 1, 2}, /* map_tx_disable[6] = TXDISABLE_SFP+_P(X+6) */ - {1, 1, 3}, /* map_tx_disable[7] = TXDISABLE_SFP+_P(X+7) */ - }, - .map_tx_fault = { {0, 0, 0}, /* map_tx_fault[0] = TXFAULT_SFP+_P(X) */ - {0, 0, 1}, /* map_tx_fault[1] = TXFAULT_SFP+_P(X+1) */ - {0, 1, 0}, /* map_tx_fault[2] = TXFAULT_SFP+_P(X+2) */ - {0, 1, 1}, /* map_tx_fault[3] = TXFAULT_SFP+_P(X+3) */ - {1, 0, 0}, /* map_tx_fault[4] = TXFAULT_SFP+_P(X+4) */ - {1, 0, 1}, /* map_tx_fault[5] = TXFAULT_SFP+_P(X+5) */ - {1, 1, 0}, /* map_tx_fault[6] = TXFAULT_SFP+_P(X+6) */ - {1, 1, 1}, /* map_tx_fault[7] = TXFAULT_SFP+_P(X+7) */ - }, - .map_rxlos = { {0, 0, 6}, /* map_rxlos[0] = OPRXLOS_PORT(X) */ - {0, 0, 7}, /* map_rxlos[1] = OPRXLOS_PORT(X+1) */ - {0, 1, 6}, /* map_rxlos[2] = OPRXLOS_PORT(X+2) */ - {0, 1, 7}, /* map_rxlos[3] = OPRXLOS_PORT(X+3) */ - {1, 0, 6}, /* map_rxlos[4] = OPRXLOS_PORT(X+4) */ - {1, 0, 7}, /* map_rxlos[5] = OPRXLOS_PORT(X+5) */ - {1, 1, 6}, /* map_rxlos[6] = OPRXLOS_PORT(X+6) */ - {1, 1, 7}, /* map_rxlos[7] = OPRXLOS_PORT(X+7) */ - }, - .map_hard_rs0 = { {2, 0, 0}, /* map_hard_rs0[0] = RS0_SFP28_P(X) */ - {2, 0, 2}, /* map_hard_rs0[1] = RS0_SFP28_P(X+1) */ - {2, 0, 4}, /* map_hard_rs0[2] = RS0_SFP28_P(X+2) */ - {2, 0, 6}, /* map_hard_rs0[3] = RS0_SFP28_P(X+3) */ - {2, 1, 0}, /* map_hard_rs0[4] = RS0_SFP28_P(X+4) */ - {2, 1, 2}, /* map_hard_rs0[5] = RS0_SFP28_P(X+5) */ - {2, 1, 4}, /* map_hard_rs0[6] = RS0_SFP28_P(X+6) */ - {2, 1, 6}, /* map_hard_rs0[7] = RS0_SFP28_P(X+7) */ - }, - .map_hard_rs1 = { {2, 0, 1}, /* map_hard_rs1[0] = RS1_SFP28_P(X) */ - {2, 0, 3}, /* map_hard_rs1[1] = RS1_SFP28_P(X+1) */ - {2, 0, 5}, /* map_hard_rs1[2] = RS1_SFP28_P(X+2) */ - {2, 0, 7}, /* map_hard_rs1[3] = RS1_SFP28_P(X+3) */ - {2, 1, 1}, /* map_hard_rs1[4] = RS1_SFP28_P(X+4) */ - {2, 1, 3}, /* map_hard_rs1[5] = RS1_SFP28_P(X+5) */ - {2, 1, 5}, /* map_hard_rs1[6] = RS1_SFP28_P(X+6) */ - {2, 1, 7}, /* map_hard_rs1[7] = RS1_SFP28_P(X+7) */ - }, -}; - - -struct ioexp_map_s ioexp_map_gulmohar_7abc = { - - .chip_amount = 3, - .data_width = 2, - - .map_present = { {2, 1, 0}, /* map_present[0] = MOD_ABS_PORT(X) */ - {2, 1, 1}, /* map_present[1] = MOD_ABS_PORT(X+1) */ - {2, 1, 2}, /* map_present[2] = MOD_ABS_PORT(X+2) */ - {2, 1, 3}, /* map_present[3] = MOD_ABS_PORT(X+3) */ - {2, 1, 4}, /* map_present[4] = MOD_ABS_PORT(X+4) */ - {2, 1, 5}, /* map_present[5] = MOD_ABS_PORT(X+5) */ - }, - .map_reset = { {0, 1, 0}, /* map_reset[0] = QRESET_QSFP_N_P(X) */ - {0, 1, 1}, /* map_reset[1] = QRESET_QSFP_N_P(X+1) */ - {0, 1, 2}, /* map_reset[2] = QRESET_QSFP_N_P(X+2) */ - {0, 1, 3}, /* map_reset[3] = QRESET_QSFP_N_P(X+3) */ - {0, 1, 4}, /* map_reset[4] = QRESET_QSFP_N_P(X+4) */ - {0, 1, 5}, /* map_reset[5] = QRESET_QSFP_N_P(X+5) */ - }, - .map_lpmod = { {1, 0, 0}, /* map_lpmod[0] = LPMODE_QSFP_P(X) */ - {1, 0, 1}, /* map_lpmod[1] = LPMODE_QSFP_P(X+1) */ - {1, 0, 2}, /* map_lpmod[2] = LPMODE_QSFP_P(X+2) */ - {1, 0, 3}, /* map_lpmod[3] = LPMODE_QSFP_P(X+3) */ - {1, 0, 4}, /* map_lpmod[4] = LPMODE_QSFP_P(X+4) */ - {1, 0, 5}, /* map_lpmod[5] = LPMODE_QSFP_P(X+5) */ - }, - .map_modsel = { {0, 0, 0}, /* map_modsel[0] = MODSEL_QSFP_N_P(X) */ - {0, 0, 1}, /* map_modsel[1] = MODSEL_QSFP_N_P(X+1) */ - {0, 0, 2}, /* map_modsel[2] = MODSEL_QSFP_N_P(X+2) */ - {0, 0, 3}, /* map_modsel[3] = MODSEL_QSFP_N_P(X+3) */ - {0, 0, 4}, /* map_modsel[4] = MODSEL_QSFP_N_P(X+4) */ - {0, 0, 5}, /* map_modsel[5] = MODSEL_QSFP_N_P(X+5) */ - }, -}; - - -/* ========== Private functions ========== - */ -int check_channel_tier_1(void); - -struct i2c_client * -_get_i2c_client(struct ioexp_obj_s *self, - int chip_id){ - - struct ioexp_i2c_s *i2c_curr_p = self->i2c_head_p; - - if (!(i2c_curr_p)){ - SWPS_ERR("%s: i2c_curr_p is NULL\n", __func__); - return NULL; - } - while (i2c_curr_p){ - if ((i2c_curr_p->chip_id) == chip_id){ - return i2c_curr_p->i2c_client_p; - } - i2c_curr_p = i2c_curr_p->next; - } - SWPS_ERR("%s: not exist! :%d\n", __func__, chip_id); - return NULL; -} - - -static int -_common_ioexp_update_one(struct ioexp_obj_s *self, - struct ioexp_addr_s *ioexp_addr, - int chip_id, - int data_width, - int show_err, - char *caller_name) { - int buf = 0; - int err = 0; - int data_id = 0; - int r_offset = 0; - - for(data_id=0; data_idread_offset[data_id]; - buf = i2c_smbus_read_byte_data(_get_i2c_client(self, chip_id), r_offset); - /* Check error */ - if (buf < 0) { - err = 1; - if (show_err) { - SWPS_INFO("IOEXP-%d read fail! :%d \n", self->ioexp_id, buf); - SWPS_INFO("Dump: :%d :0x%02x :%d, :%s\n", - ioexp_addr->chan_id, ioexp_addr->chip_addr, - ioexp_addr->read_offset[data_id], caller_name); - } - continue; - } - /* Update IOEXP object */ - self->chip_data[chip_id].data[data_id] = (uint8_t)buf; - } - if (err) { - return ERR_IOEXP_UNEXCPT; - } - return 0; -} - - -static int -common_ioexp_update_all(struct ioexp_obj_s *self, - int show_err, - char *caller_name){ - - int err = 0; - int chip_id = 0; - int chip_amount = self->ioexp_map_p->chip_amount; - - for (chip_id=0; chip_idioexp_map_p->map_addr[chip_id]), - chip_id, - self->ioexp_map_p->data_width, - show_err, - caller_name) < 0) { - err = 1; - } - } - if (err) { - return ERR_IOEXP_UNEXCPT; - } - return 0; -} - - -static int -_common_check_by_mode(struct ioexp_obj_s *self){ - - switch (self->mode){ - case IOEXP_MODE_DIRECT: - return self->fsm_4_direct(self); - - case IOEXP_MODE_POLLING: - if (self->state >= 0){ - return 0; - } - switch (self->state){ - case STATE_IOEXP_INIT: - return ERR_IOEXP_UNINIT; - case STATE_IOEXP_ABNORMAL: - return ERR_IOEXP_ABNORMAL; - default: - return ERR_IOEXP_NOSTATE; - } - break; - - default: - break; - } - SWPS_ERR("%s: Exception occurs. :%d \n", __func__, self->mode); - return ERR_IOEXP_UNEXCPT; -} - - -static int -_common_get_bit(struct ioexp_obj_s *self, - struct ioexp_bitmap_s *bitmap_obj_p, - char *func_mane){ - uint8_t buf; - int err_code; - - /* Check and get address */ - err_code = _common_check_by_mode(self); - if (err_code < 0){ - return err_code; - } - if (!bitmap_obj_p){ - SWPS_ERR("Layout config incorrect! :%d :%s\n", - self->ioexp_id, func_mane); - return ERR_IOEXP_BADCONF; - } - /* Get data form cache */ - buf = self->chip_data[bitmap_obj_p->chip_id].data[bitmap_obj_p->ioexp_voffset]; - return (int)(buf >> bitmap_obj_p->bit_shift & 0x01); -} - - -static int -_common_set_bit(struct ioexp_obj_s *self, - struct ioexp_bitmap_s *bitmap_obj_p, - int input_val, - char *func_mane){ - int err_code, target_offset; - uint8_t origin_byte; - uint8_t modify_byte; - - /* Check and get address */ - err_code = _common_check_by_mode(self); - if (err_code < 0){ - return err_code; - } - if (!bitmap_obj_p){ - SWPS_ERR("Layout config incorrect! :%d :%s\n", - self->ioexp_id, func_mane); - return ERR_IOEXP_BADCONF; - } - /* Prepare write date */ - origin_byte = self->chip_data[bitmap_obj_p->chip_id].data[bitmap_obj_p->ioexp_voffset]; - switch (input_val) { - case 0: - modify_byte = origin_byte; - SWP_BIT_CLEAR(modify_byte, bitmap_obj_p->bit_shift); - break; - case 1: - modify_byte = origin_byte; - SWP_BIT_SET(modify_byte, bitmap_obj_p->bit_shift); - break; - default: - SWPS_ERR("Input value incorrect! :%d :%d :%s\n", - input_val, self->ioexp_id, func_mane); - return ERR_IOEXP_BADINPUT; - } - /* Setup i2c client */ - target_offset = self->ioexp_map_p->map_addr[bitmap_obj_p->chip_id].write_offset[bitmap_obj_p->ioexp_voffset]; - /* Write byte to chip via I2C */ - err_code = i2c_smbus_write_byte_data(_get_i2c_client(self, bitmap_obj_p->chip_id), - target_offset, - modify_byte); - /* Update or bollback object */ - if (err_code < 0){ - self->chip_data[bitmap_obj_p->chip_id].data[bitmap_obj_p->ioexp_voffset] = origin_byte; - SWPS_ERR("I2C write fail! :%d :%d :%s :%d\n", - input_val, self->ioexp_id, func_mane, err_code); - return err_code; - } - self->chip_data[bitmap_obj_p->chip_id].data[bitmap_obj_p->ioexp_voffset] = modify_byte; - return 0; -} - - -/* ========== Object public functions ========== - */ -int -common_get_present(struct ioexp_obj_s *self, - int virt_offset){ - - int UNPLUG = 1; - int retval = ERR_IOEXP_UNEXCPT; - - retval = _common_get_bit(self, - &(self->ioexp_map_p->map_present[virt_offset]), - "common_get_present"); - if (retval < 0) { - /* [Note] - * => Transceiver object does not need to handle IOEXP layer issues. - */ - return UNPLUG; - } - return retval; -} - - -int -common_get_tx_fault(struct ioexp_obj_s *self, - int virt_offset){ - /* [Transmit Fault (Tx_Fault)] - * A catastrophic laser fault will activate the transmitter signal, - * TX_FAULT, and disable the laser. This signal is an open collector - * output (pull-up required on the host board). A low signal indicates - * normal laser operation and a high signal indicates a fault. The - * TX_FAULT will be latched high when a laser fault occurs and is - * cleared by toggling the TX_DISABLE input or power cycling the - * transceiver. The transmitter fault condition can also be monitored - * via the two-wire serial interface. - * (address A2, byte 110, bit 2). - * - * 0: Normal - * 1: Abnormal - */ - return _common_get_bit(self, - &(self->ioexp_map_p->map_tx_fault[virt_offset]), - "common_get_tx_fault"); -} - - -int -common_get_rxlos(struct ioexp_obj_s *self, - int virt_offset){ - /* [Receiver Loss of Signal (Rx_LOS)] - * The post-amplification IC also includes transition detection circuitry - * which monitors the ac level of incoming optical signals and provides a - * TTL/CMOS compatible status signal to the host (pin 8). An adequate optical - * input results in a low Rx_LOS output while a high Rx_LOS output indicates - * an unusable optical input. The Rx_LOS thresholds are factory set so that - * a high output indicates a definite optical fault has occurred. Rx_LOS can - * also be monitored via the two-wire serial interface - * (address A2h, byte 110, bit 1). - * - * 0: Normal - * 1: Abnormal - */ - return _common_get_bit(self, - &(self->ioexp_map_p->map_rxlos[virt_offset]), - "common_get_rxlos"); -} - - -int -common_get_tx_disable(struct ioexp_obj_s *self, - int virt_offset){ - - return _common_get_bit(self, - &(self->ioexp_map_p->map_tx_disable[virt_offset]), - "common_get_tx_disable"); -} - - -int -common_get_reset(struct ioexp_obj_s *self, - int virt_offset){ - - return _common_get_bit(self, - &(self->ioexp_map_p->map_reset[virt_offset]), - "common_get_reset"); -} - - -int -common_get_lpmod(struct ioexp_obj_s *self, - int virt_offset){ - - return _common_get_bit(self, - &(self->ioexp_map_p->map_lpmod[virt_offset]), - "common_get_lpmod"); -} - - -int -common_get_modsel(struct ioexp_obj_s *self, - int virt_offset){ - - return _common_get_bit(self, - &(self->ioexp_map_p->map_modsel[virt_offset]), - "common_get_modsel"); -} - - -int -common_get_hard_rs0(struct ioexp_obj_s *self, - int virt_offset){ - - return _common_get_bit(self, - &(self->ioexp_map_p->map_hard_rs0[virt_offset]), - "common_get_hard_rs0"); -} - - -int -common_get_hard_rs1(struct ioexp_obj_s *self, - int virt_offset){ - - return _common_get_bit(self, - &(self->ioexp_map_p->map_hard_rs1[virt_offset]), - "common_get_hard_rs1"); -} - - -int -common_set_tx_disable(struct ioexp_obj_s *self, - int virt_offset, - int input_val){ - - return _common_set_bit(self, - &(self->ioexp_map_p->map_tx_disable[virt_offset]), - input_val, - "common_set_tx_disable"); -} - - -int -common_set_reset(struct ioexp_obj_s *self, - int virt_offset, - int input_val){ - - return _common_set_bit(self, - &(self->ioexp_map_p->map_reset[virt_offset]), - input_val, - "common_set_reset"); -} - - -int -common_set_lpmod(struct ioexp_obj_s *self, - int virt_offset, - int input_val){ - - return _common_set_bit(self, - &(self->ioexp_map_p->map_lpmod[virt_offset]), - input_val, - "common_set_lpmod"); -} - - -int -common_set_modsel(struct ioexp_obj_s *self, - int virt_offset, - int input_val){ - - return _common_set_bit(self, - &(self->ioexp_map_p->map_modsel[virt_offset]), - input_val, - "common_set_modsel"); -} - - -int -common_set_hard_rs0(struct ioexp_obj_s *self, - int virt_offset, - int input_val){ - - return _common_set_bit(self, - &(self->ioexp_map_p->map_hard_rs0[virt_offset]), - input_val, - "common_set_hard_rs0"); -} - - -int -common_set_hard_rs1(struct ioexp_obj_s *self, - int virt_offset, - int input_val){ - - return _common_set_bit(self, - &(self->ioexp_map_p->map_hard_rs1[virt_offset]), - input_val, - "common_set_hard_rs1"); -} - - -int -ioexp_get_not_support(struct ioexp_obj_s *self, - int virt_offset){ - return ERR_IOEXP_NOTSUPPORT; -} - - -int -ioexp_set_not_support(struct ioexp_obj_s *self, - int virt_offset, - int input_val){ - return ERR_IOEXP_NOTSUPPORT; -} - - -int -fake_ioexp_init(struct ioexp_obj_s *self){ - return 1; -} - -int -fake_ioexp_update(struct ioexp_obj_s *self){ - return 1; -} - - -int -fake_update_func(struct ioexp_obj_s *self){ - return 1; -} - -int -fake_get_func(struct ioexp_obj_s *self, - int virt_offset){ - SWPS_WARN("Someone called fake_get_func\n"); - return -1; -} - -int -fake_set_func(struct ioexp_obj_s *self, - int virt_offset, - int input_val){ - SWPS_WARN("Someone called fake_set_func\n"); - return -1; -} - - -/* ========== Initial functions for IO Expander ========== - */ -int -common_ioexp_init(struct ioexp_obj_s *self) { - - int chip_id, offset, err_code; - struct ioexp_addr_s *addr_p; - - if (self->mode == IOEXP_MODE_DIRECT) { - goto update_common_ioexp_init; - } - /* Setup default value to each physical IO Expander */ - for (chip_id=0; chip_id<(self->ioexp_map_p->chip_amount); chip_id++){ - /* Get address mapping */ - addr_p = &(self->ioexp_map_p->map_addr[chip_id]); - if (!addr_p){ - SWPS_ERR("%s: IOEXP config incorrect! :%d \n", - __func__, chip_id); - return -1; - } - /* Setup default value */ - for (offset=0; offset<(self->ioexp_map_p->data_width); offset++){ - - /* [Desc] Skip the setup default value behavior - [Note] Setup default value = -1 if you don't want to write the value to IOEXP or CPLD - */ - if(addr_p->write_offset[offset] < 0){ - SWPS_DEBUG("skip a write_offset <%d>\n", addr_p->conf_offset[offset]); - continue; - } - err_code = i2c_smbus_write_byte_data(_get_i2c_client(self, chip_id), - addr_p->write_offset[offset], - addr_p->data_default[offset]); - if (err_code < 0){ - SWPS_ERR("%s: set default fail! :%d \n", - __func__, err_code); - return ERR_IOEXP_UNEXCPT; - } - } - } -update_common_ioexp_init: - /* Check and update info to object */ - err_code = self->update_all(self, 1, "common_ioexp_init"); - if (err_code < 0) { - SWPS_ERR("%s: update_all() fail! :%d \n", - __func__, err_code); - return ERR_IOEXP_UNEXCPT; - } - return 0; -} - - -/* ========== Object functions for Final State Machine ========== - */ -int -_is_channel_ready(struct ioexp_obj_s *self){ - - int buf = 0; - int chip_id = 0; /* Use first chip which be registered */ - int data_id = 0; /* Use first byte which be registered */ - struct ioexp_addr_s *ioexp_addr = NULL; - - ioexp_addr = &(self->ioexp_map_p->map_addr[chip_id]); - if (!ioexp_addr){ - SWPS_ERR("%s: config incorrect!\n", __func__); - return ERR_IOEXP_UNEXCPT; - } - buf = i2c_smbus_read_byte_data(_get_i2c_client(self, chip_id), - ioexp_addr->read_offset[data_id]); - if (buf >= 0){ - return 1; - } - return 0; -} - -int -_ioexp_init_handler(struct ioexp_obj_s *self){ - - int return_val; - - switch (self->mode) { - case IOEXP_MODE_DIRECT: - return_val = self->init(self); - if (return_val < 0){ - self->state = STATE_IOEXP_ABNORMAL; - } else { - self->state = STATE_IOEXP_NORMAL; - } - return return_val; - - case IOEXP_MODE_POLLING: - /* Check system and channel is ready */ - if (self->state == STATE_IOEXP_INIT){ - if (!_is_channel_ready(self)){ - self->state = STATE_IOEXP_INIT; - SWPS_WARN("%s: IOEXP:%d channel not ready.\n", - __func__, self->ioexp_id); - return 0; - } - } - /* Execute initial callback */ - return_val = self->init(self); - if (return_val < 0){ - self->state = STATE_IOEXP_ABNORMAL; - } else { - self->state = STATE_IOEXP_NORMAL; - } - return return_val; - - default: - break; - } - SWPS_ERR("%s: exception occur :%d\n", __func__, self->mode); - return ERR_IOEXP_UNEXCPT; -} - - -int -common_ioexp_fsm_4_direct(struct ioexp_obj_s *self){ - - int result_val; - int show_err = 1; - char *func_mane = "common_ioexp_fsm_4_direct"; - - switch (self->state){ - case STATE_IOEXP_INIT: - result_val = _ioexp_init_handler(self); - /* Exception case: terminate initial procedure */ - if(result_val < 0){ - /* Initial fail */ - return result_val; - } - if(self->state == STATE_IOEXP_INIT){ - /* Keep in INIT state, and return error */ - return ERR_IOEXP_UNINIT; - } - /* Case: Initial done */ - return 0; - - case STATE_IOEXP_NORMAL: - result_val = self->update_all(self, show_err, func_mane); - if (result_val < 0){ - SWPS_INFO("%s: NORMAL -> ABNORMAL :%d\n", - __func__, result_val); - self->state = STATE_IOEXP_ABNORMAL; - return result_val; - } - self->state = STATE_IOEXP_NORMAL; - return 0; - - case STATE_IOEXP_ABNORMAL: - result_val = self->update_all(self, show_err, func_mane); - if (result_val < 0){ - self->state = STATE_IOEXP_ABNORMAL; - return result_val; - } - SWPS_DEBUG("%s: ABNORMAL -> NORMAL :%d\n", - __func__, result_val); - self->state = STATE_IOEXP_NORMAL; - return 0; - - default: - break; - } - SWPS_ERR("%s: Exception occurs :%d\n", - __func__, self->state); - return ERR_IOEXP_UNEXCPT; -} - - -int -common_ioexp_fsm_4_polling(struct ioexp_obj_s *self){ - - int result_val, i, show_e; - int fail_retry = 3; - char *func_name = "common_ioexp_fsm_4_polling"; - -#ifdef DEBUG_SWPS - show_e = 1; -#else - show_e = 0; -#endif - - switch (self->state){ - case STATE_IOEXP_INIT: - result_val = _ioexp_init_handler(self); - /* Exception case: terminate initial procedure */ - if(result_val < 0){ - /* Initial fail */ - return result_val; - } - /* Case: System (Channel) not ready */ - if(self->state == STATE_IOEXP_INIT){ - /* Keep in INIT state, wait and retry */ - return 0; - } - /* Case: Initial done */ - SWPS_INFO("IOEXP-%d: initial done. :%d\n", - self->ioexp_id, self->ioexp_type); - return result_val; - - case STATE_IOEXP_NORMAL: - /* Retry mechanism for case of i2c topology not stable */ - for (i=0; iupdate_all(self, show_e, func_name); - if (result_val >= 0) { - self->state = STATE_IOEXP_NORMAL; - return 0; - } - if (check_channel_tier_1() < 0) { - SWPS_INFO("%s: detect I2C crash :%d\n", - __func__, self->ioexp_id); - break; - } - SWPS_DEBUG("IOEXP-%d: unstable :%d\n", - self->ioexp_id, result_val); - } - SWPS_INFO("IOEXP-%d: NORMAL -> ABNORMAL :%d\n", - self->ioexp_id, result_val); - self->state = STATE_IOEXP_ABNORMAL; - return result_val; - - case STATE_IOEXP_ABNORMAL: - result_val = self->update_all(self, show_e, func_name); - if (result_val < 0){ - self->state = STATE_IOEXP_ABNORMAL; - return result_val; - } - SWPS_INFO("IOEXP-%d: ABNORMAL -> NORMAL :%d\n", - self->ioexp_id, result_val); - self->state = STATE_IOEXP_NORMAL; - return 0; - - default: - break; - } - SWPS_ERR("IOEXP-%d: Exception occurs :%d\n", - self->ioexp_id, self->state); - return ERR_IOEXP_UNEXCPT; -} - - -/* ========== Object private functions for check & update ========== - */ -int -common_ioexp_check(struct ioexp_obj_s *self){ - - int result; - - if (self->mode != IOEXP_MODE_POLLING){ - SWPS_ERR("%s: not polling mode :%d\n", - __func__, self->mode); - return ERR_IOEXP_NOTSUPPORT; - } - mutex_lock(&self->lock); - result = self->fsm_4_polling(self); - mutex_unlock(&self->lock); - return result; -} - - -/* ========== Functions for Factory pattern ========== - */ -static struct ioexp_map_s * -get_ioexp_map(int ioexp_type){ - switch (ioexp_type){ - case IOEXP_TYPE_MAGINOLIA_NAB: - return &ioexp_map_magnolia_nab; - case IOEXP_TYPE_MAGINOLIA_4AB: - return &ioexp_map_magnolia_4ab; - case IOEXP_TYPE_MAGINOLIA_7AB: - case IOEXP_TYPE_SPRUCE_7AB: - return &ioexp_map_magnolia_7ab; - case IOEXP_TYPE_REDWOOD_P01P08: - return &ioexp_map_redwood_p01p08_p17p24; - case IOEXP_TYPE_REDWOOD_P09P16: - return &ioexp_map_redwood_p09p16_p25p32; - case IOEXP_TYPE_HUDSON32IGA_P01P08: - return &ioexp_map_hudson32iga_p01p08_p17p24; - case IOEXP_TYPE_HUDSON32IGA_P09P16: - return &ioexp_map_hudson32iga_p09p16_p25p32; - case IOEXP_TYPE_CYPRESS_NABC: - return &ioexp_map_cypress_nabc; - case IOEXP_TYPE_CYPRESS_7ABC: - return &ioexp_map_cypress_7abc; - case IOEXP_TYPE_TAHOE_5A: - return &ioexp_map_tahoe_5a; - case IOEXP_TYPE_TAHOE_6ABC: - return &ioexp_map_tahoe_6abc; - case IOEXP_TYPE_SEQUOIA_NABC: - return &ioexp_map_sequoia_nabc; - case IOEXP_TYPE_LAVENDER_P65: - return &ioexp_map_lavender_p65; - case CPLD_TYPE_COTTONWOOD: - return &cpld_map_cottonwood; - case IOEXP_TYPE_MAPLE_0ABC: - return &ioexp_map_maple_0abc; - case IOEXP_TYPE_MAPLE_NABC: - return &ioexp_map_maple_nabc; - case IOEXP_TYPE_GULMOHAR_NABC: - return &ioexp_map_gulmohar_nabc; - case IOEXP_TYPE_GULMOHAR_7ABC: - return &ioexp_map_gulmohar_7abc; - default: - return NULL; - } -} - - -int -setup_ioexp_ssize_attr(struct ioexp_obj_s *self, - struct ioexp_map_s *ioexp_map_p, - int ioexp_id, - int ioexp_type, - int run_mode){ - switch (run_mode){ - case IOEXP_MODE_POLLING: /* Direct access device mode */ - case IOEXP_MODE_DIRECT: /* Polling mode, read from cache */ - self->mode = run_mode; - break; - default: - SWPS_ERR("%s: non-defined run_mode:%d\n", - __func__, run_mode); - self->mode = ERR_IOEXP_UNEXCPT; - return ERR_IOEXP_UNEXCPT; - } - /* Setup mapping structure */ - self->ioexp_map_p = kzalloc(sizeof(*ioexp_map_p), GFP_KERNEL); - if (!(self->ioexp_map_p)) { - SWPS_ERR("%s: kzalloc ioexp_map_p fail\n", __func__); - return -1; - } - memcpy(self->ioexp_map_p, ioexp_map_p, sizeof(*ioexp_map_p)); - /* Setup attributes */ - self->ioexp_id = ioexp_id; - self->ioexp_type = ioexp_type; - self->state = STATE_IOEXP_INIT; - mutex_init(&self->lock); - return 0; -} - - -static int -setup_addr_mapping(struct ioexp_obj_s *self, - struct ioexp_addr_s *addr_map_p, - int chip_amount){ - struct ioexp_addr_s *tmp_p; - if (!addr_map_p){ - SWPS_ERR("%s: map is null\n", __func__); - return -1; - } - tmp_p = kzalloc((sizeof(*addr_map_p) * chip_amount), GFP_KERNEL); - if (!tmp_p){ - SWPS_ERR("%s: kzalloc fail.\n", __func__); - return -1; - } - memcpy(tmp_p, addr_map_p, (sizeof(*addr_map_p) * chip_amount)); - self->ioexp_map_p->map_addr = tmp_p; - - return 0; -} - - -static int -setup_ioexp_public_cb(struct ioexp_obj_s *self, - int ioexp_type){ - - switch (ioexp_type){ - case IOEXP_TYPE_MAGINOLIA_NAB: - case IOEXP_TYPE_MAGINOLIA_4AB: - case CPLD_TYPE_COTTONWOOD: - self->get_present = common_get_present; - self->get_tx_fault = common_get_tx_fault; - self->get_rxlos = common_get_rxlos; - self->get_tx_disable = common_get_tx_disable; - self->get_reset = ioexp_get_not_support; - self->get_lpmod = ioexp_get_not_support; - self->get_modsel = ioexp_get_not_support; - self->get_hard_rs0 = ioexp_get_not_support; - self->get_hard_rs1 = ioexp_get_not_support; - self->set_tx_disable = common_set_tx_disable; - self->set_reset = ioexp_set_not_support; - self->set_lpmod = ioexp_set_not_support; - self->set_modsel = ioexp_set_not_support; - self->set_hard_rs0 = ioexp_set_not_support; - self->set_hard_rs1 = ioexp_set_not_support; - return 0; - case IOEXP_TYPE_CYPRESS_NABC: - case IOEXP_TYPE_MAPLE_NABC: - case IOEXP_TYPE_GULMOHAR_NABC: - self->get_present = common_get_present; - self->get_tx_fault = common_get_tx_fault; - self->get_rxlos = common_get_rxlos; - self->get_tx_disable = common_get_tx_disable; - self->get_reset = ioexp_get_not_support; - self->get_lpmod = ioexp_get_not_support; - self->get_modsel = ioexp_get_not_support; - self->get_hard_rs0 = common_get_hard_rs0; - self->get_hard_rs1 = common_get_hard_rs1; - self->set_tx_disable = common_set_tx_disable; - self->set_reset = ioexp_set_not_support; - self->set_lpmod = ioexp_set_not_support; - self->set_modsel = ioexp_set_not_support; - self->set_hard_rs0 = common_set_hard_rs0; - self->set_hard_rs1 = common_set_hard_rs1; - return 0; - case IOEXP_TYPE_MAGINOLIA_7AB: - case IOEXP_TYPE_SPRUCE_7AB: - case IOEXP_TYPE_REDWOOD_P01P08: - case IOEXP_TYPE_REDWOOD_P09P16: - case IOEXP_TYPE_HUDSON32IGA_P01P08: - case IOEXP_TYPE_HUDSON32IGA_P09P16: - case IOEXP_TYPE_CYPRESS_7ABC: - case IOEXP_TYPE_TAHOE_5A: - case IOEXP_TYPE_TAHOE_6ABC: - case IOEXP_TYPE_SEQUOIA_NABC: - case IOEXP_TYPE_LAVENDER_P65: - case IOEXP_TYPE_MAPLE_0ABC: - case IOEXP_TYPE_GULMOHAR_7ABC: - self->get_present = common_get_present; - self->get_tx_fault = ioexp_get_not_support; - self->get_rxlos = ioexp_get_not_support; - self->get_tx_disable = ioexp_get_not_support; - self->get_reset = common_get_reset; - self->get_lpmod = common_get_lpmod; - self->get_modsel = common_get_modsel; - self->get_hard_rs0 = ioexp_get_not_support; - self->get_hard_rs1 = ioexp_get_not_support; - self->set_tx_disable = ioexp_set_not_support; - self->set_reset = common_set_reset; - self->set_lpmod = common_set_lpmod; - self->set_modsel = common_set_modsel; - self->set_hard_rs0 = ioexp_set_not_support; - self->set_hard_rs1 = ioexp_set_not_support; - return 0; - - default: - SWPS_ERR("%s: type:%d incorrect!\n", __func__, ioexp_type); - break; - } - return ERR_IOEXP_UNEXCPT; -} - - -static int -setup_ioexp_private_cb(struct ioexp_obj_s *self, - int ioexp_type){ - - switch (ioexp_type){ - case IOEXP_TYPE_MAGINOLIA_NAB: - case IOEXP_TYPE_MAGINOLIA_4AB: - case IOEXP_TYPE_MAGINOLIA_7AB: - case IOEXP_TYPE_SPRUCE_7AB: - case IOEXP_TYPE_REDWOOD_P01P08: - case IOEXP_TYPE_REDWOOD_P09P16: - case IOEXP_TYPE_HUDSON32IGA_P01P08: - case IOEXP_TYPE_HUDSON32IGA_P09P16: - case IOEXP_TYPE_CYPRESS_NABC: - case IOEXP_TYPE_CYPRESS_7ABC: - case IOEXP_TYPE_TAHOE_5A: - case IOEXP_TYPE_TAHOE_6ABC: - case IOEXP_TYPE_SEQUOIA_NABC: - case IOEXP_TYPE_LAVENDER_P65: - case CPLD_TYPE_COTTONWOOD: - case IOEXP_TYPE_MAPLE_NABC: - case IOEXP_TYPE_MAPLE_0ABC: - case IOEXP_TYPE_GULMOHAR_NABC: - case IOEXP_TYPE_GULMOHAR_7ABC: - self->init = common_ioexp_init; - self->check = common_ioexp_check; - self->update_all = common_ioexp_update_all; - self->fsm_4_direct = common_ioexp_fsm_4_direct; - self->fsm_4_polling = common_ioexp_fsm_4_polling; - return 0; - - default: - SWPS_ERR("%s: type:%d incorrect!\n", __func__, ioexp_type); - break; - } - return ERR_IOEXP_UNEXCPT; -} - - -static int -setup_i2c_client_one(struct ioexp_obj_s *self, - int chip_id){ - - char *err_msg = "ERROR"; - struct i2c_adapter *adap = NULL; - struct i2c_client *client = NULL; - struct ioexp_i2c_s *i2c_obj_p = NULL; - struct ioexp_i2c_s *i2c_curr_p = NULL; - - int chan_id = self->ioexp_map_p->map_addr[chip_id].chan_id; - adap = i2c_get_adapter(chan_id); - if(!adap){ - err_msg = "Can not get adap!"; - goto err_ioexp_setup_i2c_1; - } - client = kzalloc(sizeof(*client), GFP_KERNEL); - if (!client){ - err_msg = "Can not kzalloc client!"; - goto err_ioexp_setup_i2c_1; - } - i2c_obj_p = kzalloc(sizeof(*i2c_obj_p), GFP_KERNEL); - if (!i2c_obj_p){ - err_msg = "Can not kzalloc i2c_obj_p!"; - goto err_ioexp_setup_i2c_2; - } - client->adapter = adap; - client->addr = self->ioexp_map_p->map_addr[chip_id].chip_addr; - i2c_obj_p->i2c_client_p = client; - i2c_obj_p->chip_id = chip_id; - i2c_obj_p->next = NULL; - if (!self->i2c_head_p){ - self->i2c_head_p = i2c_obj_p; - } else { - i2c_curr_p = self->i2c_head_p; - while (i2c_curr_p->next){ - i2c_curr_p = i2c_curr_p->next; - } - i2c_curr_p->next = i2c_obj_p; - } - return 0; - -err_ioexp_setup_i2c_2: - kfree(client); -err_ioexp_setup_i2c_1: - SWPS_ERR("%s: %s :%d\n", __func__, err_msg, chan_id); - return -1; -} - - -static int -setup_i2c_client(struct ioexp_obj_s* self){ - - int result; - int chip_id = 0; - - for (chip_id=0; chip_id<(self->ioexp_map_p->chip_amount); chip_id++){ - result = setup_i2c_client_one(self, chip_id); - if (result < 0){ - SWPS_ERR("%s fail! :%d\n", __func__, chip_id); - return -1; - } - } - return 0; -} - - -static int -setup_ioexp_config(struct ioexp_obj_s *self) { - - int chip_id, offset, err_code; - struct ioexp_addr_s *addr_p; - - for (chip_id=0; chip_id<(self->ioexp_map_p->chip_amount); chip_id++){ - addr_p = &(self->ioexp_map_p->map_addr[chip_id]); - if (!addr_p){ - SWPS_ERR("IOEXP config incorrect! :%d \n",chip_id); - return -1; - } - for (offset=0; offset<(self->ioexp_map_p->data_width); offset++){ - - /* [Desc] Skip the setup config value behavior - [Note] Setup config value = -1 if you don't want to write the value to IOEXP or CPLD - */ - if(addr_p->conf_offset[offset] < 0){ - SWPS_DEBUG("skip a config_offset <%d>\n", addr_p->conf_offset[offset]); - continue; - } - err_code = i2c_smbus_write_byte_data(_get_i2c_client(self, chip_id), - addr_p->conf_offset[offset], - addr_p->conf_default[offset]); - - if (err_code < 0){ - SWPS_INFO("%s: set conf fail! :%d \n", __func__, err_code); - return -2; - } - } - } - return 0; -} - - -struct ioexp_obj_s * -_create_ioexp_obj(int ioexp_id, - int ioexp_type, - struct ioexp_addr_s *addr_map_p, - int run_mode){ - - struct ioexp_map_s* ioexp_map_p; - struct ioexp_obj_s* result_p; - struct ioexp_i2c_s *i2c_curr_p; - struct ioexp_i2c_s *i2c_next_p; - - /* Get layout */ - ioexp_map_p = get_ioexp_map(ioexp_type); - if (!ioexp_map_p){ - SWPS_ERR("%s: Invalid ioexp_type\n", __func__); - goto err_create_ioexp_fail; - } - /* Prepare IOEXP object */ - result_p = kzalloc(sizeof(*result_p), GFP_KERNEL); - if (!result_p){ - SWPS_ERR("%s: kzalloc failure!\n", __func__); - goto err_create_ioexp_fail; - } - /* Prepare static size attributes */ - if (setup_ioexp_ssize_attr(result_p, - ioexp_map_p, - ioexp_id, - ioexp_type, - run_mode) < 0){ - goto err_create_ioexp_setup_attr_fail; - } - /* Prepare address mapping */ - if (setup_addr_mapping(result_p, addr_map_p, ioexp_map_p->chip_amount) < 0){ - goto err_create_ioexp_setup_attr_fail; - } - if (setup_i2c_client(result_p) < 0){ - goto err_create_ioexp_setup_i2c_fail; - } - /* Prepare call back functions of object */ - if (setup_ioexp_public_cb(result_p, ioexp_type) < 0){ - goto err_create_ioexp_setup_i2c_fail; - } - if (setup_ioexp_private_cb(result_p, ioexp_type) < 0){ - goto err_create_ioexp_setup_i2c_fail; - } - return result_p; - -err_create_ioexp_setup_i2c_fail: - i2c_curr_p = result_p->i2c_head_p; - i2c_next_p = result_p->i2c_head_p; - while (i2c_curr_p){ - i2c_next_p = i2c_curr_p->next; - kfree(i2c_curr_p->i2c_client_p); - kfree(i2c_curr_p); - i2c_curr_p = i2c_next_p; - } -err_create_ioexp_setup_attr_fail: - kfree(result_p); -err_create_ioexp_fail: - SWPS_ERR("%s: fail! :%d :%d \n", - __func__, ioexp_id, ioexp_type); - return NULL; -} - - -int -create_ioexp_obj(int ioexp_id, - int ioexp_type, - struct ioexp_addr_s *addr_map_p, - int run_mode){ - - struct ioexp_obj_s *ioexp_p = NULL; - - ioexp_p = _create_ioexp_obj(ioexp_id, ioexp_type, - addr_map_p, run_mode); - if (!ioexp_p){ - return -1; - } - if (ioexp_head_p == NULL){ - ioexp_head_p = ioexp_p; - ioexp_tail_p = ioexp_p; - return 0; - } - ioexp_tail_p->next = ioexp_p; - ioexp_tail_p = ioexp_p; - return 0; -} -EXPORT_SYMBOL(create_ioexp_obj); - - -static int -_init_ioexp_obj(struct ioexp_obj_s* self) { - - char *err_msg = "ERR"; - char *func_name = "_init_ioexp_obj"; - - /* Setup IOEXP configure byte */ - if (setup_ioexp_config(self) < 0){ - err_msg = "setup_ioexp_config fail"; - goto err_init_ioexp_obj; - } - /* Setup default data */ - if (_ioexp_init_handler(self) < 0){ - err_msg = "_ioexp_init_handler fail"; - goto err_init_ioexp_obj; - } - /* Update all */ - if (self->state == STATE_IOEXP_NORMAL){ - if (self->update_all(self, 1, func_name) < 0){ - err_msg = "update_all() fail"; - goto err_init_ioexp_obj; - } - } - return 0; - -err_init_ioexp_obj: - SWPS_DEBUG("%s: %s\n", __func__, err_msg); - return -1; -} - - -int -init_ioexp_objs(void){ - /* Return value: - * 0: Success - * -1: Detect topology error - * -2: SWPS internal error - */ - - struct ioexp_obj_s *curr_p = ioexp_head_p; - - if (!curr_p) { - SWPS_ERR("%s: ioexp_head_p is NULL\n", __func__); - return -2; - } - while (curr_p) { - if (_init_ioexp_obj(curr_p) < 0) { - SWPS_DEBUG("%s: _init_ioexp_obj() fail\n", __func__); - return -1; - } - curr_p = curr_p->next; - } - SWPS_DEBUG("%s: done.\n", __func__); - return 0; -} -EXPORT_SYMBOL(init_ioexp_objs); - - -void -clean_ioexp_objs(void){ - - struct ioexp_i2c_s *i2c_curr_p = NULL; - struct ioexp_i2c_s *i2c_next_p = NULL; - struct ioexp_obj_s *ioexp_next_p = NULL; - struct ioexp_obj_s *ioexp_curr_p = ioexp_head_p; - - if (ioexp_head_p == NULL){ - ioexp_tail_p = NULL; - return; - } - while(ioexp_curr_p){ - ioexp_next_p = ioexp_curr_p->next; - if (ioexp_curr_p->ioexp_map_p) { - if (ioexp_curr_p->ioexp_map_p->map_addr) { - kfree(ioexp_curr_p->ioexp_map_p->map_addr); - } - kfree(ioexp_curr_p->ioexp_map_p); - } - - i2c_curr_p = ioexp_curr_p->i2c_head_p; - while (i2c_curr_p) { - i2c_next_p = i2c_curr_p->next; - kfree(i2c_curr_p->i2c_client_p); - kfree(i2c_curr_p); - i2c_curr_p = i2c_next_p; - } - kfree(ioexp_curr_p); - ioexp_curr_p = ioexp_next_p; - } - ioexp_tail_p = NULL; - SWPS_DEBUG("%s: done.\n", __func__); -} -EXPORT_SYMBOL(clean_ioexp_objs); - - -int -check_ioexp_objs(void){ - - struct ioexp_obj_s *ioexp_curr_p = ioexp_head_p; - - while (ioexp_curr_p){ - if ( (ioexp_curr_p->check(ioexp_curr_p)) < 0){ - SWPS_INFO("check IOEXP-%d fail! :%d\n", - ioexp_curr_p->ioexp_id, ioexp_curr_p->ioexp_type); - return -1; - } - ioexp_curr_p = ioexp_curr_p->next; - } - return 0; -} -EXPORT_SYMBOL(check_ioexp_objs); - - -struct ioexp_obj_s * -get_ioexp_obj(int ioexp_id){ - - struct ioexp_obj_s *result_p = NULL; - struct ioexp_obj_s *ioexp_curr_p = ioexp_head_p; - - while(ioexp_curr_p){ - if (ioexp_curr_p->ioexp_id == ioexp_id){ - result_p = ioexp_curr_p; - break; - } - ioexp_curr_p = ioexp_curr_p->next; - } - return result_p; -} -EXPORT_SYMBOL(get_ioexp_obj); - - -void -unlock_ioexp_all(void) { - - struct ioexp_obj_s *ioexp_curr_p = ioexp_head_p; - - while(ioexp_curr_p){ - mutex_unlock(&ioexp_curr_p->lock); - ioexp_curr_p = ioexp_curr_p->next; - } -} -EXPORT_SYMBOL(unlock_ioexp_all); - -int -lock_ioexp_all(void) { - - struct ioexp_obj_s *ioexp_curr_p = ioexp_head_p; - - while(ioexp_curr_p){ - mutex_lock(&ioexp_curr_p->lock); - ioexp_curr_p = ioexp_curr_p->next; - } - return 0; -} -EXPORT_SYMBOL(lock_ioexp_all); - - -int -check_channel_tier_1(void) { - - if ( (!_is_channel_ready(ioexp_head_p)) && - (!_is_channel_ready(ioexp_tail_p)) ){ - return -1; - } - return 0; -} -EXPORT_SYMBOL(check_channel_tier_1); - - -static int -_scan_channel_tier_1(int force, - int show_err) { - - struct ioexp_obj_s *ioexp_curr_p = ioexp_head_p; - int ready = 0; - - if (!ioexp_curr_p) { - goto err_scan_tier_1_channel; - } - while(ioexp_curr_p) { - ready = _is_channel_ready(ioexp_curr_p); - if ((!ready) && (!force)) { - goto err_scan_tier_1_channel; - } - ioexp_curr_p = ioexp_curr_p->next; - } - return 0; - -err_scan_tier_1_channel: - if (show_err) { - if (ioexp_curr_p) { - SWPS_INFO("%s: IOEXP-%d fail\n", __func__, ioexp_curr_p->ioexp_id); - } else { - SWPS_INFO("%s: IOEXP is null.\n", __func__); - } - } - return -1; -} - - -static int -_scan_channel_tier_1_single(void) { - - int ret = 0; - int chan_id = 0; - int fake_cid = 0; - int fake_offs = 0; - int fake_addr = 0; - struct i2c_adapter *adap = NULL; - struct i2c_client *client = NULL; - - if (ioexp_head_p->ioexp_id != ioexp_tail_p->ioexp_id) { - return 0; - } - /* Setup i2c_client */ - chan_id = ioexp_head_p->ioexp_map_p->map_addr[fake_cid].chan_id; - fake_addr = ioexp_head_p->ioexp_map_p->map_addr[fake_cid].chip_addr; - adap = i2c_get_adapter((chan_id + 1)); - if(!adap){ - SWPS_INFO("%s: Can not get adap!\n", __func__); - return 0; - } - client = kzalloc(sizeof(*client), GFP_KERNEL); - if (!client){ - SWPS_INFO("%s: Can not kzalloc client!\n", __func__); - return 0; - } - client->adapter = adap; - client->addr = fake_addr; - /* Fouce move ioexp ptr to next */ - ret = i2c_smbus_read_byte_data(client, fake_offs); - SWPS_DEBUG("%s: move ioexp_ptr done. :%d\n", __func__, ret); - kfree(client); - return 1; -} - - -int -resync_channel_tier_1(void) { - - char *emsg = "ERR"; - - if (!ioexp_head_p) { - emsg = "ioexp_head_p is NULL"; - goto err_resync_ioexp_status_1; - } - /* Run all */ - if (ioexp_head_p->ioexp_id == ioexp_tail_p->ioexp_id) { - _scan_channel_tier_1_single(); - } else { - _scan_channel_tier_1(1, 0); - } - /* Check all */ - if (_scan_channel_tier_1(0, 1) < 0) { - emsg = "resync tier-1 channel fail"; - goto err_resync_ioexp_status_1; - } - return 0; - -err_resync_ioexp_status_1: - SWPS_ERR("%s: %s\n", __func__, emsg); - return -1; -} -EXPORT_SYMBOL(resync_channel_tier_1); - - -/* For build single module using (Ex: ONL platform) */ -MODULE_LICENSE("GPL"); - - diff --git a/packages/platforms/inventec/x86-64/d5254/modules/builds/src/io_expander.h b/packages/platforms/inventec/x86-64/d5254/modules/builds/src/io_expander.h deleted file mode 100644 index 2f241d034..000000000 --- a/packages/platforms/inventec/x86-64/d5254/modules/builds/src/io_expander.h +++ /dev/null @@ -1,183 +0,0 @@ -#ifndef IO_EXPANDER_H -#define IO_EXPANDER_H - -#include - - -/* IOEXP type define (SFP series) */ -#define IOEXP_TYPE_MAGINOLIA_NAB (10101) -#define IOEXP_TYPE_MAGINOLIA_4AB (10102) -#define IOEXP_TYPE_CYPRESS_NABC (10103) -#define IOEXP_TYPE_MAPLE_NABC (10104) -#define IOEXP_TYPE_GULMOHAR_NABC (10105) - -/* IOEXP type define (QSFP series) */ -#define IOEXP_TYPE_MAGINOLIA_7AB (10201) -#define IOEXP_TYPE_REDWOOD_P01P08 (10202) -#define IOEXP_TYPE_REDWOOD_P09P16 (10203) -#define IOEXP_TYPE_HUDSON32IGA_P01P08 (10204) -#define IOEXP_TYPE_HUDSON32IGA_P09P16 (10205) -#define IOEXP_TYPE_SPRUCE_7AB (10206) -#define IOEXP_TYPE_CYPRESS_7ABC (10207) -#define IOEXP_TYPE_TAHOE_5A (10208) -#define IOEXP_TYPE_TAHOE_6ABC (10209) -#define IOEXP_TYPE_SEQUOIA_NABC (10210) -#define IOEXP_TYPE_LAVENDER_P65 (10211) -#define IOEXP_TYPE_MAPLE_0ABC (10212) -#define IOEXP_TYPE_GULMOHAR_7ABC (10213) - -/* CPLD type define */ -#define CPLD_TYPE_COTTONWOOD (10301) - -/* IOEXP mode define */ -#define IOEXP_MODE_POLLING (19000) -#define IOEXP_MODE_DIRECT (19001) - -/* IOEXP state define */ -#define STATE_IOEXP_NORMAL (0) -#define STATE_IOEXP_INIT (-1) -#define STATE_IOEXP_ABNORMAL (-2) - -/* IOEXP error code define */ -#define ERR_IOEXP_NOTSUPPORT (-100) -#define ERR_IOEXP_UNINIT (-101) -#define ERR_IOEXP_BADCONF (-102) -#define ERR_IOEXP_ABNORMAL (-103) -#define ERR_IOEXP_NOSTATE (-104) -#define ERR_IOEXP_BADINPUT (-105) -#define ERR_IOEXP_UNEXCPT (-199) - -#define SWPS_INFO(fmt, args...) printk( KERN_INFO "[SWPS] " fmt, ##args) -#define SWPS_WARN(fmt, args...) printk( KERN_WARNING "[SWPS] " fmt, ##args) -#define SWPS_ERR(fmt, args...) printk( KERN_ERR "[SWPS] " fmt, ##args) - -#ifdef DEBUG_SWPS -# define SWPS_DEBUG(fmt, args...) printk( KERN_DEBUG "[SWPS] " fmt, ##args) -#else -# define SWPS_DEBUG(fmt, args...) -#endif - - -struct ioexp_addr_s { - int chan_id; - int chip_addr; - int read_offset[8]; - int write_offset[8]; - int conf_offset[8]; - uint8_t data_default[8]; - uint8_t conf_default[8]; -}; - -struct ioexp_i2c_s { - int chip_id; - struct i2c_client *i2c_client_p; - struct ioexp_i2c_s *next; -}; - - -struct ioexp_bitmap_s { - int chip_id; /* IOEXP chip id */ - int ioexp_voffset; /* IOEXP virtual offset */ - int bit_shift; -}; - -struct ioexp_map_s { - int chip_amount; /* Number of chips that IOEXP object content */ - int data_width; /* Number of (Read/Write/Config) bytes */ - struct ioexp_addr_s *map_addr; /* Chip address info */ - struct ioexp_bitmap_s map_present[10]; /* IOEXP for SFP / QSFP */ - struct ioexp_bitmap_s map_tx_disable[10]; /* IOEXP for SFP */ - struct ioexp_bitmap_s map_tx_fault[10]; /* IOEXP for SFP */ - struct ioexp_bitmap_s map_rxlos[10]; /* IOEXP for SFP */ - struct ioexp_bitmap_s map_reset[10]; /* IOEXP for QSFP */ - struct ioexp_bitmap_s map_lpmod[10]; /* IOEXP for QSFP */ - struct ioexp_bitmap_s map_modsel[10]; /* IOEXP for QSFP */ - struct ioexp_bitmap_s map_hard_rs0[10]; /* IOEXP for QSFP */ - struct ioexp_bitmap_s map_hard_rs1[10]; /* IOEXP for QSFP */ -}; - -struct ioexp_data_s { - uint8_t data[8]; -}; - -struct ioexp_obj_s { - - /* ============================ - * Object public property - * ============================ - */ - int ioexp_id; - int ioexp_type; - - /* ============================ - * Object private property - * ============================ - */ - struct ioexp_data_s chip_data[16]; /* Max: 8-ioexp in one virt-ioexp(ioexp_obj) */ - struct ioexp_map_s *ioexp_map_p; - struct ioexp_obj_s *next; - struct ioexp_i2c_s *i2c_head_p; - struct mutex lock; - int mode; - int state; - - /* =========================================== - * Object public functions - * =========================================== - */ - int (*get_present)(struct ioexp_obj_s *self, int virt_offset); - int (*get_tx_fault)(struct ioexp_obj_s *self, int virt_offset); - int (*get_rxlos)(struct ioexp_obj_s *self, int virt_offset); - int (*get_tx_disable)(struct ioexp_obj_s *self, int virt_offset); - int (*get_reset)(struct ioexp_obj_s *self, int virt_offset); - int (*get_lpmod)(struct ioexp_obj_s *self, int virt_offset); - int (*get_modsel)(struct ioexp_obj_s *self, int virt_offset); - int (*get_hard_rs0)(struct ioexp_obj_s *self, int virt_offset); - int (*get_hard_rs1)(struct ioexp_obj_s *self, int virt_offset); - int (*set_tx_disable)(struct ioexp_obj_s *self, int virt_offset, int input_val); - int (*set_reset)(struct ioexp_obj_s *self, int virt_offset, int input_val); - int (*set_lpmod)(struct ioexp_obj_s *self, int virt_offset, int input_val); - int (*set_modsel)(struct ioexp_obj_s *self, int virt_offset, int input_val); - int (*set_hard_rs0)(struct ioexp_obj_s *self, int virt_offset, int input_val); - int (*set_hard_rs1)(struct ioexp_obj_s *self, int virt_offset, int input_val); - - /* =========================================== - * Object private functions - * =========================================== - */ - int (*init)(struct ioexp_obj_s *self); - int (*check)(struct ioexp_obj_s *self); - int (*update_all)(struct ioexp_obj_s *self, int show_err, char *caller_name); - int (*fsm_4_direct)(struct ioexp_obj_s* self); - int (*fsm_4_polling)(struct ioexp_obj_s* self); -}; - - -struct ioexp_obj_s* get_ioexp_obj(int ioexp_id); -int create_ioexp_obj(int ioexp_id, - int ioexp_type, - struct ioexp_addr_s *addr_map_p, - int run_mode); -int init_ioexp_objs(void); -int check_ioexp_objs(void); -void clean_ioexp_objs(void); - -void unlock_ioexp_all(void); -int lock_ioexp_all(void); - -int check_channel_tier_1(void); -int resync_channel_tier_1(void); - -/* Macro for bit control */ -#define SWP_BIT_SET(byte_val,bit_shift) ((byte_val) |= (1<<(bit_shift))) -#define SWP_BIT_CLEAR(byte_val,bit_shift) ((byte_val) &= ~(1<<(bit_shift))) - - -#endif /* IO_EXPANDER_H */ - - - - - - - diff --git a/packages/platforms/inventec/x86-64/d5254/modules/builds/src/onie_tlvinfo.c b/packages/platforms/inventec/x86-64/d5254/modules/builds/src/onie_tlvinfo.c deleted file mode 100644 index 303ffde76..000000000 --- a/packages/platforms/inventec/x86-64/d5254/modules/builds/src/onie_tlvinfo.c +++ /dev/null @@ -1,820 +0,0 @@ -#include -#include -#include -#include -//#include -#include - -//#include -//#include -#include "onie_tlvinfo.h" - -/* Set to 1 if we've read EEPROM into memory */ -static int has_been_read = 0; - -int read_sys_eeprom(struct i2c_client *pi2c_client,void *eeprom_data, int offset, int len); -int write_sys_eeprom(struct i2c_client *pi2c_client, void *eeprom_data, int len); - -static inline int is_multicast_ether_addr(const u_int8_t *addr) -{ - return 0x01 & addr[0]; -} - -static inline int is_zero_ether_addr(const u_int8_t *addr) -{ - return !(addr[0] | addr[1] | addr[2] | addr[3] | addr[4] | addr[5]); -} - -static inline int is_valid_ether_addr(const u_int8_t *addr) -{ - return !is_multicast_ether_addr(addr) && !is_zero_ether_addr(addr); -} - -#if 0 -static unsigned int crc32(unsigned char const *p, unsigned int len) -{ - int i; - unsigned int crc = 0; - while (len--) { - crc ^= *p++; - for (i = 0; i < 8; i++) - crc = (crc >> 1) ^ ((crc & 1) ? 0xedb88320 : 0); - } - return crc; -} -#else -static unsigned long crc32_tab[] = { - 0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f, - 0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988, - 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91, 0x1db71064, 0x6ab020f2, - 0xf3b97148, 0x84be41de, 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7, - 0x136c9856, 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, 0x14015c4f, 0x63066cd9, - 0xfa0f3d63, 0x8d080df5, 0x3b6e20c8, 0x4c69105e, 0xd56041e4, 0xa2677172, - 0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b, 0x35b5a8fa, 0x42b2986c, - 0xdbbbc9d6, 0xacbcf940, 0x32d86ce3, 0x45df5c75, 0xdcd60dcf, 0xabd13d59, - 0x26d930ac, 0x51de003a, 0xc8d75180, 0xbfd06116, 0x21b4f4b5, 0x56b3c423, - 0xcfba9599, 0xb8bda50f, 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924, - 0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d, 0x76dc4190, 0x01db7106, - 0x98d220bc, 0xefd5102a, 0x71b18589, 0x06b6b51f, 0x9fbfe4a5, 0xe8b8d433, - 0x7807c9a2, 0x0f00f934, 0x9609a88e, 0xe10e9818, 0x7f6a0dbb, 0x086d3d2d, - 0x91646c97, 0xe6635c01, 0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e, - 0x6c0695ed, 0x1b01a57b, 0x8208f4c1, 0xf50fc457, 0x65b0d9c6, 0x12b7e950, - 0x8bbeb8ea, 0xfcb9887c, 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, 0xfbd44c65, - 0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2, 0x4adfa541, 0x3dd895d7, - 0xa4d1c46d, 0xd3d6f4fb, 0x4369e96a, 0x346ed9fc, 0xad678846, 0xda60b8d0, - 0x44042d73, 0x33031de5, 0xaa0a4c5f, 0xdd0d7cc9, 0x5005713c, 0x270241aa, - 0xbe0b1010, 0xc90c2086, 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f, - 0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, 0x59b33d17, 0x2eb40d81, - 0xb7bd5c3b, 0xc0ba6cad, 0xedb88320, 0x9abfb3b6, 0x03b6e20c, 0x74b1d29a, - 0xead54739, 0x9dd277af, 0x04db2615, 0x73dc1683, 0xe3630b12, 0x94643b84, - 0x0d6d6a3e, 0x7a6a5aa8, 0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1, - 0xf00f9344, 0x8708a3d2, 0x1e01f268, 0x6906c2fe, 0xf762575d, 0x806567cb, - 0x196c3671, 0x6e6b06e7, 0xfed41b76, 0x89d32be0, 0x10da7a5a, 0x67dd4acc, - 0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5, 0xd6d6a3e8, 0xa1d1937e, - 0x38d8c2c4, 0x4fdff252, 0xd1bb67f1, 0xa6bc5767, 0x3fb506dd, 0x48b2364b, - 0xd80d2bda, 0xaf0a1b4c, 0x36034af6, 0x41047a60, 0xdf60efc3, 0xa867df55, - 0x316e8eef, 0x4669be79, 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236, - 0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f, 0xc5ba3bbe, 0xb2bd0b28, - 0x2bb45a92, 0x5cb36a04, 0xc2d7ffa7, 0xb5d0cf31, 0x2cd99e8b, 0x5bdeae1d, - 0x9b64c2b0, 0xec63f226, 0x756aa39c, 0x026d930a, 0x9c0906a9, 0xeb0e363f, - 0x72076785, 0x05005713, 0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38, - 0x92d28e9b, 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21, 0x86d3d2d4, 0xf1d4e242, - 0x68ddb3f8, 0x1fda836e, 0x81be16cd, 0xf6b9265b, 0x6fb077e1, 0x18b74777, - 0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c, 0x8f659eff, 0xf862ae69, - 0x616bffd3, 0x166ccf45, 0xa00ae278, 0xd70dd2ee, 0x4e048354, 0x3903b3c2, - 0xa7672661, 0xd06016f7, 0x4969474d, 0x3e6e77db, 0xaed16a4a, 0xd9d65adc, - 0x40df0b66, 0x37d83bf0, 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9, - 0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605, 0xcdd70693, - 0x54de5729, 0x23d967bf, 0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94, - 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d -}; - -static unsigned long crc32(unsigned char const *buf, unsigned int size) -{ - unsigned char *p = buf; - unsigned long crc = 0; - - crc = crc ^ ~0U; - - while (size--) - crc = crc32_tab[(crc ^ *p++) & 0xFF] ^ (crc >> 8); - - return crc ^ ~0U; -} -#endif - -static int set_bytes(char *buf, const char *string, int * converted_accum) -{ - char *p = (char *) string; - int i; - uint byte; - - if (!p) { - printk("ERROR: NULL string passed in.\n"); - return -1; - } - /* Convert string to bytes */ - for (i = 0, p = (char *)string; (i < TLV_VALUE_MAX_LEN) && (*p != 0); - i++) { - while ((*p == ' ') || (*p == '\t') || (*p == ',') || - (*p == ';')) { - p++; - } - if (*p != 0) { - if (!isdigit(*p)) { - printk("ERROR: Non-digit found in byte string: (%s)\n", string); - return -1; - } - byte = strtoul(p, &p, 0); - if (byte >= 256) { - printk("ERROR: The value specified is greater than 255: (%u) " \ - "in string: %s\n", byte, string); - return -1; - } - buf[i] = byte & 0xFF; - } - } - if ((i == TLV_VALUE_MAX_LEN) && (*p != 0)) { - printk("ERROR: Trying to assign too many bytes " - "(max: %d) in string: %s\n", TLV_VALUE_MAX_LEN, string); - return -1; - } - *converted_accum = i; - return 0; -} - -/* - * set_date - * - * Validates the format of the data string - * - * This function takes a pointer to a date string (i.e. MM/DD/YYYY hh:mm:ss) - * and validates that the format is correct. If so the string is copied - * to the supplied buffer. - */ -static int set_date(char *buf, const char *string) -{ - int i; - - if (!string) { - printk("ERROR: NULL date string passed in.\n"); - return -1; - } - if (strlen(string) != 19) { - printk("ERROR: Date strlen() != 19 -- %d\n", strlen(string)); - printk("ERROR: Bad date format (MM/DD/YYYY hh:mm:ss): %s\n", string); - return -1; - } - for (i = 0; string[i] != 0; i++) { - switch (i) { - case 2: - case 5: - if (string[i] != '/') { - printk("ERROR: Bad date format (MM/DD/YYYY hh:mm:ss): %s\n", - string); - return -1; - } - break; - case 10: - if (string[i] != ' ') { - printk("ERROR: Bad date format (MM/DD/YYYY hh:mm:ss): %s\n", - string); - return -1; - } - break; - case 13: - case 16: - if (string[i] != ':') { - printk("ERROR: Bad date format (MM/DD/YYYY hh:mm:ss): %s\n", - string); - return -1; - } - break; - default: - if (!isdigit(string[i])) { - printk("ERROR: Bad date format (MM/DD/YYYY hh:mm:ss): %s\n", - string); - return -1; - } - break; - } - } - strcpy(buf, string); - return 0; -} - -/* - * is_valid_tlv - * - * Perform basic sanity checks on a TLV field. The TLV is pointed to - * by the parameter provided. - * 1. The type code is not reserved (0x00 or 0xFF) - */ -static inline bool is_valid_tlv(tlvinfo_tlv_t *tlv) -{ - return((tlv->type != 0x00) && (tlv->type != 0xFF)); -} - -/* - * set_mac - * - * Converts a string MAC address into a binary buffer. - * - * This function takes a pointer to a MAC address string - * (i.e."XX:XX:XX:XX:XX:XX", where "XX" is a two-digit hex number). - * The string format is verified and then converted to binary and - * stored in a buffer. - */ -static int set_mac(char *buf, const char *string) -{ - char *p = (char *) string; - int i; - int err = 0; - char *end; - - if (!p) { - printk("ERROR: NULL mac addr string passed in.\n"); - return -1; - } - if (strlen(p) != 17) { - printk("ERROR: MAC address strlen() != 17 -- %d\n", strlen(p)); - printk("ERROR: Bad MAC address format: %s\n", string); - return -1; - } - for (i = 0; i < 17; i++) { - if ((i % 3) == 2) { - if (p[i] != ':') { - err++; - printk("ERROR: mac: p[%i] != :, found: `%c'\n", - i, p[i]); - break; - } - continue; - } else if (!isxdigit(p[i])) { - err++; - printk("ERROR: mac: p[%i] != hex digit, found: `%c'\n", - i, p[i]); - break; - } - } - if (err != 0) { - printk("ERROR: Bad MAC address format: %s\n", string); - return -1; - } - /* Convert string to binary */ - for (i = 0, p = (char *)string; i < 6; i++) { - buf[i] = p ? strtoul(p, &end, 16) : 0; - if (p) { - p = (*end) ? end + 1 : end; - } - } - if (!is_valid_ether_addr((char *)buf)) { - printk("ERROR: MAC address must not be 00:00:00:00:00:00, " - "a multicast address or FF:FF:FF:FF:FF:FF.\n"); - printk("ERROR: Bad MAC address format: %s\n", string); - return -1; - } - return 0; -} - -/* - * is_valid_tlvinfo_header - * - * Perform sanity checks on the first 11 bytes of the TlvInfo EEPROM - * data pointed to by the parameter: - * 1. First 8 bytes contain null-terminated ASCII string "TlvInfo" - * 2. Version byte is 1 - * 3. Total length bytes contain value which is less than or equal - * to the allowed maximum (2048-11) - * - */ -static inline bool is_valid_tlvinfo_header(tlvinfo_header_t *hdr) -{ - int max_size = TLV_TOTAL_LEN_MAX; - return((strcmp(hdr->signature, TLV_INFO_ID_STRING) == 0) && - (hdr->version == TLV_INFO_VERSION) && - (be16_to_cpu(hdr->totallen) <= max_size) ); -} - -/* - * decode_tlv_value - * - * Decode a single TLV value into a string. - - * The validity of EEPROM contents and the TLV field have been verified - * prior to calling this function. - */ -#define DECODE_NAME_MAX 20 - -static void decode_tlv_value(tlvinfo_tlv_t * tlv, char* value) -{ - int i; - - switch (tlv->type) { - case TLV_CODE_PRODUCT_NAME: - case TLV_CODE_PART_NUMBER: - case TLV_CODE_SERIAL_NUMBER: - case TLV_CODE_MANUF_DATE: - case TLV_CODE_LABEL_REVISION: - case TLV_CODE_PLATFORM_NAME: - case TLV_CODE_ONIE_VERSION: - case TLV_CODE_MANUF_NAME: - case TLV_CODE_MANUF_COUNTRY: - case TLV_CODE_VENDOR_NAME: - case TLV_CODE_DIAG_VERSION: - case TLV_CODE_SERVICE_TAG: - memcpy(value, tlv->value, tlv->length); - value[tlv->length] = 0; - break; - case TLV_CODE_MAC_BASE: - snprintf(value, MAX_STRING_SIZE, "%02X:%02X:%02X:%02X:%02X:%02X", - tlv->value[0], tlv->value[1], tlv->value[2], - tlv->value[3], tlv->value[4], tlv->value[5]); - break; - case TLV_CODE_DEVICE_VERSION: - snprintf(value, MAX_STRING_SIZE, "%u", tlv->value[0]); - break; - case TLV_CODE_MAC_SIZE: - snprintf(value, MAX_STRING_SIZE, "%u", (tlv->value[0] << 8) | tlv->value[1]); - break; - case TLV_CODE_VENDOR_EXT: - value[0] = 0; - for (i = 0; (i < (TLV_DECODE_VALUE_MAX_LEN/5)) && (i < tlv->length); - i++) { - snprintf(value, MAX_STRING_SIZE, "%s 0x%02X", value, tlv->value[i]); - } - break; - case TLV_CODE_CRC_32: - snprintf(value, MAX_STRING_SIZE, "0x%02X%02X%02X%02X", - tlv->value[0], tlv->value[1], tlv->value[2], - tlv->value[3]); - break; - default: - value[0] = 0; - for (i = 0; (i < (TLV_DECODE_VALUE_MAX_LEN/5)) && (i < tlv->length); - i++) { - snprintf(value, MAX_STRING_SIZE, "%s 0x%02X", value, tlv->value[i]); - } - break; - } - -} - -/* - * is_checksum_valid - * - * Validate the checksum in the provided TlvInfo EEPROM data. First, - * verify that the TlvInfo header is valid, then make sure the last - * TLV is a CRC-32 TLV. Then calculate the CRC over the EEPROM data - * and compare it to the value stored in the EEPROM CRC-32 TLV. - */ -static bool is_checksum_valid(u_int8_t *eeprom) -{ - tlvinfo_header_t * eeprom_hdr = (tlvinfo_header_t *) eeprom; - tlvinfo_tlv_t * eeprom_crc; - unsigned int calc_crc; - unsigned int stored_crc; - - // Is the eeprom header valid? - if (!is_valid_tlvinfo_header(eeprom_hdr)) { - return(FALSE); - } - - // Is the last TLV a CRC? - eeprom_crc = (tlvinfo_tlv_t *) &eeprom[sizeof(tlvinfo_header_t) + - be16_to_cpu(eeprom_hdr->totallen) - - (sizeof(tlvinfo_tlv_t) + 4)]; - if ((eeprom_crc->type != TLV_CODE_CRC_32) || (eeprom_crc->length != 4)) { - return(FALSE); - } - - // Calculate the checksum - calc_crc = crc32((void *)eeprom, sizeof(tlvinfo_header_t) + - be16_to_cpu(eeprom_hdr->totallen) - 4); - stored_crc = ((eeprom_crc->value[0] << 24) | (eeprom_crc->value[1] << 16) | - (eeprom_crc->value[2] << 8) | eeprom_crc->value[3]); - - //printk(KERN_ERR "[SWPS] cal_crc =0x%x, stored_crc =0x%x\n", calc_crc, stored_crc); - //return(calc_crc == stored_crc); - return 1; -} - -/* - * update_crc - * - * This function updates the CRC-32 TLV. If there is no CRC-32 TLV, then - * one is added. This function should be called after each update to the - * EEPROM structure, to make sure the CRC is always correct. - */ -static void update_crc(u_int8_t *eeprom) -{ - tlvinfo_header_t * eeprom_hdr = (tlvinfo_header_t *) eeprom; - tlvinfo_tlv_t * eeprom_crc; - unsigned int calc_crc; - - // Is the eeprom header valid? - if (!is_valid_tlvinfo_header(eeprom_hdr)) { - return; - } - // Is the last TLV a CRC? - eeprom_crc = (tlvinfo_tlv_t *) &eeprom[sizeof(tlvinfo_header_t) + - be16_to_cpu(eeprom_hdr->totallen) - - (sizeof(tlvinfo_tlv_t) + 4)]; - if (eeprom_crc->type != TLV_CODE_CRC_32) { - if ((be16_to_cpu(eeprom_hdr->totallen) + sizeof(tlvinfo_tlv_t) + 4) > - TLV_TOTAL_LEN_MAX) { - return; - } - eeprom_crc = (tlvinfo_tlv_t *) &eeprom[sizeof(tlvinfo_header_t) + - be16_to_cpu( - eeprom_hdr->totallen)]; - eeprom_hdr->totallen = cpu_to_be16(be16_to_cpu(eeprom_hdr->totallen) + - sizeof(tlvinfo_tlv_t) + 4); - eeprom_crc->type = TLV_CODE_CRC_32; - } - eeprom_crc->length = 4; - - // Calculate the checksum - calc_crc = crc32((void *)eeprom, - sizeof(tlvinfo_header_t) + - be16_to_cpu(eeprom_hdr->totallen) - 4); - - eeprom_crc->value[0] = (calc_crc >> 24) & 0xFF; - eeprom_crc->value[1] = (calc_crc >> 16) & 0xFF; - eeprom_crc->value[2] = (calc_crc >> 8) & 0xFF; - eeprom_crc->value[3] = (calc_crc >> 0) & 0xFF; -} - -/* - * show_eeprom - * - * Display the contents of the EEPROM - */ - -/* - * read_eeprom - * - * Read the EEPROM into memory, if it hasn't already been read. - */ -int read_eeprom( struct i2c_client *pi2c_client, u_int8_t *eeprom) -{ - int ret; - tlvinfo_header_t *eeprom_hdr = (tlvinfo_header_t *) eeprom; - tlvinfo_tlv_t *eeprom_tlv = (tlvinfo_tlv_t *)&eeprom[ - sizeof(tlvinfo_header_t)]; - - if (has_been_read) - return 0; - - /* Read the header */ - ret = read_sys_eeprom( pi2c_client,(void *)eeprom_hdr, 0, sizeof(tlvinfo_header_t)); - /* If the header was successfully read, read the TLVs */ - if ((ret == 0) && is_valid_tlvinfo_header(eeprom_hdr)) { - ret = read_sys_eeprom( pi2c_client, (void *)eeprom_tlv, sizeof(tlvinfo_header_t), - be16_to_cpu(eeprom_hdr->totallen)); - } - // If the contents are invalid, start over with default contents - if(!is_valid_tlvinfo_header(eeprom_hdr)) - printk(KERN_ERR - "Notice: Invalid TLV header found. Using default contents--1.\n"); - if(!is_checksum_valid(eeprom)) - printk(KERN_ERR - "Notice: Invalid TLV checksum found. Using default contents--2.\n"); - if ( !is_valid_tlvinfo_header(eeprom_hdr) || !is_checksum_valid(eeprom) ){ - strcpy(eeprom_hdr->signature, TLV_INFO_ID_STRING); - eeprom_hdr->version = TLV_INFO_VERSION; - eeprom_hdr->totallen = cpu_to_be16(0); - update_crc(eeprom); - } - has_been_read = 1; - - return ret; -} -EXPORT_SYMBOL(read_eeprom); - -/* - * prog_eeprom - * Write the EEPROM data from CPU memory to the hardware. - */ -int prog_eeprom(struct i2c_client *pi2c_client, u_int8_t * eeprom) -{ - int ret = 0; - tlvinfo_header_t * eeprom_hdr = (tlvinfo_header_t *) eeprom; - int eeprom_len; - - eeprom_len = sizeof(tlvinfo_header_t) + be16_to_cpu(eeprom_hdr->totallen); - ret = write_sys_eeprom( pi2c_client, eeprom, eeprom_len); - if (ret) { - printk("Programming failed.\n"); - return -1; - } - has_been_read = 0; - return 0; -} -EXPORT_SYMBOL(prog_eeprom); - -/* - * tlvinfo_find_tlv - * - * This function finds the TLV with the supplied code in the EERPOM. - * An offset from the beginning of the EEPROM is returned in the - * eeprom_index parameter if the TLV is found. - */ -bool tlvinfo_find_tlv(u_int8_t *eeprom, u_int8_t tcode, - int *eeprom_index) -{ - tlvinfo_header_t * eeprom_hdr = (tlvinfo_header_t *) eeprom; - tlvinfo_tlv_t * eeprom_tlv; - int eeprom_end; - - // Make sure the EEPROM contents are valid - if (!is_valid_tlvinfo_header(eeprom_hdr) || !is_checksum_valid(eeprom)) { - return(FALSE); - } - // Search through the TLVs, looking for the first one which matches the - // supplied type code. - *eeprom_index = sizeof(tlvinfo_header_t); - eeprom_end = sizeof(tlvinfo_header_t) + be16_to_cpu(eeprom_hdr->totallen); - - while (*eeprom_index < eeprom_end) { - eeprom_tlv = (tlvinfo_tlv_t *) &eeprom[*eeprom_index]; - if (!is_valid_tlv(eeprom_tlv)) { - return(FALSE); - } - if (eeprom_tlv->type == tcode) { - return(TRUE); - } - *eeprom_index += sizeof(tlvinfo_tlv_t) + eeprom_tlv->length; - } - return(FALSE); -} - -/* - * tlvinfo_decode_tlv - * - * This function finds the TLV with the supplied code in the EERPOM - * and decodes the value into the buffer provided. - */ -bool tlvinfo_decode_tlv(u_int8_t *eeprom, u_int8_t tcode, char* value) -{ - int eeprom_index; - tlvinfo_tlv_t * eeprom_tlv; - - // Find the TLV and then decode it - - if (tlvinfo_find_tlv(eeprom, tcode, &eeprom_index)) { - eeprom_tlv = (tlvinfo_tlv_t *) &eeprom[eeprom_index]; - decode_tlv_value(eeprom_tlv, value); - return TRUE; - } - - return FALSE; -} -EXPORT_SYMBOL(tlvinfo_decode_tlv); - -/* - * tlvinfo_delete_tlv - * - * This function deletes the TLV with the specified type code from the - * EEPROM. - */ -bool tlvinfo_delete_tlv(u_int8_t * eeprom, u_int8_t code) -{ - int eeprom_index; - int tlength; - tlvinfo_header_t * eeprom_hdr = (tlvinfo_header_t *) eeprom; - tlvinfo_tlv_t * eeprom_tlv; - - // Find the TLV and then move all following TLVs "forward" - if (tlvinfo_find_tlv(eeprom, code, &eeprom_index)) { - eeprom_tlv = (tlvinfo_tlv_t *) &eeprom[eeprom_index]; - tlength = sizeof(tlvinfo_tlv_t) + eeprom_tlv->length; - memcpy(&eeprom[eeprom_index], &eeprom[eeprom_index+tlength], - sizeof(tlvinfo_header_t) + be16_to_cpu(eeprom_hdr->totallen) - - eeprom_index - tlength); - eeprom_hdr->totallen = cpu_to_be16(be16_to_cpu(eeprom_hdr->totallen) - - tlength); - update_crc(eeprom); - return(TRUE); - } - return(FALSE); -} -EXPORT_SYMBOL(tlvinfo_delete_tlv); - -/* - * tlvinfo_add_tlv - * - * This function adds a TLV to the EEPROM, converting the value (a string) to - * the format in which it will be stored in the EEPROM. - */ -#define MAX_TLV_VALUE_LEN 256 -bool tlvinfo_add_tlv(u_int8_t * eeprom, int tcode, char * strval) -{ - tlvinfo_header_t * eeprom_hdr = (tlvinfo_header_t *) eeprom; - tlvinfo_tlv_t * eeprom_tlv; - int new_tlv_len = 0; - u_int32_t value; - char data[MAX_TLV_VALUE_LEN]; - int eeprom_index; - int max_size = TLV_TOTAL_LEN_MAX; - - // Encode each TLV type into the format to be stored in the EERPOM - switch (tcode) { - case TLV_CODE_PRODUCT_NAME: - case TLV_CODE_PART_NUMBER: - case TLV_CODE_SERIAL_NUMBER: - case TLV_CODE_LABEL_REVISION: - case TLV_CODE_PLATFORM_NAME: - case TLV_CODE_ONIE_VERSION: - case TLV_CODE_MANUF_NAME: - case TLV_CODE_MANUF_COUNTRY: - case TLV_CODE_VENDOR_NAME: - case TLV_CODE_DIAG_VERSION: - case TLV_CODE_SERVICE_TAG: - strncpy(data, strval, MAX_TLV_VALUE_LEN); - - if( strlen(strval) >= MAX_TLV_VALUE_LEN ) - new_tlv_len = MAX_TLV_VALUE_LEN; - else - new_tlv_len = strlen(strval); - - break; - case TLV_CODE_DEVICE_VERSION: - value = strtoul(strval, NULL, 0); - if (value >= 256) { - printk("ERROR: Device version must be 255 or less. Value " \ - "supplied: %u", value); - return(FALSE); - } - data[0] = value & 0xFF; - new_tlv_len = 1; - break; - case TLV_CODE_MAC_SIZE: - value = strtoul(strval, NULL, 0); - if (value >= 65536) { - printk("ERROR: MAC Size must be 65535 or less. Value " \ - "supplied: %u", value); - return(FALSE); - } - data[0] = (value >> 8) & 0xFF; - data[1] = value & 0xFF; - new_tlv_len = 2; - break; - case TLV_CODE_MANUF_DATE: - if (set_date(data, strval) != 0) { - return(FALSE); - } - new_tlv_len = 19; - break; - case TLV_CODE_MAC_BASE: - if (set_mac(data, strval) != 0) { - return(FALSE); - } - new_tlv_len = 6; - break; - case TLV_CODE_CRC_32: - printk("WARNING: The CRC TLV is set automatically and cannot be set " \ - "manually.\n"); - return(FALSE); - case TLV_CODE_VENDOR_EXT: - default: - if (set_bytes(data, strval, &new_tlv_len) != 0 ) { - return(FALSE); - } - break; - } - - // Is there room for this TLV? - if ((be16_to_cpu(eeprom_hdr->totallen) + sizeof(tlvinfo_tlv_t) + - new_tlv_len) > max_size) { - printk("ERROR: There is not enough room in the EERPOM to save data.\n"); - return(FALSE); - } - - // Add TLV at the end, overwriting CRC TLV if it exists - if (tlvinfo_find_tlv(eeprom, TLV_CODE_CRC_32, &eeprom_index)) { - eeprom_hdr->totallen = cpu_to_be16(be16_to_cpu(eeprom_hdr->totallen) - - sizeof(tlvinfo_tlv_t) - 4); - } else { - eeprom_index = sizeof(tlvinfo_header_t) + - be16_to_cpu(eeprom_hdr->totallen); - } - eeprom_tlv = (tlvinfo_tlv_t *) &eeprom[eeprom_index]; - eeprom_tlv->type = tcode; - eeprom_tlv->length = new_tlv_len; - memcpy(eeprom_tlv->value, data, new_tlv_len); - - // Update the total length and calculate (add) a new CRC-32 TLV - eeprom_hdr->totallen = cpu_to_be16(be16_to_cpu(eeprom_hdr->totallen) + - sizeof(tlvinfo_tlv_t) + new_tlv_len); - update_crc(eeprom); - - return(TRUE); -} -EXPORT_SYMBOL(tlvinfo_add_tlv); - -/* - * read_sys_eeprom - read the hwinfo from i2c EEPROM - */ -int read_sys_eeprom(struct i2c_client *pi2c_client,void *eeprom_data, int offset, int len) -{ - int iRet = 0; - int i = 0; - unsigned char ucBuf[2]; - u_int8_t *c; - unsigned short usAddr = SYS_EEPROM_OFFSET + offset; - - c = eeprom_data; - for (i = 0; i < len; i++) { - ucBuf[0] = (usAddr & 0xFF00) >> 8; - ucBuf[1] = (usAddr & 0x00FF); - - iRet = i2c_smbus_write_byte_data(pi2c_client, ucBuf[0], ucBuf[1]); - if( iRet < 0 ){ - printk(KERN_ERR"Error!! VPD data read error\n"); - return -1; - } - - *c = i2c_smbus_read_byte(pi2c_client); - c++; usAddr++; - } - return 0; -} - -/* - * write_sys_eeprom - write the hwinfo to i2c EEPROM - */ -int write_sys_eeprom(struct i2c_client *pi2c_client, void *eeprom_data, int len) -{ - int iRet = 0; - int i = 0; - u_int8_t *c; - unsigned short usAddr = SYS_EEPROM_OFFSET; - unsigned char ucBuf[3]; - - c = eeprom_data; - for (i = 0; i < len; i++) { - ucBuf[ 0 ] = (usAddr & 0xFF00) >>8 ; - ucBuf[ 1 ] = (usAddr & 0x00FF); - ucBuf[ 2 ] = *c; - - iRet = i2c_smbus_write_word_data( pi2c_client, ucBuf[0], (ucBuf[2] << 8 | ucBuf[1])); - if (iRet < 0 ){ - printk(KERN_ERR"Error!! VPD data write error . \n"); - return -1; - } - - c++; usAddr++; - msleep_interruptible(10); - } - - return 0; -} - -void update_eeprom_header(u_int8_t *eeprom) -{ - tlvinfo_header_t * eeprom_hdr = (tlvinfo_header_t *) eeprom; - - strcpy(eeprom_hdr->signature, TLV_INFO_ID_STRING); - eeprom_hdr->version = TLV_INFO_VERSION; - eeprom_hdr->totallen = cpu_to_be16(0); - update_crc(eeprom); -} -#if 0 -int find_vpd_data(u_int8_t *eeprom, int i_offset, char *c_buf) -{ - int tlv_end; - int curr_tlv; - tlvinfo_header_t * eeprom_hdr = (tlvinfo_header_t *) eeprom; - tlvinfo_tlv_t * eeprom_tlv; - int iFind = 0; - - if( !is_valid_tlvinfo_header(eeprom_hdr) ) { - printk(KERN_ERR"EEPROM does not contain data in a valid TlvInfo format.\n"); - return -1; - } - - curr_tlv = sizeof(tlvinfo_header_t); - tlv_end = sizeof(tlvinfo_header_t) + be16_to_cpu(eeprom_hdr->totallen); - while(curr_tlv < tlv_end){ - eeprom_tlv = (tlvinfo_tlv_t *) &eeprom[curr_tlv]; - if (!is_valid_tlv(eeprom_tlv)) { - printk(KERN_ERR"Invalid TLV field starting at EEPROM offset %d\n", - curr_tlv); - return -1; - } - - decode_tlv_value(eeprom_tlv, c_buf); - if( eeprom_tlv->type == i_offset){ - iFind = 1; - break; - } - curr_tlv += sizeof(tlvinfo_tlv_t) + eeprom_tlv->length; - } - - if( iFind == 0 ) - return -1; - else - return 0; -} -#endif diff --git a/packages/platforms/inventec/x86-64/d5254/modules/builds/src/onie_tlvinfo.h b/packages/platforms/inventec/x86-64/d5254/modules/builds/src/onie_tlvinfo.h deleted file mode 100644 index 74f3c9604..000000000 --- a/packages/platforms/inventec/x86-64/d5254/modules/builds/src/onie_tlvinfo.h +++ /dev/null @@ -1,150 +0,0 @@ -/* - * The Definition of the TlvInfo EEPROM format can be found at onie.org or - * github.com/onie - */ -#include -#define strtoul simple_strtoul - -#define FALSE 0 -#define TRUE (!FALSE) -#define MAX_STRING_SIZE 128 -/* - * Tlvinf header: Layout of the header for the TlvInfo format - * - * See the end of this file for details of this eeprom format - */ -struct __attribute__ ((__packed__)) tlvinfo_header_s { - char signature[8]; /* 0x00 - 0x07 EEPROM Tag "TlvInfo" */ - u_int8_t version; /* 0x08 Structure version */ - u_int16_t totallen; /* 0x09 - 0x0A Length of all data which follows */ -}; -typedef struct tlvinfo_header_s tlvinfo_header_t; - -// Header Field Constants -#define TLV_INFO_ID_STRING "TlvInfo" -#define TLV_INFO_VERSION 0x01 -#define TLV_TOTAL_LEN_MAX (SYS_EEPROM_SIZE - sizeof(tlvinfo_header_t)) - -/* - * TlvInfo TLV: Layout of a TLV field - */ -struct __attribute__ ((__packed__)) tlvinfo_tlv_s { - u_int8_t type; - u_int8_t length; - u_int8_t value[0]; -}; -typedef struct tlvinfo_tlv_s tlvinfo_tlv_t; - -/* Maximum length of a TLV value in bytes */ -#define TLV_VALUE_MAX_LEN 255 - -/** - * The TLV Types. - * - * Keep these in sync with tlv_code_list in cmd_sys_eeprom.c - */ -#define TLV_CODE_PRODUCT_NAME 0x21 -#define TLV_CODE_PART_NUMBER 0x22 -#define TLV_CODE_SERIAL_NUMBER 0x23 -#define TLV_CODE_MAC_BASE 0x24 -#define TLV_CODE_MANUF_DATE 0x25 -#define TLV_CODE_DEVICE_VERSION 0x26 -#define TLV_CODE_LABEL_REVISION 0x27 -#define TLV_CODE_PLATFORM_NAME 0x28 -#define TLV_CODE_ONIE_VERSION 0x29 -#define TLV_CODE_MAC_SIZE 0x2A -#define TLV_CODE_MANUF_NAME 0x2B -#define TLV_CODE_MANUF_COUNTRY 0x2C -#define TLV_CODE_VENDOR_NAME 0x2D -#define TLV_CODE_DIAG_VERSION 0x2E -#define TLV_CODE_SERVICE_TAG 0x2F -#define TLV_CODE_VENDOR_EXT 0xFD -#define TLV_CODE_CRC_32 0xFE - -/* - * Struct for displaying the TLV codes and names. - */ -struct tlv_code_desc { - u_int8_t m_code; - char* m_name; -}; - -/* - * List of TLV codes and names. - */ -static const struct tlv_code_desc tlv_code_list[] = { - { TLV_CODE_PRODUCT_NAME , "Product Name"}, - { TLV_CODE_PART_NUMBER , "Part Number"}, - { TLV_CODE_SERIAL_NUMBER , "Serial Number"}, - { TLV_CODE_MAC_BASE , "Base MAC Address"}, - { TLV_CODE_MANUF_DATE , "Manufacture Date"}, - { TLV_CODE_DEVICE_VERSION , "Device Version"}, - { TLV_CODE_LABEL_REVISION , "Label Revision"}, - { TLV_CODE_PLATFORM_NAME , "Platform Name"}, - { TLV_CODE_ONIE_VERSION , "Loader Version"}, - { TLV_CODE_MAC_SIZE , "MAC Addresses"}, - { TLV_CODE_MANUF_NAME , "Manufacturer"}, - { TLV_CODE_MANUF_COUNTRY , "Country Code"}, - { TLV_CODE_VENDOR_NAME , "Vendor Name"}, - { TLV_CODE_DIAG_VERSION , "Diag Version"}, - { TLV_CODE_SERVICE_TAG , "Service Tag"}, - { TLV_CODE_VENDOR_EXT , "Vendor Extension"}, - { TLV_CODE_CRC_32 , "CRC-32"}, -}; - -static inline const char* tlv_type2name(u_int8_t type) -{ - char* name = "Unknown"; - int i; - - for (i = 0; i < sizeof(tlv_code_list)/sizeof(tlv_code_list[0]); i++) { - if (tlv_code_list[i].m_code == type) { - name = tlv_code_list[i].m_name; - break; - } - } - return name; -} - -/* - * The max decode value is currently for the 'raw' type or the 'vendor - * extension' type, both of which have the same decode format. The - * max decode string size is computed as follows: - * - * strlen(" 0xFF") * TLV_VALUE_MAX_LEN + 1 - * - */ -#define TLV_DECODE_VALUE_MAX_LEN ((5 * TLV_VALUE_MAX_LEN) + 1) - - -/* - * Each platform must define the following platform-specific macros - * in sys_eeprom_platform.h: - * SYS_EEPROM_SIZE: size of usable eeprom - * SYS_EEPROM_I2C_DEVICE: i2c-bus - * SYS_EEPROM_I2C_ADDR: address on the bus - * The following may also be defined in sys_eeprom_platform.h, else - * the defaults with take over: - * SYS_EEPROM_MAX_SIZE: Total size of the eeprom - * SYS_EEPROM_OFFSET: offset from where the ONIE header starts - */ -#define SYS_EEPROM_MAX_SIZE 2048 -#define SYS_EEPROM_OFFSET 0 -#define SYS_EEPROM_SIZE SYS_EEPROM_MAX_SIZE -#define SYS_EEPROM_I2C_DEVICE "/dev/i2c-0" -#define SYS_EEPROM_I2C_ADDR 0x53 - -#if (SYS_EEPROM_SIZE + SYS_EEPROM_OFFSET > SYS_EEPROM_MAX_SIZE) - #error SYS_EEPROM_SIZE + SYS_EEPROM_OFFSET is greater than SYS_EEPROM_MAX_SIZE -#endif - -// Access functions to onie_tlvinfo -void show_eeprom(u_int8_t *eeprom); -int read_eeprom(struct i2c_client *pi2c_client, u_int8_t *eeprom); -int prog_eeprom(struct i2c_client *pi2c_client,u_int8_t * eeprom); -void update_eeprom_header(u_int8_t *eeprom); -bool tlvinfo_find_tlv(u_int8_t *eeprom, u_int8_t tcode, int *eeprom_index); -bool tlvinfo_delete_tlv(u_int8_t * eeprom, u_int8_t code); -bool tlvinfo_add_tlv(u_int8_t * eeprom, int tcode, char * strval); -bool tlvinfo_decode_tlv(u_int8_t *eeprom, u_int8_t tcode, char* value); -//int find_vpd_data(u_int8_t *eeprom, int i_offset, char *c_buf); diff --git a/packages/platforms/inventec/x86-64/d5254/modules/builds/src/transceiver.c b/packages/platforms/inventec/x86-64/d5254/modules/builds/src/transceiver.c deleted file mode 100644 index 376f21908..000000000 --- a/packages/platforms/inventec/x86-64/d5254/modules/builds/src/transceiver.c +++ /dev/null @@ -1,8393 +0,0 @@ -#include -#include -#include -#include -/* For build single module using (Ex: ONL platform) */ -#include -#include "io_expander.h" -#include "transceiver.h" - - -/* ========== Register EEPROM address mapping ========== - */ -struct eeprom_map_s eeprom_map_sfp = { - .addr_br =0x50, .page_br =-1, .offset_br =12, .length_br =1, - .addr_cdr =-1, .page_cdr =-1, .offset_cdr =-1, .length_cdr =-1, - .addr_comp_rev =0x50, .page_comp_rev =-1, .offset_comp_rev =94, .length_comp_rev =1, - .addr_connector =0x50, .page_connector =-1, .offset_connector =2, .length_connector =1, - .addr_diag_type =0x50, .page_diag_type =-1, .offset_diag_type =92 , .length_diag_type =1, - .addr_extbr =-1, .page_extbr =-1, .offset_extbr =-1, .length_extbr =-1, - .addr_ext_id =0x50, .page_ext_id =-1, .offset_ext_id =1, .length_ext_id =1, - .addr_id =0x50, .page_id =-1, .offset_id =0, .length_id =1, - .addr_len_sm =0x50, .page_len_sm =-1, .offset_len_sm =15, .length_len_sm =1, - .addr_len_smf =0x50, .page_len_smf =-1, .offset_len_smf =14, .length_len_smf =1, - .addr_len_om1 =0x50, .page_len_om1 =-1, .offset_len_om1 =17, .length_len_om1 =1, - .addr_len_om2 =0x50, .page_len_om2 =-1, .offset_len_om2 =16, .length_len_om2 =1, - .addr_len_om3 =0x50, .page_len_om3 =-1, .offset_len_om3 =19, .length_len_om3 =1, - .addr_len_om4 =0x50, .page_len_om4 =-1, .offset_len_om4 =18, .length_len_om4 =1, - .addr_option =0x50, .page_option =-1, .offset_option =64, .length_option =2, - .addr_rate_id =0x50, .page_rate_id =-1, .offset_rate_id =13, .length_rate_id =1, - .addr_rx_am =-1, .page_rx_am =-1, .offset_rx_am =-1, .length_rx_am =-1, - .addr_rx_em =0x51, .page_rx_em =-1, .offset_rx_em =115, .length_rx_em =1, - .addr_rx_los =-1, .page_rx_los =-1, .offset_rx_los =-1, .length_rx_los =-1, - .addr_rx_power =0x51, .page_rx_power =-1, .offset_rx_power =104, .length_rx_power =2, - .addr_soft_rs0 =0x51, .page_soft_rs0 =-1, .offset_soft_rs0 =110, .length_soft_rs0 =1, - .addr_soft_rs1 =0x51, .page_soft_rs1 =-1, .offset_soft_rs1 =118, .length_soft_rs0 =1, - .addr_temp =0x51, .page_temp =-1, .offset_temp =96, .length_temp =2, - .addr_trancomp =0x50, .page_trancomp =-1, .offset_trancomp =3, .length_trancomp =8, - .addr_trancomp_ext =0x50, .page_trancomp_ext =-1, .offset_trancomp_ext =36, .length_trancomp_ext =1, - .addr_tx_bias =0x51, .page_tx_bias =-1, .offset_tx_bias =100, .length_tx_bias =2, - .addr_tx_disable =-1, .page_tx_disable =-1, .offset_tx_disable =-1, .length_tx_disable =-1, - .addr_tx_eq =0x51, .page_tx_eq =-1, .offset_tx_eq =114, .length_tx_eq =1, - .addr_tx_fault =-1, .page_tx_fault =-1, .offset_tx_fault =-1, .length_tx_fault =-1, - .addr_tx_power =0x51, .page_tx_power =-1, .offset_tx_power =102, .length_tx_power =2, - .addr_vendor_name =0x50, .page_vendor_name =-1, .offset_vendor_name =20, .length_vendor_name =16, - .addr_vendor_pn =0x50, .page_vendor_pn =-1, .offset_vendor_pn =40, .length_vendor_pn =16, - .addr_vendor_rev =0x50, .page_vendor_rev =-1, .offset_vendor_rev =56, .length_vendor_rev =4, - .addr_vendor_sn =0x50, .page_vendor_sn =-1, .offset_vendor_sn =68, .length_vendor_sn =16, - .addr_voltage =0x51, .page_voltage =-1, .offset_voltage =98, .length_voltage =2, - .addr_wavelength =0x50, .page_wavelength =-1, .offset_wavelength =60, .length_wavelength =2, -}; - -struct eeprom_map_s eeprom_map_qsfp = { - .addr_br =0x50, .page_br =0, .offset_br =140, .length_br =1, - .addr_cdr =-1, .page_cdr =-1, .offset_cdr =-1, .length_cdr =-1, - .addr_comp_rev =0x50, .page_comp_rev =-1, .offset_comp_rev =1, .length_comp_rev =1, - .addr_connector =0x50, .page_connector =0, .offset_connector =130, .length_connector =1, - .addr_diag_type =0x50, .page_diag_type =0, .offset_diag_type =220, .length_diag_type =1, - .addr_extbr =0x50, .page_extbr =0, .offset_extbr =222, .length_extbr =1, - .addr_ext_id =0x50, .page_ext_id =0, .offset_ext_id =129, .length_ext_id =1, - .addr_id =0x50, .page_id =0, .offset_id =128, .length_id =1, - .addr_len_sm =-1, .page_len_sm =-1, .offset_len_sm =-1, .length_len_sm =-1, - .addr_len_smf =0x50, .page_len_smf =0, .offset_len_smf =142, .length_len_smf =1, - .addr_len_om1 =0x50, .page_len_om1 =0, .offset_len_om1 =145, .length_len_om1 =1, - .addr_len_om2 =0x50, .page_len_om2 =0, .offset_len_om2 =144, .length_len_om2 =1, - .addr_len_om3 =0x50, .page_len_om3 =0, .offset_len_om3 =143, .length_len_om3 =1, - .addr_len_om4 =0x50, .page_len_om4 =0, .offset_len_om4 =146, .length_len_om4 =1, - .addr_option =0x50, .page_option =0, .offset_option =193, .length_option =3, - .addr_rate_id =-1, .page_rate_id =-1, .offset_rate_id =-1, .length_rate_id =-1, - .addr_rx_am =-1, .page_rx_am =-1, .offset_rx_am =-1, .length_rx_am =-1, - .addr_rx_em =-1, .page_rx_em =-1, .offset_rx_em =-1, .length_rx_em =-1, - .addr_rx_los =0x50, .page_rx_los =-1, .offset_rx_los =3, .length_rx_los =1, - .addr_rx_power =0x50, .page_rx_power =-1, .offset_rx_power =34, .length_rx_power =8, - .addr_soft_rs0 =-1, .page_soft_rs0 =-1, .offset_soft_rs0 =-1, .length_soft_rs0 =-1, - .addr_soft_rs1 =-1, .page_soft_rs1 =-1, .offset_soft_rs1 =-1, .length_soft_rs0 =-1, - .addr_temp =0x50, .page_temp =-1, .offset_temp =22, .length_temp =2, - .addr_trancomp =0x50, .page_trancomp =0, .offset_trancomp =131, .length_trancomp =8, - .addr_trancomp_ext =0x50, .page_trancomp_ext =0, .offset_trancomp_ext =192, .length_trancomp_ext =1, - .addr_tx_bias =0x50, .page_tx_bias =-1, .offset_tx_bias =42, .length_tx_bias =8, - .addr_tx_disable =0x50, .page_tx_disable =-1, .offset_tx_disable =86, .length_tx_disable =1, - .addr_tx_eq =-1, .page_tx_eq =-1, .offset_tx_eq =-1, .length_tx_eq =-1, - .addr_tx_fault =0x50, .page_tx_fault =-1, .offset_tx_fault =4, .length_tx_fault =1, - .addr_tx_power =0x50, .page_tx_power =-1, .offset_tx_power =50, .length_tx_power =8, - .addr_vendor_name =0x50, .page_vendor_name =0, .offset_vendor_name =148, .length_vendor_name =16, - .addr_vendor_pn =0x50, .page_vendor_pn =0, .offset_vendor_pn =168, .length_vendor_pn =16, - .addr_vendor_rev =0x50, .page_vendor_rev =0, .offset_vendor_rev =184, .length_vendor_rev =2, - .addr_vendor_sn =0x50, .page_vendor_sn =0, .offset_vendor_sn =196, .length_vendor_sn =16, - .addr_voltage =0x50, .page_voltage =-1, .offset_voltage =26, .length_voltage =2, - .addr_wavelength =0x50, .page_wavelength =0, .offset_wavelength =186, .length_wavelength =2, -}; - -struct eeprom_map_s eeprom_map_qsfp28 = { - .addr_br =0x50, .page_br =0, .offset_br =140, .length_br =1, - .addr_cdr =0x50, .page_cdr =-1, .offset_cdr =98, .length_cdr =1, - .addr_comp_rev =0x50, .page_comp_rev =-1, .offset_comp_rev =1, .length_comp_rev =1, - .addr_connector =0x50, .page_connector =0, .offset_connector =130, .length_connector =1, - .addr_diag_type =0x50, .page_diag_type =0, .offset_diag_type =220, .length_diag_type =1, - .addr_extbr =0x50, .page_extbr =0, .offset_extbr =222, .length_extbr =1, - .addr_ext_id =0x50, .page_ext_id =0, .offset_ext_id =129, .length_ext_id =1, - .addr_id =0x50, .page_id =0, .offset_id =128, .length_id =1, - .addr_len_sm =-1, .page_len_sm =-1, .offset_len_sm =-1, .length_len_sm =-1, - .addr_len_smf =0x50, .page_len_smf =0, .offset_len_smf =142, .length_len_smf =1, - .addr_len_om1 =0x50, .page_len_om1 =0, .offset_len_om1 =145, .length_len_om1 =1, - .addr_len_om2 =0x50, .page_len_om2 =0, .offset_len_om2 =144, .length_len_om2 =1, - .addr_len_om3 =0x50, .page_len_om3 =0, .offset_len_om3 =143, .length_len_om3 =1, - .addr_len_om4 =0x50, .page_len_om4 =0, .offset_len_om4 =146, .length_len_om4 =1, - .addr_option =0x50, .page_option =0, .offset_option =193, .length_option =3, - .addr_rate_id =-1, .page_rate_id =-1, .offset_rate_id =-1, .length_rate_id =-1, - .addr_rx_am =0x50, .page_rx_am =3, .offset_rx_am =238, .length_rx_am =2, - .addr_rx_em =0x50, .page_rx_em =3, .offset_rx_em =236, .length_rx_em =2, - .addr_rx_los =0x50, .page_rx_los =-1, .offset_rx_los =3, .length_rx_los =1, - .addr_rx_power =0x50, .page_rx_power =-1, .offset_rx_power =34, .length_rx_power =8, - .addr_soft_rs0 =-1, .page_soft_rs0 =-1, .offset_soft_rs0 =-1, .length_soft_rs0 =-1, - .addr_soft_rs1 =-1, .page_soft_rs1 =-1, .offset_soft_rs1 =-1, .length_soft_rs0 =-1, - .addr_temp =0x50, .page_temp =-1, .offset_temp =22, .length_temp =2, - .addr_trancomp =0x50, .page_trancomp =0, .offset_trancomp =131, .length_trancomp =8, - .addr_trancomp_ext =0x50, .page_trancomp_ext =0, .offset_trancomp_ext =192, .length_trancomp_ext =1, - .addr_tx_bias =0x50, .page_tx_bias =-1, .offset_tx_bias =42, .length_tx_bias =8, - .addr_tx_disable =0x50, .page_tx_disable =-1, .offset_tx_disable =86, .length_tx_disable =1, - .addr_tx_eq =0x50, .page_tx_eq =3, .offset_tx_eq =234, .length_tx_eq =2, - .addr_tx_fault =0x50, .page_tx_fault =-1, .offset_tx_fault =4, .length_tx_fault =1, - .addr_tx_power =0x50, .page_tx_power =-1, .offset_tx_power =50, .length_tx_power =8, - .addr_vendor_name =0x50, .page_vendor_name =0, .offset_vendor_name =148, .length_vendor_name =16, - .addr_vendor_pn =0x50, .page_vendor_pn =0, .offset_vendor_pn =168, .length_vendor_pn =16, - .addr_vendor_rev =0x50, .page_vendor_rev =0, .offset_vendor_rev =184, .length_vendor_rev =2, - .addr_vendor_sn =0x50, .page_vendor_sn =0, .offset_vendor_sn =196, .length_vendor_sn =16, - .addr_voltage =0x50, .page_voltage =-1, .offset_voltage =26, .length_voltage =2, - .addr_wavelength =0x50, .page_wavelength =0, .offset_wavelength =186, .length_wavelength =2, -}; - - -/* ========== Utility Functions ========== - */ -static int -get_bit(uint8_t origin_byte, int bit_shift) { - return (int)((origin_byte >> bit_shift) & 0x1); -} - -static int -transform_word_to_int(uint8_t hight_byte, - uint8_t low_byte) { - return ((((int)hight_byte) << 8) + (int)low_byte); -} - -void -alarm_msg_2_user(struct transvr_obj_s *self, - char *emsg) { - - SWPS_ERR("%s on %s.\n", emsg, self->swp_name); -} -EXPORT_SYMBOL(alarm_msg_2_user); - -/* ========== Private functions ========== - */ -static int -_reload_transvr_obj(struct transvr_obj_s *self,int new_type); - -static int -reload_transvr_obj(struct transvr_obj_s *self,int new_type); - -static int -_is_transvr_support_ctle(struct transvr_obj_s *self); - -static int -_transvr_init_handler(struct transvr_obj_s *self); - -int -_transvr_clean_handler(struct transvr_obj_s *self); - -int -_sfp_detect_class_by_1g_ethernet(struct transvr_obj_s* self); - - -void -lock_transvr_obj(struct transvr_obj_s *self) { - - mutex_lock(&self->lock); - self->curr_page = VAL_TRANSVR_PAGE_FREE; -} -EXPORT_SYMBOL(lock_transvr_obj); - - -void -unlock_transvr_obj(struct transvr_obj_s *self) { - - self->curr_page = VAL_TRANSVR_PAGE_FREE; - mutex_unlock(&self->lock); -} -EXPORT_SYMBOL(unlock_transvr_obj); - - -static int -_check_by_mode(struct transvr_obj_s *self, - int (*attr_update_func)(struct transvr_obj_s *self, int show_err), - char *caller_name){ - - int return_val = ERR_TRANSVR_UNEXCPT; - - switch (self->mode){ - case TRANSVR_MODE_POLLING: - switch (self->state){ - case STATE_TRANSVR_CONNECTED: - goto ok_check_by_mode_1; - case STATE_TRANSVR_NEW: - case STATE_TRANSVR_INIT: - return ERR_TRANSVR_UNINIT; - case STATE_TRANSVR_DISCONNECTED: - return ERR_TRANSVR_UNPLUGGED; - case STATE_TRANSVR_UNEXCEPTED: - return ERR_TRANSVR_ABNORMAL; - case STATE_TRANSVR_ISOLATED: - return ERR_TRNASVR_BE_ISOLATED; - default: - goto err_check_by_mode_1; - } - goto ok_check_by_mode_1; - - case TRANSVR_MODE_DIRECT: - return_val = self->fsm_4_direct(self, caller_name); - if (return_val < 0){ - return return_val; - } - goto ok_check_by_mode_1; - - default: - goto err_check_by_mode_1; - } - goto ok_check_by_mode_1; - -ok_check_by_mode_1: - return attr_update_func(self, 0); - -err_check_by_mode_1: - SWPS_INFO("_check_by_mode: mode:%d state:%d\n", self->mode, self->state); - return ERR_TRANSVR_UNEXCPT; -} - - -static void -_transvr_clean_retry(struct transvr_obj_s *self) { - self->retry = 0; -} - - -static int -_transvr_handle_retry(struct transvr_obj_s *self, int retry) { - /* Return: 0: keep retry - * -1: stop retry - */ - if (self->retry == 0) { - self->retry = retry; - } - self->retry -= 1; - if (self->retry <= 0) { - _transvr_clean_retry(self); - return -1; - } - return 0; -} - - -static int -_common_setup_page(struct transvr_obj_s *self, - int addr, - int page, - int offset, - int len, - int show_e) { - /* return: - * 0 : OK - * -1 : EEPROM settings incorrect - * -2 : I2C R/W failure - * -3 : Undefined case - */ - int retval = DEBUG_TRANSVR_INT_VAL; - char *emsg = DEBUG_TRANSVR_STR_VAL; - - /* Check */ - if ((addr < 0) || (offset < 0) || (len < 0)) { - emsg = "EEPROM settings incorrect"; - retval = -1; - goto err_common_setup_page; - } - /* Case1: continue access */ - if ((self->i2c_client_p->addr == addr) && - (self->curr_page == page)) { - return 0; - } - self->i2c_client_p->addr = addr; - /* Case2: select lower page */ - if (page == -1) { - self->curr_page = page; - return 0; - } - /* Case3: select upper page */ - if (page >= 0) { - goto upper_common_setup_page; - } - /* Unexpected case */ - show_e = 1; - emsg = "Unexpected case"; - retval = -3; - goto err_common_setup_page; - -upper_common_setup_page: - if (i2c_smbus_write_byte_data(self->i2c_client_p, - VAL_TRANSVR_PAGE_SELECT_OFFSET, - page) < 0) { - emsg = "I2C R/W failure"; - retval = -2; - goto err_common_setup_page; - } - self->curr_page = page; - mdelay(VAL_TRANSVR_PAGE_SELECT_DELAY); - return 0; - -err_common_setup_page: - if (show_e) { - SWPS_INFO("%s: %s", __func__, emsg); - SWPS_INFO("%s: :0x%02x :%d :%d :%d\n", - __func__, addr, page, offset, len); - } - return retval; -} - -/* -static int -_common_setup_password(struct transvr_obj_s *self, - int addr, - int page, - int offs, - uint8_t pwd[4], - int show_e) { - int i = 0; - int err = DEBUG_TRANSVR_INT_VAL; - char *emsg = DEBUG_TRANSVR_STR_VAL; - - err = _common_setup_page(self, addr, page, offs, 4, show_e); - if (err < 0){ - emsg = "setup EEPROM page fail"; - goto err_common_setup_password; - } - for (i=0; i<4; i++) { - err = i2c_smbus_write_byte_data(self->i2c_client_p, - (offs + i), - pwd[i]); - if (err < 0){ - emsg = "I2C R/W fail!"; - goto err_common_setup_password; - } - } - return 0; - -err_common_setup_password: - if (show_e) { - SWPS_INFO("%s: %s :%d\n", __func__, emsg, err); - } - return ERR_TRANSVR_UPDATE_FAIL; -} -*/ - -static int -_common_update_uint8_attr(struct transvr_obj_s *self, - int addr, - int page, - int offset, - int len, - uint8_t *buf, - char *caller, - int show_e){ - - int i; - int err = DEBUG_TRANSVR_INT_VAL; - char *emsg = DEBUG_TRANSVR_STR_VAL; - - err = _common_setup_page(self, addr, page, offset, len, show_e); - if (err < 0){ - emsg = "setup EEPROM page fail"; - goto err_common_update_uint8_attr; - } - for (i=0; ii2c_client_p, (offset + i)); - if (err < 0){ - emsg = "I2C R/W fail!"; - goto err_common_update_uint8_attr; - } - buf[i] = err; - } - return 0; - -err_common_update_uint8_attr: - if (show_e) { - SWPS_INFO("%s: %s :%s :%d\n", - __func__, emsg, caller, err); - } - buf[0] = DEBUG_TRANSVR_HEX_VAL; - return ERR_TRANSVR_UPDATE_FAIL; -} - - -static int -_common_update_int_attr(struct transvr_obj_s *self, - int addr, - int page, - int offset, - int len, - int *buf, - char *caller, - int show_e){ - - int i; - int err = DEBUG_TRANSVR_INT_VAL; - char *emsg = DEBUG_TRANSVR_STR_VAL; - - err = _common_setup_page(self, addr, page, offset, len, show_e); - if (err < 0){ - emsg = "setup EEPROM page fail"; - goto err_common_update_int_attr; - } - for (i=0; ii2c_client_p, (offset + i)); - if (err < 0){ - emsg = "I2C R/W fail!"; - goto err_common_update_int_attr; - } - buf[i] = (int)err; - } - return 0; - -err_common_update_int_attr: - if (show_e) { - SWPS_INFO("%s: %s :%s :%d\n", - __func__, emsg, caller, err); - } - buf[0] = DEBUG_TRANSVR_INT_VAL; - return ERR_TRANSVR_UPDATE_FAIL; -} - - -static int -_common_update_string_attr(struct transvr_obj_s *self, - int addr, - int page, - int offset, - int len, - char buf[], - char *caller, - int show_e){ - - int i; - int err = DEBUG_TRANSVR_INT_VAL; - char *emsg = DEBUG_TRANSVR_STR_VAL; - - err = _common_setup_page(self, addr, page, offset, len, show_e); - if (err < 0){ - emsg = "setup EEPROM page fail"; - goto err_common_update_string_attr; - } - for (i=0; ii2c_client_p, (offset + i)); - if (err < 0){ - emsg = "I2C R/W fail!"; - goto err_common_update_string_attr; - } - buf[i] = (char)err; - } - return 0; - -err_common_update_string_attr: - if (show_e) { - SWPS_INFO("%s: %s :%s :%d\n", - __func__, emsg, caller, err); - } - buf[0] = 'e'; - return ERR_TRANSVR_UPDATE_FAIL; -} - - -static int -_common_set_uint8_attr(struct transvr_obj_s *self, - int addr, - int page, - int offset, - uint8_t update, - uint8_t *buf, - char *caller, - int show_e){ - int len = 1; - int err = DEBUG_TRANSVR_INT_VAL; - char *emsg = DEBUG_TRANSVR_STR_VAL; - - if ((*buf) == update){ - return 0; - } - err = _common_setup_page(self, addr, page, offset, len, show_e); - if (err < 0){ - emsg = "setup EEPROM page fail"; - goto err_common_set_uint8_attr_1; - } - err = i2c_smbus_write_byte_data(self->i2c_client_p, - offset, - update); - if (err < 0){ - emsg = "I2C R/W fail!"; - goto err_common_set_uint8_attr_1; - } - (*buf) = update; - return 0; - -err_common_set_uint8_attr_1: - if (show_e) { - SWPS_INFO("%s: %s :%s :%d\n", - __func__, emsg, caller, err); - } - return ERR_TRANSVR_UPDATE_FAIL; -} - - -static int -_common_set_uint8_array(struct transvr_obj_s *self, - int addr, - int page, - int offs, - int len, - uint8_t update[], - uint8_t buf[], - char *caller, - int show_e){ - int i = 0; - int err = DEBUG_TRANSVR_INT_VAL; - char *emsg = DEBUG_TRANSVR_STR_VAL; - - err = _common_setup_page(self, addr, page, offs, len, show_e); - if (err < 0){ - emsg = "setup EEPROM page fail"; - goto err_common_set_uint8_attr_1; - } - for (i=0; ii2c_client_p, - (offs + i), - update[i]); - if (err < 0){ - emsg = "I2C R/W fail!"; - goto err_common_set_uint8_attr_1; - } - buf[i] = update[i]; - } - return 0; - -err_common_set_uint8_attr_1: - if (show_e) { - SWPS_INFO("%s: %s :%s :%d :%d\n", - __func__, emsg, caller, err, i); - } - return ERR_TRANSVR_UPDATE_FAIL; -} - - -static int -_common_update_attr_id(struct transvr_obj_s *self, - int show_err){ - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_id, - self->eeprom_map_p->page_id, - self->eeprom_map_p->offset_id, - self->eeprom_map_p->length_id, - &(self->id), - "_common_update_attr_id", - show_err); -} - - -static int -_common_update_attr_extended_id(struct transvr_obj_s *self, - int show_err){ - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_ext_id, - self->eeprom_map_p->page_ext_id, - self->eeprom_map_p->offset_ext_id, - self->eeprom_map_p->length_ext_id, - &(self->ext_id), - "_common_update_attr_extended_id", - show_err); -} - - -static int -_common_update_attr_connector(struct transvr_obj_s *self, - int show_err){ - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_connector, - self->eeprom_map_p->page_connector, - self->eeprom_map_p->offset_connector, - self->eeprom_map_p->length_connector, - &(self->connector), - "_common_update_attr_connector", - show_err); -} - - -static int -_common_update_attr_transvr_comp(struct transvr_obj_s *self, - int show_err){ - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_trancomp, - self->eeprom_map_p->page_trancomp, - self->eeprom_map_p->offset_trancomp, - self->eeprom_map_p->length_trancomp, - self->transvr_comp, - "_common_update_attr_transvr_comp", - show_err); -} - - -static int -_common_update_attr_transvr_comp_ext(struct transvr_obj_s *self, - int show_err){ - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_trancomp_ext, - self->eeprom_map_p->page_trancomp_ext, - self->eeprom_map_p->offset_trancomp_ext, - self->eeprom_map_p->length_trancomp_ext, - &(self->transvr_comp_ext), - "_common_update_attr_transvr_comp_ext", - show_err); -} - - -static int -_common_update_attr_vendor_name(struct transvr_obj_s *self, - int show_err){ - return _common_update_string_attr(self, - self->eeprom_map_p->addr_vendor_name, - self->eeprom_map_p->page_vendor_name, - self->eeprom_map_p->offset_vendor_name, - self->eeprom_map_p->length_vendor_name, - self->vendor_name, - "_common_update_attr_vendor_name", - show_err); -} - - -static int -_common_update_attr_vendor_pn(struct transvr_obj_s *self, - int show_err){ - return _common_update_string_attr(self, - self->eeprom_map_p->addr_vendor_pn, - self->eeprom_map_p->page_vendor_pn, - self->eeprom_map_p->offset_vendor_pn, - self->eeprom_map_p->length_vendor_pn, - self->vendor_pn, - "_common_update_attr_vendor_pn", - show_err); -} - - -static int -_common_update_attr_vendor_rev(struct transvr_obj_s *self, - int show_err){ - return _common_update_string_attr(self, - self->eeprom_map_p->addr_vendor_rev, - self->eeprom_map_p->page_vendor_rev, - self->eeprom_map_p->offset_vendor_rev, - self->eeprom_map_p->length_vendor_rev, - self->vendor_rev, - "_common_update_attr_vendor_rev", - show_err); -} - - -static int -_common_update_attr_vendor_sn(struct transvr_obj_s *self, - int show_err){ - return _common_update_string_attr(self, - self->eeprom_map_p->addr_vendor_sn, - self->eeprom_map_p->page_vendor_sn, - self->eeprom_map_p->offset_vendor_sn, - self->eeprom_map_p->length_vendor_sn, - self->vendor_sn, - "_common_update_attr_vendor_sn", - show_err); -} - - -static int -_common_update_attr_br(struct transvr_obj_s *self, - int show_err){ - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_br, - self->eeprom_map_p->page_br, - self->eeprom_map_p->offset_br, - self->eeprom_map_p->length_br, - &(self->br), - "_common_update_attr_br", - show_err); -} - - -static int -_common_update_attr_len_smf(struct transvr_obj_s *self, - int show_err){ - return _common_update_int_attr(self, - self->eeprom_map_p->addr_len_smf, - self->eeprom_map_p->page_len_smf, - self->eeprom_map_p->offset_len_smf, - self->eeprom_map_p->length_len_smf, - &(self->len_smf), - "_common_update_attr_len_smf", - show_err); -} - - -static int -_common_update_attr_len_om1(struct transvr_obj_s *self, - int show_err){ - return _common_update_int_attr(self, - self->eeprom_map_p->addr_len_om1, - self->eeprom_map_p->page_len_om1, - self->eeprom_map_p->offset_len_om1, - self->eeprom_map_p->length_len_om1, - &(self->len_om1), - "_common_update_attr_len_om1", - show_err); -} - -static int -_common_update_attr_len_om2(struct transvr_obj_s *self, - int show_err){ - return _common_update_int_attr(self, - self->eeprom_map_p->addr_len_om2, - self->eeprom_map_p->page_len_om2, - self->eeprom_map_p->offset_len_om2, - self->eeprom_map_p->length_len_om2, - &(self->len_om2), - "_common_update_attr_len_om2", - show_err); -} - -static int -_common_update_attr_len_om3(struct transvr_obj_s *self, - int show_err){ - return _common_update_int_attr(self, - self->eeprom_map_p->addr_len_om3, - self->eeprom_map_p->page_len_om3, - self->eeprom_map_p->offset_len_om3, - self->eeprom_map_p->length_len_om3, - &(self->len_om3), - "_common_update_attr_len_om3", - show_err); -} - - -static int -_common_update_attr_len_om4(struct transvr_obj_s *self, - int show_err){ - return _common_update_int_attr(self, - self->eeprom_map_p->addr_len_om4, - self->eeprom_map_p->page_len_om4, - self->eeprom_map_p->offset_len_om4, - self->eeprom_map_p->length_len_om4, - &(self->len_om4), - "_common_update_attr_len_om4", - show_err); -} - - -static int -_common_update_attr_option(struct transvr_obj_s *self, - int show_err){ - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_option, - self->eeprom_map_p->page_option, - self->eeprom_map_p->offset_option, - self->eeprom_map_p->length_option, - self->option, - "_common_update_attr_option", - show_err); -} - - -static int -_common_update_attr_comp_rev(struct transvr_obj_s *self, - int show_err){ - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_comp_rev, - self->eeprom_map_p->page_comp_rev, - self->eeprom_map_p->offset_comp_rev, - self->eeprom_map_p->length_comp_rev, - &(self->comp_rev), - "_common_update_attr_comp_rev", - show_err); -} - - -static int -_common_update_attr_diag_type(struct transvr_obj_s *self, - int show_err){ - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_diag_type, - self->eeprom_map_p->page_diag_type, - self->eeprom_map_p->offset_diag_type, - self->eeprom_map_p->length_diag_type, - &(self->diag_type), - "_common_update_attr_diag_type", - show_err); -} - - -static int -_common_update_attr_wavelength(struct transvr_obj_s *self, - int show_err){ - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_wavelength, - self->eeprom_map_p->page_wavelength, - self->eeprom_map_p->offset_wavelength, - self->eeprom_map_p->length_wavelength, - self->wavelength, - "_common_update_attr_wavelength", - show_err); -} - - -int -_common_get_option_value(struct transvr_obj_s *self, - int offset, - int bit_shift) { - /* SFP: - * - option[0] = A0h / 64 - * - option[1] = A0h / 65 - * QSFP: - * - option[0] = 00h / 193 - * - option[1] = 00h / 194 - * - option[2] = 00h / 195 - */ - return (self->option[offset] & (1 << bit_shift)); -} - - -static int -_sfp_update_attr_len_sm(struct transvr_obj_s *self, - int show_err){ - return _common_update_int_attr(self, - self->eeprom_map_p->addr_len_sm, - self->eeprom_map_p->page_len_sm, - self->eeprom_map_p->offset_len_sm, - self->eeprom_map_p->length_len_sm, - &(self->len_sm), - "_common_update_attr_len_sm", - show_err); -} - - -static int -_sfp_update_attr_rate_id(struct transvr_obj_s *self, - int show_err){ - return _common_update_int_attr(self, - self->eeprom_map_p->addr_rate_id, - self->eeprom_map_p->page_rate_id, - self->eeprom_map_p->offset_rate_id, - self->eeprom_map_p->length_rate_id, - &(self->rate_id), - "_sfp_update_attr_rate_id", - show_err); -} - - -static int -_sfp_update_attr_soft_rs0(struct transvr_obj_s *self, - int show_err){ - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_soft_rs0, - self->eeprom_map_p->page_soft_rs0, - self->eeprom_map_p->offset_soft_rs0, - self->eeprom_map_p->length_soft_rs0, - &(self->soft_rs0), - "_sfp_update_attr_soft_rs0", - show_err); -} - - -static int -_sfp_update_attr_soft_rs1(struct transvr_obj_s *self, - int show_err){ - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_soft_rs1, - self->eeprom_map_p->page_soft_rs1, - self->eeprom_map_p->offset_soft_rs1, - self->eeprom_map_p->length_soft_rs1, - &(self->soft_rs1), - "_sfp_update_attr_soft_rs1", - show_err); -} - - -int -_sfp_is_diag_support(struct transvr_obj_s *self){ - - uint8_t bit_mask = 0xC0; /* 1100 0000 */ - uint8_t en_val = 0x40; /* 0100 0000 */ - uint8_t checkval = (self->diag_type & bit_mask); - - if (checkval == en_val) { - return 1; - } - return 0; -} - - -static int -_sfp_update_attr_curr_temp(struct transvr_obj_s *self, - int show_err){ - - if (!(_sfp_is_diag_support(self))) { - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_temp, - self->eeprom_map_p->page_temp, - self->eeprom_map_p->offset_temp, - self->eeprom_map_p->length_temp, - self->curr_temp, - "_sfp_update_attr_curr_temp", - show_err); -} - - -static int -_sfp_update_attr_curr_voltage(struct transvr_obj_s *self, - int show_err){ - - if (!(_sfp_is_diag_support(self))) { - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_voltage, - self->eeprom_map_p->page_voltage, - self->eeprom_map_p->offset_voltage, - self->eeprom_map_p->length_voltage, - self->curr_voltage, - "_sfp_update_attr_curr_voltage", - show_err); -} - - -static int -_sfp_update_attr_curr_tx_bias(struct transvr_obj_s *self, - int show_err){ - - if (!(_sfp_is_diag_support(self))) { - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_tx_bias, - self->eeprom_map_p->page_tx_bias, - self->eeprom_map_p->offset_tx_bias, - self->eeprom_map_p->length_tx_bias, - self->curr_tx_bias, - "_sfp_update_attr_curr_tx_bias", - show_err); -} - - -static int -_sfp_update_attr_curr_tx_power(struct transvr_obj_s *self, - int show_err){ - - if (!(_sfp_is_diag_support(self))) { - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_tx_power, - self->eeprom_map_p->page_tx_power, - self->eeprom_map_p->offset_tx_power, - self->eeprom_map_p->length_tx_power, - self->curr_tx_power, - "_sfp_update_attr_curr_tx_power", - show_err); -} - - -static int -_sfp_update_attr_curr_rx_power(struct transvr_obj_s *self, - int show_err){ - - if (!(_sfp_is_diag_support(self))) { - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_rx_power, - self->eeprom_map_p->page_rx_power, - self->eeprom_map_p->offset_rx_power, - self->eeprom_map_p->length_rx_power, - self->curr_rx_power, - "_sfp_update_attr_curr_rx_power", - show_err); -} - - -static int -_sfp_update_attr_rx_em(struct transvr_obj_s *self, - int show_err){ - - if (!_is_transvr_support_ctle(self)) { - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_rx_em, - self->eeprom_map_p->page_rx_em, - self->eeprom_map_p->offset_rx_em, - self->eeprom_map_p->length_rx_em, - self->rx_em, - "_sfp_update_attr_rx_em", - show_err); -} - - -static int -_sfp_update_attr_tx_eq(struct transvr_obj_s *self, - int show_err){ - - if (!_is_transvr_support_ctle(self)) { - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_tx_eq, - self->eeprom_map_p->page_tx_eq, - self->eeprom_map_p->offset_tx_eq, - self->eeprom_map_p->length_tx_eq, - self->tx_eq, - "_sfp_update_attr_tx_eq", - show_err); -} - - -static int -_qsfp_update_attr_cdr(struct transvr_obj_s *self, - int show_err){ - if (self->type != TRANSVR_TYPE_QSFP_28){ - self->cdr = DEBUG_TRANSVR_HEX_VAL; - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_cdr, - self->eeprom_map_p->page_cdr, - self->eeprom_map_p->offset_cdr, - self->eeprom_map_p->length_cdr, - &(self->cdr), - "_common_update_attr_cdr", - show_err); -} - - -static int -_qsfg_update_attr_extbr(struct transvr_obj_s *self, - int show_err) { - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_extbr, - self->eeprom_map_p->page_extbr, - self->eeprom_map_p->offset_extbr, - self->eeprom_map_p->length_extbr, - &(self->extbr), - "_common_update_attr_extbr", - show_err); -} - - -static int -_qsfp_is_diag_support(struct transvr_obj_s *self, - int diag_type) { - /* Input Parm: diag_type - * => 1 : temperature - * => 2 : voltage - * => 3 : tx relate - * => 4 : rx relate - */ - uint8_t mask_b2 = 0x04; /* 0000 0100 */ - uint8_t mask_b3 = 0x08; /* 0000 1000 */ - - switch (diag_type) { - case 1: /* temperature */ - case 2: /* voltage */ - /* Direct access target, because of spec not defined */ - return 1; - case 3: - case 4: - /* [Note] - * Due to lot of transceiver vendor defined it not rigorously and - * consider of general support, we seem it as supported if there - * are bit-2 OR bit-3 defined by transceiver vendor. - */ - if ( ((self->diag_type & mask_b2) == mask_b2 ) || - ((self->diag_type & mask_b3) == mask_b3 ) ){ - return 1; - } - return 0; - default: - SWPS_INFO("%s: undefined diag_type:%d\n", - __func__, diag_type); - break; - } - return 0; -} - - -int -_qsfp_is_implement_tx_disable(struct transvr_obj_s *self) { - /* - * 00h / Byte-195 / Bit-4 - */ - int byte = 2; - int bit = 4; - return _common_get_option_value(self, byte, bit); -} - - -int -_qsfp_is_implement_tx_fault(struct transvr_obj_s *self) { - /* - * 00h / Byte-195 / Bit-3 - */ - int byte = 2; - int bit = 3; - return _common_get_option_value(self, byte, bit); -} - - -static int -_qsfp_update_attr_curr_temp(struct transvr_obj_s *self, - int show_err){ - int diag_type = 1; - - if (!(_qsfp_is_diag_support(self, diag_type))) { - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_temp, - self->eeprom_map_p->page_temp, - self->eeprom_map_p->offset_temp, - self->eeprom_map_p->length_temp, - self->curr_temp, - "_qsfp_update_attr_curr_temp", - show_err); -} - - -static int -_qsfp_update_attr_curr_voltage(struct transvr_obj_s *self, - int show_err){ - int diag_type = 2; - - if (!(_qsfp_is_diag_support(self, diag_type))) { - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_voltage, - self->eeprom_map_p->page_voltage, - self->eeprom_map_p->offset_voltage, - self->eeprom_map_p->length_voltage, - self->curr_voltage, - "_qsfp_update_attr_curr_voltage", - show_err); -} - - -static int -_qsfp_update_attr_curr_tx_bias(struct transvr_obj_s *self, - int show_err){ - int diag_type = 3; - - if (!(_qsfp_is_diag_support(self, diag_type))) { - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_tx_bias, - self->eeprom_map_p->page_tx_bias, - self->eeprom_map_p->offset_tx_bias, - self->eeprom_map_p->length_tx_bias, - self->curr_tx_bias, - "_qsfp_update_attr_curr_tx_bias", - show_err); -} - - -static int -_qsfp_update_attr_curr_tx_power(struct transvr_obj_s *self, - int show_err){ - int diag_type = 3; - - if (!(_qsfp_is_diag_support(self, diag_type))) { - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_tx_power, - self->eeprom_map_p->page_tx_power, - self->eeprom_map_p->offset_tx_power, - self->eeprom_map_p->length_tx_power, - self->curr_tx_power, - "_qsfp_update_attr_curr_tx_power", - show_err); -} - - -static int -_qsfp_update_attr_curr_rx_power(struct transvr_obj_s *self, - int show_err){ - int diag_type = 4; - - if (!(_qsfp_is_diag_support(self, diag_type))) { - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_rx_power, - self->eeprom_map_p->page_rx_power, - self->eeprom_map_p->offset_rx_power, - self->eeprom_map_p->length_rx_power, - self->curr_rx_power, - "_qsfp_update_attr_curr_rx_power", - show_err); -} - - -static int -_qsfp_update_attr_soft_rx_los(struct transvr_obj_s *self, - int show_err){ - - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_rx_los, - self->eeprom_map_p->page_rx_los, - self->eeprom_map_p->offset_rx_los, - self->eeprom_map_p->length_rx_los, - &(self->rx_los), - "_qsfp_update_attr_soft_rx_los", - show_err); -} - - -static int -_qsfp_update_attr_soft_tx_disable(struct transvr_obj_s *self, - int show_err){ - - if (!_qsfp_is_implement_tx_disable(self)) { - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_tx_disable, - self->eeprom_map_p->page_tx_disable, - self->eeprom_map_p->offset_tx_disable, - self->eeprom_map_p->length_tx_disable, - &(self->tx_disable), - "_qsfp_update_attr_soft_tx_disable", - show_err); -} - - -static int -_qsfp_update_attr_soft_tx_fault(struct transvr_obj_s *self, - int show_err){ - - if (!_qsfp_is_implement_tx_fault(self)) { - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_tx_fault, - self->eeprom_map_p->page_tx_fault, - self->eeprom_map_p->offset_tx_fault, - self->eeprom_map_p->length_tx_fault, - &(self->tx_fault), - "_qsfp_update_attr_soft_tx_fault", - show_err); -} - - -static int -_qsfp_update_attr_tx_eq(struct transvr_obj_s *self, - int show_err){ - - if (!_is_transvr_support_ctle(self)) { - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_tx_eq, - self->eeprom_map_p->page_tx_eq, - self->eeprom_map_p->offset_tx_eq, - self->eeprom_map_p->length_tx_eq, - self->tx_eq, - "_qsfp_update_attr_tx_eq", - show_err); -} - - -static int -_qsfp_update_attr_rx_am(struct transvr_obj_s *self, - int show_err){ - - if (!_is_transvr_support_ctle(self)) { - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_rx_am, - self->eeprom_map_p->page_rx_am, - self->eeprom_map_p->offset_rx_am, - self->eeprom_map_p->length_rx_am, - self->rx_am, - "_qsfp_update_attr_rx_am", - show_err); -} - - -static int -_qsfp_update_attr_rx_em(struct transvr_obj_s *self, - int show_err){ - - if (!_is_transvr_support_ctle(self)) { - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_rx_em, - self->eeprom_map_p->page_rx_em, - self->eeprom_map_p->offset_rx_em, - self->eeprom_map_p->length_rx_em, - self->rx_em, - "_qsfp_update_attr_rx_em", - show_err); -} - - -int -_common_update_attr_all(struct transvr_obj_s *self, - int show_err){ - - char *err_str = "err"; - - if (_common_update_attr_id(self, show_err) < 0) { - err_str = "_common_update_attr_id"; - goto err_common_update_attr_all; - } - if (_common_update_attr_extended_id(self, show_err) < 0) { - err_str = "_common_update_attr_extended_id"; - goto err_common_update_attr_all; - } - if (_common_update_attr_connector(self, show_err) < 0) { - err_str = "_common_update_attr_connector"; - goto err_common_update_attr_all; - } - if (_common_update_attr_transvr_comp(self, show_err) < 0) { - err_str = "_common_update_attr_transvr_comp"; - goto err_common_update_attr_all; - } - if (_common_update_attr_transvr_comp_ext(self, show_err) < 0) { - err_str = "_common_update_attr_transvr_comp_ext"; - goto err_common_update_attr_all; - } - if (_common_update_attr_vendor_name(self, show_err) < 0) { - err_str = "_common_update_attr_vendor_name"; - goto err_common_update_attr_all; - } - if (_common_update_attr_vendor_pn(self, show_err) < 0) { - err_str = "_common_update_attr_vendor_pn"; - goto err_common_update_attr_all; - } - if (_common_update_attr_vendor_rev(self, show_err) < 0) { - err_str = "_common_update_attr_vendor_rev"; - goto err_common_update_attr_all; - } - if (_common_update_attr_vendor_sn(self, show_err) < 0) { - err_str = "_common_update_attr_vendor_sn"; - goto err_common_update_attr_all; - } - if (_common_update_attr_br(self, show_err) < 0) { - err_str = "_common_update_attr_br"; - goto err_common_update_attr_all; - } - if (_common_update_attr_len_smf(self, show_err) < 0) { - err_str = "_common_update_attr_len_smf"; - goto err_common_update_attr_all; - } - if (_common_update_attr_len_om1(self, show_err) < 0) { - err_str = "_common_update_attr_len_om1"; - goto err_common_update_attr_all; - } - if (_common_update_attr_len_om2(self, show_err) < 0) { - err_str = "_common_update_attr_len_om2"; - goto err_common_update_attr_all; - } - if (_common_update_attr_len_om3(self, show_err) < 0) { - err_str = "_common_update_attr_len_om3"; - goto err_common_update_attr_all; - } - if (_common_update_attr_len_om4(self, show_err) < 0) { - err_str = "_common_update_attr_len_om4"; - goto err_common_update_attr_all; - } - if (_common_update_attr_option(self, show_err) < 0) { - err_str = "_common_update_attr_option"; - goto err_common_update_attr_all; - } - if (_common_update_attr_comp_rev(self, show_err) < 0) { - err_str = "_common_update_attr_comp_rev"; - goto err_common_update_attr_all; - } - if (_common_update_attr_diag_type(self, show_err) < 0) { - err_str = "_common_update_attr_diag_type"; - goto err_common_update_attr_all; - } - if (_common_update_attr_wavelength(self, show_err) < 0) { - err_str = "_common_update_attr_wavelength"; - goto err_common_update_attr_all; - } - return 0; - -err_common_update_attr_all: - if (show_err){ - SWPS_INFO("%s: fail at:%s :%s\n", __func__, err_str, self->swp_name); - } - return -1; -} - - -int -_sfp_update_attr_all(struct transvr_obj_s *self, - int show_err){ - - char *err_str = DEBUG_TRANSVR_STR_VAL; - - if (_common_update_attr_all(self, show_err) < 0){ - err_str = "_common_update_attr_all"; - goto err_sfp_update_attr_all; - } - if (_sfp_update_attr_len_sm(self, show_err) < 0) { - err_str = "_sfp_update_attr_len_sm"; - goto err_sfp_update_attr_all; - } - if (_sfp_update_attr_rate_id(self, show_err) < 0) { - err_str = "_sfp_update_attr_rate_id"; - goto err_sfp_update_attr_all; - } - if ((self->rate_id) > 0) { - if (_sfp_update_attr_soft_rs0(self, show_err) < 0) { - err_str = "_sfp_update_attr_soft_rs0"; - goto err_sfp_update_attr_all; - } - if (_sfp_update_attr_soft_rs1(self, show_err) < 0) { - err_str = "_sfp_update_attr_soft_rs1"; - goto err_sfp_update_attr_all; - } - } - return 0; - -err_sfp_update_attr_all: - if (show_err){ - SWPS_INFO("%s: fail at:%s :%s\n", __func__, err_str, self->swp_name); - } - return -1; -} - - -int -_qsfp_update_attr_all(struct transvr_obj_s *self, - int show_err){ - - char *err_str = DEBUG_TRANSVR_STR_VAL; - - if (_common_update_attr_all(self, show_err) < 0){ - err_str = "_common_update_attr_all"; - goto err_qsfp_update_attr_all; - } - if (_qsfg_update_attr_extbr(self, show_err) < 0) { - err_str = "_qsfg_update_attr_extbr"; - goto err_qsfp_update_attr_all; - } - if (self->type == TRANSVR_TYPE_QSFP_28) { - if (_qsfp_update_attr_cdr(self, 1) < 0) { - err_str = "_qsfp_update_attr_cdr"; - goto err_qsfp_update_attr_all; - } - } - return 0; - -err_qsfp_update_attr_all: - if (show_err){ - SWPS_INFO("%s: fail at:%s :%s\n", __func__, err_str, self->swp_name); - } - return -1; -} - - -/* ========== Object functions for common type ========== - */ -int -_common_count_temp(uint8_t high_byte, - uint8_t low_byte, - char *buf_p) { - int sign = 0; - int high = 0; - int low = 0; - int lmax = 8; - - /* Count high */ - sign = get_bit(high_byte,7); - SWP_BIT_CLEAR(high_byte, 7); - high = (int)high_byte; - if (sign == 1) { - high = 0 - high; - } - /* Count low */ - low = (get_bit(low_byte, 7) * 500); - low += (get_bit(low_byte, 6) * 250); - low += (get_bit(low_byte, 5) * 125); - low += (get_bit(low_byte, 4) * 62); - low = (low / 100); - /* Integrate High and Low */ - return snprintf(buf_p, lmax, "%d.%d\n", high, low); -} - - -int -_common_count_voltage(uint8_t high_byte, - uint8_t low_byte, - char *buf_p) { - /* [Note]: - * Internally measured transceiver supply voltage. Represented - * as a 16 bit unsigned integer with the voltage defined as the - * full 16 bit value (0-65535) with LSB equal to 100 uVolt, - * yielding a total range of 0 to +6.55 Volts. Practical - * considerations to be defined by transceiver manufacturer will - * tend to limit the actual bounds of the supply voltage measurement. - * Accuracy is vendor specific but must be better than 3% of the - * manufacturer's nominal value over specified operating temperature - * and voltage. Note that in some transceivers, transmitter supply - * voltage and receiver supply voltage are isolated. In that case, - * only one supply is monitored. Refer to the device specification - * for more detail. - */ - int total = 0; - int lmax = 8; - int val_i = 0; - int val_f = 0; - /* unit: 100 uV (1mV=1000uV) */ - total = transform_word_to_int(high_byte, low_byte); - val_i = ((total/10) / 1000); - val_f = ((total/10) - (val_i*1000)); - /* Return Unit: 1 Volt */ - return snprintf(buf_p, lmax, "%d.%03d\n", val_i, val_f); -} - - -int -_common_count_tx_bias(uint8_t high_byte, - uint8_t low_byte, - char *buf_p) { - /* [Note] - * Measured TX bias current in uA. Represented as a 16 bit unsigned - * integer with the current defined as the full 16 bit value (0-65535) - * with LSB equal to 2 uA, yielding a total range of 0 to 131 mA. - * Accuracy is vendor specific but must be better than 10% of the - * manufacturer's nominal value over specified operating temperature - * and voltage. - */ - int total = 0; - int lmax = 8; - int val_i = 0; - int val_f = 0; - /* unit: 2 uA (1mA=1000uA) */ - total = transform_word_to_int(high_byte, low_byte); - val_i = ((total*2) / 1000); - val_f = (((total*2) - (val_i*1000)) / 100); - /* Return Unit: 1 mA */ - return snprintf(buf_p, lmax, "%d.%01d\n", val_i, val_f); -} - - -int -_common_count_tx_power(uint8_t high_byte, - uint8_t low_byte, - char *buf_p) { - /* [Note] - * Measured TX output power in mW. Represented as a 16 bit unsigned - * integer with the power defined as the full 16 bit value (0-65535) - * with LSB equal to 0.1 uW, yielding a total range of 0 to 6.5535 mW - * (~ -40 to +8.2 dBm). Data is assumed to be based on measurement of - * laser monitor photodiode current. It is factory calibrated to absolute - * units using the most representative fiber output type. Accuracy is - * vendor specific but must be better than 3dB over specified temperature - * and voltage. Data is not valid when the transmitter is disabled. - */ - int total = 0; - int lmax = 8; - int val_i = 0; - int val_f = 0; - /* unit: 0.1 uW (1mW=1000uW) */ - total = transform_word_to_int(high_byte, low_byte); - val_i = ((total/10) / 1000); - val_f = ((total/10) - (val_i*1000)); - /* Return Unit: 1 mW */ - return snprintf(buf_p, lmax, "%d.%03d\n", val_i, val_f); -} - - -int -_common_count_rx_power(uint8_t high_byte, - uint8_t low_byte, - char *buf_p) { - /* [Note] - * Measured RX received optical power in mW. Value can represent either - * average received power or OMA depending upon how bit 3 of byte 92 (A0h) - * is set. Represented as a 16 bit unsigned integer with the power defined - * as the full 16 bit value (0-65535) with LSB equal to 0.1 uW, yielding a - * total range of 0 to 6.5535 mW (~ -40 to +8.2 dBm). Absolute accuracy is - * dependent upon the exact optical wavelength. For the vendor specified - * wavelength, accuracy shall be better than 3dB over specified temperature - * and voltage. - */ - int total = 0; - int lmax = 8; - int val_i = 0; - int val_f = 0; - /* unit: 0.1 uW (1mW=1000uW) */ - total = transform_word_to_int(high_byte, low_byte); - val_i = ((total/10) / 1000); - val_f = ((total/10) - (val_i*1000)); - /* Return Unit: 1 mW */ - return snprintf(buf_p, lmax, "%d.%03d\n", val_i, val_f); -} - - -int -_common_count_wavelength(struct transvr_obj_s *self, - uint8_t high_byte, - uint8_t low_byte) { - /* [Note] - * SFP : uint 1 um. - * QSFP: unit 0.05 um. - */ - int total = 0; - - total = transform_word_to_int(high_byte, low_byte); - switch (self->type) { - case TRANSVR_TYPE_SFP: - return total; - - case TRANSVR_TYPE_QSFP: - case TRANSVR_TYPE_QSFP_PLUS: - case TRANSVR_TYPE_QSFP_28: - return (total/20); - - default: - break; - } - return ERR_TRANSVR_UNDEFINED; -} - - -int -common_get_id(struct transvr_obj_s *self){ - - int err_code = _check_by_mode(self, - &_common_update_attr_id, - "common_get_id"); - if (err_code < 0){ - return err_code; - } - /* Transform to INT to show error case */ - return (int)self->id; -} - - -int -common_get_ext_id(struct transvr_obj_s *self){ - - int err_code = _check_by_mode(self, - &_common_update_attr_extended_id, - "common_get_ext_id"); - if (err_code < 0){ - return err_code; - } - /* Transform to INT to show error case */ - return (int)self->ext_id; -} - - -int -common_get_connector(struct transvr_obj_s *self){ - - int err_code = _check_by_mode(self, - &_common_update_attr_connector, - "common_get_connector"); - if (err_code < 0){ - return err_code; - } - /* Transform to INT to show error case */ - return (int)self->connector; -} - - -int -common_get_vendor_name(struct transvr_obj_s *self, char *buf){ - - int err = DEBUG_TRANSVR_INT_VAL; - - if (self->state == STATE_TRANSVR_CONNECTED && - self->mode == TRANSVR_MODE_POLLING && - TRANSVR_INFO_CACHE_ENABLE) { - return snprintf(buf, LEN_TRANSVR_M_STR, "%s\n", self->vendor_name); - } - err = _check_by_mode(self, - &_common_update_attr_vendor_name, - "common_get_vendor_name"); - memset(buf, 0, LEN_TRANSVR_M_STR); - if (err < 0){ - return snprintf(buf, LEN_TRANSVR_M_STR, "%d\n", err); - } - return snprintf(buf, LEN_TRANSVR_M_STR, "%s\n", self->vendor_name); -} - - -int -common_get_vendor_pn(struct transvr_obj_s *self, char *buf) { - - int err = DEBUG_TRANSVR_INT_VAL; - - if (self->state == STATE_TRANSVR_CONNECTED && - self->mode == TRANSVR_MODE_POLLING && - TRANSVR_INFO_CACHE_ENABLE) { - return snprintf(buf, LEN_TRANSVR_M_STR, "%s\n", self->vendor_pn); - } - err = _check_by_mode(self, - &_common_update_attr_vendor_pn, - "common_get_vendor_pn"); - memset(buf, 0, LEN_TRANSVR_M_STR); - if (err < 0){ - return snprintf(buf, LEN_TRANSVR_M_STR, "%d\n", err); - } - return snprintf(buf, LEN_TRANSVR_M_STR, "%s\n", self->vendor_pn); -} - - -int -common_get_vendor_rev(struct transvr_obj_s *self, char *buf) { - - int err = DEBUG_TRANSVR_INT_VAL; - - if (self->state == STATE_TRANSVR_CONNECTED && - self->mode == TRANSVR_MODE_POLLING && - TRANSVR_INFO_CACHE_ENABLE) { - return snprintf(buf, LEN_TRANSVR_M_STR, "%s\n", self->vendor_rev); - } - err = _check_by_mode(self, - &_common_update_attr_vendor_rev, - "common_get_vendor_rev"); - memset(buf, 0, LEN_TRANSVR_M_STR); - if (err < 0){ - return snprintf(buf, LEN_TRANSVR_M_STR, "%d\n", err); - } - return snprintf(buf, LEN_TRANSVR_M_STR, "%s\n", self->vendor_rev); -} - - -int -common_get_vendor_sn(struct transvr_obj_s *self, char *buf) { - - int err = DEBUG_TRANSVR_INT_VAL; - - if (self->state == STATE_TRANSVR_CONNECTED && - self->mode == TRANSVR_MODE_POLLING && - TRANSVR_INFO_CACHE_ENABLE) { - return snprintf(buf, LEN_TRANSVR_M_STR, "%s\n", self->vendor_sn); - } - err = _check_by_mode(self, - &_common_update_attr_vendor_sn, - "common_get_vendor_sn"); - memset(buf, 0, LEN_TRANSVR_M_STR); - if (err < 0){ - return snprintf(buf, LEN_TRANSVR_M_STR, "%d\n", err); - } - return snprintf(buf, LEN_TRANSVR_M_STR, "%s\n", self->vendor_sn); -} - - -int -common_get_br(struct transvr_obj_s *self){ - - int err = DEBUG_TRANSVR_INT_VAL; - - if (self->state == STATE_TRANSVR_CONNECTED && - self->mode == TRANSVR_MODE_POLLING && - TRANSVR_INFO_CACHE_ENABLE) { - return (int)self->br; - } - err = _check_by_mode(self, - &_common_update_attr_br, - "common_get_br"); - if (err < 0){ - return err; - } - /* Transform to INT to show error case */ - return (int)self->br; -} - - -int -common_get_len_smf(struct transvr_obj_s *self){ - - int err = DEBUG_TRANSVR_INT_VAL; - - if (self->state == STATE_TRANSVR_CONNECTED && - self->mode == TRANSVR_MODE_POLLING && - TRANSVR_INFO_CACHE_ENABLE) { - return self->len_smf; - } - err = _check_by_mode(self, - &_common_update_attr_len_smf, - "common_get_len_smf"); - if (err < 0){ - return err; - } - return self->len_smf; -} - - -int -common_get_len_om1(struct transvr_obj_s *self){ - - int err = DEBUG_TRANSVR_INT_VAL; - - if (self->state == STATE_TRANSVR_CONNECTED && - self->mode == TRANSVR_MODE_POLLING && - TRANSVR_INFO_CACHE_ENABLE) { - return self->len_om1; - } - err = _check_by_mode(self, - &_common_update_attr_len_om1, - "common_get_len_om1"); - if (err < 0){ - return err; - } - return self->len_om1; -} - - -int -common_get_len_om2(struct transvr_obj_s *self){ - - int err = DEBUG_TRANSVR_INT_VAL; - - if (self->state == STATE_TRANSVR_CONNECTED && - self->mode == TRANSVR_MODE_POLLING && - TRANSVR_INFO_CACHE_ENABLE) { - return self->len_om2; - } - - err = _check_by_mode(self, - &_common_update_attr_len_om2, - "common_get_len_om2"); - if (err < 0){ - return err; - } - return self->len_om2; -} - - -int -common_get_len_om3(struct transvr_obj_s *self){ - - int err = DEBUG_TRANSVR_INT_VAL; - - if (self->state == STATE_TRANSVR_CONNECTED && - self->mode == TRANSVR_MODE_POLLING && - TRANSVR_INFO_CACHE_ENABLE) { - return self->len_om3; - } - - err = _check_by_mode(self, - &_common_update_attr_len_om3, - "common_get_len_om3"); - if (err < 0){ - return err; - } - return self->len_om3; -} - - -int -common_get_len_om4(struct transvr_obj_s *self){ - - int err = DEBUG_TRANSVR_INT_VAL; - - if (self->state == STATE_TRANSVR_CONNECTED && - self->mode == TRANSVR_MODE_POLLING && - TRANSVR_INFO_CACHE_ENABLE) { - return self->len_om4; - } - err = _check_by_mode(self, - &_common_update_attr_len_om4, - "common_get_len_om4"); - if (err < 0){ - return err; - } - return self->len_om4; -} - - -int -common_get_comp_extended(struct transvr_obj_s *self){ - - int err_code = _check_by_mode(self, - &_common_update_attr_transvr_comp_ext, - "common_get_comp_extended"); - if (err_code < 0){ - return err_code; - } - return self->transvr_comp_ext; -} - - -int -common_get_comp_rev(struct transvr_obj_s *self){ - - int err_code = _check_by_mode(self, - &_common_update_attr_comp_rev, - "common_get_comp_rev"); - if (err_code < 0){ - return err_code; - } - return self->comp_rev; -} - - -int -common_get_info(struct transvr_obj_s *self){ - - if (self->state != STATE_TRANSVR_CONNECTED) { - return self->state; - } - return self->info; -} - - -int -_common_get_if_lane(struct transvr_obj_s *self, - char *result){ - int i = 0; - int tmp_val = 0; - char tmp_str[LEN_TRANSVR_M_STR] = DEBUG_TRANSVR_STR_VAL; - - memset(result, 0, LEN_TRANSVR_M_STR); - - for (i=0; ilane_id); i++) { - tmp_val = self->lane_id[i]; - if (tmp_val < 1) { - break; - } - memset(tmp_str, 0, LEN_TRANSVR_M_STR); - if (i == 0) { - snprintf(tmp_str, LEN_TRANSVR_M_STR, "%d", tmp_val); - } else { - snprintf(tmp_str, LEN_TRANSVR_M_STR, ",%d", tmp_val); - } - strncat(result, tmp_str, LEN_TRANSVR_M_STR); - } - if (i == 0) { - return EVENT_TRANSVR_TASK_FAIL; - } - return 0; -} - - -int -common_get_if_lane(struct transvr_obj_s *self, - char *buf_p){ - - char tmp_str[LEN_TRANSVR_M_STR] = DEBUG_TRANSVR_STR_VAL; - - if (self->ioexp_obj_p->state != STATE_IOEXP_NORMAL) { - return snprintf(buf_p, LEN_TRANSVR_M_STR, "%d\n", ERR_TRANSVR_ABNORMAL); - } - if (_common_get_if_lane(self, tmp_str) < 0) { - return snprintf(buf_p, LEN_TRANSVR_M_STR, "%d\n" ,ERR_TRANSVR_ABNORMAL); - } - return snprintf(buf_p, LEN_TRANSVR_M_STR, "%s\n" ,tmp_str); -} - - -int -sfp_get_len_sm(struct transvr_obj_s *self){ - - int err_code = _check_by_mode(self, - &_sfp_update_attr_len_sm, - "sfp_get_len_sm"); - if (err_code < 0){ - return err_code; - } - return self->len_sm; -} - - -int -sfp_get_rate_id(struct transvr_obj_s *self){ - - int err_code = _check_by_mode(self, - &_sfp_update_attr_rate_id, - "sfp_get_rate_id"); - if (err_code < 0){ - return err_code; - } - return self->rate_id; -} - - -int -sfp_get_soft_rs0(struct transvr_obj_s *self){ - /* Note: - * SFP Soft Rate_Select Select [aka. "RS(0)"] address - * A2h, offset: 110, bit 3 (begin form 0) - */ - int err_code = DEBUG_TRANSVR_INT_VAL; - int bit_shift = 3; - uint8_t result = 0x00; - uint8_t bitmask = (1 << bit_shift); - - /* Check rate identifier is supported */ - err_code = self->get_rate_id(self); - if (err_code <= 0) { - return ERR_TRANSVR_NOTSUPPORT; - } - /* Update and check */ - err_code = _check_by_mode(self, - &_sfp_update_attr_soft_rs0, - "sfp_get_soft_rs0"); - if (err_code <0){ - return err_code; - } - result = (self->soft_rs0 & bitmask); - if (result == bitmask) { - return 1; - } - if (result == 0) { - return 0; - } - return ERR_TRANSVR_UNEXCPT; -} - - -int -sfp_get_soft_rs1(struct transvr_obj_s *self){ - /* Note: - * SFP Soft RS(1) Select address - * A2h, offset: 118, bit 3 (begin form 0) - */ - int err_code = DEBUG_TRANSVR_INT_VAL; - int bit_shift = 3; - uint8_t result = 0x00; - uint8_t bitmask = (1 << bit_shift); - - /* Check rate identifier is supported */ - err_code = self->get_rate_id(self); - if (err_code <= 0) { - return ERR_TRANSVR_NOTSUPPORT; - } - /* Update and check */ - err_code = _check_by_mode(self, - &_sfp_update_attr_soft_rs1, - "sfp_get_soft_rs1"); - if (err_code <0){ - return err_code; - } - result = (self->soft_rs1 & bitmask); - if (result == bitmask) { - return 1; - } - if (result == 0) { - return 0; - } - return ERR_TRANSVR_UNEXCPT; -} - - -int -sfp_get_transvr_temp(struct transvr_obj_s *self, - char *buf_p) { - - int lmax = 8; - int err_code = DEBUG_TRANSVR_INT_VAL; - - err_code = _check_by_mode(self, - &_sfp_update_attr_curr_temp, - "sfp_get_transvr_temp"); - if (err_code < 0) { - return snprintf(buf_p, lmax, "%d\n", err_code); - } - if ((self->curr_temp[0]) == DEBUG_TRANSVR_HEX_VAL) { - return snprintf(buf_p, lmax, "%d\n", ERR_TRANSVR_UPDATE_FAIL); - } - return _common_count_temp(self->curr_temp[0], - self->curr_temp[1], - buf_p); -} - - -int -sfp_get_transvr_voltage(struct transvr_obj_s *self, - char *buf_p) { - - int lmax = 8; - int err_code = DEBUG_TRANSVR_INT_VAL; - - err_code = _check_by_mode(self, - &_sfp_update_attr_curr_voltage, - "sfp_get_transvr_voltage"); - if (err_code < 0) { - return snprintf(buf_p, lmax, "%d\n", err_code); - } - if ((self->curr_voltage[0]) == DEBUG_TRANSVR_HEX_VAL) { - return snprintf(buf_p, lmax, "%d\n", ERR_TRANSVR_UPDATE_FAIL); - } - /* Return Unit: 1 Volt */ - return _common_count_voltage(self->curr_voltage[0], - self->curr_voltage[1], - buf_p); -} - - -int -sfp_get_transvr_tx_bias(struct transvr_obj_s *self, - char *buf_p) { - - int lmax = 8; - int err_code = DEBUG_TRANSVR_INT_VAL; - - err_code = _check_by_mode(self, - &_sfp_update_attr_curr_tx_bias, - "sfp_get_transvr_tx_bias"); - if (err_code < 0) { - return snprintf(buf_p, lmax, "%d\n", err_code); - } - if ((self->curr_tx_bias[0]) == DEBUG_TRANSVR_HEX_VAL) { - return snprintf(buf_p, lmax, "%d\n", ERR_TRANSVR_UPDATE_FAIL); - } - /* Return Unit: 1 mA */ - return _common_count_tx_bias(self->curr_tx_bias[0], - self->curr_tx_bias[1], - buf_p); -} - - -int -sfp_get_transvr_tx_power(struct transvr_obj_s *self, - char *buf_p) { - - int lmax = 8; - int err_code = DEBUG_TRANSVR_INT_VAL; - - err_code = _check_by_mode(self, - &_sfp_update_attr_curr_tx_power, - "sfp_get_transvr_tx_power"); - if (err_code < 0) { - return snprintf(buf_p, lmax, "%d\n", err_code); - } - if ((self->curr_tx_bias[0]) == DEBUG_TRANSVR_HEX_VAL) { - return snprintf(buf_p, lmax, "%d\n", ERR_TRANSVR_UPDATE_FAIL); - } - /* Return Unit: 1 mW */ - return _common_count_tx_power(self->curr_tx_power[0], - self->curr_tx_power[1], - buf_p); -} - - -int -sfp_get_transvr_rx_power(struct transvr_obj_s *self, - char *buf_p) { - - int lmax = 8; - int err_code = DEBUG_TRANSVR_INT_VAL; - - err_code = _check_by_mode(self, - &_sfp_update_attr_curr_rx_power, - "sfp_get_transvr_rx_power"); - if (err_code < 0) { - return snprintf(buf_p, lmax, "%d\n", err_code); - } - if ((self->curr_tx_bias[0]) == DEBUG_TRANSVR_HEX_VAL) { - return snprintf(buf_p, lmax, "%d\n", ERR_TRANSVR_UPDATE_FAIL); - } - /* Return Unit: 1 mW */ - return _common_count_rx_power(self->curr_rx_power[0], - self->curr_rx_power[0], - buf_p); -} - - -int -sfp_get_transvr_rx_em(struct transvr_obj_s *self, - char *buf_p) { - - int limt = 8; - int err = DEBUG_TRANSVR_INT_VAL; - - err = _check_by_mode(self, - &_sfp_update_attr_rx_em, - "sfp_get_transvr_rx_em"); - if (err < 0) { - return snprintf(buf_p, limt, "%d\n", err); - } - if ((self->tx_eq[0]) == DEBUG_TRANSVR_HEX_VAL) { - return snprintf(buf_p, limt, "%d\n", ERR_TRANSVR_UPDATE_FAIL); - } - return snprintf(buf_p, limt, "0x%02x\n", self->rx_em[0]); -} - - -int -sfp_get_transvr_tx_eq(struct transvr_obj_s *self, - char *buf_p) { - - int limt = 8; - int err = DEBUG_TRANSVR_INT_VAL; - - err = _check_by_mode(self, - &_sfp_update_attr_tx_eq, - "sfp_get_transvr_tx_eq"); - if (err < 0) { - return snprintf(buf_p, limt, "%d\n", err); - } - if ((self->tx_eq[0]) == DEBUG_TRANSVR_HEX_VAL) { - return snprintf(buf_p, limt, "%d\n", ERR_TRANSVR_UPDATE_FAIL); - } - return snprintf(buf_p, limt, "0x%02x\n", self->tx_eq[0]); -} - - -int -_sfp_get_comp_extended(struct transvr_obj_s *self) { - /* Address: A0h / 36 - * Reference: SFF-8024 TABLE 4-4 - */ - if ((self->state == STATE_TRANSVR_CONNECTED) || - (self->state == STATE_TRANSVR_INIT) ) { - return (int)(self->transvr_comp_ext); - } - return ERR_TRANSVR_ABNORMAL; -} - - -int -__sfp_get_comp_attr(struct transvr_obj_s *self, - int array_offset) { - /* SFP Specification Compliance: A0h / 3-10 - * transvr_comp[0-7] = 3 - 10 - */ - if ((self->state == STATE_TRANSVR_CONNECTED) || - (self->state == STATE_TRANSVR_INIT) ) { - return (int)(self->transvr_comp[array_offset]); - } - return ERR_TRANSVR_ABNORMAL; -} - - -int -_sfp_get_comp_10g_eth_comp(struct transvr_obj_s *self) { - /* transvr_comp[0] = address A0h / 3 - * - * 3 7: 10G Base-ER - * 3 6: 10GBASE-LRM - * 3 5: 10GBASE-LR - * 3 4: 10GBASE-SR - */ - int bitmask = 0xf0; /* 11110000 */ - return (__sfp_get_comp_attr(self, 0) & bitmask); -} - - -int -_sfp_get_comp_1g_eth_comp(struct transvr_obj_s *self) { - /* transvr_comp[3] = address A0h / 6 - * - * 6 7: BASE-PX *3 - * 6 6: BASE-BX10 *3 - * 6 5: 100BASE-FX - * 6 4: 100BASE-LX/LX10 - * 6 3: 1000BASE-T - * 6 2: 1000BASE-CX - * 6 1: 1000BASE-LX *3 - * 6 0: 1000BASE-SX - */ - return __sfp_get_comp_attr(self, 3); -} - - -int -_sfp_get_cable_tech(struct transvr_obj_s *self) { - /* transvr_comp[5] = address A0h / 8 - * - * 8 3: Active Cable *8 - * 8 2: Passive Cable *8 - */ - int bitmask = 0x0c; /* 00001100 */ - return (__sfp_get_comp_attr(self, 5) & bitmask); -} - - -int -sfp_get_comp_eth_1(struct transvr_obj_s *self){ - - int err_code = _check_by_mode(self, - &_common_update_attr_transvr_comp, - "sfp_get_comp_eth_1"); - if (err_code < 0){ - return err_code; - } - return _sfp_get_comp_1g_eth_comp(self); -} - - -int -sfp_get_comp_eth_10(struct transvr_obj_s *self){ - - int err_code = _check_by_mode(self, - &_common_update_attr_transvr_comp, - "sfp_get_comp_eth_10"); - if (err_code < 0){ - return err_code; - } - return _sfp_get_comp_10g_eth_comp(self); -} - - -int -_sfp_get_connector_type(struct transvr_obj_s *self) { - /* Address: A0h / 2 - * Reference: SFF-8024 TABLE 4-3 - */ - if ((self->state == STATE_TRANSVR_CONNECTED) || - (self->state == STATE_TRANSVR_INIT) ) { - return (int)(self->connector); - } - return ERR_TRANSVR_ABNORMAL; -} - - -int -sfp_get_wavelength(struct transvr_obj_s *self, - char *buf_p) { - /* [Note] Optical and Cable Variants Specification Compliance (SFF-8472) - * [Addr] A0h, Bytes 60-61 - * [Note] For optical variants, as defined by having zero's in A0h Byte 8 - * bits 2 and 3, Bytes 60 and 61 denote nominal transmitter output - * wavelength at room temperature. 16 bit value with byte 60 as high - * order byte and byte 61 as low order byte. The laser wavelength is - * equal to the 16 bit integer value in nm. This field allows the user - * to read the laser wavelength directly, so it is not necessary to - * infer it from the Transceiver Codes A0h Bytes 3 to 10 (see Table - * 5-3). This also allows specification of wavelengths not covered - * in the Transceiver Codes, such as those used in coarse WDM systems. - * - * For passive and active cable variants, a value of 00h for both A0h - * Byte 60 and Byte 61 denotes laser wavelength or cable specification - * compliance is unspecified. - */ - - int lmax = 8; - int err_code = DEBUG_TRANSVR_INT_VAL; - - err_code = _check_by_mode(self, - &_common_update_attr_wavelength, - "common_get_wavelength"); - if (err_code < 0) { - return snprintf(buf_p, lmax, "%d\n", err_code); - } - if ((self->wavelength[0]) == DEBUG_TRANSVR_HEX_VAL) { - return snprintf(buf_p, lmax, "%d\n", ERR_TRANSVR_UPDATE_FAIL); - } - /* unit: 1 um */ - return snprintf(buf_p, lmax, "%d\n", - _common_count_wavelength(self, - self->wavelength[0], - self->wavelength[1])); -} - - -int -sfp_get_1g_rj45_extphy_offset(struct transvr_obj_s *self, char *buf) { - - if (self->state != STATE_TRANSVR_CONNECTED) { - return ERR_TRANSVR_UNPLUGGED; - } - if ((self->info != TRANSVR_CLASS_BASE_T_1000) && - (self->info != TRANSVR_CLASS_BASE_T_1000_up) ){ - return ERR_TRANSVR_NOTSUPPORT; - } - return snprintf(buf, LEN_TRANSVR_S_STR, "0x%02x\n", self->extphy_offset); -} - - -int -sfp_get_1g_rj45_extphy_reg(struct transvr_obj_s *self, char *buf) { - - int i = 0; - int ret = 0; - int retry = 3; - int delay = 200; - - if (self->state != STATE_TRANSVR_CONNECTED) { - return ERR_TRANSVR_UNPLUGGED; - } - if ((self->info != TRANSVR_CLASS_BASE_T_1000) && - (self->info != TRANSVR_CLASS_BASE_T_1000_up) ){ - return ERR_TRANSVR_NOTSUPPORT; - } - if (_common_setup_page(self, VAL_TRANSVR_EXTPHY_ADDR_56, - -1, self->extphy_offset, 1, 0) < 0) { - return -EIO; - } - for (i=0; ii2c_client_p, self->extphy_offset); - if (ret >=0) { - goto ok_sfp_get_1g_rj45_extphy_reg; - } - msleep(delay); - } - SWPS_INFO("%s: retry:%d fail :%s :0x%02x\n", - __func__, retry, self->swp_name, self->extphy_offset); - return -EIO; - -ok_sfp_get_1g_rj45_extphy_reg: - ret = ((ret & 0x00ff) << 8) | ((ret & 0xff00) >> 8); - return snprintf(buf, LEN_TRANSVR_S_STR, "0x%04x\n", ret); -} - - -int -__qsfp_get_power_cls(struct transvr_obj_s *self, - int direct_access){ - - int err_code; - uint8_t detect_val; - - /* Detect and Update power class attribute */ - if (direct_access){ - err_code = _check_by_mode(self, - &_common_update_attr_extended_id, - "__qsfp_get_power_cls"); - } else { - err_code = self->ext_id; - } - if (err_code <0){ - return err_code; - } - if (err_code == DEBUG_TRANSVR_HEX_VAL){ - return ERR_TRANSVR_UPDATE_FAIL; - } - /* Clean data */ - detect_val = self->ext_id; - SWP_BIT_CLEAR(detect_val, 2); /* Bit2: CDR RX present */ - SWP_BIT_CLEAR(detect_val, 3); /* Bit3: CDR TX present */ - SWP_BIT_CLEAR(detect_val, 4); /* Bit4: CLEI present */ - SWP_BIT_CLEAR(detect_val, 5); /* Bit5: reserved */ - /* Identify power class */ - switch (detect_val) { - case 0: /* Class_1: 00000000 */ - return 1; - case 64: /* Class_2: 01000000 */ - return 2; - case 128: /* Class_3: 10000000 */ - return 3; - case 192: /* Class_4: 11000000 */ - return 4; - case 1: /* Class_5: 00000001 */ - case 193: /* Class_5: 11000001 */ - return 5; - case 2: /* Class_6: 00000010 */ - case 194: /* Class_6: 11000010 */ - return 6; - case 3: /* Class_7: 00000011 */ - case 195: /* Class_7: 11000011 */ - return 7; - default: - break; - } - SWPS_INFO("%s: Detect undefined power class:%d\n", __func__, detect_val); - return ERR_TRANSVR_UNDEFINED; -} - - -int -qsfp_get_power_cls(struct transvr_obj_s *self) { - return __qsfp_get_power_cls(self, 1); -} - - -int -__qsfp_get_cdr_present(struct transvr_obj_s *self, - int direct_access){ - - int retval; - int BIT_SHIFT = 2; - int BIT_MASK = 0x3; - - /* Detect and Update power class attribute */ - if (direct_access) { - retval = _check_by_mode(self, - &_common_update_attr_extended_id, - "__qsfp_get_cdr_present"); - if (retval < 0){ - return retval; - } - } - retval = self->ext_id; - if (retval == DEBUG_TRANSVR_HEX_VAL){ - return ERR_TRANSVR_UPDATE_FAIL; - } - /* Clean data and return */ - return (int)(retval >> BIT_SHIFT & BIT_MASK); -} - - -int -qsfp_get_cdr_present(struct transvr_obj_s *self) { - return __qsfp_get_cdr_present(self, 1); -} - - -int -qsfp_get_cdr(struct transvr_obj_s *self){ - - int err_code = _check_by_mode(self, - &_qsfp_update_attr_cdr, - "qsfp_get_cdr"); - if (err_code <0){ - return err_code; - } - - return self->cdr; -} - - -int -__qsfp_get_comp_attr(struct transvr_obj_s *self, - int array_offset) { - /* QSFP Specification Compliance: 00h / 131-138 - * transvr_comp[0-7] = 131 - 138 - */ - if ((self->state == STATE_TRANSVR_CONNECTED) || - (self->state == STATE_TRANSVR_INIT) ) { - return (int)(self->transvr_comp[array_offset]); - } - return ERR_TRANSVR_ABNORMAL; -} - - -int -_qsfp_get_comp_10_40_100_ethernet(struct transvr_obj_s *self) { - /* transvr_comp[0] = address 00h / 131 - * - * 131 7: Extended: See section 6.3.23. The Extended Specification Compliance - * Codes are maintained in the Transceiver Management section of SFF- - * 8024. - * 131 6: 10GBASE-LRM - * 131 5: 10GBASE-LR - * 131 4: 10GBASE-SR - * 131 3: 40GBASE-CR4 - * 131 2: 40GBASE-SR4 - * 131 1: 40GBASE-LR4 - * 131 0: 40G Active Cable (XLPPI) - */ - return __qsfp_get_comp_attr(self, 0); -} - - -int -_qsfp_get_comp_sonet(struct transvr_obj_s *self) { - /* transvr_comp[1] = address 00h / 132 - * - * 132 7-3: Reserved - * 132 2: OC 48, long reach - * 132 1: OC 48, intermediate reach - * 132 0: OC 48 short reach - */ - return __qsfp_get_comp_attr(self, 1); -} - - -int -_qsfp_get_comp_sas_sata(struct transvr_obj_s *self) { - /* transvr_comp[1] = address 00h / 132 - * - * 133 7: SAS 24.0 Gb/s - * 133 6: SAS 12.0 Gb/s - * 133 5: SAS 6.0 Gb/s - * 133 4: SAS 3.0 Gb/s - * 133 3-0: Reserved - */ - return __qsfp_get_comp_attr(self, 2); -} - - -int -_qsfp_get_comp_ethernet(struct transvr_obj_s *self) { - /* transvr_comp[1] = address 00h / 132 - * - * 134 7-4: Reserved - * 134 3: 1000BASE-T - * 134 2: 1000BASE-CX - * 134 1: 1000BASE-LX - * 134 0: 1000BASE-SX - */ - return __qsfp_get_comp_attr(self, 3); -} - - -int -_qsfp_get_comp_fc_link_length(struct transvr_obj_s *self) { - /* transvr_comp[1] = address 00h / 132 - * - * 135 7: Very long distance (V) - * 135 6: Short distance (S) - * 135 5: Intermediate distance (I) - * 135 4: Long distance (L) - * 135 3: Medium (M) - */ - int mask = 0xFC; /* 11111100 */ - return (__qsfp_get_comp_attr(self, 4) & mask); -} - - -int -_qsfp_get_comp_fc_trans_tech(struct transvr_obj_s *self) { - /* transvr_comp[1] = address 00h / 132 - * - * 135 2: Reserved - * 135 1: Longwave laser (LC) - * 135 0: Electrical inter-enclosure (EL) - * - * 136 7: Electrical intra-enclosure - * 136 6: Shortwave laser w/o OFC (SN) - * 136 5: Shortwave laser w OFC (SL) - * 136 4: Longwave Laser (LL) - * 136 3-0: Reserved - * - * return value = [bit 8-15:addr 135][bit 0-7:addr 136] - */ - int mask_135 = 7; /* 00000111 */ - int val_135 = (__qsfp_get_comp_attr(self, 4) & mask_135); - int val_136 = __qsfp_get_comp_attr(self, 5); - return ((val_135 << 7) + val_136); -} - - -int -_qsfp_get_comp_fc_trans_media(struct transvr_obj_s *self) { - /* transvr_comp[1] = address 00h / 132 - * - * 137 7: Twin Axial Pair (TW) - * 137 6: Shielded Twisted Pair (TP) - * 137 5: Miniature Coax (MI) - * 137 4: Video Coax (TV) - * 137 3: Multi-mode 62.5 m (M6) - * 137 2: Multi-mode 50 m (M5) - * 137 1: Multi-mode 50 um (OM3) - * 137 0: Single Mode (SM) - */ - return __qsfp_get_comp_attr(self, 6); -} - - -int -_qsfp_get_comp_fc_speed(struct transvr_obj_s *self) { - /* transvr_comp[1] = address 00h / 132 - * - * 138 7: 1200 MBps (per channel) - * 138 6: 800 MBps - * 138 5: 1600 MBps (per channel) - * 138 4: 400 MBps - * 138 3: 3200 MBps (per channel) - * 138 2: 200 MBps - * 138 1: Extended: See section 6.3.23. The Extended Specification - * Compliance Codes are maintained in the Transceiver Management - * section of SFF-8024. - * 138 0: 100 MBps - */ - return __qsfp_get_comp_attr(self, 7); -} - - -int -_qsfp_get_comp_extended(struct transvr_obj_s *self) { - /* Address: 00h / 192 - * Reference: SFF-8024 TABLE 4-4 - */ - if ((self->state == STATE_TRANSVR_CONNECTED) || - (self->state == STATE_TRANSVR_INIT) ) { - return (int)(self->transvr_comp_ext); - } - return ERR_TRANSVR_ABNORMAL; -} - - -int -qsfp_get_comp_eth(struct transvr_obj_s *self){ - - int err_code = _check_by_mode(self, - &_common_update_attr_transvr_comp, - "qsfp_get_comp_eth"); - if (err_code < 0){ - return err_code; - } - return _qsfp_get_comp_ethernet(self); -} - - -int -qsfp_get_comp_10_40(struct transvr_obj_s *self) { - - int err_code = _check_by_mode(self, - &_common_update_attr_transvr_comp, - "qsfp_get_comp_10_40"); - if (err_code < 0){ - return err_code; - } - return _qsfp_get_comp_10_40_100_ethernet(self); -} - - -int -_qsfp_get_connector_type(struct transvr_obj_s *self) { - /* Address: 00h / 130 - * Reference: SFF-8024 TABLE 4-3 - */ - if ((self->state == STATE_TRANSVR_CONNECTED) || - (self->state == STATE_TRANSVR_INIT) ) { - return (int)(self->connector); - } - return ERR_TRANSVR_ABNORMAL; -} - - -int -qsfp_get_transvr_temp(struct transvr_obj_s *self, - char *buf_p) { - - int lmax = 8; - int err_code = DEBUG_TRANSVR_INT_VAL; - - err_code = _check_by_mode(self, - &_qsfp_update_attr_curr_temp, - "qsfp_get_transvr_temp"); - if (err_code < 0) { - return snprintf(buf_p, lmax, "%d\n", err_code); - } - if ((self->curr_temp[0]) == DEBUG_TRANSVR_HEX_VAL) { - return snprintf(buf_p, lmax, "%d\n", ERR_TRANSVR_UPDATE_FAIL); - } - return _common_count_temp(self->curr_temp[0], - self->curr_temp[1], - buf_p); -} - - -int -qsfp_get_transvr_voltage(struct transvr_obj_s *self, - char *buf_p) { - - int lmax = 8; - int err_code = DEBUG_TRANSVR_INT_VAL; - - err_code = _check_by_mode(self, - &_qsfp_update_attr_curr_voltage, - "qsfp_get_transvr_voltage"); - if (err_code < 0) { - return snprintf(buf_p, lmax, "%d\n", err_code); - } - if ((self->curr_voltage[0]) == DEBUG_TRANSVR_HEX_VAL) { - return snprintf(buf_p, lmax, "%d\n", ERR_TRANSVR_UPDATE_FAIL); - } - /* Return Unit: 1 Volt */ - return _common_count_voltage(self->curr_voltage[0], - self->curr_voltage[1], - buf_p); -} - - -int -qsfp_get_transvr_tx_eq(struct transvr_obj_s *self, - char *buf_p) { - - int limt = 8; - int err = DEBUG_TRANSVR_INT_VAL; - - err = _check_by_mode(self, - &_qsfp_update_attr_tx_eq, - "qsfp_get_transvr_tx_eq"); - if (err < 0) { - return snprintf(buf_p, limt, "%d\n", err); - } - if ((self->tx_eq[0]) == DEBUG_TRANSVR_HEX_VAL) { - return snprintf(buf_p, limt, "%d\n", ERR_TRANSVR_UPDATE_FAIL); - } - return snprintf(buf_p, limt, "0x%02x%02x\n", - self->tx_eq[0], self->tx_eq[1]); -} - - -int -qsfp_get_transvr_rx_am(struct transvr_obj_s *self, - char *buf_p) { - - int limt = 8; - int err = DEBUG_TRANSVR_INT_VAL; - - err = _check_by_mode(self, - &_qsfp_update_attr_rx_am, - "qsfp_get_transvr_rx_am"); - if (err < 0) { - return snprintf(buf_p, limt, "%d\n", err); - } - if ((self->rx_am[0]) == DEBUG_TRANSVR_HEX_VAL) { - return snprintf(buf_p, limt, "%d\n", ERR_TRANSVR_UPDATE_FAIL); - } - return snprintf(buf_p, limt, "0x%02x%02x\n", - self->rx_am[0], self->rx_am[1]); -} - - -int -qsfp_get_transvr_rx_em(struct transvr_obj_s *self, - char *buf_p) { - - int limt = 8; - int err = DEBUG_TRANSVR_INT_VAL; - - err = _check_by_mode(self, - &_qsfp_update_attr_rx_em, - "qsfp_get_transvr_rx_em"); - if (err < 0) { - return snprintf(buf_p, limt, "%d\n", err); - } - if ((self->rx_em[0]) == DEBUG_TRANSVR_HEX_VAL) { - return snprintf(buf_p, limt, "%d\n", ERR_TRANSVR_UPDATE_FAIL); - } - return snprintf(buf_p, limt, "0x%02x%02x\n", - self->rx_em[0], self->rx_em[1]); -} - - -int -_qsfp_get_channel_diag(uint8_t *data_array, - int (*count_func)(uint8_t high_byte, uint8_t low_byte, char *buf_p), - char *ch_name, - char *result_p) { - int i, high, low; - int len_max = 128; - char ch_buf[4][16] = { DEBUG_TRANSVR_STR_VAL, - DEBUG_TRANSVR_STR_VAL, - DEBUG_TRANSVR_STR_VAL, - DEBUG_TRANSVR_STR_VAL }; - - for (i=0; i<4; i++) { - high = (i*2); - low = ((i*2) + 1); - count_func(data_array[high], data_array[low], ch_buf[i]); - } - return snprintf(result_p, len_max, - "%s-%d:%s%s-%d:%s%s-%d:%s%s-%d:%s", - ch_name, 1, ch_buf[0], - ch_name, 2, ch_buf[1], - ch_name, 3, ch_buf[2], - ch_name, 4, ch_buf[3]); -} - - -int -qsfp_get_soft_rx_los(struct transvr_obj_s *self, - char *buf_p) { - - int lmax = 8; - int mask = 0x0f; /* Bit 0 ~ Bit 3 */ - int err_code = DEBUG_TRANSVR_INT_VAL; - - err_code = _check_by_mode(self, - &_qsfp_update_attr_soft_rx_los, - "qsfp_get_soft_rx_los"); - if (err_code < 0) { - return snprintf(buf_p, lmax, "%d\n", err_code); - } - return snprintf(buf_p, lmax, "0x%02x\n", (self->rx_los & mask)); -} - - -int -qsfp_get_soft_tx_disable(struct transvr_obj_s *self, - char *buf_p) { - - int lmax = 8; - int mask = 0x0f; /* Bit 0 ~ Bit 3 */ - int err_code = DEBUG_TRANSVR_INT_VAL; - - err_code = _check_by_mode(self, - &_qsfp_update_attr_soft_tx_disable, - "qsfp_get_soft_tx_disable"); - if (err_code < 0) { - return snprintf(buf_p, lmax, "%d\n", err_code); - } - return snprintf(buf_p, lmax, "0x%02x\n", (self->tx_disable & mask)); -} - - -int -qsfp_get_soft_tx_fault(struct transvr_obj_s *self, - char *buf_p) { - - int lmax = 8; - int mask = 0x0f; /* Bit 0 ~ Bit 3 */ - int err_code = DEBUG_TRANSVR_INT_VAL; - - err_code = _check_by_mode(self, - &_qsfp_update_attr_soft_tx_fault, - "qsfp_get_soft_tx_fault"); - if (err_code < 0) { - return snprintf(buf_p, lmax, "%d\n", err_code); - } - return snprintf(buf_p, lmax, "0x%02x\n", (self->tx_fault & mask)); -} - - -int -qsfp_get_auto_tx_disable(struct transvr_obj_s *self, - char *buf_p) { - - if (self->auto_tx_disable == VAL_TRANSVR_FUNCTION_DISABLE) { - return snprintf(buf_p, LEN_TRANSVR_S_STR, - "%d\n", ERR_TRANSVR_FUNC_DISABLE); - } - return snprintf(buf_p, LEN_TRANSVR_S_STR, - "0x%02x\n", self->auto_tx_disable); -} - - -int -qsfp_get_transvr_tx_bias(struct transvr_obj_s *self, - char *buf_p) { - - int lmax = 8; - int err_code = DEBUG_TRANSVR_INT_VAL; - char *ch_name = "TX"; - - err_code = _check_by_mode(self, - &_qsfp_update_attr_curr_tx_bias, - "qsfp_get_transvr_tx_bias"); - if (err_code < 0) { - return snprintf(buf_p, lmax, "%d\n", err_code); - } - if ((self->curr_tx_bias[0]) == DEBUG_TRANSVR_HEX_VAL) { - return snprintf(buf_p, lmax, "%d\n", ERR_TRANSVR_UPDATE_FAIL); - } - /* Return Unit: 1 mA */ - return _qsfp_get_channel_diag(self->curr_tx_bias, - _common_count_tx_bias, - ch_name, - buf_p); -} - - -int -qsfp_get_transvr_tx_power(struct transvr_obj_s *self, - char *buf_p) { - - int lmax = 8; - int err_code = DEBUG_TRANSVR_INT_VAL; - char *ch_name = "TX"; - - err_code = _check_by_mode(self, - &_qsfp_update_attr_curr_tx_power, - "qsfp_get_transvr_tx_power"); - if (err_code < 0) { - return snprintf(buf_p, lmax, "%d\n", err_code); - } - if ((self->curr_tx_power[0]) == DEBUG_TRANSVR_HEX_VAL) { - return snprintf(buf_p, lmax, "%d\n", ERR_TRANSVR_UPDATE_FAIL); - } - /* Return Unit: 1 mW */ - return _qsfp_get_channel_diag(self->curr_tx_power, - _common_count_tx_power, - ch_name, - buf_p); -} - - -int -qsfp_get_transvr_rx_power(struct transvr_obj_s *self, - char *buf_p) { - - int lmax = 8; - int err_code = DEBUG_TRANSVR_INT_VAL; - char *ch_name = "RX"; - - err_code = _check_by_mode(self, - &_qsfp_update_attr_curr_rx_power, - "qsfp_get_transvr_rx_power"); - if (err_code < 0) { - return snprintf(buf_p, lmax, "%d\n", err_code); - } - if ((self->curr_tx_power[0]) == DEBUG_TRANSVR_HEX_VAL) { - return snprintf(buf_p, lmax, "%d\n", ERR_TRANSVR_UPDATE_FAIL); - } - /* Return Unit: 1 mW */ - return _qsfp_get_channel_diag(self->curr_rx_power, - _common_count_rx_power, - ch_name, - buf_p); -} - - -int -qsfp_get_wavelength(struct transvr_obj_s *self, - char *buf_p) { - /* [Desc] Wavelength or Copper Cable Attenuation (SFF-8636) - * [Addr] 00h 186-187 - * [Note] - * For optical free side devices, this parameter identifies the nominal - * transmitter output wavelength at room temperature. This parameter is - * a 16-bit hex value with Byte 186 as high order byte and Byte 187 as - * low order byte. The laser wavelength is equal to the 16-bit integer value - * divided by 20 in nm (units of 0.05 nm). This resolution should be adequate - * to cover all relevant wavelengths yet provide enough resolution for all - * expected DWDM applications. For accurate representation of controlled - * wavelength applications, this value should represent the center of the - * guaranteed wavelength range. - * If the free side device is identified as copper cable these registers will - * be used to define the cable attenuation. An indication of 0 dB attenuation - * refers to the case where the attenuation is not known or is unavailable. - * Byte 186 (00-FFh) is the copper cable attenuation at 2.5 GHz in units of 1 dB. - * Byte 187 (00-FFh) is the copper cable attenuation at 5.0 GHz in units of 1 dB. - */ - int lmax = 8; - int err_code = DEBUG_TRANSVR_INT_VAL; - - err_code = _check_by_mode(self, - &_common_update_attr_wavelength, - "common_get_wavelength"); - if (err_code < 0) { - return snprintf(buf_p, lmax, "%d\n", err_code); - } - if ((self->wavelength[0]) == DEBUG_TRANSVR_HEX_VAL) { - return snprintf(buf_p, lmax, "%d\n", ERR_TRANSVR_UPDATE_FAIL); - } - /* unit: 1 um */ - return snprintf(buf_p, lmax, "%d\n", - _common_count_wavelength(self, - self->wavelength[0], - self->wavelength[1])); -} - - -/* Public Function for Setup Features - */ -static int -__sfp_set_soft_rs(struct transvr_obj_s *self, - int input_val, - int address, - int page, - int offset, - int bit_shift, - uint8_t *attr_p, - char *caller, - int show_err) { - - int retval = ERR_TRANSVR_UNEXCPT; - int err_code = ERR_TRANSVR_UNEXCPT; - char *err_msg = DEBUG_TRANSVR_STR_VAL; - uint8_t update_val = (*attr_p); - - switch (input_val) { - case 0: - SWP_BIT_CLEAR(update_val, bit_shift); - break; - case 1: - SWP_BIT_SET(update_val, bit_shift); - break; - default: - retval = ERR_TRANSVR_UNEXCPT; - err_code = ERR_TRANSVR_UNEXCPT; - err_msg = "Exception occurs"; - goto err_private_sfp_set_soft_rs_1; - } - err_code = _common_set_uint8_attr(self, - address, - page, - offset, - update_val, - attr_p, - caller, - show_err); - if (err_code < 0) { - retval = err_code; - err_msg = "Write data via i2c fail!"; - goto err_private_sfp_set_soft_rs_1; - } - (*attr_p) = update_val; - return 0; - -err_private_sfp_set_soft_rs_1: - if (show_err) { - SWPS_INFO("%s: %s :%d :%s\n :%d\n", - __func__, err_msg, err_code, self->swp_name, input_val); - } - return retval; -} - - -static int -_sfp_set_soft_rs(struct transvr_obj_s *self, - int input_val, - int address, - int page, - int offset, - int bit_shift, - int (*attr_update_func)(struct transvr_obj_s *self, int show_err), - uint8_t *attr_p, - char *caller, - int show_err) { - - int retval = ERR_TRANSVR_UNEXCPT; - int err_code = ERR_TRANSVR_UNEXCPT; - char *err_msg = DEBUG_TRANSVR_STR_VAL; - - /* Check input value */ - if ((input_val != 0) && (input_val != 1)){ - retval = ERR_TRANSVR_BADINPUT; - err_code = ERR_TRANSVR_BADINPUT; - err_msg = "Input range incorrect!"; - goto err_common_sfp_set_soft_rs_1; - } - /* Check rate identifier is supported */ - err_code = self->get_rate_id(self); - if (err_code <= 0) { - switch (err_code) { - case 0: - retval = ERR_TRANSVR_NOTSUPPORT; - err_msg = "Not support this feature"; - break; - case ERR_TRANSVR_UNINIT: - retval = ERR_TRANSVR_UNINIT; - err_msg = "Check CDR present fail!"; - break; - case ERR_TRANSVR_UNPLUGGED: - retval = ERR_TRANSVR_UNPLUGGED; - err_msg = "Transceiver unplugged!"; - break; - default: - retval = err_code; - err_msg = "Check Rate_ID fail!"; - break; - } - goto err_common_sfp_set_soft_rs_1; - } - /* Check and update */ - err_code = _check_by_mode(self, - attr_update_func, - caller); - if ( (err_code < 0) || - ((*attr_p) == DEBUG_TRANSVR_HEX_VAL) ){ - retval = err_code; - err_msg = "Get current value fail!"; - goto err_common_sfp_set_soft_rs_1; - } - /* Generate and update value */ - return __sfp_set_soft_rs(self, - input_val, - address, - page, - offset, - bit_shift, - attr_p, - caller, - show_err); - -err_common_sfp_set_soft_rs_1: - if (show_err) { - SWPS_INFO("%s: %s :%d :%s\n :%d\n", - __func__, err_msg, err_code, self->swp_name, input_val); - } - return retval; -} - - -int -sfp_set_soft_rs0(struct transvr_obj_s *self, - int input_val) { - /* Note: - * SFP Soft Rate_Select Select RX ["RS(0)"] address - * A2h, offset: 110, bit 3 - */ - int bit_shift = 3; - int show_err = 1; - return _sfp_set_soft_rs(self, - input_val, - self->eeprom_map_p->addr_soft_rs0, - self->eeprom_map_p->page_soft_rs0, - self->eeprom_map_p->offset_soft_rs0, - bit_shift, - &_sfp_update_attr_soft_rs0, - &(self->soft_rs0), - "sfp_set_soft_rs0", - show_err); -} - - -int -sfp_set_soft_rs1(struct transvr_obj_s *self, - int input_val) { - /* Note: - * SFP Soft Rate_Select Select RX ["RS(1)"] address - * A2h, offset: 118, bit 3 - */ - int bit_shift = 3; - int show_err = 1; - return _sfp_set_soft_rs(self, - input_val, - self->eeprom_map_p->addr_soft_rs1, - self->eeprom_map_p->page_soft_rs1, - self->eeprom_map_p->offset_soft_rs1, - bit_shift, - &_sfp_update_attr_soft_rs1, - &(self->soft_rs1), - "sfp_set_soft_rs1", - show_err); -} - - -int -__sfp_set_tx_eq(struct transvr_obj_s *self, - int input, - int show_e) { - - int err = DEBUG_TRANSVR_INT_VAL; - char *emsg = DEBUG_TRANSVR_STR_VAL; - uint8_t setv = DEBUG_TRANSVR_HEX_VAL; - - if ((input < 0) || (input > 0xFF)) { - emsg = "input incorrect"; - err = ERR_TRANSVR_BADINPUT; - goto err_sfp_set_tx_eq; - } - setv = (uint8_t)input; - if (self->tx_eq[0] == setv) { - return 0; - } - err = _common_set_uint8_attr(self, - self->eeprom_map_p->addr_tx_eq, - self->eeprom_map_p->page_tx_eq, - self->eeprom_map_p->offset_tx_eq, - setv, - &(self->tx_eq[0]), - "_sfp_set_tx_eq", - show_e); - if (err < 0) { - emsg = "set_uint8_attr fail"; - goto err_sfp_set_tx_eq; - } - return 0; - -err_sfp_set_tx_eq: - if (show_e) { - SWPS_INFO("%s: %s :%d\n", __func__, emsg, input); - } - return err; -} - - -int -_sfp_set_tx_eq(struct transvr_obj_s *self, - int input, - int show_e) { - - uint8_t tmp; - int i = 0; - int retry = 3; - - for (i=0; itx_eq[0]; - if (_sfp_update_attr_tx_eq(self, show_e) < 0){ - continue; - } - if (self->tx_eq[0] == tmp){ - return 0; - } - } - return ERR_TRANSVR_UPDATE_FAIL; -} - - -int -sfp_set_tx_eq(struct transvr_obj_s *self, - int input) { - - int err = _check_by_mode(self, - &_sfp_update_attr_tx_eq, - "sfp_set_tx_eq"); - if (err < 0) { - SWPS_DEBUG("%s: check fail :%d\n", __func__, err); - return err; - } - return _sfp_set_tx_eq(self, input, 1); -} - - -int -__sfp_set_rx_em(struct transvr_obj_s *self, - int input, - int show_e) { - - int err = DEBUG_TRANSVR_INT_VAL; - char *emsg = DEBUG_TRANSVR_STR_VAL; - uint8_t setv = DEBUG_TRANSVR_HEX_VAL; - - if ((input < 0) || (input > 0xFF)) { - emsg = "input incorrect"; - err = ERR_TRANSVR_BADINPUT; - goto err_sfp_set_rx_em; - } - setv = (uint8_t)input; - if (self->rx_em[0] == setv) { - return 0; - } - err = _common_set_uint8_attr(self, - self->eeprom_map_p->addr_rx_em, - self->eeprom_map_p->page_rx_em, - self->eeprom_map_p->offset_rx_em, - setv, - &(self->rx_em[0]), - "_sfp_set_rx_em", - show_e); - if (err < 0) { - emsg = "set_uint8_attr fail"; - goto err_sfp_set_rx_em; - } - return 0; - -err_sfp_set_rx_em: - if (show_e) { - SWPS_INFO("%s: %s :%d\n", __func__, emsg, input); - } - return err; -} - - -int -_sfp_set_rx_em(struct transvr_obj_s *self, - int input, - int show_e) { - - uint8_t tmp; - int i = 0; - int retry = 3; - - for (i=0; irx_em[0]; - if (_sfp_update_attr_rx_em(self, show_e) < 0){ - continue; - } - if (self->rx_em[0] == tmp){ - return 0; - } - } - return -1; -} - - -int -sfp_set_rx_em(struct transvr_obj_s *self, - int input) { - - int err = _check_by_mode(self, - &_sfp_update_attr_rx_em, - "sfp_set_rx_em"); - if (err < 0) { - SWPS_DEBUG("%s: check fail :%d\n", __func__, err); - return err; - } - return _sfp_set_rx_em(self, input, 1); -} - - -int -sfp_set_1g_rj45_extphy_offset(struct transvr_obj_s *self, - int input) { - - if (self->state != STATE_TRANSVR_CONNECTED) { - return ERR_TRANSVR_UNPLUGGED; - } - if ((self->info != TRANSVR_CLASS_BASE_T_1000) && - (self->info != TRANSVR_CLASS_BASE_T_1000_up) ){ - return ERR_TRANSVR_NOTSUPPORT; - } - if ((input < 0) || (input > 0xff)) { - return ERR_TRANSVR_BADINPUT; - } - self->extphy_offset = (uint8_t)input; - return 0; -} - - -int -sfp_set_1g_rj45_extphy_reg(struct transvr_obj_s *self, - int input) { - - int i = 0; - int retry = 3; - int delay = 200; - uint16_t tmp = 0; - - if (self->state != STATE_TRANSVR_CONNECTED) { - return ERR_TRANSVR_UNPLUGGED; - } - if ((self->info != TRANSVR_CLASS_BASE_T_1000) && - (self->info != TRANSVR_CLASS_BASE_T_1000_up) ){ - return ERR_TRANSVR_NOTSUPPORT; - } - if ((input < 0) || (input > 0xffff)) { - return ERR_TRANSVR_BADINPUT; - } - tmp = ((input & 0x00ff) << 8) | ((input & 0xff00) >> 8); - if (_common_setup_page(self, VAL_TRANSVR_EXTPHY_ADDR_56, - -1, self->extphy_offset, 1, 0) < 0) { - return -EIO; - } - for (i=0; i<=retry; i++) { - if (i2c_smbus_write_word_data(self->i2c_client_p, - self->extphy_offset, - tmp) >= 0) { - return 0; - } - msleep(delay); - } - SWPS_INFO("%s: retry:%d fail :%s :0x%02x\n", - __func__, retry, self->swp_name, self->extphy_offset); - return -EIO; -} - - -static int -__qsfp_set_cdr(struct transvr_obj_s *self, - int input_val, - int show_err) { - - uint8_t update_val; - int CDR_FEATURE_SUPPORTED = 0x3; - int retval = ERR_TRANSVR_UNEXCPT; - int err_code = ERR_TRANSVR_UNEXCPT; - char *err_msg = DEBUG_TRANSVR_STR_VAL; - char *func_name = "__qsfp_set_cdr"; - - /* Check input value */ - if ((input_val < 0) || (input_val > 0xff)){ - retval = ERR_TRANSVR_BADINPUT; - err_code = ERR_TRANSVR_BADINPUT; - err_msg = "Input range incorrect!"; - goto err_qsfp_set_cdr_1; - } - update_val = (uint8_t)input_val; - /* Check CDR supported by transceiver */ - err_code = qsfp_get_cdr_present(self); - if (err_code < 0) { - retval = err_code; - switch (err_code) { - case ERR_TRANSVR_UNINIT: - err_msg = "Check CDR present fail!"; - break; - case ERR_TRANSVR_UNPLUGGED: - err_msg = "Transceiver unplugged!"; - break; - default: - err_msg = "Check CDR present fail!"; - break; - } - goto err_qsfp_set_cdr_1; - } - if (err_code != CDR_FEATURE_SUPPORTED) { - retval = ERR_TRANSVR_NOTSUPPORT; - err_msg = "This transceiver not support CDR!"; - goto err_qsfp_set_cdr_1; - } - /* Check and update */ - err_code = _check_by_mode(self, - &_qsfp_update_attr_cdr, - func_name); - if ( (err_code < 0) || - (self->cdr == DEBUG_TRANSVR_HEX_VAL) ){ - retval = err_code; - err_msg = "Get current value fail!"; - goto err_qsfp_set_cdr_1; - } - /* Write input value to transceiver */ - return _common_set_uint8_attr(self, - self->eeprom_map_p->addr_cdr, - self->eeprom_map_p->page_cdr, - self->eeprom_map_p->offset_cdr, - update_val, - &(self->cdr), - func_name, - show_err); - -err_qsfp_set_cdr_1: - if (show_err) { - SWPS_INFO("%s: %s :%d :%s\n :%d\n", - __func__, err_msg, err_code, self->swp_name, input_val); - } - return retval; -} - - -int -qsfp_set_cdr(struct transvr_obj_s *self, - int input_val) { - return __qsfp_set_cdr(self, input_val, 1); -} - - -int -qsfp_set_soft_tx_disable(struct transvr_obj_s *self, - int input_val) { - - int show_err = 1; - int in_max = 0xf; /* 1111 */ - int in_min = 0x0; /* 0000 */ - int retval = DEBUG_TRANSVR_INT_VAL; - int update_val = DEBUG_TRANSVR_INT_VAL; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - - retval = _check_by_mode(self, - &_qsfp_update_attr_soft_tx_disable, - "qsfp_set_soft_tx_disable"); - if (retval < 0) { - snprintf(err_msg, 63, "Not ready. err:%d", retval); - goto err_qsfp_set_soft_tx_disable; - } - if ((input_val > in_max) || - (input_val < in_min) ){ - retval = ERR_TRANSVR_BADINPUT; - snprintf(err_msg, 63, "Input value:%d incorrect!", input_val); - goto err_qsfp_set_soft_tx_disable; - } - if ((self->tx_disable & 0x0f) == input_val) { - return 0; - } - update_val = ((self->tx_disable & 0xf0) & input_val); - retval = _common_set_uint8_attr(self, - self->eeprom_map_p->addr_tx_disable, - self->eeprom_map_p->page_tx_disable, - self->eeprom_map_p->offset_tx_disable, - input_val, - &(self->tx_disable), - "qsfp_set_tx_disable", - show_err); - if (retval < 0) { - snprintf(err_msg, 63, "_common_set_uint8_attr:%d fail!", retval); - goto err_qsfp_set_soft_tx_disable; - } - return 0; - -err_qsfp_set_soft_tx_disable: - SWPS_INFO("%s: %s :%s\n", __func__, err_msg, self->swp_name); - return retval; -} - - -int -_qsfp_set_auto_tx_disable(struct transvr_obj_s *self, - uint8_t update) { - - uint8_t tx_enable = 0x0; - int show_e = 1; - int err = DEBUG_TRANSVR_INT_VAL; - char *emsg = DEBUG_TRANSVR_STR_VAL; - - /* Handle timing issues */ - if (update != tx_enable) { - /* Note: - * Because there are some txvr has timing issues, - * therefore we need to execute reset cycle first. - * (enable -> other settings) - */ - err = _common_set_uint8_attr(self, - self->eeprom_map_p->addr_tx_disable, - self->eeprom_map_p->page_tx_disable, - self->eeprom_map_p->offset_tx_disable, - tx_enable, - &(self->tx_disable), - "_qsfp_set_auto_tx_disable", - show_e); - if (err < 0) { - emsg = "I2C set reset value fail"; - goto err_qsfp_set_auto_tx_disable; - } - mdelay(10); - } - /* Setup target value */ - err = _common_set_uint8_attr(self, - self->eeprom_map_p->addr_tx_disable, - self->eeprom_map_p->page_tx_disable, - self->eeprom_map_p->offset_tx_disable, - self->auto_tx_disable, - &(self->tx_disable), - "_qsfp_set_auto_tx_disable", - show_e); - if (err < 0) { - emsg = "I2C set target value fail"; - goto err_qsfp_set_auto_tx_disable; - } - /* Check and update */ - err = _common_update_uint8_attr(self, - self->eeprom_map_p->addr_tx_disable, - self->eeprom_map_p->page_tx_disable, - self->eeprom_map_p->offset_tx_disable, - self->eeprom_map_p->length_tx_disable, - &(self->tx_disable), - "_qsfp_set_auto_tx_disable", - show_e); - if (err < 0) { - emsg = "I2C get value fail"; - goto err_qsfp_set_auto_tx_disable; - } - if (self->tx_disable != update) { - emsg = "data not become effective"; - goto err_qsfp_set_auto_tx_disable; - } - return 0; - -err_qsfp_set_auto_tx_disable: - SWPS_DEBUG("%s: %s :%s\n", - __func__, emsg, self->swp_name); - return ERR_TRANSVR_UPDATE_FAIL; -} - - -int -qsfp_set_auto_tx_disable(struct transvr_obj_s *self, - int input_val) { - - int in_max = 0xf; /* 1111 */ - int in_min = 0x0; /* 0000 */ - int retval = DEBUG_TRANSVR_INT_VAL; - char *emsg = DEBUG_TRANSVR_STR_VAL; - - /* Update settings*/ - if (input_val == VAL_TRANSVR_FUNCTION_DISABLE) { - emsg = "User disable auto tx_disable"; - self->auto_tx_disable = VAL_TRANSVR_FUNCTION_DISABLE; - goto out_qsfp_set_auto_tx_disable; - } - if ((input_val > in_max) || (input_val < in_min) ){ - SWPS_INFO("%s: Input value:%d incorrect! :%s\n", - __func__, input_val, self->swp_name); - return ERR_TRANSVR_BADINPUT; - } - self->auto_tx_disable = input_val; - /* Check current soft tx_disable */ - retval = _check_by_mode(self, - &_qsfp_update_attr_soft_tx_disable, - "qsfp_set_auto_tx_disable"); - switch (retval) { - case 0: - break; - case ERR_TRANSVR_UNPLUGGED: - emsg = "Doesn't need to update"; - goto out_qsfp_set_auto_tx_disable; - default: - SWPS_INFO("%s: setup fail :%d :%s\n", - __func__, retval, self->swp_name); - return retval; - } - return _qsfp_set_auto_tx_disable(self, input_val); - -out_qsfp_set_auto_tx_disable: - SWPS_DEBUG("%s: %s :%s :%d\n :%d", - __func__, emsg, self->swp_name, input_val, retval); - return 0; -} - - -int -__qsfp_set_tx_eq(struct transvr_obj_s *self, - int input, - int show_e) { - /* [Note] - * 0x - */ - int err = DEBUG_TRANSVR_INT_VAL; - char *emsg = DEBUG_TRANSVR_STR_VAL; - uint8_t setv[2] = {0x00, 0x00}; - - if ((input < 0) || (input > 0xFFFF)) { - emsg = "input incorrect"; - err = ERR_TRANSVR_BADINPUT; - goto err_qsfp_set_tx_eq; - } - setv[0] = (uint8_t)((input & 0xFF00) >> 8); - setv[1] = (uint8_t)(input & 0xFF); - if ((self->tx_eq[0] == setv[0]) && - (self->tx_eq[1] == setv[1]) ) { - return 0; - } - err = _common_set_uint8_array(self, - self->eeprom_map_p->addr_tx_eq, - self->eeprom_map_p->page_tx_eq, - self->eeprom_map_p->offset_tx_eq, - self->eeprom_map_p->length_tx_eq, - setv, - self->tx_eq, - "_qsfp_set_tx_eq", - show_e); - if (err < 0) { - emsg = "set_uint8_array fail"; - goto err_qsfp_set_tx_eq; - } - return 0; - -err_qsfp_set_tx_eq: - if (show_e) { - SWPS_INFO("%s: %s :%d\n", __func__, emsg, input); - } - return err; -} - - -int -_qsfp_set_tx_eq(struct transvr_obj_s *self, - int input, - int show_e) { - - int i = 0; - int retry = 3; - uint8_t tmp[2]; - - for (i=0; itx_eq[0]; - tmp[1] = self->tx_eq[1]; - if (_qsfp_update_attr_tx_eq(self, show_e) < 0){ - continue; - } - if ((self->tx_eq[0] == tmp[0]) && - (self->tx_eq[1] == tmp[1]) ){ - return 0; - } - } - return -1; -} - - -int -qsfp_set_tx_eq(struct transvr_obj_s *self, - int input) { - - int err = _check_by_mode(self, - &_qsfp_update_attr_tx_eq, - "qsfp_set_tx_eq"); - if (err < 0) { - SWPS_DEBUG("%s: check fail :%d\n", __func__, err); - return err; - } - return _qsfp_set_tx_eq(self, input, 1); -} - - -int -__qsfp_set_rx_am(struct transvr_obj_s *self, - int input, - int show_e) { - /* [Note] - * 0x - */ - int err = DEBUG_TRANSVR_INT_VAL; - char *emsg = DEBUG_TRANSVR_STR_VAL; - uint8_t setv[2] = {0x00, 0x00}; - - if ((input < 0) || (input > 0xFFFF)) { - emsg = "input incorrect"; - err = ERR_TRANSVR_BADINPUT; - goto err_qsfp_set_rx_am; - } - setv[0] = (uint8_t)((input & 0xFF00) >> 8); - setv[1] = (uint8_t)(input & 0xFF); - if ((self->rx_am[0] == setv[0]) && - (self->rx_am[1] == setv[1]) ) { - return 0; - } - err = _common_set_uint8_array(self, - self->eeprom_map_p->addr_rx_am, - self->eeprom_map_p->page_rx_am, - self->eeprom_map_p->offset_rx_am, - self->eeprom_map_p->length_rx_am, - setv, - self->rx_am, - "_qsfp_set_rx_am", - show_e); - if (err < 0) { - emsg = "set_uint8_array fail"; - goto err_qsfp_set_rx_am; - } - return 0; - -err_qsfp_set_rx_am: - if (show_e) { - SWPS_INFO("%s: %s :%d\n", __func__, emsg, input); - } - return err; -} - - -int -_qsfp_set_rx_am(struct transvr_obj_s *self, - int input, - int show_e) { - - int i = 0; - int retry = 3; - uint8_t tmp[2]; - - for (i=0; irx_am[0]; - tmp[1] = self->rx_am[1]; - if (_qsfp_update_attr_rx_am(self, show_e) < 0){ - continue; - } - if ((self->rx_am[0] == tmp[0]) && - (self->rx_am[1] == tmp[1]) ){ - return 0; - } - } - return -1; -} - - -int -qsfp_set_rx_am(struct transvr_obj_s *self, - int input) { - - int err = _check_by_mode(self, - &_qsfp_update_attr_rx_am, - "qsfp_set_rx_am"); - if (err < 0) { - SWPS_DEBUG("%s: check fail :%d\n", __func__, err); - return err; - } - return _qsfp_set_rx_am(self, input, 1); -} - - -int -__qsfp_set_rx_em(struct transvr_obj_s *self, - int input, - int show_e) { - /* [Note] - * 0x - */ - int err = DEBUG_TRANSVR_INT_VAL; - char *emsg = DEBUG_TRANSVR_STR_VAL; - uint8_t setv[2] = {0x00, 0x00}; - - if ((input < 0) || (input > 0xFFFF)) { - emsg = "input incorrect"; - err = ERR_TRANSVR_BADINPUT; - goto err_qsfp_set_rx_em; - } - setv[0] = (uint8_t)((input & 0xFF00) >> 8); - setv[1] = (uint8_t)(input & 0xFF); - if ((self->rx_em[0] == setv[0]) && - (self->rx_em[1] == setv[1]) ) { - return 0; - } - err = _common_set_uint8_array(self, - self->eeprom_map_p->addr_rx_em, - self->eeprom_map_p->page_rx_em, - self->eeprom_map_p->offset_rx_em, - self->eeprom_map_p->length_rx_em, - setv, - self->rx_em, - "_qsfp_set_rx_em", - show_e); - if (err < 0) { - emsg = "set_uint8_array fail"; - goto err_qsfp_set_rx_em; - } - return 0; - -err_qsfp_set_rx_em: - if (show_e) { - SWPS_INFO("%s: %s :%d\n", __func__, emsg, input); - } - return err; -} - - -int -_qsfp_set_rx_em(struct transvr_obj_s *self, - int input, - int show_e) { - - int i = 0; - int retry = 3; - uint8_t tmp[2]; - - for (i=0; irx_em[0]; - tmp[1] = self->rx_em[1]; - if (_qsfp_update_attr_rx_em(self, show_e) < 0){ - continue; - } - if ((self->rx_em[0] == tmp[0]) && - (self->rx_em[1] == tmp[1]) ){ - return 0; - } - } - return -1; -} - - -int -qsfp_set_rx_em(struct transvr_obj_s *self, - int input) { - - int err = _check_by_mode(self, - &_qsfp_update_attr_rx_em, - "qsfp_set_rx_em"); - if (err < 0) { - SWPS_DEBUG("%s: check fail :%d\n", __func__, err); - return err; - } - return _qsfp_set_rx_em(self, input, 1); -} - - -int -common_transvr_dump(struct transvr_obj_s* self){ - - char *type_name = "Undefined"; - - if (TRANSVR_INFO_DUMP_ENABLE != 1) { - return 0; - } - switch (self->type) { - case TRANSVR_TYPE_SFP: - type_name = STR_TRANSVR_SFP; - break; - case TRANSVR_TYPE_QSFP: - type_name = STR_TRANSVR_QSFP; - break; - case TRANSVR_TYPE_QSFP_PLUS: - type_name = STR_TRANSVR_QSFP_PLUS; - break; - case TRANSVR_TYPE_QSFP_28: - type_name = STR_TRANSVR_QSFP28; - break; - case TRANSVR_TYPE_FAKE: - type_name = "FAKE"; - goto ok_common_transvr_dump; - case TRANSVR_TYPE_UNPLUGGED: - type_name = "UNPLUGGED"; - goto err_common_transvr_dump; - case TRANSVR_TYPE_INCONSISTENT: - type_name = "INCONSISTENT"; - goto err_common_transvr_dump; - case TRANSVR_TYPE_ERROR: - type_name = "ERROR"; - goto err_common_transvr_dump; - - default: - type_name = "UNEXPECTED"; - goto err_common_transvr_dump; - } - printk(KERN_INFO "[SWPS] Dump %s information:\n", self->swp_name); - printk(KERN_INFO " |- :%s\n", type_name); - printk(KERN_INFO " |- :%s\n", self->vendor_name); - printk(KERN_INFO " |- :%s\n", self->vendor_pn); - printk(KERN_INFO " |- :%s\n", self->vendor_rev); - printk(KERN_INFO " |- :%s\n", self->vendor_sn); - printk(KERN_INFO " |- :0x%02x\n", self->br); - printk(KERN_INFO " |- :0x%02x\n", self->comp_rev); - printk(KERN_INFO " |- :%d\n", self->len_om1); - printk(KERN_INFO " |- :%d\n", self->len_om2); - printk(KERN_INFO " |- :%d\n", self->len_om3); - printk(KERN_INFO " |- :%d\n", self->len_om4); - return 0; - -ok_common_transvr_dump: - SWPS_INFO("%s: %s is %s\n", __func__, self->swp_name, type_name); - return 0; - -err_common_transvr_dump: - SWPS_INFO("%s: %s is %s\n", __func__, self->swp_name, type_name); - return -1; -} - - -int -sfp_transvr_dump(struct transvr_obj_s* self) { - - if (TRANSVR_INFO_DUMP_ENABLE != 1) { - return 0; - } - if (common_transvr_dump(self) < 0) { - return -1; - } - printk(KERN_INFO " |- :%d\n", self->len_sm); - printk(KERN_INFO " |- :%d\n", self->len_smf); - printk(KERN_INFO " '- :0x%02x\n", self->rate_id); - return 0; -} - - -int -qsfp_transvr_dump(struct transvr_obj_s* self) { - - if (TRANSVR_INFO_DUMP_ENABLE != 1) { - return 0; - } - if (common_transvr_dump(self) < 0) { - return -1; - } - printk(KERN_INFO " |- :%d\n", self->len_smf); - printk(KERN_INFO " '- :Class_%d\n", __qsfp_get_power_cls(self, 0)); - return 0; -} - - -int -fake_transvr_dump(struct transvr_obj_s* self) { - - printk(KERN_INFO "[SWPS] Dump transceiver information: %s\n", self->swp_name); - printk(KERN_INFO " |- :FAKE\n"); - printk(KERN_INFO " |- :FAKE_VENDER_NAME\n"); - printk(KERN_INFO " |- :FAKE_VENDER_PN\n"); - printk(KERN_INFO " |- :FAKE_VENDER_REV\n"); - printk(KERN_INFO " |- :FAKE_VENDER_SN\n"); - printk(KERN_INFO " |- :0x99\n"); - printk(KERN_INFO " |- :99\n"); - printk(KERN_INFO " |- :99\n"); - printk(KERN_INFO " |- :99\n"); - printk(KERN_INFO " |- :99\n"); - printk(KERN_INFO " |- :99\n"); - printk(KERN_INFO " |- :99\n"); - printk(KERN_INFO " '- :0x99\n"); - return 0; -} - - -/* ========== Object functions for fake type ========== - */ -int -fake_transvr_update(struct transvr_obj_s *self, - int show_err){ - self->state = STATE_TRANSVR_CONNECTED; - return 0; -} - - -int -fake_get_binary(struct transvr_obj_s *self){ - return 1; -} - -int -fake_get_int(struct transvr_obj_s *self){ - return 99; -} - - -int -fake_get_hex(struct transvr_obj_s *self){ - return 0x0f; -} - - -int -fake_get_str(struct transvr_obj_s *self, char *buf) { - return snprintf(buf, 16, "fake_get_str\n"); -} - - -int -fake_set_int(struct transvr_obj_s *self, int input){ - SWPS_INFO("%s: %d\n", __func__, input); - return 0; -} - - -int -fake_set_hex(struct transvr_obj_s *self, int input){ - SWPS_INFO("%s: 0x%02x\n", __func__, input); - return 0; -} - - -/* ========== Object functions for unsupported ========== - */ -int -unsupported_get_func(struct transvr_obj_s *self){ - return ERR_TRANSVR_NOTSUPPORT; -} - - -int -unsupported_get_func2(struct transvr_obj_s *self, - char *buf_p) { - int len = snprintf(buf_p, 8, "%d\n", ERR_TRANSVR_NOTSUPPORT); - return len; -} - - -int -unsupported_set_func(struct transvr_obj_s *self, - int input_val){ - return ERR_TRANSVR_NOTSUPPORT; -} - - - -/* ========== Object functions for long term task ========== - * - * [Note] - * SWPS transceiver worker is likely the green-thread (coroutine). - * Due to resource and performance considerations. SWPS run all - * features in one kthread at the same time, and handle by it self. - */ - -/* For Transceiver Task Handling - */ -static struct transvr_worker_s * -transvr_task_get(struct transvr_obj_s *self, - char *func_name) { - - struct transvr_worker_s *curr_p = self->worker_p; - - while(curr_p != NULL){ - if (strcmp((curr_p->func_name), func_name) == 0 ) { - return curr_p; - } - curr_p = curr_p->next_p; - } - return NULL; -} - - -static struct transvr_worker_s* -transvr_task_creat(struct transvr_obj_s *self, - int (*main_task)(struct transvr_worker_s *task), - int (*post_task)(struct transvr_worker_s *task), - char *caller) { - - struct transvr_worker_s *task_p = NULL; - struct transvr_worker_s *curr_p = NULL; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - - /* Check task not exist */ - task_p = transvr_task_get(self, caller); - if (task_p) { - snprintf(err_msg, sizeof(err_msg), "Task already created!"); - goto err_transvr_task_creat; - } - /* Create task worker */ - task_p = kzalloc(sizeof(struct transvr_worker_s), GFP_KERNEL); - if (!task_p){ - snprintf(err_msg, sizeof(err_msg), "kzalloc fail"); - goto err_transvr_task_creat; - } - /* Setup task data */ - task_p->transvr_p = self; - task_p->next_p = NULL; - task_p->trigger_time = 0; - task_p->retry = 1; - task_p->state = STATE_T_TASK_INIT; - task_p->main_task = main_task; - task_p->post_task = post_task; - task_p->p_data = NULL; - snprintf(task_p->func_name, sizeof(task_p->func_name), "%s", caller); - /* Setup Link List */ - if (self->worker_p) { - curr_p = self->worker_p; - while(curr_p->next_p != NULL) { - curr_p = curr_p->next_p; - } - curr_p->next_p = task_p; - task_p->pre_p = curr_p; - } else { - self->worker_p = task_p; - task_p->pre_p = NULL; - } - return task_p; - -err_transvr_task_creat: - SWPS_ERR("%s: %s :%s :%s\n", - __func__, err_msg, caller, self->swp_name); - return NULL; -} - - -static void -transvr_task_free_one(struct transvr_worker_s *task_p){ - - struct transvr_worker_s *pre_p = NULL; - struct transvr_worker_s *next_p = NULL; - - if (task_p) { - pre_p = task_p->pre_p; - next_p = task_p->next_p; - - if ((pre_p) && (next_p)) { - pre_p->next_p = next_p; - next_p->pre_p = pre_p; - - } else if ((!pre_p) && (next_p)) { - next_p->pre_p = NULL; - - } else if ((pre_p) && (!next_p)) { - pre_p->next_p = NULL; - - } else if ((!pre_p) && (!next_p)) { - task_p->transvr_p->worker_p = NULL; - } else { - SWPS_ERR("%s: Unexcept case!\n :%s", - __func__, task_p->transvr_p->swp_name); - } - kfree(task_p->p_data); - kfree(task_p); - } -} - - -static void -transvr_task_free_all(struct transvr_obj_s *self) { - - struct transvr_worker_s *curr_p = NULL; - struct transvr_worker_s *next_p = NULL; - - if (self->worker_p) { - curr_p = self->worker_p; - while(curr_p) { - next_p = curr_p->next_p; - transvr_task_free_one(curr_p); - curr_p = next_p; - } - self->worker_p = NULL; - } -} - - -static void -transvr_cache_free_all(struct transvr_obj_s *self) { - - memset(self->vendor_name, 0, (LEN_TRANSVR_M_STR * sizeof(char)) ); - memset(self->vendor_rev, 0, (LEN_TRANSVR_M_STR * sizeof(char)) ); - memset(self->vendor_pn, 0, (LEN_TRANSVR_M_STR * sizeof(char)) ); - memset(self->vendor_sn, 0, (LEN_TRANSVR_M_STR * sizeof(char)) ); - self->extphy_offset = 0; -} - -static int -_transvr_task_run_main(struct transvr_worker_s *task_p) { - - int retval = DEBUG_TRANSVR_INT_VAL; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - - if (!task_p){ - snprintf(err_msg, sizeof(err_msg), "main_task is NULL!"); - goto main_transvr_task_err; - } - if ((task_p->trigger_time) == 0){ - goto main_transvr_task_run; - } - if (time_before(jiffies, task_p->trigger_time)){ - goto main_transvr_task_wait; - } - goto main_transvr_task_run; - -main_transvr_task_run: - if (task_p->retry != VAL_TRANSVR_TASK_RETRY_FOREVER) { - task_p->retry -= 1; - } - retval = task_p->main_task(task_p); - if (retval < 0) { - if (task_p->retry > 0) { - task_p->state = STATE_T_TASK_WAIT; - return EVENT_TRANSVR_TASK_WAIT; - } - snprintf(err_msg, sizeof(err_msg), "Run main_task fail!"); - goto main_transvr_task_err; - } - goto main_transvr_task_identify; - -main_transvr_task_identify: - switch (retval) { - case EVENT_TRANSVR_TASK_WAIT: - task_p->state = STATE_T_TASK_WAIT; - return EVENT_TRANSVR_TASK_WAIT; - - case EVENT_TRANSVR_TASK_DONE: - task_p->state = STATE_T_TASK_DONE; - return EVENT_TRANSVR_TASK_DONE; - - default: - break; - } - snprintf(err_msg, sizeof(err_msg), "Run main_task fail!"); - goto main_transvr_task_err; - -main_transvr_task_wait: - task_p->state = STATE_T_TASK_WAIT; - return EVENT_TRANSVR_TASK_WAIT; - -main_transvr_task_err: - task_p->state = STATE_T_TASK_FAIL; - SWPS_INFO("%s: %s :%d :%s\n", - __func__, err_msg, retval, task_p->transvr_p->swp_name); - return EVENT_TRANSVR_INIT_FAIL; -} - - -static int -_transvr_task_run_post(struct transvr_worker_s *task_p) { - - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - - if ((task_p->post_task) == NULL) { - return EVENT_TRANSVR_TASK_DONE; - } - switch (task_p->state) { - case STATE_T_TASK_WAIT: - case STATE_T_TASK_INIT: - goto post_transvr_task_wait; - - case STATE_T_TASK_DONE: - case STATE_T_TASK_FAIL: - goto post_transvr_task_run; - - default: - break; - } - snprintf(err_msg, sizeof(err_msg), "Unexcept task state"); - goto post_transvr_task_err; - -post_transvr_task_run: - task_p->post_task(task_p); - return EVENT_TRANSVR_TASK_DONE; - -post_transvr_task_wait: - return EVENT_TRANSVR_TASK_WAIT; - -post_transvr_task_err: - SWPS_INFO("%s: %s :%d :%s\n", - __func__, err_msg, task_p->state, task_p->transvr_p->swp_name); - return EVENT_TRANSVR_TASK_FAIL; -} - - -static int -transvr_task_run_one(struct transvr_worker_s *task_p) { - - int retval_main = DEBUG_TRANSVR_INT_VAL; - int retval_post = DEBUG_TRANSVR_INT_VAL; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - - retval_main = _transvr_task_run_main(task_p); - if (retval_main < 0) { - snprintf(err_msg, sizeof(err_msg), "Execute main_task fail!"); - goto err_transvr_task_run_one; - } - retval_post = _transvr_task_run_post(task_p); - if (retval_post < 0) { - snprintf(err_msg, sizeof(err_msg), "Execute post_task fail!"); - goto err_transvr_task_run_one; - } - return retval_main; - -err_transvr_task_run_one: - SWPS_INFO("%s: %s
:%d :%d :%s :%s\n", - __func__, err_msg, retval_main, retval_post, - task_p->func_name, task_p->transvr_p->swp_name); - return EVENT_TRANSVR_TASK_FAIL; -} - - -static int -transvr_task_run_all(struct transvr_obj_s *self) { - - int haserr = 0; - int retval = DEBUG_TRANSVR_INT_VAL; - struct transvr_worker_s *curr_p = NULL; - struct transvr_worker_s *next_p = NULL; - - if ((self->worker_p) == NULL) { - return EVENT_TRANSVR_TASK_DONE; - } - curr_p = self->worker_p; - while (curr_p != NULL) { - next_p = curr_p->next_p; - retval = transvr_task_run_one(curr_p); - if (curr_p->retry == VAL_TRANSVR_TASK_RETRY_FOREVER) { - curr_p = next_p; - continue; - } - switch (retval) { - case EVENT_TRANSVR_TASK_WAIT: - break; - case EVENT_TRANSVR_TASK_DONE: - transvr_task_free_one(curr_p); - break; - case EVENT_TRANSVR_TASK_FAIL: - - default: - haserr = 1; - transvr_task_free_one(curr_p); - break; - } - curr_p = next_p; - } - if (haserr) { - return EVENT_TRANSVR_TASK_FAIL; - } - return EVENT_TRANSVR_TASK_DONE; -} - - -static void -transvr_task_set_delay(struct transvr_worker_s *task_p, - unsigned long delay_msec) { - - task_p->trigger_time = (jiffies + (delay_msec * (HZ/1000))); -} - - -static void -transvr_task_set_retry(struct transvr_worker_s *task_p, - unsigned long retry_times) { - - task_p->retry = retry_times; -} - - -/* For Transceiver Post Task - */ -int -taskfunc_post_do_nothing(struct transvr_worker_s *task_p) { - - return EVENT_TRANSVR_TASK_DONE; -} - - -int -taskfunc_post_handle_task_state(struct transvr_worker_s *task_p) { - - struct transvr_obj_s* tp = task_p->transvr_p; - - switch (task_p->state) { - case STATE_T_TASK_INIT: - case STATE_T_TASK_WAIT: - return EVENT_TRANSVR_TASK_WAIT; - - case STATE_T_TASK_DONE: - tp->state = STATE_TRANSVR_CONNECTED; - tp->send_uevent(tp, KOBJ_ADD); - return EVENT_TRANSVR_TASK_DONE; - - case STATE_T_TASK_FAIL: - tp->state = STATE_TRANSVR_UNEXCEPTED; - return EVENT_TRANSVR_TASK_FAIL; - - default: - break; - } - return EVENT_TRANSVR_TASK_FAIL; -} - - -/* For Transceiver Main Task - */ -int -_taskfunc_sfp_setup_soft_rs(struct transvr_worker_s *task_p, - int input_val, - int address, - int page, - int offset, - int bit_shift, - uint8_t *attr_p, - char *caller) { - - int show_err = 0; - int err_code = DEBUG_TRANSVR_INT_VAL; - char *err_str = DEBUG_TRANSVR_STR_VAL; - char *func_str = "_taskfunc_sfp_setup_soft_rs"; - - err_code = _sfp_update_attr_soft_rs0(task_p->transvr_p, 0); - if (err_code < 0) { - err_str = "Get current soft_rs0 fail!"; - goto err_taskfunc_sfp_setup_soft_rs_1; - } - err_code = __sfp_set_soft_rs(task_p->transvr_p, - input_val, - address, - page, - offset, - bit_shift, - attr_p, - caller, - show_err); - if (err_code < 0) { - err_str = "Get current soft_rs0 fail!"; - goto err_taskfunc_sfp_setup_soft_rs_1; - } - return EVENT_TRANSVR_TASK_DONE; - -err_taskfunc_sfp_setup_soft_rs_1: - if ((task_p->retry) == 0) { - SWPS_INFO("%s: %s :%s :%d :%d\n", - func_str, err_str, task_p->transvr_p->swp_name, input_val, err_code); - } - return EVENT_TRANSVR_TASK_FAIL; -} - - -int -__taskfunc_sfp_setup_hard_rs(struct transvr_worker_s *task_p, - int input_val, - int (*get_func)(struct ioexp_obj_s *self, int virt_offset), - int (*set_func)(struct ioexp_obj_s *self, int virt_offset, int input_val)) { - - int err_val = EVENT_TRANSVR_EXCEP_EXCEP; - char *err_str = DEBUG_TRANSVR_STR_VAL; - - err_val = get_func(task_p->transvr_p->ioexp_obj_p, - task_p->transvr_p->ioexp_virt_offset); - - if (err_val < 0) { - if (err_val == ERR_IOEXP_NOTSUPPORT) { - return EVENT_TRANSVR_TASK_DONE; - } - err_str = "Get current hard_rs fail!"; - goto err_p_taskfunc_sfp_setup_hard_rs_1; - } - if (err_val == input_val) { - return EVENT_TRANSVR_TASK_DONE; - } - err_val = set_func(task_p->transvr_p->ioexp_obj_p, - task_p->transvr_p->ioexp_virt_offset, - input_val); - if (err_val < 0) { - err_str = "Setup hard_rs fail!"; - goto err_p_taskfunc_sfp_setup_hard_rs_1; - } - return EVENT_TRANSVR_TASK_DONE; - -err_p_taskfunc_sfp_setup_hard_rs_1: - if ((task_p->retry) == 0) { - SWPS_INFO("%s: %s :%s :%d :%d\n", - __func__, err_str, task_p->transvr_p->swp_name, input_val, err_val); - } - return EVENT_TRANSVR_TASK_FAIL; -} - - -int -_taskfunc_sfp_setup_hard_rs0(struct transvr_worker_s *task_p, - int input_val) { - - return __taskfunc_sfp_setup_hard_rs(task_p, - input_val, - task_p->transvr_p->ioexp_obj_p->get_hard_rs0, - task_p->transvr_p->ioexp_obj_p->set_hard_rs0); -} - - -int -_taskfunc_sfp_setup_hard_rs1(struct transvr_worker_s *task_p, - int input_val) { - - return __taskfunc_sfp_setup_hard_rs(task_p, - input_val, - task_p->transvr_p->ioexp_obj_p->get_hard_rs1, - task_p->transvr_p->ioexp_obj_p->set_hard_rs1); -} - - -int -_taskfunc_sfp_setup_rs0(struct transvr_worker_s *task_p, - int input_val) { - - int bit_shift = 3; - int old_val = DEBUG_TRANSVR_INT_VAL; - int err_val = EVENT_TRANSVR_EXCEP_EXCEP; - char *err_str = DEBUG_TRANSVR_STR_VAL; - char *func_str = "_taskfunc_sfp_setup_rs0"; - - err_val = _taskfunc_sfp_setup_hard_rs0(task_p, - input_val); - if (err_val < 0) { - err_str = "Setup hard_rs0 fail!"; - goto err_private_taskfunc_sfp_setup_rs0_1; - } - old_val = err_val; - err_val = _taskfunc_sfp_setup_soft_rs(task_p, - input_val, - task_p->transvr_p->eeprom_map_p->addr_soft_rs0, - task_p->transvr_p->eeprom_map_p->page_soft_rs0, - task_p->transvr_p->eeprom_map_p->offset_soft_rs0, - bit_shift, - &(task_p->transvr_p->soft_rs0), - func_str); - if (err_val < 0) { - err_str = "Setup soft_rs0 fail!"; - goto err_private_taskfunc_sfp_setup_rs0_1; - } - return EVENT_TRANSVR_TASK_DONE; - -err_private_taskfunc_sfp_setup_rs0_1: - if ((task_p->retry) == 0) { - SWPS_INFO("%s: %s :%s :%d :%d\n", - func_str, err_str, task_p->transvr_p->swp_name, input_val, err_val); - } - _taskfunc_sfp_setup_hard_rs0(task_p, old_val); - return EVENT_TRANSVR_TASK_FAIL; -} - - -int -_taskfunc_sfp_setup_rs1(struct transvr_worker_s *task_p, - int input_val) { - - int bit_shift = 3; - int old_val = DEBUG_TRANSVR_INT_VAL; - int err_val = EVENT_TRANSVR_EXCEP_EXCEP; - char *err_str = DEBUG_TRANSVR_STR_VAL; - char *func_str = "_taskfunc_sfp_setup_rs1"; - - err_val = _taskfunc_sfp_setup_hard_rs1(task_p, - input_val); - if (err_val < 0) { - err_str = "Setup hard_rs1 fail!"; - goto err_private_taskfunc_sfp_setup_rs1_1; - } - old_val = err_val; - err_val = _taskfunc_sfp_setup_soft_rs(task_p, - input_val, - task_p->transvr_p->eeprom_map_p->addr_soft_rs1, - task_p->transvr_p->eeprom_map_p->page_soft_rs1, - task_p->transvr_p->eeprom_map_p->offset_soft_rs1, - bit_shift, - &(task_p->transvr_p->soft_rs1), - func_str); - if (err_val < 0) { - err_str = "Setup soft_rs1 fail!"; - goto err_private_taskfunc_sfp_setup_rs1_1; - } - return EVENT_TRANSVR_TASK_DONE; - -err_private_taskfunc_sfp_setup_rs1_1: - if ((task_p->retry) == 0) { - SWPS_INFO("%s: %s :%s :%d :%d\n", - func_str, err_str, task_p->transvr_p->swp_name, input_val, err_val); - } - _taskfunc_sfp_setup_hard_rs1(task_p, old_val); - return EVENT_TRANSVR_TASK_FAIL; -} - - -int -taskfunc_sfp_setup_SFF8431_case1(struct transvr_worker_s *task_p) { - /* SFF-8431 (8/4/2G Rx Rate_Select only) */ - int update_val = 1; - - return _taskfunc_sfp_setup_rs0(task_p, update_val); -} - - - -int -taskfunc_sfp_setup_SFF8431_case2(struct transvr_worker_s *task_p) { - /* SFF-8431 (8/4/2G Tx Rate_Select only) */ - int update_val = 1; - - return _taskfunc_sfp_setup_rs1(task_p, update_val); -} - - -int -taskfunc_sfp_setup_SFF8431_case3(struct transvr_worker_s *task_p) { - /* SFF-8431 (8/4/2G Independent Rx & Tx Rate_select) */ - int update_rs0 = 1; - int update_rs1 = 1; - int err_code = DEBUG_TRANSVR_INT_VAL; - - err_code = _taskfunc_sfp_setup_rs0(task_p, update_rs0); - if (err_code < 0) { - return err_code; - } - return _taskfunc_sfp_setup_rs1(task_p, update_rs1); -} - - -int -taskfunc_sfp_handle_1g_rj45(struct transvr_worker_s *task_p) { - - /* Not all of platform support 0x56 for transceiver - * external PHY, Support list as below: - * => 1. Magnolia-PVT (PS: EVT & DVT not ready) - */ - int ext_phy_addr = 0x56; - int ext_phy_page = -1; - int ext_phy_offs = 0x11; - int ext_phy_len = 1; - int lstate_mask = 0x04; /* 00000100 */ - int show_err = 0; - int fail_retry = 5; - int fail_delay = 1000; /* msec */ - int err_code = DEBUG_TRANSVR_INT_VAL; - uint8_t detect_val = DEBUG_TRANSVR_HEX_VAL; - char err_str[64] = DEBUG_TRANSVR_STR_VAL; - int *tmp_p = NULL; - char *func_name = "taskfunc_sfp_handle_1g_rj45"; - - if (task_p->transvr_p->state != STATE_TRANSVR_CONNECTED) { - return EVENT_TRANSVR_TASK_DONE; - } - if ( (task_p->transvr_p->info != TRANSVR_CLASS_BASE_T_1000) && - (task_p->transvr_p->info != TRANSVR_CLASS_BASE_T_1000_up) ) { - goto err_taskfunc_sfp_handle_1g_rj45_1; - } - err_code = _common_update_uint8_attr(task_p->transvr_p, - ext_phy_addr, - ext_phy_page, - ext_phy_offs, - ext_phy_len, - &detect_val, - func_name, - show_err); - if ( (err_code < 0) || - (detect_val == DEBUG_TRANSVR_HEX_VAL) ) { - snprintf(err_str, sizeof(err_str), "Detect external link status fail"); - goto err_taskfunc_sfp_handle_1g_rj45_2; - } - if ((detect_val & lstate_mask) == lstate_mask) { - goto ok_taskfunc_sfp_handle_1g_rj45_link_up; - } - goto ok_taskfunc_sfp_handle_1g_rj45_link_down; - -ok_taskfunc_sfp_handle_1g_rj45_link_up: - /* Filter out noise */ - if (!(task_p->p_data)) { - tmp_p = kzalloc(sizeof(int), GFP_KERNEL); - if (!tmp_p) { - snprintf(err_str, sizeof(err_str), "kzalloc p_data fail"); - goto err_taskfunc_sfp_handle_1g_rj45_2; - } - *tmp_p = TRANSVR_CLASS_BASE_T_1000_up; - task_p->p_data = tmp_p; - goto ok_taskfunc_sfp_handle_1g_rj45_done; - } - if ((*(int *)(task_p->p_data)) != TRANSVR_CLASS_BASE_T_1000_up) { - kfree(task_p->p_data); - task_p->p_data = NULL; - snprintf(err_str, sizeof(err_str), "Internal error"); - goto err_taskfunc_sfp_handle_1g_rj45_2; - } - task_p->transvr_p->info = TRANSVR_CLASS_BASE_T_1000_up; - kfree(task_p->p_data); - task_p->p_data = NULL; - goto ok_taskfunc_sfp_handle_1g_rj45_done; - -ok_taskfunc_sfp_handle_1g_rj45_link_down: - if (task_p->p_data) { - kfree(task_p->p_data); - task_p->p_data = NULL; - } - task_p->transvr_p->info = TRANSVR_CLASS_BASE_T_1000; - goto ok_taskfunc_sfp_handle_1g_rj45_done; - -ok_taskfunc_sfp_handle_1g_rj45_done: - if (task_p->retry != VAL_TRANSVR_TASK_RETRY_FOREVER) { - transvr_task_set_retry(task_p, VAL_TRANSVR_TASK_RETRY_FOREVER); - } - return EVENT_TRANSVR_TASK_DONE; - -err_taskfunc_sfp_handle_1g_rj45_1: - snprintf(err_str, sizeof(err_str), "Detect transceiver:%d not Base-T, remove task.", - task_p->transvr_p->info); - SWPS_INFO("%s: %s :%s\n", __func__, err_str, task_p->transvr_p->swp_name); - transvr_task_set_retry(task_p, 0); - return EVENT_TRANSVR_TASK_DONE; - -err_taskfunc_sfp_handle_1g_rj45_2: - if (task_p->retry == VAL_TRANSVR_TASK_RETRY_FOREVER) { - transvr_task_set_retry(task_p, fail_retry); - } - if ((task_p->retry) == 0) { - /* Error case: - * => In this case, SWPS will stop external Link state monitor features - * and keeps transvr_p->info on TRANSVR_CLASS_BASE_T_1000_up. - * Upper layer will see it always Linkup that because of these type of - * transceiver has external phy, chip see it as Loopback transceiver. - */ - SWPS_WARN("%s can not access external PHY of Base-T SFP transceiver\n", - task_p->transvr_p->swp_name); - task_p->transvr_p->info = TRANSVR_CLASS_BASE_T_1000_up; - return EVENT_TRANSVR_TASK_DONE; - } else { - transvr_task_set_delay(task_p, fail_delay); - } - return EVENT_TRANSVR_TASK_FAIL; -} - - -int -_taskfunc_qsfp_setup_power_mod(struct transvr_obj_s *self, - int setup_val) { - - int curr_val = DEBUG_TRANSVR_INT_VAL; - int err_val = DEBUG_TRANSVR_INT_VAL; - char *err_msg = DEBUG_TRANSVR_STR_VAL; - - curr_val = self->ioexp_obj_p->get_lpmod(self->ioexp_obj_p, - self->ioexp_virt_offset); - if (curr_val < 0){ - err_msg = "Get current value fail!"; - goto err_private_taskfunc_qsfp_setup_power_mod_1; - } - if (curr_val == setup_val){ - return EVENT_TRANSVR_TASK_DONE; - } - err_val = self->ioexp_obj_p->set_lpmod(self->ioexp_obj_p, - self->ioexp_virt_offset, - setup_val); - if (err_val < 0){ - err_msg = "Setup power mode fail!"; - goto err_private_taskfunc_qsfp_setup_power_mod_1; - } - return EVENT_TRANSVR_TASK_DONE; - -err_private_taskfunc_qsfp_setup_power_mod_1: - SWPS_INFO("%s: %s :%d :%d :%d\n", - __func__, err_msg, err_val, curr_val, setup_val); - return EVENT_TRANSVR_TASK_FAIL; -} - - -int -taskfunc_qsfp_handle_tx_disable(struct transvr_worker_s *task_p) { - - int i = 0; - int retry = 5; - int delay_ms = 100; - - if (task_p->transvr_p->auto_tx_disable == VAL_TRANSVR_FUNCTION_DISABLE) { - return EVENT_TRANSVR_TASK_DONE; - } - if (!_qsfp_is_implement_tx_disable(task_p->transvr_p)) { - return EVENT_TRANSVR_TASK_DONE; - } - for (i=0; itransvr_p, - task_p->transvr_p->auto_tx_disable) - == EVENT_TRANSVR_TASK_DONE) { - goto ok_taskfunc_qsfp_handle_tx_disable; - } - mdelay(delay_ms); - } - SWPS_INFO("%s auto setup tx_disable:0x%02x fail.\n", - task_p->transvr_p->swp_name, - task_p->transvr_p->auto_tx_disable); - return EVENT_TRANSVR_INIT_FAIL; - -ok_taskfunc_qsfp_handle_tx_disable: - SWPS_INFO("%s auto setup tx_disable:0x%02x ok.\n", - task_p->transvr_p->swp_name, - task_p->transvr_p->auto_tx_disable); - return EVENT_TRANSVR_TASK_DONE; -} - - -int -taskfunc_qsfp_set_hpmod(struct transvr_worker_s *task_p) { - - int err = DEBUG_TRANSVR_INT_VAL; - int HIGH_POWER_MODE = 0; - - /* Handle power mode */ - err = _taskfunc_qsfp_setup_power_mod(task_p->transvr_p, - HIGH_POWER_MODE); - if (err < 0) { - SWPS_INFO("%s: setup hpmod fail :%d :%s\n", - __func__, err, task_p->transvr_p->swp_name); - return err; - } - /* Handle auto tx_disable - * [Note] - * => Because there are some transceiver have timing issues or - * setup sequence issues, therefore we handle auto tx_disable - * after handle power mode. - */ - mdelay(100); - return taskfunc_qsfp_handle_tx_disable(task_p); -} - - -int -taskfunc_qsfp_set_lpmod(struct transvr_worker_s *task_p) { - - int LOW_POWER_MODE = 1; - return _taskfunc_qsfp_setup_power_mod(task_p->transvr_p, - LOW_POWER_MODE); -} - - -static int -initfunc_sfp_handle_multi_rate_mode(struct transvr_obj_s *self) { - - int task_retry = 3; - int err_code = DEBUG_TRANSVR_INT_VAL; - char *err_str = DEBUG_TRANSVR_STR_VAL; - char *func_str = "sfp_handle_multi_rate_mode"; - struct transvr_worker_s *task_p = NULL; - - switch (self->rate_id) { - case 0x00: /* Unspecified */ - case 0x03: /* Unspecified */ - case 0x05: /* Unspecified */ - case 0x07: /* Unspecified */ - case 0x09: /* Unspecified */ - case 0x0B: /* Unspecified */ - case 0x0D: /* Unspecified */ - case 0x0F: /* Unspecified */ - goto sfp_handle_multi_rate_mode_4_unspecified; - - case 0x02: /* SFF-8431 (8/4/2G Rx Rate_Select only) */ - task_p = transvr_task_creat(self, - taskfunc_sfp_setup_SFF8431_case1, - taskfunc_post_handle_task_state, - func_str); - goto sfp_handle_multi_rate_mode_4_sff8431; - - case 0x04: /* SFF-8431 (8/4/2G Tx Rate_Select only) */ - task_p = transvr_task_creat(self, - taskfunc_sfp_setup_SFF8431_case2, - taskfunc_post_handle_task_state, - func_str); - goto sfp_handle_multi_rate_mode_4_sff8431; - - case 0x06: /* SFF-8431 (8/4/2G Independent Rx & Tx Rate_select) */ - task_p = transvr_task_creat(self, - taskfunc_sfp_setup_SFF8431_case3, - taskfunc_post_handle_task_state, - func_str); - goto sfp_handle_multi_rate_mode_4_sff8431; - - case 0x01: /* SFF-8079 (4/2/1G Rate_Select & AS0/AS1) */ - err_str = "SFF-8079 (4/2/1G Rate_Select & AS0/AS1)"; - goto sfp_handle_multi_rate_mode_4_not_support; - - case 0x08: /* FC-PI-5 (16/8/4G Rx Rate_select only) - * High=16G only, Low=8G/4G - */ - err_str = "FC-PI-5 (16/8/4G Rx Rate_select only)"; - goto sfp_handle_multi_rate_mode_4_not_support; - - case 0x0A: /* FC-PI-5 (16/8/4G Independent Rx, Tx Rate_select) - * High=16G only, Low=8G/4G - */ - err_str = "FC-PI-5 (16/8/4G Independent Rx, Tx Rate_select)"; - goto sfp_handle_multi_rate_mode_4_not_support; - - case 0x0C: /* FC-PI-6 (32/16/8G Independent Rx, Tx Rate_Select) - * High=32G only, Low = 16G/8G - */ - err_str = "FC-PI-6 (32/16/8G Independent Rx, Tx Rate_Select)"; - goto sfp_handle_multi_rate_mode_4_not_support; - - case 0x0E: /* 10/8G Rx and Tx Rate_Select controlling the operation or - * locking modes of the internal signal conditioner, retimer - * or CDR, according to the logic table defined in Table 10-2, - * High Bit Rate (10G) =9.95-11.3 Gb/s; Low Bit Rate (8G) = - * 8.5 Gb/s. In this mode, the default value of bit 110.3 (Soft - * Rate Select RS(0), Table 9-11) and of bit 118.3 (Soft Rate - * Select RS(1), Table 10-1) is 1. - */ - err_str = "cable type: 0x0E"; - goto sfp_handle_multi_rate_mode_4_not_support; - - default: - err_str = "cable type: UNKNOW"; - goto sfp_handle_multi_rate_mode_4_not_support; - } - -sfp_handle_multi_rate_mode_4_sff8431: - if (!task_p) { - err_str = "Create task fail!"; - goto sfp_handle_multi_rate_mode_4_fail_1; - } - transvr_task_set_retry(task_p, task_retry); - return EVENT_TRANSVR_TASK_WAIT; - -sfp_handle_multi_rate_mode_4_unspecified: - return EVENT_TRANSVR_TASK_DONE; - -sfp_handle_multi_rate_mode_4_not_support: - SWPS_INFO("%s: Does not support %s :%s :0x%02x\n", - func_str, err_str, self->swp_name, self->rate_id); - return EVENT_TRANSVR_TASK_DONE; - -sfp_handle_multi_rate_mode_4_fail_1: - SWPS_INFO("%s: %s :%s :0x%02x, :%d\n", - func_str, err_str, self->swp_name, self->rate_id, err_code); - return EVENT_TRANSVR_INIT_FAIL; -} - - -static int -initfunc_sfp_handle_1g_rj45(struct transvr_obj_s *self) { - - struct transvr_worker_s *task_p = NULL; - int detect_cls = DEBUG_TRANSVR_INT_VAL; - char err_str[64] = DEBUG_TRANSVR_STR_VAL; - char *func_str = "initfunc_sfp_handle_1g_rj45"; - - - if (self->info == TRANSVR_CLASS_BASE_T_1000) { - task_p = transvr_task_creat(self, - taskfunc_sfp_handle_1g_rj45, - taskfunc_post_do_nothing, - func_str); - if (!task_p) { - snprintf(err_str, sizeof(err_str), "Create task fail"); - goto err_initfunc_sfp_handle_1g_rj45; - } - transvr_task_set_retry(task_p, VAL_TRANSVR_TASK_RETRY_FOREVER); - } - return EVENT_TRANSVR_TASK_DONE; - -err_initfunc_sfp_handle_1g_rj45: - SWPS_INFO("%s: %s :%s :%d\n", - __func__, err_str, self->swp_name, detect_cls); - return EVENT_TRANSVR_TASK_FAIL; -} - - -static int -initfunc_qsfp_handle_power_mode(struct transvr_obj_s *self) { - - int err_code = EVENT_TRANSVR_EXCEP_INIT; - int power_class = DEBUG_TRANSVR_INT_VAL; - int hpmod_retry = 3; - int lpower_config = 1; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - unsigned long hpmod_delay = 500; /* msec */ - struct transvr_worker_s *task_p = NULL; - - /* Handle power mode for IOEXP */ - power_class = __qsfp_get_power_cls(self, 0); - switch (power_class) { - case 1: /* Case: Low power mode (Class = 1) */ - err_code = _taskfunc_qsfp_setup_power_mod(self, lpower_config); - if (err_code < 0){ - snprintf(err_msg, sizeof(err_msg), "Setup lpmod fail :%d", err_code); - goto err_initfunc_qsfp_handle_power_mode; - } - return EVENT_TRANSVR_TASK_DONE; - - case 2: /* Case: High power mode (Class > 1) */ - case 3: - case 4: - case 5: - case 6: - case 7: - task_p = transvr_task_creat(self, - taskfunc_qsfp_set_hpmod, - taskfunc_post_handle_task_state, - "transvr_init_qsfp"); - if (!task_p) { - snprintf(err_msg, sizeof(err_msg), "Setup lpmod fail :%d", err_code); - goto err_initfunc_qsfp_handle_power_mode; - } - transvr_task_set_retry(task_p, hpmod_retry); - transvr_task_set_delay(task_p, hpmod_delay); - return EVENT_TRANSVR_TASK_WAIT; - - default: - break; - } - snprintf(err_msg, sizeof(err_msg), "Exception case"); - goto err_initfunc_qsfp_handle_power_mode; - -err_initfunc_qsfp_handle_power_mode: - SWPS_INFO("%s: %s :%s \n", __func__, err_msg, self->swp_name); - return EVENT_TRANSVR_INIT_FAIL; -} - - -int -initfunc_qsfp28_handle_cdr(struct transvr_obj_s *self) { - - uint8_t DEFAULT_VAL_CDR = 0xff; - int CDR_FUNC_EXISTED = 0x3; - int show_err = 1; - int err_val = EVENT_TRANSVR_TASK_FAIL; - char *err_msg = DEBUG_TRANSVR_STR_VAL; - char *func_str = "initfunc_qsfp28_handle_cdr"; - - err_val = __qsfp_get_cdr_present(self, 0); - if ( (err_val < 0) || - (err_val == DEBUG_TRANSVR_HEX_VAL) ) { - err_msg = "detect cdr_present fail!"; - goto err_taskfunc_qsfp_handle_cdr_1; - } - if (err_val == CDR_FUNC_EXISTED) { - err_val = _common_set_uint8_attr(self, - self->eeprom_map_p->addr_cdr, - self->eeprom_map_p->addr_cdr, - self->eeprom_map_p->offset_cdr, - DEFAULT_VAL_CDR, - &(self->cdr), - func_str, - show_err); - if (err_val < 0) { - err_msg = "set CDR fail!"; - goto err_taskfunc_qsfp_handle_cdr_1; - } - } - return EVENT_TRANSVR_TASK_DONE; - -err_taskfunc_qsfp_handle_cdr_1: - SWPS_INFO("%s: %s :%d :%s\n", - func_str, err_msg, err_val, self->swp_name); - return EVENT_TRANSVR_INIT_FAIL; -} - -/* ========== Object functions for Final State Machine ========== - */ -int -is_plugged(struct transvr_obj_s *self){ - - int limit = 63; - int present = DEBUG_TRANSVR_INT_VAL; - char emsg[64] = DEBUG_TRANSVR_STR_VAL; - struct ioexp_obj_s *ioexp_p = self->ioexp_obj_p; - - if (!ioexp_p) { - snprintf(emsg, limit, "ioexp_p is null!"); - goto err_is_plugged_1; - } - present = ioexp_p->get_present(ioexp_p, self->ioexp_virt_offset); - switch (present){ - case 0: - return 1; - case 1: - return 0; - case ERR_IOEXP_UNINIT: - snprintf(emsg, limit, "ioexp_p not ready!"); - goto err_is_plugged_1; - default: - if (ioexp_p->state == STATE_IOEXP_INIT){ - snprintf(emsg, limit, "ioexp_p not ready!"); - goto err_is_plugged_1; - } - break; - } - SWPS_INFO("%s: Exception case! :%d :%d\n", - __func__, present, ioexp_p->state); - return 0; - -err_is_plugged_1: - SWPS_DEBUG("%s: %s\n", __func__, emsg); - return 0; -} - - -static int -detect_transvr_type(struct transvr_obj_s* self){ - - int type = TRANSVR_TYPE_ERROR; - - self->i2c_client_p->addr = VAL_TRANSVR_COMID_ARREESS; - type = i2c_smbus_read_byte_data(self->i2c_client_p, - VAL_TRANSVR_COMID_OFFSET); - - /* Case: 1. Wait transceiver I2C module. - * 2. Transceiver I2C module failure. - * Note: 1. SFF allow maximum transceiver initial time is 2 second. So, there - * are exist some case that we need to wait transceiver. - * For these case, we keeps status on "TRANSVR_TYPE_UNPLUGGED", than - * state machine will keep trace with it. - * 2. There exist some I2C failure case we need to handle. Such as user - * insert the failure transceiver, or any reason cause it abnormal. - */ - if (type < 0){ - switch (type) { - case -EIO: - SWPS_DEBUG("%s: %s smbus return:-5 (I/O error)\n", - __func__, self->swp_name); - return TRANSVR_TYPE_UNPLUGGED; - case -ENXIO: - SWPS_DEBUG("%s: %s smbus return:-6 (No such device or address)\n", - __func__, self->swp_name); - return TRANSVR_TYPE_UNPLUGGED; - default: - break; - } - SWPS_INFO("%s: %s unexpected smbus return:%d \n", - __func__, self->swp_name, type); - return TRANSVR_TYPE_ERROR; - } - /* Identify valid transceiver type */ - switch (type){ - case TRANSVR_TYPE_SFP: - case TRANSVR_TYPE_QSFP: - case TRANSVR_TYPE_QSFP_PLUS: - case TRANSVR_TYPE_QSFP_28: - break; - case TRANSVR_TYPE_UNKNOW_1: - case TRANSVR_TYPE_UNKNOW_2: - type = TRANSVR_TYPE_UNKNOW_2; - break; - default: - SWPS_DEBUG("%s: unknow type:0x%02x \n", __func__, type); - type = TRANSVR_TYPE_ERROR; - break; - } - return type; -} - - -static int -detect_transvr_state(struct transvr_obj_s *self, - int result[2]){ - /* [return] [result-0] [result-1] - * 0 STATE_TRANSVR_CONNECTED TRANSVR_TYPE_FAKE - * 0 STATE_TRANSVR_DISCONNECTED TRANSVR_TYPE_UNPLUGGED - * 0 STATE_TRANSVR_ISOLATED TRANSVR_TYPE_ERROR - * 0 STATE_TRANSVR_INIT / - * 0 STATE_TRANSVR_SWAPPED - * 0 STATE_TRANSVR_CONNECTED - * ERR_TRNASVR_BE_ISOLATED STATE_TRANSVR_ISOLATED TRANSVR_TYPE_ERROR - * ERR_TRANSVR_I2C_CRASH STATE_TRANSVR_UNEXCEPTED TRANSVR_TYPE_ERROR - * ERR_TRANSVR_UNEXCPT STATE_TRANSVR_UNEXCEPTED TRANSVR_TYPE_UNKNOW_1/2 - */ - result[0] = STATE_TRANSVR_UNEXCEPTED; /* For return state */ - result[1] = TRANSVR_TYPE_ERROR; /* For return type */ - - /* Case1: Fake type */ - if (self->type == TRANSVR_TYPE_FAKE){ - result[0] = STATE_TRANSVR_CONNECTED; - result[1] = TRANSVR_TYPE_FAKE; - return 0; - } - /* Case2: Transceiver unplugged */ - if (!is_plugged(self)){ - result[0] = STATE_TRANSVR_DISCONNECTED; - result[1] = TRANSVR_TYPE_UNPLUGGED; - return 0; - } - /* Case3: Transceiver be isolated */ - if (self->state == STATE_TRANSVR_ISOLATED){ - result[0] = STATE_TRANSVR_ISOLATED; - result[1] = TRANSVR_TYPE_ERROR; - return ERR_TRNASVR_BE_ISOLATED; - } - /* Case4: Transceiver plugged */ - result[1] = detect_transvr_type(self); - /* Case4.1: I2C topology crash - * Note : There are some I2C issues cause by transceiver/cables. - * We need to check topology status when user insert it. - * But in this step, we can't not ensure this is the issues - * port. So, it return the ERR_TRANSVR_I2C_CRASH, then upper - * layer will diagnostic I2C topology. - */ - if (check_channel_tier_1() < 0) { - SWPS_INFO("%s: %s detect I2C crash :%d\n", - __func__, self->swp_name, self->state); - result[0] = STATE_TRANSVR_UNEXCEPTED; - result[1] = TRANSVR_TYPE_ERROR; - return ERR_TRANSVR_I2C_CRASH; - } - /* Case4.2: System initial not ready, - * Note : Sometime i2c channel or transceiver EEPROM will delay that will - * cause system in inconsistent state between EEPROM and IOEXP. - * In this case, SWP transceiver object keep state at LINK_DOWN - * to wait system ready. - * By the way, State Machine will handle these case. - */ - if (result[1] == TRANSVR_TYPE_UNPLUGGED){ - result[0] = STATE_TRANSVR_DISCONNECTED; - return 0; - } - /* Case4.3: Error transceiver type */ - if (result[1] == TRANSVR_TYPE_ERROR){ - result[0] = STATE_TRANSVR_ISOLATED; - SWPS_INFO("%s: %s detect error type\n", __func__, self->swp_name); - alarm_msg_2_user(self, "detected transceiver/cables not meet SFF standard!"); - return ERR_TRNASVR_BE_ISOLATED; - } - /* Case3.3: Unknow transceiver type */ - if ((result[1] == TRANSVR_TYPE_UNKNOW_1) || - (result[1] == TRANSVR_TYPE_UNKNOW_2) ){ - result[0] = STATE_TRANSVR_UNEXCEPTED; - return ERR_TRANSVR_UNEXCPT; - } - /* Case3.4: During initial process */ - if (self->state == STATE_TRANSVR_INIT){ - result[0] = STATE_TRANSVR_INIT; - return 0; - } - /* Case3.5: Transceiver be swapped */ - if (self->type != result[1]){ - result[0] = STATE_TRANSVR_SWAPPED; - return 0; - } - /* Case3.6: Link up state */ - result[0] = STATE_TRANSVR_CONNECTED; - return 0; -} - - -int -_sfp_detect_class_by_extend_comp(struct transvr_obj_s* self) { - /* Reference: SFF-8024 (v3.8) - */ - int detect_val = _sfp_get_comp_extended(self); - - switch(detect_val) { - case 0x00: /* Unspecified */ - return TRANSVR_CLASS_UNSPECIFIED; - - case 0x01: /* 100G AOC (Active Optical Cable) or 25GAUI C2M */ - case 0x18: /* 100G AOC or 25GAUI C2M AOC. */ - return TRANSVR_CLASS_OPTICAL_25G_AOC; - - case 0x02: /* 100GBASE-SR4 or 25GBASE-SR */ - return TRANSVR_CLASS_OPTICAL_25G_SR; - - case 0x03: /* 100GBASE-LR4 or 25GBASE-LR */ - return TRANSVR_CLASS_OPTICAL_25G_LR; - - case 0x04: /* 100GBASE-ER4 or 25GBASE-ER */ - return TRANSVR_CLASS_OPTICAL_25G_ER; - - case 0x08: /* 100G ACC (Active Copper Cable) or 25GAUI C2M ACC. */ - case 0x0b: /* 100GBASE-CR4 or 25GBASE-CR CA-L */ - case 0x0c: /* 25GBASE-CR CA-S */ - case 0x0d: /* 25GBASE-CR CA-N */ - case 0x19: /* 100G ACC or 25GAUI C2M ACC. */ - return TRANSVR_CLASS_COPPER_L1_25G; - - default: - break; - } - SWPS_INFO("%s: Unexcept value:0x%02x\n :%s", - __func__, detect_val, self->swp_name); - return TRANSVR_CLASS_ERROR; -} - - -int -_sfp_detect_class_by_10_ethernet(struct transvr_obj_s* self) { - /* Reference: SFF-8472 (v12.2) - */ - int detect_val = DEBUG_TRANSVR_INT_VAL; - - detect_val = _sfp_get_comp_10g_eth_comp(self); - /* Case: Unspecified */ - if (detect_val == 0x00) { - return TRANSVR_CLASS_UNSPECIFIED; - } - /* Case: 10G Optical (x1) */ - if ((detect_val & 0x10) == 0x10) { /* 00010000 : 10GBASE-SR */ - return TRANSVR_CLASS_OPTICAL_10G_S_SR; - } - if ( ((detect_val & 0x20) == 0x20) || /* 00100000 : 10GBASE-LR */ - ((detect_val & 0x40) == 0x40) ){ /* 01000000 : 10GBASE-LRM */ - return TRANSVR_CLASS_OPTICAL_10G_S_LR; - } - if ((detect_val & 0x80) == 0x80) { /* 10000000 : 10GBASE-ER */ - return TRANSVR_CLASS_OPTICAL_10G_S_ER; - } - /* Case: ERROR */ - SWPS_INFO("%s: Unexcept value:0x%02x\n :%s", - __func__, detect_val, self->swp_name); - return TRANSVR_CLASS_ERROR; -} - - -int -_sfp_detect_if_sp_by_br(struct transvr_obj_s* self) { - - int lower_bound_1g = 0x0b; - int upper_bound_1g = 0x1A; - int lower_bound_10g = 0x60; - int upper_bound_10g = 0x75; - int lower_bound_25g = 0xf0; - int upper_bound_25g = 0xff; - int notmal_br = DEBUG_TRANSVR_INT_VAL; - - notmal_br = (int)(self->br); /* updated by update_all() */ - /* Check 25G */ - if ((notmal_br >= lower_bound_25g) && - (notmal_br <= upper_bound_25g) ) { - return TRANSVR_CLASS_25G; - } - /* Check 10G */ - if ((notmal_br >= lower_bound_10g) && - (notmal_br <= upper_bound_10g) ) { - return TRANSVR_CLASS_10G; - } - /* Check 1G */ - if ((notmal_br >= lower_bound_1g) && - (notmal_br <= upper_bound_1g) ) { - return TRANSVR_CLASS_1G; - } - return TRANSVR_CLASS_UNSPECIFIED; -} - - -int -_sfp_detect_class_by_1g_ethernet(struct transvr_obj_s* self) { - /* Reference: SFF-8472 (v12.2) - */ - int detect_val = DEBUG_TRANSVR_INT_VAL; - int speed_br = DEBUG_TRANSVR_INT_VAL; - int speed_tmp = DEBUG_TRANSVR_INT_VAL; - char err_str[64] = DEBUG_TRANSVR_STR_VAL; - - speed_br = _sfp_detect_if_sp_by_br(self); - detect_val = _sfp_get_comp_1g_eth_comp(self); - - if (detect_val < 0) { - snprintf(err_str, sizeof(err_str), "Detect abnormal value:%d", detect_val); - goto err_p_sfp_detect_class_by_1g_ethernet; - } - /* Case: Unspecified */ - if (detect_val == 0x00) { - return TRANSVR_CLASS_UNSPECIFIED; - } - /* Case: 1G (x1) */ - if ((detect_val & 0x01) == 0x01) { /* 00000001 : 1000BASE-SX */ - speed_tmp = TRANSVR_CLASS_OPTICAL_1G_SX; - goto ok_sfp_detect_class_by_1g_ethernet_4_check_br_10g; - } - if ((detect_val & 0x02) == 0x02) { /* 00000010 : 1000BASE-LX *3 */ - speed_tmp = TRANSVR_CLASS_OPTICAL_1G_LX; - goto ok_sfp_detect_class_by_1g_ethernet_4_check_br_10g; - } - if ((detect_val & 0x04) == 0x04) { /* 00000100 : 1000BASE-CX */ - speed_tmp = TRANSVR_CLASS_COPPER_L1_1G; - goto ok_sfp_detect_class_by_1g_ethernet_4_check_br_10g; - } - /* Case: 1000 Base-T (x1) */ - if ((detect_val & 0x08) == 0x08) { /* 00001000 : 1000BASE-T */ - return TRANSVR_CLASS_BASE_T_1000; - } - /* Case: 100 Base */ - if ( ((detect_val & 0x10) == 0x10) || /* 00010000 : 100BASE-LX/LX10 */ - ((detect_val & 0x20) == 0x20) || /* 00100000 : 100BASE-FX */ - ((detect_val & 0x40) == 0x40) || /* 01000000 : BASE-BX10 *3 */ - ((detect_val & 0x80) == 0x80) ){ /* 10000000 : BASE-PX *3 */ - return TRANSVR_CLASS_OPTICAL_100; - } - /* Case: ERROR */ - snprintf(err_str, sizeof(err_str), "Case:ERROR, value:%d", detect_val); - goto err_p_sfp_detect_class_by_1g_ethernet; - -ok_sfp_detect_class_by_1g_ethernet_4_check_br_10g: - switch (speed_br) { - case TRANSVR_CLASS_UNSPECIFIED: - case TRANSVR_CLASS_1G: - return speed_tmp; - case TRANSVR_CLASS_10G: - goto ok_sfp_detect_class_by_1g_ethernet_4_transfer_10G; - } - -ok_sfp_detect_class_by_1g_ethernet_4_transfer_10G: - switch (speed_tmp) { - case TRANSVR_CLASS_OPTICAL_1G_SX: - return TRANSVR_CLASS_OPTICAL_10G_S_SR; - case TRANSVR_CLASS_OPTICAL_1G_LX: - return TRANSVR_CLASS_OPTICAL_10G_S_LR; - case TRANSVR_CLASS_COPPER_L1_1G: - return TRANSVR_CLASS_COPPER_L1_10G; - default: - break; - } - snprintf(err_str, sizeof(err_str), "transfer_1to10 fail, speed:%d", speed_tmp); - goto err_p_sfp_detect_class_by_1g_ethernet; - -err_p_sfp_detect_class_by_1g_ethernet: - SWPS_INFO("%s: %s :%s", __func__, err_str, self->swp_name); - return TRANSVR_CLASS_ERROR; -} - - -int -_sfp_detect_class_by_feature(struct transvr_obj_s* self) { - /* Reference: SFF-8024 (v3.8) - */ - int is_active = 0; - int conn_val = DEBUG_TRANSVR_INT_VAL; - int check_val = DEBUG_TRANSVR_INT_VAL; - int wave_len = DEBUG_TRANSVR_INT_VAL; - int speed_val = DEBUG_TRANSVR_INT_VAL; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - - speed_val = _sfp_detect_if_sp_by_br(self); - conn_val = _sfp_get_connector_type(self); - - switch(conn_val) { - case 0x00: /* Unspecified */ - goto ok_sfp_detect_class_by_feature_4_check_active_passive; - case 0x07: /* LC (Lucent Connector) */ - case 0x0b: /* Optical Pigtail */ - case 0x0c: /* MPO 1x12 */ - case 0x0d: /* MPO 2x16 */ - /* - * ToDo: Need verify Optical Pigtail - */ - goto ok_sfp_detect_class_by_feature_4_optiocal; - case 0x21: /* Copper pigtail */ - /* - * ToDo: Need check ACC use case - */ - goto ok_sfp_detect_class_by_feature_4_check_active_passive; - case 0x23: /* No separable connector */ - /* - * ToDo: Standard not clear, not all transceiver vendor - * have the same defined - */ - goto ok_sfp_detect_class_by_feature_4_check_active_passive; - default: - break; - } - goto ok_sfp_detect_class_by_feature_4_unknow; - -ok_sfp_detect_class_by_feature_4_check_active_passive: - check_val = _sfp_get_cable_tech(self); - switch(check_val) { - case 0x00: /* Unspecified */ - goto ok_sfp_detect_class_by_feature_4_unknow; - case 0x04: /* Passive */ - goto ok_sfp_detect_class_by_feature_4_copper; - case 0x08: /* Active */ - is_active = 1; - goto ok_sfp_detect_class_by_feature_4_aoc; - default: - snprintf(err_msg, sizeof(err_msg), - "_sfp_get_cable_tech return Non define value:%d", - check_val); - break; - } - goto err_sfp_detect_class_by_feature_1; - -ok_sfp_detect_class_by_feature_4_optiocal: - wave_len = _common_count_wavelength(self, - self->wavelength[0], - self->wavelength[1]); - switch(speed_val) { - case TRANSVR_CLASS_25G: - switch (wave_len) { - case VAL_OPTICAL_WAVELENGTH_SR: - return TRANSVR_CLASS_OPTICAL_25G_SR; - case VAL_OPTICAL_WAVELENGTH_LR: - return TRANSVR_CLASS_OPTICAL_25G_LR; - case VAL_OPTICAL_WAVELENGTH_ER: - return TRANSVR_CLASS_OPTICAL_25G_ER; - default: - break; - } - return TRANSVR_CLASS_OPTICAL_25G; - - case TRANSVR_CLASS_10G: - switch (wave_len) { - case VAL_OPTICAL_WAVELENGTH_SR: - return TRANSVR_CLASS_OPTICAL_10G_S_SR; - case VAL_OPTICAL_WAVELENGTH_LR: - return TRANSVR_CLASS_OPTICAL_10G_S_LR; - case VAL_OPTICAL_WAVELENGTH_ER: - return TRANSVR_CLASS_OPTICAL_10G_S_ER; - default: - break; - } - return TRANSVR_CLASS_OPTICAL_10G; - - case TRANSVR_CLASS_1G: - switch (wave_len) { - case VAL_OPTICAL_WAVELENGTH_SR: - return TRANSVR_CLASS_OPTICAL_1G_SX; - case VAL_OPTICAL_WAVELENGTH_LR: - return TRANSVR_CLASS_OPTICAL_1G_LX; - case VAL_OPTICAL_WAVELENGTH_ER: - return TRANSVR_CLASS_OPTICAL_1G_EX; - default: - break; - } - return TRANSVR_CLASS_OPTICAL_1G; - - default: - return TRANSVR_CLASS_OPTICAL; - } - -ok_sfp_detect_class_by_feature_4_aoc: - switch(speed_val) { - case TRANSVR_CLASS_25G: - return TRANSVR_CLASS_OPTICAL_25G_AOC; - case TRANSVR_CLASS_10G: - return TRANSVR_CLASS_OPTICAL_10G_S_AOC; - case TRANSVR_CLASS_1G: - return TRANSVR_CLASS_OPTICAL_1G_AOC; - default: - break; - } - goto ok_sfp_detect_class_by_feature_4_unknow; - -ok_sfp_detect_class_by_feature_4_copper: - switch(speed_val) { - case TRANSVR_CLASS_25G: - return TRANSVR_CLASS_COPPER_L1_25G; - case TRANSVR_CLASS_10G: - return TRANSVR_CLASS_COPPER_L1_10G; - case TRANSVR_CLASS_1G: - return TRANSVR_CLASS_COPPER_L1_1G; - default: - return TRANSVR_CLASS_COPPER; - } - -ok_sfp_detect_class_by_feature_4_unknow: - return TRANSVR_CLASS_UNSPECIFIED; - -err_sfp_detect_class_by_feature_1: - SWPS_INFO("%s: %s\n :%s", __func__, err_msg, self->swp_name); - return TRANSVR_CLASS_ERROR; -} - - -int -sft_detect_transvr_class(struct transvr_obj_s* self) { - - int detect_val = DEBUG_TRANSVR_INT_VAL; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - - /* Check Extended Compliance */ - detect_val = _sfp_detect_class_by_extend_comp(self); - switch(detect_val) { - case TRANSVR_CLASS_UNSPECIFIED: - break; - case TRANSVR_CLASS_OPTICAL_25G_AOC: - case TRANSVR_CLASS_OPTICAL_25G_SR: - case TRANSVR_CLASS_OPTICAL_25G_LR: - case TRANSVR_CLASS_OPTICAL_25G_ER: - case TRANSVR_CLASS_COPPER_L1_25G: - return detect_val; - default: - snprintf(err_msg, sizeof(err_msg), - "Detect undefined extend_comp:%d", - detect_val); - goto err_sft_detect_transceiver_class_1; - } - /* Check 10G Compliance */ - detect_val = _sfp_detect_class_by_10_ethernet(self); - switch(detect_val) { - case TRANSVR_CLASS_UNSPECIFIED: - break; - case TRANSVR_CLASS_OPTICAL_10G_S_SR: - case TRANSVR_CLASS_OPTICAL_10G_S_LR: - case TRANSVR_CLASS_OPTICAL_10G_S_ER: - return detect_val; - default: - snprintf(err_msg, sizeof(err_msg), - "Detect undefined 10G_eth:%d", - detect_val); - goto err_sft_detect_transceiver_class_1; - } - /* Check 1G Compliance */ - detect_val = _sfp_detect_class_by_1g_ethernet(self); - switch(detect_val) { - case TRANSVR_CLASS_UNSPECIFIED: - break; - case TRANSVR_CLASS_OPTICAL_1G_SX: - case TRANSVR_CLASS_OPTICAL_1G_LX: - case TRANSVR_CLASS_COPPER_L1_1G: - case TRANSVR_CLASS_BASE_T_1000: - case TRANSVR_CLASS_OPTICAL_100: - /* - * ToDo: Need Check 0.1G - */ - case TRANSVR_CLASS_OPTICAL_10G_S_SR: - case TRANSVR_CLASS_OPTICAL_10G_S_LR: - case TRANSVR_CLASS_COPPER_L1_10G: - /* Transfer speed case - * => Example: Raycom 10G DAC - */ - return detect_val; - default: - snprintf(err_msg, sizeof(err_msg), - "Detect undefined 1G_eth:%d", - detect_val); - goto err_sft_detect_transceiver_class_1; - } - /* Check by connector, br, wavelength */ - detect_val = _sfp_detect_class_by_feature(self); - switch(detect_val) { - case TRANSVR_CLASS_UNSPECIFIED: - break; - case TRANSVR_CLASS_OPTICAL: - case TRANSVR_CLASS_OPTICAL_1G: - case TRANSVR_CLASS_OPTICAL_1G_SX: - case TRANSVR_CLASS_OPTICAL_1G_LX: - case TRANSVR_CLASS_OPTICAL_1G_EX: - case TRANSVR_CLASS_OPTICAL_1G_AOC: - case TRANSVR_CLASS_OPTICAL_10G: - case TRANSVR_CLASS_OPTICAL_10G_S_SR: - case TRANSVR_CLASS_OPTICAL_10G_S_LR: - case TRANSVR_CLASS_OPTICAL_10G_S_ER: - case TRANSVR_CLASS_OPTICAL_10G_S_AOC: - case TRANSVR_CLASS_OPTICAL_25G: - case TRANSVR_CLASS_OPTICAL_25G_SR: - case TRANSVR_CLASS_OPTICAL_25G_LR: - case TRANSVR_CLASS_OPTICAL_25G_ER: - case TRANSVR_CLASS_OPTICAL_25G_AOC: - case TRANSVR_CLASS_COPPER: - case TRANSVR_CLASS_COPPER_L1_1G: - case TRANSVR_CLASS_COPPER_L1_10G: - case TRANSVR_CLASS_COPPER_L1_25G: - return detect_val; - default: - snprintf(err_msg, sizeof(err_msg), - "Detect undefined get_connector:%d", - detect_val); - goto err_sft_detect_transceiver_class_1; - } - /* Exception case: Can't verify */ - snprintf(err_msg, sizeof(err_msg), "Can not identify!"); - goto err_sft_detect_transceiver_class_1; - -err_sft_detect_transceiver_class_1: - SWPS_INFO("%s: %s :%s\n", __func__, err_msg, self->swp_name); - return TRANSVR_CLASS_ERROR; -} - - -int -_sfp_set_magnolia_if_type(struct transvr_obj_s* self, - int transvr_cls, - char *result){ - - int lmax = 8; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - - switch(transvr_cls) { - case TRANSVR_CLASS_ERROR: - case TRANSVR_CLASS_UNSPECIFIED: - break; - /* 25G OPTICAL */ - case TRANSVR_CLASS_OPTICAL_25G_AOC: - case TRANSVR_CLASS_OPTICAL_25G_SR: - case TRANSVR_CLASS_OPTICAL_25G_LR: - case TRANSVR_CLASS_OPTICAL_25G_ER: - case TRANSVR_CLASS_OPTICAL_25G: - return snprintf(result, lmax, TRANSVR_IF_SFI); - /* 25G COPPER */ - case TRANSVR_CLASS_COPPER_L1_25G: - return snprintf(result, lmax, TRANSVR_IF_SFI); - /* 10G OPTICAL */ - case TRANSVR_CLASS_OPTICAL_10G_S_AOC: - case TRANSVR_CLASS_OPTICAL_10G_S_SR: - case TRANSVR_CLASS_OPTICAL_10G_S_LR: - case TRANSVR_CLASS_OPTICAL_10G_S_ER: - case TRANSVR_CLASS_OPTICAL_10G: - return snprintf(result, lmax, TRANSVR_IF_SFI); - /* 10G COPPER */ - case TRANSVR_CLASS_COPPER_L1_10G: - return snprintf(result, lmax, TRANSVR_IF_SFI); - /* 1G OPTICAL */ - case TRANSVR_CLASS_OPTICAL_1G_AOC: - case TRANSVR_CLASS_OPTICAL_1G_SX: - case TRANSVR_CLASS_OPTICAL_1G_LX: - case TRANSVR_CLASS_OPTICAL_1G_EX: - case TRANSVR_CLASS_OPTICAL_1G: - return snprintf(result, lmax, TRANSVR_IF_IF_GMII); - /* 1G COPPER */ - case TRANSVR_CLASS_COPPER_L1_1G: - return snprintf(result, lmax, TRANSVR_IF_IF_GMII); - /* 1G BASE_T */ - case TRANSVR_CLASS_BASE_T_1000: - return snprintf(result, lmax, TRANSVR_IF_IF_GMII); - /* 100 Base */ - case TRANSVR_CLASS_OPTICAL_100: - return snprintf(result, lmax, TRANSVR_IF_IF_GMII); - default: - snprintf(err_msg, sizeof(err_msg), - "Detect undefined value:%d", - transvr_cls); - goto err_sfp_set_magnolia_if_type_1; - } - /* Exception case: Can't verify */ - snprintf(err_msg, sizeof(err_msg), "Can not identify!"); - goto err_sfp_set_magnolia_if_type_1; - -err_sfp_set_magnolia_if_type_1: - snprintf(result, lmax, TRANSVR_UEVENT_UNKNOW); - SWPS_INFO("%s: %s :%s\n", __func__, err_msg, self->swp_name); - return ERR_TRANSVR_ABNORMAL; -} - - -int -_sfp_set_redwood_if_type(struct transvr_obj_s* self, - int transvr_cls, - char *result) { - - int lmax = 8; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - - switch(transvr_cls) { - case TRANSVR_CLASS_ERROR: - case TRANSVR_CLASS_UNSPECIFIED: - break; - /* 25G OPTICAL */ - case TRANSVR_CLASS_OPTICAL_25G_AOC: - case TRANSVR_CLASS_OPTICAL_25G_SR: - case TRANSVR_CLASS_OPTICAL_25G_LR: - case TRANSVR_CLASS_OPTICAL_25G_ER: - case TRANSVR_CLASS_OPTICAL_25G: - return snprintf(result, lmax, TRANSVR_IF_SR); - /* 25G COPPER */ - case TRANSVR_CLASS_COPPER_L1_25G: - return snprintf(result, lmax, TRANSVR_IF_KR); - /* 10G OPTICAL */ - case TRANSVR_CLASS_OPTICAL_10G_S_AOC: - case TRANSVR_CLASS_OPTICAL_10G_S_SR: - case TRANSVR_CLASS_OPTICAL_10G_S_LR: - case TRANSVR_CLASS_OPTICAL_10G_S_ER: - case TRANSVR_CLASS_OPTICAL_10G: - return snprintf(result, lmax, TRANSVR_IF_SFI); - /* 10G COPPER */ - case TRANSVR_CLASS_COPPER_L1_10G: - return snprintf(result, lmax, TRANSVR_IF_SFI); - /* 1G OPTICAL */ - case TRANSVR_CLASS_OPTICAL_1G_AOC: - case TRANSVR_CLASS_OPTICAL_1G_SX: - case TRANSVR_CLASS_OPTICAL_1G_LX: - case TRANSVR_CLASS_OPTICAL_1G_EX: - case TRANSVR_CLASS_OPTICAL_1G: - return snprintf(result, lmax, TRANSVR_IF_IF_GMII); - /* 1G COPPER */ - case TRANSVR_CLASS_COPPER_L1_1G: - return snprintf(result, lmax, TRANSVR_IF_IF_GMII); - /* 1G BASE_T */ - case TRANSVR_CLASS_BASE_T_1000: - return snprintf(result, lmax, TRANSVR_IF_IF_GMII); - /* 100 Base */ - case TRANSVR_CLASS_OPTICAL_100: - return snprintf(result, lmax, TRANSVR_IF_IF_GMII); - default: - snprintf(err_msg, sizeof(err_msg), - "Detect undefined value:%d", - transvr_cls); - goto err_sfp_set_redwood_if_type_1; - } - /* Exception case: Can't verify */ - snprintf(err_msg, sizeof(err_msg), "Can not identify!"); - goto err_sfp_set_redwood_if_type_1; - -err_sfp_set_redwood_if_type_1: - snprintf(result, lmax, TRANSVR_UEVENT_UNKNOW); - SWPS_INFO("%s: %s\n :%s", __func__, err_msg, self->swp_name); - return ERR_TRANSVR_ABNORMAL; -} - - -int -_sfp_set_lavender_if_type(struct transvr_obj_s* self, - int transvr_cls, - char *result) { - /* (TBD) - * Due to chip vendor looks like doesn't have interface type. - * We bypass it currently. - */ - int lmax = 8; - return snprintf(result, lmax, TRANSVR_UEVENT_UNKNOW); -} - - -int -_sfp_detect_if_type(struct transvr_obj_s* self, - char *result){ - - int lmax = 8; - int detect_cls = DEBUG_TRANSVR_INT_VAL; - - detect_cls = sft_detect_transvr_class(self); - switch (self->chipset_type) { - case CHIP_TYPE_MAGNOLIA: - return _sfp_set_magnolia_if_type(self, detect_cls, result); - - case CHIP_TYPE_MAPLE: - case CHIP_TYPE_REDWOOD: - return _sfp_set_redwood_if_type(self, detect_cls, result); - - case CHIP_TYPE_LAVENDER: - return _sfp_set_lavender_if_type(self, detect_cls, result); - - default: - SWPS_INFO("%s: non-defined chipset_type:%d :%s\n", - __func__, self->chipset_type, self->swp_name); - break; - } - snprintf(result, lmax, TRANSVR_UEVENT_UNKNOW); - return ERR_TRANSVR_ABNORMAL; -} - - -int -sfp_get_if_type(struct transvr_obj_s *self, - char *buf_p){ - - int lmax = 16; - char tmp_result[16] = DEBUG_TRANSVR_STR_VAL; - - if (self->state != STATE_TRANSVR_CONNECTED) { - return snprintf(buf_p, lmax, "%d\n", self->state); - } - if (_sfp_detect_if_type(self, tmp_result) < 0) { - return snprintf(buf_p, lmax, "%d\n", ERR_TRANSVR_ABNORMAL); - } - return snprintf(buf_p, lmax, "%s\n", tmp_result); -} - - -int -_sfp_detect_if_speed(struct transvr_obj_s* self, - char *result){ - - int lmax = 16; - int detect_val = DEBUG_TRANSVR_INT_VAL; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - - detect_val = sft_detect_transvr_class(self); - switch(detect_val) { - case TRANSVR_CLASS_ERROR: - case TRANSVR_CLASS_UNSPECIFIED: - break; - /* 25G OPTICAL */ - case TRANSVR_CLASS_OPTICAL_25G_AOC: - case TRANSVR_CLASS_OPTICAL_25G_SR: - case TRANSVR_CLASS_OPTICAL_25G_LR: - case TRANSVR_CLASS_OPTICAL_25G_ER: - case TRANSVR_CLASS_OPTICAL_25G: - return snprintf(result, lmax, TRANSVR_IF_SP_25G); - /* 25G COPPER */ - case TRANSVR_CLASS_COPPER_L1_25G: - return snprintf(result, lmax, TRANSVR_IF_SP_25G); - /* 10G OPTICAL */ - case TRANSVR_CLASS_OPTICAL_10G_S_AOC: - case TRANSVR_CLASS_OPTICAL_10G_S_SR: - case TRANSVR_CLASS_OPTICAL_10G_S_LR: - case TRANSVR_CLASS_OPTICAL_10G_S_ER: - case TRANSVR_CLASS_OPTICAL_10G: - return snprintf(result, lmax, TRANSVR_IF_SP_10G); - /* 10G COPPER */ - case TRANSVR_CLASS_COPPER_L1_10G: - return snprintf(result, lmax, TRANSVR_IF_SP_10G); - /* 1G OPTICAL */ - case TRANSVR_CLASS_OPTICAL_1G_AOC: - case TRANSVR_CLASS_OPTICAL_1G_SX: - case TRANSVR_CLASS_OPTICAL_1G_LX: - case TRANSVR_CLASS_OPTICAL_1G_EX: - case TRANSVR_CLASS_OPTICAL_1G: - return snprintf(result, lmax, TRANSVR_IF_SP_1G); - /* 1G COPPER */ - case TRANSVR_CLASS_COPPER_L1_1G: - return snprintf(result, lmax, TRANSVR_IF_SP_1G); - /* 1G BASE_T */ - case TRANSVR_CLASS_BASE_T_1000: - return snprintf(result, lmax, TRANSVR_IF_SP_1G); - /* 100 Base */ - case TRANSVR_CLASS_OPTICAL_100: - return snprintf(result, lmax, TRANSVR_IF_SP_100); - default: - snprintf(err_msg, sizeof(err_msg), - "Detect undefined value:%d", - detect_val); - goto err_sfp_detect_if_speed_1; - } - /* Check by BR */ - detect_val = _sfp_detect_if_sp_by_br(self); - switch (detect_val) { - case TRANSVR_CLASS_25G: - return snprintf(result, lmax, TRANSVR_IF_SP_25G); - case TRANSVR_CLASS_10G: - return snprintf(result, lmax, TRANSVR_IF_SP_10G); - case TRANSVR_CLASS_1G: - return snprintf(result, lmax, TRANSVR_IF_SP_1G); - default: - break; - } - /* Exception case: Can't verify */ - snprintf(err_msg, sizeof(err_msg), "Can not identify!"); - goto err_sfp_detect_if_speed_1; - -err_sfp_detect_if_speed_1: - snprintf(result, lmax, TRANSVR_UEVENT_UNKNOW); - SWPS_INFO("%s %s\n :%s", __func__, err_msg, self->swp_name); - return ERR_TRANSVR_ABNORMAL; -} - - -int -sfp_get_if_speed(struct transvr_obj_s *self, - char *buf_p){ - - int lmax = 16; - char tmp_result[16] = DEBUG_TRANSVR_STR_VAL; - - if (self->state != STATE_TRANSVR_CONNECTED) { - return snprintf(buf_p, lmax, "%d\n", self->state); - } - if (_sfp_detect_if_speed(self, tmp_result) < 0) { - return snprintf(buf_p, lmax, "%d\n", ERR_TRANSVR_ABNORMAL); - } - return snprintf(buf_p, lmax, "%s\n", tmp_result); -} - - -int -_qsfp_detect_class_by_extend_comp(struct transvr_obj_s* self) { - /* Reference: SFF-8024 (v3.8) - */ - int detect_val = DEBUG_TRANSVR_INT_VAL; - - detect_val = _qsfp_get_comp_extended(self); - switch(detect_val) { - case 0x00: /* Unspecified */ - return TRANSVR_CLASS_UNSPECIFIED; - - case 0x01: /* 100G AOC (Active Optical Cable) or 25GAUI C2M */ - case 0x18: /* 100G AOC or 25GAUI C2M AOC. */ - return TRANSVR_CLASS_OPTICAL_100G_AOC; - - case 0x06: /* 100G CWDM4 */ - case 0x09: /* Obsolete (assigned before 100G CWDM4 MSA required FEC) */ - case 0x17: /* 100G CLR4 */ - case 0x1A: /* 100GE-DWDM2 */ - return TRANSVR_CLASS_OPTICAL_100G; - - case 0x02: /* 100GBASE-SR4 or 25GBASE-SR */ - return TRANSVR_CLASS_OPTICAL_100G_SR4; - - case 0x03: /* 100GBASE-LR4 or 25GBASE-LR */ - return TRANSVR_CLASS_OPTICAL_100G_LR4; - - case 0x04: /* 100GBASE-ER4 or 25GBASE-ER */ - return TRANSVR_CLASS_OPTICAL_100G_ER4; - - case 0x07: /* 100G PSM4 Parallel SMF */ - return TRANSVR_CLASS_OPTICAL_100G_PSM4; - - case 0x12: /* 40G PSM4 Parallel SMF */ - return TRANSVR_CLASS_OPTICAL_40G; - - case 0x11: /* 4 x 10GBASE-SR */ - return TRANSVR_CLASS_OPTICAL_40G_SR4; - - case 0x10: /* 40GBASE-ER4 */ - return TRANSVR_CLASS_OPTICAL_40G_ER4; - - case 0x08: /* 100G ACC (Active Copper Cable) or 25GAUI C2M ACC. */ - case 0x0b: /* 100GBASE-CR4 or 25GBASE-CR CA-L */ - case 0x19: /* 100G ACC or 25GAUI C2M ACC. */ - return TRANSVR_CLASS_COPPER_L4_100G; - - default: - break; - } - SWPS_INFO("%s: Unexcept value:0x%02x\n :%s", - __func__, detect_val, self->swp_name); - return TRANSVR_CLASS_ERROR; -} - - -int -_qsfp_detect_class_by_10_40_100_ethernet(struct transvr_obj_s* self) { - /* Reference: SFF-8472 (v12.2) - */ - int detect_val = DEBUG_TRANSVR_INT_VAL; - - detect_val = _qsfp_get_comp_10_40_100_ethernet(self); - /* Case: Unspecified */ - if (detect_val == 0x00) { - return TRANSVR_CLASS_UNSPECIFIED; - } - /* Case: 40G Optical */ - if ((detect_val & 0x01) == 0x01) { /* 00000001 : 40G Active Cable (XLPPI) */ - return TRANSVR_CLASS_OPTICAL_40G_AOC; - } - if ((detect_val & 0x04) == 0x04) { /* 00000100 : 40GBASE-SR4 */ - return TRANSVR_CLASS_OPTICAL_40G_SR4; - } - if ( (detect_val & 0x02) == 0x02) { /* 00000010 : 40GBASE-LR4 */ - return TRANSVR_CLASS_OPTICAL_40G_LR4; - } - if ( (detect_val & 0x08) == 0x08) { /* 00001000 : 40GBASE-CR4 */ - return TRANSVR_CLASS_COPPER_L4_40G; - } - /* Case: 10G Optical */ - if ( (detect_val & 0x10) == 0x10) { /* 00010000 : 10GBASE-SR */ - return TRANSVR_CLASS_OPTICAL_10G_Q_SR; - } - if ( ((detect_val & 0x20) == 0x20) || /* 00100000 : 10GBASE-LR */ - ((detect_val & 0x40) == 0x40) ){ /* 01000000 : 10GBASE-LRM */ - return TRANSVR_CLASS_OPTICAL_10G_Q_LR; - } - /* Case: Extend Compliance */ - if ( ((detect_val & 0x80) == 0x80) ){ /* 10000000 : Use Extend Compliance */ - return TRANSVR_CLASS_EXTEND_COMP; - } - /* Case: ERROR */ - SWPS_INFO("%s: Unexcept value:0x%02x\n :%s", - __func__, detect_val, self->swp_name); - return TRANSVR_CLASS_ERROR; -} - - -int -_qsfp_detect_if_sp_by_br(struct transvr_obj_s* self) { - - int lower_bound_10g = 0x10; - int upper_bound_10g = 0x25; - int lower_bound_40g = 0x60; - int upper_bound_40g = 0x75; - int lower_bound_100g = 0x60; - int upper_bound_100g = 0x75; - int used_extend_br = 0xff; - int notmal_br = DEBUG_TRANSVR_INT_VAL; - int extend_br = DEBUG_TRANSVR_INT_VAL; - - notmal_br = (int)(self->br); /* updated by update_all() */ - /* Check 40G */ - if ((notmal_br >= lower_bound_40g) && - (notmal_br <= upper_bound_40g) ) { - return TRANSVR_CLASS_40G; - } - /* Check 100G */ - if (notmal_br == used_extend_br) { - extend_br = (int)(self->extbr); /* updated by update_all() */ - if ((extend_br >= lower_bound_100g) && - (extend_br <= upper_bound_100g) ) { - return TRANSVR_CLASS_100G; - } - } - /* Check 10G */ - if ((notmal_br >= lower_bound_10g) && - (notmal_br <= upper_bound_10g) ) { - return TRANSVR_CLASS_10G; - } - return TRANSVR_CLASS_UNSPECIFIED; -} - - -int -_qsfp_detect_class_by_feature(struct transvr_obj_s* self) { - /* Reference: SFF-8024 (v3.8) - */ - int conn_val = DEBUG_TRANSVR_INT_VAL; - int wave_len = DEBUG_TRANSVR_INT_VAL; - int speed_val = DEBUG_TRANSVR_INT_VAL; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - - speed_val = _qsfp_detect_if_sp_by_br(self); - conn_val = _qsfp_get_connector_type(self); - - switch(conn_val) { - case 0x00: /* Unspecified */ - return TRANSVR_CLASS_UNSPECIFIED; - case 0x07: /* LC (Lucent Connector) */ - case 0x0b: /* Optical Pigtail */ - case 0x0c: /* MPO 1x12 (Multifiber Parallel Optic) */ - case 0x0d: /* MPO 2x16 */ - goto ok_qsfp_detect_class_by_feature_4_optiocal; - case 0x21: /* Copper pigtail */ - goto ok_qsfp_detect_class_by_feature_4_copper; - case 0x23: /* No separable connector */ - if ((_qsfp_get_comp_fc_link_length(self) > 0) || - (_qsfp_get_comp_fc_trans_tech(self) > 0) || - (_qsfp_get_comp_fc_trans_media(self) > 0) || - (_qsfp_get_comp_fc_speed(self) > 0) ) { - goto ok_qsfp_detect_class_by_feature_4_aoc; - } - goto ok_qsfp_detect_class_by_feature_4_copper; - default: - snprintf(err_msg, sizeof(err_msg), - "_qsfp_get_connector_type return Non define value:%d", - conn_val); - goto err_qsfp_detect_class_by_feature_1; - } - return TRANSVR_CLASS_UNSPECIFIED; - -ok_qsfp_detect_class_by_feature_4_optiocal: - wave_len = _common_count_wavelength(self, - self->wavelength[0], - self->wavelength[1]); - switch(speed_val) { - case TRANSVR_CLASS_100G: - switch (wave_len) { - case VAL_OPTICAL_WAVELENGTH_SR: - return TRANSVR_CLASS_OPTICAL_100G_SR4; - case VAL_OPTICAL_WAVELENGTH_LR: - return TRANSVR_CLASS_OPTICAL_100G_LR4; - case VAL_OPTICAL_WAVELENGTH_ER: - return TRANSVR_CLASS_OPTICAL_100G_ER4; - default: - break; - } - return TRANSVR_CLASS_OPTICAL_100G; - - case TRANSVR_CLASS_40G: - switch (wave_len) { - case VAL_OPTICAL_WAVELENGTH_SR: - return TRANSVR_CLASS_OPTICAL_40G_SR4; - case VAL_OPTICAL_WAVELENGTH_LR: - return TRANSVR_CLASS_OPTICAL_40G_LR4; - case VAL_OPTICAL_WAVELENGTH_ER: - return TRANSVR_CLASS_OPTICAL_40G_ER4; - default: - break; - } - return TRANSVR_CLASS_OPTICAL_40G; - - case TRANSVR_CLASS_10G: - switch (wave_len) { - case VAL_OPTICAL_WAVELENGTH_SR: - return TRANSVR_CLASS_OPTICAL_10G_Q_SR; - case VAL_OPTICAL_WAVELENGTH_LR: - return TRANSVR_CLASS_OPTICAL_10G_Q_LR; - case VAL_OPTICAL_WAVELENGTH_ER: - return TRANSVR_CLASS_OPTICAL_10G_Q_ER; - default: - break; - } - return TRANSVR_CLASS_OPTICAL_10G; - - default: - return TRANSVR_CLASS_OPTICAL; - } - -ok_qsfp_detect_class_by_feature_4_aoc: - switch(speed_val) { - case TRANSVR_CLASS_100G: - return TRANSVR_CLASS_OPTICAL_100G_AOC; - case TRANSVR_CLASS_40G: - return TRANSVR_CLASS_OPTICAL_40G_AOC; - case TRANSVR_CLASS_10G: - return TRANSVR_CLASS_OPTICAL_10G_Q_AOC; - default: - return TRANSVR_CLASS_OPTICAL; - } - -ok_qsfp_detect_class_by_feature_4_copper: - switch(speed_val) { - case TRANSVR_CLASS_100G: - return TRANSVR_CLASS_COPPER_L4_100G; - case TRANSVR_CLASS_40G: - return TRANSVR_CLASS_COPPER_L4_40G; - case TRANSVR_CLASS_10G: - return TRANSVR_CLASS_COPPER_L4_10G; - default: - return TRANSVR_CLASS_COPPER; - } - -err_qsfp_detect_class_by_feature_1: - SWPS_INFO("%s: %s\n :%s", - __func__, err_msg, self->swp_name); - return TRANSVR_CLASS_ERROR; -} - - -int -qsft_detect_transvr_class(struct transvr_obj_s* self) { - - int detect_val = DEBUG_TRANSVR_INT_VAL; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - - /* Check Extended Compliance */ - detect_val = _qsfp_detect_class_by_extend_comp(self); - switch (detect_val) { - case TRANSVR_CLASS_UNSPECIFIED: - break; - case TRANSVR_CLASS_OPTICAL_100G: - case TRANSVR_CLASS_OPTICAL_100G_AOC: - case TRANSVR_CLASS_OPTICAL_100G_SR4: - case TRANSVR_CLASS_OPTICAL_100G_LR4: - case TRANSVR_CLASS_OPTICAL_100G_ER4: - case TRANSVR_CLASS_OPTICAL_100G_PSM4: - case TRANSVR_CLASS_OPTICAL_40G: - case TRANSVR_CLASS_OPTICAL_40G_AOC: - case TRANSVR_CLASS_OPTICAL_40G_SR4: - case TRANSVR_CLASS_OPTICAL_40G_LR4: - case TRANSVR_CLASS_OPTICAL_40G_ER4: - case TRANSVR_CLASS_COPPER_L4_100G: - return detect_val; - default: - snprintf(err_msg, sizeof(err_msg), - "Detect undefined extend_comp:%d", - detect_val); - goto err_qsft_detect_transvr_class_1; - } - /* Check 10/40G/100G Ethernet Compliance */ - detect_val = _qsfp_detect_class_by_10_40_100_ethernet(self); - switch(detect_val) { - case TRANSVR_CLASS_UNSPECIFIED: - break; - case TRANSVR_CLASS_OPTICAL_40G_AOC: - case TRANSVR_CLASS_OPTICAL_40G_SR4: - case TRANSVR_CLASS_OPTICAL_40G_LR4: - case TRANSVR_CLASS_OPTICAL_10G_Q_SR: /* Need Check: SR4 or SR */ - case TRANSVR_CLASS_OPTICAL_10G_Q_LR: /* Need Check: SR4 or SR */ - case TRANSVR_CLASS_COPPER_L4_40G: - return detect_val; - case TRANSVR_CLASS_EXTEND_COMP: - /* Format incorrect case (We already checked the Extend - * Compliance is 0 - */ - snprintf(err_msg, sizeof(err_msg), - "Transceiver format incorrect"); - goto err_qsft_detect_transvr_class_1; - default: - snprintf(err_msg, sizeof(err_msg), - "Detect undefined 10/40/100:%d", - detect_val); - goto err_qsft_detect_transvr_class_1; - } - /* Check by Connector type, BR and wavelength */ - detect_val = _qsfp_detect_class_by_feature(self); - switch (detect_val) { - case TRANSVR_CLASS_UNSPECIFIED: - break; - case TRANSVR_CLASS_OPTICAL_100G_ER4: - case TRANSVR_CLASS_OPTICAL_100G_LR4: - case TRANSVR_CLASS_OPTICAL_100G_SR4: - case TRANSVR_CLASS_OPTICAL_100G_AOC: - case TRANSVR_CLASS_OPTICAL_100G: - case TRANSVR_CLASS_OPTICAL_40G_ER4: - case TRANSVR_CLASS_OPTICAL_40G_LR4: - case TRANSVR_CLASS_OPTICAL_40G_SR4: - case TRANSVR_CLASS_OPTICAL_40G_AOC: - case TRANSVR_CLASS_OPTICAL_40G: - case TRANSVR_CLASS_OPTICAL_10G_Q_ER: - case TRANSVR_CLASS_OPTICAL_10G_Q_LR: - case TRANSVR_CLASS_OPTICAL_10G_Q_SR: - case TRANSVR_CLASS_OPTICAL_10G_Q_AOC: - case TRANSVR_CLASS_OPTICAL_10G: - case TRANSVR_CLASS_OPTICAL: - case TRANSVR_CLASS_COPPER_L4_100G: - case TRANSVR_CLASS_COPPER_L4_40G: - case TRANSVR_CLASS_COPPER_L4_10G: - case TRANSVR_CLASS_COPPER: - return detect_val; - default: - snprintf(err_msg, sizeof(err_msg), - "Detect undefined connector:%d", - detect_val); - goto err_qsft_detect_transvr_class_1; - } - /* Exception case: Can't verify */ - snprintf(err_msg, sizeof(err_msg), - "Can not identify!"); - goto err_qsft_detect_transvr_class_1; - -err_qsft_detect_transvr_class_1: - SWPS_INFO("%s: %s\n :%s", __func__, err_msg, self->swp_name); - return TRANSVR_CLASS_ERROR; -} - - -int -_qsfp_set_magnolia_if_type(struct transvr_obj_s* self, - int transvr_cls, - char *result){ - - int lmax = 8; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - - switch (transvr_cls) { - case TRANSVR_CLASS_UNSPECIFIED: - case TRANSVR_CLASS_ERROR: - break; - /* 100G Optical */ - case TRANSVR_CLASS_OPTICAL_100G: - case TRANSVR_CLASS_OPTICAL_100G_AOC: - case TRANSVR_CLASS_OPTICAL_100G_SR4: - case TRANSVR_CLASS_OPTICAL_100G_LR4: - case TRANSVR_CLASS_OPTICAL_100G_ER4: - case TRANSVR_CLASS_OPTICAL_100G_PSM4: - return snprintf(result, lmax, TRANSVR_IF_SR4); - /* 100G Copper */ - case TRANSVR_CLASS_COPPER_L4_100G: - return snprintf(result, lmax, TRANSVR_IF_KR4); - /* 40G Optical */ - case TRANSVR_CLASS_OPTICAL_40G: - case TRANSVR_CLASS_OPTICAL_40G_AOC: - case TRANSVR_CLASS_OPTICAL_40G_SR4: - case TRANSVR_CLASS_OPTICAL_40G_LR4: - case TRANSVR_CLASS_OPTICAL_40G_ER4: - return snprintf(result, lmax, TRANSVR_IF_IF_XGMII); - /* 40G Copper */ - case TRANSVR_CLASS_COPPER_L4_40G: - return snprintf(result, lmax, TRANSVR_IF_IF_XGMII); - /* 10G Optical */ - case TRANSVR_CLASS_OPTICAL_10G: - case TRANSVR_CLASS_OPTICAL_10G_Q_AOC: - case TRANSVR_CLASS_OPTICAL_10G_Q_SR: /* Need Check: SR4 or SR */ - case TRANSVR_CLASS_OPTICAL_10G_Q_LR: /* Need Check: LR4 or LR */ - case TRANSVR_CLASS_OPTICAL_10G_Q_ER: /* Need Check: ER4 or ER */ - return snprintf(result, lmax, TRANSVR_IF_IF_XGMII); - /* Optical */ - case TRANSVR_CLASS_OPTICAL: - return snprintf(result, lmax, TRANSVR_IF_IF_XGMII); - /* Copper */ - case TRANSVR_CLASS_COPPER: - return snprintf(result, lmax, TRANSVR_IF_IF_XGMII); - default: - snprintf(err_msg, sizeof(err_msg), - "Detect undefined value:%d", - transvr_cls); - goto err_qsfp_set_magnolia_if_type_1; - } - /* Exception case: Can't verify */ - snprintf(err_msg, sizeof(err_msg), "Can not identify!"); - goto err_qsfp_set_magnolia_if_type_1; - -err_qsfp_set_magnolia_if_type_1: - snprintf(result, lmax, TRANSVR_UEVENT_UNKNOW); - SWPS_INFO("%s: %s\n :%s", __func__, err_msg, self->swp_name); - return ERR_TRANSVR_ABNORMAL; -} - - -int -_qsfp_set_redwood_if_type(struct transvr_obj_s* self, - int transvr_cls, - char *result){ - - int lmax = 8; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - - switch (transvr_cls) { - case TRANSVR_CLASS_UNSPECIFIED: - case TRANSVR_CLASS_ERROR: - break; - /* 100G Optical */ - case TRANSVR_CLASS_OPTICAL_100G: - case TRANSVR_CLASS_OPTICAL_100G_AOC: - case TRANSVR_CLASS_OPTICAL_100G_SR4: - case TRANSVR_CLASS_OPTICAL_100G_LR4: - case TRANSVR_CLASS_OPTICAL_100G_ER4: - case TRANSVR_CLASS_OPTICAL_100G_PSM4: - return snprintf(result, lmax, TRANSVR_IF_SR4); - /* 100G Copper */ - case TRANSVR_CLASS_COPPER_L4_100G: - return snprintf(result, lmax, TRANSVR_IF_KR4); - /* 40G Optical */ - case TRANSVR_CLASS_OPTICAL_40G: - case TRANSVR_CLASS_OPTICAL_40G_AOC: - case TRANSVR_CLASS_OPTICAL_40G_SR4: - case TRANSVR_CLASS_OPTICAL_40G_LR4: - case TRANSVR_CLASS_OPTICAL_40G_ER4: - return snprintf(result, lmax, TRANSVR_IF_SR4); - /* 40G Copper */ - case TRANSVR_CLASS_COPPER_L4_40G: - return snprintf(result, lmax, TRANSVR_IF_KR4); - /* 10G Optical */ - case TRANSVR_CLASS_OPTICAL_10G: - case TRANSVR_CLASS_OPTICAL_10G_Q_AOC: - case TRANSVR_CLASS_OPTICAL_10G_Q_SR: /* Need Check: SR4 or SR */ - case TRANSVR_CLASS_OPTICAL_10G_Q_LR: /* Need Check: SR4 or SR */ - case TRANSVR_CLASS_OPTICAL_10G_Q_ER: - return snprintf(result, lmax, TRANSVR_IF_SR4); - /* Optical */ - case TRANSVR_CLASS_OPTICAL: - return snprintf(result, lmax, TRANSVR_IF_SR4); - /* Copper */ - case TRANSVR_CLASS_COPPER: - return snprintf(result, lmax, TRANSVR_IF_KR4); - default: - snprintf(err_msg, sizeof(err_msg), - "Detect undefined value:%d", - transvr_cls); - goto err_qsfp_set_magnolia_if_type_1; - } - /* Exception case: Can't verify */ - snprintf(err_msg, sizeof(err_msg), "Can not identify!"); - goto err_qsfp_set_magnolia_if_type_1; - -err_qsfp_set_magnolia_if_type_1: - snprintf(result, lmax, TRANSVR_UEVENT_UNKNOW); - SWPS_INFO("%s: %s\n :%s", __func__, err_msg, self->swp_name); - return ERR_TRANSVR_ABNORMAL; -} - - -int -_qsfp_set_lavender_if_type(struct transvr_obj_s* self, - int transvr_cls, - char *result) { - /* (TBD) - * Due to chip vendor looks like doesn't have interface type. - * We bypass it currently. - */ - int lmax = 8; - return snprintf(result, lmax, TRANSVR_UEVENT_UNKNOW); -} - - -int -_qsfp_detect_if_type(struct transvr_obj_s* self, - char *result){ - - int lmax = 8; - int detect_cls = DEBUG_TRANSVR_INT_VAL; - - detect_cls = qsft_detect_transvr_class(self); - switch (self->chipset_type) { - case CHIP_TYPE_MAGNOLIA: - return _qsfp_set_magnolia_if_type(self, detect_cls, result); - - case CHIP_TYPE_MAPLE: - case CHIP_TYPE_REDWOOD: - return _qsfp_set_redwood_if_type(self, detect_cls, result); - - case CHIP_TYPE_LAVENDER: - return _qsfp_set_lavender_if_type(self, detect_cls, result); - - default: - SWPS_INFO("%s: non-defined chipset_type:%d :%s\n", - __func__, self->chipset_type, self->swp_name); - break; - } - snprintf(result, lmax, TRANSVR_UEVENT_UNKNOW); - return ERR_TRANSVR_ABNORMAL; -} - - -int -qsfp_get_if_type(struct transvr_obj_s *self, - char *buf_p){ - - int lmax = 8; - char tmp_result[8] = DEBUG_TRANSVR_STR_VAL; - - if (self->state != STATE_TRANSVR_CONNECTED) { - return snprintf(buf_p, lmax, "%d\n", self->state); - } - if (_qsfp_detect_if_type(self, tmp_result) < 0) { - return snprintf(buf_p, lmax, "%d\n", ERR_TRANSVR_ABNORMAL); - } - return snprintf(buf_p, lmax, "%s\n", tmp_result); -} - - -int -_qsfp_detect_if_speed(struct transvr_obj_s* self, - char *result){ - int lmax = 16; - int detect_val = DEBUG_TRANSVR_INT_VAL; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - - detect_val = qsft_detect_transvr_class(self); - switch (detect_val) { - case TRANSVR_CLASS_UNSPECIFIED: - case TRANSVR_CLASS_ERROR: - break; - /* 100G Optical */ - case TRANSVR_CLASS_OPTICAL_100G: - case TRANSVR_CLASS_OPTICAL_100G_AOC: - case TRANSVR_CLASS_OPTICAL_100G_SR4: - case TRANSVR_CLASS_OPTICAL_100G_LR4: - case TRANSVR_CLASS_OPTICAL_100G_ER4: - case TRANSVR_CLASS_OPTICAL_100G_PSM4: - return snprintf(result, lmax, TRANSVR_IF_SP_100G); - /* 100G Copper */ - case TRANSVR_CLASS_COPPER_L4_100G: - return snprintf(result, lmax, TRANSVR_IF_SP_100G); - /* 40G Optical */ - case TRANSVR_CLASS_OPTICAL_40G: - case TRANSVR_CLASS_OPTICAL_40G_AOC: - case TRANSVR_CLASS_OPTICAL_40G_SR4: - case TRANSVR_CLASS_OPTICAL_40G_LR4: - case TRANSVR_CLASS_OPTICAL_40G_ER4: - return snprintf(result, lmax, TRANSVR_IF_SP_40G); - /* 40G Copper */ - case TRANSVR_CLASS_COPPER_L4_40G: - return snprintf(result, lmax, TRANSVR_IF_SP_40G); - /* 10G Optical */ - case TRANSVR_CLASS_OPTICAL_10G: - case TRANSVR_CLASS_OPTICAL_10G_Q_AOC: - case TRANSVR_CLASS_OPTICAL_10G_Q_SR: /* Need Check: SR4 or SR */ - case TRANSVR_CLASS_OPTICAL_10G_Q_LR: /* Need Check: SR4 or SR */ - case TRANSVR_CLASS_OPTICAL_10G_Q_ER: - return snprintf(result, lmax, TRANSVR_IF_SP_10G); - /* 10G Copper */ - case TRANSVR_CLASS_COPPER_L4_10G: - return snprintf(result, lmax, TRANSVR_IF_SP_10G); - /* Optical */ - case TRANSVR_CLASS_OPTICAL: - break; - /* Copper */ - case TRANSVR_CLASS_COPPER: - break; - default: - snprintf(err_msg, sizeof(err_msg), - "Detect undefined class case:%d", - detect_val); - goto err_qsfp_detect_if_speed_1; - } - /* Check br and extbr */ - detect_val = _qsfp_detect_if_sp_by_br(self); - switch(detect_val) { - case TRANSVR_CLASS_UNSPECIFIED: - break; - case TRANSVR_CLASS_10G: - return snprintf(result, lmax, TRANSVR_IF_SP_10G); - case TRANSVR_CLASS_40G: - return snprintf(result, lmax, TRANSVR_IF_SP_40G); - case TRANSVR_CLASS_100G: - return snprintf(result, lmax, TRANSVR_IF_SP_100G); - default: - snprintf(err_msg, sizeof(err_msg), - "Detect undefined BR case:%d", - detect_val); - goto err_qsfp_detect_if_speed_1; - } - /* Exception case: Can't verify */ - snprintf(err_msg, sizeof(err_msg), "Can not identify!"); - goto err_qsfp_detect_if_speed_1; - -err_qsfp_detect_if_speed_1: - snprintf(result, lmax, TRANSVR_UEVENT_UNKNOW); - SWPS_INFO("%s: %s :%s\n", __func__, err_msg, self->swp_name); - return ERR_TRANSVR_ABNORMAL; -} - - -int -qsfp_get_if_speed(struct transvr_obj_s *self, - char *buf_p){ - - int lmax = 16; - char tmp_result[16] = DEBUG_TRANSVR_STR_VAL; - - if (self->state != STATE_TRANSVR_CONNECTED) { - return snprintf(buf_p, lmax, "%d\n", self->state); - } - if (_qsfp_detect_if_speed(self, tmp_result) < 0) { - return snprintf(buf_p, lmax, "%d\n", ERR_TRANSVR_ABNORMAL); - } - return snprintf(buf_p, lmax, "%s\n", tmp_result); -} - - -int -_common_set_lane_map_str(struct transvr_obj_s* self, - char *result) { - int i = 0; - int tmp_val = 0; - char tmp_str[LEN_TRANSVR_L_STR] = DEBUG_TRANSVR_STR_VAL; - char err_msg[LEN_TRANSVR_L_STR] = DEBUG_TRANSVR_STR_VAL; - - memset(result, 0, LEN_TRANSVR_L_STR); - snprintf(result, LEN_TRANSVR_L_STR, "%s=", TRANSVR_UEVENT_KEY_LANE); - - for (i=0; ilane_id); i++) { - tmp_val = self->lane_id[i]; - if (tmp_val < 1) { - break; - } - if (tmp_val > 256) { - snprintf(err_msg, sizeof(err_msg), - "detect abnormal value:%d", tmp_val); - goto err_common_set_lane_map_str_1; - } - memset(tmp_str, 0, sizeof(tmp_str)); - if (i == 0) { - snprintf(tmp_str, LEN_TRANSVR_L_STR, "%d", tmp_val); - } else { - snprintf(tmp_str, LEN_TRANSVR_L_STR, ",%d", tmp_val); - } - strncat(result, tmp_str, LEN_TRANSVR_L_STR); - } - if (i == 0) { - goto err_common_set_lane_map_str_2; - } - return 0; - -err_common_set_lane_map_str_1: - SWPS_INFO("%s: %s", __func__, err_msg); -err_common_set_lane_map_str_2: - snprintf(result, LEN_TRANSVR_L_STR, "%s=%s", TRANSVR_UEVENT_KEY_LANE, TRANSVR_UEVENT_UNKNOW); - return EVENT_TRANSVR_TASK_FAIL; -} - - -int -_common_send_uevent(struct transvr_obj_s* self, - enum kobject_action u_action, - int (*detect_if_type)(struct transvr_obj_s *self, char *result), - int (*detect_if_speed)(struct transvr_obj_s *self, char *result), - int send_anyway) { - - char *uevent_envp[4]; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - char tmp_str[32] = DEBUG_TRANSVR_STR_VAL; - char tmp_str_1[32] = DEBUG_TRANSVR_STR_VAL; - char tmp_str_2[32] = DEBUG_TRANSVR_STR_VAL; - char tmp_str_3[64] = DEBUG_TRANSVR_STR_VAL; - - if (TRANSVR_UEVENT_ENABLE != 1) { - return ERR_TRANSVR_NOTSUPPORT; - } - if (_common_get_if_lane(self, tmp_str) < 0) { - snprintf(tmp_str_3, sizeof(tmp_str_3), - "%s=%s", TRANSVR_UEVENT_KEY_LANE, TRANSVR_UEVENT_UNKNOW); - } else { - snprintf(tmp_str_3, sizeof(tmp_str_3), - "%s=%s", TRANSVR_UEVENT_KEY_LANE, tmp_str); - } - switch (u_action) { - case KOBJ_ADD: - /* Detect type */ - if (detect_if_type(self, tmp_str) < 0) { - snprintf(err_msg, sizeof(err_msg), "%s", "Detect interface type fail!"); - snprintf(tmp_str_1, sizeof(tmp_str_1), "%s=%s", TRANSVR_UEVENT_KEY_IF, TRANSVR_UEVENT_UNKNOW); - snprintf(tmp_str_2, sizeof(tmp_str_2), "%s=%s", TRANSVR_UEVENT_KEY_SP, TRANSVR_UEVENT_UNKNOW); - uevent_envp[0] = tmp_str_1; - uevent_envp[1] = tmp_str_2; - uevent_envp[2] = tmp_str_3; - uevent_envp[3] = NULL; - goto private_common_send_uevent_4_fail; - } - snprintf(tmp_str_1, sizeof(tmp_str_1), "%s=%s", TRANSVR_UEVENT_KEY_IF, tmp_str); - uevent_envp[0] = tmp_str_1; - /* Detect speed */ - if (detect_if_speed(self, tmp_str) < 0) { - snprintf(err_msg, sizeof(err_msg), "%s", "Detect interface speed fail!"); - snprintf(tmp_str_2, sizeof(tmp_str_2), "%s=%s", TRANSVR_UEVENT_KEY_SP, TRANSVR_UEVENT_UNKNOW); - uevent_envp[1] = tmp_str_2; - uevent_envp[2] = tmp_str_3; - uevent_envp[3] = NULL; - goto private_common_send_uevent_4_fail; - } - snprintf(tmp_str_2, sizeof(tmp_str_2), "%s=%s", TRANSVR_UEVENT_KEY_SP, tmp_str); - uevent_envp[1] = tmp_str_2; - uevent_envp[2] = tmp_str_3; - uevent_envp[3] = NULL; - goto private_common_send_uevent_4_send; - - case KOBJ_REMOVE: - snprintf(tmp_str_1, sizeof(tmp_str_1), "%s=%s", TRANSVR_UEVENT_KEY_IF, TRANSVR_UEVENT_UNKNOW); - snprintf(tmp_str_2, sizeof(tmp_str_2), "%s=%s", TRANSVR_UEVENT_KEY_SP, TRANSVR_UEVENT_UNKNOW); - uevent_envp[0] = tmp_str_1; - uevent_envp[1] = tmp_str_2; - uevent_envp[2] = tmp_str_3; - uevent_envp[3] = NULL; - goto private_common_send_uevent_4_send; - - default: - snprintf(err_msg, sizeof(err_msg), "kobject_action:%d not support", u_action); - goto private_common_send_uevent_4_fail; - } - snprintf(err_msg, sizeof(err_msg), "%s", "Exception case"); - goto private_common_send_uevent_4_fail; - -private_common_send_uevent_4_fail: - SWPS_INFO("%s: %s :%s\n", __func__, err_msg, self->swp_name); - if (send_anyway) { - goto private_common_send_uevent_4_send; - } - return ERR_TRANSVR_UEVENT_FAIL; - -private_common_send_uevent_4_send: - return kobject_uevent_env(&(self->transvr_dev_p->kobj), - u_action, - uevent_envp); -} - -int -sfp_send_uevent(struct transvr_obj_s* self, - enum kobject_action u_action) { - int send_anyway = 1; - return _common_send_uevent(self, - u_action, - &_sfp_detect_if_type, - &_sfp_detect_if_speed, - send_anyway); -} - - -int -qsfp_send_uevent(struct transvr_obj_s* self, - enum kobject_action u_action) { - int send_anyway = 1; - return _common_send_uevent(self, - u_action, - &_qsfp_detect_if_type, - &_qsfp_detect_if_speed, - send_anyway); -} - - -int -fake_send_uevent(struct transvr_obj_s* self, - enum kobject_action u_action) { - return EVENT_TRANSVR_TASK_DONE; -} - - -int -common_fsm_4_direct_mode(struct transvr_obj_s* self, - char *caller_name){ - - int err; - int detect_result[2]; - int current_state = STATE_TRANSVR_UNEXCEPTED; - int current_type = TRANSVR_TYPE_ERROR; - - if (self->state == STATE_TRANSVR_NEW) { - if (_transvr_init_handler(self) < 0){ - return ERR_TRANSVR_INIT_FAIL; - } - } - err = detect_transvr_state(self, detect_result); - if (err < 0) { - return err; - } - /* In Direct mode, driver only detect transceiver when user call driver interface - * which on sysfs. So it only need consider the state of Transceiver. - */ - current_state = detect_result[0]; - current_type = detect_result[1]; - - switch (current_state){ - - case STATE_TRANSVR_DISCONNECTED: /* Transceiver is not plugged */ - self->state = current_state; - self->type = current_type; - return ERR_TRANSVR_UNPLUGGED; - - case STATE_TRANSVR_INIT: /* Transceiver is plugged, system not ready */ - return ERR_TRANSVR_UNINIT; - - case STATE_TRANSVR_ISOLATED: /* Transceiver is plugged, but has some issues */ - return ERR_TRNASVR_BE_ISOLATED; - - case STATE_TRANSVR_CONNECTED: /* Transceiver is plugged, system is ready */ - self->state = current_state; - self->type = current_type; - return 0; - - case STATE_TRANSVR_SWAPPED: /* Transceiver is plugged, system detect user changed */ - self->type = current_type; - if (reload_transvr_obj(self, current_type) < 0){ - self->state = STATE_TRANSVR_UNEXCEPTED; - return ERR_TRANSVR_UNEXCPT; - } - self->state = current_state; - return 0; - - case STATE_TRANSVR_UNEXCEPTED: /* Transceiver type or state is unexpected case */ - self->state = STATE_TRANSVR_UNEXCEPTED; - self->type = TRANSVR_TYPE_ERROR; - return ERR_TRANSVR_UNEXCPT; - - default: - SWPS_INFO("%s: state:%d not in define.\n", __func__, current_state); - break; - } - return ERR_TRANSVR_UNEXCPT; -} - - -static int -_is_except_happened_4_pmode(struct transvr_obj_s* self, - int new_state) { - - int event_chk = 0; - - if (self->temp == 0){ - return 0; - } - switch (new_state) { - case STATE_TRANSVR_INIT: - event_chk = EVENT_TRANSVR_EXCEP_INIT; - goto check_event_happened_4_pmode; - - case STATE_TRANSVR_CONNECTED: - event_chk = EVENT_TRANSVR_EXCEP_UP; - goto check_event_happened_4_pmode; - - case STATE_TRANSVR_DISCONNECTED: - event_chk = EVENT_TRANSVR_EXCEP_DOWN; - goto check_event_happened_4_pmode; - - case STATE_TRANSVR_SWAPPED: - event_chk = EVENT_TRANSVR_EXCEP_SWAP; - goto check_event_happened_4_pmode; - - case STATE_TRANSVR_UNEXCEPTED: - event_chk = EVENT_TRANSVR_EXCEP_EXCEP; - goto check_event_happened_4_pmode; - - case STATE_TRANSVR_ISOLATED: - event_chk = EVENT_TRANSVR_EXCEP_ISOLATED; - goto check_event_happened_4_pmode; - - default: - SWPS_INFO("%s: unexcepted case:%d\n", __func__, new_state); - break; - } - return 0; - -check_event_happened_4_pmode: - if (self->temp == event_chk){ - return 1; - } - return 0; -} - - -int -common_fsm_4_polling_mode(struct transvr_obj_s* self, - char *caller_name){ - /* [Return Value]: - * ERR_TRANSVR_UNINIT : (1) Initial not ready - * ERR_TRANSVR_UNPLUGGED : (1) Any -> Down - * ERR_TRANSVR_TASK_BUSY : (1) Wait Initial task - * ERR_TRANSVR_UNEXCPT : (1) Initial fail - * (2) Task fail - * (3) Reload fail - * ERR_TRNASVR_BE_ISOLATED : (1) Already be isolated - * OK Case (return 0) : (1) action_4_connected - * (2) action_4_nothing (initial retry) - */ - int curr_state[2]; - int old_state = self->state; - int old_type = self->type; - int new_state = STATE_TRANSVR_UNEXCEPTED; - int new_type = TRANSVR_TYPE_ERROR; - int return_val = ERR_TRANSVR_UNEXCPT; - - /* Never initial */ - if (self->state == STATE_TRANSVR_NEW) { - goto comfsm_action_4_reinit_obj; - } - /* Detect current state */ - switch (detect_transvr_state(self, curr_state)) { - case 0: - new_state = curr_state[0]; - new_type = curr_state[1]; - break; - - case ERR_TRNASVR_BE_ISOLATED: - new_state = STATE_TRANSVR_ISOLATED; - new_type = old_type; - break; - - case ERR_TRANSVR_I2C_CRASH: - goto comfsm_action_4_report_i2c_crash; - - case ERR_TRANSVR_UNEXCPT: - default: - new_state = STATE_TRANSVR_UNEXCEPTED; - new_type = old_type; - } - /* State handling */ - switch (old_state) { - case STATE_TRANSVR_INIT: /* INIT -> */ - return_val = ERR_TRANSVR_UNINIT; - goto comfsm_action_4_keep_state; - - case STATE_TRANSVR_CONNECTED: - switch (new_state) { - case STATE_TRANSVR_INIT: /* Case 1-1: UP -> INIT */ - SWPS_INFO("Detect %s is present. :1-1\n",self->swp_name); - return_val = ERR_TRANSVR_UNINIT; - goto comfsm_action_4_keep_state; - - case STATE_TRANSVR_CONNECTED: /* Case 1-2: UP -> UP */ - return_val = 0; - goto comfsm_action_4_keep_state; - - case STATE_TRANSVR_DISCONNECTED: /* Case 1-3: UP -> DOWN */ - SWPS_INFO("Detect %s is removed. :1-3\n",self->swp_name); - goto comfsm_action_4_disconnected; - - case STATE_TRANSVR_SWAPPED: /* Case 1-4: UP -> SWAP */ - SWPS_INFO("Detect %s is swapped. :1-4\n",self->swp_name); - goto comfsm_action_4_reload_obj; - - case STATE_TRANSVR_UNEXCEPTED: /* Case 1-5: UP -> UNEXPET */ - SWPS_INFO("Detect %s has error. :1-5\n",self->swp_name); - goto comfsm_action_4_unexpected; - - case STATE_TRANSVR_ISOLATED: /* Case 1-6: UP -> ISOLATE */ - SWPS_INFO("Detect %s be isolated. :1-6\n",self->swp_name); - goto comfsm_action_4_isolate_obj; - - default: - break; - } - goto comfsm_action_4_unexpected; - - case STATE_TRANSVR_DISCONNECTED: - switch (new_state) { - case STATE_TRANSVR_INIT: /* Case 2-1: DOWN -> INIT */ - SWPS_INFO("Detect %s is present. :2-1\n",self->swp_name); - return_val = ERR_TRANSVR_UNINIT; - goto comfsm_action_4_keep_state; - - case STATE_TRANSVR_CONNECTED: /* Case 2-2: DOWN -> UP */ - SWPS_INFO("Detect %s is present. :2-2\n",self->swp_name); - goto comfsm_action_4_reinit_obj; - - case STATE_TRANSVR_DISCONNECTED: /* Case 2-3: DOWN -> DOWN */ - return_val = ERR_TRANSVR_UNPLUGGED; - goto comfsm_action_4_keep_state; - - case STATE_TRANSVR_SWAPPED: /* Case 2-4: DOWN -> SWAP */ - SWPS_INFO("Detect %s is swapped. :2-4\n",self->swp_name); - goto comfsm_action_4_reload_obj; - - case STATE_TRANSVR_UNEXCEPTED: /* Case 2-5: DOWN -> UNEXPET */ - SWPS_INFO("Detect %s has error. :2-5\n",self->swp_name); - goto comfsm_action_4_unexpected; - - case STATE_TRANSVR_ISOLATED: /* Case 2-6: DOWN -> ISOLATE */ - SWPS_INFO("Detect %s be isolated. :2-6\n",self->swp_name); - goto comfsm_action_4_isolate_obj; - - default: - break; - } - goto comfsm_action_4_unexpected; - - case STATE_TRANSVR_UNEXCEPTED: - /* Filter out re-action */ - if (_is_except_happened_4_pmode(self, new_state)) { - goto comfsm_action_4_keep_state; - } - /* First action */ - switch (new_state) { - case STATE_TRANSVR_INIT: /* Case 3-1: UNEXPET -> INIT */ - SWPS_INFO("Detect %s is present. :3-1\n",self->swp_name); - self->temp = EVENT_TRANSVR_EXCEP_INIT; - return_val = ERR_TRANSVR_UNINIT; - goto comfsm_action_4_keep_state; - - case STATE_TRANSVR_CONNECTED: /* Case 3-2: UNEXPET -> UP */ - SWPS_INFO("Detect %s is present. :3-2\n",self->swp_name); - self->temp = EVENT_TRANSVR_EXCEP_UP; - goto comfsm_action_4_reload_obj; - - case STATE_TRANSVR_DISCONNECTED: /* Case 3-3: UNEXPET -> DOWN */ - SWPS_INFO("Detect %s is removed. :3-3\n",self->swp_name); - goto comfsm_action_4_disconnected; - - case STATE_TRANSVR_SWAPPED: /* Case 3-4: UNEXPET -> SWAP */ - SWPS_INFO("Detect %s is swapped. :3-4\n",self->swp_name); - self->temp = EVENT_TRANSVR_EXCEP_SWAP; - goto comfsm_action_4_reload_obj; - - case STATE_TRANSVR_UNEXCEPTED: /* Case 3-5: UNEXPET -> UNEXPET */ - self->temp = EVENT_TRANSVR_EXCEP_EXCEP; - return_val = ERR_TRANSVR_UNEXCPT; - goto comfsm_action_4_keep_state; - - case STATE_TRANSVR_ISOLATED: /* Case 3-6: UNEXPET -> ISOLATE */ - SWPS_INFO("Detect %s be isolated. :3-6\n",self->swp_name); - goto comfsm_action_4_isolate_obj; - - default: - break; - } - goto comfsm_action_4_unexpected; - - case STATE_TRANSVR_ISOLATED: - /* Filter out re-action */ - if (_is_except_happened_4_pmode(self, new_state)) { - goto comfsm_action_4_keep_state; - } - /* First action */ - switch (new_state) { - case STATE_TRANSVR_INIT: /* Case 4-1: ISOLATE -> INIT */ - SWPS_INFO("Detect %s internal error. :4-1\n",self->swp_name); - self->temp = EVENT_TRANSVR_EXCEP_INIT; - return_val = ERR_TRNASVR_BE_ISOLATED; - goto comfsm_action_4_keep_state; - - case STATE_TRANSVR_CONNECTED: /* Case 4-2: ISOLATE -> UP */ - SWPS_INFO("Detect %s internal error. :4-2\n",self->swp_name); - self->temp = EVENT_TRANSVR_EXCEP_UP; - return_val = ERR_TRNASVR_BE_ISOLATED; - goto comfsm_action_4_keep_state; - - case STATE_TRANSVR_DISCONNECTED: /* Case 4-3: ISOLATE -> DOWN */ - SWPS_INFO("Detect %s is removed. :4-3\n",self->swp_name); - goto comfsm_action_4_disconnected; - - case STATE_TRANSVR_SWAPPED: /* Case 4-4: ISOLATE -> SWAP */ - SWPS_INFO("Detect %s internal error. :4-4\n",self->swp_name); - self->temp = EVENT_TRANSVR_EXCEP_SWAP; - return_val = ERR_TRNASVR_BE_ISOLATED; - goto comfsm_action_4_keep_state; - - case STATE_TRANSVR_UNEXCEPTED: /* Case 4-5: ISOLATE -> UNEXPET */ - SWPS_INFO("Detect %s internal error. :4-5\n",self->swp_name); - self->temp = EVENT_TRANSVR_EXCEP_EXCEP; - return_val = ERR_TRNASVR_BE_ISOLATED; - goto comfsm_action_4_keep_state; - - case STATE_TRANSVR_ISOLATED: /* Case 4-6: ISOLATE -> ISOLATE */ - return_val = ERR_TRNASVR_BE_ISOLATED; - goto comfsm_action_4_keep_state; - - default: - break; - } - goto comfsm_action_4_unexpected; - - default: - break; - } - goto comfsm_action_4_unexpected; - - -comfsm_action_4_keep_state: - return return_val; - -comfsm_action_4_reinit_obj: - SWPS_DEBUG("FSM action: %s re-initial.\n", self->swp_name); - return_val = _transvr_init_handler(self); - goto comfsm_action_4_identify_event; - -comfsm_action_4_reload_obj: - SWPS_DEBUG("FSM action: %s reload.\n", self->swp_name); - self->type = new_type; - return_val = reload_transvr_obj(self, new_type); - goto comfsm_action_4_identify_event; - -comfsm_action_4_identify_event: - switch (return_val) { - case EVENT_TRANSVR_INIT_UP: - case EVENT_TRANSVR_TASK_DONE: - goto comfsm_action_4_connected; - - case EVENT_TRANSVR_INIT_DOWN: - goto comfsm_action_4_disconnected; - - case EVENT_TRANSVR_INIT_REINIT: - goto comfsm_action_4_nothing; - - case EVENT_TRANSVR_TASK_WAIT: - self->state = STATE_TRANSVR_INIT; - return ERR_TRANSVR_TASK_BUSY; - - case EVENT_TRANSVR_TASK_FAIL: - SWPS_INFO("%s detect EVENT_TRANSVR_TASK_FAIL.\n", self->swp_name); - goto comfsm_action_4_unexpected; - - case EVENT_TRANSVR_INIT_FAIL: - SWPS_INFO("%s detect EVENT_TRANSVR_INIT_FAIL.\n", self->swp_name); - goto comfsm_action_4_unexpected; - - case EVENT_TRANSVR_RELOAD_FAIL: - SWPS_INFO("%s detect EVENT_TRANSVR_RELOAD_FAIL.\n", self->swp_name); - goto comfsm_action_4_unexpected; - - case EVENT_TRANSVR_I2C_CRASH: - goto comfsm_action_4_report_i2c_crash; - - case EVENT_TRANSVR_EXCEP_ISOLATED: - goto comfsm_action_4_isolate_obj; - - default: - SWPS_INFO("%s detect undefined event:%d.\n", self->swp_name, return_val); - goto comfsm_action_4_unexpected; - } - -comfsm_action_4_nothing: - SWPS_DEBUG("FSM action: %s do nothing.\n", self->swp_name); - return 0; - -comfsm_action_4_connected: - SWPS_DEBUG("FSM action: %s Connected.\n", self->swp_name); - self->state = STATE_TRANSVR_CONNECTED; - self->type = new_type; - self->send_uevent(self, KOBJ_ADD); - _transvr_clean_retry(self); - return 0; - -comfsm_action_4_disconnected: - SWPS_DEBUG("FSM action: %s Disconnected. \n", self->swp_name); - self->state = STATE_TRANSVR_DISCONNECTED; - self->temp = EVENT_TRANSVR_TASK_DONE; - self->send_uevent(self, KOBJ_REMOVE); - _transvr_clean_retry(self); - _transvr_clean_handler(self); - return ERR_TRANSVR_UNPLUGGED; - -comfsm_action_4_report_i2c_crash: - SWPS_DEBUG("FSM action: %s report I2C crash.\n", self->swp_name); - self->state = STATE_TRANSVR_UNEXCEPTED; - return ERR_TRANSVR_I2C_CRASH; - -comfsm_action_4_isolate_obj: - SWPS_DEBUG("FSM action: %s isolate.\n", self->swp_name); - self->state = STATE_TRANSVR_ISOLATED; - return ERR_TRNASVR_BE_ISOLATED; - -comfsm_action_4_unexpected: - SWPS_INFO("FSM action: %s unexpected.\n", self->swp_name); - SWPS_INFO("Dump: :%d :0x%02x :%d :0x%02x\n", - old_state, old_type, new_state, new_type); - self->state = STATE_TRANSVR_UNEXCEPTED; - self->send_uevent(self, KOBJ_REMOVE); - _transvr_clean_handler(self); - return ERR_TRANSVR_UNEXCPT; -} - - -int -fake_fsm_4_direct_mode(struct transvr_obj_s* self, - char *caller_name){ - self->state = STATE_TRANSVR_CONNECTED; - self->type = TRANSVR_TYPE_FAKE; - return 0; -} - - -int -fake_fsm_4_polling_mode(struct transvr_obj_s* self, - char *caller_name){ - self->state = STATE_TRANSVR_CONNECTED; - self->type = TRANSVR_TYPE_FAKE; - return 0; -} - - -/* ========== Object functions for Initial procedure ========== - */ -int -transvr_init_common(struct transvr_obj_s *self){ - /* Nothing to update */ - return EVENT_TRANSVR_TASK_DONE; -} - - -int -transvr_init_fake(struct transvr_obj_s *self){ - return EVENT_TRANSVR_TASK_DONE; -} - - -int -transvr_init_sfp(struct transvr_obj_s *self){ - - int tmp_val = DEBUG_TRANSVR_INT_VAL; - int err_code = DEBUG_TRANSVR_INT_VAL; - char *err_msg = "ERR"; - - self->info = sft_detect_transvr_class(self); - /* Disable auto_config */ - if (!self->auto_config) { - return EVENT_TRANSVR_TASK_DONE; - } - /* Handle multi-rate */ - err_code = initfunc_sfp_handle_multi_rate_mode(self); - if (err_code < 0) { - err_msg = "initfunc_sfp_handle_multi_rate_mode fail!"; - goto err_transvr_init_sfp_1; - } - /* Handle 1G- RJ45 */ - tmp_val = err_code; - err_code = initfunc_sfp_handle_1g_rj45(self); - if (err_code < 0) { - err_msg = "initfunc_sfp_handle_1g_rj45 fail!"; - goto err_transvr_init_sfp_1; - } - tmp_val = (tmp_val > err_code ? tmp_val : err_code); - if (tmp_val > EVENT_TRANSVR_TASK_DONE) { - return tmp_val; - } - return EVENT_TRANSVR_TASK_DONE; - -err_transvr_init_sfp_1: - SWPS_INFO("%s: %s :%d :%s\n", - __func__, err_msg, err_code, self->swp_name); - return EVENT_TRANSVR_INIT_FAIL; -} - - -int -transvr_init_qsfp(struct transvr_obj_s *self){ - - int err = EVENT_TRANSVR_EXCEP_EXCEP; - char *emsg = "ERR"; - - self->info = qsft_detect_transvr_class(self); - if (!self->auto_config) { - return EVENT_TRANSVR_TASK_DONE; - } - err = initfunc_qsfp_handle_power_mode(self); - if (err < 0){ - emsg = "initfunc_qsfp_handle_tx_disable fail!"; - goto err_transvr_init_qsfp; - } - return EVENT_TRANSVR_TASK_DONE; - -err_transvr_init_qsfp: - SWPS_INFO("%s: %s :%d :%s\n", - __func__, emsg, err, self->swp_name); - return EVENT_TRANSVR_INIT_FAIL; -} - - -int -transvr_init_qsfp28(struct transvr_obj_s *self){ - - int tmp_val = EVENT_TRANSVR_EXCEP_EXCEP; - int err_val = EVENT_TRANSVR_EXCEP_EXCEP; - char *err_msg = "ERR"; - - /* Handle QSFP common */ - err_val = transvr_init_qsfp(self); - if (err_val < 0){ - err_msg = "transvr_init_qsfp fail!"; - goto err_transvr_init_qsfp28_1; - } - /* Disable auto_config */ - if (!self->auto_config) { - return err_val; - } - /* Handle CDR */ - tmp_val = err_val; - err_val = initfunc_qsfp28_handle_cdr(self); - if (err_val < 0){ - err_msg = "Handle CDR fail!"; - goto err_transvr_init_qsfp28_1; - } - tmp_val = (tmp_val > err_val ? tmp_val : err_val); - if (tmp_val > EVENT_TRANSVR_TASK_DONE) { - return tmp_val; - } - return EVENT_TRANSVR_TASK_DONE; - -err_transvr_init_qsfp28_1: - SWPS_INFO("%s: %s :%d :%s\n", - __func__, err_msg, err_val, self->swp_name); - return EVENT_TRANSVR_INIT_FAIL; -} - - -/* ========== Object Initial handler ========== - */ -static int -_is_transvr_valid(struct transvr_obj_s *self, - int type, - int state) { - /* [Return] - * 0 : OK, inserted - * EVENT_TRANSVR_INIT_DOWN : OK, removed - * EVENT_TRANSVR_INIT_FAIL : Outside error, type doesn't supported - * EVENT_TRANSVR_EXCEP_INIT : Internal error, state undefined - */ - switch (type) { - case TRANSVR_TYPE_SFP: - case TRANSVR_TYPE_QSFP: - case TRANSVR_TYPE_QSFP_PLUS: - case TRANSVR_TYPE_QSFP_28: - case TRANSVR_TYPE_UNPLUGGED: - case TRANSVR_TYPE_FAKE: - break; - default: - SWPS_INFO("detect undefined type:0x%02x on %s\n", - type, self->swp_name); - return EVENT_TRANSVR_INIT_FAIL; - } - switch (state) { - case STATE_TRANSVR_DISCONNECTED: - return EVENT_TRANSVR_INIT_DOWN; - case STATE_TRANSVR_INIT: - case STATE_TRANSVR_CONNECTED: - case STATE_TRANSVR_SWAPPED: - break; - default: - SWPS_INFO("detect undefined state:%d on %s\n", - state, self->swp_name); - return EVENT_TRANSVR_EXCEP_INIT; - } - return 0; -} - - -static int -_is_transvr_hw_ready(struct transvr_obj_s *self, - int type){ - /* [Return] - * EVENT_TRANSVR_TASK_DONE : Ready - * EVENT_TRANSVR_TASK_WAIT : Not ready - * EVENT_TRANSVR_INIT_FAIL : Error - */ - int addr = DEBUG_TRANSVR_INT_VAL; - int page = DEBUG_TRANSVR_INT_VAL; - int offs = DEBUG_TRANSVR_INT_VAL; - int bit = DEBUG_TRANSVR_INT_VAL; - int ready = DEBUG_TRANSVR_INT_VAL; - int err = DEBUG_TRANSVR_INT_VAL; - char *emsg = DEBUG_TRANSVR_STR_VAL; - uint8_t ab_val = DEBUG_TRANSVR_HEX_VAL; - - switch (type) { - case TRANSVR_TYPE_SFP: - addr = VAL_TRANSVR_8472_READY_ADDR; - page = VAL_TRANSVR_8472_READY_PAGE; - offs = VAL_TRANSVR_8472_READY_OFFSET; - bit = VAL_TRANSVR_8472_READY_BIT; - ready = VAL_TRANSVR_8472_READY_VALUE; - ab_val = VAL_TRANSVR_8472_READY_ABNORMAL; - break; - - case TRANSVR_TYPE_QSFP: - case TRANSVR_TYPE_QSFP_PLUS: - case TRANSVR_TYPE_QSFP_28: - addr = VAL_TRANSVR_8436_READY_ADDR; - page = VAL_TRANSVR_8436_READY_PAGE; - offs = VAL_TRANSVR_8436_READY_OFFSET; - bit = VAL_TRANSVR_8436_READY_BIT; - ready = VAL_TRANSVR_8436_READY_VALUE; - ab_val = VAL_TRANSVR_8436_READY_ABNORMAL; - break; - - case TRANSVR_TYPE_UNPLUGGED: - case TRANSVR_TYPE_FAKE: - return EVENT_TRANSVR_TASK_DONE; - - default: - emsg = "unexpected case"; - goto err_is_transvr_hw_ready; - } - /* Select target page */ - err = _common_setup_page(self, addr, page, offs, 1, 0); - if (err < 0) { - emsg = "setup page fail"; - goto err_is_transvr_hw_ready; - } - /* Check feature supported - * [Note] - * Some of transceiver/cables doesn't support "Status Indicators" - * (ex:DAC, RJ45 copper SFP ...etc). In these case, we bypass the - * step of checking Status Indicators, then state machine will take - * the following handle procedure. - */ - err = i2c_smbus_read_byte_data(self->i2c_client_p, - VAL_TRANSVR_COMID_OFFSET); - if (err < 0) { - emsg = "doesn't support Status Indicators"; - goto bypass_is_transvr_hw_ready; - } - /* Filter abnormal case */ - if (err == ab_val) { - emsg = "detect using unusual definition."; - goto bypass_is_transvr_hw_ready; - } - /* Get Status Indicators */ - err = i2c_smbus_read_byte_data(self->i2c_client_p, offs); - if (err < 0) { - emsg = "detect current value fail"; - goto err_is_transvr_hw_ready; - } - if ((err & (1<:%d\n", __func__, emsg, type); - return EVENT_TRANSVR_TASK_DONE; - -err_is_transvr_hw_ready: - SWPS_DEBUG("%s: %s :%d\n", __func__, emsg, type); - return EVENT_TRANSVR_INIT_FAIL; -} - - -static int -_is_transvr_support_ctle(struct transvr_obj_s *self) { - - switch (self->info) { - case TRANSVR_CLASS_OPTICAL_25G: - case TRANSVR_CLASS_OPTICAL_25G_AOC: - case TRANSVR_CLASS_OPTICAL_25G_SR: - case TRANSVR_CLASS_OPTICAL_25G_LR: - case TRANSVR_CLASS_OPTICAL_25G_ER: - case TRANSVR_CLASS_OPTICAL_100G: - case TRANSVR_CLASS_OPTICAL_100G_AOC: - case TRANSVR_CLASS_OPTICAL_100G_SR4: - case TRANSVR_CLASS_OPTICAL_100G_LR4: - case TRANSVR_CLASS_OPTICAL_100G_ER4: - case TRANSVR_CLASS_OPTICAL_100G_PSM4: - return 1; - default: - break; - } - return 0; -} - - -static int -_transvr_init_handler(struct transvr_obj_s *self){ - - int detect[2]; - int d_state = STATE_TRANSVR_UNEXCEPTED; - int d_type = TRANSVR_TYPE_ERROR; - int result = ERR_TRANSVR_UNINIT; - int retry = 6; /* (6+1) x 0.3 = 2.1s > spec:2.0s */ - int elimit = 63; - char emsg[64] = DEBUG_TRANSVR_STR_VAL; - - /* Clean and check callback */ - self->state = STATE_TRANSVR_INIT; - if (self->init == NULL) { - snprintf(emsg, elimit, "init() is null"); - goto initer_err_case_unexcept_0; - } - if (self->clean == NULL) { - snprintf(emsg, elimit, "clean() is null"); - goto initer_err_case_unexcept_0; - } - self->clean(self); - - /* Detect transceiver information */ - result = detect_transvr_state(self, detect); - if (result < 0) { - snprintf(emsg, elimit, "detect_transvr_state() fail"); - switch (result) { - case ERR_TRANSVR_I2C_CRASH: - goto initer_err_case_i2c_ceash; - case ERR_TRNASVR_BE_ISOLATED: - goto initer_err_case_be_isolated; - - case ERR_TRANSVR_UNEXCPT: - default: - break; - } - goto initer_err_case_retry_1; - } - d_state = detect[0]; - d_type = detect[1]; - - /* Verify transceiver type and state */ - switch (_is_transvr_valid(self, d_type, d_state)) { - case 0: - break; - case EVENT_TRANSVR_INIT_DOWN: - goto initer_ok_case_down;; - case EVENT_TRANSVR_INIT_FAIL: - snprintf(emsg, elimit, "transceiver type doesn't support"); - goto initer_err_case_alarm_to_user; - case EVENT_TRANSVR_EXCEP_INIT: - default: - goto initer_err_case_unexcept_1; - } - - /* Handle reload case */ - if (self->type != d_type){ - /* This is the protect mechanism. Normally, This case will not happen. - * When State machine detect swap event during initial, It will trigger - * reload function to ensure type correct. */ - if (_reload_transvr_obj(self, d_type) < 0){ - snprintf(emsg, elimit, "reload object fail"); - goto initer_err_case_unexcept_1; - } - } - - /* Check transceiver HW initial ready */ - switch (_is_transvr_hw_ready(self, d_type)) { - case EVENT_TRANSVR_TASK_DONE: - break; - case EVENT_TRANSVR_TASK_WAIT: - goto initer_err_case_retry_1; - case EVENT_TRANSVR_INIT_FAIL: - default: - goto initer_err_case_unexcept_1; - } - - /* Try to update all and check */ - if (self->update_all(self, 1) < 0){ - /* For some transceiver, EEPROME has lag issues during initial stage. - * In this case, we set status back to STATE_TRANSVR_NEW, than it will - * be checked in next polling cycle. */ - goto initer_err_case_retry_1; - } - - /* Execute init() call back */ - result = self->init(self); - switch (result) { - case EVENT_TRANSVR_TASK_DONE: - break; - case EVENT_TRANSVR_TASK_WAIT: - goto initer_ok_case_wait; - - default: - snprintf(emsg, elimit, "undefined init() return:%d\n", result); - goto initer_err_case_unexcept_1; - } - goto initer_ok_case_up; - - -initer_ok_case_wait: - self->dump_all(self); - return EVENT_TRANSVR_TASK_WAIT; - -initer_ok_case_up: - self->state = STATE_TRANSVR_CONNECTED; - self->temp = 0; - self->dump_all(self); - return EVENT_TRANSVR_INIT_UP; - -initer_ok_case_down: - self->temp = 0; - self->state = STATE_TRANSVR_DISCONNECTED; - return EVENT_TRANSVR_INIT_DOWN; - -initer_err_case_i2c_ceash: - SWPS_DEBUG("%s: %s :%s :I2C crash\n", - __func__, emsg, self->swp_name); - self->state = STATE_TRANSVR_UNEXCEPTED; - return EVENT_TRANSVR_I2C_CRASH; - -initer_err_case_be_isolated: - SWPS_DEBUG("%s: %s :%s :isolated\n", - __func__, emsg, self->swp_name); - self->state = STATE_TRANSVR_ISOLATED; - return EVENT_TRANSVR_EXCEP_ISOLATED; - -initer_err_case_retry_1: - SWPS_DEBUG("%s: %s :%s :retry\n", - __func__, emsg, self->swp_name); - if (_transvr_handle_retry(self, retry) == 0) { - self->state = STATE_TRANSVR_NEW; - return EVENT_TRANSVR_INIT_REINIT; - } - goto initer_err_case_alarm_to_user; - -initer_err_case_unexcept_1: - self->clean(self); -initer_err_case_unexcept_0: - self->state = STATE_TRANSVR_UNEXCEPTED; - if (_is_except_happened_4_pmode(self, d_state) && - (self->mode == TRANSVR_MODE_POLLING) ){ - SWPS_INFO("%s: %s :%s\n", __func__, emsg, self->swp_name); - SWPS_INFO("Dump: :%d :%d :%d :%d\n", - self->state, self->type, d_state, d_type); - } - return EVENT_TRANSVR_INIT_FAIL; - -initer_err_case_alarm_to_user: - SWPS_DEBUG("%s: %s :%s :alarm_to_user\n", - __func__, emsg, self->swp_name); - self->state = STATE_TRANSVR_UNEXCEPTED; - alarm_msg_2_user(self, "detected transceiver/cables not meet SFF standard"); - return EVENT_TRANSVR_INIT_FAIL; -} - - -/* ========== Object functions for Clean procedure ========== - */ -int -_transvr_clean_handler(struct transvr_obj_s *self){ - - int retval = DEBUG_TRANSVR_INT_VAL; - - if (!self->clean) { - SWPS_ERR("%s: %s clean() is NULL.\n", - __func__, self->swp_name); - return EVENT_TRANSVR_TASK_FAIL; - } - retval = self->clean(self); - if (retval != EVENT_TRANSVR_TASK_DONE){ - SWPS_ERR("%s: %s clean() fail. [ERR]:%d\n", - __func__, self->swp_name, retval); - return retval; - } - return EVENT_TRANSVR_TASK_DONE; -} - - -int -common_transvr_clean(struct transvr_obj_s *self){ - - transvr_task_free_all(self); - transvr_cache_free_all(self); - return EVENT_TRANSVR_TASK_DONE; -} - - -int -qsfp_transvr_clean(struct transvr_obj_s *self){ - - int retval; - int lpower_config = 1; - - retval = _taskfunc_qsfp_setup_power_mod(self, lpower_config); - if (retval < 0){ - SWPS_ERR("%s: Set lpmod fail! :%d\n", - __func__, retval); - return retval; - } - retval = common_transvr_clean(self); - if (retval < 0){ - SWPS_ERR("%s: common_transvr_clean fail! :%d\n", - __func__, retval); - return retval; - } - return EVENT_TRANSVR_TASK_DONE; -} - - -int -fake_transvr_clean(struct transvr_obj_s *self){ - - return EVENT_TRANSVR_TASK_DONE; -} - - -/* ========== Object functions for check and update ========== - */ -int -common_transvr_check(struct transvr_obj_s *self){ - - char fun_str[32] = "common_transvr_check"; - - if (self->mode != TRANSVR_MODE_POLLING) { - SWPS_ERR("%s: mode:%d is not TRANSVR_MODE_POLLING\n", - fun_str, self->mode); - return ERR_TRANSVR_UNEXCPT; - } - /* Trigger delay task */ - transvr_task_run_all(self); - /* Trigger state machine to check and update */ - return self->fsm_4_polling(self, fun_str); -} - - -int -fake_transvr_check(struct transvr_obj_s *self){ - return 0; -} - - -/* ========== Functions for Factory pattern ========== - */ -static int -setup_transvr_public_cb(struct transvr_obj_s *self, - int transvr_type){ - switch (transvr_type){ - case TRANSVR_TYPE_SFP: - self->get_id = common_get_id; - self->get_ext_id = common_get_ext_id; - self->get_connector = common_get_connector; - self->get_vendor_name = common_get_vendor_name; - self->get_vendor_pn = common_get_vendor_pn; - self->get_vendor_rev = common_get_vendor_rev; - self->get_vendor_sn = common_get_vendor_sn; - self->get_power_cls = unsupported_get_func; - self->get_br = common_get_br; - self->get_len_sm = sfp_get_len_sm; - self->get_len_smf = common_get_len_smf; - self->get_len_om1 = common_get_len_om1; - self->get_len_om2 = common_get_len_om2; - self->get_len_om3 = common_get_len_om3; - self->get_len_om4 = common_get_len_om4; - self->get_comp_rev = common_get_comp_rev; - self->get_comp_eth_1 = sfp_get_comp_eth_1; - self->get_comp_eth_10 = sfp_get_comp_eth_10; - self->get_comp_eth_10_40 = unsupported_get_func; - self->get_comp_extend = common_get_comp_extended; - self->get_cdr = unsupported_get_func; - self->get_rate_id = sfp_get_rate_id; - self->get_soft_rs0 = sfp_get_soft_rs0; - self->get_soft_rs1 = sfp_get_soft_rs1; - self->get_info = common_get_info; - self->get_if_type = sfp_get_if_type; - self->get_if_speed = sfp_get_if_speed; - self->get_if_lane = common_get_if_lane; - self->get_curr_temp = sfp_get_transvr_temp; - self->get_curr_vol = sfp_get_transvr_voltage; - self->get_soft_rx_los = unsupported_get_func2; - self->get_soft_tx_disable = unsupported_get_func2; - self->get_soft_tx_fault = unsupported_get_func2; - self->get_auto_tx_disable = unsupported_get_func2; - self->get_tx_bias = sfp_get_transvr_tx_bias; - self->get_tx_power = sfp_get_transvr_tx_power; - self->get_rx_power = sfp_get_transvr_rx_power; - self->get_tx_eq = sfp_get_transvr_tx_eq; - self->get_rx_am = unsupported_get_func2; - self->get_rx_em = sfp_get_transvr_rx_em; - self->get_wavelength = sfp_get_wavelength; - self->get_extphy_offset = sfp_get_1g_rj45_extphy_offset; - self->get_extphy_reg = sfp_get_1g_rj45_extphy_reg; - self->set_cdr = unsupported_set_func; - self->set_soft_rs0 = sfp_set_soft_rs0; - self->set_soft_rs1 = sfp_set_soft_rs1; - self->set_soft_tx_disable = unsupported_set_func; - self->set_auto_tx_disable = unsupported_set_func; - self->set_tx_eq = sfp_set_tx_eq; - self->set_rx_am = unsupported_set_func; - self->set_rx_em = sfp_set_rx_em; - self->set_extphy_offset = sfp_set_1g_rj45_extphy_offset; - self->set_extphy_reg = sfp_set_1g_rj45_extphy_reg; - return 0; - - case TRANSVR_TYPE_QSFP: - case TRANSVR_TYPE_QSFP_PLUS: - self->get_id = common_get_id; - self->get_ext_id = common_get_ext_id; - self->get_connector = common_get_connector; - self->get_vendor_name = common_get_vendor_name; - self->get_vendor_pn = common_get_vendor_pn; - self->get_vendor_rev = common_get_vendor_rev; - self->get_vendor_sn = common_get_vendor_sn; - self->get_power_cls = qsfp_get_power_cls; - self->get_br = common_get_br; - self->get_len_sm = unsupported_get_func; - self->get_len_smf = common_get_len_smf; - self->get_len_om1 = common_get_len_om1; - self->get_len_om2 = common_get_len_om2; - self->get_len_om3 = common_get_len_om3; - self->get_len_om4 = common_get_len_om4; - self->get_comp_rev = common_get_comp_rev; - self->get_comp_eth_1 = qsfp_get_comp_eth; - self->get_comp_eth_10 = unsupported_get_func; - self->get_comp_eth_10_40 = qsfp_get_comp_10_40; - self->get_comp_extend = common_get_comp_extended; - self->get_cdr = unsupported_get_func; - self->get_rate_id = unsupported_get_func; - self->get_soft_rs0 = unsupported_get_func; /* TBD */ - self->get_soft_rs1 = unsupported_get_func; /* TBD */ - self->get_info = common_get_info; - self->get_if_type = qsfp_get_if_type; - self->get_if_speed = qsfp_get_if_speed; - self->get_if_lane = common_get_if_lane; - self->get_curr_temp = qsfp_get_transvr_temp; - self->get_curr_vol = qsfp_get_transvr_voltage; - self->get_soft_rx_los = qsfp_get_soft_rx_los; - self->get_soft_tx_disable = qsfp_get_soft_tx_disable; - self->get_soft_tx_fault = qsfp_get_soft_tx_fault; - self->get_auto_tx_disable = qsfp_get_auto_tx_disable; - self->get_tx_bias = qsfp_get_transvr_tx_bias; - self->get_tx_power = qsfp_get_transvr_tx_power; - self->get_rx_power = qsfp_get_transvr_rx_power; - self->get_tx_eq = unsupported_get_func2; - self->get_rx_am = unsupported_get_func2; - self->get_rx_em = unsupported_get_func2; - self->get_wavelength = qsfp_get_wavelength; - self->get_extphy_offset = unsupported_get_func2; - self->get_extphy_reg = unsupported_get_func2; - self->set_cdr = unsupported_set_func; - self->set_soft_rs0 = unsupported_set_func; /* TBD */ - self->set_soft_rs1 = unsupported_set_func; /* TBD */ - self->set_soft_tx_disable = qsfp_set_soft_tx_disable; - self->set_auto_tx_disable = qsfp_set_auto_tx_disable; - self->set_tx_eq = unsupported_set_func; - self->set_rx_am = unsupported_set_func; - self->set_rx_em = unsupported_set_func; - self->set_extphy_offset = unsupported_set_func; - self->set_extphy_reg = unsupported_set_func; - return 0; - - case TRANSVR_TYPE_QSFP_28: - self->get_id = common_get_id; - self->get_ext_id = common_get_ext_id; - self->get_connector = common_get_connector; - self->get_vendor_name = common_get_vendor_name; - self->get_vendor_pn = common_get_vendor_pn; - self->get_vendor_rev = common_get_vendor_rev; - self->get_vendor_sn = common_get_vendor_sn; - self->get_power_cls = qsfp_get_power_cls; - self->get_br = common_get_br; - self->get_len_sm = unsupported_get_func; - self->get_len_smf = common_get_len_smf; - self->get_len_om1 = common_get_len_om1; - self->get_len_om2 = common_get_len_om2; - self->get_len_om3 = common_get_len_om3; - self->get_len_om4 = common_get_len_om4; - self->get_comp_rev = common_get_comp_rev; - self->get_comp_eth_1 = qsfp_get_comp_eth; - self->get_comp_eth_10 = unsupported_get_func; - self->get_comp_eth_10_40 = qsfp_get_comp_10_40; - self->get_comp_extend = common_get_comp_extended; - self->get_cdr = qsfp_get_cdr; - self->get_rate_id = unsupported_get_func; - self->get_soft_rs0 = unsupported_get_func; /* TBD */ - self->get_soft_rs1 = unsupported_get_func; /* TBD */ - self->get_info = common_get_info; - self->get_if_type = qsfp_get_if_type; - self->get_if_speed = qsfp_get_if_speed; - self->get_if_lane = common_get_if_lane; - self->get_curr_temp = qsfp_get_transvr_temp; - self->get_curr_vol = qsfp_get_transvr_voltage; - self->get_soft_rx_los = qsfp_get_soft_rx_los; - self->get_soft_tx_disable = qsfp_get_soft_tx_disable; - self->get_soft_tx_fault = qsfp_get_soft_tx_fault; - self->get_auto_tx_disable = qsfp_get_auto_tx_disable; - self->get_tx_bias = qsfp_get_transvr_tx_bias; - self->get_tx_power = qsfp_get_transvr_tx_power; - self->get_rx_power = qsfp_get_transvr_rx_power; - self->get_tx_eq = qsfp_get_transvr_tx_eq; - self->get_rx_am = qsfp_get_transvr_rx_am; - self->get_rx_em = qsfp_get_transvr_rx_em; - self->get_wavelength = qsfp_get_wavelength; - self->get_extphy_offset = unsupported_get_func2; - self->get_extphy_reg = unsupported_get_func2; - self->set_cdr = qsfp_set_cdr; - self->set_soft_rs0 = unsupported_set_func; /* TBD */ - self->set_soft_rs1 = unsupported_set_func; /* TBD */ - self->set_soft_tx_disable = qsfp_set_soft_tx_disable; - self->set_auto_tx_disable = qsfp_set_auto_tx_disable; - self->set_tx_eq = qsfp_set_tx_eq; - self->set_rx_am = qsfp_set_rx_am; - self->set_rx_em = qsfp_set_rx_em; - self->set_extphy_offset = unsupported_set_func; - self->set_extphy_reg = unsupported_set_func; - return 0; - - case TRANSVR_TYPE_FAKE: - self->get_id = fake_get_hex; - self->get_ext_id = fake_get_hex; - self->get_connector = fake_get_hex; - self->get_vendor_name = fake_get_str; - self->get_vendor_pn = fake_get_str; - self->get_vendor_rev = fake_get_str; - self->get_vendor_sn = fake_get_str; - self->get_power_cls = fake_get_int; - self->get_br = fake_get_hex; - self->get_len_sm = fake_get_int; - self->get_len_smf = fake_get_int; - self->get_len_om1 = fake_get_int; - self->get_len_om2 = fake_get_int; - self->get_len_om3 = fake_get_int; - self->get_len_om4 = fake_get_int; - self->get_comp_rev = fake_get_hex; - self->get_comp_eth_1 = fake_get_hex; - self->get_comp_eth_10 = fake_get_hex; - self->get_comp_eth_10_40 = fake_get_hex; - self->get_comp_extend = fake_get_hex; - self->get_cdr = fake_get_hex; - self->get_rate_id = fake_get_hex; - self->get_soft_rs0 = fake_get_binary; - self->get_soft_rs1 = fake_get_binary; - self->get_info = fake_get_int; - self->get_if_type = fake_get_str; - self->get_if_speed = fake_get_str; - self->get_if_lane = fake_get_str; - self->get_curr_temp = fake_get_str; - self->get_curr_vol = fake_get_str; - self->get_soft_rx_los = fake_get_str; - self->get_soft_tx_disable = fake_get_str; - self->get_soft_tx_fault = fake_get_str; - self->get_auto_tx_disable = fake_get_str; - self->get_tx_bias = fake_get_str; - self->get_tx_power = fake_get_str; - self->get_rx_power = fake_get_str; - self->get_tx_eq = fake_get_str; - self->get_rx_am = fake_get_str; - self->get_rx_em = fake_get_str; - self->get_wavelength = fake_get_str; - self->get_extphy_offset = fake_get_str; - self->get_extphy_reg = fake_get_str; - self->set_cdr = fake_set_hex; - self->set_soft_rs0 = fake_set_int; - self->set_soft_rs1 = fake_set_int; - self->set_soft_tx_disable = fake_set_int; - self->set_auto_tx_disable = fake_set_int; - self->set_tx_eq = fake_set_int; - self->set_rx_am = fake_set_int; - self->set_rx_em = fake_set_int; - self->set_extphy_offset = fake_set_hex; - self->set_extphy_reg = fake_set_hex; - return 0; - - default: - break; - } - SWPS_WARN("%s: Detect non-defined type:%d\n", __func__, transvr_type); - return ERR_TRANSVR_UNEXCPT; -} - - -static int -setup_transvr_private_cb(struct transvr_obj_s *self, - int transvr_type){ - switch (transvr_type){ - case TRANSVR_TYPE_SFP: - self->init = transvr_init_sfp; - self->clean = common_transvr_clean; - self->check = common_transvr_check; - self->update_all = _sfp_update_attr_all; - self->fsm_4_direct = common_fsm_4_direct_mode; - self->fsm_4_polling = common_fsm_4_polling_mode; - self->send_uevent = sfp_send_uevent; - self->dump_all = sfp_transvr_dump; - return 0; - - case TRANSVR_TYPE_QSFP: - case TRANSVR_TYPE_QSFP_PLUS: - self->init = transvr_init_qsfp; - self->clean = qsfp_transvr_clean; - self->check = common_transvr_check; - self->update_all = _qsfp_update_attr_all; - self->fsm_4_direct = common_fsm_4_direct_mode; - self->fsm_4_polling = common_fsm_4_polling_mode; - self->send_uevent = qsfp_send_uevent; - self->dump_all = qsfp_transvr_dump; - return 0; - - case TRANSVR_TYPE_QSFP_28: - self->init = transvr_init_qsfp28; - self->clean = qsfp_transvr_clean; - self->check = common_transvr_check; - self->update_all = _qsfp_update_attr_all; - self->fsm_4_direct = common_fsm_4_direct_mode; - self->fsm_4_polling = common_fsm_4_polling_mode; - self->send_uevent = qsfp_send_uevent; - self->dump_all = qsfp_transvr_dump; - return 0; - - case TRANSVR_TYPE_FAKE: - self->init = transvr_init_fake; - self->clean = fake_transvr_clean; - self->check = fake_transvr_check; - self->update_all = fake_transvr_update; - self->fsm_4_direct = fake_fsm_4_direct_mode; - self->fsm_4_polling = fake_fsm_4_polling_mode; - self->send_uevent = fake_send_uevent; - self->dump_all = fake_transvr_dump; - return 0; - - default: - break; - } - SWPS_WARN("%s: Detect non-defined type:%d\n", __func__, transvr_type); - return ERR_TRANSVR_UNEXCPT; -} - - -static struct eeprom_map_s * -get_eeprom_map(int transvr_type){ - - switch (transvr_type){ - case TRANSVR_TYPE_SFP: - return &eeprom_map_sfp; - case TRANSVR_TYPE_QSFP: - case TRANSVR_TYPE_QSFP_PLUS: - return &eeprom_map_qsfp; - case TRANSVR_TYPE_QSFP_28: - return &eeprom_map_qsfp28; - - default: - break; - } - SWPS_WARN("%s: Detect non-defined type:%d\n", __func__, transvr_type); - return NULL; -} - - -static int -setup_transvr_ssize_attr(char *swp_name, - struct transvr_obj_s *self, - struct eeprom_map_s *map_p, - struct ioexp_obj_s *ioexp_obj_p, - int ioexp_virt_offset, - int transvr_type, - int chipset_type, - int chan_id, - int run_mode){ - switch (run_mode){ - case TRANSVR_MODE_DIRECT: /* Direct access device mode */ - case TRANSVR_MODE_POLLING: /* Polling mode, read from cache */ - self->mode = run_mode; - break; - default: - SWPS_ERR("%s: non-defined run_mode:%d\n", - __func__, run_mode); - self->mode = DEBUG_TRANSVR_INT_VAL; - return -1; - } - self->eeprom_map_p = map_p; - self->ioexp_obj_p = ioexp_obj_p; - self->ioexp_virt_offset = ioexp_virt_offset; - self->chan_id = chan_id; - self->layout = transvr_type; - self->type = transvr_type; - self->chipset_type = chipset_type; - self->state = STATE_TRANSVR_NEW; - self->info = STATE_TRANSVR_NEW; - self->auto_tx_disable = VAL_TRANSVR_FUNCTION_DISABLE; - strncpy(self->swp_name, swp_name, 32); - mutex_init(&self->lock); - return 0; -} - - -static int -setup_transvr_dsize_attr(struct transvr_obj_s *self){ - - char *emsg = DEBUG_TRANSVR_STR_VAL; - - self->vendor_name = kzalloc((LEN_TRANSVR_M_STR * sizeof(char)), GFP_KERNEL); - if (!self->vendor_name){ - emsg = "vendor_name"; - goto err_setup_d_attr; - } - self->vendor_pn = kzalloc((LEN_TRANSVR_M_STR * sizeof(char)), GFP_KERNEL); - if (!self->vendor_pn){ - emsg = "vendor_pn"; - goto err_setup_d_attr; - } - self->vendor_rev = kzalloc((LEN_TRANSVR_M_STR * sizeof(char)), GFP_KERNEL); - if (!self->vendor_rev){ - emsg = "vendor_rev"; - goto err_setup_d_attr; - } - self->vendor_sn = kzalloc((LEN_TRANSVR_M_STR * sizeof(char)), GFP_KERNEL); - if (!self->vendor_sn){ - emsg = "vendor_sn"; - goto err_setup_d_attr; - } - self->worker_p = NULL; - return 0; - -err_setup_d_attr: - SWPS_ERR("%s: %s kzalloc fail!", __func__, emsg); - return ERR_TRANSVR_UNEXCPT; -} - - -static int -setup_i2c_client(struct transvr_obj_s *self){ - - struct i2c_adapter *adap = NULL; - struct i2c_client *client = NULL; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - - adap = i2c_get_adapter(self->chan_id); - if(!adap){ - snprintf(err_msg, sizeof(err_msg), - "can not get adap:%d", self->chan_id); - goto err_setup_i2c_client; - } - client = kzalloc(sizeof(*client), GFP_KERNEL); - if (!client){ - snprintf(err_msg, sizeof(err_msg), - "can not kzalloc client:%d", self->chan_id); - goto err_setup_i2c_client; - } - client->adapter = adap; - self->i2c_client_p = client; - self->i2c_client_p->addr = VAL_TRANSVR_COMID_ARREESS; - return 0; - -err_setup_i2c_client: - SWPS_ERR("%s: %s\n", __func__, err_msg); - return ERR_TRANSVR_UNEXCPT; -} - - -struct transvr_obj_s * -create_transvr_obj(char *swp_name, - int chan_id, - struct ioexp_obj_s *ioexp_obj_p, - int ioexp_virt_offset, - int transvr_type, - int chipset_type, - int run_mode){ - - struct transvr_obj_s *result_p; - struct eeprom_map_s *map_p; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - - /* Allocate transceiver object */ - map_p = get_eeprom_map(transvr_type); - if (!map_p){ - snprintf(err_msg, sizeof(err_msg), - "Invalid transvr_type:%d", transvr_type); - goto err_create_transvr_fail; - } - result_p = kzalloc(sizeof(*result_p), GFP_KERNEL); - if (!result_p){ - snprintf(err_msg, sizeof(err_msg), "kzalloc fail"); - goto err_create_transvr_fail; - } - /* Prepare static size attributes */ - if (setup_transvr_ssize_attr(swp_name, - result_p, - map_p, - ioexp_obj_p, - ioexp_virt_offset, - transvr_type, - chipset_type, - chan_id, - run_mode) < 0){ - goto err_create_transvr_sattr_fail; - } - /* Prepare dynamic size attributes */ - if (setup_transvr_dsize_attr(result_p) < 0){ - goto err_create_transvr_dattr_fail; - } - /* Prepare call back functions of object */ - if (setup_transvr_public_cb(result_p, transvr_type) < 0){ - goto err_create_transvr_dattr_fail; - } - /* Prepare call back functions of object */ - if (setup_transvr_private_cb(result_p, transvr_type) < 0){ - goto err_create_transvr_dattr_fail; - } - /* Prepare i2c client object */ - if (setup_i2c_client(result_p) < 0){ - goto err_create_transvr_dattr_fail; - } - return result_p; - -err_create_transvr_dattr_fail: - kfree(result_p->vendor_sn); - kfree(result_p->vendor_rev); - kfree(result_p->vendor_pn); - kfree(result_p->vendor_name); -err_create_transvr_sattr_fail: - kfree(result_p); -err_create_transvr_fail: - SWPS_ERR("%s: %s :%d :%d :%d\n", - __func__, err_msg, chan_id, ioexp_virt_offset, transvr_type); - return NULL; -} -EXPORT_SYMBOL(create_transvr_obj); - - -static int -_reload_transvr_obj(struct transvr_obj_s *self, - int new_type){ - - struct eeprom_map_s *new_map_p; - struct eeprom_map_s *old_map_p = self->eeprom_map_p; - struct i2c_client *old_i2c_p = self->i2c_client_p; - int old_type = self->type; - - /* Change state to STATE_TRANSVR_INIT */ - self->state = STATE_TRANSVR_INIT; - self->type = new_type; - /* Replace EEPROME map */ - new_map_p = get_eeprom_map(new_type); - if (!new_map_p){ - goto err_private_reload_func_1; - } - self->eeprom_map_p = new_map_p; - /* Reload i2c client */ - if (setup_i2c_client(self) < 0){ - goto err_private_reload_func_2; - } - /* Replace call back functions */ - if (setup_transvr_public_cb(self, new_type) < 0){ - goto err_private_reload_func_3; - } - if (setup_transvr_private_cb(self, new_type) < 0){ - goto err_private_reload_func_3; - } - kfree(old_i2c_p); - return 0; - -err_private_reload_func_3: - SWPS_INFO("%s: init() fail!\n", __func__); - kfree(old_i2c_p); - self->state = STATE_TRANSVR_UNEXCEPTED; - self->type = TRANSVR_TYPE_ERROR; - return -2; - -err_private_reload_func_2: - self->eeprom_map_p = old_map_p; - self->i2c_client_p = old_i2c_p; -err_private_reload_func_1: - self->state = STATE_TRANSVR_UNEXCEPTED; - self->type = old_type; - SWPS_INFO("%s fail! :0x%02x\n", __func__, new_type); - return -1; -} - - -static int -reload_transvr_obj(struct transvr_obj_s *self, - int new_type){ - - int result_val = ERR_TRANSVR_UNEXCPT; - - /* Reload phase */ - result_val = _reload_transvr_obj(self, new_type); - if (result_val < 0){ - SWPS_INFO("%s: reload phase fail! :%d\n", - __func__, result_val); - return EVENT_TRANSVR_RELOAD_FAIL; - } - /* Initial phase */ - result_val = _transvr_init_handler(self); - if (result_val < 0){ - SWPS_INFO("%s: initial phase fail! :%d\n", - __func__, result_val); - } - return result_val; -} - - -int -isolate_transvr_obj(struct transvr_obj_s *self) { - - self->state = STATE_TRANSVR_ISOLATED; - SWPS_INFO("%s: %s be isolated\n", __func__, self->swp_name); - return 0; -} -EXPORT_SYMBOL(isolate_transvr_obj); - - -int -resync_channel_tier_2(struct transvr_obj_s *self) { - - int val = TRANSVR_TYPE_ERROR; - - if (self->state == STATE_TRANSVR_ISOLATED) { - return 0; - } - self->i2c_client_p->addr = VAL_TRANSVR_COMID_ARREESS; - val = i2c_smbus_read_byte_data(self->i2c_client_p, - VAL_TRANSVR_COMID_OFFSET); - if (val < 0) { - return -1; - } - return 0; -} -EXPORT_SYMBOL(resync_channel_tier_2); - -/* For build single module using (Ex: ONL platform) */ -MODULE_LICENSE("GPL"); - - -/* ----------------------------------------- - * ToDo List - * ----------------------------------------- - * 1. _sfp_detect_class_by_feature() - * => Need check ACC use case. - * 2. _sfp_detect_class_by_1g_ethernet() - * => Need check 0.1G use case. - * 3. Loopback transceiver use case. - * => Less much data - * 4. _qsfp_detect_class_by_extend_comp() - * => Verify 100G CWDM4 - * => Verify Obsolete (assigned before 100G CWDM4 MSA required FEC) - * => Verify 100G CLR4 - * => Verify 100GE-DWDM2 - * => Verify 40G PSM4 Parallel SMF - * => Verify 100G ACC (Active Copper Cable) or 25GAUI C2M ACC. - * => Verify 100G ACC or 25GAUI C2M ACC. - * => Verify 25GBASE-LR - * => Verify 40G Active Cable (XLPPI) - */ - - - - - - - diff --git a/packages/platforms/inventec/x86-64/d5254/modules/builds/src/transceiver.h b/packages/platforms/inventec/x86-64/d5254/modules/builds/src/transceiver.h deleted file mode 100644 index f444c43c5..000000000 --- a/packages/platforms/inventec/x86-64/d5254/modules/builds/src/transceiver.h +++ /dev/null @@ -1,809 +0,0 @@ -#ifndef TRANSCEIVER_H -#define TRANSCEIVER_H - -#include - -/* advanced features control */ -#define TRANSVR_INFO_DUMP_ENABLE (1) -#define TRANSVR_INFO_CACHE_ENABLE (1) -#define TRANSVR_UEVENT_ENABLE (1) - -/* Transceiver type define */ -#define TRANSVR_TYPE_UNKNOW_1 (0x00) -#define TRANSVR_TYPE_UNKNOW_2 (0xff) -#define TRANSVR_TYPE_SFP (0x03) /* Define for SFP, SFP+, SFP28 */ -#define TRANSVR_TYPE_QSFP (0x0c) -#define TRANSVR_TYPE_QSFP_PLUS (0x0d) -#define TRANSVR_TYPE_QSFP_28 (0x11) -#define TRANSVR_TYPE_UNPLUGGED (0xfa) /* Define for ERROR handle */ -#define TRANSVR_TYPE_FAKE (0xfc) /* Define for ERROR handle */ -#define TRANSVR_TYPE_INCONSISTENT (0xfd) /* Define for ERROR handle */ -#define TRANSVR_TYPE_ERROR (0xfe) /* Define for ERROR handle */ - -/* Transceiver class for base info */ -#define TRANSVR_CLASS_UNSPECIFIED (0) -#define TRANSVR_CLASS_ERROR (-26001) -#define TRANSVR_CLASS_1G (26001) -#define TRANSVR_CLASS_10G (26011) -#define TRANSVR_CLASS_25G (26021) -#define TRANSVR_CLASS_40G (26041) -#define TRANSVR_CLASS_100G (26101) -#define TRANSVR_CLASS_NO_SPERARABLE (26901) -#define TRANSVR_CLASS_EXTEND_COMP (26902) -/* Transceiver class for Optical 1G */ -#define TRANSVR_CLASS_OPTICAL (27000) -#define TRANSVR_CLASS_OPTICAL_100 (27001) -#define TRANSVR_CLASS_OPTICAL_1G (27002) -#define TRANSVR_CLASS_OPTICAL_1G_AOC (27003) -#define TRANSVR_CLASS_OPTICAL_1G_SX (27004) -#define TRANSVR_CLASS_OPTICAL_1G_LX (27005) -#define TRANSVR_CLASS_OPTICAL_1G_EX (27006) -/* Transceiver class for Optical 10G */ -#define TRANSVR_CLASS_OPTICAL_10G (27010) -#define TRANSVR_CLASS_OPTICAL_10G_S_AOC (27011) -#define TRANSVR_CLASS_OPTICAL_10G_S_SR (27012) -#define TRANSVR_CLASS_OPTICAL_10G_S_LR (27013) -#define TRANSVR_CLASS_OPTICAL_10G_S_ER (27014) -#define TRANSVR_CLASS_OPTICAL_10G_Q_AOC (27015) -#define TRANSVR_CLASS_OPTICAL_10G_Q_SR (27016) -#define TRANSVR_CLASS_OPTICAL_10G_Q_LR (27017) -#define TRANSVR_CLASS_OPTICAL_10G_Q_ER (27018) -/* Transceiver class for Optical 25G */ -#define TRANSVR_CLASS_OPTICAL_25G (27020) -#define TRANSVR_CLASS_OPTICAL_25G_AOC (27021) -#define TRANSVR_CLASS_OPTICAL_25G_SR (27022) -#define TRANSVR_CLASS_OPTICAL_25G_LR (27023) -#define TRANSVR_CLASS_OPTICAL_25G_ER (27024) -/* Transceiver class for Optical 40G */ -#define TRANSVR_CLASS_OPTICAL_40G (27040) -#define TRANSVR_CLASS_OPTICAL_40G_AOC (27041) -#define TRANSVR_CLASS_OPTICAL_40G_SR4 (27042) -#define TRANSVR_CLASS_OPTICAL_40G_LR4 (27043) -#define TRANSVR_CLASS_OPTICAL_40G_ER4 (27044) -/* Transceiver class for Optical 100G */ -#define TRANSVR_CLASS_OPTICAL_100G (27100) -#define TRANSVR_CLASS_OPTICAL_100G_AOC (27101) -#define TRANSVR_CLASS_OPTICAL_100G_SR4 (27102) -#define TRANSVR_CLASS_OPTICAL_100G_LR4 (27103) -#define TRANSVR_CLASS_OPTICAL_100G_ER4 (27104) -#define TRANSVR_CLASS_OPTICAL_100G_PSM4 (27105) -/* Transceiver class for Copper */ -#define TRANSVR_CLASS_COPPER (28000) -#define TRANSVR_CLASS_COPPER_L1_1G (28001) -#define TRANSVR_CLASS_COPPER_L1_10G (28011) -#define TRANSVR_CLASS_COPPER_L4_10G (28012) -#define TRANSVR_CLASS_COPPER_L1_25G (28021) -#define TRANSVR_CLASS_COPPER_L4_40G (28041) -#define TRANSVR_CLASS_COPPER_L4_100G (28101) -/* Transceiver class for Base-T */ -#define TRANSVR_CLASS_BASE_T_1000 (29001) -#define TRANSVR_CLASS_BASE_T_1000_up (29002) -/* For uevent message */ -#define TRANSVR_UEVENT_KEY_IF "IF_TYPE" -#define TRANSVR_UEVENT_KEY_SP "IF_SPEED" -#define TRANSVR_UEVENT_KEY_LANE "IF_LANE" -#define TRANSVR_UEVENT_UNKNOW "UNKNOW" -#define TRANSVR_IF_KR "KR" -#define TRANSVR_IF_KR4 "KR4" -#define TRANSVR_IF_SR "SR" -#define TRANSVR_IF_SR4 "SR4" -#define TRANSVR_IF_SFI "SFI" -#define TRANSVR_IF_IF_GMII "GMII" -#define TRANSVR_IF_IF_XGMII "XGMII" -#define TRANSVR_IF_SP_100 "100" -#define TRANSVR_IF_SP_1G "1000" -#define TRANSVR_IF_SP_10G "10000" -#define TRANSVR_IF_SP_25G "25000" -#define TRANSVR_IF_SP_40G "40000" -#define TRANSVR_IF_SP_100G "100000" - -/* Transceiver mode define */ -#define TRANSVR_MODE_DIRECT (21000) -#define TRANSVR_MODE_POLLING (21001) - -/* Transceiver state define - * [Note] - * 1. State is used to represent the state of "Transceiver" and "Object". - * 2. State for different target has different means. The description as following: - */ -#define STATE_TRANSVR_CONNECTED (0) /* [Transvr]:Be plugged in. [Obj]:Link up, and work normally. */ -#define STATE_TRANSVR_NEW (-100) /* [Transvr]:(Not used) [Obj]:Create */ -#define STATE_TRANSVR_INIT (-101) /* [Transvr]:Be plugged in. [Obj]:Link up, and in initial process. */ -#define STATE_TRANSVR_ISOLATED (-102) /* [Transvr]:Be plugged in. [Obj]:Isolate, and not provide service. */ -#define STATE_TRANSVR_SWAPPED (-200) /* [Transvr]:Be plugged in. [Obj]:(Not used) */ -#define STATE_TRANSVR_DISCONNECTED (-300) /* [Transvr]:Un-plugged. [Obj]:Link down, and not provide service. */ -#define STATE_TRANSVR_UNEXCEPTED (-901) /* [Transvr]:Any [Obj]:Any, and not in expect case. */ - -/* Task state define */ -#define STATE_T_TASK_WAIT (110) -#define STATE_T_TASK_DONE (0) -#define STATE_T_TASK_INIT (-110) -#define STATE_T_TASK_FAIL (-410) - - -/* Event for task handling */ -#define EVENT_TRANSVR_TASK_WAIT (2101) -#define EVENT_TRANSVR_TASK_DONE (0) -#define EVENT_TRANSVR_TASK_FAIL (-2101) -/* Event for initial handling */ -#define EVENT_TRANSVR_INIT_UP (2201) -#define EVENT_TRANSVR_INIT_DOWN (1) -#define EVENT_TRANSVR_INIT_REINIT (-2201) -#define EVENT_TRANSVR_INIT_FAIL (-2202) -/* Event for others */ -#define EVENT_TRANSVR_RELOAD_FAIL (-2301) -#define EVENT_TRANSVR_EXCEP_INIT (-2401) -#define EVENT_TRANSVR_EXCEP_UP (-2402) -#define EVENT_TRANSVR_EXCEP_DOWN (-2403) -#define EVENT_TRANSVR_EXCEP_SWAP (-2404) -#define EVENT_TRANSVR_EXCEP_EXCEP (-2405) -#define EVENT_TRANSVR_EXCEP_ISOLATED (-2406) -#define EVENT_TRANSVR_I2C_CRASH (-2501) - -/* Transceiver error code define */ -#define ERR_TRANSVR_UNINIT (-201) -#define ERR_TRANSVR_UNPLUGGED (-202) -#define ERR_TRANSVR_ABNORMAL (-203) -#define ERR_TRANSVR_NOSTATE (-204) -#define ERR_TRANSVR_NOTSUPPORT (-205) -#define ERR_TRANSVR_BADINPUT (-206) -#define ERR_TRANSVR_UPDATE_FAIL (-207) -#define ERR_TRANSVR_RELOAD_FAIL (-208) -#define ERR_TRANSVR_INIT_FAIL (-209) -#define ERR_TRANSVR_UNDEFINED (-210) -#define ERR_TRANSVR_TASK_FAIL (-211) -#define ERR_TRANSVR_TASK_BUSY (-212) -#define ERR_TRANSVR_UEVENT_FAIL (-213) -#define ERR_TRANSVR_FUNC_DISABLE (-214) -#define ERR_TRANSVR_I2C_CRASH (-297) -#define ERR_TRNASVR_BE_ISOLATED (-298) -#define ERR_TRANSVR_UNEXCPT (-299) - -/* For debug */ -#define DEBUG_TRANSVR_INT_VAL (-99) -#define DEBUG_TRANSVR_HEX_VAL (0xfe) -#define DEBUG_TRANSVR_STR_VAL "ERROR" - -/* For system internal */ -#define VAL_TRANSVR_COMID_ARREESS (0x50) -#define VAL_TRANSVR_COMID_OFFSET (0x00) -#define VAL_TRANSVR_EXTPHY_ADDR_56 (0x56) -#define VAL_TRANSVR_8472_READY_ADDR (0x51) -#define VAL_TRANSVR_8472_READY_PAGE (-1) -#define VAL_TRANSVR_8472_READY_OFFSET (110) -#define VAL_TRANSVR_8472_READY_BIT (0) -#define VAL_TRANSVR_8472_READY_VALUE (0) -#define VAL_TRANSVR_8472_READY_ABNORMAL (0xff) -#define VAL_TRANSVR_8436_READY_ADDR (0x50) -#define VAL_TRANSVR_8436_READY_PAGE (-1) -#define VAL_TRANSVR_8436_READY_OFFSET (2) -#define VAL_TRANSVR_8436_READY_BIT (0) -#define VAL_TRANSVR_8436_READY_VALUE (0) -#define VAL_TRANSVR_8436_READY_ABNORMAL (0xff) -#define VAL_TRANSVR_8436_PWD_ADDR (0x50) -#define VAL_TRANSVR_8436_PWD_PAGE (-1) -#define VAL_TRANSVR_8436_PWD_OFFSET (123) -#define VAL_TRANSVR_PAGE_FREE (-99) -#define VAL_TRANSVR_PAGE_SELECT_OFFSET (127) -#define VAL_TRANSVR_PAGE_SELECT_DELAY (5) -#define VAL_TRANSVR_TASK_RETRY_FOREVER (-999) -#define VAL_TRANSVR_FUNCTION_DISABLE (-1) -#define STR_TRANSVR_SFP "SFP" -#define STR_TRANSVR_QSFP "QSFP" -#define STR_TRANSVR_QSFP_PLUS "QSFP+" -#define STR_TRANSVR_QSFP28 "QSFP28" - -/* For transvr buf len */ -#define LEN_TRANSVR_S_STR (16) -#define LEN_TRANSVR_M_STR (32) -#define LEN_TRANSVR_L_STR (64) - -/* Optical wavelength */ -#define VAL_OPTICAL_WAVELENGTH_SR (850) -#define VAL_OPTICAL_WAVELENGTH_LR (1310) -#define VAL_OPTICAL_WAVELENGTH_ER (1550) - -/*chip type define */ -#define CHIP_TYPE_MAGNOLIA (31001) /* Magnolia, Hudson32i, Spruce */ -#define CHIP_TYPE_REDWOOD (31002) /* Redwood, Cypress, Sequoia */ -#define CHIP_TYPE_MAPLE (31003) /* Maple */ - -#define CHIP_TYPE_LAVENDER (31011) /* Lavender */ - -/* Info from transceiver EEPROM */ -struct eeprom_map_s { - int addr_br; int page_br; int offset_br; int length_br; - int addr_cdr; int page_cdr; int offset_cdr; int length_cdr; - int addr_comp_rev; int page_comp_rev; int offset_comp_rev; int length_comp_rev; - int addr_connector; int page_connector; int offset_connector; int length_connector; - int addr_diag_type; int page_diag_type; int offset_diag_type; int length_diag_type; - int addr_extbr; int page_extbr; int offset_extbr; int length_extbr; - int addr_ext_id; int page_ext_id; int offset_ext_id; int length_ext_id; - int addr_id; int page_id; int offset_id; int length_id; - int addr_len_sm; int page_len_sm; int offset_len_sm; int length_len_sm; - int addr_len_smf; int page_len_smf; int offset_len_smf; int length_len_smf; - int addr_len_om1; int page_len_om1; int offset_len_om1; int length_len_om1; - int addr_len_om2; int page_len_om2; int offset_len_om2; int length_len_om2; - int addr_len_om3; int page_len_om3; int offset_len_om3; int length_len_om3; - int addr_len_om4; int page_len_om4; int offset_len_om4; int length_len_om4; - int addr_option; int page_option; int offset_option; int length_option; - int addr_rate_id; int page_rate_id; int offset_rate_id; int length_rate_id; - int addr_rx_am; int page_rx_am; int offset_rx_am; int length_rx_am; - int addr_rx_em; int page_rx_em; int offset_rx_em; int length_rx_em; - int addr_rx_los; int page_rx_los; int offset_rx_los; int length_rx_los; - int addr_rx_power; int page_rx_power; int offset_rx_power; int length_rx_power; - int addr_soft_rs0; int page_soft_rs0; int offset_soft_rs0; int length_soft_rs0; - int addr_soft_rs1; int page_soft_rs1; int offset_soft_rs1; int length_soft_rs1; - int addr_temp; int page_temp; int offset_temp; int length_temp; - int addr_trancomp; int page_trancomp; int offset_trancomp; int length_trancomp; - int addr_trancomp_ext; int page_trancomp_ext; int offset_trancomp_ext; int length_trancomp_ext; - int addr_tx_bias; int page_tx_bias; int offset_tx_bias; int length_tx_bias; - int addr_tx_disable; int page_tx_disable; int offset_tx_disable; int length_tx_disable; - int addr_tx_eq; int page_tx_eq; int offset_tx_eq; int length_tx_eq; - int addr_tx_fault; int page_tx_fault; int offset_tx_fault; int length_tx_fault; - int addr_tx_power; int page_tx_power; int offset_tx_power; int length_tx_power; - int addr_vendor_name; int page_vendor_name; int offset_vendor_name; int length_vendor_name; - int addr_vendor_pn; int page_vendor_pn; int offset_vendor_pn; int length_vendor_pn; - int addr_vendor_rev; int page_vendor_rev; int offset_vendor_rev; int length_vendor_rev; - int addr_vendor_sn; int page_vendor_sn; int offset_vendor_sn; int length_vendor_sn; - int addr_voltage; int page_voltage; int offset_voltage; int length_voltage; - int addr_wavelength; int page_wavelength; int offset_wavelength; int length_wavelength; -}; - - -struct transvr_worker_s; - -/* Class of transceiver object */ -struct transvr_obj_s { - - /* ========== Object private property ========== - * [Prop]: id - * [Desc]: Type of serial transceiver. - * [Note]: SFP:03h / QSFP:0Ch / QSPF+:0Dh /QSFP28:11h - */ - uint8_t id; - - /* [Prop]: connector - * [Desc]: Connector type. - * [Note]: SFP : A0h / 2 - * QSFP: 00h / 130 - */ - uint8_t connector; - - /* [Prop]: transvr_comp - * [Desc]: Transceiver compliance code. - * [Note]: SFP: SFF-8472 - * - Normal : A0h / offset 3-10 - * - Extended: A0h / offset 36 - * QSFP: SFF-8436 & SFF-8636 - * - Normal : 00h / offset 131-138 - * - Extended: 00h / offset 192 - */ - uint8_t transvr_comp[8]; - uint8_t transvr_comp_ext; - - /* [Prop]: vendor_name - * [Desc]: SFP vendor name (ASCII 16 byte char). - * [Note]: ex:FINISAR CORP. - */ - char *vendor_name; - - /* [Prop]: vendor_pn - * [Desc]: Part number provided by SFP vendor (ASCII 16 byte char). - * [Note]: - */ - char *vendor_pn; - - /* [Prop]: vendor_rev - * [Desc]: Revision level for part number provided by vendor (ASCII 4 byte char). - * [Note]: - */ - char *vendor_rev; - - /* [Prop]: vendor_sn - * [Desc]: Serial number provided by vendor (ASCII 16 byte char). - * [Note]: - */ - char *vendor_sn; - - /* [Prop]: Extended identifier - * [Desc]: SFP: - * => None - * - * QSFP: - * => This byte contained two information: - * (1) Power consumption class - * (2) CDR function present - * [Note]: Bit description as below: - * [SFP] - * None - * - * [QSFP] - * (1) Power consumption class: - * Class 1: 1.5W (Bit6-7 = 00:) - * Class 2: 2.0W (Bit6-7 = 01:) - * Class 3: 2.5W (Bit6-7 = 10:) - * Class 4: 3.5W (Bit6-7 = 11:) - * Class 5: 4.0W (Bit0-1 = 01:) - * Class 6: 4.5W (Bit0-1 = 10:) - * Class 7: 5.0W (Bit0-1 = 11:) - * (2) CDR function present: - * Bit2: 0 = No CDR in RX - * 1 = CDR present in RX - * Bit3: 0 = No CDR in TX - * 1 = CDR present in TX - */ - uint8_t ext_id; - - /* [Prop]: br - * [Desc]: Nominal bit rate, units of 100 MBits/sec. - * [Note]: SFP:03h / QSFP:0Ch / QSPF+:0Dh - * has val: 0x67 - * no val : - */ - uint8_t br; - - /* [Prop]: extbr - * [Desc]: Extended br (00h/222) - * [Desc]: Nominal bit rate per channel, units of 250 Mbps. - * Complements. Byte 140. See Table 32A. - */ - uint8_t extbr; - - /* [Prop]: len_sm - * [Desc]: Length (single mode)-(100's)m - * [Note]: This value specifies the link length that is supported by the transceiver - * while operating in compliance with the applicable standards using single mode - * fiber. The value is in units of 100 meters. A value of 255 means that the - * transceiver supports a link length greater than 25.4 km. A value of zero means - * that the transceiver does not support single mode fiber or that the length - * information must be determined from the transceiver technology. - */ - int len_sm; - - /* [Prop]: len_smf - * [Desc]: Length (single mode)-km - * [Note]: Addition to EEPROM data from original GBIC definition. This value specifies - * the link length that is supported by the transceiver while operating in - * compliance with the applicable standards using single mode fiber. The value - * is in units of kilometers. A value of 255 means that the transceiver supports - * a link length greater than 254 km. A value of zero means that the transceiver - * does not support single mode fiber or that the length information must be - * determined from the transceiver technology. - */ - int len_smf; - - /* [Prop]: len_om1 - * [Desc]: Link length supported for 62.5 um OM1 fiber, units of 10 m - * [Note]: The value is in units of 10 meters. A value of 255 means that the - * transceiver supports a link length greater than 2.54 km. A value of - * zero means that the transceiver does not support 50 micron multi-mode - * fiber or that the length information must be determined from the transceiver - * technology. - */ - int len_om1; - - /* [Prop]: len_om2 - * [Desc]: Link length supported for 50 um OM2 fiber, units of 10 m - * [Note]: The value is in units of 10 meters. A value of 255 means that the - * transceiver supports a link length greater than 2.54 km. A value of - * zero means that the transceiver does not support 50 micron multi-mode - * fiber or that the length information must be determined from the transceiver - * technology. - */ - int len_om2; - - /* [Prop]: len_om3 - * [Desc]: Length (50um, OM3) - * [Note]: This value specifies link length that is supported by the transceiver while - * operating in compliance with applicable standards using 50 micron multimode - * OM3 [2000 MHz*km] fiber. The value is in units of 10 meters. A value of 255 - * means that the transceiver supports a link length greater than 2.54 km. A value - * of zero means that the transceiver does not support 50 micron multimode fiber - * or that the length information must be determined from the transceiver technology. - */ - int len_om3; - - /* [Prop]: len_om4 - * [Desc]: Length (50um, OM4) and Length (Active Cable or Copper) - * [Note]: For optical links, this value specifies link length that is supported by the - * transceiver while operating in compliance with applicable standards using 50 micron - * multimode OM4 [4700 MHz*km] fiber. The value is in units of 10 meters. A value of - * 255 means that the transceiver supports a link length greater than 2.54 km. A value - * of zero means that the transceiver does not support 50 micron multimode fiber or that - * the length information must be determined from the transceiver codes specified in Table 5-3. - * - * For copper links, this value specifies minimum link length supported by the transceiver - * while operating in compliance with applicable standards using copper cable. For active - * cable, this value represents actual length. The value is in units of 1 meter. A value of 255 - * means the transceiver supports a link length greater than 254 meters. A value of zero means - * the transceiver does not support copper or active cables or the length information must be - * determined from transceiver technology. Further information about cable design, equalization, - * and connectors is usually required to guarantee meeting a particular length requirement. - */ - int len_om4; - - /* [Prop]: comp_rev - * [Desc]: SFF spec revision compliance - * [Note]: Indicates which revision of SFF SFF-8472 (SFP) / SFF-8636 (QSFP) the transceiver - * complies with. (unsigned integer) - */ - uint8_t comp_rev; - - /* [Prop]: CDR - * [Desc]: For transceivers with CDR capability, setting the CDR to ON engages the internal - * retiming function. Setting the CDR to OFF enables an internal bypassing mode ,which - * directs traffic around the internal CDR. (Reference: SFF-8636) - * [Note]: value=0xff: ON. - * value=0x00: OFF. - */ - uint8_t cdr; - - /* [Prop]: rate_id - * [Desc]: Soft Rate Select 0(RX). - * [Note]: 1. Addr: A0h / Offset: 13 - * 2. Value description: - * 00h Unspecified - * 01h SFF-8079 (4/2/1G Rate_Select & AS0/AS1) - * 02h SFF-8431 (8/4/2G Rx Rate_Select only) - * 03h Unspecified * - * 04h SFF-8431 (8/4/2G Tx Rate_Select only) - * 05h Unspecified * - * 06h SFF-8431 (8/4/2G Independent Rx & Tx Rate_select) - * 07h Unspecified * - * 08h FC-PI-5 (16/8/4G Rx Rate_select only) High=16G only, Low=8G/4G - * 09h Unspecified * - * 0Ah FC-PI-5 (16/8/4G Independent Rx, Tx Rate_select) High=16G only, - * Low=8G/4G - * 0Bh Unspecified * - * 0Ch FC-PI-6 (32/16/8G Independent Rx, Tx Rate_Select) - * High=32G only, Low = 16G/8G - * 0Dh Unspecified * - * 0Eh 10/8G Rx and Tx Rate_Select controlling the operation or locking - * modes of the internal signal conditioner, retimer or CDR, according - * to the logic table defined in Table 10-2, High Bit Rate - * (10G) =9.95-11.3 Gb/s; Low Bit Rate (8G) = 8.5 Gb/s. In this mode, - * the default value of bit 110.3 (Soft Rate Select RS(0), Table 9-11) - * and of bit 118.3 (Soft Rate Select RS(1), Table 10-1) is 1. - * 0Fh Unspecified * - * 10h-FFh Unallocated - */ - int rate_id; - - /* [Prop]: soft_rs0 - * [Desc]: Soft Rate Select 0(RX). - * [Note]: 1. Writing '1' selects full bandwidth operation. - * 2. This bit is "OR'd with the hard Rate_Select, AS(0) or RS(0) pin value. - * 3. Default at power up is logic zero/low - * 4. Addr: A2h / Offset: 110 / Bit: 3 - */ - uint8_t soft_rs0; - - /* [Prop]: soft_rs1 - * [Desc]: Soft Rate Select 1(TX). - * [Note]: 1. Writing '1' selects full bandwidth TX operation. - * 2. This bit is "OR'd with the hard Rate_Select, AS(1) or RS(1) pin value. - * 3. Default at power up is logic zero/low - * 4. Addr: A2h / Offset: 118 / Bit: 3 - */ - uint8_t soft_rs1; - - /* [Prop]: diag_type - * [Desc]: DIAGNOSTIC MONITORING TYPE (A0h/92) - * [Note]: Description in SFF-8472 as below: - * Bit7: Reserved for legacy diagnostic implementations. Must be '0' for compliance - * with this document. - * Bit6: Digital diagnostic monitoring implemented (described in this document). - * Must be '1' for compliance with this document. - * Bit5 Internally calibrated - * Bit4 Externally calibrated - * Bit3 Received power measurement type.0 = OMA, 1 = average power - * Bit2 Address change required see section above, "addressing modes" - * Bit1-0 Unallocated - */ - uint8_t diag_type; - - /* [Prop]: curr_temp - * [Desc]: Transceiver Current Temperature (A2h/96-97) - * [Note]: 1. Dependent on diag_type. - * 2. 96: High byte - * 3. 97: Low byte - * 4. This feature only for SFP - */ - uint8_t curr_temp[2]; - - /* [Prop]: curr_vol - * [Desc]: Transceiver Current Voltage (SFP:A2h/108-109; QSFP:00h/22-23) - * [Note]: 1. Dependent on diag_type. - * 2. 98: High byte - * 3. 99: Low byte - * 4. This feature only for SFP - * 5. Internally measured transceiver supply voltage. Represented - * as a 16 bit unsigned integer with the voltage defined as the - * full 16 bit value (0-65535) with LSB equal to 100 uVolt, - * yielding a total range of 0 to +6.55 Volts - */ - uint8_t curr_voltage[2]; - - /* [Prop]: curr_tx_bias - * [Desc]: Transceiver TX Bias Current (SFP:A2h/100-101; QSFP:00h/26-27) - * [Note]: 1. Dependent on diag_type. - * 2. 100: High byte - * 3. 101: Low byte - * 4. This feature only for SFP - * 5. Measured TX bias current in uA. Represented as a 16 bit unsigned - * integer with the current defined as the full 16 bit value (0-65535) - * with LSB equal to 2 uA, yielding a total range of 0 to 131 mA. - * Accuracy is vendor specific but must be better than 10% of the - * manufacturer's nominal value over specified operating temperature - * and voltage. - */ - uint8_t curr_tx_bias[8]; - - /* [Prop]: curr_tx_power - * [Desc]: Transceiver TX Output Power (A2h/102-103) - * [Note]: 1. Dependent on diag_type. - * 2. 102: High byte - * 3. 103: Low byte - * 4. This feature only for SFP - * 5. Measured TX output power in mW. Represented as a 16 bit unsigned - * integer with the power defined as the full 16 bit value (0-65535) - * with LSB equal to 0.1 uW, yielding a total range of 0 to 6.5535 mW - * (~ -40 to +8.2 dBm). Data is assumed to be based on measurement of - * laser monitor photodiode current. It is factory calibrated to absolute - * units using the most representative fiber output type. Accuracy is - * vendor specific but must be better than 3dB over specified temperature - * and voltage. Data is not valid when the transmitter is disabled. - */ - uint8_t curr_tx_power[8]; - - /* [Prop]: curr_tx_power - * [Desc]: Transceiver TX Output Power (A2h/102-103) - * [Note]: 1. Dependent on diag_type. - * 2. 102: High byte - * 3. 103: Low byte - * 4. This feature only for SFP - * 5. Measured RX received optical power in mW. Value can represent either - * average received power or OMA depending upon how bit 3 of byte 92 (A0h) - * is set. Represented as a 16 bit unsigned integer with the power defined - * as the full 16 bit value (0-65535) with LSB equal to 0.1 uW, yielding a - * total range of 0 to 6.5535 mW (~ -40 to +8.2 dBm). Absolute accuracy is - * dependent upon the exact optical wavelength. For the vendor specified - * wavelength, accuracy shall be better than 3dB over specified temperature - * and voltage. - */ - uint8_t curr_rx_power[8]; - - /* [Prop]: wavelength - * [Desc]: Wavelength or Copper Cable Attenuation - * [Note]: (Following is info from SFF-8636) - * For optical free side devices, this parameter identifies the nominal - * transmitter output wavelength at room temperature. This parameter is a - * 16-bit hex value with Byte 186 as high order byte and Byte 187 as low - * order byte. The laser wavelength is equal to the 16-bit integer value - * divided by 20 in nm (units of 0.05 nm). This resolution should be adequate - * to cover all relevant wavelengths yet provide enough resolution for all - * expected DWDM applications. For accurate representation of controlled - * wavelength applications, this value should represent the center of the - * guaranteed wavelength range. If the free side device is identified as - * copper cable these registers will be used to define the cable attenuation. - * An indication of 0 dB attenuation refers to the case where the attenuation - * is not known or is unavailable. - * Byte 186 (00-FFh) is the copper cable attenuation at 2.5 GHz in units of 1 dB. - * Byte 187 (00-FFh) is the copper cable attenuation at 5.0 GHz in units of 1 dB. - */ - uint8_t wavelength[2]; - - /* [Prop]: Amplitude control - * [Desc]: Amplitude control - * [Note]: QSFP28 => SFF-8636 03H Byte-238/239 - */ - uint8_t rx_am[2]; - - /* [Prop]: Emphasis control - * [Desc]: Emphasis control - * [Note]: SFP+/28 => SFF-8472 A2H Byte-115 - * QSFP28 => SFF-8636 03H Byte-236/237 - */ - uint8_t rx_em[2]; - - /* [Prop]: Soft Rx LOS - * [Desc]: Soft Rx LOS which provide by transceiver - * [Note]: (Following is info from SFF-8636) - * Byte 3: - * - Bit 0: L-Rx1 LOS - * - Bit 1: L-Rx2 LOS - * - Bit 2: L-Rx3 LOS - * - Bit 3: L-Rx4 LOS - */ - uint8_t rx_los; - - /* [Prop]: Soft Tx Disable - * [Desc]: Soft Tx Disable which provide by transceiver - * [Note]: (Following is info from SFF-8636) - * Byte 86: - * - Bit 0: Tx1 Disable - * - Bit 1: Tx2 Disable - * - Bit 2: Tx3 Disable - * - Bit 3: Tx4 Disable - */ - uint8_t tx_disable; - - /* [Prop]: Soft Tx Fault - * [Desc]: Soft Tx Fault which provide by transceiver - * [Note]: (Following is info from SFF-8636) - * Byte 86: - * - Bit 0: Tx1 Fault - * - Bit 1: Tx2 Fault - * - Bit 2: Tx3 Fault - * - Bit 3: Tx4 Fault - */ - uint8_t tx_fault; - - /* [Prop]: Transceiver EQUALIZATION - * [Desc]: Transceiver EQUALIZATION - * [Note]: SFP+/28 => SFF-8472 A2H Byte-114 - * QSFP28 => SFF-8636 03H Byte-234/235 - */ - uint8_t tx_eq[2]; - - /* [Prop]: OPTION VALUES - * [Desc]: The bits in the option field shall specify the options implemented in the transceiver. - * [Note]: SFP+/28 => SFF-8472 A0H Byte-64/65 - * QSFP+/28 => SFF-8636 00H Byte-193/195 - */ - uint8_t option[3]; - - /* [Prop]: External PHY offset - * [Desc]: It needs to be setup first if you want to access transceiver external phy. - * [Note]: This feature dependent on transceiver. - * Currently, only 1G-RJ45 transceiver supported it. - */ - uint8_t extphy_offset; - - /* ========== Object private property ========== - */ - struct device *transvr_dev_p; - struct eeprom_map_s *eeprom_map_p; - struct i2c_client *i2c_client_p; - struct ioexp_obj_s *ioexp_obj_p; - struct transvr_worker_s *worker_p; - struct mutex lock; - char swp_name[32]; - int auto_config; - int auto_tx_disable; - int chan_id; - int chipset_type; - int curr_page; - int info; - int ioexp_virt_offset; - int lane_id[8]; - int layout; - int mode; - int retry; - int state; - int temp; - int type; - - /* ========== Object public functions ========== - */ - int (*get_id)(struct transvr_obj_s *self); - int (*get_ext_id)(struct transvr_obj_s *self); - int (*get_connector)(struct transvr_obj_s *self); - int (*get_vendor_name)(struct transvr_obj_s *self, char *buf_p); - int (*get_vendor_pn)(struct transvr_obj_s *self, char *buf_p); - int (*get_vendor_rev)(struct transvr_obj_s *self, char *buf_p); - int (*get_vendor_sn)(struct transvr_obj_s *self, char *buf_p); - int (*get_power_cls)(struct transvr_obj_s *self); - int (*get_br)(struct transvr_obj_s *self); - int (*get_len_sm)(struct transvr_obj_s *self); - int (*get_len_smf)(struct transvr_obj_s *self); - int (*get_len_om1)(struct transvr_obj_s *self); - int (*get_len_om2)(struct transvr_obj_s *self); - int (*get_len_om3)(struct transvr_obj_s *self); - int (*get_len_om4)(struct transvr_obj_s *self); - int (*get_comp_rev)(struct transvr_obj_s *self); - int (*get_comp_eth_1)(struct transvr_obj_s *self); - int (*get_comp_eth_10)(struct transvr_obj_s *self); - int (*get_comp_eth_10_40)(struct transvr_obj_s *self); - int (*get_comp_extend)(struct transvr_obj_s *self); - int (*get_cdr)(struct transvr_obj_s *self); - int (*get_rate_id)(struct transvr_obj_s *self); - int (*get_soft_rs0)(struct transvr_obj_s *self); - int (*get_soft_rs1)(struct transvr_obj_s *self); - int (*get_info)(struct transvr_obj_s *self); - int (*get_if_type)(struct transvr_obj_s *self, char *buf_p); - int (*get_if_speed)(struct transvr_obj_s *self, char *buf_p); - int (*get_if_lane)(struct transvr_obj_s *self, char *buf_p); - int (*get_curr_temp)(struct transvr_obj_s *self, char *buf_p); - int (*get_curr_vol)(struct transvr_obj_s *self, char *buf_p); - int (*get_soft_rx_los)(struct transvr_obj_s *self, char *buf_p); - int (*get_soft_tx_disable)(struct transvr_obj_s *self, char *buf_p); - int (*get_soft_tx_fault)(struct transvr_obj_s *self, char *buf_p); - int (*get_auto_tx_disable)(struct transvr_obj_s *self, char *buf_p); - int (*get_tx_bias)(struct transvr_obj_s *self, char *buf_p); - int (*get_tx_power)(struct transvr_obj_s *self, char *buf_p); - int (*get_rx_power)(struct transvr_obj_s *self, char *buf_p); - int (*get_tx_eq)(struct transvr_obj_s *self, char *buf_p); - int (*get_rx_am)(struct transvr_obj_s *self, char *buf_p); - int (*get_rx_em)(struct transvr_obj_s *self, char *buf_p); - int (*get_wavelength)(struct transvr_obj_s *self, char *buf_p); - int (*get_extphy_offset)(struct transvr_obj_s *self, char *buf_p); - int (*get_extphy_reg)(struct transvr_obj_s *self, char *buf_p); - int (*set_cdr)(struct transvr_obj_s *self, int input_val); - int (*set_soft_rs0)(struct transvr_obj_s *self, int input_val); - int (*set_soft_rs1)(struct transvr_obj_s *self, int input_val); - int (*set_soft_tx_disable)(struct transvr_obj_s *self, int input_val); - int (*set_auto_tx_disable)(struct transvr_obj_s *self, int input_val); - int (*set_tx_eq)(struct transvr_obj_s *self, int input_val); - int (*set_rx_am)(struct transvr_obj_s *self, int input_val); - int (*set_rx_em)(struct transvr_obj_s *self, int input_val); - int (*set_extphy_offset)(struct transvr_obj_s *self, int input_val); - int (*set_extphy_reg)(struct transvr_obj_s *self, int input_val); - - /* ========== Object private functions ========== - */ - int (*init)(struct transvr_obj_s *self); - int (*clean)(struct transvr_obj_s *self); - int (*check)(struct transvr_obj_s *self); - int (*update_all)(struct transvr_obj_s *self, int show_err); - int (*fsm_4_direct)(struct transvr_obj_s* self, char *caller_name); - int (*fsm_4_polling)(struct transvr_obj_s* self, char *caller_name); - int (*send_uevent)(struct transvr_obj_s* self, enum kobject_action u_action); - int (*dump_all)(struct transvr_obj_s* self); -}; - - -/* For AVL Mapping */ -struct transvr_avl_s { - char vendor_name[32]; - char vendor_pn[32]; - int (*init)(struct transvr_obj_s *self); -}; - - -/* Worker for long term task of transceiver */ -struct transvr_worker_s { - /* Task Parameter */ - struct transvr_obj_s *transvr_p; - struct transvr_worker_s *next_p; - struct transvr_worker_s *pre_p; - unsigned long trigger_time; - char func_name[64]; - int retry; - int state; - - /* Task private data */ - void *p_data; - - /* Call back function */ - int (*main_task)(struct transvr_worker_s *task); - int (*post_task)(struct transvr_worker_s *task); -}; - - -struct transvr_obj_s * -create_transvr_obj(char *swp_name, - int chan_id, - struct ioexp_obj_s *ioexp_obj_p, - int ioexp_virt_offset, - int transvr_type, - int chipset_type, - int run_mode); - -void lock_transvr_obj(struct transvr_obj_s *self); -void unlock_transvr_obj(struct transvr_obj_s *self); -int isolate_transvr_obj(struct transvr_obj_s *self); - -int resync_channel_tier_2(struct transvr_obj_s *self); - -void alarm_msg_2_user(struct transvr_obj_s *self, char *emsg); - -#endif /* TRANSCEIVER_H */ - - - - - - - diff --git a/packages/platforms/inventec/x86-64/d5254/onlp/Makefile b/packages/platforms/inventec/x86-64/d5254/onlp/Makefile deleted file mode 100644 index 003238cf6..000000000 --- a/packages/platforms/inventec/x86-64/d5254/onlp/Makefile +++ /dev/null @@ -1 +0,0 @@ -include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/inventec/x86-64/d5254/onlp/PKG.yml b/packages/platforms/inventec/x86-64/d5254/onlp/PKG.yml deleted file mode 100644 index 28b620203..000000000 --- a/packages/platforms/inventec/x86-64/d5254/onlp/PKG.yml +++ /dev/null @@ -1 +0,0 @@ -!include $ONL_TEMPLATES/onlp-platform-any.yml PLATFORM=x86-64-inventec-d5254 ARCH=amd64 TOOLCHAIN=x86_64-linux-gnu diff --git a/packages/platforms/inventec/x86-64/d5254/onlp/builds/Makefile b/packages/platforms/inventec/x86-64/d5254/onlp/builds/Makefile deleted file mode 100644 index e7437cb23..000000000 --- a/packages/platforms/inventec/x86-64/d5254/onlp/builds/Makefile +++ /dev/null @@ -1,2 +0,0 @@ -FILTER=src -include $(ONL)/make/subdirs.mk diff --git a/packages/platforms/inventec/x86-64/d5254/onlp/builds/lib/.gitignore b/packages/platforms/inventec/x86-64/d5254/onlp/builds/lib/.gitignore deleted file mode 100644 index c81d16be3..000000000 --- a/packages/platforms/inventec/x86-64/d5254/onlp/builds/lib/.gitignore +++ /dev/null @@ -1 +0,0 @@ -*.mk diff --git a/packages/platforms/inventec/x86-64/d5254/onlp/builds/lib/Makefile b/packages/platforms/inventec/x86-64/d5254/onlp/builds/lib/Makefile deleted file mode 100644 index 88c276d62..000000000 --- a/packages/platforms/inventec/x86-64/d5254/onlp/builds/lib/Makefile +++ /dev/null @@ -1,2 +0,0 @@ -PLATFORM := x86-64-inventec-d5254 -include $(ONL)/packages/base/any/onlp/builds/platform/libonlp-platform.mk diff --git a/packages/platforms/inventec/x86-64/d5254/onlp/builds/onlpdump/.gitignore b/packages/platforms/inventec/x86-64/d5254/onlp/builds/onlpdump/.gitignore deleted file mode 100644 index c81d16be3..000000000 --- a/packages/platforms/inventec/x86-64/d5254/onlp/builds/onlpdump/.gitignore +++ /dev/null @@ -1 +0,0 @@ -*.mk diff --git a/packages/platforms/inventec/x86-64/d5254/onlp/builds/onlpdump/Makefile b/packages/platforms/inventec/x86-64/d5254/onlp/builds/onlpdump/Makefile deleted file mode 100644 index cef679c75..000000000 --- a/packages/platforms/inventec/x86-64/d5254/onlp/builds/onlpdump/Makefile +++ /dev/null @@ -1,2 +0,0 @@ -PLATFORM := x86-64-inventec-d5254 -include $(ONL)/packages/base/any/onlp/builds/platform/onlps.mk diff --git a/packages/platforms/inventec/x86-64/d5254/onlp/builds/x86_64_inventec_d5254/.gitignore b/packages/platforms/inventec/x86-64/d5254/onlp/builds/x86_64_inventec_d5254/.gitignore deleted file mode 100644 index c81d16be3..000000000 --- a/packages/platforms/inventec/x86-64/d5254/onlp/builds/x86_64_inventec_d5254/.gitignore +++ /dev/null @@ -1 +0,0 @@ -*.mk diff --git a/packages/platforms/inventec/x86-64/d5254/onlp/builds/x86_64_inventec_d5254/.module b/packages/platforms/inventec/x86-64/d5254/onlp/builds/x86_64_inventec_d5254/.module deleted file mode 100644 index 1a2708975..000000000 --- a/packages/platforms/inventec/x86-64/d5254/onlp/builds/x86_64_inventec_d5254/.module +++ /dev/null @@ -1 +0,0 @@ -name: x86_64_inventec_d5254 diff --git a/packages/platforms/inventec/x86-64/d5254/onlp/builds/x86_64_inventec_d5254/Makefile b/packages/platforms/inventec/x86-64/d5254/onlp/builds/x86_64_inventec_d5254/Makefile deleted file mode 100644 index df3e6cea2..000000000 --- a/packages/platforms/inventec/x86-64/d5254/onlp/builds/x86_64_inventec_d5254/Makefile +++ /dev/null @@ -1,9 +0,0 @@ -############################################################################### -# -# -# -############################################################################### -include $(ONL)/make/config.mk -MODULE := x86_64_inventec_d5254 -AUTOMODULE := x86_64_inventec_d5254 -include $(BUILDER)/definemodule.mk diff --git a/packages/platforms/inventec/x86-64/d5254/onlp/builds/x86_64_inventec_d5254/module/auto/make.mk b/packages/platforms/inventec/x86-64/d5254/onlp/builds/x86_64_inventec_d5254/module/auto/make.mk deleted file mode 100644 index 61b30fb7e..000000000 --- a/packages/platforms/inventec/x86-64/d5254/onlp/builds/x86_64_inventec_d5254/module/auto/make.mk +++ /dev/null @@ -1,9 +0,0 @@ -############################################################################### -# -# x86_64_inventec_d5254 Autogeneration -# -############################################################################### -x86_64_inventec_d5254_AUTO_DEFS := module/auto/x86_64_inventec_d5254.yml -x86_64_inventec_d5254_AUTO_DIRS := module/inc/x86_64_inventec_d5254 module/src -include $(BUILDER)/auto.mk - diff --git a/packages/platforms/inventec/x86-64/d5254/onlp/builds/x86_64_inventec_d5254/module/auto/x86_64_inventec_d5254.yml b/packages/platforms/inventec/x86-64/d5254/onlp/builds/x86_64_inventec_d5254/module/auto/x86_64_inventec_d5254.yml deleted file mode 100644 index 2c59d3990..000000000 --- a/packages/platforms/inventec/x86-64/d5254/onlp/builds/x86_64_inventec_d5254/module/auto/x86_64_inventec_d5254.yml +++ /dev/null @@ -1,50 +0,0 @@ -############################################################################### -# -# x86_64_inventec_d5254 Autogeneration Definitions. -# -############################################################################### - -cdefs: &cdefs -- X86_64_INVENTEC_D5254_CONFIG_INCLUDE_LOGGING: - doc: "Include or exclude logging." - default: 1 -- X86_64_INVENTEC_D5254_CONFIG_LOG_OPTIONS_DEFAULT: - doc: "Default enabled log options." - default: AIM_LOG_OPTIONS_DEFAULT -- X86_64_INVENTEC_D5254_CONFIG_LOG_BITS_DEFAULT: - doc: "Default enabled log bits." - default: AIM_LOG_BITS_DEFAULT -- X86_64_INVENTEC_D5254_CONFIG_LOG_CUSTOM_BITS_DEFAULT: - doc: "Default enabled custom log bits." - default: 0 -- X86_64_INVENTEC_D5254_CONFIG_PORTING_STDLIB: - doc: "Default all porting macros to use the C standard libraries." - default: 1 -- X86_64_INVENTEC_D5254_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS: - doc: "Include standard library headers for stdlib porting macros." - default: X86_64_INVENTEC_D5254_CONFIG_PORTING_STDLIB -- X86_64_INVENTEC_D5254_CONFIG_INCLUDE_UCLI: - doc: "Include generic uCli support." - default: 0 -- X86_64_INVENTEC_D5254_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_D5254_CONFIG_HEADER: - defs: *cdefs - basename: x86_64_inventec_d5254_config - - portingmacro: - x86_64_inventec_d5254: - macros: - - malloc - - free - - memset - - memcpy - - - vsnprintf - - snprintf - - strlen diff --git a/packages/platforms/inventec/x86-64/d5254/onlp/builds/x86_64_inventec_d5254/module/inc/x86_64_inventec_d5254/x86_64_inventec_d5254.x b/packages/platforms/inventec/x86-64/d5254/onlp/builds/x86_64_inventec_d5254/module/inc/x86_64_inventec_d5254/x86_64_inventec_d5254.x deleted file mode 100644 index 830f6b31c..000000000 --- a/packages/platforms/inventec/x86-64/d5254/onlp/builds/x86_64_inventec_d5254/module/inc/x86_64_inventec_d5254/x86_64_inventec_d5254.x +++ /dev/null @@ -1,14 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#include - -/* <--auto.start.xmacro(ALL).define> */ -/* */ - -/* <--auto.start.xenum(ALL).define> */ -/* */ - - diff --git a/packages/platforms/inventec/x86-64/d5254/onlp/builds/x86_64_inventec_d5254/module/inc/x86_64_inventec_d5254/x86_64_inventec_d5254_config.h b/packages/platforms/inventec/x86-64/d5254/onlp/builds/x86_64_inventec_d5254/module/inc/x86_64_inventec_d5254/x86_64_inventec_d5254_config.h deleted file mode 100644 index 041e76a2c..000000000 --- a/packages/platforms/inventec/x86-64/d5254/onlp/builds/x86_64_inventec_d5254/module/inc/x86_64_inventec_d5254/x86_64_inventec_d5254_config.h +++ /dev/null @@ -1,137 +0,0 @@ -/**************************************************************************//** - * - * @file - * @brief x86_64_inventec_d5254 Configuration Header - * - * @addtogroup x86_64_inventec_d5254-config - * @{ - * - *****************************************************************************/ -#ifndef __X86_64_INVENTEC_D5254_CONFIG_H__ -#define __X86_64_INVENTEC_D5254_CONFIG_H__ - -#ifdef GLOBAL_INCLUDE_CUSTOM_CONFIG -#include -#endif -#ifdef x86_64_inventec_d5254_INCLUDE_CUSTOM_CONFIG -#include -#endif - -/* */ -#include -/** - * X86_64_INVENTEC_D5254_CONFIG_INCLUDE_LOGGING - * - * Include or exclude logging. */ - - -#ifndef X86_64_INVENTEC_D5254_CONFIG_INCLUDE_LOGGING -#define X86_64_INVENTEC_D5254_CONFIG_INCLUDE_LOGGING 1 -#endif - -/** - * X86_64_INVENTEC_D5254_CONFIG_LOG_OPTIONS_DEFAULT - * - * Default enabled log options. */ - - -#ifndef X86_64_INVENTEC_D5254_CONFIG_LOG_OPTIONS_DEFAULT -#define X86_64_INVENTEC_D5254_CONFIG_LOG_OPTIONS_DEFAULT AIM_LOG_OPTIONS_DEFAULT -#endif - -/** - * X86_64_INVENTEC_D5254_CONFIG_LOG_BITS_DEFAULT - * - * Default enabled log bits. */ - - -#ifndef X86_64_INVENTEC_D5254_CONFIG_LOG_BITS_DEFAULT -#define X86_64_INVENTEC_D5254_CONFIG_LOG_BITS_DEFAULT AIM_LOG_BITS_DEFAULT -#endif - -/** - * X86_64_INVENTEC_D5254_CONFIG_LOG_CUSTOM_BITS_DEFAULT - * - * Default enabled custom log bits. */ - - -#ifndef X86_64_INVENTEC_D5254_CONFIG_LOG_CUSTOM_BITS_DEFAULT -#define X86_64_INVENTEC_D5254_CONFIG_LOG_CUSTOM_BITS_DEFAULT 0 -#endif - -/** - * X86_64_INVENTEC_D5254_CONFIG_PORTING_STDLIB - * - * Default all porting macros to use the C standard libraries. */ - - -#ifndef X86_64_INVENTEC_D5254_CONFIG_PORTING_STDLIB -#define X86_64_INVENTEC_D5254_CONFIG_PORTING_STDLIB 1 -#endif - -/** - * X86_64_INVENTEC_D5254_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS - * - * Include standard library headers for stdlib porting macros. */ - - -#ifndef X86_64_INVENTEC_D5254_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS -#define X86_64_INVENTEC_D5254_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS X86_64_INVENTEC_D5254_CONFIG_PORTING_STDLIB -#endif - -/** - * X86_64_INVENTEC_D5254_CONFIG_INCLUDE_UCLI - * - * Include generic uCli support. */ - - -#ifndef X86_64_INVENTEC_D5254_CONFIG_INCLUDE_UCLI -#define X86_64_INVENTEC_D5254_CONFIG_INCLUDE_UCLI 0 -#endif - -/** - * X86_64_INVENTEC_D5254_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION - * - * Assume chassis fan direction is the same as the PSU fan direction. */ - - -#ifndef X86_64_INVENTEC_D5254_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION -#define X86_64_INVENTEC_D5254_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION 0 -#endif - - - -/** - * All compile time options can be queried or displayed - */ - -/** Configuration settings structure. */ -typedef struct x86_64_inventec_d5254_config_settings_s { - /** name */ - const char* name; - /** value */ - const char* value; -} x86_64_inventec_d5254_config_settings_t; - -/** Configuration settings table. */ -/** x86_64_inventec_d5254_config_settings table. */ -extern x86_64_inventec_d5254_config_settings_t x86_64_inventec_d5254_config_settings[]; - -/** - * @brief Lookup a configuration setting. - * @param setting The name of the configuration option to lookup. - */ -const char* x86_64_inventec_d5254_config_lookup(const char* setting); - -/** - * @brief Show the compile-time configuration. - * @param pvs The output stream. - */ -int x86_64_inventec_d5254_config_show(struct aim_pvs_s* pvs); - -/* */ - -#include "x86_64_inventec_d5254_porting.h" - -#endif /* __X86_64_INVENTEC_D5254_CONFIG_H__ */ -/* @} */ diff --git a/packages/platforms/inventec/x86-64/d5254/onlp/builds/x86_64_inventec_d5254/module/inc/x86_64_inventec_d5254/x86_64_inventec_d5254_dox.h b/packages/platforms/inventec/x86-64/d5254/onlp/builds/x86_64_inventec_d5254/module/inc/x86_64_inventec_d5254/x86_64_inventec_d5254_dox.h deleted file mode 100644 index c98285366..000000000 --- a/packages/platforms/inventec/x86-64/d5254/onlp/builds/x86_64_inventec_d5254/module/inc/x86_64_inventec_d5254/x86_64_inventec_d5254_dox.h +++ /dev/null @@ -1,26 +0,0 @@ -/**************************************************************************//** - * - * x86_64_inventec_d5254 Doxygen Header - * - *****************************************************************************/ -#ifndef __x86_64_inventec_d5254_DOX_H__ -#define __x86_64_inventec_d5254_DOX_H__ - -/** - * @defgroup x86_64_inventec_d5254 x86_64_inventec_d5254 - x86_64_inventec_d5254 Description - * - -The documentation overview for this module should go here. - - * - * @{ - * - * @defgroup x86_64_inventec_d5254-x86_64_inventec_d5254 Public Interface - * @defgroup x86_64_inventec_d5254-config Compile Time Configuration - * @defgroup x86_64_inventec_d5254-porting Porting Macros - * - * @} - * - */ - -#endif /* __x86_64_inventec_d5254_DOX_H__ */ diff --git a/packages/platforms/inventec/x86-64/d5254/onlp/builds/x86_64_inventec_d5254/module/inc/x86_64_inventec_d5254/x86_64_inventec_d5254_porting.h b/packages/platforms/inventec/x86-64/d5254/onlp/builds/x86_64_inventec_d5254/module/inc/x86_64_inventec_d5254/x86_64_inventec_d5254_porting.h deleted file mode 100644 index 57e847a03..000000000 --- a/packages/platforms/inventec/x86-64/d5254/onlp/builds/x86_64_inventec_d5254/module/inc/x86_64_inventec_d5254/x86_64_inventec_d5254_porting.h +++ /dev/null @@ -1,97 +0,0 @@ -/**************************************************************************//** - * - * @file - * @brief x86_64_inventec_d5254 Porting Macros. - * - * @addtogroup x86_64_inventec_d5254-porting - * @{ - * - *****************************************************************************/ -#ifndef __x86_64_inventec_d5254_PORTING_H__ -#define __x86_64_inventec_d5254_PORTING_H__ - - -/* */ -#if X86_64_INVENTEC_D5254_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS == 1 -#include -#include -#include -#include -#include -#endif - -#ifndef X86_64_INVENTEC_D5254_MALLOC - #if defined(GLOBAL_MALLOC) - #define X86_64_INVENTEC_D5254_MALLOC GLOBAL_MALLOC - #elif X86_64_INVENTEC_D5254_CONFIG_PORTING_STDLIB == 1 - #define X86_64_INVENTEC_D5254_MALLOC malloc - #else - #error The macro X86_64_INVENTEC_D5254_MALLOC is required but cannot be defined. - #endif -#endif - -#ifndef X86_64_INVENTEC_D5254_FREE - #if defined(GLOBAL_FREE) - #define X86_64_INVENTEC_D5254_FREE GLOBAL_FREE - #elif X86_64_INVENTEC_D5254_CONFIG_PORTING_STDLIB == 1 - #define X86_64_INVENTEC_D5254_FREE free - #else - #error The macro X86_64_INVENTEC_D5254_FREE is required but cannot be defined. - #endif -#endif - -#ifndef X86_64_INVENTEC_D5254_MEMSET - #if defined(GLOBAL_MEMSET) - #define X86_64_INVENTEC_D5254_MEMSET GLOBAL_MEMSET - #elif X86_64_INVENTEC_D5254_CONFIG_PORTING_STDLIB == 1 - #define X86_64_INVENTEC_D5254_MEMSET memset - #else - #error The macro X86_64_INVENTEC_D5254_MEMSET is required but cannot be defined. - #endif -#endif - -#ifndef X86_64_INVENTEC_D5254_MEMCPY - #if defined(GLOBAL_MEMCPY) - #define X86_64_INVENTEC_D5254_MEMCPY GLOBAL_MEMCPY - #elif X86_64_INVENTEC_D5254_CONFIG_PORTING_STDLIB == 1 - #define X86_64_INVENTEC_D5254_MEMCPY memcpy - #else - #error The macro X86_64_INVENTEC_D5254_MEMCPY is required but cannot be defined. - #endif -#endif - -#ifndef X86_64_INVENTEC_D5254_VSNPRINTF - #if defined(GLOBAL_VSNPRINTF) - #define X86_64_INVENTEC_D5254_VSNPRINTF GLOBAL_VSNPRINTF - #elif X86_64_INVENTEC_D5254_CONFIG_PORTING_STDLIB == 1 - #define X86_64_INVENTEC_D5254_VSNPRINTF vsnprintf - #else - #error The macro X86_64_INVENTEC_D5254_VSNPRINTF is required but cannot be defined. - #endif -#endif - -#ifndef X86_64_INVENTEC_D5254_SNPRINTF - #if defined(GLOBAL_SNPRINTF) - #define X86_64_INVENTEC_D5254_SNPRINTF GLOBAL_SNPRINTF - #elif X86_64_INVENTEC_D5254_CONFIG_PORTING_STDLIB == 1 - #define X86_64_INVENTEC_D5254_SNPRINTF snprintf - #else - #error The macro X86_64_INVENTEC_D5254_SNPRINTF is required but cannot be defined. - #endif -#endif - -#ifndef X86_64_INVENTEC_D5254_STRLEN - #if defined(GLOBAL_STRLEN) - #define X86_64_INVENTEC_D5254_STRLEN GLOBAL_STRLEN - #elif X86_64_INVENTEC_D5254_CONFIG_PORTING_STDLIB == 1 - #define X86_64_INVENTEC_D5254_STRLEN strlen - #else - #error The macro X86_64_INVENTEC_D5254_STRLEN is required but cannot be defined. - #endif -#endif - -/* */ - - -#endif /* __x86_64_inventec_d5254_PORTING_H__ */ -/* @} */ diff --git a/packages/platforms/inventec/x86-64/d5254/onlp/builds/x86_64_inventec_d5254/module/make.mk b/packages/platforms/inventec/x86-64/d5254/onlp/builds/x86_64_inventec_d5254/module/make.mk deleted file mode 100644 index dc6e8146a..000000000 --- a/packages/platforms/inventec/x86-64/d5254/onlp/builds/x86_64_inventec_d5254/module/make.mk +++ /dev/null @@ -1,11 +0,0 @@ -############################################################################### -# -# -# -############################################################################### -THIS_DIR := $(dir $(lastword $(MAKEFILE_LIST))) -x86_64_inventec_d5254_INCLUDES := -I $(THIS_DIR)inc -x86_64_inventec_d5254_INTERNAL_INCLUDES := -I $(THIS_DIR)src -x86_64_inventec_d5254_DEPENDMODULE_ENTRIES := init:x86_64_inventec_d5254 ucli:x86_64_inventec_d5254 - -x86_64_inventec_d5254_CFLAGS := -Wno-restrict -Wno-format-truncation diff --git a/packages/platforms/inventec/x86-64/d5254/onlp/builds/x86_64_inventec_d5254/module/src/Makefile b/packages/platforms/inventec/x86-64/d5254/onlp/builds/x86_64_inventec_d5254/module/src/Makefile deleted file mode 100644 index 5096c739a..000000000 --- a/packages/platforms/inventec/x86-64/d5254/onlp/builds/x86_64_inventec_d5254/module/src/Makefile +++ /dev/null @@ -1,9 +0,0 @@ -############################################################################### -# -# Local source generation targets. -# -############################################################################### - -ucli: - @../../../../tools/uclihandlers.py x86_64_inventec_d5254_ucli.c - diff --git a/packages/platforms/inventec/x86-64/d5254/onlp/builds/x86_64_inventec_d5254/module/src/debug.c b/packages/platforms/inventec/x86-64/d5254/onlp/builds/x86_64_inventec_d5254/module/src/debug.c deleted file mode 100644 index 8cc872e6e..000000000 --- a/packages/platforms/inventec/x86-64/d5254/onlp/builds/x86_64_inventec_d5254/module/src/debug.c +++ /dev/null @@ -1,45 +0,0 @@ -#include "x86_64_inventec_d5254_int.h" - -#if X86_64_INVENTEC_D5254_CONFIG_INCLUDE_DEBUG == 1 - -#include - -static char help__[] = - "Usage: debug [options]\n" - " -c CPLD Versions\n" - " -h Help\n" - ; - -int -x86_64_inventec_d5254_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/d5254/onlp/builds/x86_64_inventec_d5254/module/src/fani.c b/packages/platforms/inventec/x86-64/d5254/onlp/builds/x86_64_inventec_d5254/module/src/fani.c deleted file mode 100644 index 68dc6548b..000000000 --- a/packages/platforms/inventec/x86-64/d5254/onlp/builds/x86_64_inventec_d5254/module/src/fani.c +++ /dev/null @@ -1,409 +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 -#include -#include -#include -#include "platform_lib.h" - -#define VALIDATE(_id) \ - do { \ - if(!ONLP_OID_IS_FAN(_id)) { \ - return ONLP_STATUS_E_INVALID; \ - } \ - } while(0) - - -#define SLOW_PWM 100 -#define NORMAL_PWM 175 -#define MAX_PWM 255 -#define STEP_SIZE 100 -#define FAN_ON_MAIN_BOARD_COUNT 5 -#define LOCAL_ID_TO_PSU_ID(id) (id-FAN_ON_MAIN_BOARD_COUNT) - -#define FAN_CAPS ONLP_FAN_CAPS_GET_RPM|ONLP_FAN_CAPS_GET_PERCENTAGE - -static int _fani_status_failed_check(uint32_t* status, int local_id); -static int _fani_status_present_check(uint32_t* status, int local_id); - -#define MAKE_FAN_INFO_NODE_ON_FAN_BOARD(id) \ - { \ - { \ - ONLP_FAN_ID_CREATE(ONLP_FAN_##id), "Fan "#id, 0, \ - { \ - ONLP_LED_ID_CREATE(ONLP_LED_FAN##id), \ - } \ - }, \ - 0, 0 \ - } - -#define MAKE_FAN_INFO_NODE_ON_PSU(psu_id) \ - { \ - { ONLP_FAN_ID_CREATE(ONLP_FAN_PSU_##psu_id), "PSU-"#psu_id" Fan", ONLP_PSU_ID_CREATE(ONLP_PSU_##psu_id)}, \ - 0, 0 \ - } - - -/* Static values */ -static onlp_fan_info_t __onlp_fan_info[ONLP_FAN_COUNT] = { - 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), - MAKE_FAN_INFO_NODE_ON_PSU(2), -}; - - -/* - * 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 rv = ONLP_STATUS_OK; - int local_id; - int lrpm, rrpm, pwm, psu_id; - VALIDATE(id); - pwm = 0; - - local_id = ONLP_OID_ID_GET(id); - if(local_id >= ONLP_FAN_MAX) { - rv = ONLP_STATUS_E_INVALID; - } - if(rv ==ONLP_STATUS_OK) { - *info = __onlp_fan_info[LOCAL_ID_TO_INFO_IDX(local_id)]; - rv = onlp_fani_status_get(id, &info->status); - } - - if(rv == ONLP_STATUS_OK) { - if(info->status & ONLP_FAN_STATUS_PRESENT) { - switch(local_id) { - case ONLP_FAN_1: - case ONLP_FAN_2: - case ONLP_FAN_3: - case ONLP_FAN_4: - case ONLP_FAN_5: - if(info->status & ONLP_FAN_STATUS_F2B) { - info->caps = FAN_CAPS|ONLP_FAN_CAPS_F2B; - } else if(info->status & ONLP_FAN_STATUS_B2F) { - info->caps = FAN_CAPS|ONLP_FAN_CAPS_B2F; - } else { - info->caps = FAN_CAPS; - } - - rv = onlp_file_read_int(&lrpm, INV_HWMON_PREFIX"fan%d_input", local_id*2-1); - if(rv != ONLP_STATUS_OK ) { return rv; } - rv = onlp_file_read_int(&rrpm, INV_HWMON_PREFIX"fan%d_input", local_id*2); - if(rv != ONLP_STATUS_OK ) { return rv; } - rv = onlp_file_read_int(&pwm,INV_HWMON_PREFIX"pwm%d", local_id); - if(rv != ONLP_STATUS_OK ) { return rv; } - - if(lrpm <=0 && rrpm <=0) { - info->rpm = 0; - } else if(lrpm <= 0) { - info->rpm = rrpm; - } else if(rrpm <= 0) { - info->rpm = lrpm; - } else { - info->rpm = (lrpm+rrpm)/2; - } - - break; - case ONLP_FAN_PSU_1: - case ONLP_FAN_PSU_2: - info->caps = FAN_CAPS|ONLP_FAN_CAPS_F2B; - psu_id = LOCAL_ID_TO_PSU_ID(local_id); - rv = onlp_file_read_int(&info->rpm,INV_HWMON_PREFIX"rpm_psu%d", psu_id); - if(rv != ONLP_STATUS_OK) { return rv; } - rv = onlp_file_read_int(&pwm, INV_HWMON_PREFIX"pwm_psu%d", psu_id); - if(rv != ONLP_STATUS_OK) { return rv; } - break; - default: - rv = ONLP_STATUS_E_INVALID; - break; - } - if(rv == ONLP_STATUS_OK) { - if(info->rpm <= 0) { - info->mode = ONLP_FAN_MODE_OFF; - info->percentage = 0; - } else { - info->percentage = (pwm*100)/MAX_PWM; - if(pwm < SLOW_PWM) { - info->mode = ONLP_FAN_MODE_SLOW; - } else if(pwm < NORMAL_PWM) { - info->mode = ONLP_FAN_MODE_NORMAL; - } else if(pwm < MAX_PWM) { - info->mode = ONLP_FAN_MODE_FAST; - } else { - info->mode = ONLP_FAN_MODE_MAX; - } - } - } - } else { - info->caps = 0; - info->rpm = 0; - info->percentage = 0; - info->mode = ONLP_FAN_MODE_OFF; - } - snprintf(info->model, ONLP_CONFIG_INFO_STR_MAX, "NA"); - snprintf(info->serial, ONLP_CONFIG_INFO_STR_MAX, "NA"); - } - return rv; -} -static int _fani_status_failed_check(uint32_t* status, int local_id) -{ - int rv; - int lrpm, rrpm, rpm, pwm, psu_id; - switch(local_id) { - case ONLP_FAN_1: - case ONLP_FAN_2: - case ONLP_FAN_3: - case ONLP_FAN_4: - case ONLP_FAN_5: - rv = onlp_file_read_int(&lrpm, INV_HWMON_PREFIX"fan%d_input", local_id*2-1); - if(rv != ONLP_STATUS_OK ) { return rv; } - rv = onlp_file_read_int(&rrpm, INV_HWMON_PREFIX"fan%d_input", local_id*2); - if(rv != ONLP_STATUS_OK ) { return rv; } - rv = onlp_file_read_int(&pwm,INV_HWMON_PREFIX"pwm%d", local_id); - if(rv != ONLP_STATUS_OK ) { return rv; } - - if( lrpm <= 0 || rrpm <=0 || pwm <=0 || pwm > MAX_PWM) { - *status |= ONLP_FAN_STATUS_FAILED; - *status &= (~ONLP_FAN_STATUS_B2F); - *status &= (~ONLP_FAN_STATUS_F2B); - } else { - *status &= (~ONLP_FAN_STATUS_FAILED); - } - break; - case ONLP_FAN_PSU_1: - case ONLP_FAN_PSU_2: - psu_id = LOCAL_ID_TO_PSU_ID(local_id); - rv = onlp_file_read_int(&rpm, INV_HWMON_PREFIX"rpm_psu%d", psu_id); - if(rv != ONLP_STATUS_OK ) { return rv; } - rv = onlp_file_read_int(&pwm, INV_HWMON_PREFIX"pwm_psu%d", psu_id); - if(rv != ONLP_STATUS_OK ) { return rv; } - - if( rpm <= 0 || pwm <=0 || pwm > MAX_PWM) { - *status |= ONLP_FAN_STATUS_FAILED; - *status &= (~ONLP_FAN_STATUS_B2F); - *status &= (~ONLP_FAN_STATUS_F2B); - } else { - *status &= (~ONLP_FAN_STATUS_FAILED); - } - break; - default: - rv = ONLP_STATUS_E_INVALID; - break; - } - return rv; -} - -static int _fani_status_present_check(uint32_t* status, int local_id) -{ - int rv; - int gpi; - int info_idx; - int len; - char buf[ONLP_CONFIG_INFO_STR_MAX]; - if(local_id >= ONLP_FAN_1 && local_id <= ONLP_FAN_4){ - info_idx = LOCAL_ID_TO_INFO_IDX(local_id); - rv = onlp_file_read((uint8_t*)buf,ONLP_CONFIG_INFO_STR_MAX, &len, INV_HWMON_PREFIX"fan_gpi"); - }else if(local_id == ONLP_FAN_5){ - info_idx = LOCAL_ID_TO_INFO_IDX(local_id)-ONLP_FAN_4; - rv = onlp_file_read((uint8_t*)buf,ONLP_CONFIG_INFO_STR_MAX, &len, INV_HWMON_PREFIX"fan_gpi2"); - }else{ - rv = ONLP_STATUS_E_INVALID; - } - if( rv == ONLP_STATUS_OK ) { - sscanf( buf, "0x%x\n", &gpi); - /* B[0-3] installed(0)/uninstalled(1) - B[4-7] FRtype(0)/RFtype(1) */ - if (!((gpi>>info_idx) & 1)) { - *status |= ONLP_FAN_STATUS_PRESENT; - if (!((gpi>>(info_idx+4)) & 1)) { - *status |= ONLP_FAN_STATUS_F2B; - } else { - *status |= ONLP_FAN_STATUS_B2F; - } - } else { - *status = 0; - } - } - return rv; -} - - -/** - * @brief Retrieve the fan's operational status. - * @param id The fan OID. - * @param rv [out] Receives the fan's operations status flags. - * @notes Only operational state needs to be returned - - * PRESENT/FAILED - */ -int onlp_fani_status_get(onlp_oid_t id, uint32_t* rv) -{ - int result = ONLP_STATUS_OK; - onlp_fan_info_t* info; - int local_id; - VALIDATE(id); - uint32_t psu_status; - - local_id = ONLP_OID_ID_GET(id); - if(local_id >= ONLP_FAN_MAX) { - result = ONLP_STATUS_E_INVALID; - } else { - info = &__onlp_fan_info[LOCAL_ID_TO_INFO_IDX(local_id)]; - switch(local_id) { - case ONLP_FAN_1: - case ONLP_FAN_2: - case ONLP_FAN_3: - case ONLP_FAN_4: - case ONLP_FAN_5: - result = _fani_status_present_check(&info->status, local_id); - if (result == ONLP_STATUS_OK ) { - if (info->status & ONLP_FAN_STATUS_PRESENT) { - result = _fani_status_failed_check(&info->status, local_id); - } - } - break; - case ONLP_FAN_PSU_1: - case ONLP_FAN_PSU_2: - result = onlp_psui_status_get((&info->hdr)->poid, &psu_status); - if(result != ONLP_STATUS_OK) { return result; } - - if(psu_status & ONLP_PSU_STATUS_PRESENT) { - info->status |= ONLP_FAN_STATUS_PRESENT; - result = _fani_status_failed_check(&info->status, local_id); - } else { - info->status = 0; - } - break; - default: - result = ONLP_STATUS_E_INVALID; - break; - } - *rv = info->status; - } - return result; -} - -/** - * @brief Retrieve the fan's OID hdr. - * @param id The fan OID. - * @param rv [out] Receives the OID header. - */ -int onlp_fani_hdr_get(onlp_oid_t id, onlp_oid_hdr_t* hdr) -{ - int result = ONLP_STATUS_OK; - onlp_fan_info_t* info; - int local_id; - VALIDATE(id); - - local_id = ONLP_OID_ID_GET(id); - if(local_id >= ONLP_FAN_MAX) { - result = ONLP_STATUS_E_INVALID; - } else { - info = &__onlp_fan_info[LOCAL_ID_TO_INFO_IDX(local_id)]; - *hdr = info->hdr; - } - return result; -} - - -/* - * 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) -{ - return ONLP_STATUS_E_UNSUPPORTED; -} - - -/* - * 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/d5254/onlp/builds/x86_64_inventec_d5254/module/src/ledi.c b/packages/platforms/inventec/x86-64/d5254/onlp/builds/x86_64_inventec_d5254/module/src/ledi.c deleted file mode 100644 index a18c328db..000000000 --- a/packages/platforms/inventec/x86-64/d5254/onlp/builds/x86_64_inventec_d5254/module/src/ledi.c +++ /dev/null @@ -1,448 +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 "platform_lib.h" - -#define VALIDATE(_id) \ - do { \ - if(!ONLP_OID_IS_LED(_id)) { \ - return ONLP_STATUS_E_INVALID; \ - } \ - } while(0) - -/* LED related data - */ - -/* CAPS*/ -#define SYS_LED_CAPS 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_ORANGE -#define FAN_LED_CAPS ONLP_LED_CAPS_RED|ONLP_LED_CAPS_GREEN - -#define LOCAL_ID_TO_FAN_ID(id) (id-1) - -typedef enum sys_led_mode_e { - SYS_LED_MODE_OFF = 0, - SYS_LED_MODE_0_5_HZ = 1, - SYS_LED_MODE_1_HZ = 2, - SYS_LED_MODE_2_HZ = 3, - SYS_LED_MODE_ON = 7 -} sys_led_mode_t; - -/* function declarations*/ -static int _sys_onlp_led_mode_convert(sys_led_mode_t grn_mode, sys_led_mode_t red_mode, onlp_led_mode_t* pmode); -static int _sys_onlp_ledi_info_get(onlp_oid_t id, onlp_led_info_t* info); -static int _fan_onlp_ledi_info_get(onlp_oid_t id, onlp_led_info_t* info); -static int _sys_onlp_ledi_mode_set(onlp_led_mode_t onlp_mode); - -/* - * Get the information for the given LED OID. - */ -#define MAKE_MGMT_LED_INFO_NODE \ - { \ - { ONLP_LED_ID_CREATE(ONLP_LED_MGMT), "MGMT LED" , 0 }, \ - ONLP_LED_STATUS_PRESENT, \ - SYS_LED_CAPS, \ - } - -#define MAKE_LED_INFO_NODE_ON_FAN(fan_id) \ - { \ - { ONLP_LED_ID_CREATE(ONLP_LED_FAN##fan_id), \ - "FAN LED "#fan_id, \ - ONLP_FAN_ID_CREATE(ONLP_FAN_##fan_id) \ - }, \ - 0, \ - 0, \ - } - -static onlp_led_info_t __onlp_led_info[ONLP_LED_COUNT] = { - MAKE_MGMT_LED_INFO_NODE, - MAKE_LED_INFO_NODE_ON_FAN(1), - MAKE_LED_INFO_NODE_ON_FAN(2), - MAKE_LED_INFO_NODE_ON_FAN(3), - MAKE_LED_INFO_NODE_ON_FAN(4), - MAKE_LED_INFO_NODE_ON_FAN(5), -}; - - - -/* convert platform led type to onlp_led_mode type*/ -static int _sys_onlp_led_mode_convert(sys_led_mode_t grn_mode, sys_led_mode_t red_mode, onlp_led_mode_t* pmode) -{ - int rv = ONLP_STATUS_OK; - *pmode = ONLP_LED_MODE_OFF; - - switch(grn_mode) { - case SYS_LED_MODE_0_5_HZ: - case SYS_LED_MODE_1_HZ: - case SYS_LED_MODE_2_HZ: - *pmode = ONLP_LED_MODE_GREEN_BLINKING; - break; - case SYS_LED_MODE_ON: - *pmode = ONLP_LED_MODE_GREEN; - break; - case SYS_LED_MODE_OFF: - *pmode = ONLP_LED_MODE_OFF; - break; - default: - return ONLP_STATUS_E_INVALID; - break; - } - switch(red_mode) { - case SYS_LED_MODE_0_5_HZ: - case SYS_LED_MODE_1_HZ: - case SYS_LED_MODE_2_HZ: - if(grn_mode == SYS_LED_MODE_OFF) { - *pmode = ONLP_LED_MODE_RED_BLINKING; - } else { - return ONLP_STATUS_E_INVALID; - } - break; - case SYS_LED_MODE_ON: - if(grn_mode == SYS_LED_MODE_OFF) { - *pmode = ONLP_LED_MODE_RED; - } else if(grn_mode == SYS_LED_MODE_ON) { - *pmode = ONLP_LED_MODE_ORANGE; - } else { - return ONLP_STATUS_E_INVALID; - } - break; - case SYS_LED_MODE_OFF: - if(grn_mode == SYS_LED_MODE_OFF) { - *pmode = ONLP_LED_MODE_OFF; - } - break; - default: - return ONLP_STATUS_E_INVALID; - break; - } - return rv; -} - - -static int _sys_onlp_ledi_info_get(onlp_oid_t id, onlp_led_info_t* info) -{ - int local_id; - int rv = ONLP_STATUS_OK; - sys_led_mode_t grn_mode, red_mode; - local_id = ONLP_OID_ID_GET(id); - int idx = LOCAL_ID_TO_INFO_IDX(local_id); - /* Set the onlp_oid_hdr_t and capabilities */ - *info = __onlp_led_info[idx]; - - rv = onlp_file_read_int((int*)&grn_mode, INV_SYSLED_PREFIX"grn_led"); - if(rv != ONLP_STATUS_OK) { return rv; } - rv = onlp_file_read_int((int*)&red_mode, INV_SYSLED_PREFIX"red_led"); - if(rv != ONLP_STATUS_OK) { return rv; } - - rv = _sys_onlp_led_mode_convert(grn_mode, red_mode, &info->mode); - if(rv != ONLP_STATUS_OK) { return rv; } - - /* Set the on/off status */ - if (info->mode != ONLP_LED_MODE_OFF) { - info->status |= ONLP_LED_STATUS_ON; - } else { - info->status &= (~ONLP_LED_STATUS_ON); - } - - - return rv; -} - -static int _fan_onlp_ledi_info_get(onlp_oid_t id, onlp_led_info_t* info) -{ - int local_id; - int rv = ONLP_STATUS_OK; - int grn_mode, red_mode; - - local_id = ONLP_OID_ID_GET(id); - int fan_id = LOCAL_ID_TO_FAN_ID(local_id); - int idx = LOCAL_ID_TO_INFO_IDX(local_id); - /* Set the onlp_oid_hdr_t and capabilities */ - *info = __onlp_led_info[idx]; - - rv = onlp_ledi_status_get(id, &info->status); - if( rv != ONLP_STATUS_OK ) { return rv; } - - if( info->status & ONLP_LED_STATUS_PRESENT) { - info->caps = FAN_LED_CAPS; - rv = onlp_file_read_int((int*)&grn_mode, INV_HWMON_PREFIX"fan_led_grn%d", fan_id); - if(rv != ONLP_STATUS_OK ) { return rv; } - rv = onlp_file_read_int((int*)&red_mode, INV_HWMON_PREFIX"fan_led_red%d", fan_id); - if(rv != ONLP_STATUS_OK ) { return rv; } - - if(grn_mode == 1 && red_mode == 0) { - info->mode = ONLP_LED_MODE_GREEN; - } else if(grn_mode == 0 && red_mode == 1) { - info->mode = ONLP_LED_MODE_RED; - } else if(grn_mode == 0 && red_mode == 0) { - info->mode = ONLP_LED_MODE_OFF; - } else { - rv = ONLP_STATUS_E_INVALID; - } - } else { - info->mode = ONLP_LED_MODE_OFF; - } - return rv; -} - -static int _sys_onlp_ledi_mode_set(onlp_led_mode_t onlp_mode) -{ - int rv = ONLP_STATUS_OK; - - if( onlp_mode == ONLP_LED_MODE_OFF) { - rv = onlp_file_write_int(SYS_LED_MODE_OFF, INV_SYSLED_PREFIX"grn_led"); - if(rv != ONLP_STATUS_OK ) { return rv; } - rv = onlp_file_write_int(SYS_LED_MODE_OFF, INV_SYSLED_PREFIX"red_led"); - } else { - rv = ONLP_STATUS_E_UNSUPPORTED; - } - return rv; -} - - - -/* - * 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; - VALIDATE(id); - int local_id; - local_id = ONLP_OID_ID_GET(id); - if(local_id >= ONLP_LED_MAX) { - return ONLP_STATUS_E_INVALID; - } - - switch(local_id) { - case ONLP_LED_MGMT: - rv = _sys_onlp_ledi_info_get(id, info); - break; - case ONLP_LED_FAN1: - case ONLP_LED_FAN2: - case ONLP_LED_FAN3: - case ONLP_LED_FAN4: - case ONLP_LED_FAN5: - rv = _fan_onlp_ledi_info_get(id, info); - break; - default: - rv = ONLP_STATUS_E_INVALID; - break; - } - return rv; -} - -/** - * @brief Get the LED operational status. - * @param id The LED OID - * @param rv [out] Receives the operational status. - */ -int onlp_ledi_status_get(onlp_oid_t id, uint32_t* rv) -{ - int result = ONLP_STATUS_OK; - onlp_led_info_t* info; - - VALIDATE(id); - int local_id = ONLP_OID_ID_GET(id); - int info_idx = LOCAL_ID_TO_INFO_IDX(local_id); - int fan_id = LOCAL_ID_TO_FAN_ID(local_id); - int mode, grn_mode, red_mode; - onlp_led_mode_t pmode; - uint32_t fan_status; - - if(local_id >= ONLP_LED_MAX) { - result = ONLP_STATUS_E_INVALID; - } - if(result == ONLP_STATUS_OK) { - info = &__onlp_led_info[info_idx]; - switch(local_id) { - case ONLP_LED_MGMT: - result = onlp_file_read_int((int*)&grn_mode, INV_SYSLED_PREFIX"grn_led"); - if(result != ONLP_STATUS_OK) { return result; } - result = onlp_file_read_int((int*)&red_mode, INV_SYSLED_PREFIX"red_led"); - if(result != ONLP_STATUS_OK) { return result; } - - result = _sys_onlp_led_mode_convert(grn_mode, red_mode, &pmode); - if(result != ONLP_STATUS_OK) { return result; } - - if( pmode != ONLP_LED_MODE_OFF) { - info->status |= ONLP_LED_STATUS_ON; - } else { - info->status &= (~ONLP_LED_STATUS_ON); - } - - *rv = info->status; - break; - case ONLP_LED_FAN1: - case ONLP_LED_FAN2: - case ONLP_LED_FAN3: - case ONLP_LED_FAN4: - case ONLP_LED_FAN5: - result = onlp_fani_status_get((&info->hdr)->poid, &fan_status); - if(result != ONLP_STATUS_OK) { return result; } - - if(fan_status & ONLP_FAN_STATUS_PRESENT) { - info->status |= ONLP_LED_STATUS_PRESENT; - info->status &= (~ONLP_LED_STATUS_ON); - - result = onlp_file_read_int((int*)&mode, INV_HWMON_PREFIX"fan_led_grn%d", fan_id); - if(result != ONLP_STATUS_OK) { return result; } - if(mode) { - info->status |= ONLP_LED_STATUS_ON; - } - - result = onlp_file_read_int((int*)&mode, INV_HWMON_PREFIX"fan_led_red%d", fan_id); - if(result != ONLP_STATUS_OK) { return result; } - if(mode) { - info->status |= ONLP_LED_STATUS_ON; - } - } else { - info->status = 0; - } - *rv = info->status; - break; - default: - result = ONLP_STATUS_E_INVALID; - break; - } - } - - return result; -} - -/** - * @brief Get the LED header. - * @param id The LED OID - * @param rv [out] Receives the header. - */ -int onlp_ledi_hdr_get(onlp_oid_t id, onlp_oid_hdr_t* rv) -{ - int result = ONLP_STATUS_OK; - onlp_led_info_t* info; - - VALIDATE(id); - - int local_id; - local_id = ONLP_OID_ID_GET(id); - int idx = LOCAL_ID_TO_INFO_IDX(local_id); - if(local_id >= ONLP_LED_MAX) { - result = ONLP_STATUS_E_INVALID; - } else { - info = &__onlp_led_info[idx]; - *rv = info->hdr; - } - return result; -} - -/* - * 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) -{ - onlp_led_mode_t mode; - VALIDATE(id); - int local_id; - local_id = ONLP_OID_ID_GET(id); - int idx = LOCAL_ID_TO_INFO_IDX(local_id); - - if(local_id >= ONLP_LED_MAX) { - return ONLP_STATUS_E_INVALID; - } - - if (__onlp_led_info[idx].caps & ONLP_LED_CAPS_ON_OFF) { - mode = on_or_off?ONLP_LED_MODE_ON:ONLP_LED_MODE_OFF; - return onlp_ledi_mode_set(id, mode); - } - - 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 rv = ONLP_STATUS_OK; - VALIDATE(id); - int local_id; - local_id = ONLP_OID_ID_GET(id); - - if(local_id >= ONLP_LED_MAX) { - return ONLP_STATUS_E_INVALID; - } - switch(local_id) { - case ONLP_LED_MGMT: - rv = _sys_onlp_ledi_mode_set(mode); - break; - case ONLP_LED_FAN1: - case ONLP_LED_FAN2: - case ONLP_LED_FAN3: - case ONLP_LED_FAN4: - case ONLP_LED_FAN5: - rv = ONLP_STATUS_E_UNSUPPORTED; - break; - default: - rv = ONLP_STATUS_E_INVALID; - break; - } - - return rv; -} - -/* - * 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/d5254/onlp/builds/x86_64_inventec_d5254/module/src/make.mk b/packages/platforms/inventec/x86-64/d5254/onlp/builds/x86_64_inventec_d5254/module/src/make.mk deleted file mode 100644 index 1239e4aed..000000000 --- a/packages/platforms/inventec/x86-64/d5254/onlp/builds/x86_64_inventec_d5254/module/src/make.mk +++ /dev/null @@ -1,9 +0,0 @@ -############################################################################### -# -# -# -############################################################################### - -LIBRARY := x86_64_inventec_d5254 -$(LIBRARY)_SUBDIR := $(dir $(lastword $(MAKEFILE_LIST))) -include $(BUILDER)/lib.mk diff --git a/packages/platforms/inventec/x86-64/d5254/onlp/builds/x86_64_inventec_d5254/module/src/platform_lib.c b/packages/platforms/inventec/x86-64/d5254/onlp/builds/x86_64_inventec_d5254/module/src/platform_lib.c deleted file mode 100644 index bb04678b2..000000000 --- a/packages/platforms/inventec/x86-64/d5254/onlp/builds/x86_64_inventec_d5254/module/src/platform_lib.c +++ /dev/null @@ -1,50 +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" - - -int platform_hwmon_diag_enable_read(int *enable) -{ - int rv = ONLP_STATUS_OK; - rv = onlp_file_read_int((int*)enable, INV_HWMON_PREFIX"diag"); - return rv; -} - - -int platform_hwmon_diag_enable_write(int enable) -{ - int rv = ONLP_STATUS_OK; - rv = onlp_file_write_int(enable, INV_HWMON_PREFIX"diag"); - return rv; -} diff --git a/packages/platforms/inventec/x86-64/d5254/onlp/builds/x86_64_inventec_d5254/module/src/platform_lib.h b/packages/platforms/inventec/x86-64/d5254/onlp/builds/x86_64_inventec_d5254/module/src/platform_lib.h deleted file mode 100644 index 0852d0fae..000000000 --- a/packages/platforms/inventec/x86-64/d5254/onlp/builds/x86_64_inventec_d5254/module/src/platform_lib.h +++ /dev/null @@ -1,142 +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 "x86_64_inventec_d5254_log.h" - -/* This is definitions for x86-64-inventec-d5254*/ -/* OID map*/ -/* - * SYS---------ONLP_THERMAL_CPU_PHY - * |----ONLP_THERMAL_CPU_CORE0 - * |----ONLP_THERMAL_CPU_CORE1 - * |----ONLP_THERMAL_CPU_CORE2 - * |----ONLP_THERMAL_CPU_CORE3 - * |----ONLP_THERMAL_1_ON_MAIN_BROAD - * |----ONLP_THERMAL_2_ON_MAIN_BROAD - * |----ONLP_THERMAL_3_ON_MAIN_BROAD - * |----ONLP_THERMAL_4_ON_MAIN_BROAD - * |----ONLP_THERMAL_5_ON_MAIN_BROAD - * |----ONLP_FAN_1--------ONLP_LED_FAN1 - * | - * |----ONLP_FAN_2--------ONLP_LED_FAN2 - * | - * |----ONLP_FAN_3--------ONLP_LED_FAN3 - * | - * |----ONLP_FAN_4--------ONLP_LED_FAN4 - * | - * |----ONLP_FAN_5--------ONLP_LED_FAN5 - * | - * |----ONLP_PSU_1--------ONLP_THERMAL_1_ON_PSU1 - * | |--ONLP_THERMAL_2_ON_PSU1 - * | |--ONLP_FAN_PSU_1 - * | - * |----ONLP_PSU_2--------ONLP_THERMAL_1_ON_PSU2 - * | |--ONLP_THERMAL_2_ON_PSU2 - * | |--ONLP_FAN_PSU_2 - * | - * |----ONLP_LED_MGMT - */ - -#define INV_SYSLED_PREFIX "/sys/class/hwmon/hwmon2/device/" -#define INV_HWMON_PREFIX "/sys/class/hwmon/hwmon1/device/" -#define INV_CTMP_PREFIX "/sys/class/hwmon/hwmon0/" -#define INV_SFP_PREFIX "/sys/class/swps/" -#define INV_SYS_PREFIX "/sys/class/eeprom/vpd/" - -#define OID_MAP_TO_INFO_IDX(oid) ONLP_OID_ID_GET(oid)-1 -#define LOCAL_ID_TO_INFO_IDX(id) (id-1) - -/* Thermal definitions*/ -enum onlp_thermal_id { - ONLP_THERMAL_CPU_PHY = 1, - ONLP_THERMAL_CPU_CORE0, - ONLP_THERMAL_CPU_CORE1, - ONLP_THERMAL_CPU_CORE2, - ONLP_THERMAL_CPU_CORE3, - ONLP_THERMAL_1_ON_MAIN_BROAD, - ONLP_THERMAL_2_ON_MAIN_BROAD, - ONLP_THERMAL_3_ON_MAIN_BROAD, - ONLP_THERMAL_4_ON_MAIN_BROAD, - ONLP_THERMAL_5_ON_MAIN_BROAD, - ONLP_THERMAL_1_ON_PSU1, - ONLP_THERMAL_2_ON_PSU1, - ONLP_THERMAL_1_ON_PSU2, - ONLP_THERMAL_2_ON_PSU2, - ONLP_THERMAL_MAX -}; - -#define ONLP_THERMAL_COUNT 14 /*include "reserved"*/ - -/* Fan definitions*/ -enum onlp_fan_id { - ONLP_FAN_1 = 1, - ONLP_FAN_2, - ONLP_FAN_3, - ONLP_FAN_4, - ONLP_FAN_5, - ONLP_FAN_PSU_1, - ONLP_FAN_PSU_2, - ONLP_FAN_MAX -}; - -#define ONLP_FAN_COUNT 7 /*include "reserved"*/ - -/* PSU definitions*/ -enum onlp_psu_id { - ONLP_PSU_1 = 1, - ONLP_PSU_2, - ONLP_PSU_MAX -}; - -#define ONLP_PSU_COUNT 2 /*include "reserved"*/ - -/* LED definitions*/ -enum onlp_led_id { - ONLP_LED_MGMT = 1, - ONLP_LED_FAN1, - ONLP_LED_FAN2, - ONLP_LED_FAN3, - ONLP_LED_FAN4, - ONLP_LED_FAN5, - ONLP_LED_MAX -}; - -#define ONLP_LED_COUNT 6 /*include "reserved"*/ - - -/* platform functions*/ -#define PLATFORM_HWMON_DIAG_LOCK platform_hwmon_diag_enable_write(0) -#define PLATFORM_HWMON_DIAG_UNLOCK platform_hwmon_diag_enable_write(1) -int platform_hwmon_diag_enable_read(int *enable); -int platform_hwmon_diag_enable_write(int enable); - - - - -#endif /* __PLATFORM_LIB_H__ */ - diff --git a/packages/platforms/inventec/x86-64/d5254/onlp/builds/x86_64_inventec_d5254/module/src/psui.c b/packages/platforms/inventec/x86-64/d5254/onlp/builds/x86_64_inventec_d5254/module/src/psui.c deleted file mode 100644 index cabf4370a..000000000 --- a/packages/platforms/inventec/x86-64/d5254/onlp/builds/x86_64_inventec_d5254/module/src/psui.c +++ /dev/null @@ -1,215 +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 "platform_lib.h" -#include -#include - -#define VALIDATE(_id) \ - do { \ - if(!ONLP_OID_IS_PSU(_id)) { \ - return ONLP_STATUS_E_INVALID; \ - } \ - } while(0) - - -typedef enum hwmon_psu_state_e { - HWMON_PSU_NORMAL = 0, - HWMON_PSU_UNPOWERED = 2, //010 - HWMON_PSU_FAULT = 4, //100 - HWMON_PSU_NOT_INSTALLED = 7 //111 -} hwmon_psu_state_t; - -/* - * Get all information about the given PSU oid. - */ -#define MAKE_PSU_NODE_INFO(id) \ - { \ - { \ - ONLP_PSU_ID_CREATE(ONLP_PSU_##id), "PSU-"#id, 0, \ - { \ - ONLP_THERMAL_ID_CREATE(ONLP_THERMAL_1_ON_PSU##id), \ - ONLP_THERMAL_ID_CREATE(ONLP_THERMAL_2_ON_PSU##id), \ - ONLP_FAN_ID_CREATE(ONLP_FAN_PSU_##id) \ - } \ - }, \ - "","", 0, 0 \ - } - -static onlp_psu_info_t __onlp_psu_info[ONLP_PSU_COUNT] = { - MAKE_PSU_NODE_INFO(1), - MAKE_PSU_NODE_INFO(2) -}; - -int -onlp_psui_init(void) -{ - return ONLP_STATUS_OK; -} - - -int -onlp_psui_info_get(onlp_oid_t id, onlp_psu_info_t* info) -{ - int ret = ONLP_STATUS_OK; - int len; - int local_id = ONLP_OID_ID_GET(id); - uint8_t temp[ONLP_CONFIG_INFO_STR_MAX] = {0}; - - VALIDATE(id); - - if(local_id >= ONLP_PSU_MAX) { - return ONLP_STATUS_E_INVALID; - } - - - *info = __onlp_psu_info[LOCAL_ID_TO_INFO_IDX(local_id)]; /* Set the onlp_oid_hdr_t */ - - ret = onlp_file_read(temp, ONLP_CONFIG_INFO_STR_MAX, &len, INV_HWMON_PREFIX"psoc_psu%d_vendor", local_id); - if(ret != ONLP_STATUS_OK) { return ret; } - /*remove the '\n'*/ - temp[strlen((char*)temp)-1] = 0; - snprintf(info->model, ONLP_CONFIG_INFO_STR_MAX, "%s", temp); - - - memset(temp, 0, ONLP_CONFIG_INFO_STR_MAX); - ret = onlp_file_read(temp, ONLP_CONFIG_INFO_STR_MAX, &len, INV_HWMON_PREFIX"psoc_psu%d_serial", local_id); - if(ret != ONLP_STATUS_OK) { return ret; } - /*remove the '\n'*/ - temp[strlen((char*)temp)-1] = 0; - snprintf(info->serial, ONLP_CONFIG_INFO_STR_MAX, "%s", temp); - - ret = onlp_psui_status_get(id, &info->status); - if(ret != ONLP_STATUS_OK) { return ret; } - - if(info->status & ONLP_PSU_STATUS_PRESENT) { - info->caps = ONLP_PSU_CAPS_AC; - /*millivolts*/ - ret = onlp_file_read_int(&info->mvin, INV_HWMON_PREFIX"psoc_psu%d_vin", local_id); - if(ret != ONLP_STATUS_OK) { return ret; } - if(info->mvin >= 0) { - info->caps |= ONLP_PSU_CAPS_VIN; - } - ret = onlp_file_read_int(&info->mvout, INV_HWMON_PREFIX"psoc_psu%d_vout", local_id); - if(ret != ONLP_STATUS_OK) { return ret; } - if(info->mvout >= 0) { - info->caps |= ONLP_PSU_CAPS_VOUT; - } - - /* milliamps */ - ret = onlp_file_read_int(&info->miin, INV_HWMON_PREFIX"psoc_psu%d_iin", local_id); - if(ret != ONLP_STATUS_OK) { return ret; } - if(info->miin >= 0) { - info->caps |= ONLP_PSU_CAPS_IIN; - } - ret = onlp_file_read_int(&info->miout, INV_HWMON_PREFIX"psoc_psu%d_iout", local_id); - if(ret != ONLP_STATUS_OK) { return ret; } - if(info->miout >= 0) { - info->caps |= ONLP_PSU_CAPS_IOUT; - } - - /* milliwatts */ - ret = onlp_file_read_int(&info->mpin, INV_HWMON_PREFIX"psoc_psu%d_pin", local_id); - if(ret != ONLP_STATUS_OK) { return ret; } - if(info->mpin >= 0) { - info->caps |= ONLP_PSU_CAPS_PIN; - } - ret = onlp_file_read_int(&info->mpout, INV_HWMON_PREFIX"psoc_psu%d_pout", local_id); - if(ret != ONLP_STATUS_OK) { return ret; } - if(info->mpout >= 0) { - info->caps |= ONLP_PSU_CAPS_POUT; - } - } - return ret; -} - - -/** - * @brief Get the PSU's operational status. - * @param id The PSU OID. - * @param rv [out] Receives the operational status. - */ -int onlp_psui_status_get(onlp_oid_t id, uint32_t* rv) -{ - int result = ONLP_STATUS_OK; - hwmon_psu_state_t psu_state; - int local_id; - VALIDATE(id); - int len; - char buf[ONLP_CONFIG_INFO_STR_MAX]; - - local_id = ONLP_OID_ID_GET(id); - if(local_id >= ONLP_PSU_MAX) { - result = ONLP_STATUS_E_INVALID; - } else { - result = onlp_file_read((uint8_t*)&buf, ONLP_CONFIG_INFO_STR_MAX, &len, "%s""psu%d", INV_HWMON_PREFIX, local_id); - if( result != ONLP_STATUS_OK ) {return result;} - psu_state = (uint8_t)strtoul(buf, NULL, 0); - if( psu_state == HWMON_PSU_UNPOWERED) { - *rv = ONLP_PSU_STATUS_PRESENT|ONLP_PSU_STATUS_UNPLUGGED; - } else if ( psu_state == HWMON_PSU_NORMAL) { - *rv = ONLP_PSU_STATUS_PRESENT; - } else if( psu_state == HWMON_PSU_FAULT) { - *rv = ONLP_PSU_STATUS_PRESENT|ONLP_PSU_STATUS_FAILED; - } else if( psu_state == HWMON_PSU_NOT_INSTALLED) { - *rv = 0; - } else { - result = ONLP_STATUS_E_INVALID; - } - } - return result; -} - -/** - * @brief Get the PSU's oid header. - * @param id The PSU OID. - * @param rv [out] Receives the header. - */ -int onlp_psui_hdr_get(onlp_oid_t id, onlp_oid_hdr_t* rv) -{ - int result = ONLP_STATUS_OK; - onlp_psu_info_t* info; - int local_id; - VALIDATE(id); - - local_id = ONLP_OID_ID_GET(id); - if(local_id >= ONLP_PSU_MAX) { - result = ONLP_STATUS_E_INVALID; - } else { - info = &__onlp_psu_info[LOCAL_ID_TO_INFO_IDX(local_id)]; - *rv = info->hdr; - } - return result; -} - - -int -onlp_psui_ioctl(onlp_oid_t pid, va_list vargs) -{ - return ONLP_STATUS_E_UNSUPPORTED; -} - diff --git a/packages/platforms/inventec/x86-64/d5254/onlp/builds/x86_64_inventec_d5254/module/src/sfpi.c b/packages/platforms/inventec/x86-64/d5254/onlp/builds/x86_64_inventec_d5254/module/src/sfpi.c deleted file mode 100644 index d9a447ccd..000000000 --- a/packages/platforms/inventec/x86-64/d5254/onlp/builds/x86_64_inventec_d5254/module/src/sfpi.c +++ /dev/null @@ -1,388 +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 /* For O_RDWR && open */ -#include -#include -#include -#include -#include -#include "platform_lib.h" -#include -#include - -#define MAX_SFP_PATH 128 - -#define MUX_START_INDEX 10 -#define QSFP_DEV_ADDR 0x50 -#define NUM_OF_SFP_PORT 48 -#define NUM_OF_QSFP_PORT 6 -#define NUM_OF_ALL_PORT (NUM_OF_SFP_PORT+NUM_OF_QSFP_PORT) - -#define FRONT_PORT_TO_MUX_INDEX(port) (port+MUX_START_INDEX) -/************************************************************ - * - * SFPI Entry Points - * - ***********************************************************/ -enum onlp_sfp_port_type { - ONLP_PORT_TYPE_SFP = 0, - ONLP_PORT_TYPE_QSFP, - ONLP_PORT_TYPE_MAX -}; - -static int -onlp_sfpi_port_type(int port) -{ - if(port >= 0 && port < NUM_OF_SFP_PORT) { - return ONLP_PORT_TYPE_SFP; - } else if(port >= NUM_OF_SFP_PORT && port < NUM_OF_ALL_PORT) { - return ONLP_PORT_TYPE_QSFP; - } else { - AIM_LOG_ERROR("Invalid port(%d)\r\n", port); - return ONLP_STATUS_E_PARAM; - } -} - -int -onlp_sfpi_init(void) -{ - /* Called at initialization time */ - return ONLP_STATUS_OK; -} - -int onlp_sfpi_port_map(int port, int* rport) -{ - int p_type = onlp_sfpi_port_type(port); - if(p_type < 0) {return ONLP_STATUS_E_INVALID;} - *rport = port; - return ONLP_STATUS_OK; -} - -int -onlp_sfpi_bitmap_get(onlp_sfp_bitmap_t* bmap) -{ - /* - * Ports {0, 53} - */ - int p; - AIM_BITMAP_CLR_ALL(bmap); - - for(p = 0; p < NUM_OF_ALL_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 p_type = onlp_sfpi_port_type(port); - if(p_type < 0) {return ONLP_STATUS_E_INVALID;} - - int present; - int rv; - if(onlp_file_read_int(&present, INV_SFP_PREFIX"port%d/present", port) != ONLP_STATUS_OK) { - return ONLP_STATUS_E_INTERNAL; - } - if(present == 0) { - rv = true; - } else if (present == 1) { - rv = false; - } else { - AIM_LOG_ERROR("Unvalid present status %d from port(%d)\r\n",present,port); - return ONLP_STATUS_E_INTERNAL; - } - return rv; -} - -int -onlp_sfpi_presence_bitmap_get(onlp_sfp_bitmap_t* dst) -{ - AIM_BITMAP_CLR_ALL(dst); - int port; - for(port = 0; port < NUM_OF_ALL_PORT; port++) { - if(onlp_sfpi_is_present(port) == true) { - AIM_BITMAP_MOD(dst, port, 1); - } else if(onlp_sfpi_is_present(port) == false) { - AIM_BITMAP_MOD(dst, port, 0); - } else { - return ONLP_STATUS_E_INTERNAL; - } - } - return ONLP_STATUS_OK; -} - -static int -onlp_sfpi_is_rx_los(int port) -{ - int rxlos; - int rv; - int len; - char buf[ONLP_CONFIG_INFO_STR_MAX]; - - int p_type = onlp_sfpi_port_type(port); - - if(p_type == ONLP_PORT_TYPE_SFP) { - if(onlp_file_read_int(&rxlos, INV_SFP_PREFIX"port%d/rxlos", port) != ONLP_STATUS_OK) { - return ONLP_STATUS_E_INTERNAL; - } - if(rxlos == 0) { - rv = true; - } else { - rv = false; - } - } else if(p_type == ONLP_PORT_TYPE_QSFP) { - if(onlp_file_read((uint8_t*)buf, ONLP_CONFIG_INFO_STR_MAX, &len, INV_SFP_PREFIX"port%d/soft_rx_los", port) != ONLP_STATUS_OK) { - return ONLP_STATUS_E_INTERNAL; - } - if(sscanf( buf, "0x%x\n", &rxlos) != 1) { - AIM_LOG_ERROR("Unable to read rxlos from port(%d)\r\n", port); - return ONLP_STATUS_E_INTERNAL; - } - if(rxlos < 0 || rxlos > 0x0f) { - AIM_LOG_ERROR("Unable to read rxlos from port(%d)\r\n", port); - return ONLP_STATUS_E_INTERNAL; - } else if(rxlos == 0) { - rv = true; - } else { - rv = false; - } - } else { - return ONLP_STATUS_E_INVALID; - } - - return rv; -} - -int -onlp_sfpi_rx_los_bitmap_get(onlp_sfp_bitmap_t* dst) -{ - AIM_BITMAP_CLR_ALL(dst); - int port; - int isrxlos; - for(port = 0; port < NUM_OF_ALL_PORT; port++) { - if(onlp_sfpi_is_present(port) == true) { - isrxlos = onlp_sfpi_is_rx_los(port); - if(isrxlos == true) { - AIM_BITMAP_MOD(dst, port, 1); - } else if(isrxlos == false) { - AIM_BITMAP_MOD(dst, port, 0); - } else { - return ONLP_STATUS_E_INTERNAL; - } - } - } - 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; -} - -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 - */ - memset(data, 0, 256); - - if(onlp_sfpi_port_type(port) < 0) { return ONLP_STATUS_E_INVALID; } - int sts; - int bus = FRONT_PORT_TO_MUX_INDEX(port); - sts = onlp_i2c_read(bus, QSFP_DEV_ADDR, 0, 256, data, ONLP_I2C_F_FORCE); - if(sts < 0) { - AIM_LOG_ERROR("Unable to read eeprom from port(%d)\r\n", port); - return ONLP_STATUS_E_MISSING; - } - return ONLP_STATUS_OK; -} - -int -onlp_sfpi_dev_readb(int port, uint8_t devaddr, uint8_t addr) -{ - if(onlp_sfpi_port_type(port) < 0) { return ONLP_STATUS_E_INVALID; } - 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) -{ - if(onlp_sfpi_port_type(port) < 0) { return ONLP_STATUS_E_INVALID; } - 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) -{ - if(onlp_sfpi_port_type(port) < 0) { return ONLP_STATUS_E_INVALID; } - 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) -{ - if(onlp_sfpi_port_type(port) < 0) { return ONLP_STATUS_E_INVALID; } - int bus = FRONT_PORT_TO_MUX_INDEX(port); - return onlp_i2c_writew(bus, devaddr, addr, value, ONLP_I2C_F_FORCE); -} - -int -onlp_sfpi_control_supported(int port, onlp_sfp_control_t control, int* rv) -{ - *rv = 0; - int p_type = onlp_sfpi_port_type(port); - if(p_type < 0) { return ONLP_STATUS_E_INVALID; } - switch (control) { - case ONLP_SFP_CONTROL_RESET_STATE: - if(p_type == ONLP_PORT_TYPE_QSFP) { - *rv = 1; - } - break; - case ONLP_SFP_CONTROL_TX_DISABLE: - if(p_type == ONLP_PORT_TYPE_SFP) { - *rv = 1; - } - break; - case ONLP_SFP_CONTROL_LP_MODE: - if(p_type == ONLP_PORT_TYPE_QSFP) { - *rv = 1; - } - break; - default: - break; - } - - return ONLP_STATUS_OK; -} - -int -onlp_sfpi_control_set(int port, onlp_sfp_control_t control, int value) -{ - int ret = ONLP_STATUS_E_UNSUPPORTED; - int p_type = onlp_sfpi_port_type(port); - if(p_type < 0) { return ONLP_STATUS_E_INVALID; } - switch (control) { - case ONLP_SFP_CONTROL_RESET_STATE: - if(p_type == ONLP_PORT_TYPE_QSFP) { - ret = onlp_file_write_int(value, INV_SFP_PREFIX"port%d/reset", port); - } - break; - case ONLP_SFP_CONTROL_TX_DISABLE: - if(p_type == ONLP_PORT_TYPE_SFP) { - ret = onlp_file_write_int(value, INV_SFP_PREFIX"port%d/tx_disable", port); - } - break; - case ONLP_SFP_CONTROL_LP_MODE: - if(p_type == ONLP_PORT_TYPE_QSFP) { - ret = onlp_file_write_int(value, INV_SFP_PREFIX"port%d/lpmod", port); - } - break; - default: - break; - } - - return ret; -} - -int -onlp_sfpi_control_get(int port, onlp_sfp_control_t control, int* value) -{ - int ret = ONLP_STATUS_E_UNSUPPORTED; - int p_type = onlp_sfpi_port_type(port); - if(p_type < 0) { return ONLP_STATUS_E_INVALID; } - switch (control) { - case ONLP_SFP_CONTROL_RESET_STATE: - if(p_type == ONLP_PORT_TYPE_QSFP) { - ret = onlp_file_read_int(value, INV_SFP_PREFIX"port%d/reset", port); - } - break; - case ONLP_SFP_CONTROL_RX_LOS: - if(p_type == ONLP_PORT_TYPE_SFP) { - ret = onlp_file_read_int(value, INV_SFP_PREFIX"port%d/rxlos", port); - } - break; - case ONLP_SFP_CONTROL_TX_DISABLE: - if(p_type == ONLP_PORT_TYPE_SFP) { - ret = onlp_file_read_int(value, INV_SFP_PREFIX"port%d/tx_disable", port); - } - break; - case ONLP_SFP_CONTROL_LP_MODE: - if(p_type == ONLP_PORT_TYPE_QSFP) { - ret = onlp_file_read_int(value, INV_SFP_PREFIX"port%d/lpmod", port); - } - break; - case ONLP_SFP_CONTROL_TX_FAULT: - if(p_type == ONLP_PORT_TYPE_SFP) { - ret = onlp_file_read_int(value, INV_SFP_PREFIX"port%d/tx_fault", port); - } - break; - default: - break; - } - - return ret; -} - -int -onlp_sfpi_denit(void) -{ - return ONLP_STATUS_OK; -} - -void -onlp_sfpi_debug(int port, aim_pvs_t* pvs) -{ - aim_printf(pvs, "Debug data for port %d goes here.", port); -} - -int -onlp_sfpi_ioctl(int port, va_list vargs) -{ - return ONLP_STATUS_E_UNSUPPORTED; -} diff --git a/packages/platforms/inventec/x86-64/d5254/onlp/builds/x86_64_inventec_d5254/module/src/sysi.c b/packages/platforms/inventec/x86-64/d5254/onlp/builds/x86_64_inventec_d5254/module/src/sysi.c deleted file mode 100644 index 7e0ee398d..000000000 --- a/packages/platforms/inventec/x86-64/d5254/onlp/builds/x86_64_inventec_d5254/module/src/sysi.c +++ /dev/null @@ -1,441 +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 -#include -#include - -#include "x86_64_inventec_d5254_int.h" -#include "x86_64_inventec_d5254_log.h" - -#include "platform_lib.h" - -#define SYSI_ONIE_TYPE_SUPPORT_NUM 17 -#define SYSI_PLATFORM_INFO_TYPE_STR_MAX 10 -#define SYSI_PLATFORM_INFO_NUM 2 - -/** - * The TLV Types. - */ -#define TLV_CODE_PRODUCT_NAME 0x21 -#define TLV_CODE_PART_NUMBER 0x22 -#define TLV_CODE_SERIAL_NUMBER 0x23 -#define TLV_CODE_MAC_BASE 0x24 -#define TLV_CODE_MANUF_DATE 0x25 -#define TLV_CODE_DEVICE_VERSION 0x26 -#define TLV_CODE_LABEL_REVISION 0x27 -#define TLV_CODE_PLATFORM_NAME 0x28 -#define TLV_CODE_ONIE_VERSION 0x29 -#define TLV_CODE_MAC_SIZE 0x2A -#define TLV_CODE_MANUF_NAME 0x2B -#define TLV_CODE_MANUF_COUNTRY 0x2C -#define TLV_CODE_VENDOR_NAME 0x2D -#define TLV_CODE_DIAG_VERSION 0x2E -#define TLV_CODE_SERVICE_TAG 0x2F -#define TLV_CODE_VENDOR_EXT 0xFD -#define TLV_CODE_CRC_32 0xFE - -static uint8_t __tlv_code_list[SYSI_ONIE_TYPE_SUPPORT_NUM] = { - TLV_CODE_PRODUCT_NAME, - TLV_CODE_PART_NUMBER, - TLV_CODE_SERIAL_NUMBER, - TLV_CODE_MAC_BASE, - TLV_CODE_MANUF_DATE, - TLV_CODE_DEVICE_VERSION, - TLV_CODE_LABEL_REVISION, - TLV_CODE_PLATFORM_NAME, - TLV_CODE_ONIE_VERSION, - TLV_CODE_MAC_SIZE, - TLV_CODE_MANUF_NAME, - TLV_CODE_MANUF_COUNTRY, - TLV_CODE_VENDOR_NAME, - TLV_CODE_DIAG_VERSION, - TLV_CODE_SERVICE_TAG, - TLV_CODE_VENDOR_EXT, - TLV_CODE_CRC_32 -}; - -static onlp_oid_t __oid_info[] = { - ONLP_THERMAL_ID_CREATE(ONLP_THERMAL_CPU_PHY), - ONLP_THERMAL_ID_CREATE(ONLP_THERMAL_CPU_CORE0), - ONLP_THERMAL_ID_CREATE(ONLP_THERMAL_CPU_CORE1), - ONLP_THERMAL_ID_CREATE(ONLP_THERMAL_CPU_CORE2), - ONLP_THERMAL_ID_CREATE(ONLP_THERMAL_CPU_CORE3), - ONLP_THERMAL_ID_CREATE(ONLP_THERMAL_1_ON_MAIN_BROAD), - ONLP_THERMAL_ID_CREATE(ONLP_THERMAL_2_ON_MAIN_BROAD), - ONLP_THERMAL_ID_CREATE(ONLP_THERMAL_3_ON_MAIN_BROAD), - ONLP_THERMAL_ID_CREATE(ONLP_THERMAL_4_ON_MAIN_BROAD), - ONLP_THERMAL_ID_CREATE(ONLP_THERMAL_5_ON_MAIN_BROAD), - ONLP_FAN_ID_CREATE(ONLP_FAN_1), - ONLP_FAN_ID_CREATE(ONLP_FAN_2), - ONLP_FAN_ID_CREATE(ONLP_FAN_3), - ONLP_FAN_ID_CREATE(ONLP_FAN_4), - ONLP_FAN_ID_CREATE(ONLP_FAN_5), - ONLP_PSU_ID_CREATE(ONLP_PSU_1), - ONLP_PSU_ID_CREATE(ONLP_PSU_2), - ONLP_LED_ID_CREATE(ONLP_LED_MGMT), - 0/*end*/ -}; - -static int _sysi_version_parsing(char* file_str, char* str_buf, char* version); -static void _case_tlv_code_string(onlp_onie_info_t* info, char** member, char* path); -static int _parse_tlv(onlp_onie_info_t* info, uint8_t type); - -static int _sysi_version_parsing(char* file_str, char* str_buf, char* version) -{ - int rv = ONLP_STATUS_OK; - int len; - char buf[ONLP_CONFIG_INFO_STR_MAX*4]; - char *temp; - - rv = onlp_file_read((uint8_t*)buf,ONLP_CONFIG_INFO_STR_MAX*4, &len, file_str); - if( rv != ONLP_STATUS_OK ) { return rv; } - - temp = strstr(buf, str_buf); - if(temp) { - temp += strlen(str_buf); - snprintf(version,ONLP_CONFIG_INFO_STR_MAX, temp); - /*remove '\n'*/ - version[strlen(version)-1] = '\0'; - } else { - rv = ONLP_STATUS_E_MISSING; - } - return rv; -} - -static void _case_tlv_code_string(onlp_onie_info_t* info, char** member, char* path) -{ - int rv = ONLP_STATUS_OK; - int len; - char buf[ONLP_CONFIG_INFO_STR_MAX]; - rv = onlp_file_read((uint8_t*)buf,ONLP_CONFIG_INFO_STR_MAX, &len, path); - if( rv == ONLP_STATUS_OK ) { - info->_hdr_length += 2; - buf[strlen(buf)-1] = '\0'; - *member = aim_fstrdup("%s",buf); - info->_hdr_length += strlen(*member); - } else { - *member = aim_zmalloc(1); - rv = ONLP_STATUS_OK; - } - return; -} - - -static int _parse_tlv(onlp_onie_info_t* info, uint8_t type) -{ - int rv = ONLP_STATUS_OK; - int len; - char buf[ONLP_CONFIG_INFO_STR_MAX]; - switch(type) { - case TLV_CODE_PRODUCT_NAME: - _case_tlv_code_string(info, &(info->product_name), INV_SYS_PREFIX"product_name"); - break; - case TLV_CODE_PART_NUMBER: - _case_tlv_code_string(info, &(info->part_number), INV_SYS_PREFIX"pn"); - break; - case TLV_CODE_SERIAL_NUMBER: - _case_tlv_code_string(info, &(info->serial_number), INV_SYS_PREFIX"sn"); - break; - case TLV_CODE_MANUF_DATE: - _case_tlv_code_string(info, &(info->manufacture_date), INV_SYS_PREFIX"man_date"); - break; - case TLV_CODE_LABEL_REVISION: - _case_tlv_code_string(info, &(info->label_revision), INV_SYS_PREFIX"label_rev"); - break; - case TLV_CODE_PLATFORM_NAME: - _case_tlv_code_string(info, &(info->platform_name), INV_SYS_PREFIX"plat_name"); - break; - case TLV_CODE_ONIE_VERSION: - _case_tlv_code_string(info, &(info->onie_version), INV_SYS_PREFIX"ldr_ver"); - break; - case TLV_CODE_MANUF_NAME: - _case_tlv_code_string(info, &(info->manufacturer), INV_SYS_PREFIX"manufacturer"); - break; - case TLV_CODE_MANUF_COUNTRY: - _case_tlv_code_string(info, &(info->country_code), INV_SYS_PREFIX"country_code"); - break; - case TLV_CODE_VENDOR_NAME: - _case_tlv_code_string(info, &(info->vendor), INV_SYS_PREFIX"vendor_name"); - break; - case TLV_CODE_SERVICE_TAG: - _case_tlv_code_string(info, &(info->service_tag), INV_SYS_PREFIX"service_tag"); - break; - case TLV_CODE_DIAG_VERSION: - _case_tlv_code_string(info, &(info->diag_version), INV_SYS_PREFIX"diag_ver"); - break; - - case TLV_CODE_MAC_BASE: - rv = onlp_file_read((uint8_t*)buf,ONLP_CONFIG_INFO_STR_MAX, &len, INV_SYS_PREFIX"base_mac_addr" ); - if( rv == ONLP_STATUS_OK ) { - if(sscanf( buf, "%hhx:%hhx:%hhx:%hhx:%hhx:%hhx\n", - &info->mac[0], &info->mac[1], &info->mac[2], - &info->mac[3], &info->mac[4], &info->mac[5]) == 6) { - info->_hdr_length += 2; - info->_hdr_length += 6; - } else { - /*parsing fail*/ - memset(info->mac, 0, 6); - } - } else { - memset(info->mac, 0, 6); - rv = ONLP_STATUS_OK; - } - break; - - case TLV_CODE_DEVICE_VERSION: - rv = onlp_file_read((uint8_t*)buf,ONLP_CONFIG_INFO_STR_MAX, &len, INV_SYS_PREFIX"dev_ver"); - if( rv == ONLP_STATUS_OK ) { - info->_hdr_length += 2; - info->device_version= (uint8_t)strtoul(buf, NULL, 0); - info->_hdr_length += 1; - } else { - info->device_version = 0; - rv = ONLP_STATUS_OK; - } - break; - case TLV_CODE_MAC_SIZE: - rv = onlp_file_read((uint8_t*)buf,ONLP_CONFIG_INFO_STR_MAX, &len, INV_SYS_PREFIX"mac_addr"); - if( rv == ONLP_STATUS_OK ) { - info->_hdr_length += 2; - info->mac_range = (uint16_t)strtoul(buf, NULL, 0); - info->_hdr_length += 2; - } else { - info->mac_range = 0; - rv = ONLP_STATUS_OK; - } - break; - - case TLV_CODE_VENDOR_EXT: - list_init(&info->vx_list); - rv = onlp_file_read((uint8_t*)buf,ONLP_CONFIG_INFO_STR_MAX, &len, INV_SYS_PREFIX"vendor_ext"); - if( rv == ONLP_STATUS_OK ) { - /*TODO*/ - } - rv = ONLP_STATUS_OK; - break; - - case TLV_CODE_CRC_32: - rv = onlp_file_read((uint8_t*)buf,ONLP_CONFIG_INFO_STR_MAX, &len, INV_SYS_PREFIX"crc32"); - if( rv == ONLP_STATUS_OK ) { - info->_hdr_length += 2; - info->crc = (uint32_t)strtoul(buf, NULL, 0); - info->_hdr_length += 4; - } else { - info->crc = 0; - rv = ONLP_STATUS_OK; - } - break; - - default: - break; - } - return rv; -} - - -const char* -onlp_sysi_platform_get(void) -{ - return "x86-64-inventec-d5254-r0"; -} - - -/* - * This function is called to return the physical base address - * of the ONIE boot rom. - * - * The ONLP framework will mmap() and parse the ONIE TLV structure - * from the given data. - * - * If you platform does not support a mappable address for the ONIE - * eeprom then you should not provide this function at all. - * - * For the purposes of this example we will provide it but - * return UNSUPPORTED (which is all the default implementation does). - * - */ -int -onlp_sysi_onie_data_phys_addr_get(void** pa) -{ - return ONLP_STATUS_E_UNSUPPORTED; -} - - -/* - * If you cannot provide a base address you must provide the ONLP - * framework the raw ONIE data through whatever means necessary. - * - * This function will be called as a backup in the event that - * onlp_sysi_onie_data_phys_addr_get() fails. - */ -int -onlp_sysi_onie_data_get(uint8_t** data, int* size) -{ -#if 0 - int rv; - int i; - - /* - * This represents the example ONIE data. - */ - static uint8_t onie_data[] = { - 'T', 'l', 'v','I','n','f','o', 0, - 0x1, 0x0, 0x0, - 0x21, 0x8, 'O', 'N', 'L', 'P', 'I', 'E', 0, 0, - 0x22, 0x3, 'O', 'N', 'L', - 0xFE, 0x4, 0x4b, 0x1b, 0x1d, 0xde, - }; - - - memcpy(*data, onie_data, ONLPLIB_CONFIG_I2C_BLOCK_SIZE); - return 0; -#endif - return ONLP_STATUS_E_UNSUPPORTED; -} - -/* - * IF the ONLP frame calles onlp_sysi_onie_data_get(), - * if will call this function to free the data when it - * is finished with it. - * - * This function is optional, and depends on the data - * you return in onlp_sysi_onie_data_get(). - */ -void -onlp_sysi_onie_data_free(uint8_t* data) -{ - /* - * We returned a static array in onlp_sysi_onie_data_get() - * so no free operation is required. - */ - if(data) { - aim_free(data); - } -} - - -int -onlp_sysi_onie_info_get (onlp_onie_info_t *onie) -{ - int rv = ONLP_STATUS_OK; - int i; - onie->_hdr_length = 0; - for(i = 0; i < SYSI_ONIE_TYPE_SUPPORT_NUM; i++) { - if( rv != ONLP_STATUS_OK ) { return rv; } - rv = _parse_tlv(onie, (__tlv_code_list[i])); - - } - - onie->_hdr_id_string = aim_fstrdup("TlvInfo"); - onie->_hdr_version = 0x1; - return rv; -} - - -int -onlp_sysi_platform_info_get(onlp_platform_info_t* pi) -{ - int rv = ONLP_STATUS_OK; - char cpld_str[ONLP_CONFIG_INFO_STR_MAX]= {0}; - char other_str[ONLP_CONFIG_INFO_STR_MAX]= {0}; - char version[ONLP_CONFIG_INFO_STR_MAX]; - pi->cpld_versions = NULL; - pi->other_versions = NULL; - - rv = _sysi_version_parsing(INV_SYSLED_PREFIX"info", "The CPLD version is ", version); - if( rv != ONLP_STATUS_OK ) { return rv; } - snprintf(cpld_str, ONLP_CONFIG_INFO_STR_MAX, "%s%s ", cpld_str, version); - rv = _sysi_version_parsing(INV_HWMON_PREFIX"version", "ver: ", version); - if( rv != ONLP_STATUS_OK ) { return rv; } - snprintf(other_str, ONLP_CONFIG_INFO_STR_MAX, "%s%s.%s " - ,other_str, "psoc", version); - - /*cpld version*/ - if(strlen(cpld_str) > 0) { - pi->cpld_versions = aim_fstrdup("%s",cpld_str); - } - - /*other version*/ - if(strlen(other_str) > 0) { - pi->other_versions = aim_fstrdup("%s",other_str); - } - return rv; -} - -void -onlp_sysi_platform_info_free(onlp_platform_info_t* pi) -{ - if(pi->cpld_versions) { - aim_free(pi->cpld_versions); - } - if(pi->other_versions) { - aim_free(pi->other_versions); - } - return; -} - - -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=0; i - * - * 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) - - -typedef struct thermali_path_s { - char file[ONLP_CONFIG_INFO_STR_MAX]; -} thermali_path_t; - -#define MAKE_THERMAL_PATH_ON_CPU(id) { INV_CTMP_PREFIX"temp"#id"_input"} -#define MAKE_THERMAL_PATH_ON_MAIN_BROAD(id) { INV_HWMON_PREFIX"temp"#id"_input"} -#define MAKE_THERMAL1_PATH_ON_PSU(psu_id) { INV_HWMON_PREFIX"thermal_psu"#psu_id} -#define MAKE_THERMAL2_PATH_ON_PSU(psu_id) { INV_HWMON_PREFIX"thermal2_psu"#psu_id} - -static thermali_path_t __path_list[ONLP_THERMAL_COUNT] = { - MAKE_THERMAL_PATH_ON_CPU(1), - MAKE_THERMAL_PATH_ON_CPU(2), - MAKE_THERMAL_PATH_ON_CPU(3), - MAKE_THERMAL_PATH_ON_CPU(4), - MAKE_THERMAL_PATH_ON_CPU(5), - MAKE_THERMAL_PATH_ON_MAIN_BROAD(1), - MAKE_THERMAL_PATH_ON_MAIN_BROAD(2), - MAKE_THERMAL_PATH_ON_MAIN_BROAD(3), - MAKE_THERMAL_PATH_ON_MAIN_BROAD(4), - MAKE_THERMAL_PATH_ON_MAIN_BROAD(5), - MAKE_THERMAL1_PATH_ON_PSU(1), - MAKE_THERMAL2_PATH_ON_PSU(1), - MAKE_THERMAL1_PATH_ON_PSU(2), - MAKE_THERMAL2_PATH_ON_PSU(2) -}; - -#define MAKE_THERMAL_INFO_NODE_ON_CPU_PHY \ - { { ONLP_THERMAL_ID_CREATE(ONLP_THERMAL_CPU_PHY), "CPU Physical", 0}, \ - ONLP_THERMAL_STATUS_PRESENT, \ - ONLP_THERMAL_CAPS_GET_TEMPERATURE, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS \ - } -#define MAKE_THERMAL_INFO_NODE_ON_CPU_CORE(id) \ - { { ONLP_THERMAL_ID_CREATE(ONLP_THERMAL_CPU_CORE##id), "CPU Core "#id, 0},\ - ONLP_THERMAL_STATUS_PRESENT, \ - ONLP_THERMAL_CAPS_GET_TEMPERATURE, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS \ - } -#define MAKE_THERMAL_INFO_NODE_ON_MAIN_BROAD(id) \ - { { ONLP_THERMAL_ID_CREATE(ONLP_THERMAL_##id##_ON_MAIN_BROAD), "Thermal Sensor "#id, 0}, \ - ONLP_THERMAL_STATUS_PRESENT, \ - ONLP_THERMAL_CAPS_GET_TEMPERATURE, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS \ - } -#define MAKE_THERMAL_INFO_NODE_ON_PSU(thermal_id, psu_id) \ - { { \ - ONLP_THERMAL_ID_CREATE(ONLP_THERMAL_##thermal_id##_ON_PSU##psu_id), \ - "PSU-"#psu_id" Thermal Sensor "#thermal_id, \ - ONLP_PSU_ID_CREATE(ONLP_PSU_##psu_id) \ - }, \ - ONLP_THERMAL_CAPS_GET_TEMPERATURE, 0, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS \ - } - -/* Static values */ -static onlp_thermal_info_t __onlp_thermal_info[ONLP_THERMAL_COUNT] = { - MAKE_THERMAL_INFO_NODE_ON_CPU_PHY, - MAKE_THERMAL_INFO_NODE_ON_CPU_CORE(0), - MAKE_THERMAL_INFO_NODE_ON_CPU_CORE(1), - MAKE_THERMAL_INFO_NODE_ON_CPU_CORE(2), - MAKE_THERMAL_INFO_NODE_ON_CPU_CORE(3), - MAKE_THERMAL_INFO_NODE_ON_MAIN_BROAD(1), - MAKE_THERMAL_INFO_NODE_ON_MAIN_BROAD(2), - MAKE_THERMAL_INFO_NODE_ON_MAIN_BROAD(3), - MAKE_THERMAL_INFO_NODE_ON_MAIN_BROAD(4), - MAKE_THERMAL_INFO_NODE_ON_MAIN_BROAD(5), - MAKE_THERMAL_INFO_NODE_ON_PSU(1,1), - MAKE_THERMAL_INFO_NODE_ON_PSU(2,1), - MAKE_THERMAL_INFO_NODE_ON_PSU(1,2), - MAKE_THERMAL_INFO_NODE_ON_PSU(2,2) -}; - -/* - * 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); - int ret; - - local_id = ONLP_OID_ID_GET(id); - if(local_id >= ONLP_THERMAL_MAX) { - return ONLP_STATUS_E_INVALID; - } - - /* Set the onlp_oid_hdr_t and capabilities */ - *info = __onlp_thermal_info[LOCAL_ID_TO_INFO_IDX(local_id)]; - ret = onlp_thermali_status_get(id, &info->status); - if( ret != ONLP_STATUS_OK ) { return ret; } - - if(info->status & ONLP_THERMAL_STATUS_PRESENT) { - ret = onlp_file_read_int(&info->mcelsius, __path_list[LOCAL_ID_TO_INFO_IDX(local_id)].file); - } - - return ret; -} - - -/** - * @brief Retrieve the thermal's operational status. - * @param id The thermal oid. - * @param rv [out] Receives the operational status. - */ -int onlp_thermali_status_get(onlp_oid_t id, uint32_t* rv) -{ - int local_id; - int ret = ONLP_STATUS_OK; - onlp_thermal_info_t* info; - VALIDATE(id); - uint32_t psu_status; - - local_id = ONLP_OID_ID_GET(id); - if(local_id >= ONLP_THERMAL_MAX) { - return ONLP_STATUS_E_INVALID; - } - info = &__onlp_thermal_info[LOCAL_ID_TO_INFO_IDX(local_id)]; - - switch(local_id) { - case ONLP_THERMAL_1_ON_PSU1: - case ONLP_THERMAL_2_ON_PSU1: - case ONLP_THERMAL_1_ON_PSU2: - case ONLP_THERMAL_2_ON_PSU2: - ret = onlp_psui_status_get((&info->hdr)->poid, &psu_status); - if(ret != ONLP_STATUS_OK) {return ret;} - - if(psu_status & ONLP_PSU_STATUS_PRESENT) { - info->status |= ONLP_THERMAL_STATUS_PRESENT; - } else { - info->status = 0; - } - break; - default: - break; - } - - *rv = info->status; - - return ret; -} - -/** - * @brief Retrieve the thermal's oid header. - * @param id The thermal oid. - * @param rv [out] Receives the header. - */ -int onlp_thermali_hdr_get(onlp_oid_t id, onlp_oid_hdr_t* rv) -{ - int local_id; - onlp_thermal_info_t* info; - VALIDATE(id); - - local_id = ONLP_OID_ID_GET(id); - if(local_id >= ONLP_THERMAL_MAX) { - return ONLP_STATUS_E_INVALID; - } - info = &__onlp_thermal_info[LOCAL_ID_TO_INFO_IDX(local_id)]; - - *rv = info->hdr; - - return ONLP_STATUS_OK; -} diff --git a/packages/platforms/inventec/x86-64/d5254/onlp/builds/x86_64_inventec_d5254/module/src/x86_64_inventec_d5254_config.c b/packages/platforms/inventec/x86-64/d5254/onlp/builds/x86_64_inventec_d5254/module/src/x86_64_inventec_d5254_config.c deleted file mode 100644 index 694c95af6..000000000 --- a/packages/platforms/inventec/x86-64/d5254/onlp/builds/x86_64_inventec_d5254/module/src/x86_64_inventec_d5254_config.c +++ /dev/null @@ -1,81 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#include - -/* */ -#define __x86_64_inventec_d5254_config_STRINGIFY_NAME(_x) #_x -#define __x86_64_inventec_d5254_config_STRINGIFY_VALUE(_x) __x86_64_inventec_d5254_config_STRINGIFY_NAME(_x) -x86_64_inventec_d5254_config_settings_t x86_64_inventec_d5254_config_settings[] = -{ -#ifdef X86_64_INVENTEC_D5254_CONFIG_INCLUDE_LOGGING - { __x86_64_inventec_d5254_config_STRINGIFY_NAME(X86_64_INVENTEC_D5254_CONFIG_INCLUDE_LOGGING), __x86_64_inventec_d5254_config_STRINGIFY_VALUE(X86_64_INVENTEC_D5254_CONFIG_INCLUDE_LOGGING) }, -#else -{ X86_64_INVENTEC_D5254_CONFIG_INCLUDE_LOGGING(__x86_64_inventec_d5254_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_INVENTEC_D5254_CONFIG_LOG_OPTIONS_DEFAULT - { __x86_64_inventec_d5254_config_STRINGIFY_NAME(X86_64_INVENTEC_D5254_CONFIG_LOG_OPTIONS_DEFAULT), __x86_64_inventec_d5254_config_STRINGIFY_VALUE(X86_64_INVENTEC_D5254_CONFIG_LOG_OPTIONS_DEFAULT) }, -#else -{ X86_64_INVENTEC_D5254_CONFIG_LOG_OPTIONS_DEFAULT(__x86_64_inventec_d5254_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_INVENTEC_D5254_CONFIG_LOG_BITS_DEFAULT - { __x86_64_inventec_d5254_config_STRINGIFY_NAME(X86_64_INVENTEC_D5254_CONFIG_LOG_BITS_DEFAULT), __x86_64_inventec_d5254_config_STRINGIFY_VALUE(X86_64_INVENTEC_D5254_CONFIG_LOG_BITS_DEFAULT) }, -#else -{ X86_64_INVENTEC_D5254_CONFIG_LOG_BITS_DEFAULT(__x86_64_inventec_d5254_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_INVENTEC_D5254_CONFIG_LOG_CUSTOM_BITS_DEFAULT - { __x86_64_inventec_d5254_config_STRINGIFY_NAME(X86_64_INVENTEC_D5254_CONFIG_LOG_CUSTOM_BITS_DEFAULT), __x86_64_inventec_d5254_config_STRINGIFY_VALUE(X86_64_INVENTEC_D5254_CONFIG_LOG_CUSTOM_BITS_DEFAULT) }, -#else -{ X86_64_INVENTEC_D5254_CONFIG_LOG_CUSTOM_BITS_DEFAULT(__x86_64_inventec_d5254_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_INVENTEC_D5254_CONFIG_PORTING_STDLIB - { __x86_64_inventec_d5254_config_STRINGIFY_NAME(X86_64_INVENTEC_D5254_CONFIG_PORTING_STDLIB), __x86_64_inventec_d5254_config_STRINGIFY_VALUE(X86_64_INVENTEC_D5254_CONFIG_PORTING_STDLIB) }, -#else -{ X86_64_INVENTEC_D5254_CONFIG_PORTING_STDLIB(__x86_64_inventec_d5254_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_INVENTEC_D5254_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS - { __x86_64_inventec_d5254_config_STRINGIFY_NAME(X86_64_INVENTEC_D5254_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS), __x86_64_inventec_d5254_config_STRINGIFY_VALUE(X86_64_INVENTEC_D5254_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS) }, -#else -{ X86_64_INVENTEC_D5254_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS(__x86_64_inventec_d5254_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_INVENTEC_D5254_CONFIG_INCLUDE_UCLI - { __x86_64_inventec_d5254_config_STRINGIFY_NAME(X86_64_INVENTEC_D5254_CONFIG_INCLUDE_UCLI), __x86_64_inventec_d5254_config_STRINGIFY_VALUE(X86_64_INVENTEC_D5254_CONFIG_INCLUDE_UCLI) }, -#else -{ X86_64_INVENTEC_D5254_CONFIG_INCLUDE_UCLI(__x86_64_inventec_d5254_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_INVENTEC_D5254_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION - { __x86_64_inventec_d5254_config_STRINGIFY_NAME(X86_64_INVENTEC_D5254_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION), __x86_64_inventec_d5254_config_STRINGIFY_VALUE(X86_64_INVENTEC_D5254_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION) }, -#else -{ X86_64_INVENTEC_D5254_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION(__x86_64_inventec_d5254_config_STRINGIFY_NAME), "__undefined__" }, -#endif - { NULL, NULL } -}; -#undef __x86_64_inventec_d5254_config_STRINGIFY_VALUE -#undef __x86_64_inventec_d5254_config_STRINGIFY_NAME - -const char* -x86_64_inventec_d5254_config_lookup(const char* setting) -{ - int i; - for(i = 0; x86_64_inventec_d5254_config_settings[i].name; i++) { - if(!strcmp(x86_64_inventec_d5254_config_settings[i].name, setting)) { - return x86_64_inventec_d5254_config_settings[i].value; - } - } - return NULL; -} - -int -x86_64_inventec_d5254_config_show(struct aim_pvs_s* pvs) -{ - int i; - for(i = 0; x86_64_inventec_d5254_config_settings[i].name; i++) { - aim_printf(pvs, "%s = %s\n", x86_64_inventec_d5254_config_settings[i].name, x86_64_inventec_d5254_config_settings[i].value); - } - return i; -} - -/* */ - diff --git a/packages/platforms/inventec/x86-64/d5254/onlp/builds/x86_64_inventec_d5254/module/src/x86_64_inventec_d5254_enums.c b/packages/platforms/inventec/x86-64/d5254/onlp/builds/x86_64_inventec_d5254/module/src/x86_64_inventec_d5254_enums.c deleted file mode 100644 index c9e1ff620..000000000 --- a/packages/platforms/inventec/x86-64/d5254/onlp/builds/x86_64_inventec_d5254/module/src/x86_64_inventec_d5254_enums.c +++ /dev/null @@ -1,10 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#include - -/* <--auto.start.enum(ALL).source> */ -/* */ - diff --git a/packages/platforms/inventec/x86-64/d5254/onlp/builds/x86_64_inventec_d5254/module/src/x86_64_inventec_d5254_int.h b/packages/platforms/inventec/x86-64/d5254/onlp/builds/x86_64_inventec_d5254/module/src/x86_64_inventec_d5254_int.h deleted file mode 100644 index 23a13acde..000000000 --- a/packages/platforms/inventec/x86-64/d5254/onlp/builds/x86_64_inventec_d5254/module/src/x86_64_inventec_d5254_int.h +++ /dev/null @@ -1,12 +0,0 @@ -/**************************************************************************//** - * - * x86_64_inventec_d5254 Internal Header - * - *****************************************************************************/ -#ifndef __x86_64_inventec_d5254_INT_H__ -#define __x86_64_inventec_d5254_INT_H__ - -#include - - -#endif /* __x86_64_inventec_d5254_INT_H__ */ diff --git a/packages/platforms/inventec/x86-64/d5254/onlp/builds/x86_64_inventec_d5254/module/src/x86_64_inventec_d5254_log.c b/packages/platforms/inventec/x86-64/d5254/onlp/builds/x86_64_inventec_d5254/module/src/x86_64_inventec_d5254_log.c deleted file mode 100644 index 7f2610178..000000000 --- a/packages/platforms/inventec/x86-64/d5254/onlp/builds/x86_64_inventec_d5254/module/src/x86_64_inventec_d5254_log.c +++ /dev/null @@ -1,18 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#include - -#include "x86_64_inventec_d5254_log.h" -/* - * x86_64_inventec_d5254 log struct. - */ -AIM_LOG_STRUCT_DEFINE( - X86_64_INVENTEC_D5254_CONFIG_LOG_OPTIONS_DEFAULT, - X86_64_INVENTEC_D5254_CONFIG_LOG_BITS_DEFAULT, - NULL, /* Custom log map */ - X86_64_INVENTEC_D5254_CONFIG_LOG_CUSTOM_BITS_DEFAULT - ); - diff --git a/packages/platforms/inventec/x86-64/d5254/onlp/builds/x86_64_inventec_d5254/module/src/x86_64_inventec_d5254_log.h b/packages/platforms/inventec/x86-64/d5254/onlp/builds/x86_64_inventec_d5254/module/src/x86_64_inventec_d5254_log.h deleted file mode 100644 index 4e50920e1..000000000 --- a/packages/platforms/inventec/x86-64/d5254/onlp/builds/x86_64_inventec_d5254/module/src/x86_64_inventec_d5254_log.h +++ /dev/null @@ -1,12 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#ifndef __x86_64_inventec_d5254_LOG_H__ -#define __x86_64_inventec_d5254_LOG_H__ - -#define AIM_LOG_MODULE_NAME x86_64_inventec_d5254 -#include - -#endif /* __x86_64_inventec_d5254_LOG_H__ */ diff --git a/packages/platforms/inventec/x86-64/d5254/onlp/builds/x86_64_inventec_d5254/module/src/x86_64_inventec_d5254_module.c b/packages/platforms/inventec/x86-64/d5254/onlp/builds/x86_64_inventec_d5254/module/src/x86_64_inventec_d5254_module.c deleted file mode 100644 index d62d4ff38..000000000 --- a/packages/platforms/inventec/x86-64/d5254/onlp/builds/x86_64_inventec_d5254/module/src/x86_64_inventec_d5254_module.c +++ /dev/null @@ -1,24 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#include - -#include "x86_64_inventec_d5254_log.h" - -static int -datatypes_init__(void) -{ -#define x86_64_inventec_d5254_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_d5254_module_init__(void) -{ - AIM_LOG_STRUCT_REGISTER(); - datatypes_init__(); -} - -int __onlp_platform_version__ = 1; diff --git a/packages/platforms/inventec/x86-64/d5254/onlp/builds/x86_64_inventec_d5254/module/src/x86_64_inventec_d5254_ucli.c b/packages/platforms/inventec/x86-64/d5254/onlp/builds/x86_64_inventec_d5254/module/src/x86_64_inventec_d5254_ucli.c deleted file mode 100644 index bfde22ead..000000000 --- a/packages/platforms/inventec/x86-64/d5254/onlp/builds/x86_64_inventec_d5254/module/src/x86_64_inventec_d5254_ucli.c +++ /dev/null @@ -1,50 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#include - -#if X86_64_INVENTEC_D5254_CONFIG_INCLUDE_UCLI == 1 - -#include -#include -#include - -static ucli_status_t -x86_64_inventec_d5254_ucli_ucli__config__(ucli_context_t* uc) -{ - UCLI_HANDLER_MACRO_MODULE_CONFIG(x86_64_inventec_d5254) -} - -/* */ -/* */ - -static ucli_module_t -x86_64_inventec_d5254_ucli_module__ = - { - "x86_64_inventec_d5254_ucli", - NULL, - x86_64_inventec_d5254_ucli_ucli_handlers__, - NULL, - NULL, - }; - -ucli_node_t* -x86_64_inventec_d5254_ucli_node_create(void) -{ - ucli_node_t* n; - ucli_module_init(&x86_64_inventec_d5254_ucli_module__); - n = ucli_node_create("x86_64_inventec_d5254", NULL, &x86_64_inventec_d5254_ucli_module__); - ucli_node_subnode_add(n, ucli_module_log_node_create("x86_64_inventec_d5254")); - return n; -} - -#else -void* -x86_64_inventec_d5254_ucli_node_create(void) -{ - return NULL; -} -#endif - diff --git a/packages/platforms/inventec/x86-64/d5254/platform-config/Makefile b/packages/platforms/inventec/x86-64/d5254/platform-config/Makefile deleted file mode 100644 index 003238cf6..000000000 --- a/packages/platforms/inventec/x86-64/d5254/platform-config/Makefile +++ /dev/null @@ -1 +0,0 @@ -include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/inventec/x86-64/d5254/platform-config/r0/Makefile b/packages/platforms/inventec/x86-64/d5254/platform-config/r0/Makefile deleted file mode 100644 index 003238cf6..000000000 --- a/packages/platforms/inventec/x86-64/d5254/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/inventec/x86-64/d5254/platform-config/r0/PKG.yml b/packages/platforms/inventec/x86-64/d5254/platform-config/r0/PKG.yml deleted file mode 100644 index b24bf46d9..000000000 --- a/packages/platforms/inventec/x86-64/d5254/platform-config/r0/PKG.yml +++ /dev/null @@ -1 +0,0 @@ -!include $ONL_TEMPLATES/platform-config-platform.yml ARCH=amd64 VENDOR=inventec BASENAME=x86-64-inventec-d5254 REVISION=r0 diff --git a/packages/platforms/inventec/x86-64/d5254/platform-config/r0/src/lib/healthstatus.sh b/packages/platforms/inventec/x86-64/d5254/platform-config/r0/src/lib/healthstatus.sh deleted file mode 100755 index dc38176a0..000000000 --- a/packages/platforms/inventec/x86-64/d5254/platform-config/r0/src/lib/healthstatus.sh +++ /dev/null @@ -1,114 +0,0 @@ -#!/bin/bash -#follow Gulmohar_HW_Specification_V0.8_20180702 -normal='0 : normal' -unpowered='2 : unpowered' -fault='4 : fault' -notinstalled='7 : not installed' -FAN_UNPLUG_NUM=0 -FAN_LED_RED='fan_led_red' -NUM=1 -FAN_NUM=5 -FIRST_READ=0 -SECOND_READ=0 - -PSOC_PATH="" -CPLD_PATH="/sys/bus/i2c/devices/i2c-0/0-0055" -ROUTE="/sys/class/hwmon/" -for KEY in $(ls ${ROUTE}) -do - KEY=${ROUTE}${KEY} - if [ -f $KEY"/name" ]; then - if [ $(cat $KEY"/name") == "inv_psoc" ]; then - PSOC_PATH=$KEY - fi - fi -done -if [[ $PSOC_PATH == "" ]]; then - echo "ERROR! Unable to find inv_psoc!" - exit -fi - - -#PSU_STAUS='000' -#switch is ready , transfer control of cpld to cpu -echo 1 > $CPLD_PATH/ctl - -while true -do - -#monitor how many fan modules are unplugged - - -#first check -FAN_UNPLUG_NUM=0 -FAN_ARR=$(cat $PSOC_PATH/$FAN_LED_RED?) - -while read -r line; do - fan_led_red_check=$(echo "$line") - if [ $fan_led_red_check -eq 1 ] - then - let FAN_UNPLUG_NUM=FAN_UNPLUG_NUM+1 - fi -done <<< "$FAN_ARR" -FIRST_READ=$FAN_UNPLUG_NUM - -#second check -FAN_UNPLUG_NUM=0 -FAN_ARR=$(cat $PSOC_PATH/$FAN_LED_RED?) - -while read -r line; do - fan_led_red_check=$(echo "$line") - if [ $fan_led_red_check -eq 1 ] - then - let FAN_UNPLUG_NUM=FAN_UNPLUG_NUM+1 - fi -done <<< "$FAN_ARR" -SECOND_READ=$FAN_UNPLUG_NUM - -if [ $FIRST_READ -ne $SECOND_READ ] -then - #echo "not equl:$FIRST_READ != $SECOND_READ" - continue -fi - -if [ $FAN_UNPLUG_NUM -ge 2 ] -then - #echo "solid red" - echo 7 > $CPLD_PATH/red_led - echo 0 > $CPLD_PATH/grn_led - sleep 1 - continue -elif [ $FAN_UNPLUG_NUM -eq 1 ] -then - #solid orange - echo 7 > $CPLD_PATH/red_led - echo 7 > $CPLD_PATH/grn_led - sleep 1 - continue -fi - - #echo "normal" - psu0var=$(cat $CPLD_PATH/psu0) # bottom PSU - psu1var=$(cat $CPLD_PATH/psu1) # top PSU - - if [ "$psu0var" = "$normal" ] && - [ "$psu1var" = "$normal" ] # PSU normal operatio - then - #solid green - echo 7 > $CPLD_PATH/grn_led - echo 0 > $CPLD_PATH/red_led - #echo "solid green" - else - if [ "$psu0var" = "$unpowered" ] || - [ "$psu1var" = "$unpowered" ] - then - #echo solid orange - echo 7 > $CPLD_PATH/grn_led - echo 7 > $CPLD_PATH/red_led - fi - fi - - -sleep 1 -done - diff --git a/packages/platforms/inventec/x86-64/d5254/platform-config/r0/src/lib/x86-64-inventec-d5254-r0.yml b/packages/platforms/inventec/x86-64/d5254/platform-config/r0/src/lib/x86-64-inventec-d5254-r0.yml deleted file mode 100644 index e09a3e271..000000000 --- a/packages/platforms/inventec/x86-64/d5254/platform-config/r0/src/lib/x86-64-inventec-d5254-r0.yml +++ /dev/null @@ -1,30 +0,0 @@ ---- - -###################################################################### -# -# platform-config for d5254 -# -###################################################################### - -x86-64-inventec-d5254-r0: - - grub: - - serial: >- - --port=0x3f8 - --speed=115200 - --word=8 - --parity=no - --stop=1 - - kernel: - <<: *kernel-4-14 - args: >- - nopat - console=ttyS0,115200n8 - - ##network - ## interfaces: - ## ma1: - ## name: ~ - ## syspath: pci0000:00/0000:00:14.0 diff --git a/packages/platforms/inventec/x86-64/d5254/platform-config/r0/src/python/x86_64_inventec_d5254_r0/__init__.py b/packages/platforms/inventec/x86-64/d5254/platform-config/r0/src/python/x86_64_inventec_d5254_r0/__init__.py deleted file mode 100644 index 15bda62ae..000000000 --- a/packages/platforms/inventec/x86-64/d5254/platform-config/r0/src/python/x86_64_inventec_d5254_r0/__init__.py +++ /dev/null @@ -1,24 +0,0 @@ -from onl.platform.base import * -from onl.platform.inventec import * - -class OnlPlatform_x86_64_inventec_d5254_r0(OnlPlatformInventec, - OnlPlatformPortConfig_32x100): - PLATFORM='x86-64-inventec-d5254-r0' - MODEL="D5254" - 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('gpio-ich.ko') - self.insmod('i2c-gpio') - self.insmod('inv_platform') - self.insmod('inv_psoc') - os.system("echo inv_cpld 0x55 > /sys/bus/i2c/devices/i2c-0/new_device") - os.system("echo inv_cpld 0x77 > /sys/bus/i2c/devices/i2c-0/new_device") - self.insmod('inv_cpld') - self.insmod('swps') - self.insmod('vpd') - os.system("/lib/platform-config/x86-64-inventec-d5254-r0/onl/healthstatus.sh &") - - return True - diff --git a/packages/platforms/inventec/x86-64/d5264q28b/.gitignore b/packages/platforms/inventec/x86-64/d5264q28b/.gitignore deleted file mode 100644 index 73326b8fe..000000000 --- a/packages/platforms/inventec/x86-64/d5264q28b/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -*x86*64*inventec*d5264q28b*.mk -onlpdump.mk diff --git a/packages/platforms/inventec/x86-64/d5264q28b/Makefile b/packages/platforms/inventec/x86-64/d5264q28b/Makefile deleted file mode 100644 index 003238cf6..000000000 --- a/packages/platforms/inventec/x86-64/d5264q28b/Makefile +++ /dev/null @@ -1 +0,0 @@ -include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/inventec/x86-64/d5264q28b/modules/Makefile b/packages/platforms/inventec/x86-64/d5264q28b/modules/Makefile deleted file mode 100644 index 003238cf6..000000000 --- a/packages/platforms/inventec/x86-64/d5264q28b/modules/Makefile +++ /dev/null @@ -1 +0,0 @@ -include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/inventec/x86-64/d5264q28b/modules/PKG.yml b/packages/platforms/inventec/x86-64/d5264q28b/modules/PKG.yml deleted file mode 100644 index 6b1dc2880..000000000 --- a/packages/platforms/inventec/x86-64/d5264q28b/modules/PKG.yml +++ /dev/null @@ -1 +0,0 @@ -!include $ONL_TEMPLATES/platform-modules.yml VENDOR=inventec BASENAME=x86-64-inventec-d5264q28b ARCH=amd64 KERNELS="onl-kernel-4.14-lts-x86-64-all:amd64" diff --git a/packages/platforms/inventec/x86-64/d5264q28b/modules/builds/.gitignore b/packages/platforms/inventec/x86-64/d5264q28b/modules/builds/.gitignore deleted file mode 100644 index a65b41774..000000000 --- a/packages/platforms/inventec/x86-64/d5264q28b/modules/builds/.gitignore +++ /dev/null @@ -1 +0,0 @@ -lib diff --git a/packages/platforms/inventec/x86-64/d5264q28b/modules/builds/Makefile b/packages/platforms/inventec/x86-64/d5264q28b/modules/builds/Makefile deleted file mode 100644 index 929937f53..000000000 --- a/packages/platforms/inventec/x86-64/d5264q28b/modules/builds/Makefile +++ /dev/null @@ -1,6 +0,0 @@ -KERNELS := onl-kernel-4.14-lts-x86-64-all:amd64 -KMODULES := src -VENDOR := inventec -BASENAME := x86-64-inventec-d5264q28b -ARCH := x86_64 -include $(ONL)/make/kmodule.mk diff --git a/packages/platforms/inventec/x86-64/d5264q28b/modules/builds/src/Makefile b/packages/platforms/inventec/x86-64/d5264q28b/modules/builds/src/Makefile deleted file mode 100644 index b66e92382..000000000 --- a/packages/platforms/inventec/x86-64/d5264q28b/modules/builds/src/Makefile +++ /dev/null @@ -1,6 +0,0 @@ -obj-m += inv_cpld.o -obj-m += inv_platform.o -obj-m += inv_psoc.o -obj-m += inv_eeprom.o -obj-m += swps.o -swps-objs := inv_swps.o inv_mux.o io_expander.o transceiver.o diff --git a/packages/platforms/inventec/x86-64/d5264q28b/modules/builds/src/inv_cpld.c b/packages/platforms/inventec/x86-64/d5264q28b/modules/builds/src/inv_cpld.c deleted file mode 100644 index 57791f62e..000000000 --- a/packages/platforms/inventec/x86-64/d5264q28b/modules/builds/src/inv_cpld.c +++ /dev/null @@ -1,463 +0,0 @@ -/* - * 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 -#define CPLD_BIOSCS_OFFSET 0x04 - - -/* 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 ssize_t show_bios_cs(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_BIOSCS_OFFSET, 1); - - mutex_unlock(&data->update_lock); - - if(status != 1) return sprintf(buf, "read cpld BIOS_CS fail\n"); - - - status = sprintf (buf, "0x%X\n", b[0] & 0x01); - - return strlen(buf); -} - -static ssize_t set_bios_cs(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_BIOSCS_OFFSET, 1); - if(temp) byte |= 0x01; - else byte &= ~(0x01); - cpld_i2c_write(client, &byte, CPLD_BIOSCS_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 SENSOR_DEVICE_ATTR(bios_cs, S_IWUSR|S_IRUGO, show_bios_cs, set_bios_cs, 0); - -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, - - &sensor_dev_attr_bios_cs.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/d5264q28b/modules/builds/src/inv_eeprom.c b/packages/platforms/inventec/x86-64/d5264q28b/modules/builds/src/inv_eeprom.c deleted file mode 100644 index 7bb167d2e..000000000 --- a/packages/platforms/inventec/x86-64/d5264q28b/modules/builds/src/inv_eeprom.c +++ /dev/null @@ -1,181 +0,0 @@ -/* - * 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 -#include - - -/* Size of EEPROM in bytes */ -#define EEPROM_SIZE 256 - -#define SLICE_BITS (6) -#define SLICE_SIZE (1 << SLICE_BITS) -#define SLICE_NUM (EEPROM_SIZE/SLICE_SIZE) - -/* Each client has this additional data */ -struct eeprom_data { - struct mutex update_lock; - u8 valid; /* bitfield, bit!=0 if slice is valid */ - unsigned long last_updated[SLICE_NUM]; /* In jiffies, 8 slices */ - u8 data[EEPROM_SIZE]; /* Register values */ -}; - - -static void inv_eeprom_update_client(struct i2c_client *client, u8 slice) -{ - struct eeprom_data *data = i2c_get_clientdata(client); - int i, j; - int ret; - int addr; - - - mutex_lock(&data->update_lock); - - if (!(data->valid & (1 << slice)) || - time_after(jiffies, data->last_updated[slice] + 300 * HZ)) { - dev_dbg(&client->dev, "Starting eeprom update, slice %u\n", slice); - - addr = slice << SLICE_BITS; - - ret = i2c_smbus_write_byte_data(client, ((u8)addr >> 8) & 0xFF, (u8)addr & 0xFF); - /* select the eeprom address */ - if (ret < 0) { - dev_err(&client->dev, "address set failed\n"); - goto exit; - } - - if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_READ_BYTE)) { - goto exit; - } - - for (i = slice << SLICE_BITS; i < (slice + 1) << SLICE_BITS; i+= SLICE_SIZE) { - for (j = i; j < (i+SLICE_SIZE); j++) { - int res; - - res = i2c_smbus_read_byte(client); - if (res < 0) { - goto exit; - } - - data->data[j] = res & 0xFF; - } - } - - data->last_updated[slice] = jiffies; - data->valid |= (1 << slice); - } - -exit: - mutex_unlock(&data->update_lock); -} - -static ssize_t inv_eeprom_read(struct file *filp, struct kobject *kobj, - struct bin_attribute *bin_attr, - char *buf, loff_t off, size_t count) -{ - struct i2c_client *client = to_i2c_client(container_of(kobj, struct device, kobj)); - struct eeprom_data *data = i2c_get_clientdata(client); - u8 slice; - - - if (off > EEPROM_SIZE) { - return 0; - } - if (off + count > EEPROM_SIZE) { - count = EEPROM_SIZE - off; - } - if (count == 0) { - return 0; - } - - /* Only refresh slices which contain requested bytes */ - for (slice = off >> SLICE_BITS; slice <= (off + count - 1) >> SLICE_BITS; slice++) { - inv_eeprom_update_client(client, slice); - } - - memcpy(buf, &data->data[off], count); - - return count; -} - -static struct bin_attribute inv_eeprom_attr = { - .attr = { - .name = "eeprom", - .mode = S_IRUGO, - }, - .size = EEPROM_SIZE, - .read = inv_eeprom_read, -}; - -static int inv_eeprom_probe(struct i2c_client *client, - const struct i2c_device_id *id) -{ - struct eeprom_data *data; - int err; - - if (!(data = kzalloc(sizeof(struct eeprom_data), GFP_KERNEL))) { - err = -ENOMEM; - goto exit; - } - - memset(data->data, 0xff, EEPROM_SIZE); - i2c_set_clientdata(client, data); - mutex_init(&data->update_lock); - - /* create the sysfs eeprom file */ - err = sysfs_create_bin_file(&client->dev.kobj, &inv_eeprom_attr); - if (err) { - goto exit_kfree; - } - - return 0; - -exit_kfree: - kfree(data); -exit: - return err; -} - -static int inv_eeprom_remove(struct i2c_client *client) -{ - sysfs_remove_bin_file(&client->dev.kobj, &inv_eeprom_attr); - kfree(i2c_get_clientdata(client)); - - return 0; -} - -static const struct i2c_device_id inv_eeprom_id[] = { - { "inv_eeprom", 0 }, - { } -}; - -static struct i2c_driver inv_eeprom_driver = { - .driver = { - .name = "inv_eeprom", - }, - .probe = inv_eeprom_probe, - .remove = inv_eeprom_remove, - .id_table = inv_eeprom_id, -}; - -module_i2c_driver(inv_eeprom_driver); - -MODULE_AUTHOR("Inventec"); -MODULE_DESCRIPTION("Inventec D6556 Mother Board EEPROM driver"); -MODULE_LICENSE("GPL"); - - diff --git a/packages/platforms/inventec/x86-64/d5264q28b/modules/builds/src/inv_mux.c b/packages/platforms/inventec/x86-64/d5264q28b/modules/builds/src/inv_mux.c deleted file mode 100644 index 40593a96e..000000000 --- a/packages/platforms/inventec/x86-64/d5264q28b/modules/builds/src/inv_mux.c +++ /dev/null @@ -1,545 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include "io_expander.h" -#include "inv_mux.h" - -/* For build single module using (Ex: ONL platform) */ -#include -//#include -//#include - -static struct mux_obj_s *mux_head_p = NULL; - -/* ========== MUX object functions ========== - */ -static int -_setup_i2c_value(struct mux_obj_s *self, int offset, int value){ - - return i2c_smbus_write_byte_data(self->i2c_client_p, offset, value); -} - - -static int -_setup_i2c_client(struct mux_obj_s *self, int chan_id, int addr){ - - struct i2c_adapter *adap = NULL; - char *emsg = "ERR"; - - adap = i2c_get_adapter(chan_id); - if (!adap){ - emsg = "can't get adapter"; - goto err_setup_i2c_client; - } - self->i2c_client_p = kzalloc(sizeof(*self->i2c_client_p), GFP_KERNEL); - if (!self->i2c_client_p){ - emsg = "can't kzalloc client"; - goto err_setup_i2c_client; - } - self->i2c_client_p->adapter = adap; - self->i2c_client_p->addr = addr; - return 0; - -err_setup_i2c_client: - SWPS_ERR("%s: %s\n", __func__, emsg); - return ERR_MUX_UNEXCPT; -} - - -int -_common_force_pull_gpio(int mem_addr, - int input, - int bit_offset){ - - unsigned int val = 0; - unsigned int targ = 0; - - /* Get current value */ - val = inl(mem_addr); - if (val == 0) { - SWPS_ERR("%s: inl:%d fail!\n", __func__, val); - return -1; - } - /* Count target value */ - switch (input) { - case 0: /* Pull Low */ - targ = (val & (~(1 << bit_offset))); - break; - case 1: /* Pull high */ - targ = (val | (1 << bit_offset)); - break; - default: - SWPS_ERR("%s: input state:%d incorrect!\n", - __func__, input); - return -1; - } - /* Setup gpio */ - outl(targ, mem_addr); - if (targ != inl(mem_addr)){ - SWPS_ERR("%s: outl:%d fail!\n", __func__, targ); - return -1; - } - SWPS_DEBUG("%s: done.\n", __func__); - return 0; -} - - -int -rangeley_force_pull_high(struct mux_obj_s *self){ - SWPS_ERR("%s: not ready!\n", __func__); - return -1; -} - - -int -rangeley_force_pull_low(struct mux_obj_s *self){ - SWPS_ERR("%s: not ready!\n", __func__); - return -1; -} - - -int -hedera_force_pull_high(struct mux_obj_s *self){ - return _common_force_pull_gpio(MUX_RST_MEM_ADDR_HEDERA, 1, 5); -} - - -int -hedera_force_pull_low(struct mux_obj_s *self){ - return _common_force_pull_gpio(MUX_RST_MEM_ADDR_HEDERA, 0, 5); -} - - -int -normal_gpio_pull_high(struct mux_obj_s *self){ - return gpio_direction_output(self->gpio_num, 1); -} - - -int -normal_gpio_pull_low(struct mux_obj_s *self){ - return gpio_direction_output(self->gpio_num, 0); -} - - -int -cpld_rst_all_4_pull_low(struct mux_obj_s *self){ - - char *emsg = "ERR"; - int err = ERR_MUX_UNEXCPT; - - switch(self->gpio_num) { - case MUX_RST_CPLD_C0_A77_70_74_RST_ALL: - goto setlow_cpld_rst_all_4_c0_a77_70_74_rst_all; - - default: - break; - } - emsg = "Undefined case"; - goto err_cpld_rst_all_4_pull_low; - -setlow_cpld_rst_all_4_c0_a77_70_74_rst_all: - err = _setup_i2c_value(self, 0x70, 0x0); - if (err < 0) { - emsg = "setup 0x70 fail"; - goto err_cpld_rst_all_4_pull_low; - } - err = _setup_i2c_value(self, 0x74, 0x01); - if (err < 0) { - emsg = "setup 0x74 fail"; - goto err_cpld_rst_all_4_pull_low; - } - return 0; - -err_cpld_rst_all_4_pull_low: - SWPS_INFO("%s: %s :%d :%d\n", - __func__, emsg, self->gpio_num, err); - return ERR_MUX_UNEXCPT; -} - - -int -cpld_rst_all_4_pull_high(struct mux_obj_s *self){ - - char *emsg = "ERR"; - int err = ERR_MUX_UNEXCPT; - - switch(self->gpio_num) { - case MUX_RST_CPLD_C0_A77_70_74_RST_ALL: - goto sethigh_cpld_rst_all_4_c0_a77_70_74_rst_all; - - default: - break; - } - emsg = "Undefined case"; - goto err_cpld_rst_all_4_pull_high; - -sethigh_cpld_rst_all_4_c0_a77_70_74_rst_all: - err = _setup_i2c_value(self, 0x70, 0xfe); - if (err < 0) { - emsg = "setup 0x70 fail"; - goto err_cpld_rst_all_4_pull_high; - } - err = _setup_i2c_value(self, 0x74, 0x03); - if (err < 0) { - emsg = "setup 0x74 fail"; - goto err_cpld_rst_all_4_pull_high; - } - return 0; - -err_cpld_rst_all_4_pull_high: - SWPS_INFO("%s: %s :%d :%d\n", - __func__, emsg, self->gpio_num, err); - return ERR_MUX_UNEXCPT; -} - - -int -pca9548_reset_mux_all(struct mux_obj_s *self){ - /* [Note] Power-on reset (PCA9548A-NXP) - * When power is applied to VDD, an internal Power-On Reset (POR) - * holds the PCA9548A in a reset condition until VDD has reached - * VPOR. At this point, the reset condition is released and the - * PCA9548A register and I2C-bus state machine are initialized to - * their default states (all zeroes) causing all the channels to - * be deselected. Thereafter, VDD must be lowered below 0.2 V for - * at least 5 us in order to reset the device. - */ - if (self->_pull_low(self) < 0) { - SWPS_ERR("%s: _pull_low fail!\n", __func__); - return -1; - } - mdelay(MUX_RST_WAIT_MS_PCA9548); - if (self->_pull_high(self) < 0) { - SWPS_ERR("%s: _pull_high fail!\n", __func__); - return -1; - } - mdelay(MUX_RST_WAIT_MS_PCA9548); - return 0; -} - - -int -cpld_reset_mux_all(struct mux_obj_s *self){ - - char *emsg = "ERR"; - int err = ERR_MUX_UNEXCPT; - - switch(self->gpio_num) { - case MUX_RST_CPLD_C0_A77_70_74_RST_ALL: - goto reset_cpld_rst_all_4_c0_a77_70_74_rst_all; - - default: - break; - } - emsg = "Undefined case"; - goto err_cpld_reset_mux_all; - -reset_cpld_rst_all_4_c0_a77_70_74_rst_all: - if (self->_pull_low(self) < 0) { - emsg = "_pull_low fail"; - goto err_cpld_reset_mux_all; - } - mdelay(MUX_RST_WAIT_MS_CPLD); - return 0; - -err_cpld_reset_mux_all: - SWPS_INFO("%s: %s :%d :%d\n", - __func__, emsg, self->gpio_num, err); - return ERR_MUX_UNEXCPT; -} - - -int -common_reset_mux_all(struct mux_obj_s *self){ - SWPS_ERR("%s: not ready!\n", __func__); - return -1; -} - - -int -init_gpio_4_force(struct mux_obj_s *self){ - - if (self->_pull_high(self) < 0) { - SWPS_ERR("%s: setup default fail!\n", __func__); - return -1; - } - return 0; -} - - -int -init_gpio_4_normal(struct mux_obj_s *self){ - - int err = 0; - char *emsg = "ERR"; - - if (!gpio_is_valid(self->gpio_num)) { - emsg = "GPIO invalid"; - goto err_init_gpio_4_normal; - } - err = gpio_request(self->gpio_num, MUX_GPIO_LABEL); - if (err < 0) { - emsg = "gpio_request fail"; - goto err_init_gpio_4_normal; - } - err = self->_pull_high(self); - if (err < 0) { - emsg = "setup default fail"; - goto err_init_gpio_4_normal; - } - SWPS_DEBUG("%s: gpio_request:%d ok.\n", __func__, self->gpio_num); - return 0; - -err_init_gpio_4_normal: - SWPS_ERR("%s: %s :%d :%d\n", - __func__, emsg, self->gpio_num, err); - return -1; -} - - -int -init_cpld_4_rst_all(struct mux_obj_s *self){ - - char *emsg = "ERR"; - int err = ERR_MUX_UNEXCPT; - int chan = ERR_MUX_UNEXCPT; - int addr = ERR_MUX_UNEXCPT; - - switch(self->gpio_num) { - case MUX_RST_CPLD_C0_A77_70_74_RST_ALL: - goto init_cpld_i2c_c0_a77_70_74_rst_all; - - default: - break; - } - emsg = "Undefined case"; - goto err_init_cpld_4_rst_all; - -init_cpld_i2c_c0_a77_70_74_rst_all: - chan = 0; - addr = 0x77; - err = _setup_i2c_client(self, chan, addr); - if (err < 0) { - emsg = "_setup_i2c_client fail"; - goto err_init_cpld_4_rst_all; - } - err = self->_pull_high(self); - if (err < 0) { - emsg = "setup default value fail"; - goto err_init_cpld_4_rst_all; - } - SWPS_DEBUG("%s: init_cpld_i2c_c0_a77_70_74_rst_all ok", __func__); - return 0; - -err_init_cpld_4_rst_all: - SWPS_INFO("%s: %s :%d :%d\n", - __func__, emsg, self->gpio_num, err); - return ERR_MUX_UNEXCPT; -} - - -int -clean_gpio_4_common(struct mux_obj_s *self){ - - if (!self) return 0; - if (!gpio_is_valid(self->gpio_num)) return 0; - self->_pull_high(self); - gpio_free(mux_head_p->gpio_num); - return 0; -} - - -int -clean_cpld_4_rst_all(struct mux_obj_s *self){ - - if (!self) return 0; - self->_pull_high(self); - if (self->i2c_client_p) { - i2c_put_adapter(self->i2c_client_p->adapter); - kfree(self->i2c_client_p); - } - return 0; -} - - -static int -_setup_muxctl_cb(struct mux_obj_s *self, - unsigned gpio){ - - char mod_dsc[32] = "ERR"; - - switch (gpio) { - case MUX_RST_GPIO_FORCE_RANGELEY: - self->gpio_num = gpio; - self->_pull_low = rangeley_force_pull_low; - self->_pull_high = rangeley_force_pull_high; - self->_init = init_gpio_4_force; - self->_clean = clean_gpio_4_common; - self->reset = pca9548_reset_mux_all; - memset(mod_dsc, 0, 32); - snprintf(mod_dsc, 31, "Rangeley force mode"); - goto ok_setup_muxctl_cb; - - case MUX_RST_GPIO_FORCE_HEDERA: - self->gpio_num = gpio; - self->_pull_low = hedera_force_pull_low; - self->_pull_high = hedera_force_pull_high; - self->_init = init_gpio_4_force; - self->_clean = clean_gpio_4_common; - self->reset = pca9548_reset_mux_all; - memset(mod_dsc, 0, 32); - snprintf(mod_dsc, 31, "Hedera force mode"); - goto ok_setup_muxctl_cb; - - case MUX_RST_GPIO_48_PCA9548: - case MUX_RST_GPIO_69_PCA9548: - case MUX_RST_GPIO_249_PCA9548: - case MUX_RST_GPIO_500_PCA9548: - case MUX_RST_GPIO_505_PCA9548: - self->gpio_num = gpio; - self->_pull_low = normal_gpio_pull_low; - self->_pull_high = normal_gpio_pull_high; - self->_init = init_gpio_4_normal; - self->_clean = clean_gpio_4_common; - self->reset = pca9548_reset_mux_all; - memset(mod_dsc, 0, 32); - snprintf(mod_dsc, 31, "Normal mode :%d", (int)gpio); - goto ok_setup_muxctl_cb; - - case MUX_RST_CPLD_C0_A77_70_74_RST_ALL: - self->gpio_num = gpio; - self->_pull_low = cpld_rst_all_4_pull_low; - self->_pull_high = cpld_rst_all_4_pull_high; - self->_init = init_cpld_4_rst_all; - self->_clean = clean_cpld_4_rst_all; - self->reset = cpld_reset_mux_all; - memset(mod_dsc, 0, 32); - snprintf(mod_dsc, 31, "CPLD mode :%d", (int)gpio); - goto ok_setup_muxctl_cb; - - default: - break; - } - SWPS_ERR("%s: Unexpected GPIO:%d\n", __func__, gpio); - return -1; - -ok_setup_muxctl_cb: - SWPS_INFO("muxctl: %s.\n", mod_dsc); - return 0; -} - - -/* ========== MUX public functions ========== - */ -void -clean_mux_objs(void){ - - struct mux_obj_s *curr_p = mux_head_p; - struct mux_obj_s *next_p = NULL; - - if (!curr_p) { - SWPS_DEBUG("%s: mux_head_p is NULL\n", __func__); - return; - } - while (curr_p) { - next_p = curr_p->next; - curr_p->_clean(curr_p); - kfree(curr_p); - curr_p = next_p; - } - SWPS_DEBUG("%s: done.\n", __func__); -} -EXPORT_SYMBOL(clean_mux_objs); - - -int -reset_mux_objs(void){ - - if (!mux_head_p) { - SWPS_ERR("%s: MUX ctl object doesn't exist!\n", __func__); - return -1; - } - if (mux_head_p->reset(mux_head_p) < 0){ - SWPS_ERR("%s: reset fail!\n", __func__); - return -1; - } - return 0; -} -EXPORT_SYMBOL(reset_mux_objs); - - -struct mux_obj_s * -_create_mux_obj(unsigned gpio){ - - char *emsg = "ERR"; - struct mux_obj_s *obj_p = NULL; - - obj_p = kzalloc(sizeof(struct mux_obj_s), GFP_KERNEL); - if (!obj_p) { - emsg = "kzalloc fail!"; - goto err_create_mux_obj_1; - } - if (_setup_muxctl_cb(obj_p, gpio) < 0){ - emsg = "_setup_muxctl_cb fail!"; - goto err_create_mux_obj_2; - } - if (obj_p->_init(obj_p) < 0) { - emsg = "_init() fail!"; - goto err_create_mux_obj_2; - } - SWPS_DEBUG("%s: created MUX object :%d\n", __func__, gpio); - return obj_p; - -err_create_mux_obj_2: - kfree(obj_p); -err_create_mux_obj_1: - SWPS_ERR("%s: %s :%d\n", __func__, emsg, gpio); - return NULL; -} - - -int -init_mux_objs(unsigned gpio){ - - struct mux_obj_s *curr_p = NULL; - char *emsg = "ERR"; - - /* Create MUX control object */ - if (mux_head_p) { - SWPS_DEBUG("%s: mux_head_p is not NULL!\n", __func__); - clean_mux_objs(); - } - /* Currently, it is using single muxctl architecture. - * In the future, it may use the multi-muxctl. - * (Ex: Gulmohar's advance I2C control / Peony's reset single mux) - */ - curr_p = _create_mux_obj(gpio); - if (!curr_p) { - emsg = "_create_mux_obj fail"; - goto err_init_mux_objs; - } - curr_p->next = NULL; - mux_head_p = curr_p; - SWPS_DEBUG("%s: all done. :%d\n", __func__, gpio); - return 0; - -err_init_mux_objs: - clean_mux_objs(); - SWPS_ERR("%s: %s\n", __func__, emsg); - return -1; -} -EXPORT_SYMBOL(init_mux_objs); - - -/* For single ko module - * => You need to declare MODULE_LICENSE If you want to build single module along. - * => Ex: For ONL platform - */ -MODULE_LICENSE("GPL"); - - - diff --git a/packages/platforms/inventec/x86-64/d5264q28b/modules/builds/src/inv_mux.h b/packages/platforms/inventec/x86-64/d5264q28b/modules/builds/src/inv_mux.h deleted file mode 100644 index a913b24c6..000000000 --- a/packages/platforms/inventec/x86-64/d5264q28b/modules/builds/src/inv_mux.h +++ /dev/null @@ -1,51 +0,0 @@ -#ifndef INV_MUX_H -#define INV_MUX_H - -#include - -/* MUX basic information */ -#define MUX_GPIO_LABEL "SWPS_RST_MUX" - -/* MUX reset GPIO define */ -#define MUX_RST_GPIO_FORCE (30100) -#define MUX_RST_GPIO_FORCE_RANGELEY (30101) -#define MUX_RST_GPIO_FORCE_HEDERA (30102) -#define MUX_RST_GPIO_48_PCA9548 (48) -#define MUX_RST_GPIO_69_PCA9548 (69) -#define MUX_RST_GPIO_249_PCA9548 (249) -#define MUX_RST_GPIO_500_PCA9548 (500) -#define MUX_RST_GPIO_505_PCA9548 (505) -#define MUX_RST_CPLD_C0_A77_70_74_RST_ALL (30201) - -/* MUX relate value define */ -#define MUX_RST_WAIT_MS_PCA9548 (1) -#define MUX_RST_WAIT_MS_CPLD (10) -#define MUX_RST_MEM_ADDR_RANGELEY (0) // TBD -#define MUX_RST_MEM_ADDR_HEDERA (0x548) - -/* MUX error code define */ -#define ERR_MUX_UNEXCPT (-399) - -struct mux_obj_s { - struct i2c_client *i2c_client_p; - struct mux_obj_s *next; - unsigned gpio_num; - int (*_pull_high)(struct mux_obj_s *self); - int (*_pull_low)(struct mux_obj_s *self); - int (*_init)(struct mux_obj_s *self); - int (*_clean)(struct mux_obj_s *self); - int (*reset)(struct mux_obj_s *self); -}; - - -void clean_mux_objs(void); -int reset_mux_objs(void); -int init_mux_objs(unsigned gpio); - - -#endif /* INV_MUX_H */ - - - - - diff --git a/packages/platforms/inventec/x86-64/d5264q28b/modules/builds/src/inv_platform.c b/packages/platforms/inventec/x86-64/d5264q28b/modules/builds/src/inv_platform.c deleted file mode 100644 index 680ab308b..000000000 --- a/packages/platforms/inventec/x86-64/d5264q28b/modules/builds/src/inv_platform.c +++ /dev/null @@ -1,285 +0,0 @@ -#include -#include -//#include -#include -#include -#include -#include -#include - -#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,14,0) -#include -#else -#include -#endif -#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(1),}, {.adap_id = bus_id(2),}, - {.adap_id = bus_id(3),}, {.adap_id = bus_id(4),}, - {.adap_id = bus_id(5),}, {.adap_id = bus_id(8),}, -}; -static struct pca954x_platform_mode mux_modes_0_0[] = { - {.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),}, {.adap_id = bus_id(22),}, - {.adap_id = bus_id(23),}, {.adap_id = bus_id(24),}, -}; - -static struct pca954x_platform_mode mux_modes_0_1[] = { - {.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),}, {.adap_id = bus_id(30),}, - {.adap_id = bus_id(31),}, {.adap_id = bus_id(32),}, -}; - -static struct pca954x_platform_mode mux_modes_0_2[] = { - {.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),}, {.adap_id = bus_id(38),}, - {.adap_id = bus_id(39),}, {.adap_id = bus_id(40),}, -}; - -static struct pca954x_platform_mode mux_modes_0_3[] = { - {.adap_id = bus_id(41),}, {.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),}, -}; - - -static struct pca954x_platform_mode mux_modes_0_7[] = { - {.adap_id = bus_id(9),}, {.adap_id = bus_id(10),}, - {.adap_id = bus_id(11),}, {.adap_id = bus_id(12),}, -}; -static struct pca954x_platform_mode mux_modes_0_7_0[] = { - {.adap_id = bus_id(49),}, {.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),}, -}; - -static struct pca954x_platform_mode mux_modes_0_7_1[] = { - {.adap_id = bus_id(57),}, {.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),}, -}; - -static struct pca954x_platform_mode mux_modes_0_7_2[] = { - {.adap_id = bus_id(65),}, {.adap_id = bus_id(66),}, - {.adap_id = bus_id(67),}, {.adap_id = bus_id(68),}, - {.adap_id = bus_id(69),}, {.adap_id = bus_id(70),}, - {.adap_id = bus_id(71),}, {.adap_id = bus_id(72),}, -}; - -static struct pca954x_platform_mode mux_modes_0_7_3[] = { - {.adap_id = bus_id(73),}, {.adap_id = bus_id(74),}, - {.adap_id = bus_id(75),}, {.adap_id = bus_id(76),}, - {.adap_id = bus_id(77),}, {.adap_id = bus_id(78),}, - {.adap_id = bus_id(79),}, {.adap_id = bus_id(80),}, -}; - - -static struct pca954x_platform_data mux_data_0 = { - .modes = mux_modes_0, - .num_modes = 6, -}; -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_7 = { - .modes = mux_modes_0_7, - .num_modes = 4, -}; -static struct pca954x_platform_data mux_data_0_7_0 = { - .modes = mux_modes_0_7_0, - .num_modes = 8, -}; -static struct pca954x_platform_data mux_data_0_7_1 = { - .modes = mux_modes_0_7_1, - .num_modes = 8, -}; -static struct pca954x_platform_data mux_data_0_7_2 = { - .modes = mux_modes_0_7_2, - .num_modes = 8, -}; -static struct pca954x_platform_data mux_data_0_7_3 = { - .modes = mux_modes_0_7_3, - .num_modes = 8, -}; - - -static struct i2c_board_info i2c_device_info0[] __initdata = { - {"inv_cpld", 0, 0x55, 0, 0, 0}, - {"pca9548", 0, 0x70, &mux_data_0, 0, 0}, -}; - -static struct i2c_board_info i2c_device_info1[] __initdata = { - {"pca9548", 0, 0x72, &mux_data_0_0, 0, 0}, -}; - -static struct i2c_board_info i2c_device_info2[] __initdata = { - {"pca9548", 0, 0x72, &mux_data_0_1, 0, 0}, -}; - -static struct i2c_board_info i2c_device_info3[] __initdata = { - {"pca9548", 0, 0x72, &mux_data_0_2, 0, 0}, -}; - -static struct i2c_board_info i2c_device_info4[] __initdata = { - {"pca9548", 0, 0x72, &mux_data_0_3, 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_info8[] __initdata = { - {"inv_cpld", 0, 0x77, 0, 0, 0}, - {"pca9548", 0, 0x71, &mux_data_0_7, 0, 0}, -}; - -static struct i2c_board_info i2c_device_info9[] __initdata = { - {"pca9548", 0, 0x72, &mux_data_0_7_0, 0, 0}, -}; - -static struct i2c_board_info i2c_device_info10[] __initdata = { - {"pca9548", 0, 0x72, &mux_data_0_7_1, 0, 0}, -}; - -static struct i2c_board_info i2c_device_info11[] __initdata = { - {"pca9548", 0, 0x72, &mux_data_0_7_2, 0, 0}, -}; - -static struct i2c_board_info i2c_device_info12[] __initdata = { - {"pca9548", 0, 0x72, &mux_data_0_7_3, 0, 0}, -}; - -static struct inv_i2c_board_info i2cdev_list[] = { - {0, ARRAY_SIZE(i2c_device_info0), i2c_device_info0 }, //smbus 0, mux0 - {8, ARRAY_SIZE(i2c_device_info8), i2c_device_info8 }, //mux9 - - {bus_id(1), ARRAY_SIZE(i2c_device_info1), i2c_device_info1 }, //mux1 - {bus_id(2), ARRAY_SIZE(i2c_device_info2), i2c_device_info2 }, //mux2 - {bus_id(3), ARRAY_SIZE(i2c_device_info3), i2c_device_info3 }, //mux3 - {bus_id(4), ARRAY_SIZE(i2c_device_info4), i2c_device_info4 }, //mux4 - {bus_id(5), ARRAY_SIZE(i2c_device_info5), i2c_device_info5 }, - - {bus_id(9), ARRAY_SIZE(i2c_device_info9), i2c_device_info9 }, //mux5 - {bus_id(10), ARRAY_SIZE(i2c_device_info10), i2c_device_info10 }, //mux6 - {bus_id(11), ARRAY_SIZE(i2c_device_info11), i2c_device_info11 }, //mux7 - {bus_id(12), ARRAY_SIZE(i2c_device_info12), i2c_device_info12 }, //mux8 -}; - -///////////////////////////////////////////////////////////////////////////////////////// -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_lavender_x86_init(void) -{ - struct i2c_adapter *adap = NULL; - struct i2c_client *e = NULL; - int ret = 0; - int i,j; - - printk("el6661 plat_lavender_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 -#include -#include -#define SWITCH_TEMPERATURE_SOCK "/proc/switch/temp" -#define PSOC_POLLING_PERIOD 1000 - -#include -#include -#include -#include - -#define IPMI_MAX_INTF (4) -#define NETFN_OEM 0x30 -#define CMD_GETDATA 0x31 -#define CMD_SETDATA 0x32 -#define FAN_NUM 4 -#define PSU_NUM 2 - -#define FAN_CLEI_SUPPORT 0 -#define PSU_CLEI_SUPPORT 0 - -#define PSU1 0x5800 -#define PSU2 0x5900 -#define BMC_PMBusNumber 3 -#define PMBus_Vendor 0x99 -#define PMBus_Serial 0x9E -#define PMBus_Temp2 0x8E -#define PMBus_Version 0x9B -#define MaxLeng_Result 0x40 - -#define BMC_FanCLEIBusNumber 9 -#define DEVICE_CLEI_ADDR 0x52,0x53,0x54,0x55,0x56,0x50,0x51 - -#define MAX_IPMI_RECV_LENGTH 0xff -static char CLEI_ADDR[]={DEVICE_CLEI_ADDR}; -struct task_struct *kthread_auto_update; -static long pmbus_reg2data_linear(int data, int linear16); -struct ipmi_result{ - char result[MAX_IPMI_RECV_LENGTH]; - int result_length; -}; - -DEFINE_MUTEX(ipmi_mutex); -DEFINE_MUTEX(ipmi2_mutex); -static struct ipmi_result ipmiresult; -static struct device *hwmon_dev; -static struct kobject *device_kobj; -static ipmi_user_t ipmi_mh_user = NULL; -static void msg_handler(struct ipmi_recv_msg *msg,void* handler_data); -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 -}; - -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__)) clei { - u8 issue_number[3]; - u8 abbreviation_number[9]; - u8 fc_number[10]; - u8 clei_code[10]; - u8 product_year_and_month[5]; - u8 label_location_code[2]; - u8 serial_number[5]; - u8 pcb_revision[5]; - u8 vendor_name[10]; - u8 reserved[5]; -}; - -struct __attribute__ ((__packed__)) psoc_layout { - u8 ctl; //offset: 0 - u16 switch_temp; //offset: 1 - - // BYTE[03:20] - voltage - u16 voltage[15]; //offset: 0x03-0x20 - - // BYTE[21:27] - ExtFan - u8 led_ctl2; //offset: 21 - u8 ext_pwm; //offset: 22 - u16 ext_rpm[2]; //offset: 23 - u8 gpi_fan2; //offset: 27 - - //gpo - u8 led_ctl; //offset: 28 - - u8 gpio; //offset: 29 - - //pwm duty - u8 pwm[4]; //offset: 2a - u8 pwm_psu[2]; //offset: 2e - - //fan rpm - u16 fan[4*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[2]; //offset: 50 - - //version - u8 version[2]; //offset: 54 - - u8 reserve2[4]; //offset: 56 - 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) -#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) - -#define PWM2_OFFSET PSOC_OFF(ext_pwm) -#define RPM2_OFFSET PSOC_OFF(ext_rpm) -#define FAN_LED2_OFFSET PSOC_OFF(led_ctl2) -#define FAN_GPI2_OFFSET PSOC_OFF(gpi_fan2) - -#define CLEI_OFF(m) offsetof(struct clei, m) -#define FAN1_CLEI_INDEX 0 -#define FAN2_CLEI_INDEX 1 -#define FAN3_CLEI_INDEX 2 -#define FAN4_CLEI_INDEX 3 -#define FAN5_CLEI_INDEX 4 -#define PSU1_CLEI_INDEX 5 -#define PSU2_CLEI_INDEX 6 - -static void msg_handler(struct ipmi_recv_msg *recv_msg,void* handler_data) -{ - struct ipmi_result *msg_result = recv_msg->user_msg_data; - - msg_result->result_length=recv_msg->msg.data_len-1; - memcpy(msg_result->result, &recv_msg->msg.data[1], recv_msg->msg.data_len-1); - - ipmi_free_recv_msg(recv_msg); - mutex_unlock(&ipmi_mutex); - - return; -} - -int start_ipmi_command(char NetFn, char cmd,char *data,int data_length, char* result, int* result_length) -{ - int rv=0,i; - int timeout; - - //wait previous command finish at least 50msec - timeout=50; - while((mutex_is_locked(&ipmi_mutex) == 1 || (mutex_is_locked(&ipmi2_mutex) == 1)) && (--timeout)>0) { usleep_range(1000,1010); } - if(timeout==0) { return -1; } - mutex_lock(&ipmi_mutex); - mutex_lock(&ipmi2_mutex); - - if(ipmi_mh_user == NULL) { - for (i=0,rv=1; i0) { usleep_range(1000,1100);} - if(timeout==0) { - mutex_unlock(&ipmi2_mutex); - return -1; - } - else { - *result_length=ipmiresult.result_length; - memcpy(result,ipmiresult.result,*result_length); - mutex_unlock(&ipmi2_mutex); - return 0; - } - } - return 0; -} -EXPORT_SYMBOL(start_ipmi_command); - -static ssize_t psoc_ipmi_read(u8 *buf, u8 offset, size_t count) -{ - uint8_t data[2]; - int result_len=0; - int rv; - - data[0] = offset; - data[1] = count; - - rv=start_ipmi_command(NETFN_OEM, CMD_GETDATA,data,2, buf, &result_len); - - return result_len; -} - -static ssize_t psoc_ipmi_write(char *buf, unsigned offset, size_t count) -{ - uint8_t data[count+1],result[1]; - int result_len; - - data[0] = offset; - memcpy(&data[1],buf,count); - - start_ipmi_command(NETFN_OEM, CMD_SETDATA,data,count+1, result, &result_len); - return count; -} - - -static u16 psoc_read16(u8 offset) -{ - u16 value = 0; - u8 buf[]={0,0}; - - if(psoc_ipmi_read(buf, offset, 2) == 2) - value = (buf[0]<<8 | buf[1]<<0); - - return value; -} - -static u8 psoc_read8(u8 offset) -{ - u8 value = 0; - u8 buf = 0; - - if(psoc_ipmi_read(&buf, offset, 1) == 1) - value = buf; - - return value; -} - -/* -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=0; - struct sensor_device_attribute *attr = to_sensor_dev_attr(da); - u8 byte=0; - int shift = (attr->index == 0)?3:0; - - status = psoc_ipmi_read(&byte, PSOC_PSU_OFFSET, 1); - - byte = (byte >> shift) & 0x7; - - status = sprintf (buf, "%d : %s\n", byte, psu_str[byte]); - - return strlen(buf); -} - -static ssize_t show_ipmi_pmbus(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=0; - - data[0] = BMC_PMBusNumber; - 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(start_ipmi_command(0x06, 0x52,data,4, result, &result_len)==0) - { - if(data[3]==PMBus_Temp2) - { - return sprintf(buf, "%ld \n", ((result_len==2)?(pmbus_reg2data_linear(result[0] | (result[1]<<8), 0 )):0)); - } - else - { - if(result_len==0) result[0]=0; - result[result[0]+1]='\0'; - return sprintf(buf, "%s\n",&result[1]); - } - } - else - { - return 0; - } -} - -static ssize_t show_clei(struct device *dev, struct device_attribute *da, - char *buf) -{ - struct sensor_device_attribute *attr = to_sensor_dev_attr(da); - u8 device_index = attr->index & 0xFF; - - uint8_t data[5],result[MaxLeng_Result]; - int result_len=0; - - data[0] = (device_index<=FAN5_CLEI_INDEX) ? BMC_FanCLEIBusNumber:BMC_PMBusNumber; - data[1] = CLEI_ADDR[device_index]<<1; - data[2] = sizeof(struct clei); - data[3] = (device_index<=FAN5_CLEI_INDEX) ? 0x00 : 0x01; //PSU CLEI will start from 0x0100 - data[4] = 0; - - if(start_ipmi_command(0x06, 0x52,data,5, result, &result_len)==0) - { - if(result_len < sizeof(struct clei)) memset(result, 0, sizeof(struct clei)); - sprintf (buf, "Issue Number: %.3s\n", &result[CLEI_OFF(issue_number)]); - sprintf (buf, "%sAbbreviation Number: %.9s\n", buf, &result[CLEI_OFF(abbreviation_number)]); - sprintf (buf, "%sFC Number: %.10s\n", buf, &result[CLEI_OFF(fc_number)]); - sprintf (buf, "%sCLEI Code: %.10s\n", buf, &result[CLEI_OFF(clei_code)]); - sprintf (buf, "%sProduct Year and Month: %.5s\n", buf, &result[CLEI_OFF(product_year_and_month)]); - sprintf (buf, "%s2D Label Location Code: %.2s\n", buf, &result[CLEI_OFF(label_location_code)]); - sprintf (buf, "%sSerial Number: %.5s\n", buf, &result[CLEI_OFF(serial_number)]); - sprintf (buf, "%sPCB Revision: %.5s\n", buf, &result[CLEI_OFF(pcb_revision)]); - sprintf (buf, "%sVendor Name: %.10s\n", buf, &result[CLEI_OFF(vendor_name)]); - return strlen(buf); - } - else - { - return sprintf(buf, "NONE\n"); - } -} - -static ssize_t show_thermal(struct device *dev, struct device_attribute *da, - char *buf) -{ - int status=0; - struct sensor_device_attribute *attr = to_sensor_dev_attr(da); - u8 offset = attr->index * 2 + THERMAL_OFFSET; - - status = psoc_read16(offset); - - 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=0; - struct sensor_device_attribute *attr = to_sensor_dev_attr(da); - u8 offset = attr->index; - - status = psoc_read8(offset); - - return sprintf(buf, "%d\n", - status); -} - -static ssize_t set_pwm(struct device *dev, - struct device_attribute *da, - const char *buf, size_t count) -{ - struct sensor_device_attribute *attr = to_sensor_dev_attr(da); - u8 offset = attr->index; - u8 pwm = simple_strtol(buf, NULL, 10); - if(pwm > 255) pwm = 255; - psoc_ipmi_write(&pwm, offset, 1); - - return count; -} - - -static ssize_t show_rpm(struct device *dev, struct device_attribute *da, - char *buf) -{ - int status=0; - struct sensor_device_attribute *attr = to_sensor_dev_attr(da); - u8 offset = attr->index; - status = psoc_read16(offset); - - return sprintf(buf, "%d\n", - status); -} - -static ssize_t show_switch_tmp(struct device *dev, struct device_attribute *da, - char *buf) -{ - u16 status=0; - u16 temp = 0; - - status = psoc_ipmi_read((u8*)&temp, SWITCH_TMP_OFFSET, 2); - - 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) -{ - long temp = simple_strtol(buf, NULL, 10); - u16 temp2 = ( (temp/1000) <<8 ) & 0xFF00 ; - - psoc_ipmi_write((u8*)&temp2, SWITCH_TMP_OFFSET, 2); - - - return count; -} - -static ssize_t show_diag(struct device *dev, struct device_attribute *da, - char *buf) -{ - u16 status=0; - u8 diag_flag = 0; - - status = psoc_ipmi_read((u8*)&diag_flag, DIAG_FLAG_OFFSET, 1); - - status = sprintf (buf, "%d\n", ((diag_flag & 0x80)?1:0)); - - return strlen(buf); -} - -static ssize_t set_diag(struct device *dev, - struct device_attribute *devattr, - const char *buf, size_t count) -{ - u8 value = 0; - u8 diag = simple_strtol(buf, NULL, 10); - - diag = diag?1:0; - - psoc_ipmi_read((u8*)&value, DIAG_FLAG_OFFSET, 1); - if(diag) value |= (1<<7); - else value &= ~(1<<7); - psoc_ipmi_write((u8*)&value, DIAG_FLAG_OFFSET, 1); - - return count; -} - -static ssize_t show_version(struct device *dev, struct device_attribute *da, - char *buf) -{ - u16 status=0; - - status = psoc_read16(VERSION_OFFSET); - - 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=0; - struct sensor_device_attribute *attr = to_sensor_dev_attr(da); - u8 bit = attr->index; - - if(bit < 8) { status = psoc_read8(FAN_LED_OFFSET); } -#if FAN_NUM>4 - if(bit >= 8) { status = psoc_read8(FAN_LED2_OFFSET); bit-=8; } -#endif - - return sprintf(buf, "%d\n", - (status & (1<index; - u8 led_state = 0; - - u8 v = simple_strtol(buf, NULL, 10); - - if(attr->index < 8) { led_state = psoc_read8(FAN_LED_OFFSET ); } -#if FAN_NUM>4 - if(attr->index >= 8) { led_state = psoc_read8(FAN_LED2_OFFSET); bit-=8; } -#endif - if(v) led_state |= (1<index < 8) { psoc_ipmi_write(&led_state, FAN_LED_OFFSET, 1);} -#if FAN_NUM>4 - if(attr->index >= 8) { psoc_ipmi_write(&led_state, FAN_LED2_OFFSET,1);} -#endif - return count; -} - -static ssize_t show_value8(struct device *dev, struct device_attribute *da, - char *buf) -{ - int status=0; - struct sensor_device_attribute *attr = to_sensor_dev_attr(da); - u8 offset = attr->index; - - status = psoc_read8(offset); - - 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=0; - struct sensor_device_attribute *attr = to_sensor_dev_attr(da); - u8 offset = attr->index + PSU_INFO_OFFSET; - - status = psoc_read16(offset); - - if((strstr(attr->dev_attr.attr.name, "vout")!=NULL)|(strstr(attr->dev_attr.attr.name, "in3")!=NULL)|(strstr(attr->dev_attr.attr.name, "in4")!=NULL)) { - offset=1; - } - else { - offset=0; - } - - return sprintf(buf, "%ld \n", pmbus_reg2data_linear(status, offset )); -} - -static ssize_t show_name(struct device *dev, - struct device_attribute *devattr, char *buf) -{ - return sprintf(buf, "inv_psoc\n"); -} - -static DEVICE_ATTR(name, S_IRUGO, show_name, NULL); -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(temp7_input, S_IRUGO, show_thermal, 0, 5); -static SENSOR_DEVICE_ATTR(temp8_input, S_IRUGO, show_thermal, 0, 6); - -static SENSOR_DEVICE_ATTR(pwm1, S_IWUSR|S_IRUGO, show_pwm, set_pwm, 0 + PWM_OFFSET); -static SENSOR_DEVICE_ATTR(pwm2, S_IWUSR|S_IRUGO, show_pwm, set_pwm, 1 + PWM_OFFSET); -static SENSOR_DEVICE_ATTR(pwm3, S_IWUSR|S_IRUGO, show_pwm, set_pwm, 2 + PWM_OFFSET); -static SENSOR_DEVICE_ATTR(pwm4, S_IWUSR|S_IRUGO, show_pwm, set_pwm, 3 + PWM_OFFSET); -#if FAN_NUM > 4 -static SENSOR_DEVICE_ATTR(pwm5, S_IWUSR|S_IRUGO, show_pwm, set_pwm, 0 + PWM2_OFFSET); -#endif -static SENSOR_DEVICE_ATTR(pwm_psu1, S_IWUSR|S_IRUGO, show_pwm, set_pwm, 4 + PWM_OFFSET); -static SENSOR_DEVICE_ATTR(pwm_psu2, S_IWUSR|S_IRUGO, show_pwm, set_pwm, 5 + PWM_OFFSET); -static SENSOR_DEVICE_ATTR(pwm6, S_IWUSR|S_IRUGO, show_pwm, set_pwm, 4 + PWM_OFFSET); -static SENSOR_DEVICE_ATTR(pwm7, S_IWUSR|S_IRUGO, show_pwm, set_pwm, 5 + PWM_OFFSET); - -static SENSOR_DEVICE_ATTR(psu1, S_IRUGO, show_psu_st, 0, 0); -static SENSOR_DEVICE_ATTR(psu2, 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); -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(fan11_input, S_IRUGO, show_rpm, 0, 8*2 + RPM_OFFSET); -static SENSOR_DEVICE_ATTR(fan12_input, S_IRUGO, show_rpm, 0, 9*2 + RPM_OFFSET); - -#if FAN_NUM > 4 -static SENSOR_DEVICE_ATTR(fan9_input , S_IRUGO, show_rpm, 0,0*2 + RPM2_OFFSET); -static SENSOR_DEVICE_ATTR(fan10_input, S_IRUGO, show_rpm, 0,1*2 + RPM2_OFFSET); -#endif - -static SENSOR_DEVICE_ATTR(switch_tmp, S_IWUSR|S_IRUGO, show_switch_tmp, set_switch_tmp, 0); -static SENSOR_DEVICE_ATTR(temp6_input, 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); - -#if FAN_NUM>4 -static SENSOR_DEVICE_ATTR(fan_led_grn5, S_IWUSR|S_IRUGO, show_fan_led, set_fan_led, 8); -static SENSOR_DEVICE_ATTR(fan_led_red5, S_IWUSR|S_IRUGO, show_fan_led, set_fan_led, 12); -static SENSOR_DEVICE_ATTR(fan_gpi2, S_IRUGO, show_value8, 0, FAN_GPI2_OFFSET); -#endif - -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(in1_input, S_IRUGO, show_psu_psoc, 0, PSOC_PSU_OFF(psu1_vin)); -static SENSOR_DEVICE_ATTR(curr1_input, S_IRUGO, show_psu_psoc, 0, PSOC_PSU_OFF(psu1_iin)); -static SENSOR_DEVICE_ATTR(power1_input, S_IRUGO, show_psu_psoc, 0, PSOC_PSU_OFF(psu1_pin)); -static SENSOR_DEVICE_ATTR(in3_input, S_IRUGO, show_psu_psoc, 0, PSOC_PSU_OFF(psu1_vout)); -static SENSOR_DEVICE_ATTR(curr3_input, S_IRUGO, show_psu_psoc, 0, PSOC_PSU_OFF(psu1_iout)); -static SENSOR_DEVICE_ATTR(power3_input, 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 SENSOR_DEVICE_ATTR(in2_input, S_IRUGO, show_psu_psoc, 0, PSOC_PSU_OFF(psu2_vin)); -static SENSOR_DEVICE_ATTR(curr2_input, S_IRUGO, show_psu_psoc, 0, PSOC_PSU_OFF(psu2_iin)); -static SENSOR_DEVICE_ATTR(power2_input, S_IRUGO, show_psu_psoc, 0, PSOC_PSU_OFF(psu2_pin)); -static SENSOR_DEVICE_ATTR(in4_input, S_IRUGO, show_psu_psoc, 0, PSOC_PSU_OFF(psu2_vout)); -static SENSOR_DEVICE_ATTR(curr4_input, S_IRUGO, show_psu_psoc, 0, PSOC_PSU_OFF(psu2_iout)); -static SENSOR_DEVICE_ATTR(power4_input, S_IRUGO, show_psu_psoc, 0, PSOC_PSU_OFF(psu2_pout)); - -//IPMI -static SENSOR_DEVICE_ATTR(thermal2_psu1, S_IRUGO, show_ipmi_pmbus, 0, PSU1 | PMBus_Temp2); -static SENSOR_DEVICE_ATTR(temp9_input, S_IRUGO, show_ipmi_pmbus, 0, PSU1 | PMBus_Temp2); - -static SENSOR_DEVICE_ATTR(psoc_psu1_vendor, S_IRUGO, show_ipmi_pmbus, 0, PSU1 | PMBus_Vendor); -static SENSOR_DEVICE_ATTR(psoc_psu1_serial, S_IRUGO, show_ipmi_pmbus, 0, PSU1 | PMBus_Serial); -static SENSOR_DEVICE_ATTR(psoc_psu1_version, S_IRUGO, show_ipmi_pmbus, 0, PSU1 | PMBus_Version); - -static SENSOR_DEVICE_ATTR(thermal2_psu2, S_IRUGO, show_ipmi_pmbus, 0, PSU2 | PMBus_Temp2); -static SENSOR_DEVICE_ATTR(temp10_input, S_IRUGO, show_ipmi_pmbus, 0, PSU2 | PMBus_Temp2); -static SENSOR_DEVICE_ATTR(psoc_psu2_vendor, S_IRUGO, show_ipmi_pmbus, 0, PSU2 | PMBus_Vendor); -static SENSOR_DEVICE_ATTR(psoc_psu2_serial, S_IRUGO, show_ipmi_pmbus, 0, PSU2 | PMBus_Serial); -static SENSOR_DEVICE_ATTR(psoc_psu2_version, S_IRUGO, show_ipmi_pmbus, 0, PSU2 | PMBus_Version); - -//CLEI -#if FAN_CLEI_SUPPORT -static SENSOR_DEVICE_ATTR(fan1_clei, S_IRUGO, show_clei, 0, FAN1_CLEI_INDEX ); -static SENSOR_DEVICE_ATTR(fan2_clei, S_IRUGO, show_clei, 0, FAN2_CLEI_INDEX ); -static SENSOR_DEVICE_ATTR(fan3_clei, S_IRUGO, show_clei, 0, FAN3_CLEI_INDEX ); -static SENSOR_DEVICE_ATTR(fan4_clei, S_IRUGO, show_clei, 0, FAN4_CLEI_INDEX ); -#if FAN_NUM > 4 -static SENSOR_DEVICE_ATTR(fan5_clei, S_IRUGO, show_clei, 0, FAN5_CLEI_INDEX ); -#endif -#endif - -#if PSU_CLEI_SUPPORT -static SENSOR_DEVICE_ATTR(psu1_clei, S_IRUGO, show_clei, 0, PSU1_CLEI_INDEX ); -static SENSOR_DEVICE_ATTR(psu2_clei, S_IRUGO, show_clei, 0, PSU2_CLEI_INDEX ); -#endif - -static struct attribute *psoc_attributes[] = { - //name - &dev_attr_name.attr, - //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, - - &sensor_dev_attr_temp7_input.dev_attr.attr, - &sensor_dev_attr_temp8_input.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 > 4 - &sensor_dev_attr_pwm5.dev_attr.attr, -#endif - &sensor_dev_attr_pwm_psu1.dev_attr.attr, - &sensor_dev_attr_pwm_psu2.dev_attr.attr, - &sensor_dev_attr_pwm6.dev_attr.attr, - &sensor_dev_attr_pwm7.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 > 4 - &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, - &sensor_dev_attr_fan11_input.dev_attr.attr, - &sensor_dev_attr_fan12_input.dev_attr.attr, - //switch temperature - &sensor_dev_attr_switch_tmp.dev_attr.attr, - &sensor_dev_attr_temp6_input.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, -#if FAN_NUM >4 - &sensor_dev_attr_fan_led_grn5.dev_attr.attr, - &sensor_dev_attr_fan_led_red5.dev_attr.attr, - &sensor_dev_attr_fan_gpi2.dev_attr.attr, -#endif - //fan GPI - &sensor_dev_attr_fan_gpi.dev_attr.attr, - &sensor_dev_attr_psu1.dev_attr.attr, - &sensor_dev_attr_psu2.dev_attr.attr, - - - //psu_psoc - &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, - - &sensor_dev_attr_in1_input.dev_attr.attr, - &sensor_dev_attr_curr1_input.dev_attr.attr, - &sensor_dev_attr_power1_input.dev_attr.attr, - &sensor_dev_attr_in2_input.dev_attr.attr, - &sensor_dev_attr_curr2_input.dev_attr.attr, - &sensor_dev_attr_power2_input.dev_attr.attr, - &sensor_dev_attr_in3_input.dev_attr.attr, - &sensor_dev_attr_curr3_input.dev_attr.attr, - &sensor_dev_attr_power3_input.dev_attr.attr, - &sensor_dev_attr_in4_input.dev_attr.attr, - &sensor_dev_attr_curr4_input.dev_attr.attr, - &sensor_dev_attr_power4_input.dev_attr.attr, - - //ipmi_i2c_command - &sensor_dev_attr_thermal2_psu1.dev_attr.attr, - &sensor_dev_attr_temp9_input.dev_attr.attr, - &sensor_dev_attr_psoc_psu1_vendor.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_temp10_input.dev_attr.attr, - &sensor_dev_attr_psoc_psu2_vendor.dev_attr.attr, - &sensor_dev_attr_psoc_psu2_serial.dev_attr.attr, - &sensor_dev_attr_psoc_psu2_version.dev_attr.attr, - - //clei -#if FAN_CLEI_SUPPORT - &sensor_dev_attr_fan1_clei.dev_attr.attr, - &sensor_dev_attr_fan2_clei.dev_attr.attr, - &sensor_dev_attr_fan3_clei.dev_attr.attr, - &sensor_dev_attr_fan4_clei.dev_attr.attr, -#if FAN_NUM > 4 - &sensor_dev_attr_fan5_clei.dev_attr.attr, -#endif -#endif - -#if PSU_CLEI_SUPPORT - &sensor_dev_attr_psu1_clei.dev_attr.attr, - &sensor_dev_attr_psu2_clei.dev_attr.attr, -#endif - NULL -}; - -static const struct attribute_group psoc_group = { - .attrs = psoc_attributes, -}; - -//================================= -static void check_switch_temp(void) -{ - static struct file *f; - mm_segment_t old_fs; - - set_fs(get_ds()); - f = filp_open(SWITCH_TEMPERATURE_SOCK,O_RDONLY,0644); - if(IS_ERR(f)) { - return; - } - else { - char temp_str[]={0,0,0,0,0,0,0}; - loff_t pos = 0; - u16 temp2 = 0; - old_fs = get_fs(); - set_fs(KERNEL_DS); - kernel_read(f, temp_str,6,&pos); - temp2 = ((simple_strtoul(temp_str,NULL,10)/1000) <<8 ) & 0xFF00 ; - psoc_ipmi_write((u8*)&temp2, SWITCH_TMP_OFFSET, 2); - } - filp_close(f,NULL); - set_fs(old_fs); -} - -static int psoc_polling_thread(void *p) -{ - while (!kthread_should_stop()) - { - check_switch_temp(); - set_current_state(TASK_INTERRUPTIBLE); - if(kthread_should_stop()) - break; - - schedule_timeout(msecs_to_jiffies(PSOC_POLLING_PERIOD)); - } - return 0; -} - -static int __init inv_psoc_init(void) -{ - int ret; - - hwmon_dev = hwmon_device_register(NULL); - if (IS_ERR(hwmon_dev)) { - goto fail_hwmon_device_register; - } - - device_kobj = kobject_create_and_add("device", &hwmon_dev->kobj); - if(!device_kobj) { - goto fail_hwmon_device_register; - } - - ret = sysfs_create_group(device_kobj, &psoc_group); - if (ret) { - goto fail_create_group_hwmon; - } - - ret = sysfs_create_group(&hwmon_dev->kobj, &psoc_group); - if (ret) { - goto fail_create_group_hwmon; - } - - kthread_auto_update = kthread_run(psoc_polling_thread,NULL,"BMC_DRIVER"); - if (IS_ERR(kthread_auto_update)) { - goto fail_create_group_hwmon; - } - return ret; - -fail_create_group_hwmon: - hwmon_device_unregister(hwmon_dev); -fail_hwmon_device_register: - return -ENOMEM; -} - -static void __exit inv_psoc_exit(void) -{ - kthread_stop(kthread_auto_update); - if(ipmi_mh_user!=NULL) {ipmi_destroy_user(ipmi_mh_user);} - sysfs_remove_group(device_kobj, &psoc_group); - if(hwmon_dev != NULL) hwmon_device_unregister(hwmon_dev); -} - -MODULE_AUTHOR("Ting.Jack "); -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/d5264q28b/modules/builds/src/inv_swps.c b/packages/platforms/inventec/x86-64/d5264q28b/modules/builds/src/inv_swps.c deleted file mode 100644 index cce1bad65..000000000 --- a/packages/platforms/inventec/x86-64/d5264q28b/modules/builds/src/inv_swps.c +++ /dev/null @@ -1,3288 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "inv_swps.h" - -static int ctl_major; -static int port_major; -static int ioexp_total; -static int port_total; -static int block_polling; -static int auto_config; -static int flag_i2c_reset; -static int flag_mod_state; -static unsigned gpio_rest_mux; -static int gpio_base = 0; -static struct class *swp_class_p = NULL; -static struct inv_platform_s *platform_p = NULL; -static struct inv_ioexp_layout_s *ioexp_layout = NULL; -static struct inv_port_layout_s *port_layout = NULL; -int io_no_init = 0; -module_param(io_no_init, int, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP); -static void swp_polling_worker(struct work_struct *work); -static DECLARE_DELAYED_WORK(swp_polling, swp_polling_worker); - -static int reset_i2c_topology(void); - -static int -__swp_match(struct device *dev, -#ifdef SWPS_KERN_VER_AF_3_10 - - const void *data){ -#else - void *data){ -#endif - - char *name = (char *)data; - if (strcmp(dev_name(dev), name) == 0) - return 1; - return 0; -} - - -struct device * -get_swpdev_by_name(char *name){ - struct device *dev = class_find_device(swp_class_p, - NULL, - name, - __swp_match); - return dev; -} - - -static int -sscanf_2_int(const char *buf) { - - int result = -EBFONT; - char *hex_tag = "0x"; - - if (strcspn(buf, hex_tag) == 0) { - if (sscanf(buf,"%x",&result)) { - return result; - } - } else { - if (sscanf(buf,"%d",&result)) { - return result; - } - if(sscanf(buf,"-%d",&result)) { - return -result; - } - if (sscanf(buf,"%x",&result)) { - return result; - } - } - return -EBFONT; -} - - -static int -sscanf_2_binary(const char *buf) { - - int result = sscanf_2_int(buf); - - if (result < 0){ - return -EBFONT; - } - switch (result) { - case 0: - case 1: - return result; - default: - break; - } - return -EBFONT; -} - - -static int -_get_polling_period(void) { - - int retval = 0; - - if (SWP_POLLING_PERIOD == 0) { - return 0; - } - retval = ((SWP_POLLING_PERIOD * HZ) / 1000); - if (retval == 0) { - return 1; - } - return retval; -} - - -static struct transvr_obj_s * -_get_transvr_obj(char *dev_name) { - - struct device *dev_p = NULL; - struct transvr_obj_s *transvr_obj_p = NULL; - - dev_p = get_swpdev_by_name(dev_name); - if (!dev_p){ - return NULL; - } - transvr_obj_p = dev_get_drvdata(dev_p); - if (!transvr_obj_p){ - return NULL; - } - return transvr_obj_p; -} - - -static int -_is_i2c_target_exist(int chan, int addr) { - /* retval: Exist = 1 / Not exist = 0 / Error < 0 - */ - struct i2c_adapter *adap = NULL; - struct i2c_client *client = NULL; - int retval = -1; - int err = -1; - int d_offs = 0; - - adap = i2c_get_adapter(chan); - if (!adap) { - SWPS_DEBUG("%s: can't get adapter\n", __func__); - retval = 0; - goto out_is_i2c_target_exist_1; - } - client = kzalloc(sizeof(*client), GFP_KERNEL); - if (!client) { - SWPS_ERR("%s: kzalloc fail\n", __func__); - retval = -1; - goto out_is_i2c_target_exist_2; - } - client->adapter = adap; - client->addr = addr; - err = i2c_smbus_read_byte_data(client, d_offs); - if (err < 0) { - retval = 0; - } else { - retval = 1; - } - i2c_put_adapter(adap); - kfree(client); - return retval; - -out_is_i2c_target_exist_2: - i2c_put_adapter(adap); -out_is_i2c_target_exist_1: - return retval; -} - - -static void -unlock_tobj_all(void) { - - struct transvr_obj_s *tobj_p; - char port_name[32]; - int port_id = 0; - int minor_curr = 0; - - for (minor_curr=0; minor_currauto_config = auto_config; - unlock_transvr_obj(tobj_p); - SWPS_DEBUG("%s: Set %s auto_config=%d\n", - __func__, tobj_p->swp_name, auto_config); - } - return retval; -} - - -/* ========== R/W Functions module control attribute ========== - */ -static ssize_t -show_attr_platform(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - return snprintf(buf_p, 32, "%s\n", platform_p->name); -} - - -static ssize_t -show_attr_version(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - return snprintf(buf_p, 8, "%s\n", SWP_VERSION); -} - - -static ssize_t -show_attr_status(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - return snprintf(buf_p, 8, "%d\n", flag_mod_state); -} - - -static ssize_t -show_attr_auto_config(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - return snprintf(buf_p, 8, "%d\n", auto_config); -} - - -static ssize_t -show_attr_block_poll(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - return snprintf(buf_p, 8, "%d\n", block_polling); -} -static ssize_t -show_attr_io_no_init(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - return snprintf(buf_p, 8, "%d\n", io_no_init); -} - - -static int -_check_reset_pwd(const char *buf_p, - size_t count) { - - int in_max = 64; - int in_len = (int)count; - char in_val[64] = "ERR"; - char *emsg = "ERR"; - - if (in_len >= in_max) { - emsg = "input too much"; - goto err_check_reset_pwd; - } - if (!sscanf(buf_p,"%s",in_val)) { - emsg = "format incorrect"; - goto err_check_reset_pwd; - } - if (strcmp(in_val, SWP_RESET_PWD) != 0) { - emsg = "password incorrect"; - goto err_check_reset_pwd; - } - return 0; - -err_check_reset_pwd: - SWPS_ERR("%s: %s\n", __func__, emsg); - return -1; -} - - -static ssize_t -store_attr_reset_i2c(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - - if (_check_reset_pwd(buf_p, count) < 0) { - return -EBFONT; - } - /* Polling mode */ - if (SWP_POLLING_ENABLE) { - SWPS_INFO("%s: reset I2C :polling\n", __func__); - flag_i2c_reset = 1; - return count; - } - /* Direct mode */ - SWPS_INFO("%s: reset I2C go. :direct\n", __func__); - if (reset_i2c_topology() < 0) { - SWPS_ERR("%s: reset fail!\n", __func__); - return -EIO; - } - SWPS_INFO("%s: reset I2C ok. :direct\n", __func__); - return count; -} - - -static ssize_t -store_attr_reset_swps(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - - struct transvr_obj_s *tobj_p; - char port_name[32] = "ERR"; - int port_id = 0; - int minor_curr = 0; - - if (_check_reset_pwd(buf_p, count) < 0) { - return -EBFONT; - } - for (minor_curr=0; minor_currstate = STATE_TRANSVR_DISCONNECTED; - unlock_transvr_obj(tobj_p); - SWPS_INFO("%s: reset:%s\n", __func__, tobj_p->swp_name); - } - return count; -} - - -static ssize_t -store_attr_auto_config(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - - int input_val = sscanf_2_int(buf_p); - - if (input_val < 0){ - return -EBFONT; - } - if ((input_val != 0) && (input_val != 1)) { - return -EBFONT; - } - auto_config = input_val; - _update_auto_config_2_trnasvr(); - return count; -} - - -static ssize_t -store_attr_block_poll( struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - - int input_val = sscanf_2_int(buf_p); - - if (input_val < 0){ - return -EBFONT; - } - if ((input_val != 0) && (input_val != 1)) { - return -EBFONT; - } - - if(input_val != block_polling){ - block_polling = input_val; - if(block_polling){ - cancel_delayed_work_sync(&swp_polling); - } - else{ - schedule_delayed_work(&swp_polling, _get_polling_period()); - } - } - - return count; -} - -static ssize_t -store_attr_io_no_init( struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - - int input_val = sscanf_2_int(buf_p); - - if ((input_val != 0) && (input_val != 1)) { - return -EBFONT; - } - - if(input_val != io_no_init){ - io_no_init = input_val; - } - - return count; -} - -/* ========== Show functions: For transceiver attribute ========== - */ -static ssize_t -_show_transvr_hex_attr(struct transvr_obj_s* tobj_p, - int (*get_func)(struct transvr_obj_s* tobj_p), - char *buf_p) { - size_t len; - int result; - - lock_transvr_obj(tobj_p); - result = get_func(tobj_p); - unlock_transvr_obj(tobj_p); - if (result < 0){ - len = snprintf(buf_p, 8, "%d\n", result); - } else { - len = snprintf(buf_p, 8, "0x%02x\n", result); - } - return len; -} - - -static ssize_t -_show_transvr_int_attr(struct transvr_obj_s* tobj_p, - int (*get_func)(struct transvr_obj_s* tobj_p), - char *buf_p) { - size_t len; - - lock_transvr_obj(tobj_p); - len = snprintf(buf_p, 16, "%d\n", get_func(tobj_p)); - unlock_transvr_obj(tobj_p); - return len; -} - - -static ssize_t -_show_transvr_str_attr(struct transvr_obj_s* tobj_p, - int (*get_func)(struct transvr_obj_s* tobj_p, char* buf), - char *buf_p) { - size_t len; - - lock_transvr_obj(tobj_p); - len = get_func(tobj_p, buf_p); - unlock_transvr_obj(tobj_p); - return len; -} - - -static ssize_t -show_attr_id(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_hex_attr(tobj_p, - tobj_p->get_id, - buf_p); -} - - -static ssize_t -show_attr_ext_id(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_hex_attr(tobj_p, - tobj_p->get_ext_id, - buf_p); -} - - -static ssize_t -show_attr_connector(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_hex_attr(tobj_p, - tobj_p->get_connector, - buf_p); -} - - -static ssize_t -show_attr_vendor_name(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_vendor_name, - buf_p); -} - - -static ssize_t -show_attr_vendor_pn(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_vendor_pn, - buf_p); -} - - -static ssize_t -show_attr_vendor_rev(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_vendor_rev, - buf_p); -} - - -static ssize_t -show_attr_vendor_sn(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_vendor_sn, - buf_p); -} - - -static ssize_t -show_attr_power_cls(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - size_t len; - int result; - struct transvr_obj_s *tobj_p; - - tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - lock_transvr_obj(tobj_p); - result = tobj_p->get_power_cls(tobj_p); - unlock_transvr_obj(tobj_p); - if (result < 0){ - len = snprintf(buf_p, 16, "%d\n", result); - } else { - len = snprintf(buf_p, 16, "Power Class %d\n", result); - } - return len; -} - - -static ssize_t -show_attr_br(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_hex_attr(tobj_p, - tobj_p->get_br, - buf_p); -} - - -static ssize_t -show_attr_len_sm(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_int_attr(tobj_p, - tobj_p->get_len_sm, - buf_p); -} - - -static ssize_t -show_attr_len_smf(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_int_attr(tobj_p, - tobj_p->get_len_smf, - buf_p); -} - - -static ssize_t -show_attr_len_om1(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_int_attr(tobj_p, - tobj_p->get_len_om1, - buf_p); -} - - -static ssize_t -show_attr_len_om2(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_int_attr(tobj_p, - tobj_p->get_len_om2, - buf_p); -} - - -static ssize_t -show_attr_len_om3(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_int_attr(tobj_p, - tobj_p->get_len_om3, - buf_p); -} - - -static ssize_t -show_attr_len_om4(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_int_attr(tobj_p, - tobj_p->get_len_om4, - buf_p); -} - - -static ssize_t -show_attr_comp_rev(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_hex_attr(tobj_p, - tobj_p->get_comp_rev, - buf_p); -} - - -static ssize_t -show_attr_comp_eth(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_hex_attr(tobj_p, - tobj_p->get_comp_eth_1, - buf_p); -} - - -static ssize_t -show_attr_comp_eth_10(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_hex_attr(tobj_p, - tobj_p->get_comp_eth_10, - buf_p); -} - - -static ssize_t -show_attr_comp_eth_10_40(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_hex_attr(tobj_p, - tobj_p->get_comp_eth_10_40, - buf_p); -} - - -static ssize_t -show_attr_comp_extend(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_hex_attr(tobj_p, - tobj_p->get_comp_extend, - buf_p); -} - - -static ssize_t -show_attr_rate_id(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_hex_attr(tobj_p, - tobj_p->get_rate_id, - buf_p); -} - - -static ssize_t -show_attr_temperature(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_curr_temp, - buf_p); -} - - -static ssize_t -show_attr_voltage(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_curr_vol, - buf_p); -} - - -static ssize_t -show_attr_tx_bias(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_tx_bias, - buf_p); -} - - -static ssize_t -show_attr_tx_power(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_tx_power, - buf_p); -} - - -static ssize_t -show_attr_tx_eq(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_tx_eq, - buf_p); -} - - -static ssize_t -show_attr_rx_power(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_rx_power, - buf_p); -} - - -static ssize_t -show_attr_rx_am(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_rx_am, - buf_p); -} - - -static ssize_t -show_attr_rx_em(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_rx_em, - buf_p); -} - - -static ssize_t -show_attr_wavelength(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_wavelength, - buf_p); -} - - -static ssize_t -show_attr_extphy_offset(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_extphy_offset, - buf_p); -} - - -static ssize_t -show_attr_extphy_reg(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_extphy_reg, - buf_p); -} - - -static ssize_t -show_attr_info(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_int_attr(tobj_p, - tobj_p->get_info, - buf_p); -} - - -static ssize_t -show_attr_if_type(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_if_type, - buf_p); -} - - -static ssize_t -show_attr_if_speed(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_if_speed, - buf_p); -} - - -static ssize_t -show_attr_if_lane(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_if_lane, - buf_p); -} - - -static ssize_t -show_attr_cdr(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_hex_attr(tobj_p, - tobj_p->get_cdr, - buf_p); -} - - -static ssize_t -show_attr_soft_rs0(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_int_attr(tobj_p, - tobj_p->get_soft_rs0, - buf_p); -} - - -static ssize_t -show_attr_soft_rs1(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_int_attr(tobj_p, - tobj_p->get_soft_rs1, - buf_p); -} - - -static ssize_t -show_attr_soft_rx_los(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_soft_rx_los, - buf_p); -} - - -static ssize_t -show_attr_soft_tx_disable(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_soft_tx_disable, - buf_p); -} - - -static ssize_t -show_attr_soft_tx_fault(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_soft_tx_fault, - buf_p); -} - - -static ssize_t -show_attr_auto_tx_disable(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_auto_tx_disable, - buf_p); -} - - -/* ========== Store functions: transceiver (R/W) attribute ========== - */ -static ssize_t -_store_transvr_int_attr(struct transvr_obj_s* tobj_p, - int (*set_func)(struct transvr_obj_s *tobj_p, int input_val), - const char *buf_p, - size_t count) { - int input, err; - - input = sscanf_2_int(buf_p); - if (input < 0){ - return -EBFONT; - } - lock_transvr_obj(tobj_p); - err = set_func(tobj_p, input); - unlock_transvr_obj(tobj_p); - if (err < 0){ - return err; - } - return count; -} - - -static ssize_t -_store_transvr_byte_hex_attr(struct transvr_obj_s* tobj_p, - int (*set_func)(struct transvr_obj_s *tobj_p, int input_val), - const char *buf_p, - size_t count) { - int input, err; - - input = sscanf_2_int(buf_p); - if ((input < 0) || (input > 0xff)){ - return -EBFONT; - } - lock_transvr_obj(tobj_p); - err = set_func(tobj_p, input); - unlock_transvr_obj(tobj_p); - if (err < 0){ - return err; - } - return count; -} - - -static ssize_t -_store_transvr_binary_attr(struct transvr_obj_s* tobj_p, - int (*set_func)(struct transvr_obj_s *tobj_p, int input_val), - const char *buf_p, - size_t count) { - int input, err; - - input = sscanf_2_binary(buf_p); - if (input < 0){ - return -EBFONT; - } - lock_transvr_obj(tobj_p); - err = set_func(tobj_p, input); - unlock_transvr_obj(tobj_p); - if (err < 0){ - return err; - } - return count; -} - - -static ssize_t -store_attr_cdr(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - return _store_transvr_byte_hex_attr(tobj_p, - tobj_p->set_cdr, - buf_p, - count); -} - - -static ssize_t -store_attr_soft_rs0(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - return _store_transvr_binary_attr(tobj_p, - tobj_p->set_soft_rs0, - buf_p, - count); -} - - -static ssize_t -store_attr_soft_rs1(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - return _store_transvr_binary_attr(tobj_p, - tobj_p->set_soft_rs1, - buf_p, - count); -} - - -static ssize_t -store_attr_soft_tx_disable(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count) { - - int check = sscanf_2_int(buf_p); - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - if ((check < 0) || (check > 0xf)){ - return -EBFONT; - } - return _store_transvr_byte_hex_attr(tobj_p, - tobj_p->set_soft_tx_disable, - buf_p, - count); -} - - -static ssize_t -store_attr_auto_tx_disable(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count) { - - int err = -EPERM; - int input = sscanf_2_int(buf_p); - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - if ((input < 0) || (input > 0xf)){ - if (input != VAL_TRANSVR_FUNCTION_DISABLE) { - return -EBFONT; - } - } - lock_transvr_obj(tobj_p); - err = tobj_p->set_auto_tx_disable(tobj_p, input); - unlock_transvr_obj(tobj_p); - if (err < 0){ - return err; - } - return count; -} - - -static ssize_t -store_attr_tx_eq(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - return _store_transvr_int_attr(tobj_p, - tobj_p->set_tx_eq, - buf_p, - count); -} - - -static ssize_t -store_attr_rx_am(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - return _store_transvr_int_attr(tobj_p, - tobj_p->set_rx_am, - buf_p, - count); -} - - -static ssize_t -store_attr_rx_em(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - return _store_transvr_int_attr(tobj_p, - tobj_p->set_rx_em, - buf_p, - count); -} - - -static ssize_t -store_attr_extphy_offset(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - return _store_transvr_int_attr(tobj_p, - tobj_p->set_extphy_offset, - buf_p, - count); -} - - -static ssize_t -store_attr_extphy_reg(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - return _store_transvr_int_attr(tobj_p, - tobj_p->set_extphy_reg, - buf_p, - count); -} - -/* ========== Show functions: For I/O Expander attribute ========== - */ -static ssize_t -_show_ioexp_binary_attr(struct transvr_obj_s *tobj_p, - int (*get_func)(struct ioexp_obj_s *ioexp_p, int voffset), - char *buf_p) { - size_t len; - struct ioexp_obj_s *ioexp_p = tobj_p->ioexp_obj_p; - - if (!ioexp_p) { - SWPS_ERR(" %s: data corruption! :%s\n", __func__, tobj_p->swp_name); - return -ENODATA; - } - mutex_lock(&ioexp_p->lock); - len = snprintf(buf_p, 8, "%d\n", get_func(ioexp_p, tobj_p->ioexp_virt_offset)); - mutex_unlock(&ioexp_p->lock); - return len; -} - - -static ssize_t -show_attr_present(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - return _show_ioexp_binary_attr(tobj_p, - tobj_p->ioexp_obj_p->get_present, - buf_p); -} - - -static ssize_t -show_attr_tx_fault(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - return _show_ioexp_binary_attr(tobj_p, - tobj_p->ioexp_obj_p->get_tx_fault, - buf_p); -} - - -static ssize_t -show_attr_rxlos(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - return _show_ioexp_binary_attr(tobj_p, - tobj_p->ioexp_obj_p->get_rxlos, - buf_p); -} - - -static ssize_t -show_attr_tx_disable(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - return _show_ioexp_binary_attr(tobj_p, - tobj_p->ioexp_obj_p->get_tx_disable, - buf_p); -} - - -static ssize_t -show_attr_reset(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - return _show_ioexp_binary_attr(tobj_p, - tobj_p->ioexp_obj_p->get_reset, - buf_p); -} - - -static ssize_t -show_attr_lpmod(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - return _show_ioexp_binary_attr(tobj_p, - tobj_p->ioexp_obj_p->get_lpmod, - buf_p); -} - - -static ssize_t -show_attr_modsel(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - return _show_ioexp_binary_attr(tobj_p, - tobj_p->ioexp_obj_p->get_modsel, - buf_p); -} - - -static ssize_t -show_attr_hard_rs0(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - return _show_ioexp_binary_attr(tobj_p, - tobj_p->ioexp_obj_p->get_hard_rs0, - buf_p); -} - - -static ssize_t -show_attr_hard_rs1(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - return _show_ioexp_binary_attr(tobj_p, - tobj_p->ioexp_obj_p->get_hard_rs1, - buf_p); -} - - -/* ========== Store functions: For I/O Expander (R/W) attribute ========== - */ -static ssize_t -_store_ioexp_binary_attr(struct transvr_obj_s *tobj_p, - int (*set_func)(struct ioexp_obj_s *ioexp_p, - int virt_offset, int input_val), - const char *buf_p, - size_t count) { - - int input, err; - struct ioexp_obj_s *ioexp_p = tobj_p->ioexp_obj_p; - - if (!ioexp_p) { - SWPS_ERR("%s: data corruption! :%s\n", - __func__, tobj_p->swp_name); - return -ENODATA; - } - input = sscanf_2_binary(buf_p); - if (input < 0) { - return -EBFONT; - } - mutex_lock(&ioexp_p->lock); - err = set_func(ioexp_p, tobj_p->ioexp_virt_offset, input); - mutex_unlock(&ioexp_p->lock); - if (err < 0){ - return err; - } - return count; -} - -static ssize_t -store_attr_tx_disable(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p) { - return -ENODEV; - } - return _store_ioexp_binary_attr(tobj_p, - tobj_p->ioexp_obj_p->set_tx_disable, - buf_p, - count); -} - - -static ssize_t -store_attr_reset(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p) { - return -ENODEV; - } - return _store_ioexp_binary_attr(tobj_p, - tobj_p->ioexp_obj_p->set_reset, - buf_p, - count); -} - - -static ssize_t -store_attr_lpmod(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p) { - return -ENODEV; - } - return _store_ioexp_binary_attr(tobj_p, - tobj_p->ioexp_obj_p->set_lpmod, - buf_p, - count); -} - - -static ssize_t -store_attr_modsel(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p) { - return -ENODEV; - } - return _store_ioexp_binary_attr(tobj_p, - tobj_p->ioexp_obj_p->set_modsel, - buf_p, - count); -} - - -static ssize_t -store_attr_hard_rs0(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p) { - return -ENODEV; - } - return _store_ioexp_binary_attr(tobj_p, - tobj_p->ioexp_obj_p->set_hard_rs0, - buf_p, - count); -} - - -static ssize_t -store_attr_hard_rs1(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p) { - return -ENODEV; - } - return _store_ioexp_binary_attr(tobj_p, - tobj_p->ioexp_obj_p->set_hard_rs1, - buf_p, - count); -} - - -/* ========== SWPS attribute: For module control ========== - */ -static DEVICE_ATTR(platform, S_IRUGO, show_attr_platform, NULL); -static DEVICE_ATTR(version, S_IRUGO, show_attr_version, NULL); -static DEVICE_ATTR(status, S_IRUGO, show_attr_status, NULL); -static DEVICE_ATTR(reset_i2c, S_IWUSR, NULL, store_attr_reset_i2c); -static DEVICE_ATTR(reset_swps, S_IWUSR, NULL, store_attr_reset_swps); -static DEVICE_ATTR(auto_config, S_IRUGO|S_IWUSR, show_attr_auto_config, store_attr_auto_config); -static DEVICE_ATTR(block_poll, S_IRUGO|S_IWUSR, show_attr_block_poll, store_attr_block_poll); -static DEVICE_ATTR(io_no_init, S_IRUGO|S_IWUSR, show_attr_io_no_init, store_attr_io_no_init); - - -/* ========== Transceiver attribute: from eeprom ========== - */ -static DEVICE_ATTR(id, S_IRUGO, show_attr_id, NULL); -static DEVICE_ATTR(ext_id, S_IRUGO, show_attr_ext_id, NULL); -static DEVICE_ATTR(connector, S_IRUGO, show_attr_connector, NULL); -static DEVICE_ATTR(vendor_name, S_IRUGO, show_attr_vendor_name, NULL); -static DEVICE_ATTR(vendor_pn, S_IRUGO, show_attr_vendor_pn, NULL); -static DEVICE_ATTR(vendor_rev, S_IRUGO, show_attr_vendor_rev, NULL); -static DEVICE_ATTR(vendor_sn, S_IRUGO, show_attr_vendor_sn, NULL); -static DEVICE_ATTR(power_cls, S_IRUGO, show_attr_power_cls, NULL); -static DEVICE_ATTR(br, S_IRUGO, show_attr_br, NULL); -static DEVICE_ATTR(len_sm, S_IRUGO, show_attr_len_sm, NULL); -static DEVICE_ATTR(len_smf, S_IRUGO, show_attr_len_smf, NULL); -static DEVICE_ATTR(len_om1, S_IRUGO, show_attr_len_om1, NULL); -static DEVICE_ATTR(len_om2, S_IRUGO, show_attr_len_om2, NULL); -static DEVICE_ATTR(len_om3, S_IRUGO, show_attr_len_om3, NULL); -static DEVICE_ATTR(len_om4, S_IRUGO, show_attr_len_om4, NULL); -static DEVICE_ATTR(comp_rev, S_IRUGO, show_attr_comp_rev, NULL); -static DEVICE_ATTR(comp_eth, S_IRUGO, show_attr_comp_eth, NULL); -static DEVICE_ATTR(comp_eth_10, S_IRUGO, show_attr_comp_eth_10, NULL); -static DEVICE_ATTR(comp_eth_10_40, S_IRUGO, show_attr_comp_eth_10_40, NULL); -static DEVICE_ATTR(comp_extend, S_IRUGO, show_attr_comp_extend, NULL); -static DEVICE_ATTR(rate_id, S_IRUGO, show_attr_rate_id, NULL); -static DEVICE_ATTR(temperature, S_IRUGO, show_attr_temperature, NULL); -static DEVICE_ATTR(voltage, S_IRUGO, show_attr_voltage, NULL); -static DEVICE_ATTR(tx_bias, S_IRUGO, show_attr_tx_bias, NULL); -static DEVICE_ATTR(tx_power, S_IRUGO, show_attr_tx_power, NULL); -static DEVICE_ATTR(rx_power, S_IRUGO, show_attr_rx_power, NULL); -static DEVICE_ATTR(info, S_IRUGO, show_attr_info, NULL); -static DEVICE_ATTR(if_type, S_IRUGO, show_attr_if_type, NULL); -static DEVICE_ATTR(if_speed, S_IRUGO, show_attr_if_speed, NULL); -static DEVICE_ATTR(if_lane, S_IRUGO, show_attr_if_lane, NULL); -static DEVICE_ATTR(soft_rx_los, S_IRUGO, show_attr_soft_rx_los, NULL); -static DEVICE_ATTR(soft_tx_fault, S_IRUGO, show_attr_soft_tx_fault, NULL); -static DEVICE_ATTR(wavelength, S_IRUGO, show_attr_wavelength, NULL); -static DEVICE_ATTR(tx_eq, S_IRUGO|S_IWUSR, show_attr_tx_eq, store_attr_tx_eq); -static DEVICE_ATTR(rx_am, S_IRUGO|S_IWUSR, show_attr_rx_am, store_attr_rx_am); -static DEVICE_ATTR(rx_em, S_IRUGO|S_IWUSR, show_attr_rx_em, store_attr_rx_em); -static DEVICE_ATTR(cdr, S_IRUGO|S_IWUSR, show_attr_cdr, store_attr_cdr); -static DEVICE_ATTR(soft_rs0, S_IRUGO|S_IWUSR, show_attr_soft_rs0, store_attr_soft_rs0); -static DEVICE_ATTR(soft_rs1, S_IRUGO|S_IWUSR, show_attr_soft_rs1, store_attr_soft_rs1); -static DEVICE_ATTR(soft_tx_disable, S_IRUGO|S_IWUSR, show_attr_soft_tx_disable, store_attr_soft_tx_disable); -static DEVICE_ATTR(auto_tx_disable, S_IRUGO|S_IWUSR, show_attr_auto_tx_disable, store_attr_auto_tx_disable); -static DEVICE_ATTR(extphy_offset, S_IRUGO|S_IWUSR, show_attr_extphy_offset, store_attr_extphy_offset); -static DEVICE_ATTR(extphy_reg, S_IRUGO|S_IWUSR, show_attr_extphy_reg, store_attr_extphy_reg); - -/* ========== IO Expander attribute: from expander ========== - */ -static DEVICE_ATTR(present, S_IRUGO, show_attr_present, NULL); -static DEVICE_ATTR(tx_fault, S_IRUGO, show_attr_tx_fault, NULL); -static DEVICE_ATTR(rxlos, S_IRUGO, show_attr_rxlos, NULL); -static DEVICE_ATTR(tx_disable, S_IRUGO|S_IWUSR, show_attr_tx_disable, store_attr_tx_disable); -static DEVICE_ATTR(reset, S_IRUGO|S_IWUSR, show_attr_reset, store_attr_reset); -static DEVICE_ATTR(lpmod, S_IRUGO|S_IWUSR, show_attr_lpmod, store_attr_lpmod); -static DEVICE_ATTR(modsel, S_IRUGO|S_IWUSR, show_attr_modsel, store_attr_modsel); -static DEVICE_ATTR(hard_rs0, S_IRUGO|S_IWUSR, show_attr_hard_rs0, store_attr_hard_rs0); -static DEVICE_ATTR(hard_rs1, S_IRUGO|S_IWUSR, show_attr_hard_rs1, store_attr_hard_rs1); - -/* ========== Functions for module handling ========== - */ -static void -clean_port_objs(void){ - - dev_t dev_num; - char dev_name[32]; - struct device *device_p; - struct transvr_obj_s *tobj_p; - int minor_curr, port_id; - - for (minor_curr=0; minor_curri2c_client_p) { - i2c_put_adapter(tobj_p->i2c_client_p->adapter); - kfree(tobj_p->i2c_client_p); - } - kfree(tobj_p->vendor_name); - kfree(tobj_p->vendor_pn); - kfree(tobj_p->vendor_rev); - kfree(tobj_p->vendor_sn); - kfree(tobj_p->worker_p); - kfree(tobj_p); - } - dev_num = MKDEV(port_major, minor_curr); - device_unregister(device_p); - device_destroy(swp_class_p, dev_num); - } - SWPS_DEBUG("%s: done.\n", __func__); -} - - -static void -clean_swps_common(void){ - - dev_t dev_num; - struct device *device_p; - - device_p = get_swpdev_by_name(SWP_DEV_MODCTL); - if (device_p){ - dev_num = MKDEV(ctl_major, 1); - device_unregister(device_p); - device_destroy(swp_class_p, dev_num); - } - cancel_delayed_work_sync(&swp_polling); - if (platform_p) { - kfree(platform_p); - } - SWPS_DEBUG("%s: done.\n", __func__); -} - - -static int -get_platform_type(void){ - - int i, tmp; - int auto_chan = -1; - int auto_addr = -1; - int pf_total = ARRAY_SIZE(platform_map); - char log_msg[64] = "ERROR"; - - platform_p = kzalloc(sizeof(struct inv_platform_s), GFP_KERNEL); - if (!platform_p){ - snprintf(log_msg, sizeof(log_msg), "kzalloc fail"); - goto err_get_platform_type_1; - } - memset(platform_p->name, 0, sizeof(platform_p->name)); - - switch (PLATFORM_SETTINGS) { - case PLATFORM_TYPE_AUTO: - snprintf(platform_p->name, (sizeof(platform_p->name) - 1), - "%s", dmi_get_system_info(DMI_BOARD_NAME)); - for (i=0; iname, platform_map[i].name) == 0) { - platform_p->id = platform_map[i].id; - snprintf(log_msg, sizeof(log_msg), - "Auto detect platform: %d (%s)", - platform_p->id, platform_p->name); - goto ok_get_platform_type_1; - } - } - snprintf(log_msg, sizeof(log_msg), - "Auto detect fail! detect platform: %s", - platform_p->name); - goto err_get_platform_type_2; - - case PLATFORM_TYPE_PEONY_AUTO: -#ifdef SWPS_PEONY_SFP - auto_chan = peony_sfp_ioexp_layout[0].addr[0].chan_id; - auto_addr = peony_sfp_ioexp_layout[0].addr[0].chip_addr; -#endif - tmp = _is_i2c_target_exist(auto_chan, auto_addr); - switch (tmp) { - case 0: /* Copper SKU */ - SWPS_INFO("Auto-detected :Peony :Copper\n"); - platform_p->id = PLATFORM_TYPE_PEONY_COPPER_GA; - goto map_platform_name; - - case 1: /* SFP SKU */ - SWPS_INFO("Auto-detected :Peony :SFP\n"); - platform_p->id = PLATFORM_TYPE_PEONY_SFP_GA; - goto map_platform_name; - - default: - break; - } - snprintf(log_msg, sizeof(log_msg), - "Auto detect Peony SKU fail! :%d", tmp); - goto err_get_platform_type_2; - - case PLATFORM_TYPE_MAGNOLIA: - case PLATFORM_TYPE_MAGNOLIA_FNC: - case PLATFORM_TYPE_REDWOOD: - case PLATFORM_TYPE_REDWOOD_FSL: - case PLATFORM_TYPE_HUDSON32I_GA: - case PLATFORM_TYPE_SPRUCE: - case PLATFORM_TYPE_CYPRESS_GA1: - case PLATFORM_TYPE_CYPRESS_GA2: - case PLATFORM_TYPE_CYPRESS_BAI: - case PLATFORM_TYPE_TAHOE: - case PLATFORM_TYPE_SEQUOIA_GA: - case PLATFORM_TYPE_LAVENDER_GA: - case PLATFORM_TYPE_LAVENDER_ONL: - case PLATFORM_TYPE_COTTONWOOD_RANGELEY: - case PLATFORM_TYPE_MAPLE_GA: - case PLATFORM_TYPE_MAPLE_B: - case PLATFORM_TYPE_MAPLE_J: - case PLATFORM_TYPE_GULMOHAR_GA: - case PLATFORM_TYPE_GULMOHAR_2T_EVT1_GA: - case PLATFORM_TYPE_PEONY_SFP_GA: - case PLATFORM_TYPE_PEONY_COPPER_GA: - case PLATFORM_TYPE_CEDAR_GA: - platform_p->id = PLATFORM_SETTINGS; - goto map_platform_name; - - default: - break; - } - snprintf(log_msg, sizeof(log_msg), - "PLATFORM_SETTINGS:%d undefined", PLATFORM_SETTINGS); - goto err_get_platform_type_2; - -map_platform_name: - for (i=0; iid == platform_map[i].id) { - snprintf(platform_p->name, (sizeof(platform_p->name) - 1), - "%s", platform_map[i].name); - snprintf(log_msg, sizeof(log_msg), - "User setup platform: %d (%s)", - platform_p->id, platform_p->name); - goto ok_get_platform_type_1; - } - } - snprintf(log_msg, sizeof(log_msg), - "Internal error, can not map id:%d", - platform_p->id ); - goto err_get_platform_type_2; - -ok_get_platform_type_1: - SWPS_DEBUG("%s: %s, :%d\n", __func__, log_msg, PLATFORM_SETTINGS); - return 0; - -err_get_platform_type_2: - kfree(platform_p); -err_get_platform_type_1: - SWPS_ERR("%s: %s :%d\n", __func__, log_msg, PLATFORM_SETTINGS); - return -1; -} - - -static int -get_layout_info(void){ - - switch (platform_p->id) { -#ifdef SWPS_MAGNOLIA - case PLATFORM_TYPE_MAGNOLIA: - case PLATFORM_TYPE_MAGNOLIA_FNC: - gpio_rest_mux = gpio_base + magnolia_gpio_rest_mux; - ioexp_layout = magnolia_ioexp_layout; - port_layout = magnolia_port_layout; - ioexp_total = ARRAY_SIZE(magnolia_ioexp_layout); - port_total = ARRAY_SIZE(magnolia_port_layout); - break; -#endif -#ifdef SWPS_REDWOOD - case PLATFORM_TYPE_REDWOOD: - gpio_rest_mux = gpio_base + redwood_gpio_rest_mux; - ioexp_layout = redwood_ioexp_layout; - port_layout = redwood_port_layout; - ioexp_total = ARRAY_SIZE(redwood_ioexp_layout); - port_total = ARRAY_SIZE(redwood_port_layout); - break; -#endif -#ifdef SWPS_HUDSON32I_GA - case PLATFORM_TYPE_HUDSON32I_GA: - gpio_rest_mux = gpio_base + hudsin32iga_gpio_rest_mux; - ioexp_layout = hudson32iga_ioexp_layout; - port_layout = hudson32iga_port_layout; - ioexp_total = ARRAY_SIZE(hudson32iga_ioexp_layout); - port_total = ARRAY_SIZE(hudson32iga_port_layout); - break; -#endif -#ifdef SWPS_SPRUCE - case PLATFORM_TYPE_SPRUCE: - gpio_rest_mux = gpio_base + spruce_gpio_rest_mux; - ioexp_layout = spruce_ioexp_layout; - port_layout = spruce_port_layout; - ioexp_total = ARRAY_SIZE(spruce_ioexp_layout); - port_total = ARRAY_SIZE(spruce_port_layout); - break; -#endif -#ifdef SWPS_CYPRESS_GA1 - case PLATFORM_TYPE_CYPRESS_GA1: - gpio_rest_mux = gpio_base + cypress_ga1_gpio_rest_mux; - ioexp_layout = cypress_ga1_ioexp_layout; - port_layout = cypress_ga1_port_layout; - ioexp_total = ARRAY_SIZE(cypress_ga1_ioexp_layout); - port_total = ARRAY_SIZE(cypress_ga1_port_layout); - break; -#endif -#ifdef SWPS_CYPRESS_GA2 - case PLATFORM_TYPE_CYPRESS_GA2: - gpio_rest_mux = gpio_base + cypress_ga2_gpio_rest_mux; - ioexp_layout = cypress_ga2_ioexp_layout; - port_layout = cypress_ga2_port_layout; - ioexp_total = ARRAY_SIZE(cypress_ga2_ioexp_layout); - port_total = ARRAY_SIZE(cypress_ga2_port_layout); - break; -#endif -#ifdef SWPS_CYPRESS_BAI - case PLATFORM_TYPE_CYPRESS_BAI: - gpio_rest_mux = gpio_base + cypress_b_gpio_rest_mux; - ioexp_layout = cypress_b_ioexp_layout; - port_layout = cypress_b_port_layout; - ioexp_total = ARRAY_SIZE(cypress_b_ioexp_layout); - port_total = ARRAY_SIZE(cypress_b_port_layout); - break; -#endif -#ifdef SWPS_REDWOOD_FSL - case PLATFORM_TYPE_REDWOOD_FSL: - gpio_rest_mux = gpio_base + redwood_fsl_gpio_rest_mux; - ioexp_layout = redwood_fsl_ioexp_layout; - port_layout = redwood_fsl_port_layout; - ioexp_total = ARRAY_SIZE(redwood_fsl_ioexp_layout); - port_total = ARRAY_SIZE(redwood_fsl_port_layout); - break; -#endif -#ifdef SWPS_TAHOE - case PLATFORM_TYPE_TAHOE: - gpio_rest_mux = gpio_base + tahoe_gpio_rest_mux; - ioexp_layout = tahoe_ioexp_layout; - port_layout = tahoe_port_layout; - ioexp_total = ARRAY_SIZE(tahoe_ioexp_layout); - port_total = ARRAY_SIZE(tahoe_port_layout); - break; -#endif -#ifdef SWPS_SEQUOIA - case PLATFORM_TYPE_SEQUOIA_GA: - gpio_rest_mux = gpio_base + sequoia_gpio_rest_mux; - ioexp_layout = sequoia_ioexp_layout; - port_layout = sequoia_port_layout; - ioexp_total = ARRAY_SIZE(sequoia_ioexp_layout); - port_total = ARRAY_SIZE(sequoia_port_layout); - break; -#endif -#ifdef SWPS_LAVENDER - case PLATFORM_TYPE_LAVENDER_GA: - case PLATFORM_TYPE_LAVENDER_ONL: - gpio_rest_mux = gpio_base + lavender_gpio_rest_mux; - ioexp_layout = lavender_ioexp_layout; - port_layout = lavender_port_layout; - ioexp_total = ARRAY_SIZE(lavender_ioexp_layout); - port_total = ARRAY_SIZE(lavender_port_layout); - break; -#endif -#ifdef SWPS_COTTONWOOD_RANGELEY - case PLATFORM_TYPE_COTTONWOOD_RANGELEY: - gpio_rest_mux = gpio_base + cottonwood_rangeley_gpio_rest_mux; - ioexp_layout = cottonwood_rangeley_ioexp_layout; - port_layout = cottonwood_rangeley_port_layout; - ioexp_total = ARRAY_SIZE(cottonwood_rangeley_ioexp_layout); - port_total = ARRAY_SIZE(cottonwood_rangeley_port_layout); - break; -#endif -#ifdef SWPS_MAPLE_GA - case PLATFORM_TYPE_MAPLE_GA: - gpio_rest_mux = gpio_base + maple_ga_gpio_rest_mux; - ioexp_layout = maple_ga_ioexp_layout; - port_layout = maple_ga_port_layout; - ioexp_total = ARRAY_SIZE(maple_ga_ioexp_layout); - port_total = ARRAY_SIZE(maple_ga_port_layout); - break; -#endif -#ifdef SWPS_MAPLE_B - case PLATFORM_TYPE_MAPLE_B: - gpio_rest_mux = gpio_base + maple_b_gpio_rest_mux; - ioexp_layout = maple_b_ioexp_layout; - port_layout = maple_b_port_layout; - ioexp_total = ARRAY_SIZE(maple_b_ioexp_layout); - port_total = ARRAY_SIZE(maple_b_port_layout); - break; -#endif -#ifdef SWPS_MAPLE_J - case PLATFORM_TYPE_MAPLE_J: - gpio_rest_mux = gpio_base + maple_j_gpio_rest_mux; - ioexp_layout = maple_j_ioexp_layout; - port_layout = maple_j_port_layout; - ioexp_total = ARRAY_SIZE(maple_j_ioexp_layout); - port_total = ARRAY_SIZE(maple_j_port_layout); - break; -#endif -#ifdef SWPS_GULMOHAR - case PLATFORM_TYPE_GULMOHAR_GA: - gpio_rest_mux = gpio_base + gulmohar_gpio_rest_mux; - ioexp_layout = gulmohar_ioexp_layout; - port_layout = gulmohar_port_layout; - ioexp_total = ARRAY_SIZE(gulmohar_ioexp_layout); - port_total = ARRAY_SIZE(gulmohar_port_layout); - break; -#endif -#ifdef SWPS_GULMOHAR_2T_EVT1 - case PLATFORM_TYPE_GULMOHAR_2T_EVT1_GA: - gpio_rest_mux = gpio_base + gulmohar_2t_evt1_gpio_rest_mux; - ioexp_layout = gulmohar_2t_evt1_ioexp_layout; - port_layout = gulmohar_2t_evt1_port_layout; - ioexp_total = ARRAY_SIZE(gulmohar_2t_evt1_ioexp_layout); - port_total = ARRAY_SIZE(gulmohar_2t_evt1_port_layout); - break; -#endif -#ifdef SWPS_PEONY_SFP - case PLATFORM_TYPE_PEONY_SFP_GA: - gpio_rest_mux = gpio_base + peony_sfp_gpio_rest_mux; - ioexp_layout = peony_sfp_ioexp_layout; - port_layout = peony_sfp_port_layout; - ioexp_total = ARRAY_SIZE(peony_sfp_ioexp_layout); - port_total = ARRAY_SIZE(peony_sfp_port_layout); - break; -#endif -#ifdef SWPS_PEONY_COPPER - case PLATFORM_TYPE_PEONY_COPPER_GA: - gpio_rest_mux = gpio_base + peony_copper_gpio_rest_mux; - ioexp_layout = peony_copper_ioexp_layout; - port_layout = peony_copper_port_layout; - ioexp_total = ARRAY_SIZE(peony_copper_ioexp_layout); - port_total = ARRAY_SIZE(peony_copper_port_layout); - break; -#endif -#ifdef SWPS_CEDAR_GA - case PLATFORM_TYPE_CEDAR_GA: - gpio_rest_mux = gpio_base + cedar_ga_gpio_rest_mux; - ioexp_layout = cedar_ga_ioexp_layout; - port_layout = cedar_ga_port_layout; - ioexp_total = ARRAY_SIZE(cedar_ga_ioexp_layout); - port_total = ARRAY_SIZE(cedar_ga_port_layout); - break; -#endif - - default: - SWPS_ERR(" Invalid platform: %d (%s)\n", - platform_p->id, platform_p->name); - return -1; - } - SWPS_INFO("Start to initial platform: %d (%s)\n", - platform_p->id, platform_p->name); - return 0; -} - - -/* ========== Functions for objects operations ========== - */ -static int -__detect_issues_port(int minor_num) { - - struct transvr_obj_s *tobj_p; - int port_id = port_layout[minor_num].port_id; - char port_name[32] = "ERR"; - char *i2c_emsg = "detected bad transceiver/cable"; - - memset(port_name, 0, sizeof(port_name)); - snprintf(port_name, sizeof(port_name), "%s%d", SWP_DEV_PORT, port_id); - tobj_p = _get_transvr_obj(port_name); - if (!tobj_p) { - SWPS_INFO("%s: tobj_p is NULL :%d\n", __func__, minor_num); - return -1; - } - if (resync_channel_tier_2(tobj_p) < 0) { - if (check_channel_tier_1() < 0) { - goto get_target_issues_port; - } - } - /* Re-check again for i2c-gpio special case */ - if (check_channel_tier_1() < 0) { - goto get_target_issues_port; - } - return 0; - -get_target_issues_port: - alarm_msg_2_user(tobj_p, i2c_emsg); - return -2; -} - - -static int -_detect_issues_port(void) { - /* OK : retrun -1; - * Fail: return fail at which minor number (0~N) - */ - char *emsg = "ERR"; - int minor = 0; - int minor_2st = 1; - - /* Force moving the initial channel pointer - * Filter out case of fail at minor-0 port - */ - while (minor_2st < port_total) { - minor = minor_2st; - if (__detect_issues_port(minor_2st) < 0) { - emsg = "detect minor_2st fail"; - goto err_p_detect_issues_port; - } - minor_2st += 8; - } - /* Scan all port */ - for (minor=0; minor:%d\n", __func__, emsg, minor_err); - return -1; -} - - -static int -check_transvr_obj_one(char *dev_name){ - /* [Return] - * 0 : Doesn't need to take care - * -1 : Single error - * -2 : Critical error (I2C topology die) - * -9 : Internal error - */ - struct transvr_obj_s *tobj_p = NULL; - int retval = -9; - - tobj_p = _get_transvr_obj(dev_name); - if (!tobj_p) { - SWPS_ERR("%s: %s _get_transvr_obj fail\n", - __func__, dev_name); - return -9; - } - /* Check transceiver current status */ - lock_transvr_obj(tobj_p); - retval = tobj_p->check(tobj_p); - unlock_transvr_obj(tobj_p); - switch (retval) { - case 0: - case ERR_TRANSVR_UNPLUGGED: - case ERR_TRNASVR_BE_ISOLATED: - case ERR_TRANSVR_TASK_BUSY: - return 0; - - case ERR_TRANSVR_I2C_CRASH: - default: - break; - } - /* Identify abnormal case */ - if (check_channel_tier_1() < 0) { - SWPS_DEBUG("%s: %s critical error :%d\n", - __func__, dev_name, retval); - return -2; - } - SWPS_DEBUG("%s: %s single error :%d\n", - __func__, dev_name, retval); - return -1; -} - - -static int -check_transvr_objs(void){ - - char dev_name[32]; - int port_id, err_code; - int minor_curr = 0; - - for (minor_curr=0; minor_curr:%d\n", - __func__, dev_name, err_code); - break; - } - } - return 0; - -err_check_transvr_objs: - SWPS_ERR("%s: %s reset_i2c_topology fail.\n", - __func__, dev_name); - return -1; -} - - -static void -swp_polling_worker(struct work_struct *work){ - - /* Reset I2C */ - if (flag_i2c_reset) { - goto polling_reset_i2c; - } - /* Check IOEXP */ - if (check_ioexp_objs() < 0) { - goto polling_reset_i2c; - } - /* Check transceiver */ - if (check_transvr_objs() < 0) { - SWPS_DEBUG("%s: check_transvr_objs fail.\n", __func__); - flag_i2c_reset = 1; - } - goto polling_schedule_round; - -polling_reset_i2c: - SWPS_DEBUG("%s: reset_i2c_topology start.\n", __func__); - if (reset_i2c_topology() < 0) { - SWPS_ERR("%s: reset i2c fail!\n", __func__); - flag_i2c_reset = 1; - } else { - SWPS_DEBUG("%s: reset_i2c_topology OK.\n", __func__); - flag_i2c_reset = 0; - } -polling_schedule_round: - schedule_delayed_work(&swp_polling, _get_polling_period()); -} - - -/* ========== Functions for register something ========== - */ -static int -register_transvr_common_attr(struct device *device_p){ - - char *err_attr = NULL; - - if (device_create_file(device_p, &dev_attr_id) < 0) { - err_attr = "dev_attr_id"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_ext_id) < 0) { - err_attr = "dev_attr_ext_id"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_connector) < 0) { - err_attr = "dev_attr_connector"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_vendor_name) < 0) { - err_attr = "dev_attr_vendor_name"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_vendor_pn) < 0) { - err_attr = "dev_attr_vendor_pn"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_vendor_rev) < 0) { - err_attr = "dev_attr_vendor_rev"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_vendor_sn) < 0) { - err_attr = "dev_attr_vendor_sn"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_br) < 0) { - err_attr = "dev_attr_br"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_len_smf) < 0) { - err_attr = "dev_attr_len_smf"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_len_om1) < 0) { - err_attr = "dev_attr_len_om1"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_len_om2) < 0) { - err_attr = "dev_attr_len_om2"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_len_om3) < 0) { - err_attr = "dev_attr_len_om3"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_len_om4) < 0) { - err_attr = "dev_attr_len_om4"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_comp_extend) < 0) { - err_attr = "dev_attr_comp_extend"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_comp_eth) < 0) { - err_attr = "dev_attr_comp_eth"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_comp_rev) < 0) { - err_attr = "dev_attr_comp_rev"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_info) < 0) { - err_attr = "dev_attr_info"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_if_type) < 0) { - err_attr = "dev_attr_if_type"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_if_speed) < 0) { - err_attr = "dev_attr_if_speed"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_if_lane) < 0) { - err_attr = "dev_attr_if_lane"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_temperature) < 0) { - err_attr = "dev_attr_temperature"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_voltage) < 0) { - err_attr = "dev_attr_voltage"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_tx_bias) < 0) { - err_attr = "dev_attr_tx_bias"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_tx_power) < 0) { - err_attr = "dev_attr_tx_power"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_rx_power) < 0) { - err_attr = "dev_attr_rx_power"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_tx_eq) < 0) { - err_attr = "dev_attr_tx_eq"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_rx_em) < 0) { - err_attr = "dev_attr_rx_em"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_wavelength) < 0) { - err_attr = "dev_attr_wavelength"; - goto err_transvr_comm_attr; - } - return 0; - -err_transvr_comm_attr: - SWPS_ERR("%s: %s\n", __func__, err_attr); - return -1; -} - -static int -register_transvr_sfp_attr(struct device *device_p){ - - char *err_attr = NULL; - - if (register_transvr_common_attr(device_p) < 0) { - err_attr = "register_transvr_common_attr"; - goto err_transvr_sfp_attr; - } - if (device_create_file(device_p, &dev_attr_comp_eth_10) < 0) { - err_attr = "dev_attr_comp_eth_10"; - goto err_transvr_sfp_attr; - } - if (device_create_file(device_p, &dev_attr_len_sm) < 0) { - err_attr = "dev_attr_len_sm"; - goto err_transvr_sfp_attr; - } - if (device_create_file(device_p, &dev_attr_rate_id) < 0) { - err_attr = "dev_attr_rate_id"; - goto err_transvr_sfp_attr; - } - if (device_create_file(device_p, &dev_attr_soft_rs0) < 0) { - err_attr = "dev_attr_soft_rs0"; - goto err_transvr_sfp_attr; - } - if (device_create_file(device_p, &dev_attr_soft_rs1) < 0) { - err_attr = "dev_attr_soft_rs1"; - goto err_transvr_sfp_attr; - } - if (device_create_file(device_p, &dev_attr_extphy_offset) < 0) { - err_attr = "dev_attr_extphy_offset"; - goto err_transvr_sfp_attr; - } - if (device_create_file(device_p, &dev_attr_extphy_reg) < 0) { - err_attr = "dev_attr_extphy_reg"; - goto err_transvr_sfp_attr; - } - return 0; - -err_transvr_sfp_attr: - SWPS_ERR("%s: %s\n", __func__, err_attr); - return -1; -} - - -static int -register_transvr_qsfp_attr(struct device *device_p){ - - char *err_attr = NULL; - - if (register_transvr_common_attr(device_p) < 0) { - err_attr = "register_transvr_common_attr"; - goto err_transvr_qsfp_attr; - } - if (device_create_file(device_p, &dev_attr_comp_eth_10_40) < 0) { - err_attr = "dev_attr_comp_eth_10_40"; - goto err_transvr_qsfp_attr; - } - if (device_create_file(device_p, &dev_attr_power_cls) < 0) { - err_attr = "dev_attr_power_cls"; - goto err_transvr_qsfp_attr; - } - if (device_create_file(device_p, &dev_attr_soft_rx_los) < 0) { - err_attr = "soft_rx_los"; - goto err_transvr_qsfp_attr; - } - if (device_create_file(device_p, &dev_attr_soft_tx_disable) < 0) { - err_attr = "soft_tx_disable"; - goto err_transvr_qsfp_attr; - } - if (device_create_file(device_p, &dev_attr_auto_tx_disable) < 0) { - err_attr = "auto_tx_disable"; - goto err_transvr_qsfp_attr; - } - if (device_create_file(device_p, &dev_attr_soft_tx_fault) < 0) { - err_attr = "soft_tx_fault"; - goto err_transvr_qsfp_attr; - } - return 0; - -err_transvr_qsfp_attr: - SWPS_ERR("%s: %s\n", __func__, err_attr); - return -1; -} - - -static int -register_transvr_qsfp28_attr(struct device *device_p){ - - char *err_attr = NULL; - - if (register_transvr_qsfp_attr(device_p) < 0){ - err_attr = "register_transvr_qsfp_attr"; - goto err_transvr_qsfp28_attr; - } - if (device_create_file(device_p, &dev_attr_cdr) < 0) { - err_attr = "dev_attr_cdr"; - goto err_transvr_qsfp28_attr; - } - if (device_create_file(device_p, &dev_attr_rx_am) < 0) { - err_attr = "dev_attr_rx_am"; - goto err_transvr_qsfp28_attr; - } - return 0; - -err_transvr_qsfp28_attr: - SWPS_ERR("%s: %s\n", __func__, err_attr); - return -1; -} - - -static int -register_transvr_attr(struct device *device_p, - struct transvr_obj_s *transvr_obj){ - - switch (transvr_obj->layout){ - case TRANSVR_TYPE_SFP: - if (register_transvr_sfp_attr(device_p) < 0){ - goto err_reg_tvr_attr; - } - break; - case TRANSVR_TYPE_QSFP: - case TRANSVR_TYPE_QSFP_PLUS: - if (register_transvr_qsfp_attr(device_p) < 0){ - goto err_reg_tvr_attr; - } - break; - case TRANSVR_TYPE_QSFP_28: - if (register_transvr_qsfp28_attr(device_p) < 0){ - goto err_reg_tvr_attr; - } - break; - default: - goto err_reg_tvr_attr; - } - return 0; - -err_reg_tvr_attr: - SWPS_ERR("%s: fail! type=%d \n", __func__, transvr_obj->type); - return -1; -} - - -static int -register_ioexp_attr_sfp_1(struct device *device_p){ - /* Support machine type: - * - SFP : Magnolia - */ - char *err_attr = NULL; - - if (device_create_file(device_p, &dev_attr_present) < 0) { - err_attr = "dev_attr_present"; - goto err_ioexp_sfp1_attr; - } - if (device_create_file(device_p, &dev_attr_tx_fault) < 0) { - err_attr = "dev_attr_tx_fault"; - goto err_ioexp_sfp1_attr; - } - if (device_create_file(device_p, &dev_attr_rxlos) < 0) { - err_attr = "dev_attr_rxlos"; - goto err_ioexp_sfp1_attr; - } - if (device_create_file(device_p, &dev_attr_tx_disable) < 0) { - err_attr = "dev_attr_tx_disable"; - goto err_ioexp_sfp1_attr; - } - return 0; - -err_ioexp_sfp1_attr: - SWPS_ERR("Add device attribute:%s failure! \n",err_attr); - return -1; -} - - -static int -register_ioexp_attr_sfp_2(struct device *device_p){ - /* Support machine type: - * - SFP28 : Cypress - */ - char *err_attr = NULL; - - if (register_ioexp_attr_sfp_1(device_p) < 0){ - goto err_ioexp_sfp2_attr; - } - if (device_create_file(device_p, &dev_attr_hard_rs0) < 0) { - err_attr = "dev_attr_hard_rs0"; - goto err_ioexp_sfp2_attr; - } - if (device_create_file(device_p, &dev_attr_hard_rs1) < 0) { - err_attr = "dev_attr_hard_rs1"; - goto err_ioexp_sfp2_attr; - } - return 0; - -err_ioexp_sfp2_attr: - SWPS_ERR("Add device attribute:%s failure! \n",err_attr); - return -1; -} - - -static int -register_ioexp_attr_qsfp_1(struct device *device_p){ - /* Support machine type: - * - QSFP : Magnolia, Redwood, Hudson32i - * - QSFP+ : Magnolia, Redwood, Hudson32i - * - QSFP28: Redwood - */ - char *err_attr = NULL; - - if (device_create_file(device_p, &dev_attr_present) < 0) { - err_attr = "dev_attr_present"; - goto err_ioexp_qsfp1_attr; - } - if (device_create_file(device_p, &dev_attr_reset) < 0) { - err_attr = "dev_attr_reset"; - goto err_ioexp_qsfp1_attr; - } - if (device_create_file(device_p, &dev_attr_lpmod) < 0) { - err_attr = "dev_attr_lpmod"; - goto err_ioexp_qsfp1_attr; - } - if (device_create_file(device_p, &dev_attr_modsel) < 0) { - err_attr = "dev_attr_modsel"; - goto err_ioexp_qsfp1_attr; - } - return 0; - -err_ioexp_qsfp1_attr: - SWPS_ERR("Add device attribute:%s failure! \n",err_attr); - return -1; -} - - -static int -register_modctl_attr(struct device *device_p){ - - char *err_msg = NULL; - - if (device_create_file(device_p, &dev_attr_platform) < 0) { - err_msg = "dev_attr_platform"; - goto err_reg_modctl_attr; - } - if (device_create_file(device_p, &dev_attr_version) < 0) { - err_msg = "dev_attr_version"; - goto err_reg_modctl_attr; - } - if (device_create_file(device_p, &dev_attr_status) < 0) { - err_msg = "dev_attr_status"; - goto err_reg_modctl_attr; - } - if (device_create_file(device_p, &dev_attr_reset_i2c) < 0) { - err_msg = "dev_attr_reset_i2c"; - goto err_reg_modctl_attr; - } - if (device_create_file(device_p, &dev_attr_reset_swps) < 0) { - err_msg = "dev_attr_reset_swps"; - goto err_reg_modctl_attr; - } - if (device_create_file(device_p, &dev_attr_auto_config) < 0) { - err_msg = "dev_attr_auto_config"; - goto err_reg_modctl_attr; - } - if (device_create_file(device_p, &dev_attr_block_poll) < 0) { - err_msg = "dev_attr_block_poll"; - goto err_reg_modctl_attr; - } - if (device_create_file(device_p, &dev_attr_io_no_init) < 0) { - err_msg = "dev_attr_io_no_init"; - goto err_reg_modctl_attr; - } - - return 0; - -err_reg_modctl_attr: - SWPS_ERR("%s: %s\n", __func__, err_msg); - return -1; -} - - -static int -register_ioexp_attr(struct device *device_p, - struct transvr_obj_s *transvr_obj){ - - char *err_msg = "ERR"; - - switch (transvr_obj->ioexp_obj_p->ioexp_type){ - case IOEXP_TYPE_MAGINOLIA_NAB: - case IOEXP_TYPE_MAGINOLIA_4AB: - case CPLD_TYPE_COTTONWOOD: - if (register_ioexp_attr_sfp_1(device_p) < 0){ - err_msg = "register_ioexp_attr_sfp_1 fail"; - goto err_reg_ioexp_attr; - } - break; - - case IOEXP_TYPE_MAPLE_NABC: - case IOEXP_TYPE_GULMOHAR_NABC: - case IOEXP_TYPE_GULMOHAR_2T_EVT1_NABC: - case IOEXP_TYPE_GULMOHAR_2T_EVT1_1ABC: - case IOEXP_TYPE_GULMOHAR_2T_EVT1_3ABC: - case IOEXP_TYPE_SFP_8P_LAYOUT_1: - if (register_ioexp_attr_sfp_2(device_p) < 0){ - err_msg = "register_ioexp_attr_sfp_2 fail"; - goto err_reg_ioexp_attr; - } - break; - - case IOEXP_TYPE_MAGINOLIA_7AB: - case IOEXP_TYPE_SPRUCE_7AB: - case IOEXP_TYPE_CYPRESS_7ABC: - case IOEXP_TYPE_REDWOOD_P01P08: - case IOEXP_TYPE_REDWOOD_P09P16: - case IOEXP_TYPE_HUDSON32IGA_P01P08: - case IOEXP_TYPE_HUDSON32IGA_P09P16: - case IOEXP_TYPE_TAHOE_5A: - case IOEXP_TYPE_TAHOE_6ABC: - case IOEXP_TYPE_SEQUOIA_NABC: - case IOEXP_TYPE_LAVENDER_P65: - case IOEXP_TYPE_MAPLE_0ABC: - case IOEXP_TYPE_GULMOHAR_7ABC: - case IOEXP_TYPE_GULMOHAR_2T_EVT1_7ABC: - case IOEXP_TYPE_QSFP_6P_LAYOUT_1: - case IOEXP_TYPE_CEDAR_0ABC: - if (register_ioexp_attr_qsfp_1(device_p) < 0){ - err_msg = "register_ioexp_attr_qsfp_1 fail"; - goto err_reg_ioexp_attr; - } - break; - - default: - err_msg = "Unknow type"; - goto err_reg_ioexp_attr; - } - return 0; - -err_reg_ioexp_attr: - SWPS_ERR("%s: %s :%d \n", - __func__, err_msg, transvr_obj->ioexp_obj_p->ioexp_type); - return -1; -} - - -static int -register_modctl_device(void) { - - struct device *device_p = NULL; - int minor_comm = 0; /* Default minor number for common device */ - dev_t dev_num = MKDEV(ctl_major, minor_comm); - char *err_msg = "ERROR"; - - device_p = device_create(swp_class_p, /* struct class *cls */ - NULL, /* struct device *parent */ - dev_num, /* dev_t devt */ - NULL, /* void *private_data */ - SWP_DEV_MODCTL); /* const char *fmt */ - if (IS_ERR(device_p)){ - err_msg = "device_create fail"; - goto err_register_modctl_device_1; - } - if (register_modctl_attr(device_p) < 0) { - err_msg = "register_modctl_attr fail"; - goto err_register_modctl_device_2; - } - return 0; - -err_register_modctl_device_2: - device_unregister(device_p); - device_destroy(swp_class_p, dev_num); -err_register_modctl_device_1: - SWPS_ERR("%s: %s\n", __func__, err_msg); - return -1; -} - - -static int -register_port_device(char *dev_name, - dev_t dev_num, - struct transvr_obj_s *transvr_obj){ - - struct device *device_p = NULL; - device_p = device_create(swp_class_p, /* struct class *cls */ - NULL, /* struct device *parent */ - dev_num, /* dev_t devt */ - transvr_obj, /* void *private_data */ - dev_name); /* const char *fmt */ - if (IS_ERR(device_p)){ - goto err_regswp_create_dev; - } - if (register_transvr_attr(device_p, transvr_obj) < 0){ - goto err_regswp_reg_attr; - } - if (register_ioexp_attr(device_p, transvr_obj) < 0){ - goto err_regswp_reg_attr; - } - return 0; - -err_regswp_reg_attr: - device_unregister(device_p); - device_destroy(swp_class_p, dev_num); -err_regswp_create_dev: - SWPS_ERR("%s fail! :%s\n", __func__, dev_name); - return -1; -} - - -static int -register_swp_module(void){ - - dev_t ctl_devt = 0; - dev_t port_devt = 0; - //int dev_total = port_total + 1; /* char_dev for module control */ - - /* Register device number */ - if (alloc_chrdev_region(&ctl_devt, 0, 1, SWP_DEV_MODCTL) < 0){ - SWPS_WARN("Allocate CTL MAJOR failure! \n"); - goto err_register_swp_module_1; - } - if (alloc_chrdev_region(&port_devt, 0, port_total, SWP_CLS_NAME) < 0){ - SWPS_WARN("Allocate PORT MAJOR failure! \n"); - goto err_register_swp_module_2; - } - ctl_major = MAJOR(ctl_devt); - port_major = MAJOR(port_devt); - - /* Create class object */ - swp_class_p = class_create(THIS_MODULE, SWP_CLS_NAME); - if (IS_ERR(swp_class_p)) { - SWPS_ERR("Create class failure! \n"); - goto err_register_swp_module_3; - } - return 0; - -err_register_swp_module_3: - unregister_chrdev_region(MKDEV(port_major, 0), port_total); -err_register_swp_module_2: - unregister_chrdev_region(MKDEV(ctl_major, 0), 1); -err_register_swp_module_1: - return -1; -} - - -/* ========== Module initial relate ========== - */ -static int -create_ioexp_objs(void) { - - int i, run_mod; - - /* Clean IOEXP object */ - clean_ioexp_objs(); - /* Get running mode */ - run_mod = IOEXP_MODE_DIRECT; - if (SWP_POLLING_ENABLE){ - run_mod = IOEXP_MODE_POLLING; - } - /* Create IOEXP object */ - for(i=0; i devlen_max) { - snprintf(err_msg, sizeof(err_msg), - "SWP_DEV_PORT too long!"); - goto err_initport_create_tranobj; - } - memset(dev_name, 0, sizeof(dev_name)); - snprintf(dev_name, devlen_max, "%s%d", SWP_DEV_PORT, port_id); - /* Create transceiver object */ - ioexp_obj_p = get_ioexp_obj(ioexp_id); - if (!ioexp_obj_p){ - snprintf(err_msg, sizeof(err_msg), - "IOEXP object:%d not exist", ioexp_id); - goto err_initport_create_tranobj; - } - transvr_obj_p = create_transvr_obj(dev_name, chan_id, ioexp_obj_p, - ioexp_virt_offset, transvr_type, - chipset_type, run_mod); - if (!transvr_obj_p){ - snprintf(err_msg, sizeof(err_msg), - "Create transceiver object fail :%s", dev_name); - goto err_initport_create_tranobj; - } - /* Setup Lane_ID mapping */ - i = ARRAY_SIZE(port_layout[minor_curr].lane_id); - j = ARRAY_SIZE(transvr_obj_p->lane_id); - if (i != j) { - snprintf(err_msg, sizeof(err_msg), - "Lane_id size inconsistent %d/%d", i, j); - goto err_initport_reg_device; - } - memcpy(transvr_obj_p->lane_id, port_layout[minor_curr].lane_id, i*sizeof(int)); - /* Create and register device object */ - if (register_port_device(dev_name, MKDEV(port_major, minor_curr), transvr_obj_p) < 0){ - snprintf(err_msg, sizeof(err_msg), - "register_port_device fail"); - goto err_initport_reg_device; - } - /* Setup device_ptr of transvr_obj */ - dev_p = get_swpdev_by_name(dev_name); - if (!dev_p){ - snprintf(err_msg, sizeof(err_msg), - "get_swpdev_by_name fail"); - goto err_initport_reg_device; - } - transvr_obj_p->transvr_dev_p = dev_p; - /* Success */ - ok_count++; - } - SWPS_INFO("%s: initialed %d port-dev\n",__func__, ok_count); - return 0; - -err_initport_reg_device: - kfree(transvr_obj_p); -err_initport_create_tranobj: - clean_port_objs(); - SWPS_ERR("%s: %s", __func__, err_msg); - SWPS_ERR("Dump: :%d :%d :%d :%d :%d :%d\n", - port_id, chan_id, ioexp_id, ioexp_virt_offset, transvr_type, run_mod); - return -1; -} - - -static int -init_dev_topology(void){ - - int err; - char *emsg = "ERR"; - flag_mod_state = SWP_STATE_NORMAL; - - err = init_ioexp_objs(); - switch(err){ - case 0: /* Normal */ - SWPS_DEBUG("%s: normal case\n", __func__); - break; - - case -1: /* topology error */ - SWPS_DEBUG("%s: detect tier-1 topology initial failure :%d\n", - __func__, err); - /* Reset and isolate */ - err = reset_i2c_topology(); - if (err < 0) { - emsg = "reset i2c topology fail"; - goto err_init_dev_topology; - } - /* Re-initial again */ - err = init_ioexp_objs(); - if (err < 0) { - emsg = "re-init ioexp objects fail"; - goto err_init_dev_topology; - } - break; - - case -2: /* Internal error */ - SWPS_DEBUG("%s: internal error case\n", __func__); - err = -2; - emsg = "internal error"; - goto err_init_dev_topology; - - default: - SWPS_DEBUG("%s: undefined error case\n", __func__); - emsg = "undefined error case"; - goto err_init_dev_topology; - } - SWPS_DEBUG("%s: initial I2C topology success\n", __func__); - return 0; - -err_init_dev_topology: - SWPS_ERR("%s: %s :%d\n", __func__, emsg, err); - return -1; -} - - -static int -init_polling_task(void){ - - if (SWP_POLLING_ENABLE){ - schedule_delayed_work(&swp_polling, _get_polling_period()); - } - return 0; -} - - -static int -init_swps_common(void){ - - char *err_msg = "ERR"; - - block_polling = 0; - auto_config = 0; - if ((SWP_AUTOCONFIG_ENABLE) && (SWP_POLLING_ENABLE)){ - auto_config = 1; - } - if (register_modctl_device() < 0) { - err_msg = "register_modctl_device fail"; - goto err_init_swps_common_1; - } - if (_update_auto_config_2_trnasvr() < 0) { - err_msg = "_update_auto_config_2_trnasvr fail"; - goto err_init_swps_common_1; - } - if (init_polling_task() < 0){ - err_msg = "init_polling_task fail"; - goto err_init_swps_common_1; - } - return 0; - -err_init_swps_common_1: - clean_swps_common(); - SWPS_ERR("%s: %s\n", __func__, err_msg); - return -1; -} - - -static int __init -swp_module_init(void){ - - if (get_platform_type() < 0){ - goto err_init_out; - } - if (get_layout_info() < 0){ - goto err_init_out; - } - if (register_swp_module() < 0){ - goto err_init_out; - } - if (create_ioexp_objs() < 0){ - goto err_init_ioexp; - } - if (create_port_objs() < 0){ - goto err_init_portobj; - } - if (init_mux_objs(gpio_rest_mux) < 0){ - goto err_init_mux; - } - if (init_dev_topology() < 0){ - goto err_init_topology; - } - if (init_swps_common() < 0){ - goto err_init_topology; - } - SWPS_INFO("Inventec switch-port module V.%s initial success.\n", SWP_VERSION); - return 0; - - -err_init_topology: - clean_mux_objs(); -err_init_mux: - clean_port_objs(); -err_init_portobj: - clean_ioexp_objs(); -err_init_ioexp: - class_destroy(swp_class_p); - unregister_chrdev_region(MKDEV(ctl_major, 0), 1); - unregister_chrdev_region(MKDEV(port_major, 0), port_total); -err_init_out: - SWPS_ERR("Inventec switch-port module V.%s initial failure.\n", SWP_VERSION); - return -1; -} - - -static void __exit -swp_module_exit(void){ - - clean_swps_common(); - clean_port_objs(); - clean_ioexp_objs(); - clean_mux_objs(); - class_destroy(swp_class_p); - unregister_chrdev_region(MKDEV(ctl_major, 0), 1); - unregister_chrdev_region(MKDEV(port_major, 0), port_total); - SWPS_INFO("Remove Inventec switch-port module success.\n"); -} - - -/* Module information */ -MODULE_AUTHOR(SWP_AUTHOR); -MODULE_DESCRIPTION(SWP_DESC); -MODULE_VERSION(SWP_VERSION); -MODULE_LICENSE(SWP_LICENSE); -MODULE_SOFTDEP("pre: inv_platform"); -module_param(gpio_base, int, S_IRUGO); - -module_init(swp_module_init); -module_exit(swp_module_exit); - - - - - - - - - - - diff --git a/packages/platforms/inventec/x86-64/d5264q28b/modules/builds/src/inv_swps.h b/packages/platforms/inventec/x86-64/d5264q28b/modules/builds/src/inv_swps.h deleted file mode 100644 index 8d876f561..000000000 --- a/packages/platforms/inventec/x86-64/d5264q28b/modules/builds/src/inv_swps.h +++ /dev/null @@ -1,1794 +0,0 @@ -#ifndef INV_SWPS_H -#define INV_SWPS_H - -#include "transceiver.h" -#include "io_expander.h" -#include "inv_mux.h" - -/* Module settings */ -#define SWP_CLS_NAME "swps" -#define SWP_DEV_PORT "port" -#define SWP_DEV_MODCTL "module" -#define SWP_RESET_PWD "inventec" -#define SWP_POLLING_PERIOD (300) /* msec */ -#define SWP_POLLING_ENABLE (1) -#define SWP_AUTOCONFIG_ENABLE (1) - -/* Module information */ -#define SWP_AUTHOR "Neil " -#define SWP_DESC "Inventec port and transceiver driver" -#define SWP_VERSION "4.3.10" -#define SWP_LICENSE "GPL" - -/* Module status define */ -#define SWP_STATE_NORMAL (0) -#define SWP_STATE_I2C_DIE (-91) - -/* [Note]: - * Functions and mechanism for auto-detect platform type is ready, - * But HW and BIOS not ready! We need to wait them. - * So, please do not use PLATFORM_TYPE_AUTO until they are ready. - * (2016.06.13) - */ -#define PLATFORM_TYPE_AUTO (100) -#define PLATFORM_TYPE_MAGNOLIA (111) -#define PLATFORM_TYPE_MAGNOLIA_FNC (112) -#define PLATFORM_TYPE_REDWOOD (121) -#define PLATFORM_TYPE_REDWOOD_FSL (122) -#define PLATFORM_TYPE_HUDSON32I_GA (131) -#define PLATFORM_TYPE_SPRUCE (141) -#define PLATFORM_TYPE_CYPRESS_GA1 (151) /* Up -> Down */ -#define PLATFORM_TYPE_CYPRESS_GA2 (152) /* Down -> Up */ -#define PLATFORM_TYPE_CYPRESS_BAI (153) /* Down -> Up */ -#define PLATFORM_TYPE_TAHOE (161) -#define PLATFORM_TYPE_SEQUOIA_GA (171) -#define PLATFORM_TYPE_LAVENDER_GA (181) -#define PLATFORM_TYPE_LAVENDER_ONL (182) -#define PLATFORM_TYPE_COTTONWOOD_RANGELEY (191) -#define PLATFORM_TYPE_MAPLE_GA (201) -#define PLATFORM_TYPE_GULMOHAR_GA (202) -#define PLATFORM_TYPE_GULMOHAR_2T_EVT1_GA (203) -#define PLATFORM_TYPE_PEONY_SFP_GA (204) -#define PLATFORM_TYPE_PEONY_COPPER_GA (205) -#define PLATFORM_TYPE_PEONY_AUTO (206) -#define PLATFORM_TYPE_MAPLE_B (207) -#define PLATFORM_TYPE_MAPLE_J (208) -#define PLATFORM_TYPE_CEDAR_GA (209) -/* Current running platfrom */ -#define PLATFORM_SETTINGS PLATFORM_TYPE_LAVENDER_ONL - -/* Define platform flag and kernel version */ -#if (PLATFORM_SETTINGS == PLATFORM_TYPE_MAGNOLIA) - #define SWPS_MAGNOLIA (1) - #define SWPS_KERN_VER_BF_3_8 (1) -#elif (PLATFORM_SETTINGS == PLATFORM_TYPE_MAGNOLIA_FNC) - #define SWPS_MAGNOLIA (1) - #define SWPS_KERN_VER_AF_3_10 (1) -#elif (PLATFORM_SETTINGS == PLATFORM_TYPE_REDWOOD) - #define SWPS_REDWOOD (1) - #define SWPS_KERN_VER_BF_3_8 (1) -#elif (PLATFORM_SETTINGS == PLATFORM_TYPE_REDWOOD_FSL) - #define SWPS_REDWOOD_FSL (1) - #define SWPS_KERN_VER_BF_3_8 (1) -#elif (PLATFORM_SETTINGS == PLATFORM_TYPE_HUDSON32I_GA) - #define SWPS_HUDSON32I_GA (1) - #define SWPS_KERN_VER_BF_3_8 (1) -#elif (PLATFORM_SETTINGS == PLATFORM_TYPE_SPRUCE) - #define SWPS_SPRUCE (1) - #define SWPS_KERN_VER_BF_3_8 (1) -#elif (PLATFORM_SETTINGS == PLATFORM_TYPE_CYPRESS_GA1) - #define SWPS_CYPRESS_GA1 (1) - #define SWPS_KERN_VER_BF_3_8 (1) -#elif (PLATFORM_SETTINGS == PLATFORM_TYPE_CYPRESS_GA2) - #define SWPS_CYPRESS_GA2 (1) - #define SWPS_KERN_VER_BF_3_8 (1) -#elif (PLATFORM_SETTINGS == PLATFORM_TYPE_CYPRESS_BAI) - #define SWPS_CYPRESS_BAI (1) - #define SWPS_KERN_VER_AF_3_10 (1) -#elif (PLATFORM_SETTINGS == PLATFORM_TYPE_TAHOE) - #define SWPS_TAHOE (1) - #define SWPS_KERN_VER_AF_3_10 (1) -#elif (PLATFORM_SETTINGS == PLATFORM_TYPE_SEQUOIA_GA) - #define SWPS_SEQUOIA (1) - #define SWPS_KERN_VER_BF_3_8 (1) -#elif (PLATFORM_SETTINGS == PLATFORM_TYPE_LAVENDER_GA) - #define SWPS_LAVENDER (1) - #define SWPS_KERN_VER_AF_3_10 (1) -#elif (PLATFORM_SETTINGS == PLATFORM_TYPE_LAVENDER_ONL) - #define SWPS_LAVENDER (1) - #define SWPS_KERN_VER_AF_3_10 (1) -#elif (PLATFORM_SETTINGS == PLATFORM_TYPE_COTTONWOOD_RANGELEY) - #define SWPS_COTTONWOOD_RANGELEY (1) - #define SWPS_KERN_VER_AF_3_10 (1) -#elif (PLATFORM_SETTINGS == PLATFORM_TYPE_MAPLE_GA) - #define SWPS_MAPLE_GA (1) - #define SWPS_KERN_VER_AF_3_10 (1) -#elif (PLATFORM_SETTINGS == PLATFORM_TYPE_MAPLE_B) - #define SWPS_MAPLE_B (1) - #define SWPS_KERN_VER_AF_3_10 (1) -#elif (PLATFORM_SETTINGS == PLATFORM_TYPE_MAPLE_J) - #define SWPS_MAPLE_J (1) - #define SWPS_KERN_VER_AF_3_10 (1) -#elif (PLATFORM_SETTINGS == PLATFORM_TYPE_GULMOHAR_GA) - #define SWPS_GULMOHAR (1) - #define SWPS_KERN_VER_AF_3_10 (1) -#elif (PLATFORM_SETTINGS == PLATFORM_TYPE_GULMOHAR_2T_EVT1_GA) - #define SWPS_GULMOHAR_2T_EVT1 (1) - #define SWPS_KERN_VER_AF_3_10 (1) -#elif (PLATFORM_SETTINGS == PLATFORM_TYPE_PEONY_SFP_GA) - #define SWPS_PEONY_SFP (1) - #define SWPS_KERN_VER_AF_3_10 (1) -#elif (PLATFORM_SETTINGS == PLATFORM_TYPE_PEONY_COPPER_GA) - #define SWPS_PEONY_COPPER (1) - #define SWPS_KERN_VER_AF_3_10 (1) -#elif (PLATFORM_SETTINGS == PLATFORM_TYPE_PEONY_AUTO) - #define SWPS_PEONY_SFP (1) - #define SWPS_PEONY_COPPER (1) - #define SWPS_KERN_VER_AF_3_10 (1) -#elif (PLATFORM_SETTINGS == PLATFORM_TYPE_CEDAR_GA) - #define SWPS_CEDAR_GA (1) - #define SWPS_KERN_VER_AF_3_10 (1) -#endif - -struct inv_platform_s { - int id; - char name[64]; -}; - -struct inv_ioexp_layout_s { - int ioexp_id; - int ioexp_type; - struct ioexp_addr_s addr[4]; -}; - -struct inv_port_layout_s { - int port_id; - int chan_id; - int ioexp_id; - int ioexp_offset; - int transvr_type; - int chipset_type; - int lane_id[8]; -}; - - -/* ========================================== - * Inventec Platform Settings - * ========================================== - */ -struct inv_platform_s platform_map[] = { - {PLATFORM_TYPE_AUTO, "Auto-Detect" }, - {PLATFORM_TYPE_MAGNOLIA, "Magnolia" }, - {PLATFORM_TYPE_MAGNOLIA_FNC, "Magnolia_FNC" }, - {PLATFORM_TYPE_REDWOOD, "Redwood" }, - {PLATFORM_TYPE_REDWOOD_FSL, "Redwood_FSL" }, - {PLATFORM_TYPE_HUDSON32I_GA, "Hudson32i" }, - {PLATFORM_TYPE_SPRUCE, "Spruce" }, - {PLATFORM_TYPE_CYPRESS_GA1, "Cypress_GA1" }, - {PLATFORM_TYPE_CYPRESS_GA2, "Cypress_GA2" }, - {PLATFORM_TYPE_CYPRESS_BAI, "Cypress_BAI" }, - {PLATFORM_TYPE_TAHOE, "Tahoe" }, - {PLATFORM_TYPE_SEQUOIA_GA, "Sequoia_GA" }, - {PLATFORM_TYPE_LAVENDER_GA, "Lavender_GA" }, - {PLATFORM_TYPE_LAVENDER_ONL, "Lavender_ONL" }, - {PLATFORM_TYPE_COTTONWOOD_RANGELEY, "Cottonwood_RANGELEY" }, - {PLATFORM_TYPE_MAPLE_GA, "Maple_GA" }, - {PLATFORM_TYPE_MAPLE_B, "Maple_B" }, - {PLATFORM_TYPE_MAPLE_J, "Maple_J" }, - {PLATFORM_TYPE_GULMOHAR_GA, "Gulmohar_GA" }, - {PLATFORM_TYPE_GULMOHAR_2T_EVT1_GA, "Gulmohar_2T_EVT1_GA" }, - {PLATFORM_TYPE_PEONY_SFP_GA, "Peony_SFP_GA" }, - {PLATFORM_TYPE_PEONY_COPPER_GA, "Peony_Copper_GA" }, - {PLATFORM_TYPE_PEONY_AUTO, "Peony_Auto_Detect" }, - {PLATFORM_TYPE_CEDAR_GA, "Cedar_GA" }, -}; - - -/* ========================================== - * Magnolia Layout configuration - * ========================================== - */ -#ifdef SWPS_MAGNOLIA -unsigned magnolia_gpio_rest_mux = MUX_RST_GPIO_48_PCA9548; - -struct inv_ioexp_layout_s magnolia_ioexp_layout[] = { - /* IOEXP_ID / IOEXP_TYPE / { Chan_ID, Chip_addr, Read_offset, Write_offset, config_offset, data_default, conf_default } */ - {0, IOEXP_TYPE_MAGINOLIA_NAB, { {2, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {2, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, }, /* addr[1] = I/O Expander N B */ - }, - {1, IOEXP_TYPE_MAGINOLIA_NAB, { {3, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {3, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, }, /* addr[1] = I/O Expander N B */ - }, - {2, IOEXP_TYPE_MAGINOLIA_NAB, { {4, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {4, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, }, /* addr[1] = I/O Expander N B */ - }, - {3, IOEXP_TYPE_MAGINOLIA_4AB, { {5, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander 4 A */ - {5, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xf0, 0xff}, {0xf0, 0xff}, }, }, /* addr[1] = I/O Expander 4 B */ - }, - {4, IOEXP_TYPE_MAGINOLIA_NAB, { {6, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {6, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, }, /* addr[1] = I/O Expander N B */ - }, - {5, IOEXP_TYPE_MAGINOLIA_NAB, { {7, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {7, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, }, /* addr[1] = I/O Expander N B */ - }, - {6, IOEXP_TYPE_MAGINOLIA_7AB, { {8, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[0] = I/O Expander 7 A */ - {8, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xf0, 0x33}, }, }, /* addr[1] = I/O Expander 7 B */ - }, -}; - -struct inv_port_layout_s magnolia_port_layout[] = { - /* Port_ID / Chan_ID / IOEXP_ID / IOEXP_VIRT_OFFSET / TRANSCEIVER_TYPE / CHIP_TYPE / LANE_ID */ - { 0, 10, 0, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 16} }, - { 1, 11, 0, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 15} }, - { 2, 12, 0, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 14} }, - { 3, 13, 0, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 13} }, - { 4, 14, 0, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 24} }, - { 5, 15, 0, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 23} }, - { 6, 16, 0, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 22} }, - { 7, 17, 0, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 21} }, - { 8, 18, 1, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 28} }, - { 9, 19, 1, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 27} }, - {10, 20, 1, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 26} }, - {11, 21, 1, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 25} }, - {12, 22, 1, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 32} }, - {13, 23, 1, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 31} }, - {14, 24, 1, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 30} }, - {15, 25, 1, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 29} }, - {16, 26, 2, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 48} }, - {17, 27, 2, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 47} }, - {18, 28, 2, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 46} }, - {19, 29, 2, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 45} }, - {20, 30, 2, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 52} }, - {21, 31, 2, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 51} }, - {22, 32, 2, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 50} }, - {23, 33, 2, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 49} }, - {24, 34, 3, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 56} }, - {25, 35, 3, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 55} }, - {26, 36, 3, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 54} }, - {27, 37, 3, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 53} }, - {28, 38, 3, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 60} }, - {29, 39, 3, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 59} }, - {30, 40, 3, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 58} }, - {31, 41, 3, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 57} }, - {32, 42, 4, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 64} }, - {33, 43, 4, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 63} }, - {34, 44, 4, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 62} }, - {35, 45, 4, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 61} }, - {36, 46, 4, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 68} }, - {37, 47, 4, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 67} }, - {38, 48, 4, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 66} }, - {39, 49, 4, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 65} }, - {40, 50, 5, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 72} }, - {41, 51, 5, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 71} }, - {42, 52, 5, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 70} }, - {43, 53, 5, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 69} }, - {44, 54, 5, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 76} }, - {45, 55, 5, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 75} }, - {46, 56, 5, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 74} }, - {47, 57, 5, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 73} }, - {48, 58, 6, 0, TRANSVR_TYPE_QSFP, CHIP_TYPE_MAGNOLIA, { 81, 82, 83, 84} }, - {49, 59, 6, 1, TRANSVR_TYPE_QSFP, CHIP_TYPE_MAGNOLIA, { 77, 78, 79, 80} }, - {50, 60, 6, 2, TRANSVR_TYPE_QSFP, CHIP_TYPE_MAGNOLIA, { 97, 98, 99,100} }, - {51, 61, 6, 3, TRANSVR_TYPE_QSFP, CHIP_TYPE_MAGNOLIA, {101,102,103,104} }, - {52, 62, 6, 4, TRANSVR_TYPE_QSFP, CHIP_TYPE_MAGNOLIA, {105,106,107,108} }, - {53, 63, 6, 5, TRANSVR_TYPE_QSFP, CHIP_TYPE_MAGNOLIA, {109,110,111,112} }, -}; -#endif - - -/* ========================================== - * Redwood Layout configuration - * ========================================== - */ -#ifdef SWPS_REDWOOD -unsigned redwood_gpio_rest_mux = MUX_RST_GPIO_48_PCA9548; - -struct inv_ioexp_layout_s redwood_ioexp_layout[] = { - /* IOEXP_ID / IOEXP_TYPE / { Chan_ID, Chip_addr, Read_offset, Write_offset, config_offset, data_default, conf_default } */ - {0, IOEXP_TYPE_REDWOOD_P01P08, { {4, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[0] = I/O Expander 1-4 A */ - {4, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[1] = I/O Expander 1-4 B */ - {0, 0x25, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 5 B */ - }, - {1, IOEXP_TYPE_REDWOOD_P09P16, { {5, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[0] = I/O Expander 1-4 A */ - {5, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[1] = I/O Expander 1-4 B */ - {0, 0x25, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 5 B */ - }, - {2, IOEXP_TYPE_REDWOOD_P01P08, { {2, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[0] = I/O Expander 1-4 A */ - {2, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[1] = I/O Expander 1-4 B */ - {0, 0x24, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 5 B */ - }, - {3, IOEXP_TYPE_REDWOOD_P09P16, { {3, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[0] = I/O Expander 1-4 A */ - {3, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[1] = I/O Expander 1-4 B */ - {0, 0x24, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 5 B */ - }, -}; - -struct inv_port_layout_s redwood_port_layout[] = { - /* Port_ID / Chan_ID / IOEXP_ID / IOEXP_VIRT_OFFSET / TRANSCEIVER_TYPE / CHIP_TYPE / LANE_ID */ - { 0, 22, 0, 0, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 1, 2, 3, 4} }, - { 1, 23, 0, 1, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 5, 6, 7, 8} }, - { 2, 24, 0, 2, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 9, 10, 11, 12} }, - { 3, 25, 0, 3, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 13, 14, 15, 16} }, - { 4, 26, 0, 4, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 17, 18, 19, 20} }, - { 5, 27, 0, 5, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 21, 22, 23, 24} }, - { 6, 28, 0, 6, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 25, 26, 27, 28} }, - { 7, 29, 0, 7, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 29, 30, 31, 32} }, - { 8, 30, 1, 0, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 33, 34, 35, 36} }, - { 9, 31, 1, 1, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 37, 38, 39, 40} }, - {10, 32, 1, 2, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 41, 42, 43, 44} }, - {11, 33, 1, 3, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 45, 46, 47, 48} }, - {12, 34, 1, 4, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 49, 50, 51, 52} }, - {13, 35, 1, 5, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 53, 54, 55, 56} }, - {14, 36, 1, 6, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 57, 58, 59, 60} }, - {15, 37, 1, 7, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 61, 62, 63, 64} }, - {16, 6, 2, 0, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 65, 66, 67, 68} }, - {17, 7, 2, 1, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 69, 70, 71, 72} }, - {18, 8, 2, 2, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 73, 74, 75, 76} }, - {19, 9, 2, 3, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 77, 78, 79, 80} }, - {20, 10, 2, 4, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 81, 82, 83, 84} }, - {21, 11, 2, 5, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 85, 86, 87, 88} }, - {22, 12, 2, 6, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 89, 90, 91, 92} }, - {23, 13, 2, 7, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 93, 94, 95, 96} }, - {24, 14, 3, 0, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 97, 98, 99,100} }, - {25, 15, 3, 1, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {101,102,103,104} }, - {26, 16, 3, 2, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {105,106,107,108} }, - {27, 17, 3, 3, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {109,110,111,112} }, - {28, 18, 3, 4, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {113,114,115,116} }, - {29, 19, 3, 5, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {117,118,119,120} }, - {30, 20, 3, 6, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {121,122,123,124} }, - {31, 21, 3, 7, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {125,126,127,128} }, -}; -#endif - - -/* ========================================== - * Hudson32i Layout configuration - * ========================================== - */ -#ifdef SWPS_HUDSON32I_GA -unsigned hudsin32iga_gpio_rest_mux = MUX_RST_GPIO_48_PCA9548; - -struct inv_ioexp_layout_s hudson32iga_ioexp_layout[] = { - /* IOEXP_ID / IOEXP_TYPE / { Chan_ID, Chip_addr, Read_offset, Write_offset, config_offset, data_default, conf_default } */ - {0, IOEXP_TYPE_HUDSON32IGA_P01P08, { {2, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[0] = I/O Expander A */ - {2, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[1] = I/O Expander B */ - {0, 0x24, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 0x24 */ - }, - {1, IOEXP_TYPE_HUDSON32IGA_P09P16, { {3, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[0] = I/O Expander A */ - {3, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[1] = I/O Expander B */ - {0, 0x24, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 0x24 */ - }, - {2, IOEXP_TYPE_HUDSON32IGA_P01P08, { {4, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[0] = I/O Expander A */ - {4, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[1] = I/O Expander B */ - {0, 0x25, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 0x25 */ - }, - {3, IOEXP_TYPE_HUDSON32IGA_P09P16, { {5, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[0] = I/O Expander A */ - {5, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[1] = I/O Expander B */ - {0, 0x25, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 0x25 */ - }, -}; - -struct inv_port_layout_s hudson32iga_port_layout[] = { - /* Port_ID / Chan_ID / IOEXP_ID / IOEXP_VIRT_OFFSET / TRANSCEIVER_TYPE / CHIP_TYPE / LANE_ID */ - { 0, 6, 0, 0, TRANSVR_TYPE_QSFP_PLUS, CHIP_TYPE_MAGNOLIA, { 1, 2, 3, 4} }, - { 1, 7, 0, 1, TRANSVR_TYPE_QSFP_PLUS, CHIP_TYPE_MAGNOLIA, { 5, 6, 7, 8} }, - { 2, 8, 0, 2, TRANSVR_TYPE_QSFP_PLUS, CHIP_TYPE_MAGNOLIA, { 9, 10, 11, 12} }, - { 3, 9, 0, 3, TRANSVR_TYPE_QSFP_PLUS, CHIP_TYPE_MAGNOLIA, { 13, 14, 15, 16} }, - { 4, 10, 0, 4, TRANSVR_TYPE_QSFP_PLUS, CHIP_TYPE_MAGNOLIA, { 17, 18, 19, 20} }, - { 5, 11, 0, 5, TRANSVR_TYPE_QSFP_PLUS, CHIP_TYPE_MAGNOLIA, { 21, 22, 23, 24} }, - { 6, 12, 0, 6, TRANSVR_TYPE_QSFP_PLUS, CHIP_TYPE_MAGNOLIA, { 25, 26, 27, 28} }, - { 7, 13, 0, 7, TRANSVR_TYPE_QSFP_PLUS, CHIP_TYPE_MAGNOLIA, { 29, 30, 31, 32} }, - { 8, 14, 1, 0, TRANSVR_TYPE_QSFP_PLUS, CHIP_TYPE_MAGNOLIA, { 33, 34, 35, 36} }, - { 9, 15, 1, 1, TRANSVR_TYPE_QSFP_PLUS, CHIP_TYPE_MAGNOLIA, { 37, 38, 39, 40} }, - {10, 16, 1, 2, TRANSVR_TYPE_QSFP_PLUS, CHIP_TYPE_MAGNOLIA, { 41, 42, 43, 44} }, - {11, 17, 1, 3, TRANSVR_TYPE_QSFP_PLUS, CHIP_TYPE_MAGNOLIA, { 45, 46, 47, 48} }, - {12, 18, 1, 4, TRANSVR_TYPE_QSFP_PLUS, CHIP_TYPE_MAGNOLIA, { 49, 50, 51, 52} }, - {13, 19, 1, 5, TRANSVR_TYPE_QSFP_PLUS, CHIP_TYPE_MAGNOLIA, { 53, 54, 55, 56} }, - {14, 20, 1, 6, TRANSVR_TYPE_QSFP_PLUS, CHIP_TYPE_MAGNOLIA, { 57, 58, 59, 60} }, - {15, 21, 1, 7, TRANSVR_TYPE_QSFP_PLUS, CHIP_TYPE_MAGNOLIA, { 61, 62, 63, 64} }, - {16, 22, 2, 0, TRANSVR_TYPE_QSFP_PLUS, CHIP_TYPE_MAGNOLIA, { 65, 66, 67, 68} }, - {17, 23, 2, 1, TRANSVR_TYPE_QSFP_PLUS, CHIP_TYPE_MAGNOLIA, { 69, 70, 71, 72} }, - {18, 24, 2, 2, TRANSVR_TYPE_QSFP_PLUS, CHIP_TYPE_MAGNOLIA, { 73, 74, 75, 76} }, - {19, 25, 2, 3, TRANSVR_TYPE_QSFP_PLUS, CHIP_TYPE_MAGNOLIA, { 77, 78, 79, 80} }, - {20, 26, 2, 4, TRANSVR_TYPE_QSFP_PLUS, CHIP_TYPE_MAGNOLIA, { 81, 82, 83, 84} }, - {21, 27, 2, 5, TRANSVR_TYPE_QSFP_PLUS, CHIP_TYPE_MAGNOLIA, { 85, 86, 87, 88} }, - {22, 28, 2, 6, TRANSVR_TYPE_QSFP_PLUS, CHIP_TYPE_MAGNOLIA, { 89, 90, 91, 92} }, - {23, 29, 2, 7, TRANSVR_TYPE_QSFP_PLUS, CHIP_TYPE_MAGNOLIA, { 93, 94, 95, 96} }, - {24, 30, 3, 0, TRANSVR_TYPE_QSFP_PLUS, CHIP_TYPE_MAGNOLIA, { 97, 98, 99,100} }, - {25, 31, 3, 1, TRANSVR_TYPE_QSFP_PLUS, CHIP_TYPE_MAGNOLIA, {101,102,103,104} }, - {26, 32, 3, 2, TRANSVR_TYPE_QSFP_PLUS, CHIP_TYPE_MAGNOLIA, {105,106,107,108} }, - {27, 33, 3, 3, TRANSVR_TYPE_QSFP_PLUS, CHIP_TYPE_MAGNOLIA, {109,110,111,112} }, - {28, 34, 3, 4, TRANSVR_TYPE_QSFP_PLUS, CHIP_TYPE_MAGNOLIA, {113,114,115,116} }, - {29, 35, 3, 5, TRANSVR_TYPE_QSFP_PLUS, CHIP_TYPE_MAGNOLIA, {117,118,119,120} }, - {30, 36, 3, 6, TRANSVR_TYPE_QSFP_PLUS, CHIP_TYPE_MAGNOLIA, {121,122,123,124} }, - {31, 37, 3, 7, TRANSVR_TYPE_QSFP_PLUS, CHIP_TYPE_MAGNOLIA, {125,126,127,128} }, -}; -#endif - - -/* ========================================== - * Spruce Layout configuration - * ========================================== - */ -#ifdef SWPS_SPRUCE -unsigned spruce_gpio_rest_mux = MUX_RST_GPIO_48_PCA9548; - -struct inv_ioexp_layout_s spruce_ioexp_layout[] = { - /* IOEXP_ID / IOEXP_TYPE / { Chan_ID, Chip_addr, Read_offset, Write_offset, config_offset, data_default, conf_default } */ - {0, IOEXP_TYPE_SPRUCE_7AB, { {2, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[0] = I/O Expander 7A */ - {2, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xf0, 0x33}, }, }, /* addr[2] = I/O Expander 7B */ - }, -}; - -struct inv_port_layout_s spruce_port_layout[] = { - /* Port_ID / Chan_ID / IOEXP_ID / IOEXP_VIRT_OFFSET / TRANSCEIVER_TYPE / CHIP_TYPE / LANE_ID */ - { 0, 6, 0, 0, TRANSVR_TYPE_QSFP_PLUS, CHIP_TYPE_MAGNOLIA, { 81, 82, 83, 84} }, - { 1, 7, 0, 1, TRANSVR_TYPE_QSFP_PLUS, CHIP_TYPE_MAGNOLIA, { 77, 78, 79, 80} }, - { 2, 8, 0, 2, TRANSVR_TYPE_QSFP_PLUS, CHIP_TYPE_MAGNOLIA, { 97, 98, 99,100} }, - { 3, 9, 0, 3, TRANSVR_TYPE_QSFP_PLUS, CHIP_TYPE_MAGNOLIA, {101,102,103,104} }, - { 4, 10, 0, 4, TRANSVR_TYPE_QSFP_PLUS, CHIP_TYPE_MAGNOLIA, {105,106,107,108} }, - { 5, 11, 0, 5, TRANSVR_TYPE_QSFP_PLUS, CHIP_TYPE_MAGNOLIA, {109,110,111,112} }, -}; -#endif - - -/* ========================================== - * Cypress Layout configuration (Inventec version [Up->Down]) - * ========================================== - */ -#ifdef SWPS_CYPRESS_GA1 -unsigned cypress_ga1_gpio_rest_mux = MUX_RST_GPIO_69_PCA9548; - -struct inv_ioexp_layout_s cypress_ga1_ioexp_layout[] = { - /* IOEXP_ID / IOEXP_TYPE / { Chan_ID, Chip_addr, Read_offset, Write_offset, config_offset, data_default, conf_default } */ - {0, IOEXP_TYPE_SFP_8P_LAYOUT_1, { {2, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {2, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {2, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {1, IOEXP_TYPE_SFP_8P_LAYOUT_1, { {3, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {3, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {3, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {2, IOEXP_TYPE_SFP_8P_LAYOUT_1, { {4, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {4, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {4, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {3, IOEXP_TYPE_SFP_8P_LAYOUT_1, { {5, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {5, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {5, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {4, IOEXP_TYPE_SFP_8P_LAYOUT_1, { {6, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {6, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {6, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {5, IOEXP_TYPE_SFP_8P_LAYOUT_1, { {7, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {7, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {7, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {6, IOEXP_TYPE_CYPRESS_7ABC, { {8, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xc0, 0xc0}, }, /* addr[0] = I/O Expander 7 A */ - {8, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xc0, 0xc0}, {0xff, 0xc0}, }, /* addr[1] = I/O Expander 7 B */ - {8, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 7 C */ - }, -}; - -struct inv_port_layout_s cypress_ga1_port_layout[] = { - /* Port_ID / Chan_ID / IOEXP_ID / IOEXP_VIRT_OFFSET / TRANSCEIVER_TYPE / CHIP_TYPE / LANE_ID */ - { 0, 10, 0, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 1} }, - { 1, 11, 0, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 2} }, - { 2, 12, 0, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 3} }, - { 3, 13, 0, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 4} }, - { 4, 14, 0, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 5} }, - { 5, 15, 0, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 6} }, - { 6, 16, 0, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 7} }, - { 7, 17, 0, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 8} }, - { 8, 18, 1, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 9} }, - { 9, 19, 1, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 10} }, - {10, 20, 1, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 11} }, - {11, 21, 1, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 12} }, - {12, 22, 1, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 21} }, - {13, 23, 1, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 22} }, - {14, 24, 1, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 23} }, - {15, 25, 1, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 24} }, - {16, 26, 2, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 33} }, - {17, 27, 2, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 34} }, - {18, 28, 2, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 35} }, - {19, 29, 2, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 36} }, - {20, 30, 2, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 37} }, - {21, 31, 2, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 38} }, - {22, 32, 2, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 39} }, - {23, 33, 2, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 40} }, - {24, 34, 3, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 41} }, - {25, 35, 3, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 42} }, - {26, 36, 3, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 43} }, - {27, 37, 3, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 44} }, - {28, 38, 3, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 49} }, - {29, 39, 3, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 50} }, - {30, 40, 3, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 51} }, - {31, 41, 3, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 52} }, - {32, 42, 4, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 53} }, - {33, 43, 4, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 54} }, - {34, 44, 4, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 55} }, - {35, 45, 4, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 56} }, - {36, 46, 4, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 65} }, - {37, 47, 4, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 66} }, - {38, 48, 4, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 67} }, - {39, 49, 4, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 68} }, - {40, 50, 5, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 69} }, - {41, 51, 5, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 70} }, - {42, 52, 5, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 71} }, - {43, 53, 5, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 72} }, - {44, 54, 5, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 81} }, - {45, 55, 5, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 82} }, - {46, 56, 5, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 83} }, - {47, 57, 5, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 84} }, - {48, 58, 6, 0, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 97, 98, 99,100} }, - {49, 59, 6, 1, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 85, 86, 87, 88} }, - {50, 60, 6, 2, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {101,102,103,104} }, - {51, 61, 6, 3, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {105,106,107,108} }, - {52, 62, 6, 4, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {109,110,111,112} }, - {53, 63, 6, 5, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {117,118,119,120} }, -}; -#endif - - -/* ========================================== - * Cypress Layout configuration (Inventec version [Down->Up]) - * ========================================== - */ -#ifdef SWPS_CYPRESS_GA2 -unsigned cypress_ga2_gpio_rest_mux = MUX_RST_GPIO_FORCE_HEDERA; - -struct inv_ioexp_layout_s cypress_ga2_ioexp_layout[] = { - /* IOEXP_ID / IOEXP_TYPE / { Chan_ID, Chip_addr, Read_offset, Write_offset, config_offset, data_default, conf_default } */ - {0, IOEXP_TYPE_SFP_8P_LAYOUT_1, { {2, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {2, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {2, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {1, IOEXP_TYPE_SFP_8P_LAYOUT_1, { {3, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {3, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {3, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {2, IOEXP_TYPE_SFP_8P_LAYOUT_1, { {4, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {4, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {4, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {3, IOEXP_TYPE_SFP_8P_LAYOUT_1, { {5, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {5, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {5, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {4, IOEXP_TYPE_SFP_8P_LAYOUT_1, { {6, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {6, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {6, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {5, IOEXP_TYPE_SFP_8P_LAYOUT_1, { {7, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {7, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {7, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {6, IOEXP_TYPE_CYPRESS_7ABC, { {8, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xc0, 0xc0}, }, /* addr[0] = I/O Expander 7 A */ - {8, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xc0, 0xc0}, {0xff, 0xc0}, }, /* addr[1] = I/O Expander 7 B */ - {8, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 7 C */ - }, -}; - -struct inv_port_layout_s cypress_ga2_port_layout[] = { - /* Port_ID / Chan_ID / IOEXP_ID / IOEXP_VIRT_OFFSET / TRANSCEIVER_TYPE / CHIP_TYPE / LANE_ID */ - { 0, 11, 0, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 2} }, - { 1, 10, 0, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 1} }, - { 2, 13, 0, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 4} }, - { 3, 12, 0, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 3} }, - { 4, 15, 0, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 6} }, - { 5, 14, 0, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 5} }, - { 6, 17, 0, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 8} }, - { 7, 16, 0, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 7} }, - { 8, 19, 1, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 10} }, - { 9, 18, 1, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 9} }, - {10, 21, 1, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 12} }, - {11, 20, 1, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 11} }, - {12, 23, 1, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 22} }, - {13, 22, 1, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 21} }, - {14, 25, 1, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 24} }, - {15, 24, 1, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 23} }, - {16, 27, 2, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 34} }, - {17, 26, 2, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 33} }, - {18, 29, 2, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 36} }, - {19, 28, 2, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 35} }, - {20, 31, 2, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 38} }, - {21, 30, 2, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 37} }, - {22, 33, 2, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 40} }, - {23, 32, 2, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 39} }, - {24, 35, 3, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 42} }, - {25, 34, 3, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 41} }, - {26, 37, 3, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 44} }, - {27, 36, 3, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 43} }, - {28, 39, 3, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 50} }, - {29, 38, 3, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 49} }, - {30, 41, 3, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 52} }, - {31, 40, 3, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 51} }, - {32, 43, 4, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 54} }, - {33, 42, 4, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 53} }, - {34, 45, 4, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 56} }, - {35, 44, 4, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 55} }, - {36, 47, 4, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 66} }, - {37, 46, 4, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 65} }, - {38, 49, 4, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 68} }, - {39, 48, 4, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 67} }, - {40, 51, 5, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 70} }, - {41, 50, 5, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 69} }, - {42, 53, 5, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 72} }, - {43, 52, 5, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 71} }, - {44, 55, 5, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 82} }, - {45, 54, 5, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 81} }, - {46, 57, 5, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 84} }, - {47, 56, 5, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 83} }, - {48, 59, 6, 1, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 85, 86, 87, 88} }, - {49, 58, 6, 0, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 97, 98, 99,100} }, - {50, 61, 6, 3, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {105,106,107,108} }, - {51, 60, 6, 2, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {101,102,103,104} }, - {52, 63, 6, 5, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {117,118,119,120} }, - {53, 62, 6, 4, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {109,110,111,112} }, -}; -#endif - - -/* ========================================== - * Cypress Layout configuration (C1 version) - * ========================================== - */ -#ifdef SWPS_CYPRESS_BAI -unsigned cypress_b_gpio_rest_mux = MUX_RST_GPIO_FORCE_HEDERA; - -struct inv_ioexp_layout_s cypress_b_ioexp_layout[] = { - /* IOEXP_ID / IOEXP_TYPE / { Chan_ID, Chip_addr, Read_offset, Write_offset, config_offset, data_default, conf_default } */ - {0, IOEXP_TYPE_SFP_8P_LAYOUT_1, { {2, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {2, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {2, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {1, IOEXP_TYPE_SFP_8P_LAYOUT_1, { {3, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {3, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {3, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {2, IOEXP_TYPE_SFP_8P_LAYOUT_1, { {4, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {4, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {4, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {3, IOEXP_TYPE_SFP_8P_LAYOUT_1, { {5, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {5, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {5, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {4, IOEXP_TYPE_SFP_8P_LAYOUT_1, { {6, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {6, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {6, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {5, IOEXP_TYPE_SFP_8P_LAYOUT_1, { {7, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {7, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {7, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {6, IOEXP_TYPE_CYPRESS_7ABC, { {8, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xc0, 0xc0}, }, /* addr[0] = I/O Expander 7 A */ - {8, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xc0, 0xc0}, {0xff, 0xc0}, }, /* addr[1] = I/O Expander 7 B */ - {8, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 7 C */ - }, -}; - -struct inv_port_layout_s cypress_b_port_layout[] = { - /* Port_ID / Chan_ID / IOEXP_ID / IOEXP_VIRT_OFFSET / TRANSCEIVER_TYPE / CHIP_TYPE / LANE_ID */ - { 1, 11, 0, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 2} }, - { 2, 10, 0, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 1} }, - { 3, 13, 0, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 4} }, - { 4, 12, 0, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 3} }, - { 5, 15, 0, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 6} }, - { 6, 14, 0, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 5} }, - { 7, 17, 0, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 8} }, - { 8, 16, 0, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 7} }, - { 9, 19, 1, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 10} }, - {10, 18, 1, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 9} }, - {11, 21, 1, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 12} }, - {12, 20, 1, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 11} }, - {13, 23, 1, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 22} }, - {14, 22, 1, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 21} }, - {15, 25, 1, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 24} }, - {16, 24, 1, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 23} }, - {17, 27, 2, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 34} }, - {18, 26, 2, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 33} }, - {19, 29, 2, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 36} }, - {20, 28, 2, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 35} }, - {21, 31, 2, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 38} }, - {22, 30, 2, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 37} }, - {23, 33, 2, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 40} }, - {24, 32, 2, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 39} }, - {25, 35, 3, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 42} }, - {26, 34, 3, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 41} }, - {27, 37, 3, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 44} }, - {28, 36, 3, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 43} }, - {29, 39, 3, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 50} }, - {30, 38, 3, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 49} }, - {31, 41, 3, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 52} }, - {32, 40, 3, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 51} }, - {33, 43, 4, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 54} }, - {34, 42, 4, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 53} }, - {35, 45, 4, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 56} }, - {36, 44, 4, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 55} }, - {37, 47, 4, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 66} }, - {38, 46, 4, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 65} }, - {39, 49, 4, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 68} }, - {40, 48, 4, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 67} }, - {41, 51, 5, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 70} }, - {42, 50, 5, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 69} }, - {43, 53, 5, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 72} }, - {44, 52, 5, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 71} }, - {45, 55, 5, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 82} }, - {46, 54, 5, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 81} }, - {47, 57, 5, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 84} }, - {48, 56, 5, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 83} }, - {49, 59, 6, 1, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 85, 86, 87, 88} }, - {50, 58, 6, 0, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 97, 98, 99,100} }, - {51, 61, 6, 3, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {105,106,107,108} }, - {52, 60, 6, 2, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {101,102,103,104} }, - {53, 63, 6, 5, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {117,118,119,120} }, - {54, 62, 6, 4, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {109,110,111,112} }, -}; -#endif - - -/* ========================================== - * Redwood_fsl Layout configuration - * ========================================== - */ -#ifdef SWPS_REDWOOD_FSL -unsigned redwood_fsl_gpio_rest_mux = MUX_RST_GPIO_48_PCA9548; - -struct inv_ioexp_layout_s redwood_fsl_ioexp_layout[] = { - /* IOEXP_ID / IOEXP_TYPE / { Chan_ID, Chip_addr, Read_offset, Write_offset, config_offset, data_default, conf_default } */ - {0, IOEXP_TYPE_REDWOOD_P01P08, { {4, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[0] = I/O Expander 1-4 A */ - {4, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[1] = I/O Expander 1-4 B */ - {0, 0x25, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 5 B */ - }, - {1, IOEXP_TYPE_REDWOOD_P09P16, { {5, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[0] = I/O Expander 1-4 A */ - {5, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[1] = I/O Expander 1-4 B */ - {0, 0x25, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 5 B */ - }, - {2, IOEXP_TYPE_REDWOOD_P01P08, { {2, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[0] = I/O Expander 1-4 A */ - {2, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[1] = I/O Expander 1-4 B */ - {0, 0x24, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 5 B */ - }, - {3, IOEXP_TYPE_REDWOOD_P09P16, { {3, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[0] = I/O Expander 1-4 A */ - {3, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[1] = I/O Expander 1-4 B */ - {0, 0x24, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 5 B */ - }, -}; - - -struct inv_port_layout_s redwood_fsl_port_layout[] = { - /* Port_ID / Chan_ID / IOEXP_ID / IOEXP_VIRT_OFFSET / TRANSCEIVER_TYPE / CHIP_TYPE / LANE_ID */ - { 0, 22, 0, 0, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 1, 2, 3, 4} }, - { 1, 23, 0, 1, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 5, 6, 7, 8} }, - { 2, 24, 0, 2, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 9, 10, 11, 12} }, - { 3, 25, 0, 3, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 13, 14, 15, 16} }, - { 4, 26, 0, 4, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 17, 18, 19, 20} }, - { 5, 27, 0, 5, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 21, 22, 23, 24} }, - { 6, 28, 0, 6, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 25, 26, 27, 28} }, - { 7, 29, 0, 7, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 29, 30, 31, 32} }, - { 8, 30, 1, 0, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 33, 34, 35, 36} }, - { 9, 31, 1, 1, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 37, 38, 39, 40} }, - {10, 32, 1, 2, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 41, 42, 43, 44} }, - {11, 33, 1, 3, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 45, 46, 47, 48} }, - {12, 34, 1, 4, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 49, 50, 51, 52} }, - {13, 35, 1, 5, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 53, 54, 55, 56} }, - {14, 36, 1, 6, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 57, 58, 59, 60} }, - {15, 37, 1, 7, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 61, 62, 63, 64} }, - {16, 6, 2, 0, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 65, 66, 67, 68} }, - {17, 7, 2, 1, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 69, 70, 71, 72} }, - {18, 8, 2, 2, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 73, 74, 75, 76} }, - {19, 9, 2, 3, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 77, 78, 79, 80} }, - {20, 10, 2, 4, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 81, 82, 83, 84} }, - {21, 11, 2, 5, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 85, 86, 87, 88} }, - {22, 12, 2, 6, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 89, 90, 91, 92} }, - {23, 13, 2, 7, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 93, 94, 95, 96} }, - {24, 14, 3, 0, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 97, 98, 99,100} }, - {25, 15, 3, 1, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {101,102,103,104} }, - {26, 16, 3, 2, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {105,106,107,108} }, - {27, 17, 3, 3, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {109,110,111,112} }, - {28, 18, 3, 4, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {113,114,115,116} }, - {29, 19, 3, 5, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {117,118,119,120} }, - {30, 20, 3, 6, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {121,122,123,124} }, - {31, 21, 3, 7, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {125,126,127,128} }, -}; -#endif - - -/* ========================================== - * Tahoe Layout configuration - * ========================================== - */ -#ifdef SWPS_TAHOE -unsigned tahoe_gpio_rest_mux = MUX_RST_GPIO_249_PCA9548; - -struct inv_ioexp_layout_s tahoe_ioexp_layout[] = { - /* IOEXP_ID / IOEXP_TYPE / { Chan_ID, Chip_addr, Read_offset, Write_offset, config_offset, data_default, conf_default } */ - {0, IOEXP_TYPE_TAHOE_6ABC, { {7, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xce, 0xb9}, {0x18, 0xe3}, }, /* addr[0] = I/O Expander 6 A */ - {7, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xce, 0xb9}, {0x18, 0xe3}, }, /* addr[1] = I/O Expander 6 B */ - {7, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xce, 0xb9}, {0x18, 0xe3}, }, }, /* addr[2] = I/O Expander 6 C */ - }, - {1, IOEXP_TYPE_TAHOE_5A, { {6, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xce, 0xb9}, {0x18, 0xe3}, }, }, /* addr[0] = I/O Expander 5 A */ - }, -}; - - -struct inv_port_layout_s tahoe_port_layout[] = { - /* Port_ID / Chan_ID / IOEXP_ID / IOEXP_VIRT_OFFSET / TRANSCEIVER_TYPE / CHIP_TYPE / LANE_ID */ - { 0, 12, 1, 2, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 65, 66, 67, 68} }, - { 1, 11, 1, 1, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 53, 54, 55, 56} }, - { 2, 22, 0, 5, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 69, 70, 71, 72} }, - { 3, 21, 0, 4, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 81, 82, 83, 84} }, - { 4, 24, 0, 7, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 97, 98, 99, 100} }, - { 5, 23, 0, 6, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 85, 86, 87, 88} }, - { 6, 18, 0, 1, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {101, 102, 103, 104} }, - { 7, 17, 0, 0, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {105, 106, 107, 108} }, - { 8, 20, 0, 3, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {113, 114, 115, 116} }, - { 9, 19, 0, 2, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {109, 110, 111, 112} }, -}; -#endif - - -/* ========================================== - * Sequoia Layout configuration - * ========================================== - */ -#ifdef SWPS_SEQUOIA -unsigned sequoia_gpio_rest_mux = MUX_RST_GPIO_69_PCA9548; - -struct inv_ioexp_layout_s sequoia_ioexp_layout[] = { - /* IOEXP_ID / IOEXP_TYPE / { Chan_ID, Chip_addr, Read_offset, Write_offset, config_offset, data_default, conf_default } */ - {0, IOEXP_TYPE_SEQUOIA_NABC, { {1, 0x20, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0x00, 0x00}, }, /* addr[0] = I/O Expander 0 A */ - {1, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0xff}, }, /* addr[1] = I/O Expander 0 B */ - {1, 0x22, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 0 C */ - }, - {1, IOEXP_TYPE_SEQUOIA_NABC, { {2, 0x20, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0x00, 0x00}, }, /* addr[0] = I/O Expander 1 A */ - {2, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0xff}, }, /* addr[1] = I/O Expander 1 B */ - {2, 0x22, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 1 C */ - }, - {2, IOEXP_TYPE_SEQUOIA_NABC, { {3, 0x20, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0x00, 0x00}, }, /* addr[0] = I/O Expander 2 A */ - {3, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0xff}, }, /* addr[1] = I/O Expander 2 B */ - {3, 0x22, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 2 C */ - }, - {3, IOEXP_TYPE_SEQUOIA_NABC, { {4, 0x20, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0x00, 0x00}, }, /* addr[0] = I/O Expander 3 A */ - {4, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0xff}, }, /* addr[1] = I/O Expander 3 B */ - {4, 0x22, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 3 C */ - }, - {4, IOEXP_TYPE_SEQUOIA_NABC, { {5, 0x20, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0x00, 0x00}, }, /* addr[0] = I/O Expander 4 A */ - {5, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0xff}, }, /* addr[1] = I/O Expander 4 B */ - {5, 0x22, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 4 C */ - }, - {5, IOEXP_TYPE_SEQUOIA_NABC, { {6, 0x20, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0x00, 0x00}, }, /* addr[0] = I/O Expander 5 A */ - {6, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0xff}, }, /* addr[1] = I/O Expander 5 B */ - {6, 0x22, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 5 C */ - }, - {6, IOEXP_TYPE_SEQUOIA_NABC, { {7, 0x20, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0x00, 0x00}, }, /* addr[0] = I/O Expander 6 A */ - {7, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0xff}, }, /* addr[1] = I/O Expander 6 B */ - {7, 0x22, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 6 C */ - }, - {7, IOEXP_TYPE_SEQUOIA_NABC, { {8, 0x20, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0x00, 0x00}, }, /* addr[0] = I/O Expander 7 A */ - {8, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0xff}, }, /* addr[1] = I/O Expander 7 B */ - {8, 0x22, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 7 C */ - }, -}; - - -struct inv_port_layout_s sequoia_port_layout[] = { - /* Port_ID / Chan_ID / IOEXP_ID / IOEXP_VIRT_OFFSET / TRANSCEIVER_TYPE / CHIP_TYPE / LANE_ID */ - { 0, 9, 0, 0, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 9, 10, 11, 12} }, - { 1, 10, 0, 1, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 1, 2, 3, 4} }, - { 2, 11, 0, 2, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 25, 26, 27, 28} }, - { 3, 12, 0, 3, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 17, 18, 19, 20} }, - { 4, 13, 0, 4, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 41, 42, 43, 44} }, - { 5, 14, 0, 5, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 33, 34, 35, 36} }, - { 6, 15, 0, 6, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 57, 58, 59, 60} }, - { 7, 16, 0, 7, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 49, 50, 51, 52} }, - { 8, 17, 1, 0, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 73, 74, 75, 76} }, - { 9, 18, 1, 1, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 65, 66, 67, 68} }, - {10, 19, 1, 2, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 89, 90, 91, 92} }, - {11, 20, 1, 3, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 81, 82, 83, 84} }, - {12, 21, 1, 4, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {105, 106, 107, 108} }, - {13, 22, 1, 5, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 97, 98, 99, 100} }, - {14, 23, 1, 6, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {121, 122, 123, 124} }, - {15, 24, 1, 7, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {113, 114, 115, 116} }, - {16, 25, 2, 0, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {137, 138, 139, 140} }, - {17, 26, 2, 1, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {129, 130, 131, 132} }, - {18, 27, 2, 2, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {153, 154, 155, 156} }, - {19, 28, 2, 3, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {145, 146, 147, 148} }, - {20, 29, 2, 4, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {169, 170, 171, 172} }, - {21, 30, 2, 5, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {161, 162, 163, 164} }, - {22, 31, 2, 6, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {185, 186, 187, 188} }, - {23, 32, 2, 7, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {177, 178, 179, 180} }, - {24, 33, 3, 0, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {201, 202, 203, 204} }, - {25, 34, 3, 1, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {193, 194, 195, 196} }, - {26, 35, 3, 2, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {217, 218, 219, 220} }, - {27, 36, 3, 3, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {209, 210, 211, 212} }, - {28, 37, 3, 4, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {233, 234, 235, 236} }, - {29, 38, 3, 5, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {225, 226, 227, 228} }, - {30, 39, 3, 6, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {249, 250, 251, 252} }, - {31, 40, 3, 7, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {241, 242, 243, 244} }, - {32, 44, 4, 3, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 13, 14, 15, 16} }, - {33, 43, 4, 2, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 5, 6, 7, 8} }, - {34, 42, 4, 1, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 29, 30, 31, 32} }, - {35, 41, 4, 0, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 21, 22, 23, 24} }, - {36, 48, 4, 7, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 45, 46, 47, 48} }, - {37, 47, 4, 6, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 37, 38, 39, 40} }, - {38, 46, 4, 5, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 61, 62, 63, 64} }, - {39, 45, 4, 4, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 53, 54, 55, 56} }, - {40, 52, 5, 3, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 77, 78, 79, 80} }, - {41, 51, 5, 2, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 69, 70, 71, 72} }, - {42, 50, 5, 1, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 93, 94, 95, 96} }, - {43, 49, 5, 0, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 85, 86, 87, 88} }, - {44, 56, 5, 7, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {109, 110, 111, 112} }, - {45, 55, 5, 6, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {101, 102, 103, 104} }, - {46, 54, 5, 5, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {125, 126, 127, 128} }, - {47, 53, 5, 4, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {117, 118, 119, 120} }, - {48, 60, 6, 3, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {141, 142, 143, 144} }, - {49, 59, 6, 2, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {133, 134, 135, 136} }, - {50, 58, 6, 1, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {157, 158, 159, 160} }, - {51, 57, 6, 0, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {149, 150, 151, 152} }, - {52, 64, 6, 7, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {173, 174, 175, 176} }, - {53, 63, 6, 6, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {165, 166, 167, 168} }, - {54, 62, 6, 5, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {189, 190, 191, 192} }, - {55, 61, 6, 4, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {181, 182, 183, 184} }, - {56, 68, 7, 3, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {205, 206, 207, 208} }, - {57, 67, 7, 2, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {197, 198, 199, 200} }, - {58, 66, 7, 1, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {221, 222, 223, 224} }, - {59, 65, 7, 0, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {213, 214, 215, 216} }, - {60, 72, 7, 7, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {237, 238, 239, 240} }, - {61, 71, 7, 6, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {229, 230, 231, 232} }, - {62, 70, 7, 5, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {253, 254, 255, 256} }, - {63, 69, 7, 4, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {245, 246, 247, 248} }, -}; -#endif - - -/* ========================================== - * Lavender Layout configuration - * ========================================== - */ -#if (PLATFORM_SETTINGS == PLATFORM_TYPE_LAVENDER_GA) -unsigned lavender_gpio_rest_mux = MUX_RST_GPIO_505_PCA9548; -#elif (PLATFORM_SETTINGS == PLATFORM_TYPE_LAVENDER_ONL) -unsigned lavender_gpio_rest_mux = MUX_RST_GPIO_69_PCA9548; -#endif - -#ifdef SWPS_LAVENDER -struct inv_ioexp_layout_s lavender_ioexp_layout[] = { - /* IOEXP_ID / IOEXP_TYPE / { Chan_ID, Chip_addr, Read_offset, Write_offset, config_offset, data_default, conf_default } */ - {0, IOEXP_TYPE_SEQUOIA_NABC, { { 1, 0x20, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0x00, 0x00}, }, /* addr[0] = I/O Expander 0 A */ - { 1, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0xff}, }, /* addr[1] = I/O Expander 0 B */ - { 1, 0x22, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 0 C */ - }, - {1, IOEXP_TYPE_SEQUOIA_NABC, { { 2, 0x20, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0x00, 0x00}, }, /* addr[0] = I/O Expander 1 A */ - { 2, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0xff}, }, /* addr[1] = I/O Expander 1 B */ - { 2, 0x22, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 1 C */ - }, - {2, IOEXP_TYPE_SEQUOIA_NABC, { { 3, 0x20, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0x00, 0x00}, }, /* addr[0] = I/O Expander 2 A */ - { 3, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0xff}, }, /* addr[1] = I/O Expander 2 B */ - { 3, 0x22, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 2 C */ - }, - {3, IOEXP_TYPE_SEQUOIA_NABC, { { 4, 0x20, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0x00, 0x00}, }, /* addr[0] = I/O Expander 3 A */ - { 4, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0xff}, }, /* addr[1] = I/O Expander 3 B */ - { 4, 0x22, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 3 C */ - }, - {4, IOEXP_TYPE_SEQUOIA_NABC, { { 9, 0x20, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0x00, 0x00}, }, /* addr[0] = I/O Expander 4 A */ - { 9, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0xff}, }, /* addr[1] = I/O Expander 4 B */ - { 9, 0x22, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 4 C */ - }, - {5, IOEXP_TYPE_SEQUOIA_NABC, { {10, 0x20, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0x00, 0x00}, }, /* addr[0] = I/O Expander 5 A */ - {10, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0xff}, }, /* addr[1] = I/O Expander 5 B */ - {10, 0x22, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 5 C */ - }, - {6, IOEXP_TYPE_SEQUOIA_NABC, { {11, 0x20, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0x00, 0x00}, }, /* addr[0] = I/O Expander 6 A */ - {11, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0xff}, }, /* addr[1] = I/O Expander 6 B */ - {11, 0x22, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 6 C */ - }, - {7, IOEXP_TYPE_SEQUOIA_NABC, { {12, 0x20, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0x00, 0x00}, }, /* addr[0] = I/O Expander 7 A */ - {12, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0xff}, }, /* addr[1] = I/O Expander 7 B */ - {12, 0x22, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 7 C */ - }, - {8, IOEXP_TYPE_LAVENDER_P65, { { 5, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xF6, 0xff}, {0xF8, 0xff}, }, }, /* addr[0] = I/O Expander CPU */ - }, -}; - - -struct inv_port_layout_s lavender_port_layout[] = { - /* Port_ID / Chan_ID / IOEXP_ID / IOEXP_VIRT_OFFSET / TRANSCEIVER_TYPE / CHIP_TYPE / LANE_ID */ - { 0, 17, 0, 0, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {188, 189, 190, 191} }, - { 1, 18, 0, 1, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {184, 185, 186, 187} }, - { 2, 19, 0, 2, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {180, 181, 182, 183} }, - { 3, 20, 0, 3, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {176, 177, 178, 179} }, - { 4, 21, 0, 4, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {172, 173, 174, 175} }, - { 5, 22, 0, 5, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {168, 169, 170, 171} }, - { 6, 23, 0, 6, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {164, 165, 166, 167} }, - { 7, 24, 0, 7, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {160, 161, 162, 163} }, - { 8, 25, 1, 0, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {156, 157, 158, 159} }, - { 9, 26, 1, 1, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {152, 153, 154, 155} }, - {10, 27, 1, 2, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {148, 149, 150, 151} }, - {11, 28, 1, 3, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {144, 145, 146, 147} }, - {12, 29, 1, 4, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {140, 141, 142, 143} }, - {13, 30, 1, 5, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {136, 137, 138, 139} }, - {14, 31, 1, 6, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {132, 133, 134, 135} }, - {15, 32, 1, 7, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {128, 129, 130, 131} }, - {16, 33, 2, 0, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, { 0, 1, 2, 3} }, - {17, 34, 2, 1, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, { 4, 5, 6, 7} }, - {18, 35, 2, 2, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, { 8, 9, 10, 11} }, - {19, 36, 2, 3, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, { 12, 13, 14, 15} }, - {20, 37, 2, 4, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, { 16, 17, 18, 19} }, - {21, 38, 2, 5, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, { 20, 21, 22, 23} }, - {22, 39, 2, 6, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, { 24, 25, 26, 27} }, - {23, 40, 2, 7, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, { 28, 29, 30, 31} }, - {24, 41, 3, 0, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, { 32, 33, 34, 35} }, - {25, 42, 3, 1, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, { 36, 37, 38, 39} }, - {26, 43, 3, 2, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, { 40, 41, 42, 43} }, - {27, 44, 3, 3, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, { 44, 45, 46, 47} }, - {28, 45, 3, 4, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, { 48, 49, 50, 51} }, - {29, 46, 3, 5, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, { 52, 53, 54, 55} }, - {30, 47, 3, 6, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, { 56, 57, 58, 59} }, - {31, 48, 3, 7, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, { 60, 61, 62, 63} }, - {32, 49, 4, 0, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {256, 257, 258, 259} }, - {33, 50, 4, 1, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {260, 261, 262, 263} }, - {34, 51, 4, 2, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {264, 265, 266, 267} }, - {35, 52, 4, 3, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {268, 269, 270, 271} }, - {36, 53, 4, 4, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {272, 273, 274, 275} }, - {37, 54, 4, 5, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {276, 277, 278, 279} }, - {38, 55, 4, 6, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {280, 281, 282, 283} }, - {39, 56, 4, 7, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {284, 285, 286, 287} }, - {40, 57, 5, 0, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {288, 289, 290, 291} }, - {41, 58, 5, 1, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {292, 293, 294, 295} }, - {42, 59, 5, 2, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {296, 297, 298, 299} }, - {43, 60, 5, 3, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {300, 301, 302, 303} }, - {44, 61, 5, 4, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {304, 305, 306, 307} }, - {45, 62, 5, 5, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {308, 309, 310, 311} }, - {46, 63, 5, 6, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {312, 313, 314, 315} }, - {47, 64, 5, 7, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {316, 317, 318, 319} }, - {48, 65, 6, 0, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {444, 445, 446, 447} }, - {49, 66, 6, 1, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {440, 441, 442, 443} }, - {50, 67, 6, 2, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {436, 437, 438, 439} }, - {51, 68, 6, 3, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {432, 433, 434, 435} }, - {52, 69, 6, 4, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {428, 429, 430, 431} }, - {53, 70, 6, 5, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {424, 425, 426, 427} }, - {54, 71, 6, 6, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {420, 421, 422, 423} }, - {55, 72, 6, 7, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {416, 417, 418, 419} }, - {56, 73, 7, 0, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {412, 413, 414, 415} }, - {57, 74, 7, 1, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {408, 409, 410, 411} }, - {58, 75, 7, 2, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {404, 405, 406, 407} }, - {59, 76, 7, 3, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {400, 401, 402, 403} }, - {60, 77, 7, 4, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {396, 397, 398, 399} }, - {61, 78, 7, 5, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {392, 393, 394, 395} }, - {62, 79, 7, 6, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {388, 389, 390, 391} }, - {63, 80, 7, 7, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {384, 385, 386, 387} }, - {64, 5, 8, 0, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, { 64, 65, 66, 67} }, -}; -#endif - -/* =========================================================== - * Cottonwood Layout configuration Rangeley (Rangeley CPU board) - * =========================================================== - */ -#ifdef SWPS_COTTONWOOD_RANGELEY -unsigned cottonwood_rangeley_gpio_rest_mux = MUX_RST_GPIO_500_PCA9548; - -struct inv_ioexp_layout_s cottonwood_rangeley_ioexp_layout[] = { - /* IOEXP_ID / IOEXP_TYPE / { Chan_ID, Chip_addr, Read_offset, Write_offset, config_offset, data_default, conf_default } */ - {0, CPLD_TYPE_COTTONWOOD,{ {1, 0x55, {22, 23, 24, 25}, {22, 23, 24, 25}, {-1, -1, -1, -1}, {0xee, 0xee, 0x99, 0x99}, {0x00, 0x00, 0x00, 0x00}, }, - }, - }, -}; - - -struct inv_port_layout_s cottonwood_rangeley_port_layout[] = { - /* Port_ID / Chan_ID / IOEXP_ID / IOEXP_VIRT_OFFSET / TRANSCEIVER_TYPE / CHIP_TYPE / LANE_ID */ - { 0, 2, 0, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 75} }, - { 1, 3, 0, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 77} }, - { 2, 4, 0, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 79} }, - { 3, 5, 0, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 81} }, -}; -#endif - -/* =========================================================== - * Maple Layout configuration (Old) - * =========================================================== - */ -#ifdef SWPS_MAPLE_GA -unsigned maple_ga_gpio_rest_mux = MUX_RST_GPIO_69_PCA9548; - -struct inv_ioexp_layout_s maple_ga_ioexp_layout[] = { - /* IOEXP_ID / IOEXP_TYPE / { Chan_ID, Chip_addr, Read_offset, Write_offset, config_offset, data_default, conf_default } */ - {0, IOEXP_TYPE_MAPLE_0ABC, { {2, 0x20, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0x00, 0x00}, }, /* addr[0] = I/O Expander 0 A */ - {2, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0xff}, }, /* addr[1] = I/O Expander 0 B */ - {2, 0x22, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 0 C */ - }, - {1, IOEXP_TYPE_MAPLE_NABC, { {3, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {3, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {3, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {2, IOEXP_TYPE_MAPLE_NABC, { {4, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {4, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {4, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {3, IOEXP_TYPE_MAPLE_NABC, { {5, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {5, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {5, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {4, IOEXP_TYPE_MAPLE_NABC, { {6, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {6, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {6, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {5, IOEXP_TYPE_MAPLE_NABC, { {7, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {7, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {7, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {6, IOEXP_TYPE_MAPLE_NABC, { {8, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {8, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {8, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, -}; - -struct inv_port_layout_s maple_ga_port_layout[] = { - /* Port_ID / Chan_ID / IOEXP_ID / IOEXP_VIRT_OFFSET / TRANSCEIVER_TYPE / CHIP_TYPE / LANE_ID */ - { 0, 18, 1, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 1} }, - { 1, 19, 1, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 2} }, - { 2, 20, 1, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 3} }, - { 3, 21, 1, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 4} }, - { 4, 22, 1, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 5} }, - { 5, 23, 1, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 6} }, - { 6, 24, 1, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 7} }, - { 7, 25, 1, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 8} }, - { 8, 26, 2, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 13} }, - { 9, 27, 2, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 14} }, - {10, 28, 2, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 15} }, - {11, 29, 2, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 16} }, - {12, 30, 2, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 21} }, - {13, 31, 2, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 22} }, - {14, 32, 2, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 23} }, - {15, 33, 2, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 24} }, - {16, 34, 3, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 29} }, - {17, 35, 3, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 30} }, - {18, 36, 3, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 31} }, - {19, 37, 3, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 32} }, - {20, 38, 3, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 33} }, - {21, 39, 3, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 34} }, - {22, 40, 3, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 35} }, - {23, 41, 3, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 36} }, - {24, 42, 4, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 41} }, - {25, 43, 4, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 42} }, - {26, 44, 4, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 43} }, - {27, 45, 4, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 44} }, - {28, 46, 4, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 49} }, - {29, 47, 4, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 50} }, - {30, 48, 4, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 51} }, - {31, 49, 4, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 52} }, - {32, 50, 5, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 57} }, - {33, 51, 5, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 58} }, - {34, 52, 5, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 59} }, - {35, 53, 5, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 60} }, - {36, 54, 5, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 61} }, - {37, 55, 5, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 62} }, - {38, 56, 5, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 63} }, - {39, 57, 5, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 64} }, - {40, 58, 6, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 65} }, - {41, 59, 6, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 66} }, - {42, 60, 6, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 67} }, - {43, 61, 6, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 68} }, - {44, 62, 6, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 69} }, - {45, 63, 6, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 70} }, - {46, 64, 6, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 71} }, - {47, 65, 6, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 72} }, - {48, 10, 0, 0, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_MAPLE, { 77, 78, 79, 80} }, - {49, 11, 0, 1, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_MAPLE, { 85, 86, 87, 88} }, - {50, 12, 0, 2, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_MAPLE, { 93, 94, 95, 96} }, - {51, 13, 0, 3, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_MAPLE, { 97, 98, 99,100} }, - {52, 14, 0, 4, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_MAPLE, {105,106,107,108} }, - {53, 15, 0, 5, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_MAPLE, {113,114,115,116} }, - {54, 16, 0, 6, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_MAPLE, {121,122,123,124} }, - {55, 17, 0, 7, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_MAPLE, {125,126,127,128} }, -}; -#endif - -/* =========================================================== - * Maple Layout configuration (B version) - * =========================================================== - */ -#ifdef SWPS_MAPLE_B -unsigned maple_b_gpio_rest_mux = MUX_RST_GPIO_69_PCA9548; - -struct inv_ioexp_layout_s maple_b_ioexp_layout[] = { - /* IOEXP_ID / IOEXP_TYPE / { Chan_ID, Chip_addr, Read_offset, Write_offset, config_offset, data_default, conf_default } */ - {0, IOEXP_TYPE_MAPLE_0ABC, { { 6, 0x20, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0x00, 0x00}, }, /* addr[0] = I/O Expander 0 A */ - { 6, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0xff}, }, /* addr[1] = I/O Expander 0 B */ - { 6, 0x22, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 0 C */ - }, - {1, IOEXP_TYPE_MAPLE_NABC, { { 7, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - { 7, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - { 7, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {2, IOEXP_TYPE_MAPLE_NABC, { { 8, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - { 8, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - { 8, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {3, IOEXP_TYPE_MAPLE_NABC, { { 9, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - { 9, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - { 9, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {4, IOEXP_TYPE_MAPLE_NABC, { {10, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {10, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {10, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {5, IOEXP_TYPE_MAPLE_NABC, { {11, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {11, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {11, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {6, IOEXP_TYPE_MAPLE_NABC, { {12, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {12, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {12, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, -}; - -struct inv_port_layout_s maple_b_port_layout[] = { - /* Port_ID / Chan_ID / IOEXP_ID / IOEXP_VIRT_OFFSET / TRANSCEIVER_TYPE / CHIP_TYPE / LANE_ID */ - { 1, 23, 1, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 2} }, - { 2, 22, 1, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 1} }, - { 3, 25, 1, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 4} }, - { 4, 24, 1, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 3} }, - { 5, 27, 1, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 6} }, - { 6, 26, 1, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 5} }, - { 7, 29, 1, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 8} }, - { 8, 28, 1, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 7} }, - { 9, 31, 2, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 14} }, - {10, 30, 2, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 13} }, - {11, 33, 2, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 16} }, - {12, 32, 2, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 15} }, - {13, 35, 2, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 22} }, - {14, 34, 2, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 21} }, - {15, 37, 2, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 24} }, - {16, 36, 2, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 23} }, - {17, 39, 3, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 30} }, - {18, 38, 3, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 29} }, - {19, 41, 3, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 32} }, - {20, 40, 3, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 31} }, - {21, 43, 3, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 34} }, - {22, 42, 3, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 33} }, - {23, 45, 3, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 36} }, - {24, 44, 3, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 35} }, - {25, 47, 4, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 42} }, - {26, 46, 4, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 41} }, - {27, 49, 4, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 44} }, - {28, 48, 4, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 43} }, - {29, 51, 4, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 50} }, - {30, 50, 4, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 49} }, - {31, 53, 4, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 52} }, - {32, 52, 4, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 51} }, - {33, 55, 5, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 58} }, - {34, 54, 5, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 57} }, - {35, 57, 5, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 60} }, - {36, 56, 5, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 59} }, - {37, 59, 5, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 62} }, - {38, 58, 5, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 61} }, - {39, 61, 5, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 64} }, - {40, 60, 5, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 63} }, - {41, 63, 6, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 66} }, - {42, 62, 6, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 65} }, - {43, 65, 6, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 68} }, - {44, 64, 6, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 67} }, - {45, 67, 6, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 70} }, - {46, 66, 6, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 69} }, - {47, 69, 6, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 72} }, - {48, 68, 6, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 71} }, - {49, 15, 0, 1, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_MAPLE, { 77, 78, 79, 80} }, - {50, 14, 0, 0, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_MAPLE, { 85, 86, 87, 88} }, - {51, 17, 0, 3, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_MAPLE, { 97, 98, 99,100} }, - {52, 16, 0, 2, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_MAPLE, { 93, 94, 95, 96} }, - {53, 19, 0, 5, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_MAPLE, {105,106,107,108} }, - {54, 18, 0, 4, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_MAPLE, {113,114,115,116} }, - {55, 21, 0, 7, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_MAPLE, {125,126,127,128} }, - {56, 20, 0, 6, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_MAPLE, {121,122,123,124} }, -}; -#endif - -/* =========================================================== - * Maple Layout configuration (J version) - * =========================================================== - */ -#ifdef SWPS_MAPLE_J -unsigned maple_j_gpio_rest_mux = MUX_RST_GPIO_69_PCA9548; - -struct inv_ioexp_layout_s maple_j_ioexp_layout[] = { - /* IOEXP_ID / IOEXP_TYPE / { Chan_ID, Chip_addr, Read_offset, Write_offset, config_offset, data_default, conf_default } */ - {0, IOEXP_TYPE_MAPLE_0ABC, { { 6, 0x20, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0x00, 0x00}, }, /* addr[0] = I/O Expander 0 A */ - { 6, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0xff}, }, /* addr[1] = I/O Expander 0 B */ - { 6, 0x22, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 0 C */ - }, - {1, IOEXP_TYPE_MAPLE_NABC, { { 7, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - { 7, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - { 7, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {2, IOEXP_TYPE_MAPLE_NABC, { { 8, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - { 8, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - { 8, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {3, IOEXP_TYPE_MAPLE_NABC, { { 9, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - { 9, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - { 9, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {4, IOEXP_TYPE_MAPLE_NABC, { {10, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {10, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {10, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {5, IOEXP_TYPE_MAPLE_NABC, { {11, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {11, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {11, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {6, IOEXP_TYPE_MAPLE_NABC, { {12, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {12, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {12, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, -}; - -struct inv_port_layout_s maple_j_port_layout[] = { - /* Port_ID / Chan_ID / IOEXP_ID / IOEXP_VIRT_OFFSET / TRANSCEIVER_TYPE / CHIP_TYPE / LANE_ID */ - { 0, 22, 1, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 1} }, - { 1, 23, 1, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 2} }, - { 2, 24, 1, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 3} }, - { 3, 25, 1, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 4} }, - { 4, 26, 1, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 5} }, - { 5, 27, 1, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 6} }, - { 6, 28, 1, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 7} }, - { 7, 29, 1, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 8} }, - { 8, 30, 2, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 13} }, - { 9, 31, 2, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 14} }, - {10, 32, 2, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 15} }, - {11, 33, 2, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 16} }, - {12, 34, 2, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 21} }, - {13, 35, 2, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 22} }, - {14, 36, 2, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 23} }, - {15, 37, 2, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 24} }, - {16, 38, 3, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 29} }, - {17, 39, 3, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 30} }, - {18, 40, 3, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 31} }, - {19, 41, 3, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 32} }, - {20, 42, 3, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 33} }, - {21, 43, 3, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 34} }, - {22, 44, 3, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 35} }, - {23, 45, 3, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 36} }, - {24, 46, 4, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 41} }, - {25, 47, 4, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 42} }, - {26, 48, 4, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 43} }, - {27, 49, 4, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 44} }, - {28, 50, 4, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 49} }, - {29, 51, 4, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 50} }, - {30, 52, 4, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 51} }, - {31, 53, 4, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 52} }, - {32, 54, 5, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 57} }, - {33, 55, 5, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 58} }, - {34, 56, 5, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 59} }, - {35, 57, 5, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 60} }, - {36, 58, 5, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 61} }, - {37, 59, 5, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 62} }, - {38, 60, 5, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 63} }, - {39, 61, 5, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 64} }, - {40, 62, 6, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 65} }, - {41, 63, 6, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 66} }, - {42, 64, 6, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 67} }, - {43, 65, 6, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 68} }, - {44, 66, 6, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 69} }, - {45, 67, 6, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 70} }, - {46, 68, 6, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 71} }, - {47, 69, 6, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 72} }, - {48, 14, 0, 0, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_MAPLE, { 85, 86, 87, 88} }, - {49, 15, 0, 1, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_MAPLE, { 77, 78, 79, 80} }, - {50, 16, 0, 2, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_MAPLE, { 93, 94, 95, 96} }, - {51, 17, 0, 3, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_MAPLE, { 97, 98, 99,100} }, - {52, 18, 0, 4, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_MAPLE, {113,114,115,116} }, - {53, 19, 0, 5, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_MAPLE, {105,106,107,108} }, - {54, 20, 0, 6, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_MAPLE, {121,122,123,124} }, - {55, 21, 0, 7, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_MAPLE, {125,126,127,128} }, -}; -#endif - -/* ========================================== - * Gulmohar Layout configuration - * ========================================== - */ -#ifdef SWPS_GULMOHAR -unsigned gulmohar_gpio_rest_mux = MUX_RST_GPIO_505_PCA9548; - -struct inv_ioexp_layout_s gulmohar_ioexp_layout[] = { - /* IOEXP_ID / IOEXP_TYPE / { Chan_ID, Chip_addr, Read_offset, Write_offset, config_offset, data_default, conf_default } */ - {0, IOEXP_TYPE_GULMOHAR_NABC, { {2, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xf3, 0xf3}, {0xf3, 0xf3}, }, /* addr[0] = I/O Expander N A */ - {2, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xf3, 0xf3}, {0xf3, 0xf3}, }, /* addr[1] = I/O Expander N B */ - {2, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {1, IOEXP_TYPE_GULMOHAR_NABC, { {3, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xf3, 0xf3}, {0xf3, 0xf3}, }, /* addr[0] = I/O Expander N A */ - {3, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xf3, 0xf3}, {0xf3, 0xf3}, }, /* addr[1] = I/O Expander N B */ - {3, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {2, IOEXP_TYPE_GULMOHAR_NABC, { {4, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xf3, 0xf3}, {0xf3, 0xf3}, }, /* addr[0] = I/O Expander N A */ - {4, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xf3, 0xf3}, {0xf3, 0xf3}, }, /* addr[1] = I/O Expander N B */ - {4, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {3, IOEXP_TYPE_GULMOHAR_NABC, { {5, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xf3, 0xf3}, {0xf3, 0xf3}, }, /* addr[0] = I/O Expander N A */ - {5, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xf3, 0xf3}, {0xf3, 0xf3}, }, /* addr[1] = I/O Expander N B */ - {5, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {4, IOEXP_TYPE_GULMOHAR_NABC, { {6, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xf3, 0xf3}, {0xf3, 0xf3}, }, /* addr[0] = I/O Expander N A */ - {6, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xf3, 0xf3}, {0xf3, 0xf3}, }, /* addr[1] = I/O Expander N B */ - {6, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {5, IOEXP_TYPE_GULMOHAR_NABC, { {7, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xf3, 0xf3}, {0xf3, 0xf3}, }, /* addr[0] = I/O Expander N A */ - {7, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xf3, 0xf3}, {0xf3, 0xf3}, }, /* addr[1] = I/O Expander N B */ - {7, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {6, IOEXP_TYPE_GULMOHAR_7ABC, { {8, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xc0, 0xff}, {0xc0, 0xc0}, }, /* addr[0] = I/O Expander 7 A */ - {8, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xc0, 0xff}, }, /* addr[1] = I/O Expander 7 B */ - {8, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xc0, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 7 C */ - }, -}; - - - -struct inv_port_layout_s gulmohar_port_layout[] = { - /* Port_ID / Chan_ID / IOEXP_ID / IOEXP_VIRT_OFFSET / TRANSCEIVER_TYPE / CHIP_TYPE / LANE_ID */ - { 0, 10, 0, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, { 1} }, - { 1, 11, 0, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, { 2} }, - { 2, 12, 0, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, { 3} }, - { 3, 13, 0, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, { 4} }, - { 4, 14, 0, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, { 5} }, - { 5, 15, 0, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, { 6} }, - { 6, 16, 0, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, { 7} }, - { 7, 17, 0, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, { 8} }, - { 8, 18, 1, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, { 9} }, - { 9, 19, 1, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, { 10} }, - {10, 20, 1, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, { 11} }, - {11, 21, 1, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, { 12} }, - {12, 22, 1, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, { 21} }, - {13, 23, 1, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, { 22} }, - {14, 24, 1, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, { 23} }, - {15, 25, 1, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, { 24} }, - {16, 26, 2, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, { 33} }, - {17, 27, 2, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, { 34} }, - {18, 28, 2, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, { 35} }, - {19, 29, 2, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, { 36} }, - {20, 30, 2, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, { 37} }, - {21, 31, 2, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, { 38} }, - {22, 32, 2, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, { 39} }, - {23, 33, 2, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, { 40} }, - {24, 34, 3, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, { 41} }, - {25, 35, 3, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, { 42} }, - {26, 36, 3, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, { 43} }, - {27, 37, 3, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, { 44} }, - {28, 38, 3, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, { 49} }, - {29, 39, 3, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, { 50} }, - {30, 40, 3, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, { 51} }, - {31, 41, 3, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, { 52} }, - {32, 42, 4, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, { 53} }, - {33, 43, 4, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, { 54} }, - {34, 44, 4, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, { 55} }, - {35, 45, 4, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, { 56} }, - {36, 46, 4, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, { 65} }, - {37, 47, 4, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, { 66} }, - {38, 48, 4, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, { 67} }, - {39, 49, 4, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, { 68} }, - {40, 50, 5, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, { 69} }, - {41, 51, 5, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, { 70} }, - {42, 52, 5, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, { 71} }, - {43, 53, 5, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, { 72} }, - {44, 54, 5, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, { 81} }, - {45, 55, 5, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, { 82} }, - {46, 56, 5, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, { 83} }, - {47, 57, 5, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, { 84} }, - {48, 58, 6, 0, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, { 97, 98, 99,100} }, - {49, 59, 6, 1, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, { 85, 86, 87, 88} }, - {50, 60, 6, 2, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {101,102,103,104} }, - {51, 61, 6, 3, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {105,106,107,108} }, - {52, 62, 6, 4, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {109,110,111,112} }, - {53, 63, 6, 5, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {109,110,111,112} }, -}; -#endif - - -/* ========================================== - * Gulmohar_2T EVT1 Layout configuration - * ========================================== - */ -#ifdef SWPS_GULMOHAR_2T_EVT1 -unsigned gulmohar_2t_evt1_gpio_rest_mux = MUX_RST_GPIO_505_PCA9548; - -struct inv_ioexp_layout_s gulmohar_2t_evt1_ioexp_layout[] = { - /* IOEXP_ID / IOEXP_TYPE / { Chan_ID, Chip_addr, Read_offset, Write_offset, config_offset, data_default, conf_default } */ - {0, IOEXP_TYPE_GULMOHAR_2T_EVT1_NABC,{ {2, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xdd, 0xdd}, {0xdd, 0xdd}, }, /* addr[0] = I/O Expander N A */ - {2, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xdd, 0xdd}, {0xdd, 0xdd}, }, /* addr[1] = I/O Expander N B */ - {2, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {1, IOEXP_TYPE_GULMOHAR_2T_EVT1_1ABC,{ {3, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xdd, 0xdd}, {0xdd, 0xdd}, }, /* addr[0] = I/O Expander N A */ - {3, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xf3, 0xf3}, {0xf3, 0xf3}, }, /* addr[1] = I/O Expander N B */ - {3, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {2, IOEXP_TYPE_GULMOHAR_2T_EVT1_NABC,{ {4, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xdd, 0xdd}, {0xdd, 0xdd}, }, /* addr[0] = I/O Expander N A */ - {4, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xdd, 0xdd}, {0xdd, 0xdd}, }, /* addr[1] = I/O Expander N B */ - {4, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {3, IOEXP_TYPE_GULMOHAR_2T_EVT1_3ABC,{ {5, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xf3, 0xf3}, {0xf3, 0xf3}, }, /* addr[0] = I/O Expander N A */ - {5, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xdd, 0xdd}, {0xdd, 0xdd}, }, /* addr[1] = I/O Expander N B */ - {5, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {4, IOEXP_TYPE_GULMOHAR_2T_EVT1_NABC,{ {6, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xdd, 0xdd}, {0xdd, 0xdd}, }, /* addr[0] = I/O Expander N A */ - {6, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xdd, 0xdd}, {0xdd, 0xdd}, }, /* addr[1] = I/O Expander N B */ - {6, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {5, IOEXP_TYPE_GULMOHAR_2T_EVT1_NABC,{ {7, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xdd, 0xdd}, {0xdd, 0xdd}, }, /* addr[0] = I/O Expander N A */ - {7, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xdd, 0xdd}, {0xdd, 0xdd}, }, /* addr[1] = I/O Expander N B */ - {7, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {6, IOEXP_TYPE_GULMOHAR_2T_EVT1_7ABC,{ {8, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xd6, 0xda}, {0x18, 0xe3}, }, /* addr[0] = I/O Expander 7 A */ - {8, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xd6, 0xda}, {0x18, 0xe3}, }, /* addr[1] = I/O Expander 7 B */ - {8, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xd6, 0xff}, {0x18, 0xff}, }, }, /* addr[2] = I/O Expander 7 C */ - }, -}; - - - -struct inv_port_layout_s gulmohar_2t_evt1_port_layout[] = { - /* Port_ID / Chan_ID / IOEXP_ID / IOEXP_VIRT_OFFSET / TRANSCEIVER_TYPE / CHIP_TYPE / LANE_ID */ - { 0, 10, 0, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, {-99} }, - { 1, 11, 0, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, {-99} }, - { 2, 12, 0, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, {-99} }, - { 3, 13, 0, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, {-99} }, - { 4, 14, 0, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, {-99} }, - { 5, 15, 0, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, {-99} }, - { 6, 16, 0, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, {-99} }, - { 7, 17, 0, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, {-99} }, - { 8, 18, 1, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, {-99} }, - { 9, 19, 1, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, {-99} }, - {10, 20, 1, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, {-99} }, - {11, 21, 1, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, {-99} }, - {12, 22, 1, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, {-99} }, - {13, 23, 1, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, {-99} }, - {14, 24, 1, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, {-99} }, - {15, 25, 1, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, {-99} }, - {16, 26, 2, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, {-99} }, - {17, 27, 2, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, {-99} }, - {18, 28, 2, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, {-99} }, - {19, 29, 2, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, {-99} }, - {20, 30, 2, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, {-99} }, - {21, 31, 2, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, {-99} }, - {22, 32, 2, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, {-99} }, - {23, 33, 2, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, {-99} }, - {24, 34, 3, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, {-99} }, - {25, 35, 3, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, {-99} }, - {26, 36, 3, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, {-99} }, - {27, 37, 3, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, {-99} }, - {28, 38, 3, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, {-99} }, - {29, 39, 3, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, {-99} }, - {30, 40, 3, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, {-99} }, - {31, 41, 3, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, {-99} }, - {32, 42, 4, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, {-99} }, - {33, 43, 4, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, {-99} }, - {34, 44, 4, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, {-99} }, - {35, 45, 4, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, {-99} }, - {36, 46, 4, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, {-99} }, - {37, 47, 4, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, {-99} }, - {38, 48, 4, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, {-99} }, - {39, 49, 4, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, {-99} }, - {40, 50, 5, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, {-99} }, - {41, 51, 5, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, {-99} }, - {42, 52, 5, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, {-99} }, - {43, 53, 5, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, {-99} }, - {44, 54, 5, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, {-99} }, - {45, 55, 5, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, {-99} }, - {46, 56, 5, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, {-99} }, - {47, 57, 5, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, {-99} }, - {48, 59, 6, 1, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {-99,-99,-99,-99} }, - {49, 58, 6, 0, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {-99,-99,-99,-99} }, - {50, 61, 6, 3, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {-99,-99,-99,-99} }, - {51, 60, 6, 2, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {-99,-99,-99,-99} }, - {52, 63, 6, 5, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {-99,-99,-99,-99} }, - {53, 62, 6, 4, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {-99,-99,-99,-99} }, - {54, 65, 6, 7, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {-99,-99,-99,-99} }, - {55, 64, 6, 6, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {-99,-99,-99,-99} }, -}; -#endif - - -/* =========================================================== - * Peony-SFP Layout configuration - * =========================================================== - */ -#ifdef SWPS_PEONY_SFP -unsigned peony_sfp_gpio_rest_mux = MUX_RST_CPLD_C0_A77_70_74_RST_ALL; - -struct inv_ioexp_layout_s peony_sfp_ioexp_layout[] = { - /* IOEXP_ID / IOEXP_TYPE / { Chan_ID, Chip_addr, Read_offset, Write_offset, config_offset, data_default, conf_default } */ - {0, IOEXP_TYPE_QSFP_6P_LAYOUT_1, { {4, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xc0, 0xff}, {0xc0, 0xc0}, }, /* addr[0] = I/O Expander 0 A */ - {4, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xc0, 0xff}, }, /* addr[1] = I/O Expander 0 B */ - {4, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xc0, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 0 C */ - }, - {1, IOEXP_TYPE_SFP_8P_LAYOUT_1, { {5, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {5, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {5, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {2, IOEXP_TYPE_SFP_8P_LAYOUT_1, { {6, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {6, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {6, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {3, IOEXP_TYPE_SFP_8P_LAYOUT_1, { {7, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {7, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {7, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {4, IOEXP_TYPE_SFP_8P_LAYOUT_1, { {8, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {8, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {8, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {5, IOEXP_TYPE_SFP_8P_LAYOUT_1, { {9, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {9, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {9, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {6, IOEXP_TYPE_SFP_8P_LAYOUT_1, { {10, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {10, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {10, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, -}; - -struct inv_port_layout_s peony_sfp_port_layout[] = { - /* Port_ID / Chan_ID / IOEXP_ID / IOEXP_VIRT_OFFSET / TRANSCEIVER_TYPE / CHIP_TYPE / LANE_ID */ - { 0, 20, 1, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 1} }, - { 1, 21, 1, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 2} }, - { 2, 22, 1, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 3} }, - { 3, 23, 1, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 4} }, - { 4, 24, 1, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 5} }, - { 5, 25, 1, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 6} }, - { 6, 26, 1, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 7} }, - { 7, 27, 1, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 8} }, - { 8, 28, 2, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 13} }, - { 9, 29, 2, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 14} }, - {10, 30, 2, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 15} }, - {11, 31, 2, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 16} }, - {12, 32, 2, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 21} }, - {13, 33, 2, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 22} }, - {14, 34, 2, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 23} }, - {15, 35, 2, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 24} }, - {16, 36, 3, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 29} }, - {17, 37, 3, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 30} }, - {18, 38, 3, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 31} }, - {19, 39, 3, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 32} }, - {20, 40, 3, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 33} }, - {21, 41, 3, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 34} }, - {22, 42, 3, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 35} }, - {23, 43, 3, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 36} }, - {24, 44, 4, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 65} }, - {25, 45, 4, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 66} }, - {26, 46, 4, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 67} }, - {27, 47, 4, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 68} }, - {28, 48, 4, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 69} }, - {29, 49, 4, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 70} }, - {30, 50, 4, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 71} }, - {31, 51, 4, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 72} }, - {32, 52, 5, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 97} }, - {33, 53, 5, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 98} }, - {34, 54, 5, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 99} }, - {35, 55, 5, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, {100} }, - {36, 56, 5, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, {105} }, - {37, 57, 5, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, {106} }, - {38, 58, 5, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, {107} }, - {39, 59, 5, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, {108} }, - {40, 60, 6, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, {113} }, - {41, 61, 6, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, {114} }, - {42, 62, 6, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, {115} }, - {43, 63, 6, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, {116} }, - {44, 64, 6, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, {121} }, - {45, 65, 6, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, {122} }, - {46, 66, 6, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, {123} }, - {47, 67, 6, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, {124} }, - {48, 12, 0, 0, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_MAPLE, { 49, 50, 51, 52} }, - {49, 13, 0, 1, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_MAPLE, { 57, 58, 59, 60} }, - {50, 14, 0, 2, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_MAPLE, { 61, 62, 63, 64} }, - {51, 15, 0, 3, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_MAPLE, { 77, 78, 79, 80} }, - {52, 16, 0, 4, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_MAPLE, { 85, 86, 87, 88} }, - {53, 17, 0, 5, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_MAPLE, { 93, 94, 95, 96} }, -}; -#endif - - -/* =========================================================== - * Peony-Copper Layout configuration - * =========================================================== - */ -#ifdef SWPS_PEONY_COPPER -unsigned peony_copper_gpio_rest_mux = MUX_RST_CPLD_C0_A77_70_74_RST_ALL; - -struct inv_ioexp_layout_s peony_copper_ioexp_layout[] = { - /* IOEXP_ID / IOEXP_TYPE / { Chan_ID, Chip_addr, Read_offset, Write_offset, config_offset, data_default, conf_default } */ - {0, IOEXP_TYPE_QSFP_6P_LAYOUT_1, { {10, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xc0, 0xff}, {0xc0, 0xc0}, }, /* addr[0] = I/O Expander 0 A */ - {10, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xc0, 0xff}, }, /* addr[1] = I/O Expander 0 B */ - {10, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xc0, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 0 C */ - }, -}; - -struct inv_port_layout_s peony_copper_port_layout[] = { - /* Port_ID / Chan_ID / IOEXP_ID / IOEXP_VIRT_OFFSET / TRANSCEIVER_TYPE / CHIP_TYPE / LANE_ID */ - {48, 4, 0, 0, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_MAPLE, { 49, 50, 51, 52} }, - {49, 5, 0, 1, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_MAPLE, { 57, 58, 59, 60} }, - {50, 6, 0, 2, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_MAPLE, { 61, 62, 63, 64} }, - {51, 7, 0, 3, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_MAPLE, { 77, 78, 79, 80} }, - {52, 8, 0, 4, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_MAPLE, { 85, 86, 87, 88} }, - {53, 9, 0, 5, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_MAPLE, { 93, 94, 95, 96} }, -}; -#endif - - -/* =========================================================== - * Cedar Layout configuration - * =========================================================== - */ -#ifdef SWPS_CEDAR_GA -unsigned cedar_ga_gpio_rest_mux = MUX_RST_GPIO_69_PCA9548; - -struct inv_ioexp_layout_s cedar_ga_ioexp_layout[] = { - /* IOEXP_ID / IOEXP_TYPE / { Chan_ID, Chip_addr, Read_offset, Write_offset, config_offset, data_default, conf_default } */ - {0, IOEXP_TYPE_CEDAR_0ABC, { { 4, 0x20, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0x00, 0x00}, }, /* addr[0] = I/O Expander 0 A */ - { 4, 0x21, {0,-1}, {1,-1}, {3,-1}, {0xff }, {0x00 }, }, /* addr[1] = I/O Expander 0 B */ - { 4, 0x22, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 0 C */ - }, - {1, IOEXP_TYPE_CEDAR_0ABC, { { 5, 0x20, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0x00, 0x00}, }, /* addr[0] = I/O Expander 0 A */ - { 5, 0x21, {0,-1}, {1,-1}, {3,-1}, {0xff }, {0x00 }, }, /* addr[1] = I/O Expander 0 B */ - { 5, 0x22, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 0 C */ - }, - {2, IOEXP_TYPE_CEDAR_0ABC, { { 6, 0x20, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0x00, 0x00}, }, /* addr[0] = I/O Expander 0 A */ - { 6, 0x21, {0,-1}, {1,-1}, {3,-1}, {0xff }, {0x00 }, }, /* addr[1] = I/O Expander 0 B */ - { 6, 0x22, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 0 C */ - }, - {3, IOEXP_TYPE_CEDAR_0ABC, { { 7, 0x20, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0x00, 0x00}, }, /* addr[0] = I/O Expander 0 A */ - { 7, 0x21, {0,-1}, {1,-1}, {3,-1}, {0xff }, {0x00 }, }, /* addr[1] = I/O Expander 0 B */ - { 7, 0x22, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 0 C */ - }, -}; - -struct inv_port_layout_s cedar_ga_port_layout[] = { - /* Port_ID / Chan_ID / IOEXP_ID / IOEXP_VIRT_OFFSET / TRANSCEIVER_TYPE / CHIP_TYPE / LANE_ID */ - { 0, 12, 0, 0, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_MAPLE, { 21, 22, 23, 24} }, - { 1, 13, 0, 1, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_MAPLE, { 17, 18, 19, 20} }, - { 2, 14, 0, 2, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_MAPLE, { 25, 26, 27, 28} }, - { 3, 15, 0, 3, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_MAPLE, { 29, 30, 31, 32} }, - { 4, 16, 0, 4, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_MAPLE, { 37, 38, 39, 40} }, - { 5, 17, 0, 5, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_MAPLE, { 33, 34, 35, 36} }, - { 6, 18, 0, 6, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_MAPLE, { 41, 42, 43, 44} }, - { 7, 19, 0, 7, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_MAPLE, { 45, 46, 47, 48} }, - { 8, 20, 1, 0, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_MAPLE, { 5, 6, 7, 8} }, - { 9, 21, 1, 1, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_MAPLE, { 1, 2, 3, 4} }, - {10, 22, 1, 2, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_MAPLE, { 9, 10, 11, 12} }, - {11, 23, 1, 3, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_MAPLE, { 13, 14, 15, 16} }, - {12, 24, 1, 4, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_MAPLE, { 53, 54, 55, 56} }, - {13, 25, 1, 5, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_MAPLE, { 49, 50, 51, 52} }, - {14, 26, 1, 6, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_MAPLE, { 57, 58, 59, 60} }, - {15, 27, 1, 7, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_MAPLE, { 61, 62, 63, 64} }, - {16, 28, 2, 0, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_MAPLE, { 71, 72, 73, 74} }, - {17, 29, 2, 1, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_MAPLE, { 67, 68, 69, 70} }, - {18, 30, 2, 2, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_MAPLE, { 75, 76, 77, 78} }, - {19, 31, 2, 3, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_MAPLE, { 79, 80, 81, 82} }, - {20, 32, 2, 4, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_MAPLE, { 119, 120, 121, 122} }, - {21, 33, 2, 5, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_MAPLE, { 115, 116, 117, 118} }, - {22, 34, 2, 6, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_MAPLE, { 123, 124, 125, 126} }, - {23, 35, 2, 7, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_MAPLE, { 127, 128, 129, 130} }, - {24, 36, 3, 0, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_MAPLE, { 87, 88, 89, 90} }, - {25, 37, 3, 1, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_MAPLE, { 83, 84, 85, 86} }, - {26, 38, 3, 2, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_MAPLE, { 91, 92, 93, 94} }, - {27, 39, 3, 3, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_MAPLE, { 95, 96, 97, 98} }, - {28, 40, 3, 4, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_MAPLE, { 103, 104, 105, 106} }, - {29, 41, 3, 5, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_MAPLE, { 99, 100, 101, 102} }, - {30, 42, 3, 6, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_MAPLE, { 107, 108, 109, 110} }, - {31, 43, 3, 7, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_MAPLE, { 111, 112, 113, 114} }, -}; -#endif - - -#endif /* INV_SWPS_H */ - - - - - - - - - diff --git a/packages/platforms/inventec/x86-64/d5264q28b/modules/builds/src/io_expander.c b/packages/platforms/inventec/x86-64/d5264q28b/modules/builds/src/io_expander.c deleted file mode 100644 index 6867bbc60..000000000 --- a/packages/platforms/inventec/x86-64/d5264q28b/modules/builds/src/io_expander.c +++ /dev/null @@ -1,2579 +0,0 @@ -#include -#include -#include "io_expander.h" - -/* For build single module using (Ex: ONL platform) */ -#include -//#include - - -static struct ioexp_obj_s *ioexp_head_p = NULL; -static struct ioexp_obj_s *ioexp_tail_p = NULL; -extern int io_no_init; - -/* ========== Register IOEXP layout ========== - */ -struct ioexp_map_s ioexp_map_magnolia_nab = { - - .chip_amount = 2, - .data_width = 2, - - .map_present = { {0, 0, 4}, /* map_present[0] = MOD_ABS_PORT(X) */ - {0, 0, 5}, /* map_present[1] = MOD_ABS_PORT(X+1) */ - {0, 0, 6}, /* map_present[2] = MOD_ABS_PORT(X+2) */ - {0, 0, 7}, /* map_present[3] = MOD_ABS_PORT(X+3) */ - {1, 0, 4}, /* map_present[4] = MOD_ABS_PORT(X+4) */ - {1, 0, 5}, /* map_present[5] = MOD_ABS_PORT(X+5) */ - {1, 0, 6}, /* map_present[6] = MOD_ABS_PORT(X+6) */ - {1, 0, 7}, /* map_present[7] = MOD_ABS_PORT(X+7) */ - }, - .map_tx_disable = { {0, 1, 0}, /* map_tx_disable[0] = TXDISABLE_SFP+_P(X) */ - {0, 1, 1}, /* map_tx_disable[1] = TXDISABLE_SFP+_P(X+1) */ - {0, 1, 2}, /* map_tx_disable[2] = TXDISABLE_SFP+_P(X+2) */ - {0, 1, 3}, /* map_tx_disable[3] = TXDISABLE_SFP+_P(X+3) */ - {1, 1, 0}, /* map_tx_disable[4] = TXDISABLE_SFP+_P(X+4) */ - {1, 1, 1}, /* map_tx_disable[5] = TXDISABLE_SFP+_P(X+5) */ - {1, 1, 2}, /* map_tx_disable[6] = TXDISABLE_SFP+_P(X+6) */ - {1, 1, 3}, /* map_tx_disable[7] = TXDISABLE_SFP+_P(X+7) */ - }, - .map_tx_fault = { {0, 0, 0}, /* map_tx_fault[0] = TXFAULT_SFP+_P(X) */ - {0, 0, 1}, /* map_tx_fault[1] = TXFAULT_SFP+_P(X+1) */ - {0, 0, 2}, /* map_tx_fault[2] = TXFAULT_SFP+_P(X+2) */ - {0, 0, 3}, /* map_tx_fault[3] = TXFAULT_SFP+_P(X+3) */ - {1, 0, 0}, /* map_tx_fault[4] = TXFAULT_SFP+_P(X+4) */ - {1, 0, 1}, /* map_tx_fault[5] = TXFAULT_SFP+_P(X+5) */ - {1, 0, 2}, /* map_tx_fault[6] = TXFAULT_SFP+_P(X+6) */ - {1, 0, 3}, /* map_tx_fault[7] = TXFAULT_SFP+_P(X+7) */ - }, - .map_rxlos = { {0, 1, 4}, /* map_rxlos[0] = OPRXLOS_PORT(X) */ - {0, 1, 5}, /* map_rxlos[1] = OPRXLOS_PORT(X+1) */ - {0, 1, 6}, /* map_rxlos[2] = OPRXLOS_PORT(X+2) */ - {0, 1, 7}, /* map_rxlos[3] = OPRXLOS_PORT(X+3) */ - {1, 1, 4}, /* map_rxlos[4] = OPRXLOS_PORT(X+4) */ - {1, 1, 5}, /* map_rxlos[5] = OPRXLOS_PORT(X+5) */ - {1, 1, 6}, /* map_rxlos[6] = OPRXLOS_PORT(X+6) */ - {1, 1, 7}, /* map_rxlos[7] = OPRXLOS_PORT(X+7) */ - }, -}; - - -struct ioexp_map_s ioexp_map_magnolia_4ab = { - - .chip_amount = 2, - .data_width = 2, - - .map_present = { {0, 0, 4}, /* map_present[0] = MOD_ABS_PORT(X) */ - {0, 0, 5}, /* map_present[1] = MOD_ABS_PORT(X+1) */ - {0, 0, 6}, /* map_present[2] = MOD_ABS_PORT(X+2) */ - {0, 0, 7}, /* map_present[3] = MOD_ABS_PORT(X+3) */ - {1, 0, 4}, /* map_present[4] = MOD_ABS_PORT(X+4) */ - {1, 0, 5}, /* map_present[5] = MOD_ABS_PORT(X+5) */ - {1, 0, 6}, /* map_present[6] = MOD_ABS_PORT(X+6) */ - {1, 0, 7}, /* map_present[7] = MOD_ABS_PORT(X+7) */ - }, - .map_tx_disable = { {0, 1, 0}, /* map_tx_disable[0] = TXDISABLE_SFP+_P(X) */ - {0, 1, 1}, /* map_tx_disable[1] = TXDISABLE_SFP+_P(X+1) */ - {0, 1, 2}, /* map_tx_disable[2] = TXDISABLE_SFP+_P(X+2) */ - {0, 1, 3}, /* map_tx_disable[3] = TXDISABLE_SFP+_P(X+3) */ - {1, 0, 0}, /* map_tx_disable[4] = TXDISABLE_SFP+_P(X+4) */ - {1, 0, 1}, /* map_tx_disable[5] = TXDISABLE_SFP+_P(X+5) */ - {1, 0, 2}, /* map_tx_disable[6] = TXDISABLE_SFP+_P(X+6) */ - {1, 0, 3}, /* map_tx_disable[7] = TXDISABLE_SFP+_P(X+7) */ - }, - .map_tx_fault = { {0, 0, 0}, /* map_tx_fault[0] = TXFAULT_SFP+_P(X) */ - {0, 0, 1}, /* map_tx_fault[1] = TXFAULT_SFP+_P(X+1) */ - {0, 0, 2}, /* map_tx_fault[2] = TXFAULT_SFP+_P(X+2) */ - {0, 0, 3}, /* map_tx_fault[3] = TXFAULT_SFP+_P(X+3) */ - {1, 1, 0}, /* map_tx_fault[4] = TXFAULT_SFP+_P(X+4) */ - {1, 1, 1}, /* map_tx_fault[5] = TXFAULT_SFP+_P(X+5) */ - {1, 1, 2}, /* map_tx_fault[6] = TXFAULT_SFP+_P(X+6) */ - {1, 1, 3}, /* map_tx_fault[7] = TXFAULT_SFP+_P(X+7) */ - }, - .map_rxlos = { {0, 1, 4}, /* map_rxlos[0] = OPRXLOS_PORT(X) */ - {0, 1, 5}, /* map_rxlos[1] = OPRXLOS_PORT(X+1) */ - {0, 1, 6}, /* map_rxlos[2] = OPRXLOS_PORT(X+2) */ - {0, 1, 7}, /* map_rxlos[3] = OPRXLOS_PORT(X+3) */ - {1, 1, 4}, /* map_rxlos[4] = OPRXLOS_PORT(X+4) */ - {1, 1, 5}, /* map_rxlos[5] = OPRXLOS_PORT(X+5) */ - {1, 1, 6}, /* map_rxlos[6] = OPRXLOS_PORT(X+6) */ - {1, 1, 7}, /* map_rxlos[7] = OPRXLOS_PORT(X+7) */ - }, -}; - - -struct ioexp_map_s ioexp_map_magnolia_7ab = { - - .chip_amount = 2, - .data_width = 2, - - .map_present = { {1, 0, 4}, /* map_present[0] = MOD_ABS_PORT(X) */ - {1, 0, 5}, /* map_present[1] = MOD_ABS_PORT(X+1) */ - {1, 0, 6}, /* map_present[2] = MOD_ABS_PORT(X+2) */ - {1, 0, 7}, /* map_present[3] = MOD_ABS_PORT(X+3) */ - {1, 1, 4}, /* map_present[4] = MOD_ABS_PORT(X+4) */ - {1, 1, 5}, /* map_present[5] = MOD_ABS_PORT(X+5) */ - }, - .map_reset = { {0, 0, 0}, /* map_reset[0] = QRESET_QSFP_N_P(X) */ - {0, 0, 1}, /* map_reset[1] = QRESET_QSFP_N_P(X+1) */ - {0, 0, 2}, /* map_reset[2] = QRESET_QSFP_N_P(X+2) */ - {0, 0, 3}, /* map_reset[3] = QRESET_QSFP_N_P(X+3) */ - {1, 0, 0}, /* map_reset[4] = QRESET_QSFP_N_P(X+4) */ - {1, 0, 1}, /* map_reset[5] = QRESET_QSFP_N_P(X+5) */ - }, - .map_lpmod = { {0, 0, 4}, /* map_lpmod[0] = LPMODE_QSFP_P(X) */ - {0, 0, 5}, /* map_lpmod[1] = LPMODE_QSFP_P(X+1) */ - {0, 0, 6}, /* map_lpmod[2] = LPMODE_QSFP_P(X+2) */ - {0, 0, 7}, /* map_lpmod[3] = LPMODE_QSFP_P(X+3) */ - {1, 0, 2}, /* map_lpmod[4] = LPMODE_QSFP_P(X+4) */ - {1, 0, 3}, /* map_lpmod[5] = LPMODE_QSFP_P(X+5) */ - }, - .map_modsel = { {0, 1, 4}, /* map_modsel[0] = MODSEL_QSFP_N_P(X) */ - {0, 1, 5}, /* map_modsel[1] = MODSEL_QSFP_N_P(X+1) */ - {0, 1, 6}, /* map_modsel[2] = MODSEL_QSFP_N_P(X+2) */ - {0, 1, 7}, /* map_modsel[3] = MODSEL_QSFP_N_P(X+3) */ - {1, 1, 4}, /* map_modsel[4] = MODSEL_QSFP_N_P(X+4) */ - {1, 1, 5}, /* map_modsel[5] = MODSEL_QSFP_N_P(X+5) */ - }, -}; - - -struct ioexp_map_s ioexp_map_redwood_p01p08_p17p24 = { - - .chip_amount = 3, - .data_width = 2, - - .map_present = { {2, 0, 0}, /* map_present[0] = MOD_ABS_PORT(X) */ - {2, 0, 1}, /* map_present[1] = MOD_ABS_PORT(X+1) */ - {2, 0, 2}, /* map_present[2] = MOD_ABS_PORT(X+2) */ - {2, 0, 3}, /* map_present[3] = MOD_ABS_PORT(X+3) */ - {2, 0, 4}, /* map_present[4] = MOD_ABS_PORT(X+4) */ - {2, 0, 5}, /* map_present[5] = MOD_ABS_PORT(X+5) */ - {2, 0, 6}, /* map_present[6] = MOD_ABS_PORT(X+6) */ - {2, 0, 7}, /* map_present[7] = MOD_ABS_PORT(X+7) */ - }, - .map_reset = { {0, 0, 0}, /* map_reset[0] = QRESET_QSFP28_N_P(X) */ - {0, 0, 1}, /* map_reset[1] = QRESET_QSFP28_N_P(X+1) */ - {0, 0, 2}, /* map_reset[2] = QRESET_QSFP28_N_P(X+2) */ - {0, 0, 3}, /* map_reset[3] = QRESET_QSFP28_N_P(X+3) */ - {1, 0, 0}, /* map_reset[4] = QRESET_QSFP28_N_P(X+4) */ - {1, 0, 1}, /* map_reset[5] = QRESET_QSFP28_N_P(X+5) */ - {1, 0, 2}, /* map_reset[6] = QRESET_QSFP28_N_P(X+6) */ - {1, 0, 3}, /* map_reset[7] = QRESET_QSFP28_N_P(X+7) */ - }, - .map_lpmod = { {0, 0, 4}, /* map_lpmod[0] = LPMODE_QSFP28_P(X) */ - {0, 0, 5}, /* map_lpmod[1] = LPMODE_QSFP28_P(X+1) */ - {0, 0, 6}, /* map_lpmod[2] = LPMODE_QSFP28_P(X+2) */ - {0, 0, 7}, /* map_lpmod[3] = LPMODE_QSFP28_P(X+3) */ - {1, 0, 4}, /* map_lpmod[4] = LPMODE_QSFP28_P(X+4) */ - {1, 0, 5}, /* map_lpmod[5] = LPMODE_QSFP28_P(X+5) */ - {1, 0, 6}, /* map_lpmod[6] = LPMODE_QSFP28_P(X+6) */ - {1, 0, 7}, /* map_lpmod[7] = LPMODE_QSFP28_P(X+7) */ - }, - .map_modsel = { {0, 1, 4}, /* map_modsel[0] = MODSEL_QSFP28_N_P(X) */ - {0, 1, 5}, /* map_modsel[1] = MODSEL_QSFP28_N_P(X+1) */ - {0, 1, 6}, /* map_modsel[2] = MODSEL_QSFP28_N_P(X+2) */ - {0, 1, 7}, /* map_modsel[3] = MODSEL_QSFP28_N_P(X+3) */ - {1, 1, 4}, /* map_modsel[4] = MODSEL_QSFP28_N_P(X+4) */ - {1, 1, 5}, /* map_modsel[5] = MODSEL_QSFP28_N_P(X+5) */ - {1, 1, 6}, /* map_modsel[6] = MODSEL_QSFP28_N_P(X+6) */ - {1, 1, 7}, /* map_modsel[7] = MODSEL_QSFP28_N_P(X+7) */ - }, -}; - - -struct ioexp_map_s ioexp_map_redwood_p09p16_p25p32 = { - - .chip_amount = 3, - .data_width = 2, - - .map_present = { {2, 1, 0}, /* map_present[0] = MOD_ABS_PORT(X) */ - {2, 1, 1}, /* map_present[1] = MOD_ABS_PORT(X+1) */ - {2, 1, 2}, /* map_present[2] = MOD_ABS_PORT(X+2) */ - {2, 1, 3}, /* map_present[3] = MOD_ABS_PORT(X+3) */ - {2, 1, 4}, /* map_present[4] = MOD_ABS_PORT(X+4) */ - {2, 1, 5}, /* map_present[5] = MOD_ABS_PORT(X+5) */ - {2, 1, 6}, /* map_present[6] = MOD_ABS_PORT(X+6) */ - {2, 1, 7}, /* map_present[7] = MOD_ABS_PORT(X+7) */ - }, - .map_reset = { {0, 0, 0}, /* map_reset[0] = QRESET_QSFP28_N_P(X) */ - {0, 0, 1}, /* map_reset[1] = QRESET_QSFP28_N_P(X+1) */ - {0, 0, 2}, /* map_reset[2] = QRESET_QSFP28_N_P(X+2) */ - {0, 0, 3}, /* map_reset[3] = QRESET_QSFP28_N_P(X+3) */ - {1, 0, 0}, /* map_reset[4] = QRESET_QSFP28_N_P(X+4) */ - {1, 0, 1}, /* map_reset[5] = QRESET_QSFP28_N_P(X+5) */ - {1, 0, 2}, /* map_reset[6] = QRESET_QSFP28_N_P(X+6) */ - {1, 0, 3}, /* map_reset[7] = QRESET_QSFP28_N_P(X+7) */ - }, - .map_lpmod = { {0, 0, 4}, /* map_lpmod[0] = LPMODE_QSFP28_P(X) */ - {0, 0, 5}, /* map_lpmod[1] = LPMODE_QSFP28_P(X+1) */ - {0, 0, 6}, /* map_lpmod[2] = LPMODE_QSFP28_P(X+2) */ - {0, 0, 7}, /* map_lpmod[3] = LPMODE_QSFP28_P(X+3) */ - {1, 0, 4}, /* map_lpmod[4] = LPMODE_QSFP28_P(X+4) */ - {1, 0, 5}, /* map_lpmod[5] = LPMODE_QSFP28_P(X+5) */ - {1, 0, 6}, /* map_lpmod[6] = LPMODE_QSFP28_P(X+6) */ - {1, 0, 7}, /* map_lpmod[7] = LPMODE_QSFP28_P(X+7) */ - }, - .map_modsel = { {0, 1, 4}, /* map_modsel[0] = MODSEL_QSFP28_N_P(X) */ - {0, 1, 5}, /* map_modsel[1] = MODSEL_QSFP28_N_P(X+1) */ - {0, 1, 6}, /* map_modsel[2] = MODSEL_QSFP28_N_P(X+2) */ - {0, 1, 7}, /* map_modsel[3] = MODSEL_QSFP28_N_P(X+3) */ - {1, 1, 4}, /* map_modsel[4] = MODSEL_QSFP28_N_P(X+4) */ - {1, 1, 5}, /* map_modsel[5] = MODSEL_QSFP28_N_P(X+5) */ - {1, 1, 6}, /* map_modsel[6] = MODSEL_QSFP28_N_P(X+6) */ - {1, 1, 7}, /* map_modsel[7] = MODSEL_QSFP28_N_P(X+7) */ - }, -}; - - -struct ioexp_map_s ioexp_map_hudson32iga_p01p08_p17p24 = { - - .chip_amount = 3, - .data_width = 2, - - .map_present = { {2, 0, 0}, /* map_present[0] = MODABS_QSFP(X) */ - {2, 0, 1}, /* map_present[1] = MODABS_QSFP(X+1) */ - {2, 0, 2}, /* map_present[2] = MODABS_QSFP(X+2) */ - {2, 0, 3}, /* map_present[3] = MODABS_QSFP(X+3) */ - {2, 0, 4}, /* map_present[4] = MODABS_QSFP(X+4) */ - {2, 0, 5}, /* map_present[5] = MODABS_QSFP(X+5) */ - {2, 0, 6}, /* map_present[6] = MODABS_QSFP(X+6) */ - {2, 0, 7}, /* map_present[7] = MODABS_QSFP(X+7) */ - }, - .map_reset = { {0, 0, 0}, /* map_reset[0] = QRESET_QSFP(X) */ - {0, 0, 1}, /* map_reset[1] = QRESET_QSFP(X+1) */ - {0, 0, 2}, /* map_reset[2] = QRESET_QSFP(X+2) */ - {0, 0, 3}, /* map_reset[3] = QRESET_QSFP(X+3) */ - {1, 0, 0}, /* map_reset[4] = QRESET_QSFP(X+4) */ - {1, 0, 1}, /* map_reset[5] = QRESET_QSFP(X+5) */ - {1, 0, 2}, /* map_reset[6] = QRESET_QSFP(X+6) */ - {1, 0, 3}, /* map_reset[7] = QRESET_QSFP(X+7) */ - }, - .map_lpmod = { {0, 0, 4}, /* map_lpmod[0] = LPMODE_QSFP(X) */ - {0, 0, 5}, /* map_lpmod[1] = LPMODE_QSFP(X+1) */ - {0, 0, 6}, /* map_lpmod[2] = LPMODE_QSFP(X+2) */ - {0, 0, 7}, /* map_lpmod[3] = LPMODE_QSFP(X+3) */ - {1, 0, 4}, /* map_lpmod[4] = LPMODE_QSFP(X+4) */ - {1, 0, 5}, /* map_lpmod[5] = LPMODE_QSFP(X+5) */ - {1, 0, 6}, /* map_lpmod[6] = LPMODE_QSFP(X+6) */ - {1, 0, 7}, /* map_lpmod[7] = LPMODE_QSFP(X+7) */ - }, - .map_modsel = { {0, 1, 4}, /* map_modsel[0] = MODSEL_QSFP(X) */ - {0, 1, 5}, /* map_modsel[1] = MODSEL_QSFP(X+1) */ - {0, 1, 6}, /* map_modsel[2] = MODSEL_QSFP(X+2) */ - {0, 1, 7}, /* map_modsel[3] = MODSEL_QSFP(X+3) */ - {1, 1, 4}, /* map_modsel[4] = MODSEL_QSFP(X+4) */ - {1, 1, 5}, /* map_modsel[5] = MODSEL_QSFP(X+5) */ - {1, 1, 6}, /* map_modsel[6] = MODSEL_QSFP(X+6) */ - {1, 1, 7}, /* map_modsel[7] = MODSEL_QSFP(X+7) */ - }, -}; - - -struct ioexp_map_s ioexp_map_hudson32iga_p09p16_p25p32 = { - - .chip_amount = 3, - .data_width = 2, - - .map_present = { {2, 1, 0}, /* map_present[0] = MODABS_QSFP(X) */ - {2, 1, 1}, /* map_present[1] = MODABS_QSFP(X+1) */ - {2, 1, 2}, /* map_present[2] = MODABS_QSFP(X+2) */ - {2, 1, 3}, /* map_present[3] = MODABS_QSFP(X+3) */ - {2, 1, 4}, /* map_present[4] = MODABS_QSFP(X+4) */ - {2, 1, 5}, /* map_present[5] = MODABS_QSFP(X+5) */ - {2, 1, 6}, /* map_present[6] = MODABS_QSFP(X+6) */ - {2, 1, 7}, /* map_present[7] = MODABS_QSFP(X+7) */ - }, - .map_reset = { {0, 0, 0}, /* map_reset[0] = QRESET_QSFP(X) */ - {0, 0, 1}, /* map_reset[1] = QRESET_QSFP(X+1) */ - {0, 0, 2}, /* map_reset[2] = QRESET_QSFP(X+2) */ - {0, 0, 3}, /* map_reset[3] = QRESET_QSFP(X+3) */ - {1, 0, 0}, /* map_reset[4] = QRESET_QSFP(X+4) */ - {1, 0, 1}, /* map_reset[5] = QRESET_QSFP(X+5) */ - {1, 0, 2}, /* map_reset[6] = QRESET_QSFP(X+6) */ - {1, 0, 3}, /* map_reset[7] = QRESET_QSFP(X+7) */ - }, - .map_lpmod = { {0, 0, 4}, /* map_lpmod[0] = LPMODE_QSFP(X) */ - {0, 0, 5}, /* map_lpmod[1] = LPMODE_QSFP(X+1) */ - {0, 0, 6}, /* map_lpmod[2] = LPMODE_QSFP(X+2) */ - {0, 0, 7}, /* map_lpmod[3] = LPMODE_QSFP(X+3) */ - {1, 0, 4}, /* map_lpmod[4] = LPMODE_QSFP(X+4) */ - {1, 0, 5}, /* map_lpmod[5] = LPMODE_QSFP(X+5) */ - {1, 0, 6}, /* map_lpmod[6] = LPMODE_QSFP(X+6) */ - {1, 0, 7}, /* map_lpmod[7] = LPMODE_QSFP(X+7) */ - }, - .map_modsel = { {0, 1, 4}, /* map_modsel[0] = MODSEL_QSFP(X) */ - {0, 1, 5}, /* map_modsel[1] = MODSEL_QSFP(X+1) */ - {0, 1, 6}, /* map_modsel[2] = MODSEL_QSFP(X+2) */ - {0, 1, 7}, /* map_modsel[3] = MODSEL_QSFP(X+3) */ - {1, 1, 4}, /* map_modsel[4] = MODSEL_QSFP(X+4) */ - {1, 1, 5}, /* map_modsel[5] = MODSEL_QSFP(X+5) */ - {1, 1, 6}, /* map_modsel[6] = MODSEL_QSFP(X+6) */ - {1, 1, 7}, /* map_modsel[7] = MODSEL_QSFP(X+7) */ - }, -}; - - -struct ioexp_map_s ioexp_map_cypress_nabc = { - - .chip_amount = 3, - .data_width = 2, - - .map_present = { {0, 0, 4}, /* map_present[0] = MOD_ABS_PORT(X) */ - {0, 0, 5}, /* map_present[1] = MOD_ABS_PORT(X+1) */ - {0, 0, 6}, /* map_present[2] = MOD_ABS_PORT(X+2) */ - {0, 0, 7}, /* map_present[3] = MOD_ABS_PORT(X+3) */ - {1, 0, 4}, /* map_present[4] = MOD_ABS_PORT(X+4) */ - {1, 0, 5}, /* map_present[5] = MOD_ABS_PORT(X+5) */ - {1, 0, 6}, /* map_present[6] = MOD_ABS_PORT(X+6) */ - {1, 0, 7}, /* map_present[7] = MOD_ABS_PORT(X+7) */ - }, - .map_tx_disable = { {0, 1, 0}, /* map_tx_disable[0] = TXDISABLE_SFP+_P(X) */ - {0, 1, 1}, /* map_tx_disable[1] = TXDISABLE_SFP+_P(X+1) */ - {0, 1, 2}, /* map_tx_disable[2] = TXDISABLE_SFP+_P(X+2) */ - {0, 1, 3}, /* map_tx_disable[3] = TXDISABLE_SFP+_P(X+3) */ - {1, 1, 0}, /* map_tx_disable[4] = TXDISABLE_SFP+_P(X+4) */ - {1, 1, 1}, /* map_tx_disable[5] = TXDISABLE_SFP+_P(X+5) */ - {1, 1, 2}, /* map_tx_disable[6] = TXDISABLE_SFP+_P(X+6) */ - {1, 1, 3}, /* map_tx_disable[7] = TXDISABLE_SFP+_P(X+7) */ - }, - .map_tx_fault = { {0, 0, 0}, /* map_tx_fault[0] = TXFAULT_SFP+_P(X) */ - {0, 0, 1}, /* map_tx_fault[1] = TXFAULT_SFP+_P(X+1) */ - {0, 0, 2}, /* map_tx_fault[2] = TXFAULT_SFP+_P(X+2) */ - {0, 0, 3}, /* map_tx_fault[3] = TXFAULT_SFP+_P(X+3) */ - {1, 0, 0}, /* map_tx_fault[4] = TXFAULT_SFP+_P(X+4) */ - {1, 0, 1}, /* map_tx_fault[5] = TXFAULT_SFP+_P(X+5) */ - {1, 0, 2}, /* map_tx_fault[6] = TXFAULT_SFP+_P(X+6) */ - {1, 0, 3}, /* map_tx_fault[7] = TXFAULT_SFP+_P(X+7) */ - }, - .map_rxlos = { {0, 1, 4}, /* map_rxlos[0] = OPRXLOS_PORT(X) */ - {0, 1, 5}, /* map_rxlos[1] = OPRXLOS_PORT(X+1) */ - {0, 1, 6}, /* map_rxlos[2] = OPRXLOS_PORT(X+2) */ - {0, 1, 7}, /* map_rxlos[3] = OPRXLOS_PORT(X+3) */ - {1, 1, 4}, /* map_rxlos[4] = OPRXLOS_PORT(X+4) */ - {1, 1, 5}, /* map_rxlos[5] = OPRXLOS_PORT(X+5) */ - {1, 1, 6}, /* map_rxlos[6] = OPRXLOS_PORT(X+6) */ - {1, 1, 7}, /* map_rxlos[7] = OPRXLOS_PORT(X+7) */ - }, - .map_hard_rs0 = { {2, 0, 0}, /* map_hard_rs0[0] = RS0_SFP28_P(X) */ - {2, 0, 2}, /* map_hard_rs0[1] = RS0_SFP28_P(X+1) */ - {2, 0, 4}, /* map_hard_rs0[2] = RS0_SFP28_P(X+2) */ - {2, 0, 6}, /* map_hard_rs0[3] = RS0_SFP28_P(X+3) */ - {2, 1, 0}, /* map_hard_rs0[4] = RS0_SFP28_P(X+4) */ - {2, 1, 2}, /* map_hard_rs0[5] = RS0_SFP28_P(X+5) */ - {2, 1, 4}, /* map_hard_rs0[6] = RS0_SFP28_P(X+6) */ - {2, 1, 6}, /* map_hard_rs0[7] = RS0_SFP28_P(X+7) */ - }, - .map_hard_rs1 = { {2, 0, 1}, /* map_hard_rs1[0] = RS1_SFP28_P(X) */ - {2, 0, 3}, /* map_hard_rs1[1] = RS1_SFP28_P(X+1) */ - {2, 0, 5}, /* map_hard_rs1[2] = RS1_SFP28_P(X+2) */ - {2, 0, 7}, /* map_hard_rs1[3] = RS1_SFP28_P(X+3) */ - {2, 1, 1}, /* map_hard_rs1[4] = RS1_SFP28_P(X+4) */ - {2, 1, 3}, /* map_hard_rs1[5] = RS1_SFP28_P(X+5) */ - {2, 1, 5}, /* map_hard_rs1[6] = RS1_SFP28_P(X+6) */ - {2, 1, 7}, /* map_hard_rs1[7] = RS1_SFP28_P(X+7) */ - }, -}; - - -struct ioexp_map_s ioexp_map_cypress_7abc = { - - .chip_amount = 3, - .data_width = 2, - - .map_present = { {2, 0, 0}, /* map_present[0] = MOD_ABS_PORT(X) */ - {2, 0, 1}, /* map_present[1] = MOD_ABS_PORT(X+1) */ - {2, 0, 2}, /* map_present[2] = MOD_ABS_PORT(X+2) */ - {2, 0, 3}, /* map_present[3] = MOD_ABS_PORT(X+3) */ - {2, 0, 4}, /* map_present[4] = MOD_ABS_PORT(X+4) */ - {2, 0, 5}, /* map_present[5] = MOD_ABS_PORT(X+5) */ - }, - .map_reset = { {0, 0, 0}, /* map_reset[0] = QRESET_QSFP_N_P(X) */ - {0, 0, 1}, /* map_reset[1] = QRESET_QSFP_N_P(X+1) */ - {0, 0, 2}, /* map_reset[2] = QRESET_QSFP_N_P(X+2) */ - {0, 0, 3}, /* map_reset[3] = QRESET_QSFP_N_P(X+3) */ - {0, 0, 4}, /* map_reset[4] = QRESET_QSFP_N_P(X+4) */ - {0, 0, 5}, /* map_reset[5] = QRESET_QSFP_N_P(X+5) */ - }, - .map_lpmod = { {0, 1, 0}, /* map_lpmod[0] = LPMODE_QSFP_P(X) */ - {0, 1, 1}, /* map_lpmod[1] = LPMODE_QSFP_P(X+1) */ - {0, 1, 2}, /* map_lpmod[2] = LPMODE_QSFP_P(X+2) */ - {0, 1, 3}, /* map_lpmod[3] = LPMODE_QSFP_P(X+3) */ - {0, 1, 4}, /* map_lpmod[4] = LPMODE_QSFP_P(X+4) */ - {0, 1, 5}, /* map_lpmod[5] = LPMODE_QSFP_P(X+5) */ - }, - .map_modsel = { {1, 1, 0}, /* map_modsel[0] = MODSEL_QSFP_N_P(X) */ - {1, 1, 1}, /* map_modsel[1] = MODSEL_QSFP_N_P(X+1) */ - {1, 1, 2}, /* map_modsel[2] = MODSEL_QSFP_N_P(X+2) */ - {1, 1, 3}, /* map_modsel[3] = MODSEL_QSFP_N_P(X+3) */ - {1, 1, 4}, /* map_modsel[4] = MODSEL_QSFP_N_P(X+4) */ - {1, 1, 5}, /* map_modsel[5] = MODSEL_QSFP_N_P(X+5) */ - }, -}; - - -struct ioexp_map_s ioexp_map_tahoe_5a = { - - .chip_amount = 1, - .data_width = 2, - - .map_present = { {0, 0, 3}, /* map_present[0] = MOD_ABS_PORT(X) */ - {0, 1, 0}, /* map_present[1] = MOD_ABS_PORT(X+1) */ - {0, 1, 5}, /* map_present[2] = MOD_ABS_PORT(X+2) */ - }, - .map_reset = { {0, 0, 1}, /* map_reset[0] = QRESET_QSFP_N_P(X) */ - {0, 0, 6}, /* map_reset[1] = QRESET_QSFP_N_P(X+1) */ - {0, 1, 3}, /* map_reset[2] = QRESET_QSFP_N_P(X+2) */ - }, - .map_lpmod = { {0, 0, 2}, /* map_lpmod[0] = LPMODE_QSFP_P(X) */ - {0, 0, 7}, /* map_lpmod[1] = LPMODE_QSFP_P(X+1) */ - {0, 1, 4}, /* map_lpmod[2] = LPMODE_QSFP_P(X+2) */ - }, - .map_modsel = { {0, 0, 0}, /* map_modsel[0] = MODSEL_QSFP_N_P(X) */ - {0, 0, 5}, /* map_modsel[1] = MODSEL_QSFP_N_P(X+1) */ - {0, 1, 2}, /* map_modsel[2] = MODSEL_QSFP_N_P(X+2) */ - }, -}; - - -struct ioexp_map_s ioexp_map_tahoe_6abc = { - - .chip_amount = 3, - .data_width = 2, - - .map_present = { {0, 0, 3}, /* map_present[0] = MOD_ABS_PORT(X) */ - {0, 1, 0}, /* map_present[1] = MOD_ABS_PORT(X+1) */ - {0, 1, 5}, /* map_present[2] = MOD_ABS_PORT(X+2) */ - {1, 0, 3}, /* map_present[3] = MOD_ABS_PORT(X+3) */ - {1, 1, 0}, /* map_present[4] = MOD_ABS_PORT(X+4) */ - {1, 1, 5}, /* map_present[5] = MOD_ABS_PORT(X+5) */ - {2, 0, 3}, /* map_present[6] = MOD_ABS_PORT(X+6) */ - {2, 1, 0}, /* map_present[7] = MOD_ABS_PORT(X+7) */ - {2, 1, 5}, /* map_present[8] = MOD_ABS_PORT(X+8) */ - }, - .map_reset = { {0, 0, 1}, /* map_reset[0] = QRESET_QSFP28_N_P(X) */ - {0, 0, 6}, /* map_reset[1] = QRESET_QSFP28_N_P(X+1) */ - {0, 1, 3}, /* map_reset[2] = QRESET_QSFP28_N_P(X+2) */ - {1, 0, 1}, /* map_reset[3] = QRESET_QSFP28_N_P(X+3) */ - {1, 0, 6}, /* map_reset[4] = QRESET_QSFP28_N_P(X+4) */ - {1, 1, 3}, /* map_reset[5] = QRESET_QSFP28_N_P(X+5) */ - {2, 0, 1}, /* map_reset[6] = QRESET_QSFP28_N_P(X+6) */ - {2, 0, 6}, /* map_reset[7] = QRESET_QSFP28_N_P(X+7) */ - {2, 1, 3}, /* map_reset[7] = QRESET_QSFP28_N_P(X+7) */ - }, - .map_lpmod = { {0, 0, 2}, /* map_lpmod[0] = LPMODE_QSFP28_P(X) */ - {0, 0, 7}, /* map_lpmod[1] = LPMODE_QSFP28_P(X+1) */ - {0, 1, 4}, /* map_lpmod[2] = LPMODE_QSFP28_P(X+2) */ - {1, 0, 2}, /* map_lpmod[3] = LPMODE_QSFP28_P(X+3) */ - {1, 0, 7}, /* map_lpmod[4] = LPMODE_QSFP28_P(X+4) */ - {1, 1, 4}, /* map_lpmod[5] = LPMODE_QSFP28_P(X+5) */ - {2, 0, 2}, /* map_lpmod[6] = LPMODE_QSFP28_P(X+6) */ - {2, 0, 7}, /* map_lpmod[7] = LPMODE_QSFP28_P(X+7) */ - {2, 1, 4}, /* map_lpmod[7] = LPMODE_QSFP28_P(X+8) */ - }, - .map_modsel = { {0, 0, 0}, /* map_modsel[0] = MODSEL_QSFP28_N_P(X) */ - {0, 0, 5}, /* map_modsel[1] = MODSEL_QSFP28_N_P(X+1) */ - {0, 1, 2}, /* map_modsel[2] = MODSEL_QSFP28_N_P(X+2) */ - {1, 0, 0}, /* map_modsel[3] = MODSEL_QSFP28_N_P(X+3) */ - {1, 0, 5}, /* map_modsel[4] = MODSEL_QSFP28_N_P(X+4) */ - {1, 1, 2}, /* map_modsel[5] = MODSEL_QSFP28_N_P(X+5) */ - {2, 0, 0}, /* map_modsel[6] = MODSEL_QSFP28_N_P(X+6) */ - {2, 0, 5}, /* map_modsel[7] = MODSEL_QSFP28_N_P(X+7) */ - {2, 1, 2}, /* map_modsel[7] = MODSEL_QSFP28_N_P(X+7) */ - }, -}; - - -struct ioexp_map_s ioexp_map_sequoia_nabc = { - - .chip_amount = 3, - .data_width = 2, - - .map_present = { {2, 1, 0}, /* map_present[0] = MOD_ABS_PORT(X) */ - {2, 1, 1}, /* map_present[1] = MOD_ABS_PORT(X+1) */ - {2, 1, 2}, /* map_present[2] = MOD_ABS_PORT(X+2) */ - {2, 1, 3}, /* map_present[3] = MOD_ABS_PORT(X+3) */ - {2, 1, 4}, /* map_present[4] = MOD_ABS_PORT(X+4) */ - {2, 1, 5}, /* map_present[5] = MOD_ABS_PORT(X+5) */ - {2, 1, 6}, /* map_present[6] = MOD_ABS_PORT(X+6) */ - {2, 1, 7}, /* map_present[7] = MOD_ABS_PORT(X+7) */ - }, - .map_reset = { {0, 1, 0}, /* map_reset[0] = QRESET_QSFP28_N_P(X) */ - {0, 1, 1}, /* map_reset[1] = QRESET_QSFP28_N_P(X+1) */ - {0, 1, 2}, /* map_reset[2] = QRESET_QSFP28_N_P(X+2) */ - {0, 1, 3}, /* map_reset[3] = QRESET_QSFP28_N_P(X+3) */ - {0, 1, 4}, /* map_reset[4] = QRESET_QSFP28_N_P(X+4) */ - {0, 1, 5}, /* map_reset[5] = QRESET_QSFP28_N_P(X+5) */ - {0, 1, 6}, /* map_reset[6] = QRESET_QSFP28_N_P(X+6) */ - {0, 1, 7}, /* map_reset[7] = QRESET_QSFP28_N_P(X+7) */ - }, - .map_lpmod = { {1, 0, 0}, /* map_lpmod[0] = LPMODE_QSFP28_P(X) */ - {1, 0, 1}, /* map_lpmod[1] = LPMODE_QSFP28_P(X+1) */ - {1, 0, 2}, /* map_lpmod[2] = LPMODE_QSFP28_P(X+2) */ - {1, 0, 3}, /* map_lpmod[3] = LPMODE_QSFP28_P(X+3) */ - {1, 0, 4}, /* map_lpmod[4] = LPMODE_QSFP28_P(X+4) */ - {1, 0, 5}, /* map_lpmod[5] = LPMODE_QSFP28_P(X+5) */ - {1, 0, 6}, /* map_lpmod[6] = LPMODE_QSFP28_P(X+6) */ - {1, 0, 7}, /* map_lpmod[7] = LPMODE_QSFP28_P(X+7) */ - }, - .map_modsel = { {0, 0, 0}, /* map_modsel[0] = MODSEL_QSFP28_N_P(X) */ - {0, 0, 1}, /* map_modsel[1] = MODSEL_QSFP28_N_P(X+1) */ - {0, 0, 2}, /* map_modsel[2] = MODSEL_QSFP28_N_P(X+2) */ - {0, 0, 3}, /* map_modsel[3] = MODSEL_QSFP28_N_P(X+3) */ - {0, 0, 4}, /* map_modsel[4] = MODSEL_QSFP28_N_P(X+4) */ - {0, 0, 5}, /* map_modsel[5] = MODSEL_QSFP28_N_P(X+5) */ - {0, 0, 6}, /* map_modsel[6] = MODSEL_QSFP28_N_P(X+6) */ - {0, 0, 7}, /* map_modsel[7] = MODSEL_QSFP28_N_P(X+7) */ - }, -}; - - -struct ioexp_map_s ioexp_map_lavender_p65 = { - - .chip_amount = 1, - .data_width = 1, - - .map_present = { {0, 0, 4}, }, /* map_present[0] = MOD_ABS_PORT(X) */ - .map_reset = { {0, 0, 1}, }, /* map_reset[0] = QRESET_QSFP28_N_P(X) */ - .map_lpmod = { {0, 0, 2}, }, /* map_lpmod[0] = LPMODE_QSFP28_P(X) */ - .map_modsel = { {0, 0, 0}, }, /* map_modsel[0] = MODSEL_QSFP28_N_P(X) */ -}; - - -struct ioexp_map_s cpld_map_cottonwood = { - - .chip_amount = 1, - .data_width = 4, - - .map_present = { {0, 2, 0}, /* map_present[0] = MOD_ABS_PORT(X) */ - {0, 2, 4}, /* map_present[1] = MOD_ABS_PORT(X+1) */ - {0, 3, 0}, /* map_present[2] = MOD_ABS_PORT(X+2) */ - {0, 3, 4}, /* map_present[3] = MOD_ABS_PORT(X+3) */ - }, - .map_tx_disable = { {0, 0, 0}, /* map_tx_disable[0] = TXDISABLE_SFP+_P(X) */ - {0, 0, 4}, /* map_tx_disable[1] = TXDISABLE_SFP+_P(X+1) */ - {0, 1, 0}, /* map_tx_disable[2] = TXDISABLE_SFP+_P(X+2) */ - {0, 1, 4}, /* map_tx_disable[3] = TXDISABLE_SFP+_P(X+3) */ - }, - .map_tx_fault = { {0, 2, 2}, /* map_tx_fault[0] = TXFAULT_SFP+_P(X) */ - {0, 2, 6}, /* map_tx_fault[1] = TXFAULT_SFP+_P(X+1) */ - {0, 3, 2}, /* map_tx_fault[2] = TXFAULT_SFP+_P(X+2) */ - {0, 3, 6}, /* map_tx_fault[3] = TXFAULT_SFP+_P(X+3) */ - }, - .map_rxlos = { {0, 2, 1}, /* map_rxlos[0] = OPRXLOS_PORT(X) */ - {0, 2, 5}, /* map_rxlos[1] = OPRXLOS_PORT(X+1) */ - {0, 3, 1}, /* map_rxlos[2] = OPRXLOS_PORT(X+2) */ - {0, 3, 5}, /* map_rxlos[3] = OPRXLOS_PORT(X+3) */ - }, - .map_hard_rs0 = { {0, 0, 2}, /* map_hard_rs0[0] = RS0_SFP28_P(X) */ - {0, 0, 6}, /* map_hard_rs0[1] = RS0_SFP28_P(X+1) */ - {0, 1, 2}, /* map_hard_rs0[2] = RS0_SFP28_P(X+2) */ - {0, 1, 6}, /* map_hard_rs0[3] = RS0_SFP28_P(X+3) */ - }, - .map_hard_rs1 = { {0, 0, 2}, /* map_hard_rs1[0] = RS1_SFP28_P(X) */ - {0, 0, 6}, /* map_hard_rs1[1] = RS1_SFP28_P(X+1) */ - {0, 1, 2}, /* map_hard_rs1[2] = RS1_SFP28_P(X+2) */ - {0, 1, 6}, /* map_hard_rs1[3] = RS1_SFP28_P(X+3) */ - }, -}; - - -struct ioexp_map_s ioexp_map_maple_0abc = { - - .chip_amount = 3, - .data_width = 2, - - .map_present = { {2, 1, 0}, /* map_present[0] = MOD_ABS_PORT(X) */ - {2, 1, 1}, /* map_present[1] = MOD_ABS_PORT(X+1) */ - {2, 1, 2}, /* map_present[2] = MOD_ABS_PORT(X+2) */ - {2, 1, 3}, /* map_present[3] = MOD_ABS_PORT(X+3) */ - {2, 1, 4}, /* map_present[4] = MOD_ABS_PORT(X+4) */ - {2, 1, 5}, /* map_present[5] = MOD_ABS_PORT(X+5) */ - {2, 1, 6}, /* map_present[6] = MOD_ABS_PORT(X+6) */ - {2, 1, 7}, /* map_present[7] = MOD_ABS_PORT(X+7) */ - }, - .map_reset = { {0, 1, 0}, /* map_reset[0] = QRESET_QSFP_N_P(X) */ - {0, 1, 1}, /* map_reset[1] = QRESET_QSFP_N_P(X+1) */ - {0, 1, 2}, /* map_reset[2] = QRESET_QSFP_N_P(X+2) */ - {0, 1, 3}, /* map_reset[3] = QRESET_QSFP_N_P(X+3) */ - {0, 1, 4}, /* map_reset[4] = QRESET_QSFP_N_P(X+4) */ - {0, 1, 5}, /* map_reset[5] = QRESET_QSFP_N_P(X+5) */ - {0, 1, 6}, /* map_reset[6] = QRESET_QSFP_N_P(X+6) */ - {0, 1, 7}, /* map_reset[7] = QRESET_QSFP_N_P(X+7) */ - }, - .map_lpmod = { {1, 0, 0}, /* map_lpmod[0] = LPMODE_QSFP_P(X) */ - {1, 0, 1}, /* map_lpmod[1] = LPMODE_QSFP_P(X+1) */ - {1, 0, 2}, /* map_lpmod[2] = LPMODE_QSFP_P(X+2) */ - {1, 0, 3}, /* map_lpmod[3] = LPMODE_QSFP_P(X+3) */ - {1, 0, 4}, /* map_lpmod[4] = LPMODE_QSFP_P(X+4) */ - {1, 0, 5}, /* map_lpmod[5] = LPMODE_QSFP_P(X+5) */ - {1, 0, 6}, /* map_lpmod[6] = LPMODE_QSFP_P(X+6) */ - {1, 0, 7}, /* map_lpmod[7] = LPMODE_QSFP_P(X+7) */ - }, - .map_modsel = { {0, 0, 0}, /* map_modsel[0] = MODSEL_QSFP_N_P(X) */ - {0, 0, 1}, /* map_modsel[1] = MODSEL_QSFP_N_P(X+1) */ - {0, 0, 2}, /* map_modsel[2] = MODSEL_QSFP_N_P(X+2) */ - {0, 0, 3}, /* map_modsel[3] = MODSEL_QSFP_N_P(X+3) */ - {0, 0, 4}, /* map_modsel[4] = MODSEL_QSFP_N_P(X+4) */ - {0, 0, 5}, /* map_modsel[5] = MODSEL_QSFP_N_P(X+5) */ - {0, 0, 6}, /* map_modsel[6] = MODSEL_QSFP_N_P(X+6) */ - {0, 0, 7}, /* map_modsel[7] = MODSEL_QSFP_N_P(X+7) */ - }, -}; - - -struct ioexp_map_s ioexp_map_maple_nabc = { - - .chip_amount = 3, - .data_width = 2, - - .map_present = { {0, 0, 4}, /* map_present[0] = MOD_ABS_PORT(X) */ - {0, 0, 5}, /* map_present[1] = MOD_ABS_PORT(X+1) */ - {0, 0, 6}, /* map_present[2] = MOD_ABS_PORT(X+2) */ - {0, 0, 7}, /* map_present[3] = MOD_ABS_PORT(X+3) */ - {1, 0, 4}, /* map_present[4] = MOD_ABS_PORT(X+4) */ - {1, 0, 5}, /* map_present[5] = MOD_ABS_PORT(X+5) */ - {1, 0, 6}, /* map_present[6] = MOD_ABS_PORT(X+6) */ - {1, 0, 7}, /* map_present[7] = MOD_ABS_PORT(X+7) */ - }, - .map_tx_disable = { {0, 1, 0}, /* map_tx_disable[0] = TXDISABLE_SFP+_P(X) */ - {0, 1, 1}, /* map_tx_disable[1] = TXDISABLE_SFP+_P(X+1) */ - {0, 1, 2}, /* map_tx_disable[2] = TXDISABLE_SFP+_P(X+2) */ - {0, 1, 3}, /* map_tx_disable[3] = TXDISABLE_SFP+_P(X+3) */ - {1, 1, 0}, /* map_tx_disable[4] = TXDISABLE_SFP+_P(X+4) */ - {1, 1, 1}, /* map_tx_disable[5] = TXDISABLE_SFP+_P(X+5) */ - {1, 1, 2}, /* map_tx_disable[6] = TXDISABLE_SFP+_P(X+6) */ - {1, 1, 3}, /* map_tx_disable[7] = TXDISABLE_SFP+_P(X+7) */ - }, - .map_tx_fault = { {0, 0, 0}, /* map_tx_fault[0] = TXFAULT_SFP+_P(X) */ - {0, 0, 1}, /* map_tx_fault[1] = TXFAULT_SFP+_P(X+1) */ - {0, 0, 2}, /* map_tx_fault[2] = TXFAULT_SFP+_P(X+2) */ - {0, 0, 3}, /* map_tx_fault[3] = TXFAULT_SFP+_P(X+3) */ - {1, 0, 0}, /* map_tx_fault[4] = TXFAULT_SFP+_P(X+4) */ - {1, 0, 1}, /* map_tx_fault[5] = TXFAULT_SFP+_P(X+5) */ - {1, 0, 2}, /* map_tx_fault[6] = TXFAULT_SFP+_P(X+6) */ - {1, 0, 3}, /* map_tx_fault[7] = TXFAULT_SFP+_P(X+7) */ - }, - .map_rxlos = { {0, 1, 4}, /* map_rxlos[0] = OPRXLOS_PORT(X) */ - {0, 1, 5}, /* map_rxlos[1] = OPRXLOS_PORT(X+1) */ - {0, 1, 6}, /* map_rxlos[2] = OPRXLOS_PORT(X+2) */ - {0, 1, 7}, /* map_rxlos[3] = OPRXLOS_PORT(X+3) */ - {1, 1, 4}, /* map_rxlos[4] = OPRXLOS_PORT(X+4) */ - {1, 1, 5}, /* map_rxlos[5] = OPRXLOS_PORT(X+5) */ - {1, 1, 6}, /* map_rxlos[6] = OPRXLOS_PORT(X+6) */ - {1, 1, 7}, /* map_rxlos[7] = OPRXLOS_PORT(X+7) */ - }, - .map_hard_rs0 = { {2, 0, 0}, /* map_hard_rs0[0] = RS0_SFP28_P(X) */ - {2, 0, 2}, /* map_hard_rs0[1] = RS0_SFP28_P(X+1) */ - {2, 0, 4}, /* map_hard_rs0[2] = RS0_SFP28_P(X+2) */ - {2, 0, 6}, /* map_hard_rs0[3] = RS0_SFP28_P(X+3) */ - {2, 1, 0}, /* map_hard_rs0[4] = RS0_SFP28_P(X+4) */ - {2, 1, 2}, /* map_hard_rs0[5] = RS0_SFP28_P(X+5) */ - {2, 1, 4}, /* map_hard_rs0[6] = RS0_SFP28_P(X+6) */ - {2, 1, 6}, /* map_hard_rs0[7] = RS0_SFP28_P(X+7) */ - }, - .map_hard_rs1 = { {2, 0, 1}, /* map_hard_rs1[0] = RS1_SFP28_P(X) */ - {2, 0, 3}, /* map_hard_rs1[1] = RS1_SFP28_P(X+1) */ - {2, 0, 5}, /* map_hard_rs1[2] = RS1_SFP28_P(X+2) */ - {2, 0, 7}, /* map_hard_rs1[3] = RS1_SFP28_P(X+3) */ - {2, 1, 1}, /* map_hard_rs1[4] = RS1_SFP28_P(X+4) */ - {2, 1, 3}, /* map_hard_rs1[5] = RS1_SFP28_P(X+5) */ - {2, 1, 5}, /* map_hard_rs1[6] = RS1_SFP28_P(X+6) */ - {2, 1, 7}, /* map_hard_rs1[7] = RS1_SFP28_P(X+7) */ - }, -}; - - -struct ioexp_map_s ioexp_map_gulmohar_nabc = { - - .chip_amount = 3, - .data_width = 2, - - .map_present = { {0, 0, 4}, /* map_present[0] = MOD_ABS_PORT(X) */ - {0, 0, 5}, /* map_present[1] = MOD_ABS_PORT(X+1) */ - {0, 1, 4}, /* map_present[2] = MOD_ABS_PORT(X+2) */ - {0, 1, 5}, /* map_present[3] = MOD_ABS_PORT(X+3) */ - {1, 0, 4}, /* map_present[4] = MOD_ABS_PORT(X+4) */ - {1, 0, 5}, /* map_present[5] = MOD_ABS_PORT(X+5) */ - {1, 1, 4}, /* map_present[6] = MOD_ABS_PORT(X+6) */ - {1, 1, 5}, /* map_present[7] = MOD_ABS_PORT(X+7) */ - }, - .map_tx_disable = { {0, 0, 2}, /* map_tx_disable[0] = TXDISABLE_SFP+_P(X) */ - {0, 0, 3}, /* map_tx_disable[1] = TXDISABLE_SFP+_P(X+1) */ - {0, 1, 2}, /* map_tx_disable[2] = TXDISABLE_SFP+_P(X+2) */ - {0, 1, 3}, /* map_tx_disable[3] = TXDISABLE_SFP+_P(X+3) */ - {1, 0, 2}, /* map_tx_disable[4] = TXDISABLE_SFP+_P(X+4) */ - {1, 0, 3}, /* map_tx_disable[5] = TXDISABLE_SFP+_P(X+5) */ - {1, 1, 2}, /* map_tx_disable[6] = TXDISABLE_SFP+_P(X+6) */ - {1, 1, 3}, /* map_tx_disable[7] = TXDISABLE_SFP+_P(X+7) */ - }, - .map_tx_fault = { {0, 0, 0}, /* map_tx_fault[0] = TXFAULT_SFP+_P(X) */ - {0, 0, 1}, /* map_tx_fault[1] = TXFAULT_SFP+_P(X+1) */ - {0, 1, 0}, /* map_tx_fault[2] = TXFAULT_SFP+_P(X+2) */ - {0, 1, 1}, /* map_tx_fault[3] = TXFAULT_SFP+_P(X+3) */ - {1, 0, 0}, /* map_tx_fault[4] = TXFAULT_SFP+_P(X+4) */ - {1, 0, 1}, /* map_tx_fault[5] = TXFAULT_SFP+_P(X+5) */ - {1, 1, 0}, /* map_tx_fault[6] = TXFAULT_SFP+_P(X+6) */ - {1, 1, 1}, /* map_tx_fault[7] = TXFAULT_SFP+_P(X+7) */ - }, - .map_rxlos = { {0, 0, 6}, /* map_rxlos[0] = OPRXLOS_PORT(X) */ - {0, 0, 7}, /* map_rxlos[1] = OPRXLOS_PORT(X+1) */ - {0, 1, 6}, /* map_rxlos[2] = OPRXLOS_PORT(X+2) */ - {0, 1, 7}, /* map_rxlos[3] = OPRXLOS_PORT(X+3) */ - {1, 0, 6}, /* map_rxlos[4] = OPRXLOS_PORT(X+4) */ - {1, 0, 7}, /* map_rxlos[5] = OPRXLOS_PORT(X+5) */ - {1, 1, 6}, /* map_rxlos[6] = OPRXLOS_PORT(X+6) */ - {1, 1, 7}, /* map_rxlos[7] = OPRXLOS_PORT(X+7) */ - }, - .map_hard_rs0 = { {2, 0, 0}, /* map_hard_rs0[0] = RS0_SFP28_P(X) */ - {2, 0, 2}, /* map_hard_rs0[1] = RS0_SFP28_P(X+1) */ - {2, 0, 4}, /* map_hard_rs0[2] = RS0_SFP28_P(X+2) */ - {2, 0, 6}, /* map_hard_rs0[3] = RS0_SFP28_P(X+3) */ - {2, 1, 0}, /* map_hard_rs0[4] = RS0_SFP28_P(X+4) */ - {2, 1, 2}, /* map_hard_rs0[5] = RS0_SFP28_P(X+5) */ - {2, 1, 4}, /* map_hard_rs0[6] = RS0_SFP28_P(X+6) */ - {2, 1, 6}, /* map_hard_rs0[7] = RS0_SFP28_P(X+7) */ - }, - .map_hard_rs1 = { {2, 0, 1}, /* map_hard_rs1[0] = RS1_SFP28_P(X) */ - {2, 0, 3}, /* map_hard_rs1[1] = RS1_SFP28_P(X+1) */ - {2, 0, 5}, /* map_hard_rs1[2] = RS1_SFP28_P(X+2) */ - {2, 0, 7}, /* map_hard_rs1[3] = RS1_SFP28_P(X+3) */ - {2, 1, 1}, /* map_hard_rs1[4] = RS1_SFP28_P(X+4) */ - {2, 1, 3}, /* map_hard_rs1[5] = RS1_SFP28_P(X+5) */ - {2, 1, 5}, /* map_hard_rs1[6] = RS1_SFP28_P(X+6) */ - {2, 1, 7}, /* map_hard_rs1[7] = RS1_SFP28_P(X+7) */ - }, -}; - - -struct ioexp_map_s ioexp_map_gulmohar_7abc = { - - .chip_amount = 3, - .data_width = 2, - - .map_present = { {2, 1, 0}, /* map_present[0] = MOD_ABS_PORT(X) */ - {2, 1, 1}, /* map_present[1] = MOD_ABS_PORT(X+1) */ - {2, 1, 2}, /* map_present[2] = MOD_ABS_PORT(X+2) */ - {2, 1, 3}, /* map_present[3] = MOD_ABS_PORT(X+3) */ - {2, 1, 4}, /* map_present[4] = MOD_ABS_PORT(X+4) */ - {2, 1, 5}, /* map_present[5] = MOD_ABS_PORT(X+5) */ - }, - .map_reset = { {0, 1, 0}, /* map_reset[0] = QRESET_QSFP_N_P(X) */ - {0, 1, 1}, /* map_reset[1] = QRESET_QSFP_N_P(X+1) */ - {0, 1, 2}, /* map_reset[2] = QRESET_QSFP_N_P(X+2) */ - {0, 1, 3}, /* map_reset[3] = QRESET_QSFP_N_P(X+3) */ - {0, 1, 4}, /* map_reset[4] = QRESET_QSFP_N_P(X+4) */ - {0, 1, 5}, /* map_reset[5] = QRESET_QSFP_N_P(X+5) */ - }, - .map_lpmod = { {1, 0, 0}, /* map_lpmod[0] = LPMODE_QSFP_P(X) */ - {1, 0, 1}, /* map_lpmod[1] = LPMODE_QSFP_P(X+1) */ - {1, 0, 2}, /* map_lpmod[2] = LPMODE_QSFP_P(X+2) */ - {1, 0, 3}, /* map_lpmod[3] = LPMODE_QSFP_P(X+3) */ - {1, 0, 4}, /* map_lpmod[4] = LPMODE_QSFP_P(X+4) */ - {1, 0, 5}, /* map_lpmod[5] = LPMODE_QSFP_P(X+5) */ - }, - .map_modsel = { {0, 0, 0}, /* map_modsel[0] = MODSEL_QSFP_N_P(X) */ - {0, 0, 1}, /* map_modsel[1] = MODSEL_QSFP_N_P(X+1) */ - {0, 0, 2}, /* map_modsel[2] = MODSEL_QSFP_N_P(X+2) */ - {0, 0, 3}, /* map_modsel[3] = MODSEL_QSFP_N_P(X+3) */ - {0, 0, 4}, /* map_modsel[4] = MODSEL_QSFP_N_P(X+4) */ - {0, 0, 5}, /* map_modsel[5] = MODSEL_QSFP_N_P(X+5) */ - }, -}; - - -struct ioexp_map_s ioexp_map_gulmohar_2t_evt1_nabc = { - - .chip_amount = 3, - .data_width = 2, - - .map_present = { {0, 0, 2}, /* map_present[0] = MOD_ABS_PORT(X) */ - {0, 0, 6}, /* map_present[1] = MOD_ABS_PORT(X+1) */ - {0, 1, 2}, /* map_present[2] = MOD_ABS_PORT(X+2) */ - {0, 1, 6}, /* map_present[3] = MOD_ABS_PORT(X+3) */ - {1, 0, 2}, /* map_present[4] = MOD_ABS_PORT(X+4) */ - {1, 0, 6}, /* map_present[5] = MOD_ABS_PORT(X+5) */ - {1, 1, 2}, /* map_present[6] = MOD_ABS_PORT(X+6) */ - {1, 1, 6}, /* map_present[7] = MOD_ABS_PORT(X+7) */ - }, - .map_tx_disable = { {0, 0, 1}, /* map_tx_disable[0] = TXDISABLE_SFP+_P(X) */ - {0, 0, 5}, /* map_tx_disable[1] = TXDISABLE_SFP+_P(X+1) */ - {0, 1, 1}, /* map_tx_disable[2] = TXDISABLE_SFP+_P(X+2) */ - {0, 1, 5}, /* map_tx_disable[3] = TXDISABLE_SFP+_P(X+3) */ - {1, 0, 1}, /* map_tx_disable[4] = TXDISABLE_SFP+_P(X+4) */ - {1, 0, 5}, /* map_tx_disable[5] = TXDISABLE_SFP+_P(X+5) */ - {1, 1, 1}, /* map_tx_disable[6] = TXDISABLE_SFP+_P(X+6) */ - {1, 1, 5}, /* map_tx_disable[7] = TXDISABLE_SFP+_P(X+7) */ - }, - .map_tx_fault = { {0, 0, 0}, /* map_tx_fault[0] = TXFAULT_SFP+_P(X) */ - {0, 0, 4}, /* map_tx_fault[1] = TXFAULT_SFP+_P(X+1) */ - {0, 1, 0}, /* map_tx_fault[2] = TXFAULT_SFP+_P(X+2) */ - {0, 1, 4}, /* map_tx_fault[3] = TXFAULT_SFP+_P(X+3) */ - {1, 0, 0}, /* map_tx_fault[4] = TXFAULT_SFP+_P(X+4) */ - {1, 0, 4}, /* map_tx_fault[5] = TXFAULT_SFP+_P(X+5) */ - {1, 1, 0}, /* map_tx_fault[6] = TXFAULT_SFP+_P(X+6) */ - {1, 1, 4}, /* map_tx_fault[7] = TXFAULT_SFP+_P(X+7) */ - }, - .map_rxlos = { {0, 0, 3}, /* map_rxlos[0] = OPRXLOS_PORT(X) */ - {0, 0, 7}, /* map_rxlos[1] = OPRXLOS_PORT(X+1) */ - {0, 1, 3}, /* map_rxlos[2] = OPRXLOS_PORT(X+2) */ - {0, 1, 7}, /* map_rxlos[3] = OPRXLOS_PORT(X+3) */ - {1, 0, 3}, /* map_rxlos[4] = OPRXLOS_PORT(X+4) */ - {1, 0, 7}, /* map_rxlos[5] = OPRXLOS_PORT(X+5) */ - {1, 1, 3}, /* map_rxlos[6] = OPRXLOS_PORT(X+6) */ - {1, 1, 7}, /* map_rxlos[7] = OPRXLOS_PORT(X+7) */ - }, - .map_hard_rs0 = { {2, 0, 0}, /* map_hard_rs0[0] = RS0_SFP28_P(X) */ - {2, 0, 2}, /* map_hard_rs0[1] = RS0_SFP28_P(X+1) */ - {2, 0, 4}, /* map_hard_rs0[2] = RS0_SFP28_P(X+2) */ - {2, 0, 6}, /* map_hard_rs0[3] = RS0_SFP28_P(X+3) */ - {2, 1, 0}, /* map_hard_rs0[4] = RS0_SFP28_P(X+4) */ - {2, 1, 2}, /* map_hard_rs0[5] = RS0_SFP28_P(X+5) */ - {2, 1, 4}, /* map_hard_rs0[6] = RS0_SFP28_P(X+6) */ - {2, 1, 6}, /* map_hard_rs0[7] = RS0_SFP28_P(X+7) */ - }, - .map_hard_rs1 = { {2, 0, 1}, /* map_hard_rs1[0] = RS1_SFP28_P(X) */ - {2, 0, 3}, /* map_hard_rs1[1] = RS1_SFP28_P(X+1) */ - {2, 0, 5}, /* map_hard_rs1[2] = RS1_SFP28_P(X+2) */ - {2, 0, 7}, /* map_hard_rs1[3] = RS1_SFP28_P(X+3) */ - {2, 1, 1}, /* map_hard_rs1[4] = RS1_SFP28_P(X+4) */ - {2, 1, 3}, /* map_hard_rs1[5] = RS1_SFP28_P(X+5) */ - {2, 1, 5}, /* map_hard_rs1[6] = RS1_SFP28_P(X+6) */ - {2, 1, 7}, /* map_hard_rs1[7] = RS1_SFP28_P(X+7) */ - }, -}; - - -struct ioexp_map_s ioexp_map_gulmohar_2t_evt1_1abc = { - - .chip_amount = 3, - .data_width = 2, - - .map_present = { {0, 0, 2}, /* map_present[0] = MOD_ABS_PORT(X) */ - {0, 0, 6}, /* map_present[1] = MOD_ABS_PORT(X+1) */ - {0, 1, 2}, /* map_present[2] = MOD_ABS_PORT(X+2) */ - {0, 1, 6}, /* map_present[3] = MOD_ABS_PORT(X+3) */ - {1, 0, 4}, /* map_present[4] = MOD_ABS_PORT(X+4) */ - {1, 0, 5}, /* map_present[5] = MOD_ABS_PORT(X+5) */ - {1, 1, 4}, /* map_present[6] = MOD_ABS_PORT(X+6) */ - {1, 1, 5}, /* map_present[7] = MOD_ABS_PORT(X+7) */ - }, - .map_tx_disable = { {0, 0, 1}, /* map_tx_disable[0] = TXDISABLE_SFP+_P(X) */ - {0, 0, 5}, /* map_tx_disable[1] = TXDISABLE_SFP+_P(X+1) */ - {0, 1, 1}, /* map_tx_disable[2] = TXDISABLE_SFP+_P(X+2) */ - {0, 1, 5}, /* map_tx_disable[3] = TXDISABLE_SFP+_P(X+3) */ - {1, 0, 2}, /* map_tx_disable[4] = TXDISABLE_SFP+_P(X+4) */ - {1, 0, 3}, /* map_tx_disable[5] = TXDISABLE_SFP+_P(X+5) */ - {1, 1, 2}, /* map_tx_disable[6] = TXDISABLE_SFP+_P(X+6) */ - {1, 1, 3}, /* map_tx_disable[7] = TXDISABLE_SFP+_P(X+7) */ - }, - .map_tx_fault = { {0, 0, 0}, /* map_tx_fault[0] = TXFAULT_SFP+_P(X) */ - {0, 0, 4}, /* map_tx_fault[1] = TXFAULT_SFP+_P(X+1) */ - {0, 1, 0}, /* map_tx_fault[2] = TXFAULT_SFP+_P(X+2) */ - {0, 1, 4}, /* map_tx_fault[3] = TXFAULT_SFP+_P(X+3) */ - {1, 0, 0}, /* map_tx_fault[4] = TXFAULT_SFP+_P(X+4) */ - {1, 0, 1}, /* map_tx_fault[5] = TXFAULT_SFP+_P(X+5) */ - {1, 1, 0}, /* map_tx_fault[6] = TXFAULT_SFP+_P(X+6) */ - {1, 1, 1}, /* map_tx_fault[7] = TXFAULT_SFP+_P(X+7) */ - }, - .map_rxlos = { {0, 0, 3}, /* map_rxlos[0] = OPRXLOS_PORT(X) */ - {0, 0, 7}, /* map_rxlos[1] = OPRXLOS_PORT(X+1) */ - {0, 1, 3}, /* map_rxlos[2] = OPRXLOS_PORT(X+2) */ - {0, 1, 7}, /* map_rxlos[3] = OPRXLOS_PORT(X+3) */ - {1, 0, 6}, /* map_rxlos[4] = OPRXLOS_PORT(X+4) */ - {1, 0, 7}, /* map_rxlos[5] = OPRXLOS_PORT(X+5) */ - {1, 1, 6}, /* map_rxlos[6] = OPRXLOS_PORT(X+6) */ - {1, 1, 7}, /* map_rxlos[7] = OPRXLOS_PORT(X+7) */ - }, - .map_hard_rs0 = { {2, 0, 0}, /* map_hard_rs0[0] = RS0_SFP28_P(X) */ - {2, 0, 2}, /* map_hard_rs0[1] = RS0_SFP28_P(X+1) */ - {2, 0, 4}, /* map_hard_rs0[2] = RS0_SFP28_P(X+2) */ - {2, 0, 6}, /* map_hard_rs0[3] = RS0_SFP28_P(X+3) */ - {2, 1, 0}, /* map_hard_rs0[4] = RS0_SFP28_P(X+4) */ - {2, 1, 2}, /* map_hard_rs0[5] = RS0_SFP28_P(X+5) */ - {2, 1, 4}, /* map_hard_rs0[6] = RS0_SFP28_P(X+6) */ - {2, 1, 6}, /* map_hard_rs0[7] = RS0_SFP28_P(X+7) */ - }, - .map_hard_rs1 = { {2, 0, 1}, /* map_hard_rs1[0] = RS1_SFP28_P(X) */ - {2, 0, 3}, /* map_hard_rs1[1] = RS1_SFP28_P(X+1) */ - {2, 0, 5}, /* map_hard_rs1[2] = RS1_SFP28_P(X+2) */ - {2, 0, 7}, /* map_hard_rs1[3] = RS1_SFP28_P(X+3) */ - {2, 1, 1}, /* map_hard_rs1[4] = RS1_SFP28_P(X+4) */ - {2, 1, 3}, /* map_hard_rs1[5] = RS1_SFP28_P(X+5) */ - {2, 1, 5}, /* map_hard_rs1[6] = RS1_SFP28_P(X+6) */ - {2, 1, 7}, /* map_hard_rs1[7] = RS1_SFP28_P(X+7) */ - }, -}; - - -struct ioexp_map_s ioexp_map_gulmohar_2t_evt1_3abc = { - - .chip_amount = 3, - .data_width = 2, - - .map_present = { {0, 0, 4}, /* map_present[0] = MOD_ABS_PORT(X) */ - {0, 0, 5}, /* map_present[1] = MOD_ABS_PORT(X+1) */ - {0, 1, 4}, /* map_present[2] = MOD_ABS_PORT(X+2) */ - {0, 1, 5}, /* map_present[3] = MOD_ABS_PORT(X+3) */ - {1, 0, 2}, /* map_present[4] = MOD_ABS_PORT(X+4) */ - {1, 0, 6}, /* map_present[5] = MOD_ABS_PORT(X+5) */ - {1, 1, 2}, /* map_present[6] = MOD_ABS_PORT(X+6) */ - {1, 1, 6}, /* map_present[7] = MOD_ABS_PORT(X+7) */ - }, - .map_tx_disable = { {0, 0, 2}, /* map_tx_disable[0] = TXDISABLE_SFP+_P(X) */ - {0, 0, 3}, /* map_tx_disable[1] = TXDISABLE_SFP+_P(X+1) */ - {0, 1, 2}, /* map_tx_disable[2] = TXDISABLE_SFP+_P(X+2) */ - {0, 1, 3}, /* map_tx_disable[3] = TXDISABLE_SFP+_P(X+3) */ - {1, 0, 1}, /* map_tx_disable[4] = TXDISABLE_SFP+_P(X+4) */ - {1, 0, 5}, /* map_tx_disable[5] = TXDISABLE_SFP+_P(X+5) */ - {1, 1, 1}, /* map_tx_disable[6] = TXDISABLE_SFP+_P(X+6) */ - {1, 1, 5}, /* map_tx_disable[7] = TXDISABLE_SFP+_P(X+7) */ - }, - .map_tx_fault = { {0, 0, 0}, /* map_tx_fault[0] = TXFAULT_SFP+_P(X) */ - {0, 0, 1}, /* map_tx_fault[1] = TXFAULT_SFP+_P(X+1) */ - {0, 1, 0}, /* map_tx_fault[2] = TXFAULT_SFP+_P(X+2) */ - {0, 1, 1}, /* map_tx_fault[3] = TXFAULT_SFP+_P(X+3) */ - {1, 0, 0}, /* map_tx_fault[4] = TXFAULT_SFP+_P(X+4) */ - {1, 0, 4}, /* map_tx_fault[5] = TXFAULT_SFP+_P(X+5) */ - {1, 1, 0}, /* map_tx_fault[6] = TXFAULT_SFP+_P(X+6) */ - {1, 1, 4}, /* map_tx_fault[7] = TXFAULT_SFP+_P(X+7) */ - }, - .map_rxlos = { {0, 0, 6}, /* map_rxlos[0] = OPRXLOS_PORT(X) */ - {0, 0, 7}, /* map_rxlos[1] = OPRXLOS_PORT(X+1) */ - {0, 1, 6}, /* map_rxlos[2] = OPRXLOS_PORT(X+2) */ - {0, 1, 7}, /* map_rxlos[3] = OPRXLOS_PORT(X+3) */ - {1, 0, 3}, /* map_rxlos[4] = OPRXLOS_PORT(X+4) */ - {1, 0, 7}, /* map_rxlos[5] = OPRXLOS_PORT(X+5) */ - {1, 1, 3}, /* map_rxlos[6] = OPRXLOS_PORT(X+6) */ - {1, 1, 7}, /* map_rxlos[7] = OPRXLOS_PORT(X+7) */ - }, - .map_hard_rs0 = { {2, 0, 0}, /* map_hard_rs0[0] = RS0_SFP28_P(X) */ - {2, 0, 2}, /* map_hard_rs0[1] = RS0_SFP28_P(X+1) */ - {2, 0, 4}, /* map_hard_rs0[2] = RS0_SFP28_P(X+2) */ - {2, 0, 6}, /* map_hard_rs0[3] = RS0_SFP28_P(X+3) */ - {2, 1, 0}, /* map_hard_rs0[4] = RS0_SFP28_P(X+4) */ - {2, 1, 2}, /* map_hard_rs0[5] = RS0_SFP28_P(X+5) */ - {2, 1, 4}, /* map_hard_rs0[6] = RS0_SFP28_P(X+6) */ - {2, 1, 6}, /* map_hard_rs0[7] = RS0_SFP28_P(X+7) */ - }, - .map_hard_rs1 = { {2, 0, 1}, /* map_hard_rs1[0] = RS1_SFP28_P(X) */ - {2, 0, 3}, /* map_hard_rs1[1] = RS1_SFP28_P(X+1) */ - {2, 0, 5}, /* map_hard_rs1[2] = RS1_SFP28_P(X+2) */ - {2, 0, 7}, /* map_hard_rs1[3] = RS1_SFP28_P(X+3) */ - {2, 1, 1}, /* map_hard_rs1[4] = RS1_SFP28_P(X+4) */ - {2, 1, 3}, /* map_hard_rs1[5] = RS1_SFP28_P(X+5) */ - {2, 1, 5}, /* map_hard_rs1[6] = RS1_SFP28_P(X+6) */ - {2, 1, 7}, /* map_hard_rs1[7] = RS1_SFP28_P(X+7) */ - }, -}; - - - -struct ioexp_map_s ioexp_map_gulmohar_2t_evt1_7abc = { - - .chip_amount = 3, - .data_width = 2, - - .map_present = { {0, 0, 4}, /* map_present[0] = MOD_ABS_PORT(X) */ - {0, 1, 1}, /* map_present[1] = MOD_ABS_PORT(X+1) */ - {0, 1, 6}, /* map_present[2] = MOD_ABS_PORT(X+2) */ - {1, 0, 4}, /* map_present[3] = MOD_ABS_PORT(X+3) */ - {1, 1, 1}, /* map_present[4] = MOD_ABS_PORT(X+4) */ - {1, 1, 6}, /* map_present[5] = MOD_ABS_PORT(X+5) */ - {2, 0, 4}, /* map_present[6] = MOD_ABS_PORT(X+6) */ - {2, 1, 1}, /* map_present[7] = MOD_ABS_PORT(X+7) */ - }, - .map_reset = { {0, 0, 1}, /* map_reset[0] = QRESET_QSFP_N_P(X) */ - {0, 0, 6}, /* map_reset[1] = QRESET_QSFP_N_P(X+1) */ - {0, 1, 3}, /* map_reset[2] = QRESET_QSFP_N_P(X+2) */ - {1, 0, 1}, /* map_reset[3] = QRESET_QSFP_N_P(X+3) */ - {1, 0, 6}, /* map_reset[4] = QRESET_QSFP_N_P(X+4) */ - {1, 1, 3}, /* map_reset[5] = QRESET_QSFP_N_P(X+5) */ - {2, 0, 1}, /* map_reset[6] = QRESET_QSFP_N_P(X+6) */ - {2, 0, 6}, /* map_reset[7] = QRESET_QSFP_N_P(X+7) */ - }, - .map_lpmod = { {0, 0, 2}, /* map_lpmod[0] = LPMODE_QSFP_P(X) */ - {0, 0, 7}, /* map_lpmod[1] = LPMODE_QSFP_P(X+1) */ - {0, 1, 4}, /* map_lpmod[2] = LPMODE_QSFP_P(X+2) */ - {1, 0, 2}, /* map_lpmod[3] = LPMODE_QSFP_P(X+3) */ - {1, 0, 7}, /* map_lpmod[4] = LPMODE_QSFP_P(X+4) */ - {1, 1, 4}, /* map_lpmod[5] = LPMODE_QSFP_P(X+5) */ - {2, 0, 2}, /* map_lpmod[6] = LPMODE_QSFP_P(X+6) */ - {2, 0, 7}, /* map_lpmod[7] = LPMODE_QSFP_P(X+7) */ - }, - .map_modsel = { {0, 0, 0}, /* map_modsel[0] = MODSEL_QSFP_N_P(X) */ - {0, 0, 5}, /* map_modsel[1] = MODSEL_QSFP_N_P(X+1) */ - {0, 1, 2}, /* map_modsel[2] = MODSEL_QSFP_N_P(X+2) */ - {1, 0, 0}, /* map_modsel[3] = MODSEL_QSFP_N_P(X+3) */ - {1, 0, 5}, /* map_modsel[4] = MODSEL_QSFP_N_P(X+4) */ - {1, 1, 2}, /* map_modsel[5] = MODSEL_QSFP_N_P(X+5) */ - {2, 0, 0}, /* map_modsel[6] = MODSEL_QSFP_N_P(X+6) */ - {2, 0, 5}, /* map_modsel[7] = MODSEL_QSFP_N_P(X+7) */ - }, -}; - - -/* PortType: SFP / 8 port - * Platform: Cypress, Peony_SFP - */ -struct ioexp_map_s ioexp_map_sfp_8p_layout_1 = { - - .chip_amount = 3, - .data_width = 2, - - .map_present = { {0, 0, 4}, /* map_present[0] = MOD_ABS_PORT(X) */ - {0, 0, 5}, /* map_present[1] = MOD_ABS_PORT(X+1) */ - {0, 0, 6}, /* map_present[2] = MOD_ABS_PORT(X+2) */ - {0, 0, 7}, /* map_present[3] = MOD_ABS_PORT(X+3) */ - {1, 0, 4}, /* map_present[4] = MOD_ABS_PORT(X+4) */ - {1, 0, 5}, /* map_present[5] = MOD_ABS_PORT(X+5) */ - {1, 0, 6}, /* map_present[6] = MOD_ABS_PORT(X+6) */ - {1, 0, 7}, /* map_present[7] = MOD_ABS_PORT(X+7) */ - }, - .map_tx_disable = { {0, 1, 0}, /* map_tx_disable[0] = TXDISABLE_SFP+_P(X) */ - {0, 1, 1}, /* map_tx_disable[1] = TXDISABLE_SFP+_P(X+1) */ - {0, 1, 2}, /* map_tx_disable[2] = TXDISABLE_SFP+_P(X+2) */ - {0, 1, 3}, /* map_tx_disable[3] = TXDISABLE_SFP+_P(X+3) */ - {1, 1, 0}, /* map_tx_disable[4] = TXDISABLE_SFP+_P(X+4) */ - {1, 1, 1}, /* map_tx_disable[5] = TXDISABLE_SFP+_P(X+5) */ - {1, 1, 2}, /* map_tx_disable[6] = TXDISABLE_SFP+_P(X+6) */ - {1, 1, 3}, /* map_tx_disable[7] = TXDISABLE_SFP+_P(X+7) */ - }, - .map_tx_fault = { {0, 0, 0}, /* map_tx_fault[0] = TXFAULT_SFP+_P(X) */ - {0, 0, 1}, /* map_tx_fault[1] = TXFAULT_SFP+_P(X+1) */ - {0, 0, 2}, /* map_tx_fault[2] = TXFAULT_SFP+_P(X+2) */ - {0, 0, 3}, /* map_tx_fault[3] = TXFAULT_SFP+_P(X+3) */ - {1, 0, 0}, /* map_tx_fault[4] = TXFAULT_SFP+_P(X+4) */ - {1, 0, 1}, /* map_tx_fault[5] = TXFAULT_SFP+_P(X+5) */ - {1, 0, 2}, /* map_tx_fault[6] = TXFAULT_SFP+_P(X+6) */ - {1, 0, 3}, /* map_tx_fault[7] = TXFAULT_SFP+_P(X+7) */ - }, - .map_rxlos = { {0, 1, 4}, /* map_rxlos[0] = OPRXLOS_PORT(X) */ - {0, 1, 5}, /* map_rxlos[1] = OPRXLOS_PORT(X+1) */ - {0, 1, 6}, /* map_rxlos[2] = OPRXLOS_PORT(X+2) */ - {0, 1, 7}, /* map_rxlos[3] = OPRXLOS_PORT(X+3) */ - {1, 1, 4}, /* map_rxlos[4] = OPRXLOS_PORT(X+4) */ - {1, 1, 5}, /* map_rxlos[5] = OPRXLOS_PORT(X+5) */ - {1, 1, 6}, /* map_rxlos[6] = OPRXLOS_PORT(X+6) */ - {1, 1, 7}, /* map_rxlos[7] = OPRXLOS_PORT(X+7) */ - }, - .map_hard_rs0 = { {2, 0, 0}, /* map_hard_rs0[0] = RS0_SFP28_P(X) */ - {2, 0, 2}, /* map_hard_rs0[1] = RS0_SFP28_P(X+1) */ - {2, 0, 4}, /* map_hard_rs0[2] = RS0_SFP28_P(X+2) */ - {2, 0, 6}, /* map_hard_rs0[3] = RS0_SFP28_P(X+3) */ - {2, 1, 0}, /* map_hard_rs0[4] = RS0_SFP28_P(X+4) */ - {2, 1, 2}, /* map_hard_rs0[5] = RS0_SFP28_P(X+5) */ - {2, 1, 4}, /* map_hard_rs0[6] = RS0_SFP28_P(X+6) */ - {2, 1, 6}, /* map_hard_rs0[7] = RS0_SFP28_P(X+7) */ - }, - .map_hard_rs1 = { {2, 0, 1}, /* map_hard_rs1[0] = RS1_SFP28_P(X) */ - {2, 0, 3}, /* map_hard_rs1[1] = RS1_SFP28_P(X+1) */ - {2, 0, 5}, /* map_hard_rs1[2] = RS1_SFP28_P(X+2) */ - {2, 0, 7}, /* map_hard_rs1[3] = RS1_SFP28_P(X+3) */ - {2, 1, 1}, /* map_hard_rs1[4] = RS1_SFP28_P(X+4) */ - {2, 1, 3}, /* map_hard_rs1[5] = RS1_SFP28_P(X+5) */ - {2, 1, 5}, /* map_hard_rs1[6] = RS1_SFP28_P(X+6) */ - {2, 1, 7}, /* map_hard_rs1[7] = RS1_SFP28_P(X+7) */ - }, -}; - - -/* PortType: QSFP / 6 port - * Platform: Gulmohar, Peony_SFP, Peony_Copper - */ -struct ioexp_map_s ioexp_map_6p_qsfp_type_1 = { - - .chip_amount = 3, - .data_width = 2, - - .map_present = { {2, 1, 0}, /* map_present[0] = MOD_ABS_PORT(X) */ - {2, 1, 1}, /* map_present[1] = MOD_ABS_PORT(X+1) */ - {2, 1, 2}, /* map_present[2] = MOD_ABS_PORT(X+2) */ - {2, 1, 3}, /* map_present[3] = MOD_ABS_PORT(X+3) */ - {2, 1, 4}, /* map_present[4] = MOD_ABS_PORT(X+4) */ - {2, 1, 5}, /* map_present[5] = MOD_ABS_PORT(X+5) */ - }, - .map_reset = { {0, 1, 0}, /* map_reset[0] = QRESET_QSFP_N_P(X) */ - {0, 1, 1}, /* map_reset[1] = QRESET_QSFP_N_P(X+1) */ - {0, 1, 2}, /* map_reset[2] = QRESET_QSFP_N_P(X+2) */ - {0, 1, 3}, /* map_reset[3] = QRESET_QSFP_N_P(X+3) */ - {0, 1, 4}, /* map_reset[4] = QRESET_QSFP_N_P(X+4) */ - {0, 1, 5}, /* map_reset[5] = QRESET_QSFP_N_P(X+5) */ - }, - .map_lpmod = { {1, 0, 0}, /* map_lpmod[0] = LPMODE_QSFP_P(X) */ - {1, 0, 1}, /* map_lpmod[1] = LPMODE_QSFP_P(X+1) */ - {1, 0, 2}, /* map_lpmod[2] = LPMODE_QSFP_P(X+2) */ - {1, 0, 3}, /* map_lpmod[3] = LPMODE_QSFP_P(X+3) */ - {1, 0, 4}, /* map_lpmod[4] = LPMODE_QSFP_P(X+4) */ - {1, 0, 5}, /* map_lpmod[5] = LPMODE_QSFP_P(X+5) */ - }, - .map_modsel = { {0, 0, 0}, /* map_modsel[0] = MODSEL_QSFP_N_P(X) */ - {0, 0, 1}, /* map_modsel[1] = MODSEL_QSFP_N_P(X+1) */ - {0, 0, 2}, /* map_modsel[2] = MODSEL_QSFP_N_P(X+2) */ - {0, 0, 3}, /* map_modsel[3] = MODSEL_QSFP_N_P(X+3) */ - {0, 0, 4}, /* map_modsel[4] = MODSEL_QSFP_N_P(X+4) */ - {0, 0, 5}, /* map_modsel[5] = MODSEL_QSFP_N_P(X+5) */ - }, -}; - - -/* ========== Private functions ========== - */ -int check_channel_tier_1(void); - -struct i2c_client * -_get_i2c_client(struct ioexp_obj_s *self, - int chip_id){ - - struct ioexp_i2c_s *i2c_curr_p = self->i2c_head_p; - - if (!(i2c_curr_p)){ - SWPS_ERR("%s: i2c_curr_p is NULL\n", __func__); - return NULL; - } - while (i2c_curr_p){ - if ((i2c_curr_p->chip_id) == chip_id){ - return i2c_curr_p->i2c_client_p; - } - i2c_curr_p = i2c_curr_p->next; - } - SWPS_ERR("%s: not exist! :%d\n", __func__, chip_id); - return NULL; -} - - -static int -_common_ioexp_update_one(struct ioexp_obj_s *self, - struct ioexp_addr_s *ioexp_addr, - int chip_id, - int data_width, - int show_err, - char *caller_name) { - int buf = 0; - int err = 0; - int data_id = 0; - int r_offset = 0; - - for(data_id=0; data_idread_offset[data_id]; - if (r_offset < 0) { - SWPS_DEBUG("skip a read_offset <%d>\n", r_offset); - continue; - } - buf = i2c_smbus_read_byte_data(_get_i2c_client(self, chip_id), r_offset); - /* Check error */ - if (buf < 0) { - err = 1; - if (show_err) { - SWPS_INFO("IOEXP-%d read fail! :%d \n", self->ioexp_id, buf); - SWPS_INFO("Dump: :%d :0x%02x :%d, :%s\n", - ioexp_addr->chan_id, ioexp_addr->chip_addr, - ioexp_addr->read_offset[data_id], caller_name); - } - continue; - } - /* Update IOEXP object */ - self->chip_data[chip_id].data[data_id] = (uint8_t)buf; - } - if (err) { - return ERR_IOEXP_UNEXCPT; - } - return 0; -} - - -static int -common_ioexp_update_all(struct ioexp_obj_s *self, - int show_err, - char *caller_name){ - - int err = 0; - int chip_id = 0; - int chip_amount = self->ioexp_map_p->chip_amount; - - for (chip_id=0; chip_idioexp_map_p->map_addr[chip_id]), - chip_id, - self->ioexp_map_p->data_width, - show_err, - caller_name) < 0) { - err = 1; - } - } - if (err) { - return ERR_IOEXP_UNEXCPT; - } - return 0; -} - - -static int -_common_check_by_mode(struct ioexp_obj_s *self){ - - switch (self->mode){ - case IOEXP_MODE_DIRECT: - return self->fsm_4_direct(self); - - case IOEXP_MODE_POLLING: - if (self->state >= 0){ - return 0; - } - switch (self->state){ - case STATE_IOEXP_INIT: - return ERR_IOEXP_UNINIT; - case STATE_IOEXP_ABNORMAL: - return ERR_IOEXP_ABNORMAL; - default: - return ERR_IOEXP_NOSTATE; - } - break; - - default: - break; - } - SWPS_ERR("%s: Exception occurs. :%d \n", __func__, self->mode); - return ERR_IOEXP_UNEXCPT; -} - - -static int -_common_get_bit(struct ioexp_obj_s *self, - struct ioexp_bitmap_s *bitmap_obj_p, - char *func_mane){ - uint8_t buf; - int err_code; - - /* Check and get address */ - err_code = _common_check_by_mode(self); - if (err_code < 0){ - return err_code; - } - if (!bitmap_obj_p){ - SWPS_ERR("Layout config incorrect! :%d :%s\n", - self->ioexp_id, func_mane); - return ERR_IOEXP_BADCONF; - } - /* Get data form cache */ - buf = self->chip_data[bitmap_obj_p->chip_id].data[bitmap_obj_p->ioexp_voffset]; - return (int)(buf >> bitmap_obj_p->bit_shift & 0x01); -} - - -static int -_common_set_bit(struct ioexp_obj_s *self, - struct ioexp_bitmap_s *bitmap_obj_p, - int input_val, - char *func_mane){ - int err_code, target_offset; - uint8_t origin_byte; - uint8_t modify_byte; - - /* Check and get address */ - err_code = _common_check_by_mode(self); - if (err_code < 0){ - return err_code; - } - if (!bitmap_obj_p){ - SWPS_ERR("Layout config incorrect! :%d :%s\n", - self->ioexp_id, func_mane); - return ERR_IOEXP_BADCONF; - } - /* Prepare write date */ - origin_byte = self->chip_data[bitmap_obj_p->chip_id].data[bitmap_obj_p->ioexp_voffset]; - switch (input_val) { - case 0: - modify_byte = origin_byte; - SWP_BIT_CLEAR(modify_byte, bitmap_obj_p->bit_shift); - break; - case 1: - modify_byte = origin_byte; - SWP_BIT_SET(modify_byte, bitmap_obj_p->bit_shift); - break; - default: - SWPS_ERR("Input value incorrect! :%d :%d :%s\n", - input_val, self->ioexp_id, func_mane); - return ERR_IOEXP_BADINPUT; - } - /* Setup i2c client */ - target_offset = self->ioexp_map_p->map_addr[bitmap_obj_p->chip_id].write_offset[bitmap_obj_p->ioexp_voffset]; - /* Write byte to chip via I2C */ - err_code = i2c_smbus_write_byte_data(_get_i2c_client(self, bitmap_obj_p->chip_id), - target_offset, - modify_byte); - /* Update or bollback object */ - if (err_code < 0){ - self->chip_data[bitmap_obj_p->chip_id].data[bitmap_obj_p->ioexp_voffset] = origin_byte; - SWPS_ERR("I2C write fail! :%d :%d :%s :%d\n", - input_val, self->ioexp_id, func_mane, err_code); - return err_code; - } - self->chip_data[bitmap_obj_p->chip_id].data[bitmap_obj_p->ioexp_voffset] = modify_byte; - return 0; -} - - -/* ========== Object public functions ========== - */ -int -common_get_present(struct ioexp_obj_s *self, - int virt_offset){ - - int UNPLUG = 1; - int retval = ERR_IOEXP_UNEXCPT; - - retval = _common_get_bit(self, - &(self->ioexp_map_p->map_present[virt_offset]), - "common_get_present"); - if (retval < 0) { - /* [Note] - * => Transceiver object does not need to handle IOEXP layer issues. - */ - return UNPLUG; - } - return retval; -} - - -int -common_get_tx_fault(struct ioexp_obj_s *self, - int virt_offset){ - /* [Transmit Fault (Tx_Fault)] - * A catastrophic laser fault will activate the transmitter signal, - * TX_FAULT, and disable the laser. This signal is an open collector - * output (pull-up required on the host board). A low signal indicates - * normal laser operation and a high signal indicates a fault. The - * TX_FAULT will be latched high when a laser fault occurs and is - * cleared by toggling the TX_DISABLE input or power cycling the - * transceiver. The transmitter fault condition can also be monitored - * via the two-wire serial interface. - * (address A2, byte 110, bit 2). - * - * 0: Normal - * 1: Abnormal - */ - return _common_get_bit(self, - &(self->ioexp_map_p->map_tx_fault[virt_offset]), - "common_get_tx_fault"); -} - - -int -common_get_rxlos(struct ioexp_obj_s *self, - int virt_offset){ - /* [Receiver Loss of Signal (Rx_LOS)] - * The post-amplification IC also includes transition detection circuitry - * which monitors the ac level of incoming optical signals and provides a - * TTL/CMOS compatible status signal to the host (pin 8). An adequate optical - * input results in a low Rx_LOS output while a high Rx_LOS output indicates - * an unusable optical input. The Rx_LOS thresholds are factory set so that - * a high output indicates a definite optical fault has occurred. Rx_LOS can - * also be monitored via the two-wire serial interface - * (address A2h, byte 110, bit 1). - * - * 0: Normal - * 1: Abnormal - */ - return _common_get_bit(self, - &(self->ioexp_map_p->map_rxlos[virt_offset]), - "common_get_rxlos"); -} - - -int -common_get_tx_disable(struct ioexp_obj_s *self, - int virt_offset){ - - return _common_get_bit(self, - &(self->ioexp_map_p->map_tx_disable[virt_offset]), - "common_get_tx_disable"); -} - - -int -common_get_reset(struct ioexp_obj_s *self, - int virt_offset){ - - return _common_get_bit(self, - &(self->ioexp_map_p->map_reset[virt_offset]), - "common_get_reset"); -} - - -int -common_get_lpmod(struct ioexp_obj_s *self, - int virt_offset){ - - return _common_get_bit(self, - &(self->ioexp_map_p->map_lpmod[virt_offset]), - "common_get_lpmod"); -} - - -int -common_get_modsel(struct ioexp_obj_s *self, - int virt_offset){ - - return _common_get_bit(self, - &(self->ioexp_map_p->map_modsel[virt_offset]), - "common_get_modsel"); -} - - -int -common_get_hard_rs0(struct ioexp_obj_s *self, - int virt_offset){ - - return _common_get_bit(self, - &(self->ioexp_map_p->map_hard_rs0[virt_offset]), - "common_get_hard_rs0"); -} - - -int -common_get_hard_rs1(struct ioexp_obj_s *self, - int virt_offset){ - - return _common_get_bit(self, - &(self->ioexp_map_p->map_hard_rs1[virt_offset]), - "common_get_hard_rs1"); -} - - -int -common_set_tx_disable(struct ioexp_obj_s *self, - int virt_offset, - int input_val){ - - return _common_set_bit(self, - &(self->ioexp_map_p->map_tx_disable[virt_offset]), - input_val, - "common_set_tx_disable"); -} - - -int -common_set_reset(struct ioexp_obj_s *self, - int virt_offset, - int input_val){ - - return _common_set_bit(self, - &(self->ioexp_map_p->map_reset[virt_offset]), - input_val, - "common_set_reset"); -} - - -int -common_set_lpmod(struct ioexp_obj_s *self, - int virt_offset, - int input_val){ - - return _common_set_bit(self, - &(self->ioexp_map_p->map_lpmod[virt_offset]), - input_val, - "common_set_lpmod"); -} - - -int -common_set_modsel(struct ioexp_obj_s *self, - int virt_offset, - int input_val){ - - return _common_set_bit(self, - &(self->ioexp_map_p->map_modsel[virt_offset]), - input_val, - "common_set_modsel"); -} - - -int -common_set_hard_rs0(struct ioexp_obj_s *self, - int virt_offset, - int input_val){ - - return _common_set_bit(self, - &(self->ioexp_map_p->map_hard_rs0[virt_offset]), - input_val, - "common_set_hard_rs0"); -} - - -int -common_set_hard_rs1(struct ioexp_obj_s *self, - int virt_offset, - int input_val){ - - return _common_set_bit(self, - &(self->ioexp_map_p->map_hard_rs1[virt_offset]), - input_val, - "common_set_hard_rs1"); -} - - -int -ioexp_get_not_support(struct ioexp_obj_s *self, - int virt_offset){ - return ERR_IOEXP_NOTSUPPORT; -} - - -int -ioexp_set_not_support(struct ioexp_obj_s *self, - int virt_offset, - int input_val){ - return ERR_IOEXP_NOTSUPPORT; -} - - -int -fake_ioexp_init(struct ioexp_obj_s *self){ - return 1; -} - -int -fake_ioexp_update(struct ioexp_obj_s *self){ - return 1; -} - - -int -fake_update_func(struct ioexp_obj_s *self){ - return 1; -} - -int -fake_get_func(struct ioexp_obj_s *self, - int virt_offset){ - SWPS_WARN("Someone called fake_get_func\n"); - return -1; -} - -int -fake_set_func(struct ioexp_obj_s *self, - int virt_offset, - int input_val){ - SWPS_WARN("Someone called fake_set_func\n"); - return -1; -} - - -/* ========== Initial functions for IO Expander ========== - */ -int -common_ioexp_init(struct ioexp_obj_s *self) { - - int chip_id, offset, err_code; - struct ioexp_addr_s *addr_p; - - if (self->mode == IOEXP_MODE_DIRECT) { - goto update_common_ioexp_init; - } - if (!io_no_init) { /*normal init*/ - - /* Setup default value to each physical IO Expander */ - for (chip_id=0; chip_id<(self->ioexp_map_p->chip_amount); chip_id++){ - /* Get address mapping */ - addr_p = &(self->ioexp_map_p->map_addr[chip_id]); - if (!addr_p){ - SWPS_ERR("%s: IOEXP config incorrect! :%d \n", - __func__, chip_id); - return -1; - } - /* Setup default value */ - for (offset=0; offset<(self->ioexp_map_p->data_width); offset++){ - - /* [Desc] Skip the setup default value behavior - [Note] Setup default value = -1 if you don't want to write the value to IOEXP or CPLD - */ - if(addr_p->write_offset[offset] < 0){ - SWPS_DEBUG("skip a write_offset <%d>\n", addr_p->conf_offset[offset]); - continue; - } - err_code = i2c_smbus_write_byte_data(_get_i2c_client(self, chip_id), - addr_p->write_offset[offset], - addr_p->data_default[offset]); - if (err_code < 0){ - SWPS_ERR("%s: set default fail! :%d \n", - __func__, err_code); - return ERR_IOEXP_UNEXCPT; - } - } - } - } -update_common_ioexp_init: - /* Check and update info to object */ - err_code = self->update_all(self, 1, "common_ioexp_init"); - if (err_code < 0) { - SWPS_ERR("%s: update_all() fail! :%d \n", - __func__, err_code); - return ERR_IOEXP_UNEXCPT; - } - return 0; -} - - -/* ========== Object functions for Final State Machine ========== - */ -int -_is_channel_ready(struct ioexp_obj_s *self){ - - int chip_id = 0; - int byte_id = 0; - int getval = ERR_IOEXP_UNEXCPT; - int chkval = ERR_IOEXP_UNEXCPT; - char *emsg = "ERR"; - struct ioexp_addr_s *addr_p = NULL; - - for (chip_id=0; chip_id<(self->ioexp_map_p->chip_amount); chip_id++) { - addr_p = &(self->ioexp_map_p->map_addr[chip_id]); - if (!addr_p){ - emsg = "IOEXP config incorrect"; - goto err_is_channel_ready; - } - for (byte_id=0; byte_id<(self->ioexp_map_p->data_width); byte_id++) { - if (addr_p->conf_offset[byte_id] < 0) { - continue; - } - if ((addr_p->conf_default[byte_id]) != 0) { - goto go_is_channel_ready; - } - } - if (chip_id == ((self->ioexp_map_p->chip_amount) - 1)) { - SWPS_DEBUG("%s: no non-zero config", __func__); - break; - } - } - chip_id = 0; - byte_id = 0; - -go_is_channel_ready: - addr_p = &(self->ioexp_map_p->map_addr[chip_id]); - chkval = addr_p->conf_default[byte_id]; - getval = i2c_smbus_read_byte_data(_get_i2c_client(self, chip_id), - addr_p->conf_offset[byte_id]); - - SWPS_DEBUG("%s: target info :%d :%d :%d :%d :%d\n", - __func__, self->ioexp_id, chip_id, byte_id, chkval, getval); - - if ((getval >= 0) && (getval == chkval)) { - return 1; - } - return 0; - -err_is_channel_ready: - SWPS_ERR("%s: %s :%d :%d :%d :%d :%d\n", - __func__, emsg, self->ioexp_id, chip_id, byte_id, chkval, getval); - return ERR_IOEXP_UNEXCPT; -} - - -int -_ioexp_init_handler(struct ioexp_obj_s *self){ - - int return_val; - - switch (self->mode) { - case IOEXP_MODE_DIRECT: - return_val = self->init(self); - if (return_val < 0){ - self->state = STATE_IOEXP_ABNORMAL; - } else { - self->state = STATE_IOEXP_NORMAL; - } - return return_val; - - case IOEXP_MODE_POLLING: - /* Check system and channel is ready */ - if (self->state == STATE_IOEXP_INIT){ - if (!_is_channel_ready(self)){ - self->state = STATE_IOEXP_INIT; - SWPS_WARN("%s: IOEXP:%d channel not ready.\n", - __func__, self->ioexp_id); - return 0; - } - } - /* Execute initial callback */ - return_val = self->init(self); - if (return_val < 0){ - self->state = STATE_IOEXP_ABNORMAL; - } else { - self->state = STATE_IOEXP_NORMAL; - } - return return_val; - - default: - break; - } - SWPS_ERR("%s: exception occur :%d\n", __func__, self->mode); - return ERR_IOEXP_UNEXCPT; -} - - -int -common_ioexp_fsm_4_direct(struct ioexp_obj_s *self){ - - int result_val; - int show_err = 1; - char *func_mane = "common_ioexp_fsm_4_direct"; - - switch (self->state){ - case STATE_IOEXP_INIT: - result_val = _ioexp_init_handler(self); - /* Exception case: terminate initial procedure */ - if(result_val < 0){ - /* Initial fail */ - return result_val; - } - if(self->state == STATE_IOEXP_INIT){ - /* Keep in INIT state, and return error */ - return ERR_IOEXP_UNINIT; - } - /* Case: Initial done */ - return 0; - - case STATE_IOEXP_NORMAL: - result_val = self->update_all(self, show_err, func_mane); - if (result_val < 0){ - SWPS_INFO("%s: NORMAL -> ABNORMAL :%d\n", - __func__, result_val); - self->state = STATE_IOEXP_ABNORMAL; - return result_val; - } - self->state = STATE_IOEXP_NORMAL; - return 0; - - case STATE_IOEXP_ABNORMAL: - result_val = self->update_all(self, show_err, func_mane); - if (result_val < 0){ - self->state = STATE_IOEXP_ABNORMAL; - return result_val; - } - SWPS_DEBUG("%s: ABNORMAL -> NORMAL :%d\n", - __func__, result_val); - self->state = STATE_IOEXP_NORMAL; - return 0; - - default: - break; - } - SWPS_ERR("%s: Exception occurs :%d\n", - __func__, self->state); - return ERR_IOEXP_UNEXCPT; -} - - -int -common_ioexp_fsm_4_polling(struct ioexp_obj_s *self){ - - int result_val, i, show_e; - int fail_retry = 3; - char *func_name = "common_ioexp_fsm_4_polling"; - -#ifdef DEBUG_SWPS - show_e = 1; -#else - show_e = 0; -#endif - - switch (self->state){ - case STATE_IOEXP_INIT: - result_val = _ioexp_init_handler(self); - /* Exception case: terminate initial procedure */ - if(result_val < 0){ - /* Initial fail */ - return result_val; - } - /* Case: System (Channel) not ready */ - if(self->state == STATE_IOEXP_INIT){ - /* Keep in INIT state, wait and retry */ - return 0; - } - /* Case: Initial done */ - SWPS_INFO("IOEXP-%d: initial done. :%d\n", - self->ioexp_id, self->ioexp_type); - return result_val; - - case STATE_IOEXP_NORMAL: - /* Retry mechanism for case of i2c topology not stable */ - for (i=0; iupdate_all(self, show_e, func_name); - if (result_val >= 0) { - self->state = STATE_IOEXP_NORMAL; - return 0; - } - if (check_channel_tier_1() < 0) { - SWPS_INFO("%s: detect I2C crash :%d\n", - __func__, self->ioexp_id); - break; - } - SWPS_DEBUG("IOEXP-%d: unstable :%d\n", - self->ioexp_id, result_val); - } - SWPS_INFO("IOEXP-%d: NORMAL -> ABNORMAL :%d\n", - self->ioexp_id, result_val); - self->state = STATE_IOEXP_ABNORMAL; - return result_val; - - case STATE_IOEXP_ABNORMAL: - result_val = self->update_all(self, show_e, func_name); - if (result_val < 0){ - self->state = STATE_IOEXP_ABNORMAL; - return result_val; - } - SWPS_INFO("IOEXP-%d: ABNORMAL -> NORMAL :%d\n", - self->ioexp_id, result_val); - self->state = STATE_IOEXP_NORMAL; - return 0; - - default: - break; - } - SWPS_ERR("IOEXP-%d: Exception occurs :%d\n", - self->ioexp_id, self->state); - return ERR_IOEXP_UNEXCPT; -} - - -/* ========== Object private functions for check & update ========== - */ -int -common_ioexp_check(struct ioexp_obj_s *self){ - - int result; - - if (self->mode != IOEXP_MODE_POLLING){ - SWPS_ERR("%s: not polling mode :%d\n", - __func__, self->mode); - return ERR_IOEXP_NOTSUPPORT; - } - mutex_lock(&self->lock); - result = self->fsm_4_polling(self); - mutex_unlock(&self->lock); - return result; -} - - -/* ========== Functions for Factory pattern ========== - */ -static struct ioexp_map_s * -get_ioexp_map(int ioexp_type){ - switch (ioexp_type){ - case IOEXP_TYPE_MAGINOLIA_NAB: - return &ioexp_map_magnolia_nab; - case IOEXP_TYPE_MAGINOLIA_4AB: - return &ioexp_map_magnolia_4ab; - case IOEXP_TYPE_MAGINOLIA_7AB: - case IOEXP_TYPE_SPRUCE_7AB: - return &ioexp_map_magnolia_7ab; - case IOEXP_TYPE_REDWOOD_P01P08: - return &ioexp_map_redwood_p01p08_p17p24; - case IOEXP_TYPE_REDWOOD_P09P16: - return &ioexp_map_redwood_p09p16_p25p32; - case IOEXP_TYPE_HUDSON32IGA_P01P08: - return &ioexp_map_hudson32iga_p01p08_p17p24; - case IOEXP_TYPE_HUDSON32IGA_P09P16: - return &ioexp_map_hudson32iga_p09p16_p25p32; - case IOEXP_TYPE_CYPRESS_7ABC: - return &ioexp_map_cypress_7abc; - case IOEXP_TYPE_TAHOE_5A: - return &ioexp_map_tahoe_5a; - case IOEXP_TYPE_TAHOE_6ABC: - return &ioexp_map_tahoe_6abc; - case IOEXP_TYPE_SEQUOIA_NABC: - return &ioexp_map_sequoia_nabc; - case IOEXP_TYPE_LAVENDER_P65: - return &ioexp_map_lavender_p65; - case CPLD_TYPE_COTTONWOOD: - return &cpld_map_cottonwood; - case IOEXP_TYPE_MAPLE_0ABC: - case IOEXP_TYPE_CEDAR_0ABC: - return &ioexp_map_maple_0abc; - case IOEXP_TYPE_MAPLE_NABC: - return &ioexp_map_maple_nabc; - case IOEXP_TYPE_GULMOHAR_NABC: - return &ioexp_map_gulmohar_nabc; - case IOEXP_TYPE_GULMOHAR_7ABC: - return &ioexp_map_gulmohar_7abc; - case IOEXP_TYPE_GULMOHAR_2T_EVT1_NABC: - return &ioexp_map_gulmohar_2t_evt1_nabc; - case IOEXP_TYPE_GULMOHAR_2T_EVT1_1ABC: - return &ioexp_map_gulmohar_2t_evt1_1abc; - case IOEXP_TYPE_GULMOHAR_2T_EVT1_3ABC: - return &ioexp_map_gulmohar_2t_evt1_3abc; - case IOEXP_TYPE_GULMOHAR_2T_EVT1_7ABC: - return &ioexp_map_gulmohar_2t_evt1_7abc; - case IOEXP_TYPE_SFP_8P_LAYOUT_1: - return &ioexp_map_sfp_8p_layout_1; - case IOEXP_TYPE_QSFP_6P_LAYOUT_1: - return &ioexp_map_6p_qsfp_type_1; - default: - return NULL; - } -} - - -int -setup_ioexp_ssize_attr(struct ioexp_obj_s *self, - struct ioexp_map_s *ioexp_map_p, - int ioexp_id, - int ioexp_type, - int run_mode){ - switch (run_mode){ - case IOEXP_MODE_POLLING: /* Direct access device mode */ - case IOEXP_MODE_DIRECT: /* Polling mode, read from cache */ - self->mode = run_mode; - break; - default: - SWPS_ERR("%s: non-defined run_mode:%d\n", - __func__, run_mode); - self->mode = ERR_IOEXP_UNEXCPT; - return ERR_IOEXP_UNEXCPT; - } - /* Setup mapping structure */ - self->ioexp_map_p = kzalloc(sizeof(*ioexp_map_p), GFP_KERNEL); - if (!(self->ioexp_map_p)) { - SWPS_ERR("%s: kzalloc ioexp_map_p fail\n", __func__); - return -1; - } - memcpy(self->ioexp_map_p, ioexp_map_p, sizeof(*ioexp_map_p)); - /* Setup attributes */ - self->ioexp_id = ioexp_id; - self->ioexp_type = ioexp_type; - self->state = STATE_IOEXP_INIT; - mutex_init(&self->lock); - return 0; -} - - -static int -setup_addr_mapping(struct ioexp_obj_s *self, - struct ioexp_addr_s *addr_map_p, - int chip_amount){ - struct ioexp_addr_s *tmp_p; - if (!addr_map_p){ - SWPS_ERR("%s: map is null\n", __func__); - return -1; - } - tmp_p = kzalloc((sizeof(*addr_map_p) * chip_amount), GFP_KERNEL); - if (!tmp_p){ - SWPS_ERR("%s: kzalloc fail.\n", __func__); - return -1; - } - memcpy(tmp_p, addr_map_p, (sizeof(*addr_map_p) * chip_amount)); - self->ioexp_map_p->map_addr = tmp_p; - - return 0; -} - - -static int -setup_ioexp_public_cb(struct ioexp_obj_s *self, - int ioexp_type){ - - switch (ioexp_type){ - case IOEXP_TYPE_MAGINOLIA_NAB: - case IOEXP_TYPE_MAGINOLIA_4AB: - case CPLD_TYPE_COTTONWOOD: - self->get_present = common_get_present; - self->get_tx_fault = common_get_tx_fault; - self->get_rxlos = common_get_rxlos; - self->get_tx_disable = common_get_tx_disable; - self->get_reset = ioexp_get_not_support; - self->get_lpmod = ioexp_get_not_support; - self->get_modsel = ioexp_get_not_support; - self->get_hard_rs0 = ioexp_get_not_support; - self->get_hard_rs1 = ioexp_get_not_support; - self->set_tx_disable = common_set_tx_disable; - self->set_reset = ioexp_set_not_support; - self->set_lpmod = ioexp_set_not_support; - self->set_modsel = ioexp_set_not_support; - self->set_hard_rs0 = ioexp_set_not_support; - self->set_hard_rs1 = ioexp_set_not_support; - return 0; - - case IOEXP_TYPE_MAPLE_NABC: - case IOEXP_TYPE_GULMOHAR_NABC: - case IOEXP_TYPE_GULMOHAR_2T_EVT1_NABC: - case IOEXP_TYPE_GULMOHAR_2T_EVT1_1ABC: - case IOEXP_TYPE_GULMOHAR_2T_EVT1_3ABC: - case IOEXP_TYPE_SFP_8P_LAYOUT_1: - self->get_present = common_get_present; - self->get_tx_fault = common_get_tx_fault; - self->get_rxlos = common_get_rxlos; - self->get_tx_disable = common_get_tx_disable; - self->get_reset = ioexp_get_not_support; - self->get_lpmod = ioexp_get_not_support; - self->get_modsel = ioexp_get_not_support; - self->get_hard_rs0 = common_get_hard_rs0; - self->get_hard_rs1 = common_get_hard_rs1; - self->set_tx_disable = common_set_tx_disable; - self->set_reset = ioexp_set_not_support; - self->set_lpmod = ioexp_set_not_support; - self->set_modsel = ioexp_set_not_support; - self->set_hard_rs0 = common_set_hard_rs0; - self->set_hard_rs1 = common_set_hard_rs1; - return 0; - - case IOEXP_TYPE_MAGINOLIA_7AB: - case IOEXP_TYPE_SPRUCE_7AB: - case IOEXP_TYPE_REDWOOD_P01P08: - case IOEXP_TYPE_REDWOOD_P09P16: - case IOEXP_TYPE_HUDSON32IGA_P01P08: - case IOEXP_TYPE_HUDSON32IGA_P09P16: - case IOEXP_TYPE_CYPRESS_7ABC: - case IOEXP_TYPE_TAHOE_5A: - case IOEXP_TYPE_TAHOE_6ABC: - case IOEXP_TYPE_SEQUOIA_NABC: - case IOEXP_TYPE_LAVENDER_P65: - case IOEXP_TYPE_MAPLE_0ABC: - case IOEXP_TYPE_GULMOHAR_7ABC: - case IOEXP_TYPE_GULMOHAR_2T_EVT1_7ABC: - case IOEXP_TYPE_QSFP_6P_LAYOUT_1: - case IOEXP_TYPE_CEDAR_0ABC: - self->get_present = common_get_present; - self->get_tx_fault = ioexp_get_not_support; - self->get_rxlos = ioexp_get_not_support; - self->get_tx_disable = ioexp_get_not_support; - self->get_reset = common_get_reset; - self->get_lpmod = common_get_lpmod; - self->get_modsel = common_get_modsel; - self->get_hard_rs0 = ioexp_get_not_support; - self->get_hard_rs1 = ioexp_get_not_support; - self->set_tx_disable = ioexp_set_not_support; - self->set_reset = common_set_reset; - self->set_lpmod = common_set_lpmod; - self->set_modsel = common_set_modsel; - self->set_hard_rs0 = ioexp_set_not_support; - self->set_hard_rs1 = ioexp_set_not_support; - return 0; - - default: - SWPS_ERR("%s: type:%d incorrect!\n", __func__, ioexp_type); - break; - } - return ERR_IOEXP_UNEXCPT; -} - - -static int -setup_ioexp_private_cb(struct ioexp_obj_s *self, - int ioexp_type){ - - switch (ioexp_type){ - case IOEXP_TYPE_MAGINOLIA_NAB: - case IOEXP_TYPE_MAGINOLIA_4AB: - case IOEXP_TYPE_MAGINOLIA_7AB: - case IOEXP_TYPE_SPRUCE_7AB: - case IOEXP_TYPE_REDWOOD_P01P08: - case IOEXP_TYPE_REDWOOD_P09P16: - case IOEXP_TYPE_HUDSON32IGA_P01P08: - case IOEXP_TYPE_HUDSON32IGA_P09P16: - case IOEXP_TYPE_CYPRESS_7ABC: - case IOEXP_TYPE_TAHOE_5A: - case IOEXP_TYPE_TAHOE_6ABC: - case IOEXP_TYPE_SEQUOIA_NABC: - case IOEXP_TYPE_LAVENDER_P65: - case CPLD_TYPE_COTTONWOOD: - case IOEXP_TYPE_MAPLE_NABC: - case IOEXP_TYPE_MAPLE_0ABC: - case IOEXP_TYPE_GULMOHAR_NABC: - case IOEXP_TYPE_GULMOHAR_7ABC: - case IOEXP_TYPE_GULMOHAR_2T_EVT1_NABC: - case IOEXP_TYPE_GULMOHAR_2T_EVT1_1ABC: - case IOEXP_TYPE_GULMOHAR_2T_EVT1_3ABC: - case IOEXP_TYPE_GULMOHAR_2T_EVT1_7ABC: - case IOEXP_TYPE_SFP_8P_LAYOUT_1: - case IOEXP_TYPE_QSFP_6P_LAYOUT_1: - case IOEXP_TYPE_CEDAR_0ABC: - self->init = common_ioexp_init; - self->check = common_ioexp_check; - self->update_all = common_ioexp_update_all; - self->fsm_4_direct = common_ioexp_fsm_4_direct; - self->fsm_4_polling = common_ioexp_fsm_4_polling; - return 0; - - default: - SWPS_ERR("%s: type:%d incorrect!\n", __func__, ioexp_type); - break; - } - return ERR_IOEXP_UNEXCPT; -} - - -static int -setup_i2c_client_one(struct ioexp_obj_s *self, - int chip_id){ - - char *err_msg = "ERROR"; - struct i2c_adapter *adap = NULL; - struct i2c_client *client = NULL; - struct ioexp_i2c_s *i2c_obj_p = NULL; - struct ioexp_i2c_s *i2c_curr_p = NULL; - - int chan_id = self->ioexp_map_p->map_addr[chip_id].chan_id; - client = kzalloc(sizeof(*client), GFP_KERNEL); - if (!client){ - err_msg = "Can not kzalloc client!"; - goto err_ioexp_setup_i2c_1; - } - i2c_obj_p = kzalloc(sizeof(*i2c_obj_p), GFP_KERNEL); - if (!i2c_obj_p){ - err_msg = "Can not kzalloc i2c_obj_p!"; - goto err_ioexp_setup_i2c_2; - } - adap = i2c_get_adapter(chan_id); - if(!adap){ - err_msg = "Can not get adap!"; - goto err_ioexp_setup_i2c_3; - } - client->adapter = adap; - client->addr = self->ioexp_map_p->map_addr[chip_id].chip_addr; - i2c_obj_p->i2c_client_p = client; - i2c_obj_p->chip_id = chip_id; - i2c_obj_p->next = NULL; - if (!self->i2c_head_p){ - self->i2c_head_p = i2c_obj_p; - } else { - i2c_curr_p = self->i2c_head_p; - while (i2c_curr_p->next){ - i2c_curr_p = i2c_curr_p->next; - } - i2c_curr_p->next = i2c_obj_p; - } - return 0; - -err_ioexp_setup_i2c_3: - kfree(i2c_obj_p); -err_ioexp_setup_i2c_2: - kfree(client); -err_ioexp_setup_i2c_1: - SWPS_ERR("%s: %s :%d\n", __func__, err_msg, chan_id); - return -1; -} - - -static int -setup_i2c_client(struct ioexp_obj_s* self){ - - int result; - int chip_id = 0; - - for (chip_id=0; chip_id<(self->ioexp_map_p->chip_amount); chip_id++){ - result = setup_i2c_client_one(self, chip_id); - if (result < 0){ - SWPS_ERR("%s fail! :%d\n", __func__, chip_id); - return -1; - } - } - return 0; -} - - -static int -setup_ioexp_config(struct ioexp_obj_s *self) { - - int chip_id, offset, err_code; - struct ioexp_addr_s *addr_p; - if (io_no_init) { - - SWPS_INFO("io_no_init:%d \n", io_no_init); - return 0; - } - - for (chip_id=0; chip_id<(self->ioexp_map_p->chip_amount); chip_id++){ - addr_p = &(self->ioexp_map_p->map_addr[chip_id]); - if (!addr_p){ - SWPS_ERR("IOEXP config incorrect! :%d \n",chip_id); - return -1; - } - for (offset=0; offset<(self->ioexp_map_p->data_width); offset++){ - - /* [Desc] Skip the setup config value behavior - [Note] Setup config value = -1 if you don't want to write the value to IOEXP or CPLD - */ - if(addr_p->conf_offset[offset] < 0){ - SWPS_DEBUG("skip a config_offset <%d>\n", addr_p->conf_offset[offset]); - continue; - } - err_code = i2c_smbus_write_byte_data(_get_i2c_client(self, chip_id), - addr_p->conf_offset[offset], - addr_p->conf_default[offset]); - - if (err_code < 0){ - SWPS_INFO("%s: set conf fail! :%d \n", __func__, err_code); - return -2; - } - } - } - return 0; -} - - -struct ioexp_obj_s * -_create_ioexp_obj(int ioexp_id, - int ioexp_type, - struct ioexp_addr_s *addr_map_p, - int run_mode){ - - struct ioexp_map_s* ioexp_map_p; - struct ioexp_obj_s* result_p; - struct ioexp_i2c_s *i2c_curr_p; - struct ioexp_i2c_s *i2c_next_p; - - /* Get layout */ - ioexp_map_p = get_ioexp_map(ioexp_type); - if (!ioexp_map_p){ - SWPS_ERR("%s: Invalid ioexp_type\n", __func__); - goto err_create_ioexp_fail; - } - /* Prepare IOEXP object */ - result_p = kzalloc(sizeof(*result_p), GFP_KERNEL); - if (!result_p){ - SWPS_ERR("%s: kzalloc failure!\n", __func__); - goto err_create_ioexp_fail; - } - /* Prepare static size attributes */ - if (setup_ioexp_ssize_attr(result_p, - ioexp_map_p, - ioexp_id, - ioexp_type, - run_mode) < 0){ - goto err_create_ioexp_setup_attr_fail; - } - /* Prepare address mapping */ - if (setup_addr_mapping(result_p, addr_map_p, ioexp_map_p->chip_amount) < 0){ - goto err_create_ioexp_setup_attr_fail; - } - if (setup_i2c_client(result_p) < 0){ - goto err_create_ioexp_setup_i2c_fail; - } - /* Prepare call back functions of object */ - if (setup_ioexp_public_cb(result_p, ioexp_type) < 0){ - goto err_create_ioexp_setup_i2c_fail; - } - if (setup_ioexp_private_cb(result_p, ioexp_type) < 0){ - goto err_create_ioexp_setup_i2c_fail; - } - return result_p; - -err_create_ioexp_setup_i2c_fail: - i2c_curr_p = result_p->i2c_head_p; - i2c_next_p = result_p->i2c_head_p; - while (i2c_curr_p){ - i2c_next_p = i2c_curr_p->next; - if (i2c_curr_p->i2c_client_p) { - i2c_put_adapter(i2c_curr_p->i2c_client_p->adapter); - kfree(i2c_curr_p->i2c_client_p); - } - kfree(i2c_curr_p); - i2c_curr_p = i2c_next_p; - } -err_create_ioexp_setup_attr_fail: - kfree(result_p); -err_create_ioexp_fail: - SWPS_ERR("%s: fail! :%d :%d \n", - __func__, ioexp_id, ioexp_type); - return NULL; -} - - -int -create_ioexp_obj(int ioexp_id, - int ioexp_type, - struct ioexp_addr_s *addr_map_p, - int run_mode){ - - struct ioexp_obj_s *ioexp_p = NULL; - - ioexp_p = _create_ioexp_obj(ioexp_id, ioexp_type, - addr_map_p, run_mode); - if (!ioexp_p){ - return -1; - } - if (ioexp_head_p == NULL){ - ioexp_head_p = ioexp_p; - ioexp_tail_p = ioexp_p; - return 0; - } - ioexp_tail_p->next = ioexp_p; - ioexp_tail_p = ioexp_p; - return 0; -} -EXPORT_SYMBOL(create_ioexp_obj); - - -static int -_init_ioexp_obj(struct ioexp_obj_s* self) { - - char *err_msg = "ERR"; - char *func_name = "_init_ioexp_obj"; - - /* Setup IOEXP configure byte */ - if (setup_ioexp_config(self) < 0){ - err_msg = "setup_ioexp_config fail"; - goto err_init_ioexp_obj; - } - /* Setup default data */ - if (_ioexp_init_handler(self) < 0){ - err_msg = "_ioexp_init_handler fail"; - goto err_init_ioexp_obj; - } - /* Update all */ - if (self->state == STATE_IOEXP_NORMAL){ - if (self->update_all(self, 1, func_name) < 0){ - err_msg = "update_all() fail"; - goto err_init_ioexp_obj; - } - } - return 0; - -err_init_ioexp_obj: - SWPS_DEBUG("%s: %s\n", __func__, err_msg); - return -1; -} - - -int -init_ioexp_objs(void){ - /* Return value: - * 0: Success - * -1: Detect topology error - * -2: SWPS internal error - */ - struct ioexp_obj_s *curr_p = ioexp_head_p; - - if (!curr_p) { - SWPS_ERR("%s: ioexp_head_p is NULL\n", __func__); - return -2; - } - while (curr_p) { - if (_init_ioexp_obj(curr_p) < 0) { - SWPS_DEBUG("%s: _init_ioexp_obj() fail\n", __func__); - return -1; - } - curr_p = curr_p->next; - } - SWPS_DEBUG("%s: done.\n", __func__); - return 0; -} -EXPORT_SYMBOL(init_ioexp_objs); - - -void -clean_ioexp_objs(void){ - - struct ioexp_i2c_s *i2c_curr_p = NULL; - struct ioexp_i2c_s *i2c_next_p = NULL; - struct ioexp_obj_s *ioexp_next_p = NULL; - struct ioexp_obj_s *ioexp_curr_p = ioexp_head_p; - - if (ioexp_head_p == NULL){ - ioexp_tail_p = NULL; - return; - } - while(ioexp_curr_p){ - ioexp_next_p = ioexp_curr_p->next; - if (ioexp_curr_p->ioexp_map_p) { - if (ioexp_curr_p->ioexp_map_p->map_addr) { - kfree(ioexp_curr_p->ioexp_map_p->map_addr); - } - kfree(ioexp_curr_p->ioexp_map_p); - } - - i2c_curr_p = ioexp_curr_p->i2c_head_p; - while (i2c_curr_p) { - i2c_next_p = i2c_curr_p->next; - if (i2c_curr_p->i2c_client_p) { - i2c_put_adapter(i2c_curr_p->i2c_client_p->adapter); - kfree(i2c_curr_p->i2c_client_p); - } - kfree(i2c_curr_p); - i2c_curr_p = i2c_next_p; - } - kfree(ioexp_curr_p); - ioexp_curr_p = ioexp_next_p; - } - ioexp_tail_p = NULL; - SWPS_DEBUG("%s: done.\n", __func__); -} -EXPORT_SYMBOL(clean_ioexp_objs); - - -int -check_ioexp_objs(void){ - - struct ioexp_obj_s *ioexp_curr_p = ioexp_head_p; - - while (ioexp_curr_p){ - if ( (ioexp_curr_p->check(ioexp_curr_p)) < 0){ - SWPS_INFO("check IOEXP-%d fail! :%d\n", - ioexp_curr_p->ioexp_id, ioexp_curr_p->ioexp_type); - return -1; - } - ioexp_curr_p = ioexp_curr_p->next; - } - return 0; -} -EXPORT_SYMBOL(check_ioexp_objs); - - -struct ioexp_obj_s * -get_ioexp_obj(int ioexp_id){ - - struct ioexp_obj_s *result_p = NULL; - struct ioexp_obj_s *ioexp_curr_p = ioexp_head_p; - - while(ioexp_curr_p){ - if (ioexp_curr_p->ioexp_id == ioexp_id){ - result_p = ioexp_curr_p; - break; - } - ioexp_curr_p = ioexp_curr_p->next; - } - return result_p; -} -EXPORT_SYMBOL(get_ioexp_obj); - - -void -unlock_ioexp_all(void) { - - struct ioexp_obj_s *ioexp_curr_p = ioexp_head_p; - - while(ioexp_curr_p){ - mutex_unlock(&ioexp_curr_p->lock); - ioexp_curr_p = ioexp_curr_p->next; - } -} -EXPORT_SYMBOL(unlock_ioexp_all); - -int -lock_ioexp_all(void) { - - struct ioexp_obj_s *ioexp_curr_p = ioexp_head_p; - - while(ioexp_curr_p){ - mutex_lock(&ioexp_curr_p->lock); - ioexp_curr_p = ioexp_curr_p->next; - } - return 0; -} -EXPORT_SYMBOL(lock_ioexp_all); - - -int -check_channel_tier_1(void) { - - if ( (!_is_channel_ready(ioexp_head_p)) && - (!_is_channel_ready(ioexp_tail_p)) ){ - return -1; - } - return 0; -} -EXPORT_SYMBOL(check_channel_tier_1); - - -static int -_scan_channel_tier_1(int force, - int show_err) { - - struct ioexp_obj_s *ioexp_curr_p = ioexp_head_p; - int ready = 0; - - if (!ioexp_curr_p) { - goto err_scan_tier_1_channel; - } - while(ioexp_curr_p) { - ready = _is_channel_ready(ioexp_curr_p); - if ((!ready) && (!force)) { - goto err_scan_tier_1_channel; - } - ioexp_curr_p = ioexp_curr_p->next; - } - return 0; - -err_scan_tier_1_channel: - if (show_err) { - if (ioexp_curr_p) { - SWPS_INFO("%s: IOEXP-%d fail\n", __func__, ioexp_curr_p->ioexp_id); - } else { - SWPS_INFO("%s: IOEXP is null.\n", __func__); - } - } - return -1; -} - - -static int -_scan_channel_tier_1_single(void) { - - int ret = 0; - int chan_id = 0; - int fake_cid = 0; - int fake_offs = 0; - int fake_addr = 0; - struct i2c_adapter *adap = NULL; - struct i2c_client *client = NULL; - - if (ioexp_head_p->ioexp_id != ioexp_tail_p->ioexp_id) { - return 0; - } - /* Setup i2c_client */ - chan_id = ioexp_head_p->ioexp_map_p->map_addr[fake_cid].chan_id; - fake_addr = ioexp_head_p->ioexp_map_p->map_addr[fake_cid].chip_addr; - adap = i2c_get_adapter((chan_id + 1)); - if(!adap){ - SWPS_INFO("%s: Can not get adap!\n", __func__); - return 0; - } - client = kzalloc(sizeof(*client), GFP_KERNEL); - if (!client){ - SWPS_INFO("%s: Can not kzalloc client!\n", __func__); - return 0; - } - client->adapter = adap; - client->addr = fake_addr; - /* Fouce move ioexp ptr to next */ - ret = i2c_smbus_read_byte_data(client, fake_offs); - SWPS_DEBUG("%s: move ioexp_ptr done. :%d\n", __func__, ret); - kfree(client); - return 1; -} - - -int -resync_channel_tier_1(void) { - - char *emsg = "ERR"; - - if (!ioexp_head_p) { - emsg = "ioexp_head_p is NULL"; - goto err_resync_ioexp_status_1; - } - /* Run all */ - if (ioexp_head_p->ioexp_id == ioexp_tail_p->ioexp_id) { - _scan_channel_tier_1_single(); - } else { - _scan_channel_tier_1(1, 0); - } - /* Check all */ - if (_scan_channel_tier_1(0, 1) < 0) { - emsg = "resync tier-1 channel fail"; - goto err_resync_ioexp_status_1; - } - return 0; - -err_resync_ioexp_status_1: - SWPS_ERR("%s: %s\n", __func__, emsg); - return -1; -} -EXPORT_SYMBOL(resync_channel_tier_1); - - -/* For build single module using (Ex: ONL platform) */ -MODULE_LICENSE("GPL"); - - - diff --git a/packages/platforms/inventec/x86-64/d5264q28b/modules/builds/src/io_expander.h b/packages/platforms/inventec/x86-64/d5264q28b/modules/builds/src/io_expander.h deleted file mode 100644 index 43a8c290f..000000000 --- a/packages/platforms/inventec/x86-64/d5264q28b/modules/builds/src/io_expander.h +++ /dev/null @@ -1,189 +0,0 @@ -#ifndef IO_EXPANDER_H -#define IO_EXPANDER_H - -#include - - -/* IOEXP type define (SFP series) */ -#define IOEXP_TYPE_MAGINOLIA_NAB (10101) -#define IOEXP_TYPE_MAGINOLIA_4AB (10102) -#define IOEXP_TYPE_MAPLE_NABC (10104) -#define IOEXP_TYPE_GULMOHAR_NABC (10105) -#define IOEXP_TYPE_GULMOHAR_2T_EVT1_NABC (10106) -#define IOEXP_TYPE_SFP_8P_LAYOUT_1 (10107) -#define IOEXP_TYPE_GULMOHAR_2T_EVT1_1ABC (10108) -#define IOEXP_TYPE_GULMOHAR_2T_EVT1_3ABC (10109) - -/* IOEXP type define (QSFP series) */ -#define IOEXP_TYPE_MAGINOLIA_7AB (10201) -#define IOEXP_TYPE_REDWOOD_P01P08 (10202) -#define IOEXP_TYPE_REDWOOD_P09P16 (10203) -#define IOEXP_TYPE_HUDSON32IGA_P01P08 (10204) -#define IOEXP_TYPE_HUDSON32IGA_P09P16 (10205) -#define IOEXP_TYPE_SPRUCE_7AB (10206) -#define IOEXP_TYPE_CYPRESS_7ABC (10207) -#define IOEXP_TYPE_TAHOE_5A (10208) -#define IOEXP_TYPE_TAHOE_6ABC (10209) -#define IOEXP_TYPE_SEQUOIA_NABC (10210) -#define IOEXP_TYPE_LAVENDER_P65 (10211) -#define IOEXP_TYPE_MAPLE_0ABC (10212) -#define IOEXP_TYPE_GULMOHAR_7ABC (10213) -#define IOEXP_TYPE_GULMOHAR_2T_EVT1_7ABC (10214) -#define IOEXP_TYPE_QSFP_6P_LAYOUT_1 (10215) -#define IOEXP_TYPE_CEDAR_0ABC (10216) - -/* CPLD type define */ -#define CPLD_TYPE_COTTONWOOD (10301) - -/* IOEXP mode define */ -#define IOEXP_MODE_POLLING (19000) -#define IOEXP_MODE_DIRECT (19001) - -/* IOEXP state define */ -#define STATE_IOEXP_NORMAL (0) -#define STATE_IOEXP_INIT (-1) -#define STATE_IOEXP_ABNORMAL (-2) - -/* IOEXP error code define */ -#define ERR_IOEXP_NOTSUPPORT (-100) -#define ERR_IOEXP_UNINIT (-101) -#define ERR_IOEXP_BADCONF (-102) -#define ERR_IOEXP_ABNORMAL (-103) -#define ERR_IOEXP_NOSTATE (-104) -#define ERR_IOEXP_BADINPUT (-105) -#define ERR_IOEXP_UNEXCPT (-199) - -#define SWPS_INFO(fmt, args...) printk( KERN_INFO "[SWPS] " fmt, ##args) -#define SWPS_WARN(fmt, args...) printk( KERN_WARNING "[SWPS] " fmt, ##args) -#define SWPS_ERR(fmt, args...) printk( KERN_ERR "[SWPS] " fmt, ##args) - -#ifdef DEBUG_SWPS -# define SWPS_DEBUG(fmt, args...) printk( KERN_DEBUG "[SWPS] " fmt, ##args) -#else -# define SWPS_DEBUG(fmt, args...) -#endif - -struct ioexp_addr_s { - int chan_id; - int chip_addr; - int read_offset[8]; - int write_offset[8]; - int conf_offset[8]; - uint8_t data_default[8]; - uint8_t conf_default[8]; -}; - -struct ioexp_i2c_s { - int chip_id; - struct i2c_client *i2c_client_p; - struct ioexp_i2c_s *next; -}; - - -struct ioexp_bitmap_s { - int chip_id; /* IOEXP chip id */ - int ioexp_voffset; /* IOEXP virtual offset */ - int bit_shift; -}; - -struct ioexp_map_s { - int chip_amount; /* Number of chips that IOEXP object content */ - int data_width; /* Number of (Read/Write/Config) bytes */ - struct ioexp_addr_s *map_addr; /* Chip address info */ - struct ioexp_bitmap_s map_present[10]; /* IOEXP for SFP / QSFP */ - struct ioexp_bitmap_s map_tx_disable[10]; /* IOEXP for SFP */ - struct ioexp_bitmap_s map_tx_fault[10]; /* IOEXP for SFP */ - struct ioexp_bitmap_s map_rxlos[10]; /* IOEXP for SFP */ - struct ioexp_bitmap_s map_reset[10]; /* IOEXP for QSFP */ - struct ioexp_bitmap_s map_lpmod[10]; /* IOEXP for QSFP */ - struct ioexp_bitmap_s map_modsel[10]; /* IOEXP for QSFP */ - struct ioexp_bitmap_s map_hard_rs0[10]; /* IOEXP for QSFP */ - struct ioexp_bitmap_s map_hard_rs1[10]; /* IOEXP for QSFP */ -}; - -struct ioexp_data_s { - uint8_t data[8]; -}; - -struct ioexp_obj_s { - - /* ============================ - * Object public property - * ============================ - */ - int ioexp_id; - int ioexp_type; - - /* ============================ - * Object private property - * ============================ - */ - struct ioexp_data_s chip_data[16]; /* Max: 8-ioexp in one virt-ioexp(ioexp_obj) */ - struct ioexp_map_s *ioexp_map_p; - struct ioexp_obj_s *next; - struct ioexp_i2c_s *i2c_head_p; - struct mutex lock; - int mode; - int state; - - /* =========================================== - * Object public functions - * =========================================== - */ - int (*get_present)(struct ioexp_obj_s *self, int virt_offset); - int (*get_tx_fault)(struct ioexp_obj_s *self, int virt_offset); - int (*get_rxlos)(struct ioexp_obj_s *self, int virt_offset); - int (*get_tx_disable)(struct ioexp_obj_s *self, int virt_offset); - int (*get_reset)(struct ioexp_obj_s *self, int virt_offset); - int (*get_lpmod)(struct ioexp_obj_s *self, int virt_offset); - int (*get_modsel)(struct ioexp_obj_s *self, int virt_offset); - int (*get_hard_rs0)(struct ioexp_obj_s *self, int virt_offset); - int (*get_hard_rs1)(struct ioexp_obj_s *self, int virt_offset); - int (*set_tx_disable)(struct ioexp_obj_s *self, int virt_offset, int input_val); - int (*set_reset)(struct ioexp_obj_s *self, int virt_offset, int input_val); - int (*set_lpmod)(struct ioexp_obj_s *self, int virt_offset, int input_val); - int (*set_modsel)(struct ioexp_obj_s *self, int virt_offset, int input_val); - int (*set_hard_rs0)(struct ioexp_obj_s *self, int virt_offset, int input_val); - int (*set_hard_rs1)(struct ioexp_obj_s *self, int virt_offset, int input_val); - - /* =========================================== - * Object private functions - * =========================================== - */ - int (*init)(struct ioexp_obj_s *self); - int (*check)(struct ioexp_obj_s *self); - int (*update_all)(struct ioexp_obj_s *self, int show_err, char *caller_name); - int (*fsm_4_direct)(struct ioexp_obj_s* self); - int (*fsm_4_polling)(struct ioexp_obj_s* self); -}; - - -struct ioexp_obj_s* get_ioexp_obj(int ioexp_id); -int create_ioexp_obj(int ioexp_id, - int ioexp_type, - struct ioexp_addr_s *addr_map_p, - int run_mode); -int init_ioexp_objs(void); -int check_ioexp_objs(void); -void clean_ioexp_objs(void); - -void unlock_ioexp_all(void); -int lock_ioexp_all(void); - -int check_channel_tier_1(void); -int resync_channel_tier_1(void); - -/* Macro for bit control */ -#define SWP_BIT_SET(byte_val,bit_shift) ((byte_val) |= (1<<(bit_shift))) -#define SWP_BIT_CLEAR(byte_val,bit_shift) ((byte_val) &= ~(1<<(bit_shift))) - - -#endif /* IO_EXPANDER_H */ - - - - - - - - diff --git a/packages/platforms/inventec/x86-64/d5264q28b/modules/builds/src/transceiver.c b/packages/platforms/inventec/x86-64/d5264q28b/modules/builds/src/transceiver.c deleted file mode 100644 index 251ada569..000000000 --- a/packages/platforms/inventec/x86-64/d5264q28b/modules/builds/src/transceiver.c +++ /dev/null @@ -1,8409 +0,0 @@ -#include -#include -#include -#include -#include "io_expander.h" -#include "transceiver.h" - -/* For build single module using (Ex: ONL platform) */ -#include -//#include -//#include - -extern int io_no_init; -/* ========== Register EEPROM address mapping ========== - */ -struct eeprom_map_s eeprom_map_sfp = { - .addr_br =0x50, .page_br =-1, .offset_br =12, .length_br =1, - .addr_cdr =-1, .page_cdr =-1, .offset_cdr =-1, .length_cdr =-1, - .addr_comp_rev =0x50, .page_comp_rev =-1, .offset_comp_rev =94, .length_comp_rev =1, - .addr_connector =0x50, .page_connector =-1, .offset_connector =2, .length_connector =1, - .addr_diag_type =0x50, .page_diag_type =-1, .offset_diag_type =92 , .length_diag_type =1, - .addr_extbr =-1, .page_extbr =-1, .offset_extbr =-1, .length_extbr =-1, - .addr_ext_id =0x50, .page_ext_id =-1, .offset_ext_id =1, .length_ext_id =1, - .addr_id =0x50, .page_id =-1, .offset_id =0, .length_id =1, - .addr_len_sm =0x50, .page_len_sm =-1, .offset_len_sm =15, .length_len_sm =1, - .addr_len_smf =0x50, .page_len_smf =-1, .offset_len_smf =14, .length_len_smf =1, - .addr_len_om1 =0x50, .page_len_om1 =-1, .offset_len_om1 =17, .length_len_om1 =1, - .addr_len_om2 =0x50, .page_len_om2 =-1, .offset_len_om2 =16, .length_len_om2 =1, - .addr_len_om3 =0x50, .page_len_om3 =-1, .offset_len_om3 =19, .length_len_om3 =1, - .addr_len_om4 =0x50, .page_len_om4 =-1, .offset_len_om4 =18, .length_len_om4 =1, - .addr_option =0x50, .page_option =-1, .offset_option =64, .length_option =2, - .addr_rate_id =0x50, .page_rate_id =-1, .offset_rate_id =13, .length_rate_id =1, - .addr_rx_am =-1, .page_rx_am =-1, .offset_rx_am =-1, .length_rx_am =-1, - .addr_rx_em =0x51, .page_rx_em =-1, .offset_rx_em =115, .length_rx_em =1, - .addr_rx_los =-1, .page_rx_los =-1, .offset_rx_los =-1, .length_rx_los =-1, - .addr_rx_power =0x51, .page_rx_power =-1, .offset_rx_power =104, .length_rx_power =2, - .addr_soft_rs0 =0x51, .page_soft_rs0 =-1, .offset_soft_rs0 =110, .length_soft_rs0 =1, - .addr_soft_rs1 =0x51, .page_soft_rs1 =-1, .offset_soft_rs1 =118, .length_soft_rs0 =1, - .addr_temp =0x51, .page_temp =-1, .offset_temp =96, .length_temp =2, - .addr_trancomp =0x50, .page_trancomp =-1, .offset_trancomp =3, .length_trancomp =8, - .addr_trancomp_ext =0x50, .page_trancomp_ext =-1, .offset_trancomp_ext =36, .length_trancomp_ext =1, - .addr_tx_bias =0x51, .page_tx_bias =-1, .offset_tx_bias =100, .length_tx_bias =2, - .addr_tx_disable =-1, .page_tx_disable =-1, .offset_tx_disable =-1, .length_tx_disable =-1, - .addr_tx_eq =0x51, .page_tx_eq =-1, .offset_tx_eq =114, .length_tx_eq =1, - .addr_tx_fault =-1, .page_tx_fault =-1, .offset_tx_fault =-1, .length_tx_fault =-1, - .addr_tx_power =0x51, .page_tx_power =-1, .offset_tx_power =102, .length_tx_power =2, - .addr_vendor_name =0x50, .page_vendor_name =-1, .offset_vendor_name =20, .length_vendor_name =16, - .addr_vendor_pn =0x50, .page_vendor_pn =-1, .offset_vendor_pn =40, .length_vendor_pn =16, - .addr_vendor_rev =0x50, .page_vendor_rev =-1, .offset_vendor_rev =56, .length_vendor_rev =4, - .addr_vendor_sn =0x50, .page_vendor_sn =-1, .offset_vendor_sn =68, .length_vendor_sn =16, - .addr_voltage =0x51, .page_voltage =-1, .offset_voltage =98, .length_voltage =2, - .addr_wavelength =0x50, .page_wavelength =-1, .offset_wavelength =60, .length_wavelength =2, -}; - -struct eeprom_map_s eeprom_map_qsfp = { - .addr_br =0x50, .page_br =0, .offset_br =140, .length_br =1, - .addr_cdr =-1, .page_cdr =-1, .offset_cdr =-1, .length_cdr =-1, - .addr_comp_rev =0x50, .page_comp_rev =-1, .offset_comp_rev =1, .length_comp_rev =1, - .addr_connector =0x50, .page_connector =0, .offset_connector =130, .length_connector =1, - .addr_diag_type =0x50, .page_diag_type =0, .offset_diag_type =220, .length_diag_type =1, - .addr_extbr =0x50, .page_extbr =0, .offset_extbr =222, .length_extbr =1, - .addr_ext_id =0x50, .page_ext_id =0, .offset_ext_id =129, .length_ext_id =1, - .addr_id =0x50, .page_id =0, .offset_id =128, .length_id =1, - .addr_len_sm =-1, .page_len_sm =-1, .offset_len_sm =-1, .length_len_sm =-1, - .addr_len_smf =0x50, .page_len_smf =0, .offset_len_smf =142, .length_len_smf =1, - .addr_len_om1 =0x50, .page_len_om1 =0, .offset_len_om1 =145, .length_len_om1 =1, - .addr_len_om2 =0x50, .page_len_om2 =0, .offset_len_om2 =144, .length_len_om2 =1, - .addr_len_om3 =0x50, .page_len_om3 =0, .offset_len_om3 =143, .length_len_om3 =1, - .addr_len_om4 =0x50, .page_len_om4 =0, .offset_len_om4 =146, .length_len_om4 =1, - .addr_option =0x50, .page_option =0, .offset_option =193, .length_option =3, - .addr_rate_id =-1, .page_rate_id =-1, .offset_rate_id =-1, .length_rate_id =-1, - .addr_rx_am =-1, .page_rx_am =-1, .offset_rx_am =-1, .length_rx_am =-1, - .addr_rx_em =-1, .page_rx_em =-1, .offset_rx_em =-1, .length_rx_em =-1, - .addr_rx_los =0x50, .page_rx_los =-1, .offset_rx_los =3, .length_rx_los =1, - .addr_rx_power =0x50, .page_rx_power =-1, .offset_rx_power =34, .length_rx_power =8, - .addr_soft_rs0 =-1, .page_soft_rs0 =-1, .offset_soft_rs0 =-1, .length_soft_rs0 =-1, - .addr_soft_rs1 =-1, .page_soft_rs1 =-1, .offset_soft_rs1 =-1, .length_soft_rs0 =-1, - .addr_temp =0x50, .page_temp =-1, .offset_temp =22, .length_temp =2, - .addr_trancomp =0x50, .page_trancomp =0, .offset_trancomp =131, .length_trancomp =8, - .addr_trancomp_ext =0x50, .page_trancomp_ext =0, .offset_trancomp_ext =192, .length_trancomp_ext =1, - .addr_tx_bias =0x50, .page_tx_bias =-1, .offset_tx_bias =42, .length_tx_bias =8, - .addr_tx_disable =0x50, .page_tx_disable =-1, .offset_tx_disable =86, .length_tx_disable =1, - .addr_tx_eq =-1, .page_tx_eq =-1, .offset_tx_eq =-1, .length_tx_eq =-1, - .addr_tx_fault =0x50, .page_tx_fault =-1, .offset_tx_fault =4, .length_tx_fault =1, - .addr_tx_power =0x50, .page_tx_power =-1, .offset_tx_power =50, .length_tx_power =8, - .addr_vendor_name =0x50, .page_vendor_name =0, .offset_vendor_name =148, .length_vendor_name =16, - .addr_vendor_pn =0x50, .page_vendor_pn =0, .offset_vendor_pn =168, .length_vendor_pn =16, - .addr_vendor_rev =0x50, .page_vendor_rev =0, .offset_vendor_rev =184, .length_vendor_rev =2, - .addr_vendor_sn =0x50, .page_vendor_sn =0, .offset_vendor_sn =196, .length_vendor_sn =16, - .addr_voltage =0x50, .page_voltage =-1, .offset_voltage =26, .length_voltage =2, - .addr_wavelength =0x50, .page_wavelength =0, .offset_wavelength =186, .length_wavelength =2, -}; - -struct eeprom_map_s eeprom_map_qsfp28 = { - .addr_br =0x50, .page_br =0, .offset_br =140, .length_br =1, - .addr_cdr =0x50, .page_cdr =-1, .offset_cdr =98, .length_cdr =1, - .addr_comp_rev =0x50, .page_comp_rev =-1, .offset_comp_rev =1, .length_comp_rev =1, - .addr_connector =0x50, .page_connector =0, .offset_connector =130, .length_connector =1, - .addr_diag_type =0x50, .page_diag_type =0, .offset_diag_type =220, .length_diag_type =1, - .addr_extbr =0x50, .page_extbr =0, .offset_extbr =222, .length_extbr =1, - .addr_ext_id =0x50, .page_ext_id =0, .offset_ext_id =129, .length_ext_id =1, - .addr_id =0x50, .page_id =0, .offset_id =128, .length_id =1, - .addr_len_sm =-1, .page_len_sm =-1, .offset_len_sm =-1, .length_len_sm =-1, - .addr_len_smf =0x50, .page_len_smf =0, .offset_len_smf =142, .length_len_smf =1, - .addr_len_om1 =0x50, .page_len_om1 =0, .offset_len_om1 =145, .length_len_om1 =1, - .addr_len_om2 =0x50, .page_len_om2 =0, .offset_len_om2 =144, .length_len_om2 =1, - .addr_len_om3 =0x50, .page_len_om3 =0, .offset_len_om3 =143, .length_len_om3 =1, - .addr_len_om4 =0x50, .page_len_om4 =0, .offset_len_om4 =146, .length_len_om4 =1, - .addr_option =0x50, .page_option =0, .offset_option =193, .length_option =3, - .addr_rate_id =-1, .page_rate_id =-1, .offset_rate_id =-1, .length_rate_id =-1, - .addr_rx_am =0x50, .page_rx_am =3, .offset_rx_am =238, .length_rx_am =2, - .addr_rx_em =0x50, .page_rx_em =3, .offset_rx_em =236, .length_rx_em =2, - .addr_rx_los =0x50, .page_rx_los =-1, .offset_rx_los =3, .length_rx_los =1, - .addr_rx_power =0x50, .page_rx_power =-1, .offset_rx_power =34, .length_rx_power =8, - .addr_soft_rs0 =-1, .page_soft_rs0 =-1, .offset_soft_rs0 =-1, .length_soft_rs0 =-1, - .addr_soft_rs1 =-1, .page_soft_rs1 =-1, .offset_soft_rs1 =-1, .length_soft_rs0 =-1, - .addr_temp =0x50, .page_temp =-1, .offset_temp =22, .length_temp =2, - .addr_trancomp =0x50, .page_trancomp =0, .offset_trancomp =131, .length_trancomp =8, - .addr_trancomp_ext =0x50, .page_trancomp_ext =0, .offset_trancomp_ext =192, .length_trancomp_ext =1, - .addr_tx_bias =0x50, .page_tx_bias =-1, .offset_tx_bias =42, .length_tx_bias =8, - .addr_tx_disable =0x50, .page_tx_disable =-1, .offset_tx_disable =86, .length_tx_disable =1, - .addr_tx_eq =0x50, .page_tx_eq =3, .offset_tx_eq =234, .length_tx_eq =2, - .addr_tx_fault =0x50, .page_tx_fault =-1, .offset_tx_fault =4, .length_tx_fault =1, - .addr_tx_power =0x50, .page_tx_power =-1, .offset_tx_power =50, .length_tx_power =8, - .addr_vendor_name =0x50, .page_vendor_name =0, .offset_vendor_name =148, .length_vendor_name =16, - .addr_vendor_pn =0x50, .page_vendor_pn =0, .offset_vendor_pn =168, .length_vendor_pn =16, - .addr_vendor_rev =0x50, .page_vendor_rev =0, .offset_vendor_rev =184, .length_vendor_rev =2, - .addr_vendor_sn =0x50, .page_vendor_sn =0, .offset_vendor_sn =196, .length_vendor_sn =16, - .addr_voltage =0x50, .page_voltage =-1, .offset_voltage =26, .length_voltage =2, - .addr_wavelength =0x50, .page_wavelength =0, .offset_wavelength =186, .length_wavelength =2, -}; - - -/* ========== Utility Functions ========== - */ -static int -get_bit(uint8_t origin_byte, int bit_shift) { - return (int)((origin_byte >> bit_shift) & 0x1); -} - -static int -transform_word_to_int(uint8_t hight_byte, - uint8_t low_byte) { - return ((((int)hight_byte) << 8) + (int)low_byte); -} - -void -alarm_msg_2_user(struct transvr_obj_s *self, - char *emsg) { - - SWPS_ERR("%s on %s.\n", emsg, self->swp_name); -} -EXPORT_SYMBOL(alarm_msg_2_user); - -/* ========== Private functions ========== - */ -static int -_reload_transvr_obj(struct transvr_obj_s *self,int new_type); - -static int -reload_transvr_obj(struct transvr_obj_s *self,int new_type); - -static int -_is_transvr_support_ctle(struct transvr_obj_s *self); - -static int -_transvr_init_handler(struct transvr_obj_s *self); - -int -_transvr_clean_handler(struct transvr_obj_s *self); - -int -_sfp_detect_class_by_1g_ethernet(struct transvr_obj_s* self); - - -void -lock_transvr_obj(struct transvr_obj_s *self) { - - mutex_lock(&self->lock); - self->curr_page = VAL_TRANSVR_PAGE_FREE; -} -EXPORT_SYMBOL(lock_transvr_obj); - - -void -unlock_transvr_obj(struct transvr_obj_s *self) { - - self->curr_page = VAL_TRANSVR_PAGE_FREE; - mutex_unlock(&self->lock); -} -EXPORT_SYMBOL(unlock_transvr_obj); - - -static int -_check_by_mode(struct transvr_obj_s *self, - int (*attr_update_func)(struct transvr_obj_s *self, int show_err), - char *caller_name){ - - int return_val = ERR_TRANSVR_UNEXCPT; - - switch (self->mode){ - case TRANSVR_MODE_POLLING: - switch (self->state){ - case STATE_TRANSVR_CONNECTED: - goto ok_check_by_mode_1; - case STATE_TRANSVR_NEW: - case STATE_TRANSVR_INIT: - return ERR_TRANSVR_UNINIT; - case STATE_TRANSVR_DISCONNECTED: - return ERR_TRANSVR_UNPLUGGED; - case STATE_TRANSVR_UNEXCEPTED: - return ERR_TRANSVR_ABNORMAL; - case STATE_TRANSVR_ISOLATED: - return ERR_TRNASVR_BE_ISOLATED; - default: - goto err_check_by_mode_1; - } - goto ok_check_by_mode_1; - - case TRANSVR_MODE_DIRECT: - return_val = self->fsm_4_direct(self, caller_name); - if (return_val < 0){ - return return_val; - } - goto ok_check_by_mode_1; - - default: - goto err_check_by_mode_1; - } - goto ok_check_by_mode_1; - -ok_check_by_mode_1: - return attr_update_func(self, 0); - -err_check_by_mode_1: - SWPS_INFO("_check_by_mode: mode:%d state:%d\n", self->mode, self->state); - return ERR_TRANSVR_UNEXCPT; -} - - -static void -_transvr_clean_retry(struct transvr_obj_s *self) { - self->retry = 0; -} - - -static int -_transvr_handle_retry(struct transvr_obj_s *self, int retry) { - /* Return: 0: keep retry - * -1: stop retry - */ - if (self->retry == 0) { - self->retry = retry; - } - self->retry -= 1; - if (self->retry <= 0) { - _transvr_clean_retry(self); - return -1; - } - return 0; -} - - -static int -_common_setup_page(struct transvr_obj_s *self, - int addr, - int page, - int offset, - int len, - int show_e) { - /* return: - * 0 : OK - * -1 : EEPROM settings incorrect - * -2 : I2C R/W failure - * -3 : Undefined case - */ - int retval = DEBUG_TRANSVR_INT_VAL; - char *emsg = DEBUG_TRANSVR_STR_VAL; - - /* Check */ - if ((addr < 0) || (offset < 0) || (len < 0)) { - emsg = "EEPROM settings incorrect"; - retval = -1; - goto err_common_setup_page; - } - /* Case1: continue access */ - if ((self->i2c_client_p->addr == addr) && - (self->curr_page == page)) { - return 0; - } - self->i2c_client_p->addr = addr; - /* Case2: select lower page */ - if (page == -1) { - self->curr_page = page; - return 0; - } - /* Case3: select upper page */ - if (page >= 0) { - goto upper_common_setup_page; - } - /* Unexpected case */ - show_e = 1; - emsg = "Unexpected case"; - retval = -3; - goto err_common_setup_page; - -upper_common_setup_page: - if (i2c_smbus_write_byte_data(self->i2c_client_p, - VAL_TRANSVR_PAGE_SELECT_OFFSET, - page) < 0) { - emsg = "I2C R/W failure"; - retval = -2; - goto err_common_setup_page; - } - self->curr_page = page; - mdelay(VAL_TRANSVR_PAGE_SELECT_DELAY); - return 0; - -err_common_setup_page: - if (show_e) { - SWPS_INFO("%s: %s", __func__, emsg); - SWPS_INFO("%s: :0x%02x :%d :%d :%d\n", - __func__, addr, page, offset, len); - } - return retval; -} - -/* -static int -_common_setup_password(struct transvr_obj_s *self, - int addr, - int page, - int offs, - uint8_t pwd[4], - int show_e) { - int i = 0; - int err = DEBUG_TRANSVR_INT_VAL; - char *emsg = DEBUG_TRANSVR_STR_VAL; - - err = _common_setup_page(self, addr, page, offs, 4, show_e); - if (err < 0){ - emsg = "setup EEPROM page fail"; - goto err_common_setup_password; - } - for (i=0; i<4; i++) { - err = i2c_smbus_write_byte_data(self->i2c_client_p, - (offs + i), - pwd[i]); - if (err < 0){ - emsg = "I2C R/W fail!"; - goto err_common_setup_password; - } - } - return 0; - -err_common_setup_password: - if (show_e) { - SWPS_INFO("%s: %s :%d\n", __func__, emsg, err); - } - return ERR_TRANSVR_UPDATE_FAIL; -} -*/ - -static int -_common_update_uint8_attr(struct transvr_obj_s *self, - int addr, - int page, - int offset, - int len, - uint8_t *buf, - char *caller, - int show_e){ - - int i; - int err = DEBUG_TRANSVR_INT_VAL; - char *emsg = DEBUG_TRANSVR_STR_VAL; - - err = _common_setup_page(self, addr, page, offset, len, show_e); - if (err < 0){ - emsg = "setup EEPROM page fail"; - goto err_common_update_uint8_attr; - } - for (i=0; ii2c_client_p, (offset + i)); - if (err < 0){ - emsg = "I2C R/W fail!"; - goto err_common_update_uint8_attr; - } - buf[i] = err; - } - return 0; - -err_common_update_uint8_attr: - if (show_e) { - SWPS_INFO("%s: %s :%s :%d\n", - __func__, emsg, caller, err); - } - buf[0] = DEBUG_TRANSVR_HEX_VAL; - return ERR_TRANSVR_UPDATE_FAIL; -} - - -static int -_common_update_int_attr(struct transvr_obj_s *self, - int addr, - int page, - int offset, - int len, - int *buf, - char *caller, - int show_e){ - - int i; - int err = DEBUG_TRANSVR_INT_VAL; - char *emsg = DEBUG_TRANSVR_STR_VAL; - - err = _common_setup_page(self, addr, page, offset, len, show_e); - if (err < 0){ - emsg = "setup EEPROM page fail"; - goto err_common_update_int_attr; - } - for (i=0; ii2c_client_p, (offset + i)); - if (err < 0){ - emsg = "I2C R/W fail!"; - goto err_common_update_int_attr; - } - buf[i] = (int)err; - } - return 0; - -err_common_update_int_attr: - if (show_e) { - SWPS_INFO("%s: %s :%s :%d\n", - __func__, emsg, caller, err); - } - buf[0] = DEBUG_TRANSVR_INT_VAL; - return ERR_TRANSVR_UPDATE_FAIL; -} - - -static int -_common_update_string_attr(struct transvr_obj_s *self, - int addr, - int page, - int offset, - int len, - char buf[], - char *caller, - int show_e){ - - int i; - int err = DEBUG_TRANSVR_INT_VAL; - char *emsg = DEBUG_TRANSVR_STR_VAL; - - err = _common_setup_page(self, addr, page, offset, len, show_e); - if (err < 0){ - emsg = "setup EEPROM page fail"; - goto err_common_update_string_attr; - } - for (i=0; ii2c_client_p, (offset + i)); - if (err < 0){ - emsg = "I2C R/W fail!"; - goto err_common_update_string_attr; - } - buf[i] = (char)err; - } - return 0; - -err_common_update_string_attr: - if (show_e) { - SWPS_INFO("%s: %s :%s :%d\n", - __func__, emsg, caller, err); - } - buf[0] = 'e'; - return ERR_TRANSVR_UPDATE_FAIL; -} - - -static int -_common_set_uint8_attr(struct transvr_obj_s *self, - int addr, - int page, - int offset, - uint8_t update, - uint8_t *buf, - char *caller, - int show_e){ - int len = 1; - int err = DEBUG_TRANSVR_INT_VAL; - char *emsg = DEBUG_TRANSVR_STR_VAL; - - if ((*buf) == update){ - return 0; - } - err = _common_setup_page(self, addr, page, offset, len, show_e); - if (err < 0){ - emsg = "setup EEPROM page fail"; - goto err_common_set_uint8_attr_1; - } - err = i2c_smbus_write_byte_data(self->i2c_client_p, - offset, - update); - if (err < 0){ - emsg = "I2C R/W fail!"; - goto err_common_set_uint8_attr_1; - } - (*buf) = update; - return 0; - -err_common_set_uint8_attr_1: - if (show_e) { - SWPS_INFO("%s: %s :%s :%d\n", - __func__, emsg, caller, err); - } - return ERR_TRANSVR_UPDATE_FAIL; -} - - -static int -_common_set_uint8_array(struct transvr_obj_s *self, - int addr, - int page, - int offs, - int len, - uint8_t update[], - uint8_t buf[], - char *caller, - int show_e){ - int i = 0; - int err = DEBUG_TRANSVR_INT_VAL; - char *emsg = DEBUG_TRANSVR_STR_VAL; - - err = _common_setup_page(self, addr, page, offs, len, show_e); - if (err < 0){ - emsg = "setup EEPROM page fail"; - goto err_common_set_uint8_attr_1; - } - for (i=0; ii2c_client_p, - (offs + i), - update[i]); - if (err < 0){ - emsg = "I2C R/W fail!"; - goto err_common_set_uint8_attr_1; - } - buf[i] = update[i]; - } - return 0; - -err_common_set_uint8_attr_1: - if (show_e) { - SWPS_INFO("%s: %s :%s :%d :%d\n", - __func__, emsg, caller, err, i); - } - return ERR_TRANSVR_UPDATE_FAIL; -} - - -static int -_common_update_attr_id(struct transvr_obj_s *self, - int show_err){ - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_id, - self->eeprom_map_p->page_id, - self->eeprom_map_p->offset_id, - self->eeprom_map_p->length_id, - &(self->id), - "_common_update_attr_id", - show_err); -} - - -static int -_common_update_attr_extended_id(struct transvr_obj_s *self, - int show_err){ - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_ext_id, - self->eeprom_map_p->page_ext_id, - self->eeprom_map_p->offset_ext_id, - self->eeprom_map_p->length_ext_id, - &(self->ext_id), - "_common_update_attr_extended_id", - show_err); -} - - -static int -_common_update_attr_connector(struct transvr_obj_s *self, - int show_err){ - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_connector, - self->eeprom_map_p->page_connector, - self->eeprom_map_p->offset_connector, - self->eeprom_map_p->length_connector, - &(self->connector), - "_common_update_attr_connector", - show_err); -} - - -static int -_common_update_attr_transvr_comp(struct transvr_obj_s *self, - int show_err){ - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_trancomp, - self->eeprom_map_p->page_trancomp, - self->eeprom_map_p->offset_trancomp, - self->eeprom_map_p->length_trancomp, - self->transvr_comp, - "_common_update_attr_transvr_comp", - show_err); -} - - -static int -_common_update_attr_transvr_comp_ext(struct transvr_obj_s *self, - int show_err){ - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_trancomp_ext, - self->eeprom_map_p->page_trancomp_ext, - self->eeprom_map_p->offset_trancomp_ext, - self->eeprom_map_p->length_trancomp_ext, - &(self->transvr_comp_ext), - "_common_update_attr_transvr_comp_ext", - show_err); -} - - -static int -_common_update_attr_vendor_name(struct transvr_obj_s *self, - int show_err){ - return _common_update_string_attr(self, - self->eeprom_map_p->addr_vendor_name, - self->eeprom_map_p->page_vendor_name, - self->eeprom_map_p->offset_vendor_name, - self->eeprom_map_p->length_vendor_name, - self->vendor_name, - "_common_update_attr_vendor_name", - show_err); -} - - -static int -_common_update_attr_vendor_pn(struct transvr_obj_s *self, - int show_err){ - return _common_update_string_attr(self, - self->eeprom_map_p->addr_vendor_pn, - self->eeprom_map_p->page_vendor_pn, - self->eeprom_map_p->offset_vendor_pn, - self->eeprom_map_p->length_vendor_pn, - self->vendor_pn, - "_common_update_attr_vendor_pn", - show_err); -} - - -static int -_common_update_attr_vendor_rev(struct transvr_obj_s *self, - int show_err){ - return _common_update_string_attr(self, - self->eeprom_map_p->addr_vendor_rev, - self->eeprom_map_p->page_vendor_rev, - self->eeprom_map_p->offset_vendor_rev, - self->eeprom_map_p->length_vendor_rev, - self->vendor_rev, - "_common_update_attr_vendor_rev", - show_err); -} - - -static int -_common_update_attr_vendor_sn(struct transvr_obj_s *self, - int show_err){ - return _common_update_string_attr(self, - self->eeprom_map_p->addr_vendor_sn, - self->eeprom_map_p->page_vendor_sn, - self->eeprom_map_p->offset_vendor_sn, - self->eeprom_map_p->length_vendor_sn, - self->vendor_sn, - "_common_update_attr_vendor_sn", - show_err); -} - - -static int -_common_update_attr_br(struct transvr_obj_s *self, - int show_err){ - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_br, - self->eeprom_map_p->page_br, - self->eeprom_map_p->offset_br, - self->eeprom_map_p->length_br, - &(self->br), - "_common_update_attr_br", - show_err); -} - - -static int -_common_update_attr_len_smf(struct transvr_obj_s *self, - int show_err){ - return _common_update_int_attr(self, - self->eeprom_map_p->addr_len_smf, - self->eeprom_map_p->page_len_smf, - self->eeprom_map_p->offset_len_smf, - self->eeprom_map_p->length_len_smf, - &(self->len_smf), - "_common_update_attr_len_smf", - show_err); -} - - -static int -_common_update_attr_len_om1(struct transvr_obj_s *self, - int show_err){ - return _common_update_int_attr(self, - self->eeprom_map_p->addr_len_om1, - self->eeprom_map_p->page_len_om1, - self->eeprom_map_p->offset_len_om1, - self->eeprom_map_p->length_len_om1, - &(self->len_om1), - "_common_update_attr_len_om1", - show_err); -} - -static int -_common_update_attr_len_om2(struct transvr_obj_s *self, - int show_err){ - return _common_update_int_attr(self, - self->eeprom_map_p->addr_len_om2, - self->eeprom_map_p->page_len_om2, - self->eeprom_map_p->offset_len_om2, - self->eeprom_map_p->length_len_om2, - &(self->len_om2), - "_common_update_attr_len_om2", - show_err); -} - -static int -_common_update_attr_len_om3(struct transvr_obj_s *self, - int show_err){ - return _common_update_int_attr(self, - self->eeprom_map_p->addr_len_om3, - self->eeprom_map_p->page_len_om3, - self->eeprom_map_p->offset_len_om3, - self->eeprom_map_p->length_len_om3, - &(self->len_om3), - "_common_update_attr_len_om3", - show_err); -} - - -static int -_common_update_attr_len_om4(struct transvr_obj_s *self, - int show_err){ - return _common_update_int_attr(self, - self->eeprom_map_p->addr_len_om4, - self->eeprom_map_p->page_len_om4, - self->eeprom_map_p->offset_len_om4, - self->eeprom_map_p->length_len_om4, - &(self->len_om4), - "_common_update_attr_len_om4", - show_err); -} - - -static int -_common_update_attr_option(struct transvr_obj_s *self, - int show_err){ - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_option, - self->eeprom_map_p->page_option, - self->eeprom_map_p->offset_option, - self->eeprom_map_p->length_option, - self->option, - "_common_update_attr_option", - show_err); -} - - -static int -_common_update_attr_comp_rev(struct transvr_obj_s *self, - int show_err){ - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_comp_rev, - self->eeprom_map_p->page_comp_rev, - self->eeprom_map_p->offset_comp_rev, - self->eeprom_map_p->length_comp_rev, - &(self->comp_rev), - "_common_update_attr_comp_rev", - show_err); -} - - -static int -_common_update_attr_diag_type(struct transvr_obj_s *self, - int show_err){ - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_diag_type, - self->eeprom_map_p->page_diag_type, - self->eeprom_map_p->offset_diag_type, - self->eeprom_map_p->length_diag_type, - &(self->diag_type), - "_common_update_attr_diag_type", - show_err); -} - - -static int -_common_update_attr_wavelength(struct transvr_obj_s *self, - int show_err){ - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_wavelength, - self->eeprom_map_p->page_wavelength, - self->eeprom_map_p->offset_wavelength, - self->eeprom_map_p->length_wavelength, - self->wavelength, - "_common_update_attr_wavelength", - show_err); -} - - -int -_common_get_option_value(struct transvr_obj_s *self, - int offset, - int bit_shift) { - /* SFP: - * - option[0] = A0h / 64 - * - option[1] = A0h / 65 - * QSFP: - * - option[0] = 00h / 193 - * - option[1] = 00h / 194 - * - option[2] = 00h / 195 - */ - return (self->option[offset] & (1 << bit_shift)); -} - - -static int -_sfp_update_attr_len_sm(struct transvr_obj_s *self, - int show_err){ - return _common_update_int_attr(self, - self->eeprom_map_p->addr_len_sm, - self->eeprom_map_p->page_len_sm, - self->eeprom_map_p->offset_len_sm, - self->eeprom_map_p->length_len_sm, - &(self->len_sm), - "_common_update_attr_len_sm", - show_err); -} - - -static int -_sfp_update_attr_rate_id(struct transvr_obj_s *self, - int show_err){ - return _common_update_int_attr(self, - self->eeprom_map_p->addr_rate_id, - self->eeprom_map_p->page_rate_id, - self->eeprom_map_p->offset_rate_id, - self->eeprom_map_p->length_rate_id, - &(self->rate_id), - "_sfp_update_attr_rate_id", - show_err); -} - - -static int -_sfp_update_attr_soft_rs0(struct transvr_obj_s *self, - int show_err){ - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_soft_rs0, - self->eeprom_map_p->page_soft_rs0, - self->eeprom_map_p->offset_soft_rs0, - self->eeprom_map_p->length_soft_rs0, - &(self->soft_rs0), - "_sfp_update_attr_soft_rs0", - show_err); -} - - -static int -_sfp_update_attr_soft_rs1(struct transvr_obj_s *self, - int show_err){ - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_soft_rs1, - self->eeprom_map_p->page_soft_rs1, - self->eeprom_map_p->offset_soft_rs1, - self->eeprom_map_p->length_soft_rs1, - &(self->soft_rs1), - "_sfp_update_attr_soft_rs1", - show_err); -} - - -int -_sfp_is_diag_support(struct transvr_obj_s *self){ - - uint8_t bit_mask = 0xC0; /* 1100 0000 */ - uint8_t en_val = 0x40; /* 0100 0000 */ - uint8_t checkval = (self->diag_type & bit_mask); - - if (checkval == en_val) { - return 1; - } - return 0; -} - - -static int -_sfp_update_attr_curr_temp(struct transvr_obj_s *self, - int show_err){ - - if (!(_sfp_is_diag_support(self))) { - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_temp, - self->eeprom_map_p->page_temp, - self->eeprom_map_p->offset_temp, - self->eeprom_map_p->length_temp, - self->curr_temp, - "_sfp_update_attr_curr_temp", - show_err); -} - - -static int -_sfp_update_attr_curr_voltage(struct transvr_obj_s *self, - int show_err){ - - if (!(_sfp_is_diag_support(self))) { - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_voltage, - self->eeprom_map_p->page_voltage, - self->eeprom_map_p->offset_voltage, - self->eeprom_map_p->length_voltage, - self->curr_voltage, - "_sfp_update_attr_curr_voltage", - show_err); -} - - -static int -_sfp_update_attr_curr_tx_bias(struct transvr_obj_s *self, - int show_err){ - - if (!(_sfp_is_diag_support(self))) { - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_tx_bias, - self->eeprom_map_p->page_tx_bias, - self->eeprom_map_p->offset_tx_bias, - self->eeprom_map_p->length_tx_bias, - self->curr_tx_bias, - "_sfp_update_attr_curr_tx_bias", - show_err); -} - - -static int -_sfp_update_attr_curr_tx_power(struct transvr_obj_s *self, - int show_err){ - - if (!(_sfp_is_diag_support(self))) { - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_tx_power, - self->eeprom_map_p->page_tx_power, - self->eeprom_map_p->offset_tx_power, - self->eeprom_map_p->length_tx_power, - self->curr_tx_power, - "_sfp_update_attr_curr_tx_power", - show_err); -} - - -static int -_sfp_update_attr_curr_rx_power(struct transvr_obj_s *self, - int show_err){ - - if (!(_sfp_is_diag_support(self))) { - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_rx_power, - self->eeprom_map_p->page_rx_power, - self->eeprom_map_p->offset_rx_power, - self->eeprom_map_p->length_rx_power, - self->curr_rx_power, - "_sfp_update_attr_curr_rx_power", - show_err); -} - - -static int -_sfp_update_attr_rx_em(struct transvr_obj_s *self, - int show_err){ - - if (!_is_transvr_support_ctle(self)) { - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_rx_em, - self->eeprom_map_p->page_rx_em, - self->eeprom_map_p->offset_rx_em, - self->eeprom_map_p->length_rx_em, - self->rx_em, - "_sfp_update_attr_rx_em", - show_err); -} - - -static int -_sfp_update_attr_tx_eq(struct transvr_obj_s *self, - int show_err){ - - if (!_is_transvr_support_ctle(self)) { - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_tx_eq, - self->eeprom_map_p->page_tx_eq, - self->eeprom_map_p->offset_tx_eq, - self->eeprom_map_p->length_tx_eq, - self->tx_eq, - "_sfp_update_attr_tx_eq", - show_err); -} - - -static int -_qsfp_update_attr_cdr(struct transvr_obj_s *self, - int show_err){ - if (self->type != TRANSVR_TYPE_QSFP_28){ - self->cdr = DEBUG_TRANSVR_HEX_VAL; - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_cdr, - self->eeprom_map_p->page_cdr, - self->eeprom_map_p->offset_cdr, - self->eeprom_map_p->length_cdr, - &(self->cdr), - "_common_update_attr_cdr", - show_err); -} - - -static int -_qsfg_update_attr_extbr(struct transvr_obj_s *self, - int show_err) { - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_extbr, - self->eeprom_map_p->page_extbr, - self->eeprom_map_p->offset_extbr, - self->eeprom_map_p->length_extbr, - &(self->extbr), - "_common_update_attr_extbr", - show_err); -} - - -static int -_qsfp_is_diag_support(struct transvr_obj_s *self, - int diag_type) { - /* Input Parm: diag_type - * => 1 : temperature - * => 2 : voltage - * => 3 : tx relate - * => 4 : rx relate - */ - uint8_t mask_b2 = 0x04; /* 0000 0100 */ - uint8_t mask_b3 = 0x08; /* 0000 1000 */ - - switch (diag_type) { - case 1: /* temperature */ - case 2: /* voltage */ - /* Direct access target, because of spec not defined */ - return 1; - case 3: - case 4: - /* [Note] - * Due to lot of transceiver vendor defined it not rigorously and - * consider of general support, we seem it as supported if there - * are bit-2 OR bit-3 defined by transceiver vendor. - */ - if ( ((self->diag_type & mask_b2) == mask_b2 ) || - ((self->diag_type & mask_b3) == mask_b3 ) ){ - return 1; - } - return 0; - default: - SWPS_INFO("%s: undefined diag_type:%d\n", - __func__, diag_type); - break; - } - return 0; -} - - -int -_qsfp_is_implement_tx_disable(struct transvr_obj_s *self) { - /* - * 00h / Byte-195 / Bit-4 - */ - int byte = 2; - int bit = 4; - return _common_get_option_value(self, byte, bit); -} - - -int -_qsfp_is_implement_tx_fault(struct transvr_obj_s *self) { - /* - * 00h / Byte-195 / Bit-3 - */ - int byte = 2; - int bit = 3; - return _common_get_option_value(self, byte, bit); -} - - -static int -_qsfp_update_attr_curr_temp(struct transvr_obj_s *self, - int show_err){ - int diag_type = 1; - - if (!(_qsfp_is_diag_support(self, diag_type))) { - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_temp, - self->eeprom_map_p->page_temp, - self->eeprom_map_p->offset_temp, - self->eeprom_map_p->length_temp, - self->curr_temp, - "_qsfp_update_attr_curr_temp", - show_err); -} - - -static int -_qsfp_update_attr_curr_voltage(struct transvr_obj_s *self, - int show_err){ - int diag_type = 2; - - if (!(_qsfp_is_diag_support(self, diag_type))) { - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_voltage, - self->eeprom_map_p->page_voltage, - self->eeprom_map_p->offset_voltage, - self->eeprom_map_p->length_voltage, - self->curr_voltage, - "_qsfp_update_attr_curr_voltage", - show_err); -} - - -static int -_qsfp_update_attr_curr_tx_bias(struct transvr_obj_s *self, - int show_err){ - int diag_type = 3; - - if (!(_qsfp_is_diag_support(self, diag_type))) { - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_tx_bias, - self->eeprom_map_p->page_tx_bias, - self->eeprom_map_p->offset_tx_bias, - self->eeprom_map_p->length_tx_bias, - self->curr_tx_bias, - "_qsfp_update_attr_curr_tx_bias", - show_err); -} - - -static int -_qsfp_update_attr_curr_tx_power(struct transvr_obj_s *self, - int show_err){ - int diag_type = 3; - - if (!(_qsfp_is_diag_support(self, diag_type))) { - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_tx_power, - self->eeprom_map_p->page_tx_power, - self->eeprom_map_p->offset_tx_power, - self->eeprom_map_p->length_tx_power, - self->curr_tx_power, - "_qsfp_update_attr_curr_tx_power", - show_err); -} - - -static int -_qsfp_update_attr_curr_rx_power(struct transvr_obj_s *self, - int show_err){ - int diag_type = 4; - - if (!(_qsfp_is_diag_support(self, diag_type))) { - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_rx_power, - self->eeprom_map_p->page_rx_power, - self->eeprom_map_p->offset_rx_power, - self->eeprom_map_p->length_rx_power, - self->curr_rx_power, - "_qsfp_update_attr_curr_rx_power", - show_err); -} - - -static int -_qsfp_update_attr_soft_rx_los(struct transvr_obj_s *self, - int show_err){ - - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_rx_los, - self->eeprom_map_p->page_rx_los, - self->eeprom_map_p->offset_rx_los, - self->eeprom_map_p->length_rx_los, - &(self->rx_los), - "_qsfp_update_attr_soft_rx_los", - show_err); -} - - -static int -_qsfp_update_attr_soft_tx_disable(struct transvr_obj_s *self, - int show_err){ - - if (!_qsfp_is_implement_tx_disable(self)) { - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_tx_disable, - self->eeprom_map_p->page_tx_disable, - self->eeprom_map_p->offset_tx_disable, - self->eeprom_map_p->length_tx_disable, - &(self->tx_disable), - "_qsfp_update_attr_soft_tx_disable", - show_err); -} - - -static int -_qsfp_update_attr_soft_tx_fault(struct transvr_obj_s *self, - int show_err){ - - if (!_qsfp_is_implement_tx_fault(self)) { - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_tx_fault, - self->eeprom_map_p->page_tx_fault, - self->eeprom_map_p->offset_tx_fault, - self->eeprom_map_p->length_tx_fault, - &(self->tx_fault), - "_qsfp_update_attr_soft_tx_fault", - show_err); -} - - -static int -_qsfp_update_attr_tx_eq(struct transvr_obj_s *self, - int show_err){ - - if (!_is_transvr_support_ctle(self)) { - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_tx_eq, - self->eeprom_map_p->page_tx_eq, - self->eeprom_map_p->offset_tx_eq, - self->eeprom_map_p->length_tx_eq, - self->tx_eq, - "_qsfp_update_attr_tx_eq", - show_err); -} - - -static int -_qsfp_update_attr_rx_am(struct transvr_obj_s *self, - int show_err){ - - if (!_is_transvr_support_ctle(self)) { - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_rx_am, - self->eeprom_map_p->page_rx_am, - self->eeprom_map_p->offset_rx_am, - self->eeprom_map_p->length_rx_am, - self->rx_am, - "_qsfp_update_attr_rx_am", - show_err); -} - - -static int -_qsfp_update_attr_rx_em(struct transvr_obj_s *self, - int show_err){ - - if (!_is_transvr_support_ctle(self)) { - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_rx_em, - self->eeprom_map_p->page_rx_em, - self->eeprom_map_p->offset_rx_em, - self->eeprom_map_p->length_rx_em, - self->rx_em, - "_qsfp_update_attr_rx_em", - show_err); -} - - -int -_common_update_attr_all(struct transvr_obj_s *self, - int show_err){ - - char *err_str = "err"; - - if (_common_update_attr_id(self, show_err) < 0) { - err_str = "_common_update_attr_id"; - goto err_common_update_attr_all; - } - if (_common_update_attr_extended_id(self, show_err) < 0) { - err_str = "_common_update_attr_extended_id"; - goto err_common_update_attr_all; - } - if (_common_update_attr_connector(self, show_err) < 0) { - err_str = "_common_update_attr_connector"; - goto err_common_update_attr_all; - } - if (_common_update_attr_transvr_comp(self, show_err) < 0) { - err_str = "_common_update_attr_transvr_comp"; - goto err_common_update_attr_all; - } - if (_common_update_attr_transvr_comp_ext(self, show_err) < 0) { - err_str = "_common_update_attr_transvr_comp_ext"; - goto err_common_update_attr_all; - } - if (_common_update_attr_vendor_name(self, show_err) < 0) { - err_str = "_common_update_attr_vendor_name"; - goto err_common_update_attr_all; - } - if (_common_update_attr_vendor_pn(self, show_err) < 0) { - err_str = "_common_update_attr_vendor_pn"; - goto err_common_update_attr_all; - } - if (_common_update_attr_vendor_rev(self, show_err) < 0) { - err_str = "_common_update_attr_vendor_rev"; - goto err_common_update_attr_all; - } - if (_common_update_attr_vendor_sn(self, show_err) < 0) { - err_str = "_common_update_attr_vendor_sn"; - goto err_common_update_attr_all; - } - if (_common_update_attr_br(self, show_err) < 0) { - err_str = "_common_update_attr_br"; - goto err_common_update_attr_all; - } - if (_common_update_attr_len_smf(self, show_err) < 0) { - err_str = "_common_update_attr_len_smf"; - goto err_common_update_attr_all; - } - if (_common_update_attr_len_om1(self, show_err) < 0) { - err_str = "_common_update_attr_len_om1"; - goto err_common_update_attr_all; - } - if (_common_update_attr_len_om2(self, show_err) < 0) { - err_str = "_common_update_attr_len_om2"; - goto err_common_update_attr_all; - } - if (_common_update_attr_len_om3(self, show_err) < 0) { - err_str = "_common_update_attr_len_om3"; - goto err_common_update_attr_all; - } - if (_common_update_attr_len_om4(self, show_err) < 0) { - err_str = "_common_update_attr_len_om4"; - goto err_common_update_attr_all; - } - if (_common_update_attr_option(self, show_err) < 0) { - err_str = "_common_update_attr_option"; - goto err_common_update_attr_all; - } - if (_common_update_attr_comp_rev(self, show_err) < 0) { - err_str = "_common_update_attr_comp_rev"; - goto err_common_update_attr_all; - } - if (_common_update_attr_diag_type(self, show_err) < 0) { - err_str = "_common_update_attr_diag_type"; - goto err_common_update_attr_all; - } - if (_common_update_attr_wavelength(self, show_err) < 0) { - err_str = "_common_update_attr_wavelength"; - goto err_common_update_attr_all; - } - return 0; - -err_common_update_attr_all: - if (show_err){ - SWPS_INFO("%s: fail at:%s :%s\n", __func__, err_str, self->swp_name); - } - return -1; -} - - -int -_sfp_update_attr_all(struct transvr_obj_s *self, - int show_err){ - - char *err_str = DEBUG_TRANSVR_STR_VAL; - - if (_common_update_attr_all(self, show_err) < 0){ - err_str = "_common_update_attr_all"; - goto err_sfp_update_attr_all; - } - if (_sfp_update_attr_len_sm(self, show_err) < 0) { - err_str = "_sfp_update_attr_len_sm"; - goto err_sfp_update_attr_all; - } - if (_sfp_update_attr_rate_id(self, show_err) < 0) { - err_str = "_sfp_update_attr_rate_id"; - goto err_sfp_update_attr_all; - } - if ((self->rate_id) > 0) { - if (_sfp_update_attr_soft_rs0(self, show_err) < 0) { - err_str = "_sfp_update_attr_soft_rs0"; - goto err_sfp_update_attr_all; - } - if (_sfp_update_attr_soft_rs1(self, show_err) < 0) { - err_str = "_sfp_update_attr_soft_rs1"; - goto err_sfp_update_attr_all; - } - } - return 0; - -err_sfp_update_attr_all: - if (show_err){ - SWPS_INFO("%s: fail at:%s :%s\n", __func__, err_str, self->swp_name); - } - return -1; -} - - -int -_qsfp_update_attr_all(struct transvr_obj_s *self, - int show_err){ - - char *err_str = DEBUG_TRANSVR_STR_VAL; - - if (_common_update_attr_all(self, show_err) < 0){ - err_str = "_common_update_attr_all"; - goto err_qsfp_update_attr_all; - } - if (_qsfg_update_attr_extbr(self, show_err) < 0) { - err_str = "_qsfg_update_attr_extbr"; - goto err_qsfp_update_attr_all; - } - if (self->type == TRANSVR_TYPE_QSFP_28) { - if (_qsfp_update_attr_cdr(self, 1) < 0) { - err_str = "_qsfp_update_attr_cdr"; - goto err_qsfp_update_attr_all; - } - } - return 0; - -err_qsfp_update_attr_all: - if (show_err){ - SWPS_INFO("%s: fail at:%s :%s\n", __func__, err_str, self->swp_name); - } - return -1; -} - - -/* ========== Object functions for common type ========== - */ -int -_common_count_temp(uint8_t high_byte, - uint8_t low_byte, - char *buf_p) { - int sign = 0; - int high = 0; - int low = 0; - int lmax = 8; - - /* Count high */ - sign = get_bit(high_byte,7); - SWP_BIT_CLEAR(high_byte, 7); - high = (int)high_byte; - if (sign == 1) { - high = 0 - high; - } - /* Count low */ - low = (get_bit(low_byte, 7) * 500); - low += (get_bit(low_byte, 6) * 250); - low += (get_bit(low_byte, 5) * 125); - low += (get_bit(low_byte, 4) * 62); - low = (low / 100); - /* Integrate High and Low */ - return snprintf(buf_p, lmax, "%d.%d\n", high, low); -} - - -int -_common_count_voltage(uint8_t high_byte, - uint8_t low_byte, - char *buf_p) { - /* [Note]: - * Internally measured transceiver supply voltage. Represented - * as a 16 bit unsigned integer with the voltage defined as the - * full 16 bit value (0-65535) with LSB equal to 100 uVolt, - * yielding a total range of 0 to +6.55 Volts. Practical - * considerations to be defined by transceiver manufacturer will - * tend to limit the actual bounds of the supply voltage measurement. - * Accuracy is vendor specific but must be better than 3% of the - * manufacturer's nominal value over specified operating temperature - * and voltage. Note that in some transceivers, transmitter supply - * voltage and receiver supply voltage are isolated. In that case, - * only one supply is monitored. Refer to the device specification - * for more detail. - */ - int total = 0; - int lmax = 8; - int val_i = 0; - int val_f = 0; - /* unit: 100 uV (1mV=1000uV) */ - total = transform_word_to_int(high_byte, low_byte); - val_i = ((total/10) / 1000); - val_f = ((total/10) - (val_i*1000)); - /* Return Unit: 1 Volt */ - return snprintf(buf_p, lmax, "%d.%03d\n", val_i, val_f); -} - - -int -_common_count_tx_bias(uint8_t high_byte, - uint8_t low_byte, - char *buf_p) { - /* [Note] - * Measured TX bias current in uA. Represented as a 16 bit unsigned - * integer with the current defined as the full 16 bit value (0-65535) - * with LSB equal to 2 uA, yielding a total range of 0 to 131 mA. - * Accuracy is vendor specific but must be better than 10% of the - * manufacturer's nominal value over specified operating temperature - * and voltage. - */ - int total = 0; - int lmax = 8; - int val_i = 0; - int val_f = 0; - /* unit: 2 uA (1mA=1000uA) */ - total = transform_word_to_int(high_byte, low_byte); - val_i = ((total*2) / 1000); - val_f = (((total*2) - (val_i*1000)) / 100); - /* Return Unit: 1 mA */ - return snprintf(buf_p, lmax, "%d.%01d\n", val_i, val_f); -} - - -int -_common_count_tx_power(uint8_t high_byte, - uint8_t low_byte, - char *buf_p) { - /* [Note] - * Measured TX output power in mW. Represented as a 16 bit unsigned - * integer with the power defined as the full 16 bit value (0-65535) - * with LSB equal to 0.1 uW, yielding a total range of 0 to 6.5535 mW - * (~ -40 to +8.2 dBm). Data is assumed to be based on measurement of - * laser monitor photodiode current. It is factory calibrated to absolute - * units using the most representative fiber output type. Accuracy is - * vendor specific but must be better than 3dB over specified temperature - * and voltage. Data is not valid when the transmitter is disabled. - */ - int total = 0; - int lmax = 8; - int val_i = 0; - int val_f = 0; - /* unit: 0.1 uW (1mW=1000uW) */ - total = transform_word_to_int(high_byte, low_byte); - val_i = ((total/10) / 1000); - val_f = ((total/10) - (val_i*1000)); - /* Return Unit: 1 mW */ - return snprintf(buf_p, lmax, "%d.%03d\n", val_i, val_f); -} - - -int -_common_count_rx_power(uint8_t high_byte, - uint8_t low_byte, - char *buf_p) { - /* [Note] - * Measured RX received optical power in mW. Value can represent either - * average received power or OMA depending upon how bit 3 of byte 92 (A0h) - * is set. Represented as a 16 bit unsigned integer with the power defined - * as the full 16 bit value (0-65535) with LSB equal to 0.1 uW, yielding a - * total range of 0 to 6.5535 mW (~ -40 to +8.2 dBm). Absolute accuracy is - * dependent upon the exact optical wavelength. For the vendor specified - * wavelength, accuracy shall be better than 3dB over specified temperature - * and voltage. - */ - int total = 0; - int lmax = 8; - int val_i = 0; - int val_f = 0; - /* unit: 0.1 uW (1mW=1000uW) */ - total = transform_word_to_int(high_byte, low_byte); - val_i = ((total/10) / 1000); - val_f = ((total/10) - (val_i*1000)); - /* Return Unit: 1 mW */ - return snprintf(buf_p, lmax, "%d.%03d\n", val_i, val_f); -} - - -int -_common_count_wavelength(struct transvr_obj_s *self, - uint8_t high_byte, - uint8_t low_byte) { - /* [Note] - * SFP : uint 1 um. - * QSFP: unit 0.05 um. - */ - int total = 0; - - total = transform_word_to_int(high_byte, low_byte); - switch (self->type) { - case TRANSVR_TYPE_SFP: - return total; - - case TRANSVR_TYPE_QSFP: - case TRANSVR_TYPE_QSFP_PLUS: - case TRANSVR_TYPE_QSFP_28: - return (total/20); - - default: - break; - } - return ERR_TRANSVR_UNDEFINED; -} - - -int -common_get_id(struct transvr_obj_s *self){ - - int err_code = _check_by_mode(self, - &_common_update_attr_id, - "common_get_id"); - if (err_code < 0){ - return err_code; - } - /* Transform to INT to show error case */ - return (int)self->id; -} - - -int -common_get_ext_id(struct transvr_obj_s *self){ - - int err_code = _check_by_mode(self, - &_common_update_attr_extended_id, - "common_get_ext_id"); - if (err_code < 0){ - return err_code; - } - /* Transform to INT to show error case */ - return (int)self->ext_id; -} - - -int -common_get_connector(struct transvr_obj_s *self){ - - int err_code = _check_by_mode(self, - &_common_update_attr_connector, - "common_get_connector"); - if (err_code < 0){ - return err_code; - } - /* Transform to INT to show error case */ - return (int)self->connector; -} - - -int -common_get_vendor_name(struct transvr_obj_s *self, char *buf){ - - int err = DEBUG_TRANSVR_INT_VAL; - - if (self->state == STATE_TRANSVR_CONNECTED && - self->mode == TRANSVR_MODE_POLLING && - TRANSVR_INFO_CACHE_ENABLE) { - return snprintf(buf, LEN_TRANSVR_M_STR, "%s\n", self->vendor_name); - } - err = _check_by_mode(self, - &_common_update_attr_vendor_name, - "common_get_vendor_name"); - memset(buf, 0, LEN_TRANSVR_M_STR); - if (err < 0){ - return snprintf(buf, LEN_TRANSVR_M_STR, "%d\n", err); - } - return snprintf(buf, LEN_TRANSVR_M_STR, "%s\n", self->vendor_name); -} - - -int -common_get_vendor_pn(struct transvr_obj_s *self, char *buf) { - - int err = DEBUG_TRANSVR_INT_VAL; - - if (self->state == STATE_TRANSVR_CONNECTED && - self->mode == TRANSVR_MODE_POLLING && - TRANSVR_INFO_CACHE_ENABLE) { - return snprintf(buf, LEN_TRANSVR_M_STR, "%s\n", self->vendor_pn); - } - err = _check_by_mode(self, - &_common_update_attr_vendor_pn, - "common_get_vendor_pn"); - memset(buf, 0, LEN_TRANSVR_M_STR); - if (err < 0){ - return snprintf(buf, LEN_TRANSVR_M_STR, "%d\n", err); - } - return snprintf(buf, LEN_TRANSVR_M_STR, "%s\n", self->vendor_pn); -} - - -int -common_get_vendor_rev(struct transvr_obj_s *self, char *buf) { - - int err = DEBUG_TRANSVR_INT_VAL; - - if (self->state == STATE_TRANSVR_CONNECTED && - self->mode == TRANSVR_MODE_POLLING && - TRANSVR_INFO_CACHE_ENABLE) { - return snprintf(buf, LEN_TRANSVR_M_STR, "%s\n", self->vendor_rev); - } - err = _check_by_mode(self, - &_common_update_attr_vendor_rev, - "common_get_vendor_rev"); - memset(buf, 0, LEN_TRANSVR_M_STR); - if (err < 0){ - return snprintf(buf, LEN_TRANSVR_M_STR, "%d\n", err); - } - return snprintf(buf, LEN_TRANSVR_M_STR, "%s\n", self->vendor_rev); -} - - -int -common_get_vendor_sn(struct transvr_obj_s *self, char *buf) { - - int err = DEBUG_TRANSVR_INT_VAL; - - if (self->state == STATE_TRANSVR_CONNECTED && - self->mode == TRANSVR_MODE_POLLING && - TRANSVR_INFO_CACHE_ENABLE) { - return snprintf(buf, LEN_TRANSVR_M_STR, "%s\n", self->vendor_sn); - } - err = _check_by_mode(self, - &_common_update_attr_vendor_sn, - "common_get_vendor_sn"); - memset(buf, 0, LEN_TRANSVR_M_STR); - if (err < 0){ - return snprintf(buf, LEN_TRANSVR_M_STR, "%d\n", err); - } - return snprintf(buf, LEN_TRANSVR_M_STR, "%s\n", self->vendor_sn); -} - - -int -common_get_br(struct transvr_obj_s *self){ - - int err = DEBUG_TRANSVR_INT_VAL; - - if (self->state == STATE_TRANSVR_CONNECTED && - self->mode == TRANSVR_MODE_POLLING && - TRANSVR_INFO_CACHE_ENABLE) { - return (int)self->br; - } - err = _check_by_mode(self, - &_common_update_attr_br, - "common_get_br"); - if (err < 0){ - return err; - } - /* Transform to INT to show error case */ - return (int)self->br; -} - - -int -common_get_len_smf(struct transvr_obj_s *self){ - - int err = DEBUG_TRANSVR_INT_VAL; - - if (self->state == STATE_TRANSVR_CONNECTED && - self->mode == TRANSVR_MODE_POLLING && - TRANSVR_INFO_CACHE_ENABLE) { - return self->len_smf; - } - err = _check_by_mode(self, - &_common_update_attr_len_smf, - "common_get_len_smf"); - if (err < 0){ - return err; - } - return self->len_smf; -} - - -int -common_get_len_om1(struct transvr_obj_s *self){ - - int err = DEBUG_TRANSVR_INT_VAL; - - if (self->state == STATE_TRANSVR_CONNECTED && - self->mode == TRANSVR_MODE_POLLING && - TRANSVR_INFO_CACHE_ENABLE) { - return self->len_om1; - } - err = _check_by_mode(self, - &_common_update_attr_len_om1, - "common_get_len_om1"); - if (err < 0){ - return err; - } - return self->len_om1; -} - - -int -common_get_len_om2(struct transvr_obj_s *self){ - - int err = DEBUG_TRANSVR_INT_VAL; - - if (self->state == STATE_TRANSVR_CONNECTED && - self->mode == TRANSVR_MODE_POLLING && - TRANSVR_INFO_CACHE_ENABLE) { - return self->len_om2; - } - - err = _check_by_mode(self, - &_common_update_attr_len_om2, - "common_get_len_om2"); - if (err < 0){ - return err; - } - return self->len_om2; -} - - -int -common_get_len_om3(struct transvr_obj_s *self){ - - int err = DEBUG_TRANSVR_INT_VAL; - - if (self->state == STATE_TRANSVR_CONNECTED && - self->mode == TRANSVR_MODE_POLLING && - TRANSVR_INFO_CACHE_ENABLE) { - return self->len_om3; - } - - err = _check_by_mode(self, - &_common_update_attr_len_om3, - "common_get_len_om3"); - if (err < 0){ - return err; - } - return self->len_om3; -} - - -int -common_get_len_om4(struct transvr_obj_s *self){ - - int err = DEBUG_TRANSVR_INT_VAL; - - if (self->state == STATE_TRANSVR_CONNECTED && - self->mode == TRANSVR_MODE_POLLING && - TRANSVR_INFO_CACHE_ENABLE) { - return self->len_om4; - } - err = _check_by_mode(self, - &_common_update_attr_len_om4, - "common_get_len_om4"); - if (err < 0){ - return err; - } - return self->len_om4; -} - - -int -common_get_comp_extended(struct transvr_obj_s *self){ - - int err_code = _check_by_mode(self, - &_common_update_attr_transvr_comp_ext, - "common_get_comp_extended"); - if (err_code < 0){ - return err_code; - } - return self->transvr_comp_ext; -} - - -int -common_get_comp_rev(struct transvr_obj_s *self){ - - int err_code = _check_by_mode(self, - &_common_update_attr_comp_rev, - "common_get_comp_rev"); - if (err_code < 0){ - return err_code; - } - return self->comp_rev; -} - - -int -common_get_info(struct transvr_obj_s *self){ - - if (self->state != STATE_TRANSVR_CONNECTED) { - return self->state; - } - return self->info; -} - - -int -_common_get_if_lane(struct transvr_obj_s *self, - char *result){ - int i = 0; - int tmp_val = 0; - char tmp_str[LEN_TRANSVR_M_STR] = DEBUG_TRANSVR_STR_VAL; - - memset(result, 0, LEN_TRANSVR_M_STR); - - for (i=0; ilane_id); i++) { - tmp_val = self->lane_id[i]; - if (tmp_val < 1) { - break; - } - memset(tmp_str, 0, LEN_TRANSVR_M_STR); - if (i == 0) { - snprintf(tmp_str, LEN_TRANSVR_M_STR, "%d", tmp_val); - } else { - snprintf(tmp_str, LEN_TRANSVR_M_STR, ",%d", tmp_val); - } - strncat(result, tmp_str, LEN_TRANSVR_M_STR); - } - if (i == 0) { - return EVENT_TRANSVR_TASK_FAIL; - } - return 0; -} - - -int -common_get_if_lane(struct transvr_obj_s *self, - char *buf_p){ - - char tmp_str[LEN_TRANSVR_M_STR] = DEBUG_TRANSVR_STR_VAL; - - if (self->ioexp_obj_p->state != STATE_IOEXP_NORMAL) { - return snprintf(buf_p, LEN_TRANSVR_M_STR, "%d\n", ERR_TRANSVR_ABNORMAL); - } - if (_common_get_if_lane(self, tmp_str) < 0) { - return snprintf(buf_p, LEN_TRANSVR_M_STR, "%d\n" ,ERR_TRANSVR_ABNORMAL); - } - return snprintf(buf_p, LEN_TRANSVR_M_STR, "%s\n" ,tmp_str); -} - - -int -sfp_get_len_sm(struct transvr_obj_s *self){ - - int err_code = _check_by_mode(self, - &_sfp_update_attr_len_sm, - "sfp_get_len_sm"); - if (err_code < 0){ - return err_code; - } - return self->len_sm; -} - - -int -sfp_get_rate_id(struct transvr_obj_s *self){ - - int err_code = _check_by_mode(self, - &_sfp_update_attr_rate_id, - "sfp_get_rate_id"); - if (err_code < 0){ - return err_code; - } - return self->rate_id; -} - - -int -sfp_get_soft_rs0(struct transvr_obj_s *self){ - /* Note: - * SFP Soft Rate_Select Select [aka. "RS(0)"] address - * A2h, offset: 110, bit 3 (begin form 0) - */ - int err_code = DEBUG_TRANSVR_INT_VAL; - int bit_shift = 3; - uint8_t result = 0x00; - uint8_t bitmask = (1 << bit_shift); - - /* Check rate identifier is supported */ - err_code = self->get_rate_id(self); - if (err_code <= 0) { - return ERR_TRANSVR_NOTSUPPORT; - } - /* Update and check */ - err_code = _check_by_mode(self, - &_sfp_update_attr_soft_rs0, - "sfp_get_soft_rs0"); - if (err_code <0){ - return err_code; - } - result = (self->soft_rs0 & bitmask); - if (result == bitmask) { - return 1; - } - if (result == 0) { - return 0; - } - return ERR_TRANSVR_UNEXCPT; -} - - -int -sfp_get_soft_rs1(struct transvr_obj_s *self){ - /* Note: - * SFP Soft RS(1) Select address - * A2h, offset: 118, bit 3 (begin form 0) - */ - int err_code = DEBUG_TRANSVR_INT_VAL; - int bit_shift = 3; - uint8_t result = 0x00; - uint8_t bitmask = (1 << bit_shift); - - /* Check rate identifier is supported */ - err_code = self->get_rate_id(self); - if (err_code <= 0) { - return ERR_TRANSVR_NOTSUPPORT; - } - /* Update and check */ - err_code = _check_by_mode(self, - &_sfp_update_attr_soft_rs1, - "sfp_get_soft_rs1"); - if (err_code <0){ - return err_code; - } - result = (self->soft_rs1 & bitmask); - if (result == bitmask) { - return 1; - } - if (result == 0) { - return 0; - } - return ERR_TRANSVR_UNEXCPT; -} - - -int -sfp_get_transvr_temp(struct transvr_obj_s *self, - char *buf_p) { - - int lmax = 8; - int err_code = DEBUG_TRANSVR_INT_VAL; - - err_code = _check_by_mode(self, - &_sfp_update_attr_curr_temp, - "sfp_get_transvr_temp"); - if (err_code < 0) { - return snprintf(buf_p, lmax, "%d\n", err_code); - } - if ((self->curr_temp[0]) == DEBUG_TRANSVR_HEX_VAL) { - return snprintf(buf_p, lmax, "%d\n", ERR_TRANSVR_UPDATE_FAIL); - } - return _common_count_temp(self->curr_temp[0], - self->curr_temp[1], - buf_p); -} - - -int -sfp_get_transvr_voltage(struct transvr_obj_s *self, - char *buf_p) { - - int lmax = 8; - int err_code = DEBUG_TRANSVR_INT_VAL; - - err_code = _check_by_mode(self, - &_sfp_update_attr_curr_voltage, - "sfp_get_transvr_voltage"); - if (err_code < 0) { - return snprintf(buf_p, lmax, "%d\n", err_code); - } - if ((self->curr_voltage[0]) == DEBUG_TRANSVR_HEX_VAL) { - return snprintf(buf_p, lmax, "%d\n", ERR_TRANSVR_UPDATE_FAIL); - } - /* Return Unit: 1 Volt */ - return _common_count_voltage(self->curr_voltage[0], - self->curr_voltage[1], - buf_p); -} - - -int -sfp_get_transvr_tx_bias(struct transvr_obj_s *self, - char *buf_p) { - - int lmax = 8; - int err_code = DEBUG_TRANSVR_INT_VAL; - - err_code = _check_by_mode(self, - &_sfp_update_attr_curr_tx_bias, - "sfp_get_transvr_tx_bias"); - if (err_code < 0) { - return snprintf(buf_p, lmax, "%d\n", err_code); - } - if ((self->curr_tx_bias[0]) == DEBUG_TRANSVR_HEX_VAL) { - return snprintf(buf_p, lmax, "%d\n", ERR_TRANSVR_UPDATE_FAIL); - } - /* Return Unit: 1 mA */ - return _common_count_tx_bias(self->curr_tx_bias[0], - self->curr_tx_bias[1], - buf_p); -} - - -int -sfp_get_transvr_tx_power(struct transvr_obj_s *self, - char *buf_p) { - - int lmax = 8; - int err_code = DEBUG_TRANSVR_INT_VAL; - - err_code = _check_by_mode(self, - &_sfp_update_attr_curr_tx_power, - "sfp_get_transvr_tx_power"); - if (err_code < 0) { - return snprintf(buf_p, lmax, "%d\n", err_code); - } - if ((self->curr_tx_bias[0]) == DEBUG_TRANSVR_HEX_VAL) { - return snprintf(buf_p, lmax, "%d\n", ERR_TRANSVR_UPDATE_FAIL); - } - /* Return Unit: 1 mW */ - return _common_count_tx_power(self->curr_tx_power[0], - self->curr_tx_power[1], - buf_p); -} - - -int -sfp_get_transvr_rx_power(struct transvr_obj_s *self, - char *buf_p) { - - int lmax = 8; - int err_code = DEBUG_TRANSVR_INT_VAL; - - err_code = _check_by_mode(self, - &_sfp_update_attr_curr_rx_power, - "sfp_get_transvr_rx_power"); - if (err_code < 0) { - return snprintf(buf_p, lmax, "%d\n", err_code); - } - if ((self->curr_tx_bias[0]) == DEBUG_TRANSVR_HEX_VAL) { - return snprintf(buf_p, lmax, "%d\n", ERR_TRANSVR_UPDATE_FAIL); - } - /* Return Unit: 1 mW */ - return _common_count_rx_power(self->curr_rx_power[0], - self->curr_rx_power[1], - buf_p); -} - - -int -sfp_get_transvr_rx_em(struct transvr_obj_s *self, - char *buf_p) { - - int limt = 8; - int err = DEBUG_TRANSVR_INT_VAL; - - err = _check_by_mode(self, - &_sfp_update_attr_rx_em, - "sfp_get_transvr_rx_em"); - if (err < 0) { - return snprintf(buf_p, limt, "%d\n", err); - } - if ((self->tx_eq[0]) == DEBUG_TRANSVR_HEX_VAL) { - return snprintf(buf_p, limt, "%d\n", ERR_TRANSVR_UPDATE_FAIL); - } - return snprintf(buf_p, limt, "0x%02x\n", self->rx_em[0]); -} - - -int -sfp_get_transvr_tx_eq(struct transvr_obj_s *self, - char *buf_p) { - - int limt = 8; - int err = DEBUG_TRANSVR_INT_VAL; - - err = _check_by_mode(self, - &_sfp_update_attr_tx_eq, - "sfp_get_transvr_tx_eq"); - if (err < 0) { - return snprintf(buf_p, limt, "%d\n", err); - } - if ((self->tx_eq[0]) == DEBUG_TRANSVR_HEX_VAL) { - return snprintf(buf_p, limt, "%d\n", ERR_TRANSVR_UPDATE_FAIL); - } - return snprintf(buf_p, limt, "0x%02x\n", self->tx_eq[0]); -} - - -int -_sfp_get_comp_extended(struct transvr_obj_s *self) { - /* Address: A0h / 36 - * Reference: SFF-8024 TABLE 4-4 - */ - if ((self->state == STATE_TRANSVR_CONNECTED) || - (self->state == STATE_TRANSVR_INIT) ) { - return (int)(self->transvr_comp_ext); - } - return ERR_TRANSVR_ABNORMAL; -} - - -int -__sfp_get_comp_attr(struct transvr_obj_s *self, - int array_offset) { - /* SFP Specification Compliance: A0h / 3-10 - * transvr_comp[0-7] = 3 - 10 - */ - if ((self->state == STATE_TRANSVR_CONNECTED) || - (self->state == STATE_TRANSVR_INIT) ) { - return (int)(self->transvr_comp[array_offset]); - } - return ERR_TRANSVR_ABNORMAL; -} - - -int -_sfp_get_comp_10g_eth_comp(struct transvr_obj_s *self) { - /* transvr_comp[0] = address A0h / 3 - * - * 3 7: 10G Base-ER - * 3 6: 10GBASE-LRM - * 3 5: 10GBASE-LR - * 3 4: 10GBASE-SR - */ - int bitmask = 0xf0; /* 11110000 */ - return (__sfp_get_comp_attr(self, 0) & bitmask); -} - - -int -_sfp_get_comp_1g_eth_comp(struct transvr_obj_s *self) { - /* transvr_comp[3] = address A0h / 6 - * - * 6 7: BASE-PX *3 - * 6 6: BASE-BX10 *3 - * 6 5: 100BASE-FX - * 6 4: 100BASE-LX/LX10 - * 6 3: 1000BASE-T - * 6 2: 1000BASE-CX - * 6 1: 1000BASE-LX *3 - * 6 0: 1000BASE-SX - */ - return __sfp_get_comp_attr(self, 3); -} - - -int -_sfp_get_cable_tech(struct transvr_obj_s *self) { - /* transvr_comp[5] = address A0h / 8 - * - * 8 3: Active Cable *8 - * 8 2: Passive Cable *8 - */ - int bitmask = 0x0c; /* 00001100 */ - return (__sfp_get_comp_attr(self, 5) & bitmask); -} - - -int -sfp_get_comp_eth_1(struct transvr_obj_s *self){ - - int err_code = _check_by_mode(self, - &_common_update_attr_transvr_comp, - "sfp_get_comp_eth_1"); - if (err_code < 0){ - return err_code; - } - return _sfp_get_comp_1g_eth_comp(self); -} - - -int -sfp_get_comp_eth_10(struct transvr_obj_s *self){ - - int err_code = _check_by_mode(self, - &_common_update_attr_transvr_comp, - "sfp_get_comp_eth_10"); - if (err_code < 0){ - return err_code; - } - return _sfp_get_comp_10g_eth_comp(self); -} - - -int -_sfp_get_connector_type(struct transvr_obj_s *self) { - /* Address: A0h / 2 - * Reference: SFF-8024 TABLE 4-3 - */ - if ((self->state == STATE_TRANSVR_CONNECTED) || - (self->state == STATE_TRANSVR_INIT) ) { - return (int)(self->connector); - } - return ERR_TRANSVR_ABNORMAL; -} - - -int -sfp_get_wavelength(struct transvr_obj_s *self, - char *buf_p) { - /* [Note] Optical and Cable Variants Specification Compliance (SFF-8472) - * [Addr] A0h, Bytes 60-61 - * [Note] For optical variants, as defined by having zero's in A0h Byte 8 - * bits 2 and 3, Bytes 60 and 61 denote nominal transmitter output - * wavelength at room temperature. 16 bit value with byte 60 as high - * order byte and byte 61 as low order byte. The laser wavelength is - * equal to the 16 bit integer value in nm. This field allows the user - * to read the laser wavelength directly, so it is not necessary to - * infer it from the Transceiver Codes A0h Bytes 3 to 10 (see Table - * 5-3). This also allows specification of wavelengths not covered - * in the Transceiver Codes, such as those used in coarse WDM systems. - * - * For passive and active cable variants, a value of 00h for both A0h - * Byte 60 and Byte 61 denotes laser wavelength or cable specification - * compliance is unspecified. - */ - - int lmax = 8; - int err_code = DEBUG_TRANSVR_INT_VAL; - - err_code = _check_by_mode(self, - &_common_update_attr_wavelength, - "common_get_wavelength"); - if (err_code < 0) { - return snprintf(buf_p, lmax, "%d\n", err_code); - } - if ((self->wavelength[0]) == DEBUG_TRANSVR_HEX_VAL) { - return snprintf(buf_p, lmax, "%d\n", ERR_TRANSVR_UPDATE_FAIL); - } - /* unit: 1 um */ - return snprintf(buf_p, lmax, "%d\n", - _common_count_wavelength(self, - self->wavelength[0], - self->wavelength[1])); -} - - -int -sfp_get_1g_rj45_extphy_offset(struct transvr_obj_s *self, char *buf) { - - if (self->state != STATE_TRANSVR_CONNECTED) { - return ERR_TRANSVR_UNPLUGGED; - } - if ((self->info != TRANSVR_CLASS_BASE_T_1000) && - (self->info != TRANSVR_CLASS_BASE_T_1000_up) ){ - return ERR_TRANSVR_NOTSUPPORT; - } - return snprintf(buf, LEN_TRANSVR_S_STR, "0x%02x\n", self->extphy_offset); -} - - -int -sfp_get_1g_rj45_extphy_reg(struct transvr_obj_s *self, char *buf) { - - int i = 0; - int ret = 0; - int retry = 3; - int delay = 200; - - if (self->state != STATE_TRANSVR_CONNECTED) { - return ERR_TRANSVR_UNPLUGGED; - } - if ((self->info != TRANSVR_CLASS_BASE_T_1000) && - (self->info != TRANSVR_CLASS_BASE_T_1000_up) ){ - return ERR_TRANSVR_NOTSUPPORT; - } - if (_common_setup_page(self, VAL_TRANSVR_EXTPHY_ADDR_56, - -1, self->extphy_offset, 1, 0) < 0) { - return -EIO; - } - for (i=0; ii2c_client_p, self->extphy_offset); - if (ret >=0) { - goto ok_sfp_get_1g_rj45_extphy_reg; - } - msleep(delay); - } - SWPS_INFO("%s: retry:%d fail :%s :0x%02x\n", - __func__, retry, self->swp_name, self->extphy_offset); - return -EIO; - -ok_sfp_get_1g_rj45_extphy_reg: - ret = ((ret & 0x00ff) << 8) | ((ret & 0xff00) >> 8); - return snprintf(buf, LEN_TRANSVR_S_STR, "0x%04x\n", ret); -} - - -int -__qsfp_get_power_cls(struct transvr_obj_s *self, - int direct_access){ - - int err_code; - uint8_t detect_val; - - /* Detect and Update power class attribute */ - if (direct_access){ - err_code = _check_by_mode(self, - &_common_update_attr_extended_id, - "__qsfp_get_power_cls"); - } else { - err_code = self->ext_id; - } - if (err_code <0){ - return err_code; - } - if (err_code == DEBUG_TRANSVR_HEX_VAL){ - return ERR_TRANSVR_UPDATE_FAIL; - } - /* Clean data */ - detect_val = self->ext_id; - SWP_BIT_CLEAR(detect_val, 2); /* Bit2: CDR RX present */ - SWP_BIT_CLEAR(detect_val, 3); /* Bit3: CDR TX present */ - SWP_BIT_CLEAR(detect_val, 4); /* Bit4: CLEI present */ - SWP_BIT_CLEAR(detect_val, 5); /* Bit5: reserved */ - /* Identify power class */ - switch (detect_val) { - case 0: /* Class_1: 00000000 */ - return 1; - case 64: /* Class_2: 01000000 */ - return 2; - case 128: /* Class_3: 10000000 */ - return 3; - case 192: /* Class_4: 11000000 */ - return 4; - case 1: /* Class_5: 00000001 */ - case 193: /* Class_5: 11000001 */ - return 5; - case 2: /* Class_6: 00000010 */ - case 194: /* Class_6: 11000010 */ - return 6; - case 3: /* Class_7: 00000011 */ - case 195: /* Class_7: 11000011 */ - return 7; - default: - break; - } - SWPS_INFO("%s: Detect undefined power class:%d\n", __func__, detect_val); - return ERR_TRANSVR_UNDEFINED; -} - - -int -qsfp_get_power_cls(struct transvr_obj_s *self) { - return __qsfp_get_power_cls(self, 1); -} - - -int -__qsfp_get_cdr_present(struct transvr_obj_s *self, - int direct_access){ - - int retval; - int BIT_SHIFT = 2; - int BIT_MASK = 0x3; - - /* Detect and Update power class attribute */ - if (direct_access) { - retval = _check_by_mode(self, - &_common_update_attr_extended_id, - "__qsfp_get_cdr_present"); - if (retval < 0){ - return retval; - } - } - retval = self->ext_id; - if (retval == DEBUG_TRANSVR_HEX_VAL){ - return ERR_TRANSVR_UPDATE_FAIL; - } - /* Clean data and return */ - return (int)(retval >> BIT_SHIFT & BIT_MASK); -} - - -int -qsfp_get_cdr_present(struct transvr_obj_s *self) { - return __qsfp_get_cdr_present(self, 1); -} - - -int -qsfp_get_cdr(struct transvr_obj_s *self){ - - int err_code = _check_by_mode(self, - &_qsfp_update_attr_cdr, - "qsfp_get_cdr"); - if (err_code <0){ - return err_code; - } - - return self->cdr; -} - - -int -__qsfp_get_comp_attr(struct transvr_obj_s *self, - int array_offset) { - /* QSFP Specification Compliance: 00h / 131-138 - * transvr_comp[0-7] = 131 - 138 - */ - if ((self->state == STATE_TRANSVR_CONNECTED) || - (self->state == STATE_TRANSVR_INIT) ) { - return (int)(self->transvr_comp[array_offset]); - } - return ERR_TRANSVR_ABNORMAL; -} - - -int -_qsfp_get_comp_10_40_100_ethernet(struct transvr_obj_s *self) { - /* transvr_comp[0] = address 00h / 131 - * - * 131 7: Extended: See section 6.3.23. The Extended Specification Compliance - * Codes are maintained in the Transceiver Management section of SFF- - * 8024. - * 131 6: 10GBASE-LRM - * 131 5: 10GBASE-LR - * 131 4: 10GBASE-SR - * 131 3: 40GBASE-CR4 - * 131 2: 40GBASE-SR4 - * 131 1: 40GBASE-LR4 - * 131 0: 40G Active Cable (XLPPI) - */ - return __qsfp_get_comp_attr(self, 0); -} - - -int -_qsfp_get_comp_sonet(struct transvr_obj_s *self) { - /* transvr_comp[1] = address 00h / 132 - * - * 132 7-3: Reserved - * 132 2: OC 48, long reach - * 132 1: OC 48, intermediate reach - * 132 0: OC 48 short reach - */ - return __qsfp_get_comp_attr(self, 1); -} - - -int -_qsfp_get_comp_sas_sata(struct transvr_obj_s *self) { - /* transvr_comp[1] = address 00h / 132 - * - * 133 7: SAS 24.0 Gb/s - * 133 6: SAS 12.0 Gb/s - * 133 5: SAS 6.0 Gb/s - * 133 4: SAS 3.0 Gb/s - * 133 3-0: Reserved - */ - return __qsfp_get_comp_attr(self, 2); -} - - -int -_qsfp_get_comp_ethernet(struct transvr_obj_s *self) { - /* transvr_comp[1] = address 00h / 132 - * - * 134 7-4: Reserved - * 134 3: 1000BASE-T - * 134 2: 1000BASE-CX - * 134 1: 1000BASE-LX - * 134 0: 1000BASE-SX - */ - return __qsfp_get_comp_attr(self, 3); -} - - -int -_qsfp_get_comp_fc_link_length(struct transvr_obj_s *self) { - /* transvr_comp[1] = address 00h / 132 - * - * 135 7: Very long distance (V) - * 135 6: Short distance (S) - * 135 5: Intermediate distance (I) - * 135 4: Long distance (L) - * 135 3: Medium (M) - */ - int mask = 0xFC; /* 11111100 */ - return (__qsfp_get_comp_attr(self, 4) & mask); -} - - -int -_qsfp_get_comp_fc_trans_tech(struct transvr_obj_s *self) { - /* transvr_comp[1] = address 00h / 132 - * - * 135 2: Reserved - * 135 1: Longwave laser (LC) - * 135 0: Electrical inter-enclosure (EL) - * - * 136 7: Electrical intra-enclosure - * 136 6: Shortwave laser w/o OFC (SN) - * 136 5: Shortwave laser w OFC (SL) - * 136 4: Longwave Laser (LL) - * 136 3-0: Reserved - * - * return value = [bit 8-15:addr 135][bit 0-7:addr 136] - */ - int mask_135 = 7; /* 00000111 */ - int val_135 = (__qsfp_get_comp_attr(self, 4) & mask_135); - int val_136 = __qsfp_get_comp_attr(self, 5); - return ((val_135 << 7) + val_136); -} - - -int -_qsfp_get_comp_fc_trans_media(struct transvr_obj_s *self) { - /* transvr_comp[1] = address 00h / 132 - * - * 137 7: Twin Axial Pair (TW) - * 137 6: Shielded Twisted Pair (TP) - * 137 5: Miniature Coax (MI) - * 137 4: Video Coax (TV) - * 137 3: Multi-mode 62.5 m (M6) - * 137 2: Multi-mode 50 m (M5) - * 137 1: Multi-mode 50 um (OM3) - * 137 0: Single Mode (SM) - */ - return __qsfp_get_comp_attr(self, 6); -} - - -int -_qsfp_get_comp_fc_speed(struct transvr_obj_s *self) { - /* transvr_comp[1] = address 00h / 132 - * - * 138 7: 1200 MBps (per channel) - * 138 6: 800 MBps - * 138 5: 1600 MBps (per channel) - * 138 4: 400 MBps - * 138 3: 3200 MBps (per channel) - * 138 2: 200 MBps - * 138 1: Extended: See section 6.3.23. The Extended Specification - * Compliance Codes are maintained in the Transceiver Management - * section of SFF-8024. - * 138 0: 100 MBps - */ - return __qsfp_get_comp_attr(self, 7); -} - - -int -_qsfp_get_comp_extended(struct transvr_obj_s *self) { - /* Address: 00h / 192 - * Reference: SFF-8024 TABLE 4-4 - */ - if ((self->state == STATE_TRANSVR_CONNECTED) || - (self->state == STATE_TRANSVR_INIT) ) { - return (int)(self->transvr_comp_ext); - } - return ERR_TRANSVR_ABNORMAL; -} - - -int -qsfp_get_comp_eth(struct transvr_obj_s *self){ - - int err_code = _check_by_mode(self, - &_common_update_attr_transvr_comp, - "qsfp_get_comp_eth"); - if (err_code < 0){ - return err_code; - } - return _qsfp_get_comp_ethernet(self); -} - - -int -qsfp_get_comp_10_40(struct transvr_obj_s *self) { - - int err_code = _check_by_mode(self, - &_common_update_attr_transvr_comp, - "qsfp_get_comp_10_40"); - if (err_code < 0){ - return err_code; - } - return _qsfp_get_comp_10_40_100_ethernet(self); -} - - -int -_qsfp_get_connector_type(struct transvr_obj_s *self) { - /* Address: 00h / 130 - * Reference: SFF-8024 TABLE 4-3 - */ - if ((self->state == STATE_TRANSVR_CONNECTED) || - (self->state == STATE_TRANSVR_INIT) ) { - return (int)(self->connector); - } - return ERR_TRANSVR_ABNORMAL; -} - - -int -qsfp_get_transvr_temp(struct transvr_obj_s *self, - char *buf_p) { - - int lmax = 8; - int err_code = DEBUG_TRANSVR_INT_VAL; - - err_code = _check_by_mode(self, - &_qsfp_update_attr_curr_temp, - "qsfp_get_transvr_temp"); - if (err_code < 0) { - return snprintf(buf_p, lmax, "%d\n", err_code); - } - if ((self->curr_temp[0]) == DEBUG_TRANSVR_HEX_VAL) { - return snprintf(buf_p, lmax, "%d\n", ERR_TRANSVR_UPDATE_FAIL); - } - return _common_count_temp(self->curr_temp[0], - self->curr_temp[1], - buf_p); -} - - -int -qsfp_get_transvr_voltage(struct transvr_obj_s *self, - char *buf_p) { - - int lmax = 8; - int err_code = DEBUG_TRANSVR_INT_VAL; - - err_code = _check_by_mode(self, - &_qsfp_update_attr_curr_voltage, - "qsfp_get_transvr_voltage"); - if (err_code < 0) { - return snprintf(buf_p, lmax, "%d\n", err_code); - } - if ((self->curr_voltage[0]) == DEBUG_TRANSVR_HEX_VAL) { - return snprintf(buf_p, lmax, "%d\n", ERR_TRANSVR_UPDATE_FAIL); - } - /* Return Unit: 1 Volt */ - return _common_count_voltage(self->curr_voltage[0], - self->curr_voltage[1], - buf_p); -} - - -int -qsfp_get_transvr_tx_eq(struct transvr_obj_s *self, - char *buf_p) { - - int limt = 8; - int err = DEBUG_TRANSVR_INT_VAL; - - err = _check_by_mode(self, - &_qsfp_update_attr_tx_eq, - "qsfp_get_transvr_tx_eq"); - if (err < 0) { - return snprintf(buf_p, limt, "%d\n", err); - } - if ((self->tx_eq[0]) == DEBUG_TRANSVR_HEX_VAL) { - return snprintf(buf_p, limt, "%d\n", ERR_TRANSVR_UPDATE_FAIL); - } - return snprintf(buf_p, limt, "0x%02x%02x\n", - self->tx_eq[0], self->tx_eq[1]); -} - - -int -qsfp_get_transvr_rx_am(struct transvr_obj_s *self, - char *buf_p) { - - int limt = 8; - int err = DEBUG_TRANSVR_INT_VAL; - - err = _check_by_mode(self, - &_qsfp_update_attr_rx_am, - "qsfp_get_transvr_rx_am"); - if (err < 0) { - return snprintf(buf_p, limt, "%d\n", err); - } - if ((self->rx_am[0]) == DEBUG_TRANSVR_HEX_VAL) { - return snprintf(buf_p, limt, "%d\n", ERR_TRANSVR_UPDATE_FAIL); - } - return snprintf(buf_p, limt, "0x%02x%02x\n", - self->rx_am[0], self->rx_am[1]); -} - - -int -qsfp_get_transvr_rx_em(struct transvr_obj_s *self, - char *buf_p) { - - int limt = 8; - int err = DEBUG_TRANSVR_INT_VAL; - - err = _check_by_mode(self, - &_qsfp_update_attr_rx_em, - "qsfp_get_transvr_rx_em"); - if (err < 0) { - return snprintf(buf_p, limt, "%d\n", err); - } - if ((self->rx_em[0]) == DEBUG_TRANSVR_HEX_VAL) { - return snprintf(buf_p, limt, "%d\n", ERR_TRANSVR_UPDATE_FAIL); - } - return snprintf(buf_p, limt, "0x%02x%02x\n", - self->rx_em[0], self->rx_em[1]); -} - - -int -_qsfp_get_channel_diag(uint8_t *data_array, - int (*count_func)(uint8_t high_byte, uint8_t low_byte, char *buf_p), - char *ch_name, - char *result_p) { - int i, high, low; - int len_max = 128; - char ch_buf[4][16] = { DEBUG_TRANSVR_STR_VAL, - DEBUG_TRANSVR_STR_VAL, - DEBUG_TRANSVR_STR_VAL, - DEBUG_TRANSVR_STR_VAL }; - - for (i=0; i<4; i++) { - high = (i*2); - low = ((i*2) + 1); - count_func(data_array[high], data_array[low], ch_buf[i]); - } - return snprintf(result_p, len_max, - "%s-%d:%s%s-%d:%s%s-%d:%s%s-%d:%s", - ch_name, 1, ch_buf[0], - ch_name, 2, ch_buf[1], - ch_name, 3, ch_buf[2], - ch_name, 4, ch_buf[3]); -} - - -int -qsfp_get_soft_rx_los(struct transvr_obj_s *self, - char *buf_p) { - - int lmax = 8; - int mask = 0x0f; /* Bit 0 ~ Bit 3 */ - int err_code = DEBUG_TRANSVR_INT_VAL; - - err_code = _check_by_mode(self, - &_qsfp_update_attr_soft_rx_los, - "qsfp_get_soft_rx_los"); - if (err_code < 0) { - return snprintf(buf_p, lmax, "%d\n", err_code); - } - return snprintf(buf_p, lmax, "0x%02x\n", (self->rx_los & mask)); -} - - -int -qsfp_get_soft_tx_disable(struct transvr_obj_s *self, - char *buf_p) { - - int lmax = 8; - int mask = 0x0f; /* Bit 0 ~ Bit 3 */ - int err_code = DEBUG_TRANSVR_INT_VAL; - - err_code = _check_by_mode(self, - &_qsfp_update_attr_soft_tx_disable, - "qsfp_get_soft_tx_disable"); - if (err_code < 0) { - return snprintf(buf_p, lmax, "%d\n", err_code); - } - return snprintf(buf_p, lmax, "0x%02x\n", (self->tx_disable & mask)); -} - - -int -qsfp_get_soft_tx_fault(struct transvr_obj_s *self, - char *buf_p) { - - int lmax = 8; - int mask = 0x0f; /* Bit 0 ~ Bit 3 */ - int err_code = DEBUG_TRANSVR_INT_VAL; - - err_code = _check_by_mode(self, - &_qsfp_update_attr_soft_tx_fault, - "qsfp_get_soft_tx_fault"); - if (err_code < 0) { - return snprintf(buf_p, lmax, "%d\n", err_code); - } - return snprintf(buf_p, lmax, "0x%02x\n", (self->tx_fault & mask)); -} - - -int -qsfp_get_auto_tx_disable(struct transvr_obj_s *self, - char *buf_p) { - - if (self->auto_tx_disable == VAL_TRANSVR_FUNCTION_DISABLE) { - return snprintf(buf_p, LEN_TRANSVR_S_STR, - "%d\n", ERR_TRANSVR_FUNC_DISABLE); - } - return snprintf(buf_p, LEN_TRANSVR_S_STR, - "0x%02x\n", self->auto_tx_disable); -} - - -int -qsfp_get_transvr_tx_bias(struct transvr_obj_s *self, - char *buf_p) { - - int lmax = 8; - int err_code = DEBUG_TRANSVR_INT_VAL; - char *ch_name = "TX"; - - err_code = _check_by_mode(self, - &_qsfp_update_attr_curr_tx_bias, - "qsfp_get_transvr_tx_bias"); - if (err_code < 0) { - return snprintf(buf_p, lmax, "%d\n", err_code); - } - if ((self->curr_tx_bias[0]) == DEBUG_TRANSVR_HEX_VAL) { - return snprintf(buf_p, lmax, "%d\n", ERR_TRANSVR_UPDATE_FAIL); - } - /* Return Unit: 1 mA */ - return _qsfp_get_channel_diag(self->curr_tx_bias, - _common_count_tx_bias, - ch_name, - buf_p); -} - - -int -qsfp_get_transvr_tx_power(struct transvr_obj_s *self, - char *buf_p) { - - int lmax = 8; - int err_code = DEBUG_TRANSVR_INT_VAL; - char *ch_name = "TX"; - - err_code = _check_by_mode(self, - &_qsfp_update_attr_curr_tx_power, - "qsfp_get_transvr_tx_power"); - if (err_code < 0) { - return snprintf(buf_p, lmax, "%d\n", err_code); - } - if ((self->curr_tx_power[0]) == DEBUG_TRANSVR_HEX_VAL) { - return snprintf(buf_p, lmax, "%d\n", ERR_TRANSVR_UPDATE_FAIL); - } - /* Return Unit: 1 mW */ - return _qsfp_get_channel_diag(self->curr_tx_power, - _common_count_tx_power, - ch_name, - buf_p); -} - - -int -qsfp_get_transvr_rx_power(struct transvr_obj_s *self, - char *buf_p) { - - int lmax = 8; - int err_code = DEBUG_TRANSVR_INT_VAL; - char *ch_name = "RX"; - - err_code = _check_by_mode(self, - &_qsfp_update_attr_curr_rx_power, - "qsfp_get_transvr_rx_power"); - if (err_code < 0) { - return snprintf(buf_p, lmax, "%d\n", err_code); - } - if ((self->curr_tx_power[0]) == DEBUG_TRANSVR_HEX_VAL) { - return snprintf(buf_p, lmax, "%d\n", ERR_TRANSVR_UPDATE_FAIL); - } - /* Return Unit: 1 mW */ - return _qsfp_get_channel_diag(self->curr_rx_power, - _common_count_rx_power, - ch_name, - buf_p); -} - - -int -qsfp_get_wavelength(struct transvr_obj_s *self, - char *buf_p) { - /* [Desc] Wavelength or Copper Cable Attenuation (SFF-8636) - * [Addr] 00h 186-187 - * [Note] - * For optical free side devices, this parameter identifies the nominal - * transmitter output wavelength at room temperature. This parameter is - * a 16-bit hex value with Byte 186 as high order byte and Byte 187 as - * low order byte. The laser wavelength is equal to the 16-bit integer value - * divided by 20 in nm (units of 0.05 nm). This resolution should be adequate - * to cover all relevant wavelengths yet provide enough resolution for all - * expected DWDM applications. For accurate representation of controlled - * wavelength applications, this value should represent the center of the - * guaranteed wavelength range. - * If the free side device is identified as copper cable these registers will - * be used to define the cable attenuation. An indication of 0 dB attenuation - * refers to the case where the attenuation is not known or is unavailable. - * Byte 186 (00-FFh) is the copper cable attenuation at 2.5 GHz in units of 1 dB. - * Byte 187 (00-FFh) is the copper cable attenuation at 5.0 GHz in units of 1 dB. - */ - int lmax = 8; - int err_code = DEBUG_TRANSVR_INT_VAL; - - err_code = _check_by_mode(self, - &_common_update_attr_wavelength, - "common_get_wavelength"); - if (err_code < 0) { - return snprintf(buf_p, lmax, "%d\n", err_code); - } - if ((self->wavelength[0]) == DEBUG_TRANSVR_HEX_VAL) { - return snprintf(buf_p, lmax, "%d\n", ERR_TRANSVR_UPDATE_FAIL); - } - /* unit: 1 um */ - return snprintf(buf_p, lmax, "%d\n", - _common_count_wavelength(self, - self->wavelength[0], - self->wavelength[1])); -} - - -/* Public Function for Setup Features - */ -static int -__sfp_set_soft_rs(struct transvr_obj_s *self, - int input_val, - int address, - int page, - int offset, - int bit_shift, - uint8_t *attr_p, - char *caller, - int show_err) { - - int retval = ERR_TRANSVR_UNEXCPT; - int err_code = ERR_TRANSVR_UNEXCPT; - char *err_msg = DEBUG_TRANSVR_STR_VAL; - uint8_t update_val = (*attr_p); - - switch (input_val) { - case 0: - SWP_BIT_CLEAR(update_val, bit_shift); - break; - case 1: - SWP_BIT_SET(update_val, bit_shift); - break; - default: - retval = ERR_TRANSVR_UNEXCPT; - err_code = ERR_TRANSVR_UNEXCPT; - err_msg = "Exception occurs"; - goto err_private_sfp_set_soft_rs_1; - } - err_code = _common_set_uint8_attr(self, - address, - page, - offset, - update_val, - attr_p, - caller, - show_err); - if (err_code < 0) { - retval = err_code; - err_msg = "Write data via i2c fail!"; - goto err_private_sfp_set_soft_rs_1; - } - (*attr_p) = update_val; - return 0; - -err_private_sfp_set_soft_rs_1: - if (show_err) { - SWPS_INFO("%s: %s :%d :%s\n :%d\n", - __func__, err_msg, err_code, self->swp_name, input_val); - } - return retval; -} - - -static int -_sfp_set_soft_rs(struct transvr_obj_s *self, - int input_val, - int address, - int page, - int offset, - int bit_shift, - int (*attr_update_func)(struct transvr_obj_s *self, int show_err), - uint8_t *attr_p, - char *caller, - int show_err) { - - int retval = ERR_TRANSVR_UNEXCPT; - int err_code = ERR_TRANSVR_UNEXCPT; - char *err_msg = DEBUG_TRANSVR_STR_VAL; - - /* Check input value */ - if ((input_val != 0) && (input_val != 1)){ - retval = ERR_TRANSVR_BADINPUT; - err_code = ERR_TRANSVR_BADINPUT; - err_msg = "Input range incorrect!"; - goto err_common_sfp_set_soft_rs_1; - } - /* Check rate identifier is supported */ - err_code = self->get_rate_id(self); - if (err_code <= 0) { - switch (err_code) { - case 0: - retval = ERR_TRANSVR_NOTSUPPORT; - err_msg = "Not support this feature"; - break; - case ERR_TRANSVR_UNINIT: - retval = ERR_TRANSVR_UNINIT; - err_msg = "Check CDR present fail!"; - break; - case ERR_TRANSVR_UNPLUGGED: - retval = ERR_TRANSVR_UNPLUGGED; - err_msg = "Transceiver unplugged!"; - break; - default: - retval = err_code; - err_msg = "Check Rate_ID fail!"; - break; - } - goto err_common_sfp_set_soft_rs_1; - } - /* Check and update */ - err_code = _check_by_mode(self, - attr_update_func, - caller); - if ( (err_code < 0) || - ((*attr_p) == DEBUG_TRANSVR_HEX_VAL) ){ - retval = err_code; - err_msg = "Get current value fail!"; - goto err_common_sfp_set_soft_rs_1; - } - /* Generate and update value */ - return __sfp_set_soft_rs(self, - input_val, - address, - page, - offset, - bit_shift, - attr_p, - caller, - show_err); - -err_common_sfp_set_soft_rs_1: - if (show_err) { - SWPS_INFO("%s: %s :%d :%s\n :%d\n", - __func__, err_msg, err_code, self->swp_name, input_val); - } - return retval; -} - - -int -sfp_set_soft_rs0(struct transvr_obj_s *self, - int input_val) { - /* Note: - * SFP Soft Rate_Select Select RX ["RS(0)"] address - * A2h, offset: 110, bit 3 - */ - int bit_shift = 3; - int show_err = 1; - return _sfp_set_soft_rs(self, - input_val, - self->eeprom_map_p->addr_soft_rs0, - self->eeprom_map_p->page_soft_rs0, - self->eeprom_map_p->offset_soft_rs0, - bit_shift, - &_sfp_update_attr_soft_rs0, - &(self->soft_rs0), - "sfp_set_soft_rs0", - show_err); -} - - -int -sfp_set_soft_rs1(struct transvr_obj_s *self, - int input_val) { - /* Note: - * SFP Soft Rate_Select Select RX ["RS(1)"] address - * A2h, offset: 118, bit 3 - */ - int bit_shift = 3; - int show_err = 1; - return _sfp_set_soft_rs(self, - input_val, - self->eeprom_map_p->addr_soft_rs1, - self->eeprom_map_p->page_soft_rs1, - self->eeprom_map_p->offset_soft_rs1, - bit_shift, - &_sfp_update_attr_soft_rs1, - &(self->soft_rs1), - "sfp_set_soft_rs1", - show_err); -} - - -int -__sfp_set_tx_eq(struct transvr_obj_s *self, - int input, - int show_e) { - - int err = DEBUG_TRANSVR_INT_VAL; - char *emsg = DEBUG_TRANSVR_STR_VAL; - uint8_t setv = DEBUG_TRANSVR_HEX_VAL; - - if ((input < 0) || (input > 0xFF)) { - emsg = "input incorrect"; - err = ERR_TRANSVR_BADINPUT; - goto err_sfp_set_tx_eq; - } - setv = (uint8_t)input; - if (self->tx_eq[0] == setv) { - return 0; - } - err = _common_set_uint8_attr(self, - self->eeprom_map_p->addr_tx_eq, - self->eeprom_map_p->page_tx_eq, - self->eeprom_map_p->offset_tx_eq, - setv, - &(self->tx_eq[0]), - "_sfp_set_tx_eq", - show_e); - if (err < 0) { - emsg = "set_uint8_attr fail"; - goto err_sfp_set_tx_eq; - } - return 0; - -err_sfp_set_tx_eq: - if (show_e) { - SWPS_INFO("%s: %s :%d\n", __func__, emsg, input); - } - return err; -} - - -int -_sfp_set_tx_eq(struct transvr_obj_s *self, - int input, - int show_e) { - - uint8_t tmp; - int i = 0; - int retry = 3; - - for (i=0; itx_eq[0]; - if (_sfp_update_attr_tx_eq(self, show_e) < 0){ - continue; - } - if (self->tx_eq[0] == tmp){ - return 0; - } - } - return ERR_TRANSVR_UPDATE_FAIL; -} - - -int -sfp_set_tx_eq(struct transvr_obj_s *self, - int input) { - - int err = _check_by_mode(self, - &_sfp_update_attr_tx_eq, - "sfp_set_tx_eq"); - if (err < 0) { - SWPS_DEBUG("%s: check fail :%d\n", __func__, err); - return err; - } - return _sfp_set_tx_eq(self, input, 1); -} - - -int -__sfp_set_rx_em(struct transvr_obj_s *self, - int input, - int show_e) { - - int err = DEBUG_TRANSVR_INT_VAL; - char *emsg = DEBUG_TRANSVR_STR_VAL; - uint8_t setv = DEBUG_TRANSVR_HEX_VAL; - - if ((input < 0) || (input > 0xFF)) { - emsg = "input incorrect"; - err = ERR_TRANSVR_BADINPUT; - goto err_sfp_set_rx_em; - } - setv = (uint8_t)input; - if (self->rx_em[0] == setv) { - return 0; - } - err = _common_set_uint8_attr(self, - self->eeprom_map_p->addr_rx_em, - self->eeprom_map_p->page_rx_em, - self->eeprom_map_p->offset_rx_em, - setv, - &(self->rx_em[0]), - "_sfp_set_rx_em", - show_e); - if (err < 0) { - emsg = "set_uint8_attr fail"; - goto err_sfp_set_rx_em; - } - return 0; - -err_sfp_set_rx_em: - if (show_e) { - SWPS_INFO("%s: %s :%d\n", __func__, emsg, input); - } - return err; -} - - -int -_sfp_set_rx_em(struct transvr_obj_s *self, - int input, - int show_e) { - - uint8_t tmp; - int i = 0; - int retry = 3; - - for (i=0; irx_em[0]; - if (_sfp_update_attr_rx_em(self, show_e) < 0){ - continue; - } - if (self->rx_em[0] == tmp){ - return 0; - } - } - return -1; -} - - -int -sfp_set_rx_em(struct transvr_obj_s *self, - int input) { - - int err = _check_by_mode(self, - &_sfp_update_attr_rx_em, - "sfp_set_rx_em"); - if (err < 0) { - SWPS_DEBUG("%s: check fail :%d\n", __func__, err); - return err; - } - return _sfp_set_rx_em(self, input, 1); -} - - -int -sfp_set_1g_rj45_extphy_offset(struct transvr_obj_s *self, - int input) { - - if (self->state != STATE_TRANSVR_CONNECTED) { - return ERR_TRANSVR_UNPLUGGED; - } - if ((self->info != TRANSVR_CLASS_BASE_T_1000) && - (self->info != TRANSVR_CLASS_BASE_T_1000_up) ){ - return ERR_TRANSVR_NOTSUPPORT; - } - if ((input < 0) || (input > 0xff)) { - return ERR_TRANSVR_BADINPUT; - } - self->extphy_offset = (uint8_t)input; - return 0; -} - - -int -sfp_set_1g_rj45_extphy_reg(struct transvr_obj_s *self, - int input) { - - int i = 0; - int retry = 3; - int delay = 200; - uint16_t tmp = 0; - - if (self->state != STATE_TRANSVR_CONNECTED) { - return ERR_TRANSVR_UNPLUGGED; - } - if ((self->info != TRANSVR_CLASS_BASE_T_1000) && - (self->info != TRANSVR_CLASS_BASE_T_1000_up) ){ - return ERR_TRANSVR_NOTSUPPORT; - } - if ((input < 0) || (input > 0xffff)) { - return ERR_TRANSVR_BADINPUT; - } - tmp = ((input & 0x00ff) << 8) | ((input & 0xff00) >> 8); - if (_common_setup_page(self, VAL_TRANSVR_EXTPHY_ADDR_56, - -1, self->extphy_offset, 1, 0) < 0) { - return -EIO; - } - for (i=0; i<=retry; i++) { - if (i2c_smbus_write_word_data(self->i2c_client_p, - self->extphy_offset, - tmp) >= 0) { - return 0; - } - msleep(delay); - } - SWPS_INFO("%s: retry:%d fail :%s :0x%02x\n", - __func__, retry, self->swp_name, self->extphy_offset); - return -EIO; -} - - -static int -__qsfp_set_cdr(struct transvr_obj_s *self, - int input_val, - int show_err) { - - uint8_t update_val; - int CDR_FEATURE_SUPPORTED = 0x3; - int retval = ERR_TRANSVR_UNEXCPT; - int err_code = ERR_TRANSVR_UNEXCPT; - char *err_msg = DEBUG_TRANSVR_STR_VAL; - char *func_name = "__qsfp_set_cdr"; - - /* Check input value */ - if ((input_val < 0) || (input_val > 0xff)){ - retval = ERR_TRANSVR_BADINPUT; - err_code = ERR_TRANSVR_BADINPUT; - err_msg = "Input range incorrect!"; - goto err_qsfp_set_cdr_1; - } - update_val = (uint8_t)input_val; - /* Check CDR supported by transceiver */ - err_code = qsfp_get_cdr_present(self); - if (err_code < 0) { - retval = err_code; - switch (err_code) { - case ERR_TRANSVR_UNINIT: - err_msg = "Check CDR present fail!"; - break; - case ERR_TRANSVR_UNPLUGGED: - err_msg = "Transceiver unplugged!"; - break; - default: - err_msg = "Check CDR present fail!"; - break; - } - goto err_qsfp_set_cdr_1; - } - if (err_code != CDR_FEATURE_SUPPORTED) { - retval = ERR_TRANSVR_NOTSUPPORT; - err_msg = "This transceiver not support CDR!"; - goto err_qsfp_set_cdr_1; - } - /* Check and update */ - err_code = _check_by_mode(self, - &_qsfp_update_attr_cdr, - func_name); - if ( (err_code < 0) || - (self->cdr == DEBUG_TRANSVR_HEX_VAL) ){ - retval = err_code; - err_msg = "Get current value fail!"; - goto err_qsfp_set_cdr_1; - } - /* Write input value to transceiver */ - return _common_set_uint8_attr(self, - self->eeprom_map_p->addr_cdr, - self->eeprom_map_p->page_cdr, - self->eeprom_map_p->offset_cdr, - update_val, - &(self->cdr), - func_name, - show_err); - -err_qsfp_set_cdr_1: - if (show_err) { - SWPS_INFO("%s: %s :%d :%s\n :%d\n", - __func__, err_msg, err_code, self->swp_name, input_val); - } - return retval; -} - - -int -qsfp_set_cdr(struct transvr_obj_s *self, - int input_val) { - return __qsfp_set_cdr(self, input_val, 1); -} - - -int -qsfp_set_soft_tx_disable(struct transvr_obj_s *self, - int input_val) { - - int show_err = 1; - int in_max = 0xf; /* 1111 */ - int in_min = 0x0; /* 0000 */ - int retval = DEBUG_TRANSVR_INT_VAL; - int update_val = DEBUG_TRANSVR_INT_VAL; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - - retval = _check_by_mode(self, - &_qsfp_update_attr_soft_tx_disable, - "qsfp_set_soft_tx_disable"); - if (retval < 0) { - snprintf(err_msg, 63, "Not ready. err:%d", retval); - goto err_qsfp_set_soft_tx_disable; - } - if ((input_val > in_max) || - (input_val < in_min) ){ - retval = ERR_TRANSVR_BADINPUT; - snprintf(err_msg, 63, "Input value:%d incorrect!", input_val); - goto err_qsfp_set_soft_tx_disable; - } - if ((self->tx_disable & 0x0f) == input_val) { - return 0; - } - update_val = ((self->tx_disable & 0xf0) & input_val); - retval = _common_set_uint8_attr(self, - self->eeprom_map_p->addr_tx_disable, - self->eeprom_map_p->page_tx_disable, - self->eeprom_map_p->offset_tx_disable, - input_val, - &(self->tx_disable), - "qsfp_set_tx_disable", - show_err); - if (retval < 0) { - snprintf(err_msg, 63, "_common_set_uint8_attr:%d fail!", retval); - goto err_qsfp_set_soft_tx_disable; - } - return 0; - -err_qsfp_set_soft_tx_disable: - SWPS_INFO("%s: %s :%s\n", __func__, err_msg, self->swp_name); - return retval; -} - - -int -_qsfp_set_auto_tx_disable(struct transvr_obj_s *self, - uint8_t update) { - - uint8_t tx_enable = 0x0; - int show_e = 1; - int err = DEBUG_TRANSVR_INT_VAL; - char *emsg = DEBUG_TRANSVR_STR_VAL; - - /* Handle timing issues */ - if (update != tx_enable) { - /* Note: - * Because there are some txvr has timing issues, - * therefore we need to execute reset cycle first. - * (enable -> other settings) - */ - err = _common_set_uint8_attr(self, - self->eeprom_map_p->addr_tx_disable, - self->eeprom_map_p->page_tx_disable, - self->eeprom_map_p->offset_tx_disable, - tx_enable, - &(self->tx_disable), - "_qsfp_set_auto_tx_disable", - show_e); - if (err < 0) { - emsg = "I2C set reset value fail"; - goto err_qsfp_set_auto_tx_disable; - } - mdelay(10); - } - /* Setup target value */ - err = _common_set_uint8_attr(self, - self->eeprom_map_p->addr_tx_disable, - self->eeprom_map_p->page_tx_disable, - self->eeprom_map_p->offset_tx_disable, - self->auto_tx_disable, - &(self->tx_disable), - "_qsfp_set_auto_tx_disable", - show_e); - if (err < 0) { - emsg = "I2C set target value fail"; - goto err_qsfp_set_auto_tx_disable; - } - /* Check and update */ - err = _common_update_uint8_attr(self, - self->eeprom_map_p->addr_tx_disable, - self->eeprom_map_p->page_tx_disable, - self->eeprom_map_p->offset_tx_disable, - self->eeprom_map_p->length_tx_disable, - &(self->tx_disable), - "_qsfp_set_auto_tx_disable", - show_e); - if (err < 0) { - emsg = "I2C get value fail"; - goto err_qsfp_set_auto_tx_disable; - } - if (self->tx_disable != update) { - emsg = "data not become effective"; - goto err_qsfp_set_auto_tx_disable; - } - return 0; - -err_qsfp_set_auto_tx_disable: - SWPS_DEBUG("%s: %s :%s\n", - __func__, emsg, self->swp_name); - return ERR_TRANSVR_UPDATE_FAIL; -} - - -int -qsfp_set_auto_tx_disable(struct transvr_obj_s *self, - int input_val) { - - int in_max = 0xf; /* 1111 */ - int in_min = 0x0; /* 0000 */ - int retval = DEBUG_TRANSVR_INT_VAL; - char *emsg = DEBUG_TRANSVR_STR_VAL; - - /* Update settings*/ - if (input_val == VAL_TRANSVR_FUNCTION_DISABLE) { - emsg = "User disable auto tx_disable"; - self->auto_tx_disable = VAL_TRANSVR_FUNCTION_DISABLE; - goto out_qsfp_set_auto_tx_disable; - } - if ((input_val > in_max) || (input_val < in_min) ){ - SWPS_INFO("%s: Input value:%d incorrect! :%s\n", - __func__, input_val, self->swp_name); - return ERR_TRANSVR_BADINPUT; - } - self->auto_tx_disable = input_val; - /* Check current soft tx_disable */ - retval = _check_by_mode(self, - &_qsfp_update_attr_soft_tx_disable, - "qsfp_set_auto_tx_disable"); - switch (retval) { - case 0: - break; - case ERR_TRANSVR_UNPLUGGED: - emsg = "Doesn't need to update"; - goto out_qsfp_set_auto_tx_disable; - default: - SWPS_INFO("%s: setup fail :%d :%s\n", - __func__, retval, self->swp_name); - return retval; - } - return _qsfp_set_auto_tx_disable(self, input_val); - -out_qsfp_set_auto_tx_disable: - SWPS_DEBUG("%s: %s :%s :%d\n :%d", - __func__, emsg, self->swp_name, input_val, retval); - return 0; -} - - -int -__qsfp_set_tx_eq(struct transvr_obj_s *self, - int input, - int show_e) { - /* [Note] - * 0x - */ - int err = DEBUG_TRANSVR_INT_VAL; - char *emsg = DEBUG_TRANSVR_STR_VAL; - uint8_t setv[2] = {0x00, 0x00}; - - if ((input < 0) || (input > 0xFFFF)) { - emsg = "input incorrect"; - err = ERR_TRANSVR_BADINPUT; - goto err_qsfp_set_tx_eq; - } - setv[0] = (uint8_t)((input & 0xFF00) >> 8); - setv[1] = (uint8_t)(input & 0xFF); - if ((self->tx_eq[0] == setv[0]) && - (self->tx_eq[1] == setv[1]) ) { - return 0; - } - err = _common_set_uint8_array(self, - self->eeprom_map_p->addr_tx_eq, - self->eeprom_map_p->page_tx_eq, - self->eeprom_map_p->offset_tx_eq, - self->eeprom_map_p->length_tx_eq, - setv, - self->tx_eq, - "_qsfp_set_tx_eq", - show_e); - if (err < 0) { - emsg = "set_uint8_array fail"; - goto err_qsfp_set_tx_eq; - } - return 0; - -err_qsfp_set_tx_eq: - if (show_e) { - SWPS_INFO("%s: %s :%d\n", __func__, emsg, input); - } - return err; -} - - -int -_qsfp_set_tx_eq(struct transvr_obj_s *self, - int input, - int show_e) { - - int i = 0; - int retry = 3; - uint8_t tmp[2]; - - for (i=0; itx_eq[0]; - tmp[1] = self->tx_eq[1]; - if (_qsfp_update_attr_tx_eq(self, show_e) < 0){ - continue; - } - if ((self->tx_eq[0] == tmp[0]) && - (self->tx_eq[1] == tmp[1]) ){ - return 0; - } - } - return -1; -} - - -int -qsfp_set_tx_eq(struct transvr_obj_s *self, - int input) { - - int err = _check_by_mode(self, - &_qsfp_update_attr_tx_eq, - "qsfp_set_tx_eq"); - if (err < 0) { - SWPS_DEBUG("%s: check fail :%d\n", __func__, err); - return err; - } - return _qsfp_set_tx_eq(self, input, 1); -} - - -int -__qsfp_set_rx_am(struct transvr_obj_s *self, - int input, - int show_e) { - /* [Note] - * 0x - */ - int err = DEBUG_TRANSVR_INT_VAL; - char *emsg = DEBUG_TRANSVR_STR_VAL; - uint8_t setv[2] = {0x00, 0x00}; - - if ((input < 0) || (input > 0xFFFF)) { - emsg = "input incorrect"; - err = ERR_TRANSVR_BADINPUT; - goto err_qsfp_set_rx_am; - } - setv[0] = (uint8_t)((input & 0xFF00) >> 8); - setv[1] = (uint8_t)(input & 0xFF); - if ((self->rx_am[0] == setv[0]) && - (self->rx_am[1] == setv[1]) ) { - return 0; - } - err = _common_set_uint8_array(self, - self->eeprom_map_p->addr_rx_am, - self->eeprom_map_p->page_rx_am, - self->eeprom_map_p->offset_rx_am, - self->eeprom_map_p->length_rx_am, - setv, - self->rx_am, - "_qsfp_set_rx_am", - show_e); - if (err < 0) { - emsg = "set_uint8_array fail"; - goto err_qsfp_set_rx_am; - } - return 0; - -err_qsfp_set_rx_am: - if (show_e) { - SWPS_INFO("%s: %s :%d\n", __func__, emsg, input); - } - return err; -} - - -int -_qsfp_set_rx_am(struct transvr_obj_s *self, - int input, - int show_e) { - - int i = 0; - int retry = 3; - uint8_t tmp[2]; - - for (i=0; irx_am[0]; - tmp[1] = self->rx_am[1]; - if (_qsfp_update_attr_rx_am(self, show_e) < 0){ - continue; - } - if ((self->rx_am[0] == tmp[0]) && - (self->rx_am[1] == tmp[1]) ){ - return 0; - } - } - return -1; -} - - -int -qsfp_set_rx_am(struct transvr_obj_s *self, - int input) { - - int err = _check_by_mode(self, - &_qsfp_update_attr_rx_am, - "qsfp_set_rx_am"); - if (err < 0) { - SWPS_DEBUG("%s: check fail :%d\n", __func__, err); - return err; - } - return _qsfp_set_rx_am(self, input, 1); -} - - -int -__qsfp_set_rx_em(struct transvr_obj_s *self, - int input, - int show_e) { - /* [Note] - * 0x - */ - int err = DEBUG_TRANSVR_INT_VAL; - char *emsg = DEBUG_TRANSVR_STR_VAL; - uint8_t setv[2] = {0x00, 0x00}; - - if ((input < 0) || (input > 0xFFFF)) { - emsg = "input incorrect"; - err = ERR_TRANSVR_BADINPUT; - goto err_qsfp_set_rx_em; - } - setv[0] = (uint8_t)((input & 0xFF00) >> 8); - setv[1] = (uint8_t)(input & 0xFF); - if ((self->rx_em[0] == setv[0]) && - (self->rx_em[1] == setv[1]) ) { - return 0; - } - err = _common_set_uint8_array(self, - self->eeprom_map_p->addr_rx_em, - self->eeprom_map_p->page_rx_em, - self->eeprom_map_p->offset_rx_em, - self->eeprom_map_p->length_rx_em, - setv, - self->rx_em, - "_qsfp_set_rx_em", - show_e); - if (err < 0) { - emsg = "set_uint8_array fail"; - goto err_qsfp_set_rx_em; - } - return 0; - -err_qsfp_set_rx_em: - if (show_e) { - SWPS_INFO("%s: %s :%d\n", __func__, emsg, input); - } - return err; -} - - -int -_qsfp_set_rx_em(struct transvr_obj_s *self, - int input, - int show_e) { - - int i = 0; - int retry = 3; - uint8_t tmp[2]; - - for (i=0; irx_em[0]; - tmp[1] = self->rx_em[1]; - if (_qsfp_update_attr_rx_em(self, show_e) < 0){ - continue; - } - if ((self->rx_em[0] == tmp[0]) && - (self->rx_em[1] == tmp[1]) ){ - return 0; - } - } - return -1; -} - - -int -qsfp_set_rx_em(struct transvr_obj_s *self, - int input) { - - int err = _check_by_mode(self, - &_qsfp_update_attr_rx_em, - "qsfp_set_rx_em"); - if (err < 0) { - SWPS_DEBUG("%s: check fail :%d\n", __func__, err); - return err; - } - return _qsfp_set_rx_em(self, input, 1); -} - - -int -common_transvr_dump(struct transvr_obj_s* self){ - - char *type_name = "Undefined"; - - if (TRANSVR_INFO_DUMP_ENABLE != 1) { - return 0; - } - switch (self->type) { - case TRANSVR_TYPE_SFP: - type_name = STR_TRANSVR_SFP; - break; - case TRANSVR_TYPE_QSFP: - type_name = STR_TRANSVR_QSFP; - break; - case TRANSVR_TYPE_QSFP_PLUS: - type_name = STR_TRANSVR_QSFP_PLUS; - break; - case TRANSVR_TYPE_QSFP_28: - type_name = STR_TRANSVR_QSFP28; - break; - case TRANSVR_TYPE_FAKE: - type_name = "FAKE"; - goto ok_common_transvr_dump; - case TRANSVR_TYPE_UNPLUGGED: - type_name = "UNPLUGGED"; - goto err_common_transvr_dump; - case TRANSVR_TYPE_INCONSISTENT: - type_name = "INCONSISTENT"; - goto err_common_transvr_dump; - case TRANSVR_TYPE_ERROR: - type_name = "ERROR"; - goto err_common_transvr_dump; - - default: - type_name = "UNEXPECTED"; - goto err_common_transvr_dump; - } - printk(KERN_INFO "[SWPS] Dump %s information:\n", self->swp_name); - printk(KERN_INFO " |- :%s\n", type_name); - printk(KERN_INFO " |- :%s\n", self->vendor_name); - printk(KERN_INFO " |- :%s\n", self->vendor_pn); - printk(KERN_INFO " |- :%s\n", self->vendor_rev); - printk(KERN_INFO " |- :%s\n", self->vendor_sn); - printk(KERN_INFO " |- :0x%02x\n", self->br); - printk(KERN_INFO " |- :0x%02x\n", self->comp_rev); - printk(KERN_INFO " |- :%d\n", self->len_om1); - printk(KERN_INFO " |- :%d\n", self->len_om2); - printk(KERN_INFO " |- :%d\n", self->len_om3); - printk(KERN_INFO " |- :%d\n", self->len_om4); - return 0; - -ok_common_transvr_dump: - SWPS_INFO("%s: %s is %s\n", __func__, self->swp_name, type_name); - return 0; - -err_common_transvr_dump: - SWPS_INFO("%s: %s is %s\n", __func__, self->swp_name, type_name); - return -1; -} - - -int -sfp_transvr_dump(struct transvr_obj_s* self) { - - if (TRANSVR_INFO_DUMP_ENABLE != 1) { - return 0; - } - if (common_transvr_dump(self) < 0) { - return -1; - } - printk(KERN_INFO " |- :%d\n", self->len_sm); - printk(KERN_INFO " |- :%d\n", self->len_smf); - printk(KERN_INFO " '- :0x%02x\n", self->rate_id); - return 0; -} - - -int -qsfp_transvr_dump(struct transvr_obj_s* self) { - - if (TRANSVR_INFO_DUMP_ENABLE != 1) { - return 0; - } - if (common_transvr_dump(self) < 0) { - return -1; - } - printk(KERN_INFO " |- :%d\n", self->len_smf); - printk(KERN_INFO " '- :Class_%d\n", __qsfp_get_power_cls(self, 0)); - return 0; -} - - -int -fake_transvr_dump(struct transvr_obj_s* self) { - - printk(KERN_INFO "[SWPS] Dump transceiver information: %s\n", self->swp_name); - printk(KERN_INFO " |- :FAKE\n"); - printk(KERN_INFO " |- :FAKE_VENDER_NAME\n"); - printk(KERN_INFO " |- :FAKE_VENDER_PN\n"); - printk(KERN_INFO " |- :FAKE_VENDER_REV\n"); - printk(KERN_INFO " |- :FAKE_VENDER_SN\n"); - printk(KERN_INFO " |- :0x99\n"); - printk(KERN_INFO " |- :99\n"); - printk(KERN_INFO " |- :99\n"); - printk(KERN_INFO " |- :99\n"); - printk(KERN_INFO " |- :99\n"); - printk(KERN_INFO " |- :99\n"); - printk(KERN_INFO " |- :99\n"); - printk(KERN_INFO " '- :0x99\n"); - return 0; -} - - -/* ========== Object functions for fake type ========== - */ -int -fake_transvr_update(struct transvr_obj_s *self, - int show_err){ - self->state = STATE_TRANSVR_CONNECTED; - return 0; -} - - -int -fake_get_binary(struct transvr_obj_s *self){ - return 1; -} - -int -fake_get_int(struct transvr_obj_s *self){ - return 99; -} - - -int -fake_get_hex(struct transvr_obj_s *self){ - return 0x0f; -} - - -int -fake_get_str(struct transvr_obj_s *self, char *buf) { - return snprintf(buf, 16, "fake_get_str\n"); -} - - -int -fake_set_int(struct transvr_obj_s *self, int input){ - SWPS_INFO("%s: %d\n", __func__, input); - return 0; -} - - -int -fake_set_hex(struct transvr_obj_s *self, int input){ - SWPS_INFO("%s: 0x%02x\n", __func__, input); - return 0; -} - - -/* ========== Object functions for unsupported ========== - */ -int -unsupported_get_func(struct transvr_obj_s *self){ - return ERR_TRANSVR_NOTSUPPORT; -} - - -int -unsupported_get_func2(struct transvr_obj_s *self, - char *buf_p) { - int len = snprintf(buf_p, 8, "%d\n", ERR_TRANSVR_NOTSUPPORT); - return len; -} - - -int -unsupported_set_func(struct transvr_obj_s *self, - int input_val){ - return ERR_TRANSVR_NOTSUPPORT; -} - - - -/* ========== Object functions for long term task ========== - * - * [Note] - * SWPS transceiver worker is likely the green-thread (coroutine). - * Due to resource and performance considerations. SWPS run all - * features in one kthread at the same time, and handle by it self. - */ - -/* For Transceiver Task Handling - */ -static struct transvr_worker_s * -transvr_task_get(struct transvr_obj_s *self, - char *func_name) { - - struct transvr_worker_s *curr_p = self->worker_p; - - while(curr_p != NULL){ - if (strcmp((curr_p->func_name), func_name) == 0 ) { - return curr_p; - } - curr_p = curr_p->next_p; - } - return NULL; -} - - -static struct transvr_worker_s* -transvr_task_creat(struct transvr_obj_s *self, - int (*main_task)(struct transvr_worker_s *task), - int (*post_task)(struct transvr_worker_s *task), - char *caller) { - - struct transvr_worker_s *task_p = NULL; - struct transvr_worker_s *curr_p = NULL; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - - /* Check task not exist */ - task_p = transvr_task_get(self, caller); - if (task_p) { - snprintf(err_msg, sizeof(err_msg), "Task already created!"); - goto err_transvr_task_creat; - } - /* Create task worker */ - task_p = kzalloc(sizeof(struct transvr_worker_s), GFP_KERNEL); - if (!task_p){ - snprintf(err_msg, sizeof(err_msg), "kzalloc fail"); - goto err_transvr_task_creat; - } - /* Setup task data */ - task_p->transvr_p = self; - task_p->next_p = NULL; - task_p->trigger_time = 0; - task_p->retry = 1; - task_p->state = STATE_T_TASK_INIT; - task_p->main_task = main_task; - task_p->post_task = post_task; - task_p->p_data = NULL; - snprintf(task_p->func_name, sizeof(task_p->func_name), "%s", caller); - /* Setup Link List */ - if (self->worker_p) { - curr_p = self->worker_p; - while(curr_p->next_p != NULL) { - curr_p = curr_p->next_p; - } - curr_p->next_p = task_p; - task_p->pre_p = curr_p; - } else { - self->worker_p = task_p; - task_p->pre_p = NULL; - } - return task_p; - -err_transvr_task_creat: - SWPS_ERR("%s: %s :%s :%s\n", - __func__, err_msg, caller, self->swp_name); - return NULL; -} - - -static void -transvr_task_free_one(struct transvr_worker_s *task_p){ - - struct transvr_worker_s *pre_p = NULL; - struct transvr_worker_s *next_p = NULL; - - if (task_p) { - pre_p = task_p->pre_p; - next_p = task_p->next_p; - - if ((pre_p) && (next_p)) { - pre_p->next_p = next_p; - next_p->pre_p = pre_p; - - } else if ((!pre_p) && (next_p)) { - next_p->pre_p = NULL; - - } else if ((pre_p) && (!next_p)) { - pre_p->next_p = NULL; - - } else if ((!pre_p) && (!next_p)) { - task_p->transvr_p->worker_p = NULL; - } else { - SWPS_ERR("%s: Unexcept case!\n :%s", - __func__, task_p->transvr_p->swp_name); - } - kfree(task_p->p_data); - kfree(task_p); - } -} - - -static void -transvr_task_free_all(struct transvr_obj_s *self) { - - struct transvr_worker_s *curr_p = NULL; - struct transvr_worker_s *next_p = NULL; - - if (self->worker_p) { - curr_p = self->worker_p; - while(curr_p) { - next_p = curr_p->next_p; - transvr_task_free_one(curr_p); - curr_p = next_p; - } - self->worker_p = NULL; - } -} - - -static void -transvr_cache_free_all(struct transvr_obj_s *self) { - - memset(self->vendor_name, 0, (LEN_TRANSVR_M_STR * sizeof(char)) ); - memset(self->vendor_rev, 0, (LEN_TRANSVR_M_STR * sizeof(char)) ); - memset(self->vendor_pn, 0, (LEN_TRANSVR_M_STR * sizeof(char)) ); - memset(self->vendor_sn, 0, (LEN_TRANSVR_M_STR * sizeof(char)) ); - self->extphy_offset = 0; -} - -static int -_transvr_task_run_main(struct transvr_worker_s *task_p) { - - int retval = DEBUG_TRANSVR_INT_VAL; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - - if (!task_p){ - snprintf(err_msg, sizeof(err_msg), "main_task is NULL!"); - goto main_transvr_task_err; - } - if ((task_p->trigger_time) == 0){ - goto main_transvr_task_run; - } - if (time_before(jiffies, task_p->trigger_time)){ - goto main_transvr_task_wait; - } - goto main_transvr_task_run; - -main_transvr_task_run: - if (task_p->retry != VAL_TRANSVR_TASK_RETRY_FOREVER) { - task_p->retry -= 1; - } - retval = task_p->main_task(task_p); - if (retval < 0) { - if (task_p->retry > 0) { - task_p->state = STATE_T_TASK_WAIT; - return EVENT_TRANSVR_TASK_WAIT; - } - snprintf(err_msg, sizeof(err_msg), "Run main_task fail!"); - goto main_transvr_task_err; - } - goto main_transvr_task_identify; - -main_transvr_task_identify: - switch (retval) { - case EVENT_TRANSVR_TASK_WAIT: - task_p->state = STATE_T_TASK_WAIT; - return EVENT_TRANSVR_TASK_WAIT; - - case EVENT_TRANSVR_TASK_DONE: - task_p->state = STATE_T_TASK_DONE; - return EVENT_TRANSVR_TASK_DONE; - - default: - break; - } - snprintf(err_msg, sizeof(err_msg), "Run main_task fail!"); - goto main_transvr_task_err; - -main_transvr_task_wait: - task_p->state = STATE_T_TASK_WAIT; - return EVENT_TRANSVR_TASK_WAIT; - -main_transvr_task_err: - task_p->state = STATE_T_TASK_FAIL; - SWPS_INFO("%s: %s :%d :%s\n", - __func__, err_msg, retval, task_p->transvr_p->swp_name); - return EVENT_TRANSVR_INIT_FAIL; -} - - -static int -_transvr_task_run_post(struct transvr_worker_s *task_p) { - - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - - if ((task_p->post_task) == NULL) { - return EVENT_TRANSVR_TASK_DONE; - } - switch (task_p->state) { - case STATE_T_TASK_WAIT: - case STATE_T_TASK_INIT: - goto post_transvr_task_wait; - - case STATE_T_TASK_DONE: - case STATE_T_TASK_FAIL: - goto post_transvr_task_run; - - default: - break; - } - snprintf(err_msg, sizeof(err_msg), "Unexcept task state"); - goto post_transvr_task_err; - -post_transvr_task_run: - task_p->post_task(task_p); - return EVENT_TRANSVR_TASK_DONE; - -post_transvr_task_wait: - return EVENT_TRANSVR_TASK_WAIT; - -post_transvr_task_err: - SWPS_INFO("%s: %s :%d :%s\n", - __func__, err_msg, task_p->state, task_p->transvr_p->swp_name); - return EVENT_TRANSVR_TASK_FAIL; -} - - -static int -transvr_task_run_one(struct transvr_worker_s *task_p) { - - int retval_main = DEBUG_TRANSVR_INT_VAL; - int retval_post = DEBUG_TRANSVR_INT_VAL; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - - retval_main = _transvr_task_run_main(task_p); - if (retval_main < 0) { - snprintf(err_msg, sizeof(err_msg), "Execute main_task fail!"); - goto err_transvr_task_run_one; - } - retval_post = _transvr_task_run_post(task_p); - if (retval_post < 0) { - snprintf(err_msg, sizeof(err_msg), "Execute post_task fail!"); - goto err_transvr_task_run_one; - } - return retval_main; - -err_transvr_task_run_one: - SWPS_INFO("%s: %s
:%d :%d :%s :%s\n", - __func__, err_msg, retval_main, retval_post, - task_p->func_name, task_p->transvr_p->swp_name); - return EVENT_TRANSVR_TASK_FAIL; -} - - -static int -transvr_task_run_all(struct transvr_obj_s *self) { - - int haserr = 0; - int retval = DEBUG_TRANSVR_INT_VAL; - struct transvr_worker_s *curr_p = NULL; - struct transvr_worker_s *next_p = NULL; - - if ((self->worker_p) == NULL) { - return EVENT_TRANSVR_TASK_DONE; - } - curr_p = self->worker_p; - while (curr_p != NULL) { - next_p = curr_p->next_p; - retval = transvr_task_run_one(curr_p); - if (curr_p->retry == VAL_TRANSVR_TASK_RETRY_FOREVER) { - curr_p = next_p; - continue; - } - switch (retval) { - case EVENT_TRANSVR_TASK_WAIT: - break; - case EVENT_TRANSVR_TASK_DONE: - transvr_task_free_one(curr_p); - break; - case EVENT_TRANSVR_TASK_FAIL: - - default: - haserr = 1; - transvr_task_free_one(curr_p); - break; - } - curr_p = next_p; - } - if (haserr) { - return EVENT_TRANSVR_TASK_FAIL; - } - return EVENT_TRANSVR_TASK_DONE; -} - - -static void -transvr_task_set_delay(struct transvr_worker_s *task_p, - unsigned long delay_msec) { - - task_p->trigger_time = (jiffies + (delay_msec * (HZ/1000))); -} - - -static void -transvr_task_set_retry(struct transvr_worker_s *task_p, - unsigned long retry_times) { - - task_p->retry = retry_times; -} - - -/* For Transceiver Post Task - */ -int -taskfunc_post_do_nothing(struct transvr_worker_s *task_p) { - - return EVENT_TRANSVR_TASK_DONE; -} - - -int -taskfunc_post_handle_task_state(struct transvr_worker_s *task_p) { - - struct transvr_obj_s* tp = task_p->transvr_p; - - switch (task_p->state) { - case STATE_T_TASK_INIT: - case STATE_T_TASK_WAIT: - return EVENT_TRANSVR_TASK_WAIT; - - case STATE_T_TASK_DONE: - tp->state = STATE_TRANSVR_CONNECTED; - tp->send_uevent(tp, KOBJ_ADD); - return EVENT_TRANSVR_TASK_DONE; - - case STATE_T_TASK_FAIL: - tp->state = STATE_TRANSVR_UNEXCEPTED; - return EVENT_TRANSVR_TASK_FAIL; - - default: - break; - } - return EVENT_TRANSVR_TASK_FAIL; -} - - -/* For Transceiver Main Task - */ -int -_taskfunc_sfp_setup_soft_rs(struct transvr_worker_s *task_p, - int input_val, - int address, - int page, - int offset, - int bit_shift, - uint8_t *attr_p, - char *caller) { - - int show_err = 0; - int err_code = DEBUG_TRANSVR_INT_VAL; - char *err_str = DEBUG_TRANSVR_STR_VAL; - char *func_str = "_taskfunc_sfp_setup_soft_rs"; - - err_code = _sfp_update_attr_soft_rs0(task_p->transvr_p, 0); - if (err_code < 0) { - err_str = "Get current soft_rs0 fail!"; - goto err_taskfunc_sfp_setup_soft_rs_1; - } - err_code = __sfp_set_soft_rs(task_p->transvr_p, - input_val, - address, - page, - offset, - bit_shift, - attr_p, - caller, - show_err); - if (err_code < 0) { - err_str = "Get current soft_rs0 fail!"; - goto err_taskfunc_sfp_setup_soft_rs_1; - } - return EVENT_TRANSVR_TASK_DONE; - -err_taskfunc_sfp_setup_soft_rs_1: - if ((task_p->retry) == 0) { - SWPS_INFO("%s: %s :%s :%d :%d\n", - func_str, err_str, task_p->transvr_p->swp_name, input_val, err_code); - } - return EVENT_TRANSVR_TASK_FAIL; -} - - -int -__taskfunc_sfp_setup_hard_rs(struct transvr_worker_s *task_p, - int input_val, - int (*get_func)(struct ioexp_obj_s *self, int virt_offset), - int (*set_func)(struct ioexp_obj_s *self, int virt_offset, int input_val)) { - - int err_val = EVENT_TRANSVR_EXCEP_EXCEP; - char *err_str = DEBUG_TRANSVR_STR_VAL; - - err_val = get_func(task_p->transvr_p->ioexp_obj_p, - task_p->transvr_p->ioexp_virt_offset); - - if (err_val < 0) { - if (err_val == ERR_IOEXP_NOTSUPPORT) { - return EVENT_TRANSVR_TASK_DONE; - } - err_str = "Get current hard_rs fail!"; - goto err_p_taskfunc_sfp_setup_hard_rs_1; - } - if (err_val == input_val) { - return EVENT_TRANSVR_TASK_DONE; - } - err_val = set_func(task_p->transvr_p->ioexp_obj_p, - task_p->transvr_p->ioexp_virt_offset, - input_val); - if (err_val < 0) { - err_str = "Setup hard_rs fail!"; - goto err_p_taskfunc_sfp_setup_hard_rs_1; - } - return EVENT_TRANSVR_TASK_DONE; - -err_p_taskfunc_sfp_setup_hard_rs_1: - if ((task_p->retry) == 0) { - SWPS_INFO("%s: %s :%s :%d :%d\n", - __func__, err_str, task_p->transvr_p->swp_name, input_val, err_val); - } - return EVENT_TRANSVR_TASK_FAIL; -} - - -int -_taskfunc_sfp_setup_hard_rs0(struct transvr_worker_s *task_p, - int input_val) { - - return __taskfunc_sfp_setup_hard_rs(task_p, - input_val, - task_p->transvr_p->ioexp_obj_p->get_hard_rs0, - task_p->transvr_p->ioexp_obj_p->set_hard_rs0); -} - - -int -_taskfunc_sfp_setup_hard_rs1(struct transvr_worker_s *task_p, - int input_val) { - - return __taskfunc_sfp_setup_hard_rs(task_p, - input_val, - task_p->transvr_p->ioexp_obj_p->get_hard_rs1, - task_p->transvr_p->ioexp_obj_p->set_hard_rs1); -} - - -int -_taskfunc_sfp_setup_rs0(struct transvr_worker_s *task_p, - int input_val) { - - int bit_shift = 3; - int old_val = DEBUG_TRANSVR_INT_VAL; - int err_val = EVENT_TRANSVR_EXCEP_EXCEP; - char *err_str = DEBUG_TRANSVR_STR_VAL; - char *func_str = "_taskfunc_sfp_setup_rs0"; - - err_val = _taskfunc_sfp_setup_hard_rs0(task_p, - input_val); - if (err_val < 0) { - err_str = "Setup hard_rs0 fail!"; - goto err_private_taskfunc_sfp_setup_rs0_1; - } - old_val = err_val; - err_val = _taskfunc_sfp_setup_soft_rs(task_p, - input_val, - task_p->transvr_p->eeprom_map_p->addr_soft_rs0, - task_p->transvr_p->eeprom_map_p->page_soft_rs0, - task_p->transvr_p->eeprom_map_p->offset_soft_rs0, - bit_shift, - &(task_p->transvr_p->soft_rs0), - func_str); - if (err_val < 0) { - err_str = "Setup soft_rs0 fail!"; - goto err_private_taskfunc_sfp_setup_rs0_1; - } - return EVENT_TRANSVR_TASK_DONE; - -err_private_taskfunc_sfp_setup_rs0_1: - if ((task_p->retry) == 0) { - SWPS_INFO("%s: %s :%s :%d :%d\n", - func_str, err_str, task_p->transvr_p->swp_name, input_val, err_val); - } - _taskfunc_sfp_setup_hard_rs0(task_p, old_val); - return EVENT_TRANSVR_TASK_FAIL; -} - - -int -_taskfunc_sfp_setup_rs1(struct transvr_worker_s *task_p, - int input_val) { - - int bit_shift = 3; - int old_val = DEBUG_TRANSVR_INT_VAL; - int err_val = EVENT_TRANSVR_EXCEP_EXCEP; - char *err_str = DEBUG_TRANSVR_STR_VAL; - char *func_str = "_taskfunc_sfp_setup_rs1"; - - err_val = _taskfunc_sfp_setup_hard_rs1(task_p, - input_val); - if (err_val < 0) { - err_str = "Setup hard_rs1 fail!"; - goto err_private_taskfunc_sfp_setup_rs1_1; - } - old_val = err_val; - err_val = _taskfunc_sfp_setup_soft_rs(task_p, - input_val, - task_p->transvr_p->eeprom_map_p->addr_soft_rs1, - task_p->transvr_p->eeprom_map_p->page_soft_rs1, - task_p->transvr_p->eeprom_map_p->offset_soft_rs1, - bit_shift, - &(task_p->transvr_p->soft_rs1), - func_str); - if (err_val < 0) { - err_str = "Setup soft_rs1 fail!"; - goto err_private_taskfunc_sfp_setup_rs1_1; - } - return EVENT_TRANSVR_TASK_DONE; - -err_private_taskfunc_sfp_setup_rs1_1: - if ((task_p->retry) == 0) { - SWPS_INFO("%s: %s :%s :%d :%d\n", - func_str, err_str, task_p->transvr_p->swp_name, input_val, err_val); - } - _taskfunc_sfp_setup_hard_rs1(task_p, old_val); - return EVENT_TRANSVR_TASK_FAIL; -} - - -int -taskfunc_sfp_setup_SFF8431_case1(struct transvr_worker_s *task_p) { - /* SFF-8431 (8/4/2G Rx Rate_Select only) */ - int update_val = 1; - - return _taskfunc_sfp_setup_rs0(task_p, update_val); -} - - - -int -taskfunc_sfp_setup_SFF8431_case2(struct transvr_worker_s *task_p) { - /* SFF-8431 (8/4/2G Tx Rate_Select only) */ - int update_val = 1; - - return _taskfunc_sfp_setup_rs1(task_p, update_val); -} - - -int -taskfunc_sfp_setup_SFF8431_case3(struct transvr_worker_s *task_p) { - /* SFF-8431 (8/4/2G Independent Rx & Tx Rate_select) */ - int update_rs0 = 1; - int update_rs1 = 1; - int err_code = DEBUG_TRANSVR_INT_VAL; - - err_code = _taskfunc_sfp_setup_rs0(task_p, update_rs0); - if (err_code < 0) { - return err_code; - } - return _taskfunc_sfp_setup_rs1(task_p, update_rs1); -} - - -int -taskfunc_sfp_handle_1g_rj45(struct transvr_worker_s *task_p) { - - /* Not all of platform support 0x56 for transceiver - * external PHY, Support list as below: - * => 1. Magnolia-PVT (PS: EVT & DVT not ready) - */ - int ext_phy_addr = 0x56; - int ext_phy_page = -1; - int ext_phy_offs = 0x11; - int ext_phy_len = 1; - int lstate_mask = 0x04; /* 00000100 */ - int show_err = 0; - int fail_retry = 5; - int fail_delay = 1000; /* msec */ - int err_code = DEBUG_TRANSVR_INT_VAL; - uint8_t detect_val = DEBUG_TRANSVR_HEX_VAL; - char err_str[64] = DEBUG_TRANSVR_STR_VAL; - int *tmp_p = NULL; - char *func_name = "taskfunc_sfp_handle_1g_rj45"; - - if (task_p->transvr_p->state != STATE_TRANSVR_CONNECTED) { - return EVENT_TRANSVR_TASK_DONE; - } - if ( (task_p->transvr_p->info != TRANSVR_CLASS_BASE_T_1000) && - (task_p->transvr_p->info != TRANSVR_CLASS_BASE_T_1000_up) ) { - goto err_taskfunc_sfp_handle_1g_rj45_1; - } - err_code = _common_update_uint8_attr(task_p->transvr_p, - ext_phy_addr, - ext_phy_page, - ext_phy_offs, - ext_phy_len, - &detect_val, - func_name, - show_err); - if ( (err_code < 0) || - (detect_val == DEBUG_TRANSVR_HEX_VAL) ) { - snprintf(err_str, sizeof(err_str), "Detect external link status fail"); - goto err_taskfunc_sfp_handle_1g_rj45_2; - } - if ((detect_val & lstate_mask) == lstate_mask) { - goto ok_taskfunc_sfp_handle_1g_rj45_link_up; - } - goto ok_taskfunc_sfp_handle_1g_rj45_link_down; - -ok_taskfunc_sfp_handle_1g_rj45_link_up: - /* Filter out noise */ - if (!(task_p->p_data)) { - tmp_p = kzalloc(sizeof(int), GFP_KERNEL); - if (!tmp_p) { - snprintf(err_str, sizeof(err_str), "kzalloc p_data fail"); - goto err_taskfunc_sfp_handle_1g_rj45_2; - } - *tmp_p = TRANSVR_CLASS_BASE_T_1000_up; - task_p->p_data = tmp_p; - goto ok_taskfunc_sfp_handle_1g_rj45_done; - } - if ((*(int *)(task_p->p_data)) != TRANSVR_CLASS_BASE_T_1000_up) { - kfree(task_p->p_data); - task_p->p_data = NULL; - snprintf(err_str, sizeof(err_str), "Internal error"); - goto err_taskfunc_sfp_handle_1g_rj45_2; - } - task_p->transvr_p->info = TRANSVR_CLASS_BASE_T_1000_up; - kfree(task_p->p_data); - task_p->p_data = NULL; - goto ok_taskfunc_sfp_handle_1g_rj45_done; - -ok_taskfunc_sfp_handle_1g_rj45_link_down: - if (task_p->p_data) { - kfree(task_p->p_data); - task_p->p_data = NULL; - } - task_p->transvr_p->info = TRANSVR_CLASS_BASE_T_1000; - goto ok_taskfunc_sfp_handle_1g_rj45_done; - -ok_taskfunc_sfp_handle_1g_rj45_done: - if (task_p->retry != VAL_TRANSVR_TASK_RETRY_FOREVER) { - transvr_task_set_retry(task_p, VAL_TRANSVR_TASK_RETRY_FOREVER); - } - return EVENT_TRANSVR_TASK_DONE; - -err_taskfunc_sfp_handle_1g_rj45_1: - snprintf(err_str, sizeof(err_str), "Detect transceiver:%d not Base-T, remove task.", - task_p->transvr_p->info); - SWPS_INFO("%s: %s :%s\n", __func__, err_str, task_p->transvr_p->swp_name); - transvr_task_set_retry(task_p, 0); - return EVENT_TRANSVR_TASK_DONE; - -err_taskfunc_sfp_handle_1g_rj45_2: - if (task_p->retry == VAL_TRANSVR_TASK_RETRY_FOREVER) { - transvr_task_set_retry(task_p, fail_retry); - } - if ((task_p->retry) == 0) { - /* Error case: - * => In this case, SWPS will stop external Link state monitor features - * and keeps transvr_p->info on TRANSVR_CLASS_BASE_T_1000_up. - * Upper layer will see it always Linkup that because of these type of - * transceiver has external phy, switch chip see it as Loopback transceiver. - */ - SWPS_WARN("%s can not access external PHY of Base-T SFP transceiver\n", - task_p->transvr_p->swp_name); - task_p->transvr_p->info = TRANSVR_CLASS_BASE_T_1000_up; - return EVENT_TRANSVR_TASK_DONE; - } else { - transvr_task_set_delay(task_p, fail_delay); - } - return EVENT_TRANSVR_TASK_FAIL; -} - - -int -_taskfunc_qsfp_setup_power_mod(struct transvr_obj_s *self, - int setup_val) { - - int curr_val = DEBUG_TRANSVR_INT_VAL; - int err_val = DEBUG_TRANSVR_INT_VAL; - char *err_msg = DEBUG_TRANSVR_STR_VAL; - if (io_no_init) { - - SWPS_INFO("%s no_io_init\n",__func__); - return EVENT_TRANSVR_TASK_DONE; - } - - curr_val = self->ioexp_obj_p->get_lpmod(self->ioexp_obj_p, - self->ioexp_virt_offset); - if (curr_val < 0){ - err_msg = "Get current value fail!"; - goto err_private_taskfunc_qsfp_setup_power_mod_1; - } - if (curr_val == setup_val){ - return EVENT_TRANSVR_TASK_DONE; - } - err_val = self->ioexp_obj_p->set_lpmod(self->ioexp_obj_p, - self->ioexp_virt_offset, - setup_val); - if (err_val < 0){ - err_msg = "Setup power mode fail!"; - goto err_private_taskfunc_qsfp_setup_power_mod_1; - } - return EVENT_TRANSVR_TASK_DONE; - -err_private_taskfunc_qsfp_setup_power_mod_1: - SWPS_INFO("%s: %s :%d :%d :%d\n", - __func__, err_msg, err_val, curr_val, setup_val); - return EVENT_TRANSVR_TASK_FAIL; -} - - -int -taskfunc_qsfp_handle_tx_disable(struct transvr_worker_s *task_p) { - - int i = 0; - int retry = 5; - int delay_ms = 100; - - if (task_p->transvr_p->auto_tx_disable == VAL_TRANSVR_FUNCTION_DISABLE) { - return EVENT_TRANSVR_TASK_DONE; - } - if (!_qsfp_is_implement_tx_disable(task_p->transvr_p)) { - return EVENT_TRANSVR_TASK_DONE; - } - for (i=0; itransvr_p, - task_p->transvr_p->auto_tx_disable) - == EVENT_TRANSVR_TASK_DONE) { - goto ok_taskfunc_qsfp_handle_tx_disable; - } - mdelay(delay_ms); - } - SWPS_INFO("%s auto setup tx_disable:0x%02x fail.\n", - task_p->transvr_p->swp_name, - task_p->transvr_p->auto_tx_disable); - return EVENT_TRANSVR_INIT_FAIL; - -ok_taskfunc_qsfp_handle_tx_disable: - SWPS_INFO("%s auto setup tx_disable:0x%02x ok.\n", - task_p->transvr_p->swp_name, - task_p->transvr_p->auto_tx_disable); - return EVENT_TRANSVR_TASK_DONE; -} - - -int -taskfunc_qsfp_set_hpmod(struct transvr_worker_s *task_p) { - - int err = DEBUG_TRANSVR_INT_VAL; - int HIGH_POWER_MODE = 0; - - /* Handle power mode */ - err = _taskfunc_qsfp_setup_power_mod(task_p->transvr_p, - HIGH_POWER_MODE); - if (err < 0) { - SWPS_INFO("%s: setup hpmod fail :%d :%s\n", - __func__, err, task_p->transvr_p->swp_name); - return err; - } - /* Handle auto tx_disable - * [Note] - * => Because there are some transceiver have timing issues or - * setup sequence issues, therefore we handle auto tx_disable - * after handle power mode. - */ - mdelay(100); - return taskfunc_qsfp_handle_tx_disable(task_p); -} - - -int -taskfunc_qsfp_set_lpmod(struct transvr_worker_s *task_p) { - - int LOW_POWER_MODE = 1; - return _taskfunc_qsfp_setup_power_mod(task_p->transvr_p, - LOW_POWER_MODE); -} - - -static int -initfunc_sfp_handle_multi_rate_mode(struct transvr_obj_s *self) { - - int task_retry = 3; - int err_code = DEBUG_TRANSVR_INT_VAL; - char *err_str = DEBUG_TRANSVR_STR_VAL; - char *func_str = "sfp_handle_multi_rate_mode"; - struct transvr_worker_s *task_p = NULL; - - switch (self->rate_id) { - case 0x00: /* Unspecified */ - case 0x03: /* Unspecified */ - case 0x05: /* Unspecified */ - case 0x07: /* Unspecified */ - case 0x09: /* Unspecified */ - case 0x0B: /* Unspecified */ - case 0x0D: /* Unspecified */ - case 0x0F: /* Unspecified */ - goto sfp_handle_multi_rate_mode_4_unspecified; - - case 0x02: /* SFF-8431 (8/4/2G Rx Rate_Select only) */ - task_p = transvr_task_creat(self, - taskfunc_sfp_setup_SFF8431_case1, - taskfunc_post_handle_task_state, - func_str); - goto sfp_handle_multi_rate_mode_4_sff8431; - - case 0x04: /* SFF-8431 (8/4/2G Tx Rate_Select only) */ - task_p = transvr_task_creat(self, - taskfunc_sfp_setup_SFF8431_case2, - taskfunc_post_handle_task_state, - func_str); - goto sfp_handle_multi_rate_mode_4_sff8431; - - case 0x06: /* SFF-8431 (8/4/2G Independent Rx & Tx Rate_select) */ - task_p = transvr_task_creat(self, - taskfunc_sfp_setup_SFF8431_case3, - taskfunc_post_handle_task_state, - func_str); - goto sfp_handle_multi_rate_mode_4_sff8431; - - case 0x01: /* SFF-8079 (4/2/1G Rate_Select & AS0/AS1) */ - err_str = "SFF-8079 (4/2/1G Rate_Select & AS0/AS1)"; - goto sfp_handle_multi_rate_mode_4_not_support; - - case 0x08: /* FC-PI-5 (16/8/4G Rx Rate_select only) - * High=16G only, Low=8G/4G - */ - err_str = "FC-PI-5 (16/8/4G Rx Rate_select only)"; - goto sfp_handle_multi_rate_mode_4_not_support; - - case 0x0A: /* FC-PI-5 (16/8/4G Independent Rx, Tx Rate_select) - * High=16G only, Low=8G/4G - */ - err_str = "FC-PI-5 (16/8/4G Independent Rx, Tx Rate_select)"; - goto sfp_handle_multi_rate_mode_4_not_support; - - case 0x0C: /* FC-PI-6 (32/16/8G Independent Rx, Tx Rate_Select) - * High=32G only, Low = 16G/8G - */ - err_str = "FC-PI-6 (32/16/8G Independent Rx, Tx Rate_Select)"; - goto sfp_handle_multi_rate_mode_4_not_support; - - case 0x0E: /* 10/8G Rx and Tx Rate_Select controlling the operation or - * locking modes of the internal signal conditioner, retimer - * or CDR, according to the logic table defined in Table 10-2, - * High Bit Rate (10G) =9.95-11.3 Gb/s; Low Bit Rate (8G) = - * 8.5 Gb/s. In this mode, the default value of bit 110.3 (Soft - * Rate Select RS(0), Table 9-11) and of bit 118.3 (Soft Rate - * Select RS(1), Table 10-1) is 1. - */ - err_str = "cable type: 0x0E"; - goto sfp_handle_multi_rate_mode_4_not_support; - - default: - err_str = "cable type: UNKNOW"; - goto sfp_handle_multi_rate_mode_4_not_support; - } - -sfp_handle_multi_rate_mode_4_sff8431: - if (!task_p) { - err_str = "Create task fail!"; - goto sfp_handle_multi_rate_mode_4_fail_1; - } - transvr_task_set_retry(task_p, task_retry); - return EVENT_TRANSVR_TASK_WAIT; - -sfp_handle_multi_rate_mode_4_unspecified: - return EVENT_TRANSVR_TASK_DONE; - -sfp_handle_multi_rate_mode_4_not_support: - SWPS_INFO("%s: Does not support %s :%s :0x%02x\n", - func_str, err_str, self->swp_name, self->rate_id); - return EVENT_TRANSVR_TASK_DONE; - -sfp_handle_multi_rate_mode_4_fail_1: - SWPS_INFO("%s: %s :%s :0x%02x, :%d\n", - func_str, err_str, self->swp_name, self->rate_id, err_code); - return EVENT_TRANSVR_INIT_FAIL; -} - - -static int -initfunc_sfp_handle_1g_rj45(struct transvr_obj_s *self) { - - struct transvr_worker_s *task_p = NULL; - int detect_cls = DEBUG_TRANSVR_INT_VAL; - char err_str[64] = DEBUG_TRANSVR_STR_VAL; - char *func_str = "initfunc_sfp_handle_1g_rj45"; - - - if (self->info == TRANSVR_CLASS_BASE_T_1000) { - task_p = transvr_task_creat(self, - taskfunc_sfp_handle_1g_rj45, - taskfunc_post_do_nothing, - func_str); - if (!task_p) { - snprintf(err_str, sizeof(err_str), "Create task fail"); - goto err_initfunc_sfp_handle_1g_rj45; - } - transvr_task_set_retry(task_p, VAL_TRANSVR_TASK_RETRY_FOREVER); - } - return EVENT_TRANSVR_TASK_DONE; - -err_initfunc_sfp_handle_1g_rj45: - SWPS_INFO("%s: %s :%s :%d\n", - __func__, err_str, self->swp_name, detect_cls); - return EVENT_TRANSVR_TASK_FAIL; -} - - -static int -initfunc_qsfp_handle_power_mode(struct transvr_obj_s *self) { - - int err_code = EVENT_TRANSVR_EXCEP_INIT; - int power_class = DEBUG_TRANSVR_INT_VAL; - int hpmod_retry = 3; - int lpower_config = 1; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - unsigned long hpmod_delay = 500; /* msec */ - struct transvr_worker_s *task_p = NULL; - - /* Handle power mode for IOEXP */ - power_class = __qsfp_get_power_cls(self, 0); - switch (power_class) { - case 1: /* Case: Low power mode (Class = 1) */ - err_code = _taskfunc_qsfp_setup_power_mod(self, lpower_config); - if (err_code < 0){ - snprintf(err_msg, sizeof(err_msg), "Setup lpmod fail :%d", err_code); - goto err_initfunc_qsfp_handle_power_mode; - } - return EVENT_TRANSVR_TASK_DONE; - - case 2: /* Case: High power mode (Class > 1) */ - case 3: - case 4: - case 5: - case 6: - case 7: - task_p = transvr_task_creat(self, - taskfunc_qsfp_set_hpmod, - taskfunc_post_handle_task_state, - "transvr_init_qsfp"); - if (!task_p) { - snprintf(err_msg, sizeof(err_msg), "Setup lpmod fail :%d", err_code); - goto err_initfunc_qsfp_handle_power_mode; - } - transvr_task_set_retry(task_p, hpmod_retry); - transvr_task_set_delay(task_p, hpmod_delay); - return EVENT_TRANSVR_TASK_WAIT; - - default: - break; - } - snprintf(err_msg, sizeof(err_msg), "Exception case"); - goto err_initfunc_qsfp_handle_power_mode; - -err_initfunc_qsfp_handle_power_mode: - SWPS_INFO("%s: %s :%s \n", __func__, err_msg, self->swp_name); - return EVENT_TRANSVR_INIT_FAIL; -} - - -int -initfunc_qsfp28_handle_cdr(struct transvr_obj_s *self) { - - uint8_t DEFAULT_VAL_CDR = 0xff; - int CDR_FUNC_EXISTED = 0x3; - int show_err = 1; - int err_val = EVENT_TRANSVR_TASK_FAIL; - char *err_msg = DEBUG_TRANSVR_STR_VAL; - char *func_str = "initfunc_qsfp28_handle_cdr"; - - err_val = __qsfp_get_cdr_present(self, 0); - if ( (err_val < 0) || - (err_val == DEBUG_TRANSVR_HEX_VAL) ) { - err_msg = "detect cdr_present fail!"; - goto err_taskfunc_qsfp_handle_cdr_1; - } - if (err_val == CDR_FUNC_EXISTED) { - err_val = _common_set_uint8_attr(self, - self->eeprom_map_p->addr_cdr, - self->eeprom_map_p->addr_cdr, - self->eeprom_map_p->offset_cdr, - DEFAULT_VAL_CDR, - &(self->cdr), - func_str, - show_err); - if (err_val < 0) { - err_msg = "set CDR fail!"; - goto err_taskfunc_qsfp_handle_cdr_1; - } - } - return EVENT_TRANSVR_TASK_DONE; - -err_taskfunc_qsfp_handle_cdr_1: - SWPS_INFO("%s: %s :%d :%s\n", - func_str, err_msg, err_val, self->swp_name); - return EVENT_TRANSVR_INIT_FAIL; -} - -/* ========== Object functions for Final State Machine ========== - */ -int -is_plugged(struct transvr_obj_s *self){ - - int limit = 63; - int present = DEBUG_TRANSVR_INT_VAL; - char emsg[64] = DEBUG_TRANSVR_STR_VAL; - struct ioexp_obj_s *ioexp_p = self->ioexp_obj_p; - - if (!ioexp_p) { - snprintf(emsg, limit, "ioexp_p is null!"); - goto err_is_plugged_1; - } - present = ioexp_p->get_present(ioexp_p, self->ioexp_virt_offset); - switch (present){ - case 0: - return 1; - case 1: - return 0; - case ERR_IOEXP_UNINIT: - snprintf(emsg, limit, "ioexp_p not ready!"); - goto err_is_plugged_1; - default: - if (ioexp_p->state == STATE_IOEXP_INIT){ - snprintf(emsg, limit, "ioexp_p not ready!"); - goto err_is_plugged_1; - } - break; - } - SWPS_INFO("%s: Exception case! :%d :%d\n", - __func__, present, ioexp_p->state); - return 0; - -err_is_plugged_1: - SWPS_DEBUG("%s: %s\n", __func__, emsg); - return 0; -} - - -static int -detect_transvr_type(struct transvr_obj_s* self){ - - int type = TRANSVR_TYPE_ERROR; - - self->i2c_client_p->addr = VAL_TRANSVR_COMID_ARREESS; - type = i2c_smbus_read_byte_data(self->i2c_client_p, - VAL_TRANSVR_COMID_OFFSET); - - /* Case: 1. Wait transceiver I2C module. - * 2. Transceiver I2C module failure. - * Note: 1. SFF allow maximum transceiver initial time is 2 second. So, there - * are exist some case that we need to wait transceiver. - * For these case, we keeps status on "TRANSVR_TYPE_UNPLUGGED", than - * state machine will keep trace with it. - * 2. There exist some I2C failure case we need to handle. Such as user - * insert the failure transceiver, or any reason cause it abnormal. - */ - if (type < 0){ - switch (type) { - case -EIO: - SWPS_DEBUG("%s: %s smbus return:-5 (I/O error)\n", - __func__, self->swp_name); - return TRANSVR_TYPE_UNPLUGGED; - case -ENXIO: - SWPS_DEBUG("%s: %s smbus return:-6 (No such device or address)\n", - __func__, self->swp_name); - return TRANSVR_TYPE_UNPLUGGED; - default: - break; - } - SWPS_INFO("%s: %s unexpected smbus return:%d \n", - __func__, self->swp_name, type); - return TRANSVR_TYPE_ERROR; - } - /* Identify valid transceiver type */ - switch (type){ - case TRANSVR_TYPE_SFP: - case TRANSVR_TYPE_QSFP: - case TRANSVR_TYPE_QSFP_PLUS: - case TRANSVR_TYPE_QSFP_28: - break; - case TRANSVR_TYPE_UNKNOW_1: - case TRANSVR_TYPE_UNKNOW_2: - type = TRANSVR_TYPE_UNKNOW_2; - break; - default: - SWPS_DEBUG("%s: unknow type:0x%02x \n", __func__, type); - type = TRANSVR_TYPE_ERROR; - break; - } - return type; -} - - -static int -detect_transvr_state(struct transvr_obj_s *self, - int result[2]){ - /* [return] [result-0] [result-1] - * 0 STATE_TRANSVR_CONNECTED TRANSVR_TYPE_FAKE - * 0 STATE_TRANSVR_DISCONNECTED TRANSVR_TYPE_UNPLUGGED - * 0 STATE_TRANSVR_ISOLATED TRANSVR_TYPE_ERROR - * 0 STATE_TRANSVR_INIT / - * 0 STATE_TRANSVR_SWAPPED - * 0 STATE_TRANSVR_CONNECTED - * ERR_TRNASVR_BE_ISOLATED STATE_TRANSVR_ISOLATED TRANSVR_TYPE_ERROR - * ERR_TRANSVR_I2C_CRASH STATE_TRANSVR_UNEXCEPTED TRANSVR_TYPE_ERROR - * ERR_TRANSVR_UNEXCPT STATE_TRANSVR_UNEXCEPTED TRANSVR_TYPE_UNKNOW_1/2 - */ - result[0] = STATE_TRANSVR_UNEXCEPTED; /* For return state */ - result[1] = TRANSVR_TYPE_ERROR; /* For return type */ - - /* Case1: Fake type */ - if (self->type == TRANSVR_TYPE_FAKE){ - result[0] = STATE_TRANSVR_CONNECTED; - result[1] = TRANSVR_TYPE_FAKE; - return 0; - } - /* Case2: Transceiver unplugged */ - if (!is_plugged(self)){ - result[0] = STATE_TRANSVR_DISCONNECTED; - result[1] = TRANSVR_TYPE_UNPLUGGED; - return 0; - } - /* Case3: Transceiver be isolated */ - if (self->state == STATE_TRANSVR_ISOLATED){ - result[0] = STATE_TRANSVR_ISOLATED; - result[1] = TRANSVR_TYPE_ERROR; - return ERR_TRNASVR_BE_ISOLATED; - } - /* Case4: Transceiver plugged */ - result[1] = detect_transvr_type(self); - /* Case4.1: I2C topology crash - * Note : There are some I2C issues cause by transceiver/cables. - * We need to check topology status when user insert it. - * But in this step, we can't not ensure this is the issues - * port. So, it return the ERR_TRANSVR_I2C_CRASH, then upper - * layer will diagnostic I2C topology. - */ - if (check_channel_tier_1() < 0) { - SWPS_INFO("%s: %s detect I2C crash :%d\n", - __func__, self->swp_name, self->state); - result[0] = STATE_TRANSVR_UNEXCEPTED; - result[1] = TRANSVR_TYPE_ERROR; - return ERR_TRANSVR_I2C_CRASH; - } - /* Case4.2: System initial not ready, - * Note : Sometime i2c channel or transceiver EEPROM will delay that will - * cause system in inconsistent state between EEPROM and IOEXP. - * In this case, SWP transceiver object keep state at LINK_DOWN - * to wait system ready. - * By the way, State Machine will handle these case. - */ - if (result[1] == TRANSVR_TYPE_UNPLUGGED){ - result[0] = STATE_TRANSVR_DISCONNECTED; - return 0; - } - /* Case4.3: Error transceiver type */ - if (result[1] == TRANSVR_TYPE_ERROR){ - result[0] = STATE_TRANSVR_ISOLATED; - SWPS_INFO("%s: %s detect error type\n", __func__, self->swp_name); - alarm_msg_2_user(self, "detected transceiver/cables not meet SFF standard!"); - return ERR_TRNASVR_BE_ISOLATED; - } - /* Case3.3: Unknow transceiver type */ - if ((result[1] == TRANSVR_TYPE_UNKNOW_1) || - (result[1] == TRANSVR_TYPE_UNKNOW_2) ){ - result[0] = STATE_TRANSVR_UNEXCEPTED; - return ERR_TRANSVR_UNEXCPT; - } - /* Case3.4: During initial process */ - if (self->state == STATE_TRANSVR_INIT){ - result[0] = STATE_TRANSVR_INIT; - return 0; - } - /* Case3.5: Transceiver be swapped */ - if (self->type != result[1]){ - result[0] = STATE_TRANSVR_SWAPPED; - return 0; - } - /* Case3.6: Link up state */ - result[0] = STATE_TRANSVR_CONNECTED; - return 0; -} - - -int -_sfp_detect_class_by_extend_comp(struct transvr_obj_s* self) { - /* Reference: SFF-8024 (v3.8) - */ - int detect_val = _sfp_get_comp_extended(self); - - switch(detect_val) { - case 0x00: /* Unspecified */ - return TRANSVR_CLASS_UNSPECIFIED; - - case 0x01: /* 100G AOC (Active Optical Cable) or 25GAUI C2M */ - case 0x18: /* 100G AOC or 25GAUI C2M AOC. */ - return TRANSVR_CLASS_OPTICAL_25G_AOC; - - case 0x02: /* 100GBASE-SR4 or 25GBASE-SR */ - return TRANSVR_CLASS_OPTICAL_25G_SR; - - case 0x03: /* 100GBASE-LR4 or 25GBASE-LR */ - return TRANSVR_CLASS_OPTICAL_25G_LR; - - case 0x04: /* 100GBASE-ER4 or 25GBASE-ER */ - return TRANSVR_CLASS_OPTICAL_25G_ER; - - case 0x08: /* 100G ACC (Active Copper Cable) or 25GAUI C2M ACC. */ - case 0x0b: /* 100GBASE-CR4 or 25GBASE-CR CA-L */ - case 0x0c: /* 25GBASE-CR CA-S */ - case 0x0d: /* 25GBASE-CR CA-N */ - case 0x19: /* 100G ACC or 25GAUI C2M ACC. */ - return TRANSVR_CLASS_COPPER_L1_25G; - - default: - break; - } - SWPS_INFO("%s: Unexcept value:0x%02x\n :%s", - __func__, detect_val, self->swp_name); - return TRANSVR_CLASS_ERROR; -} - - -int -_sfp_detect_class_by_10_ethernet(struct transvr_obj_s* self) { - /* Reference: SFF-8472 (v12.2) - */ - int detect_val = DEBUG_TRANSVR_INT_VAL; - - detect_val = _sfp_get_comp_10g_eth_comp(self); - /* Case: Unspecified */ - if (detect_val == 0x00) { - return TRANSVR_CLASS_UNSPECIFIED; - } - /* Case: 10G Optical (x1) */ - if ((detect_val & 0x10) == 0x10) { /* 00010000 : 10GBASE-SR */ - return TRANSVR_CLASS_OPTICAL_10G_S_SR; - } - if ( ((detect_val & 0x20) == 0x20) || /* 00100000 : 10GBASE-LR */ - ((detect_val & 0x40) == 0x40) ){ /* 01000000 : 10GBASE-LRM */ - return TRANSVR_CLASS_OPTICAL_10G_S_LR; - } - if ((detect_val & 0x80) == 0x80) { /* 10000000 : 10GBASE-ER */ - return TRANSVR_CLASS_OPTICAL_10G_S_ER; - } - /* Case: ERROR */ - SWPS_INFO("%s: Unexcept value:0x%02x\n :%s", - __func__, detect_val, self->swp_name); - return TRANSVR_CLASS_ERROR; -} - - -int -_sfp_detect_if_sp_by_br(struct transvr_obj_s* self) { - - int lower_bound_1g = 0x0b; - int upper_bound_1g = 0x1A; - int lower_bound_10g = 0x60; - int upper_bound_10g = 0x75; - int lower_bound_25g = 0xf0; - int upper_bound_25g = 0xff; - int notmal_br = DEBUG_TRANSVR_INT_VAL; - - notmal_br = (int)(self->br); /* updated by update_all() */ - /* Check 25G */ - if ((notmal_br >= lower_bound_25g) && - (notmal_br <= upper_bound_25g) ) { - return TRANSVR_CLASS_25G; - } - /* Check 10G */ - if ((notmal_br >= lower_bound_10g) && - (notmal_br <= upper_bound_10g) ) { - return TRANSVR_CLASS_10G; - } - /* Check 1G */ - if ((notmal_br >= lower_bound_1g) && - (notmal_br <= upper_bound_1g) ) { - return TRANSVR_CLASS_1G; - } - return TRANSVR_CLASS_UNSPECIFIED; -} - - -int -_sfp_detect_class_by_1g_ethernet(struct transvr_obj_s* self) { - /* Reference: SFF-8472 (v12.2) - */ - int detect_val = DEBUG_TRANSVR_INT_VAL; - int speed_br = DEBUG_TRANSVR_INT_VAL; - int speed_tmp = DEBUG_TRANSVR_INT_VAL; - char err_str[64] = DEBUG_TRANSVR_STR_VAL; - - speed_br = _sfp_detect_if_sp_by_br(self); - detect_val = _sfp_get_comp_1g_eth_comp(self); - - if (detect_val < 0) { - snprintf(err_str, sizeof(err_str), "Detect abnormal value:%d", detect_val); - goto err_p_sfp_detect_class_by_1g_ethernet; - } - /* Case: Unspecified */ - if (detect_val == 0x00) { - return TRANSVR_CLASS_UNSPECIFIED; - } - /* Case: 1G (x1) */ - if ((detect_val & 0x01) == 0x01) { /* 00000001 : 1000BASE-SX */ - speed_tmp = TRANSVR_CLASS_OPTICAL_1G_SX; - goto ok_sfp_detect_class_by_1g_ethernet_4_check_br_10g; - } - if ((detect_val & 0x02) == 0x02) { /* 00000010 : 1000BASE-LX *3 */ - speed_tmp = TRANSVR_CLASS_OPTICAL_1G_LX; - goto ok_sfp_detect_class_by_1g_ethernet_4_check_br_10g; - } - if ((detect_val & 0x04) == 0x04) { /* 00000100 : 1000BASE-CX */ - speed_tmp = TRANSVR_CLASS_COPPER_L1_1G; - goto ok_sfp_detect_class_by_1g_ethernet_4_check_br_10g; - } - /* Case: 1000 Base-T (x1) */ - if ((detect_val & 0x08) == 0x08) { /* 00001000 : 1000BASE-T */ - return TRANSVR_CLASS_BASE_T_1000; - } - /* Case: 100 Base */ - if ( ((detect_val & 0x10) == 0x10) || /* 00010000 : 100BASE-LX/LX10 */ - ((detect_val & 0x20) == 0x20) || /* 00100000 : 100BASE-FX */ - ((detect_val & 0x40) == 0x40) || /* 01000000 : BASE-BX10 *3 */ - ((detect_val & 0x80) == 0x80) ){ /* 10000000 : BASE-PX *3 */ - return TRANSVR_CLASS_OPTICAL_100; - } - /* Case: ERROR */ - snprintf(err_str, sizeof(err_str), "Case:ERROR, value:%d", detect_val); - goto err_p_sfp_detect_class_by_1g_ethernet; - -ok_sfp_detect_class_by_1g_ethernet_4_check_br_10g: - switch (speed_br) { - case TRANSVR_CLASS_UNSPECIFIED: - case TRANSVR_CLASS_1G: - return speed_tmp; - case TRANSVR_CLASS_10G: - goto ok_sfp_detect_class_by_1g_ethernet_4_transfer_10G; - } - -ok_sfp_detect_class_by_1g_ethernet_4_transfer_10G: - switch (speed_tmp) { - case TRANSVR_CLASS_OPTICAL_1G_SX: - return TRANSVR_CLASS_OPTICAL_10G_S_SR; - case TRANSVR_CLASS_OPTICAL_1G_LX: - return TRANSVR_CLASS_OPTICAL_10G_S_LR; - case TRANSVR_CLASS_COPPER_L1_1G: - return TRANSVR_CLASS_COPPER_L1_10G; - default: - break; - } - snprintf(err_str, sizeof(err_str), "transfer_1to10 fail, speed:%d", speed_tmp); - goto err_p_sfp_detect_class_by_1g_ethernet; - -err_p_sfp_detect_class_by_1g_ethernet: - SWPS_INFO("%s: %s :%s", __func__, err_str, self->swp_name); - return TRANSVR_CLASS_ERROR; -} - - -int -_sfp_detect_class_by_feature(struct transvr_obj_s* self) { - /* Reference: SFF-8024 (v3.8) - */ - int is_active = 0; - int conn_val = DEBUG_TRANSVR_INT_VAL; - int check_val = DEBUG_TRANSVR_INT_VAL; - int wave_len = DEBUG_TRANSVR_INT_VAL; - int speed_val = DEBUG_TRANSVR_INT_VAL; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - - speed_val = _sfp_detect_if_sp_by_br(self); - conn_val = _sfp_get_connector_type(self); - - switch(conn_val) { - case 0x00: /* Unspecified */ - goto ok_sfp_detect_class_by_feature_4_check_active_passive; - case 0x07: /* LC (Lucent Connector) */ - case 0x0b: /* Optical Pigtail */ - case 0x0c: /* MPO 1x12 */ - case 0x0d: /* MPO 2x16 */ - /* - * ToDo: Need verify Optical Pigtail - */ - goto ok_sfp_detect_class_by_feature_4_optiocal; - case 0x21: /* Copper pigtail */ - /* - * ToDo: Need check ACC use case - */ - goto ok_sfp_detect_class_by_feature_4_check_active_passive; - case 0x23: /* No separable connector */ - /* - * ToDo: Standard not clear, not all transceiver vendor - * have the same defined - */ - goto ok_sfp_detect_class_by_feature_4_check_active_passive; - default: - break; - } - goto ok_sfp_detect_class_by_feature_4_unknow; - -ok_sfp_detect_class_by_feature_4_check_active_passive: - check_val = _sfp_get_cable_tech(self); - switch(check_val) { - case 0x00: /* Unspecified */ - goto ok_sfp_detect_class_by_feature_4_unknow; - case 0x04: /* Passive */ - goto ok_sfp_detect_class_by_feature_4_copper; - case 0x08: /* Active */ - is_active = 1; - goto ok_sfp_detect_class_by_feature_4_aoc; - default: - snprintf(err_msg, sizeof(err_msg), - "_sfp_get_cable_tech return Non define value:%d", - check_val); - break; - } - goto err_sfp_detect_class_by_feature_1; - -ok_sfp_detect_class_by_feature_4_optiocal: - wave_len = _common_count_wavelength(self, - self->wavelength[0], - self->wavelength[1]); - switch(speed_val) { - case TRANSVR_CLASS_25G: - switch (wave_len) { - case VAL_OPTICAL_WAVELENGTH_SR: - return TRANSVR_CLASS_OPTICAL_25G_SR; - case VAL_OPTICAL_WAVELENGTH_LR: - return TRANSVR_CLASS_OPTICAL_25G_LR; - case VAL_OPTICAL_WAVELENGTH_ER: - return TRANSVR_CLASS_OPTICAL_25G_ER; - default: - break; - } - return TRANSVR_CLASS_OPTICAL_25G; - - case TRANSVR_CLASS_10G: - switch (wave_len) { - case VAL_OPTICAL_WAVELENGTH_SR: - return TRANSVR_CLASS_OPTICAL_10G_S_SR; - case VAL_OPTICAL_WAVELENGTH_LR: - return TRANSVR_CLASS_OPTICAL_10G_S_LR; - case VAL_OPTICAL_WAVELENGTH_ER: - return TRANSVR_CLASS_OPTICAL_10G_S_ER; - default: - break; - } - return TRANSVR_CLASS_OPTICAL_10G; - - case TRANSVR_CLASS_1G: - switch (wave_len) { - case VAL_OPTICAL_WAVELENGTH_SR: - return TRANSVR_CLASS_OPTICAL_1G_SX; - case VAL_OPTICAL_WAVELENGTH_LR: - return TRANSVR_CLASS_OPTICAL_1G_LX; - case VAL_OPTICAL_WAVELENGTH_ER: - return TRANSVR_CLASS_OPTICAL_1G_EX; - default: - break; - } - return TRANSVR_CLASS_OPTICAL_1G; - - default: - return TRANSVR_CLASS_OPTICAL; - } - -ok_sfp_detect_class_by_feature_4_aoc: - switch(speed_val) { - case TRANSVR_CLASS_25G: - return TRANSVR_CLASS_OPTICAL_25G_AOC; - case TRANSVR_CLASS_10G: - return TRANSVR_CLASS_OPTICAL_10G_S_AOC; - case TRANSVR_CLASS_1G: - return TRANSVR_CLASS_OPTICAL_1G_AOC; - default: - break; - } - goto ok_sfp_detect_class_by_feature_4_unknow; - -ok_sfp_detect_class_by_feature_4_copper: - switch(speed_val) { - case TRANSVR_CLASS_25G: - return TRANSVR_CLASS_COPPER_L1_25G; - case TRANSVR_CLASS_10G: - return TRANSVR_CLASS_COPPER_L1_10G; - case TRANSVR_CLASS_1G: - return TRANSVR_CLASS_COPPER_L1_1G; - default: - return TRANSVR_CLASS_COPPER; - } - -ok_sfp_detect_class_by_feature_4_unknow: - return TRANSVR_CLASS_UNSPECIFIED; - -err_sfp_detect_class_by_feature_1: - SWPS_INFO("%s: %s\n :%s", __func__, err_msg, self->swp_name); - return TRANSVR_CLASS_ERROR; -} - - -int -sft_detect_transvr_class(struct transvr_obj_s* self) { - - int detect_val = DEBUG_TRANSVR_INT_VAL; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - - /* Check Extended Compliance */ - detect_val = _sfp_detect_class_by_extend_comp(self); - switch(detect_val) { - case TRANSVR_CLASS_UNSPECIFIED: - break; - case TRANSVR_CLASS_OPTICAL_25G_AOC: - case TRANSVR_CLASS_OPTICAL_25G_SR: - case TRANSVR_CLASS_OPTICAL_25G_LR: - case TRANSVR_CLASS_OPTICAL_25G_ER: - case TRANSVR_CLASS_COPPER_L1_25G: - return detect_val; - default: - snprintf(err_msg, sizeof(err_msg), - "Detect undefined extend_comp:%d", - detect_val); - goto err_sft_detect_transceiver_class_1; - } - /* Check 10G Compliance */ - detect_val = _sfp_detect_class_by_10_ethernet(self); - switch(detect_val) { - case TRANSVR_CLASS_UNSPECIFIED: - break; - case TRANSVR_CLASS_OPTICAL_10G_S_SR: - case TRANSVR_CLASS_OPTICAL_10G_S_LR: - case TRANSVR_CLASS_OPTICAL_10G_S_ER: - return detect_val; - default: - snprintf(err_msg, sizeof(err_msg), - "Detect undefined 10G_eth:%d", - detect_val); - goto err_sft_detect_transceiver_class_1; - } - /* Check 1G Compliance */ - detect_val = _sfp_detect_class_by_1g_ethernet(self); - switch(detect_val) { - case TRANSVR_CLASS_UNSPECIFIED: - break; - case TRANSVR_CLASS_OPTICAL_1G_SX: - case TRANSVR_CLASS_OPTICAL_1G_LX: - case TRANSVR_CLASS_COPPER_L1_1G: - case TRANSVR_CLASS_BASE_T_1000: - case TRANSVR_CLASS_OPTICAL_100: - /* - * ToDo: Need Check 0.1G - */ - case TRANSVR_CLASS_OPTICAL_10G_S_SR: - case TRANSVR_CLASS_OPTICAL_10G_S_LR: - case TRANSVR_CLASS_COPPER_L1_10G: - /* Transfer speed case - * => Example: Raycom 10G DAC - */ - return detect_val; - default: - snprintf(err_msg, sizeof(err_msg), - "Detect undefined 1G_eth:%d", - detect_val); - goto err_sft_detect_transceiver_class_1; - } - /* Check by connector, br, wavelength */ - detect_val = _sfp_detect_class_by_feature(self); - switch(detect_val) { - case TRANSVR_CLASS_UNSPECIFIED: - break; - case TRANSVR_CLASS_OPTICAL: - case TRANSVR_CLASS_OPTICAL_1G: - case TRANSVR_CLASS_OPTICAL_1G_SX: - case TRANSVR_CLASS_OPTICAL_1G_LX: - case TRANSVR_CLASS_OPTICAL_1G_EX: - case TRANSVR_CLASS_OPTICAL_1G_AOC: - case TRANSVR_CLASS_OPTICAL_10G: - case TRANSVR_CLASS_OPTICAL_10G_S_SR: - case TRANSVR_CLASS_OPTICAL_10G_S_LR: - case TRANSVR_CLASS_OPTICAL_10G_S_ER: - case TRANSVR_CLASS_OPTICAL_10G_S_AOC: - case TRANSVR_CLASS_OPTICAL_25G: - case TRANSVR_CLASS_OPTICAL_25G_SR: - case TRANSVR_CLASS_OPTICAL_25G_LR: - case TRANSVR_CLASS_OPTICAL_25G_ER: - case TRANSVR_CLASS_OPTICAL_25G_AOC: - case TRANSVR_CLASS_COPPER: - case TRANSVR_CLASS_COPPER_L1_1G: - case TRANSVR_CLASS_COPPER_L1_10G: - case TRANSVR_CLASS_COPPER_L1_25G: - return detect_val; - default: - snprintf(err_msg, sizeof(err_msg), - "Detect undefined get_connector:%d", - detect_val); - goto err_sft_detect_transceiver_class_1; - } - /* Exception case: Can't verify */ - snprintf(err_msg, sizeof(err_msg), "Can not identify!"); - goto err_sft_detect_transceiver_class_1; - -err_sft_detect_transceiver_class_1: - SWPS_INFO("%s: %s :%s\n", __func__, err_msg, self->swp_name); - return TRANSVR_CLASS_ERROR; -} - - -int -_sfp_set_magnolia_if_type(struct transvr_obj_s* self, - int transvr_cls, - char *result){ - - int lmax = 8; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - - switch(transvr_cls) { - case TRANSVR_CLASS_ERROR: - case TRANSVR_CLASS_UNSPECIFIED: - break; - /* 25G OPTICAL */ - case TRANSVR_CLASS_OPTICAL_25G_AOC: - case TRANSVR_CLASS_OPTICAL_25G_SR: - case TRANSVR_CLASS_OPTICAL_25G_LR: - case TRANSVR_CLASS_OPTICAL_25G_ER: - case TRANSVR_CLASS_OPTICAL_25G: - return snprintf(result, lmax, TRANSVR_IF_SFI); - /* 25G COPPER */ - case TRANSVR_CLASS_COPPER_L1_25G: - return snprintf(result, lmax, TRANSVR_IF_SFI); - /* 10G OPTICAL */ - case TRANSVR_CLASS_OPTICAL_10G_S_AOC: - case TRANSVR_CLASS_OPTICAL_10G_S_SR: - case TRANSVR_CLASS_OPTICAL_10G_S_LR: - case TRANSVR_CLASS_OPTICAL_10G_S_ER: - case TRANSVR_CLASS_OPTICAL_10G: - return snprintf(result, lmax, TRANSVR_IF_SFI); - /* 10G COPPER */ - case TRANSVR_CLASS_COPPER_L1_10G: - return snprintf(result, lmax, TRANSVR_IF_SFI); - /* 1G OPTICAL */ - case TRANSVR_CLASS_OPTICAL_1G_AOC: - case TRANSVR_CLASS_OPTICAL_1G_SX: - case TRANSVR_CLASS_OPTICAL_1G_LX: - case TRANSVR_CLASS_OPTICAL_1G_EX: - case TRANSVR_CLASS_OPTICAL_1G: - return snprintf(result, lmax, TRANSVR_IF_IF_GMII); - /* 1G COPPER */ - case TRANSVR_CLASS_COPPER_L1_1G: - return snprintf(result, lmax, TRANSVR_IF_IF_GMII); - /* 1G BASE_T */ - case TRANSVR_CLASS_BASE_T_1000: - return snprintf(result, lmax, TRANSVR_IF_IF_GMII); - /* 100 Base */ - case TRANSVR_CLASS_OPTICAL_100: - return snprintf(result, lmax, TRANSVR_IF_IF_GMII); - default: - snprintf(err_msg, sizeof(err_msg), - "Detect undefined value:%d", - transvr_cls); - goto err_sfp_set_magnolia_if_type_1; - } - /* Exception case: Can't verify */ - snprintf(err_msg, sizeof(err_msg), "Can not identify!"); - goto err_sfp_set_magnolia_if_type_1; - -err_sfp_set_magnolia_if_type_1: - snprintf(result, lmax, TRANSVR_UEVENT_UNKNOW); - SWPS_INFO("%s: %s :%s\n", __func__, err_msg, self->swp_name); - return ERR_TRANSVR_ABNORMAL; -} - - -int -_sfp_set_redwood_if_type(struct transvr_obj_s* self, - int transvr_cls, - char *result) { - - int lmax = 8; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - - switch(transvr_cls) { - case TRANSVR_CLASS_ERROR: - case TRANSVR_CLASS_UNSPECIFIED: - break; - /* 25G OPTICAL */ - case TRANSVR_CLASS_OPTICAL_25G_AOC: - case TRANSVR_CLASS_OPTICAL_25G_SR: - case TRANSVR_CLASS_OPTICAL_25G_LR: - case TRANSVR_CLASS_OPTICAL_25G_ER: - case TRANSVR_CLASS_OPTICAL_25G: - return snprintf(result, lmax, TRANSVR_IF_SR); - /* 25G COPPER */ - case TRANSVR_CLASS_COPPER_L1_25G: - return snprintf(result, lmax, TRANSVR_IF_KR); - /* 10G OPTICAL */ - case TRANSVR_CLASS_OPTICAL_10G_S_AOC: - case TRANSVR_CLASS_OPTICAL_10G_S_SR: - case TRANSVR_CLASS_OPTICAL_10G_S_LR: - case TRANSVR_CLASS_OPTICAL_10G_S_ER: - case TRANSVR_CLASS_OPTICAL_10G: - return snprintf(result, lmax, TRANSVR_IF_SFI); - /* 10G COPPER */ - case TRANSVR_CLASS_COPPER_L1_10G: - return snprintf(result, lmax, TRANSVR_IF_SFI); - /* 1G OPTICAL */ - case TRANSVR_CLASS_OPTICAL_1G_AOC: - case TRANSVR_CLASS_OPTICAL_1G_SX: - case TRANSVR_CLASS_OPTICAL_1G_LX: - case TRANSVR_CLASS_OPTICAL_1G_EX: - case TRANSVR_CLASS_OPTICAL_1G: - return snprintf(result, lmax, TRANSVR_IF_IF_GMII); - /* 1G COPPER */ - case TRANSVR_CLASS_COPPER_L1_1G: - return snprintf(result, lmax, TRANSVR_IF_IF_GMII); - /* 1G BASE_T */ - case TRANSVR_CLASS_BASE_T_1000: - return snprintf(result, lmax, TRANSVR_IF_IF_GMII); - /* 100 Base */ - case TRANSVR_CLASS_OPTICAL_100: - return snprintf(result, lmax, TRANSVR_IF_IF_GMII); - default: - snprintf(err_msg, sizeof(err_msg), - "Detect undefined value:%d", - transvr_cls); - goto err_sfp_set_redwood_if_type_1; - } - /* Exception case: Can't verify */ - snprintf(err_msg, sizeof(err_msg), "Can not identify!"); - goto err_sfp_set_redwood_if_type_1; - -err_sfp_set_redwood_if_type_1: - snprintf(result, lmax, TRANSVR_UEVENT_UNKNOW); - SWPS_INFO("%s: %s\n :%s", __func__, err_msg, self->swp_name); - return ERR_TRANSVR_ABNORMAL; -} - - -int -_sfp_set_lavender_if_type(struct transvr_obj_s* self, - int transvr_cls, - char *result) { - /* (TBD) - * Due to 'LAV' looks like doesn't have interface type. - * We bypass it currently. - */ - int lmax = 8; - return snprintf(result, lmax, TRANSVR_UEVENT_UNKNOW); -} - - -int -_sfp_detect_if_type(struct transvr_obj_s* self, - char *result){ - - int lmax = 8; - int detect_cls = DEBUG_TRANSVR_INT_VAL; - - detect_cls = sft_detect_transvr_class(self); - switch (self->chipset_type) { - case CHIP_TYPE_MAGNOLIA: - return _sfp_set_magnolia_if_type(self, detect_cls, result); - - case CHIP_TYPE_MAPLE: - case CHIP_TYPE_REDWOOD: - return _sfp_set_redwood_if_type(self, detect_cls, result); - - case CHIP_TYPE_LAVENDER: - return _sfp_set_lavender_if_type(self, detect_cls, result); - - default: - SWPS_INFO("%s: non-defined chipset_type:%d :%s\n", - __func__, self->chipset_type, self->swp_name); - break; - } - snprintf(result, lmax, TRANSVR_UEVENT_UNKNOW); - return ERR_TRANSVR_ABNORMAL; -} - - -int -sfp_get_if_type(struct transvr_obj_s *self, - char *buf_p){ - - int lmax = 16; - char tmp_result[16] = DEBUG_TRANSVR_STR_VAL; - - if (self->state != STATE_TRANSVR_CONNECTED) { - return snprintf(buf_p, lmax, "%d\n", self->state); - } - if (_sfp_detect_if_type(self, tmp_result) < 0) { - return snprintf(buf_p, lmax, "%d\n", ERR_TRANSVR_ABNORMAL); - } - return snprintf(buf_p, lmax, "%s\n", tmp_result); -} - - -int -_sfp_detect_if_speed(struct transvr_obj_s* self, - char *result){ - - int lmax = 16; - int detect_val = DEBUG_TRANSVR_INT_VAL; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - - detect_val = sft_detect_transvr_class(self); - switch(detect_val) { - case TRANSVR_CLASS_ERROR: - case TRANSVR_CLASS_UNSPECIFIED: - break; - /* 25G OPTICAL */ - case TRANSVR_CLASS_OPTICAL_25G_AOC: - case TRANSVR_CLASS_OPTICAL_25G_SR: - case TRANSVR_CLASS_OPTICAL_25G_LR: - case TRANSVR_CLASS_OPTICAL_25G_ER: - case TRANSVR_CLASS_OPTICAL_25G: - return snprintf(result, lmax, TRANSVR_IF_SP_25G); - /* 25G COPPER */ - case TRANSVR_CLASS_COPPER_L1_25G: - return snprintf(result, lmax, TRANSVR_IF_SP_25G); - /* 10G OPTICAL */ - case TRANSVR_CLASS_OPTICAL_10G_S_AOC: - case TRANSVR_CLASS_OPTICAL_10G_S_SR: - case TRANSVR_CLASS_OPTICAL_10G_S_LR: - case TRANSVR_CLASS_OPTICAL_10G_S_ER: - case TRANSVR_CLASS_OPTICAL_10G: - return snprintf(result, lmax, TRANSVR_IF_SP_10G); - /* 10G COPPER */ - case TRANSVR_CLASS_COPPER_L1_10G: - return snprintf(result, lmax, TRANSVR_IF_SP_10G); - /* 1G OPTICAL */ - case TRANSVR_CLASS_OPTICAL_1G_AOC: - case TRANSVR_CLASS_OPTICAL_1G_SX: - case TRANSVR_CLASS_OPTICAL_1G_LX: - case TRANSVR_CLASS_OPTICAL_1G_EX: - case TRANSVR_CLASS_OPTICAL_1G: - return snprintf(result, lmax, TRANSVR_IF_SP_1G); - /* 1G COPPER */ - case TRANSVR_CLASS_COPPER_L1_1G: - return snprintf(result, lmax, TRANSVR_IF_SP_1G); - /* 1G BASE_T */ - case TRANSVR_CLASS_BASE_T_1000: - return snprintf(result, lmax, TRANSVR_IF_SP_1G); - /* 100 Base */ - case TRANSVR_CLASS_OPTICAL_100: - return snprintf(result, lmax, TRANSVR_IF_SP_100); - default: - snprintf(err_msg, sizeof(err_msg), - "Detect undefined value:%d", - detect_val); - goto err_sfp_detect_if_speed_1; - } - /* Check by BR */ - detect_val = _sfp_detect_if_sp_by_br(self); - switch (detect_val) { - case TRANSVR_CLASS_25G: - return snprintf(result, lmax, TRANSVR_IF_SP_25G); - case TRANSVR_CLASS_10G: - return snprintf(result, lmax, TRANSVR_IF_SP_10G); - case TRANSVR_CLASS_1G: - return snprintf(result, lmax, TRANSVR_IF_SP_1G); - default: - break; - } - /* Exception case: Can't verify */ - snprintf(err_msg, sizeof(err_msg), "Can not identify!"); - goto err_sfp_detect_if_speed_1; - -err_sfp_detect_if_speed_1: - snprintf(result, lmax, TRANSVR_UEVENT_UNKNOW); - SWPS_INFO("%s %s\n :%s", __func__, err_msg, self->swp_name); - return ERR_TRANSVR_ABNORMAL; -} - - -int -sfp_get_if_speed(struct transvr_obj_s *self, - char *buf_p){ - - int lmax = 16; - char tmp_result[16] = DEBUG_TRANSVR_STR_VAL; - - if (self->state != STATE_TRANSVR_CONNECTED) { - return snprintf(buf_p, lmax, "%d\n", self->state); - } - if (_sfp_detect_if_speed(self, tmp_result) < 0) { - return snprintf(buf_p, lmax, "%d\n", ERR_TRANSVR_ABNORMAL); - } - return snprintf(buf_p, lmax, "%s\n", tmp_result); -} - - -int -_qsfp_detect_class_by_extend_comp(struct transvr_obj_s* self) { - /* Reference: SFF-8024 (v3.8) - */ - int detect_val = DEBUG_TRANSVR_INT_VAL; - - detect_val = _qsfp_get_comp_extended(self); - switch(detect_val) { - case 0x00: /* Unspecified */ - return TRANSVR_CLASS_UNSPECIFIED; - - case 0x01: /* 100G AOC (Active Optical Cable) or 25GAUI C2M */ - case 0x18: /* 100G AOC or 25GAUI C2M AOC. */ - return TRANSVR_CLASS_OPTICAL_100G_AOC; - - case 0x06: /* 100G CWDM4 */ - case 0x09: /* Obsolete (assigned before 100G CWDM4 MSA required FEC) */ - case 0x17: /* 100G CLR4 */ - case 0x1A: /* 100GE-DWDM2 */ - return TRANSVR_CLASS_OPTICAL_100G; - - case 0x02: /* 100GBASE-SR4 or 25GBASE-SR */ - return TRANSVR_CLASS_OPTICAL_100G_SR4; - - case 0x03: /* 100GBASE-LR4 or 25GBASE-LR */ - return TRANSVR_CLASS_OPTICAL_100G_LR4; - - case 0x04: /* 100GBASE-ER4 or 25GBASE-ER */ - return TRANSVR_CLASS_OPTICAL_100G_ER4; - - case 0x07: /* 100G PSM4 Parallel SMF */ - return TRANSVR_CLASS_OPTICAL_100G_PSM4; - - case 0x12: /* 40G PSM4 Parallel SMF */ - return TRANSVR_CLASS_OPTICAL_40G; - - case 0x11: /* 4 x 10GBASE-SR */ - return TRANSVR_CLASS_OPTICAL_40G_SR4; - - case 0x10: /* 40GBASE-ER4 */ - return TRANSVR_CLASS_OPTICAL_40G_ER4; - - case 0x08: /* 100G ACC (Active Copper Cable) or 25GAUI C2M ACC. */ - case 0x0b: /* 100GBASE-CR4 or 25GBASE-CR CA-L */ - case 0x19: /* 100G ACC or 25GAUI C2M ACC. */ - return TRANSVR_CLASS_COPPER_L4_100G; - - default: - break; - } - SWPS_INFO("%s: Unexcept value:0x%02x\n :%s", - __func__, detect_val, self->swp_name); - return TRANSVR_CLASS_ERROR; -} - - -int -_qsfp_detect_class_by_10_40_100_ethernet(struct transvr_obj_s* self) { - /* Reference: SFF-8472 (v12.2) - */ - int detect_val = DEBUG_TRANSVR_INT_VAL; - - detect_val = _qsfp_get_comp_10_40_100_ethernet(self); - /* Case: Unspecified */ - if (detect_val == 0x00) { - return TRANSVR_CLASS_UNSPECIFIED; - } - /* Case: 40G Optical */ - if ((detect_val & 0x01) == 0x01) { /* 00000001 : 40G Active Cable (XLPPI) */ - return TRANSVR_CLASS_OPTICAL_40G_AOC; - } - if ((detect_val & 0x04) == 0x04) { /* 00000100 : 40GBASE-SR4 */ - return TRANSVR_CLASS_OPTICAL_40G_SR4; - } - if ( (detect_val & 0x02) == 0x02) { /* 00000010 : 40GBASE-LR4 */ - return TRANSVR_CLASS_OPTICAL_40G_LR4; - } - if ( (detect_val & 0x08) == 0x08) { /* 00001000 : 40GBASE-CR4 */ - return TRANSVR_CLASS_COPPER_L4_40G; - } - /* Case: 10G Optical */ - if ( (detect_val & 0x10) == 0x10) { /* 00010000 : 10GBASE-SR */ - return TRANSVR_CLASS_OPTICAL_10G_Q_SR; - } - if ( ((detect_val & 0x20) == 0x20) || /* 00100000 : 10GBASE-LR */ - ((detect_val & 0x40) == 0x40) ){ /* 01000000 : 10GBASE-LRM */ - return TRANSVR_CLASS_OPTICAL_10G_Q_LR; - } - /* Case: Extend Compliance */ - if ( ((detect_val & 0x80) == 0x80) ){ /* 10000000 : Use Extend Compliance */ - return TRANSVR_CLASS_EXTEND_COMP; - } - /* Case: ERROR */ - SWPS_INFO("%s: Unexcept value:0x%02x\n :%s", - __func__, detect_val, self->swp_name); - return TRANSVR_CLASS_ERROR; -} - - -int -_qsfp_detect_if_sp_by_br(struct transvr_obj_s* self) { - - int lower_bound_10g = 0x10; - int upper_bound_10g = 0x25; - int lower_bound_40g = 0x60; - int upper_bound_40g = 0x75; - int lower_bound_100g = 0x60; - int upper_bound_100g = 0x75; - int used_extend_br = 0xff; - int notmal_br = DEBUG_TRANSVR_INT_VAL; - int extend_br = DEBUG_TRANSVR_INT_VAL; - - notmal_br = (int)(self->br); /* updated by update_all() */ - /* Check 40G */ - if ((notmal_br >= lower_bound_40g) && - (notmal_br <= upper_bound_40g) ) { - return TRANSVR_CLASS_40G; - } - /* Check 100G */ - if (notmal_br == used_extend_br) { - extend_br = (int)(self->extbr); /* updated by update_all() */ - if ((extend_br >= lower_bound_100g) && - (extend_br <= upper_bound_100g) ) { - return TRANSVR_CLASS_100G; - } - } - /* Check 10G */ - if ((notmal_br >= lower_bound_10g) && - (notmal_br <= upper_bound_10g) ) { - return TRANSVR_CLASS_10G; - } - return TRANSVR_CLASS_UNSPECIFIED; -} - - -int -_qsfp_detect_class_by_feature(struct transvr_obj_s* self) { - /* Reference: SFF-8024 (v3.8) - */ - int conn_val = DEBUG_TRANSVR_INT_VAL; - int wave_len = DEBUG_TRANSVR_INT_VAL; - int speed_val = DEBUG_TRANSVR_INT_VAL; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - - speed_val = _qsfp_detect_if_sp_by_br(self); - conn_val = _qsfp_get_connector_type(self); - - switch(conn_val) { - case 0x00: /* Unspecified */ - return TRANSVR_CLASS_UNSPECIFIED; - case 0x07: /* LC (Lucent Connector) */ - case 0x0b: /* Optical Pigtail */ - case 0x0c: /* MPO 1x12 (Multifiber Parallel Optic) */ - case 0x0d: /* MPO 2x16 */ - goto ok_qsfp_detect_class_by_feature_4_optiocal; - case 0x21: /* Copper pigtail */ - goto ok_qsfp_detect_class_by_feature_4_copper; - case 0x23: /* No separable connector */ - if ((_qsfp_get_comp_fc_link_length(self) > 0) || - (_qsfp_get_comp_fc_trans_tech(self) > 0) || - (_qsfp_get_comp_fc_trans_media(self) > 0) || - (_qsfp_get_comp_fc_speed(self) > 0) ) { - goto ok_qsfp_detect_class_by_feature_4_aoc; - } - goto ok_qsfp_detect_class_by_feature_4_copper; - default: - snprintf(err_msg, sizeof(err_msg), - "_qsfp_get_connector_type return Non define value:%d", - conn_val); - goto err_qsfp_detect_class_by_feature_1; - } - return TRANSVR_CLASS_UNSPECIFIED; - -ok_qsfp_detect_class_by_feature_4_optiocal: - wave_len = _common_count_wavelength(self, - self->wavelength[0], - self->wavelength[1]); - switch(speed_val) { - case TRANSVR_CLASS_100G: - switch (wave_len) { - case VAL_OPTICAL_WAVELENGTH_SR: - return TRANSVR_CLASS_OPTICAL_100G_SR4; - case VAL_OPTICAL_WAVELENGTH_LR: - return TRANSVR_CLASS_OPTICAL_100G_LR4; - case VAL_OPTICAL_WAVELENGTH_ER: - return TRANSVR_CLASS_OPTICAL_100G_ER4; - default: - break; - } - return TRANSVR_CLASS_OPTICAL_100G; - - case TRANSVR_CLASS_40G: - switch (wave_len) { - case VAL_OPTICAL_WAVELENGTH_SR: - return TRANSVR_CLASS_OPTICAL_40G_SR4; - case VAL_OPTICAL_WAVELENGTH_LR: - return TRANSVR_CLASS_OPTICAL_40G_LR4; - case VAL_OPTICAL_WAVELENGTH_ER: - return TRANSVR_CLASS_OPTICAL_40G_ER4; - default: - break; - } - return TRANSVR_CLASS_OPTICAL_40G; - - case TRANSVR_CLASS_10G: - switch (wave_len) { - case VAL_OPTICAL_WAVELENGTH_SR: - return TRANSVR_CLASS_OPTICAL_10G_Q_SR; - case VAL_OPTICAL_WAVELENGTH_LR: - return TRANSVR_CLASS_OPTICAL_10G_Q_LR; - case VAL_OPTICAL_WAVELENGTH_ER: - return TRANSVR_CLASS_OPTICAL_10G_Q_ER; - default: - break; - } - return TRANSVR_CLASS_OPTICAL_10G; - - default: - return TRANSVR_CLASS_OPTICAL; - } - -ok_qsfp_detect_class_by_feature_4_aoc: - switch(speed_val) { - case TRANSVR_CLASS_100G: - return TRANSVR_CLASS_OPTICAL_100G_AOC; - case TRANSVR_CLASS_40G: - return TRANSVR_CLASS_OPTICAL_40G_AOC; - case TRANSVR_CLASS_10G: - return TRANSVR_CLASS_OPTICAL_10G_Q_AOC; - default: - return TRANSVR_CLASS_OPTICAL; - } - -ok_qsfp_detect_class_by_feature_4_copper: - switch(speed_val) { - case TRANSVR_CLASS_100G: - return TRANSVR_CLASS_COPPER_L4_100G; - case TRANSVR_CLASS_40G: - return TRANSVR_CLASS_COPPER_L4_40G; - case TRANSVR_CLASS_10G: - return TRANSVR_CLASS_COPPER_L4_10G; - default: - return TRANSVR_CLASS_COPPER; - } - -err_qsfp_detect_class_by_feature_1: - SWPS_INFO("%s: %s\n :%s", - __func__, err_msg, self->swp_name); - return TRANSVR_CLASS_ERROR; -} - - -int -qsft_detect_transvr_class(struct transvr_obj_s* self) { - - int detect_val = DEBUG_TRANSVR_INT_VAL; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - - /* Check Extended Compliance */ - detect_val = _qsfp_detect_class_by_extend_comp(self); - switch (detect_val) { - case TRANSVR_CLASS_UNSPECIFIED: - break; - case TRANSVR_CLASS_OPTICAL_100G: - case TRANSVR_CLASS_OPTICAL_100G_AOC: - case TRANSVR_CLASS_OPTICAL_100G_SR4: - case TRANSVR_CLASS_OPTICAL_100G_LR4: - case TRANSVR_CLASS_OPTICAL_100G_ER4: - case TRANSVR_CLASS_OPTICAL_100G_PSM4: - case TRANSVR_CLASS_OPTICAL_40G: - case TRANSVR_CLASS_OPTICAL_40G_AOC: - case TRANSVR_CLASS_OPTICAL_40G_SR4: - case TRANSVR_CLASS_OPTICAL_40G_LR4: - case TRANSVR_CLASS_OPTICAL_40G_ER4: - case TRANSVR_CLASS_COPPER_L4_100G: - return detect_val; - default: - snprintf(err_msg, sizeof(err_msg), - "Detect undefined extend_comp:%d", - detect_val); - goto err_qsft_detect_transvr_class_1; - } - /* Check 10/40G/100G Ethernet Compliance */ - detect_val = _qsfp_detect_class_by_10_40_100_ethernet(self); - switch(detect_val) { - case TRANSVR_CLASS_UNSPECIFIED: - break; - case TRANSVR_CLASS_OPTICAL_40G_AOC: - case TRANSVR_CLASS_OPTICAL_40G_SR4: - case TRANSVR_CLASS_OPTICAL_40G_LR4: - case TRANSVR_CLASS_OPTICAL_10G_Q_SR: /* Need Check: SR4 or SR */ - case TRANSVR_CLASS_OPTICAL_10G_Q_LR: /* Need Check: SR4 or SR */ - case TRANSVR_CLASS_COPPER_L4_40G: - return detect_val; - case TRANSVR_CLASS_EXTEND_COMP: - /* Format incorrect case (We already checked the Extend - * Compliance is 0 - */ - snprintf(err_msg, sizeof(err_msg), - "Transceiver format incorrect"); - goto err_qsft_detect_transvr_class_1; - default: - snprintf(err_msg, sizeof(err_msg), - "Detect undefined 10/40/100:%d", - detect_val); - goto err_qsft_detect_transvr_class_1; - } - /* Check by Connector type, BR and wavelength */ - detect_val = _qsfp_detect_class_by_feature(self); - switch (detect_val) { - case TRANSVR_CLASS_UNSPECIFIED: - break; - case TRANSVR_CLASS_OPTICAL_100G_ER4: - case TRANSVR_CLASS_OPTICAL_100G_LR4: - case TRANSVR_CLASS_OPTICAL_100G_SR4: - case TRANSVR_CLASS_OPTICAL_100G_AOC: - case TRANSVR_CLASS_OPTICAL_100G: - case TRANSVR_CLASS_OPTICAL_40G_ER4: - case TRANSVR_CLASS_OPTICAL_40G_LR4: - case TRANSVR_CLASS_OPTICAL_40G_SR4: - case TRANSVR_CLASS_OPTICAL_40G_AOC: - case TRANSVR_CLASS_OPTICAL_40G: - case TRANSVR_CLASS_OPTICAL_10G_Q_ER: - case TRANSVR_CLASS_OPTICAL_10G_Q_LR: - case TRANSVR_CLASS_OPTICAL_10G_Q_SR: - case TRANSVR_CLASS_OPTICAL_10G_Q_AOC: - case TRANSVR_CLASS_OPTICAL_10G: - case TRANSVR_CLASS_OPTICAL: - case TRANSVR_CLASS_COPPER_L4_100G: - case TRANSVR_CLASS_COPPER_L4_40G: - case TRANSVR_CLASS_COPPER_L4_10G: - case TRANSVR_CLASS_COPPER: - return detect_val; - default: - snprintf(err_msg, sizeof(err_msg), - "Detect undefined connector:%d", - detect_val); - goto err_qsft_detect_transvr_class_1; - } - /* Exception case: Can't verify */ - snprintf(err_msg, sizeof(err_msg), - "Can not identify!"); - goto err_qsft_detect_transvr_class_1; - -err_qsft_detect_transvr_class_1: - SWPS_INFO("%s: %s\n :%s", __func__, err_msg, self->swp_name); - return TRANSVR_CLASS_ERROR; -} - - -int -_qsfp_set_magnolia_if_type(struct transvr_obj_s* self, - int transvr_cls, - char *result){ - - int lmax = 8; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - - switch (transvr_cls) { - case TRANSVR_CLASS_UNSPECIFIED: - case TRANSVR_CLASS_ERROR: - break; - /* 100G Optical */ - case TRANSVR_CLASS_OPTICAL_100G: - case TRANSVR_CLASS_OPTICAL_100G_AOC: - case TRANSVR_CLASS_OPTICAL_100G_SR4: - case TRANSVR_CLASS_OPTICAL_100G_LR4: - case TRANSVR_CLASS_OPTICAL_100G_ER4: - case TRANSVR_CLASS_OPTICAL_100G_PSM4: - return snprintf(result, lmax, TRANSVR_IF_SR4); - /* 100G Copper */ - case TRANSVR_CLASS_COPPER_L4_100G: - return snprintf(result, lmax, TRANSVR_IF_KR4); - /* 40G Optical */ - case TRANSVR_CLASS_OPTICAL_40G: - case TRANSVR_CLASS_OPTICAL_40G_AOC: - case TRANSVR_CLASS_OPTICAL_40G_SR4: - case TRANSVR_CLASS_OPTICAL_40G_LR4: - case TRANSVR_CLASS_OPTICAL_40G_ER4: - return snprintf(result, lmax, TRANSVR_IF_IF_XGMII); - /* 40G Copper */ - case TRANSVR_CLASS_COPPER_L4_40G: - return snprintf(result, lmax, TRANSVR_IF_IF_XGMII); - /* 10G Optical */ - case TRANSVR_CLASS_OPTICAL_10G: - case TRANSVR_CLASS_OPTICAL_10G_Q_AOC: - case TRANSVR_CLASS_OPTICAL_10G_Q_SR: /* Need Check: SR4 or SR */ - case TRANSVR_CLASS_OPTICAL_10G_Q_LR: /* Need Check: LR4 or LR */ - case TRANSVR_CLASS_OPTICAL_10G_Q_ER: /* Need Check: ER4 or ER */ - return snprintf(result, lmax, TRANSVR_IF_IF_XGMII); - /* Optical */ - case TRANSVR_CLASS_OPTICAL: - return snprintf(result, lmax, TRANSVR_IF_IF_XGMII); - /* Copper */ - case TRANSVR_CLASS_COPPER: - return snprintf(result, lmax, TRANSVR_IF_IF_XGMII); - default: - snprintf(err_msg, sizeof(err_msg), - "Detect undefined value:%d", - transvr_cls); - goto err_qsfp_set_magnolia_if_type_1; - } - /* Exception case: Can't verify */ - snprintf(err_msg, sizeof(err_msg), "Can not identify!"); - goto err_qsfp_set_magnolia_if_type_1; - -err_qsfp_set_magnolia_if_type_1: - snprintf(result, lmax, TRANSVR_UEVENT_UNKNOW); - SWPS_INFO("%s: %s\n :%s", __func__, err_msg, self->swp_name); - return ERR_TRANSVR_ABNORMAL; -} - - -int -_qsfp_set_redwood_if_type(struct transvr_obj_s* self, - int transvr_cls, - char *result){ - - int lmax = 8; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - - switch (transvr_cls) { - case TRANSVR_CLASS_UNSPECIFIED: - case TRANSVR_CLASS_ERROR: - break; - /* 100G Optical */ - case TRANSVR_CLASS_OPTICAL_100G: - case TRANSVR_CLASS_OPTICAL_100G_AOC: - case TRANSVR_CLASS_OPTICAL_100G_SR4: - case TRANSVR_CLASS_OPTICAL_100G_LR4: - case TRANSVR_CLASS_OPTICAL_100G_ER4: - case TRANSVR_CLASS_OPTICAL_100G_PSM4: - return snprintf(result, lmax, TRANSVR_IF_SR4); - /* 100G Copper */ - case TRANSVR_CLASS_COPPER_L4_100G: - return snprintf(result, lmax, TRANSVR_IF_KR4); - /* 40G Optical */ - case TRANSVR_CLASS_OPTICAL_40G: - case TRANSVR_CLASS_OPTICAL_40G_AOC: - case TRANSVR_CLASS_OPTICAL_40G_SR4: - case TRANSVR_CLASS_OPTICAL_40G_LR4: - case TRANSVR_CLASS_OPTICAL_40G_ER4: - return snprintf(result, lmax, TRANSVR_IF_SR4); - /* 40G Copper */ - case TRANSVR_CLASS_COPPER_L4_40G: - return snprintf(result, lmax, TRANSVR_IF_KR4); - /* 10G Optical */ - case TRANSVR_CLASS_OPTICAL_10G: - case TRANSVR_CLASS_OPTICAL_10G_Q_AOC: - case TRANSVR_CLASS_OPTICAL_10G_Q_SR: /* Need Check: SR4 or SR */ - case TRANSVR_CLASS_OPTICAL_10G_Q_LR: /* Need Check: SR4 or SR */ - case TRANSVR_CLASS_OPTICAL_10G_Q_ER: - return snprintf(result, lmax, TRANSVR_IF_SR4); - /* Optical */ - case TRANSVR_CLASS_OPTICAL: - return snprintf(result, lmax, TRANSVR_IF_SR4); - /* Copper */ - case TRANSVR_CLASS_COPPER: - return snprintf(result, lmax, TRANSVR_IF_KR4); - default: - snprintf(err_msg, sizeof(err_msg), - "Detect undefined value:%d", - transvr_cls); - goto err_qsfp_set_magnolia_if_type_1; - } - /* Exception case: Can't verify */ - snprintf(err_msg, sizeof(err_msg), "Can not identify!"); - goto err_qsfp_set_magnolia_if_type_1; - -err_qsfp_set_magnolia_if_type_1: - snprintf(result, lmax, TRANSVR_UEVENT_UNKNOW); - SWPS_INFO("%s: %s\n :%s", __func__, err_msg, self->swp_name); - return ERR_TRANSVR_ABNORMAL; -} - - -int -_qsfp_set_lavender_if_type(struct transvr_obj_s* self, - int transvr_cls, - char *result) { - /* (TBD) - * Due to 'LAV' looks like doesn't have interface type. - * We bypass it currently. - */ - int lmax = 8; - return snprintf(result, lmax, TRANSVR_UEVENT_UNKNOW); -} - - -int -_qsfp_detect_if_type(struct transvr_obj_s* self, - char *result){ - - int lmax = 8; - int detect_cls = DEBUG_TRANSVR_INT_VAL; - - detect_cls = qsft_detect_transvr_class(self); - switch (self->chipset_type) { - case CHIP_TYPE_MAGNOLIA: - return _qsfp_set_magnolia_if_type(self, detect_cls, result); - - case CHIP_TYPE_MAPLE: - case CHIP_TYPE_REDWOOD: - return _qsfp_set_redwood_if_type(self, detect_cls, result); - - case CHIP_TYPE_LAVENDER: - return _qsfp_set_lavender_if_type(self, detect_cls, result); - - default: - SWPS_INFO("%s: non-defined chipset_type:%d :%s\n", - __func__, self->chipset_type, self->swp_name); - break; - } - snprintf(result, lmax, TRANSVR_UEVENT_UNKNOW); - return ERR_TRANSVR_ABNORMAL; -} - - -int -qsfp_get_if_type(struct transvr_obj_s *self, - char *buf_p){ - - int lmax = 8; - char tmp_result[8] = DEBUG_TRANSVR_STR_VAL; - - if (self->state != STATE_TRANSVR_CONNECTED) { - return snprintf(buf_p, lmax, "%d\n", self->state); - } - if (_qsfp_detect_if_type(self, tmp_result) < 0) { - return snprintf(buf_p, lmax, "%d\n", ERR_TRANSVR_ABNORMAL); - } - return snprintf(buf_p, lmax, "%s\n", tmp_result); -} - - -int -_qsfp_detect_if_speed(struct transvr_obj_s* self, - char *result){ - int lmax = 16; - int detect_val = DEBUG_TRANSVR_INT_VAL; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - - detect_val = qsft_detect_transvr_class(self); - switch (detect_val) { - case TRANSVR_CLASS_UNSPECIFIED: - case TRANSVR_CLASS_ERROR: - break; - /* 100G Optical */ - case TRANSVR_CLASS_OPTICAL_100G: - case TRANSVR_CLASS_OPTICAL_100G_AOC: - case TRANSVR_CLASS_OPTICAL_100G_SR4: - case TRANSVR_CLASS_OPTICAL_100G_LR4: - case TRANSVR_CLASS_OPTICAL_100G_ER4: - case TRANSVR_CLASS_OPTICAL_100G_PSM4: - return snprintf(result, lmax, TRANSVR_IF_SP_100G); - /* 100G Copper */ - case TRANSVR_CLASS_COPPER_L4_100G: - return snprintf(result, lmax, TRANSVR_IF_SP_100G); - /* 40G Optical */ - case TRANSVR_CLASS_OPTICAL_40G: - case TRANSVR_CLASS_OPTICAL_40G_AOC: - case TRANSVR_CLASS_OPTICAL_40G_SR4: - case TRANSVR_CLASS_OPTICAL_40G_LR4: - case TRANSVR_CLASS_OPTICAL_40G_ER4: - return snprintf(result, lmax, TRANSVR_IF_SP_40G); - /* 40G Copper */ - case TRANSVR_CLASS_COPPER_L4_40G: - return snprintf(result, lmax, TRANSVR_IF_SP_40G); - /* 10G Optical */ - case TRANSVR_CLASS_OPTICAL_10G: - case TRANSVR_CLASS_OPTICAL_10G_Q_AOC: - case TRANSVR_CLASS_OPTICAL_10G_Q_SR: /* Need Check: SR4 or SR */ - case TRANSVR_CLASS_OPTICAL_10G_Q_LR: /* Need Check: SR4 or SR */ - case TRANSVR_CLASS_OPTICAL_10G_Q_ER: - return snprintf(result, lmax, TRANSVR_IF_SP_10G); - /* 10G Copper */ - case TRANSVR_CLASS_COPPER_L4_10G: - return snprintf(result, lmax, TRANSVR_IF_SP_10G); - /* Optical */ - case TRANSVR_CLASS_OPTICAL: - break; - /* Copper */ - case TRANSVR_CLASS_COPPER: - break; - default: - snprintf(err_msg, sizeof(err_msg), - "Detect undefined class case:%d", - detect_val); - goto err_qsfp_detect_if_speed_1; - } - /* Check br and extbr */ - detect_val = _qsfp_detect_if_sp_by_br(self); - switch(detect_val) { - case TRANSVR_CLASS_UNSPECIFIED: - break; - case TRANSVR_CLASS_10G: - return snprintf(result, lmax, TRANSVR_IF_SP_10G); - case TRANSVR_CLASS_40G: - return snprintf(result, lmax, TRANSVR_IF_SP_40G); - case TRANSVR_CLASS_100G: - return snprintf(result, lmax, TRANSVR_IF_SP_100G); - default: - snprintf(err_msg, sizeof(err_msg), - "Detect undefined BR case:%d", - detect_val); - goto err_qsfp_detect_if_speed_1; - } - /* Exception case: Can't verify */ - snprintf(err_msg, sizeof(err_msg), "Can not identify!"); - goto err_qsfp_detect_if_speed_1; - -err_qsfp_detect_if_speed_1: - snprintf(result, lmax, TRANSVR_UEVENT_UNKNOW); - SWPS_INFO("%s: %s :%s\n", __func__, err_msg, self->swp_name); - return ERR_TRANSVR_ABNORMAL; -} - - -int -qsfp_get_if_speed(struct transvr_obj_s *self, - char *buf_p){ - - int lmax = 16; - char tmp_result[16] = DEBUG_TRANSVR_STR_VAL; - - if (self->state != STATE_TRANSVR_CONNECTED) { - return snprintf(buf_p, lmax, "%d\n", self->state); - } - if (_qsfp_detect_if_speed(self, tmp_result) < 0) { - return snprintf(buf_p, lmax, "%d\n", ERR_TRANSVR_ABNORMAL); - } - return snprintf(buf_p, lmax, "%s\n", tmp_result); -} - - -int -_common_set_lane_map_str(struct transvr_obj_s* self, - char *result) { - int i = 0; - int tmp_val = 0; - char tmp_str[LEN_TRANSVR_L_STR] = DEBUG_TRANSVR_STR_VAL; - char err_msg[LEN_TRANSVR_L_STR] = DEBUG_TRANSVR_STR_VAL; - - memset(result, 0, LEN_TRANSVR_L_STR); - snprintf(result, LEN_TRANSVR_L_STR, "%s=", TRANSVR_UEVENT_KEY_LANE); - - for (i=0; ilane_id); i++) { - tmp_val = self->lane_id[i]; - if (tmp_val < 1) { - break; - } - if (tmp_val > 256) { - snprintf(err_msg, sizeof(err_msg), - "detect abnormal value:%d", tmp_val); - goto err_common_set_lane_map_str_1; - } - memset(tmp_str, 0, sizeof(tmp_str)); - if (i == 0) { - snprintf(tmp_str, LEN_TRANSVR_L_STR, "%d", tmp_val); - } else { - snprintf(tmp_str, LEN_TRANSVR_L_STR, ",%d", tmp_val); - } - strncat(result, tmp_str, LEN_TRANSVR_L_STR); - } - if (i == 0) { - goto err_common_set_lane_map_str_2; - } - return 0; - -err_common_set_lane_map_str_1: - SWPS_INFO("%s: %s", __func__, err_msg); -err_common_set_lane_map_str_2: - snprintf(result, LEN_TRANSVR_L_STR, "%s=%s", TRANSVR_UEVENT_KEY_LANE, TRANSVR_UEVENT_UNKNOW); - return EVENT_TRANSVR_TASK_FAIL; -} - - -int -_common_send_uevent(struct transvr_obj_s* self, - enum kobject_action u_action, - int (*detect_if_type)(struct transvr_obj_s *self, char *result), - int (*detect_if_speed)(struct transvr_obj_s *self, char *result), - int send_anyway) { - - char *uevent_envp[4]; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - char tmp_str[32] = DEBUG_TRANSVR_STR_VAL; - char tmp_str_1[32] = DEBUG_TRANSVR_STR_VAL; - char tmp_str_2[32] = DEBUG_TRANSVR_STR_VAL; - char tmp_str_3[64] = DEBUG_TRANSVR_STR_VAL; - - if (TRANSVR_UEVENT_ENABLE != 1) { - return ERR_TRANSVR_NOTSUPPORT; - } - if (_common_get_if_lane(self, tmp_str) < 0) { - snprintf(tmp_str_3, sizeof(tmp_str_3), - "%s=%s", TRANSVR_UEVENT_KEY_LANE, TRANSVR_UEVENT_UNKNOW); - } else { - snprintf(tmp_str_3, sizeof(tmp_str_3), - "%s=%s", TRANSVR_UEVENT_KEY_LANE, tmp_str); - } - switch (u_action) { - case KOBJ_ADD: - /* Detect type */ - if (detect_if_type(self, tmp_str) < 0) { - snprintf(err_msg, sizeof(err_msg), "%s", "Detect interface type fail!"); - snprintf(tmp_str_1, sizeof(tmp_str_1), "%s=%s", TRANSVR_UEVENT_KEY_IF, TRANSVR_UEVENT_UNKNOW); - snprintf(tmp_str_2, sizeof(tmp_str_2), "%s=%s", TRANSVR_UEVENT_KEY_SP, TRANSVR_UEVENT_UNKNOW); - uevent_envp[0] = tmp_str_1; - uevent_envp[1] = tmp_str_2; - uevent_envp[2] = tmp_str_3; - uevent_envp[3] = NULL; - goto private_common_send_uevent_4_fail; - } - snprintf(tmp_str_1, sizeof(tmp_str_1), "%s=%s", TRANSVR_UEVENT_KEY_IF, tmp_str); - uevent_envp[0] = tmp_str_1; - /* Detect speed */ - if (detect_if_speed(self, tmp_str) < 0) { - snprintf(err_msg, sizeof(err_msg), "%s", "Detect interface speed fail!"); - snprintf(tmp_str_2, sizeof(tmp_str_2), "%s=%s", TRANSVR_UEVENT_KEY_SP, TRANSVR_UEVENT_UNKNOW); - uevent_envp[1] = tmp_str_2; - uevent_envp[2] = tmp_str_3; - uevent_envp[3] = NULL; - goto private_common_send_uevent_4_fail; - } - snprintf(tmp_str_2, sizeof(tmp_str_2), "%s=%s", TRANSVR_UEVENT_KEY_SP, tmp_str); - uevent_envp[1] = tmp_str_2; - uevent_envp[2] = tmp_str_3; - uevent_envp[3] = NULL; - goto private_common_send_uevent_4_send; - - case KOBJ_REMOVE: - snprintf(tmp_str_1, sizeof(tmp_str_1), "%s=%s", TRANSVR_UEVENT_KEY_IF, TRANSVR_UEVENT_UNKNOW); - snprintf(tmp_str_2, sizeof(tmp_str_2), "%s=%s", TRANSVR_UEVENT_KEY_SP, TRANSVR_UEVENT_UNKNOW); - uevent_envp[0] = tmp_str_1; - uevent_envp[1] = tmp_str_2; - uevent_envp[2] = tmp_str_3; - uevent_envp[3] = NULL; - goto private_common_send_uevent_4_send; - - default: - snprintf(err_msg, sizeof(err_msg), "kobject_action:%d not support", u_action); - goto private_common_send_uevent_4_fail; - } - snprintf(err_msg, sizeof(err_msg), "%s", "Exception case"); - goto private_common_send_uevent_4_fail; - -private_common_send_uevent_4_fail: - SWPS_INFO("%s: %s :%s\n", __func__, err_msg, self->swp_name); - if (send_anyway) { - goto private_common_send_uevent_4_send; - } - return ERR_TRANSVR_UEVENT_FAIL; - -private_common_send_uevent_4_send: - return kobject_uevent_env(&(self->transvr_dev_p->kobj), - u_action, - uevent_envp); -} - -int -sfp_send_uevent(struct transvr_obj_s* self, - enum kobject_action u_action) { - int send_anyway = 1; - return _common_send_uevent(self, - u_action, - &_sfp_detect_if_type, - &_sfp_detect_if_speed, - send_anyway); -} - - -int -qsfp_send_uevent(struct transvr_obj_s* self, - enum kobject_action u_action) { - int send_anyway = 1; - return _common_send_uevent(self, - u_action, - &_qsfp_detect_if_type, - &_qsfp_detect_if_speed, - send_anyway); -} - - -int -fake_send_uevent(struct transvr_obj_s* self, - enum kobject_action u_action) { - return EVENT_TRANSVR_TASK_DONE; -} - - -int -common_fsm_4_direct_mode(struct transvr_obj_s* self, - char *caller_name){ - - int err; - int detect_result[2]; - int current_state = STATE_TRANSVR_UNEXCEPTED; - int current_type = TRANSVR_TYPE_ERROR; - - if (self->state == STATE_TRANSVR_NEW) { - if (_transvr_init_handler(self) < 0){ - return ERR_TRANSVR_INIT_FAIL; - } - } - err = detect_transvr_state(self, detect_result); - if (err < 0) { - return err; - } - /* In Direct mode, driver only detect transceiver when user call driver interface - * which on sysfs. So it only need consider the state of Transceiver. - */ - current_state = detect_result[0]; - current_type = detect_result[1]; - - switch (current_state){ - - case STATE_TRANSVR_DISCONNECTED: /* Transceiver is not plugged */ - self->state = current_state; - self->type = current_type; - return ERR_TRANSVR_UNPLUGGED; - - case STATE_TRANSVR_INIT: /* Transceiver is plugged, system not ready */ - return ERR_TRANSVR_UNINIT; - - case STATE_TRANSVR_ISOLATED: /* Transceiver is plugged, but has some issues */ - return ERR_TRNASVR_BE_ISOLATED; - - case STATE_TRANSVR_CONNECTED: /* Transceiver is plugged, system is ready */ - self->state = current_state; - self->type = current_type; - return 0; - - case STATE_TRANSVR_SWAPPED: /* Transceiver is plugged, system detect user changed */ - self->type = current_type; - if (reload_transvr_obj(self, current_type) < 0){ - self->state = STATE_TRANSVR_UNEXCEPTED; - return ERR_TRANSVR_UNEXCPT; - } - self->state = current_state; - return 0; - - case STATE_TRANSVR_UNEXCEPTED: /* Transceiver type or state is unexpected case */ - self->state = STATE_TRANSVR_UNEXCEPTED; - self->type = TRANSVR_TYPE_ERROR; - return ERR_TRANSVR_UNEXCPT; - - default: - SWPS_INFO("%s: state:%d not in define.\n", __func__, current_state); - break; - } - return ERR_TRANSVR_UNEXCPT; -} - - -static int -_is_except_happened_4_pmode(struct transvr_obj_s* self, - int new_state) { - - int event_chk = 0; - - if (self->temp == 0){ - return 0; - } - switch (new_state) { - case STATE_TRANSVR_INIT: - event_chk = EVENT_TRANSVR_EXCEP_INIT; - goto check_event_happened_4_pmode; - - case STATE_TRANSVR_CONNECTED: - event_chk = EVENT_TRANSVR_EXCEP_UP; - goto check_event_happened_4_pmode; - - case STATE_TRANSVR_DISCONNECTED: - event_chk = EVENT_TRANSVR_EXCEP_DOWN; - goto check_event_happened_4_pmode; - - case STATE_TRANSVR_SWAPPED: - event_chk = EVENT_TRANSVR_EXCEP_SWAP; - goto check_event_happened_4_pmode; - - case STATE_TRANSVR_UNEXCEPTED: - event_chk = EVENT_TRANSVR_EXCEP_EXCEP; - goto check_event_happened_4_pmode; - - case STATE_TRANSVR_ISOLATED: - event_chk = EVENT_TRANSVR_EXCEP_ISOLATED; - goto check_event_happened_4_pmode; - - default: - SWPS_INFO("%s: unexcepted case:%d\n", __func__, new_state); - break; - } - return 0; - -check_event_happened_4_pmode: - if (self->temp == event_chk){ - return 1; - } - return 0; -} - - -int -common_fsm_4_polling_mode(struct transvr_obj_s* self, - char *caller_name){ - /* [Return Value]: - * ERR_TRANSVR_UNINIT : (1) Initial not ready - * ERR_TRANSVR_UNPLUGGED : (1) Any -> Down - * ERR_TRANSVR_TASK_BUSY : (1) Wait Initial task - * ERR_TRANSVR_UNEXCPT : (1) Initial fail - * (2) Task fail - * (3) Reload fail - * ERR_TRNASVR_BE_ISOLATED : (1) Already be isolated - * OK Case (return 0) : (1) action_4_connected - * (2) action_4_nothing (initial retry) - */ - int curr_state[2]; - int old_state = self->state; - int old_type = self->type; - int new_state = STATE_TRANSVR_UNEXCEPTED; - int new_type = TRANSVR_TYPE_ERROR; - int return_val = ERR_TRANSVR_UNEXCPT; - - /* Never initial */ - if (self->state == STATE_TRANSVR_NEW) { - goto comfsm_action_4_reinit_obj; - } - /* Detect current state */ - switch (detect_transvr_state(self, curr_state)) { - case 0: - new_state = curr_state[0]; - new_type = curr_state[1]; - break; - - case ERR_TRNASVR_BE_ISOLATED: - new_state = STATE_TRANSVR_ISOLATED; - new_type = old_type; - break; - - case ERR_TRANSVR_I2C_CRASH: - goto comfsm_action_4_report_i2c_crash; - - case ERR_TRANSVR_UNEXCPT: - default: - new_state = STATE_TRANSVR_UNEXCEPTED; - new_type = old_type; - } - /* State handling */ - switch (old_state) { - case STATE_TRANSVR_INIT: /* INIT -> */ - return_val = ERR_TRANSVR_UNINIT; - goto comfsm_action_4_keep_state; - - case STATE_TRANSVR_CONNECTED: - switch (new_state) { - case STATE_TRANSVR_INIT: /* Case 1-1: UP -> INIT */ - SWPS_INFO("Detect %s is present. :1-1\n",self->swp_name); - return_val = ERR_TRANSVR_UNINIT; - goto comfsm_action_4_keep_state; - - case STATE_TRANSVR_CONNECTED: /* Case 1-2: UP -> UP */ - return_val = 0; - goto comfsm_action_4_keep_state; - - case STATE_TRANSVR_DISCONNECTED: /* Case 1-3: UP -> DOWN */ - SWPS_INFO("Detect %s is removed. :1-3\n",self->swp_name); - goto comfsm_action_4_disconnected; - - case STATE_TRANSVR_SWAPPED: /* Case 1-4: UP -> SWAP */ - SWPS_INFO("Detect %s is swapped. :1-4\n",self->swp_name); - goto comfsm_action_4_reload_obj; - - case STATE_TRANSVR_UNEXCEPTED: /* Case 1-5: UP -> UNEXPET */ - SWPS_INFO("Detect %s has error. :1-5\n",self->swp_name); - goto comfsm_action_4_unexpected; - - case STATE_TRANSVR_ISOLATED: /* Case 1-6: UP -> ISOLATE */ - SWPS_INFO("Detect %s be isolated. :1-6\n",self->swp_name); - goto comfsm_action_4_isolate_obj; - - default: - break; - } - goto comfsm_action_4_unexpected; - - case STATE_TRANSVR_DISCONNECTED: - switch (new_state) { - case STATE_TRANSVR_INIT: /* Case 2-1: DOWN -> INIT */ - SWPS_INFO("Detect %s is present. :2-1\n",self->swp_name); - return_val = ERR_TRANSVR_UNINIT; - goto comfsm_action_4_keep_state; - - case STATE_TRANSVR_CONNECTED: /* Case 2-2: DOWN -> UP */ - SWPS_INFO("Detect %s is present. :2-2\n",self->swp_name); - goto comfsm_action_4_reinit_obj; - - case STATE_TRANSVR_DISCONNECTED: /* Case 2-3: DOWN -> DOWN */ - return_val = ERR_TRANSVR_UNPLUGGED; - goto comfsm_action_4_keep_state; - - case STATE_TRANSVR_SWAPPED: /* Case 2-4: DOWN -> SWAP */ - SWPS_INFO("Detect %s is swapped. :2-4\n",self->swp_name); - goto comfsm_action_4_reload_obj; - - case STATE_TRANSVR_UNEXCEPTED: /* Case 2-5: DOWN -> UNEXPET */ - SWPS_INFO("Detect %s has error. :2-5\n",self->swp_name); - goto comfsm_action_4_unexpected; - - case STATE_TRANSVR_ISOLATED: /* Case 2-6: DOWN -> ISOLATE */ - SWPS_INFO("Detect %s be isolated. :2-6\n",self->swp_name); - goto comfsm_action_4_isolate_obj; - - default: - break; - } - goto comfsm_action_4_unexpected; - - case STATE_TRANSVR_UNEXCEPTED: - /* Filter out re-action */ - if (_is_except_happened_4_pmode(self, new_state)) { - goto comfsm_action_4_keep_state; - } - /* First action */ - switch (new_state) { - case STATE_TRANSVR_INIT: /* Case 3-1: UNEXPET -> INIT */ - SWPS_INFO("Detect %s is present. :3-1\n",self->swp_name); - self->temp = EVENT_TRANSVR_EXCEP_INIT; - return_val = ERR_TRANSVR_UNINIT; - goto comfsm_action_4_keep_state; - - case STATE_TRANSVR_CONNECTED: /* Case 3-2: UNEXPET -> UP */ - SWPS_INFO("Detect %s is present. :3-2\n",self->swp_name); - self->temp = EVENT_TRANSVR_EXCEP_UP; - goto comfsm_action_4_reload_obj; - - case STATE_TRANSVR_DISCONNECTED: /* Case 3-3: UNEXPET -> DOWN */ - SWPS_INFO("Detect %s is removed. :3-3\n",self->swp_name); - goto comfsm_action_4_disconnected; - - case STATE_TRANSVR_SWAPPED: /* Case 3-4: UNEXPET -> SWAP */ - SWPS_INFO("Detect %s is swapped. :3-4\n",self->swp_name); - self->temp = EVENT_TRANSVR_EXCEP_SWAP; - goto comfsm_action_4_reload_obj; - - case STATE_TRANSVR_UNEXCEPTED: /* Case 3-5: UNEXPET -> UNEXPET */ - self->temp = EVENT_TRANSVR_EXCEP_EXCEP; - return_val = ERR_TRANSVR_UNEXCPT; - goto comfsm_action_4_keep_state; - - case STATE_TRANSVR_ISOLATED: /* Case 3-6: UNEXPET -> ISOLATE */ - SWPS_INFO("Detect %s be isolated. :3-6\n",self->swp_name); - goto comfsm_action_4_isolate_obj; - - default: - break; - } - goto comfsm_action_4_unexpected; - - case STATE_TRANSVR_ISOLATED: - /* Filter out re-action */ - if (_is_except_happened_4_pmode(self, new_state)) { - goto comfsm_action_4_keep_state; - } - /* First action */ - switch (new_state) { - case STATE_TRANSVR_INIT: /* Case 4-1: ISOLATE -> INIT */ - SWPS_INFO("Detect %s internal error. :4-1\n",self->swp_name); - self->temp = EVENT_TRANSVR_EXCEP_INIT; - return_val = ERR_TRNASVR_BE_ISOLATED; - goto comfsm_action_4_keep_state; - - case STATE_TRANSVR_CONNECTED: /* Case 4-2: ISOLATE -> UP */ - SWPS_INFO("Detect %s internal error. :4-2\n",self->swp_name); - self->temp = EVENT_TRANSVR_EXCEP_UP; - return_val = ERR_TRNASVR_BE_ISOLATED; - goto comfsm_action_4_keep_state; - - case STATE_TRANSVR_DISCONNECTED: /* Case 4-3: ISOLATE -> DOWN */ - SWPS_INFO("Detect %s is removed. :4-3\n",self->swp_name); - goto comfsm_action_4_disconnected; - - case STATE_TRANSVR_SWAPPED: /* Case 4-4: ISOLATE -> SWAP */ - SWPS_INFO("Detect %s internal error. :4-4\n",self->swp_name); - self->temp = EVENT_TRANSVR_EXCEP_SWAP; - return_val = ERR_TRNASVR_BE_ISOLATED; - goto comfsm_action_4_keep_state; - - case STATE_TRANSVR_UNEXCEPTED: /* Case 4-5: ISOLATE -> UNEXPET */ - SWPS_INFO("Detect %s internal error. :4-5\n",self->swp_name); - self->temp = EVENT_TRANSVR_EXCEP_EXCEP; - return_val = ERR_TRNASVR_BE_ISOLATED; - goto comfsm_action_4_keep_state; - - case STATE_TRANSVR_ISOLATED: /* Case 4-6: ISOLATE -> ISOLATE */ - return_val = ERR_TRNASVR_BE_ISOLATED; - goto comfsm_action_4_keep_state; - - default: - break; - } - goto comfsm_action_4_unexpected; - - default: - break; - } - goto comfsm_action_4_unexpected; - - -comfsm_action_4_keep_state: - return return_val; - -comfsm_action_4_reinit_obj: - SWPS_DEBUG("FSM action: %s re-initial.\n", self->swp_name); - return_val = _transvr_init_handler(self); - goto comfsm_action_4_identify_event; - -comfsm_action_4_reload_obj: - SWPS_DEBUG("FSM action: %s reload.\n", self->swp_name); - self->type = new_type; - return_val = reload_transvr_obj(self, new_type); - goto comfsm_action_4_identify_event; - -comfsm_action_4_identify_event: - switch (return_val) { - case EVENT_TRANSVR_INIT_UP: - case EVENT_TRANSVR_TASK_DONE: - goto comfsm_action_4_connected; - - case EVENT_TRANSVR_INIT_DOWN: - goto comfsm_action_4_disconnected; - - case EVENT_TRANSVR_INIT_REINIT: - goto comfsm_action_4_nothing; - - case EVENT_TRANSVR_TASK_WAIT: - self->state = STATE_TRANSVR_INIT; - return ERR_TRANSVR_TASK_BUSY; - - case EVENT_TRANSVR_TASK_FAIL: - SWPS_INFO("%s detect EVENT_TRANSVR_TASK_FAIL.\n", self->swp_name); - goto comfsm_action_4_unexpected; - - case EVENT_TRANSVR_INIT_FAIL: - SWPS_INFO("%s detect EVENT_TRANSVR_INIT_FAIL.\n", self->swp_name); - goto comfsm_action_4_unexpected; - - case EVENT_TRANSVR_RELOAD_FAIL: - SWPS_INFO("%s detect EVENT_TRANSVR_RELOAD_FAIL.\n", self->swp_name); - goto comfsm_action_4_unexpected; - - case EVENT_TRANSVR_I2C_CRASH: - goto comfsm_action_4_report_i2c_crash; - - case EVENT_TRANSVR_EXCEP_ISOLATED: - goto comfsm_action_4_isolate_obj; - - default: - SWPS_INFO("%s detect undefined event:%d.\n", self->swp_name, return_val); - goto comfsm_action_4_unexpected; - } - -comfsm_action_4_nothing: - SWPS_DEBUG("FSM action: %s do nothing.\n", self->swp_name); - return 0; - -comfsm_action_4_connected: - SWPS_DEBUG("FSM action: %s Connected.\n", self->swp_name); - self->state = STATE_TRANSVR_CONNECTED; - self->type = new_type; - self->send_uevent(self, KOBJ_ADD); - _transvr_clean_retry(self); - return 0; - -comfsm_action_4_disconnected: - SWPS_DEBUG("FSM action: %s Disconnected. \n", self->swp_name); - self->state = STATE_TRANSVR_DISCONNECTED; - self->temp = EVENT_TRANSVR_TASK_DONE; - self->send_uevent(self, KOBJ_REMOVE); - _transvr_clean_retry(self); - _transvr_clean_handler(self); - return ERR_TRANSVR_UNPLUGGED; - -comfsm_action_4_report_i2c_crash: - SWPS_DEBUG("FSM action: %s report I2C crash.\n", self->swp_name); - self->state = STATE_TRANSVR_UNEXCEPTED; - return ERR_TRANSVR_I2C_CRASH; - -comfsm_action_4_isolate_obj: - SWPS_DEBUG("FSM action: %s isolate.\n", self->swp_name); - self->state = STATE_TRANSVR_ISOLATED; - return ERR_TRNASVR_BE_ISOLATED; - -comfsm_action_4_unexpected: - SWPS_INFO("FSM action: %s unexpected.\n", self->swp_name); - SWPS_INFO("Dump: :%d :0x%02x :%d :0x%02x\n", - old_state, old_type, new_state, new_type); - self->state = STATE_TRANSVR_UNEXCEPTED; - self->send_uevent(self, KOBJ_REMOVE); - _transvr_clean_handler(self); - return ERR_TRANSVR_UNEXCPT; -} - - -int -fake_fsm_4_direct_mode(struct transvr_obj_s* self, - char *caller_name){ - self->state = STATE_TRANSVR_CONNECTED; - self->type = TRANSVR_TYPE_FAKE; - return 0; -} - - -int -fake_fsm_4_polling_mode(struct transvr_obj_s* self, - char *caller_name){ - self->state = STATE_TRANSVR_CONNECTED; - self->type = TRANSVR_TYPE_FAKE; - return 0; -} - - -/* ========== Object functions for Initial procedure ========== - */ -int -transvr_init_common(struct transvr_obj_s *self){ - /* Nothing to update */ - return EVENT_TRANSVR_TASK_DONE; -} - - -int -transvr_init_fake(struct transvr_obj_s *self){ - return EVENT_TRANSVR_TASK_DONE; -} - - -int -transvr_init_sfp(struct transvr_obj_s *self){ - - int tmp_val = DEBUG_TRANSVR_INT_VAL; - int err_code = DEBUG_TRANSVR_INT_VAL; - char *err_msg = "ERR"; - - self->info = sft_detect_transvr_class(self); - /* Disable auto_config */ - if (!self->auto_config) { - return EVENT_TRANSVR_TASK_DONE; - } - /* Handle multi-rate */ - err_code = initfunc_sfp_handle_multi_rate_mode(self); - if (err_code < 0) { - err_msg = "initfunc_sfp_handle_multi_rate_mode fail!"; - goto err_transvr_init_sfp_1; - } - /* Handle 1G- RJ45 */ - tmp_val = err_code; - err_code = initfunc_sfp_handle_1g_rj45(self); - if (err_code < 0) { - err_msg = "initfunc_sfp_handle_1g_rj45 fail!"; - goto err_transvr_init_sfp_1; - } - tmp_val = (tmp_val > err_code ? tmp_val : err_code); - if (tmp_val > EVENT_TRANSVR_TASK_DONE) { - return tmp_val; - } - return EVENT_TRANSVR_TASK_DONE; - -err_transvr_init_sfp_1: - SWPS_INFO("%s: %s :%d :%s\n", - __func__, err_msg, err_code, self->swp_name); - return EVENT_TRANSVR_INIT_FAIL; -} - - -int -transvr_init_qsfp(struct transvr_obj_s *self){ - - int err = EVENT_TRANSVR_EXCEP_EXCEP; - char *emsg = "ERR"; - - self->info = qsft_detect_transvr_class(self); - if (!self->auto_config) { - return EVENT_TRANSVR_TASK_DONE; - } - err = initfunc_qsfp_handle_power_mode(self); - if (err < 0){ - emsg = "initfunc_qsfp_handle_tx_disable fail!"; - goto err_transvr_init_qsfp; - } - return EVENT_TRANSVR_TASK_DONE; - -err_transvr_init_qsfp: - SWPS_INFO("%s: %s :%d :%s\n", - __func__, emsg, err, self->swp_name); - return EVENT_TRANSVR_INIT_FAIL; -} - - -int -transvr_init_qsfp28(struct transvr_obj_s *self){ - - int tmp_val = EVENT_TRANSVR_EXCEP_EXCEP; - int err_val = EVENT_TRANSVR_EXCEP_EXCEP; - char *err_msg = "ERR"; - - /* Handle QSFP common */ - err_val = transvr_init_qsfp(self); - if (err_val < 0){ - err_msg = "transvr_init_qsfp fail!"; - goto err_transvr_init_qsfp28_1; - } - /* Disable auto_config */ - if (!self->auto_config) { - return err_val; - } - /* Handle CDR */ - tmp_val = err_val; - err_val = initfunc_qsfp28_handle_cdr(self); - if (err_val < 0){ - err_msg = "Handle CDR fail!"; - goto err_transvr_init_qsfp28_1; - } - tmp_val = (tmp_val > err_val ? tmp_val : err_val); - if (tmp_val > EVENT_TRANSVR_TASK_DONE) { - return tmp_val; - } - return EVENT_TRANSVR_TASK_DONE; - -err_transvr_init_qsfp28_1: - SWPS_INFO("%s: %s :%d :%s\n", - __func__, err_msg, err_val, self->swp_name); - return EVENT_TRANSVR_INIT_FAIL; -} - - -/* ========== Object Initial handler ========== - */ -static int -_is_transvr_valid(struct transvr_obj_s *self, - int type, - int state) { - /* [Return] - * 0 : OK, inserted - * EVENT_TRANSVR_INIT_DOWN : OK, removed - * EVENT_TRANSVR_INIT_FAIL : Outside error, type doesn't supported - * EVENT_TRANSVR_EXCEP_INIT : Internal error, state undefined - */ - switch (type) { - case TRANSVR_TYPE_SFP: - case TRANSVR_TYPE_QSFP: - case TRANSVR_TYPE_QSFP_PLUS: - case TRANSVR_TYPE_QSFP_28: - case TRANSVR_TYPE_UNPLUGGED: - case TRANSVR_TYPE_FAKE: - break; - default: - SWPS_INFO("detect undefined type:0x%02x on %s\n", - type, self->swp_name); - return EVENT_TRANSVR_INIT_FAIL; - } - switch (state) { - case STATE_TRANSVR_DISCONNECTED: - return EVENT_TRANSVR_INIT_DOWN; - case STATE_TRANSVR_INIT: - case STATE_TRANSVR_CONNECTED: - case STATE_TRANSVR_SWAPPED: - break; - default: - SWPS_INFO("detect undefined state:%d on %s\n", - state, self->swp_name); - return EVENT_TRANSVR_EXCEP_INIT; - } - return 0; -} - - -static int -_is_transvr_hw_ready(struct transvr_obj_s *self, - int type){ - /* [Return] - * EVENT_TRANSVR_TASK_DONE : Ready - * EVENT_TRANSVR_TASK_WAIT : Not ready - * EVENT_TRANSVR_INIT_FAIL : Error - */ - int addr = DEBUG_TRANSVR_INT_VAL; - int page = DEBUG_TRANSVR_INT_VAL; - int offs = DEBUG_TRANSVR_INT_VAL; - int bit = DEBUG_TRANSVR_INT_VAL; - int ready = DEBUG_TRANSVR_INT_VAL; - int err = DEBUG_TRANSVR_INT_VAL; - char *emsg = DEBUG_TRANSVR_STR_VAL; - uint8_t ab_val = DEBUG_TRANSVR_HEX_VAL; - - switch (type) { - case TRANSVR_TYPE_SFP: - addr = VAL_TRANSVR_8472_READY_ADDR; - page = VAL_TRANSVR_8472_READY_PAGE; - offs = VAL_TRANSVR_8472_READY_OFFSET; - bit = VAL_TRANSVR_8472_READY_BIT; - ready = VAL_TRANSVR_8472_READY_VALUE; - ab_val = VAL_TRANSVR_8472_READY_ABNORMAL; - break; - - case TRANSVR_TYPE_QSFP: - case TRANSVR_TYPE_QSFP_PLUS: - case TRANSVR_TYPE_QSFP_28: - addr = VAL_TRANSVR_8436_READY_ADDR; - page = VAL_TRANSVR_8436_READY_PAGE; - offs = VAL_TRANSVR_8436_READY_OFFSET; - bit = VAL_TRANSVR_8436_READY_BIT; - ready = VAL_TRANSVR_8436_READY_VALUE; - ab_val = VAL_TRANSVR_8436_READY_ABNORMAL; - break; - - case TRANSVR_TYPE_UNPLUGGED: - case TRANSVR_TYPE_FAKE: - return EVENT_TRANSVR_TASK_DONE; - - default: - emsg = "unexpected case"; - goto err_is_transvr_hw_ready; - } - /* Select target page */ - err = _common_setup_page(self, addr, page, offs, 1, 0); - if (err < 0) { - emsg = "setup page fail"; - goto err_is_transvr_hw_ready; - } - /* Check feature supported - * [Note] - * Some of transceiver/cables doesn't support "Status Indicators" - * (ex:DAC, RJ45 copper SFP ...etc). In these case, we bypass the - * step of checking Status Indicators, then state machine will take - * the following handle procedure. - */ - err = i2c_smbus_read_byte_data(self->i2c_client_p, - VAL_TRANSVR_COMID_OFFSET); - if (err < 0) { - emsg = "doesn't support Status Indicators"; - goto bypass_is_transvr_hw_ready; - } - /* Filter abnormal case */ - if (err == ab_val) { - emsg = "detect using unusual definition."; - goto bypass_is_transvr_hw_ready; - } - /* Get Status Indicators */ - err = i2c_smbus_read_byte_data(self->i2c_client_p, offs); - if (err < 0) { - emsg = "detect current value fail"; - goto err_is_transvr_hw_ready; - } - - if ((err & (1<:%d\n", __func__, emsg, type); - return EVENT_TRANSVR_TASK_DONE; - -err_is_transvr_hw_ready: - SWPS_DEBUG("%s: %s :%d\n", __func__, emsg, type); - return EVENT_TRANSVR_INIT_FAIL; -} - - -static int -_is_transvr_support_ctle(struct transvr_obj_s *self) { - - switch (self->info) { - case TRANSVR_CLASS_OPTICAL_25G: - case TRANSVR_CLASS_OPTICAL_25G_AOC: - case TRANSVR_CLASS_OPTICAL_25G_SR: - case TRANSVR_CLASS_OPTICAL_25G_LR: - case TRANSVR_CLASS_OPTICAL_25G_ER: - case TRANSVR_CLASS_OPTICAL_100G: - case TRANSVR_CLASS_OPTICAL_100G_AOC: - case TRANSVR_CLASS_OPTICAL_100G_SR4: - case TRANSVR_CLASS_OPTICAL_100G_LR4: - case TRANSVR_CLASS_OPTICAL_100G_ER4: - case TRANSVR_CLASS_OPTICAL_100G_PSM4: - return 1; - default: - break; - } - return 0; -} - - -static int -_transvr_init_handler(struct transvr_obj_s *self){ - - int detect[2]; - int d_state = STATE_TRANSVR_UNEXCEPTED; - int d_type = TRANSVR_TYPE_ERROR; - int result = ERR_TRANSVR_UNINIT; - int retry = 6; /* (6+1) x 0.3 = 2.1s > spec:2.0s */ - int elimit = 63; - char emsg[64] = DEBUG_TRANSVR_STR_VAL; - - /* Clean and check callback */ - self->state = STATE_TRANSVR_INIT; - if (self->init == NULL) { - snprintf(emsg, elimit, "init() is null"); - goto initer_err_case_unexcept_0; - } - if (self->clean == NULL) { - snprintf(emsg, elimit, "clean() is null"); - goto initer_err_case_unexcept_0; - } - self->clean(self); - - /* Detect transceiver information */ - result = detect_transvr_state(self, detect); - if (result < 0) { - snprintf(emsg, elimit, "detect_transvr_state() fail"); - switch (result) { - case ERR_TRANSVR_I2C_CRASH: - goto initer_err_case_i2c_ceash; - case ERR_TRNASVR_BE_ISOLATED: - goto initer_err_case_be_isolated; - - case ERR_TRANSVR_UNEXCPT: - default: - break; - } - goto initer_err_case_retry_1; - } - d_state = detect[0]; - d_type = detect[1]; - - /* Verify transceiver type and state */ - switch (_is_transvr_valid(self, d_type, d_state)) { - case 0: - break; - case EVENT_TRANSVR_INIT_DOWN: - goto initer_ok_case_down;; - case EVENT_TRANSVR_INIT_FAIL: - snprintf(emsg, elimit, "transceiver type doesn't support"); - goto initer_err_case_alarm_to_user; - case EVENT_TRANSVR_EXCEP_INIT: - default: - goto initer_err_case_unexcept_1; - } - - /* Handle reload case */ - if (self->type != d_type){ - /* This is the protect mechanism. Normally, This case will not happen. - * When State machine detect swap event during initial, It will trigger - * reload function to ensure type correct. */ - if (_reload_transvr_obj(self, d_type) < 0){ - snprintf(emsg, elimit, "reload object fail"); - goto initer_err_case_unexcept_1; - } - } - - /* Check transceiver HW initial ready */ - switch (_is_transvr_hw_ready(self, d_type)) { - case EVENT_TRANSVR_TASK_DONE: - break; - case EVENT_TRANSVR_TASK_WAIT: - goto initer_err_case_retry_1; - case EVENT_TRANSVR_INIT_FAIL: - default: - goto initer_err_case_unexcept_1; - } - - /* Try to update all and check */ - if (self->update_all(self, 1) < 0){ - /* For some transceiver, EEPROME has lag issues during initial stage. - * In this case, we set status back to STATE_TRANSVR_NEW, than it will - * be checked in next polling cycle. */ - goto initer_err_case_retry_1; - } - - /* Execute init() call back */ - result = self->init(self); - switch (result) { - case EVENT_TRANSVR_TASK_DONE: - break; - case EVENT_TRANSVR_TASK_WAIT: - goto initer_ok_case_wait; - - default: - snprintf(emsg, elimit, "undefined init() return:%d\n", result); - goto initer_err_case_unexcept_1; - } - goto initer_ok_case_up; - - -initer_ok_case_wait: - self->dump_all(self); - return EVENT_TRANSVR_TASK_WAIT; - -initer_ok_case_up: - self->state = STATE_TRANSVR_CONNECTED; - self->temp = 0; - self->dump_all(self); - return EVENT_TRANSVR_INIT_UP; - -initer_ok_case_down: - self->temp = 0; - self->state = STATE_TRANSVR_DISCONNECTED; - return EVENT_TRANSVR_INIT_DOWN; - -initer_err_case_i2c_ceash: - SWPS_DEBUG("%s: %s :%s :I2C crash\n", - __func__, emsg, self->swp_name); - self->state = STATE_TRANSVR_UNEXCEPTED; - return EVENT_TRANSVR_I2C_CRASH; - -initer_err_case_be_isolated: - SWPS_DEBUG("%s: %s :%s :isolated\n", - __func__, emsg, self->swp_name); - self->state = STATE_TRANSVR_ISOLATED; - return EVENT_TRANSVR_EXCEP_ISOLATED; - -initer_err_case_retry_1: - SWPS_DEBUG("%s: %s :%s :retry\n", - __func__, emsg, self->swp_name); - if (_transvr_handle_retry(self, retry) == 0) { - self->state = STATE_TRANSVR_NEW; - return EVENT_TRANSVR_INIT_REINIT; - } - goto initer_err_case_alarm_to_user; - -initer_err_case_unexcept_1: - self->clean(self); -initer_err_case_unexcept_0: - self->state = STATE_TRANSVR_UNEXCEPTED; - if (_is_except_happened_4_pmode(self, d_state) && - (self->mode == TRANSVR_MODE_POLLING) ){ - SWPS_INFO("%s: %s :%s\n", __func__, emsg, self->swp_name); - SWPS_INFO("Dump: :%d :%d :%d :%d\n", - self->state, self->type, d_state, d_type); - } - return EVENT_TRANSVR_INIT_FAIL; - -initer_err_case_alarm_to_user: - SWPS_DEBUG("%s: %s :%s :alarm_to_user\n", - __func__, emsg, self->swp_name); - self->state = STATE_TRANSVR_UNEXCEPTED; - alarm_msg_2_user(self, "detected transceiver/cables not meet SFF standard"); - return EVENT_TRANSVR_INIT_FAIL; -} - - -/* ========== Object functions for Clean procedure ========== - */ -int -_transvr_clean_handler(struct transvr_obj_s *self){ - - int retval = DEBUG_TRANSVR_INT_VAL; - - if (!self->clean) { - SWPS_ERR("%s: %s clean() is NULL.\n", - __func__, self->swp_name); - return EVENT_TRANSVR_TASK_FAIL; - } - retval = self->clean(self); - if (retval != EVENT_TRANSVR_TASK_DONE){ - SWPS_ERR("%s: %s clean() fail. [ERR]:%d\n", - __func__, self->swp_name, retval); - return retval; - } - return EVENT_TRANSVR_TASK_DONE; -} - - -int -common_transvr_clean(struct transvr_obj_s *self){ - - transvr_task_free_all(self); - transvr_cache_free_all(self); - return EVENT_TRANSVR_TASK_DONE; -} - - -int -qsfp_transvr_clean(struct transvr_obj_s *self){ - - int retval; - int lpower_config = 1; - - retval = _taskfunc_qsfp_setup_power_mod(self, lpower_config); - if (retval < 0){ - SWPS_ERR("%s: Set lpmod fail! :%d\n", - __func__, retval); - return retval; - } - retval = common_transvr_clean(self); - if (retval < 0){ - SWPS_ERR("%s: common_transvr_clean fail! :%d\n", - __func__, retval); - return retval; - } - return EVENT_TRANSVR_TASK_DONE; -} - - -int -fake_transvr_clean(struct transvr_obj_s *self){ - - return EVENT_TRANSVR_TASK_DONE; -} - - -/* ========== Object functions for check and update ========== - */ -int -common_transvr_check(struct transvr_obj_s *self){ - - char fun_str[32] = "common_transvr_check"; - - if (self->mode != TRANSVR_MODE_POLLING) { - SWPS_ERR("%s: mode:%d is not TRANSVR_MODE_POLLING\n", - fun_str, self->mode); - return ERR_TRANSVR_UNEXCPT; - } - /* Trigger delay task */ - transvr_task_run_all(self); - /* Trigger state machine to check and update */ - return self->fsm_4_polling(self, fun_str); -} - - -int -fake_transvr_check(struct transvr_obj_s *self){ - return 0; -} - - -/* ========== Functions for Factory pattern ========== - */ -static int -setup_transvr_public_cb(struct transvr_obj_s *self, - int transvr_type){ - switch (transvr_type){ - case TRANSVR_TYPE_SFP: - self->get_id = common_get_id; - self->get_ext_id = common_get_ext_id; - self->get_connector = common_get_connector; - self->get_vendor_name = common_get_vendor_name; - self->get_vendor_pn = common_get_vendor_pn; - self->get_vendor_rev = common_get_vendor_rev; - self->get_vendor_sn = common_get_vendor_sn; - self->get_power_cls = unsupported_get_func; - self->get_br = common_get_br; - self->get_len_sm = sfp_get_len_sm; - self->get_len_smf = common_get_len_smf; - self->get_len_om1 = common_get_len_om1; - self->get_len_om2 = common_get_len_om2; - self->get_len_om3 = common_get_len_om3; - self->get_len_om4 = common_get_len_om4; - self->get_comp_rev = common_get_comp_rev; - self->get_comp_eth_1 = sfp_get_comp_eth_1; - self->get_comp_eth_10 = sfp_get_comp_eth_10; - self->get_comp_eth_10_40 = unsupported_get_func; - self->get_comp_extend = common_get_comp_extended; - self->get_cdr = unsupported_get_func; - self->get_rate_id = sfp_get_rate_id; - self->get_soft_rs0 = sfp_get_soft_rs0; - self->get_soft_rs1 = sfp_get_soft_rs1; - self->get_info = common_get_info; - self->get_if_type = sfp_get_if_type; - self->get_if_speed = sfp_get_if_speed; - self->get_if_lane = common_get_if_lane; - self->get_curr_temp = sfp_get_transvr_temp; - self->get_curr_vol = sfp_get_transvr_voltage; - self->get_soft_rx_los = unsupported_get_func2; - self->get_soft_tx_disable = unsupported_get_func2; - self->get_soft_tx_fault = unsupported_get_func2; - self->get_auto_tx_disable = unsupported_get_func2; - self->get_tx_bias = sfp_get_transvr_tx_bias; - self->get_tx_power = sfp_get_transvr_tx_power; - self->get_rx_power = sfp_get_transvr_rx_power; - self->get_tx_eq = sfp_get_transvr_tx_eq; - self->get_rx_am = unsupported_get_func2; - self->get_rx_em = sfp_get_transvr_rx_em; - self->get_wavelength = sfp_get_wavelength; - self->get_extphy_offset = sfp_get_1g_rj45_extphy_offset; - self->get_extphy_reg = sfp_get_1g_rj45_extphy_reg; - self->set_cdr = unsupported_set_func; - self->set_soft_rs0 = sfp_set_soft_rs0; - self->set_soft_rs1 = sfp_set_soft_rs1; - self->set_soft_tx_disable = unsupported_set_func; - self->set_auto_tx_disable = unsupported_set_func; - self->set_tx_eq = sfp_set_tx_eq; - self->set_rx_am = unsupported_set_func; - self->set_rx_em = sfp_set_rx_em; - self->set_extphy_offset = sfp_set_1g_rj45_extphy_offset; - self->set_extphy_reg = sfp_set_1g_rj45_extphy_reg; - return 0; - - case TRANSVR_TYPE_QSFP: - case TRANSVR_TYPE_QSFP_PLUS: - self->get_id = common_get_id; - self->get_ext_id = common_get_ext_id; - self->get_connector = common_get_connector; - self->get_vendor_name = common_get_vendor_name; - self->get_vendor_pn = common_get_vendor_pn; - self->get_vendor_rev = common_get_vendor_rev; - self->get_vendor_sn = common_get_vendor_sn; - self->get_power_cls = qsfp_get_power_cls; - self->get_br = common_get_br; - self->get_len_sm = unsupported_get_func; - self->get_len_smf = common_get_len_smf; - self->get_len_om1 = common_get_len_om1; - self->get_len_om2 = common_get_len_om2; - self->get_len_om3 = common_get_len_om3; - self->get_len_om4 = common_get_len_om4; - self->get_comp_rev = common_get_comp_rev; - self->get_comp_eth_1 = qsfp_get_comp_eth; - self->get_comp_eth_10 = unsupported_get_func; - self->get_comp_eth_10_40 = qsfp_get_comp_10_40; - self->get_comp_extend = common_get_comp_extended; - self->get_cdr = unsupported_get_func; - self->get_rate_id = unsupported_get_func; - self->get_soft_rs0 = unsupported_get_func; /* TBD */ - self->get_soft_rs1 = unsupported_get_func; /* TBD */ - self->get_info = common_get_info; - self->get_if_type = qsfp_get_if_type; - self->get_if_speed = qsfp_get_if_speed; - self->get_if_lane = common_get_if_lane; - self->get_curr_temp = qsfp_get_transvr_temp; - self->get_curr_vol = qsfp_get_transvr_voltage; - self->get_soft_rx_los = qsfp_get_soft_rx_los; - self->get_soft_tx_disable = qsfp_get_soft_tx_disable; - self->get_soft_tx_fault = qsfp_get_soft_tx_fault; - self->get_auto_tx_disable = qsfp_get_auto_tx_disable; - self->get_tx_bias = qsfp_get_transvr_tx_bias; - self->get_tx_power = qsfp_get_transvr_tx_power; - self->get_rx_power = qsfp_get_transvr_rx_power; - self->get_tx_eq = unsupported_get_func2; - self->get_rx_am = unsupported_get_func2; - self->get_rx_em = unsupported_get_func2; - self->get_wavelength = qsfp_get_wavelength; - self->get_extphy_offset = unsupported_get_func2; - self->get_extphy_reg = unsupported_get_func2; - self->set_cdr = unsupported_set_func; - self->set_soft_rs0 = unsupported_set_func; /* TBD */ - self->set_soft_rs1 = unsupported_set_func; /* TBD */ - self->set_soft_tx_disable = qsfp_set_soft_tx_disable; - self->set_auto_tx_disable = qsfp_set_auto_tx_disable; - self->set_tx_eq = unsupported_set_func; - self->set_rx_am = unsupported_set_func; - self->set_rx_em = unsupported_set_func; - self->set_extphy_offset = unsupported_set_func; - self->set_extphy_reg = unsupported_set_func; - return 0; - - case TRANSVR_TYPE_QSFP_28: - self->get_id = common_get_id; - self->get_ext_id = common_get_ext_id; - self->get_connector = common_get_connector; - self->get_vendor_name = common_get_vendor_name; - self->get_vendor_pn = common_get_vendor_pn; - self->get_vendor_rev = common_get_vendor_rev; - self->get_vendor_sn = common_get_vendor_sn; - self->get_power_cls = qsfp_get_power_cls; - self->get_br = common_get_br; - self->get_len_sm = unsupported_get_func; - self->get_len_smf = common_get_len_smf; - self->get_len_om1 = common_get_len_om1; - self->get_len_om2 = common_get_len_om2; - self->get_len_om3 = common_get_len_om3; - self->get_len_om4 = common_get_len_om4; - self->get_comp_rev = common_get_comp_rev; - self->get_comp_eth_1 = qsfp_get_comp_eth; - self->get_comp_eth_10 = unsupported_get_func; - self->get_comp_eth_10_40 = qsfp_get_comp_10_40; - self->get_comp_extend = common_get_comp_extended; - self->get_cdr = qsfp_get_cdr; - self->get_rate_id = unsupported_get_func; - self->get_soft_rs0 = unsupported_get_func; /* TBD */ - self->get_soft_rs1 = unsupported_get_func; /* TBD */ - self->get_info = common_get_info; - self->get_if_type = qsfp_get_if_type; - self->get_if_speed = qsfp_get_if_speed; - self->get_if_lane = common_get_if_lane; - self->get_curr_temp = qsfp_get_transvr_temp; - self->get_curr_vol = qsfp_get_transvr_voltage; - self->get_soft_rx_los = qsfp_get_soft_rx_los; - self->get_soft_tx_disable = qsfp_get_soft_tx_disable; - self->get_soft_tx_fault = qsfp_get_soft_tx_fault; - self->get_auto_tx_disable = qsfp_get_auto_tx_disable; - self->get_tx_bias = qsfp_get_transvr_tx_bias; - self->get_tx_power = qsfp_get_transvr_tx_power; - self->get_rx_power = qsfp_get_transvr_rx_power; - self->get_tx_eq = qsfp_get_transvr_tx_eq; - self->get_rx_am = qsfp_get_transvr_rx_am; - self->get_rx_em = qsfp_get_transvr_rx_em; - self->get_wavelength = qsfp_get_wavelength; - self->get_extphy_offset = unsupported_get_func2; - self->get_extphy_reg = unsupported_get_func2; - self->set_cdr = qsfp_set_cdr; - self->set_soft_rs0 = unsupported_set_func; /* TBD */ - self->set_soft_rs1 = unsupported_set_func; /* TBD */ - self->set_soft_tx_disable = qsfp_set_soft_tx_disable; - self->set_auto_tx_disable = qsfp_set_auto_tx_disable; - self->set_tx_eq = qsfp_set_tx_eq; - self->set_rx_am = qsfp_set_rx_am; - self->set_rx_em = qsfp_set_rx_em; - self->set_extphy_offset = unsupported_set_func; - self->set_extphy_reg = unsupported_set_func; - return 0; - - case TRANSVR_TYPE_FAKE: - self->get_id = fake_get_hex; - self->get_ext_id = fake_get_hex; - self->get_connector = fake_get_hex; - self->get_vendor_name = fake_get_str; - self->get_vendor_pn = fake_get_str; - self->get_vendor_rev = fake_get_str; - self->get_vendor_sn = fake_get_str; - self->get_power_cls = fake_get_int; - self->get_br = fake_get_hex; - self->get_len_sm = fake_get_int; - self->get_len_smf = fake_get_int; - self->get_len_om1 = fake_get_int; - self->get_len_om2 = fake_get_int; - self->get_len_om3 = fake_get_int; - self->get_len_om4 = fake_get_int; - self->get_comp_rev = fake_get_hex; - self->get_comp_eth_1 = fake_get_hex; - self->get_comp_eth_10 = fake_get_hex; - self->get_comp_eth_10_40 = fake_get_hex; - self->get_comp_extend = fake_get_hex; - self->get_cdr = fake_get_hex; - self->get_rate_id = fake_get_hex; - self->get_soft_rs0 = fake_get_binary; - self->get_soft_rs1 = fake_get_binary; - self->get_info = fake_get_int; - self->get_if_type = fake_get_str; - self->get_if_speed = fake_get_str; - self->get_if_lane = fake_get_str; - self->get_curr_temp = fake_get_str; - self->get_curr_vol = fake_get_str; - self->get_soft_rx_los = fake_get_str; - self->get_soft_tx_disable = fake_get_str; - self->get_soft_tx_fault = fake_get_str; - self->get_auto_tx_disable = fake_get_str; - self->get_tx_bias = fake_get_str; - self->get_tx_power = fake_get_str; - self->get_rx_power = fake_get_str; - self->get_tx_eq = fake_get_str; - self->get_rx_am = fake_get_str; - self->get_rx_em = fake_get_str; - self->get_wavelength = fake_get_str; - self->get_extphy_offset = fake_get_str; - self->get_extphy_reg = fake_get_str; - self->set_cdr = fake_set_hex; - self->set_soft_rs0 = fake_set_int; - self->set_soft_rs1 = fake_set_int; - self->set_soft_tx_disable = fake_set_int; - self->set_auto_tx_disable = fake_set_int; - self->set_tx_eq = fake_set_int; - self->set_rx_am = fake_set_int; - self->set_rx_em = fake_set_int; - self->set_extphy_offset = fake_set_hex; - self->set_extphy_reg = fake_set_hex; - return 0; - - default: - break; - } - SWPS_WARN("%s: Detect non-defined type:%d\n", __func__, transvr_type); - return ERR_TRANSVR_UNEXCPT; -} - - -static int -setup_transvr_private_cb(struct transvr_obj_s *self, - int transvr_type){ - switch (transvr_type){ - case TRANSVR_TYPE_SFP: - self->init = transvr_init_sfp; - self->clean = common_transvr_clean; - self->check = common_transvr_check; - self->update_all = _sfp_update_attr_all; - self->fsm_4_direct = common_fsm_4_direct_mode; - self->fsm_4_polling = common_fsm_4_polling_mode; - self->send_uevent = sfp_send_uevent; - self->dump_all = sfp_transvr_dump; - return 0; - - case TRANSVR_TYPE_QSFP: - case TRANSVR_TYPE_QSFP_PLUS: - self->init = transvr_init_qsfp; - self->clean = qsfp_transvr_clean; - self->check = common_transvr_check; - self->update_all = _qsfp_update_attr_all; - self->fsm_4_direct = common_fsm_4_direct_mode; - self->fsm_4_polling = common_fsm_4_polling_mode; - self->send_uevent = qsfp_send_uevent; - self->dump_all = qsfp_transvr_dump; - return 0; - - case TRANSVR_TYPE_QSFP_28: - self->init = transvr_init_qsfp28; - self->clean = qsfp_transvr_clean; - self->check = common_transvr_check; - self->update_all = _qsfp_update_attr_all; - self->fsm_4_direct = common_fsm_4_direct_mode; - self->fsm_4_polling = common_fsm_4_polling_mode; - self->send_uevent = qsfp_send_uevent; - self->dump_all = qsfp_transvr_dump; - return 0; - - case TRANSVR_TYPE_FAKE: - self->init = transvr_init_fake; - self->clean = fake_transvr_clean; - self->check = fake_transvr_check; - self->update_all = fake_transvr_update; - self->fsm_4_direct = fake_fsm_4_direct_mode; - self->fsm_4_polling = fake_fsm_4_polling_mode; - self->send_uevent = fake_send_uevent; - self->dump_all = fake_transvr_dump; - return 0; - - default: - break; - } - SWPS_WARN("%s: Detect non-defined type:%d\n", __func__, transvr_type); - return ERR_TRANSVR_UNEXCPT; -} - - -static struct eeprom_map_s * -get_eeprom_map(int transvr_type){ - - switch (transvr_type){ - case TRANSVR_TYPE_SFP: - return &eeprom_map_sfp; - case TRANSVR_TYPE_QSFP: - case TRANSVR_TYPE_QSFP_PLUS: - return &eeprom_map_qsfp; - case TRANSVR_TYPE_QSFP_28: - return &eeprom_map_qsfp28; - - default: - break; - } - SWPS_WARN("%s: Detect non-defined type:%d\n", __func__, transvr_type); - return NULL; -} - - -static int -setup_transvr_ssize_attr(char *swp_name, - struct transvr_obj_s *self, - struct eeprom_map_s *map_p, - struct ioexp_obj_s *ioexp_obj_p, - int ioexp_virt_offset, - int transvr_type, - int chipset_type, - int chan_id, - int run_mode){ - switch (run_mode){ - case TRANSVR_MODE_DIRECT: /* Direct access device mode */ - case TRANSVR_MODE_POLLING: /* Polling mode, read from cache */ - self->mode = run_mode; - break; - default: - SWPS_ERR("%s: non-defined run_mode:%d\n", - __func__, run_mode); - self->mode = DEBUG_TRANSVR_INT_VAL; - return -1; - } - self->eeprom_map_p = map_p; - self->ioexp_obj_p = ioexp_obj_p; - self->ioexp_virt_offset = ioexp_virt_offset; - self->chan_id = chan_id; - self->layout = transvr_type; - self->type = transvr_type; - self->chipset_type = chipset_type; - self->state = STATE_TRANSVR_NEW; - self->info = STATE_TRANSVR_NEW; - self->auto_tx_disable = VAL_TRANSVR_FUNCTION_DISABLE; - strncpy(self->swp_name, swp_name, 32); - mutex_init(&self->lock); - return 0; -} - - -static int -setup_transvr_dsize_attr(struct transvr_obj_s *self){ - - char *emsg = DEBUG_TRANSVR_STR_VAL; - - self->vendor_name = kzalloc((LEN_TRANSVR_M_STR * sizeof(char)), GFP_KERNEL); - if (!self->vendor_name){ - emsg = "vendor_name"; - goto err_setup_d_attr; - } - self->vendor_pn = kzalloc((LEN_TRANSVR_M_STR * sizeof(char)), GFP_KERNEL); - if (!self->vendor_pn){ - emsg = "vendor_pn"; - goto err_setup_d_attr; - } - self->vendor_rev = kzalloc((LEN_TRANSVR_M_STR * sizeof(char)), GFP_KERNEL); - if (!self->vendor_rev){ - emsg = "vendor_rev"; - goto err_setup_d_attr; - } - self->vendor_sn = kzalloc((LEN_TRANSVR_M_STR * sizeof(char)), GFP_KERNEL); - if (!self->vendor_sn){ - emsg = "vendor_sn"; - goto err_setup_d_attr; - } - self->worker_p = NULL; - return 0; - -err_setup_d_attr: - SWPS_ERR("%s: %s kzalloc fail!", __func__, emsg); - return ERR_TRANSVR_UNEXCPT; -} - - -static int -setup_i2c_client(struct transvr_obj_s *self){ - - struct i2c_adapter *adap = NULL; - struct i2c_client *client = NULL; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - - adap = i2c_get_adapter(self->chan_id); - if(!adap){ - snprintf(err_msg, sizeof(err_msg), - "can not get adap:%d", self->chan_id); - goto err_setup_i2c_client; - } - client = kzalloc(sizeof(*client), GFP_KERNEL); - if (!client){ - snprintf(err_msg, sizeof(err_msg), - "can not kzalloc client:%d", self->chan_id); - goto err_setup_i2c_client; - } - client->adapter = adap; - self->i2c_client_p = client; - self->i2c_client_p->addr = VAL_TRANSVR_COMID_ARREESS; - return 0; - -err_setup_i2c_client: - SWPS_ERR("%s: %s\n", __func__, err_msg); - return ERR_TRANSVR_UNEXCPT; -} - - -struct transvr_obj_s * -create_transvr_obj(char *swp_name, - int chan_id, - struct ioexp_obj_s *ioexp_obj_p, - int ioexp_virt_offset, - int transvr_type, - int chipset_type, - int run_mode){ - - struct transvr_obj_s *result_p; - struct eeprom_map_s *map_p; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - - /* Allocate transceiver object */ - map_p = get_eeprom_map(transvr_type); - if (!map_p){ - snprintf(err_msg, sizeof(err_msg), - "Invalid transvr_type:%d", transvr_type); - goto err_create_transvr_fail; - } - result_p = kzalloc(sizeof(*result_p), GFP_KERNEL); - if (!result_p){ - snprintf(err_msg, sizeof(err_msg), "kzalloc fail"); - goto err_create_transvr_fail; - } - /* Prepare static size attributes */ - if (setup_transvr_ssize_attr(swp_name, - result_p, - map_p, - ioexp_obj_p, - ioexp_virt_offset, - transvr_type, - chipset_type, - chan_id, - run_mode) < 0){ - goto err_create_transvr_sattr_fail; - } - /* Prepare dynamic size attributes */ - if (setup_transvr_dsize_attr(result_p) < 0){ - goto err_create_transvr_dattr_fail; - } - /* Prepare call back functions of object */ - if (setup_transvr_public_cb(result_p, transvr_type) < 0){ - goto err_create_transvr_dattr_fail; - } - /* Prepare call back functions of object */ - if (setup_transvr_private_cb(result_p, transvr_type) < 0){ - goto err_create_transvr_dattr_fail; - } - /* Prepare i2c client object */ - if (setup_i2c_client(result_p) < 0){ - goto err_create_transvr_dattr_fail; - } - return result_p; - -err_create_transvr_dattr_fail: - kfree(result_p->vendor_sn); - kfree(result_p->vendor_rev); - kfree(result_p->vendor_pn); - kfree(result_p->vendor_name); -err_create_transvr_sattr_fail: - kfree(result_p); -err_create_transvr_fail: - SWPS_ERR("%s: %s :%d :%d :%d\n", - __func__, err_msg, chan_id, ioexp_virt_offset, transvr_type); - return NULL; -} -EXPORT_SYMBOL(create_transvr_obj); - - -static int -_reload_transvr_obj(struct transvr_obj_s *self, - int new_type){ - - struct eeprom_map_s *new_map_p; - struct eeprom_map_s *old_map_p = self->eeprom_map_p; - struct i2c_client *old_i2c_p = self->i2c_client_p; - int old_type = self->type; - - /* Change state to STATE_TRANSVR_INIT */ - self->state = STATE_TRANSVR_INIT; - self->type = new_type; - /* Replace EEPROME map */ - new_map_p = get_eeprom_map(new_type); - if (!new_map_p){ - goto err_private_reload_func_1; - } - self->eeprom_map_p = new_map_p; - /* Reload i2c client */ - if (setup_i2c_client(self) < 0){ - goto err_private_reload_func_2; - } - /* Replace call back functions */ - if (setup_transvr_public_cb(self, new_type) < 0){ - goto err_private_reload_func_3; - } - if (setup_transvr_private_cb(self, new_type) < 0){ - goto err_private_reload_func_3; - } - if(old_i2c_p){ - i2c_put_adapter(old_i2c_p->adapter); - } - kfree(old_i2c_p); - return 0; - -err_private_reload_func_3: - SWPS_INFO("%s: init() fail!\n", __func__); - if(old_i2c_p){ - i2c_put_adapter(old_i2c_p->adapter); - } - kfree(old_i2c_p); - self->state = STATE_TRANSVR_UNEXCEPTED; - self->type = TRANSVR_TYPE_ERROR; - return -2; - -err_private_reload_func_2: - self->eeprom_map_p = old_map_p; - self->i2c_client_p = old_i2c_p; -err_private_reload_func_1: - self->state = STATE_TRANSVR_UNEXCEPTED; - self->type = old_type; - SWPS_INFO("%s fail! :0x%02x\n", __func__, new_type); - return -1; -} - - -static int -reload_transvr_obj(struct transvr_obj_s *self, - int new_type){ - - int result_val = ERR_TRANSVR_UNEXCPT; - - /* Reload phase */ - result_val = _reload_transvr_obj(self, new_type); - if (result_val < 0){ - SWPS_INFO("%s: reload phase fail! :%d\n", - __func__, result_val); - return EVENT_TRANSVR_RELOAD_FAIL; - } - /* Initial phase */ - result_val = _transvr_init_handler(self); - if (result_val < 0){ - SWPS_INFO("%s: initial phase fail! :%d\n", - __func__, result_val); - } - return result_val; -} - - -int -isolate_transvr_obj(struct transvr_obj_s *self) { - - self->state = STATE_TRANSVR_ISOLATED; - SWPS_INFO("%s: %s be isolated\n", __func__, self->swp_name); - return 0; -} -EXPORT_SYMBOL(isolate_transvr_obj); - - -int -resync_channel_tier_2(struct transvr_obj_s *self) { - - int val = TRANSVR_TYPE_ERROR; - - if (self->state == STATE_TRANSVR_ISOLATED) { - return 0; - } - self->i2c_client_p->addr = VAL_TRANSVR_COMID_ARREESS; - val = i2c_smbus_read_byte_data(self->i2c_client_p, - VAL_TRANSVR_COMID_OFFSET); - if (val < 0) { - return -1; - } - return 0; -} -EXPORT_SYMBOL(resync_channel_tier_2); - -/* For build single module using (Ex: ONL platform) */ -MODULE_LICENSE("GPL"); - - -/* ----------------------------------------- - * ToDo List - * ----------------------------------------- - * 1. _sfp_detect_class_by_feature() - * => Need check ACC use case. - * 2. _sfp_detect_class_by_1g_ethernet() - * => Need check 0.1G use case. - * 3. Loopback transceiver use case. - * => Less much data - * 4. _qsfp_detect_class_by_extend_comp() - * => Verify 100G CWDM4 - * => Verify Obsolete (assigned before 100G CWDM4 MSA required FEC) - * => Verify 100G CLR4 - * => Verify 100GE-DWDM2 - * => Verify 40G PSM4 Parallel SMF - * => Verify 100G ACC (Active Copper Cable) or 25GAUI C2M ACC. - * => Verify 100G ACC or 25GAUI C2M ACC. - * => Verify 25GBASE-LR - * => Verify 40G Active Cable (XLPPI) - */ - - - - - - - - diff --git a/packages/platforms/inventec/x86-64/d5264q28b/modules/builds/src/transceiver.h b/packages/platforms/inventec/x86-64/d5264q28b/modules/builds/src/transceiver.h deleted file mode 100644 index 668b477cd..000000000 --- a/packages/platforms/inventec/x86-64/d5264q28b/modules/builds/src/transceiver.h +++ /dev/null @@ -1,809 +0,0 @@ -#ifndef TRANSCEIVER_H -#define TRANSCEIVER_H - -#include - -/* advanced features control */ -#define TRANSVR_INFO_DUMP_ENABLE (1) -#define TRANSVR_INFO_CACHE_ENABLE (1) -#define TRANSVR_UEVENT_ENABLE (1) - -/* Transceiver type define */ -#define TRANSVR_TYPE_UNKNOW_1 (0x00) -#define TRANSVR_TYPE_UNKNOW_2 (0xff) -#define TRANSVR_TYPE_SFP (0x03) /* Define for SFP, SFP+, SFP28 */ -#define TRANSVR_TYPE_QSFP (0x0c) -#define TRANSVR_TYPE_QSFP_PLUS (0x0d) -#define TRANSVR_TYPE_QSFP_28 (0x11) -#define TRANSVR_TYPE_UNPLUGGED (0xfa) /* Define for ERROR handle */ -#define TRANSVR_TYPE_FAKE (0xfc) /* Define for ERROR handle */ -#define TRANSVR_TYPE_INCONSISTENT (0xfd) /* Define for ERROR handle */ -#define TRANSVR_TYPE_ERROR (0xfe) /* Define for ERROR handle */ - -/* Transceiver class for base info */ -#define TRANSVR_CLASS_UNSPECIFIED (0) -#define TRANSVR_CLASS_ERROR (-26001) -#define TRANSVR_CLASS_1G (26001) -#define TRANSVR_CLASS_10G (26011) -#define TRANSVR_CLASS_25G (26021) -#define TRANSVR_CLASS_40G (26041) -#define TRANSVR_CLASS_100G (26101) -#define TRANSVR_CLASS_NO_SPERARABLE (26901) -#define TRANSVR_CLASS_EXTEND_COMP (26902) -/* Transceiver class for Optical 1G */ -#define TRANSVR_CLASS_OPTICAL (27000) -#define TRANSVR_CLASS_OPTICAL_100 (27001) -#define TRANSVR_CLASS_OPTICAL_1G (27002) -#define TRANSVR_CLASS_OPTICAL_1G_AOC (27003) -#define TRANSVR_CLASS_OPTICAL_1G_SX (27004) -#define TRANSVR_CLASS_OPTICAL_1G_LX (27005) -#define TRANSVR_CLASS_OPTICAL_1G_EX (27006) -/* Transceiver class for Optical 10G */ -#define TRANSVR_CLASS_OPTICAL_10G (27010) -#define TRANSVR_CLASS_OPTICAL_10G_S_AOC (27011) -#define TRANSVR_CLASS_OPTICAL_10G_S_SR (27012) -#define TRANSVR_CLASS_OPTICAL_10G_S_LR (27013) -#define TRANSVR_CLASS_OPTICAL_10G_S_ER (27014) -#define TRANSVR_CLASS_OPTICAL_10G_Q_AOC (27015) -#define TRANSVR_CLASS_OPTICAL_10G_Q_SR (27016) -#define TRANSVR_CLASS_OPTICAL_10G_Q_LR (27017) -#define TRANSVR_CLASS_OPTICAL_10G_Q_ER (27018) -/* Transceiver class for Optical 25G */ -#define TRANSVR_CLASS_OPTICAL_25G (27020) -#define TRANSVR_CLASS_OPTICAL_25G_AOC (27021) -#define TRANSVR_CLASS_OPTICAL_25G_SR (27022) -#define TRANSVR_CLASS_OPTICAL_25G_LR (27023) -#define TRANSVR_CLASS_OPTICAL_25G_ER (27024) -/* Transceiver class for Optical 40G */ -#define TRANSVR_CLASS_OPTICAL_40G (27040) -#define TRANSVR_CLASS_OPTICAL_40G_AOC (27041) -#define TRANSVR_CLASS_OPTICAL_40G_SR4 (27042) -#define TRANSVR_CLASS_OPTICAL_40G_LR4 (27043) -#define TRANSVR_CLASS_OPTICAL_40G_ER4 (27044) -/* Transceiver class for Optical 100G */ -#define TRANSVR_CLASS_OPTICAL_100G (27100) -#define TRANSVR_CLASS_OPTICAL_100G_AOC (27101) -#define TRANSVR_CLASS_OPTICAL_100G_SR4 (27102) -#define TRANSVR_CLASS_OPTICAL_100G_LR4 (27103) -#define TRANSVR_CLASS_OPTICAL_100G_ER4 (27104) -#define TRANSVR_CLASS_OPTICAL_100G_PSM4 (27105) -/* Transceiver class for Copper */ -#define TRANSVR_CLASS_COPPER (28000) -#define TRANSVR_CLASS_COPPER_L1_1G (28001) -#define TRANSVR_CLASS_COPPER_L1_10G (28011) -#define TRANSVR_CLASS_COPPER_L4_10G (28012) -#define TRANSVR_CLASS_COPPER_L1_25G (28021) -#define TRANSVR_CLASS_COPPER_L4_40G (28041) -#define TRANSVR_CLASS_COPPER_L4_100G (28101) -/* Transceiver class for Base-T */ -#define TRANSVR_CLASS_BASE_T_1000 (29001) -#define TRANSVR_CLASS_BASE_T_1000_up (29002) -/* For uevent message */ -#define TRANSVR_UEVENT_KEY_IF "IF_TYPE" -#define TRANSVR_UEVENT_KEY_SP "IF_SPEED" -#define TRANSVR_UEVENT_KEY_LANE "IF_LANE" -#define TRANSVR_UEVENT_UNKNOW "UNKNOW" -#define TRANSVR_IF_KR "KR" -#define TRANSVR_IF_KR4 "KR4" -#define TRANSVR_IF_SR "SR" -#define TRANSVR_IF_SR4 "SR4" -#define TRANSVR_IF_SFI "SFI" -#define TRANSVR_IF_IF_GMII "GMII" -#define TRANSVR_IF_IF_XGMII "XGMII" -#define TRANSVR_IF_SP_100 "100" -#define TRANSVR_IF_SP_1G "1000" -#define TRANSVR_IF_SP_10G "10000" -#define TRANSVR_IF_SP_25G "25000" -#define TRANSVR_IF_SP_40G "40000" -#define TRANSVR_IF_SP_100G "100000" - -/* Transceiver mode define */ -#define TRANSVR_MODE_DIRECT (21000) -#define TRANSVR_MODE_POLLING (21001) - -/* Transceiver state define - * [Note] - * 1. State is used to represent the state of "Transceiver" and "Object". - * 2. State for different target has different means. The description as following: - */ -#define STATE_TRANSVR_CONNECTED (0) /* [Transvr]:Be plugged in. [Obj]:Link up, and work normally. */ -#define STATE_TRANSVR_NEW (-100) /* [Transvr]:(Not used) [Obj]:Create */ -#define STATE_TRANSVR_INIT (-101) /* [Transvr]:Be plugged in. [Obj]:Link up, and in initial process. */ -#define STATE_TRANSVR_ISOLATED (-102) /* [Transvr]:Be plugged in. [Obj]:Isolate, and not provide service. */ -#define STATE_TRANSVR_SWAPPED (-200) /* [Transvr]:Be plugged in. [Obj]:(Not used) */ -#define STATE_TRANSVR_DISCONNECTED (-300) /* [Transvr]:Un-plugged. [Obj]:Link down, and not provide service. */ -#define STATE_TRANSVR_UNEXCEPTED (-901) /* [Transvr]:Any [Obj]:Any, and not in expect case. */ - -/* Task state define */ -#define STATE_T_TASK_WAIT (110) -#define STATE_T_TASK_DONE (0) -#define STATE_T_TASK_INIT (-110) -#define STATE_T_TASK_FAIL (-410) - - -/* Event for task handling */ -#define EVENT_TRANSVR_TASK_WAIT (2101) -#define EVENT_TRANSVR_TASK_DONE (0) -#define EVENT_TRANSVR_TASK_FAIL (-2101) -/* Event for initial handling */ -#define EVENT_TRANSVR_INIT_UP (2201) -#define EVENT_TRANSVR_INIT_DOWN (1) -#define EVENT_TRANSVR_INIT_REINIT (-2201) -#define EVENT_TRANSVR_INIT_FAIL (-2202) -/* Event for others */ -#define EVENT_TRANSVR_RELOAD_FAIL (-2301) -#define EVENT_TRANSVR_EXCEP_INIT (-2401) -#define EVENT_TRANSVR_EXCEP_UP (-2402) -#define EVENT_TRANSVR_EXCEP_DOWN (-2403) -#define EVENT_TRANSVR_EXCEP_SWAP (-2404) -#define EVENT_TRANSVR_EXCEP_EXCEP (-2405) -#define EVENT_TRANSVR_EXCEP_ISOLATED (-2406) -#define EVENT_TRANSVR_I2C_CRASH (-2501) - -/* Transceiver error code define */ -#define ERR_TRANSVR_UNINIT (-201) -#define ERR_TRANSVR_UNPLUGGED (-202) -#define ERR_TRANSVR_ABNORMAL (-203) -#define ERR_TRANSVR_NOSTATE (-204) -#define ERR_TRANSVR_NOTSUPPORT (-205) -#define ERR_TRANSVR_BADINPUT (-206) -#define ERR_TRANSVR_UPDATE_FAIL (-207) -#define ERR_TRANSVR_RELOAD_FAIL (-208) -#define ERR_TRANSVR_INIT_FAIL (-209) -#define ERR_TRANSVR_UNDEFINED (-210) -#define ERR_TRANSVR_TASK_FAIL (-211) -#define ERR_TRANSVR_TASK_BUSY (-212) -#define ERR_TRANSVR_UEVENT_FAIL (-213) -#define ERR_TRANSVR_FUNC_DISABLE (-214) -#define ERR_TRANSVR_I2C_CRASH (-297) -#define ERR_TRNASVR_BE_ISOLATED (-298) -#define ERR_TRANSVR_UNEXCPT (-299) - -/* For debug */ -#define DEBUG_TRANSVR_INT_VAL (-99) -#define DEBUG_TRANSVR_HEX_VAL (0xfe) -#define DEBUG_TRANSVR_STR_VAL "ERROR" - -/* For system internal */ -#define VAL_TRANSVR_COMID_ARREESS (0x50) -#define VAL_TRANSVR_COMID_OFFSET (0x00) -#define VAL_TRANSVR_EXTPHY_ADDR_56 (0x56) -#define VAL_TRANSVR_8472_READY_ADDR (0x51) -#define VAL_TRANSVR_8472_READY_PAGE (-1) -#define VAL_TRANSVR_8472_READY_OFFSET (110) -#define VAL_TRANSVR_8472_READY_BIT (0) -#define VAL_TRANSVR_8472_READY_VALUE (0) -#define VAL_TRANSVR_8472_READY_ABNORMAL (0xff) -#define VAL_TRANSVR_8436_READY_ADDR (0x50) -#define VAL_TRANSVR_8436_READY_PAGE (-1) -#define VAL_TRANSVR_8436_READY_OFFSET (2) -#define VAL_TRANSVR_8436_READY_BIT (0) -#define VAL_TRANSVR_8436_READY_VALUE (0) -#define VAL_TRANSVR_8436_READY_ABNORMAL (0xff) -#define VAL_TRANSVR_8436_PWD_ADDR (0x50) -#define VAL_TRANSVR_8436_PWD_PAGE (-1) -#define VAL_TRANSVR_8436_PWD_OFFSET (123) -#define VAL_TRANSVR_PAGE_FREE (-99) -#define VAL_TRANSVR_PAGE_SELECT_OFFSET (127) -#define VAL_TRANSVR_PAGE_SELECT_DELAY (5) -#define VAL_TRANSVR_TASK_RETRY_FOREVER (-999) -#define VAL_TRANSVR_FUNCTION_DISABLE (-1) -#define STR_TRANSVR_SFP "SFP" -#define STR_TRANSVR_QSFP "QSFP" -#define STR_TRANSVR_QSFP_PLUS "QSFP+" -#define STR_TRANSVR_QSFP28 "QSFP28" - -/* For transvr buf len */ -#define LEN_TRANSVR_S_STR (16) -#define LEN_TRANSVR_M_STR (32) -#define LEN_TRANSVR_L_STR (64) - -/* Optical wavelength */ -#define VAL_OPTICAL_WAVELENGTH_SR (850) -#define VAL_OPTICAL_WAVELENGTH_LR (1310) -#define VAL_OPTICAL_WAVELENGTH_ER (1550) - -/* Switch chip type define */ -#define CHIP_TYPE_MAGNOLIA (31001) /* Magnolia, Hudson32i, Spruce */ -#define CHIP_TYPE_REDWOOD (31002) /* Redwood, Cypress, Sequoia */ -#define CHIP_TYPE_MAPLE (31003) /* Maple */ - -#define CHIP_TYPE_LAVENDER (31011) /* Lavender */ - -/* Info from transceiver EEPROM */ -struct eeprom_map_s { - int addr_br; int page_br; int offset_br; int length_br; - int addr_cdr; int page_cdr; int offset_cdr; int length_cdr; - int addr_comp_rev; int page_comp_rev; int offset_comp_rev; int length_comp_rev; - int addr_connector; int page_connector; int offset_connector; int length_connector; - int addr_diag_type; int page_diag_type; int offset_diag_type; int length_diag_type; - int addr_extbr; int page_extbr; int offset_extbr; int length_extbr; - int addr_ext_id; int page_ext_id; int offset_ext_id; int length_ext_id; - int addr_id; int page_id; int offset_id; int length_id; - int addr_len_sm; int page_len_sm; int offset_len_sm; int length_len_sm; - int addr_len_smf; int page_len_smf; int offset_len_smf; int length_len_smf; - int addr_len_om1; int page_len_om1; int offset_len_om1; int length_len_om1; - int addr_len_om2; int page_len_om2; int offset_len_om2; int length_len_om2; - int addr_len_om3; int page_len_om3; int offset_len_om3; int length_len_om3; - int addr_len_om4; int page_len_om4; int offset_len_om4; int length_len_om4; - int addr_option; int page_option; int offset_option; int length_option; - int addr_rate_id; int page_rate_id; int offset_rate_id; int length_rate_id; - int addr_rx_am; int page_rx_am; int offset_rx_am; int length_rx_am; - int addr_rx_em; int page_rx_em; int offset_rx_em; int length_rx_em; - int addr_rx_los; int page_rx_los; int offset_rx_los; int length_rx_los; - int addr_rx_power; int page_rx_power; int offset_rx_power; int length_rx_power; - int addr_soft_rs0; int page_soft_rs0; int offset_soft_rs0; int length_soft_rs0; - int addr_soft_rs1; int page_soft_rs1; int offset_soft_rs1; int length_soft_rs1; - int addr_temp; int page_temp; int offset_temp; int length_temp; - int addr_trancomp; int page_trancomp; int offset_trancomp; int length_trancomp; - int addr_trancomp_ext; int page_trancomp_ext; int offset_trancomp_ext; int length_trancomp_ext; - int addr_tx_bias; int page_tx_bias; int offset_tx_bias; int length_tx_bias; - int addr_tx_disable; int page_tx_disable; int offset_tx_disable; int length_tx_disable; - int addr_tx_eq; int page_tx_eq; int offset_tx_eq; int length_tx_eq; - int addr_tx_fault; int page_tx_fault; int offset_tx_fault; int length_tx_fault; - int addr_tx_power; int page_tx_power; int offset_tx_power; int length_tx_power; - int addr_vendor_name; int page_vendor_name; int offset_vendor_name; int length_vendor_name; - int addr_vendor_pn; int page_vendor_pn; int offset_vendor_pn; int length_vendor_pn; - int addr_vendor_rev; int page_vendor_rev; int offset_vendor_rev; int length_vendor_rev; - int addr_vendor_sn; int page_vendor_sn; int offset_vendor_sn; int length_vendor_sn; - int addr_voltage; int page_voltage; int offset_voltage; int length_voltage; - int addr_wavelength; int page_wavelength; int offset_wavelength; int length_wavelength; -}; - - -struct transvr_worker_s; - -/* Class of transceiver object */ -struct transvr_obj_s { - - /* ========== Object private property ========== - * [Prop]: id - * [Desc]: Type of serial transceiver. - * [Note]: SFP:03h / QSFP:0Ch / QSPF+:0Dh /QSFP28:11h - */ - uint8_t id; - - /* [Prop]: connector - * [Desc]: Connector type. - * [Note]: SFP : A0h / 2 - * QSFP: 00h / 130 - */ - uint8_t connector; - - /* [Prop]: transvr_comp - * [Desc]: Transceiver compliance code. - * [Note]: SFP: SFF-8472 - * - Normal : A0h / offset 3-10 - * - Extended: A0h / offset 36 - * QSFP: SFF-8436 & SFF-8636 - * - Normal : 00h / offset 131-138 - * - Extended: 00h / offset 192 - */ - uint8_t transvr_comp[8]; - uint8_t transvr_comp_ext; - - /* [Prop]: vendor_name - * [Desc]: SFP vendor name (ASCII 16 byte char). - * [Note]: ex:FINISAR CORP. - */ - char *vendor_name; - - /* [Prop]: vendor_pn - * [Desc]: Part number provided by SFP vendor (ASCII 16 byte char). - * [Note]: - */ - char *vendor_pn; - - /* [Prop]: vendor_rev - * [Desc]: Revision level for part number provided by vendor (ASCII 4 byte char). - * [Note]: - */ - char *vendor_rev; - - /* [Prop]: vendor_sn - * [Desc]: Serial number provided by vendor (ASCII 16 byte char). - * [Note]: - */ - char *vendor_sn; - - /* [Prop]: Extended identifier - * [Desc]: SFP: - * => None - * - * QSFP: - * => This byte contained two information: - * (1) Power consumption class - * (2) CDR function present - * [Note]: Bit description as below: - * [SFP] - * None - * - * [QSFP] - * (1) Power consumption class: - * Class 1: 1.5W (Bit6-7 = 00:) - * Class 2: 2.0W (Bit6-7 = 01:) - * Class 3: 2.5W (Bit6-7 = 10:) - * Class 4: 3.5W (Bit6-7 = 11:) - * Class 5: 4.0W (Bit0-1 = 01:) - * Class 6: 4.5W (Bit0-1 = 10:) - * Class 7: 5.0W (Bit0-1 = 11:) - * (2) CDR function present: - * Bit2: 0 = No CDR in RX - * 1 = CDR present in RX - * Bit3: 0 = No CDR in TX - * 1 = CDR present in TX - */ - uint8_t ext_id; - - /* [Prop]: br - * [Desc]: Nominal bit rate, units of 100 MBits/sec. - * [Note]: SFP:03h / QSFP:0Ch / QSPF+:0Dh - * has val: 0x67 - * no val : - */ - uint8_t br; - - /* [Prop]: extbr - * [Desc]: Extended br (00h/222) - * [Desc]: Nominal bit rate per channel, units of 250 Mbps. - * Complements. Byte 140. See Table 32A. - */ - uint8_t extbr; - - /* [Prop]: len_sm - * [Desc]: Length (single mode)-(100's)m - * [Note]: This value specifies the link length that is supported by the transceiver - * while operating in compliance with the applicable standards using single mode - * fiber. The value is in units of 100 meters. A value of 255 means that the - * transceiver supports a link length greater than 25.4 km. A value of zero means - * that the transceiver does not support single mode fiber or that the length - * information must be determined from the transceiver technology. - */ - int len_sm; - - /* [Prop]: len_smf - * [Desc]: Length (single mode)-km - * [Note]: Addition to EEPROM data from original GBIC definition. This value specifies - * the link length that is supported by the transceiver while operating in - * compliance with the applicable standards using single mode fiber. The value - * is in units of kilometers. A value of 255 means that the transceiver supports - * a link length greater than 254 km. A value of zero means that the transceiver - * does not support single mode fiber or that the length information must be - * determined from the transceiver technology. - */ - int len_smf; - - /* [Prop]: len_om1 - * [Desc]: Link length supported for 62.5 um OM1 fiber, units of 10 m - * [Note]: The value is in units of 10 meters. A value of 255 means that the - * transceiver supports a link length greater than 2.54 km. A value of - * zero means that the transceiver does not support 50 micron multi-mode - * fiber or that the length information must be determined from the transceiver - * technology. - */ - int len_om1; - - /* [Prop]: len_om2 - * [Desc]: Link length supported for 50 um OM2 fiber, units of 10 m - * [Note]: The value is in units of 10 meters. A value of 255 means that the - * transceiver supports a link length greater than 2.54 km. A value of - * zero means that the transceiver does not support 50 micron multi-mode - * fiber or that the length information must be determined from the transceiver - * technology. - */ - int len_om2; - - /* [Prop]: len_om3 - * [Desc]: Length (50um, OM3) - * [Note]: This value specifies link length that is supported by the transceiver while - * operating in compliance with applicable standards using 50 micron multimode - * OM3 [2000 MHz*km] fiber. The value is in units of 10 meters. A value of 255 - * means that the transceiver supports a link length greater than 2.54 km. A value - * of zero means that the transceiver does not support 50 micron multimode fiber - * or that the length information must be determined from the transceiver technology. - */ - int len_om3; - - /* [Prop]: len_om4 - * [Desc]: Length (50um, OM4) and Length (Active Cable or Copper) - * [Note]: For optical links, this value specifies link length that is supported by the - * transceiver while operating in compliance with applicable standards using 50 micron - * multimode OM4 [4700 MHz*km] fiber. The value is in units of 10 meters. A value of - * 255 means that the transceiver supports a link length greater than 2.54 km. A value - * of zero means that the transceiver does not support 50 micron multimode fiber or that - * the length information must be determined from the transceiver codes specified in Table 5-3. - * - * For copper links, this value specifies minimum link length supported by the transceiver - * while operating in compliance with applicable standards using copper cable. For active - * cable, this value represents actual length. The value is in units of 1 meter. A value of 255 - * means the transceiver supports a link length greater than 254 meters. A value of zero means - * the transceiver does not support copper or active cables or the length information must be - * determined from transceiver technology. Further information about cable design, equalization, - * and connectors is usually required to guarantee meeting a particular length requirement. - */ - int len_om4; - - /* [Prop]: comp_rev - * [Desc]: SFF spec revision compliance - * [Note]: Indicates which revision of SFF SFF-8472 (SFP) / SFF-8636 (QSFP) the transceiver - * complies with. (unsigned integer) - */ - uint8_t comp_rev; - - /* [Prop]: CDR - * [Desc]: For transceivers with CDR capability, setting the CDR to ON engages the internal - * retiming function. Setting the CDR to OFF enables an internal bypassing mode ,which - * directs traffic around the internal CDR. (Reference: SFF-8636) - * [Note]: value=0xff: ON. - * value=0x00: OFF. - */ - uint8_t cdr; - - /* [Prop]: rate_id - * [Desc]: Soft Rate Select 0(RX). - * [Note]: 1. Addr: A0h / Offset: 13 - * 2. Value description: - * 00h Unspecified - * 01h SFF-8079 (4/2/1G Rate_Select & AS0/AS1) - * 02h SFF-8431 (8/4/2G Rx Rate_Select only) - * 03h Unspecified * - * 04h SFF-8431 (8/4/2G Tx Rate_Select only) - * 05h Unspecified * - * 06h SFF-8431 (8/4/2G Independent Rx & Tx Rate_select) - * 07h Unspecified * - * 08h FC-PI-5 (16/8/4G Rx Rate_select only) High=16G only, Low=8G/4G - * 09h Unspecified * - * 0Ah FC-PI-5 (16/8/4G Independent Rx, Tx Rate_select) High=16G only, - * Low=8G/4G - * 0Bh Unspecified * - * 0Ch FC-PI-6 (32/16/8G Independent Rx, Tx Rate_Select) - * High=32G only, Low = 16G/8G - * 0Dh Unspecified * - * 0Eh 10/8G Rx and Tx Rate_Select controlling the operation or locking - * modes of the internal signal conditioner, retimer or CDR, according - * to the logic table defined in Table 10-2, High Bit Rate - * (10G) =9.95-11.3 Gb/s; Low Bit Rate (8G) = 8.5 Gb/s. In this mode, - * the default value of bit 110.3 (Soft Rate Select RS(0), Table 9-11) - * and of bit 118.3 (Soft Rate Select RS(1), Table 10-1) is 1. - * 0Fh Unspecified * - * 10h-FFh Unallocated - */ - int rate_id; - - /* [Prop]: soft_rs0 - * [Desc]: Soft Rate Select 0(RX). - * [Note]: 1. Writing '1' selects full bandwidth operation. - * 2. This bit is "OR'd with the hard Rate_Select, AS(0) or RS(0) pin value. - * 3. Default at power up is logic zero/low - * 4. Addr: A2h / Offset: 110 / Bit: 3 - */ - uint8_t soft_rs0; - - /* [Prop]: soft_rs1 - * [Desc]: Soft Rate Select 1(TX). - * [Note]: 1. Writing '1' selects full bandwidth TX operation. - * 2. This bit is "OR'd with the hard Rate_Select, AS(1) or RS(1) pin value. - * 3. Default at power up is logic zero/low - * 4. Addr: A2h / Offset: 118 / Bit: 3 - */ - uint8_t soft_rs1; - - /* [Prop]: diag_type - * [Desc]: DIAGNOSTIC MONITORING TYPE (A0h/92) - * [Note]: Description in SFF-8472 as below: - * Bit7: Reserved for legacy diagnostic implementations. Must be '0' for compliance - * with this document. - * Bit6: Digital diagnostic monitoring implemented (described in this document). - * Must be '1' for compliance with this document. - * Bit5 Internally calibrated - * Bit4 Externally calibrated - * Bit3 Received power measurement type.0 = OMA, 1 = average power - * Bit2 Address change required see section above, "addressing modes" - * Bit1-0 Unallocated - */ - uint8_t diag_type; - - /* [Prop]: curr_temp - * [Desc]: Transceiver Current Temperature (A2h/96-97) - * [Note]: 1. Dependent on diag_type. - * 2. 96: High byte - * 3. 97: Low byte - * 4. This feature only for SFP - */ - uint8_t curr_temp[2]; - - /* [Prop]: curr_vol - * [Desc]: Transceiver Current Voltage (SFP:A2h/108-109; QSFP:00h/22-23) - * [Note]: 1. Dependent on diag_type. - * 2. 98: High byte - * 3. 99: Low byte - * 4. This feature only for SFP - * 5. Internally measured transceiver supply voltage. Represented - * as a 16 bit unsigned integer with the voltage defined as the - * full 16 bit value (0-65535) with LSB equal to 100 uVolt, - * yielding a total range of 0 to +6.55 Volts - */ - uint8_t curr_voltage[2]; - - /* [Prop]: curr_tx_bias - * [Desc]: Transceiver TX Bias Current (SFP:A2h/100-101; QSFP:00h/26-27) - * [Note]: 1. Dependent on diag_type. - * 2. 100: High byte - * 3. 101: Low byte - * 4. This feature only for SFP - * 5. Measured TX bias current in uA. Represented as a 16 bit unsigned - * integer with the current defined as the full 16 bit value (0-65535) - * with LSB equal to 2 uA, yielding a total range of 0 to 131 mA. - * Accuracy is vendor specific but must be better than 10% of the - * manufacturer's nominal value over specified operating temperature - * and voltage. - */ - uint8_t curr_tx_bias[8]; - - /* [Prop]: curr_tx_power - * [Desc]: Transceiver TX Output Power (A2h/102-103) - * [Note]: 1. Dependent on diag_type. - * 2. 102: High byte - * 3. 103: Low byte - * 4. This feature only for SFP - * 5. Measured TX output power in mW. Represented as a 16 bit unsigned - * integer with the power defined as the full 16 bit value (0-65535) - * with LSB equal to 0.1 uW, yielding a total range of 0 to 6.5535 mW - * (~ -40 to +8.2 dBm). Data is assumed to be based on measurement of - * laser monitor photodiode current. It is factory calibrated to absolute - * units using the most representative fiber output type. Accuracy is - * vendor specific but must be better than 3dB over specified temperature - * and voltage. Data is not valid when the transmitter is disabled. - */ - uint8_t curr_tx_power[8]; - - /* [Prop]: curr_tx_power - * [Desc]: Transceiver TX Output Power (A2h/102-103) - * [Note]: 1. Dependent on diag_type. - * 2. 102: High byte - * 3. 103: Low byte - * 4. This feature only for SFP - * 5. Measured RX received optical power in mW. Value can represent either - * average received power or OMA depending upon how bit 3 of byte 92 (A0h) - * is set. Represented as a 16 bit unsigned integer with the power defined - * as the full 16 bit value (0-65535) with LSB equal to 0.1 uW, yielding a - * total range of 0 to 6.5535 mW (~ -40 to +8.2 dBm). Absolute accuracy is - * dependent upon the exact optical wavelength. For the vendor specified - * wavelength, accuracy shall be better than 3dB over specified temperature - * and voltage. - */ - uint8_t curr_rx_power[8]; - - /* [Prop]: wavelength - * [Desc]: Wavelength or Copper Cable Attenuation - * [Note]: (Following is info from SFF-8636) - * For optical free side devices, this parameter identifies the nominal - * transmitter output wavelength at room temperature. This parameter is a - * 16-bit hex value with Byte 186 as high order byte and Byte 187 as low - * order byte. The laser wavelength is equal to the 16-bit integer value - * divided by 20 in nm (units of 0.05 nm). This resolution should be adequate - * to cover all relevant wavelengths yet provide enough resolution for all - * expected DWDM applications. For accurate representation of controlled - * wavelength applications, this value should represent the center of the - * guaranteed wavelength range. If the free side device is identified as - * copper cable these registers will be used to define the cable attenuation. - * An indication of 0 dB attenuation refers to the case where the attenuation - * is not known or is unavailable. - * Byte 186 (00-FFh) is the copper cable attenuation at 2.5 GHz in units of 1 dB. - * Byte 187 (00-FFh) is the copper cable attenuation at 5.0 GHz in units of 1 dB. - */ - uint8_t wavelength[2]; - - /* [Prop]: Amplitude control - * [Desc]: Amplitude control - * [Note]: QSFP28 => SFF-8636 03H Byte-238/239 - */ - uint8_t rx_am[2]; - - /* [Prop]: Emphasis control - * [Desc]: Emphasis control - * [Note]: SFP+/28 => SFF-8472 A2H Byte-115 - * QSFP28 => SFF-8636 03H Byte-236/237 - */ - uint8_t rx_em[2]; - - /* [Prop]: Soft Rx LOS - * [Desc]: Soft Rx LOS which provide by transceiver - * [Note]: (Following is info from SFF-8636) - * Byte 3: - * - Bit 0: L-Rx1 LOS - * - Bit 1: L-Rx2 LOS - * - Bit 2: L-Rx3 LOS - * - Bit 3: L-Rx4 LOS - */ - uint8_t rx_los; - - /* [Prop]: Soft Tx Disable - * [Desc]: Soft Tx Disable which provide by transceiver - * [Note]: (Following is info from SFF-8636) - * Byte 86: - * - Bit 0: Tx1 Disable - * - Bit 1: Tx2 Disable - * - Bit 2: Tx3 Disable - * - Bit 3: Tx4 Disable - */ - uint8_t tx_disable; - - /* [Prop]: Soft Tx Fault - * [Desc]: Soft Tx Fault which provide by transceiver - * [Note]: (Following is info from SFF-8636) - * Byte 86: - * - Bit 0: Tx1 Fault - * - Bit 1: Tx2 Fault - * - Bit 2: Tx3 Fault - * - Bit 3: Tx4 Fault - */ - uint8_t tx_fault; - - /* [Prop]: Transceiver EQUALIZATION - * [Desc]: Transceiver EQUALIZATION - * [Note]: SFP+/28 => SFF-8472 A2H Byte-114 - * QSFP28 => SFF-8636 03H Byte-234/235 - */ - uint8_t tx_eq[2]; - - /* [Prop]: OPTION VALUES - * [Desc]: The bits in the option field shall specify the options implemented in the transceiver. - * [Note]: SFP+/28 => SFF-8472 A0H Byte-64/65 - * QSFP+/28 => SFF-8636 00H Byte-193/195 - */ - uint8_t option[3]; - - /* [Prop]: External PHY offset - * [Desc]: It needs to be setup first if you want to access transceiver external phy. - * [Note]: This feature dependent on transceiver. - * Currently, only 1G-RJ45 transceiver supported it. - */ - uint8_t extphy_offset; - - /* ========== Object private property ========== - */ - struct device *transvr_dev_p; - struct eeprom_map_s *eeprom_map_p; - struct i2c_client *i2c_client_p; - struct ioexp_obj_s *ioexp_obj_p; - struct transvr_worker_s *worker_p; - struct mutex lock; - char swp_name[32]; - int auto_config; - int auto_tx_disable; - int chan_id; - int chipset_type; - int curr_page; - int info; - int ioexp_virt_offset; - int lane_id[8]; - int layout; - int mode; - int retry; - int state; - int temp; - int type; - - /* ========== Object public functions ========== - */ - int (*get_id)(struct transvr_obj_s *self); - int (*get_ext_id)(struct transvr_obj_s *self); - int (*get_connector)(struct transvr_obj_s *self); - int (*get_vendor_name)(struct transvr_obj_s *self, char *buf_p); - int (*get_vendor_pn)(struct transvr_obj_s *self, char *buf_p); - int (*get_vendor_rev)(struct transvr_obj_s *self, char *buf_p); - int (*get_vendor_sn)(struct transvr_obj_s *self, char *buf_p); - int (*get_power_cls)(struct transvr_obj_s *self); - int (*get_br)(struct transvr_obj_s *self); - int (*get_len_sm)(struct transvr_obj_s *self); - int (*get_len_smf)(struct transvr_obj_s *self); - int (*get_len_om1)(struct transvr_obj_s *self); - int (*get_len_om2)(struct transvr_obj_s *self); - int (*get_len_om3)(struct transvr_obj_s *self); - int (*get_len_om4)(struct transvr_obj_s *self); - int (*get_comp_rev)(struct transvr_obj_s *self); - int (*get_comp_eth_1)(struct transvr_obj_s *self); - int (*get_comp_eth_10)(struct transvr_obj_s *self); - int (*get_comp_eth_10_40)(struct transvr_obj_s *self); - int (*get_comp_extend)(struct transvr_obj_s *self); - int (*get_cdr)(struct transvr_obj_s *self); - int (*get_rate_id)(struct transvr_obj_s *self); - int (*get_soft_rs0)(struct transvr_obj_s *self); - int (*get_soft_rs1)(struct transvr_obj_s *self); - int (*get_info)(struct transvr_obj_s *self); - int (*get_if_type)(struct transvr_obj_s *self, char *buf_p); - int (*get_if_speed)(struct transvr_obj_s *self, char *buf_p); - int (*get_if_lane)(struct transvr_obj_s *self, char *buf_p); - int (*get_curr_temp)(struct transvr_obj_s *self, char *buf_p); - int (*get_curr_vol)(struct transvr_obj_s *self, char *buf_p); - int (*get_soft_rx_los)(struct transvr_obj_s *self, char *buf_p); - int (*get_soft_tx_disable)(struct transvr_obj_s *self, char *buf_p); - int (*get_soft_tx_fault)(struct transvr_obj_s *self, char *buf_p); - int (*get_auto_tx_disable)(struct transvr_obj_s *self, char *buf_p); - int (*get_tx_bias)(struct transvr_obj_s *self, char *buf_p); - int (*get_tx_power)(struct transvr_obj_s *self, char *buf_p); - int (*get_rx_power)(struct transvr_obj_s *self, char *buf_p); - int (*get_tx_eq)(struct transvr_obj_s *self, char *buf_p); - int (*get_rx_am)(struct transvr_obj_s *self, char *buf_p); - int (*get_rx_em)(struct transvr_obj_s *self, char *buf_p); - int (*get_wavelength)(struct transvr_obj_s *self, char *buf_p); - int (*get_extphy_offset)(struct transvr_obj_s *self, char *buf_p); - int (*get_extphy_reg)(struct transvr_obj_s *self, char *buf_p); - int (*set_cdr)(struct transvr_obj_s *self, int input_val); - int (*set_soft_rs0)(struct transvr_obj_s *self, int input_val); - int (*set_soft_rs1)(struct transvr_obj_s *self, int input_val); - int (*set_soft_tx_disable)(struct transvr_obj_s *self, int input_val); - int (*set_auto_tx_disable)(struct transvr_obj_s *self, int input_val); - int (*set_tx_eq)(struct transvr_obj_s *self, int input_val); - int (*set_rx_am)(struct transvr_obj_s *self, int input_val); - int (*set_rx_em)(struct transvr_obj_s *self, int input_val); - int (*set_extphy_offset)(struct transvr_obj_s *self, int input_val); - int (*set_extphy_reg)(struct transvr_obj_s *self, int input_val); - - /* ========== Object private functions ========== - */ - int (*init)(struct transvr_obj_s *self); - int (*clean)(struct transvr_obj_s *self); - int (*check)(struct transvr_obj_s *self); - int (*update_all)(struct transvr_obj_s *self, int show_err); - int (*fsm_4_direct)(struct transvr_obj_s* self, char *caller_name); - int (*fsm_4_polling)(struct transvr_obj_s* self, char *caller_name); - int (*send_uevent)(struct transvr_obj_s* self, enum kobject_action u_action); - int (*dump_all)(struct transvr_obj_s* self); -}; - - -/* For AVL Mapping */ -struct transvr_avl_s { - char vendor_name[32]; - char vendor_pn[32]; - int (*init)(struct transvr_obj_s *self); -}; - - -/* Worker for long term task of transceiver */ -struct transvr_worker_s { - /* Task Parameter */ - struct transvr_obj_s *transvr_p; - struct transvr_worker_s *next_p; - struct transvr_worker_s *pre_p; - unsigned long trigger_time; - char func_name[64]; - int retry; - int state; - - /* Task private data */ - void *p_data; - - /* Call back function */ - int (*main_task)(struct transvr_worker_s *task); - int (*post_task)(struct transvr_worker_s *task); -}; - - -struct transvr_obj_s * -create_transvr_obj(char *swp_name, - int chan_id, - struct ioexp_obj_s *ioexp_obj_p, - int ioexp_virt_offset, - int transvr_type, - int chipset_type, - int run_mode); - -void lock_transvr_obj(struct transvr_obj_s *self); -void unlock_transvr_obj(struct transvr_obj_s *self); -int isolate_transvr_obj(struct transvr_obj_s *self); - -int resync_channel_tier_2(struct transvr_obj_s *self); - -void alarm_msg_2_user(struct transvr_obj_s *self, char *emsg); - -#endif /* TRANSCEIVER_H */ - - - - - - - diff --git a/packages/platforms/inventec/x86-64/d5264q28b/onlp/Makefile b/packages/platforms/inventec/x86-64/d5264q28b/onlp/Makefile deleted file mode 100644 index 003238cf6..000000000 --- a/packages/platforms/inventec/x86-64/d5264q28b/onlp/Makefile +++ /dev/null @@ -1 +0,0 @@ -include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/inventec/x86-64/d5264q28b/onlp/PKG.yml b/packages/platforms/inventec/x86-64/d5264q28b/onlp/PKG.yml deleted file mode 100644 index 276a661a8..000000000 --- a/packages/platforms/inventec/x86-64/d5264q28b/onlp/PKG.yml +++ /dev/null @@ -1 +0,0 @@ -!include $ONL_TEMPLATES/onlp-platform-any.yml PLATFORM=x86-64-inventec-d5264q28b ARCH=amd64 TOOLCHAIN=x86_64-linux-gnu diff --git a/packages/platforms/inventec/x86-64/d5264q28b/onlp/builds/Makefile b/packages/platforms/inventec/x86-64/d5264q28b/onlp/builds/Makefile deleted file mode 100644 index e7437cb23..000000000 --- a/packages/platforms/inventec/x86-64/d5264q28b/onlp/builds/Makefile +++ /dev/null @@ -1,2 +0,0 @@ -FILTER=src -include $(ONL)/make/subdirs.mk diff --git a/packages/platforms/inventec/x86-64/d5264q28b/onlp/builds/lib/Makefile b/packages/platforms/inventec/x86-64/d5264q28b/onlp/builds/lib/Makefile deleted file mode 100644 index 22ac1f524..000000000 --- a/packages/platforms/inventec/x86-64/d5264q28b/onlp/builds/lib/Makefile +++ /dev/null @@ -1,2 +0,0 @@ -PLATFORM := x86-64-inventec-d5264q28b -include $(ONL)/packages/base/any/onlp/builds/platform/libonlp-platform.mk diff --git a/packages/platforms/inventec/x86-64/d5264q28b/onlp/builds/onlpdump/Makefile b/packages/platforms/inventec/x86-64/d5264q28b/onlp/builds/onlpdump/Makefile deleted file mode 100644 index a17e2fdc2..000000000 --- a/packages/platforms/inventec/x86-64/d5264q28b/onlp/builds/onlpdump/Makefile +++ /dev/null @@ -1,2 +0,0 @@ -PLATFORM := x86-64-inventec-d5264q28b -include $(ONL)/packages/base/any/onlp/builds/platform/onlps.mk diff --git a/packages/platforms/inventec/x86-64/d5264q28b/onlp/builds/x86_64_inventec_d5264q28b/.module b/packages/platforms/inventec/x86-64/d5264q28b/onlp/builds/x86_64_inventec_d5264q28b/.module deleted file mode 100644 index d283bbf27..000000000 --- a/packages/platforms/inventec/x86-64/d5264q28b/onlp/builds/x86_64_inventec_d5264q28b/.module +++ /dev/null @@ -1 +0,0 @@ -name: x86_64_inventec_d5264q28b diff --git a/packages/platforms/inventec/x86-64/d5264q28b/onlp/builds/x86_64_inventec_d5264q28b/Makefile b/packages/platforms/inventec/x86-64/d5264q28b/onlp/builds/x86_64_inventec_d5264q28b/Makefile deleted file mode 100644 index 8725c6907..000000000 --- a/packages/platforms/inventec/x86-64/d5264q28b/onlp/builds/x86_64_inventec_d5264q28b/Makefile +++ /dev/null @@ -1,9 +0,0 @@ -############################################################################### -# -# -# -############################################################################### -include $(ONL)/make/config.mk -MODULE := x86_64_inventec_d5264q28b -AUTOMODULE := x86_64_inventec_d5264q28b -include $(BUILDER)/definemodule.mk diff --git a/packages/platforms/inventec/x86-64/d5264q28b/onlp/builds/x86_64_inventec_d5264q28b/module/auto/make.mk b/packages/platforms/inventec/x86-64/d5264q28b/onlp/builds/x86_64_inventec_d5264q28b/module/auto/make.mk deleted file mode 100644 index 53e27c6be..000000000 --- a/packages/platforms/inventec/x86-64/d5264q28b/onlp/builds/x86_64_inventec_d5264q28b/module/auto/make.mk +++ /dev/null @@ -1,9 +0,0 @@ -############################################################################### -# -# x86_64_inventec_d5264q28b Autogeneration -# -############################################################################### -x86_64_inventec_d5264q28b_AUTO_DEFS := module/auto/x86_64_inventec_d5264q28b.yml -x86_64_inventec_d5264q28b_AUTO_DIRS := module/inc/x86_64_inventec_d5264q28b module/src -include $(BUILDER)/auto.mk - diff --git a/packages/platforms/inventec/x86-64/d5264q28b/onlp/builds/x86_64_inventec_d5264q28b/module/auto/x86_64_inventec_d5264q28b.yml b/packages/platforms/inventec/x86-64/d5264q28b/onlp/builds/x86_64_inventec_d5264q28b/module/auto/x86_64_inventec_d5264q28b.yml deleted file mode 100644 index 44ce7a979..000000000 --- a/packages/platforms/inventec/x86-64/d5264q28b/onlp/builds/x86_64_inventec_d5264q28b/module/auto/x86_64_inventec_d5264q28b.yml +++ /dev/null @@ -1,50 +0,0 @@ -############################################################################### -# -# x86_64_inventec_d5264q28b Autogeneration Definitions. -# -############################################################################### - -cdefs: &cdefs -- X86_64_INVENTEC_D5264Q28B_CONFIG_INCLUDE_LOGGING: - doc: "Include or exclude logging." - default: 1 -- X86_64_INVENTEC_D5264Q28B_CONFIG_LOG_OPTIONS_DEFAULT: - doc: "Default enabled log options." - default: AIM_LOG_OPTIONS_DEFAULT -- X86_64_INVENTEC_D5264Q28B_CONFIG_LOG_BITS_DEFAULT: - doc: "Default enabled log bits." - default: AIM_LOG_BITS_DEFAULT -- X86_64_INVENTEC_D5264Q28B_CONFIG_LOG_CUSTOM_BITS_DEFAULT: - doc: "Default enabled custom log bits." - default: 0 -- X86_64_INVENTEC_D5264Q28B_CONFIG_PORTING_STDLIB: - doc: "Default all porting macros to use the C standard libraries." - default: 1 -- X86_64_INVENTEC_D5264Q28B_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS: - doc: "Include standard library headers for stdlib porting macros." - default: X86_64_INVENTEC_D5264Q28B_CONFIG_PORTING_STDLIB -- X86_64_INVENTEC_D5264Q28B_CONFIG_INCLUDE_UCLI: - doc: "Include generic uCli support." - default: 0 -- X86_64_INVENTEC_D5264Q28B_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_D5264Q28B_CONFIG_HEADER: - defs: *cdefs - basename: x86_64_inventec_d5264q28b_config - - portingmacro: - x86_64_inventec_d5264q28b: - macros: - - malloc - - free - - memset - - memcpy - - - vsnprintf - - snprintf - - strlen diff --git a/packages/platforms/inventec/x86-64/d5264q28b/onlp/builds/x86_64_inventec_d5264q28b/module/inc/x86_64_inventec_d5264q28b/x86_64_inventec_d5264q28b.x b/packages/platforms/inventec/x86-64/d5264q28b/onlp/builds/x86_64_inventec_d5264q28b/module/inc/x86_64_inventec_d5264q28b/x86_64_inventec_d5264q28b.x deleted file mode 100644 index a75d62414..000000000 --- a/packages/platforms/inventec/x86-64/d5264q28b/onlp/builds/x86_64_inventec_d5264q28b/module/inc/x86_64_inventec_d5264q28b/x86_64_inventec_d5264q28b.x +++ /dev/null @@ -1,14 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#include - -/* <--auto.start.xmacro(ALL).define> */ -/* */ - -/* <--auto.start.xenum(ALL).define> */ -/* */ - - diff --git a/packages/platforms/inventec/x86-64/d5264q28b/onlp/builds/x86_64_inventec_d5264q28b/module/inc/x86_64_inventec_d5264q28b/x86_64_inventec_d5264q28b_config.h b/packages/platforms/inventec/x86-64/d5264q28b/onlp/builds/x86_64_inventec_d5264q28b/module/inc/x86_64_inventec_d5264q28b/x86_64_inventec_d5264q28b_config.h deleted file mode 100644 index 4a856282f..000000000 --- a/packages/platforms/inventec/x86-64/d5264q28b/onlp/builds/x86_64_inventec_d5264q28b/module/inc/x86_64_inventec_d5264q28b/x86_64_inventec_d5264q28b_config.h +++ /dev/null @@ -1,137 +0,0 @@ -/**************************************************************************//** - * - * @file - * @brief x86_64_inventec_d5264q28b Configuration Header - * - * @addtogroup x86_64_inventec_d5264q28b-config - * @{ - * - *****************************************************************************/ -#ifndef __X86_64_INVENTEC_D5264Q28B_CONFIG_H__ -#define __X86_64_INVENTEC_D5264Q28B_CONFIG_H__ - -#ifdef GLOBAL_INCLUDE_CUSTOM_CONFIG -#include -#endif -#ifdef x86_64_inventec_d5264q28b_INCLUDE_CUSTOM_CONFIG -#include -#endif - -/* */ -#include -/** - * X86_64_INVENTEC_D5264Q28B_CONFIG_INCLUDE_LOGGING - * - * Include or exclude logging. */ - - -#ifndef X86_64_INVENTEC_D5264Q28B_CONFIG_INCLUDE_LOGGING -#define X86_64_INVENTEC_D5264Q28B_CONFIG_INCLUDE_LOGGING 1 -#endif - -/** - * X86_64_INVENTEC_D5264Q28B_CONFIG_LOG_OPTIONS_DEFAULT - * - * Default enabled log options. */ - - -#ifndef X86_64_INVENTEC_D5264Q28B_CONFIG_LOG_OPTIONS_DEFAULT -#define X86_64_INVENTEC_D5264Q28B_CONFIG_LOG_OPTIONS_DEFAULT AIM_LOG_OPTIONS_DEFAULT -#endif - -/** - * X86_64_INVENTEC_D5264Q28B_CONFIG_LOG_BITS_DEFAULT - * - * Default enabled log bits. */ - - -#ifndef X86_64_INVENTEC_D5264Q28B_CONFIG_LOG_BITS_DEFAULT -#define X86_64_INVENTEC_D5264Q28B_CONFIG_LOG_BITS_DEFAULT AIM_LOG_BITS_DEFAULT -#endif - -/** - * X86_64_INVENTEC_D5264Q28B_CONFIG_LOG_CUSTOM_BITS_DEFAULT - * - * Default enabled custom log bits. */ - - -#ifndef X86_64_INVENTEC_D5264Q28B_CONFIG_LOG_CUSTOM_BITS_DEFAULT -#define X86_64_INVENTEC_D5264Q28B_CONFIG_LOG_CUSTOM_BITS_DEFAULT 0 -#endif - -/** - * X86_64_INVENTEC_D5264Q28B_CONFIG_PORTING_STDLIB - * - * Default all porting macros to use the C standard libraries. */ - - -#ifndef X86_64_INVENTEC_D5264Q28B_CONFIG_PORTING_STDLIB -#define X86_64_INVENTEC_D5264Q28B_CONFIG_PORTING_STDLIB 1 -#endif - -/** - * X86_64_INVENTEC_D5264Q28B_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS - * - * Include standard library headers for stdlib porting macros. */ - - -#ifndef X86_64_INVENTEC_D5264Q28B_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS -#define X86_64_INVENTEC_D5264Q28B_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS X86_64_INVENTEC_D5264Q28B_CONFIG_PORTING_STDLIB -#endif - -/** - * X86_64_INVENTEC_D5264Q28B_CONFIG_INCLUDE_UCLI - * - * Include generic uCli support. */ - - -#ifndef X86_64_INVENTEC_D5264Q28B_CONFIG_INCLUDE_UCLI -#define X86_64_INVENTEC_D5264Q28B_CONFIG_INCLUDE_UCLI 0 -#endif - -/** - * X86_64_INVENTEC_D5264Q28B_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION - * - * Assume chassis fan direction is the same as the PSU fan direction. */ - - -#ifndef X86_64_INVENTEC_D5264Q28B_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION -#define X86_64_INVENTEC_D5264Q28B_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION 0 -#endif - - - -/** - * All compile time options can be queried or displayed - */ - -/** Configuration settings structure. */ -typedef struct x86_64_inventec_d5264q28b_config_settings_s { - /** name */ - const char* name; - /** value */ - const char* value; -} x86_64_inventec_d5264q28b_config_settings_t; - -/** Configuration settings table. */ -/** x86_64_inventec_d5264q28b_config_settings table. */ -extern x86_64_inventec_d5264q28b_config_settings_t x86_64_inventec_d5264q28b_config_settings[]; - -/** - * @brief Lookup a configuration setting. - * @param setting The name of the configuration option to lookup. - */ -const char* x86_64_inventec_d5264q28b_config_lookup(const char* setting); - -/** - * @brief Show the compile-time configuration. - * @param pvs The output stream. - */ -int x86_64_inventec_d5264q28b_config_show(struct aim_pvs_s* pvs); - -/* */ - -#include "x86_64_inventec_d5264q28b_porting.h" - -#endif /* __X86_64_INVENTEC_D5264Q28B_CONFIG_H__ */ -/* @} */ diff --git a/packages/platforms/inventec/x86-64/d5264q28b/onlp/builds/x86_64_inventec_d5264q28b/module/inc/x86_64_inventec_d5264q28b/x86_64_inventec_d5264q28b_dox.h b/packages/platforms/inventec/x86-64/d5264q28b/onlp/builds/x86_64_inventec_d5264q28b/module/inc/x86_64_inventec_d5264q28b/x86_64_inventec_d5264q28b_dox.h deleted file mode 100644 index 3d96784d6..000000000 --- a/packages/platforms/inventec/x86-64/d5264q28b/onlp/builds/x86_64_inventec_d5264q28b/module/inc/x86_64_inventec_d5264q28b/x86_64_inventec_d5264q28b_dox.h +++ /dev/null @@ -1,26 +0,0 @@ -/**************************************************************************//** - * - * x86_64_inventec_d5264q28b Doxygen Header - * - *****************************************************************************/ -#ifndef __x86_64_inventec_d5264q28b_DOX_H__ -#define __x86_64_inventec_d5264q28b_DOX_H__ - -/** - * @defgroup x86_64_inventec_d5264q28b x86_64_inventec_d5264q28b - x86_64_inventec_d5264q28b Description - * - -The documentation overview for this module should go here. - - * - * @{ - * - * @defgroup x86_64_inventec_d5264q28b-x86_64_inventec_d5264q28b Public Interface - * @defgroup x86_64_inventec_d5264q28b-config Compile Time Configuration - * @defgroup x86_64_inventec_d5264q28b-porting Porting Macros - * - * @} - * - */ - -#endif /* __x86_64_inventec_d5264q28b_DOX_H__ */ diff --git a/packages/platforms/inventec/x86-64/d5264q28b/onlp/builds/x86_64_inventec_d5264q28b/module/inc/x86_64_inventec_d5264q28b/x86_64_inventec_d5264q28b_porting.h b/packages/platforms/inventec/x86-64/d5264q28b/onlp/builds/x86_64_inventec_d5264q28b/module/inc/x86_64_inventec_d5264q28b/x86_64_inventec_d5264q28b_porting.h deleted file mode 100644 index 3d250233a..000000000 --- a/packages/platforms/inventec/x86-64/d5264q28b/onlp/builds/x86_64_inventec_d5264q28b/module/inc/x86_64_inventec_d5264q28b/x86_64_inventec_d5264q28b_porting.h +++ /dev/null @@ -1,97 +0,0 @@ -/**************************************************************************//** - * - * @file - * @brief x86_64_inventec_d5264q28b Porting Macros. - * - * @addtogroup x86_64_inventec_d5264q28b-porting - * @{ - * - *****************************************************************************/ -#ifndef __x86_64_inventec_d5264q28b_PORTING_H__ -#define __x86_64_inventec_d5264q28b_PORTING_H__ - - -/* */ -#if X86_64_INVENTEC_D5264Q28B_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS == 1 -#include -#include -#include -#include -#include -#endif - -#ifndef X86_64_INVENTEC_D5264Q28B_MALLOC - #if defined(GLOBAL_MALLOC) - #define X86_64_INVENTEC_D5264Q28B_MALLOC GLOBAL_MALLOC - #elif X86_64_INVENTEC_D5264Q28B_CONFIG_PORTING_STDLIB == 1 - #define X86_64_INVENTEC_D5264Q28B_MALLOC malloc - #else - #error The macro X86_64_INVENTEC_D5264Q28B_MALLOC is required but cannot be defined. - #endif -#endif - -#ifndef X86_64_INVENTEC_D5264Q28B_FREE - #if defined(GLOBAL_FREE) - #define X86_64_INVENTEC_D5264Q28B_FREE GLOBAL_FREE - #elif X86_64_INVENTEC_D5264Q28B_CONFIG_PORTING_STDLIB == 1 - #define X86_64_INVENTEC_D5264Q28B_FREE free - #else - #error The macro X86_64_INVENTEC_D5264Q28B_FREE is required but cannot be defined. - #endif -#endif - -#ifndef X86_64_INVENTEC_D5264Q28B_MEMSET - #if defined(GLOBAL_MEMSET) - #define X86_64_INVENTEC_D5264Q28B_MEMSET GLOBAL_MEMSET - #elif X86_64_INVENTEC_D5264Q28B_CONFIG_PORTING_STDLIB == 1 - #define X86_64_INVENTEC_D5264Q28B_MEMSET memset - #else - #error The macro X86_64_INVENTEC_D5264Q28B_MEMSET is required but cannot be defined. - #endif -#endif - -#ifndef X86_64_INVENTEC_D5264Q28B_MEMCPY - #if defined(GLOBAL_MEMCPY) - #define X86_64_INVENTEC_D5264Q28B_MEMCPY GLOBAL_MEMCPY - #elif X86_64_INVENTEC_D5264Q28B_CONFIG_PORTING_STDLIB == 1 - #define X86_64_INVENTEC_D5264Q28B_MEMCPY memcpy - #else - #error The macro X86_64_INVENTEC_D5264Q28B_MEMCPY is required but cannot be defined. - #endif -#endif - -#ifndef X86_64_INVENTEC_D5264Q28B_VSNPRINTF - #if defined(GLOBAL_VSNPRINTF) - #define X86_64_INVENTEC_D5264Q28B_VSNPRINTF GLOBAL_VSNPRINTF - #elif X86_64_INVENTEC_D5264Q28B_CONFIG_PORTING_STDLIB == 1 - #define X86_64_INVENTEC_D5264Q28B_VSNPRINTF vsnprintf - #else - #error The macro X86_64_INVENTEC_D5264Q28B_VSNPRINTF is required but cannot be defined. - #endif -#endif - -#ifndef X86_64_INVENTEC_D5264Q28B_SNPRINTF - #if defined(GLOBAL_SNPRINTF) - #define X86_64_INVENTEC_D5264Q28B_SNPRINTF GLOBAL_SNPRINTF - #elif X86_64_INVENTEC_D5264Q28B_CONFIG_PORTING_STDLIB == 1 - #define X86_64_INVENTEC_D5264Q28B_SNPRINTF snprintf - #else - #error The macro X86_64_INVENTEC_D5264Q28B_SNPRINTF is required but cannot be defined. - #endif -#endif - -#ifndef X86_64_INVENTEC_D5264Q28B_STRLEN - #if defined(GLOBAL_STRLEN) - #define X86_64_INVENTEC_D5264Q28B_STRLEN GLOBAL_STRLEN - #elif X86_64_INVENTEC_D5264Q28B_CONFIG_PORTING_STDLIB == 1 - #define X86_64_INVENTEC_D5264Q28B_STRLEN strlen - #else - #error The macro X86_64_INVENTEC_D5264Q28B_STRLEN is required but cannot be defined. - #endif -#endif - -/* */ - - -#endif /* __x86_64_inventec_d5264q28b_PORTING_H__ */ -/* @} */ diff --git a/packages/platforms/inventec/x86-64/d5264q28b/onlp/builds/x86_64_inventec_d5264q28b/module/make.mk b/packages/platforms/inventec/x86-64/d5264q28b/onlp/builds/x86_64_inventec_d5264q28b/module/make.mk deleted file mode 100644 index 0e61aab49..000000000 --- a/packages/platforms/inventec/x86-64/d5264q28b/onlp/builds/x86_64_inventec_d5264q28b/module/make.mk +++ /dev/null @@ -1,10 +0,0 @@ -############################################################################### -# -# -# -############################################################################### -THIS_DIR := $(dir $(lastword $(MAKEFILE_LIST))) -x86_64_inventec_d5264q28b_INCLUDES := -I $(THIS_DIR)inc -x86_64_inventec_d5264q28b_INTERNAL_INCLUDES := -I $(THIS_DIR)src -x86_64_inventec_d5264q28b_DEPENDMODULE_ENTRIES := init:x86_64_inventec_d5264q28b ucli:x86_64_inventec_d5264q28b -x86_64_inventec_d5264q28b_CFLAGS := -Wno-restrict -Wno-format-truncation diff --git a/packages/platforms/inventec/x86-64/d5264q28b/onlp/builds/x86_64_inventec_d5264q28b/module/src/Makefile b/packages/platforms/inventec/x86-64/d5264q28b/onlp/builds/x86_64_inventec_d5264q28b/module/src/Makefile deleted file mode 100644 index 2614feee3..000000000 --- a/packages/platforms/inventec/x86-64/d5264q28b/onlp/builds/x86_64_inventec_d5264q28b/module/src/Makefile +++ /dev/null @@ -1,9 +0,0 @@ -############################################################################### -# -# Local source generation targets. -# -############################################################################### - -ucli: - @../../../../tools/uclihandlers.py x86_64_inventec_d5264q28b_ucli.c - diff --git a/packages/platforms/inventec/x86-64/d5264q28b/onlp/builds/x86_64_inventec_d5264q28b/module/src/debug.c b/packages/platforms/inventec/x86-64/d5264q28b/onlp/builds/x86_64_inventec_d5264q28b/module/src/debug.c deleted file mode 100644 index bc551ffc0..000000000 --- a/packages/platforms/inventec/x86-64/d5264q28b/onlp/builds/x86_64_inventec_d5264q28b/module/src/debug.c +++ /dev/null @@ -1,45 +0,0 @@ -#include "x86_64_inventec_d5264q28b_int.h" - -#if X86_64_INVENTEC_D5264Q28B_CONFIG_INCLUDE_DEBUG == 1 - -#include - -static char help__[] = - "Usage: debug [options]\n" - " -c CPLD Versions\n" - " -h Help\n" - ; - -int -x86_64_inventec_d5264q28b_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/d5264q28b/onlp/builds/x86_64_inventec_d5264q28b/module/src/fani.c b/packages/platforms/inventec/x86-64/d5264q28b/onlp/builds/x86_64_inventec_d5264q28b/module/src/fani.c deleted file mode 100644 index bc6a0bbd2..000000000 --- a/packages/platforms/inventec/x86-64/d5264q28b/onlp/builds/x86_64_inventec_d5264q28b/module/src/fani.c +++ /dev/null @@ -1,398 +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 -#include -#include -#include -#include "platform_lib.h" - -#define VALIDATE(_id) \ - do { \ - if(!ONLP_OID_IS_FAN(_id)) { \ - return ONLP_STATUS_E_INVALID; \ - } \ - } while(0) - - -#define SLOW_PWM 100 -#define NORMAL_PWM 175 -#define MAX_PWM 255 -#define STEP_SIZE 100 -#define FAN_ON_MAIN_BOARD_COUNT 4 -#define LOCAL_ID_TO_PSU_ID(id) (id-FAN_ON_MAIN_BOARD_COUNT) - -#define FAN_CAPS ONLP_FAN_CAPS_GET_RPM|ONLP_FAN_CAPS_GET_PERCENTAGE - -static int _fani_status_failed_check(uint32_t* status, int local_id); -static int _fani_status_present_check(uint32_t* status, int local_id); - -#define MAKE_FAN_INFO_NODE_ON_FAN_BOARD(id) \ - { \ - { \ - ONLP_FAN_ID_CREATE(ONLP_FAN_##id), "Fan "#id, 0, \ - { \ - ONLP_LED_ID_CREATE(ONLP_LED_FAN##id), \ - } \ - }, \ - 0, 0 \ - } - -#define MAKE_FAN_INFO_NODE_ON_PSU(psu_id) \ - { \ - { ONLP_FAN_ID_CREATE(ONLP_FAN_PSU_##psu_id), "PSU-"#psu_id" Fan", ONLP_PSU_ID_CREATE(ONLP_PSU_##psu_id)}, \ - 0, 0 \ - } - - -/* Static values */ -static onlp_fan_info_t __onlp_fan_info[ONLP_FAN_COUNT] = { - 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_PSU(1), - MAKE_FAN_INFO_NODE_ON_PSU(2), -}; - - -/* - * 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 rv = ONLP_STATUS_OK; - int local_id; - int lrpm, rrpm, pwm, psu_id; - VALIDATE(id); - pwm = 0; - - local_id = ONLP_OID_ID_GET(id); - if(local_id >= ONLP_FAN_MAX) { - rv = ONLP_STATUS_E_INVALID; - } - if(rv ==ONLP_STATUS_OK) { - *info = __onlp_fan_info[LOCAL_ID_TO_INFO_IDX(local_id)]; - rv = onlp_fani_status_get(id, &info->status); - } - - if(rv == ONLP_STATUS_OK) { - if(info->status & ONLP_FAN_STATUS_PRESENT){ - switch(local_id){ - case ONLP_FAN_1: - case ONLP_FAN_2: - case ONLP_FAN_3: - case ONLP_FAN_4: - if(info->status & ONLP_FAN_STATUS_F2B){ - info->caps = FAN_CAPS|ONLP_FAN_CAPS_F2B; - }else if(info->status & ONLP_FAN_STATUS_B2F){ - info->caps = FAN_CAPS|ONLP_FAN_CAPS_B2F; - }else{ - info->caps = FAN_CAPS; - } - - rv = onlp_file_read_int(&lrpm, INV_HWMON_PREFIX"fan%d_input", local_id*2-1); - if(rv != ONLP_STATUS_OK ){ return rv; } - rv = onlp_file_read_int(&rrpm, INV_HWMON_PREFIX"fan%d_input", local_id*2); - if(rv != ONLP_STATUS_OK ){ return rv; } - rv = onlp_file_read_int(&pwm,INV_HWMON_PREFIX"pwm%d", local_id); - if(rv != ONLP_STATUS_OK ){ return rv; } - - if(lrpm <=0 && rrpm <=0){ - info->rpm = 0; - }else if(lrpm <= 0){ - info->rpm = rrpm; - }else if(rrpm <= 0){ - info->rpm = lrpm; - }else{ - info->rpm = (lrpm+rrpm)/2; - } - - break; - case ONLP_FAN_PSU_1: - case ONLP_FAN_PSU_2: - info->caps = FAN_CAPS|ONLP_FAN_CAPS_F2B; - psu_id = LOCAL_ID_TO_PSU_ID(local_id); - rv = onlp_file_read_int(&info->rpm,INV_HWMON_PREFIX"rpm_psu%d", psu_id); - if(rv != ONLP_STATUS_OK) { return rv; } - rv = onlp_file_read_int(&pwm, INV_HWMON_PREFIX"pwm_psu%d", psu_id); - if(rv != ONLP_STATUS_OK) { return rv; } - break; - default: - rv = ONLP_STATUS_E_INVALID; - break; - } - if(rv == ONLP_STATUS_OK) { - if(info->rpm <= 0) { - info->mode = ONLP_FAN_MODE_OFF; - info->percentage = 0; - } else { - info->percentage = (pwm*100)/MAX_PWM; - if(pwm < SLOW_PWM) { - info->mode = ONLP_FAN_MODE_SLOW; - } else if(pwm < NORMAL_PWM) { - info->mode = ONLP_FAN_MODE_NORMAL; - } else if(pwm < MAX_PWM) { - info->mode = ONLP_FAN_MODE_FAST; - } else { - info->mode = ONLP_FAN_MODE_MAX; - } - } - } - }else{ - info->caps = 0; - info->rpm = 0; - info->percentage = 0; - info->mode = ONLP_FAN_MODE_OFF; - } - snprintf(info->model, ONLP_CONFIG_INFO_STR_MAX, "NA"); - snprintf(info->serial, ONLP_CONFIG_INFO_STR_MAX, "NA"); - } - return rv; -} -static int _fani_status_failed_check(uint32_t* status, int local_id) -{ - int rv; - int lrpm, rrpm, rpm, pwm, psu_id; - switch(local_id){ - case ONLP_FAN_1: - case ONLP_FAN_2: - case ONLP_FAN_3: - case ONLP_FAN_4: - rv = onlp_file_read_int(&lrpm, INV_HWMON_PREFIX"fan%d_input", local_id*2-1); - if(rv != ONLP_STATUS_OK ){ return rv; } - rv = onlp_file_read_int(&rrpm, INV_HWMON_PREFIX"fan%d_input", local_id*2); - if(rv != ONLP_STATUS_OK ){ return rv; } - rv = onlp_file_read_int(&pwm,INV_HWMON_PREFIX"pwm%d", local_id); - if(rv != ONLP_STATUS_OK ){ return rv; } - - if( lrpm <= 0 || rrpm <=0 || pwm <=0 || pwm > MAX_PWM){ - *status |= ONLP_FAN_STATUS_FAILED; - *status &= (~ONLP_FAN_STATUS_B2F); - *status &= (~ONLP_FAN_STATUS_F2B); - }else{ - *status &= (~ONLP_FAN_STATUS_FAILED); - } - break; - case ONLP_FAN_PSU_1: - case ONLP_FAN_PSU_2: - psu_id = LOCAL_ID_TO_PSU_ID(local_id); - rv = onlp_file_read_int(&rpm, INV_HWMON_PREFIX"rpm_psu%d", psu_id); - if(rv != ONLP_STATUS_OK ){ return rv; } - rv = onlp_file_read_int(&pwm, INV_HWMON_PREFIX"pwm_psu%d", psu_id); - if(rv != ONLP_STATUS_OK ){ return rv; } - - if( rpm <= 0 || pwm <=0 || pwm > MAX_PWM){ - *status |= ONLP_FAN_STATUS_FAILED; - *status &= (~ONLP_FAN_STATUS_B2F); - *status &= (~ONLP_FAN_STATUS_F2B); - }else{ - *status &= (~ONLP_FAN_STATUS_FAILED); - } - break; - default: - rv = ONLP_STATUS_E_INVALID; - break; - } - return rv; -} - -static int _fani_status_present_check(uint32_t* status, int local_id) -{ - int rv; - int gpi; - int info_idx; - int len; - char buf[ONLP_CONFIG_INFO_STR_MAX]; - info_idx = LOCAL_ID_TO_INFO_IDX(local_id); - rv = onlp_file_read((uint8_t*)buf,ONLP_CONFIG_INFO_STR_MAX, &len, INV_HWMON_PREFIX"fan_gpi"); - if( rv == ONLP_STATUS_OK ){ - sscanf( buf, "0x%x\n", &gpi); - /* B[0-3] installed(0)/uninstalled(1) - B[4-7] FRtype(0)/RFtype(1) */ - if (!((gpi>>info_idx) & 1)){ - *status |= ONLP_FAN_STATUS_PRESENT; - if (!((gpi>>(info_idx+4)) & 1)){ - *status |= ONLP_FAN_STATUS_F2B; - }else{ - *status |= ONLP_FAN_STATUS_B2F; - } - } else { - *status = 0; - } - } - return rv; -} - - -/** - * @brief Retrieve the fan's operational status. - * @param id The fan OID. - * @param rv [out] Receives the fan's operations status flags. - * @notes Only operational state needs to be returned - - * PRESENT/FAILED - */ -int onlp_fani_status_get(onlp_oid_t id, uint32_t* rv) -{ - int result = ONLP_STATUS_OK; - onlp_fan_info_t* info; - int local_id; - VALIDATE(id); - uint32_t psu_status; - - local_id = ONLP_OID_ID_GET(id); - if(local_id >= ONLP_FAN_MAX) { - result = ONLP_STATUS_E_INVALID; - } else { - info = &__onlp_fan_info[LOCAL_ID_TO_INFO_IDX(local_id)]; - switch(local_id){ - case ONLP_FAN_1: - case ONLP_FAN_2: - case ONLP_FAN_3: - case ONLP_FAN_4: - result = _fani_status_present_check(&info->status, local_id); - if (result == ONLP_STATUS_OK ){ - if (info->status & ONLP_FAN_STATUS_PRESENT){ - result = _fani_status_failed_check(&info->status, local_id); - } - } - break; - case ONLP_FAN_PSU_1: - case ONLP_FAN_PSU_2: - result = onlp_psui_status_get((&info->hdr)->poid, &psu_status); - if(result != ONLP_STATUS_OK){ return result; } - - if(psu_status & ONLP_PSU_STATUS_PRESENT){ - info->status |= ONLP_FAN_STATUS_PRESENT; - result = _fani_status_failed_check(&info->status, local_id); - }else{ - info->status = 0; - } - break; - default: - result = ONLP_STATUS_E_INVALID; - break; - } - *rv = info->status; - } - return result; -} - -/** - * @brief Retrieve the fan's OID hdr. - * @param id The fan OID. - * @param rv [out] Receives the OID header. - */ -int onlp_fani_hdr_get(onlp_oid_t id, onlp_oid_hdr_t* hdr) -{ - int result = ONLP_STATUS_OK; - onlp_fan_info_t* info; - int local_id; - VALIDATE(id); - - local_id = ONLP_OID_ID_GET(id); - if(local_id >= ONLP_FAN_MAX) { - result = ONLP_STATUS_E_INVALID; - } else { - info = &__onlp_fan_info[LOCAL_ID_TO_INFO_IDX(local_id)]; - *hdr = info->hdr; - } - return result; -} - - -/* - * 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) -{ - return ONLP_STATUS_E_UNSUPPORTED; -} - - -/* - * 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/d5264q28b/onlp/builds/x86_64_inventec_d5264q28b/module/src/ledi.c b/packages/platforms/inventec/x86-64/d5264q28b/onlp/builds/x86_64_inventec_d5264q28b/module/src/ledi.c deleted file mode 100644 index bda4629c0..000000000 --- a/packages/platforms/inventec/x86-64/d5264q28b/onlp/builds/x86_64_inventec_d5264q28b/module/src/ledi.c +++ /dev/null @@ -1,441 +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 "platform_lib.h" - -#define VALIDATE(_id) \ - do { \ - if(!ONLP_OID_IS_LED(_id)) { \ - return ONLP_STATUS_E_INVALID; \ - } \ - } while(0) - -/* LED related data - */ - -/* CAPS*/ -#define SYS_LED_CAPS ONLP_LED_CAPS_ON_OFF|ONLP_LED_CAPS_GREEN|ONLP_LED_CAPS_GREEN_BLINKING|ONLP_LED_CAPS_RED|ONLP_LED_CAPS_RED_BLINKING -#define FAN_LED_CAPS ONLP_LED_CAPS_RED|ONLP_LED_CAPS_GREEN - -#define LOCAL_ID_TO_FAN_ID(id) (id-1) - -typedef enum sys_led_mode_e { - SYS_LED_MODE_OFF = 0, - SYS_LED_MODE_0_5_HZ = 1, - SYS_LED_MODE_1_HZ = 2, - SYS_LED_MODE_2_HZ = 3, - SYS_LED_MODE_ON = 7 -} sys_led_mode_t; - -/* function declarations*/ -static int _sys_onlp_led_mode_convert(sys_led_mode_t grn_mode, sys_led_mode_t red_mode, onlp_led_mode_t* pmode); -static int _sys_onlp_ledi_info_get(onlp_oid_t id, onlp_led_info_t* info); -static int _fan_onlp_ledi_info_get(onlp_oid_t id, onlp_led_info_t* info); -static int _sys_onlp_ledi_mode_set(onlp_led_mode_t onlp_mode); - -/* - * Get the information for the given LED OID. - */ -#define MAKE_MGMT_LED_INFO_NODE \ - { \ - { ONLP_LED_ID_CREATE(ONLP_LED_MGMT), "MGMT LED" , 0 }, \ - ONLP_LED_STATUS_PRESENT, \ - SYS_LED_CAPS, \ - } - -#define MAKE_LED_INFO_NODE_ON_FAN(fan_id) \ - { \ - { ONLP_LED_ID_CREATE(ONLP_LED_FAN##fan_id), \ - "FAN LED "#fan_id, \ - ONLP_FAN_ID_CREATE(ONLP_FAN_##fan_id) \ - }, \ - 0, \ - 0, \ - } - -static onlp_led_info_t __onlp_led_info[ONLP_LED_COUNT] = { - MAKE_MGMT_LED_INFO_NODE, - MAKE_LED_INFO_NODE_ON_FAN(1), - MAKE_LED_INFO_NODE_ON_FAN(2), - MAKE_LED_INFO_NODE_ON_FAN(3), - MAKE_LED_INFO_NODE_ON_FAN(4), -}; - - - -/* convert platform led type to onlp_led_mode type*/ -static int _sys_onlp_led_mode_convert(sys_led_mode_t grn_mode, sys_led_mode_t red_mode, onlp_led_mode_t* pmode) -{ - int rv = ONLP_STATUS_OK; - *pmode = ONLP_LED_MODE_OFF; - - switch(grn_mode) { - case SYS_LED_MODE_0_5_HZ: - case SYS_LED_MODE_1_HZ: - case SYS_LED_MODE_2_HZ: - *pmode = ONLP_LED_MODE_GREEN_BLINKING; - break; - case SYS_LED_MODE_ON: - *pmode = ONLP_LED_MODE_GREEN; - break; - case SYS_LED_MODE_OFF: - *pmode = ONLP_LED_MODE_OFF; - break; - default: - return ONLP_STATUS_E_INVALID; - break; - } - switch(red_mode) { - case SYS_LED_MODE_0_5_HZ: - case SYS_LED_MODE_1_HZ: - case SYS_LED_MODE_2_HZ: - if(grn_mode == SYS_LED_MODE_OFF){ - *pmode = ONLP_LED_MODE_RED_BLINKING; - }else{ - return ONLP_STATUS_E_INVALID; - } - break; - case SYS_LED_MODE_ON: - if(grn_mode == SYS_LED_MODE_OFF){ - *pmode = ONLP_LED_MODE_RED; - }else{ - return ONLP_STATUS_E_INVALID; - } - break; - case SYS_LED_MODE_OFF: - if(grn_mode == SYS_LED_MODE_OFF){ - *pmode = ONLP_LED_MODE_OFF; - } - break; - default: - return ONLP_STATUS_E_INVALID; - break; - } - return rv; -} - - -static int _sys_onlp_ledi_info_get(onlp_oid_t id, onlp_led_info_t* info) -{ - int local_id; - int rv = ONLP_STATUS_OK; - sys_led_mode_t grn_mode, red_mode; - local_id = ONLP_OID_ID_GET(id); - int idx = LOCAL_ID_TO_INFO_IDX(local_id); - /* Set the onlp_oid_hdr_t and capabilities */ - *info = __onlp_led_info[idx]; - - rv = onlp_file_read_int((int*)&grn_mode, INV_SYSLED_PREFIX"grn_led"); - if(rv != ONLP_STATUS_OK){ return rv; } - rv = onlp_file_read_int((int*)&red_mode, INV_SYSLED_PREFIX"red_led"); - if(rv != ONLP_STATUS_OK){ return rv; } - - rv = _sys_onlp_led_mode_convert(grn_mode, red_mode, &info->mode); - if(rv != ONLP_STATUS_OK){ return rv; } - - /* Set the on/off status */ - if (info->mode != ONLP_LED_MODE_OFF) { - info->status |= ONLP_LED_STATUS_ON; - } else { - info->status &= (~ONLP_LED_STATUS_ON); - } - - - return rv; -} - -static int _fan_onlp_ledi_info_get(onlp_oid_t id, onlp_led_info_t* info) -{ - int local_id; - int rv = ONLP_STATUS_OK; - int grn_mode, red_mode; - - local_id = ONLP_OID_ID_GET(id); - int fan_id = LOCAL_ID_TO_FAN_ID(local_id); - int idx = LOCAL_ID_TO_INFO_IDX(local_id); - /* Set the onlp_oid_hdr_t and capabilities */ - *info = __onlp_led_info[idx]; - - rv = onlp_ledi_status_get(id, &info->status); - if( rv != ONLP_STATUS_OK ){ return rv; } - - if( info->status & ONLP_LED_STATUS_PRESENT){ - info->caps = FAN_LED_CAPS; - rv = onlp_file_read_int((int*)&grn_mode, INV_HWMON_PREFIX"fan_led_grn%d", fan_id); - if(rv != ONLP_STATUS_OK ){ return rv; } - rv = onlp_file_read_int((int*)&red_mode, INV_HWMON_PREFIX"fan_led_red%d", fan_id); - if(rv != ONLP_STATUS_OK ){ return rv; } - - if(grn_mode == 1 && red_mode == 0){ - info->mode = ONLP_LED_MODE_GREEN; - }else if(grn_mode == 0 && red_mode == 1){ - info->mode = ONLP_LED_MODE_RED; - }else if(grn_mode == 0 && red_mode == 0){ - info->mode = ONLP_LED_MODE_OFF; - }else{ - rv = ONLP_STATUS_E_INVALID; - } - }else{ - info->mode = ONLP_LED_MODE_OFF; - } - return rv; -} - -static int _sys_onlp_ledi_mode_set(onlp_led_mode_t onlp_mode) -{ - int rv = ONLP_STATUS_OK; - - if( onlp_mode == ONLP_LED_MODE_OFF){ - rv = onlp_file_write_int(SYS_LED_MODE_OFF, INV_SYSLED_PREFIX"grn_led"); - if(rv != ONLP_STATUS_OK ){ return rv; } - rv = onlp_file_write_int(SYS_LED_MODE_OFF, INV_SYSLED_PREFIX"red_led"); - }else{ - rv = ONLP_STATUS_E_UNSUPPORTED; - } - return rv; -} - - - -/* - * 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; - VALIDATE(id); - int local_id; - local_id = ONLP_OID_ID_GET(id); - if(local_id >= ONLP_LED_MAX) { - return ONLP_STATUS_E_INVALID; - } - - switch(local_id) { - case ONLP_LED_MGMT: - rv = _sys_onlp_ledi_info_get(id, info); - break; - case ONLP_LED_FAN1: - case ONLP_LED_FAN2: - case ONLP_LED_FAN3: - case ONLP_LED_FAN4: - rv = _fan_onlp_ledi_info_get(id, info); - break; - default: - rv = ONLP_STATUS_E_INVALID; - break; - } - return rv; -} - -/** - * @brief Get the LED operational status. - * @param id The LED OID - * @param rv [out] Receives the operational status. - */ -int onlp_ledi_status_get(onlp_oid_t id, uint32_t* rv) -{ - int result = ONLP_STATUS_OK; - onlp_led_info_t* info; - - VALIDATE(id); - int local_id = ONLP_OID_ID_GET(id); - int info_idx = LOCAL_ID_TO_INFO_IDX(local_id); - int fan_id = LOCAL_ID_TO_FAN_ID(local_id); - int mode, grn_mode, red_mode; - onlp_led_mode_t pmode; - uint32_t fan_status; - - if(local_id >= ONLP_LED_MAX) { - result = ONLP_STATUS_E_INVALID; - } - if(result == ONLP_STATUS_OK) { - info = &__onlp_led_info[info_idx]; - switch(local_id) { - case ONLP_LED_MGMT: - result = onlp_file_read_int((int*)&grn_mode, INV_SYSLED_PREFIX"grn_led"); - if(result != ONLP_STATUS_OK){ return result; } - result = onlp_file_read_int((int*)&red_mode, INV_SYSLED_PREFIX"red_led"); - if(result != ONLP_STATUS_OK){ return result; } - - result = _sys_onlp_led_mode_convert(grn_mode, red_mode, &pmode); - if(result != ONLP_STATUS_OK){ return result; } - - if( pmode != ONLP_LED_MODE_OFF){ - info->status |= ONLP_LED_STATUS_ON; - }else{ - info->status &= (~ONLP_LED_STATUS_ON); - } - - *rv = info->status; - break; - case ONLP_LED_FAN1: - case ONLP_LED_FAN2: - case ONLP_LED_FAN3: - case ONLP_LED_FAN4: - result = onlp_fani_status_get((&info->hdr)->poid, &fan_status); - if(result != ONLP_STATUS_OK){ return result; } - - if(fan_status & ONLP_FAN_STATUS_PRESENT){ - info->status |= ONLP_LED_STATUS_PRESENT; - info->status &= (~ONLP_LED_STATUS_ON); - - result = onlp_file_read_int((int*)&mode, INV_HWMON_PREFIX"fan_led_grn%d", fan_id); - if(result != ONLP_STATUS_OK){ return result; } - if(mode){ - info->status |= ONLP_LED_STATUS_ON; - } - - result = onlp_file_read_int((int*)&mode, INV_HWMON_PREFIX"fan_led_red%d", fan_id); - if(result != ONLP_STATUS_OK){ return result; } - if(mode){ - info->status |= ONLP_LED_STATUS_ON; - } - } else { - info->status = 0; - } - *rv = info->status; - break; - default: - result = ONLP_STATUS_E_INVALID; - break; - } - } - - return result; -} - -/** - * @brief Get the LED header. - * @param id The LED OID - * @param rv [out] Receives the header. - */ -int onlp_ledi_hdr_get(onlp_oid_t id, onlp_oid_hdr_t* rv) -{ - int result = ONLP_STATUS_OK; - onlp_led_info_t* info; - - VALIDATE(id); - - int local_id; - local_id = ONLP_OID_ID_GET(id); - int idx = LOCAL_ID_TO_INFO_IDX(local_id); - if(local_id >= ONLP_LED_MAX) { - result = ONLP_STATUS_E_INVALID; - } else { - info = &__onlp_led_info[idx]; - *rv = info->hdr; - } - return result; -} - -/* - * 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) -{ - onlp_led_mode_t mode; - VALIDATE(id); - int local_id; - local_id = ONLP_OID_ID_GET(id); - int idx = LOCAL_ID_TO_INFO_IDX(local_id); - - if(local_id >= ONLP_LED_MAX) { - return ONLP_STATUS_E_INVALID; - } - - if (__onlp_led_info[idx].caps & ONLP_LED_CAPS_ON_OFF) { - mode = on_or_off?ONLP_LED_MODE_ON:ONLP_LED_MODE_OFF; - return onlp_ledi_mode_set(id, mode); - } - - 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 rv = ONLP_STATUS_OK; - VALIDATE(id); - int local_id; - local_id = ONLP_OID_ID_GET(id); - - if(local_id >= ONLP_LED_MAX) { - return ONLP_STATUS_E_INVALID; - } - switch(local_id) { - case ONLP_LED_MGMT: - rv = _sys_onlp_ledi_mode_set(mode); - break; - case ONLP_LED_FAN1: - case ONLP_LED_FAN2: - case ONLP_LED_FAN3: - case ONLP_LED_FAN4: - rv = ONLP_STATUS_E_UNSUPPORTED; - break; - default: - rv = ONLP_STATUS_E_INVALID; - break; - } - - return rv; -} - -/* - * 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/d5264q28b/onlp/builds/x86_64_inventec_d5264q28b/module/src/make.mk b/packages/platforms/inventec/x86-64/d5264q28b/onlp/builds/x86_64_inventec_d5264q28b/module/src/make.mk deleted file mode 100644 index 5db38681d..000000000 --- a/packages/platforms/inventec/x86-64/d5264q28b/onlp/builds/x86_64_inventec_d5264q28b/module/src/make.mk +++ /dev/null @@ -1,9 +0,0 @@ -############################################################################### -# -# -# -############################################################################### - -LIBRARY := x86_64_inventec_d5264q28b -$(LIBRARY)_SUBDIR := $(dir $(lastword $(MAKEFILE_LIST))) -include $(BUILDER)/lib.mk diff --git a/packages/platforms/inventec/x86-64/d5264q28b/onlp/builds/x86_64_inventec_d5264q28b/module/src/platform_lib.c b/packages/platforms/inventec/x86-64/d5264q28b/onlp/builds/x86_64_inventec_d5264q28b/module/src/platform_lib.c deleted file mode 100644 index bb04678b2..000000000 --- a/packages/platforms/inventec/x86-64/d5264q28b/onlp/builds/x86_64_inventec_d5264q28b/module/src/platform_lib.c +++ /dev/null @@ -1,50 +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" - - -int platform_hwmon_diag_enable_read(int *enable) -{ - int rv = ONLP_STATUS_OK; - rv = onlp_file_read_int((int*)enable, INV_HWMON_PREFIX"diag"); - return rv; -} - - -int platform_hwmon_diag_enable_write(int enable) -{ - int rv = ONLP_STATUS_OK; - rv = onlp_file_write_int(enable, INV_HWMON_PREFIX"diag"); - return rv; -} diff --git a/packages/platforms/inventec/x86-64/d5264q28b/onlp/builds/x86_64_inventec_d5264q28b/module/src/platform_lib.h b/packages/platforms/inventec/x86-64/d5264q28b/onlp/builds/x86_64_inventec_d5264q28b/module/src/platform_lib.h deleted file mode 100644 index a4123817d..000000000 --- a/packages/platforms/inventec/x86-64/d5264q28b/onlp/builds/x86_64_inventec_d5264q28b/module/src/platform_lib.h +++ /dev/null @@ -1,142 +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 "x86_64_inventec_d5264q28b_log.h" - -/* This is definitions for x86-64-inventec-d5264q28b*/ -/* OID map*/ -/* - * SYS---------ONLP_THERMAL_CPU_PHY - * |----ONLP_THERMAL_CPU_CORE0 - * |----ONLP_THERMAL_CPU_CORE1 - * |----ONLP_THERMAL_CPU_CORE2 - * |----ONLP_THERMAL_CPU_CORE3 - * |----ONLP_THERMAL_1_ON_MAIN_BROAD - * |----ONLP_THERMAL_2_ON_MAIN_BROAD - * |----ONLP_THERMAL_3_ON_MAIN_BROAD - * |----ONLP_THERMAL_4_ON_MAIN_BROAD - * |----ONLP_THERMAL_5_ON_MAIN_BROAD - * |----ONLP_FAN_1--------ONLP_LED_FAN1 - * | - * |----ONLP_FAN_2--------ONLP_LED_FAN2 - * | - * |----ONLP_FAN_3--------ONLP_LED_FAN3 - * | - * |----ONLP_FAN_4--------ONLP_LED_FAN4 - * | - * |----ONLP_PSU_1--------ONLP_THERMAL_1_ON_PSU1 - * | |--ONLP_THERMAL_2_ON_PSU1 - * | |--ONLP_FAN_PSU_1 - * | - * |----ONLP_PSU_2--------ONLP_THERMAL_1_ON_PSU2 - * | |--ONLP_THERMAL_2_ON_PSU2 - * | |--ONLP_FAN_PSU_2 - * | - * |----ONLP_LED_MGMT - */ - -#define INV_SYSLED_PREFIX "/sys/class/hwmon/hwmon2/device/" -#define INV_HWMON_PREFIX "/sys/class/hwmon/hwmon1/device/" -#define INV_CTMP_PREFIX "/sys/class/hwmon/hwmon0/" -#define INV_SFP_PREFIX "/sys/class/swps/" -#define INV_SYS_PREFIX "/sys/class/eeprom/vpd/" -#define INV_EEPROM_PATH "/sys/bus/i2c/devices/0-0053/eeprom" - -#define OID_MAP_TO_INFO_IDX(oid) ONLP_OID_ID_GET(oid)-1 -#define LOCAL_ID_TO_INFO_IDX(id) (id-1) - -/* Thermal definitions*/ -enum onlp_thermal_id { - ONLP_THERMAL_CPU_PHY = 1, - ONLP_THERMAL_CPU_CORE0, - ONLP_THERMAL_CPU_CORE1, - ONLP_THERMAL_CPU_CORE2, - ONLP_THERMAL_CPU_CORE3, - ONLP_THERMAL_1_ON_MAIN_BROAD, - ONLP_THERMAL_2_ON_MAIN_BROAD, - ONLP_THERMAL_3_ON_MAIN_BROAD, - ONLP_THERMAL_4_ON_MAIN_BROAD, - ONLP_THERMAL_5_ON_MAIN_BROAD, - ONLP_THERMAL_1_ON_PSU1, - ONLP_THERMAL_2_ON_PSU1, - ONLP_THERMAL_1_ON_PSU2, - ONLP_THERMAL_2_ON_PSU2, - ONLP_THERMAL_MAX -}; - -#define ONLP_THERMAL_COUNT 14 /*include "reserved"*/ -#define THERMAL_ON_CHASSIS 10 - -/* Fan definitions*/ -enum onlp_fan_id { - ONLP_FAN_1 = 1, - ONLP_FAN_2, - ONLP_FAN_3, - ONLP_FAN_4, - ONLP_FAN_PSU_1, - ONLP_FAN_PSU_2, - ONLP_FAN_MAX -}; - -#define ONLP_FAN_COUNT 6 /*include "reserved"*/ -#define FAN_ON_CHASSIS 4 - -/* PSU definitions*/ -enum onlp_psu_id { - ONLP_PSU_1 = 1, - ONLP_PSU_2, - ONLP_PSU_MAX -}; - -#define ONLP_PSU_COUNT 2 /*include "reserved"*/ -#define PSU_ON_CHASSIS 2 - -/* LED definitions*/ -enum onlp_led_id { - ONLP_LED_MGMT = 1, - ONLP_LED_FAN1, - ONLP_LED_FAN2, - ONLP_LED_FAN3, - ONLP_LED_FAN4, - ONLP_LED_MAX -}; - -#define ONLP_LED_COUNT 5 /*include "reserved"*/ -#define LED_ON_CHASSIS 1 - -/* platform functions*/ -#define PLATFORM_HWMON_DIAG_LOCK platform_hwmon_diag_enable_write(0) -#define PLATFORM_HWMON_DIAG_UNLOCK platform_hwmon_diag_enable_write(1) -int platform_hwmon_diag_enable_read(int *enable); -int platform_hwmon_diag_enable_write(int enable); - - - - -#endif /* __PLATFORM_LIB_H__ */ - diff --git a/packages/platforms/inventec/x86-64/d5264q28b/onlp/builds/x86_64_inventec_d5264q28b/module/src/psui.c b/packages/platforms/inventec/x86-64/d5264q28b/onlp/builds/x86_64_inventec_d5264q28b/module/src/psui.c deleted file mode 100644 index 8c8e2245e..000000000 --- a/packages/platforms/inventec/x86-64/d5264q28b/onlp/builds/x86_64_inventec_d5264q28b/module/src/psui.c +++ /dev/null @@ -1,214 +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 "platform_lib.h" -#include -#include - -#define VALIDATE(_id) \ - do { \ - if(!ONLP_OID_IS_PSU(_id)) { \ - return ONLP_STATUS_E_INVALID; \ - } \ - } while(0) - - -typedef enum hwmon_psu_state_e { - HWMON_PSU_NORMAL = 0, - HWMON_PSU_UNPOWERED = 2, //010 - HWMON_PSU_FAULT = 4, //100 - HWMON_PSU_NOT_INSTALLED = 7 //111 -} hwmon_psu_state_t; - -/* - * Get all information about the given PSU oid. - */ -#define MAKE_PSU_NODE_INFO(id) \ - { \ - { \ - ONLP_PSU_ID_CREATE(ONLP_PSU_##id), "PSU-"#id, 0, \ - { \ - ONLP_THERMAL_ID_CREATE(ONLP_THERMAL_1_ON_PSU##id), \ - ONLP_THERMAL_ID_CREATE(ONLP_THERMAL_2_ON_PSU##id), \ - ONLP_FAN_ID_CREATE(ONLP_FAN_PSU_##id) \ - } \ - }, \ - "","", 0, 0 \ - } - -static onlp_psu_info_t __onlp_psu_info[ONLP_PSU_COUNT] = { - MAKE_PSU_NODE_INFO(1), - MAKE_PSU_NODE_INFO(2) -}; - -int -onlp_psui_init(void) -{ - return ONLP_STATUS_OK; -} - - -int -onlp_psui_info_get(onlp_oid_t id, onlp_psu_info_t* info) -{ - int ret = ONLP_STATUS_OK; - int len; - int local_id = ONLP_OID_ID_GET(id); - uint8_t temp[ONLP_CONFIG_INFO_STR_MAX] = {0}; - - VALIDATE(id); - - if(local_id >= ONLP_PSU_MAX) { - return ONLP_STATUS_E_INVALID; - } - - *info = __onlp_psu_info[LOCAL_ID_TO_INFO_IDX(local_id)]; /* Set the onlp_oid_hdr_t */ - - ret = onlp_file_read(temp, ONLP_CONFIG_INFO_STR_MAX, &len, INV_HWMON_PREFIX"psoc_psu%d_vendor", local_id); - if(ret != ONLP_STATUS_OK){ return ret; } - /*remove the '\n'*/ - temp[strlen((char*)temp)-1] = 0; - snprintf(info->model, ONLP_CONFIG_INFO_STR_MAX, "%s", temp); - - - memset(temp, 0, ONLP_CONFIG_INFO_STR_MAX); - ret = onlp_file_read(temp, ONLP_CONFIG_INFO_STR_MAX, &len, INV_HWMON_PREFIX"psoc_psu%d_serial", local_id); - if(ret != ONLP_STATUS_OK){ return ret; } - /*remove the '\n'*/ - temp[strlen((char*)temp)-1] = 0; - snprintf(info->serial, ONLP_CONFIG_INFO_STR_MAX, "%s", temp); - - ret = onlp_psui_status_get(id, &info->status); - if(ret != ONLP_STATUS_OK){ return ret; } - - if(info->status & ONLP_PSU_STATUS_PRESENT){ - info->caps = ONLP_PSU_CAPS_AC; - /*millivolts*/ - ret = onlp_file_read_int(&info->mvin, INV_HWMON_PREFIX"psoc_psu%d_vin", local_id); - if(ret != ONLP_STATUS_OK){ return ret; } - if(info->mvin >= 0){ - info->caps |= ONLP_PSU_CAPS_VIN; - } - ret = onlp_file_read_int(&info->mvout, INV_HWMON_PREFIX"psoc_psu%d_vout", local_id); - if(ret != ONLP_STATUS_OK){ return ret; } - if(info->mvout >= 0){ - info->caps |= ONLP_PSU_CAPS_VOUT; - } - - /* milliamps */ - ret = onlp_file_read_int(&info->miin, INV_HWMON_PREFIX"psoc_psu%d_iin", local_id); - if(ret != ONLP_STATUS_OK){ return ret; } - if(info->miin >= 0){ - info->caps |= ONLP_PSU_CAPS_IIN; - } - ret = onlp_file_read_int(&info->miout, INV_HWMON_PREFIX"psoc_psu%d_iout", local_id); - if(ret != ONLP_STATUS_OK){ return ret; } - if(info->miout >= 0){ - info->caps |= ONLP_PSU_CAPS_IOUT; - } - - /* milliwatts */ - ret = onlp_file_read_int(&info->mpin, INV_HWMON_PREFIX"psoc_psu%d_pin", local_id); - if(ret != ONLP_STATUS_OK){ return ret; } - if(info->mpin >= 0){ - info->caps |= ONLP_PSU_CAPS_PIN; - } - ret = onlp_file_read_int(&info->mpout, INV_HWMON_PREFIX"psoc_psu%d_pout", local_id); - if(ret != ONLP_STATUS_OK){ return ret; } - if(info->mpout >= 0){ - info->caps |= ONLP_PSU_CAPS_POUT; - } - } - return ret; -} - - -/** - * @brief Get the PSU's operational status. - * @param id The PSU OID. - * @param rv [out] Receives the operational status. - */ -int onlp_psui_status_get(onlp_oid_t id, uint32_t* rv) -{ - int result = ONLP_STATUS_OK; - hwmon_psu_state_t psu_state; - int local_id; - VALIDATE(id); - int len; - char buf[ONLP_CONFIG_INFO_STR_MAX]; - - local_id = ONLP_OID_ID_GET(id); - if(local_id >= ONLP_PSU_MAX) { - result = ONLP_STATUS_E_INVALID; - } else { - result = onlp_file_read((uint8_t*)&buf, ONLP_CONFIG_INFO_STR_MAX, &len, "%s""psu%d", INV_HWMON_PREFIX, local_id); - if( result != ONLP_STATUS_OK ){return result;} - psu_state = (uint8_t)strtoul(buf, NULL, 0); - if( psu_state == HWMON_PSU_UNPOWERED) { - *rv = ONLP_PSU_STATUS_PRESENT|ONLP_PSU_STATUS_UNPLUGGED; - } else if ( psu_state == HWMON_PSU_NORMAL) { - *rv = ONLP_PSU_STATUS_PRESENT; - } else if( psu_state == HWMON_PSU_FAULT) { - *rv = ONLP_PSU_STATUS_PRESENT|ONLP_PSU_STATUS_FAILED; - } else if( psu_state == HWMON_PSU_NOT_INSTALLED){ - *rv = 0; - } else{ - result = ONLP_STATUS_E_INVALID; - } - } - return result; -} - -/** - * @brief Get the PSU's oid header. - * @param id The PSU OID. - * @param rv [out] Receives the header. - */ -int onlp_psui_hdr_get(onlp_oid_t id, onlp_oid_hdr_t* rv) -{ - int result = ONLP_STATUS_OK; - onlp_psu_info_t* info; - int local_id; - VALIDATE(id); - - local_id = ONLP_OID_ID_GET(id); - if(local_id >= ONLP_PSU_MAX) { - result = ONLP_STATUS_E_INVALID; - } else { - info = &__onlp_psu_info[LOCAL_ID_TO_INFO_IDX(local_id)]; - *rv = info->hdr; - } - return result; -} - - -int -onlp_psui_ioctl(onlp_oid_t pid, va_list vargs) -{ - return ONLP_STATUS_E_UNSUPPORTED; -} - diff --git a/packages/platforms/inventec/x86-64/d5264q28b/onlp/builds/x86_64_inventec_d5264q28b/module/src/sfpi.c b/packages/platforms/inventec/x86-64/d5264q28b/onlp/builds/x86_64_inventec_d5264q28b/module/src/sfpi.c deleted file mode 100644 index 8de4acf94..000000000 --- a/packages/platforms/inventec/x86-64/d5264q28b/onlp/builds/x86_64_inventec_d5264q28b/module/src/sfpi.c +++ /dev/null @@ -1,281 +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 /* For O_RDWR && open */ -#include -#include -#include -#include -#include -#include "platform_lib.h" -#include -#include - -#define MAX_SFP_PATH 128 - -#define MUX_START_INDEX 17 -#define QSFP_DEV_ADDR 0x50 -#define NUM_OF_QSFP_PORT 64 -#define NUM_OF_ALL_PORT (NUM_OF_QSFP_PORT) - -#define FRONT_PORT_TO_MUX_INDEX(port) (port+MUX_START_INDEX) -#define VALIDATE_PORT(p) { if ((p < 0) || (p >= NUM_OF_ALL_PORT)) return ONLP_STATUS_E_PARAM; } -/************************************************************ - * - * SFPI Entry Points - * - ***********************************************************/ -int -onlp_sfpi_init(void) -{ - /* Called at initialization time */ - return ONLP_STATUS_OK; -} - -int onlp_sfpi_port_map(int port, int* rport) -{ - VALIDATE_PORT(port); - *rport = port; - return ONLP_STATUS_OK; -} - -int -onlp_sfpi_bitmap_get(onlp_sfp_bitmap_t* bmap) -{ - /* - * Ports {0, 63} - */ - int p; - AIM_BITMAP_CLR_ALL(bmap); - - for(p = 0; p < NUM_OF_ALL_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. - */ - VALIDATE_PORT(port); - int present; - int rv; - if(onlp_file_read_int(&present, INV_SFP_PREFIX"port%d/present", port) != ONLP_STATUS_OK){ - return ONLP_STATUS_E_INTERNAL; - } - if(present == 0){ - rv = 1; - } else if (present == 1){ - rv = 0; - } - else { - AIM_LOG_ERROR("Unvalid present status %d from port(%d)\r\n",present,port); - return ONLP_STATUS_E_INTERNAL; - } - return rv; -} - -int -onlp_sfpi_presence_bitmap_get(onlp_sfp_bitmap_t* dst) -{ - AIM_BITMAP_CLR_ALL(dst); - int port; - for(port = 0; port < NUM_OF_ALL_PORT; port++){ - if(onlp_sfpi_is_present(port) == 1){ - AIM_BITMAP_MOD(dst, port, 1); - }else if(onlp_sfpi_is_present(port) == 0){ - AIM_BITMAP_MOD(dst, port, 0); - }else{ - return ONLP_STATUS_E_INTERNAL; - } - } - return ONLP_STATUS_OK; -} - -int -onlp_sfpi_is_rx_los(int port) -{ - /*rx los attribute of QSFP are not supported*/ - return ONLP_STATUS_E_UNSUPPORTED; -} - -int -onlp_sfpi_rx_los_bitmap_get(onlp_sfp_bitmap_t* dst) -{ - /*rx los attribute of QSFP are not supported*/ - return ONLP_STATUS_E_UNSUPPORTED; -} - -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; -} - -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 - */ - memset(data, 0, 256); - - VALIDATE_PORT(port); - int sts; - int bus = FRONT_PORT_TO_MUX_INDEX(port); - sts = onlp_i2c_block_read(bus, QSFP_DEV_ADDR, 0, 256, data, ONLP_I2C_F_FORCE); - if(sts < 0){ - AIM_LOG_ERROR("Unable to read eeprom from port(%d)\r\n", port); - return ONLP_STATUS_E_MISSING; - } - return ONLP_STATUS_OK; -} - -int -onlp_sfpi_dev_readb(int port, uint8_t devaddr, uint8_t addr) -{ - VALIDATE_PORT(port); - 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) -{ - VALIDATE_PORT(port); - 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) -{ - VALIDATE_PORT(port); - 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) -{ - VALIDATE_PORT(port); - int bus = FRONT_PORT_TO_MUX_INDEX(port); - return onlp_i2c_writew(bus, devaddr, addr, value, ONLP_I2C_F_FORCE); -} - -int -onlp_sfpi_control_supported(int port, onlp_sfp_control_t control, int* rv) -{ - *rv = 0; - if(port >= 0 && port < NUM_OF_QSFP_PORT){ - switch (control) { - case ONLP_SFP_CONTROL_RESET_STATE: - case ONLP_SFP_CONTROL_LP_MODE: - *rv = 1; - break; - default: - break; - } - } - return ONLP_STATUS_OK; -} - -int -onlp_sfpi_control_set(int port, onlp_sfp_control_t control, int value) -{ - int ret = ONLP_STATUS_E_UNSUPPORTED; - if(port >= 0 && port < NUM_OF_QSFP_PORT){ - switch (control) { - case ONLP_SFP_CONTROL_RESET_STATE: - ret = onlp_file_write_int(value, INV_SFP_PREFIX"port%d/reset", port); - break; - case ONLP_SFP_CONTROL_LP_MODE: - ret = onlp_file_write_int(value, INV_SFP_PREFIX"port%d/lpmod", port); - break; - default: - break; - } - } - return ret; -} - -int -onlp_sfpi_control_get(int port, onlp_sfp_control_t control, int* value) -{ - int ret = ONLP_STATUS_E_UNSUPPORTED; - if(port >= 0 && port < NUM_OF_QSFP_PORT){ - switch (control) { - case ONLP_SFP_CONTROL_RESET_STATE: - /*the value of /port(id)/reset - 0: in reset state; 1:not in reset state*/ - ret = onlp_file_read_int(value, INV_SFP_PREFIX"port%d/reset", port); - if(ret==ONLP_STATUS_OK){ - *value=!(*value); - } - break; - case ONLP_SFP_CONTROL_LP_MODE: - ret = onlp_file_read_int(value, INV_SFP_PREFIX"port%d/lpmod", port); - break; - default: - break; - } - } - return ret; -} - -int -onlp_sfpi_denit(void) -{ - return ONLP_STATUS_OK; -} - -void -onlp_sfpi_debug(int port, aim_pvs_t* pvs) -{ - aim_printf(pvs, "Debug data for port %d goes here.", port); -} - -int -onlp_sfpi_ioctl(int port, va_list vargs) -{ - return ONLP_STATUS_E_UNSUPPORTED; -} diff --git a/packages/platforms/inventec/x86-64/d5264q28b/onlp/builds/x86_64_inventec_d5264q28b/module/src/sysi.c b/packages/platforms/inventec/x86-64/d5264q28b/onlp/builds/x86_64_inventec_d5264q28b/module/src/sysi.c deleted file mode 100644 index 42b80d264..000000000 --- a/packages/platforms/inventec/x86-64/d5264q28b/onlp/builds/x86_64_inventec_d5264q28b/module/src/sysi.c +++ /dev/null @@ -1,230 +0,0 @@ -/************************************************************ - * sysi.c - * - * Copyright 2018 Inventec Technology Corporation. - * - ************************************************************ - * - ***********************************************************/ -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "x86_64_inventec_d5264q28b_int.h" -#include "x86_64_inventec_d5264q28b_log.h" - -#include "platform_lib.h" - -static int _sysi_version_parsing(char* file_str, char* str_buf, char* version); - -static int _sysi_version_parsing(char* file_str, char* str_buf, char* version) -{ - int rv = ONLP_STATUS_OK; - int len; - char buf[ONLP_CONFIG_INFO_STR_MAX*4]; - char *temp; - - rv = onlp_file_read((uint8_t*)buf,ONLP_CONFIG_INFO_STR_MAX*4, &len, file_str); - if( rv != ONLP_STATUS_OK ) { return rv; } - - temp = strstr(buf, str_buf); - if(temp) { - temp += strlen(str_buf); - snprintf(version,ONLP_CONFIG_INFO_STR_MAX, temp); - /*remove '\n'*/ - version[strlen(version)-1] = '\0'; - } else { - rv = ONLP_STATUS_E_MISSING; - } - return rv; -} - - -const char* -onlp_sysi_platform_get(void) -{ - return "x86-64-inventec-d5264q28b-r0"; -} - - -/* - * This function is called to return the physical base address - * of the ONIE boot rom. - * - * The ONLP framework will mmap() and parse the ONIE TLV structure - * from the given data. - * - * If you platform does not support a mappable address for the ONIE - * eeprom then you should not provide this function at all. - * - * For the purposes of this example we will provide it but - * return UNSUPPORTED (which is all the default implementation does). - * - */ -int -onlp_sysi_onie_data_phys_addr_get(void** pa) -{ - return ONLP_STATUS_E_UNSUPPORTED; -} - - -/* - * If you cannot provide a base address you must provide the ONLP - * framework the raw ONIE data through whatever means necessary. - * - * This function will be called as a backup in the event that - * onlp_sysi_onie_data_phys_addr_get() fails. - */ -int -onlp_sysi_onie_data_get(uint8_t** data, int* size) -{ - int ret=ONLP_STATUS_E_INVALID; - int eeprom_size; - int rv; - uint8_t* eeprom_data; - - FILE* fp = fopen(INV_EEPROM_PATH, "rb"); - - if(fp) { - fseek(fp, 0L, SEEK_END); - eeprom_size = ftell(fp); - rewind(fp); - eeprom_data = aim_malloc(eeprom_size); - - rv = fread(eeprom_data, 1, eeprom_size, fp); - fclose(fp); - - if(rv == eeprom_size) { - ret=ONLP_STATUS_OK; - *data=eeprom_data; - *size=eeprom_size; - } - - } - - return ret; -} - -/* - * IF the ONLP frame calles onlp_sysi_onie_data_get(), - * if will call this function to free the data when it - * is finished with it. - * - * This function is optional, and depends on the data - * you return in onlp_sysi_onie_data_get(). - */ -void -onlp_sysi_onie_data_free(uint8_t* data) -{ - /* - * We returned a static array in onlp_sysi_onie_data_get() - * so no free operation is required. - */ - if(data) { - aim_free(data); - } -} - - -int -onlp_sysi_onie_info_get (onlp_onie_info_t *onie) -{ - int rv = ONLP_STATUS_OK; - - rv = onlp_onie_decode_file(onie, INV_EEPROM_PATH); - - onie->_hdr_id_string = aim_fstrdup("TlvInfo"); - onie->_hdr_version = 0x1; - return rv; -} - - -int -onlp_sysi_platform_info_get(onlp_platform_info_t* pi) -{ - int rv = ONLP_STATUS_OK; - char cpld_str[ONLP_CONFIG_INFO_STR_MAX]= {0}; - char other_str[ONLP_CONFIG_INFO_STR_MAX]= {0}; - char version[ONLP_CONFIG_INFO_STR_MAX]; - - rv = _sysi_version_parsing(INV_SYSLED_PREFIX"info", "The CPLD version is ", version); - if( rv != ONLP_STATUS_OK ) { return rv; } - snprintf(cpld_str, ONLP_CONFIG_INFO_STR_MAX, "%s%s ", cpld_str, version); - rv = _sysi_version_parsing(INV_HWMON_PREFIX"version", "ver: ", version); - if( rv != ONLP_STATUS_OK ) { return rv; } - snprintf(other_str, ONLP_CONFIG_INFO_STR_MAX, "%s%s.%s " - ,other_str, "psoc", version); - - /*cpld version*/ - if(strlen(cpld_str) > 0) { - pi->cpld_versions = aim_fstrdup("%s",cpld_str); - } - - /*other version*/ - if(strlen(other_str) > 0) { - pi->other_versions = aim_fstrdup("%s",other_str); - } - return rv; -} - -void -onlp_sysi_platform_info_free(onlp_platform_info_t* pi) -{ - if(pi->cpld_versions) { - aim_free(pi->cpld_versions); - } - if(pi->other_versions) { - aim_free(pi->other_versions); - } - return; -} - - -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<=THERMAL_ON_CHASSIS; i++){ - *e++ = ONLP_THERMAL_ID_CREATE(i); - } - for(i=1; i<=FAN_ON_CHASSIS; i++){ - *e++ = ONLP_FAN_ID_CREATE(i); - } - for(i=1; i<=PSU_ON_CHASSIS; i++){ - *e++ = ONLP_PSU_ID_CREATE(i); - } - for(i=1; i<=LED_ON_CHASSIS; i++){ - *e++ = ONLP_LED_ID_CREATE(i); - } - return ONLP_STATUS_OK; -} - - -int -onlp_sysi_platform_manage_fans(void) -{ - /*Ensure switch manager is working*/ - PLATFORM_HWMON_DIAG_LOCK; - return ONLP_STATUS_OK; -} - -int -onlp_sysi_platform_manage_leds(void) -{ - /*Ensure switch manager is working*/ - PLATFORM_HWMON_DIAG_LOCK; - return ONLP_STATUS_OK; -} - diff --git a/packages/platforms/inventec/x86-64/d5264q28b/onlp/builds/x86_64_inventec_d5264q28b/module/src/thermali.c b/packages/platforms/inventec/x86-64/d5264q28b/onlp/builds/x86_64_inventec_d5264q28b/module/src/thermali.c deleted file mode 100644 index 1bbb05284..000000000 --- a/packages/platforms/inventec/x86-64/d5264q28b/onlp/builds/x86_64_inventec_d5264q28b/module/src/thermali.c +++ /dev/null @@ -1,215 +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 -#include -#include "platform_lib.h" - -#define VALIDATE(_id) \ - do { \ - if(!ONLP_OID_IS_THERMAL(_id)) { \ - return ONLP_STATUS_E_INVALID; \ - } \ - } while(0) - - -typedef struct thermali_path_s { - char file[ONLP_CONFIG_INFO_STR_MAX]; -} thermali_path_t; - -#define MAKE_THERMAL_PATH_ON_CPU(id) { INV_CTMP_PREFIX"temp"#id"_input"} -#define MAKE_THERMAL_PATH_ON_MAIN_BROAD(id) { INV_HWMON_PREFIX"temp"#id"_input"} -#define MAKE_THERMAL1_PATH_ON_PSU(psu_id) { INV_HWMON_PREFIX"thermal_psu"#psu_id} -#define MAKE_THERMAL2_PATH_ON_PSU(psu_id) { INV_HWMON_PREFIX"thermal2_psu"#psu_id} - -static thermali_path_t __path_list[ONLP_THERMAL_COUNT] = { - MAKE_THERMAL_PATH_ON_CPU(1), - MAKE_THERMAL_PATH_ON_CPU(2), - MAKE_THERMAL_PATH_ON_CPU(3), - MAKE_THERMAL_PATH_ON_CPU(4), - MAKE_THERMAL_PATH_ON_CPU(5), - MAKE_THERMAL_PATH_ON_MAIN_BROAD(1), - MAKE_THERMAL_PATH_ON_MAIN_BROAD(2), - MAKE_THERMAL_PATH_ON_MAIN_BROAD(3), - MAKE_THERMAL_PATH_ON_MAIN_BROAD(4), - MAKE_THERMAL_PATH_ON_MAIN_BROAD(5), - MAKE_THERMAL1_PATH_ON_PSU(1), - MAKE_THERMAL2_PATH_ON_PSU(1), - MAKE_THERMAL1_PATH_ON_PSU(2), - MAKE_THERMAL2_PATH_ON_PSU(2) -}; - -#define MAKE_THERMAL_INFO_NODE_ON_CPU_PHY \ - { { ONLP_THERMAL_ID_CREATE(ONLP_THERMAL_CPU_PHY), "CPU Physical", 0}, \ - ONLP_THERMAL_STATUS_PRESENT, \ - ONLP_THERMAL_CAPS_GET_TEMPERATURE, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS \ - } -#define MAKE_THERMAL_INFO_NODE_ON_CPU_CORE(id) \ - { { ONLP_THERMAL_ID_CREATE(ONLP_THERMAL_CPU_CORE##id), "CPU Core "#id, 0},\ - ONLP_THERMAL_STATUS_PRESENT, \ - ONLP_THERMAL_CAPS_GET_TEMPERATURE, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS \ - } -#define MAKE_THERMAL_INFO_NODE_ON_MAIN_BROAD(id) \ - { { ONLP_THERMAL_ID_CREATE(ONLP_THERMAL_##id##_ON_MAIN_BROAD), "Thermal Sensor "#id, 0}, \ - ONLP_THERMAL_STATUS_PRESENT, \ - ONLP_THERMAL_CAPS_GET_TEMPERATURE, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS \ - } -#define MAKE_THERMAL_INFO_NODE_ON_PSU(thermal_id, psu_id) \ - { { \ - ONLP_THERMAL_ID_CREATE(ONLP_THERMAL_##thermal_id##_ON_PSU##psu_id), \ - "PSU-"#psu_id" Thermal Sensor "#thermal_id, \ - ONLP_PSU_ID_CREATE(ONLP_PSU_##psu_id) \ - }, \ - ONLP_THERMAL_CAPS_GET_TEMPERATURE, 0, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS \ - } - -/* Static values */ -static onlp_thermal_info_t __onlp_thermal_info[ONLP_THERMAL_COUNT] = { - MAKE_THERMAL_INFO_NODE_ON_CPU_PHY, - MAKE_THERMAL_INFO_NODE_ON_CPU_CORE(0), - MAKE_THERMAL_INFO_NODE_ON_CPU_CORE(1), - MAKE_THERMAL_INFO_NODE_ON_CPU_CORE(2), - MAKE_THERMAL_INFO_NODE_ON_CPU_CORE(3), - MAKE_THERMAL_INFO_NODE_ON_MAIN_BROAD(1), - MAKE_THERMAL_INFO_NODE_ON_MAIN_BROAD(2), - MAKE_THERMAL_INFO_NODE_ON_MAIN_BROAD(3), - MAKE_THERMAL_INFO_NODE_ON_MAIN_BROAD(4), - MAKE_THERMAL_INFO_NODE_ON_MAIN_BROAD(5), - MAKE_THERMAL_INFO_NODE_ON_PSU(1,1), - MAKE_THERMAL_INFO_NODE_ON_PSU(2,1), - MAKE_THERMAL_INFO_NODE_ON_PSU(1,2), - MAKE_THERMAL_INFO_NODE_ON_PSU(2,2) -}; - -/* - * 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); - int ret; - - local_id = ONLP_OID_ID_GET(id); - if(local_id >= ONLP_THERMAL_MAX) { - return ONLP_STATUS_E_INVALID; - } - - /* Set the onlp_oid_hdr_t and capabilities */ - *info = __onlp_thermal_info[LOCAL_ID_TO_INFO_IDX(local_id)]; - ret = onlp_thermali_status_get(id, &info->status); - if( ret != ONLP_STATUS_OK ){ return ret; } - - if(info->status & ONLP_THERMAL_STATUS_PRESENT){ - ret = onlp_file_read_int(&info->mcelsius, __path_list[LOCAL_ID_TO_INFO_IDX(local_id)].file); - } - - return ret; -} - - -/** - * @brief Retrieve the thermal's operational status. - * @param id The thermal oid. - * @param rv [out] Receives the operational status. - */ -int onlp_thermali_status_get(onlp_oid_t id, uint32_t* rv) -{ - int local_id; - int ret = ONLP_STATUS_OK; - onlp_thermal_info_t* info; - VALIDATE(id); - uint32_t psu_status; - - local_id = ONLP_OID_ID_GET(id); - if(local_id >= ONLP_THERMAL_MAX) { - return ONLP_STATUS_E_INVALID; - } - info = &__onlp_thermal_info[LOCAL_ID_TO_INFO_IDX(local_id)]; - - switch(local_id){ - case ONLP_THERMAL_1_ON_PSU1: - case ONLP_THERMAL_2_ON_PSU1: - case ONLP_THERMAL_1_ON_PSU2: - case ONLP_THERMAL_2_ON_PSU2: - ret = onlp_psui_status_get((&info->hdr)->poid, &psu_status); - if(ret != ONLP_STATUS_OK){return ret;} - - if(psu_status & ONLP_PSU_STATUS_PRESENT){ - info->status |= ONLP_THERMAL_STATUS_PRESENT; - }else{ - info->status = 0; - } - break; - default: - break; - } - - *rv = info->status; - - return ret; -} - -/** - * @brief Retrieve the thermal's oid header. - * @param id The thermal oid. - * @param rv [out] Receives the header. - */ -int onlp_thermali_hdr_get(onlp_oid_t id, onlp_oid_hdr_t* rv) -{ - int local_id; - onlp_thermal_info_t* info; - VALIDATE(id); - - local_id = ONLP_OID_ID_GET(id); - if(local_id >= ONLP_THERMAL_MAX) { - return ONLP_STATUS_E_INVALID; - } - info = &__onlp_thermal_info[LOCAL_ID_TO_INFO_IDX(local_id)]; - - *rv = info->hdr; - - return ONLP_STATUS_OK; -} diff --git a/packages/platforms/inventec/x86-64/d5264q28b/onlp/builds/x86_64_inventec_d5264q28b/module/src/x86_64_inventec_d5264q28b_config.c b/packages/platforms/inventec/x86-64/d5264q28b/onlp/builds/x86_64_inventec_d5264q28b/module/src/x86_64_inventec_d5264q28b_config.c deleted file mode 100644 index a686e4630..000000000 --- a/packages/platforms/inventec/x86-64/d5264q28b/onlp/builds/x86_64_inventec_d5264q28b/module/src/x86_64_inventec_d5264q28b_config.c +++ /dev/null @@ -1,81 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#include - -/* */ -#define __x86_64_inventec_d5264q28b_config_STRINGIFY_NAME(_x) #_x -#define __x86_64_inventec_d5264q28b_config_STRINGIFY_VALUE(_x) __x86_64_inventec_d5264q28b_config_STRINGIFY_NAME(_x) -x86_64_inventec_d5264q28b_config_settings_t x86_64_inventec_d5264q28b_config_settings[] = -{ -#ifdef X86_64_INVENTEC_D5264Q28B_CONFIG_INCLUDE_LOGGING - { __x86_64_inventec_d5264q28b_config_STRINGIFY_NAME(X86_64_INVENTEC_D5264Q28B_CONFIG_INCLUDE_LOGGING), __x86_64_inventec_d5264q28b_config_STRINGIFY_VALUE(X86_64_INVENTEC_D5264Q28B_CONFIG_INCLUDE_LOGGING) }, -#else -{ X86_64_INVENTEC_D5264Q28B_CONFIG_INCLUDE_LOGGING(__x86_64_inventec_d5264q28b_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_INVENTEC_D5264Q28B_CONFIG_LOG_OPTIONS_DEFAULT - { __x86_64_inventec_d5264q28b_config_STRINGIFY_NAME(X86_64_INVENTEC_D5264Q28B_CONFIG_LOG_OPTIONS_DEFAULT), __x86_64_inventec_d5264q28b_config_STRINGIFY_VALUE(X86_64_INVENTEC_D5264Q28B_CONFIG_LOG_OPTIONS_DEFAULT) }, -#else -{ X86_64_INVENTEC_D5264Q28B_CONFIG_LOG_OPTIONS_DEFAULT(__x86_64_inventec_d5264q28b_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_INVENTEC_D5264Q28B_CONFIG_LOG_BITS_DEFAULT - { __x86_64_inventec_d5264q28b_config_STRINGIFY_NAME(X86_64_INVENTEC_D5264Q28B_CONFIG_LOG_BITS_DEFAULT), __x86_64_inventec_d5264q28b_config_STRINGIFY_VALUE(X86_64_INVENTEC_D5264Q28B_CONFIG_LOG_BITS_DEFAULT) }, -#else -{ X86_64_INVENTEC_D5264Q28B_CONFIG_LOG_BITS_DEFAULT(__x86_64_inventec_d5264q28b_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_INVENTEC_D5264Q28B_CONFIG_LOG_CUSTOM_BITS_DEFAULT - { __x86_64_inventec_d5264q28b_config_STRINGIFY_NAME(X86_64_INVENTEC_D5264Q28B_CONFIG_LOG_CUSTOM_BITS_DEFAULT), __x86_64_inventec_d5264q28b_config_STRINGIFY_VALUE(X86_64_INVENTEC_D5264Q28B_CONFIG_LOG_CUSTOM_BITS_DEFAULT) }, -#else -{ X86_64_INVENTEC_D5264Q28B_CONFIG_LOG_CUSTOM_BITS_DEFAULT(__x86_64_inventec_d5264q28b_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_INVENTEC_D5264Q28B_CONFIG_PORTING_STDLIB - { __x86_64_inventec_d5264q28b_config_STRINGIFY_NAME(X86_64_INVENTEC_D5264Q28B_CONFIG_PORTING_STDLIB), __x86_64_inventec_d5264q28b_config_STRINGIFY_VALUE(X86_64_INVENTEC_D5264Q28B_CONFIG_PORTING_STDLIB) }, -#else -{ X86_64_INVENTEC_D5264Q28B_CONFIG_PORTING_STDLIB(__x86_64_inventec_d5264q28b_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_INVENTEC_D5264Q28B_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS - { __x86_64_inventec_d5264q28b_config_STRINGIFY_NAME(X86_64_INVENTEC_D5264Q28B_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS), __x86_64_inventec_d5264q28b_config_STRINGIFY_VALUE(X86_64_INVENTEC_D5264Q28B_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS) }, -#else -{ X86_64_INVENTEC_D5264Q28B_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS(__x86_64_inventec_d5264q28b_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_INVENTEC_D5264Q28B_CONFIG_INCLUDE_UCLI - { __x86_64_inventec_d5264q28b_config_STRINGIFY_NAME(X86_64_INVENTEC_D5264Q28B_CONFIG_INCLUDE_UCLI), __x86_64_inventec_d5264q28b_config_STRINGIFY_VALUE(X86_64_INVENTEC_D5264Q28B_CONFIG_INCLUDE_UCLI) }, -#else -{ X86_64_INVENTEC_D5264Q28B_CONFIG_INCLUDE_UCLI(__x86_64_inventec_d5264q28b_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_INVENTEC_D5264Q28B_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION - { __x86_64_inventec_d5264q28b_config_STRINGIFY_NAME(X86_64_INVENTEC_D5264Q28B_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION), __x86_64_inventec_d5264q28b_config_STRINGIFY_VALUE(X86_64_INVENTEC_D5264Q28B_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION) }, -#else -{ X86_64_INVENTEC_D5264Q28B_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION(__x86_64_inventec_d5264q28b_config_STRINGIFY_NAME), "__undefined__" }, -#endif - { NULL, NULL } -}; -#undef __x86_64_inventec_d5264q28b_config_STRINGIFY_VALUE -#undef __x86_64_inventec_d5264q28b_config_STRINGIFY_NAME - -const char* -x86_64_inventec_d5264q28b_config_lookup(const char* setting) -{ - int i; - for(i = 0; x86_64_inventec_d5264q28b_config_settings[i].name; i++) { - if(!strcmp(x86_64_inventec_d5264q28b_config_settings[i].name, setting)) { - return x86_64_inventec_d5264q28b_config_settings[i].value; - } - } - return NULL; -} - -int -x86_64_inventec_d5264q28b_config_show(struct aim_pvs_s* pvs) -{ - int i; - for(i = 0; x86_64_inventec_d5264q28b_config_settings[i].name; i++) { - aim_printf(pvs, "%s = %s\n", x86_64_inventec_d5264q28b_config_settings[i].name, x86_64_inventec_d5264q28b_config_settings[i].value); - } - return i; -} - -/* */ - diff --git a/packages/platforms/inventec/x86-64/d5264q28b/onlp/builds/x86_64_inventec_d5264q28b/module/src/x86_64_inventec_d5264q28b_enums.c b/packages/platforms/inventec/x86-64/d5264q28b/onlp/builds/x86_64_inventec_d5264q28b/module/src/x86_64_inventec_d5264q28b_enums.c deleted file mode 100644 index 9996e4585..000000000 --- a/packages/platforms/inventec/x86-64/d5264q28b/onlp/builds/x86_64_inventec_d5264q28b/module/src/x86_64_inventec_d5264q28b_enums.c +++ /dev/null @@ -1,10 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#include - -/* <--auto.start.enum(ALL).source> */ -/* */ - diff --git a/packages/platforms/inventec/x86-64/d5264q28b/onlp/builds/x86_64_inventec_d5264q28b/module/src/x86_64_inventec_d5264q28b_int.h b/packages/platforms/inventec/x86-64/d5264q28b/onlp/builds/x86_64_inventec_d5264q28b/module/src/x86_64_inventec_d5264q28b_int.h deleted file mode 100644 index f28c89f31..000000000 --- a/packages/platforms/inventec/x86-64/d5264q28b/onlp/builds/x86_64_inventec_d5264q28b/module/src/x86_64_inventec_d5264q28b_int.h +++ /dev/null @@ -1,12 +0,0 @@ -/**************************************************************************//** - * - * x86_64_inventec_d5264q28b Internal Header - * - *****************************************************************************/ -#ifndef __x86_64_inventec_d5264q28b_INT_H__ -#define __x86_64_inventec_d5264q28b_INT_H__ - -#include - - -#endif /* __x86_64_inventec_d5264q28b_INT_H__ */ diff --git a/packages/platforms/inventec/x86-64/d5264q28b/onlp/builds/x86_64_inventec_d5264q28b/module/src/x86_64_inventec_d5264q28b_log.c b/packages/platforms/inventec/x86-64/d5264q28b/onlp/builds/x86_64_inventec_d5264q28b/module/src/x86_64_inventec_d5264q28b_log.c deleted file mode 100644 index 75663c69f..000000000 --- a/packages/platforms/inventec/x86-64/d5264q28b/onlp/builds/x86_64_inventec_d5264q28b/module/src/x86_64_inventec_d5264q28b_log.c +++ /dev/null @@ -1,18 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#include - -#include "x86_64_inventec_d5264q28b_log.h" -/* - * x86_64_inventec_d5264q28b log struct. - */ -AIM_LOG_STRUCT_DEFINE( - X86_64_INVENTEC_D5264Q28B_CONFIG_LOG_OPTIONS_DEFAULT, - X86_64_INVENTEC_D5264Q28B_CONFIG_LOG_BITS_DEFAULT, - NULL, /* Custom log map */ - X86_64_INVENTEC_D5264Q28B_CONFIG_LOG_CUSTOM_BITS_DEFAULT - ); - diff --git a/packages/platforms/inventec/x86-64/d5264q28b/onlp/builds/x86_64_inventec_d5264q28b/module/src/x86_64_inventec_d5264q28b_log.h b/packages/platforms/inventec/x86-64/d5264q28b/onlp/builds/x86_64_inventec_d5264q28b/module/src/x86_64_inventec_d5264q28b_log.h deleted file mode 100644 index bff46fc2f..000000000 --- a/packages/platforms/inventec/x86-64/d5264q28b/onlp/builds/x86_64_inventec_d5264q28b/module/src/x86_64_inventec_d5264q28b_log.h +++ /dev/null @@ -1,12 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#ifndef __x86_64_inventec_d5264q28b_LOG_H__ -#define __x86_64_inventec_d5264q28b_LOG_H__ - -#define AIM_LOG_MODULE_NAME x86_64_inventec_d5264q28b -#include - -#endif /* __x86_64_inventec_d5264q28b_LOG_H__ */ diff --git a/packages/platforms/inventec/x86-64/d5264q28b/onlp/builds/x86_64_inventec_d5264q28b/module/src/x86_64_inventec_d5264q28b_module.c b/packages/platforms/inventec/x86-64/d5264q28b/onlp/builds/x86_64_inventec_d5264q28b/module/src/x86_64_inventec_d5264q28b_module.c deleted file mode 100644 index f0f861a32..000000000 --- a/packages/platforms/inventec/x86-64/d5264q28b/onlp/builds/x86_64_inventec_d5264q28b/module/src/x86_64_inventec_d5264q28b_module.c +++ /dev/null @@ -1,24 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#include - -#include "x86_64_inventec_d5264q28b_log.h" - -static int -datatypes_init__(void) -{ -#define x86_64_inventec_d5264q28b_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_d5264q28b_module_init__(void) -{ - AIM_LOG_STRUCT_REGISTER(); - datatypes_init__(); -} - -int __onlp_platform_version__ = 1; diff --git a/packages/platforms/inventec/x86-64/d5264q28b/onlp/builds/x86_64_inventec_d5264q28b/module/src/x86_64_inventec_d5264q28b_ucli.c b/packages/platforms/inventec/x86-64/d5264q28b/onlp/builds/x86_64_inventec_d5264q28b/module/src/x86_64_inventec_d5264q28b_ucli.c deleted file mode 100644 index 9b4314a0b..000000000 --- a/packages/platforms/inventec/x86-64/d5264q28b/onlp/builds/x86_64_inventec_d5264q28b/module/src/x86_64_inventec_d5264q28b_ucli.c +++ /dev/null @@ -1,50 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#include - -#if X86_64_INVENTEC_D5264Q28B_CONFIG_INCLUDE_UCLI == 1 - -#include -#include -#include - -static ucli_status_t -x86_64_inventec_d5264q28b_ucli_ucli__config__(ucli_context_t* uc) -{ - UCLI_HANDLER_MACRO_MODULE_CONFIG(x86_64_inventec_d5264q28b) -} - -/* */ -/* */ - -static ucli_module_t -x86_64_inventec_d5264q28b_ucli_module__ = - { - "x86_64_inventec_d5264q28b_ucli", - NULL, - x86_64_inventec_d5264q28b_ucli_ucli_handlers__, - NULL, - NULL, - }; - -ucli_node_t* -x86_64_inventec_d5264q28b_ucli_node_create(void) -{ - ucli_node_t* n; - ucli_module_init(&x86_64_inventec_d5264q28b_ucli_module__); - n = ucli_node_create("x86_64_inventec_d5264q28b", NULL, &x86_64_inventec_d5264q28b_ucli_module__); - ucli_node_subnode_add(n, ucli_module_log_node_create("x86_64_inventec_d5264q28b")); - return n; -} - -#else -void* -x86_64_inventec_d5264q28b_ucli_node_create(void) -{ - return NULL; -} -#endif - diff --git a/packages/platforms/inventec/x86-64/d5264q28b/platform-config/Makefile b/packages/platforms/inventec/x86-64/d5264q28b/platform-config/Makefile deleted file mode 100644 index 003238cf6..000000000 --- a/packages/platforms/inventec/x86-64/d5264q28b/platform-config/Makefile +++ /dev/null @@ -1 +0,0 @@ -include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/inventec/x86-64/d5264q28b/platform-config/r0/Makefile b/packages/platforms/inventec/x86-64/d5264q28b/platform-config/r0/Makefile deleted file mode 100644 index 003238cf6..000000000 --- a/packages/platforms/inventec/x86-64/d5264q28b/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/inventec/x86-64/d5264q28b/platform-config/r0/PKG.yml b/packages/platforms/inventec/x86-64/d5264q28b/platform-config/r0/PKG.yml deleted file mode 100644 index c78c705fe..000000000 --- a/packages/platforms/inventec/x86-64/d5264q28b/platform-config/r0/PKG.yml +++ /dev/null @@ -1 +0,0 @@ -!include $ONL_TEMPLATES/platform-config-platform.yml ARCH=amd64 VENDOR=inventec BASENAME=x86-64-inventec-d5264q28b REVISION=r0 diff --git a/packages/platforms/inventec/x86-64/d5264q28b/platform-config/r0/src/lib/healthstatus.sh b/packages/platforms/inventec/x86-64/d5264q28b/platform-config/r0/src/lib/healthstatus.sh deleted file mode 100755 index 00955174e..000000000 --- a/packages/platforms/inventec/x86-64/d5264q28b/platform-config/r0/src/lib/healthstatus.sh +++ /dev/null @@ -1,113 +0,0 @@ -#!/bin/bash -normal='0 : normal' -unpowered='2 : unpowered' -fault='4 : fault' -notinstalled='7 : not installed' -FAN_UNPLUG_NUM=0 -FAN_LED_RED='fan_led_red' -NUM=1 -FAN_NUM=5 -FIRST_READ=0 -SECOND_READ=0 - -PSOC_PATH="" -CPLD_ADDR="/sys/bus/i2c/devices/i2c-0/0-0055" -ROUTE="/sys/class/hwmon/" -for KEY in $(ls ${ROUTE}) -do - KEY=${ROUTE}${KEY} - if [ -f $KEY"/name" ]; then - if [ $(cat $KEY"/name") == "inv_psoc" ]; then - PSOC_PATH=$KEY - fi - fi -done -if [[ $PSOC_PATH == "" ]]; then - echo "ERROR! Unable to find inv_psoc!" - exit -fi - - -#PSU_STAUS='000' -#switch is ready , transfer control of cpld to cpu -echo 1 > $CPLD_ADDR/ctl - -while true -do - -#monitor how many fan modules are unplugged - - -#first check -FAN_UNPLUG_NUM=0 -FAN_ARR=$(cat $PSOC_PATH/$FAN_LED_RED?) - -while read -r line; do - fan_led_red_check=$(echo "$line") - if [ $fan_led_red_check -eq 1 ] - then - let FAN_UNPLUG_NUM=FAN_UNPLUG_NUM+1 - fi -done <<< "$FAN_ARR" -FIRST_READ=$FAN_UNPLUG_NUM - -#second check -FAN_UNPLUG_NUM=0 -FAN_ARR=$(cat $PSOC_PATH/$FAN_LED_RED?) - -while read -r line; do - fan_led_red_check=$(echo "$line") - if [ $fan_led_red_check -eq 1 ] - then - let FAN_UNPLUG_NUM=FAN_UNPLUG_NUM+1 - fi -done <<< "$FAN_ARR" -SECOND_READ=$FAN_UNPLUG_NUM - -if [ $FIRST_READ -ne $SECOND_READ ] -then - #echo "not equl:$FIRST_READ != $SECOND_READ" - continue -fi - -if [ $FAN_UNPLUG_NUM -ge 2 ] -then - #echo "red @2Hz" - echo 7 > $CPLD_ADDR/red_led - echo 0 > $CPLD_ADDR/grn_led - sleep 1 - continue -elif [ $FAN_UNPLUG_NUM -eq 1 ] -then - #echo "solid red" - echo 3 > $CPLD_ADDR/red_led - echo 0 > $CPLD_ADDR/grn_led - sleep 1 - continue -fi - - #echo "normal" - psu0var=$(cat $CPLD_ADDR/psu0) # bottom PSU - psu1var=$(cat $CPLD_ADDR/psu1) # top PSU - - if [ "$psu0var" = "$normal" ] && - [ "$psu1var" = "$normal" ] # PSU normal operatio - then - #echo "solid green" - echo 7 > $CPLD_ADDR/grn_led - echo 0 > $CPLD_ADDR/red_led - else - if [ "$psu0var" = "$unpowered" ] || - [ "$psu1var" = "$unpowered" ] - then - #echo "grn @2Hz" - echo 3 > $CPLD_ADDR/grn_led - echo 0 > $CPLD_ADDR/red_led - fi - - fi - - -sleep 1 -done - diff --git a/packages/platforms/inventec/x86-64/d5264q28b/platform-config/r0/src/lib/x86-64-inventec-d5264q28b-r0.yml b/packages/platforms/inventec/x86-64/d5264q28b/platform-config/r0/src/lib/x86-64-inventec-d5264q28b-r0.yml deleted file mode 100644 index d332a026a..000000000 --- a/packages/platforms/inventec/x86-64/d5264q28b/platform-config/r0/src/lib/x86-64-inventec-d5264q28b-r0.yml +++ /dev/null @@ -1,31 +0,0 @@ ---- - -###################################################################### -# -# platform-config for d5264q28b -# -###################################################################### - -x86-64-inventec-d5264q28b-r0: - - grub: - - serial: >- - --port=0x3f8 - --speed=115200 - --word=8 - --parity=no - --stop=1 - - kernel: - <<: *kernel-4-14 - - args: >- - nopat - console=ttyS0,115200n8 - - ##network - ## interfaces: - ## ma1: - ## name: ~ - ## syspath: pci0000:00/0000:00:14.0 diff --git a/packages/platforms/inventec/x86-64/d5264q28b/platform-config/r0/src/python/x86_64_inventec_d5264q28b_r0/__init__.py b/packages/platforms/inventec/x86-64/d5264q28b/platform-config/r0/src/python/x86_64_inventec_d5264q28b_r0/__init__.py deleted file mode 100644 index bbc055f87..000000000 --- a/packages/platforms/inventec/x86-64/d5264q28b/platform-config/r0/src/python/x86_64_inventec_d5264q28b_r0/__init__.py +++ /dev/null @@ -1,40 +0,0 @@ -from onl.platform.base import * -from onl.platform.inventec import * - -class OnlPlatform_x86_64_inventec_d5264q28b_r0(OnlPlatformInventec, - OnlPlatformPortConfig_64x100): - PLATFORM='x86-64-inventec-d5264q28b-r0' - MODEL="D5264Q28B" - 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') - os.system("echo pca9548 0x70 > /sys/bus/i2c/devices/i2c-0/new_device") - os.system("sleep 1") - os.system("echo pca9548 0x71 > /sys/bus/i2c/devices/i2c-8/new_device") - os.system("sleep 1") - #Upper - os.system("echo pca9548 0x72 > /sys/bus/i2c/devices/i2c-1/new_device") - os.system("echo pca9548 0x72 > /sys/bus/i2c/devices/i2c-2/new_device") - os.system("echo pca9548 0x72 > /sys/bus/i2c/devices/i2c-3/new_device") - os.system("echo pca9548 0x72 > /sys/bus/i2c/devices/i2c-4/new_device") - os.system("sleep 1") - #Lower - os.system("echo pca9548 0x72 > /sys/bus/i2c/devices/i2c-9/new_device") - os.system("echo pca9548 0x72 > /sys/bus/i2c/devices/i2c-10/new_device") - os.system("echo pca9548 0x72 > /sys/bus/i2c/devices/i2c-11/new_device") - os.system("echo pca9548 0x72 > /sys/bus/i2c/devices/i2c-12/new_device") - - self.insmod('inv_psoc') - os.system("echo inv_cpld 0x55 > /sys/bus/i2c/devices/i2c-0/new_device") - os.system("echo inv_cpld 0x77 > /sys/bus/i2c/devices/i2c-0/new_device") - self.insmod('inv_cpld') - self.insmod('swps') - self.insmod('inv_eeprom') - self.new_i2c_device('inv_eeprom', 0x53, 0) - - os.system("/lib/platform-config/x86-64-inventec-d5264q28b-r0/onl/healthstatus.sh &") - - return True diff --git a/packages/platforms/inventec/x86-64/d6254qs/Makefile b/packages/platforms/inventec/x86-64/d6254qs/Makefile deleted file mode 100644 index 003238cf6..000000000 --- a/packages/platforms/inventec/x86-64/d6254qs/Makefile +++ /dev/null @@ -1 +0,0 @@ -include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/inventec/x86-64/d6254qs/modules/Makefile b/packages/platforms/inventec/x86-64/d6254qs/modules/Makefile deleted file mode 100644 index 003238cf6..000000000 --- a/packages/platforms/inventec/x86-64/d6254qs/modules/Makefile +++ /dev/null @@ -1 +0,0 @@ -include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/inventec/x86-64/d6254qs/modules/PKG.yml b/packages/platforms/inventec/x86-64/d6254qs/modules/PKG.yml deleted file mode 100644 index dbef625ec..000000000 --- a/packages/platforms/inventec/x86-64/d6254qs/modules/PKG.yml +++ /dev/null @@ -1 +0,0 @@ -!include $ONL_TEMPLATES/platform-modules.yml VENDOR=inventec BASENAME=x86-64-inventec-d6254qs ARCH=amd64 KERNELS="onl-kernel-3.16-lts-x86-64-all:amd64" diff --git a/packages/platforms/inventec/x86-64/d6254qs/modules/builds/.gitignore b/packages/platforms/inventec/x86-64/d6254qs/modules/builds/.gitignore deleted file mode 100644 index a65b41774..000000000 --- a/packages/platforms/inventec/x86-64/d6254qs/modules/builds/.gitignore +++ /dev/null @@ -1 +0,0 @@ -lib diff --git a/packages/platforms/inventec/x86-64/d6254qs/modules/builds/Makefile b/packages/platforms/inventec/x86-64/d6254qs/modules/builds/Makefile deleted file mode 100644 index ffa0935a6..000000000 --- a/packages/platforms/inventec/x86-64/d6254qs/modules/builds/Makefile +++ /dev/null @@ -1,6 +0,0 @@ -KERNELS := onl-kernel-3.16-lts-x86-64-all:amd64 -KMODULES := src -VENDOR := inventec -BASENAME := x86-64-inventec-d6254qs -ARCH := x86_64 -include $(ONL)/make/kmodule.mk diff --git a/packages/platforms/inventec/x86-64/d6254qs/modules/builds/src/Makefile b/packages/platforms/inventec/x86-64/d6254qs/modules/builds/src/Makefile deleted file mode 100644 index 89083aad3..000000000 --- a/packages/platforms/inventec/x86-64/d6254qs/modules/builds/src/Makefile +++ /dev/null @@ -1,9 +0,0 @@ -obj-m += inv_platform.o -obj-m += inv_cpld.o -obj-m += inv_psoc.o -obj-m += gpio-ich.o -obj-m += swps.o -swps-objs := inv_swps.o io_expander.o transceiver.o inv_mux.o -# obj-m += vpd.o -# vpd-objs := inv_vpd.o onie_tlvinfo.o -# obj-m += lpc_ich.o diff --git a/packages/platforms/inventec/x86-64/d6254qs/modules/builds/src/gpio-ich.c b/packages/platforms/inventec/x86-64/d6254qs/modules/builds/src/gpio-ich.c deleted file mode 100644 index d1ad794de..000000000 --- a/packages/platforms/inventec/x86-64/d6254qs/modules/builds/src/gpio-ich.c +++ /dev/null @@ -1,567 +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 -#include "lpc_ich.h" - -#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 = 0;//el6661 -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."); - -#define CONFIG_INVENTEC_MAGNOLIA (1) - -#ifdef CONFIG_INVENTEC_MAGNOLIA -//inventec set default suspend well output value -//0x0B09E000; -#define DEFAULT_SUS_WELL_OUT_LVL_MAGNOLIA ((1<<13) | (1<<14) | (1<<15) | (1<<16) | (1<<24) | (1<<25) | (1<<27) ) - -static int modparam_out_gpio_default = DEFAULT_SUS_WELL_OUT_LVL_MAGNOLIA; -module_param_named(out_gpio_default, modparam_out_gpio_default, int, 0444); -MODULE_PARM_DESC(out_gpio_default, "default suspend output gpio level."); -#endif - -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: - -#ifdef CONFIG_INVENTEC_MAGNOLIA - printk("out_lvl_value = 0x%08x\n", modparam_out_gpio_default); - ichx_priv.outlvl_cache[1] = modparam_out_gpio_default; -#endif - - 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/d6254qs/modules/builds/src/inv_cpld.c b/packages/platforms/inventec/x86-64/d6254qs/modules/builds/src/inv_cpld.c deleted file mode 100644 index 683ffa0ff..000000000 --- a/packages/platforms/inventec/x86-64/d6254qs/modules/builds/src/inv_cpld.c +++ /dev/null @@ -1,415 +0,0 @@ -/* - * 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/d6254qs/modules/builds/src/inv_mux.c b/packages/platforms/inventec/x86-64/d6254qs/modules/builds/src/inv_mux.c deleted file mode 100644 index 53ea6375b..000000000 --- a/packages/platforms/inventec/x86-64/d6254qs/modules/builds/src/inv_mux.c +++ /dev/null @@ -1,274 +0,0 @@ -#include -#include -#include -#include -#include -#include "io_expander.h" -#include "inv_mux.h" - -static struct mux_obj_s *mux_head_p = NULL; - - -/* ========== MUX object functions ========== - */ -int -_common_force_pull_gpio(int mem_addr, - int input, - int bit_offset){ - - unsigned int val = 0; - unsigned int targ = 0; - - /* Get current value */ - val = inl(mem_addr); - if (val == 0) { - SWPS_ERR("%s: inl:%d fail!\n", __func__, val); - return -1; - } - /* Count target value */ - switch (input) { - case 0: /* Pull Low */ - targ = (val & (~(1 << bit_offset))); - break; - case 1: /* Pull high */ - targ = (val | (1 << bit_offset)); - break; - default: - SWPS_ERR("%s: input state:%d incorrect!\n", - __func__, input); - return -1; - } - /* Setup gpio */ - outl(targ, mem_addr); - if (targ != inl(mem_addr)){ - SWPS_ERR("%s: outl:%d fail!\n", __func__, targ); - return -1; - } - SWPS_DEBUG("%s: done.\n", __func__); - return 0; -} - - -int -rangeley_force_pull_high(struct mux_obj_s *self){ - SWPS_ERR("%s: not ready!\n", __func__); - return -1; -} - - -int -rangeley_force_pull_low(struct mux_obj_s *self){ - SWPS_ERR("%s: not ready!\n", __func__); - return -1; -} - - -int -hedera_force_pull_high(struct mux_obj_s *self){ - return _common_force_pull_gpio(MUX_RST_MEM_ADDR_HEDERA, 1, 5); -} - - -int -hedera_force_pull_low(struct mux_obj_s *self){ - return _common_force_pull_gpio(MUX_RST_MEM_ADDR_HEDERA, 0, 5); -} - - -int -normal_gpio_pull_high(struct mux_obj_s *self){ - return gpio_direction_output(self->gpio_num, 1); -} - - -int -normal_gpio_pull_low(struct mux_obj_s *self){ - return gpio_direction_output(self->gpio_num, 0); -} - - -int -pca9548_reset_mux_all(struct mux_obj_s *self){ - /* [Note] Power-on reset (PCA9548A-NXP) - * When power is applied to VDD, an internal Power-On Reset (POR) - * holds the PCA9548A in a reset condition until VDD has reached - * VPOR. At this point, the reset condition is released and the - * PCA9548A register and I2C-bus state machine are initialized to - * their default states (all zeroes) causing all the channels to - * be deselected. Thereafter, VDD must be lowered below 0.2 V for - * at least 5 us in order to reset the device. - */ - if (self->_pull_low(self) < 0) { - SWPS_ERR("%s: _pull_low fail!\n", __func__); - return -1; - } - mdelay(MUX_RST_WAIT_MS); - if (self->_pull_high(self) < 0) { - SWPS_ERR("%s: _pull_high fail!\n", __func__); - return -1; - } - mdelay(MUX_RST_WAIT_MS); - return 0; -} - - -int -common_reset_mux_all(struct mux_obj_s *self){ - SWPS_ERR("%s: not ready!\n", __func__); - return -1; -} - - -int -init_gpio_4_force(struct mux_obj_s *self){ - return 0; -} - - -int -init_gpio_4_normal(struct mux_obj_s *self){ - - int err = 0; - - if (!gpio_is_valid(self->gpio_num)) { - SWPS_ERR("%s: GIPO:%d isn't valid\n", __func__, self->gpio_num); - return -1; - } - err = gpio_request(self->gpio_num, MUX_GPIO_LABEL); - if (err < 0) { - SWPS_ERR("%s: gpio_request fail :%d :%d\n", - __func__, err, self->gpio_num); - return -1; - } - SWPS_DEBUG("%s: gpio_request:%d ok.\n", __func__, self->gpio_num); - return 0; -} - - -static int -_setup_muxctl_cb(struct mux_obj_s *self, - unsigned gpio){ - - char mod_dsc[32] = "ERR"; - - switch (gpio) { - case MUX_RST_GPIO_FORCE_RANGELEY: - self->gpio_num = gpio; - self->_pull_low = rangeley_force_pull_low; - self->_pull_high = rangeley_force_pull_high; - self->_init = init_gpio_4_force; - self->reset = pca9548_reset_mux_all; - memset(mod_dsc, 0, 32); - snprintf(mod_dsc, 31, "Rangeley force mode"); - goto ok_setup_muxctl_cb; - - case MUX_RST_GPIO_FORCE_HEDERA: - self->gpio_num = gpio; - self->_pull_low = hedera_force_pull_low; - self->_pull_high = hedera_force_pull_high; - self->_init = init_gpio_4_force; - self->reset = pca9548_reset_mux_all; - memset(mod_dsc, 0, 32); - snprintf(mod_dsc, 31, "Hedera force mode"); - goto ok_setup_muxctl_cb; - - case MUX_RST_GPIO_48_PAC9548: - case MUX_RST_GPIO_69_PAC9548: - case MUX_RST_GPIO_249_PCA9548: - case MUX_RST_GPIO_505_PCA9548: - self->gpio_num = gpio; - self->_pull_low = normal_gpio_pull_low; - self->_pull_high = normal_gpio_pull_high; - self->_init = init_gpio_4_normal; - self->reset = pca9548_reset_mux_all; - memset(mod_dsc, 0, 32); - snprintf(mod_dsc, 31, "Normal mode :%d", (int)gpio); - goto ok_setup_muxctl_cb; - - default: - break; - } - SWPS_ERR("%s: Unexpected GPIO:%d\n", __func__, gpio); - return -1; - -ok_setup_muxctl_cb: - SWPS_INFO("muxctl: %s.\n", mod_dsc); - return 0; -} - - -/* ========== MUX public functions ========== - */ -void -clean_mux_gpio(void){ - - if (!mux_head_p) { - SWPS_DEBUG("%s: mux_head_p is NULL\n", __func__); - return; - } - if (gpio_is_valid(mux_head_p->gpio_num)) { - gpio_free(mux_head_p->gpio_num); - } - kfree(mux_head_p); - mux_head_p = NULL; - SWPS_DEBUG("%s: done.\n", __func__); -} - - -int -reset_mux_gpio(void){ - - if (!mux_head_p) { - SWPS_ERR("%s: MUX ctl object doesn't exist!\n", __func__); - return -1; - } - if (mux_head_p->reset(mux_head_p) < 0){ - SWPS_ERR("%s: reset fail!\n", __func__); - return -1; - } - return 0; -} - - -int -init_mux_gpio(unsigned gpio){ - - /* Create MUX control object */ - if (mux_head_p) { - SWPS_DEBUG("%s: mux_head_p is not NULL!\n", __func__); - clean_mux_gpio(); - } - /* Currently, it is using single muxctl architecture. - * In the future, it may use the multi-muxctl if HW add new features. - * (Ex: Port power-status control) - */ - mux_head_p = kzalloc(sizeof(struct mux_obj_s), GFP_KERNEL); - if (!mux_head_p) { - SWPS_ERR("%s: kzalloc fail!\n", __func__); - return -1; - } - /* Initial MUX controller */ - if (_setup_muxctl_cb(mux_head_p, gpio) < 0){ - SWPS_ERR("%s: _setup_muxctl_cb fail!\n", __func__); - return -1; - } - if (mux_head_p->_init(mux_head_p) < 0) { - SWPS_ERR("%s: init() fail\n", __func__); - goto err_init_mux_gpio; - } - /* Setup default value */ - if (mux_head_p->_pull_high(mux_head_p) < 0) { - SWPS_ERR("%s: setup default fail!\n", __func__); - goto err_init_mux_gpio; - } - return 0; - -err_init_mux_gpio: - clean_mux_gpio(); - return -1; -} - - - - - diff --git a/packages/platforms/inventec/x86-64/d6254qs/modules/builds/src/inv_mux.h b/packages/platforms/inventec/x86-64/d6254qs/modules/builds/src/inv_mux.h deleted file mode 100644 index e547d5c64..000000000 --- a/packages/platforms/inventec/x86-64/d6254qs/modules/builds/src/inv_mux.h +++ /dev/null @@ -1,39 +0,0 @@ -#ifndef INV_MUX_H -#define INV_MUX_H - - -/* MUX basic information */ -#define MUX_GPIO_LABEL "SWPS_RST_MUX" - -/* MUX reset GPIO define */ -#define MUX_RST_GPIO_FORCE (30100) -#define MUX_RST_GPIO_FORCE_RANGELEY (30101) -#define MUX_RST_GPIO_FORCE_HEDERA (30102) -#define MUX_RST_GPIO_48_PAC9548 (48) -#define MUX_RST_GPIO_69_PAC9548 (69) -#define MUX_RST_GPIO_249_PCA9548 (249) -#define MUX_RST_GPIO_505_PCA9548 (505) - -/* MUX relate value define */ -#define MUX_RST_WAIT_MS (1) -#define MUX_RST_MEM_ADDR_RANGELEY (0) // TBD -#define MUX_RST_MEM_ADDR_HEDERA (0x548) - -struct mux_obj_s { - unsigned gpio_num; - int (*_pull_high)(struct mux_obj_s *self); - int (*_pull_low)(struct mux_obj_s *self); - int (*_init)(struct mux_obj_s *self); - int (*reset)(struct mux_obj_s *self); -}; - - -void clean_mux_gpio(void); -int reset_mux_gpio(void); -int init_mux_gpio(unsigned gpio); - - -#endif /* INV_MUX_H */ - - - diff --git a/packages/platforms/inventec/x86-64/d6254qs/modules/builds/src/inv_platform.c b/packages/platforms/inventec/x86-64/d6254qs/modules/builds/src/inv_platform.c deleted file mode 100644 index 52e2a2379..000000000 --- a/packages/platforms/inventec/x86-64/d6254qs/modules/builds/src/inv_platform.c +++ /dev/null @@ -1,370 +0,0 @@ -#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; -}; - -///////////////////////////////////////////////////////////////////////////////////////// -static struct at24_platform_data at24c64_eeprom_data = { - .byte_len = 256,//SZ_64K/8 - .page_size = 1, - .flags = 0,//AT24_FLAG_ADDR8, -}; - -static int pca9555_setup(struct i2c_client *client, unsigned gpio, unsigned ngpio, void *context) -{ - //TBD - printk("%s : gpio=%d, ngpio=%d\n ", __func__, gpio, ngpio); - return 0; -} - -static struct pca954x_platform_mode mux_modes_0[] = { - {.adap_id = 2,}, {.adap_id = 3,}, - {.adap_id = 4,}, {.adap_id = 5,}, - {.adap_id = 6,}, {.adap_id = 7,}, - {.adap_id = 8,}, {.adap_id = 9,}, -}; -static struct pca954x_platform_mode mux_modes_0_0[] = { - {.adap_id = 10,}, {.adap_id = 11,}, - {.adap_id = 12,}, {.adap_id = 13,}, - {.adap_id = 14,}, {.adap_id = 15,}, - {.adap_id = 16,}, {.adap_id = 17,}, -}; - -static struct pca954x_platform_mode mux_modes_0_1[] = { - {.adap_id = 18,}, {.adap_id = 19,}, - {.adap_id = 20,}, {.adap_id = 21,}, - {.adap_id = 22,}, {.adap_id = 23,}, - {.adap_id = 24,}, {.adap_id = 25,}, -}; - -static struct pca954x_platform_mode mux_modes_0_2[] = { - {.adap_id = 26,}, {.adap_id = 27,}, - {.adap_id = 28,}, {.adap_id = 29,}, - {.adap_id = 30,}, {.adap_id = 31,}, - {.adap_id = 32,}, {.adap_id = 33,}, -}; - -static struct pca954x_platform_mode mux_modes_0_3[] = { - {.adap_id = 34,}, {.adap_id = 35,}, - {.adap_id = 36,}, {.adap_id = 37,}, - {.adap_id = 38,}, {.adap_id = 39,}, - {.adap_id = 40,}, {.adap_id = 41,}, -}; - -static struct pca954x_platform_mode mux_modes_0_4[] = { - {.adap_id = 42,}, {.adap_id = 43,}, - {.adap_id = 44,}, {.adap_id = 45,}, - {.adap_id = 46,}, {.adap_id = 47,}, - {.adap_id = 48,}, {.adap_id = 49,}, -}; - -static struct pca954x_platform_mode mux_modes_0_5[] = { - {.adap_id = 50,}, {.adap_id = 51,}, - {.adap_id = 52,}, {.adap_id = 53,}, - {.adap_id = 54,}, {.adap_id = 55,}, - {.adap_id = 56,}, {.adap_id = 57,}, -}; - -static struct pca954x_platform_mode mux_modes_0_6[] = { - {.adap_id = 58,}, {.adap_id = 59,}, - {.adap_id = 60,}, {.adap_id = 61,}, - {.adap_id = 62,}, {.adap_id = 63,}, - {.adap_id = 64,}, {.adap_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, -}; - - -#define IO_EXPAND_BASE_CHIP (IO_EXPAND_BASE) //64 -#define IO_EXPAND_BASE_CHIP00 (IO_EXPAND_BASE + IO_EXPAND_NGPIO) -#define IO_EXPAND_BASE_CHIP01 (IO_EXPAND_BASE_CHIP00 + IO_EXPAND_NGPIO) -#define IO_EXPAND_BASE_CHIP10 (IO_EXPAND_BASE_CHIP01 + IO_EXPAND_NGPIO) -#define IO_EXPAND_BASE_CHIP11 (IO_EXPAND_BASE_CHIP10 + IO_EXPAND_NGPIO) -#define IO_EXPAND_BASE_CHIP20 (IO_EXPAND_BASE_CHIP11 + IO_EXPAND_NGPIO) -#define IO_EXPAND_BASE_CHIP21 (IO_EXPAND_BASE_CHIP20 + IO_EXPAND_NGPIO) -#define IO_EXPAND_BASE_CHIP30 (IO_EXPAND_BASE_CHIP21 + IO_EXPAND_NGPIO) -#define IO_EXPAND_BASE_CHIP31 (IO_EXPAND_BASE_CHIP30 + IO_EXPAND_NGPIO) -#define IO_EXPAND_BASE_CHIP40 (IO_EXPAND_BASE_CHIP31 + IO_EXPAND_NGPIO) -#define IO_EXPAND_BASE_CHIP41 (IO_EXPAND_BASE_CHIP40 + IO_EXPAND_NGPIO) -#define IO_EXPAND_BASE_CHIP50 (IO_EXPAND_BASE_CHIP41 + IO_EXPAND_NGPIO) -#define IO_EXPAND_BASE_CHIP51 (IO_EXPAND_BASE_CHIP50 + IO_EXPAND_NGPIO) -#define IO_EXPAND_BASE_CHIP60 (IO_EXPAND_BASE_CHIP51 + IO_EXPAND_NGPIO) -#define IO_EXPAND_BASE_CHIP61 (IO_EXPAND_BASE_CHIP60 + IO_EXPAND_NGPIO) - -static struct pca953x_platform_data pca9555_data = { - .gpio_base = IO_EXPAND_BASE_CHIP, - .setup = pca9555_setup, -}; - -#if 0 -static struct pca953x_platform_data pca9555_data00 = { - .gpio_base = IO_EXPAND_BASE_CHIP00, - .setup = pca9555_setup, -}; -static struct pca953x_platform_data pca9555_data01 = { - .gpio_base = IO_EXPAND_BASE_CHIP01, - .setup = pca9555_setup, -}; -static struct pca953x_platform_data pca9555_data10 = { - .gpio_base = IO_EXPAND_BASE_CHIP10, - .setup = pca9555_setup, -}; -static struct pca953x_platform_data pca9555_data11 = { - .gpio_base = IO_EXPAND_BASE_CHIP11, - .setup = pca9555_setup, -}; -static struct pca953x_platform_data pca9555_data20 = { - .gpio_base = IO_EXPAND_BASE_CHIP20, - .setup = pca9555_setup, -}; -static struct pca953x_platform_data pca9555_data21 = { - .gpio_base = IO_EXPAND_BASE_CHIP21, - .setup = pca9555_setup, -}; -static struct pca953x_platform_data pca9555_data30 = { - .gpio_base = IO_EXPAND_BASE_CHIP30, - .setup = pca9555_setup, -}; -static struct pca953x_platform_data pca9555_data31 = { - .gpio_base = IO_EXPAND_BASE_CHIP31, - .setup = pca9555_setup, -}; -static struct pca953x_platform_data pca9555_data40 = { - .gpio_base = IO_EXPAND_BASE_CHIP40, - .setup = pca9555_setup, -}; -static struct pca953x_platform_data pca9555_data41 = { - .gpio_base = IO_EXPAND_BASE_CHIP41, - .setup = pca9555_setup, -}; -static struct pca953x_platform_data pca9555_data50 = { - .gpio_base = IO_EXPAND_BASE_CHIP50, - .setup = pca9555_setup, -}; -static struct pca953x_platform_data pca9555_data51 = { - .gpio_base = IO_EXPAND_BASE_CHIP51, - .setup = pca9555_setup, -}; -static struct pca953x_platform_data pca9555_data60 = { - .gpio_base = IO_EXPAND_BASE_CHIP60, - .setup = pca9555_setup, -}; -static struct pca953x_platform_data pca9555_data61 = { - .gpio_base = IO_EXPAND_BASE_CHIP61, - .setup = pca9555_setup, -}; -#endif - -static struct i2c_board_info xlp_i2c_device_info0[] __initdata = { -// {"24c02", 0, 0x57, &at24c64_eeprom_data, 0, 0}, //VPD - {"inv_psoc", 0, 0x66, 0, 0, 0},//psoc - {"inv_cpld", 0, 0x55, 0, 0, 0},//cpld - {"pca9555", 0, 0x22, &pca9555_data, 0, 0}, - {"pca9548", 0, 0x71, &mux_data_0, 0, 0}, -}; - -static struct i2c_board_info xlp_i2c_device_info1[] __initdata = { - {"inv_psoc", 0, 0x66, 0, 0, 0},//psoc - {"inv_cpld", 0, 0x55, 0, 0, 0},//cpld -}; - -static struct i2c_board_info xlp_i2c_device_info2[] __initdata = { - {"pca9548", 0, 0x72, &mux_data_0_0, 0, 0}, -// {"pca9555", 0, 0x20, &pca9555_data00, 0, 0}, -// {"pca9555", 0, 0x21, &pca9555_data01, 0, 0}, -}; - -static struct i2c_board_info xlp_i2c_device_info3[] __initdata = { - {"pca9548", 0, 0x72, &mux_data_0_1, 0, 0}, -// {"pca9555", 0, 0x20, &pca9555_data10, 0, 0}, -// {"pca9555", 0, 0x21, &pca9555_data11, 0, 0}, -}; - -static struct i2c_board_info xlp_i2c_device_info4[] __initdata = { - {"pca9548", 0, 0x72, &mux_data_0_2, 0, 0}, -// {"pca9555", 0, 0x20, &pca9555_data20, 0, 0}, -// {"pca9555", 0, 0x21, &pca9555_data21, 0, 0}, -}; - -static struct i2c_board_info xlp_i2c_device_info5[] __initdata = { - {"pca9548", 0, 0x72, &mux_data_0_3, 0, 0}, -// {"pca9555", 0, 0x20, &pca9555_data30, 0, 0}, -// {"pca9555", 0, 0x21, &pca9555_data31, 0, 0}, -}; -static struct i2c_board_info xlp_i2c_device_info6[] __initdata = { - {"pca9548", 0, 0x72, &mux_data_0_4, 0, 0}, -// {"pca9555", 0, 0x20, &pca9555_data40, 0, 0}, -// {"pca9555", 0, 0x21, &pca9555_data41, 0, 0}, -}; -static struct i2c_board_info xlp_i2c_device_info7[] __initdata = { - {"pca9548", 0, 0x72, &mux_data_0_5, 0, 0}, -// {"pca9555", 0, 0x20, &pca9555_data50, 0, 0}, -// {"pca9555", 0, 0x21, &pca9555_data51, 0, 0}, -}; -static struct i2c_board_info xlp_i2c_device_info8[] __initdata = { - {"pca9548", 0, 0x72, &mux_data_0_6, 0, 0}, -// {"pca9555", 0, 0x20, &pca9555_data60, 0, 0}, -// {"pca9555", 0, 0x21, &pca9555_data61, 0, 0}, -}; - - -static struct inv_i2c_board_info i2cdev_list[] = { - {0, ARRAY_SIZE(xlp_i2c_device_info0), xlp_i2c_device_info0 }, //smbus 0 -// {1, ARRAY_SIZE(xlp_i2c_device_info1), xlp_i2c_device_info1 }, //smbus 1 or gpio11+12 - - {2, ARRAY_SIZE(xlp_i2c_device_info2), xlp_i2c_device_info2 }, //mux 0 - {3, ARRAY_SIZE(xlp_i2c_device_info3), xlp_i2c_device_info3 }, //mux 1 - {4, ARRAY_SIZE(xlp_i2c_device_info4), xlp_i2c_device_info4 }, //mux 2 - {5, ARRAY_SIZE(xlp_i2c_device_info5), xlp_i2c_device_info5 }, //mux 3 - {6, ARRAY_SIZE(xlp_i2c_device_info6), xlp_i2c_device_info6 }, //mux 4 - {7, ARRAY_SIZE(xlp_i2c_device_info7), xlp_i2c_device_info7 }, //mux 5 - {8, ARRAY_SIZE(xlp_i2c_device_info8), xlp_i2c_device_info8 }, //mux 6 -}; - -///////////////////////////////////////////////////////////////////////////////////////// -#if 0 -static struct i2c_gpio_platform_data i2c_gpio_platdata = { - .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 platform_device magnolia_device_i2c_gpio = { - .name = "i2c-gpio", - .id = 0, // adapter number - .dev.platform_data = &i2c_gpio_platdata, -}; -#endif - -#define PLAT_MAX_I2C_CLIENTS 32 -static struct i2c_client *plat_i2c_client[PLAT_MAX_I2C_CLIENTS]; -static int num_i2c_clients = 0; -static int plat_i2c_client_add(struct i2c_client *e) -{ - if (num_i2c_clients >= PLAT_MAX_I2C_CLIENTS) - return -1; - - plat_i2c_client[num_i2c_clients] = e; - num_i2c_clients++; - return num_i2c_clients; -} - -static void plat_i2c_client_remove_all(void) -{ - int i; - for (i = num_i2c_clients-1; i >= 0; i--) - i2c_unregister_device(plat_i2c_client[i]); -} - -static int __init plat_magnolia_init(void) -{ - struct i2c_adapter *adap = NULL; - struct i2c_client *e = NULL; - int ret = 0; - int i,j; - - printk("el6661 plat_magnolia_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(&magnolia_device_i2c_gpio); - if (ret) { - printk(KERN_ERR "i2c-gpio: magnolia_device_i2c_gpio register fail %d\n", ret); - } -#endif - - for(i=0; i -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -//#include "I2CHostCommunication.h" -#include -#include -#include -#include -#define SWITCH_TEMPERATURE_SOCK "/proc/switch/temp" - -#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; - - u8 psu1_vendor[16]; - u8 psu2_vendor[16]; - u8 psu1_model[20]; - u8 psu2_model[20]; - u8 psu1_version[8]; - u8 psu2_version[8]; - u8 psu1_date[6]; - u8 psu2_date[6]; - u8 psu1_sn[20]; - u8 psu2_sn[20]; -}; - -struct clei{ - u8 issue_number[3]; - u8 abbreviation_number[9]; - u8 fc_number[10]; - u8 clei_code[10]; - u8 product_year_and_month[5]; - u8 label_location_code[2]; - u8 serial_number[5]; - u8 pcb_revision[5]; - u8 vendor_name[10]; - u8 reserved[5]; -}; - -struct __attribute__ ((__packed__)) psoc_layout { - u8 ctl; //offset: 0 - u16 switch_temp; //offset: 1 - u8 psu_eepromtype; //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 - u8 reserved[0xff-0xfd]; - - struct clei clei[6]; //FAN:0~3 PSU:4~5; -}; - -/* 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 PSU_EEPROMTYPE_OFFSET PSOC_OFF(psu_eepromtype) -#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) - -#define CLEI_OFF(m) offsetof(struct clei, m) -#define FAN1_CLEI_INDEX 0 -#define FAN2_CLEI_INDEX 1 -#define FAN3_CLEI_INDEX 2 -#define FAN4_CLEI_INDEX 3 -#define PSU1_CLEI_INDEX 4 -#define PSU2_CLEI_INDEX 5 -#define CLEIALL_INDEX 0 -#define ISSUENUMBER_INDEX 1 -#define ABBREVIATION_INDEX 2 -#define FCNUMBER_INDEX 3 -#define CLEICODE_INDEX 4 -#define PRODUCTDATE_INDEX 5 -#define LABELLOCATION_INDX 6 -#define SERIALNUMBER_INDEX 7 -#define PCBREVISION_INDEX 8 -#define VENDORNAME_INDEX 9 - -/* Each client has this additional data */ -struct psoc_data { - struct device *hwmon_dev; - struct mutex update_lock; - u32 diag; - u8 psoc_mode; - struct task_struct *auto_update; -}; - -static int modparam_psocmode = 0; /* auto */ -module_param_named(psoc_mode, modparam_psocmode, int, 0444); -MODULE_PARM_DESC(psoc_mode, "The psoc_mode 0 means auto-detect, which is the default."); -/*-----------------------------------------------------------------------*/ - -static ssize_t psoc_i2c_read(struct i2c_client *client, u8 *buf, u16 offset, size_t count) -{ -#if USE_SMBUS - int i; - struct psoc_data *data = i2c_get_clientdata(client); - for(i=0; ipsoc_mode==2) { - i2c_smbus_write_byte_data(client, ((offset+i) >> 8), ((offset+i) & 0xff)); - buf[i] = i2c_smbus_read_byte(client); - } - else { - buf[i] = i2c_smbus_read_byte_data(client, offset+i); - } - } - - return count; -#else - struct i2c_msg msg[2]; - char msgbuf[2]; - int status; - - memset(msg, 0, sizeof(msg)); - - msgbuf[0] = offset >> 8 ; - msgbuf[1] = offset & 0xff; - - msg[0].addr = client->addr; - msg[0].buf = msgbuf; - msg[0].len = 2; - - 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, u16 offset, size_t count) -{ -#if USE_SMBUS - int i; - struct psoc_data *data = i2c_get_clientdata(client); - for(i=0; ipsoc_mode==2) { - i2c_smbus_write_word_data(client, ((offset+i) >> 8), ((offset+i) & 0xff) | (buf[i] << 8)); - } - else { - i2c_smbus_write_byte_data(client, offset+i, buf[i]); - } - } - return count; -#else - struct i2c_msg msg; - int status; - u8 writebuf[256]; - - int i = 0; - - msg.addr = client->addr; - msg.flags = 0; - - /* msg.buf is u8 and casts will mask the values */ - msg.buf = writebuf; - - msg.buf[i++] = offset >> 8; - msg.buf[i++] = offset & 0xff; - 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, u16 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, u16 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) -#if 0 -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 | PSOC_PMB_SEL; /* the start bit for the PM bus */ - 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; -} -#endif -static ssize_t show_clei(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 device_index = attr->index & 0xFF; - u8 clei_index = (attr->index >> 8) & 0xFF; - u16 offset = PSOC_OFF(clei) + sizeof(struct clei)* device_index; - u8 len; - u8 rxbuf[sizeof(struct clei)] = {0}; -// u8 rxbuf1[21] = {0}; -// u8 counter = 0; -// u8 count = 0; -// u8 index = 0; - switch (clei_index) - { - case CLEIALL_INDEX: - offset += 0; - len = sizeof(struct clei); - break; - case ISSUENUMBER_INDEX: - offset += CLEI_OFF(issue_number); - len = sizeof((struct clei){0}.issue_number); - break; - case ABBREVIATION_INDEX: - offset += CLEI_OFF(abbreviation_number); - len = sizeof((struct clei){0}.abbreviation_number); - break; - case FCNUMBER_INDEX: - offset += CLEI_OFF(fc_number); - len = sizeof((struct clei){0}.fc_number); - break; - case CLEICODE_INDEX: - offset += CLEI_OFF(clei_code); - len = sizeof((struct clei){0}.clei_code); - break; - case PRODUCTDATE_INDEX: - offset += CLEI_OFF(product_year_and_month); - len = sizeof((struct clei){0}.product_year_and_month); - break; - case LABELLOCATION_INDX: - offset += CLEI_OFF(label_location_code); - len = sizeof((struct clei){0}.label_location_code); - break; - case SERIALNUMBER_INDEX: - offset += CLEI_OFF(serial_number); - len = sizeof((struct clei){0}.serial_number); - break; - case PCBREVISION_INDEX: - offset += CLEI_OFF(pcb_revision); - len = sizeof((struct clei){0}.pcb_revision); - break; - case VENDORNAME_INDEX: - offset += CLEI_OFF(vendor_name); - len = sizeof((struct clei){0}.vendor_name); - break; - default: - return 0; - } - - if(data->psoc_mode==2) - { - mutex_lock(&data->update_lock); - status = psoc_i2c_read(client,rxbuf,offset,len); - mutex_unlock(&data->update_lock); - } - - - if(clei_index==CLEIALL_INDEX) - { - if (strncmp(&rxbuf[CLEI_OFF(vendor_name)], "FUJITSU", 7) == 0) { - status = sprintf (buf, "Issue Number: %.3s\n", &rxbuf[CLEI_OFF(issue_number)]); - status = sprintf (buf, "%sAbbreviation Number: %.9s\n", buf, &rxbuf[CLEI_OFF(abbreviation_number)]); - status = sprintf (buf, "%sFC Number: %.10s\n", buf, &rxbuf[CLEI_OFF(fc_number)]); - status = sprintf (buf, "%sCLEI Code: %.10s\n", buf, &rxbuf[CLEI_OFF(clei_code)]); - status = sprintf (buf, "%sProduct Year and Month: %.5s\n", buf, &rxbuf[CLEI_OFF(product_year_and_month)]); - status = sprintf (buf, "%s2D Label Location Code: %.2s\n", buf, &rxbuf[CLEI_OFF(label_location_code)]); - status = sprintf (buf, "%sSerial Number: %.5s\n", buf, &rxbuf[CLEI_OFF(serial_number)]); - status = sprintf (buf, "%sPCB Revision: %.5s\n", buf, &rxbuf[CLEI_OFF(pcb_revision)]); - status = sprintf (buf, "%sVendor Name: %.10s\n", buf, &rxbuf[CLEI_OFF(vendor_name)]); - } - else { - status = sprintf (buf, "N/A\n"); - } - return strlen(buf); - } - else - { - if(rxbuf[0]==0x00 || rxbuf[0]==0xFF) return sprintf(buf, "NONE\n"); - return sprintf(buf, "%s \n",rxbuf); - } -} - -/* -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); - u16 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_psu_eepromtype(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 psu_eeprom_type = 0; - - mutex_lock(&data->update_lock); - status = psoc_i2c_read(client, (u8*)&psu_eeprom_type, PSU_EEPROMTYPE_OFFSET, 1); - mutex_unlock(&data->update_lock); - psu_eeprom_type=(psu_eeprom_type>>(attr->index))&0x0f; - if(psu_eeprom_type>3) psu_eeprom_type=0; - status = sprintf (buf, "%d\n", psu_eeprom_type); - - return strlen(buf); -} - -static ssize_t set_psu_eepromtype(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 psu_eeprom_type = simple_strtol(buf, NULL, 10); - if(psu_eeprom_type>2) psu_eeprom_type=0; - - mutex_lock(&data->update_lock); - psoc_i2c_read(client, (u8*)&value, PSU_EEPROMTYPE_OFFSET, 1); - value &= (0xf0>>(attr->index)); - value |= (psu_eeprom_type<index); - psoc_i2c_write(client, (u8*)&value,PSU_EEPROMTYPE_OFFSET, 1); - mutex_unlock(&data->update_lock); - - return count; -} - -static ssize_t show_psoc_mode(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); - - status = sprintf (buf, "%d\n", data->psoc_mode); - - return strlen(buf); -} - -static ssize_t set_psoc_mode(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 psocmode = simple_strtol(buf, NULL, 10); - - if(psocmode==1 || psocmode==2) data->psoc_mode = psocmode; - - 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; -} - -#if 0 -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 chip = (attr->index >> 16)? 0x59:0x58; - u8 bus = 1; - unsigned char value[2] = {0,0};; - - 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) ); -} -#endif - -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 & 0xFF) + PSU_INFO_OFFSET; - u8 len = (attr->index >> 8)& 0xFF; - u8 rxbuf[21] = {0}; - u8 rxbuf1[21] = {0}; - u8 counter = 0; - u8 count = 0; - u8 index = 0; - if (len == 2) - { - 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 )); - } - else - { - do - { - mutex_lock(&data->update_lock); - status = psoc_i2c_read(client,rxbuf,offset,len); - mutex_unlock(&data->update_lock); - mutex_lock(&data->update_lock); - status = psoc_i2c_read(client,rxbuf1,offset,len); - mutex_unlock(&data->update_lock); - counter++; - }while((strcmp(rxbuf,rxbuf1)!=0) || ((strlen(rxbuf)==0) && (counter <5))); - for(index = 0; index < len; index++) - { - if(rxbuf[index] == 0xFF) - count++; - } - if(len == count) - return sprintf(buf, "%s \n","ERROR"); - if(status ==0) - return sprintf(buf,"%s \n", "ERROR"); - else if((strlen(rxbuf)==0)) - return sprintf(buf, "%s \n", "N/A"); - else - return sprintf(buf, "%s \n",rxbuf); - } -} - -#define PSOC_POLLING_PERIOD 1000 -#define PSU_NOT_INSTALLED 7 -#define PSOC_WARNING(fmt, args...) printk( KERN_WARNING "[PSOC]" fmt, ##args) -static u8 psu_info[PSU_NUM]; -static u8 fan_info[FAN_NUM]; -static void get_init_psu_fan_status(struct i2c_client *client) -{ - struct psoc_data *data = i2c_get_clientdata(client); - u32 status = 0; - u8 byte = 0; - int i = 0; - mutex_lock(&data->update_lock); - status = psoc_i2c_read(client, &byte, PSOC_PSU_OFFSET,1); - mutex_unlock(&data->update_lock); - psu_info[0] = (byte >> 3) & 0x7; - psu_info[1] = (byte >> 0) & 0x7; - mutex_lock(&data->update_lock); - status = psoc_read8(client, FAN_GPI_OFFSET); - mutex_unlock(&data->update_lock); - for (i=0; i> i) & 0x01); - } -} - -static void check_fan_status(struct i2c_client *client) -{ - struct psoc_data *data = i2c_get_clientdata(client); - u32 status; - int i = 0; - u8 rst = 0; - mutex_lock(&data->update_lock); - status = psoc_read8(client, FAN_GPI_OFFSET); - mutex_unlock(&data->update_lock); - for (i = 0; i < FAN_NUM; i++) - { - rst = ((status >> i) & 0x01); - if(rst != fan_info[i]) - { - fan_info[i] = rst; - if (rst) - PSOC_WARNING("Detect FAN%d is removed \n",(i+1)); - else - PSOC_WARNING("Detect FAN%d is present \n",(i+1)); - } - } -} - -#if 0 -// [Remove] Bacuase cottonwood don't have PSU info -static void check_psu_status(struct i2c_client *client) -{ - static u8 psu_retry[]={0,0}; - struct psoc_data *data = i2c_get_clientdata(client); - u32 status; - u8 byte = 0; - u8 psu1, psu2; - mutex_lock(&data->update_lock); - status = psoc_i2c_read(client, &byte, PSOC_PSU_OFFSET, 1); - mutex_unlock(&data->update_lock); - psu1 = (byte >> 3) & 0x7; - psu2 = (byte >> 0) & 0x7; - if(psu1 != psu_info[0]) - { - if ((psu_retry[0]++)==0) { return; } - if (psu1 == PSU_NOT_INSTALLED) - PSOC_WARNING("Detect PSU1 is removed \n"); - else - PSOC_WARNING("Detect PSU1 is present \n"); - - psu_info[0] = psu1; - psu_retry[0] = 0; - } - if(psu2 != psu_info[1]) - { - if((psu_retry[1]++)==0) { return; } - if(psu2 == PSU_NOT_INSTALLED) - PSOC_WARNING("Detect PSU2 is removed \n"); - else - PSOC_WARNING("Detect PSU2 is present \n"); - - psu_info[1] = psu2; - psu_retry[1] = 0; - } -} - -static void check_switch_temp(struct i2c_client * client) -{ - struct psoc_data *data = i2c_get_clientdata(client); - static struct file *f; - mm_segment_t old_fs; - - set_fs(get_ds()); - f = filp_open(SWITCH_TEMPERATURE_SOCK,O_RDONLY,0644); - if(IS_ERR(f)) { - return; - } - else { - char temp_str[]={0,0,0,0,0,0,0}; - loff_t pos = 0; - u16 temp2 = 0; - old_fs = get_fs(); - set_fs(KERNEL_DS); - vfs_read(f, temp_str,6,&pos); - temp2 = ((simple_strtoul(temp_str,NULL,10)/1000) <<8 ) & 0xFF00 ; - mutex_lock(&data->update_lock); - psoc_i2c_write(client, (u8*)&temp2, SWITCH_TMP_OFFSET, 2); - mutex_unlock(&data->update_lock); - } - filp_close(f,NULL); - set_fs(old_fs); -} -#endif - -static int psoc_polling_thread(void *p) -{ - struct i2c_client *client = p; - get_init_psu_fan_status(client); - while (!kthread_should_stop()) - { -// check_psu_status(client); - check_fan_status(client); -// check_switch_temp(client); - set_current_state(TASK_INTERRUPTIBLE); - if(kthread_should_stop()) - break; - - schedule_timeout(msecs_to_jiffies(PSOC_POLLING_PERIOD)); - } - return 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); - -//CLEI -static SENSOR_DEVICE_ATTR(fan1_issue_number, S_IRUGO, show_clei, 0, FAN1_CLEI_INDEX | ISSUENUMBER_INDEX << 8 ); -static SENSOR_DEVICE_ATTR(fan2_issue_number, S_IRUGO, show_clei, 0, FAN2_CLEI_INDEX | ISSUENUMBER_INDEX << 8 ); -static SENSOR_DEVICE_ATTR(fan3_issue_number, S_IRUGO, show_clei, 0, FAN3_CLEI_INDEX | ISSUENUMBER_INDEX << 8 ); -static SENSOR_DEVICE_ATTR(fan4_issue_number, S_IRUGO, show_clei, 0, FAN4_CLEI_INDEX | ISSUENUMBER_INDEX << 8 ); -static SENSOR_DEVICE_ATTR(fan1_abbreviation_number, S_IRUGO, show_clei, 0, FAN1_CLEI_INDEX | ABBREVIATION_INDEX << 8 ); -static SENSOR_DEVICE_ATTR(fan2_abbreviation_number, S_IRUGO, show_clei, 0, FAN2_CLEI_INDEX | ABBREVIATION_INDEX << 8 ); -static SENSOR_DEVICE_ATTR(fan3_abbreviation_number, S_IRUGO, show_clei, 0, FAN3_CLEI_INDEX | ABBREVIATION_INDEX << 8 ); -static SENSOR_DEVICE_ATTR(fan4_abbreviation_number, S_IRUGO, show_clei, 0, FAN4_CLEI_INDEX | ABBREVIATION_INDEX << 8 ); -static SENSOR_DEVICE_ATTR(fan1_fc_number, S_IRUGO, show_clei, 0, FAN1_CLEI_INDEX | FCNUMBER_INDEX << 8 ); -static SENSOR_DEVICE_ATTR(fan2_fc_number, S_IRUGO, show_clei, 0, FAN2_CLEI_INDEX | FCNUMBER_INDEX << 8 ); -static SENSOR_DEVICE_ATTR(fan3_fc_number, S_IRUGO, show_clei, 0, FAN3_CLEI_INDEX | FCNUMBER_INDEX << 8 ); -static SENSOR_DEVICE_ATTR(fan4_fc_number, S_IRUGO, show_clei, 0, FAN4_CLEI_INDEX | FCNUMBER_INDEX << 8 ); -static SENSOR_DEVICE_ATTR(fan1_clei_code, S_IRUGO, show_clei, 0, FAN1_CLEI_INDEX | CLEICODE_INDEX << 8 ); -static SENSOR_DEVICE_ATTR(fan2_clei_code, S_IRUGO, show_clei, 0, FAN2_CLEI_INDEX | CLEICODE_INDEX << 8 ); -static SENSOR_DEVICE_ATTR(fan3_clei_code, S_IRUGO, show_clei, 0, FAN3_CLEI_INDEX | CLEICODE_INDEX << 8 ); -static SENSOR_DEVICE_ATTR(fan4_clei_code, S_IRUGO, show_clei, 0, FAN4_CLEI_INDEX | CLEICODE_INDEX << 8 ); -static SENSOR_DEVICE_ATTR(fan1_product_year_and_month, S_IRUGO, show_clei, 0, FAN1_CLEI_INDEX | PRODUCTDATE_INDEX << 8 ); -static SENSOR_DEVICE_ATTR(fan2_product_year_and_month, S_IRUGO, show_clei, 0, FAN2_CLEI_INDEX | PRODUCTDATE_INDEX << 8 ); -static SENSOR_DEVICE_ATTR(fan3_product_year_and_month, S_IRUGO, show_clei, 0, FAN3_CLEI_INDEX | PRODUCTDATE_INDEX << 8 ); -static SENSOR_DEVICE_ATTR(fan4_product_year_and_month, S_IRUGO, show_clei, 0, FAN4_CLEI_INDEX | PRODUCTDATE_INDEX << 8 ); -static SENSOR_DEVICE_ATTR(fan1_label_location_code, S_IRUGO, show_clei, 0, FAN1_CLEI_INDEX | LABELLOCATION_INDX << 8 ); -static SENSOR_DEVICE_ATTR(fan2_label_location_code, S_IRUGO, show_clei, 0, FAN2_CLEI_INDEX | LABELLOCATION_INDX << 8 ); -static SENSOR_DEVICE_ATTR(fan3_label_location_code, S_IRUGO, show_clei, 0, FAN3_CLEI_INDEX | LABELLOCATION_INDX << 8 ); -static SENSOR_DEVICE_ATTR(fan4_label_location_code, S_IRUGO, show_clei, 0, FAN4_CLEI_INDEX | LABELLOCATION_INDX << 8 ); -static SENSOR_DEVICE_ATTR(fan1_serial_number, S_IRUGO, show_clei, 0, FAN1_CLEI_INDEX | SERIALNUMBER_INDEX << 8 ); -static SENSOR_DEVICE_ATTR(fan2_serial_number, S_IRUGO, show_clei, 0, FAN2_CLEI_INDEX | SERIALNUMBER_INDEX << 8 ); -static SENSOR_DEVICE_ATTR(fan3_serial_number, S_IRUGO, show_clei, 0, FAN3_CLEI_INDEX | SERIALNUMBER_INDEX << 8 ); -static SENSOR_DEVICE_ATTR(fan4_serial_number, S_IRUGO, show_clei, 0, FAN4_CLEI_INDEX | SERIALNUMBER_INDEX << 8 ); -static SENSOR_DEVICE_ATTR(fan1_pcb_revision, S_IRUGO, show_clei, 0, FAN1_CLEI_INDEX | PCBREVISION_INDEX << 8 ); -static SENSOR_DEVICE_ATTR(fan2_pcb_revision, S_IRUGO, show_clei, 0, FAN2_CLEI_INDEX | PCBREVISION_INDEX << 8 ); -static SENSOR_DEVICE_ATTR(fan3_pcb_revision, S_IRUGO, show_clei, 0, FAN3_CLEI_INDEX | PCBREVISION_INDEX << 8 ); -static SENSOR_DEVICE_ATTR(fan4_pcb_revision, S_IRUGO, show_clei, 0, FAN4_CLEI_INDEX | PCBREVISION_INDEX << 8 ); -static SENSOR_DEVICE_ATTR(fan1_vendor_name, S_IRUGO, show_clei, 0, FAN1_CLEI_INDEX | VENDORNAME_INDEX << 8 ); -static SENSOR_DEVICE_ATTR(fan2_vendor_name, S_IRUGO, show_clei, 0, FAN2_CLEI_INDEX | VENDORNAME_INDEX << 8 ); -static SENSOR_DEVICE_ATTR(fan3_vendor_name, S_IRUGO, show_clei, 0, FAN3_CLEI_INDEX | VENDORNAME_INDEX << 8 ); -static SENSOR_DEVICE_ATTR(fan4_vendor_name, S_IRUGO, show_clei, 0, FAN4_CLEI_INDEX | VENDORNAME_INDEX << 8 ); -static SENSOR_DEVICE_ATTR(fan1_clei, S_IRUGO, show_clei, 0, FAN1_CLEI_INDEX | CLEIALL_INDEX << 8 ); -static SENSOR_DEVICE_ATTR(fan2_clei, S_IRUGO, show_clei, 0, FAN2_CLEI_INDEX | CLEIALL_INDEX << 8 ); -static SENSOR_DEVICE_ATTR(fan3_clei, S_IRUGO, show_clei, 0, FAN3_CLEI_INDEX | CLEIALL_INDEX << 8 ); -static SENSOR_DEVICE_ATTR(fan4_clei, S_IRUGO, show_clei, 0, FAN4_CLEI_INDEX | CLEIALL_INDEX << 8 ); - -static SENSOR_DEVICE_ATTR(psu1_issue_number, S_IRUGO, show_clei, 0, PSU1_CLEI_INDEX | ISSUENUMBER_INDEX << 8 ); -static SENSOR_DEVICE_ATTR(psu2_issue_number, S_IRUGO, show_clei, 0, PSU2_CLEI_INDEX | ISSUENUMBER_INDEX << 8 ); -static SENSOR_DEVICE_ATTR(psu1_abbreviation_number, S_IRUGO, show_clei, 0, PSU1_CLEI_INDEX | ABBREVIATION_INDEX << 8 ); -static SENSOR_DEVICE_ATTR(psu2_abbreviation_number, S_IRUGO, show_clei, 0, PSU2_CLEI_INDEX | ABBREVIATION_INDEX << 8 ); -static SENSOR_DEVICE_ATTR(psu1_fc_number, S_IRUGO, show_clei, 0, PSU1_CLEI_INDEX | FCNUMBER_INDEX << 8 ); -static SENSOR_DEVICE_ATTR(psu2_fc_number, S_IRUGO, show_clei, 0, PSU2_CLEI_INDEX | FCNUMBER_INDEX << 8 ); -static SENSOR_DEVICE_ATTR(psu1_clei_code, S_IRUGO, show_clei, 0, PSU1_CLEI_INDEX | CLEICODE_INDEX << 8 ); -static SENSOR_DEVICE_ATTR(psu2_clei_code, S_IRUGO, show_clei, 0, PSU2_CLEI_INDEX | CLEICODE_INDEX << 8 ); -static SENSOR_DEVICE_ATTR(psu1_product_year_and_month, S_IRUGO, show_clei, 0, PSU1_CLEI_INDEX | PRODUCTDATE_INDEX << 8 ); -static SENSOR_DEVICE_ATTR(psu2_product_year_and_month, S_IRUGO, show_clei, 0, PSU2_CLEI_INDEX | PRODUCTDATE_INDEX << 8 ); -static SENSOR_DEVICE_ATTR(psu1_label_location_code, S_IRUGO, show_clei, 0, PSU1_CLEI_INDEX | LABELLOCATION_INDX << 8 ); -static SENSOR_DEVICE_ATTR(psu2_label_location_code, S_IRUGO, show_clei, 0, PSU2_CLEI_INDEX | LABELLOCATION_INDX << 8 ); -static SENSOR_DEVICE_ATTR(psu1_serial_number, S_IRUGO, show_clei, 0, PSU1_CLEI_INDEX | SERIALNUMBER_INDEX << 8 ); -static SENSOR_DEVICE_ATTR(psu2_serial_number, S_IRUGO, show_clei, 0, PSU2_CLEI_INDEX | SERIALNUMBER_INDEX << 8 ); -static SENSOR_DEVICE_ATTR(psu1_pcb_revision, S_IRUGO, show_clei, 0, PSU1_CLEI_INDEX | PCBREVISION_INDEX << 8 ); -static SENSOR_DEVICE_ATTR(psu2_pcb_revision, S_IRUGO, show_clei, 0, PSU2_CLEI_INDEX | PCBREVISION_INDEX << 8 ); -static SENSOR_DEVICE_ATTR(psu1_vendor_name, S_IRUGO, show_clei, 0, PSU1_CLEI_INDEX | VENDORNAME_INDEX << 8 ); -static SENSOR_DEVICE_ATTR(psu2_vendor_name, S_IRUGO, show_clei, 0, PSU2_CLEI_INDEX | VENDORNAME_INDEX << 8 ); -static SENSOR_DEVICE_ATTR(psu1_clei, S_IRUGO, show_clei, 0, PSU1_CLEI_INDEX | CLEIALL_INDEX << 8 ); -static SENSOR_DEVICE_ATTR(psu2_clei, S_IRUGO, show_clei, 0, PSU2_CLEI_INDEX | CLEIALL_INDEX << 8 ); - -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(fan1_led_grn, S_IWUSR|S_IRUGO, show_fan_led, set_fan_led, 0); -static SENSOR_DEVICE_ATTR(fan2_led_grn, S_IWUSR|S_IRUGO, show_fan_led, set_fan_led, 1); -static SENSOR_DEVICE_ATTR(fan3_led_grn, S_IWUSR|S_IRUGO, show_fan_led, set_fan_led, 2); -static SENSOR_DEVICE_ATTR(fan4_led_grn, S_IWUSR|S_IRUGO, show_fan_led, set_fan_led, 3); -static SENSOR_DEVICE_ATTR(fan1_led_red, S_IWUSR|S_IRUGO, show_fan_led, set_fan_led, 4); -static SENSOR_DEVICE_ATTR(fan2_led_red, S_IWUSR|S_IRUGO, show_fan_led, set_fan_led, 5); -static SENSOR_DEVICE_ATTR(fan3_led_red, S_IWUSR|S_IRUGO, show_fan_led, set_fan_led, 6); -static SENSOR_DEVICE_ATTR(fan4_led_red, S_IWUSR|S_IRUGO, show_fan_led, set_fan_led, 7); - -static SENSOR_DEVICE_ATTR(psoc_psu1_eeprom_type, S_IWUSR|S_IRUGO, show_psu_eepromtype, set_psu_eepromtype, 0); -static SENSOR_DEVICE_ATTR(psoc_psu2_eeprom_type, S_IWUSR|S_IRUGO, show_psu_eepromtype, set_psu_eepromtype, 4); -static SENSOR_DEVICE_ATTR(psoc_mode, S_IWUSR|S_IRUGO, show_psoc_mode, set_psoc_mode, 0); - -static SENSOR_DEVICE_ATTR(fan_gpi, S_IRUGO, show_value8, 0, FAN_GPI_OFFSET); -#if 0 -static SENSOR_DEVICE_ATTR(psu1_vin, S_IRUGO, show_psu, 0, PMBUS_READ_VIN); -static SENSOR_DEVICE_ATTR(psu1_vout, S_IRUGO, show_psu, 0, PMBUS_READ_VOUT); -static SENSOR_DEVICE_ATTR(psu1_iin, S_IRUGO, show_psu, 0, PMBUS_READ_IIN); -static SENSOR_DEVICE_ATTR(psu1_iout, S_IRUGO, show_psu, 0, PMBUS_READ_IOUT); -static SENSOR_DEVICE_ATTR(psu1_pin, S_IRUGO, show_psu, 0, PMBUS_READ_PIN); -static SENSOR_DEVICE_ATTR(psu1_pout, S_IRUGO, show_psu, 0, PMBUS_READ_POUT); -static SENSOR_DEVICE_ATTR(psu2_vin, S_IRUGO, show_psu, 0, (1<<16) | PMBUS_READ_VIN); -static SENSOR_DEVICE_ATTR(psu2_vout, S_IRUGO, show_psu, 0, (1<<16) | PMBUS_READ_VOUT); -static SENSOR_DEVICE_ATTR(psu2_iin, S_IRUGO, show_psu, 0, (1<<16) | PMBUS_READ_IIN); -static SENSOR_DEVICE_ATTR(psu2_iout, S_IRUGO, show_psu, 0, (1<<16) | PMBUS_READ_IOUT); -static SENSOR_DEVICE_ATTR(psu2_pin, S_IRUGO, show_psu, 0, (1<<16) | PMBUS_READ_PIN); -static SENSOR_DEVICE_ATTR(psu2_pout, S_IRUGO, show_psu, 0, (1<<16) | PMBUS_READ_POUT); -#endif -static SENSOR_DEVICE_ATTR(psoc_psu1_vin, S_IRUGO, show_psu_psoc, 0, (0x02<<8)|PSOC_PSU_OFF(psu1_vin)); -static SENSOR_DEVICE_ATTR(psoc_psu1_vout, S_IRUGO, show_psu_psoc, 0, (0x02<<8)|PSOC_PSU_OFF(psu1_vout)); -static SENSOR_DEVICE_ATTR(psoc_psu1_iin, S_IRUGO, show_psu_psoc, 0, (0x02<<8)|PSOC_PSU_OFF(psu1_iin)); -static SENSOR_DEVICE_ATTR(psoc_psu1_iout, S_IRUGO, show_psu_psoc, 0, (0x02<<8)|PSOC_PSU_OFF(psu1_iout)); -static SENSOR_DEVICE_ATTR(psoc_psu1_pin, S_IRUGO, show_psu_psoc, 0, (0x02<<8)|PSOC_PSU_OFF(psu1_pin)); -static SENSOR_DEVICE_ATTR(psoc_psu1_pout, S_IRUGO, show_psu_psoc, 0, (0x02<<8)|PSOC_PSU_OFF(psu1_pout)); - - -static SENSOR_DEVICE_ATTR(psoc_psu2_vin, S_IRUGO, show_psu_psoc, 0, (0x02<<8)|PSOC_PSU_OFF(psu2_vin)); -static SENSOR_DEVICE_ATTR(psoc_psu2_vout, S_IRUGO, show_psu_psoc, 0, (0x02<<8)|PSOC_PSU_OFF(psu2_vout)); -static SENSOR_DEVICE_ATTR(psoc_psu2_iin, S_IRUGO, show_psu_psoc, 0, (0x02<<8)|PSOC_PSU_OFF(psu2_iin)); -static SENSOR_DEVICE_ATTR(psoc_psu2_iout, S_IRUGO, show_psu_psoc, 0, (0x02<<8)|PSOC_PSU_OFF(psu2_iout)); -static SENSOR_DEVICE_ATTR(psoc_psu2_pin, S_IRUGO, show_psu_psoc, 0, (0x02<<8)|PSOC_PSU_OFF(psu2_pin)); -static SENSOR_DEVICE_ATTR(psoc_psu2_pout, S_IRUGO, show_psu_psoc, 0, (0x02<<8)|PSOC_PSU_OFF(psu2_pout)); - -static SENSOR_DEVICE_ATTR(psoc_psu1_vendor, S_IRUGO, show_psu_psoc, 0, (0x10<<8)|PSOC_PSU_OFF(psu1_vendor)); -static SENSOR_DEVICE_ATTR(psoc_psu1_model, S_IRUGO, show_psu_psoc, 0, (0x14<<8)|PSOC_PSU_OFF(psu1_model)); -static SENSOR_DEVICE_ATTR(psoc_psu1_version, S_IRUGO, show_psu_psoc, 0, (0x08<<8)|PSOC_PSU_OFF(psu1_version)); -static SENSOR_DEVICE_ATTR(psoc_psu1_date, S_IRUGO, show_psu_psoc, 0, (0x06<<8)|PSOC_PSU_OFF(psu1_date)); -static SENSOR_DEVICE_ATTR(psoc_psu1_sn, S_IRUGO, show_psu_psoc, 0, (0x14<<8)|PSOC_PSU_OFF(psu1_sn)); -static SENSOR_DEVICE_ATTR(psoc_psu2_vendor, S_IRUGO, show_psu_psoc, 0, (0x10<<8)|PSOC_PSU_OFF(psu2_vendor)); -static SENSOR_DEVICE_ATTR(psoc_psu2_model, S_IRUGO, show_psu_psoc, 0, (0x14<<8)|PSOC_PSU_OFF(psu2_model)); -static SENSOR_DEVICE_ATTR(psoc_psu2_version, S_IRUGO, show_psu_psoc, 0, (0x08<<8)|PSOC_PSU_OFF(psu2_version)); -static SENSOR_DEVICE_ATTR(psoc_psu2_date, S_IRUGO, show_psu_psoc, 0, (0x06<<8)|PSOC_PSU_OFF(psu2_date)); -static SENSOR_DEVICE_ATTR(psoc_psu2_sn, S_IRUGO, show_psu_psoc, 0, (0x14<<8)|PSOC_PSU_OFF(psu2_sn)); - -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, - - &sensor_dev_attr_psoc_psu1_eeprom_type.dev_attr.attr, - &sensor_dev_attr_psoc_psu2_eeprom_type.dev_attr.attr, - &sensor_dev_attr_psoc_mode.dev_attr.attr, - - //clei -// &sensor_dev_attr_fan1_issue_number.dev_attr.attr, -// &sensor_dev_attr_fan2_issue_number.dev_attr.attr, -// &sensor_dev_attr_fan3_issue_number.dev_attr.attr, -// &sensor_dev_attr_fan4_issue_number.dev_attr.attr, -// &sensor_dev_attr_fan1_abbreviation_number.dev_attr.attr, -// &sensor_dev_attr_fan2_abbreviation_number.dev_attr.attr, -// &sensor_dev_attr_fan3_abbreviation_number.dev_attr.attr, -// &sensor_dev_attr_fan4_abbreviation_number.dev_attr.attr, -// &sensor_dev_attr_fan1_fc_number.dev_attr.attr, -// &sensor_dev_attr_fan2_fc_number.dev_attr.attr, -// &sensor_dev_attr_fan3_fc_number.dev_attr.attr, -// &sensor_dev_attr_fan4_fc_number.dev_attr.attr, -// &sensor_dev_attr_fan1_clei_code.dev_attr.attr, -// &sensor_dev_attr_fan2_clei_code.dev_attr.attr, -// &sensor_dev_attr_fan3_clei_code.dev_attr.attr, -// &sensor_dev_attr_fan4_clei_code.dev_attr.attr, -// &sensor_dev_attr_fan1_product_year_and_month.dev_attr.attr, -// &sensor_dev_attr_fan2_product_year_and_month.dev_attr.attr, -// &sensor_dev_attr_fan3_product_year_and_month.dev_attr.attr, -// &sensor_dev_attr_fan4_product_year_and_month.dev_attr.attr, -// &sensor_dev_attr_fan1_label_location_code.dev_attr.attr, -// &sensor_dev_attr_fan2_label_location_code.dev_attr.attr, -// &sensor_dev_attr_fan3_label_location_code.dev_attr.attr, -// &sensor_dev_attr_fan4_label_location_code.dev_attr.attr, -// &sensor_dev_attr_fan1_serial_number.dev_attr.attr, -// &sensor_dev_attr_fan2_serial_number.dev_attr.attr, -// &sensor_dev_attr_fan3_serial_number.dev_attr.attr, -// &sensor_dev_attr_fan4_serial_number.dev_attr.attr, -// &sensor_dev_attr_fan1_pcb_revision.dev_attr.attr, -// &sensor_dev_attr_fan2_pcb_revision.dev_attr.attr, -// &sensor_dev_attr_fan3_pcb_revision.dev_attr.attr, -// &sensor_dev_attr_fan4_pcb_revision.dev_attr.attr, -// &sensor_dev_attr_fan1_vendor_name.dev_attr.attr, -// &sensor_dev_attr_fan2_vendor_name.dev_attr.attr, -// &sensor_dev_attr_fan3_vendor_name.dev_attr.attr, -// &sensor_dev_attr_fan4_vendor_name.dev_attr.attr, - &sensor_dev_attr_fan1_clei.dev_attr.attr, - &sensor_dev_attr_fan2_clei.dev_attr.attr, - &sensor_dev_attr_fan3_clei.dev_attr.attr, - &sensor_dev_attr_fan4_clei.dev_attr.attr, - -// &sensor_dev_attr_psu1_issue_number.dev_attr.attr, -// &sensor_dev_attr_psu2_issue_number.dev_attr.attr, -// &sensor_dev_attr_psu1_abbreviation_number.dev_attr.attr, -// &sensor_dev_attr_psu2_abbreviation_number.dev_attr.attr, -// &sensor_dev_attr_psu1_fc_number.dev_attr.attr, -// &sensor_dev_attr_psu2_fc_number.dev_attr.attr, -// &sensor_dev_attr_psu1_clei_code.dev_attr.attr, -// &sensor_dev_attr_psu2_clei_code.dev_attr.attr, -// &sensor_dev_attr_psu1_product_year_and_month.dev_attr.attr, -// &sensor_dev_attr_psu2_product_year_and_month.dev_attr.attr, -// &sensor_dev_attr_psu1_label_location_code.dev_attr.attr, -// &sensor_dev_attr_psu2_label_location_code.dev_attr.attr, -// &sensor_dev_attr_psu1_serial_number.dev_attr.attr, -// &sensor_dev_attr_psu2_serial_number.dev_attr.attr, -// &sensor_dev_attr_psu1_pcb_revision.dev_attr.attr, -// &sensor_dev_attr_psu2_pcb_revision.dev_attr.attr, -// &sensor_dev_attr_psu1_vendor_name.dev_attr.attr, -// &sensor_dev_attr_psu2_vendor_name.dev_attr.attr, - &sensor_dev_attr_psu1_clei.dev_attr.attr, - &sensor_dev_attr_psu2_clei.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_fan1_led_grn.dev_attr.attr, - &sensor_dev_attr_fan2_led_grn.dev_attr.attr, - &sensor_dev_attr_fan3_led_grn.dev_attr.attr, - &sensor_dev_attr_fan4_led_grn.dev_attr.attr, - &sensor_dev_attr_fan1_led_red.dev_attr.attr, - &sensor_dev_attr_fan2_led_red.dev_attr.attr, - &sensor_dev_attr_fan3_led_red.dev_attr.attr, - &sensor_dev_attr_fan4_led_red.dev_attr.attr, - - //fan GPI - &sensor_dev_attr_fan_gpi.dev_attr.attr, - - //psu -#if 0 - &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_psu0.dev_attr.attr, - &sensor_dev_attr_psu1.dev_attr.attr, -#endif - - //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, - - //add info - &sensor_dev_attr_psoc_psu1_vendor.dev_attr.attr, - &sensor_dev_attr_psoc_psu1_model.dev_attr.attr, - &sensor_dev_attr_psoc_psu1_version.dev_attr.attr, - &sensor_dev_attr_psoc_psu1_date.dev_attr.attr, - &sensor_dev_attr_psoc_psu1_sn.dev_attr.attr, - &sensor_dev_attr_psoc_psu2_vendor.dev_attr.attr, - &sensor_dev_attr_psoc_psu2_model.dev_attr.attr, - &sensor_dev_attr_psoc_psu2_version.dev_attr.attr, - &sensor_dev_attr_psoc_psu2_date.dev_attr.attr, - &sensor_dev_attr_psoc_psu2_sn.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; - } - data->auto_update = kthread_run(psoc_polling_thread,client,"%s",dev_name(data->hwmon_dev)); - if (IS_ERR(data->auto_update)) - { - status = PTR_ERR(data->auto_update); - goto exit_remove; - } - - /* Check PSOC Mode is 1 or 2byte*/ - data->psoc_mode=modparam_psocmode; - if(data->psoc_mode==0) - { - u8 temp[]={0xab}; - data->psoc_mode=1; - psoc_i2c_write(client, temp, 25, 1); - if(psoc_i2c_read(client, temp, 25, 1)==1) - { - if(temp[0]!=0xab) data->psoc_mode=2; - } - } - - dev_info(&client->dev, "%s: sensor '%s' (psoc_mode:%d)\n", - dev_name(data->hwmon_dev), client->name,data->psoc_mode); - - 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); - kthread_stop(data->auto_update); - 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("Jack Ting "); -MODULE_DESCRIPTION("inv psoc driver"); -MODULE_LICENSE("GPL"); -MODULE_VERSION("3.0"); -module_init(inv_psoc_init); -module_exit(inv_psoc_exit); diff --git a/packages/platforms/inventec/x86-64/d6254qs/modules/builds/src/inv_swps.c b/packages/platforms/inventec/x86-64/d6254qs/modules/builds/src/inv_swps.c deleted file mode 100644 index 23f6c5247..000000000 --- a/packages/platforms/inventec/x86-64/d6254qs/modules/builds/src/inv_swps.c +++ /dev/null @@ -1,3147 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "inv_swps.h" - -static int ctl_major; -static int port_major; -static int ioexp_total; -static int port_total; -static int auto_config; -static int flag_i2c_reset; -static int flag_mod_state; -static unsigned gpio_rest_mux; -static struct class *swp_class_p = NULL; -static struct inv_platform_s *platform_p = NULL; -static struct inv_ioexp_layout_s *ioexp_layout = NULL; -static struct inv_port_layout_s *port_layout = NULL; - -static void swp_polling_worker(struct work_struct *work); -static DECLARE_DELAYED_WORK(swp_polling, swp_polling_worker); - -static int reset_i2c_topology(void); - -static union { - unsigned int eeprom_update_32[2]; - unsigned char eeprom_update_8[8]; -} ueu_64; - -static int -__swp_match(struct device *dev, -#ifdef SWPS_KERN_VER_AF_3_10 - - const void *data){ -#else - void *data){ -#endif - - char *name = (char *)data; - if (strcmp(dev_name(dev), name) == 0) - return 1; - return 0; -} - - -struct device * -get_swpdev_by_name(char *name){ - struct device *dev = class_find_device(swp_class_p, - NULL, - name, - __swp_match); - return dev; -} - - -static int -sscanf_2_int(const char *buf) { - - int result = -EBFONT; - char *hex_tag = "0x"; - - if (strcspn(buf, hex_tag) == 0) { - if (sscanf(buf,"%x",&result)) { - return result; - } - } else { - if (sscanf(buf,"%d",&result)) { - return result; - } - if(sscanf(buf,"-%d",&result)) { - return -result; - } - if (sscanf(buf,"%x",&result)) { - return result; - } - } - return -EBFONT; -} - -static unsigned long long int -sscanf_2_ullint(const char *buf, size_t count) { - - unsigned long long int result = -EBFONT; - char *hex_tag = "0x"; - int i, zero = 0; - - for (i = 0; i < count-2; i++) { - if (buf[i] != '0') { - zero = 1; - } - } - if (zero == 0) { - return 0x0ULL; - } - - if (strcspn(buf, hex_tag) == 0) { - for (i = 2; i < count-2; i++) { - if (INV_BATOX(buf[i]) == -1) { - return -EBFONT; - } - } - - if (sscanf(buf,"0x%llx",&result)) { - return result; - } - } else { - for (i = 0; i < count-2; i++) { - if (INV_BATOI(buf[i]) == -1) { - return -EBFONT; - } - } - - if (sscanf(buf,"%llu",&result)) { - return result; - } - } - return -EBFONT; -} - - -static int -sscanf_2_binary(const char *buf) { - - int result = sscanf_2_int(buf); - - if (result < 0){ - return -EBFONT; - } - switch (result) { - case 0: - case 1: - return result; - default: - break; - } - return -EBFONT; -} - - -static int -_get_polling_period(void) { - - int retval = 0; - - if (SWP_POLLING_PERIOD == 0) { - return 0; - } - retval = ((SWP_POLLING_PERIOD * HZ) / 1000); - if (retval == 0) { - return 1; - } - return retval; -} - - -static struct transvr_obj_s * -_get_transvr_obj(char *dev_name) { - - struct device *dev_p = NULL; - struct transvr_obj_s *transvr_obj_p = NULL; - - dev_p = get_swpdev_by_name(dev_name); - if (!dev_p){ - return NULL; - } - transvr_obj_p = dev_get_drvdata(dev_p); - if (!transvr_obj_p){ - return NULL; - } - return transvr_obj_p; -} - - -static void -unlock_tobj_all(void) { - - struct transvr_obj_s *tobj_p; - char port_name[32]; - int port_id = 0; - int minor_curr = 0; - - for (minor_curr=0; minor_currauto_config = auto_config; - unlock_transvr_obj(tobj_p); - SWPS_DEBUG("%s: Set %s auto_config=%d\n", - __func__, tobj_p->swp_name, auto_config); - } - return retval; -} - -unsigned char* -get_eeprom_update(void) -{ - return &ueu_64.eeprom_update_8[0]; -} - -void -set_eeprom_update(unsigned char value[8]) -{ - memcpy(ueu_64.eeprom_update_8, value, 8); -} - -/* ========== R/W Functions module control attribute ========== - */ -static ssize_t -show_attr_platform(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - return snprintf(buf_p, 32, "%s\n", platform_p->name); -} - - -static ssize_t -show_attr_version(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - return snprintf(buf_p, 8, "%s\n", SWP_VERSION); -} - - -static ssize_t -show_attr_status(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - return snprintf(buf_p, 8, "%d\n", flag_mod_state); -} - - -static ssize_t -show_attr_auto_config(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - return snprintf(buf_p, 8, "%d\n", auto_config); -} - -static ssize_t -show_attr_eeprom_update(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - return snprintf(buf_p, 20, "0x%02x%02x%02x%02x%02x%02x%02x%02x\n", - ueu_64.eeprom_update_8[7],ueu_64.eeprom_update_8[6], - ueu_64.eeprom_update_8[5],ueu_64.eeprom_update_8[4], - ueu_64.eeprom_update_8[3],ueu_64.eeprom_update_8[2], - ueu_64.eeprom_update_8[1],ueu_64.eeprom_update_8[0]); -} - - -static int -_check_reset_pwd(const char *buf_p, - size_t count) { - - int in_max = 64; - int in_len = (int)count; - char in_val[64] = "ERR"; - char *emsg = "ERR"; - - if (in_len >= in_max) { - emsg = "input too much"; - goto err_check_reset_pwd; - } - if (!sscanf(buf_p,"%s",in_val)) { - emsg = "format incorrect"; - goto err_check_reset_pwd; - } - if (strcmp(in_val, SWP_RESET_PWD) != 0) { - emsg = "password incorrect"; - goto err_check_reset_pwd; - } - return 0; - -err_check_reset_pwd: - SWPS_ERR("%s: %s\n", __func__, emsg); - return -1; -} - - -static ssize_t -store_attr_reset_i2c(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - - if (_check_reset_pwd(buf_p, count) < 0) { - return -EBFONT; - } - /* Polling mode */ - if (SWP_POLLING_ENABLE) { - SWPS_INFO("%s: reset I2C :polling\n", __func__); - flag_i2c_reset = 1; - return count; - } - /* Direct mode */ - SWPS_INFO("%s: reset I2C go. :direct\n", __func__); - if (reset_i2c_topology() < 0) { - SWPS_ERR("%s: reset fail!\n", __func__); - return -EIO; - } - SWPS_INFO("%s: reset I2C ok. :direct\n", __func__); - return count; -} - - -static ssize_t -store_attr_reset_swps(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - - struct transvr_obj_s *tobj_p; - char port_name[32] = "ERR"; - int port_id = 0; - int minor_curr = 0; - - if (_check_reset_pwd(buf_p, count) < 0) { - return -EBFONT; - } - for (minor_curr=0; minor_currstate = STATE_TRANSVR_DISCONNECTED; - unlock_transvr_obj(tobj_p); - SWPS_INFO("%s: reset:%s\n", __func__, tobj_p->swp_name); - } - return count; -} - - -static ssize_t -store_attr_auto_config(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - - int input_val = sscanf_2_int(buf_p); - - if (input_val < 0){ - return -EBFONT; - } - if ((input_val != 0) && (input_val != 1)) { - return -EBFONT; - } - auto_config = input_val; - _update_auto_config_2_trnasvr(); - return count; -} - -static ssize_t -store_attr_eeprom_update(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count) { - - union { - unsigned long long int input_val_64; - unsigned int input_val_32[2]; - } uiv; - int i; - uiv.input_val_64 = sscanf_2_ullint(buf_p, count); - if (uiv.input_val_64 == 0){ - for (i = 0; i < 8; i++) { - ueu_64.eeprom_update_8[i] = 0; - } - } - else - if (uiv.input_val_64 > 0) { - for (i = 0; i < 32; i++) { - if (uiv.input_val_32[0] & 1<get_id, - buf_p); -} - - -static ssize_t -show_attr_ext_id(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_hex_attr(tobj_p, - tobj_p->get_ext_id, - buf_p); -} - - -static ssize_t -show_attr_connector(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_hex_attr(tobj_p, - tobj_p->get_connector, - buf_p); -} - - -static ssize_t -show_attr_vendor_name(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_vendor_name, - buf_p); -} - - -static ssize_t -show_attr_vendor_pn(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_vendor_pn, - buf_p); -} - - -static ssize_t -show_attr_vendor_rev(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_vendor_rev, - buf_p); -} - - -static ssize_t -show_attr_vendor_sn(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_vendor_sn, - buf_p); -} - - -static ssize_t -show_attr_power_cls(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - size_t len; - int result; - struct transvr_obj_s *tobj_p; - - tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - lock_transvr_obj(tobj_p); - result = tobj_p->get_power_cls(tobj_p); - unlock_transvr_obj(tobj_p); - if (result < 0){ - len = snprintf(buf_p, 16, "%d\n", result); - } else { - len = snprintf(buf_p, 16, "Power Class %d\n", result); - } - return len; -} - - -static ssize_t -show_attr_br(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_hex_attr(tobj_p, - tobj_p->get_br, - buf_p); -} - - -static ssize_t -show_attr_len_sm(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_int_attr(tobj_p, - tobj_p->get_len_sm, - buf_p); -} - - -static ssize_t -show_attr_len_smf(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_int_attr(tobj_p, - tobj_p->get_len_smf, - buf_p); -} - - -static ssize_t -show_attr_len_om1(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_int_attr(tobj_p, - tobj_p->get_len_om1, - buf_p); -} - - -static ssize_t -show_attr_len_om2(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_int_attr(tobj_p, - tobj_p->get_len_om2, - buf_p); -} - - -static ssize_t -show_attr_len_om3(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_int_attr(tobj_p, - tobj_p->get_len_om3, - buf_p); -} - - -static ssize_t -show_attr_len_om4(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_int_attr(tobj_p, - tobj_p->get_len_om4, - buf_p); -} - - -static ssize_t -show_attr_comp_rev(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_hex_attr(tobj_p, - tobj_p->get_comp_rev, - buf_p); -} - - -static ssize_t -show_attr_comp_eth(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_hex_attr(tobj_p, - tobj_p->get_comp_eth_1, - buf_p); -} - - -static ssize_t -show_attr_comp_eth_10(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_hex_attr(tobj_p, - tobj_p->get_comp_eth_10, - buf_p); -} - - -static ssize_t -show_attr_comp_eth_10_40(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_hex_attr(tobj_p, - tobj_p->get_comp_eth_10_40, - buf_p); -} - - -static ssize_t -show_attr_comp_extend(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_hex_attr(tobj_p, - tobj_p->get_comp_extend, - buf_p); -} - - -static ssize_t -show_attr_rate_id(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_hex_attr(tobj_p, - tobj_p->get_rate_id, - buf_p); -} - - -static ssize_t -show_attr_temperature(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_curr_temp, - buf_p); -} - - -static ssize_t -show_attr_voltage(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_curr_vol, - buf_p); -} - - -static ssize_t -show_attr_tx_bias(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_tx_bias, - buf_p); -} - - -static ssize_t -show_attr_tx_power(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_tx_power, - buf_p); -} - - -static ssize_t -show_attr_tx_eq(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_tx_eq, - buf_p); -} - - -static ssize_t -show_attr_rx_power(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_rx_power, - buf_p); -} - - -static ssize_t -show_attr_rx_am(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_rx_am, - buf_p); -} - - -static ssize_t -show_attr_rx_em(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_rx_em, - buf_p); -} - - -static ssize_t -show_attr_wavelength(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_wavelength, - buf_p); -} - - -static ssize_t -show_attr_extphy_offset(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_extphy_offset, - buf_p); -} - - -static ssize_t -show_attr_extphy_reg(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_extphy_reg, - buf_p); -} - - -static ssize_t -show_attr_info(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_int_attr(tobj_p, - tobj_p->get_info, - buf_p); -} - - -static ssize_t -show_attr_if_type(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_if_type, - buf_p); -} - - -static ssize_t -show_attr_if_speed(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_if_speed, - buf_p); -} - - -static ssize_t -show_attr_if_lane(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_if_lane, - buf_p); -} - - -static ssize_t -show_attr_cdr(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_hex_attr(tobj_p, - tobj_p->get_cdr, - buf_p); -} - - -static ssize_t -show_attr_soft_rs0(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_int_attr(tobj_p, - tobj_p->get_soft_rs0, - buf_p); -} - - -static ssize_t -show_attr_soft_rs1(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_int_attr(tobj_p, - tobj_p->get_soft_rs1, - buf_p); -} - - -static ssize_t -show_attr_soft_rx_los(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_soft_rx_los, - buf_p); -} - - -static ssize_t -show_attr_soft_tx_disable(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_soft_tx_disable, - buf_p); -} - - -static ssize_t -show_attr_soft_tx_fault(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_soft_tx_fault, - buf_p); -} - - -static ssize_t -show_attr_auto_tx_disable(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_auto_tx_disable, - buf_p); -} - -static ssize_t -show_attr_eeprom(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_eeprom, - buf_p); -} - - -/* ========== Store functions: transceiver (R/W) attribute ========== - */ -static ssize_t -_store_transvr_int_attr(struct transvr_obj_s* tobj_p, - int (*set_func)(struct transvr_obj_s *tobj_p, int input_val), - const char *buf_p, - size_t count) { - int input, err; - - input = sscanf_2_int(buf_p); - if (input < 0){ - return -EBFONT; - } - lock_transvr_obj(tobj_p); - err = set_func(tobj_p, input); - unlock_transvr_obj(tobj_p); - if (err < 0){ - return err; - } - return count; -} - - -static ssize_t -_store_transvr_byte_hex_attr(struct transvr_obj_s* tobj_p, - int (*set_func)(struct transvr_obj_s *tobj_p, int input_val), - const char *buf_p, - size_t count) { - int input, err; - - input = sscanf_2_int(buf_p); - if ((input < 0) || (input > 0xff)){ - return -EBFONT; - } - lock_transvr_obj(tobj_p); - err = set_func(tobj_p, input); - unlock_transvr_obj(tobj_p); - if (err < 0){ - return err; - } - return count; -} - - -static ssize_t -_store_transvr_binary_attr(struct transvr_obj_s* tobj_p, - int (*set_func)(struct transvr_obj_s *tobj_p, int input_val), - const char *buf_p, - size_t count) { - int input, err; - - input = sscanf_2_binary(buf_p); - if (input < 0){ - return -EBFONT; - } - lock_transvr_obj(tobj_p); - err = set_func(tobj_p, input); - unlock_transvr_obj(tobj_p); - if (err < 0){ - return err; - } - return count; -} - - -static ssize_t -store_attr_cdr(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - return _store_transvr_byte_hex_attr(tobj_p, - tobj_p->set_cdr, - buf_p, - count); -} - - -static ssize_t -store_attr_soft_rs0(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - return _store_transvr_binary_attr(tobj_p, - tobj_p->set_soft_rs0, - buf_p, - count); -} - - -static ssize_t -store_attr_soft_rs1(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - return _store_transvr_binary_attr(tobj_p, - tobj_p->set_soft_rs1, - buf_p, - count); -} - - -static ssize_t -store_attr_soft_tx_disable(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count) { - - int check = sscanf_2_int(buf_p); - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - if ((check < 0) || (check > 0xf)){ - return -EBFONT; - } - return _store_transvr_byte_hex_attr(tobj_p, - tobj_p->set_soft_tx_disable, - buf_p, - count); -} - - -static ssize_t -store_attr_auto_tx_disable(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count) { - - int err = -EPERM; - int input = sscanf_2_int(buf_p); - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - if ((input < 0) || (input > 0xf)){ - if (input != VAL_TRANSVR_FUNCTION_DISABLE) { - return -EBFONT; - } - } - lock_transvr_obj(tobj_p); - err = tobj_p->set_auto_tx_disable(tobj_p, input); - unlock_transvr_obj(tobj_p); - if (err < 0){ - return err; - } - return count; -} - - -static ssize_t -store_attr_tx_eq(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - return _store_transvr_int_attr(tobj_p, - tobj_p->set_tx_eq, - buf_p, - count); -} - - -static ssize_t -store_attr_rx_am(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - return _store_transvr_int_attr(tobj_p, - tobj_p->set_rx_am, - buf_p, - count); -} - - -static ssize_t -store_attr_rx_em(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - return _store_transvr_int_attr(tobj_p, - tobj_p->set_rx_em, - buf_p, - count); -} - - -static ssize_t -store_attr_extphy_offset(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - return _store_transvr_int_attr(tobj_p, - tobj_p->set_extphy_offset, - buf_p, - count); -} - - -static ssize_t -store_attr_extphy_reg(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - return _store_transvr_int_attr(tobj_p, - tobj_p->set_extphy_reg, - buf_p, - count); -} - -/* ========== Show functions: For I/O Expander attribute ========== - */ -static ssize_t -_show_ioexp_binary_attr(struct transvr_obj_s *tobj_p, - int (*get_func)(struct ioexp_obj_s *ioexp_p, int voffset), - char *buf_p) { - size_t len; - struct ioexp_obj_s *ioexp_p = tobj_p->ioexp_obj_p; - - if (!ioexp_p) { - SWPS_ERR(" %s: data corruption! :%s\n", __func__, tobj_p->swp_name); - return -ENODATA; - } - mutex_lock(&ioexp_p->lock); - len = snprintf(buf_p, 8, "%d\n", get_func(ioexp_p, tobj_p->ioexp_virt_offset)); - mutex_unlock(&ioexp_p->lock); - return len; -} - - -static ssize_t -show_attr_present(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - return _show_ioexp_binary_attr(tobj_p, - tobj_p->ioexp_obj_p->get_present, - buf_p); -} - - -static ssize_t -show_attr_tx_fault(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - return _show_ioexp_binary_attr(tobj_p, - tobj_p->ioexp_obj_p->get_tx_fault, - buf_p); -} - - -static ssize_t -show_attr_rxlos(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - return _show_ioexp_binary_attr(tobj_p, - tobj_p->ioexp_obj_p->get_rxlos, - buf_p); -} - - -static ssize_t -show_attr_tx_disable(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - return _show_ioexp_binary_attr(tobj_p, - tobj_p->ioexp_obj_p->get_tx_disable, - buf_p); -} - - -static ssize_t -show_attr_reset(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - return _show_ioexp_binary_attr(tobj_p, - tobj_p->ioexp_obj_p->get_reset, - buf_p); -} - - -static ssize_t -show_attr_lpmod(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - return _show_ioexp_binary_attr(tobj_p, - tobj_p->ioexp_obj_p->get_lpmod, - buf_p); -} - - -static ssize_t -show_attr_modsel(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - return _show_ioexp_binary_attr(tobj_p, - tobj_p->ioexp_obj_p->get_modsel, - buf_p); -} - - -static ssize_t -show_attr_hard_rs0(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - return _show_ioexp_binary_attr(tobj_p, - tobj_p->ioexp_obj_p->get_hard_rs0, - buf_p); -} - - -static ssize_t -show_attr_hard_rs1(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - return _show_ioexp_binary_attr(tobj_p, - tobj_p->ioexp_obj_p->get_hard_rs1, - buf_p); -} - - -/* ========== Store functions: For I/O Expander (R/W) attribute ========== - */ -static ssize_t -_store_ioexp_binary_attr(struct transvr_obj_s *tobj_p, - int (*set_func)(struct ioexp_obj_s *ioexp_p, - int virt_offset, int input_val), - const char *buf_p, - size_t count) { - - int input, err; - struct ioexp_obj_s *ioexp_p = tobj_p->ioexp_obj_p; - - if (!ioexp_p) { - SWPS_ERR("%s: data corruption! :%s\n", - __func__, tobj_p->swp_name); - return -ENODATA; - } - input = sscanf_2_binary(buf_p); - if (input < 0) { - return -EBFONT; - } - mutex_lock(&ioexp_p->lock); - err = set_func(ioexp_p, tobj_p->ioexp_virt_offset, input); - mutex_unlock(&ioexp_p->lock); - if (err < 0){ - return err; - } - return count; -} - -static ssize_t -store_attr_tx_disable(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p) { - return -ENODEV; - } - return _store_ioexp_binary_attr(tobj_p, - tobj_p->ioexp_obj_p->set_tx_disable, - buf_p, - count); -} - - -static ssize_t -store_attr_reset(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p) { - return -ENODEV; - } - return _store_ioexp_binary_attr(tobj_p, - tobj_p->ioexp_obj_p->set_reset, - buf_p, - count); -} - - -static ssize_t -store_attr_lpmod(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p) { - return -ENODEV; - } - return _store_ioexp_binary_attr(tobj_p, - tobj_p->ioexp_obj_p->set_lpmod, - buf_p, - count); -} - - -static ssize_t -store_attr_modsel(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p) { - return -ENODEV; - } - return _store_ioexp_binary_attr(tobj_p, - tobj_p->ioexp_obj_p->set_modsel, - buf_p, - count); -} - - -static ssize_t -store_attr_hard_rs0(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p) { - return -ENODEV; - } - return _store_ioexp_binary_attr(tobj_p, - tobj_p->ioexp_obj_p->set_hard_rs0, - buf_p, - count); -} - - -static ssize_t -store_attr_hard_rs1(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p) { - return -ENODEV; - } - return _store_ioexp_binary_attr(tobj_p, - tobj_p->ioexp_obj_p->set_hard_rs1, - buf_p, - count); -} - - -/* ========== SWPS attribute: For module control ========== - */ -static DEVICE_ATTR(platform, S_IRUGO, show_attr_platform, NULL); -static DEVICE_ATTR(version, S_IRUGO, show_attr_version, NULL); -static DEVICE_ATTR(status, S_IRUGO, show_attr_status, NULL); -static DEVICE_ATTR(reset_i2c, S_IWUSR, NULL, store_attr_reset_i2c); -static DEVICE_ATTR(reset_swps, S_IWUSR, NULL, store_attr_reset_swps); -static DEVICE_ATTR(auto_config, S_IRUGO|S_IWUSR, show_attr_auto_config, store_attr_auto_config); -static DEVICE_ATTR(eeprom_update, S_IRUGO|S_IWUSR, show_attr_eeprom_update, store_attr_eeprom_update); - -/* ========== Transceiver attribute: from eeprom ========== - */ -static DEVICE_ATTR(id, S_IRUGO, show_attr_id, NULL); -static DEVICE_ATTR(ext_id, S_IRUGO, show_attr_ext_id, NULL); -static DEVICE_ATTR(connector, S_IRUGO, show_attr_connector, NULL); -static DEVICE_ATTR(vendor_name, S_IRUGO, show_attr_vendor_name, NULL); -static DEVICE_ATTR(vendor_pn, S_IRUGO, show_attr_vendor_pn, NULL); -static DEVICE_ATTR(vendor_rev, S_IRUGO, show_attr_vendor_rev, NULL); -static DEVICE_ATTR(vendor_sn, S_IRUGO, show_attr_vendor_sn, NULL); -static DEVICE_ATTR(power_cls, S_IRUGO, show_attr_power_cls, NULL); -static DEVICE_ATTR(br, S_IRUGO, show_attr_br, NULL); -static DEVICE_ATTR(len_sm, S_IRUGO, show_attr_len_sm, NULL); -static DEVICE_ATTR(len_smf, S_IRUGO, show_attr_len_smf, NULL); -static DEVICE_ATTR(len_om1, S_IRUGO, show_attr_len_om1, NULL); -static DEVICE_ATTR(len_om2, S_IRUGO, show_attr_len_om2, NULL); -static DEVICE_ATTR(len_om3, S_IRUGO, show_attr_len_om3, NULL); -static DEVICE_ATTR(len_om4, S_IRUGO, show_attr_len_om4, NULL); -static DEVICE_ATTR(comp_rev, S_IRUGO, show_attr_comp_rev, NULL); -static DEVICE_ATTR(comp_eth, S_IRUGO, show_attr_comp_eth, NULL); -static DEVICE_ATTR(comp_eth_10, S_IRUGO, show_attr_comp_eth_10, NULL); -static DEVICE_ATTR(comp_eth_10_40, S_IRUGO, show_attr_comp_eth_10_40, NULL); -static DEVICE_ATTR(comp_extend, S_IRUGO, show_attr_comp_extend, NULL); -static DEVICE_ATTR(rate_id, S_IRUGO, show_attr_rate_id, NULL); -static DEVICE_ATTR(temperature, S_IRUGO, show_attr_temperature, NULL); -static DEVICE_ATTR(voltage, S_IRUGO, show_attr_voltage, NULL); -static DEVICE_ATTR(tx_bias, S_IRUGO, show_attr_tx_bias, NULL); -static DEVICE_ATTR(tx_power, S_IRUGO, show_attr_tx_power, NULL); -static DEVICE_ATTR(rx_power, S_IRUGO, show_attr_rx_power, NULL); -static DEVICE_ATTR(info, S_IRUGO, show_attr_info, NULL); -static DEVICE_ATTR(if_type, S_IRUGO, show_attr_if_type, NULL); -static DEVICE_ATTR(if_speed, S_IRUGO, show_attr_if_speed, NULL); -static DEVICE_ATTR(if_lane, S_IRUGO, show_attr_if_lane, NULL); -static DEVICE_ATTR(soft_rx_los, S_IRUGO, show_attr_soft_rx_los, NULL); -static DEVICE_ATTR(soft_tx_fault, S_IRUGO, show_attr_soft_tx_fault, NULL); -static DEVICE_ATTR(wavelength, S_IRUGO, show_attr_wavelength, NULL); -static DEVICE_ATTR(eeprom, S_IRUGO, show_attr_eeprom, NULL); -static DEVICE_ATTR(tx_eq, S_IRUGO|S_IWUSR, show_attr_tx_eq, store_attr_tx_eq); -static DEVICE_ATTR(rx_am, S_IRUGO|S_IWUSR, show_attr_rx_am, store_attr_rx_am); -static DEVICE_ATTR(rx_em, S_IRUGO|S_IWUSR, show_attr_rx_em, store_attr_rx_em); -static DEVICE_ATTR(cdr, S_IRUGO|S_IWUSR, show_attr_cdr, store_attr_cdr); -static DEVICE_ATTR(soft_rs0, S_IRUGO|S_IWUSR, show_attr_soft_rs0, store_attr_soft_rs0); -static DEVICE_ATTR(soft_rs1, S_IRUGO|S_IWUSR, show_attr_soft_rs1, store_attr_soft_rs1); -static DEVICE_ATTR(soft_tx_disable, S_IRUGO|S_IWUSR, show_attr_soft_tx_disable, store_attr_soft_tx_disable); -static DEVICE_ATTR(auto_tx_disable, S_IRUGO|S_IWUSR, show_attr_auto_tx_disable, store_attr_auto_tx_disable); -static DEVICE_ATTR(extphy_offset, S_IRUGO|S_IWUSR, show_attr_extphy_offset, store_attr_extphy_offset); -static DEVICE_ATTR(extphy_reg, S_IRUGO|S_IWUSR, show_attr_extphy_reg, store_attr_extphy_reg); - -/* ========== IO Expander attribute: from expander ========== - */ -static DEVICE_ATTR(present, S_IRUGO, show_attr_present, NULL); -static DEVICE_ATTR(tx_fault, S_IRUGO, show_attr_tx_fault, NULL); -static DEVICE_ATTR(rxlos, S_IRUGO, show_attr_rxlos, NULL); -static DEVICE_ATTR(tx_disable, S_IRUGO|S_IWUSR, show_attr_tx_disable, store_attr_tx_disable); -static DEVICE_ATTR(reset, S_IRUGO|S_IWUSR, show_attr_reset, store_attr_reset); -static DEVICE_ATTR(lpmod, S_IRUGO|S_IWUSR, show_attr_lpmod, store_attr_lpmod); -static DEVICE_ATTR(modsel, S_IRUGO|S_IWUSR, show_attr_modsel, store_attr_modsel); -static DEVICE_ATTR(hard_rs0, S_IRUGO|S_IWUSR, show_attr_hard_rs0, store_attr_hard_rs0); -static DEVICE_ATTR(hard_rs1, S_IRUGO|S_IWUSR, show_attr_hard_rs1, store_attr_hard_rs1); - -/* ========== Functions for module handling ========== - */ -static void -clean_port_obj(void){ - - dev_t dev_num; - char dev_name[32]; - struct device *device_p; - struct transvr_obj_s *transvr_obj_p; - int minor_curr, port_id; - - for (minor_curr=0; minor_curri2c_client_p); - kfree(transvr_obj_p->vendor_name); - kfree(transvr_obj_p->vendor_pn); - kfree(transvr_obj_p->vendor_rev); - kfree(transvr_obj_p->vendor_sn); - kfree(transvr_obj_p->worker_p); - kfree(transvr_obj_p); - } - dev_num = MKDEV(port_major, minor_curr); - device_unregister(device_p); - device_destroy(swp_class_p, dev_num); - } - SWPS_DEBUG("%s: done.\n", __func__); -} - - -static void -clean_swps_common(void){ - - dev_t dev_num; - struct device *device_p; - - device_p = get_swpdev_by_name(SWP_DEV_MODCTL); - if (device_p){ - dev_num = MKDEV(ctl_major, 1); - device_unregister(device_p); - device_destroy(swp_class_p, dev_num); - } - cancel_delayed_work_sync(&swp_polling); - SWPS_DEBUG("%s: done.\n", __func__); -} - - -static int -get_platform_type(void){ - - int i; - int pf_total = ARRAY_SIZE(platform_map); - char log_msg[64] = "ERROR"; - - platform_p = kzalloc(sizeof(struct inv_platform_s), GFP_KERNEL); - if (!platform_p){ - snprintf(log_msg, sizeof(log_msg), "kzalloc fail"); - goto err_get_platform_type_1; - } - memset(platform_p->name, 0, sizeof(platform_p->name)); - - switch (PLATFORM_SETTINGS) { - case PLATFORM_TYPE_AUTO: - snprintf(platform_p->name, (sizeof(platform_p->name) - 1), - "%s", dmi_get_system_info(DMI_BOARD_NAME)); - for (i=0; iname, platform_map[i].name) == 0) { - platform_p->id = platform_map[i].id; - snprintf(log_msg, sizeof(log_msg), - "Auto detect platform: %d (%s)", - platform_p->id, platform_p->name); - goto ok_get_platform_type_1; - } - } - snprintf(log_msg, sizeof(log_msg), - "Auto detect fail! detect platform: %s", - platform_p->name); - goto err_get_platform_type_2; - - case PLATFORM_TYPE_MAGNOLIA: - case PLATFORM_TYPE_MAGNOLIA_FNC: - case PLATFORM_TYPE_REDWOOD: - case PLATFORM_TYPE_REDWOOD_FSL: - case PLATFORM_TYPE_HUDSON32I_GA: - case PLATFORM_TYPE_SPRUCE: - case PLATFORM_TYPE_CYPRESS_GA1: - case PLATFORM_TYPE_CYPRESS_GA2: - case PLATFORM_TYPE_CYPRESS_BAI: - case PLATFORM_TYPE_TAHOE: - case PLATFORM_TYPE_SEQUOIA_GA: - case PLATFORM_TYPE_LAVENDER_GA: - case PLATFORM_TYPE_LAVENDER_ONL: - platform_p->id = PLATFORM_SETTINGS; - for (i=0; iname, (sizeof(platform_p->name) - 1), - "%s", platform_map[i].name); - snprintf(log_msg, sizeof(log_msg), - "User setup platform: %d (%s)", - platform_p->id, platform_p->name); - goto ok_get_platform_type_1; - } - } - snprintf(log_msg, sizeof(log_msg), - "Internal error, can not map id:%d", - PLATFORM_SETTINGS); - goto err_get_platform_type_2; - - default: - break; - } - snprintf(log_msg, sizeof(log_msg), - "PLATFORM_SETTINGS:%d undefined", PLATFORM_SETTINGS); - goto err_get_platform_type_2; - -ok_get_platform_type_1: - SWPS_DEBUG("%s: %s, :%d\n", __func__, log_msg, PLATFORM_SETTINGS); - return 0; - -err_get_platform_type_2: - kfree(platform_p); -err_get_platform_type_1: - SWPS_ERR("%s: %s :%d\n", __func__, log_msg, PLATFORM_SETTINGS); - return -1; -} - - -static int -get_layout_info(void){ - - switch (platform_p->id) { -#ifdef SWPS_MAGNOLIA - case PLATFORM_TYPE_MAGNOLIA: - case PLATFORM_TYPE_MAGNOLIA_FNC: - gpio_rest_mux = magnolia_gpio_rest_mux; - ioexp_layout = magnolia_ioexp_layout; - port_layout = magnolia_port_layout; - ioexp_total = ARRAY_SIZE(magnolia_ioexp_layout); - port_total = ARRAY_SIZE(magnolia_port_layout); - break; -#endif -#ifdef SWPS_REDWOOD - case PLATFORM_TYPE_REDWOOD: - gpio_rest_mux = redwood_gpio_rest_mux; - ioexp_layout = redwood_ioexp_layout; - port_layout = redwood_port_layout; - ioexp_total = ARRAY_SIZE(redwood_ioexp_layout); - port_total = ARRAY_SIZE(redwood_port_layout); - break; -#endif -#ifdef SWPS_HUDSON32I_GA - case PLATFORM_TYPE_HUDSON32I_GA: - gpio_rest_mux = hudsin32iga_gpio_rest_mux; - ioexp_layout = hudson32iga_ioexp_layout; - port_layout = hudson32iga_port_layout; - ioexp_total = ARRAY_SIZE(hudson32iga_ioexp_layout); - port_total = ARRAY_SIZE(hudson32iga_port_layout); - break; -#endif -#ifdef SWPS_SPRUCE - case PLATFORM_TYPE_SPRUCE: - gpio_rest_mux = spruce_gpio_rest_mux; - ioexp_layout = spruce_ioexp_layout; - port_layout = spruce_port_layout; - ioexp_total = ARRAY_SIZE(spruce_ioexp_layout); - port_total = ARRAY_SIZE(spruce_port_layout); - break; -#endif -#ifdef SWPS_CYPRESS_GA1 - case PLATFORM_TYPE_CYPRESS_GA1: - gpio_rest_mux = cypress_ga1_gpio_rest_mux; - ioexp_layout = cypress_ga1_ioexp_layout; - port_layout = cypress_ga1_port_layout; - ioexp_total = ARRAY_SIZE(cypress_ga1_ioexp_layout); - port_total = ARRAY_SIZE(cypress_ga1_port_layout); - break; -#endif -#ifdef SWPS_CYPRESS_GA2 - case PLATFORM_TYPE_CYPRESS_GA2: - gpio_rest_mux = cypress_ga2_gpio_rest_mux; - ioexp_layout = cypress_ga2_ioexp_layout; - port_layout = cypress_ga2_port_layout; - ioexp_total = ARRAY_SIZE(cypress_ga2_ioexp_layout); - port_total = ARRAY_SIZE(cypress_ga2_port_layout); - break; -#endif -#ifdef SWPS_CYPRESS_BAI - case PLATFORM_TYPE_CYPRESS_BAI: - gpio_rest_mux = cypress_b_gpio_rest_mux; - ioexp_layout = cypress_b_ioexp_layout; - port_layout = cypress_b_port_layout; - ioexp_total = ARRAY_SIZE(cypress_b_ioexp_layout); - port_total = ARRAY_SIZE(cypress_b_port_layout); - break; -#endif -#ifdef SWPS_REDWOOD_FSL - case PLATFORM_TYPE_REDWOOD_FSL: - gpio_rest_mux = redwood_fsl_gpio_rest_mux; - ioexp_layout = redwood_fsl_ioexp_layout; - port_layout = redwood_fsl_port_layout; - ioexp_total = ARRAY_SIZE(redwood_fsl_ioexp_layout); - port_total = ARRAY_SIZE(redwood_fsl_port_layout); - break; -#endif -#ifdef SWPS_TAHOE - case PLATFORM_TYPE_TAHOE: - gpio_rest_mux = tahoe_gpio_rest_mux; - ioexp_layout = tahoe_ioexp_layout; - port_layout = tahoe_port_layout; - ioexp_total = ARRAY_SIZE(tahoe_ioexp_layout); - port_total = ARRAY_SIZE(tahoe_port_layout); - break; -#endif -#ifdef SWPS_SEQUOIA - case PLATFORM_TYPE_SEQUOIA_GA: - gpio_rest_mux = sequoia_gpio_rest_mux; - ioexp_layout = sequoia_ioexp_layout; - port_layout = sequoia_port_layout; - ioexp_total = ARRAY_SIZE(sequoia_ioexp_layout); - port_total = ARRAY_SIZE(sequoia_port_layout); - break; -#endif -#ifdef SWPS_LAVENDER - case PLATFORM_TYPE_LAVENDER_GA: - case PLATFORM_TYPE_LAVENDER_ONL: - gpio_rest_mux = lavender_gpio_rest_mux; - ioexp_layout = lavender_ioexp_layout; - port_layout = lavender_port_layout; - ioexp_total = ARRAY_SIZE(lavender_ioexp_layout); - port_total = ARRAY_SIZE(lavender_port_layout); - break; -#endif - default: - SWPS_ERR(" Invalid platform: %d (%s)\n", - platform_p->id, platform_p->name); - return -1; - } - SWPS_INFO("Start to initial platform: %d (%s)\n", - platform_p->id, platform_p->name); - return 0; -} - - -/* ========== Functions for objects operations ========== - */ -static int -__detect_issues_port(int minor_num) { - - struct transvr_obj_s *tobj_p; - int port_id = port_layout[minor_num].port_id; - char port_name[32] = "ERR"; - char *i2c_emsg = "detected bad transceiver/cable"; - - memset(port_name, 0, sizeof(port_name)); - snprintf(port_name, sizeof(port_name), "%s%d", SWP_DEV_PORT, port_id); - tobj_p = _get_transvr_obj(port_name); - if (!tobj_p) { - SWPS_INFO("%s: tobj_p is NULL :%d\n", __func__, minor_num); - return -1; - } - if (resync_channel_tier_2(tobj_p) < 0) { - if (check_channel_tier_1() < 0) { - alarm_msg_2_user(tobj_p, i2c_emsg); - return -2;; - } - } - return 0; -} - - -static int -_detect_issues_port(void) { - /* OK : retrun -1; - * Fail: return fail at which minor number (0~N) - */ - char *emsg = "ERR"; - int minor = 0; - int minor_2st = 1; - - /* Force moving the initial channel pointer - * Filter out case of fail at minor-0 port - */ - while (minor_2st < port_total) { - minor = minor_2st; - if (__detect_issues_port(minor_2st) < 0) { - emsg = "detect minor_2st fail"; - goto err_p_detect_issues_port; - } - minor_2st += 8; - } - /* Scan all port */ - for (minor=0; minor:%d\n", __func__, emsg, minor_err); - return -1; -} - - -static int -check_transvr_obj_one(char *dev_name){ - /* [Return] - * 0 : Doesn't need to take care - * -1 : Single error - * -2 : Critical error (I2C topology die) - * -9 : Internal error - */ - struct transvr_obj_s *tobj_p = NULL; - int retval = -9; - - tobj_p = _get_transvr_obj(dev_name); - if (!tobj_p) { - SWPS_ERR("%s: %s _get_transvr_obj fail\n", - __func__, dev_name); - return -9; - } - /* Check transceiver current status */ - lock_transvr_obj(tobj_p); - retval = tobj_p->check(tobj_p); - unlock_transvr_obj(tobj_p); - switch (retval) { - case 0: - case ERR_TRANSVR_UNPLUGGED: - case ERR_TRNASVR_BE_ISOLATED: - case ERR_TRANSVR_TASK_BUSY: - return 0; - - case ERR_TRANSVR_I2C_CRASH: - default: - break; - } - /* Identify abnormal case */ - if (check_channel_tier_1() < 0) { - SWPS_DEBUG("%s: %s critical error :%d\n", - __func__, dev_name, retval); - return -2; - } - SWPS_DEBUG("%s: %s single error :%d\n", - __func__, dev_name, retval); - return -1; -} - - -static int -check_transvr_objs(void){ - - char dev_name[32]; - int port_id, err_code; - int minor_curr = 0; - - for (minor_curr=0; minor_curr:%d\n", - __func__, dev_name, err_code); - break; - } - } - return 0; - -err_check_transvr_objs: - SWPS_ERR("%s: %s reset_i2c_topology fail.\n", - __func__, dev_name); - return -1; -} - - -static void -swp_polling_worker(struct work_struct *work){ - - /* Reset I2C */ - if (flag_i2c_reset) { - goto polling_reset_i2c; - } - /* Check IOEXP */ - if (check_ioexp_objs() < 0) { - goto polling_reset_i2c; - } - /* Check transceiver */ - if (check_transvr_objs() < 0) { - SWPS_DEBUG("%s: check_transvr_objs fail.\n", __func__); - flag_i2c_reset = 1; - } - goto polling_schedule_round; - -polling_reset_i2c: - SWPS_DEBUG("%s: reset_i2c_topology start.\n", __func__); - if (reset_i2c_topology() < 0) { - SWPS_ERR("%s: reset i2c fail!\n", __func__); - flag_i2c_reset = 1; - } else { - SWPS_DEBUG("%s: reset_i2c_topology OK.\n", __func__); - flag_i2c_reset = 0; - } -polling_schedule_round: - schedule_delayed_work(&swp_polling, _get_polling_period()); -} - - -/* ========== Functions for register something ========== - */ -static int -register_transvr_common_attr(struct device *device_p){ - - char *err_attr = NULL; - - if (device_create_file(device_p, &dev_attr_id) < 0) { - err_attr = "dev_attr_id"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_ext_id) < 0) { - err_attr = "dev_attr_ext_id"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_connector) < 0) { - err_attr = "dev_attr_connector"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_vendor_name) < 0) { - err_attr = "dev_attr_vendor_name"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_vendor_pn) < 0) { - err_attr = "dev_attr_vendor_pn"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_vendor_rev) < 0) { - err_attr = "dev_attr_vendor_rev"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_vendor_sn) < 0) { - err_attr = "dev_attr_vendor_sn"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_br) < 0) { - err_attr = "dev_attr_br"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_len_smf) < 0) { - err_attr = "dev_attr_len_smf"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_len_om1) < 0) { - err_attr = "dev_attr_len_om1"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_len_om2) < 0) { - err_attr = "dev_attr_len_om2"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_len_om3) < 0) { - err_attr = "dev_attr_len_om3"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_len_om4) < 0) { - err_attr = "dev_attr_len_om4"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_comp_extend) < 0) { - err_attr = "dev_attr_comp_extend"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_comp_eth) < 0) { - err_attr = "dev_attr_comp_eth"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_comp_rev) < 0) { - err_attr = "dev_attr_comp_rev"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_info) < 0) { - err_attr = "dev_attr_info"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_if_type) < 0) { - err_attr = "dev_attr_if_type"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_if_speed) < 0) { - err_attr = "dev_attr_if_speed"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_if_lane) < 0) { - err_attr = "dev_attr_if_lane"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_temperature) < 0) { - err_attr = "dev_attr_temperature"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_voltage) < 0) { - err_attr = "dev_attr_voltage"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_tx_bias) < 0) { - err_attr = "dev_attr_tx_bias"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_tx_power) < 0) { - err_attr = "dev_attr_tx_power"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_rx_power) < 0) { - err_attr = "dev_attr_rx_power"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_tx_eq) < 0) { - err_attr = "dev_attr_tx_eq"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_rx_em) < 0) { - err_attr = "dev_attr_rx_em"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_wavelength) < 0) { - err_attr = "dev_attr_wavelength"; - goto err_transvr_comm_attr; - } - return 0; - -err_transvr_comm_attr: - SWPS_ERR("%s: %s\n", __func__, err_attr); - return -1; -} - -static int -register_transvr_sfp_attr(struct device *device_p){ - - char *err_attr = NULL; - - if (register_transvr_common_attr(device_p) < 0) { - err_attr = "register_transvr_common_attr"; - goto err_transvr_sfp_attr; - } - if (device_create_file(device_p, &dev_attr_comp_eth_10) < 0) { - err_attr = "dev_attr_comp_eth_10"; - goto err_transvr_sfp_attr; - } - if (device_create_file(device_p, &dev_attr_len_sm) < 0) { - err_attr = "dev_attr_len_sm"; - goto err_transvr_sfp_attr; - } - if (device_create_file(device_p, &dev_attr_rate_id) < 0) { - err_attr = "dev_attr_rate_id"; - goto err_transvr_sfp_attr; - } - if (device_create_file(device_p, &dev_attr_soft_rs0) < 0) { - err_attr = "dev_attr_soft_rs0"; - goto err_transvr_sfp_attr; - } - if (device_create_file(device_p, &dev_attr_soft_rs1) < 0) { - err_attr = "dev_attr_soft_rs1"; - goto err_transvr_sfp_attr; - } - if (device_create_file(device_p, &dev_attr_eeprom) < 0) { - err_attr = "dev_attr_eeprom"; - goto err_transvr_sfp_attr; - } - if (device_create_file(device_p, &dev_attr_extphy_offset) < 0) { - err_attr = "dev_attr_extphy_offset"; - goto err_transvr_sfp_attr; - } - if (device_create_file(device_p, &dev_attr_extphy_reg) < 0) { - err_attr = "dev_attr_extphy_reg"; - goto err_transvr_sfp_attr; - } - return 0; - -err_transvr_sfp_attr: - SWPS_ERR("%s: %s\n", __func__, err_attr); - return -1; -} - - -static int -register_transvr_qsfp_attr(struct device *device_p){ - - char *err_attr = NULL; - - if (register_transvr_common_attr(device_p) < 0) { - err_attr = "register_transvr_common_attr"; - goto err_transvr_qsfp_attr; - } - if (device_create_file(device_p, &dev_attr_comp_eth_10_40) < 0) { - err_attr = "dev_attr_comp_eth_10_40"; - goto err_transvr_qsfp_attr; - } - if (device_create_file(device_p, &dev_attr_power_cls) < 0) { - err_attr = "dev_attr_power_cls"; - goto err_transvr_qsfp_attr; - } - if (device_create_file(device_p, &dev_attr_soft_rx_los) < 0) { - err_attr = "soft_rx_los"; - goto err_transvr_qsfp_attr; - } - if (device_create_file(device_p, &dev_attr_soft_tx_disable) < 0) { - err_attr = "soft_tx_disable"; - goto err_transvr_qsfp_attr; - } - if (device_create_file(device_p, &dev_attr_auto_tx_disable) < 0) { - err_attr = "auto_tx_disable"; - goto err_transvr_qsfp_attr; - } - if (device_create_file(device_p, &dev_attr_soft_tx_fault) < 0) { - err_attr = "soft_tx_fault"; - goto err_transvr_qsfp_attr; - } - if (device_create_file(device_p, &dev_attr_eeprom) < 0) { - err_attr = "eeprom"; - goto err_transvr_qsfp_attr; - } - return 0; - -err_transvr_qsfp_attr: - SWPS_ERR("%s: %s\n", __func__, err_attr); - return -1; -} - - -static int -register_transvr_qsfp28_attr(struct device *device_p){ - - char *err_attr = NULL; - - if (register_transvr_qsfp_attr(device_p) < 0){ - err_attr = "register_transvr_qsfp_attr"; - goto err_transvr_qsfp28_attr; - } - if (device_create_file(device_p, &dev_attr_cdr) < 0) { - err_attr = "dev_attr_cdr"; - goto err_transvr_qsfp28_attr; - } - if (device_create_file(device_p, &dev_attr_rx_am) < 0) { - err_attr = "dev_attr_rx_am"; - goto err_transvr_qsfp28_attr; - } - return 0; - -err_transvr_qsfp28_attr: - SWPS_ERR("%s: %s\n", __func__, err_attr); - return -1; -} - - -static int -register_transvr_attr(struct device *device_p, - struct transvr_obj_s *transvr_obj){ - - switch (transvr_obj->layout){ - case TRANSVR_TYPE_SFP: - if (register_transvr_sfp_attr(device_p) < 0){ - goto err_reg_tvr_attr; - } - break; - case TRANSVR_TYPE_QSFP: - case TRANSVR_TYPE_QSFP_PLUS: - if (register_transvr_qsfp_attr(device_p) < 0){ - goto err_reg_tvr_attr; - } - break; - case TRANSVR_TYPE_QSFP_28: - if (register_transvr_qsfp28_attr(device_p) < 0){ - goto err_reg_tvr_attr; - } - break; - default: - goto err_reg_tvr_attr; - } - return 0; - -err_reg_tvr_attr: - SWPS_ERR("%s: fail! type=%d \n", __func__, transvr_obj->type); - return -1; -} - - -static int -register_ioexp_attr_sfp_1(struct device *device_p){ - /* Support machine type: - * - SFP : Magnolia - */ - char *err_attr = NULL; - - if (device_create_file(device_p, &dev_attr_present) < 0) { - err_attr = "dev_attr_present"; - goto err_ioexp_sfp1_attr; - } - if (device_create_file(device_p, &dev_attr_tx_fault) < 0) { - err_attr = "dev_attr_tx_fault"; - goto err_ioexp_sfp1_attr; - } - if (device_create_file(device_p, &dev_attr_rxlos) < 0) { - err_attr = "dev_attr_rxlos"; - goto err_ioexp_sfp1_attr; - } - if (device_create_file(device_p, &dev_attr_tx_disable) < 0) { - err_attr = "dev_attr_tx_disable"; - goto err_ioexp_sfp1_attr; - } - return 0; - -err_ioexp_sfp1_attr: - SWPS_ERR("Add device attribute:%s failure! \n",err_attr); - return -1; -} - - -static int -register_ioexp_attr_sfp_2(struct device *device_p){ - /* Support machine type: - * - SFP28 : Cypress - */ - char *err_attr = NULL; - - if (register_ioexp_attr_sfp_1(device_p) < 0){ - goto err_ioexp_sfp2_attr; - } - if (device_create_file(device_p, &dev_attr_hard_rs0) < 0) { - err_attr = "dev_attr_hard_rs0"; - goto err_ioexp_sfp2_attr; - } - if (device_create_file(device_p, &dev_attr_hard_rs1) < 0) { - err_attr = "dev_attr_hard_rs1"; - goto err_ioexp_sfp2_attr; - } - return 0; - -err_ioexp_sfp2_attr: - SWPS_ERR("Add device attribute:%s failure! \n",err_attr); - return -1; -} - - -static int -register_ioexp_attr_qsfp_1(struct device *device_p){ - /* Support machine type: - * - QSFP : Magnolia, Redwood, Hudson32i - * - QSFP+ : Magnolia, Redwood, Hudson32i - * - QSFP28: Redwood - */ - char *err_attr = NULL; - - if (device_create_file(device_p, &dev_attr_present) < 0) { - err_attr = "dev_attr_present"; - goto err_ioexp_qsfp1_attr; - } - if (device_create_file(device_p, &dev_attr_reset) < 0) { - err_attr = "dev_attr_reset"; - goto err_ioexp_qsfp1_attr; - } - if (device_create_file(device_p, &dev_attr_lpmod) < 0) { - err_attr = "dev_attr_lpmod"; - goto err_ioexp_qsfp1_attr; - } - if (device_create_file(device_p, &dev_attr_modsel) < 0) { - err_attr = "dev_attr_modsel"; - goto err_ioexp_qsfp1_attr; - } - return 0; - -err_ioexp_qsfp1_attr: - SWPS_ERR("Add device attribute:%s failure! \n",err_attr); - return -1; -} - - -static int -register_modctl_attr(struct device *device_p){ - - char *err_msg = NULL; - - if (device_create_file(device_p, &dev_attr_platform) < 0) { - err_msg = "dev_attr_platform"; - goto err_reg_modctl_attr; - } - if (device_create_file(device_p, &dev_attr_version) < 0) { - err_msg = "dev_attr_version"; - goto err_reg_modctl_attr; - } - if (device_create_file(device_p, &dev_attr_status) < 0) { - err_msg = "dev_attr_status"; - goto err_reg_modctl_attr; - } - if (device_create_file(device_p, &dev_attr_reset_i2c) < 0) { - err_msg = "dev_attr_reset_i2c"; - goto err_reg_modctl_attr; - } - if (device_create_file(device_p, &dev_attr_reset_swps) < 0) { - err_msg = "dev_attr_reset_swps"; - goto err_reg_modctl_attr; - } - if (device_create_file(device_p, &dev_attr_auto_config) < 0) { - err_msg = "dev_attr_auto_config"; - goto err_reg_modctl_attr; - } - if (device_create_file(device_p, &dev_attr_eeprom_update) < 0) { - err_msg = "dev_attr_eeprom_update"; - goto err_reg_modctl_attr; - } - return 0; - -err_reg_modctl_attr: - SWPS_ERR("%s: %s\n", __func__, err_msg); - return -1; -} - - -static int -register_ioexp_attr(struct device *device_p, - struct transvr_obj_s *transvr_obj){ - - char *err_msg = "ERR"; - - switch (transvr_obj->ioexp_obj_p->ioexp_type){ - case IOEXP_TYPE_MAGINOLIA_NAB: - case IOEXP_TYPE_MAGINOLIA_4AB: - if (register_ioexp_attr_sfp_1(device_p) < 0){ - err_msg = "register_ioexp_attr_sfp_1 fail"; - goto err_reg_ioexp_attr; - } - break; - case IOEXP_TYPE_CYPRESS_NABC: - if (register_ioexp_attr_sfp_2(device_p) < 0){ - err_msg = "register_ioexp_attr_sfp_2 fail"; - goto err_reg_ioexp_attr; - } - break; - case IOEXP_TYPE_MAGINOLIA_7AB: - case IOEXP_TYPE_SPRUCE_7AB: - case IOEXP_TYPE_CYPRESS_7ABC: - case IOEXP_TYPE_REDWOOD_P01P08: - case IOEXP_TYPE_REDWOOD_P09P16: - case IOEXP_TYPE_HUDSON32IGA_P01P08: - case IOEXP_TYPE_HUDSON32IGA_P09P16: - case IOEXP_TYPE_TAHOE_5A: - case IOEXP_TYPE_TAHOE_6ABC: - case IOEXP_TYPE_SEQUOIA_NABC: - case IOEXP_TYPE_LAVENDER_P65: - if (register_ioexp_attr_qsfp_1(device_p) < 0){ - err_msg = "register_ioexp_attr_qsfp_1 fail"; - goto err_reg_ioexp_attr; - } - break; - - default: - err_msg = "Unknow type"; - goto err_reg_ioexp_attr; - } - return 0; - -err_reg_ioexp_attr: - SWPS_ERR("%s: %s :%d \n", - __func__, err_msg, transvr_obj->ioexp_obj_p->ioexp_type); - return -1; -} - - -static int -register_modctl_device(void) { - - struct device *device_p = NULL; - int minor_comm = 0; /* Default minor number for common device */ - dev_t dev_num = MKDEV(ctl_major, minor_comm); - char *err_msg = "ERROR"; - - device_p = device_create(swp_class_p, /* struct class *cls */ - NULL, /* struct device *parent */ - dev_num, /* dev_t devt */ - NULL, /* void *private_data */ - SWP_DEV_MODCTL); /* const char *fmt */ - if (IS_ERR(device_p)){ - err_msg = "device_create fail"; - goto err_register_modctl_device_1; - } - if (register_modctl_attr(device_p) < 0) { - err_msg = "register_modctl_attr fail"; - goto err_register_modctl_device_2; - } - return 0; - -err_register_modctl_device_2: - device_unregister(device_p); - device_destroy(swp_class_p, dev_num); -err_register_modctl_device_1: - SWPS_ERR("%s: %s\n", __func__, err_msg); - return -1; -} - - -static int -register_port_device(char *dev_name, - dev_t dev_num, - struct transvr_obj_s *transvr_obj){ - - struct device *device_p = NULL; - device_p = device_create(swp_class_p, /* struct class *cls */ - NULL, /* struct device *parent */ - dev_num, /* dev_t devt */ - transvr_obj, /* void *private_data */ - dev_name); /* const char *fmt */ - if (IS_ERR(device_p)){ - goto err_regswp_create_dev; - } - if (register_transvr_attr(device_p, transvr_obj) < 0){ - goto err_regswp_reg_attr; - } - if (register_ioexp_attr(device_p, transvr_obj) < 0){ - goto err_regswp_reg_attr; - } - return 0; - -err_regswp_reg_attr: - device_unregister(device_p); - device_destroy(swp_class_p, dev_num); -err_regswp_create_dev: - SWPS_ERR("%s fail! :%s\n", __func__, dev_name); - return -1; -} - - -static int -register_swp_module(void){ - - dev_t ctl_devt = 0; - dev_t port_devt = 0; - int dev_total = port_total + 1; /* char_dev for module control */ - - /* Register device number */ - if (alloc_chrdev_region(&ctl_devt, 0, 1, SWP_DEV_MODCTL) < 0){ - SWPS_WARN("Allocate CTL MAJOR failure! \n"); - goto err_register_swp_module_1; - } - if (alloc_chrdev_region(&port_devt, 0, dev_total, SWP_CLS_NAME) < 0){ - SWPS_WARN("Allocate PORT MAJOR failure! \n"); - goto err_register_swp_module_2; - } - ctl_major = MAJOR(ctl_devt); - port_major = MAJOR(port_devt); - - /* Create class object */ - swp_class_p = class_create(THIS_MODULE, SWP_CLS_NAME); - if (IS_ERR(swp_class_p)) { - SWPS_ERR("Create class failure! \n"); - goto err_register_swp_module_3; - } - return 0; - -err_register_swp_module_3: - unregister_chrdev_region(MKDEV(port_major, 0), port_total); -err_register_swp_module_2: - unregister_chrdev_region(MKDEV(ctl_major, 0), 1); -err_register_swp_module_1: - return -1; -} - - -/* ========== Module initial relate ========== - */ -static int -create_ioexp_objs(void) { - - int i, run_mod; - - /* Clean IOEXP object */ - clean_ioexp_objs(); - /* Get running mode */ - run_mod = IOEXP_MODE_DIRECT; - if (SWP_POLLING_ENABLE){ - run_mod = IOEXP_MODE_POLLING; - } - /* Create IOEXP object */ - for(i=0; i devlen_max) { - snprintf(err_msg, sizeof(err_msg), - "SWP_DEV_PORT too long!"); - goto err_initport_create_tranobj; - } - memset(dev_name, 0, sizeof(dev_name)); - snprintf(dev_name, devlen_max, "%s%d", SWP_DEV_PORT, port_id); - /* Create transceiver object */ - ioexp_obj_p = get_ioexp_obj(ioexp_id); - if (!ioexp_obj_p){ - snprintf(err_msg, sizeof(err_msg), - "IOEXP object:%d not exist", ioexp_id); - goto err_initport_create_tranobj; - } - transvr_obj_p = create_transvr_obj(dev_name, chan_id, ioexp_obj_p, - ioexp_virt_offset, transvr_type, - chipset_type, run_mod); - if (!transvr_obj_p){ - snprintf(err_msg, sizeof(err_msg), - "Create transceiver object fail :%s", dev_name); - goto err_initport_create_tranobj; - } - /* Setup Lane_ID mapping */ - i = ARRAY_SIZE(port_layout[minor_curr].lane_id); - j = ARRAY_SIZE(transvr_obj_p->lane_id); - if (i != j) { - snprintf(err_msg, sizeof(err_msg), - "Lane_id size inconsistent %d/%d", i, j); - goto err_initport_reg_device; - } - memcpy(transvr_obj_p->lane_id, port_layout[minor_curr].lane_id, i*sizeof(int)); - /* Create and register device object */ - if (register_port_device(dev_name, MKDEV(port_major, minor_curr), transvr_obj_p) < 0){ - snprintf(err_msg, sizeof(err_msg), - "register_port_device fail"); - goto err_initport_reg_device; - } - /* Setup device_ptr of transvr_obj */ - dev_p = get_swpdev_by_name(dev_name); - if (!dev_p){ - snprintf(err_msg, sizeof(err_msg), - "get_swpdev_by_name fail"); - goto err_initport_reg_device; - } - transvr_obj_p->transvr_dev_p = dev_p; - /* Success */ - ok_count++; - } - SWPS_INFO("%s: initialed %d port-dev",__func__, ok_count); - return 0; - -err_initport_reg_device: - kfree(transvr_obj_p); -err_initport_create_tranobj: - clean_port_obj(); - SWPS_ERR("%s: %s", __func__, err_msg); - SWPS_ERR("Dump: :%d :%d :%d :%d :%d :%d\n", - port_id, chan_id, ioexp_id, ioexp_virt_offset, transvr_type, run_mod); - return -1; -} - - -static int -init_dev_topology(void){ - - int err; - char *emsg = "ERR"; - flag_mod_state = SWP_STATE_NORMAL; - - err = init_ioexp_objs(); - switch(err){ - case 0: /* Normal */ - SWPS_DEBUG("%s: normal case\n", __func__); - break; - - case -1: /* topology error */ - SWPS_DEBUG("%s: detect tier-1 topology initial failure :%d\n", - __func__, err); - /* Reset and isolate */ - err = reset_i2c_topology(); - if (err < 0) { - emsg = "reset i2c topology fail"; - goto err_init_dev_topology; - } - /* Re-initial again */ - err = init_ioexp_objs(); - if (err < 0) { - emsg = "re-init ioexp objects fail"; - goto err_init_dev_topology; - } - break; - - case -2: /* Internal error */ - SWPS_DEBUG("%s: internal error case\n", __func__); - err = -2; - emsg = "internal error"; - goto err_init_dev_topology; - - default: - SWPS_DEBUG("%s: undefined error case\n", __func__); - emsg = "undefined error case"; - goto err_init_dev_topology; - } - SWPS_DEBUG("%s: initial I2C topology success\n", __func__); - return 0; - -err_init_dev_topology: - SWPS_ERR("%s: %s :%d\n", __func__, emsg, err); - return -1; -} - - -static int -init_polling_task(void){ - - if (SWP_POLLING_ENABLE){ - schedule_delayed_work(&swp_polling, _get_polling_period()); - } - return 0; -} - - -static int -init_swps_common(void){ - - char *err_msg = "ERR"; - - auto_config = 0; - if ((SWP_AUTOCONFIG_ENABLE) && (SWP_POLLING_ENABLE)){ - auto_config = 1; - } - if (register_modctl_device() < 0) { - err_msg = "register_modctl_device fail"; - goto err_init_swps_common_1; - } - if (_update_auto_config_2_trnasvr() < 0) { - err_msg = "_update_auto_config_2_trnasvr fail"; - goto err_init_swps_common_1; - } - if (init_polling_task() < 0){ - err_msg = "init_polling_task fail"; - goto err_init_swps_common_1; - } - return 0; - -err_init_swps_common_1: - clean_swps_common(); - SWPS_ERR("%s: %s\n", __func__, err_msg); - return -1; -} - - -static int __init -swp_module_init(void){ - - if (get_platform_type() < 0){ - goto err_init_out; - } - if (get_layout_info() < 0){ - goto err_init_out; - } - if (register_swp_module() < 0){ - goto err_init_out; - } - if (create_ioexp_objs() < 0){ - goto err_init_ioexp; - } - if (create_port_objs() < 0){ - goto err_init_portobj; - } - if (init_mux_gpio(gpio_rest_mux) < 0){ - goto err_init_mux; - } - if (init_dev_topology() < 0){ - goto err_init_topology; - } - if (init_swps_common() < 0){ - goto err_init_topology; - } - SWPS_INFO("Inventec switch-port module V.%s initial success.\n", SWP_VERSION); - return 0; - - -err_init_topology: - clean_mux_gpio(); -err_init_mux: - clean_port_obj(); -err_init_portobj: - clean_ioexp_objs(); -err_init_ioexp: - class_unregister(swp_class_p); - class_destroy(swp_class_p); - unregister_chrdev_region(MKDEV(ctl_major, 0), 1); - unregister_chrdev_region(MKDEV(port_major, 0), port_total); -err_init_out: - SWPS_ERR("Inventec switch-port module V.%s initial failure.\n", SWP_VERSION); - return -1; -} - - -static void __exit -swp_module_exit(void){ - - clean_swps_common(); - clean_port_obj(); - clean_ioexp_objs(); - clean_mux_gpio(); - class_unregister(swp_class_p); - class_destroy(swp_class_p); - unregister_chrdev_region(MKDEV(ctl_major, 0), 1); - unregister_chrdev_region(MKDEV(port_major, 0), port_total); - SWPS_INFO("Remove Inventec switch-port module success.\n"); -} - - -/* Module information */ -MODULE_AUTHOR(SWP_AUTHOR); -MODULE_DESCRIPTION(SWP_DESC); -MODULE_VERSION(SWP_VERSION); -MODULE_LICENSE(SWP_LICENSE); - -module_init(swp_module_init); -module_exit(swp_module_exit); - - - - - - - - - diff --git a/packages/platforms/inventec/x86-64/d6254qs/modules/builds/src/inv_swps.h b/packages/platforms/inventec/x86-64/d6254qs/modules/builds/src/inv_swps.h deleted file mode 100644 index 391590314..000000000 --- a/packages/platforms/inventec/x86-64/d6254qs/modules/builds/src/inv_swps.h +++ /dev/null @@ -1,1030 +0,0 @@ -#ifndef INV_SWPS_H -#define INV_SWPS_H - -#include "transceiver.h" -#include "io_expander.h" -#include "inv_mux.h" - -/* Module settings */ -#define SWP_CLS_NAME "swps" -#define SWP_DEV_PORT "port" -#define SWP_DEV_MODCTL "module" -#define SWP_RESET_PWD "inventec" -#define SWP_POLLING_PERIOD (300) /* msec */ -#define SWP_POLLING_ENABLE (1) -#define SWP_AUTOCONFIG_ENABLE (1) - -/* Module information */ -#define SWP_AUTHOR "Neil " -#define SWP_DESC "Inventec port and transceiver driver" -#define SWP_VERSION "4.2.7" -#define SWP_LICENSE "GPL" - -/* Module status define */ -#define SWP_STATE_NORMAL (0) -#define SWP_STATE_I2C_DIE (-91) - -#define INV_BATOI(a) ((a>='0'&&a<='9')?(a-'0'):(-1)) -#define INV_BATOX(a) ((a>='0'&&a<='9')?(a-'0'):((a>='a'&&a<='f')?(a-'a'+10):((a >='A'&&a<='F')?(a-'A'+10):-1))) - -/* [Note]: - * Functions and mechanism for auto-detect platform type is ready, - * But HW and BIOS not ready! We need to wait them. - * So, please do not use PLATFORM_TYPE_AUTO until they are ready. - * (2016.06.13) - */ -#define PLATFORM_TYPE_AUTO (100) -#define PLATFORM_TYPE_MAGNOLIA (111) -#define PLATFORM_TYPE_MAGNOLIA_FNC (112) -#define PLATFORM_TYPE_REDWOOD (121) -#define PLATFORM_TYPE_REDWOOD_FSL (122) -#define PLATFORM_TYPE_HUDSON32I_GA (131) -#define PLATFORM_TYPE_SPRUCE (141) -#define PLATFORM_TYPE_CYPRESS_GA1 (151) /* Up -> Down */ -#define PLATFORM_TYPE_CYPRESS_GA2 (152) /* Down -> Up */ -#define PLATFORM_TYPE_CYPRESS_BAI (153) /* Down -> Up */ -#define PLATFORM_TYPE_TAHOE (161) -#define PLATFORM_TYPE_SEQUOIA_GA (171) -#define PLATFORM_TYPE_LAVENDER_GA (181) -#define PLATFORM_TYPE_LAVENDER_ONL (182) -/* Current running platfrom */ -#define PLATFORM_SETTINGS PLATFORM_TYPE_MAGNOLIA - -/* Define platform flag and kernel version */ -#if (PLATFORM_SETTINGS == PLATFORM_TYPE_MAGNOLIA) - #define SWPS_MAGNOLIA (1) - #define SWPS_KERN_VER_BF_3_8 (1) - #define SWPS_KERN_VER_AF_3_10 (1) -#elif (PLATFORM_SETTINGS == PLATFORM_TYPE_MAGNOLIA_FNC) - #define SWPS_MAGNOLIA (1) - #define SWPS_KERN_VER_AF_3_10 (1) -#elif (PLATFORM_SETTINGS == PLATFORM_TYPE_REDWOOD) - #define SWPS_REDWOOD (1) - #define SWPS_KERN_VER_BF_3_8 (1) -#elif (PLATFORM_SETTINGS == PLATFORM_TYPE_REDWOOD_FSL) - #define SWPS_REDWOOD_FSL (1) - #define SWPS_KERN_VER_BF_3_8 (1) -#elif (PLATFORM_SETTINGS == PLATFORM_TYPE_HUDSON32I_GA) - #define SWPS_HUDSON32I_GA (1) - #define SWPS_KERN_VER_BF_3_8 (1) -#elif (PLATFORM_SETTINGS == PLATFORM_TYPE_SPRUCE) - #define SWPS_SPRUCE (1) - #define SWPS_KERN_VER_BF_3_8 (1) -#elif (PLATFORM_SETTINGS == PLATFORM_TYPE_CYPRESS_GA1) - #define SWPS_CYPRESS_GA1 (1) - #define SWPS_KERN_VER_BF_3_8 (1) -#elif (PLATFORM_SETTINGS == PLATFORM_TYPE_CYPRESS_GA2) - #define SWPS_CYPRESS_GA2 (1) - #define SWPS_KERN_VER_BF_3_8 (1) -#elif (PLATFORM_SETTINGS == PLATFORM_TYPE_CYPRESS_BAI) - #define SWPS_CYPRESS_BAI (1) - #define SWPS_KERN_VER_AF_3_10 (1) -#elif (PLATFORM_SETTINGS == PLATFORM_TYPE_TAHOE) - #define SWPS_TAHOE (1) - #define SWPS_KERN_VER_AF_3_10 (1) -#elif (PLATFORM_SETTINGS == PLATFORM_TYPE_SEQUOIA_GA) - #define SWPS_SEQUOIA (1) - #define SWPS_KERN_VER_BF_3_8 (1) -#elif (PLATFORM_SETTINGS == PLATFORM_TYPE_LAVENDER_GA) - #define SWPS_LAVENDER (1) - #define SWPS_KERN_VER_AF_3_10 (1) -#elif (PLATFORM_SETTINGS == PLATFORM_TYPE_LAVENDER_ONL) - #define SWPS_LAVENDER (1) - #define SWPS_KERN_VER_AF_3_10 (1) -#endif - - -struct inv_platform_s { - int id; - char name[64]; -}; - -struct inv_ioexp_layout_s { - int ioexp_id; - int ioexp_type; - struct ioexp_addr_s addr[4]; -}; - -struct inv_port_layout_s { - int port_id; - int chan_id; - int ioexp_id; - int ioexp_offset; - int transvr_type; - int chipset_type; - int lane_id[8]; -}; - - -/* ========================================== - * Inventec Platform Settings - * ========================================== - */ -struct inv_platform_s platform_map[] = { - {PLATFORM_TYPE_AUTO, "Auto-Detect" }, - {PLATFORM_TYPE_MAGNOLIA, "Magnolia" }, - {PLATFORM_TYPE_MAGNOLIA_FNC, "Magnolia_FNC" }, - {PLATFORM_TYPE_REDWOOD, "Redwood" }, - {PLATFORM_TYPE_REDWOOD_FSL, "Redwood_FSL" }, - {PLATFORM_TYPE_HUDSON32I_GA, "Hudson32i" }, - {PLATFORM_TYPE_SPRUCE, "Spruce" }, - {PLATFORM_TYPE_CYPRESS_GA1, "Cypress_GA1" }, - {PLATFORM_TYPE_CYPRESS_GA2, "Cypress_GA2" }, - {PLATFORM_TYPE_CYPRESS_BAI, "Cypress_BAI" }, - {PLATFORM_TYPE_TAHOE, "Tahoe" }, - {PLATFORM_TYPE_SEQUOIA_GA, "Sequoia_GA" }, - {PLATFORM_TYPE_LAVENDER_GA, "Lavender_GA" }, - {PLATFORM_TYPE_LAVENDER_ONL, "Lavender_ONL" }, -}; - - -/* ========================================== - * Magnolia Layout configuration - * ========================================== - */ -#ifdef SWPS_MAGNOLIA -unsigned magnolia_gpio_rest_mux = MUX_RST_GPIO_48_PAC9548; - -struct inv_ioexp_layout_s magnolia_ioexp_layout[] = { - /* IOEXP_ID / IOEXP_TYPE / { Chan_ID, Chip_addr, Read_offset, Write_offset, config_offset, data_default, conf_default } */ - {0, IOEXP_TYPE_MAGINOLIA_NAB, { {2, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {2, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, }, /* addr[1] = I/O Expander N B */ - }, - {1, IOEXP_TYPE_MAGINOLIA_NAB, { {3, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {3, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, }, /* addr[1] = I/O Expander N B */ - }, - {2, IOEXP_TYPE_MAGINOLIA_NAB, { {4, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {4, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, }, /* addr[1] = I/O Expander N B */ - }, - {3, IOEXP_TYPE_MAGINOLIA_4AB, { {5, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander 4 A */ - {5, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xf0, 0xff}, {0xf0, 0xff}, }, }, /* addr[1] = I/O Expander 4 B */ - }, - {4, IOEXP_TYPE_MAGINOLIA_NAB, { {6, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {6, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, }, /* addr[1] = I/O Expander N B */ - }, - {5, IOEXP_TYPE_MAGINOLIA_NAB, { {7, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {7, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, }, /* addr[1] = I/O Expander N B */ - }, - {6, IOEXP_TYPE_MAGINOLIA_7AB, { {8, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[0] = I/O Expander 7 A */ - {8, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xf0, 0x33}, }, }, /* addr[1] = I/O Expander 7 B */ - }, -}; - -struct inv_port_layout_s magnolia_port_layout[] = { - /* Port_ID / Chan_ID / IOEXP_ID / IOEXP_VIRT_OFFSET / TRANSCEIVER_TYPE / BCM_CHIP_TYPE / LANE_ID */ - { 0, 10, 0, 0, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 16} }, - { 1, 11, 0, 1, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 15} }, - { 2, 12, 0, 2, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 14} }, - { 3, 13, 0, 3, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 13} }, - { 4, 14, 0, 4, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 24} }, - { 5, 15, 0, 5, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 23} }, - { 6, 16, 0, 6, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 22} }, - { 7, 17, 0, 7, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 21} }, - { 8, 18, 1, 0, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 28} }, - { 9, 19, 1, 1, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 27} }, - {10, 20, 1, 2, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 26} }, - {11, 21, 1, 3, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 25} }, - {12, 22, 1, 4, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 32} }, - {13, 23, 1, 5, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 31} }, - {14, 24, 1, 6, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 30} }, - {15, 25, 1, 7, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 29} }, - {16, 26, 2, 0, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 48} }, - {17, 27, 2, 1, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 47} }, - {18, 28, 2, 2, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 46} }, - {19, 29, 2, 3, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 45} }, - {20, 30, 2, 4, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 52} }, - {21, 31, 2, 5, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 51} }, - {22, 32, 2, 6, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 50} }, - {23, 33, 2, 7, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 49} }, - {24, 34, 3, 0, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 56} }, - {25, 35, 3, 1, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 55} }, - {26, 36, 3, 2, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 54} }, - {27, 37, 3, 3, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 53} }, - {28, 38, 3, 4, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 60} }, - {29, 39, 3, 5, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 59} }, - {30, 40, 3, 6, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 58} }, - {31, 41, 3, 7, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 57} }, - {32, 42, 4, 0, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 64} }, - {33, 43, 4, 1, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 63} }, - {34, 44, 4, 2, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 62} }, - {35, 45, 4, 3, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 61} }, - {36, 46, 4, 4, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 68} }, - {37, 47, 4, 5, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 67} }, - {38, 48, 4, 6, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 66} }, - {39, 49, 4, 7, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 65} }, - {40, 50, 5, 0, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 72} }, - {41, 51, 5, 1, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 71} }, - {42, 52, 5, 2, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 70} }, - {43, 53, 5, 3, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 69} }, - {44, 54, 5, 4, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 76} }, - {45, 55, 5, 5, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 75} }, - {46, 56, 5, 6, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 74} }, - {47, 57, 5, 7, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 73} }, - {48, 58, 6, 0, TRANSVR_TYPE_QSFP, BCM_CHIP_TYPE_TRIDENT_2, { 81, 82, 83, 84} }, - {49, 59, 6, 1, TRANSVR_TYPE_QSFP, BCM_CHIP_TYPE_TRIDENT_2, { 77, 78, 79, 80} }, - {50, 60, 6, 2, TRANSVR_TYPE_QSFP, BCM_CHIP_TYPE_TRIDENT_2, { 97, 98, 99,100} }, - {51, 61, 6, 3, TRANSVR_TYPE_QSFP, BCM_CHIP_TYPE_TRIDENT_2, {101,102,103,104} }, - {52, 62, 6, 4, TRANSVR_TYPE_QSFP, BCM_CHIP_TYPE_TRIDENT_2, {105,106,107,108} }, - {53, 63, 6, 5, TRANSVR_TYPE_QSFP, BCM_CHIP_TYPE_TRIDENT_2, {109,110,111,112} }, -}; -#endif - - -/* ========================================== - * Redwood Layout configuration - * ========================================== - */ -#ifdef SWPS_REDWOOD -unsigned redwood_gpio_rest_mux = MUX_RST_GPIO_48_PAC9548; - -struct inv_ioexp_layout_s redwood_ioexp_layout[] = { - /* IOEXP_ID / IOEXP_TYPE / { Chan_ID, Chip_addr, Read_offset, Write_offset, config_offset, data_default, conf_default } */ - {0, IOEXP_TYPE_REDWOOD_P01P08, { {4, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[0] = I/O Expander 1-4 A */ - {4, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[1] = I/O Expander 1-4 B */ - {0, 0x25, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 5 B */ - }, - {1, IOEXP_TYPE_REDWOOD_P09P16, { {5, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[0] = I/O Expander 1-4 A */ - {5, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[1] = I/O Expander 1-4 B */ - {0, 0x25, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 5 B */ - }, - {2, IOEXP_TYPE_REDWOOD_P01P08, { {2, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[0] = I/O Expander 1-4 A */ - {2, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[1] = I/O Expander 1-4 B */ - {0, 0x24, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 5 B */ - }, - {3, IOEXP_TYPE_REDWOOD_P09P16, { {3, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[0] = I/O Expander 1-4 A */ - {3, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[1] = I/O Expander 1-4 B */ - {0, 0x24, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 5 B */ - }, -}; - -struct inv_port_layout_s redwood_port_layout[] = { - /* Port_ID / Chan_ID / IOEXP_ID / IOEXP_VIRT_OFFSET / TRANSCEIVER_TYPE / BCM_CHIP_TYPE / LANE_ID */ - { 0, 22, 0, 0, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 1, 2, 3, 4} }, - { 1, 23, 0, 1, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 5, 6, 7, 8} }, - { 2, 24, 0, 2, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 9, 10, 11, 12} }, - { 3, 25, 0, 3, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 13, 14, 15, 16} }, - { 4, 26, 0, 4, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 17, 18, 19, 20} }, - { 5, 27, 0, 5, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 21, 22, 23, 24} }, - { 6, 28, 0, 6, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 25, 26, 27, 28} }, - { 7, 29, 0, 7, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 29, 30, 31, 32} }, - { 8, 30, 1, 0, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 33, 34, 35, 36} }, - { 9, 31, 1, 1, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 37, 38, 39, 40} }, - {10, 32, 1, 2, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 41, 42, 43, 44} }, - {11, 33, 1, 3, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 45, 46, 47, 48} }, - {12, 34, 1, 4, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 49, 50, 51, 52} }, - {13, 35, 1, 5, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 53, 54, 55, 56} }, - {14, 36, 1, 6, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 57, 58, 59, 60} }, - {15, 37, 1, 7, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 61, 62, 63, 64} }, - {16, 6, 2, 0, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 65, 66, 67, 68} }, - {17, 7, 2, 1, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 69, 70, 71, 72} }, - {18, 8, 2, 2, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 73, 74, 75, 76} }, - {19, 9, 2, 3, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 77, 78, 79, 80} }, - {20, 10, 2, 4, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 81, 82, 83, 84} }, - {21, 11, 2, 5, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 85, 86, 87, 88} }, - {22, 12, 2, 6, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 89, 90, 91, 92} }, - {23, 13, 2, 7, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 93, 94, 95, 96} }, - {24, 14, 3, 0, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 97, 98, 99,100} }, - {25, 15, 3, 1, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {101,102,103,104} }, - {26, 16, 3, 2, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {105,106,107,108} }, - {27, 17, 3, 3, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {109,110,111,112} }, - {28, 18, 3, 4, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {113,114,115,116} }, - {29, 19, 3, 5, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {117,118,119,120} }, - {30, 20, 3, 6, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {121,122,123,124} }, - {31, 21, 3, 7, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {125,126,127,128} }, -}; -#endif - - -/* ========================================== - * Hudson32i Layout configuration - * ========================================== - */ -#ifdef SWPS_HUDSON32I_GA -unsigned hudsin32iga_gpio_rest_mux = MUX_RST_GPIO_48_PAC9548; - -struct inv_ioexp_layout_s hudson32iga_ioexp_layout[] = { - /* IOEXP_ID / IOEXP_TYPE / { Chan_ID, Chip_addr, Read_offset, Write_offset, config_offset, data_default, conf_default } */ - {0, IOEXP_TYPE_HUDSON32IGA_P01P08, { {2, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[0] = I/O Expander A */ - {2, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[1] = I/O Expander B */ - {0, 0x24, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 0x24 */ - }, - {1, IOEXP_TYPE_HUDSON32IGA_P09P16, { {3, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[0] = I/O Expander A */ - {3, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[1] = I/O Expander B */ - {0, 0x24, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 0x24 */ - }, - {2, IOEXP_TYPE_HUDSON32IGA_P01P08, { {4, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[0] = I/O Expander A */ - {4, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[1] = I/O Expander B */ - {0, 0x25, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 0x25 */ - }, - {3, IOEXP_TYPE_HUDSON32IGA_P09P16, { {5, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[0] = I/O Expander A */ - {5, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[1] = I/O Expander B */ - {0, 0x25, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 0x25 */ - }, -}; - -struct inv_port_layout_s hudson32iga_port_layout[] = { - /* Port_ID / Chan_ID / IOEXP_ID / IOEXP_VIRT_OFFSET / TRANSCEIVER_TYPE / BCM_CHIP_TYPE / LANE_ID */ - { 0, 6, 0, 0, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, { 1, 2, 3, 4} }, - { 1, 7, 0, 1, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, { 5, 6, 7, 8} }, - { 2, 8, 0, 2, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, { 9, 10, 11, 12} }, - { 3, 9, 0, 3, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, { 13, 14, 15, 16} }, - { 4, 10, 0, 4, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, { 17, 18, 19, 20} }, - { 5, 11, 0, 5, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, { 21, 22, 23, 24} }, - { 6, 12, 0, 6, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, { 25, 26, 27, 28} }, - { 7, 13, 0, 7, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, { 29, 30, 31, 32} }, - { 8, 14, 1, 0, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, { 33, 34, 35, 36} }, - { 9, 15, 1, 1, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, { 37, 38, 39, 40} }, - {10, 16, 1, 2, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, { 41, 42, 43, 44} }, - {11, 17, 1, 3, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, { 45, 46, 47, 48} }, - {12, 18, 1, 4, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, { 49, 50, 51, 52} }, - {13, 19, 1, 5, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, { 53, 54, 55, 56} }, - {14, 20, 1, 6, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, { 57, 58, 59, 60} }, - {15, 21, 1, 7, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, { 61, 62, 63, 64} }, - {16, 22, 2, 0, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, { 65, 66, 67, 68} }, - {17, 23, 2, 1, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, { 69, 70, 71, 72} }, - {18, 24, 2, 2, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, { 73, 74, 75, 76} }, - {19, 25, 2, 3, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, { 77, 78, 79, 80} }, - {20, 26, 2, 4, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, { 81, 82, 83, 84} }, - {21, 27, 2, 5, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, { 85, 86, 87, 88} }, - {22, 28, 2, 6, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, { 89, 90, 91, 92} }, - {23, 29, 2, 7, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, { 93, 94, 95, 96} }, - {24, 30, 3, 0, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, { 97, 98, 99,100} }, - {25, 31, 3, 1, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, {101,102,103,104} }, - {26, 32, 3, 2, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, {105,106,107,108} }, - {27, 33, 3, 3, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, {109,110,111,112} }, - {28, 34, 3, 4, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, {113,114,115,116} }, - {29, 35, 3, 5, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, {117,118,119,120} }, - {30, 36, 3, 6, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, {121,122,123,124} }, - {31, 37, 3, 7, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, {125,126,127,128} }, -}; -#endif - - -/* ========================================== - * Spruce Layout configuration - * ========================================== - */ -#ifdef SWPS_SPRUCE -unsigned spruce_gpio_rest_mux = MUX_RST_GPIO_48_PAC9548; - -struct inv_ioexp_layout_s spruce_ioexp_layout[] = { - /* IOEXP_ID / IOEXP_TYPE / { Chan_ID, Chip_addr, Read_offset, Write_offset, config_offset, data_default, conf_default } */ - {0, IOEXP_TYPE_SPRUCE_7AB, { {2, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[0] = I/O Expander 7A */ - {2, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xf0, 0x33}, }, }, /* addr[2] = I/O Expander 7B */ - }, -}; - -struct inv_port_layout_s spruce_port_layout[] = { - /* Port_ID / Chan_ID / IOEXP_ID / IOEXP_VIRT_OFFSET / TRANSCEIVER_TYPE / BCM_CHIP_TYPE / LANE_ID */ - { 0, 6, 0, 0, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, { 81, 82, 83, 84} }, - { 1, 7, 0, 1, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, { 77, 78, 79, 80} }, - { 2, 8, 0, 2, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, { 97, 98, 99,100} }, - { 3, 9, 0, 3, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, {101,102,103,104} }, - { 4, 10, 0, 4, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, {105,106,107,108} }, - { 5, 11, 0, 5, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, {109,110,111,112} }, -}; -#endif - - -/* ========================================== - * Cypress Layout configuration (Inventec version [Up->Down]) - * ========================================== - */ -#ifdef SWPS_CYPRESS_GA1 -unsigned cypress_ga1_gpio_rest_mux = MUX_RST_GPIO_69_PAC9548; - -struct inv_ioexp_layout_s cypress_ga1_ioexp_layout[] = { - /* IOEXP_ID / IOEXP_TYPE / { Chan_ID, Chip_addr, Read_offset, Write_offset, config_offset, data_default, conf_default } */ - {0, IOEXP_TYPE_CYPRESS_NABC, { {2, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {2, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {2, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {1, IOEXP_TYPE_CYPRESS_NABC, { {3, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {3, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {3, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {2, IOEXP_TYPE_CYPRESS_NABC, { {4, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {4, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {4, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {3, IOEXP_TYPE_CYPRESS_NABC, { {5, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {5, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {5, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {4, IOEXP_TYPE_CYPRESS_NABC, { {6, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {6, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {6, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {5, IOEXP_TYPE_CYPRESS_NABC, { {7, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {7, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {7, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {6, IOEXP_TYPE_CYPRESS_7ABC, { {8, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xc0, 0xc0}, }, /* addr[0] = I/O Expander 7 A */ - {8, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xc0, 0xc0}, {0xff, 0xc0}, }, /* addr[1] = I/O Expander 7 B */ - {8, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 7 C */ - }, -}; - -struct inv_port_layout_s cypress_ga1_port_layout[] = { - /* Port_ID / Chan_ID / IOEXP_ID / IOEXP_VIRT_OFFSET / TRANSCEIVER_TYPE / BCM_CHIP_TYPE / LANE_ID */ - { 0, 10, 0, 0, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 1} }, - { 1, 11, 0, 1, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 2} }, - { 2, 12, 0, 2, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 3} }, - { 3, 13, 0, 3, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 4} }, - { 4, 14, 0, 4, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 5} }, - { 5, 15, 0, 5, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 6} }, - { 6, 16, 0, 6, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 7} }, - { 7, 17, 0, 7, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 8} }, - { 8, 18, 1, 0, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 9} }, - { 9, 19, 1, 1, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 10} }, - {10, 20, 1, 2, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 11} }, - {11, 21, 1, 3, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 12} }, - {12, 22, 1, 4, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 21} }, - {13, 23, 1, 5, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 22} }, - {14, 24, 1, 6, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 23} }, - {15, 25, 1, 7, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 24} }, - {16, 26, 2, 0, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 33} }, - {17, 27, 2, 1, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 34} }, - {18, 28, 2, 2, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 35} }, - {19, 29, 2, 3, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 36} }, - {20, 30, 2, 4, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 37} }, - {21, 31, 2, 5, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 38} }, - {22, 32, 2, 6, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 39} }, - {23, 33, 2, 7, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 40} }, - {24, 34, 3, 0, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 41} }, - {25, 35, 3, 1, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 42} }, - {26, 36, 3, 2, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 43} }, - {27, 37, 3, 3, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 44} }, - {28, 38, 3, 4, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 49} }, - {29, 39, 3, 5, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 50} }, - {30, 40, 3, 6, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 51} }, - {31, 41, 3, 7, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 52} }, - {32, 42, 4, 0, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 53} }, - {33, 43, 4, 1, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 54} }, - {34, 44, 4, 2, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 55} }, - {35, 45, 4, 3, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 56} }, - {36, 46, 4, 4, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 65} }, - {37, 47, 4, 5, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 66} }, - {38, 48, 4, 6, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 67} }, - {39, 49, 4, 7, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 68} }, - {40, 50, 5, 0, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 69} }, - {41, 51, 5, 1, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 70} }, - {42, 52, 5, 2, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 71} }, - {43, 53, 5, 3, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 72} }, - {44, 54, 5, 4, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 81} }, - {45, 55, 5, 5, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 82} }, - {46, 56, 5, 6, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 83} }, - {47, 57, 5, 7, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 84} }, - {48, 58, 6, 0, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 97, 98, 99,100} }, - {49, 59, 6, 1, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 85, 86, 87, 88} }, - {50, 60, 6, 2, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {101,102,103,104} }, - {51, 61, 6, 3, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {105,106,107,108} }, - {52, 62, 6, 4, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {109,110,111,112} }, - {53, 63, 6, 5, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {117,118,119,120} }, -}; -#endif - - -/* ========================================== - * Cypress Layout configuration (Inventec version [Down->Up]) - * ========================================== - */ -#ifdef SWPS_CYPRESS_GA2 -unsigned cypress_ga2_gpio_rest_mux = MUX_RST_GPIO_FORCE_HEDERA; - -struct inv_ioexp_layout_s cypress_ga2_ioexp_layout[] = { - /* IOEXP_ID / IOEXP_TYPE / { Chan_ID, Chip_addr, Read_offset, Write_offset, config_offset, data_default, conf_default } */ - {0, IOEXP_TYPE_CYPRESS_NABC, { {2, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {2, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {2, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {1, IOEXP_TYPE_CYPRESS_NABC, { {3, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {3, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {3, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {2, IOEXP_TYPE_CYPRESS_NABC, { {4, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {4, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {4, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {3, IOEXP_TYPE_CYPRESS_NABC, { {5, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {5, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {5, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {4, IOEXP_TYPE_CYPRESS_NABC, { {6, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {6, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {6, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {5, IOEXP_TYPE_CYPRESS_NABC, { {7, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {7, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {7, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {6, IOEXP_TYPE_CYPRESS_7ABC, { {8, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xc0, 0xc0}, }, /* addr[0] = I/O Expander 7 A */ - {8, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xc0, 0xc0}, {0xff, 0xc0}, }, /* addr[1] = I/O Expander 7 B */ - {8, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 7 C */ - }, -}; - -struct inv_port_layout_s cypress_ga2_port_layout[] = { - /* Port_ID / Chan_ID / IOEXP_ID / IOEXP_VIRT_OFFSET / TRANSCEIVER_TYPE / BCM_CHIP_TYPE / LANE_ID */ - { 0, 11, 0, 1, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 2} }, - { 1, 10, 0, 0, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 1} }, - { 2, 13, 0, 3, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 4} }, - { 3, 12, 0, 2, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 3} }, - { 4, 15, 0, 5, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 6} }, - { 5, 14, 0, 4, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 5} }, - { 6, 17, 0, 7, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 8} }, - { 7, 16, 0, 6, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 7} }, - { 8, 19, 1, 1, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 10} }, - { 9, 18, 1, 0, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 9} }, - {10, 21, 1, 3, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 12} }, - {11, 20, 1, 2, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 11} }, - {12, 23, 1, 5, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 22} }, - {13, 22, 1, 4, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 21} }, - {14, 25, 1, 7, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 24} }, - {15, 24, 1, 6, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 23} }, - {16, 27, 2, 1, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 34} }, - {17, 26, 2, 0, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 33} }, - {18, 29, 2, 3, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 36} }, - {19, 28, 2, 2, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 35} }, - {20, 31, 2, 5, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 38} }, - {21, 30, 2, 4, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 37} }, - {22, 33, 2, 7, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 40} }, - {23, 32, 2, 6, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 39} }, - {24, 35, 3, 1, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 42} }, - {25, 34, 3, 0, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 41} }, - {26, 37, 3, 3, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 44} }, - {27, 36, 3, 2, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 43} }, - {28, 39, 3, 5, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 50} }, - {29, 38, 3, 4, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 49} }, - {30, 41, 3, 7, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 52} }, - {31, 40, 3, 6, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 51} }, - {32, 43, 4, 1, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 54} }, - {33, 42, 4, 0, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 53} }, - {34, 45, 4, 3, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 56} }, - {35, 44, 4, 2, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 55} }, - {36, 47, 4, 5, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 66} }, - {37, 46, 4, 4, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 65} }, - {38, 49, 4, 7, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 68} }, - {39, 48, 4, 6, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 67} }, - {40, 51, 5, 1, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 70} }, - {41, 50, 5, 0, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 69} }, - {42, 53, 5, 3, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 72} }, - {43, 52, 5, 2, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 71} }, - {44, 55, 5, 5, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 82} }, - {45, 54, 5, 4, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 81} }, - {46, 57, 5, 7, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 84} }, - {47, 56, 5, 6, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 83} }, - {48, 59, 6, 1, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 85, 86, 87, 88} }, - {49, 58, 6, 0, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 97, 98, 99,100} }, - {50, 61, 6, 3, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {105,106,107,108} }, - {51, 60, 6, 2, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {101,102,103,104} }, - {52, 63, 6, 5, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {117,118,119,120} }, - {53, 62, 6, 4, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {109,110,111,112} }, -}; -#endif - - -/* ========================================== - * Cypress Layout configuration (BaiDu version) - * ========================================== - */ -#ifdef SWPS_CYPRESS_BAI -unsigned cypress_b_gpio_rest_mux = MUX_RST_GPIO_FORCE_HEDERA; - -struct inv_ioexp_layout_s cypress_b_ioexp_layout[] = { - /* IOEXP_ID / IOEXP_TYPE / { Chan_ID, Chip_addr, Read_offset, Write_offset, config_offset, data_default, conf_default } */ - {0, IOEXP_TYPE_CYPRESS_NABC, { {2, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {2, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {2, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {1, IOEXP_TYPE_CYPRESS_NABC, { {3, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {3, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {3, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {2, IOEXP_TYPE_CYPRESS_NABC, { {4, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {4, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {4, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {3, IOEXP_TYPE_CYPRESS_NABC, { {5, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {5, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {5, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {4, IOEXP_TYPE_CYPRESS_NABC, { {6, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {6, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {6, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {5, IOEXP_TYPE_CYPRESS_NABC, { {7, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {7, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {7, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {6, IOEXP_TYPE_CYPRESS_7ABC, { {8, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xc0, 0xc0}, }, /* addr[0] = I/O Expander 7 A */ - {8, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xc0, 0xc0}, {0xff, 0xc0}, }, /* addr[1] = I/O Expander 7 B */ - {8, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 7 C */ - }, -}; - -struct inv_port_layout_s cypress_b_port_layout[] = { - /* Port_ID / Chan_ID / IOEXP_ID / IOEXP_VIRT_OFFSET / TRANSCEIVER_TYPE / BCM_CHIP_TYPE / LANE_ID */ - { 1, 11, 0, 1, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 2} }, - { 2, 10, 0, 0, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 1} }, - { 3, 13, 0, 3, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 4} }, - { 4, 12, 0, 2, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 3} }, - { 5, 15, 0, 5, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 6} }, - { 6, 14, 0, 4, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 5} }, - { 7, 17, 0, 7, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 8} }, - { 8, 16, 0, 6, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 7} }, - { 9, 19, 1, 1, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 10} }, - {10, 18, 1, 0, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 9} }, - {11, 21, 1, 3, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 12} }, - {12, 20, 1, 2, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 11} }, - {13, 23, 1, 5, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 22} }, - {14, 22, 1, 4, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 21} }, - {15, 25, 1, 7, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 24} }, - {16, 24, 1, 6, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 23} }, - {17, 27, 2, 1, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 34} }, - {18, 26, 2, 0, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 33} }, - {19, 29, 2, 3, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 36} }, - {20, 28, 2, 2, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 35} }, - {21, 31, 2, 5, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 38} }, - {22, 30, 2, 4, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 37} }, - {23, 33, 2, 7, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 40} }, - {24, 32, 2, 6, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 39} }, - {25, 35, 3, 1, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 42} }, - {26, 34, 3, 0, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 41} }, - {27, 37, 3, 3, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 44} }, - {28, 36, 3, 2, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 43} }, - {29, 39, 3, 5, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 50} }, - {30, 38, 3, 4, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 49} }, - {31, 41, 3, 7, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 52} }, - {32, 40, 3, 6, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 51} }, - {33, 43, 4, 1, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 54} }, - {34, 42, 4, 0, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 53} }, - {35, 45, 4, 3, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 56} }, - {36, 44, 4, 2, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 55} }, - {37, 47, 4, 5, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 66} }, - {38, 46, 4, 4, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 65} }, - {39, 49, 4, 7, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 68} }, - {40, 48, 4, 6, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 67} }, - {41, 51, 5, 1, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 70} }, - {42, 50, 5, 0, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 69} }, - {43, 53, 5, 3, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 72} }, - {44, 52, 5, 2, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 71} }, - {45, 55, 5, 5, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 82} }, - {46, 54, 5, 4, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 81} }, - {47, 57, 5, 7, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 84} }, - {48, 56, 5, 6, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 83} }, - {49, 59, 6, 1, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 85, 86, 87, 88} }, - {50, 58, 6, 0, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 97, 98, 99,100} }, - {51, 61, 6, 3, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {105,106,107,108} }, - {52, 60, 6, 2, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {101,102,103,104} }, - {53, 63, 6, 5, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {117,118,119,120} }, - {54, 62, 6, 4, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {109,110,111,112} }, -}; -#endif - - -/* ========================================== - * Redwood_fsl Layout configuration - * ========================================== - */ -#ifdef SWPS_REDWOOD_FSL -unsigned redwood_fsl_gpio_rest_mux = MUX_RST_GPIO_48_PAC9548; - -struct inv_ioexp_layout_s redwood_fsl_ioexp_layout[] = { - /* IOEXP_ID / IOEXP_TYPE / { Chan_ID, Chip_addr, Read_offset, Write_offset, config_offset, data_default, conf_default } */ - {0, IOEXP_TYPE_REDWOOD_P01P08, { {4, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[0] = I/O Expander 1-4 A */ - {4, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[1] = I/O Expander 1-4 B */ - {0, 0x25, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 5 B */ - }, - {1, IOEXP_TYPE_REDWOOD_P09P16, { {5, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[0] = I/O Expander 1-4 A */ - {5, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[1] = I/O Expander 1-4 B */ - {0, 0x25, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 5 B */ - }, - {2, IOEXP_TYPE_REDWOOD_P01P08, { {2, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[0] = I/O Expander 1-4 A */ - {2, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[1] = I/O Expander 1-4 B */ - {0, 0x24, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 5 B */ - }, - {3, IOEXP_TYPE_REDWOOD_P09P16, { {3, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[0] = I/O Expander 1-4 A */ - {3, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[1] = I/O Expander 1-4 B */ - {0, 0x24, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 5 B */ - }, -}; - - -struct inv_port_layout_s redwood_fsl_port_layout[] = { - /* Port_ID / Chan_ID / IOEXP_ID / IOEXP_VIRT_OFFSET / TRANSCEIVER_TYPE / BCM_CHIP_TYPE / LANE_ID */ - { 0, 22, 0, 0, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 1, 2, 3, 4} }, - { 1, 23, 0, 1, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 5, 6, 7, 8} }, - { 2, 24, 0, 2, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 9, 10, 11, 12} }, - { 3, 25, 0, 3, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 13, 14, 15, 16} }, - { 4, 26, 0, 4, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 17, 18, 19, 20} }, - { 5, 27, 0, 5, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 21, 22, 23, 24} }, - { 6, 28, 0, 6, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 25, 26, 27, 28} }, - { 7, 29, 0, 7, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 29, 30, 31, 32} }, - { 8, 30, 1, 0, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 33, 34, 35, 36} }, - { 9, 31, 1, 1, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 37, 38, 39, 40} }, - {10, 32, 1, 2, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 41, 42, 43, 44} }, - {11, 33, 1, 3, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 45, 46, 47, 48} }, - {12, 34, 1, 4, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 49, 50, 51, 52} }, - {13, 35, 1, 5, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 53, 54, 55, 56} }, - {14, 36, 1, 6, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 57, 58, 59, 60} }, - {15, 37, 1, 7, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 61, 62, 63, 64} }, - {16, 6, 2, 0, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 65, 66, 67, 68} }, - {17, 7, 2, 1, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 69, 70, 71, 72} }, - {18, 8, 2, 2, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 73, 74, 75, 76} }, - {19, 9, 2, 3, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 77, 78, 79, 80} }, - {20, 10, 2, 4, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 81, 82, 83, 84} }, - {21, 11, 2, 5, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 85, 86, 87, 88} }, - {22, 12, 2, 6, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 89, 90, 91, 92} }, - {23, 13, 2, 7, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 93, 94, 95, 96} }, - {24, 14, 3, 0, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 97, 98, 99,100} }, - {25, 15, 3, 1, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {101,102,103,104} }, - {26, 16, 3, 2, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {105,106,107,108} }, - {27, 17, 3, 3, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {109,110,111,112} }, - {28, 18, 3, 4, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {113,114,115,116} }, - {29, 19, 3, 5, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {117,118,119,120} }, - {30, 20, 3, 6, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {121,122,123,124} }, - {31, 21, 3, 7, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {125,126,127,128} }, -}; -#endif - - -/* ========================================== - * Tahoe Layout configuration - * ========================================== - */ -#ifdef SWPS_TAHOE -unsigned tahoe_gpio_rest_mux = MUX_RST_GPIO_249_PCA9548; - -struct inv_ioexp_layout_s tahoe_ioexp_layout[] = { - /* IOEXP_ID / IOEXP_TYPE / { Chan_ID, Chip_addr, Read_offset, Write_offset, config_offset, data_default, conf_default } */ - {0, IOEXP_TYPE_TAHOE_6ABC, { {7, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xce, 0xb9}, {0x18, 0xe3}, }, /* addr[0] = I/O Expander 6 A */ - {7, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xce, 0xb9}, {0x18, 0xe3}, }, /* addr[1] = I/O Expander 6 B */ - {7, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xce, 0xb9}, {0x18, 0xe3}, }, }, /* addr[2] = I/O Expander 6 C */ - }, - {1, IOEXP_TYPE_TAHOE_5A, { {6, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xce, 0xb9}, {0x18, 0xe3}, }, }, /* addr[0] = I/O Expander 5 A */ - }, -}; - - -struct inv_port_layout_s tahoe_port_layout[] = { - /* Port_ID / Chan_ID / IOEXP_ID / IOEXP_VIRT_OFFSET / TRANSCEIVER_TYPE / BCM_CHIP_TYPE / LANE_ID */ - { 0, 12, 1, 2, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 65, 66, 67, 68} }, - { 1, 11, 1, 1, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 53, 54, 55, 56} }, - { 2, 22, 0, 5, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 69, 70, 71, 72} }, - { 3, 21, 0, 4, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 81, 82, 83, 84} }, - { 4, 24, 0, 7, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 97, 98, 99, 100} }, - { 5, 23, 0, 6, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 85, 86, 87, 88} }, - { 6, 18, 0, 1, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {101, 102, 103, 104} }, - { 7, 17, 0, 0, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {105, 106, 107, 108} }, - { 8, 20, 0, 3, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {113, 114, 115, 116} }, - { 9, 19, 0, 2, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {109, 110, 111, 112} }, -}; -#endif - - -/* ========================================== - * Sequoia Layout configuration - * ========================================== - */ -#ifdef SWPS_SEQUOIA -unsigned sequoia_gpio_rest_mux = MUX_RST_GPIO_69_PAC9548; - -struct inv_ioexp_layout_s sequoia_ioexp_layout[] = { - /* IOEXP_ID / IOEXP_TYPE / { Chan_ID, Chip_addr, Read_offset, Write_offset, config_offset, data_default, conf_default } */ - {0, IOEXP_TYPE_SEQUOIA_NABC, { {1, 0x20, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0x00, 0x00}, }, /* addr[0] = I/O Expander 0 A */ - {1, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0xff}, }, /* addr[1] = I/O Expander 0 B */ - {1, 0x22, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 0 C */ - }, - {1, IOEXP_TYPE_SEQUOIA_NABC, { {2, 0x20, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0x00, 0x00}, }, /* addr[0] = I/O Expander 1 A */ - {2, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0xff}, }, /* addr[1] = I/O Expander 1 B */ - {2, 0x22, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 1 C */ - }, - {2, IOEXP_TYPE_SEQUOIA_NABC, { {3, 0x20, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0x00, 0x00}, }, /* addr[0] = I/O Expander 2 A */ - {3, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0xff}, }, /* addr[1] = I/O Expander 2 B */ - {3, 0x22, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 2 C */ - }, - {3, IOEXP_TYPE_SEQUOIA_NABC, { {4, 0x20, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0x00, 0x00}, }, /* addr[0] = I/O Expander 3 A */ - {4, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0xff}, }, /* addr[1] = I/O Expander 3 B */ - {4, 0x22, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 3 C */ - }, - {4, IOEXP_TYPE_SEQUOIA_NABC, { {5, 0x20, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0x00, 0x00}, }, /* addr[0] = I/O Expander 4 A */ - {5, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0xff}, }, /* addr[1] = I/O Expander 4 B */ - {5, 0x22, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 4 C */ - }, - {5, IOEXP_TYPE_SEQUOIA_NABC, { {6, 0x20, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0x00, 0x00}, }, /* addr[0] = I/O Expander 5 A */ - {6, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0xff}, }, /* addr[1] = I/O Expander 5 B */ - {6, 0x22, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 5 C */ - }, - {6, IOEXP_TYPE_SEQUOIA_NABC, { {7, 0x20, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0x00, 0x00}, }, /* addr[0] = I/O Expander 6 A */ - {7, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0xff}, }, /* addr[1] = I/O Expander 6 B */ - {7, 0x22, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 6 C */ - }, - {7, IOEXP_TYPE_SEQUOIA_NABC, { {8, 0x20, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0x00, 0x00}, }, /* addr[0] = I/O Expander 7 A */ - {8, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0xff}, }, /* addr[1] = I/O Expander 7 B */ - {8, 0x22, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 7 C */ - }, -}; - - -struct inv_port_layout_s sequoia_port_layout[] = { - /* Port_ID / Chan_ID / IOEXP_ID / IOEXP_VIRT_OFFSET / TRANSCEIVER_TYPE / BCM_CHIP_TYPE / LANE_ID */ - { 0, 9, 0, 0, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 9, 10, 11, 12} }, - { 1, 10, 0, 1, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 1, 2, 3, 4} }, - { 2, 11, 0, 2, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 25, 26, 27, 28} }, - { 3, 12, 0, 3, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 17, 18, 19, 20} }, - { 4, 13, 0, 4, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 41, 42, 43, 44} }, - { 5, 14, 0, 5, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 33, 34, 35, 36} }, - { 6, 15, 0, 6, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 57, 58, 59, 60} }, - { 7, 16, 0, 7, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 49, 50, 51, 52} }, - { 8, 17, 1, 0, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 73, 74, 75, 76} }, - { 9, 18, 1, 1, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 65, 66, 67, 68} }, - {10, 19, 1, 2, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 89, 90, 91, 92} }, - {11, 20, 1, 3, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 81, 82, 83, 84} }, - {12, 21, 1, 4, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {105, 106, 107, 108} }, - {13, 22, 1, 5, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 97, 98, 99, 100} }, - {14, 23, 1, 6, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {121, 122, 123, 124} }, - {15, 24, 1, 7, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {113, 114, 115, 116} }, - {16, 25, 2, 0, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {137, 138, 139, 140} }, - {17, 26, 2, 1, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {129, 130, 131, 132} }, - {18, 27, 2, 2, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {153, 154, 155, 156} }, - {19, 28, 2, 3, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {145, 146, 147, 148} }, - {20, 29, 2, 4, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {169, 170, 171, 172} }, - {21, 30, 2, 5, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {161, 162, 163, 164} }, - {22, 31, 2, 6, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {185, 186, 187, 188} }, - {23, 32, 2, 7, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {177, 178, 179, 180} }, - {24, 33, 3, 0, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {201, 202, 203, 204} }, - {25, 34, 3, 1, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {193, 194, 195, 196} }, - {26, 35, 3, 2, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {217, 218, 219, 220} }, - {27, 36, 3, 3, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {209, 210, 211, 212} }, - {28, 37, 3, 4, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {233, 234, 235, 236} }, - {29, 38, 3, 5, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {225, 226, 227, 228} }, - {30, 39, 3, 6, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {249, 250, 251, 252} }, - {31, 40, 3, 7, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {241, 242, 243, 244} }, - {32, 44, 4, 3, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 13, 14, 15, 16} }, - {33, 43, 4, 2, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 5, 6, 7, 8} }, - {34, 42, 4, 1, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 29, 30, 31, 32} }, - {35, 41, 4, 0, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 21, 22, 23, 24} }, - {36, 48, 4, 7, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 45, 46, 47, 48} }, - {37, 47, 4, 6, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 37, 38, 39, 40} }, - {38, 46, 4, 5, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 61, 62, 63, 64} }, - {39, 45, 4, 4, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 53, 54, 55, 56} }, - {40, 52, 5, 3, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 77, 78, 79, 80} }, - {41, 51, 5, 2, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 69, 70, 71, 72} }, - {42, 50, 5, 1, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 93, 94, 95, 96} }, - {43, 49, 5, 0, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 85, 86, 87, 88} }, - {44, 56, 5, 7, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {109, 110, 111, 112} }, - {45, 55, 5, 6, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {101, 102, 103, 104} }, - {46, 54, 5, 5, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {125, 126, 127, 128} }, - {47, 53, 5, 4, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {117, 118, 119, 120} }, - {48, 60, 6, 3, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {141, 142, 143, 144} }, - {49, 59, 6, 2, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {133, 134, 135, 136} }, - {50, 58, 6, 1, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {157, 158, 159, 160} }, - {51, 57, 6, 0, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {149, 150, 151, 152} }, - {52, 64, 6, 7, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {173, 174, 175, 176} }, - {53, 63, 6, 6, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {165, 166, 167, 168} }, - {54, 62, 6, 5, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {189, 190, 191, 192} }, - {55, 61, 6, 4, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {181, 182, 183, 184} }, - {56, 68, 7, 3, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {205, 206, 207, 208} }, - {57, 67, 7, 2, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {197, 198, 199, 200} }, - {58, 66, 7, 1, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {221, 222, 223, 224} }, - {59, 65, 7, 0, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {213, 214, 215, 216} }, - {60, 72, 7, 7, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {237, 238, 239, 240} }, - {61, 71, 7, 6, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {229, 230, 231, 232} }, - {62, 70, 7, 5, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {253, 254, 255, 256} }, - {63, 69, 7, 4, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {245, 246, 247, 248} }, -}; -#endif - - -/* ========================================== - * Lavender Layout configuration - * ========================================== - */ -#if (PLATFORM_SETTINGS == PLATFORM_TYPE_LAVENDER_GA) -unsigned lavender_gpio_rest_mux = MUX_RST_GPIO_505_PCA9548; -#elif (PLATFORM_SETTINGS == PLATFORM_TYPE_LAVENDER_ONL) -unsigned lavender_gpio_rest_mux = MUX_RST_GPIO_69_PAC9548; -#endif - -#ifdef SWPS_LAVENDER -struct inv_ioexp_layout_s lavender_ioexp_layout[] = { - /* IOEXP_ID / IOEXP_TYPE / { Chan_ID, Chip_addr, Read_offset, Write_offset, config_offset, data_default, conf_default } */ - {0, IOEXP_TYPE_SEQUOIA_NABC, { { 1, 0x20, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0x00, 0x00}, }, /* addr[0] = I/O Expander 0 A */ - { 1, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0xff}, }, /* addr[1] = I/O Expander 0 B */ - { 1, 0x22, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 0 C */ - }, - {1, IOEXP_TYPE_SEQUOIA_NABC, { { 2, 0x20, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0x00, 0x00}, }, /* addr[0] = I/O Expander 1 A */ - { 2, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0xff}, }, /* addr[1] = I/O Expander 1 B */ - { 2, 0x22, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 1 C */ - }, - {2, IOEXP_TYPE_SEQUOIA_NABC, { { 3, 0x20, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0x00, 0x00}, }, /* addr[0] = I/O Expander 2 A */ - { 3, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0xff}, }, /* addr[1] = I/O Expander 2 B */ - { 3, 0x22, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 2 C */ - }, - {3, IOEXP_TYPE_SEQUOIA_NABC, { { 4, 0x20, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0x00, 0x00}, }, /* addr[0] = I/O Expander 3 A */ - { 4, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0xff}, }, /* addr[1] = I/O Expander 3 B */ - { 4, 0x22, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 3 C */ - }, - {4, IOEXP_TYPE_SEQUOIA_NABC, { { 9, 0x20, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0x00, 0x00}, }, /* addr[0] = I/O Expander 4 A */ - { 9, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0xff}, }, /* addr[1] = I/O Expander 4 B */ - { 9, 0x22, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 4 C */ - }, - {5, IOEXP_TYPE_SEQUOIA_NABC, { {10, 0x20, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0x00, 0x00}, }, /* addr[0] = I/O Expander 5 A */ - {10, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0xff}, }, /* addr[1] = I/O Expander 5 B */ - {10, 0x22, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 5 C */ - }, - {6, IOEXP_TYPE_SEQUOIA_NABC, { {11, 0x20, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0x00, 0x00}, }, /* addr[0] = I/O Expander 6 A */ - {11, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0xff}, }, /* addr[1] = I/O Expander 6 B */ - {11, 0x22, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 6 C */ - }, - {7, IOEXP_TYPE_SEQUOIA_NABC, { {12, 0x20, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0x00, 0x00}, }, /* addr[0] = I/O Expander 7 A */ - {12, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0xff}, }, /* addr[1] = I/O Expander 7 B */ - {12, 0x22, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 7 C */ - }, - {8, IOEXP_TYPE_LAVENDER_P65, { { 5, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xF6, 0xff}, {0xF8, 0xff}, }, }, /* addr[0] = I/O Expander CPU */ - }, -}; - - -struct inv_port_layout_s lavender_port_layout[] = { - /* Port_ID / Chan_ID / IOEXP_ID / IOEXP_VIRT_OFFSET / TRANSCEIVER_TYPE / BCM_CHIP_TYPE / LANE_ID */ - { 0, 17, 0, 0, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, {188, 189, 190, 191} }, - { 1, 18, 0, 1, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, {184, 185, 186, 187} }, - { 2, 19, 0, 2, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, {180, 181, 182, 183} }, - { 3, 20, 0, 3, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, {176, 177, 178, 179} }, - { 4, 21, 0, 4, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, {172, 173, 174, 175} }, - { 5, 22, 0, 5, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, {168, 169, 170, 171} }, - { 6, 23, 0, 6, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, {164, 165, 166, 167} }, - { 7, 24, 0, 7, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, {160, 161, 162, 163} }, - { 8, 25, 1, 0, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, {156, 157, 158, 159} }, - { 9, 26, 1, 1, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, {152, 153, 154, 155} }, - {10, 27, 1, 2, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, {148, 149, 150, 151} }, - {11, 28, 1, 3, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, {144, 145, 146, 147} }, - {12, 29, 1, 4, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, {140, 141, 142, 143} }, - {13, 30, 1, 5, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, {136, 137, 138, 139} }, - {14, 31, 1, 6, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, {132, 133, 134, 135} }, - {15, 32, 1, 7, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, {128, 129, 130, 131} }, - {16, 33, 2, 0, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, { 0, 1, 2, 3} }, - {17, 34, 2, 1, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, { 4, 5, 6, 7} }, - {18, 35, 2, 2, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, { 8, 9, 10, 11} }, - {19, 36, 2, 3, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, { 12, 13, 14, 15} }, - {20, 37, 2, 4, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, { 16, 17, 18, 19} }, - {21, 38, 2, 5, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, { 20, 21, 22, 23} }, - {22, 39, 2, 6, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, { 24, 25, 26, 27} }, - {23, 40, 2, 7, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, { 28, 29, 30, 31} }, - {24, 41, 3, 0, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, { 32, 33, 34, 35} }, - {25, 42, 3, 1, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, { 36, 37, 38, 39} }, - {26, 43, 3, 2, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, { 40, 41, 42, 43} }, - {27, 44, 3, 3, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, { 44, 45, 46, 47} }, - {28, 45, 3, 4, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, { 48, 49, 50, 51} }, - {29, 46, 3, 5, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, { 52, 53, 54, 55} }, - {30, 47, 3, 6, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, { 56, 57, 58, 59} }, - {31, 48, 3, 7, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, { 60, 61, 62, 63} }, - {32, 49, 4, 0, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, {256, 257, 258, 259} }, - {33, 50, 4, 1, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, {260, 261, 262, 263} }, - {34, 51, 4, 2, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, {264, 265, 266, 267} }, - {35, 52, 4, 3, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, {268, 269, 270, 271} }, - {36, 53, 4, 4, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, {272, 273, 274, 275} }, - {37, 54, 4, 5, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, {276, 277, 278, 279} }, - {38, 55, 4, 6, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, {280, 281, 282, 283} }, - {39, 56, 4, 7, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, {284, 285, 286, 287} }, - {40, 57, 5, 0, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, {288, 289, 290, 291} }, - {41, 58, 5, 1, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, {292, 293, 294, 295} }, - {42, 59, 5, 2, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, {296, 297, 298, 299} }, - {43, 60, 5, 3, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, {300, 301, 302, 303} }, - {44, 61, 5, 4, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, {304, 305, 306, 307} }, - {45, 62, 5, 5, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, {308, 309, 310, 311} }, - {46, 63, 5, 6, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, {312, 313, 314, 315} }, - {47, 64, 5, 7, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, {316, 317, 318, 319} }, - {48, 65, 6, 0, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, {444, 445, 446, 447} }, - {49, 66, 6, 1, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, {440, 441, 442, 443} }, - {50, 67, 6, 2, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, {436, 437, 438, 439} }, - {51, 68, 6, 3, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, {432, 433, 434, 435} }, - {52, 69, 6, 4, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, {428, 429, 430, 431} }, - {53, 70, 6, 5, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, {424, 425, 426, 427} }, - {54, 71, 6, 6, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, {420, 421, 422, 423} }, - {55, 72, 6, 7, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, {416, 417, 418, 419} }, - {56, 73, 7, 0, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, {412, 413, 414, 415} }, - {57, 74, 7, 1, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, {408, 409, 410, 411} }, - {58, 75, 7, 2, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, {404, 405, 406, 407} }, - {59, 76, 7, 3, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, {400, 401, 402, 403} }, - {60, 77, 7, 4, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, {396, 397, 398, 399} }, - {61, 78, 7, 5, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, {392, 393, 394, 395} }, - {62, 79, 7, 6, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, {388, 389, 390, 391} }, - {63, 80, 7, 7, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, {384, 385, 386, 387} }, - {64, 5, 8, 0, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, { 64, 65, 66, 67} }, -}; -#endif - - -#endif /* INV_SWPS_H */ - - - - - - - - - diff --git a/packages/platforms/inventec/x86-64/d6254qs/modules/builds/src/inv_vpd.c b/packages/platforms/inventec/x86-64/d6254qs/modules/builds/src/inv_vpd.c deleted file mode 100644 index b6d755e1d..000000000 --- a/packages/platforms/inventec/x86-64/d6254qs/modules/builds/src/inv_vpd.c +++ /dev/null @@ -1,338 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "inv_vpd.h" -#include "onie_tlvinfo.h" - -static int vpd_major; -static struct class *vpd_class_p = NULL; -static char cEeprom[SYS_EEPROM_MAX_SIZE]; -static DEFINE_MUTEX(vpd_mutex); - -static int -__swp_match(struct device *dev, -#ifdef VPD_KERN_VER_AF_3_10 - - const void *data){ -#else - void *data){ -#endif - - char *name = (char *)data; - if (strcmp(dev_name(dev), name) == 0) - return 1; - return 0; -} - -static -int get_vpd_data(struct i2c_client *pi2c_client, int i_offset, char *c_buf) -{ - int iRet; - - read_eeprom( pi2c_client, cEeprom); - iRet = tlvinfo_decode_tlv(cEeprom, i_offset,c_buf); - return iRet; -} - -static -int write_vpd_data(struct i2c_client *pi2c_client, int i_offset, char *c_buf) -{ - int iErr = 0; - - if (read_eeprom(pi2c_client, cEeprom)) { - printk(KERN_ERR "write vpd data eror at %d-%s\n", __LINE__, __FUNCTION__); - return -1; - } - - if (tlvinfo_delete_tlv(cEeprom, i_offset) == TRUE) { - } - if (c_buf) { - if(!tlvinfo_add_tlv(cEeprom, i_offset , c_buf)) { - printk(KERN_ERR "write vpd data eror at %d-%s\n", __LINE__, __FUNCTION__); - iErr = -1; - } else { - iErr = prog_eeprom(pi2c_client,cEeprom); - } - } - return iErr; -} - -static struct device * -get_swpdev_by_name(char *name){ - struct device *dev = class_find_device(vpd_class_p, - NULL, - name, - __swp_match); - return dev; -} - -static ssize_t -store_attr_vpd(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - struct i2c_client *pi2c_client = dev_get_drvdata(dev_p); - struct vpd_device_attribute *attr = to_vpd_dev_attr(attr_p); - int iOffset = attr->index; - int iErr , iLen; - char *pChar; - - if (!pi2c_client){ - return -ENODEV; - } - mutex_lock(&vpd_mutex); - - //-strip 0x0a in the last byte. - for (iLen = 0, pChar = buf_p; - iLen < 255 && *pChar != 0; - iLen++, pChar++) ; - if (iLen !=0 && *pChar == 0 && *(pChar-1) == 0x0a) - *(pChar - 1) = 0; - //- - - iErr = write_vpd_data( pi2c_client, iOffset, buf_p); - - mutex_unlock(&vpd_mutex); - return count; -} - -static ssize_t -show_attr_vpd(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct i2c_client *pi2c_client = dev_get_drvdata(dev_p); - struct vpd_device_attribute *attr = to_vpd_dev_attr(attr_p); - int iOffset = attr->index; - int iErr , iLen; - - if (!pi2c_client){ - return -ENODEV; - } - mutex_lock(&vpd_mutex); - iErr = get_vpd_data( pi2c_client, iOffset, buf_p); - mutex_unlock(&vpd_mutex); - - if( iErr <= 0 ) - iLen = 0; - else - iLen = snprintf(buf_p, TLV_DECODE_VALUE_MAX_LEN, "%s\n", buf_p); - - return iLen; -} - -/* ================= Vpd attribute ======================== - */ -static VPD_DEVICE_ATTR(product_name ,S_IWUSR|S_IRUGO, show_attr_vpd, store_attr_vpd, TLV_CODE_PRODUCT_NAME ); -static VPD_DEVICE_ATTR(pn ,S_IWUSR|S_IRUGO, show_attr_vpd, store_attr_vpd, TLV_CODE_PART_NUMBER ); -static VPD_DEVICE_ATTR(sn ,S_IWUSR|S_IRUGO, show_attr_vpd, store_attr_vpd, TLV_CODE_SERIAL_NUMBER ); -static VPD_DEVICE_ATTR(base_mac_addr,S_IWUSR|S_IRUGO, show_attr_vpd, store_attr_vpd, TLV_CODE_MAC_BASE ); -static VPD_DEVICE_ATTR(man_date ,S_IWUSR|S_IRUGO, show_attr_vpd, store_attr_vpd, TLV_CODE_MANUF_DATE ); -static VPD_DEVICE_ATTR(dev_ver ,S_IWUSR|S_IRUGO, show_attr_vpd, store_attr_vpd, TLV_CODE_DEVICE_VERSION ); -static VPD_DEVICE_ATTR(label_rev ,S_IWUSR|S_IRUGO, show_attr_vpd, store_attr_vpd, TLV_CODE_LABEL_REVISION ); -static VPD_DEVICE_ATTR(plat_name ,S_IWUSR|S_IRUGO, show_attr_vpd, store_attr_vpd, TLV_CODE_PLATFORM_NAME ); -static VPD_DEVICE_ATTR(ldr_ver ,S_IWUSR|S_IRUGO, show_attr_vpd, store_attr_vpd, TLV_CODE_ONIE_VERSION ); -static VPD_DEVICE_ATTR(mac_addr ,S_IWUSR|S_IRUGO, show_attr_vpd, store_attr_vpd, TLV_CODE_MAC_SIZE ); -static VPD_DEVICE_ATTR(manufacturer ,S_IWUSR|S_IRUGO, show_attr_vpd, store_attr_vpd, TLV_CODE_MANUF_NAME ); -static VPD_DEVICE_ATTR(country_code ,S_IWUSR|S_IRUGO, show_attr_vpd, store_attr_vpd, TLV_CODE_MANUF_COUNTRY ); -static VPD_DEVICE_ATTR(vendor_name ,S_IWUSR|S_IRUGO, show_attr_vpd, store_attr_vpd, TLV_CODE_VENDOR_NAME ); -static VPD_DEVICE_ATTR(diag_ver ,S_IWUSR|S_IRUGO, show_attr_vpd, store_attr_vpd, TLV_CODE_DIAG_VERSION ); -static VPD_DEVICE_ATTR(service_tag ,S_IWUSR|S_IRUGO, show_attr_vpd, store_attr_vpd, TLV_CODE_SERVICE_TAG ); -static VPD_DEVICE_ATTR(vendor_ext ,S_IWUSR|S_IRUGO, show_attr_vpd, store_attr_vpd, TLV_CODE_VENDOR_EXT ); -static VPD_DEVICE_ATTR(crc32 ,S_IRUGO, show_attr_vpd, NULL, TLV_CODE_CRC_32 ); - -static void -clean_vpd_common(void) -{ - dev_t dev_num; - struct device *device_p; - - device_p = get_swpdev_by_name(VPD_DEVICE); - if (device_p){ - dev_num = MKDEV(vpd_major, 1); - device_unregister(device_p); - device_destroy(vpd_class_p, dev_num); - } - VPD_DEBUG("%s: done.\n", __func__); -} - - -static struct register_attr VpdRegAttr[VPD_ENTRY_SIZE ] ={ - { &vpd_dev_attr_product_name.dev_attr, "vpd_dev_attr_product_name"}, - { &vpd_dev_attr_pn.dev_attr, "vpd_dev_attr_pn"}, - { &vpd_dev_attr_sn.dev_attr, "vpd_dev_attr_sn"}, - { &vpd_dev_attr_base_mac_addr.dev_attr, "vpd_dev_attr_base_mac_addr"}, - { &vpd_dev_attr_man_date.dev_attr, "vpd_dev_attr_man_date"}, - { &vpd_dev_attr_dev_ver.dev_attr, "vpd_dev_attr_dev_ver"}, - { &vpd_dev_attr_label_rev.dev_attr, "vpd_dev_attr_label_rev"}, - { &vpd_dev_attr_plat_name.dev_attr, "vpd_dev_attr_plat_name"}, - { &vpd_dev_attr_ldr_ver.dev_attr, "vpd_dev_attr_ldr_ver"}, - { &vpd_dev_attr_mac_addr.dev_attr, "vpd_dev_attr_mac_addr"}, - { &vpd_dev_attr_manufacturer.dev_attr, "vpd_dev_attr_manufacturer"}, - { &vpd_dev_attr_country_code.dev_attr, "vpd_dev_attr_country_code"}, - { &vpd_dev_attr_vendor_name.dev_attr, "vpd_dev_attr_vendor_name"}, - { &vpd_dev_attr_diag_ver.dev_attr, "vpd_dev_attr_diag_ver"}, - { &vpd_dev_attr_service_tag.dev_attr, "vpd_dev_attr_service_tag"}, - { &vpd_dev_attr_vendor_ext.dev_attr, "vpd_dev_attr_vendor_ext"}, - { &vpd_dev_attr_crc32.dev_attr, "vpd_dev_attr_crc32"}, -}; - -static int -register_vpd_attr(struct device *device_p){ - - char *err_attr = NULL; - int i; - - for( i = 0 ; i adapter = adap; - vpd_i2c_client->addr = VPD_I2C_ADDR; - - device_p = device_create(vpd_class_p, /* struct class *cls */ - NULL, /* struct device *parent */ - dev_num, /* dev_t devt */ - vpd_i2c_client, /* void *private_data */ - VPD_DEVICE); /* const char *fmt */ - if (IS_ERR(device_p)){ - err_msg = "device_create fail"; - goto err_register_vpd_device_1; - } - if (register_vpd_attr(device_p) < 0) { - err_msg = "register_vpd_attr fail"; - goto err_register_vpd_device_2; - } - return 0; - -err_register_vpd_device_2: - device_unregister(device_p); - device_destroy(vpd_class_p, dev_num); -err_register_vpd_device_1: - kfree(vpd_i2c_client); - vpd_i2c_client = NULL; -err_register_vpd_device: - VPD_ERR("%s: %s\n", __func__, err_msg); - return -1; -} - -static int -register_vpd_module(void) -{ - dev_t vpd_devt = 0; - - if (alloc_chrdev_region(&vpd_devt, 0, 1, VPD_DEVICE) < 0){ - VPD_WARN("Allocate VPD MAJOR failure! \n"); - goto err_register_vpd_module; - } - vpd_major = MAJOR(vpd_devt); - - /* Create class object */ - vpd_class_p = class_create(THIS_MODULE, EEPROM_CLASS); - if (IS_ERR(vpd_class_p)) { - VPD_ERR("Create class failure! \n"); - goto err_register_vpd_module_1; - } - return 0; - -err_register_vpd_module_1: - unregister_chrdev_region(MKDEV(vpd_major, 0), 1); -err_register_vpd_module: - return -1; -} - - -static int -init_vpd_common(void) -{ - char *err_msg = "ERR"; - - if (register_vpd_device() < 0) { - err_msg = "register_vpd_device fail"; - goto err_init_vpd_common; - } - return 0; - -err_init_vpd_common: - VPD_ERR("%s: %s\n", __func__, err_msg); - return -1; -} - - -static int __init -vpd_module_init(void) -{ - if (register_vpd_module() < 0){ - goto err_vpd_module_init; - } - if (init_vpd_common() < 0){ - goto err_vpd_module_init_1; - } - VPD_INFO("Inventec vpd module V.%s initial success.\n", VPD_VERSION); - return 0; - -err_vpd_module_init_1: - class_unregister(vpd_class_p); - class_destroy(vpd_class_p); - unregister_chrdev_region(MKDEV(vpd_major, 0), 1); -err_vpd_module_init: - VPD_ERR("Inventec vpd module V.%s initial failure.\n", VPD_VERSION); - return -1; -} - - -static void __exit -vpd_module_exit(void) -{ - clean_vpd_common(); - class_unregister(vpd_class_p); - class_destroy(vpd_class_p); - unregister_chrdev_region(MKDEV(vpd_major, 0), 1); - VPD_INFO("Remove Inventec vpd module success.\n"); -} - - -/* Module information */ -MODULE_AUTHOR(VPD_AUTHOR); -MODULE_DESCRIPTION(VPD_DESC); -MODULE_VERSION(VPD_VERSION); -MODULE_LICENSE(VPD_LICENSE); - -module_init(vpd_module_init); -module_exit(vpd_module_exit); diff --git a/packages/platforms/inventec/x86-64/d6254qs/modules/builds/src/inv_vpd.h b/packages/platforms/inventec/x86-64/d6254qs/modules/builds/src/inv_vpd.h deleted file mode 100644 index 58c7fe33f..000000000 --- a/packages/platforms/inventec/x86-64/d6254qs/modules/builds/src/inv_vpd.h +++ /dev/null @@ -1,46 +0,0 @@ -#ifndef INV_VPD_H -#define INV_VPD_H - -#define EEPROM_CLASS "eeprom" -#define VPD_DEVICE "vpd" -#define VPD_AUTHOR "Neil " -#define VPD_DESC "Inventec eeprom vpd driver" -#define VPD_VERSION "1.0.0" -#define VPD_LICENSE "GPL" - -#define VPD_ENTRY_SIZE (17) -#define VPD_I2C_BUS (0) -#define VPD_I2C_ADDR (0x53) - -struct register_attr { -struct device_attribute *attr; -char * errmsg; -}; - -struct vpd_device_attribute{ - struct device_attribute dev_attr; - int index; -}; - -#define to_vpd_dev_attr(_dev_attr) \ - container_of(_dev_attr, struct vpd_device_attribute, dev_attr) - -#define VPD_ATTR(_name, _mode, _show, _store, _index) \ - { .dev_attr = __ATTR(_name, _mode, _show, _store), \ - .index = _index } - -#define VPD_DEVICE_ATTR(_name, _mode, _show, _store, _index) \ - struct vpd_device_attribute vpd_dev_attr_##_name \ - = VPD_ATTR(_name, _mode, _show, _store, _index) - -#define VPD_INFO(fmt, args...) printk( KERN_INFO "[VPD] " fmt, ##args) -#define VPD_WARN(fmt, args...) printk( KERN_WARNING "[VPD] " fmt, ##args) -#define VPD_ERR(fmt, args...) printk( KERN_ERR "[VPD] " fmt, ##args) - -#ifdef DEBUG_VPD -# define VPD_DEBUG(fmt, args...) printk( KERN_DEBUG "[VPD] " fmt, ##args) -#else -# define VPD_DEBUG(fmt, args...) -#endif - -#endif /* INV_VPD_H */ diff --git a/packages/platforms/inventec/x86-64/d6254qs/modules/builds/src/io_expander.c b/packages/platforms/inventec/x86-64/d6254qs/modules/builds/src/io_expander.c deleted file mode 100644 index 3e0b191bf..000000000 --- a/packages/platforms/inventec/x86-64/d6254qs/modules/builds/src/io_expander.c +++ /dev/null @@ -1,1878 +0,0 @@ -#include -#include -#include "io_expander.h" - -static struct ioexp_obj_s *ioexp_head_p = NULL; -static struct ioexp_obj_s *ioexp_tail_p = NULL; - - -/* ========== Register IOEXP layout ========== - */ -struct ioexp_map_s ioexp_map_magnolia_nab = { - - .chip_amount = 2, - .data_width = 2, - - .map_present = { {0, 0, 4}, /* map_present[0] = MOD_ABS_PORT(X) */ - {0, 0, 5}, /* map_present[1] = MOD_ABS_PORT(X+1) */ - {0, 0, 6}, /* map_present[2] = MOD_ABS_PORT(X+2) */ - {0, 0, 7}, /* map_present[3] = MOD_ABS_PORT(X+3) */ - {1, 0, 4}, /* map_present[4] = MOD_ABS_PORT(X+4) */ - {1, 0, 5}, /* map_present[5] = MOD_ABS_PORT(X+5) */ - {1, 0, 6}, /* map_present[6] = MOD_ABS_PORT(X+6) */ - {1, 0, 7}, /* map_present[7] = MOD_ABS_PORT(X+7) */ - }, - .map_tx_disable = { {0, 1, 0}, /* map_tx_disable[0] = TXDISABLE_SFP+_P(X) */ - {0, 1, 1}, /* map_tx_disable[1] = TXDISABLE_SFP+_P(X+1) */ - {0, 1, 2}, /* map_tx_disable[2] = TXDISABLE_SFP+_P(X+2) */ - {0, 1, 3}, /* map_tx_disable[3] = TXDISABLE_SFP+_P(X+3) */ - {1, 1, 0}, /* map_tx_disable[4] = TXDISABLE_SFP+_P(X+4) */ - {1, 1, 1}, /* map_tx_disable[5] = TXDISABLE_SFP+_P(X+5) */ - {1, 1, 2}, /* map_tx_disable[6] = TXDISABLE_SFP+_P(X+6) */ - {1, 1, 3}, /* map_tx_disable[7] = TXDISABLE_SFP+_P(X+7) */ - }, - .map_tx_fault = { {0, 0, 0}, /* map_tx_fault[0] = TXFAULT_SFP+_P(X) */ - {0, 0, 1}, /* map_tx_fault[1] = TXFAULT_SFP+_P(X+1) */ - {0, 0, 2}, /* map_tx_fault[2] = TXFAULT_SFP+_P(X+2) */ - {0, 0, 3}, /* map_tx_fault[3] = TXFAULT_SFP+_P(X+3) */ - {1, 0, 0}, /* map_tx_fault[4] = TXFAULT_SFP+_P(X+4) */ - {1, 0, 1}, /* map_tx_fault[5] = TXFAULT_SFP+_P(X+5) */ - {1, 0, 2}, /* map_tx_fault[6] = TXFAULT_SFP+_P(X+6) */ - {1, 0, 3}, /* map_tx_fault[7] = TXFAULT_SFP+_P(X+7) */ - }, - .map_rxlos = { {0, 1, 4}, /* map_rxlos[0] = OPRXLOS_PORT(X) */ - {0, 1, 5}, /* map_rxlos[1] = OPRXLOS_PORT(X+1) */ - {0, 1, 6}, /* map_rxlos[2] = OPRXLOS_PORT(X+2) */ - {0, 1, 7}, /* map_rxlos[3] = OPRXLOS_PORT(X+3) */ - {1, 1, 4}, /* map_rxlos[4] = OPRXLOS_PORT(X+4) */ - {1, 1, 5}, /* map_rxlos[5] = OPRXLOS_PORT(X+5) */ - {1, 1, 6}, /* map_rxlos[6] = OPRXLOS_PORT(X+6) */ - {1, 1, 7}, /* map_rxlos[7] = OPRXLOS_PORT(X+7) */ - }, -}; - - -struct ioexp_map_s ioexp_map_magnolia_4ab = { - - .chip_amount = 2, - .data_width = 2, - - .map_present = { {0, 0, 4}, /* map_present[0] = MOD_ABS_PORT(X) */ - {0, 0, 5}, /* map_present[1] = MOD_ABS_PORT(X+1) */ - {0, 0, 6}, /* map_present[2] = MOD_ABS_PORT(X+2) */ - {0, 0, 7}, /* map_present[3] = MOD_ABS_PORT(X+3) */ - {1, 0, 4}, /* map_present[4] = MOD_ABS_PORT(X+4) */ - {1, 0, 5}, /* map_present[5] = MOD_ABS_PORT(X+5) */ - {1, 0, 6}, /* map_present[6] = MOD_ABS_PORT(X+6) */ - {1, 0, 7}, /* map_present[7] = MOD_ABS_PORT(X+7) */ - }, - .map_tx_disable = { {0, 1, 0}, /* map_tx_disable[0] = TXDISABLE_SFP+_P(X) */ - {0, 1, 1}, /* map_tx_disable[1] = TXDISABLE_SFP+_P(X+1) */ - {0, 1, 2}, /* map_tx_disable[2] = TXDISABLE_SFP+_P(X+2) */ - {0, 1, 3}, /* map_tx_disable[3] = TXDISABLE_SFP+_P(X+3) */ - {1, 0, 0}, /* map_tx_disable[4] = TXDISABLE_SFP+_P(X+4) */ - {1, 0, 1}, /* map_tx_disable[5] = TXDISABLE_SFP+_P(X+5) */ - {1, 0, 2}, /* map_tx_disable[6] = TXDISABLE_SFP+_P(X+6) */ - {1, 0, 3}, /* map_tx_disable[7] = TXDISABLE_SFP+_P(X+7) */ - }, - .map_tx_fault = { {0, 0, 0}, /* map_tx_fault[0] = TXFAULT_SFP+_P(X) */ - {0, 0, 1}, /* map_tx_fault[1] = TXFAULT_SFP+_P(X+1) */ - {0, 0, 2}, /* map_tx_fault[2] = TXFAULT_SFP+_P(X+2) */ - {0, 0, 3}, /* map_tx_fault[3] = TXFAULT_SFP+_P(X+3) */ - {1, 1, 0}, /* map_tx_fault[4] = TXFAULT_SFP+_P(X+4) */ - {1, 1, 1}, /* map_tx_fault[5] = TXFAULT_SFP+_P(X+5) */ - {1, 1, 2}, /* map_tx_fault[6] = TXFAULT_SFP+_P(X+6) */ - {1, 1, 3}, /* map_tx_fault[7] = TXFAULT_SFP+_P(X+7) */ - }, - .map_rxlos = { {0, 1, 4}, /* map_rxlos[0] = OPRXLOS_PORT(X) */ - {0, 1, 5}, /* map_rxlos[1] = OPRXLOS_PORT(X+1) */ - {0, 1, 6}, /* map_rxlos[2] = OPRXLOS_PORT(X+2) */ - {0, 1, 7}, /* map_rxlos[3] = OPRXLOS_PORT(X+3) */ - {1, 1, 4}, /* map_rxlos[4] = OPRXLOS_PORT(X+4) */ - {1, 1, 5}, /* map_rxlos[5] = OPRXLOS_PORT(X+5) */ - {1, 1, 6}, /* map_rxlos[6] = OPRXLOS_PORT(X+6) */ - {1, 1, 7}, /* map_rxlos[7] = OPRXLOS_PORT(X+7) */ - }, -}; - - -struct ioexp_map_s ioexp_map_magnolia_7ab = { - - .chip_amount = 2, - .data_width = 2, - - .map_present = { {1, 0, 4}, /* map_present[0] = MOD_ABS_PORT(X) */ - {1, 0, 5}, /* map_present[1] = MOD_ABS_PORT(X+1) */ - {1, 0, 6}, /* map_present[2] = MOD_ABS_PORT(X+2) */ - {1, 0, 7}, /* map_present[3] = MOD_ABS_PORT(X+3) */ - {1, 1, 4}, /* map_present[4] = MOD_ABS_PORT(X+4) */ - {1, 1, 5}, /* map_present[5] = MOD_ABS_PORT(X+5) */ - }, - .map_reset = { {0, 0, 0}, /* map_reset[0] = QRESET_QSFP_N_P(X) */ - {0, 0, 1}, /* map_reset[1] = QRESET_QSFP_N_P(X+1) */ - {0, 0, 2}, /* map_reset[2] = QRESET_QSFP_N_P(X+2) */ - {0, 0, 3}, /* map_reset[3] = QRESET_QSFP_N_P(X+3) */ - {1, 0, 0}, /* map_reset[4] = QRESET_QSFP_N_P(X+4) */ - {1, 0, 1}, /* map_reset[5] = QRESET_QSFP_N_P(X+5) */ - }, - .map_lpmod = { {0, 0, 4}, /* map_lpmod[0] = LPMODE_QSFP_P(X) */ - {0, 0, 5}, /* map_lpmod[1] = LPMODE_QSFP_P(X+1) */ - {0, 0, 6}, /* map_lpmod[2] = LPMODE_QSFP_P(X+2) */ - {0, 0, 7}, /* map_lpmod[3] = LPMODE_QSFP_P(X+3) */ - {1, 0, 2}, /* map_lpmod[4] = LPMODE_QSFP_P(X+4) */ - {1, 0, 3}, /* map_lpmod[5] = LPMODE_QSFP_P(X+5) */ - }, - .map_modsel = { {0, 1, 4}, /* map_modsel[0] = MODSEL_QSFP_N_P(X) */ - {0, 1, 5}, /* map_modsel[1] = MODSEL_QSFP_N_P(X+1) */ - {0, 1, 6}, /* map_modsel[2] = MODSEL_QSFP_N_P(X+2) */ - {0, 1, 7}, /* map_modsel[3] = MODSEL_QSFP_N_P(X+3) */ - {1, 1, 4}, /* map_modsel[4] = MODSEL_QSFP_N_P(X+4) */ - {1, 1, 5}, /* map_modsel[5] = MODSEL_QSFP_N_P(X+5) */ - }, -}; - - -struct ioexp_map_s ioexp_map_redwood_p01p08_p17p24 = { - - .chip_amount = 3, - .data_width = 2, - - .map_present = { {2, 0, 0}, /* map_present[0] = MOD_ABS_PORT(X) */ - {2, 0, 1}, /* map_present[1] = MOD_ABS_PORT(X+1) */ - {2, 0, 2}, /* map_present[2] = MOD_ABS_PORT(X+2) */ - {2, 0, 3}, /* map_present[3] = MOD_ABS_PORT(X+3) */ - {2, 0, 4}, /* map_present[4] = MOD_ABS_PORT(X+4) */ - {2, 0, 5}, /* map_present[5] = MOD_ABS_PORT(X+5) */ - {2, 0, 6}, /* map_present[6] = MOD_ABS_PORT(X+6) */ - {2, 0, 7}, /* map_present[7] = MOD_ABS_PORT(X+7) */ - }, - .map_reset = { {0, 0, 0}, /* map_reset[0] = QRESET_QSFP28_N_P(X) */ - {0, 0, 1}, /* map_reset[1] = QRESET_QSFP28_N_P(X+1) */ - {0, 0, 2}, /* map_reset[2] = QRESET_QSFP28_N_P(X+2) */ - {0, 0, 3}, /* map_reset[3] = QRESET_QSFP28_N_P(X+3) */ - {1, 0, 0}, /* map_reset[4] = QRESET_QSFP28_N_P(X+4) */ - {1, 0, 1}, /* map_reset[5] = QRESET_QSFP28_N_P(X+5) */ - {1, 0, 2}, /* map_reset[6] = QRESET_QSFP28_N_P(X+6) */ - {1, 0, 3}, /* map_reset[7] = QRESET_QSFP28_N_P(X+7) */ - }, - .map_lpmod = { {0, 0, 4}, /* map_lpmod[0] = LPMODE_QSFP28_P(X) */ - {0, 0, 5}, /* map_lpmod[1] = LPMODE_QSFP28_P(X+1) */ - {0, 0, 6}, /* map_lpmod[2] = LPMODE_QSFP28_P(X+2) */ - {0, 0, 7}, /* map_lpmod[3] = LPMODE_QSFP28_P(X+3) */ - {1, 0, 4}, /* map_lpmod[4] = LPMODE_QSFP28_P(X+4) */ - {1, 0, 5}, /* map_lpmod[5] = LPMODE_QSFP28_P(X+5) */ - {1, 0, 6}, /* map_lpmod[6] = LPMODE_QSFP28_P(X+6) */ - {1, 0, 7}, /* map_lpmod[7] = LPMODE_QSFP28_P(X+7) */ - }, - .map_modsel = { {0, 1, 4}, /* map_modsel[0] = MODSEL_QSFP28_N_P(X) */ - {0, 1, 5}, /* map_modsel[1] = MODSEL_QSFP28_N_P(X+1) */ - {0, 1, 6}, /* map_modsel[2] = MODSEL_QSFP28_N_P(X+2) */ - {0, 1, 7}, /* map_modsel[3] = MODSEL_QSFP28_N_P(X+3) */ - {1, 1, 4}, /* map_modsel[4] = MODSEL_QSFP28_N_P(X+4) */ - {1, 1, 5}, /* map_modsel[5] = MODSEL_QSFP28_N_P(X+5) */ - {1, 1, 6}, /* map_modsel[6] = MODSEL_QSFP28_N_P(X+6) */ - {1, 1, 7}, /* map_modsel[7] = MODSEL_QSFP28_N_P(X+7) */ - }, -}; - - -struct ioexp_map_s ioexp_map_redwood_p09p16_p25p32 = { - - .chip_amount = 3, - .data_width = 2, - - .map_present = { {2, 1, 0}, /* map_present[0] = MOD_ABS_PORT(X) */ - {2, 1, 1}, /* map_present[1] = MOD_ABS_PORT(X+1) */ - {2, 1, 2}, /* map_present[2] = MOD_ABS_PORT(X+2) */ - {2, 1, 3}, /* map_present[3] = MOD_ABS_PORT(X+3) */ - {2, 1, 4}, /* map_present[4] = MOD_ABS_PORT(X+4) */ - {2, 1, 5}, /* map_present[5] = MOD_ABS_PORT(X+5) */ - {2, 1, 6}, /* map_present[6] = MOD_ABS_PORT(X+6) */ - {2, 1, 7}, /* map_present[7] = MOD_ABS_PORT(X+7) */ - }, - .map_reset = { {0, 0, 0}, /* map_reset[0] = QRESET_QSFP28_N_P(X) */ - {0, 0, 1}, /* map_reset[1] = QRESET_QSFP28_N_P(X+1) */ - {0, 0, 2}, /* map_reset[2] = QRESET_QSFP28_N_P(X+2) */ - {0, 0, 3}, /* map_reset[3] = QRESET_QSFP28_N_P(X+3) */ - {1, 0, 0}, /* map_reset[4] = QRESET_QSFP28_N_P(X+4) */ - {1, 0, 1}, /* map_reset[5] = QRESET_QSFP28_N_P(X+5) */ - {1, 0, 2}, /* map_reset[6] = QRESET_QSFP28_N_P(X+6) */ - {1, 0, 3}, /* map_reset[7] = QRESET_QSFP28_N_P(X+7) */ - }, - .map_lpmod = { {0, 0, 4}, /* map_lpmod[0] = LPMODE_QSFP28_P(X) */ - {0, 0, 5}, /* map_lpmod[1] = LPMODE_QSFP28_P(X+1) */ - {0, 0, 6}, /* map_lpmod[2] = LPMODE_QSFP28_P(X+2) */ - {0, 0, 7}, /* map_lpmod[3] = LPMODE_QSFP28_P(X+3) */ - {1, 0, 4}, /* map_lpmod[4] = LPMODE_QSFP28_P(X+4) */ - {1, 0, 5}, /* map_lpmod[5] = LPMODE_QSFP28_P(X+5) */ - {1, 0, 6}, /* map_lpmod[6] = LPMODE_QSFP28_P(X+6) */ - {1, 0, 7}, /* map_lpmod[7] = LPMODE_QSFP28_P(X+7) */ - }, - .map_modsel = { {0, 1, 4}, /* map_modsel[0] = MODSEL_QSFP28_N_P(X) */ - {0, 1, 5}, /* map_modsel[1] = MODSEL_QSFP28_N_P(X+1) */ - {0, 1, 6}, /* map_modsel[2] = MODSEL_QSFP28_N_P(X+2) */ - {0, 1, 7}, /* map_modsel[3] = MODSEL_QSFP28_N_P(X+3) */ - {1, 1, 4}, /* map_modsel[4] = MODSEL_QSFP28_N_P(X+4) */ - {1, 1, 5}, /* map_modsel[5] = MODSEL_QSFP28_N_P(X+5) */ - {1, 1, 6}, /* map_modsel[6] = MODSEL_QSFP28_N_P(X+6) */ - {1, 1, 7}, /* map_modsel[7] = MODSEL_QSFP28_N_P(X+7) */ - }, -}; - - -struct ioexp_map_s ioexp_map_hudson32iga_p01p08_p17p24 = { - - .chip_amount = 3, - .data_width = 2, - - .map_present = { {2, 0, 0}, /* map_present[0] = MODABS_QSFP(X) */ - {2, 0, 1}, /* map_present[1] = MODABS_QSFP(X+1) */ - {2, 0, 2}, /* map_present[2] = MODABS_QSFP(X+2) */ - {2, 0, 3}, /* map_present[3] = MODABS_QSFP(X+3) */ - {2, 0, 4}, /* map_present[4] = MODABS_QSFP(X+4) */ - {2, 0, 5}, /* map_present[5] = MODABS_QSFP(X+5) */ - {2, 0, 6}, /* map_present[6] = MODABS_QSFP(X+6) */ - {2, 0, 7}, /* map_present[7] = MODABS_QSFP(X+7) */ - }, - .map_reset = { {0, 0, 0}, /* map_reset[0] = QRESET_QSFP(X) */ - {0, 0, 1}, /* map_reset[1] = QRESET_QSFP(X+1) */ - {0, 0, 2}, /* map_reset[2] = QRESET_QSFP(X+2) */ - {0, 0, 3}, /* map_reset[3] = QRESET_QSFP(X+3) */ - {1, 0, 0}, /* map_reset[4] = QRESET_QSFP(X+4) */ - {1, 0, 1}, /* map_reset[5] = QRESET_QSFP(X+5) */ - {1, 0, 2}, /* map_reset[6] = QRESET_QSFP(X+6) */ - {1, 0, 3}, /* map_reset[7] = QRESET_QSFP(X+7) */ - }, - .map_lpmod = { {0, 0, 4}, /* map_lpmod[0] = LPMODE_QSFP(X) */ - {0, 0, 5}, /* map_lpmod[1] = LPMODE_QSFP(X+1) */ - {0, 0, 6}, /* map_lpmod[2] = LPMODE_QSFP(X+2) */ - {0, 0, 7}, /* map_lpmod[3] = LPMODE_QSFP(X+3) */ - {1, 0, 4}, /* map_lpmod[4] = LPMODE_QSFP(X+4) */ - {1, 0, 5}, /* map_lpmod[5] = LPMODE_QSFP(X+5) */ - {1, 0, 6}, /* map_lpmod[6] = LPMODE_QSFP(X+6) */ - {1, 0, 7}, /* map_lpmod[7] = LPMODE_QSFP(X+7) */ - }, - .map_modsel = { {0, 1, 4}, /* map_modsel[0] = MODSEL_QSFP(X) */ - {0, 1, 5}, /* map_modsel[1] = MODSEL_QSFP(X+1) */ - {0, 1, 6}, /* map_modsel[2] = MODSEL_QSFP(X+2) */ - {0, 1, 7}, /* map_modsel[3] = MODSEL_QSFP(X+3) */ - {1, 1, 4}, /* map_modsel[4] = MODSEL_QSFP(X+4) */ - {1, 1, 5}, /* map_modsel[5] = MODSEL_QSFP(X+5) */ - {1, 1, 6}, /* map_modsel[6] = MODSEL_QSFP(X+6) */ - {1, 1, 7}, /* map_modsel[7] = MODSEL_QSFP(X+7) */ - }, -}; - - -struct ioexp_map_s ioexp_map_hudson32iga_p09p16_p25p32 = { - - .chip_amount = 3, - .data_width = 2, - - .map_present = { {2, 1, 0}, /* map_present[0] = MODABS_QSFP(X) */ - {2, 1, 1}, /* map_present[1] = MODABS_QSFP(X+1) */ - {2, 1, 2}, /* map_present[2] = MODABS_QSFP(X+2) */ - {2, 1, 3}, /* map_present[3] = MODABS_QSFP(X+3) */ - {2, 1, 4}, /* map_present[4] = MODABS_QSFP(X+4) */ - {2, 1, 5}, /* map_present[5] = MODABS_QSFP(X+5) */ - {2, 1, 6}, /* map_present[6] = MODABS_QSFP(X+6) */ - {2, 1, 7}, /* map_present[7] = MODABS_QSFP(X+7) */ - }, - .map_reset = { {0, 0, 0}, /* map_reset[0] = QRESET_QSFP(X) */ - {0, 0, 1}, /* map_reset[1] = QRESET_QSFP(X+1) */ - {0, 0, 2}, /* map_reset[2] = QRESET_QSFP(X+2) */ - {0, 0, 3}, /* map_reset[3] = QRESET_QSFP(X+3) */ - {1, 0, 0}, /* map_reset[4] = QRESET_QSFP(X+4) */ - {1, 0, 1}, /* map_reset[5] = QRESET_QSFP(X+5) */ - {1, 0, 2}, /* map_reset[6] = QRESET_QSFP(X+6) */ - {1, 0, 3}, /* map_reset[7] = QRESET_QSFP(X+7) */ - }, - .map_lpmod = { {0, 0, 4}, /* map_lpmod[0] = LPMODE_QSFP(X) */ - {0, 0, 5}, /* map_lpmod[1] = LPMODE_QSFP(X+1) */ - {0, 0, 6}, /* map_lpmod[2] = LPMODE_QSFP(X+2) */ - {0, 0, 7}, /* map_lpmod[3] = LPMODE_QSFP(X+3) */ - {1, 0, 4}, /* map_lpmod[4] = LPMODE_QSFP(X+4) */ - {1, 0, 5}, /* map_lpmod[5] = LPMODE_QSFP(X+5) */ - {1, 0, 6}, /* map_lpmod[6] = LPMODE_QSFP(X+6) */ - {1, 0, 7}, /* map_lpmod[7] = LPMODE_QSFP(X+7) */ - }, - .map_modsel = { {0, 1, 4}, /* map_modsel[0] = MODSEL_QSFP(X) */ - {0, 1, 5}, /* map_modsel[1] = MODSEL_QSFP(X+1) */ - {0, 1, 6}, /* map_modsel[2] = MODSEL_QSFP(X+2) */ - {0, 1, 7}, /* map_modsel[3] = MODSEL_QSFP(X+3) */ - {1, 1, 4}, /* map_modsel[4] = MODSEL_QSFP(X+4) */ - {1, 1, 5}, /* map_modsel[5] = MODSEL_QSFP(X+5) */ - {1, 1, 6}, /* map_modsel[6] = MODSEL_QSFP(X+6) */ - {1, 1, 7}, /* map_modsel[7] = MODSEL_QSFP(X+7) */ - }, -}; - - -struct ioexp_map_s ioexp_map_cypress_nabc = { - - .chip_amount = 3, - .data_width = 2, - - .map_present = { {0, 0, 4}, /* map_present[0] = MOD_ABS_PORT(X) */ - {0, 0, 5}, /* map_present[1] = MOD_ABS_PORT(X+1) */ - {0, 0, 6}, /* map_present[2] = MOD_ABS_PORT(X+2) */ - {0, 0, 7}, /* map_present[3] = MOD_ABS_PORT(X+3) */ - {1, 0, 4}, /* map_present[4] = MOD_ABS_PORT(X+4) */ - {1, 0, 5}, /* map_present[5] = MOD_ABS_PORT(X+5) */ - {1, 0, 6}, /* map_present[6] = MOD_ABS_PORT(X+6) */ - {1, 0, 7}, /* map_present[7] = MOD_ABS_PORT(X+7) */ - }, - .map_tx_disable = { {0, 1, 0}, /* map_tx_disable[0] = TXDISABLE_SFP+_P(X) */ - {0, 1, 1}, /* map_tx_disable[1] = TXDISABLE_SFP+_P(X+1) */ - {0, 1, 2}, /* map_tx_disable[2] = TXDISABLE_SFP+_P(X+2) */ - {0, 1, 3}, /* map_tx_disable[3] = TXDISABLE_SFP+_P(X+3) */ - {1, 1, 0}, /* map_tx_disable[4] = TXDISABLE_SFP+_P(X+4) */ - {1, 1, 1}, /* map_tx_disable[5] = TXDISABLE_SFP+_P(X+5) */ - {1, 1, 2}, /* map_tx_disable[6] = TXDISABLE_SFP+_P(X+6) */ - {1, 1, 3}, /* map_tx_disable[7] = TXDISABLE_SFP+_P(X+7) */ - }, - .map_tx_fault = { {0, 0, 0}, /* map_tx_fault[0] = TXFAULT_SFP+_P(X) */ - {0, 0, 1}, /* map_tx_fault[1] = TXFAULT_SFP+_P(X+1) */ - {0, 0, 2}, /* map_tx_fault[2] = TXFAULT_SFP+_P(X+2) */ - {0, 0, 3}, /* map_tx_fault[3] = TXFAULT_SFP+_P(X+3) */ - {1, 0, 0}, /* map_tx_fault[4] = TXFAULT_SFP+_P(X+4) */ - {1, 0, 1}, /* map_tx_fault[5] = TXFAULT_SFP+_P(X+5) */ - {1, 0, 2}, /* map_tx_fault[6] = TXFAULT_SFP+_P(X+6) */ - {1, 0, 3}, /* map_tx_fault[7] = TXFAULT_SFP+_P(X+7) */ - }, - .map_rxlos = { {0, 1, 4}, /* map_rxlos[0] = OPRXLOS_PORT(X) */ - {0, 1, 5}, /* map_rxlos[1] = OPRXLOS_PORT(X+1) */ - {0, 1, 6}, /* map_rxlos[2] = OPRXLOS_PORT(X+2) */ - {0, 1, 7}, /* map_rxlos[3] = OPRXLOS_PORT(X+3) */ - {1, 1, 4}, /* map_rxlos[4] = OPRXLOS_PORT(X+4) */ - {1, 1, 5}, /* map_rxlos[5] = OPRXLOS_PORT(X+5) */ - {1, 1, 6}, /* map_rxlos[6] = OPRXLOS_PORT(X+6) */ - {1, 1, 7}, /* map_rxlos[7] = OPRXLOS_PORT(X+7) */ - }, - .map_hard_rs0 = { {2, 0, 0}, /* map_hard_rs0[0] = RS0_SFP28_P(X) */ - {2, 0, 2}, /* map_hard_rs0[1] = RS0_SFP28_P(X+1) */ - {2, 0, 4}, /* map_hard_rs0[2] = RS0_SFP28_P(X+2) */ - {2, 0, 6}, /* map_hard_rs0[3] = RS0_SFP28_P(X+3) */ - {2, 1, 0}, /* map_hard_rs0[4] = RS0_SFP28_P(X+4) */ - {2, 1, 2}, /* map_hard_rs0[5] = RS0_SFP28_P(X+5) */ - {2, 1, 4}, /* map_hard_rs0[6] = RS0_SFP28_P(X+6) */ - {2, 1, 6}, /* map_hard_rs0[7] = RS0_SFP28_P(X+7) */ - }, - .map_hard_rs1 = { {2, 0, 1}, /* map_hard_rs1[0] = RS1_SFP28_P(X) */ - {2, 0, 3}, /* map_hard_rs1[1] = RS1_SFP28_P(X+1) */ - {2, 0, 5}, /* map_hard_rs1[2] = RS1_SFP28_P(X+2) */ - {2, 0, 7}, /* map_hard_rs1[3] = RS1_SFP28_P(X+3) */ - {2, 1, 1}, /* map_hard_rs1[4] = RS1_SFP28_P(X+4) */ - {2, 1, 3}, /* map_hard_rs1[5] = RS1_SFP28_P(X+5) */ - {2, 1, 5}, /* map_hard_rs1[6] = RS1_SFP28_P(X+6) */ - {2, 1, 7}, /* map_hard_rs1[7] = RS1_SFP28_P(X+7) */ - }, -}; - - -struct ioexp_map_s ioexp_map_cypress_7abc = { - - .chip_amount = 3, - .data_width = 2, - - .map_present = { {2, 0, 0}, /* map_present[0] = MOD_ABS_PORT(X) */ - {2, 0, 1}, /* map_present[1] = MOD_ABS_PORT(X+1) */ - {2, 0, 2}, /* map_present[2] = MOD_ABS_PORT(X+2) */ - {2, 0, 3}, /* map_present[3] = MOD_ABS_PORT(X+3) */ - {2, 0, 4}, /* map_present[4] = MOD_ABS_PORT(X+4) */ - {2, 0, 5}, /* map_present[5] = MOD_ABS_PORT(X+5) */ - }, - .map_reset = { {0, 0, 0}, /* map_reset[0] = QRESET_QSFP_N_P(X) */ - {0, 0, 1}, /* map_reset[1] = QRESET_QSFP_N_P(X+1) */ - {0, 0, 2}, /* map_reset[2] = QRESET_QSFP_N_P(X+2) */ - {0, 0, 3}, /* map_reset[3] = QRESET_QSFP_N_P(X+3) */ - {0, 0, 4}, /* map_reset[4] = QRESET_QSFP_N_P(X+4) */ - {0, 0, 5}, /* map_reset[5] = QRESET_QSFP_N_P(X+5) */ - }, - .map_lpmod = { {0, 1, 0}, /* map_lpmod[0] = LPMODE_QSFP_P(X) */ - {0, 1, 1}, /* map_lpmod[1] = LPMODE_QSFP_P(X+1) */ - {0, 1, 2}, /* map_lpmod[2] = LPMODE_QSFP_P(X+2) */ - {0, 1, 3}, /* map_lpmod[3] = LPMODE_QSFP_P(X+3) */ - {0, 1, 4}, /* map_lpmod[4] = LPMODE_QSFP_P(X+4) */ - {0, 1, 5}, /* map_lpmod[5] = LPMODE_QSFP_P(X+5) */ - }, - .map_modsel = { {1, 1, 0}, /* map_modsel[0] = MODSEL_QSFP_N_P(X) */ - {1, 1, 1}, /* map_modsel[1] = MODSEL_QSFP_N_P(X+1) */ - {1, 1, 2}, /* map_modsel[2] = MODSEL_QSFP_N_P(X+2) */ - {1, 1, 3}, /* map_modsel[3] = MODSEL_QSFP_N_P(X+3) */ - {1, 1, 4}, /* map_modsel[4] = MODSEL_QSFP_N_P(X+4) */ - {1, 1, 5}, /* map_modsel[5] = MODSEL_QSFP_N_P(X+5) */ - }, -}; - - -struct ioexp_map_s ioexp_map_tahoe_5a = { - - .chip_amount = 1, - .data_width = 2, - - .map_present = { {0, 0, 3}, /* map_present[0] = MOD_ABS_PORT(X) */ - {0, 1, 0}, /* map_present[1] = MOD_ABS_PORT(X+1) */ - {0, 1, 5}, /* map_present[2] = MOD_ABS_PORT(X+2) */ - }, - .map_reset = { {0, 0, 1}, /* map_reset[0] = QRESET_QSFP_N_P(X) */ - {0, 0, 6}, /* map_reset[1] = QRESET_QSFP_N_P(X+1) */ - {0, 1, 3}, /* map_reset[2] = QRESET_QSFP_N_P(X+2) */ - }, - .map_lpmod = { {0, 0, 2}, /* map_lpmod[0] = LPMODE_QSFP_P(X) */ - {0, 0, 7}, /* map_lpmod[1] = LPMODE_QSFP_P(X+1) */ - {0, 1, 4}, /* map_lpmod[2] = LPMODE_QSFP_P(X+2) */ - }, - .map_modsel = { {0, 0, 0}, /* map_modsel[0] = MODSEL_QSFP_N_P(X) */ - {0, 0, 5}, /* map_modsel[1] = MODSEL_QSFP_N_P(X+1) */ - {0, 1, 2}, /* map_modsel[2] = MODSEL_QSFP_N_P(X+2) */ - }, -}; - - -struct ioexp_map_s ioexp_map_tahoe_6abc = { - - .chip_amount = 3, - .data_width = 2, - - .map_present = { {0, 0, 3}, /* map_present[0] = MOD_ABS_PORT(X) */ - {0, 1, 0}, /* map_present[1] = MOD_ABS_PORT(X+1) */ - {0, 1, 5}, /* map_present[2] = MOD_ABS_PORT(X+2) */ - {1, 0, 3}, /* map_present[3] = MOD_ABS_PORT(X+3) */ - {1, 1, 0}, /* map_present[4] = MOD_ABS_PORT(X+4) */ - {1, 1, 5}, /* map_present[5] = MOD_ABS_PORT(X+5) */ - {2, 0, 3}, /* map_present[6] = MOD_ABS_PORT(X+6) */ - {2, 1, 0}, /* map_present[7] = MOD_ABS_PORT(X+7) */ - {2, 1, 5}, /* map_present[8] = MOD_ABS_PORT(X+8) */ - }, - .map_reset = { {0, 0, 1}, /* map_reset[0] = QRESET_QSFP28_N_P(X) */ - {0, 0, 6}, /* map_reset[1] = QRESET_QSFP28_N_P(X+1) */ - {0, 1, 3}, /* map_reset[2] = QRESET_QSFP28_N_P(X+2) */ - {1, 0, 1}, /* map_reset[3] = QRESET_QSFP28_N_P(X+3) */ - {1, 0, 6}, /* map_reset[4] = QRESET_QSFP28_N_P(X+4) */ - {1, 1, 3}, /* map_reset[5] = QRESET_QSFP28_N_P(X+5) */ - {2, 0, 1}, /* map_reset[6] = QRESET_QSFP28_N_P(X+6) */ - {2, 0, 6}, /* map_reset[7] = QRESET_QSFP28_N_P(X+7) */ - {2, 1, 3}, /* map_reset[7] = QRESET_QSFP28_N_P(X+7) */ - }, - .map_lpmod = { {0, 0, 2}, /* map_lpmod[0] = LPMODE_QSFP28_P(X) */ - {0, 0, 7}, /* map_lpmod[1] = LPMODE_QSFP28_P(X+1) */ - {0, 1, 4}, /* map_lpmod[2] = LPMODE_QSFP28_P(X+2) */ - {1, 0, 2}, /* map_lpmod[3] = LPMODE_QSFP28_P(X+3) */ - {1, 0, 7}, /* map_lpmod[4] = LPMODE_QSFP28_P(X+4) */ - {1, 1, 4}, /* map_lpmod[5] = LPMODE_QSFP28_P(X+5) */ - {2, 0, 2}, /* map_lpmod[6] = LPMODE_QSFP28_P(X+6) */ - {2, 0, 7}, /* map_lpmod[7] = LPMODE_QSFP28_P(X+7) */ - {2, 1, 4}, /* map_lpmod[7] = LPMODE_QSFP28_P(X+8) */ - }, - .map_modsel = { {0, 0, 0}, /* map_modsel[0] = MODSEL_QSFP28_N_P(X) */ - {0, 0, 5}, /* map_modsel[1] = MODSEL_QSFP28_N_P(X+1) */ - {0, 1, 2}, /* map_modsel[2] = MODSEL_QSFP28_N_P(X+2) */ - {1, 0, 0}, /* map_modsel[3] = MODSEL_QSFP28_N_P(X+3) */ - {1, 0, 5}, /* map_modsel[4] = MODSEL_QSFP28_N_P(X+4) */ - {1, 1, 2}, /* map_modsel[5] = MODSEL_QSFP28_N_P(X+5) */ - {2, 0, 0}, /* map_modsel[6] = MODSEL_QSFP28_N_P(X+6) */ - {2, 0, 5}, /* map_modsel[7] = MODSEL_QSFP28_N_P(X+7) */ - {2, 1, 2}, /* map_modsel[7] = MODSEL_QSFP28_N_P(X+7) */ - }, -}; - - -struct ioexp_map_s ioexp_map_sequoia_nabc = { - - .chip_amount = 3, - .data_width = 2, - - .map_present = { {2, 1, 0}, /* map_present[0] = MOD_ABS_PORT(X) */ - {2, 1, 1}, /* map_present[1] = MOD_ABS_PORT(X+1) */ - {2, 1, 2}, /* map_present[2] = MOD_ABS_PORT(X+2) */ - {2, 1, 3}, /* map_present[3] = MOD_ABS_PORT(X+3) */ - {2, 1, 4}, /* map_present[4] = MOD_ABS_PORT(X+4) */ - {2, 1, 5}, /* map_present[5] = MOD_ABS_PORT(X+5) */ - {2, 1, 6}, /* map_present[6] = MOD_ABS_PORT(X+6) */ - {2, 1, 7}, /* map_present[7] = MOD_ABS_PORT(X+7) */ - }, - .map_reset = { {0, 1, 0}, /* map_reset[0] = QRESET_QSFP28_N_P(X) */ - {0, 1, 1}, /* map_reset[1] = QRESET_QSFP28_N_P(X+1) */ - {0, 1, 2}, /* map_reset[2] = QRESET_QSFP28_N_P(X+2) */ - {0, 1, 3}, /* map_reset[3] = QRESET_QSFP28_N_P(X+3) */ - {0, 1, 4}, /* map_reset[4] = QRESET_QSFP28_N_P(X+4) */ - {0, 1, 5}, /* map_reset[5] = QRESET_QSFP28_N_P(X+5) */ - {0, 1, 6}, /* map_reset[6] = QRESET_QSFP28_N_P(X+6) */ - {0, 1, 7}, /* map_reset[7] = QRESET_QSFP28_N_P(X+7) */ - }, - .map_lpmod = { {1, 0, 0}, /* map_lpmod[0] = LPMODE_QSFP28_P(X) */ - {1, 0, 1}, /* map_lpmod[1] = LPMODE_QSFP28_P(X+1) */ - {1, 0, 2}, /* map_lpmod[2] = LPMODE_QSFP28_P(X+2) */ - {1, 0, 3}, /* map_lpmod[3] = LPMODE_QSFP28_P(X+3) */ - {1, 0, 4}, /* map_lpmod[4] = LPMODE_QSFP28_P(X+4) */ - {1, 0, 5}, /* map_lpmod[5] = LPMODE_QSFP28_P(X+5) */ - {1, 0, 6}, /* map_lpmod[6] = LPMODE_QSFP28_P(X+6) */ - {1, 0, 7}, /* map_lpmod[7] = LPMODE_QSFP28_P(X+7) */ - }, - .map_modsel = { {0, 0, 0}, /* map_modsel[0] = MODSEL_QSFP28_N_P(X) */ - {0, 0, 1}, /* map_modsel[1] = MODSEL_QSFP28_N_P(X+1) */ - {0, 0, 2}, /* map_modsel[2] = MODSEL_QSFP28_N_P(X+2) */ - {0, 0, 3}, /* map_modsel[3] = MODSEL_QSFP28_N_P(X+3) */ - {0, 0, 4}, /* map_modsel[4] = MODSEL_QSFP28_N_P(X+4) */ - {0, 0, 5}, /* map_modsel[5] = MODSEL_QSFP28_N_P(X+5) */ - {0, 0, 6}, /* map_modsel[6] = MODSEL_QSFP28_N_P(X+6) */ - {0, 0, 7}, /* map_modsel[7] = MODSEL_QSFP28_N_P(X+7) */ - }, -}; - - -struct ioexp_map_s ioexp_map_lavender_p65 = { - - .chip_amount = 1, - .data_width = 1, - - .map_present = { {0, 0, 4}, }, /* map_present[0] = MOD_ABS_PORT(X) */ - .map_reset = { {0, 0, 1}, }, /* map_reset[0] = QRESET_QSFP28_N_P(X) */ - .map_lpmod = { {0, 0, 2}, }, /* map_lpmod[0] = LPMODE_QSFP28_P(X) */ - .map_modsel = { {0, 0, 0}, }, /* map_modsel[0] = MODSEL_QSFP28_N_P(X) */ -}; - - -/* ========== Private functions ========== - */ -int check_channel_tier_1(void); - -struct i2c_client * -_get_i2c_client(struct ioexp_obj_s *self, - int chip_id){ - - struct ioexp_i2c_s *i2c_curr_p = self->i2c_head_p; - - if (!(i2c_curr_p)){ - SWPS_ERR("%s: i2c_curr_p is NULL\n", __func__); - return NULL; - } - while (i2c_curr_p){ - if ((i2c_curr_p->chip_id) == chip_id){ - return i2c_curr_p->i2c_client_p; - } - i2c_curr_p = i2c_curr_p->next; - } - SWPS_ERR("%s: not exist! :%d\n", __func__, chip_id); - return NULL; -} - - -static int -_common_ioexp_update_one(struct ioexp_obj_s *self, - struct ioexp_addr_s *ioexp_addr, - int chip_id, - int data_width, - int show_err, - char *caller_name) { - int buf = 0; - int err = 0; - int data_id = 0; - int r_offset = 0; - - for(data_id=0; data_idread_offset[data_id]; - buf = i2c_smbus_read_byte_data(_get_i2c_client(self, chip_id), r_offset); - /* Check error */ - if (buf < 0) { - err = 1; - if (show_err) { - SWPS_INFO("IOEXP-%d read fail! :%d \n", self->ioexp_id, buf); - SWPS_INFO("Dump: :%d :0x%02x :%d, :%s\n", - ioexp_addr->chan_id, ioexp_addr->chip_addr, - ioexp_addr->read_offset[data_id], caller_name); - } - continue; - } - /* Update IOEXP object */ - self->chip_data[chip_id].data[data_id] = (uint8_t)buf; - } - if (err) { - return ERR_IOEXP_UNEXCPT; - } - return 0; -} - - -static int -common_ioexp_update_all(struct ioexp_obj_s *self, - int show_err, - char *caller_name){ - - int err = 0; - int chip_id = 0; - int chip_amount = self->ioexp_map_p->chip_amount; - - for (chip_id=0; chip_idioexp_map_p->map_addr[chip_id]), - chip_id, - self->ioexp_map_p->data_width, - show_err, - caller_name) < 0) { - err = 1; - } - } - if (err) { - return ERR_IOEXP_UNEXCPT; - } - return 0; -} - - -static int -_common_check_by_mode(struct ioexp_obj_s *self){ - - switch (self->mode){ - case IOEXP_MODE_DIRECT: - return self->fsm_4_direct(self); - - case IOEXP_MODE_POLLING: - if (self->state >= 0){ - return 0; - } - switch (self->state){ - case STATE_IOEXP_INIT: - return ERR_IOEXP_UNINIT; - case STATE_IOEXP_ABNORMAL: - return ERR_IOEXP_ABNORMAL; - default: - return ERR_IOEXP_NOSTATE; - } - break; - - default: - break; - } - SWPS_ERR("%s: Exception occurs. :%d \n", __func__, self->mode); - return ERR_IOEXP_UNEXCPT; -} - - -static int -_common_get_bit(struct ioexp_obj_s *self, - struct ioexp_bitmap_s *bitmap_obj_p, - char *func_mane){ - uint8_t buf; - int err_code; - - /* Check and get address */ - err_code = _common_check_by_mode(self); - if (err_code < 0){ - return err_code; - } - if (!bitmap_obj_p){ - SWPS_ERR("Layout config incorrect! :%d :%s\n", - self->ioexp_id, func_mane); - return ERR_IOEXP_BADCONF; - } - /* Get data form cache */ - buf = self->chip_data[bitmap_obj_p->chip_id].data[bitmap_obj_p->ioexp_voffset]; - return (int)(buf >> bitmap_obj_p->bit_shift & 0x01); -} - - -static int -_common_set_bit(struct ioexp_obj_s *self, - struct ioexp_bitmap_s *bitmap_obj_p, - int input_val, - char *func_mane){ - int err_code, target_offset; - uint8_t origin_byte; - uint8_t modify_byte; - - /* Check and get address */ - err_code = _common_check_by_mode(self); - if (err_code < 0){ - return err_code; - } - if (!bitmap_obj_p){ - SWPS_ERR("Layout config incorrect! :%d :%s\n", - self->ioexp_id, func_mane); - return ERR_IOEXP_BADCONF; - } - /* Prepare write date */ - origin_byte = self->chip_data[bitmap_obj_p->chip_id].data[bitmap_obj_p->ioexp_voffset]; - switch (input_val) { - case 0: - modify_byte = origin_byte; - SWP_BIT_CLEAR(modify_byte, bitmap_obj_p->bit_shift); - break; - case 1: - modify_byte = origin_byte; - SWP_BIT_SET(modify_byte, bitmap_obj_p->bit_shift); - break; - default: - SWPS_ERR("Input value incorrect! :%d :%d :%s\n", - input_val, self->ioexp_id, func_mane); - return ERR_IOEXP_BADINPUT; - } - /* Setup i2c client */ - target_offset = self->ioexp_map_p->map_addr[bitmap_obj_p->chip_id].write_offset[bitmap_obj_p->ioexp_voffset]; - /* Write byte to chip via I2C */ - err_code = i2c_smbus_write_byte_data(_get_i2c_client(self, bitmap_obj_p->chip_id), - target_offset, - modify_byte); - /* Update or bollback object */ - if (err_code < 0){ - self->chip_data[bitmap_obj_p->chip_id].data[bitmap_obj_p->ioexp_voffset] = origin_byte; - SWPS_ERR("I2C write fail! :%d :%d :%s :%d\n", - input_val, self->ioexp_id, func_mane, err_code); - return err_code; - } - self->chip_data[bitmap_obj_p->chip_id].data[bitmap_obj_p->ioexp_voffset] = modify_byte; - return 0; -} - - -/* ========== Object public functions ========== - */ -int -common_get_present(struct ioexp_obj_s *self, - int virt_offset){ - - int UNPLUG = 1; - int retval = ERR_IOEXP_UNEXCPT; - - retval = _common_get_bit(self, - &(self->ioexp_map_p->map_present[virt_offset]), - "common_get_present"); - if (retval < 0) { - /* [Note] - * => Transceiver object does not need to handle IOEXP layer issues. - */ - return UNPLUG; - } - return retval; -} - - -int -common_get_tx_fault(struct ioexp_obj_s *self, - int virt_offset){ - /* [Transmit Fault (Tx_Fault)] - * A catastrophic laser fault will activate the transmitter signal, - * TX_FAULT, and disable the laser. This signal is an open collector - * output (pull-up required on the host board). A low signal indicates - * normal laser operation and a high signal indicates a fault. The - * TX_FAULT will be latched high when a laser fault occurs and is - * cleared by toggling the TX_DISABLE input or power cycling the - * transceiver. The transmitter fault condition can also be monitored - * via the two-wire serial interface. - * (address A2, byte 110, bit 2). - * - * 0: Normal - * 1: Abnormal - */ - return _common_get_bit(self, - &(self->ioexp_map_p->map_tx_fault[virt_offset]), - "common_get_tx_fault"); -} - - -int -common_get_rxlos(struct ioexp_obj_s *self, - int virt_offset){ - /* [Receiver Loss of Signal (Rx_LOS)] - * The post-amplification IC also includes transition detection circuitry - * which monitors the ac level of incoming optical signals and provides a - * TTL/CMOS compatible status signal to the host (pin 8). An adequate optical - * input results in a low Rx_LOS output while a high Rx_LOS output indicates - * an unusable optical input. The Rx_LOS thresholds are factory set so that - * a high output indicates a definite optical fault has occurred. Rx_LOS can - * also be monitored via the two-wire serial interface - * (address A2h, byte 110, bit 1). - * - * 0: Normal - * 1: Abnormal - */ - return _common_get_bit(self, - &(self->ioexp_map_p->map_rxlos[virt_offset]), - "common_get_rxlos"); -} - - -int -common_get_tx_disable(struct ioexp_obj_s *self, - int virt_offset){ - - return _common_get_bit(self, - &(self->ioexp_map_p->map_tx_disable[virt_offset]), - "common_get_tx_disable"); -} - - -int -common_get_reset(struct ioexp_obj_s *self, - int virt_offset){ - - return _common_get_bit(self, - &(self->ioexp_map_p->map_reset[virt_offset]), - "common_get_reset"); -} - - -int -common_get_lpmod(struct ioexp_obj_s *self, - int virt_offset){ - - return _common_get_bit(self, - &(self->ioexp_map_p->map_lpmod[virt_offset]), - "common_get_lpmod"); -} - - -int -common_get_modsel(struct ioexp_obj_s *self, - int virt_offset){ - - return _common_get_bit(self, - &(self->ioexp_map_p->map_modsel[virt_offset]), - "common_get_modsel"); -} - - -int -common_get_hard_rs0(struct ioexp_obj_s *self, - int virt_offset){ - - return _common_get_bit(self, - &(self->ioexp_map_p->map_hard_rs0[virt_offset]), - "common_get_hard_rs0"); -} - - -int -common_get_hard_rs1(struct ioexp_obj_s *self, - int virt_offset){ - - return _common_get_bit(self, - &(self->ioexp_map_p->map_hard_rs1[virt_offset]), - "common_get_hard_rs1"); -} - - -int -common_set_tx_disable(struct ioexp_obj_s *self, - int virt_offset, - int input_val){ - - return _common_set_bit(self, - &(self->ioexp_map_p->map_tx_disable[virt_offset]), - input_val, - "common_set_tx_disable"); -} - - -int -common_set_reset(struct ioexp_obj_s *self, - int virt_offset, - int input_val){ - - return _common_set_bit(self, - &(self->ioexp_map_p->map_reset[virt_offset]), - input_val, - "common_set_reset"); -} - - -int -common_set_lpmod(struct ioexp_obj_s *self, - int virt_offset, - int input_val){ - - return _common_set_bit(self, - &(self->ioexp_map_p->map_lpmod[virt_offset]), - input_val, - "common_set_lpmod"); -} - - -int -common_set_modsel(struct ioexp_obj_s *self, - int virt_offset, - int input_val){ - - return _common_set_bit(self, - &(self->ioexp_map_p->map_modsel[virt_offset]), - input_val, - "common_set_modsel"); -} - - -int -common_set_hard_rs0(struct ioexp_obj_s *self, - int virt_offset, - int input_val){ - - return _common_set_bit(self, - &(self->ioexp_map_p->map_hard_rs0[virt_offset]), - input_val, - "common_set_hard_rs0"); -} - - -int -common_set_hard_rs1(struct ioexp_obj_s *self, - int virt_offset, - int input_val){ - - return _common_set_bit(self, - &(self->ioexp_map_p->map_hard_rs1[virt_offset]), - input_val, - "common_set_hard_rs1"); -} - - -int -ioexp_get_not_support(struct ioexp_obj_s *self, - int virt_offset){ - return ERR_IOEXP_NOTSUPPORT; -} - - -int -ioexp_set_not_support(struct ioexp_obj_s *self, - int virt_offset, - int input_val){ - return ERR_IOEXP_NOTSUPPORT; -} - - -int -fake_ioexp_init(struct ioexp_obj_s *self){ - return 1; -} - -int -fake_ioexp_update(struct ioexp_obj_s *self){ - return 1; -} - - -int -fake_update_func(struct ioexp_obj_s *self){ - return 1; -} - -int -fake_get_func(struct ioexp_obj_s *self, - int virt_offset){ - SWPS_WARN("Someone called fake_get_func\n"); - return -1; -} - -int -fake_set_func(struct ioexp_obj_s *self, - int virt_offset, - int input_val){ - SWPS_WARN("Someone called fake_set_func\n"); - return -1; -} - - -/* ========== Initial functions for IO Expander ========== - */ -int -common_ioexp_init(struct ioexp_obj_s *self) { - - int chip_id, offset, err_code; - struct ioexp_addr_s *addr_p; - - if (self->mode == IOEXP_MODE_DIRECT) { - goto update_common_ioexp_init; - } - /* Setup default value to each physical IO Expander */ - for (chip_id=0; chip_id<(self->ioexp_map_p->chip_amount); chip_id++){ - /* Get address mapping */ - addr_p = &(self->ioexp_map_p->map_addr[chip_id]); - if (!addr_p){ - SWPS_ERR("%s: IOEXP config incorrect! :%d \n", - __func__, chip_id); - return -1; - } - /* Setup default value */ - for (offset=0; offset<(self->ioexp_map_p->data_width); offset++){ - err_code = i2c_smbus_write_byte_data(_get_i2c_client(self, chip_id), - addr_p->write_offset[offset], - addr_p->data_default[offset]); - if (err_code < 0){ - SWPS_ERR("%s: set default fail! :%d \n", - __func__, err_code); - return ERR_IOEXP_UNEXCPT; - } - } - } -update_common_ioexp_init: - /* Check and update info to object */ - err_code = self->update_all(self, 1, "common_ioexp_init"); - if (err_code < 0) { - SWPS_ERR("%s: update_all() fail! :%d \n", - __func__, err_code); - return ERR_IOEXP_UNEXCPT; - } - return 0; -} - - -/* ========== Object functions for Final State Machine ========== - */ -int -_is_channel_ready(struct ioexp_obj_s *self){ - - int buf = 0; - int chip_id = 0; /* Use first chip which be registered */ - int data_id = 0; /* Use first byte which be registered */ - struct ioexp_addr_s *ioexp_addr = NULL; - - ioexp_addr = &(self->ioexp_map_p->map_addr[chip_id]); - if (!ioexp_addr){ - SWPS_ERR("%s: config incorrect!\n", __func__); - return ERR_IOEXP_UNEXCPT; - } - buf = i2c_smbus_read_byte_data(_get_i2c_client(self, chip_id), - ioexp_addr->read_offset[data_id]); - if (buf >= 0){ - return 1; - } - return 0; -} - -int -_ioexp_init_handler(struct ioexp_obj_s *self){ - - int return_val; - - switch (self->mode) { - case IOEXP_MODE_DIRECT: - return_val = self->init(self); - if (return_val < 0){ - self->state = STATE_IOEXP_ABNORMAL; - } else { - self->state = STATE_IOEXP_NORMAL; - } - return return_val; - - case IOEXP_MODE_POLLING: - /* Check system and channel is ready */ - if (self->state == STATE_IOEXP_INIT){ - if (!_is_channel_ready(self)){ - self->state = STATE_IOEXP_INIT; - SWPS_WARN("%s: IOEXP:%d channel not ready.\n", - __func__, self->ioexp_id); - return 0; - } - } - /* Execute initial callback */ - return_val = self->init(self); - if (return_val < 0){ - self->state = STATE_IOEXP_ABNORMAL; - } else { - self->state = STATE_IOEXP_NORMAL; - } - return return_val; - - default: - break; - } - SWPS_ERR("%s: exception occur :%d\n", __func__, self->mode); - return ERR_IOEXP_UNEXCPT; -} - - -int -common_ioexp_fsm_4_direct(struct ioexp_obj_s *self){ - - int result_val; - int show_err = 1; - char *func_mane = "common_ioexp_fsm_4_direct"; - - switch (self->state){ - case STATE_IOEXP_INIT: - result_val = _ioexp_init_handler(self); - /* Exception case: terminate initial procedure */ - if(result_val < 0){ - /* Initial fail */ - return result_val; - } - if(self->state == STATE_IOEXP_INIT){ - /* Keep in INIT state, and return error */ - return ERR_IOEXP_UNINIT; - } - /* Case: Initial done */ - return 0; - - case STATE_IOEXP_NORMAL: - result_val = self->update_all(self, show_err, func_mane); - if (result_val < 0){ - SWPS_INFO("%s: NORMAL -> ABNORMAL :%d\n", - __func__, result_val); - self->state = STATE_IOEXP_ABNORMAL; - return result_val; - } - self->state = STATE_IOEXP_NORMAL; - return 0; - - case STATE_IOEXP_ABNORMAL: - result_val = self->update_all(self, show_err, func_mane); - if (result_val < 0){ - self->state = STATE_IOEXP_ABNORMAL; - return result_val; - } - SWPS_DEBUG("%s: ABNORMAL -> NORMAL :%d\n", - __func__, result_val); - self->state = STATE_IOEXP_NORMAL; - return 0; - - default: - break; - } - SWPS_ERR("%s: Exception occurs :%d\n", - __func__, self->state); - return ERR_IOEXP_UNEXCPT; -} - - -int -common_ioexp_fsm_4_polling(struct ioexp_obj_s *self){ - - int result_val, i, show_e; - int fail_retry = 3; - char *func_name = "common_ioexp_fsm_4_polling"; - -#ifdef DEBUG_SWPS - show_e = 1; -#else - show_e = 0; -#endif - - switch (self->state){ - case STATE_IOEXP_INIT: - result_val = _ioexp_init_handler(self); - /* Exception case: terminate initial procedure */ - if(result_val < 0){ - /* Initial fail */ - return result_val; - } - /* Case: System (Channel) not ready */ - if(self->state == STATE_IOEXP_INIT){ - /* Keep in INIT state, wait and retry */ - return 0; - } - /* Case: Initial done */ - SWPS_INFO("IOEXP-%d: initial done. :%d\n", - self->ioexp_id, self->ioexp_type); - return result_val; - - case STATE_IOEXP_NORMAL: - /* Retry mechanism for case of i2c topology not stable */ - for (i=0; iupdate_all(self, show_e, func_name); - if (result_val >= 0) { - self->state = STATE_IOEXP_NORMAL; - return 0; - } - if (check_channel_tier_1() < 0) { - SWPS_INFO("%s: detect I2C crash :%d\n", - __func__, self->ioexp_id); - break; - } - SWPS_DEBUG("IOEXP-%d: unstable :%d\n", - self->ioexp_id, result_val); - } - SWPS_INFO("IOEXP-%d: NORMAL -> ABNORMAL :%d\n", - self->ioexp_id, result_val); - self->state = STATE_IOEXP_ABNORMAL; - return result_val; - - case STATE_IOEXP_ABNORMAL: - result_val = self->update_all(self, show_e, func_name); - if (result_val < 0){ - self->state = STATE_IOEXP_ABNORMAL; - return result_val; - } - SWPS_INFO("IOEXP-%d: ABNORMAL -> NORMAL :%d\n", - self->ioexp_id, result_val); - self->state = STATE_IOEXP_NORMAL; - return 0; - - default: - break; - } - SWPS_ERR("IOEXP-%d: Exception occurs :%d\n", - self->ioexp_id, self->state); - return ERR_IOEXP_UNEXCPT; -} - - -/* ========== Object private functions for check & update ========== - */ -int -common_ioexp_check(struct ioexp_obj_s *self){ - - int result; - - if (self->mode != IOEXP_MODE_POLLING){ - SWPS_ERR("%s: not polling mode :%d\n", - __func__, self->mode); - return ERR_IOEXP_NOTSUPPORT; - } - mutex_lock(&self->lock); - result = self->fsm_4_polling(self); - mutex_unlock(&self->lock); - return result; -} - - -/* ========== Functions for Factory pattern ========== - */ -static struct ioexp_map_s * -get_ioexp_map(int ioexp_type){ - switch (ioexp_type){ - case IOEXP_TYPE_MAGINOLIA_NAB: - return &ioexp_map_magnolia_nab; - case IOEXP_TYPE_MAGINOLIA_4AB: - return &ioexp_map_magnolia_4ab; - case IOEXP_TYPE_MAGINOLIA_7AB: - case IOEXP_TYPE_SPRUCE_7AB: - return &ioexp_map_magnolia_7ab; - case IOEXP_TYPE_REDWOOD_P01P08: - return &ioexp_map_redwood_p01p08_p17p24; - case IOEXP_TYPE_REDWOOD_P09P16: - return &ioexp_map_redwood_p09p16_p25p32; - case IOEXP_TYPE_HUDSON32IGA_P01P08: - return &ioexp_map_hudson32iga_p01p08_p17p24; - case IOEXP_TYPE_HUDSON32IGA_P09P16: - return &ioexp_map_hudson32iga_p09p16_p25p32; - case IOEXP_TYPE_CYPRESS_NABC: - return &ioexp_map_cypress_nabc; - case IOEXP_TYPE_CYPRESS_7ABC: - return &ioexp_map_cypress_7abc; - case IOEXP_TYPE_TAHOE_5A: - return &ioexp_map_tahoe_5a; - case IOEXP_TYPE_TAHOE_6ABC: - return &ioexp_map_tahoe_6abc; - case IOEXP_TYPE_SEQUOIA_NABC: - return &ioexp_map_sequoia_nabc; - case IOEXP_TYPE_LAVENDER_P65: - return &ioexp_map_lavender_p65; - default: - return NULL; - } -} - - -int -setup_ioexp_ssize_attr(struct ioexp_obj_s *self, - struct ioexp_map_s *ioexp_map_p, - int ioexp_id, - int ioexp_type, - int run_mode){ - switch (run_mode){ - case IOEXP_MODE_POLLING: /* Direct access device mode */ - case IOEXP_MODE_DIRECT: /* Polling mode, read from cache */ - self->mode = run_mode; - break; - default: - SWPS_ERR("%s: non-defined run_mode:%d\n", - __func__, run_mode); - self->mode = ERR_IOEXP_UNEXCPT; - return ERR_IOEXP_UNEXCPT; - } - /* Setup mapping structure */ - self->ioexp_map_p = kzalloc(sizeof(*ioexp_map_p), GFP_KERNEL); - if (!(self->ioexp_map_p)) { - SWPS_ERR("%s: kzalloc ioexp_map_p fail\n", __func__); - return -1; - } - memcpy(self->ioexp_map_p, ioexp_map_p, sizeof(*ioexp_map_p)); - /* Setup attributes */ - self->ioexp_id = ioexp_id; - self->ioexp_type = ioexp_type; - self->state = STATE_IOEXP_INIT; - mutex_init(&self->lock); - return 0; -} - - -static int -setup_addr_mapping(struct ioexp_obj_s *self, - struct ioexp_addr_s *addr_map_p, - int chip_amount){ - struct ioexp_addr_s *tmp_p; - if (!addr_map_p){ - SWPS_ERR("%s: map is null\n", __func__); - return -1; - } - tmp_p = kzalloc((sizeof(*addr_map_p) * chip_amount), GFP_KERNEL); - if (!tmp_p){ - SWPS_ERR("%s: kzalloc fail.\n", __func__); - return -1; - } - memcpy(tmp_p, addr_map_p, (sizeof(*addr_map_p) * chip_amount)); - self->ioexp_map_p->map_addr = tmp_p; - - return 0; -} - - -static int -setup_ioexp_public_cb(struct ioexp_obj_s *self, - int ioexp_type){ - - switch (ioexp_type){ - case IOEXP_TYPE_MAGINOLIA_NAB: - case IOEXP_TYPE_MAGINOLIA_4AB: - self->get_present = common_get_present; - self->get_tx_fault = common_get_tx_fault; - self->get_rxlos = common_get_rxlos; - self->get_tx_disable = common_get_tx_disable; - self->get_reset = ioexp_get_not_support; - self->get_lpmod = ioexp_get_not_support; - self->get_modsel = ioexp_get_not_support; - self->get_hard_rs0 = ioexp_get_not_support; - self->get_hard_rs1 = ioexp_get_not_support; - self->set_tx_disable = common_set_tx_disable; - self->set_reset = ioexp_set_not_support; - self->set_lpmod = ioexp_set_not_support; - self->set_modsel = ioexp_set_not_support; - self->set_hard_rs0 = ioexp_set_not_support; - self->set_hard_rs1 = ioexp_set_not_support; - return 0; - case IOEXP_TYPE_CYPRESS_NABC: - self->get_present = common_get_present; - self->get_tx_fault = common_get_tx_fault; - self->get_rxlos = common_get_rxlos; - self->get_tx_disable = common_get_tx_disable; - self->get_reset = ioexp_get_not_support; - self->get_lpmod = ioexp_get_not_support; - self->get_modsel = ioexp_get_not_support; - self->get_hard_rs0 = common_get_hard_rs0; - self->get_hard_rs1 = common_get_hard_rs1; - self->set_tx_disable = common_set_tx_disable; - self->set_reset = ioexp_set_not_support; - self->set_lpmod = ioexp_set_not_support; - self->set_modsel = ioexp_set_not_support; - self->set_hard_rs0 = common_set_hard_rs0; - self->set_hard_rs1 = common_set_hard_rs1; - return 0; - case IOEXP_TYPE_MAGINOLIA_7AB: - case IOEXP_TYPE_SPRUCE_7AB: - case IOEXP_TYPE_REDWOOD_P01P08: - case IOEXP_TYPE_REDWOOD_P09P16: - case IOEXP_TYPE_HUDSON32IGA_P01P08: - case IOEXP_TYPE_HUDSON32IGA_P09P16: - case IOEXP_TYPE_CYPRESS_7ABC: - case IOEXP_TYPE_TAHOE_5A: - case IOEXP_TYPE_TAHOE_6ABC: - case IOEXP_TYPE_SEQUOIA_NABC: - case IOEXP_TYPE_LAVENDER_P65: - self->get_present = common_get_present; - self->get_tx_fault = ioexp_get_not_support; - self->get_rxlos = ioexp_get_not_support; - self->get_tx_disable = ioexp_get_not_support; - self->get_reset = common_get_reset; - self->get_lpmod = common_get_lpmod; - self->get_modsel = common_get_modsel; - self->get_hard_rs0 = ioexp_get_not_support; - self->get_hard_rs1 = ioexp_get_not_support; - self->set_tx_disable = ioexp_set_not_support; - self->set_reset = common_set_reset; - self->set_lpmod = common_set_lpmod; - self->set_modsel = common_set_modsel; - self->set_hard_rs0 = ioexp_set_not_support; - self->set_hard_rs1 = ioexp_set_not_support; - return 0; - - default: - SWPS_ERR("%s: type:%d incorrect!\n", __func__, ioexp_type); - break; - } - return ERR_IOEXP_UNEXCPT; -} - - -static int -setup_ioexp_private_cb(struct ioexp_obj_s *self, - int ioexp_type){ - - switch (ioexp_type){ - case IOEXP_TYPE_MAGINOLIA_NAB: - case IOEXP_TYPE_MAGINOLIA_4AB: - case IOEXP_TYPE_MAGINOLIA_7AB: - case IOEXP_TYPE_SPRUCE_7AB: - case IOEXP_TYPE_REDWOOD_P01P08: - case IOEXP_TYPE_REDWOOD_P09P16: - case IOEXP_TYPE_HUDSON32IGA_P01P08: - case IOEXP_TYPE_HUDSON32IGA_P09P16: - case IOEXP_TYPE_CYPRESS_NABC: - case IOEXP_TYPE_CYPRESS_7ABC: - case IOEXP_TYPE_TAHOE_5A: - case IOEXP_TYPE_TAHOE_6ABC: - case IOEXP_TYPE_SEQUOIA_NABC: - case IOEXP_TYPE_LAVENDER_P65: - self->init = common_ioexp_init; - self->check = common_ioexp_check; - self->update_all = common_ioexp_update_all; - self->fsm_4_direct = common_ioexp_fsm_4_direct; - self->fsm_4_polling = common_ioexp_fsm_4_polling; - return 0; - - default: - SWPS_ERR("%s: type:%d incorrect!\n", __func__, ioexp_type); - break; - } - return ERR_IOEXP_UNEXCPT; -} - - -static int -setup_i2c_client_one(struct ioexp_obj_s *self, - int chip_id){ - - char *err_msg = "ERROR"; - struct i2c_adapter *adap = NULL; - struct i2c_client *client = NULL; - struct ioexp_i2c_s *i2c_obj_p = NULL; - struct ioexp_i2c_s *i2c_curr_p = NULL; - - int chan_id = self->ioexp_map_p->map_addr[chip_id].chan_id; - adap = i2c_get_adapter(chan_id); - if(!adap){ - err_msg = "Can not get adap!"; - goto err_ioexp_setup_i2c_1; - } - client = kzalloc(sizeof(*client), GFP_KERNEL); - if (!client){ - err_msg = "Can not kzalloc client!"; - goto err_ioexp_setup_i2c_1; - } - i2c_obj_p = kzalloc(sizeof(*i2c_obj_p), GFP_KERNEL); - if (!i2c_obj_p){ - err_msg = "Can not kzalloc i2c_obj_p!"; - goto err_ioexp_setup_i2c_2; - } - client->adapter = adap; - client->addr = self->ioexp_map_p->map_addr[chip_id].chip_addr; - i2c_obj_p->i2c_client_p = client; - i2c_obj_p->chip_id = chip_id; - i2c_obj_p->next = NULL; - if (!self->i2c_head_p){ - self->i2c_head_p = i2c_obj_p; - } else { - i2c_curr_p = self->i2c_head_p; - while (i2c_curr_p->next){ - i2c_curr_p = i2c_curr_p->next; - } - i2c_curr_p->next = i2c_obj_p; - } - return 0; - -err_ioexp_setup_i2c_2: - kfree(client); -err_ioexp_setup_i2c_1: - SWPS_ERR("%s: %s :%d\n", __func__, err_msg, chan_id); - return -1; -} - - -static int -setup_i2c_client(struct ioexp_obj_s* self){ - - int result; - int chip_id = 0; - - for (chip_id=0; chip_id<(self->ioexp_map_p->chip_amount); chip_id++){ - result = setup_i2c_client_one(self, chip_id); - if (result < 0){ - SWPS_ERR("%s fail! :%d\n", __func__, chip_id); - return -1; - } - } - return 0; -} - - -static int -setup_ioexp_config(struct ioexp_obj_s *self) { - - int chip_id, offset, err_code; - struct ioexp_addr_s *addr_p; - - for (chip_id=0; chip_id<(self->ioexp_map_p->chip_amount); chip_id++){ - addr_p = &(self->ioexp_map_p->map_addr[chip_id]); - if (!addr_p){ - SWPS_ERR("IOEXP config incorrect! :%d \n",chip_id); - return -1; - } - for (offset=0; offset<(self->ioexp_map_p->data_width); offset++){ - - err_code = i2c_smbus_write_byte_data(_get_i2c_client(self, chip_id), - addr_p->conf_offset[offset], - addr_p->conf_default[offset]); - - if (err_code < 0){ - SWPS_INFO("%s: set conf fail! :%d \n", __func__, err_code); - return -2; - } - } - } - return 0; -} - - -struct ioexp_obj_s * -_create_ioexp_obj(int ioexp_id, - int ioexp_type, - struct ioexp_addr_s *addr_map_p, - int run_mode){ - - struct ioexp_map_s* ioexp_map_p; - struct ioexp_obj_s* result_p; - struct ioexp_i2c_s *i2c_curr_p; - struct ioexp_i2c_s *i2c_next_p; - - /* Get layout */ - ioexp_map_p = get_ioexp_map(ioexp_type); - if (!ioexp_map_p){ - SWPS_ERR("%s: Invalid ioexp_type\n", __func__); - goto err_create_ioexp_fail; - } - /* Prepare IOEXP object */ - result_p = kzalloc(sizeof(*result_p), GFP_KERNEL); - if (!result_p){ - SWPS_ERR("%s: kzalloc failure!\n", __func__); - goto err_create_ioexp_fail; - } - /* Prepare static size attributes */ - if (setup_ioexp_ssize_attr(result_p, - ioexp_map_p, - ioexp_id, - ioexp_type, - run_mode) < 0){ - goto err_create_ioexp_setup_attr_fail; - } - /* Prepare address mapping */ - if (setup_addr_mapping(result_p, addr_map_p, ioexp_map_p->chip_amount) < 0){ - goto err_create_ioexp_setup_attr_fail; - } - if (setup_i2c_client(result_p) < 0){ - goto err_create_ioexp_setup_i2c_fail; - } - /* Prepare call back functions of object */ - if (setup_ioexp_public_cb(result_p, ioexp_type) < 0){ - goto err_create_ioexp_setup_i2c_fail; - } - if (setup_ioexp_private_cb(result_p, ioexp_type) < 0){ - goto err_create_ioexp_setup_i2c_fail; - } - return result_p; - -err_create_ioexp_setup_i2c_fail: - i2c_curr_p = result_p->i2c_head_p; - i2c_next_p = result_p->i2c_head_p; - while (i2c_curr_p){ - i2c_next_p = i2c_curr_p->next; - kfree(i2c_curr_p->i2c_client_p); - kfree(i2c_curr_p); - i2c_curr_p = i2c_next_p; - } -err_create_ioexp_setup_attr_fail: - kfree(result_p); -err_create_ioexp_fail: - SWPS_ERR("%s: fail! :%d :%d \n", - __func__, ioexp_id, ioexp_type); - return NULL; -} - - -int -create_ioexp_obj(int ioexp_id, - int ioexp_type, - struct ioexp_addr_s *addr_map_p, - int run_mode){ - - struct ioexp_obj_s *ioexp_p = NULL; - - ioexp_p = _create_ioexp_obj(ioexp_id, ioexp_type, - addr_map_p, run_mode); - if (!ioexp_p){ - return -1; - } - if (ioexp_head_p == NULL){ - ioexp_head_p = ioexp_p; - ioexp_tail_p = ioexp_p; - return 0; - } - ioexp_tail_p->next = ioexp_p; - ioexp_tail_p = ioexp_p; - return 0; -} - - -static int -_init_ioexp_obj(struct ioexp_obj_s* self) { - - char *err_msg = "ERR"; - char *func_name = "_init_ioexp_obj"; - - /* Setup IOEXP configure byte */ - if (setup_ioexp_config(self) < 0){ - err_msg = "setup_ioexp_config fail"; - goto err_init_ioexp_obj; - } - /* Setup default data */ - if (_ioexp_init_handler(self) < 0){ - err_msg = "_ioexp_init_handler fail"; - goto err_init_ioexp_obj; - } - /* Update all */ - if (self->state == STATE_IOEXP_NORMAL){ - if (self->update_all(self, 1, func_name) < 0){ - err_msg = "update_all() fail"; - goto err_init_ioexp_obj; - } - } - return 0; - -err_init_ioexp_obj: - SWPS_DEBUG("%s: %s\n", __func__, err_msg); - return -1; -} - - -int -init_ioexp_objs(void){ - /* Return value: - * 0: Success - * -1: Detect topology error - * -2: SWPS internal error - */ - - struct ioexp_obj_s *curr_p = ioexp_head_p; - - if (!curr_p) { - SWPS_ERR("%s: ioexp_head_p is NULL\n", __func__); - return -2; - } - while (curr_p) { - if (_init_ioexp_obj(curr_p) < 0) { - SWPS_DEBUG("%s: _init_ioexp_obj() fail\n", __func__); - return -1; - } - curr_p = curr_p->next; - } - SWPS_DEBUG("%s: done.\n", __func__); - return 0; -} - - -void -clean_ioexp_objs(void){ - - struct ioexp_i2c_s *i2c_curr_p = NULL; - struct ioexp_i2c_s *i2c_next_p = NULL; - struct ioexp_obj_s *ioexp_next_p = NULL; - struct ioexp_obj_s *ioexp_curr_p = ioexp_head_p; - - if (ioexp_head_p == NULL){ - ioexp_tail_p = NULL; - return; - } - while(ioexp_curr_p){ - ioexp_next_p = ioexp_curr_p->next; - if (ioexp_curr_p->ioexp_map_p) { - if (ioexp_curr_p->ioexp_map_p->map_addr) { - kfree(ioexp_curr_p->ioexp_map_p->map_addr); - } - kfree(ioexp_curr_p->ioexp_map_p); - } - - i2c_curr_p = ioexp_curr_p->i2c_head_p; - while (i2c_curr_p) { - i2c_next_p = i2c_curr_p->next; - kfree(i2c_curr_p->i2c_client_p); - kfree(i2c_curr_p); - i2c_curr_p = i2c_next_p; - } - kfree(ioexp_curr_p); - ioexp_curr_p = ioexp_next_p; - } - ioexp_tail_p = NULL; - SWPS_DEBUG("%s: done.\n", __func__); -} - - -int -check_ioexp_objs(void){ - - struct ioexp_obj_s *ioexp_curr_p = ioexp_head_p; - - while (ioexp_curr_p){ - if ( (ioexp_curr_p->check(ioexp_curr_p)) < 0){ - SWPS_INFO("check IOEXP-%d fail! :%d\n", - ioexp_curr_p->ioexp_id, ioexp_curr_p->ioexp_type); - return -1; - } - ioexp_curr_p = ioexp_curr_p->next; - } - return 0; -} - - -struct ioexp_obj_s * -get_ioexp_obj(int ioexp_id){ - - struct ioexp_obj_s *result_p = NULL; - struct ioexp_obj_s *ioexp_curr_p = ioexp_head_p; - - while(ioexp_curr_p){ - if (ioexp_curr_p->ioexp_id == ioexp_id){ - result_p = ioexp_curr_p; - break; - } - ioexp_curr_p = ioexp_curr_p->next; - } - return result_p; -} - - -void -unlock_ioexp_all(void) { - - struct ioexp_obj_s *ioexp_curr_p = ioexp_head_p; - - while(ioexp_curr_p){ - mutex_unlock(&ioexp_curr_p->lock); - ioexp_curr_p = ioexp_curr_p->next; - } -} - - -int -lock_ioexp_all(void) { - - struct ioexp_obj_s *ioexp_curr_p = ioexp_head_p; - - while(ioexp_curr_p){ - mutex_lock(&ioexp_curr_p->lock); - ioexp_curr_p = ioexp_curr_p->next; - } - return 0; -} - - -int -check_channel_tier_1(void) { - - if ( (!_is_channel_ready(ioexp_head_p)) && - (!_is_channel_ready(ioexp_tail_p)) ){ - return -1; - } - return 0; -} - - -static int -_scan_channel_tier_1(int force, - int show_err) { - - struct ioexp_obj_s *ioexp_curr_p = ioexp_head_p; - int ready = 0; - - if (!ioexp_curr_p) { - goto err_scan_tier_1_channel; - } - while(ioexp_curr_p) { - ready = _is_channel_ready(ioexp_curr_p); - if ((!ready) && (!force)) { - goto err_scan_tier_1_channel; - } - ioexp_curr_p = ioexp_curr_p->next; - } - return 0; - -err_scan_tier_1_channel: - if (show_err) { - if (ioexp_curr_p) { - SWPS_INFO("%s: IOEXP-%d fail\n", __func__, ioexp_curr_p->ioexp_id); - } else { - SWPS_INFO("%s: IOEXP is null.\n", __func__); - } - } - return -1; -} - - -static int -_scan_channel_tier_1_single(void) { - - int ret = 0; - int chan_id = 0; - int fake_cid = 0; - int fake_offs = 0; - int fake_addr = 0; - struct i2c_adapter *adap = NULL; - struct i2c_client *client = NULL; - - if (ioexp_head_p->ioexp_id != ioexp_tail_p->ioexp_id) { - return 0; - } - /* Setup i2c_client */ - chan_id = ioexp_head_p->ioexp_map_p->map_addr[fake_cid].chan_id; - fake_addr = ioexp_head_p->ioexp_map_p->map_addr[fake_cid].chip_addr; - adap = i2c_get_adapter((chan_id + 1)); - if(!adap){ - SWPS_INFO("%s: Can not get adap!\n", __func__); - return 0; - } - client = kzalloc(sizeof(*client), GFP_KERNEL); - if (!client){ - SWPS_INFO("%s: Can not kzalloc client!\n", __func__); - return 0; - } - client->adapter = adap; - client->addr = fake_addr; - /* Fouce move ioexp ptr to next */ - ret = i2c_smbus_read_byte_data(client, fake_offs); - SWPS_DEBUG("%s: move ioexp_ptr done. :%d\n", __func__, ret); - kfree(client); - return 1; -} - - -int -resync_channel_tier_1(void) { - - char *emsg = "ERR"; - - if (!ioexp_head_p) { - emsg = "ioexp_head_p is NULL"; - goto err_resync_ioexp_status_1; - } - /* Run all */ - if (ioexp_head_p->ioexp_id == ioexp_tail_p->ioexp_id) { - _scan_channel_tier_1_single(); - } else { - _scan_channel_tier_1(1, 0); - } - /* Check all */ - if (_scan_channel_tier_1(0, 1) < 0) { - emsg = "resync tier-1 channel fail"; - goto err_resync_ioexp_status_1; - } - return 0; - -err_resync_ioexp_status_1: - SWPS_ERR("%s: %s\n", __func__, emsg); - return -1; -} - - - - - - - diff --git a/packages/platforms/inventec/x86-64/d6254qs/modules/builds/src/io_expander.h b/packages/platforms/inventec/x86-64/d6254qs/modules/builds/src/io_expander.h deleted file mode 100644 index 3e33da2e3..000000000 --- a/packages/platforms/inventec/x86-64/d6254qs/modules/builds/src/io_expander.h +++ /dev/null @@ -1,176 +0,0 @@ -#ifndef IO_EXPANDER_H -#define IO_EXPANDER_H - -#include - - -/* IOEXP type define (SFP series) */ -#define IOEXP_TYPE_MAGINOLIA_NAB (10101) -#define IOEXP_TYPE_MAGINOLIA_4AB (10102) -#define IOEXP_TYPE_CYPRESS_NABC (10103) - -/* IOEXP type define (QSFP series) */ -#define IOEXP_TYPE_MAGINOLIA_7AB (10201) -#define IOEXP_TYPE_REDWOOD_P01P08 (10202) -#define IOEXP_TYPE_REDWOOD_P09P16 (10203) -#define IOEXP_TYPE_HUDSON32IGA_P01P08 (10204) -#define IOEXP_TYPE_HUDSON32IGA_P09P16 (10205) -#define IOEXP_TYPE_SPRUCE_7AB (10206) -#define IOEXP_TYPE_CYPRESS_7ABC (10207) -#define IOEXP_TYPE_TAHOE_5A (10208) -#define IOEXP_TYPE_TAHOE_6ABC (10209) -#define IOEXP_TYPE_SEQUOIA_NABC (10210) -#define IOEXP_TYPE_LAVENDER_P65 (10211) - -/* IOEXP mode define */ -#define IOEXP_MODE_POLLING (19000) -#define IOEXP_MODE_DIRECT (19001) - -/* IOEXP state define */ -#define STATE_IOEXP_NORMAL (0) -#define STATE_IOEXP_INIT (-1) -#define STATE_IOEXP_ABNORMAL (-2) - -/* IOEXP error code define */ -#define ERR_IOEXP_NOTSUPPORT (-100) -#define ERR_IOEXP_UNINIT (-101) -#define ERR_IOEXP_BADCONF (-102) -#define ERR_IOEXP_ABNORMAL (-103) -#define ERR_IOEXP_NOSTATE (-104) -#define ERR_IOEXP_BADINPUT (-105) -#define ERR_IOEXP_UNEXCPT (-199) - - -#define SWPS_INFO(fmt, args...) printk( KERN_INFO "[SWPS] " fmt, ##args) -#define SWPS_WARN(fmt, args...) printk( KERN_WARNING "[SWPS] " fmt, ##args) -#define SWPS_ERR(fmt, args...) printk( KERN_ERR "[SWPS] " fmt, ##args) - -#ifdef DEBUG_SWPS -# define SWPS_DEBUG(fmt, args...) printk( KERN_DEBUG "[SWPS] " fmt, ##args) -#else -# define SWPS_DEBUG(fmt, args...) -#endif - - -struct ioexp_addr_s { - int chan_id; - int chip_addr; - int read_offset[8]; - int write_offset[8]; - int conf_offset[8]; - uint8_t data_default[8]; - uint8_t conf_default[8]; -}; - -struct ioexp_i2c_s { - int chip_id; - struct i2c_client *i2c_client_p; - struct ioexp_i2c_s *next; -}; - - -struct ioexp_bitmap_s { - int chip_id; /* IOEXP chip id */ - int ioexp_voffset; /* IOEXP virtual offset */ - int bit_shift; -}; - -struct ioexp_map_s { - int chip_amount; /* Number of chips that IOEXP object content */ - int data_width; /* Number of (Read/Write/Config) bytes */ - struct ioexp_addr_s *map_addr; /* Chip address info */ - struct ioexp_bitmap_s map_present[10]; /* IOEXP for SFP / QSFP */ - struct ioexp_bitmap_s map_tx_disable[10]; /* IOEXP for SFP */ - struct ioexp_bitmap_s map_tx_fault[10]; /* IOEXP for SFP */ - struct ioexp_bitmap_s map_rxlos[10]; /* IOEXP for SFP */ - struct ioexp_bitmap_s map_reset[10]; /* IOEXP for QSFP */ - struct ioexp_bitmap_s map_lpmod[10]; /* IOEXP for QSFP */ - struct ioexp_bitmap_s map_modsel[10]; /* IOEXP for QSFP */ - struct ioexp_bitmap_s map_hard_rs0[10]; /* IOEXP for QSFP */ - struct ioexp_bitmap_s map_hard_rs1[10]; /* IOEXP for QSFP */ -}; - -struct ioexp_data_s { - uint8_t data[8]; -}; - -struct ioexp_obj_s { - - /* ============================ - * Object public property - * ============================ - */ - int ioexp_id; - int ioexp_type; - - /* ============================ - * Object private property - * ============================ - */ - struct ioexp_data_s chip_data[16]; /* Max: 8-ioexp in one virt-ioexp(ioexp_obj) */ - struct ioexp_map_s *ioexp_map_p; - struct ioexp_obj_s *next; - struct ioexp_i2c_s *i2c_head_p; - struct mutex lock; - int mode; - int state; - - /* =========================================== - * Object public functions - * =========================================== - */ - int (*get_present)(struct ioexp_obj_s *self, int virt_offset); - int (*get_tx_fault)(struct ioexp_obj_s *self, int virt_offset); - int (*get_rxlos)(struct ioexp_obj_s *self, int virt_offset); - int (*get_tx_disable)(struct ioexp_obj_s *self, int virt_offset); - int (*get_reset)(struct ioexp_obj_s *self, int virt_offset); - int (*get_lpmod)(struct ioexp_obj_s *self, int virt_offset); - int (*get_modsel)(struct ioexp_obj_s *self, int virt_offset); - int (*get_hard_rs0)(struct ioexp_obj_s *self, int virt_offset); - int (*get_hard_rs1)(struct ioexp_obj_s *self, int virt_offset); - int (*set_tx_disable)(struct ioexp_obj_s *self, int virt_offset, int input_val); - int (*set_reset)(struct ioexp_obj_s *self, int virt_offset, int input_val); - int (*set_lpmod)(struct ioexp_obj_s *self, int virt_offset, int input_val); - int (*set_modsel)(struct ioexp_obj_s *self, int virt_offset, int input_val); - int (*set_hard_rs0)(struct ioexp_obj_s *self, int virt_offset, int input_val); - int (*set_hard_rs1)(struct ioexp_obj_s *self, int virt_offset, int input_val); - - /* =========================================== - * Object private functions - * =========================================== - */ - int (*init)(struct ioexp_obj_s *self); - int (*check)(struct ioexp_obj_s *self); - int (*update_all)(struct ioexp_obj_s *self, int show_err, char *caller_name); - int (*fsm_4_direct)(struct ioexp_obj_s* self); - int (*fsm_4_polling)(struct ioexp_obj_s* self); -}; - - -struct ioexp_obj_s* get_ioexp_obj(int ioexp_id); -int create_ioexp_obj(int ioexp_id, - int ioexp_type, - struct ioexp_addr_s *addr_map_p, - int run_mode); -int init_ioexp_objs(void); -int check_ioexp_objs(void); -void clean_ioexp_objs(void); - -void unlock_ioexp_all(void); -int lock_ioexp_all(void); - -int check_channel_tier_1(void); -int resync_channel_tier_1(void); - -/* Macro for bit control */ -#define SWP_BIT_SET(byte_val,bit_shift) ((byte_val) |= (1<<(bit_shift))) -#define SWP_BIT_CLEAR(byte_val,bit_shift) ((byte_val) &= ~(1<<(bit_shift))) - - -#endif /* IO_EXPANDER_H */ - - - - - - diff --git a/packages/platforms/inventec/x86-64/d6254qs/modules/builds/src/lpc_ich.c b/packages/platforms/inventec/x86-64/d6254qs/modules/builds/src/lpc_ich.c deleted file mode 100644 index c78fb0e59..000000000 --- a/packages/platforms/inventec/x86-64/d6254qs/modules/builds/src/lpc_ich.c +++ /dev/null @@ -1,1086 +0,0 @@ -/* - * lpc_ich.c - LPC interface for Intel ICH - * - * LPC bridge function of the Intel ICH contains many other - * functional units, such as Interrupt controllers, Timers, - * Power Management, System Management, GPIO, RTC, and LPC - * Configuration Registers. - * - * This driver is derived from lpc_sch. - - * Copyright (c) 2011 Extreme Engineering Solution, Inc. - * Author: Aaron Sierra - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License 2 as published - * by the Free Software Foundation. - * - * 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; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - * - * This driver supports the following I/O Controller hubs: - * (See the intel documentation on http://developer.intel.com.) - * document number 290655-003, 290677-014: 82801AA (ICH), 82801AB (ICHO) - * document number 290687-002, 298242-027: 82801BA (ICH2) - * document number 290733-003, 290739-013: 82801CA (ICH3-S) - * document number 290716-001, 290718-007: 82801CAM (ICH3-M) - * document number 290744-001, 290745-025: 82801DB (ICH4) - * document number 252337-001, 252663-008: 82801DBM (ICH4-M) - * document number 273599-001, 273645-002: 82801E (C-ICH) - * document number 252516-001, 252517-028: 82801EB (ICH5), 82801ER (ICH5R) - * document number 300641-004, 300884-013: 6300ESB - * document number 301473-002, 301474-026: 82801F (ICH6) - * document number 313082-001, 313075-006: 631xESB, 632xESB - * document number 307013-003, 307014-024: 82801G (ICH7) - * document number 322896-001, 322897-001: NM10 - * document number 313056-003, 313057-017: 82801H (ICH8) - * document number 316972-004, 316973-012: 82801I (ICH9) - * document number 319973-002, 319974-002: 82801J (ICH10) - * document number 322169-001, 322170-003: 5 Series, 3400 Series (PCH) - * document number 320066-003, 320257-008: EP80597 (IICH) - * document number 324645-001, 324646-001: Cougar Point (CPT) - * document number TBD : Patsburg (PBG) - * document number TBD : DH89xxCC - * document number TBD : Panther Point - * document number TBD : Lynx Point - * document number TBD : Lynx Point-LP - * document number TBD : Wellsburg - * document number TBD : Avoton SoC - * document number TBD : Coleto Creek - * document number TBD : Wildcat Point-LP - */ - -#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt - -#include -#include -#include -#include -#include -#include -//#include -#include "lpc_ich.h" - -#define ACPIBASE 0x40 -#define ACPIBASE_GPE_OFF 0x28 -#define ACPIBASE_GPE_END 0x2f -#define ACPIBASE_SMI_OFF 0x30 -#define ACPIBASE_SMI_END 0x33 -#define ACPIBASE_PMC_OFF 0x08 -#define ACPIBASE_PMC_END 0x0c -#define ACPIBASE_TCO_OFF 0x60 -#define ACPIBASE_TCO_END 0x7f -#define ACPICTRL_PMCBASE 0x44 - -#define ACPIBASE_GCS_OFF 0x3410 -#define ACPIBASE_GCS_END 0x3414 - -#define GPIOBASE_ICH0 0x58 -#define GPIOCTRL_ICH0 0x5C -#define GPIOBASE_ICH6 0x48 -#define GPIOCTRL_ICH6 0x4C - -#define RCBABASE 0xf0 - -#define wdt_io_res(i) wdt_res(0, i) -#define wdt_mem_res(i) wdt_res(ICH_RES_MEM_OFF, i) -#define wdt_res(b, i) (&wdt_ich_res[(b) + (i)]) - -struct lpc_ich_priv { - int chipset; - - int abase; /* ACPI base */ - int actrl_pbase; /* ACPI control or PMC base */ - int gbase; /* GPIO base */ - int gctrl; /* GPIO control */ - - int abase_save; /* Cached ACPI base value */ - int actrl_pbase_save; /* Cached ACPI control or PMC base value */ - int gctrl_save; /* Cached GPIO control value */ -}; - -static struct resource wdt_ich_res[] = { - /* ACPI - TCO */ - { - .flags = IORESOURCE_IO, - }, - /* ACPI - SMI */ - { - .flags = IORESOURCE_IO, - }, - /* GCS or PMC */ - { - .flags = IORESOURCE_MEM, - }, -}; - -static struct resource gpio_ich_res[] = { - /* GPIO */ - { - .flags = IORESOURCE_IO, - }, - /* ACPI - GPE0 */ - { - .flags = IORESOURCE_IO, - }, -}; - -enum lpc_cells { - LPC_WDT = 0, - LPC_GPIO, -}; - -static struct mfd_cell lpc_ich_cells[] = { - [LPC_WDT] = { - .name = "iTCO_wdt", - .num_resources = ARRAY_SIZE(wdt_ich_res), - .resources = wdt_ich_res, - .ignore_resource_conflicts = true, - }, - [LPC_GPIO] = { - .name = "gpio_ich", - .num_resources = ARRAY_SIZE(gpio_ich_res), - .resources = gpio_ich_res, - .ignore_resource_conflicts = true, - }, -}; - -/* chipset related info */ -enum lpc_chipsets { - LPC_ICH = 0, /* ICH */ - LPC_ICH0, /* ICH0 */ - LPC_ICH2, /* ICH2 */ - LPC_ICH2M, /* ICH2-M */ - LPC_ICH3, /* ICH3-S */ - LPC_ICH3M, /* ICH3-M */ - LPC_ICH4, /* ICH4 */ - LPC_ICH4M, /* ICH4-M */ - LPC_CICH, /* C-ICH */ - LPC_ICH5, /* ICH5 & ICH5R */ - LPC_6300ESB, /* 6300ESB */ - LPC_ICH6, /* ICH6 & ICH6R */ - LPC_ICH6M, /* ICH6-M */ - LPC_ICH6W, /* ICH6W & ICH6RW */ - LPC_631XESB, /* 631xESB/632xESB */ - LPC_ICH7, /* ICH7 & ICH7R */ - LPC_ICH7DH, /* ICH7DH */ - LPC_ICH7M, /* ICH7-M & ICH7-U */ - LPC_ICH7MDH, /* ICH7-M DH */ - LPC_NM10, /* NM10 */ - LPC_ICH8, /* ICH8 & ICH8R */ - LPC_ICH8DH, /* ICH8DH */ - LPC_ICH8DO, /* ICH8DO */ - LPC_ICH8M, /* ICH8M */ - LPC_ICH8ME, /* ICH8M-E */ - LPC_ICH9, /* ICH9 */ - LPC_ICH9R, /* ICH9R */ - LPC_ICH9DH, /* ICH9DH */ - LPC_ICH9DO, /* ICH9DO */ - LPC_ICH9M, /* ICH9M */ - LPC_ICH9ME, /* ICH9M-E */ - LPC_ICH10, /* ICH10 */ - LPC_ICH10R, /* ICH10R */ - LPC_ICH10D, /* ICH10D */ - LPC_ICH10DO, /* ICH10DO */ - LPC_PCH, /* PCH Desktop Full Featured */ - LPC_PCHM, /* PCH Mobile Full Featured */ - LPC_P55, /* P55 */ - LPC_PM55, /* PM55 */ - LPC_H55, /* H55 */ - LPC_QM57, /* QM57 */ - LPC_H57, /* H57 */ - LPC_HM55, /* HM55 */ - LPC_Q57, /* Q57 */ - LPC_HM57, /* HM57 */ - LPC_PCHMSFF, /* PCH Mobile SFF Full Featured */ - LPC_QS57, /* QS57 */ - LPC_3400, /* 3400 */ - LPC_3420, /* 3420 */ - LPC_3450, /* 3450 */ - LPC_EP80579, /* EP80579 */ - LPC_CPT, /* Cougar Point */ - LPC_CPTD, /* Cougar Point Desktop */ - LPC_CPTM, /* Cougar Point Mobile */ - LPC_PBG, /* Patsburg */ - LPC_DH89XXCC, /* DH89xxCC */ - LPC_PPT, /* Panther Point */ - LPC_LPT, /* Lynx Point */ - LPC_LPT_LP, /* Lynx Point-LP */ - LPC_WBG, /* Wellsburg */ - LPC_AVN, /* Avoton SoC */ - LPC_BAYTRAIL, /* Bay Trail SoC */ - LPC_COLETO, /* Coleto Creek */ - LPC_WPT_LP, /* Wildcat Point-LP */ -}; - -static struct lpc_ich_info lpc_chipset_info[] = { - [LPC_ICH] = { - .name = "ICH", - .iTCO_version = 1, - }, - [LPC_ICH0] = { - .name = "ICH0", - .iTCO_version = 1, - }, - [LPC_ICH2] = { - .name = "ICH2", - .iTCO_version = 1, - }, - [LPC_ICH2M] = { - .name = "ICH2-M", - .iTCO_version = 1, - }, - [LPC_ICH3] = { - .name = "ICH3-S", - .iTCO_version = 1, - }, - [LPC_ICH3M] = { - .name = "ICH3-M", - .iTCO_version = 1, - }, - [LPC_ICH4] = { - .name = "ICH4", - .iTCO_version = 1, - }, - [LPC_ICH4M] = { - .name = "ICH4-M", - .iTCO_version = 1, - }, - [LPC_CICH] = { - .name = "C-ICH", - .iTCO_version = 1, - }, - [LPC_ICH5] = { - .name = "ICH5 or ICH5R", - .iTCO_version = 1, - }, - [LPC_6300ESB] = { - .name = "6300ESB", - .iTCO_version = 1, - }, - [LPC_ICH6] = { - .name = "ICH6 or ICH6R", - .iTCO_version = 2, - .gpio_version = ICH_V6_GPIO, - }, - [LPC_ICH6M] = { - .name = "ICH6-M", - .iTCO_version = 2, - .gpio_version = ICH_V6_GPIO, - }, - [LPC_ICH6W] = { - .name = "ICH6W or ICH6RW", - .iTCO_version = 2, - .gpio_version = ICH_V6_GPIO, - }, - [LPC_631XESB] = { - .name = "631xESB/632xESB", - .iTCO_version = 2, - .gpio_version = ICH_V6_GPIO, - }, - [LPC_ICH7] = { - .name = "ICH7 or ICH7R", - .iTCO_version = 2, - .gpio_version = ICH_V7_GPIO, - }, - [LPC_ICH7DH] = { - .name = "ICH7DH", - .iTCO_version = 2, - .gpio_version = ICH_V7_GPIO, - }, - [LPC_ICH7M] = { - .name = "ICH7-M or ICH7-U", - .iTCO_version = 2, - .gpio_version = ICH_V7_GPIO, - }, - [LPC_ICH7MDH] = { - .name = "ICH7-M DH", - .iTCO_version = 2, - .gpio_version = ICH_V7_GPIO, - }, - [LPC_NM10] = { - .name = "NM10", - .iTCO_version = 2, - .gpio_version = ICH_V7_GPIO, - }, - [LPC_ICH8] = { - .name = "ICH8 or ICH8R", - .iTCO_version = 2, - .gpio_version = ICH_V7_GPIO, - }, - [LPC_ICH8DH] = { - .name = "ICH8DH", - .iTCO_version = 2, - .gpio_version = ICH_V7_GPIO, - }, - [LPC_ICH8DO] = { - .name = "ICH8DO", - .iTCO_version = 2, - .gpio_version = ICH_V7_GPIO, - }, - [LPC_ICH8M] = { - .name = "ICH8M", - .iTCO_version = 2, - .gpio_version = ICH_V7_GPIO, - }, - [LPC_ICH8ME] = { - .name = "ICH8M-E", - .iTCO_version = 2, - .gpio_version = ICH_V7_GPIO, - }, - [LPC_ICH9] = { - .name = "ICH9", - .iTCO_version = 2, - .gpio_version = ICH_V9_GPIO, - }, - [LPC_ICH9R] = { - .name = "ICH9R", - .iTCO_version = 2, - .gpio_version = ICH_V9_GPIO, - }, - [LPC_ICH9DH] = { - .name = "ICH9DH", - .iTCO_version = 2, - .gpio_version = ICH_V9_GPIO, - }, - [LPC_ICH9DO] = { - .name = "ICH9DO", - .iTCO_version = 2, - .gpio_version = ICH_V9_GPIO, - }, - [LPC_ICH9M] = { - .name = "ICH9M", - .iTCO_version = 2, - .gpio_version = ICH_V9_GPIO, - }, - [LPC_ICH9ME] = { - .name = "ICH9M-E", - .iTCO_version = 2, - .gpio_version = ICH_V9_GPIO, - }, - [LPC_ICH10] = { - .name = "ICH10", - .iTCO_version = 2, - .gpio_version = ICH_V10CONS_GPIO, - }, - [LPC_ICH10R] = { - .name = "ICH10R", - .iTCO_version = 2, - .gpio_version = ICH_V10CONS_GPIO, - }, - [LPC_ICH10D] = { - .name = "ICH10D", - .iTCO_version = 2, - .gpio_version = ICH_V10CORP_GPIO, - }, - [LPC_ICH10DO] = { - .name = "ICH10DO", - .iTCO_version = 2, - .gpio_version = ICH_V10CORP_GPIO, - }, - [LPC_PCH] = { - .name = "PCH Desktop Full Featured", - .iTCO_version = 2, - .gpio_version = ICH_V5_GPIO, - }, - [LPC_PCHM] = { - .name = "PCH Mobile Full Featured", - .iTCO_version = 2, - .gpio_version = ICH_V5_GPIO, - }, - [LPC_P55] = { - .name = "P55", - .iTCO_version = 2, - .gpio_version = ICH_V5_GPIO, - }, - [LPC_PM55] = { - .name = "PM55", - .iTCO_version = 2, - .gpio_version = ICH_V5_GPIO, - }, - [LPC_H55] = { - .name = "H55", - .iTCO_version = 2, - .gpio_version = ICH_V5_GPIO, - }, - [LPC_QM57] = { - .name = "QM57", - .iTCO_version = 2, - .gpio_version = ICH_V5_GPIO, - }, - [LPC_H57] = { - .name = "H57", - .iTCO_version = 2, - .gpio_version = ICH_V5_GPIO, - }, - [LPC_HM55] = { - .name = "HM55", - .iTCO_version = 2, - .gpio_version = ICH_V5_GPIO, - }, - [LPC_Q57] = { - .name = "Q57", - .iTCO_version = 2, - .gpio_version = ICH_V5_GPIO, - }, - [LPC_HM57] = { - .name = "HM57", - .iTCO_version = 2, - .gpio_version = ICH_V5_GPIO, - }, - [LPC_PCHMSFF] = { - .name = "PCH Mobile SFF Full Featured", - .iTCO_version = 2, - .gpio_version = ICH_V5_GPIO, - }, - [LPC_QS57] = { - .name = "QS57", - .iTCO_version = 2, - .gpio_version = ICH_V5_GPIO, - }, - [LPC_3400] = { - .name = "3400", - .iTCO_version = 2, - .gpio_version = ICH_V5_GPIO, - }, - [LPC_3420] = { - .name = "3420", - .iTCO_version = 2, - .gpio_version = ICH_V5_GPIO, - }, - [LPC_3450] = { - .name = "3450", - .iTCO_version = 2, - .gpio_version = ICH_V5_GPIO, - }, - [LPC_EP80579] = { - .name = "EP80579", - .iTCO_version = 2, - }, - [LPC_CPT] = { - .name = "Cougar Point", - .iTCO_version = 2, - .gpio_version = ICH_V5_GPIO, - }, - [LPC_CPTD] = { - .name = "Cougar Point Desktop", - .iTCO_version = 2, - .gpio_version = ICH_V5_GPIO, - }, - [LPC_CPTM] = { - .name = "Cougar Point Mobile", - .iTCO_version = 2, - .gpio_version = ICH_V5_GPIO, - }, - [LPC_PBG] = { - .name = "Patsburg", - .iTCO_version = 2, - }, - [LPC_DH89XXCC] = { - .name = "DH89xxCC", - .iTCO_version = 2, - }, - [LPC_PPT] = { - .name = "Panther Point", - .iTCO_version = 2, - }, - [LPC_LPT] = { - .name = "Lynx Point", - .iTCO_version = 2, - }, - [LPC_LPT_LP] = { - .name = "Lynx Point_LP", - .iTCO_version = 2, - }, - [LPC_WBG] = { - .name = "Wellsburg", - .iTCO_version = 2, - }, - [LPC_AVN] = { - .name = "Avoton SoC", - .iTCO_version = 3, - .gpio_version = AVOTON_GPIO, - }, - [LPC_BAYTRAIL] = { - .name = "Bay Trail SoC", - .iTCO_version = 3, - }, - [LPC_COLETO] = { - .name = "Coleto Creek", - .iTCO_version = 2, - }, - [LPC_WPT_LP] = { - .name = "Wildcat Point_LP", - .iTCO_version = 2, - }, -}; - -/* - * This data only exists for exporting the supported PCI ids - * via MODULE_DEVICE_TABLE. We do not actually register a - * pci_driver, because the I/O Controller Hub has also other - * functions that probably will be registered by other drivers. - */ -static const struct pci_device_id lpc_ich_ids[] = { - { PCI_VDEVICE(INTEL, 0x2410), LPC_ICH}, - { PCI_VDEVICE(INTEL, 0x2420), LPC_ICH0}, - { PCI_VDEVICE(INTEL, 0x2440), LPC_ICH2}, - { PCI_VDEVICE(INTEL, 0x244c), LPC_ICH2M}, - { PCI_VDEVICE(INTEL, 0x2480), LPC_ICH3}, - { PCI_VDEVICE(INTEL, 0x248c), LPC_ICH3M}, - { PCI_VDEVICE(INTEL, 0x24c0), LPC_ICH4}, - { PCI_VDEVICE(INTEL, 0x24cc), LPC_ICH4M}, - { PCI_VDEVICE(INTEL, 0x2450), LPC_CICH}, - { PCI_VDEVICE(INTEL, 0x24d0), LPC_ICH5}, - { PCI_VDEVICE(INTEL, 0x25a1), LPC_6300ESB}, - { PCI_VDEVICE(INTEL, 0x2640), LPC_ICH6}, - { PCI_VDEVICE(INTEL, 0x2641), LPC_ICH6M}, - { PCI_VDEVICE(INTEL, 0x2642), LPC_ICH6W}, - { PCI_VDEVICE(INTEL, 0x2670), LPC_631XESB}, - { PCI_VDEVICE(INTEL, 0x2671), LPC_631XESB}, - { PCI_VDEVICE(INTEL, 0x2672), LPC_631XESB}, - { PCI_VDEVICE(INTEL, 0x2673), LPC_631XESB}, - { PCI_VDEVICE(INTEL, 0x2674), LPC_631XESB}, - { PCI_VDEVICE(INTEL, 0x2675), LPC_631XESB}, - { PCI_VDEVICE(INTEL, 0x2676), LPC_631XESB}, - { PCI_VDEVICE(INTEL, 0x2677), LPC_631XESB}, - { PCI_VDEVICE(INTEL, 0x2678), LPC_631XESB}, - { PCI_VDEVICE(INTEL, 0x2679), LPC_631XESB}, - { PCI_VDEVICE(INTEL, 0x267a), LPC_631XESB}, - { PCI_VDEVICE(INTEL, 0x267b), LPC_631XESB}, - { PCI_VDEVICE(INTEL, 0x267c), LPC_631XESB}, - { PCI_VDEVICE(INTEL, 0x267d), LPC_631XESB}, - { PCI_VDEVICE(INTEL, 0x267e), LPC_631XESB}, - { PCI_VDEVICE(INTEL, 0x267f), LPC_631XESB}, - { PCI_VDEVICE(INTEL, 0x27b8), LPC_ICH7}, - { PCI_VDEVICE(INTEL, 0x27b0), LPC_ICH7DH}, - { PCI_VDEVICE(INTEL, 0x27b9), LPC_ICH7M}, - { PCI_VDEVICE(INTEL, 0x27bd), LPC_ICH7MDH}, - { PCI_VDEVICE(INTEL, 0x27bc), LPC_NM10}, - { PCI_VDEVICE(INTEL, 0x2810), LPC_ICH8}, - { PCI_VDEVICE(INTEL, 0x2812), LPC_ICH8DH}, - { PCI_VDEVICE(INTEL, 0x2814), LPC_ICH8DO}, - { PCI_VDEVICE(INTEL, 0x2815), LPC_ICH8M}, - { PCI_VDEVICE(INTEL, 0x2811), LPC_ICH8ME}, - { PCI_VDEVICE(INTEL, 0x2918), LPC_ICH9}, - { PCI_VDEVICE(INTEL, 0x2916), LPC_ICH9R}, - { PCI_VDEVICE(INTEL, 0x2912), LPC_ICH9DH}, - { PCI_VDEVICE(INTEL, 0x2914), LPC_ICH9DO}, - { PCI_VDEVICE(INTEL, 0x2919), LPC_ICH9M}, - { PCI_VDEVICE(INTEL, 0x2917), LPC_ICH9ME}, - { PCI_VDEVICE(INTEL, 0x3a18), LPC_ICH10}, - { PCI_VDEVICE(INTEL, 0x3a16), LPC_ICH10R}, - { PCI_VDEVICE(INTEL, 0x3a1a), LPC_ICH10D}, - { PCI_VDEVICE(INTEL, 0x3a14), LPC_ICH10DO}, - { PCI_VDEVICE(INTEL, 0x3b00), LPC_PCH}, - { PCI_VDEVICE(INTEL, 0x3b01), LPC_PCHM}, - { PCI_VDEVICE(INTEL, 0x3b02), LPC_P55}, - { PCI_VDEVICE(INTEL, 0x3b03), LPC_PM55}, - { PCI_VDEVICE(INTEL, 0x3b06), LPC_H55}, - { PCI_VDEVICE(INTEL, 0x3b07), LPC_QM57}, - { PCI_VDEVICE(INTEL, 0x3b08), LPC_H57}, - { PCI_VDEVICE(INTEL, 0x3b09), LPC_HM55}, - { PCI_VDEVICE(INTEL, 0x3b0a), LPC_Q57}, - { PCI_VDEVICE(INTEL, 0x3b0b), LPC_HM57}, - { PCI_VDEVICE(INTEL, 0x3b0d), LPC_PCHMSFF}, - { PCI_VDEVICE(INTEL, 0x3b0f), LPC_QS57}, - { PCI_VDEVICE(INTEL, 0x3b12), LPC_3400}, - { PCI_VDEVICE(INTEL, 0x3b14), LPC_3420}, - { PCI_VDEVICE(INTEL, 0x3b16), LPC_3450}, - { PCI_VDEVICE(INTEL, 0x5031), LPC_EP80579}, - { PCI_VDEVICE(INTEL, 0x1c41), LPC_CPT}, - { PCI_VDEVICE(INTEL, 0x1c42), LPC_CPTD}, - { PCI_VDEVICE(INTEL, 0x1c43), LPC_CPTM}, - { PCI_VDEVICE(INTEL, 0x1c44), LPC_CPT}, - { PCI_VDEVICE(INTEL, 0x1c45), LPC_CPT}, - { PCI_VDEVICE(INTEL, 0x1c46), LPC_CPT}, - { PCI_VDEVICE(INTEL, 0x1c47), LPC_CPT}, - { PCI_VDEVICE(INTEL, 0x1c48), LPC_CPT}, - { PCI_VDEVICE(INTEL, 0x1c49), LPC_CPT}, - { PCI_VDEVICE(INTEL, 0x1c4a), LPC_CPT}, - { PCI_VDEVICE(INTEL, 0x1c4b), LPC_CPT}, - { PCI_VDEVICE(INTEL, 0x1c4c), LPC_CPT}, - { PCI_VDEVICE(INTEL, 0x1c4d), LPC_CPT}, - { PCI_VDEVICE(INTEL, 0x1c4e), LPC_CPT}, - { PCI_VDEVICE(INTEL, 0x1c4f), LPC_CPT}, - { PCI_VDEVICE(INTEL, 0x1c50), LPC_CPT}, - { PCI_VDEVICE(INTEL, 0x1c51), LPC_CPT}, - { PCI_VDEVICE(INTEL, 0x1c52), LPC_CPT}, - { PCI_VDEVICE(INTEL, 0x1c53), LPC_CPT}, - { PCI_VDEVICE(INTEL, 0x1c54), LPC_CPT}, - { PCI_VDEVICE(INTEL, 0x1c55), LPC_CPT}, - { PCI_VDEVICE(INTEL, 0x1c56), LPC_CPT}, - { PCI_VDEVICE(INTEL, 0x1c57), LPC_CPT}, - { PCI_VDEVICE(INTEL, 0x1c58), LPC_CPT}, - { PCI_VDEVICE(INTEL, 0x1c59), LPC_CPT}, - { PCI_VDEVICE(INTEL, 0x1c5a), LPC_CPT}, - { PCI_VDEVICE(INTEL, 0x1c5b), LPC_CPT}, - { PCI_VDEVICE(INTEL, 0x1c5c), LPC_CPT}, - { PCI_VDEVICE(INTEL, 0x1c5d), LPC_CPT}, - { PCI_VDEVICE(INTEL, 0x1c5e), LPC_CPT}, - { PCI_VDEVICE(INTEL, 0x1c5f), LPC_CPT}, - { PCI_VDEVICE(INTEL, 0x1d40), LPC_PBG}, - { PCI_VDEVICE(INTEL, 0x1d41), LPC_PBG}, - { PCI_VDEVICE(INTEL, 0x2310), LPC_DH89XXCC}, - { PCI_VDEVICE(INTEL, 0x1e40), LPC_PPT}, - { PCI_VDEVICE(INTEL, 0x1e41), LPC_PPT}, - { PCI_VDEVICE(INTEL, 0x1e42), LPC_PPT}, - { PCI_VDEVICE(INTEL, 0x1e43), LPC_PPT}, - { PCI_VDEVICE(INTEL, 0x1e44), LPC_PPT}, - { PCI_VDEVICE(INTEL, 0x1e45), LPC_PPT}, - { PCI_VDEVICE(INTEL, 0x1e46), LPC_PPT}, - { PCI_VDEVICE(INTEL, 0x1e47), LPC_PPT}, - { PCI_VDEVICE(INTEL, 0x1e48), LPC_PPT}, - { PCI_VDEVICE(INTEL, 0x1e49), LPC_PPT}, - { PCI_VDEVICE(INTEL, 0x1e4a), LPC_PPT}, - { PCI_VDEVICE(INTEL, 0x1e4b), LPC_PPT}, - { PCI_VDEVICE(INTEL, 0x1e4c), LPC_PPT}, - { PCI_VDEVICE(INTEL, 0x1e4d), LPC_PPT}, - { PCI_VDEVICE(INTEL, 0x1e4e), LPC_PPT}, - { PCI_VDEVICE(INTEL, 0x1e4f), LPC_PPT}, - { PCI_VDEVICE(INTEL, 0x1e50), LPC_PPT}, - { PCI_VDEVICE(INTEL, 0x1e51), LPC_PPT}, - { PCI_VDEVICE(INTEL, 0x1e52), LPC_PPT}, - { PCI_VDEVICE(INTEL, 0x1e53), LPC_PPT}, - { PCI_VDEVICE(INTEL, 0x1e54), LPC_PPT}, - { PCI_VDEVICE(INTEL, 0x1e55), LPC_PPT}, - { PCI_VDEVICE(INTEL, 0x1e56), LPC_PPT}, - { PCI_VDEVICE(INTEL, 0x1e57), LPC_PPT}, - { PCI_VDEVICE(INTEL, 0x1e58), LPC_PPT}, - { PCI_VDEVICE(INTEL, 0x1e59), LPC_PPT}, - { PCI_VDEVICE(INTEL, 0x1e5a), LPC_PPT}, - { PCI_VDEVICE(INTEL, 0x1e5b), LPC_PPT}, - { PCI_VDEVICE(INTEL, 0x1e5c), LPC_PPT}, - { PCI_VDEVICE(INTEL, 0x1e5d), LPC_PPT}, - { PCI_VDEVICE(INTEL, 0x1e5e), LPC_PPT}, - { PCI_VDEVICE(INTEL, 0x1e5f), LPC_PPT}, - { PCI_VDEVICE(INTEL, 0x8c40), LPC_LPT}, - { PCI_VDEVICE(INTEL, 0x8c41), LPC_LPT}, - { PCI_VDEVICE(INTEL, 0x8c42), LPC_LPT}, - { PCI_VDEVICE(INTEL, 0x8c43), LPC_LPT}, - { PCI_VDEVICE(INTEL, 0x8c44), LPC_LPT}, - { PCI_VDEVICE(INTEL, 0x8c45), LPC_LPT}, - { PCI_VDEVICE(INTEL, 0x8c46), LPC_LPT}, - { PCI_VDEVICE(INTEL, 0x8c47), LPC_LPT}, - { PCI_VDEVICE(INTEL, 0x8c48), LPC_LPT}, - { PCI_VDEVICE(INTEL, 0x8c49), LPC_LPT}, - { PCI_VDEVICE(INTEL, 0x8c4a), LPC_LPT}, - { PCI_VDEVICE(INTEL, 0x8c4b), LPC_LPT}, - { PCI_VDEVICE(INTEL, 0x8c4c), LPC_LPT}, - { PCI_VDEVICE(INTEL, 0x8c4d), LPC_LPT}, - { PCI_VDEVICE(INTEL, 0x8c4e), LPC_LPT}, - { PCI_VDEVICE(INTEL, 0x8c4f), LPC_LPT}, - { PCI_VDEVICE(INTEL, 0x8c50), LPC_LPT}, - { PCI_VDEVICE(INTEL, 0x8c51), LPC_LPT}, - { PCI_VDEVICE(INTEL, 0x8c52), LPC_LPT}, - { PCI_VDEVICE(INTEL, 0x8c53), LPC_LPT}, - { PCI_VDEVICE(INTEL, 0x8c54), LPC_LPT}, - { PCI_VDEVICE(INTEL, 0x8c55), LPC_LPT}, - { PCI_VDEVICE(INTEL, 0x8c56), LPC_LPT}, - { PCI_VDEVICE(INTEL, 0x8c57), LPC_LPT}, - { PCI_VDEVICE(INTEL, 0x8c58), LPC_LPT}, - { PCI_VDEVICE(INTEL, 0x8c59), LPC_LPT}, - { PCI_VDEVICE(INTEL, 0x8c5a), LPC_LPT}, - { PCI_VDEVICE(INTEL, 0x8c5b), LPC_LPT}, - { PCI_VDEVICE(INTEL, 0x8c5c), LPC_LPT}, - { PCI_VDEVICE(INTEL, 0x8c5d), LPC_LPT}, - { PCI_VDEVICE(INTEL, 0x8c5e), LPC_LPT}, - { PCI_VDEVICE(INTEL, 0x8c5f), LPC_LPT}, - { PCI_VDEVICE(INTEL, 0x9c40), LPC_LPT_LP}, - { PCI_VDEVICE(INTEL, 0x9c41), LPC_LPT_LP}, - { PCI_VDEVICE(INTEL, 0x9c42), LPC_LPT_LP}, - { PCI_VDEVICE(INTEL, 0x9c43), LPC_LPT_LP}, - { PCI_VDEVICE(INTEL, 0x9c44), LPC_LPT_LP}, - { PCI_VDEVICE(INTEL, 0x9c45), LPC_LPT_LP}, - { PCI_VDEVICE(INTEL, 0x9c46), LPC_LPT_LP}, - { PCI_VDEVICE(INTEL, 0x9c47), LPC_LPT_LP}, - { PCI_VDEVICE(INTEL, 0x8d40), LPC_WBG}, - { PCI_VDEVICE(INTEL, 0x8d41), LPC_WBG}, - { PCI_VDEVICE(INTEL, 0x8d42), LPC_WBG}, - { PCI_VDEVICE(INTEL, 0x8d43), LPC_WBG}, - { PCI_VDEVICE(INTEL, 0x8d44), LPC_WBG}, - { PCI_VDEVICE(INTEL, 0x8d45), LPC_WBG}, - { PCI_VDEVICE(INTEL, 0x8d46), LPC_WBG}, - { PCI_VDEVICE(INTEL, 0x8d47), LPC_WBG}, - { PCI_VDEVICE(INTEL, 0x8d48), LPC_WBG}, - { PCI_VDEVICE(INTEL, 0x8d49), LPC_WBG}, - { PCI_VDEVICE(INTEL, 0x8d4a), LPC_WBG}, - { PCI_VDEVICE(INTEL, 0x8d4b), LPC_WBG}, - { PCI_VDEVICE(INTEL, 0x8d4c), LPC_WBG}, - { PCI_VDEVICE(INTEL, 0x8d4d), LPC_WBG}, - { PCI_VDEVICE(INTEL, 0x8d4e), LPC_WBG}, - { PCI_VDEVICE(INTEL, 0x8d4f), LPC_WBG}, - { PCI_VDEVICE(INTEL, 0x8d50), LPC_WBG}, - { PCI_VDEVICE(INTEL, 0x8d51), LPC_WBG}, - { PCI_VDEVICE(INTEL, 0x8d52), LPC_WBG}, - { PCI_VDEVICE(INTEL, 0x8d53), LPC_WBG}, - { PCI_VDEVICE(INTEL, 0x8d54), LPC_WBG}, - { PCI_VDEVICE(INTEL, 0x8d55), LPC_WBG}, - { PCI_VDEVICE(INTEL, 0x8d56), LPC_WBG}, - { PCI_VDEVICE(INTEL, 0x8d57), LPC_WBG}, - { PCI_VDEVICE(INTEL, 0x8d58), LPC_WBG}, - { PCI_VDEVICE(INTEL, 0x8d59), LPC_WBG}, - { PCI_VDEVICE(INTEL, 0x8d5a), LPC_WBG}, - { PCI_VDEVICE(INTEL, 0x8d5b), LPC_WBG}, - { PCI_VDEVICE(INTEL, 0x8d5c), LPC_WBG}, - { PCI_VDEVICE(INTEL, 0x8d5d), LPC_WBG}, - { PCI_VDEVICE(INTEL, 0x8d5e), LPC_WBG}, - { PCI_VDEVICE(INTEL, 0x8d5f), LPC_WBG}, - { PCI_VDEVICE(INTEL, 0x1f38), LPC_AVN}, - { PCI_VDEVICE(INTEL, 0x1f39), LPC_AVN}, - { PCI_VDEVICE(INTEL, 0x1f3a), LPC_AVN}, - { PCI_VDEVICE(INTEL, 0x1f3b), LPC_AVN}, - { PCI_VDEVICE(INTEL, 0x0f1c), LPC_BAYTRAIL}, - { PCI_VDEVICE(INTEL, 0x2390), LPC_COLETO}, - { PCI_VDEVICE(INTEL, 0x9cc1), LPC_WPT_LP}, - { PCI_VDEVICE(INTEL, 0x9cc2), LPC_WPT_LP}, - { PCI_VDEVICE(INTEL, 0x9cc3), LPC_WPT_LP}, - { PCI_VDEVICE(INTEL, 0x9cc5), LPC_WPT_LP}, - { PCI_VDEVICE(INTEL, 0x9cc6), LPC_WPT_LP}, - { PCI_VDEVICE(INTEL, 0x9cc7), LPC_WPT_LP}, - { PCI_VDEVICE(INTEL, 0x9cc9), LPC_WPT_LP}, - { 0, }, /* End of list */ -}; -MODULE_DEVICE_TABLE(pci, lpc_ich_ids); - -static void lpc_ich_restore_config_space(struct pci_dev *dev) -{ - struct lpc_ich_priv *priv = pci_get_drvdata(dev); - - if (priv->abase_save >= 0) { - pci_write_config_byte(dev, priv->abase, priv->abase_save); - priv->abase_save = -1; - } - - if (priv->actrl_pbase_save >= 0) { - pci_write_config_byte(dev, priv->actrl_pbase, - priv->actrl_pbase_save); - priv->actrl_pbase_save = -1; - } - - if (priv->gctrl_save >= 0) { - pci_write_config_byte(dev, priv->gctrl, priv->gctrl_save); - priv->gctrl_save = -1; - } -} - -static void lpc_ich_enable_acpi_space(struct pci_dev *dev) -{ - struct lpc_ich_priv *priv = pci_get_drvdata(dev); - u8 reg_save; - - switch (lpc_chipset_info[priv->chipset].iTCO_version) { - case 3: - /* - * Some chipsets (eg Avoton) enable the ACPI space in the - * ACPI BASE register. - */ - pci_read_config_byte(dev, priv->abase, ®_save); - pci_write_config_byte(dev, priv->abase, reg_save | 0x2); - priv->abase_save = reg_save; - break; - default: - /* - * Most chipsets enable the ACPI space in the ACPI control - * register. - */ - pci_read_config_byte(dev, priv->actrl_pbase, ®_save); - pci_write_config_byte(dev, priv->actrl_pbase, reg_save | 0x80); - priv->actrl_pbase_save = reg_save; - break; - } -} - -static void lpc_ich_enable_gpio_space(struct pci_dev *dev) -{ - struct lpc_ich_priv *priv = pci_get_drvdata(dev); - u8 reg_save; - - pci_read_config_byte(dev, priv->gctrl, ®_save); - pci_write_config_byte(dev, priv->gctrl, reg_save | 0x10); - priv->gctrl_save = reg_save; -} - -static void lpc_ich_enable_pmc_space(struct pci_dev *dev) -{ - struct lpc_ich_priv *priv = pci_get_drvdata(dev); - u8 reg_save; - - pci_read_config_byte(dev, priv->actrl_pbase, ®_save); - pci_write_config_byte(dev, priv->actrl_pbase, reg_save | 0x2); - - priv->actrl_pbase_save = reg_save; -} - -static void lpc_ich_finalize_cell(struct pci_dev *dev, struct mfd_cell *cell) -{ - struct lpc_ich_priv *priv = pci_get_drvdata(dev); - - cell->platform_data = &lpc_chipset_info[priv->chipset]; - cell->pdata_size = sizeof(struct lpc_ich_info); -} - -/* - * We don't check for resource conflict globally. There are 2 or 3 independent - * GPIO groups and it's enough to have access to one of these to instantiate - * the device. - */ -static int lpc_ich_check_conflict_gpio(struct resource *res) -{ - int ret; - u8 use_gpio = 0; - - if (resource_size(res) >= 0x50 && - !acpi_check_region(res->start + 0x40, 0x10, "LPC ICH GPIO3")) - use_gpio |= 1 << 2; - - if (!acpi_check_region(res->start + 0x30, 0x10, "LPC ICH GPIO2")) - use_gpio |= 1 << 1; - - ret = acpi_check_region(res->start + 0x00, 0x30, "LPC ICH GPIO1"); - if (!ret) - use_gpio |= 1 << 0; - - return use_gpio ? use_gpio : ret; -} - -static int lpc_ich_init_gpio(struct pci_dev *dev) -{ - struct lpc_ich_priv *priv = pci_get_drvdata(dev); - u32 base_addr_cfg; - u32 base_addr; - int ret; - bool acpi_conflict = false; - struct resource *res; - - /* Setup power management base register */ - pci_read_config_dword(dev, priv->abase, &base_addr_cfg); - base_addr = base_addr_cfg & 0x0000ff80; - if (!base_addr) { - dev_notice(&dev->dev, "I/O space for ACPI uninitialized\n"); - lpc_ich_cells[LPC_GPIO].num_resources--; - goto gpe0_done; - } - - res = &gpio_ich_res[ICH_RES_GPE0]; - res->start = base_addr + ACPIBASE_GPE_OFF; - res->end = base_addr + ACPIBASE_GPE_END; - ret = acpi_check_resource_conflict(res); - if (ret) { - /* - * This isn't fatal for the GPIO, but we have to make sure that - * the platform_device subsystem doesn't see this resource - * or it will register an invalid region. - */ - lpc_ich_cells[LPC_GPIO].num_resources--; - acpi_conflict = true; - } else { - lpc_ich_enable_acpi_space(dev); - } - -gpe0_done: - /* Setup GPIO base register */ - pci_read_config_dword(dev, priv->gbase, &base_addr_cfg); - base_addr = base_addr_cfg & 0x0000ff80; - if (!base_addr) { - dev_notice(&dev->dev, "I/O space for GPIO uninitialized\n"); - ret = -ENODEV; - goto gpio_done; - } - - /* Older devices provide fewer GPIO and have a smaller resource size. */ - res = &gpio_ich_res[ICH_RES_GPIO]; - res->start = base_addr; - switch (lpc_chipset_info[priv->chipset].gpio_version) { - case ICH_V5_GPIO: - case ICH_V10CORP_GPIO: - res->end = res->start + 128 - 1; - break; - default: - res->end = res->start + 64 - 1; - break; - } - - ret = lpc_ich_check_conflict_gpio(res); - if (ret < 0) { - /* this isn't necessarily fatal for the GPIO */ - acpi_conflict = true; - goto gpio_done; - } - lpc_chipset_info[priv->chipset].use_gpio = ret; - lpc_ich_enable_gpio_space(dev); - - lpc_ich_finalize_cell(dev, &lpc_ich_cells[LPC_GPIO]); - ret = mfd_add_devices(&dev->dev, -1, &lpc_ich_cells[LPC_GPIO], - 1, NULL, 0); - -gpio_done: - if (acpi_conflict) - pr_warn("Resource conflict(s) found affecting %s\n", - lpc_ich_cells[LPC_GPIO].name); - return ret; -} - -static int lpc_ich_init_wdt(struct pci_dev *dev) -{ - struct lpc_ich_priv *priv = pci_get_drvdata(dev); - u32 base_addr_cfg; - u32 base_addr; - int ret; - struct resource *res; - - /* Setup power management base register */ - pci_read_config_dword(dev, priv->abase, &base_addr_cfg); - base_addr = base_addr_cfg & 0x0000ff80; - if (!base_addr) { - dev_notice(&dev->dev, "I/O space for ACPI uninitialized\n"); - ret = -ENODEV; - goto wdt_done; - } - - res = wdt_io_res(ICH_RES_IO_TCO); - res->start = base_addr + ACPIBASE_TCO_OFF; - res->end = base_addr + ACPIBASE_TCO_END; - - res = wdt_io_res(ICH_RES_IO_SMI); - res->start = base_addr + ACPIBASE_SMI_OFF; - res->end = base_addr + ACPIBASE_SMI_END; - - lpc_ich_enable_acpi_space(dev); - - /* - * iTCO v2: - * Get the Memory-Mapped GCS register. To get access to it - * we have to read RCBA from PCI Config space 0xf0 and use - * it as base. GCS = RCBA + ICH6_GCS(0x3410). - * - * iTCO v3: - * Get the Power Management Configuration register. To get access - * to it we have to read the PMC BASE from config space and address - * the register at offset 0x8. - */ - if (lpc_chipset_info[priv->chipset].iTCO_version == 1) { - /* Don't register iomem for TCO ver 1 */ - lpc_ich_cells[LPC_WDT].num_resources--; - } else if (lpc_chipset_info[priv->chipset].iTCO_version == 2) { - pci_read_config_dword(dev, RCBABASE, &base_addr_cfg); - base_addr = base_addr_cfg & 0xffffc000; - if (!(base_addr_cfg & 1)) { - dev_notice(&dev->dev, "RCBA is disabled by " - "hardware/BIOS, device disabled\n"); - ret = -ENODEV; - goto wdt_done; - } - res = wdt_mem_res(ICH_RES_MEM_GCS_PMC); - res->start = base_addr + ACPIBASE_GCS_OFF; - res->end = base_addr + ACPIBASE_GCS_END; - } else if (lpc_chipset_info[priv->chipset].iTCO_version == 3) { - lpc_ich_enable_pmc_space(dev); - pci_read_config_dword(dev, ACPICTRL_PMCBASE, &base_addr_cfg); - base_addr = base_addr_cfg & 0xfffffe00; - - res = wdt_mem_res(ICH_RES_MEM_GCS_PMC); - res->start = base_addr + ACPIBASE_PMC_OFF; - res->end = base_addr + ACPIBASE_PMC_END; - } - - lpc_ich_finalize_cell(dev, &lpc_ich_cells[LPC_WDT]); - ret = mfd_add_devices(&dev->dev, -1, &lpc_ich_cells[LPC_WDT], - 1, NULL, 0); - -wdt_done: - return ret; -} - -static int lpc_ich_probe(struct pci_dev *dev, - const struct pci_device_id *id) -{ - struct lpc_ich_priv *priv; - int ret; - bool cell_added = false; - - priv = devm_kzalloc(&dev->dev, - sizeof(struct lpc_ich_priv), GFP_KERNEL); - if (!priv) - return -ENOMEM; - - priv->chipset = id->driver_data; - - priv->actrl_pbase_save = -1; - priv->abase_save = -1; - - priv->abase = ACPIBASE; - priv->actrl_pbase = ACPICTRL_PMCBASE; - - priv->gctrl_save = -1; - if (priv->chipset <= LPC_ICH5) { - priv->gbase = GPIOBASE_ICH0; - priv->gctrl = GPIOCTRL_ICH0; - } else { - priv->gbase = GPIOBASE_ICH6; - priv->gctrl = GPIOCTRL_ICH6; - } - - pci_set_drvdata(dev, priv); - - if (lpc_chipset_info[priv->chipset].iTCO_version) { - ret = lpc_ich_init_wdt(dev); - if (!ret) - cell_added = true; - } - - if (lpc_chipset_info[priv->chipset].gpio_version) { - ret = lpc_ich_init_gpio(dev); - if (!ret) - cell_added = true; - } - - /* - * We only care if at least one or none of the cells registered - * successfully. - */ - if (!cell_added) { - dev_warn(&dev->dev, "No MFD cells added\n"); - lpc_ich_restore_config_space(dev); - return -ENODEV; - } - - return 0; -} - -static void lpc_ich_remove(struct pci_dev *dev) -{ - mfd_remove_devices(&dev->dev); - lpc_ich_restore_config_space(dev); -} - -static struct pci_driver lpc_ich_driver = { - .name = "lpc_ich", - .id_table = lpc_ich_ids, - .probe = lpc_ich_probe, - .remove = lpc_ich_remove, -}; - -//module_pci_driver(lpc_ich_driver); -static int __init lpc_ich_init(void) -{ - return pci_register_driver(&lpc_ich_driver); -} - -static void __exit lpc_ich_exit(void) -{ - pci_unregister_driver(&lpc_ich_driver); -} - -module_init(lpc_ich_init); -module_exit(lpc_ich_exit); - -MODULE_AUTHOR("Aaron Sierra "); -MODULE_DESCRIPTION("LPC interface for Intel ICH"); -MODULE_LICENSE("GPL"); diff --git a/packages/platforms/inventec/x86-64/d6254qs/modules/builds/src/lpc_ich.h b/packages/platforms/inventec/x86-64/d6254qs/modules/builds/src/lpc_ich.h deleted file mode 100644 index 8feac782f..000000000 --- a/packages/platforms/inventec/x86-64/d6254qs/modules/builds/src/lpc_ich.h +++ /dev/null @@ -1,52 +0,0 @@ -/* - * linux/drivers/mfd/lpc_ich.h - * - * Copyright (c) 2012 Extreme Engineering Solution, Inc. - * Author: Aaron Sierra - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License 2 as published - * by the Free Software Foundation. - * - * 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; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - */ -#ifndef LPC_ICH_H -#define LPC_ICH_H - -/* Watchdog resources */ -#define ICH_RES_IO_TCO 0 -#define ICH_RES_IO_SMI 1 -#define ICH_RES_MEM_OFF 2 -#define ICH_RES_MEM_GCS_PMC 0 - -/* GPIO resources */ -#define ICH_RES_GPIO 0 -#define ICH_RES_GPE0 1 - -/* GPIO compatibility */ -enum { - ICH_I3100_GPIO, - ICH_V5_GPIO, - ICH_V6_GPIO, - ICH_V7_GPIO, - ICH_V9_GPIO, - ICH_V10CORP_GPIO, - ICH_V10CONS_GPIO, - AVOTON_GPIO, -}; - -struct lpc_ich_info { - char name[32]; - unsigned int iTCO_version; - unsigned int gpio_version; - u8 use_gpio; -}; - -#endif diff --git a/packages/platforms/inventec/x86-64/d6254qs/modules/builds/src/onie_tlvinfo.c b/packages/platforms/inventec/x86-64/d6254qs/modules/builds/src/onie_tlvinfo.c deleted file mode 100644 index 8138d7918..000000000 --- a/packages/platforms/inventec/x86-64/d6254qs/modules/builds/src/onie_tlvinfo.c +++ /dev/null @@ -1,815 +0,0 @@ -#include -#include -#include -#include -//#include -#include - -//#include -//#include -#include "onie_tlvinfo.h" - -/* Set to 1 if we've read EEPROM into memory */ -static int has_been_read = 0; - -int read_sys_eeprom(struct i2c_client *pi2c_client,void *eeprom_data, int offset, int len); -int write_sys_eeprom(struct i2c_client *pi2c_client, void *eeprom_data, int len); - -static inline int is_multicast_ether_addr(const u_int8_t *addr) -{ - return 0x01 & addr[0]; -} - -static inline int is_zero_ether_addr(const u_int8_t *addr) -{ - return !(addr[0] | addr[1] | addr[2] | addr[3] | addr[4] | addr[5]); -} - -static inline int is_valid_ether_addr(const u_int8_t *addr) -{ - return !is_multicast_ether_addr(addr) && !is_zero_ether_addr(addr); -} - -#if 0 -static unsigned int crc32(unsigned char const *p, unsigned int len) -{ - int i; - unsigned int crc = 0; - while (len--) { - crc ^= *p++; - for (i = 0; i < 8; i++) - crc = (crc >> 1) ^ ((crc & 1) ? 0xedb88320 : 0); - } - return crc; -} -#else -static unsigned long crc32_tab[] = { - 0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f, - 0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988, - 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91, 0x1db71064, 0x6ab020f2, - 0xf3b97148, 0x84be41de, 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7, - 0x136c9856, 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, 0x14015c4f, 0x63066cd9, - 0xfa0f3d63, 0x8d080df5, 0x3b6e20c8, 0x4c69105e, 0xd56041e4, 0xa2677172, - 0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b, 0x35b5a8fa, 0x42b2986c, - 0xdbbbc9d6, 0xacbcf940, 0x32d86ce3, 0x45df5c75, 0xdcd60dcf, 0xabd13d59, - 0x26d930ac, 0x51de003a, 0xc8d75180, 0xbfd06116, 0x21b4f4b5, 0x56b3c423, - 0xcfba9599, 0xb8bda50f, 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924, - 0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d, 0x76dc4190, 0x01db7106, - 0x98d220bc, 0xefd5102a, 0x71b18589, 0x06b6b51f, 0x9fbfe4a5, 0xe8b8d433, - 0x7807c9a2, 0x0f00f934, 0x9609a88e, 0xe10e9818, 0x7f6a0dbb, 0x086d3d2d, - 0x91646c97, 0xe6635c01, 0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e, - 0x6c0695ed, 0x1b01a57b, 0x8208f4c1, 0xf50fc457, 0x65b0d9c6, 0x12b7e950, - 0x8bbeb8ea, 0xfcb9887c, 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, 0xfbd44c65, - 0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2, 0x4adfa541, 0x3dd895d7, - 0xa4d1c46d, 0xd3d6f4fb, 0x4369e96a, 0x346ed9fc, 0xad678846, 0xda60b8d0, - 0x44042d73, 0x33031de5, 0xaa0a4c5f, 0xdd0d7cc9, 0x5005713c, 0x270241aa, - 0xbe0b1010, 0xc90c2086, 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f, - 0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, 0x59b33d17, 0x2eb40d81, - 0xb7bd5c3b, 0xc0ba6cad, 0xedb88320, 0x9abfb3b6, 0x03b6e20c, 0x74b1d29a, - 0xead54739, 0x9dd277af, 0x04db2615, 0x73dc1683, 0xe3630b12, 0x94643b84, - 0x0d6d6a3e, 0x7a6a5aa8, 0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1, - 0xf00f9344, 0x8708a3d2, 0x1e01f268, 0x6906c2fe, 0xf762575d, 0x806567cb, - 0x196c3671, 0x6e6b06e7, 0xfed41b76, 0x89d32be0, 0x10da7a5a, 0x67dd4acc, - 0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5, 0xd6d6a3e8, 0xa1d1937e, - 0x38d8c2c4, 0x4fdff252, 0xd1bb67f1, 0xa6bc5767, 0x3fb506dd, 0x48b2364b, - 0xd80d2bda, 0xaf0a1b4c, 0x36034af6, 0x41047a60, 0xdf60efc3, 0xa867df55, - 0x316e8eef, 0x4669be79, 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236, - 0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f, 0xc5ba3bbe, 0xb2bd0b28, - 0x2bb45a92, 0x5cb36a04, 0xc2d7ffa7, 0xb5d0cf31, 0x2cd99e8b, 0x5bdeae1d, - 0x9b64c2b0, 0xec63f226, 0x756aa39c, 0x026d930a, 0x9c0906a9, 0xeb0e363f, - 0x72076785, 0x05005713, 0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38, - 0x92d28e9b, 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21, 0x86d3d2d4, 0xf1d4e242, - 0x68ddb3f8, 0x1fda836e, 0x81be16cd, 0xf6b9265b, 0x6fb077e1, 0x18b74777, - 0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c, 0x8f659eff, 0xf862ae69, - 0x616bffd3, 0x166ccf45, 0xa00ae278, 0xd70dd2ee, 0x4e048354, 0x3903b3c2, - 0xa7672661, 0xd06016f7, 0x4969474d, 0x3e6e77db, 0xaed16a4a, 0xd9d65adc, - 0x40df0b66, 0x37d83bf0, 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9, - 0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605, 0xcdd70693, - 0x54de5729, 0x23d967bf, 0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94, - 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d -}; - -static unsigned long crc32(unsigned char const *buf, unsigned int size) -{ - unsigned char *p = buf; - unsigned long crc = 0; - - crc = crc ^ ~0U; - - while (size--) - crc = crc32_tab[(crc ^ *p++) & 0xFF] ^ (crc >> 8); - - return crc ^ ~0U; -} -#endif - -static int set_bytes(char *buf, const char *string, int * converted_accum) -{ - char *p = (char *) string; - int i; - uint byte; - - if (!p) { - printk("ERROR: NULL string passed in.\n"); - return -1; - } - /* Convert string to bytes */ - for (i = 0, p = (char *)string; (i < TLV_VALUE_MAX_LEN) && (*p != 0); - i++) { - while ((*p == ' ') || (*p == '\t') || (*p == ',') || - (*p == ';')) { - p++; - } - if (*p != 0) { - if (!isdigit(*p)) { - printk("ERROR: Non-digit found in byte string: (%s)\n", string); - return -1; - } - byte = strtoul(p, &p, 0); - if (byte >= 256) { - printk("ERROR: The value specified is greater than 255: (%u) " \ - "in string: %s\n", byte, string); - return -1; - } - buf[i] = byte & 0xFF; - } - } - if ((i == TLV_VALUE_MAX_LEN) && (*p != 0)) { - printk("ERROR: Trying to assign too many bytes " - "(max: %d) in string: %s\n", TLV_VALUE_MAX_LEN, string); - return -1; - } - *converted_accum = i; - return 0; -} - -/* - * set_date - * - * Validates the format of the data string - * - * This function takes a pointer to a date string (i.e. MM/DD/YYYY hh:mm:ss) - * and validates that the format is correct. If so the string is copied - * to the supplied buffer. - */ -static int set_date(char *buf, const char *string) -{ - int i; - - if (!string) { - printk("ERROR: NULL date string passed in.\n"); - return -1; - } - if (strlen(string) != 19) { - printk("ERROR: Date strlen() != 19 -- %d\n", strlen(string)); - printk("ERROR: Bad date format (MM/DD/YYYY hh:mm:ss): %s\n", string); - return -1; - } - for (i = 0; string[i] != 0; i++) { - switch (i) { - case 2: - case 5: - if (string[i] != '/') { - printk("ERROR: Bad date format (MM/DD/YYYY hh:mm:ss): %s\n", - string); - return -1; - } - break; - case 10: - if (string[i] != ' ') { - printk("ERROR: Bad date format (MM/DD/YYYY hh:mm:ss): %s\n", - string); - return -1; - } - break; - case 13: - case 16: - if (string[i] != ':') { - printk("ERROR: Bad date format (MM/DD/YYYY hh:mm:ss): %s\n", - string); - return -1; - } - break; - default: - if (!isdigit(string[i])) { - printk("ERROR: Bad date format (MM/DD/YYYY hh:mm:ss): %s\n", - string); - return -1; - } - break; - } - } - strcpy(buf, string); - return 0; -} - -/* - * is_valid_tlv - * - * Perform basic sanity checks on a TLV field. The TLV is pointed to - * by the parameter provided. - * 1. The type code is not reserved (0x00 or 0xFF) - */ -static inline bool is_valid_tlv(tlvinfo_tlv_t *tlv) -{ - return((tlv->type != 0x00) && (tlv->type != 0xFF)); -} - -/* - * set_mac - * - * Converts a string MAC address into a binary buffer. - * - * This function takes a pointer to a MAC address string - * (i.e."XX:XX:XX:XX:XX:XX", where "XX" is a two-digit hex number). - * The string format is verified and then converted to binary and - * stored in a buffer. - */ -static int set_mac(char *buf, const char *string) -{ - char *p = (char *) string; - int i; - int err = 0; - char *end; - - if (!p) { - printk("ERROR: NULL mac addr string passed in.\n"); - return -1; - } - if (strlen(p) != 17) { - printk("ERROR: MAC address strlen() != 17 -- %d\n", strlen(p)); - printk("ERROR: Bad MAC address format: %s\n", string); - return -1; - } - for (i = 0; i < 17; i++) { - if ((i % 3) == 2) { - if (p[i] != ':') { - err++; - printk("ERROR: mac: p[%i] != :, found: `%c'\n", - i, p[i]); - break; - } - continue; - } else if (!isxdigit(p[i])) { - err++; - printk("ERROR: mac: p[%i] != hex digit, found: `%c'\n", - i, p[i]); - break; - } - } - if (err != 0) { - printk("ERROR: Bad MAC address format: %s\n", string); - return -1; - } - /* Convert string to binary */ - for (i = 0, p = (char *)string; i < 6; i++) { - buf[i] = p ? strtoul(p, &end, 16) : 0; - if (p) { - p = (*end) ? end + 1 : end; - } - } - if (!is_valid_ether_addr((char *)buf)) { - printk("ERROR: MAC address must not be 00:00:00:00:00:00, " - "a multicast address or FF:FF:FF:FF:FF:FF.\n"); - printk("ERROR: Bad MAC address format: %s\n", string); - return -1; - } - return 0; -} - -/* - * is_valid_tlvinfo_header - * - * Perform sanity checks on the first 11 bytes of the TlvInfo EEPROM - * data pointed to by the parameter: - * 1. First 8 bytes contain null-terminated ASCII string "TlvInfo" - * 2. Version byte is 1 - * 3. Total length bytes contain value which is less than or equal - * to the allowed maximum (2048-11) - * - */ -static inline bool is_valid_tlvinfo_header(tlvinfo_header_t *hdr) -{ - int max_size = TLV_TOTAL_LEN_MAX; - return((strcmp(hdr->signature, TLV_INFO_ID_STRING) == 0) && - (hdr->version == TLV_INFO_VERSION) && - (be16_to_cpu(hdr->totallen) <= max_size) ); -} - -/* - * decode_tlv_value - * - * Decode a single TLV value into a string. - - * The validity of EEPROM contents and the TLV field have been verified - * prior to calling this function. - */ -#define DECODE_NAME_MAX 20 - -static void decode_tlv_value(tlvinfo_tlv_t * tlv, char* value) -{ - int i; - - switch (tlv->type) { - case TLV_CODE_PRODUCT_NAME: - case TLV_CODE_PART_NUMBER: - case TLV_CODE_SERIAL_NUMBER: - case TLV_CODE_MANUF_DATE: - case TLV_CODE_LABEL_REVISION: - case TLV_CODE_PLATFORM_NAME: - case TLV_CODE_ONIE_VERSION: - case TLV_CODE_MANUF_NAME: - case TLV_CODE_MANUF_COUNTRY: - case TLV_CODE_VENDOR_NAME: - case TLV_CODE_DIAG_VERSION: - case TLV_CODE_SERVICE_TAG: - memcpy(value, tlv->value, tlv->length); - value[tlv->length] = 0; - break; - case TLV_CODE_MAC_BASE: - snprintf(value, MAX_STRING_SIZE, "%02X:%02X:%02X:%02X:%02X:%02X", - tlv->value[0], tlv->value[1], tlv->value[2], - tlv->value[3], tlv->value[4], tlv->value[5]); - break; - case TLV_CODE_DEVICE_VERSION: - snprintf(value, MAX_STRING_SIZE, "%u", tlv->value[0]); - break; - case TLV_CODE_MAC_SIZE: - snprintf(value, MAX_STRING_SIZE, "%u", (tlv->value[0] << 8) | tlv->value[1]); - break; - case TLV_CODE_VENDOR_EXT: - value[0] = 0; - for (i = 0; (i < (TLV_DECODE_VALUE_MAX_LEN/5)) && (i < tlv->length); - i++) { - snprintf(value, MAX_STRING_SIZE, "%s 0x%02X", value, tlv->value[i]); - } - break; - case TLV_CODE_CRC_32: - snprintf(value, MAX_STRING_SIZE, "0x%02X%02X%02X%02X", - tlv->value[0], tlv->value[1], tlv->value[2], - tlv->value[3]); - break; - default: - value[0] = 0; - for (i = 0; (i < (TLV_DECODE_VALUE_MAX_LEN/5)) && (i < tlv->length); - i++) { - snprintf(value, MAX_STRING_SIZE, "%s 0x%02X", value, tlv->value[i]); - } - break; - } - -} - -/* - * is_checksum_valid - * - * Validate the checksum in the provided TlvInfo EEPROM data. First, - * verify that the TlvInfo header is valid, then make sure the last - * TLV is a CRC-32 TLV. Then calculate the CRC over the EEPROM data - * and compare it to the value stored in the EEPROM CRC-32 TLV. - */ -static bool is_checksum_valid(u_int8_t *eeprom) -{ - tlvinfo_header_t * eeprom_hdr = (tlvinfo_header_t *) eeprom; - tlvinfo_tlv_t * eeprom_crc; - unsigned int calc_crc; - unsigned int stored_crc; - - // Is the eeprom header valid? - if (!is_valid_tlvinfo_header(eeprom_hdr)) { - return(FALSE); - } - - // Is the last TLV a CRC? - eeprom_crc = (tlvinfo_tlv_t *) &eeprom[sizeof(tlvinfo_header_t) + - be16_to_cpu(eeprom_hdr->totallen) - - (sizeof(tlvinfo_tlv_t) + 4)]; - if ((eeprom_crc->type != TLV_CODE_CRC_32) || (eeprom_crc->length != 4)) { - return(FALSE); - } - - // Calculate the checksum - calc_crc = crc32((void *)eeprom, sizeof(tlvinfo_header_t) + - be16_to_cpu(eeprom_hdr->totallen) - 4); - stored_crc = ((eeprom_crc->value[0] << 24) | (eeprom_crc->value[1] << 16) | - (eeprom_crc->value[2] << 8) | eeprom_crc->value[3]); - - //printk(KERN_ERR "[SWPS] cal_crc =0x%x, stored_crc =0x%x\n", calc_crc, stored_crc); - //return(calc_crc == stored_crc); - return 1; -} - -/* - * update_crc - * - * This function updates the CRC-32 TLV. If there is no CRC-32 TLV, then - * one is added. This function should be called after each update to the - * EEPROM structure, to make sure the CRC is always correct. - */ -static void update_crc(u_int8_t *eeprom) -{ - tlvinfo_header_t * eeprom_hdr = (tlvinfo_header_t *) eeprom; - tlvinfo_tlv_t * eeprom_crc; - unsigned int calc_crc; - - // Is the eeprom header valid? - if (!is_valid_tlvinfo_header(eeprom_hdr)) { - return; - } - // Is the last TLV a CRC? - eeprom_crc = (tlvinfo_tlv_t *) &eeprom[sizeof(tlvinfo_header_t) + - be16_to_cpu(eeprom_hdr->totallen) - - (sizeof(tlvinfo_tlv_t) + 4)]; - if (eeprom_crc->type != TLV_CODE_CRC_32) { - if ((be16_to_cpu(eeprom_hdr->totallen) + sizeof(tlvinfo_tlv_t) + 4) > - TLV_TOTAL_LEN_MAX) { - return; - } - eeprom_crc = (tlvinfo_tlv_t *) &eeprom[sizeof(tlvinfo_header_t) + - be16_to_cpu( - eeprom_hdr->totallen)]; - eeprom_hdr->totallen = cpu_to_be16(be16_to_cpu(eeprom_hdr->totallen) + - sizeof(tlvinfo_tlv_t) + 4); - eeprom_crc->type = TLV_CODE_CRC_32; - } - eeprom_crc->length = 4; - - // Calculate the checksum - calc_crc = crc32((void *)eeprom, - sizeof(tlvinfo_header_t) + - be16_to_cpu(eeprom_hdr->totallen) - 4); - - eeprom_crc->value[0] = (calc_crc >> 24) & 0xFF; - eeprom_crc->value[1] = (calc_crc >> 16) & 0xFF; - eeprom_crc->value[2] = (calc_crc >> 8) & 0xFF; - eeprom_crc->value[3] = (calc_crc >> 0) & 0xFF; -} - -/* - * show_eeprom - * - * Display the contents of the EEPROM - */ - -/* - * read_eeprom - * - * Read the EEPROM into memory, if it hasn't already been read. - */ -int read_eeprom( struct i2c_client *pi2c_client, u_int8_t *eeprom) -{ - int ret; - tlvinfo_header_t *eeprom_hdr = (tlvinfo_header_t *) eeprom; - tlvinfo_tlv_t *eeprom_tlv = (tlvinfo_tlv_t *)&eeprom[ - sizeof(tlvinfo_header_t)]; - - if (has_been_read) - return 0; - - /* Read the header */ - ret = read_sys_eeprom( pi2c_client,(void *)eeprom_hdr, 0, sizeof(tlvinfo_header_t)); - /* If the header was successfully read, read the TLVs */ - if ((ret == 0) && is_valid_tlvinfo_header(eeprom_hdr)) { - ret = read_sys_eeprom( pi2c_client, (void *)eeprom_tlv, sizeof(tlvinfo_header_t), - be16_to_cpu(eeprom_hdr->totallen)); - } - // If the contents are invalid, start over with default contents - if(!is_valid_tlvinfo_header(eeprom_hdr)) - printk(KERN_ERR - "Notice: Invalid TLV header found. Using default contents--1.\n"); - if(!is_checksum_valid(eeprom)) - printk(KERN_ERR - "Notice: Invalid TLV checksum found. Using default contents--2.\n"); - if ( !is_valid_tlvinfo_header(eeprom_hdr) || !is_checksum_valid(eeprom) ){ - strcpy(eeprom_hdr->signature, TLV_INFO_ID_STRING); - eeprom_hdr->version = TLV_INFO_VERSION; - eeprom_hdr->totallen = cpu_to_be16(0); - update_crc(eeprom); - } - has_been_read = 1; - - return ret; -} - -/* - * prog_eeprom - * Write the EEPROM data from CPU memory to the hardware. - */ -int prog_eeprom(struct i2c_client *pi2c_client, u_int8_t * eeprom) -{ - int ret = 0; - tlvinfo_header_t * eeprom_hdr = (tlvinfo_header_t *) eeprom; - int eeprom_len; - - eeprom_len = sizeof(tlvinfo_header_t) + be16_to_cpu(eeprom_hdr->totallen); - ret = write_sys_eeprom( pi2c_client, eeprom, eeprom_len); - if (ret) { - printk("Programming failed.\n"); - return -1; - } - has_been_read = 0; - return 0; -} - -/* - * tlvinfo_find_tlv - * - * This function finds the TLV with the supplied code in the EERPOM. - * An offset from the beginning of the EEPROM is returned in the - * eeprom_index parameter if the TLV is found. - */ -bool tlvinfo_find_tlv(u_int8_t *eeprom, u_int8_t tcode, - int *eeprom_index) -{ - tlvinfo_header_t * eeprom_hdr = (tlvinfo_header_t *) eeprom; - tlvinfo_tlv_t * eeprom_tlv; - int eeprom_end; - - // Make sure the EEPROM contents are valid - if (!is_valid_tlvinfo_header(eeprom_hdr) || !is_checksum_valid(eeprom)) { - return(FALSE); - } - // Search through the TLVs, looking for the first one which matches the - // supplied type code. - *eeprom_index = sizeof(tlvinfo_header_t); - eeprom_end = sizeof(tlvinfo_header_t) + be16_to_cpu(eeprom_hdr->totallen); - - while (*eeprom_index < eeprom_end) { - eeprom_tlv = (tlvinfo_tlv_t *) &eeprom[*eeprom_index]; - if (!is_valid_tlv(eeprom_tlv)) { - return(FALSE); - } - if (eeprom_tlv->type == tcode) { - return(TRUE); - } - *eeprom_index += sizeof(tlvinfo_tlv_t) + eeprom_tlv->length; - } - return(FALSE); -} - -/* - * tlvinfo_decode_tlv - * - * This function finds the TLV with the supplied code in the EERPOM - * and decodes the value into the buffer provided. - */ -bool tlvinfo_decode_tlv(u_int8_t *eeprom, u_int8_t tcode, char* value) -{ - int eeprom_index; - tlvinfo_tlv_t * eeprom_tlv; - - // Find the TLV and then decode it - - if (tlvinfo_find_tlv(eeprom, tcode, &eeprom_index)) { - eeprom_tlv = (tlvinfo_tlv_t *) &eeprom[eeprom_index]; - decode_tlv_value(eeprom_tlv, value); - return TRUE; - } - - return FALSE; -} - -/* - * tlvinfo_delete_tlv - * - * This function deletes the TLV with the specified type code from the - * EEPROM. - */ -bool tlvinfo_delete_tlv(u_int8_t * eeprom, u_int8_t code) -{ - int eeprom_index; - int tlength; - tlvinfo_header_t * eeprom_hdr = (tlvinfo_header_t *) eeprom; - tlvinfo_tlv_t * eeprom_tlv; - - // Find the TLV and then move all following TLVs "forward" - if (tlvinfo_find_tlv(eeprom, code, &eeprom_index)) { - eeprom_tlv = (tlvinfo_tlv_t *) &eeprom[eeprom_index]; - tlength = sizeof(tlvinfo_tlv_t) + eeprom_tlv->length; - memcpy(&eeprom[eeprom_index], &eeprom[eeprom_index+tlength], - sizeof(tlvinfo_header_t) + be16_to_cpu(eeprom_hdr->totallen) - - eeprom_index - tlength); - eeprom_hdr->totallen = cpu_to_be16(be16_to_cpu(eeprom_hdr->totallen) - - tlength); - update_crc(eeprom); - return(TRUE); - } - return(FALSE); -} - -/* - * tlvinfo_add_tlv - * - * This function adds a TLV to the EEPROM, converting the value (a string) to - * the format in which it will be stored in the EEPROM. - */ -#define MAX_TLV_VALUE_LEN 256 -bool tlvinfo_add_tlv(u_int8_t * eeprom, int tcode, char * strval) -{ - tlvinfo_header_t * eeprom_hdr = (tlvinfo_header_t *) eeprom; - tlvinfo_tlv_t * eeprom_tlv; - int new_tlv_len = 0; - u_int32_t value; - char data[MAX_TLV_VALUE_LEN]; - int eeprom_index; - int max_size = TLV_TOTAL_LEN_MAX; - - // Encode each TLV type into the format to be stored in the EERPOM - switch (tcode) { - case TLV_CODE_PRODUCT_NAME: - case TLV_CODE_PART_NUMBER: - case TLV_CODE_SERIAL_NUMBER: - case TLV_CODE_LABEL_REVISION: - case TLV_CODE_PLATFORM_NAME: - case TLV_CODE_ONIE_VERSION: - case TLV_CODE_MANUF_NAME: - case TLV_CODE_MANUF_COUNTRY: - case TLV_CODE_VENDOR_NAME: - case TLV_CODE_DIAG_VERSION: - case TLV_CODE_SERVICE_TAG: - strncpy(data, strval, MAX_TLV_VALUE_LEN); - - if( strlen(strval) >= MAX_TLV_VALUE_LEN ) - new_tlv_len = MAX_TLV_VALUE_LEN; - else - new_tlv_len = strlen(strval); - - break; - case TLV_CODE_DEVICE_VERSION: - value = strtoul(strval, NULL, 0); - if (value >= 256) { - printk("ERROR: Device version must be 255 or less. Value " \ - "supplied: %u", value); - return(FALSE); - } - data[0] = value & 0xFF; - new_tlv_len = 1; - break; - case TLV_CODE_MAC_SIZE: - value = strtoul(strval, NULL, 0); - if (value >= 65536) { - printk("ERROR: MAC Size must be 65535 or less. Value " \ - "supplied: %u", value); - return(FALSE); - } - data[0] = (value >> 8) & 0xFF; - data[1] = value & 0xFF; - new_tlv_len = 2; - break; - case TLV_CODE_MANUF_DATE: - if (set_date(data, strval) != 0) { - return(FALSE); - } - new_tlv_len = 19; - break; - case TLV_CODE_MAC_BASE: - if (set_mac(data, strval) != 0) { - return(FALSE); - } - new_tlv_len = 6; - break; - case TLV_CODE_CRC_32: - printk("WARNING: The CRC TLV is set automatically and cannot be set " \ - "manually.\n"); - return(FALSE); - case TLV_CODE_VENDOR_EXT: - default: - if (set_bytes(data, strval, &new_tlv_len) != 0 ) { - return(FALSE); - } - break; - } - - // Is there room for this TLV? - if ((be16_to_cpu(eeprom_hdr->totallen) + sizeof(tlvinfo_tlv_t) + - new_tlv_len) > max_size) { - printk("ERROR: There is not enough room in the EERPOM to save data.\n"); - return(FALSE); - } - - // Add TLV at the end, overwriting CRC TLV if it exists - if (tlvinfo_find_tlv(eeprom, TLV_CODE_CRC_32, &eeprom_index)) { - eeprom_hdr->totallen = cpu_to_be16(be16_to_cpu(eeprom_hdr->totallen) - - sizeof(tlvinfo_tlv_t) - 4); - } else { - eeprom_index = sizeof(tlvinfo_header_t) + - be16_to_cpu(eeprom_hdr->totallen); - } - eeprom_tlv = (tlvinfo_tlv_t *) &eeprom[eeprom_index]; - eeprom_tlv->type = tcode; - eeprom_tlv->length = new_tlv_len; - memcpy(eeprom_tlv->value, data, new_tlv_len); - - // Update the total length and calculate (add) a new CRC-32 TLV - eeprom_hdr->totallen = cpu_to_be16(be16_to_cpu(eeprom_hdr->totallen) + - sizeof(tlvinfo_tlv_t) + new_tlv_len); - update_crc(eeprom); - - return(TRUE); -} - -/* - * read_sys_eeprom - read the hwinfo from i2c EEPROM - */ -int read_sys_eeprom(struct i2c_client *pi2c_client,void *eeprom_data, int offset, int len) -{ - int iRet = 0; - int i = 0; - unsigned char ucBuf[2]; - u_int8_t *c; - unsigned short usAddr = SYS_EEPROM_OFFSET + offset; - - c = eeprom_data; - for (i = 0; i < len; i++) { - ucBuf[0] = (usAddr & 0xFF00) >> 8; - ucBuf[1] = (usAddr & 0x00FF); - - iRet = i2c_smbus_write_byte_data(pi2c_client, ucBuf[0], ucBuf[1]); - if( iRet < 0 ){ - printk(KERN_ERR"Error!! VPD data read error\n"); - return -1; - } - - *c = i2c_smbus_read_byte(pi2c_client); - c++; usAddr++; - } - return 0; -} - -/* - * write_sys_eeprom - write the hwinfo to i2c EEPROM - */ -int write_sys_eeprom(struct i2c_client *pi2c_client, void *eeprom_data, int len) -{ - int iRet = 0; - int i = 0; - u_int8_t *c; - unsigned short usAddr = SYS_EEPROM_OFFSET; - unsigned char ucBuf[3]; - - c = eeprom_data; - for (i = 0; i < len; i++) { - ucBuf[ 0 ] = (usAddr & 0xFF00) >>8 ; - ucBuf[ 1 ] = (usAddr & 0x00FF); - ucBuf[ 2 ] = *c; - - iRet = i2c_smbus_write_word_data( pi2c_client, ucBuf[0], (ucBuf[2] << 8 | ucBuf[1])); - if (iRet < 0 ){ - printk(KERN_ERR"Error!! VPD data write error . \n"); - return -1; - } - - c++; usAddr++; - msleep_interruptible(10); - } - - return 0; -} - -void update_eeprom_header(u_int8_t *eeprom) -{ - tlvinfo_header_t * eeprom_hdr = (tlvinfo_header_t *) eeprom; - - strcpy(eeprom_hdr->signature, TLV_INFO_ID_STRING); - eeprom_hdr->version = TLV_INFO_VERSION; - eeprom_hdr->totallen = cpu_to_be16(0); - update_crc(eeprom); -} -#if 0 -int find_vpd_data(u_int8_t *eeprom, int i_offset, char *c_buf) -{ - int tlv_end; - int curr_tlv; - tlvinfo_header_t * eeprom_hdr = (tlvinfo_header_t *) eeprom; - tlvinfo_tlv_t * eeprom_tlv; - int iFind = 0; - - if( !is_valid_tlvinfo_header(eeprom_hdr) ) { - printk(KERN_ERR"EEPROM does not contain data in a valid TlvInfo format.\n"); - return -1; - } - - curr_tlv = sizeof(tlvinfo_header_t); - tlv_end = sizeof(tlvinfo_header_t) + be16_to_cpu(eeprom_hdr->totallen); - while(curr_tlv < tlv_end){ - eeprom_tlv = (tlvinfo_tlv_t *) &eeprom[curr_tlv]; - if (!is_valid_tlv(eeprom_tlv)) { - printk(KERN_ERR"Invalid TLV field starting at EEPROM offset %d\n", - curr_tlv); - return -1; - } - - decode_tlv_value(eeprom_tlv, c_buf); - if( eeprom_tlv->type == i_offset){ - iFind = 1; - break; - } - curr_tlv += sizeof(tlvinfo_tlv_t) + eeprom_tlv->length; - } - - if( iFind == 0 ) - return -1; - else - return 0; -} -#endif diff --git a/packages/platforms/inventec/x86-64/d6254qs/modules/builds/src/onie_tlvinfo.h b/packages/platforms/inventec/x86-64/d6254qs/modules/builds/src/onie_tlvinfo.h deleted file mode 100644 index 7311ca032..000000000 --- a/packages/platforms/inventec/x86-64/d6254qs/modules/builds/src/onie_tlvinfo.h +++ /dev/null @@ -1,151 +0,0 @@ -/* - * The Definition of the TlvInfo EEPROM format can be found at onie.org or - * github.com/onie - */ -#include -#define strtoul simple_strtoul - -#define FALSE 0 -#define TRUE (!FALSE) -#define MAX_STRING_SIZE 128 -/* - * Tlvinf header: Layout of the header for the TlvInfo format - * - * See the end of this file for details of this eeprom format - */ -struct __attribute__ ((__packed__)) tlvinfo_header_s { - char signature[8]; /* 0x00 - 0x07 EEPROM Tag "TlvInfo" */ - u_int8_t version; /* 0x08 Structure version */ - u_int16_t totallen; /* 0x09 - 0x0A Length of all data which follows */ -}; -typedef struct tlvinfo_header_s tlvinfo_header_t; - -// Header Field Constants -#define TLV_INFO_ID_STRING "TlvInfo" -#define TLV_INFO_VERSION 0x01 -#define TLV_TOTAL_LEN_MAX (SYS_EEPROM_SIZE - sizeof(tlvinfo_header_t)) - -/* - * TlvInfo TLV: Layout of a TLV field - */ -struct __attribute__ ((__packed__)) tlvinfo_tlv_s { - u_int8_t type; - u_int8_t length; - u_int8_t value[0]; -}; -typedef struct tlvinfo_tlv_s tlvinfo_tlv_t; - -/* Maximum length of a TLV value in bytes */ -#define TLV_VALUE_MAX_LEN 255 - -/** - * The TLV Types. - * - * Keep these in sync with tlv_code_list in cmd_sys_eeprom.c - */ -#define TLV_CODE_PRODUCT_NAME 0x21 -#define TLV_CODE_PART_NUMBER 0x22 -#define TLV_CODE_SERIAL_NUMBER 0x23 -#define TLV_CODE_MAC_BASE 0x24 -#define TLV_CODE_MANUF_DATE 0x25 -#define TLV_CODE_DEVICE_VERSION 0x26 -#define TLV_CODE_LABEL_REVISION 0x27 -#define TLV_CODE_PLATFORM_NAME 0x28 -#define TLV_CODE_ONIE_VERSION 0x29 -#define TLV_CODE_MAC_SIZE 0x2A -#define TLV_CODE_MANUF_NAME 0x2B -#define TLV_CODE_MANUF_COUNTRY 0x2C -#define TLV_CODE_VENDOR_NAME 0x2D -#define TLV_CODE_DIAG_VERSION 0x2E -#define TLV_CODE_SERVICE_TAG 0x2F -#define TLV_CODE_VENDOR_EXT 0xFD -#define TLV_CODE_CRC_32 0xFE - -/* - * Struct for displaying the TLV codes and names. - */ -struct tlv_code_desc { - u_int8_t m_code; - char* m_name; -}; - -/* - * List of TLV codes and names. - */ -static const struct tlv_code_desc tlv_code_list[] = { - { TLV_CODE_PRODUCT_NAME , "Product Name"}, - { TLV_CODE_PART_NUMBER , "Part Number"}, - { TLV_CODE_SERIAL_NUMBER , "Serial Number"}, - { TLV_CODE_MAC_BASE , "Base MAC Address"}, - { TLV_CODE_MANUF_DATE , "Manufacture Date"}, - { TLV_CODE_DEVICE_VERSION , "Device Version"}, - { TLV_CODE_LABEL_REVISION , "Label Revision"}, - { TLV_CODE_PLATFORM_NAME , "Platform Name"}, - { TLV_CODE_ONIE_VERSION , "Loader Version"}, - { TLV_CODE_MAC_SIZE , "MAC Addresses"}, - { TLV_CODE_MANUF_NAME , "Manufacturer"}, - { TLV_CODE_MANUF_COUNTRY , "Country Code"}, - { TLV_CODE_VENDOR_NAME , "Vendor Name"}, - { TLV_CODE_DIAG_VERSION , "Diag Version"}, - { TLV_CODE_SERVICE_TAG , "Service Tag"}, - { TLV_CODE_VENDOR_EXT , "Vendor Extension"}, - { TLV_CODE_CRC_32 , "CRC-32"}, -}; - -static inline const char* tlv_type2name(u_int8_t type) -{ - char* name = "Unknown"; - int i; - - for (i = 0; i < sizeof(tlv_code_list)/sizeof(tlv_code_list[0]); i++) { - if (tlv_code_list[i].m_code == type) { - name = tlv_code_list[i].m_name; - break; - } - } - return name; -} - -/* - * The max decode value is currently for the 'raw' type or the 'vendor - * extension' type, both of which have the same decode format. The - * max decode string size is computed as follows: - * - * strlen(" 0xFF") * TLV_VALUE_MAX_LEN + 1 - * - */ -#define TLV_DECODE_VALUE_MAX_LEN ((5 * TLV_VALUE_MAX_LEN) + 1) - - -/* - * Each platform must define the following platform-specific macros - * in sys_eeprom_platform.h: - * SYS_EEPROM_SIZE: size of usable eeprom - * SYS_EEPROM_I2C_DEVICE: i2c-bus - * SYS_EEPROM_I2C_ADDR: address on the bus - * The following may also be defined in sys_eeprom_platform.h, else - * the defaults with take over: - * SYS_EEPROM_MAX_SIZE: Total size of the eeprom - * SYS_EEPROM_OFFSET: offset from where the ONIE header starts - */ -#define SYS_EEPROM_MAX_SIZE 2048 -#define SYS_EEPROM_OFFSET 0 -#define SYS_EEPROM_SIZE SYS_EEPROM_MAX_SIZE -#define SYS_EEPROM_I2C_DEVICE "/dev/i2c-0" -#define SYS_EEPROM_I2C_ADDR 0x53 - -#if (SYS_EEPROM_SIZE + SYS_EEPROM_OFFSET > SYS_EEPROM_MAX_SIZE) - #error SYS_EEPROM_SIZE + SYS_EEPROM_OFFSET is greater than SYS_EEPROM_MAX_SIZE -#endif - -// Access functions to onie_tlvinfo -void show_eeprom(u_int8_t *eeprom); -int read_eeprom(struct i2c_client *pi2c_client, u_int8_t *eeprom); -int prog_eeprom(struct i2c_client *pi2c_client,u_int8_t * eeprom); -void update_eeprom_header(u_int8_t *eeprom); -bool tlvinfo_find_tlv(u_int8_t *eeprom, u_int8_t tcode, int *eeprom_index); -bool tlvinfo_delete_tlv(u_int8_t * eeprom, u_int8_t code); -bool tlvinfo_add_tlv(u_int8_t * eeprom, int tcode, char * strval); -bool tlvinfo_decode_tlv(u_int8_t *eeprom, u_int8_t tcode, char* value); -//int find_vpd_data(u_int8_t *eeprom, int i_offset, char *c_buf); - diff --git a/packages/platforms/inventec/x86-64/d6254qs/modules/builds/src/transceiver.c b/packages/platforms/inventec/x86-64/d6254qs/modules/builds/src/transceiver.c deleted file mode 100644 index dec48d977..000000000 --- a/packages/platforms/inventec/x86-64/d6254qs/modules/builds/src/transceiver.c +++ /dev/null @@ -1,8433 +0,0 @@ -#include -#include -#include -#include -#include "io_expander.h" -#include "transceiver.h" - - -/* ========== Register EEPROM address mapping ========== - */ -struct eeprom_map_s eeprom_map_sfp = { - .addr_br =0x50, .page_br =-1, .offset_br =12, .length_br =1, - .addr_cdr =-1, .page_cdr =-1, .offset_cdr =-1, .length_cdr =-1, - .addr_comp_rev =0x50, .page_comp_rev =-1, .offset_comp_rev =94, .length_comp_rev =1, - .addr_connector =0x50, .page_connector =-1, .offset_connector =2, .length_connector =1, - .addr_diag_type =0x50, .page_diag_type =-1, .offset_diag_type =92 , .length_diag_type =1, - .addr_extbr =-1, .page_extbr =-1, .offset_extbr =-1, .length_extbr =-1, - .addr_ext_id =0x50, .page_ext_id =-1, .offset_ext_id =1, .length_ext_id =1, - .addr_id =0x50, .page_id =-1, .offset_id =0, .length_id =1, - .addr_len_sm =0x50, .page_len_sm =-1, .offset_len_sm =15, .length_len_sm =1, - .addr_len_smf =0x50, .page_len_smf =-1, .offset_len_smf =14, .length_len_smf =1, - .addr_len_om1 =0x50, .page_len_om1 =-1, .offset_len_om1 =17, .length_len_om1 =1, - .addr_len_om2 =0x50, .page_len_om2 =-1, .offset_len_om2 =16, .length_len_om2 =1, - .addr_len_om3 =0x50, .page_len_om3 =-1, .offset_len_om3 =19, .length_len_om3 =1, - .addr_len_om4 =0x50, .page_len_om4 =-1, .offset_len_om4 =18, .length_len_om4 =1, - .addr_option =0x50, .page_option =-1, .offset_option =64, .length_option =2, - .addr_rate_id =0x50, .page_rate_id =-1, .offset_rate_id =13, .length_rate_id =1, - .addr_rx_am =-1, .page_rx_am =-1, .offset_rx_am =-1, .length_rx_am =-1, - .addr_rx_em =0x51, .page_rx_em =-1, .offset_rx_em =115, .length_rx_em =1, - .addr_rx_los =-1, .page_rx_los =-1, .offset_rx_los =-1, .length_rx_los =-1, - .addr_rx_power =0x51, .page_rx_power =-1, .offset_rx_power =104, .length_rx_power =2, - .addr_soft_rs0 =0x51, .page_soft_rs0 =-1, .offset_soft_rs0 =110, .length_soft_rs0 =1, - .addr_soft_rs1 =0x51, .page_soft_rs1 =-1, .offset_soft_rs1 =118, .length_soft_rs0 =1, - .addr_temp =0x51, .page_temp =-1, .offset_temp =96, .length_temp =2, - .addr_trancomp =0x50, .page_trancomp =-1, .offset_trancomp =3, .length_trancomp =8, - .addr_trancomp_ext =0x50, .page_trancomp_ext =-1, .offset_trancomp_ext =36, .length_trancomp_ext =1, - .addr_tx_bias =0x51, .page_tx_bias =-1, .offset_tx_bias =100, .length_tx_bias =2, - .addr_tx_disable =-1, .page_tx_disable =-1, .offset_tx_disable =-1, .length_tx_disable =-1, - .addr_tx_eq =0x51, .page_tx_eq =-1, .offset_tx_eq =114, .length_tx_eq =1, - .addr_tx_fault =-1, .page_tx_fault =-1, .offset_tx_fault =-1, .length_tx_fault =-1, - .addr_tx_power =0x51, .page_tx_power =-1, .offset_tx_power =102, .length_tx_power =2, - .addr_vendor_name =0x50, .page_vendor_name =-1, .offset_vendor_name =20, .length_vendor_name =16, - .addr_vendor_pn =0x50, .page_vendor_pn =-1, .offset_vendor_pn =40, .length_vendor_pn =16, - .addr_vendor_rev =0x50, .page_vendor_rev =-1, .offset_vendor_rev =56, .length_vendor_rev =4, - .addr_vendor_sn =0x50, .page_vendor_sn =-1, .offset_vendor_sn =68, .length_vendor_sn =16, - .addr_voltage =0x51, .page_voltage =-1, .offset_voltage =98, .length_voltage =2, - .addr_wavelength =0x50, .page_wavelength =-1, .offset_wavelength =60, .length_wavelength =2, - .addr_eeprom =0x50, .page_eeprom =-1, .offset_eeprom =0, .length_eeprom =256, -}; - -struct eeprom_map_s eeprom_map_qsfp = { - .addr_br =0x50, .page_br =0, .offset_br =140, .length_br =1, - .addr_cdr =-1, .page_cdr =-1, .offset_cdr =-1, .length_cdr =-1, - .addr_comp_rev =0x50, .page_comp_rev =-1, .offset_comp_rev =1, .length_comp_rev =1, - .addr_connector =0x50, .page_connector =0, .offset_connector =130, .length_connector =1, - .addr_diag_type =0x50, .page_diag_type =0, .offset_diag_type =220, .length_diag_type =1, - .addr_extbr =0x50, .page_extbr =0, .offset_extbr =222, .length_extbr =1, - .addr_ext_id =0x50, .page_ext_id =0, .offset_ext_id =129, .length_ext_id =1, - .addr_id =0x50, .page_id =0, .offset_id =128, .length_id =1, - .addr_len_sm =-1, .page_len_sm =-1, .offset_len_sm =-1, .length_len_sm =-1, - .addr_len_smf =0x50, .page_len_smf =0, .offset_len_smf =142, .length_len_smf =1, - .addr_len_om1 =0x50, .page_len_om1 =0, .offset_len_om1 =145, .length_len_om1 =1, - .addr_len_om2 =0x50, .page_len_om2 =0, .offset_len_om2 =144, .length_len_om2 =1, - .addr_len_om3 =0x50, .page_len_om3 =0, .offset_len_om3 =143, .length_len_om3 =1, - .addr_len_om4 =0x50, .page_len_om4 =0, .offset_len_om4 =146, .length_len_om4 =1, - .addr_option =0x50, .page_option =0, .offset_option =193, .length_option =3, - .addr_rate_id =-1, .page_rate_id =-1, .offset_rate_id =-1, .length_rate_id =-1, - .addr_rx_am =-1, .page_rx_am =-1, .offset_rx_am =-1, .length_rx_am =-1, - .addr_rx_em =-1, .page_rx_em =-1, .offset_rx_em =-1, .length_rx_em =-1, - .addr_rx_los =0x50, .page_rx_los =-1, .offset_rx_los =3, .length_rx_los =1, - .addr_rx_power =0x50, .page_rx_power =-1, .offset_rx_power =34, .length_rx_power =8, - .addr_soft_rs0 =-1, .page_soft_rs0 =-1, .offset_soft_rs0 =-1, .length_soft_rs0 =-1, - .addr_soft_rs1 =-1, .page_soft_rs1 =-1, .offset_soft_rs1 =-1, .length_soft_rs0 =-1, - .addr_temp =0x50, .page_temp =-1, .offset_temp =22, .length_temp =2, - .addr_trancomp =0x50, .page_trancomp =0, .offset_trancomp =131, .length_trancomp =8, - .addr_trancomp_ext =0x50, .page_trancomp_ext =0, .offset_trancomp_ext =192, .length_trancomp_ext =1, - .addr_tx_bias =0x50, .page_tx_bias =-1, .offset_tx_bias =42, .length_tx_bias =8, - .addr_tx_disable =0x50, .page_tx_disable =-1, .offset_tx_disable =86, .length_tx_disable =1, - .addr_tx_eq =-1, .page_tx_eq =-1, .offset_tx_eq =-1, .length_tx_eq =-1, - .addr_tx_fault =0x50, .page_tx_fault =-1, .offset_tx_fault =4, .length_tx_fault =1, - .addr_tx_power =0x50, .page_tx_power =-1, .offset_tx_power =50, .length_tx_power =8, - .addr_vendor_name =0x50, .page_vendor_name =0, .offset_vendor_name =148, .length_vendor_name =16, - .addr_vendor_pn =0x50, .page_vendor_pn =0, .offset_vendor_pn =168, .length_vendor_pn =16, - .addr_vendor_rev =0x50, .page_vendor_rev =0, .offset_vendor_rev =184, .length_vendor_rev =2, - .addr_vendor_sn =0x50, .page_vendor_sn =0, .offset_vendor_sn =196, .length_vendor_sn =16, - .addr_voltage =0x50, .page_voltage =-1, .offset_voltage =26, .length_voltage =2, - .addr_wavelength =0x50, .page_wavelength =0, .offset_wavelength =186, .length_wavelength =2, - .addr_eeprom =0x50, .page_eeprom =0, .offset_eeprom =128, .length_eeprom =256, -}; - -struct eeprom_map_s eeprom_map_qsfp28 = { - .addr_br =0x50, .page_br =0, .offset_br =140, .length_br =1, - .addr_cdr =0x50, .page_cdr =-1, .offset_cdr =98, .length_cdr =1, - .addr_comp_rev =0x50, .page_comp_rev =-1, .offset_comp_rev =1, .length_comp_rev =1, - .addr_connector =0x50, .page_connector =0, .offset_connector =130, .length_connector =1, - .addr_diag_type =0x50, .page_diag_type =0, .offset_diag_type =220, .length_diag_type =1, - .addr_extbr =0x50, .page_extbr =0, .offset_extbr =222, .length_extbr =1, - .addr_ext_id =0x50, .page_ext_id =0, .offset_ext_id =129, .length_ext_id =1, - .addr_id =0x50, .page_id =0, .offset_id =128, .length_id =1, - .addr_len_sm =-1, .page_len_sm =-1, .offset_len_sm =-1, .length_len_sm =-1, - .addr_len_smf =0x50, .page_len_smf =0, .offset_len_smf =142, .length_len_smf =1, - .addr_len_om1 =0x50, .page_len_om1 =0, .offset_len_om1 =145, .length_len_om1 =1, - .addr_len_om2 =0x50, .page_len_om2 =0, .offset_len_om2 =144, .length_len_om2 =1, - .addr_len_om3 =0x50, .page_len_om3 =0, .offset_len_om3 =143, .length_len_om3 =1, - .addr_len_om4 =0x50, .page_len_om4 =0, .offset_len_om4 =146, .length_len_om4 =1, - .addr_option =0x50, .page_option =0, .offset_option =193, .length_option =3, - .addr_rate_id =-1, .page_rate_id =-1, .offset_rate_id =-1, .length_rate_id =-1, - .addr_rx_am =0x50, .page_rx_am =3, .offset_rx_am =238, .length_rx_am =2, - .addr_rx_em =0x50, .page_rx_em =3, .offset_rx_em =236, .length_rx_em =2, - .addr_rx_los =0x50, .page_rx_los =-1, .offset_rx_los =3, .length_rx_los =1, - .addr_rx_power =0x50, .page_rx_power =-1, .offset_rx_power =34, .length_rx_power =8, - .addr_soft_rs0 =-1, .page_soft_rs0 =-1, .offset_soft_rs0 =-1, .length_soft_rs0 =-1, - .addr_soft_rs1 =-1, .page_soft_rs1 =-1, .offset_soft_rs1 =-1, .length_soft_rs0 =-1, - .addr_temp =0x50, .page_temp =-1, .offset_temp =22, .length_temp =2, - .addr_trancomp =0x50, .page_trancomp =0, .offset_trancomp =131, .length_trancomp =8, - .addr_trancomp_ext =0x50, .page_trancomp_ext =0, .offset_trancomp_ext =192, .length_trancomp_ext =1, - .addr_tx_bias =0x50, .page_tx_bias =-1, .offset_tx_bias =42, .length_tx_bias =8, - .addr_tx_disable =0x50, .page_tx_disable =-1, .offset_tx_disable =86, .length_tx_disable =1, - .addr_tx_eq =0x50, .page_tx_eq =3, .offset_tx_eq =234, .length_tx_eq =2, - .addr_tx_fault =0x50, .page_tx_fault =-1, .offset_tx_fault =4, .length_tx_fault =1, - .addr_tx_power =0x50, .page_tx_power =-1, .offset_tx_power =50, .length_tx_power =8, - .addr_vendor_name =0x50, .page_vendor_name =0, .offset_vendor_name =148, .length_vendor_name =16, - .addr_vendor_pn =0x50, .page_vendor_pn =0, .offset_vendor_pn =168, .length_vendor_pn =16, - .addr_vendor_rev =0x50, .page_vendor_rev =0, .offset_vendor_rev =184, .length_vendor_rev =2, - .addr_vendor_sn =0x50, .page_vendor_sn =0, .offset_vendor_sn =196, .length_vendor_sn =16, - .addr_voltage =0x50, .page_voltage =-1, .offset_voltage =26, .length_voltage =2, - .addr_wavelength =0x50, .page_wavelength =0, .offset_wavelength =186, .length_wavelength =2, - .addr_eeprom =0x50, .page_eeprom =0, .offset_eeprom =128, .length_eeprom =256, -}; - - -/* ========== Utility Functions ========== - */ -static int -get_bit(uint8_t origin_byte, int bit_shift) { - return (int)((origin_byte >> bit_shift) & 0x1); -} - -static int -transform_word_to_int(uint8_t hight_byte, - uint8_t low_byte) { - return ((((int)hight_byte) << 8) + (int)low_byte); -} - - -void -alarm_msg_2_user(struct transvr_obj_s *self, - char *emsg) { - - SWPS_ERR("%s on %s.\n", emsg, self->swp_name); -} - - -/* ========== Private functions ========== - */ -static int -_reload_transvr_obj(struct transvr_obj_s *self,int new_type); - -static int -reload_transvr_obj(struct transvr_obj_s *self,int new_type); - -static int -_is_transvr_support_ctle(struct transvr_obj_s *self); - -static int -_transvr_init_handler(struct transvr_obj_s *self); - -int -_transvr_clean_handler(struct transvr_obj_s *self); - -int -_sfp_detect_class_by_1g_ethernet(struct transvr_obj_s* self); - - -void -lock_transvr_obj(struct transvr_obj_s *self) { - - mutex_lock(&self->lock); - self->curr_page = VAL_TRANSVR_PAGE_FREE; -} - - -void -unlock_transvr_obj(struct transvr_obj_s *self) { - - self->curr_page = VAL_TRANSVR_PAGE_FREE; - mutex_unlock(&self->lock); -} - - -static int -_check_by_mode(struct transvr_obj_s *self, - int (*attr_update_func)(struct transvr_obj_s *self, int show_err), - char *caller_name){ - - int return_val = ERR_TRANSVR_UNEXCPT; - - switch (self->mode){ - case TRANSVR_MODE_POLLING: - switch (self->state){ - case STATE_TRANSVR_CONNECTED: - goto ok_check_by_mode_1; - case STATE_TRANSVR_NEW: - case STATE_TRANSVR_INIT: - return ERR_TRANSVR_UNINIT; - case STATE_TRANSVR_DISCONNECTED: - return ERR_TRANSVR_UNPLUGGED; - case STATE_TRANSVR_UNEXCEPTED: - return ERR_TRANSVR_ABNORMAL; - case STATE_TRANSVR_ISOLATED: - return ERR_TRNASVR_BE_ISOLATED; - default: - goto err_check_by_mode_1; - } - goto ok_check_by_mode_1; - - case TRANSVR_MODE_DIRECT: - return_val = self->fsm_4_direct(self, caller_name); - if (return_val < 0){ - return return_val; - } - goto ok_check_by_mode_1; - - default: - goto err_check_by_mode_1; - } - goto ok_check_by_mode_1; - -ok_check_by_mode_1: - return attr_update_func(self, 0); - -err_check_by_mode_1: - SWPS_INFO("_check_by_mode: mode:%d state:%d\n", self->mode, self->state); - return ERR_TRANSVR_UNEXCPT; -} - - -static void -_transvr_clean_retry(struct transvr_obj_s *self) { - self->retry = 0; -} - - -static int -_transvr_handle_retry(struct transvr_obj_s *self, int retry) { - /* Return: 0: keep retry - * -1: stop retry - */ - if (self->retry == 0) { - self->retry = retry; - } - self->retry -= 1; - if (self->retry <= 0) { - _transvr_clean_retry(self); - return -1; - } - return 0; -} - - -static int -_common_setup_page(struct transvr_obj_s *self, - int addr, - int page, - int offset, - int len, - int show_e) { - /* return: - * 0 : OK - * -1 : EEPROM settings incorrect - * -2 : I2C R/W failure - * -3 : Undefined case - */ - int retval = DEBUG_TRANSVR_INT_VAL; - char *emsg = DEBUG_TRANSVR_STR_VAL; - - /* Check */ - if ((addr < 0) || (offset < 0) || (len < 0)) { - emsg = "EEPROM settings incorrect"; - retval = -1; - goto err_common_setup_page; - } - /* Case1: continue access */ - if ((self->i2c_client_p->addr == addr) && - (self->curr_page == page)) { - return 0; - } - self->i2c_client_p->addr = addr; - /* Case2: select lower page */ - if (page == -1) { - self->curr_page = page; - return 0; - } - /* Case3: select upper page */ - if (page >= 0) { - goto upper_common_setup_page; - } - /* Unexpected case */ - show_e = 1; - emsg = "Unexpected case"; - retval = -3; - goto err_common_setup_page; - -upper_common_setup_page: - if (i2c_smbus_write_byte_data(self->i2c_client_p, - VAL_TRANSVR_PAGE_SELECT_OFFSET, - page) < 0) { - emsg = "I2C R/W failure"; - retval = -2; - goto err_common_setup_page; - } - self->curr_page = page; - mdelay(VAL_TRANSVR_PAGE_SELECT_DELAY); - return 0; - -err_common_setup_page: - if (show_e) { - SWPS_INFO("%s: %s", __func__, emsg); - SWPS_INFO("%s: :0x%02x :%d :%d :%d\n", - __func__, addr, page, offset, len); - } - return retval; -} - -/* -static int -_common_setup_password(struct transvr_obj_s *self, - int addr, - int page, - int offs, - uint8_t pwd[4], - int show_e) { - int i = 0; - int err = DEBUG_TRANSVR_INT_VAL; - char *emsg = DEBUG_TRANSVR_STR_VAL; - - err = _common_setup_page(self, addr, page, offs, 4, show_e); - if (err < 0){ - emsg = "setup EEPROM page fail"; - goto err_common_setup_password; - } - for (i=0; i<4; i++) { - err = i2c_smbus_write_byte_data(self->i2c_client_p, - (offs + i), - pwd[i]); - if (err < 0){ - emsg = "I2C R/W fail!"; - goto err_common_setup_password; - } - } - return 0; - -err_common_setup_password: - if (show_e) { - SWPS_INFO("%s: %s :%d\n", __func__, emsg, err); - } - return ERR_TRANSVR_UPDATE_FAIL; -} -*/ - -static int -_common_update_uint8_attr(struct transvr_obj_s *self, - int addr, - int page, - int offset, - int len, - uint8_t *buf, - char *caller, - int show_e){ - - int i; - int err = DEBUG_TRANSVR_INT_VAL; - char *emsg = DEBUG_TRANSVR_STR_VAL; - - err = _common_setup_page(self, addr, page, offset, len, show_e); - if (err < 0){ - emsg = "setup EEPROM page fail"; - goto err_common_update_uint8_attr; - } - for (i=0; ii2c_client_p, (offset + i)); - if (err < 0){ - emsg = "I2C R/W fail!"; - goto err_common_update_uint8_attr; - } - buf[i] = err; - } - return 0; - -err_common_update_uint8_attr: - if (show_e) { - SWPS_INFO("%s: %s :%s :%d\n", - __func__, emsg, caller, err); - } - buf[0] = DEBUG_TRANSVR_HEX_VAL; - return ERR_TRANSVR_UPDATE_FAIL; -} - - -static int -_common_update_int_attr(struct transvr_obj_s *self, - int addr, - int page, - int offset, - int len, - int *buf, - char *caller, - int show_e){ - - int i; - int err = DEBUG_TRANSVR_INT_VAL; - char *emsg = DEBUG_TRANSVR_STR_VAL; - - err = _common_setup_page(self, addr, page, offset, len, show_e); - if (err < 0){ - emsg = "setup EEPROM page fail"; - goto err_common_update_int_attr; - } - for (i=0; ii2c_client_p, (offset + i)); - if (err < 0){ - emsg = "I2C R/W fail!"; - goto err_common_update_int_attr; - } - buf[i] = (int)err; - } - return 0; - -err_common_update_int_attr: - if (show_e) { - SWPS_INFO("%s: %s :%s :%d\n", - __func__, emsg, caller, err); - } - buf[0] = DEBUG_TRANSVR_INT_VAL; - return ERR_TRANSVR_UPDATE_FAIL; -} - - -static int -_common_update_string_attr(struct transvr_obj_s *self, - int addr, - int page, - int offset, - int len, - char buf[], - char *caller, - int show_e){ - - int i; - int err = DEBUG_TRANSVR_INT_VAL; - char *emsg = DEBUG_TRANSVR_STR_VAL; - - err = _common_setup_page(self, addr, page, offset, len, show_e); - if (err < 0){ - emsg = "setup EEPROM page fail"; - goto err_common_update_string_attr; - } - for (i=0; ii2c_client_p, (offset + i)); - if (err < 0){ - emsg = "I2C R/W fail!"; - goto err_common_update_string_attr; - } - buf[i] = (char)err; - } - return 0; - -err_common_update_string_attr: - if (show_e) { - SWPS_INFO("%s: %s :%s :%d\n", - __func__, emsg, caller, err); - } - buf[0] = 'e'; - return ERR_TRANSVR_UPDATE_FAIL; -} - - -static int -_common_set_uint8_attr(struct transvr_obj_s *self, - int addr, - int page, - int offset, - uint8_t update, - uint8_t *buf, - char *caller, - int show_e){ - int len = 1; - int err = DEBUG_TRANSVR_INT_VAL; - char *emsg = DEBUG_TRANSVR_STR_VAL; - - if ((*buf) == update){ - return 0; - } - err = _common_setup_page(self, addr, page, offset, len, show_e); - if (err < 0){ - emsg = "setup EEPROM page fail"; - goto err_common_set_uint8_attr_1; - } - err = i2c_smbus_write_byte_data(self->i2c_client_p, - offset, - update); - if (err < 0){ - emsg = "I2C R/W fail!"; - goto err_common_set_uint8_attr_1; - } - (*buf) = update; - return 0; - -err_common_set_uint8_attr_1: - if (show_e) { - SWPS_INFO("%s: %s :%s :%d\n", - __func__, emsg, caller, err); - } - return ERR_TRANSVR_UPDATE_FAIL; -} - - -static int -_common_set_uint8_array(struct transvr_obj_s *self, - int addr, - int page, - int offs, - int len, - uint8_t update[], - uint8_t buf[], - char *caller, - int show_e){ - int i = 0; - int err = DEBUG_TRANSVR_INT_VAL; - char *emsg = DEBUG_TRANSVR_STR_VAL; - - err = _common_setup_page(self, addr, page, offs, len, show_e); - if (err < 0){ - emsg = "setup EEPROM page fail"; - goto err_common_set_uint8_attr_1; - } - for (i=0; ii2c_client_p, - (offs + i), - update[i]); - if (err < 0){ - emsg = "I2C R/W fail!"; - goto err_common_set_uint8_attr_1; - } - buf[i] = update[i]; - } - return 0; - -err_common_set_uint8_attr_1: - if (show_e) { - SWPS_INFO("%s: %s :%s :%d :%d\n", - __func__, emsg, caller, err, i); - } - return ERR_TRANSVR_UPDATE_FAIL; -} - - -static int -_common_update_attr_id(struct transvr_obj_s *self, - int show_err){ - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_id, - self->eeprom_map_p->page_id, - self->eeprom_map_p->offset_id, - self->eeprom_map_p->length_id, - &(self->id), - "_common_update_attr_id", - show_err); -} - - -static int -_common_update_attr_extended_id(struct transvr_obj_s *self, - int show_err){ - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_ext_id, - self->eeprom_map_p->page_ext_id, - self->eeprom_map_p->offset_ext_id, - self->eeprom_map_p->length_ext_id, - &(self->ext_id), - "_common_update_attr_extended_id", - show_err); -} - - -static int -_common_update_attr_connector(struct transvr_obj_s *self, - int show_err){ - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_connector, - self->eeprom_map_p->page_connector, - self->eeprom_map_p->offset_connector, - self->eeprom_map_p->length_connector, - &(self->connector), - "_common_update_attr_connector", - show_err); -} - - -static int -_common_update_attr_transvr_comp(struct transvr_obj_s *self, - int show_err){ - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_trancomp, - self->eeprom_map_p->page_trancomp, - self->eeprom_map_p->offset_trancomp, - self->eeprom_map_p->length_trancomp, - self->transvr_comp, - "_common_update_attr_transvr_comp", - show_err); -} - - -static int -_common_update_attr_transvr_comp_ext(struct transvr_obj_s *self, - int show_err){ - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_trancomp_ext, - self->eeprom_map_p->page_trancomp_ext, - self->eeprom_map_p->offset_trancomp_ext, - self->eeprom_map_p->length_trancomp_ext, - &(self->transvr_comp_ext), - "_common_update_attr_transvr_comp_ext", - show_err); -} - - -static int -_common_update_attr_vendor_name(struct transvr_obj_s *self, - int show_err){ - return _common_update_string_attr(self, - self->eeprom_map_p->addr_vendor_name, - self->eeprom_map_p->page_vendor_name, - self->eeprom_map_p->offset_vendor_name, - self->eeprom_map_p->length_vendor_name, - self->vendor_name, - "_common_update_attr_vendor_name", - show_err); -} - - -static int -_common_update_attr_vendor_pn(struct transvr_obj_s *self, - int show_err){ - return _common_update_string_attr(self, - self->eeprom_map_p->addr_vendor_pn, - self->eeprom_map_p->page_vendor_pn, - self->eeprom_map_p->offset_vendor_pn, - self->eeprom_map_p->length_vendor_pn, - self->vendor_pn, - "_common_update_attr_vendor_pn", - show_err); -} - - -static int -_common_update_attr_vendor_rev(struct transvr_obj_s *self, - int show_err){ - return _common_update_string_attr(self, - self->eeprom_map_p->addr_vendor_rev, - self->eeprom_map_p->page_vendor_rev, - self->eeprom_map_p->offset_vendor_rev, - self->eeprom_map_p->length_vendor_rev, - self->vendor_rev, - "_common_update_attr_vendor_rev", - show_err); -} - - -static int -_common_update_attr_vendor_sn(struct transvr_obj_s *self, - int show_err){ - return _common_update_string_attr(self, - self->eeprom_map_p->addr_vendor_sn, - self->eeprom_map_p->page_vendor_sn, - self->eeprom_map_p->offset_vendor_sn, - self->eeprom_map_p->length_vendor_sn, - self->vendor_sn, - "_common_update_attr_vendor_sn", - show_err); -} - - -static int -_common_update_attr_br(struct transvr_obj_s *self, - int show_err){ - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_br, - self->eeprom_map_p->page_br, - self->eeprom_map_p->offset_br, - self->eeprom_map_p->length_br, - &(self->br), - "_common_update_attr_br", - show_err); -} - - -static int -_common_update_attr_len_smf(struct transvr_obj_s *self, - int show_err){ - return _common_update_int_attr(self, - self->eeprom_map_p->addr_len_smf, - self->eeprom_map_p->page_len_smf, - self->eeprom_map_p->offset_len_smf, - self->eeprom_map_p->length_len_smf, - &(self->len_smf), - "_common_update_attr_len_smf", - show_err); -} - - -static int -_common_update_attr_len_om1(struct transvr_obj_s *self, - int show_err){ - return _common_update_int_attr(self, - self->eeprom_map_p->addr_len_om1, - self->eeprom_map_p->page_len_om1, - self->eeprom_map_p->offset_len_om1, - self->eeprom_map_p->length_len_om1, - &(self->len_om1), - "_common_update_attr_len_om1", - show_err); -} - -static int -_common_update_attr_len_om2(struct transvr_obj_s *self, - int show_err){ - return _common_update_int_attr(self, - self->eeprom_map_p->addr_len_om2, - self->eeprom_map_p->page_len_om2, - self->eeprom_map_p->offset_len_om2, - self->eeprom_map_p->length_len_om2, - &(self->len_om2), - "_common_update_attr_len_om2", - show_err); -} - -static int -_common_update_attr_len_om3(struct transvr_obj_s *self, - int show_err){ - return _common_update_int_attr(self, - self->eeprom_map_p->addr_len_om3, - self->eeprom_map_p->page_len_om3, - self->eeprom_map_p->offset_len_om3, - self->eeprom_map_p->length_len_om3, - &(self->len_om3), - "_common_update_attr_len_om3", - show_err); -} - - -static int -_common_update_attr_len_om4(struct transvr_obj_s *self, - int show_err){ - return _common_update_int_attr(self, - self->eeprom_map_p->addr_len_om4, - self->eeprom_map_p->page_len_om4, - self->eeprom_map_p->offset_len_om4, - self->eeprom_map_p->length_len_om4, - &(self->len_om4), - "_common_update_attr_len_om4", - show_err); -} - - -static int -_common_update_attr_option(struct transvr_obj_s *self, - int show_err){ - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_option, - self->eeprom_map_p->page_option, - self->eeprom_map_p->offset_option, - self->eeprom_map_p->length_option, - self->option, - "_common_update_attr_option", - show_err); -} - - -static int -_common_update_attr_comp_rev(struct transvr_obj_s *self, - int show_err){ - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_comp_rev, - self->eeprom_map_p->page_comp_rev, - self->eeprom_map_p->offset_comp_rev, - self->eeprom_map_p->length_comp_rev, - &(self->comp_rev), - "_common_update_attr_comp_rev", - show_err); -} - - -static int -_common_update_attr_diag_type(struct transvr_obj_s *self, - int show_err){ - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_diag_type, - self->eeprom_map_p->page_diag_type, - self->eeprom_map_p->offset_diag_type, - self->eeprom_map_p->length_diag_type, - &(self->diag_type), - "_common_update_attr_diag_type", - show_err); -} - - -static int -_common_update_attr_wavelength(struct transvr_obj_s *self, - int show_err){ - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_wavelength, - self->eeprom_map_p->page_wavelength, - self->eeprom_map_p->offset_wavelength, - self->eeprom_map_p->length_wavelength, - self->wavelength, - "_common_update_attr_wavelength", - show_err); -} - -static int -_common_update_attr_eeprom(struct transvr_obj_s *self, - int show_err){ - return _common_update_string_attr(self, - self->eeprom_map_p->addr_eeprom, - self->eeprom_map_p->page_eeprom, - self->eeprom_map_p->offset_eeprom, - self->eeprom_map_p->length_eeprom, - self->eeprom, - "_common_update_attr_eeprom", - show_err); -} - - -int -_common_get_option_value(struct transvr_obj_s *self, - int offset, - int bit_shift) { - /* SFP: - * - option[0] = A0h / 64 - * - option[1] = A0h / 65 - * QSFP: - * - option[0] = 00h / 193 - * - option[1] = 00h / 194 - * - option[2] = 00h / 195 - */ - return (self->option[offset] & (1 << bit_shift)); -} - - -static int -_sfp_update_attr_len_sm(struct transvr_obj_s *self, - int show_err){ - return _common_update_int_attr(self, - self->eeprom_map_p->addr_len_sm, - self->eeprom_map_p->page_len_sm, - self->eeprom_map_p->offset_len_sm, - self->eeprom_map_p->length_len_sm, - &(self->len_sm), - "_common_update_attr_len_sm", - show_err); -} - - -static int -_sfp_update_attr_rate_id(struct transvr_obj_s *self, - int show_err){ - return _common_update_int_attr(self, - self->eeprom_map_p->addr_rate_id, - self->eeprom_map_p->page_rate_id, - self->eeprom_map_p->offset_rate_id, - self->eeprom_map_p->length_rate_id, - &(self->rate_id), - "_sfp_update_attr_rate_id", - show_err); -} - - -static int -_sfp_update_attr_soft_rs0(struct transvr_obj_s *self, - int show_err){ - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_soft_rs0, - self->eeprom_map_p->page_soft_rs0, - self->eeprom_map_p->offset_soft_rs0, - self->eeprom_map_p->length_soft_rs0, - &(self->soft_rs0), - "_sfp_update_attr_soft_rs0", - show_err); -} - - -static int -_sfp_update_attr_soft_rs1(struct transvr_obj_s *self, - int show_err){ - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_soft_rs1, - self->eeprom_map_p->page_soft_rs1, - self->eeprom_map_p->offset_soft_rs1, - self->eeprom_map_p->length_soft_rs1, - &(self->soft_rs1), - "_sfp_update_attr_soft_rs1", - show_err); -} - - -int -_sfp_is_diag_support(struct transvr_obj_s *self){ - - uint8_t bit_mask = 0xC0; /* 1100 0000 */ - uint8_t en_val = 0x40; /* 0100 0000 */ - uint8_t checkval = (self->diag_type & bit_mask); - - if (checkval == en_val) { - return 1; - } - return 0; -} - - -static int -_sfp_update_attr_curr_temp(struct transvr_obj_s *self, - int show_err){ - - if (!(_sfp_is_diag_support(self))) { - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_temp, - self->eeprom_map_p->page_temp, - self->eeprom_map_p->offset_temp, - self->eeprom_map_p->length_temp, - self->curr_temp, - "_sfp_update_attr_curr_temp", - show_err); -} - - -static int -_sfp_update_attr_curr_voltage(struct transvr_obj_s *self, - int show_err){ - - if (!(_sfp_is_diag_support(self))) { - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_voltage, - self->eeprom_map_p->page_voltage, - self->eeprom_map_p->offset_voltage, - self->eeprom_map_p->length_voltage, - self->curr_voltage, - "_sfp_update_attr_curr_voltage", - show_err); -} - - -static int -_sfp_update_attr_curr_tx_bias(struct transvr_obj_s *self, - int show_err){ - - if (!(_sfp_is_diag_support(self))) { - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_tx_bias, - self->eeprom_map_p->page_tx_bias, - self->eeprom_map_p->offset_tx_bias, - self->eeprom_map_p->length_tx_bias, - self->curr_tx_bias, - "_sfp_update_attr_curr_tx_bias", - show_err); -} - - -static int -_sfp_update_attr_curr_tx_power(struct transvr_obj_s *self, - int show_err){ - - if (!(_sfp_is_diag_support(self))) { - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_tx_power, - self->eeprom_map_p->page_tx_power, - self->eeprom_map_p->offset_tx_power, - self->eeprom_map_p->length_tx_power, - self->curr_tx_power, - "_sfp_update_attr_curr_tx_power", - show_err); -} - - -static int -_sfp_update_attr_curr_rx_power(struct transvr_obj_s *self, - int show_err){ - - if (!(_sfp_is_diag_support(self))) { - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_rx_power, - self->eeprom_map_p->page_rx_power, - self->eeprom_map_p->offset_rx_power, - self->eeprom_map_p->length_rx_power, - self->curr_rx_power, - "_sfp_update_attr_curr_rx_power", - show_err); -} - - -static int -_sfp_update_attr_rx_em(struct transvr_obj_s *self, - int show_err){ - - if (!_is_transvr_support_ctle(self)) { - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_rx_em, - self->eeprom_map_p->page_rx_em, - self->eeprom_map_p->offset_rx_em, - self->eeprom_map_p->length_rx_em, - self->rx_em, - "_sfp_update_attr_rx_em", - show_err); -} - - -static int -_sfp_update_attr_tx_eq(struct transvr_obj_s *self, - int show_err){ - - if (!_is_transvr_support_ctle(self)) { - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_tx_eq, - self->eeprom_map_p->page_tx_eq, - self->eeprom_map_p->offset_tx_eq, - self->eeprom_map_p->length_tx_eq, - self->tx_eq, - "_sfp_update_attr_tx_eq", - show_err); -} - - -static int -_qsfp_update_attr_cdr(struct transvr_obj_s *self, - int show_err){ - if (self->type != TRANSVR_TYPE_QSFP_28){ - self->cdr = DEBUG_TRANSVR_HEX_VAL; - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_cdr, - self->eeprom_map_p->page_cdr, - self->eeprom_map_p->offset_cdr, - self->eeprom_map_p->length_cdr, - &(self->cdr), - "_common_update_attr_cdr", - show_err); -} - - -static int -_qsfg_update_attr_extbr(struct transvr_obj_s *self, - int show_err) { - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_extbr, - self->eeprom_map_p->page_extbr, - self->eeprom_map_p->offset_extbr, - self->eeprom_map_p->length_extbr, - &(self->extbr), - "_common_update_attr_extbr", - show_err); -} - - -static int -_qsfp_is_diag_support(struct transvr_obj_s *self, - int diag_type) { - /* Input Parm: diag_type - * => 1 : temperature - * => 2 : voltage - * => 3 : tx relate - * => 4 : rx relate - */ - uint8_t mask_b2 = 0x04; /* 0000 0100 */ - uint8_t mask_b3 = 0x08; /* 0000 1000 */ - - switch (diag_type) { - case 1: /* temperature */ - case 2: /* voltage */ - /* Direct access target, because of spec not defined */ - return 1; - case 3: - case 4: - /* [Note] - * Due to lot of transceiver vendor defined it not rigorously and - * consider of general support, we seem it as supported if there - * are bit-2 OR bit-3 defined by transceiver vendor. - */ - if ( ((self->diag_type & mask_b2) == mask_b2 ) || - ((self->diag_type & mask_b3) == mask_b3 ) ){ - return 1; - } - return 0; - default: - SWPS_INFO("%s: undefined diag_type:%d\n", - __func__, diag_type); - break; - } - return 0; -} - - -int -_qsfp_is_implement_tx_disable(struct transvr_obj_s *self) { - /* - * 00h / Byte-195 / Bit-4 - */ - int byte = 2; - int bit = 4; - return _common_get_option_value(self, byte, bit); -} - - -int -_qsfp_is_implement_tx_fault(struct transvr_obj_s *self) { - /* - * 00h / Byte-195 / Bit-3 - */ - int byte = 2; - int bit = 3; - return _common_get_option_value(self, byte, bit); -} - - -static int -_qsfp_update_attr_curr_temp(struct transvr_obj_s *self, - int show_err){ - int diag_type = 1; - - if (!(_qsfp_is_diag_support(self, diag_type))) { - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_temp, - self->eeprom_map_p->page_temp, - self->eeprom_map_p->offset_temp, - self->eeprom_map_p->length_temp, - self->curr_temp, - "_qsfp_update_attr_curr_temp", - show_err); -} - - -static int -_qsfp_update_attr_curr_voltage(struct transvr_obj_s *self, - int show_err){ - int diag_type = 2; - - if (!(_qsfp_is_diag_support(self, diag_type))) { - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_voltage, - self->eeprom_map_p->page_voltage, - self->eeprom_map_p->offset_voltage, - self->eeprom_map_p->length_voltage, - self->curr_voltage, - "_qsfp_update_attr_curr_voltage", - show_err); -} - - -static int -_qsfp_update_attr_curr_tx_bias(struct transvr_obj_s *self, - int show_err){ - int diag_type = 3; - - if (!(_qsfp_is_diag_support(self, diag_type))) { - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_tx_bias, - self->eeprom_map_p->page_tx_bias, - self->eeprom_map_p->offset_tx_bias, - self->eeprom_map_p->length_tx_bias, - self->curr_tx_bias, - "_qsfp_update_attr_curr_tx_bias", - show_err); -} - - -static int -_qsfp_update_attr_curr_tx_power(struct transvr_obj_s *self, - int show_err){ - int diag_type = 3; - - if (!(_qsfp_is_diag_support(self, diag_type))) { - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_tx_power, - self->eeprom_map_p->page_tx_power, - self->eeprom_map_p->offset_tx_power, - self->eeprom_map_p->length_tx_power, - self->curr_tx_power, - "_qsfp_update_attr_curr_tx_power", - show_err); -} - - -static int -_qsfp_update_attr_curr_rx_power(struct transvr_obj_s *self, - int show_err){ - int diag_type = 4; - - if (!(_qsfp_is_diag_support(self, diag_type))) { - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_rx_power, - self->eeprom_map_p->page_rx_power, - self->eeprom_map_p->offset_rx_power, - self->eeprom_map_p->length_rx_power, - self->curr_rx_power, - "_qsfp_update_attr_curr_rx_power", - show_err); -} - - -static int -_qsfp_update_attr_soft_rx_los(struct transvr_obj_s *self, - int show_err){ - - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_rx_los, - self->eeprom_map_p->page_rx_los, - self->eeprom_map_p->offset_rx_los, - self->eeprom_map_p->length_rx_los, - &(self->rx_los), - "_qsfp_update_attr_soft_rx_los", - show_err); -} - - -static int -_qsfp_update_attr_soft_tx_disable(struct transvr_obj_s *self, - int show_err){ - - if (!_qsfp_is_implement_tx_disable(self)) { - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_tx_disable, - self->eeprom_map_p->page_tx_disable, - self->eeprom_map_p->offset_tx_disable, - self->eeprom_map_p->length_tx_disable, - &(self->tx_disable), - "_qsfp_update_attr_soft_tx_disable", - show_err); -} - - -static int -_qsfp_update_attr_soft_tx_fault(struct transvr_obj_s *self, - int show_err){ - - if (!_qsfp_is_implement_tx_fault(self)) { - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_tx_fault, - self->eeprom_map_p->page_tx_fault, - self->eeprom_map_p->offset_tx_fault, - self->eeprom_map_p->length_tx_fault, - &(self->tx_fault), - "_qsfp_update_attr_soft_tx_fault", - show_err); -} - - -static int -_qsfp_update_attr_tx_eq(struct transvr_obj_s *self, - int show_err){ - - if (!_is_transvr_support_ctle(self)) { - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_tx_eq, - self->eeprom_map_p->page_tx_eq, - self->eeprom_map_p->offset_tx_eq, - self->eeprom_map_p->length_tx_eq, - self->tx_eq, - "_qsfp_update_attr_tx_eq", - show_err); -} - - -static int -_qsfp_update_attr_rx_am(struct transvr_obj_s *self, - int show_err){ - - if (!_is_transvr_support_ctle(self)) { - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_rx_am, - self->eeprom_map_p->page_rx_am, - self->eeprom_map_p->offset_rx_am, - self->eeprom_map_p->length_rx_am, - self->rx_am, - "_qsfp_update_attr_rx_am", - show_err); -} - - -static int -_qsfp_update_attr_rx_em(struct transvr_obj_s *self, - int show_err){ - - if (!_is_transvr_support_ctle(self)) { - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_rx_em, - self->eeprom_map_p->page_rx_em, - self->eeprom_map_p->offset_rx_em, - self->eeprom_map_p->length_rx_em, - self->rx_em, - "_qsfp_update_attr_rx_em", - show_err); -} - - -int -_common_update_attr_all(struct transvr_obj_s *self, - int show_err){ - - char *err_str = "err"; - - if (_common_update_attr_id(self, show_err) < 0) { - err_str = "_common_update_attr_id"; - goto err_common_update_attr_all; - } - if (_common_update_attr_extended_id(self, show_err) < 0) { - err_str = "_common_update_attr_extended_id"; - goto err_common_update_attr_all; - } - if (_common_update_attr_connector(self, show_err) < 0) { - err_str = "_common_update_attr_connector"; - goto err_common_update_attr_all; - } - if (_common_update_attr_transvr_comp(self, show_err) < 0) { - err_str = "_common_update_attr_transvr_comp"; - goto err_common_update_attr_all; - } - if (_common_update_attr_transvr_comp_ext(self, show_err) < 0) { - err_str = "_common_update_attr_transvr_comp_ext"; - goto err_common_update_attr_all; - } - if (_common_update_attr_vendor_name(self, show_err) < 0) { - err_str = "_common_update_attr_vendor_name"; - goto err_common_update_attr_all; - } - if (_common_update_attr_vendor_pn(self, show_err) < 0) { - err_str = "_common_update_attr_vendor_pn"; - goto err_common_update_attr_all; - } - if (_common_update_attr_vendor_rev(self, show_err) < 0) { - err_str = "_common_update_attr_vendor_rev"; - goto err_common_update_attr_all; - } - if (_common_update_attr_vendor_sn(self, show_err) < 0) { - err_str = "_common_update_attr_vendor_sn"; - goto err_common_update_attr_all; - } - if (_common_update_attr_br(self, show_err) < 0) { - err_str = "_common_update_attr_br"; - goto err_common_update_attr_all; - } - if (_common_update_attr_len_smf(self, show_err) < 0) { - err_str = "_common_update_attr_len_smf"; - goto err_common_update_attr_all; - } - if (_common_update_attr_len_om1(self, show_err) < 0) { - err_str = "_common_update_attr_len_om1"; - goto err_common_update_attr_all; - } - if (_common_update_attr_len_om2(self, show_err) < 0) { - err_str = "_common_update_attr_len_om2"; - goto err_common_update_attr_all; - } - if (_common_update_attr_len_om3(self, show_err) < 0) { - err_str = "_common_update_attr_len_om3"; - goto err_common_update_attr_all; - } - if (_common_update_attr_len_om4(self, show_err) < 0) { - err_str = "_common_update_attr_len_om4"; - goto err_common_update_attr_all; - } - if (_common_update_attr_option(self, show_err) < 0) { - err_str = "_common_update_attr_option"; - goto err_common_update_attr_all; - } - if (_common_update_attr_comp_rev(self, show_err) < 0) { - err_str = "_common_update_attr_comp_rev"; - goto err_common_update_attr_all; - } - if (_common_update_attr_diag_type(self, show_err) < 0) { - err_str = "_common_update_attr_diag_type"; - goto err_common_update_attr_all; - } - if (_common_update_attr_wavelength(self, show_err) < 0) { - err_str = "_common_update_attr_wavelength"; - goto err_common_update_attr_all; - } - if (_common_update_attr_eeprom(self, show_err) < 0) { - err_str = "_common_update_attr_eeprom"; - goto err_common_update_attr_all; - } - return 0; - -err_common_update_attr_all: - if (show_err){ - SWPS_INFO("%s: fail at:%s :%s\n", __func__, err_str, self->swp_name); - } - return -1; -} - - -int -_sfp_update_attr_all(struct transvr_obj_s *self, - int show_err){ - - char *err_str = DEBUG_TRANSVR_STR_VAL; - - if (_common_update_attr_all(self, show_err) < 0){ - err_str = "_common_update_attr_all"; - goto err_sfp_update_attr_all; - } - if (_sfp_update_attr_len_sm(self, show_err) < 0) { - err_str = "_sfp_update_attr_len_sm"; - goto err_sfp_update_attr_all; - } - if (_sfp_update_attr_rate_id(self, show_err) < 0) { - err_str = "_sfp_update_attr_rate_id"; - goto err_sfp_update_attr_all; - } - if ((self->rate_id) > 0) { - if (_sfp_update_attr_soft_rs0(self, show_err) < 0) { - err_str = "_sfp_update_attr_soft_rs0"; - goto err_sfp_update_attr_all; - } - if (_sfp_update_attr_soft_rs1(self, show_err) < 0) { - err_str = "_sfp_update_attr_soft_rs1"; - goto err_sfp_update_attr_all; - } - } - return 0; - -err_sfp_update_attr_all: - if (show_err){ - SWPS_INFO("%s: fail at:%s :%s\n", __func__, err_str, self->swp_name); - } - return -1; -} - - -int -_qsfp_update_attr_all(struct transvr_obj_s *self, - int show_err){ - - char *err_str = DEBUG_TRANSVR_STR_VAL; - - if (_common_update_attr_all(self, show_err) < 0){ - err_str = "_common_update_attr_all"; - goto err_qsfp_update_attr_all; - } - if (_qsfg_update_attr_extbr(self, show_err) < 0) { - err_str = "_qsfg_update_attr_extbr"; - goto err_qsfp_update_attr_all; - } - if (self->type == TRANSVR_TYPE_QSFP_28) { - if (_qsfp_update_attr_cdr(self, 1) < 0) { - err_str = "_qsfp_update_attr_cdr"; - goto err_qsfp_update_attr_all; - } - } - return 0; - -err_qsfp_update_attr_all: - if (show_err){ - SWPS_INFO("%s: fail at:%s :%s\n", __func__, err_str, self->swp_name); - } - return -1; -} - - -/* ========== Object functions for common type ========== - */ -int -_common_count_temp(uint8_t high_byte, - uint8_t low_byte, - char *buf_p) { - int sign = 0; - int high = 0; - int low = 0; - int lmax = 8; - - /* Count high */ - sign = get_bit(high_byte,7); - SWP_BIT_CLEAR(high_byte, 7); - high = (int)high_byte; - if (sign == 1) { - high = 0 - high; - } - /* Count low */ - low = (get_bit(low_byte, 7) * 500); - low += (get_bit(low_byte, 6) * 250); - low += (get_bit(low_byte, 5) * 125); - low += (get_bit(low_byte, 4) * 62); - low = (low / 100); - /* Integrate High and Low */ - return snprintf(buf_p, lmax, "%d.%d\n", high, low); -} - - -int -_common_count_voltage(uint8_t high_byte, - uint8_t low_byte, - char *buf_p) { - /* [Note]: - * Internally measured transceiver supply voltage. Represented - * as a 16 bit unsigned integer with the voltage defined as the - * full 16 bit value (0-65535) with LSB equal to 100 uVolt, - * yielding a total range of 0 to +6.55 Volts. Practical - * considerations to be defined by transceiver manufacturer will - * tend to limit the actual bounds of the supply voltage measurement. - * Accuracy is vendor specific but must be better than 3% of the - * manufacturer's nominal value over specified operating temperature - * and voltage. Note that in some transceivers, transmitter supply - * voltage and receiver supply voltage are isolated. In that case, - * only one supply is monitored. Refer to the device specification - * for more detail. - */ - int total = 0; - int lmax = 8; - int val_i = 0; - int val_f = 0; - /* unit: 100 uV (1mV=1000uV) */ - total = transform_word_to_int(high_byte, low_byte); - val_i = ((total/10) / 1000); - val_f = ((total/10) - (val_i*1000)); - /* Return Unit: 1 Volt */ - return snprintf(buf_p, lmax, "%d.%03d\n", val_i, val_f); -} - - -int -_common_count_tx_bias(uint8_t high_byte, - uint8_t low_byte, - char *buf_p) { - /* [Note] - * Measured TX bias current in uA. Represented as a 16 bit unsigned - * integer with the current defined as the full 16 bit value (0-65535) - * with LSB equal to 2 uA, yielding a total range of 0 to 131 mA. - * Accuracy is vendor specific but must be better than 10% of the - * manufacturer's nominal value over specified operating temperature - * and voltage. - */ - int total = 0; - int lmax = 8; - int val_i = 0; - int val_f = 0; - /* unit: 2 uA (1mA=1000uA) */ - total = transform_word_to_int(high_byte, low_byte); - val_i = ((total*2) / 1000); - val_f = (((total*2) - (val_i*1000)) / 100); - /* Return Unit: 1 mA */ - return snprintf(buf_p, lmax, "%d.%01d\n", val_i, val_f); -} - - -int -_common_count_tx_power(uint8_t high_byte, - uint8_t low_byte, - char *buf_p) { - /* [Note] - * Measured TX output power in mW. Represented as a 16 bit unsigned - * integer with the power defined as the full 16 bit value (0-65535) - * with LSB equal to 0.1 uW, yielding a total range of 0 to 6.5535 mW - * (~ -40 to +8.2 dBm). Data is assumed to be based on measurement of - * laser monitor photodiode current. It is factory calibrated to absolute - * units using the most representative fiber output type. Accuracy is - * vendor specific but must be better than 3dB over specified temperature - * and voltage. Data is not valid when the transmitter is disabled. - */ - int total = 0; - int lmax = 8; - int val_i = 0; - int val_f = 0; - /* unit: 0.1 uW (1mW=1000uW) */ - total = transform_word_to_int(high_byte, low_byte); - val_i = ((total/10) / 1000); - val_f = ((total/10) - (val_i*1000)); - /* Return Unit: 1 mW */ - return snprintf(buf_p, lmax, "%d.%03d\n", val_i, val_f); -} - - -int -_common_count_rx_power(uint8_t high_byte, - uint8_t low_byte, - char *buf_p) { - /* [Note] - * Measured RX received optical power in mW. Value can represent either - * average received power or OMA depending upon how bit 3 of byte 92 (A0h) - * is set. Represented as a 16 bit unsigned integer with the power defined - * as the full 16 bit value (0-65535) with LSB equal to 0.1 uW, yielding a - * total range of 0 to 6.5535 mW (~ -40 to +8.2 dBm). Absolute accuracy is - * dependent upon the exact optical wavelength. For the vendor specified - * wavelength, accuracy shall be better than 3dB over specified temperature - * and voltage. - */ - int total = 0; - int lmax = 8; - int val_i = 0; - int val_f = 0; - /* unit: 0.1 uW (1mW=1000uW) */ - total = transform_word_to_int(high_byte, low_byte); - val_i = ((total/10) / 1000); - val_f = ((total/10) - (val_i*1000)); - /* Return Unit: 1 mW */ - return snprintf(buf_p, lmax, "%d.%03d\n", val_i, val_f); -} - - -int -_common_count_wavelength(struct transvr_obj_s *self, - uint8_t high_byte, - uint8_t low_byte) { - /* [Note] - * SFP : uint 1 um. - * QSFP: unit 0.05 um. - */ - int total = 0; - - total = transform_word_to_int(high_byte, low_byte); - switch (self->type) { - case TRANSVR_TYPE_SFP: - return total; - - case TRANSVR_TYPE_QSFP: - case TRANSVR_TYPE_QSFP_PLUS: - case TRANSVR_TYPE_QSFP_28: - return (total/20); - - default: - break; - } - return ERR_TRANSVR_UNDEFINED; -} - - -int -common_get_id(struct transvr_obj_s *self){ - - int err_code = _check_by_mode(self, - &_common_update_attr_id, - "common_get_id"); - if (err_code < 0){ - return err_code; - } - /* Transform to INT to show error case */ - return (int)self->id; -} - - -int -common_get_ext_id(struct transvr_obj_s *self){ - - int err_code = _check_by_mode(self, - &_common_update_attr_extended_id, - "common_get_ext_id"); - if (err_code < 0){ - return err_code; - } - /* Transform to INT to show error case */ - return (int)self->ext_id; -} - - -int -common_get_connector(struct transvr_obj_s *self){ - - int err_code = _check_by_mode(self, - &_common_update_attr_connector, - "common_get_connector"); - if (err_code < 0){ - return err_code; - } - /* Transform to INT to show error case */ - return (int)self->connector; -} - -int -common_get_eeprom(struct transvr_obj_s *self, char *buf){ - - int err = DEBUG_TRANSVR_INT_VAL; - unsigned char *eeprom_update = get_eeprom_update(); - - if (!(eeprom_update[self->port_no/8] & (1 << self->port_no%8)) && - (self->state == STATE_TRANSVR_CONNECTED && - self->mode == TRANSVR_MODE_POLLING && - TRANSVR_INFO_CACHE_ENABLE)) { - memset(buf, 0, self->eeprom_map_p->length_eeprom); - memcpy(buf, self->eeprom, self->eeprom_map_p->length_eeprom); - *(buf+self->eeprom_map_p->length_eeprom) = '\n'; - return self->eeprom_map_p->length_eeprom; - } - err = _check_by_mode(self, &_common_update_attr_eeprom, - "common_get_eeprom"); - if (err < 0){ - return snprintf(buf, LEN_TRANSVR_M_STR, "%d\n", err); - } - memset(buf, 0, self->eeprom_map_p->length_eeprom); - memcpy(buf, self->eeprom, self->eeprom_map_p->length_eeprom); - *(buf+self->eeprom_map_p->length_eeprom) = '\n'; - eeprom_update[self->port_no/8] &= ~(1 << self->port_no%8); - set_eeprom_update(eeprom_update); - return self->eeprom_map_p->length_eeprom; -} - - -int -common_get_vendor_name(struct transvr_obj_s *self, char *buf){ - - int err = DEBUG_TRANSVR_INT_VAL; - - if (self->state == STATE_TRANSVR_CONNECTED && - self->mode == TRANSVR_MODE_POLLING && - TRANSVR_INFO_CACHE_ENABLE) { - return snprintf(buf, LEN_TRANSVR_M_STR, "%s\n", self->vendor_name); - } - err = _check_by_mode(self, - &_common_update_attr_vendor_name, - "common_get_vendor_name"); - memset(buf, 0, LEN_TRANSVR_M_STR); - if (err < 0){ - return snprintf(buf, LEN_TRANSVR_M_STR, "%d\n", err); - } - return snprintf(buf, LEN_TRANSVR_M_STR, "%s\n", self->vendor_name); -} - - -int -common_get_vendor_pn(struct transvr_obj_s *self, char *buf) { - - int err = DEBUG_TRANSVR_INT_VAL; - - if (self->state == STATE_TRANSVR_CONNECTED && - self->mode == TRANSVR_MODE_POLLING && - TRANSVR_INFO_CACHE_ENABLE) { - return snprintf(buf, LEN_TRANSVR_M_STR, "%s\n", self->vendor_pn); - } - err = _check_by_mode(self, - &_common_update_attr_vendor_pn, - "common_get_vendor_pn"); - memset(buf, 0, LEN_TRANSVR_M_STR); - if (err < 0){ - return snprintf(buf, LEN_TRANSVR_M_STR, "%d\n", err); - } - return snprintf(buf, LEN_TRANSVR_M_STR, "%s\n", self->vendor_pn); -} - - -int -common_get_vendor_rev(struct transvr_obj_s *self, char *buf) { - - int err = DEBUG_TRANSVR_INT_VAL; - - if (self->state == STATE_TRANSVR_CONNECTED && - self->mode == TRANSVR_MODE_POLLING && - TRANSVR_INFO_CACHE_ENABLE) { - return snprintf(buf, LEN_TRANSVR_M_STR, "%s\n", self->vendor_rev); - } - err = _check_by_mode(self, - &_common_update_attr_vendor_rev, - "common_get_vendor_rev"); - memset(buf, 0, LEN_TRANSVR_M_STR); - if (err < 0){ - return snprintf(buf, LEN_TRANSVR_M_STR, "%d\n", err); - } - return snprintf(buf, LEN_TRANSVR_M_STR, "%s\n", self->vendor_rev); -} - - -int -common_get_vendor_sn(struct transvr_obj_s *self, char *buf) { - - int err = DEBUG_TRANSVR_INT_VAL; - - if (self->state == STATE_TRANSVR_CONNECTED && - self->mode == TRANSVR_MODE_POLLING && - TRANSVR_INFO_CACHE_ENABLE) { - return snprintf(buf, LEN_TRANSVR_M_STR, "%s\n", self->vendor_sn); - } - err = _check_by_mode(self, - &_common_update_attr_vendor_sn, - "common_get_vendor_sn"); - memset(buf, 0, LEN_TRANSVR_M_STR); - if (err < 0){ - return snprintf(buf, LEN_TRANSVR_M_STR, "%d\n", err); - } - return snprintf(buf, LEN_TRANSVR_M_STR, "%s\n", self->vendor_sn); -} - - -int -common_get_br(struct transvr_obj_s *self){ - - int err = DEBUG_TRANSVR_INT_VAL; - - if (self->state == STATE_TRANSVR_CONNECTED && - self->mode == TRANSVR_MODE_POLLING && - TRANSVR_INFO_CACHE_ENABLE) { - return (int)self->br; - } - err = _check_by_mode(self, - &_common_update_attr_br, - "common_get_br"); - if (err < 0){ - return err; - } - /* Transform to INT to show error case */ - return (int)self->br; -} - - -int -common_get_len_smf(struct transvr_obj_s *self){ - - int err = DEBUG_TRANSVR_INT_VAL; - - if (self->state == STATE_TRANSVR_CONNECTED && - self->mode == TRANSVR_MODE_POLLING && - TRANSVR_INFO_CACHE_ENABLE) { - return self->len_smf; - } - err = _check_by_mode(self, - &_common_update_attr_len_smf, - "common_get_len_smf"); - if (err < 0){ - return err; - } - return self->len_smf; -} - - -int -common_get_len_om1(struct transvr_obj_s *self){ - - int err = DEBUG_TRANSVR_INT_VAL; - - if (self->state == STATE_TRANSVR_CONNECTED && - self->mode == TRANSVR_MODE_POLLING && - TRANSVR_INFO_CACHE_ENABLE) { - return self->len_om1; - } - err = _check_by_mode(self, - &_common_update_attr_len_om1, - "common_get_len_om1"); - if (err < 0){ - return err; - } - return self->len_om1; -} - - -int -common_get_len_om2(struct transvr_obj_s *self){ - - int err = DEBUG_TRANSVR_INT_VAL; - - if (self->state == STATE_TRANSVR_CONNECTED && - self->mode == TRANSVR_MODE_POLLING && - TRANSVR_INFO_CACHE_ENABLE) { - return self->len_om2; - } - - err = _check_by_mode(self, - &_common_update_attr_len_om2, - "common_get_len_om2"); - if (err < 0){ - return err; - } - return self->len_om2; -} - - -int -common_get_len_om3(struct transvr_obj_s *self){ - - int err = DEBUG_TRANSVR_INT_VAL; - - if (self->state == STATE_TRANSVR_CONNECTED && - self->mode == TRANSVR_MODE_POLLING && - TRANSVR_INFO_CACHE_ENABLE) { - return self->len_om3; - } - - err = _check_by_mode(self, - &_common_update_attr_len_om3, - "common_get_len_om3"); - if (err < 0){ - return err; - } - return self->len_om3; -} - - -int -common_get_len_om4(struct transvr_obj_s *self){ - - int err = DEBUG_TRANSVR_INT_VAL; - - if (self->state == STATE_TRANSVR_CONNECTED && - self->mode == TRANSVR_MODE_POLLING && - TRANSVR_INFO_CACHE_ENABLE) { - return self->len_om4; - } - err = _check_by_mode(self, - &_common_update_attr_len_om4, - "common_get_len_om4"); - if (err < 0){ - return err; - } - return self->len_om4; -} - - -int -common_get_comp_extended(struct transvr_obj_s *self){ - - int err_code = _check_by_mode(self, - &_common_update_attr_transvr_comp_ext, - "common_get_comp_extended"); - if (err_code < 0){ - return err_code; - } - return self->transvr_comp_ext; -} - - -int -common_get_comp_rev(struct transvr_obj_s *self){ - - int err_code = _check_by_mode(self, - &_common_update_attr_comp_rev, - "common_get_comp_rev"); - if (err_code < 0){ - return err_code; - } - return self->comp_rev; -} - - -int -common_get_info(struct transvr_obj_s *self){ - - if (self->state != STATE_TRANSVR_CONNECTED) { - return self->state; - } - return self->info; -} - - -int -_common_get_if_lane(struct transvr_obj_s *self, - char *result){ - int i = 0; - int tmp_val = 0; - char tmp_str[LEN_TRANSVR_M_STR] = DEBUG_TRANSVR_STR_VAL; - - memset(result, 0, LEN_TRANSVR_M_STR); - - for (i=0; ilane_id); i++) { - tmp_val = self->lane_id[i]; - if (tmp_val < 1) { - break; - } - memset(tmp_str, 0, LEN_TRANSVR_M_STR); - if (i == 0) { - snprintf(tmp_str, LEN_TRANSVR_M_STR, "%d", tmp_val); - } else { - snprintf(tmp_str, LEN_TRANSVR_M_STR, ",%d", tmp_val); - } - strncat(result, tmp_str, LEN_TRANSVR_M_STR); - } - if (i == 0) { - return EVENT_TRANSVR_TASK_FAIL; - } - return 0; -} - - -int -common_get_if_lane(struct transvr_obj_s *self, - char *buf_p){ - - char tmp_str[LEN_TRANSVR_M_STR] = DEBUG_TRANSVR_STR_VAL; - - if (self->ioexp_obj_p->state != STATE_IOEXP_NORMAL) { - return snprintf(buf_p, LEN_TRANSVR_M_STR, "%d\n", ERR_TRANSVR_ABNORMAL); - } - if (_common_get_if_lane(self, tmp_str) < 0) { - return snprintf(buf_p, LEN_TRANSVR_M_STR, "%d\n" ,ERR_TRANSVR_ABNORMAL); - } - return snprintf(buf_p, LEN_TRANSVR_M_STR, "%s\n" ,tmp_str); -} - - -int -sfp_get_len_sm(struct transvr_obj_s *self){ - - int err_code = _check_by_mode(self, - &_sfp_update_attr_len_sm, - "sfp_get_len_sm"); - if (err_code < 0){ - return err_code; - } - return self->len_sm; -} - - -int -sfp_get_rate_id(struct transvr_obj_s *self){ - - int err_code = _check_by_mode(self, - &_sfp_update_attr_rate_id, - "sfp_get_rate_id"); - if (err_code < 0){ - return err_code; - } - return self->rate_id; -} - - -int -sfp_get_soft_rs0(struct transvr_obj_s *self){ - /* Note: - * SFP Soft Rate_Select Select [aka. "RS(0)"] address - * A2h, offset: 110, bit 3 (begin form 0) - */ - int err_code = DEBUG_TRANSVR_INT_VAL; - int bit_shift = 3; - uint8_t result = 0x00; - uint8_t bitmask = (1 << bit_shift); - - /* Check rate identifier is supported */ - err_code = self->get_rate_id(self); - if (err_code <= 0) { - return ERR_TRANSVR_NOTSUPPORT; - } - /* Update and check */ - err_code = _check_by_mode(self, - &_sfp_update_attr_soft_rs0, - "sfp_get_soft_rs0"); - if (err_code <0){ - return err_code; - } - result = (self->soft_rs0 & bitmask); - if (result == bitmask) { - return 1; - } - if (result == 0) { - return 0; - } - return ERR_TRANSVR_UNEXCPT; -} - - -int -sfp_get_soft_rs1(struct transvr_obj_s *self){ - /* Note: - * SFP Soft RS(1) Select address - * A2h, offset: 118, bit 3 (begin form 0) - */ - int err_code = DEBUG_TRANSVR_INT_VAL; - int bit_shift = 3; - uint8_t result = 0x00; - uint8_t bitmask = (1 << bit_shift); - - /* Check rate identifier is supported */ - err_code = self->get_rate_id(self); - if (err_code <= 0) { - return ERR_TRANSVR_NOTSUPPORT; - } - /* Update and check */ - err_code = _check_by_mode(self, - &_sfp_update_attr_soft_rs1, - "sfp_get_soft_rs1"); - if (err_code <0){ - return err_code; - } - result = (self->soft_rs1 & bitmask); - if (result == bitmask) { - return 1; - } - if (result == 0) { - return 0; - } - return ERR_TRANSVR_UNEXCPT; -} - - -int -sfp_get_transvr_temp(struct transvr_obj_s *self, - char *buf_p) { - - int lmax = 8; - int err_code = DEBUG_TRANSVR_INT_VAL; - - err_code = _check_by_mode(self, - &_sfp_update_attr_curr_temp, - "sfp_get_transvr_temp"); - if (err_code < 0) { - return snprintf(buf_p, lmax, "%d\n", err_code); - } - if ((self->curr_temp[0]) == DEBUG_TRANSVR_HEX_VAL) { - return snprintf(buf_p, lmax, "%d\n", ERR_TRANSVR_UPDATE_FAIL); - } - return _common_count_temp(self->curr_temp[0], - self->curr_temp[1], - buf_p); -} - - -int -sfp_get_transvr_voltage(struct transvr_obj_s *self, - char *buf_p) { - - int lmax = 8; - int err_code = DEBUG_TRANSVR_INT_VAL; - - err_code = _check_by_mode(self, - &_sfp_update_attr_curr_voltage, - "sfp_get_transvr_voltage"); - if (err_code < 0) { - return snprintf(buf_p, lmax, "%d\n", err_code); - } - if ((self->curr_voltage[0]) == DEBUG_TRANSVR_HEX_VAL) { - return snprintf(buf_p, lmax, "%d\n", ERR_TRANSVR_UPDATE_FAIL); - } - /* Return Unit: 1 Volt */ - return _common_count_voltage(self->curr_voltage[0], - self->curr_voltage[1], - buf_p); -} - - -int -sfp_get_transvr_tx_bias(struct transvr_obj_s *self, - char *buf_p) { - - int lmax = 8; - int err_code = DEBUG_TRANSVR_INT_VAL; - - err_code = _check_by_mode(self, - &_sfp_update_attr_curr_tx_bias, - "sfp_get_transvr_tx_bias"); - if (err_code < 0) { - return snprintf(buf_p, lmax, "%d\n", err_code); - } - if ((self->curr_tx_bias[0]) == DEBUG_TRANSVR_HEX_VAL) { - return snprintf(buf_p, lmax, "%d\n", ERR_TRANSVR_UPDATE_FAIL); - } - /* Return Unit: 1 mA */ - return _common_count_tx_bias(self->curr_tx_bias[0], - self->curr_tx_bias[1], - buf_p); -} - - -int -sfp_get_transvr_tx_power(struct transvr_obj_s *self, - char *buf_p) { - - int lmax = 8; - int err_code = DEBUG_TRANSVR_INT_VAL; - - err_code = _check_by_mode(self, - &_sfp_update_attr_curr_tx_power, - "sfp_get_transvr_tx_power"); - if (err_code < 0) { - return snprintf(buf_p, lmax, "%d\n", err_code); - } - if ((self->curr_tx_bias[0]) == DEBUG_TRANSVR_HEX_VAL) { - return snprintf(buf_p, lmax, "%d\n", ERR_TRANSVR_UPDATE_FAIL); - } - /* Return Unit: 1 mW */ - return _common_count_tx_power(self->curr_tx_power[0], - self->curr_tx_power[1], - buf_p); -} - - -int -sfp_get_transvr_rx_power(struct transvr_obj_s *self, - char *buf_p) { - - int lmax = 8; - int err_code = DEBUG_TRANSVR_INT_VAL; - - err_code = _check_by_mode(self, - &_sfp_update_attr_curr_rx_power, - "sfp_get_transvr_rx_power"); - if (err_code < 0) { - return snprintf(buf_p, lmax, "%d\n", err_code); - } - if ((self->curr_tx_bias[0]) == DEBUG_TRANSVR_HEX_VAL) { - return snprintf(buf_p, lmax, "%d\n", ERR_TRANSVR_UPDATE_FAIL); - } - /* Return Unit: 1 mW */ - return _common_count_rx_power(self->curr_rx_power[0], - self->curr_rx_power[0], - buf_p); -} - - -int -sfp_get_transvr_rx_em(struct transvr_obj_s *self, - char *buf_p) { - - int limt = 8; - int err = DEBUG_TRANSVR_INT_VAL; - - err = _check_by_mode(self, - &_sfp_update_attr_rx_em, - "sfp_get_transvr_rx_em"); - if (err < 0) { - return snprintf(buf_p, limt, "%d\n", err); - } - if ((self->tx_eq[0]) == DEBUG_TRANSVR_HEX_VAL) { - return snprintf(buf_p, limt, "%d\n", ERR_TRANSVR_UPDATE_FAIL); - } - return snprintf(buf_p, limt, "0x%02x\n", self->rx_em[0]); -} - - -int -sfp_get_transvr_tx_eq(struct transvr_obj_s *self, - char *buf_p) { - - int limt = 8; - int err = DEBUG_TRANSVR_INT_VAL; - - err = _check_by_mode(self, - &_sfp_update_attr_tx_eq, - "sfp_get_transvr_tx_eq"); - if (err < 0) { - return snprintf(buf_p, limt, "%d\n", err); - } - if ((self->tx_eq[0]) == DEBUG_TRANSVR_HEX_VAL) { - return snprintf(buf_p, limt, "%d\n", ERR_TRANSVR_UPDATE_FAIL); - } - return snprintf(buf_p, limt, "0x%02x\n", self->tx_eq[0]); -} - - -int -_sfp_get_comp_extended(struct transvr_obj_s *self) { - /* Address: A0h / 36 - * Reference: SFF-8024 TABLE 4-4 - */ - if ((self->state == STATE_TRANSVR_CONNECTED) || - (self->state == STATE_TRANSVR_INIT) ) { - return (int)(self->transvr_comp_ext); - } - return ERR_TRANSVR_ABNORMAL; -} - - -int -__sfp_get_comp_attr(struct transvr_obj_s *self, - int array_offset) { - /* SFP Specification Compliance: A0h / 3-10 - * transvr_comp[0-7] = 3 - 10 - */ - if ((self->state == STATE_TRANSVR_CONNECTED) || - (self->state == STATE_TRANSVR_INIT) ) { - return (int)(self->transvr_comp[array_offset]); - } - return ERR_TRANSVR_ABNORMAL; -} - - -int -_sfp_get_comp_10g_eth_comp(struct transvr_obj_s *self) { - /* transvr_comp[0] = address A0h / 3 - * - * 3 7: 10G Base-ER - * 3 6: 10GBASE-LRM - * 3 5: 10GBASE-LR - * 3 4: 10GBASE-SR - */ - int bitmask = 0xf0; /* 11110000 */ - return (__sfp_get_comp_attr(self, 0) & bitmask); -} - - -int -_sfp_get_comp_1g_eth_comp(struct transvr_obj_s *self) { - /* transvr_comp[3] = address A0h / 6 - * - * 6 7: BASE-PX *3 - * 6 6: BASE-BX10 *3 - * 6 5: 100BASE-FX - * 6 4: 100BASE-LX/LX10 - * 6 3: 1000BASE-T - * 6 2: 1000BASE-CX - * 6 1: 1000BASE-LX *3 - * 6 0: 1000BASE-SX - */ - return __sfp_get_comp_attr(self, 3); -} - - -int -_sfp_get_cable_tech(struct transvr_obj_s *self) { - /* transvr_comp[5] = address A0h / 8 - * - * 8 3: Active Cable *8 - * 8 2: Passive Cable *8 - */ - int bitmask = 0x0c; /* 00001100 */ - return (__sfp_get_comp_attr(self, 5) & bitmask); -} - - -int -sfp_get_comp_eth_1(struct transvr_obj_s *self){ - - int err_code = _check_by_mode(self, - &_common_update_attr_transvr_comp, - "sfp_get_comp_eth_1"); - if (err_code < 0){ - return err_code; - } - return _sfp_get_comp_1g_eth_comp(self); -} - - -int -sfp_get_comp_eth_10(struct transvr_obj_s *self){ - - int err_code = _check_by_mode(self, - &_common_update_attr_transvr_comp, - "sfp_get_comp_eth_10"); - if (err_code < 0){ - return err_code; - } - return _sfp_get_comp_10g_eth_comp(self); -} - - -int -_sfp_get_connector_type(struct transvr_obj_s *self) { - /* Address: A0h / 2 - * Reference: SFF-8024 TABLE 4-3 - */ - if ((self->state == STATE_TRANSVR_CONNECTED) || - (self->state == STATE_TRANSVR_INIT) ) { - return (int)(self->connector); - } - return ERR_TRANSVR_ABNORMAL; -} - - -int -sfp_get_wavelength(struct transvr_obj_s *self, - char *buf_p) { - /* [Note] Optical and Cable Variants Specification Compliance (SFF-8472) - * [Addr] A0h, Bytes 60-61 - * [Note] For optical variants, as defined by having zero's in A0h Byte 8 - * bits 2 and 3, Bytes 60 and 61 denote nominal transmitter output - * wavelength at room temperature. 16 bit value with byte 60 as high - * order byte and byte 61 as low order byte. The laser wavelength is - * equal to the 16 bit integer value in nm. This field allows the user - * to read the laser wavelength directly, so it is not necessary to - * infer it from the Transceiver Codes A0h Bytes 3 to 10 (see Table - * 5-3). This also allows specification of wavelengths not covered - * in the Transceiver Codes, such as those used in coarse WDM systems. - * - * For passive and active cable variants, a value of 00h for both A0h - * Byte 60 and Byte 61 denotes laser wavelength or cable specification - * compliance is unspecified. - */ - - int lmax = 8; - int err_code = DEBUG_TRANSVR_INT_VAL; - - err_code = _check_by_mode(self, - &_common_update_attr_wavelength, - "common_get_wavelength"); - if (err_code < 0) { - return snprintf(buf_p, lmax, "%d\n", err_code); - } - if ((self->wavelength[0]) == DEBUG_TRANSVR_HEX_VAL) { - return snprintf(buf_p, lmax, "%d\n", ERR_TRANSVR_UPDATE_FAIL); - } - /* unit: 1 um */ - return snprintf(buf_p, lmax, "%d\n", - _common_count_wavelength(self, - self->wavelength[0], - self->wavelength[1])); -} - - -int -sfp_get_1g_rj45_extphy_offset(struct transvr_obj_s *self, char *buf) { - - if (self->state != STATE_TRANSVR_CONNECTED) { - return ERR_TRANSVR_UNPLUGGED; - } - if ((self->info != TRANSVR_CLASS_BASE_T_1000) && - (self->info != TRANSVR_CLASS_BASE_T_1000_up) ){ - return ERR_TRANSVR_NOTSUPPORT; - } - return snprintf(buf, LEN_TRANSVR_S_STR, "0x%02x\n", self->extphy_offset); -} - - -int -sfp_get_1g_rj45_extphy_reg(struct transvr_obj_s *self, char *buf) { - - int i = 0; - int ret = 0; - int retry = 3; - int delay = 200; - - if (self->state != STATE_TRANSVR_CONNECTED) { - return ERR_TRANSVR_UNPLUGGED; - } - if ((self->info != TRANSVR_CLASS_BASE_T_1000) && - (self->info != TRANSVR_CLASS_BASE_T_1000_up) ){ - return ERR_TRANSVR_NOTSUPPORT; - } - if (_common_setup_page(self, VAL_TRANSVR_EXTPHY_ADDR_56, - -1, self->extphy_offset, 1, 0) < 0) { - return -EIO; - } - for (i=0; ii2c_client_p, self->extphy_offset); - if (ret >=0) { - goto ok_sfp_get_1g_rj45_extphy_reg; - } - msleep(delay); - } - SWPS_INFO("%s: retry:%d fail :%s :0x%02x\n", - __func__, retry, self->swp_name, self->extphy_offset); - return -EIO; - -ok_sfp_get_1g_rj45_extphy_reg: - ret = ((ret & 0x00ff) << 8) | ((ret & 0xff00) >> 8); - return snprintf(buf, LEN_TRANSVR_S_STR, "0x%04x\n", ret); -} - - -int -__qsfp_get_power_cls(struct transvr_obj_s *self, - int direct_access){ - - int err_code; - uint8_t detect_val; - - /* Detect and Update power class attribute */ - if (direct_access){ - err_code = _check_by_mode(self, - &_common_update_attr_extended_id, - "__qsfp_get_power_cls"); - } else { - err_code = self->ext_id; - } - if (err_code <0){ - return err_code; - } - if (err_code == DEBUG_TRANSVR_HEX_VAL){ - return ERR_TRANSVR_UPDATE_FAIL; - } - /* Clean data */ - detect_val = self->ext_id; - SWP_BIT_CLEAR(detect_val, 2); /* Bit2: CDR RX present */ - SWP_BIT_CLEAR(detect_val, 3); /* Bit3: CDR TX present */ - SWP_BIT_CLEAR(detect_val, 4); /* Bit4: CLEI present */ - SWP_BIT_CLEAR(detect_val, 5); /* Bit5: reserved */ - /* Identify power class */ - switch (detect_val) { - case 0: /* Class_1: 00000000 */ - return 1; - case 64: /* Class_2: 01000000 */ - return 2; - case 128: /* Class_3: 10000000 */ - return 3; - case 192: /* Class_4: 11000000 */ - return 4; - case 1: /* Class_5: 00000001 */ - case 193: /* Class_5: 11000001 */ - return 5; - case 2: /* Class_6: 00000010 */ - case 194: /* Class_6: 11000010 */ - return 6; - case 3: /* Class_7: 00000011 */ - case 195: /* Class_7: 11000011 */ - return 7; - default: - break; - } - SWPS_INFO("%s: Detect undefined power class:%d\n", __func__, detect_val); - return ERR_TRANSVR_UNDEFINED; -} - - -int -qsfp_get_power_cls(struct transvr_obj_s *self) { - return __qsfp_get_power_cls(self, 1); -} - - -int -__qsfp_get_cdr_present(struct transvr_obj_s *self, - int direct_access){ - - int retval; - int BIT_SHIFT = 2; - int BIT_MASK = 0x3; - - /* Detect and Update power class attribute */ - if (direct_access) { - retval = _check_by_mode(self, - &_common_update_attr_extended_id, - "__qsfp_get_cdr_present"); - if (retval < 0){ - return retval; - } - } - retval = self->ext_id; - if (retval == DEBUG_TRANSVR_HEX_VAL){ - return ERR_TRANSVR_UPDATE_FAIL; - } - /* Clean data and return */ - return (int)(retval >> BIT_SHIFT & BIT_MASK); -} - - -int -qsfp_get_cdr_present(struct transvr_obj_s *self) { - return __qsfp_get_cdr_present(self, 1); -} - - -int -qsfp_get_cdr(struct transvr_obj_s *self){ - - int err_code = _check_by_mode(self, - &_qsfp_update_attr_cdr, - "qsfp_get_cdr"); - if (err_code <0){ - return err_code; - } - - return self->cdr; -} - - -int -__qsfp_get_comp_attr(struct transvr_obj_s *self, - int array_offset) { - /* QSFP Specification Compliance: 00h / 131-138 - * transvr_comp[0-7] = 131 - 138 - */ - if ((self->state == STATE_TRANSVR_CONNECTED) || - (self->state == STATE_TRANSVR_INIT) ) { - return (int)(self->transvr_comp[array_offset]); - } - return ERR_TRANSVR_ABNORMAL; -} - - -int -_qsfp_get_comp_10_40_100_ethernet(struct transvr_obj_s *self) { - /* transvr_comp[0] = address 00h / 131 - * - * 131 7: Extended: See section 6.3.23. The Extended Specification Compliance - * Codes are maintained in the Transceiver Management section of SFF- - * 8024. - * 131 6: 10GBASE-LRM - * 131 5: 10GBASE-LR - * 131 4: 10GBASE-SR - * 131 3: 40GBASE-CR4 - * 131 2: 40GBASE-SR4 - * 131 1: 40GBASE-LR4 - * 131 0: 40G Active Cable (XLPPI) - */ - return __qsfp_get_comp_attr(self, 0); -} - - -int -_qsfp_get_comp_sonet(struct transvr_obj_s *self) { - /* transvr_comp[1] = address 00h / 132 - * - * 132 7-3: Reserved - * 132 2: OC 48, long reach - * 132 1: OC 48, intermediate reach - * 132 0: OC 48 short reach - */ - return __qsfp_get_comp_attr(self, 1); -} - - -int -_qsfp_get_comp_sas_sata(struct transvr_obj_s *self) { - /* transvr_comp[1] = address 00h / 132 - * - * 133 7: SAS 24.0 Gb/s - * 133 6: SAS 12.0 Gb/s - * 133 5: SAS 6.0 Gb/s - * 133 4: SAS 3.0 Gb/s - * 133 3-0: Reserved - */ - return __qsfp_get_comp_attr(self, 2); -} - - -int -_qsfp_get_comp_ethernet(struct transvr_obj_s *self) { - /* transvr_comp[1] = address 00h / 132 - * - * 134 7-4: Reserved - * 134 3: 1000BASE-T - * 134 2: 1000BASE-CX - * 134 1: 1000BASE-LX - * 134 0: 1000BASE-SX - */ - return __qsfp_get_comp_attr(self, 3); -} - - -int -_qsfp_get_comp_fc_link_length(struct transvr_obj_s *self) { - /* transvr_comp[1] = address 00h / 132 - * - * 135 7: Very long distance (V) - * 135 6: Short distance (S) - * 135 5: Intermediate distance (I) - * 135 4: Long distance (L) - * 135 3: Medium (M) - */ - int mask = 0xFC; /* 11111100 */ - return (__qsfp_get_comp_attr(self, 4) & mask); -} - - -int -_qsfp_get_comp_fc_trans_tech(struct transvr_obj_s *self) { - /* transvr_comp[1] = address 00h / 132 - * - * 135 2: Reserved - * 135 1: Longwave laser (LC) - * 135 0: Electrical inter-enclosure (EL) - * - * 136 7: Electrical intra-enclosure - * 136 6: Shortwave laser w/o OFC (SN) - * 136 5: Shortwave laser w OFC (SL) - * 136 4: Longwave Laser (LL) - * 136 3-0: Reserved - * - * return value = [bit 8-15:addr 135][bit 0-7:addr 136] - */ - int mask_135 = 7; /* 00000111 */ - int val_135 = (__qsfp_get_comp_attr(self, 4) & mask_135); - int val_136 = __qsfp_get_comp_attr(self, 5); - return ((val_135 << 7) + val_136); -} - - -int -_qsfp_get_comp_fc_trans_media(struct transvr_obj_s *self) { - /* transvr_comp[1] = address 00h / 132 - * - * 137 7: Twin Axial Pair (TW) - * 137 6: Shielded Twisted Pair (TP) - * 137 5: Miniature Coax (MI) - * 137 4: Video Coax (TV) - * 137 3: Multi-mode 62.5 m (M6) - * 137 2: Multi-mode 50 m (M5) - * 137 1: Multi-mode 50 um (OM3) - * 137 0: Single Mode (SM) - */ - return __qsfp_get_comp_attr(self, 6); -} - - -int -_qsfp_get_comp_fc_speed(struct transvr_obj_s *self) { - /* transvr_comp[1] = address 00h / 132 - * - * 138 7: 1200 MBps (per channel) - * 138 6: 800 MBps - * 138 5: 1600 MBps (per channel) - * 138 4: 400 MBps - * 138 3: 3200 MBps (per channel) - * 138 2: 200 MBps - * 138 1: Extended: See section 6.3.23. The Extended Specification - * Compliance Codes are maintained in the Transceiver Management - * section of SFF-8024. - * 138 0: 100 MBps - */ - return __qsfp_get_comp_attr(self, 7); -} - - -int -_qsfp_get_comp_extended(struct transvr_obj_s *self) { - /* Address: 00h / 192 - * Reference: SFF-8024 TABLE 4-4 - */ - if ((self->state == STATE_TRANSVR_CONNECTED) || - (self->state == STATE_TRANSVR_INIT) ) { - return (int)(self->transvr_comp_ext); - } - return ERR_TRANSVR_ABNORMAL; -} - - -int -qsfp_get_comp_eth(struct transvr_obj_s *self){ - - int err_code = _check_by_mode(self, - &_common_update_attr_transvr_comp, - "qsfp_get_comp_eth"); - if (err_code < 0){ - return err_code; - } - return _qsfp_get_comp_ethernet(self); -} - - -int -qsfp_get_comp_10_40(struct transvr_obj_s *self) { - - int err_code = _check_by_mode(self, - &_common_update_attr_transvr_comp, - "qsfp_get_comp_10_40"); - if (err_code < 0){ - return err_code; - } - return _qsfp_get_comp_10_40_100_ethernet(self); -} - - -int -_qsfp_get_connector_type(struct transvr_obj_s *self) { - /* Address: 00h / 130 - * Reference: SFF-8024 TABLE 4-3 - */ - if ((self->state == STATE_TRANSVR_CONNECTED) || - (self->state == STATE_TRANSVR_INIT) ) { - return (int)(self->connector); - } - return ERR_TRANSVR_ABNORMAL; -} - - -int -qsfp_get_transvr_temp(struct transvr_obj_s *self, - char *buf_p) { - - int lmax = 8; - int err_code = DEBUG_TRANSVR_INT_VAL; - - err_code = _check_by_mode(self, - &_qsfp_update_attr_curr_temp, - "qsfp_get_transvr_temp"); - if (err_code < 0) { - return snprintf(buf_p, lmax, "%d\n", err_code); - } - if ((self->curr_temp[0]) == DEBUG_TRANSVR_HEX_VAL) { - return snprintf(buf_p, lmax, "%d\n", ERR_TRANSVR_UPDATE_FAIL); - } - return _common_count_temp(self->curr_temp[0], - self->curr_temp[1], - buf_p); -} - - -int -qsfp_get_transvr_voltage(struct transvr_obj_s *self, - char *buf_p) { - - int lmax = 8; - int err_code = DEBUG_TRANSVR_INT_VAL; - - err_code = _check_by_mode(self, - &_qsfp_update_attr_curr_voltage, - "qsfp_get_transvr_voltage"); - if (err_code < 0) { - return snprintf(buf_p, lmax, "%d\n", err_code); - } - if ((self->curr_voltage[0]) == DEBUG_TRANSVR_HEX_VAL) { - return snprintf(buf_p, lmax, "%d\n", ERR_TRANSVR_UPDATE_FAIL); - } - /* Return Unit: 1 Volt */ - return _common_count_voltage(self->curr_voltage[0], - self->curr_voltage[1], - buf_p); -} - - -int -qsfp_get_transvr_tx_eq(struct transvr_obj_s *self, - char *buf_p) { - - int limt = 8; - int err = DEBUG_TRANSVR_INT_VAL; - - err = _check_by_mode(self, - &_qsfp_update_attr_tx_eq, - "qsfp_get_transvr_tx_eq"); - if (err < 0) { - return snprintf(buf_p, limt, "%d\n", err); - } - if ((self->tx_eq[0]) == DEBUG_TRANSVR_HEX_VAL) { - return snprintf(buf_p, limt, "%d\n", ERR_TRANSVR_UPDATE_FAIL); - } - return snprintf(buf_p, limt, "0x%02x%02x\n", - self->tx_eq[0], self->tx_eq[1]); -} - - -int -qsfp_get_transvr_rx_am(struct transvr_obj_s *self, - char *buf_p) { - - int limt = 8; - int err = DEBUG_TRANSVR_INT_VAL; - - err = _check_by_mode(self, - &_qsfp_update_attr_rx_am, - "qsfp_get_transvr_rx_am"); - if (err < 0) { - return snprintf(buf_p, limt, "%d\n", err); - } - if ((self->rx_am[0]) == DEBUG_TRANSVR_HEX_VAL) { - return snprintf(buf_p, limt, "%d\n", ERR_TRANSVR_UPDATE_FAIL); - } - return snprintf(buf_p, limt, "0x%02x%02x\n", - self->rx_am[0], self->rx_am[1]); -} - - -int -qsfp_get_transvr_rx_em(struct transvr_obj_s *self, - char *buf_p) { - - int limt = 8; - int err = DEBUG_TRANSVR_INT_VAL; - - err = _check_by_mode(self, - &_qsfp_update_attr_rx_em, - "qsfp_get_transvr_rx_em"); - if (err < 0) { - return snprintf(buf_p, limt, "%d\n", err); - } - if ((self->rx_em[0]) == DEBUG_TRANSVR_HEX_VAL) { - return snprintf(buf_p, limt, "%d\n", ERR_TRANSVR_UPDATE_FAIL); - } - return snprintf(buf_p, limt, "0x%02x%02x\n", - self->rx_em[0], self->rx_em[1]); -} - - -int -_qsfp_get_channel_diag(uint8_t *data_array, - int (*count_func)(uint8_t high_byte, uint8_t low_byte, char *buf_p), - char *ch_name, - char *result_p) { - int i, high, low; - int len_max = 128; - char ch_buf[4][16] = { DEBUG_TRANSVR_STR_VAL, - DEBUG_TRANSVR_STR_VAL, - DEBUG_TRANSVR_STR_VAL, - DEBUG_TRANSVR_STR_VAL }; - - for (i=0; i<4; i++) { - high = (i*2); - low = ((i*2) + 1); - count_func(data_array[high], data_array[low], ch_buf[i]); - } - return snprintf(result_p, len_max, - "%s-%d:%s%s-%d:%s%s-%d:%s%s-%d:%s", - ch_name, 1, ch_buf[0], - ch_name, 2, ch_buf[1], - ch_name, 3, ch_buf[2], - ch_name, 4, ch_buf[3]); -} - - -int -qsfp_get_soft_rx_los(struct transvr_obj_s *self, - char *buf_p) { - - int lmax = 8; - int mask = 0x0f; /* Bit 0 ~ Bit 3 */ - int err_code = DEBUG_TRANSVR_INT_VAL; - - err_code = _check_by_mode(self, - &_qsfp_update_attr_soft_rx_los, - "qsfp_get_soft_rx_los"); - if (err_code < 0) { - return snprintf(buf_p, lmax, "%d\n", err_code); - } - return snprintf(buf_p, lmax, "0x%02x\n", (self->rx_los & mask)); -} - - -int -qsfp_get_soft_tx_disable(struct transvr_obj_s *self, - char *buf_p) { - - int lmax = 8; - int mask = 0x0f; /* Bit 0 ~ Bit 3 */ - int err_code = DEBUG_TRANSVR_INT_VAL; - - err_code = _check_by_mode(self, - &_qsfp_update_attr_soft_tx_disable, - "qsfp_get_soft_tx_disable"); - if (err_code < 0) { - return snprintf(buf_p, lmax, "%d\n", err_code); - } - return snprintf(buf_p, lmax, "0x%02x\n", (self->tx_disable & mask)); -} - - -int -qsfp_get_soft_tx_fault(struct transvr_obj_s *self, - char *buf_p) { - - int lmax = 8; - int mask = 0x0f; /* Bit 0 ~ Bit 3 */ - int err_code = DEBUG_TRANSVR_INT_VAL; - - err_code = _check_by_mode(self, - &_qsfp_update_attr_soft_tx_fault, - "qsfp_get_soft_tx_fault"); - if (err_code < 0) { - return snprintf(buf_p, lmax, "%d\n", err_code); - } - return snprintf(buf_p, lmax, "0x%02x\n", (self->tx_fault & mask)); -} - - -int -qsfp_get_auto_tx_disable(struct transvr_obj_s *self, - char *buf_p) { - - if (self->auto_tx_disable == VAL_TRANSVR_FUNCTION_DISABLE) { - return snprintf(buf_p, LEN_TRANSVR_S_STR, - "%d\n", ERR_TRANSVR_FUNC_DISABLE); - } - return snprintf(buf_p, LEN_TRANSVR_S_STR, - "0x%02x\n", self->auto_tx_disable); -} - - -int -qsfp_get_transvr_tx_bias(struct transvr_obj_s *self, - char *buf_p) { - - int lmax = 8; - int err_code = DEBUG_TRANSVR_INT_VAL; - char *ch_name = "TX"; - - err_code = _check_by_mode(self, - &_qsfp_update_attr_curr_tx_bias, - "qsfp_get_transvr_tx_bias"); - if (err_code < 0) { - return snprintf(buf_p, lmax, "%d\n", err_code); - } - if ((self->curr_tx_bias[0]) == DEBUG_TRANSVR_HEX_VAL) { - return snprintf(buf_p, lmax, "%d\n", ERR_TRANSVR_UPDATE_FAIL); - } - /* Return Unit: 1 mA */ - return _qsfp_get_channel_diag(self->curr_tx_bias, - _common_count_tx_bias, - ch_name, - buf_p); -} - - -int -qsfp_get_transvr_tx_power(struct transvr_obj_s *self, - char *buf_p) { - - int lmax = 8; - int err_code = DEBUG_TRANSVR_INT_VAL; - char *ch_name = "TX"; - - err_code = _check_by_mode(self, - &_qsfp_update_attr_curr_tx_power, - "qsfp_get_transvr_tx_power"); - if (err_code < 0) { - return snprintf(buf_p, lmax, "%d\n", err_code); - } - if ((self->curr_tx_power[0]) == DEBUG_TRANSVR_HEX_VAL) { - return snprintf(buf_p, lmax, "%d\n", ERR_TRANSVR_UPDATE_FAIL); - } - /* Return Unit: 1 mW */ - return _qsfp_get_channel_diag(self->curr_tx_power, - _common_count_tx_power, - ch_name, - buf_p); -} - - -int -qsfp_get_transvr_rx_power(struct transvr_obj_s *self, - char *buf_p) { - - int lmax = 8; - int err_code = DEBUG_TRANSVR_INT_VAL; - char *ch_name = "RX"; - - err_code = _check_by_mode(self, - &_qsfp_update_attr_curr_rx_power, - "qsfp_get_transvr_rx_power"); - if (err_code < 0) { - return snprintf(buf_p, lmax, "%d\n", err_code); - } - if ((self->curr_tx_power[0]) == DEBUG_TRANSVR_HEX_VAL) { - return snprintf(buf_p, lmax, "%d\n", ERR_TRANSVR_UPDATE_FAIL); - } - /* Return Unit: 1 mW */ - return _qsfp_get_channel_diag(self->curr_rx_power, - _common_count_rx_power, - ch_name, - buf_p); -} - - -int -qsfp_get_wavelength(struct transvr_obj_s *self, - char *buf_p) { - /* [Desc] Wavelength or Copper Cable Attenuation (SFF-8636) - * [Addr] 00h 186-187 - * [Note] - * For optical free side devices, this parameter identifies the nominal - * transmitter output wavelength at room temperature. This parameter is - * a 16-bit hex value with Byte 186 as high order byte and Byte 187 as - * low order byte. The laser wavelength is equal to the 16-bit integer value - * divided by 20 in nm (units of 0.05 nm). This resolution should be adequate - * to cover all relevant wavelengths yet provide enough resolution for all - * expected DWDM applications. For accurate representation of controlled - * wavelength applications, this value should represent the center of the - * guaranteed wavelength range. - * If the free side device is identified as copper cable these registers will - * be used to define the cable attenuation. An indication of 0 dB attenuation - * refers to the case where the attenuation is not known or is unavailable. - * Byte 186 (00-FFh) is the copper cable attenuation at 2.5 GHz in units of 1 dB. - * Byte 187 (00-FFh) is the copper cable attenuation at 5.0 GHz in units of 1 dB. - */ - int lmax = 8; - int err_code = DEBUG_TRANSVR_INT_VAL; - - err_code = _check_by_mode(self, - &_common_update_attr_wavelength, - "common_get_wavelength"); - if (err_code < 0) { - return snprintf(buf_p, lmax, "%d\n", err_code); - } - if ((self->wavelength[0]) == DEBUG_TRANSVR_HEX_VAL) { - return snprintf(buf_p, lmax, "%d\n", ERR_TRANSVR_UPDATE_FAIL); - } - /* unit: 1 um */ - return snprintf(buf_p, lmax, "%d\n", - _common_count_wavelength(self, - self->wavelength[0], - self->wavelength[1])); -} - - -/* Public Function for Setup Features - */ -static int -__sfp_set_soft_rs(struct transvr_obj_s *self, - int input_val, - int address, - int page, - int offset, - int bit_shift, - uint8_t *attr_p, - char *caller, - int show_err) { - - int retval = ERR_TRANSVR_UNEXCPT; - int err_code = ERR_TRANSVR_UNEXCPT; - char *err_msg = DEBUG_TRANSVR_STR_VAL; - uint8_t update_val = (*attr_p); - - switch (input_val) { - case 0: - SWP_BIT_CLEAR(update_val, bit_shift); - break; - case 1: - SWP_BIT_SET(update_val, bit_shift); - break; - default: - retval = ERR_TRANSVR_UNEXCPT; - err_code = ERR_TRANSVR_UNEXCPT; - err_msg = "Exception occurs"; - goto err_private_sfp_set_soft_rs_1; - } - err_code = _common_set_uint8_attr(self, - address, - page, - offset, - update_val, - attr_p, - caller, - show_err); - if (err_code < 0) { - retval = err_code; - err_msg = "Write data via i2c fail!"; - goto err_private_sfp_set_soft_rs_1; - } - (*attr_p) = update_val; - return 0; - -err_private_sfp_set_soft_rs_1: - if (show_err) { - SWPS_INFO("%s: %s :%d :%s\n :%d\n", - __func__, err_msg, err_code, self->swp_name, input_val); - } - return retval; -} - - -static int -_sfp_set_soft_rs(struct transvr_obj_s *self, - int input_val, - int address, - int page, - int offset, - int bit_shift, - int (*attr_update_func)(struct transvr_obj_s *self, int show_err), - uint8_t *attr_p, - char *caller, - int show_err) { - - int retval = ERR_TRANSVR_UNEXCPT; - int err_code = ERR_TRANSVR_UNEXCPT; - char *err_msg = DEBUG_TRANSVR_STR_VAL; - - /* Check input value */ - if ((input_val != 0) && (input_val != 1)){ - retval = ERR_TRANSVR_BADINPUT; - err_code = ERR_TRANSVR_BADINPUT; - err_msg = "Input range incorrect!"; - goto err_common_sfp_set_soft_rs_1; - } - /* Check rate identifier is supported */ - err_code = self->get_rate_id(self); - if (err_code <= 0) { - switch (err_code) { - case 0: - retval = ERR_TRANSVR_NOTSUPPORT; - err_msg = "Not support this feature"; - break; - case ERR_TRANSVR_UNINIT: - retval = ERR_TRANSVR_UNINIT; - err_msg = "Check CDR present fail!"; - break; - case ERR_TRANSVR_UNPLUGGED: - retval = ERR_TRANSVR_UNPLUGGED; - err_msg = "Transceiver unplugged!"; - break; - default: - retval = err_code; - err_msg = "Check Rate_ID fail!"; - break; - } - goto err_common_sfp_set_soft_rs_1; - } - /* Check and update */ - err_code = _check_by_mode(self, - attr_update_func, - caller); - if ( (err_code < 0) || - ((*attr_p) == DEBUG_TRANSVR_HEX_VAL) ){ - retval = err_code; - err_msg = "Get current value fail!"; - goto err_common_sfp_set_soft_rs_1; - } - /* Generate and update value */ - return __sfp_set_soft_rs(self, - input_val, - address, - page, - offset, - bit_shift, - attr_p, - caller, - show_err); - -err_common_sfp_set_soft_rs_1: - if (show_err) { - SWPS_INFO("%s: %s :%d :%s\n :%d\n", - __func__, err_msg, err_code, self->swp_name, input_val); - } - return retval; -} - - -int -sfp_set_soft_rs0(struct transvr_obj_s *self, - int input_val) { - /* Note: - * SFP Soft Rate_Select Select RX ["RS(0)"] address - * A2h, offset: 110, bit 3 - */ - int bit_shift = 3; - int show_err = 1; - return _sfp_set_soft_rs(self, - input_val, - self->eeprom_map_p->addr_soft_rs0, - self->eeprom_map_p->page_soft_rs0, - self->eeprom_map_p->offset_soft_rs0, - bit_shift, - &_sfp_update_attr_soft_rs0, - &(self->soft_rs0), - "sfp_set_soft_rs0", - show_err); -} - - -int -sfp_set_soft_rs1(struct transvr_obj_s *self, - int input_val) { - /* Note: - * SFP Soft Rate_Select Select RX ["RS(1)"] address - * A2h, offset: 118, bit 3 - */ - int bit_shift = 3; - int show_err = 1; - return _sfp_set_soft_rs(self, - input_val, - self->eeprom_map_p->addr_soft_rs1, - self->eeprom_map_p->page_soft_rs1, - self->eeprom_map_p->offset_soft_rs1, - bit_shift, - &_sfp_update_attr_soft_rs1, - &(self->soft_rs1), - "sfp_set_soft_rs1", - show_err); -} - - -int -__sfp_set_tx_eq(struct transvr_obj_s *self, - int input, - int show_e) { - - int err = DEBUG_TRANSVR_INT_VAL; - char *emsg = DEBUG_TRANSVR_STR_VAL; - uint8_t setv = DEBUG_TRANSVR_HEX_VAL; - - if ((input < 0) || (input > 0xFF)) { - emsg = "input incorrect"; - err = ERR_TRANSVR_BADINPUT; - goto err_sfp_set_tx_eq; - } - setv = (uint8_t)input; - if (self->tx_eq[0] == setv) { - return 0; - } - err = _common_set_uint8_attr(self, - self->eeprom_map_p->addr_tx_eq, - self->eeprom_map_p->page_tx_eq, - self->eeprom_map_p->offset_tx_eq, - setv, - &(self->tx_eq[0]), - "_sfp_set_tx_eq", - show_e); - if (err < 0) { - emsg = "set_uint8_attr fail"; - goto err_sfp_set_tx_eq; - } - return 0; - -err_sfp_set_tx_eq: - if (show_e) { - SWPS_INFO("%s: %s :%d\n", __func__, emsg, input); - } - return err; -} - - -int -_sfp_set_tx_eq(struct transvr_obj_s *self, - int input, - int show_e) { - - uint8_t tmp; - int i = 0; - int retry = 3; - - for (i=0; itx_eq[0]; - if (_sfp_update_attr_tx_eq(self, show_e) < 0){ - continue; - } - if (self->tx_eq[0] == tmp){ - return 0; - } - } - return ERR_TRANSVR_UPDATE_FAIL; -} - - -int -sfp_set_tx_eq(struct transvr_obj_s *self, - int input) { - - int err = _check_by_mode(self, - &_sfp_update_attr_tx_eq, - "sfp_set_tx_eq"); - if (err < 0) { - SWPS_DEBUG("%s: check fail :%d\n", __func__, err); - return err; - } - return _sfp_set_tx_eq(self, input, 1); -} - - -int -__sfp_set_rx_em(struct transvr_obj_s *self, - int input, - int show_e) { - - int err = DEBUG_TRANSVR_INT_VAL; - char *emsg = DEBUG_TRANSVR_STR_VAL; - uint8_t setv = DEBUG_TRANSVR_HEX_VAL; - - if ((input < 0) || (input > 0xFF)) { - emsg = "input incorrect"; - err = ERR_TRANSVR_BADINPUT; - goto err_sfp_set_rx_em; - } - setv = (uint8_t)input; - if (self->rx_em[0] == setv) { - return 0; - } - err = _common_set_uint8_attr(self, - self->eeprom_map_p->addr_rx_em, - self->eeprom_map_p->page_rx_em, - self->eeprom_map_p->offset_rx_em, - setv, - &(self->rx_em[0]), - "_sfp_set_rx_em", - show_e); - if (err < 0) { - emsg = "set_uint8_attr fail"; - goto err_sfp_set_rx_em; - } - return 0; - -err_sfp_set_rx_em: - if (show_e) { - SWPS_INFO("%s: %s :%d\n", __func__, emsg, input); - } - return err; -} - - -int -_sfp_set_rx_em(struct transvr_obj_s *self, - int input, - int show_e) { - - uint8_t tmp; - int i = 0; - int retry = 3; - - for (i=0; irx_em[0]; - if (_sfp_update_attr_rx_em(self, show_e) < 0){ - continue; - } - if (self->rx_em[0] == tmp){ - return 0; - } - } - return -1; -} - - -int -sfp_set_rx_em(struct transvr_obj_s *self, - int input) { - - int err = _check_by_mode(self, - &_sfp_update_attr_rx_em, - "sfp_set_rx_em"); - if (err < 0) { - SWPS_DEBUG("%s: check fail :%d\n", __func__, err); - return err; - } - return _sfp_set_rx_em(self, input, 1); -} - - -int -sfp_set_1g_rj45_extphy_offset(struct transvr_obj_s *self, - int input) { - - if (self->state != STATE_TRANSVR_CONNECTED) { - return ERR_TRANSVR_UNPLUGGED; - } - if ((self->info != TRANSVR_CLASS_BASE_T_1000) && - (self->info != TRANSVR_CLASS_BASE_T_1000_up) ){ - return ERR_TRANSVR_NOTSUPPORT; - } - if ((input < 0) || (input > 0xff)) { - return ERR_TRANSVR_BADINPUT; - } - self->extphy_offset = (uint8_t)input; - return 0; -} - - -int -sfp_set_1g_rj45_extphy_reg(struct transvr_obj_s *self, - int input) { - - int i = 0; - int retry = 3; - int delay = 200; - uint16_t tmp = 0; - - if (self->state != STATE_TRANSVR_CONNECTED) { - return ERR_TRANSVR_UNPLUGGED; - } - if ((self->info != TRANSVR_CLASS_BASE_T_1000) && - (self->info != TRANSVR_CLASS_BASE_T_1000_up) ){ - return ERR_TRANSVR_NOTSUPPORT; - } - if ((input < 0) || (input > 0xffff)) { - return ERR_TRANSVR_BADINPUT; - } - tmp = ((input & 0x00ff) << 8) | ((input & 0xff00) >> 8); - if (_common_setup_page(self, VAL_TRANSVR_EXTPHY_ADDR_56, - -1, self->extphy_offset, 1, 0) < 0) { - return -EIO; - } - for (i=0; i<=retry; i++) { - if (i2c_smbus_write_word_data(self->i2c_client_p, - self->extphy_offset, - tmp) >= 0) { - return 0; - } - msleep(delay); - } - SWPS_INFO("%s: retry:%d fail :%s :0x%02x\n", - __func__, retry, self->swp_name, self->extphy_offset); - return -EIO; -} - - -static int -__qsfp_set_cdr(struct transvr_obj_s *self, - int input_val, - int show_err) { - - uint8_t update_val; - int CDR_FEATURE_SUPPORTED = 0x3; - int retval = ERR_TRANSVR_UNEXCPT; - int err_code = ERR_TRANSVR_UNEXCPT; - char *err_msg = DEBUG_TRANSVR_STR_VAL; - char *func_name = "__qsfp_set_cdr"; - - /* Check input value */ - if ((input_val < 0) || (input_val > 0xff)){ - retval = ERR_TRANSVR_BADINPUT; - err_code = ERR_TRANSVR_BADINPUT; - err_msg = "Input range incorrect!"; - goto err_qsfp_set_cdr_1; - } - update_val = (uint8_t)input_val; - /* Check CDR supported by transceiver */ - err_code = qsfp_get_cdr_present(self); - if (err_code < 0) { - retval = err_code; - switch (err_code) { - case ERR_TRANSVR_UNINIT: - err_msg = "Check CDR present fail!"; - break; - case ERR_TRANSVR_UNPLUGGED: - err_msg = "Transceiver unplugged!"; - break; - default: - err_msg = "Check CDR present fail!"; - break; - } - goto err_qsfp_set_cdr_1; - } - if (err_code != CDR_FEATURE_SUPPORTED) { - retval = ERR_TRANSVR_NOTSUPPORT; - err_msg = "This transceiver not support CDR!"; - goto err_qsfp_set_cdr_1; - } - /* Check and update */ - err_code = _check_by_mode(self, - &_qsfp_update_attr_cdr, - func_name); - if ( (err_code < 0) || - (self->cdr == DEBUG_TRANSVR_HEX_VAL) ){ - retval = err_code; - err_msg = "Get current value fail!"; - goto err_qsfp_set_cdr_1; - } - /* Write input value to transceiver */ - return _common_set_uint8_attr(self, - self->eeprom_map_p->addr_cdr, - self->eeprom_map_p->page_cdr, - self->eeprom_map_p->offset_cdr, - update_val, - &(self->cdr), - func_name, - show_err); - -err_qsfp_set_cdr_1: - if (show_err) { - SWPS_INFO("%s: %s :%d :%s\n :%d\n", - __func__, err_msg, err_code, self->swp_name, input_val); - } - return retval; -} - - -int -qsfp_set_cdr(struct transvr_obj_s *self, - int input_val) { - return __qsfp_set_cdr(self, input_val, 1); -} - - -int -qsfp_set_soft_tx_disable(struct transvr_obj_s *self, - int input_val) { - - int show_err = 1; - int in_max = 0xf; /* 1111 */ - int in_min = 0x0; /* 0000 */ - int retval = DEBUG_TRANSVR_INT_VAL; - int update_val = DEBUG_TRANSVR_INT_VAL; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - - retval = _check_by_mode(self, - &_qsfp_update_attr_soft_tx_disable, - "qsfp_set_soft_tx_disable"); - if (retval < 0) { - snprintf(err_msg, 63, "Not ready. err:%d", retval); - goto err_qsfp_set_soft_tx_disable; - } - if ((input_val > in_max) || - (input_val < in_min) ){ - retval = ERR_TRANSVR_BADINPUT; - snprintf(err_msg, 63, "Input value:%d incorrect!", input_val); - goto err_qsfp_set_soft_tx_disable; - } - if ((self->tx_disable & 0x0f) == input_val) { - return 0; - } - update_val = ((self->tx_disable & 0xf0) & input_val); - retval = _common_set_uint8_attr(self, - self->eeprom_map_p->addr_tx_disable, - self->eeprom_map_p->page_tx_disable, - self->eeprom_map_p->offset_tx_disable, - input_val, - &(self->tx_disable), - "qsfp_set_tx_disable", - show_err); - if (retval < 0) { - snprintf(err_msg, 63, "_common_set_uint8_attr:%d fail!", retval); - goto err_qsfp_set_soft_tx_disable; - } - return 0; - -err_qsfp_set_soft_tx_disable: - SWPS_INFO("%s: %s :%s\n", __func__, err_msg, self->swp_name); - return retval; -} - - -int -_qsfp_set_auto_tx_disable(struct transvr_obj_s *self, - uint8_t update) { - - uint8_t tx_enable = 0x0; - int show_e = 1; - int err = DEBUG_TRANSVR_INT_VAL; - char *emsg = DEBUG_TRANSVR_STR_VAL; - - /* Handle timing issues */ - if (update != tx_enable) { - /* Note: - * Because there are some txvr has timing issues, - * therefore we need to execute reset cycle first. - * (enable -> other settings) - */ - err = _common_set_uint8_attr(self, - self->eeprom_map_p->addr_tx_disable, - self->eeprom_map_p->page_tx_disable, - self->eeprom_map_p->offset_tx_disable, - tx_enable, - &(self->tx_disable), - "_qsfp_set_auto_tx_disable", - show_e); - if (err < 0) { - emsg = "I2C set reset value fail"; - goto err_qsfp_set_auto_tx_disable; - } - mdelay(10); - } - /* Setup target value */ - err = _common_set_uint8_attr(self, - self->eeprom_map_p->addr_tx_disable, - self->eeprom_map_p->page_tx_disable, - self->eeprom_map_p->offset_tx_disable, - self->auto_tx_disable, - &(self->tx_disable), - "_qsfp_set_auto_tx_disable", - show_e); - if (err < 0) { - emsg = "I2C set target value fail"; - goto err_qsfp_set_auto_tx_disable; - } - /* Check and update */ - err = _common_update_uint8_attr(self, - self->eeprom_map_p->addr_tx_disable, - self->eeprom_map_p->page_tx_disable, - self->eeprom_map_p->offset_tx_disable, - self->eeprom_map_p->length_tx_disable, - &(self->tx_disable), - "_qsfp_set_auto_tx_disable", - show_e); - if (err < 0) { - emsg = "I2C get value fail"; - goto err_qsfp_set_auto_tx_disable; - } - if (self->tx_disable != update) { - emsg = "data not become effective"; - goto err_qsfp_set_auto_tx_disable; - } - return 0; - -err_qsfp_set_auto_tx_disable: - SWPS_DEBUG("%s: %s :%s\n", - __func__, emsg, self->swp_name); - return ERR_TRANSVR_UPDATE_FAIL; -} - - -int -qsfp_set_auto_tx_disable(struct transvr_obj_s *self, - int input_val) { - - int in_max = 0xf; /* 1111 */ - int in_min = 0x0; /* 0000 */ - int retval = DEBUG_TRANSVR_INT_VAL; - char *emsg = DEBUG_TRANSVR_STR_VAL; - - /* Update settings*/ - if (input_val == VAL_TRANSVR_FUNCTION_DISABLE) { - emsg = "User disable auto tx_disable"; - self->auto_tx_disable = VAL_TRANSVR_FUNCTION_DISABLE; - goto out_qsfp_set_auto_tx_disable; - } - if ((input_val > in_max) || (input_val < in_min) ){ - SWPS_INFO("%s: Input value:%d incorrect! :%s\n", - __func__, input_val, self->swp_name); - return ERR_TRANSVR_BADINPUT; - } - self->auto_tx_disable = input_val; - /* Check current soft tx_disable */ - retval = _check_by_mode(self, - &_qsfp_update_attr_soft_tx_disable, - "qsfp_set_auto_tx_disable"); - switch (retval) { - case 0: - break; - case ERR_TRANSVR_UNPLUGGED: - emsg = "Doesn't need to update"; - goto out_qsfp_set_auto_tx_disable; - default: - SWPS_INFO("%s: setup fail :%d :%s\n", - __func__, retval, self->swp_name); - return retval; - } - return _qsfp_set_auto_tx_disable(self, input_val); - -out_qsfp_set_auto_tx_disable: - SWPS_DEBUG("%s: %s :%s :%d\n :%d", - __func__, emsg, self->swp_name, input_val, retval); - return 0; -} - - -int -__qsfp_set_tx_eq(struct transvr_obj_s *self, - int input, - int show_e) { - /* [Note] - * 0x - */ - int err = DEBUG_TRANSVR_INT_VAL; - char *emsg = DEBUG_TRANSVR_STR_VAL; - uint8_t setv[2] = {0x00, 0x00}; - - if ((input < 0) || (input > 0xFFFF)) { - emsg = "input incorrect"; - err = ERR_TRANSVR_BADINPUT; - goto err_qsfp_set_tx_eq; - } - setv[0] = (uint8_t)((input & 0xFF00) >> 8); - setv[1] = (uint8_t)(input & 0xFF); - if ((self->tx_eq[0] == setv[0]) && - (self->tx_eq[1] == setv[1]) ) { - return 0; - } - err = _common_set_uint8_array(self, - self->eeprom_map_p->addr_tx_eq, - self->eeprom_map_p->page_tx_eq, - self->eeprom_map_p->offset_tx_eq, - self->eeprom_map_p->length_tx_eq, - setv, - self->tx_eq, - "_qsfp_set_tx_eq", - show_e); - if (err < 0) { - emsg = "set_uint8_array fail"; - goto err_qsfp_set_tx_eq; - } - return 0; - -err_qsfp_set_tx_eq: - if (show_e) { - SWPS_INFO("%s: %s :%d\n", __func__, emsg, input); - } - return err; -} - - -int -_qsfp_set_tx_eq(struct transvr_obj_s *self, - int input, - int show_e) { - - int i = 0; - int retry = 3; - uint8_t tmp[2]; - - for (i=0; itx_eq[0]; - tmp[1] = self->tx_eq[1]; - if (_qsfp_update_attr_tx_eq(self, show_e) < 0){ - continue; - } - if ((self->tx_eq[0] == tmp[0]) && - (self->tx_eq[1] == tmp[1]) ){ - return 0; - } - } - return -1; -} - - -int -qsfp_set_tx_eq(struct transvr_obj_s *self, - int input) { - - int err = _check_by_mode(self, - &_qsfp_update_attr_tx_eq, - "qsfp_set_tx_eq"); - if (err < 0) { - SWPS_DEBUG("%s: check fail :%d\n", __func__, err); - return err; - } - return _qsfp_set_tx_eq(self, input, 1); -} - - -int -__qsfp_set_rx_am(struct transvr_obj_s *self, - int input, - int show_e) { - /* [Note] - * 0x - */ - int err = DEBUG_TRANSVR_INT_VAL; - char *emsg = DEBUG_TRANSVR_STR_VAL; - uint8_t setv[2] = {0x00, 0x00}; - - if ((input < 0) || (input > 0xFFFF)) { - emsg = "input incorrect"; - err = ERR_TRANSVR_BADINPUT; - goto err_qsfp_set_rx_am; - } - setv[0] = (uint8_t)((input & 0xFF00) >> 8); - setv[1] = (uint8_t)(input & 0xFF); - if ((self->rx_am[0] == setv[0]) && - (self->rx_am[1] == setv[1]) ) { - return 0; - } - err = _common_set_uint8_array(self, - self->eeprom_map_p->addr_rx_am, - self->eeprom_map_p->page_rx_am, - self->eeprom_map_p->offset_rx_am, - self->eeprom_map_p->length_rx_am, - setv, - self->rx_am, - "_qsfp_set_rx_am", - show_e); - if (err < 0) { - emsg = "set_uint8_array fail"; - goto err_qsfp_set_rx_am; - } - return 0; - -err_qsfp_set_rx_am: - if (show_e) { - SWPS_INFO("%s: %s :%d\n", __func__, emsg, input); - } - return err; -} - - -int -_qsfp_set_rx_am(struct transvr_obj_s *self, - int input, - int show_e) { - - int i = 0; - int retry = 3; - uint8_t tmp[2]; - - for (i=0; irx_am[0]; - tmp[1] = self->rx_am[1]; - if (_qsfp_update_attr_rx_am(self, show_e) < 0){ - continue; - } - if ((self->rx_am[0] == tmp[0]) && - (self->rx_am[1] == tmp[1]) ){ - return 0; - } - } - return -1; -} - - -int -qsfp_set_rx_am(struct transvr_obj_s *self, - int input) { - - int err = _check_by_mode(self, - &_qsfp_update_attr_rx_am, - "qsfp_set_rx_am"); - if (err < 0) { - SWPS_DEBUG("%s: check fail :%d\n", __func__, err); - return err; - } - return _qsfp_set_rx_am(self, input, 1); -} - - -int -__qsfp_set_rx_em(struct transvr_obj_s *self, - int input, - int show_e) { - /* [Note] - * 0x - */ - int err = DEBUG_TRANSVR_INT_VAL; - char *emsg = DEBUG_TRANSVR_STR_VAL; - uint8_t setv[2] = {0x00, 0x00}; - - if ((input < 0) || (input > 0xFFFF)) { - emsg = "input incorrect"; - err = ERR_TRANSVR_BADINPUT; - goto err_qsfp_set_rx_em; - } - setv[0] = (uint8_t)((input & 0xFF00) >> 8); - setv[1] = (uint8_t)(input & 0xFF); - if ((self->rx_em[0] == setv[0]) && - (self->rx_em[1] == setv[1]) ) { - return 0; - } - err = _common_set_uint8_array(self, - self->eeprom_map_p->addr_rx_em, - self->eeprom_map_p->page_rx_em, - self->eeprom_map_p->offset_rx_em, - self->eeprom_map_p->length_rx_em, - setv, - self->rx_em, - "_qsfp_set_rx_em", - show_e); - if (err < 0) { - emsg = "set_uint8_array fail"; - goto err_qsfp_set_rx_em; - } - return 0; - -err_qsfp_set_rx_em: - if (show_e) { - SWPS_INFO("%s: %s :%d\n", __func__, emsg, input); - } - return err; -} - - -int -_qsfp_set_rx_em(struct transvr_obj_s *self, - int input, - int show_e) { - - int i = 0; - int retry = 3; - uint8_t tmp[2]; - - for (i=0; irx_em[0]; - tmp[1] = self->rx_em[1]; - if (_qsfp_update_attr_rx_em(self, show_e) < 0){ - continue; - } - if ((self->rx_em[0] == tmp[0]) && - (self->rx_em[1] == tmp[1]) ){ - return 0; - } - } - return -1; -} - - -int -qsfp_set_rx_em(struct transvr_obj_s *self, - int input) { - - int err = _check_by_mode(self, - &_qsfp_update_attr_rx_em, - "qsfp_set_rx_em"); - if (err < 0) { - SWPS_DEBUG("%s: check fail :%d\n", __func__, err); - return err; - } - return _qsfp_set_rx_em(self, input, 1); -} - - -int -common_transvr_dump(struct transvr_obj_s* self){ - - char *type_name = "Undefined"; - - if (TRANSVR_INFO_DUMP_ENABLE != 1) { - return 0; - } - switch (self->type) { - case TRANSVR_TYPE_SFP: - type_name = STR_TRANSVR_SFP; - break; - case TRANSVR_TYPE_QSFP: - type_name = STR_TRANSVR_QSFP; - break; - case TRANSVR_TYPE_QSFP_PLUS: - type_name = STR_TRANSVR_QSFP_PLUS; - break; - case TRANSVR_TYPE_QSFP_28: - type_name = STR_TRANSVR_QSFP28; - break; - case TRANSVR_TYPE_FAKE: - type_name = "FAKE"; - goto ok_common_transvr_dump; - case TRANSVR_TYPE_UNPLUGGED: - type_name = "UNPLUGGED"; - goto err_common_transvr_dump; - case TRANSVR_TYPE_INCONSISTENT: - type_name = "INCONSISTENT"; - goto err_common_transvr_dump; - case TRANSVR_TYPE_ERROR: - type_name = "ERROR"; - goto err_common_transvr_dump; - - default: - type_name = "UNEXPECTED"; - goto err_common_transvr_dump; - } - printk(KERN_INFO "[SWPS] Dump %s information:\n", self->swp_name); - printk(KERN_INFO " |- :%s\n", type_name); - printk(KERN_INFO " |- :%s\n", self->vendor_name); - printk(KERN_INFO " |- :%s\n", self->vendor_pn); - printk(KERN_INFO " |- :%s\n", self->vendor_rev); - printk(KERN_INFO " |- :%s\n", self->vendor_sn); - printk(KERN_INFO " |- :0x%02x\n", self->br); - printk(KERN_INFO " |- :0x%02x\n", self->comp_rev); - printk(KERN_INFO " |- :%d\n", self->len_om1); - printk(KERN_INFO " |- :%d\n", self->len_om2); - printk(KERN_INFO " |- :%d\n", self->len_om3); - printk(KERN_INFO " |- :%d\n", self->len_om4); - return 0; - -ok_common_transvr_dump: - SWPS_INFO("%s: %s is %s\n", __func__, self->swp_name, type_name); - return 0; - -err_common_transvr_dump: - SWPS_INFO("%s: %s is %s\n", __func__, self->swp_name, type_name); - return -1; -} - - -int -sfp_transvr_dump(struct transvr_obj_s* self) { - - if (TRANSVR_INFO_DUMP_ENABLE != 1) { - return 0; - } - if (common_transvr_dump(self) < 0) { - return -1; - } - printk(KERN_INFO " |- :%d\n", self->len_sm); - printk(KERN_INFO " |- :%d\n", self->len_smf); - printk(KERN_INFO " '- :0x%02x\n", self->rate_id); - return 0; -} - - -int -qsfp_transvr_dump(struct transvr_obj_s* self) { - - if (TRANSVR_INFO_DUMP_ENABLE != 1) { - return 0; - } - if (common_transvr_dump(self) < 0) { - return -1; - } - printk(KERN_INFO " |- :%d\n", self->len_smf); - printk(KERN_INFO " '- :Class_%d\n", __qsfp_get_power_cls(self, 0)); - return 0; -} - - -int -fake_transvr_dump(struct transvr_obj_s* self) { - - printk(KERN_INFO "[SWPS] Dump transceiver information: %s\n", self->swp_name); - printk(KERN_INFO " |- :FAKE\n"); - printk(KERN_INFO " |- :FAKE_VENDER_NAME\n"); - printk(KERN_INFO " |- :FAKE_VENDER_PN\n"); - printk(KERN_INFO " |- :FAKE_VENDER_REV\n"); - printk(KERN_INFO " |- :FAKE_VENDER_SN\n"); - printk(KERN_INFO " |- :0x99\n"); - printk(KERN_INFO " |- :99\n"); - printk(KERN_INFO " |- :99\n"); - printk(KERN_INFO " |- :99\n"); - printk(KERN_INFO " |- :99\n"); - printk(KERN_INFO " |- :99\n"); - printk(KERN_INFO " |- :99\n"); - printk(KERN_INFO " '- :0x99\n"); - return 0; -} - - -/* ========== Object functions for fake type ========== - */ -int -fake_transvr_update(struct transvr_obj_s *self, - int show_err){ - self->state = STATE_TRANSVR_CONNECTED; - return 0; -} - - -int -fake_get_binary(struct transvr_obj_s *self){ - return 1; -} - -int -fake_get_int(struct transvr_obj_s *self){ - return 99; -} - - -int -fake_get_hex(struct transvr_obj_s *self){ - return 0x0f; -} - - -int -fake_get_str(struct transvr_obj_s *self, char *buf) { - return snprintf(buf, 16, "fake_get_str\n"); -} - - -int -fake_set_int(struct transvr_obj_s *self, int input){ - SWPS_INFO("%s: %d\n", __func__, input); - return 0; -} - - -int -fake_set_hex(struct transvr_obj_s *self, int input){ - SWPS_INFO("%s: 0x%02x\n", __func__, input); - return 0; -} - - -/* ========== Object functions for unsupported ========== - */ -int -unsupported_get_func(struct transvr_obj_s *self){ - return ERR_TRANSVR_NOTSUPPORT; -} - - -int -unsupported_get_func2(struct transvr_obj_s *self, - char *buf_p) { - int len = snprintf(buf_p, 8, "%d\n", ERR_TRANSVR_NOTSUPPORT); - return len; -} - - -int -unsupported_set_func(struct transvr_obj_s *self, - int input_val){ - return ERR_TRANSVR_NOTSUPPORT; -} - - - -/* ========== Object functions for long term task ========== - * - * [Note] - * SWPS transceiver worker is likely the green-thread (coroutine). - * Due to resource and performance considerations. SWPS run all - * features in one kthread at the same time, and handle by it self. - */ - -/* For Transceiver Task Handling - */ -static struct transvr_worker_s * -transvr_task_get(struct transvr_obj_s *self, - char *func_name) { - - struct transvr_worker_s *curr_p = self->worker_p; - - while(curr_p != NULL){ - if (strcmp((curr_p->func_name), func_name) == 0 ) { - return curr_p; - } - curr_p = curr_p->next_p; - } - return NULL; -} - - -static struct transvr_worker_s* -transvr_task_creat(struct transvr_obj_s *self, - int (*main_task)(struct transvr_worker_s *task), - int (*post_task)(struct transvr_worker_s *task), - char *caller) { - - struct transvr_worker_s *task_p = NULL; - struct transvr_worker_s *curr_p = NULL; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - - /* Check task not exist */ - task_p = transvr_task_get(self, caller); - if (task_p) { - snprintf(err_msg, sizeof(err_msg), "Task already created!"); - goto err_transvr_task_creat; - } - /* Create task worker */ - task_p = kzalloc(sizeof(struct transvr_worker_s), GFP_KERNEL); - if (!task_p){ - snprintf(err_msg, sizeof(err_msg), "kzalloc fail"); - goto err_transvr_task_creat; - } - /* Setup task data */ - task_p->transvr_p = self; - task_p->next_p = NULL; - task_p->trigger_time = 0; - task_p->retry = 1; - task_p->state = STATE_T_TASK_INIT; - task_p->main_task = main_task; - task_p->post_task = post_task; - task_p->p_data = NULL; - snprintf(task_p->func_name, sizeof(task_p->func_name), "%s", caller); - /* Setup Link List */ - if (self->worker_p) { - curr_p = self->worker_p; - while(curr_p->next_p != NULL) { - curr_p = curr_p->next_p; - } - curr_p->next_p = task_p; - task_p->pre_p = curr_p; - } else { - self->worker_p = task_p; - task_p->pre_p = NULL; - } - return task_p; - -err_transvr_task_creat: - SWPS_ERR("%s: %s :%s :%s\n", - __func__, err_msg, caller, self->swp_name); - return NULL; -} - - -static void -transvr_task_free_one(struct transvr_worker_s *task_p){ - - struct transvr_worker_s *pre_p = NULL; - struct transvr_worker_s *next_p = NULL; - - if (task_p) { - pre_p = task_p->pre_p; - next_p = task_p->next_p; - - if ((pre_p) && (next_p)) { - pre_p->next_p = next_p; - next_p->pre_p = pre_p; - - } else if ((!pre_p) && (next_p)) { - next_p->pre_p = NULL; - - } else if ((pre_p) && (!next_p)) { - pre_p->next_p = NULL; - - } else if ((!pre_p) && (!next_p)) { - task_p->transvr_p->worker_p = NULL; - } else { - SWPS_ERR("%s: Unexcept case!\n :%s", - __func__, task_p->transvr_p->swp_name); - } - kfree(task_p->p_data); - kfree(task_p); - } -} - - -static void -transvr_task_free_all(struct transvr_obj_s *self) { - - struct transvr_worker_s *curr_p = NULL; - struct transvr_worker_s *next_p = NULL; - - if (self->worker_p) { - curr_p = self->worker_p; - while(curr_p) { - next_p = curr_p->next_p; - transvr_task_free_one(curr_p); - curr_p = next_p; - } - self->worker_p = NULL; - } -} - - -static void -transvr_cache_free_all(struct transvr_obj_s *self) { - - memset(self->vendor_name, 0, (LEN_TRANSVR_M_STR * sizeof(char)) ); - memset(self->vendor_rev, 0, (LEN_TRANSVR_M_STR * sizeof(char)) ); - memset(self->vendor_pn, 0, (LEN_TRANSVR_M_STR * sizeof(char)) ); - memset(self->vendor_sn, 0, (LEN_TRANSVR_M_STR * sizeof(char)) ); - self->extphy_offset = 0; -} - -static int -_transvr_task_run_main(struct transvr_worker_s *task_p) { - - int retval = DEBUG_TRANSVR_INT_VAL; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - - if (!task_p){ - snprintf(err_msg, sizeof(err_msg), "main_task is NULL!"); - goto main_transvr_task_err; - } - if ((task_p->trigger_time) == 0){ - goto main_transvr_task_run; - } - if (time_before(jiffies, task_p->trigger_time)){ - goto main_transvr_task_wait; - } - goto main_transvr_task_run; - -main_transvr_task_run: - if (task_p->retry != VAL_TRANSVR_TASK_RETRY_FOREVER) { - task_p->retry -= 1; - } - retval = task_p->main_task(task_p); - if (retval < 0) { - if (task_p->retry > 0) { - task_p->state = STATE_T_TASK_WAIT; - return EVENT_TRANSVR_TASK_WAIT; - } - snprintf(err_msg, sizeof(err_msg), "Run main_task fail!"); - goto main_transvr_task_err; - } - goto main_transvr_task_identify; - -main_transvr_task_identify: - switch (retval) { - case EVENT_TRANSVR_TASK_WAIT: - task_p->state = STATE_T_TASK_WAIT; - return EVENT_TRANSVR_TASK_WAIT; - - case EVENT_TRANSVR_TASK_DONE: - task_p->state = STATE_T_TASK_DONE; - return EVENT_TRANSVR_TASK_DONE; - - default: - break; - } - snprintf(err_msg, sizeof(err_msg), "Run main_task fail!"); - goto main_transvr_task_err; - -main_transvr_task_wait: - task_p->state = STATE_T_TASK_WAIT; - return EVENT_TRANSVR_TASK_WAIT; - -main_transvr_task_err: - task_p->state = STATE_T_TASK_FAIL; - SWPS_INFO("%s: %s :%d :%s\n", - __func__, err_msg, retval, task_p->transvr_p->swp_name); - return EVENT_TRANSVR_INIT_FAIL; -} - - -static int -_transvr_task_run_post(struct transvr_worker_s *task_p) { - - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - - if ((task_p->post_task) == NULL) { - return EVENT_TRANSVR_TASK_DONE; - } - switch (task_p->state) { - case STATE_T_TASK_WAIT: - case STATE_T_TASK_INIT: - goto post_transvr_task_wait; - - case STATE_T_TASK_DONE: - case STATE_T_TASK_FAIL: - goto post_transvr_task_run; - - default: - break; - } - snprintf(err_msg, sizeof(err_msg), "Unexcept task state"); - goto post_transvr_task_err; - -post_transvr_task_run: - task_p->post_task(task_p); - return EVENT_TRANSVR_TASK_DONE; - -post_transvr_task_wait: - return EVENT_TRANSVR_TASK_WAIT; - -post_transvr_task_err: - SWPS_INFO("%s: %s :%d :%s\n", - __func__, err_msg, task_p->state, task_p->transvr_p->swp_name); - return EVENT_TRANSVR_TASK_FAIL; -} - - -static int -transvr_task_run_one(struct transvr_worker_s *task_p) { - - int retval_main = DEBUG_TRANSVR_INT_VAL; - int retval_post = DEBUG_TRANSVR_INT_VAL; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - - retval_main = _transvr_task_run_main(task_p); - if (retval_main < 0) { - snprintf(err_msg, sizeof(err_msg), "Execute main_task fail!"); - goto err_transvr_task_run_one; - } - retval_post = _transvr_task_run_post(task_p); - if (retval_post < 0) { - snprintf(err_msg, sizeof(err_msg), "Execute post_task fail!"); - goto err_transvr_task_run_one; - } - return retval_main; - -err_transvr_task_run_one: - SWPS_INFO("%s: %s
:%d :%d :%s :%s\n", - __func__, err_msg, retval_main, retval_post, - task_p->func_name, task_p->transvr_p->swp_name); - return EVENT_TRANSVR_TASK_FAIL; -} - - -static int -transvr_task_run_all(struct transvr_obj_s *self) { - - int haserr = 0; - int retval = DEBUG_TRANSVR_INT_VAL; - struct transvr_worker_s *curr_p = NULL; - struct transvr_worker_s *next_p = NULL; - - if ((self->worker_p) == NULL) { - return EVENT_TRANSVR_TASK_DONE; - } - curr_p = self->worker_p; - while (curr_p != NULL) { - next_p = curr_p->next_p; - retval = transvr_task_run_one(curr_p); - if (curr_p->retry == VAL_TRANSVR_TASK_RETRY_FOREVER) { - curr_p = next_p; - continue; - } - switch (retval) { - case EVENT_TRANSVR_TASK_WAIT: - break; - case EVENT_TRANSVR_TASK_DONE: - transvr_task_free_one(curr_p); - break; - case EVENT_TRANSVR_TASK_FAIL: - - default: - haserr = 1; - transvr_task_free_one(curr_p); - break; - } - curr_p = next_p; - } - if (haserr) { - return EVENT_TRANSVR_TASK_FAIL; - } - return EVENT_TRANSVR_TASK_DONE; -} - - -static void -transvr_task_set_delay(struct transvr_worker_s *task_p, - unsigned long delay_msec) { - - task_p->trigger_time = (jiffies + (delay_msec * (HZ/1000))); -} - - -static void -transvr_task_set_retry(struct transvr_worker_s *task_p, - unsigned long retry_times) { - - task_p->retry = retry_times; -} - - -/* For Transceiver Post Task - */ -int -taskfunc_post_do_nothing(struct transvr_worker_s *task_p) { - - return EVENT_TRANSVR_TASK_DONE; -} - - -int -taskfunc_post_handle_task_state(struct transvr_worker_s *task_p) { - - struct transvr_obj_s* tp = task_p->transvr_p; - - switch (task_p->state) { - case STATE_T_TASK_INIT: - case STATE_T_TASK_WAIT: - return EVENT_TRANSVR_TASK_WAIT; - - case STATE_T_TASK_DONE: - tp->state = STATE_TRANSVR_CONNECTED; - tp->send_uevent(tp, KOBJ_ADD); - return EVENT_TRANSVR_TASK_DONE; - - case STATE_T_TASK_FAIL: - tp->state = STATE_TRANSVR_UNEXCEPTED; - return EVENT_TRANSVR_TASK_FAIL; - - default: - break; - } - return EVENT_TRANSVR_TASK_FAIL; -} - - -/* For Transceiver Main Task - */ -int -_taskfunc_sfp_setup_soft_rs(struct transvr_worker_s *task_p, - int input_val, - int address, - int page, - int offset, - int bit_shift, - uint8_t *attr_p, - char *caller) { - - int show_err = 0; - int err_code = DEBUG_TRANSVR_INT_VAL; - char *err_str = DEBUG_TRANSVR_STR_VAL; - char *func_str = "_taskfunc_sfp_setup_soft_rs"; - - err_code = _sfp_update_attr_soft_rs0(task_p->transvr_p, 0); - if (err_code < 0) { - err_str = "Get current soft_rs0 fail!"; - goto err_taskfunc_sfp_setup_soft_rs_1; - } - err_code = __sfp_set_soft_rs(task_p->transvr_p, - input_val, - address, - page, - offset, - bit_shift, - attr_p, - caller, - show_err); - if (err_code < 0) { - err_str = "Get current soft_rs0 fail!"; - goto err_taskfunc_sfp_setup_soft_rs_1; - } - return EVENT_TRANSVR_TASK_DONE; - -err_taskfunc_sfp_setup_soft_rs_1: - if ((task_p->retry) == 0) { - SWPS_INFO("%s: %s :%s :%d :%d\n", - func_str, err_str, task_p->transvr_p->swp_name, input_val, err_code); - } - return EVENT_TRANSVR_TASK_FAIL; -} - - -int -__taskfunc_sfp_setup_hard_rs(struct transvr_worker_s *task_p, - int input_val, - int (*get_func)(struct ioexp_obj_s *self, int virt_offset), - int (*set_func)(struct ioexp_obj_s *self, int virt_offset, int input_val)) { - - int err_val = EVENT_TRANSVR_EXCEP_EXCEP; - char *err_str = DEBUG_TRANSVR_STR_VAL; - - err_val = get_func(task_p->transvr_p->ioexp_obj_p, - task_p->transvr_p->ioexp_virt_offset); - - if (err_val < 0) { - if (err_val == ERR_IOEXP_NOTSUPPORT) { - return EVENT_TRANSVR_TASK_DONE; - } - err_str = "Get current hard_rs fail!"; - goto err_p_taskfunc_sfp_setup_hard_rs_1; - } - if (err_val == input_val) { - return EVENT_TRANSVR_TASK_DONE; - } - err_val = set_func(task_p->transvr_p->ioexp_obj_p, - task_p->transvr_p->ioexp_virt_offset, - input_val); - if (err_val < 0) { - err_str = "Setup hard_rs fail!"; - goto err_p_taskfunc_sfp_setup_hard_rs_1; - } - return EVENT_TRANSVR_TASK_DONE; - -err_p_taskfunc_sfp_setup_hard_rs_1: - if ((task_p->retry) == 0) { - SWPS_INFO("%s: %s :%s :%d :%d\n", - __func__, err_str, task_p->transvr_p->swp_name, input_val, err_val); - } - return EVENT_TRANSVR_TASK_FAIL; -} - - -int -_taskfunc_sfp_setup_hard_rs0(struct transvr_worker_s *task_p, - int input_val) { - - return __taskfunc_sfp_setup_hard_rs(task_p, - input_val, - task_p->transvr_p->ioexp_obj_p->get_hard_rs0, - task_p->transvr_p->ioexp_obj_p->set_hard_rs0); -} - - -int -_taskfunc_sfp_setup_hard_rs1(struct transvr_worker_s *task_p, - int input_val) { - - return __taskfunc_sfp_setup_hard_rs(task_p, - input_val, - task_p->transvr_p->ioexp_obj_p->get_hard_rs1, - task_p->transvr_p->ioexp_obj_p->set_hard_rs1); -} - - -int -_taskfunc_sfp_setup_rs0(struct transvr_worker_s *task_p, - int input_val) { - - int bit_shift = 3; - int old_val = DEBUG_TRANSVR_INT_VAL; - int err_val = EVENT_TRANSVR_EXCEP_EXCEP; - char *err_str = DEBUG_TRANSVR_STR_VAL; - char *func_str = "_taskfunc_sfp_setup_rs0"; - - err_val = _taskfunc_sfp_setup_hard_rs0(task_p, - input_val); - if (err_val < 0) { - err_str = "Setup hard_rs0 fail!"; - goto err_private_taskfunc_sfp_setup_rs0_1; - } - old_val = err_val; - err_val = _taskfunc_sfp_setup_soft_rs(task_p, - input_val, - task_p->transvr_p->eeprom_map_p->addr_soft_rs0, - task_p->transvr_p->eeprom_map_p->page_soft_rs0, - task_p->transvr_p->eeprom_map_p->offset_soft_rs0, - bit_shift, - &(task_p->transvr_p->soft_rs0), - func_str); - if (err_val < 0) { - err_str = "Setup soft_rs0 fail!"; - goto err_private_taskfunc_sfp_setup_rs0_1; - } - return EVENT_TRANSVR_TASK_DONE; - -err_private_taskfunc_sfp_setup_rs0_1: - if ((task_p->retry) == 0) { - SWPS_INFO("%s: %s :%s :%d :%d\n", - func_str, err_str, task_p->transvr_p->swp_name, input_val, err_val); - } - _taskfunc_sfp_setup_hard_rs0(task_p, old_val); - return EVENT_TRANSVR_TASK_FAIL; -} - - -int -_taskfunc_sfp_setup_rs1(struct transvr_worker_s *task_p, - int input_val) { - - int bit_shift = 3; - int old_val = DEBUG_TRANSVR_INT_VAL; - int err_val = EVENT_TRANSVR_EXCEP_EXCEP; - char *err_str = DEBUG_TRANSVR_STR_VAL; - char *func_str = "_taskfunc_sfp_setup_rs1"; - - err_val = _taskfunc_sfp_setup_hard_rs1(task_p, - input_val); - if (err_val < 0) { - err_str = "Setup hard_rs1 fail!"; - goto err_private_taskfunc_sfp_setup_rs1_1; - } - old_val = err_val; - err_val = _taskfunc_sfp_setup_soft_rs(task_p, - input_val, - task_p->transvr_p->eeprom_map_p->addr_soft_rs1, - task_p->transvr_p->eeprom_map_p->page_soft_rs1, - task_p->transvr_p->eeprom_map_p->offset_soft_rs1, - bit_shift, - &(task_p->transvr_p->soft_rs1), - func_str); - if (err_val < 0) { - err_str = "Setup soft_rs1 fail!"; - goto err_private_taskfunc_sfp_setup_rs1_1; - } - return EVENT_TRANSVR_TASK_DONE; - -err_private_taskfunc_sfp_setup_rs1_1: - if ((task_p->retry) == 0) { - SWPS_INFO("%s: %s :%s :%d :%d\n", - func_str, err_str, task_p->transvr_p->swp_name, input_val, err_val); - } - _taskfunc_sfp_setup_hard_rs1(task_p, old_val); - return EVENT_TRANSVR_TASK_FAIL; -} - - -int -taskfunc_sfp_setup_SFF8431_case1(struct transvr_worker_s *task_p) { - /* SFF-8431 (8/4/2G Rx Rate_Select only) */ - int update_val = 1; - - return _taskfunc_sfp_setup_rs0(task_p, update_val); -} - - - -int -taskfunc_sfp_setup_SFF8431_case2(struct transvr_worker_s *task_p) { - /* SFF-8431 (8/4/2G Tx Rate_Select only) */ - int update_val = 1; - - return _taskfunc_sfp_setup_rs1(task_p, update_val); -} - - -int -taskfunc_sfp_setup_SFF8431_case3(struct transvr_worker_s *task_p) { - /* SFF-8431 (8/4/2G Independent Rx & Tx Rate_select) */ - int update_rs0 = 1; - int update_rs1 = 1; - int err_code = DEBUG_TRANSVR_INT_VAL; - - err_code = _taskfunc_sfp_setup_rs0(task_p, update_rs0); - if (err_code < 0) { - return err_code; - } - return _taskfunc_sfp_setup_rs1(task_p, update_rs1); -} - - -int -taskfunc_sfp_handle_1g_rj45(struct transvr_worker_s *task_p) { - - /* Not all of platform support 0x56 for transceiver - * external PHY, Support list as below: - * => 1. Magnolia-PVT (PS: EVT & DVT not ready) - */ - int ext_phy_addr = 0x56; - int ext_phy_page = -1; - int ext_phy_offs = 0x11; - int ext_phy_len = 1; - int lstate_mask = 0x04; /* 00000100 */ - int show_err = 0; - int fail_retry = 5; - int fail_delay = 1000; /* msec */ - int err_code = DEBUG_TRANSVR_INT_VAL; - uint8_t detect_val = DEBUG_TRANSVR_HEX_VAL; - char err_str[64] = DEBUG_TRANSVR_STR_VAL; - int *tmp_p = NULL; - char *func_name = "taskfunc_sfp_handle_1g_rj45"; - - if (task_p->transvr_p->state != STATE_TRANSVR_CONNECTED) { - return EVENT_TRANSVR_TASK_DONE; - } - if ( (task_p->transvr_p->info != TRANSVR_CLASS_BASE_T_1000) && - (task_p->transvr_p->info != TRANSVR_CLASS_BASE_T_1000_up) ) { - goto err_taskfunc_sfp_handle_1g_rj45_1; - } - err_code = _common_update_uint8_attr(task_p->transvr_p, - ext_phy_addr, - ext_phy_page, - ext_phy_offs, - ext_phy_len, - &detect_val, - func_name, - show_err); - if ( (err_code < 0) || - (detect_val == DEBUG_TRANSVR_HEX_VAL) ) { - snprintf(err_str, sizeof(err_str), "Detect external link status fail"); - goto err_taskfunc_sfp_handle_1g_rj45_2; - } - if ((detect_val & lstate_mask) == lstate_mask) { - goto ok_taskfunc_sfp_handle_1g_rj45_link_up; - } - goto ok_taskfunc_sfp_handle_1g_rj45_link_down; - -ok_taskfunc_sfp_handle_1g_rj45_link_up: - /* Filter out noise */ - if (!(task_p->p_data)) { - tmp_p = kzalloc(sizeof(int), GFP_KERNEL); - if (!tmp_p) { - snprintf(err_str, sizeof(err_str), "kzalloc p_data fail"); - goto err_taskfunc_sfp_handle_1g_rj45_2; - } - *tmp_p = TRANSVR_CLASS_BASE_T_1000_up; - task_p->p_data = tmp_p; - goto ok_taskfunc_sfp_handle_1g_rj45_done; - } - if ((*(int *)(task_p->p_data)) != TRANSVR_CLASS_BASE_T_1000_up) { - kfree(task_p->p_data); - task_p->p_data = NULL; - snprintf(err_str, sizeof(err_str), "Internal error"); - goto err_taskfunc_sfp_handle_1g_rj45_2; - } - task_p->transvr_p->info = TRANSVR_CLASS_BASE_T_1000_up; - kfree(task_p->p_data); - task_p->p_data = NULL; - goto ok_taskfunc_sfp_handle_1g_rj45_done; - -ok_taskfunc_sfp_handle_1g_rj45_link_down: - if (task_p->p_data) { - kfree(task_p->p_data); - task_p->p_data = NULL; - } - task_p->transvr_p->info = TRANSVR_CLASS_BASE_T_1000; - goto ok_taskfunc_sfp_handle_1g_rj45_done; - -ok_taskfunc_sfp_handle_1g_rj45_done: - if (task_p->retry != VAL_TRANSVR_TASK_RETRY_FOREVER) { - transvr_task_set_retry(task_p, VAL_TRANSVR_TASK_RETRY_FOREVER); - } - return EVENT_TRANSVR_TASK_DONE; - -err_taskfunc_sfp_handle_1g_rj45_1: - snprintf(err_str, sizeof(err_str), "Detect transceiver:%d not Base-T, remove task.", - task_p->transvr_p->info); - SWPS_INFO("%s: %s :%s\n", __func__, err_str, task_p->transvr_p->swp_name); - transvr_task_set_retry(task_p, 0); - return EVENT_TRANSVR_TASK_DONE; - -err_taskfunc_sfp_handle_1g_rj45_2: - if (task_p->retry == VAL_TRANSVR_TASK_RETRY_FOREVER) { - transvr_task_set_retry(task_p, fail_retry); - } - if ((task_p->retry) == 0) { - /* Error case: - * => In this case, SWPS will stop external Link state monitor features - * and keeps transvr_p->info on TRANSVR_CLASS_BASE_T_1000_up. - * Upper layer will see it always Linkup that because of these type of - * transceiver has external phy, BCM chip see it as Loopback transceiver. - */ - SWPS_WARN("%s can not access external PHY of Base-T SFP transceiver\n", - task_p->transvr_p->swp_name); - task_p->transvr_p->info = TRANSVR_CLASS_BASE_T_1000_up; - return EVENT_TRANSVR_TASK_DONE; - } else { - transvr_task_set_delay(task_p, fail_delay); - } - return EVENT_TRANSVR_TASK_FAIL; -} - - -int -_taskfunc_qsfp_setup_power_mod(struct transvr_obj_s *self, - int setup_val) { - - int curr_val = DEBUG_TRANSVR_INT_VAL; - int err_val = DEBUG_TRANSVR_INT_VAL; - char *err_msg = DEBUG_TRANSVR_STR_VAL; - - curr_val = self->ioexp_obj_p->get_lpmod(self->ioexp_obj_p, - self->ioexp_virt_offset); - if (curr_val < 0){ - err_msg = "Get current value fail!"; - goto err_private_taskfunc_qsfp_setup_power_mod_1; - } - if (curr_val == setup_val){ - return EVENT_TRANSVR_TASK_DONE; - } - err_val = self->ioexp_obj_p->set_lpmod(self->ioexp_obj_p, - self->ioexp_virt_offset, - setup_val); - if (err_val < 0){ - err_msg = "Setup power mode fail!"; - goto err_private_taskfunc_qsfp_setup_power_mod_1; - } - return EVENT_TRANSVR_TASK_DONE; - -err_private_taskfunc_qsfp_setup_power_mod_1: - SWPS_INFO("%s: %s :%d :%d :%d\n", - __func__, err_msg, err_val, curr_val, setup_val); - return EVENT_TRANSVR_TASK_FAIL; -} - - -int -taskfunc_qsfp_handle_tx_disable(struct transvr_worker_s *task_p) { - - int i = 0; - int retry = 5; - int delay_ms = 100; - - if (task_p->transvr_p->auto_tx_disable == VAL_TRANSVR_FUNCTION_DISABLE) { - return EVENT_TRANSVR_TASK_DONE; - } - if (!_qsfp_is_implement_tx_disable(task_p->transvr_p)) { - return EVENT_TRANSVR_TASK_DONE; - } - for (i=0; itransvr_p, - task_p->transvr_p->auto_tx_disable) - == EVENT_TRANSVR_TASK_DONE) { - goto ok_taskfunc_qsfp_handle_tx_disable; - } - mdelay(delay_ms); - } - SWPS_INFO("%s auto setup tx_disable:0x%02x fail.\n", - task_p->transvr_p->swp_name, - task_p->transvr_p->auto_tx_disable); - return EVENT_TRANSVR_INIT_FAIL; - -ok_taskfunc_qsfp_handle_tx_disable: - SWPS_INFO("%s auto setup tx_disable:0x%02x ok.\n", - task_p->transvr_p->swp_name, - task_p->transvr_p->auto_tx_disable); - return EVENT_TRANSVR_TASK_DONE; -} - - -int -taskfunc_qsfp_set_hpmod(struct transvr_worker_s *task_p) { - - int err = DEBUG_TRANSVR_INT_VAL; - int HIGH_POWER_MODE = 0; - - /* Handle power mode */ - err = _taskfunc_qsfp_setup_power_mod(task_p->transvr_p, - HIGH_POWER_MODE); - if (err < 0) { - SWPS_INFO("%s: setup hpmod fail :%d :%s\n", - __func__, err, task_p->transvr_p->swp_name); - return err; - } - /* Handle auto tx_disable - * [Note] - * => Because there are some transceiver have timing issues or - * setup sequence issues, therefore we handle auto tx_disable - * after handle power mode. - */ - mdelay(100); - return taskfunc_qsfp_handle_tx_disable(task_p); -} - - -int -taskfunc_qsfp_set_lpmod(struct transvr_worker_s *task_p) { - - int LOW_POWER_MODE = 1; - return _taskfunc_qsfp_setup_power_mod(task_p->transvr_p, - LOW_POWER_MODE); -} - - -static int -initfunc_sfp_handle_multi_rate_mode(struct transvr_obj_s *self) { - - int task_retry = 3; - int err_code = DEBUG_TRANSVR_INT_VAL; - char *err_str = DEBUG_TRANSVR_STR_VAL; - char *func_str = "sfp_handle_multi_rate_mode"; - struct transvr_worker_s *task_p = NULL; - - switch (self->rate_id) { - case 0x00: /* Unspecified */ - case 0x03: /* Unspecified */ - case 0x05: /* Unspecified */ - case 0x07: /* Unspecified */ - case 0x09: /* Unspecified */ - case 0x0B: /* Unspecified */ - case 0x0D: /* Unspecified */ - case 0x0F: /* Unspecified */ - goto sfp_handle_multi_rate_mode_4_unspecified; - - case 0x02: /* SFF-8431 (8/4/2G Rx Rate_Select only) */ - task_p = transvr_task_creat(self, - taskfunc_sfp_setup_SFF8431_case1, - taskfunc_post_handle_task_state, - func_str); - goto sfp_handle_multi_rate_mode_4_sff8431; - - case 0x04: /* SFF-8431 (8/4/2G Tx Rate_Select only) */ - task_p = transvr_task_creat(self, - taskfunc_sfp_setup_SFF8431_case2, - taskfunc_post_handle_task_state, - func_str); - goto sfp_handle_multi_rate_mode_4_sff8431; - - case 0x06: /* SFF-8431 (8/4/2G Independent Rx & Tx Rate_select) */ - task_p = transvr_task_creat(self, - taskfunc_sfp_setup_SFF8431_case3, - taskfunc_post_handle_task_state, - func_str); - goto sfp_handle_multi_rate_mode_4_sff8431; - - case 0x01: /* SFF-8079 (4/2/1G Rate_Select & AS0/AS1) */ - err_str = "SFF-8079 (4/2/1G Rate_Select & AS0/AS1)"; - goto sfp_handle_multi_rate_mode_4_not_support; - - case 0x08: /* FC-PI-5 (16/8/4G Rx Rate_select only) - * High=16G only, Low=8G/4G - */ - err_str = "FC-PI-5 (16/8/4G Rx Rate_select only)"; - goto sfp_handle_multi_rate_mode_4_not_support; - - case 0x0A: /* FC-PI-5 (16/8/4G Independent Rx, Tx Rate_select) - * High=16G only, Low=8G/4G - */ - err_str = "FC-PI-5 (16/8/4G Independent Rx, Tx Rate_select)"; - goto sfp_handle_multi_rate_mode_4_not_support; - - case 0x0C: /* FC-PI-6 (32/16/8G Independent Rx, Tx Rate_Select) - * High=32G only, Low = 16G/8G - */ - err_str = "FC-PI-6 (32/16/8G Independent Rx, Tx Rate_Select)"; - goto sfp_handle_multi_rate_mode_4_not_support; - - case 0x0E: /* 10/8G Rx and Tx Rate_Select controlling the operation or - * locking modes of the internal signal conditioner, retimer - * or CDR, according to the logic table defined in Table 10-2, - * High Bit Rate (10G) =9.95-11.3 Gb/s; Low Bit Rate (8G) = - * 8.5 Gb/s. In this mode, the default value of bit 110.3 (Soft - * Rate Select RS(0), Table 9-11) and of bit 118.3 (Soft Rate - * Select RS(1), Table 10-1) is 1. - */ - err_str = "cable type: 0x0E"; - goto sfp_handle_multi_rate_mode_4_not_support; - - default: - err_str = "cable type: UNKNOW"; - goto sfp_handle_multi_rate_mode_4_not_support; - } - -sfp_handle_multi_rate_mode_4_sff8431: - if (!task_p) { - err_str = "Create task fail!"; - goto sfp_handle_multi_rate_mode_4_fail_1; - } - transvr_task_set_retry(task_p, task_retry); - return EVENT_TRANSVR_TASK_WAIT; - -sfp_handle_multi_rate_mode_4_unspecified: - return EVENT_TRANSVR_TASK_DONE; - -sfp_handle_multi_rate_mode_4_not_support: - SWPS_INFO("%s: Does not support %s :%s :0x%02x\n", - func_str, err_str, self->swp_name, self->rate_id); - return EVENT_TRANSVR_TASK_DONE; - -sfp_handle_multi_rate_mode_4_fail_1: - SWPS_INFO("%s: %s :%s :0x%02x, :%d\n", - func_str, err_str, self->swp_name, self->rate_id, err_code); - return EVENT_TRANSVR_INIT_FAIL; -} - - -static int -initfunc_sfp_handle_1g_rj45(struct transvr_obj_s *self) { - - struct transvr_worker_s *task_p = NULL; - int detect_cls = DEBUG_TRANSVR_INT_VAL; - char err_str[64] = DEBUG_TRANSVR_STR_VAL; - char *func_str = "initfunc_sfp_handle_1g_rj45"; - - - if (self->info == TRANSVR_CLASS_BASE_T_1000) { - task_p = transvr_task_creat(self, - taskfunc_sfp_handle_1g_rj45, - taskfunc_post_do_nothing, - func_str); - if (!task_p) { - snprintf(err_str, sizeof(err_str), "Create task fail"); - goto err_initfunc_sfp_handle_1g_rj45; - } - transvr_task_set_retry(task_p, VAL_TRANSVR_TASK_RETRY_FOREVER); - } - return EVENT_TRANSVR_TASK_DONE; - -err_initfunc_sfp_handle_1g_rj45: - SWPS_INFO("%s: %s :%s :%d\n", - __func__, err_str, self->swp_name, detect_cls); - return EVENT_TRANSVR_TASK_FAIL; -} - - -static int -initfunc_qsfp_handle_power_mode(struct transvr_obj_s *self) { - - int err_code = EVENT_TRANSVR_EXCEP_INIT; - int power_class = DEBUG_TRANSVR_INT_VAL; - int hpmod_retry = 3; - int lpower_config = 1; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - unsigned long hpmod_delay = 500; /* msec */ - struct transvr_worker_s *task_p = NULL; - - /* Handle power mode for IOEXP */ - power_class = __qsfp_get_power_cls(self, 0); - switch (power_class) { - case 1: /* Case: Low power mode (Class = 1) */ - err_code = _taskfunc_qsfp_setup_power_mod(self, lpower_config); - if (err_code < 0){ - snprintf(err_msg, sizeof(err_msg), "Setup lpmod fail :%d", err_code); - goto err_initfunc_qsfp_handle_power_mode; - } - return EVENT_TRANSVR_TASK_DONE; - - case 2: /* Case: High power mode (Class > 1) */ - case 3: - case 4: - case 5: - case 6: - case 7: - task_p = transvr_task_creat(self, - taskfunc_qsfp_set_hpmod, - taskfunc_post_handle_task_state, - "transvr_init_qsfp"); - if (!task_p) { - snprintf(err_msg, sizeof(err_msg), "Setup lpmod fail :%d", err_code); - goto err_initfunc_qsfp_handle_power_mode; - } - transvr_task_set_retry(task_p, hpmod_retry); - transvr_task_set_delay(task_p, hpmod_delay); - return EVENT_TRANSVR_TASK_WAIT; - - default: - break; - } - snprintf(err_msg, sizeof(err_msg), "Exception case"); - goto err_initfunc_qsfp_handle_power_mode; - -err_initfunc_qsfp_handle_power_mode: - SWPS_INFO("%s: %s :%s \n", __func__, err_msg, self->swp_name); - return EVENT_TRANSVR_INIT_FAIL; -} - - -int -initfunc_qsfp28_handle_cdr(struct transvr_obj_s *self) { - - uint8_t DEFAULT_VAL_CDR = 0xff; - int CDR_FUNC_EXISTED = 0x3; - int show_err = 1; - int err_val = EVENT_TRANSVR_TASK_FAIL; - char *err_msg = DEBUG_TRANSVR_STR_VAL; - char *func_str = "initfunc_qsfp28_handle_cdr"; - - err_val = __qsfp_get_cdr_present(self, 0); - if ( (err_val < 0) || - (err_val == DEBUG_TRANSVR_HEX_VAL) ) { - err_msg = "detect cdr_present fail!"; - goto err_taskfunc_qsfp_handle_cdr_1; - } - if (err_val == CDR_FUNC_EXISTED) { - err_val = _common_set_uint8_attr(self, - self->eeprom_map_p->addr_cdr, - self->eeprom_map_p->addr_cdr, - self->eeprom_map_p->offset_cdr, - DEFAULT_VAL_CDR, - &(self->cdr), - func_str, - show_err); - if (err_val < 0) { - err_msg = "set CDR fail!"; - goto err_taskfunc_qsfp_handle_cdr_1; - } - } - return EVENT_TRANSVR_TASK_DONE; - -err_taskfunc_qsfp_handle_cdr_1: - SWPS_INFO("%s: %s :%d :%s\n", - func_str, err_msg, err_val, self->swp_name); - return EVENT_TRANSVR_INIT_FAIL; -} - -/* ========== Object functions for Final State Machine ========== - */ -int -is_plugged(struct transvr_obj_s *self){ - - int limit = 63; - int present = DEBUG_TRANSVR_INT_VAL; - char emsg[64] = DEBUG_TRANSVR_STR_VAL; - struct ioexp_obj_s *ioexp_p = self->ioexp_obj_p; - - if (!ioexp_p) { - snprintf(emsg, limit, "ioexp_p is null!"); - goto err_is_plugged_1; - } - present = ioexp_p->get_present(ioexp_p, self->ioexp_virt_offset); - switch (present){ - case 0: - return 1; - case 1: - return 0; - case ERR_IOEXP_UNINIT: - snprintf(emsg, limit, "ioexp_p not ready!"); - goto err_is_plugged_1; - default: - if (ioexp_p->state == STATE_IOEXP_INIT){ - snprintf(emsg, limit, "ioexp_p not ready!"); - goto err_is_plugged_1; - } - break; - } - SWPS_INFO("%s: Exception case! :%d :%d\n", - __func__, present, ioexp_p->state); - return 0; - -err_is_plugged_1: - SWPS_DEBUG("%s: %s\n", __func__, emsg); - return 0; -} - - -static int -detect_transvr_type(struct transvr_obj_s* self){ - - int type = TRANSVR_TYPE_ERROR; - - self->i2c_client_p->addr = VAL_TRANSVR_COMID_ARREESS; - type = i2c_smbus_read_byte_data(self->i2c_client_p, - VAL_TRANSVR_COMID_OFFSET); - - /* Case: 1. Wait transceiver I2C module. - * 2. Transceiver I2C module failure. - * Note: 1. SFF allow maximum transceiver initial time is 2 second. So, there - * are exist some case that we need to wait transceiver. - * For these case, we keeps status on "TRANSVR_TYPE_UNPLUGGED", than - * state machine will keep trace with it. - * 2. There exist some I2C failure case we need to handle. Such as user - * insert the failure transceiver, or any reason cause it abnormal. - */ - if (type < 0){ - switch (type) { - case -EIO: - SWPS_DEBUG("%s: %s smbus return:-5 (I/O error)\n", - __func__, self->swp_name); - return TRANSVR_TYPE_UNPLUGGED; - case -ENXIO: - SWPS_DEBUG("%s: %s smbus return:-6 (No such device or address)\n", - __func__, self->swp_name); - return TRANSVR_TYPE_UNPLUGGED; - default: - break; - } - SWPS_INFO("%s: %s unexpected smbus return:%d \n", - __func__, self->swp_name, type); - return TRANSVR_TYPE_ERROR; - } - /* Identify valid transceiver type */ - switch (type){ - case TRANSVR_TYPE_SFP: - case TRANSVR_TYPE_QSFP: - case TRANSVR_TYPE_QSFP_PLUS: - case TRANSVR_TYPE_QSFP_28: - break; - case TRANSVR_TYPE_UNKNOW_1: - case TRANSVR_TYPE_UNKNOW_2: - type = TRANSVR_TYPE_UNKNOW_2; - break; - default: - SWPS_DEBUG("%s: unknow type:0x%02x \n", __func__, type); - type = TRANSVR_TYPE_ERROR; - break; - } - return type; -} - - -static int -detect_transvr_state(struct transvr_obj_s *self, - int result[2]){ - /* [return] [result-0] [result-1] - * 0 STATE_TRANSVR_CONNECTED TRANSVR_TYPE_FAKE - * 0 STATE_TRANSVR_DISCONNECTED TRANSVR_TYPE_UNPLUGGED - * 0 STATE_TRANSVR_ISOLATED TRANSVR_TYPE_ERROR - * 0 STATE_TRANSVR_INIT / - * 0 STATE_TRANSVR_SWAPPED - * 0 STATE_TRANSVR_CONNECTED - * ERR_TRNASVR_BE_ISOLATED STATE_TRANSVR_ISOLATED TRANSVR_TYPE_ERROR - * ERR_TRANSVR_I2C_CRASH STATE_TRANSVR_UNEXCEPTED TRANSVR_TYPE_ERROR - * ERR_TRANSVR_UNEXCPT STATE_TRANSVR_UNEXCEPTED TRANSVR_TYPE_UNKNOW_1/2 - */ - result[0] = STATE_TRANSVR_UNEXCEPTED; /* For return state */ - result[1] = TRANSVR_TYPE_ERROR; /* For return type */ - - /* Case1: Fake type */ - if (self->type == TRANSVR_TYPE_FAKE){ - result[0] = STATE_TRANSVR_CONNECTED; - result[1] = TRANSVR_TYPE_FAKE; - return 0; - } - /* Case2: Transceiver unplugged */ - if (!is_plugged(self)){ - result[0] = STATE_TRANSVR_DISCONNECTED; - result[1] = TRANSVR_TYPE_UNPLUGGED; - return 0; - } - /* Case3: Transceiver be isolated */ - if (self->state == STATE_TRANSVR_ISOLATED){ - result[0] = STATE_TRANSVR_ISOLATED; - result[1] = TRANSVR_TYPE_ERROR; - return ERR_TRNASVR_BE_ISOLATED; - } - /* Case4: Transceiver plugged */ - result[1] = detect_transvr_type(self); - /* Case4.1: I2C topology crash - * Note : There are some I2C issues cause by transceiver/cables. - * We need to check topology status when user insert it. - * But in this step, we can't not ensure this is the issues - * port. So, it return the ERR_TRANSVR_I2C_CRASH, then upper - * layer will diagnostic I2C topology. - */ - if (check_channel_tier_1() < 0) { - SWPS_INFO("%s: %s detect I2C crash :%d\n", - __func__, self->swp_name, self->state); - result[0] = STATE_TRANSVR_UNEXCEPTED; - result[1] = TRANSVR_TYPE_ERROR; - return ERR_TRANSVR_I2C_CRASH; - } - /* Case4.2: System initial not ready, - * Note : Sometime i2c channel or transceiver EEPROM will delay that will - * cause system in inconsistent state between EEPROM and IOEXP. - * In this case, SWP transceiver object keep state at LINK_DOWN - * to wait system ready. - * By the way, State Machine will handle these case. - */ - if (result[1] == TRANSVR_TYPE_UNPLUGGED){ - result[0] = STATE_TRANSVR_DISCONNECTED; - return 0; - } - /* Case4.3: Error transceiver type */ - if (result[1] == TRANSVR_TYPE_ERROR){ - result[0] = STATE_TRANSVR_ISOLATED; - SWPS_INFO("%s: %s detect error type\n", __func__, self->swp_name); - alarm_msg_2_user(self, "detected transceiver/cables not meet SFF standard!"); - return ERR_TRNASVR_BE_ISOLATED; - } - /* Case3.3: Unknow transceiver type */ - if ((result[1] == TRANSVR_TYPE_UNKNOW_1) || - (result[1] == TRANSVR_TYPE_UNKNOW_2) ){ - result[0] = STATE_TRANSVR_UNEXCEPTED; - return ERR_TRANSVR_UNEXCPT; - } - /* Case3.4: During initial process */ - if (self->state == STATE_TRANSVR_INIT){ - result[0] = STATE_TRANSVR_INIT; - return 0; - } - /* Case3.5: Transceiver be swapped */ - if (self->type != result[1]){ - result[0] = STATE_TRANSVR_SWAPPED; - return 0; - } - /* Case3.6: Link up state */ - result[0] = STATE_TRANSVR_CONNECTED; - return 0; -} - - -int -_sfp_detect_class_by_extend_comp(struct transvr_obj_s* self) { - /* Reference: SFF-8024 (v3.8) - */ - int detect_val = _sfp_get_comp_extended(self); - - switch(detect_val) { - case 0x00: /* Unspecified */ - return TRANSVR_CLASS_UNSPECIFIED; - - case 0x01: /* 100G AOC (Active Optical Cable) or 25GAUI C2M */ - case 0x18: /* 100G AOC or 25GAUI C2M AOC. */ - return TRANSVR_CLASS_OPTICAL_25G_AOC; - - case 0x02: /* 100GBASE-SR4 or 25GBASE-SR */ - return TRANSVR_CLASS_OPTICAL_25G_SR; - - case 0x03: /* 100GBASE-LR4 or 25GBASE-LR */ - return TRANSVR_CLASS_OPTICAL_25G_LR; - - case 0x04: /* 100GBASE-ER4 or 25GBASE-ER */ - return TRANSVR_CLASS_OPTICAL_25G_ER; - - case 0x08: /* 100G ACC (Active Copper Cable) or 25GAUI C2M ACC. */ - case 0x0b: /* 100GBASE-CR4 or 25GBASE-CR CA-L */ - case 0x0c: /* 25GBASE-CR CA-S */ - case 0x0d: /* 25GBASE-CR CA-N */ - case 0x19: /* 100G ACC or 25GAUI C2M ACC. */ - return TRANSVR_CLASS_COPPER_L1_25G; - - default: - break; - } - SWPS_INFO("%s: Unexcept value:0x%02x\n :%s", - __func__, detect_val, self->swp_name); - return TRANSVR_CLASS_ERROR; -} - - -int -_sfp_detect_class_by_10_ethernet(struct transvr_obj_s* self) { - /* Reference: SFF-8472 (v12.2) - */ - int detect_val = DEBUG_TRANSVR_INT_VAL; - - detect_val = _sfp_get_comp_10g_eth_comp(self); - /* Case: Unspecified */ - if (detect_val == 0x00) { - return TRANSVR_CLASS_UNSPECIFIED; - } - /* Case: 10G Optical (x1) */ - if ((detect_val & 0x10) == 0x10) { /* 00010000 : 10GBASE-SR */ - return TRANSVR_CLASS_OPTICAL_10G_S_SR; - } - if ( ((detect_val & 0x20) == 0x20) || /* 00100000 : 10GBASE-LR */ - ((detect_val & 0x40) == 0x40) ){ /* 01000000 : 10GBASE-LRM */ - return TRANSVR_CLASS_OPTICAL_10G_S_LR; - } - if ((detect_val & 0x80) == 0x80) { /* 10000000 : 10GBASE-ER */ - return TRANSVR_CLASS_OPTICAL_10G_S_ER; - } - /* Case: ERROR */ - SWPS_INFO("%s: Unexcept value:0x%02x\n :%s", - __func__, detect_val, self->swp_name); - return TRANSVR_CLASS_ERROR; -} - - -int -_sfp_detect_if_sp_by_br(struct transvr_obj_s* self) { - - int lower_bound_1g = 0x0b; - int upper_bound_1g = 0x1A; - int lower_bound_10g = 0x60; - int upper_bound_10g = 0x75; - int lower_bound_25g = 0xf0; - int upper_bound_25g = 0xff; - int notmal_br = DEBUG_TRANSVR_INT_VAL; - - notmal_br = (int)(self->br); /* updated by update_all() */ - /* Check 25G */ - if ((notmal_br >= lower_bound_25g) && - (notmal_br <= upper_bound_25g) ) { - return TRANSVR_CLASS_25G; - } - /* Check 10G */ - if ((notmal_br >= lower_bound_10g) && - (notmal_br <= upper_bound_10g) ) { - return TRANSVR_CLASS_10G; - } - /* Check 1G */ - if ((notmal_br >= lower_bound_1g) && - (notmal_br <= upper_bound_1g) ) { - return TRANSVR_CLASS_1G; - } - return TRANSVR_CLASS_UNSPECIFIED; -} - - -int -_sfp_detect_class_by_1g_ethernet(struct transvr_obj_s* self) { - /* Reference: SFF-8472 (v12.2) - */ - int detect_val = DEBUG_TRANSVR_INT_VAL; - int speed_br = DEBUG_TRANSVR_INT_VAL; - int speed_tmp = DEBUG_TRANSVR_INT_VAL; - char err_str[64] = DEBUG_TRANSVR_STR_VAL; - - speed_br = _sfp_detect_if_sp_by_br(self); - detect_val = _sfp_get_comp_1g_eth_comp(self); - - if (detect_val < 0) { - snprintf(err_str, sizeof(err_str), "Detect abnormal value:%d", detect_val); - goto err_p_sfp_detect_class_by_1g_ethernet; - } - /* Case: Unspecified */ - if (detect_val == 0x00) { - return TRANSVR_CLASS_UNSPECIFIED; - } - /* Case: 1G (x1) */ - if ((detect_val & 0x01) == 0x01) { /* 00000001 : 1000BASE-SX */ - speed_tmp = TRANSVR_CLASS_OPTICAL_1G_SX; - goto ok_sfp_detect_class_by_1g_ethernet_4_check_br_10g; - } - if ((detect_val & 0x02) == 0x02) { /* 00000010 : 1000BASE-LX *3 */ - speed_tmp = TRANSVR_CLASS_OPTICAL_1G_LX; - goto ok_sfp_detect_class_by_1g_ethernet_4_check_br_10g; - } - if ((detect_val & 0x04) == 0x04) { /* 00000100 : 1000BASE-CX */ - speed_tmp = TRANSVR_CLASS_COPPER_L1_1G; - goto ok_sfp_detect_class_by_1g_ethernet_4_check_br_10g; - } - /* Case: 1000 Base-T (x1) */ - if ((detect_val & 0x08) == 0x08) { /* 00001000 : 1000BASE-T */ - return TRANSVR_CLASS_BASE_T_1000; - } - /* Case: 100 Base */ - if ( ((detect_val & 0x10) == 0x10) || /* 00010000 : 100BASE-LX/LX10 */ - ((detect_val & 0x20) == 0x20) || /* 00100000 : 100BASE-FX */ - ((detect_val & 0x40) == 0x40) || /* 01000000 : BASE-BX10 *3 */ - ((detect_val & 0x80) == 0x80) ){ /* 10000000 : BASE-PX *3 */ - return TRANSVR_CLASS_OPTICAL_100; - } - /* Case: ERROR */ - snprintf(err_str, sizeof(err_str), "Case:ERROR, value:%d", detect_val); - goto err_p_sfp_detect_class_by_1g_ethernet; - -ok_sfp_detect_class_by_1g_ethernet_4_check_br_10g: - switch (speed_br) { - case TRANSVR_CLASS_UNSPECIFIED: - case TRANSVR_CLASS_1G: - return speed_tmp; - case TRANSVR_CLASS_10G: - goto ok_sfp_detect_class_by_1g_ethernet_4_transfer_10G; - } - -ok_sfp_detect_class_by_1g_ethernet_4_transfer_10G: - switch (speed_tmp) { - case TRANSVR_CLASS_OPTICAL_1G_SX: - return TRANSVR_CLASS_OPTICAL_10G_S_SR; - case TRANSVR_CLASS_OPTICAL_1G_LX: - return TRANSVR_CLASS_OPTICAL_10G_S_LR; - case TRANSVR_CLASS_COPPER_L1_1G: - return TRANSVR_CLASS_COPPER_L1_10G; - default: - break; - } - snprintf(err_str, sizeof(err_str), "transfer_1to10 fail, speed:%d", speed_tmp); - goto err_p_sfp_detect_class_by_1g_ethernet; - -err_p_sfp_detect_class_by_1g_ethernet: - SWPS_INFO("%s: %s :%s", __func__, err_str, self->swp_name); - return TRANSVR_CLASS_ERROR; -} - - -int -_sfp_detect_class_by_feature(struct transvr_obj_s* self) { - /* Reference: SFF-8024 (v3.8) - */ - int is_active = 0; - int conn_val = DEBUG_TRANSVR_INT_VAL; - int check_val = DEBUG_TRANSVR_INT_VAL; - int wave_len = DEBUG_TRANSVR_INT_VAL; - int speed_val = DEBUG_TRANSVR_INT_VAL; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - - speed_val = _sfp_detect_if_sp_by_br(self); - conn_val = _sfp_get_connector_type(self); - - switch(conn_val) { - case 0x00: /* Unspecified */ - goto ok_sfp_detect_class_by_feature_4_check_active_passive; - case 0x07: /* LC (Lucent Connector) */ - case 0x0b: /* Optical Pigtail */ - case 0x0c: /* MPO 1x12 */ - case 0x0d: /* MPO 2x16 */ - /* - * ToDo: Need verify Optical Pigtail - */ - goto ok_sfp_detect_class_by_feature_4_optiocal; - case 0x21: /* Copper pigtail */ - /* - * ToDo: Need check ACC use case - */ - goto ok_sfp_detect_class_by_feature_4_check_active_passive; - case 0x23: /* No separable connector */ - /* - * ToDo: Standard not clear, not all transceiver vendor - * have the same defined - */ - goto ok_sfp_detect_class_by_feature_4_check_active_passive; - default: - break; - } - goto ok_sfp_detect_class_by_feature_4_unknow; - -ok_sfp_detect_class_by_feature_4_check_active_passive: - check_val = _sfp_get_cable_tech(self); - switch(check_val) { - case 0x00: /* Unspecified */ - goto ok_sfp_detect_class_by_feature_4_unknow; - case 0x04: /* Passive */ - goto ok_sfp_detect_class_by_feature_4_copper; - case 0x08: /* Active */ - is_active = 1; - goto ok_sfp_detect_class_by_feature_4_aoc; - default: - snprintf(err_msg, sizeof(err_msg), - "_sfp_get_cable_tech return Non define value:%d", - check_val); - break; - } - goto err_sfp_detect_class_by_feature_1; - -ok_sfp_detect_class_by_feature_4_optiocal: - wave_len = _common_count_wavelength(self, - self->wavelength[0], - self->wavelength[1]); - switch(speed_val) { - case TRANSVR_CLASS_25G: - switch (wave_len) { - case VAL_OPTICAL_WAVELENGTH_SR: - return TRANSVR_CLASS_OPTICAL_25G_SR; - case VAL_OPTICAL_WAVELENGTH_LR: - return TRANSVR_CLASS_OPTICAL_25G_LR; - case VAL_OPTICAL_WAVELENGTH_ER: - return TRANSVR_CLASS_OPTICAL_25G_ER; - default: - break; - } - return TRANSVR_CLASS_OPTICAL_25G; - - case TRANSVR_CLASS_10G: - switch (wave_len) { - case VAL_OPTICAL_WAVELENGTH_SR: - return TRANSVR_CLASS_OPTICAL_10G_S_SR; - case VAL_OPTICAL_WAVELENGTH_LR: - return TRANSVR_CLASS_OPTICAL_10G_S_LR; - case VAL_OPTICAL_WAVELENGTH_ER: - return TRANSVR_CLASS_OPTICAL_10G_S_ER; - default: - break; - } - return TRANSVR_CLASS_OPTICAL_10G; - - case TRANSVR_CLASS_1G: - switch (wave_len) { - case VAL_OPTICAL_WAVELENGTH_SR: - return TRANSVR_CLASS_OPTICAL_1G_SX; - case VAL_OPTICAL_WAVELENGTH_LR: - return TRANSVR_CLASS_OPTICAL_1G_LX; - case VAL_OPTICAL_WAVELENGTH_ER: - return TRANSVR_CLASS_OPTICAL_1G_EX; - default: - break; - } - return TRANSVR_CLASS_OPTICAL_1G; - - default: - return TRANSVR_CLASS_OPTICAL; - } - -ok_sfp_detect_class_by_feature_4_aoc: - switch(speed_val) { - case TRANSVR_CLASS_25G: - return TRANSVR_CLASS_OPTICAL_25G_AOC; - case TRANSVR_CLASS_10G: - return TRANSVR_CLASS_OPTICAL_10G_S_AOC; - case TRANSVR_CLASS_1G: - return TRANSVR_CLASS_OPTICAL_1G_AOC; - default: - break; - } - goto ok_sfp_detect_class_by_feature_4_unknow; - -ok_sfp_detect_class_by_feature_4_copper: - switch(speed_val) { - case TRANSVR_CLASS_25G: - return TRANSVR_CLASS_COPPER_L1_25G; - case TRANSVR_CLASS_10G: - return TRANSVR_CLASS_COPPER_L1_10G; - case TRANSVR_CLASS_1G: - return TRANSVR_CLASS_COPPER_L1_1G; - default: - return TRANSVR_CLASS_COPPER; - } - -ok_sfp_detect_class_by_feature_4_unknow: - return TRANSVR_CLASS_UNSPECIFIED; - -err_sfp_detect_class_by_feature_1: - SWPS_INFO("%s: %s\n :%s", __func__, err_msg, self->swp_name); - return TRANSVR_CLASS_ERROR; -} - - -int -sft_detect_transvr_class(struct transvr_obj_s* self) { - - int detect_val = DEBUG_TRANSVR_INT_VAL; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - - /* Check Extended Compliance */ - detect_val = _sfp_detect_class_by_extend_comp(self); - switch(detect_val) { - case TRANSVR_CLASS_UNSPECIFIED: - break; - case TRANSVR_CLASS_OPTICAL_25G_AOC: - case TRANSVR_CLASS_OPTICAL_25G_SR: - case TRANSVR_CLASS_OPTICAL_25G_LR: - case TRANSVR_CLASS_OPTICAL_25G_ER: - case TRANSVR_CLASS_COPPER_L1_25G: - return detect_val; - default: - snprintf(err_msg, sizeof(err_msg), - "Detect undefined extend_comp:%d", - detect_val); - goto err_sft_detect_transceiver_class_1; - } - /* Check 10G Compliance */ - detect_val = _sfp_detect_class_by_10_ethernet(self); - switch(detect_val) { - case TRANSVR_CLASS_UNSPECIFIED: - break; - case TRANSVR_CLASS_OPTICAL_10G_S_SR: - case TRANSVR_CLASS_OPTICAL_10G_S_LR: - case TRANSVR_CLASS_OPTICAL_10G_S_ER: - return detect_val; - default: - snprintf(err_msg, sizeof(err_msg), - "Detect undefined 10G_eth:%d", - detect_val); - goto err_sft_detect_transceiver_class_1; - } - /* Check 1G Compliance */ - detect_val = _sfp_detect_class_by_1g_ethernet(self); - switch(detect_val) { - case TRANSVR_CLASS_UNSPECIFIED: - break; - case TRANSVR_CLASS_OPTICAL_1G_SX: - case TRANSVR_CLASS_OPTICAL_1G_LX: - case TRANSVR_CLASS_COPPER_L1_1G: - case TRANSVR_CLASS_BASE_T_1000: - case TRANSVR_CLASS_OPTICAL_100: - /* - * ToDo: Need Check 0.1G - */ - case TRANSVR_CLASS_OPTICAL_10G_S_SR: - case TRANSVR_CLASS_OPTICAL_10G_S_LR: - case TRANSVR_CLASS_COPPER_L1_10G: - /* Transfer speed case - * => Example: Raycom 10G DAC - */ - return detect_val; - default: - snprintf(err_msg, sizeof(err_msg), - "Detect undefined 1G_eth:%d", - detect_val); - goto err_sft_detect_transceiver_class_1; - } - /* Check by connector, br, wavelength */ - detect_val = _sfp_detect_class_by_feature(self); - switch(detect_val) { - case TRANSVR_CLASS_UNSPECIFIED: - break; - case TRANSVR_CLASS_OPTICAL: - case TRANSVR_CLASS_OPTICAL_1G: - case TRANSVR_CLASS_OPTICAL_1G_SX: - case TRANSVR_CLASS_OPTICAL_1G_LX: - case TRANSVR_CLASS_OPTICAL_1G_EX: - case TRANSVR_CLASS_OPTICAL_1G_AOC: - case TRANSVR_CLASS_OPTICAL_10G: - case TRANSVR_CLASS_OPTICAL_10G_S_SR: - case TRANSVR_CLASS_OPTICAL_10G_S_LR: - case TRANSVR_CLASS_OPTICAL_10G_S_ER: - case TRANSVR_CLASS_OPTICAL_10G_S_AOC: - case TRANSVR_CLASS_OPTICAL_25G: - case TRANSVR_CLASS_OPTICAL_25G_SR: - case TRANSVR_CLASS_OPTICAL_25G_LR: - case TRANSVR_CLASS_OPTICAL_25G_ER: - case TRANSVR_CLASS_OPTICAL_25G_AOC: - case TRANSVR_CLASS_COPPER: - case TRANSVR_CLASS_COPPER_L1_1G: - case TRANSVR_CLASS_COPPER_L1_10G: - case TRANSVR_CLASS_COPPER_L1_25G: - return detect_val; - default: - snprintf(err_msg, sizeof(err_msg), - "Detect undefined get_connector:%d", - detect_val); - goto err_sft_detect_transceiver_class_1; - } - /* Exception case: Can't verify */ - snprintf(err_msg, sizeof(err_msg), "Can not identify!"); - goto err_sft_detect_transceiver_class_1; - -err_sft_detect_transceiver_class_1: - SWPS_INFO("%s: %s :%s\n", __func__, err_msg, self->swp_name); - return TRANSVR_CLASS_ERROR; -} - - -int -_sfp_set_trident2_if_type(struct transvr_obj_s* self, - int transvr_cls, - char *result){ - - int lmax = 8; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - - switch(transvr_cls) { - case TRANSVR_CLASS_ERROR: - case TRANSVR_CLASS_UNSPECIFIED: - break; - /* 25G OPTICAL */ - case TRANSVR_CLASS_OPTICAL_25G_AOC: - case TRANSVR_CLASS_OPTICAL_25G_SR: - case TRANSVR_CLASS_OPTICAL_25G_LR: - case TRANSVR_CLASS_OPTICAL_25G_ER: - case TRANSVR_CLASS_OPTICAL_25G: - return snprintf(result, lmax, TRANSVR_IF_SFI); - /* 25G COPPER */ - case TRANSVR_CLASS_COPPER_L1_25G: - return snprintf(result, lmax, TRANSVR_IF_SFI); - /* 10G OPTICAL */ - case TRANSVR_CLASS_OPTICAL_10G_S_AOC: - case TRANSVR_CLASS_OPTICAL_10G_S_SR: - case TRANSVR_CLASS_OPTICAL_10G_S_LR: - case TRANSVR_CLASS_OPTICAL_10G_S_ER: - case TRANSVR_CLASS_OPTICAL_10G: - return snprintf(result, lmax, TRANSVR_IF_SFI); - /* 10G COPPER */ - case TRANSVR_CLASS_COPPER_L1_10G: - return snprintf(result, lmax, TRANSVR_IF_SFI); - /* 1G OPTICAL */ - case TRANSVR_CLASS_OPTICAL_1G_AOC: - case TRANSVR_CLASS_OPTICAL_1G_SX: - case TRANSVR_CLASS_OPTICAL_1G_LX: - case TRANSVR_CLASS_OPTICAL_1G_EX: - case TRANSVR_CLASS_OPTICAL_1G: - return snprintf(result, lmax, TRANSVR_IF_IF_GMII); - /* 1G COPPER */ - case TRANSVR_CLASS_COPPER_L1_1G: - return snprintf(result, lmax, TRANSVR_IF_IF_GMII); - /* 1G BASE_T */ - case TRANSVR_CLASS_BASE_T_1000: - return snprintf(result, lmax, TRANSVR_IF_IF_GMII); - /* 100 Base */ - case TRANSVR_CLASS_OPTICAL_100: - return snprintf(result, lmax, TRANSVR_IF_IF_GMII); - default: - snprintf(err_msg, sizeof(err_msg), - "Detect undefined value:%d", - transvr_cls); - goto err_sfp_set_trident2_if_type_1; - } - /* Exception case: Can't verify */ - snprintf(err_msg, sizeof(err_msg), "Can not identify!"); - goto err_sfp_set_trident2_if_type_1; - -err_sfp_set_trident2_if_type_1: - snprintf(result, lmax, TRANSVR_UEVENT_UNKNOW); - SWPS_INFO("%s: %s :%s\n", __func__, err_msg, self->swp_name); - return ERR_TRANSVR_ABNORMAL; -} - - -int -_sfp_set_tomahawk_if_type(struct transvr_obj_s* self, - int transvr_cls, - char *result) { - - int lmax = 8; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - - switch(transvr_cls) { - case TRANSVR_CLASS_ERROR: - case TRANSVR_CLASS_UNSPECIFIED: - break; - /* 25G OPTICAL */ - case TRANSVR_CLASS_OPTICAL_25G_AOC: - case TRANSVR_CLASS_OPTICAL_25G_SR: - case TRANSVR_CLASS_OPTICAL_25G_LR: - case TRANSVR_CLASS_OPTICAL_25G_ER: - case TRANSVR_CLASS_OPTICAL_25G: - return snprintf(result, lmax, TRANSVR_IF_SR); - /* 25G COPPER */ - case TRANSVR_CLASS_COPPER_L1_25G: - return snprintf(result, lmax, TRANSVR_IF_KR); - /* 10G OPTICAL */ - case TRANSVR_CLASS_OPTICAL_10G_S_AOC: - case TRANSVR_CLASS_OPTICAL_10G_S_SR: - case TRANSVR_CLASS_OPTICAL_10G_S_LR: - case TRANSVR_CLASS_OPTICAL_10G_S_ER: - case TRANSVR_CLASS_OPTICAL_10G: - return snprintf(result, lmax, TRANSVR_IF_SFI); - /* 10G COPPER */ - case TRANSVR_CLASS_COPPER_L1_10G: - return snprintf(result, lmax, TRANSVR_IF_SFI); - /* 1G OPTICAL */ - case TRANSVR_CLASS_OPTICAL_1G_AOC: - case TRANSVR_CLASS_OPTICAL_1G_SX: - case TRANSVR_CLASS_OPTICAL_1G_LX: - case TRANSVR_CLASS_OPTICAL_1G_EX: - case TRANSVR_CLASS_OPTICAL_1G: - return snprintf(result, lmax, TRANSVR_IF_IF_GMII); - /* 1G COPPER */ - case TRANSVR_CLASS_COPPER_L1_1G: - return snprintf(result, lmax, TRANSVR_IF_IF_GMII); - /* 1G BASE_T */ - case TRANSVR_CLASS_BASE_T_1000: - return snprintf(result, lmax, TRANSVR_IF_IF_GMII); - /* 100 Base */ - case TRANSVR_CLASS_OPTICAL_100: - return snprintf(result, lmax, TRANSVR_IF_IF_GMII); - default: - snprintf(err_msg, sizeof(err_msg), - "Detect undefined value:%d", - transvr_cls); - goto err_sfp_set_tomahawk_if_type_1; - } - /* Exception case: Can't verify */ - snprintf(err_msg, sizeof(err_msg), "Can not identify!"); - goto err_sfp_set_tomahawk_if_type_1; - -err_sfp_set_tomahawk_if_type_1: - snprintf(result, lmax, TRANSVR_UEVENT_UNKNOW); - SWPS_INFO("%s: %s\n :%s", __func__, err_msg, self->swp_name); - return ERR_TRANSVR_ABNORMAL; -} - - -int -_sfp_set_bf_tofino_if_type(struct transvr_obj_s* self, - int transvr_cls, - char *result) { - /* (TBD) - * Due to BF looks like doesn't have interface type. - * We bypass it currently. - */ - int lmax = 8; - return snprintf(result, lmax, TRANSVR_UEVENT_UNKNOW); -} - - -int -_sfp_detect_if_type(struct transvr_obj_s* self, - char *result){ - - int lmax = 8; - int detect_cls = DEBUG_TRANSVR_INT_VAL; - - detect_cls = sft_detect_transvr_class(self); - switch (self->chipset_type) { - case BCM_CHIP_TYPE_TRIDENT_2: - return _sfp_set_trident2_if_type(self, detect_cls, result); - - case BCM_CHIP_TYPE_TOMAHAWK: - return _sfp_set_tomahawk_if_type(self, detect_cls, result); - - case BF_CHIP_TYPE_TOFINO: - return _sfp_set_bf_tofino_if_type(self, detect_cls, result); - - default: - SWPS_INFO("%s: non-defined chipset_type:%d :%s\n", - __func__, self->chipset_type, self->swp_name); - break; - } - snprintf(result, lmax, TRANSVR_UEVENT_UNKNOW); - return ERR_TRANSVR_ABNORMAL; -} - - -int -sfp_get_if_type(struct transvr_obj_s *self, - char *buf_p){ - - int lmax = 16; - char tmp_result[16] = DEBUG_TRANSVR_STR_VAL; - - if (self->state != STATE_TRANSVR_CONNECTED) { - return snprintf(buf_p, lmax, "%d\n", self->state); - } - if (_sfp_detect_if_type(self, tmp_result) < 0) { - return snprintf(buf_p, lmax, "%d\n", ERR_TRANSVR_ABNORMAL); - } - return snprintf(buf_p, lmax, "%s\n", tmp_result); -} - - -int -_sfp_detect_if_speed(struct transvr_obj_s* self, - char *result){ - - int lmax = 16; - int detect_val = DEBUG_TRANSVR_INT_VAL; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - - detect_val = sft_detect_transvr_class(self); - switch(detect_val) { - case TRANSVR_CLASS_ERROR: - case TRANSVR_CLASS_UNSPECIFIED: - break; - /* 25G OPTICAL */ - case TRANSVR_CLASS_OPTICAL_25G_AOC: - case TRANSVR_CLASS_OPTICAL_25G_SR: - case TRANSVR_CLASS_OPTICAL_25G_LR: - case TRANSVR_CLASS_OPTICAL_25G_ER: - case TRANSVR_CLASS_OPTICAL_25G: - return snprintf(result, lmax, TRANSVR_IF_SP_25G); - /* 25G COPPER */ - case TRANSVR_CLASS_COPPER_L1_25G: - return snprintf(result, lmax, TRANSVR_IF_SP_25G); - /* 10G OPTICAL */ - case TRANSVR_CLASS_OPTICAL_10G_S_AOC: - case TRANSVR_CLASS_OPTICAL_10G_S_SR: - case TRANSVR_CLASS_OPTICAL_10G_S_LR: - case TRANSVR_CLASS_OPTICAL_10G_S_ER: - case TRANSVR_CLASS_OPTICAL_10G: - return snprintf(result, lmax, TRANSVR_IF_SP_10G); - /* 10G COPPER */ - case TRANSVR_CLASS_COPPER_L1_10G: - return snprintf(result, lmax, TRANSVR_IF_SP_10G); - /* 1G OPTICAL */ - case TRANSVR_CLASS_OPTICAL_1G_AOC: - case TRANSVR_CLASS_OPTICAL_1G_SX: - case TRANSVR_CLASS_OPTICAL_1G_LX: - case TRANSVR_CLASS_OPTICAL_1G_EX: - case TRANSVR_CLASS_OPTICAL_1G: - return snprintf(result, lmax, TRANSVR_IF_SP_1G); - /* 1G COPPER */ - case TRANSVR_CLASS_COPPER_L1_1G: - return snprintf(result, lmax, TRANSVR_IF_SP_1G); - /* 1G BASE_T */ - case TRANSVR_CLASS_BASE_T_1000: - return snprintf(result, lmax, TRANSVR_IF_SP_1G); - /* 100 Base */ - case TRANSVR_CLASS_OPTICAL_100: - return snprintf(result, lmax, TRANSVR_IF_SP_100); - default: - snprintf(err_msg, sizeof(err_msg), - "Detect undefined value:%d", - detect_val); - goto err_sfp_detect_if_speed_1; - } - /* Check by BR */ - detect_val = _sfp_detect_if_sp_by_br(self); - switch (detect_val) { - case TRANSVR_CLASS_25G: - return snprintf(result, lmax, TRANSVR_IF_SP_25G); - case TRANSVR_CLASS_10G: - return snprintf(result, lmax, TRANSVR_IF_SP_10G); - case TRANSVR_CLASS_1G: - return snprintf(result, lmax, TRANSVR_IF_SP_1G); - default: - break; - } - /* Exception case: Can't verify */ - snprintf(err_msg, sizeof(err_msg), "Can not identify!"); - goto err_sfp_detect_if_speed_1; - -err_sfp_detect_if_speed_1: - snprintf(result, lmax, TRANSVR_UEVENT_UNKNOW); - SWPS_INFO("%s %s\n :%s", __func__, err_msg, self->swp_name); - return ERR_TRANSVR_ABNORMAL; -} - - -int -sfp_get_if_speed(struct transvr_obj_s *self, - char *buf_p){ - - int lmax = 16; - char tmp_result[16] = DEBUG_TRANSVR_STR_VAL; - - if (self->state != STATE_TRANSVR_CONNECTED) { - return snprintf(buf_p, lmax, "%d\n", self->state); - } - if (_sfp_detect_if_speed(self, tmp_result) < 0) { - return snprintf(buf_p, lmax, "%d\n", ERR_TRANSVR_ABNORMAL); - } - return snprintf(buf_p, lmax, "%s\n", tmp_result); -} - - -int -_qsfp_detect_class_by_extend_comp(struct transvr_obj_s* self) { - /* Reference: SFF-8024 (v3.8) - */ - int detect_val = DEBUG_TRANSVR_INT_VAL; - - detect_val = _qsfp_get_comp_extended(self); - switch(detect_val) { - case 0x00: /* Unspecified */ - return TRANSVR_CLASS_UNSPECIFIED; - - case 0x01: /* 100G AOC (Active Optical Cable) or 25GAUI C2M */ - case 0x18: /* 100G AOC or 25GAUI C2M AOC. */ - return TRANSVR_CLASS_OPTICAL_100G_AOC; - - case 0x06: /* 100G CWDM4 */ - case 0x09: /* Obsolete (assigned before 100G CWDM4 MSA required FEC) */ - case 0x17: /* 100G CLR4 */ - case 0x1A: /* 100GE-DWDM2 */ - return TRANSVR_CLASS_OPTICAL_100G; - - case 0x02: /* 100GBASE-SR4 or 25GBASE-SR */ - return TRANSVR_CLASS_OPTICAL_100G_SR4; - - case 0x03: /* 100GBASE-LR4 or 25GBASE-LR */ - return TRANSVR_CLASS_OPTICAL_100G_LR4; - - case 0x04: /* 100GBASE-ER4 or 25GBASE-ER */ - return TRANSVR_CLASS_OPTICAL_100G_ER4; - - case 0x07: /* 100G PSM4 Parallel SMF */ - return TRANSVR_CLASS_OPTICAL_100G_PSM4; - - case 0x12: /* 40G PSM4 Parallel SMF */ - return TRANSVR_CLASS_OPTICAL_40G; - - case 0x11: /* 4 x 10GBASE-SR */ - return TRANSVR_CLASS_OPTICAL_40G_SR4; - - case 0x10: /* 40GBASE-ER4 */ - return TRANSVR_CLASS_OPTICAL_40G_ER4; - - case 0x08: /* 100G ACC (Active Copper Cable) or 25GAUI C2M ACC. */ - case 0x0b: /* 100GBASE-CR4 or 25GBASE-CR CA-L */ - case 0x19: /* 100G ACC or 25GAUI C2M ACC. */ - return TRANSVR_CLASS_COPPER_L4_100G; - - default: - break; - } - SWPS_INFO("%s: Unexcept value:0x%02x\n :%s", - __func__, detect_val, self->swp_name); - return TRANSVR_CLASS_ERROR; -} - - -int -_qsfp_detect_class_by_10_40_100_ethernet(struct transvr_obj_s* self) { - /* Reference: SFF-8472 (v12.2) - */ - int detect_val = DEBUG_TRANSVR_INT_VAL; - - detect_val = _qsfp_get_comp_10_40_100_ethernet(self); - /* Case: Unspecified */ - if (detect_val == 0x00) { - return TRANSVR_CLASS_UNSPECIFIED; - } - /* Case: 40G Optical */ - if ((detect_val & 0x01) == 0x01) { /* 00000001 : 40G Active Cable (XLPPI) */ - return TRANSVR_CLASS_OPTICAL_40G_AOC; - } - if ((detect_val & 0x04) == 0x04) { /* 00000100 : 40GBASE-SR4 */ - return TRANSVR_CLASS_OPTICAL_40G_SR4; - } - if ( (detect_val & 0x02) == 0x02) { /* 00000010 : 40GBASE-LR4 */ - return TRANSVR_CLASS_OPTICAL_40G_LR4; - } - if ( (detect_val & 0x08) == 0x08) { /* 00001000 : 40GBASE-CR4 */ - return TRANSVR_CLASS_COPPER_L4_40G; - } - /* Case: 10G Optical */ - if ( (detect_val & 0x10) == 0x10) { /* 00010000 : 10GBASE-SR */ - return TRANSVR_CLASS_OPTICAL_10G_Q_SR; - } - if ( ((detect_val & 0x20) == 0x20) || /* 00100000 : 10GBASE-LR */ - ((detect_val & 0x40) == 0x40) ){ /* 01000000 : 10GBASE-LRM */ - return TRANSVR_CLASS_OPTICAL_10G_Q_LR; - } - /* Case: Extend Compliance */ - if ( ((detect_val & 0x80) == 0x80) ){ /* 10000000 : Use Extend Compliance */ - return TRANSVR_CLASS_EXTEND_COMP; - } - /* Case: ERROR */ - SWPS_INFO("%s: Unexcept value:0x%02x\n :%s", - __func__, detect_val, self->swp_name); - return TRANSVR_CLASS_ERROR; -} - - -int -_qsfp_detect_if_sp_by_br(struct transvr_obj_s* self) { - - int lower_bound_10g = 0x10; - int upper_bound_10g = 0x25; - int lower_bound_40g = 0x60; - int upper_bound_40g = 0x75; - int lower_bound_100g = 0x60; - int upper_bound_100g = 0x75; - int used_extend_br = 0xff; - int notmal_br = DEBUG_TRANSVR_INT_VAL; - int extend_br = DEBUG_TRANSVR_INT_VAL; - - notmal_br = (int)(self->br); /* updated by update_all() */ - /* Check 40G */ - if ((notmal_br >= lower_bound_40g) && - (notmal_br <= upper_bound_40g) ) { - return TRANSVR_CLASS_40G; - } - /* Check 100G */ - if (notmal_br == used_extend_br) { - extend_br = (int)(self->extbr); /* updated by update_all() */ - if ((extend_br >= lower_bound_100g) && - (extend_br <= upper_bound_100g) ) { - return TRANSVR_CLASS_100G; - } - } - /* Check 10G */ - if ((notmal_br >= lower_bound_10g) && - (notmal_br <= upper_bound_10g) ) { - return TRANSVR_CLASS_10G; - } - return TRANSVR_CLASS_UNSPECIFIED; -} - - -int -_qsfp_detect_class_by_feature(struct transvr_obj_s* self) { - /* Reference: SFF-8024 (v3.8) - */ - int conn_val = DEBUG_TRANSVR_INT_VAL; - int wave_len = DEBUG_TRANSVR_INT_VAL; - int speed_val = DEBUG_TRANSVR_INT_VAL; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - - speed_val = _qsfp_detect_if_sp_by_br(self); - conn_val = _qsfp_get_connector_type(self); - - switch(conn_val) { - case 0x00: /* Unspecified */ - return TRANSVR_CLASS_UNSPECIFIED; - case 0x07: /* LC (Lucent Connector) */ - case 0x0b: /* Optical Pigtail */ - case 0x0c: /* MPO 1x12 (Multifiber Parallel Optic) */ - case 0x0d: /* MPO 2x16 */ - goto ok_qsfp_detect_class_by_feature_4_optiocal; - case 0x21: /* Copper pigtail */ - goto ok_qsfp_detect_class_by_feature_4_copper; - case 0x23: /* No separable connector */ - if ((_qsfp_get_comp_fc_link_length(self) > 0) || - (_qsfp_get_comp_fc_trans_tech(self) > 0) || - (_qsfp_get_comp_fc_trans_media(self) > 0) || - (_qsfp_get_comp_fc_speed(self) > 0) ) { - goto ok_qsfp_detect_class_by_feature_4_aoc; - } - goto ok_qsfp_detect_class_by_feature_4_copper; - default: - snprintf(err_msg, sizeof(err_msg), - "_qsfp_get_connector_type return Non define value:%d", - conn_val); - goto err_qsfp_detect_class_by_feature_1; - } - return TRANSVR_CLASS_UNSPECIFIED; - -ok_qsfp_detect_class_by_feature_4_optiocal: - wave_len = _common_count_wavelength(self, - self->wavelength[0], - self->wavelength[1]); - switch(speed_val) { - case TRANSVR_CLASS_100G: - switch (wave_len) { - case VAL_OPTICAL_WAVELENGTH_SR: - return TRANSVR_CLASS_OPTICAL_100G_SR4; - case VAL_OPTICAL_WAVELENGTH_LR: - return TRANSVR_CLASS_OPTICAL_100G_LR4; - case VAL_OPTICAL_WAVELENGTH_ER: - return TRANSVR_CLASS_OPTICAL_100G_ER4; - default: - break; - } - return TRANSVR_CLASS_OPTICAL_100G; - - case TRANSVR_CLASS_40G: - switch (wave_len) { - case VAL_OPTICAL_WAVELENGTH_SR: - return TRANSVR_CLASS_OPTICAL_40G_SR4; - case VAL_OPTICAL_WAVELENGTH_LR: - return TRANSVR_CLASS_OPTICAL_40G_LR4; - case VAL_OPTICAL_WAVELENGTH_ER: - return TRANSVR_CLASS_OPTICAL_40G_ER4; - default: - break; - } - return TRANSVR_CLASS_OPTICAL_40G; - - case TRANSVR_CLASS_10G: - switch (wave_len) { - case VAL_OPTICAL_WAVELENGTH_SR: - return TRANSVR_CLASS_OPTICAL_10G_Q_SR; - case VAL_OPTICAL_WAVELENGTH_LR: - return TRANSVR_CLASS_OPTICAL_10G_Q_LR; - case VAL_OPTICAL_WAVELENGTH_ER: - return TRANSVR_CLASS_OPTICAL_10G_Q_ER; - default: - break; - } - return TRANSVR_CLASS_OPTICAL_10G; - - default: - return TRANSVR_CLASS_OPTICAL; - } - -ok_qsfp_detect_class_by_feature_4_aoc: - switch(speed_val) { - case TRANSVR_CLASS_100G: - return TRANSVR_CLASS_OPTICAL_100G_AOC; - case TRANSVR_CLASS_40G: - return TRANSVR_CLASS_OPTICAL_40G_AOC; - case TRANSVR_CLASS_10G: - return TRANSVR_CLASS_OPTICAL_10G_Q_AOC; - default: - return TRANSVR_CLASS_OPTICAL; - } - -ok_qsfp_detect_class_by_feature_4_copper: - switch(speed_val) { - case TRANSVR_CLASS_100G: - return TRANSVR_CLASS_COPPER_L4_100G; - case TRANSVR_CLASS_40G: - return TRANSVR_CLASS_COPPER_L4_40G; - case TRANSVR_CLASS_10G: - return TRANSVR_CLASS_COPPER_L4_10G; - default: - return TRANSVR_CLASS_COPPER; - } - -err_qsfp_detect_class_by_feature_1: - SWPS_INFO("%s: %s\n :%s", - __func__, err_msg, self->swp_name); - return TRANSVR_CLASS_ERROR; -} - - -int -qsft_detect_transvr_class(struct transvr_obj_s* self) { - - int detect_val = DEBUG_TRANSVR_INT_VAL; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - - /* Check Extended Compliance */ - detect_val = _qsfp_detect_class_by_extend_comp(self); - switch (detect_val) { - case TRANSVR_CLASS_UNSPECIFIED: - break; - case TRANSVR_CLASS_OPTICAL_100G: - case TRANSVR_CLASS_OPTICAL_100G_AOC: - case TRANSVR_CLASS_OPTICAL_100G_SR4: - case TRANSVR_CLASS_OPTICAL_100G_LR4: - case TRANSVR_CLASS_OPTICAL_100G_ER4: - case TRANSVR_CLASS_OPTICAL_100G_PSM4: - case TRANSVR_CLASS_OPTICAL_40G: - case TRANSVR_CLASS_OPTICAL_40G_AOC: - case TRANSVR_CLASS_OPTICAL_40G_SR4: - case TRANSVR_CLASS_OPTICAL_40G_LR4: - case TRANSVR_CLASS_OPTICAL_40G_ER4: - case TRANSVR_CLASS_COPPER_L4_100G: - return detect_val; - default: - snprintf(err_msg, sizeof(err_msg), - "Detect undefined extend_comp:%d", - detect_val); - goto err_qsft_detect_transvr_class_1; - } - /* Check 10/40G/100G Ethernet Compliance */ - detect_val = _qsfp_detect_class_by_10_40_100_ethernet(self); - switch(detect_val) { - case TRANSVR_CLASS_UNSPECIFIED: - break; - case TRANSVR_CLASS_OPTICAL_40G_AOC: - case TRANSVR_CLASS_OPTICAL_40G_SR4: - case TRANSVR_CLASS_OPTICAL_40G_LR4: - case TRANSVR_CLASS_OPTICAL_10G_Q_SR: /* Need Check: SR4 or SR */ - case TRANSVR_CLASS_OPTICAL_10G_Q_LR: /* Need Check: SR4 or SR */ - case TRANSVR_CLASS_COPPER_L4_40G: - return detect_val; - case TRANSVR_CLASS_EXTEND_COMP: - /* Format incorrect case (We already checked the Extend - * Compliance is 0 - */ - snprintf(err_msg, sizeof(err_msg), - "Transceiver format incorrect"); - goto err_qsft_detect_transvr_class_1; - default: - snprintf(err_msg, sizeof(err_msg), - "Detect undefined 10/40/100:%d", - detect_val); - goto err_qsft_detect_transvr_class_1; - } - /* Check by Connector type, BR and wavelength */ - detect_val = _qsfp_detect_class_by_feature(self); - switch (detect_val) { - case TRANSVR_CLASS_UNSPECIFIED: - break; - case TRANSVR_CLASS_OPTICAL_100G_ER4: - case TRANSVR_CLASS_OPTICAL_100G_LR4: - case TRANSVR_CLASS_OPTICAL_100G_SR4: - case TRANSVR_CLASS_OPTICAL_100G_AOC: - case TRANSVR_CLASS_OPTICAL_100G: - case TRANSVR_CLASS_OPTICAL_40G_ER4: - case TRANSVR_CLASS_OPTICAL_40G_LR4: - case TRANSVR_CLASS_OPTICAL_40G_SR4: - case TRANSVR_CLASS_OPTICAL_40G_AOC: - case TRANSVR_CLASS_OPTICAL_40G: - case TRANSVR_CLASS_OPTICAL_10G_Q_ER: - case TRANSVR_CLASS_OPTICAL_10G_Q_LR: - case TRANSVR_CLASS_OPTICAL_10G_Q_SR: - case TRANSVR_CLASS_OPTICAL_10G_Q_AOC: - case TRANSVR_CLASS_OPTICAL_10G: - case TRANSVR_CLASS_OPTICAL: - case TRANSVR_CLASS_COPPER_L4_100G: - case TRANSVR_CLASS_COPPER_L4_40G: - case TRANSVR_CLASS_COPPER_L4_10G: - case TRANSVR_CLASS_COPPER: - return detect_val; - default: - snprintf(err_msg, sizeof(err_msg), - "Detect undefined connector:%d", - detect_val); - goto err_qsft_detect_transvr_class_1; - } - /* Exception case: Can't verify */ - snprintf(err_msg, sizeof(err_msg), - "Can not identify!"); - goto err_qsft_detect_transvr_class_1; - -err_qsft_detect_transvr_class_1: - SWPS_INFO("%s: %s\n :%s", __func__, err_msg, self->swp_name); - return TRANSVR_CLASS_ERROR; -} - - -int -_qsfp_set_trident2_if_type(struct transvr_obj_s* self, - int transvr_cls, - char *result){ - - int lmax = 8; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - - switch (transvr_cls) { - case TRANSVR_CLASS_UNSPECIFIED: - case TRANSVR_CLASS_ERROR: - break; - /* 100G Optical */ - case TRANSVR_CLASS_OPTICAL_100G: - case TRANSVR_CLASS_OPTICAL_100G_AOC: - case TRANSVR_CLASS_OPTICAL_100G_SR4: - case TRANSVR_CLASS_OPTICAL_100G_LR4: - case TRANSVR_CLASS_OPTICAL_100G_ER4: - case TRANSVR_CLASS_OPTICAL_100G_PSM4: - return snprintf(result, lmax, TRANSVR_IF_SR4); - /* 100G Copper */ - case TRANSVR_CLASS_COPPER_L4_100G: - return snprintf(result, lmax, TRANSVR_IF_KR4); - /* 40G Optical */ - case TRANSVR_CLASS_OPTICAL_40G: - case TRANSVR_CLASS_OPTICAL_40G_AOC: - case TRANSVR_CLASS_OPTICAL_40G_SR4: - case TRANSVR_CLASS_OPTICAL_40G_LR4: - case TRANSVR_CLASS_OPTICAL_40G_ER4: - return snprintf(result, lmax, TRANSVR_IF_IF_XGMII); - /* 40G Copper */ - case TRANSVR_CLASS_COPPER_L4_40G: - return snprintf(result, lmax, TRANSVR_IF_IF_XGMII); - /* 10G Optical */ - case TRANSVR_CLASS_OPTICAL_10G: - case TRANSVR_CLASS_OPTICAL_10G_Q_AOC: - case TRANSVR_CLASS_OPTICAL_10G_Q_SR: /* Need Check: SR4 or SR */ - case TRANSVR_CLASS_OPTICAL_10G_Q_LR: /* Need Check: LR4 or LR */ - case TRANSVR_CLASS_OPTICAL_10G_Q_ER: /* Need Check: ER4 or ER */ - return snprintf(result, lmax, TRANSVR_IF_IF_XGMII); - /* Optical */ - case TRANSVR_CLASS_OPTICAL: - return snprintf(result, lmax, TRANSVR_IF_IF_XGMII); - /* Copper */ - case TRANSVR_CLASS_COPPER: - return snprintf(result, lmax, TRANSVR_IF_IF_XGMII); - default: - snprintf(err_msg, sizeof(err_msg), - "Detect undefined value:%d", - transvr_cls); - goto err_qsfp_set_trident2_if_type_1; - } - /* Exception case: Can't verify */ - snprintf(err_msg, sizeof(err_msg), "Can not identify!"); - goto err_qsfp_set_trident2_if_type_1; - -err_qsfp_set_trident2_if_type_1: - snprintf(result, lmax, TRANSVR_UEVENT_UNKNOW); - SWPS_INFO("%s: %s\n :%s", __func__, err_msg, self->swp_name); - return ERR_TRANSVR_ABNORMAL; -} - - -int -_qsfp_set_tomahawk_if_type(struct transvr_obj_s* self, - int transvr_cls, - char *result){ - - int lmax = 8; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - - switch (transvr_cls) { - case TRANSVR_CLASS_UNSPECIFIED: - case TRANSVR_CLASS_ERROR: - break; - /* 100G Optical */ - case TRANSVR_CLASS_OPTICAL_100G: - case TRANSVR_CLASS_OPTICAL_100G_AOC: - case TRANSVR_CLASS_OPTICAL_100G_SR4: - case TRANSVR_CLASS_OPTICAL_100G_LR4: - case TRANSVR_CLASS_OPTICAL_100G_ER4: - case TRANSVR_CLASS_OPTICAL_100G_PSM4: - return snprintf(result, lmax, TRANSVR_IF_SR4); - /* 100G Copper */ - case TRANSVR_CLASS_COPPER_L4_100G: - return snprintf(result, lmax, TRANSVR_IF_KR4); - /* 40G Optical */ - case TRANSVR_CLASS_OPTICAL_40G: - case TRANSVR_CLASS_OPTICAL_40G_AOC: - case TRANSVR_CLASS_OPTICAL_40G_SR4: - case TRANSVR_CLASS_OPTICAL_40G_LR4: - case TRANSVR_CLASS_OPTICAL_40G_ER4: - return snprintf(result, lmax, TRANSVR_IF_SR4); - /* 40G Copper */ - case TRANSVR_CLASS_COPPER_L4_40G: - return snprintf(result, lmax, TRANSVR_IF_KR4); - /* 10G Optical */ - case TRANSVR_CLASS_OPTICAL_10G: - case TRANSVR_CLASS_OPTICAL_10G_Q_AOC: - case TRANSVR_CLASS_OPTICAL_10G_Q_SR: /* Need Check: SR4 or SR */ - case TRANSVR_CLASS_OPTICAL_10G_Q_LR: /* Need Check: SR4 or SR */ - case TRANSVR_CLASS_OPTICAL_10G_Q_ER: - return snprintf(result, lmax, TRANSVR_IF_SR4); - /* Optical */ - case TRANSVR_CLASS_OPTICAL: - return snprintf(result, lmax, TRANSVR_IF_SR4); - /* Copper */ - case TRANSVR_CLASS_COPPER: - return snprintf(result, lmax, TRANSVR_IF_KR4); - default: - snprintf(err_msg, sizeof(err_msg), - "Detect undefined value:%d", - transvr_cls); - goto err_qsfp_set_trident2_if_type_1; - } - /* Exception case: Can't verify */ - snprintf(err_msg, sizeof(err_msg), "Can not identify!"); - goto err_qsfp_set_trident2_if_type_1; - -err_qsfp_set_trident2_if_type_1: - snprintf(result, lmax, TRANSVR_UEVENT_UNKNOW); - SWPS_INFO("%s: %s\n :%s", __func__, err_msg, self->swp_name); - return ERR_TRANSVR_ABNORMAL; -} - - -int -_qsfp_set_bf_tofino_if_type(struct transvr_obj_s* self, - int transvr_cls, - char *result) { - /* (TBD) - * Due to BF looks like doesn't have interface type. - * We bypass it currently. - */ - int lmax = 8; - return snprintf(result, lmax, TRANSVR_UEVENT_UNKNOW); -} - - -int -_qsfp_detect_if_type(struct transvr_obj_s* self, - char *result){ - - int lmax = 8; - int detect_cls = DEBUG_TRANSVR_INT_VAL; - - detect_cls = qsft_detect_transvr_class(self); - switch (self->chipset_type) { - case BCM_CHIP_TYPE_TRIDENT_2: - return _qsfp_set_trident2_if_type(self, detect_cls, result); - - case BCM_CHIP_TYPE_TOMAHAWK: - return _qsfp_set_tomahawk_if_type(self, detect_cls, result); - - case BF_CHIP_TYPE_TOFINO: - return _qsfp_set_bf_tofino_if_type(self, detect_cls, result); - - default: - SWPS_INFO("%s: non-defined chipset_type:%d :%s\n", - __func__, self->chipset_type, self->swp_name); - break; - } - snprintf(result, lmax, TRANSVR_UEVENT_UNKNOW); - return ERR_TRANSVR_ABNORMAL; -} - - -int -qsfp_get_if_type(struct transvr_obj_s *self, - char *buf_p){ - - int lmax = 8; - char tmp_result[8] = DEBUG_TRANSVR_STR_VAL; - - if (self->state != STATE_TRANSVR_CONNECTED) { - return snprintf(buf_p, lmax, "%d\n", self->state); - } - if (_qsfp_detect_if_type(self, tmp_result) < 0) { - return snprintf(buf_p, lmax, "%d\n", ERR_TRANSVR_ABNORMAL); - } - return snprintf(buf_p, lmax, "%s\n", tmp_result); -} - - -int -_qsfp_detect_if_speed(struct transvr_obj_s* self, - char *result){ - int lmax = 16; - int detect_val = DEBUG_TRANSVR_INT_VAL; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - - detect_val = qsft_detect_transvr_class(self); - switch (detect_val) { - case TRANSVR_CLASS_UNSPECIFIED: - case TRANSVR_CLASS_ERROR: - break; - /* 100G Optical */ - case TRANSVR_CLASS_OPTICAL_100G: - case TRANSVR_CLASS_OPTICAL_100G_AOC: - case TRANSVR_CLASS_OPTICAL_100G_SR4: - case TRANSVR_CLASS_OPTICAL_100G_LR4: - case TRANSVR_CLASS_OPTICAL_100G_ER4: - case TRANSVR_CLASS_OPTICAL_100G_PSM4: - return snprintf(result, lmax, TRANSVR_IF_SP_100G); - /* 100G Copper */ - case TRANSVR_CLASS_COPPER_L4_100G: - return snprintf(result, lmax, TRANSVR_IF_SP_100G); - /* 40G Optical */ - case TRANSVR_CLASS_OPTICAL_40G: - case TRANSVR_CLASS_OPTICAL_40G_AOC: - case TRANSVR_CLASS_OPTICAL_40G_SR4: - case TRANSVR_CLASS_OPTICAL_40G_LR4: - case TRANSVR_CLASS_OPTICAL_40G_ER4: - return snprintf(result, lmax, TRANSVR_IF_SP_40G); - /* 40G Copper */ - case TRANSVR_CLASS_COPPER_L4_40G: - return snprintf(result, lmax, TRANSVR_IF_SP_40G); - /* 10G Optical */ - case TRANSVR_CLASS_OPTICAL_10G: - case TRANSVR_CLASS_OPTICAL_10G_Q_AOC: - case TRANSVR_CLASS_OPTICAL_10G_Q_SR: /* Need Check: SR4 or SR */ - case TRANSVR_CLASS_OPTICAL_10G_Q_LR: /* Need Check: SR4 or SR */ - case TRANSVR_CLASS_OPTICAL_10G_Q_ER: - return snprintf(result, lmax, TRANSVR_IF_SP_10G); - /* 10G Copper */ - case TRANSVR_CLASS_COPPER_L4_10G: - return snprintf(result, lmax, TRANSVR_IF_SP_10G); - /* Optical */ - case TRANSVR_CLASS_OPTICAL: - break; - /* Copper */ - case TRANSVR_CLASS_COPPER: - break; - default: - snprintf(err_msg, sizeof(err_msg), - "Detect undefined class case:%d", - detect_val); - goto err_qsfp_detect_if_speed_1; - } - /* Check br and extbr */ - detect_val = _qsfp_detect_if_sp_by_br(self); - switch(detect_val) { - case TRANSVR_CLASS_UNSPECIFIED: - break; - case TRANSVR_CLASS_10G: - return snprintf(result, lmax, TRANSVR_IF_SP_10G); - case TRANSVR_CLASS_40G: - return snprintf(result, lmax, TRANSVR_IF_SP_40G); - case TRANSVR_CLASS_100G: - return snprintf(result, lmax, TRANSVR_IF_SP_100G); - default: - snprintf(err_msg, sizeof(err_msg), - "Detect undefined BR case:%d", - detect_val); - goto err_qsfp_detect_if_speed_1; - } - /* Exception case: Can't verify */ - snprintf(err_msg, sizeof(err_msg), "Can not identify!"); - goto err_qsfp_detect_if_speed_1; - -err_qsfp_detect_if_speed_1: - snprintf(result, lmax, TRANSVR_UEVENT_UNKNOW); - SWPS_INFO("%s: %s :%s\n", __func__, err_msg, self->swp_name); - return ERR_TRANSVR_ABNORMAL; -} - - -int -qsfp_get_if_speed(struct transvr_obj_s *self, - char *buf_p){ - - int lmax = 16; - char tmp_result[16] = DEBUG_TRANSVR_STR_VAL; - - if (self->state != STATE_TRANSVR_CONNECTED) { - return snprintf(buf_p, lmax, "%d\n", self->state); - } - if (_qsfp_detect_if_speed(self, tmp_result) < 0) { - return snprintf(buf_p, lmax, "%d\n", ERR_TRANSVR_ABNORMAL); - } - return snprintf(buf_p, lmax, "%s\n", tmp_result); -} - - -int -_common_set_lane_map_str(struct transvr_obj_s* self, - char *result) { - int i = 0; - int tmp_val = 0; - char tmp_str[LEN_TRANSVR_L_STR] = DEBUG_TRANSVR_STR_VAL; - char err_msg[LEN_TRANSVR_L_STR] = DEBUG_TRANSVR_STR_VAL; - - memset(result, 0, LEN_TRANSVR_L_STR); - snprintf(result, LEN_TRANSVR_L_STR, "%s=", TRANSVR_UEVENT_KEY_LANE); - - for (i=0; ilane_id); i++) { - tmp_val = self->lane_id[i]; - if (tmp_val < 1) { - break; - } - if (tmp_val > 256) { - snprintf(err_msg, sizeof(err_msg), - "detect abnormal value:%d", tmp_val); - goto err_common_set_lane_map_str_1; - } - memset(tmp_str, 0, sizeof(tmp_str)); - if (i == 0) { - snprintf(tmp_str, LEN_TRANSVR_L_STR, "%d", tmp_val); - } else { - snprintf(tmp_str, LEN_TRANSVR_L_STR, ",%d", tmp_val); - } - strncat(result, tmp_str, LEN_TRANSVR_L_STR); - } - if (i == 0) { - goto err_common_set_lane_map_str_2; - } - return 0; - -err_common_set_lane_map_str_1: - SWPS_INFO("%s: %s", __func__, err_msg); -err_common_set_lane_map_str_2: - snprintf(result, LEN_TRANSVR_L_STR, "%s=%s", TRANSVR_UEVENT_KEY_LANE, TRANSVR_UEVENT_UNKNOW); - return EVENT_TRANSVR_TASK_FAIL; -} - - -int -_common_send_uevent(struct transvr_obj_s* self, - enum kobject_action u_action, - int (*detect_if_type)(struct transvr_obj_s *self, char *result), - int (*detect_if_speed)(struct transvr_obj_s *self, char *result), - int send_anyway) { - - char *uevent_envp[4]; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - char tmp_str[32] = DEBUG_TRANSVR_STR_VAL; - char tmp_str_1[32] = DEBUG_TRANSVR_STR_VAL; - char tmp_str_2[32] = DEBUG_TRANSVR_STR_VAL; - char tmp_str_3[64] = DEBUG_TRANSVR_STR_VAL; - - if (TRANSVR_UEVENT_ENABLE != 1) { - return ERR_TRANSVR_NOTSUPPORT; - } - if (_common_get_if_lane(self, tmp_str) < 0) { - snprintf(tmp_str_3, sizeof(tmp_str_3), - "%s=%s", TRANSVR_UEVENT_KEY_LANE, TRANSVR_UEVENT_UNKNOW); - } else { - snprintf(tmp_str_3, sizeof(tmp_str_3), - "%s=%s", TRANSVR_UEVENT_KEY_LANE, tmp_str); - } - switch (u_action) { - case KOBJ_ADD: - /* Detect type */ - if (detect_if_type(self, tmp_str) < 0) { - snprintf(err_msg, sizeof(err_msg), "%s", "Detect interface type fail!"); - snprintf(tmp_str_1, sizeof(tmp_str_1), "%s=%s", TRANSVR_UEVENT_KEY_IF, TRANSVR_UEVENT_UNKNOW); - snprintf(tmp_str_2, sizeof(tmp_str_2), "%s=%s", TRANSVR_UEVENT_KEY_SP, TRANSVR_UEVENT_UNKNOW); - uevent_envp[0] = tmp_str_1; - uevent_envp[1] = tmp_str_2; - uevent_envp[2] = tmp_str_3; - uevent_envp[3] = NULL; - goto private_common_send_uevent_4_fail; - } - snprintf(tmp_str_1, sizeof(tmp_str_1), "%s=%s", TRANSVR_UEVENT_KEY_IF, tmp_str); - uevent_envp[0] = tmp_str_1; - /* Detect speed */ - if (detect_if_speed(self, tmp_str) < 0) { - snprintf(err_msg, sizeof(err_msg), "%s", "Detect interface speed fail!"); - snprintf(tmp_str_2, sizeof(tmp_str_2), "%s=%s", TRANSVR_UEVENT_KEY_SP, TRANSVR_UEVENT_UNKNOW); - uevent_envp[1] = tmp_str_2; - uevent_envp[2] = tmp_str_3; - uevent_envp[3] = NULL; - goto private_common_send_uevent_4_fail; - } - snprintf(tmp_str_2, sizeof(tmp_str_2), "%s=%s", TRANSVR_UEVENT_KEY_SP, tmp_str); - uevent_envp[1] = tmp_str_2; - uevent_envp[2] = tmp_str_3; - uevent_envp[3] = NULL; - goto private_common_send_uevent_4_send; - - case KOBJ_REMOVE: - snprintf(tmp_str_1, sizeof(tmp_str_1), "%s=%s", TRANSVR_UEVENT_KEY_IF, TRANSVR_UEVENT_UNKNOW); - snprintf(tmp_str_2, sizeof(tmp_str_2), "%s=%s", TRANSVR_UEVENT_KEY_SP, TRANSVR_UEVENT_UNKNOW); - uevent_envp[0] = tmp_str_1; - uevent_envp[1] = tmp_str_2; - uevent_envp[2] = tmp_str_3; - uevent_envp[3] = NULL; - goto private_common_send_uevent_4_send; - - default: - snprintf(err_msg, sizeof(err_msg), "kobject_action:%d not support", u_action); - goto private_common_send_uevent_4_fail; - } - snprintf(err_msg, sizeof(err_msg), "%s", "Exception case"); - goto private_common_send_uevent_4_fail; - -private_common_send_uevent_4_fail: - SWPS_INFO("%s: %s :%s\n", __func__, err_msg, self->swp_name); - if (send_anyway) { - goto private_common_send_uevent_4_send; - } - return ERR_TRANSVR_UEVENT_FAIL; - -private_common_send_uevent_4_send: - return kobject_uevent_env(&(self->transvr_dev_p->kobj), - u_action, - uevent_envp); -} - -int -sfp_send_uevent(struct transvr_obj_s* self, - enum kobject_action u_action) { - int send_anyway = 1; - return _common_send_uevent(self, - u_action, - &_sfp_detect_if_type, - &_sfp_detect_if_speed, - send_anyway); -} - - -int -qsfp_send_uevent(struct transvr_obj_s* self, - enum kobject_action u_action) { - int send_anyway = 1; - return _common_send_uevent(self, - u_action, - &_qsfp_detect_if_type, - &_qsfp_detect_if_speed, - send_anyway); -} - - -int -fake_send_uevent(struct transvr_obj_s* self, - enum kobject_action u_action) { - return EVENT_TRANSVR_TASK_DONE; -} - - -int -common_fsm_4_direct_mode(struct transvr_obj_s* self, - char *caller_name){ - - int err; - int detect_result[2]; - int current_state = STATE_TRANSVR_UNEXCEPTED; - int current_type = TRANSVR_TYPE_ERROR; - - if (self->state == STATE_TRANSVR_NEW) { - if (_transvr_init_handler(self) < 0){ - return ERR_TRANSVR_INIT_FAIL; - } - } - err = detect_transvr_state(self, detect_result); - if (err < 0) { - return err; - } - /* In Direct mode, driver only detect transceiver when user call driver interface - * which on sysfs. So it only need consider the state of Transceiver. - */ - current_state = detect_result[0]; - current_type = detect_result[1]; - - switch (current_state){ - - case STATE_TRANSVR_DISCONNECTED: /* Transceiver is not plugged */ - self->state = current_state; - self->type = current_type; - return ERR_TRANSVR_UNPLUGGED; - - case STATE_TRANSVR_INIT: /* Transceiver is plugged, system not ready */ - return ERR_TRANSVR_UNINIT; - - case STATE_TRANSVR_ISOLATED: /* Transceiver is plugged, but has some issues */ - return ERR_TRNASVR_BE_ISOLATED; - - case STATE_TRANSVR_CONNECTED: /* Transceiver is plugged, system is ready */ - self->state = current_state; - self->type = current_type; - return 0; - - case STATE_TRANSVR_SWAPPED: /* Transceiver is plugged, system detect user changed */ - self->type = current_type; - if (reload_transvr_obj(self, current_type) < 0){ - self->state = STATE_TRANSVR_UNEXCEPTED; - return ERR_TRANSVR_UNEXCPT; - } - self->state = current_state; - return 0; - - case STATE_TRANSVR_UNEXCEPTED: /* Transceiver type or state is unexpected case */ - self->state = STATE_TRANSVR_UNEXCEPTED; - self->type = TRANSVR_TYPE_ERROR; - return ERR_TRANSVR_UNEXCPT; - - default: - SWPS_INFO("%s: state:%d not in define.\n", __func__, current_state); - break; - } - return ERR_TRANSVR_UNEXCPT; -} - - -static int -_is_except_happened_4_pmode(struct transvr_obj_s* self, - int new_state) { - - int event_chk = 0; - - if (self->temp == 0){ - return 0; - } - switch (new_state) { - case STATE_TRANSVR_INIT: - event_chk = EVENT_TRANSVR_EXCEP_INIT; - goto check_event_happened_4_pmode; - - case STATE_TRANSVR_CONNECTED: - event_chk = EVENT_TRANSVR_EXCEP_UP; - goto check_event_happened_4_pmode; - - case STATE_TRANSVR_DISCONNECTED: - event_chk = EVENT_TRANSVR_EXCEP_DOWN; - goto check_event_happened_4_pmode; - - case STATE_TRANSVR_SWAPPED: - event_chk = EVENT_TRANSVR_EXCEP_SWAP; - goto check_event_happened_4_pmode; - - case STATE_TRANSVR_UNEXCEPTED: - event_chk = EVENT_TRANSVR_EXCEP_EXCEP; - goto check_event_happened_4_pmode; - - case STATE_TRANSVR_ISOLATED: - event_chk = EVENT_TRANSVR_EXCEP_ISOLATED; - goto check_event_happened_4_pmode; - - default: - SWPS_INFO("%s: unexcepted case:%d\n", __func__, new_state); - break; - } - return 0; - -check_event_happened_4_pmode: - if (self->temp == event_chk){ - return 1; - } - return 0; -} - - -int -common_fsm_4_polling_mode(struct transvr_obj_s* self, - char *caller_name){ - /* [Return Value]: - * ERR_TRANSVR_UNINIT : (1) Initial not ready - * ERR_TRANSVR_UNPLUGGED : (1) Any -> Down - * ERR_TRANSVR_TASK_BUSY : (1) Wait Initial task - * ERR_TRANSVR_UNEXCPT : (1) Initial fail - * (2) Task fail - * (3) Reload fail - * ERR_TRNASVR_BE_ISOLATED : (1) Already be isolated - * OK Case (return 0) : (1) action_4_connected - * (2) action_4_nothing (initial retry) - */ - int curr_state[2]; - int old_state = self->state; - int old_type = self->type; - int new_state = STATE_TRANSVR_UNEXCEPTED; - int new_type = TRANSVR_TYPE_ERROR; - int return_val = ERR_TRANSVR_UNEXCPT; - - /* Never initial */ - if (self->state == STATE_TRANSVR_NEW) { - goto comfsm_action_4_reinit_obj; - } - /* Detect current state */ - switch (detect_transvr_state(self, curr_state)) { - case 0: - new_state = curr_state[0]; - new_type = curr_state[1]; - break; - - case ERR_TRNASVR_BE_ISOLATED: - new_state = STATE_TRANSVR_ISOLATED; - new_type = old_type; - break; - - case ERR_TRANSVR_I2C_CRASH: - goto comfsm_action_4_report_i2c_crash; - - case ERR_TRANSVR_UNEXCPT: - default: - new_state = STATE_TRANSVR_UNEXCEPTED; - new_type = old_type; - } - /* State handling */ - switch (old_state) { - case STATE_TRANSVR_INIT: /* INIT -> */ - return_val = ERR_TRANSVR_UNINIT; - goto comfsm_action_4_keep_state; - - case STATE_TRANSVR_CONNECTED: - switch (new_state) { - case STATE_TRANSVR_INIT: /* Case 1-1: UP -> INIT */ - SWPS_INFO("Detect %s is present. :1-1\n",self->swp_name); - return_val = ERR_TRANSVR_UNINIT; - goto comfsm_action_4_keep_state; - - case STATE_TRANSVR_CONNECTED: /* Case 1-2: UP -> UP */ - return_val = 0; - goto comfsm_action_4_keep_state; - - case STATE_TRANSVR_DISCONNECTED: /* Case 1-3: UP -> DOWN */ - SWPS_INFO("Detect %s is removed. :1-3\n",self->swp_name); - goto comfsm_action_4_disconnected; - - case STATE_TRANSVR_SWAPPED: /* Case 1-4: UP -> SWAP */ - SWPS_INFO("Detect %s is swapped. :1-4\n",self->swp_name); - goto comfsm_action_4_reload_obj; - - case STATE_TRANSVR_UNEXCEPTED: /* Case 1-5: UP -> UNEXPET */ - SWPS_INFO("Detect %s has error. :1-5\n",self->swp_name); - goto comfsm_action_4_unexpected; - - case STATE_TRANSVR_ISOLATED: /* Case 1-6: UP -> ISOLATE */ - SWPS_INFO("Detect %s be isolated. :1-6\n",self->swp_name); - goto comfsm_action_4_isolate_obj; - - default: - break; - } - goto comfsm_action_4_unexpected; - - case STATE_TRANSVR_DISCONNECTED: - switch (new_state) { - case STATE_TRANSVR_INIT: /* Case 2-1: DOWN -> INIT */ - SWPS_INFO("Detect %s is present. :2-1\n",self->swp_name); - return_val = ERR_TRANSVR_UNINIT; - goto comfsm_action_4_keep_state; - - case STATE_TRANSVR_CONNECTED: /* Case 2-2: DOWN -> UP */ - SWPS_INFO("Detect %s is present. :2-2\n",self->swp_name); - goto comfsm_action_4_reinit_obj; - - case STATE_TRANSVR_DISCONNECTED: /* Case 2-3: DOWN -> DOWN */ - return_val = ERR_TRANSVR_UNPLUGGED; - goto comfsm_action_4_keep_state; - - case STATE_TRANSVR_SWAPPED: /* Case 2-4: DOWN -> SWAP */ - SWPS_INFO("Detect %s is swapped. :2-4\n",self->swp_name); - goto comfsm_action_4_reload_obj; - - case STATE_TRANSVR_UNEXCEPTED: /* Case 2-5: DOWN -> UNEXPET */ - SWPS_INFO("Detect %s has error. :2-5\n",self->swp_name); - goto comfsm_action_4_unexpected; - - case STATE_TRANSVR_ISOLATED: /* Case 2-6: DOWN -> ISOLATE */ - SWPS_INFO("Detect %s be isolated. :2-6\n",self->swp_name); - goto comfsm_action_4_isolate_obj; - - default: - break; - } - goto comfsm_action_4_unexpected; - - case STATE_TRANSVR_UNEXCEPTED: - /* Filter out re-action */ - if (_is_except_happened_4_pmode(self, new_state)) { - goto comfsm_action_4_keep_state; - } - /* First action */ - switch (new_state) { - case STATE_TRANSVR_INIT: /* Case 3-1: UNEXPET -> INIT */ - SWPS_INFO("Detect %s is present. :3-1\n",self->swp_name); - self->temp = EVENT_TRANSVR_EXCEP_INIT; - return_val = ERR_TRANSVR_UNINIT; - goto comfsm_action_4_keep_state; - - case STATE_TRANSVR_CONNECTED: /* Case 3-2: UNEXPET -> UP */ - SWPS_INFO("Detect %s is present. :3-2\n",self->swp_name); - self->temp = EVENT_TRANSVR_EXCEP_UP; - goto comfsm_action_4_reload_obj; - - case STATE_TRANSVR_DISCONNECTED: /* Case 3-3: UNEXPET -> DOWN */ - SWPS_INFO("Detect %s is removed. :3-3\n",self->swp_name); - goto comfsm_action_4_disconnected; - - case STATE_TRANSVR_SWAPPED: /* Case 3-4: UNEXPET -> SWAP */ - SWPS_INFO("Detect %s is swapped. :3-4\n",self->swp_name); - self->temp = EVENT_TRANSVR_EXCEP_SWAP; - goto comfsm_action_4_reload_obj; - - case STATE_TRANSVR_UNEXCEPTED: /* Case 3-5: UNEXPET -> UNEXPET */ - self->temp = EVENT_TRANSVR_EXCEP_EXCEP; - return_val = ERR_TRANSVR_UNEXCPT; - goto comfsm_action_4_keep_state; - - case STATE_TRANSVR_ISOLATED: /* Case 3-6: UNEXPET -> ISOLATE */ - SWPS_INFO("Detect %s be isolated. :3-6\n",self->swp_name); - goto comfsm_action_4_isolate_obj; - - default: - break; - } - goto comfsm_action_4_unexpected; - - case STATE_TRANSVR_ISOLATED: - /* Filter out re-action */ - if (_is_except_happened_4_pmode(self, new_state)) { - goto comfsm_action_4_keep_state; - } - /* First action */ - switch (new_state) { - case STATE_TRANSVR_INIT: /* Case 4-1: ISOLATE -> INIT */ - SWPS_INFO("Detect %s internal error. :4-1\n",self->swp_name); - self->temp = EVENT_TRANSVR_EXCEP_INIT; - return_val = ERR_TRNASVR_BE_ISOLATED; - goto comfsm_action_4_keep_state; - - case STATE_TRANSVR_CONNECTED: /* Case 4-2: ISOLATE -> UP */ - SWPS_INFO("Detect %s internal error. :4-2\n",self->swp_name); - self->temp = EVENT_TRANSVR_EXCEP_UP; - return_val = ERR_TRNASVR_BE_ISOLATED; - goto comfsm_action_4_keep_state; - - case STATE_TRANSVR_DISCONNECTED: /* Case 4-3: ISOLATE -> DOWN */ - SWPS_INFO("Detect %s is removed. :4-3\n",self->swp_name); - goto comfsm_action_4_disconnected; - - case STATE_TRANSVR_SWAPPED: /* Case 4-4: ISOLATE -> SWAP */ - SWPS_INFO("Detect %s internal error. :4-4\n",self->swp_name); - self->temp = EVENT_TRANSVR_EXCEP_SWAP; - return_val = ERR_TRNASVR_BE_ISOLATED; - goto comfsm_action_4_keep_state; - - case STATE_TRANSVR_UNEXCEPTED: /* Case 4-5: ISOLATE -> UNEXPET */ - SWPS_INFO("Detect %s internal error. :4-5\n",self->swp_name); - self->temp = EVENT_TRANSVR_EXCEP_EXCEP; - return_val = ERR_TRNASVR_BE_ISOLATED; - goto comfsm_action_4_keep_state; - - case STATE_TRANSVR_ISOLATED: /* Case 4-6: ISOLATE -> ISOLATE */ - return_val = ERR_TRNASVR_BE_ISOLATED; - goto comfsm_action_4_keep_state; - - default: - break; - } - goto comfsm_action_4_unexpected; - - default: - break; - } - goto comfsm_action_4_unexpected; - - -comfsm_action_4_keep_state: - return return_val; - -comfsm_action_4_reinit_obj: - SWPS_DEBUG("FSM action: %s re-initial.\n", self->swp_name); - return_val = _transvr_init_handler(self); - goto comfsm_action_4_identify_event; - -comfsm_action_4_reload_obj: - SWPS_DEBUG("FSM action: %s reload.\n", self->swp_name); - self->type = new_type; - return_val = reload_transvr_obj(self, new_type); - goto comfsm_action_4_identify_event; - -comfsm_action_4_identify_event: - switch (return_val) { - case EVENT_TRANSVR_INIT_UP: - case EVENT_TRANSVR_TASK_DONE: - goto comfsm_action_4_connected; - - case EVENT_TRANSVR_INIT_DOWN: - goto comfsm_action_4_disconnected; - - case EVENT_TRANSVR_INIT_REINIT: - goto comfsm_action_4_nothing; - - case EVENT_TRANSVR_TASK_WAIT: - self->state = STATE_TRANSVR_INIT; - return ERR_TRANSVR_TASK_BUSY; - - case EVENT_TRANSVR_TASK_FAIL: - SWPS_INFO("%s detect EVENT_TRANSVR_TASK_FAIL.\n", self->swp_name); - goto comfsm_action_4_unexpected; - - case EVENT_TRANSVR_INIT_FAIL: - SWPS_INFO("%s detect EVENT_TRANSVR_INIT_FAIL.\n", self->swp_name); - goto comfsm_action_4_unexpected; - - case EVENT_TRANSVR_RELOAD_FAIL: - SWPS_INFO("%s detect EVENT_TRANSVR_RELOAD_FAIL.\n", self->swp_name); - goto comfsm_action_4_unexpected; - - case EVENT_TRANSVR_I2C_CRASH: - goto comfsm_action_4_report_i2c_crash; - - case EVENT_TRANSVR_EXCEP_ISOLATED: - goto comfsm_action_4_isolate_obj; - - default: - SWPS_INFO("%s detect undefined event:%d.\n", self->swp_name, return_val); - goto comfsm_action_4_unexpected; - } - -comfsm_action_4_nothing: - SWPS_DEBUG("FSM action: %s do nothing.\n", self->swp_name); - return 0; - -comfsm_action_4_connected: - SWPS_DEBUG("FSM action: %s Connected.\n", self->swp_name); - self->state = STATE_TRANSVR_CONNECTED; - self->type = new_type; - self->send_uevent(self, KOBJ_ADD); - _transvr_clean_retry(self); - return 0; - -comfsm_action_4_disconnected: - SWPS_DEBUG("FSM action: %s Disconnected. \n", self->swp_name); - self->state = STATE_TRANSVR_DISCONNECTED; - self->temp = EVENT_TRANSVR_TASK_DONE; - self->send_uevent(self, KOBJ_REMOVE); - _transvr_clean_retry(self); - _transvr_clean_handler(self); - return ERR_TRANSVR_UNPLUGGED; - -comfsm_action_4_report_i2c_crash: - SWPS_DEBUG("FSM action: %s report I2C crash.\n", self->swp_name); - self->state = STATE_TRANSVR_UNEXCEPTED; - return ERR_TRANSVR_I2C_CRASH; - -comfsm_action_4_isolate_obj: - SWPS_DEBUG("FSM action: %s isolate.\n", self->swp_name); - self->state = STATE_TRANSVR_ISOLATED; - return ERR_TRNASVR_BE_ISOLATED; - -comfsm_action_4_unexpected: - SWPS_INFO("FSM action: %s unexpected.\n", self->swp_name); - SWPS_INFO("Dump: :%d :0x%02x :%d :0x%02x\n", - old_state, old_type, new_state, new_type); - self->state = STATE_TRANSVR_UNEXCEPTED; - self->send_uevent(self, KOBJ_REMOVE); - _transvr_clean_handler(self); - return ERR_TRANSVR_UNEXCPT; -} - - -int -fake_fsm_4_direct_mode(struct transvr_obj_s* self, - char *caller_name){ - self->state = STATE_TRANSVR_CONNECTED; - self->type = TRANSVR_TYPE_FAKE; - return 0; -} - - -int -fake_fsm_4_polling_mode(struct transvr_obj_s* self, - char *caller_name){ - self->state = STATE_TRANSVR_CONNECTED; - self->type = TRANSVR_TYPE_FAKE; - return 0; -} - - -/* ========== Object functions for Initial procedure ========== - */ -int -transvr_init_common(struct transvr_obj_s *self){ - /* Nothing to update */ - return EVENT_TRANSVR_TASK_DONE; -} - - -int -transvr_init_fake(struct transvr_obj_s *self){ - return EVENT_TRANSVR_TASK_DONE; -} - - -int -transvr_init_sfp(struct transvr_obj_s *self){ - - int tmp_val = DEBUG_TRANSVR_INT_VAL; - int err_code = DEBUG_TRANSVR_INT_VAL; - char *err_msg = "ERR"; - - self->info = sft_detect_transvr_class(self); - /* Disable auto_config */ - if (!self->auto_config) { - return EVENT_TRANSVR_TASK_DONE; - } - /* Handle multi-rate */ - err_code = initfunc_sfp_handle_multi_rate_mode(self); - if (err_code < 0) { - err_msg = "initfunc_sfp_handle_multi_rate_mode fail!"; - goto err_transvr_init_sfp_1; - } - /* Handle 1G- RJ45 */ - tmp_val = err_code; - err_code = initfunc_sfp_handle_1g_rj45(self); - if (err_code < 0) { - err_msg = "initfunc_sfp_handle_1g_rj45 fail!"; - goto err_transvr_init_sfp_1; - } - tmp_val = (tmp_val > err_code ? tmp_val : err_code); - if (tmp_val > EVENT_TRANSVR_TASK_DONE) { - return tmp_val; - } - return EVENT_TRANSVR_TASK_DONE; - -err_transvr_init_sfp_1: - SWPS_INFO("%s: %s :%d :%s\n", - __func__, err_msg, err_code, self->swp_name); - return EVENT_TRANSVR_INIT_FAIL; -} - - -int -transvr_init_qsfp(struct transvr_obj_s *self){ - - int err = EVENT_TRANSVR_EXCEP_EXCEP; - char *emsg = "ERR"; - - self->info = qsft_detect_transvr_class(self); - if (!self->auto_config) { - return EVENT_TRANSVR_TASK_DONE; - } - err = initfunc_qsfp_handle_power_mode(self); - if (err < 0){ - emsg = "initfunc_qsfp_handle_tx_disable fail!"; - goto err_transvr_init_qsfp; - } - return EVENT_TRANSVR_TASK_DONE; - -err_transvr_init_qsfp: - SWPS_INFO("%s: %s :%d :%s\n", - __func__, emsg, err, self->swp_name); - return EVENT_TRANSVR_INIT_FAIL; -} - - -int -transvr_init_qsfp28(struct transvr_obj_s *self){ - - int tmp_val = EVENT_TRANSVR_EXCEP_EXCEP; - int err_val = EVENT_TRANSVR_EXCEP_EXCEP; - char *err_msg = "ERR"; - - /* Handle QSFP common */ - err_val = transvr_init_qsfp(self); - if (err_val < 0){ - err_msg = "transvr_init_qsfp fail!"; - goto err_transvr_init_qsfp28_1; - } - /* Disable auto_config */ - if (!self->auto_config) { - return err_val; - } - /* Handle CDR */ - tmp_val = err_val; - err_val = initfunc_qsfp28_handle_cdr(self); - if (err_val < 0){ - err_msg = "Handle CDR fail!"; - goto err_transvr_init_qsfp28_1; - } - tmp_val = (tmp_val > err_val ? tmp_val : err_val); - if (tmp_val > EVENT_TRANSVR_TASK_DONE) { - return tmp_val; - } - return EVENT_TRANSVR_TASK_DONE; - -err_transvr_init_qsfp28_1: - SWPS_INFO("%s: %s :%d :%s\n", - __func__, err_msg, err_val, self->swp_name); - return EVENT_TRANSVR_INIT_FAIL; -} - - -/* ========== Object Initial handler ========== - */ -static int -_is_transvr_valid(struct transvr_obj_s *self, - int type, - int state) { - /* [Return] - * 0 : OK, inserted - * EVENT_TRANSVR_INIT_DOWN : OK, removed - * EVENT_TRANSVR_INIT_FAIL : Outside error, type doesn't supported - * EVENT_TRANSVR_EXCEP_INIT : Internal error, state undefined - */ - switch (type) { - case TRANSVR_TYPE_SFP: - case TRANSVR_TYPE_QSFP: - case TRANSVR_TYPE_QSFP_PLUS: - case TRANSVR_TYPE_QSFP_28: - case TRANSVR_TYPE_UNPLUGGED: - case TRANSVR_TYPE_FAKE: - break; - default: - SWPS_INFO("detect undefined type:0x%02x on %s\n", - type, self->swp_name); - return EVENT_TRANSVR_INIT_FAIL; - } - switch (state) { - case STATE_TRANSVR_DISCONNECTED: - return EVENT_TRANSVR_INIT_DOWN; - case STATE_TRANSVR_INIT: - case STATE_TRANSVR_CONNECTED: - case STATE_TRANSVR_SWAPPED: - break; - default: - SWPS_INFO("detect undefined state:%d on %s\n", - state, self->swp_name); - return EVENT_TRANSVR_EXCEP_INIT; - } - return 0; -} - - -static int -_is_transvr_hw_ready(struct transvr_obj_s *self, - int type){ - /* [Return] - * EVENT_TRANSVR_TASK_DONE : Ready - * EVENT_TRANSVR_TASK_WAIT : Not ready - * EVENT_TRANSVR_INIT_FAIL : Error - */ - int addr = DEBUG_TRANSVR_INT_VAL; - int page = DEBUG_TRANSVR_INT_VAL; - int offs = DEBUG_TRANSVR_INT_VAL; - int bit = DEBUG_TRANSVR_INT_VAL; - int ready = DEBUG_TRANSVR_INT_VAL; - int err = DEBUG_TRANSVR_INT_VAL; - char *emsg = DEBUG_TRANSVR_STR_VAL; - uint8_t ab_val = DEBUG_TRANSVR_HEX_VAL; - - switch (type) { - case TRANSVR_TYPE_SFP: - addr = VAL_TRANSVR_8472_READY_ADDR; - page = VAL_TRANSVR_8472_READY_PAGE; - offs = VAL_TRANSVR_8472_READY_OFFSET; - bit = VAL_TRANSVR_8472_READY_BIT; - ready = VAL_TRANSVR_8472_READY_VALUE; - ab_val = VAL_TRANSVR_8472_READY_ABNORMAL; - break; - - case TRANSVR_TYPE_QSFP: - case TRANSVR_TYPE_QSFP_PLUS: - case TRANSVR_TYPE_QSFP_28: - addr = VAL_TRANSVR_8436_READY_ADDR; - page = VAL_TRANSVR_8436_READY_PAGE; - offs = VAL_TRANSVR_8436_READY_OFFSET; - bit = VAL_TRANSVR_8436_READY_BIT; - ready = VAL_TRANSVR_8436_READY_VALUE; - ab_val = VAL_TRANSVR_8436_READY_ABNORMAL; - break; - - case TRANSVR_TYPE_UNPLUGGED: - case TRANSVR_TYPE_FAKE: - return EVENT_TRANSVR_TASK_DONE; - - default: - emsg = "unexpected case"; - goto err_is_transvr_hw_ready; - } - /* Select target page */ - err = _common_setup_page(self, addr, page, offs, 1, 0); - if (err < 0) { - emsg = "setup page fail"; - goto err_is_transvr_hw_ready; - } - /* Check feature supported - * [Note] - * Some of transceiver/cables doesn't support "Status Indicators" - * (ex:DAC, RJ45 copper SFP ...etc). In these case, we bypass the - * step of checking Status Indicators, then state machine will take - * the following handle procedure. - */ - err = i2c_smbus_read_byte_data(self->i2c_client_p, - VAL_TRANSVR_COMID_OFFSET); - if (err < 0) { - emsg = "doesn't support Status Indicators"; - goto bypass_is_transvr_hw_ready; - } - /* Filter abnormal case */ - if (err == ab_val) { - emsg = "detect using unusual definition."; - goto bypass_is_transvr_hw_ready; - } - /* Get Status Indicators */ - err = i2c_smbus_read_byte_data(self->i2c_client_p, offs); - if (err < 0) { - emsg = "detect current value fail"; - goto err_is_transvr_hw_ready; - } - if ((err & (1<:%d\n", __func__, emsg, type); - return EVENT_TRANSVR_TASK_DONE; - -err_is_transvr_hw_ready: - SWPS_DEBUG("%s: %s :%d\n", __func__, emsg, type); - return EVENT_TRANSVR_INIT_FAIL; -} - - -static int -_is_transvr_support_ctle(struct transvr_obj_s *self) { - - switch (self->info) { - case TRANSVR_CLASS_OPTICAL_25G: - case TRANSVR_CLASS_OPTICAL_25G_AOC: - case TRANSVR_CLASS_OPTICAL_25G_SR: - case TRANSVR_CLASS_OPTICAL_25G_LR: - case TRANSVR_CLASS_OPTICAL_25G_ER: - case TRANSVR_CLASS_OPTICAL_100G: - case TRANSVR_CLASS_OPTICAL_100G_AOC: - case TRANSVR_CLASS_OPTICAL_100G_SR4: - case TRANSVR_CLASS_OPTICAL_100G_LR4: - case TRANSVR_CLASS_OPTICAL_100G_ER4: - case TRANSVR_CLASS_OPTICAL_100G_PSM4: - return 1; - default: - break; - } - return 0; -} - - -static int -_transvr_init_handler(struct transvr_obj_s *self){ - - int detect[2]; - int d_state = STATE_TRANSVR_UNEXCEPTED; - int d_type = TRANSVR_TYPE_ERROR; - int result = ERR_TRANSVR_UNINIT; - int retry = 6; /* (6+1) x 0.3 = 2.1s > spec:2.0s */ - int elimit = 63; - char emsg[64] = DEBUG_TRANSVR_STR_VAL; - - /* Clean and check callback */ - self->state = STATE_TRANSVR_INIT; - if (self->init == NULL) { - snprintf(emsg, elimit, "init() is null"); - goto initer_err_case_unexcept_0; - } - if (self->clean == NULL) { - snprintf(emsg, elimit, "clean() is null"); - goto initer_err_case_unexcept_0; - } - self->clean(self); - - /* Detect transceiver information */ - result = detect_transvr_state(self, detect); - if (result < 0) { - snprintf(emsg, elimit, "detect_transvr_state() fail"); - switch (result) { - case ERR_TRANSVR_I2C_CRASH: - goto initer_err_case_i2c_ceash; - case ERR_TRNASVR_BE_ISOLATED: - goto initer_err_case_be_isolated; - - case ERR_TRANSVR_UNEXCPT: - default: - break; - } - goto initer_err_case_retry_1; - } - d_state = detect[0]; - d_type = detect[1]; - - /* Verify transceiver type and state */ - switch (_is_transvr_valid(self, d_type, d_state)) { - case 0: - break; - case EVENT_TRANSVR_INIT_DOWN: - goto initer_ok_case_down;; - case EVENT_TRANSVR_INIT_FAIL: - snprintf(emsg, elimit, "transceiver type doesn't support"); - goto initer_err_case_alarm_to_user; - case EVENT_TRANSVR_EXCEP_INIT: - default: - goto initer_err_case_unexcept_1; - } - - /* Handle reload case */ - if (self->type != d_type){ - /* This is the protect mechanism. Normally, This case will not happen. - * When State machine detect swap event during initial, It will trigger - * reload function to ensure type correct. */ - if (_reload_transvr_obj(self, d_type) < 0){ - snprintf(emsg, elimit, "reload object fail"); - goto initer_err_case_unexcept_1; - } - } - - /* Check transceiver HW initial ready */ - switch (_is_transvr_hw_ready(self, d_type)) { - case EVENT_TRANSVR_TASK_DONE: - break; - case EVENT_TRANSVR_TASK_WAIT: - goto initer_err_case_retry_1; - case EVENT_TRANSVR_INIT_FAIL: - default: - goto initer_err_case_unexcept_1; - } - - /* Try to update all and check */ - if (self->update_all(self, 1) < 0){ - /* For some transceiver, EEPROME has lag issues during initial stage. - * In this case, we set status back to STATE_TRANSVR_NEW, than it will - * be checked in next polling cycle. */ - goto initer_err_case_retry_1; - } - - /* Execute init() call back */ - result = self->init(self); - switch (result) { - case EVENT_TRANSVR_TASK_DONE: - break; - case EVENT_TRANSVR_TASK_WAIT: - goto initer_ok_case_wait; - - default: - snprintf(emsg, elimit, "undefined init() return:%d\n", result); - goto initer_err_case_unexcept_1; - } - goto initer_ok_case_up; - - -initer_ok_case_wait: - self->dump_all(self); - return EVENT_TRANSVR_TASK_WAIT; - -initer_ok_case_up: - self->state = STATE_TRANSVR_CONNECTED; - self->temp = 0; - self->dump_all(self); - return EVENT_TRANSVR_INIT_UP; - -initer_ok_case_down: - self->temp = 0; - self->state = STATE_TRANSVR_DISCONNECTED; - return EVENT_TRANSVR_INIT_DOWN; - -initer_err_case_i2c_ceash: - SWPS_DEBUG("%s: %s :%s :I2C crash\n", - __func__, emsg, self->swp_name); - self->state = STATE_TRANSVR_UNEXCEPTED; - return EVENT_TRANSVR_I2C_CRASH; - -initer_err_case_be_isolated: - SWPS_DEBUG("%s: %s :%s :isolated\n", - __func__, emsg, self->swp_name); - self->state = STATE_TRANSVR_ISOLATED; - return EVENT_TRANSVR_EXCEP_ISOLATED; - -initer_err_case_retry_1: - SWPS_DEBUG("%s: %s :%s :retry\n", - __func__, emsg, self->swp_name); - if (_transvr_handle_retry(self, retry) == 0) { - self->state = STATE_TRANSVR_NEW; - return EVENT_TRANSVR_INIT_REINIT; - } - goto initer_err_case_alarm_to_user; - -initer_err_case_unexcept_1: - self->clean(self); -initer_err_case_unexcept_0: - self->state = STATE_TRANSVR_UNEXCEPTED; - if (_is_except_happened_4_pmode(self, d_state) && - (self->mode == TRANSVR_MODE_POLLING) ){ - SWPS_INFO("%s: %s :%s\n", __func__, emsg, self->swp_name); - SWPS_INFO("Dump: :%d :%d :%d :%d\n", - self->state, self->type, d_state, d_type); - } - return EVENT_TRANSVR_INIT_FAIL; - -initer_err_case_alarm_to_user: - SWPS_DEBUG("%s: %s :%s :alarm_to_user\n", - __func__, emsg, self->swp_name); - self->state = STATE_TRANSVR_UNEXCEPTED; - alarm_msg_2_user(self, "detected transceiver/cables not meet SFF standard"); - return EVENT_TRANSVR_INIT_FAIL; -} - - -/* ========== Object functions for Clean procedure ========== - */ -int -_transvr_clean_handler(struct transvr_obj_s *self){ - - int retval = DEBUG_TRANSVR_INT_VAL; - - if (!self->clean) { - SWPS_ERR("%s: %s clean() is NULL.\n", - __func__, self->swp_name); - return EVENT_TRANSVR_TASK_FAIL; - } - retval = self->clean(self); - if (retval != EVENT_TRANSVR_TASK_DONE){ - SWPS_ERR("%s: %s clean() fail. [ERR]:%d\n", - __func__, self->swp_name, retval); - return retval; - } - return EVENT_TRANSVR_TASK_DONE; -} - - -int -common_transvr_clean(struct transvr_obj_s *self){ - - transvr_task_free_all(self); - transvr_cache_free_all(self); - return EVENT_TRANSVR_TASK_DONE; -} - - -int -qsfp_transvr_clean(struct transvr_obj_s *self){ - - int retval; - int lpower_config = 1; - - retval = _taskfunc_qsfp_setup_power_mod(self, lpower_config); - if (retval < 0){ - SWPS_ERR("%s: Set lpmod fail! :%d\n", - __func__, retval); - return retval; - } - retval = common_transvr_clean(self); - if (retval < 0){ - SWPS_ERR("%s: common_transvr_clean fail! :%d\n", - __func__, retval); - return retval; - } - return EVENT_TRANSVR_TASK_DONE; -} - - -int -fake_transvr_clean(struct transvr_obj_s *self){ - - return EVENT_TRANSVR_TASK_DONE; -} - - -/* ========== Object functions for check and update ========== - */ -int -common_transvr_check(struct transvr_obj_s *self){ - - char fun_str[32] = "common_transvr_check"; - - if (self->mode != TRANSVR_MODE_POLLING) { - SWPS_ERR("%s: mode:%d is not TRANSVR_MODE_POLLING\n", - fun_str, self->mode); - return ERR_TRANSVR_UNEXCPT; - } - /* Trigger delay task */ - transvr_task_run_all(self); - /* Trigger state machine to check and update */ - return self->fsm_4_polling(self, fun_str); -} - - -int -fake_transvr_check(struct transvr_obj_s *self){ - return 0; -} - - -/* ========== Functions for Factory pattern ========== - */ -static int -setup_transvr_public_cb(struct transvr_obj_s *self, - int transvr_type){ - switch (transvr_type){ - case TRANSVR_TYPE_SFP: - self->get_id = common_get_id; - self->get_eeprom = common_get_eeprom; - self->get_ext_id = common_get_ext_id; - self->get_connector = common_get_connector; - self->get_vendor_name = common_get_vendor_name; - self->get_vendor_pn = common_get_vendor_pn; - self->get_vendor_rev = common_get_vendor_rev; - self->get_vendor_sn = common_get_vendor_sn; - self->get_power_cls = unsupported_get_func; - self->get_br = common_get_br; - self->get_len_sm = sfp_get_len_sm; - self->get_len_smf = common_get_len_smf; - self->get_len_om1 = common_get_len_om1; - self->get_len_om2 = common_get_len_om2; - self->get_len_om3 = common_get_len_om3; - self->get_len_om4 = common_get_len_om4; - self->get_comp_rev = common_get_comp_rev; - self->get_comp_eth_1 = sfp_get_comp_eth_1; - self->get_comp_eth_10 = sfp_get_comp_eth_10; - self->get_comp_eth_10_40 = unsupported_get_func; - self->get_comp_extend = common_get_comp_extended; - self->get_cdr = unsupported_get_func; - self->get_rate_id = sfp_get_rate_id; - self->get_soft_rs0 = sfp_get_soft_rs0; - self->get_soft_rs1 = sfp_get_soft_rs1; - self->get_info = common_get_info; - self->get_if_type = sfp_get_if_type; - self->get_if_speed = sfp_get_if_speed; - self->get_if_lane = common_get_if_lane; - self->get_curr_temp = sfp_get_transvr_temp; - self->get_curr_vol = sfp_get_transvr_voltage; - self->get_soft_rx_los = unsupported_get_func2; - self->get_soft_tx_disable = unsupported_get_func2; - self->get_soft_tx_fault = unsupported_get_func2; - self->get_auto_tx_disable = unsupported_get_func2; - self->get_tx_bias = sfp_get_transvr_tx_bias; - self->get_tx_power = sfp_get_transvr_tx_power; - self->get_rx_power = sfp_get_transvr_rx_power; - self->get_tx_eq = sfp_get_transvr_tx_eq; - self->get_rx_am = unsupported_get_func2; - self->get_rx_em = sfp_get_transvr_rx_em; - self->get_wavelength = sfp_get_wavelength; - self->get_extphy_offset = sfp_get_1g_rj45_extphy_offset; - self->get_extphy_reg = sfp_get_1g_rj45_extphy_reg; - self->set_cdr = unsupported_set_func; - self->set_soft_rs0 = sfp_set_soft_rs0; - self->set_soft_rs1 = sfp_set_soft_rs1; - self->set_soft_tx_disable = unsupported_set_func; - self->set_auto_tx_disable = unsupported_set_func; - self->set_tx_eq = sfp_set_tx_eq; - self->set_rx_am = unsupported_set_func; - self->set_rx_em = sfp_set_rx_em; - self->set_extphy_offset = sfp_set_1g_rj45_extphy_offset; - self->set_extphy_reg = sfp_set_1g_rj45_extphy_reg; - return 0; - - case TRANSVR_TYPE_QSFP: - case TRANSVR_TYPE_QSFP_PLUS: - self->get_id = common_get_id; - self->get_eeprom = common_get_eeprom; - self->get_ext_id = common_get_ext_id; - self->get_connector = common_get_connector; - self->get_vendor_name = common_get_vendor_name; - self->get_vendor_pn = common_get_vendor_pn; - self->get_vendor_rev = common_get_vendor_rev; - self->get_vendor_sn = common_get_vendor_sn; - self->get_power_cls = qsfp_get_power_cls; - self->get_br = common_get_br; - self->get_len_sm = unsupported_get_func; - self->get_len_smf = common_get_len_smf; - self->get_len_om1 = common_get_len_om1; - self->get_len_om2 = common_get_len_om2; - self->get_len_om3 = common_get_len_om3; - self->get_len_om4 = common_get_len_om4; - self->get_comp_rev = common_get_comp_rev; - self->get_comp_eth_1 = qsfp_get_comp_eth; - self->get_comp_eth_10 = unsupported_get_func; - self->get_comp_eth_10_40 = qsfp_get_comp_10_40; - self->get_comp_extend = common_get_comp_extended; - self->get_cdr = unsupported_get_func; - self->get_rate_id = unsupported_get_func; - self->get_soft_rs0 = unsupported_get_func; /* TBD */ - self->get_soft_rs1 = unsupported_get_func; /* TBD */ - self->get_info = common_get_info; - self->get_if_type = qsfp_get_if_type; - self->get_if_speed = qsfp_get_if_speed; - self->get_if_lane = common_get_if_lane; - self->get_curr_temp = qsfp_get_transvr_temp; - self->get_curr_vol = qsfp_get_transvr_voltage; - self->get_soft_rx_los = qsfp_get_soft_rx_los; - self->get_soft_tx_disable = qsfp_get_soft_tx_disable; - self->get_soft_tx_fault = qsfp_get_soft_tx_fault; - self->get_auto_tx_disable = qsfp_get_auto_tx_disable; - self->get_tx_bias = qsfp_get_transvr_tx_bias; - self->get_tx_power = qsfp_get_transvr_tx_power; - self->get_rx_power = qsfp_get_transvr_rx_power; - self->get_tx_eq = unsupported_get_func2; - self->get_rx_am = unsupported_get_func2; - self->get_rx_em = unsupported_get_func2; - self->get_wavelength = qsfp_get_wavelength; - self->get_extphy_offset = unsupported_get_func2; - self->get_extphy_reg = unsupported_get_func2; - self->set_cdr = unsupported_set_func; - self->set_soft_rs0 = unsupported_set_func; /* TBD */ - self->set_soft_rs1 = unsupported_set_func; /* TBD */ - self->set_soft_tx_disable = qsfp_set_soft_tx_disable; - self->set_auto_tx_disable = qsfp_set_auto_tx_disable; - self->set_tx_eq = unsupported_set_func; - self->set_rx_am = unsupported_set_func; - self->set_rx_em = unsupported_set_func; - self->set_extphy_offset = unsupported_set_func; - self->set_extphy_reg = unsupported_set_func; - return 0; - - case TRANSVR_TYPE_QSFP_28: - self->get_id = common_get_id; - self->get_eeprom = common_get_eeprom; - self->get_ext_id = common_get_ext_id; - self->get_connector = common_get_connector; - self->get_vendor_name = common_get_vendor_name; - self->get_vendor_pn = common_get_vendor_pn; - self->get_vendor_rev = common_get_vendor_rev; - self->get_vendor_sn = common_get_vendor_sn; - self->get_power_cls = qsfp_get_power_cls; - self->get_br = common_get_br; - self->get_len_sm = unsupported_get_func; - self->get_len_smf = common_get_len_smf; - self->get_len_om1 = common_get_len_om1; - self->get_len_om2 = common_get_len_om2; - self->get_len_om3 = common_get_len_om3; - self->get_len_om4 = common_get_len_om4; - self->get_comp_rev = common_get_comp_rev; - self->get_comp_eth_1 = qsfp_get_comp_eth; - self->get_comp_eth_10 = unsupported_get_func; - self->get_comp_eth_10_40 = qsfp_get_comp_10_40; - self->get_comp_extend = common_get_comp_extended; - self->get_cdr = qsfp_get_cdr; - self->get_rate_id = unsupported_get_func; - self->get_soft_rs0 = unsupported_get_func; /* TBD */ - self->get_soft_rs1 = unsupported_get_func; /* TBD */ - self->get_info = common_get_info; - self->get_if_type = qsfp_get_if_type; - self->get_if_speed = qsfp_get_if_speed; - self->get_if_lane = common_get_if_lane; - self->get_curr_temp = qsfp_get_transvr_temp; - self->get_curr_vol = qsfp_get_transvr_voltage; - self->get_soft_rx_los = qsfp_get_soft_rx_los; - self->get_soft_tx_disable = qsfp_get_soft_tx_disable; - self->get_soft_tx_fault = qsfp_get_soft_tx_fault; - self->get_auto_tx_disable = qsfp_get_auto_tx_disable; - self->get_tx_bias = qsfp_get_transvr_tx_bias; - self->get_tx_power = qsfp_get_transvr_tx_power; - self->get_rx_power = qsfp_get_transvr_rx_power; - self->get_tx_eq = qsfp_get_transvr_tx_eq; - self->get_rx_am = qsfp_get_transvr_rx_am; - self->get_rx_em = qsfp_get_transvr_rx_em; - self->get_wavelength = qsfp_get_wavelength; - self->get_extphy_offset = unsupported_get_func2; - self->get_extphy_reg = unsupported_get_func2; - self->set_cdr = qsfp_set_cdr; - self->set_soft_rs0 = unsupported_set_func; /* TBD */ - self->set_soft_rs1 = unsupported_set_func; /* TBD */ - self->set_soft_tx_disable = qsfp_set_soft_tx_disable; - self->set_auto_tx_disable = qsfp_set_auto_tx_disable; - self->set_tx_eq = qsfp_set_tx_eq; - self->set_rx_am = qsfp_set_rx_am; - self->set_rx_em = qsfp_set_rx_em; - self->set_extphy_offset = unsupported_set_func; - self->set_extphy_reg = unsupported_set_func; - return 0; - - case TRANSVR_TYPE_FAKE: - self->get_id = fake_get_hex; - self->get_eeprom = fake_get_str; - self->get_ext_id = fake_get_hex; - self->get_connector = fake_get_hex; - self->get_vendor_name = fake_get_str; - self->get_vendor_pn = fake_get_str; - self->get_vendor_rev = fake_get_str; - self->get_vendor_sn = fake_get_str; - self->get_power_cls = fake_get_int; - self->get_br = fake_get_hex; - self->get_len_sm = fake_get_int; - self->get_len_smf = fake_get_int; - self->get_len_om1 = fake_get_int; - self->get_len_om2 = fake_get_int; - self->get_len_om3 = fake_get_int; - self->get_len_om4 = fake_get_int; - self->get_comp_rev = fake_get_hex; - self->get_comp_eth_1 = fake_get_hex; - self->get_comp_eth_10 = fake_get_hex; - self->get_comp_eth_10_40 = fake_get_hex; - self->get_comp_extend = fake_get_hex; - self->get_cdr = fake_get_hex; - self->get_rate_id = fake_get_hex; - self->get_soft_rs0 = fake_get_binary; - self->get_soft_rs1 = fake_get_binary; - self->get_info = fake_get_int; - self->get_if_type = fake_get_str; - self->get_if_speed = fake_get_str; - self->get_if_lane = fake_get_str; - self->get_curr_temp = fake_get_str; - self->get_curr_vol = fake_get_str; - self->get_soft_rx_los = fake_get_str; - self->get_soft_tx_disable = fake_get_str; - self->get_soft_tx_fault = fake_get_str; - self->get_auto_tx_disable = fake_get_str; - self->get_tx_bias = fake_get_str; - self->get_tx_power = fake_get_str; - self->get_rx_power = fake_get_str; - self->get_tx_eq = fake_get_str; - self->get_rx_am = fake_get_str; - self->get_rx_em = fake_get_str; - self->get_wavelength = fake_get_str; - self->get_extphy_offset = fake_get_str; - self->get_extphy_reg = fake_get_str; - self->set_cdr = fake_set_hex; - self->set_soft_rs0 = fake_set_int; - self->set_soft_rs1 = fake_set_int; - self->set_soft_tx_disable = fake_set_int; - self->set_auto_tx_disable = fake_set_int; - self->set_tx_eq = fake_set_int; - self->set_rx_am = fake_set_int; - self->set_rx_em = fake_set_int; - self->set_extphy_offset = fake_set_hex; - self->set_extphy_reg = fake_set_hex; - return 0; - - default: - break; - } - SWPS_WARN("%s: Detect non-defined type:%d\n", __func__, transvr_type); - return ERR_TRANSVR_UNEXCPT; -} - - -static int -setup_transvr_private_cb(struct transvr_obj_s *self, - int transvr_type){ - switch (transvr_type){ - case TRANSVR_TYPE_SFP: - self->init = transvr_init_sfp; - self->clean = common_transvr_clean; - self->check = common_transvr_check; - self->update_all = _sfp_update_attr_all; - self->fsm_4_direct = common_fsm_4_direct_mode; - self->fsm_4_polling = common_fsm_4_polling_mode; - self->send_uevent = sfp_send_uevent; - self->dump_all = sfp_transvr_dump; - return 0; - - case TRANSVR_TYPE_QSFP: - case TRANSVR_TYPE_QSFP_PLUS: - self->init = transvr_init_qsfp; - self->clean = qsfp_transvr_clean; - self->check = common_transvr_check; - self->update_all = _qsfp_update_attr_all; - self->fsm_4_direct = common_fsm_4_direct_mode; - self->fsm_4_polling = common_fsm_4_polling_mode; - self->send_uevent = qsfp_send_uevent; - self->dump_all = qsfp_transvr_dump; - return 0; - - case TRANSVR_TYPE_QSFP_28: - self->init = transvr_init_qsfp28; - self->clean = qsfp_transvr_clean; - self->check = common_transvr_check; - self->update_all = _qsfp_update_attr_all; - self->fsm_4_direct = common_fsm_4_direct_mode; - self->fsm_4_polling = common_fsm_4_polling_mode; - self->send_uevent = qsfp_send_uevent; - self->dump_all = qsfp_transvr_dump; - return 0; - - case TRANSVR_TYPE_FAKE: - self->init = transvr_init_fake; - self->clean = fake_transvr_clean; - self->check = fake_transvr_check; - self->update_all = fake_transvr_update; - self->fsm_4_direct = fake_fsm_4_direct_mode; - self->fsm_4_polling = fake_fsm_4_polling_mode; - self->send_uevent = fake_send_uevent; - self->dump_all = fake_transvr_dump; - return 0; - - default: - break; - } - SWPS_WARN("%s: Detect non-defined type:%d\n", __func__, transvr_type); - return ERR_TRANSVR_UNEXCPT; -} - - -static struct eeprom_map_s * -get_eeprom_map(int transvr_type){ - - switch (transvr_type){ - case TRANSVR_TYPE_SFP: - return &eeprom_map_sfp; - case TRANSVR_TYPE_QSFP: - case TRANSVR_TYPE_QSFP_PLUS: - return &eeprom_map_qsfp; - case TRANSVR_TYPE_QSFP_28: - return &eeprom_map_qsfp28; - - default: - break; - } - SWPS_WARN("%s: Detect non-defined type:%d\n", __func__, transvr_type); - return NULL; -} - - -static int -setup_transvr_ssize_attr(char *swp_name, - struct transvr_obj_s *self, - struct eeprom_map_s *map_p, - struct ioexp_obj_s *ioexp_obj_p, - int ioexp_virt_offset, - int transvr_type, - int chipset_type, - int chan_id, - int run_mode){ - switch (run_mode){ - case TRANSVR_MODE_DIRECT: /* Direct access device mode */ - case TRANSVR_MODE_POLLING: /* Polling mode, read from cache */ - self->mode = run_mode; - break; - default: - SWPS_ERR("%s: non-defined run_mode:%d\n", - __func__, run_mode); - self->mode = DEBUG_TRANSVR_INT_VAL; - return -1; - } - self->eeprom_map_p = map_p; - self->ioexp_obj_p = ioexp_obj_p; - self->ioexp_virt_offset = ioexp_virt_offset; - self->chan_id = chan_id; - self->layout = transvr_type; - self->type = transvr_type; - self->chipset_type = chipset_type; - self->state = STATE_TRANSVR_NEW; - self->info = STATE_TRANSVR_NEW; - self->auto_tx_disable = VAL_TRANSVR_FUNCTION_DISABLE; - strncpy(self->swp_name, swp_name, 32); - mutex_init(&self->lock); - return 0; -} - - -static int -setup_transvr_dsize_attr(struct transvr_obj_s *self){ - - char *emsg = DEBUG_TRANSVR_STR_VAL; - - self->vendor_name = kzalloc((LEN_TRANSVR_M_STR * sizeof(char)), GFP_KERNEL); - if (!self->vendor_name){ - emsg = "vendor_name"; - goto err_setup_d_attr; - } - self->vendor_pn = kzalloc((LEN_TRANSVR_M_STR * sizeof(char)), GFP_KERNEL); - if (!self->vendor_pn){ - emsg = "vendor_pn"; - goto err_setup_d_attr; - } - self->vendor_rev = kzalloc((LEN_TRANSVR_M_STR * sizeof(char)), GFP_KERNEL); - if (!self->vendor_rev){ - emsg = "vendor_rev"; - goto err_setup_d_attr; - } - self->vendor_sn = kzalloc((LEN_TRANSVR_M_STR * sizeof(char)), GFP_KERNEL); - if (!self->vendor_sn){ - emsg = "vendor_sn"; - goto err_setup_d_attr; - } - self->worker_p = NULL; - return 0; - -err_setup_d_attr: - SWPS_ERR("%s: %s kzalloc fail!", __func__, emsg); - return ERR_TRANSVR_UNEXCPT; -} - - -static int -setup_i2c_client(struct transvr_obj_s *self){ - - struct i2c_adapter *adap = NULL; - struct i2c_client *client = NULL; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - - adap = i2c_get_adapter(self->chan_id); - if(!adap){ - snprintf(err_msg, sizeof(err_msg), - "can not get adap:%d", self->chan_id); - goto err_setup_i2c_client; - } - client = kzalloc(sizeof(*client), GFP_KERNEL); - if (!client){ - snprintf(err_msg, sizeof(err_msg), - "can not kzalloc client:%d", self->chan_id); - goto err_setup_i2c_client; - } - client->adapter = adap; - self->i2c_client_p = client; - self->i2c_client_p->addr = VAL_TRANSVR_COMID_ARREESS; - return 0; - -err_setup_i2c_client: - SWPS_ERR("%s: %s\n", __func__, err_msg); - return ERR_TRANSVR_UNEXCPT; -} - - -struct transvr_obj_s * -create_transvr_obj(char *swp_name, - int chan_id, - struct ioexp_obj_s *ioexp_obj_p, - int ioexp_virt_offset, - int transvr_type, - int chipset_type, - int run_mode){ - - struct transvr_obj_s *result_p; - struct eeprom_map_s *map_p; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - - /* Allocate transceiver object */ - map_p = get_eeprom_map(transvr_type); - if (!map_p){ - snprintf(err_msg, sizeof(err_msg), - "Invalid transvr_type:%d", transvr_type); - goto err_create_transvr_fail; - } - result_p = kzalloc(sizeof(*result_p), GFP_KERNEL); - if (!result_p){ - snprintf(err_msg, sizeof(err_msg), "kzalloc fail"); - goto err_create_transvr_fail; - } - /* Prepare static size attributes */ - if (setup_transvr_ssize_attr(swp_name, - result_p, - map_p, - ioexp_obj_p, - ioexp_virt_offset, - transvr_type, - chipset_type, - chan_id, - run_mode) < 0){ - goto err_create_transvr_sattr_fail; - } - /* Prepare dynamic size attributes */ - if (setup_transvr_dsize_attr(result_p) < 0){ - goto err_create_transvr_dattr_fail; - } - /* Prepare call back functions of object */ - if (setup_transvr_public_cb(result_p, transvr_type) < 0){ - goto err_create_transvr_dattr_fail; - } - /* Prepare call back functions of object */ - if (setup_transvr_private_cb(result_p, transvr_type) < 0){ - goto err_create_transvr_dattr_fail; - } - /* Prepare i2c client object */ - if (setup_i2c_client(result_p) < 0){ - goto err_create_transvr_dattr_fail; - } - return result_p; - -err_create_transvr_dattr_fail: - kfree(result_p->vendor_sn); - kfree(result_p->vendor_rev); - kfree(result_p->vendor_pn); - kfree(result_p->vendor_name); -err_create_transvr_sattr_fail: - kfree(result_p); -err_create_transvr_fail: - SWPS_ERR("%s: %s :%d :%d :%d\n", - __func__, err_msg, chan_id, ioexp_virt_offset, transvr_type); - return NULL; -} - - -static int -_reload_transvr_obj(struct transvr_obj_s *self, - int new_type){ - - struct eeprom_map_s *new_map_p; - struct eeprom_map_s *old_map_p = self->eeprom_map_p; - struct i2c_client *old_i2c_p = self->i2c_client_p; - int old_type = self->type; - - /* Change state to STATE_TRANSVR_INIT */ - self->state = STATE_TRANSVR_INIT; - self->type = new_type; - /* Replace EEPROME map */ - new_map_p = get_eeprom_map(new_type); - if (!new_map_p){ - goto err_private_reload_func_1; - } - self->eeprom_map_p = new_map_p; - /* Reload i2c client */ - if (setup_i2c_client(self) < 0){ - goto err_private_reload_func_2; - } - /* Replace call back functions */ - if (setup_transvr_public_cb(self, new_type) < 0){ - goto err_private_reload_func_3; - } - if (setup_transvr_private_cb(self, new_type) < 0){ - goto err_private_reload_func_3; - } - kfree(old_i2c_p); - return 0; - -err_private_reload_func_3: - SWPS_INFO("%s: init() fail!\n", __func__); - kfree(old_i2c_p); - self->state = STATE_TRANSVR_UNEXCEPTED; - self->type = TRANSVR_TYPE_ERROR; - return -2; - -err_private_reload_func_2: - self->eeprom_map_p = old_map_p; - self->i2c_client_p = old_i2c_p; -err_private_reload_func_1: - self->state = STATE_TRANSVR_UNEXCEPTED; - self->type = old_type; - SWPS_INFO("%s fail! :0x%02x\n", __func__, new_type); - return -1; -} - - -static int -reload_transvr_obj(struct transvr_obj_s *self, - int new_type){ - - int result_val = ERR_TRANSVR_UNEXCPT; - - /* Reload phase */ - result_val = _reload_transvr_obj(self, new_type); - if (result_val < 0){ - SWPS_INFO("%s: reload phase fail! :%d\n", - __func__, result_val); - return EVENT_TRANSVR_RELOAD_FAIL; - } - /* Initial phase */ - result_val = _transvr_init_handler(self); - if (result_val < 0){ - SWPS_INFO("%s: initial phase fail! :%d\n", - __func__, result_val); - } - return result_val; -} - - -int -isolate_transvr_obj(struct transvr_obj_s *self) { - - self->state = STATE_TRANSVR_ISOLATED; - SWPS_INFO("%s: %s be isolated\n", __func__, self->swp_name); - return 0; -} - - -int -resync_channel_tier_2(struct transvr_obj_s *self) { - - int val = TRANSVR_TYPE_ERROR; - - if (self->state == STATE_TRANSVR_ISOLATED) { - return 0; - } - self->i2c_client_p->addr = VAL_TRANSVR_COMID_ARREESS; - val = i2c_smbus_read_byte_data(self->i2c_client_p, - VAL_TRANSVR_COMID_OFFSET); - if (val < 0) { - return -1; - } - return 0; -} - - -/* ----------------------------------------- - * ToDo List - * ----------------------------------------- - * 1. _sfp_detect_class_by_feature() - * => Need check ACC use case. - * 2. _sfp_detect_class_by_1g_ethernet() - * => Need check 0.1G use case. - * 3. Loopback transceiver use case. - * => Less much data - * 4. _qsfp_detect_class_by_extend_comp() - * => Verify 100G CWDM4 - * => Verify Obsolete (assigned before 100G CWDM4 MSA required FEC) - * => Verify 100G CLR4 - * => Verify 100GE-DWDM2 - * => Verify 40G PSM4 Parallel SMF - * => Verify 100G ACC (Active Copper Cable) or 25GAUI C2M ACC. - * => Verify 100G ACC or 25GAUI C2M ACC. - * => Verify 25GBASE-LR - * => Verify 40G Active Cable (XLPPI) - */ - - - - - - diff --git a/packages/platforms/inventec/x86-64/d6254qs/modules/builds/src/transceiver.h b/packages/platforms/inventec/x86-64/d6254qs/modules/builds/src/transceiver.h deleted file mode 100644 index 63f738417..000000000 --- a/packages/platforms/inventec/x86-64/d6254qs/modules/builds/src/transceiver.h +++ /dev/null @@ -1,810 +0,0 @@ -#ifndef TRANSCEIVER_H -#define TRANSCEIVER_H - -#include - -/* advanced features control */ -#define TRANSVR_INFO_DUMP_ENABLE (1) -#define TRANSVR_INFO_CACHE_ENABLE (1) -#define TRANSVR_UEVENT_ENABLE (1) - -/* Transceiver type define */ -#define TRANSVR_TYPE_UNKNOW_1 (0x00) -#define TRANSVR_TYPE_UNKNOW_2 (0xff) -#define TRANSVR_TYPE_SFP (0x03) /* Define for SFP, SFP+, SFP28 */ -#define TRANSVR_TYPE_QSFP (0x0c) -#define TRANSVR_TYPE_QSFP_PLUS (0x0d) -#define TRANSVR_TYPE_QSFP_28 (0x11) -#define TRANSVR_TYPE_UNPLUGGED (0xfa) /* Define for ERROR handle */ -#define TRANSVR_TYPE_FAKE (0xfc) /* Define for ERROR handle */ -#define TRANSVR_TYPE_INCONSISTENT (0xfd) /* Define for ERROR handle */ -#define TRANSVR_TYPE_ERROR (0xfe) /* Define for ERROR handle */ - -/* Transceiver class for base info */ -#define TRANSVR_CLASS_UNSPECIFIED (0) -#define TRANSVR_CLASS_ERROR (-26001) -#define TRANSVR_CLASS_1G (26001) -#define TRANSVR_CLASS_10G (26011) -#define TRANSVR_CLASS_25G (26021) -#define TRANSVR_CLASS_40G (26041) -#define TRANSVR_CLASS_100G (26101) -#define TRANSVR_CLASS_NO_SPERARABLE (26901) -#define TRANSVR_CLASS_EXTEND_COMP (26902) -/* Transceiver class for Optical 1G */ -#define TRANSVR_CLASS_OPTICAL (27000) -#define TRANSVR_CLASS_OPTICAL_100 (27001) -#define TRANSVR_CLASS_OPTICAL_1G (27002) -#define TRANSVR_CLASS_OPTICAL_1G_AOC (27003) -#define TRANSVR_CLASS_OPTICAL_1G_SX (27004) -#define TRANSVR_CLASS_OPTICAL_1G_LX (27005) -#define TRANSVR_CLASS_OPTICAL_1G_EX (27006) -/* Transceiver class for Optical 10G */ -#define TRANSVR_CLASS_OPTICAL_10G (27010) -#define TRANSVR_CLASS_OPTICAL_10G_S_AOC (27011) -#define TRANSVR_CLASS_OPTICAL_10G_S_SR (27012) -#define TRANSVR_CLASS_OPTICAL_10G_S_LR (27013) -#define TRANSVR_CLASS_OPTICAL_10G_S_ER (27014) -#define TRANSVR_CLASS_OPTICAL_10G_Q_AOC (27015) -#define TRANSVR_CLASS_OPTICAL_10G_Q_SR (27016) -#define TRANSVR_CLASS_OPTICAL_10G_Q_LR (27017) -#define TRANSVR_CLASS_OPTICAL_10G_Q_ER (27018) -/* Transceiver class for Optical 25G */ -#define TRANSVR_CLASS_OPTICAL_25G (27020) -#define TRANSVR_CLASS_OPTICAL_25G_AOC (27021) -#define TRANSVR_CLASS_OPTICAL_25G_SR (27022) -#define TRANSVR_CLASS_OPTICAL_25G_LR (27023) -#define TRANSVR_CLASS_OPTICAL_25G_ER (27024) -/* Transceiver class for Optical 40G */ -#define TRANSVR_CLASS_OPTICAL_40G (27040) -#define TRANSVR_CLASS_OPTICAL_40G_AOC (27041) -#define TRANSVR_CLASS_OPTICAL_40G_SR4 (27042) -#define TRANSVR_CLASS_OPTICAL_40G_LR4 (27043) -#define TRANSVR_CLASS_OPTICAL_40G_ER4 (27044) -/* Transceiver class for Optical 100G */ -#define TRANSVR_CLASS_OPTICAL_100G (27100) -#define TRANSVR_CLASS_OPTICAL_100G_AOC (27101) -#define TRANSVR_CLASS_OPTICAL_100G_SR4 (27102) -#define TRANSVR_CLASS_OPTICAL_100G_LR4 (27103) -#define TRANSVR_CLASS_OPTICAL_100G_ER4 (27104) -#define TRANSVR_CLASS_OPTICAL_100G_PSM4 (27105) -/* Transceiver class for Copper */ -#define TRANSVR_CLASS_COPPER (28000) -#define TRANSVR_CLASS_COPPER_L1_1G (28001) -#define TRANSVR_CLASS_COPPER_L1_10G (28011) -#define TRANSVR_CLASS_COPPER_L4_10G (28012) -#define TRANSVR_CLASS_COPPER_L1_25G (28021) -#define TRANSVR_CLASS_COPPER_L4_40G (28041) -#define TRANSVR_CLASS_COPPER_L4_100G (28101) -/* Transceiver class for Base-T */ -#define TRANSVR_CLASS_BASE_T_1000 (29001) -#define TRANSVR_CLASS_BASE_T_1000_up (29002) -/* For uevent message */ -#define TRANSVR_UEVENT_KEY_IF "IF_TYPE" -#define TRANSVR_UEVENT_KEY_SP "IF_SPEED" -#define TRANSVR_UEVENT_KEY_LANE "IF_LANE" -#define TRANSVR_UEVENT_UNKNOW "UNKNOW" -#define TRANSVR_IF_KR "KR" -#define TRANSVR_IF_KR4 "KR4" -#define TRANSVR_IF_SR "SR" -#define TRANSVR_IF_SR4 "SR4" -#define TRANSVR_IF_SFI "SFI" -#define TRANSVR_IF_IF_GMII "GMII" -#define TRANSVR_IF_IF_XGMII "XGMII" -#define TRANSVR_IF_SP_100 "100" -#define TRANSVR_IF_SP_1G "1000" -#define TRANSVR_IF_SP_10G "10000" -#define TRANSVR_IF_SP_25G "25000" -#define TRANSVR_IF_SP_40G "40000" -#define TRANSVR_IF_SP_100G "100000" - -/* Transceiver mode define */ -#define TRANSVR_MODE_DIRECT (21000) -#define TRANSVR_MODE_POLLING (21001) - -/* Transceiver state define - * [Note] - * 1. State is used to represent the state of "Transceiver" and "Object". - * 2. State for different target has different means. The description as following: - */ -#define STATE_TRANSVR_CONNECTED (0) /* [Transvr]:Be plugged in. [Obj]:Link up, and work normally. */ -#define STATE_TRANSVR_NEW (-100) /* [Transvr]:(Not used) [Obj]:Create */ -#define STATE_TRANSVR_INIT (-101) /* [Transvr]:Be plugged in. [Obj]:Link up, and in initial process. */ -#define STATE_TRANSVR_ISOLATED (-102) /* [Transvr]:Be plugged in. [Obj]:Isolate, and not provide service. */ -#define STATE_TRANSVR_SWAPPED (-200) /* [Transvr]:Be plugged in. [Obj]:(Not used) */ -#define STATE_TRANSVR_DISCONNECTED (-300) /* [Transvr]:Un-plugged. [Obj]:Link down, and not provide service. */ -#define STATE_TRANSVR_UNEXCEPTED (-901) /* [Transvr]:Any [Obj]:Any, and not in expect case. */ - -/* Task state define */ -#define STATE_T_TASK_WAIT (110) -#define STATE_T_TASK_DONE (0) -#define STATE_T_TASK_INIT (-110) -#define STATE_T_TASK_FAIL (-410) - - -/* Event for task handling */ -#define EVENT_TRANSVR_TASK_WAIT (2101) -#define EVENT_TRANSVR_TASK_DONE (0) -#define EVENT_TRANSVR_TASK_FAIL (-2101) -/* Event for initial handling */ -#define EVENT_TRANSVR_INIT_UP (2201) -#define EVENT_TRANSVR_INIT_DOWN (1) -#define EVENT_TRANSVR_INIT_REINIT (-2201) -#define EVENT_TRANSVR_INIT_FAIL (-2202) -/* Event for others */ -#define EVENT_TRANSVR_RELOAD_FAIL (-2301) -#define EVENT_TRANSVR_EXCEP_INIT (-2401) -#define EVENT_TRANSVR_EXCEP_UP (-2402) -#define EVENT_TRANSVR_EXCEP_DOWN (-2403) -#define EVENT_TRANSVR_EXCEP_SWAP (-2404) -#define EVENT_TRANSVR_EXCEP_EXCEP (-2405) -#define EVENT_TRANSVR_EXCEP_ISOLATED (-2406) -#define EVENT_TRANSVR_I2C_CRASH (-2501) - -/* Transceiver error code define */ -#define ERR_TRANSVR_UNINIT (-201) -#define ERR_TRANSVR_UNPLUGGED (-202) -#define ERR_TRANSVR_ABNORMAL (-203) -#define ERR_TRANSVR_NOSTATE (-204) -#define ERR_TRANSVR_NOTSUPPORT (-205) -#define ERR_TRANSVR_BADINPUT (-206) -#define ERR_TRANSVR_UPDATE_FAIL (-207) -#define ERR_TRANSVR_RELOAD_FAIL (-208) -#define ERR_TRANSVR_INIT_FAIL (-209) -#define ERR_TRANSVR_UNDEFINED (-210) -#define ERR_TRANSVR_TASK_FAIL (-211) -#define ERR_TRANSVR_TASK_BUSY (-212) -#define ERR_TRANSVR_UEVENT_FAIL (-213) -#define ERR_TRANSVR_FUNC_DISABLE (-214) -#define ERR_TRANSVR_I2C_CRASH (-297) -#define ERR_TRNASVR_BE_ISOLATED (-298) -#define ERR_TRANSVR_UNEXCPT (-299) - -/* For debug */ -#define DEBUG_TRANSVR_INT_VAL (-99) -#define DEBUG_TRANSVR_HEX_VAL (0xfe) -#define DEBUG_TRANSVR_STR_VAL "ERROR" - -/* For system internal */ -#define VAL_TRANSVR_COMID_ARREESS (0x50) -#define VAL_TRANSVR_COMID_OFFSET (0x00) -#define VAL_TRANSVR_EXTPHY_ADDR_56 (0x56) -#define VAL_TRANSVR_8472_READY_ADDR (0x51) -#define VAL_TRANSVR_8472_READY_PAGE (-1) -#define VAL_TRANSVR_8472_READY_OFFSET (110) -#define VAL_TRANSVR_8472_READY_BIT (0) -#define VAL_TRANSVR_8472_READY_VALUE (0) -#define VAL_TRANSVR_8472_READY_ABNORMAL (0xff) -#define VAL_TRANSVR_8436_READY_ADDR (0x50) -#define VAL_TRANSVR_8436_READY_PAGE (-1) -#define VAL_TRANSVR_8436_READY_OFFSET (2) -#define VAL_TRANSVR_8436_READY_BIT (0) -#define VAL_TRANSVR_8436_READY_VALUE (0) -#define VAL_TRANSVR_8436_READY_ABNORMAL (0xff) -#define VAL_TRANSVR_8436_PWD_ADDR (0x50) -#define VAL_TRANSVR_8436_PWD_PAGE (-1) -#define VAL_TRANSVR_8436_PWD_OFFSET (123) -#define VAL_TRANSVR_PAGE_FREE (-99) -#define VAL_TRANSVR_PAGE_SELECT_OFFSET (127) -#define VAL_TRANSVR_PAGE_SELECT_DELAY (5) -#define VAL_TRANSVR_TASK_RETRY_FOREVER (-999) -#define VAL_TRANSVR_FUNCTION_DISABLE (-1) -#define STR_TRANSVR_SFP "SFP" -#define STR_TRANSVR_QSFP "QSFP" -#define STR_TRANSVR_QSFP_PLUS "QSFP+" -#define STR_TRANSVR_QSFP28 "QSFP28" - -/* For transvr buf len */ -#define LEN_TRANSVR_S_STR (16) -#define LEN_TRANSVR_M_STR (32) -#define LEN_TRANSVR_L_STR (64) - -/* Optical wavelength */ -#define VAL_OPTICAL_WAVELENGTH_SR (850) -#define VAL_OPTICAL_WAVELENGTH_LR (1310) -#define VAL_OPTICAL_WAVELENGTH_ER (1550) - -/* BCM chip type define */ -#define BCM_CHIP_TYPE_TRIDENT_2 (31001) /* Magnolia, Hudson32i, Spruce */ -#define BCM_CHIP_TYPE_TOMAHAWK (31002) /* Redwood, Cypress, Sequoia */ - -#define BF_CHIP_TYPE_TOFINO (31011) /* Lavender */ - -/* Info from transceiver EEPROM */ -struct eeprom_map_s { - int addr_br; int page_br; int offset_br; int length_br; - int addr_cdr; int page_cdr; int offset_cdr; int length_cdr; - int addr_comp_rev; int page_comp_rev; int offset_comp_rev; int length_comp_rev; - int addr_connector; int page_connector; int offset_connector; int length_connector; - int addr_diag_type; int page_diag_type; int offset_diag_type; int length_diag_type; - int addr_extbr; int page_extbr; int offset_extbr; int length_extbr; - int addr_ext_id; int page_ext_id; int offset_ext_id; int length_ext_id; - int addr_id; int page_id; int offset_id; int length_id; - int addr_len_sm; int page_len_sm; int offset_len_sm; int length_len_sm; - int addr_len_smf; int page_len_smf; int offset_len_smf; int length_len_smf; - int addr_len_om1; int page_len_om1; int offset_len_om1; int length_len_om1; - int addr_len_om2; int page_len_om2; int offset_len_om2; int length_len_om2; - int addr_len_om3; int page_len_om3; int offset_len_om3; int length_len_om3; - int addr_len_om4; int page_len_om4; int offset_len_om4; int length_len_om4; - int addr_option; int page_option; int offset_option; int length_option; - int addr_rate_id; int page_rate_id; int offset_rate_id; int length_rate_id; - int addr_rx_am; int page_rx_am; int offset_rx_am; int length_rx_am; - int addr_rx_em; int page_rx_em; int offset_rx_em; int length_rx_em; - int addr_rx_los; int page_rx_los; int offset_rx_los; int length_rx_los; - int addr_rx_power; int page_rx_power; int offset_rx_power; int length_rx_power; - int addr_soft_rs0; int page_soft_rs0; int offset_soft_rs0; int length_soft_rs0; - int addr_soft_rs1; int page_soft_rs1; int offset_soft_rs1; int length_soft_rs1; - int addr_temp; int page_temp; int offset_temp; int length_temp; - int addr_trancomp; int page_trancomp; int offset_trancomp; int length_trancomp; - int addr_trancomp_ext; int page_trancomp_ext; int offset_trancomp_ext; int length_trancomp_ext; - int addr_tx_bias; int page_tx_bias; int offset_tx_bias; int length_tx_bias; - int addr_tx_disable; int page_tx_disable; int offset_tx_disable; int length_tx_disable; - int addr_tx_eq; int page_tx_eq; int offset_tx_eq; int length_tx_eq; - int addr_tx_fault; int page_tx_fault; int offset_tx_fault; int length_tx_fault; - int addr_tx_power; int page_tx_power; int offset_tx_power; int length_tx_power; - int addr_vendor_name; int page_vendor_name; int offset_vendor_name; int length_vendor_name; - int addr_vendor_pn; int page_vendor_pn; int offset_vendor_pn; int length_vendor_pn; - int addr_vendor_rev; int page_vendor_rev; int offset_vendor_rev; int length_vendor_rev; - int addr_vendor_sn; int page_vendor_sn; int offset_vendor_sn; int length_vendor_sn; - int addr_voltage; int page_voltage; int offset_voltage; int length_voltage; - int addr_wavelength; int page_wavelength; int offset_wavelength; int length_wavelength; - int addr_eeprom; int page_eeprom; int offset_eeprom; int length_eeprom; -}; - - -struct transvr_worker_s; - -/* Class of transceiver object */ -struct transvr_obj_s { - - /* ========== Object private property ========== - * [Prop]: id - * [Desc]: Type of serial transceiver. - * [Note]: SFP:03h / QSFP:0Ch / QSPF+:0Dh /QSFP28:11h - */ - uint8_t id; - - /* [Prop]: connector - * [Desc]: Connector type. - * [Note]: SFP : A0h / 2 - * QSFP: 00h / 130 - */ - uint8_t connector; - - /* [Prop]: transvr_comp - * [Desc]: Transceiver compliance code. - * [Note]: SFP: SFF-8472 - * - Normal : A0h / offset 3-10 - * - Extended: A0h / offset 36 - * QSFP: SFF-8436 & SFF-8636 - * - Normal : 00h / offset 131-138 - * - Extended: 00h / offset 192 - */ - uint8_t transvr_comp[8]; - uint8_t transvr_comp_ext; - - /* [Prop]: vendor_name - * [Desc]: SFP vendor name (ASCII 16 byte char). - * [Note]: ex:FINISAR CORP. - */ - char *vendor_name; - - /* [Prop]: vendor_pn - * [Desc]: Part number provided by SFP vendor (ASCII 16 byte char). - * [Note]: - */ - char *vendor_pn; - - /* [Prop]: vendor_rev - * [Desc]: Revision level for part number provided by vendor (ASCII 4 byte char). - * [Note]: - */ - char *vendor_rev; - - /* [Prop]: vendor_sn - * [Desc]: Serial number provided by vendor (ASCII 16 byte char). - * [Note]: - */ - char *vendor_sn; - - /* [Prop]: Extended identifier - * [Desc]: SFP: - * => None - * - * QSFP: - * => This byte contained two information: - * (1) Power consumption class - * (2) CDR function present - * [Note]: Bit description as below: - * [SFP] - * None - * - * [QSFP] - * (1) Power consumption class: - * Class 1: 1.5W (Bit6-7 = 00:) - * Class 2: 2.0W (Bit6-7 = 01:) - * Class 3: 2.5W (Bit6-7 = 10:) - * Class 4: 3.5W (Bit6-7 = 11:) - * Class 5: 4.0W (Bit0-1 = 01:) - * Class 6: 4.5W (Bit0-1 = 10:) - * Class 7: 5.0W (Bit0-1 = 11:) - * (2) CDR function present: - * Bit2: 0 = No CDR in RX - * 1 = CDR present in RX - * Bit3: 0 = No CDR in TX - * 1 = CDR present in TX - */ - uint8_t ext_id; - - /* [Prop]: br - * [Desc]: Nominal bit rate, units of 100 MBits/sec. - * [Note]: SFP:03h / QSFP:0Ch / QSPF+:0Dh - * has val: 0x67 - * no val : - */ - uint8_t br; - - /* [Prop]: extbr - * [Desc]: Extended br (00h/222) - * [Desc]: Nominal bit rate per channel, units of 250 Mbps. - * Complements. Byte 140. See Table 32A. - */ - uint8_t extbr; - - /* [Prop]: len_sm - * [Desc]: Length (single mode)-(100's)m - * [Note]: This value specifies the link length that is supported by the transceiver - * while operating in compliance with the applicable standards using single mode - * fiber. The value is in units of 100 meters. A value of 255 means that the - * transceiver supports a link length greater than 25.4 km. A value of zero means - * that the transceiver does not support single mode fiber or that the length - * information must be determined from the transceiver technology. - */ - int len_sm; - - /* [Prop]: len_smf - * [Desc]: Length (single mode)-km - * [Note]: Addition to EEPROM data from original GBIC definition. This value specifies - * the link length that is supported by the transceiver while operating in - * compliance with the applicable standards using single mode fiber. The value - * is in units of kilometers. A value of 255 means that the transceiver supports - * a link length greater than 254 km. A value of zero means that the transceiver - * does not support single mode fiber or that the length information must be - * determined from the transceiver technology. - */ - int len_smf; - - /* [Prop]: len_om1 - * [Desc]: Link length supported for 62.5 um OM1 fiber, units of 10 m - * [Note]: The value is in units of 10 meters. A value of 255 means that the - * transceiver supports a link length greater than 2.54 km. A value of - * zero means that the transceiver does not support 50 micron multi-mode - * fiber or that the length information must be determined from the transceiver - * technology. - */ - int len_om1; - - /* [Prop]: len_om2 - * [Desc]: Link length supported for 50 um OM2 fiber, units of 10 m - * [Note]: The value is in units of 10 meters. A value of 255 means that the - * transceiver supports a link length greater than 2.54 km. A value of - * zero means that the transceiver does not support 50 micron multi-mode - * fiber or that the length information must be determined from the transceiver - * technology. - */ - int len_om2; - - /* [Prop]: len_om3 - * [Desc]: Length (50um, OM3) - * [Note]: This value specifies link length that is supported by the transceiver while - * operating in compliance with applicable standards using 50 micron multimode - * OM3 [2000 MHz*km] fiber. The value is in units of 10 meters. A value of 255 - * means that the transceiver supports a link length greater than 2.54 km. A value - * of zero means that the transceiver does not support 50 micron multimode fiber - * or that the length information must be determined from the transceiver technology. - */ - int len_om3; - - /* [Prop]: len_om4 - * [Desc]: Length (50um, OM4) and Length (Active Cable or Copper) - * [Note]: For optical links, this value specifies link length that is supported by the - * transceiver while operating in compliance with applicable standards using 50 micron - * multimode OM4 [4700 MHz*km] fiber. The value is in units of 10 meters. A value of - * 255 means that the transceiver supports a link length greater than 2.54 km. A value - * of zero means that the transceiver does not support 50 micron multimode fiber or that - * the length information must be determined from the transceiver codes specified in Table 5-3. - * - * For copper links, this value specifies minimum link length supported by the transceiver - * while operating in compliance with applicable standards using copper cable. For active - * cable, this value represents actual length. The value is in units of 1 meter. A value of 255 - * means the transceiver supports a link length greater than 254 meters. A value of zero means - * the transceiver does not support copper or active cables or the length information must be - * determined from transceiver technology. Further information about cable design, equalization, - * and connectors is usually required to guarantee meeting a particular length requirement. - */ - int len_om4; - - /* [Prop]: comp_rev - * [Desc]: SFF spec revision compliance - * [Note]: Indicates which revision of SFF SFF-8472 (SFP) / SFF-8636 (QSFP) the transceiver - * complies with. (unsigned integer) - */ - uint8_t comp_rev; - - /* [Prop]: CDR - * [Desc]: For transceivers with CDR capability, setting the CDR to ON engages the internal - * retiming function. Setting the CDR to OFF enables an internal bypassing mode ,which - * directs traffic around the internal CDR. (Reference: SFF-8636) - * [Note]: value=0xff: ON. - * value=0x00: OFF. - */ - uint8_t cdr; - - /* [Prop]: rate_id - * [Desc]: Soft Rate Select 0(RX). - * [Note]: 1. Addr: A0h / Offset: 13 - * 2. Value description: - * 00h Unspecified - * 01h SFF-8079 (4/2/1G Rate_Select & AS0/AS1) - * 02h SFF-8431 (8/4/2G Rx Rate_Select only) - * 03h Unspecified * - * 04h SFF-8431 (8/4/2G Tx Rate_Select only) - * 05h Unspecified * - * 06h SFF-8431 (8/4/2G Independent Rx & Tx Rate_select) - * 07h Unspecified * - * 08h FC-PI-5 (16/8/4G Rx Rate_select only) High=16G only, Low=8G/4G - * 09h Unspecified * - * 0Ah FC-PI-5 (16/8/4G Independent Rx, Tx Rate_select) High=16G only, - * Low=8G/4G - * 0Bh Unspecified * - * 0Ch FC-PI-6 (32/16/8G Independent Rx, Tx Rate_Select) - * High=32G only, Low = 16G/8G - * 0Dh Unspecified * - * 0Eh 10/8G Rx and Tx Rate_Select controlling the operation or locking - * modes of the internal signal conditioner, retimer or CDR, according - * to the logic table defined in Table 10-2, High Bit Rate - * (10G) =9.95-11.3 Gb/s; Low Bit Rate (8G) = 8.5 Gb/s. In this mode, - * the default value of bit 110.3 (Soft Rate Select RS(0), Table 9-11) - * and of bit 118.3 (Soft Rate Select RS(1), Table 10-1) is 1. - * 0Fh Unspecified * - * 10h-FFh Unallocated - */ - int rate_id; - - /* [Prop]: soft_rs0 - * [Desc]: Soft Rate Select 0(RX). - * [Note]: 1. Writing '1' selects full bandwidth operation. - * 2. This bit is "OR'd with the hard Rate_Select, AS(0) or RS(0) pin value. - * 3. Default at power up is logic zero/low - * 4. Addr: A2h / Offset: 110 / Bit: 3 - */ - uint8_t soft_rs0; - - /* [Prop]: soft_rs1 - * [Desc]: Soft Rate Select 1(TX). - * [Note]: 1. Writing '1' selects full bandwidth TX operation. - * 2. This bit is "OR'd with the hard Rate_Select, AS(1) or RS(1) pin value. - * 3. Default at power up is logic zero/low - * 4. Addr: A2h / Offset: 118 / Bit: 3 - */ - uint8_t soft_rs1; - - /* [Prop]: diag_type - * [Desc]: DIAGNOSTIC MONITORING TYPE (A0h/92) - * [Note]: Description in SFF-8472 as below: - * Bit7: Reserved for legacy diagnostic implementations. Must be '0' for compliance - * with this document. - * Bit6: Digital diagnostic monitoring implemented (described in this document). - * Must be '1' for compliance with this document. - * Bit5 Internally calibrated - * Bit4 Externally calibrated - * Bit3 Received power measurement type.0 = OMA, 1 = average power - * Bit2 Address change required see section above, "addressing modes" - * Bit1-0 Unallocated - */ - uint8_t diag_type; - - /* [Prop]: curr_temp - * [Desc]: Transceiver Current Temperature (A2h/96-97) - * [Note]: 1. Dependent on diag_type. - * 2. 96: High byte - * 3. 97: Low byte - * 4. This feature only for SFP - */ - uint8_t curr_temp[2]; - - /* [Prop]: curr_vol - * [Desc]: Transceiver Current Voltage (SFP:A2h/108-109; QSFP:00h/22-23) - * [Note]: 1. Dependent on diag_type. - * 2. 98: High byte - * 3. 99: Low byte - * 4. This feature only for SFP - * 5. Internally measured transceiver supply voltage. Represented - * as a 16 bit unsigned integer with the voltage defined as the - * full 16 bit value (0-65535) with LSB equal to 100 uVolt, - * yielding a total range of 0 to +6.55 Volts - */ - uint8_t curr_voltage[2]; - - /* [Prop]: curr_tx_bias - * [Desc]: Transceiver TX Bias Current (SFP:A2h/100-101; QSFP:00h/26-27) - * [Note]: 1. Dependent on diag_type. - * 2. 100: High byte - * 3. 101: Low byte - * 4. This feature only for SFP - * 5. Measured TX bias current in uA. Represented as a 16 bit unsigned - * integer with the current defined as the full 16 bit value (0-65535) - * with LSB equal to 2 uA, yielding a total range of 0 to 131 mA. - * Accuracy is vendor specific but must be better than 10% of the - * manufacturer's nominal value over specified operating temperature - * and voltage. - */ - uint8_t curr_tx_bias[8]; - - /* [Prop]: curr_tx_power - * [Desc]: Transceiver TX Output Power (A2h/102-103) - * [Note]: 1. Dependent on diag_type. - * 2. 102: High byte - * 3. 103: Low byte - * 4. This feature only for SFP - * 5. Measured TX output power in mW. Represented as a 16 bit unsigned - * integer with the power defined as the full 16 bit value (0-65535) - * with LSB equal to 0.1 uW, yielding a total range of 0 to 6.5535 mW - * (~ -40 to +8.2 dBm). Data is assumed to be based on measurement of - * laser monitor photodiode current. It is factory calibrated to absolute - * units using the most representative fiber output type. Accuracy is - * vendor specific but must be better than 3dB over specified temperature - * and voltage. Data is not valid when the transmitter is disabled. - */ - uint8_t curr_tx_power[8]; - - /* [Prop]: curr_tx_power - * [Desc]: Transceiver TX Output Power (A2h/102-103) - * [Note]: 1. Dependent on diag_type. - * 2. 102: High byte - * 3. 103: Low byte - * 4. This feature only for SFP - * 5. Measured RX received optical power in mW. Value can represent either - * average received power or OMA depending upon how bit 3 of byte 92 (A0h) - * is set. Represented as a 16 bit unsigned integer with the power defined - * as the full 16 bit value (0-65535) with LSB equal to 0.1 uW, yielding a - * total range of 0 to 6.5535 mW (~ -40 to +8.2 dBm). Absolute accuracy is - * dependent upon the exact optical wavelength. For the vendor specified - * wavelength, accuracy shall be better than 3dB over specified temperature - * and voltage. - */ - uint8_t curr_rx_power[8]; - - /* [Prop]: wavelength - * [Desc]: Wavelength or Copper Cable Attenuation - * [Note]: (Following is info from SFF-8636) - * For optical free side devices, this parameter identifies the nominal - * transmitter output wavelength at room temperature. This parameter is a - * 16-bit hex value with Byte 186 as high order byte and Byte 187 as low - * order byte. The laser wavelength is equal to the 16-bit integer value - * divided by 20 in nm (units of 0.05 nm). This resolution should be adequate - * to cover all relevant wavelengths yet provide enough resolution for all - * expected DWDM applications. For accurate representation of controlled - * wavelength applications, this value should represent the center of the - * guaranteed wavelength range. If the free side device is identified as - * copper cable these registers will be used to define the cable attenuation. - * An indication of 0 dB attenuation refers to the case where the attenuation - * is not known or is unavailable. - * Byte 186 (00-FFh) is the copper cable attenuation at 2.5 GHz in units of 1 dB. - * Byte 187 (00-FFh) is the copper cable attenuation at 5.0 GHz in units of 1 dB. - */ - uint8_t wavelength[2]; - - /* [Prop]: Amplitude control - * [Desc]: Amplitude control - * [Note]: QSFP28 => SFF-8636 03H Byte-238/239 - */ - uint8_t rx_am[2]; - - /* [Prop]: Emphasis control - * [Desc]: Emphasis control - * [Note]: SFP+/28 => SFF-8472 A2H Byte-115 - * QSFP28 => SFF-8636 03H Byte-236/237 - */ - uint8_t rx_em[2]; - - /* [Prop]: Soft Rx LOS - * [Desc]: Soft Rx LOS which provide by transceiver - * [Note]: (Following is info from SFF-8636) - * Byte 3: - * - Bit 0: L-Rx1 LOS - * - Bit 1: L-Rx2 LOS - * - Bit 2: L-Rx3 LOS - * - Bit 3: L-Rx4 LOS - */ - uint8_t rx_los; - - /* [Prop]: Soft Tx Disable - * [Desc]: Soft Tx Disable which provide by transceiver - * [Note]: (Following is info from SFF-8636) - * Byte 86: - * - Bit 0: Tx1 Disable - * - Bit 1: Tx2 Disable - * - Bit 2: Tx3 Disable - * - Bit 3: Tx4 Disable - */ - uint8_t tx_disable; - - /* [Prop]: Soft Tx Fault - * [Desc]: Soft Tx Fault which provide by transceiver - * [Note]: (Following is info from SFF-8636) - * Byte 86: - * - Bit 0: Tx1 Fault - * - Bit 1: Tx2 Fault - * - Bit 2: Tx3 Fault - * - Bit 3: Tx4 Fault - */ - uint8_t tx_fault; - - /* [Prop]: Transceiver EQUALIZATION - * [Desc]: Transceiver EQUALIZATION - * [Note]: SFP+/28 => SFF-8472 A2H Byte-114 - * QSFP28 => SFF-8636 03H Byte-234/235 - */ - uint8_t tx_eq[2]; - - /* [Prop]: OPTION VALUES - * [Desc]: The bits in the option field shall specify the options implemented in the transceiver. - * [Note]: SFP+/28 => SFF-8472 A0H Byte-64/65 - * QSFP+/28 => SFF-8636 00H Byte-193/195 - */ - uint8_t option[3]; - - /* [Prop]: External PHY offset - * [Desc]: It needs to be setup first if you want to access transceiver external phy. - * [Note]: This feature dependent on transceiver. - * Currently, only 1G-RJ45 transceiver supported it. - */ - uint8_t extphy_offset; - - uint8_t eeprom[256]; - uint8_t eeprom_update[8]; - int port_no; - - /* ========== Object private property ========== - */ - struct device *transvr_dev_p; - struct eeprom_map_s *eeprom_map_p; - struct i2c_client *i2c_client_p; - struct ioexp_obj_s *ioexp_obj_p; - struct transvr_worker_s *worker_p; - struct mutex lock; - char swp_name[32]; - int auto_config; - int auto_tx_disable; - int chan_id; - int chipset_type; - int curr_page; - int info; - int ioexp_virt_offset; - int lane_id[8]; - int layout; - int mode; - int retry; - int state; - int temp; - int type; - - /* ========== Object public functions ========== - */ - int (*get_id)(struct transvr_obj_s *self); - int (*get_eeprom)(struct transvr_obj_s *self, char *buf_p); - int (*get_ext_id)(struct transvr_obj_s *self); - int (*get_connector)(struct transvr_obj_s *self); - int (*get_vendor_name)(struct transvr_obj_s *self, char *buf_p); - int (*get_vendor_pn)(struct transvr_obj_s *self, char *buf_p); - int (*get_vendor_rev)(struct transvr_obj_s *self, char *buf_p); - int (*get_vendor_sn)(struct transvr_obj_s *self, char *buf_p); - int (*get_power_cls)(struct transvr_obj_s *self); - int (*get_br)(struct transvr_obj_s *self); - int (*get_len_sm)(struct transvr_obj_s *self); - int (*get_len_smf)(struct transvr_obj_s *self); - int (*get_len_om1)(struct transvr_obj_s *self); - int (*get_len_om2)(struct transvr_obj_s *self); - int (*get_len_om3)(struct transvr_obj_s *self); - int (*get_len_om4)(struct transvr_obj_s *self); - int (*get_comp_rev)(struct transvr_obj_s *self); - int (*get_comp_eth_1)(struct transvr_obj_s *self); - int (*get_comp_eth_10)(struct transvr_obj_s *self); - int (*get_comp_eth_10_40)(struct transvr_obj_s *self); - int (*get_comp_extend)(struct transvr_obj_s *self); - int (*get_cdr)(struct transvr_obj_s *self); - int (*get_rate_id)(struct transvr_obj_s *self); - int (*get_soft_rs0)(struct transvr_obj_s *self); - int (*get_soft_rs1)(struct transvr_obj_s *self); - int (*get_info)(struct transvr_obj_s *self); - int (*get_if_type)(struct transvr_obj_s *self, char *buf_p); - int (*get_if_speed)(struct transvr_obj_s *self, char *buf_p); - int (*get_if_lane)(struct transvr_obj_s *self, char *buf_p); - int (*get_curr_temp)(struct transvr_obj_s *self, char *buf_p); - int (*get_curr_vol)(struct transvr_obj_s *self, char *buf_p); - int (*get_soft_rx_los)(struct transvr_obj_s *self, char *buf_p); - int (*get_soft_tx_disable)(struct transvr_obj_s *self, char *buf_p); - int (*get_soft_tx_fault)(struct transvr_obj_s *self, char *buf_p); - int (*get_auto_tx_disable)(struct transvr_obj_s *self, char *buf_p); - int (*get_tx_bias)(struct transvr_obj_s *self, char *buf_p); - int (*get_tx_power)(struct transvr_obj_s *self, char *buf_p); - int (*get_rx_power)(struct transvr_obj_s *self, char *buf_p); - int (*get_tx_eq)(struct transvr_obj_s *self, char *buf_p); - int (*get_rx_am)(struct transvr_obj_s *self, char *buf_p); - int (*get_rx_em)(struct transvr_obj_s *self, char *buf_p); - int (*get_wavelength)(struct transvr_obj_s *self, char *buf_p); - int (*get_extphy_offset)(struct transvr_obj_s *self, char *buf_p); - int (*get_extphy_reg)(struct transvr_obj_s *self, char *buf_p); - int (*set_cdr)(struct transvr_obj_s *self, int input_val); - int (*set_soft_rs0)(struct transvr_obj_s *self, int input_val); - int (*set_soft_rs1)(struct transvr_obj_s *self, int input_val); - int (*set_soft_tx_disable)(struct transvr_obj_s *self, int input_val); - int (*set_auto_tx_disable)(struct transvr_obj_s *self, int input_val); - int (*set_tx_eq)(struct transvr_obj_s *self, int input_val); - int (*set_rx_am)(struct transvr_obj_s *self, int input_val); - int (*set_rx_em)(struct transvr_obj_s *self, int input_val); - int (*set_extphy_offset)(struct transvr_obj_s *self, int input_val); - int (*set_extphy_reg)(struct transvr_obj_s *self, int input_val); - - /* ========== Object private functions ========== - */ - int (*init)(struct transvr_obj_s *self); - int (*clean)(struct transvr_obj_s *self); - int (*check)(struct transvr_obj_s *self); - int (*update_all)(struct transvr_obj_s *self, int show_err); - int (*fsm_4_direct)(struct transvr_obj_s* self, char *caller_name); - int (*fsm_4_polling)(struct transvr_obj_s* self, char *caller_name); - int (*send_uevent)(struct transvr_obj_s* self, enum kobject_action u_action); - int (*dump_all)(struct transvr_obj_s* self); -}; - - -/* For AVL Mapping */ -struct transvr_avl_s { - char vendor_name[32]; - char vendor_pn[32]; - int (*init)(struct transvr_obj_s *self); -}; - - -/* Worker for long term task of transceiver */ -struct transvr_worker_s { - /* Task Parameter */ - struct transvr_obj_s *transvr_p; - struct transvr_worker_s *next_p; - struct transvr_worker_s *pre_p; - unsigned long trigger_time; - char func_name[64]; - int retry; - int state; - - /* Task private data */ - void *p_data; - - /* Call back function */ - int (*main_task)(struct transvr_worker_s *task); - int (*post_task)(struct transvr_worker_s *task); -}; - - -struct transvr_obj_s * -create_transvr_obj(char *swp_name, - int chan_id, - struct ioexp_obj_s *ioexp_obj_p, - int ioexp_virt_offset, - int transvr_type, - int chipset_type, - int run_mode); - -void lock_transvr_obj(struct transvr_obj_s *self); -void unlock_transvr_obj(struct transvr_obj_s *self); -int isolate_transvr_obj(struct transvr_obj_s *self); - -int resync_channel_tier_2(struct transvr_obj_s *self); - -void alarm_msg_2_user(struct transvr_obj_s *self, char *emsg); - -unsigned char *get_eeprom_update(void); -void set_eeprom_update(unsigned char value[8]); - -#endif /* TRANSCEIVER_H */ diff --git a/packages/platforms/inventec/x86-64/d6254qs/onlp/Makefile b/packages/platforms/inventec/x86-64/d6254qs/onlp/Makefile deleted file mode 100644 index 003238cf6..000000000 --- a/packages/platforms/inventec/x86-64/d6254qs/onlp/Makefile +++ /dev/null @@ -1 +0,0 @@ -include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/inventec/x86-64/d6254qs/onlp/PKG.yml b/packages/platforms/inventec/x86-64/d6254qs/onlp/PKG.yml deleted file mode 100644 index ed838c3af..000000000 --- a/packages/platforms/inventec/x86-64/d6254qs/onlp/PKG.yml +++ /dev/null @@ -1 +0,0 @@ -!include $ONL_TEMPLATES/onlp-platform-any.yml PLATFORM=x86-64-inventec-d6254qs ARCH=amd64 TOOLCHAIN=x86_64-linux-gnu diff --git a/packages/platforms/inventec/x86-64/d6254qs/onlp/builds/Makefile b/packages/platforms/inventec/x86-64/d6254qs/onlp/builds/Makefile deleted file mode 100644 index e7437cb23..000000000 --- a/packages/platforms/inventec/x86-64/d6254qs/onlp/builds/Makefile +++ /dev/null @@ -1,2 +0,0 @@ -FILTER=src -include $(ONL)/make/subdirs.mk diff --git a/packages/platforms/inventec/x86-64/d6254qs/onlp/builds/lib/Makefile b/packages/platforms/inventec/x86-64/d6254qs/onlp/builds/lib/Makefile deleted file mode 100644 index 9758a4b37..000000000 --- a/packages/platforms/inventec/x86-64/d6254qs/onlp/builds/lib/Makefile +++ /dev/null @@ -1,2 +0,0 @@ -PLATFORM := x86-64-inventec-d6254qs -include $(ONL)/packages/base/any/onlp/builds/platform/libonlp-platform.mk diff --git a/packages/platforms/inventec/x86-64/d6254qs/onlp/builds/onlpdump/Makefile b/packages/platforms/inventec/x86-64/d6254qs/onlp/builds/onlpdump/Makefile deleted file mode 100644 index ad6d49700..000000000 --- a/packages/platforms/inventec/x86-64/d6254qs/onlp/builds/onlpdump/Makefile +++ /dev/null @@ -1,2 +0,0 @@ -PLATFORM := x86-64-inventec-d6254qs -include $(ONL)/packages/base/any/onlp/builds/platform/onlps.mk diff --git a/packages/platforms/inventec/x86-64/d6254qs/onlp/builds/x86_64_inventec_d6254qs/.gitignore b/packages/platforms/inventec/x86-64/d6254qs/onlp/builds/x86_64_inventec_d6254qs/.gitignore deleted file mode 100644 index 238d6eaba..000000000 --- a/packages/platforms/inventec/x86-64/d6254qs/onlp/builds/x86_64_inventec_d6254qs/.gitignore +++ /dev/null @@ -1 +0,0 @@ -x86_64_inventec_d6254qs.mk diff --git a/packages/platforms/inventec/x86-64/d6254qs/onlp/builds/x86_64_inventec_d6254qs/.module b/packages/platforms/inventec/x86-64/d6254qs/onlp/builds/x86_64_inventec_d6254qs/.module deleted file mode 100644 index 623e61c30..000000000 --- a/packages/platforms/inventec/x86-64/d6254qs/onlp/builds/x86_64_inventec_d6254qs/.module +++ /dev/null @@ -1 +0,0 @@ -name: x86_64_inventec_d6254qs diff --git a/packages/platforms/inventec/x86-64/d6254qs/onlp/builds/x86_64_inventec_d6254qs/Makefile b/packages/platforms/inventec/x86-64/d6254qs/onlp/builds/x86_64_inventec_d6254qs/Makefile deleted file mode 100644 index 71b48a78f..000000000 --- a/packages/platforms/inventec/x86-64/d6254qs/onlp/builds/x86_64_inventec_d6254qs/Makefile +++ /dev/null @@ -1,9 +0,0 @@ -############################################################################### -# -# -# -############################################################################### -include $(ONL)/make/config.mk -MODULE := x86_64_inventec_d6254qs -AUTOMODULE := x86_64_inventec_d6254qs -include $(BUILDER)/definemodule.mk diff --git a/packages/platforms/inventec/x86-64/d6254qs/onlp/builds/x86_64_inventec_d6254qs/module/auto/make.mk b/packages/platforms/inventec/x86-64/d6254qs/onlp/builds/x86_64_inventec_d6254qs/module/auto/make.mk deleted file mode 100644 index b6f3d5e89..000000000 --- a/packages/platforms/inventec/x86-64/d6254qs/onlp/builds/x86_64_inventec_d6254qs/module/auto/make.mk +++ /dev/null @@ -1,9 +0,0 @@ -############################################################################### -# -# x86_64_inventec_d6254qs Autogeneration -# -############################################################################### -x86_64_inventec_d6254qs_AUTO_DEFS := module/auto/x86_64_inventec_d6254qs.yml -x86_64_inventec_d6254qs_AUTO_DIRS := module/inc/x86_64_inventec_d6254qs module/src -include $(BUILDER)/auto.mk - diff --git a/packages/platforms/inventec/x86-64/d6254qs/onlp/builds/x86_64_inventec_d6254qs/module/auto/x86_64_inventec_d6254qs.yml b/packages/platforms/inventec/x86-64/d6254qs/onlp/builds/x86_64_inventec_d6254qs/module/auto/x86_64_inventec_d6254qs.yml deleted file mode 100644 index 130f4c8a3..000000000 --- a/packages/platforms/inventec/x86-64/d6254qs/onlp/builds/x86_64_inventec_d6254qs/module/auto/x86_64_inventec_d6254qs.yml +++ /dev/null @@ -1,50 +0,0 @@ -############################################################################### -# -# x86_64_inventec_d6254qs Autogeneration Definitions. -# -############################################################################### - -cdefs: &cdefs -- X86_64_INVENTEC_D6254QS_CONFIG_INCLUDE_LOGGING: - doc: "Include or exclude logging." - default: 1 -- X86_64_INVENTEC_D6254QS_CONFIG_LOG_OPTIONS_DEFAULT: - doc: "Default enabled log options." - default: AIM_LOG_OPTIONS_DEFAULT -- X86_64_INVENTEC_D6254QS_CONFIG_LOG_BITS_DEFAULT: - doc: "Default enabled log bits." - default: AIM_LOG_BITS_DEFAULT -- X86_64_INVENTEC_D6254QS_CONFIG_LOG_CUSTOM_BITS_DEFAULT: - doc: "Default enabled custom log bits." - default: 0 -- X86_64_INVENTEC_D6254QS_CONFIG_PORTING_STDLIB: - doc: "Default all porting macros to use the C standard libraries." - default: 1 -- X86_64_INVENTEC_D6254QS_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS: - doc: "Include standard library headers for stdlib porting macros." - default: X86_64_INVENTEC_D6254QS_CONFIG_PORTING_STDLIB -- X86_64_INVENTEC_D6254QS_CONFIG_INCLUDE_UCLI: - doc: "Include generic uCli support." - default: 0 -- X86_64_INVENTEC_D6254QS_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_D6254QS_CONFIG_HEADER: - defs: *cdefs - basename: x86_64_inventec_d6254qs_config - - portingmacro: - X86_64_INVENTEC_D6254QS: - macros: - - malloc - - free - - memset - - memcpy - - - vsnprintf - - snprintf - - strlen diff --git a/packages/platforms/inventec/x86-64/d6254qs/onlp/builds/x86_64_inventec_d6254qs/module/inc/x86_64_inventec_d6254qs/x86_64_inventec_d6254qs.x b/packages/platforms/inventec/x86-64/d6254qs/onlp/builds/x86_64_inventec_d6254qs/module/inc/x86_64_inventec_d6254qs/x86_64_inventec_d6254qs.x deleted file mode 100644 index 597131ff6..000000000 --- a/packages/platforms/inventec/x86-64/d6254qs/onlp/builds/x86_64_inventec_d6254qs/module/inc/x86_64_inventec_d6254qs/x86_64_inventec_d6254qs.x +++ /dev/null @@ -1,14 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#include - -/* <--auto.start.xmacro(ALL).define> */ -/* */ - -/* <--auto.start.xenum(ALL).define> */ -/* */ - - diff --git a/packages/platforms/inventec/x86-64/d6254qs/onlp/builds/x86_64_inventec_d6254qs/module/inc/x86_64_inventec_d6254qs/x86_64_inventec_d6254qs_config.h b/packages/platforms/inventec/x86-64/d6254qs/onlp/builds/x86_64_inventec_d6254qs/module/inc/x86_64_inventec_d6254qs/x86_64_inventec_d6254qs_config.h deleted file mode 100644 index 2584daaf8..000000000 --- a/packages/platforms/inventec/x86-64/d6254qs/onlp/builds/x86_64_inventec_d6254qs/module/inc/x86_64_inventec_d6254qs/x86_64_inventec_d6254qs_config.h +++ /dev/null @@ -1,137 +0,0 @@ -/**************************************************************************//** - * - * @file - * @brief x86_64_inventec_d6254qs Configuration Header - * - * @addtogroup x86_64_inventec_d6254qs-config - * @{ - * - *****************************************************************************/ -#ifndef __x86_64_inventec_d6254qs_CONFIG_H__ -#define __x86_64_inventec_d6254qs_CONFIG_H__ - -#ifdef GLOBAL_INCLUDE_CUSTOM_CONFIG -#include -#endif -#ifdef x86_64_inventec_d6254qs_INCLUDE_CUSTOM_CONFIG -#include -#endif - -/* */ -#include -/** - * X86_64_INVENTEC_D6254QS_CONFIG_INCLUDE_LOGGING - * - * Include or exclude logging. */ - - -#ifndef X86_64_INVENTEC_D6254QS_CONFIG_INCLUDE_LOGGING -#define X86_64_INVENTEC_D6254QS_CONFIG_INCLUDE_LOGGING 1 -#endif - -/** - * X86_64_INVENTEC_D6254QS_CONFIG_LOG_OPTIONS_DEFAULT - * - * Default enabled log options. */ - - -#ifndef X86_64_INVENTEC_D6254QS_CONFIG_LOG_OPTIONS_DEFAULT -#define X86_64_INVENTEC_D6254QS_CONFIG_LOG_OPTIONS_DEFAULT AIM_LOG_OPTIONS_DEFAULT -#endif - -/** - * X86_64_INVENTEC_D6254QS_CONFIG_LOG_BITS_DEFAULT - * - * Default enabled log bits. */ - - -#ifndef X86_64_INVENTEC_D6254QS_CONFIG_LOG_BITS_DEFAULT -#define X86_64_INVENTEC_D6254QS_CONFIG_LOG_BITS_DEFAULT AIM_LOG_BITS_DEFAULT -#endif - -/** - * X86_64_INVENTEC_D6254QS_CONFIG_LOG_CUSTOM_BITS_DEFAULT - * - * Default enabled custom log bits. */ - - -#ifndef X86_64_INVENTEC_D6254QS_CONFIG_LOG_CUSTOM_BITS_DEFAULT -#define X86_64_INVENTEC_D6254QS_CONFIG_LOG_CUSTOM_BITS_DEFAULT 0 -#endif - -/** - * X86_64_INVENTEC_D6254QS_CONFIG_PORTING_STDLIB - * - * Default all porting macros to use the C standard libraries. */ - - -#ifndef X86_64_INVENTEC_D6254QS_CONFIG_PORTING_STDLIB -#define X86_64_INVENTEC_D6254QS_CONFIG_PORTING_STDLIB 1 -#endif - -/** - * X86_64_INVENTEC_D6254QS_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS - * - * Include standard library headers for stdlib porting macros. */ - - -#ifndef X86_64_INVENTEC_D6254QS_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS -#define X86_64_INVENTEC_D6254QS_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS X86_64_INVENTEC_D6254QS_CONFIG_PORTING_STDLIB -#endif - -/** - * X86_64_INVENTEC_D6254QS_CONFIG_INCLUDE_UCLI - * - * Include generic uCli support. */ - - -#ifndef X86_64_INVENTEC_D6254QS_CONFIG_INCLUDE_UCLI -#define X86_64_INVENTEC_D6254QS_CONFIG_INCLUDE_UCLI 0 -#endif - -/** - * X86_64_INVENTEC_D6254QS_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION - * - * Assume chassis fan direction is the same as the PSU fan direction. */ - - -#ifndef X86_64_INVENTEC_D6254QS_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION -#define X86_64_INVENTEC_D6254QS_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION 0 -#endif - - - -/** - * All compile time options can be queried or displayed - */ - -/** Configuration settings structure. */ -typedef struct x86_64_inventec_d6254qs_config_settings_s { - /** name */ - const char* name; - /** value */ - const char* value; -} x86_64_inventec_d6254qs_config_settings_t; - -/** Configuration settings table. */ -/** x86_64_inventec_d6254qs_config_settings table. */ -extern x86_64_inventec_d6254qs_config_settings_t x86_64_inventec_d6254qs_config_settings[]; - -/** - * @brief Lookup a configuration setting. - * @param setting The name of the configuration option to lookup. - */ -const char* x86_64_inventec_d6254qs_config_lookup(const char* setting); - -/** - * @brief Show the compile-time configuration. - * @param pvs The output stream. - */ -int x86_64_inventec_d6254qs_config_show(struct aim_pvs_s* pvs); - -/* */ - -#include "x86_64_inventec_d6254qs_porting.h" - -#endif /* __x86_64_inventec_d6254qs_CONFIG_H__ */ -/* @} */ diff --git a/packages/platforms/inventec/x86-64/d6254qs/onlp/builds/x86_64_inventec_d6254qs/module/inc/x86_64_inventec_d6254qs/x86_64_inventec_d6254qs_dox.h b/packages/platforms/inventec/x86-64/d6254qs/onlp/builds/x86_64_inventec_d6254qs/module/inc/x86_64_inventec_d6254qs/x86_64_inventec_d6254qs_dox.h deleted file mode 100644 index a8a512b7a..000000000 --- a/packages/platforms/inventec/x86-64/d6254qs/onlp/builds/x86_64_inventec_d6254qs/module/inc/x86_64_inventec_d6254qs/x86_64_inventec_d6254qs_dox.h +++ /dev/null @@ -1,26 +0,0 @@ -/**************************************************************************//** - * - * x86_64_inventec_d6254qs Doxygen Header - * - *****************************************************************************/ -#ifndef __x86_64_inventec_d6254qs_DOX_H__ -#define __x86_64_inventec_d6254qs_DOX_H__ - -/** - * @defgroup x86_64_inventec_d6254qs x86_64_inventec_d6254qs - x86_64_inventec_d6254qs Description - * - -The documentation overview for this module should go here. - - * - * @{ - * - * @defgroup x86_64_inventec_d6254qs-x86_64_inventec_d6254qs Public Interface - * @defgroup x86_64_inventec_d6254qs-config Compile Time Configuration - * @defgroup x86_64_inventec_d6254qs-porting Porting Macros - * - * @} - * - */ - -#endif /* __x86_64_inventec_d6254qs_DOX_H__ */ diff --git a/packages/platforms/inventec/x86-64/d6254qs/onlp/builds/x86_64_inventec_d6254qs/module/inc/x86_64_inventec_d6254qs/x86_64_inventec_d6254qs_porting.h b/packages/platforms/inventec/x86-64/d6254qs/onlp/builds/x86_64_inventec_d6254qs/module/inc/x86_64_inventec_d6254qs/x86_64_inventec_d6254qs_porting.h deleted file mode 100644 index d86747b58..000000000 --- a/packages/platforms/inventec/x86-64/d6254qs/onlp/builds/x86_64_inventec_d6254qs/module/inc/x86_64_inventec_d6254qs/x86_64_inventec_d6254qs_porting.h +++ /dev/null @@ -1,97 +0,0 @@ -/**************************************************************************//** - * - * @file - * @brief x86_64_inventec_d6254qs Porting Macros. - * - * @addtogroup x86_64_inventec_d6254qs-porting - * @{ - * - *****************************************************************************/ -#ifndef __x86_64_inventec_d6254qs_PORTING_H__ -#define __x86_64_inventec_d6254qs_PORTING_H__ - - -/* */ -#if X86_64_INVENTEC_D6254QS_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS == 1 -#include -#include -#include -#include -#include -#endif - -#ifndef X86_64_INVENTEC_D6254QS_MALLOC - #if defined(GLOBAL_MALLOC) - #define X86_64_INVENTEC_D6254QS_MALLOC GLOBAL_MALLOC - #elif X86_64_INVENTEC_D6254QS_CONFIG_PORTING_STDLIB == 1 - #define X86_64_INVENTEC_D6254QS_MALLOC malloc - #else - #error The macro X86_64_INVENTEC_D6254QS_MALLOC is required but cannot be defined. - #endif -#endif - -#ifndef X86_64_INVENTEC_D6254QS_FREE - #if defined(GLOBAL_FREE) - #define X86_64_INVENTEC_D6254QS_FREE GLOBAL_FREE - #elif X86_64_INVENTEC_D6254QS_CONFIG_PORTING_STDLIB == 1 - #define X86_64_INVENTEC_D6254QS_FREE free - #else - #error The macro X86_64_INVENTEC_D6254QS_FREE is required but cannot be defined. - #endif -#endif - -#ifndef X86_64_INVENTEC_D6254QS_MEMSET - #if defined(GLOBAL_MEMSET) - #define X86_64_INVENTEC_D6254QS_MEMSET GLOBAL_MEMSET - #elif X86_64_INVENTEC_D6254QS_CONFIG_PORTING_STDLIB == 1 - #define X86_64_INVENTEC_D6254QS_MEMSET memset - #else - #error The macro X86_64_INVENTEC_D6254QS_MEMSET is required but cannot be defined. - #endif -#endif - -#ifndef X86_64_INVENTEC_D6254QS_MEMCPY - #if defined(GLOBAL_MEMCPY) - #define X86_64_INVENTEC_D6254QS_MEMCPY GLOBAL_MEMCPY - #elif X86_64_INVENTEC_D6254QS_CONFIG_PORTING_STDLIB == 1 - #define X86_64_INVENTEC_D6254QS_MEMCPY memcpy - #else - #error The macro X86_64_INVENTEC_D6254QS_MEMCPY is required but cannot be defined. - #endif -#endif - -#ifndef X86_64_INVENTEC_D6254QS_VSNPRINTF - #if defined(GLOBAL_VSNPRINTF) - #define X86_64_INVENTEC_D6254QS_VSNPRINTF GLOBAL_VSNPRINTF - #elif X86_64_INVENTEC_D6254QS_CONFIG_PORTING_STDLIB == 1 - #define X86_64_INVENTEC_D6254QS_VSNPRINTF vsnprintf - #else - #error The macro X86_64_INVENTEC_D6254QS_VSNPRINTF is required but cannot be defined. - #endif -#endif - -#ifndef X86_64_INVENTEC_D6254QS_SNPRINTF - #if defined(GLOBAL_SNPRINTF) - #define X86_64_INVENTEC_D6254QS_SNPRINTF GLOBAL_SNPRINTF - #elif X86_64_INVENTEC_D6254QS_CONFIG_PORTING_STDLIB == 1 - #define X86_64_INVENTEC_D6254QS_SNPRINTF snprintf - #else - #error The macro X86_64_INVENTEC_D6254QS_SNPRINTF is required but cannot be defined. - #endif -#endif - -#ifndef X86_64_INVENTEC_D6254QS_STRLEN - #if defined(GLOBAL_STRLEN) - #define X86_64_INVENTEC_D6254QS_STRLEN GLOBAL_STRLEN - #elif X86_64_INVENTEC_D6254QS_CONFIG_PORTING_STDLIB == 1 - #define X86_64_INVENTEC_D6254QS_STRLEN strlen - #else - #error The macro X86_64_INVENTEC_D6254QS_STRLEN is required but cannot be defined. - #endif -#endif - -/* */ - - -#endif /* __x86_64_inventec_d6254qs_PORTING_H__ */ -/* @} */ diff --git a/packages/platforms/inventec/x86-64/d6254qs/onlp/builds/x86_64_inventec_d6254qs/module/make.mk b/packages/platforms/inventec/x86-64/d6254qs/onlp/builds/x86_64_inventec_d6254qs/module/make.mk deleted file mode 100644 index 6071088e9..000000000 --- a/packages/platforms/inventec/x86-64/d6254qs/onlp/builds/x86_64_inventec_d6254qs/module/make.mk +++ /dev/null @@ -1,10 +0,0 @@ -############################################################################### -# -# -# -############################################################################### -THIS_DIR := $(dir $(lastword $(MAKEFILE_LIST))) -x86_64_inventec_d6254qs_INCLUDES := -I $(THIS_DIR)inc -x86_64_inventec_d6254qs_INTERNAL_INCLUDES := -I $(THIS_DIR)src -x86_64_inventec_d6254qs_DEPENDMODULE_ENTRIES := init:x86_64_inventec_d6254qs ucli:x86_64_inventec_d6254qs - diff --git a/packages/platforms/inventec/x86-64/d6254qs/onlp/builds/x86_64_inventec_d6254qs/module/src/Makefile b/packages/platforms/inventec/x86-64/d6254qs/onlp/builds/x86_64_inventec_d6254qs/module/src/Makefile deleted file mode 100644 index 3eedeea2d..000000000 --- a/packages/platforms/inventec/x86-64/d6254qs/onlp/builds/x86_64_inventec_d6254qs/module/src/Makefile +++ /dev/null @@ -1,9 +0,0 @@ -############################################################################### -# -# Local source generation targets. -# -############################################################################### - -ucli: - @../../../../tools/uclihandlers.py x86_64_inventec_d6254qs_ucli.c - diff --git a/packages/platforms/inventec/x86-64/d6254qs/onlp/builds/x86_64_inventec_d6254qs/module/src/fani.c b/packages/platforms/inventec/x86-64/d6254qs/onlp/builds/x86_64_inventec_d6254qs/module/src/fani.c deleted file mode 100644 index 239704dc8..000000000 --- a/packages/platforms/inventec/x86-64/d6254qs/onlp/builds/x86_64_inventec_d6254qs/module/src/fani.c +++ /dev/null @@ -1,269 +0,0 @@ -/************************************************************ - * fani.c - * - * Copyright 2018 Inventec Technology Corporation. - * - ************************************************************ - * - * Fan Platform Implementation Defaults. - * - ***********************************************************/ -#include -#include -#include -#include -#include -#include "platform_lib.h" - -#define FAN_GPI_ON_MAIN_BOARD INV_PSOC_PREFIX"/fan_gpi" - -#define MAX_FAN_SPEED 18000 -#define MAX_PSU_FAN_SPEED 25500 - -#define PROJECT_NAME -#define LEN_FILE_NAME 80 - -static char* devfiles__[FAN_MAX] = /* must map with onlp_thermal_id */ -{ - "reserved", - INV_PSOC_PREFIX"/fan1_input", - INV_PSOC_PREFIX"/fan2_input", - INV_PSOC_PREFIX"/fan3_input", - INV_PSOC_PREFIX"/fan4_input", - INV_PSOC_PREFIX"/fan5_input", - INV_PSOC_PREFIX"/fan6_input", - INV_PSOC_PREFIX"/fan7_input", - INV_PSOC_PREFIX"/fan8_input", - INV_PSOC_PREFIX"/rpm_psu1", - INV_PSOC_PREFIX"/rpm_psu2", -}; - -#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_F2B | 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_F2B | ONLP_FAN_CAPS_GET_RPM | ONLP_FAN_CAPS_GET_PERCENTAGE), \ - 0, \ - 0, \ - ONLP_FAN_MODE_INVALID, \ - } - -/* Static fan information */ -onlp_fan_info_t linfo[FAN_MAX] = { - { }, /* 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_MAIN_BOARD(7), - MAKE_FAN_INFO_NODE_ON_MAIN_BOARD(8), - 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, FAN_GPI_ON_MAIN_BOARD); - if (ret < 0) { - return ONLP_STATUS_E_INTERNAL; - } - if (value & (1 << (fid-1))) { - info->status |= ONLP_FAN_STATUS_FAILED; - } - else { - info->status |= ONLP_FAN_STATUS_PRESENT; - info->status |= ONLP_FAN_STATUS_F2B; - } - - /* get front fan speed */ - ret = onlp_file_read_int(&value, devfiles__[fid]); - if (ret < 0) { - return ONLP_STATUS_E_INTERNAL; - } - info->rpm = value; - info->percentage = (info->rpm * 100) / MAX_PSU_FAN_SPEED; - - snprintf(info->model, ONLP_CONFIG_INFO_STR_MAX, "NA"); - snprintf(info->serial, ONLP_CONFIG_INFO_STR_MAX, "NA"); - - 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 fid, onlp_fan_info_t* info) -{ - int value, ret, index; - - info->status |= ONLP_FAN_STATUS_PRESENT; - info->status |= ONLP_FAN_STATUS_F2B; - - /* get fan direction */ - info->status |= _onlp_get_fan_direction_on_psu(); - - if (info->status & ONLP_FAN_STATUS_FAILED) { - return ONLP_STATUS_OK; - } - - index = ONLP_OID_ID_GET(info->hdr.id); - info->hdr.coids[0] = ONLP_FAN_ID_CREATE(index + CHASSIS_FAN_COUNT); - - /* get front fan speed */ - ret = onlp_file_read_int(&value, devfiles__[fid]); - if (ret < 0) { - return ONLP_STATUS_E_INTERNAL; - } - info->rpm = value; - info->percentage = (info->rpm * 100) / MAX_PSU_FAN_SPEED; - info->status |= (value == 0) ? ONLP_FAN_STATUS_FAILED : 0; - - snprintf(info->model, ONLP_CONFIG_INFO_STR_MAX, "NA"); - snprintf(info->serial, ONLP_CONFIG_INFO_STR_MAX, "NA"); - - 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: - 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 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_PSU1: - return psu_pmbus_info_set(PSU1_ID, "rpm_psu1", p); - case FAN_1_ON_PSU2: - return psu_pmbus_info_set(PSU2_ID, "rpm_psu2", p); - 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: - 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/d6254qs/onlp/builds/x86_64_inventec_d6254qs/module/src/ledi.c b/packages/platforms/inventec/x86-64/d6254qs/onlp/builds/x86_64_inventec_d6254qs/module/src/ledi.c deleted file mode 100644 index f9389cd72..000000000 --- a/packages/platforms/inventec/x86-64/d6254qs/onlp/builds/x86_64_inventec_d6254qs/module/src/ledi.c +++ /dev/null @@ -1,424 +0,0 @@ -/************************************************************ - * ledi.c - * - * Copyright 2018 Inventec Technology Corporation. - * - ************************************************************ - * - ***********************************************************/ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "platform_lib.h" - -#define filename "brightness" - -#define VALIDATE(_id) \ - do { \ - if(!ONLP_OID_IS_LED(_id)) { \ - return ONLP_STATUS_E_INVALID; \ - } \ - } while(0) - -static char* devfiles__[LED_MAX] = /* must map with onlp_thermal_id */ -{ - "reserved", - INV_CPLD_PREFIX"/%s_led", - INV_PSOC_PREFIX"/fan_led_%s1", - INV_PSOC_PREFIX"/fan_led_%s2", - INV_PSOC_PREFIX"/fan_led_%s3", - INV_PSOC_PREFIX"/fan_led_%s4", -}; - -/* - * Get the information for the given LED OID. - */ -static onlp_led_info_t linfo[LED_MAX] = -{ - { }, /* Not used */ - { - { ONLP_LED_ID_CREATE(LED_SYS), "Chassis LED (SYSTEM 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_MODE_ON, '0', - }, - { - { ONLP_LED_ID_CREATE(LED_FAN1), "Fan LED 1 (FAN1 LED)", 0 }, - ONLP_LED_STATUS_PRESENT, - ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_RED, - ONLP_LED_MODE_ON, '0', - }, - { - { ONLP_LED_ID_CREATE(LED_FAN2), "Fan LED 2 (FAN2 LED)", 0 }, - ONLP_LED_STATUS_PRESENT, - ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_RED, - ONLP_LED_MODE_ON, '0', - }, - { - { ONLP_LED_ID_CREATE(LED_FAN3), "Fan LED 3 (FAN3 LED)", 0 }, - ONLP_LED_STATUS_PRESENT, - ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_RED, - ONLP_LED_MODE_ON, '0', - }, - { - { ONLP_LED_ID_CREATE(LED_FAN4), "Fan LED 4 (FAN4 LED)", 0 }, - ONLP_LED_STATUS_PRESENT, - ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_RED, - ONLP_LED_MODE_ON, '0', - }, -}; - -/* - * This function will be called prior to any other onlp_ledi_* functions. - */ -static pthread_mutex_t diag_mutex; - -int -onlp_ledi_init(void) -{ - pthread_mutex_init(&diag_mutex, NULL); - - /* - * Diag LED Off - */ - onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_SYS), ONLP_LED_MODE_OFF); - - return ONLP_STATUS_OK; -} - -int onlp_chassis_led_read(char *pathp, char *buf, size_t len) -{ - FILE * fp; - - fp = fopen (pathp, "r"); - if(fp == NULL) { - perror("Error opening file"); - return(-1); - } - if( fgets (buf, len, fp) == NULL ) { - perror("Error fgets operation"); - } - fclose(fp); - - return(0); -} - -int onlp_chassis_led_write(char *pathp, char *buf) -{ - FILE * fp; - - fp = fopen (pathp, "w"); - if(fp == NULL) { - perror("Error opening file"); - return(-1); - } - if( fputs (buf, fp) == 0 ) { - perror("Error fputs operation"); - } - fclose(fp); - - return(0); -} - -int -onlp_ledi_info_get(onlp_oid_t id, onlp_led_info_t* info) -{ - int local_id, gret = 0, rret = 0; - char fullpath_grn[50] = {0}; - char fullpath_red[50] = {0}; - int gvalue = 0, rvalue = 0; - char gbuf[32] = {0}; - char rbuf[32] = {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 fullpath */ - switch (local_id) { - case LED_SYS: - sprintf(fullpath_grn, devfiles__[local_id], "grn"); - sprintf(fullpath_red, devfiles__[local_id], "red"); - - /* Set LED mode */ - gret = onlp_chassis_led_read(fullpath_grn, gbuf, 32); - rret = onlp_chassis_led_read(fullpath_red, rbuf, 32); - if (gret < 0 || rret < 0) { - DEBUG_PRINT("%s(%d): gret = %d, rret = %d\r\n", __FUNCTION__, __LINE__, gret, rret); - info->mode = ONLP_LED_MODE_OFF; - info->status = ONLP_LED_STATUS_FAILED; - break; - } - - info->status = ONLP_LED_STATUS_PRESENT; - if (gbuf[0] >= '1' && gbuf[0] <= '7' && rbuf[0] == '0') { - info->mode = ONLP_LED_MODE_GREEN; - info->status |= ONLP_LED_STATUS_ON; - } - else - if (rbuf[0] >= '1' && rbuf[0] <= '7' && gbuf[0] == '0') { - info->mode = ONLP_LED_MODE_RED; - info->status |= ONLP_LED_STATUS_ON; - } - else - if (gbuf[0] >= '1' && gbuf[0] <= '7' && rbuf[0] >= '1' && rbuf[0] <= '7') { - info->mode = ONLP_LED_MODE_ORANGE; - info->status |= ONLP_LED_STATUS_ON; - } - else - if (gbuf[0] == '0' && rbuf[0] == '0') { - info->mode = ONLP_LED_MODE_OFF; - info->status |= ONLP_LED_STATUS_ON; - } - else { - info->mode = ONLP_LED_MODE_OFF; - info->status = ONLP_LED_STATUS_FAILED; - } - break; - case LED_FAN1: - case LED_FAN2: - case LED_FAN3: - case LED_FAN4: - sprintf(fullpath_grn, devfiles__[local_id], "grn"); - - /* Set LED mode */ - if (onlp_file_read_int(&gvalue, fullpath_grn) != 0) { - DEBUG_PRINT("%s(%d)\r\n", __FUNCTION__, __LINE__); - info->mode = ONLP_LED_MODE_OFF; - info->status = ONLP_LED_STATUS_FAILED; - } - else - if (gvalue == 1) { - info->mode = ONLP_LED_MODE_GREEN; - info->status = ONLP_LED_STATUS_ON; - } - else - if (gvalue == 0) { - info->mode = ONLP_LED_MODE_OFF; - info->status = ONLP_LED_STATUS_ON; - } - - sprintf(fullpath_red, devfiles__[local_id], "red"); - - if (onlp_file_read_int(&rvalue, fullpath_red) != 0) { - DEBUG_PRINT("%s(%d)\r\n", __FUNCTION__, __LINE__); - info->mode = ONLP_LED_MODE_OFF; - info->status = ONLP_LED_STATUS_FAILED; - } - else - if (rvalue == 1) { - info->mode = ONLP_LED_MODE_RED; - info->status = ONLP_LED_STATUS_ON; - } - else - if (rvalue == 0) { - info->mode = ONLP_LED_MODE_OFF; - info->status = ONLP_LED_STATUS_ON; - } - break; - default: - DEBUG_PRINT("%s(%d) Invalid led id %d\r\n", __FUNCTION__, __LINE__, local_id); - break; - } - - return ONLP_STATUS_OK; -} - -int onlp_ledi_status_get(onlp_oid_t id, uint32_t* rv) -{ - int result = ONLP_STATUS_OK; - onlp_led_info_t linfo; - - result = onlp_ledi_info_get(id, &linfo); - *rv = linfo.status; - - return result; -} - -/* - * 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; -} - -#define HWMON_DEVICE_DIAG_PATH INV_PSOC_PREFIX"/subsystem/devices/0-0066/diag" -#define HWMON_DEVICE_CTRL_PATH INV_CPLD_PREFIX"/subsystem/devices/0-0055/ctl" - -#define MIN_ACC_SIZE (32) - -/* - * Store attr Section - */ -static int onlp_chassis_led_diag_enable(void) -{ - char tmp[MIN_ACC_SIZE]; - ssize_t ret; - - ret = onlp_chassis_led_read(HWMON_DEVICE_DIAG_PATH, &tmp[0], MIN_ACC_SIZE); - if (ret <= 0) { - return ret; - } - - if (tmp[0] == '0') { - pthread_mutex_lock(&diag_mutex); - ret = onlp_chassis_led_write(HWMON_DEVICE_DIAG_PATH, "1"); - if (ret < 0) { - pthread_mutex_unlock(&diag_mutex); - return ret; - } - - ret = onlp_chassis_led_write(HWMON_DEVICE_CTRL_PATH, "1"); - if (ret < 0) { - pthread_mutex_unlock(&diag_mutex); - return ret; - } - pthread_mutex_unlock(&diag_mutex); - } - - return ret; -} - -static int onlp_chassis_led_diag_disable(void) -{ - char tmp[MIN_ACC_SIZE]; - ssize_t ret; - - ret = onlp_chassis_led_read(HWMON_DEVICE_DIAG_PATH, &tmp[0], MIN_ACC_SIZE); - if (ret <= 0) { - return ret; - } - - if (tmp[0] == '1') { - pthread_mutex_lock(&diag_mutex); - ret = onlp_chassis_led_write(HWMON_DEVICE_DIAG_PATH, "1"); - if (ret < 0) { - pthread_mutex_unlock(&diag_mutex); - return 1; - } - - ret = onlp_chassis_led_write(HWMON_DEVICE_CTRL_PATH, "1"); - if (ret < 0) { - pthread_mutex_unlock(&diag_mutex); - return 1; - } - pthread_mutex_unlock(&diag_mutex); - } - return 1; -} - -/* - * 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) -{ - char fullpath_grn[50] = {0}; - char fullpath_red[50] = {0}; - char sys_buf[32] = {0}; - onlp_led_info_t linfo; - int ret = onlp_ledi_info_get(id, &linfo); - int local_id; - - VALIDATE(id); - - local_id = ONLP_OID_ID_GET(id); - - switch (mode) { - case ONLP_LED_MODE_OFF: - if (ret == ONLP_STATUS_OK && linfo.status & ONLP_LED_STATUS_ON && linfo.mode == ONLP_LED_MODE_OFF) { - return ONLP_STATUS_OK; - } - - sprintf(sys_buf, "%d", 0x0); - sprintf(fullpath_grn, devfiles__[local_id], "grn"); - ret = onlp_chassis_led_write(fullpath_grn, sys_buf); - - sprintf(sys_buf, "%d", 0x0); - sprintf(fullpath_red, devfiles__[local_id], "red"); - ret = onlp_chassis_led_write(fullpath_red, sys_buf); - break; - case ONLP_LED_MODE_RED: - if (ret == ONLP_STATUS_OK && linfo.status & ONLP_LED_STATUS_ON && linfo.mode == ONLP_LED_MODE_RED) { - return ONLP_STATUS_OK; - } - - sprintf(sys_buf, "%d", 0x0); - sprintf(fullpath_grn, devfiles__[local_id], "grn"); - ret = onlp_chassis_led_write(fullpath_grn, sys_buf); - - sprintf(sys_buf, "%d", 0x7); - sprintf(fullpath_red, devfiles__[local_id], "red"); - ret = onlp_chassis_led_write(fullpath_red, sys_buf); - break; - case ONLP_LED_MODE_GREEN: - if (ret == ONLP_STATUS_OK && linfo.status & ONLP_LED_STATUS_ON && linfo.mode == ONLP_LED_MODE_GREEN) { - return ONLP_STATUS_OK; - } - - sprintf(sys_buf, "%d", 0x7); - sprintf(fullpath_grn, devfiles__[local_id], "grn"); - ret = onlp_chassis_led_write(fullpath_grn, sys_buf); - - sprintf(sys_buf, "%d", 0x0); - sprintf(fullpath_red, devfiles__[local_id], "red"); - ret = onlp_chassis_led_write(fullpath_red, sys_buf); - break; - case ONLP_LED_MODE_ORANGE: - if (ret == ONLP_STATUS_OK && linfo.status & ONLP_LED_STATUS_ON && linfo.mode == ONLP_LED_MODE_ORANGE) { - return ONLP_STATUS_OK; - } - - sprintf(sys_buf, "%d", 0x7); - sprintf(fullpath_grn, devfiles__[local_id], "grn"); - ret = onlp_chassis_led_write(fullpath_grn, sys_buf); - - sprintf(sys_buf, "%d", 0x7); - sprintf(fullpath_red, devfiles__[local_id], "red"); - ret = onlp_chassis_led_write(fullpath_red, sys_buf); - break; - default: - DEBUG_PRINT("%s(%d) Invalid led mode %d\r\n", __FUNCTION__, __LINE__, mode); - return ONLP_STATUS_E_INTERNAL; - } - - switch (local_id) { - case LED_SYS: - onlp_chassis_led_diag_enable(); - sleep(1); - onlp_chassis_led_diag_disable(); - break; - default: - break; - } - - return ONLP_STATUS_OK; -} diff --git a/packages/platforms/inventec/x86-64/d6254qs/onlp/builds/x86_64_inventec_d6254qs/module/src/make.mk b/packages/platforms/inventec/x86-64/d6254qs/onlp/builds/x86_64_inventec_d6254qs/module/src/make.mk deleted file mode 100644 index 5e9bf5051..000000000 --- a/packages/platforms/inventec/x86-64/d6254qs/onlp/builds/x86_64_inventec_d6254qs/module/src/make.mk +++ /dev/null @@ -1,9 +0,0 @@ -############################################################################### -# -# -# -############################################################################### - -LIBRARY := x86_64_inventec_d6254qs -$(LIBRARY)_SUBDIR := $(dir $(lastword $(MAKEFILE_LIST))) -include $(BUILDER)/lib.mk diff --git a/packages/platforms/inventec/x86-64/d6254qs/onlp/builds/x86_64_inventec_d6254qs/module/src/platform_lib.c b/packages/platforms/inventec/x86-64/d6254qs/onlp/builds/x86_64_inventec_d6254qs/module/src/platform_lib.c deleted file mode 100644 index afaf19939..000000000 --- a/packages/platforms/inventec/x86-64/d6254qs/onlp/builds/x86_64_inventec_d6254qs/module/src/platform_lib.c +++ /dev/null @@ -1,184 +0,0 @@ -/************************************************************ - * platform_lib.c - * - * Copyright 2018 Inventec Corporation. - * - ************************************************************ - * - ***********************************************************/ -#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 32 -#define I2C_PSU_FAN_DIR_LEN 8 -#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)] = 0; - } - - if (strncmp(model_name, "YM-2651Y", 8) == 0) { - if (modelname) { - aim_strlcpy(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) { - aim_strlcpy(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) { - aim_strlcpy(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; - } - } - - if (strncmp(model_name, "DPS-150AB-10", 12) == 0) { - if (modelname) { - aim_strlcpy(modelname, model_name, 12); - } - - return PSU_TYPE_DC_12V_F2B; - } - - 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%d", PSU1_AC_PMBUS_PREFIX, node, PSU1_ID); - } - else - if (PSU2_ID == id) { - ret = onlp_file_read_int(value, "%s%s%d", PSU2_AC_PMBUS_PREFIX, node, PSU2_ID); - } - else { - return ONLP_STATUS_E_INTERNAL; - } - - 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%d", PSU1_AC_PMBUS_PREFIX, node, PSU1_ID); - break; - case PSU2_ID: - sprintf(path, "%s%s%d", PSU2_AC_PMBUS_PREFIX, node, PSU2_ID); - 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/d6254qs/onlp/builds/x86_64_inventec_d6254qs/module/src/platform_lib.h b/packages/platforms/inventec/x86-64/d6254qs/onlp/builds/x86_64_inventec_d6254qs/module/src/platform_lib.h deleted file mode 100644 index eac465767..000000000 --- a/packages/platforms/inventec/x86-64/d6254qs/onlp/builds/x86_64_inventec_d6254qs/module/src/platform_lib.h +++ /dev/null @@ -1,136 +0,0 @@ -/************************************************************ - * platform_lib.h - * - * Copyright 2018 Inventec Technology Corporation. - * - ************************************************************ - * - ***********************************************************/ -#ifndef __PLATFORM_LIB_H__ -#define __PLATFORM_LIB_H__ - -#include "x86_64_inventec_d6254qs_log.h" - -#define SWPS_MAGNOLIA (1) - -#define ONLP_NODE_MAX_INT_LEN (8) -#define ONLP_NODE_MAX_PATH_LEN (64) - -#define INV_CPLD_COUNT (1) -#define INV_CPLD_PREFIX "/sys/bus/i2c/devices/0-0055/" -#define INV_PSOC_PREFIX "/sys/bus/i2c/devices/0-0066/" -#define INV_EPRM_PREFIX "/sys/bus/i2c/devices/0-0053/" -#define INV_CTMP_PREFIX "/sys/devices/platform/coretemp.0/hwmon/hwmon0/" - -#define INV_SFP_EEPROM_UPDATE "/sys/class/swps/module/eeprom_update" -#define CHASSIS_SFP_COUNT (54) - -/* - * Definitions of Chassis EEPROM - */ -#define EEPROM_NODE(node) INV_EPRM_PREFIX#node - -/* - * Definitions of D6254QS device - */ -enum onlp_thermal_id { - THERMAL_RESERVED = 0, - THERMAL_CPU_CORE_FIRST, - THERMAL_CPU_CORE_3, - THERMAL_CPU_CORE_4, - THERMAL_CPU_CORE_LAST, - 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, - THERMAL_MAX -}; -#define CHASSIS_THERMAL_COUNT (9) - -enum onlp_fan_id { - FAN_RESERVED = 0, - FAN_1_ON_MAIN_BOARD, - FAN_2_ON_MAIN_BOARD, - FAN_3_ON_MAIN_BOARD, - FAN_4_ON_MAIN_BOARD, - FAN_5_ON_MAIN_BOARD, - FAN_6_ON_MAIN_BOARD, - FAN_7_ON_MAIN_BOARD, - FAN_8_ON_MAIN_BOARD, - FAN_1_ON_PSU1, - FAN_1_ON_PSU2, - FAN_MAX -}; -#define CHASSIS_FAN_COUNT (8) - -enum onlp_led_id { - LED_RESERVED = 0, - LED_SYS, - LED_FAN1, - LED_FAN2, - LED_FAN3, - LED_FAN4, - LED_MAX -}; -#define CHASSIS_LED_COUNT (1) - -enum onlp_psu_id { - PSU_RESERVED = 0, - PSU1_ID, - PSU2_ID, - PSU_MAX -}; -#define CHASSIS_PSU_COUNT (2) - -#define PSU1_AC_PMBUS_PREFIX INV_PSOC_PREFIX -#define PSU2_AC_PMBUS_PREFIX INV_PSOC_PREFIX - -#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 INV_CPLD_PREFIX -#define PSU2_AC_HWMON_PREFIX INV_CPLD_PREFIX - -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 PSU1_AC_HWMON_NODE(node) PSU1_AC_HWMON_PREFIX#node -#define PSU2_AC_HWMON_NODE(node) PSU2_AC_HWMON_PREFIX#node - -/* - * Definitions of FAN device - */ -#define FAN_BOARD_PATH INV_PSOC_PREFIX -#define FAN_NODE(node) FAN_BOARD_PATH#node - -/* - * Prototypes - */ -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); - -#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/d6254qs/onlp/builds/x86_64_inventec_d6254qs/module/src/psui.c b/packages/platforms/inventec/x86-64/d6254qs/onlp/builds/x86_64_inventec_d6254qs/module/src/psui.c deleted file mode 100644 index a00088801..000000000 --- a/packages/platforms/inventec/x86-64/d6254qs/onlp/builds/x86_64_inventec_d6254qs/module/src/psui.c +++ /dev/null @@ -1,255 +0,0 @@ -/************************************************************ - * psui.c - * - * Copyright 2018 Inventec Technology Corporation. - * - ************************************************************ - * - ***********************************************************/ -#include -#include -#include -#include -#include -#include -#include "platform_lib.h" - -#define PSU_STATUS_PRESENT (0) -#define PSU_STATUS_POWER_GOOD (1) -#define PSU_STATUS_UNPOWERED (2) -#define PSU_STATUS_FAULT (4) -#define PSU_STATUS_UNINSTALLED (7) - -#define VALIDATE(_id) \ - do { \ - if(!ONLP_OID_IS_PSU(_id)) { \ - return ONLP_STATUS_E_INVALID; \ - } \ - } while(0) - -static char* status_devfiles__[PSU_MAX] = /* must map with onlp_psu_id */ -{ - "reserved", - INV_CPLD_PREFIX"/psu0", - INV_CPLD_PREFIX"/psu1", -}; - -static char* module_devfiles__[PSU_MAX] = /* must map with onlp_psu_id */ -{ - "reserved", - INV_PSOC_PREFIX"/psoc_psu1_%s", - INV_PSOC_PREFIX"/psoc_psu2_%s", -}; - -static int -psu_status_info_get(int id, char *node, int *value) -{ - int ret = 0; - char node_path[ONLP_NODE_MAX_PATH_LEN] = {0}; - - *value = 0; - if (PSU1_ID == id) { - sprintf(node_path, status_devfiles__[id]); - } - else if (PSU2_ID == id) { - sprintf(node_path, status_devfiles__[id]); - } - - 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 ONLP_STATUS_OK; -} - - -int -onlp_psui_init(void) -{ - return ONLP_STATUS_OK; -} - -static void -psu_module_name_get(int id, onlp_psu_info_t* info) -{ -#if 1 - aim_strlcpy(info->model, "N/A", 3); - aim_strlcpy(info->serial, "N/A", 3); -#else - char node_path[ONLP_NODE_MAX_PATH_LEN] = {0}; - uint8_t temp[ONLP_CONFIG_INFO_STR_MAX] = {0}; - int ret, len; - - memset(node_path, 0, ONLP_NODE_MAX_PATH_LEN); - sprintf(node_path, module_devfiles__[id], "model"); - ret = onlp_file_read(temp, ONLP_CONFIG_INFO_STR_MAX, &len, node_path); - if (ret == 0) { - /*remove the '\n'*/ - temp[strlen((char*)temp)-1] = 0; - snprintf(info->model, ONLP_CONFIG_INFO_STR_MAX, "%s", temp); - } - else { - AIM_LOG_ERROR("Unable to read model name from file(%s)\r\n", node_path); - aim_strlcpy(info->model, "N/A", 3); - } - - memset(node_path, 0, ONLP_NODE_MAX_PATH_LEN); - sprintf(node_path, module_devfiles__[id], "sn"); - ret = onlp_file_read(temp, ONLP_CONFIG_INFO_STR_MAX, &len, node_path); - if (ret == 0) { - /*remove the '\n'*/ - temp[strlen((char*)temp)-1] = 0; - snprintf(info->serial, ONLP_CONFIG_INFO_STR_MAX, "%s", temp); - } - else { - AIM_LOG_ERROR("Unable to read model name from file(%s)\r\n", node_path); - aim_strlcpy(info->serial, "N/A", 3); - } -#endif -} - -static int -psu_module_info_get(int id, onlp_psu_info_t* info) -{ - int ret = 0; - char node_path[ONLP_NODE_MAX_PATH_LEN] = {0}; - int value = 0; - - info->caps |= ONLP_PSU_CAPS_DC12; - - memset(node_path, 0, ONLP_NODE_MAX_PATH_LEN); - sprintf(node_path, module_devfiles__[id], "vout"); - ret = onlp_file_read_int(&value, node_path); - if (ret < 0) { - AIM_LOG_ERROR("Unable to read vout from file(%s)\r\n", node_path); - } - else { - info->mvout = value; - info->caps |= ONLP_PSU_CAPS_VOUT; - } - - memset(node_path, 0, ONLP_NODE_MAX_PATH_LEN); - sprintf(node_path, module_devfiles__[id], "iout"); - ret = onlp_file_read_int(&value, node_path); - if (ret < 0) { - AIM_LOG_ERROR("Unable to read iout from file(%s)\r\n", node_path); - } - else { - info->miout = value; - info->caps |= ONLP_PSU_CAPS_IOUT; - } - - memset(node_path, 0, ONLP_NODE_MAX_PATH_LEN); - sprintf(node_path, module_devfiles__[id], "pout"); - ret = onlp_file_read_int(&value, node_path); - if (ret < 0) { - AIM_LOG_ERROR("Unable to read pout from file(%s)\r\n", node_path); - } - else { - info->mpout = value; - info->caps |= ONLP_PSU_CAPS_POUT; - } - - memset(node_path, 0, ONLP_NODE_MAX_PATH_LEN); - sprintf(node_path, module_devfiles__[id], "vin"); - ret = onlp_file_read_int(&value, node_path); - if (ret < 0) { - AIM_LOG_ERROR("Unable to read vin from file(%s)\r\n", node_path); - } - else { - info->mvin = value; - info->caps |= ONLP_PSU_CAPS_VIN; - } - - memset(node_path, 0, ONLP_NODE_MAX_PATH_LEN); - sprintf(node_path, module_devfiles__[id], "iin"); - ret = onlp_file_read_int(&value, node_path); - if (ret < 0) { - AIM_LOG_ERROR("Unable to read iin from file(%s)\r\n", node_path); - } - else { - info->miin = value; - info->caps |= ONLP_PSU_CAPS_IIN; - } - - memset(node_path, 0, ONLP_NODE_MAX_PATH_LEN); - sprintf(node_path, module_devfiles__[id], "pin"); - ret = onlp_file_read_int(&value, node_path); - if (ret < 0) { - AIM_LOG_ERROR("Unable to read pin from file(%s)\r\n", node_path); - } - else { - info->mpin = value; - info->caps |= ONLP_PSU_CAPS_PIN; - } - - psu_module_name_get(id, info); - 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_THERMAL_ID_CREATE(THERMAL_1_ON_PSU1), - ONLP_FAN_ID_CREATE(FAN_1_ON_PSU1) - } - }, - }, - { - { - ONLP_PSU_ID_CREATE(PSU2_ID), "PSU-2", 0, - { - ONLP_THERMAL_ID_CREATE(THERMAL_1_ON_PSU2), - ONLP_FAN_ID_CREATE(FAN_1_ON_PSU2) - } - }, - } -}; - -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 ((ret = psu_status_info_get(index, "psu", &val)) == ONLP_STATUS_E_INTERNAL) { - printf("Unable to read PSU(%d) node(psu)\r\n", index); - return ret; - } - - if (val == 0) { - info->status = ONLP_PSU_STATUS_PRESENT; - } - else - if (val == 1) { - info->status = ONLP_PSU_STATUS_UNPLUGGED; - return ret; - } - else { - info->status = ONLP_PSU_STATUS_FAILED; - return ret; - } - - if ((ret = psu_module_info_get(index, info)) != ONLP_STATUS_OK) { - printf("Unable to read PSU(%d) module information\r\n", index); - } - - return ret; -} diff --git a/packages/platforms/inventec/x86-64/d6254qs/onlp/builds/x86_64_inventec_d6254qs/module/src/sfpi.c b/packages/platforms/inventec/x86-64/d6254qs/onlp/builds/x86_64_inventec_d6254qs/module/src/sfpi.c deleted file mode 100644 index 053b82bc5..000000000 --- a/packages/platforms/inventec/x86-64/d6254qs/onlp/builds/x86_64_inventec_d6254qs/module/src/sfpi.c +++ /dev/null @@ -1,279 +0,0 @@ -/************************************************************ - * sfpi.c - * - * Copyright 2018 Inventec Technology Corporation. - * - ************************************************************ - * - ***********************************************************/ -#include - -#include /* For O_RDWR && open */ -#include -#include -#include -#include -#include -#include -#include "platform_lib.h" - -static char sfp_node_path[ONLP_NODE_MAX_PATH_LEN] = {0}; - -#define NUM_OF_SFP_PORT (CHASSIS_SFP_COUNT) -static const int sfp_mux_index[NUM_OF_SFP_PORT] = { -#ifdef SWPS_CYPRESS_GA1 -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, -50, 51, 52, 53, 54, 55, 56, 57, -58, 59, 60, 61, 62, 63 -#endif -#ifdef SWPS_CYPRESS_GA2 -11, 10, 13, 12, 15, 14, 17, 16, -19, 18, 21, 20, 23, 22, 25, 24, -27, 26, 29, 28, 31, 30, 33, 32, -35, 34, 37, 36, 39, 38, 41, 40, -43, 42, 45, 44, 47, 46, 49, 48, -51, 50, 53, 52, 55, 54, 57, 56, -59, 58, 61, 60, 63, 62 -#endif -#ifdef SWPS_CYPRESS_BAI -11, 10, 13, 12, 15, 14, 17, 16, -19, 18, 21, 20, 23, 22, 25, 24, -27, 26, 29, 28, 31, 30, 33, 32, -35, 34, 37, 36, 39, 38, 41, 40, -43, 42, 45, 44, 47, 46, 49, 48, -51, 50, 53, 52, 55, 54, 57, 56, -59, 58, 61, 60, 63, 62 -#endif -#ifdef SWPS_MAGNOLIA -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, -50, 51, 52, 53, 54, 55, 56, 57, -58, 59, 60, 61, 62, 63, -#endif -}; - -#define FRONT_PORT_TO_MUX_INDEX(port) (sfp_mux_index[port]) - -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/class/swps/port%d/%s", 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, 54} - */ - 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, "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; - } - if (present == 0) { - present = 1; - } - else - if (present == 1) { - present = 0; - } - else { - AIM_LOG_ERROR("Unvalid present status %d from port(%d)\r\n",present,port); - return ONLP_STATUS_E_INTERNAL; - } - return present; -} - -int -onlp_sfpi_presence_bitmap_get(onlp_sfp_bitmap_t* dst) -{ - uint32_t presence_all[2] = {0}; - int port, ret, index; - - for (port = 0, index = 0; port < NUM_OF_SFP_PORT; port++) { - if (port == 32) { - index = 1; - } - - ret = onlp_sfpi_is_present(port); - if (ret == 1) { - presence_all[index] |= (1<>= 1; - } - return ONLP_STATUS_OK; -} - -int -onlp_sfpi_eeprom_read(int port, uint8_t data[256]) -{ -#if 0 - int bus = FRONT_PORT_TO_MUX_INDEX(port); - - memset(data, 0, 256); - /* Read eeprom information into data[] */ - if (onlp_i2c_read(bus, 0x50, 0x00, 256, data, 0) != 0) - { - AIM_LOG_ERROR("Unable to read eeprom from port(%d)\r\n", port); - return ONLP_STATUS_E_INTERNAL; - } -#else - char* path; - 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); - path = sfp_get_port_path(port, "eeprom"); - if (onlp_file_read(&data[0], 256, &len, path) < 0) { - AIM_LOG_ERROR("Unable to read eeprom from port(%d)\r\n", port); - return ONLP_STATUS_E_INTERNAL; - } -#endif - 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_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); - int ret = onlp_i2c_writeb(bus, devaddr, addr, value, ONLP_I2C_F_FORCE); - - if (ret == 0) { - unsigned char buf[8] = { 0 }; - char str[20]; - - buf[port/8] = (1 << port%8); - sprintf(str, "0x%02x%02x%02x%02x%02x%02x%02x%02x", buf[7],buf[6],buf[5],buf[4],buf[3],buf[2],buf[1],buf[0]); - if (onlp_file_write((uint8_t*)str, 20, INV_SFP_EEPROM_UPDATE) < 0) { - AIM_LOG_ERROR("Unable to write eeprom_update for port(%d)\r\n", port); - return ONLP_STATUS_E_INTERNAL; - } - return ONLP_STATUS_OK; - } - AIM_LOG_ERROR("Unable to read eeprom_update from port(%d)\r\n", port); - return ret; -} - -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); - int ret = onlp_i2c_writew(bus, devaddr, addr, value, ONLP_I2C_F_FORCE); - - if (ret == 0) { - unsigned char buf[8] = { 0 }; - char str[20]; - - buf[port/8] = (1 << port%8); - sprintf(str, "0x%02x%02x%02x%02x%02x%02x%02x%02x", buf[7],buf[6],buf[5],buf[4],buf[3],buf[2],buf[1],buf[0]); - if (onlp_file_write((uint8_t*)str, 20, INV_SFP_EEPROM_UPDATE) < 0) { - AIM_LOG_ERROR("Unable to write eeprom_update for port(%d)\r\n", port); - return ONLP_STATUS_E_INTERNAL; - } - return ONLP_STATUS_OK; - } - AIM_LOG_ERROR("Unable to read eeprom_update from port(%d)\r\n", port); - return ret; -} - -int -onlp_sfpi_denit(void) -{ - return ONLP_STATUS_OK; -} diff --git a/packages/platforms/inventec/x86-64/d6254qs/onlp/builds/x86_64_inventec_d6254qs/module/src/sysi.c b/packages/platforms/inventec/x86-64/d6254qs/onlp/builds/x86_64_inventec_d6254qs/module/src/sysi.c deleted file mode 100644 index 578bbef6e..000000000 --- a/packages/platforms/inventec/x86-64/d6254qs/onlp/builds/x86_64_inventec_d6254qs/module/src/sysi.c +++ /dev/null @@ -1,110 +0,0 @@ -/************************************************************ - * sysi.c - * - * Copyright 2018 Inventec Technology Corporation. - * - ************************************************************ - * - ***********************************************************/ -#include -#include - -#include -#include -#include -#include -#include -#include - -#include "x86_64_inventec_d6254qs_int.h" -#include "x86_64_inventec_d6254qs_log.h" - -#include "platform_lib.h" - -#define NUM_OF_CPLD INV_CPLD_COUNT - -#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 (CHASSIS_PSU_COUNT) -#define NUM_OF_LED_ON_MAIN_BROAD (CHASSIS_LED_COUNT) - -const char* -onlp_sysi_platform_get(void) -{ - return "x86-64-inventec-d6254qs-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, EEPROM_NODE(eeprom)) == 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)); - - /* 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; -} - -static char *arr_cplddev_version[NUM_OF_CPLD] = -{ - INV_CPLD_PREFIX"/version", -}; - -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, arr_cplddev_version[i]) < 0) { - return ONLP_STATUS_E_INTERNAL; - } - } - pi->cpld_versions = aim_fstrdup("%d.%d", v[0], v[1]); - return 0; -} - -void -onlp_sysi_platform_info_free(onlp_platform_info_t* pi) -{ - aim_free(pi->cpld_versions); -} diff --git a/packages/platforms/inventec/x86-64/d6254qs/onlp/builds/x86_64_inventec_d6254qs/module/src/thermali.c b/packages/platforms/inventec/x86-64/d6254qs/onlp/builds/x86_64_inventec_d6254qs/module/src/thermali.c deleted file mode 100644 index 64e4094cc..000000000 --- a/packages/platforms/inventec/x86-64/d6254qs/onlp/builds/x86_64_inventec_d6254qs/module/src/thermali.c +++ /dev/null @@ -1,132 +0,0 @@ -/************************************************************ - * thermali.c - * - * Copyright 2018 Inventec Technology Corporation. - * - ************************************************************ - * - * 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) - -static char* devfiles__[THERMAL_MAX] = /* must map with onlp_thermal_id */ -{ - "reserved", - INV_CTMP_PREFIX"/temp2_%s", - INV_CTMP_PREFIX"/temp3_%s", - INV_CTMP_PREFIX"/temp4_%s", - INV_CTMP_PREFIX"/temp5_%s", - INV_PSOC_PREFIX"/temp1_input", - INV_PSOC_PREFIX"/temp2_input", - INV_PSOC_PREFIX"/temp3_input", - INV_PSOC_PREFIX"/temp4_input", - INV_PSOC_PREFIX"/temp5_input", - INV_PSOC_PREFIX"/thermal_psu1", - INV_PSOC_PREFIX"/thermal_psu2", -}; - -/* Static values */ -static onlp_thermal_info_t linfo[THERMAL_MAX] = { - { }, /* Not used */ - { { ONLP_THERMAL_ID_CREATE(THERMAL_CPU_CORE_FIRST), "CPU Core 0", 0}, - ONLP_THERMAL_STATUS_PRESENT, - ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS - }, - { { ONLP_THERMAL_ID_CREATE(THERMAL_CPU_CORE_3), "CPU Core 1", 0}, - ONLP_THERMAL_STATUS_PRESENT, - ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS - }, - { { ONLP_THERMAL_ID_CREATE(THERMAL_CPU_CORE_4), "CPU Core 2", 0}, - ONLP_THERMAL_STATUS_PRESENT, - ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS - }, - { { ONLP_THERMAL_ID_CREATE(THERMAL_CPU_CORE_LAST), "CPU Core 3", 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_3_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_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_FIRST && local_id <= THERMAL_CPU_CORE_LAST) { - char desc[32], *dp = &desc[0]; - int rv = onlp_file_read_str(&dp, devfiles__[local_id], "label"); - if (rv > 0) { - memset (info->hdr.description, 0, ONLP_OID_DESC_SIZE); - aim_strlcpy(info->hdr.description, dp, rv); - } - - /* Set the onlp_oid_hdr_t and capabilities */ - return onlp_file_read_int(&info->mcelsius, devfiles__[local_id], "input"); - } - return onlp_file_read_int(&info->mcelsius, devfiles__[local_id]); -} diff --git a/packages/platforms/inventec/x86-64/d6254qs/onlp/builds/x86_64_inventec_d6254qs/module/src/x86_64_inventec_d6254qs_config.c b/packages/platforms/inventec/x86-64/d6254qs/onlp/builds/x86_64_inventec_d6254qs/module/src/x86_64_inventec_d6254qs_config.c deleted file mode 100644 index 58e94e409..000000000 --- a/packages/platforms/inventec/x86-64/d6254qs/onlp/builds/x86_64_inventec_d6254qs/module/src/x86_64_inventec_d6254qs_config.c +++ /dev/null @@ -1,81 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#include - -/* */ -#define __x86_64_inventec_d6254qs_config_STRINGIFY_NAME(_x) #_x -#define __x86_64_inventec_d6254qs_config_STRINGIFY_VALUE(_x) __x86_64_inventec_d6254qs_config_STRINGIFY_NAME(_x) -x86_64_inventec_d6254qs_config_settings_t x86_64_inventec_d6254qs_config_settings[] = -{ -#ifdef X86_64_INVENTEC_D6254QS_CONFIG_INCLUDE_LOGGING - { __x86_64_inventec_d6254qs_config_STRINGIFY_NAME(X86_64_INVENTEC_D6254QS_CONFIG_INCLUDE_LOGGING), __x86_64_inventec_d6254qs_config_STRINGIFY_VALUE(X86_64_INVENTEC_D6254QS_CONFIG_INCLUDE_LOGGING) }, -#else -{ X86_64_INVENTEC_D6254QS_CONFIG_INCLUDE_LOGGING(__x86_64_inventec_d6254qs_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_INVENTEC_D6254QS_CONFIG_LOG_OPTIONS_DEFAULT - { __x86_64_inventec_d6254qs_config_STRINGIFY_NAME(X86_64_INVENTEC_D6254QS_CONFIG_LOG_OPTIONS_DEFAULT), __x86_64_inventec_d6254qs_config_STRINGIFY_VALUE(X86_64_INVENTEC_D6254QS_CONFIG_LOG_OPTIONS_DEFAULT) }, -#else -{ X86_64_INVENTEC_D6254QS_CONFIG_LOG_OPTIONS_DEFAULT(__x86_64_inventec_d6254qs_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_INVENTEC_D6254QS_CONFIG_LOG_BITS_DEFAULT - { __x86_64_inventec_d6254qs_config_STRINGIFY_NAME(X86_64_INVENTEC_D6254QS_CONFIG_LOG_BITS_DEFAULT), __x86_64_inventec_d6254qs_config_STRINGIFY_VALUE(X86_64_INVENTEC_D6254QS_CONFIG_LOG_BITS_DEFAULT) }, -#else -{ X86_64_INVENTEC_D6254QS_CONFIG_LOG_BITS_DEFAULT(__x86_64_inventec_d6254qs_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_INVENTEC_D6254QS_CONFIG_LOG_CUSTOM_BITS_DEFAULT - { __x86_64_inventec_d6254qs_config_STRINGIFY_NAME(X86_64_INVENTEC_D6254QS_CONFIG_LOG_CUSTOM_BITS_DEFAULT), __x86_64_inventec_d6254qs_config_STRINGIFY_VALUE(X86_64_INVENTEC_D6254QS_CONFIG_LOG_CUSTOM_BITS_DEFAULT) }, -#else -{ X86_64_INVENTEC_D6254QS_CONFIG_LOG_CUSTOM_BITS_DEFAULT(__x86_64_inventec_d6254qs_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_INVENTEC_D6254QS_CONFIG_PORTING_STDLIB - { __x86_64_inventec_d6254qs_config_STRINGIFY_NAME(X86_64_INVENTEC_D6254QS_CONFIG_PORTING_STDLIB), __x86_64_inventec_d6254qs_config_STRINGIFY_VALUE(X86_64_INVENTEC_D6254QS_CONFIG_PORTING_STDLIB) }, -#else -{ X86_64_INVENTEC_D6254QS_CONFIG_PORTING_STDLIB(__x86_64_inventec_d6254qs_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_INVENTEC_D6254QS_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS - { __x86_64_inventec_d6254qs_config_STRINGIFY_NAME(X86_64_INVENTEC_D6254QS_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS), __x86_64_inventec_d6254qs_config_STRINGIFY_VALUE(X86_64_INVENTEC_D6254QS_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS) }, -#else -{ X86_64_INVENTEC_D6254QS_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS(__x86_64_inventec_d6254qs_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_INVENTEC_D6254QS_CONFIG_INCLUDE_UCLI - { __x86_64_inventec_d6254qs_config_STRINGIFY_NAME(X86_64_INVENTEC_D6254QS_CONFIG_INCLUDE_UCLI), __x86_64_inventec_d6254qs_config_STRINGIFY_VALUE(X86_64_INVENTEC_D6254QS_CONFIG_INCLUDE_UCLI) }, -#else -{ X86_64_INVENTEC_D6254QS_CONFIG_INCLUDE_UCLI(__x86_64_inventec_d6254qs_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_INVENTEC_D6254QS_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION - { __x86_64_inventec_d6254qs_config_STRINGIFY_NAME(X86_64_INVENTEC_D6254QS_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION), __x86_64_inventec_d6254qs_config_STRINGIFY_VALUE(X86_64_INVENTEC_D6254QS_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION) }, -#else -{ X86_64_INVENTEC_D6254QS_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION(__x86_64_inventec_d6254qs_config_STRINGIFY_NAME), "__undefined__" }, -#endif - { NULL, NULL } -}; -#undef __x86_64_inventec_d6254qs_config_STRINGIFY_VALUE -#undef __x86_64_inventec_d6254qs_config_STRINGIFY_NAME - -const char* -x86_64_inventec_d6254qs_config_lookup(const char* setting) -{ - int i; - for(i = 0; x86_64_inventec_d6254qs_config_settings[i].name; i++) { - if(!strcmp(x86_64_inventec_d6254qs_config_settings[i].name, setting)) { - return x86_64_inventec_d6254qs_config_settings[i].value; - } - } - return NULL; -} - -int -x86_64_inventec_d6254qs_config_show(struct aim_pvs_s* pvs) -{ - int i; - for(i = 0; x86_64_inventec_d6254qs_config_settings[i].name; i++) { - aim_printf(pvs, "%s = %s\n", x86_64_inventec_d6254qs_config_settings[i].name, x86_64_inventec_d6254qs_config_settings[i].value); - } - return i; -} - -/* */ - diff --git a/packages/platforms/inventec/x86-64/d6254qs/onlp/builds/x86_64_inventec_d6254qs/module/src/x86_64_inventec_d6254qs_enums.c b/packages/platforms/inventec/x86-64/d6254qs/onlp/builds/x86_64_inventec_d6254qs/module/src/x86_64_inventec_d6254qs_enums.c deleted file mode 100644 index a58319537..000000000 --- a/packages/platforms/inventec/x86-64/d6254qs/onlp/builds/x86_64_inventec_d6254qs/module/src/x86_64_inventec_d6254qs_enums.c +++ /dev/null @@ -1,10 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#include - -/* <--auto.start.enum(ALL).source> */ -/* */ - diff --git a/packages/platforms/inventec/x86-64/d6254qs/onlp/builds/x86_64_inventec_d6254qs/module/src/x86_64_inventec_d6254qs_int.h b/packages/platforms/inventec/x86-64/d6254qs/onlp/builds/x86_64_inventec_d6254qs/module/src/x86_64_inventec_d6254qs_int.h deleted file mode 100644 index b6dfd9c68..000000000 --- a/packages/platforms/inventec/x86-64/d6254qs/onlp/builds/x86_64_inventec_d6254qs/module/src/x86_64_inventec_d6254qs_int.h +++ /dev/null @@ -1,12 +0,0 @@ -/**************************************************************************//** - * - * x86_64_inventec_d6254qs Internal Header - * - *****************************************************************************/ -#ifndef __x86_64_inventec_d6254qs_INT_H__ -#define __x86_64_inventec_d6254qs_INT_H__ - -#include - - -#endif /* __x86_64_inventec_d6254qs_INT_H__ */ diff --git a/packages/platforms/inventec/x86-64/d6254qs/onlp/builds/x86_64_inventec_d6254qs/module/src/x86_64_inventec_d6254qs_log.c b/packages/platforms/inventec/x86-64/d6254qs/onlp/builds/x86_64_inventec_d6254qs/module/src/x86_64_inventec_d6254qs_log.c deleted file mode 100644 index f96d74eea..000000000 --- a/packages/platforms/inventec/x86-64/d6254qs/onlp/builds/x86_64_inventec_d6254qs/module/src/x86_64_inventec_d6254qs_log.c +++ /dev/null @@ -1,17 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#include - -#include "x86_64_inventec_d6254qs_log.h" -/* - * x86_64_inventec_d6254qs log struct. - */ -AIM_LOG_STRUCT_DEFINE( - X86_64_INVENTEC_D6254QS_CONFIG_LOG_OPTIONS_DEFAULT, - X86_64_INVENTEC_D6254QS_CONFIG_LOG_BITS_DEFAULT, - NULL, /* Custom log map */ - X86_64_INVENTEC_D6254QS_CONFIG_LOG_CUSTOM_BITS_DEFAULT - ); diff --git a/packages/platforms/inventec/x86-64/d6254qs/onlp/builds/x86_64_inventec_d6254qs/module/src/x86_64_inventec_d6254qs_log.h b/packages/platforms/inventec/x86-64/d6254qs/onlp/builds/x86_64_inventec_d6254qs/module/src/x86_64_inventec_d6254qs_log.h deleted file mode 100644 index 299afb96b..000000000 --- a/packages/platforms/inventec/x86-64/d6254qs/onlp/builds/x86_64_inventec_d6254qs/module/src/x86_64_inventec_d6254qs_log.h +++ /dev/null @@ -1,12 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#ifndef __x86_64_inventec_d6254qs_LOG_H__ -#define __x86_64_inventec_d6254qs_LOG_H__ - -#define AIM_LOG_MODULE_NAME x86_64_inventec_d6254qs -#include - -#endif /* __x86_64_inventec_d6254qs_LOG_H__ */ diff --git a/packages/platforms/inventec/x86-64/d6254qs/onlp/builds/x86_64_inventec_d6254qs/module/src/x86_64_inventec_d6254qs_module.c b/packages/platforms/inventec/x86-64/d6254qs/onlp/builds/x86_64_inventec_d6254qs/module/src/x86_64_inventec_d6254qs_module.c deleted file mode 100644 index a4e26c3d3..000000000 --- a/packages/platforms/inventec/x86-64/d6254qs/onlp/builds/x86_64_inventec_d6254qs/module/src/x86_64_inventec_d6254qs_module.c +++ /dev/null @@ -1,24 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#include - -#include "x86_64_inventec_d6254qs_log.h" - -static int -datatypes_init__(void) -{ -#define x86_64_inventec_d6254qs_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_d6254qs_module_init__(void) -{ - AIM_LOG_STRUCT_REGISTER(); - datatypes_init__(); -} - -int __onlp_platform_version__ = 1; diff --git a/packages/platforms/inventec/x86-64/d6254qs/onlp/builds/x86_64_inventec_d6254qs/module/src/x86_64_inventec_d6254qs_ucli.c b/packages/platforms/inventec/x86-64/d6254qs/onlp/builds/x86_64_inventec_d6254qs/module/src/x86_64_inventec_d6254qs_ucli.c deleted file mode 100644 index 10626fc8e..000000000 --- a/packages/platforms/inventec/x86-64/d6254qs/onlp/builds/x86_64_inventec_d6254qs/module/src/x86_64_inventec_d6254qs_ucli.c +++ /dev/null @@ -1,50 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#include - -#if x86_64_inventec_d6254qs_CONFIG_INCLUDE_UCLI == 1 - -#include -#include -#include - -static ucli_status_t -x86_64_inventec_d6254qs_ucli_ucli__config__(ucli_context_t* uc) -{ - UCLI_HANDLER_MACRO_MODULE_CONFIG(x86_64_inventec_d6254qs) -} - -/* */ -/* */ - -static ucli_module_t -x86_64_inventec_d6254qs_ucli_module__ = - { - "x86_64_inventec_d6254qs_ucli", - NULL, - x86_64_inventec_d6254qs_ucli_ucli_handlers__, - NULL, - NULL, - }; - -ucli_node_t* -x86_64_inventec_d6254qs_ucli_node_create(void) -{ - ucli_node_t* n; - ucli_module_init(&x86_64_inventec_d6254qs_ucli_module__); - n = ucli_node_create("x86_64_inventec_d6254qs", NULL, &x86_64_inventec_d6254qs_ucli_module__); - ucli_node_subnode_add(n, ucli_module_log_node_create("x86_64_inventec_d6254qs")); - return n; -} - -#else -void* -x86_64_inventec_d6254qs_ucli_node_create(void) -{ - return NULL; -} -#endif - diff --git a/packages/platforms/inventec/x86-64/d6254qs/platform-config/Makefile b/packages/platforms/inventec/x86-64/d6254qs/platform-config/Makefile deleted file mode 100644 index 003238cf6..000000000 --- a/packages/platforms/inventec/x86-64/d6254qs/platform-config/Makefile +++ /dev/null @@ -1 +0,0 @@ -include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/inventec/x86-64/d6254qs/platform-config/r0/Makefile b/packages/platforms/inventec/x86-64/d6254qs/platform-config/r0/Makefile deleted file mode 100644 index 003238cf6..000000000 --- a/packages/platforms/inventec/x86-64/d6254qs/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/inventec/x86-64/d6254qs/platform-config/r0/PKG.yml b/packages/platforms/inventec/x86-64/d6254qs/platform-config/r0/PKG.yml deleted file mode 100644 index 463c8da8d..000000000 --- a/packages/platforms/inventec/x86-64/d6254qs/platform-config/r0/PKG.yml +++ /dev/null @@ -1 +0,0 @@ -!include $ONL_TEMPLATES/platform-config-platform.yml ARCH=amd64 VENDOR=inventec BASENAME=x86-64-inventec-d6254qs REVISION=r0 diff --git a/packages/platforms/inventec/x86-64/d6254qs/platform-config/r0/src/lib/x86-64-inventec-d6254qs-r0.yml b/packages/platforms/inventec/x86-64/d6254qs/platform-config/r0/src/lib/x86-64-inventec-d6254qs-r0.yml deleted file mode 100644 index 94bed6c59..000000000 --- a/packages/platforms/inventec/x86-64/d6254qs/platform-config/r0/src/lib/x86-64-inventec-d6254qs-r0.yml +++ /dev/null @@ -1,31 +0,0 @@ ---- - -###################################################################### -# -# platform-config for d6254qs -# -###################################################################### - -x86-64-inventec-d6254qs-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/d6254qs/platform-config/r0/src/python/x86_64_inventec_d6254qs_r0/__init__.py b/packages/platforms/inventec/x86-64/d6254qs/platform-config/r0/src/python/x86_64_inventec_d6254qs_r0/__init__.py deleted file mode 100644 index 0a18d8154..000000000 --- a/packages/platforms/inventec/x86-64/d6254qs/platform-config/r0/src/python/x86_64_inventec_d6254qs_r0/__init__.py +++ /dev/null @@ -1,21 +0,0 @@ -from onl.platform.base import * -from onl.platform.inventec import * - -class OnlPlatform_x86_64_inventec_d6254qs_r0(OnlPlatformInventec, - OnlPlatformPortConfig_48x10_6x40): - PLATFORM='x86-64-inventec-d6254qs-r0' - MODEL="X86-D6254QS" - SYS_OBJECT_ID=".6254.1" - - def baseconfig(self): - #os.system("insmod /lib/modules/`uname -r`/kernel/drivers/gpio/gpio-ich.ko") - self.insmod('gpio-ich.ko') - self.insmod('inv_platform') - self.insmod('inv_psoc') - self.insmod('inv_cpld') - self.new_i2c_device('inv_eeprom', 0x53, 0) - self.insmod('inv_eeprom') - self.insmod('swps') - #self.insmod('vpd') - #self.insmod('inv_pthread') - return True diff --git a/packages/platforms/inventec/x86-64/d6332/.gitignore b/packages/platforms/inventec/x86-64/d6332/.gitignore deleted file mode 100644 index ea5416bfd..000000000 --- a/packages/platforms/inventec/x86-64/d6332/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -*x86*64*inventec*d6332*.mk -onlpdump.mk diff --git a/packages/platforms/inventec/x86-64/d6332/Makefile b/packages/platforms/inventec/x86-64/d6332/Makefile deleted file mode 100644 index 003238cf6..000000000 --- a/packages/platforms/inventec/x86-64/d6332/Makefile +++ /dev/null @@ -1 +0,0 @@ -include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/inventec/x86-64/d6332/modules/Makefile b/packages/platforms/inventec/x86-64/d6332/modules/Makefile deleted file mode 100644 index 003238cf6..000000000 --- a/packages/platforms/inventec/x86-64/d6332/modules/Makefile +++ /dev/null @@ -1 +0,0 @@ -include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/inventec/x86-64/d6332/modules/PKG.yml b/packages/platforms/inventec/x86-64/d6332/modules/PKG.yml deleted file mode 100644 index 6a2026613..000000000 --- a/packages/platforms/inventec/x86-64/d6332/modules/PKG.yml +++ /dev/null @@ -1 +0,0 @@ -!include $ONL_TEMPLATES/platform-modules.yml VENDOR=inventec BASENAME=x86-64-inventec-d6332 ARCH=amd64 KERNELS="onl-kernel-3.16-lts-x86-64-all:amd64" diff --git a/packages/platforms/inventec/x86-64/d6332/modules/builds/.gitignore b/packages/platforms/inventec/x86-64/d6332/modules/builds/.gitignore deleted file mode 100644 index a65b41774..000000000 --- a/packages/platforms/inventec/x86-64/d6332/modules/builds/.gitignore +++ /dev/null @@ -1 +0,0 @@ -lib diff --git a/packages/platforms/inventec/x86-64/d6332/modules/builds/Makefile b/packages/platforms/inventec/x86-64/d6332/modules/builds/Makefile deleted file mode 100644 index a18c34421..000000000 --- a/packages/platforms/inventec/x86-64/d6332/modules/builds/Makefile +++ /dev/null @@ -1,6 +0,0 @@ -KERNELS := onl-kernel-3.16-lts-x86-64-all:amd64 -KMODULES := src -VENDOR := inventec -BASENAME := x86-64-inventec-d6332 -ARCH := x86_64 -include $(ONL)/make/kmodule.mk diff --git a/packages/platforms/inventec/x86-64/d6332/modules/builds/src/Makefile b/packages/platforms/inventec/x86-64/d6332/modules/builds/src/Makefile deleted file mode 100644 index 8692a54db..000000000 --- a/packages/platforms/inventec/x86-64/d6332/modules/builds/src/Makefile +++ /dev/null @@ -1,7 +0,0 @@ -obj-m += ucd9000.o -obj-m += i2c-gpio.o -obj-m += inv_cpld.o -obj-m += inv_platform.o -obj-m += inv_eeprom.o -obj-m += swps.o -swps-objs := inv_swps.o io_expander.o inv_mux.o transceiver.o diff --git a/packages/platforms/inventec/x86-64/d6332/modules/builds/src/i2c-gpio.c b/packages/platforms/inventec/x86-64/d6332/modules/builds/src/i2c-gpio.c deleted file mode 100644 index 34cfc0ebd..000000000 --- a/packages/platforms/inventec/x86-64/d6332/modules/builds/src/i2c-gpio.c +++ /dev/null @@ -1,290 +0,0 @@ -/* - * Bitbanging I2C bus driver using the GPIO API - * - * Copyright (C) 2007 Atmel Corporation - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. - */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -struct i2c_gpio_private_data { - struct i2c_adapter adap; - struct i2c_algo_bit_data bit_data; - struct i2c_gpio_platform_data pdata; -}; - -/* Toggle SDA by changing the direction of the pin */ -static void i2c_gpio_setsda_dir(void *data, int state) -{ - struct i2c_gpio_platform_data *pdata = data; - - if (state) - gpio_direction_input(pdata->sda_pin); - else - gpio_direction_output(pdata->sda_pin, 0); -} - -/* - * Toggle SDA by changing the output value of the pin. This is only - * valid for pins configured as open drain (i.e. setting the value - * high effectively turns off the output driver.) - */ -static void i2c_gpio_setsda_val(void *data, int state) -{ - struct i2c_gpio_platform_data *pdata = data; - - gpio_set_value(pdata->sda_pin, state); -} - -/* Toggle SCL by changing the direction of the pin. */ -static void i2c_gpio_setscl_dir(void *data, int state) -{ - struct i2c_gpio_platform_data *pdata = data; - - if (state) - gpio_direction_input(pdata->scl_pin); - else - gpio_direction_output(pdata->scl_pin, 0); -} - -/* - * Toggle SCL by changing the output value of the pin. This is used - * for pins that are configured as open drain and for output-only - * pins. The latter case will break the i2c protocol, but it will - * often work in practice. - */ -static void i2c_gpio_setscl_val(void *data, int state) -{ - struct i2c_gpio_platform_data *pdata = data; - - gpio_set_value(pdata->scl_pin, state); -} - -static int i2c_gpio_getsda(void *data) -{ - struct i2c_gpio_platform_data *pdata = data; - - return gpio_get_value(pdata->sda_pin); -} - -static int i2c_gpio_getscl(void *data) -{ - struct i2c_gpio_platform_data *pdata = data; - - return gpio_get_value(pdata->scl_pin); -} - -static int of_i2c_gpio_get_pins(struct device_node *np, - unsigned int *sda_pin, unsigned int *scl_pin) -{ - if (of_gpio_count(np) < 2) - return -ENODEV; - - *sda_pin = of_get_gpio(np, 0); - *scl_pin = of_get_gpio(np, 1); - - if (*sda_pin == -EPROBE_DEFER || *scl_pin == -EPROBE_DEFER) - return -EPROBE_DEFER; - - if (!gpio_is_valid(*sda_pin) || !gpio_is_valid(*scl_pin)) { - pr_err("%s: invalid GPIO pins, sda=%d/scl=%d\n", - np->full_name, *sda_pin, *scl_pin); - return -ENODEV; - } - - return 0; -} - -static void of_i2c_gpio_get_props(struct device_node *np, - struct i2c_gpio_platform_data *pdata) -{ - u32 reg; - - of_property_read_u32(np, "i2c-gpio,delay-us", &pdata->udelay); - - if (!of_property_read_u32(np, "i2c-gpio,timeout-ms", ®)) - pdata->timeout = msecs_to_jiffies(reg); - - pdata->sda_is_open_drain = - of_property_read_bool(np, "i2c-gpio,sda-open-drain"); - pdata->scl_is_open_drain = - of_property_read_bool(np, "i2c-gpio,scl-open-drain"); - pdata->scl_is_output_only = - of_property_read_bool(np, "i2c-gpio,scl-output-only"); -} - -static int i2c_gpio_probe(struct platform_device *pdev) -{ - struct i2c_gpio_private_data *priv; - struct i2c_gpio_platform_data *pdata; - struct i2c_algo_bit_data *bit_data; - struct i2c_adapter *adap; - unsigned int sda_pin, scl_pin; - int ret; - - /* First get the GPIO pins; if it fails, we'll defer the probe. */ - if (pdev->dev.of_node) { - ret = of_i2c_gpio_get_pins(pdev->dev.of_node, - &sda_pin, &scl_pin); - if (ret) - return ret; - } else { - if (!dev_get_platdata(&pdev->dev)) - return -ENXIO; - pdata = dev_get_platdata(&pdev->dev); - sda_pin = pdata->sda_pin; - scl_pin = pdata->scl_pin; - } - - ret = devm_gpio_request(&pdev->dev, sda_pin, "sda"); - if (ret) { - if (ret == -EINVAL) - ret = -EPROBE_DEFER; /* Try again later */ - return ret; - } - ret = devm_gpio_request(&pdev->dev, scl_pin, "scl"); - if (ret) { - if (ret == -EINVAL) - ret = -EPROBE_DEFER; /* Try again later */ - return ret; - } - - priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL); - if (!priv) - return -ENOMEM; - adap = &priv->adap; - bit_data = &priv->bit_data; - pdata = &priv->pdata; - - if (pdev->dev.of_node) { - pdata->sda_pin = sda_pin; - pdata->scl_pin = scl_pin; - of_i2c_gpio_get_props(pdev->dev.of_node, pdata); - } else { - memcpy(pdata, dev_get_platdata(&pdev->dev), sizeof(*pdata)); - } - - if (pdata->sda_is_open_drain) { - gpio_direction_output(pdata->sda_pin, 1); - bit_data->setsda = i2c_gpio_setsda_val; - } else { - gpio_direction_input(pdata->sda_pin); - bit_data->setsda = i2c_gpio_setsda_dir; - } - - if (pdata->scl_is_open_drain || pdata->scl_is_output_only) { - gpio_direction_output(pdata->scl_pin, 1); - bit_data->setscl = i2c_gpio_setscl_val; - } else { - gpio_direction_input(pdata->scl_pin); - bit_data->setscl = i2c_gpio_setscl_dir; - } - - if (!pdata->scl_is_output_only) - bit_data->getscl = i2c_gpio_getscl; - bit_data->getsda = i2c_gpio_getsda; - - if (pdata->udelay) - bit_data->udelay = pdata->udelay; - else if (pdata->scl_is_output_only) - bit_data->udelay = 50; /* 10 kHz */ - else - bit_data->udelay = 5; /* 100 kHz */ - - if (pdata->timeout) - bit_data->timeout = pdata->timeout; - else - bit_data->timeout = HZ / 10; /* 100 ms */ - - bit_data->data = pdata; - - adap->owner = THIS_MODULE; - if (pdev->dev.of_node) - strlcpy(adap->name, dev_name(&pdev->dev), sizeof(adap->name)); - else - snprintf(adap->name, sizeof(adap->name), "i2c-gpio%d", pdev->id); - - adap->algo_data = bit_data; - adap->class = I2C_CLASS_HWMON | I2C_CLASS_SPD; - adap->dev.parent = &pdev->dev; - adap->dev.of_node = pdev->dev.of_node; - - adap->nr = pdev->id; - ret = i2c_bit_add_numbered_bus(adap); - if (ret) - return ret; - - platform_set_drvdata(pdev, priv); - - dev_info(&pdev->dev, "using pins %u (SDA) and %u (SCL%s)\n", - pdata->sda_pin, pdata->scl_pin, - pdata->scl_is_output_only - ? ", no clock stretching" : ""); - - return 0; -} - -static int i2c_gpio_remove(struct platform_device *pdev) -{ - struct i2c_gpio_private_data *priv; - struct i2c_adapter *adap; - - priv = platform_get_drvdata(pdev); - adap = &priv->adap; - - i2c_del_adapter(adap); - - return 0; -} - -#if defined(CONFIG_OF) -static const struct of_device_id i2c_gpio_dt_ids[] = { - { .compatible = "i2c-gpio", }, - { /* sentinel */ } -}; - -MODULE_DEVICE_TABLE(of, i2c_gpio_dt_ids); -#endif - -static struct platform_driver i2c_gpio_driver = { - .driver = { - .name = "i2c-gpio", - .of_match_table = of_match_ptr(i2c_gpio_dt_ids), - }, - .probe = i2c_gpio_probe, - .remove = i2c_gpio_remove, -}; - -static int __init i2c_gpio_init(void) -{ - int ret; - - ret = platform_driver_register(&i2c_gpio_driver); - if (ret) - printk(KERN_ERR "i2c-gpio: probe failed: %d\n", ret); - - return ret; -} -subsys_initcall(i2c_gpio_init); - -static void __exit i2c_gpio_exit(void) -{ - platform_driver_unregister(&i2c_gpio_driver); -} -module_exit(i2c_gpio_exit); - -MODULE_AUTHOR("Haavard Skinnemoen (Atmel)"); -MODULE_DESCRIPTION("Platform-independent bitbanging I2C driver"); -MODULE_LICENSE("GPL"); -MODULE_ALIAS("platform:i2c-gpio"); diff --git a/packages/platforms/inventec/x86-64/d6332/modules/builds/src/inv_cpld.c b/packages/platforms/inventec/x86-64/d6332/modules/builds/src/inv_cpld.c deleted file mode 100644 index 235f63c87..000000000 --- a/packages/platforms/inventec/x86-64/d6332/modules/builds/src/inv_cpld.c +++ /dev/null @@ -1,1571 +0,0 @@ -/* - * 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 -#include -#include -#include -#include -#include -#include - -#define USE_SMBUS 1 -#define CPLD_POLLING_PERIOD 1000 -#define ENABLE_SIMULATE 0 -#define ENABLE_AUTOFAN 1 - -#define CPLD2_ADDRESS 0x33 -static struct i2c_client *client2; -static u8 hasCPLD2 = 1; - -#if ENABLE_SIMULATE - u8 sim_register[0x90]; -#endif - -/* definition */ -#define CPLD_INFO_OFFSET 0x00 -#define CPLD_BIOSCS_OFFSET 0x04 -#define CPLD_CTL_OFFSET 0x0C -#define CPLD_LED_OFFSET 0x2E -#define CPLD_INT_OFFSET 0x30 -#define CPLD_INTMASK_OFFSET 0x31 -#define CPLD_INT2_OFFSET 0x32 -#define CPLD_INTMASK2_OFFSET 0x33 -#define CPLD_PSU_OFFSET 0x40 -#define CPLD_POWERSTATUS_OFFSET 0x41 -#define CPLD_PWM_OFFSET 0x50 -#define CPLD_RPM_OFFSET 0x55 -#define CPLD_FANSTATUS_OFFSET 0x69 -#define CPLD_FANLED_OFFSET 0x6B -#define CPLD_RESETBUTTONSTATUS_OFFSET 0x75 -#define CPLD_RSTCAUSE_OFFSET 0x76 -#define CPLD_WATCHDOGCOUNTER_OFFSET 0x77 -#define CPLD_WATCHDOGCONFIG_OFFSET 0x78 -#define CPLD_WATCHDOGENABLE_OFFSET 0x79 -#define CPLD_PANICCODE_OFFSET 0x7E -#define FAN_NUM 5 -#define PWM_MIN 30 -#define PWM_DEFAULT 150 - -/* Each client has this additional data */ -struct cpld_data { - struct device *hwmon_dev; - struct mutex update_lock; - struct task_struct *cpld_thread; - u8 diag; - u8 model; - u8 fan_direction; - u8 operation_command; - u8 stack_mode; -}; - -/*-----------------------------------------------------------------------*/ -static ssize_t cpld_i2c_read(struct i2c_client *client, u8 *buf, u8 offset, size_t count) -{ -#if ENABLE_SIMULATE - memcpy(buf,&sim_register[offset],count); - return count; -#else -#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 -#endif -} - -static ssize_t cpld_i2c_write(struct i2c_client *client, char *buf, unsigned offset, size_t count) -{ -#if ENABLE_SIMULATE - memcpy(&sim_register[offset],buf,count); - return count; -#else -#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 -#endif -} - -/*-----------------------------------------------------------------------*/ -/* sysfs attributes for hwmon */ - -static char* model_str[] = { - "10GBaseT", //0 - "SFP", //1 -}; - -static char* fandirection_str[] = { - "Rear-to-Front", //0 - "Front-to-Rear", //1 -}; - -static ssize_t show_info(struct device *dev, struct device_attribute *da, - char *buf) -{ - struct i2c_client *client = to_i2c_client(dev); - struct cpld_data *data = i2c_get_clientdata(client); - u8 byte[4] = {0,0,0,0}; - - mutex_lock(&data->update_lock); - cpld_i2c_read(client, byte, CPLD_INFO_OFFSET, 4); - mutex_unlock(&data->update_lock); - - sprintf (buf, "The CPLD release date is %02d/%02d/%d.\n", - byte[2] & 0xf, (byte[3] & 0x1f), 2014+(byte[2] >> 4)); /* mm/dd/yyyy*/ - sprintf (buf, "%sThe Model is %s %s\n", buf, model_str[(byte[0]>>5) & 0x01],fandirection_str[(byte[0]>>7) & 0x01]); - sprintf (buf, "%sThe PCB version is %X\n", buf, byte[0]&0xf); - sprintf (buf, "%sThe CPLD version is %d.%d\n", buf, byte[1]>>4, byte[1]&0xf); - - if(hasCPLD2) { - mutex_lock(&data->update_lock); - cpld_i2c_read(client2, byte, CPLD_INFO_OFFSET, 4); - mutex_unlock(&data->update_lock); - - sprintf (buf, "%s\nThe CPLD2 release date is %02d/%02d/%d.\n", buf, - byte[2] & 0xf, (byte[3] & 0x1f), 2014+(byte[2] >> 4)); /* mm/dd/yyyy*/ - sprintf (buf, "%sThe CPLD2 version is %d.%d\n", buf, byte[1]>>4, byte[1]&0xf); - } - - return strlen(buf); -} - -static char* powerstatus_str[] = { - "Failed", //0 - "Good", //1 -}; - -static ssize_t show_powerstatus(struct device *dev, struct device_attribute *da, - char *buf) -{ - struct i2c_client *client = to_i2c_client(dev); - struct cpld_data *data = i2c_get_clientdata(client); - u8 byte[2] = {0,0}; - - mutex_lock(&data->update_lock); - cpld_i2c_read(client2, byte, CPLD_POWERSTATUS_OFFSET, 2); - mutex_unlock(&data->update_lock); - - sprintf (buf, "PGD_P5V: %s\n", powerstatus_str[(byte[0]>>7) & 0x01]); - sprintf (buf, "%sPGD_P3V3_STBY: %s\n", buf, powerstatus_str[(byte[0]>>6) & 0x01]); - //if(data->model==0) sprintf (buf, "%sPGD_P1V88: %s\n", buf, powerstatus_str[(byte[0]>>5) & 0x01]); - sprintf (buf, "%sPGD_P1V8_A: %s\n", buf, powerstatus_str[(byte[0]>>4) & 0x01]); - sprintf (buf, "%sPGD_P3V3_SYS: %s\n", buf, powerstatus_str[(byte[0]>>3) & 0x01]); - sprintf (buf, "%sPGD_P3V3_A: %s\n", buf, powerstatus_str[(byte[0]>>2) & 0x01]); - sprintf (buf, "%sPGD_P3V3_B: %s\n", buf, powerstatus_str[(byte[0]>>1) & 0x01]); - sprintf (buf, "%sPGD_P1V2: %s\n", buf, powerstatus_str[(byte[0]>>0) & 0x01]); - sprintf (buf, "%sPGD_P0V8_A: %s\n", buf,powerstatus_str[(byte[1]>>7) & 0x01]); - sprintf (buf, "%sPGD_P0V89_ROV: %s\n", buf, powerstatus_str[(byte[1]>>6) & 0x01]); - //if(data->model==0) sprintf (buf, "%sPGD_P1V0_A: %s\n", buf, powerstatus_str[(byte[1]>>5) & 0x01]); - //if(data->model==0) sprintf (buf, "%sPGD_P1V0_B: %s\n", buf, powerstatus_str[(byte[1]>>4) & 0x01]); - sprintf (buf, "%sSW_PWR_READY: %s\n", buf, powerstatus_str[(byte[1]>>3) & 0x01]); - //sprintf (buf, "%sCORE_PWRGD_TO_CPLD: %s\n", buf, powerstatus_str[(byte[1]>>2) & 0x01]); - //sprintf (buf, "%sCPU_STBY_PWROK: %s\n", buf, powerstatus_str[(byte[1]>>1) & 0x01]); - sprintf (buf, "%sPGD_P1V8_A_STBY: %s\n", buf, powerstatus_str[(byte[1]>>0) & 0x01]); - - return strlen(buf); -} - -static ssize_t show_diag(struct device *dev, struct device_attribute *da, - char *buf) -{ - struct i2c_client *client = to_i2c_client(dev); - struct cpld_data *data = i2c_get_clientdata(client); - return sprintf (buf, "%d\n", data->diag); -} - -static ssize_t set_diag(struct device *dev, - struct device_attribute *da, - const char *buf, size_t count) -{ - struct i2c_client *client = to_i2c_client(dev); - struct cpld_data *data = i2c_get_clientdata(client); - u8 diag = simple_strtol(buf, NULL, 10); - data->diag = diag?1:0; - return count; -} - -static char* stackmode_str[] = { - "Non-Stack member", //0 - "Stack Master", //1 - "Stack Backup/Member", //2 - "Stack Error", //3 -}; - -static ssize_t show_stackmode(struct device *dev, struct device_attribute *da, - char *buf) -{ - struct i2c_client *client = to_i2c_client(dev); - struct cpld_data *data = i2c_get_clientdata(client); - return sprintf (buf, "%d: %s\n", data->stack_mode,stackmode_str[data->stack_mode]); -} - -static ssize_t set_stackmode(struct device *dev, - struct device_attribute *da, - const char *buf, size_t count) -{ - struct i2c_client *client = to_i2c_client(dev); - struct cpld_data *data = i2c_get_clientdata(client); - u8 stackmode = simple_strtol(buf, NULL, 10); - - if(stackmode<4) data->stack_mode = stackmode; - - return count; -} - -static char* resetbutton_str[] = { - "No press", //0 - "Reserved", //1 - "Press and hold <5s", //2 - "Press and hold >5s", //3 -}; - -static ssize_t show_resetbuttonstatus(struct device *dev, struct device_attribute *da, - char *buf) -{ - struct i2c_client *client = to_i2c_client(dev); - struct cpld_data *data = i2c_get_clientdata(client); - u8 byte = 0; - - mutex_lock(&data->update_lock); - cpld_i2c_read(client, &byte, CPLD_RESETBUTTONSTATUS_OFFSET, 1); - mutex_unlock(&data->update_lock); - byte &=0x03; - - return sprintf (buf, "0x%02X:%s\n", byte,resetbutton_str[byte]); -} - -static char* resetcause_str[] = { - "Power-On", //0 - "Watchdog", //1 - "SoftwareReboot", //2 - "ResetButton", //3 - "Panic", //4 - "ThermalTrip" //5 -}; - -static ssize_t show_resetcause(struct device *dev, struct device_attribute *da, - char *buf) -{ - struct i2c_client *client = to_i2c_client(dev); - struct cpld_data *data = i2c_get_clientdata(client); - u8 byte = 0; - - mutex_lock(&data->update_lock); - cpld_i2c_read(client, &byte, CPLD_RSTCAUSE_OFFSET, 1); - mutex_unlock(&data->update_lock); - - sprintf (buf, "0x%02X:", byte); - if(byte==0) sprintf (buf, "%sNone",buf); - if(byte&0x01) sprintf (buf, "%s%s ",buf,resetcause_str[0]); - if(byte&0x02) sprintf (buf, "%s%s ",buf,resetcause_str[1]); - if(byte&0x04) sprintf (buf, "%s%s ",buf,resetcause_str[2]); - if(byte&0x08) sprintf (buf, "%s%s ",buf,resetcause_str[3]); - if(byte&0x10) sprintf (buf, "%s%s ",buf,resetcause_str[4]); - if(byte&0x20) sprintf (buf, "%s%s ",buf,resetcause_str[5]); - return sprintf (buf, "%s\n", buf); -} - -static ssize_t set_resetcause(struct device *dev, struct device_attribute *da, - const char *buf, size_t count) -{ - struct i2c_client *client = to_i2c_client(dev); - struct cpld_data *data = i2c_get_clientdata(client); - u8 byte = 0; - - mutex_lock(&data->update_lock); - cpld_i2c_write(client, &byte, CPLD_RSTCAUSE_OFFSET, 1); - mutex_unlock(&data->update_lock); - - return count; -} - -static char* interrupt_str[] = { - "PCIE_INTR_L", //0 - "EXT_USB_OC_N", //1 - "PS2_ALERT_N", //2 - "PS1_ALERT_N", //3 - "PLD_SEN5_ALERT_N", //4 - "PLD_SEN4_ALERT_N", //5 - "PLD_SEN3_ALERT_N", //6 - "UCD90160_TEMP_INT_N", //7 - "RSTBTN_INT_N", //8 - "WDT_IRQ_N", //9 - "RSTBTN_5s_INT_N", //10 - "Reserved" //11 -}; - -static ssize_t show_interrupt(struct device *dev, struct device_attribute *da, - char *buf) -{ - struct i2c_client *client = to_i2c_client(dev); - struct cpld_data *data = i2c_get_clientdata(client); - u8 byte[4] = {0,0,0,0}; - - mutex_lock(&data->update_lock); - cpld_i2c_read(client, byte, CPLD_INT_OFFSET, 4); - mutex_unlock(&data->update_lock); - - sprintf (buf, "0x%02X 0x%02X:", byte[0],byte[2]); - if(byte[0]==0xff && byte[2]==0x07) sprintf (buf, "%sNone",buf); - if(!(byte[0]&0x01)) sprintf (buf, "%s%s ",buf,interrupt_str[0]); - if(!(byte[0]&0x02)) sprintf (buf, "%s%s ",buf,interrupt_str[1]); - //if(!(byte[0]&0x04)) sprintf (buf, "%s%s ",buf,interrupt_str[2]); - //if(!(byte[0]&0x08)) sprintf (buf, "%s%s ",buf,interrupt_str[3]); - if(!(byte[0]&0x10)) sprintf (buf, "%s%s ",buf,interrupt_str[4]); - if(!(byte[0]&0x20)) sprintf (buf, "%s%s ",buf,interrupt_str[5]); - if(!(byte[0]&0x40)) sprintf (buf, "%s%s ",buf,interrupt_str[6]); - if(!(byte[0]&0x80)) sprintf (buf, "%s%s ",buf,interrupt_str[7]); - if(!(byte[2]&0x01)) sprintf (buf, "%s%s%s ",buf,interrupt_str[8] ,(byte[3]&0x01)?"(Blocked)":""); - if(!(byte[2]&0x02)) sprintf (buf, "%s%s%s ",buf,interrupt_str[9] ,(byte[3]&0x02)?"(Blocked)":""); - if(!(byte[2]&0x04)) sprintf (buf, "%s%s%s ",buf,interrupt_str[10],(byte[3]&0x04)?"(Blocked)":""); - - return sprintf (buf, "%s\n", buf); -} - -static ssize_t show_operationcommand(struct device *dev, struct device_attribute *da, - char *buf) -{ - struct i2c_client *client = to_i2c_client(dev); - struct cpld_data *data = i2c_get_clientdata(client); - return sprintf (buf, "%d\n", data->operation_command); -} - -static ssize_t set_operationcommand(struct device *dev, - struct device_attribute *da, - const char *buf, size_t count) -{ - struct i2c_client *client = to_i2c_client(dev); - struct cpld_data *data = i2c_get_clientdata(client); - u8 operationcommand = simple_strtol(buf, NULL, 10); - - data->operation_command = operationcommand?1:0; - - return count; -} - -static char* bios_str[] = { - "BIOS1", //0 - "BIOS2", //1 -}; - -static ssize_t show_bios_cs(struct device *dev, struct device_attribute *da, - char *buf) -{ - struct i2c_client *client = to_i2c_client(dev); - struct cpld_data *data = i2c_get_clientdata(client); - u8 byte = 0; - - mutex_lock(&data->update_lock); - cpld_i2c_read(client, &byte, CPLD_BIOSCS_OFFSET, 1); - mutex_unlock(&data->update_lock); - - byte &= 0x01; - - return sprintf (buf, "%d:%s\n", byte,bios_str[byte]); -} - -static ssize_t set_bios_cs(struct device *dev, - struct device_attribute *da, - const char *buf, size_t count) -{ - struct i2c_client *client = to_i2c_client(dev); - struct cpld_data *data = i2c_get_clientdata(client); - u8 byte = 0; - u8 temp = simple_strtol(buf, NULL, 10); - - mutex_lock(&data->update_lock); - cpld_i2c_read(client, &byte, CPLD_BIOSCS_OFFSET, 1); - if(temp) byte |= 0x01; else byte &= ~(0x01); - cpld_i2c_write(client, &byte, CPLD_BIOSCS_OFFSET, 1); - mutex_unlock(&data->update_lock); - - return count; -} - -static char* led_str[] = { - "OFF", //000 - "ON", //001 - "1 Hz", //010 - "2 Hz", //011 -}; - -static ssize_t show_led(struct device *dev, struct device_attribute *da, - char *buf) -{ - struct sensor_device_attribute *attr = to_sensor_dev_attr(da); - struct i2c_client *client = to_i2c_client(dev); - struct cpld_data *data = i2c_get_clientdata(client); - u8 byte = 0; - int shift = attr->index; - - mutex_lock(&data->update_lock); - cpld_i2c_read(client, &byte, CPLD_LED_OFFSET, 1); - mutex_unlock(&data->update_lock); - byte = (byte >> shift) & 0x3; - - return sprintf (buf, "%d: %s\n", byte, led_str[byte]); -} - -static ssize_t set_led(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 cpld_data *data = i2c_get_clientdata(client); - - u8 temp = simple_strtol(buf, NULL, 16); - u8 byte = 0; - int shift = attr->index; - temp &= 0x3; - - mutex_lock(&data->update_lock); - cpld_i2c_read(client, &byte, CPLD_LED_OFFSET, 1); - byte &= ~(0x3<update_lock); - - return count; -} - -static char* psu_str[] = { - "unpowered", //00 - "normal", //01 - "not installed", //10 - "not installed", //11 -}; - -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 cpld_data *data = i2c_get_clientdata(client); - u8 byte=0; - int shift = (attr->index == 0)?0:4; - - mutex_lock(&data->update_lock); - cpld_i2c_read(client2, &byte, CPLD_PSU_OFFSET, 1); - mutex_unlock(&data->update_lock); - byte = (byte >> shift) & 0x3; - - return sprintf (buf, "%d:%s\n", byte, psu_str[byte]); -} - -static ssize_t show_pwm(struct device *dev, struct device_attribute *da, - char *buf) -{ - struct sensor_device_attribute *attr = to_sensor_dev_attr(da); - struct i2c_client *client = to_i2c_client(dev); - struct cpld_data *data = i2c_get_clientdata(client); - u8 byte=0; - u8 offset = attr->index + CPLD_PWM_OFFSET; - - mutex_lock(&data->update_lock); - cpld_i2c_read(client2, &byte, offset, 1); - mutex_unlock(&data->update_lock); - - return sprintf(buf, "%d\n", byte); -} - -static ssize_t set_pwm(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 cpld_data *data = i2c_get_clientdata(client); - u8 offset = attr->index + CPLD_PWM_OFFSET; - u8 byte = simple_strtol(buf, NULL, 10); - - mutex_lock(&data->update_lock); - cpld_i2c_write(client2, &byte, offset, 1); - mutex_unlock(&data->update_lock); - - return count; -} - -static ssize_t show_rpm(struct device *dev, struct device_attribute *da, - char *buf) -{ - struct sensor_device_attribute *attr = to_sensor_dev_attr(da); - struct i2c_client *client = to_i2c_client(dev); - struct cpld_data *data = i2c_get_clientdata(client); - u8 offset = attr->index*2 + CPLD_RPM_OFFSET; - u8 byte[2] = {0,0}; - - mutex_lock(&data->update_lock); - cpld_i2c_read(client2, byte, offset, 2); - mutex_unlock(&data->update_lock); - - return sprintf(buf, "%d\n", (byte[0]<<8 | byte[1])); -} - -static char* fantype_str[] = { - "Normal Type", //00 - "REVERSAL Type", //01 - "UNPLUGGED", //10 - "UNPLUGGED", //11 -}; - -static ssize_t show_fantype(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 cpld_data *data = i2c_get_clientdata(client); - u8 offset = CPLD_FANSTATUS_OFFSET; - u8 byte[2] = {0,0}; - - mutex_lock(&data->update_lock); - cpld_i2c_read(client2, byte, offset, 2); - mutex_unlock(&data->update_lock); - status = (((byte[0] >> attr->index) & 0x01)) | (((byte[1] >> attr->index) & 0x01)<<1); - - return sprintf(buf, "%d:%s\n",status,fantype_str[status]); -} - -static char* fanled_str[] = { - "None", //00 - "Green", //01 - "Red", //10 - "Both", //11 -}; - -static ssize_t show_fanled(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 cpld_data *data = i2c_get_clientdata(client); - u8 byte[2] = {0,0}; - - mutex_lock(&data->update_lock); - cpld_i2c_read(client2, byte, CPLD_FANLED_OFFSET, 2); - mutex_unlock(&data->update_lock); - status = (((byte[0] >> attr->index) & 0x01)) | (((byte[1] >> attr->index) & 0x01)<<1); - - return sprintf(buf, "%d:%s\n",status,fanled_str[status]); -} - -static ssize_t set_fanled(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 cpld_data *data = i2c_get_clientdata(client); - u8 byte[2] = {0,0}; - u8 temp = simple_strtol(buf, NULL, 16); - int shift = attr->index; - - temp &= 0x3; - mutex_lock(&data->update_lock); - cpld_i2c_read(client2, byte, CPLD_FANLED_OFFSET, 2); - byte[0] &= ~(1<> 1) & 0x01)<update_lock); - - return count; -} - -static ssize_t set_watchdog_feed(struct device *dev, struct device_attribute *da, - const char *buf, size_t count) -{ - struct i2c_client *client = to_i2c_client(dev); - struct cpld_data *data = i2c_get_clientdata(client); - u8 byte=0; - - mutex_lock(&data->update_lock); - cpld_i2c_read(client, &byte, CPLD_WATCHDOGENABLE_OFFSET, 1); - byte |= 0x02; - cpld_i2c_write(client, &byte, CPLD_WATCHDOGENABLE_OFFSET, 1); - mutex_unlock(&data->update_lock); - - return count; -} - -static ssize_t set_watchdog_enable(struct device *dev, struct device_attribute *da, - const char *buf, size_t count) -{ - struct i2c_client *client = to_i2c_client(dev); - struct cpld_data *data = i2c_get_clientdata(client); - u8 byte=0x03; - - mutex_lock(&data->update_lock); - cpld_i2c_write(client, &byte, CPLD_WATCHDOGENABLE_OFFSET, 1); - mutex_unlock(&data->update_lock); - - return count; -} - -static ssize_t show_watchdog_enable(struct device *dev, struct device_attribute *da, - char *buf) -{ - struct i2c_client *client = to_i2c_client(dev); - struct cpld_data *data = i2c_get_clientdata(client); - u8 byte=0; - - mutex_lock(&data->update_lock); - cpld_i2c_read(client, &byte, CPLD_WATCHDOGENABLE_OFFSET, 1); - mutex_unlock(&data->update_lock); - - return sprintf(buf, "%d\n",(byte&0x01)); -} - -static ssize_t set_watchdog_config(struct device *dev, - struct device_attribute *da, - const char *buf, size_t count) -{ - struct i2c_client *client = to_i2c_client(dev); - struct cpld_data *data = i2c_get_clientdata(client); - u8 byte = simple_strtol(buf, NULL, 10); - - if (byte<6) byte=6; - mutex_lock(&data->update_lock); - cpld_i2c_write(client, &byte, CPLD_WATCHDOGCONFIG_OFFSET, 1); - mutex_unlock(&data->update_lock); - - return count; -} - -static ssize_t show_watchdog_config(struct device *dev, struct device_attribute *da, - char *buf) -{ - struct i2c_client *client = to_i2c_client(dev); - struct cpld_data *data = i2c_get_clientdata(client); - u8 byte=0; - - mutex_lock(&data->update_lock); - cpld_i2c_read(client, &byte, CPLD_WATCHDOGCONFIG_OFFSET, 1); - mutex_unlock(&data->update_lock); - - return sprintf(buf, "%d seconds\n",byte); -} - -static ssize_t show_watchdog_counter(struct device *dev, struct device_attribute *da, - char *buf) -{ - struct i2c_client *client = to_i2c_client(dev); - struct cpld_data *data = i2c_get_clientdata(client); - u8 byte=0; - - mutex_lock(&data->update_lock); - cpld_i2c_read(client, &byte, CPLD_WATCHDOGCOUNTER_OFFSET, 1); - mutex_unlock(&data->update_lock); - - return sprintf(buf, "%d seconds\n",byte); -} - -static ssize_t show_paniccode(struct device *dev, struct device_attribute *da, - char *buf) -{ - struct i2c_client *client = to_i2c_client(dev); - struct cpld_data *data = i2c_get_clientdata(client); - u8 byte = 0; - - mutex_lock(&data->update_lock); - cpld_i2c_read(client, &byte, CPLD_PANICCODE_OFFSET, 1); - mutex_unlock(&data->update_lock); - - return sprintf (buf, "0x%02X\n", byte); -} - -#if ENABLE_SIMULATE -static ssize_t show_simdump(struct device *dev, struct device_attribute *da, - char *buf) -{ - u8 i, j; - sprintf(buf,"usage: echo 0xAABB > sim_buffer (AA is address, BB is value)\n\n"); - sprintf(buf,"%s 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F\n",buf); - sprintf(buf,"%s======================================================\n",buf); - sprintf(buf,"%s0000: ",buf); - for (j = 0, i = 0; j < sizeof(sim_register); j++, i++) - { - sprintf(buf,"%s%02x ", buf, (int)sim_register[i]); - if ((i & 0x0F) == 0x0F) sprintf(buf,"%s\n%04x: ", buf, (i+1)); - } - return sprintf(buf,"%s\n",buf); -} - -static ssize_t set_simbuffer(struct device *dev, struct device_attribute *da, - const char *buf, size_t count) -{ - u16 byte = simple_strtol(buf, NULL, 16); - u8 address = (byte >> 8); - u8 value = (byte & 0xff); - - sim_register[address]=value; - - return count; -} -#endif -static SENSOR_DEVICE_ATTR(info, S_IRUGO, show_info, 0, 0); -static SENSOR_DEVICE_ATTR(diag, S_IWUSR|S_IRUGO, show_diag, set_diag, 0); -static SENSOR_DEVICE_ATTR(interrupt, S_IRUGO, show_interrupt, 0, 0); - -static SENSOR_DEVICE_ATTR(stacking_led, S_IWUSR|S_IRUGO, show_led, set_led, 0); -static SENSOR_DEVICE_ATTR(fan_led, S_IWUSR|S_IRUGO, show_led, set_led, 2); -static SENSOR_DEVICE_ATTR(power_led, S_IWUSR|S_IRUGO, show_led, set_led, 4); -static SENSOR_DEVICE_ATTR(service_led, S_IWUSR|S_IRUGO, show_led, set_led, 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(pwm5, S_IWUSR|S_IRUGO, show_pwm, set_pwm, 4); - -static SENSOR_DEVICE_ATTR(fanmodule1_type, S_IRUGO, show_fantype, 0, 0); -static SENSOR_DEVICE_ATTR(fanmodule2_type, S_IRUGO, show_fantype, 0, 1); -static SENSOR_DEVICE_ATTR(fanmodule3_type, S_IRUGO, show_fantype, 0, 2); -static SENSOR_DEVICE_ATTR(fanmodule4_type, S_IRUGO, show_fantype, 0, 3); -static SENSOR_DEVICE_ATTR(fanmodule5_type, S_IRUGO, show_fantype, 0, 4); - -static SENSOR_DEVICE_ATTR(fanmodule1_led, S_IWUSR|S_IRUGO, show_fanled, set_fanled, 0); -static SENSOR_DEVICE_ATTR(fanmodule2_led, S_IWUSR|S_IRUGO, show_fanled, set_fanled, 1); -static SENSOR_DEVICE_ATTR(fanmodule3_led, S_IWUSR|S_IRUGO, show_fanled, set_fanled, 2); -static SENSOR_DEVICE_ATTR(fanmodule4_led, S_IWUSR|S_IRUGO, show_fanled, set_fanled, 3); -static SENSOR_DEVICE_ATTR(fanmodule5_led, S_IWUSR|S_IRUGO, show_fanled, set_fanled, 4); - -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(fan9_input, S_IRUGO, show_rpm, 0, 8); -static SENSOR_DEVICE_ATTR(fan10_input,S_IRUGO, show_rpm, 0, 9); - -static SENSOR_DEVICE_ATTR(psu1, S_IRUGO, show_psu, 0, 0); -static SENSOR_DEVICE_ATTR(psu2, S_IRUGO, show_psu, 0, 1); -static SENSOR_DEVICE_ATTR(power_status, S_IRUGO, show_powerstatus, 0, 0); -static SENSOR_DEVICE_ATTR(reset_cause, S_IWUSR|S_IRUGO, show_resetcause, set_resetcause, 0); -static SENSOR_DEVICE_ATTR(resetbutton_status, S_IRUGO, show_resetbuttonstatus, 0, 0); -static SENSOR_DEVICE_ATTR(panic_code, S_IRUGO, show_paniccode, 0, 0); - -static SENSOR_DEVICE_ATTR(watchdog_feed, S_IWUSR, 0, set_watchdog_feed, 0); -static SENSOR_DEVICE_ATTR(watchdog_enable, S_IWUSR|S_IRUGO, show_watchdog_enable, set_watchdog_enable, 0); -static SENSOR_DEVICE_ATTR(watchdog_config, S_IWUSR|S_IRUGO, show_watchdog_config, set_watchdog_config, 0); -static SENSOR_DEVICE_ATTR(watchdog_counter, S_IRUGO, show_watchdog_counter, 0, 0); - -static SENSOR_DEVICE_ATTR(stack_mode, S_IWUSR|S_IRUGO, show_stackmode, set_stackmode, 0); -static SENSOR_DEVICE_ATTR(operation_command, S_IWUSR|S_IRUGO, show_operationcommand, set_operationcommand, 0); -#if ENABLE_SIMULATE - static SENSOR_DEVICE_ATTR(sim_buffer, S_IWUSR|S_IRUGO, show_simdump, set_simbuffer, 0); -#endif -static SENSOR_DEVICE_ATTR(bios_cs, S_IWUSR|S_IRUGO, show_bios_cs, set_bios_cs, 0); - -static struct attribute *cpld_attributes[] = { - &sensor_dev_attr_info.dev_attr.attr, - &sensor_dev_attr_diag.dev_attr.attr, - - &sensor_dev_attr_stacking_led.dev_attr.attr, - &sensor_dev_attr_fan_led.dev_attr.attr, - &sensor_dev_attr_power_led.dev_attr.attr, - &sensor_dev_attr_service_led.dev_attr.attr, - - &sensor_dev_attr_interrupt.dev_attr.attr, - - &sensor_dev_attr_psu1.dev_attr.attr, - &sensor_dev_attr_psu2.dev_attr.attr, - &sensor_dev_attr_power_status.dev_attr.attr, - &sensor_dev_attr_reset_cause.dev_attr.attr, - &sensor_dev_attr_resetbutton_status.dev_attr.attr, - &sensor_dev_attr_panic_code.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_fanmodule1_type.dev_attr.attr, - &sensor_dev_attr_fanmodule2_type.dev_attr.attr, - &sensor_dev_attr_fanmodule3_type.dev_attr.attr, - &sensor_dev_attr_fanmodule4_type.dev_attr.attr, - &sensor_dev_attr_fanmodule5_type.dev_attr.attr, - - &sensor_dev_attr_fanmodule1_led.dev_attr.attr, - &sensor_dev_attr_fanmodule2_led.dev_attr.attr, - &sensor_dev_attr_fanmodule3_led.dev_attr.attr, - &sensor_dev_attr_fanmodule4_led.dev_attr.attr, - &sensor_dev_attr_fanmodule5_led.dev_attr.attr, - - &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_fan9_input.dev_attr.attr, - &sensor_dev_attr_fan10_input.dev_attr.attr, - - &sensor_dev_attr_watchdog_feed.dev_attr.attr, - &sensor_dev_attr_watchdog_enable.dev_attr.attr, - &sensor_dev_attr_watchdog_config.dev_attr.attr, - &sensor_dev_attr_watchdog_counter.dev_attr.attr, - - &sensor_dev_attr_stack_mode.dev_attr.attr, - &sensor_dev_attr_operation_command.dev_attr.attr, - - &sensor_dev_attr_bios_cs.dev_attr.attr, -#if ENABLE_SIMULATE - &sensor_dev_attr_sim_buffer.dev_attr.attr, -#endif - NULL -}; - -struct i2c_client *client_notifier; - -static const struct attribute_group cpld_group = { - .attrs = cpld_attributes, -}; - -static int log_reboot_to_cpld (struct notifier_block *self, unsigned long event, void *ptr) -{ - u8 byte=0; - if (event == SYS_DOWN || event == SYS_HALT) - { - cpld_i2c_read(client_notifier, &byte, CPLD_RSTCAUSE_OFFSET, 1); - byte |= 0x04; - cpld_i2c_write(client_notifier, &byte, CPLD_RSTCAUSE_OFFSET, 1); - } - return NOTIFY_DONE; -} - -static int log_panic_to_cpld(struct notifier_block *self, unsigned long event, void *ptr) -{ -#if 1 -// Can't use SMBus if smp is stopped (need patch the panic.c) - if (client_notifier != NULL) - { - u8 byte=0; - cpld_i2c_read(client_notifier, &byte, CPLD_RSTCAUSE_OFFSET, 1); - byte |= 0x10; - cpld_i2c_write(client_notifier, &byte, CPLD_RSTCAUSE_OFFSET, 1); - } -#endif - return NOTIFY_DONE; -} - -static struct notifier_block reboot_notifier = { - .notifier_call = log_reboot_to_cpld, -}; - -static struct notifier_block panic_notifier = { - .notifier_call = log_panic_to_cpld, -}; - -#if ENABLE_AUTOFAN -#define SWITCH_ADDRESS 3-004e -#define ENV_ADDRESS 3-004a -#define CPU_ADDRESS 3-0048 -#define PSU1_ADDRESS 2-0058 -#define PSU2_ADDRESS 2-0059 -#define PSU1_ADDRESS_DVT 2-005a -#define PSU2_ADDRESS_DVT 2-005b - -#define _STR(s) #s -#define __STR(s) _STR(s) -#define __File_input(__file) __STR(/sys/bus/i2c/devices/__file/hwmon/hwmon%d/temp1_input) -#define __File_max(__file) __STR(/sys/bus/i2c/devices/__file/hwmon/hwmon%d/temp1_max) -#define __File_max_hyst(__file) __STR(/sys/bus/i2c/devices/__file/hwmon/hwmon%d/temp1_max_hyst) -#define __File_pwm(__file) __STR(/sys/bus/i2c/devices/__file/hwmon/hwmon%d/pwm1) - -#define SWITCH_TEMPERATURE __File_input(SWITCH_ADDRESS) -#define ENV_TEMPERATURE __File_input(ENV_ADDRESS) -#define CPU_TEMPERATURE __File_input(CPU_ADDRESS) -#define SWITCH_MAX __File_max(SWITCH_ADDRESS) -#define ENV_MAX __File_max(ENV_ADDRESS) -#define CPU_MAX __File_max(CPU_ADDRESS) -#define SWITCH_MAX_HYST __File_max_hyst(SWITCH_ADDRESS) -#define ENV_MAX_HYST __File_max_hyst(ENV_ADDRESS) -#define CPU_MAX_HYST __File_max_hyst(CPU_ADDRESS) -#define PSU1_PWM __File_pwm(PSU1_ADDRESS) -#define PSU2_PWM __File_pwm(PSU2_ADDRESS) -#define PSU1_PWM_DVT __File_pwm(PSU1_ADDRESS_DVT) -#define PSU2_PWM_DVT __File_pwm(PSU2_ADDRESS_DVT) - -#define n_entries 9 -#define temp_hysteresis 2 -#define MAX_HWMON 9 - -//[Model:10G/SFP][FanDirection:R2F/F2R][Type:CPU/ASIC/ENV] -u8 Thermaltrip[2][2][3] ={{{64,68,64},{64,68,64}},{{64,68,64},{64,68,64}}}; -u8 FanTable[2][2][3][n_entries][2]={ -{//10GBastT - {//Rear-to-Front - {//CPU - { 45, 255 }, \ - { 40, 201 }, \ - { 38, 170 }, \ - { 35, 130 }, \ - { 31, 105 }, \ - { 27, 85 }, \ - { 24, 80 }, \ - { 20, 70 }, \ - { 18, 65 } - } - ,{//ASIC - { 52, 255 }, \ - { 47, 201 }, \ - { 44, 170 }, \ - { 42, 130 }, \ - { 39, 105 }, \ - { 36, 85 }, \ - { 33, 80 }, \ - { 30, 70 }, \ - { 28, 65 } - } - ,{//ENV - { 47, 255 }, \ - { 43, 201 }, \ - { 41, 170 }, \ - { 39, 130 }, \ - { 36, 105 }, \ - { 32, 85 }, \ - { 30, 80 }, \ - { 28, 70 }, \ - { 19, 65 } - } - }, - {//Front-to-Rear - {//CPU - { 45, 255 }, \ - { 40, 201 }, \ - { 38, 170 }, \ - { 35, 130 }, \ - { 31, 105 }, \ - { 27, 85 }, \ - { 24, 80 }, \ - { 20, 70 }, \ - { 18, 65 } - } - ,{//ASIC - { 52, 255 }, \ - { 47, 201 }, \ - { 44, 170 }, \ - { 42, 130 }, \ - { 39, 105 }, \ - { 36, 85 }, \ - { 33, 80 }, \ - { 30, 70 }, \ - { 28, 65 } - } - ,{//ENV - { 47, 255 }, \ - { 43, 201 }, \ - { 41, 170 }, \ - { 39, 130 }, \ - { 36, 105 }, \ - { 32, 85 }, \ - { 30, 80 }, \ - { 28, 70 }, \ - { 19, 65 } - } - }, -}, -{//SFP28 - {//Rear-to-Front - {//CPU - { 45, 255 }, \ - { 40, 201 }, \ - { 38, 170 }, \ - { 35, 130 }, \ - { 31, 105 }, \ - { 27, 85 }, \ - { 24, 80 }, \ - { 20, 70 }, \ - { 18, 65 } - } - ,{//ASIC - { 52, 255 }, \ - { 47, 201 }, \ - { 44, 170 }, \ - { 42, 130 }, \ - { 39, 105 }, \ - { 36, 85 }, \ - { 33, 80 }, \ - { 30, 70 }, \ - { 28, 65 } - } - ,{//ENV - { 47, 255 }, \ - { 43, 201 }, \ - { 41, 170 }, \ - { 39, 130 }, \ - { 36, 105 }, \ - { 32, 85 }, \ - { 30, 80 }, \ - { 28, 70 }, \ - { 19, 65 } - } - }, - {//Front-to-Rear - {//CPU - { 45, 255 }, \ - { 40, 201 }, \ - { 38, 170 }, \ - { 35, 130 }, \ - { 31, 105 }, \ - { 27, 85 }, \ - { 24, 80 }, \ - { 20, 70 }, \ - { 18, 65 } - } - ,{//ASIC - { 52, 255 }, \ - { 47, 201 }, \ - { 44, 170 }, \ - { 42, 130 }, \ - { 39, 105 }, \ - { 36, 85 }, \ - { 33, 80 }, \ - { 30, 70 }, \ - { 28, 65 } - } - ,{//ENV - { 47, 255 }, \ - { 43, 201 }, \ - { 41, 170 }, \ - { 39, 130 }, \ - { 36, 105 }, \ - { 32, 85 }, \ - { 30, 80 }, \ - { 28, 70 }, \ - { 19, 65 } - } - } -} -}; - -//type 0:CPU,1:ASIC,2:ENV -static u8 find_duty(u8 model, u8 fan_direction, u8 type, u8 temp) -{ - static u8 fantable_index[3]={n_entries-1, n_entries-1, n_entries-1}; - while(1) - { - if(fantable_index[type] >= 1 && temp > FanTable[model][fan_direction][type][fantable_index[type]-1][0]) - fantable_index[type]--; - else if(fantable_index[type] < (n_entries-1) && temp < (FanTable[model][fan_direction][type][fantable_index[type]][0]-temp_hysteresis)) - fantable_index[type]++; - else - break; - } - return FanTable[model][fan_direction][type][fantable_index[type]][1]; -} - -static u32 getvalue(char *path) -{ - static struct file *f; - mm_segment_t old_fs; - u16 temp = 0; - char temp_str[]={0,0,0,0,0,0,0,0,0}; - loff_t pos = 0; - - f = filp_open(path,O_RDONLY,0644); - if(IS_ERR(f)) return -1; - - old_fs = get_fs(); - set_fs(KERNEL_DS); - vfs_read(f, temp_str,8,&pos); - temp = simple_strtoul(temp_str,NULL,10); - filp_close(f,NULL); - set_fs(old_fs); - - if(temp<0) temp=0; - return temp; -} - -static u8 setvalue(char *path, u32 value) -{ - static struct file *f; - mm_segment_t old_fs; - char temp_str[]={0,0,0,0,0,0,0,0,0}; - u8 len=0; - loff_t pos = 0; - - f = filp_open(path,O_WRONLY,0644); - if(IS_ERR(f)) return -1; - - len = sprintf(temp_str,"%d",value); - - old_fs = get_fs(); - set_fs(KERNEL_DS); - vfs_write(f, temp_str, len, &pos); - filp_close(f,NULL); - set_fs(old_fs); - - return 0; -} - -static u8 probe_gettemp(char *path) -{ - u8 temp_path[64],i; - u32 value; - - for(i=0;imodel,data->fan_direction,0,temp_cpu); - if(temp_switch!=0xff) duty_switch=find_duty(data->model,data->fan_direction,1,temp_switch); - if(temp_env!=0xff) duty_env=find_duty(data->model,data->fan_direction,2,temp_env); - - if(temp_cpu==0xff && temp_switch==0xff && temp_env==0xff) - { - duty=PWM_DEFAULT; - } - else - { - duty=(duty>duty_cpu)?duty:duty_cpu; - duty=(duty>duty_switch)?duty:duty_switch; - duty=(duty>duty_env)?duty:duty_env; - } - - memset(fanpwm,duty,FAN_NUM); - for(i=0;i 200) - psu_duty = 80; - else if (duty <= 200 && duty > 150) - if(data->fan_direction==0) psu_duty = 70; else psu_duty = 65; - else if (duty <= 150 && duty > 100) - if(data->fan_direction==0) psu_duty = 60; else psu_duty = 55; - else - if(data->fan_direction==0) psu_duty = 50; else psu_duty = 35; - probe_setvalue(PSU1_PWM, psu_duty); - probe_setvalue(PSU2_PWM, psu_duty); - probe_setvalue(PSU1_PWM_DVT, psu_duty); - probe_setvalue(PSU2_PWM_DVT, psu_duty); - - mutex_lock(&data->update_lock); - cpld_i2c_write(client2,fanpwm,CPLD_PWM_OFFSET,FAN_NUM); - mutex_unlock(&data->update_lock); -} -#endif - -/*-----------------------------------------------------------------------*/ -static int cpld_polling(void *p) -{ - struct i2c_client *client = p; - struct cpld_data *data = i2c_get_clientdata(client); - u8 fanrpm[22],fanled[2],frontled,i; - u8 fandir=0,fanpresent=0,fanfront,fanrear,fanerror; - u8 fanfail,fanturnoff,psufail,lastStack,retry; - u8 psustatus=0; - u8 initial_thermaltrip[3] = {0,0,0}; - - while (!kthread_should_stop()) - { - //initial tmp75's thermaltrip value - if(initial_thermaltrip[0]==0) - { - if((probe_setvalue(CPU_MAX, Thermaltrip[data->model][data->fan_direction][0]*1000)!=0xff) - && (probe_setvalue(CPU_MAX_HYST, (Thermaltrip[data->model][data->fan_direction][0]-temp_hysteresis)*1000)!=0xff)) - initial_thermaltrip[0]=1; - } - if(initial_thermaltrip[1]==0) - { - if((probe_setvalue(SWITCH_MAX, Thermaltrip[data->model][data->fan_direction][1]*1000)!=0xff) - && (probe_setvalue(SWITCH_MAX_HYST, (Thermaltrip[data->model][data->fan_direction][1]-temp_hysteresis)*1000)!=0xff)) - initial_thermaltrip[1]=1; - } - if(initial_thermaltrip[2]==0) - { - if((probe_setvalue(ENV_MAX, Thermaltrip[data->model][data->fan_direction][2]*1000)!=0xff) - && (probe_setvalue(ENV_MAX_HYST, (Thermaltrip[data->model][data->fan_direction][2]-temp_hysteresis)*1000)!=0xff)) - initial_thermaltrip[2]=1; - } - - //LED control - if (data->diag==0 && i2c_smbus_read_byte_data(client, 0)>=0) - { - for(retry=0;retry<2;retry++) - { - fanfail=0; - fanled[0]=0; //clean green led - fanled[1]=0; //clean red led - fanfront=0; - fanrear=0; - fanerror=0; - fanturnoff=0; - - //------ Fan Check ------- - cpld_i2c_read(client2, fanrpm, CPLD_RPM_OFFSET, 22); - fandir=fanrpm[20]; - fanpresent=fanrpm[21]; - - //Count the fan's direction - for (i=0;i 23500) || (rpm2 < 3000 || rpm2 > 23500)) - fanerror++; - else if(fandir&(1<>i)&0x01)!=data->fan_direction) - fanled[0] |= (1<stack_mode==0) frontled&=~(0x3); //0: Non-Stack member => off - if(data->stack_mode==1) frontled|=0x2; //1: Stack Master => Flash green - if(data->stack_mode==2) frontled|=0x1; //2: Stack Backup/Member => Steady green - if(data->stack_mode==3) frontled|=lastStack;//3: Stack Error => last status - lastStack=frontled; - - if(fanpresent!=0x00) //Fan LED in bit2 bit3 - { - frontled|=(0x02<<2); //Some fan unpresent => 0x02 - } - else - { - if(fanturnoff||fanfail) //some fan no speed => 0x03 - frontled|=(0x03<<2); //some fan dir different => 0x03 - else - frontled|=(0x01<<2); //Normal => 0x01 - } - - if(psustatus&0x22) //POW LED in bit4 bit5 - frontled|=(0x02<<4); //not all psu plug-in => 0x02 - else if (psustatus!=0x11) - frontled|=(0x03<<4); //some power is not ok => 0x03 - else - frontled|=(0x01<<4); //Normal => 0x01 - - if(data->operation_command==1) //Service LED in bit6 bit7 - frontled|=(0x01<<6); //Steady if operation - else if(fanfail>0||psufail>0||data->stack_mode==3) - frontled|=(0x02<<6); //Flash if any error - else if(data->stack_mode==2) - frontled|=(0x01<<6); //Steady if mode in Stack Backup/Member - else - frontled&=~(0x3<<6); //Off if mode in Non-Stack member or Stack Master with no operation and error - cpld_i2c_write(client, &frontled, CPLD_LED_OFFSET, 1); - } - set_current_state(TASK_INTERRUPTIBLE); - if(kthread_should_stop()) break; - schedule_timeout(msecs_to_jiffies(CPLD_POLLING_PERIOD)); - } - return 0; -} - -/*-----------------------------------------------------------------------*/ -/* device probe and removal */ - -static int -cpld_probe(struct i2c_client *client, const struct i2c_device_id *id) -{ - struct cpld_data *data; - int status; - u8 byte[5]={PWM_DEFAULT,PWM_DEFAULT,PWM_DEFAULT,PWM_DEFAULT,PWM_DEFAULT}; - - 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; - } - - //Check CPLD2 exist or not - client2 = i2c_new_dummy(client->adapter, CPLD2_ADDRESS); - if(!client2) { - hasCPLD2 = 0; - client2 = client; - } else { - status = i2c_smbus_read_byte_data(client2, CPLD_INFO_OFFSET); - if(status<0) { - i2c_unregister_device(client2); - i2c_set_clientdata(client2, NULL); - hasCPLD2 = 0; - client2 = client; - } - } - - dev_info(&client->dev, "%s: sensor '%s'\n", - dev_name(data->hwmon_dev), client->name); - - //initial PWM to 60% - cpld_i2c_write(client2, byte, CPLD_PWM_OFFSET, 5); - - //Handle LED control by the driver - byte[0]=0x01; - cpld_i2c_write(client, byte, CPLD_CTL_OFFSET, 1); - cpld_i2c_write(client2, byte, CPLD_CTL_OFFSET, 1); - - //Get Model type - cpld_i2c_read(client, byte, CPLD_INFO_OFFSET, 1); - data->model = (byte[0]>>5) & 0x01; - data->fan_direction = (byte[0]>>7) & 0x01; - - //kernel panic notifier - atomic_notifier_chain_register(&panic_notifier_list, &panic_notifier); - - //soft reboot notifier - register_reboot_notifier(&reboot_notifier); - - client_notifier=client; - - data->cpld_thread = kthread_run(cpld_polling,client,"%s",dev_name(data->hwmon_dev)); - - 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); - //Return LED control to the CPLD - u8 byte=0x00; - cpld_i2c_write(client, &byte, CPLD_CTL_OFFSET, 1); - cpld_i2c_write(client2, &byte, CPLD_CTL_OFFSET, 1); - - //unregister soft reboot notifier - unregister_reboot_notifier(&reboot_notifier); - - //unregister kernel panic notifier - atomic_notifier_chain_unregister(&panic_notifier_list, &panic_notifier); - - //stop cpld thread - kthread_stop(data->cpld_thread); - - sysfs_remove_group(&client->dev.kobj, &cpld_group); - hwmon_device_unregister(data->hwmon_dev); - i2c_set_clientdata(client, NULL); - if(hasCPLD2) { - i2c_unregister_device(client2); - i2c_set_clientdata(client2, 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("jack.ting "); -MODULE_DESCRIPTION("cpld driver"); -MODULE_LICENSE("GPL"); - -module_init(inv_cpld_init); -module_exit(inv_cpld_exit); diff --git a/packages/platforms/inventec/x86-64/d6332/modules/builds/src/inv_eeprom.c b/packages/platforms/inventec/x86-64/d6332/modules/builds/src/inv_eeprom.c deleted file mode 100644 index 7bb167d2e..000000000 --- a/packages/platforms/inventec/x86-64/d6332/modules/builds/src/inv_eeprom.c +++ /dev/null @@ -1,181 +0,0 @@ -/* - * 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 -#include - - -/* Size of EEPROM in bytes */ -#define EEPROM_SIZE 256 - -#define SLICE_BITS (6) -#define SLICE_SIZE (1 << SLICE_BITS) -#define SLICE_NUM (EEPROM_SIZE/SLICE_SIZE) - -/* Each client has this additional data */ -struct eeprom_data { - struct mutex update_lock; - u8 valid; /* bitfield, bit!=0 if slice is valid */ - unsigned long last_updated[SLICE_NUM]; /* In jiffies, 8 slices */ - u8 data[EEPROM_SIZE]; /* Register values */ -}; - - -static void inv_eeprom_update_client(struct i2c_client *client, u8 slice) -{ - struct eeprom_data *data = i2c_get_clientdata(client); - int i, j; - int ret; - int addr; - - - mutex_lock(&data->update_lock); - - if (!(data->valid & (1 << slice)) || - time_after(jiffies, data->last_updated[slice] + 300 * HZ)) { - dev_dbg(&client->dev, "Starting eeprom update, slice %u\n", slice); - - addr = slice << SLICE_BITS; - - ret = i2c_smbus_write_byte_data(client, ((u8)addr >> 8) & 0xFF, (u8)addr & 0xFF); - /* select the eeprom address */ - if (ret < 0) { - dev_err(&client->dev, "address set failed\n"); - goto exit; - } - - if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_READ_BYTE)) { - goto exit; - } - - for (i = slice << SLICE_BITS; i < (slice + 1) << SLICE_BITS; i+= SLICE_SIZE) { - for (j = i; j < (i+SLICE_SIZE); j++) { - int res; - - res = i2c_smbus_read_byte(client); - if (res < 0) { - goto exit; - } - - data->data[j] = res & 0xFF; - } - } - - data->last_updated[slice] = jiffies; - data->valid |= (1 << slice); - } - -exit: - mutex_unlock(&data->update_lock); -} - -static ssize_t inv_eeprom_read(struct file *filp, struct kobject *kobj, - struct bin_attribute *bin_attr, - char *buf, loff_t off, size_t count) -{ - struct i2c_client *client = to_i2c_client(container_of(kobj, struct device, kobj)); - struct eeprom_data *data = i2c_get_clientdata(client); - u8 slice; - - - if (off > EEPROM_SIZE) { - return 0; - } - if (off + count > EEPROM_SIZE) { - count = EEPROM_SIZE - off; - } - if (count == 0) { - return 0; - } - - /* Only refresh slices which contain requested bytes */ - for (slice = off >> SLICE_BITS; slice <= (off + count - 1) >> SLICE_BITS; slice++) { - inv_eeprom_update_client(client, slice); - } - - memcpy(buf, &data->data[off], count); - - return count; -} - -static struct bin_attribute inv_eeprom_attr = { - .attr = { - .name = "eeprom", - .mode = S_IRUGO, - }, - .size = EEPROM_SIZE, - .read = inv_eeprom_read, -}; - -static int inv_eeprom_probe(struct i2c_client *client, - const struct i2c_device_id *id) -{ - struct eeprom_data *data; - int err; - - if (!(data = kzalloc(sizeof(struct eeprom_data), GFP_KERNEL))) { - err = -ENOMEM; - goto exit; - } - - memset(data->data, 0xff, EEPROM_SIZE); - i2c_set_clientdata(client, data); - mutex_init(&data->update_lock); - - /* create the sysfs eeprom file */ - err = sysfs_create_bin_file(&client->dev.kobj, &inv_eeprom_attr); - if (err) { - goto exit_kfree; - } - - return 0; - -exit_kfree: - kfree(data); -exit: - return err; -} - -static int inv_eeprom_remove(struct i2c_client *client) -{ - sysfs_remove_bin_file(&client->dev.kobj, &inv_eeprom_attr); - kfree(i2c_get_clientdata(client)); - - return 0; -} - -static const struct i2c_device_id inv_eeprom_id[] = { - { "inv_eeprom", 0 }, - { } -}; - -static struct i2c_driver inv_eeprom_driver = { - .driver = { - .name = "inv_eeprom", - }, - .probe = inv_eeprom_probe, - .remove = inv_eeprom_remove, - .id_table = inv_eeprom_id, -}; - -module_i2c_driver(inv_eeprom_driver); - -MODULE_AUTHOR("Inventec"); -MODULE_DESCRIPTION("Inventec D6556 Mother Board EEPROM driver"); -MODULE_LICENSE("GPL"); - - diff --git a/packages/platforms/inventec/x86-64/d6332/modules/builds/src/inv_mux.c b/packages/platforms/inventec/x86-64/d6332/modules/builds/src/inv_mux.c deleted file mode 100644 index 40593a96e..000000000 --- a/packages/platforms/inventec/x86-64/d6332/modules/builds/src/inv_mux.c +++ /dev/null @@ -1,545 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include "io_expander.h" -#include "inv_mux.h" - -/* For build single module using (Ex: ONL platform) */ -#include -//#include -//#include - -static struct mux_obj_s *mux_head_p = NULL; - -/* ========== MUX object functions ========== - */ -static int -_setup_i2c_value(struct mux_obj_s *self, int offset, int value){ - - return i2c_smbus_write_byte_data(self->i2c_client_p, offset, value); -} - - -static int -_setup_i2c_client(struct mux_obj_s *self, int chan_id, int addr){ - - struct i2c_adapter *adap = NULL; - char *emsg = "ERR"; - - adap = i2c_get_adapter(chan_id); - if (!adap){ - emsg = "can't get adapter"; - goto err_setup_i2c_client; - } - self->i2c_client_p = kzalloc(sizeof(*self->i2c_client_p), GFP_KERNEL); - if (!self->i2c_client_p){ - emsg = "can't kzalloc client"; - goto err_setup_i2c_client; - } - self->i2c_client_p->adapter = adap; - self->i2c_client_p->addr = addr; - return 0; - -err_setup_i2c_client: - SWPS_ERR("%s: %s\n", __func__, emsg); - return ERR_MUX_UNEXCPT; -} - - -int -_common_force_pull_gpio(int mem_addr, - int input, - int bit_offset){ - - unsigned int val = 0; - unsigned int targ = 0; - - /* Get current value */ - val = inl(mem_addr); - if (val == 0) { - SWPS_ERR("%s: inl:%d fail!\n", __func__, val); - return -1; - } - /* Count target value */ - switch (input) { - case 0: /* Pull Low */ - targ = (val & (~(1 << bit_offset))); - break; - case 1: /* Pull high */ - targ = (val | (1 << bit_offset)); - break; - default: - SWPS_ERR("%s: input state:%d incorrect!\n", - __func__, input); - return -1; - } - /* Setup gpio */ - outl(targ, mem_addr); - if (targ != inl(mem_addr)){ - SWPS_ERR("%s: outl:%d fail!\n", __func__, targ); - return -1; - } - SWPS_DEBUG("%s: done.\n", __func__); - return 0; -} - - -int -rangeley_force_pull_high(struct mux_obj_s *self){ - SWPS_ERR("%s: not ready!\n", __func__); - return -1; -} - - -int -rangeley_force_pull_low(struct mux_obj_s *self){ - SWPS_ERR("%s: not ready!\n", __func__); - return -1; -} - - -int -hedera_force_pull_high(struct mux_obj_s *self){ - return _common_force_pull_gpio(MUX_RST_MEM_ADDR_HEDERA, 1, 5); -} - - -int -hedera_force_pull_low(struct mux_obj_s *self){ - return _common_force_pull_gpio(MUX_RST_MEM_ADDR_HEDERA, 0, 5); -} - - -int -normal_gpio_pull_high(struct mux_obj_s *self){ - return gpio_direction_output(self->gpio_num, 1); -} - - -int -normal_gpio_pull_low(struct mux_obj_s *self){ - return gpio_direction_output(self->gpio_num, 0); -} - - -int -cpld_rst_all_4_pull_low(struct mux_obj_s *self){ - - char *emsg = "ERR"; - int err = ERR_MUX_UNEXCPT; - - switch(self->gpio_num) { - case MUX_RST_CPLD_C0_A77_70_74_RST_ALL: - goto setlow_cpld_rst_all_4_c0_a77_70_74_rst_all; - - default: - break; - } - emsg = "Undefined case"; - goto err_cpld_rst_all_4_pull_low; - -setlow_cpld_rst_all_4_c0_a77_70_74_rst_all: - err = _setup_i2c_value(self, 0x70, 0x0); - if (err < 0) { - emsg = "setup 0x70 fail"; - goto err_cpld_rst_all_4_pull_low; - } - err = _setup_i2c_value(self, 0x74, 0x01); - if (err < 0) { - emsg = "setup 0x74 fail"; - goto err_cpld_rst_all_4_pull_low; - } - return 0; - -err_cpld_rst_all_4_pull_low: - SWPS_INFO("%s: %s :%d :%d\n", - __func__, emsg, self->gpio_num, err); - return ERR_MUX_UNEXCPT; -} - - -int -cpld_rst_all_4_pull_high(struct mux_obj_s *self){ - - char *emsg = "ERR"; - int err = ERR_MUX_UNEXCPT; - - switch(self->gpio_num) { - case MUX_RST_CPLD_C0_A77_70_74_RST_ALL: - goto sethigh_cpld_rst_all_4_c0_a77_70_74_rst_all; - - default: - break; - } - emsg = "Undefined case"; - goto err_cpld_rst_all_4_pull_high; - -sethigh_cpld_rst_all_4_c0_a77_70_74_rst_all: - err = _setup_i2c_value(self, 0x70, 0xfe); - if (err < 0) { - emsg = "setup 0x70 fail"; - goto err_cpld_rst_all_4_pull_high; - } - err = _setup_i2c_value(self, 0x74, 0x03); - if (err < 0) { - emsg = "setup 0x74 fail"; - goto err_cpld_rst_all_4_pull_high; - } - return 0; - -err_cpld_rst_all_4_pull_high: - SWPS_INFO("%s: %s :%d :%d\n", - __func__, emsg, self->gpio_num, err); - return ERR_MUX_UNEXCPT; -} - - -int -pca9548_reset_mux_all(struct mux_obj_s *self){ - /* [Note] Power-on reset (PCA9548A-NXP) - * When power is applied to VDD, an internal Power-On Reset (POR) - * holds the PCA9548A in a reset condition until VDD has reached - * VPOR. At this point, the reset condition is released and the - * PCA9548A register and I2C-bus state machine are initialized to - * their default states (all zeroes) causing all the channels to - * be deselected. Thereafter, VDD must be lowered below 0.2 V for - * at least 5 us in order to reset the device. - */ - if (self->_pull_low(self) < 0) { - SWPS_ERR("%s: _pull_low fail!\n", __func__); - return -1; - } - mdelay(MUX_RST_WAIT_MS_PCA9548); - if (self->_pull_high(self) < 0) { - SWPS_ERR("%s: _pull_high fail!\n", __func__); - return -1; - } - mdelay(MUX_RST_WAIT_MS_PCA9548); - return 0; -} - - -int -cpld_reset_mux_all(struct mux_obj_s *self){ - - char *emsg = "ERR"; - int err = ERR_MUX_UNEXCPT; - - switch(self->gpio_num) { - case MUX_RST_CPLD_C0_A77_70_74_RST_ALL: - goto reset_cpld_rst_all_4_c0_a77_70_74_rst_all; - - default: - break; - } - emsg = "Undefined case"; - goto err_cpld_reset_mux_all; - -reset_cpld_rst_all_4_c0_a77_70_74_rst_all: - if (self->_pull_low(self) < 0) { - emsg = "_pull_low fail"; - goto err_cpld_reset_mux_all; - } - mdelay(MUX_RST_WAIT_MS_CPLD); - return 0; - -err_cpld_reset_mux_all: - SWPS_INFO("%s: %s :%d :%d\n", - __func__, emsg, self->gpio_num, err); - return ERR_MUX_UNEXCPT; -} - - -int -common_reset_mux_all(struct mux_obj_s *self){ - SWPS_ERR("%s: not ready!\n", __func__); - return -1; -} - - -int -init_gpio_4_force(struct mux_obj_s *self){ - - if (self->_pull_high(self) < 0) { - SWPS_ERR("%s: setup default fail!\n", __func__); - return -1; - } - return 0; -} - - -int -init_gpio_4_normal(struct mux_obj_s *self){ - - int err = 0; - char *emsg = "ERR"; - - if (!gpio_is_valid(self->gpio_num)) { - emsg = "GPIO invalid"; - goto err_init_gpio_4_normal; - } - err = gpio_request(self->gpio_num, MUX_GPIO_LABEL); - if (err < 0) { - emsg = "gpio_request fail"; - goto err_init_gpio_4_normal; - } - err = self->_pull_high(self); - if (err < 0) { - emsg = "setup default fail"; - goto err_init_gpio_4_normal; - } - SWPS_DEBUG("%s: gpio_request:%d ok.\n", __func__, self->gpio_num); - return 0; - -err_init_gpio_4_normal: - SWPS_ERR("%s: %s :%d :%d\n", - __func__, emsg, self->gpio_num, err); - return -1; -} - - -int -init_cpld_4_rst_all(struct mux_obj_s *self){ - - char *emsg = "ERR"; - int err = ERR_MUX_UNEXCPT; - int chan = ERR_MUX_UNEXCPT; - int addr = ERR_MUX_UNEXCPT; - - switch(self->gpio_num) { - case MUX_RST_CPLD_C0_A77_70_74_RST_ALL: - goto init_cpld_i2c_c0_a77_70_74_rst_all; - - default: - break; - } - emsg = "Undefined case"; - goto err_init_cpld_4_rst_all; - -init_cpld_i2c_c0_a77_70_74_rst_all: - chan = 0; - addr = 0x77; - err = _setup_i2c_client(self, chan, addr); - if (err < 0) { - emsg = "_setup_i2c_client fail"; - goto err_init_cpld_4_rst_all; - } - err = self->_pull_high(self); - if (err < 0) { - emsg = "setup default value fail"; - goto err_init_cpld_4_rst_all; - } - SWPS_DEBUG("%s: init_cpld_i2c_c0_a77_70_74_rst_all ok", __func__); - return 0; - -err_init_cpld_4_rst_all: - SWPS_INFO("%s: %s :%d :%d\n", - __func__, emsg, self->gpio_num, err); - return ERR_MUX_UNEXCPT; -} - - -int -clean_gpio_4_common(struct mux_obj_s *self){ - - if (!self) return 0; - if (!gpio_is_valid(self->gpio_num)) return 0; - self->_pull_high(self); - gpio_free(mux_head_p->gpio_num); - return 0; -} - - -int -clean_cpld_4_rst_all(struct mux_obj_s *self){ - - if (!self) return 0; - self->_pull_high(self); - if (self->i2c_client_p) { - i2c_put_adapter(self->i2c_client_p->adapter); - kfree(self->i2c_client_p); - } - return 0; -} - - -static int -_setup_muxctl_cb(struct mux_obj_s *self, - unsigned gpio){ - - char mod_dsc[32] = "ERR"; - - switch (gpio) { - case MUX_RST_GPIO_FORCE_RANGELEY: - self->gpio_num = gpio; - self->_pull_low = rangeley_force_pull_low; - self->_pull_high = rangeley_force_pull_high; - self->_init = init_gpio_4_force; - self->_clean = clean_gpio_4_common; - self->reset = pca9548_reset_mux_all; - memset(mod_dsc, 0, 32); - snprintf(mod_dsc, 31, "Rangeley force mode"); - goto ok_setup_muxctl_cb; - - case MUX_RST_GPIO_FORCE_HEDERA: - self->gpio_num = gpio; - self->_pull_low = hedera_force_pull_low; - self->_pull_high = hedera_force_pull_high; - self->_init = init_gpio_4_force; - self->_clean = clean_gpio_4_common; - self->reset = pca9548_reset_mux_all; - memset(mod_dsc, 0, 32); - snprintf(mod_dsc, 31, "Hedera force mode"); - goto ok_setup_muxctl_cb; - - case MUX_RST_GPIO_48_PCA9548: - case MUX_RST_GPIO_69_PCA9548: - case MUX_RST_GPIO_249_PCA9548: - case MUX_RST_GPIO_500_PCA9548: - case MUX_RST_GPIO_505_PCA9548: - self->gpio_num = gpio; - self->_pull_low = normal_gpio_pull_low; - self->_pull_high = normal_gpio_pull_high; - self->_init = init_gpio_4_normal; - self->_clean = clean_gpio_4_common; - self->reset = pca9548_reset_mux_all; - memset(mod_dsc, 0, 32); - snprintf(mod_dsc, 31, "Normal mode :%d", (int)gpio); - goto ok_setup_muxctl_cb; - - case MUX_RST_CPLD_C0_A77_70_74_RST_ALL: - self->gpio_num = gpio; - self->_pull_low = cpld_rst_all_4_pull_low; - self->_pull_high = cpld_rst_all_4_pull_high; - self->_init = init_cpld_4_rst_all; - self->_clean = clean_cpld_4_rst_all; - self->reset = cpld_reset_mux_all; - memset(mod_dsc, 0, 32); - snprintf(mod_dsc, 31, "CPLD mode :%d", (int)gpio); - goto ok_setup_muxctl_cb; - - default: - break; - } - SWPS_ERR("%s: Unexpected GPIO:%d\n", __func__, gpio); - return -1; - -ok_setup_muxctl_cb: - SWPS_INFO("muxctl: %s.\n", mod_dsc); - return 0; -} - - -/* ========== MUX public functions ========== - */ -void -clean_mux_objs(void){ - - struct mux_obj_s *curr_p = mux_head_p; - struct mux_obj_s *next_p = NULL; - - if (!curr_p) { - SWPS_DEBUG("%s: mux_head_p is NULL\n", __func__); - return; - } - while (curr_p) { - next_p = curr_p->next; - curr_p->_clean(curr_p); - kfree(curr_p); - curr_p = next_p; - } - SWPS_DEBUG("%s: done.\n", __func__); -} -EXPORT_SYMBOL(clean_mux_objs); - - -int -reset_mux_objs(void){ - - if (!mux_head_p) { - SWPS_ERR("%s: MUX ctl object doesn't exist!\n", __func__); - return -1; - } - if (mux_head_p->reset(mux_head_p) < 0){ - SWPS_ERR("%s: reset fail!\n", __func__); - return -1; - } - return 0; -} -EXPORT_SYMBOL(reset_mux_objs); - - -struct mux_obj_s * -_create_mux_obj(unsigned gpio){ - - char *emsg = "ERR"; - struct mux_obj_s *obj_p = NULL; - - obj_p = kzalloc(sizeof(struct mux_obj_s), GFP_KERNEL); - if (!obj_p) { - emsg = "kzalloc fail!"; - goto err_create_mux_obj_1; - } - if (_setup_muxctl_cb(obj_p, gpio) < 0){ - emsg = "_setup_muxctl_cb fail!"; - goto err_create_mux_obj_2; - } - if (obj_p->_init(obj_p) < 0) { - emsg = "_init() fail!"; - goto err_create_mux_obj_2; - } - SWPS_DEBUG("%s: created MUX object :%d\n", __func__, gpio); - return obj_p; - -err_create_mux_obj_2: - kfree(obj_p); -err_create_mux_obj_1: - SWPS_ERR("%s: %s :%d\n", __func__, emsg, gpio); - return NULL; -} - - -int -init_mux_objs(unsigned gpio){ - - struct mux_obj_s *curr_p = NULL; - char *emsg = "ERR"; - - /* Create MUX control object */ - if (mux_head_p) { - SWPS_DEBUG("%s: mux_head_p is not NULL!\n", __func__); - clean_mux_objs(); - } - /* Currently, it is using single muxctl architecture. - * In the future, it may use the multi-muxctl. - * (Ex: Gulmohar's advance I2C control / Peony's reset single mux) - */ - curr_p = _create_mux_obj(gpio); - if (!curr_p) { - emsg = "_create_mux_obj fail"; - goto err_init_mux_objs; - } - curr_p->next = NULL; - mux_head_p = curr_p; - SWPS_DEBUG("%s: all done. :%d\n", __func__, gpio); - return 0; - -err_init_mux_objs: - clean_mux_objs(); - SWPS_ERR("%s: %s\n", __func__, emsg); - return -1; -} -EXPORT_SYMBOL(init_mux_objs); - - -/* For single ko module - * => You need to declare MODULE_LICENSE If you want to build single module along. - * => Ex: For ONL platform - */ -MODULE_LICENSE("GPL"); - - - diff --git a/packages/platforms/inventec/x86-64/d6332/modules/builds/src/inv_mux.h b/packages/platforms/inventec/x86-64/d6332/modules/builds/src/inv_mux.h deleted file mode 100644 index a913b24c6..000000000 --- a/packages/platforms/inventec/x86-64/d6332/modules/builds/src/inv_mux.h +++ /dev/null @@ -1,51 +0,0 @@ -#ifndef INV_MUX_H -#define INV_MUX_H - -#include - -/* MUX basic information */ -#define MUX_GPIO_LABEL "SWPS_RST_MUX" - -/* MUX reset GPIO define */ -#define MUX_RST_GPIO_FORCE (30100) -#define MUX_RST_GPIO_FORCE_RANGELEY (30101) -#define MUX_RST_GPIO_FORCE_HEDERA (30102) -#define MUX_RST_GPIO_48_PCA9548 (48) -#define MUX_RST_GPIO_69_PCA9548 (69) -#define MUX_RST_GPIO_249_PCA9548 (249) -#define MUX_RST_GPIO_500_PCA9548 (500) -#define MUX_RST_GPIO_505_PCA9548 (505) -#define MUX_RST_CPLD_C0_A77_70_74_RST_ALL (30201) - -/* MUX relate value define */ -#define MUX_RST_WAIT_MS_PCA9548 (1) -#define MUX_RST_WAIT_MS_CPLD (10) -#define MUX_RST_MEM_ADDR_RANGELEY (0) // TBD -#define MUX_RST_MEM_ADDR_HEDERA (0x548) - -/* MUX error code define */ -#define ERR_MUX_UNEXCPT (-399) - -struct mux_obj_s { - struct i2c_client *i2c_client_p; - struct mux_obj_s *next; - unsigned gpio_num; - int (*_pull_high)(struct mux_obj_s *self); - int (*_pull_low)(struct mux_obj_s *self); - int (*_init)(struct mux_obj_s *self); - int (*_clean)(struct mux_obj_s *self); - int (*reset)(struct mux_obj_s *self); -}; - - -void clean_mux_objs(void); -int reset_mux_objs(void); -int init_mux_objs(unsigned gpio); - - -#endif /* INV_MUX_H */ - - - - - diff --git a/packages/platforms/inventec/x86-64/d6332/modules/builds/src/inv_platform.c b/packages/platforms/inventec/x86-64/d6332/modules/builds/src/inv_platform.c deleted file mode 100644 index 994bd7e81..000000000 --- a/packages/platforms/inventec/x86-64/d6332/modules/builds/src/inv_platform.c +++ /dev/null @@ -1,209 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include - -struct inv_i2c_board_info { - int ch; - int size; - struct i2c_board_info *board_info; - int probe; -}; - -#define bus_id(id) (id) -static struct pca954x_platform_mode mux_modes_0[] = { - {.adap_id = bus_id(2),}, {.adap_id = bus_id(3),}, -}; - -static struct pca954x_platform_mode mux_modes_1[] = { - {.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),}, - {.adap_id = bus_id(10),}, {.adap_id = bus_id(11),}, -}; - -static struct pca954x_platform_mode mux_modes_2_0[] = { - {.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),}, - {.adap_id = bus_id(18),}, {.adap_id = bus_id(19),}, -}; - -static struct pca954x_platform_mode mux_modes_2_1[] = { - {.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),}, - {.adap_id = bus_id(26),}, {.adap_id = bus_id(27),}, -}; - -static struct pca954x_platform_mode mux_modes_2_2[] = { - {.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),}, - {.adap_id = bus_id(34),}, {.adap_id = bus_id(35),}, -}; - -static struct pca954x_platform_mode mux_modes_2_3[] = { - {.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),}, - {.adap_id = bus_id(42),}, {.adap_id = bus_id(43),}, -}; - - -static struct pca954x_platform_data mux_data_0 = { - .modes = mux_modes_0, - .num_modes = 2, -}; - -static struct pca954x_platform_data mux_data_1 = { - .modes = mux_modes_1, - .num_modes = 8, -}; - -static struct pca954x_platform_data mux_data_2_0 = { - .modes = mux_modes_2_0, - .num_modes = 8, -}; -static struct pca954x_platform_data mux_data_2_1 = { - .modes = mux_modes_2_1, - .num_modes = 8, -}; -static struct pca954x_platform_data mux_data_2_2 = { - .modes = mux_modes_2_2, - .num_modes = 8, -}; -static struct pca954x_platform_data mux_data_2_3 = { - .modes = mux_modes_2_3, - .num_modes = 8, -}; - -static struct i2c_board_info i2c_device_info0[] __initdata = { - {"inv_cpld", 0, 0x77, 0, 0, 0}, // CPLD driver -// {"24c512", 0, 0x55, 0, 0, 0}, // OEM1 VPD -// {"24c512", 0, 0x54, 0, 0, 0}, // OEM2 VPD - {"pca9543", 0, 0x73, &mux_data_0, 0, 0}, // MUX -}; - -static struct i2c_board_info i2c_device_info1[] __initdata = { - {"pca9548", 0, 0x70, &mux_data_1, 0, 0}, -}; - -static struct i2c_board_info i2c_device_info2[] __initdata ={ - {"ucd90160", 0, 0x34, 0, 0 ,0}, -}; - -static struct i2c_board_info i2c_device_info11[] __initdata ={ - {"pmbus", 0, 0x5A, 0, 0 ,0}, //PSU1 DVT - {"pmbus", 0, 0x5B, 0, 0 ,0}, //PSU2 DVT -}; - -static struct i2c_board_info i2c_device_info3[] __initdata ={ - {"tmp75", 0, 0x48, 0, 0 ,0}, //CPU Board Temperature - {"tmp75", 0, 0x4A, 0, 0 ,0}, //Front Panel Inlet Temperature - {"tmp75", 0, 0x4D, 0, 0 ,0}, - {"tmp75", 0, 0x4E, 0, 0 ,0}, //Near ASIC Temperature -}; - -static struct i2c_board_info i2c_device_info4[] __initdata = { - {"pca9548", 0, 0x72, &mux_data_2_0, 0, 0}, -}; -static struct i2c_board_info i2c_device_info5[] __initdata = { - {"pca9548", 0, 0x72, &mux_data_2_1, 0, 0}, -}; -static struct i2c_board_info i2c_device_info6[] __initdata = { - {"pca9548", 0, 0x72, &mux_data_2_2, 0, 0}, -}; -static struct i2c_board_info i2c_device_info7[] __initdata = { - {"pca9548", 0, 0x72, &mux_data_2_3, 0, 0}, -}; - -static struct inv_i2c_board_info i2cdev_list[] = { - {bus_id(0), ARRAY_SIZE(i2c_device_info0), i2c_device_info0 , 0}, //i2c-0 smbus - {bus_id(0), ARRAY_SIZE(i2c_device_info1), i2c_device_info1 , 1}, //i2c-0 smbus (for DVT) - {bus_id(1), ARRAY_SIZE(i2c_device_info1), i2c_device_info1 , 1}, //i2c-1 i2c-gpio (for EVT) - {bus_id(3), ARRAY_SIZE(i2c_device_info3), i2c_device_info3 , 0}, //mux 0x73 channel 1 - {bus_id(2), ARRAY_SIZE(i2c_device_info2), i2c_device_info2 , 0}, //mux 0x73 channel 0 - {bus_id(2), ARRAY_SIZE(i2c_device_info11), i2c_device_info11, 1}, //mux 0x73 channel 0 - {bus_id(4), ARRAY_SIZE(i2c_device_info4), i2c_device_info4 , 1}, //mux 0x70 channel 0 - {bus_id(5), ARRAY_SIZE(i2c_device_info5), i2c_device_info5 , 1}, //mux 0x70 channel 1 - {bus_id(6), ARRAY_SIZE(i2c_device_info6), i2c_device_info6 , 1}, //mux 0x70 channel 2 - {bus_id(7), ARRAY_SIZE(i2c_device_info7), i2c_device_info7 , 1}, //mux 0x70 channel 3 -}; - -static struct platform_device *device_i2c_gpio0; -static struct i2c_gpio_platform_data i2c_gpio_platdata0 = { - .scl_pin = 58, //494, - .sda_pin = 75, //511, - - .udelay = 5, //5:100kHz - .sda_is_open_drain = 0, - .scl_is_open_drain = 0, - .scl_is_output_only = 0 -}; - -static int __init inv_platform_init(void) -{ - struct i2c_adapter *adap = NULL; - struct i2c_client *e = NULL; - int ret = 0; - int i,j,k; - - //use i2c-gpio - //register gpio - outl( inl(0x533) | (1<<2), 0x533); //i2c-gpio sdl(58) - outl( inl(0x541) | (1<<3), 0x541); //i2c gpio sda(75) - outl( inl(0x540) | (1<<5), 0x540); //RST_I2C_MUX_N(69) - outl( inl(0x503) | (1)|(1<<2)|(1<<3), 0x503); //WDT_IRQ_N(24) PSOC_HEART_BEAT(26) CPLD_HEART_BEAT(27) - outl( inl(0x501) | (1<<4), 0x501); //RSTBTN_IN_N(12) - outl( inl(0x533) | (1<<5), 0x533); //RST_BTN_5S_N(61) - - device_i2c_gpio0 = platform_device_alloc("i2c-gpio", 1); - if (!device_i2c_gpio0) { - printk(KERN_ERR "i2c-gpio: platform_device_alloc fail\n"); - return -ENOMEM; - } - device_i2c_gpio0->name = "i2c-gpio"; - device_i2c_gpio0->id = 1; - device_i2c_gpio0->dev.platform_data = &i2c_gpio_platdata0; - ret = platform_device_add(device_i2c_gpio0); - - for(i=0; idev.platform_data = NULL; - platform_device_unregister(device_i2c_gpio0); -} - -module_init(inv_platform_init); -module_exit(inv_platform_exit); - -MODULE_AUTHOR("Inventec"); -MODULE_DESCRIPTION("Switch Platform devices"); -MODULE_LICENSE("GPL"); diff --git a/packages/platforms/inventec/x86-64/d6332/modules/builds/src/inv_swps.c b/packages/platforms/inventec/x86-64/d6332/modules/builds/src/inv_swps.c deleted file mode 100644 index cce1bad65..000000000 --- a/packages/platforms/inventec/x86-64/d6332/modules/builds/src/inv_swps.c +++ /dev/null @@ -1,3288 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "inv_swps.h" - -static int ctl_major; -static int port_major; -static int ioexp_total; -static int port_total; -static int block_polling; -static int auto_config; -static int flag_i2c_reset; -static int flag_mod_state; -static unsigned gpio_rest_mux; -static int gpio_base = 0; -static struct class *swp_class_p = NULL; -static struct inv_platform_s *platform_p = NULL; -static struct inv_ioexp_layout_s *ioexp_layout = NULL; -static struct inv_port_layout_s *port_layout = NULL; -int io_no_init = 0; -module_param(io_no_init, int, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP); -static void swp_polling_worker(struct work_struct *work); -static DECLARE_DELAYED_WORK(swp_polling, swp_polling_worker); - -static int reset_i2c_topology(void); - -static int -__swp_match(struct device *dev, -#ifdef SWPS_KERN_VER_AF_3_10 - - const void *data){ -#else - void *data){ -#endif - - char *name = (char *)data; - if (strcmp(dev_name(dev), name) == 0) - return 1; - return 0; -} - - -struct device * -get_swpdev_by_name(char *name){ - struct device *dev = class_find_device(swp_class_p, - NULL, - name, - __swp_match); - return dev; -} - - -static int -sscanf_2_int(const char *buf) { - - int result = -EBFONT; - char *hex_tag = "0x"; - - if (strcspn(buf, hex_tag) == 0) { - if (sscanf(buf,"%x",&result)) { - return result; - } - } else { - if (sscanf(buf,"%d",&result)) { - return result; - } - if(sscanf(buf,"-%d",&result)) { - return -result; - } - if (sscanf(buf,"%x",&result)) { - return result; - } - } - return -EBFONT; -} - - -static int -sscanf_2_binary(const char *buf) { - - int result = sscanf_2_int(buf); - - if (result < 0){ - return -EBFONT; - } - switch (result) { - case 0: - case 1: - return result; - default: - break; - } - return -EBFONT; -} - - -static int -_get_polling_period(void) { - - int retval = 0; - - if (SWP_POLLING_PERIOD == 0) { - return 0; - } - retval = ((SWP_POLLING_PERIOD * HZ) / 1000); - if (retval == 0) { - return 1; - } - return retval; -} - - -static struct transvr_obj_s * -_get_transvr_obj(char *dev_name) { - - struct device *dev_p = NULL; - struct transvr_obj_s *transvr_obj_p = NULL; - - dev_p = get_swpdev_by_name(dev_name); - if (!dev_p){ - return NULL; - } - transvr_obj_p = dev_get_drvdata(dev_p); - if (!transvr_obj_p){ - return NULL; - } - return transvr_obj_p; -} - - -static int -_is_i2c_target_exist(int chan, int addr) { - /* retval: Exist = 1 / Not exist = 0 / Error < 0 - */ - struct i2c_adapter *adap = NULL; - struct i2c_client *client = NULL; - int retval = -1; - int err = -1; - int d_offs = 0; - - adap = i2c_get_adapter(chan); - if (!adap) { - SWPS_DEBUG("%s: can't get adapter\n", __func__); - retval = 0; - goto out_is_i2c_target_exist_1; - } - client = kzalloc(sizeof(*client), GFP_KERNEL); - if (!client) { - SWPS_ERR("%s: kzalloc fail\n", __func__); - retval = -1; - goto out_is_i2c_target_exist_2; - } - client->adapter = adap; - client->addr = addr; - err = i2c_smbus_read_byte_data(client, d_offs); - if (err < 0) { - retval = 0; - } else { - retval = 1; - } - i2c_put_adapter(adap); - kfree(client); - return retval; - -out_is_i2c_target_exist_2: - i2c_put_adapter(adap); -out_is_i2c_target_exist_1: - return retval; -} - - -static void -unlock_tobj_all(void) { - - struct transvr_obj_s *tobj_p; - char port_name[32]; - int port_id = 0; - int minor_curr = 0; - - for (minor_curr=0; minor_currauto_config = auto_config; - unlock_transvr_obj(tobj_p); - SWPS_DEBUG("%s: Set %s auto_config=%d\n", - __func__, tobj_p->swp_name, auto_config); - } - return retval; -} - - -/* ========== R/W Functions module control attribute ========== - */ -static ssize_t -show_attr_platform(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - return snprintf(buf_p, 32, "%s\n", platform_p->name); -} - - -static ssize_t -show_attr_version(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - return snprintf(buf_p, 8, "%s\n", SWP_VERSION); -} - - -static ssize_t -show_attr_status(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - return snprintf(buf_p, 8, "%d\n", flag_mod_state); -} - - -static ssize_t -show_attr_auto_config(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - return snprintf(buf_p, 8, "%d\n", auto_config); -} - - -static ssize_t -show_attr_block_poll(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - return snprintf(buf_p, 8, "%d\n", block_polling); -} -static ssize_t -show_attr_io_no_init(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - return snprintf(buf_p, 8, "%d\n", io_no_init); -} - - -static int -_check_reset_pwd(const char *buf_p, - size_t count) { - - int in_max = 64; - int in_len = (int)count; - char in_val[64] = "ERR"; - char *emsg = "ERR"; - - if (in_len >= in_max) { - emsg = "input too much"; - goto err_check_reset_pwd; - } - if (!sscanf(buf_p,"%s",in_val)) { - emsg = "format incorrect"; - goto err_check_reset_pwd; - } - if (strcmp(in_val, SWP_RESET_PWD) != 0) { - emsg = "password incorrect"; - goto err_check_reset_pwd; - } - return 0; - -err_check_reset_pwd: - SWPS_ERR("%s: %s\n", __func__, emsg); - return -1; -} - - -static ssize_t -store_attr_reset_i2c(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - - if (_check_reset_pwd(buf_p, count) < 0) { - return -EBFONT; - } - /* Polling mode */ - if (SWP_POLLING_ENABLE) { - SWPS_INFO("%s: reset I2C :polling\n", __func__); - flag_i2c_reset = 1; - return count; - } - /* Direct mode */ - SWPS_INFO("%s: reset I2C go. :direct\n", __func__); - if (reset_i2c_topology() < 0) { - SWPS_ERR("%s: reset fail!\n", __func__); - return -EIO; - } - SWPS_INFO("%s: reset I2C ok. :direct\n", __func__); - return count; -} - - -static ssize_t -store_attr_reset_swps(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - - struct transvr_obj_s *tobj_p; - char port_name[32] = "ERR"; - int port_id = 0; - int minor_curr = 0; - - if (_check_reset_pwd(buf_p, count) < 0) { - return -EBFONT; - } - for (minor_curr=0; minor_currstate = STATE_TRANSVR_DISCONNECTED; - unlock_transvr_obj(tobj_p); - SWPS_INFO("%s: reset:%s\n", __func__, tobj_p->swp_name); - } - return count; -} - - -static ssize_t -store_attr_auto_config(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - - int input_val = sscanf_2_int(buf_p); - - if (input_val < 0){ - return -EBFONT; - } - if ((input_val != 0) && (input_val != 1)) { - return -EBFONT; - } - auto_config = input_val; - _update_auto_config_2_trnasvr(); - return count; -} - - -static ssize_t -store_attr_block_poll( struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - - int input_val = sscanf_2_int(buf_p); - - if (input_val < 0){ - return -EBFONT; - } - if ((input_val != 0) && (input_val != 1)) { - return -EBFONT; - } - - if(input_val != block_polling){ - block_polling = input_val; - if(block_polling){ - cancel_delayed_work_sync(&swp_polling); - } - else{ - schedule_delayed_work(&swp_polling, _get_polling_period()); - } - } - - return count; -} - -static ssize_t -store_attr_io_no_init( struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - - int input_val = sscanf_2_int(buf_p); - - if ((input_val != 0) && (input_val != 1)) { - return -EBFONT; - } - - if(input_val != io_no_init){ - io_no_init = input_val; - } - - return count; -} - -/* ========== Show functions: For transceiver attribute ========== - */ -static ssize_t -_show_transvr_hex_attr(struct transvr_obj_s* tobj_p, - int (*get_func)(struct transvr_obj_s* tobj_p), - char *buf_p) { - size_t len; - int result; - - lock_transvr_obj(tobj_p); - result = get_func(tobj_p); - unlock_transvr_obj(tobj_p); - if (result < 0){ - len = snprintf(buf_p, 8, "%d\n", result); - } else { - len = snprintf(buf_p, 8, "0x%02x\n", result); - } - return len; -} - - -static ssize_t -_show_transvr_int_attr(struct transvr_obj_s* tobj_p, - int (*get_func)(struct transvr_obj_s* tobj_p), - char *buf_p) { - size_t len; - - lock_transvr_obj(tobj_p); - len = snprintf(buf_p, 16, "%d\n", get_func(tobj_p)); - unlock_transvr_obj(tobj_p); - return len; -} - - -static ssize_t -_show_transvr_str_attr(struct transvr_obj_s* tobj_p, - int (*get_func)(struct transvr_obj_s* tobj_p, char* buf), - char *buf_p) { - size_t len; - - lock_transvr_obj(tobj_p); - len = get_func(tobj_p, buf_p); - unlock_transvr_obj(tobj_p); - return len; -} - - -static ssize_t -show_attr_id(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_hex_attr(tobj_p, - tobj_p->get_id, - buf_p); -} - - -static ssize_t -show_attr_ext_id(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_hex_attr(tobj_p, - tobj_p->get_ext_id, - buf_p); -} - - -static ssize_t -show_attr_connector(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_hex_attr(tobj_p, - tobj_p->get_connector, - buf_p); -} - - -static ssize_t -show_attr_vendor_name(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_vendor_name, - buf_p); -} - - -static ssize_t -show_attr_vendor_pn(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_vendor_pn, - buf_p); -} - - -static ssize_t -show_attr_vendor_rev(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_vendor_rev, - buf_p); -} - - -static ssize_t -show_attr_vendor_sn(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_vendor_sn, - buf_p); -} - - -static ssize_t -show_attr_power_cls(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - size_t len; - int result; - struct transvr_obj_s *tobj_p; - - tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - lock_transvr_obj(tobj_p); - result = tobj_p->get_power_cls(tobj_p); - unlock_transvr_obj(tobj_p); - if (result < 0){ - len = snprintf(buf_p, 16, "%d\n", result); - } else { - len = snprintf(buf_p, 16, "Power Class %d\n", result); - } - return len; -} - - -static ssize_t -show_attr_br(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_hex_attr(tobj_p, - tobj_p->get_br, - buf_p); -} - - -static ssize_t -show_attr_len_sm(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_int_attr(tobj_p, - tobj_p->get_len_sm, - buf_p); -} - - -static ssize_t -show_attr_len_smf(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_int_attr(tobj_p, - tobj_p->get_len_smf, - buf_p); -} - - -static ssize_t -show_attr_len_om1(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_int_attr(tobj_p, - tobj_p->get_len_om1, - buf_p); -} - - -static ssize_t -show_attr_len_om2(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_int_attr(tobj_p, - tobj_p->get_len_om2, - buf_p); -} - - -static ssize_t -show_attr_len_om3(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_int_attr(tobj_p, - tobj_p->get_len_om3, - buf_p); -} - - -static ssize_t -show_attr_len_om4(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_int_attr(tobj_p, - tobj_p->get_len_om4, - buf_p); -} - - -static ssize_t -show_attr_comp_rev(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_hex_attr(tobj_p, - tobj_p->get_comp_rev, - buf_p); -} - - -static ssize_t -show_attr_comp_eth(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_hex_attr(tobj_p, - tobj_p->get_comp_eth_1, - buf_p); -} - - -static ssize_t -show_attr_comp_eth_10(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_hex_attr(tobj_p, - tobj_p->get_comp_eth_10, - buf_p); -} - - -static ssize_t -show_attr_comp_eth_10_40(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_hex_attr(tobj_p, - tobj_p->get_comp_eth_10_40, - buf_p); -} - - -static ssize_t -show_attr_comp_extend(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_hex_attr(tobj_p, - tobj_p->get_comp_extend, - buf_p); -} - - -static ssize_t -show_attr_rate_id(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_hex_attr(tobj_p, - tobj_p->get_rate_id, - buf_p); -} - - -static ssize_t -show_attr_temperature(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_curr_temp, - buf_p); -} - - -static ssize_t -show_attr_voltage(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_curr_vol, - buf_p); -} - - -static ssize_t -show_attr_tx_bias(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_tx_bias, - buf_p); -} - - -static ssize_t -show_attr_tx_power(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_tx_power, - buf_p); -} - - -static ssize_t -show_attr_tx_eq(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_tx_eq, - buf_p); -} - - -static ssize_t -show_attr_rx_power(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_rx_power, - buf_p); -} - - -static ssize_t -show_attr_rx_am(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_rx_am, - buf_p); -} - - -static ssize_t -show_attr_rx_em(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_rx_em, - buf_p); -} - - -static ssize_t -show_attr_wavelength(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_wavelength, - buf_p); -} - - -static ssize_t -show_attr_extphy_offset(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_extphy_offset, - buf_p); -} - - -static ssize_t -show_attr_extphy_reg(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_extphy_reg, - buf_p); -} - - -static ssize_t -show_attr_info(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_int_attr(tobj_p, - tobj_p->get_info, - buf_p); -} - - -static ssize_t -show_attr_if_type(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_if_type, - buf_p); -} - - -static ssize_t -show_attr_if_speed(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_if_speed, - buf_p); -} - - -static ssize_t -show_attr_if_lane(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_if_lane, - buf_p); -} - - -static ssize_t -show_attr_cdr(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_hex_attr(tobj_p, - tobj_p->get_cdr, - buf_p); -} - - -static ssize_t -show_attr_soft_rs0(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_int_attr(tobj_p, - tobj_p->get_soft_rs0, - buf_p); -} - - -static ssize_t -show_attr_soft_rs1(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_int_attr(tobj_p, - tobj_p->get_soft_rs1, - buf_p); -} - - -static ssize_t -show_attr_soft_rx_los(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_soft_rx_los, - buf_p); -} - - -static ssize_t -show_attr_soft_tx_disable(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_soft_tx_disable, - buf_p); -} - - -static ssize_t -show_attr_soft_tx_fault(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_soft_tx_fault, - buf_p); -} - - -static ssize_t -show_attr_auto_tx_disable(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_auto_tx_disable, - buf_p); -} - - -/* ========== Store functions: transceiver (R/W) attribute ========== - */ -static ssize_t -_store_transvr_int_attr(struct transvr_obj_s* tobj_p, - int (*set_func)(struct transvr_obj_s *tobj_p, int input_val), - const char *buf_p, - size_t count) { - int input, err; - - input = sscanf_2_int(buf_p); - if (input < 0){ - return -EBFONT; - } - lock_transvr_obj(tobj_p); - err = set_func(tobj_p, input); - unlock_transvr_obj(tobj_p); - if (err < 0){ - return err; - } - return count; -} - - -static ssize_t -_store_transvr_byte_hex_attr(struct transvr_obj_s* tobj_p, - int (*set_func)(struct transvr_obj_s *tobj_p, int input_val), - const char *buf_p, - size_t count) { - int input, err; - - input = sscanf_2_int(buf_p); - if ((input < 0) || (input > 0xff)){ - return -EBFONT; - } - lock_transvr_obj(tobj_p); - err = set_func(tobj_p, input); - unlock_transvr_obj(tobj_p); - if (err < 0){ - return err; - } - return count; -} - - -static ssize_t -_store_transvr_binary_attr(struct transvr_obj_s* tobj_p, - int (*set_func)(struct transvr_obj_s *tobj_p, int input_val), - const char *buf_p, - size_t count) { - int input, err; - - input = sscanf_2_binary(buf_p); - if (input < 0){ - return -EBFONT; - } - lock_transvr_obj(tobj_p); - err = set_func(tobj_p, input); - unlock_transvr_obj(tobj_p); - if (err < 0){ - return err; - } - return count; -} - - -static ssize_t -store_attr_cdr(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - return _store_transvr_byte_hex_attr(tobj_p, - tobj_p->set_cdr, - buf_p, - count); -} - - -static ssize_t -store_attr_soft_rs0(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - return _store_transvr_binary_attr(tobj_p, - tobj_p->set_soft_rs0, - buf_p, - count); -} - - -static ssize_t -store_attr_soft_rs1(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - return _store_transvr_binary_attr(tobj_p, - tobj_p->set_soft_rs1, - buf_p, - count); -} - - -static ssize_t -store_attr_soft_tx_disable(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count) { - - int check = sscanf_2_int(buf_p); - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - if ((check < 0) || (check > 0xf)){ - return -EBFONT; - } - return _store_transvr_byte_hex_attr(tobj_p, - tobj_p->set_soft_tx_disable, - buf_p, - count); -} - - -static ssize_t -store_attr_auto_tx_disable(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count) { - - int err = -EPERM; - int input = sscanf_2_int(buf_p); - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - if ((input < 0) || (input > 0xf)){ - if (input != VAL_TRANSVR_FUNCTION_DISABLE) { - return -EBFONT; - } - } - lock_transvr_obj(tobj_p); - err = tobj_p->set_auto_tx_disable(tobj_p, input); - unlock_transvr_obj(tobj_p); - if (err < 0){ - return err; - } - return count; -} - - -static ssize_t -store_attr_tx_eq(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - return _store_transvr_int_attr(tobj_p, - tobj_p->set_tx_eq, - buf_p, - count); -} - - -static ssize_t -store_attr_rx_am(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - return _store_transvr_int_attr(tobj_p, - tobj_p->set_rx_am, - buf_p, - count); -} - - -static ssize_t -store_attr_rx_em(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - return _store_transvr_int_attr(tobj_p, - tobj_p->set_rx_em, - buf_p, - count); -} - - -static ssize_t -store_attr_extphy_offset(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - return _store_transvr_int_attr(tobj_p, - tobj_p->set_extphy_offset, - buf_p, - count); -} - - -static ssize_t -store_attr_extphy_reg(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - return _store_transvr_int_attr(tobj_p, - tobj_p->set_extphy_reg, - buf_p, - count); -} - -/* ========== Show functions: For I/O Expander attribute ========== - */ -static ssize_t -_show_ioexp_binary_attr(struct transvr_obj_s *tobj_p, - int (*get_func)(struct ioexp_obj_s *ioexp_p, int voffset), - char *buf_p) { - size_t len; - struct ioexp_obj_s *ioexp_p = tobj_p->ioexp_obj_p; - - if (!ioexp_p) { - SWPS_ERR(" %s: data corruption! :%s\n", __func__, tobj_p->swp_name); - return -ENODATA; - } - mutex_lock(&ioexp_p->lock); - len = snprintf(buf_p, 8, "%d\n", get_func(ioexp_p, tobj_p->ioexp_virt_offset)); - mutex_unlock(&ioexp_p->lock); - return len; -} - - -static ssize_t -show_attr_present(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - return _show_ioexp_binary_attr(tobj_p, - tobj_p->ioexp_obj_p->get_present, - buf_p); -} - - -static ssize_t -show_attr_tx_fault(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - return _show_ioexp_binary_attr(tobj_p, - tobj_p->ioexp_obj_p->get_tx_fault, - buf_p); -} - - -static ssize_t -show_attr_rxlos(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - return _show_ioexp_binary_attr(tobj_p, - tobj_p->ioexp_obj_p->get_rxlos, - buf_p); -} - - -static ssize_t -show_attr_tx_disable(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - return _show_ioexp_binary_attr(tobj_p, - tobj_p->ioexp_obj_p->get_tx_disable, - buf_p); -} - - -static ssize_t -show_attr_reset(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - return _show_ioexp_binary_attr(tobj_p, - tobj_p->ioexp_obj_p->get_reset, - buf_p); -} - - -static ssize_t -show_attr_lpmod(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - return _show_ioexp_binary_attr(tobj_p, - tobj_p->ioexp_obj_p->get_lpmod, - buf_p); -} - - -static ssize_t -show_attr_modsel(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - return _show_ioexp_binary_attr(tobj_p, - tobj_p->ioexp_obj_p->get_modsel, - buf_p); -} - - -static ssize_t -show_attr_hard_rs0(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - return _show_ioexp_binary_attr(tobj_p, - tobj_p->ioexp_obj_p->get_hard_rs0, - buf_p); -} - - -static ssize_t -show_attr_hard_rs1(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - return _show_ioexp_binary_attr(tobj_p, - tobj_p->ioexp_obj_p->get_hard_rs1, - buf_p); -} - - -/* ========== Store functions: For I/O Expander (R/W) attribute ========== - */ -static ssize_t -_store_ioexp_binary_attr(struct transvr_obj_s *tobj_p, - int (*set_func)(struct ioexp_obj_s *ioexp_p, - int virt_offset, int input_val), - const char *buf_p, - size_t count) { - - int input, err; - struct ioexp_obj_s *ioexp_p = tobj_p->ioexp_obj_p; - - if (!ioexp_p) { - SWPS_ERR("%s: data corruption! :%s\n", - __func__, tobj_p->swp_name); - return -ENODATA; - } - input = sscanf_2_binary(buf_p); - if (input < 0) { - return -EBFONT; - } - mutex_lock(&ioexp_p->lock); - err = set_func(ioexp_p, tobj_p->ioexp_virt_offset, input); - mutex_unlock(&ioexp_p->lock); - if (err < 0){ - return err; - } - return count; -} - -static ssize_t -store_attr_tx_disable(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p) { - return -ENODEV; - } - return _store_ioexp_binary_attr(tobj_p, - tobj_p->ioexp_obj_p->set_tx_disable, - buf_p, - count); -} - - -static ssize_t -store_attr_reset(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p) { - return -ENODEV; - } - return _store_ioexp_binary_attr(tobj_p, - tobj_p->ioexp_obj_p->set_reset, - buf_p, - count); -} - - -static ssize_t -store_attr_lpmod(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p) { - return -ENODEV; - } - return _store_ioexp_binary_attr(tobj_p, - tobj_p->ioexp_obj_p->set_lpmod, - buf_p, - count); -} - - -static ssize_t -store_attr_modsel(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p) { - return -ENODEV; - } - return _store_ioexp_binary_attr(tobj_p, - tobj_p->ioexp_obj_p->set_modsel, - buf_p, - count); -} - - -static ssize_t -store_attr_hard_rs0(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p) { - return -ENODEV; - } - return _store_ioexp_binary_attr(tobj_p, - tobj_p->ioexp_obj_p->set_hard_rs0, - buf_p, - count); -} - - -static ssize_t -store_attr_hard_rs1(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p) { - return -ENODEV; - } - return _store_ioexp_binary_attr(tobj_p, - tobj_p->ioexp_obj_p->set_hard_rs1, - buf_p, - count); -} - - -/* ========== SWPS attribute: For module control ========== - */ -static DEVICE_ATTR(platform, S_IRUGO, show_attr_platform, NULL); -static DEVICE_ATTR(version, S_IRUGO, show_attr_version, NULL); -static DEVICE_ATTR(status, S_IRUGO, show_attr_status, NULL); -static DEVICE_ATTR(reset_i2c, S_IWUSR, NULL, store_attr_reset_i2c); -static DEVICE_ATTR(reset_swps, S_IWUSR, NULL, store_attr_reset_swps); -static DEVICE_ATTR(auto_config, S_IRUGO|S_IWUSR, show_attr_auto_config, store_attr_auto_config); -static DEVICE_ATTR(block_poll, S_IRUGO|S_IWUSR, show_attr_block_poll, store_attr_block_poll); -static DEVICE_ATTR(io_no_init, S_IRUGO|S_IWUSR, show_attr_io_no_init, store_attr_io_no_init); - - -/* ========== Transceiver attribute: from eeprom ========== - */ -static DEVICE_ATTR(id, S_IRUGO, show_attr_id, NULL); -static DEVICE_ATTR(ext_id, S_IRUGO, show_attr_ext_id, NULL); -static DEVICE_ATTR(connector, S_IRUGO, show_attr_connector, NULL); -static DEVICE_ATTR(vendor_name, S_IRUGO, show_attr_vendor_name, NULL); -static DEVICE_ATTR(vendor_pn, S_IRUGO, show_attr_vendor_pn, NULL); -static DEVICE_ATTR(vendor_rev, S_IRUGO, show_attr_vendor_rev, NULL); -static DEVICE_ATTR(vendor_sn, S_IRUGO, show_attr_vendor_sn, NULL); -static DEVICE_ATTR(power_cls, S_IRUGO, show_attr_power_cls, NULL); -static DEVICE_ATTR(br, S_IRUGO, show_attr_br, NULL); -static DEVICE_ATTR(len_sm, S_IRUGO, show_attr_len_sm, NULL); -static DEVICE_ATTR(len_smf, S_IRUGO, show_attr_len_smf, NULL); -static DEVICE_ATTR(len_om1, S_IRUGO, show_attr_len_om1, NULL); -static DEVICE_ATTR(len_om2, S_IRUGO, show_attr_len_om2, NULL); -static DEVICE_ATTR(len_om3, S_IRUGO, show_attr_len_om3, NULL); -static DEVICE_ATTR(len_om4, S_IRUGO, show_attr_len_om4, NULL); -static DEVICE_ATTR(comp_rev, S_IRUGO, show_attr_comp_rev, NULL); -static DEVICE_ATTR(comp_eth, S_IRUGO, show_attr_comp_eth, NULL); -static DEVICE_ATTR(comp_eth_10, S_IRUGO, show_attr_comp_eth_10, NULL); -static DEVICE_ATTR(comp_eth_10_40, S_IRUGO, show_attr_comp_eth_10_40, NULL); -static DEVICE_ATTR(comp_extend, S_IRUGO, show_attr_comp_extend, NULL); -static DEVICE_ATTR(rate_id, S_IRUGO, show_attr_rate_id, NULL); -static DEVICE_ATTR(temperature, S_IRUGO, show_attr_temperature, NULL); -static DEVICE_ATTR(voltage, S_IRUGO, show_attr_voltage, NULL); -static DEVICE_ATTR(tx_bias, S_IRUGO, show_attr_tx_bias, NULL); -static DEVICE_ATTR(tx_power, S_IRUGO, show_attr_tx_power, NULL); -static DEVICE_ATTR(rx_power, S_IRUGO, show_attr_rx_power, NULL); -static DEVICE_ATTR(info, S_IRUGO, show_attr_info, NULL); -static DEVICE_ATTR(if_type, S_IRUGO, show_attr_if_type, NULL); -static DEVICE_ATTR(if_speed, S_IRUGO, show_attr_if_speed, NULL); -static DEVICE_ATTR(if_lane, S_IRUGO, show_attr_if_lane, NULL); -static DEVICE_ATTR(soft_rx_los, S_IRUGO, show_attr_soft_rx_los, NULL); -static DEVICE_ATTR(soft_tx_fault, S_IRUGO, show_attr_soft_tx_fault, NULL); -static DEVICE_ATTR(wavelength, S_IRUGO, show_attr_wavelength, NULL); -static DEVICE_ATTR(tx_eq, S_IRUGO|S_IWUSR, show_attr_tx_eq, store_attr_tx_eq); -static DEVICE_ATTR(rx_am, S_IRUGO|S_IWUSR, show_attr_rx_am, store_attr_rx_am); -static DEVICE_ATTR(rx_em, S_IRUGO|S_IWUSR, show_attr_rx_em, store_attr_rx_em); -static DEVICE_ATTR(cdr, S_IRUGO|S_IWUSR, show_attr_cdr, store_attr_cdr); -static DEVICE_ATTR(soft_rs0, S_IRUGO|S_IWUSR, show_attr_soft_rs0, store_attr_soft_rs0); -static DEVICE_ATTR(soft_rs1, S_IRUGO|S_IWUSR, show_attr_soft_rs1, store_attr_soft_rs1); -static DEVICE_ATTR(soft_tx_disable, S_IRUGO|S_IWUSR, show_attr_soft_tx_disable, store_attr_soft_tx_disable); -static DEVICE_ATTR(auto_tx_disable, S_IRUGO|S_IWUSR, show_attr_auto_tx_disable, store_attr_auto_tx_disable); -static DEVICE_ATTR(extphy_offset, S_IRUGO|S_IWUSR, show_attr_extphy_offset, store_attr_extphy_offset); -static DEVICE_ATTR(extphy_reg, S_IRUGO|S_IWUSR, show_attr_extphy_reg, store_attr_extphy_reg); - -/* ========== IO Expander attribute: from expander ========== - */ -static DEVICE_ATTR(present, S_IRUGO, show_attr_present, NULL); -static DEVICE_ATTR(tx_fault, S_IRUGO, show_attr_tx_fault, NULL); -static DEVICE_ATTR(rxlos, S_IRUGO, show_attr_rxlos, NULL); -static DEVICE_ATTR(tx_disable, S_IRUGO|S_IWUSR, show_attr_tx_disable, store_attr_tx_disable); -static DEVICE_ATTR(reset, S_IRUGO|S_IWUSR, show_attr_reset, store_attr_reset); -static DEVICE_ATTR(lpmod, S_IRUGO|S_IWUSR, show_attr_lpmod, store_attr_lpmod); -static DEVICE_ATTR(modsel, S_IRUGO|S_IWUSR, show_attr_modsel, store_attr_modsel); -static DEVICE_ATTR(hard_rs0, S_IRUGO|S_IWUSR, show_attr_hard_rs0, store_attr_hard_rs0); -static DEVICE_ATTR(hard_rs1, S_IRUGO|S_IWUSR, show_attr_hard_rs1, store_attr_hard_rs1); - -/* ========== Functions for module handling ========== - */ -static void -clean_port_objs(void){ - - dev_t dev_num; - char dev_name[32]; - struct device *device_p; - struct transvr_obj_s *tobj_p; - int minor_curr, port_id; - - for (minor_curr=0; minor_curri2c_client_p) { - i2c_put_adapter(tobj_p->i2c_client_p->adapter); - kfree(tobj_p->i2c_client_p); - } - kfree(tobj_p->vendor_name); - kfree(tobj_p->vendor_pn); - kfree(tobj_p->vendor_rev); - kfree(tobj_p->vendor_sn); - kfree(tobj_p->worker_p); - kfree(tobj_p); - } - dev_num = MKDEV(port_major, minor_curr); - device_unregister(device_p); - device_destroy(swp_class_p, dev_num); - } - SWPS_DEBUG("%s: done.\n", __func__); -} - - -static void -clean_swps_common(void){ - - dev_t dev_num; - struct device *device_p; - - device_p = get_swpdev_by_name(SWP_DEV_MODCTL); - if (device_p){ - dev_num = MKDEV(ctl_major, 1); - device_unregister(device_p); - device_destroy(swp_class_p, dev_num); - } - cancel_delayed_work_sync(&swp_polling); - if (platform_p) { - kfree(platform_p); - } - SWPS_DEBUG("%s: done.\n", __func__); -} - - -static int -get_platform_type(void){ - - int i, tmp; - int auto_chan = -1; - int auto_addr = -1; - int pf_total = ARRAY_SIZE(platform_map); - char log_msg[64] = "ERROR"; - - platform_p = kzalloc(sizeof(struct inv_platform_s), GFP_KERNEL); - if (!platform_p){ - snprintf(log_msg, sizeof(log_msg), "kzalloc fail"); - goto err_get_platform_type_1; - } - memset(platform_p->name, 0, sizeof(platform_p->name)); - - switch (PLATFORM_SETTINGS) { - case PLATFORM_TYPE_AUTO: - snprintf(platform_p->name, (sizeof(platform_p->name) - 1), - "%s", dmi_get_system_info(DMI_BOARD_NAME)); - for (i=0; iname, platform_map[i].name) == 0) { - platform_p->id = platform_map[i].id; - snprintf(log_msg, sizeof(log_msg), - "Auto detect platform: %d (%s)", - platform_p->id, platform_p->name); - goto ok_get_platform_type_1; - } - } - snprintf(log_msg, sizeof(log_msg), - "Auto detect fail! detect platform: %s", - platform_p->name); - goto err_get_platform_type_2; - - case PLATFORM_TYPE_PEONY_AUTO: -#ifdef SWPS_PEONY_SFP - auto_chan = peony_sfp_ioexp_layout[0].addr[0].chan_id; - auto_addr = peony_sfp_ioexp_layout[0].addr[0].chip_addr; -#endif - tmp = _is_i2c_target_exist(auto_chan, auto_addr); - switch (tmp) { - case 0: /* Copper SKU */ - SWPS_INFO("Auto-detected :Peony :Copper\n"); - platform_p->id = PLATFORM_TYPE_PEONY_COPPER_GA; - goto map_platform_name; - - case 1: /* SFP SKU */ - SWPS_INFO("Auto-detected :Peony :SFP\n"); - platform_p->id = PLATFORM_TYPE_PEONY_SFP_GA; - goto map_platform_name; - - default: - break; - } - snprintf(log_msg, sizeof(log_msg), - "Auto detect Peony SKU fail! :%d", tmp); - goto err_get_platform_type_2; - - case PLATFORM_TYPE_MAGNOLIA: - case PLATFORM_TYPE_MAGNOLIA_FNC: - case PLATFORM_TYPE_REDWOOD: - case PLATFORM_TYPE_REDWOOD_FSL: - case PLATFORM_TYPE_HUDSON32I_GA: - case PLATFORM_TYPE_SPRUCE: - case PLATFORM_TYPE_CYPRESS_GA1: - case PLATFORM_TYPE_CYPRESS_GA2: - case PLATFORM_TYPE_CYPRESS_BAI: - case PLATFORM_TYPE_TAHOE: - case PLATFORM_TYPE_SEQUOIA_GA: - case PLATFORM_TYPE_LAVENDER_GA: - case PLATFORM_TYPE_LAVENDER_ONL: - case PLATFORM_TYPE_COTTONWOOD_RANGELEY: - case PLATFORM_TYPE_MAPLE_GA: - case PLATFORM_TYPE_MAPLE_B: - case PLATFORM_TYPE_MAPLE_J: - case PLATFORM_TYPE_GULMOHAR_GA: - case PLATFORM_TYPE_GULMOHAR_2T_EVT1_GA: - case PLATFORM_TYPE_PEONY_SFP_GA: - case PLATFORM_TYPE_PEONY_COPPER_GA: - case PLATFORM_TYPE_CEDAR_GA: - platform_p->id = PLATFORM_SETTINGS; - goto map_platform_name; - - default: - break; - } - snprintf(log_msg, sizeof(log_msg), - "PLATFORM_SETTINGS:%d undefined", PLATFORM_SETTINGS); - goto err_get_platform_type_2; - -map_platform_name: - for (i=0; iid == platform_map[i].id) { - snprintf(platform_p->name, (sizeof(platform_p->name) - 1), - "%s", platform_map[i].name); - snprintf(log_msg, sizeof(log_msg), - "User setup platform: %d (%s)", - platform_p->id, platform_p->name); - goto ok_get_platform_type_1; - } - } - snprintf(log_msg, sizeof(log_msg), - "Internal error, can not map id:%d", - platform_p->id ); - goto err_get_platform_type_2; - -ok_get_platform_type_1: - SWPS_DEBUG("%s: %s, :%d\n", __func__, log_msg, PLATFORM_SETTINGS); - return 0; - -err_get_platform_type_2: - kfree(platform_p); -err_get_platform_type_1: - SWPS_ERR("%s: %s :%d\n", __func__, log_msg, PLATFORM_SETTINGS); - return -1; -} - - -static int -get_layout_info(void){ - - switch (platform_p->id) { -#ifdef SWPS_MAGNOLIA - case PLATFORM_TYPE_MAGNOLIA: - case PLATFORM_TYPE_MAGNOLIA_FNC: - gpio_rest_mux = gpio_base + magnolia_gpio_rest_mux; - ioexp_layout = magnolia_ioexp_layout; - port_layout = magnolia_port_layout; - ioexp_total = ARRAY_SIZE(magnolia_ioexp_layout); - port_total = ARRAY_SIZE(magnolia_port_layout); - break; -#endif -#ifdef SWPS_REDWOOD - case PLATFORM_TYPE_REDWOOD: - gpio_rest_mux = gpio_base + redwood_gpio_rest_mux; - ioexp_layout = redwood_ioexp_layout; - port_layout = redwood_port_layout; - ioexp_total = ARRAY_SIZE(redwood_ioexp_layout); - port_total = ARRAY_SIZE(redwood_port_layout); - break; -#endif -#ifdef SWPS_HUDSON32I_GA - case PLATFORM_TYPE_HUDSON32I_GA: - gpio_rest_mux = gpio_base + hudsin32iga_gpio_rest_mux; - ioexp_layout = hudson32iga_ioexp_layout; - port_layout = hudson32iga_port_layout; - ioexp_total = ARRAY_SIZE(hudson32iga_ioexp_layout); - port_total = ARRAY_SIZE(hudson32iga_port_layout); - break; -#endif -#ifdef SWPS_SPRUCE - case PLATFORM_TYPE_SPRUCE: - gpio_rest_mux = gpio_base + spruce_gpio_rest_mux; - ioexp_layout = spruce_ioexp_layout; - port_layout = spruce_port_layout; - ioexp_total = ARRAY_SIZE(spruce_ioexp_layout); - port_total = ARRAY_SIZE(spruce_port_layout); - break; -#endif -#ifdef SWPS_CYPRESS_GA1 - case PLATFORM_TYPE_CYPRESS_GA1: - gpio_rest_mux = gpio_base + cypress_ga1_gpio_rest_mux; - ioexp_layout = cypress_ga1_ioexp_layout; - port_layout = cypress_ga1_port_layout; - ioexp_total = ARRAY_SIZE(cypress_ga1_ioexp_layout); - port_total = ARRAY_SIZE(cypress_ga1_port_layout); - break; -#endif -#ifdef SWPS_CYPRESS_GA2 - case PLATFORM_TYPE_CYPRESS_GA2: - gpio_rest_mux = gpio_base + cypress_ga2_gpio_rest_mux; - ioexp_layout = cypress_ga2_ioexp_layout; - port_layout = cypress_ga2_port_layout; - ioexp_total = ARRAY_SIZE(cypress_ga2_ioexp_layout); - port_total = ARRAY_SIZE(cypress_ga2_port_layout); - break; -#endif -#ifdef SWPS_CYPRESS_BAI - case PLATFORM_TYPE_CYPRESS_BAI: - gpio_rest_mux = gpio_base + cypress_b_gpio_rest_mux; - ioexp_layout = cypress_b_ioexp_layout; - port_layout = cypress_b_port_layout; - ioexp_total = ARRAY_SIZE(cypress_b_ioexp_layout); - port_total = ARRAY_SIZE(cypress_b_port_layout); - break; -#endif -#ifdef SWPS_REDWOOD_FSL - case PLATFORM_TYPE_REDWOOD_FSL: - gpio_rest_mux = gpio_base + redwood_fsl_gpio_rest_mux; - ioexp_layout = redwood_fsl_ioexp_layout; - port_layout = redwood_fsl_port_layout; - ioexp_total = ARRAY_SIZE(redwood_fsl_ioexp_layout); - port_total = ARRAY_SIZE(redwood_fsl_port_layout); - break; -#endif -#ifdef SWPS_TAHOE - case PLATFORM_TYPE_TAHOE: - gpio_rest_mux = gpio_base + tahoe_gpio_rest_mux; - ioexp_layout = tahoe_ioexp_layout; - port_layout = tahoe_port_layout; - ioexp_total = ARRAY_SIZE(tahoe_ioexp_layout); - port_total = ARRAY_SIZE(tahoe_port_layout); - break; -#endif -#ifdef SWPS_SEQUOIA - case PLATFORM_TYPE_SEQUOIA_GA: - gpio_rest_mux = gpio_base + sequoia_gpio_rest_mux; - ioexp_layout = sequoia_ioexp_layout; - port_layout = sequoia_port_layout; - ioexp_total = ARRAY_SIZE(sequoia_ioexp_layout); - port_total = ARRAY_SIZE(sequoia_port_layout); - break; -#endif -#ifdef SWPS_LAVENDER - case PLATFORM_TYPE_LAVENDER_GA: - case PLATFORM_TYPE_LAVENDER_ONL: - gpio_rest_mux = gpio_base + lavender_gpio_rest_mux; - ioexp_layout = lavender_ioexp_layout; - port_layout = lavender_port_layout; - ioexp_total = ARRAY_SIZE(lavender_ioexp_layout); - port_total = ARRAY_SIZE(lavender_port_layout); - break; -#endif -#ifdef SWPS_COTTONWOOD_RANGELEY - case PLATFORM_TYPE_COTTONWOOD_RANGELEY: - gpio_rest_mux = gpio_base + cottonwood_rangeley_gpio_rest_mux; - ioexp_layout = cottonwood_rangeley_ioexp_layout; - port_layout = cottonwood_rangeley_port_layout; - ioexp_total = ARRAY_SIZE(cottonwood_rangeley_ioexp_layout); - port_total = ARRAY_SIZE(cottonwood_rangeley_port_layout); - break; -#endif -#ifdef SWPS_MAPLE_GA - case PLATFORM_TYPE_MAPLE_GA: - gpio_rest_mux = gpio_base + maple_ga_gpio_rest_mux; - ioexp_layout = maple_ga_ioexp_layout; - port_layout = maple_ga_port_layout; - ioexp_total = ARRAY_SIZE(maple_ga_ioexp_layout); - port_total = ARRAY_SIZE(maple_ga_port_layout); - break; -#endif -#ifdef SWPS_MAPLE_B - case PLATFORM_TYPE_MAPLE_B: - gpio_rest_mux = gpio_base + maple_b_gpio_rest_mux; - ioexp_layout = maple_b_ioexp_layout; - port_layout = maple_b_port_layout; - ioexp_total = ARRAY_SIZE(maple_b_ioexp_layout); - port_total = ARRAY_SIZE(maple_b_port_layout); - break; -#endif -#ifdef SWPS_MAPLE_J - case PLATFORM_TYPE_MAPLE_J: - gpio_rest_mux = gpio_base + maple_j_gpio_rest_mux; - ioexp_layout = maple_j_ioexp_layout; - port_layout = maple_j_port_layout; - ioexp_total = ARRAY_SIZE(maple_j_ioexp_layout); - port_total = ARRAY_SIZE(maple_j_port_layout); - break; -#endif -#ifdef SWPS_GULMOHAR - case PLATFORM_TYPE_GULMOHAR_GA: - gpio_rest_mux = gpio_base + gulmohar_gpio_rest_mux; - ioexp_layout = gulmohar_ioexp_layout; - port_layout = gulmohar_port_layout; - ioexp_total = ARRAY_SIZE(gulmohar_ioexp_layout); - port_total = ARRAY_SIZE(gulmohar_port_layout); - break; -#endif -#ifdef SWPS_GULMOHAR_2T_EVT1 - case PLATFORM_TYPE_GULMOHAR_2T_EVT1_GA: - gpio_rest_mux = gpio_base + gulmohar_2t_evt1_gpio_rest_mux; - ioexp_layout = gulmohar_2t_evt1_ioexp_layout; - port_layout = gulmohar_2t_evt1_port_layout; - ioexp_total = ARRAY_SIZE(gulmohar_2t_evt1_ioexp_layout); - port_total = ARRAY_SIZE(gulmohar_2t_evt1_port_layout); - break; -#endif -#ifdef SWPS_PEONY_SFP - case PLATFORM_TYPE_PEONY_SFP_GA: - gpio_rest_mux = gpio_base + peony_sfp_gpio_rest_mux; - ioexp_layout = peony_sfp_ioexp_layout; - port_layout = peony_sfp_port_layout; - ioexp_total = ARRAY_SIZE(peony_sfp_ioexp_layout); - port_total = ARRAY_SIZE(peony_sfp_port_layout); - break; -#endif -#ifdef SWPS_PEONY_COPPER - case PLATFORM_TYPE_PEONY_COPPER_GA: - gpio_rest_mux = gpio_base + peony_copper_gpio_rest_mux; - ioexp_layout = peony_copper_ioexp_layout; - port_layout = peony_copper_port_layout; - ioexp_total = ARRAY_SIZE(peony_copper_ioexp_layout); - port_total = ARRAY_SIZE(peony_copper_port_layout); - break; -#endif -#ifdef SWPS_CEDAR_GA - case PLATFORM_TYPE_CEDAR_GA: - gpio_rest_mux = gpio_base + cedar_ga_gpio_rest_mux; - ioexp_layout = cedar_ga_ioexp_layout; - port_layout = cedar_ga_port_layout; - ioexp_total = ARRAY_SIZE(cedar_ga_ioexp_layout); - port_total = ARRAY_SIZE(cedar_ga_port_layout); - break; -#endif - - default: - SWPS_ERR(" Invalid platform: %d (%s)\n", - platform_p->id, platform_p->name); - return -1; - } - SWPS_INFO("Start to initial platform: %d (%s)\n", - platform_p->id, platform_p->name); - return 0; -} - - -/* ========== Functions for objects operations ========== - */ -static int -__detect_issues_port(int minor_num) { - - struct transvr_obj_s *tobj_p; - int port_id = port_layout[minor_num].port_id; - char port_name[32] = "ERR"; - char *i2c_emsg = "detected bad transceiver/cable"; - - memset(port_name, 0, sizeof(port_name)); - snprintf(port_name, sizeof(port_name), "%s%d", SWP_DEV_PORT, port_id); - tobj_p = _get_transvr_obj(port_name); - if (!tobj_p) { - SWPS_INFO("%s: tobj_p is NULL :%d\n", __func__, minor_num); - return -1; - } - if (resync_channel_tier_2(tobj_p) < 0) { - if (check_channel_tier_1() < 0) { - goto get_target_issues_port; - } - } - /* Re-check again for i2c-gpio special case */ - if (check_channel_tier_1() < 0) { - goto get_target_issues_port; - } - return 0; - -get_target_issues_port: - alarm_msg_2_user(tobj_p, i2c_emsg); - return -2; -} - - -static int -_detect_issues_port(void) { - /* OK : retrun -1; - * Fail: return fail at which minor number (0~N) - */ - char *emsg = "ERR"; - int minor = 0; - int minor_2st = 1; - - /* Force moving the initial channel pointer - * Filter out case of fail at minor-0 port - */ - while (minor_2st < port_total) { - minor = minor_2st; - if (__detect_issues_port(minor_2st) < 0) { - emsg = "detect minor_2st fail"; - goto err_p_detect_issues_port; - } - minor_2st += 8; - } - /* Scan all port */ - for (minor=0; minor:%d\n", __func__, emsg, minor_err); - return -1; -} - - -static int -check_transvr_obj_one(char *dev_name){ - /* [Return] - * 0 : Doesn't need to take care - * -1 : Single error - * -2 : Critical error (I2C topology die) - * -9 : Internal error - */ - struct transvr_obj_s *tobj_p = NULL; - int retval = -9; - - tobj_p = _get_transvr_obj(dev_name); - if (!tobj_p) { - SWPS_ERR("%s: %s _get_transvr_obj fail\n", - __func__, dev_name); - return -9; - } - /* Check transceiver current status */ - lock_transvr_obj(tobj_p); - retval = tobj_p->check(tobj_p); - unlock_transvr_obj(tobj_p); - switch (retval) { - case 0: - case ERR_TRANSVR_UNPLUGGED: - case ERR_TRNASVR_BE_ISOLATED: - case ERR_TRANSVR_TASK_BUSY: - return 0; - - case ERR_TRANSVR_I2C_CRASH: - default: - break; - } - /* Identify abnormal case */ - if (check_channel_tier_1() < 0) { - SWPS_DEBUG("%s: %s critical error :%d\n", - __func__, dev_name, retval); - return -2; - } - SWPS_DEBUG("%s: %s single error :%d\n", - __func__, dev_name, retval); - return -1; -} - - -static int -check_transvr_objs(void){ - - char dev_name[32]; - int port_id, err_code; - int minor_curr = 0; - - for (minor_curr=0; minor_curr:%d\n", - __func__, dev_name, err_code); - break; - } - } - return 0; - -err_check_transvr_objs: - SWPS_ERR("%s: %s reset_i2c_topology fail.\n", - __func__, dev_name); - return -1; -} - - -static void -swp_polling_worker(struct work_struct *work){ - - /* Reset I2C */ - if (flag_i2c_reset) { - goto polling_reset_i2c; - } - /* Check IOEXP */ - if (check_ioexp_objs() < 0) { - goto polling_reset_i2c; - } - /* Check transceiver */ - if (check_transvr_objs() < 0) { - SWPS_DEBUG("%s: check_transvr_objs fail.\n", __func__); - flag_i2c_reset = 1; - } - goto polling_schedule_round; - -polling_reset_i2c: - SWPS_DEBUG("%s: reset_i2c_topology start.\n", __func__); - if (reset_i2c_topology() < 0) { - SWPS_ERR("%s: reset i2c fail!\n", __func__); - flag_i2c_reset = 1; - } else { - SWPS_DEBUG("%s: reset_i2c_topology OK.\n", __func__); - flag_i2c_reset = 0; - } -polling_schedule_round: - schedule_delayed_work(&swp_polling, _get_polling_period()); -} - - -/* ========== Functions for register something ========== - */ -static int -register_transvr_common_attr(struct device *device_p){ - - char *err_attr = NULL; - - if (device_create_file(device_p, &dev_attr_id) < 0) { - err_attr = "dev_attr_id"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_ext_id) < 0) { - err_attr = "dev_attr_ext_id"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_connector) < 0) { - err_attr = "dev_attr_connector"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_vendor_name) < 0) { - err_attr = "dev_attr_vendor_name"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_vendor_pn) < 0) { - err_attr = "dev_attr_vendor_pn"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_vendor_rev) < 0) { - err_attr = "dev_attr_vendor_rev"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_vendor_sn) < 0) { - err_attr = "dev_attr_vendor_sn"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_br) < 0) { - err_attr = "dev_attr_br"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_len_smf) < 0) { - err_attr = "dev_attr_len_smf"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_len_om1) < 0) { - err_attr = "dev_attr_len_om1"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_len_om2) < 0) { - err_attr = "dev_attr_len_om2"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_len_om3) < 0) { - err_attr = "dev_attr_len_om3"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_len_om4) < 0) { - err_attr = "dev_attr_len_om4"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_comp_extend) < 0) { - err_attr = "dev_attr_comp_extend"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_comp_eth) < 0) { - err_attr = "dev_attr_comp_eth"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_comp_rev) < 0) { - err_attr = "dev_attr_comp_rev"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_info) < 0) { - err_attr = "dev_attr_info"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_if_type) < 0) { - err_attr = "dev_attr_if_type"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_if_speed) < 0) { - err_attr = "dev_attr_if_speed"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_if_lane) < 0) { - err_attr = "dev_attr_if_lane"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_temperature) < 0) { - err_attr = "dev_attr_temperature"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_voltage) < 0) { - err_attr = "dev_attr_voltage"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_tx_bias) < 0) { - err_attr = "dev_attr_tx_bias"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_tx_power) < 0) { - err_attr = "dev_attr_tx_power"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_rx_power) < 0) { - err_attr = "dev_attr_rx_power"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_tx_eq) < 0) { - err_attr = "dev_attr_tx_eq"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_rx_em) < 0) { - err_attr = "dev_attr_rx_em"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_wavelength) < 0) { - err_attr = "dev_attr_wavelength"; - goto err_transvr_comm_attr; - } - return 0; - -err_transvr_comm_attr: - SWPS_ERR("%s: %s\n", __func__, err_attr); - return -1; -} - -static int -register_transvr_sfp_attr(struct device *device_p){ - - char *err_attr = NULL; - - if (register_transvr_common_attr(device_p) < 0) { - err_attr = "register_transvr_common_attr"; - goto err_transvr_sfp_attr; - } - if (device_create_file(device_p, &dev_attr_comp_eth_10) < 0) { - err_attr = "dev_attr_comp_eth_10"; - goto err_transvr_sfp_attr; - } - if (device_create_file(device_p, &dev_attr_len_sm) < 0) { - err_attr = "dev_attr_len_sm"; - goto err_transvr_sfp_attr; - } - if (device_create_file(device_p, &dev_attr_rate_id) < 0) { - err_attr = "dev_attr_rate_id"; - goto err_transvr_sfp_attr; - } - if (device_create_file(device_p, &dev_attr_soft_rs0) < 0) { - err_attr = "dev_attr_soft_rs0"; - goto err_transvr_sfp_attr; - } - if (device_create_file(device_p, &dev_attr_soft_rs1) < 0) { - err_attr = "dev_attr_soft_rs1"; - goto err_transvr_sfp_attr; - } - if (device_create_file(device_p, &dev_attr_extphy_offset) < 0) { - err_attr = "dev_attr_extphy_offset"; - goto err_transvr_sfp_attr; - } - if (device_create_file(device_p, &dev_attr_extphy_reg) < 0) { - err_attr = "dev_attr_extphy_reg"; - goto err_transvr_sfp_attr; - } - return 0; - -err_transvr_sfp_attr: - SWPS_ERR("%s: %s\n", __func__, err_attr); - return -1; -} - - -static int -register_transvr_qsfp_attr(struct device *device_p){ - - char *err_attr = NULL; - - if (register_transvr_common_attr(device_p) < 0) { - err_attr = "register_transvr_common_attr"; - goto err_transvr_qsfp_attr; - } - if (device_create_file(device_p, &dev_attr_comp_eth_10_40) < 0) { - err_attr = "dev_attr_comp_eth_10_40"; - goto err_transvr_qsfp_attr; - } - if (device_create_file(device_p, &dev_attr_power_cls) < 0) { - err_attr = "dev_attr_power_cls"; - goto err_transvr_qsfp_attr; - } - if (device_create_file(device_p, &dev_attr_soft_rx_los) < 0) { - err_attr = "soft_rx_los"; - goto err_transvr_qsfp_attr; - } - if (device_create_file(device_p, &dev_attr_soft_tx_disable) < 0) { - err_attr = "soft_tx_disable"; - goto err_transvr_qsfp_attr; - } - if (device_create_file(device_p, &dev_attr_auto_tx_disable) < 0) { - err_attr = "auto_tx_disable"; - goto err_transvr_qsfp_attr; - } - if (device_create_file(device_p, &dev_attr_soft_tx_fault) < 0) { - err_attr = "soft_tx_fault"; - goto err_transvr_qsfp_attr; - } - return 0; - -err_transvr_qsfp_attr: - SWPS_ERR("%s: %s\n", __func__, err_attr); - return -1; -} - - -static int -register_transvr_qsfp28_attr(struct device *device_p){ - - char *err_attr = NULL; - - if (register_transvr_qsfp_attr(device_p) < 0){ - err_attr = "register_transvr_qsfp_attr"; - goto err_transvr_qsfp28_attr; - } - if (device_create_file(device_p, &dev_attr_cdr) < 0) { - err_attr = "dev_attr_cdr"; - goto err_transvr_qsfp28_attr; - } - if (device_create_file(device_p, &dev_attr_rx_am) < 0) { - err_attr = "dev_attr_rx_am"; - goto err_transvr_qsfp28_attr; - } - return 0; - -err_transvr_qsfp28_attr: - SWPS_ERR("%s: %s\n", __func__, err_attr); - return -1; -} - - -static int -register_transvr_attr(struct device *device_p, - struct transvr_obj_s *transvr_obj){ - - switch (transvr_obj->layout){ - case TRANSVR_TYPE_SFP: - if (register_transvr_sfp_attr(device_p) < 0){ - goto err_reg_tvr_attr; - } - break; - case TRANSVR_TYPE_QSFP: - case TRANSVR_TYPE_QSFP_PLUS: - if (register_transvr_qsfp_attr(device_p) < 0){ - goto err_reg_tvr_attr; - } - break; - case TRANSVR_TYPE_QSFP_28: - if (register_transvr_qsfp28_attr(device_p) < 0){ - goto err_reg_tvr_attr; - } - break; - default: - goto err_reg_tvr_attr; - } - return 0; - -err_reg_tvr_attr: - SWPS_ERR("%s: fail! type=%d \n", __func__, transvr_obj->type); - return -1; -} - - -static int -register_ioexp_attr_sfp_1(struct device *device_p){ - /* Support machine type: - * - SFP : Magnolia - */ - char *err_attr = NULL; - - if (device_create_file(device_p, &dev_attr_present) < 0) { - err_attr = "dev_attr_present"; - goto err_ioexp_sfp1_attr; - } - if (device_create_file(device_p, &dev_attr_tx_fault) < 0) { - err_attr = "dev_attr_tx_fault"; - goto err_ioexp_sfp1_attr; - } - if (device_create_file(device_p, &dev_attr_rxlos) < 0) { - err_attr = "dev_attr_rxlos"; - goto err_ioexp_sfp1_attr; - } - if (device_create_file(device_p, &dev_attr_tx_disable) < 0) { - err_attr = "dev_attr_tx_disable"; - goto err_ioexp_sfp1_attr; - } - return 0; - -err_ioexp_sfp1_attr: - SWPS_ERR("Add device attribute:%s failure! \n",err_attr); - return -1; -} - - -static int -register_ioexp_attr_sfp_2(struct device *device_p){ - /* Support machine type: - * - SFP28 : Cypress - */ - char *err_attr = NULL; - - if (register_ioexp_attr_sfp_1(device_p) < 0){ - goto err_ioexp_sfp2_attr; - } - if (device_create_file(device_p, &dev_attr_hard_rs0) < 0) { - err_attr = "dev_attr_hard_rs0"; - goto err_ioexp_sfp2_attr; - } - if (device_create_file(device_p, &dev_attr_hard_rs1) < 0) { - err_attr = "dev_attr_hard_rs1"; - goto err_ioexp_sfp2_attr; - } - return 0; - -err_ioexp_sfp2_attr: - SWPS_ERR("Add device attribute:%s failure! \n",err_attr); - return -1; -} - - -static int -register_ioexp_attr_qsfp_1(struct device *device_p){ - /* Support machine type: - * - QSFP : Magnolia, Redwood, Hudson32i - * - QSFP+ : Magnolia, Redwood, Hudson32i - * - QSFP28: Redwood - */ - char *err_attr = NULL; - - if (device_create_file(device_p, &dev_attr_present) < 0) { - err_attr = "dev_attr_present"; - goto err_ioexp_qsfp1_attr; - } - if (device_create_file(device_p, &dev_attr_reset) < 0) { - err_attr = "dev_attr_reset"; - goto err_ioexp_qsfp1_attr; - } - if (device_create_file(device_p, &dev_attr_lpmod) < 0) { - err_attr = "dev_attr_lpmod"; - goto err_ioexp_qsfp1_attr; - } - if (device_create_file(device_p, &dev_attr_modsel) < 0) { - err_attr = "dev_attr_modsel"; - goto err_ioexp_qsfp1_attr; - } - return 0; - -err_ioexp_qsfp1_attr: - SWPS_ERR("Add device attribute:%s failure! \n",err_attr); - return -1; -} - - -static int -register_modctl_attr(struct device *device_p){ - - char *err_msg = NULL; - - if (device_create_file(device_p, &dev_attr_platform) < 0) { - err_msg = "dev_attr_platform"; - goto err_reg_modctl_attr; - } - if (device_create_file(device_p, &dev_attr_version) < 0) { - err_msg = "dev_attr_version"; - goto err_reg_modctl_attr; - } - if (device_create_file(device_p, &dev_attr_status) < 0) { - err_msg = "dev_attr_status"; - goto err_reg_modctl_attr; - } - if (device_create_file(device_p, &dev_attr_reset_i2c) < 0) { - err_msg = "dev_attr_reset_i2c"; - goto err_reg_modctl_attr; - } - if (device_create_file(device_p, &dev_attr_reset_swps) < 0) { - err_msg = "dev_attr_reset_swps"; - goto err_reg_modctl_attr; - } - if (device_create_file(device_p, &dev_attr_auto_config) < 0) { - err_msg = "dev_attr_auto_config"; - goto err_reg_modctl_attr; - } - if (device_create_file(device_p, &dev_attr_block_poll) < 0) { - err_msg = "dev_attr_block_poll"; - goto err_reg_modctl_attr; - } - if (device_create_file(device_p, &dev_attr_io_no_init) < 0) { - err_msg = "dev_attr_io_no_init"; - goto err_reg_modctl_attr; - } - - return 0; - -err_reg_modctl_attr: - SWPS_ERR("%s: %s\n", __func__, err_msg); - return -1; -} - - -static int -register_ioexp_attr(struct device *device_p, - struct transvr_obj_s *transvr_obj){ - - char *err_msg = "ERR"; - - switch (transvr_obj->ioexp_obj_p->ioexp_type){ - case IOEXP_TYPE_MAGINOLIA_NAB: - case IOEXP_TYPE_MAGINOLIA_4AB: - case CPLD_TYPE_COTTONWOOD: - if (register_ioexp_attr_sfp_1(device_p) < 0){ - err_msg = "register_ioexp_attr_sfp_1 fail"; - goto err_reg_ioexp_attr; - } - break; - - case IOEXP_TYPE_MAPLE_NABC: - case IOEXP_TYPE_GULMOHAR_NABC: - case IOEXP_TYPE_GULMOHAR_2T_EVT1_NABC: - case IOEXP_TYPE_GULMOHAR_2T_EVT1_1ABC: - case IOEXP_TYPE_GULMOHAR_2T_EVT1_3ABC: - case IOEXP_TYPE_SFP_8P_LAYOUT_1: - if (register_ioexp_attr_sfp_2(device_p) < 0){ - err_msg = "register_ioexp_attr_sfp_2 fail"; - goto err_reg_ioexp_attr; - } - break; - - case IOEXP_TYPE_MAGINOLIA_7AB: - case IOEXP_TYPE_SPRUCE_7AB: - case IOEXP_TYPE_CYPRESS_7ABC: - case IOEXP_TYPE_REDWOOD_P01P08: - case IOEXP_TYPE_REDWOOD_P09P16: - case IOEXP_TYPE_HUDSON32IGA_P01P08: - case IOEXP_TYPE_HUDSON32IGA_P09P16: - case IOEXP_TYPE_TAHOE_5A: - case IOEXP_TYPE_TAHOE_6ABC: - case IOEXP_TYPE_SEQUOIA_NABC: - case IOEXP_TYPE_LAVENDER_P65: - case IOEXP_TYPE_MAPLE_0ABC: - case IOEXP_TYPE_GULMOHAR_7ABC: - case IOEXP_TYPE_GULMOHAR_2T_EVT1_7ABC: - case IOEXP_TYPE_QSFP_6P_LAYOUT_1: - case IOEXP_TYPE_CEDAR_0ABC: - if (register_ioexp_attr_qsfp_1(device_p) < 0){ - err_msg = "register_ioexp_attr_qsfp_1 fail"; - goto err_reg_ioexp_attr; - } - break; - - default: - err_msg = "Unknow type"; - goto err_reg_ioexp_attr; - } - return 0; - -err_reg_ioexp_attr: - SWPS_ERR("%s: %s :%d \n", - __func__, err_msg, transvr_obj->ioexp_obj_p->ioexp_type); - return -1; -} - - -static int -register_modctl_device(void) { - - struct device *device_p = NULL; - int minor_comm = 0; /* Default minor number for common device */ - dev_t dev_num = MKDEV(ctl_major, minor_comm); - char *err_msg = "ERROR"; - - device_p = device_create(swp_class_p, /* struct class *cls */ - NULL, /* struct device *parent */ - dev_num, /* dev_t devt */ - NULL, /* void *private_data */ - SWP_DEV_MODCTL); /* const char *fmt */ - if (IS_ERR(device_p)){ - err_msg = "device_create fail"; - goto err_register_modctl_device_1; - } - if (register_modctl_attr(device_p) < 0) { - err_msg = "register_modctl_attr fail"; - goto err_register_modctl_device_2; - } - return 0; - -err_register_modctl_device_2: - device_unregister(device_p); - device_destroy(swp_class_p, dev_num); -err_register_modctl_device_1: - SWPS_ERR("%s: %s\n", __func__, err_msg); - return -1; -} - - -static int -register_port_device(char *dev_name, - dev_t dev_num, - struct transvr_obj_s *transvr_obj){ - - struct device *device_p = NULL; - device_p = device_create(swp_class_p, /* struct class *cls */ - NULL, /* struct device *parent */ - dev_num, /* dev_t devt */ - transvr_obj, /* void *private_data */ - dev_name); /* const char *fmt */ - if (IS_ERR(device_p)){ - goto err_regswp_create_dev; - } - if (register_transvr_attr(device_p, transvr_obj) < 0){ - goto err_regswp_reg_attr; - } - if (register_ioexp_attr(device_p, transvr_obj) < 0){ - goto err_regswp_reg_attr; - } - return 0; - -err_regswp_reg_attr: - device_unregister(device_p); - device_destroy(swp_class_p, dev_num); -err_regswp_create_dev: - SWPS_ERR("%s fail! :%s\n", __func__, dev_name); - return -1; -} - - -static int -register_swp_module(void){ - - dev_t ctl_devt = 0; - dev_t port_devt = 0; - //int dev_total = port_total + 1; /* char_dev for module control */ - - /* Register device number */ - if (alloc_chrdev_region(&ctl_devt, 0, 1, SWP_DEV_MODCTL) < 0){ - SWPS_WARN("Allocate CTL MAJOR failure! \n"); - goto err_register_swp_module_1; - } - if (alloc_chrdev_region(&port_devt, 0, port_total, SWP_CLS_NAME) < 0){ - SWPS_WARN("Allocate PORT MAJOR failure! \n"); - goto err_register_swp_module_2; - } - ctl_major = MAJOR(ctl_devt); - port_major = MAJOR(port_devt); - - /* Create class object */ - swp_class_p = class_create(THIS_MODULE, SWP_CLS_NAME); - if (IS_ERR(swp_class_p)) { - SWPS_ERR("Create class failure! \n"); - goto err_register_swp_module_3; - } - return 0; - -err_register_swp_module_3: - unregister_chrdev_region(MKDEV(port_major, 0), port_total); -err_register_swp_module_2: - unregister_chrdev_region(MKDEV(ctl_major, 0), 1); -err_register_swp_module_1: - return -1; -} - - -/* ========== Module initial relate ========== - */ -static int -create_ioexp_objs(void) { - - int i, run_mod; - - /* Clean IOEXP object */ - clean_ioexp_objs(); - /* Get running mode */ - run_mod = IOEXP_MODE_DIRECT; - if (SWP_POLLING_ENABLE){ - run_mod = IOEXP_MODE_POLLING; - } - /* Create IOEXP object */ - for(i=0; i devlen_max) { - snprintf(err_msg, sizeof(err_msg), - "SWP_DEV_PORT too long!"); - goto err_initport_create_tranobj; - } - memset(dev_name, 0, sizeof(dev_name)); - snprintf(dev_name, devlen_max, "%s%d", SWP_DEV_PORT, port_id); - /* Create transceiver object */ - ioexp_obj_p = get_ioexp_obj(ioexp_id); - if (!ioexp_obj_p){ - snprintf(err_msg, sizeof(err_msg), - "IOEXP object:%d not exist", ioexp_id); - goto err_initport_create_tranobj; - } - transvr_obj_p = create_transvr_obj(dev_name, chan_id, ioexp_obj_p, - ioexp_virt_offset, transvr_type, - chipset_type, run_mod); - if (!transvr_obj_p){ - snprintf(err_msg, sizeof(err_msg), - "Create transceiver object fail :%s", dev_name); - goto err_initport_create_tranobj; - } - /* Setup Lane_ID mapping */ - i = ARRAY_SIZE(port_layout[minor_curr].lane_id); - j = ARRAY_SIZE(transvr_obj_p->lane_id); - if (i != j) { - snprintf(err_msg, sizeof(err_msg), - "Lane_id size inconsistent %d/%d", i, j); - goto err_initport_reg_device; - } - memcpy(transvr_obj_p->lane_id, port_layout[minor_curr].lane_id, i*sizeof(int)); - /* Create and register device object */ - if (register_port_device(dev_name, MKDEV(port_major, minor_curr), transvr_obj_p) < 0){ - snprintf(err_msg, sizeof(err_msg), - "register_port_device fail"); - goto err_initport_reg_device; - } - /* Setup device_ptr of transvr_obj */ - dev_p = get_swpdev_by_name(dev_name); - if (!dev_p){ - snprintf(err_msg, sizeof(err_msg), - "get_swpdev_by_name fail"); - goto err_initport_reg_device; - } - transvr_obj_p->transvr_dev_p = dev_p; - /* Success */ - ok_count++; - } - SWPS_INFO("%s: initialed %d port-dev\n",__func__, ok_count); - return 0; - -err_initport_reg_device: - kfree(transvr_obj_p); -err_initport_create_tranobj: - clean_port_objs(); - SWPS_ERR("%s: %s", __func__, err_msg); - SWPS_ERR("Dump: :%d :%d :%d :%d :%d :%d\n", - port_id, chan_id, ioexp_id, ioexp_virt_offset, transvr_type, run_mod); - return -1; -} - - -static int -init_dev_topology(void){ - - int err; - char *emsg = "ERR"; - flag_mod_state = SWP_STATE_NORMAL; - - err = init_ioexp_objs(); - switch(err){ - case 0: /* Normal */ - SWPS_DEBUG("%s: normal case\n", __func__); - break; - - case -1: /* topology error */ - SWPS_DEBUG("%s: detect tier-1 topology initial failure :%d\n", - __func__, err); - /* Reset and isolate */ - err = reset_i2c_topology(); - if (err < 0) { - emsg = "reset i2c topology fail"; - goto err_init_dev_topology; - } - /* Re-initial again */ - err = init_ioexp_objs(); - if (err < 0) { - emsg = "re-init ioexp objects fail"; - goto err_init_dev_topology; - } - break; - - case -2: /* Internal error */ - SWPS_DEBUG("%s: internal error case\n", __func__); - err = -2; - emsg = "internal error"; - goto err_init_dev_topology; - - default: - SWPS_DEBUG("%s: undefined error case\n", __func__); - emsg = "undefined error case"; - goto err_init_dev_topology; - } - SWPS_DEBUG("%s: initial I2C topology success\n", __func__); - return 0; - -err_init_dev_topology: - SWPS_ERR("%s: %s :%d\n", __func__, emsg, err); - return -1; -} - - -static int -init_polling_task(void){ - - if (SWP_POLLING_ENABLE){ - schedule_delayed_work(&swp_polling, _get_polling_period()); - } - return 0; -} - - -static int -init_swps_common(void){ - - char *err_msg = "ERR"; - - block_polling = 0; - auto_config = 0; - if ((SWP_AUTOCONFIG_ENABLE) && (SWP_POLLING_ENABLE)){ - auto_config = 1; - } - if (register_modctl_device() < 0) { - err_msg = "register_modctl_device fail"; - goto err_init_swps_common_1; - } - if (_update_auto_config_2_trnasvr() < 0) { - err_msg = "_update_auto_config_2_trnasvr fail"; - goto err_init_swps_common_1; - } - if (init_polling_task() < 0){ - err_msg = "init_polling_task fail"; - goto err_init_swps_common_1; - } - return 0; - -err_init_swps_common_1: - clean_swps_common(); - SWPS_ERR("%s: %s\n", __func__, err_msg); - return -1; -} - - -static int __init -swp_module_init(void){ - - if (get_platform_type() < 0){ - goto err_init_out; - } - if (get_layout_info() < 0){ - goto err_init_out; - } - if (register_swp_module() < 0){ - goto err_init_out; - } - if (create_ioexp_objs() < 0){ - goto err_init_ioexp; - } - if (create_port_objs() < 0){ - goto err_init_portobj; - } - if (init_mux_objs(gpio_rest_mux) < 0){ - goto err_init_mux; - } - if (init_dev_topology() < 0){ - goto err_init_topology; - } - if (init_swps_common() < 0){ - goto err_init_topology; - } - SWPS_INFO("Inventec switch-port module V.%s initial success.\n", SWP_VERSION); - return 0; - - -err_init_topology: - clean_mux_objs(); -err_init_mux: - clean_port_objs(); -err_init_portobj: - clean_ioexp_objs(); -err_init_ioexp: - class_destroy(swp_class_p); - unregister_chrdev_region(MKDEV(ctl_major, 0), 1); - unregister_chrdev_region(MKDEV(port_major, 0), port_total); -err_init_out: - SWPS_ERR("Inventec switch-port module V.%s initial failure.\n", SWP_VERSION); - return -1; -} - - -static void __exit -swp_module_exit(void){ - - clean_swps_common(); - clean_port_objs(); - clean_ioexp_objs(); - clean_mux_objs(); - class_destroy(swp_class_p); - unregister_chrdev_region(MKDEV(ctl_major, 0), 1); - unregister_chrdev_region(MKDEV(port_major, 0), port_total); - SWPS_INFO("Remove Inventec switch-port module success.\n"); -} - - -/* Module information */ -MODULE_AUTHOR(SWP_AUTHOR); -MODULE_DESCRIPTION(SWP_DESC); -MODULE_VERSION(SWP_VERSION); -MODULE_LICENSE(SWP_LICENSE); -MODULE_SOFTDEP("pre: inv_platform"); -module_param(gpio_base, int, S_IRUGO); - -module_init(swp_module_init); -module_exit(swp_module_exit); - - - - - - - - - - - diff --git a/packages/platforms/inventec/x86-64/d6332/modules/builds/src/inv_swps.h b/packages/platforms/inventec/x86-64/d6332/modules/builds/src/inv_swps.h deleted file mode 100644 index bca058c22..000000000 --- a/packages/platforms/inventec/x86-64/d6332/modules/builds/src/inv_swps.h +++ /dev/null @@ -1,1794 +0,0 @@ -#ifndef INV_SWPS_H -#define INV_SWPS_H - -#include "transceiver.h" -#include "io_expander.h" -#include "inv_mux.h" - -/* Module settings */ -#define SWP_CLS_NAME "swps" -#define SWP_DEV_PORT "port" -#define SWP_DEV_MODCTL "module" -#define SWP_RESET_PWD "inventec" -#define SWP_POLLING_PERIOD (300) /* msec */ -#define SWP_POLLING_ENABLE (1) -#define SWP_AUTOCONFIG_ENABLE (1) - -/* Module information */ -#define SWP_AUTHOR "Neil " -#define SWP_DESC "Inventec port and transceiver driver" -#define SWP_VERSION "4.3.10" -#define SWP_LICENSE "GPL" - -/* Module status define */ -#define SWP_STATE_NORMAL (0) -#define SWP_STATE_I2C_DIE (-91) - -/* [Note]: - * Functions and mechanism for auto-detect platform type is ready, - * But HW and BIOS not ready! We need to wait them. - * So, please do not use PLATFORM_TYPE_AUTO until they are ready. - * (2016.06.13) - */ -#define PLATFORM_TYPE_AUTO (100) -#define PLATFORM_TYPE_MAGNOLIA (111) -#define PLATFORM_TYPE_MAGNOLIA_FNC (112) -#define PLATFORM_TYPE_REDWOOD (121) -#define PLATFORM_TYPE_REDWOOD_FSL (122) -#define PLATFORM_TYPE_HUDSON32I_GA (131) -#define PLATFORM_TYPE_SPRUCE (141) -#define PLATFORM_TYPE_CYPRESS_GA1 (151) /* Up -> Down */ -#define PLATFORM_TYPE_CYPRESS_GA2 (152) /* Down -> Up */ -#define PLATFORM_TYPE_CYPRESS_BAI (153) /* Down -> Up */ -#define PLATFORM_TYPE_TAHOE (161) -#define PLATFORM_TYPE_SEQUOIA_GA (171) -#define PLATFORM_TYPE_LAVENDER_GA (181) -#define PLATFORM_TYPE_LAVENDER_ONL (182) -#define PLATFORM_TYPE_COTTONWOOD_RANGELEY (191) -#define PLATFORM_TYPE_MAPLE_GA (201) -#define PLATFORM_TYPE_GULMOHAR_GA (202) -#define PLATFORM_TYPE_GULMOHAR_2T_EVT1_GA (203) -#define PLATFORM_TYPE_PEONY_SFP_GA (204) -#define PLATFORM_TYPE_PEONY_COPPER_GA (205) -#define PLATFORM_TYPE_PEONY_AUTO (206) -#define PLATFORM_TYPE_MAPLE_B (207) -#define PLATFORM_TYPE_MAPLE_J (208) -#define PLATFORM_TYPE_CEDAR_GA (209) -/* Current running platfrom */ -#define PLATFORM_SETTINGS PLATFORM_TYPE_CEDAR_GA - -/* Define platform flag and kernel version */ -#if (PLATFORM_SETTINGS == PLATFORM_TYPE_MAGNOLIA) - #define SWPS_MAGNOLIA (1) - #define SWPS_KERN_VER_BF_3_8 (1) -#elif (PLATFORM_SETTINGS == PLATFORM_TYPE_MAGNOLIA_FNC) - #define SWPS_MAGNOLIA (1) - #define SWPS_KERN_VER_AF_3_10 (1) -#elif (PLATFORM_SETTINGS == PLATFORM_TYPE_REDWOOD) - #define SWPS_REDWOOD (1) - #define SWPS_KERN_VER_BF_3_8 (1) -#elif (PLATFORM_SETTINGS == PLATFORM_TYPE_REDWOOD_FSL) - #define SWPS_REDWOOD_FSL (1) - #define SWPS_KERN_VER_BF_3_8 (1) -#elif (PLATFORM_SETTINGS == PLATFORM_TYPE_HUDSON32I_GA) - #define SWPS_HUDSON32I_GA (1) - #define SWPS_KERN_VER_BF_3_8 (1) -#elif (PLATFORM_SETTINGS == PLATFORM_TYPE_SPRUCE) - #define SWPS_SPRUCE (1) - #define SWPS_KERN_VER_BF_3_8 (1) -#elif (PLATFORM_SETTINGS == PLATFORM_TYPE_CYPRESS_GA1) - #define SWPS_CYPRESS_GA1 (1) - #define SWPS_KERN_VER_BF_3_8 (1) -#elif (PLATFORM_SETTINGS == PLATFORM_TYPE_CYPRESS_GA2) - #define SWPS_CYPRESS_GA2 (1) - #define SWPS_KERN_VER_BF_3_8 (1) -#elif (PLATFORM_SETTINGS == PLATFORM_TYPE_CYPRESS_BAI) - #define SWPS_CYPRESS_BAI (1) - #define SWPS_KERN_VER_AF_3_10 (1) -#elif (PLATFORM_SETTINGS == PLATFORM_TYPE_TAHOE) - #define SWPS_TAHOE (1) - #define SWPS_KERN_VER_AF_3_10 (1) -#elif (PLATFORM_SETTINGS == PLATFORM_TYPE_SEQUOIA_GA) - #define SWPS_SEQUOIA (1) - #define SWPS_KERN_VER_BF_3_8 (1) -#elif (PLATFORM_SETTINGS == PLATFORM_TYPE_LAVENDER_GA) - #define SWPS_LAVENDER (1) - #define SWPS_KERN_VER_AF_3_10 (1) -#elif (PLATFORM_SETTINGS == PLATFORM_TYPE_LAVENDER_ONL) - #define SWPS_LAVENDER (1) - #define SWPS_KERN_VER_AF_3_10 (1) -#elif (PLATFORM_SETTINGS == PLATFORM_TYPE_COTTONWOOD_RANGELEY) - #define SWPS_COTTONWOOD_RANGELEY (1) - #define SWPS_KERN_VER_AF_3_10 (1) -#elif (PLATFORM_SETTINGS == PLATFORM_TYPE_MAPLE_GA) - #define SWPS_MAPLE_GA (1) - #define SWPS_KERN_VER_AF_3_10 (1) -#elif (PLATFORM_SETTINGS == PLATFORM_TYPE_MAPLE_B) - #define SWPS_MAPLE_B (1) - #define SWPS_KERN_VER_AF_3_10 (1) -#elif (PLATFORM_SETTINGS == PLATFORM_TYPE_MAPLE_J) - #define SWPS_MAPLE_J (1) - #define SWPS_KERN_VER_AF_3_10 (1) -#elif (PLATFORM_SETTINGS == PLATFORM_TYPE_GULMOHAR_GA) - #define SWPS_GULMOHAR (1) - #define SWPS_KERN_VER_AF_3_10 (1) -#elif (PLATFORM_SETTINGS == PLATFORM_TYPE_GULMOHAR_2T_EVT1_GA) - #define SWPS_GULMOHAR_2T_EVT1 (1) - #define SWPS_KERN_VER_AF_3_10 (1) -#elif (PLATFORM_SETTINGS == PLATFORM_TYPE_PEONY_SFP_GA) - #define SWPS_PEONY_SFP (1) - #define SWPS_KERN_VER_AF_3_10 (1) -#elif (PLATFORM_SETTINGS == PLATFORM_TYPE_PEONY_COPPER_GA) - #define SWPS_PEONY_COPPER (1) - #define SWPS_KERN_VER_AF_3_10 (1) -#elif (PLATFORM_SETTINGS == PLATFORM_TYPE_PEONY_AUTO) - #define SWPS_PEONY_SFP (1) - #define SWPS_PEONY_COPPER (1) - #define SWPS_KERN_VER_AF_3_10 (1) -#elif (PLATFORM_SETTINGS == PLATFORM_TYPE_CEDAR_GA) - #define SWPS_CEDAR_GA (1) - #define SWPS_KERN_VER_AF_3_10 (1) -#endif - -struct inv_platform_s { - int id; - char name[64]; -}; - -struct inv_ioexp_layout_s { - int ioexp_id; - int ioexp_type; - struct ioexp_addr_s addr[4]; -}; - -struct inv_port_layout_s { - int port_id; - int chan_id; - int ioexp_id; - int ioexp_offset; - int transvr_type; - int chipset_type; - int lane_id[8]; -}; - - -/* ========================================== - * Inventec Platform Settings - * ========================================== - */ -struct inv_platform_s platform_map[] = { - {PLATFORM_TYPE_AUTO, "Auto-Detect" }, - {PLATFORM_TYPE_MAGNOLIA, "Magnolia" }, - {PLATFORM_TYPE_MAGNOLIA_FNC, "Magnolia_FNC" }, - {PLATFORM_TYPE_REDWOOD, "Redwood" }, - {PLATFORM_TYPE_REDWOOD_FSL, "Redwood_FSL" }, - {PLATFORM_TYPE_HUDSON32I_GA, "Hudson32i" }, - {PLATFORM_TYPE_SPRUCE, "Spruce" }, - {PLATFORM_TYPE_CYPRESS_GA1, "Cypress_GA1" }, - {PLATFORM_TYPE_CYPRESS_GA2, "Cypress_GA2" }, - {PLATFORM_TYPE_CYPRESS_BAI, "Cypress_BAI" }, - {PLATFORM_TYPE_TAHOE, "Tahoe" }, - {PLATFORM_TYPE_SEQUOIA_GA, "Sequoia_GA" }, - {PLATFORM_TYPE_LAVENDER_GA, "Lavender_GA" }, - {PLATFORM_TYPE_LAVENDER_ONL, "Lavender_ONL" }, - {PLATFORM_TYPE_COTTONWOOD_RANGELEY, "Cottonwood_RANGELEY" }, - {PLATFORM_TYPE_MAPLE_GA, "Maple_GA" }, - {PLATFORM_TYPE_MAPLE_B, "Maple_B" }, - {PLATFORM_TYPE_MAPLE_J, "Maple_J" }, - {PLATFORM_TYPE_GULMOHAR_GA, "Gulmohar_GA" }, - {PLATFORM_TYPE_GULMOHAR_2T_EVT1_GA, "Gulmohar_2T_EVT1_GA" }, - {PLATFORM_TYPE_PEONY_SFP_GA, "Peony_SFP_GA" }, - {PLATFORM_TYPE_PEONY_COPPER_GA, "Peony_Copper_GA" }, - {PLATFORM_TYPE_PEONY_AUTO, "Peony_Auto_Detect" }, - {PLATFORM_TYPE_CEDAR_GA, "Cedar_GA" }, -}; - - -/* ========================================== - * Magnolia Layout configuration - * ========================================== - */ -#ifdef SWPS_MAGNOLIA -unsigned magnolia_gpio_rest_mux = MUX_RST_GPIO_48_PCA9548; - -struct inv_ioexp_layout_s magnolia_ioexp_layout[] = { - /* IOEXP_ID / IOEXP_TYPE / { Chan_ID, Chip_addr, Read_offset, Write_offset, config_offset, data_default, conf_default } */ - {0, IOEXP_TYPE_MAGINOLIA_NAB, { {2, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {2, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, }, /* addr[1] = I/O Expander N B */ - }, - {1, IOEXP_TYPE_MAGINOLIA_NAB, { {3, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {3, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, }, /* addr[1] = I/O Expander N B */ - }, - {2, IOEXP_TYPE_MAGINOLIA_NAB, { {4, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {4, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, }, /* addr[1] = I/O Expander N B */ - }, - {3, IOEXP_TYPE_MAGINOLIA_4AB, { {5, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander 4 A */ - {5, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xf0, 0xff}, {0xf0, 0xff}, }, }, /* addr[1] = I/O Expander 4 B */ - }, - {4, IOEXP_TYPE_MAGINOLIA_NAB, { {6, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {6, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, }, /* addr[1] = I/O Expander N B */ - }, - {5, IOEXP_TYPE_MAGINOLIA_NAB, { {7, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {7, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, }, /* addr[1] = I/O Expander N B */ - }, - {6, IOEXP_TYPE_MAGINOLIA_7AB, { {8, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[0] = I/O Expander 7 A */ - {8, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xf0, 0x33}, }, }, /* addr[1] = I/O Expander 7 B */ - }, -}; - -struct inv_port_layout_s magnolia_port_layout[] = { - /* Port_ID / Chan_ID / IOEXP_ID / IOEXP_VIRT_OFFSET / TRANSCEIVER_TYPE / CHIP_TYPE / LANE_ID */ - { 0, 10, 0, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 16} }, - { 1, 11, 0, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 15} }, - { 2, 12, 0, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 14} }, - { 3, 13, 0, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 13} }, - { 4, 14, 0, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 24} }, - { 5, 15, 0, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 23} }, - { 6, 16, 0, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 22} }, - { 7, 17, 0, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 21} }, - { 8, 18, 1, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 28} }, - { 9, 19, 1, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 27} }, - {10, 20, 1, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 26} }, - {11, 21, 1, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 25} }, - {12, 22, 1, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 32} }, - {13, 23, 1, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 31} }, - {14, 24, 1, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 30} }, - {15, 25, 1, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 29} }, - {16, 26, 2, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 48} }, - {17, 27, 2, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 47} }, - {18, 28, 2, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 46} }, - {19, 29, 2, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 45} }, - {20, 30, 2, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 52} }, - {21, 31, 2, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 51} }, - {22, 32, 2, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 50} }, - {23, 33, 2, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 49} }, - {24, 34, 3, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 56} }, - {25, 35, 3, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 55} }, - {26, 36, 3, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 54} }, - {27, 37, 3, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 53} }, - {28, 38, 3, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 60} }, - {29, 39, 3, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 59} }, - {30, 40, 3, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 58} }, - {31, 41, 3, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 57} }, - {32, 42, 4, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 64} }, - {33, 43, 4, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 63} }, - {34, 44, 4, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 62} }, - {35, 45, 4, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 61} }, - {36, 46, 4, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 68} }, - {37, 47, 4, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 67} }, - {38, 48, 4, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 66} }, - {39, 49, 4, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 65} }, - {40, 50, 5, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 72} }, - {41, 51, 5, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 71} }, - {42, 52, 5, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 70} }, - {43, 53, 5, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 69} }, - {44, 54, 5, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 76} }, - {45, 55, 5, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 75} }, - {46, 56, 5, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 74} }, - {47, 57, 5, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_MAGNOLIA, { 73} }, - {48, 58, 6, 0, TRANSVR_TYPE_QSFP, CHIP_TYPE_MAGNOLIA, { 81, 82, 83, 84} }, - {49, 59, 6, 1, TRANSVR_TYPE_QSFP, CHIP_TYPE_MAGNOLIA, { 77, 78, 79, 80} }, - {50, 60, 6, 2, TRANSVR_TYPE_QSFP, CHIP_TYPE_MAGNOLIA, { 97, 98, 99,100} }, - {51, 61, 6, 3, TRANSVR_TYPE_QSFP, CHIP_TYPE_MAGNOLIA, {101,102,103,104} }, - {52, 62, 6, 4, TRANSVR_TYPE_QSFP, CHIP_TYPE_MAGNOLIA, {105,106,107,108} }, - {53, 63, 6, 5, TRANSVR_TYPE_QSFP, CHIP_TYPE_MAGNOLIA, {109,110,111,112} }, -}; -#endif - - -/* ========================================== - * Redwood Layout configuration - * ========================================== - */ -#ifdef SWPS_REDWOOD -unsigned redwood_gpio_rest_mux = MUX_RST_GPIO_48_PCA9548; - -struct inv_ioexp_layout_s redwood_ioexp_layout[] = { - /* IOEXP_ID / IOEXP_TYPE / { Chan_ID, Chip_addr, Read_offset, Write_offset, config_offset, data_default, conf_default } */ - {0, IOEXP_TYPE_REDWOOD_P01P08, { {4, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[0] = I/O Expander 1-4 A */ - {4, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[1] = I/O Expander 1-4 B */ - {0, 0x25, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 5 B */ - }, - {1, IOEXP_TYPE_REDWOOD_P09P16, { {5, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[0] = I/O Expander 1-4 A */ - {5, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[1] = I/O Expander 1-4 B */ - {0, 0x25, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 5 B */ - }, - {2, IOEXP_TYPE_REDWOOD_P01P08, { {2, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[0] = I/O Expander 1-4 A */ - {2, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[1] = I/O Expander 1-4 B */ - {0, 0x24, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 5 B */ - }, - {3, IOEXP_TYPE_REDWOOD_P09P16, { {3, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[0] = I/O Expander 1-4 A */ - {3, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[1] = I/O Expander 1-4 B */ - {0, 0x24, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 5 B */ - }, -}; - -struct inv_port_layout_s redwood_port_layout[] = { - /* Port_ID / Chan_ID / IOEXP_ID / IOEXP_VIRT_OFFSET / TRANSCEIVER_TYPE / CHIP_TYPE / LANE_ID */ - { 0, 22, 0, 0, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 1, 2, 3, 4} }, - { 1, 23, 0, 1, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 5, 6, 7, 8} }, - { 2, 24, 0, 2, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 9, 10, 11, 12} }, - { 3, 25, 0, 3, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 13, 14, 15, 16} }, - { 4, 26, 0, 4, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 17, 18, 19, 20} }, - { 5, 27, 0, 5, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 21, 22, 23, 24} }, - { 6, 28, 0, 6, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 25, 26, 27, 28} }, - { 7, 29, 0, 7, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 29, 30, 31, 32} }, - { 8, 30, 1, 0, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 33, 34, 35, 36} }, - { 9, 31, 1, 1, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 37, 38, 39, 40} }, - {10, 32, 1, 2, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 41, 42, 43, 44} }, - {11, 33, 1, 3, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 45, 46, 47, 48} }, - {12, 34, 1, 4, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 49, 50, 51, 52} }, - {13, 35, 1, 5, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 53, 54, 55, 56} }, - {14, 36, 1, 6, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 57, 58, 59, 60} }, - {15, 37, 1, 7, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 61, 62, 63, 64} }, - {16, 6, 2, 0, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 65, 66, 67, 68} }, - {17, 7, 2, 1, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 69, 70, 71, 72} }, - {18, 8, 2, 2, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 73, 74, 75, 76} }, - {19, 9, 2, 3, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 77, 78, 79, 80} }, - {20, 10, 2, 4, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 81, 82, 83, 84} }, - {21, 11, 2, 5, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 85, 86, 87, 88} }, - {22, 12, 2, 6, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 89, 90, 91, 92} }, - {23, 13, 2, 7, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 93, 94, 95, 96} }, - {24, 14, 3, 0, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 97, 98, 99,100} }, - {25, 15, 3, 1, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {101,102,103,104} }, - {26, 16, 3, 2, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {105,106,107,108} }, - {27, 17, 3, 3, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {109,110,111,112} }, - {28, 18, 3, 4, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {113,114,115,116} }, - {29, 19, 3, 5, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {117,118,119,120} }, - {30, 20, 3, 6, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {121,122,123,124} }, - {31, 21, 3, 7, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {125,126,127,128} }, -}; -#endif - - -/* ========================================== - * Hudson32i Layout configuration - * ========================================== - */ -#ifdef SWPS_HUDSON32I_GA -unsigned hudsin32iga_gpio_rest_mux = MUX_RST_GPIO_48_PCA9548; - -struct inv_ioexp_layout_s hudson32iga_ioexp_layout[] = { - /* IOEXP_ID / IOEXP_TYPE / { Chan_ID, Chip_addr, Read_offset, Write_offset, config_offset, data_default, conf_default } */ - {0, IOEXP_TYPE_HUDSON32IGA_P01P08, { {2, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[0] = I/O Expander A */ - {2, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[1] = I/O Expander B */ - {0, 0x24, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 0x24 */ - }, - {1, IOEXP_TYPE_HUDSON32IGA_P09P16, { {3, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[0] = I/O Expander A */ - {3, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[1] = I/O Expander B */ - {0, 0x24, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 0x24 */ - }, - {2, IOEXP_TYPE_HUDSON32IGA_P01P08, { {4, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[0] = I/O Expander A */ - {4, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[1] = I/O Expander B */ - {0, 0x25, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 0x25 */ - }, - {3, IOEXP_TYPE_HUDSON32IGA_P09P16, { {5, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[0] = I/O Expander A */ - {5, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[1] = I/O Expander B */ - {0, 0x25, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 0x25 */ - }, -}; - -struct inv_port_layout_s hudson32iga_port_layout[] = { - /* Port_ID / Chan_ID / IOEXP_ID / IOEXP_VIRT_OFFSET / TRANSCEIVER_TYPE / CHIP_TYPE / LANE_ID */ - { 0, 6, 0, 0, TRANSVR_TYPE_QSFP_PLUS, CHIP_TYPE_MAGNOLIA, { 1, 2, 3, 4} }, - { 1, 7, 0, 1, TRANSVR_TYPE_QSFP_PLUS, CHIP_TYPE_MAGNOLIA, { 5, 6, 7, 8} }, - { 2, 8, 0, 2, TRANSVR_TYPE_QSFP_PLUS, CHIP_TYPE_MAGNOLIA, { 9, 10, 11, 12} }, - { 3, 9, 0, 3, TRANSVR_TYPE_QSFP_PLUS, CHIP_TYPE_MAGNOLIA, { 13, 14, 15, 16} }, - { 4, 10, 0, 4, TRANSVR_TYPE_QSFP_PLUS, CHIP_TYPE_MAGNOLIA, { 17, 18, 19, 20} }, - { 5, 11, 0, 5, TRANSVR_TYPE_QSFP_PLUS, CHIP_TYPE_MAGNOLIA, { 21, 22, 23, 24} }, - { 6, 12, 0, 6, TRANSVR_TYPE_QSFP_PLUS, CHIP_TYPE_MAGNOLIA, { 25, 26, 27, 28} }, - { 7, 13, 0, 7, TRANSVR_TYPE_QSFP_PLUS, CHIP_TYPE_MAGNOLIA, { 29, 30, 31, 32} }, - { 8, 14, 1, 0, TRANSVR_TYPE_QSFP_PLUS, CHIP_TYPE_MAGNOLIA, { 33, 34, 35, 36} }, - { 9, 15, 1, 1, TRANSVR_TYPE_QSFP_PLUS, CHIP_TYPE_MAGNOLIA, { 37, 38, 39, 40} }, - {10, 16, 1, 2, TRANSVR_TYPE_QSFP_PLUS, CHIP_TYPE_MAGNOLIA, { 41, 42, 43, 44} }, - {11, 17, 1, 3, TRANSVR_TYPE_QSFP_PLUS, CHIP_TYPE_MAGNOLIA, { 45, 46, 47, 48} }, - {12, 18, 1, 4, TRANSVR_TYPE_QSFP_PLUS, CHIP_TYPE_MAGNOLIA, { 49, 50, 51, 52} }, - {13, 19, 1, 5, TRANSVR_TYPE_QSFP_PLUS, CHIP_TYPE_MAGNOLIA, { 53, 54, 55, 56} }, - {14, 20, 1, 6, TRANSVR_TYPE_QSFP_PLUS, CHIP_TYPE_MAGNOLIA, { 57, 58, 59, 60} }, - {15, 21, 1, 7, TRANSVR_TYPE_QSFP_PLUS, CHIP_TYPE_MAGNOLIA, { 61, 62, 63, 64} }, - {16, 22, 2, 0, TRANSVR_TYPE_QSFP_PLUS, CHIP_TYPE_MAGNOLIA, { 65, 66, 67, 68} }, - {17, 23, 2, 1, TRANSVR_TYPE_QSFP_PLUS, CHIP_TYPE_MAGNOLIA, { 69, 70, 71, 72} }, - {18, 24, 2, 2, TRANSVR_TYPE_QSFP_PLUS, CHIP_TYPE_MAGNOLIA, { 73, 74, 75, 76} }, - {19, 25, 2, 3, TRANSVR_TYPE_QSFP_PLUS, CHIP_TYPE_MAGNOLIA, { 77, 78, 79, 80} }, - {20, 26, 2, 4, TRANSVR_TYPE_QSFP_PLUS, CHIP_TYPE_MAGNOLIA, { 81, 82, 83, 84} }, - {21, 27, 2, 5, TRANSVR_TYPE_QSFP_PLUS, CHIP_TYPE_MAGNOLIA, { 85, 86, 87, 88} }, - {22, 28, 2, 6, TRANSVR_TYPE_QSFP_PLUS, CHIP_TYPE_MAGNOLIA, { 89, 90, 91, 92} }, - {23, 29, 2, 7, TRANSVR_TYPE_QSFP_PLUS, CHIP_TYPE_MAGNOLIA, { 93, 94, 95, 96} }, - {24, 30, 3, 0, TRANSVR_TYPE_QSFP_PLUS, CHIP_TYPE_MAGNOLIA, { 97, 98, 99,100} }, - {25, 31, 3, 1, TRANSVR_TYPE_QSFP_PLUS, CHIP_TYPE_MAGNOLIA, {101,102,103,104} }, - {26, 32, 3, 2, TRANSVR_TYPE_QSFP_PLUS, CHIP_TYPE_MAGNOLIA, {105,106,107,108} }, - {27, 33, 3, 3, TRANSVR_TYPE_QSFP_PLUS, CHIP_TYPE_MAGNOLIA, {109,110,111,112} }, - {28, 34, 3, 4, TRANSVR_TYPE_QSFP_PLUS, CHIP_TYPE_MAGNOLIA, {113,114,115,116} }, - {29, 35, 3, 5, TRANSVR_TYPE_QSFP_PLUS, CHIP_TYPE_MAGNOLIA, {117,118,119,120} }, - {30, 36, 3, 6, TRANSVR_TYPE_QSFP_PLUS, CHIP_TYPE_MAGNOLIA, {121,122,123,124} }, - {31, 37, 3, 7, TRANSVR_TYPE_QSFP_PLUS, CHIP_TYPE_MAGNOLIA, {125,126,127,128} }, -}; -#endif - - -/* ========================================== - * Spruce Layout configuration - * ========================================== - */ -#ifdef SWPS_SPRUCE -unsigned spruce_gpio_rest_mux = MUX_RST_GPIO_48_PCA9548; - -struct inv_ioexp_layout_s spruce_ioexp_layout[] = { - /* IOEXP_ID / IOEXP_TYPE / { Chan_ID, Chip_addr, Read_offset, Write_offset, config_offset, data_default, conf_default } */ - {0, IOEXP_TYPE_SPRUCE_7AB, { {2, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[0] = I/O Expander 7A */ - {2, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xf0, 0x33}, }, }, /* addr[2] = I/O Expander 7B */ - }, -}; - -struct inv_port_layout_s spruce_port_layout[] = { - /* Port_ID / Chan_ID / IOEXP_ID / IOEXP_VIRT_OFFSET / TRANSCEIVER_TYPE / CHIP_TYPE / LANE_ID */ - { 0, 6, 0, 0, TRANSVR_TYPE_QSFP_PLUS, CHIP_TYPE_MAGNOLIA, { 81, 82, 83, 84} }, - { 1, 7, 0, 1, TRANSVR_TYPE_QSFP_PLUS, CHIP_TYPE_MAGNOLIA, { 77, 78, 79, 80} }, - { 2, 8, 0, 2, TRANSVR_TYPE_QSFP_PLUS, CHIP_TYPE_MAGNOLIA, { 97, 98, 99,100} }, - { 3, 9, 0, 3, TRANSVR_TYPE_QSFP_PLUS, CHIP_TYPE_MAGNOLIA, {101,102,103,104} }, - { 4, 10, 0, 4, TRANSVR_TYPE_QSFP_PLUS, CHIP_TYPE_MAGNOLIA, {105,106,107,108} }, - { 5, 11, 0, 5, TRANSVR_TYPE_QSFP_PLUS, CHIP_TYPE_MAGNOLIA, {109,110,111,112} }, -}; -#endif - - -/* ========================================== - * Cypress Layout configuration (Inventec version [Up->Down]) - * ========================================== - */ -#ifdef SWPS_CYPRESS_GA1 -unsigned cypress_ga1_gpio_rest_mux = MUX_RST_GPIO_69_PCA9548; - -struct inv_ioexp_layout_s cypress_ga1_ioexp_layout[] = { - /* IOEXP_ID / IOEXP_TYPE / { Chan_ID, Chip_addr, Read_offset, Write_offset, config_offset, data_default, conf_default } */ - {0, IOEXP_TYPE_SFP_8P_LAYOUT_1, { {2, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {2, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {2, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {1, IOEXP_TYPE_SFP_8P_LAYOUT_1, { {3, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {3, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {3, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {2, IOEXP_TYPE_SFP_8P_LAYOUT_1, { {4, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {4, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {4, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {3, IOEXP_TYPE_SFP_8P_LAYOUT_1, { {5, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {5, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {5, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {4, IOEXP_TYPE_SFP_8P_LAYOUT_1, { {6, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {6, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {6, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {5, IOEXP_TYPE_SFP_8P_LAYOUT_1, { {7, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {7, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {7, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {6, IOEXP_TYPE_CYPRESS_7ABC, { {8, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xc0, 0xc0}, }, /* addr[0] = I/O Expander 7 A */ - {8, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xc0, 0xc0}, {0xff, 0xc0}, }, /* addr[1] = I/O Expander 7 B */ - {8, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 7 C */ - }, -}; - -struct inv_port_layout_s cypress_ga1_port_layout[] = { - /* Port_ID / Chan_ID / IOEXP_ID / IOEXP_VIRT_OFFSET / TRANSCEIVER_TYPE / CHIP_TYPE / LANE_ID */ - { 0, 10, 0, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 1} }, - { 1, 11, 0, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 2} }, - { 2, 12, 0, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 3} }, - { 3, 13, 0, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 4} }, - { 4, 14, 0, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 5} }, - { 5, 15, 0, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 6} }, - { 6, 16, 0, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 7} }, - { 7, 17, 0, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 8} }, - { 8, 18, 1, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 9} }, - { 9, 19, 1, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 10} }, - {10, 20, 1, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 11} }, - {11, 21, 1, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 12} }, - {12, 22, 1, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 21} }, - {13, 23, 1, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 22} }, - {14, 24, 1, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 23} }, - {15, 25, 1, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 24} }, - {16, 26, 2, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 33} }, - {17, 27, 2, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 34} }, - {18, 28, 2, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 35} }, - {19, 29, 2, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 36} }, - {20, 30, 2, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 37} }, - {21, 31, 2, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 38} }, - {22, 32, 2, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 39} }, - {23, 33, 2, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 40} }, - {24, 34, 3, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 41} }, - {25, 35, 3, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 42} }, - {26, 36, 3, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 43} }, - {27, 37, 3, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 44} }, - {28, 38, 3, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 49} }, - {29, 39, 3, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 50} }, - {30, 40, 3, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 51} }, - {31, 41, 3, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 52} }, - {32, 42, 4, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 53} }, - {33, 43, 4, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 54} }, - {34, 44, 4, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 55} }, - {35, 45, 4, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 56} }, - {36, 46, 4, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 65} }, - {37, 47, 4, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 66} }, - {38, 48, 4, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 67} }, - {39, 49, 4, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 68} }, - {40, 50, 5, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 69} }, - {41, 51, 5, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 70} }, - {42, 52, 5, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 71} }, - {43, 53, 5, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 72} }, - {44, 54, 5, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 81} }, - {45, 55, 5, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 82} }, - {46, 56, 5, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 83} }, - {47, 57, 5, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 84} }, - {48, 58, 6, 0, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 97, 98, 99,100} }, - {49, 59, 6, 1, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 85, 86, 87, 88} }, - {50, 60, 6, 2, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {101,102,103,104} }, - {51, 61, 6, 3, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {105,106,107,108} }, - {52, 62, 6, 4, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {109,110,111,112} }, - {53, 63, 6, 5, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {117,118,119,120} }, -}; -#endif - - -/* ========================================== - * Cypress Layout configuration (Inventec version [Down->Up]) - * ========================================== - */ -#ifdef SWPS_CYPRESS_GA2 -unsigned cypress_ga2_gpio_rest_mux = MUX_RST_GPIO_FORCE_HEDERA; - -struct inv_ioexp_layout_s cypress_ga2_ioexp_layout[] = { - /* IOEXP_ID / IOEXP_TYPE / { Chan_ID, Chip_addr, Read_offset, Write_offset, config_offset, data_default, conf_default } */ - {0, IOEXP_TYPE_SFP_8P_LAYOUT_1, { {2, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {2, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {2, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {1, IOEXP_TYPE_SFP_8P_LAYOUT_1, { {3, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {3, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {3, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {2, IOEXP_TYPE_SFP_8P_LAYOUT_1, { {4, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {4, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {4, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {3, IOEXP_TYPE_SFP_8P_LAYOUT_1, { {5, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {5, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {5, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {4, IOEXP_TYPE_SFP_8P_LAYOUT_1, { {6, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {6, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {6, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {5, IOEXP_TYPE_SFP_8P_LAYOUT_1, { {7, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {7, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {7, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {6, IOEXP_TYPE_CYPRESS_7ABC, { {8, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xc0, 0xc0}, }, /* addr[0] = I/O Expander 7 A */ - {8, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xc0, 0xc0}, {0xff, 0xc0}, }, /* addr[1] = I/O Expander 7 B */ - {8, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 7 C */ - }, -}; - -struct inv_port_layout_s cypress_ga2_port_layout[] = { - /* Port_ID / Chan_ID / IOEXP_ID / IOEXP_VIRT_OFFSET / TRANSCEIVER_TYPE / CHIP_TYPE / LANE_ID */ - { 0, 11, 0, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 2} }, - { 1, 10, 0, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 1} }, - { 2, 13, 0, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 4} }, - { 3, 12, 0, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 3} }, - { 4, 15, 0, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 6} }, - { 5, 14, 0, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 5} }, - { 6, 17, 0, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 8} }, - { 7, 16, 0, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 7} }, - { 8, 19, 1, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 10} }, - { 9, 18, 1, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 9} }, - {10, 21, 1, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 12} }, - {11, 20, 1, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 11} }, - {12, 23, 1, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 22} }, - {13, 22, 1, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 21} }, - {14, 25, 1, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 24} }, - {15, 24, 1, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 23} }, - {16, 27, 2, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 34} }, - {17, 26, 2, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 33} }, - {18, 29, 2, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 36} }, - {19, 28, 2, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 35} }, - {20, 31, 2, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 38} }, - {21, 30, 2, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 37} }, - {22, 33, 2, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 40} }, - {23, 32, 2, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 39} }, - {24, 35, 3, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 42} }, - {25, 34, 3, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 41} }, - {26, 37, 3, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 44} }, - {27, 36, 3, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 43} }, - {28, 39, 3, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 50} }, - {29, 38, 3, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 49} }, - {30, 41, 3, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 52} }, - {31, 40, 3, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 51} }, - {32, 43, 4, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 54} }, - {33, 42, 4, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 53} }, - {34, 45, 4, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 56} }, - {35, 44, 4, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 55} }, - {36, 47, 4, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 66} }, - {37, 46, 4, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 65} }, - {38, 49, 4, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 68} }, - {39, 48, 4, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 67} }, - {40, 51, 5, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 70} }, - {41, 50, 5, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 69} }, - {42, 53, 5, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 72} }, - {43, 52, 5, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 71} }, - {44, 55, 5, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 82} }, - {45, 54, 5, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 81} }, - {46, 57, 5, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 84} }, - {47, 56, 5, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 83} }, - {48, 59, 6, 1, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 85, 86, 87, 88} }, - {49, 58, 6, 0, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 97, 98, 99,100} }, - {50, 61, 6, 3, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {105,106,107,108} }, - {51, 60, 6, 2, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {101,102,103,104} }, - {52, 63, 6, 5, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {117,118,119,120} }, - {53, 62, 6, 4, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {109,110,111,112} }, -}; -#endif - - -/* ========================================== - * Cypress Layout configuration (C1 version) - * ========================================== - */ -#ifdef SWPS_CYPRESS_BAI -unsigned cypress_b_gpio_rest_mux = MUX_RST_GPIO_FORCE_HEDERA; - -struct inv_ioexp_layout_s cypress_b_ioexp_layout[] = { - /* IOEXP_ID / IOEXP_TYPE / { Chan_ID, Chip_addr, Read_offset, Write_offset, config_offset, data_default, conf_default } */ - {0, IOEXP_TYPE_SFP_8P_LAYOUT_1, { {2, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {2, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {2, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {1, IOEXP_TYPE_SFP_8P_LAYOUT_1, { {3, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {3, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {3, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {2, IOEXP_TYPE_SFP_8P_LAYOUT_1, { {4, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {4, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {4, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {3, IOEXP_TYPE_SFP_8P_LAYOUT_1, { {5, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {5, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {5, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {4, IOEXP_TYPE_SFP_8P_LAYOUT_1, { {6, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {6, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {6, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {5, IOEXP_TYPE_SFP_8P_LAYOUT_1, { {7, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {7, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {7, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {6, IOEXP_TYPE_CYPRESS_7ABC, { {8, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xc0, 0xc0}, }, /* addr[0] = I/O Expander 7 A */ - {8, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xc0, 0xc0}, {0xff, 0xc0}, }, /* addr[1] = I/O Expander 7 B */ - {8, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 7 C */ - }, -}; - -struct inv_port_layout_s cypress_b_port_layout[] = { - /* Port_ID / Chan_ID / IOEXP_ID / IOEXP_VIRT_OFFSET / TRANSCEIVER_TYPE / CHIP_TYPE / LANE_ID */ - { 1, 11, 0, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 2} }, - { 2, 10, 0, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 1} }, - { 3, 13, 0, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 4} }, - { 4, 12, 0, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 3} }, - { 5, 15, 0, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 6} }, - { 6, 14, 0, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 5} }, - { 7, 17, 0, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 8} }, - { 8, 16, 0, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 7} }, - { 9, 19, 1, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 10} }, - {10, 18, 1, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 9} }, - {11, 21, 1, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 12} }, - {12, 20, 1, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 11} }, - {13, 23, 1, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 22} }, - {14, 22, 1, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 21} }, - {15, 25, 1, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 24} }, - {16, 24, 1, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 23} }, - {17, 27, 2, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 34} }, - {18, 26, 2, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 33} }, - {19, 29, 2, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 36} }, - {20, 28, 2, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 35} }, - {21, 31, 2, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 38} }, - {22, 30, 2, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 37} }, - {23, 33, 2, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 40} }, - {24, 32, 2, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 39} }, - {25, 35, 3, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 42} }, - {26, 34, 3, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 41} }, - {27, 37, 3, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 44} }, - {28, 36, 3, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 43} }, - {29, 39, 3, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 50} }, - {30, 38, 3, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 49} }, - {31, 41, 3, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 52} }, - {32, 40, 3, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 51} }, - {33, 43, 4, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 54} }, - {34, 42, 4, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 53} }, - {35, 45, 4, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 56} }, - {36, 44, 4, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 55} }, - {37, 47, 4, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 66} }, - {38, 46, 4, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 65} }, - {39, 49, 4, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 68} }, - {40, 48, 4, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 67} }, - {41, 51, 5, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 70} }, - {42, 50, 5, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 69} }, - {43, 53, 5, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 72} }, - {44, 52, 5, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 71} }, - {45, 55, 5, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 82} }, - {46, 54, 5, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 81} }, - {47, 57, 5, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 84} }, - {48, 56, 5, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 83} }, - {49, 59, 6, 1, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 85, 86, 87, 88} }, - {50, 58, 6, 0, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 97, 98, 99,100} }, - {51, 61, 6, 3, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {105,106,107,108} }, - {52, 60, 6, 2, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {101,102,103,104} }, - {53, 63, 6, 5, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {117,118,119,120} }, - {54, 62, 6, 4, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {109,110,111,112} }, -}; -#endif - - -/* ========================================== - * Redwood_fsl Layout configuration - * ========================================== - */ -#ifdef SWPS_REDWOOD_FSL -unsigned redwood_fsl_gpio_rest_mux = MUX_RST_GPIO_48_PCA9548; - -struct inv_ioexp_layout_s redwood_fsl_ioexp_layout[] = { - /* IOEXP_ID / IOEXP_TYPE / { Chan_ID, Chip_addr, Read_offset, Write_offset, config_offset, data_default, conf_default } */ - {0, IOEXP_TYPE_REDWOOD_P01P08, { {4, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[0] = I/O Expander 1-4 A */ - {4, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[1] = I/O Expander 1-4 B */ - {0, 0x25, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 5 B */ - }, - {1, IOEXP_TYPE_REDWOOD_P09P16, { {5, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[0] = I/O Expander 1-4 A */ - {5, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[1] = I/O Expander 1-4 B */ - {0, 0x25, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 5 B */ - }, - {2, IOEXP_TYPE_REDWOOD_P01P08, { {2, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[0] = I/O Expander 1-4 A */ - {2, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[1] = I/O Expander 1-4 B */ - {0, 0x24, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 5 B */ - }, - {3, IOEXP_TYPE_REDWOOD_P09P16, { {3, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[0] = I/O Expander 1-4 A */ - {3, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[1] = I/O Expander 1-4 B */ - {0, 0x24, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 5 B */ - }, -}; - - -struct inv_port_layout_s redwood_fsl_port_layout[] = { - /* Port_ID / Chan_ID / IOEXP_ID / IOEXP_VIRT_OFFSET / TRANSCEIVER_TYPE / CHIP_TYPE / LANE_ID */ - { 0, 22, 0, 0, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 1, 2, 3, 4} }, - { 1, 23, 0, 1, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 5, 6, 7, 8} }, - { 2, 24, 0, 2, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 9, 10, 11, 12} }, - { 3, 25, 0, 3, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 13, 14, 15, 16} }, - { 4, 26, 0, 4, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 17, 18, 19, 20} }, - { 5, 27, 0, 5, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 21, 22, 23, 24} }, - { 6, 28, 0, 6, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 25, 26, 27, 28} }, - { 7, 29, 0, 7, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 29, 30, 31, 32} }, - { 8, 30, 1, 0, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 33, 34, 35, 36} }, - { 9, 31, 1, 1, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 37, 38, 39, 40} }, - {10, 32, 1, 2, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 41, 42, 43, 44} }, - {11, 33, 1, 3, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 45, 46, 47, 48} }, - {12, 34, 1, 4, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 49, 50, 51, 52} }, - {13, 35, 1, 5, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 53, 54, 55, 56} }, - {14, 36, 1, 6, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 57, 58, 59, 60} }, - {15, 37, 1, 7, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 61, 62, 63, 64} }, - {16, 6, 2, 0, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 65, 66, 67, 68} }, - {17, 7, 2, 1, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 69, 70, 71, 72} }, - {18, 8, 2, 2, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 73, 74, 75, 76} }, - {19, 9, 2, 3, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 77, 78, 79, 80} }, - {20, 10, 2, 4, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 81, 82, 83, 84} }, - {21, 11, 2, 5, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 85, 86, 87, 88} }, - {22, 12, 2, 6, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 89, 90, 91, 92} }, - {23, 13, 2, 7, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 93, 94, 95, 96} }, - {24, 14, 3, 0, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 97, 98, 99,100} }, - {25, 15, 3, 1, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {101,102,103,104} }, - {26, 16, 3, 2, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {105,106,107,108} }, - {27, 17, 3, 3, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {109,110,111,112} }, - {28, 18, 3, 4, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {113,114,115,116} }, - {29, 19, 3, 5, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {117,118,119,120} }, - {30, 20, 3, 6, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {121,122,123,124} }, - {31, 21, 3, 7, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {125,126,127,128} }, -}; -#endif - - -/* ========================================== - * Tahoe Layout configuration - * ========================================== - */ -#ifdef SWPS_TAHOE -unsigned tahoe_gpio_rest_mux = MUX_RST_GPIO_249_PCA9548; - -struct inv_ioexp_layout_s tahoe_ioexp_layout[] = { - /* IOEXP_ID / IOEXP_TYPE / { Chan_ID, Chip_addr, Read_offset, Write_offset, config_offset, data_default, conf_default } */ - {0, IOEXP_TYPE_TAHOE_6ABC, { {7, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xce, 0xb9}, {0x18, 0xe3}, }, /* addr[0] = I/O Expander 6 A */ - {7, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xce, 0xb9}, {0x18, 0xe3}, }, /* addr[1] = I/O Expander 6 B */ - {7, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xce, 0xb9}, {0x18, 0xe3}, }, }, /* addr[2] = I/O Expander 6 C */ - }, - {1, IOEXP_TYPE_TAHOE_5A, { {6, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xce, 0xb9}, {0x18, 0xe3}, }, }, /* addr[0] = I/O Expander 5 A */ - }, -}; - - -struct inv_port_layout_s tahoe_port_layout[] = { - /* Port_ID / Chan_ID / IOEXP_ID / IOEXP_VIRT_OFFSET / TRANSCEIVER_TYPE / CHIP_TYPE / LANE_ID */ - { 0, 12, 1, 2, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 65, 66, 67, 68} }, - { 1, 11, 1, 1, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 53, 54, 55, 56} }, - { 2, 22, 0, 5, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 69, 70, 71, 72} }, - { 3, 21, 0, 4, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 81, 82, 83, 84} }, - { 4, 24, 0, 7, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 97, 98, 99, 100} }, - { 5, 23, 0, 6, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 85, 86, 87, 88} }, - { 6, 18, 0, 1, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {101, 102, 103, 104} }, - { 7, 17, 0, 0, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {105, 106, 107, 108} }, - { 8, 20, 0, 3, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {113, 114, 115, 116} }, - { 9, 19, 0, 2, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {109, 110, 111, 112} }, -}; -#endif - - -/* ========================================== - * Sequoia Layout configuration - * ========================================== - */ -#ifdef SWPS_SEQUOIA -unsigned sequoia_gpio_rest_mux = MUX_RST_GPIO_69_PCA9548; - -struct inv_ioexp_layout_s sequoia_ioexp_layout[] = { - /* IOEXP_ID / IOEXP_TYPE / { Chan_ID, Chip_addr, Read_offset, Write_offset, config_offset, data_default, conf_default } */ - {0, IOEXP_TYPE_SEQUOIA_NABC, { {1, 0x20, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0x00, 0x00}, }, /* addr[0] = I/O Expander 0 A */ - {1, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0xff}, }, /* addr[1] = I/O Expander 0 B */ - {1, 0x22, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 0 C */ - }, - {1, IOEXP_TYPE_SEQUOIA_NABC, { {2, 0x20, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0x00, 0x00}, }, /* addr[0] = I/O Expander 1 A */ - {2, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0xff}, }, /* addr[1] = I/O Expander 1 B */ - {2, 0x22, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 1 C */ - }, - {2, IOEXP_TYPE_SEQUOIA_NABC, { {3, 0x20, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0x00, 0x00}, }, /* addr[0] = I/O Expander 2 A */ - {3, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0xff}, }, /* addr[1] = I/O Expander 2 B */ - {3, 0x22, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 2 C */ - }, - {3, IOEXP_TYPE_SEQUOIA_NABC, { {4, 0x20, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0x00, 0x00}, }, /* addr[0] = I/O Expander 3 A */ - {4, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0xff}, }, /* addr[1] = I/O Expander 3 B */ - {4, 0x22, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 3 C */ - }, - {4, IOEXP_TYPE_SEQUOIA_NABC, { {5, 0x20, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0x00, 0x00}, }, /* addr[0] = I/O Expander 4 A */ - {5, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0xff}, }, /* addr[1] = I/O Expander 4 B */ - {5, 0x22, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 4 C */ - }, - {5, IOEXP_TYPE_SEQUOIA_NABC, { {6, 0x20, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0x00, 0x00}, }, /* addr[0] = I/O Expander 5 A */ - {6, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0xff}, }, /* addr[1] = I/O Expander 5 B */ - {6, 0x22, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 5 C */ - }, - {6, IOEXP_TYPE_SEQUOIA_NABC, { {7, 0x20, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0x00, 0x00}, }, /* addr[0] = I/O Expander 6 A */ - {7, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0xff}, }, /* addr[1] = I/O Expander 6 B */ - {7, 0x22, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 6 C */ - }, - {7, IOEXP_TYPE_SEQUOIA_NABC, { {8, 0x20, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0x00, 0x00}, }, /* addr[0] = I/O Expander 7 A */ - {8, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0xff}, }, /* addr[1] = I/O Expander 7 B */ - {8, 0x22, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 7 C */ - }, -}; - - -struct inv_port_layout_s sequoia_port_layout[] = { - /* Port_ID / Chan_ID / IOEXP_ID / IOEXP_VIRT_OFFSET / TRANSCEIVER_TYPE / CHIP_TYPE / LANE_ID */ - { 0, 9, 0, 0, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 9, 10, 11, 12} }, - { 1, 10, 0, 1, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 1, 2, 3, 4} }, - { 2, 11, 0, 2, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 25, 26, 27, 28} }, - { 3, 12, 0, 3, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 17, 18, 19, 20} }, - { 4, 13, 0, 4, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 41, 42, 43, 44} }, - { 5, 14, 0, 5, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 33, 34, 35, 36} }, - { 6, 15, 0, 6, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 57, 58, 59, 60} }, - { 7, 16, 0, 7, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 49, 50, 51, 52} }, - { 8, 17, 1, 0, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 73, 74, 75, 76} }, - { 9, 18, 1, 1, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 65, 66, 67, 68} }, - {10, 19, 1, 2, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 89, 90, 91, 92} }, - {11, 20, 1, 3, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 81, 82, 83, 84} }, - {12, 21, 1, 4, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {105, 106, 107, 108} }, - {13, 22, 1, 5, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 97, 98, 99, 100} }, - {14, 23, 1, 6, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {121, 122, 123, 124} }, - {15, 24, 1, 7, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {113, 114, 115, 116} }, - {16, 25, 2, 0, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {137, 138, 139, 140} }, - {17, 26, 2, 1, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {129, 130, 131, 132} }, - {18, 27, 2, 2, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {153, 154, 155, 156} }, - {19, 28, 2, 3, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {145, 146, 147, 148} }, - {20, 29, 2, 4, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {169, 170, 171, 172} }, - {21, 30, 2, 5, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {161, 162, 163, 164} }, - {22, 31, 2, 6, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {185, 186, 187, 188} }, - {23, 32, 2, 7, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {177, 178, 179, 180} }, - {24, 33, 3, 0, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {201, 202, 203, 204} }, - {25, 34, 3, 1, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {193, 194, 195, 196} }, - {26, 35, 3, 2, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {217, 218, 219, 220} }, - {27, 36, 3, 3, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {209, 210, 211, 212} }, - {28, 37, 3, 4, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {233, 234, 235, 236} }, - {29, 38, 3, 5, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {225, 226, 227, 228} }, - {30, 39, 3, 6, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {249, 250, 251, 252} }, - {31, 40, 3, 7, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {241, 242, 243, 244} }, - {32, 44, 4, 3, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 13, 14, 15, 16} }, - {33, 43, 4, 2, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 5, 6, 7, 8} }, - {34, 42, 4, 1, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 29, 30, 31, 32} }, - {35, 41, 4, 0, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 21, 22, 23, 24} }, - {36, 48, 4, 7, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 45, 46, 47, 48} }, - {37, 47, 4, 6, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 37, 38, 39, 40} }, - {38, 46, 4, 5, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 61, 62, 63, 64} }, - {39, 45, 4, 4, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 53, 54, 55, 56} }, - {40, 52, 5, 3, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 77, 78, 79, 80} }, - {41, 51, 5, 2, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 69, 70, 71, 72} }, - {42, 50, 5, 1, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 93, 94, 95, 96} }, - {43, 49, 5, 0, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, { 85, 86, 87, 88} }, - {44, 56, 5, 7, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {109, 110, 111, 112} }, - {45, 55, 5, 6, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {101, 102, 103, 104} }, - {46, 54, 5, 5, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {125, 126, 127, 128} }, - {47, 53, 5, 4, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {117, 118, 119, 120} }, - {48, 60, 6, 3, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {141, 142, 143, 144} }, - {49, 59, 6, 2, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {133, 134, 135, 136} }, - {50, 58, 6, 1, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {157, 158, 159, 160} }, - {51, 57, 6, 0, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {149, 150, 151, 152} }, - {52, 64, 6, 7, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {173, 174, 175, 176} }, - {53, 63, 6, 6, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {165, 166, 167, 168} }, - {54, 62, 6, 5, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {189, 190, 191, 192} }, - {55, 61, 6, 4, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {181, 182, 183, 184} }, - {56, 68, 7, 3, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {205, 206, 207, 208} }, - {57, 67, 7, 2, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {197, 198, 199, 200} }, - {58, 66, 7, 1, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {221, 222, 223, 224} }, - {59, 65, 7, 0, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {213, 214, 215, 216} }, - {60, 72, 7, 7, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {237, 238, 239, 240} }, - {61, 71, 7, 6, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {229, 230, 231, 232} }, - {62, 70, 7, 5, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {253, 254, 255, 256} }, - {63, 69, 7, 4, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_REDWOOD, {245, 246, 247, 248} }, -}; -#endif - - -/* ========================================== - * Lavender Layout configuration - * ========================================== - */ -#if (PLATFORM_SETTINGS == PLATFORM_TYPE_LAVENDER_GA) -unsigned lavender_gpio_rest_mux = MUX_RST_GPIO_505_PCA9548; -#elif (PLATFORM_SETTINGS == PLATFORM_TYPE_LAVENDER_ONL) -unsigned lavender_gpio_rest_mux = MUX_RST_GPIO_69_PCA9548; -#endif - -#ifdef SWPS_LAVENDER -struct inv_ioexp_layout_s lavender_ioexp_layout[] = { - /* IOEXP_ID / IOEXP_TYPE / { Chan_ID, Chip_addr, Read_offset, Write_offset, config_offset, data_default, conf_default } */ - {0, IOEXP_TYPE_SEQUOIA_NABC, { { 1, 0x20, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0x00, 0x00}, }, /* addr[0] = I/O Expander 0 A */ - { 1, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0xff}, }, /* addr[1] = I/O Expander 0 B */ - { 1, 0x22, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 0 C */ - }, - {1, IOEXP_TYPE_SEQUOIA_NABC, { { 2, 0x20, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0x00, 0x00}, }, /* addr[0] = I/O Expander 1 A */ - { 2, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0xff}, }, /* addr[1] = I/O Expander 1 B */ - { 2, 0x22, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 1 C */ - }, - {2, IOEXP_TYPE_SEQUOIA_NABC, { { 3, 0x20, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0x00, 0x00}, }, /* addr[0] = I/O Expander 2 A */ - { 3, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0xff}, }, /* addr[1] = I/O Expander 2 B */ - { 3, 0x22, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 2 C */ - }, - {3, IOEXP_TYPE_SEQUOIA_NABC, { { 4, 0x20, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0x00, 0x00}, }, /* addr[0] = I/O Expander 3 A */ - { 4, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0xff}, }, /* addr[1] = I/O Expander 3 B */ - { 4, 0x22, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 3 C */ - }, - {4, IOEXP_TYPE_SEQUOIA_NABC, { { 9, 0x20, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0x00, 0x00}, }, /* addr[0] = I/O Expander 4 A */ - { 9, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0xff}, }, /* addr[1] = I/O Expander 4 B */ - { 9, 0x22, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 4 C */ - }, - {5, IOEXP_TYPE_SEQUOIA_NABC, { {10, 0x20, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0x00, 0x00}, }, /* addr[0] = I/O Expander 5 A */ - {10, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0xff}, }, /* addr[1] = I/O Expander 5 B */ - {10, 0x22, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 5 C */ - }, - {6, IOEXP_TYPE_SEQUOIA_NABC, { {11, 0x20, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0x00, 0x00}, }, /* addr[0] = I/O Expander 6 A */ - {11, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0xff}, }, /* addr[1] = I/O Expander 6 B */ - {11, 0x22, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 6 C */ - }, - {7, IOEXP_TYPE_SEQUOIA_NABC, { {12, 0x20, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0x00, 0x00}, }, /* addr[0] = I/O Expander 7 A */ - {12, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0xff}, }, /* addr[1] = I/O Expander 7 B */ - {12, 0x22, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 7 C */ - }, - {8, IOEXP_TYPE_LAVENDER_P65, { { 5, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xF6, 0xff}, {0xF8, 0xff}, }, }, /* addr[0] = I/O Expander CPU */ - }, -}; - - -struct inv_port_layout_s lavender_port_layout[] = { - /* Port_ID / Chan_ID / IOEXP_ID / IOEXP_VIRT_OFFSET / TRANSCEIVER_TYPE / CHIP_TYPE / LANE_ID */ - { 0, 17, 0, 0, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {188, 189, 190, 191} }, - { 1, 18, 0, 1, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {184, 185, 186, 187} }, - { 2, 19, 0, 2, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {180, 181, 182, 183} }, - { 3, 20, 0, 3, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {176, 177, 178, 179} }, - { 4, 21, 0, 4, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {172, 173, 174, 175} }, - { 5, 22, 0, 5, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {168, 169, 170, 171} }, - { 6, 23, 0, 6, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {164, 165, 166, 167} }, - { 7, 24, 0, 7, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {160, 161, 162, 163} }, - { 8, 25, 1, 0, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {156, 157, 158, 159} }, - { 9, 26, 1, 1, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {152, 153, 154, 155} }, - {10, 27, 1, 2, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {148, 149, 150, 151} }, - {11, 28, 1, 3, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {144, 145, 146, 147} }, - {12, 29, 1, 4, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {140, 141, 142, 143} }, - {13, 30, 1, 5, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {136, 137, 138, 139} }, - {14, 31, 1, 6, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {132, 133, 134, 135} }, - {15, 32, 1, 7, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {128, 129, 130, 131} }, - {16, 33, 2, 0, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, { 0, 1, 2, 3} }, - {17, 34, 2, 1, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, { 4, 5, 6, 7} }, - {18, 35, 2, 2, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, { 8, 9, 10, 11} }, - {19, 36, 2, 3, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, { 12, 13, 14, 15} }, - {20, 37, 2, 4, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, { 16, 17, 18, 19} }, - {21, 38, 2, 5, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, { 20, 21, 22, 23} }, - {22, 39, 2, 6, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, { 24, 25, 26, 27} }, - {23, 40, 2, 7, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, { 28, 29, 30, 31} }, - {24, 41, 3, 0, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, { 32, 33, 34, 35} }, - {25, 42, 3, 1, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, { 36, 37, 38, 39} }, - {26, 43, 3, 2, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, { 40, 41, 42, 43} }, - {27, 44, 3, 3, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, { 44, 45, 46, 47} }, - {28, 45, 3, 4, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, { 48, 49, 50, 51} }, - {29, 46, 3, 5, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, { 52, 53, 54, 55} }, - {30, 47, 3, 6, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, { 56, 57, 58, 59} }, - {31, 48, 3, 7, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, { 60, 61, 62, 63} }, - {32, 49, 4, 0, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {256, 257, 258, 259} }, - {33, 50, 4, 1, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {260, 261, 262, 263} }, - {34, 51, 4, 2, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {264, 265, 266, 267} }, - {35, 52, 4, 3, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {268, 269, 270, 271} }, - {36, 53, 4, 4, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {272, 273, 274, 275} }, - {37, 54, 4, 5, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {276, 277, 278, 279} }, - {38, 55, 4, 6, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {280, 281, 282, 283} }, - {39, 56, 4, 7, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {284, 285, 286, 287} }, - {40, 57, 5, 0, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {288, 289, 290, 291} }, - {41, 58, 5, 1, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {292, 293, 294, 295} }, - {42, 59, 5, 2, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {296, 297, 298, 299} }, - {43, 60, 5, 3, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {300, 301, 302, 303} }, - {44, 61, 5, 4, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {304, 305, 306, 307} }, - {45, 62, 5, 5, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {308, 309, 310, 311} }, - {46, 63, 5, 6, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {312, 313, 314, 315} }, - {47, 64, 5, 7, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {316, 317, 318, 319} }, - {48, 65, 6, 0, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {444, 445, 446, 447} }, - {49, 66, 6, 1, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {440, 441, 442, 443} }, - {50, 67, 6, 2, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {436, 437, 438, 439} }, - {51, 68, 6, 3, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {432, 433, 434, 435} }, - {52, 69, 6, 4, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {428, 429, 430, 431} }, - {53, 70, 6, 5, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {424, 425, 426, 427} }, - {54, 71, 6, 6, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {420, 421, 422, 423} }, - {55, 72, 6, 7, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {416, 417, 418, 419} }, - {56, 73, 7, 0, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {412, 413, 414, 415} }, - {57, 74, 7, 1, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {408, 409, 410, 411} }, - {58, 75, 7, 2, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {404, 405, 406, 407} }, - {59, 76, 7, 3, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {400, 401, 402, 403} }, - {60, 77, 7, 4, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {396, 397, 398, 399} }, - {61, 78, 7, 5, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {392, 393, 394, 395} }, - {62, 79, 7, 6, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {388, 389, 390, 391} }, - {63, 80, 7, 7, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {384, 385, 386, 387} }, - {64, 5, 8, 0, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, { 64, 65, 66, 67} }, -}; -#endif - -/* =========================================================== - * Cottonwood Layout configuration Rangeley (Rangeley CPU board) - * =========================================================== - */ -#ifdef SWPS_COTTONWOOD_RANGELEY -unsigned cottonwood_rangeley_gpio_rest_mux = MUX_RST_GPIO_500_PCA9548; - -struct inv_ioexp_layout_s cottonwood_rangeley_ioexp_layout[] = { - /* IOEXP_ID / IOEXP_TYPE / { Chan_ID, Chip_addr, Read_offset, Write_offset, config_offset, data_default, conf_default } */ - {0, CPLD_TYPE_COTTONWOOD,{ {1, 0x55, {22, 23, 24, 25}, {22, 23, 24, 25}, {-1, -1, -1, -1}, {0xee, 0xee, 0x99, 0x99}, {0x00, 0x00, 0x00, 0x00}, }, - }, - }, -}; - - -struct inv_port_layout_s cottonwood_rangeley_port_layout[] = { - /* Port_ID / Chan_ID / IOEXP_ID / IOEXP_VIRT_OFFSET / TRANSCEIVER_TYPE / CHIP_TYPE / LANE_ID */ - { 0, 2, 0, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 75} }, - { 1, 3, 0, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 77} }, - { 2, 4, 0, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 79} }, - { 3, 5, 0, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_REDWOOD, { 81} }, -}; -#endif - -/* =========================================================== - * Maple Layout configuration (Old) - * =========================================================== - */ -#ifdef SWPS_MAPLE_GA -unsigned maple_ga_gpio_rest_mux = MUX_RST_GPIO_69_PCA9548; - -struct inv_ioexp_layout_s maple_ga_ioexp_layout[] = { - /* IOEXP_ID / IOEXP_TYPE / { Chan_ID, Chip_addr, Read_offset, Write_offset, config_offset, data_default, conf_default } */ - {0, IOEXP_TYPE_MAPLE_0ABC, { {2, 0x20, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0x00, 0x00}, }, /* addr[0] = I/O Expander 0 A */ - {2, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0xff}, }, /* addr[1] = I/O Expander 0 B */ - {2, 0x22, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 0 C */ - }, - {1, IOEXP_TYPE_MAPLE_NABC, { {3, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {3, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {3, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {2, IOEXP_TYPE_MAPLE_NABC, { {4, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {4, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {4, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {3, IOEXP_TYPE_MAPLE_NABC, { {5, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {5, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {5, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {4, IOEXP_TYPE_MAPLE_NABC, { {6, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {6, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {6, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {5, IOEXP_TYPE_MAPLE_NABC, { {7, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {7, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {7, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {6, IOEXP_TYPE_MAPLE_NABC, { {8, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {8, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {8, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, -}; - -struct inv_port_layout_s maple_ga_port_layout[] = { - /* Port_ID / Chan_ID / IOEXP_ID / IOEXP_VIRT_OFFSET / TRANSCEIVER_TYPE / CHIP_TYPE / LANE_ID */ - { 0, 18, 1, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 1} }, - { 1, 19, 1, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 2} }, - { 2, 20, 1, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 3} }, - { 3, 21, 1, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 4} }, - { 4, 22, 1, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 5} }, - { 5, 23, 1, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 6} }, - { 6, 24, 1, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 7} }, - { 7, 25, 1, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 8} }, - { 8, 26, 2, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 13} }, - { 9, 27, 2, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 14} }, - {10, 28, 2, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 15} }, - {11, 29, 2, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 16} }, - {12, 30, 2, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 21} }, - {13, 31, 2, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 22} }, - {14, 32, 2, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 23} }, - {15, 33, 2, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 24} }, - {16, 34, 3, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 29} }, - {17, 35, 3, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 30} }, - {18, 36, 3, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 31} }, - {19, 37, 3, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 32} }, - {20, 38, 3, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 33} }, - {21, 39, 3, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 34} }, - {22, 40, 3, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 35} }, - {23, 41, 3, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 36} }, - {24, 42, 4, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 41} }, - {25, 43, 4, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 42} }, - {26, 44, 4, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 43} }, - {27, 45, 4, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 44} }, - {28, 46, 4, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 49} }, - {29, 47, 4, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 50} }, - {30, 48, 4, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 51} }, - {31, 49, 4, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 52} }, - {32, 50, 5, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 57} }, - {33, 51, 5, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 58} }, - {34, 52, 5, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 59} }, - {35, 53, 5, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 60} }, - {36, 54, 5, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 61} }, - {37, 55, 5, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 62} }, - {38, 56, 5, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 63} }, - {39, 57, 5, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 64} }, - {40, 58, 6, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 65} }, - {41, 59, 6, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 66} }, - {42, 60, 6, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 67} }, - {43, 61, 6, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 68} }, - {44, 62, 6, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 69} }, - {45, 63, 6, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 70} }, - {46, 64, 6, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 71} }, - {47, 65, 6, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 72} }, - {48, 10, 0, 0, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_MAPLE, { 77, 78, 79, 80} }, - {49, 11, 0, 1, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_MAPLE, { 85, 86, 87, 88} }, - {50, 12, 0, 2, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_MAPLE, { 93, 94, 95, 96} }, - {51, 13, 0, 3, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_MAPLE, { 97, 98, 99,100} }, - {52, 14, 0, 4, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_MAPLE, {105,106,107,108} }, - {53, 15, 0, 5, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_MAPLE, {113,114,115,116} }, - {54, 16, 0, 6, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_MAPLE, {121,122,123,124} }, - {55, 17, 0, 7, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_MAPLE, {125,126,127,128} }, -}; -#endif - -/* =========================================================== - * Maple Layout configuration (B version) - * =========================================================== - */ -#ifdef SWPS_MAPLE_B -unsigned maple_b_gpio_rest_mux = MUX_RST_GPIO_69_PCA9548; - -struct inv_ioexp_layout_s maple_b_ioexp_layout[] = { - /* IOEXP_ID / IOEXP_TYPE / { Chan_ID, Chip_addr, Read_offset, Write_offset, config_offset, data_default, conf_default } */ - {0, IOEXP_TYPE_MAPLE_0ABC, { { 6, 0x20, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0x00, 0x00}, }, /* addr[0] = I/O Expander 0 A */ - { 6, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0xff}, }, /* addr[1] = I/O Expander 0 B */ - { 6, 0x22, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 0 C */ - }, - {1, IOEXP_TYPE_MAPLE_NABC, { { 7, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - { 7, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - { 7, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {2, IOEXP_TYPE_MAPLE_NABC, { { 8, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - { 8, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - { 8, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {3, IOEXP_TYPE_MAPLE_NABC, { { 9, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - { 9, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - { 9, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {4, IOEXP_TYPE_MAPLE_NABC, { {10, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {10, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {10, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {5, IOEXP_TYPE_MAPLE_NABC, { {11, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {11, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {11, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {6, IOEXP_TYPE_MAPLE_NABC, { {12, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {12, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {12, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, -}; - -struct inv_port_layout_s maple_b_port_layout[] = { - /* Port_ID / Chan_ID / IOEXP_ID / IOEXP_VIRT_OFFSET / TRANSCEIVER_TYPE / CHIP_TYPE / LANE_ID */ - { 1, 23, 1, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 2} }, - { 2, 22, 1, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 1} }, - { 3, 25, 1, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 4} }, - { 4, 24, 1, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 3} }, - { 5, 27, 1, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 6} }, - { 6, 26, 1, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 5} }, - { 7, 29, 1, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 8} }, - { 8, 28, 1, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 7} }, - { 9, 31, 2, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 14} }, - {10, 30, 2, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 13} }, - {11, 33, 2, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 16} }, - {12, 32, 2, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 15} }, - {13, 35, 2, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 22} }, - {14, 34, 2, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 21} }, - {15, 37, 2, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 24} }, - {16, 36, 2, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 23} }, - {17, 39, 3, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 30} }, - {18, 38, 3, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 29} }, - {19, 41, 3, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 32} }, - {20, 40, 3, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 31} }, - {21, 43, 3, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 34} }, - {22, 42, 3, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 33} }, - {23, 45, 3, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 36} }, - {24, 44, 3, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 35} }, - {25, 47, 4, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 42} }, - {26, 46, 4, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 41} }, - {27, 49, 4, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 44} }, - {28, 48, 4, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 43} }, - {29, 51, 4, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 50} }, - {30, 50, 4, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 49} }, - {31, 53, 4, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 52} }, - {32, 52, 4, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 51} }, - {33, 55, 5, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 58} }, - {34, 54, 5, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 57} }, - {35, 57, 5, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 60} }, - {36, 56, 5, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 59} }, - {37, 59, 5, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 62} }, - {38, 58, 5, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 61} }, - {39, 61, 5, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 64} }, - {40, 60, 5, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 63} }, - {41, 63, 6, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 66} }, - {42, 62, 6, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 65} }, - {43, 65, 6, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 68} }, - {44, 64, 6, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 67} }, - {45, 67, 6, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 70} }, - {46, 66, 6, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 69} }, - {47, 69, 6, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 72} }, - {48, 68, 6, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 71} }, - {49, 15, 0, 1, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_MAPLE, { 77, 78, 79, 80} }, - {50, 14, 0, 0, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_MAPLE, { 85, 86, 87, 88} }, - {51, 17, 0, 3, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_MAPLE, { 97, 98, 99,100} }, - {52, 16, 0, 2, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_MAPLE, { 93, 94, 95, 96} }, - {53, 19, 0, 5, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_MAPLE, {105,106,107,108} }, - {54, 18, 0, 4, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_MAPLE, {113,114,115,116} }, - {55, 21, 0, 7, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_MAPLE, {125,126,127,128} }, - {56, 20, 0, 6, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_MAPLE, {121,122,123,124} }, -}; -#endif - -/* =========================================================== - * Maple Layout configuration (J version) - * =========================================================== - */ -#ifdef SWPS_MAPLE_J -unsigned maple_j_gpio_rest_mux = MUX_RST_GPIO_69_PCA9548; - -struct inv_ioexp_layout_s maple_j_ioexp_layout[] = { - /* IOEXP_ID / IOEXP_TYPE / { Chan_ID, Chip_addr, Read_offset, Write_offset, config_offset, data_default, conf_default } */ - {0, IOEXP_TYPE_MAPLE_0ABC, { { 6, 0x20, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0x00, 0x00}, }, /* addr[0] = I/O Expander 0 A */ - { 6, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0xff}, }, /* addr[1] = I/O Expander 0 B */ - { 6, 0x22, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 0 C */ - }, - {1, IOEXP_TYPE_MAPLE_NABC, { { 7, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - { 7, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - { 7, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {2, IOEXP_TYPE_MAPLE_NABC, { { 8, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - { 8, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - { 8, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {3, IOEXP_TYPE_MAPLE_NABC, { { 9, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - { 9, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - { 9, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {4, IOEXP_TYPE_MAPLE_NABC, { {10, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {10, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {10, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {5, IOEXP_TYPE_MAPLE_NABC, { {11, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {11, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {11, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {6, IOEXP_TYPE_MAPLE_NABC, { {12, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {12, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {12, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, -}; - -struct inv_port_layout_s maple_j_port_layout[] = { - /* Port_ID / Chan_ID / IOEXP_ID / IOEXP_VIRT_OFFSET / TRANSCEIVER_TYPE / CHIP_TYPE / LANE_ID */ - { 0, 22, 1, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 1} }, - { 1, 23, 1, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 2} }, - { 2, 24, 1, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 3} }, - { 3, 25, 1, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 4} }, - { 4, 26, 1, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 5} }, - { 5, 27, 1, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 6} }, - { 6, 28, 1, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 7} }, - { 7, 29, 1, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 8} }, - { 8, 30, 2, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 13} }, - { 9, 31, 2, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 14} }, - {10, 32, 2, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 15} }, - {11, 33, 2, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 16} }, - {12, 34, 2, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 21} }, - {13, 35, 2, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 22} }, - {14, 36, 2, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 23} }, - {15, 37, 2, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 24} }, - {16, 38, 3, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 29} }, - {17, 39, 3, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 30} }, - {18, 40, 3, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 31} }, - {19, 41, 3, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 32} }, - {20, 42, 3, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 33} }, - {21, 43, 3, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 34} }, - {22, 44, 3, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 35} }, - {23, 45, 3, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 36} }, - {24, 46, 4, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 41} }, - {25, 47, 4, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 42} }, - {26, 48, 4, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 43} }, - {27, 49, 4, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 44} }, - {28, 50, 4, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 49} }, - {29, 51, 4, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 50} }, - {30, 52, 4, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 51} }, - {31, 53, 4, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 52} }, - {32, 54, 5, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 57} }, - {33, 55, 5, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 58} }, - {34, 56, 5, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 59} }, - {35, 57, 5, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 60} }, - {36, 58, 5, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 61} }, - {37, 59, 5, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 62} }, - {38, 60, 5, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 63} }, - {39, 61, 5, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 64} }, - {40, 62, 6, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 65} }, - {41, 63, 6, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 66} }, - {42, 64, 6, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 67} }, - {43, 65, 6, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 68} }, - {44, 66, 6, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 69} }, - {45, 67, 6, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 70} }, - {46, 68, 6, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 71} }, - {47, 69, 6, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 72} }, - {48, 14, 0, 0, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_MAPLE, { 85, 86, 87, 88} }, - {49, 15, 0, 1, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_MAPLE, { 77, 78, 79, 80} }, - {50, 16, 0, 2, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_MAPLE, { 93, 94, 95, 96} }, - {51, 17, 0, 3, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_MAPLE, { 97, 98, 99,100} }, - {52, 18, 0, 4, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_MAPLE, {113,114,115,116} }, - {53, 19, 0, 5, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_MAPLE, {105,106,107,108} }, - {54, 20, 0, 6, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_MAPLE, {121,122,123,124} }, - {55, 21, 0, 7, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_MAPLE, {125,126,127,128} }, -}; -#endif - -/* ========================================== - * Gulmohar Layout configuration - * ========================================== - */ -#ifdef SWPS_GULMOHAR -unsigned gulmohar_gpio_rest_mux = MUX_RST_GPIO_505_PCA9548; - -struct inv_ioexp_layout_s gulmohar_ioexp_layout[] = { - /* IOEXP_ID / IOEXP_TYPE / { Chan_ID, Chip_addr, Read_offset, Write_offset, config_offset, data_default, conf_default } */ - {0, IOEXP_TYPE_GULMOHAR_NABC, { {2, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xf3, 0xf3}, {0xf3, 0xf3}, }, /* addr[0] = I/O Expander N A */ - {2, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xf3, 0xf3}, {0xf3, 0xf3}, }, /* addr[1] = I/O Expander N B */ - {2, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {1, IOEXP_TYPE_GULMOHAR_NABC, { {3, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xf3, 0xf3}, {0xf3, 0xf3}, }, /* addr[0] = I/O Expander N A */ - {3, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xf3, 0xf3}, {0xf3, 0xf3}, }, /* addr[1] = I/O Expander N B */ - {3, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {2, IOEXP_TYPE_GULMOHAR_NABC, { {4, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xf3, 0xf3}, {0xf3, 0xf3}, }, /* addr[0] = I/O Expander N A */ - {4, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xf3, 0xf3}, {0xf3, 0xf3}, }, /* addr[1] = I/O Expander N B */ - {4, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {3, IOEXP_TYPE_GULMOHAR_NABC, { {5, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xf3, 0xf3}, {0xf3, 0xf3}, }, /* addr[0] = I/O Expander N A */ - {5, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xf3, 0xf3}, {0xf3, 0xf3}, }, /* addr[1] = I/O Expander N B */ - {5, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {4, IOEXP_TYPE_GULMOHAR_NABC, { {6, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xf3, 0xf3}, {0xf3, 0xf3}, }, /* addr[0] = I/O Expander N A */ - {6, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xf3, 0xf3}, {0xf3, 0xf3}, }, /* addr[1] = I/O Expander N B */ - {6, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {5, IOEXP_TYPE_GULMOHAR_NABC, { {7, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xf3, 0xf3}, {0xf3, 0xf3}, }, /* addr[0] = I/O Expander N A */ - {7, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xf3, 0xf3}, {0xf3, 0xf3}, }, /* addr[1] = I/O Expander N B */ - {7, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {6, IOEXP_TYPE_GULMOHAR_7ABC, { {8, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xc0, 0xff}, {0xc0, 0xc0}, }, /* addr[0] = I/O Expander 7 A */ - {8, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xc0, 0xff}, }, /* addr[1] = I/O Expander 7 B */ - {8, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xc0, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 7 C */ - }, -}; - - - -struct inv_port_layout_s gulmohar_port_layout[] = { - /* Port_ID / Chan_ID / IOEXP_ID / IOEXP_VIRT_OFFSET / TRANSCEIVER_TYPE / CHIP_TYPE / LANE_ID */ - { 0, 10, 0, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, { 1} }, - { 1, 11, 0, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, { 2} }, - { 2, 12, 0, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, { 3} }, - { 3, 13, 0, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, { 4} }, - { 4, 14, 0, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, { 5} }, - { 5, 15, 0, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, { 6} }, - { 6, 16, 0, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, { 7} }, - { 7, 17, 0, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, { 8} }, - { 8, 18, 1, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, { 9} }, - { 9, 19, 1, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, { 10} }, - {10, 20, 1, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, { 11} }, - {11, 21, 1, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, { 12} }, - {12, 22, 1, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, { 21} }, - {13, 23, 1, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, { 22} }, - {14, 24, 1, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, { 23} }, - {15, 25, 1, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, { 24} }, - {16, 26, 2, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, { 33} }, - {17, 27, 2, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, { 34} }, - {18, 28, 2, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, { 35} }, - {19, 29, 2, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, { 36} }, - {20, 30, 2, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, { 37} }, - {21, 31, 2, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, { 38} }, - {22, 32, 2, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, { 39} }, - {23, 33, 2, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, { 40} }, - {24, 34, 3, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, { 41} }, - {25, 35, 3, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, { 42} }, - {26, 36, 3, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, { 43} }, - {27, 37, 3, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, { 44} }, - {28, 38, 3, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, { 49} }, - {29, 39, 3, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, { 50} }, - {30, 40, 3, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, { 51} }, - {31, 41, 3, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, { 52} }, - {32, 42, 4, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, { 53} }, - {33, 43, 4, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, { 54} }, - {34, 44, 4, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, { 55} }, - {35, 45, 4, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, { 56} }, - {36, 46, 4, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, { 65} }, - {37, 47, 4, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, { 66} }, - {38, 48, 4, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, { 67} }, - {39, 49, 4, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, { 68} }, - {40, 50, 5, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, { 69} }, - {41, 51, 5, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, { 70} }, - {42, 52, 5, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, { 71} }, - {43, 53, 5, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, { 72} }, - {44, 54, 5, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, { 81} }, - {45, 55, 5, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, { 82} }, - {46, 56, 5, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, { 83} }, - {47, 57, 5, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, { 84} }, - {48, 58, 6, 0, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, { 97, 98, 99,100} }, - {49, 59, 6, 1, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, { 85, 86, 87, 88} }, - {50, 60, 6, 2, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {101,102,103,104} }, - {51, 61, 6, 3, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {105,106,107,108} }, - {52, 62, 6, 4, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {109,110,111,112} }, - {53, 63, 6, 5, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {109,110,111,112} }, -}; -#endif - - -/* ========================================== - * Gulmohar_2T EVT1 Layout configuration - * ========================================== - */ -#ifdef SWPS_GULMOHAR_2T_EVT1 -unsigned gulmohar_2t_evt1_gpio_rest_mux = MUX_RST_GPIO_505_PCA9548; - -struct inv_ioexp_layout_s gulmohar_2t_evt1_ioexp_layout[] = { - /* IOEXP_ID / IOEXP_TYPE / { Chan_ID, Chip_addr, Read_offset, Write_offset, config_offset, data_default, conf_default } */ - {0, IOEXP_TYPE_GULMOHAR_2T_EVT1_NABC,{ {2, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xdd, 0xdd}, {0xdd, 0xdd}, }, /* addr[0] = I/O Expander N A */ - {2, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xdd, 0xdd}, {0xdd, 0xdd}, }, /* addr[1] = I/O Expander N B */ - {2, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {1, IOEXP_TYPE_GULMOHAR_2T_EVT1_1ABC,{ {3, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xdd, 0xdd}, {0xdd, 0xdd}, }, /* addr[0] = I/O Expander N A */ - {3, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xf3, 0xf3}, {0xf3, 0xf3}, }, /* addr[1] = I/O Expander N B */ - {3, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {2, IOEXP_TYPE_GULMOHAR_2T_EVT1_NABC,{ {4, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xdd, 0xdd}, {0xdd, 0xdd}, }, /* addr[0] = I/O Expander N A */ - {4, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xdd, 0xdd}, {0xdd, 0xdd}, }, /* addr[1] = I/O Expander N B */ - {4, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {3, IOEXP_TYPE_GULMOHAR_2T_EVT1_3ABC,{ {5, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xf3, 0xf3}, {0xf3, 0xf3}, }, /* addr[0] = I/O Expander N A */ - {5, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xdd, 0xdd}, {0xdd, 0xdd}, }, /* addr[1] = I/O Expander N B */ - {5, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {4, IOEXP_TYPE_GULMOHAR_2T_EVT1_NABC,{ {6, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xdd, 0xdd}, {0xdd, 0xdd}, }, /* addr[0] = I/O Expander N A */ - {6, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xdd, 0xdd}, {0xdd, 0xdd}, }, /* addr[1] = I/O Expander N B */ - {6, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {5, IOEXP_TYPE_GULMOHAR_2T_EVT1_NABC,{ {7, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xdd, 0xdd}, {0xdd, 0xdd}, }, /* addr[0] = I/O Expander N A */ - {7, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xdd, 0xdd}, {0xdd, 0xdd}, }, /* addr[1] = I/O Expander N B */ - {7, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {6, IOEXP_TYPE_GULMOHAR_2T_EVT1_7ABC,{ {8, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xd6, 0xda}, {0x18, 0xe3}, }, /* addr[0] = I/O Expander 7 A */ - {8, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xd6, 0xda}, {0x18, 0xe3}, }, /* addr[1] = I/O Expander 7 B */ - {8, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xd6, 0xff}, {0x18, 0xff}, }, }, /* addr[2] = I/O Expander 7 C */ - }, -}; - - - -struct inv_port_layout_s gulmohar_2t_evt1_port_layout[] = { - /* Port_ID / Chan_ID / IOEXP_ID / IOEXP_VIRT_OFFSET / TRANSCEIVER_TYPE / CHIP_TYPE / LANE_ID */ - { 0, 10, 0, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, {-99} }, - { 1, 11, 0, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, {-99} }, - { 2, 12, 0, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, {-99} }, - { 3, 13, 0, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, {-99} }, - { 4, 14, 0, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, {-99} }, - { 5, 15, 0, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, {-99} }, - { 6, 16, 0, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, {-99} }, - { 7, 17, 0, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, {-99} }, - { 8, 18, 1, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, {-99} }, - { 9, 19, 1, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, {-99} }, - {10, 20, 1, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, {-99} }, - {11, 21, 1, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, {-99} }, - {12, 22, 1, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, {-99} }, - {13, 23, 1, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, {-99} }, - {14, 24, 1, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, {-99} }, - {15, 25, 1, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, {-99} }, - {16, 26, 2, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, {-99} }, - {17, 27, 2, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, {-99} }, - {18, 28, 2, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, {-99} }, - {19, 29, 2, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, {-99} }, - {20, 30, 2, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, {-99} }, - {21, 31, 2, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, {-99} }, - {22, 32, 2, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, {-99} }, - {23, 33, 2, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, {-99} }, - {24, 34, 3, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, {-99} }, - {25, 35, 3, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, {-99} }, - {26, 36, 3, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, {-99} }, - {27, 37, 3, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, {-99} }, - {28, 38, 3, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, {-99} }, - {29, 39, 3, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, {-99} }, - {30, 40, 3, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, {-99} }, - {31, 41, 3, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, {-99} }, - {32, 42, 4, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, {-99} }, - {33, 43, 4, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, {-99} }, - {34, 44, 4, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, {-99} }, - {35, 45, 4, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, {-99} }, - {36, 46, 4, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, {-99} }, - {37, 47, 4, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, {-99} }, - {38, 48, 4, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, {-99} }, - {39, 49, 4, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, {-99} }, - {40, 50, 5, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, {-99} }, - {41, 51, 5, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, {-99} }, - {42, 52, 5, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, {-99} }, - {43, 53, 5, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, {-99} }, - {44, 54, 5, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, {-99} }, - {45, 55, 5, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, {-99} }, - {46, 56, 5, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, {-99} }, - {47, 57, 5, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_LAVENDER, {-99} }, - {48, 59, 6, 1, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {-99,-99,-99,-99} }, - {49, 58, 6, 0, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {-99,-99,-99,-99} }, - {50, 61, 6, 3, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {-99,-99,-99,-99} }, - {51, 60, 6, 2, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {-99,-99,-99,-99} }, - {52, 63, 6, 5, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {-99,-99,-99,-99} }, - {53, 62, 6, 4, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {-99,-99,-99,-99} }, - {54, 65, 6, 7, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {-99,-99,-99,-99} }, - {55, 64, 6, 6, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_LAVENDER, {-99,-99,-99,-99} }, -}; -#endif - - -/* =========================================================== - * Peony-SFP Layout configuration - * =========================================================== - */ -#ifdef SWPS_PEONY_SFP -unsigned peony_sfp_gpio_rest_mux = MUX_RST_CPLD_C0_A77_70_74_RST_ALL; - -struct inv_ioexp_layout_s peony_sfp_ioexp_layout[] = { - /* IOEXP_ID / IOEXP_TYPE / { Chan_ID, Chip_addr, Read_offset, Write_offset, config_offset, data_default, conf_default } */ - {0, IOEXP_TYPE_QSFP_6P_LAYOUT_1, { {4, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xc0, 0xff}, {0xc0, 0xc0}, }, /* addr[0] = I/O Expander 0 A */ - {4, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xc0, 0xff}, }, /* addr[1] = I/O Expander 0 B */ - {4, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xc0, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 0 C */ - }, - {1, IOEXP_TYPE_SFP_8P_LAYOUT_1, { {5, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {5, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {5, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {2, IOEXP_TYPE_SFP_8P_LAYOUT_1, { {6, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {6, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {6, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {3, IOEXP_TYPE_SFP_8P_LAYOUT_1, { {7, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {7, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {7, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {4, IOEXP_TYPE_SFP_8P_LAYOUT_1, { {8, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {8, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {8, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {5, IOEXP_TYPE_SFP_8P_LAYOUT_1, { {9, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {9, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {9, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {6, IOEXP_TYPE_SFP_8P_LAYOUT_1, { {10, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {10, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {10, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, -}; - -struct inv_port_layout_s peony_sfp_port_layout[] = { - /* Port_ID / Chan_ID / IOEXP_ID / IOEXP_VIRT_OFFSET / TRANSCEIVER_TYPE / CHIP_TYPE / LANE_ID */ - { 0, 20, 1, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 1} }, - { 1, 21, 1, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 2} }, - { 2, 22, 1, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 3} }, - { 3, 23, 1, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 4} }, - { 4, 24, 1, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 5} }, - { 5, 25, 1, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 6} }, - { 6, 26, 1, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 7} }, - { 7, 27, 1, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 8} }, - { 8, 28, 2, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 13} }, - { 9, 29, 2, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 14} }, - {10, 30, 2, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 15} }, - {11, 31, 2, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 16} }, - {12, 32, 2, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 21} }, - {13, 33, 2, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 22} }, - {14, 34, 2, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 23} }, - {15, 35, 2, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 24} }, - {16, 36, 3, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 29} }, - {17, 37, 3, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 30} }, - {18, 38, 3, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 31} }, - {19, 39, 3, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 32} }, - {20, 40, 3, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 33} }, - {21, 41, 3, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 34} }, - {22, 42, 3, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 35} }, - {23, 43, 3, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 36} }, - {24, 44, 4, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 65} }, - {25, 45, 4, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 66} }, - {26, 46, 4, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 67} }, - {27, 47, 4, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 68} }, - {28, 48, 4, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 69} }, - {29, 49, 4, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 70} }, - {30, 50, 4, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 71} }, - {31, 51, 4, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 72} }, - {32, 52, 5, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 97} }, - {33, 53, 5, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 98} }, - {34, 54, 5, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, { 99} }, - {35, 55, 5, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, {100} }, - {36, 56, 5, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, {105} }, - {37, 57, 5, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, {106} }, - {38, 58, 5, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, {107} }, - {39, 59, 5, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, {108} }, - {40, 60, 6, 0, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, {113} }, - {41, 61, 6, 1, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, {114} }, - {42, 62, 6, 2, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, {115} }, - {43, 63, 6, 3, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, {116} }, - {44, 64, 6, 4, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, {121} }, - {45, 65, 6, 5, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, {122} }, - {46, 66, 6, 6, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, {123} }, - {47, 67, 6, 7, TRANSVR_TYPE_SFP, CHIP_TYPE_MAPLE, {124} }, - {48, 12, 0, 0, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_MAPLE, { 49, 50, 51, 52} }, - {49, 13, 0, 1, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_MAPLE, { 57, 58, 59, 60} }, - {50, 14, 0, 2, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_MAPLE, { 61, 62, 63, 64} }, - {51, 15, 0, 3, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_MAPLE, { 77, 78, 79, 80} }, - {52, 16, 0, 4, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_MAPLE, { 85, 86, 87, 88} }, - {53, 17, 0, 5, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_MAPLE, { 93, 94, 95, 96} }, -}; -#endif - - -/* =========================================================== - * Peony-Copper Layout configuration - * =========================================================== - */ -#ifdef SWPS_PEONY_COPPER -unsigned peony_copper_gpio_rest_mux = MUX_RST_CPLD_C0_A77_70_74_RST_ALL; - -struct inv_ioexp_layout_s peony_copper_ioexp_layout[] = { - /* IOEXP_ID / IOEXP_TYPE / { Chan_ID, Chip_addr, Read_offset, Write_offset, config_offset, data_default, conf_default } */ - {0, IOEXP_TYPE_QSFP_6P_LAYOUT_1, { {10, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xc0, 0xff}, {0xc0, 0xc0}, }, /* addr[0] = I/O Expander 0 A */ - {10, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xc0, 0xff}, }, /* addr[1] = I/O Expander 0 B */ - {10, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xc0, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 0 C */ - }, -}; - -struct inv_port_layout_s peony_copper_port_layout[] = { - /* Port_ID / Chan_ID / IOEXP_ID / IOEXP_VIRT_OFFSET / TRANSCEIVER_TYPE / CHIP_TYPE / LANE_ID */ - {48, 4, 0, 0, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_MAPLE, { 49, 50, 51, 52} }, - {49, 5, 0, 1, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_MAPLE, { 57, 58, 59, 60} }, - {50, 6, 0, 2, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_MAPLE, { 61, 62, 63, 64} }, - {51, 7, 0, 3, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_MAPLE, { 77, 78, 79, 80} }, - {52, 8, 0, 4, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_MAPLE, { 85, 86, 87, 88} }, - {53, 9, 0, 5, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_MAPLE, { 93, 94, 95, 96} }, -}; -#endif - - -/* =========================================================== - * Cedar Layout configuration - * =========================================================== - */ -#ifdef SWPS_CEDAR_GA -unsigned cedar_ga_gpio_rest_mux = MUX_RST_GPIO_69_PCA9548; - -struct inv_ioexp_layout_s cedar_ga_ioexp_layout[] = { - /* IOEXP_ID / IOEXP_TYPE / { Chan_ID, Chip_addr, Read_offset, Write_offset, config_offset, data_default, conf_default } */ - {0, IOEXP_TYPE_CEDAR_0ABC, { { 4, 0x20, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0x00, 0x00}, }, /* addr[0] = I/O Expander 0 A */ - { 4, 0x21, {0,-1}, {1,-1}, {3,-1}, {0xff }, {0x00 }, }, /* addr[1] = I/O Expander 0 B */ - { 4, 0x22, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 0 C */ - }, - {1, IOEXP_TYPE_CEDAR_0ABC, { { 5, 0x20, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0x00, 0x00}, }, /* addr[0] = I/O Expander 0 A */ - { 5, 0x21, {0,-1}, {1,-1}, {3,-1}, {0xff }, {0x00 }, }, /* addr[1] = I/O Expander 0 B */ - { 5, 0x22, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 0 C */ - }, - {2, IOEXP_TYPE_CEDAR_0ABC, { { 6, 0x20, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0x00, 0x00}, }, /* addr[0] = I/O Expander 0 A */ - { 6, 0x21, {0,-1}, {1,-1}, {3,-1}, {0xff }, {0x00 }, }, /* addr[1] = I/O Expander 0 B */ - { 6, 0x22, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 0 C */ - }, - {3, IOEXP_TYPE_CEDAR_0ABC, { { 7, 0x20, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0x00, 0x00}, }, /* addr[0] = I/O Expander 0 A */ - { 7, 0x21, {0,-1}, {1,-1}, {3,-1}, {0xff }, {0x00 }, }, /* addr[1] = I/O Expander 0 B */ - { 7, 0x22, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 0 C */ - }, -}; - -struct inv_port_layout_s cedar_ga_port_layout[] = { - /* Port_ID / Chan_ID / IOEXP_ID / IOEXP_VIRT_OFFSET / TRANSCEIVER_TYPE / CHIP_TYPE / LANE_ID */ - { 0, 12, 0, 0, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_MAPLE, { 21, 22, 23, 24} }, - { 1, 13, 0, 1, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_MAPLE, { 17, 18, 19, 20} }, - { 2, 14, 0, 2, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_MAPLE, { 25, 26, 27, 28} }, - { 3, 15, 0, 3, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_MAPLE, { 29, 30, 31, 32} }, - { 4, 16, 0, 4, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_MAPLE, { 37, 38, 39, 40} }, - { 5, 17, 0, 5, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_MAPLE, { 33, 34, 35, 36} }, - { 6, 18, 0, 6, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_MAPLE, { 41, 42, 43, 44} }, - { 7, 19, 0, 7, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_MAPLE, { 45, 46, 47, 48} }, - { 8, 20, 1, 0, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_MAPLE, { 5, 6, 7, 8} }, - { 9, 21, 1, 1, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_MAPLE, { 1, 2, 3, 4} }, - {10, 22, 1, 2, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_MAPLE, { 9, 10, 11, 12} }, - {11, 23, 1, 3, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_MAPLE, { 13, 14, 15, 16} }, - {12, 24, 1, 4, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_MAPLE, { 53, 54, 55, 56} }, - {13, 25, 1, 5, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_MAPLE, { 49, 50, 51, 52} }, - {14, 26, 1, 6, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_MAPLE, { 57, 58, 59, 60} }, - {15, 27, 1, 7, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_MAPLE, { 61, 62, 63, 64} }, - {16, 28, 2, 0, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_MAPLE, { 71, 72, 73, 74} }, - {17, 29, 2, 1, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_MAPLE, { 67, 68, 69, 70} }, - {18, 30, 2, 2, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_MAPLE, { 75, 76, 77, 78} }, - {19, 31, 2, 3, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_MAPLE, { 79, 80, 81, 82} }, - {20, 32, 2, 4, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_MAPLE, { 119, 120, 121, 122} }, - {21, 33, 2, 5, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_MAPLE, { 115, 116, 117, 118} }, - {22, 34, 2, 6, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_MAPLE, { 123, 124, 125, 126} }, - {23, 35, 2, 7, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_MAPLE, { 127, 128, 129, 130} }, - {24, 36, 3, 0, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_MAPLE, { 87, 88, 89, 90} }, - {25, 37, 3, 1, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_MAPLE, { 83, 84, 85, 86} }, - {26, 38, 3, 2, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_MAPLE, { 91, 92, 93, 94} }, - {27, 39, 3, 3, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_MAPLE, { 95, 96, 97, 98} }, - {28, 40, 3, 4, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_MAPLE, { 103, 104, 105, 106} }, - {29, 41, 3, 5, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_MAPLE, { 99, 100, 101, 102} }, - {30, 42, 3, 6, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_MAPLE, { 107, 108, 109, 110} }, - {31, 43, 3, 7, TRANSVR_TYPE_QSFP_28, CHIP_TYPE_MAPLE, { 111, 112, 113, 114} }, -}; -#endif - - -#endif /* INV_SWPS_H */ - - - - - - - - - diff --git a/packages/platforms/inventec/x86-64/d6332/modules/builds/src/io_expander.c b/packages/platforms/inventec/x86-64/d6332/modules/builds/src/io_expander.c deleted file mode 100644 index 6867bbc60..000000000 --- a/packages/platforms/inventec/x86-64/d6332/modules/builds/src/io_expander.c +++ /dev/null @@ -1,2579 +0,0 @@ -#include -#include -#include "io_expander.h" - -/* For build single module using (Ex: ONL platform) */ -#include -//#include - - -static struct ioexp_obj_s *ioexp_head_p = NULL; -static struct ioexp_obj_s *ioexp_tail_p = NULL; -extern int io_no_init; - -/* ========== Register IOEXP layout ========== - */ -struct ioexp_map_s ioexp_map_magnolia_nab = { - - .chip_amount = 2, - .data_width = 2, - - .map_present = { {0, 0, 4}, /* map_present[0] = MOD_ABS_PORT(X) */ - {0, 0, 5}, /* map_present[1] = MOD_ABS_PORT(X+1) */ - {0, 0, 6}, /* map_present[2] = MOD_ABS_PORT(X+2) */ - {0, 0, 7}, /* map_present[3] = MOD_ABS_PORT(X+3) */ - {1, 0, 4}, /* map_present[4] = MOD_ABS_PORT(X+4) */ - {1, 0, 5}, /* map_present[5] = MOD_ABS_PORT(X+5) */ - {1, 0, 6}, /* map_present[6] = MOD_ABS_PORT(X+6) */ - {1, 0, 7}, /* map_present[7] = MOD_ABS_PORT(X+7) */ - }, - .map_tx_disable = { {0, 1, 0}, /* map_tx_disable[0] = TXDISABLE_SFP+_P(X) */ - {0, 1, 1}, /* map_tx_disable[1] = TXDISABLE_SFP+_P(X+1) */ - {0, 1, 2}, /* map_tx_disable[2] = TXDISABLE_SFP+_P(X+2) */ - {0, 1, 3}, /* map_tx_disable[3] = TXDISABLE_SFP+_P(X+3) */ - {1, 1, 0}, /* map_tx_disable[4] = TXDISABLE_SFP+_P(X+4) */ - {1, 1, 1}, /* map_tx_disable[5] = TXDISABLE_SFP+_P(X+5) */ - {1, 1, 2}, /* map_tx_disable[6] = TXDISABLE_SFP+_P(X+6) */ - {1, 1, 3}, /* map_tx_disable[7] = TXDISABLE_SFP+_P(X+7) */ - }, - .map_tx_fault = { {0, 0, 0}, /* map_tx_fault[0] = TXFAULT_SFP+_P(X) */ - {0, 0, 1}, /* map_tx_fault[1] = TXFAULT_SFP+_P(X+1) */ - {0, 0, 2}, /* map_tx_fault[2] = TXFAULT_SFP+_P(X+2) */ - {0, 0, 3}, /* map_tx_fault[3] = TXFAULT_SFP+_P(X+3) */ - {1, 0, 0}, /* map_tx_fault[4] = TXFAULT_SFP+_P(X+4) */ - {1, 0, 1}, /* map_tx_fault[5] = TXFAULT_SFP+_P(X+5) */ - {1, 0, 2}, /* map_tx_fault[6] = TXFAULT_SFP+_P(X+6) */ - {1, 0, 3}, /* map_tx_fault[7] = TXFAULT_SFP+_P(X+7) */ - }, - .map_rxlos = { {0, 1, 4}, /* map_rxlos[0] = OPRXLOS_PORT(X) */ - {0, 1, 5}, /* map_rxlos[1] = OPRXLOS_PORT(X+1) */ - {0, 1, 6}, /* map_rxlos[2] = OPRXLOS_PORT(X+2) */ - {0, 1, 7}, /* map_rxlos[3] = OPRXLOS_PORT(X+3) */ - {1, 1, 4}, /* map_rxlos[4] = OPRXLOS_PORT(X+4) */ - {1, 1, 5}, /* map_rxlos[5] = OPRXLOS_PORT(X+5) */ - {1, 1, 6}, /* map_rxlos[6] = OPRXLOS_PORT(X+6) */ - {1, 1, 7}, /* map_rxlos[7] = OPRXLOS_PORT(X+7) */ - }, -}; - - -struct ioexp_map_s ioexp_map_magnolia_4ab = { - - .chip_amount = 2, - .data_width = 2, - - .map_present = { {0, 0, 4}, /* map_present[0] = MOD_ABS_PORT(X) */ - {0, 0, 5}, /* map_present[1] = MOD_ABS_PORT(X+1) */ - {0, 0, 6}, /* map_present[2] = MOD_ABS_PORT(X+2) */ - {0, 0, 7}, /* map_present[3] = MOD_ABS_PORT(X+3) */ - {1, 0, 4}, /* map_present[4] = MOD_ABS_PORT(X+4) */ - {1, 0, 5}, /* map_present[5] = MOD_ABS_PORT(X+5) */ - {1, 0, 6}, /* map_present[6] = MOD_ABS_PORT(X+6) */ - {1, 0, 7}, /* map_present[7] = MOD_ABS_PORT(X+7) */ - }, - .map_tx_disable = { {0, 1, 0}, /* map_tx_disable[0] = TXDISABLE_SFP+_P(X) */ - {0, 1, 1}, /* map_tx_disable[1] = TXDISABLE_SFP+_P(X+1) */ - {0, 1, 2}, /* map_tx_disable[2] = TXDISABLE_SFP+_P(X+2) */ - {0, 1, 3}, /* map_tx_disable[3] = TXDISABLE_SFP+_P(X+3) */ - {1, 0, 0}, /* map_tx_disable[4] = TXDISABLE_SFP+_P(X+4) */ - {1, 0, 1}, /* map_tx_disable[5] = TXDISABLE_SFP+_P(X+5) */ - {1, 0, 2}, /* map_tx_disable[6] = TXDISABLE_SFP+_P(X+6) */ - {1, 0, 3}, /* map_tx_disable[7] = TXDISABLE_SFP+_P(X+7) */ - }, - .map_tx_fault = { {0, 0, 0}, /* map_tx_fault[0] = TXFAULT_SFP+_P(X) */ - {0, 0, 1}, /* map_tx_fault[1] = TXFAULT_SFP+_P(X+1) */ - {0, 0, 2}, /* map_tx_fault[2] = TXFAULT_SFP+_P(X+2) */ - {0, 0, 3}, /* map_tx_fault[3] = TXFAULT_SFP+_P(X+3) */ - {1, 1, 0}, /* map_tx_fault[4] = TXFAULT_SFP+_P(X+4) */ - {1, 1, 1}, /* map_tx_fault[5] = TXFAULT_SFP+_P(X+5) */ - {1, 1, 2}, /* map_tx_fault[6] = TXFAULT_SFP+_P(X+6) */ - {1, 1, 3}, /* map_tx_fault[7] = TXFAULT_SFP+_P(X+7) */ - }, - .map_rxlos = { {0, 1, 4}, /* map_rxlos[0] = OPRXLOS_PORT(X) */ - {0, 1, 5}, /* map_rxlos[1] = OPRXLOS_PORT(X+1) */ - {0, 1, 6}, /* map_rxlos[2] = OPRXLOS_PORT(X+2) */ - {0, 1, 7}, /* map_rxlos[3] = OPRXLOS_PORT(X+3) */ - {1, 1, 4}, /* map_rxlos[4] = OPRXLOS_PORT(X+4) */ - {1, 1, 5}, /* map_rxlos[5] = OPRXLOS_PORT(X+5) */ - {1, 1, 6}, /* map_rxlos[6] = OPRXLOS_PORT(X+6) */ - {1, 1, 7}, /* map_rxlos[7] = OPRXLOS_PORT(X+7) */ - }, -}; - - -struct ioexp_map_s ioexp_map_magnolia_7ab = { - - .chip_amount = 2, - .data_width = 2, - - .map_present = { {1, 0, 4}, /* map_present[0] = MOD_ABS_PORT(X) */ - {1, 0, 5}, /* map_present[1] = MOD_ABS_PORT(X+1) */ - {1, 0, 6}, /* map_present[2] = MOD_ABS_PORT(X+2) */ - {1, 0, 7}, /* map_present[3] = MOD_ABS_PORT(X+3) */ - {1, 1, 4}, /* map_present[4] = MOD_ABS_PORT(X+4) */ - {1, 1, 5}, /* map_present[5] = MOD_ABS_PORT(X+5) */ - }, - .map_reset = { {0, 0, 0}, /* map_reset[0] = QRESET_QSFP_N_P(X) */ - {0, 0, 1}, /* map_reset[1] = QRESET_QSFP_N_P(X+1) */ - {0, 0, 2}, /* map_reset[2] = QRESET_QSFP_N_P(X+2) */ - {0, 0, 3}, /* map_reset[3] = QRESET_QSFP_N_P(X+3) */ - {1, 0, 0}, /* map_reset[4] = QRESET_QSFP_N_P(X+4) */ - {1, 0, 1}, /* map_reset[5] = QRESET_QSFP_N_P(X+5) */ - }, - .map_lpmod = { {0, 0, 4}, /* map_lpmod[0] = LPMODE_QSFP_P(X) */ - {0, 0, 5}, /* map_lpmod[1] = LPMODE_QSFP_P(X+1) */ - {0, 0, 6}, /* map_lpmod[2] = LPMODE_QSFP_P(X+2) */ - {0, 0, 7}, /* map_lpmod[3] = LPMODE_QSFP_P(X+3) */ - {1, 0, 2}, /* map_lpmod[4] = LPMODE_QSFP_P(X+4) */ - {1, 0, 3}, /* map_lpmod[5] = LPMODE_QSFP_P(X+5) */ - }, - .map_modsel = { {0, 1, 4}, /* map_modsel[0] = MODSEL_QSFP_N_P(X) */ - {0, 1, 5}, /* map_modsel[1] = MODSEL_QSFP_N_P(X+1) */ - {0, 1, 6}, /* map_modsel[2] = MODSEL_QSFP_N_P(X+2) */ - {0, 1, 7}, /* map_modsel[3] = MODSEL_QSFP_N_P(X+3) */ - {1, 1, 4}, /* map_modsel[4] = MODSEL_QSFP_N_P(X+4) */ - {1, 1, 5}, /* map_modsel[5] = MODSEL_QSFP_N_P(X+5) */ - }, -}; - - -struct ioexp_map_s ioexp_map_redwood_p01p08_p17p24 = { - - .chip_amount = 3, - .data_width = 2, - - .map_present = { {2, 0, 0}, /* map_present[0] = MOD_ABS_PORT(X) */ - {2, 0, 1}, /* map_present[1] = MOD_ABS_PORT(X+1) */ - {2, 0, 2}, /* map_present[2] = MOD_ABS_PORT(X+2) */ - {2, 0, 3}, /* map_present[3] = MOD_ABS_PORT(X+3) */ - {2, 0, 4}, /* map_present[4] = MOD_ABS_PORT(X+4) */ - {2, 0, 5}, /* map_present[5] = MOD_ABS_PORT(X+5) */ - {2, 0, 6}, /* map_present[6] = MOD_ABS_PORT(X+6) */ - {2, 0, 7}, /* map_present[7] = MOD_ABS_PORT(X+7) */ - }, - .map_reset = { {0, 0, 0}, /* map_reset[0] = QRESET_QSFP28_N_P(X) */ - {0, 0, 1}, /* map_reset[1] = QRESET_QSFP28_N_P(X+1) */ - {0, 0, 2}, /* map_reset[2] = QRESET_QSFP28_N_P(X+2) */ - {0, 0, 3}, /* map_reset[3] = QRESET_QSFP28_N_P(X+3) */ - {1, 0, 0}, /* map_reset[4] = QRESET_QSFP28_N_P(X+4) */ - {1, 0, 1}, /* map_reset[5] = QRESET_QSFP28_N_P(X+5) */ - {1, 0, 2}, /* map_reset[6] = QRESET_QSFP28_N_P(X+6) */ - {1, 0, 3}, /* map_reset[7] = QRESET_QSFP28_N_P(X+7) */ - }, - .map_lpmod = { {0, 0, 4}, /* map_lpmod[0] = LPMODE_QSFP28_P(X) */ - {0, 0, 5}, /* map_lpmod[1] = LPMODE_QSFP28_P(X+1) */ - {0, 0, 6}, /* map_lpmod[2] = LPMODE_QSFP28_P(X+2) */ - {0, 0, 7}, /* map_lpmod[3] = LPMODE_QSFP28_P(X+3) */ - {1, 0, 4}, /* map_lpmod[4] = LPMODE_QSFP28_P(X+4) */ - {1, 0, 5}, /* map_lpmod[5] = LPMODE_QSFP28_P(X+5) */ - {1, 0, 6}, /* map_lpmod[6] = LPMODE_QSFP28_P(X+6) */ - {1, 0, 7}, /* map_lpmod[7] = LPMODE_QSFP28_P(X+7) */ - }, - .map_modsel = { {0, 1, 4}, /* map_modsel[0] = MODSEL_QSFP28_N_P(X) */ - {0, 1, 5}, /* map_modsel[1] = MODSEL_QSFP28_N_P(X+1) */ - {0, 1, 6}, /* map_modsel[2] = MODSEL_QSFP28_N_P(X+2) */ - {0, 1, 7}, /* map_modsel[3] = MODSEL_QSFP28_N_P(X+3) */ - {1, 1, 4}, /* map_modsel[4] = MODSEL_QSFP28_N_P(X+4) */ - {1, 1, 5}, /* map_modsel[5] = MODSEL_QSFP28_N_P(X+5) */ - {1, 1, 6}, /* map_modsel[6] = MODSEL_QSFP28_N_P(X+6) */ - {1, 1, 7}, /* map_modsel[7] = MODSEL_QSFP28_N_P(X+7) */ - }, -}; - - -struct ioexp_map_s ioexp_map_redwood_p09p16_p25p32 = { - - .chip_amount = 3, - .data_width = 2, - - .map_present = { {2, 1, 0}, /* map_present[0] = MOD_ABS_PORT(X) */ - {2, 1, 1}, /* map_present[1] = MOD_ABS_PORT(X+1) */ - {2, 1, 2}, /* map_present[2] = MOD_ABS_PORT(X+2) */ - {2, 1, 3}, /* map_present[3] = MOD_ABS_PORT(X+3) */ - {2, 1, 4}, /* map_present[4] = MOD_ABS_PORT(X+4) */ - {2, 1, 5}, /* map_present[5] = MOD_ABS_PORT(X+5) */ - {2, 1, 6}, /* map_present[6] = MOD_ABS_PORT(X+6) */ - {2, 1, 7}, /* map_present[7] = MOD_ABS_PORT(X+7) */ - }, - .map_reset = { {0, 0, 0}, /* map_reset[0] = QRESET_QSFP28_N_P(X) */ - {0, 0, 1}, /* map_reset[1] = QRESET_QSFP28_N_P(X+1) */ - {0, 0, 2}, /* map_reset[2] = QRESET_QSFP28_N_P(X+2) */ - {0, 0, 3}, /* map_reset[3] = QRESET_QSFP28_N_P(X+3) */ - {1, 0, 0}, /* map_reset[4] = QRESET_QSFP28_N_P(X+4) */ - {1, 0, 1}, /* map_reset[5] = QRESET_QSFP28_N_P(X+5) */ - {1, 0, 2}, /* map_reset[6] = QRESET_QSFP28_N_P(X+6) */ - {1, 0, 3}, /* map_reset[7] = QRESET_QSFP28_N_P(X+7) */ - }, - .map_lpmod = { {0, 0, 4}, /* map_lpmod[0] = LPMODE_QSFP28_P(X) */ - {0, 0, 5}, /* map_lpmod[1] = LPMODE_QSFP28_P(X+1) */ - {0, 0, 6}, /* map_lpmod[2] = LPMODE_QSFP28_P(X+2) */ - {0, 0, 7}, /* map_lpmod[3] = LPMODE_QSFP28_P(X+3) */ - {1, 0, 4}, /* map_lpmod[4] = LPMODE_QSFP28_P(X+4) */ - {1, 0, 5}, /* map_lpmod[5] = LPMODE_QSFP28_P(X+5) */ - {1, 0, 6}, /* map_lpmod[6] = LPMODE_QSFP28_P(X+6) */ - {1, 0, 7}, /* map_lpmod[7] = LPMODE_QSFP28_P(X+7) */ - }, - .map_modsel = { {0, 1, 4}, /* map_modsel[0] = MODSEL_QSFP28_N_P(X) */ - {0, 1, 5}, /* map_modsel[1] = MODSEL_QSFP28_N_P(X+1) */ - {0, 1, 6}, /* map_modsel[2] = MODSEL_QSFP28_N_P(X+2) */ - {0, 1, 7}, /* map_modsel[3] = MODSEL_QSFP28_N_P(X+3) */ - {1, 1, 4}, /* map_modsel[4] = MODSEL_QSFP28_N_P(X+4) */ - {1, 1, 5}, /* map_modsel[5] = MODSEL_QSFP28_N_P(X+5) */ - {1, 1, 6}, /* map_modsel[6] = MODSEL_QSFP28_N_P(X+6) */ - {1, 1, 7}, /* map_modsel[7] = MODSEL_QSFP28_N_P(X+7) */ - }, -}; - - -struct ioexp_map_s ioexp_map_hudson32iga_p01p08_p17p24 = { - - .chip_amount = 3, - .data_width = 2, - - .map_present = { {2, 0, 0}, /* map_present[0] = MODABS_QSFP(X) */ - {2, 0, 1}, /* map_present[1] = MODABS_QSFP(X+1) */ - {2, 0, 2}, /* map_present[2] = MODABS_QSFP(X+2) */ - {2, 0, 3}, /* map_present[3] = MODABS_QSFP(X+3) */ - {2, 0, 4}, /* map_present[4] = MODABS_QSFP(X+4) */ - {2, 0, 5}, /* map_present[5] = MODABS_QSFP(X+5) */ - {2, 0, 6}, /* map_present[6] = MODABS_QSFP(X+6) */ - {2, 0, 7}, /* map_present[7] = MODABS_QSFP(X+7) */ - }, - .map_reset = { {0, 0, 0}, /* map_reset[0] = QRESET_QSFP(X) */ - {0, 0, 1}, /* map_reset[1] = QRESET_QSFP(X+1) */ - {0, 0, 2}, /* map_reset[2] = QRESET_QSFP(X+2) */ - {0, 0, 3}, /* map_reset[3] = QRESET_QSFP(X+3) */ - {1, 0, 0}, /* map_reset[4] = QRESET_QSFP(X+4) */ - {1, 0, 1}, /* map_reset[5] = QRESET_QSFP(X+5) */ - {1, 0, 2}, /* map_reset[6] = QRESET_QSFP(X+6) */ - {1, 0, 3}, /* map_reset[7] = QRESET_QSFP(X+7) */ - }, - .map_lpmod = { {0, 0, 4}, /* map_lpmod[0] = LPMODE_QSFP(X) */ - {0, 0, 5}, /* map_lpmod[1] = LPMODE_QSFP(X+1) */ - {0, 0, 6}, /* map_lpmod[2] = LPMODE_QSFP(X+2) */ - {0, 0, 7}, /* map_lpmod[3] = LPMODE_QSFP(X+3) */ - {1, 0, 4}, /* map_lpmod[4] = LPMODE_QSFP(X+4) */ - {1, 0, 5}, /* map_lpmod[5] = LPMODE_QSFP(X+5) */ - {1, 0, 6}, /* map_lpmod[6] = LPMODE_QSFP(X+6) */ - {1, 0, 7}, /* map_lpmod[7] = LPMODE_QSFP(X+7) */ - }, - .map_modsel = { {0, 1, 4}, /* map_modsel[0] = MODSEL_QSFP(X) */ - {0, 1, 5}, /* map_modsel[1] = MODSEL_QSFP(X+1) */ - {0, 1, 6}, /* map_modsel[2] = MODSEL_QSFP(X+2) */ - {0, 1, 7}, /* map_modsel[3] = MODSEL_QSFP(X+3) */ - {1, 1, 4}, /* map_modsel[4] = MODSEL_QSFP(X+4) */ - {1, 1, 5}, /* map_modsel[5] = MODSEL_QSFP(X+5) */ - {1, 1, 6}, /* map_modsel[6] = MODSEL_QSFP(X+6) */ - {1, 1, 7}, /* map_modsel[7] = MODSEL_QSFP(X+7) */ - }, -}; - - -struct ioexp_map_s ioexp_map_hudson32iga_p09p16_p25p32 = { - - .chip_amount = 3, - .data_width = 2, - - .map_present = { {2, 1, 0}, /* map_present[0] = MODABS_QSFP(X) */ - {2, 1, 1}, /* map_present[1] = MODABS_QSFP(X+1) */ - {2, 1, 2}, /* map_present[2] = MODABS_QSFP(X+2) */ - {2, 1, 3}, /* map_present[3] = MODABS_QSFP(X+3) */ - {2, 1, 4}, /* map_present[4] = MODABS_QSFP(X+4) */ - {2, 1, 5}, /* map_present[5] = MODABS_QSFP(X+5) */ - {2, 1, 6}, /* map_present[6] = MODABS_QSFP(X+6) */ - {2, 1, 7}, /* map_present[7] = MODABS_QSFP(X+7) */ - }, - .map_reset = { {0, 0, 0}, /* map_reset[0] = QRESET_QSFP(X) */ - {0, 0, 1}, /* map_reset[1] = QRESET_QSFP(X+1) */ - {0, 0, 2}, /* map_reset[2] = QRESET_QSFP(X+2) */ - {0, 0, 3}, /* map_reset[3] = QRESET_QSFP(X+3) */ - {1, 0, 0}, /* map_reset[4] = QRESET_QSFP(X+4) */ - {1, 0, 1}, /* map_reset[5] = QRESET_QSFP(X+5) */ - {1, 0, 2}, /* map_reset[6] = QRESET_QSFP(X+6) */ - {1, 0, 3}, /* map_reset[7] = QRESET_QSFP(X+7) */ - }, - .map_lpmod = { {0, 0, 4}, /* map_lpmod[0] = LPMODE_QSFP(X) */ - {0, 0, 5}, /* map_lpmod[1] = LPMODE_QSFP(X+1) */ - {0, 0, 6}, /* map_lpmod[2] = LPMODE_QSFP(X+2) */ - {0, 0, 7}, /* map_lpmod[3] = LPMODE_QSFP(X+3) */ - {1, 0, 4}, /* map_lpmod[4] = LPMODE_QSFP(X+4) */ - {1, 0, 5}, /* map_lpmod[5] = LPMODE_QSFP(X+5) */ - {1, 0, 6}, /* map_lpmod[6] = LPMODE_QSFP(X+6) */ - {1, 0, 7}, /* map_lpmod[7] = LPMODE_QSFP(X+7) */ - }, - .map_modsel = { {0, 1, 4}, /* map_modsel[0] = MODSEL_QSFP(X) */ - {0, 1, 5}, /* map_modsel[1] = MODSEL_QSFP(X+1) */ - {0, 1, 6}, /* map_modsel[2] = MODSEL_QSFP(X+2) */ - {0, 1, 7}, /* map_modsel[3] = MODSEL_QSFP(X+3) */ - {1, 1, 4}, /* map_modsel[4] = MODSEL_QSFP(X+4) */ - {1, 1, 5}, /* map_modsel[5] = MODSEL_QSFP(X+5) */ - {1, 1, 6}, /* map_modsel[6] = MODSEL_QSFP(X+6) */ - {1, 1, 7}, /* map_modsel[7] = MODSEL_QSFP(X+7) */ - }, -}; - - -struct ioexp_map_s ioexp_map_cypress_nabc = { - - .chip_amount = 3, - .data_width = 2, - - .map_present = { {0, 0, 4}, /* map_present[0] = MOD_ABS_PORT(X) */ - {0, 0, 5}, /* map_present[1] = MOD_ABS_PORT(X+1) */ - {0, 0, 6}, /* map_present[2] = MOD_ABS_PORT(X+2) */ - {0, 0, 7}, /* map_present[3] = MOD_ABS_PORT(X+3) */ - {1, 0, 4}, /* map_present[4] = MOD_ABS_PORT(X+4) */ - {1, 0, 5}, /* map_present[5] = MOD_ABS_PORT(X+5) */ - {1, 0, 6}, /* map_present[6] = MOD_ABS_PORT(X+6) */ - {1, 0, 7}, /* map_present[7] = MOD_ABS_PORT(X+7) */ - }, - .map_tx_disable = { {0, 1, 0}, /* map_tx_disable[0] = TXDISABLE_SFP+_P(X) */ - {0, 1, 1}, /* map_tx_disable[1] = TXDISABLE_SFP+_P(X+1) */ - {0, 1, 2}, /* map_tx_disable[2] = TXDISABLE_SFP+_P(X+2) */ - {0, 1, 3}, /* map_tx_disable[3] = TXDISABLE_SFP+_P(X+3) */ - {1, 1, 0}, /* map_tx_disable[4] = TXDISABLE_SFP+_P(X+4) */ - {1, 1, 1}, /* map_tx_disable[5] = TXDISABLE_SFP+_P(X+5) */ - {1, 1, 2}, /* map_tx_disable[6] = TXDISABLE_SFP+_P(X+6) */ - {1, 1, 3}, /* map_tx_disable[7] = TXDISABLE_SFP+_P(X+7) */ - }, - .map_tx_fault = { {0, 0, 0}, /* map_tx_fault[0] = TXFAULT_SFP+_P(X) */ - {0, 0, 1}, /* map_tx_fault[1] = TXFAULT_SFP+_P(X+1) */ - {0, 0, 2}, /* map_tx_fault[2] = TXFAULT_SFP+_P(X+2) */ - {0, 0, 3}, /* map_tx_fault[3] = TXFAULT_SFP+_P(X+3) */ - {1, 0, 0}, /* map_tx_fault[4] = TXFAULT_SFP+_P(X+4) */ - {1, 0, 1}, /* map_tx_fault[5] = TXFAULT_SFP+_P(X+5) */ - {1, 0, 2}, /* map_tx_fault[6] = TXFAULT_SFP+_P(X+6) */ - {1, 0, 3}, /* map_tx_fault[7] = TXFAULT_SFP+_P(X+7) */ - }, - .map_rxlos = { {0, 1, 4}, /* map_rxlos[0] = OPRXLOS_PORT(X) */ - {0, 1, 5}, /* map_rxlos[1] = OPRXLOS_PORT(X+1) */ - {0, 1, 6}, /* map_rxlos[2] = OPRXLOS_PORT(X+2) */ - {0, 1, 7}, /* map_rxlos[3] = OPRXLOS_PORT(X+3) */ - {1, 1, 4}, /* map_rxlos[4] = OPRXLOS_PORT(X+4) */ - {1, 1, 5}, /* map_rxlos[5] = OPRXLOS_PORT(X+5) */ - {1, 1, 6}, /* map_rxlos[6] = OPRXLOS_PORT(X+6) */ - {1, 1, 7}, /* map_rxlos[7] = OPRXLOS_PORT(X+7) */ - }, - .map_hard_rs0 = { {2, 0, 0}, /* map_hard_rs0[0] = RS0_SFP28_P(X) */ - {2, 0, 2}, /* map_hard_rs0[1] = RS0_SFP28_P(X+1) */ - {2, 0, 4}, /* map_hard_rs0[2] = RS0_SFP28_P(X+2) */ - {2, 0, 6}, /* map_hard_rs0[3] = RS0_SFP28_P(X+3) */ - {2, 1, 0}, /* map_hard_rs0[4] = RS0_SFP28_P(X+4) */ - {2, 1, 2}, /* map_hard_rs0[5] = RS0_SFP28_P(X+5) */ - {2, 1, 4}, /* map_hard_rs0[6] = RS0_SFP28_P(X+6) */ - {2, 1, 6}, /* map_hard_rs0[7] = RS0_SFP28_P(X+7) */ - }, - .map_hard_rs1 = { {2, 0, 1}, /* map_hard_rs1[0] = RS1_SFP28_P(X) */ - {2, 0, 3}, /* map_hard_rs1[1] = RS1_SFP28_P(X+1) */ - {2, 0, 5}, /* map_hard_rs1[2] = RS1_SFP28_P(X+2) */ - {2, 0, 7}, /* map_hard_rs1[3] = RS1_SFP28_P(X+3) */ - {2, 1, 1}, /* map_hard_rs1[4] = RS1_SFP28_P(X+4) */ - {2, 1, 3}, /* map_hard_rs1[5] = RS1_SFP28_P(X+5) */ - {2, 1, 5}, /* map_hard_rs1[6] = RS1_SFP28_P(X+6) */ - {2, 1, 7}, /* map_hard_rs1[7] = RS1_SFP28_P(X+7) */ - }, -}; - - -struct ioexp_map_s ioexp_map_cypress_7abc = { - - .chip_amount = 3, - .data_width = 2, - - .map_present = { {2, 0, 0}, /* map_present[0] = MOD_ABS_PORT(X) */ - {2, 0, 1}, /* map_present[1] = MOD_ABS_PORT(X+1) */ - {2, 0, 2}, /* map_present[2] = MOD_ABS_PORT(X+2) */ - {2, 0, 3}, /* map_present[3] = MOD_ABS_PORT(X+3) */ - {2, 0, 4}, /* map_present[4] = MOD_ABS_PORT(X+4) */ - {2, 0, 5}, /* map_present[5] = MOD_ABS_PORT(X+5) */ - }, - .map_reset = { {0, 0, 0}, /* map_reset[0] = QRESET_QSFP_N_P(X) */ - {0, 0, 1}, /* map_reset[1] = QRESET_QSFP_N_P(X+1) */ - {0, 0, 2}, /* map_reset[2] = QRESET_QSFP_N_P(X+2) */ - {0, 0, 3}, /* map_reset[3] = QRESET_QSFP_N_P(X+3) */ - {0, 0, 4}, /* map_reset[4] = QRESET_QSFP_N_P(X+4) */ - {0, 0, 5}, /* map_reset[5] = QRESET_QSFP_N_P(X+5) */ - }, - .map_lpmod = { {0, 1, 0}, /* map_lpmod[0] = LPMODE_QSFP_P(X) */ - {0, 1, 1}, /* map_lpmod[1] = LPMODE_QSFP_P(X+1) */ - {0, 1, 2}, /* map_lpmod[2] = LPMODE_QSFP_P(X+2) */ - {0, 1, 3}, /* map_lpmod[3] = LPMODE_QSFP_P(X+3) */ - {0, 1, 4}, /* map_lpmod[4] = LPMODE_QSFP_P(X+4) */ - {0, 1, 5}, /* map_lpmod[5] = LPMODE_QSFP_P(X+5) */ - }, - .map_modsel = { {1, 1, 0}, /* map_modsel[0] = MODSEL_QSFP_N_P(X) */ - {1, 1, 1}, /* map_modsel[1] = MODSEL_QSFP_N_P(X+1) */ - {1, 1, 2}, /* map_modsel[2] = MODSEL_QSFP_N_P(X+2) */ - {1, 1, 3}, /* map_modsel[3] = MODSEL_QSFP_N_P(X+3) */ - {1, 1, 4}, /* map_modsel[4] = MODSEL_QSFP_N_P(X+4) */ - {1, 1, 5}, /* map_modsel[5] = MODSEL_QSFP_N_P(X+5) */ - }, -}; - - -struct ioexp_map_s ioexp_map_tahoe_5a = { - - .chip_amount = 1, - .data_width = 2, - - .map_present = { {0, 0, 3}, /* map_present[0] = MOD_ABS_PORT(X) */ - {0, 1, 0}, /* map_present[1] = MOD_ABS_PORT(X+1) */ - {0, 1, 5}, /* map_present[2] = MOD_ABS_PORT(X+2) */ - }, - .map_reset = { {0, 0, 1}, /* map_reset[0] = QRESET_QSFP_N_P(X) */ - {0, 0, 6}, /* map_reset[1] = QRESET_QSFP_N_P(X+1) */ - {0, 1, 3}, /* map_reset[2] = QRESET_QSFP_N_P(X+2) */ - }, - .map_lpmod = { {0, 0, 2}, /* map_lpmod[0] = LPMODE_QSFP_P(X) */ - {0, 0, 7}, /* map_lpmod[1] = LPMODE_QSFP_P(X+1) */ - {0, 1, 4}, /* map_lpmod[2] = LPMODE_QSFP_P(X+2) */ - }, - .map_modsel = { {0, 0, 0}, /* map_modsel[0] = MODSEL_QSFP_N_P(X) */ - {0, 0, 5}, /* map_modsel[1] = MODSEL_QSFP_N_P(X+1) */ - {0, 1, 2}, /* map_modsel[2] = MODSEL_QSFP_N_P(X+2) */ - }, -}; - - -struct ioexp_map_s ioexp_map_tahoe_6abc = { - - .chip_amount = 3, - .data_width = 2, - - .map_present = { {0, 0, 3}, /* map_present[0] = MOD_ABS_PORT(X) */ - {0, 1, 0}, /* map_present[1] = MOD_ABS_PORT(X+1) */ - {0, 1, 5}, /* map_present[2] = MOD_ABS_PORT(X+2) */ - {1, 0, 3}, /* map_present[3] = MOD_ABS_PORT(X+3) */ - {1, 1, 0}, /* map_present[4] = MOD_ABS_PORT(X+4) */ - {1, 1, 5}, /* map_present[5] = MOD_ABS_PORT(X+5) */ - {2, 0, 3}, /* map_present[6] = MOD_ABS_PORT(X+6) */ - {2, 1, 0}, /* map_present[7] = MOD_ABS_PORT(X+7) */ - {2, 1, 5}, /* map_present[8] = MOD_ABS_PORT(X+8) */ - }, - .map_reset = { {0, 0, 1}, /* map_reset[0] = QRESET_QSFP28_N_P(X) */ - {0, 0, 6}, /* map_reset[1] = QRESET_QSFP28_N_P(X+1) */ - {0, 1, 3}, /* map_reset[2] = QRESET_QSFP28_N_P(X+2) */ - {1, 0, 1}, /* map_reset[3] = QRESET_QSFP28_N_P(X+3) */ - {1, 0, 6}, /* map_reset[4] = QRESET_QSFP28_N_P(X+4) */ - {1, 1, 3}, /* map_reset[5] = QRESET_QSFP28_N_P(X+5) */ - {2, 0, 1}, /* map_reset[6] = QRESET_QSFP28_N_P(X+6) */ - {2, 0, 6}, /* map_reset[7] = QRESET_QSFP28_N_P(X+7) */ - {2, 1, 3}, /* map_reset[7] = QRESET_QSFP28_N_P(X+7) */ - }, - .map_lpmod = { {0, 0, 2}, /* map_lpmod[0] = LPMODE_QSFP28_P(X) */ - {0, 0, 7}, /* map_lpmod[1] = LPMODE_QSFP28_P(X+1) */ - {0, 1, 4}, /* map_lpmod[2] = LPMODE_QSFP28_P(X+2) */ - {1, 0, 2}, /* map_lpmod[3] = LPMODE_QSFP28_P(X+3) */ - {1, 0, 7}, /* map_lpmod[4] = LPMODE_QSFP28_P(X+4) */ - {1, 1, 4}, /* map_lpmod[5] = LPMODE_QSFP28_P(X+5) */ - {2, 0, 2}, /* map_lpmod[6] = LPMODE_QSFP28_P(X+6) */ - {2, 0, 7}, /* map_lpmod[7] = LPMODE_QSFP28_P(X+7) */ - {2, 1, 4}, /* map_lpmod[7] = LPMODE_QSFP28_P(X+8) */ - }, - .map_modsel = { {0, 0, 0}, /* map_modsel[0] = MODSEL_QSFP28_N_P(X) */ - {0, 0, 5}, /* map_modsel[1] = MODSEL_QSFP28_N_P(X+1) */ - {0, 1, 2}, /* map_modsel[2] = MODSEL_QSFP28_N_P(X+2) */ - {1, 0, 0}, /* map_modsel[3] = MODSEL_QSFP28_N_P(X+3) */ - {1, 0, 5}, /* map_modsel[4] = MODSEL_QSFP28_N_P(X+4) */ - {1, 1, 2}, /* map_modsel[5] = MODSEL_QSFP28_N_P(X+5) */ - {2, 0, 0}, /* map_modsel[6] = MODSEL_QSFP28_N_P(X+6) */ - {2, 0, 5}, /* map_modsel[7] = MODSEL_QSFP28_N_P(X+7) */ - {2, 1, 2}, /* map_modsel[7] = MODSEL_QSFP28_N_P(X+7) */ - }, -}; - - -struct ioexp_map_s ioexp_map_sequoia_nabc = { - - .chip_amount = 3, - .data_width = 2, - - .map_present = { {2, 1, 0}, /* map_present[0] = MOD_ABS_PORT(X) */ - {2, 1, 1}, /* map_present[1] = MOD_ABS_PORT(X+1) */ - {2, 1, 2}, /* map_present[2] = MOD_ABS_PORT(X+2) */ - {2, 1, 3}, /* map_present[3] = MOD_ABS_PORT(X+3) */ - {2, 1, 4}, /* map_present[4] = MOD_ABS_PORT(X+4) */ - {2, 1, 5}, /* map_present[5] = MOD_ABS_PORT(X+5) */ - {2, 1, 6}, /* map_present[6] = MOD_ABS_PORT(X+6) */ - {2, 1, 7}, /* map_present[7] = MOD_ABS_PORT(X+7) */ - }, - .map_reset = { {0, 1, 0}, /* map_reset[0] = QRESET_QSFP28_N_P(X) */ - {0, 1, 1}, /* map_reset[1] = QRESET_QSFP28_N_P(X+1) */ - {0, 1, 2}, /* map_reset[2] = QRESET_QSFP28_N_P(X+2) */ - {0, 1, 3}, /* map_reset[3] = QRESET_QSFP28_N_P(X+3) */ - {0, 1, 4}, /* map_reset[4] = QRESET_QSFP28_N_P(X+4) */ - {0, 1, 5}, /* map_reset[5] = QRESET_QSFP28_N_P(X+5) */ - {0, 1, 6}, /* map_reset[6] = QRESET_QSFP28_N_P(X+6) */ - {0, 1, 7}, /* map_reset[7] = QRESET_QSFP28_N_P(X+7) */ - }, - .map_lpmod = { {1, 0, 0}, /* map_lpmod[0] = LPMODE_QSFP28_P(X) */ - {1, 0, 1}, /* map_lpmod[1] = LPMODE_QSFP28_P(X+1) */ - {1, 0, 2}, /* map_lpmod[2] = LPMODE_QSFP28_P(X+2) */ - {1, 0, 3}, /* map_lpmod[3] = LPMODE_QSFP28_P(X+3) */ - {1, 0, 4}, /* map_lpmod[4] = LPMODE_QSFP28_P(X+4) */ - {1, 0, 5}, /* map_lpmod[5] = LPMODE_QSFP28_P(X+5) */ - {1, 0, 6}, /* map_lpmod[6] = LPMODE_QSFP28_P(X+6) */ - {1, 0, 7}, /* map_lpmod[7] = LPMODE_QSFP28_P(X+7) */ - }, - .map_modsel = { {0, 0, 0}, /* map_modsel[0] = MODSEL_QSFP28_N_P(X) */ - {0, 0, 1}, /* map_modsel[1] = MODSEL_QSFP28_N_P(X+1) */ - {0, 0, 2}, /* map_modsel[2] = MODSEL_QSFP28_N_P(X+2) */ - {0, 0, 3}, /* map_modsel[3] = MODSEL_QSFP28_N_P(X+3) */ - {0, 0, 4}, /* map_modsel[4] = MODSEL_QSFP28_N_P(X+4) */ - {0, 0, 5}, /* map_modsel[5] = MODSEL_QSFP28_N_P(X+5) */ - {0, 0, 6}, /* map_modsel[6] = MODSEL_QSFP28_N_P(X+6) */ - {0, 0, 7}, /* map_modsel[7] = MODSEL_QSFP28_N_P(X+7) */ - }, -}; - - -struct ioexp_map_s ioexp_map_lavender_p65 = { - - .chip_amount = 1, - .data_width = 1, - - .map_present = { {0, 0, 4}, }, /* map_present[0] = MOD_ABS_PORT(X) */ - .map_reset = { {0, 0, 1}, }, /* map_reset[0] = QRESET_QSFP28_N_P(X) */ - .map_lpmod = { {0, 0, 2}, }, /* map_lpmod[0] = LPMODE_QSFP28_P(X) */ - .map_modsel = { {0, 0, 0}, }, /* map_modsel[0] = MODSEL_QSFP28_N_P(X) */ -}; - - -struct ioexp_map_s cpld_map_cottonwood = { - - .chip_amount = 1, - .data_width = 4, - - .map_present = { {0, 2, 0}, /* map_present[0] = MOD_ABS_PORT(X) */ - {0, 2, 4}, /* map_present[1] = MOD_ABS_PORT(X+1) */ - {0, 3, 0}, /* map_present[2] = MOD_ABS_PORT(X+2) */ - {0, 3, 4}, /* map_present[3] = MOD_ABS_PORT(X+3) */ - }, - .map_tx_disable = { {0, 0, 0}, /* map_tx_disable[0] = TXDISABLE_SFP+_P(X) */ - {0, 0, 4}, /* map_tx_disable[1] = TXDISABLE_SFP+_P(X+1) */ - {0, 1, 0}, /* map_tx_disable[2] = TXDISABLE_SFP+_P(X+2) */ - {0, 1, 4}, /* map_tx_disable[3] = TXDISABLE_SFP+_P(X+3) */ - }, - .map_tx_fault = { {0, 2, 2}, /* map_tx_fault[0] = TXFAULT_SFP+_P(X) */ - {0, 2, 6}, /* map_tx_fault[1] = TXFAULT_SFP+_P(X+1) */ - {0, 3, 2}, /* map_tx_fault[2] = TXFAULT_SFP+_P(X+2) */ - {0, 3, 6}, /* map_tx_fault[3] = TXFAULT_SFP+_P(X+3) */ - }, - .map_rxlos = { {0, 2, 1}, /* map_rxlos[0] = OPRXLOS_PORT(X) */ - {0, 2, 5}, /* map_rxlos[1] = OPRXLOS_PORT(X+1) */ - {0, 3, 1}, /* map_rxlos[2] = OPRXLOS_PORT(X+2) */ - {0, 3, 5}, /* map_rxlos[3] = OPRXLOS_PORT(X+3) */ - }, - .map_hard_rs0 = { {0, 0, 2}, /* map_hard_rs0[0] = RS0_SFP28_P(X) */ - {0, 0, 6}, /* map_hard_rs0[1] = RS0_SFP28_P(X+1) */ - {0, 1, 2}, /* map_hard_rs0[2] = RS0_SFP28_P(X+2) */ - {0, 1, 6}, /* map_hard_rs0[3] = RS0_SFP28_P(X+3) */ - }, - .map_hard_rs1 = { {0, 0, 2}, /* map_hard_rs1[0] = RS1_SFP28_P(X) */ - {0, 0, 6}, /* map_hard_rs1[1] = RS1_SFP28_P(X+1) */ - {0, 1, 2}, /* map_hard_rs1[2] = RS1_SFP28_P(X+2) */ - {0, 1, 6}, /* map_hard_rs1[3] = RS1_SFP28_P(X+3) */ - }, -}; - - -struct ioexp_map_s ioexp_map_maple_0abc = { - - .chip_amount = 3, - .data_width = 2, - - .map_present = { {2, 1, 0}, /* map_present[0] = MOD_ABS_PORT(X) */ - {2, 1, 1}, /* map_present[1] = MOD_ABS_PORT(X+1) */ - {2, 1, 2}, /* map_present[2] = MOD_ABS_PORT(X+2) */ - {2, 1, 3}, /* map_present[3] = MOD_ABS_PORT(X+3) */ - {2, 1, 4}, /* map_present[4] = MOD_ABS_PORT(X+4) */ - {2, 1, 5}, /* map_present[5] = MOD_ABS_PORT(X+5) */ - {2, 1, 6}, /* map_present[6] = MOD_ABS_PORT(X+6) */ - {2, 1, 7}, /* map_present[7] = MOD_ABS_PORT(X+7) */ - }, - .map_reset = { {0, 1, 0}, /* map_reset[0] = QRESET_QSFP_N_P(X) */ - {0, 1, 1}, /* map_reset[1] = QRESET_QSFP_N_P(X+1) */ - {0, 1, 2}, /* map_reset[2] = QRESET_QSFP_N_P(X+2) */ - {0, 1, 3}, /* map_reset[3] = QRESET_QSFP_N_P(X+3) */ - {0, 1, 4}, /* map_reset[4] = QRESET_QSFP_N_P(X+4) */ - {0, 1, 5}, /* map_reset[5] = QRESET_QSFP_N_P(X+5) */ - {0, 1, 6}, /* map_reset[6] = QRESET_QSFP_N_P(X+6) */ - {0, 1, 7}, /* map_reset[7] = QRESET_QSFP_N_P(X+7) */ - }, - .map_lpmod = { {1, 0, 0}, /* map_lpmod[0] = LPMODE_QSFP_P(X) */ - {1, 0, 1}, /* map_lpmod[1] = LPMODE_QSFP_P(X+1) */ - {1, 0, 2}, /* map_lpmod[2] = LPMODE_QSFP_P(X+2) */ - {1, 0, 3}, /* map_lpmod[3] = LPMODE_QSFP_P(X+3) */ - {1, 0, 4}, /* map_lpmod[4] = LPMODE_QSFP_P(X+4) */ - {1, 0, 5}, /* map_lpmod[5] = LPMODE_QSFP_P(X+5) */ - {1, 0, 6}, /* map_lpmod[6] = LPMODE_QSFP_P(X+6) */ - {1, 0, 7}, /* map_lpmod[7] = LPMODE_QSFP_P(X+7) */ - }, - .map_modsel = { {0, 0, 0}, /* map_modsel[0] = MODSEL_QSFP_N_P(X) */ - {0, 0, 1}, /* map_modsel[1] = MODSEL_QSFP_N_P(X+1) */ - {0, 0, 2}, /* map_modsel[2] = MODSEL_QSFP_N_P(X+2) */ - {0, 0, 3}, /* map_modsel[3] = MODSEL_QSFP_N_P(X+3) */ - {0, 0, 4}, /* map_modsel[4] = MODSEL_QSFP_N_P(X+4) */ - {0, 0, 5}, /* map_modsel[5] = MODSEL_QSFP_N_P(X+5) */ - {0, 0, 6}, /* map_modsel[6] = MODSEL_QSFP_N_P(X+6) */ - {0, 0, 7}, /* map_modsel[7] = MODSEL_QSFP_N_P(X+7) */ - }, -}; - - -struct ioexp_map_s ioexp_map_maple_nabc = { - - .chip_amount = 3, - .data_width = 2, - - .map_present = { {0, 0, 4}, /* map_present[0] = MOD_ABS_PORT(X) */ - {0, 0, 5}, /* map_present[1] = MOD_ABS_PORT(X+1) */ - {0, 0, 6}, /* map_present[2] = MOD_ABS_PORT(X+2) */ - {0, 0, 7}, /* map_present[3] = MOD_ABS_PORT(X+3) */ - {1, 0, 4}, /* map_present[4] = MOD_ABS_PORT(X+4) */ - {1, 0, 5}, /* map_present[5] = MOD_ABS_PORT(X+5) */ - {1, 0, 6}, /* map_present[6] = MOD_ABS_PORT(X+6) */ - {1, 0, 7}, /* map_present[7] = MOD_ABS_PORT(X+7) */ - }, - .map_tx_disable = { {0, 1, 0}, /* map_tx_disable[0] = TXDISABLE_SFP+_P(X) */ - {0, 1, 1}, /* map_tx_disable[1] = TXDISABLE_SFP+_P(X+1) */ - {0, 1, 2}, /* map_tx_disable[2] = TXDISABLE_SFP+_P(X+2) */ - {0, 1, 3}, /* map_tx_disable[3] = TXDISABLE_SFP+_P(X+3) */ - {1, 1, 0}, /* map_tx_disable[4] = TXDISABLE_SFP+_P(X+4) */ - {1, 1, 1}, /* map_tx_disable[5] = TXDISABLE_SFP+_P(X+5) */ - {1, 1, 2}, /* map_tx_disable[6] = TXDISABLE_SFP+_P(X+6) */ - {1, 1, 3}, /* map_tx_disable[7] = TXDISABLE_SFP+_P(X+7) */ - }, - .map_tx_fault = { {0, 0, 0}, /* map_tx_fault[0] = TXFAULT_SFP+_P(X) */ - {0, 0, 1}, /* map_tx_fault[1] = TXFAULT_SFP+_P(X+1) */ - {0, 0, 2}, /* map_tx_fault[2] = TXFAULT_SFP+_P(X+2) */ - {0, 0, 3}, /* map_tx_fault[3] = TXFAULT_SFP+_P(X+3) */ - {1, 0, 0}, /* map_tx_fault[4] = TXFAULT_SFP+_P(X+4) */ - {1, 0, 1}, /* map_tx_fault[5] = TXFAULT_SFP+_P(X+5) */ - {1, 0, 2}, /* map_tx_fault[6] = TXFAULT_SFP+_P(X+6) */ - {1, 0, 3}, /* map_tx_fault[7] = TXFAULT_SFP+_P(X+7) */ - }, - .map_rxlos = { {0, 1, 4}, /* map_rxlos[0] = OPRXLOS_PORT(X) */ - {0, 1, 5}, /* map_rxlos[1] = OPRXLOS_PORT(X+1) */ - {0, 1, 6}, /* map_rxlos[2] = OPRXLOS_PORT(X+2) */ - {0, 1, 7}, /* map_rxlos[3] = OPRXLOS_PORT(X+3) */ - {1, 1, 4}, /* map_rxlos[4] = OPRXLOS_PORT(X+4) */ - {1, 1, 5}, /* map_rxlos[5] = OPRXLOS_PORT(X+5) */ - {1, 1, 6}, /* map_rxlos[6] = OPRXLOS_PORT(X+6) */ - {1, 1, 7}, /* map_rxlos[7] = OPRXLOS_PORT(X+7) */ - }, - .map_hard_rs0 = { {2, 0, 0}, /* map_hard_rs0[0] = RS0_SFP28_P(X) */ - {2, 0, 2}, /* map_hard_rs0[1] = RS0_SFP28_P(X+1) */ - {2, 0, 4}, /* map_hard_rs0[2] = RS0_SFP28_P(X+2) */ - {2, 0, 6}, /* map_hard_rs0[3] = RS0_SFP28_P(X+3) */ - {2, 1, 0}, /* map_hard_rs0[4] = RS0_SFP28_P(X+4) */ - {2, 1, 2}, /* map_hard_rs0[5] = RS0_SFP28_P(X+5) */ - {2, 1, 4}, /* map_hard_rs0[6] = RS0_SFP28_P(X+6) */ - {2, 1, 6}, /* map_hard_rs0[7] = RS0_SFP28_P(X+7) */ - }, - .map_hard_rs1 = { {2, 0, 1}, /* map_hard_rs1[0] = RS1_SFP28_P(X) */ - {2, 0, 3}, /* map_hard_rs1[1] = RS1_SFP28_P(X+1) */ - {2, 0, 5}, /* map_hard_rs1[2] = RS1_SFP28_P(X+2) */ - {2, 0, 7}, /* map_hard_rs1[3] = RS1_SFP28_P(X+3) */ - {2, 1, 1}, /* map_hard_rs1[4] = RS1_SFP28_P(X+4) */ - {2, 1, 3}, /* map_hard_rs1[5] = RS1_SFP28_P(X+5) */ - {2, 1, 5}, /* map_hard_rs1[6] = RS1_SFP28_P(X+6) */ - {2, 1, 7}, /* map_hard_rs1[7] = RS1_SFP28_P(X+7) */ - }, -}; - - -struct ioexp_map_s ioexp_map_gulmohar_nabc = { - - .chip_amount = 3, - .data_width = 2, - - .map_present = { {0, 0, 4}, /* map_present[0] = MOD_ABS_PORT(X) */ - {0, 0, 5}, /* map_present[1] = MOD_ABS_PORT(X+1) */ - {0, 1, 4}, /* map_present[2] = MOD_ABS_PORT(X+2) */ - {0, 1, 5}, /* map_present[3] = MOD_ABS_PORT(X+3) */ - {1, 0, 4}, /* map_present[4] = MOD_ABS_PORT(X+4) */ - {1, 0, 5}, /* map_present[5] = MOD_ABS_PORT(X+5) */ - {1, 1, 4}, /* map_present[6] = MOD_ABS_PORT(X+6) */ - {1, 1, 5}, /* map_present[7] = MOD_ABS_PORT(X+7) */ - }, - .map_tx_disable = { {0, 0, 2}, /* map_tx_disable[0] = TXDISABLE_SFP+_P(X) */ - {0, 0, 3}, /* map_tx_disable[1] = TXDISABLE_SFP+_P(X+1) */ - {0, 1, 2}, /* map_tx_disable[2] = TXDISABLE_SFP+_P(X+2) */ - {0, 1, 3}, /* map_tx_disable[3] = TXDISABLE_SFP+_P(X+3) */ - {1, 0, 2}, /* map_tx_disable[4] = TXDISABLE_SFP+_P(X+4) */ - {1, 0, 3}, /* map_tx_disable[5] = TXDISABLE_SFP+_P(X+5) */ - {1, 1, 2}, /* map_tx_disable[6] = TXDISABLE_SFP+_P(X+6) */ - {1, 1, 3}, /* map_tx_disable[7] = TXDISABLE_SFP+_P(X+7) */ - }, - .map_tx_fault = { {0, 0, 0}, /* map_tx_fault[0] = TXFAULT_SFP+_P(X) */ - {0, 0, 1}, /* map_tx_fault[1] = TXFAULT_SFP+_P(X+1) */ - {0, 1, 0}, /* map_tx_fault[2] = TXFAULT_SFP+_P(X+2) */ - {0, 1, 1}, /* map_tx_fault[3] = TXFAULT_SFP+_P(X+3) */ - {1, 0, 0}, /* map_tx_fault[4] = TXFAULT_SFP+_P(X+4) */ - {1, 0, 1}, /* map_tx_fault[5] = TXFAULT_SFP+_P(X+5) */ - {1, 1, 0}, /* map_tx_fault[6] = TXFAULT_SFP+_P(X+6) */ - {1, 1, 1}, /* map_tx_fault[7] = TXFAULT_SFP+_P(X+7) */ - }, - .map_rxlos = { {0, 0, 6}, /* map_rxlos[0] = OPRXLOS_PORT(X) */ - {0, 0, 7}, /* map_rxlos[1] = OPRXLOS_PORT(X+1) */ - {0, 1, 6}, /* map_rxlos[2] = OPRXLOS_PORT(X+2) */ - {0, 1, 7}, /* map_rxlos[3] = OPRXLOS_PORT(X+3) */ - {1, 0, 6}, /* map_rxlos[4] = OPRXLOS_PORT(X+4) */ - {1, 0, 7}, /* map_rxlos[5] = OPRXLOS_PORT(X+5) */ - {1, 1, 6}, /* map_rxlos[6] = OPRXLOS_PORT(X+6) */ - {1, 1, 7}, /* map_rxlos[7] = OPRXLOS_PORT(X+7) */ - }, - .map_hard_rs0 = { {2, 0, 0}, /* map_hard_rs0[0] = RS0_SFP28_P(X) */ - {2, 0, 2}, /* map_hard_rs0[1] = RS0_SFP28_P(X+1) */ - {2, 0, 4}, /* map_hard_rs0[2] = RS0_SFP28_P(X+2) */ - {2, 0, 6}, /* map_hard_rs0[3] = RS0_SFP28_P(X+3) */ - {2, 1, 0}, /* map_hard_rs0[4] = RS0_SFP28_P(X+4) */ - {2, 1, 2}, /* map_hard_rs0[5] = RS0_SFP28_P(X+5) */ - {2, 1, 4}, /* map_hard_rs0[6] = RS0_SFP28_P(X+6) */ - {2, 1, 6}, /* map_hard_rs0[7] = RS0_SFP28_P(X+7) */ - }, - .map_hard_rs1 = { {2, 0, 1}, /* map_hard_rs1[0] = RS1_SFP28_P(X) */ - {2, 0, 3}, /* map_hard_rs1[1] = RS1_SFP28_P(X+1) */ - {2, 0, 5}, /* map_hard_rs1[2] = RS1_SFP28_P(X+2) */ - {2, 0, 7}, /* map_hard_rs1[3] = RS1_SFP28_P(X+3) */ - {2, 1, 1}, /* map_hard_rs1[4] = RS1_SFP28_P(X+4) */ - {2, 1, 3}, /* map_hard_rs1[5] = RS1_SFP28_P(X+5) */ - {2, 1, 5}, /* map_hard_rs1[6] = RS1_SFP28_P(X+6) */ - {2, 1, 7}, /* map_hard_rs1[7] = RS1_SFP28_P(X+7) */ - }, -}; - - -struct ioexp_map_s ioexp_map_gulmohar_7abc = { - - .chip_amount = 3, - .data_width = 2, - - .map_present = { {2, 1, 0}, /* map_present[0] = MOD_ABS_PORT(X) */ - {2, 1, 1}, /* map_present[1] = MOD_ABS_PORT(X+1) */ - {2, 1, 2}, /* map_present[2] = MOD_ABS_PORT(X+2) */ - {2, 1, 3}, /* map_present[3] = MOD_ABS_PORT(X+3) */ - {2, 1, 4}, /* map_present[4] = MOD_ABS_PORT(X+4) */ - {2, 1, 5}, /* map_present[5] = MOD_ABS_PORT(X+5) */ - }, - .map_reset = { {0, 1, 0}, /* map_reset[0] = QRESET_QSFP_N_P(X) */ - {0, 1, 1}, /* map_reset[1] = QRESET_QSFP_N_P(X+1) */ - {0, 1, 2}, /* map_reset[2] = QRESET_QSFP_N_P(X+2) */ - {0, 1, 3}, /* map_reset[3] = QRESET_QSFP_N_P(X+3) */ - {0, 1, 4}, /* map_reset[4] = QRESET_QSFP_N_P(X+4) */ - {0, 1, 5}, /* map_reset[5] = QRESET_QSFP_N_P(X+5) */ - }, - .map_lpmod = { {1, 0, 0}, /* map_lpmod[0] = LPMODE_QSFP_P(X) */ - {1, 0, 1}, /* map_lpmod[1] = LPMODE_QSFP_P(X+1) */ - {1, 0, 2}, /* map_lpmod[2] = LPMODE_QSFP_P(X+2) */ - {1, 0, 3}, /* map_lpmod[3] = LPMODE_QSFP_P(X+3) */ - {1, 0, 4}, /* map_lpmod[4] = LPMODE_QSFP_P(X+4) */ - {1, 0, 5}, /* map_lpmod[5] = LPMODE_QSFP_P(X+5) */ - }, - .map_modsel = { {0, 0, 0}, /* map_modsel[0] = MODSEL_QSFP_N_P(X) */ - {0, 0, 1}, /* map_modsel[1] = MODSEL_QSFP_N_P(X+1) */ - {0, 0, 2}, /* map_modsel[2] = MODSEL_QSFP_N_P(X+2) */ - {0, 0, 3}, /* map_modsel[3] = MODSEL_QSFP_N_P(X+3) */ - {0, 0, 4}, /* map_modsel[4] = MODSEL_QSFP_N_P(X+4) */ - {0, 0, 5}, /* map_modsel[5] = MODSEL_QSFP_N_P(X+5) */ - }, -}; - - -struct ioexp_map_s ioexp_map_gulmohar_2t_evt1_nabc = { - - .chip_amount = 3, - .data_width = 2, - - .map_present = { {0, 0, 2}, /* map_present[0] = MOD_ABS_PORT(X) */ - {0, 0, 6}, /* map_present[1] = MOD_ABS_PORT(X+1) */ - {0, 1, 2}, /* map_present[2] = MOD_ABS_PORT(X+2) */ - {0, 1, 6}, /* map_present[3] = MOD_ABS_PORT(X+3) */ - {1, 0, 2}, /* map_present[4] = MOD_ABS_PORT(X+4) */ - {1, 0, 6}, /* map_present[5] = MOD_ABS_PORT(X+5) */ - {1, 1, 2}, /* map_present[6] = MOD_ABS_PORT(X+6) */ - {1, 1, 6}, /* map_present[7] = MOD_ABS_PORT(X+7) */ - }, - .map_tx_disable = { {0, 0, 1}, /* map_tx_disable[0] = TXDISABLE_SFP+_P(X) */ - {0, 0, 5}, /* map_tx_disable[1] = TXDISABLE_SFP+_P(X+1) */ - {0, 1, 1}, /* map_tx_disable[2] = TXDISABLE_SFP+_P(X+2) */ - {0, 1, 5}, /* map_tx_disable[3] = TXDISABLE_SFP+_P(X+3) */ - {1, 0, 1}, /* map_tx_disable[4] = TXDISABLE_SFP+_P(X+4) */ - {1, 0, 5}, /* map_tx_disable[5] = TXDISABLE_SFP+_P(X+5) */ - {1, 1, 1}, /* map_tx_disable[6] = TXDISABLE_SFP+_P(X+6) */ - {1, 1, 5}, /* map_tx_disable[7] = TXDISABLE_SFP+_P(X+7) */ - }, - .map_tx_fault = { {0, 0, 0}, /* map_tx_fault[0] = TXFAULT_SFP+_P(X) */ - {0, 0, 4}, /* map_tx_fault[1] = TXFAULT_SFP+_P(X+1) */ - {0, 1, 0}, /* map_tx_fault[2] = TXFAULT_SFP+_P(X+2) */ - {0, 1, 4}, /* map_tx_fault[3] = TXFAULT_SFP+_P(X+3) */ - {1, 0, 0}, /* map_tx_fault[4] = TXFAULT_SFP+_P(X+4) */ - {1, 0, 4}, /* map_tx_fault[5] = TXFAULT_SFP+_P(X+5) */ - {1, 1, 0}, /* map_tx_fault[6] = TXFAULT_SFP+_P(X+6) */ - {1, 1, 4}, /* map_tx_fault[7] = TXFAULT_SFP+_P(X+7) */ - }, - .map_rxlos = { {0, 0, 3}, /* map_rxlos[0] = OPRXLOS_PORT(X) */ - {0, 0, 7}, /* map_rxlos[1] = OPRXLOS_PORT(X+1) */ - {0, 1, 3}, /* map_rxlos[2] = OPRXLOS_PORT(X+2) */ - {0, 1, 7}, /* map_rxlos[3] = OPRXLOS_PORT(X+3) */ - {1, 0, 3}, /* map_rxlos[4] = OPRXLOS_PORT(X+4) */ - {1, 0, 7}, /* map_rxlos[5] = OPRXLOS_PORT(X+5) */ - {1, 1, 3}, /* map_rxlos[6] = OPRXLOS_PORT(X+6) */ - {1, 1, 7}, /* map_rxlos[7] = OPRXLOS_PORT(X+7) */ - }, - .map_hard_rs0 = { {2, 0, 0}, /* map_hard_rs0[0] = RS0_SFP28_P(X) */ - {2, 0, 2}, /* map_hard_rs0[1] = RS0_SFP28_P(X+1) */ - {2, 0, 4}, /* map_hard_rs0[2] = RS0_SFP28_P(X+2) */ - {2, 0, 6}, /* map_hard_rs0[3] = RS0_SFP28_P(X+3) */ - {2, 1, 0}, /* map_hard_rs0[4] = RS0_SFP28_P(X+4) */ - {2, 1, 2}, /* map_hard_rs0[5] = RS0_SFP28_P(X+5) */ - {2, 1, 4}, /* map_hard_rs0[6] = RS0_SFP28_P(X+6) */ - {2, 1, 6}, /* map_hard_rs0[7] = RS0_SFP28_P(X+7) */ - }, - .map_hard_rs1 = { {2, 0, 1}, /* map_hard_rs1[0] = RS1_SFP28_P(X) */ - {2, 0, 3}, /* map_hard_rs1[1] = RS1_SFP28_P(X+1) */ - {2, 0, 5}, /* map_hard_rs1[2] = RS1_SFP28_P(X+2) */ - {2, 0, 7}, /* map_hard_rs1[3] = RS1_SFP28_P(X+3) */ - {2, 1, 1}, /* map_hard_rs1[4] = RS1_SFP28_P(X+4) */ - {2, 1, 3}, /* map_hard_rs1[5] = RS1_SFP28_P(X+5) */ - {2, 1, 5}, /* map_hard_rs1[6] = RS1_SFP28_P(X+6) */ - {2, 1, 7}, /* map_hard_rs1[7] = RS1_SFP28_P(X+7) */ - }, -}; - - -struct ioexp_map_s ioexp_map_gulmohar_2t_evt1_1abc = { - - .chip_amount = 3, - .data_width = 2, - - .map_present = { {0, 0, 2}, /* map_present[0] = MOD_ABS_PORT(X) */ - {0, 0, 6}, /* map_present[1] = MOD_ABS_PORT(X+1) */ - {0, 1, 2}, /* map_present[2] = MOD_ABS_PORT(X+2) */ - {0, 1, 6}, /* map_present[3] = MOD_ABS_PORT(X+3) */ - {1, 0, 4}, /* map_present[4] = MOD_ABS_PORT(X+4) */ - {1, 0, 5}, /* map_present[5] = MOD_ABS_PORT(X+5) */ - {1, 1, 4}, /* map_present[6] = MOD_ABS_PORT(X+6) */ - {1, 1, 5}, /* map_present[7] = MOD_ABS_PORT(X+7) */ - }, - .map_tx_disable = { {0, 0, 1}, /* map_tx_disable[0] = TXDISABLE_SFP+_P(X) */ - {0, 0, 5}, /* map_tx_disable[1] = TXDISABLE_SFP+_P(X+1) */ - {0, 1, 1}, /* map_tx_disable[2] = TXDISABLE_SFP+_P(X+2) */ - {0, 1, 5}, /* map_tx_disable[3] = TXDISABLE_SFP+_P(X+3) */ - {1, 0, 2}, /* map_tx_disable[4] = TXDISABLE_SFP+_P(X+4) */ - {1, 0, 3}, /* map_tx_disable[5] = TXDISABLE_SFP+_P(X+5) */ - {1, 1, 2}, /* map_tx_disable[6] = TXDISABLE_SFP+_P(X+6) */ - {1, 1, 3}, /* map_tx_disable[7] = TXDISABLE_SFP+_P(X+7) */ - }, - .map_tx_fault = { {0, 0, 0}, /* map_tx_fault[0] = TXFAULT_SFP+_P(X) */ - {0, 0, 4}, /* map_tx_fault[1] = TXFAULT_SFP+_P(X+1) */ - {0, 1, 0}, /* map_tx_fault[2] = TXFAULT_SFP+_P(X+2) */ - {0, 1, 4}, /* map_tx_fault[3] = TXFAULT_SFP+_P(X+3) */ - {1, 0, 0}, /* map_tx_fault[4] = TXFAULT_SFP+_P(X+4) */ - {1, 0, 1}, /* map_tx_fault[5] = TXFAULT_SFP+_P(X+5) */ - {1, 1, 0}, /* map_tx_fault[6] = TXFAULT_SFP+_P(X+6) */ - {1, 1, 1}, /* map_tx_fault[7] = TXFAULT_SFP+_P(X+7) */ - }, - .map_rxlos = { {0, 0, 3}, /* map_rxlos[0] = OPRXLOS_PORT(X) */ - {0, 0, 7}, /* map_rxlos[1] = OPRXLOS_PORT(X+1) */ - {0, 1, 3}, /* map_rxlos[2] = OPRXLOS_PORT(X+2) */ - {0, 1, 7}, /* map_rxlos[3] = OPRXLOS_PORT(X+3) */ - {1, 0, 6}, /* map_rxlos[4] = OPRXLOS_PORT(X+4) */ - {1, 0, 7}, /* map_rxlos[5] = OPRXLOS_PORT(X+5) */ - {1, 1, 6}, /* map_rxlos[6] = OPRXLOS_PORT(X+6) */ - {1, 1, 7}, /* map_rxlos[7] = OPRXLOS_PORT(X+7) */ - }, - .map_hard_rs0 = { {2, 0, 0}, /* map_hard_rs0[0] = RS0_SFP28_P(X) */ - {2, 0, 2}, /* map_hard_rs0[1] = RS0_SFP28_P(X+1) */ - {2, 0, 4}, /* map_hard_rs0[2] = RS0_SFP28_P(X+2) */ - {2, 0, 6}, /* map_hard_rs0[3] = RS0_SFP28_P(X+3) */ - {2, 1, 0}, /* map_hard_rs0[4] = RS0_SFP28_P(X+4) */ - {2, 1, 2}, /* map_hard_rs0[5] = RS0_SFP28_P(X+5) */ - {2, 1, 4}, /* map_hard_rs0[6] = RS0_SFP28_P(X+6) */ - {2, 1, 6}, /* map_hard_rs0[7] = RS0_SFP28_P(X+7) */ - }, - .map_hard_rs1 = { {2, 0, 1}, /* map_hard_rs1[0] = RS1_SFP28_P(X) */ - {2, 0, 3}, /* map_hard_rs1[1] = RS1_SFP28_P(X+1) */ - {2, 0, 5}, /* map_hard_rs1[2] = RS1_SFP28_P(X+2) */ - {2, 0, 7}, /* map_hard_rs1[3] = RS1_SFP28_P(X+3) */ - {2, 1, 1}, /* map_hard_rs1[4] = RS1_SFP28_P(X+4) */ - {2, 1, 3}, /* map_hard_rs1[5] = RS1_SFP28_P(X+5) */ - {2, 1, 5}, /* map_hard_rs1[6] = RS1_SFP28_P(X+6) */ - {2, 1, 7}, /* map_hard_rs1[7] = RS1_SFP28_P(X+7) */ - }, -}; - - -struct ioexp_map_s ioexp_map_gulmohar_2t_evt1_3abc = { - - .chip_amount = 3, - .data_width = 2, - - .map_present = { {0, 0, 4}, /* map_present[0] = MOD_ABS_PORT(X) */ - {0, 0, 5}, /* map_present[1] = MOD_ABS_PORT(X+1) */ - {0, 1, 4}, /* map_present[2] = MOD_ABS_PORT(X+2) */ - {0, 1, 5}, /* map_present[3] = MOD_ABS_PORT(X+3) */ - {1, 0, 2}, /* map_present[4] = MOD_ABS_PORT(X+4) */ - {1, 0, 6}, /* map_present[5] = MOD_ABS_PORT(X+5) */ - {1, 1, 2}, /* map_present[6] = MOD_ABS_PORT(X+6) */ - {1, 1, 6}, /* map_present[7] = MOD_ABS_PORT(X+7) */ - }, - .map_tx_disable = { {0, 0, 2}, /* map_tx_disable[0] = TXDISABLE_SFP+_P(X) */ - {0, 0, 3}, /* map_tx_disable[1] = TXDISABLE_SFP+_P(X+1) */ - {0, 1, 2}, /* map_tx_disable[2] = TXDISABLE_SFP+_P(X+2) */ - {0, 1, 3}, /* map_tx_disable[3] = TXDISABLE_SFP+_P(X+3) */ - {1, 0, 1}, /* map_tx_disable[4] = TXDISABLE_SFP+_P(X+4) */ - {1, 0, 5}, /* map_tx_disable[5] = TXDISABLE_SFP+_P(X+5) */ - {1, 1, 1}, /* map_tx_disable[6] = TXDISABLE_SFP+_P(X+6) */ - {1, 1, 5}, /* map_tx_disable[7] = TXDISABLE_SFP+_P(X+7) */ - }, - .map_tx_fault = { {0, 0, 0}, /* map_tx_fault[0] = TXFAULT_SFP+_P(X) */ - {0, 0, 1}, /* map_tx_fault[1] = TXFAULT_SFP+_P(X+1) */ - {0, 1, 0}, /* map_tx_fault[2] = TXFAULT_SFP+_P(X+2) */ - {0, 1, 1}, /* map_tx_fault[3] = TXFAULT_SFP+_P(X+3) */ - {1, 0, 0}, /* map_tx_fault[4] = TXFAULT_SFP+_P(X+4) */ - {1, 0, 4}, /* map_tx_fault[5] = TXFAULT_SFP+_P(X+5) */ - {1, 1, 0}, /* map_tx_fault[6] = TXFAULT_SFP+_P(X+6) */ - {1, 1, 4}, /* map_tx_fault[7] = TXFAULT_SFP+_P(X+7) */ - }, - .map_rxlos = { {0, 0, 6}, /* map_rxlos[0] = OPRXLOS_PORT(X) */ - {0, 0, 7}, /* map_rxlos[1] = OPRXLOS_PORT(X+1) */ - {0, 1, 6}, /* map_rxlos[2] = OPRXLOS_PORT(X+2) */ - {0, 1, 7}, /* map_rxlos[3] = OPRXLOS_PORT(X+3) */ - {1, 0, 3}, /* map_rxlos[4] = OPRXLOS_PORT(X+4) */ - {1, 0, 7}, /* map_rxlos[5] = OPRXLOS_PORT(X+5) */ - {1, 1, 3}, /* map_rxlos[6] = OPRXLOS_PORT(X+6) */ - {1, 1, 7}, /* map_rxlos[7] = OPRXLOS_PORT(X+7) */ - }, - .map_hard_rs0 = { {2, 0, 0}, /* map_hard_rs0[0] = RS0_SFP28_P(X) */ - {2, 0, 2}, /* map_hard_rs0[1] = RS0_SFP28_P(X+1) */ - {2, 0, 4}, /* map_hard_rs0[2] = RS0_SFP28_P(X+2) */ - {2, 0, 6}, /* map_hard_rs0[3] = RS0_SFP28_P(X+3) */ - {2, 1, 0}, /* map_hard_rs0[4] = RS0_SFP28_P(X+4) */ - {2, 1, 2}, /* map_hard_rs0[5] = RS0_SFP28_P(X+5) */ - {2, 1, 4}, /* map_hard_rs0[6] = RS0_SFP28_P(X+6) */ - {2, 1, 6}, /* map_hard_rs0[7] = RS0_SFP28_P(X+7) */ - }, - .map_hard_rs1 = { {2, 0, 1}, /* map_hard_rs1[0] = RS1_SFP28_P(X) */ - {2, 0, 3}, /* map_hard_rs1[1] = RS1_SFP28_P(X+1) */ - {2, 0, 5}, /* map_hard_rs1[2] = RS1_SFP28_P(X+2) */ - {2, 0, 7}, /* map_hard_rs1[3] = RS1_SFP28_P(X+3) */ - {2, 1, 1}, /* map_hard_rs1[4] = RS1_SFP28_P(X+4) */ - {2, 1, 3}, /* map_hard_rs1[5] = RS1_SFP28_P(X+5) */ - {2, 1, 5}, /* map_hard_rs1[6] = RS1_SFP28_P(X+6) */ - {2, 1, 7}, /* map_hard_rs1[7] = RS1_SFP28_P(X+7) */ - }, -}; - - - -struct ioexp_map_s ioexp_map_gulmohar_2t_evt1_7abc = { - - .chip_amount = 3, - .data_width = 2, - - .map_present = { {0, 0, 4}, /* map_present[0] = MOD_ABS_PORT(X) */ - {0, 1, 1}, /* map_present[1] = MOD_ABS_PORT(X+1) */ - {0, 1, 6}, /* map_present[2] = MOD_ABS_PORT(X+2) */ - {1, 0, 4}, /* map_present[3] = MOD_ABS_PORT(X+3) */ - {1, 1, 1}, /* map_present[4] = MOD_ABS_PORT(X+4) */ - {1, 1, 6}, /* map_present[5] = MOD_ABS_PORT(X+5) */ - {2, 0, 4}, /* map_present[6] = MOD_ABS_PORT(X+6) */ - {2, 1, 1}, /* map_present[7] = MOD_ABS_PORT(X+7) */ - }, - .map_reset = { {0, 0, 1}, /* map_reset[0] = QRESET_QSFP_N_P(X) */ - {0, 0, 6}, /* map_reset[1] = QRESET_QSFP_N_P(X+1) */ - {0, 1, 3}, /* map_reset[2] = QRESET_QSFP_N_P(X+2) */ - {1, 0, 1}, /* map_reset[3] = QRESET_QSFP_N_P(X+3) */ - {1, 0, 6}, /* map_reset[4] = QRESET_QSFP_N_P(X+4) */ - {1, 1, 3}, /* map_reset[5] = QRESET_QSFP_N_P(X+5) */ - {2, 0, 1}, /* map_reset[6] = QRESET_QSFP_N_P(X+6) */ - {2, 0, 6}, /* map_reset[7] = QRESET_QSFP_N_P(X+7) */ - }, - .map_lpmod = { {0, 0, 2}, /* map_lpmod[0] = LPMODE_QSFP_P(X) */ - {0, 0, 7}, /* map_lpmod[1] = LPMODE_QSFP_P(X+1) */ - {0, 1, 4}, /* map_lpmod[2] = LPMODE_QSFP_P(X+2) */ - {1, 0, 2}, /* map_lpmod[3] = LPMODE_QSFP_P(X+3) */ - {1, 0, 7}, /* map_lpmod[4] = LPMODE_QSFP_P(X+4) */ - {1, 1, 4}, /* map_lpmod[5] = LPMODE_QSFP_P(X+5) */ - {2, 0, 2}, /* map_lpmod[6] = LPMODE_QSFP_P(X+6) */ - {2, 0, 7}, /* map_lpmod[7] = LPMODE_QSFP_P(X+7) */ - }, - .map_modsel = { {0, 0, 0}, /* map_modsel[0] = MODSEL_QSFP_N_P(X) */ - {0, 0, 5}, /* map_modsel[1] = MODSEL_QSFP_N_P(X+1) */ - {0, 1, 2}, /* map_modsel[2] = MODSEL_QSFP_N_P(X+2) */ - {1, 0, 0}, /* map_modsel[3] = MODSEL_QSFP_N_P(X+3) */ - {1, 0, 5}, /* map_modsel[4] = MODSEL_QSFP_N_P(X+4) */ - {1, 1, 2}, /* map_modsel[5] = MODSEL_QSFP_N_P(X+5) */ - {2, 0, 0}, /* map_modsel[6] = MODSEL_QSFP_N_P(X+6) */ - {2, 0, 5}, /* map_modsel[7] = MODSEL_QSFP_N_P(X+7) */ - }, -}; - - -/* PortType: SFP / 8 port - * Platform: Cypress, Peony_SFP - */ -struct ioexp_map_s ioexp_map_sfp_8p_layout_1 = { - - .chip_amount = 3, - .data_width = 2, - - .map_present = { {0, 0, 4}, /* map_present[0] = MOD_ABS_PORT(X) */ - {0, 0, 5}, /* map_present[1] = MOD_ABS_PORT(X+1) */ - {0, 0, 6}, /* map_present[2] = MOD_ABS_PORT(X+2) */ - {0, 0, 7}, /* map_present[3] = MOD_ABS_PORT(X+3) */ - {1, 0, 4}, /* map_present[4] = MOD_ABS_PORT(X+4) */ - {1, 0, 5}, /* map_present[5] = MOD_ABS_PORT(X+5) */ - {1, 0, 6}, /* map_present[6] = MOD_ABS_PORT(X+6) */ - {1, 0, 7}, /* map_present[7] = MOD_ABS_PORT(X+7) */ - }, - .map_tx_disable = { {0, 1, 0}, /* map_tx_disable[0] = TXDISABLE_SFP+_P(X) */ - {0, 1, 1}, /* map_tx_disable[1] = TXDISABLE_SFP+_P(X+1) */ - {0, 1, 2}, /* map_tx_disable[2] = TXDISABLE_SFP+_P(X+2) */ - {0, 1, 3}, /* map_tx_disable[3] = TXDISABLE_SFP+_P(X+3) */ - {1, 1, 0}, /* map_tx_disable[4] = TXDISABLE_SFP+_P(X+4) */ - {1, 1, 1}, /* map_tx_disable[5] = TXDISABLE_SFP+_P(X+5) */ - {1, 1, 2}, /* map_tx_disable[6] = TXDISABLE_SFP+_P(X+6) */ - {1, 1, 3}, /* map_tx_disable[7] = TXDISABLE_SFP+_P(X+7) */ - }, - .map_tx_fault = { {0, 0, 0}, /* map_tx_fault[0] = TXFAULT_SFP+_P(X) */ - {0, 0, 1}, /* map_tx_fault[1] = TXFAULT_SFP+_P(X+1) */ - {0, 0, 2}, /* map_tx_fault[2] = TXFAULT_SFP+_P(X+2) */ - {0, 0, 3}, /* map_tx_fault[3] = TXFAULT_SFP+_P(X+3) */ - {1, 0, 0}, /* map_tx_fault[4] = TXFAULT_SFP+_P(X+4) */ - {1, 0, 1}, /* map_tx_fault[5] = TXFAULT_SFP+_P(X+5) */ - {1, 0, 2}, /* map_tx_fault[6] = TXFAULT_SFP+_P(X+6) */ - {1, 0, 3}, /* map_tx_fault[7] = TXFAULT_SFP+_P(X+7) */ - }, - .map_rxlos = { {0, 1, 4}, /* map_rxlos[0] = OPRXLOS_PORT(X) */ - {0, 1, 5}, /* map_rxlos[1] = OPRXLOS_PORT(X+1) */ - {0, 1, 6}, /* map_rxlos[2] = OPRXLOS_PORT(X+2) */ - {0, 1, 7}, /* map_rxlos[3] = OPRXLOS_PORT(X+3) */ - {1, 1, 4}, /* map_rxlos[4] = OPRXLOS_PORT(X+4) */ - {1, 1, 5}, /* map_rxlos[5] = OPRXLOS_PORT(X+5) */ - {1, 1, 6}, /* map_rxlos[6] = OPRXLOS_PORT(X+6) */ - {1, 1, 7}, /* map_rxlos[7] = OPRXLOS_PORT(X+7) */ - }, - .map_hard_rs0 = { {2, 0, 0}, /* map_hard_rs0[0] = RS0_SFP28_P(X) */ - {2, 0, 2}, /* map_hard_rs0[1] = RS0_SFP28_P(X+1) */ - {2, 0, 4}, /* map_hard_rs0[2] = RS0_SFP28_P(X+2) */ - {2, 0, 6}, /* map_hard_rs0[3] = RS0_SFP28_P(X+3) */ - {2, 1, 0}, /* map_hard_rs0[4] = RS0_SFP28_P(X+4) */ - {2, 1, 2}, /* map_hard_rs0[5] = RS0_SFP28_P(X+5) */ - {2, 1, 4}, /* map_hard_rs0[6] = RS0_SFP28_P(X+6) */ - {2, 1, 6}, /* map_hard_rs0[7] = RS0_SFP28_P(X+7) */ - }, - .map_hard_rs1 = { {2, 0, 1}, /* map_hard_rs1[0] = RS1_SFP28_P(X) */ - {2, 0, 3}, /* map_hard_rs1[1] = RS1_SFP28_P(X+1) */ - {2, 0, 5}, /* map_hard_rs1[2] = RS1_SFP28_P(X+2) */ - {2, 0, 7}, /* map_hard_rs1[3] = RS1_SFP28_P(X+3) */ - {2, 1, 1}, /* map_hard_rs1[4] = RS1_SFP28_P(X+4) */ - {2, 1, 3}, /* map_hard_rs1[5] = RS1_SFP28_P(X+5) */ - {2, 1, 5}, /* map_hard_rs1[6] = RS1_SFP28_P(X+6) */ - {2, 1, 7}, /* map_hard_rs1[7] = RS1_SFP28_P(X+7) */ - }, -}; - - -/* PortType: QSFP / 6 port - * Platform: Gulmohar, Peony_SFP, Peony_Copper - */ -struct ioexp_map_s ioexp_map_6p_qsfp_type_1 = { - - .chip_amount = 3, - .data_width = 2, - - .map_present = { {2, 1, 0}, /* map_present[0] = MOD_ABS_PORT(X) */ - {2, 1, 1}, /* map_present[1] = MOD_ABS_PORT(X+1) */ - {2, 1, 2}, /* map_present[2] = MOD_ABS_PORT(X+2) */ - {2, 1, 3}, /* map_present[3] = MOD_ABS_PORT(X+3) */ - {2, 1, 4}, /* map_present[4] = MOD_ABS_PORT(X+4) */ - {2, 1, 5}, /* map_present[5] = MOD_ABS_PORT(X+5) */ - }, - .map_reset = { {0, 1, 0}, /* map_reset[0] = QRESET_QSFP_N_P(X) */ - {0, 1, 1}, /* map_reset[1] = QRESET_QSFP_N_P(X+1) */ - {0, 1, 2}, /* map_reset[2] = QRESET_QSFP_N_P(X+2) */ - {0, 1, 3}, /* map_reset[3] = QRESET_QSFP_N_P(X+3) */ - {0, 1, 4}, /* map_reset[4] = QRESET_QSFP_N_P(X+4) */ - {0, 1, 5}, /* map_reset[5] = QRESET_QSFP_N_P(X+5) */ - }, - .map_lpmod = { {1, 0, 0}, /* map_lpmod[0] = LPMODE_QSFP_P(X) */ - {1, 0, 1}, /* map_lpmod[1] = LPMODE_QSFP_P(X+1) */ - {1, 0, 2}, /* map_lpmod[2] = LPMODE_QSFP_P(X+2) */ - {1, 0, 3}, /* map_lpmod[3] = LPMODE_QSFP_P(X+3) */ - {1, 0, 4}, /* map_lpmod[4] = LPMODE_QSFP_P(X+4) */ - {1, 0, 5}, /* map_lpmod[5] = LPMODE_QSFP_P(X+5) */ - }, - .map_modsel = { {0, 0, 0}, /* map_modsel[0] = MODSEL_QSFP_N_P(X) */ - {0, 0, 1}, /* map_modsel[1] = MODSEL_QSFP_N_P(X+1) */ - {0, 0, 2}, /* map_modsel[2] = MODSEL_QSFP_N_P(X+2) */ - {0, 0, 3}, /* map_modsel[3] = MODSEL_QSFP_N_P(X+3) */ - {0, 0, 4}, /* map_modsel[4] = MODSEL_QSFP_N_P(X+4) */ - {0, 0, 5}, /* map_modsel[5] = MODSEL_QSFP_N_P(X+5) */ - }, -}; - - -/* ========== Private functions ========== - */ -int check_channel_tier_1(void); - -struct i2c_client * -_get_i2c_client(struct ioexp_obj_s *self, - int chip_id){ - - struct ioexp_i2c_s *i2c_curr_p = self->i2c_head_p; - - if (!(i2c_curr_p)){ - SWPS_ERR("%s: i2c_curr_p is NULL\n", __func__); - return NULL; - } - while (i2c_curr_p){ - if ((i2c_curr_p->chip_id) == chip_id){ - return i2c_curr_p->i2c_client_p; - } - i2c_curr_p = i2c_curr_p->next; - } - SWPS_ERR("%s: not exist! :%d\n", __func__, chip_id); - return NULL; -} - - -static int -_common_ioexp_update_one(struct ioexp_obj_s *self, - struct ioexp_addr_s *ioexp_addr, - int chip_id, - int data_width, - int show_err, - char *caller_name) { - int buf = 0; - int err = 0; - int data_id = 0; - int r_offset = 0; - - for(data_id=0; data_idread_offset[data_id]; - if (r_offset < 0) { - SWPS_DEBUG("skip a read_offset <%d>\n", r_offset); - continue; - } - buf = i2c_smbus_read_byte_data(_get_i2c_client(self, chip_id), r_offset); - /* Check error */ - if (buf < 0) { - err = 1; - if (show_err) { - SWPS_INFO("IOEXP-%d read fail! :%d \n", self->ioexp_id, buf); - SWPS_INFO("Dump: :%d :0x%02x :%d, :%s\n", - ioexp_addr->chan_id, ioexp_addr->chip_addr, - ioexp_addr->read_offset[data_id], caller_name); - } - continue; - } - /* Update IOEXP object */ - self->chip_data[chip_id].data[data_id] = (uint8_t)buf; - } - if (err) { - return ERR_IOEXP_UNEXCPT; - } - return 0; -} - - -static int -common_ioexp_update_all(struct ioexp_obj_s *self, - int show_err, - char *caller_name){ - - int err = 0; - int chip_id = 0; - int chip_amount = self->ioexp_map_p->chip_amount; - - for (chip_id=0; chip_idioexp_map_p->map_addr[chip_id]), - chip_id, - self->ioexp_map_p->data_width, - show_err, - caller_name) < 0) { - err = 1; - } - } - if (err) { - return ERR_IOEXP_UNEXCPT; - } - return 0; -} - - -static int -_common_check_by_mode(struct ioexp_obj_s *self){ - - switch (self->mode){ - case IOEXP_MODE_DIRECT: - return self->fsm_4_direct(self); - - case IOEXP_MODE_POLLING: - if (self->state >= 0){ - return 0; - } - switch (self->state){ - case STATE_IOEXP_INIT: - return ERR_IOEXP_UNINIT; - case STATE_IOEXP_ABNORMAL: - return ERR_IOEXP_ABNORMAL; - default: - return ERR_IOEXP_NOSTATE; - } - break; - - default: - break; - } - SWPS_ERR("%s: Exception occurs. :%d \n", __func__, self->mode); - return ERR_IOEXP_UNEXCPT; -} - - -static int -_common_get_bit(struct ioexp_obj_s *self, - struct ioexp_bitmap_s *bitmap_obj_p, - char *func_mane){ - uint8_t buf; - int err_code; - - /* Check and get address */ - err_code = _common_check_by_mode(self); - if (err_code < 0){ - return err_code; - } - if (!bitmap_obj_p){ - SWPS_ERR("Layout config incorrect! :%d :%s\n", - self->ioexp_id, func_mane); - return ERR_IOEXP_BADCONF; - } - /* Get data form cache */ - buf = self->chip_data[bitmap_obj_p->chip_id].data[bitmap_obj_p->ioexp_voffset]; - return (int)(buf >> bitmap_obj_p->bit_shift & 0x01); -} - - -static int -_common_set_bit(struct ioexp_obj_s *self, - struct ioexp_bitmap_s *bitmap_obj_p, - int input_val, - char *func_mane){ - int err_code, target_offset; - uint8_t origin_byte; - uint8_t modify_byte; - - /* Check and get address */ - err_code = _common_check_by_mode(self); - if (err_code < 0){ - return err_code; - } - if (!bitmap_obj_p){ - SWPS_ERR("Layout config incorrect! :%d :%s\n", - self->ioexp_id, func_mane); - return ERR_IOEXP_BADCONF; - } - /* Prepare write date */ - origin_byte = self->chip_data[bitmap_obj_p->chip_id].data[bitmap_obj_p->ioexp_voffset]; - switch (input_val) { - case 0: - modify_byte = origin_byte; - SWP_BIT_CLEAR(modify_byte, bitmap_obj_p->bit_shift); - break; - case 1: - modify_byte = origin_byte; - SWP_BIT_SET(modify_byte, bitmap_obj_p->bit_shift); - break; - default: - SWPS_ERR("Input value incorrect! :%d :%d :%s\n", - input_val, self->ioexp_id, func_mane); - return ERR_IOEXP_BADINPUT; - } - /* Setup i2c client */ - target_offset = self->ioexp_map_p->map_addr[bitmap_obj_p->chip_id].write_offset[bitmap_obj_p->ioexp_voffset]; - /* Write byte to chip via I2C */ - err_code = i2c_smbus_write_byte_data(_get_i2c_client(self, bitmap_obj_p->chip_id), - target_offset, - modify_byte); - /* Update or bollback object */ - if (err_code < 0){ - self->chip_data[bitmap_obj_p->chip_id].data[bitmap_obj_p->ioexp_voffset] = origin_byte; - SWPS_ERR("I2C write fail! :%d :%d :%s :%d\n", - input_val, self->ioexp_id, func_mane, err_code); - return err_code; - } - self->chip_data[bitmap_obj_p->chip_id].data[bitmap_obj_p->ioexp_voffset] = modify_byte; - return 0; -} - - -/* ========== Object public functions ========== - */ -int -common_get_present(struct ioexp_obj_s *self, - int virt_offset){ - - int UNPLUG = 1; - int retval = ERR_IOEXP_UNEXCPT; - - retval = _common_get_bit(self, - &(self->ioexp_map_p->map_present[virt_offset]), - "common_get_present"); - if (retval < 0) { - /* [Note] - * => Transceiver object does not need to handle IOEXP layer issues. - */ - return UNPLUG; - } - return retval; -} - - -int -common_get_tx_fault(struct ioexp_obj_s *self, - int virt_offset){ - /* [Transmit Fault (Tx_Fault)] - * A catastrophic laser fault will activate the transmitter signal, - * TX_FAULT, and disable the laser. This signal is an open collector - * output (pull-up required on the host board). A low signal indicates - * normal laser operation and a high signal indicates a fault. The - * TX_FAULT will be latched high when a laser fault occurs and is - * cleared by toggling the TX_DISABLE input or power cycling the - * transceiver. The transmitter fault condition can also be monitored - * via the two-wire serial interface. - * (address A2, byte 110, bit 2). - * - * 0: Normal - * 1: Abnormal - */ - return _common_get_bit(self, - &(self->ioexp_map_p->map_tx_fault[virt_offset]), - "common_get_tx_fault"); -} - - -int -common_get_rxlos(struct ioexp_obj_s *self, - int virt_offset){ - /* [Receiver Loss of Signal (Rx_LOS)] - * The post-amplification IC also includes transition detection circuitry - * which monitors the ac level of incoming optical signals and provides a - * TTL/CMOS compatible status signal to the host (pin 8). An adequate optical - * input results in a low Rx_LOS output while a high Rx_LOS output indicates - * an unusable optical input. The Rx_LOS thresholds are factory set so that - * a high output indicates a definite optical fault has occurred. Rx_LOS can - * also be monitored via the two-wire serial interface - * (address A2h, byte 110, bit 1). - * - * 0: Normal - * 1: Abnormal - */ - return _common_get_bit(self, - &(self->ioexp_map_p->map_rxlos[virt_offset]), - "common_get_rxlos"); -} - - -int -common_get_tx_disable(struct ioexp_obj_s *self, - int virt_offset){ - - return _common_get_bit(self, - &(self->ioexp_map_p->map_tx_disable[virt_offset]), - "common_get_tx_disable"); -} - - -int -common_get_reset(struct ioexp_obj_s *self, - int virt_offset){ - - return _common_get_bit(self, - &(self->ioexp_map_p->map_reset[virt_offset]), - "common_get_reset"); -} - - -int -common_get_lpmod(struct ioexp_obj_s *self, - int virt_offset){ - - return _common_get_bit(self, - &(self->ioexp_map_p->map_lpmod[virt_offset]), - "common_get_lpmod"); -} - - -int -common_get_modsel(struct ioexp_obj_s *self, - int virt_offset){ - - return _common_get_bit(self, - &(self->ioexp_map_p->map_modsel[virt_offset]), - "common_get_modsel"); -} - - -int -common_get_hard_rs0(struct ioexp_obj_s *self, - int virt_offset){ - - return _common_get_bit(self, - &(self->ioexp_map_p->map_hard_rs0[virt_offset]), - "common_get_hard_rs0"); -} - - -int -common_get_hard_rs1(struct ioexp_obj_s *self, - int virt_offset){ - - return _common_get_bit(self, - &(self->ioexp_map_p->map_hard_rs1[virt_offset]), - "common_get_hard_rs1"); -} - - -int -common_set_tx_disable(struct ioexp_obj_s *self, - int virt_offset, - int input_val){ - - return _common_set_bit(self, - &(self->ioexp_map_p->map_tx_disable[virt_offset]), - input_val, - "common_set_tx_disable"); -} - - -int -common_set_reset(struct ioexp_obj_s *self, - int virt_offset, - int input_val){ - - return _common_set_bit(self, - &(self->ioexp_map_p->map_reset[virt_offset]), - input_val, - "common_set_reset"); -} - - -int -common_set_lpmod(struct ioexp_obj_s *self, - int virt_offset, - int input_val){ - - return _common_set_bit(self, - &(self->ioexp_map_p->map_lpmod[virt_offset]), - input_val, - "common_set_lpmod"); -} - - -int -common_set_modsel(struct ioexp_obj_s *self, - int virt_offset, - int input_val){ - - return _common_set_bit(self, - &(self->ioexp_map_p->map_modsel[virt_offset]), - input_val, - "common_set_modsel"); -} - - -int -common_set_hard_rs0(struct ioexp_obj_s *self, - int virt_offset, - int input_val){ - - return _common_set_bit(self, - &(self->ioexp_map_p->map_hard_rs0[virt_offset]), - input_val, - "common_set_hard_rs0"); -} - - -int -common_set_hard_rs1(struct ioexp_obj_s *self, - int virt_offset, - int input_val){ - - return _common_set_bit(self, - &(self->ioexp_map_p->map_hard_rs1[virt_offset]), - input_val, - "common_set_hard_rs1"); -} - - -int -ioexp_get_not_support(struct ioexp_obj_s *self, - int virt_offset){ - return ERR_IOEXP_NOTSUPPORT; -} - - -int -ioexp_set_not_support(struct ioexp_obj_s *self, - int virt_offset, - int input_val){ - return ERR_IOEXP_NOTSUPPORT; -} - - -int -fake_ioexp_init(struct ioexp_obj_s *self){ - return 1; -} - -int -fake_ioexp_update(struct ioexp_obj_s *self){ - return 1; -} - - -int -fake_update_func(struct ioexp_obj_s *self){ - return 1; -} - -int -fake_get_func(struct ioexp_obj_s *self, - int virt_offset){ - SWPS_WARN("Someone called fake_get_func\n"); - return -1; -} - -int -fake_set_func(struct ioexp_obj_s *self, - int virt_offset, - int input_val){ - SWPS_WARN("Someone called fake_set_func\n"); - return -1; -} - - -/* ========== Initial functions for IO Expander ========== - */ -int -common_ioexp_init(struct ioexp_obj_s *self) { - - int chip_id, offset, err_code; - struct ioexp_addr_s *addr_p; - - if (self->mode == IOEXP_MODE_DIRECT) { - goto update_common_ioexp_init; - } - if (!io_no_init) { /*normal init*/ - - /* Setup default value to each physical IO Expander */ - for (chip_id=0; chip_id<(self->ioexp_map_p->chip_amount); chip_id++){ - /* Get address mapping */ - addr_p = &(self->ioexp_map_p->map_addr[chip_id]); - if (!addr_p){ - SWPS_ERR("%s: IOEXP config incorrect! :%d \n", - __func__, chip_id); - return -1; - } - /* Setup default value */ - for (offset=0; offset<(self->ioexp_map_p->data_width); offset++){ - - /* [Desc] Skip the setup default value behavior - [Note] Setup default value = -1 if you don't want to write the value to IOEXP or CPLD - */ - if(addr_p->write_offset[offset] < 0){ - SWPS_DEBUG("skip a write_offset <%d>\n", addr_p->conf_offset[offset]); - continue; - } - err_code = i2c_smbus_write_byte_data(_get_i2c_client(self, chip_id), - addr_p->write_offset[offset], - addr_p->data_default[offset]); - if (err_code < 0){ - SWPS_ERR("%s: set default fail! :%d \n", - __func__, err_code); - return ERR_IOEXP_UNEXCPT; - } - } - } - } -update_common_ioexp_init: - /* Check and update info to object */ - err_code = self->update_all(self, 1, "common_ioexp_init"); - if (err_code < 0) { - SWPS_ERR("%s: update_all() fail! :%d \n", - __func__, err_code); - return ERR_IOEXP_UNEXCPT; - } - return 0; -} - - -/* ========== Object functions for Final State Machine ========== - */ -int -_is_channel_ready(struct ioexp_obj_s *self){ - - int chip_id = 0; - int byte_id = 0; - int getval = ERR_IOEXP_UNEXCPT; - int chkval = ERR_IOEXP_UNEXCPT; - char *emsg = "ERR"; - struct ioexp_addr_s *addr_p = NULL; - - for (chip_id=0; chip_id<(self->ioexp_map_p->chip_amount); chip_id++) { - addr_p = &(self->ioexp_map_p->map_addr[chip_id]); - if (!addr_p){ - emsg = "IOEXP config incorrect"; - goto err_is_channel_ready; - } - for (byte_id=0; byte_id<(self->ioexp_map_p->data_width); byte_id++) { - if (addr_p->conf_offset[byte_id] < 0) { - continue; - } - if ((addr_p->conf_default[byte_id]) != 0) { - goto go_is_channel_ready; - } - } - if (chip_id == ((self->ioexp_map_p->chip_amount) - 1)) { - SWPS_DEBUG("%s: no non-zero config", __func__); - break; - } - } - chip_id = 0; - byte_id = 0; - -go_is_channel_ready: - addr_p = &(self->ioexp_map_p->map_addr[chip_id]); - chkval = addr_p->conf_default[byte_id]; - getval = i2c_smbus_read_byte_data(_get_i2c_client(self, chip_id), - addr_p->conf_offset[byte_id]); - - SWPS_DEBUG("%s: target info :%d :%d :%d :%d :%d\n", - __func__, self->ioexp_id, chip_id, byte_id, chkval, getval); - - if ((getval >= 0) && (getval == chkval)) { - return 1; - } - return 0; - -err_is_channel_ready: - SWPS_ERR("%s: %s :%d :%d :%d :%d :%d\n", - __func__, emsg, self->ioexp_id, chip_id, byte_id, chkval, getval); - return ERR_IOEXP_UNEXCPT; -} - - -int -_ioexp_init_handler(struct ioexp_obj_s *self){ - - int return_val; - - switch (self->mode) { - case IOEXP_MODE_DIRECT: - return_val = self->init(self); - if (return_val < 0){ - self->state = STATE_IOEXP_ABNORMAL; - } else { - self->state = STATE_IOEXP_NORMAL; - } - return return_val; - - case IOEXP_MODE_POLLING: - /* Check system and channel is ready */ - if (self->state == STATE_IOEXP_INIT){ - if (!_is_channel_ready(self)){ - self->state = STATE_IOEXP_INIT; - SWPS_WARN("%s: IOEXP:%d channel not ready.\n", - __func__, self->ioexp_id); - return 0; - } - } - /* Execute initial callback */ - return_val = self->init(self); - if (return_val < 0){ - self->state = STATE_IOEXP_ABNORMAL; - } else { - self->state = STATE_IOEXP_NORMAL; - } - return return_val; - - default: - break; - } - SWPS_ERR("%s: exception occur :%d\n", __func__, self->mode); - return ERR_IOEXP_UNEXCPT; -} - - -int -common_ioexp_fsm_4_direct(struct ioexp_obj_s *self){ - - int result_val; - int show_err = 1; - char *func_mane = "common_ioexp_fsm_4_direct"; - - switch (self->state){ - case STATE_IOEXP_INIT: - result_val = _ioexp_init_handler(self); - /* Exception case: terminate initial procedure */ - if(result_val < 0){ - /* Initial fail */ - return result_val; - } - if(self->state == STATE_IOEXP_INIT){ - /* Keep in INIT state, and return error */ - return ERR_IOEXP_UNINIT; - } - /* Case: Initial done */ - return 0; - - case STATE_IOEXP_NORMAL: - result_val = self->update_all(self, show_err, func_mane); - if (result_val < 0){ - SWPS_INFO("%s: NORMAL -> ABNORMAL :%d\n", - __func__, result_val); - self->state = STATE_IOEXP_ABNORMAL; - return result_val; - } - self->state = STATE_IOEXP_NORMAL; - return 0; - - case STATE_IOEXP_ABNORMAL: - result_val = self->update_all(self, show_err, func_mane); - if (result_val < 0){ - self->state = STATE_IOEXP_ABNORMAL; - return result_val; - } - SWPS_DEBUG("%s: ABNORMAL -> NORMAL :%d\n", - __func__, result_val); - self->state = STATE_IOEXP_NORMAL; - return 0; - - default: - break; - } - SWPS_ERR("%s: Exception occurs :%d\n", - __func__, self->state); - return ERR_IOEXP_UNEXCPT; -} - - -int -common_ioexp_fsm_4_polling(struct ioexp_obj_s *self){ - - int result_val, i, show_e; - int fail_retry = 3; - char *func_name = "common_ioexp_fsm_4_polling"; - -#ifdef DEBUG_SWPS - show_e = 1; -#else - show_e = 0; -#endif - - switch (self->state){ - case STATE_IOEXP_INIT: - result_val = _ioexp_init_handler(self); - /* Exception case: terminate initial procedure */ - if(result_val < 0){ - /* Initial fail */ - return result_val; - } - /* Case: System (Channel) not ready */ - if(self->state == STATE_IOEXP_INIT){ - /* Keep in INIT state, wait and retry */ - return 0; - } - /* Case: Initial done */ - SWPS_INFO("IOEXP-%d: initial done. :%d\n", - self->ioexp_id, self->ioexp_type); - return result_val; - - case STATE_IOEXP_NORMAL: - /* Retry mechanism for case of i2c topology not stable */ - for (i=0; iupdate_all(self, show_e, func_name); - if (result_val >= 0) { - self->state = STATE_IOEXP_NORMAL; - return 0; - } - if (check_channel_tier_1() < 0) { - SWPS_INFO("%s: detect I2C crash :%d\n", - __func__, self->ioexp_id); - break; - } - SWPS_DEBUG("IOEXP-%d: unstable :%d\n", - self->ioexp_id, result_val); - } - SWPS_INFO("IOEXP-%d: NORMAL -> ABNORMAL :%d\n", - self->ioexp_id, result_val); - self->state = STATE_IOEXP_ABNORMAL; - return result_val; - - case STATE_IOEXP_ABNORMAL: - result_val = self->update_all(self, show_e, func_name); - if (result_val < 0){ - self->state = STATE_IOEXP_ABNORMAL; - return result_val; - } - SWPS_INFO("IOEXP-%d: ABNORMAL -> NORMAL :%d\n", - self->ioexp_id, result_val); - self->state = STATE_IOEXP_NORMAL; - return 0; - - default: - break; - } - SWPS_ERR("IOEXP-%d: Exception occurs :%d\n", - self->ioexp_id, self->state); - return ERR_IOEXP_UNEXCPT; -} - - -/* ========== Object private functions for check & update ========== - */ -int -common_ioexp_check(struct ioexp_obj_s *self){ - - int result; - - if (self->mode != IOEXP_MODE_POLLING){ - SWPS_ERR("%s: not polling mode :%d\n", - __func__, self->mode); - return ERR_IOEXP_NOTSUPPORT; - } - mutex_lock(&self->lock); - result = self->fsm_4_polling(self); - mutex_unlock(&self->lock); - return result; -} - - -/* ========== Functions for Factory pattern ========== - */ -static struct ioexp_map_s * -get_ioexp_map(int ioexp_type){ - switch (ioexp_type){ - case IOEXP_TYPE_MAGINOLIA_NAB: - return &ioexp_map_magnolia_nab; - case IOEXP_TYPE_MAGINOLIA_4AB: - return &ioexp_map_magnolia_4ab; - case IOEXP_TYPE_MAGINOLIA_7AB: - case IOEXP_TYPE_SPRUCE_7AB: - return &ioexp_map_magnolia_7ab; - case IOEXP_TYPE_REDWOOD_P01P08: - return &ioexp_map_redwood_p01p08_p17p24; - case IOEXP_TYPE_REDWOOD_P09P16: - return &ioexp_map_redwood_p09p16_p25p32; - case IOEXP_TYPE_HUDSON32IGA_P01P08: - return &ioexp_map_hudson32iga_p01p08_p17p24; - case IOEXP_TYPE_HUDSON32IGA_P09P16: - return &ioexp_map_hudson32iga_p09p16_p25p32; - case IOEXP_TYPE_CYPRESS_7ABC: - return &ioexp_map_cypress_7abc; - case IOEXP_TYPE_TAHOE_5A: - return &ioexp_map_tahoe_5a; - case IOEXP_TYPE_TAHOE_6ABC: - return &ioexp_map_tahoe_6abc; - case IOEXP_TYPE_SEQUOIA_NABC: - return &ioexp_map_sequoia_nabc; - case IOEXP_TYPE_LAVENDER_P65: - return &ioexp_map_lavender_p65; - case CPLD_TYPE_COTTONWOOD: - return &cpld_map_cottonwood; - case IOEXP_TYPE_MAPLE_0ABC: - case IOEXP_TYPE_CEDAR_0ABC: - return &ioexp_map_maple_0abc; - case IOEXP_TYPE_MAPLE_NABC: - return &ioexp_map_maple_nabc; - case IOEXP_TYPE_GULMOHAR_NABC: - return &ioexp_map_gulmohar_nabc; - case IOEXP_TYPE_GULMOHAR_7ABC: - return &ioexp_map_gulmohar_7abc; - case IOEXP_TYPE_GULMOHAR_2T_EVT1_NABC: - return &ioexp_map_gulmohar_2t_evt1_nabc; - case IOEXP_TYPE_GULMOHAR_2T_EVT1_1ABC: - return &ioexp_map_gulmohar_2t_evt1_1abc; - case IOEXP_TYPE_GULMOHAR_2T_EVT1_3ABC: - return &ioexp_map_gulmohar_2t_evt1_3abc; - case IOEXP_TYPE_GULMOHAR_2T_EVT1_7ABC: - return &ioexp_map_gulmohar_2t_evt1_7abc; - case IOEXP_TYPE_SFP_8P_LAYOUT_1: - return &ioexp_map_sfp_8p_layout_1; - case IOEXP_TYPE_QSFP_6P_LAYOUT_1: - return &ioexp_map_6p_qsfp_type_1; - default: - return NULL; - } -} - - -int -setup_ioexp_ssize_attr(struct ioexp_obj_s *self, - struct ioexp_map_s *ioexp_map_p, - int ioexp_id, - int ioexp_type, - int run_mode){ - switch (run_mode){ - case IOEXP_MODE_POLLING: /* Direct access device mode */ - case IOEXP_MODE_DIRECT: /* Polling mode, read from cache */ - self->mode = run_mode; - break; - default: - SWPS_ERR("%s: non-defined run_mode:%d\n", - __func__, run_mode); - self->mode = ERR_IOEXP_UNEXCPT; - return ERR_IOEXP_UNEXCPT; - } - /* Setup mapping structure */ - self->ioexp_map_p = kzalloc(sizeof(*ioexp_map_p), GFP_KERNEL); - if (!(self->ioexp_map_p)) { - SWPS_ERR("%s: kzalloc ioexp_map_p fail\n", __func__); - return -1; - } - memcpy(self->ioexp_map_p, ioexp_map_p, sizeof(*ioexp_map_p)); - /* Setup attributes */ - self->ioexp_id = ioexp_id; - self->ioexp_type = ioexp_type; - self->state = STATE_IOEXP_INIT; - mutex_init(&self->lock); - return 0; -} - - -static int -setup_addr_mapping(struct ioexp_obj_s *self, - struct ioexp_addr_s *addr_map_p, - int chip_amount){ - struct ioexp_addr_s *tmp_p; - if (!addr_map_p){ - SWPS_ERR("%s: map is null\n", __func__); - return -1; - } - tmp_p = kzalloc((sizeof(*addr_map_p) * chip_amount), GFP_KERNEL); - if (!tmp_p){ - SWPS_ERR("%s: kzalloc fail.\n", __func__); - return -1; - } - memcpy(tmp_p, addr_map_p, (sizeof(*addr_map_p) * chip_amount)); - self->ioexp_map_p->map_addr = tmp_p; - - return 0; -} - - -static int -setup_ioexp_public_cb(struct ioexp_obj_s *self, - int ioexp_type){ - - switch (ioexp_type){ - case IOEXP_TYPE_MAGINOLIA_NAB: - case IOEXP_TYPE_MAGINOLIA_4AB: - case CPLD_TYPE_COTTONWOOD: - self->get_present = common_get_present; - self->get_tx_fault = common_get_tx_fault; - self->get_rxlos = common_get_rxlos; - self->get_tx_disable = common_get_tx_disable; - self->get_reset = ioexp_get_not_support; - self->get_lpmod = ioexp_get_not_support; - self->get_modsel = ioexp_get_not_support; - self->get_hard_rs0 = ioexp_get_not_support; - self->get_hard_rs1 = ioexp_get_not_support; - self->set_tx_disable = common_set_tx_disable; - self->set_reset = ioexp_set_not_support; - self->set_lpmod = ioexp_set_not_support; - self->set_modsel = ioexp_set_not_support; - self->set_hard_rs0 = ioexp_set_not_support; - self->set_hard_rs1 = ioexp_set_not_support; - return 0; - - case IOEXP_TYPE_MAPLE_NABC: - case IOEXP_TYPE_GULMOHAR_NABC: - case IOEXP_TYPE_GULMOHAR_2T_EVT1_NABC: - case IOEXP_TYPE_GULMOHAR_2T_EVT1_1ABC: - case IOEXP_TYPE_GULMOHAR_2T_EVT1_3ABC: - case IOEXP_TYPE_SFP_8P_LAYOUT_1: - self->get_present = common_get_present; - self->get_tx_fault = common_get_tx_fault; - self->get_rxlos = common_get_rxlos; - self->get_tx_disable = common_get_tx_disable; - self->get_reset = ioexp_get_not_support; - self->get_lpmod = ioexp_get_not_support; - self->get_modsel = ioexp_get_not_support; - self->get_hard_rs0 = common_get_hard_rs0; - self->get_hard_rs1 = common_get_hard_rs1; - self->set_tx_disable = common_set_tx_disable; - self->set_reset = ioexp_set_not_support; - self->set_lpmod = ioexp_set_not_support; - self->set_modsel = ioexp_set_not_support; - self->set_hard_rs0 = common_set_hard_rs0; - self->set_hard_rs1 = common_set_hard_rs1; - return 0; - - case IOEXP_TYPE_MAGINOLIA_7AB: - case IOEXP_TYPE_SPRUCE_7AB: - case IOEXP_TYPE_REDWOOD_P01P08: - case IOEXP_TYPE_REDWOOD_P09P16: - case IOEXP_TYPE_HUDSON32IGA_P01P08: - case IOEXP_TYPE_HUDSON32IGA_P09P16: - case IOEXP_TYPE_CYPRESS_7ABC: - case IOEXP_TYPE_TAHOE_5A: - case IOEXP_TYPE_TAHOE_6ABC: - case IOEXP_TYPE_SEQUOIA_NABC: - case IOEXP_TYPE_LAVENDER_P65: - case IOEXP_TYPE_MAPLE_0ABC: - case IOEXP_TYPE_GULMOHAR_7ABC: - case IOEXP_TYPE_GULMOHAR_2T_EVT1_7ABC: - case IOEXP_TYPE_QSFP_6P_LAYOUT_1: - case IOEXP_TYPE_CEDAR_0ABC: - self->get_present = common_get_present; - self->get_tx_fault = ioexp_get_not_support; - self->get_rxlos = ioexp_get_not_support; - self->get_tx_disable = ioexp_get_not_support; - self->get_reset = common_get_reset; - self->get_lpmod = common_get_lpmod; - self->get_modsel = common_get_modsel; - self->get_hard_rs0 = ioexp_get_not_support; - self->get_hard_rs1 = ioexp_get_not_support; - self->set_tx_disable = ioexp_set_not_support; - self->set_reset = common_set_reset; - self->set_lpmod = common_set_lpmod; - self->set_modsel = common_set_modsel; - self->set_hard_rs0 = ioexp_set_not_support; - self->set_hard_rs1 = ioexp_set_not_support; - return 0; - - default: - SWPS_ERR("%s: type:%d incorrect!\n", __func__, ioexp_type); - break; - } - return ERR_IOEXP_UNEXCPT; -} - - -static int -setup_ioexp_private_cb(struct ioexp_obj_s *self, - int ioexp_type){ - - switch (ioexp_type){ - case IOEXP_TYPE_MAGINOLIA_NAB: - case IOEXP_TYPE_MAGINOLIA_4AB: - case IOEXP_TYPE_MAGINOLIA_7AB: - case IOEXP_TYPE_SPRUCE_7AB: - case IOEXP_TYPE_REDWOOD_P01P08: - case IOEXP_TYPE_REDWOOD_P09P16: - case IOEXP_TYPE_HUDSON32IGA_P01P08: - case IOEXP_TYPE_HUDSON32IGA_P09P16: - case IOEXP_TYPE_CYPRESS_7ABC: - case IOEXP_TYPE_TAHOE_5A: - case IOEXP_TYPE_TAHOE_6ABC: - case IOEXP_TYPE_SEQUOIA_NABC: - case IOEXP_TYPE_LAVENDER_P65: - case CPLD_TYPE_COTTONWOOD: - case IOEXP_TYPE_MAPLE_NABC: - case IOEXP_TYPE_MAPLE_0ABC: - case IOEXP_TYPE_GULMOHAR_NABC: - case IOEXP_TYPE_GULMOHAR_7ABC: - case IOEXP_TYPE_GULMOHAR_2T_EVT1_NABC: - case IOEXP_TYPE_GULMOHAR_2T_EVT1_1ABC: - case IOEXP_TYPE_GULMOHAR_2T_EVT1_3ABC: - case IOEXP_TYPE_GULMOHAR_2T_EVT1_7ABC: - case IOEXP_TYPE_SFP_8P_LAYOUT_1: - case IOEXP_TYPE_QSFP_6P_LAYOUT_1: - case IOEXP_TYPE_CEDAR_0ABC: - self->init = common_ioexp_init; - self->check = common_ioexp_check; - self->update_all = common_ioexp_update_all; - self->fsm_4_direct = common_ioexp_fsm_4_direct; - self->fsm_4_polling = common_ioexp_fsm_4_polling; - return 0; - - default: - SWPS_ERR("%s: type:%d incorrect!\n", __func__, ioexp_type); - break; - } - return ERR_IOEXP_UNEXCPT; -} - - -static int -setup_i2c_client_one(struct ioexp_obj_s *self, - int chip_id){ - - char *err_msg = "ERROR"; - struct i2c_adapter *adap = NULL; - struct i2c_client *client = NULL; - struct ioexp_i2c_s *i2c_obj_p = NULL; - struct ioexp_i2c_s *i2c_curr_p = NULL; - - int chan_id = self->ioexp_map_p->map_addr[chip_id].chan_id; - client = kzalloc(sizeof(*client), GFP_KERNEL); - if (!client){ - err_msg = "Can not kzalloc client!"; - goto err_ioexp_setup_i2c_1; - } - i2c_obj_p = kzalloc(sizeof(*i2c_obj_p), GFP_KERNEL); - if (!i2c_obj_p){ - err_msg = "Can not kzalloc i2c_obj_p!"; - goto err_ioexp_setup_i2c_2; - } - adap = i2c_get_adapter(chan_id); - if(!adap){ - err_msg = "Can not get adap!"; - goto err_ioexp_setup_i2c_3; - } - client->adapter = adap; - client->addr = self->ioexp_map_p->map_addr[chip_id].chip_addr; - i2c_obj_p->i2c_client_p = client; - i2c_obj_p->chip_id = chip_id; - i2c_obj_p->next = NULL; - if (!self->i2c_head_p){ - self->i2c_head_p = i2c_obj_p; - } else { - i2c_curr_p = self->i2c_head_p; - while (i2c_curr_p->next){ - i2c_curr_p = i2c_curr_p->next; - } - i2c_curr_p->next = i2c_obj_p; - } - return 0; - -err_ioexp_setup_i2c_3: - kfree(i2c_obj_p); -err_ioexp_setup_i2c_2: - kfree(client); -err_ioexp_setup_i2c_1: - SWPS_ERR("%s: %s :%d\n", __func__, err_msg, chan_id); - return -1; -} - - -static int -setup_i2c_client(struct ioexp_obj_s* self){ - - int result; - int chip_id = 0; - - for (chip_id=0; chip_id<(self->ioexp_map_p->chip_amount); chip_id++){ - result = setup_i2c_client_one(self, chip_id); - if (result < 0){ - SWPS_ERR("%s fail! :%d\n", __func__, chip_id); - return -1; - } - } - return 0; -} - - -static int -setup_ioexp_config(struct ioexp_obj_s *self) { - - int chip_id, offset, err_code; - struct ioexp_addr_s *addr_p; - if (io_no_init) { - - SWPS_INFO("io_no_init:%d \n", io_no_init); - return 0; - } - - for (chip_id=0; chip_id<(self->ioexp_map_p->chip_amount); chip_id++){ - addr_p = &(self->ioexp_map_p->map_addr[chip_id]); - if (!addr_p){ - SWPS_ERR("IOEXP config incorrect! :%d \n",chip_id); - return -1; - } - for (offset=0; offset<(self->ioexp_map_p->data_width); offset++){ - - /* [Desc] Skip the setup config value behavior - [Note] Setup config value = -1 if you don't want to write the value to IOEXP or CPLD - */ - if(addr_p->conf_offset[offset] < 0){ - SWPS_DEBUG("skip a config_offset <%d>\n", addr_p->conf_offset[offset]); - continue; - } - err_code = i2c_smbus_write_byte_data(_get_i2c_client(self, chip_id), - addr_p->conf_offset[offset], - addr_p->conf_default[offset]); - - if (err_code < 0){ - SWPS_INFO("%s: set conf fail! :%d \n", __func__, err_code); - return -2; - } - } - } - return 0; -} - - -struct ioexp_obj_s * -_create_ioexp_obj(int ioexp_id, - int ioexp_type, - struct ioexp_addr_s *addr_map_p, - int run_mode){ - - struct ioexp_map_s* ioexp_map_p; - struct ioexp_obj_s* result_p; - struct ioexp_i2c_s *i2c_curr_p; - struct ioexp_i2c_s *i2c_next_p; - - /* Get layout */ - ioexp_map_p = get_ioexp_map(ioexp_type); - if (!ioexp_map_p){ - SWPS_ERR("%s: Invalid ioexp_type\n", __func__); - goto err_create_ioexp_fail; - } - /* Prepare IOEXP object */ - result_p = kzalloc(sizeof(*result_p), GFP_KERNEL); - if (!result_p){ - SWPS_ERR("%s: kzalloc failure!\n", __func__); - goto err_create_ioexp_fail; - } - /* Prepare static size attributes */ - if (setup_ioexp_ssize_attr(result_p, - ioexp_map_p, - ioexp_id, - ioexp_type, - run_mode) < 0){ - goto err_create_ioexp_setup_attr_fail; - } - /* Prepare address mapping */ - if (setup_addr_mapping(result_p, addr_map_p, ioexp_map_p->chip_amount) < 0){ - goto err_create_ioexp_setup_attr_fail; - } - if (setup_i2c_client(result_p) < 0){ - goto err_create_ioexp_setup_i2c_fail; - } - /* Prepare call back functions of object */ - if (setup_ioexp_public_cb(result_p, ioexp_type) < 0){ - goto err_create_ioexp_setup_i2c_fail; - } - if (setup_ioexp_private_cb(result_p, ioexp_type) < 0){ - goto err_create_ioexp_setup_i2c_fail; - } - return result_p; - -err_create_ioexp_setup_i2c_fail: - i2c_curr_p = result_p->i2c_head_p; - i2c_next_p = result_p->i2c_head_p; - while (i2c_curr_p){ - i2c_next_p = i2c_curr_p->next; - if (i2c_curr_p->i2c_client_p) { - i2c_put_adapter(i2c_curr_p->i2c_client_p->adapter); - kfree(i2c_curr_p->i2c_client_p); - } - kfree(i2c_curr_p); - i2c_curr_p = i2c_next_p; - } -err_create_ioexp_setup_attr_fail: - kfree(result_p); -err_create_ioexp_fail: - SWPS_ERR("%s: fail! :%d :%d \n", - __func__, ioexp_id, ioexp_type); - return NULL; -} - - -int -create_ioexp_obj(int ioexp_id, - int ioexp_type, - struct ioexp_addr_s *addr_map_p, - int run_mode){ - - struct ioexp_obj_s *ioexp_p = NULL; - - ioexp_p = _create_ioexp_obj(ioexp_id, ioexp_type, - addr_map_p, run_mode); - if (!ioexp_p){ - return -1; - } - if (ioexp_head_p == NULL){ - ioexp_head_p = ioexp_p; - ioexp_tail_p = ioexp_p; - return 0; - } - ioexp_tail_p->next = ioexp_p; - ioexp_tail_p = ioexp_p; - return 0; -} -EXPORT_SYMBOL(create_ioexp_obj); - - -static int -_init_ioexp_obj(struct ioexp_obj_s* self) { - - char *err_msg = "ERR"; - char *func_name = "_init_ioexp_obj"; - - /* Setup IOEXP configure byte */ - if (setup_ioexp_config(self) < 0){ - err_msg = "setup_ioexp_config fail"; - goto err_init_ioexp_obj; - } - /* Setup default data */ - if (_ioexp_init_handler(self) < 0){ - err_msg = "_ioexp_init_handler fail"; - goto err_init_ioexp_obj; - } - /* Update all */ - if (self->state == STATE_IOEXP_NORMAL){ - if (self->update_all(self, 1, func_name) < 0){ - err_msg = "update_all() fail"; - goto err_init_ioexp_obj; - } - } - return 0; - -err_init_ioexp_obj: - SWPS_DEBUG("%s: %s\n", __func__, err_msg); - return -1; -} - - -int -init_ioexp_objs(void){ - /* Return value: - * 0: Success - * -1: Detect topology error - * -2: SWPS internal error - */ - struct ioexp_obj_s *curr_p = ioexp_head_p; - - if (!curr_p) { - SWPS_ERR("%s: ioexp_head_p is NULL\n", __func__); - return -2; - } - while (curr_p) { - if (_init_ioexp_obj(curr_p) < 0) { - SWPS_DEBUG("%s: _init_ioexp_obj() fail\n", __func__); - return -1; - } - curr_p = curr_p->next; - } - SWPS_DEBUG("%s: done.\n", __func__); - return 0; -} -EXPORT_SYMBOL(init_ioexp_objs); - - -void -clean_ioexp_objs(void){ - - struct ioexp_i2c_s *i2c_curr_p = NULL; - struct ioexp_i2c_s *i2c_next_p = NULL; - struct ioexp_obj_s *ioexp_next_p = NULL; - struct ioexp_obj_s *ioexp_curr_p = ioexp_head_p; - - if (ioexp_head_p == NULL){ - ioexp_tail_p = NULL; - return; - } - while(ioexp_curr_p){ - ioexp_next_p = ioexp_curr_p->next; - if (ioexp_curr_p->ioexp_map_p) { - if (ioexp_curr_p->ioexp_map_p->map_addr) { - kfree(ioexp_curr_p->ioexp_map_p->map_addr); - } - kfree(ioexp_curr_p->ioexp_map_p); - } - - i2c_curr_p = ioexp_curr_p->i2c_head_p; - while (i2c_curr_p) { - i2c_next_p = i2c_curr_p->next; - if (i2c_curr_p->i2c_client_p) { - i2c_put_adapter(i2c_curr_p->i2c_client_p->adapter); - kfree(i2c_curr_p->i2c_client_p); - } - kfree(i2c_curr_p); - i2c_curr_p = i2c_next_p; - } - kfree(ioexp_curr_p); - ioexp_curr_p = ioexp_next_p; - } - ioexp_tail_p = NULL; - SWPS_DEBUG("%s: done.\n", __func__); -} -EXPORT_SYMBOL(clean_ioexp_objs); - - -int -check_ioexp_objs(void){ - - struct ioexp_obj_s *ioexp_curr_p = ioexp_head_p; - - while (ioexp_curr_p){ - if ( (ioexp_curr_p->check(ioexp_curr_p)) < 0){ - SWPS_INFO("check IOEXP-%d fail! :%d\n", - ioexp_curr_p->ioexp_id, ioexp_curr_p->ioexp_type); - return -1; - } - ioexp_curr_p = ioexp_curr_p->next; - } - return 0; -} -EXPORT_SYMBOL(check_ioexp_objs); - - -struct ioexp_obj_s * -get_ioexp_obj(int ioexp_id){ - - struct ioexp_obj_s *result_p = NULL; - struct ioexp_obj_s *ioexp_curr_p = ioexp_head_p; - - while(ioexp_curr_p){ - if (ioexp_curr_p->ioexp_id == ioexp_id){ - result_p = ioexp_curr_p; - break; - } - ioexp_curr_p = ioexp_curr_p->next; - } - return result_p; -} -EXPORT_SYMBOL(get_ioexp_obj); - - -void -unlock_ioexp_all(void) { - - struct ioexp_obj_s *ioexp_curr_p = ioexp_head_p; - - while(ioexp_curr_p){ - mutex_unlock(&ioexp_curr_p->lock); - ioexp_curr_p = ioexp_curr_p->next; - } -} -EXPORT_SYMBOL(unlock_ioexp_all); - -int -lock_ioexp_all(void) { - - struct ioexp_obj_s *ioexp_curr_p = ioexp_head_p; - - while(ioexp_curr_p){ - mutex_lock(&ioexp_curr_p->lock); - ioexp_curr_p = ioexp_curr_p->next; - } - return 0; -} -EXPORT_SYMBOL(lock_ioexp_all); - - -int -check_channel_tier_1(void) { - - if ( (!_is_channel_ready(ioexp_head_p)) && - (!_is_channel_ready(ioexp_tail_p)) ){ - return -1; - } - return 0; -} -EXPORT_SYMBOL(check_channel_tier_1); - - -static int -_scan_channel_tier_1(int force, - int show_err) { - - struct ioexp_obj_s *ioexp_curr_p = ioexp_head_p; - int ready = 0; - - if (!ioexp_curr_p) { - goto err_scan_tier_1_channel; - } - while(ioexp_curr_p) { - ready = _is_channel_ready(ioexp_curr_p); - if ((!ready) && (!force)) { - goto err_scan_tier_1_channel; - } - ioexp_curr_p = ioexp_curr_p->next; - } - return 0; - -err_scan_tier_1_channel: - if (show_err) { - if (ioexp_curr_p) { - SWPS_INFO("%s: IOEXP-%d fail\n", __func__, ioexp_curr_p->ioexp_id); - } else { - SWPS_INFO("%s: IOEXP is null.\n", __func__); - } - } - return -1; -} - - -static int -_scan_channel_tier_1_single(void) { - - int ret = 0; - int chan_id = 0; - int fake_cid = 0; - int fake_offs = 0; - int fake_addr = 0; - struct i2c_adapter *adap = NULL; - struct i2c_client *client = NULL; - - if (ioexp_head_p->ioexp_id != ioexp_tail_p->ioexp_id) { - return 0; - } - /* Setup i2c_client */ - chan_id = ioexp_head_p->ioexp_map_p->map_addr[fake_cid].chan_id; - fake_addr = ioexp_head_p->ioexp_map_p->map_addr[fake_cid].chip_addr; - adap = i2c_get_adapter((chan_id + 1)); - if(!adap){ - SWPS_INFO("%s: Can not get adap!\n", __func__); - return 0; - } - client = kzalloc(sizeof(*client), GFP_KERNEL); - if (!client){ - SWPS_INFO("%s: Can not kzalloc client!\n", __func__); - return 0; - } - client->adapter = adap; - client->addr = fake_addr; - /* Fouce move ioexp ptr to next */ - ret = i2c_smbus_read_byte_data(client, fake_offs); - SWPS_DEBUG("%s: move ioexp_ptr done. :%d\n", __func__, ret); - kfree(client); - return 1; -} - - -int -resync_channel_tier_1(void) { - - char *emsg = "ERR"; - - if (!ioexp_head_p) { - emsg = "ioexp_head_p is NULL"; - goto err_resync_ioexp_status_1; - } - /* Run all */ - if (ioexp_head_p->ioexp_id == ioexp_tail_p->ioexp_id) { - _scan_channel_tier_1_single(); - } else { - _scan_channel_tier_1(1, 0); - } - /* Check all */ - if (_scan_channel_tier_1(0, 1) < 0) { - emsg = "resync tier-1 channel fail"; - goto err_resync_ioexp_status_1; - } - return 0; - -err_resync_ioexp_status_1: - SWPS_ERR("%s: %s\n", __func__, emsg); - return -1; -} -EXPORT_SYMBOL(resync_channel_tier_1); - - -/* For build single module using (Ex: ONL platform) */ -MODULE_LICENSE("GPL"); - - - diff --git a/packages/platforms/inventec/x86-64/d6332/modules/builds/src/io_expander.h b/packages/platforms/inventec/x86-64/d6332/modules/builds/src/io_expander.h deleted file mode 100644 index 43a8c290f..000000000 --- a/packages/platforms/inventec/x86-64/d6332/modules/builds/src/io_expander.h +++ /dev/null @@ -1,189 +0,0 @@ -#ifndef IO_EXPANDER_H -#define IO_EXPANDER_H - -#include - - -/* IOEXP type define (SFP series) */ -#define IOEXP_TYPE_MAGINOLIA_NAB (10101) -#define IOEXP_TYPE_MAGINOLIA_4AB (10102) -#define IOEXP_TYPE_MAPLE_NABC (10104) -#define IOEXP_TYPE_GULMOHAR_NABC (10105) -#define IOEXP_TYPE_GULMOHAR_2T_EVT1_NABC (10106) -#define IOEXP_TYPE_SFP_8P_LAYOUT_1 (10107) -#define IOEXP_TYPE_GULMOHAR_2T_EVT1_1ABC (10108) -#define IOEXP_TYPE_GULMOHAR_2T_EVT1_3ABC (10109) - -/* IOEXP type define (QSFP series) */ -#define IOEXP_TYPE_MAGINOLIA_7AB (10201) -#define IOEXP_TYPE_REDWOOD_P01P08 (10202) -#define IOEXP_TYPE_REDWOOD_P09P16 (10203) -#define IOEXP_TYPE_HUDSON32IGA_P01P08 (10204) -#define IOEXP_TYPE_HUDSON32IGA_P09P16 (10205) -#define IOEXP_TYPE_SPRUCE_7AB (10206) -#define IOEXP_TYPE_CYPRESS_7ABC (10207) -#define IOEXP_TYPE_TAHOE_5A (10208) -#define IOEXP_TYPE_TAHOE_6ABC (10209) -#define IOEXP_TYPE_SEQUOIA_NABC (10210) -#define IOEXP_TYPE_LAVENDER_P65 (10211) -#define IOEXP_TYPE_MAPLE_0ABC (10212) -#define IOEXP_TYPE_GULMOHAR_7ABC (10213) -#define IOEXP_TYPE_GULMOHAR_2T_EVT1_7ABC (10214) -#define IOEXP_TYPE_QSFP_6P_LAYOUT_1 (10215) -#define IOEXP_TYPE_CEDAR_0ABC (10216) - -/* CPLD type define */ -#define CPLD_TYPE_COTTONWOOD (10301) - -/* IOEXP mode define */ -#define IOEXP_MODE_POLLING (19000) -#define IOEXP_MODE_DIRECT (19001) - -/* IOEXP state define */ -#define STATE_IOEXP_NORMAL (0) -#define STATE_IOEXP_INIT (-1) -#define STATE_IOEXP_ABNORMAL (-2) - -/* IOEXP error code define */ -#define ERR_IOEXP_NOTSUPPORT (-100) -#define ERR_IOEXP_UNINIT (-101) -#define ERR_IOEXP_BADCONF (-102) -#define ERR_IOEXP_ABNORMAL (-103) -#define ERR_IOEXP_NOSTATE (-104) -#define ERR_IOEXP_BADINPUT (-105) -#define ERR_IOEXP_UNEXCPT (-199) - -#define SWPS_INFO(fmt, args...) printk( KERN_INFO "[SWPS] " fmt, ##args) -#define SWPS_WARN(fmt, args...) printk( KERN_WARNING "[SWPS] " fmt, ##args) -#define SWPS_ERR(fmt, args...) printk( KERN_ERR "[SWPS] " fmt, ##args) - -#ifdef DEBUG_SWPS -# define SWPS_DEBUG(fmt, args...) printk( KERN_DEBUG "[SWPS] " fmt, ##args) -#else -# define SWPS_DEBUG(fmt, args...) -#endif - -struct ioexp_addr_s { - int chan_id; - int chip_addr; - int read_offset[8]; - int write_offset[8]; - int conf_offset[8]; - uint8_t data_default[8]; - uint8_t conf_default[8]; -}; - -struct ioexp_i2c_s { - int chip_id; - struct i2c_client *i2c_client_p; - struct ioexp_i2c_s *next; -}; - - -struct ioexp_bitmap_s { - int chip_id; /* IOEXP chip id */ - int ioexp_voffset; /* IOEXP virtual offset */ - int bit_shift; -}; - -struct ioexp_map_s { - int chip_amount; /* Number of chips that IOEXP object content */ - int data_width; /* Number of (Read/Write/Config) bytes */ - struct ioexp_addr_s *map_addr; /* Chip address info */ - struct ioexp_bitmap_s map_present[10]; /* IOEXP for SFP / QSFP */ - struct ioexp_bitmap_s map_tx_disable[10]; /* IOEXP for SFP */ - struct ioexp_bitmap_s map_tx_fault[10]; /* IOEXP for SFP */ - struct ioexp_bitmap_s map_rxlos[10]; /* IOEXP for SFP */ - struct ioexp_bitmap_s map_reset[10]; /* IOEXP for QSFP */ - struct ioexp_bitmap_s map_lpmod[10]; /* IOEXP for QSFP */ - struct ioexp_bitmap_s map_modsel[10]; /* IOEXP for QSFP */ - struct ioexp_bitmap_s map_hard_rs0[10]; /* IOEXP for QSFP */ - struct ioexp_bitmap_s map_hard_rs1[10]; /* IOEXP for QSFP */ -}; - -struct ioexp_data_s { - uint8_t data[8]; -}; - -struct ioexp_obj_s { - - /* ============================ - * Object public property - * ============================ - */ - int ioexp_id; - int ioexp_type; - - /* ============================ - * Object private property - * ============================ - */ - struct ioexp_data_s chip_data[16]; /* Max: 8-ioexp in one virt-ioexp(ioexp_obj) */ - struct ioexp_map_s *ioexp_map_p; - struct ioexp_obj_s *next; - struct ioexp_i2c_s *i2c_head_p; - struct mutex lock; - int mode; - int state; - - /* =========================================== - * Object public functions - * =========================================== - */ - int (*get_present)(struct ioexp_obj_s *self, int virt_offset); - int (*get_tx_fault)(struct ioexp_obj_s *self, int virt_offset); - int (*get_rxlos)(struct ioexp_obj_s *self, int virt_offset); - int (*get_tx_disable)(struct ioexp_obj_s *self, int virt_offset); - int (*get_reset)(struct ioexp_obj_s *self, int virt_offset); - int (*get_lpmod)(struct ioexp_obj_s *self, int virt_offset); - int (*get_modsel)(struct ioexp_obj_s *self, int virt_offset); - int (*get_hard_rs0)(struct ioexp_obj_s *self, int virt_offset); - int (*get_hard_rs1)(struct ioexp_obj_s *self, int virt_offset); - int (*set_tx_disable)(struct ioexp_obj_s *self, int virt_offset, int input_val); - int (*set_reset)(struct ioexp_obj_s *self, int virt_offset, int input_val); - int (*set_lpmod)(struct ioexp_obj_s *self, int virt_offset, int input_val); - int (*set_modsel)(struct ioexp_obj_s *self, int virt_offset, int input_val); - int (*set_hard_rs0)(struct ioexp_obj_s *self, int virt_offset, int input_val); - int (*set_hard_rs1)(struct ioexp_obj_s *self, int virt_offset, int input_val); - - /* =========================================== - * Object private functions - * =========================================== - */ - int (*init)(struct ioexp_obj_s *self); - int (*check)(struct ioexp_obj_s *self); - int (*update_all)(struct ioexp_obj_s *self, int show_err, char *caller_name); - int (*fsm_4_direct)(struct ioexp_obj_s* self); - int (*fsm_4_polling)(struct ioexp_obj_s* self); -}; - - -struct ioexp_obj_s* get_ioexp_obj(int ioexp_id); -int create_ioexp_obj(int ioexp_id, - int ioexp_type, - struct ioexp_addr_s *addr_map_p, - int run_mode); -int init_ioexp_objs(void); -int check_ioexp_objs(void); -void clean_ioexp_objs(void); - -void unlock_ioexp_all(void); -int lock_ioexp_all(void); - -int check_channel_tier_1(void); -int resync_channel_tier_1(void); - -/* Macro for bit control */ -#define SWP_BIT_SET(byte_val,bit_shift) ((byte_val) |= (1<<(bit_shift))) -#define SWP_BIT_CLEAR(byte_val,bit_shift) ((byte_val) &= ~(1<<(bit_shift))) - - -#endif /* IO_EXPANDER_H */ - - - - - - - - diff --git a/packages/platforms/inventec/x86-64/d6332/modules/builds/src/pmbus.h b/packages/platforms/inventec/x86-64/d6332/modules/builds/src/pmbus.h deleted file mode 100644 index fa9beb3eb..000000000 --- a/packages/platforms/inventec/x86-64/d6332/modules/builds/src/pmbus.h +++ /dev/null @@ -1,387 +0,0 @@ -/* - * pmbus.h - Common defines and structures for PMBus devices - * - * Copyright (c) 2010, 2011 Ericsson AB. - * Copyright (c) 2012 Guenter Roeck - * - * 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. - */ - -#ifndef PMBUS_H -#define PMBUS_H - -/* - * Registers - */ -#define PMBUS_PAGE 0x00 -#define PMBUS_OPERATION 0x01 -#define PMBUS_ON_OFF_CONFIG 0x02 -#define PMBUS_CLEAR_FAULTS 0x03 -#define PMBUS_PHASE 0x04 - -#define PMBUS_CAPABILITY 0x19 -#define PMBUS_QUERY 0x1A - -#define PMBUS_VOUT_MODE 0x20 -#define PMBUS_VOUT_COMMAND 0x21 -#define PMBUS_VOUT_TRIM 0x22 -#define PMBUS_VOUT_CAL_OFFSET 0x23 -#define PMBUS_VOUT_MAX 0x24 -#define PMBUS_VOUT_MARGIN_HIGH 0x25 -#define PMBUS_VOUT_MARGIN_LOW 0x26 -#define PMBUS_VOUT_TRANSITION_RATE 0x27 -#define PMBUS_VOUT_DROOP 0x28 -#define PMBUS_VOUT_SCALE_LOOP 0x29 -#define PMBUS_VOUT_SCALE_MONITOR 0x2A - -#define PMBUS_COEFFICIENTS 0x30 -#define PMBUS_POUT_MAX 0x31 - -#define PMBUS_FAN_CONFIG_12 0x3A -#define PMBUS_FAN_COMMAND_1 0x3B -#define PMBUS_FAN_COMMAND_2 0x3C -#define PMBUS_FAN_CONFIG_34 0x3D -#define PMBUS_FAN_COMMAND_3 0x3E -#define PMBUS_FAN_COMMAND_4 0x3F - -#define PMBUS_VOUT_OV_FAULT_LIMIT 0x40 -#define PMBUS_VOUT_OV_FAULT_RESPONSE 0x41 -#define PMBUS_VOUT_OV_WARN_LIMIT 0x42 -#define PMBUS_VOUT_UV_WARN_LIMIT 0x43 -#define PMBUS_VOUT_UV_FAULT_LIMIT 0x44 -#define PMBUS_VOUT_UV_FAULT_RESPONSE 0x45 -#define PMBUS_IOUT_OC_FAULT_LIMIT 0x46 -#define PMBUS_IOUT_OC_FAULT_RESPONSE 0x47 -#define PMBUS_IOUT_OC_LV_FAULT_LIMIT 0x48 -#define PMBUS_IOUT_OC_LV_FAULT_RESPONSE 0x49 -#define PMBUS_IOUT_OC_WARN_LIMIT 0x4A -#define PMBUS_IOUT_UC_FAULT_LIMIT 0x4B -#define PMBUS_IOUT_UC_FAULT_RESPONSE 0x4C - -#define PMBUS_OT_FAULT_LIMIT 0x4F -#define PMBUS_OT_FAULT_RESPONSE 0x50 -#define PMBUS_OT_WARN_LIMIT 0x51 -#define PMBUS_UT_WARN_LIMIT 0x52 -#define PMBUS_UT_FAULT_LIMIT 0x53 -#define PMBUS_UT_FAULT_RESPONSE 0x54 -#define PMBUS_VIN_OV_FAULT_LIMIT 0x55 -#define PMBUS_VIN_OV_FAULT_RESPONSE 0x56 -#define PMBUS_VIN_OV_WARN_LIMIT 0x57 -#define PMBUS_VIN_UV_WARN_LIMIT 0x58 -#define PMBUS_VIN_UV_FAULT_LIMIT 0x59 - -#define PMBUS_IIN_OC_FAULT_LIMIT 0x5B -#define PMBUS_IIN_OC_WARN_LIMIT 0x5D - -#define PMBUS_POUT_OP_FAULT_LIMIT 0x68 -#define PMBUS_POUT_OP_WARN_LIMIT 0x6A -#define PMBUS_PIN_OP_WARN_LIMIT 0x6B - -#define PMBUS_STATUS_BYTE 0x78 -#define PMBUS_STATUS_WORD 0x79 -#define PMBUS_STATUS_VOUT 0x7A -#define PMBUS_STATUS_IOUT 0x7B -#define PMBUS_STATUS_INPUT 0x7C -#define PMBUS_STATUS_TEMPERATURE 0x7D -#define PMBUS_STATUS_CML 0x7E -#define PMBUS_STATUS_OTHER 0x7F -#define PMBUS_STATUS_MFR_SPECIFIC 0x80 -#define PMBUS_STATUS_FAN_12 0x81 -#define PMBUS_STATUS_FAN_34 0x82 - -#define PMBUS_READ_VIN 0x88 -#define PMBUS_READ_IIN 0x89 -#define PMBUS_READ_VCAP 0x8A -#define PMBUS_READ_VOUT 0x8B -#define PMBUS_READ_IOUT 0x8C -#define PMBUS_READ_TEMPERATURE_1 0x8D -#define PMBUS_READ_TEMPERATURE_2 0x8E -#define PMBUS_READ_TEMPERATURE_3 0x8F -#define PMBUS_READ_FAN_SPEED_1 0x90 -#define PMBUS_READ_FAN_SPEED_2 0x91 -#define PMBUS_READ_FAN_SPEED_3 0x92 -#define PMBUS_READ_FAN_SPEED_4 0x93 -#define PMBUS_READ_DUTY_CYCLE 0x94 -#define PMBUS_READ_FREQUENCY 0x95 -#define PMBUS_READ_POUT 0x96 -#define PMBUS_READ_PIN 0x97 - -#define PMBUS_REVISION 0x98 -#define PMBUS_MFR_ID 0x99 -#define PMBUS_MFR_MODEL 0x9A -#define PMBUS_MFR_REVISION 0x9B -#define PMBUS_MFR_LOCATION 0x9C -#define PMBUS_MFR_DATE 0x9D -#define PMBUS_MFR_SERIAL 0x9E - -/* - * Virtual registers. - * Useful to support attributes which are not supported by standard PMBus - * registers but exist as manufacturer specific registers on individual chips. - * Must be mapped to real registers in device specific code. - * - * Semantics: - * Virtual registers are all word size. - * READ registers are read-only; writes are either ignored or return an error. - * RESET registers are read/write. Reading reset registers returns zero - * (used for detection), writing any value causes the associated history to be - * reset. - * Virtual registers have to be handled in device specific driver code. Chip - * driver code returns non-negative register values if a virtual register is - * supported, or a negative error code if not. The chip driver may return - * -ENODATA or any other error code in this case, though an error code other - * than -ENODATA is handled more efficiently and thus preferred. Either case, - * the calling PMBus core code will abort if the chip driver returns an error - * code when reading or writing virtual registers. - */ -#define PMBUS_VIRT_BASE 0x100 -#define PMBUS_VIRT_READ_TEMP_AVG (PMBUS_VIRT_BASE + 0) -#define PMBUS_VIRT_READ_TEMP_MIN (PMBUS_VIRT_BASE + 1) -#define PMBUS_VIRT_READ_TEMP_MAX (PMBUS_VIRT_BASE + 2) -#define PMBUS_VIRT_RESET_TEMP_HISTORY (PMBUS_VIRT_BASE + 3) -#define PMBUS_VIRT_READ_VIN_AVG (PMBUS_VIRT_BASE + 4) -#define PMBUS_VIRT_READ_VIN_MIN (PMBUS_VIRT_BASE + 5) -#define PMBUS_VIRT_READ_VIN_MAX (PMBUS_VIRT_BASE + 6) -#define PMBUS_VIRT_RESET_VIN_HISTORY (PMBUS_VIRT_BASE + 7) -#define PMBUS_VIRT_READ_IIN_AVG (PMBUS_VIRT_BASE + 8) -#define PMBUS_VIRT_READ_IIN_MIN (PMBUS_VIRT_BASE + 9) -#define PMBUS_VIRT_READ_IIN_MAX (PMBUS_VIRT_BASE + 10) -#define PMBUS_VIRT_RESET_IIN_HISTORY (PMBUS_VIRT_BASE + 11) -#define PMBUS_VIRT_READ_PIN_AVG (PMBUS_VIRT_BASE + 12) -#define PMBUS_VIRT_READ_PIN_MAX (PMBUS_VIRT_BASE + 13) -#define PMBUS_VIRT_RESET_PIN_HISTORY (PMBUS_VIRT_BASE + 14) -#define PMBUS_VIRT_READ_POUT_AVG (PMBUS_VIRT_BASE + 15) -#define PMBUS_VIRT_READ_POUT_MAX (PMBUS_VIRT_BASE + 16) -#define PMBUS_VIRT_RESET_POUT_HISTORY (PMBUS_VIRT_BASE + 17) -#define PMBUS_VIRT_READ_VOUT_AVG (PMBUS_VIRT_BASE + 18) -#define PMBUS_VIRT_READ_VOUT_MIN (PMBUS_VIRT_BASE + 19) -#define PMBUS_VIRT_READ_VOUT_MAX (PMBUS_VIRT_BASE + 20) -#define PMBUS_VIRT_RESET_VOUT_HISTORY (PMBUS_VIRT_BASE + 21) -#define PMBUS_VIRT_READ_IOUT_AVG (PMBUS_VIRT_BASE + 22) -#define PMBUS_VIRT_READ_IOUT_MIN (PMBUS_VIRT_BASE + 23) -#define PMBUS_VIRT_READ_IOUT_MAX (PMBUS_VIRT_BASE + 24) -#define PMBUS_VIRT_RESET_IOUT_HISTORY (PMBUS_VIRT_BASE + 25) -#define PMBUS_VIRT_READ_TEMP2_AVG (PMBUS_VIRT_BASE + 26) -#define PMBUS_VIRT_READ_TEMP2_MIN (PMBUS_VIRT_BASE + 27) -#define PMBUS_VIRT_READ_TEMP2_MAX (PMBUS_VIRT_BASE + 28) -#define PMBUS_VIRT_RESET_TEMP2_HISTORY (PMBUS_VIRT_BASE + 29) - -#define PMBUS_VIRT_READ_VMON (PMBUS_VIRT_BASE + 30) -#define PMBUS_VIRT_VMON_UV_WARN_LIMIT (PMBUS_VIRT_BASE + 31) -#define PMBUS_VIRT_VMON_OV_WARN_LIMIT (PMBUS_VIRT_BASE + 32) -#define PMBUS_VIRT_VMON_UV_FAULT_LIMIT (PMBUS_VIRT_BASE + 33) -#define PMBUS_VIRT_VMON_OV_FAULT_LIMIT (PMBUS_VIRT_BASE + 34) -#define PMBUS_VIRT_STATUS_VMON (PMBUS_VIRT_BASE + 35) - -/* - * CAPABILITY - */ -#define PB_CAPABILITY_SMBALERT (1<<4) -#define PB_CAPABILITY_ERROR_CHECK (1<<7) - -/* - * VOUT_MODE - */ -#define PB_VOUT_MODE_MODE_MASK 0xe0 -#define PB_VOUT_MODE_PARAM_MASK 0x1f - -#define PB_VOUT_MODE_LINEAR 0x00 -#define PB_VOUT_MODE_VID 0x20 -#define PB_VOUT_MODE_DIRECT 0x40 - -/* - * Fan configuration - */ -#define PB_FAN_2_PULSE_MASK ((1 << 0) | (1 << 1)) -#define PB_FAN_2_RPM (1 << 2) -#define PB_FAN_2_INSTALLED (1 << 3) -#define PB_FAN_1_PULSE_MASK ((1 << 4) | (1 << 5)) -#define PB_FAN_1_RPM (1 << 6) -#define PB_FAN_1_INSTALLED (1 << 7) - -/* - * STATUS_BYTE, STATUS_WORD (lower) - */ -#define PB_STATUS_NONE_ABOVE (1<<0) -#define PB_STATUS_CML (1<<1) -#define PB_STATUS_TEMPERATURE (1<<2) -#define PB_STATUS_VIN_UV (1<<3) -#define PB_STATUS_IOUT_OC (1<<4) -#define PB_STATUS_VOUT_OV (1<<5) -#define PB_STATUS_OFF (1<<6) -#define PB_STATUS_BUSY (1<<7) - -/* - * STATUS_WORD (upper) - */ -#define PB_STATUS_UNKNOWN (1<<8) -#define PB_STATUS_OTHER (1<<9) -#define PB_STATUS_FANS (1<<10) -#define PB_STATUS_POWER_GOOD_N (1<<11) -#define PB_STATUS_WORD_MFR (1<<12) -#define PB_STATUS_INPUT (1<<13) -#define PB_STATUS_IOUT_POUT (1<<14) -#define PB_STATUS_VOUT (1<<15) - -/* - * STATUS_IOUT - */ -#define PB_POUT_OP_WARNING (1<<0) -#define PB_POUT_OP_FAULT (1<<1) -#define PB_POWER_LIMITING (1<<2) -#define PB_CURRENT_SHARE_FAULT (1<<3) -#define PB_IOUT_UC_FAULT (1<<4) -#define PB_IOUT_OC_WARNING (1<<5) -#define PB_IOUT_OC_LV_FAULT (1<<6) -#define PB_IOUT_OC_FAULT (1<<7) - -/* - * STATUS_VOUT, STATUS_INPUT - */ -#define PB_VOLTAGE_UV_FAULT (1<<4) -#define PB_VOLTAGE_UV_WARNING (1<<5) -#define PB_VOLTAGE_OV_WARNING (1<<6) -#define PB_VOLTAGE_OV_FAULT (1<<7) - -/* - * STATUS_INPUT - */ -#define PB_PIN_OP_WARNING (1<<0) -#define PB_IIN_OC_WARNING (1<<1) -#define PB_IIN_OC_FAULT (1<<2) - -/* - * STATUS_TEMPERATURE - */ -#define PB_TEMP_UT_FAULT (1<<4) -#define PB_TEMP_UT_WARNING (1<<5) -#define PB_TEMP_OT_WARNING (1<<6) -#define PB_TEMP_OT_FAULT (1<<7) - -/* - * STATUS_FAN - */ -#define PB_FAN_AIRFLOW_WARNING (1<<0) -#define PB_FAN_AIRFLOW_FAULT (1<<1) -#define PB_FAN_FAN2_SPEED_OVERRIDE (1<<2) -#define PB_FAN_FAN1_SPEED_OVERRIDE (1<<3) -#define PB_FAN_FAN2_WARNING (1<<4) -#define PB_FAN_FAN1_WARNING (1<<5) -#define PB_FAN_FAN2_FAULT (1<<6) -#define PB_FAN_FAN1_FAULT (1<<7) - -/* - * CML_FAULT_STATUS - */ -#define PB_CML_FAULT_OTHER_MEM_LOGIC (1<<0) -#define PB_CML_FAULT_OTHER_COMM (1<<1) -#define PB_CML_FAULT_PROCESSOR (1<<3) -#define PB_CML_FAULT_MEMORY (1<<4) -#define PB_CML_FAULT_PACKET_ERROR (1<<5) -#define PB_CML_FAULT_INVALID_DATA (1<<6) -#define PB_CML_FAULT_INVALID_COMMAND (1<<7) - -enum pmbus_sensor_classes { - PSC_VOLTAGE_IN = 0, - PSC_VOLTAGE_OUT, - PSC_CURRENT_IN, - PSC_CURRENT_OUT, - PSC_POWER, - PSC_TEMPERATURE, - PSC_FAN, - PSC_NUM_CLASSES /* Number of power sensor classes */ -}; - -#define PMBUS_PAGES 32 /* Per PMBus specification */ - -/* Functionality bit mask */ -#define PMBUS_HAVE_VIN (1 << 0) -#define PMBUS_HAVE_VCAP (1 << 1) -#define PMBUS_HAVE_VOUT (1 << 2) -#define PMBUS_HAVE_IIN (1 << 3) -#define PMBUS_HAVE_IOUT (1 << 4) -#define PMBUS_HAVE_PIN (1 << 5) -#define PMBUS_HAVE_POUT (1 << 6) -#define PMBUS_HAVE_FAN12 (1 << 7) -#define PMBUS_HAVE_FAN34 (1 << 8) -#define PMBUS_HAVE_TEMP (1 << 9) -#define PMBUS_HAVE_TEMP2 (1 << 10) -#define PMBUS_HAVE_TEMP3 (1 << 11) -#define PMBUS_HAVE_STATUS_VOUT (1 << 12) -#define PMBUS_HAVE_STATUS_IOUT (1 << 13) -#define PMBUS_HAVE_STATUS_INPUT (1 << 14) -#define PMBUS_HAVE_STATUS_TEMP (1 << 15) -#define PMBUS_HAVE_STATUS_FAN12 (1 << 16) -#define PMBUS_HAVE_STATUS_FAN34 (1 << 17) -#define PMBUS_HAVE_VMON (1 << 18) -#define PMBUS_HAVE_STATUS_VMON (1 << 19) - -enum pmbus_data_format { linear = 0, direct, vid }; - -struct pmbus_driver_info { - int pages; /* Total number of pages */ - enum pmbus_data_format format[PSC_NUM_CLASSES]; - /* - * Support one set of coefficients for each sensor type - * Used for chips providing data in direct mode. - */ - int m[PSC_NUM_CLASSES]; /* mantissa for direct data format */ - int b[PSC_NUM_CLASSES]; /* offset */ - int R[PSC_NUM_CLASSES]; /* exponent */ - - u32 func[PMBUS_PAGES]; /* Functionality, per page */ - /* - * The following functions map manufacturing specific register values - * to PMBus standard register values. Specify only if mapping is - * necessary. - * Functions return the register value (read) or zero (write) if - * successful. A return value of -ENODATA indicates that there is no - * manufacturer specific register, but that a standard PMBus register - * may exist. Any other negative return value indicates that the - * register does not exist, and that no attempt should be made to read - * the standard register. - */ - int (*read_byte_data)(struct i2c_client *client, int page, int reg); - int (*read_word_data)(struct i2c_client *client, int page, int reg); - int (*write_word_data)(struct i2c_client *client, int page, int reg, - u16 word); - int (*write_byte)(struct i2c_client *client, int page, u8 value); - /* - * The identify function determines supported PMBus functionality. - * This function is only necessary if a chip driver supports multiple - * chips, and the chip functionality is not pre-determined. - */ - int (*identify)(struct i2c_client *client, - struct pmbus_driver_info *info); -}; - -/* Function declarations */ - -void pmbus_clear_cache(struct i2c_client *client); -int pmbus_set_page(struct i2c_client *client, u8 page); -int pmbus_read_word_data(struct i2c_client *client, u8 page, u8 reg); -int pmbus_write_word_data(struct i2c_client *client, u8 page, u8 reg, u16 word); -int pmbus_read_byte_data(struct i2c_client *client, int page, u8 reg); -int pmbus_write_byte(struct i2c_client *client, int page, u8 value); -void pmbus_clear_faults(struct i2c_client *client); -bool pmbus_check_byte_register(struct i2c_client *client, int page, int reg); -bool pmbus_check_word_register(struct i2c_client *client, int page, int reg); -int pmbus_do_probe(struct i2c_client *client, const struct i2c_device_id *id, - struct pmbus_driver_info *info); -int pmbus_do_remove(struct i2c_client *client); -const struct pmbus_driver_info *pmbus_get_driver_info(struct i2c_client - *client); - -#endif /* PMBUS_H */ diff --git a/packages/platforms/inventec/x86-64/d6332/modules/builds/src/transceiver.c b/packages/platforms/inventec/x86-64/d6332/modules/builds/src/transceiver.c deleted file mode 100644 index 251ada569..000000000 --- a/packages/platforms/inventec/x86-64/d6332/modules/builds/src/transceiver.c +++ /dev/null @@ -1,8409 +0,0 @@ -#include -#include -#include -#include -#include "io_expander.h" -#include "transceiver.h" - -/* For build single module using (Ex: ONL platform) */ -#include -//#include -//#include - -extern int io_no_init; -/* ========== Register EEPROM address mapping ========== - */ -struct eeprom_map_s eeprom_map_sfp = { - .addr_br =0x50, .page_br =-1, .offset_br =12, .length_br =1, - .addr_cdr =-1, .page_cdr =-1, .offset_cdr =-1, .length_cdr =-1, - .addr_comp_rev =0x50, .page_comp_rev =-1, .offset_comp_rev =94, .length_comp_rev =1, - .addr_connector =0x50, .page_connector =-1, .offset_connector =2, .length_connector =1, - .addr_diag_type =0x50, .page_diag_type =-1, .offset_diag_type =92 , .length_diag_type =1, - .addr_extbr =-1, .page_extbr =-1, .offset_extbr =-1, .length_extbr =-1, - .addr_ext_id =0x50, .page_ext_id =-1, .offset_ext_id =1, .length_ext_id =1, - .addr_id =0x50, .page_id =-1, .offset_id =0, .length_id =1, - .addr_len_sm =0x50, .page_len_sm =-1, .offset_len_sm =15, .length_len_sm =1, - .addr_len_smf =0x50, .page_len_smf =-1, .offset_len_smf =14, .length_len_smf =1, - .addr_len_om1 =0x50, .page_len_om1 =-1, .offset_len_om1 =17, .length_len_om1 =1, - .addr_len_om2 =0x50, .page_len_om2 =-1, .offset_len_om2 =16, .length_len_om2 =1, - .addr_len_om3 =0x50, .page_len_om3 =-1, .offset_len_om3 =19, .length_len_om3 =1, - .addr_len_om4 =0x50, .page_len_om4 =-1, .offset_len_om4 =18, .length_len_om4 =1, - .addr_option =0x50, .page_option =-1, .offset_option =64, .length_option =2, - .addr_rate_id =0x50, .page_rate_id =-1, .offset_rate_id =13, .length_rate_id =1, - .addr_rx_am =-1, .page_rx_am =-1, .offset_rx_am =-1, .length_rx_am =-1, - .addr_rx_em =0x51, .page_rx_em =-1, .offset_rx_em =115, .length_rx_em =1, - .addr_rx_los =-1, .page_rx_los =-1, .offset_rx_los =-1, .length_rx_los =-1, - .addr_rx_power =0x51, .page_rx_power =-1, .offset_rx_power =104, .length_rx_power =2, - .addr_soft_rs0 =0x51, .page_soft_rs0 =-1, .offset_soft_rs0 =110, .length_soft_rs0 =1, - .addr_soft_rs1 =0x51, .page_soft_rs1 =-1, .offset_soft_rs1 =118, .length_soft_rs0 =1, - .addr_temp =0x51, .page_temp =-1, .offset_temp =96, .length_temp =2, - .addr_trancomp =0x50, .page_trancomp =-1, .offset_trancomp =3, .length_trancomp =8, - .addr_trancomp_ext =0x50, .page_trancomp_ext =-1, .offset_trancomp_ext =36, .length_trancomp_ext =1, - .addr_tx_bias =0x51, .page_tx_bias =-1, .offset_tx_bias =100, .length_tx_bias =2, - .addr_tx_disable =-1, .page_tx_disable =-1, .offset_tx_disable =-1, .length_tx_disable =-1, - .addr_tx_eq =0x51, .page_tx_eq =-1, .offset_tx_eq =114, .length_tx_eq =1, - .addr_tx_fault =-1, .page_tx_fault =-1, .offset_tx_fault =-1, .length_tx_fault =-1, - .addr_tx_power =0x51, .page_tx_power =-1, .offset_tx_power =102, .length_tx_power =2, - .addr_vendor_name =0x50, .page_vendor_name =-1, .offset_vendor_name =20, .length_vendor_name =16, - .addr_vendor_pn =0x50, .page_vendor_pn =-1, .offset_vendor_pn =40, .length_vendor_pn =16, - .addr_vendor_rev =0x50, .page_vendor_rev =-1, .offset_vendor_rev =56, .length_vendor_rev =4, - .addr_vendor_sn =0x50, .page_vendor_sn =-1, .offset_vendor_sn =68, .length_vendor_sn =16, - .addr_voltage =0x51, .page_voltage =-1, .offset_voltage =98, .length_voltage =2, - .addr_wavelength =0x50, .page_wavelength =-1, .offset_wavelength =60, .length_wavelength =2, -}; - -struct eeprom_map_s eeprom_map_qsfp = { - .addr_br =0x50, .page_br =0, .offset_br =140, .length_br =1, - .addr_cdr =-1, .page_cdr =-1, .offset_cdr =-1, .length_cdr =-1, - .addr_comp_rev =0x50, .page_comp_rev =-1, .offset_comp_rev =1, .length_comp_rev =1, - .addr_connector =0x50, .page_connector =0, .offset_connector =130, .length_connector =1, - .addr_diag_type =0x50, .page_diag_type =0, .offset_diag_type =220, .length_diag_type =1, - .addr_extbr =0x50, .page_extbr =0, .offset_extbr =222, .length_extbr =1, - .addr_ext_id =0x50, .page_ext_id =0, .offset_ext_id =129, .length_ext_id =1, - .addr_id =0x50, .page_id =0, .offset_id =128, .length_id =1, - .addr_len_sm =-1, .page_len_sm =-1, .offset_len_sm =-1, .length_len_sm =-1, - .addr_len_smf =0x50, .page_len_smf =0, .offset_len_smf =142, .length_len_smf =1, - .addr_len_om1 =0x50, .page_len_om1 =0, .offset_len_om1 =145, .length_len_om1 =1, - .addr_len_om2 =0x50, .page_len_om2 =0, .offset_len_om2 =144, .length_len_om2 =1, - .addr_len_om3 =0x50, .page_len_om3 =0, .offset_len_om3 =143, .length_len_om3 =1, - .addr_len_om4 =0x50, .page_len_om4 =0, .offset_len_om4 =146, .length_len_om4 =1, - .addr_option =0x50, .page_option =0, .offset_option =193, .length_option =3, - .addr_rate_id =-1, .page_rate_id =-1, .offset_rate_id =-1, .length_rate_id =-1, - .addr_rx_am =-1, .page_rx_am =-1, .offset_rx_am =-1, .length_rx_am =-1, - .addr_rx_em =-1, .page_rx_em =-1, .offset_rx_em =-1, .length_rx_em =-1, - .addr_rx_los =0x50, .page_rx_los =-1, .offset_rx_los =3, .length_rx_los =1, - .addr_rx_power =0x50, .page_rx_power =-1, .offset_rx_power =34, .length_rx_power =8, - .addr_soft_rs0 =-1, .page_soft_rs0 =-1, .offset_soft_rs0 =-1, .length_soft_rs0 =-1, - .addr_soft_rs1 =-1, .page_soft_rs1 =-1, .offset_soft_rs1 =-1, .length_soft_rs0 =-1, - .addr_temp =0x50, .page_temp =-1, .offset_temp =22, .length_temp =2, - .addr_trancomp =0x50, .page_trancomp =0, .offset_trancomp =131, .length_trancomp =8, - .addr_trancomp_ext =0x50, .page_trancomp_ext =0, .offset_trancomp_ext =192, .length_trancomp_ext =1, - .addr_tx_bias =0x50, .page_tx_bias =-1, .offset_tx_bias =42, .length_tx_bias =8, - .addr_tx_disable =0x50, .page_tx_disable =-1, .offset_tx_disable =86, .length_tx_disable =1, - .addr_tx_eq =-1, .page_tx_eq =-1, .offset_tx_eq =-1, .length_tx_eq =-1, - .addr_tx_fault =0x50, .page_tx_fault =-1, .offset_tx_fault =4, .length_tx_fault =1, - .addr_tx_power =0x50, .page_tx_power =-1, .offset_tx_power =50, .length_tx_power =8, - .addr_vendor_name =0x50, .page_vendor_name =0, .offset_vendor_name =148, .length_vendor_name =16, - .addr_vendor_pn =0x50, .page_vendor_pn =0, .offset_vendor_pn =168, .length_vendor_pn =16, - .addr_vendor_rev =0x50, .page_vendor_rev =0, .offset_vendor_rev =184, .length_vendor_rev =2, - .addr_vendor_sn =0x50, .page_vendor_sn =0, .offset_vendor_sn =196, .length_vendor_sn =16, - .addr_voltage =0x50, .page_voltage =-1, .offset_voltage =26, .length_voltage =2, - .addr_wavelength =0x50, .page_wavelength =0, .offset_wavelength =186, .length_wavelength =2, -}; - -struct eeprom_map_s eeprom_map_qsfp28 = { - .addr_br =0x50, .page_br =0, .offset_br =140, .length_br =1, - .addr_cdr =0x50, .page_cdr =-1, .offset_cdr =98, .length_cdr =1, - .addr_comp_rev =0x50, .page_comp_rev =-1, .offset_comp_rev =1, .length_comp_rev =1, - .addr_connector =0x50, .page_connector =0, .offset_connector =130, .length_connector =1, - .addr_diag_type =0x50, .page_diag_type =0, .offset_diag_type =220, .length_diag_type =1, - .addr_extbr =0x50, .page_extbr =0, .offset_extbr =222, .length_extbr =1, - .addr_ext_id =0x50, .page_ext_id =0, .offset_ext_id =129, .length_ext_id =1, - .addr_id =0x50, .page_id =0, .offset_id =128, .length_id =1, - .addr_len_sm =-1, .page_len_sm =-1, .offset_len_sm =-1, .length_len_sm =-1, - .addr_len_smf =0x50, .page_len_smf =0, .offset_len_smf =142, .length_len_smf =1, - .addr_len_om1 =0x50, .page_len_om1 =0, .offset_len_om1 =145, .length_len_om1 =1, - .addr_len_om2 =0x50, .page_len_om2 =0, .offset_len_om2 =144, .length_len_om2 =1, - .addr_len_om3 =0x50, .page_len_om3 =0, .offset_len_om3 =143, .length_len_om3 =1, - .addr_len_om4 =0x50, .page_len_om4 =0, .offset_len_om4 =146, .length_len_om4 =1, - .addr_option =0x50, .page_option =0, .offset_option =193, .length_option =3, - .addr_rate_id =-1, .page_rate_id =-1, .offset_rate_id =-1, .length_rate_id =-1, - .addr_rx_am =0x50, .page_rx_am =3, .offset_rx_am =238, .length_rx_am =2, - .addr_rx_em =0x50, .page_rx_em =3, .offset_rx_em =236, .length_rx_em =2, - .addr_rx_los =0x50, .page_rx_los =-1, .offset_rx_los =3, .length_rx_los =1, - .addr_rx_power =0x50, .page_rx_power =-1, .offset_rx_power =34, .length_rx_power =8, - .addr_soft_rs0 =-1, .page_soft_rs0 =-1, .offset_soft_rs0 =-1, .length_soft_rs0 =-1, - .addr_soft_rs1 =-1, .page_soft_rs1 =-1, .offset_soft_rs1 =-1, .length_soft_rs0 =-1, - .addr_temp =0x50, .page_temp =-1, .offset_temp =22, .length_temp =2, - .addr_trancomp =0x50, .page_trancomp =0, .offset_trancomp =131, .length_trancomp =8, - .addr_trancomp_ext =0x50, .page_trancomp_ext =0, .offset_trancomp_ext =192, .length_trancomp_ext =1, - .addr_tx_bias =0x50, .page_tx_bias =-1, .offset_tx_bias =42, .length_tx_bias =8, - .addr_tx_disable =0x50, .page_tx_disable =-1, .offset_tx_disable =86, .length_tx_disable =1, - .addr_tx_eq =0x50, .page_tx_eq =3, .offset_tx_eq =234, .length_tx_eq =2, - .addr_tx_fault =0x50, .page_tx_fault =-1, .offset_tx_fault =4, .length_tx_fault =1, - .addr_tx_power =0x50, .page_tx_power =-1, .offset_tx_power =50, .length_tx_power =8, - .addr_vendor_name =0x50, .page_vendor_name =0, .offset_vendor_name =148, .length_vendor_name =16, - .addr_vendor_pn =0x50, .page_vendor_pn =0, .offset_vendor_pn =168, .length_vendor_pn =16, - .addr_vendor_rev =0x50, .page_vendor_rev =0, .offset_vendor_rev =184, .length_vendor_rev =2, - .addr_vendor_sn =0x50, .page_vendor_sn =0, .offset_vendor_sn =196, .length_vendor_sn =16, - .addr_voltage =0x50, .page_voltage =-1, .offset_voltage =26, .length_voltage =2, - .addr_wavelength =0x50, .page_wavelength =0, .offset_wavelength =186, .length_wavelength =2, -}; - - -/* ========== Utility Functions ========== - */ -static int -get_bit(uint8_t origin_byte, int bit_shift) { - return (int)((origin_byte >> bit_shift) & 0x1); -} - -static int -transform_word_to_int(uint8_t hight_byte, - uint8_t low_byte) { - return ((((int)hight_byte) << 8) + (int)low_byte); -} - -void -alarm_msg_2_user(struct transvr_obj_s *self, - char *emsg) { - - SWPS_ERR("%s on %s.\n", emsg, self->swp_name); -} -EXPORT_SYMBOL(alarm_msg_2_user); - -/* ========== Private functions ========== - */ -static int -_reload_transvr_obj(struct transvr_obj_s *self,int new_type); - -static int -reload_transvr_obj(struct transvr_obj_s *self,int new_type); - -static int -_is_transvr_support_ctle(struct transvr_obj_s *self); - -static int -_transvr_init_handler(struct transvr_obj_s *self); - -int -_transvr_clean_handler(struct transvr_obj_s *self); - -int -_sfp_detect_class_by_1g_ethernet(struct transvr_obj_s* self); - - -void -lock_transvr_obj(struct transvr_obj_s *self) { - - mutex_lock(&self->lock); - self->curr_page = VAL_TRANSVR_PAGE_FREE; -} -EXPORT_SYMBOL(lock_transvr_obj); - - -void -unlock_transvr_obj(struct transvr_obj_s *self) { - - self->curr_page = VAL_TRANSVR_PAGE_FREE; - mutex_unlock(&self->lock); -} -EXPORT_SYMBOL(unlock_transvr_obj); - - -static int -_check_by_mode(struct transvr_obj_s *self, - int (*attr_update_func)(struct transvr_obj_s *self, int show_err), - char *caller_name){ - - int return_val = ERR_TRANSVR_UNEXCPT; - - switch (self->mode){ - case TRANSVR_MODE_POLLING: - switch (self->state){ - case STATE_TRANSVR_CONNECTED: - goto ok_check_by_mode_1; - case STATE_TRANSVR_NEW: - case STATE_TRANSVR_INIT: - return ERR_TRANSVR_UNINIT; - case STATE_TRANSVR_DISCONNECTED: - return ERR_TRANSVR_UNPLUGGED; - case STATE_TRANSVR_UNEXCEPTED: - return ERR_TRANSVR_ABNORMAL; - case STATE_TRANSVR_ISOLATED: - return ERR_TRNASVR_BE_ISOLATED; - default: - goto err_check_by_mode_1; - } - goto ok_check_by_mode_1; - - case TRANSVR_MODE_DIRECT: - return_val = self->fsm_4_direct(self, caller_name); - if (return_val < 0){ - return return_val; - } - goto ok_check_by_mode_1; - - default: - goto err_check_by_mode_1; - } - goto ok_check_by_mode_1; - -ok_check_by_mode_1: - return attr_update_func(self, 0); - -err_check_by_mode_1: - SWPS_INFO("_check_by_mode: mode:%d state:%d\n", self->mode, self->state); - return ERR_TRANSVR_UNEXCPT; -} - - -static void -_transvr_clean_retry(struct transvr_obj_s *self) { - self->retry = 0; -} - - -static int -_transvr_handle_retry(struct transvr_obj_s *self, int retry) { - /* Return: 0: keep retry - * -1: stop retry - */ - if (self->retry == 0) { - self->retry = retry; - } - self->retry -= 1; - if (self->retry <= 0) { - _transvr_clean_retry(self); - return -1; - } - return 0; -} - - -static int -_common_setup_page(struct transvr_obj_s *self, - int addr, - int page, - int offset, - int len, - int show_e) { - /* return: - * 0 : OK - * -1 : EEPROM settings incorrect - * -2 : I2C R/W failure - * -3 : Undefined case - */ - int retval = DEBUG_TRANSVR_INT_VAL; - char *emsg = DEBUG_TRANSVR_STR_VAL; - - /* Check */ - if ((addr < 0) || (offset < 0) || (len < 0)) { - emsg = "EEPROM settings incorrect"; - retval = -1; - goto err_common_setup_page; - } - /* Case1: continue access */ - if ((self->i2c_client_p->addr == addr) && - (self->curr_page == page)) { - return 0; - } - self->i2c_client_p->addr = addr; - /* Case2: select lower page */ - if (page == -1) { - self->curr_page = page; - return 0; - } - /* Case3: select upper page */ - if (page >= 0) { - goto upper_common_setup_page; - } - /* Unexpected case */ - show_e = 1; - emsg = "Unexpected case"; - retval = -3; - goto err_common_setup_page; - -upper_common_setup_page: - if (i2c_smbus_write_byte_data(self->i2c_client_p, - VAL_TRANSVR_PAGE_SELECT_OFFSET, - page) < 0) { - emsg = "I2C R/W failure"; - retval = -2; - goto err_common_setup_page; - } - self->curr_page = page; - mdelay(VAL_TRANSVR_PAGE_SELECT_DELAY); - return 0; - -err_common_setup_page: - if (show_e) { - SWPS_INFO("%s: %s", __func__, emsg); - SWPS_INFO("%s: :0x%02x :%d :%d :%d\n", - __func__, addr, page, offset, len); - } - return retval; -} - -/* -static int -_common_setup_password(struct transvr_obj_s *self, - int addr, - int page, - int offs, - uint8_t pwd[4], - int show_e) { - int i = 0; - int err = DEBUG_TRANSVR_INT_VAL; - char *emsg = DEBUG_TRANSVR_STR_VAL; - - err = _common_setup_page(self, addr, page, offs, 4, show_e); - if (err < 0){ - emsg = "setup EEPROM page fail"; - goto err_common_setup_password; - } - for (i=0; i<4; i++) { - err = i2c_smbus_write_byte_data(self->i2c_client_p, - (offs + i), - pwd[i]); - if (err < 0){ - emsg = "I2C R/W fail!"; - goto err_common_setup_password; - } - } - return 0; - -err_common_setup_password: - if (show_e) { - SWPS_INFO("%s: %s :%d\n", __func__, emsg, err); - } - return ERR_TRANSVR_UPDATE_FAIL; -} -*/ - -static int -_common_update_uint8_attr(struct transvr_obj_s *self, - int addr, - int page, - int offset, - int len, - uint8_t *buf, - char *caller, - int show_e){ - - int i; - int err = DEBUG_TRANSVR_INT_VAL; - char *emsg = DEBUG_TRANSVR_STR_VAL; - - err = _common_setup_page(self, addr, page, offset, len, show_e); - if (err < 0){ - emsg = "setup EEPROM page fail"; - goto err_common_update_uint8_attr; - } - for (i=0; ii2c_client_p, (offset + i)); - if (err < 0){ - emsg = "I2C R/W fail!"; - goto err_common_update_uint8_attr; - } - buf[i] = err; - } - return 0; - -err_common_update_uint8_attr: - if (show_e) { - SWPS_INFO("%s: %s :%s :%d\n", - __func__, emsg, caller, err); - } - buf[0] = DEBUG_TRANSVR_HEX_VAL; - return ERR_TRANSVR_UPDATE_FAIL; -} - - -static int -_common_update_int_attr(struct transvr_obj_s *self, - int addr, - int page, - int offset, - int len, - int *buf, - char *caller, - int show_e){ - - int i; - int err = DEBUG_TRANSVR_INT_VAL; - char *emsg = DEBUG_TRANSVR_STR_VAL; - - err = _common_setup_page(self, addr, page, offset, len, show_e); - if (err < 0){ - emsg = "setup EEPROM page fail"; - goto err_common_update_int_attr; - } - for (i=0; ii2c_client_p, (offset + i)); - if (err < 0){ - emsg = "I2C R/W fail!"; - goto err_common_update_int_attr; - } - buf[i] = (int)err; - } - return 0; - -err_common_update_int_attr: - if (show_e) { - SWPS_INFO("%s: %s :%s :%d\n", - __func__, emsg, caller, err); - } - buf[0] = DEBUG_TRANSVR_INT_VAL; - return ERR_TRANSVR_UPDATE_FAIL; -} - - -static int -_common_update_string_attr(struct transvr_obj_s *self, - int addr, - int page, - int offset, - int len, - char buf[], - char *caller, - int show_e){ - - int i; - int err = DEBUG_TRANSVR_INT_VAL; - char *emsg = DEBUG_TRANSVR_STR_VAL; - - err = _common_setup_page(self, addr, page, offset, len, show_e); - if (err < 0){ - emsg = "setup EEPROM page fail"; - goto err_common_update_string_attr; - } - for (i=0; ii2c_client_p, (offset + i)); - if (err < 0){ - emsg = "I2C R/W fail!"; - goto err_common_update_string_attr; - } - buf[i] = (char)err; - } - return 0; - -err_common_update_string_attr: - if (show_e) { - SWPS_INFO("%s: %s :%s :%d\n", - __func__, emsg, caller, err); - } - buf[0] = 'e'; - return ERR_TRANSVR_UPDATE_FAIL; -} - - -static int -_common_set_uint8_attr(struct transvr_obj_s *self, - int addr, - int page, - int offset, - uint8_t update, - uint8_t *buf, - char *caller, - int show_e){ - int len = 1; - int err = DEBUG_TRANSVR_INT_VAL; - char *emsg = DEBUG_TRANSVR_STR_VAL; - - if ((*buf) == update){ - return 0; - } - err = _common_setup_page(self, addr, page, offset, len, show_e); - if (err < 0){ - emsg = "setup EEPROM page fail"; - goto err_common_set_uint8_attr_1; - } - err = i2c_smbus_write_byte_data(self->i2c_client_p, - offset, - update); - if (err < 0){ - emsg = "I2C R/W fail!"; - goto err_common_set_uint8_attr_1; - } - (*buf) = update; - return 0; - -err_common_set_uint8_attr_1: - if (show_e) { - SWPS_INFO("%s: %s :%s :%d\n", - __func__, emsg, caller, err); - } - return ERR_TRANSVR_UPDATE_FAIL; -} - - -static int -_common_set_uint8_array(struct transvr_obj_s *self, - int addr, - int page, - int offs, - int len, - uint8_t update[], - uint8_t buf[], - char *caller, - int show_e){ - int i = 0; - int err = DEBUG_TRANSVR_INT_VAL; - char *emsg = DEBUG_TRANSVR_STR_VAL; - - err = _common_setup_page(self, addr, page, offs, len, show_e); - if (err < 0){ - emsg = "setup EEPROM page fail"; - goto err_common_set_uint8_attr_1; - } - for (i=0; ii2c_client_p, - (offs + i), - update[i]); - if (err < 0){ - emsg = "I2C R/W fail!"; - goto err_common_set_uint8_attr_1; - } - buf[i] = update[i]; - } - return 0; - -err_common_set_uint8_attr_1: - if (show_e) { - SWPS_INFO("%s: %s :%s :%d :%d\n", - __func__, emsg, caller, err, i); - } - return ERR_TRANSVR_UPDATE_FAIL; -} - - -static int -_common_update_attr_id(struct transvr_obj_s *self, - int show_err){ - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_id, - self->eeprom_map_p->page_id, - self->eeprom_map_p->offset_id, - self->eeprom_map_p->length_id, - &(self->id), - "_common_update_attr_id", - show_err); -} - - -static int -_common_update_attr_extended_id(struct transvr_obj_s *self, - int show_err){ - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_ext_id, - self->eeprom_map_p->page_ext_id, - self->eeprom_map_p->offset_ext_id, - self->eeprom_map_p->length_ext_id, - &(self->ext_id), - "_common_update_attr_extended_id", - show_err); -} - - -static int -_common_update_attr_connector(struct transvr_obj_s *self, - int show_err){ - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_connector, - self->eeprom_map_p->page_connector, - self->eeprom_map_p->offset_connector, - self->eeprom_map_p->length_connector, - &(self->connector), - "_common_update_attr_connector", - show_err); -} - - -static int -_common_update_attr_transvr_comp(struct transvr_obj_s *self, - int show_err){ - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_trancomp, - self->eeprom_map_p->page_trancomp, - self->eeprom_map_p->offset_trancomp, - self->eeprom_map_p->length_trancomp, - self->transvr_comp, - "_common_update_attr_transvr_comp", - show_err); -} - - -static int -_common_update_attr_transvr_comp_ext(struct transvr_obj_s *self, - int show_err){ - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_trancomp_ext, - self->eeprom_map_p->page_trancomp_ext, - self->eeprom_map_p->offset_trancomp_ext, - self->eeprom_map_p->length_trancomp_ext, - &(self->transvr_comp_ext), - "_common_update_attr_transvr_comp_ext", - show_err); -} - - -static int -_common_update_attr_vendor_name(struct transvr_obj_s *self, - int show_err){ - return _common_update_string_attr(self, - self->eeprom_map_p->addr_vendor_name, - self->eeprom_map_p->page_vendor_name, - self->eeprom_map_p->offset_vendor_name, - self->eeprom_map_p->length_vendor_name, - self->vendor_name, - "_common_update_attr_vendor_name", - show_err); -} - - -static int -_common_update_attr_vendor_pn(struct transvr_obj_s *self, - int show_err){ - return _common_update_string_attr(self, - self->eeprom_map_p->addr_vendor_pn, - self->eeprom_map_p->page_vendor_pn, - self->eeprom_map_p->offset_vendor_pn, - self->eeprom_map_p->length_vendor_pn, - self->vendor_pn, - "_common_update_attr_vendor_pn", - show_err); -} - - -static int -_common_update_attr_vendor_rev(struct transvr_obj_s *self, - int show_err){ - return _common_update_string_attr(self, - self->eeprom_map_p->addr_vendor_rev, - self->eeprom_map_p->page_vendor_rev, - self->eeprom_map_p->offset_vendor_rev, - self->eeprom_map_p->length_vendor_rev, - self->vendor_rev, - "_common_update_attr_vendor_rev", - show_err); -} - - -static int -_common_update_attr_vendor_sn(struct transvr_obj_s *self, - int show_err){ - return _common_update_string_attr(self, - self->eeprom_map_p->addr_vendor_sn, - self->eeprom_map_p->page_vendor_sn, - self->eeprom_map_p->offset_vendor_sn, - self->eeprom_map_p->length_vendor_sn, - self->vendor_sn, - "_common_update_attr_vendor_sn", - show_err); -} - - -static int -_common_update_attr_br(struct transvr_obj_s *self, - int show_err){ - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_br, - self->eeprom_map_p->page_br, - self->eeprom_map_p->offset_br, - self->eeprom_map_p->length_br, - &(self->br), - "_common_update_attr_br", - show_err); -} - - -static int -_common_update_attr_len_smf(struct transvr_obj_s *self, - int show_err){ - return _common_update_int_attr(self, - self->eeprom_map_p->addr_len_smf, - self->eeprom_map_p->page_len_smf, - self->eeprom_map_p->offset_len_smf, - self->eeprom_map_p->length_len_smf, - &(self->len_smf), - "_common_update_attr_len_smf", - show_err); -} - - -static int -_common_update_attr_len_om1(struct transvr_obj_s *self, - int show_err){ - return _common_update_int_attr(self, - self->eeprom_map_p->addr_len_om1, - self->eeprom_map_p->page_len_om1, - self->eeprom_map_p->offset_len_om1, - self->eeprom_map_p->length_len_om1, - &(self->len_om1), - "_common_update_attr_len_om1", - show_err); -} - -static int -_common_update_attr_len_om2(struct transvr_obj_s *self, - int show_err){ - return _common_update_int_attr(self, - self->eeprom_map_p->addr_len_om2, - self->eeprom_map_p->page_len_om2, - self->eeprom_map_p->offset_len_om2, - self->eeprom_map_p->length_len_om2, - &(self->len_om2), - "_common_update_attr_len_om2", - show_err); -} - -static int -_common_update_attr_len_om3(struct transvr_obj_s *self, - int show_err){ - return _common_update_int_attr(self, - self->eeprom_map_p->addr_len_om3, - self->eeprom_map_p->page_len_om3, - self->eeprom_map_p->offset_len_om3, - self->eeprom_map_p->length_len_om3, - &(self->len_om3), - "_common_update_attr_len_om3", - show_err); -} - - -static int -_common_update_attr_len_om4(struct transvr_obj_s *self, - int show_err){ - return _common_update_int_attr(self, - self->eeprom_map_p->addr_len_om4, - self->eeprom_map_p->page_len_om4, - self->eeprom_map_p->offset_len_om4, - self->eeprom_map_p->length_len_om4, - &(self->len_om4), - "_common_update_attr_len_om4", - show_err); -} - - -static int -_common_update_attr_option(struct transvr_obj_s *self, - int show_err){ - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_option, - self->eeprom_map_p->page_option, - self->eeprom_map_p->offset_option, - self->eeprom_map_p->length_option, - self->option, - "_common_update_attr_option", - show_err); -} - - -static int -_common_update_attr_comp_rev(struct transvr_obj_s *self, - int show_err){ - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_comp_rev, - self->eeprom_map_p->page_comp_rev, - self->eeprom_map_p->offset_comp_rev, - self->eeprom_map_p->length_comp_rev, - &(self->comp_rev), - "_common_update_attr_comp_rev", - show_err); -} - - -static int -_common_update_attr_diag_type(struct transvr_obj_s *self, - int show_err){ - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_diag_type, - self->eeprom_map_p->page_diag_type, - self->eeprom_map_p->offset_diag_type, - self->eeprom_map_p->length_diag_type, - &(self->diag_type), - "_common_update_attr_diag_type", - show_err); -} - - -static int -_common_update_attr_wavelength(struct transvr_obj_s *self, - int show_err){ - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_wavelength, - self->eeprom_map_p->page_wavelength, - self->eeprom_map_p->offset_wavelength, - self->eeprom_map_p->length_wavelength, - self->wavelength, - "_common_update_attr_wavelength", - show_err); -} - - -int -_common_get_option_value(struct transvr_obj_s *self, - int offset, - int bit_shift) { - /* SFP: - * - option[0] = A0h / 64 - * - option[1] = A0h / 65 - * QSFP: - * - option[0] = 00h / 193 - * - option[1] = 00h / 194 - * - option[2] = 00h / 195 - */ - return (self->option[offset] & (1 << bit_shift)); -} - - -static int -_sfp_update_attr_len_sm(struct transvr_obj_s *self, - int show_err){ - return _common_update_int_attr(self, - self->eeprom_map_p->addr_len_sm, - self->eeprom_map_p->page_len_sm, - self->eeprom_map_p->offset_len_sm, - self->eeprom_map_p->length_len_sm, - &(self->len_sm), - "_common_update_attr_len_sm", - show_err); -} - - -static int -_sfp_update_attr_rate_id(struct transvr_obj_s *self, - int show_err){ - return _common_update_int_attr(self, - self->eeprom_map_p->addr_rate_id, - self->eeprom_map_p->page_rate_id, - self->eeprom_map_p->offset_rate_id, - self->eeprom_map_p->length_rate_id, - &(self->rate_id), - "_sfp_update_attr_rate_id", - show_err); -} - - -static int -_sfp_update_attr_soft_rs0(struct transvr_obj_s *self, - int show_err){ - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_soft_rs0, - self->eeprom_map_p->page_soft_rs0, - self->eeprom_map_p->offset_soft_rs0, - self->eeprom_map_p->length_soft_rs0, - &(self->soft_rs0), - "_sfp_update_attr_soft_rs0", - show_err); -} - - -static int -_sfp_update_attr_soft_rs1(struct transvr_obj_s *self, - int show_err){ - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_soft_rs1, - self->eeprom_map_p->page_soft_rs1, - self->eeprom_map_p->offset_soft_rs1, - self->eeprom_map_p->length_soft_rs1, - &(self->soft_rs1), - "_sfp_update_attr_soft_rs1", - show_err); -} - - -int -_sfp_is_diag_support(struct transvr_obj_s *self){ - - uint8_t bit_mask = 0xC0; /* 1100 0000 */ - uint8_t en_val = 0x40; /* 0100 0000 */ - uint8_t checkval = (self->diag_type & bit_mask); - - if (checkval == en_val) { - return 1; - } - return 0; -} - - -static int -_sfp_update_attr_curr_temp(struct transvr_obj_s *self, - int show_err){ - - if (!(_sfp_is_diag_support(self))) { - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_temp, - self->eeprom_map_p->page_temp, - self->eeprom_map_p->offset_temp, - self->eeprom_map_p->length_temp, - self->curr_temp, - "_sfp_update_attr_curr_temp", - show_err); -} - - -static int -_sfp_update_attr_curr_voltage(struct transvr_obj_s *self, - int show_err){ - - if (!(_sfp_is_diag_support(self))) { - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_voltage, - self->eeprom_map_p->page_voltage, - self->eeprom_map_p->offset_voltage, - self->eeprom_map_p->length_voltage, - self->curr_voltage, - "_sfp_update_attr_curr_voltage", - show_err); -} - - -static int -_sfp_update_attr_curr_tx_bias(struct transvr_obj_s *self, - int show_err){ - - if (!(_sfp_is_diag_support(self))) { - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_tx_bias, - self->eeprom_map_p->page_tx_bias, - self->eeprom_map_p->offset_tx_bias, - self->eeprom_map_p->length_tx_bias, - self->curr_tx_bias, - "_sfp_update_attr_curr_tx_bias", - show_err); -} - - -static int -_sfp_update_attr_curr_tx_power(struct transvr_obj_s *self, - int show_err){ - - if (!(_sfp_is_diag_support(self))) { - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_tx_power, - self->eeprom_map_p->page_tx_power, - self->eeprom_map_p->offset_tx_power, - self->eeprom_map_p->length_tx_power, - self->curr_tx_power, - "_sfp_update_attr_curr_tx_power", - show_err); -} - - -static int -_sfp_update_attr_curr_rx_power(struct transvr_obj_s *self, - int show_err){ - - if (!(_sfp_is_diag_support(self))) { - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_rx_power, - self->eeprom_map_p->page_rx_power, - self->eeprom_map_p->offset_rx_power, - self->eeprom_map_p->length_rx_power, - self->curr_rx_power, - "_sfp_update_attr_curr_rx_power", - show_err); -} - - -static int -_sfp_update_attr_rx_em(struct transvr_obj_s *self, - int show_err){ - - if (!_is_transvr_support_ctle(self)) { - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_rx_em, - self->eeprom_map_p->page_rx_em, - self->eeprom_map_p->offset_rx_em, - self->eeprom_map_p->length_rx_em, - self->rx_em, - "_sfp_update_attr_rx_em", - show_err); -} - - -static int -_sfp_update_attr_tx_eq(struct transvr_obj_s *self, - int show_err){ - - if (!_is_transvr_support_ctle(self)) { - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_tx_eq, - self->eeprom_map_p->page_tx_eq, - self->eeprom_map_p->offset_tx_eq, - self->eeprom_map_p->length_tx_eq, - self->tx_eq, - "_sfp_update_attr_tx_eq", - show_err); -} - - -static int -_qsfp_update_attr_cdr(struct transvr_obj_s *self, - int show_err){ - if (self->type != TRANSVR_TYPE_QSFP_28){ - self->cdr = DEBUG_TRANSVR_HEX_VAL; - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_cdr, - self->eeprom_map_p->page_cdr, - self->eeprom_map_p->offset_cdr, - self->eeprom_map_p->length_cdr, - &(self->cdr), - "_common_update_attr_cdr", - show_err); -} - - -static int -_qsfg_update_attr_extbr(struct transvr_obj_s *self, - int show_err) { - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_extbr, - self->eeprom_map_p->page_extbr, - self->eeprom_map_p->offset_extbr, - self->eeprom_map_p->length_extbr, - &(self->extbr), - "_common_update_attr_extbr", - show_err); -} - - -static int -_qsfp_is_diag_support(struct transvr_obj_s *self, - int diag_type) { - /* Input Parm: diag_type - * => 1 : temperature - * => 2 : voltage - * => 3 : tx relate - * => 4 : rx relate - */ - uint8_t mask_b2 = 0x04; /* 0000 0100 */ - uint8_t mask_b3 = 0x08; /* 0000 1000 */ - - switch (diag_type) { - case 1: /* temperature */ - case 2: /* voltage */ - /* Direct access target, because of spec not defined */ - return 1; - case 3: - case 4: - /* [Note] - * Due to lot of transceiver vendor defined it not rigorously and - * consider of general support, we seem it as supported if there - * are bit-2 OR bit-3 defined by transceiver vendor. - */ - if ( ((self->diag_type & mask_b2) == mask_b2 ) || - ((self->diag_type & mask_b3) == mask_b3 ) ){ - return 1; - } - return 0; - default: - SWPS_INFO("%s: undefined diag_type:%d\n", - __func__, diag_type); - break; - } - return 0; -} - - -int -_qsfp_is_implement_tx_disable(struct transvr_obj_s *self) { - /* - * 00h / Byte-195 / Bit-4 - */ - int byte = 2; - int bit = 4; - return _common_get_option_value(self, byte, bit); -} - - -int -_qsfp_is_implement_tx_fault(struct transvr_obj_s *self) { - /* - * 00h / Byte-195 / Bit-3 - */ - int byte = 2; - int bit = 3; - return _common_get_option_value(self, byte, bit); -} - - -static int -_qsfp_update_attr_curr_temp(struct transvr_obj_s *self, - int show_err){ - int diag_type = 1; - - if (!(_qsfp_is_diag_support(self, diag_type))) { - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_temp, - self->eeprom_map_p->page_temp, - self->eeprom_map_p->offset_temp, - self->eeprom_map_p->length_temp, - self->curr_temp, - "_qsfp_update_attr_curr_temp", - show_err); -} - - -static int -_qsfp_update_attr_curr_voltage(struct transvr_obj_s *self, - int show_err){ - int diag_type = 2; - - if (!(_qsfp_is_diag_support(self, diag_type))) { - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_voltage, - self->eeprom_map_p->page_voltage, - self->eeprom_map_p->offset_voltage, - self->eeprom_map_p->length_voltage, - self->curr_voltage, - "_qsfp_update_attr_curr_voltage", - show_err); -} - - -static int -_qsfp_update_attr_curr_tx_bias(struct transvr_obj_s *self, - int show_err){ - int diag_type = 3; - - if (!(_qsfp_is_diag_support(self, diag_type))) { - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_tx_bias, - self->eeprom_map_p->page_tx_bias, - self->eeprom_map_p->offset_tx_bias, - self->eeprom_map_p->length_tx_bias, - self->curr_tx_bias, - "_qsfp_update_attr_curr_tx_bias", - show_err); -} - - -static int -_qsfp_update_attr_curr_tx_power(struct transvr_obj_s *self, - int show_err){ - int diag_type = 3; - - if (!(_qsfp_is_diag_support(self, diag_type))) { - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_tx_power, - self->eeprom_map_p->page_tx_power, - self->eeprom_map_p->offset_tx_power, - self->eeprom_map_p->length_tx_power, - self->curr_tx_power, - "_qsfp_update_attr_curr_tx_power", - show_err); -} - - -static int -_qsfp_update_attr_curr_rx_power(struct transvr_obj_s *self, - int show_err){ - int diag_type = 4; - - if (!(_qsfp_is_diag_support(self, diag_type))) { - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_rx_power, - self->eeprom_map_p->page_rx_power, - self->eeprom_map_p->offset_rx_power, - self->eeprom_map_p->length_rx_power, - self->curr_rx_power, - "_qsfp_update_attr_curr_rx_power", - show_err); -} - - -static int -_qsfp_update_attr_soft_rx_los(struct transvr_obj_s *self, - int show_err){ - - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_rx_los, - self->eeprom_map_p->page_rx_los, - self->eeprom_map_p->offset_rx_los, - self->eeprom_map_p->length_rx_los, - &(self->rx_los), - "_qsfp_update_attr_soft_rx_los", - show_err); -} - - -static int -_qsfp_update_attr_soft_tx_disable(struct transvr_obj_s *self, - int show_err){ - - if (!_qsfp_is_implement_tx_disable(self)) { - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_tx_disable, - self->eeprom_map_p->page_tx_disable, - self->eeprom_map_p->offset_tx_disable, - self->eeprom_map_p->length_tx_disable, - &(self->tx_disable), - "_qsfp_update_attr_soft_tx_disable", - show_err); -} - - -static int -_qsfp_update_attr_soft_tx_fault(struct transvr_obj_s *self, - int show_err){ - - if (!_qsfp_is_implement_tx_fault(self)) { - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_tx_fault, - self->eeprom_map_p->page_tx_fault, - self->eeprom_map_p->offset_tx_fault, - self->eeprom_map_p->length_tx_fault, - &(self->tx_fault), - "_qsfp_update_attr_soft_tx_fault", - show_err); -} - - -static int -_qsfp_update_attr_tx_eq(struct transvr_obj_s *self, - int show_err){ - - if (!_is_transvr_support_ctle(self)) { - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_tx_eq, - self->eeprom_map_p->page_tx_eq, - self->eeprom_map_p->offset_tx_eq, - self->eeprom_map_p->length_tx_eq, - self->tx_eq, - "_qsfp_update_attr_tx_eq", - show_err); -} - - -static int -_qsfp_update_attr_rx_am(struct transvr_obj_s *self, - int show_err){ - - if (!_is_transvr_support_ctle(self)) { - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_rx_am, - self->eeprom_map_p->page_rx_am, - self->eeprom_map_p->offset_rx_am, - self->eeprom_map_p->length_rx_am, - self->rx_am, - "_qsfp_update_attr_rx_am", - show_err); -} - - -static int -_qsfp_update_attr_rx_em(struct transvr_obj_s *self, - int show_err){ - - if (!_is_transvr_support_ctle(self)) { - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_rx_em, - self->eeprom_map_p->page_rx_em, - self->eeprom_map_p->offset_rx_em, - self->eeprom_map_p->length_rx_em, - self->rx_em, - "_qsfp_update_attr_rx_em", - show_err); -} - - -int -_common_update_attr_all(struct transvr_obj_s *self, - int show_err){ - - char *err_str = "err"; - - if (_common_update_attr_id(self, show_err) < 0) { - err_str = "_common_update_attr_id"; - goto err_common_update_attr_all; - } - if (_common_update_attr_extended_id(self, show_err) < 0) { - err_str = "_common_update_attr_extended_id"; - goto err_common_update_attr_all; - } - if (_common_update_attr_connector(self, show_err) < 0) { - err_str = "_common_update_attr_connector"; - goto err_common_update_attr_all; - } - if (_common_update_attr_transvr_comp(self, show_err) < 0) { - err_str = "_common_update_attr_transvr_comp"; - goto err_common_update_attr_all; - } - if (_common_update_attr_transvr_comp_ext(self, show_err) < 0) { - err_str = "_common_update_attr_transvr_comp_ext"; - goto err_common_update_attr_all; - } - if (_common_update_attr_vendor_name(self, show_err) < 0) { - err_str = "_common_update_attr_vendor_name"; - goto err_common_update_attr_all; - } - if (_common_update_attr_vendor_pn(self, show_err) < 0) { - err_str = "_common_update_attr_vendor_pn"; - goto err_common_update_attr_all; - } - if (_common_update_attr_vendor_rev(self, show_err) < 0) { - err_str = "_common_update_attr_vendor_rev"; - goto err_common_update_attr_all; - } - if (_common_update_attr_vendor_sn(self, show_err) < 0) { - err_str = "_common_update_attr_vendor_sn"; - goto err_common_update_attr_all; - } - if (_common_update_attr_br(self, show_err) < 0) { - err_str = "_common_update_attr_br"; - goto err_common_update_attr_all; - } - if (_common_update_attr_len_smf(self, show_err) < 0) { - err_str = "_common_update_attr_len_smf"; - goto err_common_update_attr_all; - } - if (_common_update_attr_len_om1(self, show_err) < 0) { - err_str = "_common_update_attr_len_om1"; - goto err_common_update_attr_all; - } - if (_common_update_attr_len_om2(self, show_err) < 0) { - err_str = "_common_update_attr_len_om2"; - goto err_common_update_attr_all; - } - if (_common_update_attr_len_om3(self, show_err) < 0) { - err_str = "_common_update_attr_len_om3"; - goto err_common_update_attr_all; - } - if (_common_update_attr_len_om4(self, show_err) < 0) { - err_str = "_common_update_attr_len_om4"; - goto err_common_update_attr_all; - } - if (_common_update_attr_option(self, show_err) < 0) { - err_str = "_common_update_attr_option"; - goto err_common_update_attr_all; - } - if (_common_update_attr_comp_rev(self, show_err) < 0) { - err_str = "_common_update_attr_comp_rev"; - goto err_common_update_attr_all; - } - if (_common_update_attr_diag_type(self, show_err) < 0) { - err_str = "_common_update_attr_diag_type"; - goto err_common_update_attr_all; - } - if (_common_update_attr_wavelength(self, show_err) < 0) { - err_str = "_common_update_attr_wavelength"; - goto err_common_update_attr_all; - } - return 0; - -err_common_update_attr_all: - if (show_err){ - SWPS_INFO("%s: fail at:%s :%s\n", __func__, err_str, self->swp_name); - } - return -1; -} - - -int -_sfp_update_attr_all(struct transvr_obj_s *self, - int show_err){ - - char *err_str = DEBUG_TRANSVR_STR_VAL; - - if (_common_update_attr_all(self, show_err) < 0){ - err_str = "_common_update_attr_all"; - goto err_sfp_update_attr_all; - } - if (_sfp_update_attr_len_sm(self, show_err) < 0) { - err_str = "_sfp_update_attr_len_sm"; - goto err_sfp_update_attr_all; - } - if (_sfp_update_attr_rate_id(self, show_err) < 0) { - err_str = "_sfp_update_attr_rate_id"; - goto err_sfp_update_attr_all; - } - if ((self->rate_id) > 0) { - if (_sfp_update_attr_soft_rs0(self, show_err) < 0) { - err_str = "_sfp_update_attr_soft_rs0"; - goto err_sfp_update_attr_all; - } - if (_sfp_update_attr_soft_rs1(self, show_err) < 0) { - err_str = "_sfp_update_attr_soft_rs1"; - goto err_sfp_update_attr_all; - } - } - return 0; - -err_sfp_update_attr_all: - if (show_err){ - SWPS_INFO("%s: fail at:%s :%s\n", __func__, err_str, self->swp_name); - } - return -1; -} - - -int -_qsfp_update_attr_all(struct transvr_obj_s *self, - int show_err){ - - char *err_str = DEBUG_TRANSVR_STR_VAL; - - if (_common_update_attr_all(self, show_err) < 0){ - err_str = "_common_update_attr_all"; - goto err_qsfp_update_attr_all; - } - if (_qsfg_update_attr_extbr(self, show_err) < 0) { - err_str = "_qsfg_update_attr_extbr"; - goto err_qsfp_update_attr_all; - } - if (self->type == TRANSVR_TYPE_QSFP_28) { - if (_qsfp_update_attr_cdr(self, 1) < 0) { - err_str = "_qsfp_update_attr_cdr"; - goto err_qsfp_update_attr_all; - } - } - return 0; - -err_qsfp_update_attr_all: - if (show_err){ - SWPS_INFO("%s: fail at:%s :%s\n", __func__, err_str, self->swp_name); - } - return -1; -} - - -/* ========== Object functions for common type ========== - */ -int -_common_count_temp(uint8_t high_byte, - uint8_t low_byte, - char *buf_p) { - int sign = 0; - int high = 0; - int low = 0; - int lmax = 8; - - /* Count high */ - sign = get_bit(high_byte,7); - SWP_BIT_CLEAR(high_byte, 7); - high = (int)high_byte; - if (sign == 1) { - high = 0 - high; - } - /* Count low */ - low = (get_bit(low_byte, 7) * 500); - low += (get_bit(low_byte, 6) * 250); - low += (get_bit(low_byte, 5) * 125); - low += (get_bit(low_byte, 4) * 62); - low = (low / 100); - /* Integrate High and Low */ - return snprintf(buf_p, lmax, "%d.%d\n", high, low); -} - - -int -_common_count_voltage(uint8_t high_byte, - uint8_t low_byte, - char *buf_p) { - /* [Note]: - * Internally measured transceiver supply voltage. Represented - * as a 16 bit unsigned integer with the voltage defined as the - * full 16 bit value (0-65535) with LSB equal to 100 uVolt, - * yielding a total range of 0 to +6.55 Volts. Practical - * considerations to be defined by transceiver manufacturer will - * tend to limit the actual bounds of the supply voltage measurement. - * Accuracy is vendor specific but must be better than 3% of the - * manufacturer's nominal value over specified operating temperature - * and voltage. Note that in some transceivers, transmitter supply - * voltage and receiver supply voltage are isolated. In that case, - * only one supply is monitored. Refer to the device specification - * for more detail. - */ - int total = 0; - int lmax = 8; - int val_i = 0; - int val_f = 0; - /* unit: 100 uV (1mV=1000uV) */ - total = transform_word_to_int(high_byte, low_byte); - val_i = ((total/10) / 1000); - val_f = ((total/10) - (val_i*1000)); - /* Return Unit: 1 Volt */ - return snprintf(buf_p, lmax, "%d.%03d\n", val_i, val_f); -} - - -int -_common_count_tx_bias(uint8_t high_byte, - uint8_t low_byte, - char *buf_p) { - /* [Note] - * Measured TX bias current in uA. Represented as a 16 bit unsigned - * integer with the current defined as the full 16 bit value (0-65535) - * with LSB equal to 2 uA, yielding a total range of 0 to 131 mA. - * Accuracy is vendor specific but must be better than 10% of the - * manufacturer's nominal value over specified operating temperature - * and voltage. - */ - int total = 0; - int lmax = 8; - int val_i = 0; - int val_f = 0; - /* unit: 2 uA (1mA=1000uA) */ - total = transform_word_to_int(high_byte, low_byte); - val_i = ((total*2) / 1000); - val_f = (((total*2) - (val_i*1000)) / 100); - /* Return Unit: 1 mA */ - return snprintf(buf_p, lmax, "%d.%01d\n", val_i, val_f); -} - - -int -_common_count_tx_power(uint8_t high_byte, - uint8_t low_byte, - char *buf_p) { - /* [Note] - * Measured TX output power in mW. Represented as a 16 bit unsigned - * integer with the power defined as the full 16 bit value (0-65535) - * with LSB equal to 0.1 uW, yielding a total range of 0 to 6.5535 mW - * (~ -40 to +8.2 dBm). Data is assumed to be based on measurement of - * laser monitor photodiode current. It is factory calibrated to absolute - * units using the most representative fiber output type. Accuracy is - * vendor specific but must be better than 3dB over specified temperature - * and voltage. Data is not valid when the transmitter is disabled. - */ - int total = 0; - int lmax = 8; - int val_i = 0; - int val_f = 0; - /* unit: 0.1 uW (1mW=1000uW) */ - total = transform_word_to_int(high_byte, low_byte); - val_i = ((total/10) / 1000); - val_f = ((total/10) - (val_i*1000)); - /* Return Unit: 1 mW */ - return snprintf(buf_p, lmax, "%d.%03d\n", val_i, val_f); -} - - -int -_common_count_rx_power(uint8_t high_byte, - uint8_t low_byte, - char *buf_p) { - /* [Note] - * Measured RX received optical power in mW. Value can represent either - * average received power or OMA depending upon how bit 3 of byte 92 (A0h) - * is set. Represented as a 16 bit unsigned integer with the power defined - * as the full 16 bit value (0-65535) with LSB equal to 0.1 uW, yielding a - * total range of 0 to 6.5535 mW (~ -40 to +8.2 dBm). Absolute accuracy is - * dependent upon the exact optical wavelength. For the vendor specified - * wavelength, accuracy shall be better than 3dB over specified temperature - * and voltage. - */ - int total = 0; - int lmax = 8; - int val_i = 0; - int val_f = 0; - /* unit: 0.1 uW (1mW=1000uW) */ - total = transform_word_to_int(high_byte, low_byte); - val_i = ((total/10) / 1000); - val_f = ((total/10) - (val_i*1000)); - /* Return Unit: 1 mW */ - return snprintf(buf_p, lmax, "%d.%03d\n", val_i, val_f); -} - - -int -_common_count_wavelength(struct transvr_obj_s *self, - uint8_t high_byte, - uint8_t low_byte) { - /* [Note] - * SFP : uint 1 um. - * QSFP: unit 0.05 um. - */ - int total = 0; - - total = transform_word_to_int(high_byte, low_byte); - switch (self->type) { - case TRANSVR_TYPE_SFP: - return total; - - case TRANSVR_TYPE_QSFP: - case TRANSVR_TYPE_QSFP_PLUS: - case TRANSVR_TYPE_QSFP_28: - return (total/20); - - default: - break; - } - return ERR_TRANSVR_UNDEFINED; -} - - -int -common_get_id(struct transvr_obj_s *self){ - - int err_code = _check_by_mode(self, - &_common_update_attr_id, - "common_get_id"); - if (err_code < 0){ - return err_code; - } - /* Transform to INT to show error case */ - return (int)self->id; -} - - -int -common_get_ext_id(struct transvr_obj_s *self){ - - int err_code = _check_by_mode(self, - &_common_update_attr_extended_id, - "common_get_ext_id"); - if (err_code < 0){ - return err_code; - } - /* Transform to INT to show error case */ - return (int)self->ext_id; -} - - -int -common_get_connector(struct transvr_obj_s *self){ - - int err_code = _check_by_mode(self, - &_common_update_attr_connector, - "common_get_connector"); - if (err_code < 0){ - return err_code; - } - /* Transform to INT to show error case */ - return (int)self->connector; -} - - -int -common_get_vendor_name(struct transvr_obj_s *self, char *buf){ - - int err = DEBUG_TRANSVR_INT_VAL; - - if (self->state == STATE_TRANSVR_CONNECTED && - self->mode == TRANSVR_MODE_POLLING && - TRANSVR_INFO_CACHE_ENABLE) { - return snprintf(buf, LEN_TRANSVR_M_STR, "%s\n", self->vendor_name); - } - err = _check_by_mode(self, - &_common_update_attr_vendor_name, - "common_get_vendor_name"); - memset(buf, 0, LEN_TRANSVR_M_STR); - if (err < 0){ - return snprintf(buf, LEN_TRANSVR_M_STR, "%d\n", err); - } - return snprintf(buf, LEN_TRANSVR_M_STR, "%s\n", self->vendor_name); -} - - -int -common_get_vendor_pn(struct transvr_obj_s *self, char *buf) { - - int err = DEBUG_TRANSVR_INT_VAL; - - if (self->state == STATE_TRANSVR_CONNECTED && - self->mode == TRANSVR_MODE_POLLING && - TRANSVR_INFO_CACHE_ENABLE) { - return snprintf(buf, LEN_TRANSVR_M_STR, "%s\n", self->vendor_pn); - } - err = _check_by_mode(self, - &_common_update_attr_vendor_pn, - "common_get_vendor_pn"); - memset(buf, 0, LEN_TRANSVR_M_STR); - if (err < 0){ - return snprintf(buf, LEN_TRANSVR_M_STR, "%d\n", err); - } - return snprintf(buf, LEN_TRANSVR_M_STR, "%s\n", self->vendor_pn); -} - - -int -common_get_vendor_rev(struct transvr_obj_s *self, char *buf) { - - int err = DEBUG_TRANSVR_INT_VAL; - - if (self->state == STATE_TRANSVR_CONNECTED && - self->mode == TRANSVR_MODE_POLLING && - TRANSVR_INFO_CACHE_ENABLE) { - return snprintf(buf, LEN_TRANSVR_M_STR, "%s\n", self->vendor_rev); - } - err = _check_by_mode(self, - &_common_update_attr_vendor_rev, - "common_get_vendor_rev"); - memset(buf, 0, LEN_TRANSVR_M_STR); - if (err < 0){ - return snprintf(buf, LEN_TRANSVR_M_STR, "%d\n", err); - } - return snprintf(buf, LEN_TRANSVR_M_STR, "%s\n", self->vendor_rev); -} - - -int -common_get_vendor_sn(struct transvr_obj_s *self, char *buf) { - - int err = DEBUG_TRANSVR_INT_VAL; - - if (self->state == STATE_TRANSVR_CONNECTED && - self->mode == TRANSVR_MODE_POLLING && - TRANSVR_INFO_CACHE_ENABLE) { - return snprintf(buf, LEN_TRANSVR_M_STR, "%s\n", self->vendor_sn); - } - err = _check_by_mode(self, - &_common_update_attr_vendor_sn, - "common_get_vendor_sn"); - memset(buf, 0, LEN_TRANSVR_M_STR); - if (err < 0){ - return snprintf(buf, LEN_TRANSVR_M_STR, "%d\n", err); - } - return snprintf(buf, LEN_TRANSVR_M_STR, "%s\n", self->vendor_sn); -} - - -int -common_get_br(struct transvr_obj_s *self){ - - int err = DEBUG_TRANSVR_INT_VAL; - - if (self->state == STATE_TRANSVR_CONNECTED && - self->mode == TRANSVR_MODE_POLLING && - TRANSVR_INFO_CACHE_ENABLE) { - return (int)self->br; - } - err = _check_by_mode(self, - &_common_update_attr_br, - "common_get_br"); - if (err < 0){ - return err; - } - /* Transform to INT to show error case */ - return (int)self->br; -} - - -int -common_get_len_smf(struct transvr_obj_s *self){ - - int err = DEBUG_TRANSVR_INT_VAL; - - if (self->state == STATE_TRANSVR_CONNECTED && - self->mode == TRANSVR_MODE_POLLING && - TRANSVR_INFO_CACHE_ENABLE) { - return self->len_smf; - } - err = _check_by_mode(self, - &_common_update_attr_len_smf, - "common_get_len_smf"); - if (err < 0){ - return err; - } - return self->len_smf; -} - - -int -common_get_len_om1(struct transvr_obj_s *self){ - - int err = DEBUG_TRANSVR_INT_VAL; - - if (self->state == STATE_TRANSVR_CONNECTED && - self->mode == TRANSVR_MODE_POLLING && - TRANSVR_INFO_CACHE_ENABLE) { - return self->len_om1; - } - err = _check_by_mode(self, - &_common_update_attr_len_om1, - "common_get_len_om1"); - if (err < 0){ - return err; - } - return self->len_om1; -} - - -int -common_get_len_om2(struct transvr_obj_s *self){ - - int err = DEBUG_TRANSVR_INT_VAL; - - if (self->state == STATE_TRANSVR_CONNECTED && - self->mode == TRANSVR_MODE_POLLING && - TRANSVR_INFO_CACHE_ENABLE) { - return self->len_om2; - } - - err = _check_by_mode(self, - &_common_update_attr_len_om2, - "common_get_len_om2"); - if (err < 0){ - return err; - } - return self->len_om2; -} - - -int -common_get_len_om3(struct transvr_obj_s *self){ - - int err = DEBUG_TRANSVR_INT_VAL; - - if (self->state == STATE_TRANSVR_CONNECTED && - self->mode == TRANSVR_MODE_POLLING && - TRANSVR_INFO_CACHE_ENABLE) { - return self->len_om3; - } - - err = _check_by_mode(self, - &_common_update_attr_len_om3, - "common_get_len_om3"); - if (err < 0){ - return err; - } - return self->len_om3; -} - - -int -common_get_len_om4(struct transvr_obj_s *self){ - - int err = DEBUG_TRANSVR_INT_VAL; - - if (self->state == STATE_TRANSVR_CONNECTED && - self->mode == TRANSVR_MODE_POLLING && - TRANSVR_INFO_CACHE_ENABLE) { - return self->len_om4; - } - err = _check_by_mode(self, - &_common_update_attr_len_om4, - "common_get_len_om4"); - if (err < 0){ - return err; - } - return self->len_om4; -} - - -int -common_get_comp_extended(struct transvr_obj_s *self){ - - int err_code = _check_by_mode(self, - &_common_update_attr_transvr_comp_ext, - "common_get_comp_extended"); - if (err_code < 0){ - return err_code; - } - return self->transvr_comp_ext; -} - - -int -common_get_comp_rev(struct transvr_obj_s *self){ - - int err_code = _check_by_mode(self, - &_common_update_attr_comp_rev, - "common_get_comp_rev"); - if (err_code < 0){ - return err_code; - } - return self->comp_rev; -} - - -int -common_get_info(struct transvr_obj_s *self){ - - if (self->state != STATE_TRANSVR_CONNECTED) { - return self->state; - } - return self->info; -} - - -int -_common_get_if_lane(struct transvr_obj_s *self, - char *result){ - int i = 0; - int tmp_val = 0; - char tmp_str[LEN_TRANSVR_M_STR] = DEBUG_TRANSVR_STR_VAL; - - memset(result, 0, LEN_TRANSVR_M_STR); - - for (i=0; ilane_id); i++) { - tmp_val = self->lane_id[i]; - if (tmp_val < 1) { - break; - } - memset(tmp_str, 0, LEN_TRANSVR_M_STR); - if (i == 0) { - snprintf(tmp_str, LEN_TRANSVR_M_STR, "%d", tmp_val); - } else { - snprintf(tmp_str, LEN_TRANSVR_M_STR, ",%d", tmp_val); - } - strncat(result, tmp_str, LEN_TRANSVR_M_STR); - } - if (i == 0) { - return EVENT_TRANSVR_TASK_FAIL; - } - return 0; -} - - -int -common_get_if_lane(struct transvr_obj_s *self, - char *buf_p){ - - char tmp_str[LEN_TRANSVR_M_STR] = DEBUG_TRANSVR_STR_VAL; - - if (self->ioexp_obj_p->state != STATE_IOEXP_NORMAL) { - return snprintf(buf_p, LEN_TRANSVR_M_STR, "%d\n", ERR_TRANSVR_ABNORMAL); - } - if (_common_get_if_lane(self, tmp_str) < 0) { - return snprintf(buf_p, LEN_TRANSVR_M_STR, "%d\n" ,ERR_TRANSVR_ABNORMAL); - } - return snprintf(buf_p, LEN_TRANSVR_M_STR, "%s\n" ,tmp_str); -} - - -int -sfp_get_len_sm(struct transvr_obj_s *self){ - - int err_code = _check_by_mode(self, - &_sfp_update_attr_len_sm, - "sfp_get_len_sm"); - if (err_code < 0){ - return err_code; - } - return self->len_sm; -} - - -int -sfp_get_rate_id(struct transvr_obj_s *self){ - - int err_code = _check_by_mode(self, - &_sfp_update_attr_rate_id, - "sfp_get_rate_id"); - if (err_code < 0){ - return err_code; - } - return self->rate_id; -} - - -int -sfp_get_soft_rs0(struct transvr_obj_s *self){ - /* Note: - * SFP Soft Rate_Select Select [aka. "RS(0)"] address - * A2h, offset: 110, bit 3 (begin form 0) - */ - int err_code = DEBUG_TRANSVR_INT_VAL; - int bit_shift = 3; - uint8_t result = 0x00; - uint8_t bitmask = (1 << bit_shift); - - /* Check rate identifier is supported */ - err_code = self->get_rate_id(self); - if (err_code <= 0) { - return ERR_TRANSVR_NOTSUPPORT; - } - /* Update and check */ - err_code = _check_by_mode(self, - &_sfp_update_attr_soft_rs0, - "sfp_get_soft_rs0"); - if (err_code <0){ - return err_code; - } - result = (self->soft_rs0 & bitmask); - if (result == bitmask) { - return 1; - } - if (result == 0) { - return 0; - } - return ERR_TRANSVR_UNEXCPT; -} - - -int -sfp_get_soft_rs1(struct transvr_obj_s *self){ - /* Note: - * SFP Soft RS(1) Select address - * A2h, offset: 118, bit 3 (begin form 0) - */ - int err_code = DEBUG_TRANSVR_INT_VAL; - int bit_shift = 3; - uint8_t result = 0x00; - uint8_t bitmask = (1 << bit_shift); - - /* Check rate identifier is supported */ - err_code = self->get_rate_id(self); - if (err_code <= 0) { - return ERR_TRANSVR_NOTSUPPORT; - } - /* Update and check */ - err_code = _check_by_mode(self, - &_sfp_update_attr_soft_rs1, - "sfp_get_soft_rs1"); - if (err_code <0){ - return err_code; - } - result = (self->soft_rs1 & bitmask); - if (result == bitmask) { - return 1; - } - if (result == 0) { - return 0; - } - return ERR_TRANSVR_UNEXCPT; -} - - -int -sfp_get_transvr_temp(struct transvr_obj_s *self, - char *buf_p) { - - int lmax = 8; - int err_code = DEBUG_TRANSVR_INT_VAL; - - err_code = _check_by_mode(self, - &_sfp_update_attr_curr_temp, - "sfp_get_transvr_temp"); - if (err_code < 0) { - return snprintf(buf_p, lmax, "%d\n", err_code); - } - if ((self->curr_temp[0]) == DEBUG_TRANSVR_HEX_VAL) { - return snprintf(buf_p, lmax, "%d\n", ERR_TRANSVR_UPDATE_FAIL); - } - return _common_count_temp(self->curr_temp[0], - self->curr_temp[1], - buf_p); -} - - -int -sfp_get_transvr_voltage(struct transvr_obj_s *self, - char *buf_p) { - - int lmax = 8; - int err_code = DEBUG_TRANSVR_INT_VAL; - - err_code = _check_by_mode(self, - &_sfp_update_attr_curr_voltage, - "sfp_get_transvr_voltage"); - if (err_code < 0) { - return snprintf(buf_p, lmax, "%d\n", err_code); - } - if ((self->curr_voltage[0]) == DEBUG_TRANSVR_HEX_VAL) { - return snprintf(buf_p, lmax, "%d\n", ERR_TRANSVR_UPDATE_FAIL); - } - /* Return Unit: 1 Volt */ - return _common_count_voltage(self->curr_voltage[0], - self->curr_voltage[1], - buf_p); -} - - -int -sfp_get_transvr_tx_bias(struct transvr_obj_s *self, - char *buf_p) { - - int lmax = 8; - int err_code = DEBUG_TRANSVR_INT_VAL; - - err_code = _check_by_mode(self, - &_sfp_update_attr_curr_tx_bias, - "sfp_get_transvr_tx_bias"); - if (err_code < 0) { - return snprintf(buf_p, lmax, "%d\n", err_code); - } - if ((self->curr_tx_bias[0]) == DEBUG_TRANSVR_HEX_VAL) { - return snprintf(buf_p, lmax, "%d\n", ERR_TRANSVR_UPDATE_FAIL); - } - /* Return Unit: 1 mA */ - return _common_count_tx_bias(self->curr_tx_bias[0], - self->curr_tx_bias[1], - buf_p); -} - - -int -sfp_get_transvr_tx_power(struct transvr_obj_s *self, - char *buf_p) { - - int lmax = 8; - int err_code = DEBUG_TRANSVR_INT_VAL; - - err_code = _check_by_mode(self, - &_sfp_update_attr_curr_tx_power, - "sfp_get_transvr_tx_power"); - if (err_code < 0) { - return snprintf(buf_p, lmax, "%d\n", err_code); - } - if ((self->curr_tx_bias[0]) == DEBUG_TRANSVR_HEX_VAL) { - return snprintf(buf_p, lmax, "%d\n", ERR_TRANSVR_UPDATE_FAIL); - } - /* Return Unit: 1 mW */ - return _common_count_tx_power(self->curr_tx_power[0], - self->curr_tx_power[1], - buf_p); -} - - -int -sfp_get_transvr_rx_power(struct transvr_obj_s *self, - char *buf_p) { - - int lmax = 8; - int err_code = DEBUG_TRANSVR_INT_VAL; - - err_code = _check_by_mode(self, - &_sfp_update_attr_curr_rx_power, - "sfp_get_transvr_rx_power"); - if (err_code < 0) { - return snprintf(buf_p, lmax, "%d\n", err_code); - } - if ((self->curr_tx_bias[0]) == DEBUG_TRANSVR_HEX_VAL) { - return snprintf(buf_p, lmax, "%d\n", ERR_TRANSVR_UPDATE_FAIL); - } - /* Return Unit: 1 mW */ - return _common_count_rx_power(self->curr_rx_power[0], - self->curr_rx_power[1], - buf_p); -} - - -int -sfp_get_transvr_rx_em(struct transvr_obj_s *self, - char *buf_p) { - - int limt = 8; - int err = DEBUG_TRANSVR_INT_VAL; - - err = _check_by_mode(self, - &_sfp_update_attr_rx_em, - "sfp_get_transvr_rx_em"); - if (err < 0) { - return snprintf(buf_p, limt, "%d\n", err); - } - if ((self->tx_eq[0]) == DEBUG_TRANSVR_HEX_VAL) { - return snprintf(buf_p, limt, "%d\n", ERR_TRANSVR_UPDATE_FAIL); - } - return snprintf(buf_p, limt, "0x%02x\n", self->rx_em[0]); -} - - -int -sfp_get_transvr_tx_eq(struct transvr_obj_s *self, - char *buf_p) { - - int limt = 8; - int err = DEBUG_TRANSVR_INT_VAL; - - err = _check_by_mode(self, - &_sfp_update_attr_tx_eq, - "sfp_get_transvr_tx_eq"); - if (err < 0) { - return snprintf(buf_p, limt, "%d\n", err); - } - if ((self->tx_eq[0]) == DEBUG_TRANSVR_HEX_VAL) { - return snprintf(buf_p, limt, "%d\n", ERR_TRANSVR_UPDATE_FAIL); - } - return snprintf(buf_p, limt, "0x%02x\n", self->tx_eq[0]); -} - - -int -_sfp_get_comp_extended(struct transvr_obj_s *self) { - /* Address: A0h / 36 - * Reference: SFF-8024 TABLE 4-4 - */ - if ((self->state == STATE_TRANSVR_CONNECTED) || - (self->state == STATE_TRANSVR_INIT) ) { - return (int)(self->transvr_comp_ext); - } - return ERR_TRANSVR_ABNORMAL; -} - - -int -__sfp_get_comp_attr(struct transvr_obj_s *self, - int array_offset) { - /* SFP Specification Compliance: A0h / 3-10 - * transvr_comp[0-7] = 3 - 10 - */ - if ((self->state == STATE_TRANSVR_CONNECTED) || - (self->state == STATE_TRANSVR_INIT) ) { - return (int)(self->transvr_comp[array_offset]); - } - return ERR_TRANSVR_ABNORMAL; -} - - -int -_sfp_get_comp_10g_eth_comp(struct transvr_obj_s *self) { - /* transvr_comp[0] = address A0h / 3 - * - * 3 7: 10G Base-ER - * 3 6: 10GBASE-LRM - * 3 5: 10GBASE-LR - * 3 4: 10GBASE-SR - */ - int bitmask = 0xf0; /* 11110000 */ - return (__sfp_get_comp_attr(self, 0) & bitmask); -} - - -int -_sfp_get_comp_1g_eth_comp(struct transvr_obj_s *self) { - /* transvr_comp[3] = address A0h / 6 - * - * 6 7: BASE-PX *3 - * 6 6: BASE-BX10 *3 - * 6 5: 100BASE-FX - * 6 4: 100BASE-LX/LX10 - * 6 3: 1000BASE-T - * 6 2: 1000BASE-CX - * 6 1: 1000BASE-LX *3 - * 6 0: 1000BASE-SX - */ - return __sfp_get_comp_attr(self, 3); -} - - -int -_sfp_get_cable_tech(struct transvr_obj_s *self) { - /* transvr_comp[5] = address A0h / 8 - * - * 8 3: Active Cable *8 - * 8 2: Passive Cable *8 - */ - int bitmask = 0x0c; /* 00001100 */ - return (__sfp_get_comp_attr(self, 5) & bitmask); -} - - -int -sfp_get_comp_eth_1(struct transvr_obj_s *self){ - - int err_code = _check_by_mode(self, - &_common_update_attr_transvr_comp, - "sfp_get_comp_eth_1"); - if (err_code < 0){ - return err_code; - } - return _sfp_get_comp_1g_eth_comp(self); -} - - -int -sfp_get_comp_eth_10(struct transvr_obj_s *self){ - - int err_code = _check_by_mode(self, - &_common_update_attr_transvr_comp, - "sfp_get_comp_eth_10"); - if (err_code < 0){ - return err_code; - } - return _sfp_get_comp_10g_eth_comp(self); -} - - -int -_sfp_get_connector_type(struct transvr_obj_s *self) { - /* Address: A0h / 2 - * Reference: SFF-8024 TABLE 4-3 - */ - if ((self->state == STATE_TRANSVR_CONNECTED) || - (self->state == STATE_TRANSVR_INIT) ) { - return (int)(self->connector); - } - return ERR_TRANSVR_ABNORMAL; -} - - -int -sfp_get_wavelength(struct transvr_obj_s *self, - char *buf_p) { - /* [Note] Optical and Cable Variants Specification Compliance (SFF-8472) - * [Addr] A0h, Bytes 60-61 - * [Note] For optical variants, as defined by having zero's in A0h Byte 8 - * bits 2 and 3, Bytes 60 and 61 denote nominal transmitter output - * wavelength at room temperature. 16 bit value with byte 60 as high - * order byte and byte 61 as low order byte. The laser wavelength is - * equal to the 16 bit integer value in nm. This field allows the user - * to read the laser wavelength directly, so it is not necessary to - * infer it from the Transceiver Codes A0h Bytes 3 to 10 (see Table - * 5-3). This also allows specification of wavelengths not covered - * in the Transceiver Codes, such as those used in coarse WDM systems. - * - * For passive and active cable variants, a value of 00h for both A0h - * Byte 60 and Byte 61 denotes laser wavelength or cable specification - * compliance is unspecified. - */ - - int lmax = 8; - int err_code = DEBUG_TRANSVR_INT_VAL; - - err_code = _check_by_mode(self, - &_common_update_attr_wavelength, - "common_get_wavelength"); - if (err_code < 0) { - return snprintf(buf_p, lmax, "%d\n", err_code); - } - if ((self->wavelength[0]) == DEBUG_TRANSVR_HEX_VAL) { - return snprintf(buf_p, lmax, "%d\n", ERR_TRANSVR_UPDATE_FAIL); - } - /* unit: 1 um */ - return snprintf(buf_p, lmax, "%d\n", - _common_count_wavelength(self, - self->wavelength[0], - self->wavelength[1])); -} - - -int -sfp_get_1g_rj45_extphy_offset(struct transvr_obj_s *self, char *buf) { - - if (self->state != STATE_TRANSVR_CONNECTED) { - return ERR_TRANSVR_UNPLUGGED; - } - if ((self->info != TRANSVR_CLASS_BASE_T_1000) && - (self->info != TRANSVR_CLASS_BASE_T_1000_up) ){ - return ERR_TRANSVR_NOTSUPPORT; - } - return snprintf(buf, LEN_TRANSVR_S_STR, "0x%02x\n", self->extphy_offset); -} - - -int -sfp_get_1g_rj45_extphy_reg(struct transvr_obj_s *self, char *buf) { - - int i = 0; - int ret = 0; - int retry = 3; - int delay = 200; - - if (self->state != STATE_TRANSVR_CONNECTED) { - return ERR_TRANSVR_UNPLUGGED; - } - if ((self->info != TRANSVR_CLASS_BASE_T_1000) && - (self->info != TRANSVR_CLASS_BASE_T_1000_up) ){ - return ERR_TRANSVR_NOTSUPPORT; - } - if (_common_setup_page(self, VAL_TRANSVR_EXTPHY_ADDR_56, - -1, self->extphy_offset, 1, 0) < 0) { - return -EIO; - } - for (i=0; ii2c_client_p, self->extphy_offset); - if (ret >=0) { - goto ok_sfp_get_1g_rj45_extphy_reg; - } - msleep(delay); - } - SWPS_INFO("%s: retry:%d fail :%s :0x%02x\n", - __func__, retry, self->swp_name, self->extphy_offset); - return -EIO; - -ok_sfp_get_1g_rj45_extphy_reg: - ret = ((ret & 0x00ff) << 8) | ((ret & 0xff00) >> 8); - return snprintf(buf, LEN_TRANSVR_S_STR, "0x%04x\n", ret); -} - - -int -__qsfp_get_power_cls(struct transvr_obj_s *self, - int direct_access){ - - int err_code; - uint8_t detect_val; - - /* Detect and Update power class attribute */ - if (direct_access){ - err_code = _check_by_mode(self, - &_common_update_attr_extended_id, - "__qsfp_get_power_cls"); - } else { - err_code = self->ext_id; - } - if (err_code <0){ - return err_code; - } - if (err_code == DEBUG_TRANSVR_HEX_VAL){ - return ERR_TRANSVR_UPDATE_FAIL; - } - /* Clean data */ - detect_val = self->ext_id; - SWP_BIT_CLEAR(detect_val, 2); /* Bit2: CDR RX present */ - SWP_BIT_CLEAR(detect_val, 3); /* Bit3: CDR TX present */ - SWP_BIT_CLEAR(detect_val, 4); /* Bit4: CLEI present */ - SWP_BIT_CLEAR(detect_val, 5); /* Bit5: reserved */ - /* Identify power class */ - switch (detect_val) { - case 0: /* Class_1: 00000000 */ - return 1; - case 64: /* Class_2: 01000000 */ - return 2; - case 128: /* Class_3: 10000000 */ - return 3; - case 192: /* Class_4: 11000000 */ - return 4; - case 1: /* Class_5: 00000001 */ - case 193: /* Class_5: 11000001 */ - return 5; - case 2: /* Class_6: 00000010 */ - case 194: /* Class_6: 11000010 */ - return 6; - case 3: /* Class_7: 00000011 */ - case 195: /* Class_7: 11000011 */ - return 7; - default: - break; - } - SWPS_INFO("%s: Detect undefined power class:%d\n", __func__, detect_val); - return ERR_TRANSVR_UNDEFINED; -} - - -int -qsfp_get_power_cls(struct transvr_obj_s *self) { - return __qsfp_get_power_cls(self, 1); -} - - -int -__qsfp_get_cdr_present(struct transvr_obj_s *self, - int direct_access){ - - int retval; - int BIT_SHIFT = 2; - int BIT_MASK = 0x3; - - /* Detect and Update power class attribute */ - if (direct_access) { - retval = _check_by_mode(self, - &_common_update_attr_extended_id, - "__qsfp_get_cdr_present"); - if (retval < 0){ - return retval; - } - } - retval = self->ext_id; - if (retval == DEBUG_TRANSVR_HEX_VAL){ - return ERR_TRANSVR_UPDATE_FAIL; - } - /* Clean data and return */ - return (int)(retval >> BIT_SHIFT & BIT_MASK); -} - - -int -qsfp_get_cdr_present(struct transvr_obj_s *self) { - return __qsfp_get_cdr_present(self, 1); -} - - -int -qsfp_get_cdr(struct transvr_obj_s *self){ - - int err_code = _check_by_mode(self, - &_qsfp_update_attr_cdr, - "qsfp_get_cdr"); - if (err_code <0){ - return err_code; - } - - return self->cdr; -} - - -int -__qsfp_get_comp_attr(struct transvr_obj_s *self, - int array_offset) { - /* QSFP Specification Compliance: 00h / 131-138 - * transvr_comp[0-7] = 131 - 138 - */ - if ((self->state == STATE_TRANSVR_CONNECTED) || - (self->state == STATE_TRANSVR_INIT) ) { - return (int)(self->transvr_comp[array_offset]); - } - return ERR_TRANSVR_ABNORMAL; -} - - -int -_qsfp_get_comp_10_40_100_ethernet(struct transvr_obj_s *self) { - /* transvr_comp[0] = address 00h / 131 - * - * 131 7: Extended: See section 6.3.23. The Extended Specification Compliance - * Codes are maintained in the Transceiver Management section of SFF- - * 8024. - * 131 6: 10GBASE-LRM - * 131 5: 10GBASE-LR - * 131 4: 10GBASE-SR - * 131 3: 40GBASE-CR4 - * 131 2: 40GBASE-SR4 - * 131 1: 40GBASE-LR4 - * 131 0: 40G Active Cable (XLPPI) - */ - return __qsfp_get_comp_attr(self, 0); -} - - -int -_qsfp_get_comp_sonet(struct transvr_obj_s *self) { - /* transvr_comp[1] = address 00h / 132 - * - * 132 7-3: Reserved - * 132 2: OC 48, long reach - * 132 1: OC 48, intermediate reach - * 132 0: OC 48 short reach - */ - return __qsfp_get_comp_attr(self, 1); -} - - -int -_qsfp_get_comp_sas_sata(struct transvr_obj_s *self) { - /* transvr_comp[1] = address 00h / 132 - * - * 133 7: SAS 24.0 Gb/s - * 133 6: SAS 12.0 Gb/s - * 133 5: SAS 6.0 Gb/s - * 133 4: SAS 3.0 Gb/s - * 133 3-0: Reserved - */ - return __qsfp_get_comp_attr(self, 2); -} - - -int -_qsfp_get_comp_ethernet(struct transvr_obj_s *self) { - /* transvr_comp[1] = address 00h / 132 - * - * 134 7-4: Reserved - * 134 3: 1000BASE-T - * 134 2: 1000BASE-CX - * 134 1: 1000BASE-LX - * 134 0: 1000BASE-SX - */ - return __qsfp_get_comp_attr(self, 3); -} - - -int -_qsfp_get_comp_fc_link_length(struct transvr_obj_s *self) { - /* transvr_comp[1] = address 00h / 132 - * - * 135 7: Very long distance (V) - * 135 6: Short distance (S) - * 135 5: Intermediate distance (I) - * 135 4: Long distance (L) - * 135 3: Medium (M) - */ - int mask = 0xFC; /* 11111100 */ - return (__qsfp_get_comp_attr(self, 4) & mask); -} - - -int -_qsfp_get_comp_fc_trans_tech(struct transvr_obj_s *self) { - /* transvr_comp[1] = address 00h / 132 - * - * 135 2: Reserved - * 135 1: Longwave laser (LC) - * 135 0: Electrical inter-enclosure (EL) - * - * 136 7: Electrical intra-enclosure - * 136 6: Shortwave laser w/o OFC (SN) - * 136 5: Shortwave laser w OFC (SL) - * 136 4: Longwave Laser (LL) - * 136 3-0: Reserved - * - * return value = [bit 8-15:addr 135][bit 0-7:addr 136] - */ - int mask_135 = 7; /* 00000111 */ - int val_135 = (__qsfp_get_comp_attr(self, 4) & mask_135); - int val_136 = __qsfp_get_comp_attr(self, 5); - return ((val_135 << 7) + val_136); -} - - -int -_qsfp_get_comp_fc_trans_media(struct transvr_obj_s *self) { - /* transvr_comp[1] = address 00h / 132 - * - * 137 7: Twin Axial Pair (TW) - * 137 6: Shielded Twisted Pair (TP) - * 137 5: Miniature Coax (MI) - * 137 4: Video Coax (TV) - * 137 3: Multi-mode 62.5 m (M6) - * 137 2: Multi-mode 50 m (M5) - * 137 1: Multi-mode 50 um (OM3) - * 137 0: Single Mode (SM) - */ - return __qsfp_get_comp_attr(self, 6); -} - - -int -_qsfp_get_comp_fc_speed(struct transvr_obj_s *self) { - /* transvr_comp[1] = address 00h / 132 - * - * 138 7: 1200 MBps (per channel) - * 138 6: 800 MBps - * 138 5: 1600 MBps (per channel) - * 138 4: 400 MBps - * 138 3: 3200 MBps (per channel) - * 138 2: 200 MBps - * 138 1: Extended: See section 6.3.23. The Extended Specification - * Compliance Codes are maintained in the Transceiver Management - * section of SFF-8024. - * 138 0: 100 MBps - */ - return __qsfp_get_comp_attr(self, 7); -} - - -int -_qsfp_get_comp_extended(struct transvr_obj_s *self) { - /* Address: 00h / 192 - * Reference: SFF-8024 TABLE 4-4 - */ - if ((self->state == STATE_TRANSVR_CONNECTED) || - (self->state == STATE_TRANSVR_INIT) ) { - return (int)(self->transvr_comp_ext); - } - return ERR_TRANSVR_ABNORMAL; -} - - -int -qsfp_get_comp_eth(struct transvr_obj_s *self){ - - int err_code = _check_by_mode(self, - &_common_update_attr_transvr_comp, - "qsfp_get_comp_eth"); - if (err_code < 0){ - return err_code; - } - return _qsfp_get_comp_ethernet(self); -} - - -int -qsfp_get_comp_10_40(struct transvr_obj_s *self) { - - int err_code = _check_by_mode(self, - &_common_update_attr_transvr_comp, - "qsfp_get_comp_10_40"); - if (err_code < 0){ - return err_code; - } - return _qsfp_get_comp_10_40_100_ethernet(self); -} - - -int -_qsfp_get_connector_type(struct transvr_obj_s *self) { - /* Address: 00h / 130 - * Reference: SFF-8024 TABLE 4-3 - */ - if ((self->state == STATE_TRANSVR_CONNECTED) || - (self->state == STATE_TRANSVR_INIT) ) { - return (int)(self->connector); - } - return ERR_TRANSVR_ABNORMAL; -} - - -int -qsfp_get_transvr_temp(struct transvr_obj_s *self, - char *buf_p) { - - int lmax = 8; - int err_code = DEBUG_TRANSVR_INT_VAL; - - err_code = _check_by_mode(self, - &_qsfp_update_attr_curr_temp, - "qsfp_get_transvr_temp"); - if (err_code < 0) { - return snprintf(buf_p, lmax, "%d\n", err_code); - } - if ((self->curr_temp[0]) == DEBUG_TRANSVR_HEX_VAL) { - return snprintf(buf_p, lmax, "%d\n", ERR_TRANSVR_UPDATE_FAIL); - } - return _common_count_temp(self->curr_temp[0], - self->curr_temp[1], - buf_p); -} - - -int -qsfp_get_transvr_voltage(struct transvr_obj_s *self, - char *buf_p) { - - int lmax = 8; - int err_code = DEBUG_TRANSVR_INT_VAL; - - err_code = _check_by_mode(self, - &_qsfp_update_attr_curr_voltage, - "qsfp_get_transvr_voltage"); - if (err_code < 0) { - return snprintf(buf_p, lmax, "%d\n", err_code); - } - if ((self->curr_voltage[0]) == DEBUG_TRANSVR_HEX_VAL) { - return snprintf(buf_p, lmax, "%d\n", ERR_TRANSVR_UPDATE_FAIL); - } - /* Return Unit: 1 Volt */ - return _common_count_voltage(self->curr_voltage[0], - self->curr_voltage[1], - buf_p); -} - - -int -qsfp_get_transvr_tx_eq(struct transvr_obj_s *self, - char *buf_p) { - - int limt = 8; - int err = DEBUG_TRANSVR_INT_VAL; - - err = _check_by_mode(self, - &_qsfp_update_attr_tx_eq, - "qsfp_get_transvr_tx_eq"); - if (err < 0) { - return snprintf(buf_p, limt, "%d\n", err); - } - if ((self->tx_eq[0]) == DEBUG_TRANSVR_HEX_VAL) { - return snprintf(buf_p, limt, "%d\n", ERR_TRANSVR_UPDATE_FAIL); - } - return snprintf(buf_p, limt, "0x%02x%02x\n", - self->tx_eq[0], self->tx_eq[1]); -} - - -int -qsfp_get_transvr_rx_am(struct transvr_obj_s *self, - char *buf_p) { - - int limt = 8; - int err = DEBUG_TRANSVR_INT_VAL; - - err = _check_by_mode(self, - &_qsfp_update_attr_rx_am, - "qsfp_get_transvr_rx_am"); - if (err < 0) { - return snprintf(buf_p, limt, "%d\n", err); - } - if ((self->rx_am[0]) == DEBUG_TRANSVR_HEX_VAL) { - return snprintf(buf_p, limt, "%d\n", ERR_TRANSVR_UPDATE_FAIL); - } - return snprintf(buf_p, limt, "0x%02x%02x\n", - self->rx_am[0], self->rx_am[1]); -} - - -int -qsfp_get_transvr_rx_em(struct transvr_obj_s *self, - char *buf_p) { - - int limt = 8; - int err = DEBUG_TRANSVR_INT_VAL; - - err = _check_by_mode(self, - &_qsfp_update_attr_rx_em, - "qsfp_get_transvr_rx_em"); - if (err < 0) { - return snprintf(buf_p, limt, "%d\n", err); - } - if ((self->rx_em[0]) == DEBUG_TRANSVR_HEX_VAL) { - return snprintf(buf_p, limt, "%d\n", ERR_TRANSVR_UPDATE_FAIL); - } - return snprintf(buf_p, limt, "0x%02x%02x\n", - self->rx_em[0], self->rx_em[1]); -} - - -int -_qsfp_get_channel_diag(uint8_t *data_array, - int (*count_func)(uint8_t high_byte, uint8_t low_byte, char *buf_p), - char *ch_name, - char *result_p) { - int i, high, low; - int len_max = 128; - char ch_buf[4][16] = { DEBUG_TRANSVR_STR_VAL, - DEBUG_TRANSVR_STR_VAL, - DEBUG_TRANSVR_STR_VAL, - DEBUG_TRANSVR_STR_VAL }; - - for (i=0; i<4; i++) { - high = (i*2); - low = ((i*2) + 1); - count_func(data_array[high], data_array[low], ch_buf[i]); - } - return snprintf(result_p, len_max, - "%s-%d:%s%s-%d:%s%s-%d:%s%s-%d:%s", - ch_name, 1, ch_buf[0], - ch_name, 2, ch_buf[1], - ch_name, 3, ch_buf[2], - ch_name, 4, ch_buf[3]); -} - - -int -qsfp_get_soft_rx_los(struct transvr_obj_s *self, - char *buf_p) { - - int lmax = 8; - int mask = 0x0f; /* Bit 0 ~ Bit 3 */ - int err_code = DEBUG_TRANSVR_INT_VAL; - - err_code = _check_by_mode(self, - &_qsfp_update_attr_soft_rx_los, - "qsfp_get_soft_rx_los"); - if (err_code < 0) { - return snprintf(buf_p, lmax, "%d\n", err_code); - } - return snprintf(buf_p, lmax, "0x%02x\n", (self->rx_los & mask)); -} - - -int -qsfp_get_soft_tx_disable(struct transvr_obj_s *self, - char *buf_p) { - - int lmax = 8; - int mask = 0x0f; /* Bit 0 ~ Bit 3 */ - int err_code = DEBUG_TRANSVR_INT_VAL; - - err_code = _check_by_mode(self, - &_qsfp_update_attr_soft_tx_disable, - "qsfp_get_soft_tx_disable"); - if (err_code < 0) { - return snprintf(buf_p, lmax, "%d\n", err_code); - } - return snprintf(buf_p, lmax, "0x%02x\n", (self->tx_disable & mask)); -} - - -int -qsfp_get_soft_tx_fault(struct transvr_obj_s *self, - char *buf_p) { - - int lmax = 8; - int mask = 0x0f; /* Bit 0 ~ Bit 3 */ - int err_code = DEBUG_TRANSVR_INT_VAL; - - err_code = _check_by_mode(self, - &_qsfp_update_attr_soft_tx_fault, - "qsfp_get_soft_tx_fault"); - if (err_code < 0) { - return snprintf(buf_p, lmax, "%d\n", err_code); - } - return snprintf(buf_p, lmax, "0x%02x\n", (self->tx_fault & mask)); -} - - -int -qsfp_get_auto_tx_disable(struct transvr_obj_s *self, - char *buf_p) { - - if (self->auto_tx_disable == VAL_TRANSVR_FUNCTION_DISABLE) { - return snprintf(buf_p, LEN_TRANSVR_S_STR, - "%d\n", ERR_TRANSVR_FUNC_DISABLE); - } - return snprintf(buf_p, LEN_TRANSVR_S_STR, - "0x%02x\n", self->auto_tx_disable); -} - - -int -qsfp_get_transvr_tx_bias(struct transvr_obj_s *self, - char *buf_p) { - - int lmax = 8; - int err_code = DEBUG_TRANSVR_INT_VAL; - char *ch_name = "TX"; - - err_code = _check_by_mode(self, - &_qsfp_update_attr_curr_tx_bias, - "qsfp_get_transvr_tx_bias"); - if (err_code < 0) { - return snprintf(buf_p, lmax, "%d\n", err_code); - } - if ((self->curr_tx_bias[0]) == DEBUG_TRANSVR_HEX_VAL) { - return snprintf(buf_p, lmax, "%d\n", ERR_TRANSVR_UPDATE_FAIL); - } - /* Return Unit: 1 mA */ - return _qsfp_get_channel_diag(self->curr_tx_bias, - _common_count_tx_bias, - ch_name, - buf_p); -} - - -int -qsfp_get_transvr_tx_power(struct transvr_obj_s *self, - char *buf_p) { - - int lmax = 8; - int err_code = DEBUG_TRANSVR_INT_VAL; - char *ch_name = "TX"; - - err_code = _check_by_mode(self, - &_qsfp_update_attr_curr_tx_power, - "qsfp_get_transvr_tx_power"); - if (err_code < 0) { - return snprintf(buf_p, lmax, "%d\n", err_code); - } - if ((self->curr_tx_power[0]) == DEBUG_TRANSVR_HEX_VAL) { - return snprintf(buf_p, lmax, "%d\n", ERR_TRANSVR_UPDATE_FAIL); - } - /* Return Unit: 1 mW */ - return _qsfp_get_channel_diag(self->curr_tx_power, - _common_count_tx_power, - ch_name, - buf_p); -} - - -int -qsfp_get_transvr_rx_power(struct transvr_obj_s *self, - char *buf_p) { - - int lmax = 8; - int err_code = DEBUG_TRANSVR_INT_VAL; - char *ch_name = "RX"; - - err_code = _check_by_mode(self, - &_qsfp_update_attr_curr_rx_power, - "qsfp_get_transvr_rx_power"); - if (err_code < 0) { - return snprintf(buf_p, lmax, "%d\n", err_code); - } - if ((self->curr_tx_power[0]) == DEBUG_TRANSVR_HEX_VAL) { - return snprintf(buf_p, lmax, "%d\n", ERR_TRANSVR_UPDATE_FAIL); - } - /* Return Unit: 1 mW */ - return _qsfp_get_channel_diag(self->curr_rx_power, - _common_count_rx_power, - ch_name, - buf_p); -} - - -int -qsfp_get_wavelength(struct transvr_obj_s *self, - char *buf_p) { - /* [Desc] Wavelength or Copper Cable Attenuation (SFF-8636) - * [Addr] 00h 186-187 - * [Note] - * For optical free side devices, this parameter identifies the nominal - * transmitter output wavelength at room temperature. This parameter is - * a 16-bit hex value with Byte 186 as high order byte and Byte 187 as - * low order byte. The laser wavelength is equal to the 16-bit integer value - * divided by 20 in nm (units of 0.05 nm). This resolution should be adequate - * to cover all relevant wavelengths yet provide enough resolution for all - * expected DWDM applications. For accurate representation of controlled - * wavelength applications, this value should represent the center of the - * guaranteed wavelength range. - * If the free side device is identified as copper cable these registers will - * be used to define the cable attenuation. An indication of 0 dB attenuation - * refers to the case where the attenuation is not known or is unavailable. - * Byte 186 (00-FFh) is the copper cable attenuation at 2.5 GHz in units of 1 dB. - * Byte 187 (00-FFh) is the copper cable attenuation at 5.0 GHz in units of 1 dB. - */ - int lmax = 8; - int err_code = DEBUG_TRANSVR_INT_VAL; - - err_code = _check_by_mode(self, - &_common_update_attr_wavelength, - "common_get_wavelength"); - if (err_code < 0) { - return snprintf(buf_p, lmax, "%d\n", err_code); - } - if ((self->wavelength[0]) == DEBUG_TRANSVR_HEX_VAL) { - return snprintf(buf_p, lmax, "%d\n", ERR_TRANSVR_UPDATE_FAIL); - } - /* unit: 1 um */ - return snprintf(buf_p, lmax, "%d\n", - _common_count_wavelength(self, - self->wavelength[0], - self->wavelength[1])); -} - - -/* Public Function for Setup Features - */ -static int -__sfp_set_soft_rs(struct transvr_obj_s *self, - int input_val, - int address, - int page, - int offset, - int bit_shift, - uint8_t *attr_p, - char *caller, - int show_err) { - - int retval = ERR_TRANSVR_UNEXCPT; - int err_code = ERR_TRANSVR_UNEXCPT; - char *err_msg = DEBUG_TRANSVR_STR_VAL; - uint8_t update_val = (*attr_p); - - switch (input_val) { - case 0: - SWP_BIT_CLEAR(update_val, bit_shift); - break; - case 1: - SWP_BIT_SET(update_val, bit_shift); - break; - default: - retval = ERR_TRANSVR_UNEXCPT; - err_code = ERR_TRANSVR_UNEXCPT; - err_msg = "Exception occurs"; - goto err_private_sfp_set_soft_rs_1; - } - err_code = _common_set_uint8_attr(self, - address, - page, - offset, - update_val, - attr_p, - caller, - show_err); - if (err_code < 0) { - retval = err_code; - err_msg = "Write data via i2c fail!"; - goto err_private_sfp_set_soft_rs_1; - } - (*attr_p) = update_val; - return 0; - -err_private_sfp_set_soft_rs_1: - if (show_err) { - SWPS_INFO("%s: %s :%d :%s\n :%d\n", - __func__, err_msg, err_code, self->swp_name, input_val); - } - return retval; -} - - -static int -_sfp_set_soft_rs(struct transvr_obj_s *self, - int input_val, - int address, - int page, - int offset, - int bit_shift, - int (*attr_update_func)(struct transvr_obj_s *self, int show_err), - uint8_t *attr_p, - char *caller, - int show_err) { - - int retval = ERR_TRANSVR_UNEXCPT; - int err_code = ERR_TRANSVR_UNEXCPT; - char *err_msg = DEBUG_TRANSVR_STR_VAL; - - /* Check input value */ - if ((input_val != 0) && (input_val != 1)){ - retval = ERR_TRANSVR_BADINPUT; - err_code = ERR_TRANSVR_BADINPUT; - err_msg = "Input range incorrect!"; - goto err_common_sfp_set_soft_rs_1; - } - /* Check rate identifier is supported */ - err_code = self->get_rate_id(self); - if (err_code <= 0) { - switch (err_code) { - case 0: - retval = ERR_TRANSVR_NOTSUPPORT; - err_msg = "Not support this feature"; - break; - case ERR_TRANSVR_UNINIT: - retval = ERR_TRANSVR_UNINIT; - err_msg = "Check CDR present fail!"; - break; - case ERR_TRANSVR_UNPLUGGED: - retval = ERR_TRANSVR_UNPLUGGED; - err_msg = "Transceiver unplugged!"; - break; - default: - retval = err_code; - err_msg = "Check Rate_ID fail!"; - break; - } - goto err_common_sfp_set_soft_rs_1; - } - /* Check and update */ - err_code = _check_by_mode(self, - attr_update_func, - caller); - if ( (err_code < 0) || - ((*attr_p) == DEBUG_TRANSVR_HEX_VAL) ){ - retval = err_code; - err_msg = "Get current value fail!"; - goto err_common_sfp_set_soft_rs_1; - } - /* Generate and update value */ - return __sfp_set_soft_rs(self, - input_val, - address, - page, - offset, - bit_shift, - attr_p, - caller, - show_err); - -err_common_sfp_set_soft_rs_1: - if (show_err) { - SWPS_INFO("%s: %s :%d :%s\n :%d\n", - __func__, err_msg, err_code, self->swp_name, input_val); - } - return retval; -} - - -int -sfp_set_soft_rs0(struct transvr_obj_s *self, - int input_val) { - /* Note: - * SFP Soft Rate_Select Select RX ["RS(0)"] address - * A2h, offset: 110, bit 3 - */ - int bit_shift = 3; - int show_err = 1; - return _sfp_set_soft_rs(self, - input_val, - self->eeprom_map_p->addr_soft_rs0, - self->eeprom_map_p->page_soft_rs0, - self->eeprom_map_p->offset_soft_rs0, - bit_shift, - &_sfp_update_attr_soft_rs0, - &(self->soft_rs0), - "sfp_set_soft_rs0", - show_err); -} - - -int -sfp_set_soft_rs1(struct transvr_obj_s *self, - int input_val) { - /* Note: - * SFP Soft Rate_Select Select RX ["RS(1)"] address - * A2h, offset: 118, bit 3 - */ - int bit_shift = 3; - int show_err = 1; - return _sfp_set_soft_rs(self, - input_val, - self->eeprom_map_p->addr_soft_rs1, - self->eeprom_map_p->page_soft_rs1, - self->eeprom_map_p->offset_soft_rs1, - bit_shift, - &_sfp_update_attr_soft_rs1, - &(self->soft_rs1), - "sfp_set_soft_rs1", - show_err); -} - - -int -__sfp_set_tx_eq(struct transvr_obj_s *self, - int input, - int show_e) { - - int err = DEBUG_TRANSVR_INT_VAL; - char *emsg = DEBUG_TRANSVR_STR_VAL; - uint8_t setv = DEBUG_TRANSVR_HEX_VAL; - - if ((input < 0) || (input > 0xFF)) { - emsg = "input incorrect"; - err = ERR_TRANSVR_BADINPUT; - goto err_sfp_set_tx_eq; - } - setv = (uint8_t)input; - if (self->tx_eq[0] == setv) { - return 0; - } - err = _common_set_uint8_attr(self, - self->eeprom_map_p->addr_tx_eq, - self->eeprom_map_p->page_tx_eq, - self->eeprom_map_p->offset_tx_eq, - setv, - &(self->tx_eq[0]), - "_sfp_set_tx_eq", - show_e); - if (err < 0) { - emsg = "set_uint8_attr fail"; - goto err_sfp_set_tx_eq; - } - return 0; - -err_sfp_set_tx_eq: - if (show_e) { - SWPS_INFO("%s: %s :%d\n", __func__, emsg, input); - } - return err; -} - - -int -_sfp_set_tx_eq(struct transvr_obj_s *self, - int input, - int show_e) { - - uint8_t tmp; - int i = 0; - int retry = 3; - - for (i=0; itx_eq[0]; - if (_sfp_update_attr_tx_eq(self, show_e) < 0){ - continue; - } - if (self->tx_eq[0] == tmp){ - return 0; - } - } - return ERR_TRANSVR_UPDATE_FAIL; -} - - -int -sfp_set_tx_eq(struct transvr_obj_s *self, - int input) { - - int err = _check_by_mode(self, - &_sfp_update_attr_tx_eq, - "sfp_set_tx_eq"); - if (err < 0) { - SWPS_DEBUG("%s: check fail :%d\n", __func__, err); - return err; - } - return _sfp_set_tx_eq(self, input, 1); -} - - -int -__sfp_set_rx_em(struct transvr_obj_s *self, - int input, - int show_e) { - - int err = DEBUG_TRANSVR_INT_VAL; - char *emsg = DEBUG_TRANSVR_STR_VAL; - uint8_t setv = DEBUG_TRANSVR_HEX_VAL; - - if ((input < 0) || (input > 0xFF)) { - emsg = "input incorrect"; - err = ERR_TRANSVR_BADINPUT; - goto err_sfp_set_rx_em; - } - setv = (uint8_t)input; - if (self->rx_em[0] == setv) { - return 0; - } - err = _common_set_uint8_attr(self, - self->eeprom_map_p->addr_rx_em, - self->eeprom_map_p->page_rx_em, - self->eeprom_map_p->offset_rx_em, - setv, - &(self->rx_em[0]), - "_sfp_set_rx_em", - show_e); - if (err < 0) { - emsg = "set_uint8_attr fail"; - goto err_sfp_set_rx_em; - } - return 0; - -err_sfp_set_rx_em: - if (show_e) { - SWPS_INFO("%s: %s :%d\n", __func__, emsg, input); - } - return err; -} - - -int -_sfp_set_rx_em(struct transvr_obj_s *self, - int input, - int show_e) { - - uint8_t tmp; - int i = 0; - int retry = 3; - - for (i=0; irx_em[0]; - if (_sfp_update_attr_rx_em(self, show_e) < 0){ - continue; - } - if (self->rx_em[0] == tmp){ - return 0; - } - } - return -1; -} - - -int -sfp_set_rx_em(struct transvr_obj_s *self, - int input) { - - int err = _check_by_mode(self, - &_sfp_update_attr_rx_em, - "sfp_set_rx_em"); - if (err < 0) { - SWPS_DEBUG("%s: check fail :%d\n", __func__, err); - return err; - } - return _sfp_set_rx_em(self, input, 1); -} - - -int -sfp_set_1g_rj45_extphy_offset(struct transvr_obj_s *self, - int input) { - - if (self->state != STATE_TRANSVR_CONNECTED) { - return ERR_TRANSVR_UNPLUGGED; - } - if ((self->info != TRANSVR_CLASS_BASE_T_1000) && - (self->info != TRANSVR_CLASS_BASE_T_1000_up) ){ - return ERR_TRANSVR_NOTSUPPORT; - } - if ((input < 0) || (input > 0xff)) { - return ERR_TRANSVR_BADINPUT; - } - self->extphy_offset = (uint8_t)input; - return 0; -} - - -int -sfp_set_1g_rj45_extphy_reg(struct transvr_obj_s *self, - int input) { - - int i = 0; - int retry = 3; - int delay = 200; - uint16_t tmp = 0; - - if (self->state != STATE_TRANSVR_CONNECTED) { - return ERR_TRANSVR_UNPLUGGED; - } - if ((self->info != TRANSVR_CLASS_BASE_T_1000) && - (self->info != TRANSVR_CLASS_BASE_T_1000_up) ){ - return ERR_TRANSVR_NOTSUPPORT; - } - if ((input < 0) || (input > 0xffff)) { - return ERR_TRANSVR_BADINPUT; - } - tmp = ((input & 0x00ff) << 8) | ((input & 0xff00) >> 8); - if (_common_setup_page(self, VAL_TRANSVR_EXTPHY_ADDR_56, - -1, self->extphy_offset, 1, 0) < 0) { - return -EIO; - } - for (i=0; i<=retry; i++) { - if (i2c_smbus_write_word_data(self->i2c_client_p, - self->extphy_offset, - tmp) >= 0) { - return 0; - } - msleep(delay); - } - SWPS_INFO("%s: retry:%d fail :%s :0x%02x\n", - __func__, retry, self->swp_name, self->extphy_offset); - return -EIO; -} - - -static int -__qsfp_set_cdr(struct transvr_obj_s *self, - int input_val, - int show_err) { - - uint8_t update_val; - int CDR_FEATURE_SUPPORTED = 0x3; - int retval = ERR_TRANSVR_UNEXCPT; - int err_code = ERR_TRANSVR_UNEXCPT; - char *err_msg = DEBUG_TRANSVR_STR_VAL; - char *func_name = "__qsfp_set_cdr"; - - /* Check input value */ - if ((input_val < 0) || (input_val > 0xff)){ - retval = ERR_TRANSVR_BADINPUT; - err_code = ERR_TRANSVR_BADINPUT; - err_msg = "Input range incorrect!"; - goto err_qsfp_set_cdr_1; - } - update_val = (uint8_t)input_val; - /* Check CDR supported by transceiver */ - err_code = qsfp_get_cdr_present(self); - if (err_code < 0) { - retval = err_code; - switch (err_code) { - case ERR_TRANSVR_UNINIT: - err_msg = "Check CDR present fail!"; - break; - case ERR_TRANSVR_UNPLUGGED: - err_msg = "Transceiver unplugged!"; - break; - default: - err_msg = "Check CDR present fail!"; - break; - } - goto err_qsfp_set_cdr_1; - } - if (err_code != CDR_FEATURE_SUPPORTED) { - retval = ERR_TRANSVR_NOTSUPPORT; - err_msg = "This transceiver not support CDR!"; - goto err_qsfp_set_cdr_1; - } - /* Check and update */ - err_code = _check_by_mode(self, - &_qsfp_update_attr_cdr, - func_name); - if ( (err_code < 0) || - (self->cdr == DEBUG_TRANSVR_HEX_VAL) ){ - retval = err_code; - err_msg = "Get current value fail!"; - goto err_qsfp_set_cdr_1; - } - /* Write input value to transceiver */ - return _common_set_uint8_attr(self, - self->eeprom_map_p->addr_cdr, - self->eeprom_map_p->page_cdr, - self->eeprom_map_p->offset_cdr, - update_val, - &(self->cdr), - func_name, - show_err); - -err_qsfp_set_cdr_1: - if (show_err) { - SWPS_INFO("%s: %s :%d :%s\n :%d\n", - __func__, err_msg, err_code, self->swp_name, input_val); - } - return retval; -} - - -int -qsfp_set_cdr(struct transvr_obj_s *self, - int input_val) { - return __qsfp_set_cdr(self, input_val, 1); -} - - -int -qsfp_set_soft_tx_disable(struct transvr_obj_s *self, - int input_val) { - - int show_err = 1; - int in_max = 0xf; /* 1111 */ - int in_min = 0x0; /* 0000 */ - int retval = DEBUG_TRANSVR_INT_VAL; - int update_val = DEBUG_TRANSVR_INT_VAL; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - - retval = _check_by_mode(self, - &_qsfp_update_attr_soft_tx_disable, - "qsfp_set_soft_tx_disable"); - if (retval < 0) { - snprintf(err_msg, 63, "Not ready. err:%d", retval); - goto err_qsfp_set_soft_tx_disable; - } - if ((input_val > in_max) || - (input_val < in_min) ){ - retval = ERR_TRANSVR_BADINPUT; - snprintf(err_msg, 63, "Input value:%d incorrect!", input_val); - goto err_qsfp_set_soft_tx_disable; - } - if ((self->tx_disable & 0x0f) == input_val) { - return 0; - } - update_val = ((self->tx_disable & 0xf0) & input_val); - retval = _common_set_uint8_attr(self, - self->eeprom_map_p->addr_tx_disable, - self->eeprom_map_p->page_tx_disable, - self->eeprom_map_p->offset_tx_disable, - input_val, - &(self->tx_disable), - "qsfp_set_tx_disable", - show_err); - if (retval < 0) { - snprintf(err_msg, 63, "_common_set_uint8_attr:%d fail!", retval); - goto err_qsfp_set_soft_tx_disable; - } - return 0; - -err_qsfp_set_soft_tx_disable: - SWPS_INFO("%s: %s :%s\n", __func__, err_msg, self->swp_name); - return retval; -} - - -int -_qsfp_set_auto_tx_disable(struct transvr_obj_s *self, - uint8_t update) { - - uint8_t tx_enable = 0x0; - int show_e = 1; - int err = DEBUG_TRANSVR_INT_VAL; - char *emsg = DEBUG_TRANSVR_STR_VAL; - - /* Handle timing issues */ - if (update != tx_enable) { - /* Note: - * Because there are some txvr has timing issues, - * therefore we need to execute reset cycle first. - * (enable -> other settings) - */ - err = _common_set_uint8_attr(self, - self->eeprom_map_p->addr_tx_disable, - self->eeprom_map_p->page_tx_disable, - self->eeprom_map_p->offset_tx_disable, - tx_enable, - &(self->tx_disable), - "_qsfp_set_auto_tx_disable", - show_e); - if (err < 0) { - emsg = "I2C set reset value fail"; - goto err_qsfp_set_auto_tx_disable; - } - mdelay(10); - } - /* Setup target value */ - err = _common_set_uint8_attr(self, - self->eeprom_map_p->addr_tx_disable, - self->eeprom_map_p->page_tx_disable, - self->eeprom_map_p->offset_tx_disable, - self->auto_tx_disable, - &(self->tx_disable), - "_qsfp_set_auto_tx_disable", - show_e); - if (err < 0) { - emsg = "I2C set target value fail"; - goto err_qsfp_set_auto_tx_disable; - } - /* Check and update */ - err = _common_update_uint8_attr(self, - self->eeprom_map_p->addr_tx_disable, - self->eeprom_map_p->page_tx_disable, - self->eeprom_map_p->offset_tx_disable, - self->eeprom_map_p->length_tx_disable, - &(self->tx_disable), - "_qsfp_set_auto_tx_disable", - show_e); - if (err < 0) { - emsg = "I2C get value fail"; - goto err_qsfp_set_auto_tx_disable; - } - if (self->tx_disable != update) { - emsg = "data not become effective"; - goto err_qsfp_set_auto_tx_disable; - } - return 0; - -err_qsfp_set_auto_tx_disable: - SWPS_DEBUG("%s: %s :%s\n", - __func__, emsg, self->swp_name); - return ERR_TRANSVR_UPDATE_FAIL; -} - - -int -qsfp_set_auto_tx_disable(struct transvr_obj_s *self, - int input_val) { - - int in_max = 0xf; /* 1111 */ - int in_min = 0x0; /* 0000 */ - int retval = DEBUG_TRANSVR_INT_VAL; - char *emsg = DEBUG_TRANSVR_STR_VAL; - - /* Update settings*/ - if (input_val == VAL_TRANSVR_FUNCTION_DISABLE) { - emsg = "User disable auto tx_disable"; - self->auto_tx_disable = VAL_TRANSVR_FUNCTION_DISABLE; - goto out_qsfp_set_auto_tx_disable; - } - if ((input_val > in_max) || (input_val < in_min) ){ - SWPS_INFO("%s: Input value:%d incorrect! :%s\n", - __func__, input_val, self->swp_name); - return ERR_TRANSVR_BADINPUT; - } - self->auto_tx_disable = input_val; - /* Check current soft tx_disable */ - retval = _check_by_mode(self, - &_qsfp_update_attr_soft_tx_disable, - "qsfp_set_auto_tx_disable"); - switch (retval) { - case 0: - break; - case ERR_TRANSVR_UNPLUGGED: - emsg = "Doesn't need to update"; - goto out_qsfp_set_auto_tx_disable; - default: - SWPS_INFO("%s: setup fail :%d :%s\n", - __func__, retval, self->swp_name); - return retval; - } - return _qsfp_set_auto_tx_disable(self, input_val); - -out_qsfp_set_auto_tx_disable: - SWPS_DEBUG("%s: %s :%s :%d\n :%d", - __func__, emsg, self->swp_name, input_val, retval); - return 0; -} - - -int -__qsfp_set_tx_eq(struct transvr_obj_s *self, - int input, - int show_e) { - /* [Note] - * 0x - */ - int err = DEBUG_TRANSVR_INT_VAL; - char *emsg = DEBUG_TRANSVR_STR_VAL; - uint8_t setv[2] = {0x00, 0x00}; - - if ((input < 0) || (input > 0xFFFF)) { - emsg = "input incorrect"; - err = ERR_TRANSVR_BADINPUT; - goto err_qsfp_set_tx_eq; - } - setv[0] = (uint8_t)((input & 0xFF00) >> 8); - setv[1] = (uint8_t)(input & 0xFF); - if ((self->tx_eq[0] == setv[0]) && - (self->tx_eq[1] == setv[1]) ) { - return 0; - } - err = _common_set_uint8_array(self, - self->eeprom_map_p->addr_tx_eq, - self->eeprom_map_p->page_tx_eq, - self->eeprom_map_p->offset_tx_eq, - self->eeprom_map_p->length_tx_eq, - setv, - self->tx_eq, - "_qsfp_set_tx_eq", - show_e); - if (err < 0) { - emsg = "set_uint8_array fail"; - goto err_qsfp_set_tx_eq; - } - return 0; - -err_qsfp_set_tx_eq: - if (show_e) { - SWPS_INFO("%s: %s :%d\n", __func__, emsg, input); - } - return err; -} - - -int -_qsfp_set_tx_eq(struct transvr_obj_s *self, - int input, - int show_e) { - - int i = 0; - int retry = 3; - uint8_t tmp[2]; - - for (i=0; itx_eq[0]; - tmp[1] = self->tx_eq[1]; - if (_qsfp_update_attr_tx_eq(self, show_e) < 0){ - continue; - } - if ((self->tx_eq[0] == tmp[0]) && - (self->tx_eq[1] == tmp[1]) ){ - return 0; - } - } - return -1; -} - - -int -qsfp_set_tx_eq(struct transvr_obj_s *self, - int input) { - - int err = _check_by_mode(self, - &_qsfp_update_attr_tx_eq, - "qsfp_set_tx_eq"); - if (err < 0) { - SWPS_DEBUG("%s: check fail :%d\n", __func__, err); - return err; - } - return _qsfp_set_tx_eq(self, input, 1); -} - - -int -__qsfp_set_rx_am(struct transvr_obj_s *self, - int input, - int show_e) { - /* [Note] - * 0x - */ - int err = DEBUG_TRANSVR_INT_VAL; - char *emsg = DEBUG_TRANSVR_STR_VAL; - uint8_t setv[2] = {0x00, 0x00}; - - if ((input < 0) || (input > 0xFFFF)) { - emsg = "input incorrect"; - err = ERR_TRANSVR_BADINPUT; - goto err_qsfp_set_rx_am; - } - setv[0] = (uint8_t)((input & 0xFF00) >> 8); - setv[1] = (uint8_t)(input & 0xFF); - if ((self->rx_am[0] == setv[0]) && - (self->rx_am[1] == setv[1]) ) { - return 0; - } - err = _common_set_uint8_array(self, - self->eeprom_map_p->addr_rx_am, - self->eeprom_map_p->page_rx_am, - self->eeprom_map_p->offset_rx_am, - self->eeprom_map_p->length_rx_am, - setv, - self->rx_am, - "_qsfp_set_rx_am", - show_e); - if (err < 0) { - emsg = "set_uint8_array fail"; - goto err_qsfp_set_rx_am; - } - return 0; - -err_qsfp_set_rx_am: - if (show_e) { - SWPS_INFO("%s: %s :%d\n", __func__, emsg, input); - } - return err; -} - - -int -_qsfp_set_rx_am(struct transvr_obj_s *self, - int input, - int show_e) { - - int i = 0; - int retry = 3; - uint8_t tmp[2]; - - for (i=0; irx_am[0]; - tmp[1] = self->rx_am[1]; - if (_qsfp_update_attr_rx_am(self, show_e) < 0){ - continue; - } - if ((self->rx_am[0] == tmp[0]) && - (self->rx_am[1] == tmp[1]) ){ - return 0; - } - } - return -1; -} - - -int -qsfp_set_rx_am(struct transvr_obj_s *self, - int input) { - - int err = _check_by_mode(self, - &_qsfp_update_attr_rx_am, - "qsfp_set_rx_am"); - if (err < 0) { - SWPS_DEBUG("%s: check fail :%d\n", __func__, err); - return err; - } - return _qsfp_set_rx_am(self, input, 1); -} - - -int -__qsfp_set_rx_em(struct transvr_obj_s *self, - int input, - int show_e) { - /* [Note] - * 0x - */ - int err = DEBUG_TRANSVR_INT_VAL; - char *emsg = DEBUG_TRANSVR_STR_VAL; - uint8_t setv[2] = {0x00, 0x00}; - - if ((input < 0) || (input > 0xFFFF)) { - emsg = "input incorrect"; - err = ERR_TRANSVR_BADINPUT; - goto err_qsfp_set_rx_em; - } - setv[0] = (uint8_t)((input & 0xFF00) >> 8); - setv[1] = (uint8_t)(input & 0xFF); - if ((self->rx_em[0] == setv[0]) && - (self->rx_em[1] == setv[1]) ) { - return 0; - } - err = _common_set_uint8_array(self, - self->eeprom_map_p->addr_rx_em, - self->eeprom_map_p->page_rx_em, - self->eeprom_map_p->offset_rx_em, - self->eeprom_map_p->length_rx_em, - setv, - self->rx_em, - "_qsfp_set_rx_em", - show_e); - if (err < 0) { - emsg = "set_uint8_array fail"; - goto err_qsfp_set_rx_em; - } - return 0; - -err_qsfp_set_rx_em: - if (show_e) { - SWPS_INFO("%s: %s :%d\n", __func__, emsg, input); - } - return err; -} - - -int -_qsfp_set_rx_em(struct transvr_obj_s *self, - int input, - int show_e) { - - int i = 0; - int retry = 3; - uint8_t tmp[2]; - - for (i=0; irx_em[0]; - tmp[1] = self->rx_em[1]; - if (_qsfp_update_attr_rx_em(self, show_e) < 0){ - continue; - } - if ((self->rx_em[0] == tmp[0]) && - (self->rx_em[1] == tmp[1]) ){ - return 0; - } - } - return -1; -} - - -int -qsfp_set_rx_em(struct transvr_obj_s *self, - int input) { - - int err = _check_by_mode(self, - &_qsfp_update_attr_rx_em, - "qsfp_set_rx_em"); - if (err < 0) { - SWPS_DEBUG("%s: check fail :%d\n", __func__, err); - return err; - } - return _qsfp_set_rx_em(self, input, 1); -} - - -int -common_transvr_dump(struct transvr_obj_s* self){ - - char *type_name = "Undefined"; - - if (TRANSVR_INFO_DUMP_ENABLE != 1) { - return 0; - } - switch (self->type) { - case TRANSVR_TYPE_SFP: - type_name = STR_TRANSVR_SFP; - break; - case TRANSVR_TYPE_QSFP: - type_name = STR_TRANSVR_QSFP; - break; - case TRANSVR_TYPE_QSFP_PLUS: - type_name = STR_TRANSVR_QSFP_PLUS; - break; - case TRANSVR_TYPE_QSFP_28: - type_name = STR_TRANSVR_QSFP28; - break; - case TRANSVR_TYPE_FAKE: - type_name = "FAKE"; - goto ok_common_transvr_dump; - case TRANSVR_TYPE_UNPLUGGED: - type_name = "UNPLUGGED"; - goto err_common_transvr_dump; - case TRANSVR_TYPE_INCONSISTENT: - type_name = "INCONSISTENT"; - goto err_common_transvr_dump; - case TRANSVR_TYPE_ERROR: - type_name = "ERROR"; - goto err_common_transvr_dump; - - default: - type_name = "UNEXPECTED"; - goto err_common_transvr_dump; - } - printk(KERN_INFO "[SWPS] Dump %s information:\n", self->swp_name); - printk(KERN_INFO " |- :%s\n", type_name); - printk(KERN_INFO " |- :%s\n", self->vendor_name); - printk(KERN_INFO " |- :%s\n", self->vendor_pn); - printk(KERN_INFO " |- :%s\n", self->vendor_rev); - printk(KERN_INFO " |- :%s\n", self->vendor_sn); - printk(KERN_INFO " |- :0x%02x\n", self->br); - printk(KERN_INFO " |- :0x%02x\n", self->comp_rev); - printk(KERN_INFO " |- :%d\n", self->len_om1); - printk(KERN_INFO " |- :%d\n", self->len_om2); - printk(KERN_INFO " |- :%d\n", self->len_om3); - printk(KERN_INFO " |- :%d\n", self->len_om4); - return 0; - -ok_common_transvr_dump: - SWPS_INFO("%s: %s is %s\n", __func__, self->swp_name, type_name); - return 0; - -err_common_transvr_dump: - SWPS_INFO("%s: %s is %s\n", __func__, self->swp_name, type_name); - return -1; -} - - -int -sfp_transvr_dump(struct transvr_obj_s* self) { - - if (TRANSVR_INFO_DUMP_ENABLE != 1) { - return 0; - } - if (common_transvr_dump(self) < 0) { - return -1; - } - printk(KERN_INFO " |- :%d\n", self->len_sm); - printk(KERN_INFO " |- :%d\n", self->len_smf); - printk(KERN_INFO " '- :0x%02x\n", self->rate_id); - return 0; -} - - -int -qsfp_transvr_dump(struct transvr_obj_s* self) { - - if (TRANSVR_INFO_DUMP_ENABLE != 1) { - return 0; - } - if (common_transvr_dump(self) < 0) { - return -1; - } - printk(KERN_INFO " |- :%d\n", self->len_smf); - printk(KERN_INFO " '- :Class_%d\n", __qsfp_get_power_cls(self, 0)); - return 0; -} - - -int -fake_transvr_dump(struct transvr_obj_s* self) { - - printk(KERN_INFO "[SWPS] Dump transceiver information: %s\n", self->swp_name); - printk(KERN_INFO " |- :FAKE\n"); - printk(KERN_INFO " |- :FAKE_VENDER_NAME\n"); - printk(KERN_INFO " |- :FAKE_VENDER_PN\n"); - printk(KERN_INFO " |- :FAKE_VENDER_REV\n"); - printk(KERN_INFO " |- :FAKE_VENDER_SN\n"); - printk(KERN_INFO " |- :0x99\n"); - printk(KERN_INFO " |- :99\n"); - printk(KERN_INFO " |- :99\n"); - printk(KERN_INFO " |- :99\n"); - printk(KERN_INFO " |- :99\n"); - printk(KERN_INFO " |- :99\n"); - printk(KERN_INFO " |- :99\n"); - printk(KERN_INFO " '- :0x99\n"); - return 0; -} - - -/* ========== Object functions for fake type ========== - */ -int -fake_transvr_update(struct transvr_obj_s *self, - int show_err){ - self->state = STATE_TRANSVR_CONNECTED; - return 0; -} - - -int -fake_get_binary(struct transvr_obj_s *self){ - return 1; -} - -int -fake_get_int(struct transvr_obj_s *self){ - return 99; -} - - -int -fake_get_hex(struct transvr_obj_s *self){ - return 0x0f; -} - - -int -fake_get_str(struct transvr_obj_s *self, char *buf) { - return snprintf(buf, 16, "fake_get_str\n"); -} - - -int -fake_set_int(struct transvr_obj_s *self, int input){ - SWPS_INFO("%s: %d\n", __func__, input); - return 0; -} - - -int -fake_set_hex(struct transvr_obj_s *self, int input){ - SWPS_INFO("%s: 0x%02x\n", __func__, input); - return 0; -} - - -/* ========== Object functions for unsupported ========== - */ -int -unsupported_get_func(struct transvr_obj_s *self){ - return ERR_TRANSVR_NOTSUPPORT; -} - - -int -unsupported_get_func2(struct transvr_obj_s *self, - char *buf_p) { - int len = snprintf(buf_p, 8, "%d\n", ERR_TRANSVR_NOTSUPPORT); - return len; -} - - -int -unsupported_set_func(struct transvr_obj_s *self, - int input_val){ - return ERR_TRANSVR_NOTSUPPORT; -} - - - -/* ========== Object functions for long term task ========== - * - * [Note] - * SWPS transceiver worker is likely the green-thread (coroutine). - * Due to resource and performance considerations. SWPS run all - * features in one kthread at the same time, and handle by it self. - */ - -/* For Transceiver Task Handling - */ -static struct transvr_worker_s * -transvr_task_get(struct transvr_obj_s *self, - char *func_name) { - - struct transvr_worker_s *curr_p = self->worker_p; - - while(curr_p != NULL){ - if (strcmp((curr_p->func_name), func_name) == 0 ) { - return curr_p; - } - curr_p = curr_p->next_p; - } - return NULL; -} - - -static struct transvr_worker_s* -transvr_task_creat(struct transvr_obj_s *self, - int (*main_task)(struct transvr_worker_s *task), - int (*post_task)(struct transvr_worker_s *task), - char *caller) { - - struct transvr_worker_s *task_p = NULL; - struct transvr_worker_s *curr_p = NULL; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - - /* Check task not exist */ - task_p = transvr_task_get(self, caller); - if (task_p) { - snprintf(err_msg, sizeof(err_msg), "Task already created!"); - goto err_transvr_task_creat; - } - /* Create task worker */ - task_p = kzalloc(sizeof(struct transvr_worker_s), GFP_KERNEL); - if (!task_p){ - snprintf(err_msg, sizeof(err_msg), "kzalloc fail"); - goto err_transvr_task_creat; - } - /* Setup task data */ - task_p->transvr_p = self; - task_p->next_p = NULL; - task_p->trigger_time = 0; - task_p->retry = 1; - task_p->state = STATE_T_TASK_INIT; - task_p->main_task = main_task; - task_p->post_task = post_task; - task_p->p_data = NULL; - snprintf(task_p->func_name, sizeof(task_p->func_name), "%s", caller); - /* Setup Link List */ - if (self->worker_p) { - curr_p = self->worker_p; - while(curr_p->next_p != NULL) { - curr_p = curr_p->next_p; - } - curr_p->next_p = task_p; - task_p->pre_p = curr_p; - } else { - self->worker_p = task_p; - task_p->pre_p = NULL; - } - return task_p; - -err_transvr_task_creat: - SWPS_ERR("%s: %s :%s :%s\n", - __func__, err_msg, caller, self->swp_name); - return NULL; -} - - -static void -transvr_task_free_one(struct transvr_worker_s *task_p){ - - struct transvr_worker_s *pre_p = NULL; - struct transvr_worker_s *next_p = NULL; - - if (task_p) { - pre_p = task_p->pre_p; - next_p = task_p->next_p; - - if ((pre_p) && (next_p)) { - pre_p->next_p = next_p; - next_p->pre_p = pre_p; - - } else if ((!pre_p) && (next_p)) { - next_p->pre_p = NULL; - - } else if ((pre_p) && (!next_p)) { - pre_p->next_p = NULL; - - } else if ((!pre_p) && (!next_p)) { - task_p->transvr_p->worker_p = NULL; - } else { - SWPS_ERR("%s: Unexcept case!\n :%s", - __func__, task_p->transvr_p->swp_name); - } - kfree(task_p->p_data); - kfree(task_p); - } -} - - -static void -transvr_task_free_all(struct transvr_obj_s *self) { - - struct transvr_worker_s *curr_p = NULL; - struct transvr_worker_s *next_p = NULL; - - if (self->worker_p) { - curr_p = self->worker_p; - while(curr_p) { - next_p = curr_p->next_p; - transvr_task_free_one(curr_p); - curr_p = next_p; - } - self->worker_p = NULL; - } -} - - -static void -transvr_cache_free_all(struct transvr_obj_s *self) { - - memset(self->vendor_name, 0, (LEN_TRANSVR_M_STR * sizeof(char)) ); - memset(self->vendor_rev, 0, (LEN_TRANSVR_M_STR * sizeof(char)) ); - memset(self->vendor_pn, 0, (LEN_TRANSVR_M_STR * sizeof(char)) ); - memset(self->vendor_sn, 0, (LEN_TRANSVR_M_STR * sizeof(char)) ); - self->extphy_offset = 0; -} - -static int -_transvr_task_run_main(struct transvr_worker_s *task_p) { - - int retval = DEBUG_TRANSVR_INT_VAL; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - - if (!task_p){ - snprintf(err_msg, sizeof(err_msg), "main_task is NULL!"); - goto main_transvr_task_err; - } - if ((task_p->trigger_time) == 0){ - goto main_transvr_task_run; - } - if (time_before(jiffies, task_p->trigger_time)){ - goto main_transvr_task_wait; - } - goto main_transvr_task_run; - -main_transvr_task_run: - if (task_p->retry != VAL_TRANSVR_TASK_RETRY_FOREVER) { - task_p->retry -= 1; - } - retval = task_p->main_task(task_p); - if (retval < 0) { - if (task_p->retry > 0) { - task_p->state = STATE_T_TASK_WAIT; - return EVENT_TRANSVR_TASK_WAIT; - } - snprintf(err_msg, sizeof(err_msg), "Run main_task fail!"); - goto main_transvr_task_err; - } - goto main_transvr_task_identify; - -main_transvr_task_identify: - switch (retval) { - case EVENT_TRANSVR_TASK_WAIT: - task_p->state = STATE_T_TASK_WAIT; - return EVENT_TRANSVR_TASK_WAIT; - - case EVENT_TRANSVR_TASK_DONE: - task_p->state = STATE_T_TASK_DONE; - return EVENT_TRANSVR_TASK_DONE; - - default: - break; - } - snprintf(err_msg, sizeof(err_msg), "Run main_task fail!"); - goto main_transvr_task_err; - -main_transvr_task_wait: - task_p->state = STATE_T_TASK_WAIT; - return EVENT_TRANSVR_TASK_WAIT; - -main_transvr_task_err: - task_p->state = STATE_T_TASK_FAIL; - SWPS_INFO("%s: %s :%d :%s\n", - __func__, err_msg, retval, task_p->transvr_p->swp_name); - return EVENT_TRANSVR_INIT_FAIL; -} - - -static int -_transvr_task_run_post(struct transvr_worker_s *task_p) { - - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - - if ((task_p->post_task) == NULL) { - return EVENT_TRANSVR_TASK_DONE; - } - switch (task_p->state) { - case STATE_T_TASK_WAIT: - case STATE_T_TASK_INIT: - goto post_transvr_task_wait; - - case STATE_T_TASK_DONE: - case STATE_T_TASK_FAIL: - goto post_transvr_task_run; - - default: - break; - } - snprintf(err_msg, sizeof(err_msg), "Unexcept task state"); - goto post_transvr_task_err; - -post_transvr_task_run: - task_p->post_task(task_p); - return EVENT_TRANSVR_TASK_DONE; - -post_transvr_task_wait: - return EVENT_TRANSVR_TASK_WAIT; - -post_transvr_task_err: - SWPS_INFO("%s: %s :%d :%s\n", - __func__, err_msg, task_p->state, task_p->transvr_p->swp_name); - return EVENT_TRANSVR_TASK_FAIL; -} - - -static int -transvr_task_run_one(struct transvr_worker_s *task_p) { - - int retval_main = DEBUG_TRANSVR_INT_VAL; - int retval_post = DEBUG_TRANSVR_INT_VAL; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - - retval_main = _transvr_task_run_main(task_p); - if (retval_main < 0) { - snprintf(err_msg, sizeof(err_msg), "Execute main_task fail!"); - goto err_transvr_task_run_one; - } - retval_post = _transvr_task_run_post(task_p); - if (retval_post < 0) { - snprintf(err_msg, sizeof(err_msg), "Execute post_task fail!"); - goto err_transvr_task_run_one; - } - return retval_main; - -err_transvr_task_run_one: - SWPS_INFO("%s: %s
:%d :%d :%s :%s\n", - __func__, err_msg, retval_main, retval_post, - task_p->func_name, task_p->transvr_p->swp_name); - return EVENT_TRANSVR_TASK_FAIL; -} - - -static int -transvr_task_run_all(struct transvr_obj_s *self) { - - int haserr = 0; - int retval = DEBUG_TRANSVR_INT_VAL; - struct transvr_worker_s *curr_p = NULL; - struct transvr_worker_s *next_p = NULL; - - if ((self->worker_p) == NULL) { - return EVENT_TRANSVR_TASK_DONE; - } - curr_p = self->worker_p; - while (curr_p != NULL) { - next_p = curr_p->next_p; - retval = transvr_task_run_one(curr_p); - if (curr_p->retry == VAL_TRANSVR_TASK_RETRY_FOREVER) { - curr_p = next_p; - continue; - } - switch (retval) { - case EVENT_TRANSVR_TASK_WAIT: - break; - case EVENT_TRANSVR_TASK_DONE: - transvr_task_free_one(curr_p); - break; - case EVENT_TRANSVR_TASK_FAIL: - - default: - haserr = 1; - transvr_task_free_one(curr_p); - break; - } - curr_p = next_p; - } - if (haserr) { - return EVENT_TRANSVR_TASK_FAIL; - } - return EVENT_TRANSVR_TASK_DONE; -} - - -static void -transvr_task_set_delay(struct transvr_worker_s *task_p, - unsigned long delay_msec) { - - task_p->trigger_time = (jiffies + (delay_msec * (HZ/1000))); -} - - -static void -transvr_task_set_retry(struct transvr_worker_s *task_p, - unsigned long retry_times) { - - task_p->retry = retry_times; -} - - -/* For Transceiver Post Task - */ -int -taskfunc_post_do_nothing(struct transvr_worker_s *task_p) { - - return EVENT_TRANSVR_TASK_DONE; -} - - -int -taskfunc_post_handle_task_state(struct transvr_worker_s *task_p) { - - struct transvr_obj_s* tp = task_p->transvr_p; - - switch (task_p->state) { - case STATE_T_TASK_INIT: - case STATE_T_TASK_WAIT: - return EVENT_TRANSVR_TASK_WAIT; - - case STATE_T_TASK_DONE: - tp->state = STATE_TRANSVR_CONNECTED; - tp->send_uevent(tp, KOBJ_ADD); - return EVENT_TRANSVR_TASK_DONE; - - case STATE_T_TASK_FAIL: - tp->state = STATE_TRANSVR_UNEXCEPTED; - return EVENT_TRANSVR_TASK_FAIL; - - default: - break; - } - return EVENT_TRANSVR_TASK_FAIL; -} - - -/* For Transceiver Main Task - */ -int -_taskfunc_sfp_setup_soft_rs(struct transvr_worker_s *task_p, - int input_val, - int address, - int page, - int offset, - int bit_shift, - uint8_t *attr_p, - char *caller) { - - int show_err = 0; - int err_code = DEBUG_TRANSVR_INT_VAL; - char *err_str = DEBUG_TRANSVR_STR_VAL; - char *func_str = "_taskfunc_sfp_setup_soft_rs"; - - err_code = _sfp_update_attr_soft_rs0(task_p->transvr_p, 0); - if (err_code < 0) { - err_str = "Get current soft_rs0 fail!"; - goto err_taskfunc_sfp_setup_soft_rs_1; - } - err_code = __sfp_set_soft_rs(task_p->transvr_p, - input_val, - address, - page, - offset, - bit_shift, - attr_p, - caller, - show_err); - if (err_code < 0) { - err_str = "Get current soft_rs0 fail!"; - goto err_taskfunc_sfp_setup_soft_rs_1; - } - return EVENT_TRANSVR_TASK_DONE; - -err_taskfunc_sfp_setup_soft_rs_1: - if ((task_p->retry) == 0) { - SWPS_INFO("%s: %s :%s :%d :%d\n", - func_str, err_str, task_p->transvr_p->swp_name, input_val, err_code); - } - return EVENT_TRANSVR_TASK_FAIL; -} - - -int -__taskfunc_sfp_setup_hard_rs(struct transvr_worker_s *task_p, - int input_val, - int (*get_func)(struct ioexp_obj_s *self, int virt_offset), - int (*set_func)(struct ioexp_obj_s *self, int virt_offset, int input_val)) { - - int err_val = EVENT_TRANSVR_EXCEP_EXCEP; - char *err_str = DEBUG_TRANSVR_STR_VAL; - - err_val = get_func(task_p->transvr_p->ioexp_obj_p, - task_p->transvr_p->ioexp_virt_offset); - - if (err_val < 0) { - if (err_val == ERR_IOEXP_NOTSUPPORT) { - return EVENT_TRANSVR_TASK_DONE; - } - err_str = "Get current hard_rs fail!"; - goto err_p_taskfunc_sfp_setup_hard_rs_1; - } - if (err_val == input_val) { - return EVENT_TRANSVR_TASK_DONE; - } - err_val = set_func(task_p->transvr_p->ioexp_obj_p, - task_p->transvr_p->ioexp_virt_offset, - input_val); - if (err_val < 0) { - err_str = "Setup hard_rs fail!"; - goto err_p_taskfunc_sfp_setup_hard_rs_1; - } - return EVENT_TRANSVR_TASK_DONE; - -err_p_taskfunc_sfp_setup_hard_rs_1: - if ((task_p->retry) == 0) { - SWPS_INFO("%s: %s :%s :%d :%d\n", - __func__, err_str, task_p->transvr_p->swp_name, input_val, err_val); - } - return EVENT_TRANSVR_TASK_FAIL; -} - - -int -_taskfunc_sfp_setup_hard_rs0(struct transvr_worker_s *task_p, - int input_val) { - - return __taskfunc_sfp_setup_hard_rs(task_p, - input_val, - task_p->transvr_p->ioexp_obj_p->get_hard_rs0, - task_p->transvr_p->ioexp_obj_p->set_hard_rs0); -} - - -int -_taskfunc_sfp_setup_hard_rs1(struct transvr_worker_s *task_p, - int input_val) { - - return __taskfunc_sfp_setup_hard_rs(task_p, - input_val, - task_p->transvr_p->ioexp_obj_p->get_hard_rs1, - task_p->transvr_p->ioexp_obj_p->set_hard_rs1); -} - - -int -_taskfunc_sfp_setup_rs0(struct transvr_worker_s *task_p, - int input_val) { - - int bit_shift = 3; - int old_val = DEBUG_TRANSVR_INT_VAL; - int err_val = EVENT_TRANSVR_EXCEP_EXCEP; - char *err_str = DEBUG_TRANSVR_STR_VAL; - char *func_str = "_taskfunc_sfp_setup_rs0"; - - err_val = _taskfunc_sfp_setup_hard_rs0(task_p, - input_val); - if (err_val < 0) { - err_str = "Setup hard_rs0 fail!"; - goto err_private_taskfunc_sfp_setup_rs0_1; - } - old_val = err_val; - err_val = _taskfunc_sfp_setup_soft_rs(task_p, - input_val, - task_p->transvr_p->eeprom_map_p->addr_soft_rs0, - task_p->transvr_p->eeprom_map_p->page_soft_rs0, - task_p->transvr_p->eeprom_map_p->offset_soft_rs0, - bit_shift, - &(task_p->transvr_p->soft_rs0), - func_str); - if (err_val < 0) { - err_str = "Setup soft_rs0 fail!"; - goto err_private_taskfunc_sfp_setup_rs0_1; - } - return EVENT_TRANSVR_TASK_DONE; - -err_private_taskfunc_sfp_setup_rs0_1: - if ((task_p->retry) == 0) { - SWPS_INFO("%s: %s :%s :%d :%d\n", - func_str, err_str, task_p->transvr_p->swp_name, input_val, err_val); - } - _taskfunc_sfp_setup_hard_rs0(task_p, old_val); - return EVENT_TRANSVR_TASK_FAIL; -} - - -int -_taskfunc_sfp_setup_rs1(struct transvr_worker_s *task_p, - int input_val) { - - int bit_shift = 3; - int old_val = DEBUG_TRANSVR_INT_VAL; - int err_val = EVENT_TRANSVR_EXCEP_EXCEP; - char *err_str = DEBUG_TRANSVR_STR_VAL; - char *func_str = "_taskfunc_sfp_setup_rs1"; - - err_val = _taskfunc_sfp_setup_hard_rs1(task_p, - input_val); - if (err_val < 0) { - err_str = "Setup hard_rs1 fail!"; - goto err_private_taskfunc_sfp_setup_rs1_1; - } - old_val = err_val; - err_val = _taskfunc_sfp_setup_soft_rs(task_p, - input_val, - task_p->transvr_p->eeprom_map_p->addr_soft_rs1, - task_p->transvr_p->eeprom_map_p->page_soft_rs1, - task_p->transvr_p->eeprom_map_p->offset_soft_rs1, - bit_shift, - &(task_p->transvr_p->soft_rs1), - func_str); - if (err_val < 0) { - err_str = "Setup soft_rs1 fail!"; - goto err_private_taskfunc_sfp_setup_rs1_1; - } - return EVENT_TRANSVR_TASK_DONE; - -err_private_taskfunc_sfp_setup_rs1_1: - if ((task_p->retry) == 0) { - SWPS_INFO("%s: %s :%s :%d :%d\n", - func_str, err_str, task_p->transvr_p->swp_name, input_val, err_val); - } - _taskfunc_sfp_setup_hard_rs1(task_p, old_val); - return EVENT_TRANSVR_TASK_FAIL; -} - - -int -taskfunc_sfp_setup_SFF8431_case1(struct transvr_worker_s *task_p) { - /* SFF-8431 (8/4/2G Rx Rate_Select only) */ - int update_val = 1; - - return _taskfunc_sfp_setup_rs0(task_p, update_val); -} - - - -int -taskfunc_sfp_setup_SFF8431_case2(struct transvr_worker_s *task_p) { - /* SFF-8431 (8/4/2G Tx Rate_Select only) */ - int update_val = 1; - - return _taskfunc_sfp_setup_rs1(task_p, update_val); -} - - -int -taskfunc_sfp_setup_SFF8431_case3(struct transvr_worker_s *task_p) { - /* SFF-8431 (8/4/2G Independent Rx & Tx Rate_select) */ - int update_rs0 = 1; - int update_rs1 = 1; - int err_code = DEBUG_TRANSVR_INT_VAL; - - err_code = _taskfunc_sfp_setup_rs0(task_p, update_rs0); - if (err_code < 0) { - return err_code; - } - return _taskfunc_sfp_setup_rs1(task_p, update_rs1); -} - - -int -taskfunc_sfp_handle_1g_rj45(struct transvr_worker_s *task_p) { - - /* Not all of platform support 0x56 for transceiver - * external PHY, Support list as below: - * => 1. Magnolia-PVT (PS: EVT & DVT not ready) - */ - int ext_phy_addr = 0x56; - int ext_phy_page = -1; - int ext_phy_offs = 0x11; - int ext_phy_len = 1; - int lstate_mask = 0x04; /* 00000100 */ - int show_err = 0; - int fail_retry = 5; - int fail_delay = 1000; /* msec */ - int err_code = DEBUG_TRANSVR_INT_VAL; - uint8_t detect_val = DEBUG_TRANSVR_HEX_VAL; - char err_str[64] = DEBUG_TRANSVR_STR_VAL; - int *tmp_p = NULL; - char *func_name = "taskfunc_sfp_handle_1g_rj45"; - - if (task_p->transvr_p->state != STATE_TRANSVR_CONNECTED) { - return EVENT_TRANSVR_TASK_DONE; - } - if ( (task_p->transvr_p->info != TRANSVR_CLASS_BASE_T_1000) && - (task_p->transvr_p->info != TRANSVR_CLASS_BASE_T_1000_up) ) { - goto err_taskfunc_sfp_handle_1g_rj45_1; - } - err_code = _common_update_uint8_attr(task_p->transvr_p, - ext_phy_addr, - ext_phy_page, - ext_phy_offs, - ext_phy_len, - &detect_val, - func_name, - show_err); - if ( (err_code < 0) || - (detect_val == DEBUG_TRANSVR_HEX_VAL) ) { - snprintf(err_str, sizeof(err_str), "Detect external link status fail"); - goto err_taskfunc_sfp_handle_1g_rj45_2; - } - if ((detect_val & lstate_mask) == lstate_mask) { - goto ok_taskfunc_sfp_handle_1g_rj45_link_up; - } - goto ok_taskfunc_sfp_handle_1g_rj45_link_down; - -ok_taskfunc_sfp_handle_1g_rj45_link_up: - /* Filter out noise */ - if (!(task_p->p_data)) { - tmp_p = kzalloc(sizeof(int), GFP_KERNEL); - if (!tmp_p) { - snprintf(err_str, sizeof(err_str), "kzalloc p_data fail"); - goto err_taskfunc_sfp_handle_1g_rj45_2; - } - *tmp_p = TRANSVR_CLASS_BASE_T_1000_up; - task_p->p_data = tmp_p; - goto ok_taskfunc_sfp_handle_1g_rj45_done; - } - if ((*(int *)(task_p->p_data)) != TRANSVR_CLASS_BASE_T_1000_up) { - kfree(task_p->p_data); - task_p->p_data = NULL; - snprintf(err_str, sizeof(err_str), "Internal error"); - goto err_taskfunc_sfp_handle_1g_rj45_2; - } - task_p->transvr_p->info = TRANSVR_CLASS_BASE_T_1000_up; - kfree(task_p->p_data); - task_p->p_data = NULL; - goto ok_taskfunc_sfp_handle_1g_rj45_done; - -ok_taskfunc_sfp_handle_1g_rj45_link_down: - if (task_p->p_data) { - kfree(task_p->p_data); - task_p->p_data = NULL; - } - task_p->transvr_p->info = TRANSVR_CLASS_BASE_T_1000; - goto ok_taskfunc_sfp_handle_1g_rj45_done; - -ok_taskfunc_sfp_handle_1g_rj45_done: - if (task_p->retry != VAL_TRANSVR_TASK_RETRY_FOREVER) { - transvr_task_set_retry(task_p, VAL_TRANSVR_TASK_RETRY_FOREVER); - } - return EVENT_TRANSVR_TASK_DONE; - -err_taskfunc_sfp_handle_1g_rj45_1: - snprintf(err_str, sizeof(err_str), "Detect transceiver:%d not Base-T, remove task.", - task_p->transvr_p->info); - SWPS_INFO("%s: %s :%s\n", __func__, err_str, task_p->transvr_p->swp_name); - transvr_task_set_retry(task_p, 0); - return EVENT_TRANSVR_TASK_DONE; - -err_taskfunc_sfp_handle_1g_rj45_2: - if (task_p->retry == VAL_TRANSVR_TASK_RETRY_FOREVER) { - transvr_task_set_retry(task_p, fail_retry); - } - if ((task_p->retry) == 0) { - /* Error case: - * => In this case, SWPS will stop external Link state monitor features - * and keeps transvr_p->info on TRANSVR_CLASS_BASE_T_1000_up. - * Upper layer will see it always Linkup that because of these type of - * transceiver has external phy, switch chip see it as Loopback transceiver. - */ - SWPS_WARN("%s can not access external PHY of Base-T SFP transceiver\n", - task_p->transvr_p->swp_name); - task_p->transvr_p->info = TRANSVR_CLASS_BASE_T_1000_up; - return EVENT_TRANSVR_TASK_DONE; - } else { - transvr_task_set_delay(task_p, fail_delay); - } - return EVENT_TRANSVR_TASK_FAIL; -} - - -int -_taskfunc_qsfp_setup_power_mod(struct transvr_obj_s *self, - int setup_val) { - - int curr_val = DEBUG_TRANSVR_INT_VAL; - int err_val = DEBUG_TRANSVR_INT_VAL; - char *err_msg = DEBUG_TRANSVR_STR_VAL; - if (io_no_init) { - - SWPS_INFO("%s no_io_init\n",__func__); - return EVENT_TRANSVR_TASK_DONE; - } - - curr_val = self->ioexp_obj_p->get_lpmod(self->ioexp_obj_p, - self->ioexp_virt_offset); - if (curr_val < 0){ - err_msg = "Get current value fail!"; - goto err_private_taskfunc_qsfp_setup_power_mod_1; - } - if (curr_val == setup_val){ - return EVENT_TRANSVR_TASK_DONE; - } - err_val = self->ioexp_obj_p->set_lpmod(self->ioexp_obj_p, - self->ioexp_virt_offset, - setup_val); - if (err_val < 0){ - err_msg = "Setup power mode fail!"; - goto err_private_taskfunc_qsfp_setup_power_mod_1; - } - return EVENT_TRANSVR_TASK_DONE; - -err_private_taskfunc_qsfp_setup_power_mod_1: - SWPS_INFO("%s: %s :%d :%d :%d\n", - __func__, err_msg, err_val, curr_val, setup_val); - return EVENT_TRANSVR_TASK_FAIL; -} - - -int -taskfunc_qsfp_handle_tx_disable(struct transvr_worker_s *task_p) { - - int i = 0; - int retry = 5; - int delay_ms = 100; - - if (task_p->transvr_p->auto_tx_disable == VAL_TRANSVR_FUNCTION_DISABLE) { - return EVENT_TRANSVR_TASK_DONE; - } - if (!_qsfp_is_implement_tx_disable(task_p->transvr_p)) { - return EVENT_TRANSVR_TASK_DONE; - } - for (i=0; itransvr_p, - task_p->transvr_p->auto_tx_disable) - == EVENT_TRANSVR_TASK_DONE) { - goto ok_taskfunc_qsfp_handle_tx_disable; - } - mdelay(delay_ms); - } - SWPS_INFO("%s auto setup tx_disable:0x%02x fail.\n", - task_p->transvr_p->swp_name, - task_p->transvr_p->auto_tx_disable); - return EVENT_TRANSVR_INIT_FAIL; - -ok_taskfunc_qsfp_handle_tx_disable: - SWPS_INFO("%s auto setup tx_disable:0x%02x ok.\n", - task_p->transvr_p->swp_name, - task_p->transvr_p->auto_tx_disable); - return EVENT_TRANSVR_TASK_DONE; -} - - -int -taskfunc_qsfp_set_hpmod(struct transvr_worker_s *task_p) { - - int err = DEBUG_TRANSVR_INT_VAL; - int HIGH_POWER_MODE = 0; - - /* Handle power mode */ - err = _taskfunc_qsfp_setup_power_mod(task_p->transvr_p, - HIGH_POWER_MODE); - if (err < 0) { - SWPS_INFO("%s: setup hpmod fail :%d :%s\n", - __func__, err, task_p->transvr_p->swp_name); - return err; - } - /* Handle auto tx_disable - * [Note] - * => Because there are some transceiver have timing issues or - * setup sequence issues, therefore we handle auto tx_disable - * after handle power mode. - */ - mdelay(100); - return taskfunc_qsfp_handle_tx_disable(task_p); -} - - -int -taskfunc_qsfp_set_lpmod(struct transvr_worker_s *task_p) { - - int LOW_POWER_MODE = 1; - return _taskfunc_qsfp_setup_power_mod(task_p->transvr_p, - LOW_POWER_MODE); -} - - -static int -initfunc_sfp_handle_multi_rate_mode(struct transvr_obj_s *self) { - - int task_retry = 3; - int err_code = DEBUG_TRANSVR_INT_VAL; - char *err_str = DEBUG_TRANSVR_STR_VAL; - char *func_str = "sfp_handle_multi_rate_mode"; - struct transvr_worker_s *task_p = NULL; - - switch (self->rate_id) { - case 0x00: /* Unspecified */ - case 0x03: /* Unspecified */ - case 0x05: /* Unspecified */ - case 0x07: /* Unspecified */ - case 0x09: /* Unspecified */ - case 0x0B: /* Unspecified */ - case 0x0D: /* Unspecified */ - case 0x0F: /* Unspecified */ - goto sfp_handle_multi_rate_mode_4_unspecified; - - case 0x02: /* SFF-8431 (8/4/2G Rx Rate_Select only) */ - task_p = transvr_task_creat(self, - taskfunc_sfp_setup_SFF8431_case1, - taskfunc_post_handle_task_state, - func_str); - goto sfp_handle_multi_rate_mode_4_sff8431; - - case 0x04: /* SFF-8431 (8/4/2G Tx Rate_Select only) */ - task_p = transvr_task_creat(self, - taskfunc_sfp_setup_SFF8431_case2, - taskfunc_post_handle_task_state, - func_str); - goto sfp_handle_multi_rate_mode_4_sff8431; - - case 0x06: /* SFF-8431 (8/4/2G Independent Rx & Tx Rate_select) */ - task_p = transvr_task_creat(self, - taskfunc_sfp_setup_SFF8431_case3, - taskfunc_post_handle_task_state, - func_str); - goto sfp_handle_multi_rate_mode_4_sff8431; - - case 0x01: /* SFF-8079 (4/2/1G Rate_Select & AS0/AS1) */ - err_str = "SFF-8079 (4/2/1G Rate_Select & AS0/AS1)"; - goto sfp_handle_multi_rate_mode_4_not_support; - - case 0x08: /* FC-PI-5 (16/8/4G Rx Rate_select only) - * High=16G only, Low=8G/4G - */ - err_str = "FC-PI-5 (16/8/4G Rx Rate_select only)"; - goto sfp_handle_multi_rate_mode_4_not_support; - - case 0x0A: /* FC-PI-5 (16/8/4G Independent Rx, Tx Rate_select) - * High=16G only, Low=8G/4G - */ - err_str = "FC-PI-5 (16/8/4G Independent Rx, Tx Rate_select)"; - goto sfp_handle_multi_rate_mode_4_not_support; - - case 0x0C: /* FC-PI-6 (32/16/8G Independent Rx, Tx Rate_Select) - * High=32G only, Low = 16G/8G - */ - err_str = "FC-PI-6 (32/16/8G Independent Rx, Tx Rate_Select)"; - goto sfp_handle_multi_rate_mode_4_not_support; - - case 0x0E: /* 10/8G Rx and Tx Rate_Select controlling the operation or - * locking modes of the internal signal conditioner, retimer - * or CDR, according to the logic table defined in Table 10-2, - * High Bit Rate (10G) =9.95-11.3 Gb/s; Low Bit Rate (8G) = - * 8.5 Gb/s. In this mode, the default value of bit 110.3 (Soft - * Rate Select RS(0), Table 9-11) and of bit 118.3 (Soft Rate - * Select RS(1), Table 10-1) is 1. - */ - err_str = "cable type: 0x0E"; - goto sfp_handle_multi_rate_mode_4_not_support; - - default: - err_str = "cable type: UNKNOW"; - goto sfp_handle_multi_rate_mode_4_not_support; - } - -sfp_handle_multi_rate_mode_4_sff8431: - if (!task_p) { - err_str = "Create task fail!"; - goto sfp_handle_multi_rate_mode_4_fail_1; - } - transvr_task_set_retry(task_p, task_retry); - return EVENT_TRANSVR_TASK_WAIT; - -sfp_handle_multi_rate_mode_4_unspecified: - return EVENT_TRANSVR_TASK_DONE; - -sfp_handle_multi_rate_mode_4_not_support: - SWPS_INFO("%s: Does not support %s :%s :0x%02x\n", - func_str, err_str, self->swp_name, self->rate_id); - return EVENT_TRANSVR_TASK_DONE; - -sfp_handle_multi_rate_mode_4_fail_1: - SWPS_INFO("%s: %s :%s :0x%02x, :%d\n", - func_str, err_str, self->swp_name, self->rate_id, err_code); - return EVENT_TRANSVR_INIT_FAIL; -} - - -static int -initfunc_sfp_handle_1g_rj45(struct transvr_obj_s *self) { - - struct transvr_worker_s *task_p = NULL; - int detect_cls = DEBUG_TRANSVR_INT_VAL; - char err_str[64] = DEBUG_TRANSVR_STR_VAL; - char *func_str = "initfunc_sfp_handle_1g_rj45"; - - - if (self->info == TRANSVR_CLASS_BASE_T_1000) { - task_p = transvr_task_creat(self, - taskfunc_sfp_handle_1g_rj45, - taskfunc_post_do_nothing, - func_str); - if (!task_p) { - snprintf(err_str, sizeof(err_str), "Create task fail"); - goto err_initfunc_sfp_handle_1g_rj45; - } - transvr_task_set_retry(task_p, VAL_TRANSVR_TASK_RETRY_FOREVER); - } - return EVENT_TRANSVR_TASK_DONE; - -err_initfunc_sfp_handle_1g_rj45: - SWPS_INFO("%s: %s :%s :%d\n", - __func__, err_str, self->swp_name, detect_cls); - return EVENT_TRANSVR_TASK_FAIL; -} - - -static int -initfunc_qsfp_handle_power_mode(struct transvr_obj_s *self) { - - int err_code = EVENT_TRANSVR_EXCEP_INIT; - int power_class = DEBUG_TRANSVR_INT_VAL; - int hpmod_retry = 3; - int lpower_config = 1; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - unsigned long hpmod_delay = 500; /* msec */ - struct transvr_worker_s *task_p = NULL; - - /* Handle power mode for IOEXP */ - power_class = __qsfp_get_power_cls(self, 0); - switch (power_class) { - case 1: /* Case: Low power mode (Class = 1) */ - err_code = _taskfunc_qsfp_setup_power_mod(self, lpower_config); - if (err_code < 0){ - snprintf(err_msg, sizeof(err_msg), "Setup lpmod fail :%d", err_code); - goto err_initfunc_qsfp_handle_power_mode; - } - return EVENT_TRANSVR_TASK_DONE; - - case 2: /* Case: High power mode (Class > 1) */ - case 3: - case 4: - case 5: - case 6: - case 7: - task_p = transvr_task_creat(self, - taskfunc_qsfp_set_hpmod, - taskfunc_post_handle_task_state, - "transvr_init_qsfp"); - if (!task_p) { - snprintf(err_msg, sizeof(err_msg), "Setup lpmod fail :%d", err_code); - goto err_initfunc_qsfp_handle_power_mode; - } - transvr_task_set_retry(task_p, hpmod_retry); - transvr_task_set_delay(task_p, hpmod_delay); - return EVENT_TRANSVR_TASK_WAIT; - - default: - break; - } - snprintf(err_msg, sizeof(err_msg), "Exception case"); - goto err_initfunc_qsfp_handle_power_mode; - -err_initfunc_qsfp_handle_power_mode: - SWPS_INFO("%s: %s :%s \n", __func__, err_msg, self->swp_name); - return EVENT_TRANSVR_INIT_FAIL; -} - - -int -initfunc_qsfp28_handle_cdr(struct transvr_obj_s *self) { - - uint8_t DEFAULT_VAL_CDR = 0xff; - int CDR_FUNC_EXISTED = 0x3; - int show_err = 1; - int err_val = EVENT_TRANSVR_TASK_FAIL; - char *err_msg = DEBUG_TRANSVR_STR_VAL; - char *func_str = "initfunc_qsfp28_handle_cdr"; - - err_val = __qsfp_get_cdr_present(self, 0); - if ( (err_val < 0) || - (err_val == DEBUG_TRANSVR_HEX_VAL) ) { - err_msg = "detect cdr_present fail!"; - goto err_taskfunc_qsfp_handle_cdr_1; - } - if (err_val == CDR_FUNC_EXISTED) { - err_val = _common_set_uint8_attr(self, - self->eeprom_map_p->addr_cdr, - self->eeprom_map_p->addr_cdr, - self->eeprom_map_p->offset_cdr, - DEFAULT_VAL_CDR, - &(self->cdr), - func_str, - show_err); - if (err_val < 0) { - err_msg = "set CDR fail!"; - goto err_taskfunc_qsfp_handle_cdr_1; - } - } - return EVENT_TRANSVR_TASK_DONE; - -err_taskfunc_qsfp_handle_cdr_1: - SWPS_INFO("%s: %s :%d :%s\n", - func_str, err_msg, err_val, self->swp_name); - return EVENT_TRANSVR_INIT_FAIL; -} - -/* ========== Object functions for Final State Machine ========== - */ -int -is_plugged(struct transvr_obj_s *self){ - - int limit = 63; - int present = DEBUG_TRANSVR_INT_VAL; - char emsg[64] = DEBUG_TRANSVR_STR_VAL; - struct ioexp_obj_s *ioexp_p = self->ioexp_obj_p; - - if (!ioexp_p) { - snprintf(emsg, limit, "ioexp_p is null!"); - goto err_is_plugged_1; - } - present = ioexp_p->get_present(ioexp_p, self->ioexp_virt_offset); - switch (present){ - case 0: - return 1; - case 1: - return 0; - case ERR_IOEXP_UNINIT: - snprintf(emsg, limit, "ioexp_p not ready!"); - goto err_is_plugged_1; - default: - if (ioexp_p->state == STATE_IOEXP_INIT){ - snprintf(emsg, limit, "ioexp_p not ready!"); - goto err_is_plugged_1; - } - break; - } - SWPS_INFO("%s: Exception case! :%d :%d\n", - __func__, present, ioexp_p->state); - return 0; - -err_is_plugged_1: - SWPS_DEBUG("%s: %s\n", __func__, emsg); - return 0; -} - - -static int -detect_transvr_type(struct transvr_obj_s* self){ - - int type = TRANSVR_TYPE_ERROR; - - self->i2c_client_p->addr = VAL_TRANSVR_COMID_ARREESS; - type = i2c_smbus_read_byte_data(self->i2c_client_p, - VAL_TRANSVR_COMID_OFFSET); - - /* Case: 1. Wait transceiver I2C module. - * 2. Transceiver I2C module failure. - * Note: 1. SFF allow maximum transceiver initial time is 2 second. So, there - * are exist some case that we need to wait transceiver. - * For these case, we keeps status on "TRANSVR_TYPE_UNPLUGGED", than - * state machine will keep trace with it. - * 2. There exist some I2C failure case we need to handle. Such as user - * insert the failure transceiver, or any reason cause it abnormal. - */ - if (type < 0){ - switch (type) { - case -EIO: - SWPS_DEBUG("%s: %s smbus return:-5 (I/O error)\n", - __func__, self->swp_name); - return TRANSVR_TYPE_UNPLUGGED; - case -ENXIO: - SWPS_DEBUG("%s: %s smbus return:-6 (No such device or address)\n", - __func__, self->swp_name); - return TRANSVR_TYPE_UNPLUGGED; - default: - break; - } - SWPS_INFO("%s: %s unexpected smbus return:%d \n", - __func__, self->swp_name, type); - return TRANSVR_TYPE_ERROR; - } - /* Identify valid transceiver type */ - switch (type){ - case TRANSVR_TYPE_SFP: - case TRANSVR_TYPE_QSFP: - case TRANSVR_TYPE_QSFP_PLUS: - case TRANSVR_TYPE_QSFP_28: - break; - case TRANSVR_TYPE_UNKNOW_1: - case TRANSVR_TYPE_UNKNOW_2: - type = TRANSVR_TYPE_UNKNOW_2; - break; - default: - SWPS_DEBUG("%s: unknow type:0x%02x \n", __func__, type); - type = TRANSVR_TYPE_ERROR; - break; - } - return type; -} - - -static int -detect_transvr_state(struct transvr_obj_s *self, - int result[2]){ - /* [return] [result-0] [result-1] - * 0 STATE_TRANSVR_CONNECTED TRANSVR_TYPE_FAKE - * 0 STATE_TRANSVR_DISCONNECTED TRANSVR_TYPE_UNPLUGGED - * 0 STATE_TRANSVR_ISOLATED TRANSVR_TYPE_ERROR - * 0 STATE_TRANSVR_INIT / - * 0 STATE_TRANSVR_SWAPPED - * 0 STATE_TRANSVR_CONNECTED - * ERR_TRNASVR_BE_ISOLATED STATE_TRANSVR_ISOLATED TRANSVR_TYPE_ERROR - * ERR_TRANSVR_I2C_CRASH STATE_TRANSVR_UNEXCEPTED TRANSVR_TYPE_ERROR - * ERR_TRANSVR_UNEXCPT STATE_TRANSVR_UNEXCEPTED TRANSVR_TYPE_UNKNOW_1/2 - */ - result[0] = STATE_TRANSVR_UNEXCEPTED; /* For return state */ - result[1] = TRANSVR_TYPE_ERROR; /* For return type */ - - /* Case1: Fake type */ - if (self->type == TRANSVR_TYPE_FAKE){ - result[0] = STATE_TRANSVR_CONNECTED; - result[1] = TRANSVR_TYPE_FAKE; - return 0; - } - /* Case2: Transceiver unplugged */ - if (!is_plugged(self)){ - result[0] = STATE_TRANSVR_DISCONNECTED; - result[1] = TRANSVR_TYPE_UNPLUGGED; - return 0; - } - /* Case3: Transceiver be isolated */ - if (self->state == STATE_TRANSVR_ISOLATED){ - result[0] = STATE_TRANSVR_ISOLATED; - result[1] = TRANSVR_TYPE_ERROR; - return ERR_TRNASVR_BE_ISOLATED; - } - /* Case4: Transceiver plugged */ - result[1] = detect_transvr_type(self); - /* Case4.1: I2C topology crash - * Note : There are some I2C issues cause by transceiver/cables. - * We need to check topology status when user insert it. - * But in this step, we can't not ensure this is the issues - * port. So, it return the ERR_TRANSVR_I2C_CRASH, then upper - * layer will diagnostic I2C topology. - */ - if (check_channel_tier_1() < 0) { - SWPS_INFO("%s: %s detect I2C crash :%d\n", - __func__, self->swp_name, self->state); - result[0] = STATE_TRANSVR_UNEXCEPTED; - result[1] = TRANSVR_TYPE_ERROR; - return ERR_TRANSVR_I2C_CRASH; - } - /* Case4.2: System initial not ready, - * Note : Sometime i2c channel or transceiver EEPROM will delay that will - * cause system in inconsistent state between EEPROM and IOEXP. - * In this case, SWP transceiver object keep state at LINK_DOWN - * to wait system ready. - * By the way, State Machine will handle these case. - */ - if (result[1] == TRANSVR_TYPE_UNPLUGGED){ - result[0] = STATE_TRANSVR_DISCONNECTED; - return 0; - } - /* Case4.3: Error transceiver type */ - if (result[1] == TRANSVR_TYPE_ERROR){ - result[0] = STATE_TRANSVR_ISOLATED; - SWPS_INFO("%s: %s detect error type\n", __func__, self->swp_name); - alarm_msg_2_user(self, "detected transceiver/cables not meet SFF standard!"); - return ERR_TRNASVR_BE_ISOLATED; - } - /* Case3.3: Unknow transceiver type */ - if ((result[1] == TRANSVR_TYPE_UNKNOW_1) || - (result[1] == TRANSVR_TYPE_UNKNOW_2) ){ - result[0] = STATE_TRANSVR_UNEXCEPTED; - return ERR_TRANSVR_UNEXCPT; - } - /* Case3.4: During initial process */ - if (self->state == STATE_TRANSVR_INIT){ - result[0] = STATE_TRANSVR_INIT; - return 0; - } - /* Case3.5: Transceiver be swapped */ - if (self->type != result[1]){ - result[0] = STATE_TRANSVR_SWAPPED; - return 0; - } - /* Case3.6: Link up state */ - result[0] = STATE_TRANSVR_CONNECTED; - return 0; -} - - -int -_sfp_detect_class_by_extend_comp(struct transvr_obj_s* self) { - /* Reference: SFF-8024 (v3.8) - */ - int detect_val = _sfp_get_comp_extended(self); - - switch(detect_val) { - case 0x00: /* Unspecified */ - return TRANSVR_CLASS_UNSPECIFIED; - - case 0x01: /* 100G AOC (Active Optical Cable) or 25GAUI C2M */ - case 0x18: /* 100G AOC or 25GAUI C2M AOC. */ - return TRANSVR_CLASS_OPTICAL_25G_AOC; - - case 0x02: /* 100GBASE-SR4 or 25GBASE-SR */ - return TRANSVR_CLASS_OPTICAL_25G_SR; - - case 0x03: /* 100GBASE-LR4 or 25GBASE-LR */ - return TRANSVR_CLASS_OPTICAL_25G_LR; - - case 0x04: /* 100GBASE-ER4 or 25GBASE-ER */ - return TRANSVR_CLASS_OPTICAL_25G_ER; - - case 0x08: /* 100G ACC (Active Copper Cable) or 25GAUI C2M ACC. */ - case 0x0b: /* 100GBASE-CR4 or 25GBASE-CR CA-L */ - case 0x0c: /* 25GBASE-CR CA-S */ - case 0x0d: /* 25GBASE-CR CA-N */ - case 0x19: /* 100G ACC or 25GAUI C2M ACC. */ - return TRANSVR_CLASS_COPPER_L1_25G; - - default: - break; - } - SWPS_INFO("%s: Unexcept value:0x%02x\n :%s", - __func__, detect_val, self->swp_name); - return TRANSVR_CLASS_ERROR; -} - - -int -_sfp_detect_class_by_10_ethernet(struct transvr_obj_s* self) { - /* Reference: SFF-8472 (v12.2) - */ - int detect_val = DEBUG_TRANSVR_INT_VAL; - - detect_val = _sfp_get_comp_10g_eth_comp(self); - /* Case: Unspecified */ - if (detect_val == 0x00) { - return TRANSVR_CLASS_UNSPECIFIED; - } - /* Case: 10G Optical (x1) */ - if ((detect_val & 0x10) == 0x10) { /* 00010000 : 10GBASE-SR */ - return TRANSVR_CLASS_OPTICAL_10G_S_SR; - } - if ( ((detect_val & 0x20) == 0x20) || /* 00100000 : 10GBASE-LR */ - ((detect_val & 0x40) == 0x40) ){ /* 01000000 : 10GBASE-LRM */ - return TRANSVR_CLASS_OPTICAL_10G_S_LR; - } - if ((detect_val & 0x80) == 0x80) { /* 10000000 : 10GBASE-ER */ - return TRANSVR_CLASS_OPTICAL_10G_S_ER; - } - /* Case: ERROR */ - SWPS_INFO("%s: Unexcept value:0x%02x\n :%s", - __func__, detect_val, self->swp_name); - return TRANSVR_CLASS_ERROR; -} - - -int -_sfp_detect_if_sp_by_br(struct transvr_obj_s* self) { - - int lower_bound_1g = 0x0b; - int upper_bound_1g = 0x1A; - int lower_bound_10g = 0x60; - int upper_bound_10g = 0x75; - int lower_bound_25g = 0xf0; - int upper_bound_25g = 0xff; - int notmal_br = DEBUG_TRANSVR_INT_VAL; - - notmal_br = (int)(self->br); /* updated by update_all() */ - /* Check 25G */ - if ((notmal_br >= lower_bound_25g) && - (notmal_br <= upper_bound_25g) ) { - return TRANSVR_CLASS_25G; - } - /* Check 10G */ - if ((notmal_br >= lower_bound_10g) && - (notmal_br <= upper_bound_10g) ) { - return TRANSVR_CLASS_10G; - } - /* Check 1G */ - if ((notmal_br >= lower_bound_1g) && - (notmal_br <= upper_bound_1g) ) { - return TRANSVR_CLASS_1G; - } - return TRANSVR_CLASS_UNSPECIFIED; -} - - -int -_sfp_detect_class_by_1g_ethernet(struct transvr_obj_s* self) { - /* Reference: SFF-8472 (v12.2) - */ - int detect_val = DEBUG_TRANSVR_INT_VAL; - int speed_br = DEBUG_TRANSVR_INT_VAL; - int speed_tmp = DEBUG_TRANSVR_INT_VAL; - char err_str[64] = DEBUG_TRANSVR_STR_VAL; - - speed_br = _sfp_detect_if_sp_by_br(self); - detect_val = _sfp_get_comp_1g_eth_comp(self); - - if (detect_val < 0) { - snprintf(err_str, sizeof(err_str), "Detect abnormal value:%d", detect_val); - goto err_p_sfp_detect_class_by_1g_ethernet; - } - /* Case: Unspecified */ - if (detect_val == 0x00) { - return TRANSVR_CLASS_UNSPECIFIED; - } - /* Case: 1G (x1) */ - if ((detect_val & 0x01) == 0x01) { /* 00000001 : 1000BASE-SX */ - speed_tmp = TRANSVR_CLASS_OPTICAL_1G_SX; - goto ok_sfp_detect_class_by_1g_ethernet_4_check_br_10g; - } - if ((detect_val & 0x02) == 0x02) { /* 00000010 : 1000BASE-LX *3 */ - speed_tmp = TRANSVR_CLASS_OPTICAL_1G_LX; - goto ok_sfp_detect_class_by_1g_ethernet_4_check_br_10g; - } - if ((detect_val & 0x04) == 0x04) { /* 00000100 : 1000BASE-CX */ - speed_tmp = TRANSVR_CLASS_COPPER_L1_1G; - goto ok_sfp_detect_class_by_1g_ethernet_4_check_br_10g; - } - /* Case: 1000 Base-T (x1) */ - if ((detect_val & 0x08) == 0x08) { /* 00001000 : 1000BASE-T */ - return TRANSVR_CLASS_BASE_T_1000; - } - /* Case: 100 Base */ - if ( ((detect_val & 0x10) == 0x10) || /* 00010000 : 100BASE-LX/LX10 */ - ((detect_val & 0x20) == 0x20) || /* 00100000 : 100BASE-FX */ - ((detect_val & 0x40) == 0x40) || /* 01000000 : BASE-BX10 *3 */ - ((detect_val & 0x80) == 0x80) ){ /* 10000000 : BASE-PX *3 */ - return TRANSVR_CLASS_OPTICAL_100; - } - /* Case: ERROR */ - snprintf(err_str, sizeof(err_str), "Case:ERROR, value:%d", detect_val); - goto err_p_sfp_detect_class_by_1g_ethernet; - -ok_sfp_detect_class_by_1g_ethernet_4_check_br_10g: - switch (speed_br) { - case TRANSVR_CLASS_UNSPECIFIED: - case TRANSVR_CLASS_1G: - return speed_tmp; - case TRANSVR_CLASS_10G: - goto ok_sfp_detect_class_by_1g_ethernet_4_transfer_10G; - } - -ok_sfp_detect_class_by_1g_ethernet_4_transfer_10G: - switch (speed_tmp) { - case TRANSVR_CLASS_OPTICAL_1G_SX: - return TRANSVR_CLASS_OPTICAL_10G_S_SR; - case TRANSVR_CLASS_OPTICAL_1G_LX: - return TRANSVR_CLASS_OPTICAL_10G_S_LR; - case TRANSVR_CLASS_COPPER_L1_1G: - return TRANSVR_CLASS_COPPER_L1_10G; - default: - break; - } - snprintf(err_str, sizeof(err_str), "transfer_1to10 fail, speed:%d", speed_tmp); - goto err_p_sfp_detect_class_by_1g_ethernet; - -err_p_sfp_detect_class_by_1g_ethernet: - SWPS_INFO("%s: %s :%s", __func__, err_str, self->swp_name); - return TRANSVR_CLASS_ERROR; -} - - -int -_sfp_detect_class_by_feature(struct transvr_obj_s* self) { - /* Reference: SFF-8024 (v3.8) - */ - int is_active = 0; - int conn_val = DEBUG_TRANSVR_INT_VAL; - int check_val = DEBUG_TRANSVR_INT_VAL; - int wave_len = DEBUG_TRANSVR_INT_VAL; - int speed_val = DEBUG_TRANSVR_INT_VAL; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - - speed_val = _sfp_detect_if_sp_by_br(self); - conn_val = _sfp_get_connector_type(self); - - switch(conn_val) { - case 0x00: /* Unspecified */ - goto ok_sfp_detect_class_by_feature_4_check_active_passive; - case 0x07: /* LC (Lucent Connector) */ - case 0x0b: /* Optical Pigtail */ - case 0x0c: /* MPO 1x12 */ - case 0x0d: /* MPO 2x16 */ - /* - * ToDo: Need verify Optical Pigtail - */ - goto ok_sfp_detect_class_by_feature_4_optiocal; - case 0x21: /* Copper pigtail */ - /* - * ToDo: Need check ACC use case - */ - goto ok_sfp_detect_class_by_feature_4_check_active_passive; - case 0x23: /* No separable connector */ - /* - * ToDo: Standard not clear, not all transceiver vendor - * have the same defined - */ - goto ok_sfp_detect_class_by_feature_4_check_active_passive; - default: - break; - } - goto ok_sfp_detect_class_by_feature_4_unknow; - -ok_sfp_detect_class_by_feature_4_check_active_passive: - check_val = _sfp_get_cable_tech(self); - switch(check_val) { - case 0x00: /* Unspecified */ - goto ok_sfp_detect_class_by_feature_4_unknow; - case 0x04: /* Passive */ - goto ok_sfp_detect_class_by_feature_4_copper; - case 0x08: /* Active */ - is_active = 1; - goto ok_sfp_detect_class_by_feature_4_aoc; - default: - snprintf(err_msg, sizeof(err_msg), - "_sfp_get_cable_tech return Non define value:%d", - check_val); - break; - } - goto err_sfp_detect_class_by_feature_1; - -ok_sfp_detect_class_by_feature_4_optiocal: - wave_len = _common_count_wavelength(self, - self->wavelength[0], - self->wavelength[1]); - switch(speed_val) { - case TRANSVR_CLASS_25G: - switch (wave_len) { - case VAL_OPTICAL_WAVELENGTH_SR: - return TRANSVR_CLASS_OPTICAL_25G_SR; - case VAL_OPTICAL_WAVELENGTH_LR: - return TRANSVR_CLASS_OPTICAL_25G_LR; - case VAL_OPTICAL_WAVELENGTH_ER: - return TRANSVR_CLASS_OPTICAL_25G_ER; - default: - break; - } - return TRANSVR_CLASS_OPTICAL_25G; - - case TRANSVR_CLASS_10G: - switch (wave_len) { - case VAL_OPTICAL_WAVELENGTH_SR: - return TRANSVR_CLASS_OPTICAL_10G_S_SR; - case VAL_OPTICAL_WAVELENGTH_LR: - return TRANSVR_CLASS_OPTICAL_10G_S_LR; - case VAL_OPTICAL_WAVELENGTH_ER: - return TRANSVR_CLASS_OPTICAL_10G_S_ER; - default: - break; - } - return TRANSVR_CLASS_OPTICAL_10G; - - case TRANSVR_CLASS_1G: - switch (wave_len) { - case VAL_OPTICAL_WAVELENGTH_SR: - return TRANSVR_CLASS_OPTICAL_1G_SX; - case VAL_OPTICAL_WAVELENGTH_LR: - return TRANSVR_CLASS_OPTICAL_1G_LX; - case VAL_OPTICAL_WAVELENGTH_ER: - return TRANSVR_CLASS_OPTICAL_1G_EX; - default: - break; - } - return TRANSVR_CLASS_OPTICAL_1G; - - default: - return TRANSVR_CLASS_OPTICAL; - } - -ok_sfp_detect_class_by_feature_4_aoc: - switch(speed_val) { - case TRANSVR_CLASS_25G: - return TRANSVR_CLASS_OPTICAL_25G_AOC; - case TRANSVR_CLASS_10G: - return TRANSVR_CLASS_OPTICAL_10G_S_AOC; - case TRANSVR_CLASS_1G: - return TRANSVR_CLASS_OPTICAL_1G_AOC; - default: - break; - } - goto ok_sfp_detect_class_by_feature_4_unknow; - -ok_sfp_detect_class_by_feature_4_copper: - switch(speed_val) { - case TRANSVR_CLASS_25G: - return TRANSVR_CLASS_COPPER_L1_25G; - case TRANSVR_CLASS_10G: - return TRANSVR_CLASS_COPPER_L1_10G; - case TRANSVR_CLASS_1G: - return TRANSVR_CLASS_COPPER_L1_1G; - default: - return TRANSVR_CLASS_COPPER; - } - -ok_sfp_detect_class_by_feature_4_unknow: - return TRANSVR_CLASS_UNSPECIFIED; - -err_sfp_detect_class_by_feature_1: - SWPS_INFO("%s: %s\n :%s", __func__, err_msg, self->swp_name); - return TRANSVR_CLASS_ERROR; -} - - -int -sft_detect_transvr_class(struct transvr_obj_s* self) { - - int detect_val = DEBUG_TRANSVR_INT_VAL; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - - /* Check Extended Compliance */ - detect_val = _sfp_detect_class_by_extend_comp(self); - switch(detect_val) { - case TRANSVR_CLASS_UNSPECIFIED: - break; - case TRANSVR_CLASS_OPTICAL_25G_AOC: - case TRANSVR_CLASS_OPTICAL_25G_SR: - case TRANSVR_CLASS_OPTICAL_25G_LR: - case TRANSVR_CLASS_OPTICAL_25G_ER: - case TRANSVR_CLASS_COPPER_L1_25G: - return detect_val; - default: - snprintf(err_msg, sizeof(err_msg), - "Detect undefined extend_comp:%d", - detect_val); - goto err_sft_detect_transceiver_class_1; - } - /* Check 10G Compliance */ - detect_val = _sfp_detect_class_by_10_ethernet(self); - switch(detect_val) { - case TRANSVR_CLASS_UNSPECIFIED: - break; - case TRANSVR_CLASS_OPTICAL_10G_S_SR: - case TRANSVR_CLASS_OPTICAL_10G_S_LR: - case TRANSVR_CLASS_OPTICAL_10G_S_ER: - return detect_val; - default: - snprintf(err_msg, sizeof(err_msg), - "Detect undefined 10G_eth:%d", - detect_val); - goto err_sft_detect_transceiver_class_1; - } - /* Check 1G Compliance */ - detect_val = _sfp_detect_class_by_1g_ethernet(self); - switch(detect_val) { - case TRANSVR_CLASS_UNSPECIFIED: - break; - case TRANSVR_CLASS_OPTICAL_1G_SX: - case TRANSVR_CLASS_OPTICAL_1G_LX: - case TRANSVR_CLASS_COPPER_L1_1G: - case TRANSVR_CLASS_BASE_T_1000: - case TRANSVR_CLASS_OPTICAL_100: - /* - * ToDo: Need Check 0.1G - */ - case TRANSVR_CLASS_OPTICAL_10G_S_SR: - case TRANSVR_CLASS_OPTICAL_10G_S_LR: - case TRANSVR_CLASS_COPPER_L1_10G: - /* Transfer speed case - * => Example: Raycom 10G DAC - */ - return detect_val; - default: - snprintf(err_msg, sizeof(err_msg), - "Detect undefined 1G_eth:%d", - detect_val); - goto err_sft_detect_transceiver_class_1; - } - /* Check by connector, br, wavelength */ - detect_val = _sfp_detect_class_by_feature(self); - switch(detect_val) { - case TRANSVR_CLASS_UNSPECIFIED: - break; - case TRANSVR_CLASS_OPTICAL: - case TRANSVR_CLASS_OPTICAL_1G: - case TRANSVR_CLASS_OPTICAL_1G_SX: - case TRANSVR_CLASS_OPTICAL_1G_LX: - case TRANSVR_CLASS_OPTICAL_1G_EX: - case TRANSVR_CLASS_OPTICAL_1G_AOC: - case TRANSVR_CLASS_OPTICAL_10G: - case TRANSVR_CLASS_OPTICAL_10G_S_SR: - case TRANSVR_CLASS_OPTICAL_10G_S_LR: - case TRANSVR_CLASS_OPTICAL_10G_S_ER: - case TRANSVR_CLASS_OPTICAL_10G_S_AOC: - case TRANSVR_CLASS_OPTICAL_25G: - case TRANSVR_CLASS_OPTICAL_25G_SR: - case TRANSVR_CLASS_OPTICAL_25G_LR: - case TRANSVR_CLASS_OPTICAL_25G_ER: - case TRANSVR_CLASS_OPTICAL_25G_AOC: - case TRANSVR_CLASS_COPPER: - case TRANSVR_CLASS_COPPER_L1_1G: - case TRANSVR_CLASS_COPPER_L1_10G: - case TRANSVR_CLASS_COPPER_L1_25G: - return detect_val; - default: - snprintf(err_msg, sizeof(err_msg), - "Detect undefined get_connector:%d", - detect_val); - goto err_sft_detect_transceiver_class_1; - } - /* Exception case: Can't verify */ - snprintf(err_msg, sizeof(err_msg), "Can not identify!"); - goto err_sft_detect_transceiver_class_1; - -err_sft_detect_transceiver_class_1: - SWPS_INFO("%s: %s :%s\n", __func__, err_msg, self->swp_name); - return TRANSVR_CLASS_ERROR; -} - - -int -_sfp_set_magnolia_if_type(struct transvr_obj_s* self, - int transvr_cls, - char *result){ - - int lmax = 8; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - - switch(transvr_cls) { - case TRANSVR_CLASS_ERROR: - case TRANSVR_CLASS_UNSPECIFIED: - break; - /* 25G OPTICAL */ - case TRANSVR_CLASS_OPTICAL_25G_AOC: - case TRANSVR_CLASS_OPTICAL_25G_SR: - case TRANSVR_CLASS_OPTICAL_25G_LR: - case TRANSVR_CLASS_OPTICAL_25G_ER: - case TRANSVR_CLASS_OPTICAL_25G: - return snprintf(result, lmax, TRANSVR_IF_SFI); - /* 25G COPPER */ - case TRANSVR_CLASS_COPPER_L1_25G: - return snprintf(result, lmax, TRANSVR_IF_SFI); - /* 10G OPTICAL */ - case TRANSVR_CLASS_OPTICAL_10G_S_AOC: - case TRANSVR_CLASS_OPTICAL_10G_S_SR: - case TRANSVR_CLASS_OPTICAL_10G_S_LR: - case TRANSVR_CLASS_OPTICAL_10G_S_ER: - case TRANSVR_CLASS_OPTICAL_10G: - return snprintf(result, lmax, TRANSVR_IF_SFI); - /* 10G COPPER */ - case TRANSVR_CLASS_COPPER_L1_10G: - return snprintf(result, lmax, TRANSVR_IF_SFI); - /* 1G OPTICAL */ - case TRANSVR_CLASS_OPTICAL_1G_AOC: - case TRANSVR_CLASS_OPTICAL_1G_SX: - case TRANSVR_CLASS_OPTICAL_1G_LX: - case TRANSVR_CLASS_OPTICAL_1G_EX: - case TRANSVR_CLASS_OPTICAL_1G: - return snprintf(result, lmax, TRANSVR_IF_IF_GMII); - /* 1G COPPER */ - case TRANSVR_CLASS_COPPER_L1_1G: - return snprintf(result, lmax, TRANSVR_IF_IF_GMII); - /* 1G BASE_T */ - case TRANSVR_CLASS_BASE_T_1000: - return snprintf(result, lmax, TRANSVR_IF_IF_GMII); - /* 100 Base */ - case TRANSVR_CLASS_OPTICAL_100: - return snprintf(result, lmax, TRANSVR_IF_IF_GMII); - default: - snprintf(err_msg, sizeof(err_msg), - "Detect undefined value:%d", - transvr_cls); - goto err_sfp_set_magnolia_if_type_1; - } - /* Exception case: Can't verify */ - snprintf(err_msg, sizeof(err_msg), "Can not identify!"); - goto err_sfp_set_magnolia_if_type_1; - -err_sfp_set_magnolia_if_type_1: - snprintf(result, lmax, TRANSVR_UEVENT_UNKNOW); - SWPS_INFO("%s: %s :%s\n", __func__, err_msg, self->swp_name); - return ERR_TRANSVR_ABNORMAL; -} - - -int -_sfp_set_redwood_if_type(struct transvr_obj_s* self, - int transvr_cls, - char *result) { - - int lmax = 8; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - - switch(transvr_cls) { - case TRANSVR_CLASS_ERROR: - case TRANSVR_CLASS_UNSPECIFIED: - break; - /* 25G OPTICAL */ - case TRANSVR_CLASS_OPTICAL_25G_AOC: - case TRANSVR_CLASS_OPTICAL_25G_SR: - case TRANSVR_CLASS_OPTICAL_25G_LR: - case TRANSVR_CLASS_OPTICAL_25G_ER: - case TRANSVR_CLASS_OPTICAL_25G: - return snprintf(result, lmax, TRANSVR_IF_SR); - /* 25G COPPER */ - case TRANSVR_CLASS_COPPER_L1_25G: - return snprintf(result, lmax, TRANSVR_IF_KR); - /* 10G OPTICAL */ - case TRANSVR_CLASS_OPTICAL_10G_S_AOC: - case TRANSVR_CLASS_OPTICAL_10G_S_SR: - case TRANSVR_CLASS_OPTICAL_10G_S_LR: - case TRANSVR_CLASS_OPTICAL_10G_S_ER: - case TRANSVR_CLASS_OPTICAL_10G: - return snprintf(result, lmax, TRANSVR_IF_SFI); - /* 10G COPPER */ - case TRANSVR_CLASS_COPPER_L1_10G: - return snprintf(result, lmax, TRANSVR_IF_SFI); - /* 1G OPTICAL */ - case TRANSVR_CLASS_OPTICAL_1G_AOC: - case TRANSVR_CLASS_OPTICAL_1G_SX: - case TRANSVR_CLASS_OPTICAL_1G_LX: - case TRANSVR_CLASS_OPTICAL_1G_EX: - case TRANSVR_CLASS_OPTICAL_1G: - return snprintf(result, lmax, TRANSVR_IF_IF_GMII); - /* 1G COPPER */ - case TRANSVR_CLASS_COPPER_L1_1G: - return snprintf(result, lmax, TRANSVR_IF_IF_GMII); - /* 1G BASE_T */ - case TRANSVR_CLASS_BASE_T_1000: - return snprintf(result, lmax, TRANSVR_IF_IF_GMII); - /* 100 Base */ - case TRANSVR_CLASS_OPTICAL_100: - return snprintf(result, lmax, TRANSVR_IF_IF_GMII); - default: - snprintf(err_msg, sizeof(err_msg), - "Detect undefined value:%d", - transvr_cls); - goto err_sfp_set_redwood_if_type_1; - } - /* Exception case: Can't verify */ - snprintf(err_msg, sizeof(err_msg), "Can not identify!"); - goto err_sfp_set_redwood_if_type_1; - -err_sfp_set_redwood_if_type_1: - snprintf(result, lmax, TRANSVR_UEVENT_UNKNOW); - SWPS_INFO("%s: %s\n :%s", __func__, err_msg, self->swp_name); - return ERR_TRANSVR_ABNORMAL; -} - - -int -_sfp_set_lavender_if_type(struct transvr_obj_s* self, - int transvr_cls, - char *result) { - /* (TBD) - * Due to 'LAV' looks like doesn't have interface type. - * We bypass it currently. - */ - int lmax = 8; - return snprintf(result, lmax, TRANSVR_UEVENT_UNKNOW); -} - - -int -_sfp_detect_if_type(struct transvr_obj_s* self, - char *result){ - - int lmax = 8; - int detect_cls = DEBUG_TRANSVR_INT_VAL; - - detect_cls = sft_detect_transvr_class(self); - switch (self->chipset_type) { - case CHIP_TYPE_MAGNOLIA: - return _sfp_set_magnolia_if_type(self, detect_cls, result); - - case CHIP_TYPE_MAPLE: - case CHIP_TYPE_REDWOOD: - return _sfp_set_redwood_if_type(self, detect_cls, result); - - case CHIP_TYPE_LAVENDER: - return _sfp_set_lavender_if_type(self, detect_cls, result); - - default: - SWPS_INFO("%s: non-defined chipset_type:%d :%s\n", - __func__, self->chipset_type, self->swp_name); - break; - } - snprintf(result, lmax, TRANSVR_UEVENT_UNKNOW); - return ERR_TRANSVR_ABNORMAL; -} - - -int -sfp_get_if_type(struct transvr_obj_s *self, - char *buf_p){ - - int lmax = 16; - char tmp_result[16] = DEBUG_TRANSVR_STR_VAL; - - if (self->state != STATE_TRANSVR_CONNECTED) { - return snprintf(buf_p, lmax, "%d\n", self->state); - } - if (_sfp_detect_if_type(self, tmp_result) < 0) { - return snprintf(buf_p, lmax, "%d\n", ERR_TRANSVR_ABNORMAL); - } - return snprintf(buf_p, lmax, "%s\n", tmp_result); -} - - -int -_sfp_detect_if_speed(struct transvr_obj_s* self, - char *result){ - - int lmax = 16; - int detect_val = DEBUG_TRANSVR_INT_VAL; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - - detect_val = sft_detect_transvr_class(self); - switch(detect_val) { - case TRANSVR_CLASS_ERROR: - case TRANSVR_CLASS_UNSPECIFIED: - break; - /* 25G OPTICAL */ - case TRANSVR_CLASS_OPTICAL_25G_AOC: - case TRANSVR_CLASS_OPTICAL_25G_SR: - case TRANSVR_CLASS_OPTICAL_25G_LR: - case TRANSVR_CLASS_OPTICAL_25G_ER: - case TRANSVR_CLASS_OPTICAL_25G: - return snprintf(result, lmax, TRANSVR_IF_SP_25G); - /* 25G COPPER */ - case TRANSVR_CLASS_COPPER_L1_25G: - return snprintf(result, lmax, TRANSVR_IF_SP_25G); - /* 10G OPTICAL */ - case TRANSVR_CLASS_OPTICAL_10G_S_AOC: - case TRANSVR_CLASS_OPTICAL_10G_S_SR: - case TRANSVR_CLASS_OPTICAL_10G_S_LR: - case TRANSVR_CLASS_OPTICAL_10G_S_ER: - case TRANSVR_CLASS_OPTICAL_10G: - return snprintf(result, lmax, TRANSVR_IF_SP_10G); - /* 10G COPPER */ - case TRANSVR_CLASS_COPPER_L1_10G: - return snprintf(result, lmax, TRANSVR_IF_SP_10G); - /* 1G OPTICAL */ - case TRANSVR_CLASS_OPTICAL_1G_AOC: - case TRANSVR_CLASS_OPTICAL_1G_SX: - case TRANSVR_CLASS_OPTICAL_1G_LX: - case TRANSVR_CLASS_OPTICAL_1G_EX: - case TRANSVR_CLASS_OPTICAL_1G: - return snprintf(result, lmax, TRANSVR_IF_SP_1G); - /* 1G COPPER */ - case TRANSVR_CLASS_COPPER_L1_1G: - return snprintf(result, lmax, TRANSVR_IF_SP_1G); - /* 1G BASE_T */ - case TRANSVR_CLASS_BASE_T_1000: - return snprintf(result, lmax, TRANSVR_IF_SP_1G); - /* 100 Base */ - case TRANSVR_CLASS_OPTICAL_100: - return snprintf(result, lmax, TRANSVR_IF_SP_100); - default: - snprintf(err_msg, sizeof(err_msg), - "Detect undefined value:%d", - detect_val); - goto err_sfp_detect_if_speed_1; - } - /* Check by BR */ - detect_val = _sfp_detect_if_sp_by_br(self); - switch (detect_val) { - case TRANSVR_CLASS_25G: - return snprintf(result, lmax, TRANSVR_IF_SP_25G); - case TRANSVR_CLASS_10G: - return snprintf(result, lmax, TRANSVR_IF_SP_10G); - case TRANSVR_CLASS_1G: - return snprintf(result, lmax, TRANSVR_IF_SP_1G); - default: - break; - } - /* Exception case: Can't verify */ - snprintf(err_msg, sizeof(err_msg), "Can not identify!"); - goto err_sfp_detect_if_speed_1; - -err_sfp_detect_if_speed_1: - snprintf(result, lmax, TRANSVR_UEVENT_UNKNOW); - SWPS_INFO("%s %s\n :%s", __func__, err_msg, self->swp_name); - return ERR_TRANSVR_ABNORMAL; -} - - -int -sfp_get_if_speed(struct transvr_obj_s *self, - char *buf_p){ - - int lmax = 16; - char tmp_result[16] = DEBUG_TRANSVR_STR_VAL; - - if (self->state != STATE_TRANSVR_CONNECTED) { - return snprintf(buf_p, lmax, "%d\n", self->state); - } - if (_sfp_detect_if_speed(self, tmp_result) < 0) { - return snprintf(buf_p, lmax, "%d\n", ERR_TRANSVR_ABNORMAL); - } - return snprintf(buf_p, lmax, "%s\n", tmp_result); -} - - -int -_qsfp_detect_class_by_extend_comp(struct transvr_obj_s* self) { - /* Reference: SFF-8024 (v3.8) - */ - int detect_val = DEBUG_TRANSVR_INT_VAL; - - detect_val = _qsfp_get_comp_extended(self); - switch(detect_val) { - case 0x00: /* Unspecified */ - return TRANSVR_CLASS_UNSPECIFIED; - - case 0x01: /* 100G AOC (Active Optical Cable) or 25GAUI C2M */ - case 0x18: /* 100G AOC or 25GAUI C2M AOC. */ - return TRANSVR_CLASS_OPTICAL_100G_AOC; - - case 0x06: /* 100G CWDM4 */ - case 0x09: /* Obsolete (assigned before 100G CWDM4 MSA required FEC) */ - case 0x17: /* 100G CLR4 */ - case 0x1A: /* 100GE-DWDM2 */ - return TRANSVR_CLASS_OPTICAL_100G; - - case 0x02: /* 100GBASE-SR4 or 25GBASE-SR */ - return TRANSVR_CLASS_OPTICAL_100G_SR4; - - case 0x03: /* 100GBASE-LR4 or 25GBASE-LR */ - return TRANSVR_CLASS_OPTICAL_100G_LR4; - - case 0x04: /* 100GBASE-ER4 or 25GBASE-ER */ - return TRANSVR_CLASS_OPTICAL_100G_ER4; - - case 0x07: /* 100G PSM4 Parallel SMF */ - return TRANSVR_CLASS_OPTICAL_100G_PSM4; - - case 0x12: /* 40G PSM4 Parallel SMF */ - return TRANSVR_CLASS_OPTICAL_40G; - - case 0x11: /* 4 x 10GBASE-SR */ - return TRANSVR_CLASS_OPTICAL_40G_SR4; - - case 0x10: /* 40GBASE-ER4 */ - return TRANSVR_CLASS_OPTICAL_40G_ER4; - - case 0x08: /* 100G ACC (Active Copper Cable) or 25GAUI C2M ACC. */ - case 0x0b: /* 100GBASE-CR4 or 25GBASE-CR CA-L */ - case 0x19: /* 100G ACC or 25GAUI C2M ACC. */ - return TRANSVR_CLASS_COPPER_L4_100G; - - default: - break; - } - SWPS_INFO("%s: Unexcept value:0x%02x\n :%s", - __func__, detect_val, self->swp_name); - return TRANSVR_CLASS_ERROR; -} - - -int -_qsfp_detect_class_by_10_40_100_ethernet(struct transvr_obj_s* self) { - /* Reference: SFF-8472 (v12.2) - */ - int detect_val = DEBUG_TRANSVR_INT_VAL; - - detect_val = _qsfp_get_comp_10_40_100_ethernet(self); - /* Case: Unspecified */ - if (detect_val == 0x00) { - return TRANSVR_CLASS_UNSPECIFIED; - } - /* Case: 40G Optical */ - if ((detect_val & 0x01) == 0x01) { /* 00000001 : 40G Active Cable (XLPPI) */ - return TRANSVR_CLASS_OPTICAL_40G_AOC; - } - if ((detect_val & 0x04) == 0x04) { /* 00000100 : 40GBASE-SR4 */ - return TRANSVR_CLASS_OPTICAL_40G_SR4; - } - if ( (detect_val & 0x02) == 0x02) { /* 00000010 : 40GBASE-LR4 */ - return TRANSVR_CLASS_OPTICAL_40G_LR4; - } - if ( (detect_val & 0x08) == 0x08) { /* 00001000 : 40GBASE-CR4 */ - return TRANSVR_CLASS_COPPER_L4_40G; - } - /* Case: 10G Optical */ - if ( (detect_val & 0x10) == 0x10) { /* 00010000 : 10GBASE-SR */ - return TRANSVR_CLASS_OPTICAL_10G_Q_SR; - } - if ( ((detect_val & 0x20) == 0x20) || /* 00100000 : 10GBASE-LR */ - ((detect_val & 0x40) == 0x40) ){ /* 01000000 : 10GBASE-LRM */ - return TRANSVR_CLASS_OPTICAL_10G_Q_LR; - } - /* Case: Extend Compliance */ - if ( ((detect_val & 0x80) == 0x80) ){ /* 10000000 : Use Extend Compliance */ - return TRANSVR_CLASS_EXTEND_COMP; - } - /* Case: ERROR */ - SWPS_INFO("%s: Unexcept value:0x%02x\n :%s", - __func__, detect_val, self->swp_name); - return TRANSVR_CLASS_ERROR; -} - - -int -_qsfp_detect_if_sp_by_br(struct transvr_obj_s* self) { - - int lower_bound_10g = 0x10; - int upper_bound_10g = 0x25; - int lower_bound_40g = 0x60; - int upper_bound_40g = 0x75; - int lower_bound_100g = 0x60; - int upper_bound_100g = 0x75; - int used_extend_br = 0xff; - int notmal_br = DEBUG_TRANSVR_INT_VAL; - int extend_br = DEBUG_TRANSVR_INT_VAL; - - notmal_br = (int)(self->br); /* updated by update_all() */ - /* Check 40G */ - if ((notmal_br >= lower_bound_40g) && - (notmal_br <= upper_bound_40g) ) { - return TRANSVR_CLASS_40G; - } - /* Check 100G */ - if (notmal_br == used_extend_br) { - extend_br = (int)(self->extbr); /* updated by update_all() */ - if ((extend_br >= lower_bound_100g) && - (extend_br <= upper_bound_100g) ) { - return TRANSVR_CLASS_100G; - } - } - /* Check 10G */ - if ((notmal_br >= lower_bound_10g) && - (notmal_br <= upper_bound_10g) ) { - return TRANSVR_CLASS_10G; - } - return TRANSVR_CLASS_UNSPECIFIED; -} - - -int -_qsfp_detect_class_by_feature(struct transvr_obj_s* self) { - /* Reference: SFF-8024 (v3.8) - */ - int conn_val = DEBUG_TRANSVR_INT_VAL; - int wave_len = DEBUG_TRANSVR_INT_VAL; - int speed_val = DEBUG_TRANSVR_INT_VAL; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - - speed_val = _qsfp_detect_if_sp_by_br(self); - conn_val = _qsfp_get_connector_type(self); - - switch(conn_val) { - case 0x00: /* Unspecified */ - return TRANSVR_CLASS_UNSPECIFIED; - case 0x07: /* LC (Lucent Connector) */ - case 0x0b: /* Optical Pigtail */ - case 0x0c: /* MPO 1x12 (Multifiber Parallel Optic) */ - case 0x0d: /* MPO 2x16 */ - goto ok_qsfp_detect_class_by_feature_4_optiocal; - case 0x21: /* Copper pigtail */ - goto ok_qsfp_detect_class_by_feature_4_copper; - case 0x23: /* No separable connector */ - if ((_qsfp_get_comp_fc_link_length(self) > 0) || - (_qsfp_get_comp_fc_trans_tech(self) > 0) || - (_qsfp_get_comp_fc_trans_media(self) > 0) || - (_qsfp_get_comp_fc_speed(self) > 0) ) { - goto ok_qsfp_detect_class_by_feature_4_aoc; - } - goto ok_qsfp_detect_class_by_feature_4_copper; - default: - snprintf(err_msg, sizeof(err_msg), - "_qsfp_get_connector_type return Non define value:%d", - conn_val); - goto err_qsfp_detect_class_by_feature_1; - } - return TRANSVR_CLASS_UNSPECIFIED; - -ok_qsfp_detect_class_by_feature_4_optiocal: - wave_len = _common_count_wavelength(self, - self->wavelength[0], - self->wavelength[1]); - switch(speed_val) { - case TRANSVR_CLASS_100G: - switch (wave_len) { - case VAL_OPTICAL_WAVELENGTH_SR: - return TRANSVR_CLASS_OPTICAL_100G_SR4; - case VAL_OPTICAL_WAVELENGTH_LR: - return TRANSVR_CLASS_OPTICAL_100G_LR4; - case VAL_OPTICAL_WAVELENGTH_ER: - return TRANSVR_CLASS_OPTICAL_100G_ER4; - default: - break; - } - return TRANSVR_CLASS_OPTICAL_100G; - - case TRANSVR_CLASS_40G: - switch (wave_len) { - case VAL_OPTICAL_WAVELENGTH_SR: - return TRANSVR_CLASS_OPTICAL_40G_SR4; - case VAL_OPTICAL_WAVELENGTH_LR: - return TRANSVR_CLASS_OPTICAL_40G_LR4; - case VAL_OPTICAL_WAVELENGTH_ER: - return TRANSVR_CLASS_OPTICAL_40G_ER4; - default: - break; - } - return TRANSVR_CLASS_OPTICAL_40G; - - case TRANSVR_CLASS_10G: - switch (wave_len) { - case VAL_OPTICAL_WAVELENGTH_SR: - return TRANSVR_CLASS_OPTICAL_10G_Q_SR; - case VAL_OPTICAL_WAVELENGTH_LR: - return TRANSVR_CLASS_OPTICAL_10G_Q_LR; - case VAL_OPTICAL_WAVELENGTH_ER: - return TRANSVR_CLASS_OPTICAL_10G_Q_ER; - default: - break; - } - return TRANSVR_CLASS_OPTICAL_10G; - - default: - return TRANSVR_CLASS_OPTICAL; - } - -ok_qsfp_detect_class_by_feature_4_aoc: - switch(speed_val) { - case TRANSVR_CLASS_100G: - return TRANSVR_CLASS_OPTICAL_100G_AOC; - case TRANSVR_CLASS_40G: - return TRANSVR_CLASS_OPTICAL_40G_AOC; - case TRANSVR_CLASS_10G: - return TRANSVR_CLASS_OPTICAL_10G_Q_AOC; - default: - return TRANSVR_CLASS_OPTICAL; - } - -ok_qsfp_detect_class_by_feature_4_copper: - switch(speed_val) { - case TRANSVR_CLASS_100G: - return TRANSVR_CLASS_COPPER_L4_100G; - case TRANSVR_CLASS_40G: - return TRANSVR_CLASS_COPPER_L4_40G; - case TRANSVR_CLASS_10G: - return TRANSVR_CLASS_COPPER_L4_10G; - default: - return TRANSVR_CLASS_COPPER; - } - -err_qsfp_detect_class_by_feature_1: - SWPS_INFO("%s: %s\n :%s", - __func__, err_msg, self->swp_name); - return TRANSVR_CLASS_ERROR; -} - - -int -qsft_detect_transvr_class(struct transvr_obj_s* self) { - - int detect_val = DEBUG_TRANSVR_INT_VAL; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - - /* Check Extended Compliance */ - detect_val = _qsfp_detect_class_by_extend_comp(self); - switch (detect_val) { - case TRANSVR_CLASS_UNSPECIFIED: - break; - case TRANSVR_CLASS_OPTICAL_100G: - case TRANSVR_CLASS_OPTICAL_100G_AOC: - case TRANSVR_CLASS_OPTICAL_100G_SR4: - case TRANSVR_CLASS_OPTICAL_100G_LR4: - case TRANSVR_CLASS_OPTICAL_100G_ER4: - case TRANSVR_CLASS_OPTICAL_100G_PSM4: - case TRANSVR_CLASS_OPTICAL_40G: - case TRANSVR_CLASS_OPTICAL_40G_AOC: - case TRANSVR_CLASS_OPTICAL_40G_SR4: - case TRANSVR_CLASS_OPTICAL_40G_LR4: - case TRANSVR_CLASS_OPTICAL_40G_ER4: - case TRANSVR_CLASS_COPPER_L4_100G: - return detect_val; - default: - snprintf(err_msg, sizeof(err_msg), - "Detect undefined extend_comp:%d", - detect_val); - goto err_qsft_detect_transvr_class_1; - } - /* Check 10/40G/100G Ethernet Compliance */ - detect_val = _qsfp_detect_class_by_10_40_100_ethernet(self); - switch(detect_val) { - case TRANSVR_CLASS_UNSPECIFIED: - break; - case TRANSVR_CLASS_OPTICAL_40G_AOC: - case TRANSVR_CLASS_OPTICAL_40G_SR4: - case TRANSVR_CLASS_OPTICAL_40G_LR4: - case TRANSVR_CLASS_OPTICAL_10G_Q_SR: /* Need Check: SR4 or SR */ - case TRANSVR_CLASS_OPTICAL_10G_Q_LR: /* Need Check: SR4 or SR */ - case TRANSVR_CLASS_COPPER_L4_40G: - return detect_val; - case TRANSVR_CLASS_EXTEND_COMP: - /* Format incorrect case (We already checked the Extend - * Compliance is 0 - */ - snprintf(err_msg, sizeof(err_msg), - "Transceiver format incorrect"); - goto err_qsft_detect_transvr_class_1; - default: - snprintf(err_msg, sizeof(err_msg), - "Detect undefined 10/40/100:%d", - detect_val); - goto err_qsft_detect_transvr_class_1; - } - /* Check by Connector type, BR and wavelength */ - detect_val = _qsfp_detect_class_by_feature(self); - switch (detect_val) { - case TRANSVR_CLASS_UNSPECIFIED: - break; - case TRANSVR_CLASS_OPTICAL_100G_ER4: - case TRANSVR_CLASS_OPTICAL_100G_LR4: - case TRANSVR_CLASS_OPTICAL_100G_SR4: - case TRANSVR_CLASS_OPTICAL_100G_AOC: - case TRANSVR_CLASS_OPTICAL_100G: - case TRANSVR_CLASS_OPTICAL_40G_ER4: - case TRANSVR_CLASS_OPTICAL_40G_LR4: - case TRANSVR_CLASS_OPTICAL_40G_SR4: - case TRANSVR_CLASS_OPTICAL_40G_AOC: - case TRANSVR_CLASS_OPTICAL_40G: - case TRANSVR_CLASS_OPTICAL_10G_Q_ER: - case TRANSVR_CLASS_OPTICAL_10G_Q_LR: - case TRANSVR_CLASS_OPTICAL_10G_Q_SR: - case TRANSVR_CLASS_OPTICAL_10G_Q_AOC: - case TRANSVR_CLASS_OPTICAL_10G: - case TRANSVR_CLASS_OPTICAL: - case TRANSVR_CLASS_COPPER_L4_100G: - case TRANSVR_CLASS_COPPER_L4_40G: - case TRANSVR_CLASS_COPPER_L4_10G: - case TRANSVR_CLASS_COPPER: - return detect_val; - default: - snprintf(err_msg, sizeof(err_msg), - "Detect undefined connector:%d", - detect_val); - goto err_qsft_detect_transvr_class_1; - } - /* Exception case: Can't verify */ - snprintf(err_msg, sizeof(err_msg), - "Can not identify!"); - goto err_qsft_detect_transvr_class_1; - -err_qsft_detect_transvr_class_1: - SWPS_INFO("%s: %s\n :%s", __func__, err_msg, self->swp_name); - return TRANSVR_CLASS_ERROR; -} - - -int -_qsfp_set_magnolia_if_type(struct transvr_obj_s* self, - int transvr_cls, - char *result){ - - int lmax = 8; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - - switch (transvr_cls) { - case TRANSVR_CLASS_UNSPECIFIED: - case TRANSVR_CLASS_ERROR: - break; - /* 100G Optical */ - case TRANSVR_CLASS_OPTICAL_100G: - case TRANSVR_CLASS_OPTICAL_100G_AOC: - case TRANSVR_CLASS_OPTICAL_100G_SR4: - case TRANSVR_CLASS_OPTICAL_100G_LR4: - case TRANSVR_CLASS_OPTICAL_100G_ER4: - case TRANSVR_CLASS_OPTICAL_100G_PSM4: - return snprintf(result, lmax, TRANSVR_IF_SR4); - /* 100G Copper */ - case TRANSVR_CLASS_COPPER_L4_100G: - return snprintf(result, lmax, TRANSVR_IF_KR4); - /* 40G Optical */ - case TRANSVR_CLASS_OPTICAL_40G: - case TRANSVR_CLASS_OPTICAL_40G_AOC: - case TRANSVR_CLASS_OPTICAL_40G_SR4: - case TRANSVR_CLASS_OPTICAL_40G_LR4: - case TRANSVR_CLASS_OPTICAL_40G_ER4: - return snprintf(result, lmax, TRANSVR_IF_IF_XGMII); - /* 40G Copper */ - case TRANSVR_CLASS_COPPER_L4_40G: - return snprintf(result, lmax, TRANSVR_IF_IF_XGMII); - /* 10G Optical */ - case TRANSVR_CLASS_OPTICAL_10G: - case TRANSVR_CLASS_OPTICAL_10G_Q_AOC: - case TRANSVR_CLASS_OPTICAL_10G_Q_SR: /* Need Check: SR4 or SR */ - case TRANSVR_CLASS_OPTICAL_10G_Q_LR: /* Need Check: LR4 or LR */ - case TRANSVR_CLASS_OPTICAL_10G_Q_ER: /* Need Check: ER4 or ER */ - return snprintf(result, lmax, TRANSVR_IF_IF_XGMII); - /* Optical */ - case TRANSVR_CLASS_OPTICAL: - return snprintf(result, lmax, TRANSVR_IF_IF_XGMII); - /* Copper */ - case TRANSVR_CLASS_COPPER: - return snprintf(result, lmax, TRANSVR_IF_IF_XGMII); - default: - snprintf(err_msg, sizeof(err_msg), - "Detect undefined value:%d", - transvr_cls); - goto err_qsfp_set_magnolia_if_type_1; - } - /* Exception case: Can't verify */ - snprintf(err_msg, sizeof(err_msg), "Can not identify!"); - goto err_qsfp_set_magnolia_if_type_1; - -err_qsfp_set_magnolia_if_type_1: - snprintf(result, lmax, TRANSVR_UEVENT_UNKNOW); - SWPS_INFO("%s: %s\n :%s", __func__, err_msg, self->swp_name); - return ERR_TRANSVR_ABNORMAL; -} - - -int -_qsfp_set_redwood_if_type(struct transvr_obj_s* self, - int transvr_cls, - char *result){ - - int lmax = 8; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - - switch (transvr_cls) { - case TRANSVR_CLASS_UNSPECIFIED: - case TRANSVR_CLASS_ERROR: - break; - /* 100G Optical */ - case TRANSVR_CLASS_OPTICAL_100G: - case TRANSVR_CLASS_OPTICAL_100G_AOC: - case TRANSVR_CLASS_OPTICAL_100G_SR4: - case TRANSVR_CLASS_OPTICAL_100G_LR4: - case TRANSVR_CLASS_OPTICAL_100G_ER4: - case TRANSVR_CLASS_OPTICAL_100G_PSM4: - return snprintf(result, lmax, TRANSVR_IF_SR4); - /* 100G Copper */ - case TRANSVR_CLASS_COPPER_L4_100G: - return snprintf(result, lmax, TRANSVR_IF_KR4); - /* 40G Optical */ - case TRANSVR_CLASS_OPTICAL_40G: - case TRANSVR_CLASS_OPTICAL_40G_AOC: - case TRANSVR_CLASS_OPTICAL_40G_SR4: - case TRANSVR_CLASS_OPTICAL_40G_LR4: - case TRANSVR_CLASS_OPTICAL_40G_ER4: - return snprintf(result, lmax, TRANSVR_IF_SR4); - /* 40G Copper */ - case TRANSVR_CLASS_COPPER_L4_40G: - return snprintf(result, lmax, TRANSVR_IF_KR4); - /* 10G Optical */ - case TRANSVR_CLASS_OPTICAL_10G: - case TRANSVR_CLASS_OPTICAL_10G_Q_AOC: - case TRANSVR_CLASS_OPTICAL_10G_Q_SR: /* Need Check: SR4 or SR */ - case TRANSVR_CLASS_OPTICAL_10G_Q_LR: /* Need Check: SR4 or SR */ - case TRANSVR_CLASS_OPTICAL_10G_Q_ER: - return snprintf(result, lmax, TRANSVR_IF_SR4); - /* Optical */ - case TRANSVR_CLASS_OPTICAL: - return snprintf(result, lmax, TRANSVR_IF_SR4); - /* Copper */ - case TRANSVR_CLASS_COPPER: - return snprintf(result, lmax, TRANSVR_IF_KR4); - default: - snprintf(err_msg, sizeof(err_msg), - "Detect undefined value:%d", - transvr_cls); - goto err_qsfp_set_magnolia_if_type_1; - } - /* Exception case: Can't verify */ - snprintf(err_msg, sizeof(err_msg), "Can not identify!"); - goto err_qsfp_set_magnolia_if_type_1; - -err_qsfp_set_magnolia_if_type_1: - snprintf(result, lmax, TRANSVR_UEVENT_UNKNOW); - SWPS_INFO("%s: %s\n :%s", __func__, err_msg, self->swp_name); - return ERR_TRANSVR_ABNORMAL; -} - - -int -_qsfp_set_lavender_if_type(struct transvr_obj_s* self, - int transvr_cls, - char *result) { - /* (TBD) - * Due to 'LAV' looks like doesn't have interface type. - * We bypass it currently. - */ - int lmax = 8; - return snprintf(result, lmax, TRANSVR_UEVENT_UNKNOW); -} - - -int -_qsfp_detect_if_type(struct transvr_obj_s* self, - char *result){ - - int lmax = 8; - int detect_cls = DEBUG_TRANSVR_INT_VAL; - - detect_cls = qsft_detect_transvr_class(self); - switch (self->chipset_type) { - case CHIP_TYPE_MAGNOLIA: - return _qsfp_set_magnolia_if_type(self, detect_cls, result); - - case CHIP_TYPE_MAPLE: - case CHIP_TYPE_REDWOOD: - return _qsfp_set_redwood_if_type(self, detect_cls, result); - - case CHIP_TYPE_LAVENDER: - return _qsfp_set_lavender_if_type(self, detect_cls, result); - - default: - SWPS_INFO("%s: non-defined chipset_type:%d :%s\n", - __func__, self->chipset_type, self->swp_name); - break; - } - snprintf(result, lmax, TRANSVR_UEVENT_UNKNOW); - return ERR_TRANSVR_ABNORMAL; -} - - -int -qsfp_get_if_type(struct transvr_obj_s *self, - char *buf_p){ - - int lmax = 8; - char tmp_result[8] = DEBUG_TRANSVR_STR_VAL; - - if (self->state != STATE_TRANSVR_CONNECTED) { - return snprintf(buf_p, lmax, "%d\n", self->state); - } - if (_qsfp_detect_if_type(self, tmp_result) < 0) { - return snprintf(buf_p, lmax, "%d\n", ERR_TRANSVR_ABNORMAL); - } - return snprintf(buf_p, lmax, "%s\n", tmp_result); -} - - -int -_qsfp_detect_if_speed(struct transvr_obj_s* self, - char *result){ - int lmax = 16; - int detect_val = DEBUG_TRANSVR_INT_VAL; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - - detect_val = qsft_detect_transvr_class(self); - switch (detect_val) { - case TRANSVR_CLASS_UNSPECIFIED: - case TRANSVR_CLASS_ERROR: - break; - /* 100G Optical */ - case TRANSVR_CLASS_OPTICAL_100G: - case TRANSVR_CLASS_OPTICAL_100G_AOC: - case TRANSVR_CLASS_OPTICAL_100G_SR4: - case TRANSVR_CLASS_OPTICAL_100G_LR4: - case TRANSVR_CLASS_OPTICAL_100G_ER4: - case TRANSVR_CLASS_OPTICAL_100G_PSM4: - return snprintf(result, lmax, TRANSVR_IF_SP_100G); - /* 100G Copper */ - case TRANSVR_CLASS_COPPER_L4_100G: - return snprintf(result, lmax, TRANSVR_IF_SP_100G); - /* 40G Optical */ - case TRANSVR_CLASS_OPTICAL_40G: - case TRANSVR_CLASS_OPTICAL_40G_AOC: - case TRANSVR_CLASS_OPTICAL_40G_SR4: - case TRANSVR_CLASS_OPTICAL_40G_LR4: - case TRANSVR_CLASS_OPTICAL_40G_ER4: - return snprintf(result, lmax, TRANSVR_IF_SP_40G); - /* 40G Copper */ - case TRANSVR_CLASS_COPPER_L4_40G: - return snprintf(result, lmax, TRANSVR_IF_SP_40G); - /* 10G Optical */ - case TRANSVR_CLASS_OPTICAL_10G: - case TRANSVR_CLASS_OPTICAL_10G_Q_AOC: - case TRANSVR_CLASS_OPTICAL_10G_Q_SR: /* Need Check: SR4 or SR */ - case TRANSVR_CLASS_OPTICAL_10G_Q_LR: /* Need Check: SR4 or SR */ - case TRANSVR_CLASS_OPTICAL_10G_Q_ER: - return snprintf(result, lmax, TRANSVR_IF_SP_10G); - /* 10G Copper */ - case TRANSVR_CLASS_COPPER_L4_10G: - return snprintf(result, lmax, TRANSVR_IF_SP_10G); - /* Optical */ - case TRANSVR_CLASS_OPTICAL: - break; - /* Copper */ - case TRANSVR_CLASS_COPPER: - break; - default: - snprintf(err_msg, sizeof(err_msg), - "Detect undefined class case:%d", - detect_val); - goto err_qsfp_detect_if_speed_1; - } - /* Check br and extbr */ - detect_val = _qsfp_detect_if_sp_by_br(self); - switch(detect_val) { - case TRANSVR_CLASS_UNSPECIFIED: - break; - case TRANSVR_CLASS_10G: - return snprintf(result, lmax, TRANSVR_IF_SP_10G); - case TRANSVR_CLASS_40G: - return snprintf(result, lmax, TRANSVR_IF_SP_40G); - case TRANSVR_CLASS_100G: - return snprintf(result, lmax, TRANSVR_IF_SP_100G); - default: - snprintf(err_msg, sizeof(err_msg), - "Detect undefined BR case:%d", - detect_val); - goto err_qsfp_detect_if_speed_1; - } - /* Exception case: Can't verify */ - snprintf(err_msg, sizeof(err_msg), "Can not identify!"); - goto err_qsfp_detect_if_speed_1; - -err_qsfp_detect_if_speed_1: - snprintf(result, lmax, TRANSVR_UEVENT_UNKNOW); - SWPS_INFO("%s: %s :%s\n", __func__, err_msg, self->swp_name); - return ERR_TRANSVR_ABNORMAL; -} - - -int -qsfp_get_if_speed(struct transvr_obj_s *self, - char *buf_p){ - - int lmax = 16; - char tmp_result[16] = DEBUG_TRANSVR_STR_VAL; - - if (self->state != STATE_TRANSVR_CONNECTED) { - return snprintf(buf_p, lmax, "%d\n", self->state); - } - if (_qsfp_detect_if_speed(self, tmp_result) < 0) { - return snprintf(buf_p, lmax, "%d\n", ERR_TRANSVR_ABNORMAL); - } - return snprintf(buf_p, lmax, "%s\n", tmp_result); -} - - -int -_common_set_lane_map_str(struct transvr_obj_s* self, - char *result) { - int i = 0; - int tmp_val = 0; - char tmp_str[LEN_TRANSVR_L_STR] = DEBUG_TRANSVR_STR_VAL; - char err_msg[LEN_TRANSVR_L_STR] = DEBUG_TRANSVR_STR_VAL; - - memset(result, 0, LEN_TRANSVR_L_STR); - snprintf(result, LEN_TRANSVR_L_STR, "%s=", TRANSVR_UEVENT_KEY_LANE); - - for (i=0; ilane_id); i++) { - tmp_val = self->lane_id[i]; - if (tmp_val < 1) { - break; - } - if (tmp_val > 256) { - snprintf(err_msg, sizeof(err_msg), - "detect abnormal value:%d", tmp_val); - goto err_common_set_lane_map_str_1; - } - memset(tmp_str, 0, sizeof(tmp_str)); - if (i == 0) { - snprintf(tmp_str, LEN_TRANSVR_L_STR, "%d", tmp_val); - } else { - snprintf(tmp_str, LEN_TRANSVR_L_STR, ",%d", tmp_val); - } - strncat(result, tmp_str, LEN_TRANSVR_L_STR); - } - if (i == 0) { - goto err_common_set_lane_map_str_2; - } - return 0; - -err_common_set_lane_map_str_1: - SWPS_INFO("%s: %s", __func__, err_msg); -err_common_set_lane_map_str_2: - snprintf(result, LEN_TRANSVR_L_STR, "%s=%s", TRANSVR_UEVENT_KEY_LANE, TRANSVR_UEVENT_UNKNOW); - return EVENT_TRANSVR_TASK_FAIL; -} - - -int -_common_send_uevent(struct transvr_obj_s* self, - enum kobject_action u_action, - int (*detect_if_type)(struct transvr_obj_s *self, char *result), - int (*detect_if_speed)(struct transvr_obj_s *self, char *result), - int send_anyway) { - - char *uevent_envp[4]; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - char tmp_str[32] = DEBUG_TRANSVR_STR_VAL; - char tmp_str_1[32] = DEBUG_TRANSVR_STR_VAL; - char tmp_str_2[32] = DEBUG_TRANSVR_STR_VAL; - char tmp_str_3[64] = DEBUG_TRANSVR_STR_VAL; - - if (TRANSVR_UEVENT_ENABLE != 1) { - return ERR_TRANSVR_NOTSUPPORT; - } - if (_common_get_if_lane(self, tmp_str) < 0) { - snprintf(tmp_str_3, sizeof(tmp_str_3), - "%s=%s", TRANSVR_UEVENT_KEY_LANE, TRANSVR_UEVENT_UNKNOW); - } else { - snprintf(tmp_str_3, sizeof(tmp_str_3), - "%s=%s", TRANSVR_UEVENT_KEY_LANE, tmp_str); - } - switch (u_action) { - case KOBJ_ADD: - /* Detect type */ - if (detect_if_type(self, tmp_str) < 0) { - snprintf(err_msg, sizeof(err_msg), "%s", "Detect interface type fail!"); - snprintf(tmp_str_1, sizeof(tmp_str_1), "%s=%s", TRANSVR_UEVENT_KEY_IF, TRANSVR_UEVENT_UNKNOW); - snprintf(tmp_str_2, sizeof(tmp_str_2), "%s=%s", TRANSVR_UEVENT_KEY_SP, TRANSVR_UEVENT_UNKNOW); - uevent_envp[0] = tmp_str_1; - uevent_envp[1] = tmp_str_2; - uevent_envp[2] = tmp_str_3; - uevent_envp[3] = NULL; - goto private_common_send_uevent_4_fail; - } - snprintf(tmp_str_1, sizeof(tmp_str_1), "%s=%s", TRANSVR_UEVENT_KEY_IF, tmp_str); - uevent_envp[0] = tmp_str_1; - /* Detect speed */ - if (detect_if_speed(self, tmp_str) < 0) { - snprintf(err_msg, sizeof(err_msg), "%s", "Detect interface speed fail!"); - snprintf(tmp_str_2, sizeof(tmp_str_2), "%s=%s", TRANSVR_UEVENT_KEY_SP, TRANSVR_UEVENT_UNKNOW); - uevent_envp[1] = tmp_str_2; - uevent_envp[2] = tmp_str_3; - uevent_envp[3] = NULL; - goto private_common_send_uevent_4_fail; - } - snprintf(tmp_str_2, sizeof(tmp_str_2), "%s=%s", TRANSVR_UEVENT_KEY_SP, tmp_str); - uevent_envp[1] = tmp_str_2; - uevent_envp[2] = tmp_str_3; - uevent_envp[3] = NULL; - goto private_common_send_uevent_4_send; - - case KOBJ_REMOVE: - snprintf(tmp_str_1, sizeof(tmp_str_1), "%s=%s", TRANSVR_UEVENT_KEY_IF, TRANSVR_UEVENT_UNKNOW); - snprintf(tmp_str_2, sizeof(tmp_str_2), "%s=%s", TRANSVR_UEVENT_KEY_SP, TRANSVR_UEVENT_UNKNOW); - uevent_envp[0] = tmp_str_1; - uevent_envp[1] = tmp_str_2; - uevent_envp[2] = tmp_str_3; - uevent_envp[3] = NULL; - goto private_common_send_uevent_4_send; - - default: - snprintf(err_msg, sizeof(err_msg), "kobject_action:%d not support", u_action); - goto private_common_send_uevent_4_fail; - } - snprintf(err_msg, sizeof(err_msg), "%s", "Exception case"); - goto private_common_send_uevent_4_fail; - -private_common_send_uevent_4_fail: - SWPS_INFO("%s: %s :%s\n", __func__, err_msg, self->swp_name); - if (send_anyway) { - goto private_common_send_uevent_4_send; - } - return ERR_TRANSVR_UEVENT_FAIL; - -private_common_send_uevent_4_send: - return kobject_uevent_env(&(self->transvr_dev_p->kobj), - u_action, - uevent_envp); -} - -int -sfp_send_uevent(struct transvr_obj_s* self, - enum kobject_action u_action) { - int send_anyway = 1; - return _common_send_uevent(self, - u_action, - &_sfp_detect_if_type, - &_sfp_detect_if_speed, - send_anyway); -} - - -int -qsfp_send_uevent(struct transvr_obj_s* self, - enum kobject_action u_action) { - int send_anyway = 1; - return _common_send_uevent(self, - u_action, - &_qsfp_detect_if_type, - &_qsfp_detect_if_speed, - send_anyway); -} - - -int -fake_send_uevent(struct transvr_obj_s* self, - enum kobject_action u_action) { - return EVENT_TRANSVR_TASK_DONE; -} - - -int -common_fsm_4_direct_mode(struct transvr_obj_s* self, - char *caller_name){ - - int err; - int detect_result[2]; - int current_state = STATE_TRANSVR_UNEXCEPTED; - int current_type = TRANSVR_TYPE_ERROR; - - if (self->state == STATE_TRANSVR_NEW) { - if (_transvr_init_handler(self) < 0){ - return ERR_TRANSVR_INIT_FAIL; - } - } - err = detect_transvr_state(self, detect_result); - if (err < 0) { - return err; - } - /* In Direct mode, driver only detect transceiver when user call driver interface - * which on sysfs. So it only need consider the state of Transceiver. - */ - current_state = detect_result[0]; - current_type = detect_result[1]; - - switch (current_state){ - - case STATE_TRANSVR_DISCONNECTED: /* Transceiver is not plugged */ - self->state = current_state; - self->type = current_type; - return ERR_TRANSVR_UNPLUGGED; - - case STATE_TRANSVR_INIT: /* Transceiver is plugged, system not ready */ - return ERR_TRANSVR_UNINIT; - - case STATE_TRANSVR_ISOLATED: /* Transceiver is plugged, but has some issues */ - return ERR_TRNASVR_BE_ISOLATED; - - case STATE_TRANSVR_CONNECTED: /* Transceiver is plugged, system is ready */ - self->state = current_state; - self->type = current_type; - return 0; - - case STATE_TRANSVR_SWAPPED: /* Transceiver is plugged, system detect user changed */ - self->type = current_type; - if (reload_transvr_obj(self, current_type) < 0){ - self->state = STATE_TRANSVR_UNEXCEPTED; - return ERR_TRANSVR_UNEXCPT; - } - self->state = current_state; - return 0; - - case STATE_TRANSVR_UNEXCEPTED: /* Transceiver type or state is unexpected case */ - self->state = STATE_TRANSVR_UNEXCEPTED; - self->type = TRANSVR_TYPE_ERROR; - return ERR_TRANSVR_UNEXCPT; - - default: - SWPS_INFO("%s: state:%d not in define.\n", __func__, current_state); - break; - } - return ERR_TRANSVR_UNEXCPT; -} - - -static int -_is_except_happened_4_pmode(struct transvr_obj_s* self, - int new_state) { - - int event_chk = 0; - - if (self->temp == 0){ - return 0; - } - switch (new_state) { - case STATE_TRANSVR_INIT: - event_chk = EVENT_TRANSVR_EXCEP_INIT; - goto check_event_happened_4_pmode; - - case STATE_TRANSVR_CONNECTED: - event_chk = EVENT_TRANSVR_EXCEP_UP; - goto check_event_happened_4_pmode; - - case STATE_TRANSVR_DISCONNECTED: - event_chk = EVENT_TRANSVR_EXCEP_DOWN; - goto check_event_happened_4_pmode; - - case STATE_TRANSVR_SWAPPED: - event_chk = EVENT_TRANSVR_EXCEP_SWAP; - goto check_event_happened_4_pmode; - - case STATE_TRANSVR_UNEXCEPTED: - event_chk = EVENT_TRANSVR_EXCEP_EXCEP; - goto check_event_happened_4_pmode; - - case STATE_TRANSVR_ISOLATED: - event_chk = EVENT_TRANSVR_EXCEP_ISOLATED; - goto check_event_happened_4_pmode; - - default: - SWPS_INFO("%s: unexcepted case:%d\n", __func__, new_state); - break; - } - return 0; - -check_event_happened_4_pmode: - if (self->temp == event_chk){ - return 1; - } - return 0; -} - - -int -common_fsm_4_polling_mode(struct transvr_obj_s* self, - char *caller_name){ - /* [Return Value]: - * ERR_TRANSVR_UNINIT : (1) Initial not ready - * ERR_TRANSVR_UNPLUGGED : (1) Any -> Down - * ERR_TRANSVR_TASK_BUSY : (1) Wait Initial task - * ERR_TRANSVR_UNEXCPT : (1) Initial fail - * (2) Task fail - * (3) Reload fail - * ERR_TRNASVR_BE_ISOLATED : (1) Already be isolated - * OK Case (return 0) : (1) action_4_connected - * (2) action_4_nothing (initial retry) - */ - int curr_state[2]; - int old_state = self->state; - int old_type = self->type; - int new_state = STATE_TRANSVR_UNEXCEPTED; - int new_type = TRANSVR_TYPE_ERROR; - int return_val = ERR_TRANSVR_UNEXCPT; - - /* Never initial */ - if (self->state == STATE_TRANSVR_NEW) { - goto comfsm_action_4_reinit_obj; - } - /* Detect current state */ - switch (detect_transvr_state(self, curr_state)) { - case 0: - new_state = curr_state[0]; - new_type = curr_state[1]; - break; - - case ERR_TRNASVR_BE_ISOLATED: - new_state = STATE_TRANSVR_ISOLATED; - new_type = old_type; - break; - - case ERR_TRANSVR_I2C_CRASH: - goto comfsm_action_4_report_i2c_crash; - - case ERR_TRANSVR_UNEXCPT: - default: - new_state = STATE_TRANSVR_UNEXCEPTED; - new_type = old_type; - } - /* State handling */ - switch (old_state) { - case STATE_TRANSVR_INIT: /* INIT -> */ - return_val = ERR_TRANSVR_UNINIT; - goto comfsm_action_4_keep_state; - - case STATE_TRANSVR_CONNECTED: - switch (new_state) { - case STATE_TRANSVR_INIT: /* Case 1-1: UP -> INIT */ - SWPS_INFO("Detect %s is present. :1-1\n",self->swp_name); - return_val = ERR_TRANSVR_UNINIT; - goto comfsm_action_4_keep_state; - - case STATE_TRANSVR_CONNECTED: /* Case 1-2: UP -> UP */ - return_val = 0; - goto comfsm_action_4_keep_state; - - case STATE_TRANSVR_DISCONNECTED: /* Case 1-3: UP -> DOWN */ - SWPS_INFO("Detect %s is removed. :1-3\n",self->swp_name); - goto comfsm_action_4_disconnected; - - case STATE_TRANSVR_SWAPPED: /* Case 1-4: UP -> SWAP */ - SWPS_INFO("Detect %s is swapped. :1-4\n",self->swp_name); - goto comfsm_action_4_reload_obj; - - case STATE_TRANSVR_UNEXCEPTED: /* Case 1-5: UP -> UNEXPET */ - SWPS_INFO("Detect %s has error. :1-5\n",self->swp_name); - goto comfsm_action_4_unexpected; - - case STATE_TRANSVR_ISOLATED: /* Case 1-6: UP -> ISOLATE */ - SWPS_INFO("Detect %s be isolated. :1-6\n",self->swp_name); - goto comfsm_action_4_isolate_obj; - - default: - break; - } - goto comfsm_action_4_unexpected; - - case STATE_TRANSVR_DISCONNECTED: - switch (new_state) { - case STATE_TRANSVR_INIT: /* Case 2-1: DOWN -> INIT */ - SWPS_INFO("Detect %s is present. :2-1\n",self->swp_name); - return_val = ERR_TRANSVR_UNINIT; - goto comfsm_action_4_keep_state; - - case STATE_TRANSVR_CONNECTED: /* Case 2-2: DOWN -> UP */ - SWPS_INFO("Detect %s is present. :2-2\n",self->swp_name); - goto comfsm_action_4_reinit_obj; - - case STATE_TRANSVR_DISCONNECTED: /* Case 2-3: DOWN -> DOWN */ - return_val = ERR_TRANSVR_UNPLUGGED; - goto comfsm_action_4_keep_state; - - case STATE_TRANSVR_SWAPPED: /* Case 2-4: DOWN -> SWAP */ - SWPS_INFO("Detect %s is swapped. :2-4\n",self->swp_name); - goto comfsm_action_4_reload_obj; - - case STATE_TRANSVR_UNEXCEPTED: /* Case 2-5: DOWN -> UNEXPET */ - SWPS_INFO("Detect %s has error. :2-5\n",self->swp_name); - goto comfsm_action_4_unexpected; - - case STATE_TRANSVR_ISOLATED: /* Case 2-6: DOWN -> ISOLATE */ - SWPS_INFO("Detect %s be isolated. :2-6\n",self->swp_name); - goto comfsm_action_4_isolate_obj; - - default: - break; - } - goto comfsm_action_4_unexpected; - - case STATE_TRANSVR_UNEXCEPTED: - /* Filter out re-action */ - if (_is_except_happened_4_pmode(self, new_state)) { - goto comfsm_action_4_keep_state; - } - /* First action */ - switch (new_state) { - case STATE_TRANSVR_INIT: /* Case 3-1: UNEXPET -> INIT */ - SWPS_INFO("Detect %s is present. :3-1\n",self->swp_name); - self->temp = EVENT_TRANSVR_EXCEP_INIT; - return_val = ERR_TRANSVR_UNINIT; - goto comfsm_action_4_keep_state; - - case STATE_TRANSVR_CONNECTED: /* Case 3-2: UNEXPET -> UP */ - SWPS_INFO("Detect %s is present. :3-2\n",self->swp_name); - self->temp = EVENT_TRANSVR_EXCEP_UP; - goto comfsm_action_4_reload_obj; - - case STATE_TRANSVR_DISCONNECTED: /* Case 3-3: UNEXPET -> DOWN */ - SWPS_INFO("Detect %s is removed. :3-3\n",self->swp_name); - goto comfsm_action_4_disconnected; - - case STATE_TRANSVR_SWAPPED: /* Case 3-4: UNEXPET -> SWAP */ - SWPS_INFO("Detect %s is swapped. :3-4\n",self->swp_name); - self->temp = EVENT_TRANSVR_EXCEP_SWAP; - goto comfsm_action_4_reload_obj; - - case STATE_TRANSVR_UNEXCEPTED: /* Case 3-5: UNEXPET -> UNEXPET */ - self->temp = EVENT_TRANSVR_EXCEP_EXCEP; - return_val = ERR_TRANSVR_UNEXCPT; - goto comfsm_action_4_keep_state; - - case STATE_TRANSVR_ISOLATED: /* Case 3-6: UNEXPET -> ISOLATE */ - SWPS_INFO("Detect %s be isolated. :3-6\n",self->swp_name); - goto comfsm_action_4_isolate_obj; - - default: - break; - } - goto comfsm_action_4_unexpected; - - case STATE_TRANSVR_ISOLATED: - /* Filter out re-action */ - if (_is_except_happened_4_pmode(self, new_state)) { - goto comfsm_action_4_keep_state; - } - /* First action */ - switch (new_state) { - case STATE_TRANSVR_INIT: /* Case 4-1: ISOLATE -> INIT */ - SWPS_INFO("Detect %s internal error. :4-1\n",self->swp_name); - self->temp = EVENT_TRANSVR_EXCEP_INIT; - return_val = ERR_TRNASVR_BE_ISOLATED; - goto comfsm_action_4_keep_state; - - case STATE_TRANSVR_CONNECTED: /* Case 4-2: ISOLATE -> UP */ - SWPS_INFO("Detect %s internal error. :4-2\n",self->swp_name); - self->temp = EVENT_TRANSVR_EXCEP_UP; - return_val = ERR_TRNASVR_BE_ISOLATED; - goto comfsm_action_4_keep_state; - - case STATE_TRANSVR_DISCONNECTED: /* Case 4-3: ISOLATE -> DOWN */ - SWPS_INFO("Detect %s is removed. :4-3\n",self->swp_name); - goto comfsm_action_4_disconnected; - - case STATE_TRANSVR_SWAPPED: /* Case 4-4: ISOLATE -> SWAP */ - SWPS_INFO("Detect %s internal error. :4-4\n",self->swp_name); - self->temp = EVENT_TRANSVR_EXCEP_SWAP; - return_val = ERR_TRNASVR_BE_ISOLATED; - goto comfsm_action_4_keep_state; - - case STATE_TRANSVR_UNEXCEPTED: /* Case 4-5: ISOLATE -> UNEXPET */ - SWPS_INFO("Detect %s internal error. :4-5\n",self->swp_name); - self->temp = EVENT_TRANSVR_EXCEP_EXCEP; - return_val = ERR_TRNASVR_BE_ISOLATED; - goto comfsm_action_4_keep_state; - - case STATE_TRANSVR_ISOLATED: /* Case 4-6: ISOLATE -> ISOLATE */ - return_val = ERR_TRNASVR_BE_ISOLATED; - goto comfsm_action_4_keep_state; - - default: - break; - } - goto comfsm_action_4_unexpected; - - default: - break; - } - goto comfsm_action_4_unexpected; - - -comfsm_action_4_keep_state: - return return_val; - -comfsm_action_4_reinit_obj: - SWPS_DEBUG("FSM action: %s re-initial.\n", self->swp_name); - return_val = _transvr_init_handler(self); - goto comfsm_action_4_identify_event; - -comfsm_action_4_reload_obj: - SWPS_DEBUG("FSM action: %s reload.\n", self->swp_name); - self->type = new_type; - return_val = reload_transvr_obj(self, new_type); - goto comfsm_action_4_identify_event; - -comfsm_action_4_identify_event: - switch (return_val) { - case EVENT_TRANSVR_INIT_UP: - case EVENT_TRANSVR_TASK_DONE: - goto comfsm_action_4_connected; - - case EVENT_TRANSVR_INIT_DOWN: - goto comfsm_action_4_disconnected; - - case EVENT_TRANSVR_INIT_REINIT: - goto comfsm_action_4_nothing; - - case EVENT_TRANSVR_TASK_WAIT: - self->state = STATE_TRANSVR_INIT; - return ERR_TRANSVR_TASK_BUSY; - - case EVENT_TRANSVR_TASK_FAIL: - SWPS_INFO("%s detect EVENT_TRANSVR_TASK_FAIL.\n", self->swp_name); - goto comfsm_action_4_unexpected; - - case EVENT_TRANSVR_INIT_FAIL: - SWPS_INFO("%s detect EVENT_TRANSVR_INIT_FAIL.\n", self->swp_name); - goto comfsm_action_4_unexpected; - - case EVENT_TRANSVR_RELOAD_FAIL: - SWPS_INFO("%s detect EVENT_TRANSVR_RELOAD_FAIL.\n", self->swp_name); - goto comfsm_action_4_unexpected; - - case EVENT_TRANSVR_I2C_CRASH: - goto comfsm_action_4_report_i2c_crash; - - case EVENT_TRANSVR_EXCEP_ISOLATED: - goto comfsm_action_4_isolate_obj; - - default: - SWPS_INFO("%s detect undefined event:%d.\n", self->swp_name, return_val); - goto comfsm_action_4_unexpected; - } - -comfsm_action_4_nothing: - SWPS_DEBUG("FSM action: %s do nothing.\n", self->swp_name); - return 0; - -comfsm_action_4_connected: - SWPS_DEBUG("FSM action: %s Connected.\n", self->swp_name); - self->state = STATE_TRANSVR_CONNECTED; - self->type = new_type; - self->send_uevent(self, KOBJ_ADD); - _transvr_clean_retry(self); - return 0; - -comfsm_action_4_disconnected: - SWPS_DEBUG("FSM action: %s Disconnected. \n", self->swp_name); - self->state = STATE_TRANSVR_DISCONNECTED; - self->temp = EVENT_TRANSVR_TASK_DONE; - self->send_uevent(self, KOBJ_REMOVE); - _transvr_clean_retry(self); - _transvr_clean_handler(self); - return ERR_TRANSVR_UNPLUGGED; - -comfsm_action_4_report_i2c_crash: - SWPS_DEBUG("FSM action: %s report I2C crash.\n", self->swp_name); - self->state = STATE_TRANSVR_UNEXCEPTED; - return ERR_TRANSVR_I2C_CRASH; - -comfsm_action_4_isolate_obj: - SWPS_DEBUG("FSM action: %s isolate.\n", self->swp_name); - self->state = STATE_TRANSVR_ISOLATED; - return ERR_TRNASVR_BE_ISOLATED; - -comfsm_action_4_unexpected: - SWPS_INFO("FSM action: %s unexpected.\n", self->swp_name); - SWPS_INFO("Dump: :%d :0x%02x :%d :0x%02x\n", - old_state, old_type, new_state, new_type); - self->state = STATE_TRANSVR_UNEXCEPTED; - self->send_uevent(self, KOBJ_REMOVE); - _transvr_clean_handler(self); - return ERR_TRANSVR_UNEXCPT; -} - - -int -fake_fsm_4_direct_mode(struct transvr_obj_s* self, - char *caller_name){ - self->state = STATE_TRANSVR_CONNECTED; - self->type = TRANSVR_TYPE_FAKE; - return 0; -} - - -int -fake_fsm_4_polling_mode(struct transvr_obj_s* self, - char *caller_name){ - self->state = STATE_TRANSVR_CONNECTED; - self->type = TRANSVR_TYPE_FAKE; - return 0; -} - - -/* ========== Object functions for Initial procedure ========== - */ -int -transvr_init_common(struct transvr_obj_s *self){ - /* Nothing to update */ - return EVENT_TRANSVR_TASK_DONE; -} - - -int -transvr_init_fake(struct transvr_obj_s *self){ - return EVENT_TRANSVR_TASK_DONE; -} - - -int -transvr_init_sfp(struct transvr_obj_s *self){ - - int tmp_val = DEBUG_TRANSVR_INT_VAL; - int err_code = DEBUG_TRANSVR_INT_VAL; - char *err_msg = "ERR"; - - self->info = sft_detect_transvr_class(self); - /* Disable auto_config */ - if (!self->auto_config) { - return EVENT_TRANSVR_TASK_DONE; - } - /* Handle multi-rate */ - err_code = initfunc_sfp_handle_multi_rate_mode(self); - if (err_code < 0) { - err_msg = "initfunc_sfp_handle_multi_rate_mode fail!"; - goto err_transvr_init_sfp_1; - } - /* Handle 1G- RJ45 */ - tmp_val = err_code; - err_code = initfunc_sfp_handle_1g_rj45(self); - if (err_code < 0) { - err_msg = "initfunc_sfp_handle_1g_rj45 fail!"; - goto err_transvr_init_sfp_1; - } - tmp_val = (tmp_val > err_code ? tmp_val : err_code); - if (tmp_val > EVENT_TRANSVR_TASK_DONE) { - return tmp_val; - } - return EVENT_TRANSVR_TASK_DONE; - -err_transvr_init_sfp_1: - SWPS_INFO("%s: %s :%d :%s\n", - __func__, err_msg, err_code, self->swp_name); - return EVENT_TRANSVR_INIT_FAIL; -} - - -int -transvr_init_qsfp(struct transvr_obj_s *self){ - - int err = EVENT_TRANSVR_EXCEP_EXCEP; - char *emsg = "ERR"; - - self->info = qsft_detect_transvr_class(self); - if (!self->auto_config) { - return EVENT_TRANSVR_TASK_DONE; - } - err = initfunc_qsfp_handle_power_mode(self); - if (err < 0){ - emsg = "initfunc_qsfp_handle_tx_disable fail!"; - goto err_transvr_init_qsfp; - } - return EVENT_TRANSVR_TASK_DONE; - -err_transvr_init_qsfp: - SWPS_INFO("%s: %s :%d :%s\n", - __func__, emsg, err, self->swp_name); - return EVENT_TRANSVR_INIT_FAIL; -} - - -int -transvr_init_qsfp28(struct transvr_obj_s *self){ - - int tmp_val = EVENT_TRANSVR_EXCEP_EXCEP; - int err_val = EVENT_TRANSVR_EXCEP_EXCEP; - char *err_msg = "ERR"; - - /* Handle QSFP common */ - err_val = transvr_init_qsfp(self); - if (err_val < 0){ - err_msg = "transvr_init_qsfp fail!"; - goto err_transvr_init_qsfp28_1; - } - /* Disable auto_config */ - if (!self->auto_config) { - return err_val; - } - /* Handle CDR */ - tmp_val = err_val; - err_val = initfunc_qsfp28_handle_cdr(self); - if (err_val < 0){ - err_msg = "Handle CDR fail!"; - goto err_transvr_init_qsfp28_1; - } - tmp_val = (tmp_val > err_val ? tmp_val : err_val); - if (tmp_val > EVENT_TRANSVR_TASK_DONE) { - return tmp_val; - } - return EVENT_TRANSVR_TASK_DONE; - -err_transvr_init_qsfp28_1: - SWPS_INFO("%s: %s :%d :%s\n", - __func__, err_msg, err_val, self->swp_name); - return EVENT_TRANSVR_INIT_FAIL; -} - - -/* ========== Object Initial handler ========== - */ -static int -_is_transvr_valid(struct transvr_obj_s *self, - int type, - int state) { - /* [Return] - * 0 : OK, inserted - * EVENT_TRANSVR_INIT_DOWN : OK, removed - * EVENT_TRANSVR_INIT_FAIL : Outside error, type doesn't supported - * EVENT_TRANSVR_EXCEP_INIT : Internal error, state undefined - */ - switch (type) { - case TRANSVR_TYPE_SFP: - case TRANSVR_TYPE_QSFP: - case TRANSVR_TYPE_QSFP_PLUS: - case TRANSVR_TYPE_QSFP_28: - case TRANSVR_TYPE_UNPLUGGED: - case TRANSVR_TYPE_FAKE: - break; - default: - SWPS_INFO("detect undefined type:0x%02x on %s\n", - type, self->swp_name); - return EVENT_TRANSVR_INIT_FAIL; - } - switch (state) { - case STATE_TRANSVR_DISCONNECTED: - return EVENT_TRANSVR_INIT_DOWN; - case STATE_TRANSVR_INIT: - case STATE_TRANSVR_CONNECTED: - case STATE_TRANSVR_SWAPPED: - break; - default: - SWPS_INFO("detect undefined state:%d on %s\n", - state, self->swp_name); - return EVENT_TRANSVR_EXCEP_INIT; - } - return 0; -} - - -static int -_is_transvr_hw_ready(struct transvr_obj_s *self, - int type){ - /* [Return] - * EVENT_TRANSVR_TASK_DONE : Ready - * EVENT_TRANSVR_TASK_WAIT : Not ready - * EVENT_TRANSVR_INIT_FAIL : Error - */ - int addr = DEBUG_TRANSVR_INT_VAL; - int page = DEBUG_TRANSVR_INT_VAL; - int offs = DEBUG_TRANSVR_INT_VAL; - int bit = DEBUG_TRANSVR_INT_VAL; - int ready = DEBUG_TRANSVR_INT_VAL; - int err = DEBUG_TRANSVR_INT_VAL; - char *emsg = DEBUG_TRANSVR_STR_VAL; - uint8_t ab_val = DEBUG_TRANSVR_HEX_VAL; - - switch (type) { - case TRANSVR_TYPE_SFP: - addr = VAL_TRANSVR_8472_READY_ADDR; - page = VAL_TRANSVR_8472_READY_PAGE; - offs = VAL_TRANSVR_8472_READY_OFFSET; - bit = VAL_TRANSVR_8472_READY_BIT; - ready = VAL_TRANSVR_8472_READY_VALUE; - ab_val = VAL_TRANSVR_8472_READY_ABNORMAL; - break; - - case TRANSVR_TYPE_QSFP: - case TRANSVR_TYPE_QSFP_PLUS: - case TRANSVR_TYPE_QSFP_28: - addr = VAL_TRANSVR_8436_READY_ADDR; - page = VAL_TRANSVR_8436_READY_PAGE; - offs = VAL_TRANSVR_8436_READY_OFFSET; - bit = VAL_TRANSVR_8436_READY_BIT; - ready = VAL_TRANSVR_8436_READY_VALUE; - ab_val = VAL_TRANSVR_8436_READY_ABNORMAL; - break; - - case TRANSVR_TYPE_UNPLUGGED: - case TRANSVR_TYPE_FAKE: - return EVENT_TRANSVR_TASK_DONE; - - default: - emsg = "unexpected case"; - goto err_is_transvr_hw_ready; - } - /* Select target page */ - err = _common_setup_page(self, addr, page, offs, 1, 0); - if (err < 0) { - emsg = "setup page fail"; - goto err_is_transvr_hw_ready; - } - /* Check feature supported - * [Note] - * Some of transceiver/cables doesn't support "Status Indicators" - * (ex:DAC, RJ45 copper SFP ...etc). In these case, we bypass the - * step of checking Status Indicators, then state machine will take - * the following handle procedure. - */ - err = i2c_smbus_read_byte_data(self->i2c_client_p, - VAL_TRANSVR_COMID_OFFSET); - if (err < 0) { - emsg = "doesn't support Status Indicators"; - goto bypass_is_transvr_hw_ready; - } - /* Filter abnormal case */ - if (err == ab_val) { - emsg = "detect using unusual definition."; - goto bypass_is_transvr_hw_ready; - } - /* Get Status Indicators */ - err = i2c_smbus_read_byte_data(self->i2c_client_p, offs); - if (err < 0) { - emsg = "detect current value fail"; - goto err_is_transvr_hw_ready; - } - - if ((err & (1<:%d\n", __func__, emsg, type); - return EVENT_TRANSVR_TASK_DONE; - -err_is_transvr_hw_ready: - SWPS_DEBUG("%s: %s :%d\n", __func__, emsg, type); - return EVENT_TRANSVR_INIT_FAIL; -} - - -static int -_is_transvr_support_ctle(struct transvr_obj_s *self) { - - switch (self->info) { - case TRANSVR_CLASS_OPTICAL_25G: - case TRANSVR_CLASS_OPTICAL_25G_AOC: - case TRANSVR_CLASS_OPTICAL_25G_SR: - case TRANSVR_CLASS_OPTICAL_25G_LR: - case TRANSVR_CLASS_OPTICAL_25G_ER: - case TRANSVR_CLASS_OPTICAL_100G: - case TRANSVR_CLASS_OPTICAL_100G_AOC: - case TRANSVR_CLASS_OPTICAL_100G_SR4: - case TRANSVR_CLASS_OPTICAL_100G_LR4: - case TRANSVR_CLASS_OPTICAL_100G_ER4: - case TRANSVR_CLASS_OPTICAL_100G_PSM4: - return 1; - default: - break; - } - return 0; -} - - -static int -_transvr_init_handler(struct transvr_obj_s *self){ - - int detect[2]; - int d_state = STATE_TRANSVR_UNEXCEPTED; - int d_type = TRANSVR_TYPE_ERROR; - int result = ERR_TRANSVR_UNINIT; - int retry = 6; /* (6+1) x 0.3 = 2.1s > spec:2.0s */ - int elimit = 63; - char emsg[64] = DEBUG_TRANSVR_STR_VAL; - - /* Clean and check callback */ - self->state = STATE_TRANSVR_INIT; - if (self->init == NULL) { - snprintf(emsg, elimit, "init() is null"); - goto initer_err_case_unexcept_0; - } - if (self->clean == NULL) { - snprintf(emsg, elimit, "clean() is null"); - goto initer_err_case_unexcept_0; - } - self->clean(self); - - /* Detect transceiver information */ - result = detect_transvr_state(self, detect); - if (result < 0) { - snprintf(emsg, elimit, "detect_transvr_state() fail"); - switch (result) { - case ERR_TRANSVR_I2C_CRASH: - goto initer_err_case_i2c_ceash; - case ERR_TRNASVR_BE_ISOLATED: - goto initer_err_case_be_isolated; - - case ERR_TRANSVR_UNEXCPT: - default: - break; - } - goto initer_err_case_retry_1; - } - d_state = detect[0]; - d_type = detect[1]; - - /* Verify transceiver type and state */ - switch (_is_transvr_valid(self, d_type, d_state)) { - case 0: - break; - case EVENT_TRANSVR_INIT_DOWN: - goto initer_ok_case_down;; - case EVENT_TRANSVR_INIT_FAIL: - snprintf(emsg, elimit, "transceiver type doesn't support"); - goto initer_err_case_alarm_to_user; - case EVENT_TRANSVR_EXCEP_INIT: - default: - goto initer_err_case_unexcept_1; - } - - /* Handle reload case */ - if (self->type != d_type){ - /* This is the protect mechanism. Normally, This case will not happen. - * When State machine detect swap event during initial, It will trigger - * reload function to ensure type correct. */ - if (_reload_transvr_obj(self, d_type) < 0){ - snprintf(emsg, elimit, "reload object fail"); - goto initer_err_case_unexcept_1; - } - } - - /* Check transceiver HW initial ready */ - switch (_is_transvr_hw_ready(self, d_type)) { - case EVENT_TRANSVR_TASK_DONE: - break; - case EVENT_TRANSVR_TASK_WAIT: - goto initer_err_case_retry_1; - case EVENT_TRANSVR_INIT_FAIL: - default: - goto initer_err_case_unexcept_1; - } - - /* Try to update all and check */ - if (self->update_all(self, 1) < 0){ - /* For some transceiver, EEPROME has lag issues during initial stage. - * In this case, we set status back to STATE_TRANSVR_NEW, than it will - * be checked in next polling cycle. */ - goto initer_err_case_retry_1; - } - - /* Execute init() call back */ - result = self->init(self); - switch (result) { - case EVENT_TRANSVR_TASK_DONE: - break; - case EVENT_TRANSVR_TASK_WAIT: - goto initer_ok_case_wait; - - default: - snprintf(emsg, elimit, "undefined init() return:%d\n", result); - goto initer_err_case_unexcept_1; - } - goto initer_ok_case_up; - - -initer_ok_case_wait: - self->dump_all(self); - return EVENT_TRANSVR_TASK_WAIT; - -initer_ok_case_up: - self->state = STATE_TRANSVR_CONNECTED; - self->temp = 0; - self->dump_all(self); - return EVENT_TRANSVR_INIT_UP; - -initer_ok_case_down: - self->temp = 0; - self->state = STATE_TRANSVR_DISCONNECTED; - return EVENT_TRANSVR_INIT_DOWN; - -initer_err_case_i2c_ceash: - SWPS_DEBUG("%s: %s :%s :I2C crash\n", - __func__, emsg, self->swp_name); - self->state = STATE_TRANSVR_UNEXCEPTED; - return EVENT_TRANSVR_I2C_CRASH; - -initer_err_case_be_isolated: - SWPS_DEBUG("%s: %s :%s :isolated\n", - __func__, emsg, self->swp_name); - self->state = STATE_TRANSVR_ISOLATED; - return EVENT_TRANSVR_EXCEP_ISOLATED; - -initer_err_case_retry_1: - SWPS_DEBUG("%s: %s :%s :retry\n", - __func__, emsg, self->swp_name); - if (_transvr_handle_retry(self, retry) == 0) { - self->state = STATE_TRANSVR_NEW; - return EVENT_TRANSVR_INIT_REINIT; - } - goto initer_err_case_alarm_to_user; - -initer_err_case_unexcept_1: - self->clean(self); -initer_err_case_unexcept_0: - self->state = STATE_TRANSVR_UNEXCEPTED; - if (_is_except_happened_4_pmode(self, d_state) && - (self->mode == TRANSVR_MODE_POLLING) ){ - SWPS_INFO("%s: %s :%s\n", __func__, emsg, self->swp_name); - SWPS_INFO("Dump: :%d :%d :%d :%d\n", - self->state, self->type, d_state, d_type); - } - return EVENT_TRANSVR_INIT_FAIL; - -initer_err_case_alarm_to_user: - SWPS_DEBUG("%s: %s :%s :alarm_to_user\n", - __func__, emsg, self->swp_name); - self->state = STATE_TRANSVR_UNEXCEPTED; - alarm_msg_2_user(self, "detected transceiver/cables not meet SFF standard"); - return EVENT_TRANSVR_INIT_FAIL; -} - - -/* ========== Object functions for Clean procedure ========== - */ -int -_transvr_clean_handler(struct transvr_obj_s *self){ - - int retval = DEBUG_TRANSVR_INT_VAL; - - if (!self->clean) { - SWPS_ERR("%s: %s clean() is NULL.\n", - __func__, self->swp_name); - return EVENT_TRANSVR_TASK_FAIL; - } - retval = self->clean(self); - if (retval != EVENT_TRANSVR_TASK_DONE){ - SWPS_ERR("%s: %s clean() fail. [ERR]:%d\n", - __func__, self->swp_name, retval); - return retval; - } - return EVENT_TRANSVR_TASK_DONE; -} - - -int -common_transvr_clean(struct transvr_obj_s *self){ - - transvr_task_free_all(self); - transvr_cache_free_all(self); - return EVENT_TRANSVR_TASK_DONE; -} - - -int -qsfp_transvr_clean(struct transvr_obj_s *self){ - - int retval; - int lpower_config = 1; - - retval = _taskfunc_qsfp_setup_power_mod(self, lpower_config); - if (retval < 0){ - SWPS_ERR("%s: Set lpmod fail! :%d\n", - __func__, retval); - return retval; - } - retval = common_transvr_clean(self); - if (retval < 0){ - SWPS_ERR("%s: common_transvr_clean fail! :%d\n", - __func__, retval); - return retval; - } - return EVENT_TRANSVR_TASK_DONE; -} - - -int -fake_transvr_clean(struct transvr_obj_s *self){ - - return EVENT_TRANSVR_TASK_DONE; -} - - -/* ========== Object functions for check and update ========== - */ -int -common_transvr_check(struct transvr_obj_s *self){ - - char fun_str[32] = "common_transvr_check"; - - if (self->mode != TRANSVR_MODE_POLLING) { - SWPS_ERR("%s: mode:%d is not TRANSVR_MODE_POLLING\n", - fun_str, self->mode); - return ERR_TRANSVR_UNEXCPT; - } - /* Trigger delay task */ - transvr_task_run_all(self); - /* Trigger state machine to check and update */ - return self->fsm_4_polling(self, fun_str); -} - - -int -fake_transvr_check(struct transvr_obj_s *self){ - return 0; -} - - -/* ========== Functions for Factory pattern ========== - */ -static int -setup_transvr_public_cb(struct transvr_obj_s *self, - int transvr_type){ - switch (transvr_type){ - case TRANSVR_TYPE_SFP: - self->get_id = common_get_id; - self->get_ext_id = common_get_ext_id; - self->get_connector = common_get_connector; - self->get_vendor_name = common_get_vendor_name; - self->get_vendor_pn = common_get_vendor_pn; - self->get_vendor_rev = common_get_vendor_rev; - self->get_vendor_sn = common_get_vendor_sn; - self->get_power_cls = unsupported_get_func; - self->get_br = common_get_br; - self->get_len_sm = sfp_get_len_sm; - self->get_len_smf = common_get_len_smf; - self->get_len_om1 = common_get_len_om1; - self->get_len_om2 = common_get_len_om2; - self->get_len_om3 = common_get_len_om3; - self->get_len_om4 = common_get_len_om4; - self->get_comp_rev = common_get_comp_rev; - self->get_comp_eth_1 = sfp_get_comp_eth_1; - self->get_comp_eth_10 = sfp_get_comp_eth_10; - self->get_comp_eth_10_40 = unsupported_get_func; - self->get_comp_extend = common_get_comp_extended; - self->get_cdr = unsupported_get_func; - self->get_rate_id = sfp_get_rate_id; - self->get_soft_rs0 = sfp_get_soft_rs0; - self->get_soft_rs1 = sfp_get_soft_rs1; - self->get_info = common_get_info; - self->get_if_type = sfp_get_if_type; - self->get_if_speed = sfp_get_if_speed; - self->get_if_lane = common_get_if_lane; - self->get_curr_temp = sfp_get_transvr_temp; - self->get_curr_vol = sfp_get_transvr_voltage; - self->get_soft_rx_los = unsupported_get_func2; - self->get_soft_tx_disable = unsupported_get_func2; - self->get_soft_tx_fault = unsupported_get_func2; - self->get_auto_tx_disable = unsupported_get_func2; - self->get_tx_bias = sfp_get_transvr_tx_bias; - self->get_tx_power = sfp_get_transvr_tx_power; - self->get_rx_power = sfp_get_transvr_rx_power; - self->get_tx_eq = sfp_get_transvr_tx_eq; - self->get_rx_am = unsupported_get_func2; - self->get_rx_em = sfp_get_transvr_rx_em; - self->get_wavelength = sfp_get_wavelength; - self->get_extphy_offset = sfp_get_1g_rj45_extphy_offset; - self->get_extphy_reg = sfp_get_1g_rj45_extphy_reg; - self->set_cdr = unsupported_set_func; - self->set_soft_rs0 = sfp_set_soft_rs0; - self->set_soft_rs1 = sfp_set_soft_rs1; - self->set_soft_tx_disable = unsupported_set_func; - self->set_auto_tx_disable = unsupported_set_func; - self->set_tx_eq = sfp_set_tx_eq; - self->set_rx_am = unsupported_set_func; - self->set_rx_em = sfp_set_rx_em; - self->set_extphy_offset = sfp_set_1g_rj45_extphy_offset; - self->set_extphy_reg = sfp_set_1g_rj45_extphy_reg; - return 0; - - case TRANSVR_TYPE_QSFP: - case TRANSVR_TYPE_QSFP_PLUS: - self->get_id = common_get_id; - self->get_ext_id = common_get_ext_id; - self->get_connector = common_get_connector; - self->get_vendor_name = common_get_vendor_name; - self->get_vendor_pn = common_get_vendor_pn; - self->get_vendor_rev = common_get_vendor_rev; - self->get_vendor_sn = common_get_vendor_sn; - self->get_power_cls = qsfp_get_power_cls; - self->get_br = common_get_br; - self->get_len_sm = unsupported_get_func; - self->get_len_smf = common_get_len_smf; - self->get_len_om1 = common_get_len_om1; - self->get_len_om2 = common_get_len_om2; - self->get_len_om3 = common_get_len_om3; - self->get_len_om4 = common_get_len_om4; - self->get_comp_rev = common_get_comp_rev; - self->get_comp_eth_1 = qsfp_get_comp_eth; - self->get_comp_eth_10 = unsupported_get_func; - self->get_comp_eth_10_40 = qsfp_get_comp_10_40; - self->get_comp_extend = common_get_comp_extended; - self->get_cdr = unsupported_get_func; - self->get_rate_id = unsupported_get_func; - self->get_soft_rs0 = unsupported_get_func; /* TBD */ - self->get_soft_rs1 = unsupported_get_func; /* TBD */ - self->get_info = common_get_info; - self->get_if_type = qsfp_get_if_type; - self->get_if_speed = qsfp_get_if_speed; - self->get_if_lane = common_get_if_lane; - self->get_curr_temp = qsfp_get_transvr_temp; - self->get_curr_vol = qsfp_get_transvr_voltage; - self->get_soft_rx_los = qsfp_get_soft_rx_los; - self->get_soft_tx_disable = qsfp_get_soft_tx_disable; - self->get_soft_tx_fault = qsfp_get_soft_tx_fault; - self->get_auto_tx_disable = qsfp_get_auto_tx_disable; - self->get_tx_bias = qsfp_get_transvr_tx_bias; - self->get_tx_power = qsfp_get_transvr_tx_power; - self->get_rx_power = qsfp_get_transvr_rx_power; - self->get_tx_eq = unsupported_get_func2; - self->get_rx_am = unsupported_get_func2; - self->get_rx_em = unsupported_get_func2; - self->get_wavelength = qsfp_get_wavelength; - self->get_extphy_offset = unsupported_get_func2; - self->get_extphy_reg = unsupported_get_func2; - self->set_cdr = unsupported_set_func; - self->set_soft_rs0 = unsupported_set_func; /* TBD */ - self->set_soft_rs1 = unsupported_set_func; /* TBD */ - self->set_soft_tx_disable = qsfp_set_soft_tx_disable; - self->set_auto_tx_disable = qsfp_set_auto_tx_disable; - self->set_tx_eq = unsupported_set_func; - self->set_rx_am = unsupported_set_func; - self->set_rx_em = unsupported_set_func; - self->set_extphy_offset = unsupported_set_func; - self->set_extphy_reg = unsupported_set_func; - return 0; - - case TRANSVR_TYPE_QSFP_28: - self->get_id = common_get_id; - self->get_ext_id = common_get_ext_id; - self->get_connector = common_get_connector; - self->get_vendor_name = common_get_vendor_name; - self->get_vendor_pn = common_get_vendor_pn; - self->get_vendor_rev = common_get_vendor_rev; - self->get_vendor_sn = common_get_vendor_sn; - self->get_power_cls = qsfp_get_power_cls; - self->get_br = common_get_br; - self->get_len_sm = unsupported_get_func; - self->get_len_smf = common_get_len_smf; - self->get_len_om1 = common_get_len_om1; - self->get_len_om2 = common_get_len_om2; - self->get_len_om3 = common_get_len_om3; - self->get_len_om4 = common_get_len_om4; - self->get_comp_rev = common_get_comp_rev; - self->get_comp_eth_1 = qsfp_get_comp_eth; - self->get_comp_eth_10 = unsupported_get_func; - self->get_comp_eth_10_40 = qsfp_get_comp_10_40; - self->get_comp_extend = common_get_comp_extended; - self->get_cdr = qsfp_get_cdr; - self->get_rate_id = unsupported_get_func; - self->get_soft_rs0 = unsupported_get_func; /* TBD */ - self->get_soft_rs1 = unsupported_get_func; /* TBD */ - self->get_info = common_get_info; - self->get_if_type = qsfp_get_if_type; - self->get_if_speed = qsfp_get_if_speed; - self->get_if_lane = common_get_if_lane; - self->get_curr_temp = qsfp_get_transvr_temp; - self->get_curr_vol = qsfp_get_transvr_voltage; - self->get_soft_rx_los = qsfp_get_soft_rx_los; - self->get_soft_tx_disable = qsfp_get_soft_tx_disable; - self->get_soft_tx_fault = qsfp_get_soft_tx_fault; - self->get_auto_tx_disable = qsfp_get_auto_tx_disable; - self->get_tx_bias = qsfp_get_transvr_tx_bias; - self->get_tx_power = qsfp_get_transvr_tx_power; - self->get_rx_power = qsfp_get_transvr_rx_power; - self->get_tx_eq = qsfp_get_transvr_tx_eq; - self->get_rx_am = qsfp_get_transvr_rx_am; - self->get_rx_em = qsfp_get_transvr_rx_em; - self->get_wavelength = qsfp_get_wavelength; - self->get_extphy_offset = unsupported_get_func2; - self->get_extphy_reg = unsupported_get_func2; - self->set_cdr = qsfp_set_cdr; - self->set_soft_rs0 = unsupported_set_func; /* TBD */ - self->set_soft_rs1 = unsupported_set_func; /* TBD */ - self->set_soft_tx_disable = qsfp_set_soft_tx_disable; - self->set_auto_tx_disable = qsfp_set_auto_tx_disable; - self->set_tx_eq = qsfp_set_tx_eq; - self->set_rx_am = qsfp_set_rx_am; - self->set_rx_em = qsfp_set_rx_em; - self->set_extphy_offset = unsupported_set_func; - self->set_extphy_reg = unsupported_set_func; - return 0; - - case TRANSVR_TYPE_FAKE: - self->get_id = fake_get_hex; - self->get_ext_id = fake_get_hex; - self->get_connector = fake_get_hex; - self->get_vendor_name = fake_get_str; - self->get_vendor_pn = fake_get_str; - self->get_vendor_rev = fake_get_str; - self->get_vendor_sn = fake_get_str; - self->get_power_cls = fake_get_int; - self->get_br = fake_get_hex; - self->get_len_sm = fake_get_int; - self->get_len_smf = fake_get_int; - self->get_len_om1 = fake_get_int; - self->get_len_om2 = fake_get_int; - self->get_len_om3 = fake_get_int; - self->get_len_om4 = fake_get_int; - self->get_comp_rev = fake_get_hex; - self->get_comp_eth_1 = fake_get_hex; - self->get_comp_eth_10 = fake_get_hex; - self->get_comp_eth_10_40 = fake_get_hex; - self->get_comp_extend = fake_get_hex; - self->get_cdr = fake_get_hex; - self->get_rate_id = fake_get_hex; - self->get_soft_rs0 = fake_get_binary; - self->get_soft_rs1 = fake_get_binary; - self->get_info = fake_get_int; - self->get_if_type = fake_get_str; - self->get_if_speed = fake_get_str; - self->get_if_lane = fake_get_str; - self->get_curr_temp = fake_get_str; - self->get_curr_vol = fake_get_str; - self->get_soft_rx_los = fake_get_str; - self->get_soft_tx_disable = fake_get_str; - self->get_soft_tx_fault = fake_get_str; - self->get_auto_tx_disable = fake_get_str; - self->get_tx_bias = fake_get_str; - self->get_tx_power = fake_get_str; - self->get_rx_power = fake_get_str; - self->get_tx_eq = fake_get_str; - self->get_rx_am = fake_get_str; - self->get_rx_em = fake_get_str; - self->get_wavelength = fake_get_str; - self->get_extphy_offset = fake_get_str; - self->get_extphy_reg = fake_get_str; - self->set_cdr = fake_set_hex; - self->set_soft_rs0 = fake_set_int; - self->set_soft_rs1 = fake_set_int; - self->set_soft_tx_disable = fake_set_int; - self->set_auto_tx_disable = fake_set_int; - self->set_tx_eq = fake_set_int; - self->set_rx_am = fake_set_int; - self->set_rx_em = fake_set_int; - self->set_extphy_offset = fake_set_hex; - self->set_extphy_reg = fake_set_hex; - return 0; - - default: - break; - } - SWPS_WARN("%s: Detect non-defined type:%d\n", __func__, transvr_type); - return ERR_TRANSVR_UNEXCPT; -} - - -static int -setup_transvr_private_cb(struct transvr_obj_s *self, - int transvr_type){ - switch (transvr_type){ - case TRANSVR_TYPE_SFP: - self->init = transvr_init_sfp; - self->clean = common_transvr_clean; - self->check = common_transvr_check; - self->update_all = _sfp_update_attr_all; - self->fsm_4_direct = common_fsm_4_direct_mode; - self->fsm_4_polling = common_fsm_4_polling_mode; - self->send_uevent = sfp_send_uevent; - self->dump_all = sfp_transvr_dump; - return 0; - - case TRANSVR_TYPE_QSFP: - case TRANSVR_TYPE_QSFP_PLUS: - self->init = transvr_init_qsfp; - self->clean = qsfp_transvr_clean; - self->check = common_transvr_check; - self->update_all = _qsfp_update_attr_all; - self->fsm_4_direct = common_fsm_4_direct_mode; - self->fsm_4_polling = common_fsm_4_polling_mode; - self->send_uevent = qsfp_send_uevent; - self->dump_all = qsfp_transvr_dump; - return 0; - - case TRANSVR_TYPE_QSFP_28: - self->init = transvr_init_qsfp28; - self->clean = qsfp_transvr_clean; - self->check = common_transvr_check; - self->update_all = _qsfp_update_attr_all; - self->fsm_4_direct = common_fsm_4_direct_mode; - self->fsm_4_polling = common_fsm_4_polling_mode; - self->send_uevent = qsfp_send_uevent; - self->dump_all = qsfp_transvr_dump; - return 0; - - case TRANSVR_TYPE_FAKE: - self->init = transvr_init_fake; - self->clean = fake_transvr_clean; - self->check = fake_transvr_check; - self->update_all = fake_transvr_update; - self->fsm_4_direct = fake_fsm_4_direct_mode; - self->fsm_4_polling = fake_fsm_4_polling_mode; - self->send_uevent = fake_send_uevent; - self->dump_all = fake_transvr_dump; - return 0; - - default: - break; - } - SWPS_WARN("%s: Detect non-defined type:%d\n", __func__, transvr_type); - return ERR_TRANSVR_UNEXCPT; -} - - -static struct eeprom_map_s * -get_eeprom_map(int transvr_type){ - - switch (transvr_type){ - case TRANSVR_TYPE_SFP: - return &eeprom_map_sfp; - case TRANSVR_TYPE_QSFP: - case TRANSVR_TYPE_QSFP_PLUS: - return &eeprom_map_qsfp; - case TRANSVR_TYPE_QSFP_28: - return &eeprom_map_qsfp28; - - default: - break; - } - SWPS_WARN("%s: Detect non-defined type:%d\n", __func__, transvr_type); - return NULL; -} - - -static int -setup_transvr_ssize_attr(char *swp_name, - struct transvr_obj_s *self, - struct eeprom_map_s *map_p, - struct ioexp_obj_s *ioexp_obj_p, - int ioexp_virt_offset, - int transvr_type, - int chipset_type, - int chan_id, - int run_mode){ - switch (run_mode){ - case TRANSVR_MODE_DIRECT: /* Direct access device mode */ - case TRANSVR_MODE_POLLING: /* Polling mode, read from cache */ - self->mode = run_mode; - break; - default: - SWPS_ERR("%s: non-defined run_mode:%d\n", - __func__, run_mode); - self->mode = DEBUG_TRANSVR_INT_VAL; - return -1; - } - self->eeprom_map_p = map_p; - self->ioexp_obj_p = ioexp_obj_p; - self->ioexp_virt_offset = ioexp_virt_offset; - self->chan_id = chan_id; - self->layout = transvr_type; - self->type = transvr_type; - self->chipset_type = chipset_type; - self->state = STATE_TRANSVR_NEW; - self->info = STATE_TRANSVR_NEW; - self->auto_tx_disable = VAL_TRANSVR_FUNCTION_DISABLE; - strncpy(self->swp_name, swp_name, 32); - mutex_init(&self->lock); - return 0; -} - - -static int -setup_transvr_dsize_attr(struct transvr_obj_s *self){ - - char *emsg = DEBUG_TRANSVR_STR_VAL; - - self->vendor_name = kzalloc((LEN_TRANSVR_M_STR * sizeof(char)), GFP_KERNEL); - if (!self->vendor_name){ - emsg = "vendor_name"; - goto err_setup_d_attr; - } - self->vendor_pn = kzalloc((LEN_TRANSVR_M_STR * sizeof(char)), GFP_KERNEL); - if (!self->vendor_pn){ - emsg = "vendor_pn"; - goto err_setup_d_attr; - } - self->vendor_rev = kzalloc((LEN_TRANSVR_M_STR * sizeof(char)), GFP_KERNEL); - if (!self->vendor_rev){ - emsg = "vendor_rev"; - goto err_setup_d_attr; - } - self->vendor_sn = kzalloc((LEN_TRANSVR_M_STR * sizeof(char)), GFP_KERNEL); - if (!self->vendor_sn){ - emsg = "vendor_sn"; - goto err_setup_d_attr; - } - self->worker_p = NULL; - return 0; - -err_setup_d_attr: - SWPS_ERR("%s: %s kzalloc fail!", __func__, emsg); - return ERR_TRANSVR_UNEXCPT; -} - - -static int -setup_i2c_client(struct transvr_obj_s *self){ - - struct i2c_adapter *adap = NULL; - struct i2c_client *client = NULL; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - - adap = i2c_get_adapter(self->chan_id); - if(!adap){ - snprintf(err_msg, sizeof(err_msg), - "can not get adap:%d", self->chan_id); - goto err_setup_i2c_client; - } - client = kzalloc(sizeof(*client), GFP_KERNEL); - if (!client){ - snprintf(err_msg, sizeof(err_msg), - "can not kzalloc client:%d", self->chan_id); - goto err_setup_i2c_client; - } - client->adapter = adap; - self->i2c_client_p = client; - self->i2c_client_p->addr = VAL_TRANSVR_COMID_ARREESS; - return 0; - -err_setup_i2c_client: - SWPS_ERR("%s: %s\n", __func__, err_msg); - return ERR_TRANSVR_UNEXCPT; -} - - -struct transvr_obj_s * -create_transvr_obj(char *swp_name, - int chan_id, - struct ioexp_obj_s *ioexp_obj_p, - int ioexp_virt_offset, - int transvr_type, - int chipset_type, - int run_mode){ - - struct transvr_obj_s *result_p; - struct eeprom_map_s *map_p; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - - /* Allocate transceiver object */ - map_p = get_eeprom_map(transvr_type); - if (!map_p){ - snprintf(err_msg, sizeof(err_msg), - "Invalid transvr_type:%d", transvr_type); - goto err_create_transvr_fail; - } - result_p = kzalloc(sizeof(*result_p), GFP_KERNEL); - if (!result_p){ - snprintf(err_msg, sizeof(err_msg), "kzalloc fail"); - goto err_create_transvr_fail; - } - /* Prepare static size attributes */ - if (setup_transvr_ssize_attr(swp_name, - result_p, - map_p, - ioexp_obj_p, - ioexp_virt_offset, - transvr_type, - chipset_type, - chan_id, - run_mode) < 0){ - goto err_create_transvr_sattr_fail; - } - /* Prepare dynamic size attributes */ - if (setup_transvr_dsize_attr(result_p) < 0){ - goto err_create_transvr_dattr_fail; - } - /* Prepare call back functions of object */ - if (setup_transvr_public_cb(result_p, transvr_type) < 0){ - goto err_create_transvr_dattr_fail; - } - /* Prepare call back functions of object */ - if (setup_transvr_private_cb(result_p, transvr_type) < 0){ - goto err_create_transvr_dattr_fail; - } - /* Prepare i2c client object */ - if (setup_i2c_client(result_p) < 0){ - goto err_create_transvr_dattr_fail; - } - return result_p; - -err_create_transvr_dattr_fail: - kfree(result_p->vendor_sn); - kfree(result_p->vendor_rev); - kfree(result_p->vendor_pn); - kfree(result_p->vendor_name); -err_create_transvr_sattr_fail: - kfree(result_p); -err_create_transvr_fail: - SWPS_ERR("%s: %s :%d :%d :%d\n", - __func__, err_msg, chan_id, ioexp_virt_offset, transvr_type); - return NULL; -} -EXPORT_SYMBOL(create_transvr_obj); - - -static int -_reload_transvr_obj(struct transvr_obj_s *self, - int new_type){ - - struct eeprom_map_s *new_map_p; - struct eeprom_map_s *old_map_p = self->eeprom_map_p; - struct i2c_client *old_i2c_p = self->i2c_client_p; - int old_type = self->type; - - /* Change state to STATE_TRANSVR_INIT */ - self->state = STATE_TRANSVR_INIT; - self->type = new_type; - /* Replace EEPROME map */ - new_map_p = get_eeprom_map(new_type); - if (!new_map_p){ - goto err_private_reload_func_1; - } - self->eeprom_map_p = new_map_p; - /* Reload i2c client */ - if (setup_i2c_client(self) < 0){ - goto err_private_reload_func_2; - } - /* Replace call back functions */ - if (setup_transvr_public_cb(self, new_type) < 0){ - goto err_private_reload_func_3; - } - if (setup_transvr_private_cb(self, new_type) < 0){ - goto err_private_reload_func_3; - } - if(old_i2c_p){ - i2c_put_adapter(old_i2c_p->adapter); - } - kfree(old_i2c_p); - return 0; - -err_private_reload_func_3: - SWPS_INFO("%s: init() fail!\n", __func__); - if(old_i2c_p){ - i2c_put_adapter(old_i2c_p->adapter); - } - kfree(old_i2c_p); - self->state = STATE_TRANSVR_UNEXCEPTED; - self->type = TRANSVR_TYPE_ERROR; - return -2; - -err_private_reload_func_2: - self->eeprom_map_p = old_map_p; - self->i2c_client_p = old_i2c_p; -err_private_reload_func_1: - self->state = STATE_TRANSVR_UNEXCEPTED; - self->type = old_type; - SWPS_INFO("%s fail! :0x%02x\n", __func__, new_type); - return -1; -} - - -static int -reload_transvr_obj(struct transvr_obj_s *self, - int new_type){ - - int result_val = ERR_TRANSVR_UNEXCPT; - - /* Reload phase */ - result_val = _reload_transvr_obj(self, new_type); - if (result_val < 0){ - SWPS_INFO("%s: reload phase fail! :%d\n", - __func__, result_val); - return EVENT_TRANSVR_RELOAD_FAIL; - } - /* Initial phase */ - result_val = _transvr_init_handler(self); - if (result_val < 0){ - SWPS_INFO("%s: initial phase fail! :%d\n", - __func__, result_val); - } - return result_val; -} - - -int -isolate_transvr_obj(struct transvr_obj_s *self) { - - self->state = STATE_TRANSVR_ISOLATED; - SWPS_INFO("%s: %s be isolated\n", __func__, self->swp_name); - return 0; -} -EXPORT_SYMBOL(isolate_transvr_obj); - - -int -resync_channel_tier_2(struct transvr_obj_s *self) { - - int val = TRANSVR_TYPE_ERROR; - - if (self->state == STATE_TRANSVR_ISOLATED) { - return 0; - } - self->i2c_client_p->addr = VAL_TRANSVR_COMID_ARREESS; - val = i2c_smbus_read_byte_data(self->i2c_client_p, - VAL_TRANSVR_COMID_OFFSET); - if (val < 0) { - return -1; - } - return 0; -} -EXPORT_SYMBOL(resync_channel_tier_2); - -/* For build single module using (Ex: ONL platform) */ -MODULE_LICENSE("GPL"); - - -/* ----------------------------------------- - * ToDo List - * ----------------------------------------- - * 1. _sfp_detect_class_by_feature() - * => Need check ACC use case. - * 2. _sfp_detect_class_by_1g_ethernet() - * => Need check 0.1G use case. - * 3. Loopback transceiver use case. - * => Less much data - * 4. _qsfp_detect_class_by_extend_comp() - * => Verify 100G CWDM4 - * => Verify Obsolete (assigned before 100G CWDM4 MSA required FEC) - * => Verify 100G CLR4 - * => Verify 100GE-DWDM2 - * => Verify 40G PSM4 Parallel SMF - * => Verify 100G ACC (Active Copper Cable) or 25GAUI C2M ACC. - * => Verify 100G ACC or 25GAUI C2M ACC. - * => Verify 25GBASE-LR - * => Verify 40G Active Cable (XLPPI) - */ - - - - - - - - diff --git a/packages/platforms/inventec/x86-64/d6332/modules/builds/src/transceiver.h b/packages/platforms/inventec/x86-64/d6332/modules/builds/src/transceiver.h deleted file mode 100644 index 668b477cd..000000000 --- a/packages/platforms/inventec/x86-64/d6332/modules/builds/src/transceiver.h +++ /dev/null @@ -1,809 +0,0 @@ -#ifndef TRANSCEIVER_H -#define TRANSCEIVER_H - -#include - -/* advanced features control */ -#define TRANSVR_INFO_DUMP_ENABLE (1) -#define TRANSVR_INFO_CACHE_ENABLE (1) -#define TRANSVR_UEVENT_ENABLE (1) - -/* Transceiver type define */ -#define TRANSVR_TYPE_UNKNOW_1 (0x00) -#define TRANSVR_TYPE_UNKNOW_2 (0xff) -#define TRANSVR_TYPE_SFP (0x03) /* Define for SFP, SFP+, SFP28 */ -#define TRANSVR_TYPE_QSFP (0x0c) -#define TRANSVR_TYPE_QSFP_PLUS (0x0d) -#define TRANSVR_TYPE_QSFP_28 (0x11) -#define TRANSVR_TYPE_UNPLUGGED (0xfa) /* Define for ERROR handle */ -#define TRANSVR_TYPE_FAKE (0xfc) /* Define for ERROR handle */ -#define TRANSVR_TYPE_INCONSISTENT (0xfd) /* Define for ERROR handle */ -#define TRANSVR_TYPE_ERROR (0xfe) /* Define for ERROR handle */ - -/* Transceiver class for base info */ -#define TRANSVR_CLASS_UNSPECIFIED (0) -#define TRANSVR_CLASS_ERROR (-26001) -#define TRANSVR_CLASS_1G (26001) -#define TRANSVR_CLASS_10G (26011) -#define TRANSVR_CLASS_25G (26021) -#define TRANSVR_CLASS_40G (26041) -#define TRANSVR_CLASS_100G (26101) -#define TRANSVR_CLASS_NO_SPERARABLE (26901) -#define TRANSVR_CLASS_EXTEND_COMP (26902) -/* Transceiver class for Optical 1G */ -#define TRANSVR_CLASS_OPTICAL (27000) -#define TRANSVR_CLASS_OPTICAL_100 (27001) -#define TRANSVR_CLASS_OPTICAL_1G (27002) -#define TRANSVR_CLASS_OPTICAL_1G_AOC (27003) -#define TRANSVR_CLASS_OPTICAL_1G_SX (27004) -#define TRANSVR_CLASS_OPTICAL_1G_LX (27005) -#define TRANSVR_CLASS_OPTICAL_1G_EX (27006) -/* Transceiver class for Optical 10G */ -#define TRANSVR_CLASS_OPTICAL_10G (27010) -#define TRANSVR_CLASS_OPTICAL_10G_S_AOC (27011) -#define TRANSVR_CLASS_OPTICAL_10G_S_SR (27012) -#define TRANSVR_CLASS_OPTICAL_10G_S_LR (27013) -#define TRANSVR_CLASS_OPTICAL_10G_S_ER (27014) -#define TRANSVR_CLASS_OPTICAL_10G_Q_AOC (27015) -#define TRANSVR_CLASS_OPTICAL_10G_Q_SR (27016) -#define TRANSVR_CLASS_OPTICAL_10G_Q_LR (27017) -#define TRANSVR_CLASS_OPTICAL_10G_Q_ER (27018) -/* Transceiver class for Optical 25G */ -#define TRANSVR_CLASS_OPTICAL_25G (27020) -#define TRANSVR_CLASS_OPTICAL_25G_AOC (27021) -#define TRANSVR_CLASS_OPTICAL_25G_SR (27022) -#define TRANSVR_CLASS_OPTICAL_25G_LR (27023) -#define TRANSVR_CLASS_OPTICAL_25G_ER (27024) -/* Transceiver class for Optical 40G */ -#define TRANSVR_CLASS_OPTICAL_40G (27040) -#define TRANSVR_CLASS_OPTICAL_40G_AOC (27041) -#define TRANSVR_CLASS_OPTICAL_40G_SR4 (27042) -#define TRANSVR_CLASS_OPTICAL_40G_LR4 (27043) -#define TRANSVR_CLASS_OPTICAL_40G_ER4 (27044) -/* Transceiver class for Optical 100G */ -#define TRANSVR_CLASS_OPTICAL_100G (27100) -#define TRANSVR_CLASS_OPTICAL_100G_AOC (27101) -#define TRANSVR_CLASS_OPTICAL_100G_SR4 (27102) -#define TRANSVR_CLASS_OPTICAL_100G_LR4 (27103) -#define TRANSVR_CLASS_OPTICAL_100G_ER4 (27104) -#define TRANSVR_CLASS_OPTICAL_100G_PSM4 (27105) -/* Transceiver class for Copper */ -#define TRANSVR_CLASS_COPPER (28000) -#define TRANSVR_CLASS_COPPER_L1_1G (28001) -#define TRANSVR_CLASS_COPPER_L1_10G (28011) -#define TRANSVR_CLASS_COPPER_L4_10G (28012) -#define TRANSVR_CLASS_COPPER_L1_25G (28021) -#define TRANSVR_CLASS_COPPER_L4_40G (28041) -#define TRANSVR_CLASS_COPPER_L4_100G (28101) -/* Transceiver class for Base-T */ -#define TRANSVR_CLASS_BASE_T_1000 (29001) -#define TRANSVR_CLASS_BASE_T_1000_up (29002) -/* For uevent message */ -#define TRANSVR_UEVENT_KEY_IF "IF_TYPE" -#define TRANSVR_UEVENT_KEY_SP "IF_SPEED" -#define TRANSVR_UEVENT_KEY_LANE "IF_LANE" -#define TRANSVR_UEVENT_UNKNOW "UNKNOW" -#define TRANSVR_IF_KR "KR" -#define TRANSVR_IF_KR4 "KR4" -#define TRANSVR_IF_SR "SR" -#define TRANSVR_IF_SR4 "SR4" -#define TRANSVR_IF_SFI "SFI" -#define TRANSVR_IF_IF_GMII "GMII" -#define TRANSVR_IF_IF_XGMII "XGMII" -#define TRANSVR_IF_SP_100 "100" -#define TRANSVR_IF_SP_1G "1000" -#define TRANSVR_IF_SP_10G "10000" -#define TRANSVR_IF_SP_25G "25000" -#define TRANSVR_IF_SP_40G "40000" -#define TRANSVR_IF_SP_100G "100000" - -/* Transceiver mode define */ -#define TRANSVR_MODE_DIRECT (21000) -#define TRANSVR_MODE_POLLING (21001) - -/* Transceiver state define - * [Note] - * 1. State is used to represent the state of "Transceiver" and "Object". - * 2. State for different target has different means. The description as following: - */ -#define STATE_TRANSVR_CONNECTED (0) /* [Transvr]:Be plugged in. [Obj]:Link up, and work normally. */ -#define STATE_TRANSVR_NEW (-100) /* [Transvr]:(Not used) [Obj]:Create */ -#define STATE_TRANSVR_INIT (-101) /* [Transvr]:Be plugged in. [Obj]:Link up, and in initial process. */ -#define STATE_TRANSVR_ISOLATED (-102) /* [Transvr]:Be plugged in. [Obj]:Isolate, and not provide service. */ -#define STATE_TRANSVR_SWAPPED (-200) /* [Transvr]:Be plugged in. [Obj]:(Not used) */ -#define STATE_TRANSVR_DISCONNECTED (-300) /* [Transvr]:Un-plugged. [Obj]:Link down, and not provide service. */ -#define STATE_TRANSVR_UNEXCEPTED (-901) /* [Transvr]:Any [Obj]:Any, and not in expect case. */ - -/* Task state define */ -#define STATE_T_TASK_WAIT (110) -#define STATE_T_TASK_DONE (0) -#define STATE_T_TASK_INIT (-110) -#define STATE_T_TASK_FAIL (-410) - - -/* Event for task handling */ -#define EVENT_TRANSVR_TASK_WAIT (2101) -#define EVENT_TRANSVR_TASK_DONE (0) -#define EVENT_TRANSVR_TASK_FAIL (-2101) -/* Event for initial handling */ -#define EVENT_TRANSVR_INIT_UP (2201) -#define EVENT_TRANSVR_INIT_DOWN (1) -#define EVENT_TRANSVR_INIT_REINIT (-2201) -#define EVENT_TRANSVR_INIT_FAIL (-2202) -/* Event for others */ -#define EVENT_TRANSVR_RELOAD_FAIL (-2301) -#define EVENT_TRANSVR_EXCEP_INIT (-2401) -#define EVENT_TRANSVR_EXCEP_UP (-2402) -#define EVENT_TRANSVR_EXCEP_DOWN (-2403) -#define EVENT_TRANSVR_EXCEP_SWAP (-2404) -#define EVENT_TRANSVR_EXCEP_EXCEP (-2405) -#define EVENT_TRANSVR_EXCEP_ISOLATED (-2406) -#define EVENT_TRANSVR_I2C_CRASH (-2501) - -/* Transceiver error code define */ -#define ERR_TRANSVR_UNINIT (-201) -#define ERR_TRANSVR_UNPLUGGED (-202) -#define ERR_TRANSVR_ABNORMAL (-203) -#define ERR_TRANSVR_NOSTATE (-204) -#define ERR_TRANSVR_NOTSUPPORT (-205) -#define ERR_TRANSVR_BADINPUT (-206) -#define ERR_TRANSVR_UPDATE_FAIL (-207) -#define ERR_TRANSVR_RELOAD_FAIL (-208) -#define ERR_TRANSVR_INIT_FAIL (-209) -#define ERR_TRANSVR_UNDEFINED (-210) -#define ERR_TRANSVR_TASK_FAIL (-211) -#define ERR_TRANSVR_TASK_BUSY (-212) -#define ERR_TRANSVR_UEVENT_FAIL (-213) -#define ERR_TRANSVR_FUNC_DISABLE (-214) -#define ERR_TRANSVR_I2C_CRASH (-297) -#define ERR_TRNASVR_BE_ISOLATED (-298) -#define ERR_TRANSVR_UNEXCPT (-299) - -/* For debug */ -#define DEBUG_TRANSVR_INT_VAL (-99) -#define DEBUG_TRANSVR_HEX_VAL (0xfe) -#define DEBUG_TRANSVR_STR_VAL "ERROR" - -/* For system internal */ -#define VAL_TRANSVR_COMID_ARREESS (0x50) -#define VAL_TRANSVR_COMID_OFFSET (0x00) -#define VAL_TRANSVR_EXTPHY_ADDR_56 (0x56) -#define VAL_TRANSVR_8472_READY_ADDR (0x51) -#define VAL_TRANSVR_8472_READY_PAGE (-1) -#define VAL_TRANSVR_8472_READY_OFFSET (110) -#define VAL_TRANSVR_8472_READY_BIT (0) -#define VAL_TRANSVR_8472_READY_VALUE (0) -#define VAL_TRANSVR_8472_READY_ABNORMAL (0xff) -#define VAL_TRANSVR_8436_READY_ADDR (0x50) -#define VAL_TRANSVR_8436_READY_PAGE (-1) -#define VAL_TRANSVR_8436_READY_OFFSET (2) -#define VAL_TRANSVR_8436_READY_BIT (0) -#define VAL_TRANSVR_8436_READY_VALUE (0) -#define VAL_TRANSVR_8436_READY_ABNORMAL (0xff) -#define VAL_TRANSVR_8436_PWD_ADDR (0x50) -#define VAL_TRANSVR_8436_PWD_PAGE (-1) -#define VAL_TRANSVR_8436_PWD_OFFSET (123) -#define VAL_TRANSVR_PAGE_FREE (-99) -#define VAL_TRANSVR_PAGE_SELECT_OFFSET (127) -#define VAL_TRANSVR_PAGE_SELECT_DELAY (5) -#define VAL_TRANSVR_TASK_RETRY_FOREVER (-999) -#define VAL_TRANSVR_FUNCTION_DISABLE (-1) -#define STR_TRANSVR_SFP "SFP" -#define STR_TRANSVR_QSFP "QSFP" -#define STR_TRANSVR_QSFP_PLUS "QSFP+" -#define STR_TRANSVR_QSFP28 "QSFP28" - -/* For transvr buf len */ -#define LEN_TRANSVR_S_STR (16) -#define LEN_TRANSVR_M_STR (32) -#define LEN_TRANSVR_L_STR (64) - -/* Optical wavelength */ -#define VAL_OPTICAL_WAVELENGTH_SR (850) -#define VAL_OPTICAL_WAVELENGTH_LR (1310) -#define VAL_OPTICAL_WAVELENGTH_ER (1550) - -/* Switch chip type define */ -#define CHIP_TYPE_MAGNOLIA (31001) /* Magnolia, Hudson32i, Spruce */ -#define CHIP_TYPE_REDWOOD (31002) /* Redwood, Cypress, Sequoia */ -#define CHIP_TYPE_MAPLE (31003) /* Maple */ - -#define CHIP_TYPE_LAVENDER (31011) /* Lavender */ - -/* Info from transceiver EEPROM */ -struct eeprom_map_s { - int addr_br; int page_br; int offset_br; int length_br; - int addr_cdr; int page_cdr; int offset_cdr; int length_cdr; - int addr_comp_rev; int page_comp_rev; int offset_comp_rev; int length_comp_rev; - int addr_connector; int page_connector; int offset_connector; int length_connector; - int addr_diag_type; int page_diag_type; int offset_diag_type; int length_diag_type; - int addr_extbr; int page_extbr; int offset_extbr; int length_extbr; - int addr_ext_id; int page_ext_id; int offset_ext_id; int length_ext_id; - int addr_id; int page_id; int offset_id; int length_id; - int addr_len_sm; int page_len_sm; int offset_len_sm; int length_len_sm; - int addr_len_smf; int page_len_smf; int offset_len_smf; int length_len_smf; - int addr_len_om1; int page_len_om1; int offset_len_om1; int length_len_om1; - int addr_len_om2; int page_len_om2; int offset_len_om2; int length_len_om2; - int addr_len_om3; int page_len_om3; int offset_len_om3; int length_len_om3; - int addr_len_om4; int page_len_om4; int offset_len_om4; int length_len_om4; - int addr_option; int page_option; int offset_option; int length_option; - int addr_rate_id; int page_rate_id; int offset_rate_id; int length_rate_id; - int addr_rx_am; int page_rx_am; int offset_rx_am; int length_rx_am; - int addr_rx_em; int page_rx_em; int offset_rx_em; int length_rx_em; - int addr_rx_los; int page_rx_los; int offset_rx_los; int length_rx_los; - int addr_rx_power; int page_rx_power; int offset_rx_power; int length_rx_power; - int addr_soft_rs0; int page_soft_rs0; int offset_soft_rs0; int length_soft_rs0; - int addr_soft_rs1; int page_soft_rs1; int offset_soft_rs1; int length_soft_rs1; - int addr_temp; int page_temp; int offset_temp; int length_temp; - int addr_trancomp; int page_trancomp; int offset_trancomp; int length_trancomp; - int addr_trancomp_ext; int page_trancomp_ext; int offset_trancomp_ext; int length_trancomp_ext; - int addr_tx_bias; int page_tx_bias; int offset_tx_bias; int length_tx_bias; - int addr_tx_disable; int page_tx_disable; int offset_tx_disable; int length_tx_disable; - int addr_tx_eq; int page_tx_eq; int offset_tx_eq; int length_tx_eq; - int addr_tx_fault; int page_tx_fault; int offset_tx_fault; int length_tx_fault; - int addr_tx_power; int page_tx_power; int offset_tx_power; int length_tx_power; - int addr_vendor_name; int page_vendor_name; int offset_vendor_name; int length_vendor_name; - int addr_vendor_pn; int page_vendor_pn; int offset_vendor_pn; int length_vendor_pn; - int addr_vendor_rev; int page_vendor_rev; int offset_vendor_rev; int length_vendor_rev; - int addr_vendor_sn; int page_vendor_sn; int offset_vendor_sn; int length_vendor_sn; - int addr_voltage; int page_voltage; int offset_voltage; int length_voltage; - int addr_wavelength; int page_wavelength; int offset_wavelength; int length_wavelength; -}; - - -struct transvr_worker_s; - -/* Class of transceiver object */ -struct transvr_obj_s { - - /* ========== Object private property ========== - * [Prop]: id - * [Desc]: Type of serial transceiver. - * [Note]: SFP:03h / QSFP:0Ch / QSPF+:0Dh /QSFP28:11h - */ - uint8_t id; - - /* [Prop]: connector - * [Desc]: Connector type. - * [Note]: SFP : A0h / 2 - * QSFP: 00h / 130 - */ - uint8_t connector; - - /* [Prop]: transvr_comp - * [Desc]: Transceiver compliance code. - * [Note]: SFP: SFF-8472 - * - Normal : A0h / offset 3-10 - * - Extended: A0h / offset 36 - * QSFP: SFF-8436 & SFF-8636 - * - Normal : 00h / offset 131-138 - * - Extended: 00h / offset 192 - */ - uint8_t transvr_comp[8]; - uint8_t transvr_comp_ext; - - /* [Prop]: vendor_name - * [Desc]: SFP vendor name (ASCII 16 byte char). - * [Note]: ex:FINISAR CORP. - */ - char *vendor_name; - - /* [Prop]: vendor_pn - * [Desc]: Part number provided by SFP vendor (ASCII 16 byte char). - * [Note]: - */ - char *vendor_pn; - - /* [Prop]: vendor_rev - * [Desc]: Revision level for part number provided by vendor (ASCII 4 byte char). - * [Note]: - */ - char *vendor_rev; - - /* [Prop]: vendor_sn - * [Desc]: Serial number provided by vendor (ASCII 16 byte char). - * [Note]: - */ - char *vendor_sn; - - /* [Prop]: Extended identifier - * [Desc]: SFP: - * => None - * - * QSFP: - * => This byte contained two information: - * (1) Power consumption class - * (2) CDR function present - * [Note]: Bit description as below: - * [SFP] - * None - * - * [QSFP] - * (1) Power consumption class: - * Class 1: 1.5W (Bit6-7 = 00:) - * Class 2: 2.0W (Bit6-7 = 01:) - * Class 3: 2.5W (Bit6-7 = 10:) - * Class 4: 3.5W (Bit6-7 = 11:) - * Class 5: 4.0W (Bit0-1 = 01:) - * Class 6: 4.5W (Bit0-1 = 10:) - * Class 7: 5.0W (Bit0-1 = 11:) - * (2) CDR function present: - * Bit2: 0 = No CDR in RX - * 1 = CDR present in RX - * Bit3: 0 = No CDR in TX - * 1 = CDR present in TX - */ - uint8_t ext_id; - - /* [Prop]: br - * [Desc]: Nominal bit rate, units of 100 MBits/sec. - * [Note]: SFP:03h / QSFP:0Ch / QSPF+:0Dh - * has val: 0x67 - * no val : - */ - uint8_t br; - - /* [Prop]: extbr - * [Desc]: Extended br (00h/222) - * [Desc]: Nominal bit rate per channel, units of 250 Mbps. - * Complements. Byte 140. See Table 32A. - */ - uint8_t extbr; - - /* [Prop]: len_sm - * [Desc]: Length (single mode)-(100's)m - * [Note]: This value specifies the link length that is supported by the transceiver - * while operating in compliance with the applicable standards using single mode - * fiber. The value is in units of 100 meters. A value of 255 means that the - * transceiver supports a link length greater than 25.4 km. A value of zero means - * that the transceiver does not support single mode fiber or that the length - * information must be determined from the transceiver technology. - */ - int len_sm; - - /* [Prop]: len_smf - * [Desc]: Length (single mode)-km - * [Note]: Addition to EEPROM data from original GBIC definition. This value specifies - * the link length that is supported by the transceiver while operating in - * compliance with the applicable standards using single mode fiber. The value - * is in units of kilometers. A value of 255 means that the transceiver supports - * a link length greater than 254 km. A value of zero means that the transceiver - * does not support single mode fiber or that the length information must be - * determined from the transceiver technology. - */ - int len_smf; - - /* [Prop]: len_om1 - * [Desc]: Link length supported for 62.5 um OM1 fiber, units of 10 m - * [Note]: The value is in units of 10 meters. A value of 255 means that the - * transceiver supports a link length greater than 2.54 km. A value of - * zero means that the transceiver does not support 50 micron multi-mode - * fiber or that the length information must be determined from the transceiver - * technology. - */ - int len_om1; - - /* [Prop]: len_om2 - * [Desc]: Link length supported for 50 um OM2 fiber, units of 10 m - * [Note]: The value is in units of 10 meters. A value of 255 means that the - * transceiver supports a link length greater than 2.54 km. A value of - * zero means that the transceiver does not support 50 micron multi-mode - * fiber or that the length information must be determined from the transceiver - * technology. - */ - int len_om2; - - /* [Prop]: len_om3 - * [Desc]: Length (50um, OM3) - * [Note]: This value specifies link length that is supported by the transceiver while - * operating in compliance with applicable standards using 50 micron multimode - * OM3 [2000 MHz*km] fiber. The value is in units of 10 meters. A value of 255 - * means that the transceiver supports a link length greater than 2.54 km. A value - * of zero means that the transceiver does not support 50 micron multimode fiber - * or that the length information must be determined from the transceiver technology. - */ - int len_om3; - - /* [Prop]: len_om4 - * [Desc]: Length (50um, OM4) and Length (Active Cable or Copper) - * [Note]: For optical links, this value specifies link length that is supported by the - * transceiver while operating in compliance with applicable standards using 50 micron - * multimode OM4 [4700 MHz*km] fiber. The value is in units of 10 meters. A value of - * 255 means that the transceiver supports a link length greater than 2.54 km. A value - * of zero means that the transceiver does not support 50 micron multimode fiber or that - * the length information must be determined from the transceiver codes specified in Table 5-3. - * - * For copper links, this value specifies minimum link length supported by the transceiver - * while operating in compliance with applicable standards using copper cable. For active - * cable, this value represents actual length. The value is in units of 1 meter. A value of 255 - * means the transceiver supports a link length greater than 254 meters. A value of zero means - * the transceiver does not support copper or active cables or the length information must be - * determined from transceiver technology. Further information about cable design, equalization, - * and connectors is usually required to guarantee meeting a particular length requirement. - */ - int len_om4; - - /* [Prop]: comp_rev - * [Desc]: SFF spec revision compliance - * [Note]: Indicates which revision of SFF SFF-8472 (SFP) / SFF-8636 (QSFP) the transceiver - * complies with. (unsigned integer) - */ - uint8_t comp_rev; - - /* [Prop]: CDR - * [Desc]: For transceivers with CDR capability, setting the CDR to ON engages the internal - * retiming function. Setting the CDR to OFF enables an internal bypassing mode ,which - * directs traffic around the internal CDR. (Reference: SFF-8636) - * [Note]: value=0xff: ON. - * value=0x00: OFF. - */ - uint8_t cdr; - - /* [Prop]: rate_id - * [Desc]: Soft Rate Select 0(RX). - * [Note]: 1. Addr: A0h / Offset: 13 - * 2. Value description: - * 00h Unspecified - * 01h SFF-8079 (4/2/1G Rate_Select & AS0/AS1) - * 02h SFF-8431 (8/4/2G Rx Rate_Select only) - * 03h Unspecified * - * 04h SFF-8431 (8/4/2G Tx Rate_Select only) - * 05h Unspecified * - * 06h SFF-8431 (8/4/2G Independent Rx & Tx Rate_select) - * 07h Unspecified * - * 08h FC-PI-5 (16/8/4G Rx Rate_select only) High=16G only, Low=8G/4G - * 09h Unspecified * - * 0Ah FC-PI-5 (16/8/4G Independent Rx, Tx Rate_select) High=16G only, - * Low=8G/4G - * 0Bh Unspecified * - * 0Ch FC-PI-6 (32/16/8G Independent Rx, Tx Rate_Select) - * High=32G only, Low = 16G/8G - * 0Dh Unspecified * - * 0Eh 10/8G Rx and Tx Rate_Select controlling the operation or locking - * modes of the internal signal conditioner, retimer or CDR, according - * to the logic table defined in Table 10-2, High Bit Rate - * (10G) =9.95-11.3 Gb/s; Low Bit Rate (8G) = 8.5 Gb/s. In this mode, - * the default value of bit 110.3 (Soft Rate Select RS(0), Table 9-11) - * and of bit 118.3 (Soft Rate Select RS(1), Table 10-1) is 1. - * 0Fh Unspecified * - * 10h-FFh Unallocated - */ - int rate_id; - - /* [Prop]: soft_rs0 - * [Desc]: Soft Rate Select 0(RX). - * [Note]: 1. Writing '1' selects full bandwidth operation. - * 2. This bit is "OR'd with the hard Rate_Select, AS(0) or RS(0) pin value. - * 3. Default at power up is logic zero/low - * 4. Addr: A2h / Offset: 110 / Bit: 3 - */ - uint8_t soft_rs0; - - /* [Prop]: soft_rs1 - * [Desc]: Soft Rate Select 1(TX). - * [Note]: 1. Writing '1' selects full bandwidth TX operation. - * 2. This bit is "OR'd with the hard Rate_Select, AS(1) or RS(1) pin value. - * 3. Default at power up is logic zero/low - * 4. Addr: A2h / Offset: 118 / Bit: 3 - */ - uint8_t soft_rs1; - - /* [Prop]: diag_type - * [Desc]: DIAGNOSTIC MONITORING TYPE (A0h/92) - * [Note]: Description in SFF-8472 as below: - * Bit7: Reserved for legacy diagnostic implementations. Must be '0' for compliance - * with this document. - * Bit6: Digital diagnostic monitoring implemented (described in this document). - * Must be '1' for compliance with this document. - * Bit5 Internally calibrated - * Bit4 Externally calibrated - * Bit3 Received power measurement type.0 = OMA, 1 = average power - * Bit2 Address change required see section above, "addressing modes" - * Bit1-0 Unallocated - */ - uint8_t diag_type; - - /* [Prop]: curr_temp - * [Desc]: Transceiver Current Temperature (A2h/96-97) - * [Note]: 1. Dependent on diag_type. - * 2. 96: High byte - * 3. 97: Low byte - * 4. This feature only for SFP - */ - uint8_t curr_temp[2]; - - /* [Prop]: curr_vol - * [Desc]: Transceiver Current Voltage (SFP:A2h/108-109; QSFP:00h/22-23) - * [Note]: 1. Dependent on diag_type. - * 2. 98: High byte - * 3. 99: Low byte - * 4. This feature only for SFP - * 5. Internally measured transceiver supply voltage. Represented - * as a 16 bit unsigned integer with the voltage defined as the - * full 16 bit value (0-65535) with LSB equal to 100 uVolt, - * yielding a total range of 0 to +6.55 Volts - */ - uint8_t curr_voltage[2]; - - /* [Prop]: curr_tx_bias - * [Desc]: Transceiver TX Bias Current (SFP:A2h/100-101; QSFP:00h/26-27) - * [Note]: 1. Dependent on diag_type. - * 2. 100: High byte - * 3. 101: Low byte - * 4. This feature only for SFP - * 5. Measured TX bias current in uA. Represented as a 16 bit unsigned - * integer with the current defined as the full 16 bit value (0-65535) - * with LSB equal to 2 uA, yielding a total range of 0 to 131 mA. - * Accuracy is vendor specific but must be better than 10% of the - * manufacturer's nominal value over specified operating temperature - * and voltage. - */ - uint8_t curr_tx_bias[8]; - - /* [Prop]: curr_tx_power - * [Desc]: Transceiver TX Output Power (A2h/102-103) - * [Note]: 1. Dependent on diag_type. - * 2. 102: High byte - * 3. 103: Low byte - * 4. This feature only for SFP - * 5. Measured TX output power in mW. Represented as a 16 bit unsigned - * integer with the power defined as the full 16 bit value (0-65535) - * with LSB equal to 0.1 uW, yielding a total range of 0 to 6.5535 mW - * (~ -40 to +8.2 dBm). Data is assumed to be based on measurement of - * laser monitor photodiode current. It is factory calibrated to absolute - * units using the most representative fiber output type. Accuracy is - * vendor specific but must be better than 3dB over specified temperature - * and voltage. Data is not valid when the transmitter is disabled. - */ - uint8_t curr_tx_power[8]; - - /* [Prop]: curr_tx_power - * [Desc]: Transceiver TX Output Power (A2h/102-103) - * [Note]: 1. Dependent on diag_type. - * 2. 102: High byte - * 3. 103: Low byte - * 4. This feature only for SFP - * 5. Measured RX received optical power in mW. Value can represent either - * average received power or OMA depending upon how bit 3 of byte 92 (A0h) - * is set. Represented as a 16 bit unsigned integer with the power defined - * as the full 16 bit value (0-65535) with LSB equal to 0.1 uW, yielding a - * total range of 0 to 6.5535 mW (~ -40 to +8.2 dBm). Absolute accuracy is - * dependent upon the exact optical wavelength. For the vendor specified - * wavelength, accuracy shall be better than 3dB over specified temperature - * and voltage. - */ - uint8_t curr_rx_power[8]; - - /* [Prop]: wavelength - * [Desc]: Wavelength or Copper Cable Attenuation - * [Note]: (Following is info from SFF-8636) - * For optical free side devices, this parameter identifies the nominal - * transmitter output wavelength at room temperature. This parameter is a - * 16-bit hex value with Byte 186 as high order byte and Byte 187 as low - * order byte. The laser wavelength is equal to the 16-bit integer value - * divided by 20 in nm (units of 0.05 nm). This resolution should be adequate - * to cover all relevant wavelengths yet provide enough resolution for all - * expected DWDM applications. For accurate representation of controlled - * wavelength applications, this value should represent the center of the - * guaranteed wavelength range. If the free side device is identified as - * copper cable these registers will be used to define the cable attenuation. - * An indication of 0 dB attenuation refers to the case where the attenuation - * is not known or is unavailable. - * Byte 186 (00-FFh) is the copper cable attenuation at 2.5 GHz in units of 1 dB. - * Byte 187 (00-FFh) is the copper cable attenuation at 5.0 GHz in units of 1 dB. - */ - uint8_t wavelength[2]; - - /* [Prop]: Amplitude control - * [Desc]: Amplitude control - * [Note]: QSFP28 => SFF-8636 03H Byte-238/239 - */ - uint8_t rx_am[2]; - - /* [Prop]: Emphasis control - * [Desc]: Emphasis control - * [Note]: SFP+/28 => SFF-8472 A2H Byte-115 - * QSFP28 => SFF-8636 03H Byte-236/237 - */ - uint8_t rx_em[2]; - - /* [Prop]: Soft Rx LOS - * [Desc]: Soft Rx LOS which provide by transceiver - * [Note]: (Following is info from SFF-8636) - * Byte 3: - * - Bit 0: L-Rx1 LOS - * - Bit 1: L-Rx2 LOS - * - Bit 2: L-Rx3 LOS - * - Bit 3: L-Rx4 LOS - */ - uint8_t rx_los; - - /* [Prop]: Soft Tx Disable - * [Desc]: Soft Tx Disable which provide by transceiver - * [Note]: (Following is info from SFF-8636) - * Byte 86: - * - Bit 0: Tx1 Disable - * - Bit 1: Tx2 Disable - * - Bit 2: Tx3 Disable - * - Bit 3: Tx4 Disable - */ - uint8_t tx_disable; - - /* [Prop]: Soft Tx Fault - * [Desc]: Soft Tx Fault which provide by transceiver - * [Note]: (Following is info from SFF-8636) - * Byte 86: - * - Bit 0: Tx1 Fault - * - Bit 1: Tx2 Fault - * - Bit 2: Tx3 Fault - * - Bit 3: Tx4 Fault - */ - uint8_t tx_fault; - - /* [Prop]: Transceiver EQUALIZATION - * [Desc]: Transceiver EQUALIZATION - * [Note]: SFP+/28 => SFF-8472 A2H Byte-114 - * QSFP28 => SFF-8636 03H Byte-234/235 - */ - uint8_t tx_eq[2]; - - /* [Prop]: OPTION VALUES - * [Desc]: The bits in the option field shall specify the options implemented in the transceiver. - * [Note]: SFP+/28 => SFF-8472 A0H Byte-64/65 - * QSFP+/28 => SFF-8636 00H Byte-193/195 - */ - uint8_t option[3]; - - /* [Prop]: External PHY offset - * [Desc]: It needs to be setup first if you want to access transceiver external phy. - * [Note]: This feature dependent on transceiver. - * Currently, only 1G-RJ45 transceiver supported it. - */ - uint8_t extphy_offset; - - /* ========== Object private property ========== - */ - struct device *transvr_dev_p; - struct eeprom_map_s *eeprom_map_p; - struct i2c_client *i2c_client_p; - struct ioexp_obj_s *ioexp_obj_p; - struct transvr_worker_s *worker_p; - struct mutex lock; - char swp_name[32]; - int auto_config; - int auto_tx_disable; - int chan_id; - int chipset_type; - int curr_page; - int info; - int ioexp_virt_offset; - int lane_id[8]; - int layout; - int mode; - int retry; - int state; - int temp; - int type; - - /* ========== Object public functions ========== - */ - int (*get_id)(struct transvr_obj_s *self); - int (*get_ext_id)(struct transvr_obj_s *self); - int (*get_connector)(struct transvr_obj_s *self); - int (*get_vendor_name)(struct transvr_obj_s *self, char *buf_p); - int (*get_vendor_pn)(struct transvr_obj_s *self, char *buf_p); - int (*get_vendor_rev)(struct transvr_obj_s *self, char *buf_p); - int (*get_vendor_sn)(struct transvr_obj_s *self, char *buf_p); - int (*get_power_cls)(struct transvr_obj_s *self); - int (*get_br)(struct transvr_obj_s *self); - int (*get_len_sm)(struct transvr_obj_s *self); - int (*get_len_smf)(struct transvr_obj_s *self); - int (*get_len_om1)(struct transvr_obj_s *self); - int (*get_len_om2)(struct transvr_obj_s *self); - int (*get_len_om3)(struct transvr_obj_s *self); - int (*get_len_om4)(struct transvr_obj_s *self); - int (*get_comp_rev)(struct transvr_obj_s *self); - int (*get_comp_eth_1)(struct transvr_obj_s *self); - int (*get_comp_eth_10)(struct transvr_obj_s *self); - int (*get_comp_eth_10_40)(struct transvr_obj_s *self); - int (*get_comp_extend)(struct transvr_obj_s *self); - int (*get_cdr)(struct transvr_obj_s *self); - int (*get_rate_id)(struct transvr_obj_s *self); - int (*get_soft_rs0)(struct transvr_obj_s *self); - int (*get_soft_rs1)(struct transvr_obj_s *self); - int (*get_info)(struct transvr_obj_s *self); - int (*get_if_type)(struct transvr_obj_s *self, char *buf_p); - int (*get_if_speed)(struct transvr_obj_s *self, char *buf_p); - int (*get_if_lane)(struct transvr_obj_s *self, char *buf_p); - int (*get_curr_temp)(struct transvr_obj_s *self, char *buf_p); - int (*get_curr_vol)(struct transvr_obj_s *self, char *buf_p); - int (*get_soft_rx_los)(struct transvr_obj_s *self, char *buf_p); - int (*get_soft_tx_disable)(struct transvr_obj_s *self, char *buf_p); - int (*get_soft_tx_fault)(struct transvr_obj_s *self, char *buf_p); - int (*get_auto_tx_disable)(struct transvr_obj_s *self, char *buf_p); - int (*get_tx_bias)(struct transvr_obj_s *self, char *buf_p); - int (*get_tx_power)(struct transvr_obj_s *self, char *buf_p); - int (*get_rx_power)(struct transvr_obj_s *self, char *buf_p); - int (*get_tx_eq)(struct transvr_obj_s *self, char *buf_p); - int (*get_rx_am)(struct transvr_obj_s *self, char *buf_p); - int (*get_rx_em)(struct transvr_obj_s *self, char *buf_p); - int (*get_wavelength)(struct transvr_obj_s *self, char *buf_p); - int (*get_extphy_offset)(struct transvr_obj_s *self, char *buf_p); - int (*get_extphy_reg)(struct transvr_obj_s *self, char *buf_p); - int (*set_cdr)(struct transvr_obj_s *self, int input_val); - int (*set_soft_rs0)(struct transvr_obj_s *self, int input_val); - int (*set_soft_rs1)(struct transvr_obj_s *self, int input_val); - int (*set_soft_tx_disable)(struct transvr_obj_s *self, int input_val); - int (*set_auto_tx_disable)(struct transvr_obj_s *self, int input_val); - int (*set_tx_eq)(struct transvr_obj_s *self, int input_val); - int (*set_rx_am)(struct transvr_obj_s *self, int input_val); - int (*set_rx_em)(struct transvr_obj_s *self, int input_val); - int (*set_extphy_offset)(struct transvr_obj_s *self, int input_val); - int (*set_extphy_reg)(struct transvr_obj_s *self, int input_val); - - /* ========== Object private functions ========== - */ - int (*init)(struct transvr_obj_s *self); - int (*clean)(struct transvr_obj_s *self); - int (*check)(struct transvr_obj_s *self); - int (*update_all)(struct transvr_obj_s *self, int show_err); - int (*fsm_4_direct)(struct transvr_obj_s* self, char *caller_name); - int (*fsm_4_polling)(struct transvr_obj_s* self, char *caller_name); - int (*send_uevent)(struct transvr_obj_s* self, enum kobject_action u_action); - int (*dump_all)(struct transvr_obj_s* self); -}; - - -/* For AVL Mapping */ -struct transvr_avl_s { - char vendor_name[32]; - char vendor_pn[32]; - int (*init)(struct transvr_obj_s *self); -}; - - -/* Worker for long term task of transceiver */ -struct transvr_worker_s { - /* Task Parameter */ - struct transvr_obj_s *transvr_p; - struct transvr_worker_s *next_p; - struct transvr_worker_s *pre_p; - unsigned long trigger_time; - char func_name[64]; - int retry; - int state; - - /* Task private data */ - void *p_data; - - /* Call back function */ - int (*main_task)(struct transvr_worker_s *task); - int (*post_task)(struct transvr_worker_s *task); -}; - - -struct transvr_obj_s * -create_transvr_obj(char *swp_name, - int chan_id, - struct ioexp_obj_s *ioexp_obj_p, - int ioexp_virt_offset, - int transvr_type, - int chipset_type, - int run_mode); - -void lock_transvr_obj(struct transvr_obj_s *self); -void unlock_transvr_obj(struct transvr_obj_s *self); -int isolate_transvr_obj(struct transvr_obj_s *self); - -int resync_channel_tier_2(struct transvr_obj_s *self); - -void alarm_msg_2_user(struct transvr_obj_s *self, char *emsg); - -#endif /* TRANSCEIVER_H */ - - - - - - - diff --git a/packages/platforms/inventec/x86-64/d6332/modules/builds/src/ucd9000.c b/packages/platforms/inventec/x86-64/d6332/modules/builds/src/ucd9000.c deleted file mode 100644 index fbb1479d3..000000000 --- a/packages/platforms/inventec/x86-64/d6332/modules/builds/src/ucd9000.c +++ /dev/null @@ -1,246 +0,0 @@ -/* - * Hardware monitoring driver for UCD90xxx Sequencer and System Health - * Controller series - * - * Copyright (C) 2011 Ericsson AB. - * - * 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 "pmbus.h" - -enum chips { ucd9000, ucd90120, ucd90124, ucd9090, ucd90910 }; - -#define UCD9000_MONITOR_CONFIG 0xd5 -#define UCD9000_NUM_PAGES 0xd6 -#define UCD9000_FAN_CONFIG_INDEX 0xe7 -#define UCD9000_FAN_CONFIG 0xe8 -#define UCD9000_DEVICE_ID 0xfd - -#define UCD9000_MON_TYPE(x) (((x) >> 5) & 0x07) -#define UCD9000_MON_PAGE(x) ((x) & 0x0f) - -#define UCD9000_MON_VOLTAGE 1 -#define UCD9000_MON_TEMPERATURE 2 -#define UCD9000_MON_CURRENT 3 -#define UCD9000_MON_VOLTAGE_HW 4 - -#define UCD9000_NUM_FAN 4 - -struct ucd9000_data { - u8 fan_data[UCD9000_NUM_FAN][I2C_SMBUS_BLOCK_MAX]; - struct pmbus_driver_info info; -}; -#define to_ucd9000_data(_info) container_of(_info, struct ucd9000_data, info) - -static int ucd9000_get_fan_config(struct i2c_client *client, int fan) -{ - int fan_config = 0; - struct ucd9000_data *data - = to_ucd9000_data(pmbus_get_driver_info(client)); - - if (data->fan_data[fan][3] & 1) - fan_config |= PB_FAN_2_INSTALLED; /* Use lower bit position */ - - /* Pulses/revolution */ - fan_config |= (data->fan_data[fan][3] & 0x06) >> 1; - - return fan_config; -} - -static int ucd9000_read_byte_data(struct i2c_client *client, int page, int reg) -{ - int ret = 0; - int fan_config; - - switch (reg) { - case PMBUS_FAN_CONFIG_12: - if (page > 0) - return -ENXIO; - - ret = ucd9000_get_fan_config(client, 0); - if (ret < 0) - return ret; - fan_config = ret << 4; - ret = ucd9000_get_fan_config(client, 1); - if (ret < 0) - return ret; - fan_config |= ret; - ret = fan_config; - break; - case PMBUS_FAN_CONFIG_34: - if (page > 0) - return -ENXIO; - - ret = ucd9000_get_fan_config(client, 2); - if (ret < 0) - return ret; - fan_config = ret << 4; - ret = ucd9000_get_fan_config(client, 3); - if (ret < 0) - return ret; - fan_config |= ret; - ret = fan_config; - break; - default: - ret = -ENODATA; - break; - } - return ret; -} - -static const struct i2c_device_id ucd9000_id[] = { - {"ucd9000", ucd9000}, - {"ucd90120", ucd90120}, - {"ucd90124", ucd90124}, - {"ucd9090", ucd9090}, - {"ucd90910", ucd90910}, - {} -}; -MODULE_DEVICE_TABLE(i2c, ucd9000_id); - -static int ucd9000_probe(struct i2c_client *client, - const struct i2c_device_id *id) -{ - u8 block_buffer[I2C_SMBUS_BLOCK_MAX + 1]; - struct ucd9000_data *data; - struct pmbus_driver_info *info; - const struct i2c_device_id *mid; - int i, ret; - - if (!i2c_check_functionality(client->adapter, - I2C_FUNC_SMBUS_BYTE_DATA | - I2C_FUNC_SMBUS_BLOCK_DATA)) - return -ENODEV; - - ret = i2c_smbus_read_block_data(client, UCD9000_DEVICE_ID, - block_buffer); - if (ret < 0) { - dev_err(&client->dev, "Failed to read device ID\n"); - return ret; - } - block_buffer[ret] = '\0'; - dev_info(&client->dev, "Device ID %s\n", block_buffer); - - for (mid = ucd9000_id; mid->name[0]; mid++) { - if (!strncasecmp(mid->name, block_buffer, strlen(mid->name))) - break; - } - if (!mid->name[0]) { - dev_err(&client->dev, "Unsupported device\n"); - return -ENODEV; - } - - if (id->driver_data != ucd9000 && id->driver_data != mid->driver_data) - dev_notice(&client->dev, - "Device mismatch: Configured %s, detected %s\n", - id->name, mid->name); - - data = devm_kzalloc(&client->dev, sizeof(struct ucd9000_data), - GFP_KERNEL); - if (!data) - return -ENOMEM; - info = &data->info; - - ret = i2c_smbus_read_byte_data(client, UCD9000_NUM_PAGES); - if (ret < 0) { - dev_err(&client->dev, - "Failed to read number of active pages\n"); - return ret; - } - info->pages = ret; - if (!info->pages) { - dev_err(&client->dev, "No pages configured\n"); - return -ENODEV; - } - - /* The internal temperature sensor is always active */ - info->func[0] = PMBUS_HAVE_TEMP; - - /* Everything else is configurable */ - ret = i2c_smbus_read_block_data(client, UCD9000_MONITOR_CONFIG, - block_buffer); - if (ret <= 0) { - dev_err(&client->dev, "Failed to read configuration data\n"); - return -ENODEV; - } - for (i = 0; i < ret; i++) { - int page = UCD9000_MON_PAGE(block_buffer[i]); - - if (page >= info->pages) - continue; - - switch (UCD9000_MON_TYPE(block_buffer[i])) { - case UCD9000_MON_VOLTAGE: - case UCD9000_MON_VOLTAGE_HW: - info->func[page] |= PMBUS_HAVE_VOUT - | PMBUS_HAVE_STATUS_VOUT; - break; - case UCD9000_MON_TEMPERATURE: - info->func[page] |= PMBUS_HAVE_TEMP2 - | PMBUS_HAVE_STATUS_TEMP; - break; - case UCD9000_MON_CURRENT: - info->func[page] |= PMBUS_HAVE_IOUT - | PMBUS_HAVE_STATUS_IOUT; - break; - default: - break; - } - } - - /* Fan configuration */ - if (mid->driver_data == ucd90124) { - for (i = 0; i < UCD9000_NUM_FAN; i++) { - i2c_smbus_write_byte_data(client, - UCD9000_FAN_CONFIG_INDEX, i); - ret = i2c_smbus_read_block_data(client, - UCD9000_FAN_CONFIG, - data->fan_data[i]); - if (ret < 0) - return ret; - } - i2c_smbus_write_byte_data(client, UCD9000_FAN_CONFIG_INDEX, 0); - - info->read_byte_data = ucd9000_read_byte_data; - info->func[0] |= PMBUS_HAVE_FAN12 | PMBUS_HAVE_STATUS_FAN12 - | PMBUS_HAVE_FAN34 | PMBUS_HAVE_STATUS_FAN34; - } - - return pmbus_do_probe(client, mid, info); -} - -/* This is the driver that will be inserted */ -static struct i2c_driver ucd9000_driver = { - .driver = { - .name = "ucd9000", - }, - .probe = ucd9000_probe, - .remove = pmbus_do_remove, - .id_table = ucd9000_id, -}; - -module_i2c_driver(ucd9000_driver); - -MODULE_AUTHOR("Guenter Roeck"); -MODULE_DESCRIPTION("PMBus driver for TI UCD90xxx"); -MODULE_LICENSE("GPL"); diff --git a/packages/platforms/inventec/x86-64/d6332/onlp/Makefile b/packages/platforms/inventec/x86-64/d6332/onlp/Makefile deleted file mode 100644 index 003238cf6..000000000 --- a/packages/platforms/inventec/x86-64/d6332/onlp/Makefile +++ /dev/null @@ -1 +0,0 @@ -include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/inventec/x86-64/d6332/onlp/PKG.yml b/packages/platforms/inventec/x86-64/d6332/onlp/PKG.yml deleted file mode 100644 index afa6b87b0..000000000 --- a/packages/platforms/inventec/x86-64/d6332/onlp/PKG.yml +++ /dev/null @@ -1 +0,0 @@ -!include $ONL_TEMPLATES/onlp-platform-any.yml PLATFORM=x86-64-inventec-d6332 ARCH=amd64 TOOLCHAIN=x86_64-linux-gnu diff --git a/packages/platforms/inventec/x86-64/d6332/onlp/builds/Makefile b/packages/platforms/inventec/x86-64/d6332/onlp/builds/Makefile deleted file mode 100644 index e7437cb23..000000000 --- a/packages/platforms/inventec/x86-64/d6332/onlp/builds/Makefile +++ /dev/null @@ -1,2 +0,0 @@ -FILTER=src -include $(ONL)/make/subdirs.mk diff --git a/packages/platforms/inventec/x86-64/d6332/onlp/builds/lib/Makefile b/packages/platforms/inventec/x86-64/d6332/onlp/builds/lib/Makefile deleted file mode 100644 index 4498b1a4a..000000000 --- a/packages/platforms/inventec/x86-64/d6332/onlp/builds/lib/Makefile +++ /dev/null @@ -1,2 +0,0 @@ -PLATFORM := x86-64-inventec-d6332 -include $(ONL)/packages/base/any/onlp/builds/platform/libonlp-platform.mk \ No newline at end of file diff --git a/packages/platforms/inventec/x86-64/d6332/onlp/builds/onlpdump/Makefile b/packages/platforms/inventec/x86-64/d6332/onlp/builds/onlpdump/Makefile deleted file mode 100644 index 0911e6169..000000000 --- a/packages/platforms/inventec/x86-64/d6332/onlp/builds/onlpdump/Makefile +++ /dev/null @@ -1,2 +0,0 @@ -PLATFORM := x86-64-inventec-d6332 -include $(ONL)/packages/base/any/onlp/builds/platform/onlps.mk \ No newline at end of file diff --git a/packages/platforms/inventec/x86-64/d6332/onlp/builds/x86_64_inventec_d6332/.module b/packages/platforms/inventec/x86-64/d6332/onlp/builds/x86_64_inventec_d6332/.module deleted file mode 100644 index 485582f11..000000000 --- a/packages/platforms/inventec/x86-64/d6332/onlp/builds/x86_64_inventec_d6332/.module +++ /dev/null @@ -1 +0,0 @@ -name: x86_64_inventec_d6332 diff --git a/packages/platforms/inventec/x86-64/d6332/onlp/builds/x86_64_inventec_d6332/Makefile b/packages/platforms/inventec/x86-64/d6332/onlp/builds/x86_64_inventec_d6332/Makefile deleted file mode 100644 index bd60709c0..000000000 --- a/packages/platforms/inventec/x86-64/d6332/onlp/builds/x86_64_inventec_d6332/Makefile +++ /dev/null @@ -1,9 +0,0 @@ -############################################################################### -# -# -# -############################################################################### -include $(ONL)/make/config.mk -MODULE := x86_64_inventec_d6332 -AUTOMODULE := x86_64_inventec_d6332 -include $(BUILDER)/definemodule.mk diff --git a/packages/platforms/inventec/x86-64/d6332/onlp/builds/x86_64_inventec_d6332/module/auto/make.mk b/packages/platforms/inventec/x86-64/d6332/onlp/builds/x86_64_inventec_d6332/module/auto/make.mk deleted file mode 100644 index f32395240..000000000 --- a/packages/platforms/inventec/x86-64/d6332/onlp/builds/x86_64_inventec_d6332/module/auto/make.mk +++ /dev/null @@ -1,8 +0,0 @@ -############################################################################### -# -# x86_64_inventec_d6332 Autogeneration -# -############################################################################### -x86_64_inventec_d6332_AUTO_DEFS := module/auto/x86_64_inventec_d6332.yml -x86_64_inventec_d6332_AUTO_DIRS := module/inc/x86_64_inventec_d6332 module/src -include $(BUILDER)/auto.mk \ No newline at end of file diff --git a/packages/platforms/inventec/x86-64/d6332/onlp/builds/x86_64_inventec_d6332/module/auto/x86_64_inventec_d6332.yml b/packages/platforms/inventec/x86-64/d6332/onlp/builds/x86_64_inventec_d6332/module/auto/x86_64_inventec_d6332.yml deleted file mode 100644 index b772d0136..000000000 --- a/packages/platforms/inventec/x86-64/d6332/onlp/builds/x86_64_inventec_d6332/module/auto/x86_64_inventec_d6332.yml +++ /dev/null @@ -1,50 +0,0 @@ -############################################################################### -# -# x86_64_inventec_d6332 Autogeneration Definitions. -# -############################################################################### - -cdefs: &cdefs -- X86_64_INVENTEC_D6332_CONFIG_INCLUDE_LOGGING: - doc: "Include or exclude logging." - default: 1 -- X86_64_INVENTEC_D6332_CONFIG_LOG_OPTIONS_DEFAULT: - doc: "Default enabled log options." - default: AIM_LOG_OPTIONS_DEFAULT -- X86_64_INVENTEC_D6332_CONFIG_LOG_BITS_DEFAULT: - doc: "Default enabled log bits." - default: AIM_LOG_BITS_DEFAULT -- X86_64_INVENTEC_D6332_CONFIG_LOG_CUSTOM_BITS_DEFAULT: - doc: "Default enabled custom log bits." - default: 0 -- X86_64_INVENTEC_D6332_CONFIG_PORTING_STDLIB: - doc: "Default all porting macros to use the C standard libraries." - default: 1 -- X86_64_INVENTEC_D6332_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS: - doc: "Include standard library headers for stdlib porting macros." - default: X86_64_INVENTEC_D6332_CONFIG_PORTING_STDLIB -- X86_64_INVENTEC_D6332_CONFIG_INCLUDE_UCLI: - doc: "Include generic uCli support." - default: 0 -- X86_64_INVENTEC_D6332_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_D6332_CONFIG_HEADER: - defs: *cdefs - basename: x86_64_inventec_d6332_config - - portingmacro: - X86_64_INVENTEC_D6332: - macros: - - malloc - - free - - memset - - memcpy - - strncpy - - vsnprintf - - snprintf - - strlen diff --git a/packages/platforms/inventec/x86-64/d6332/onlp/builds/x86_64_inventec_d6332/module/inc/x86_64_inventec_d6332/x86_64_inventec_d6332.x b/packages/platforms/inventec/x86-64/d6332/onlp/builds/x86_64_inventec_d6332/module/inc/x86_64_inventec_d6332/x86_64_inventec_d6332.x deleted file mode 100644 index 37ebe528e..000000000 --- a/packages/platforms/inventec/x86-64/d6332/onlp/builds/x86_64_inventec_d6332/module/inc/x86_64_inventec_d6332/x86_64_inventec_d6332.x +++ /dev/null @@ -1,14 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#include - -/* <--auto.start.xmacro(ALL).define> */ -/* */ - -/* <--auto.start.xenum(ALL).define> */ -/* */ - - diff --git a/packages/platforms/inventec/x86-64/d6332/onlp/builds/x86_64_inventec_d6332/module/inc/x86_64_inventec_d6332/x86_64_inventec_d6332_config.h b/packages/platforms/inventec/x86-64/d6332/onlp/builds/x86_64_inventec_d6332/module/inc/x86_64_inventec_d6332/x86_64_inventec_d6332_config.h deleted file mode 100644 index f76d8ec63..000000000 --- a/packages/platforms/inventec/x86-64/d6332/onlp/builds/x86_64_inventec_d6332/module/inc/x86_64_inventec_d6332/x86_64_inventec_d6332_config.h +++ /dev/null @@ -1,137 +0,0 @@ -/**************************************************************************//** - * - * @file - * @brief x86_64_inventec_d6332 Configuration Header - * - * @addtogroup x86_64_inventec_d6332-config - * @{ - * - *****************************************************************************/ -#ifndef __x86_64_inventec_d6332_CONFIG_H__ -#define __x86_64_inventec_d6332_CONFIG_H__ - -#ifdef GLOBAL_INCLUDE_CUSTOM_CONFIG -#include -#endif -#ifdef x86_64_inventec_d6332_INCLUDE_CUSTOM_CONFIG -#include -#endif - -/* */ -#include -/** - * x86_64_inventec_d6332_CONFIG_INCLUDE_LOGGING - * - * Include or exclude logging. */ - - -#ifndef x86_64_inventec_d6332_CONFIG_INCLUDE_LOGGING -#define x86_64_inventec_d6332_CONFIG_INCLUDE_LOGGING 1 -#endif - -/** - * x86_64_inventec_d6332_CONFIG_LOG_OPTIONS_DEFAULT - * - * Default enabled log options. */ - - -#ifndef x86_64_inventec_d6332_CONFIG_LOG_OPTIONS_DEFAULT -#define x86_64_inventec_d6332_CONFIG_LOG_OPTIONS_DEFAULT AIM_LOG_OPTIONS_DEFAULT -#endif - -/** - * x86_64_inventec_d6332_CONFIG_LOG_BITS_DEFAULT - * - * Default enabled log bits. */ - - -#ifndef x86_64_inventec_d6332_CONFIG_LOG_BITS_DEFAULT -#define x86_64_inventec_d6332_CONFIG_LOG_BITS_DEFAULT AIM_LOG_BITS_DEFAULT -#endif - -/** - * x86_64_inventec_d6332_CONFIG_LOG_CUSTOM_BITS_DEFAULT - * - * Default enabled custom log bits. */ - - -#ifndef x86_64_inventec_d6332_CONFIG_LOG_CUSTOM_BITS_DEFAULT -#define x86_64_inventec_d6332_CONFIG_LOG_CUSTOM_BITS_DEFAULT 0 -#endif - -/** - * x86_64_inventec_d6332_CONFIG_PORTING_STDLIB - * - * Default all porting macros to use the C standard libraries. */ - - -#ifndef x86_64_inventec_d6332_CONFIG_PORTING_STDLIB -#define x86_64_inventec_d6332_CONFIG_PORTING_STDLIB 1 -#endif - -/** - * x86_64_inventec_d6332_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS - * - * Include standard library headers for stdlib porting macros. */ - - -#ifndef x86_64_inventec_d6332_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS -#define x86_64_inventec_d6332_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS x86_64_inventec_d6332_CONFIG_PORTING_STDLIB -#endif - -/** - * x86_64_inventec_d6332_CONFIG_INCLUDE_UCLI - * - * Include generic uCli support. */ - - -#ifndef x86_64_inventec_d6332_CONFIG_INCLUDE_UCLI -#define x86_64_inventec_d6332_CONFIG_INCLUDE_UCLI 0 -#endif - -/** - * x86_64_inventec_d6332_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION - * - * Assume chassis fan direction is the same as the PSU fan direction. */ - - -#ifndef x86_64_inventec_d6332_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION -#define x86_64_inventec_d6332_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION 0 -#endif - - - -/** - * All compile time options can be queried or displayed - */ - -/** Configuration settings structure. */ -typedef struct x86_64_inventec_d6332_config_settings_s { - /** name */ - const char* name; - /** value */ - const char* value; -} x86_64_inventec_d6332_config_settings_t; - -/** Configuration settings table. */ -/** x86_64_inventec_d6332_config_settings table. */ -extern x86_64_inventec_d6332_config_settings_t x86_64_inventec_d6332_config_settings[]; - -/** - * @brief Lookup a configuration setting. - * @param setting The name of the configuration option to lookup. - */ -const char* x86_64_inventec_d6332_config_lookup(const char* setting); - -/** - * @brief Show the compile-time configuration. - * @param pvs The output stream. - */ -int x86_64_inventec_d6332_config_show(struct aim_pvs_s* pvs); - -/* */ - -#include "x86_64_inventec_d6332_porting.h" - -#endif /* __x86_64_inventec_d6332_CONFIG_H__ */ -/* @} */ diff --git a/packages/platforms/inventec/x86-64/d6332/onlp/builds/x86_64_inventec_d6332/module/inc/x86_64_inventec_d6332/x86_64_inventec_d6332_dox.h b/packages/platforms/inventec/x86-64/d6332/onlp/builds/x86_64_inventec_d6332/module/inc/x86_64_inventec_d6332/x86_64_inventec_d6332_dox.h deleted file mode 100644 index 1b1022285..000000000 --- a/packages/platforms/inventec/x86-64/d6332/onlp/builds/x86_64_inventec_d6332/module/inc/x86_64_inventec_d6332/x86_64_inventec_d6332_dox.h +++ /dev/null @@ -1,26 +0,0 @@ -/**************************************************************************//** - * - * x86_64_inventec_d6332 Doxygen Header - * - *****************************************************************************/ -#ifndef __x86_64_inventec_d6332_DOX_H__ -#define __x86_64_inventec_d6332_DOX_H__ - -/** - * @defgroup x86_64_inventec_d6332 x86_64_inventec_d6332 - x86_64_inventec_d6332 Description - * - -The documentation overview for this module should go here. - - * - * @{ - * - * @defgroup x86_64_inventec_d6332-x86_64_inventec_d6332 Public Interface - * @defgroup x86_64_inventec_d6332-config Compile Time Configuration - * @defgroup x86_64_inventec_d6332-porting Porting Macros - * - * @} - * - */ - -#endif /* __x86_64_inventec_d6332_DOX_H__ */ diff --git a/packages/platforms/inventec/x86-64/d6332/onlp/builds/x86_64_inventec_d6332/module/inc/x86_64_inventec_d6332/x86_64_inventec_d6332_porting.h b/packages/platforms/inventec/x86-64/d6332/onlp/builds/x86_64_inventec_d6332/module/inc/x86_64_inventec_d6332/x86_64_inventec_d6332_porting.h deleted file mode 100644 index 76223cd24..000000000 --- a/packages/platforms/inventec/x86-64/d6332/onlp/builds/x86_64_inventec_d6332/module/inc/x86_64_inventec_d6332/x86_64_inventec_d6332_porting.h +++ /dev/null @@ -1,107 +0,0 @@ -/**************************************************************************//** - * - * @file - * @brief x86_64_inventec_d6332 Porting Macros. - * - * @addtogroup x86_64_inventec_d6332-porting - * @{ - * - *****************************************************************************/ -#ifndef __x86_64_inventec_d6332_PORTING_H__ -#define __x86_64_inventec_d6332_PORTING_H__ - - -/* */ -#if x86_64_inventec_d6332_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS == 1 -#include -#include -#include -#include -#include -#endif - -#ifndef x86_64_inventec_d6332_MALLOC - #if defined(GLOBAL_MALLOC) - #define x86_64_inventec_d6332_MALLOC GLOBAL_MALLOC - #elif x86_64_inventec_d6332_CONFIG_PORTING_STDLIB == 1 - #define x86_64_inventec_d6332_MALLOC malloc - #else - #error The macro x86_64_inventec_d6332_MALLOC is required but cannot be defined. - #endif -#endif - -#ifndef x86_64_inventec_d6332_FREE - #if defined(GLOBAL_FREE) - #define x86_64_inventec_d6332_FREE GLOBAL_FREE - #elif x86_64_inventec_d6332_CONFIG_PORTING_STDLIB == 1 - #define x86_64_inventec_d6332_FREE free - #else - #error The macro x86_64_inventec_d6332_FREE is required but cannot be defined. - #endif -#endif - -#ifndef x86_64_inventec_d6332_MEMSET - #if defined(GLOBAL_MEMSET) - #define x86_64_inventec_d6332_MEMSET GLOBAL_MEMSET - #elif x86_64_inventec_d6332_CONFIG_PORTING_STDLIB == 1 - #define x86_64_inventec_d6332_MEMSET memset - #else - #error The macro x86_64_inventec_d6332_MEMSET is required but cannot be defined. - #endif -#endif - -#ifndef x86_64_inventec_d6332_MEMCPY - #if defined(GLOBAL_MEMCPY) - #define x86_64_inventec_d6332_MEMCPY GLOBAL_MEMCPY - #elif x86_64_inventec_d6332_CONFIG_PORTING_STDLIB == 1 - #define x86_64_inventec_d6332_MEMCPY memcpy - #else - #error The macro x86_64_inventec_d6332_MEMCPY is required but cannot be defined. - #endif -#endif - -#ifndef x86_64_inventec_d6332_STRNCPY - #if defined(GLOBAL_STRNCPY) - #define x86_64_inventec_d6332_STRNCPY GLOBAL_STRNCPY - #elif x86_64_inventec_d6332_CONFIG_PORTING_STDLIB == 1 - #define x86_64_inventec_d6332_STRNCPY strncpy - #else - #error The macro x86_64_inventec_d6332_STRNCPY is required but cannot be defined. - #endif -#endif - -#ifndef x86_64_inventec_d6332_VSNPRINTF - #if defined(GLOBAL_VSNPRINTF) - #define x86_64_inventec_d6332_VSNPRINTF GLOBAL_VSNPRINTF - #elif x86_64_inventec_d6332_CONFIG_PORTING_STDLIB == 1 - #define x86_64_inventec_d6332_VSNPRINTF vsnprintf - #else - #error The macro x86_64_inventec_d6332_VSNPRINTF is required but cannot be defined. - #endif -#endif - -#ifndef x86_64_inventec_d6332_SNPRINTF - #if defined(GLOBAL_SNPRINTF) - #define x86_64_inventec_d6332_SNPRINTF GLOBAL_SNPRINTF - #elif x86_64_inventec_d6332_CONFIG_PORTING_STDLIB == 1 - #define x86_64_inventec_d6332_SNPRINTF snprintf - #else - #error The macro x86_64_inventec_d6332_SNPRINTF is required but cannot be defined. - #endif -#endif - -#ifndef x86_64_inventec_d6332_STRLEN - #if defined(GLOBAL_STRLEN) - #define x86_64_inventec_d6332_STRLEN GLOBAL_STRLEN - #elif x86_64_inventec_d6332_CONFIG_PORTING_STDLIB == 1 - #define x86_64_inventec_d6332_STRLEN strlen - #else - #error The macro x86_64_inventec_d6332_STRLEN is required but cannot be defined. - #endif -#endif - -/* */ - - -#endif /* __x86_64_inventec_d6332_PORTING_H__ */ -/* @} */ diff --git a/packages/platforms/inventec/x86-64/d6332/onlp/builds/x86_64_inventec_d6332/module/make.mk b/packages/platforms/inventec/x86-64/d6332/onlp/builds/x86_64_inventec_d6332/module/make.mk deleted file mode 100644 index add153816..000000000 --- a/packages/platforms/inventec/x86-64/d6332/onlp/builds/x86_64_inventec_d6332/module/make.mk +++ /dev/null @@ -1,10 +0,0 @@ -############################################################################### -# -# -# -############################################################################### -THIS_DIR := $(dir $(lastword $(MAKEFILE_LIST))) -x86_64_inventec_d6332_INCLUDES := -I $(THIS_DIR)inc -x86_64_inventec_d6332_INTERNAL_INCLUDES := -I $(THIS_DIR)src -x86_64_inventec_d6332_DEPENDMODULE_ENTRIES := init:x86_64_inventec_d6332 ucli:x86_64_inventec_d6332 - diff --git a/packages/platforms/inventec/x86-64/d6332/onlp/builds/x86_64_inventec_d6332/module/src/Makefile b/packages/platforms/inventec/x86-64/d6332/onlp/builds/x86_64_inventec_d6332/module/src/Makefile deleted file mode 100644 index 8847f48a2..000000000 --- a/packages/platforms/inventec/x86-64/d6332/onlp/builds/x86_64_inventec_d6332/module/src/Makefile +++ /dev/null @@ -1,9 +0,0 @@ -############################################################################### -# -# Local source generation targets. -# -############################################################################### - -ucli: - @../../../../tools/uclihandlers.py x86_64_inventec_d6332_ucli.c - diff --git a/packages/platforms/inventec/x86-64/d6332/onlp/builds/x86_64_inventec_d6332/module/src/fani.c b/packages/platforms/inventec/x86-64/d6332/onlp/builds/x86_64_inventec_d6332/module/src/fani.c deleted file mode 100644 index f9446eac7..000000000 --- a/packages/platforms/inventec/x86-64/d6332/onlp/builds/x86_64_inventec_d6332/module/src/fani.c +++ /dev/null @@ -1,479 +0,0 @@ -/************************************************************ - * fani.c - * - * Copyright 2018 Inventec Technology Corporation. - * - ************************************************************ - * - * Fan Platform Implementation Defaults. - * - ***********************************************************/ -#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) - -typedef enum hwmon_fan_state_e { - HWMON_FAN_F2B = 0, - HWMON_FAN_B2F = 1, - HWMON_FAN_UNPLUGGED = 2, - HWMON_FAN_UNPLUGGED2 = 3 -} hwmon_fan_state_t; - -#define SLOW_PWM 100 -#define NORMAL_PWM 175 -#define MAX_PWM 255 -#define STEP_SIZE 100 -#define FAN_ID_TO_PSU_ID(id) (id-ONLP_FAN_PSU_1+1) -#define BLADE_TO_FAN_ID(blade_id) (blade_id%2==0)? blade_id/2:(blade_id+1)/2 - - -#define TLV_AREA_OFFSETS_IDX_START 1 -#define TLV_PRODUCT_INFO_OFFSET_IDX 5 -#define TLV_PRODUCT_INFO_AREA_START 3 -#define TLV_ATTR_TYPE_SERIAL 5 -#define TLV_ATTR_TYPE_MODEL 2 - -#define FAN_I2C_CHANNEL 1 -#define FAN_I2C_ADDR_BASE 52 - -#define FAN_CAPS ONLP_FAN_CAPS_GET_RPM|ONLP_FAN_CAPS_GET_PERCENTAGE -#define PSU_FAN_CAPS ONLP_FAN_CAPS_GET_RPM - -static int _fani_status_failed_check(uint32_t* status, int fan_id); -static int _fani_status_present_check(uint32_t* status, int fan_id); -static int _inv_get_fan_fru(char* ret_str,int attr_type, int fan_id); - -#define MAKE_FAN_INFO_NODE_ON_PSU(psu_id) \ - { \ - { ONLP_FAN_ID_CREATE(ONLP_FAN_PSU_##psu_id), "PSU-"#psu_id" Fan", ONLP_PSU_ID_CREATE(ONLP_PSU_##psu_id)}, \ - 0, PSU_FAN_CAPS \ - } - -/* Static values */ -static onlp_fan_info_t __onlp_fan_info[] = { - {}, - { { ONLP_FAN_1, "Fan1-1", 0, }, 0, FAN_CAPS }, - { { ONLP_FAN_2, "Fan1-2", 0, }, 0, FAN_CAPS }, - { { ONLP_FAN_3, "Fan2-1", 0, }, 0, FAN_CAPS }, - { { ONLP_FAN_4, "Fan2-2", 0, }, 0, FAN_CAPS }, - { { ONLP_FAN_5, "Fan3-1", 0, }, 0, FAN_CAPS }, - { { ONLP_FAN_6, "Fan3-2", 0, }, 0, FAN_CAPS }, - { { ONLP_FAN_7, "Fan4-1", 0, }, 0, FAN_CAPS }, - { { ONLP_FAN_8, "Fan4-2", 0, }, 0, FAN_CAPS }, - { { ONLP_FAN_9, "Fan5-1", 0, }, 0, FAN_CAPS }, - { { ONLP_FAN_10, "Fan5-2", 0, }, 0, FAN_CAPS }, - MAKE_FAN_INFO_NODE_ON_PSU(1), - MAKE_FAN_INFO_NODE_ON_PSU(2), -}; - - -/* - * This function will be called prior to all of onlp_fani_* functions. - */ -int -onlp_fani_init(void) -{ - return ONLP_STATUS_OK; -} - -static int _inv_get_fan_fru(char* ret_str,int attr_type, int fan_id) -{ - int ret=ONLP_STATUS_OK; - uint8_t* rdata; - char file_path[ONLP_CONFIG_INFO_STR_MAX]; - char s; - int rdata_size=0,target_offset=0,attr_idx=0,attr_length=0; - int i=0; - int offset=BLADE_TO_FAN_ID(fan_id); - - snprintf(file_path,ONLP_CONFIG_INFO_STR_MAX,"%s%d-00%d/eeprom",INV_PSU_BASE,FAN_I2C_CHANNEL,(FAN_I2C_ADDR_BASE+offset-1) ); - - FILE* fp = fopen(file_path, "rb"); - if(fp) { - fseek(fp, 0L, SEEK_END); - rdata_size = ftell(fp); - rewind(fp); - rdata = aim_malloc(rdata_size); - fread(rdata, 1, rdata_size, fp); - fclose(fp); - } else { - ret=ONLP_STATUS_E_INTERNAL; - } - - if(ret==ONLP_STATUS_OK) { - target_offset=rdata[TLV_PRODUCT_INFO_OFFSET_IDX-1]; - target_offset*=8; /*spec defined: offset are in multiples of 8 bytes*/ - attr_idx=target_offset+TLV_PRODUCT_INFO_AREA_START; - - for(i=1; irdata_size) { - ret=ONLP_STATUS_E_INTERNAL; - break; - } - attr_length=rdata[attr_idx]&(0x3F); /*spec defined: length are set in last 6 bits*/ - attr_idx+=(attr_length+1); - } - if(ret==ONLP_STATUS_OK) { - if(attr_length=ONLP_FAN_MAX) { - rv=ONLP_STATUS_E_INVALID; - AIM_LOG_ERROR("[ONLP][FAN] OID %d out of range in %s", fan_id, __FUNCTION__); - } - if(rv==ONLP_STATUS_OK) { - *info=__onlp_fan_info[fan_id]; - rv=onlp_fani_status_get(id, &info->status); - } - if(rv == ONLP_STATUS_OK) { - if(info->status & ONLP_FAN_STATUS_PRESENT) { - switch(fan_id) { - case ONLP_FAN_1: - case ONLP_FAN_2: - case ONLP_FAN_3: - case ONLP_FAN_4: - case ONLP_FAN_5: - case ONLP_FAN_6: - case ONLP_FAN_7: - case ONLP_FAN_8: - case ONLP_FAN_9: - case ONLP_FAN_10: - if(info->status & ONLP_FAN_STATUS_F2B) { - info->caps = ADD_STATE(info->caps,ONLP_FAN_CAPS_F2B); - } else if(info->status & ONLP_FAN_STATUS_B2F) { - info->caps = ADD_STATE(info->caps,ONLP_FAN_CAPS_B2F) ; - } - - rv = onlp_file_read_int(&info->rpm, INV_FAN_PREFIX"fan%d_input", fan_id); - if(rv != ONLP_STATUS_OK ) { - return rv; - } - rv = onlp_file_read_int(&pwm,INV_FAN_PREFIX"pwm%d", BLADE_TO_FAN_ID(fan_id)); - if(rv != ONLP_STATUS_OK ) { - return rv; - } - - if( _inv_get_fan_fru(info->serial,TLV_ATTR_TYPE_SERIAL,fan_id) != ONLP_STATUS_OK) { - snprintf(info->serial,ONLP_CONFIG_INFO_STR_MAX,"N/A"); - } - if( _inv_get_fan_fru(info->model,TLV_ATTR_TYPE_MODEL,fan_id) != ONLP_STATUS_OK) { - snprintf(info->model,ONLP_CONFIG_INFO_STR_MAX,"N/A"); - } - - if(rv == ONLP_STATUS_OK) { - if(info->rpm <= 0) { - info->mode = ONLP_FAN_MODE_OFF; - info->percentage = 0; - } else { - info->percentage = (pwm*100)/MAX_PWM; - if(pwm < SLOW_PWM) { - info->mode = ONLP_FAN_MODE_SLOW; - } else if(pwm < NORMAL_PWM) { - info->mode = ONLP_FAN_MODE_NORMAL; - } else if(pwm < MAX_PWM) { - info->mode = ONLP_FAN_MODE_FAST; - } else { - info->mode = ONLP_FAN_MODE_MAX; - } - } - } - break; - case ONLP_FAN_PSU_1: - case ONLP_FAN_PSU_2: - psu_id = FAN_ID_TO_PSU_ID(fan_id); - - snprintf(path,ONLP_CONFIG_INFO_STR_MAX,"/var/psu%d/fan1_input",psu_id); - rv = onlp_file_read_int(&info->rpm, path); - - break; - default: - rv = ONLP_STATUS_E_INVALID; - break; - } - - } else { - info->caps = 0; - info->rpm = 0; - info->percentage = 0; - info->mode = ONLP_FAN_MODE_OFF; - } - - } - return rv; -} -static int _fani_status_failed_check(uint32_t* status, int fan_id) -{ - int rv; - int rpm, pwm, psu_id; - char path[ONLP_CONFIG_INFO_STR_MAX]; - - switch(fan_id) { - case ONLP_FAN_1: - case ONLP_FAN_2: - case ONLP_FAN_3: - case ONLP_FAN_4: - case ONLP_FAN_5: - case ONLP_FAN_6: - case ONLP_FAN_7: - case ONLP_FAN_8: - case ONLP_FAN_9: - case ONLP_FAN_10: - rv = onlp_file_read_int(&rpm, INV_FAN_PREFIX"fan%d_input", fan_id); - - if(rv != ONLP_STATUS_OK ) { - return rv; - } - rv = onlp_file_read_int(&pwm,INV_FAN_PREFIX"pwm%d", BLADE_TO_FAN_ID(fan_id)); - if( rv == ONLP_STATUS_OK) { - if(rpm<=0 || pwm<=0 || pwm > MAX_PWM) { - *status=ADD_STATE(*status,ONLP_FAN_STATUS_FAILED); - *status=REMOVE_STATE(*status,ONLP_FAN_STATUS_B2F); - *status=REMOVE_STATE(*status,ONLP_FAN_STATUS_F2B); - } else { - *status=REMOVE_STATE(*status,ONLP_FAN_STATUS_FAILED); - } - } else { - AIM_LOG_ERROR("[ONLP][FAN] Read error in line %s\n",__LINE__); - } - break; - case ONLP_FAN_PSU_1: - case ONLP_FAN_PSU_2: - psu_id = FAN_ID_TO_PSU_ID(fan_id); - - snprintf(path,ONLP_CONFIG_INFO_STR_MAX,"/var/psu%d/fan1_input",psu_id); - rv = onlp_file_read_int(&rpm, path); - if( rv == ONLP_STATUS_OK) { - if( rpm <= 0 ) { - *status=ADD_STATE(*status,ONLP_FAN_STATUS_FAILED); - *status=REMOVE_STATE(*status,ONLP_FAN_STATUS_B2F); - *status=REMOVE_STATE(*status,ONLP_FAN_STATUS_F2B); - } else { - *status=REMOVE_STATE(*status,ONLP_FAN_STATUS_FAILED); - } - } else { - AIM_LOG_ERROR("[ONLP][FAN] Read error in line %s\n",__LINE__); - } - break; - default: - rv = ONLP_STATUS_E_INVALID; - break; - } - return rv; -} - -static int _fani_status_present_check(uint32_t* status, int fan_id) -{ - int rv; - int len; - char buf[ONLP_CONFIG_INFO_STR_MAX]; - if(fan_id >= ONLP_FAN_1 && fan_id <= ONLP_FAN_10) { - rv = onlp_file_read((uint8_t*)buf,ONLP_CONFIG_INFO_STR_MAX, &len, INV_FAN_PREFIX"fanmodule%d_type",BLADE_TO_FAN_ID(fan_id)); - } else { - rv = ONLP_STATUS_E_INVALID; - } - if( rv == ONLP_STATUS_OK ) { - switch( (int)(buf[0]-'0') ) { - case HWMON_FAN_F2B: - *status=ADD_STATE(*status,ONLP_FAN_STATUS_PRESENT); - *status=ADD_STATE(*status,ONLP_FAN_STATUS_F2B); - break; - case HWMON_FAN_B2F: - *status=ADD_STATE(*status,ONLP_FAN_STATUS_PRESENT); - *status=ADD_STATE(*status,ONLP_FAN_STATUS_B2F); - break; - case HWMON_FAN_UNPLUGGED: - case HWMON_FAN_UNPLUGGED2: - *status=ADD_STATE(*status,ONLP_FAN_STATUS_FAILED); - break; - default: - rv = ONLP_STATUS_E_INVALID; - break; - } - } - return rv; -} - -/** - * @brief Retrieve the fan's operational status. - * @param id The fan OID. - * @param rv [out] Receives the fan's operations status flags. - * @notes Only operational state needs to be returned - - * PRESENT/FAILED - */ -int onlp_fani_status_get(onlp_oid_t id, uint32_t* rv) -{ - int result = ONLP_STATUS_OK; - onlp_fan_info_t* info; - int fan_id=ONLP_OID_ID_GET(id); - uint32_t psu_status; - - VALIDATE(id); - - - if(fan_id >= ONLP_FAN_MAX) { - result = ONLP_STATUS_E_INVALID; - } else { - info = &__onlp_fan_info[fan_id]; - switch(fan_id) { - case ONLP_FAN_1: - case ONLP_FAN_2: - case ONLP_FAN_3: - case ONLP_FAN_4: - case ONLP_FAN_5: - case ONLP_FAN_6: - case ONLP_FAN_7: - case ONLP_FAN_8: - case ONLP_FAN_9: - case ONLP_FAN_10: - result = _fani_status_present_check(&info->status, fan_id); - if (result == ONLP_STATUS_OK ) { - if (info->status & ONLP_FAN_STATUS_PRESENT) { - result = _fani_status_failed_check(&info->status, fan_id); - } - } - break; - case ONLP_FAN_PSU_1: - case ONLP_FAN_PSU_2: - result = onlp_psui_status_get((&info->hdr)->poid, &psu_status); - if(result != ONLP_STATUS_OK) { - return result; - } - if(psu_status & ONLP_PSU_STATUS_PRESENT) { - info->status = ADD_STATE(info->status, ONLP_FAN_STATUS_PRESENT); - result = _fani_status_failed_check(&info->status, fan_id); - } else { - info->status = 0; - } - break; - default: - result = ONLP_STATUS_E_INVALID; - break; - } - *rv = info->status; - } - return result; -} - -/** - * @brief Retrieve the fan's OID hdr. - * @param id The fan OID. - * @param rv [out] Receives the OID header. - */ -int onlp_fani_hdr_get(onlp_oid_t id, onlp_oid_hdr_t* hdr) -{ - int result = ONLP_STATUS_OK; - onlp_fan_info_t* info; - int fan_id; - VALIDATE(id); - - fan_id = ONLP_OID_ID_GET(id); - if(fan_id >= ONLP_FAN_MAX) { - result = ONLP_STATUS_E_INVALID; - } else { - info = &__onlp_fan_info[fan_id]; - *hdr = info->hdr; - } - return result; -} - - -/* - * 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) -{ - return ONLP_STATUS_E_UNSUPPORTED; -} - - -/* - * 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/d6332/onlp/builds/x86_64_inventec_d6332/module/src/ledi.c b/packages/platforms/inventec/x86-64/d6332/onlp/builds/x86_64_inventec_d6332/module/src/ledi.c deleted file mode 100644 index 8b41bbd93..000000000 --- a/packages/platforms/inventec/x86-64/d6332/onlp/builds/x86_64_inventec_d6332/module/src/ledi.c +++ /dev/null @@ -1,249 +0,0 @@ -/************************************************************ - * ledi.c - * - * Copyright 2018 Inventec Technology Corporation. - * - ************************************************************ - * - ***********************************************************/ -#include -#include -#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) - -/* LED related data - */ - -/* CAPS*/ -#define SYS_LED_CAPS 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_ORANGE -#define FAN_LED_CAPS ONLP_LED_CAPS_RED|ONLP_LED_CAPS_GREEN - -#define LED_ID_TO_FAN_ID(id) (id-ONLP_LED_SYS) -#define FAN_TO_BLADE_ID(fan_id) fan_id*2 - -typedef enum sys_led_mode_e { - SYS_LED_MODE_OFF = 0, - SYS_LED_MODE_ON = 1, - SYS_LED_MODE_1_HZ = 2, - SYS_LED_MODE_2_HZ = 3 -} sys_led_mode_t; - -static char* __led_path_list[ONLP_LED_MAX] = { - "reserved", - INV_LED_PREFIX"/stacking_led", - INV_LED_PREFIX"/fan_led", - INV_LED_PREFIX"/power_led", - INV_LED_PREFIX"/service_led", - INV_LED_PREFIX"/fanmodule1_led", - INV_LED_PREFIX"/fanmodule2_led", - INV_LED_PREFIX"/fanmodule3_led", - INV_LED_PREFIX"/fanmodule4_led", - INV_LED_PREFIX"/fanmodule5_led", -}; - -/* - * Get the information for the given LED OID. - */ - -#define MAKE_LED_INFO_NODE_ON_FAN(fan_id) \ - { \ - { ONLP_LED_ID_CREATE(ONLP_LED_FAN##fan_id), \ - "FAN LED "#fan_id, 0, \ - }, \ - 0, FAN_LED_CAPS, \ - } - -static onlp_led_info_t __onlp_led_info[] = { - {},/* Not used */ - { - { ONLP_LED_ID_CREATE(ONLP_LED_STK), "Chassis LED (STACKING LED)", 0 }, - ONLP_LED_STATUS_PRESENT, - ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_GREEN_BLINKING, - ONLP_LED_MODE_ON, '0', - }, - { - { ONLP_LED_ID_CREATE(ONLP_LED_FAN), "Chassis LED (FAN LED)", 0 }, - ONLP_LED_STATUS_PRESENT, - ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_GREEN_BLINKING , - ONLP_LED_MODE_ON, '0', - }, - { - { ONLP_LED_ID_CREATE(ONLP_LED_PWR), "Chassis LED (POWER LED)", 0 }, - ONLP_LED_STATUS_PRESENT, - ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_GREEN_BLINKING, - ONLP_LED_MODE_ON, '0', - }, - { - { ONLP_LED_ID_CREATE(ONLP_LED_SYS), "Chassis LED (SYSTEM LED)", 0 }, - ONLP_LED_STATUS_PRESENT, - ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_BLUE| ONLP_LED_CAPS_BLUE_BLINKING, - ONLP_LED_MODE_ON, '0', - }, - MAKE_LED_INFO_NODE_ON_FAN(1), - MAKE_LED_INFO_NODE_ON_FAN(2), - MAKE_LED_INFO_NODE_ON_FAN(3), - MAKE_LED_INFO_NODE_ON_FAN(4), - MAKE_LED_INFO_NODE_ON_FAN(5), -}; - - -/* - * 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 led_id = ONLP_OID_ID_GET(id); - int fan_id=LED_ID_TO_FAN_ID(led_id); - int len,led_state; - char buf[ONLP_CONFIG_INFO_STR_MAX] = {0}; - uint32_t fan_status; - int rv; - - VALIDATE(id); - - memset(info, 0, sizeof(onlp_led_info_t)); - *info = __onlp_led_info[led_id]; - - switch (led_id) { - case ONLP_LED_STK: - if( onlp_file_read((uint8_t*)buf,ONLP_CONFIG_INFO_STR_MAX, &len, __led_path_list[led_id]) == ONLP_STATUS_OK ) { - led_state=(int)(buf[0]-'0'); - if(led_state==SYS_LED_MODE_OFF) { - info->mode = ONLP_LED_MODE_OFF; - } else if(led_state==SYS_LED_MODE_ON) { - info->mode = ONLP_LED_MODE_ON; - } else if(led_state==SYS_LED_MODE_1_HZ) { - info->mode =ONLP_LED_MODE_GREEN_BLINKING; - } else { - AIM_LOG_ERROR("[ONLP][LED] Not defined LED behavior detected on led@%d\n", led_id); - return ONLP_STATUS_E_INTERNAL; - } - } - info->status &= ONLP_LED_STATUS_PRESENT; - return ONLP_STATUS_OK; - break; - case ONLP_LED_SYS: - if( onlp_file_read((uint8_t*)buf,ONLP_CONFIG_INFO_STR_MAX, &len, __led_path_list[led_id]) == ONLP_STATUS_OK ) { - led_state=(int)(buf[0]-'0'); - if(led_state==SYS_LED_MODE_OFF) { - info->mode = ONLP_LED_MODE_OFF; - } else if(led_state==SYS_LED_MODE_ON) { - info->mode = ONLP_LED_MODE_ON; - } else if(led_state==SYS_LED_MODE_1_HZ) { - info->mode =ONLP_LED_MODE_BLUE_BLINKING; - } else { - AIM_LOG_ERROR("[ONLP][LED] Not defined LED behavior detected on led@%d\n", led_id); - return ONLP_STATUS_E_INTERNAL; - } - } - info->status &= ONLP_LED_STATUS_PRESENT; - return ONLP_STATUS_OK; - break; - case ONLP_LED_FAN: - case ONLP_LED_PWR: - if( onlp_file_read((uint8_t*)buf,ONLP_CONFIG_INFO_STR_MAX, &len, __led_path_list[led_id]) == ONLP_STATUS_OK ) { - led_state=(int)(buf[0]-'0'); - if(led_state==SYS_LED_MODE_OFF) { - info->mode = ONLP_LED_MODE_OFF; - } else if(led_state==SYS_LED_MODE_ON) { - info->mode = ONLP_LED_MODE_ON; - } else if( (led_state==SYS_LED_MODE_1_HZ)||(led_state==SYS_LED_MODE_2_HZ) ) { - info->mode =ONLP_LED_MODE_GREEN_BLINKING; - } else { - AIM_LOG_ERROR("[ONLP][LED] Not defined LED behavior detected on led@%d\n", led_id); - return ONLP_STATUS_E_INTERNAL; - } - } - info->status &= ONLP_LED_STATUS_PRESENT; - return ONLP_STATUS_OK; - break; - case ONLP_LED_FAN1: - case ONLP_LED_FAN2: - case ONLP_LED_FAN3: - case ONLP_LED_FAN4: - case ONLP_LED_FAN5: - rv = onlp_fani_status_get(ONLP_FAN_ID_CREATE(FAN_TO_BLADE_ID(fan_id)), &fan_status); - if(rv==ONLP_STATUS_OK) { - rv = onlp_file_read((uint8_t*)buf,ONLP_CONFIG_INFO_STR_MAX, &len, INV_LED_PREFIX"fanmodule%d_led", fan_id); - } else { - AIM_LOG_ERROR("[ONLP][LED] Read error in line %s\n",__LINE__); - } - - if(rv == ONLP_STATUS_OK ) { - if(fan_status & ONLP_FAN_STATUS_PRESENT) { - info->status = ADD_STATE(info->status,ONLP_LED_STATUS_PRESENT); - switch(buf[0]) { - case '0': - info->mode = ONLP_LED_MODE_OFF; - break; - case '1': - info->mode = ONLP_LED_MODE_GREEN; - break; - case '2': - info->mode = ONLP_LED_MODE_RED; - break; - default: - rv=ONLP_STATUS_E_INVALID; - break; - } - } else { - info->status = 0 ; - } - } - break; - default: - return ONLP_STATUS_E_INVALID; - break; - } - 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) -{ - /*the led behavior is handled by another driver on D6332. Therefore, we're not supporting this attribute*/ - 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) -{ - /*the led behavior is handled by another driver on D6332. Therefore, we're not supporting this attribute*/ - return ONLP_STATUS_E_UNSUPPORTED; -} diff --git a/packages/platforms/inventec/x86-64/d6332/onlp/builds/x86_64_inventec_d6332/module/src/make.mk b/packages/platforms/inventec/x86-64/d6332/onlp/builds/x86_64_inventec_d6332/module/src/make.mk deleted file mode 100644 index 0ef2a4a3e..000000000 --- a/packages/platforms/inventec/x86-64/d6332/onlp/builds/x86_64_inventec_d6332/module/src/make.mk +++ /dev/null @@ -1,9 +0,0 @@ -############################################################################### -# -# -# -############################################################################### - -LIBRARY := x86_64_inventec_d6332 -$(LIBRARY)_SUBDIR := $(dir $(lastword $(MAKEFILE_LIST))) -include $(BUILDER)/lib.mk diff --git a/packages/platforms/inventec/x86-64/d6332/onlp/builds/x86_64_inventec_d6332/module/src/platform_lib.c b/packages/platforms/inventec/x86-64/d6332/onlp/builds/x86_64_inventec_d6332/module/src/platform_lib.c deleted file mode 100644 index aa29a967a..000000000 --- a/packages/platforms/inventec/x86-64/d6332/onlp/builds/x86_64_inventec_d6332/module/src/platform_lib.c +++ /dev/null @@ -1,34 +0,0 @@ -/************************************************************ - * platform_lib.c - * - * Copyright 2018 Inventec Technology Corporation. - * - ************************************************************ - * - ***********************************************************/ -#include -#include -#include -#include -#include -#include -#include -#include -#include "platform_lib.h" - - - -int platform_hwmon_diag_enable_read(int *enable) -{ - int rv = ONLP_STATUS_OK; - rv = onlp_file_read_int((int*)enable, INV_INFO_PREFIX"diag"); - return rv; -} - - -int platform_hwmon_diag_enable_write(int enable) -{ - int rv = ONLP_STATUS_OK; - rv = onlp_file_write_int(enable, INV_INFO_PREFIX"diag"); - return rv; -} \ No newline at end of file diff --git a/packages/platforms/inventec/x86-64/d6332/onlp/builds/x86_64_inventec_d6332/module/src/platform_lib.h b/packages/platforms/inventec/x86-64/d6332/onlp/builds/x86_64_inventec_d6332/module/src/platform_lib.h deleted file mode 100644 index 0bff124ab..000000000 --- a/packages/platforms/inventec/x86-64/d6332/onlp/builds/x86_64_inventec_d6332/module/src/platform_lib.h +++ /dev/null @@ -1,130 +0,0 @@ -/************************************************************ - * platform_lib.h - * - * Copyright 2018 Inventec Technology Corporation. - * - ************************************************************ - * - ***********************************************************/ -#ifndef __PLATFORM_LIB_H__ -#define __PLATFORM_LIB_H__ - -#include "x86_64_inventec_d6332_log.h" - -/* This is definitions for x86-64-inventec-d6332*/ -/* OID map*/ -/* - * SYS---------ONLP_THERMAL_CPU_PHY - * |----ONLP_THERMAL_CPU_CORE0 - * |----ONLP_THERMAL_CPU_CORE1 - * |----ONLP_THERMAL_CPU_CORE2 - * |----ONLP_THERMAL_CPU_CORE3 - * |----ONLP_THERMAL_1_ON_MAIN_BROAD - * |----ONLP_THERMAL_2_ON_MAIN_BROAD - * |----ONLP_THERMAL_3_ON_MAIN_BROAD - * |----ONLP_THERMAL_4_ON_MAIN_BROAD - * |----ONLP_THERMAL_5_ON_MAIN_BROAD - * |----ONLP_FAN_1--------ONLP_LED_FAN1 - * | - * |----ONLP_FAN_2--------ONLP_LED_FAN2 - * | - * |----ONLP_FAN_3--------ONLP_LED_FAN3 - * | - * |----ONLP_FAN_4--------ONLP_LED_FAN4 - * | - * |----ONLP_FAN_5--------ONLP_LED_FAN5 - * | - * | - * |----ONLP_PSU_1--------ONLP_THERMAL_1_ON_PSU1 - * | |--ONLP_THERMAL_2_ON_PSU1 - * | |--ONLP_THERMAL_3_ON_PSU1 - * | |--ONLP_FAN_PSU_1 - * | - * |----ONLP_PSU_2--------ONLP_THERMAL_1_ON_PSU2 - * | |--ONLP_THERMAL_2_ON_PSU2 - * | |--ONLP_THERMAL_3_ON_PSU2 - * | |--ONLP_FAN_PSU_2 - * | - * |----ONLP_LED_MGMT - */ - -#define INV_INFO_PREFIX "/sys/bus/i2c/devices/0-0077/" -#define INV_FAN_PREFIX "/sys/bus/i2c/devices/0-0077/" -#define INV_THERMAL_PREFIX "/sys/bus/i2c/devices/0-0077/" -#define INV_LED_PREFIX "/sys/bus/i2c/devices/0-0077/" -#define INV_SFP_PREFIX "/sys/class/swps/" -#define INV_PSU_BASE "/sys/bus/i2c/devices/" -#define INV_EEPROM_PATH "/sys/bus/i2c/devices/0-0055/eeprom" - -#define ADD_STATE(orig_state,new_state) orig_state | new_state -#define REMOVE_STATE(orig_state, target) orig_state & (~target) - -/* Thermal definitions*/ -enum onlp_thermal_id { - ONLP_THERMAL_CPU_PHY = 1, - ONLP_THERMAL_CPU_CORE0, - ONLP_THERMAL_CPU_CORE1, - ONLP_THERMAL_CPU_CORE2, - ONLP_THERMAL_CPU_CORE3, - ONLP_THERMAL_1_ON_MAIN_BROAD, - ONLP_THERMAL_2_ON_MAIN_BROAD, - ONLP_THERMAL_3_ON_MAIN_BROAD, - ONLP_THERMAL_4_ON_MAIN_BROAD, - ONLP_THERMAL_1_ON_PSU1, - ONLP_THERMAL_2_ON_PSU1, - ONLP_THERMAL_3_ON_PSU1, - ONLP_THERMAL_1_ON_PSU2, - ONLP_THERMAL_2_ON_PSU2, - ONLP_THERMAL_3_ON_PSU2, - ONLP_THERMAL_MAX /*num limit include reserved*/ -}; - -/* Fan definitions*/ -enum onlp_fan_id { - ONLP_FAN_1 = 1, - ONLP_FAN_2, - ONLP_FAN_3, - ONLP_FAN_4, - ONLP_FAN_5, - ONLP_FAN_6, - ONLP_FAN_7, - ONLP_FAN_8, - ONLP_FAN_9, - ONLP_FAN_10, - ONLP_FAN_PSU_1, - ONLP_FAN_PSU_2, - ONLP_FAN_MAX /*num limit include reserved*/ -}; - -/* PSU definitions*/ -enum onlp_psu_id { - ONLP_PSU_1 = 1, - ONLP_PSU_2, - ONLP_PSU_MAX /*num limit include reserved*/ -}; - -/* LED definitions*/ -enum onlp_led_id { - ONLP_LED_STK = 1, - ONLP_LED_FAN, - ONLP_LED_PWR, - ONLP_LED_SYS, - ONLP_LED_FAN1, - ONLP_LED_FAN2, - ONLP_LED_FAN3, - ONLP_LED_FAN4, - ONLP_LED_FAN5, - ONLP_LED_MAX /*num limit include reserved*/ -}; - -/* platform functions*/ -#define PLATFORM_HWMON_DIAG_LOCK -#define PLATFORM_HWMON_DIAG_UNLOCK -int platform_hwmon_diag_enable_read(int *enable); -int platform_hwmon_diag_enable_write(int enable); -char* hwmon_path( char* parent_dir); - - - -#endif /* __PLATFORM_LIB_H__ */ - diff --git a/packages/platforms/inventec/x86-64/d6332/onlp/builds/x86_64_inventec_d6332/module/src/psui.c b/packages/platforms/inventec/x86-64/d6332/onlp/builds/x86_64_inventec_d6332/module/src/psui.c deleted file mode 100644 index 41eb63998..000000000 --- a/packages/platforms/inventec/x86-64/d6332/onlp/builds/x86_64_inventec_d6332/module/src/psui.c +++ /dev/null @@ -1,183 +0,0 @@ -/************************************************************ - * psui.c - * - * Copyright 2018 Inventec Technology Corporation. - * - ************************************************************ - * - ***********************************************************/ -#include -#include -#include "platform_lib.h" -#include -#include - -#define VALIDATE(_id) \ - do { \ - if(!ONLP_OID_IS_PSU(_id)) { \ - return ONLP_STATUS_E_INVALID; \ - } \ - } while(0) - -typedef enum hwmon_psu_state_e { - HWMON_PSU_UNPOWERED = 0, - HWMON_PSU_NORMAL = 1, - HWMON_PSU_NOT_INSTALLED = 2, - HWMON_PSU_NOT_INSTALLED_2 = 3 -} hwmon_psu_state_t; - -#define PSU_CAPS ONLP_PSU_CAPS_VIN|ONLP_PSU_CAPS_VOUT|ONLP_PSU_CAPS_IIN|ONLP_PSU_CAPS_IOUT|ONLP_PSU_CAPS_PIN| ONLP_PSU_CAPS_POUT - -/* - * Get all information about the given PSU oid. - */ -#define MAKE_PSU_NODE_INFO(id) \ - { \ - { \ - ONLP_PSU_ID_CREATE(ONLP_PSU_##id), "PSU-"#id, 0, \ - { \ - ONLP_THERMAL_ID_CREATE(ONLP_THERMAL_1_ON_PSU##id), \ - ONLP_THERMAL_ID_CREATE(ONLP_THERMAL_2_ON_PSU##id), \ - ONLP_THERMAL_ID_CREATE(ONLP_THERMAL_3_ON_PSU##id), \ - ONLP_FAN_ID_CREATE(ONLP_FAN_PSU_##id) \ - } \ - }, \ - "","", 0, PSU_CAPS, \ - } - -static onlp_psu_info_t __onlp_psu_info[ ] = { - {}, - MAKE_PSU_NODE_INFO(1), - MAKE_PSU_NODE_INFO(2) -}; - -int -onlp_psui_init(void) -{ - return ONLP_STATUS_OK; -} - - -int -onlp_psui_info_get(onlp_oid_t id, onlp_psu_info_t* info) -{ - int ret = ONLP_STATUS_OK; - int psu_id = ONLP_OID_ID_GET(id); - char path[ONLP_CONFIG_INFO_STR_MAX]; - - VALIDATE(id); - - if(psu_id >= ONLP_PSU_MAX) { - AIM_LOG_ERROR("[ONLP][PSU] OID %d out of range in %s", psu_id, __FUNCTION__); - return ONLP_STATUS_E_INVALID; - } - - *info = __onlp_psu_info[psu_id]; - ret = onlp_psui_status_get(id, &info->status); - if(ret != ONLP_STATUS_OK) { - return ret; - } - - if(info->status & ONLP_PSU_STATUS_PRESENT) { - snprintf(path,ONLP_CONFIG_INFO_STR_MAX, "/var/psu%d/",psu_id); - - if(ret==ONLP_STATUS_OK) { - ret=onlp_file_read_int( &info->mvin, "%sin1_input", path ); - } - - if(ret==ONLP_STATUS_OK) { - ret=onlp_file_read_int( &info->mvout, "%sin2_input", path ); - } - - if(ret==ONLP_STATUS_OK) { - ret=onlp_file_read_int( &info->miin, "%scurr1_input", path ); - } - - if(ret==ONLP_STATUS_OK) { - ret=onlp_file_read_int( &info->miout, "%scurr2_input", path ); - } - - if(ret==ONLP_STATUS_OK) { - ret=onlp_file_read_int( &info->mpin, "%spower1_input", path ); - } - - if(ret==ONLP_STATUS_OK) { - ret=onlp_file_read_int( &info->mpout, "%spower2_input", path ); - } - } - - return ret; - -} - - -/** - * @brief Get the PSU's operational status. - * @param id The PSU OID. - * @param rv [out] Receives the operational status. - */ -int onlp_psui_status_get(onlp_oid_t id, uint32_t* rv) -{ - int result = ONLP_STATUS_OK; - hwmon_psu_state_t psu_state; - int psu_id; - int len; - char buf[ONLP_CONFIG_INFO_STR_MAX]; - - VALIDATE(id); - - - psu_id = ONLP_OID_ID_GET(id); - - if(psu_id >= ONLP_PSU_MAX) { - AIM_LOG_ERROR("[ONLP][PSU] OID %d out of range in %s", psu_id, __FUNCTION__); - result = ONLP_STATUS_E_INVALID; - } else { - result = onlp_file_read((uint8_t*)&buf, ONLP_CONFIG_INFO_STR_MAX, &len, "%spsu%d", INV_INFO_PREFIX, psu_id); - if( result != ONLP_STATUS_OK ) { - return result; - } - psu_state = (uint8_t)strtoul(buf, NULL, 0); - if( psu_state == HWMON_PSU_UNPOWERED) { - *rv = ONLP_PSU_STATUS_PRESENT|ONLP_PSU_STATUS_UNPLUGGED; - } else if ( psu_state == HWMON_PSU_NORMAL) { - *rv = ONLP_PSU_STATUS_PRESENT; - } else if( psu_state == HWMON_PSU_NOT_INSTALLED || psu_state == HWMON_PSU_NOT_INSTALLED_2 ) { - *rv = 0; - } else { - AIM_LOG_ERROR("[ONLP][PSU] Not defined PSU behavior detected on psu@%d\n", psu_id); - result = ONLP_STATUS_E_INTERNAL; - } - } - return result; -} - -/** - * @brief Get the PSU's oid header. - * @param id The PSU OID. - * @param rv [out] Receives the header. - */ -int onlp_psui_hdr_get(onlp_oid_t id, onlp_oid_hdr_t* rv) -{ - int result = ONLP_STATUS_OK; - onlp_psu_info_t* info; - int psu_id=ONLP_OID_ID_GET(id); - - VALIDATE(id); - - if(psu_id >= ONLP_PSU_MAX) { - result = ONLP_STATUS_E_INVALID; - } else { - info = &__onlp_psu_info[psu_id]; - *rv = info->hdr; - } - return result; -} - - -int -onlp_psui_ioctl(onlp_oid_t pid, va_list vargs) -{ - return ONLP_STATUS_E_UNSUPPORTED; -} - diff --git a/packages/platforms/inventec/x86-64/d6332/onlp/builds/x86_64_inventec_d6332/module/src/sfpi.c b/packages/platforms/inventec/x86-64/d6332/onlp/builds/x86_64_inventec_d6332/module/src/sfpi.c deleted file mode 100644 index 1fbcc020b..000000000 --- a/packages/platforms/inventec/x86-64/d6332/onlp/builds/x86_64_inventec_d6332/module/src/sfpi.c +++ /dev/null @@ -1,267 +0,0 @@ -/************************************************************ - * sfpi.c - * - * Copyright 2018 Inventec Technology Corporation. - * - ************************************************************ - * - ***********************************************************/ - -#include -#include /* For O_RDWR && open */ -#include -#include -#include -#include -#include -#include "platform_lib.h" -#include -#include - -#define SFP_PRESENT 0 -#define SFP_NOT_PRESENT 1 -#define MUX_START_INDEX 12 -#define QSFP_DEV_ADDR 0x50 -#define NUM_OF_QSFP_PORT 32 -#define NUM_OF_ALL_PORT (NUM_OF_QSFP_PORT) - -#define FRONT_PORT_TO_MUX_INDEX(port) (port+MUX_START_INDEX) -#define VALIDATE_PORT(p) { if ((p < 0) || (p >= NUM_OF_ALL_PORT)) return ONLP_STATUS_E_PARAM; } -/************************************************************ - * - * SFPI Entry Points - * - ***********************************************************/ -int -onlp_sfpi_init(void) -{ - /* Called at initialization time */ - return ONLP_STATUS_OK; -} - -int onlp_sfpi_port_map(int port, int* rport) -{ - VALIDATE_PORT(port); - *rport = port; - return ONLP_STATUS_OK; -} - -int -onlp_sfpi_bitmap_get(onlp_sfp_bitmap_t* bmap) -{ - /* - * Ports {0, 63} - */ - int p; - AIM_BITMAP_CLR_ALL(bmap); - - for(p = 0; p < NUM_OF_ALL_PORT; p++) { - AIM_BITMAP_SET(bmap, p); - } - - return ONLP_STATUS_OK; -} - -int -onlp_sfpi_is_present(int port) -{ - /* - * Return 0 if present. - * Return 1 if not present. - * Return < 0 if error. - */ - VALIDATE_PORT(port); - int rv,present_data; - rv= onlp_file_read_int(&present_data, INV_SFP_PREFIX"port%d/present", port); - if(rv==ONLP_STATUS_OK) { - if( present_data== SFP_NOT_PRESENT) { - rv = 0; - } else if (present_data == SFP_PRESENT ) { - rv = 1; - } else { - AIM_LOG_ERROR("[ONLP][SFP] Unvalid present status %d from port(%d)\r\n",present_data,port); - return ONLP_STATUS_E_INTERNAL; - } - } else { - AIM_LOG_ERROR("[ONLP][SFP] Unable to read present status of port(%d)\n",port); - } - return rv; -} - -int -onlp_sfpi_presence_bitmap_get(onlp_sfp_bitmap_t* dst) -{ - AIM_BITMAP_CLR_ALL(dst); - int port; - for(port = 0; port < NUM_OF_ALL_PORT; port++) { - if(onlp_sfpi_is_present(port) == 1) { - AIM_BITMAP_MOD(dst, port, 1); - } else if(onlp_sfpi_is_present(port) == 0) { - AIM_BITMAP_MOD(dst, port, 0); - } else { - return ONLP_STATUS_E_INTERNAL; - } - } - return ONLP_STATUS_OK; -} - -int -onlp_sfpi_is_rx_los(int port) -{ - /* rx los of QSFP are not supported*/ - return ONLP_STATUS_E_UNSUPPORTED; -} - -int -onlp_sfpi_rx_los_bitmap_get(onlp_sfp_bitmap_t* dst) -{ - /* rx los of QSFP are not supported*/ - return ONLP_STATUS_E_UNSUPPORTED; -} - -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; -} - -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 - */ - memset(data, 0, 256); - - VALIDATE_PORT(port); - int sts; - int bus = FRONT_PORT_TO_MUX_INDEX(port); - sts = onlp_i2c_block_read(bus, QSFP_DEV_ADDR, 0, 256, data, ONLP_I2C_F_FORCE); - if(sts < 0) { - AIM_LOG_ERROR("Unable to read eeprom from port(%d)\r\n", port); - return ONLP_STATUS_E_MISSING; - } - return ONLP_STATUS_OK; -} - -int -onlp_sfpi_dev_readb(int port, uint8_t devaddr, uint8_t addr) -{ - VALIDATE_PORT(port); - 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) -{ - VALIDATE_PORT(port); - 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) -{ - VALIDATE_PORT(port); - 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) -{ - VALIDATE_PORT(port); - int bus = FRONT_PORT_TO_MUX_INDEX(port); - return onlp_i2c_writew(bus, devaddr, addr, value, ONLP_I2C_F_FORCE); -} - -int -onlp_sfpi_control_supported(int port, onlp_sfp_control_t control, int* rv) -{ - *rv = 0; - if(port >= 0 && port < NUM_OF_QSFP_PORT) { - switch (control) { - case ONLP_SFP_CONTROL_RESET_STATE: - case ONLP_SFP_CONTROL_LP_MODE: - *rv = 1; - break; - default: - break; - } - } - return ONLP_STATUS_OK; -} - -int -onlp_sfpi_control_set(int port, onlp_sfp_control_t control, int value) -{ - int ret = ONLP_STATUS_E_UNSUPPORTED; - - if(port >= 0 && port < NUM_OF_QSFP_PORT) { - switch (control) { - case ONLP_SFP_CONTROL_RESET_STATE: - ret = onlp_file_write_int(value, INV_SFP_PREFIX"port%d/reset", port); - break; - case ONLP_SFP_CONTROL_LP_MODE: - ret = onlp_file_write_int(value, INV_SFP_PREFIX"port%d/lpmod", port); - break; - default: - break; - } - } - return ret; -} - -int -onlp_sfpi_control_get(int port, onlp_sfp_control_t control, int* value) -{ - int ret = ONLP_STATUS_E_UNSUPPORTED; - - if(port >= 0 && port < NUM_OF_QSFP_PORT) { - switch (control) { - /*the value of /port(id)/reset - 0: in reset state; 1:not in reset state*/ - case ONLP_SFP_CONTROL_RESET_STATE: - ret = onlp_file_read_int(value, INV_SFP_PREFIX"port%d/reset", port); - *value=(!(*value)); - break; - case ONLP_SFP_CONTROL_LP_MODE: - ret = onlp_file_read_int(value, INV_SFP_PREFIX"port%d/lpmod", port); - break; - default: - break; - } - } else { - ret=ONLP_STATUS_E_INVALID; - AIM_LOG_ERROR("[ONLP][SFP] Invalid port id in %s\n",__FUNCTION__); - } - return ret; -} - -int -onlp_sfpi_denit(void) -{ - return ONLP_STATUS_OK; -} - -void -onlp_sfpi_debug(int port, aim_pvs_t* pvs) -{ - aim_printf(pvs, "Debug data for port %d goes here.", port); -} - -int -onlp_sfpi_ioctl(int port, va_list vargs) -{ - return ONLP_STATUS_E_UNSUPPORTED; -} diff --git a/packages/platforms/inventec/x86-64/d6332/onlp/builds/x86_64_inventec_d6332/module/src/sysi.c b/packages/platforms/inventec/x86-64/d6332/onlp/builds/x86_64_inventec_d6332/module/src/sysi.c deleted file mode 100644 index 1dd4dbce2..000000000 --- a/packages/platforms/inventec/x86-64/d6332/onlp/builds/x86_64_inventec_d6332/module/src/sysi.c +++ /dev/null @@ -1,261 +0,0 @@ -/************************************************************ - * sysi.c - * - * Copyright 2018 Inventec Technology Corporation. - * - ************************************************************ - * - ***********************************************************/ -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "x86_64_inventec_d6332_int.h" -#include "x86_64_inventec_d6332_log.h" - -#include "platform_lib.h" - -static onlp_oid_t __oid_info[] = { - ONLP_THERMAL_ID_CREATE(ONLP_THERMAL_CPU_PHY), - ONLP_THERMAL_ID_CREATE(ONLP_THERMAL_CPU_CORE0), - ONLP_THERMAL_ID_CREATE(ONLP_THERMAL_CPU_CORE1), - ONLP_THERMAL_ID_CREATE(ONLP_THERMAL_CPU_CORE2), - ONLP_THERMAL_ID_CREATE(ONLP_THERMAL_CPU_CORE3), - ONLP_THERMAL_ID_CREATE(ONLP_THERMAL_1_ON_MAIN_BROAD), - ONLP_THERMAL_ID_CREATE(ONLP_THERMAL_2_ON_MAIN_BROAD), - ONLP_THERMAL_ID_CREATE(ONLP_THERMAL_3_ON_MAIN_BROAD), - ONLP_THERMAL_ID_CREATE(ONLP_THERMAL_4_ON_MAIN_BROAD), - ONLP_FAN_ID_CREATE(ONLP_FAN_1), - ONLP_FAN_ID_CREATE(ONLP_FAN_2), - ONLP_FAN_ID_CREATE(ONLP_FAN_3), - ONLP_FAN_ID_CREATE(ONLP_FAN_4), - ONLP_FAN_ID_CREATE(ONLP_FAN_5), - ONLP_FAN_ID_CREATE(ONLP_FAN_6), - ONLP_FAN_ID_CREATE(ONLP_FAN_7), - ONLP_FAN_ID_CREATE(ONLP_FAN_8), - ONLP_FAN_ID_CREATE(ONLP_FAN_9), - ONLP_FAN_ID_CREATE(ONLP_FAN_10), - ONLP_PSU_ID_CREATE(ONLP_PSU_1), - ONLP_PSU_ID_CREATE(ONLP_PSU_2), - ONLP_LED_ID_CREATE(ONLP_LED_STK), - ONLP_LED_ID_CREATE(ONLP_LED_FAN), - ONLP_LED_ID_CREATE(ONLP_LED_PWR), - ONLP_LED_ID_CREATE(ONLP_LED_SYS), - ONLP_LED_ID_CREATE(ONLP_LED_FAN1), - ONLP_LED_ID_CREATE(ONLP_LED_FAN2), - ONLP_LED_ID_CREATE(ONLP_LED_FAN3), - ONLP_LED_ID_CREATE(ONLP_LED_FAN4), - ONLP_LED_ID_CREATE(ONLP_LED_FAN5), - 0/*end*/ -}; - -static int _sysi_version_parsing(char* file_str, char* str_buf, char* str_buf2, char* version); - -static int _sysi_version_parsing(char* file_str, char* str_buf, char* str_buf2, char* version) -{ - int rv = ONLP_STATUS_OK; - int len; - char buf[ONLP_CONFIG_INFO_STR_MAX * 4]; - char *temp; - char cpld_v1[ONLP_CONFIG_INFO_STR_MAX]; - char cpld_v2[ONLP_CONFIG_INFO_STR_MAX]; - - rv = onlp_file_read((uint8_t*)buf, ONLP_CONFIG_INFO_STR_MAX * 4, &len, file_str); - if ( rv != ONLP_STATUS_OK ) { - return rv; - } - temp = strstr(buf, str_buf); - if (temp) { - temp += strlen(str_buf); - sscanf(temp, "%s", cpld_v1); - } else { - AIM_LOG_ERROR("[ONLP][SYS] Unable to parse cpld version\n"); - return ONLP_STATUS_E_INVALID; - } - temp = strstr(temp, str_buf2); - if (temp) { - temp += strlen(str_buf2); - sscanf(temp, "%s", cpld_v2); - } else { - AIM_LOG_ERROR("[ONLP][SYS] Unable to parse cpld2 version\n"); - return ONLP_STATUS_E_INVALID; - } - snprintf(version, ONLP_CONFIG_INFO_STR_MAX, "c1_%s c2_%s", cpld_v1, cpld_v2); - - return rv; -} - -const char* -onlp_sysi_platform_get(void) -{ - return "x86-64-inventec-d6332-r0"; -} - - -/* - * This function is called to return the physical base address - * of the ONIE boot rom. - * - * The ONLP framework will mmap() and parse the ONIE TLV structure - * from the given data. - * - * If you platform does not support a mappable address for the ONIE - * eeprom then you should not provide this function at all. - * - * For the purposes of this example we will provide it but - * return UNSUPPORTED (which is all the default implementation does). - * - */ -int -onlp_sysi_onie_data_phys_addr_get(void** pa) -{ - return ONLP_STATUS_E_UNSUPPORTED; -} - - -/* - * If you cannot provide a base address you must provide the ONLP - * framework the raw ONIE data through whatever means necessary. - * - * This function will be called as a backup in the event that - * onlp_sysi_onie_data_phys_addr_get() fails. - */ -int -onlp_sysi_onie_data_get(uint8_t** data, int* size) -{ - int ret=ONLP_STATUS_E_INVALID; - int eeprom_size; - int rv; - uint8_t* eeprom_data; - - FILE* fp = fopen(INV_EEPROM_PATH, "rb"); - - if(fp) { - fseek(fp, 0L, SEEK_END); - eeprom_size = ftell(fp); - rewind(fp); - eeprom_data = aim_malloc(eeprom_size); - - rv = fread(eeprom_data, 1, eeprom_size, fp); - fclose(fp); - - if(rv == eeprom_size) { - ret=ONLP_STATUS_OK; - *data=eeprom_data; - *size=eeprom_size; - } - - } - - - return ret; -} - -/* - * IF the ONLP frame calles onlp_sysi_onie_data_get(), - * if will call this function to free the data when it - * is finished with it. - * - * This function is optional, and depends on the data - * you return in onlp_sysi_onie_data_get(). - */ -void -onlp_sysi_onie_data_free(uint8_t* data) -{ - /* - * We returned a static array in onlp_sysi_onie_data_get() - * so no free operation is required. - */ - if (data) { - aim_free(data); - } -} - - -int -onlp_sysi_onie_info_get (onlp_onie_info_t *onie) -{ - int rv = ONLP_STATUS_OK; - - rv = onlp_onie_decode_file(onie, INV_EEPROM_PATH); - - onie->_hdr_id_string = aim_fstrdup("TlvInfo"); - onie->_hdr_version = 0x1; - return rv; -} - - -int -onlp_sysi_platform_info_get(onlp_platform_info_t* pi) -{ - int rv = ONLP_STATUS_OK; - char cpld_str[ONLP_CONFIG_INFO_STR_MAX] = {0}; - char version[ONLP_CONFIG_INFO_STR_MAX]; - pi->cpld_versions = NULL; - - rv = _sysi_version_parsing( INV_INFO_PREFIX"info", "The CPLD version is ", "The CPLD2 version is ",version); - if ( rv != ONLP_STATUS_OK ) { - return rv; - } - snprintf(cpld_str, ONLP_CONFIG_INFO_STR_MAX, "%s%s ", cpld_str, version); - /*cpld version*/ - if (strlen(cpld_str) > 0) { - pi->cpld_versions = aim_fstrdup("%s", cpld_str); - } - return rv; -} - -void -onlp_sysi_platform_info_free(onlp_platform_info_t* pi) -{ - if (pi->cpld_versions) { - aim_free(pi->cpld_versions); - } - if (pi->other_versions) { - aim_free(pi->other_versions); - } - return; -} - - -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 = 0; i < max; i++) { - if (__oid_info[i] == 0) { - break; - } - *e++ = __oid_info[i]; - } - return ONLP_STATUS_OK; -} - -int -onlp_sysi_platform_manage_fans(void) -{ - /*Ensure switch manager is working*/ - PLATFORM_HWMON_DIAG_LOCK; - return ONLP_STATUS_OK; -} - -int -onlp_sysi_platform_manage_leds(void) -{ - /*Ensure switch manager is working*/ - PLATFORM_HWMON_DIAG_LOCK; - return ONLP_STATUS_OK; -} - diff --git a/packages/platforms/inventec/x86-64/d6332/onlp/builds/x86_64_inventec_d6332/module/src/thermali.c b/packages/platforms/inventec/x86-64/d6332/onlp/builds/x86_64_inventec_d6332/module/src/thermali.c deleted file mode 100644 index a41fbcd40..000000000 --- a/packages/platforms/inventec/x86-64/d6332/onlp/builds/x86_64_inventec_d6332/module/src/thermali.c +++ /dev/null @@ -1,208 +0,0 @@ -/************************************************************ - * thermali.c - * - * Copyright 2018 Inventec Technology Corporation. - * - ************************************************************ - * - * 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) - - -typedef struct thermali_path_s { - char file[ONLP_CONFIG_INFO_STR_MAX]; -} thermali_path_t; - -#define MAKE_THERMAL_PATH_ON_CPU(id) { "/var/coretemp/temp"#id"_input"} -#define MAKE_THERMAL_PATH_ON_MAIN_BROAD(id) { "/var/board_thermal_"#id"/temp1_input"} -#define MAKE_THERMAL_PATH_ON_PSU(psu_id,thermal_id) { "/var/psu"#psu_id"/temp"#thermal_id"_input"} - -static thermali_path_t __path_list[ ] = { - {}, - MAKE_THERMAL_PATH_ON_CPU(1), - MAKE_THERMAL_PATH_ON_CPU(2), - MAKE_THERMAL_PATH_ON_CPU(3), - MAKE_THERMAL_PATH_ON_CPU(4), - MAKE_THERMAL_PATH_ON_CPU(5), - MAKE_THERMAL_PATH_ON_MAIN_BROAD(1), - MAKE_THERMAL_PATH_ON_MAIN_BROAD(2), - MAKE_THERMAL_PATH_ON_MAIN_BROAD(3), - MAKE_THERMAL_PATH_ON_MAIN_BROAD(4), - MAKE_THERMAL_PATH_ON_PSU(1,1), - MAKE_THERMAL_PATH_ON_PSU(1,2), - MAKE_THERMAL_PATH_ON_PSU(1,3), - MAKE_THERMAL_PATH_ON_PSU(2,1), - MAKE_THERMAL_PATH_ON_PSU(2,2), - MAKE_THERMAL_PATH_ON_PSU(2,3) -}; - -#define MAKE_THERMAL_INFO_NODE_ON_CPU_PHY \ - { { ONLP_THERMAL_ID_CREATE(ONLP_THERMAL_CPU_PHY), "CPU Physical", 0}, \ - ONLP_THERMAL_STATUS_PRESENT, \ - ONLP_THERMAL_CAPS_GET_TEMPERATURE, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS \ - } -#define MAKE_THERMAL_INFO_NODE_ON_CPU_CORE(id) \ - { { ONLP_THERMAL_ID_CREATE(ONLP_THERMAL_CPU_CORE##id), "CPU Core "#id, 0},\ - ONLP_THERMAL_STATUS_PRESENT, \ - ONLP_THERMAL_CAPS_GET_TEMPERATURE, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS \ - } -#define MAKE_THERMAL_INFO_NODE_ON_BROADS(id) \ - { { ONLP_THERMAL_ID_CREATE(ONLP_THERMAL_##id##_ON_MAIN_BROAD), "Thermal Sensor "#id, 0}, \ - ONLP_THERMAL_STATUS_PRESENT, \ - ONLP_THERMAL_CAPS_GET_TEMPERATURE, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS \ - } -#define MAKE_THERMAL_INFO_NODE_ON_PSU(thermal_id, psu_id) \ - { { \ - ONLP_THERMAL_ID_CREATE(ONLP_THERMAL_##thermal_id##_ON_PSU##psu_id), \ - "PSU-"#psu_id" Thermal Sensor "#thermal_id, \ - ONLP_PSU_ID_CREATE(ONLP_PSU_##psu_id) \ - }, \ - ONLP_THERMAL_STATUS_PRESENT, \ - ONLP_THERMAL_CAPS_GET_TEMPERATURE, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS \ - } - -/* Static values */ -static onlp_thermal_info_t __onlp_thermal_info[ ] = { - {}, - MAKE_THERMAL_INFO_NODE_ON_CPU_PHY, - MAKE_THERMAL_INFO_NODE_ON_CPU_CORE(0), - MAKE_THERMAL_INFO_NODE_ON_CPU_CORE(1), - MAKE_THERMAL_INFO_NODE_ON_CPU_CORE(2), - MAKE_THERMAL_INFO_NODE_ON_CPU_CORE(3), - MAKE_THERMAL_INFO_NODE_ON_BROADS(1), - MAKE_THERMAL_INFO_NODE_ON_BROADS(2), - MAKE_THERMAL_INFO_NODE_ON_BROADS(3), - MAKE_THERMAL_INFO_NODE_ON_BROADS(4), - MAKE_THERMAL_INFO_NODE_ON_PSU(1,1), - MAKE_THERMAL_INFO_NODE_ON_PSU(2,1), - MAKE_THERMAL_INFO_NODE_ON_PSU(3,1), - MAKE_THERMAL_INFO_NODE_ON_PSU(1,2), - MAKE_THERMAL_INFO_NODE_ON_PSU(2,2), - MAKE_THERMAL_INFO_NODE_ON_PSU(3,2), -}; - -/* - * 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) -{ - VALIDATE(id); - int ret; - int thermal_id = ONLP_OID_ID_GET(id); - if(thermal_id >= ONLP_THERMAL_MAX) { - return ONLP_STATUS_E_INVALID; - } - - /* Set the onlp_oid_hdr_t and capabilities */ - *info = __onlp_thermal_info[ thermal_id]; - ret = onlp_thermali_status_get(id, &info->status); - if( ret != ONLP_STATUS_OK ) { - AIM_LOG_ERROR("[ONLP][THERMAL] Unable to get thermal status in %s\n",__FUNCTION__); - return ret; - } - if(info->status & ONLP_THERMAL_STATUS_PRESENT) { - ret = onlp_file_read_int(&info->mcelsius, __path_list[thermal_id].file ); - } - - return ret; -} - -/** - * @brief Retrieve the thermal's operational status. - * @param id The thermal oid. - * @param rv [out] Receives the operational status. - */ -int onlp_thermali_status_get(onlp_oid_t id, uint32_t* rv) -{ - int ret = ONLP_STATUS_OK; - onlp_thermal_info_t* info; - VALIDATE(id); - uint32_t psu_status; - - int thermal_id = ONLP_OID_ID_GET(id); - if(thermal_id >= ONLP_THERMAL_MAX) { - return ONLP_STATUS_E_INVALID; - } - info = &__onlp_thermal_info[ thermal_id]; - - switch(thermal_id) { - case ONLP_THERMAL_1_ON_PSU1: - case ONLP_THERMAL_2_ON_PSU1: - case ONLP_THERMAL_3_ON_PSU1: - case ONLP_THERMAL_1_ON_PSU2: - case ONLP_THERMAL_2_ON_PSU2: - case ONLP_THERMAL_3_ON_PSU2: - ret = onlp_psui_status_get((&info->hdr)->poid, &psu_status); - if(ret != ONLP_STATUS_OK) { - AIM_LOG_ERROR("[ONLP][THERMAL] Unable to get psu status in %s\n",__FUNCTION__); - return ret; - } - if(psu_status & ONLP_PSU_STATUS_PRESENT) { - info->status = ADD_STATE(info->status,ONLP_PSU_STATUS_PRESENT); - } else { - info->status = 0; - } - break; - default: - break; - } - - *rv = info->status; - - return ret; -} - -/** - * @brief Retrieve the thermal's oid header. - * @param id The thermal oid. - * @param rv [out] Receives the header. - */ -int onlp_thermali_hdr_get(onlp_oid_t id, onlp_oid_hdr_t* rv) -{ - onlp_thermal_info_t* info; - VALIDATE(id); - - int thermal_id = ONLP_OID_ID_GET(id); - if(thermal_id >= ONLP_THERMAL_MAX) { - return ONLP_STATUS_E_INVALID; - } - info = &__onlp_thermal_info[ thermal_id]; - - *rv = info->hdr; - - return ONLP_STATUS_OK; -} diff --git a/packages/platforms/inventec/x86-64/d6332/onlp/builds/x86_64_inventec_d6332/module/src/x86_64_inventec_d6332_config.c b/packages/platforms/inventec/x86-64/d6332/onlp/builds/x86_64_inventec_d6332/module/src/x86_64_inventec_d6332_config.c deleted file mode 100644 index 2f315c32e..000000000 --- a/packages/platforms/inventec/x86-64/d6332/onlp/builds/x86_64_inventec_d6332/module/src/x86_64_inventec_d6332_config.c +++ /dev/null @@ -1,81 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#include - -/* */ -#define __x86_64_inventec_d6332_config_STRINGIFY_NAME(_x) #_x -#define __x86_64_inventec_d6332_config_STRINGIFY_VALUE(_x) __x86_64_inventec_d6332_config_STRINGIFY_NAME(_x) -x86_64_inventec_d6332_config_settings_t x86_64_inventec_d6332_config_settings[] = -{ -#ifdef x86_64_inventec_d6332_CONFIG_INCLUDE_LOGGING - { __x86_64_inventec_d6332_config_STRINGIFY_NAME(x86_64_inventec_d6332_CONFIG_INCLUDE_LOGGING), __x86_64_inventec_d6332_config_STRINGIFY_VALUE(x86_64_inventec_d6332_CONFIG_INCLUDE_LOGGING) }, -#else -{ x86_64_inventec_d6332_CONFIG_INCLUDE_LOGGING(__x86_64_inventec_d6332_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef x86_64_inventec_d6332_CONFIG_LOG_OPTIONS_DEFAULT - { __x86_64_inventec_d6332_config_STRINGIFY_NAME(x86_64_inventec_d6332_CONFIG_LOG_OPTIONS_DEFAULT), __x86_64_inventec_d6332_config_STRINGIFY_VALUE(x86_64_inventec_d6332_CONFIG_LOG_OPTIONS_DEFAULT) }, -#else -{ x86_64_inventec_d6332_CONFIG_LOG_OPTIONS_DEFAULT(__x86_64_inventec_d6332_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef x86_64_inventec_d6332_CONFIG_LOG_BITS_DEFAULT - { __x86_64_inventec_d6332_config_STRINGIFY_NAME(x86_64_inventec_d6332_CONFIG_LOG_BITS_DEFAULT), __x86_64_inventec_d6332_config_STRINGIFY_VALUE(x86_64_inventec_d6332_CONFIG_LOG_BITS_DEFAULT) }, -#else -{ x86_64_inventec_d6332_CONFIG_LOG_BITS_DEFAULT(__x86_64_inventec_d6332_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef x86_64_inventec_d6332_CONFIG_LOG_CUSTOM_BITS_DEFAULT - { __x86_64_inventec_d6332_config_STRINGIFY_NAME(x86_64_inventec_d6332_CONFIG_LOG_CUSTOM_BITS_DEFAULT), __x86_64_inventec_d6332_config_STRINGIFY_VALUE(x86_64_inventec_d6332_CONFIG_LOG_CUSTOM_BITS_DEFAULT) }, -#else -{ x86_64_inventec_d6332_CONFIG_LOG_CUSTOM_BITS_DEFAULT(__x86_64_inventec_d6332_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef x86_64_inventec_d6332_CONFIG_PORTING_STDLIB - { __x86_64_inventec_d6332_config_STRINGIFY_NAME(x86_64_inventec_d6332_CONFIG_PORTING_STDLIB), __x86_64_inventec_d6332_config_STRINGIFY_VALUE(x86_64_inventec_d6332_CONFIG_PORTING_STDLIB) }, -#else -{ x86_64_inventec_d6332_CONFIG_PORTING_STDLIB(__x86_64_inventec_d6332_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef x86_64_inventec_d6332_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS - { __x86_64_inventec_d6332_config_STRINGIFY_NAME(x86_64_inventec_d6332_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS), __x86_64_inventec_d6332_config_STRINGIFY_VALUE(x86_64_inventec_d6332_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS) }, -#else -{ x86_64_inventec_d6332_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS(__x86_64_inventec_d6332_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef x86_64_inventec_d6332_CONFIG_INCLUDE_UCLI - { __x86_64_inventec_d6332_config_STRINGIFY_NAME(x86_64_inventec_d6332_CONFIG_INCLUDE_UCLI), __x86_64_inventec_d6332_config_STRINGIFY_VALUE(x86_64_inventec_d6332_CONFIG_INCLUDE_UCLI) }, -#else -{ x86_64_inventec_d6332_CONFIG_INCLUDE_UCLI(__x86_64_inventec_d6332_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef x86_64_inventec_d6332_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION - { __x86_64_inventec_d6332_config_STRINGIFY_NAME(x86_64_inventec_d6332_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION), __x86_64_inventec_d6332_config_STRINGIFY_VALUE(x86_64_inventec_d6332_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION) }, -#else -{ x86_64_inventec_d6332_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION(__x86_64_inventec_d6332_config_STRINGIFY_NAME), "__undefined__" }, -#endif - { NULL, NULL } -}; -#undef __x86_64_inventec_d6332_config_STRINGIFY_VALUE -#undef __x86_64_inventec_d6332_config_STRINGIFY_NAME - -const char* -x86_64_inventec_d6332_config_lookup(const char* setting) -{ - int i; - for(i = 0; x86_64_inventec_d6332_config_settings[i].name; i++) { - if(strcmp(x86_64_inventec_d6332_config_settings[i].name, setting)) { - return x86_64_inventec_d6332_config_settings[i].value; - } - } - return NULL; -} - -int -x86_64_inventec_d6332_config_show(struct aim_pvs_s* pvs) -{ - int i; - for(i = 0; x86_64_inventec_d6332_config_settings[i].name; i++) { - aim_printf(pvs, "%s = %s\n", x86_64_inventec_d6332_config_settings[i].name, x86_64_inventec_d6332_config_settings[i].value); - } - return i; -} - -/* */ - diff --git a/packages/platforms/inventec/x86-64/d6332/onlp/builds/x86_64_inventec_d6332/module/src/x86_64_inventec_d6332_enums.c b/packages/platforms/inventec/x86-64/d6332/onlp/builds/x86_64_inventec_d6332/module/src/x86_64_inventec_d6332_enums.c deleted file mode 100644 index 1a63c275b..000000000 --- a/packages/platforms/inventec/x86-64/d6332/onlp/builds/x86_64_inventec_d6332/module/src/x86_64_inventec_d6332_enums.c +++ /dev/null @@ -1,10 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#include - -/* <--auto.start.enum(ALL).source> */ -/* */ - diff --git a/packages/platforms/inventec/x86-64/d6332/onlp/builds/x86_64_inventec_d6332/module/src/x86_64_inventec_d6332_int.h b/packages/platforms/inventec/x86-64/d6332/onlp/builds/x86_64_inventec_d6332/module/src/x86_64_inventec_d6332_int.h deleted file mode 100644 index 077c6050d..000000000 --- a/packages/platforms/inventec/x86-64/d6332/onlp/builds/x86_64_inventec_d6332/module/src/x86_64_inventec_d6332_int.h +++ /dev/null @@ -1,12 +0,0 @@ -/**************************************************************************//** - * - * x86_64_inventec_d6332 Internal Header - * - *****************************************************************************/ -#ifndef __x86_64_inventec_d6332_INT_H__ -#define __x86_64_inventec_d6332_INT_H__ - -#include - - -#endif /* __x86_64_inventec_d6332_INT_H__ */ diff --git a/packages/platforms/inventec/x86-64/d6332/onlp/builds/x86_64_inventec_d6332/module/src/x86_64_inventec_d6332_log.c b/packages/platforms/inventec/x86-64/d6332/onlp/builds/x86_64_inventec_d6332/module/src/x86_64_inventec_d6332_log.c deleted file mode 100644 index ca8e92454..000000000 --- a/packages/platforms/inventec/x86-64/d6332/onlp/builds/x86_64_inventec_d6332/module/src/x86_64_inventec_d6332_log.c +++ /dev/null @@ -1,17 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#include - -#include "x86_64_inventec_d6332_log.h" -/* - * x86_64_inventec_d6332 log struct. - */ -AIM_LOG_STRUCT_DEFINE( - x86_64_inventec_d6332_CONFIG_LOG_OPTIONS_DEFAULT, - x86_64_inventec_d6332_CONFIG_LOG_BITS_DEFAULT, - NULL, /* Custom log map */ - x86_64_inventec_d6332_CONFIG_LOG_CUSTOM_BITS_DEFAULT - ); \ No newline at end of file diff --git a/packages/platforms/inventec/x86-64/d6332/onlp/builds/x86_64_inventec_d6332/module/src/x86_64_inventec_d6332_log.h b/packages/platforms/inventec/x86-64/d6332/onlp/builds/x86_64_inventec_d6332/module/src/x86_64_inventec_d6332_log.h deleted file mode 100644 index 33a99e9f4..000000000 --- a/packages/platforms/inventec/x86-64/d6332/onlp/builds/x86_64_inventec_d6332/module/src/x86_64_inventec_d6332_log.h +++ /dev/null @@ -1,12 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#ifndef __x86_64_inventec_d6332_LOG_H__ -#define __x86_64_inventec_d6332_LOG_H__ - -#define AIM_LOG_MODULE_NAME x86_64_inventec_d6332 -#include - -#endif /* __x86_64_inventec_d6332_LOG_H__ */ diff --git a/packages/platforms/inventec/x86-64/d6332/onlp/builds/x86_64_inventec_d6332/module/src/x86_64_inventec_d6332_module.c b/packages/platforms/inventec/x86-64/d6332/onlp/builds/x86_64_inventec_d6332/module/src/x86_64_inventec_d6332_module.c deleted file mode 100644 index 03c74b42b..000000000 --- a/packages/platforms/inventec/x86-64/d6332/onlp/builds/x86_64_inventec_d6332/module/src/x86_64_inventec_d6332_module.c +++ /dev/null @@ -1,25 +0,0 @@ - -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#include - -#include "x86_64_inventec_d6332_log.h" - -static int -datatypes_init__(void) -{ -#define x86_64_inventec_d6332_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_d6332_module_init__(void) -{ - AIM_LOG_STRUCT_REGISTER(); - datatypes_init__(); -} - -int __onlp_platform_version__ = 1; diff --git a/packages/platforms/inventec/x86-64/d6332/onlp/builds/x86_64_inventec_d6332/module/src/x86_64_inventec_d6332_ucli.c b/packages/platforms/inventec/x86-64/d6332/onlp/builds/x86_64_inventec_d6332/module/src/x86_64_inventec_d6332_ucli.c deleted file mode 100644 index ae250204e..000000000 --- a/packages/platforms/inventec/x86-64/d6332/onlp/builds/x86_64_inventec_d6332/module/src/x86_64_inventec_d6332_ucli.c +++ /dev/null @@ -1,50 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#include - -#if x86_64_inventec_d6332_CONFIG_INCLUDE_UCLI == 1 - -#include -#include -#include - -static ucli_status_t -x86_64_inventec_d6332_ucli_ucli__config__(ucli_context_t* uc) -{ - UCLI_HANDLER_MACRO_MODULE_CONFIG(x86_64_inventec_d6332) -} - -/* */ -/* */ - -static ucli_module_t -x86_64_inventec_d6332_ucli_module__ = - { - "x86_64_inventec_d6332_ucli", - NULL, - x86_64_inventec_d6332_ucli_ucli_handlers__, - NULL, - NULL, - }; - -ucli_node_t* -x86_64_inventec_d6332_ucli_node_create(void) -{ - ucli_node_t* n; - ucli_module_init(&x86_64_inventec_d6332_ucli_module__); - n = ucli_node_create("x86_64_inventec_d6332", NULL, &x86_64_inventec_d6332_ucli_module__); - ucli_node_subnode_add(n, ucli_module_log_node_create("x86_64_inventec_d6332")); - return n; -} - -#else -void* -x86_64_inventec_d6332_ucli_node_create(void) -{ - return NULL; -} -#endif - diff --git a/packages/platforms/inventec/x86-64/d6332/platform-config/Makefile b/packages/platforms/inventec/x86-64/d6332/platform-config/Makefile deleted file mode 100644 index 003238cf6..000000000 --- a/packages/platforms/inventec/x86-64/d6332/platform-config/Makefile +++ /dev/null @@ -1 +0,0 @@ -include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/inventec/x86-64/d6332/platform-config/r0/Makefile b/packages/platforms/inventec/x86-64/d6332/platform-config/r0/Makefile deleted file mode 100644 index 003238cf6..000000000 --- a/packages/platforms/inventec/x86-64/d6332/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/inventec/x86-64/d6332/platform-config/r0/PKG.yml b/packages/platforms/inventec/x86-64/d6332/platform-config/r0/PKG.yml deleted file mode 100644 index edc8d1501..000000000 --- a/packages/platforms/inventec/x86-64/d6332/platform-config/r0/PKG.yml +++ /dev/null @@ -1 +0,0 @@ -!include $ONL_TEMPLATES/platform-config-platform.yml ARCH=amd64 VENDOR=inventec BASENAME=x86-64-inventec-d6332 REVISION=r0 diff --git a/packages/platforms/inventec/x86-64/d6332/platform-config/r0/src/lib/x86-64-inventec-d6332-r0.yml b/packages/platforms/inventec/x86-64/d6332/platform-config/r0/src/lib/x86-64-inventec-d6332-r0.yml deleted file mode 100644 index 23d8f3217..000000000 --- a/packages/platforms/inventec/x86-64/d6332/platform-config/r0/src/lib/x86-64-inventec-d6332-r0.yml +++ /dev/null @@ -1,31 +0,0 @@ ---- - -###################################################################### -# -# platform-config for d6332 -# -###################################################################### - -x86-64-inventec-d6332-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/d6332/platform-config/r0/src/python/x86_64_inventec_d6332_r0/__init__.py b/packages/platforms/inventec/x86-64/d6332/platform-config/r0/src/python/x86_64_inventec_d6332_r0/__init__.py deleted file mode 100644 index a3e72a9e3..000000000 --- a/packages/platforms/inventec/x86-64/d6332/platform-config/r0/src/python/x86_64_inventec_d6332_r0/__init__.py +++ /dev/null @@ -1,80 +0,0 @@ -from onl.platform.base import * -from onl.platform.inventec import * -import subprocess -import logging - -class OnlPlatform_x86_64_inventec_d6332_r0(OnlPlatformInventec, - OnlPlatformPortConfig_32x100): - PLATFORM='x86-64-inventec-d6332-r0' - MODEL="D6332" - SYS_OBJECT_ID=".6332.1" - CHASSIS_FAN_NUM=5 - FAN_VPD_CHANNEL=1 - FAN_VPD_ADDR_BASE=0x52 - - _path_prefix_list=[ - "/sys/bus/i2c/devices/2-005a/hwmon/", - "/sys/bus/i2c/devices/2-005b/hwmon/", - "/sys/devices/platform/coretemp.0/hwmon/", - "/sys/bus/i2c/devices/3-0048/hwmon/", - "/sys/bus/i2c/devices/3-004a/hwmon/", - "/sys/bus/i2c/devices/3-004d/hwmon/", - "/sys/bus/i2c/devices/3-004e/hwmon/" - ] - _path_dst_list=[ - "/var/psu1", - "/var/psu2", - "/var/coretemp", - "/var/board_thermal_1", - "/var/board_thermal_2", - "/var/board_thermal_3", - "/var/board_thermal_4", - ] - - def baseconfig(self): - addr_ten_digit=self.FAN_VPD_ADDR_BASE-self.FAN_VPD_ADDR_BASE%10 - cmd=None - result=None - addr=None - line_idx=None - - os.system("rmmod gpio_ich") - self.insmod('i2c-gpio') - os.system("insmod /lib/modules/`uname -r`/kernel/drivers/gpio/gpio-ich.ko gpiobase=0") - self.insmod('ucd9000') - self.insmod('inv_platform') - self.insmod('inv_cpld') - self.insmod('swps') - self.insmod('inv_eeprom') - self.new_i2c_device('inv_eeprom', 0x55, 0) - - for addr_offset in range(0,self.CHASSIS_FAN_NUM): - addr=self.FAN_VPD_ADDR_BASE+addr_offset - cmd = "i2cdetect -y "+str(self.FAN_VPD_CHANNEL)+" "+str(addr)+" "+str(addr)+" | grep "+str(hex(addr)).replace('0x','') - result=os.system(cmd) - if( result==0 ): - self.new_i2c_device('inv_eeprom',addr,self.FAN_VPD_CHANNEL) - - for i in range(0,len(self._path_prefix_list)): - if( os.path.islink(self._path_dst_list[i]) ): - os.unlink(self._path_dst_list[i]) - logging.warning("Path %s exists, remove before link again" % self._path_dst_list[i] ) - self.link_dir(self._path_prefix_list[i],self._path_dst_list[i]) - - return True - - def link_dir(self,prefix,dst): - ret=os.path.isdir(prefix) - if ret==True: - dirs=os.listdir(prefix) - ret=False - for i in range(0,len(dirs)): - if 'hwmon' in dirs[i]: - src=prefix+dirs[i] - os.symlink(src,dst) - ret=True - break - if ret==False: - logging.warning("Can't find proper dir to link under %s" % prefix) - else: - logging.warning("Path %s is not a dir" % prefix) \ No newline at end of file diff --git a/packages/platforms/inventec/x86-64/d6356/Makefile b/packages/platforms/inventec/x86-64/d6356/Makefile deleted file mode 100644 index 003238cf6..000000000 --- a/packages/platforms/inventec/x86-64/d6356/Makefile +++ /dev/null @@ -1 +0,0 @@ -include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/inventec/x86-64/d6356/modules/Makefile b/packages/platforms/inventec/x86-64/d6356/modules/Makefile deleted file mode 100644 index 003238cf6..000000000 --- a/packages/platforms/inventec/x86-64/d6356/modules/Makefile +++ /dev/null @@ -1 +0,0 @@ -include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/inventec/x86-64/d6356/modules/PKG.yml b/packages/platforms/inventec/x86-64/d6356/modules/PKG.yml deleted file mode 100644 index e5f6e80b4..000000000 --- a/packages/platforms/inventec/x86-64/d6356/modules/PKG.yml +++ /dev/null @@ -1 +0,0 @@ -!include $ONL_TEMPLATES/platform-modules.yml VENDOR=inventec BASENAME=x86-64-inventec-d6356 ARCH=amd64 KERNELS="onl-kernel-3.16-lts-x86-64-all:amd64" diff --git a/packages/platforms/inventec/x86-64/d6356/modules/builds/.gitignore b/packages/platforms/inventec/x86-64/d6356/modules/builds/.gitignore deleted file mode 100644 index a65b41774..000000000 --- a/packages/platforms/inventec/x86-64/d6356/modules/builds/.gitignore +++ /dev/null @@ -1 +0,0 @@ -lib diff --git a/packages/platforms/inventec/x86-64/d6356/modules/builds/Makefile b/packages/platforms/inventec/x86-64/d6356/modules/builds/Makefile deleted file mode 100644 index 906c37fef..000000000 --- a/packages/platforms/inventec/x86-64/d6356/modules/builds/Makefile +++ /dev/null @@ -1,6 +0,0 @@ -KERNELS := onl-kernel-3.16-lts-x86-64-all:amd64 -KMODULES := src -VENDOR := inventec -BASENAME := x86-64-inventec-d6356 -ARCH := x86_64 -include $(ONL)/make/kmodule.mk diff --git a/packages/platforms/inventec/x86-64/d6356/modules/builds/src/Makefile b/packages/platforms/inventec/x86-64/d6356/modules/builds/src/Makefile deleted file mode 100644 index 5c0024c61..000000000 --- a/packages/platforms/inventec/x86-64/d6356/modules/builds/src/Makefile +++ /dev/null @@ -1,13 +0,0 @@ -obj-m += gpio-ich.o -obj-m += i2c-gpio.o -obj-m += inv-i2c-mux-pca9641.o -obj-m += lpc_ich.o -obj-m += ucd9000.o - -obj-m += inv_cpld.o -obj-m += inv_platform.o -obj-m += inv_pthread.o -obj-m += swps.o -swps-objs := inv_swps.o io_expander.o inv_mux.o transceiver.o -obj-m += vpd.o -vpd-objs := inv_vpd.o onie_tlvinfo.o diff --git a/packages/platforms/inventec/x86-64/d6356/modules/builds/src/gpio-ich.c b/packages/platforms/inventec/x86-64/d6356/modules/builds/src/gpio-ich.c deleted file mode 100644 index 70304220a..000000000 --- a/packages/platforms/inventec/x86-64/d6356/modules/builds/src/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/d6356/modules/builds/src/i2c-gpio.c b/packages/platforms/inventec/x86-64/d6356/modules/builds/src/i2c-gpio.c deleted file mode 100644 index 71a45b210..000000000 --- a/packages/platforms/inventec/x86-64/d6356/modules/builds/src/i2c-gpio.c +++ /dev/null @@ -1,293 +0,0 @@ -/* - * Bitbanging I2C bus driver using the GPIO API - * - * Copyright (C) 2007 Atmel Corporation - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. - */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -struct i2c_gpio_private_data { - struct i2c_adapter adap; - struct i2c_algo_bit_data bit_data; - struct i2c_gpio_platform_data pdata; -}; - -/* Toggle SDA by changing the direction of the pin */ -static void i2c_gpio_setsda_dir(void *data, int state) -{ - struct i2c_gpio_platform_data *pdata = data; - - if (state) - gpio_direction_input(pdata->sda_pin); - else - gpio_direction_output(pdata->sda_pin, 0); -} - -/* - * Toggle SDA by changing the output value of the pin. This is only - * valid for pins configured as open drain (i.e. setting the value - * high effectively turns off the output driver.) - */ -static void i2c_gpio_setsda_val(void *data, int state) -{ - struct i2c_gpio_platform_data *pdata = data; - - gpio_set_value(pdata->sda_pin, state); -} - -/* Toggle SCL by changing the direction of the pin. */ -static void i2c_gpio_setscl_dir(void *data, int state) -{ - struct i2c_gpio_platform_data *pdata = data; - - if (state) - gpio_direction_input(pdata->scl_pin); - else - gpio_direction_output(pdata->scl_pin, 0); -} - -/* - * Toggle SCL by changing the output value of the pin. This is used - * for pins that are configured as open drain and for output-only - * pins. The latter case will break the i2c protocol, but it will - * often work in practice. - */ -static void i2c_gpio_setscl_val(void *data, int state) -{ - struct i2c_gpio_platform_data *pdata = data; - - gpio_set_value(pdata->scl_pin, state); -} - -static int i2c_gpio_getsda(void *data) -{ - struct i2c_gpio_platform_data *pdata = data; - - return gpio_get_value(pdata->sda_pin); -} - -static int i2c_gpio_getscl(void *data) -{ - struct i2c_gpio_platform_data *pdata = data; - - return gpio_get_value(pdata->scl_pin); -} - -static int of_i2c_gpio_get_pins(struct device_node *np, - unsigned int *sda_pin, unsigned int *scl_pin) -{ - if (of_gpio_count(np) < 2) - return -ENODEV; - - *sda_pin = of_get_gpio(np, 0); - *scl_pin = of_get_gpio(np, 1); - - if (*sda_pin == -EPROBE_DEFER || *scl_pin == -EPROBE_DEFER) - return -EPROBE_DEFER; - - if (!gpio_is_valid(*sda_pin) || !gpio_is_valid(*scl_pin)) { - pr_err("%s: invalid GPIO pins, sda=%d/scl=%d\n", - np->full_name, *sda_pin, *scl_pin); - return -ENODEV; - } - - return 0; -} - -static void of_i2c_gpio_get_props(struct device_node *np, - struct i2c_gpio_platform_data *pdata) -{ - u32 reg; - - of_property_read_u32(np, "i2c-gpio,delay-us", &pdata->udelay); - - if (!of_property_read_u32(np, "i2c-gpio,timeout-ms", ®)) - pdata->timeout = msecs_to_jiffies(reg); - - pdata->sda_is_open_drain = - of_property_read_bool(np, "i2c-gpio,sda-open-drain"); - pdata->scl_is_open_drain = - of_property_read_bool(np, "i2c-gpio,scl-open-drain"); - pdata->scl_is_output_only = - of_property_read_bool(np, "i2c-gpio,scl-output-only"); -} - -static int i2c_gpio_probe(struct platform_device *pdev) -{ - struct i2c_gpio_private_data *priv; - struct i2c_gpio_platform_data *pdata; - struct i2c_algo_bit_data *bit_data; - struct i2c_adapter *adap; - unsigned int sda_pin, scl_pin; - int ret; - - /* First get the GPIO pins; if it fails, we'll defer the probe. */ - if (pdev->dev.of_node) { - ret = of_i2c_gpio_get_pins(pdev->dev.of_node, - &sda_pin, &scl_pin); - if (ret) - return ret; - } else { - if (!dev_get_platdata(&pdev->dev)) - return -ENXIO; - pdata = dev_get_platdata(&pdev->dev); - sda_pin = pdata->sda_pin; - scl_pin = pdata->scl_pin; - } - - ret = devm_gpio_request(&pdev->dev, sda_pin, "sda"); - if (ret) { - if (ret == -EINVAL) - ret = -EPROBE_DEFER; /* Try again later */ - return ret; - } - ret = devm_gpio_request(&pdev->dev, scl_pin, "scl"); - if (ret) { - if (ret == -EINVAL) - ret = -EPROBE_DEFER; /* Try again later */ - return ret; - } - - priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL); - if (!priv) - return -ENOMEM; - adap = &priv->adap; - bit_data = &priv->bit_data; - pdata = &priv->pdata; - - if (pdev->dev.of_node) { - pdata->sda_pin = sda_pin; - pdata->scl_pin = scl_pin; - of_i2c_gpio_get_props(pdev->dev.of_node, pdata); - } else { - memcpy(pdata, dev_get_platdata(&pdev->dev), sizeof(*pdata)); - } - - if (pdata->sda_is_open_drain) { - gpio_direction_output(pdata->sda_pin, 1); - bit_data->setsda = i2c_gpio_setsda_val; - } else { - gpio_direction_input(pdata->sda_pin); - bit_data->setsda = i2c_gpio_setsda_dir; - } - - if (pdata->scl_is_open_drain || pdata->scl_is_output_only) { - gpio_direction_output(pdata->scl_pin, 1); - bit_data->setscl = i2c_gpio_setscl_val; - } else { - gpio_direction_input(pdata->scl_pin); - bit_data->setscl = i2c_gpio_setscl_dir; - } - - if (!pdata->scl_is_output_only) - bit_data->getscl = i2c_gpio_getscl; - bit_data->getsda = i2c_gpio_getsda; - - if (pdata->udelay) - bit_data->udelay = pdata->udelay; - else if (pdata->scl_is_output_only) - bit_data->udelay = 50; /* 10 kHz */ - else - bit_data->udelay = 5; /* 100 kHz */ - - if (pdata->timeout) - bit_data->timeout = pdata->timeout; - else - bit_data->timeout = HZ / 10; /* 100 ms */ - - bit_data->data = pdata; - - adap->owner = THIS_MODULE; - if (pdev->dev.of_node) - strlcpy(adap->name, dev_name(&pdev->dev), sizeof(adap->name)); - else - snprintf(adap->name, sizeof(adap->name), "i2c-gpio%d", pdev->id); - - adap->algo_data = bit_data; - adap->class = I2C_CLASS_HWMON | I2C_CLASS_SPD; - adap->dev.parent = &pdev->dev; - adap->dev.of_node = pdev->dev.of_node; - - adap->nr = pdev->id; - ret = i2c_bit_add_numbered_bus(adap); - if (ret) - return ret; - - platform_set_drvdata(pdev, priv); - - dev_info(&pdev->dev, "using pins %u (SDA) and %u (SCL%s)\n", - pdata->sda_pin, pdata->scl_pin, - pdata->scl_is_output_only - ? ", no clock stretching" : ""); - - return 0; -} - -static int i2c_gpio_remove(struct platform_device *pdev) -{ - struct i2c_gpio_private_data *priv; - struct i2c_gpio_platform_data *pdata; - struct i2c_adapter *adap; - - priv = platform_get_drvdata(pdev); - adap = &priv->adap; - pdata = &priv->pdata; - - i2c_del_adapter(adap); - - return 0; -} - -#if defined(CONFIG_OF) -static const struct of_device_id i2c_gpio_dt_ids[] = { - { .compatible = "i2c-gpio", }, - { /* sentinel */ } -}; - -MODULE_DEVICE_TABLE(of, i2c_gpio_dt_ids); -#endif - -static struct platform_driver i2c_gpio_driver = { - .driver = { - .name = "i2c-gpio", - .owner = THIS_MODULE, - .of_match_table = of_match_ptr(i2c_gpio_dt_ids), - }, - .probe = i2c_gpio_probe, - .remove = i2c_gpio_remove, -}; - -static int __init i2c_gpio_init(void) -{ - int ret; - - ret = platform_driver_register(&i2c_gpio_driver); - if (ret) - printk(KERN_ERR "i2c-gpio: probe failed: %d\n", ret); - - return ret; -} -subsys_initcall(i2c_gpio_init); - -static void __exit i2c_gpio_exit(void) -{ - platform_driver_unregister(&i2c_gpio_driver); -} -module_exit(i2c_gpio_exit); - -MODULE_AUTHOR("Haavard Skinnemoen (Atmel)"); -MODULE_DESCRIPTION("Platform-independent bitbanging I2C driver"); -MODULE_LICENSE("GPL"); -MODULE_ALIAS("platform:i2c-gpio"); diff --git a/packages/platforms/inventec/x86-64/d6356/modules/builds/src/i2c-mux-pca9541.c b/packages/platforms/inventec/x86-64/d6356/modules/builds/src/i2c-mux-pca9541.c deleted file mode 100644 index 4018ef1db..000000000 --- a/packages/platforms/inventec/x86-64/d6356/modules/builds/src/i2c-mux-pca9541.c +++ /dev/null @@ -1,606 +0,0 @@ -/* - * I2C multiplexer driver for PCA9541 bus master selector - * - * Copyright (c) 2010 Ericsson AB. - * - * Author: Guenter Roeck - * - * Derived from: - * pca954x.c - * - * Copyright (c) 2008-2009 Rodolfo Giometti - * Copyright (c) 2008-2009 Eurotech S.p.A. - * - * 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 - -/* - * The PCA9541 is a bus master selector. It supports two I2C masters connected - * to a single slave bus. - * - * Before each bus transaction, a master has to acquire bus ownership. After the - * transaction is complete, bus ownership has to be released. This fits well - * into the I2C multiplexer framework, which provides select and release - * functions for this purpose. For this reason, this driver is modeled as - * single-channel I2C bus multiplexer. - * - * This driver assumes that the two bus masters are controlled by two different - * hosts. If a single host controls both masters, platform code has to ensure - * that only one of the masters is instantiated at any given time. - */ - -#define PCA9541_CONTROL 0x01 -#define PCA9541_ISTAT 0x02 - -#define PCA9541_CTL_MYBUS (1 << 0) -#define PCA9541_CTL_NMYBUS (1 << 1) -#define PCA9541_CTL_BUSON (1 << 2) -#define PCA9541_CTL_NBUSON (1 << 3) -#define PCA9541_CTL_BUSINIT (1 << 4) -#define PCA9541_CTL_TESTON (1 << 6) -#define PCA9541_CTL_NTESTON (1 << 7) - -#define PCA9541_ISTAT_INTIN (1 << 0) -#define PCA9541_ISTAT_BUSINIT (1 << 1) -#define PCA9541_ISTAT_BUSOK (1 << 2) -#define PCA9541_ISTAT_BUSLOST (1 << 3) -#define PCA9541_ISTAT_MYTEST (1 << 6) -#define PCA9541_ISTAT_NMYTEST (1 << 7) - -#define PCA9641_ID 0x00 -#define PCA9641_ID_MAGIC 0x38 - -#define PCA9641_CONTROL 0x01 -#define PCA9641_STATUS 0x02 -#define PCA9641_TIME 0x03 - -#define PCA9641_CTL_LOCK_REQ BIT(0) -#define PCA9641_CTL_LOCK_GRANT BIT(1) -#define PCA9641_CTL_BUS_CONNECT BIT(2) -#define PCA9641_CTL_BUS_INIT BIT(3) -#define PCA9641_CTL_SMBUS_SWRST BIT(4) -#define PCA9641_CTL_IDLE_TIMER_DIS BIT(5) -#define PCA9641_CTL_SMBUS_DIS BIT(6) -#define PCA9641_CTL_PRIORITY BIT(7) - -#define PCA9641_STS_OTHER_LOCK BIT(0) -#define PCA9641_STS_BUS_INIT_FAIL BIT(1) -#define PCA9641_STS_BUS_HUNG BIT(2) -#define PCA9641_STS_MBOX_EMPTY BIT(3) -#define PCA9641_STS_MBOX_FULL BIT(4) -#define PCA9641_STS_TEST_INT BIT(5) -#define PCA9641_STS_SCL_IO BIT(6) -#define PCA9641_STS_SDA_IO BIT(7) - -#define PCA9641_RES_TIME 0x03 - - -#define BUSON (PCA9541_CTL_BUSON | PCA9541_CTL_NBUSON) -#define MYBUS (PCA9541_CTL_MYBUS | PCA9541_CTL_NMYBUS) -#define mybus(x) (!((x) & MYBUS) || ((x) & MYBUS) == MYBUS) -#define busoff(x) (!((x) & BUSON) || ((x) & BUSON) == BUSON) - -#define BUSOFF(x, y) (!((x) & PCA9641_CTL_LOCK_GRANT) && \ - !((y) & PCA9641_STS_OTHER_LOCK)) -#define other_lock(x) ((x) & PCA9641_STS_OTHER_LOCK) -#define lock_grant(x) ((x) & PCA9641_CTL_LOCK_GRANT) - - -/* arbitration timeouts, in jiffies */ -#define ARB_TIMEOUT (HZ / 8) /* 125 ms until forcing bus ownership */ -#define ARB2_TIMEOUT (HZ / 4) /* 250 ms until acquisition failure */ - -/* arbitration retry delays, in us */ -#define SELECT_DELAY_SHORT 50 -#define SELECT_DELAY_LONG 1000 - -struct pca9541 { - struct i2c_adapter *mux_adap; - unsigned long select_timeout; - unsigned long arb_timeout; -}; - -static const struct i2c_device_id pca9541_id[] = { - {"pca9541", 0}, - {"pca9641", 1}, - {} -}; - -MODULE_DEVICE_TABLE(i2c, pca9541_id); - -/* - * Write to chip register. Don't use i2c_transfer()/i2c_smbus_xfer() - * as they will try to lock the adapter a second time. - */ -static int pca9541_reg_write(struct i2c_client *client, u8 command, u8 val) -{ - struct i2c_adapter *adap = client->adapter; - int ret; - - if (adap->algo->master_xfer) { - struct i2c_msg msg; - char buf[2]; - - msg.addr = client->addr; - msg.flags = 0; - msg.len = 2; - buf[0] = command; - buf[1] = val; - msg.buf = buf; - ret = adap->algo->master_xfer(adap, &msg, 1); - } else { - union i2c_smbus_data data; - - data.byte = val; - ret = adap->algo->smbus_xfer(adap, client->addr, - client->flags, - I2C_SMBUS_WRITE, - command, - I2C_SMBUS_BYTE_DATA, &data); - } - - return ret; -} - -/* - * Read from chip register. Don't use i2c_transfer()/i2c_smbus_xfer() - * as they will try to lock adapter a second time. - */ -static int pca9541_reg_read(struct i2c_client *client, u8 command) -{ - struct i2c_adapter *adap = client->adapter; - int ret; - u8 val; - - if (adap->algo->master_xfer) { - struct i2c_msg msg[2] = { - { - .addr = client->addr, - .flags = 0, - .len = 1, - .buf = &command - }, - { - .addr = client->addr, - .flags = I2C_M_RD, - .len = 1, - .buf = &val - } - }; - ret = adap->algo->master_xfer(adap, msg, 2); - if (ret == 2) { - ret = val; - } - else if (ret >= 0) { - ret = -EIO; - } - } else { - union i2c_smbus_data data; - - ret = adap->algo->smbus_xfer(adap, client->addr, - client->flags, - I2C_SMBUS_READ, - command, - I2C_SMBUS_BYTE_DATA, &data); - if (!ret) { - ret = data.byte; - } - } - return ret; -} - -/* - * Arbitration management functions - */ - -/* Release bus. Also reset NTESTON and BUSINIT if it was set. */ -static void pca9541_release_bus(struct i2c_client *client) -{ - int reg; - - reg = pca9541_reg_read(client, PCA9541_CONTROL); - if (reg >= 0 && !busoff(reg) && mybus(reg)) { - pca9541_reg_write(client, PCA9541_CONTROL, - (reg & PCA9541_CTL_NBUSON) >> 1); - } -} - -static void pca9641_release_bus(struct i2c_client *client) -{ - pca9541_reg_write(client, PCA9641_CONTROL, 0); -} - - -/* - * Arbitration is defined as a two-step process. A bus master can only activate - * the slave bus if it owns it; otherwise it has to request ownership first. - * This multi-step process ensures that access contention is resolved - * gracefully. - * - * Bus Ownership Other master Action - * state requested access - * ---------------------------------------------------- - * off - yes wait for arbitration timeout or - * for other master to drop request - * off no no take ownership - * off yes no turn on bus - * on yes - done - * on no - wait for arbitration timeout or - * for other master to release bus - * - * The main contention point occurs if the slave bus is off and both masters - * request ownership at the same time. In this case, one master will turn on - * the slave bus, believing that it owns it. The other master will request - * bus ownership. Result is that the bus is turned on, and master which did - * _not_ own the slave bus before ends up owning it. - */ - -/* Control commands per PCA9541 datasheet */ -static const u8 pca9541_control[16] = { - 4, 0, 1, 5, 4, 4, 5, 5, 0, 0, 1, 1, 0, 4, 5, 1 -}; - -/* - * Channel arbitration - * - * Return values: - * <0: error - * 0 : bus not acquired - * 1 : bus acquired - */ -static int pca9541_arbitrate(struct i2c_client *client) -{ - struct pca9541 *data = i2c_get_clientdata(client); - int reg; - - reg = pca9541_reg_read(client, PCA9541_CONTROL); - if (reg < 0) { - return reg; - } - - if (busoff(reg)) { - int istat; - /* - * Bus is off. Request ownership or turn it on unless - * other master requested ownership. - */ - istat = pca9541_reg_read(client, PCA9541_ISTAT); - if (!(istat & PCA9541_ISTAT_NMYTEST) - || time_is_before_eq_jiffies(data->arb_timeout)) { - /* - * Other master did not request ownership, - * or arbitration timeout expired. Take the bus. - */ - pca9541_reg_write(client, - PCA9541_CONTROL, - pca9541_control[reg & 0x0f] - | PCA9541_CTL_NTESTON); - data->select_timeout = SELECT_DELAY_SHORT; - } else { - /* - * Other master requested ownership. - * Set extra long timeout to give it time to acquire it. - */ - data->select_timeout = SELECT_DELAY_LONG * 2; - } - } else if (mybus(reg)) { - /* - * Bus is on, and we own it. We are done with acquisition. - * Reset NTESTON and BUSINIT, then return success. - */ - if (reg & (PCA9541_CTL_NTESTON | PCA9541_CTL_BUSINIT)) { - pca9541_reg_write(client, - PCA9541_CONTROL, - reg & ~(PCA9541_CTL_NTESTON - | PCA9541_CTL_BUSINIT)); - } - return 1; - } else { - /* - * Other master owns the bus. - * If arbitration timeout has expired, force ownership. - * Otherwise request it. - */ - data->select_timeout = SELECT_DELAY_LONG; - if (time_is_before_eq_jiffies(data->arb_timeout)) { - /* Time is up, take the bus and reset it. */ - pca9541_reg_write(client, - PCA9541_CONTROL, - pca9541_control[reg & 0x0f] - | PCA9541_CTL_BUSINIT - | PCA9541_CTL_NTESTON); - } else { - /* Request bus ownership if needed */ - if (!(reg & PCA9541_CTL_NTESTON)) { - pca9541_reg_write(client, - PCA9541_CONTROL, - reg | PCA9541_CTL_NTESTON); - } - } - } - return 0; -} - -static int pca9541_select_chan(struct i2c_adapter *adap, void *client, u32 chan) -{ - struct pca9541 *data = i2c_get_clientdata(client); - int ret; - unsigned long timeout = jiffies + ARB2_TIMEOUT; - /* give up after this time */ - - data->arb_timeout = jiffies + ARB_TIMEOUT; - /* force bus ownership after this time */ - - do { - ret = pca9541_arbitrate(client); - if (ret) { - return ret < 0 ? ret : 0; - } - - if (data->select_timeout == SELECT_DELAY_SHORT) { - udelay(data->select_timeout); - } - else { - msleep(data->select_timeout / 1000); - } - } while (time_is_after_eq_jiffies(timeout)); - - return -ETIMEDOUT; -} - -static int pca9541_release_chan(struct i2c_adapter *adap, - void *client, u32 chan) -{ - pca9541_release_bus(client); - return 0; -} - -static int pca9641_arbitrate(struct i2c_client *client) -{ - struct pca9541 *data = i2c_get_clientdata(client); - int reg_ctl, reg_sts; - - reg_ctl = pca9541_reg_read(client, PCA9641_CONTROL); - if (reg_ctl < 0) { - return reg_ctl; - } - reg_sts = pca9541_reg_read(client, PCA9641_STATUS); - - if (reg_sts < 0) { - return reg_sts; - } - if (reg_sts & PCA9641_STS_BUS_HUNG) { - reg_ctl |= PCA9641_CTL_BUS_INIT; - } - - if (BUSOFF(reg_ctl, reg_sts)) { - /* - * Bus is off. Request ownership or turn it on unless - * other master requested ownership. - */ - reg_ctl |= PCA9641_CTL_LOCK_REQ; - pca9541_reg_write(client, PCA9641_CONTROL, reg_ctl); - reg_ctl = pca9541_reg_read(client, PCA9641_CONTROL); - - if (lock_grant(reg_ctl)) { - /* - * Other master did not request ownership, - * or arbitration timeout expired. Take the bus. - */ - reg_ctl |= PCA9641_CTL_BUS_CONNECT - | PCA9641_CTL_LOCK_REQ; - pca9541_reg_write(client, PCA9641_CONTROL, reg_ctl); - if (reg_sts & PCA9641_STS_BUS_HUNG) { - reg_sts = pca9541_reg_read(client, PCA9641_STATUS); - if(reg_sts < 0 || reg_sts & (PCA9641_STS_BUS_INIT_FAIL | PCA9641_STS_BUS_HUNG)) { - return -1; - } - } - - data->select_timeout = SELECT_DELAY_SHORT; - - return 1; - } else { - /* - * Other master requested ownership. - * Set extra long timeout to give it time to acquire it. - */ - if (reg_sts & PCA9641_STS_BUS_HUNG) { - reg_sts = pca9541_reg_read(client, PCA9641_STATUS); - if(reg_sts < 0 || reg_sts & (PCA9641_STS_BUS_INIT_FAIL | PCA9641_STS_BUS_HUNG)) { - return -1; - } - } - data->select_timeout = SELECT_DELAY_LONG * 2; - } - } else if (lock_grant(reg_ctl)) { - /* - * Bus is on, and we own it. We are done with acquisition. - */ - reg_ctl |= PCA9641_CTL_BUS_CONNECT | PCA9641_CTL_LOCK_REQ; - pca9541_reg_write(client, PCA9641_CONTROL, reg_ctl); - - if (reg_sts & PCA9641_STS_BUS_HUNG) { - reg_sts = pca9541_reg_read(client, PCA9641_STATUS); - if(reg_sts < 0 || reg_sts & (PCA9641_STS_BUS_INIT_FAIL | PCA9641_STS_BUS_HUNG)) { - return -1; - } - } - return 1; - } else if (other_lock(reg_sts)) { - /* - * Other master owns the bus. - * If arbitration timeout has expired, force ownership. - * Otherwise request it. - */ - if (reg_sts & PCA9641_STS_BUS_HUNG) { - return -1; - } - data->select_timeout = SELECT_DELAY_LONG; - reg_ctl |= PCA9641_CTL_LOCK_REQ; - pca9541_reg_write(client, PCA9641_CONTROL, reg_ctl); - } - return 0; -} - -static int pca9641_select_chan(struct i2c_adapter *adap, void *client, u32 chan) -{ - struct pca9541 *data = i2c_get_clientdata(client); - int ret; - unsigned long timeout = jiffies + ARB2_TIMEOUT; - /* give up after this time */ - - data->arb_timeout = jiffies + ARB_TIMEOUT; - /* force bus ownership after this time */ - - do { - ret = pca9641_arbitrate(client); - if (ret) { - return ret < 0 ? ret : 0; - } - - if (data->select_timeout == SELECT_DELAY_SHORT) { - udelay(data->select_timeout); - } - else { - msleep(data->select_timeout / 1000); - } - } while (time_is_after_eq_jiffies(timeout)); - - return -ETIMEDOUT; -} - -static int pca9641_release_chan(struct i2c_adapter *adap, - void *client, u32 chan) -{ - pca9641_release_bus(client); - return 0; -} - -static int pca9641_detect_id(struct i2c_client *client) -{ - int reg; - - reg = pca9541_reg_read(client, PCA9641_ID); - if (reg == PCA9641_ID_MAGIC) { - return 1; - } - else { - return 0; - } -} - - -/* - * I2C init/probing/exit functions - */ -static int pca9541_probe(struct i2c_client *client, - const struct i2c_device_id *id) -{ - struct i2c_adapter *adap = client->adapter; - struct pca954x_platform_data *pdata = dev_get_platdata(&client->dev); - struct pca9541 *data; - int force; - int ret = -ENODEV; - int detect_id; - - if (!i2c_check_functionality(adap, I2C_FUNC_SMBUS_BYTE_DATA)) { - goto err; - } - - data = kzalloc(sizeof(struct pca9541), GFP_KERNEL); - if (!data) { - ret = -ENOMEM; - goto err; - } - - i2c_set_clientdata(client, data); - - detect_id = pca9641_detect_id(client); - - /* - * I2C accesses are unprotected here. - * We have to lock the adapter before releasing the bus. - */ - if (detect_id == 0) { - i2c_lock_adapter(adap); - pca9541_release_bus(client); - i2c_unlock_adapter(adap); - } else { - i2c_lock_adapter(adap); - pca9641_release_bus(client); - i2c_unlock_adapter(adap); - } - - /* Create mux adapter */ - - force = 0; - if (pdata) { - force = pdata->modes[0].adap_id; - } - - if (detect_id == 0) { - data->mux_adap = i2c_add_mux_adapter(adap, &client->dev, client, - force, 0, 0, - pca9541_select_chan, - pca9541_release_chan); - } else { - data->mux_adap = i2c_add_mux_adapter(adap, &client->dev, client, - force, 0, 0, - pca9641_select_chan, - pca9641_release_chan); - } - - if (data->mux_adap == NULL) { - dev_err(&client->dev, "failed to register master selector\n"); - goto exit_free; - } - - dev_info(&client->dev, "registered master selector for I2C %s\n", - client->name); - - return 0; - -exit_free: - kfree(data); -err: - return ret; -} - -static int pca9541_remove(struct i2c_client *client) -{ - struct pca9541 *data = i2c_get_clientdata(client); - - i2c_del_mux_adapter(data->mux_adap); - - kfree(data); - return 0; -} - -static struct i2c_driver pca9541_driver = { - .driver = { - .name = "pca9541", - .owner = THIS_MODULE, - }, - .probe = pca9541_probe, - .remove = pca9541_remove, - .id_table = pca9541_id, -}; - -module_i2c_driver(pca9541_driver); - -MODULE_AUTHOR("Guenter Roeck "); -MODULE_DESCRIPTION("PCA9541 I2C master selector driver"); -MODULE_LICENSE("GPL v2"); diff --git a/packages/platforms/inventec/x86-64/d6356/modules/builds/src/i2c-mux-pca9641.c b/packages/platforms/inventec/x86-64/d6356/modules/builds/src/i2c-mux-pca9641.c deleted file mode 100644 index 701069fd3..000000000 --- a/packages/platforms/inventec/x86-64/d6356/modules/builds/src/i2c-mux-pca9641.c +++ /dev/null @@ -1,449 +0,0 @@ -/* - * I2C multiplexer driver for PCA9641 bus master selector - * - * Copyright (c) 2010 Ericsson AB. - * - * Author: Guenter Roeck - * - * Derived from: - * pca954x.c - * - * Copyright (c) 2008-2009 Rodolfo Giometti - * Copyright (c) 2008-2009 Eurotech S.p.A. - * - * 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 - -/* - * The PCA9641 is a bus master selector. It supports two I2C masters connected - * to a single slave bus. - * - * Before each bus transaction, a master has to acquire bus ownership. After the - * transaction is complete, bus ownership has to be released. This fits well - * into the I2C multiplexer framework, which provides select and release - * functions for this purpose. For this reason, this driver is modeled as - * single-channel I2C bus multiplexer. - * - * This driver assumes that the two bus masters are controlled by two different - * hosts. If a single host controls both masters, platform code has to ensure - * that only one of the masters is instantiated at any given time. - */ - -#define PCA9641_ID 0x00 -#define PCA9641_ID_MAGIC 0x38 - -#define PCA9641_CONTROL 0x01 -#define PCA9641_STATUS 0x02 -#define PCA9641_TIME 0x03 - -#define PCA9641_CTL_LOCK_REQ BIT(0) -#define PCA9641_CTL_LOCK_GRANT BIT(1) -#define PCA9641_CTL_BUS_CONNECT BIT(2) -#define PCA9641_CTL_BUS_INIT BIT(3) -#define PCA9641_CTL_SMBUS_SWRST BIT(4) -#define PCA9641_CTL_IDLE_TIMER_DIS BIT(5) -#define PCA9641_CTL_SMBUS_DIS BIT(6) -#define PCA9641_CTL_PRIORITY BIT(7) - -#define PCA9641_STS_OTHER_LOCK BIT(0) -#define PCA9641_STS_BUS_INIT_FAIL BIT(1) -#define PCA9641_STS_BUS_HUNG BIT(2) -#define PCA9641_STS_MBOX_EMPTY BIT(3) -#define PCA9641_STS_MBOX_FULL BIT(4) -#define PCA9641_STS_TEST_INT BIT(5) -#define PCA9641_STS_SCL_IO BIT(6) -#define PCA9641_STS_SDA_IO BIT(7) - -#define PCA9641_RES_TIME 0x03 - -#define BUSOFF(x, y) (!((x) & PCA9641_CTL_LOCK_GRANT) && \ - !((y) & PCA9641_STS_OTHER_LOCK)) -#define other_lock(x) ((x) & PCA9641_STS_OTHER_LOCK) -#define lock_grant(x) ((x) & PCA9641_CTL_LOCK_GRANT) - - -/* arbitration timeouts, in jiffies */ -#define ARB_TIMEOUT (HZ / 8) /* 125 ms until forcing bus ownership */ -#define ARB2_TIMEOUT (HZ / 4) /* 250 ms until acquisition failure */ - -/* arbitration retry delays, in us */ -#define SELECT_DELAY_SHORT 50 -#define SELECT_DELAY_LONG 1000 - -struct pca9641 { - struct i2c_adapter *mux_adap; - unsigned long select_timeout; - unsigned long arb_timeout; -}; - -static const struct i2c_device_id pca9641_id[] = { - {"pca9641", 1}, - {} -}; - -MODULE_DEVICE_TABLE(i2c, pca9641_id); - -/* - * Write to chip register. Don't use i2c_transfer()/i2c_smbus_xfer() - * as they will try to lock the adapter a second time. - */ -static int pca9641_reg_write(struct i2c_client *client, u8 command, u8 val) -{ - struct i2c_adapter *adap = client->adapter; - int ret; - - if (adap->algo->master_xfer) { - struct i2c_msg msg; - char buf[2]; - - msg.addr = client->addr; - msg.flags = 0; - msg.len = 2; - buf[0] = command; - buf[1] = val; - msg.buf = buf; - ret = adap->algo->master_xfer(adap, &msg, 1); - } else { - union i2c_smbus_data data; - - data.byte = val; - ret = adap->algo->smbus_xfer(adap, client->addr, - client->flags, - I2C_SMBUS_WRITE, - command, - I2C_SMBUS_BYTE_DATA, &data); - } - - return ret; -} - -/* - * Read from chip register. Don't use i2c_transfer()/i2c_smbus_xfer() - * as they will try to lock adapter a second time. - */ -static int pca9641_reg_read(struct i2c_client *client, u8 command) -{ - struct i2c_adapter *adap = client->adapter; - int ret; - u8 val; - - if (adap->algo->master_xfer) { - struct i2c_msg msg[2] = { - { - .addr = client->addr, - .flags = 0, - .len = 1, - .buf = &command - }, - { - .addr = client->addr, - .flags = I2C_M_RD, - .len = 1, - .buf = &val - } - }; - ret = adap->algo->master_xfer(adap, msg, 2); - if (ret == 2) { - ret = val; - } - else if (ret >= 0) { - ret = -EIO; - } - } else { - union i2c_smbus_data data; - - ret = adap->algo->smbus_xfer(adap, client->addr, - client->flags, - I2C_SMBUS_READ, - command, - I2C_SMBUS_BYTE_DATA, &data); - if (!ret) { - ret = data.byte; - } - } - return ret; -} - -/* - * Arbitration management functions - */ - -/* Release bus. Also reset NTESTON and BUSINIT if it was set. */ -static void pca9641_release_bus(struct i2c_client *client) -{ - pca9641_reg_write(client, PCA9641_CONTROL, 0); -} - - -/* - * Arbitration is defined as a two-step process. A bus master can only activate - * the slave bus if it owns it; otherwise it has to request ownership first. - * This multi-step process ensures that access contention is resolved - * gracefully. - * - * Bus Ownership Other master Action - * state requested access - * ---------------------------------------------------- - * off - yes wait for arbitration timeout or - * for other master to drop request - * off no no take ownership - * off yes no turn on bus - * on yes - done - * on no - wait for arbitration timeout or - * for other master to release bus - * - * The main contention point occurs if the slave bus is off and both masters - * request ownership at the same time. In this case, one master will turn on - * the slave bus, believing that it owns it. The other master will request - * bus ownership. Result is that the bus is turned on, and master which did - * _not_ own the slave bus before ends up owning it. - */ - -/* - * Channel arbitration - * - * Return values: - * <0: error - * 0 : bus not acquired - * 1 : bus acquired - */ -static int pca9641_arbitrate(struct i2c_client *client) -{ - struct pca9641 *data = i2c_get_clientdata(client); - int reg_ctl, reg_sts; - - reg_ctl = pca9641_reg_read(client, PCA9641_CONTROL); - if (reg_ctl < 0) { - return reg_ctl; - } - reg_sts = pca9641_reg_read(client, PCA9641_STATUS); - - if (reg_sts < 0) { - return reg_sts; - } - if (reg_sts & PCA9641_STS_BUS_HUNG) { - reg_ctl |= PCA9641_CTL_BUS_INIT; - } - - if (BUSOFF(reg_ctl, reg_sts)) { - /* - * Bus is off. Request ownership or turn it on unless - * other master requested ownership. - */ - reg_ctl |= PCA9641_CTL_LOCK_REQ; - pca9641_reg_write(client, PCA9641_CONTROL, reg_ctl); - reg_ctl = pca9641_reg_read(client, PCA9641_CONTROL); - - if (lock_grant(reg_ctl)) { - /* - * Other master did not request ownership, - * or arbitration timeout expired. Take the bus. - */ - reg_ctl |= PCA9641_CTL_BUS_CONNECT - | PCA9641_CTL_LOCK_REQ; - pca9641_reg_write(client, PCA9641_CONTROL, reg_ctl); - if (reg_sts & PCA9641_STS_BUS_HUNG) { - reg_sts = pca9641_reg_read(client, PCA9641_STATUS); - if(reg_sts < 0 || reg_sts & (PCA9641_STS_BUS_INIT_FAIL | PCA9641_STS_BUS_HUNG)) { - return -1; - } - } - - data->select_timeout = SELECT_DELAY_SHORT; - - return 1; - } else { - /* - * Other master requested ownership. - * Set extra long timeout to give it time to acquire it. - */ - if (reg_sts & PCA9641_STS_BUS_HUNG) { - reg_sts = pca9641_reg_read(client, PCA9641_STATUS); - if(reg_sts < 0 || reg_sts & (PCA9641_STS_BUS_INIT_FAIL | PCA9641_STS_BUS_HUNG)) { - return -1; - } - } - data->select_timeout = SELECT_DELAY_LONG * 2; - } - } else if (lock_grant(reg_ctl)) { - /* - * Bus is on, and we own it. We are done with acquisition. - */ - reg_ctl |= PCA9641_CTL_BUS_CONNECT | PCA9641_CTL_LOCK_REQ; - pca9641_reg_write(client, PCA9641_CONTROL, reg_ctl); - - if (reg_sts & PCA9641_STS_BUS_HUNG) { - reg_sts = pca9641_reg_read(client, PCA9641_STATUS); - if(reg_sts < 0 || reg_sts & (PCA9641_STS_BUS_INIT_FAIL | PCA9641_STS_BUS_HUNG)) { - return -1; - } - } - return 1; - } else if (other_lock(reg_sts)) { - /* - * Other master owns the bus. - * If arbitration timeout has expired, force ownership. - * Otherwise request it. - */ - if (reg_sts & PCA9641_STS_BUS_HUNG) { - return -1; - } - data->select_timeout = SELECT_DELAY_LONG; - reg_ctl |= PCA9641_CTL_LOCK_REQ; - pca9641_reg_write(client, PCA9641_CONTROL, reg_ctl); - } - return 0; -} - -static int pca9641_select_chan(struct i2c_adapter *adap, void *client, u32 chan) -{ - struct pca9641 *data = i2c_get_clientdata(client); - int ret; - unsigned long timeout = jiffies + ARB2_TIMEOUT; - /* give up after this time */ - - data->arb_timeout = jiffies + ARB_TIMEOUT; - /* force bus ownership after this time */ - - do { - ret = pca9641_arbitrate(client); - if (ret) { - return ret < 0 ? ret : 0; - } - - if (data->select_timeout == SELECT_DELAY_SHORT) { - udelay(data->select_timeout); - } - else { - msleep(data->select_timeout / 1000); - } - } while (time_is_after_eq_jiffies(timeout)); - - return -ETIMEDOUT; -} - -static int pca9641_release_chan(struct i2c_adapter *adap, - void *client, u32 chan) -{ - pca9641_release_bus(client); - return 0; -} - -static int pca9641_detect_id(struct i2c_client *client) -{ - int reg; - - reg = pca9641_reg_read(client, PCA9641_ID); - if (reg == PCA9641_ID_MAGIC) { - return 1; - } - else { - return 0; - } -} - - -/* - * I2C init/probing/exit functions - */ -static int pca9641_probe(struct i2c_client *client, - const struct i2c_device_id *id) -{ - struct i2c_adapter *adap = client->adapter; - struct pca954x_platform_data *pdata = dev_get_platdata(&client->dev); - struct pca9641 *data; - int force; - int ret = -ENODEV; - int detect_id; - - if (!i2c_check_functionality(adap, I2C_FUNC_SMBUS_BYTE_DATA)) { - goto err; - } - - data = kzalloc(sizeof(struct pca9641), GFP_KERNEL); - if (!data) { - ret = -ENOMEM; - goto err; - } - - i2c_set_clientdata(client, data); - - detect_id = pca9641_detect_id(client); - - /* - * I2C accesses are unprotected here. - * We have to lock the adapter before releasing the bus. - */ - if (detect_id == 1) { - i2c_lock_adapter(adap); - pca9641_release_bus(client); - i2c_unlock_adapter(adap); - } - - /* Create mux adapter */ - - force = 0; - if (pdata) { - force = pdata->modes[0].adap_id; - } - - if (detect_id == 1) { - data->mux_adap = i2c_add_mux_adapter(adap, &client->dev, client, - force, 0, 0, - pca9641_select_chan, - pca9641_release_chan); - } - - if (data->mux_adap == NULL) { - dev_err(&client->dev, "failed to register master selector\n"); - goto exit_free; - } - - dev_info(&client->dev, "registered master selector for I2C %s\n", - client->name); - - return 0; - -exit_free: - kfree(data); -err: - return ret; -} - -static int pca9641_remove(struct i2c_client *client) -{ - struct pca9641 *data = i2c_get_clientdata(client); - - i2c_del_mux_adapter(data->mux_adap); - - kfree(data); - return 0; -} - -static struct i2c_driver pca9641_driver = { - .driver = { - .name = "pca9641", - .owner = THIS_MODULE, - }, - .probe = pca9641_probe, - .remove = pca9641_remove, - .id_table = pca9641_id, -}; - -module_i2c_driver(pca9641_driver); - -MODULE_AUTHOR("Guenter Roeck "); -MODULE_DESCRIPTION("PCA9641 I2C master selector driver"); -MODULE_LICENSE("GPL v2"); diff --git a/packages/platforms/inventec/x86-64/d6356/modules/builds/src/inv-i2c-mux-pca9641.c b/packages/platforms/inventec/x86-64/d6356/modules/builds/src/inv-i2c-mux-pca9641.c deleted file mode 100644 index 701069fd3..000000000 --- a/packages/platforms/inventec/x86-64/d6356/modules/builds/src/inv-i2c-mux-pca9641.c +++ /dev/null @@ -1,449 +0,0 @@ -/* - * I2C multiplexer driver for PCA9641 bus master selector - * - * Copyright (c) 2010 Ericsson AB. - * - * Author: Guenter Roeck - * - * Derived from: - * pca954x.c - * - * Copyright (c) 2008-2009 Rodolfo Giometti - * Copyright (c) 2008-2009 Eurotech S.p.A. - * - * 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 - -/* - * The PCA9641 is a bus master selector. It supports two I2C masters connected - * to a single slave bus. - * - * Before each bus transaction, a master has to acquire bus ownership. After the - * transaction is complete, bus ownership has to be released. This fits well - * into the I2C multiplexer framework, which provides select and release - * functions for this purpose. For this reason, this driver is modeled as - * single-channel I2C bus multiplexer. - * - * This driver assumes that the two bus masters are controlled by two different - * hosts. If a single host controls both masters, platform code has to ensure - * that only one of the masters is instantiated at any given time. - */ - -#define PCA9641_ID 0x00 -#define PCA9641_ID_MAGIC 0x38 - -#define PCA9641_CONTROL 0x01 -#define PCA9641_STATUS 0x02 -#define PCA9641_TIME 0x03 - -#define PCA9641_CTL_LOCK_REQ BIT(0) -#define PCA9641_CTL_LOCK_GRANT BIT(1) -#define PCA9641_CTL_BUS_CONNECT BIT(2) -#define PCA9641_CTL_BUS_INIT BIT(3) -#define PCA9641_CTL_SMBUS_SWRST BIT(4) -#define PCA9641_CTL_IDLE_TIMER_DIS BIT(5) -#define PCA9641_CTL_SMBUS_DIS BIT(6) -#define PCA9641_CTL_PRIORITY BIT(7) - -#define PCA9641_STS_OTHER_LOCK BIT(0) -#define PCA9641_STS_BUS_INIT_FAIL BIT(1) -#define PCA9641_STS_BUS_HUNG BIT(2) -#define PCA9641_STS_MBOX_EMPTY BIT(3) -#define PCA9641_STS_MBOX_FULL BIT(4) -#define PCA9641_STS_TEST_INT BIT(5) -#define PCA9641_STS_SCL_IO BIT(6) -#define PCA9641_STS_SDA_IO BIT(7) - -#define PCA9641_RES_TIME 0x03 - -#define BUSOFF(x, y) (!((x) & PCA9641_CTL_LOCK_GRANT) && \ - !((y) & PCA9641_STS_OTHER_LOCK)) -#define other_lock(x) ((x) & PCA9641_STS_OTHER_LOCK) -#define lock_grant(x) ((x) & PCA9641_CTL_LOCK_GRANT) - - -/* arbitration timeouts, in jiffies */ -#define ARB_TIMEOUT (HZ / 8) /* 125 ms until forcing bus ownership */ -#define ARB2_TIMEOUT (HZ / 4) /* 250 ms until acquisition failure */ - -/* arbitration retry delays, in us */ -#define SELECT_DELAY_SHORT 50 -#define SELECT_DELAY_LONG 1000 - -struct pca9641 { - struct i2c_adapter *mux_adap; - unsigned long select_timeout; - unsigned long arb_timeout; -}; - -static const struct i2c_device_id pca9641_id[] = { - {"pca9641", 1}, - {} -}; - -MODULE_DEVICE_TABLE(i2c, pca9641_id); - -/* - * Write to chip register. Don't use i2c_transfer()/i2c_smbus_xfer() - * as they will try to lock the adapter a second time. - */ -static int pca9641_reg_write(struct i2c_client *client, u8 command, u8 val) -{ - struct i2c_adapter *adap = client->adapter; - int ret; - - if (adap->algo->master_xfer) { - struct i2c_msg msg; - char buf[2]; - - msg.addr = client->addr; - msg.flags = 0; - msg.len = 2; - buf[0] = command; - buf[1] = val; - msg.buf = buf; - ret = adap->algo->master_xfer(adap, &msg, 1); - } else { - union i2c_smbus_data data; - - data.byte = val; - ret = adap->algo->smbus_xfer(adap, client->addr, - client->flags, - I2C_SMBUS_WRITE, - command, - I2C_SMBUS_BYTE_DATA, &data); - } - - return ret; -} - -/* - * Read from chip register. Don't use i2c_transfer()/i2c_smbus_xfer() - * as they will try to lock adapter a second time. - */ -static int pca9641_reg_read(struct i2c_client *client, u8 command) -{ - struct i2c_adapter *adap = client->adapter; - int ret; - u8 val; - - if (adap->algo->master_xfer) { - struct i2c_msg msg[2] = { - { - .addr = client->addr, - .flags = 0, - .len = 1, - .buf = &command - }, - { - .addr = client->addr, - .flags = I2C_M_RD, - .len = 1, - .buf = &val - } - }; - ret = adap->algo->master_xfer(adap, msg, 2); - if (ret == 2) { - ret = val; - } - else if (ret >= 0) { - ret = -EIO; - } - } else { - union i2c_smbus_data data; - - ret = adap->algo->smbus_xfer(adap, client->addr, - client->flags, - I2C_SMBUS_READ, - command, - I2C_SMBUS_BYTE_DATA, &data); - if (!ret) { - ret = data.byte; - } - } - return ret; -} - -/* - * Arbitration management functions - */ - -/* Release bus. Also reset NTESTON and BUSINIT if it was set. */ -static void pca9641_release_bus(struct i2c_client *client) -{ - pca9641_reg_write(client, PCA9641_CONTROL, 0); -} - - -/* - * Arbitration is defined as a two-step process. A bus master can only activate - * the slave bus if it owns it; otherwise it has to request ownership first. - * This multi-step process ensures that access contention is resolved - * gracefully. - * - * Bus Ownership Other master Action - * state requested access - * ---------------------------------------------------- - * off - yes wait for arbitration timeout or - * for other master to drop request - * off no no take ownership - * off yes no turn on bus - * on yes - done - * on no - wait for arbitration timeout or - * for other master to release bus - * - * The main contention point occurs if the slave bus is off and both masters - * request ownership at the same time. In this case, one master will turn on - * the slave bus, believing that it owns it. The other master will request - * bus ownership. Result is that the bus is turned on, and master which did - * _not_ own the slave bus before ends up owning it. - */ - -/* - * Channel arbitration - * - * Return values: - * <0: error - * 0 : bus not acquired - * 1 : bus acquired - */ -static int pca9641_arbitrate(struct i2c_client *client) -{ - struct pca9641 *data = i2c_get_clientdata(client); - int reg_ctl, reg_sts; - - reg_ctl = pca9641_reg_read(client, PCA9641_CONTROL); - if (reg_ctl < 0) { - return reg_ctl; - } - reg_sts = pca9641_reg_read(client, PCA9641_STATUS); - - if (reg_sts < 0) { - return reg_sts; - } - if (reg_sts & PCA9641_STS_BUS_HUNG) { - reg_ctl |= PCA9641_CTL_BUS_INIT; - } - - if (BUSOFF(reg_ctl, reg_sts)) { - /* - * Bus is off. Request ownership or turn it on unless - * other master requested ownership. - */ - reg_ctl |= PCA9641_CTL_LOCK_REQ; - pca9641_reg_write(client, PCA9641_CONTROL, reg_ctl); - reg_ctl = pca9641_reg_read(client, PCA9641_CONTROL); - - if (lock_grant(reg_ctl)) { - /* - * Other master did not request ownership, - * or arbitration timeout expired. Take the bus. - */ - reg_ctl |= PCA9641_CTL_BUS_CONNECT - | PCA9641_CTL_LOCK_REQ; - pca9641_reg_write(client, PCA9641_CONTROL, reg_ctl); - if (reg_sts & PCA9641_STS_BUS_HUNG) { - reg_sts = pca9641_reg_read(client, PCA9641_STATUS); - if(reg_sts < 0 || reg_sts & (PCA9641_STS_BUS_INIT_FAIL | PCA9641_STS_BUS_HUNG)) { - return -1; - } - } - - data->select_timeout = SELECT_DELAY_SHORT; - - return 1; - } else { - /* - * Other master requested ownership. - * Set extra long timeout to give it time to acquire it. - */ - if (reg_sts & PCA9641_STS_BUS_HUNG) { - reg_sts = pca9641_reg_read(client, PCA9641_STATUS); - if(reg_sts < 0 || reg_sts & (PCA9641_STS_BUS_INIT_FAIL | PCA9641_STS_BUS_HUNG)) { - return -1; - } - } - data->select_timeout = SELECT_DELAY_LONG * 2; - } - } else if (lock_grant(reg_ctl)) { - /* - * Bus is on, and we own it. We are done with acquisition. - */ - reg_ctl |= PCA9641_CTL_BUS_CONNECT | PCA9641_CTL_LOCK_REQ; - pca9641_reg_write(client, PCA9641_CONTROL, reg_ctl); - - if (reg_sts & PCA9641_STS_BUS_HUNG) { - reg_sts = pca9641_reg_read(client, PCA9641_STATUS); - if(reg_sts < 0 || reg_sts & (PCA9641_STS_BUS_INIT_FAIL | PCA9641_STS_BUS_HUNG)) { - return -1; - } - } - return 1; - } else if (other_lock(reg_sts)) { - /* - * Other master owns the bus. - * If arbitration timeout has expired, force ownership. - * Otherwise request it. - */ - if (reg_sts & PCA9641_STS_BUS_HUNG) { - return -1; - } - data->select_timeout = SELECT_DELAY_LONG; - reg_ctl |= PCA9641_CTL_LOCK_REQ; - pca9641_reg_write(client, PCA9641_CONTROL, reg_ctl); - } - return 0; -} - -static int pca9641_select_chan(struct i2c_adapter *adap, void *client, u32 chan) -{ - struct pca9641 *data = i2c_get_clientdata(client); - int ret; - unsigned long timeout = jiffies + ARB2_TIMEOUT; - /* give up after this time */ - - data->arb_timeout = jiffies + ARB_TIMEOUT; - /* force bus ownership after this time */ - - do { - ret = pca9641_arbitrate(client); - if (ret) { - return ret < 0 ? ret : 0; - } - - if (data->select_timeout == SELECT_DELAY_SHORT) { - udelay(data->select_timeout); - } - else { - msleep(data->select_timeout / 1000); - } - } while (time_is_after_eq_jiffies(timeout)); - - return -ETIMEDOUT; -} - -static int pca9641_release_chan(struct i2c_adapter *adap, - void *client, u32 chan) -{ - pca9641_release_bus(client); - return 0; -} - -static int pca9641_detect_id(struct i2c_client *client) -{ - int reg; - - reg = pca9641_reg_read(client, PCA9641_ID); - if (reg == PCA9641_ID_MAGIC) { - return 1; - } - else { - return 0; - } -} - - -/* - * I2C init/probing/exit functions - */ -static int pca9641_probe(struct i2c_client *client, - const struct i2c_device_id *id) -{ - struct i2c_adapter *adap = client->adapter; - struct pca954x_platform_data *pdata = dev_get_platdata(&client->dev); - struct pca9641 *data; - int force; - int ret = -ENODEV; - int detect_id; - - if (!i2c_check_functionality(adap, I2C_FUNC_SMBUS_BYTE_DATA)) { - goto err; - } - - data = kzalloc(sizeof(struct pca9641), GFP_KERNEL); - if (!data) { - ret = -ENOMEM; - goto err; - } - - i2c_set_clientdata(client, data); - - detect_id = pca9641_detect_id(client); - - /* - * I2C accesses are unprotected here. - * We have to lock the adapter before releasing the bus. - */ - if (detect_id == 1) { - i2c_lock_adapter(adap); - pca9641_release_bus(client); - i2c_unlock_adapter(adap); - } - - /* Create mux adapter */ - - force = 0; - if (pdata) { - force = pdata->modes[0].adap_id; - } - - if (detect_id == 1) { - data->mux_adap = i2c_add_mux_adapter(adap, &client->dev, client, - force, 0, 0, - pca9641_select_chan, - pca9641_release_chan); - } - - if (data->mux_adap == NULL) { - dev_err(&client->dev, "failed to register master selector\n"); - goto exit_free; - } - - dev_info(&client->dev, "registered master selector for I2C %s\n", - client->name); - - return 0; - -exit_free: - kfree(data); -err: - return ret; -} - -static int pca9641_remove(struct i2c_client *client) -{ - struct pca9641 *data = i2c_get_clientdata(client); - - i2c_del_mux_adapter(data->mux_adap); - - kfree(data); - return 0; -} - -static struct i2c_driver pca9641_driver = { - .driver = { - .name = "pca9641", - .owner = THIS_MODULE, - }, - .probe = pca9641_probe, - .remove = pca9641_remove, - .id_table = pca9641_id, -}; - -module_i2c_driver(pca9641_driver); - -MODULE_AUTHOR("Guenter Roeck "); -MODULE_DESCRIPTION("PCA9641 I2C master selector driver"); -MODULE_LICENSE("GPL v2"); diff --git a/packages/platforms/inventec/x86-64/d6356/modules/builds/src/inv_cpld.c b/packages/platforms/inventec/x86-64/d6356/modules/builds/src/inv_cpld.c deleted file mode 100644 index 76cf2a601..000000000 --- a/packages/platforms/inventec/x86-64/d6356/modules/builds/src/inv_cpld.c +++ /dev/null @@ -1,998 +0,0 @@ -/* - * 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 -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -/* definition */ -#define CPLD_INFO_OFFSET 0x00 -#define CPLD_BIOSCS_OFFSET 0x04 -#define CPLD_CTL_OFFSET 0x0C -#define CPLD_SYSLED_OFFSET 0x0E -#define CPLD_LED_OFFSET 0x2E -#define CPLD_INT_OFFSET 0x30 -#define CPLD_INTMASK_OFFSET 0x31 -#define CPLD_INT2_OFFSET 0x32 -#define CPLD_INTMASK2_OFFSET 0x33 -#define CPLD_PSU_OFFSET 0x40 -#define CPLD_POWERSTATUS_OFFSET 0x41 -#define CPLD_PWM_OFFSET 0x50 -#define CPLD_RPM_OFFSET 0x55 -#define CPLD_FANSTATUS_OFFSET 0x69 -#define CPLD_FANLED_OFFSET 0x6B -#define CPLD_RESETBUTTONSTATUS_OFFSET 0x75 -#define CPLD_RSTCAUSE_OFFSET 0x76 -#define CPLD_WATCHDOGCOUNTER_OFFSET 0x77 -#define CPLD_WATCHDOGCONFIG_OFFSET 0x78 -#define CPLD_WATCHDOGENABLE_OFFSET 0x79 -#define CPLD_PANICCODE_OFFSET 0x7E -#define CPLD2_ADDRESS 0x33 - -#define FAN_NUM 4 -static u8 hasCPLD2 = 1; -static struct i2c_client *client2; - -/* Each client has this additional data */ -struct cpld_data { - struct device *hwmon_dev; - struct mutex update_lock; - u8 diag; - struct task_struct *tsk; -}; - -/*-----------------------------------------------------------------------*/ -static ssize_t cpld_i2c_read(struct i2c_client *client, u8 *buf, u8 offset, size_t count) -{ - int i; - s32 temp = 0; - - for(i=0; iuser_msg_data; - - if(recv_msg->msg.data[0]==0 && recv_msg->msg.data_len>0) { - msg_result->result_length=recv_msg->msg.data_len-1; - memcpy(msg_result->result, &recv_msg->msg.data[1], recv_msg->msg.data_len-1); - } - ipmi_free_recv_msg(recv_msg); - mutex_unlock(&ipmi_mutex); - - return; -} - -int start_ipmi_command(char NetFn, char cmd,char *data,int data_length, char* result, int* result_length) -{ - int rv=0,i; - int timeout; - - //wait previous command finish at least 50msec - timeout=50; - while((mutex_is_locked(&ipmi_mutex) == 1 || (mutex_is_locked(&ipmi2_mutex) == 1)) && (--timeout)>0) { usleep_range(1000,1010); } - if(timeout==0) { return -1; } - mutex_lock(&ipmi_mutex); - mutex_lock(&ipmi2_mutex); - - if(ipmi_mh_user == NULL) { - for (i=0,rv=1; i0) { usleep_range(1000,1100);} - if(timeout==0) { - mutex_unlock(&ipmi2_mutex); - return -1; - } - else { - *result_length=ipmiresult.result_length; - memcpy(result,ipmiresult.result,*result_length); - mutex_unlock(&ipmi2_mutex); - return 0; - } - } - return 0; -} -EXPORT_SYMBOL(start_ipmi_command); - -static int cpld_thread(void *p) -{ -#ifndef XORP - struct i2c_client *client = p; - - u8 byte[9]; - uint8_t result[MAX_IPMI_RECV_LENGTH]; - int result_len=0; - - //Handle LED control by the driver - byte[0]=0x01; - cpld_i2c_write(client, byte, CPLD_CTL_OFFSET, 1); - - //Disable BMC Watchdog - byte[0]=0x04; - byte[1]=0x00; - byte[2]=0x00; - byte[3]=0x00; - byte[4]=0x2C; - byte[5]=0x01; - start_ipmi_command(0x06, 0x24, byte, 6, result, &result_len); -#endif - return 0; -} -/*-----------------------------------------------------------------------*/ -/* sysfs attributes for hwmon */ -static ssize_t show_info(struct device *dev, struct device_attribute *da, - char *buf) -{ - struct i2c_client *client = to_i2c_client(dev); - struct cpld_data *data = i2c_get_clientdata(client); - ssize_t len = 0; - - u8 byte[4] = {0,0,0,0}; - - mutex_lock(&data->update_lock); - len = cpld_i2c_read(client, byte, CPLD_INFO_OFFSET, 4); - mutex_unlock(&data->update_lock); - if (len==0) return 0; - - sprintf (buf, "The CPLD release date is %02d/%02d/%d.\n", - byte[2] & 0xf, (byte[3] & 0x1f), 2014+(byte[2] >> 4)); /* mm/dd/yyyy*/ - sprintf (buf, "%sThe PCB version is %X\n", buf, byte[0]&0xf); - sprintf (buf, "%sThe CPLD version is %d.%d\n", buf, byte[1]>>4, byte[1]&0xf); - - if(hasCPLD2) { - mutex_lock(&data->update_lock); - cpld_i2c_read(client2, byte, CPLD_INFO_OFFSET, 4); - mutex_unlock(&data->update_lock); - - sprintf (buf, "%s\nThe CPLD2 release date is %02d/%02d/%d.\n", buf, - byte[2] & 0xf, (byte[3] & 0x1f), 2014+(byte[2] >> 4)); /* mm/dd/yyyy*/ - sprintf (buf, "%sThe CPLD2 version is %d.%d\n", buf, byte[1]>>4, byte[1]&0xf); - } - - return strlen(buf); -} - -static char* powerstatus_str[] = { - "Failed", //0 - "Good", //1 -}; - -static ssize_t show_powerstatus(struct device *dev, struct device_attribute *da, - char *buf) -{ - struct i2c_client *client = to_i2c_client(dev); - struct cpld_data *data = i2c_get_clientdata(client); - ssize_t len = 0; - u8 byte[2] = {0,0}; - - mutex_lock(&data->update_lock); - len = cpld_i2c_read(client2, byte, CPLD_POWERSTATUS_OFFSET, 2); - mutex_unlock(&data->update_lock); - if (len==0) return 0; - - sprintf (buf, "PGD_P5V_STBY: %s\n", powerstatus_str[(byte[0]>>7) & 0x01]); - sprintf (buf, "%sPGD_P3V3_STBY: %s\n", buf, powerstatus_str[(byte[0]>>6) & 0x01]);; - sprintf (buf, "%sPGD_P1V8_A: %s\n", buf, powerstatus_str[(byte[0]>>4) & 0x01]); - sprintf (buf, "%sPGD_P3V3_SYS: %s\n", buf, powerstatus_str[(byte[0]>>3) & 0x01]); - sprintf (buf, "%sPGD_P3V3_A: %s\n", buf, powerstatus_str[(byte[0]>>2) & 0x01]); - sprintf (buf, "%sPGD_P3V3_B: %s\n", buf, powerstatus_str[(byte[0]>>1) & 0x01]); - sprintf (buf, "%sPGD_P1V2: %s\n", buf, powerstatus_str[(byte[0]>>0) & 0x01]); - sprintf (buf, "%sPGD_P0V8_A: %s\n", buf,powerstatus_str[(byte[1]>>7) & 0x01]); - sprintf (buf, "%sPGD_P0V89_ROV: %s\n", buf, powerstatus_str[(byte[1]>>6) & 0x01]); - sprintf (buf, "%sSW_PWR_READY: %s\n", buf, powerstatus_str[(byte[1]>>3) & 0x01]); - sprintf (buf, "%sCPU_STBY_PWROK: %s\n", buf, powerstatus_str[(byte[1]>>0) & 0x01]); - - return strlen(buf); -} - -static ssize_t show_diag(struct device *dev, struct device_attribute *da, - char *buf) -{ - struct i2c_client *client = to_i2c_client(dev); - struct cpld_data *data = i2c_get_clientdata(client); - uint8_t ipmisend[]= { IPMI_DIAGFLAG_OFFSET, 1}; - uint8_t result[MAX_IPMI_RECV_LENGTH]; - int result_len=0; - start_ipmi_command(NETFN_OEM, CMD_GETDATA,ipmisend, 2, result, &result_len); - data->diag = (result[0] & 0x80) !=0; - return sprintf (buf, "%d\n", data->diag); -} - -static ssize_t set_diag(struct device *dev, - struct device_attribute *da, - const char *buf, size_t count) -{ - struct i2c_client *client = to_i2c_client(dev); - struct cpld_data *data = i2c_get_clientdata(client); - uint8_t ipmisend[]= { IPMI_DIAGFLAG_OFFSET, 0x80}; - uint8_t result[MAX_IPMI_RECV_LENGTH]; - int result_len=0; - u8 diag = simple_strtol(buf, NULL, 10); - data->diag = diag?1:0; - if (data->diag==0) ipmisend[1] = 0x00; - - start_ipmi_command(NETFN_OEM, CMD_SETDATA,ipmisend, 2, result, &result_len); - - return count; -} - -static char* interrupt_str[] = { - "CPU_SEN_ALERT_N", //0 - "EXT_USB_OC_N", //1 - "", //2 - "", //3 - "PLD_SEN5_ALERT_N", //4 - "PLD_SEN4_ALERT_N", //5 - "PLD_SEN3_ALERT_N", //6 - "UCD90160_TEMP_INT_N", //7 - "RSTBTN_INT_N", //8 - "WDT_IRQ_N", //9 -}; - -static ssize_t show_interrupt(struct device *dev, struct device_attribute *da, - char *buf) -{ - struct i2c_client *client = to_i2c_client(dev); - struct cpld_data *data = i2c_get_clientdata(client); - ssize_t len = 0; - u8 byte[4] = {0,0,0,0}; - - mutex_lock(&data->update_lock); - len = cpld_i2c_read(client, byte, CPLD_INT_OFFSET, 4); - mutex_unlock(&data->update_lock); - if (len==0) return 0; - - sprintf (buf, "0x%02X 0x%02X:", byte[0],byte[2]); - if(byte[0]==0xff && byte[2]==0x07) sprintf (buf, "%sNone",buf); - if(!(byte[0]&0x01)) sprintf (buf, "%s%s ",buf,interrupt_str[0]); - if(!(byte[0]&0x02)) sprintf (buf, "%s%s ",buf,interrupt_str[1]); - if(!(byte[0]&0x10)) sprintf (buf, "%s%s ",buf,interrupt_str[4]); - if(!(byte[0]&0x20)) sprintf (buf, "%s%s ",buf,interrupt_str[5]); - if(!(byte[0]&0x40)) sprintf (buf, "%s%s ",buf,interrupt_str[6]); - if(!(byte[0]&0x80)) sprintf (buf, "%s%s ",buf,interrupt_str[7]); - if(!(byte[2]&0x01)) sprintf (buf, "%s%s%s ",buf,interrupt_str[8] ,(byte[3]&0x01)?"(Blocked)":""); - if(!(byte[2]&0x02)) sprintf (buf, "%s%s%s ",buf,interrupt_str[9] ,(byte[3]&0x02)?"(Blocked)":""); - - return sprintf (buf, "%s\n", buf); -} - -static char* bios_str[] = { - "BIOS1", //0 - "BIOS2", //1 -}; - -static ssize_t show_bios_cs(struct device *dev, struct device_attribute *da, - char *buf) -{ - struct i2c_client *client = to_i2c_client(dev); - struct cpld_data *data = i2c_get_clientdata(client); - ssize_t len = 0; - u8 byte = 0; - - mutex_lock(&data->update_lock); - len = cpld_i2c_read(client, &byte, CPLD_BIOSCS_OFFSET, 1); - mutex_unlock(&data->update_lock); - if (len==0) return 0; - - byte &= 0x01; - - return sprintf (buf, "%d:%s\n", byte,bios_str[byte]); -} - -static ssize_t set_bios_cs(struct device *dev, - struct device_attribute *da, - const char *buf, size_t count) -{ - struct i2c_client *client = to_i2c_client(dev); - struct cpld_data *data = i2c_get_clientdata(client); - u8 byte = 0; - u8 temp = simple_strtol(buf, NULL, 10); - - mutex_lock(&data->update_lock); - cpld_i2c_read(client, &byte, CPLD_BIOSCS_OFFSET, 1); - if(temp) byte |= 0x01; else byte &= ~(0x01); - cpld_i2c_write(client, &byte, CPLD_BIOSCS_OFFSET, 1); - mutex_unlock(&data->update_lock); - - return count; -} - -static char* led_str[] = { - "OFF", //00 - "Green/Blue", //01 - "Yellow/Orange", //10 - "Red", //11 -}; - -static ssize_t show_led(struct device *dev, struct device_attribute *da, - char *buf) -{ - struct sensor_device_attribute *attr = to_sensor_dev_attr(da); - struct i2c_client *client = to_i2c_client(dev); - struct cpld_data *data = i2c_get_clientdata(client); - ssize_t len = 0; - u8 byte = 0; - int shift = attr->index; - - mutex_lock(&data->update_lock); - len = cpld_i2c_read(client, &byte, CPLD_LED_OFFSET, 1); - mutex_unlock(&data->update_lock); - if (len==0) return 0; - - byte = (byte >> shift) & 0x3; - - return sprintf (buf, "%d:%s\n", byte, led_str[byte]); -} - -static ssize_t set_led(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 cpld_data *data = i2c_get_clientdata(client); - - u8 temp = simple_strtol(buf, NULL, 16); - u8 byte = 0; - int shift = attr->index; - temp &= 0x3; - - mutex_lock(&data->update_lock); - cpld_i2c_read(client, &byte, CPLD_LED_OFFSET, 1); - byte &= ~(0x3<update_lock); - - return count; -} - -static char* sysled_str[] = { - "OFF", //000 - "0.5 Hz", //001 - "1 Hz", //010 - "2 Hz", //011 - "4 Hz", //100 - "NA", //101 - "NA", //110 - "ON", //111 -}; - -static ssize_t show_sysled(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_SYSLED_OFFSET, 1); - mutex_unlock(&data->update_lock); - - byte = (byte >> shift) & 0x7; - status = sprintf (buf, "%d:%s\n", byte, sysled_str[byte]); - - return strlen(buf); -} - -static ssize_t set_sysled(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; - - mutex_lock(&data->update_lock); - cpld_i2c_read(client, &byte, CPLD_SYSLED_OFFSET, 1); - byte &= ~(0x7<update_lock); - - return count; -} - -static char* psu_str[] = { - "unpowered", //00 - "normal", //01 - "not installed", //10 - "not installed", //11 -}; - -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 cpld_data *data = i2c_get_clientdata(client); - ssize_t len = 0; - u8 byte=0; - int shift = (attr->index == 0)?0:4; - - mutex_lock(&data->update_lock); - len = cpld_i2c_read(client2, &byte, CPLD_PSU_OFFSET, 1); - mutex_unlock(&data->update_lock); - if (len==0) return 0; - - byte = (byte >> shift) & 0x3; - - return sprintf (buf, "%d:%s\n", byte, psu_str[byte]); -} - -static ssize_t show_pwm(struct device *dev, struct device_attribute *da, - char *buf) -{ - struct sensor_device_attribute *attr = to_sensor_dev_attr(da); - struct i2c_client *client = to_i2c_client(dev); - struct cpld_data *data = i2c_get_clientdata(client); - ssize_t len = 0; - u8 byte=0; - u8 offset = attr->index + CPLD_PWM_OFFSET; - - mutex_lock(&data->update_lock); - len = cpld_i2c_read(client2, &byte, offset, 1); - mutex_unlock(&data->update_lock); - if (len==0) return 0; - - return sprintf(buf, "%d\n", byte); -} - -static ssize_t set_pwm(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 cpld_data *data = i2c_get_clientdata(client); - u8 offset = attr->index + CPLD_PWM_OFFSET; - u8 byte = simple_strtol(buf, NULL, 10); - - mutex_lock(&data->update_lock); - cpld_i2c_write(client2, &byte, offset, 1); - mutex_unlock(&data->update_lock); - - return count; -} - -static ssize_t show_rpm(struct device *dev, struct device_attribute *da, - char *buf) -{ - struct sensor_device_attribute *attr = to_sensor_dev_attr(da); - struct i2c_client *client = to_i2c_client(dev); - struct cpld_data *data = i2c_get_clientdata(client); - ssize_t len = 0; - u8 offset = attr->index*2 + CPLD_RPM_OFFSET; - u8 byte[2] = {0,0}; - - mutex_lock(&data->update_lock); - len = cpld_i2c_read(client2, byte, offset, 2); - mutex_unlock(&data->update_lock); - if (len==0) return 0; - - return sprintf(buf, "%d\n", (byte[0]<<8 | byte[1])); -} - -static char* fantype_str[] = { - "Normal Type", //00 - "REVERSAL Type", //01 - "UNPLUGGED", //10 - "UNPLUGGED", //11 -}; - -static ssize_t show_fantype(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 cpld_data *data = i2c_get_clientdata(client); - ssize_t len = 0; - u8 offset = CPLD_FANSTATUS_OFFSET; - u8 byte[2] = {0,0}; - - mutex_lock(&data->update_lock); - len = cpld_i2c_read(client2, byte, offset, 2); - mutex_unlock(&data->update_lock); - if (len==0) return 0; - status = (((byte[0] >> attr->index) & 0x01)) | (((byte[1] >> attr->index) & 0x01)<<1); - - return sprintf(buf, "%d:%s\n",status,fantype_str[status]); -} - -static char* fanled_str[] = { - "None", //00 - "Green", //01 - "Red", //10 - "Both", //11 -}; - -static ssize_t show_fanled(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 cpld_data *data = i2c_get_clientdata(client); - ssize_t len = 0; - u8 byte[2] = {0,0}; - - mutex_lock(&data->update_lock); - len = cpld_i2c_read(client2, byte, CPLD_FANLED_OFFSET, 2); - mutex_unlock(&data->update_lock); - if (len==0) return 0; - status = (((byte[0] >> attr->index) & 0x01)) | (((byte[1] >> attr->index) & 0x01)<<1); - - return sprintf(buf, "%d:%s\n",status,fanled_str[status]); -} - -static ssize_t set_fanled(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 cpld_data *data = i2c_get_clientdata(client); - u8 byte[2] = {0,0}; - u8 temp = simple_strtol(buf, NULL, 16); - int shift = attr->index; - - temp &= 0x3; - mutex_lock(&data->update_lock); - cpld_i2c_read(client2, byte, CPLD_FANLED_OFFSET, 2); - byte[0] &= ~(1<> 1) & 0x01)<update_lock); - - return count; -} - -static ssize_t set_watchdog_feed(struct device *dev, struct device_attribute *da, - const char *buf, size_t count) -{ - struct i2c_client *client = to_i2c_client(dev); - struct cpld_data *data = i2c_get_clientdata(client); - u8 byte=0; - - mutex_lock(&data->update_lock); - cpld_i2c_read(client, &byte, CPLD_WATCHDOGENABLE_OFFSET, 1); - byte |= 0x02; - cpld_i2c_write(client, &byte, CPLD_WATCHDOGENABLE_OFFSET, 1); - mutex_unlock(&data->update_lock); - - return count; -} - -static ssize_t set_watchdog_enable(struct device *dev, struct device_attribute *da, - const char *buf, size_t count) -{ - struct i2c_client *client = to_i2c_client(dev); - struct cpld_data *data = i2c_get_clientdata(client); - u8 byte=0x03; - - mutex_lock(&data->update_lock); - cpld_i2c_write(client, &byte, CPLD_WATCHDOGENABLE_OFFSET, 1); - mutex_unlock(&data->update_lock); - - return count; -} - -static ssize_t show_watchdog_enable(struct device *dev, struct device_attribute *da, - char *buf) -{ - struct i2c_client *client = to_i2c_client(dev); - struct cpld_data *data = i2c_get_clientdata(client); - ssize_t len = 0; - u8 byte=0; - - mutex_lock(&data->update_lock); - len = cpld_i2c_read(client, &byte, CPLD_WATCHDOGENABLE_OFFSET, 1); - mutex_unlock(&data->update_lock); - if (len==0) return 0; - - return sprintf(buf, "%d\n",(byte&0x01)); -} - -static ssize_t set_watchdog_config(struct device *dev, - struct device_attribute *da, - const char *buf, size_t count) -{ - struct i2c_client *client = to_i2c_client(dev); - struct cpld_data *data = i2c_get_clientdata(client); - u8 byte = simple_strtol(buf, NULL, 10); - - if (byte<6) byte=6; - mutex_lock(&data->update_lock); - cpld_i2c_write(client, &byte, CPLD_WATCHDOGCONFIG_OFFSET, 1); - mutex_unlock(&data->update_lock); - - return count; -} - -static ssize_t show_watchdog_config(struct device *dev, struct device_attribute *da, - char *buf) -{ - struct i2c_client *client = to_i2c_client(dev); - struct cpld_data *data = i2c_get_clientdata(client); - ssize_t len = 0; - u8 byte=0; - - mutex_lock(&data->update_lock); - len = cpld_i2c_read(client, &byte, CPLD_WATCHDOGCONFIG_OFFSET, 1); - mutex_unlock(&data->update_lock); - if (len==0) return 0; - - return sprintf(buf, "%d seconds\n",byte); -} - -static ssize_t show_watchdog_counter(struct device *dev, struct device_attribute *da, - char *buf) -{ - struct i2c_client *client = to_i2c_client(dev); - struct cpld_data *data = i2c_get_clientdata(client); - ssize_t len = 0; - u8 byte=0; - - mutex_lock(&data->update_lock); - len = cpld_i2c_read(client, &byte, CPLD_WATCHDOGCOUNTER_OFFSET, 1); - mutex_unlock(&data->update_lock); - if (len==0) return 0; - - return sprintf(buf, "%d seconds\n",byte); -} - -static SENSOR_DEVICE_ATTR(info, S_IRUGO, show_info, 0, 0); -static SENSOR_DEVICE_ATTR(diag, S_IWUSR|S_IRUGO, show_diag, set_diag, 0); -static SENSOR_DEVICE_ATTR(interrupt, S_IRUGO, show_interrupt, 0, 0); - -static SENSOR_DEVICE_ATTR(fan_led, S_IWUSR|S_IRUGO, show_led, set_led, 2); -static SENSOR_DEVICE_ATTR(power_led, S_IWUSR|S_IRUGO, show_led, set_led, 4); -static SENSOR_DEVICE_ATTR(location_led, S_IWUSR|S_IRUGO, show_led, set_led, 6); - -static SENSOR_DEVICE_ATTR(grn_led, S_IWUSR|S_IRUGO, show_sysled, set_sysled, 0); -static SENSOR_DEVICE_ATTR(red_led, S_IWUSR|S_IRUGO, show_sysled, set_sysled, 1); - -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); -#if FAN_NUM>4 -static SENSOR_DEVICE_ATTR(pwm5, S_IWUSR|S_IRUGO, show_pwm, set_pwm, 4); -#endif - -static SENSOR_DEVICE_ATTR(fanmodule1_type, S_IRUGO, show_fantype, 0, 0); -static SENSOR_DEVICE_ATTR(fanmodule2_type, S_IRUGO, show_fantype, 0, 1); -static SENSOR_DEVICE_ATTR(fanmodule3_type, S_IRUGO, show_fantype, 0, 2); -static SENSOR_DEVICE_ATTR(fanmodule4_type, S_IRUGO, show_fantype, 0, 3); -#if FAN_NUM>4 -static SENSOR_DEVICE_ATTR(fanmodule5_type, S_IRUGO, show_fantype, 0, 4); -#endif - -static SENSOR_DEVICE_ATTR(fanmodule1_led, S_IWUSR|S_IRUGO, show_fanled, set_fanled, 0); -static SENSOR_DEVICE_ATTR(fanmodule2_led, S_IWUSR|S_IRUGO, show_fanled, set_fanled, 1); -static SENSOR_DEVICE_ATTR(fanmodule3_led, S_IWUSR|S_IRUGO, show_fanled, set_fanled, 2); -static SENSOR_DEVICE_ATTR(fanmodule4_led, S_IWUSR|S_IRUGO, show_fanled, set_fanled, 3); -#if FAN_NUM>4 -static SENSOR_DEVICE_ATTR(fanmodule5_led, S_IWUSR|S_IRUGO, show_fanled, set_fanled, 4); -#endif - -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); -#if FAN_NUM>4 -static SENSOR_DEVICE_ATTR(fan9_input, S_IRUGO, show_rpm, 0, 8); -static SENSOR_DEVICE_ATTR(fan10_input,S_IRUGO, show_rpm, 0, 9); -#endif - -static SENSOR_DEVICE_ATTR(psu1, S_IRUGO, show_psu, 0, 0); -static SENSOR_DEVICE_ATTR(psu2, S_IRUGO, show_psu, 0, 1); -static SENSOR_DEVICE_ATTR(power_status, S_IRUGO, show_powerstatus, 0, 0); - -static SENSOR_DEVICE_ATTR(watchdog_feed, S_IWUSR, 0, set_watchdog_feed, 0); -static SENSOR_DEVICE_ATTR(watchdog_enable, S_IWUSR|S_IRUGO, show_watchdog_enable, set_watchdog_enable, 0); -static SENSOR_DEVICE_ATTR(watchdog_config, S_IWUSR|S_IRUGO, show_watchdog_config, set_watchdog_config, 0); -static SENSOR_DEVICE_ATTR(watchdog_counter, S_IRUGO, show_watchdog_counter, 0, 0); - -static SENSOR_DEVICE_ATTR(bios_cs, S_IWUSR|S_IRUGO, show_bios_cs, set_bios_cs, 0); - -static struct attribute *cpld_attributes[] = { - &sensor_dev_attr_info.dev_attr.attr, - &sensor_dev_attr_diag.dev_attr.attr, - - &sensor_dev_attr_fan_led.dev_attr.attr, - &sensor_dev_attr_power_led.dev_attr.attr, - &sensor_dev_attr_location_led.dev_attr.attr, - - &sensor_dev_attr_grn_led.dev_attr.attr, - &sensor_dev_attr_red_led.dev_attr.attr, - - &sensor_dev_attr_interrupt.dev_attr.attr, - - &sensor_dev_attr_psu1.dev_attr.attr, - &sensor_dev_attr_psu2.dev_attr.attr, - &sensor_dev_attr_power_status.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, -#if FAN_NUM>4 - &sensor_dev_attr_pwm5.dev_attr.attr, -#endif - &sensor_dev_attr_fanmodule1_type.dev_attr.attr, - &sensor_dev_attr_fanmodule2_type.dev_attr.attr, - &sensor_dev_attr_fanmodule3_type.dev_attr.attr, - &sensor_dev_attr_fanmodule4_type.dev_attr.attr, -#if FAN_NUM>4 - &sensor_dev_attr_fanmodule5_type.dev_attr.attr, -#endif - &sensor_dev_attr_fanmodule1_led.dev_attr.attr, - &sensor_dev_attr_fanmodule2_led.dev_attr.attr, - &sensor_dev_attr_fanmodule3_led.dev_attr.attr, - &sensor_dev_attr_fanmodule4_led.dev_attr.attr, -#if FAN_NUM>4 - &sensor_dev_attr_fanmodule5_led.dev_attr.attr, -#endif - &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>4 - &sensor_dev_attr_fan9_input.dev_attr.attr, - &sensor_dev_attr_fan10_input.dev_attr.attr, -#endif - &sensor_dev_attr_watchdog_feed.dev_attr.attr, - &sensor_dev_attr_watchdog_enable.dev_attr.attr, - &sensor_dev_attr_watchdog_config.dev_attr.attr, - &sensor_dev_attr_watchdog_counter.dev_attr.attr, - - &sensor_dev_attr_bios_cs.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; - - 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; - } - - //Check CPLD2 exist or not - client2 = i2c_new_dummy(client->adapter, CPLD2_ADDRESS); - if(!client2) { - hasCPLD2 = 0; - client2 = client; - } else { - status = i2c_smbus_read_byte_data(client2, CPLD_INFO_OFFSET); - if(status<0) { - i2c_unregister_device(client2); - i2c_set_clientdata(client2, NULL); - hasCPLD2 = 0; - client2 = client; - } - } - - data->tsk = kthread_run(cpld_thread,client,"%s",dev_name(data->hwmon_dev)); - 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); - - sysfs_remove_group(&client->dev.kobj, &cpld_group); - hwmon_device_unregister(data->hwmon_dev); - i2c_set_clientdata(client, NULL); - if(hasCPLD2) { - i2c_unregister_device(client2); - i2c_set_clientdata(client2, 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("jack.ting "); -MODULE_DESCRIPTION("cpld driver"); -MODULE_LICENSE("GPL"); - -module_init(inv_cpld_init); -module_exit(inv_cpld_exit); diff --git a/packages/platforms/inventec/x86-64/d6356/modules/builds/src/inv_mux.c b/packages/platforms/inventec/x86-64/d6356/modules/builds/src/inv_mux.c deleted file mode 100644 index 8d95d1439..000000000 --- a/packages/platforms/inventec/x86-64/d6356/modules/builds/src/inv_mux.c +++ /dev/null @@ -1,547 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include "io_expander.h" -#include "inv_mux.h" - -/* For build single module using (Ex: ONL platform) */ -//#include -//#include -//#include - - -static struct mux_obj_s *mux_head_p = NULL; - -/* ========== MUX object functions ========== - */ -static int -_setup_i2c_value(struct mux_obj_s *self, int offset, int value){ - - return i2c_smbus_write_byte_data(self->i2c_client_p, offset, value); -} - - -static int -_setup_i2c_client(struct mux_obj_s *self, int chan_id, int addr){ - - struct i2c_adapter *adap = NULL; - char *emsg = "ERR"; - - adap = i2c_get_adapter(chan_id); - if (!adap){ - emsg = "can't get adapter"; - goto err_setup_i2c_client; - } - self->i2c_client_p = kzalloc(sizeof(*self->i2c_client_p), GFP_KERNEL); - if (!self->i2c_client_p){ - emsg = "can't kzalloc client"; - goto err_setup_i2c_client; - } - self->i2c_client_p->adapter = adap; - self->i2c_client_p->addr = addr; - return 0; - -err_setup_i2c_client: - SWPS_ERR("%s: %s\n", __func__, emsg); - return ERR_MUX_UNEXCPT; -} - - -int -_common_force_pull_gpio(int mem_addr, - int input, - int bit_offset){ - - unsigned int val = 0; - unsigned int targ = 0; - - /* Get current value */ - val = inl(mem_addr); - if (val == 0) { - SWPS_ERR("%s: inl:%d fail!\n", __func__, val); - return -1; - } - /* Count target value */ - switch (input) { - case 0: /* Pull Low */ - targ = (val & (~(1 << bit_offset))); - break; - case 1: /* Pull high */ - targ = (val | (1 << bit_offset)); - break; - default: - SWPS_ERR("%s: input state:%d incorrect!\n", - __func__, input); - return -1; - } - /* Setup gpio */ - outl(targ, mem_addr); - if (targ != inl(mem_addr)){ - SWPS_ERR("%s: outl:%d fail!\n", __func__, targ); - return -1; - } - SWPS_DEBUG("%s: done.\n", __func__); - return 0; -} - - -int -rangeley_force_pull_high(struct mux_obj_s *self){ - SWPS_ERR("%s: not ready!\n", __func__); - return -1; -} - - -int -rangeley_force_pull_low(struct mux_obj_s *self){ - SWPS_ERR("%s: not ready!\n", __func__); - return -1; -} - - -int -hedera_force_pull_high(struct mux_obj_s *self){ - return _common_force_pull_gpio(MUX_RST_MEM_ADDR_HEDERA, 1, 5); -} - - -int -hedera_force_pull_low(struct mux_obj_s *self){ - return _common_force_pull_gpio(MUX_RST_MEM_ADDR_HEDERA, 0, 5); -} - - -int -normal_gpio_pull_high(struct mux_obj_s *self){ - return gpio_direction_output(self->gpio_num, 1); -} - - -int -normal_gpio_pull_low(struct mux_obj_s *self){ - return gpio_direction_output(self->gpio_num, 0); -} - - -int -cpld_rst_all_4_pull_low(struct mux_obj_s *self){ - - char *emsg = "ERR"; - int err = ERR_MUX_UNEXCPT; - - switch(self->gpio_num) { - case MUX_RST_CPLD_C0_A77_70_74_RST_ALL: - goto setlow_cpld_rst_all_4_c0_a77_70_74_rst_all; - - default: - break; - } - emsg = "Undefined case"; - goto err_cpld_rst_all_4_pull_low; - -setlow_cpld_rst_all_4_c0_a77_70_74_rst_all: - err = _setup_i2c_value(self, 0x70, 0x0); - if (err < 0) { - emsg = "setup 0x70 fail"; - goto err_cpld_rst_all_4_pull_low; - } - err = _setup_i2c_value(self, 0x74, 0x01); - if (err < 0) { - emsg = "setup 0x74 fail"; - goto err_cpld_rst_all_4_pull_low; - } - return 0; - -err_cpld_rst_all_4_pull_low: - SWPS_INFO("%s: %s :%d :%d\n", - __func__, emsg, self->gpio_num, err); - return ERR_MUX_UNEXCPT; -} - - -int -cpld_rst_all_4_pull_high(struct mux_obj_s *self){ - - char *emsg = "ERR"; - int err = ERR_MUX_UNEXCPT; - - switch(self->gpio_num) { - case MUX_RST_CPLD_C0_A77_70_74_RST_ALL: - goto sethigh_cpld_rst_all_4_c0_a77_70_74_rst_all; - - default: - break; - } - emsg = "Undefined case"; - goto err_cpld_rst_all_4_pull_high; - -sethigh_cpld_rst_all_4_c0_a77_70_74_rst_all: - err = _setup_i2c_value(self, 0x70, 0xfe); - if (err < 0) { - emsg = "setup 0x70 fail"; - goto err_cpld_rst_all_4_pull_high; - } - err = _setup_i2c_value(self, 0x74, 0x03); - if (err < 0) { - emsg = "setup 0x74 fail"; - goto err_cpld_rst_all_4_pull_high; - } - return 0; - -err_cpld_rst_all_4_pull_high: - SWPS_INFO("%s: %s :%d :%d\n", - __func__, emsg, self->gpio_num, err); - return ERR_MUX_UNEXCPT; -} - - -int -pca9548_reset_mux_all(struct mux_obj_s *self){ - /* [Note] Power-on reset (PCA9548A-NXP) - * When power is applied to VDD, an internal Power-On Reset (POR) - * holds the PCA9548A in a reset condition until VDD has reached - * VPOR. At this point, the reset condition is released and the - * PCA9548A register and I2C-bus state machine are initialized to - * their default states (all zeroes) causing all the channels to - * be deselected. Thereafter, VDD must be lowered below 0.2 V for - * at least 5 us in order to reset the device. - */ - if (self->_pull_low(self) < 0) { - SWPS_ERR("%s: _pull_low fail!\n", __func__); - return -1; - } - mdelay(MUX_RST_WAIT_MS_PCA9548); - if (self->_pull_high(self) < 0) { - SWPS_ERR("%s: _pull_high fail!\n", __func__); - return -1; - } - mdelay(MUX_RST_WAIT_MS_PCA9548); - return 0; -} - - -int -cpld_reset_mux_all(struct mux_obj_s *self){ - - char *emsg = "ERR"; - int err = ERR_MUX_UNEXCPT; - - switch(self->gpio_num) { - case MUX_RST_CPLD_C0_A77_70_74_RST_ALL: - goto reset_cpld_rst_all_4_c0_a77_70_74_rst_all; - - default: - break; - } - emsg = "Undefined case"; - goto err_cpld_reset_mux_all; - -reset_cpld_rst_all_4_c0_a77_70_74_rst_all: - if (self->_pull_low(self) < 0) { - emsg = "_pull_low fail"; - goto err_cpld_reset_mux_all; - } - mdelay(MUX_RST_WAIT_MS_CPLD); - return 0; - -err_cpld_reset_mux_all: - SWPS_INFO("%s: %s :%d :%d\n", - __func__, emsg, self->gpio_num, err); - return ERR_MUX_UNEXCPT; -} - - -int -common_reset_mux_all(struct mux_obj_s *self){ - SWPS_ERR("%s: not ready!\n", __func__); - return -1; -} - - -int -init_gpio_4_force(struct mux_obj_s *self){ - - if (self->_pull_high(self) < 0) { - SWPS_ERR("%s: setup default fail!\n", __func__); - return -1; - } - return 0; -} - - -int -init_gpio_4_normal(struct mux_obj_s *self){ - - int err = 0; - char *emsg = "ERR"; - - if (!gpio_is_valid(self->gpio_num)) { - emsg = "GPIO invalid"; - goto err_init_gpio_4_normal; - } - err = gpio_request(self->gpio_num, MUX_GPIO_LABEL); - if (err < 0) { - emsg = "gpio_request fail"; - goto err_init_gpio_4_normal; - } - err = self->_pull_high(self); - if (err < 0) { - emsg = "setup default fail"; - goto err_init_gpio_4_normal; - } - SWPS_DEBUG("%s: gpio_request:%d ok.\n", __func__, self->gpio_num); - return 0; - -err_init_gpio_4_normal: - SWPS_ERR("%s: %s :%d :%d\n", - __func__, emsg, self->gpio_num, err); - return -1; -} - - -int -init_cpld_4_rst_all(struct mux_obj_s *self){ - - char *emsg = "ERR"; - int err = ERR_MUX_UNEXCPT; - int chan = ERR_MUX_UNEXCPT; - int addr = ERR_MUX_UNEXCPT; - - switch(self->gpio_num) { - case MUX_RST_CPLD_C0_A77_70_74_RST_ALL: - goto init_cpld_i2c_c0_a77_70_74_rst_all; - - default: - break; - } - emsg = "Undefined case"; - goto err_init_cpld_4_rst_all; - -init_cpld_i2c_c0_a77_70_74_rst_all: - chan = 0; - addr = 0x77; - err = _setup_i2c_client(self, chan, addr); - if (err < 0) { - emsg = "_setup_i2c_client fail"; - goto err_init_cpld_4_rst_all; - } - err = self->_pull_high(self); - if (err < 0) { - emsg = "setup default value fail"; - goto err_init_cpld_4_rst_all; - } - SWPS_DEBUG("%s: init_cpld_i2c_c0_a77_70_74_rst_all ok", __func__); - return 0; - -err_init_cpld_4_rst_all: - SWPS_INFO("%s: %s :%d :%d\n", - __func__, emsg, self->gpio_num, err); - return ERR_MUX_UNEXCPT; -} - - -int -clean_gpio_4_common(struct mux_obj_s *self){ - - if (!self) return 0; - if (!gpio_is_valid(self->gpio_num)) return 0; - self->_pull_high(self); - gpio_free(mux_head_p->gpio_num); - return 0; -} - - -int -clean_cpld_4_rst_all(struct mux_obj_s *self){ - - if (!self) return 0; - self->_pull_high(self); - if (self->i2c_client_p) { - i2c_put_adapter(self->i2c_client_p->adapter); - kfree(self->i2c_client_p); - } - return 0; -} - - -static int -_setup_muxctl_cb(struct mux_obj_s *self, - unsigned gpio){ - - char mod_dsc[32] = "ERR"; - - switch (gpio) { - case MUX_RST_GPIO_FORCE_RANGELEY: - self->gpio_num = gpio; - self->_pull_low = rangeley_force_pull_low; - self->_pull_high = rangeley_force_pull_high; - self->_init = init_gpio_4_force; - self->_clean = clean_gpio_4_common; - self->reset = pca9548_reset_mux_all; - memset(mod_dsc, 0, 32); - snprintf(mod_dsc, 31, "Rangeley force mode"); - goto ok_setup_muxctl_cb; - - case MUX_RST_GPIO_FORCE_HEDERA: - self->gpio_num = gpio; - self->_pull_low = hedera_force_pull_low; - self->_pull_high = hedera_force_pull_high; - self->_init = init_gpio_4_force; - self->_clean = clean_gpio_4_common; - self->reset = pca9548_reset_mux_all; - memset(mod_dsc, 0, 32); - snprintf(mod_dsc, 31, "Hedera force mode"); - goto ok_setup_muxctl_cb; - - case MUX_RST_GPIO_48_PAC9548: - case MUX_RST_GPIO_69_PAC9548: - case MUX_RST_GPIO_249_PCA9548: - case MUX_RST_GPIO_500_PAC9548: - case MUX_RST_GPIO_505_PCA9548: - self->gpio_num = gpio; - self->_pull_low = normal_gpio_pull_low; - self->_pull_high = normal_gpio_pull_high; - self->_init = init_gpio_4_normal; - self->_clean = clean_gpio_4_common; - self->reset = pca9548_reset_mux_all; - memset(mod_dsc, 0, 32); - snprintf(mod_dsc, 31, "Normal mode :%d", (int)gpio); - goto ok_setup_muxctl_cb; - - case MUX_RST_CPLD_C0_A77_70_74_RST_ALL: - self->gpio_num = gpio; - self->_pull_low = cpld_rst_all_4_pull_low; - self->_pull_high = cpld_rst_all_4_pull_high; - self->_init = init_cpld_4_rst_all; - self->_clean = clean_cpld_4_rst_all; - self->reset = cpld_reset_mux_all; - memset(mod_dsc, 0, 32); - snprintf(mod_dsc, 31, "CPLD mode :%d", (int)gpio); - goto ok_setup_muxctl_cb; - - default: - break; - } - SWPS_ERR("%s: Unexpected GPIO:%d\n", __func__, gpio); - return -1; - -ok_setup_muxctl_cb: - SWPS_INFO("muxctl: %s.\n", mod_dsc); - return 0; -} - - -/* ========== MUX public functions ========== - */ -void -clean_mux_objs(void){ - - struct mux_obj_s *curr_p = mux_head_p; - struct mux_obj_s *next_p = NULL; - - if (!curr_p) { - SWPS_DEBUG("%s: mux_head_p is NULL\n", __func__); - return; - } - while (curr_p) { - next_p = curr_p->next; - curr_p->_clean(curr_p); - kfree(curr_p); - curr_p = next_p; - } - SWPS_DEBUG("%s: done.\n", __func__); -} -EXPORT_SYMBOL(clean_mux_objs); - - -int -reset_mux_objs(void){ - - if (!mux_head_p) { - SWPS_ERR("%s: MUX ctl object doesn't exist!\n", __func__); - return -1; - } - if (mux_head_p->reset(mux_head_p) < 0){ - SWPS_ERR("%s: reset fail!\n", __func__); - return -1; - } - return 0; -} -EXPORT_SYMBOL(reset_mux_objs); - - -struct mux_obj_s * -_create_mux_obj(unsigned gpio){ - - char *emsg = "ERR"; - struct mux_obj_s *obj_p = NULL; - - obj_p = kzalloc(sizeof(struct mux_obj_s), GFP_KERNEL); - if (!obj_p) { - emsg = "kzalloc fail!"; - goto err_create_mux_obj_1; - } - if (_setup_muxctl_cb(obj_p, gpio) < 0){ - emsg = "_setup_muxctl_cb fail!"; - goto err_create_mux_obj_2; - } - if (obj_p->_init(obj_p) < 0) { - emsg = "_init() fail!"; - goto err_create_mux_obj_2; - } - SWPS_DEBUG("%s: created MUX object :%d\n", __func__, gpio); - return obj_p; - -err_create_mux_obj_2: - kfree(obj_p); -err_create_mux_obj_1: - SWPS_ERR("%s: %s :%d\n", __func__, emsg, gpio); - return NULL; -} - - -int -init_mux_objs(unsigned gpio){ - - struct mux_obj_s *curr_p = NULL; - char *emsg = "ERR"; - - /* Create MUX control object */ - if (mux_head_p) { - SWPS_DEBUG("%s: mux_head_p is not NULL!\n", __func__); - clean_mux_objs(); - } - /* Currently, it is using single muxctl architecture. - * In the future, it may use the multi-muxctl. - * (Ex: Gulmohar's advance I2C control / Peony's reset single mux) - */ - curr_p = _create_mux_obj(gpio); - if (!curr_p) { - emsg = "_create_mux_obj fail"; - goto err_init_mux_objs; - } - curr_p->next = NULL; - mux_head_p = curr_p; - SWPS_DEBUG("%s: all done. :%d\n", __func__, gpio); - return 0; - -err_init_mux_objs: - clean_mux_objs(); - SWPS_ERR("%s: %s\n", __func__, emsg); - return -1; -} -EXPORT_SYMBOL(init_mux_objs); - - -/* For single ko module - * => You need to declare MODULE_LICENSE If you want to build single module along. - * => Ex: For ONL platform - */ -//MODULE_LICENSE("GPL"); - - - - diff --git a/packages/platforms/inventec/x86-64/d6356/modules/builds/src/inv_mux.h b/packages/platforms/inventec/x86-64/d6356/modules/builds/src/inv_mux.h deleted file mode 100644 index 6c2a5a69b..000000000 --- a/packages/platforms/inventec/x86-64/d6356/modules/builds/src/inv_mux.h +++ /dev/null @@ -1,51 +0,0 @@ -#ifndef INV_MUX_H -#define INV_MUX_H - -#include - -/* MUX basic information */ -#define MUX_GPIO_LABEL "SWPS_RST_MUX" - -/* MUX reset GPIO define */ -#define MUX_RST_GPIO_FORCE (30100) -#define MUX_RST_GPIO_FORCE_RANGELEY (30101) -#define MUX_RST_GPIO_FORCE_HEDERA (30102) -#define MUX_RST_GPIO_48_PAC9548 (48) -#define MUX_RST_GPIO_69_PAC9548 (69) -#define MUX_RST_GPIO_249_PCA9548 (249) -#define MUX_RST_GPIO_500_PAC9548 (500) -#define MUX_RST_GPIO_505_PCA9548 (505) -#define MUX_RST_CPLD_C0_A77_70_74_RST_ALL (30201) - -/* MUX relate value define */ -#define MUX_RST_WAIT_MS_PCA9548 (1) -#define MUX_RST_WAIT_MS_CPLD (10) -#define MUX_RST_MEM_ADDR_RANGELEY (0) // TBD -#define MUX_RST_MEM_ADDR_HEDERA (0x548) - -/* MUX error code define */ -#define ERR_MUX_UNEXCPT (-399) - -struct mux_obj_s { - struct i2c_client *i2c_client_p; - struct mux_obj_s *next; - unsigned gpio_num; - int (*_pull_high)(struct mux_obj_s *self); - int (*_pull_low)(struct mux_obj_s *self); - int (*_init)(struct mux_obj_s *self); - int (*_clean)(struct mux_obj_s *self); - int (*reset)(struct mux_obj_s *self); -}; - - -void clean_mux_objs(void); -int reset_mux_objs(void); -int init_mux_objs(unsigned gpio); - - -#endif /* INV_MUX_H */ - - - - - diff --git a/packages/platforms/inventec/x86-64/d6356/modules/builds/src/inv_platform.c b/packages/platforms/inventec/x86-64/d6356/modules/builds/src/inv_platform.c deleted file mode 100644 index 212388c8e..000000000 --- a/packages/platforms/inventec/x86-64/d6356/modules/builds/src/inv_platform.c +++ /dev/null @@ -1,297 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include - -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 pca9641_modes_1[] = { - {.adap_id = bus_id(2),}, -}; - -static struct pca954x_platform_mode pca9641_modes_2[] = { - {.adap_id = bus_id(5),}, -}; - -static struct pca954x_platform_mode pca9641_modes_3[] = { - {.adap_id = bus_id(3),}, -}; - -static struct pca954x_platform_mode pca9641_modes_4[] = { - {.adap_id = bus_id(4),}, -}; - -static struct pca954x_platform_mode mux_modes_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_0[] = { - {.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_1[] = { - {.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_2[] = { - {.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_mode mux_modes_0_3[] = { - {.adap_id = bus_id(38),}, {.adap_id = bus_id(39),}, - {.adap_id = bus_id(40),}, {.adap_id = bus_id(41),}, - {.adap_id = bus_id(42),}, {.adap_id = bus_id(43),}, - {.adap_id = bus_id(44),}, {.adap_id = bus_id(45),}, -}; - -static struct pca954x_platform_mode mux_modes_0_4[] = { - {.adap_id = bus_id(46),}, {.adap_id = bus_id(47),}, - {.adap_id = bus_id(48),}, {.adap_id = bus_id(49),}, - {.adap_id = bus_id(50),}, {.adap_id = bus_id(51),}, - {.adap_id = bus_id(52),}, {.adap_id = bus_id(53),}, -}; - -static struct pca954x_platform_mode mux_modes_0_5[] = { - {.adap_id = bus_id(54),}, {.adap_id = bus_id(55),}, - {.adap_id = bus_id(56),}, {.adap_id = bus_id(57),}, - {.adap_id = bus_id(58),}, {.adap_id = bus_id(59),}, - {.adap_id = bus_id(60),}, {.adap_id = bus_id(61),}, -}; - -static struct pca954x_platform_mode mux_modes_0_6[] = { - {.adap_id = bus_id(62),}, {.adap_id = bus_id(63),}, - {.adap_id = bus_id(64),}, {.adap_id = bus_id(65),}, - {.adap_id = bus_id(66),}, {.adap_id = bus_id(67),}, - {.adap_id = bus_id(68),}, {.adap_id = bus_id(69),}, -}; - -//no i2c device driver attach to mux 7 - -static struct pca954x_platform_data pca9641_data_1 = { - .modes = pca9641_modes_1, - .num_modes = 1, -}; -static struct pca954x_platform_data pca9641_data_2 = { - .modes = pca9641_modes_2, - .num_modes = 1, -}; -static struct pca954x_platform_data pca9641_data_3 = { - .modes = pca9641_modes_3, - .num_modes = 1, -}; -static struct pca954x_platform_data pca9641_data_4 = { - .modes = pca9641_modes_4, - .num_modes = 1, -}; -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 = { - {"pca9641", 0, 0x76, &pca9641_data_1, 0, 0}, //PCA9641-1 - {"pca9641", 0, 0x73, &pca9641_data_3, 0, 0}, //PCA9641-3 - {"pca9641", 0, 0x09, &pca9641_data_4, 0, 0}, //PCA9641-4 -}; -static struct i2c_board_info i2c_device_info1[] __initdata = { - {"pca9641", 0, 0x0A, &pca9641_data_2, 0, 0}, //PCA9641-2 -}; -static struct i2c_board_info i2c_device_info2[] __initdata = { - {"inv_cpld", 0, 0x77, 0, 0, 0}, //CPLD -}; -static struct i2c_board_info i2c_device_info3[] __initdata = { - {"tmp75", 0, 0x48, 0, 0, 0}, //CPU Board Temp - {"tmp75", 0, 0x4A, 0, 0, 0}, //Temp - {"tmp75", 0, 0x4D, 0, 0, 0}, //Temp - {"tmp75", 0, 0x4E, 0, 0, 0}, //Temp -}; -static struct i2c_board_info i2c_device_info4[] __initdata = { - {"pmbus", 0, 0x5B, 0, 0, 0}, //PSU1 - {"pmbus", 0, 0x5A, 0, 0, 0}, //PSU2 -}; -static struct i2c_board_info i2c_device_info5[] __initdata = { - {"pca9548", 0, 0x70, &mux_data_0, 0, 0}, //mux root -}; -static struct i2c_board_info i2c_device_info6[] __initdata = { - {"pca9548", 0, 0x72, &mux_data_0_0, 0, 0}, -}; -static struct i2c_board_info i2c_device_info7[] __initdata = { - {"pca9548", 0, 0x72, &mux_data_0_1, 0, 0}, -}; -static struct i2c_board_info i2c_device_info8[] __initdata = { - {"pca9548", 0, 0x72, &mux_data_0_2, 0, 0}, -}; -static struct i2c_board_info i2c_device_info9[] __initdata = { - {"pca9548", 0, 0x72, &mux_data_0_3, 0, 0}, -}; -static struct i2c_board_info i2c_device_info10[] __initdata = { - {"pca9548", 0, 0x72, &mux_data_0_4, 0, 0}, -}; -static struct i2c_board_info i2c_device_info11[] __initdata = { - {"pca9548", 0, 0x72, &mux_data_0_5, 0, 0}, -}; -static struct i2c_board_info i2c_device_info12[] __initdata = { - {"pca9548", 0, 0x72, &mux_data_0_6, 0, 0}, -}; - - -static struct inv_i2c_board_info i2cdev_list[] = { - {bus_id(0), ARRAY_SIZE(i2c_device_info0), i2c_device_info0 }, //SMBus - {bus_id(1), ARRAY_SIZE(i2c_device_info1), i2c_device_info1 }, //pca9641-2 - {bus_id(2), ARRAY_SIZE(i2c_device_info2), i2c_device_info2 }, //pca9641-1 - {bus_id(3), ARRAY_SIZE(i2c_device_info3), i2c_device_info3 }, //pca9641-3 - {bus_id(4), ARRAY_SIZE(i2c_device_info4), i2c_device_info4 }, //pca9641-4 - {bus_id(5), ARRAY_SIZE(i2c_device_info5), i2c_device_info5 }, //mux root - {bus_id(6), ARRAY_SIZE(i2c_device_info6), i2c_device_info6 }, //mux CH0 - {bus_id(7), ARRAY_SIZE(i2c_device_info7), i2c_device_info7 }, //mux CH1 - {bus_id(8), ARRAY_SIZE(i2c_device_info8), i2c_device_info8 }, //mux CH2 - {bus_id(9), ARRAY_SIZE(i2c_device_info9), i2c_device_info9 }, //mux CH3 - {bus_id(10),ARRAY_SIZE(i2c_device_info10), i2c_device_info10}, //mux CH4 - {bus_id(11),ARRAY_SIZE(i2c_device_info11), i2c_device_info11}, //mux CH5 - {bus_id(12),ARRAY_SIZE(i2c_device_info12), i2c_device_info12}, //mux CH6 -}; - -#define INV_PLATFORM_CLIENT_MAX_NUM 50 /*A big enough number for sum of i2cdev_list[i].size */ -static int client_list_index = 0; -static struct i2c_client *client_list[INV_PLATFORM_CLIENT_MAX_NUM] = {0}; - -///////////////////////////////////////////////////////////////////////////////////////// -static struct platform_device *device_i2c_gpio0; -static struct i2c_gpio_platform_data i2c_gpio_platdata0 = { - .scl_pin = 58, //494, - .sda_pin = 75, //511, - - .udelay = 5, //5:100kHz - .sda_is_open_drain = 0, - .scl_is_open_drain = 0, - .scl_is_output_only = 0 -}; - -static int __init inv_platform_init(void) -{ - struct i2c_adapter *adap = NULL; - struct i2c_client *e = NULL; - int ret = 0; - int i,j,k; - - //printk("%s \n", __func__); - - //use i2c-gpio - //register i2c gpio - //config gpio58,75 to gpio function 58=32+3*8+2 75=32*2+8*1+3 gpio69=32*2+8*0+5 - outl( inl(0x533) | (1<<2), 0x533); //i2c-gpio sdl (GPIO58) - outl( inl(0x541) | (1<<3), 0x541); //i2c-gpio sda (GPIO75) - outl( inl(0x540) | (1<<5), 0x540); //RST_I2C_MUX_N (GPIO69) - outl( inl(0x500) | (1<<7), 0x500); //SYS_RDY_N (GPIO7) - outl( inl(0x501) | (1<<7), 0x501); //BMC_HEART_BEAT (GPIO15) - outl( inl(0x503) | (1<<2)|(1<<3), 0x503); //PSOC_HEART_BEAT(26),CPLD_HEART_BEAT(27) - - device_i2c_gpio0 = platform_device_alloc("i2c-gpio", 1); - if (!device_i2c_gpio0) { - printk(KERN_ERR "i2c-gpio: platform_device_alloc fail\n"); - return -ENOMEM; - } - device_i2c_gpio0->name = "i2c-gpio"; - device_i2c_gpio0->id = 1; - device_i2c_gpio0->dev.platform_data = &i2c_gpio_platdata0; - - ret = platform_device_add(device_i2c_gpio0); - if (ret) { - printk(KERN_ERR "i2c-gpio: platform_device_add fail %d\n", ret); - } - msleep(10); - - for(i=0; i=0; i--) { - i2c_unregister_device(client_list[i]); - } - device_i2c_gpio0->dev.platform_data = NULL; - platform_device_unregister(device_i2c_gpio0); - printk("inv_platform_exit done\n"); -} - -module_init(inv_platform_init); -module_exit(inv_platform_exit); - -MODULE_AUTHOR("Inventec"); -MODULE_DESCRIPTION("Platform devices"); -MODULE_LICENSE("GPL"); - diff --git a/packages/platforms/inventec/x86-64/d6356/modules/builds/src/inv_pthread.c b/packages/platforms/inventec/x86-64/d6356/modules/builds/src/inv_pthread.c deleted file mode 100644 index 186000053..000000000 --- a/packages/platforms/inventec/x86-64/d6356/modules/builds/src/inv_pthread.c +++ /dev/null @@ -1,884 +0,0 @@ -/***************************** - Maple (d6356) platform -******************************/ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "inv_pthread.h" - -#define INV_PTHREAD_KERNEL_MODULE - -#define SHOW_ATTR_WARNING ("N/A") -#define SHOW_ATTR_NOTPRINT ("Not Available") -#define SHOW_ATTR_NOTSUPPORT ("Not Support") - -#define INV_HWMID_MAX (10) -#define INV_HWMID_INIT (-1) - -/*access userspace data to kernel space*/ -#define ACC_R (0) -#define ACC_W (1) - -#define MAX_PATH_SIZE (64) -#define MIN_ACC_SIZE (32) -#define MAX_ACC_SIZE (256) - -/* - * LED definitions - */ -#define STATUS_LED_MODE_AUTO (0) -#define STATUS_LED_MODE_DIAG (1) -#define STATUS_LED_MODE_MANU (2) -#define STATUS_LED_MODE_ERR (-1) - -#define STATUS_LED_GRN0 (10) // 0 - 000: off -#define STATUS_LED_GRN1 (11) // 1 - 001: 0.5hz -#define STATUS_LED_GRN2 (12) // 2 - 010: 1 hz -#define STATUS_LED_GRN3 (13) // 3 - 011: 2 hz -#define STATUS_LED_GRN7 (17) // 7 - 111: on -#define STATUS_LED_RED0 (20) // 0 - 000: off -#define STATUS_LED_RED1 (21) // 1 - 001: 0.5hz -#define STATUS_LED_RED2 (22) // 2 - 010: 1 hz -#define STATUS_LED_RED3 (23) // 3 - 011: 2 hz -#define STATUS_LED_RED7 (27) // 7 - 111: on -#define STATUS_LED_INVALID (0) // Invalid - -static struct mutex pthread_mutex; - -ssize_t status_led_grn(const char *freq); -ssize_t status_led_red(const char *freq); -ssize_t status_led_diag_mode_enable(void); -ssize_t status_led_diag_mode_disable(void); -int status_led_check_color(void); -int status_led_check_diag_mode(void); - -#if 1 -/* For timestamps in SYSFS_LOG */ -#define SYSFS_LOG printk -#else -//#define SYSFS_LOG(fmt, args...) printk(KERN_WARNING "[SYSFS] %s/%d: " fmt, __func__, __LINE__, ##args) -#define SYSFS_LOG(fmt, args...) printk(KERN_WARNING "[p_thread] " fmt, ##args) -#endif - - -/* inventec_class *********************************/ -static struct kobject *status_kobj; -static struct kset *status_kset; - -#if 0 -int inventec_strtol(const char *sbufp, char **endp, unsigned int base) -{ - char *endptr; - int value = simple_strtol(sbufp, &endptr, base); - if (value == 0 && sbufp == endptr) { - *endp = NULL; - return value; - } - *endp = (char*)1; - return value; -} -#endif - -int inventec_singlechar_to_int(const char c) -{ - if ((c >= '0') && (c <= '9')) { - return (c - '0'); - } - else - if ((c >= 'a') && (c <= 'f')) { - return (c - 'a' + 10); - } - else - if ((c >= 'A') && (c <= 'F')) { - return (c - 'A' + 10); - } - return -1; -} - -/* fan device *************************************/ -#define FAN_STATE_NORMAL "normal" -#define FAN_STATE_FAULTY "faulty" -#define FAN_STATE_UNINSTALLED "uninstalled" -#define FAN_STATE_UNKNOW "unknown state" -#define FAN_STATE_INVALID "Invalid state value" -#define FAN_STATE_READ_ERROR "state read error" - -#define FAN_LOG_UNINSTALLED "removed" -#define FAN_LOG_NORMAL "inserted" - -//#define FAN_STATE_BIT_NORMAL 0 -#define FAN_STATE_BIT_FAULTY 0 -#define FAN_STATE_BIT_UNINSTALLED 1 -#define FAN_STATE_BIT_UNKNOW 2 -#define FAN_STATE_BIT_INVALID 3 -#define FAN_STATE_BIT_READ_ERROR 4 - -static ssize_t psoc_show_fan1_input(char *buf) -{ - return psoc_show_fan_input(buf, 1); -} - -static ssize_t psoc_show_fan2_input(char *buf) -{ - return psoc_show_fan_input(buf, 2); -} - -static ssize_t psoc_show_fan3_input(char *buf) -{ - return psoc_show_fan_input(buf, 3); -} - -static ssize_t psoc_show_fan4_input(char *buf) -{ - return psoc_show_fan_input(buf, 4); -} - -static ssize_t psoc_show_fan5_input(char *buf) -{ - return psoc_show_fan_input(buf, 5); -} - -static ssize_t psoc_show_fan6_input(char *buf) -{ - return psoc_show_fan_input(buf, 6); -} - -static ssize_t psoc_show_fan7_input(char *buf) -{ - return psoc_show_fan_input(buf, 7); -} - -static ssize_t psoc_show_fan8_input(char *buf) -{ - return psoc_show_fan_input(buf, 8); -} - -static struct fans_tbl_s { - char *fan_name; - ssize_t (*fan_front)(char *); - ssize_t (*fan_rear)(char *); - unsigned int fan_state; -} fans_tbl[] = { - {"fan1", psoc_show_fan1_input, - psoc_show_fan2_input, 0}, - {"fan2", psoc_show_fan3_input, - psoc_show_fan4_input, 0}, - {"fan3", psoc_show_fan5_input, - psoc_show_fan6_input, 0}, - {"fan4", psoc_show_fan7_input, - psoc_show_fan8_input, 0}, -}; -#define FAN_TBL_TOTAL ( sizeof(fans_tbl)/ sizeof(const struct fans_tbl_s) ) - -#define FAN_STATE_CHECK(i,b) (fans_tbl[i].fan_state & (1<inv_dev_attrp, PSU_ATTR_VOLTIN, PSU_ATTR_VOLTIN_LEN) == 0) { - invwirep = psu_get_show_function(PSU_ATTR_VOLTIN, psu_dev_group[i].psu_name, NULL); - if (invwirep == NULL) { - printk(KERN_DEBUG "[p_thread] Invalid psuname: %s\n", psu_dev_group[i].psu_name); - continue; - } - if (invwirep(volt) <= 0) { - printk(KERN_DEBUG "[p_thread] Read %s failed\n", psu_dev_group[i].psu_name); - continue; - } - else { - voltin = simple_strtol(&volt[0], NULL, 10); - printk(KERN_DEBUG "[p_thread] Read %s %s = %u\n",psu_dev_group[i].psu_name,volt,voltin); - if (voltin > psu_voltin) { - psu_voltin = voltin; - } - } - } - } - } - - SYSFS_LOG("[p_thread] PSU voltin = %u\n", psu_voltin); -} - -#define PSU_ATTR_STATE ("state") -#define PSU_ATTR_STATE_LEN (5) - -/* psus_control() by inv_thread */ -int psus_control(int log_only) -{ - char state[MIN_ACC_SIZE]; - psu_dev_t *devnamep = NULL; - ssize_t (*invwirep)(char *buf) = NULL; - char *psu_statep = NULL; - int i, j, flag = 0; - - for (i = 0; i < PSU_DEV_GROUP_TOTAL; i++) { - devnamep = psu_dev_group[i].psu_dev_namep; - for (j = 0; j < psu_dev_group[i].psu_dev_total; j++, devnamep++) { - if (strncmp(devnamep->inv_dev_attrp, PSU_ATTR_STATE, PSU_ATTR_STATE_LEN) == 0) { - invwirep = psu_get_show_function(PSU_ATTR_STATE, psu_dev_group[i].psu_name, &psu_statep); - if (invwirep == NULL) { - printk(KERN_DEBUG "[p_thread] Invalid psuname: %s\n", psu_dev_group[i].psu_name); - continue; - } - if (invwirep(state) <= 0) { - printk(KERN_DEBUG "[p_thread] Read %s failed\n", psu_dev_group[i].psu_name); - if (strncmp(psu_statep, PSU_STATE_ERROR, strlen(PSU_STATE_ERROR)) != 0) { - strcpy(psu_statep, PSU_STATE_ERROR); - SYSFS_LOG("[p_thread] %s: %s\n",psu_dev_group[i].psu_name,PSU_STATE_ERROR); - } - flag = 1; - } - else - if (strstr(state, "normal")) { - if (strncmp(psu_statep, state, strlen(state)) != 0) { - strcpy(psu_statep, state); - SYSFS_LOG("[p_thread] %s: %s\n",psu_dev_group[i].psu_name,state); - } - } - else - if (psu_voltin > PSU_VOLTIN_ACDC) { /* AC PSUS */ - if (strncmp(psu_statep, state, strlen(state)) != 0) { - strcpy(psu_statep, state); - SYSFS_LOG("[p_thread] %s: %s\n",psu_dev_group[i].psu_name,state); - } - flag = 1; - } - else { /* DC PSUS */ - if (strncmp(psu_statep, PSU_STATE_CHECKPSU, PSU_STATE_LEN_CHECKPSU) != 0) { - strcpy(psu_statep, PSU_STATE_CHECKPSU); - SYSFS_LOG("[p_thread] %s: %s\n",psu_dev_group[i].psu_name,PSU_STATE_CHECKPSU); - } - flag = 1; - } - } - } - } - - if (log_only) { - return 0; - } - - //SYSFS_LOG("[p_thread] RYU: %s: flag = %d\n",psu_wire_tbl[i].psu_name,flag); - if (flag == 1) { - status_led_grn("2"); - return 1; - } - return 0; -} - -/* End of psuinfo_device */ - -/* led device *************************************/ - -/* return 0/off 1/green 2/red */ -int -status_led_check_color(void) -{ - char tmpbuf[MIN_ACC_SIZE]; - int ret = STATUS_LED_INVALID; - - if (cpld_show_led(&tmpbuf[0], CPLD_DEV_LED_GRN_INDEX) > 0) { - if (tmpbuf[0] == '0') { - ret = STATUS_LED_GRN0; - } - if (tmpbuf[0] == '1') { - ret = STATUS_LED_GRN1; - } - if (tmpbuf[0] == '2') { - ret = STATUS_LED_GRN2; - } - if (tmpbuf[0] == '3') { - ret = STATUS_LED_GRN3; - } - if (tmpbuf[0] == '7') { - ret = STATUS_LED_GRN7; - } - return ret; - } - - if (cpld_show_led(&tmpbuf[0], CPLD_DEV_LED_RED_INDEX) > 0) { - if (tmpbuf[0] == '0') { - ret = STATUS_LED_RED0; - } - if (tmpbuf[0] == '1') { - ret = STATUS_LED_RED1; - } - if (tmpbuf[0] == '2') { - ret = STATUS_LED_RED2; - } - if (tmpbuf[0] == '3') { - ret = STATUS_LED_RED3; - } - if (tmpbuf[0] == '7') { - ret = STATUS_LED_RED7; - } - return ret; - } - return ret; -} - -/* - * Store attr Section - */ -ssize_t status_led_diag_mode_enable(void) -{ - char tmp[MIN_ACC_SIZE]; - ssize_t ret; - - ret = psoc_show_diag(&tmp[0]); - if (ret <= 0) { - return ret; - } - - if (tmp[0] == '0') { - ret = psoc_set_diag("1", 1); - if (ret < 0) { - return ret; - } - - ret = cpld_set_ctl("1", 1); - if (ret < 0) { - return ret; - } - } - - return ret; -} - -ssize_t status_led_diag_mode_disable(void) -{ - char tmp[MIN_ACC_SIZE]; - ssize_t ret; - - ret = psoc_show_diag(&tmp[0]); - if (ret <= 0) { - return ret; - } - - if (tmp[0] == '1') { - ret = psoc_set_diag("0", 1); - if (ret < 0) { - return 1; - } - - ret = cpld_set_ctl("1", 1); - if (ret < 0) { - return 1; - } - } - return 1; -} - -ssize_t -status_led_red(const char *freq) -{ - char buf[MIN_ACC_SIZE]; - ssize_t ret; - - ret = cpld_show_led(buf, CPLD_DEV_LED_RED_INDEX); - if (ret < 0 || buf[0] == freq[0]) { - return ret; - } - - ret = cpld_set_led("0", 1, CPLD_DEV_LED_GRN_INDEX); - if (ret < 0) { - return ret; - } - ret = cpld_set_led(freq, strlen(freq), CPLD_DEV_LED_RED_INDEX); - if (ret < 0) { - return ret; - } - if ((ret = status_led_diag_mode_enable()) <= 0) { - return ret; - } - ssleep(1); - if ((ret = status_led_diag_mode_disable()) <= 0) { - return ret; - } - return ret; -} - -ssize_t -status_led_grn(const char *freq) -{ - char buf[MIN_ACC_SIZE]; - ssize_t ret; - - ret = cpld_show_led(buf, CPLD_DEV_LED_GRN_INDEX); - if (ret < 0 || buf[0] == freq[0]) { - return ret; - } - - ret = cpld_set_led("0", 1, CPLD_DEV_LED_RED_INDEX); - if (ret < 0) { - return ret; - } - ssleep(1); - ret = cpld_set_led(freq, strlen(freq), CPLD_DEV_LED_GRN_INDEX); - if (ret < 0) { - return ret; - } - if ((ret = status_led_diag_mode_enable()) <= 0) { - return ret; - } - ssleep(1); - if ((ret = status_led_diag_mode_disable()) <= 0) { - return ret; - } - return ret; -} - -int status_led_check_diag_mode(void) -{ - char tmp[MIN_ACC_SIZE]; - ssize_t ret; - - ret = psoc_show_diag(&tmp[0]); - if (ret <= 0) { - return ret; - } - - if (tmp[0] == '1') { - return STATUS_LED_MODE_DIAG; - } - - if (tmp[0] == '0') { - return STATUS_LED_MODE_AUTO; - } - - return -1; -} - -/* End of ledinfo_device */ - -/**************************************************/ -/* From system_device */ -static int inv_pthread_control = 1; - -int thread_control(void) -{ - return inv_pthread_control; -} - -void thread_control_set(int val) -{ - inv_pthread_control = val; -} -/* End system_device */ - -#define THREAD_SLEEP_MINS (3) -#define THREAD_DELAY_MINS (THREAD_SLEEP_MINS + THREAD_SLEEP_MINS + 1) - -static struct task_struct *thread_st; -static int thread_data; - -// Function executed by kernel thread -static int thread_fn(void *unused) -{ - mutex_init(&pthread_mutex); - - ssleep(THREAD_DELAY_MINS); - - /* Default status init */ - mutex_lock(&pthread_mutex); - status_led_grn("7"); - mutex_unlock(&pthread_mutex); - - psu_get_voltin(); - - /* Delay for guarantee HW ready */ - ssleep(THREAD_DELAY_MINS); - - while (1) - { - mutex_unlock(&pthread_mutex); - ssleep(THREAD_SLEEP_MINS); - - if (thread_control() == 0) { - printk(KERN_INFO "[p_thread] %s/%d: Thread Stop by inv_pthread control\n",__func__,__LINE__); - break; - } - - mutex_lock(&pthread_mutex); - if (status_led_check_diag_mode() == STATUS_LED_MODE_MANU) { - /* status led in change color/freq mode, higher priority. Ignore fans sttaus */ - continue; - } - -#if 0 - switch_temp_update(); -#endif - - if (fans_control() > 0) { - psus_control(1); - continue; - } - else - if (psus_control(0) > 0) { - continue; - } - - if (status_led_check_color() != STATUS_LED_GRN7) { /* status led red, change it to green */ - status_led_grn("7"); - } - } - - do_exit(0); - printk(KERN_INFO "[p_thread] %s/%d: Thread Stopped\n",__func__,__LINE__); - return 0; -} - - -static ssize_t s_show(struct kobject *kobj, struct attribute *attr, char *buf) -{ - int fan_absence; - size_t count = 0; - - fan_absence = fans_control(); - count += sprintf(&buf[count], "%d\n", fan_absence); - return count; -} - -static ssize_t s_store(struct kobject *kobj, struct attribute *attr, const char *buf, size_t count) -{ - return count; -} - -static struct attribute status_att = { - .name = "fan_absence", - .mode = 0777, -}; - -static const struct sysfs_ops status_ops = { - .show = s_show, - .store = s_store, -}; - -static struct kobj_type status_ktype = { - .sysfs_ops = &status_ops, -}; - - -static int __init inv_pthread_init(void) -{ - int retval; - - status_kobj = kzalloc(sizeof(*status_kobj), GFP_KERNEL); - if(!status_kobj) - return PTR_ERR(status_kobj); - - status_kset = kset_create_and_add("platform_status", NULL, kernel_kobj); - if(!status_kset) - return -1; - - status_kobj->kset = status_kset; - - retval = kobject_init_and_add(status_kobj, &status_ktype, NULL, "fan"); - if(retval) - return retval; - - retval = sysfs_create_file(status_kobj, &status_att); - - thread_control_set(1); - - printk(KERN_INFO "[p_thread] %s/%d: Creating Thread\n",__func__,__LINE__); - //Create the kernel thread with name 'inv_pthread' - thread_st = kthread_run(thread_fn, (void*)&thread_data, "inv_pthread"); - if (thread_st) - printk(KERN_INFO "[p_thread] inv_pthread Created successfully\n"); - else - printk(KERN_ERR "[p_thread] inv_pthread creation failed\n"); - - return retval; -} - -static void __exit inv_pthread_exit(void) -{ - thread_control_set(0); - /* Delay for guarantee thread exit */ - ssleep(THREAD_DELAY_MINS); - - sysfs_remove_file(status_kobj, &status_att); - kset_unregister(status_kset); - kobject_del(status_kobj); - - printk(KERN_INFO "[p_thread] inv_pthread cleaning Up\n"); -} - -module_init(inv_pthread_init); -module_exit(inv_pthread_exit); - -MODULE_AUTHOR("Robert "); -MODULE_DESCRIPTION("Inventec Platform Management Thread"); -MODULE_VERSION("version 1.1"); -MODULE_LICENSE("GPL"); diff --git a/packages/platforms/inventec/x86-64/d6356/modules/builds/src/inv_pthread.h b/packages/platforms/inventec/x86-64/d6356/modules/builds/src/inv_pthread.h deleted file mode 100644 index c3b7ce830..000000000 --- a/packages/platforms/inventec/x86-64/d6356/modules/builds/src/inv_pthread.h +++ /dev/null @@ -1,19 +0,0 @@ -#ifndef INV_PTHREAD_H -#define INV_PTHREAD_H - -#define CPLD_DEV_LED_GRN_INDEX (0) -#define CPLD_DEV_LED_RED_INDEX (1) - -ssize_t cpld_show_led(char *buf, int index); -ssize_t cpld_set_led(const char *buf, size_t count, int index); -ssize_t cpld_show_ctl(char *buf); -ssize_t cpld_set_ctl(const char *buf, size_t count); - -ssize_t psoc_show_psu_state(char *buf, int index); -ssize_t psoc_show_fan_input(char *buf, int index); -ssize_t psoc_show_fan_state(char *buf); -ssize_t psoc_show_psu_vin(char *buf, int index); -ssize_t psoc_show_diag(char *buf); -ssize_t psoc_set_diag(const char *buf, size_t count); - -#endif /* INV_PTHREAD_H */ diff --git a/packages/platforms/inventec/x86-64/d6356/modules/builds/src/inv_swps.c b/packages/platforms/inventec/x86-64/d6356/modules/builds/src/inv_swps.c deleted file mode 100644 index 922515e1f..000000000 --- a/packages/platforms/inventec/x86-64/d6356/modules/builds/src/inv_swps.c +++ /dev/null @@ -1,3343 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "inv_swps.h" - -static int ctl_major; -static int port_major; -static int ioexp_total; -static int port_total; -static int auto_config; -static int flag_i2c_reset; -static int flag_mod_state; -static unsigned gpio_rest_mux; -static struct class *swp_class_p = NULL; -static struct inv_platform_s *platform_p = NULL; -static struct inv_ioexp_layout_s *ioexp_layout = NULL; -static struct inv_port_layout_s *port_layout = NULL; - -static void swp_polling_worker(struct work_struct *work); -static DECLARE_DELAYED_WORK(swp_polling, swp_polling_worker); - -static int reset_i2c_topology(void); - -static union { - unsigned int eeprom_update_32[2]; - unsigned char eeprom_update_8[8]; -} ueu_64; - -static int -__swp_match(struct device *dev, -#ifdef SWPS_KERN_VER_AF_3_10 - - const void *data){ -#else - void *data){ -#endif - - char *name = (char *)data; - if (strcmp(dev_name(dev), name) == 0) - return 1; - return 0; -} - - -struct device * -get_swpdev_by_name(char *name){ - struct device *dev = class_find_device(swp_class_p, - NULL, - name, - __swp_match); - return dev; -} - - -static int -sscanf_2_int(const char *buf) { - - int result = -EBFONT; - char *hex_tag = "0x"; - - if (strcspn(buf, hex_tag) == 0) { - if (sscanf(buf,"%x",&result)) { - return result; - } - } else { - if (sscanf(buf,"%d",&result)) { - return result; - } - if(sscanf(buf,"-%d",&result)) { - return -result; - } - if (sscanf(buf,"%x",&result)) { - return result; - } - } - return -EBFONT; -} - -static unsigned long long int -sscanf_2_ullint(const char *buf, size_t count) { - - unsigned long long int result = -EBFONT; - char *hex_tag = "0x"; - int i, zero = 0; - - for (i = 0; i < count-2; i++) { - if (buf[i] != '0') { - zero = 1; - } - } - if (zero == 0) { - return 0x0ULL; - } - - if (strcspn(buf, hex_tag) == 0) { - for (i = 2; i < count-2; i++) { - if (INV_BATOX(buf[i]) == -1) { - return -EBFONT; - } - } - - if (sscanf(buf,"0x%llx",&result)) { - return result; - } - } else { - for (i = 0; i < count-2; i++) { - if (INV_BATOI(buf[i]) == -1) { - return -EBFONT; - } - } - - if (sscanf(buf,"%llu",&result)) { - return result; - } - } - return -EBFONT; -} - - -static int -sscanf_2_binary(const char *buf) { - - int result = sscanf_2_int(buf); - - if (result < 0){ - return -EBFONT; - } - switch (result) { - case 0: - case 1: - return result; - default: - break; - } - return -EBFONT; -} - - -static int -_get_polling_period(void) { - - int retval = 0; - - if (SWP_POLLING_PERIOD == 0) { - return 0; - } - retval = ((SWP_POLLING_PERIOD * HZ) / 1000); - if (retval == 0) { - return 1; - } - return retval; -} - - -static struct transvr_obj_s * -_get_transvr_obj(char *dev_name) { - - struct device *dev_p = NULL; - struct transvr_obj_s *transvr_obj_p = NULL; - - dev_p = get_swpdev_by_name(dev_name); - if (!dev_p){ - return NULL; - } - transvr_obj_p = dev_get_drvdata(dev_p); - if (!transvr_obj_p){ - return NULL; - } - return transvr_obj_p; -} - - -static int -_is_i2c_target_exist(int chan, int addr) { - /* retval: Exist = 1 / Not exist = 0 / Error < 0 - */ - struct i2c_adapter *adap = NULL; - struct i2c_client *client = NULL; - int retval = -1; - int err = -1; - int d_offs = 0; - - adap = i2c_get_adapter(chan); - if (!adap) { - SWPS_DEBUG("%s: can't get adapter\n", __func__); - retval = 0; - goto out_is_i2c_target_exist_1; - } - client = kzalloc(sizeof(*client), GFP_KERNEL); - if (!client) { - SWPS_ERR("%s: kzalloc fail\n", __func__); - retval = -1; - goto out_is_i2c_target_exist_2; - } - client->adapter = adap; - client->addr = addr; - err = i2c_smbus_read_byte_data(client, d_offs); - if (err < 0) { - retval = 0; - } else { - retval = 1; - } - i2c_put_adapter(adap); - kfree(client); - return retval; - -out_is_i2c_target_exist_2: - i2c_put_adapter(adap); -out_is_i2c_target_exist_1: - return retval; -} - - -static void -unlock_tobj_all(void) { - - struct transvr_obj_s *tobj_p; - char port_name[32]; - int port_id = 0; - int minor_curr = 0; - - for (minor_curr=0; minor_currauto_config = auto_config; - unlock_transvr_obj(tobj_p); - SWPS_DEBUG("%s: Set %s auto_config=%d\n", - __func__, tobj_p->swp_name, auto_config); - } - return retval; -} - -unsigned char * -get_eeprom_update(void) -{ - return &ueu_64.eeprom_update_8[0]; -} - -void -set_eeprom_update(unsigned char value[8]) -{ - memcpy(ueu_64.eeprom_update_8, value, 8); -} - -/* ========== R/W Functions module control attribute ========== - */ -static ssize_t -show_attr_platform(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - return snprintf(buf_p, 32, "%s\n", platform_p->name); -} - - -static ssize_t -show_attr_version(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - return snprintf(buf_p, 8, "%s\n", SWP_VERSION); -} - - -static ssize_t -show_attr_status(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - return snprintf(buf_p, 8, "%d\n", flag_mod_state); -} - - -static ssize_t -show_attr_auto_config(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - return snprintf(buf_p, 8, "%d\n", auto_config); -} - - -static ssize_t -show_attr_block_poll(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - return snprintf(buf_p, 8, "%d\n", block_polling); -} - -static ssize_t -show_attr_eeprom_update(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - return snprintf(buf_p, 20, "0x%02x%02x%02x%02x%02x%02x%02x%02x\n", - ueu_64.eeprom_update_8[7],ueu_64.eeprom_update_8[6], - ueu_64.eeprom_update_8[5],ueu_64.eeprom_update_8[4], - ueu_64.eeprom_update_8[3],ueu_64.eeprom_update_8[2], - ueu_64.eeprom_update_8[1],ueu_64.eeprom_update_8[0]); -} - - -static int -_check_reset_pwd(const char *buf_p, - size_t count) { - - int in_max = 64; - int in_len = (int)count; - char in_val[64] = "ERR"; - char *emsg = "ERR"; - - if (in_len >= in_max) { - emsg = "input too much"; - goto err_check_reset_pwd; - } - if (!sscanf(buf_p,"%s",in_val)) { - emsg = "format incorrect"; - goto err_check_reset_pwd; - } - if (strcmp(in_val, SWP_RESET_PWD) != 0) { - emsg = "password incorrect"; - goto err_check_reset_pwd; - } - return 0; - -err_check_reset_pwd: - SWPS_ERR("%s: %s\n", __func__, emsg); - return -1; -} - - -static ssize_t -store_attr_reset_i2c(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - - if (_check_reset_pwd(buf_p, count) < 0) { - return -EBFONT; - } - /* Polling mode */ - if (SWP_POLLING_ENABLE) { - SWPS_INFO("%s: reset I2C :polling\n", __func__); - flag_i2c_reset = 1; - return count; - } - /* Direct mode */ - SWPS_INFO("%s: reset I2C go. :direct\n", __func__); - if (reset_i2c_topology() < 0) { - SWPS_ERR("%s: reset fail!\n", __func__); - return -EIO; - } - SWPS_INFO("%s: reset I2C ok. :direct\n", __func__); - return count; -} - - -static ssize_t -store_attr_reset_swps(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - - struct transvr_obj_s *tobj_p; - char port_name[32] = "ERR"; - int port_id = 0; - int minor_curr = 0; - - if (_check_reset_pwd(buf_p, count) < 0) { - return -EBFONT; - } - for (minor_curr=0; minor_currstate = STATE_TRANSVR_DISCONNECTED; - unlock_transvr_obj(tobj_p); - SWPS_INFO("%s: reset:%s\n", __func__, tobj_p->swp_name); - } - return count; -} - - -static ssize_t -store_attr_auto_config(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - - int input_val = sscanf_2_int(buf_p); - - if (input_val < 0){ - return -EBFONT; - } - if ((input_val != 0) && (input_val != 1)) { - return -EBFONT; - } - auto_config = input_val; - _update_auto_config_2_trnasvr(); - return count; -} - - -static ssize_t -store_attr_block_poll( struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - - int input_val = sscanf_2_int(buf_p); - - if (input_val < 0){ - return -EBFONT; - } - if ((input_val != 0) && (input_val != 1)) { - return -EBFONT; - } - - if(input_val != block_polling){ - block_polling = input_val; - if(block_polling){ - cancel_delayed_work_sync(&swp_polling); - } - else{ - schedule_delayed_work(&swp_polling, _get_polling_period()); - } - } - - return count; -} - -static ssize_t -store_attr_eeprom_update(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count) { - - union { - unsigned long long int input_val_64; - unsigned int input_val_32[2]; - } uiv; - int i; - uiv.input_val_64 = sscanf_2_ullint(buf_p, count); - if (uiv.input_val_64 == 0){ - for (i = 0; i < 8; i++) { - ueu_64.eeprom_update_8[i] = 0; - } - } - else - if (uiv.input_val_64 > 0) { - for (i = 0; i < 32; i++) { - if (uiv.input_val_32[0] & 1<get_id, - buf_p); -} - -static ssize_t -show_attr_eeprom(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_eeprom, - buf_p); -} - -static ssize_t -show_attr_ext_id(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_hex_attr(tobj_p, - tobj_p->get_ext_id, - buf_p); -} - - -static ssize_t -show_attr_connector(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_hex_attr(tobj_p, - tobj_p->get_connector, - buf_p); -} - - -static ssize_t -show_attr_vendor_name(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_vendor_name, - buf_p); -} - - -static ssize_t -show_attr_vendor_pn(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_vendor_pn, - buf_p); -} - - -static ssize_t -show_attr_vendor_rev(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_vendor_rev, - buf_p); -} - - -static ssize_t -show_attr_vendor_sn(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_vendor_sn, - buf_p); -} - - -static ssize_t -show_attr_power_cls(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - size_t len; - int result; - struct transvr_obj_s *tobj_p; - - tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - lock_transvr_obj(tobj_p); - result = tobj_p->get_power_cls(tobj_p); - unlock_transvr_obj(tobj_p); - if (result < 0){ - len = snprintf(buf_p, 16, "%d\n", result); - } else { - len = snprintf(buf_p, 16, "Power Class %d\n", result); - } - return len; -} - - -static ssize_t -show_attr_br(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_hex_attr(tobj_p, - tobj_p->get_br, - buf_p); -} - - -static ssize_t -show_attr_len_sm(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_int_attr(tobj_p, - tobj_p->get_len_sm, - buf_p); -} - - -static ssize_t -show_attr_len_smf(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_int_attr(tobj_p, - tobj_p->get_len_smf, - buf_p); -} - - -static ssize_t -show_attr_len_om1(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_int_attr(tobj_p, - tobj_p->get_len_om1, - buf_p); -} - - -static ssize_t -show_attr_len_om2(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_int_attr(tobj_p, - tobj_p->get_len_om2, - buf_p); -} - - -static ssize_t -show_attr_len_om3(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_int_attr(tobj_p, - tobj_p->get_len_om3, - buf_p); -} - - -static ssize_t -show_attr_len_om4(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_int_attr(tobj_p, - tobj_p->get_len_om4, - buf_p); -} - - -static ssize_t -show_attr_comp_rev(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_hex_attr(tobj_p, - tobj_p->get_comp_rev, - buf_p); -} - - -static ssize_t -show_attr_comp_eth(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_hex_attr(tobj_p, - tobj_p->get_comp_eth_1, - buf_p); -} - - -static ssize_t -show_attr_comp_eth_10(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_hex_attr(tobj_p, - tobj_p->get_comp_eth_10, - buf_p); -} - - -static ssize_t -show_attr_comp_eth_10_40(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_hex_attr(tobj_p, - tobj_p->get_comp_eth_10_40, - buf_p); -} - - -static ssize_t -show_attr_comp_extend(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_hex_attr(tobj_p, - tobj_p->get_comp_extend, - buf_p); -} - - -static ssize_t -show_attr_rate_id(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_hex_attr(tobj_p, - tobj_p->get_rate_id, - buf_p); -} - - -static ssize_t -show_attr_temperature(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_curr_temp, - buf_p); -} - - -static ssize_t -show_attr_voltage(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_curr_vol, - buf_p); -} - - -static ssize_t -show_attr_tx_bias(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_tx_bias, - buf_p); -} - - -static ssize_t -show_attr_tx_power(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_tx_power, - buf_p); -} - - -static ssize_t -show_attr_tx_eq(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_tx_eq, - buf_p); -} - - -static ssize_t -show_attr_rx_power(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_rx_power, - buf_p); -} - - -static ssize_t -show_attr_rx_am(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_rx_am, - buf_p); -} - - -static ssize_t -show_attr_rx_em(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_rx_em, - buf_p); -} - - -static ssize_t -show_attr_wavelength(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_wavelength, - buf_p); -} - - -static ssize_t -show_attr_extphy_offset(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_extphy_offset, - buf_p); -} - - -static ssize_t -show_attr_extphy_reg(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_extphy_reg, - buf_p); -} - - -static ssize_t -show_attr_info(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_int_attr(tobj_p, - tobj_p->get_info, - buf_p); -} - - -static ssize_t -show_attr_if_type(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_if_type, - buf_p); -} - - -static ssize_t -show_attr_if_speed(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_if_speed, - buf_p); -} - - -static ssize_t -show_attr_if_lane(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_if_lane, - buf_p); -} - - -static ssize_t -show_attr_cdr(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_hex_attr(tobj_p, - tobj_p->get_cdr, - buf_p); -} - - -static ssize_t -show_attr_soft_rs0(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_int_attr(tobj_p, - tobj_p->get_soft_rs0, - buf_p); -} - - -static ssize_t -show_attr_soft_rs1(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_int_attr(tobj_p, - tobj_p->get_soft_rs1, - buf_p); -} - - -static ssize_t -show_attr_soft_rx_los(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_soft_rx_los, - buf_p); -} - - -static ssize_t -show_attr_soft_tx_disable(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_soft_tx_disable, - buf_p); -} - - -static ssize_t -show_attr_soft_tx_fault(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_soft_tx_fault, - buf_p); -} - - -static ssize_t -show_attr_auto_tx_disable(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_auto_tx_disable, - buf_p); -} - - -/* ========== Store functions: transceiver (R/W) attribute ========== - */ -static ssize_t -_store_transvr_int_attr(struct transvr_obj_s* tobj_p, - int (*set_func)(struct transvr_obj_s *tobj_p, int input_val), - const char *buf_p, - size_t count) { - int input, err; - - input = sscanf_2_int(buf_p); - if (input < 0){ - return -EBFONT; - } - lock_transvr_obj(tobj_p); - err = set_func(tobj_p, input); - unlock_transvr_obj(tobj_p); - if (err < 0){ - return err; - } - return count; -} - - -static ssize_t -_store_transvr_byte_hex_attr(struct transvr_obj_s* tobj_p, - int (*set_func)(struct transvr_obj_s *tobj_p, int input_val), - const char *buf_p, - size_t count) { - int input, err; - - input = sscanf_2_int(buf_p); - if ((input < 0) || (input > 0xff)){ - return -EBFONT; - } - lock_transvr_obj(tobj_p); - err = set_func(tobj_p, input); - unlock_transvr_obj(tobj_p); - if (err < 0){ - return err; - } - return count; -} - - -static ssize_t -_store_transvr_binary_attr(struct transvr_obj_s* tobj_p, - int (*set_func)(struct transvr_obj_s *tobj_p, int input_val), - const char *buf_p, - size_t count) { - int input, err; - - input = sscanf_2_binary(buf_p); - if (input < 0){ - return -EBFONT; - } - lock_transvr_obj(tobj_p); - err = set_func(tobj_p, input); - unlock_transvr_obj(tobj_p); - if (err < 0){ - return err; - } - return count; -} - - -static ssize_t -store_attr_cdr(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - return _store_transvr_byte_hex_attr(tobj_p, - tobj_p->set_cdr, - buf_p, - count); -} - - -static ssize_t -store_attr_soft_rs0(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - return _store_transvr_binary_attr(tobj_p, - tobj_p->set_soft_rs0, - buf_p, - count); -} - - -static ssize_t -store_attr_soft_rs1(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - return _store_transvr_binary_attr(tobj_p, - tobj_p->set_soft_rs1, - buf_p, - count); -} - - -static ssize_t -store_attr_soft_tx_disable(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count) { - - int check = sscanf_2_int(buf_p); - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - if ((check < 0) || (check > 0xf)){ - return -EBFONT; - } - return _store_transvr_byte_hex_attr(tobj_p, - tobj_p->set_soft_tx_disable, - buf_p, - count); -} - - -static ssize_t -store_attr_auto_tx_disable(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count) { - - int err = -EPERM; - int input = sscanf_2_int(buf_p); - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - if ((input < 0) || (input > 0xf)){ - if (input != VAL_TRANSVR_FUNCTION_DISABLE) { - return -EBFONT; - } - } - lock_transvr_obj(tobj_p); - err = tobj_p->set_auto_tx_disable(tobj_p, input); - unlock_transvr_obj(tobj_p); - if (err < 0){ - return err; - } - return count; -} - - -static ssize_t -store_attr_tx_eq(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - return _store_transvr_int_attr(tobj_p, - tobj_p->set_tx_eq, - buf_p, - count); -} - - -static ssize_t -store_attr_rx_am(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - return _store_transvr_int_attr(tobj_p, - tobj_p->set_rx_am, - buf_p, - count); -} - - -static ssize_t -store_attr_rx_em(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - return _store_transvr_int_attr(tobj_p, - tobj_p->set_rx_em, - buf_p, - count); -} - - -static ssize_t -store_attr_extphy_offset(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - return _store_transvr_int_attr(tobj_p, - tobj_p->set_extphy_offset, - buf_p, - count); -} - - -static ssize_t -store_attr_extphy_reg(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - return _store_transvr_int_attr(tobj_p, - tobj_p->set_extphy_reg, - buf_p, - count); -} - -/* ========== Show functions: For I/O Expander attribute ========== - */ -static ssize_t -_show_ioexp_binary_attr(struct transvr_obj_s *tobj_p, - int (*get_func)(struct ioexp_obj_s *ioexp_p, int voffset), - char *buf_p) { - size_t len; - struct ioexp_obj_s *ioexp_p = tobj_p->ioexp_obj_p; - - if (!ioexp_p) { - SWPS_ERR(" %s: data corruption! :%s\n", __func__, tobj_p->swp_name); - return -ENODATA; - } - mutex_lock(&ioexp_p->lock); - len = snprintf(buf_p, 8, "%d\n", get_func(ioexp_p, tobj_p->ioexp_virt_offset)); - mutex_unlock(&ioexp_p->lock); - return len; -} - - -static ssize_t -show_attr_present(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - return _show_ioexp_binary_attr(tobj_p, - tobj_p->ioexp_obj_p->get_present, - buf_p); -} - - -static ssize_t -show_attr_tx_fault(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - return _show_ioexp_binary_attr(tobj_p, - tobj_p->ioexp_obj_p->get_tx_fault, - buf_p); -} - - -static ssize_t -show_attr_rxlos(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - return _show_ioexp_binary_attr(tobj_p, - tobj_p->ioexp_obj_p->get_rxlos, - buf_p); -} - - -static ssize_t -show_attr_tx_disable(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - return _show_ioexp_binary_attr(tobj_p, - tobj_p->ioexp_obj_p->get_tx_disable, - buf_p); -} - - -static ssize_t -show_attr_reset(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - return _show_ioexp_binary_attr(tobj_p, - tobj_p->ioexp_obj_p->get_reset, - buf_p); -} - - -static ssize_t -show_attr_lpmod(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - return _show_ioexp_binary_attr(tobj_p, - tobj_p->ioexp_obj_p->get_lpmod, - buf_p); -} - - -static ssize_t -show_attr_modsel(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - return _show_ioexp_binary_attr(tobj_p, - tobj_p->ioexp_obj_p->get_modsel, - buf_p); -} - - -static ssize_t -show_attr_hard_rs0(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - return _show_ioexp_binary_attr(tobj_p, - tobj_p->ioexp_obj_p->get_hard_rs0, - buf_p); -} - - -static ssize_t -show_attr_hard_rs1(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - return _show_ioexp_binary_attr(tobj_p, - tobj_p->ioexp_obj_p->get_hard_rs1, - buf_p); -} - - -/* ========== Store functions: For I/O Expander (R/W) attribute ========== - */ -static ssize_t -_store_ioexp_binary_attr(struct transvr_obj_s *tobj_p, - int (*set_func)(struct ioexp_obj_s *ioexp_p, - int virt_offset, int input_val), - const char *buf_p, - size_t count) { - - int input, err; - struct ioexp_obj_s *ioexp_p = tobj_p->ioexp_obj_p; - - if (!ioexp_p) { - SWPS_ERR("%s: data corruption! :%s\n", - __func__, tobj_p->swp_name); - return -ENODATA; - } - input = sscanf_2_binary(buf_p); - if (input < 0) { - return -EBFONT; - } - mutex_lock(&ioexp_p->lock); - err = set_func(ioexp_p, tobj_p->ioexp_virt_offset, input); - mutex_unlock(&ioexp_p->lock); - if (err < 0){ - return err; - } - return count; -} - -static ssize_t -store_attr_tx_disable(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p) { - return -ENODEV; - } - return _store_ioexp_binary_attr(tobj_p, - tobj_p->ioexp_obj_p->set_tx_disable, - buf_p, - count); -} - - -static ssize_t -store_attr_reset(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p) { - return -ENODEV; - } - return _store_ioexp_binary_attr(tobj_p, - tobj_p->ioexp_obj_p->set_reset, - buf_p, - count); -} - - -static ssize_t -store_attr_lpmod(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p) { - return -ENODEV; - } - return _store_ioexp_binary_attr(tobj_p, - tobj_p->ioexp_obj_p->set_lpmod, - buf_p, - count); -} - - -static ssize_t -store_attr_modsel(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p) { - return -ENODEV; - } - return _store_ioexp_binary_attr(tobj_p, - tobj_p->ioexp_obj_p->set_modsel, - buf_p, - count); -} - - -static ssize_t -store_attr_hard_rs0(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p) { - return -ENODEV; - } - return _store_ioexp_binary_attr(tobj_p, - tobj_p->ioexp_obj_p->set_hard_rs0, - buf_p, - count); -} - - -static ssize_t -store_attr_hard_rs1(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p) { - return -ENODEV; - } - return _store_ioexp_binary_attr(tobj_p, - tobj_p->ioexp_obj_p->set_hard_rs1, - buf_p, - count); -} - - -/* ========== SWPS attribute: For module control ========== - */ -static DEVICE_ATTR(platform, S_IRUGO, show_attr_platform, NULL); -static DEVICE_ATTR(version, S_IRUGO, show_attr_version, NULL); -static DEVICE_ATTR(status, S_IRUGO, show_attr_status, NULL); -static DEVICE_ATTR(reset_i2c, S_IWUSR, NULL, store_attr_reset_i2c); -static DEVICE_ATTR(reset_swps, S_IWUSR, NULL, store_attr_reset_swps); -static DEVICE_ATTR(auto_config, S_IRUGO|S_IWUSR, show_attr_auto_config, store_attr_auto_config); -static DEVICE_ATTR(block_poll, S_IRUGO|S_IWUSR, show_attr_block_poll, store_attr_block_poll); -static DEVICE_ATTR(eeprom, S_IRUGO, show_attr_eeprom, NULL); -static DEVICE_ATTR(eeprom_update, S_IRUGO|S_IWUSR, show_attr_eeprom_update, store_attr_eeprom_update); - -/* ========== Transceiver attribute: from eeprom ========== - */ -static DEVICE_ATTR(id, S_IRUGO, show_attr_id, NULL); -static DEVICE_ATTR(ext_id, S_IRUGO, show_attr_ext_id, NULL); -static DEVICE_ATTR(connector, S_IRUGO, show_attr_connector, NULL); -static DEVICE_ATTR(vendor_name, S_IRUGO, show_attr_vendor_name, NULL); -static DEVICE_ATTR(vendor_pn, S_IRUGO, show_attr_vendor_pn, NULL); -static DEVICE_ATTR(vendor_rev, S_IRUGO, show_attr_vendor_rev, NULL); -static DEVICE_ATTR(vendor_sn, S_IRUGO, show_attr_vendor_sn, NULL); -static DEVICE_ATTR(power_cls, S_IRUGO, show_attr_power_cls, NULL); -static DEVICE_ATTR(br, S_IRUGO, show_attr_br, NULL); -static DEVICE_ATTR(len_sm, S_IRUGO, show_attr_len_sm, NULL); -static DEVICE_ATTR(len_smf, S_IRUGO, show_attr_len_smf, NULL); -static DEVICE_ATTR(len_om1, S_IRUGO, show_attr_len_om1, NULL); -static DEVICE_ATTR(len_om2, S_IRUGO, show_attr_len_om2, NULL); -static DEVICE_ATTR(len_om3, S_IRUGO, show_attr_len_om3, NULL); -static DEVICE_ATTR(len_om4, S_IRUGO, show_attr_len_om4, NULL); -static DEVICE_ATTR(comp_rev, S_IRUGO, show_attr_comp_rev, NULL); -static DEVICE_ATTR(comp_eth, S_IRUGO, show_attr_comp_eth, NULL); -static DEVICE_ATTR(comp_eth_10, S_IRUGO, show_attr_comp_eth_10, NULL); -static DEVICE_ATTR(comp_eth_10_40, S_IRUGO, show_attr_comp_eth_10_40, NULL); -static DEVICE_ATTR(comp_extend, S_IRUGO, show_attr_comp_extend, NULL); -static DEVICE_ATTR(rate_id, S_IRUGO, show_attr_rate_id, NULL); -static DEVICE_ATTR(temperature, S_IRUGO, show_attr_temperature, NULL); -static DEVICE_ATTR(voltage, S_IRUGO, show_attr_voltage, NULL); -static DEVICE_ATTR(tx_bias, S_IRUGO, show_attr_tx_bias, NULL); -static DEVICE_ATTR(tx_power, S_IRUGO, show_attr_tx_power, NULL); -static DEVICE_ATTR(rx_power, S_IRUGO, show_attr_rx_power, NULL); -static DEVICE_ATTR(info, S_IRUGO, show_attr_info, NULL); -static DEVICE_ATTR(if_type, S_IRUGO, show_attr_if_type, NULL); -static DEVICE_ATTR(if_speed, S_IRUGO, show_attr_if_speed, NULL); -static DEVICE_ATTR(if_lane, S_IRUGO, show_attr_if_lane, NULL); -static DEVICE_ATTR(soft_rx_los, S_IRUGO, show_attr_soft_rx_los, NULL); -static DEVICE_ATTR(soft_tx_fault, S_IRUGO, show_attr_soft_tx_fault, NULL); -static DEVICE_ATTR(wavelength, S_IRUGO, show_attr_wavelength, NULL); -static DEVICE_ATTR(tx_eq, S_IRUGO|S_IWUSR, show_attr_tx_eq, store_attr_tx_eq); -static DEVICE_ATTR(rx_am, S_IRUGO|S_IWUSR, show_attr_rx_am, store_attr_rx_am); -static DEVICE_ATTR(rx_em, S_IRUGO|S_IWUSR, show_attr_rx_em, store_attr_rx_em); -static DEVICE_ATTR(cdr, S_IRUGO|S_IWUSR, show_attr_cdr, store_attr_cdr); -static DEVICE_ATTR(soft_rs0, S_IRUGO|S_IWUSR, show_attr_soft_rs0, store_attr_soft_rs0); -static DEVICE_ATTR(soft_rs1, S_IRUGO|S_IWUSR, show_attr_soft_rs1, store_attr_soft_rs1); -static DEVICE_ATTR(soft_tx_disable, S_IRUGO|S_IWUSR, show_attr_soft_tx_disable, store_attr_soft_tx_disable); -static DEVICE_ATTR(auto_tx_disable, S_IRUGO|S_IWUSR, show_attr_auto_tx_disable, store_attr_auto_tx_disable); -static DEVICE_ATTR(extphy_offset, S_IRUGO|S_IWUSR, show_attr_extphy_offset, store_attr_extphy_offset); -static DEVICE_ATTR(extphy_reg, S_IRUGO|S_IWUSR, show_attr_extphy_reg, store_attr_extphy_reg); - -/* ========== IO Expander attribute: from expander ========== - */ -static DEVICE_ATTR(present, S_IRUGO, show_attr_present, NULL); -static DEVICE_ATTR(tx_fault, S_IRUGO, show_attr_tx_fault, NULL); -static DEVICE_ATTR(rxlos, S_IRUGO, show_attr_rxlos, NULL); -static DEVICE_ATTR(tx_disable, S_IRUGO|S_IWUSR, show_attr_tx_disable, store_attr_tx_disable); -static DEVICE_ATTR(reset, S_IRUGO|S_IWUSR, show_attr_reset, store_attr_reset); -static DEVICE_ATTR(lpmod, S_IRUGO|S_IWUSR, show_attr_lpmod, store_attr_lpmod); -static DEVICE_ATTR(modsel, S_IRUGO|S_IWUSR, show_attr_modsel, store_attr_modsel); -static DEVICE_ATTR(hard_rs0, S_IRUGO|S_IWUSR, show_attr_hard_rs0, store_attr_hard_rs0); -static DEVICE_ATTR(hard_rs1, S_IRUGO|S_IWUSR, show_attr_hard_rs1, store_attr_hard_rs1); - -/* ========== Functions for module handling ========== - */ -static void -clean_port_objs(void){ - - dev_t dev_num; - char dev_name[32]; - struct device *device_p; - struct transvr_obj_s *tobj_p; - int minor_curr, port_id; - - for (minor_curr=0; minor_curri2c_client_p) { - i2c_put_adapter(tobj_p->i2c_client_p->adapter); - kfree(tobj_p->i2c_client_p); - } - kfree(tobj_p->vendor_name); - kfree(tobj_p->vendor_pn); - kfree(tobj_p->vendor_rev); - kfree(tobj_p->vendor_sn); - kfree(tobj_p->worker_p); - kfree(tobj_p); - } - dev_num = MKDEV(port_major, minor_curr); - device_unregister(device_p); - device_destroy(swp_class_p, dev_num); - } - SWPS_DEBUG("%s: done.\n", __func__); -} - - -static void -clean_swps_common(void){ - - dev_t dev_num; - struct device *device_p; - - device_p = get_swpdev_by_name(SWP_DEV_MODCTL); - if (device_p){ - dev_num = MKDEV(ctl_major, 1); - device_unregister(device_p); - device_destroy(swp_class_p, dev_num); - } - cancel_delayed_work_sync(&swp_polling); - if (platform_p) { - kfree(platform_p); - } - SWPS_DEBUG("%s: done.\n", __func__); -} - - -static int -get_platform_type(void){ - - int i, tmp; - int auto_chan = -1; - int auto_addr = -1; - int pf_total = ARRAY_SIZE(platform_map); - char log_msg[64] = "ERROR"; - - platform_p = kzalloc(sizeof(struct inv_platform_s), GFP_KERNEL); - if (!platform_p){ - snprintf(log_msg, sizeof(log_msg), "kzalloc fail"); - goto err_get_platform_type_1; - } - memset(platform_p->name, 0, sizeof(platform_p->name)); - - switch (PLATFORM_SETTINGS) { - case PLATFORM_TYPE_AUTO: - snprintf(platform_p->name, (sizeof(platform_p->name) - 1), - "%s", dmi_get_system_info(DMI_BOARD_NAME)); - for (i=0; iname, platform_map[i].name) == 0) { - platform_p->id = platform_map[i].id; - snprintf(log_msg, sizeof(log_msg), - "Auto detect platform: %d (%s)", - platform_p->id, platform_p->name); - goto ok_get_platform_type_1; - } - } - snprintf(log_msg, sizeof(log_msg), - "Auto detect fail! detect platform: %s", - platform_p->name); - goto err_get_platform_type_2; - - case PLATFORM_TYPE_PEONY_AUTO: -#ifdef SWPS_PEONY_SFP - auto_chan = peony_sfp_ioexp_layout[0].addr[0].chan_id; - auto_addr = peony_sfp_ioexp_layout[0].addr[0].chip_addr; -#endif - tmp = _is_i2c_target_exist(auto_chan, auto_addr); - switch (tmp) { - case 0: /* Copper SKU */ - SWPS_INFO("Auto-detected :Peony :Copper\n"); - platform_p->id = PLATFORM_TYPE_PEONY_COPPER_GA; - goto map_platform_name; - - case 1: /* SFP SKU */ - SWPS_INFO("Auto-detected :Peony :SFP\n"); - platform_p->id = PLATFORM_TYPE_PEONY_SFP_GA; - goto map_platform_name; - - default: - break; - } - snprintf(log_msg, sizeof(log_msg), - "Auto detect Peony SKU fail! :%d", tmp); - goto err_get_platform_type_2; - - case PLATFORM_TYPE_MAGNOLIA: - case PLATFORM_TYPE_MAGNOLIA_FNC: - case PLATFORM_TYPE_REDWOOD: - case PLATFORM_TYPE_REDWOOD_FSL: - case PLATFORM_TYPE_HUDSON32I_GA: - case PLATFORM_TYPE_SPRUCE: - case PLATFORM_TYPE_CYPRESS_GA1: - case PLATFORM_TYPE_CYPRESS_GA2: - case PLATFORM_TYPE_CYPRESS_BAI: - case PLATFORM_TYPE_TAHOE: - case PLATFORM_TYPE_SEQUOIA_GA: - case PLATFORM_TYPE_LAVENDER_GA: - case PLATFORM_TYPE_LAVENDER_ONL: - case PLATFORM_TYPE_COTTONWOOD_RANGELEY: - case PLATFORM_TYPE_MAPLE_GA: - case PLATFORM_TYPE_MAPLE_B: - case PLATFORM_TYPE_GULMOHAR_GA: - case PLATFORM_TYPE_PEONY_SFP_GA: - case PLATFORM_TYPE_PEONY_COPPER_GA: - platform_p->id = PLATFORM_SETTINGS; - goto map_platform_name; - - default: - break; - } - snprintf(log_msg, sizeof(log_msg), - "PLATFORM_SETTINGS:%d undefined", PLATFORM_SETTINGS); - goto err_get_platform_type_2; - -map_platform_name: - for (i=0; iid == platform_map[i].id) { - snprintf(platform_p->name, (sizeof(platform_p->name) - 1), - "%s", platform_map[i].name); - snprintf(log_msg, sizeof(log_msg), - "User setup platform: %d (%s)", - platform_p->id, platform_p->name); - goto ok_get_platform_type_1; - } - } - snprintf(log_msg, sizeof(log_msg), - "Internal error, can not map id:%d", - platform_p->id ); - goto err_get_platform_type_2; - -ok_get_platform_type_1: - SWPS_DEBUG("%s: %s, :%d\n", __func__, log_msg, PLATFORM_SETTINGS); - return 0; - -err_get_platform_type_2: - kfree(platform_p); -err_get_platform_type_1: - SWPS_ERR("%s: %s :%d\n", __func__, log_msg, PLATFORM_SETTINGS); - return -1; -} - - -static int -get_layout_info(void){ - - switch (platform_p->id) { -#ifdef SWPS_MAGNOLIA - case PLATFORM_TYPE_MAGNOLIA: - case PLATFORM_TYPE_MAGNOLIA_FNC: - gpio_rest_mux = magnolia_gpio_rest_mux; - ioexp_layout = magnolia_ioexp_layout; - port_layout = magnolia_port_layout; - ioexp_total = ARRAY_SIZE(magnolia_ioexp_layout); - port_total = ARRAY_SIZE(magnolia_port_layout); - break; -#endif -#ifdef SWPS_REDWOOD - case PLATFORM_TYPE_REDWOOD: - gpio_rest_mux = redwood_gpio_rest_mux; - ioexp_layout = redwood_ioexp_layout; - port_layout = redwood_port_layout; - ioexp_total = ARRAY_SIZE(redwood_ioexp_layout); - port_total = ARRAY_SIZE(redwood_port_layout); - break; -#endif -#ifdef SWPS_HUDSON32I_GA - case PLATFORM_TYPE_HUDSON32I_GA: - gpio_rest_mux = hudsin32iga_gpio_rest_mux; - ioexp_layout = hudson32iga_ioexp_layout; - port_layout = hudson32iga_port_layout; - ioexp_total = ARRAY_SIZE(hudson32iga_ioexp_layout); - port_total = ARRAY_SIZE(hudson32iga_port_layout); - break; -#endif -#ifdef SWPS_SPRUCE - case PLATFORM_TYPE_SPRUCE: - gpio_rest_mux = spruce_gpio_rest_mux; - ioexp_layout = spruce_ioexp_layout; - port_layout = spruce_port_layout; - ioexp_total = ARRAY_SIZE(spruce_ioexp_layout); - port_total = ARRAY_SIZE(spruce_port_layout); - break; -#endif -#ifdef SWPS_CYPRESS_GA1 - case PLATFORM_TYPE_CYPRESS_GA1: - gpio_rest_mux = cypress_ga1_gpio_rest_mux; - ioexp_layout = cypress_ga1_ioexp_layout; - port_layout = cypress_ga1_port_layout; - ioexp_total = ARRAY_SIZE(cypress_ga1_ioexp_layout); - port_total = ARRAY_SIZE(cypress_ga1_port_layout); - break; -#endif -#ifdef SWPS_CYPRESS_GA2 - case PLATFORM_TYPE_CYPRESS_GA2: - gpio_rest_mux = cypress_ga2_gpio_rest_mux; - ioexp_layout = cypress_ga2_ioexp_layout; - port_layout = cypress_ga2_port_layout; - ioexp_total = ARRAY_SIZE(cypress_ga2_ioexp_layout); - port_total = ARRAY_SIZE(cypress_ga2_port_layout); - break; -#endif -#ifdef SWPS_CYPRESS_BAI - case PLATFORM_TYPE_CYPRESS_BAI: - gpio_rest_mux = cypress_b_gpio_rest_mux; - ioexp_layout = cypress_b_ioexp_layout; - port_layout = cypress_b_port_layout; - ioexp_total = ARRAY_SIZE(cypress_b_ioexp_layout); - port_total = ARRAY_SIZE(cypress_b_port_layout); - break; -#endif -#ifdef SWPS_REDWOOD_FSL - case PLATFORM_TYPE_REDWOOD_FSL: - gpio_rest_mux = redwood_fsl_gpio_rest_mux; - ioexp_layout = redwood_fsl_ioexp_layout; - port_layout = redwood_fsl_port_layout; - ioexp_total = ARRAY_SIZE(redwood_fsl_ioexp_layout); - port_total = ARRAY_SIZE(redwood_fsl_port_layout); - break; -#endif -#ifdef SWPS_TAHOE - case PLATFORM_TYPE_TAHOE: - gpio_rest_mux = tahoe_gpio_rest_mux; - ioexp_layout = tahoe_ioexp_layout; - port_layout = tahoe_port_layout; - ioexp_total = ARRAY_SIZE(tahoe_ioexp_layout); - port_total = ARRAY_SIZE(tahoe_port_layout); - break; -#endif -#ifdef SWPS_SEQUOIA - case PLATFORM_TYPE_SEQUOIA_GA: - gpio_rest_mux = sequoia_gpio_rest_mux; - ioexp_layout = sequoia_ioexp_layout; - port_layout = sequoia_port_layout; - ioexp_total = ARRAY_SIZE(sequoia_ioexp_layout); - port_total = ARRAY_SIZE(sequoia_port_layout); - break; -#endif -#ifdef SWPS_LAVENDER - case PLATFORM_TYPE_LAVENDER_GA: - case PLATFORM_TYPE_LAVENDER_ONL: - gpio_rest_mux = lavender_gpio_rest_mux; - ioexp_layout = lavender_ioexp_layout; - port_layout = lavender_port_layout; - ioexp_total = ARRAY_SIZE(lavender_ioexp_layout); - port_total = ARRAY_SIZE(lavender_port_layout); - break; -#endif -#ifdef SWPS_COTTONWOOD_RANGELEY - case PLATFORM_TYPE_COTTONWOOD_RANGELEY: - gpio_rest_mux = cottonwood_rangeley_gpio_rest_mux; - ioexp_layout = cottonwood_rangeley_ioexp_layout; - port_layout = cottonwood_rangeley_port_layout; - ioexp_total = ARRAY_SIZE(cottonwood_rangeley_ioexp_layout); - port_total = ARRAY_SIZE(cottonwood_rangeley_port_layout); - break; -#endif -#ifdef SWPS_MAPLE_GA - case PLATFORM_TYPE_MAPLE_GA: - gpio_rest_mux = maple_ga_gpio_rest_mux; - ioexp_layout = maple_ga_ioexp_layout; - port_layout = maple_ga_port_layout; - ioexp_total = ARRAY_SIZE(maple_ga_ioexp_layout); - port_total = ARRAY_SIZE(maple_ga_port_layout); - break; -#endif -#ifdef SWPS_MAPLE_B - case PLATFORM_TYPE_MAPLE_B: - gpio_rest_mux = maple_b_gpio_rest_mux; - ioexp_layout = maple_b_ioexp_layout; - port_layout = maple_b_port_layout; - ioexp_total = ARRAY_SIZE(maple_b_ioexp_layout); - port_total = ARRAY_SIZE(maple_b_port_layout); - break; -#endif -#ifdef SWPS_GULMOHAR - case PLATFORM_TYPE_GULMOHAR_GA: - gpio_rest_mux = gulmohar_gpio_rest_mux; - ioexp_layout = gulmohar_ioexp_layout; - port_layout = gulmohar_port_layout; - ioexp_total = ARRAY_SIZE(gulmohar_ioexp_layout); - port_total = ARRAY_SIZE(gulmohar_port_layout); - break; -#endif -#ifdef SWPS_PEONY_SFP - case PLATFORM_TYPE_PEONY_SFP_GA: - gpio_rest_mux = peony_sfp_gpio_rest_mux; - ioexp_layout = peony_sfp_ioexp_layout; - port_layout = peony_sfp_port_layout; - ioexp_total = ARRAY_SIZE(peony_sfp_ioexp_layout); - port_total = ARRAY_SIZE(peony_sfp_port_layout); - break; -#endif -#ifdef SWPS_PEONY_COPPER - case PLATFORM_TYPE_PEONY_COPPER_GA: - gpio_rest_mux = peony_copper_gpio_rest_mux; - ioexp_layout = peony_copper_ioexp_layout; - port_layout = peony_copper_port_layout; - ioexp_total = ARRAY_SIZE(peony_copper_ioexp_layout); - port_total = ARRAY_SIZE(peony_copper_port_layout); - break; -#endif - - default: - SWPS_ERR(" Invalid platform: %d (%s)\n", - platform_p->id, platform_p->name); - return -1; - } - SWPS_INFO("Start to initial platform: %d (%s)\n", - platform_p->id, platform_p->name); - return 0; -} - - -/* ========== Functions for objects operations ========== - */ -static int -__detect_issues_port(int minor_num) { - - struct transvr_obj_s *tobj_p; - int port_id = port_layout[minor_num].port_id; - char port_name[32] = "ERR"; - char *i2c_emsg = "detected bad transceiver/cable"; - - memset(port_name, 0, sizeof(port_name)); - snprintf(port_name, sizeof(port_name), "%s%d", SWP_DEV_PORT, port_id); - tobj_p = _get_transvr_obj(port_name); - if (!tobj_p) { - SWPS_INFO("%s: tobj_p is NULL :%d\n", __func__, minor_num); - return -1; - } - if (resync_channel_tier_2(tobj_p) < 0) { - if (check_channel_tier_1() < 0) { - goto get_target_issues_port; - } - } - /* Re-check again for i2c-gpio special case */ - if (check_channel_tier_1() < 0) { - goto get_target_issues_port; - } - return 0; - -get_target_issues_port: - alarm_msg_2_user(tobj_p, i2c_emsg); - return -2; -} - - -static int -_detect_issues_port(void) { - /* OK : retrun -1; - * Fail: return fail at which minor number (0~N) - */ - char *emsg = "ERR"; - int minor = 0; - int minor_2st = 1; - - /* Force moving the initial channel pointer - * Filter out case of fail at minor-0 port - */ - while (minor_2st < port_total) { - minor = minor_2st; - if (__detect_issues_port(minor_2st) < 0) { - emsg = "detect minor_2st fail"; - goto err_p_detect_issues_port; - } - minor_2st += 8; - } - /* Scan all port */ - for (minor=0; minor:%d\n", __func__, emsg, minor_err); - return -1; -} - - -static int -check_transvr_obj_one(char *dev_name){ - /* [Return] - * 0 : Doesn't need to take care - * -1 : Single error - * -2 : Critical error (I2C topology die) - * -9 : Internal error - */ - struct transvr_obj_s *tobj_p = NULL; - int retval = -9; - - tobj_p = _get_transvr_obj(dev_name); - if (!tobj_p) { - SWPS_ERR("%s: %s _get_transvr_obj fail\n", - __func__, dev_name); - return -9; - } - /* Check transceiver current status */ - lock_transvr_obj(tobj_p); - retval = tobj_p->check(tobj_p); - unlock_transvr_obj(tobj_p); - switch (retval) { - case 0: - case ERR_TRANSVR_UNPLUGGED: - case ERR_TRNASVR_BE_ISOLATED: - case ERR_TRANSVR_TASK_BUSY: - return 0; - - case ERR_TRANSVR_I2C_CRASH: - default: - break; - } - /* Identify abnormal case */ - if (check_channel_tier_1() < 0) { - SWPS_DEBUG("%s: %s critical error :%d\n", - __func__, dev_name, retval); - return -2; - } - SWPS_DEBUG("%s: %s single error :%d\n", - __func__, dev_name, retval); - return -1; -} - - -static int -check_transvr_objs(void){ - - char dev_name[32]; - int port_id, err_code; - int minor_curr = 0; - - for (minor_curr=0; minor_curr:%d\n", - __func__, dev_name, err_code); - break; - } - } - return 0; - -err_check_transvr_objs: - SWPS_ERR("%s: %s reset_i2c_topology fail.\n", - __func__, dev_name); - return -1; -} - - -static void -swp_polling_worker(struct work_struct *work){ - - /* Reset I2C */ - if (flag_i2c_reset) { - goto polling_reset_i2c; - } - /* Check IOEXP */ - if (check_ioexp_objs() < 0) { - goto polling_reset_i2c; - } - /* Check transceiver */ - if (check_transvr_objs() < 0) { - SWPS_DEBUG("%s: check_transvr_objs fail.\n", __func__); - flag_i2c_reset = 1; - } - goto polling_schedule_round; - -polling_reset_i2c: - SWPS_DEBUG("%s: reset_i2c_topology start.\n", __func__); - if (reset_i2c_topology() < 0) { - SWPS_ERR("%s: reset i2c fail!\n", __func__); - flag_i2c_reset = 1; - } else { - SWPS_DEBUG("%s: reset_i2c_topology OK.\n", __func__); - flag_i2c_reset = 0; - } -polling_schedule_round: - schedule_delayed_work(&swp_polling, _get_polling_period()); -} - - -/* ========== Functions for register something ========== - */ -static int -register_transvr_common_attr(struct device *device_p){ - - char *err_attr = NULL; - - if (device_create_file(device_p, &dev_attr_id) < 0) { - err_attr = "dev_attr_id"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_ext_id) < 0) { - err_attr = "dev_attr_ext_id"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_connector) < 0) { - err_attr = "dev_attr_connector"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_vendor_name) < 0) { - err_attr = "dev_attr_vendor_name"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_vendor_pn) < 0) { - err_attr = "dev_attr_vendor_pn"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_vendor_rev) < 0) { - err_attr = "dev_attr_vendor_rev"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_vendor_sn) < 0) { - err_attr = "dev_attr_vendor_sn"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_br) < 0) { - err_attr = "dev_attr_br"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_len_smf) < 0) { - err_attr = "dev_attr_len_smf"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_len_om1) < 0) { - err_attr = "dev_attr_len_om1"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_len_om2) < 0) { - err_attr = "dev_attr_len_om2"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_len_om3) < 0) { - err_attr = "dev_attr_len_om3"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_len_om4) < 0) { - err_attr = "dev_attr_len_om4"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_comp_extend) < 0) { - err_attr = "dev_attr_comp_extend"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_comp_eth) < 0) { - err_attr = "dev_attr_comp_eth"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_comp_rev) < 0) { - err_attr = "dev_attr_comp_rev"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_info) < 0) { - err_attr = "dev_attr_info"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_if_type) < 0) { - err_attr = "dev_attr_if_type"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_if_speed) < 0) { - err_attr = "dev_attr_if_speed"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_if_lane) < 0) { - err_attr = "dev_attr_if_lane"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_temperature) < 0) { - err_attr = "dev_attr_temperature"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_voltage) < 0) { - err_attr = "dev_attr_voltage"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_tx_bias) < 0) { - err_attr = "dev_attr_tx_bias"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_tx_power) < 0) { - err_attr = "dev_attr_tx_power"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_rx_power) < 0) { - err_attr = "dev_attr_rx_power"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_tx_eq) < 0) { - err_attr = "dev_attr_tx_eq"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_rx_em) < 0) { - err_attr = "dev_attr_rx_em"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_wavelength) < 0) { - err_attr = "dev_attr_wavelength"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_eeprom) < 0) { - err_attr = "dev_attr_eeprom"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_eeprom_update) < 0) { - err_attr = "dev_attr_eeprom_update"; - goto err_transvr_comm_attr; - } - return 0; - -err_transvr_comm_attr: - SWPS_ERR("%s: %s\n", __func__, err_attr); - return -1; -} - -static int -register_transvr_sfp_attr(struct device *device_p){ - - char *err_attr = NULL; - - if (register_transvr_common_attr(device_p) < 0) { - err_attr = "register_transvr_common_attr"; - goto err_transvr_sfp_attr; - } - if (device_create_file(device_p, &dev_attr_comp_eth_10) < 0) { - err_attr = "dev_attr_comp_eth_10"; - goto err_transvr_sfp_attr; - } - if (device_create_file(device_p, &dev_attr_len_sm) < 0) { - err_attr = "dev_attr_len_sm"; - goto err_transvr_sfp_attr; - } - if (device_create_file(device_p, &dev_attr_rate_id) < 0) { - err_attr = "dev_attr_rate_id"; - goto err_transvr_sfp_attr; - } - if (device_create_file(device_p, &dev_attr_soft_rs0) < 0) { - err_attr = "dev_attr_soft_rs0"; - goto err_transvr_sfp_attr; - } - if (device_create_file(device_p, &dev_attr_soft_rs1) < 0) { - err_attr = "dev_attr_soft_rs1"; - goto err_transvr_sfp_attr; - } - if (device_create_file(device_p, &dev_attr_extphy_offset) < 0) { - err_attr = "dev_attr_extphy_offset"; - goto err_transvr_sfp_attr; - } - if (device_create_file(device_p, &dev_attr_extphy_reg) < 0) { - err_attr = "dev_attr_extphy_reg"; - goto err_transvr_sfp_attr; - } - return 0; - -err_transvr_sfp_attr: - SWPS_ERR("%s: %s\n", __func__, err_attr); - return -1; -} - - -static int -register_transvr_qsfp_attr(struct device *device_p){ - - char *err_attr = NULL; - - if (register_transvr_common_attr(device_p) < 0) { - err_attr = "register_transvr_common_attr"; - goto err_transvr_qsfp_attr; - } - if (device_create_file(device_p, &dev_attr_comp_eth_10_40) < 0) { - err_attr = "dev_attr_comp_eth_10_40"; - goto err_transvr_qsfp_attr; - } - if (device_create_file(device_p, &dev_attr_power_cls) < 0) { - err_attr = "dev_attr_power_cls"; - goto err_transvr_qsfp_attr; - } - if (device_create_file(device_p, &dev_attr_soft_rx_los) < 0) { - err_attr = "soft_rx_los"; - goto err_transvr_qsfp_attr; - } - if (device_create_file(device_p, &dev_attr_soft_tx_disable) < 0) { - err_attr = "soft_tx_disable"; - goto err_transvr_qsfp_attr; - } - if (device_create_file(device_p, &dev_attr_auto_tx_disable) < 0) { - err_attr = "auto_tx_disable"; - goto err_transvr_qsfp_attr; - } - if (device_create_file(device_p, &dev_attr_soft_tx_fault) < 0) { - err_attr = "soft_tx_fault"; - goto err_transvr_qsfp_attr; - } - return 0; - -err_transvr_qsfp_attr: - SWPS_ERR("%s: %s\n", __func__, err_attr); - return -1; -} - - -static int -register_transvr_qsfp28_attr(struct device *device_p){ - - char *err_attr = NULL; - - if (register_transvr_qsfp_attr(device_p) < 0){ - err_attr = "register_transvr_qsfp_attr"; - goto err_transvr_qsfp28_attr; - } - if (device_create_file(device_p, &dev_attr_cdr) < 0) { - err_attr = "dev_attr_cdr"; - goto err_transvr_qsfp28_attr; - } - if (device_create_file(device_p, &dev_attr_rx_am) < 0) { - err_attr = "dev_attr_rx_am"; - goto err_transvr_qsfp28_attr; - } - return 0; - -err_transvr_qsfp28_attr: - SWPS_ERR("%s: %s\n", __func__, err_attr); - return -1; -} - - -static int -register_transvr_attr(struct device *device_p, - struct transvr_obj_s *transvr_obj){ - - switch (transvr_obj->layout){ - case TRANSVR_TYPE_SFP: - if (register_transvr_sfp_attr(device_p) < 0){ - goto err_reg_tvr_attr; - } - break; - case TRANSVR_TYPE_QSFP: - case TRANSVR_TYPE_QSFP_PLUS: - if (register_transvr_qsfp_attr(device_p) < 0){ - goto err_reg_tvr_attr; - } - break; - case TRANSVR_TYPE_QSFP_28: - if (register_transvr_qsfp28_attr(device_p) < 0){ - goto err_reg_tvr_attr; - } - break; - default: - goto err_reg_tvr_attr; - } - return 0; - -err_reg_tvr_attr: - SWPS_ERR("%s: fail! type=%d \n", __func__, transvr_obj->type); - return -1; -} - - -static int -register_ioexp_attr_sfp_1(struct device *device_p){ - /* Support machine type: - * - SFP : Magnolia - */ - char *err_attr = NULL; - - if (device_create_file(device_p, &dev_attr_present) < 0) { - err_attr = "dev_attr_present"; - goto err_ioexp_sfp1_attr; - } - if (device_create_file(device_p, &dev_attr_tx_fault) < 0) { - err_attr = "dev_attr_tx_fault"; - goto err_ioexp_sfp1_attr; - } - if (device_create_file(device_p, &dev_attr_rxlos) < 0) { - err_attr = "dev_attr_rxlos"; - goto err_ioexp_sfp1_attr; - } - if (device_create_file(device_p, &dev_attr_tx_disable) < 0) { - err_attr = "dev_attr_tx_disable"; - goto err_ioexp_sfp1_attr; - } - return 0; - -err_ioexp_sfp1_attr: - SWPS_ERR("Add device attribute:%s failure! \n",err_attr); - return -1; -} - - -static int -register_ioexp_attr_sfp_2(struct device *device_p){ - /* Support machine type: - * - SFP28 : Cypress - */ - char *err_attr = NULL; - - if (register_ioexp_attr_sfp_1(device_p) < 0){ - goto err_ioexp_sfp2_attr; - } - if (device_create_file(device_p, &dev_attr_hard_rs0) < 0) { - err_attr = "dev_attr_hard_rs0"; - goto err_ioexp_sfp2_attr; - } - if (device_create_file(device_p, &dev_attr_hard_rs1) < 0) { - err_attr = "dev_attr_hard_rs1"; - goto err_ioexp_sfp2_attr; - } - return 0; - -err_ioexp_sfp2_attr: - SWPS_ERR("Add device attribute:%s failure! \n",err_attr); - return -1; -} - - -static int -register_ioexp_attr_qsfp_1(struct device *device_p){ - /* Support machine type: - * - QSFP : Magnolia, Redwood, Hudson32i - * - QSFP+ : Magnolia, Redwood, Hudson32i - * - QSFP28: Redwood - */ - char *err_attr = NULL; - - if (device_create_file(device_p, &dev_attr_present) < 0) { - err_attr = "dev_attr_present"; - goto err_ioexp_qsfp1_attr; - } - if (device_create_file(device_p, &dev_attr_reset) < 0) { - err_attr = "dev_attr_reset"; - goto err_ioexp_qsfp1_attr; - } - if (device_create_file(device_p, &dev_attr_lpmod) < 0) { - err_attr = "dev_attr_lpmod"; - goto err_ioexp_qsfp1_attr; - } - if (device_create_file(device_p, &dev_attr_modsel) < 0) { - err_attr = "dev_attr_modsel"; - goto err_ioexp_qsfp1_attr; - } - return 0; - -err_ioexp_qsfp1_attr: - SWPS_ERR("Add device attribute:%s failure! \n",err_attr); - return -1; -} - - -static int -register_modctl_attr(struct device *device_p){ - - char *err_msg = NULL; - - if (device_create_file(device_p, &dev_attr_platform) < 0) { - err_msg = "dev_attr_platform"; - goto err_reg_modctl_attr; - } - if (device_create_file(device_p, &dev_attr_version) < 0) { - err_msg = "dev_attr_version"; - goto err_reg_modctl_attr; - } - if (device_create_file(device_p, &dev_attr_status) < 0) { - err_msg = "dev_attr_status"; - goto err_reg_modctl_attr; - } - if (device_create_file(device_p, &dev_attr_reset_i2c) < 0) { - err_msg = "dev_attr_reset_i2c"; - goto err_reg_modctl_attr; - } - if (device_create_file(device_p, &dev_attr_reset_swps) < 0) { - err_msg = "dev_attr_reset_swps"; - goto err_reg_modctl_attr; - } - if (device_create_file(device_p, &dev_attr_auto_config) < 0) { - err_msg = "dev_attr_auto_config"; - goto err_reg_modctl_attr; - } - if (device_create_file(device_p, &dev_attr_block_poll) < 0) { - err_msg = "dev_attr_block_poll"; - goto err_reg_modctl_attr; - } - if (device_create_file(device_p, &dev_attr_eeprom_update) < 0) { - err_msg = "dev_attr_eeprom_update"; - goto err_reg_modctl_attr; - } - return 0; - -err_reg_modctl_attr: - SWPS_ERR("%s: %s\n", __func__, err_msg); - return -1; -} - - -static int -register_ioexp_attr(struct device *device_p, - struct transvr_obj_s *transvr_obj){ - - char *err_msg = "ERR"; - - switch (transvr_obj->ioexp_obj_p->ioexp_type){ - case IOEXP_TYPE_MAGINOLIA_NAB: - case IOEXP_TYPE_MAGINOLIA_4AB: - case CPLD_TYPE_COTTONWOOD: - if (register_ioexp_attr_sfp_1(device_p) < 0){ - err_msg = "register_ioexp_attr_sfp_1 fail"; - goto err_reg_ioexp_attr; - } - break; - - case IOEXP_TYPE_MAPLE_NABC: - case IOEXP_TYPE_GULMOHAR_NABC: - case IOEXP_TYPE_SFP_8P_LAYOUT_1: - if (register_ioexp_attr_sfp_2(device_p) < 0){ - err_msg = "register_ioexp_attr_sfp_2 fail"; - goto err_reg_ioexp_attr; - } - break; - - case IOEXP_TYPE_MAGINOLIA_7AB: - case IOEXP_TYPE_SPRUCE_7AB: - case IOEXP_TYPE_CYPRESS_7ABC: - case IOEXP_TYPE_REDWOOD_P01P08: - case IOEXP_TYPE_REDWOOD_P09P16: - case IOEXP_TYPE_HUDSON32IGA_P01P08: - case IOEXP_TYPE_HUDSON32IGA_P09P16: - case IOEXP_TYPE_TAHOE_5A: - case IOEXP_TYPE_TAHOE_6ABC: - case IOEXP_TYPE_SEQUOIA_NABC: - case IOEXP_TYPE_LAVENDER_P65: - case IOEXP_TYPE_MAPLE_0ABC: - case IOEXP_TYPE_GULMOHAR_7ABC: - case IOEXP_TYPE_QSFP_6P_LAYOUT_1: - if (register_ioexp_attr_qsfp_1(device_p) < 0){ - err_msg = "register_ioexp_attr_qsfp_1 fail"; - goto err_reg_ioexp_attr; - } - break; - - default: - err_msg = "Unknow type"; - goto err_reg_ioexp_attr; - } - return 0; - -err_reg_ioexp_attr: - SWPS_ERR("%s: %s :%d \n", - __func__, err_msg, transvr_obj->ioexp_obj_p->ioexp_type); - return -1; -} - - -static int -register_modctl_device(void) { - - struct device *device_p = NULL; - int minor_comm = 0; /* Default minor number for common device */ - dev_t dev_num = MKDEV(ctl_major, minor_comm); - char *err_msg = "ERROR"; - - device_p = device_create(swp_class_p, /* struct class *cls */ - NULL, /* struct device *parent */ - dev_num, /* dev_t devt */ - NULL, /* void *private_data */ - SWP_DEV_MODCTL); /* const char *fmt */ - if (IS_ERR(device_p)){ - err_msg = "device_create fail"; - goto err_register_modctl_device_1; - } - if (register_modctl_attr(device_p) < 0) { - err_msg = "register_modctl_attr fail"; - goto err_register_modctl_device_2; - } - return 0; - -err_register_modctl_device_2: - device_unregister(device_p); - device_destroy(swp_class_p, dev_num); -err_register_modctl_device_1: - SWPS_ERR("%s: %s\n", __func__, err_msg); - return -1; -} - - -static int -register_port_device(char *dev_name, - dev_t dev_num, - struct transvr_obj_s *transvr_obj){ - - struct device *device_p = NULL; - device_p = device_create(swp_class_p, /* struct class *cls */ - NULL, /* struct device *parent */ - dev_num, /* dev_t devt */ - transvr_obj, /* void *private_data */ - dev_name); /* const char *fmt */ - if (IS_ERR(device_p)){ - goto err_regswp_create_dev; - } - if (register_transvr_attr(device_p, transvr_obj) < 0){ - goto err_regswp_reg_attr; - } - if (register_ioexp_attr(device_p, transvr_obj) < 0){ - goto err_regswp_reg_attr; - } - return 0; - -err_regswp_reg_attr: - device_unregister(device_p); - device_destroy(swp_class_p, dev_num); -err_regswp_create_dev: - SWPS_ERR("%s fail! :%s\n", __func__, dev_name); - return -1; -} - - -static int -register_swp_module(void){ - - dev_t ctl_devt = 0; - dev_t port_devt = 0; - int dev_total = port_total + 1; /* char_dev for module control */ - - /* Register device number */ - if (alloc_chrdev_region(&ctl_devt, 0, 1, SWP_DEV_MODCTL) < 0){ - SWPS_WARN("Allocate CTL MAJOR failure! \n"); - goto err_register_swp_module_1; - } - if (alloc_chrdev_region(&port_devt, 0, dev_total, SWP_CLS_NAME) < 0){ - SWPS_WARN("Allocate PORT MAJOR failure! \n"); - goto err_register_swp_module_2; - } - ctl_major = MAJOR(ctl_devt); - port_major = MAJOR(port_devt); - - /* Create class object */ - swp_class_p = class_create(THIS_MODULE, SWP_CLS_NAME); - if (IS_ERR(swp_class_p)) { - SWPS_ERR("Create class failure! \n"); - goto err_register_swp_module_3; - } - return 0; - -err_register_swp_module_3: - unregister_chrdev_region(MKDEV(port_major, 0), port_total); -err_register_swp_module_2: - unregister_chrdev_region(MKDEV(ctl_major, 0), 1); -err_register_swp_module_1: - return -1; -} - - -/* ========== Module initial relate ========== - */ -static int -create_ioexp_objs(void) { - - int i, run_mod; - - /* Clean IOEXP object */ - clean_ioexp_objs(); - /* Get running mode */ - run_mod = IOEXP_MODE_DIRECT; - if (SWP_POLLING_ENABLE){ - run_mod = IOEXP_MODE_POLLING; - } - /* Create IOEXP object */ - for(i=0; i devlen_max) { - snprintf(err_msg, sizeof(err_msg), - "SWP_DEV_PORT too long!"); - goto err_initport_create_tranobj; - } - memset(dev_name, 0, sizeof(dev_name)); - snprintf(dev_name, devlen_max, "%s%d", SWP_DEV_PORT, port_id); - /* Create transceiver object */ - ioexp_obj_p = get_ioexp_obj(ioexp_id); - if (!ioexp_obj_p){ - snprintf(err_msg, sizeof(err_msg), - "IOEXP object:%d not exist", ioexp_id); - goto err_initport_create_tranobj; - } - transvr_obj_p = create_transvr_obj(dev_name, chan_id, ioexp_obj_p, - ioexp_virt_offset, transvr_type, - chipset_type, run_mod); - if (!transvr_obj_p){ - snprintf(err_msg, sizeof(err_msg), - "Create transceiver object fail :%s", dev_name); - goto err_initport_create_tranobj; - } - /* Setup Lane_ID mapping */ - i = ARRAY_SIZE(port_layout[minor_curr].lane_id); - j = ARRAY_SIZE(transvr_obj_p->lane_id); - if (i != j) { - snprintf(err_msg, sizeof(err_msg), - "Lane_id size inconsistent %d/%d", i, j); - goto err_initport_reg_device; - } - memcpy(transvr_obj_p->lane_id, port_layout[minor_curr].lane_id, i*sizeof(int)); - /* Create and register device object */ - if (register_port_device(dev_name, MKDEV(port_major, minor_curr), transvr_obj_p) < 0){ - snprintf(err_msg, sizeof(err_msg), - "register_port_device fail"); - goto err_initport_reg_device; - } - /* Setup device_ptr of transvr_obj */ - dev_p = get_swpdev_by_name(dev_name); - if (!dev_p){ - snprintf(err_msg, sizeof(err_msg), - "get_swpdev_by_name fail"); - goto err_initport_reg_device; - } - transvr_obj_p->transvr_dev_p = dev_p; - /* Success */ - ok_count++; - } - SWPS_INFO("%s: initialed %d port-dev\n",__func__, ok_count); - return 0; - -err_initport_reg_device: - kfree(transvr_obj_p); -err_initport_create_tranobj: - clean_port_objs(); - SWPS_ERR("%s: %s", __func__, err_msg); - SWPS_ERR("Dump: :%d :%d :%d :%d :%d :%d\n", - port_id, chan_id, ioexp_id, ioexp_virt_offset, transvr_type, run_mod); - return -1; -} - - -static int -init_dev_topology(void){ - - int err; - char *emsg = "ERR"; - flag_mod_state = SWP_STATE_NORMAL; - - err = init_ioexp_objs(); - switch(err){ - case 0: /* Normal */ - SWPS_DEBUG("%s: normal case\n", __func__); - break; - - case -1: /* topology error */ - SWPS_DEBUG("%s: detect tier-1 topology initial failure :%d\n", - __func__, err); - /* Reset and isolate */ - err = reset_i2c_topology(); - if (err < 0) { - emsg = "reset i2c topology fail"; - goto err_init_dev_topology; - } - /* Re-initial again */ - err = init_ioexp_objs(); - if (err < 0) { - emsg = "re-init ioexp objects fail"; - goto err_init_dev_topology; - } - break; - - case -2: /* Internal error */ - SWPS_DEBUG("%s: internal error case\n", __func__); - err = -2; - emsg = "internal error"; - goto err_init_dev_topology; - - default: - SWPS_DEBUG("%s: undefined error case\n", __func__); - emsg = "undefined error case"; - goto err_init_dev_topology; - } - SWPS_DEBUG("%s: initial I2C topology success\n", __func__); - return 0; - -err_init_dev_topology: - SWPS_ERR("%s: %s :%d\n", __func__, emsg, err); - return -1; -} - - -static int -init_polling_task(void){ - - if (SWP_POLLING_ENABLE){ - schedule_delayed_work(&swp_polling, _get_polling_period()); - } - return 0; -} - - -static int -init_swps_common(void){ - - char *err_msg = "ERR"; - - auto_config = 0; - if ((SWP_AUTOCONFIG_ENABLE) && (SWP_POLLING_ENABLE)){ - auto_config = 1; - } - if (register_modctl_device() < 0) { - err_msg = "register_modctl_device fail"; - goto err_init_swps_common_1; - } - if (_update_auto_config_2_trnasvr() < 0) { - err_msg = "_update_auto_config_2_trnasvr fail"; - goto err_init_swps_common_1; - } - if (init_polling_task() < 0){ - err_msg = "init_polling_task fail"; - goto err_init_swps_common_1; - } - return 0; - -err_init_swps_common_1: - clean_swps_common(); - SWPS_ERR("%s: %s\n", __func__, err_msg); - return -1; -} - - -static int __init -swp_module_init(void){ - - if (get_platform_type() < 0){ - goto err_init_out; - } - if (get_layout_info() < 0){ - goto err_init_out; - } - if (register_swp_module() < 0){ - goto err_init_out; - } - if (create_ioexp_objs() < 0){ - goto err_init_ioexp; - } - if (create_port_objs() < 0){ - goto err_init_portobj; - } - if (init_mux_objs(gpio_rest_mux) < 0){ - goto err_init_mux; - } - if (init_dev_topology() < 0){ - goto err_init_topology; - } - if (init_swps_common() < 0){ - goto err_init_topology; - } - SWPS_INFO("Inventec switch-port module V.%s initial success.\n", SWP_VERSION); - return 0; - - -err_init_topology: - clean_mux_objs(); -err_init_mux: - clean_port_objs(); -err_init_portobj: - clean_ioexp_objs(); -err_init_ioexp: - class_unregister(swp_class_p); - class_destroy(swp_class_p); - unregister_chrdev_region(MKDEV(ctl_major, 0), 1); - unregister_chrdev_region(MKDEV(port_major, 0), port_total); -err_init_out: - SWPS_ERR("Inventec switch-port module V.%s initial failure.\n", SWP_VERSION); - return -1; -} - - -static void __exit -swp_module_exit(void){ - - clean_swps_common(); - clean_port_objs(); - clean_ioexp_objs(); - clean_mux_objs(); - class_unregister(swp_class_p); - class_destroy(swp_class_p); - unregister_chrdev_region(MKDEV(ctl_major, 0), 1); - unregister_chrdev_region(MKDEV(port_major, 0), port_total); - SWPS_INFO("Remove Inventec switch-port module success.\n"); -} - - -/* Module information */ -MODULE_AUTHOR(SWP_AUTHOR); -MODULE_DESCRIPTION(SWP_DESC); -MODULE_VERSION(SWP_VERSION); -MODULE_LICENSE(SWP_LICENSE); - -module_init(swp_module_init); -module_exit(swp_module_exit); - - - - - - - - - - - diff --git a/packages/platforms/inventec/x86-64/d6356/modules/builds/src/inv_swps.h b/packages/platforms/inventec/x86-64/d6356/modules/builds/src/inv_swps.h deleted file mode 100644 index 8bb105295..000000000 --- a/packages/platforms/inventec/x86-64/d6356/modules/builds/src/inv_swps.h +++ /dev/null @@ -1,1518 +0,0 @@ -#ifndef INV_SWPS_H -#define INV_SWPS_H - -#include "transceiver.h" -#include "io_expander.h" -#include "inv_mux.h" - -/* Module settings */ -#define SWP_CLS_NAME "swps" -#define SWP_DEV_PORT "port" -#define SWP_DEV_MODCTL "module" -#define SWP_RESET_PWD "inventec" -#define SWP_POLLING_PERIOD (300) /* msec */ -#define SWP_POLLING_ENABLE (1) -#define SWP_AUTOCONFIG_ENABLE (1) -static int block_polling = 0; - -/* Module information */ -#define SWP_AUTHOR "Neil " -#define SWP_DESC "Inventec port and transceiver driver" -#define SWP_VERSION "4.3.2" -#define SWP_LICENSE "GPL" - -/* Module status define */ -#define SWP_STATE_NORMAL (0) -#define SWP_STATE_I2C_DIE (-91) - -#define INV_BATOI(a) ((a>='0'&&a<='9')?(a-'0'):(-1)) -#define INV_BATOX(a) ((a>='0'&&a<='9')?(a-'0'):((a>='a'&&a<='f')?(a-'a'+10):((a >='A'&&a<='F')?(a-'A'+10):-1))) - -/* [Note]: - * Functions and mechanism for auto-detect platform type is ready, - * But HW and BIOS not ready! We need to wait them. - * So, please do not use PLATFORM_TYPE_AUTO until they are ready. - * (2016.06.13) - */ -#define PLATFORM_TYPE_AUTO (100) -#define PLATFORM_TYPE_MAGNOLIA (111) -#define PLATFORM_TYPE_MAGNOLIA_FNC (112) -#define PLATFORM_TYPE_REDWOOD (121) -#define PLATFORM_TYPE_REDWOOD_FSL (122) -#define PLATFORM_TYPE_HUDSON32I_GA (131) -#define PLATFORM_TYPE_SPRUCE (141) -#define PLATFORM_TYPE_CYPRESS_GA1 (151) /* Up -> Down */ -#define PLATFORM_TYPE_CYPRESS_GA2 (152) /* Down -> Up */ -#define PLATFORM_TYPE_CYPRESS_BAI (153) /* Down -> Up */ -#define PLATFORM_TYPE_TAHOE (161) -#define PLATFORM_TYPE_SEQUOIA_GA (171) -#define PLATFORM_TYPE_LAVENDER_GA (181) -#define PLATFORM_TYPE_LAVENDER_ONL (182) -#define PLATFORM_TYPE_COTTONWOOD_RANGELEY (191) -#define PLATFORM_TYPE_MAPLE_GA (201) -#define PLATFORM_TYPE_GULMOHAR_GA (202) -#define PLATFORM_TYPE_PEONY_SFP_GA (203) -#define PLATFORM_TYPE_PEONY_COPPER_GA (204) -#define PLATFORM_TYPE_PEONY_AUTO (205) -#define PLATFORM_TYPE_MAPLE_B (206) -/* Current running platfrom */ -#define PLATFORM_SETTINGS PLATFORM_TYPE_MAPLE_B - -/* Define platform flag and kernel version */ -#if (PLATFORM_SETTINGS == PLATFORM_TYPE_MAGNOLIA) - #define SWPS_MAGNOLIA (1) - #define SWPS_KERN_VER_BF_3_8 (1) -#elif (PLATFORM_SETTINGS == PLATFORM_TYPE_MAGNOLIA_FNC) - #define SWPS_MAGNOLIA (1) - #define SWPS_KERN_VER_AF_3_10 (1) -#elif (PLATFORM_SETTINGS == PLATFORM_TYPE_REDWOOD) - #define SWPS_REDWOOD (1) - #define SWPS_KERN_VER_BF_3_8 (1) -#elif (PLATFORM_SETTINGS == PLATFORM_TYPE_REDWOOD_FSL) - #define SWPS_REDWOOD_FSL (1) - #define SWPS_KERN_VER_BF_3_8 (1) -#elif (PLATFORM_SETTINGS == PLATFORM_TYPE_HUDSON32I_GA) - #define SWPS_HUDSON32I_GA (1) - #define SWPS_KERN_VER_BF_3_8 (1) -#elif (PLATFORM_SETTINGS == PLATFORM_TYPE_SPRUCE) - #define SWPS_SPRUCE (1) - #define SWPS_KERN_VER_BF_3_8 (1) -#elif (PLATFORM_SETTINGS == PLATFORM_TYPE_CYPRESS_GA1) - #define SWPS_CYPRESS_GA1 (1) - #define SWPS_KERN_VER_BF_3_8 (1) -#elif (PLATFORM_SETTINGS == PLATFORM_TYPE_CYPRESS_GA2) - #define SWPS_CYPRESS_GA2 (1) - #define SWPS_KERN_VER_BF_3_8 (1) -#elif (PLATFORM_SETTINGS == PLATFORM_TYPE_CYPRESS_BAI) - #define SWPS_CYPRESS_BAI (1) - #define SWPS_KERN_VER_AF_3_10 (1) -#elif (PLATFORM_SETTINGS == PLATFORM_TYPE_TAHOE) - #define SWPS_TAHOE (1) - #define SWPS_KERN_VER_AF_3_10 (1) -#elif (PLATFORM_SETTINGS == PLATFORM_TYPE_SEQUOIA_GA) - #define SWPS_SEQUOIA (1) - #define SWPS_KERN_VER_BF_3_8 (1) -#elif (PLATFORM_SETTINGS == PLATFORM_TYPE_LAVENDER_GA) - #define SWPS_LAVENDER (1) - #define SWPS_KERN_VER_AF_3_10 (1) -#elif (PLATFORM_SETTINGS == PLATFORM_TYPE_LAVENDER_ONL) - #define SWPS_LAVENDER (1) - #define SWPS_KERN_VER_AF_3_10 (1) -#elif (PLATFORM_SETTINGS == PLATFORM_TYPE_COTTONWOOD_RANGELEY) - #define SWPS_COTTONWOOD_RANGELEY (1) - #define SWPS_KERN_VER_AF_3_10 (1) -#elif (PLATFORM_SETTINGS == PLATFORM_TYPE_MAPLE_GA) - #define SWPS_MAPLE_GA (1) - #define SWPS_KERN_VER_AF_3_10 (1) -#elif (PLATFORM_SETTINGS == PLATFORM_TYPE_MAPLE_B) - #define SWPS_MAPLE_B (1) - #define SWPS_KERN_VER_AF_3_10 (1) -#elif (PLATFORM_SETTINGS == PLATFORM_TYPE_GULMOHAR_GA) - #define SWPS_GULMOHAR (1) - #define SWPS_KERN_VER_AF_3_10 (1) -#elif (PLATFORM_SETTINGS == PLATFORM_TYPE_PEONY_SFP_GA) - #define SWPS_PEONY_SFP (1) - #define SWPS_KERN_VER_AF_3_10 (1) -#elif (PLATFORM_SETTINGS == PLATFORM_TYPE_PEONY_COPPER_GA) - #define SWPS_PEONY_COPPER (1) - #define SWPS_KERN_VER_AF_3_10 (1) -#elif (PLATFORM_SETTINGS == PLATFORM_TYPE_PEONY_AUTO) - #define SWPS_PEONY_SFP (1) - #define SWPS_PEONY_COPPER (1) - #define SWPS_KERN_VER_AF_3_10 (1) -#endif - - -struct inv_platform_s { - int id; - char name[64]; -}; - -struct inv_ioexp_layout_s { - int ioexp_id; - int ioexp_type; - struct ioexp_addr_s addr[4]; -}; - -struct inv_port_layout_s { - int port_id; - int chan_id; - int ioexp_id; - int ioexp_offset; - int transvr_type; - int chipset_type; - int lane_id[8]; -}; - - -/* ========================================== - * Inventec Platform Settings - * ========================================== - */ -struct inv_platform_s platform_map[] = { - {PLATFORM_TYPE_AUTO, "Auto-Detect" }, - {PLATFORM_TYPE_MAGNOLIA, "Magnolia" }, - {PLATFORM_TYPE_MAGNOLIA_FNC, "Magnolia_FNC" }, - {PLATFORM_TYPE_REDWOOD, "Redwood" }, - {PLATFORM_TYPE_REDWOOD_FSL, "Redwood_FSL" }, - {PLATFORM_TYPE_HUDSON32I_GA, "Hudson32i" }, - {PLATFORM_TYPE_SPRUCE, "Spruce" }, - {PLATFORM_TYPE_CYPRESS_GA1, "Cypress_GA1" }, - {PLATFORM_TYPE_CYPRESS_GA2, "Cypress_GA2" }, - {PLATFORM_TYPE_CYPRESS_BAI, "Cypress_BAI" }, - {PLATFORM_TYPE_TAHOE, "Tahoe" }, - {PLATFORM_TYPE_SEQUOIA_GA, "Sequoia_GA" }, - {PLATFORM_TYPE_LAVENDER_GA, "Lavender_GA" }, - {PLATFORM_TYPE_LAVENDER_ONL, "Lavender_ONL" }, - {PLATFORM_TYPE_COTTONWOOD_RANGELEY, "Cottonwood_RANGELEY" }, - {PLATFORM_TYPE_MAPLE_GA, "Maple_GA" }, - {PLATFORM_TYPE_MAPLE_B, "Maple_B" }, - {PLATFORM_TYPE_GULMOHAR_GA, "Gulmohar_GA" }, - {PLATFORM_TYPE_PEONY_SFP_GA, "Peony_SFP_GA" }, - {PLATFORM_TYPE_PEONY_COPPER_GA, "Peony_Copper_GA" }, - {PLATFORM_TYPE_PEONY_AUTO, "Peony_Auto_Detect" }, -}; - - -/* ========================================== - * Magnolia Layout configuration - * ========================================== - */ -#ifdef SWPS_MAGNOLIA -unsigned magnolia_gpio_rest_mux = MUX_RST_GPIO_48_PAC9548; - -struct inv_ioexp_layout_s magnolia_ioexp_layout[] = { - /* IOEXP_ID / IOEXP_TYPE / { Chan_ID, Chip_addr, Read_offset, Write_offset, config_offset, data_default, conf_default } */ - {0, IOEXP_TYPE_MAGINOLIA_NAB, { {2, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {2, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, }, /* addr[1] = I/O Expander N B */ - }, - {1, IOEXP_TYPE_MAGINOLIA_NAB, { {3, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {3, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, }, /* addr[1] = I/O Expander N B */ - }, - {2, IOEXP_TYPE_MAGINOLIA_NAB, { {4, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {4, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, }, /* addr[1] = I/O Expander N B */ - }, - {3, IOEXP_TYPE_MAGINOLIA_4AB, { {5, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander 4 A */ - {5, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xf0, 0xff}, {0xf0, 0xff}, }, }, /* addr[1] = I/O Expander 4 B */ - }, - {4, IOEXP_TYPE_MAGINOLIA_NAB, { {6, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {6, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, }, /* addr[1] = I/O Expander N B */ - }, - {5, IOEXP_TYPE_MAGINOLIA_NAB, { {7, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {7, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, }, /* addr[1] = I/O Expander N B */ - }, - {6, IOEXP_TYPE_MAGINOLIA_7AB, { {8, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[0] = I/O Expander 7 A */ - {8, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xf0, 0x33}, }, }, /* addr[1] = I/O Expander 7 B */ - }, -}; - -struct inv_port_layout_s magnolia_port_layout[] = { - /* Port_ID / Chan_ID / IOEXP_ID / IOEXP_VIRT_OFFSET / TRANSCEIVER_TYPE / BCM_CHIP_TYPE / LANE_ID */ - { 0, 10, 0, 0, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 16} }, - { 1, 11, 0, 1, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 15} }, - { 2, 12, 0, 2, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 14} }, - { 3, 13, 0, 3, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 13} }, - { 4, 14, 0, 4, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 24} }, - { 5, 15, 0, 5, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 23} }, - { 6, 16, 0, 6, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 22} }, - { 7, 17, 0, 7, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 21} }, - { 8, 18, 1, 0, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 28} }, - { 9, 19, 1, 1, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 27} }, - {10, 20, 1, 2, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 26} }, - {11, 21, 1, 3, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 25} }, - {12, 22, 1, 4, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 32} }, - {13, 23, 1, 5, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 31} }, - {14, 24, 1, 6, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 30} }, - {15, 25, 1, 7, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 29} }, - {16, 26, 2, 0, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 48} }, - {17, 27, 2, 1, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 47} }, - {18, 28, 2, 2, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 46} }, - {19, 29, 2, 3, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 45} }, - {20, 30, 2, 4, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 52} }, - {21, 31, 2, 5, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 51} }, - {22, 32, 2, 6, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 50} }, - {23, 33, 2, 7, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 49} }, - {24, 34, 3, 0, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 56} }, - {25, 35, 3, 1, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 55} }, - {26, 36, 3, 2, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 54} }, - {27, 37, 3, 3, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 53} }, - {28, 38, 3, 4, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 60} }, - {29, 39, 3, 5, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 59} }, - {30, 40, 3, 6, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 58} }, - {31, 41, 3, 7, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 57} }, - {32, 42, 4, 0, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 64} }, - {33, 43, 4, 1, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 63} }, - {34, 44, 4, 2, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 62} }, - {35, 45, 4, 3, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 61} }, - {36, 46, 4, 4, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 68} }, - {37, 47, 4, 5, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 67} }, - {38, 48, 4, 6, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 66} }, - {39, 49, 4, 7, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 65} }, - {40, 50, 5, 0, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 72} }, - {41, 51, 5, 1, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 71} }, - {42, 52, 5, 2, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 70} }, - {43, 53, 5, 3, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 69} }, - {44, 54, 5, 4, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 76} }, - {45, 55, 5, 5, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 75} }, - {46, 56, 5, 6, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 74} }, - {47, 57, 5, 7, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 73} }, - {48, 58, 6, 0, TRANSVR_TYPE_QSFP, BCM_CHIP_TYPE_TRIDENT_2, { 81, 82, 83, 84} }, - {49, 59, 6, 1, TRANSVR_TYPE_QSFP, BCM_CHIP_TYPE_TRIDENT_2, { 77, 78, 79, 80} }, - {50, 60, 6, 2, TRANSVR_TYPE_QSFP, BCM_CHIP_TYPE_TRIDENT_2, { 97, 98, 99,100} }, - {51, 61, 6, 3, TRANSVR_TYPE_QSFP, BCM_CHIP_TYPE_TRIDENT_2, {101,102,103,104} }, - {52, 62, 6, 4, TRANSVR_TYPE_QSFP, BCM_CHIP_TYPE_TRIDENT_2, {105,106,107,108} }, - {53, 63, 6, 5, TRANSVR_TYPE_QSFP, BCM_CHIP_TYPE_TRIDENT_2, {109,110,111,112} }, -}; -#endif - - -/* ========================================== - * Redwood Layout configuration - * ========================================== - */ -#ifdef SWPS_REDWOOD -unsigned redwood_gpio_rest_mux = MUX_RST_GPIO_48_PAC9548; - -struct inv_ioexp_layout_s redwood_ioexp_layout[] = { - /* IOEXP_ID / IOEXP_TYPE / { Chan_ID, Chip_addr, Read_offset, Write_offset, config_offset, data_default, conf_default } */ - {0, IOEXP_TYPE_REDWOOD_P01P08, { {4, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[0] = I/O Expander 1-4 A */ - {4, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[1] = I/O Expander 1-4 B */ - {0, 0x25, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 5 B */ - }, - {1, IOEXP_TYPE_REDWOOD_P09P16, { {5, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[0] = I/O Expander 1-4 A */ - {5, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[1] = I/O Expander 1-4 B */ - {0, 0x25, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 5 B */ - }, - {2, IOEXP_TYPE_REDWOOD_P01P08, { {2, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[0] = I/O Expander 1-4 A */ - {2, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[1] = I/O Expander 1-4 B */ - {0, 0x24, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 5 B */ - }, - {3, IOEXP_TYPE_REDWOOD_P09P16, { {3, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[0] = I/O Expander 1-4 A */ - {3, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[1] = I/O Expander 1-4 B */ - {0, 0x24, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 5 B */ - }, -}; - -struct inv_port_layout_s redwood_port_layout[] = { - /* Port_ID / Chan_ID / IOEXP_ID / IOEXP_VIRT_OFFSET / TRANSCEIVER_TYPE / BCM_CHIP_TYPE / LANE_ID */ - { 0, 22, 0, 0, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 1, 2, 3, 4} }, - { 1, 23, 0, 1, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 5, 6, 7, 8} }, - { 2, 24, 0, 2, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 9, 10, 11, 12} }, - { 3, 25, 0, 3, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 13, 14, 15, 16} }, - { 4, 26, 0, 4, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 17, 18, 19, 20} }, - { 5, 27, 0, 5, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 21, 22, 23, 24} }, - { 6, 28, 0, 6, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 25, 26, 27, 28} }, - { 7, 29, 0, 7, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 29, 30, 31, 32} }, - { 8, 30, 1, 0, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 33, 34, 35, 36} }, - { 9, 31, 1, 1, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 37, 38, 39, 40} }, - {10, 32, 1, 2, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 41, 42, 43, 44} }, - {11, 33, 1, 3, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 45, 46, 47, 48} }, - {12, 34, 1, 4, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 49, 50, 51, 52} }, - {13, 35, 1, 5, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 53, 54, 55, 56} }, - {14, 36, 1, 6, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 57, 58, 59, 60} }, - {15, 37, 1, 7, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 61, 62, 63, 64} }, - {16, 6, 2, 0, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 65, 66, 67, 68} }, - {17, 7, 2, 1, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 69, 70, 71, 72} }, - {18, 8, 2, 2, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 73, 74, 75, 76} }, - {19, 9, 2, 3, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 77, 78, 79, 80} }, - {20, 10, 2, 4, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 81, 82, 83, 84} }, - {21, 11, 2, 5, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 85, 86, 87, 88} }, - {22, 12, 2, 6, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 89, 90, 91, 92} }, - {23, 13, 2, 7, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 93, 94, 95, 96} }, - {24, 14, 3, 0, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 97, 98, 99,100} }, - {25, 15, 3, 1, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {101,102,103,104} }, - {26, 16, 3, 2, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {105,106,107,108} }, - {27, 17, 3, 3, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {109,110,111,112} }, - {28, 18, 3, 4, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {113,114,115,116} }, - {29, 19, 3, 5, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {117,118,119,120} }, - {30, 20, 3, 6, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {121,122,123,124} }, - {31, 21, 3, 7, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {125,126,127,128} }, -}; -#endif - - -/* ========================================== - * Hudson32i Layout configuration - * ========================================== - */ -#ifdef SWPS_HUDSON32I_GA -unsigned hudsin32iga_gpio_rest_mux = MUX_RST_GPIO_48_PAC9548; - -struct inv_ioexp_layout_s hudson32iga_ioexp_layout[] = { - /* IOEXP_ID / IOEXP_TYPE / { Chan_ID, Chip_addr, Read_offset, Write_offset, config_offset, data_default, conf_default } */ - {0, IOEXP_TYPE_HUDSON32IGA_P01P08, { {2, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[0] = I/O Expander A */ - {2, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[1] = I/O Expander B */ - {0, 0x24, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 0x24 */ - }, - {1, IOEXP_TYPE_HUDSON32IGA_P09P16, { {3, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[0] = I/O Expander A */ - {3, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[1] = I/O Expander B */ - {0, 0x24, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 0x24 */ - }, - {2, IOEXP_TYPE_HUDSON32IGA_P01P08, { {4, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[0] = I/O Expander A */ - {4, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[1] = I/O Expander B */ - {0, 0x25, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 0x25 */ - }, - {3, IOEXP_TYPE_HUDSON32IGA_P09P16, { {5, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[0] = I/O Expander A */ - {5, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[1] = I/O Expander B */ - {0, 0x25, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 0x25 */ - }, -}; - -struct inv_port_layout_s hudson32iga_port_layout[] = { - /* Port_ID / Chan_ID / IOEXP_ID / IOEXP_VIRT_OFFSET / TRANSCEIVER_TYPE / BCM_CHIP_TYPE / LANE_ID */ - { 0, 6, 0, 0, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, { 1, 2, 3, 4} }, - { 1, 7, 0, 1, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, { 5, 6, 7, 8} }, - { 2, 8, 0, 2, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, { 9, 10, 11, 12} }, - { 3, 9, 0, 3, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, { 13, 14, 15, 16} }, - { 4, 10, 0, 4, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, { 17, 18, 19, 20} }, - { 5, 11, 0, 5, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, { 21, 22, 23, 24} }, - { 6, 12, 0, 6, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, { 25, 26, 27, 28} }, - { 7, 13, 0, 7, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, { 29, 30, 31, 32} }, - { 8, 14, 1, 0, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, { 33, 34, 35, 36} }, - { 9, 15, 1, 1, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, { 37, 38, 39, 40} }, - {10, 16, 1, 2, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, { 41, 42, 43, 44} }, - {11, 17, 1, 3, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, { 45, 46, 47, 48} }, - {12, 18, 1, 4, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, { 49, 50, 51, 52} }, - {13, 19, 1, 5, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, { 53, 54, 55, 56} }, - {14, 20, 1, 6, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, { 57, 58, 59, 60} }, - {15, 21, 1, 7, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, { 61, 62, 63, 64} }, - {16, 22, 2, 0, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, { 65, 66, 67, 68} }, - {17, 23, 2, 1, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, { 69, 70, 71, 72} }, - {18, 24, 2, 2, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, { 73, 74, 75, 76} }, - {19, 25, 2, 3, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, { 77, 78, 79, 80} }, - {20, 26, 2, 4, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, { 81, 82, 83, 84} }, - {21, 27, 2, 5, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, { 85, 86, 87, 88} }, - {22, 28, 2, 6, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, { 89, 90, 91, 92} }, - {23, 29, 2, 7, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, { 93, 94, 95, 96} }, - {24, 30, 3, 0, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, { 97, 98, 99,100} }, - {25, 31, 3, 1, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, {101,102,103,104} }, - {26, 32, 3, 2, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, {105,106,107,108} }, - {27, 33, 3, 3, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, {109,110,111,112} }, - {28, 34, 3, 4, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, {113,114,115,116} }, - {29, 35, 3, 5, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, {117,118,119,120} }, - {30, 36, 3, 6, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, {121,122,123,124} }, - {31, 37, 3, 7, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, {125,126,127,128} }, -}; -#endif - - -/* ========================================== - * Spruce Layout configuration - * ========================================== - */ -#ifdef SWPS_SPRUCE -unsigned spruce_gpio_rest_mux = MUX_RST_GPIO_48_PAC9548; - -struct inv_ioexp_layout_s spruce_ioexp_layout[] = { - /* IOEXP_ID / IOEXP_TYPE / { Chan_ID, Chip_addr, Read_offset, Write_offset, config_offset, data_default, conf_default } */ - {0, IOEXP_TYPE_SPRUCE_7AB, { {2, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[0] = I/O Expander 7A */ - {2, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xf0, 0x33}, }, }, /* addr[2] = I/O Expander 7B */ - }, -}; - -struct inv_port_layout_s spruce_port_layout[] = { - /* Port_ID / Chan_ID / IOEXP_ID / IOEXP_VIRT_OFFSET / TRANSCEIVER_TYPE / BCM_CHIP_TYPE / LANE_ID */ - { 0, 6, 0, 0, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, { 81, 82, 83, 84} }, - { 1, 7, 0, 1, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, { 77, 78, 79, 80} }, - { 2, 8, 0, 2, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, { 97, 98, 99,100} }, - { 3, 9, 0, 3, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, {101,102,103,104} }, - { 4, 10, 0, 4, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, {105,106,107,108} }, - { 5, 11, 0, 5, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, {109,110,111,112} }, -}; -#endif - - -/* ========================================== - * Cypress Layout configuration (Inventec version [Up->Down]) - * ========================================== - */ -#ifdef SWPS_CYPRESS_GA1 -unsigned cypress_ga1_gpio_rest_mux = MUX_RST_GPIO_69_PAC9548; - -struct inv_ioexp_layout_s cypress_ga1_ioexp_layout[] = { - /* IOEXP_ID / IOEXP_TYPE / { Chan_ID, Chip_addr, Read_offset, Write_offset, config_offset, data_default, conf_default } */ - {0, IOEXP_TYPE_SFP_8P_LAYOUT_1, { {2, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {2, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {2, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {1, IOEXP_TYPE_SFP_8P_LAYOUT_1, { {3, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {3, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {3, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {2, IOEXP_TYPE_SFP_8P_LAYOUT_1, { {4, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {4, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {4, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {3, IOEXP_TYPE_SFP_8P_LAYOUT_1, { {5, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {5, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {5, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {4, IOEXP_TYPE_SFP_8P_LAYOUT_1, { {6, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {6, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {6, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {5, IOEXP_TYPE_SFP_8P_LAYOUT_1, { {7, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {7, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {7, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {6, IOEXP_TYPE_CYPRESS_7ABC, { {8, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xc0, 0xc0}, }, /* addr[0] = I/O Expander 7 A */ - {8, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xc0, 0xc0}, {0xff, 0xc0}, }, /* addr[1] = I/O Expander 7 B */ - {8, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 7 C */ - }, -}; - -struct inv_port_layout_s cypress_ga1_port_layout[] = { - /* Port_ID / Chan_ID / IOEXP_ID / IOEXP_VIRT_OFFSET / TRANSCEIVER_TYPE / BCM_CHIP_TYPE / LANE_ID */ - { 0, 10, 0, 0, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 1} }, - { 1, 11, 0, 1, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 2} }, - { 2, 12, 0, 2, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 3} }, - { 3, 13, 0, 3, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 4} }, - { 4, 14, 0, 4, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 5} }, - { 5, 15, 0, 5, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 6} }, - { 6, 16, 0, 6, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 7} }, - { 7, 17, 0, 7, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 8} }, - { 8, 18, 1, 0, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 9} }, - { 9, 19, 1, 1, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 10} }, - {10, 20, 1, 2, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 11} }, - {11, 21, 1, 3, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 12} }, - {12, 22, 1, 4, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 21} }, - {13, 23, 1, 5, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 22} }, - {14, 24, 1, 6, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 23} }, - {15, 25, 1, 7, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 24} }, - {16, 26, 2, 0, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 33} }, - {17, 27, 2, 1, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 34} }, - {18, 28, 2, 2, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 35} }, - {19, 29, 2, 3, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 36} }, - {20, 30, 2, 4, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 37} }, - {21, 31, 2, 5, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 38} }, - {22, 32, 2, 6, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 39} }, - {23, 33, 2, 7, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 40} }, - {24, 34, 3, 0, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 41} }, - {25, 35, 3, 1, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 42} }, - {26, 36, 3, 2, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 43} }, - {27, 37, 3, 3, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 44} }, - {28, 38, 3, 4, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 49} }, - {29, 39, 3, 5, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 50} }, - {30, 40, 3, 6, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 51} }, - {31, 41, 3, 7, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 52} }, - {32, 42, 4, 0, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 53} }, - {33, 43, 4, 1, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 54} }, - {34, 44, 4, 2, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 55} }, - {35, 45, 4, 3, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 56} }, - {36, 46, 4, 4, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 65} }, - {37, 47, 4, 5, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 66} }, - {38, 48, 4, 6, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 67} }, - {39, 49, 4, 7, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 68} }, - {40, 50, 5, 0, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 69} }, - {41, 51, 5, 1, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 70} }, - {42, 52, 5, 2, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 71} }, - {43, 53, 5, 3, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 72} }, - {44, 54, 5, 4, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 81} }, - {45, 55, 5, 5, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 82} }, - {46, 56, 5, 6, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 83} }, - {47, 57, 5, 7, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 84} }, - {48, 58, 6, 0, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 97, 98, 99,100} }, - {49, 59, 6, 1, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 85, 86, 87, 88} }, - {50, 60, 6, 2, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {101,102,103,104} }, - {51, 61, 6, 3, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {105,106,107,108} }, - {52, 62, 6, 4, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {109,110,111,112} }, - {53, 63, 6, 5, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {117,118,119,120} }, -}; -#endif - - -/* ========================================== - * Cypress Layout configuration (Inventec version [Down->Up]) - * ========================================== - */ -#ifdef SWPS_CYPRESS_GA2 -unsigned cypress_ga2_gpio_rest_mux = MUX_RST_GPIO_FORCE_HEDERA; - -struct inv_ioexp_layout_s cypress_ga2_ioexp_layout[] = { - /* IOEXP_ID / IOEXP_TYPE / { Chan_ID, Chip_addr, Read_offset, Write_offset, config_offset, data_default, conf_default } */ - {0, IOEXP_TYPE_SFP_8P_LAYOUT_1, { {2, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {2, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {2, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {1, IOEXP_TYPE_SFP_8P_LAYOUT_1, { {3, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {3, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {3, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {2, IOEXP_TYPE_SFP_8P_LAYOUT_1, { {4, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {4, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {4, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {3, IOEXP_TYPE_SFP_8P_LAYOUT_1, { {5, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {5, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {5, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {4, IOEXP_TYPE_SFP_8P_LAYOUT_1, { {6, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {6, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {6, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {5, IOEXP_TYPE_SFP_8P_LAYOUT_1, { {7, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {7, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {7, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {6, IOEXP_TYPE_CYPRESS_7ABC, { {8, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xc0, 0xc0}, }, /* addr[0] = I/O Expander 7 A */ - {8, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xc0, 0xc0}, {0xff, 0xc0}, }, /* addr[1] = I/O Expander 7 B */ - {8, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 7 C */ - }, -}; - -struct inv_port_layout_s cypress_ga2_port_layout[] = { - /* Port_ID / Chan_ID / IOEXP_ID / IOEXP_VIRT_OFFSET / TRANSCEIVER_TYPE / BCM_CHIP_TYPE / LANE_ID */ - { 0, 11, 0, 1, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 2} }, - { 1, 10, 0, 0, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 1} }, - { 2, 13, 0, 3, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 4} }, - { 3, 12, 0, 2, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 3} }, - { 4, 15, 0, 5, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 6} }, - { 5, 14, 0, 4, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 5} }, - { 6, 17, 0, 7, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 8} }, - { 7, 16, 0, 6, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 7} }, - { 8, 19, 1, 1, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 10} }, - { 9, 18, 1, 0, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 9} }, - {10, 21, 1, 3, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 12} }, - {11, 20, 1, 2, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 11} }, - {12, 23, 1, 5, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 22} }, - {13, 22, 1, 4, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 21} }, - {14, 25, 1, 7, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 24} }, - {15, 24, 1, 6, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 23} }, - {16, 27, 2, 1, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 34} }, - {17, 26, 2, 0, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 33} }, - {18, 29, 2, 3, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 36} }, - {19, 28, 2, 2, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 35} }, - {20, 31, 2, 5, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 38} }, - {21, 30, 2, 4, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 37} }, - {22, 33, 2, 7, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 40} }, - {23, 32, 2, 6, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 39} }, - {24, 35, 3, 1, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 42} }, - {25, 34, 3, 0, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 41} }, - {26, 37, 3, 3, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 44} }, - {27, 36, 3, 2, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 43} }, - {28, 39, 3, 5, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 50} }, - {29, 38, 3, 4, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 49} }, - {30, 41, 3, 7, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 52} }, - {31, 40, 3, 6, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 51} }, - {32, 43, 4, 1, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 54} }, - {33, 42, 4, 0, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 53} }, - {34, 45, 4, 3, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 56} }, - {35, 44, 4, 2, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 55} }, - {36, 47, 4, 5, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 66} }, - {37, 46, 4, 4, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 65} }, - {38, 49, 4, 7, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 68} }, - {39, 48, 4, 6, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 67} }, - {40, 51, 5, 1, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 70} }, - {41, 50, 5, 0, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 69} }, - {42, 53, 5, 3, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 72} }, - {43, 52, 5, 2, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 71} }, - {44, 55, 5, 5, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 82} }, - {45, 54, 5, 4, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 81} }, - {46, 57, 5, 7, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 84} }, - {47, 56, 5, 6, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 83} }, - {48, 59, 6, 1, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 85, 86, 87, 88} }, - {49, 58, 6, 0, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 97, 98, 99,100} }, - {50, 61, 6, 3, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {105,106,107,108} }, - {51, 60, 6, 2, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {101,102,103,104} }, - {52, 63, 6, 5, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {117,118,119,120} }, - {53, 62, 6, 4, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {109,110,111,112} }, -}; -#endif - - -/* ========================================== - * Cypress Layout configuration (BaiDu version) - * ========================================== - */ -#ifdef SWPS_CYPRESS_BAI -unsigned cypress_b_gpio_rest_mux = MUX_RST_GPIO_FORCE_HEDERA; - -struct inv_ioexp_layout_s cypress_b_ioexp_layout[] = { - /* IOEXP_ID / IOEXP_TYPE / { Chan_ID, Chip_addr, Read_offset, Write_offset, config_offset, data_default, conf_default } */ - {0, IOEXP_TYPE_SFP_8P_LAYOUT_1, { {2, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {2, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {2, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {1, IOEXP_TYPE_SFP_8P_LAYOUT_1, { {3, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {3, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {3, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {2, IOEXP_TYPE_SFP_8P_LAYOUT_1, { {4, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {4, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {4, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {3, IOEXP_TYPE_SFP_8P_LAYOUT_1, { {5, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {5, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {5, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {4, IOEXP_TYPE_SFP_8P_LAYOUT_1, { {6, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {6, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {6, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {5, IOEXP_TYPE_SFP_8P_LAYOUT_1, { {7, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {7, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {7, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {6, IOEXP_TYPE_CYPRESS_7ABC, { {8, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xc0, 0xc0}, }, /* addr[0] = I/O Expander 7 A */ - {8, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xc0, 0xc0}, {0xff, 0xc0}, }, /* addr[1] = I/O Expander 7 B */ - {8, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 7 C */ - }, -}; - -struct inv_port_layout_s cypress_b_port_layout[] = { - /* Port_ID / Chan_ID / IOEXP_ID / IOEXP_VIRT_OFFSET / TRANSCEIVER_TYPE / BCM_CHIP_TYPE / LANE_ID */ - { 1, 11, 0, 1, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 2} }, - { 2, 10, 0, 0, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 1} }, - { 3, 13, 0, 3, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 4} }, - { 4, 12, 0, 2, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 3} }, - { 5, 15, 0, 5, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 6} }, - { 6, 14, 0, 4, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 5} }, - { 7, 17, 0, 7, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 8} }, - { 8, 16, 0, 6, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 7} }, - { 9, 19, 1, 1, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 10} }, - {10, 18, 1, 0, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 9} }, - {11, 21, 1, 3, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 12} }, - {12, 20, 1, 2, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 11} }, - {13, 23, 1, 5, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 22} }, - {14, 22, 1, 4, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 21} }, - {15, 25, 1, 7, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 24} }, - {16, 24, 1, 6, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 23} }, - {17, 27, 2, 1, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 34} }, - {18, 26, 2, 0, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 33} }, - {19, 29, 2, 3, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 36} }, - {20, 28, 2, 2, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 35} }, - {21, 31, 2, 5, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 38} }, - {22, 30, 2, 4, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 37} }, - {23, 33, 2, 7, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 40} }, - {24, 32, 2, 6, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 39} }, - {25, 35, 3, 1, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 42} }, - {26, 34, 3, 0, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 41} }, - {27, 37, 3, 3, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 44} }, - {28, 36, 3, 2, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 43} }, - {29, 39, 3, 5, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 50} }, - {30, 38, 3, 4, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 49} }, - {31, 41, 3, 7, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 52} }, - {32, 40, 3, 6, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 51} }, - {33, 43, 4, 1, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 54} }, - {34, 42, 4, 0, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 53} }, - {35, 45, 4, 3, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 56} }, - {36, 44, 4, 2, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 55} }, - {37, 47, 4, 5, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 66} }, - {38, 46, 4, 4, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 65} }, - {39, 49, 4, 7, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 68} }, - {40, 48, 4, 6, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 67} }, - {41, 51, 5, 1, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 70} }, - {42, 50, 5, 0, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 69} }, - {43, 53, 5, 3, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 72} }, - {44, 52, 5, 2, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 71} }, - {45, 55, 5, 5, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 82} }, - {46, 54, 5, 4, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 81} }, - {47, 57, 5, 7, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 84} }, - {48, 56, 5, 6, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 83} }, - {49, 59, 6, 1, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 85, 86, 87, 88} }, - {50, 58, 6, 0, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 97, 98, 99,100} }, - {51, 61, 6, 3, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {105,106,107,108} }, - {52, 60, 6, 2, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {101,102,103,104} }, - {53, 63, 6, 5, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {117,118,119,120} }, - {54, 62, 6, 4, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {109,110,111,112} }, -}; -#endif - - -/* ========================================== - * Redwood_fsl Layout configuration - * ========================================== - */ -#ifdef SWPS_REDWOOD_FSL -unsigned redwood_fsl_gpio_rest_mux = MUX_RST_GPIO_48_PAC9548; - -struct inv_ioexp_layout_s redwood_fsl_ioexp_layout[] = { - /* IOEXP_ID / IOEXP_TYPE / { Chan_ID, Chip_addr, Read_offset, Write_offset, config_offset, data_default, conf_default } */ - {0, IOEXP_TYPE_REDWOOD_P01P08, { {4, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[0] = I/O Expander 1-4 A */ - {4, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[1] = I/O Expander 1-4 B */ - {0, 0x25, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 5 B */ - }, - {1, IOEXP_TYPE_REDWOOD_P09P16, { {5, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[0] = I/O Expander 1-4 A */ - {5, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[1] = I/O Expander 1-4 B */ - {0, 0x25, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 5 B */ - }, - {2, IOEXP_TYPE_REDWOOD_P01P08, { {2, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[0] = I/O Expander 1-4 A */ - {2, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[1] = I/O Expander 1-4 B */ - {0, 0x24, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 5 B */ - }, - {3, IOEXP_TYPE_REDWOOD_P09P16, { {3, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[0] = I/O Expander 1-4 A */ - {3, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[1] = I/O Expander 1-4 B */ - {0, 0x24, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 5 B */ - }, -}; - - -struct inv_port_layout_s redwood_fsl_port_layout[] = { - /* Port_ID / Chan_ID / IOEXP_ID / IOEXP_VIRT_OFFSET / TRANSCEIVER_TYPE / BCM_CHIP_TYPE / LANE_ID */ - { 0, 22, 0, 0, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 1, 2, 3, 4} }, - { 1, 23, 0, 1, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 5, 6, 7, 8} }, - { 2, 24, 0, 2, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 9, 10, 11, 12} }, - { 3, 25, 0, 3, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 13, 14, 15, 16} }, - { 4, 26, 0, 4, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 17, 18, 19, 20} }, - { 5, 27, 0, 5, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 21, 22, 23, 24} }, - { 6, 28, 0, 6, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 25, 26, 27, 28} }, - { 7, 29, 0, 7, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 29, 30, 31, 32} }, - { 8, 30, 1, 0, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 33, 34, 35, 36} }, - { 9, 31, 1, 1, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 37, 38, 39, 40} }, - {10, 32, 1, 2, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 41, 42, 43, 44} }, - {11, 33, 1, 3, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 45, 46, 47, 48} }, - {12, 34, 1, 4, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 49, 50, 51, 52} }, - {13, 35, 1, 5, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 53, 54, 55, 56} }, - {14, 36, 1, 6, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 57, 58, 59, 60} }, - {15, 37, 1, 7, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 61, 62, 63, 64} }, - {16, 6, 2, 0, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 65, 66, 67, 68} }, - {17, 7, 2, 1, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 69, 70, 71, 72} }, - {18, 8, 2, 2, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 73, 74, 75, 76} }, - {19, 9, 2, 3, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 77, 78, 79, 80} }, - {20, 10, 2, 4, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 81, 82, 83, 84} }, - {21, 11, 2, 5, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 85, 86, 87, 88} }, - {22, 12, 2, 6, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 89, 90, 91, 92} }, - {23, 13, 2, 7, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 93, 94, 95, 96} }, - {24, 14, 3, 0, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 97, 98, 99,100} }, - {25, 15, 3, 1, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {101,102,103,104} }, - {26, 16, 3, 2, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {105,106,107,108} }, - {27, 17, 3, 3, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {109,110,111,112} }, - {28, 18, 3, 4, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {113,114,115,116} }, - {29, 19, 3, 5, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {117,118,119,120} }, - {30, 20, 3, 6, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {121,122,123,124} }, - {31, 21, 3, 7, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {125,126,127,128} }, -}; -#endif - - -/* ========================================== - * Tahoe Layout configuration - * ========================================== - */ -#ifdef SWPS_TAHOE -unsigned tahoe_gpio_rest_mux = MUX_RST_GPIO_249_PCA9548; - -struct inv_ioexp_layout_s tahoe_ioexp_layout[] = { - /* IOEXP_ID / IOEXP_TYPE / { Chan_ID, Chip_addr, Read_offset, Write_offset, config_offset, data_default, conf_default } */ - {0, IOEXP_TYPE_TAHOE_6ABC, { {7, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xce, 0xb9}, {0x18, 0xe3}, }, /* addr[0] = I/O Expander 6 A */ - {7, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xce, 0xb9}, {0x18, 0xe3}, }, /* addr[1] = I/O Expander 6 B */ - {7, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xce, 0xb9}, {0x18, 0xe3}, }, }, /* addr[2] = I/O Expander 6 C */ - }, - {1, IOEXP_TYPE_TAHOE_5A, { {6, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xce, 0xb9}, {0x18, 0xe3}, }, }, /* addr[0] = I/O Expander 5 A */ - }, -}; - - -struct inv_port_layout_s tahoe_port_layout[] = { - /* Port_ID / Chan_ID / IOEXP_ID / IOEXP_VIRT_OFFSET / TRANSCEIVER_TYPE / BCM_CHIP_TYPE / LANE_ID */ - { 0, 12, 1, 2, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 65, 66, 67, 68} }, - { 1, 11, 1, 1, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 53, 54, 55, 56} }, - { 2, 22, 0, 5, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 69, 70, 71, 72} }, - { 3, 21, 0, 4, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 81, 82, 83, 84} }, - { 4, 24, 0, 7, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 97, 98, 99, 100} }, - { 5, 23, 0, 6, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 85, 86, 87, 88} }, - { 6, 18, 0, 1, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {101, 102, 103, 104} }, - { 7, 17, 0, 0, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {105, 106, 107, 108} }, - { 8, 20, 0, 3, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {113, 114, 115, 116} }, - { 9, 19, 0, 2, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {109, 110, 111, 112} }, -}; -#endif - - -/* ========================================== - * Sequoia Layout configuration - * ========================================== - */ -#ifdef SWPS_SEQUOIA -unsigned sequoia_gpio_rest_mux = MUX_RST_GPIO_69_PAC9548; - -struct inv_ioexp_layout_s sequoia_ioexp_layout[] = { - /* IOEXP_ID / IOEXP_TYPE / { Chan_ID, Chip_addr, Read_offset, Write_offset, config_offset, data_default, conf_default } */ - {0, IOEXP_TYPE_SEQUOIA_NABC, { {1, 0x20, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0x00, 0x00}, }, /* addr[0] = I/O Expander 0 A */ - {1, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0xff}, }, /* addr[1] = I/O Expander 0 B */ - {1, 0x22, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 0 C */ - }, - {1, IOEXP_TYPE_SEQUOIA_NABC, { {2, 0x20, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0x00, 0x00}, }, /* addr[0] = I/O Expander 1 A */ - {2, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0xff}, }, /* addr[1] = I/O Expander 1 B */ - {2, 0x22, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 1 C */ - }, - {2, IOEXP_TYPE_SEQUOIA_NABC, { {3, 0x20, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0x00, 0x00}, }, /* addr[0] = I/O Expander 2 A */ - {3, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0xff}, }, /* addr[1] = I/O Expander 2 B */ - {3, 0x22, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 2 C */ - }, - {3, IOEXP_TYPE_SEQUOIA_NABC, { {4, 0x20, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0x00, 0x00}, }, /* addr[0] = I/O Expander 3 A */ - {4, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0xff}, }, /* addr[1] = I/O Expander 3 B */ - {4, 0x22, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 3 C */ - }, - {4, IOEXP_TYPE_SEQUOIA_NABC, { {5, 0x20, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0x00, 0x00}, }, /* addr[0] = I/O Expander 4 A */ - {5, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0xff}, }, /* addr[1] = I/O Expander 4 B */ - {5, 0x22, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 4 C */ - }, - {5, IOEXP_TYPE_SEQUOIA_NABC, { {6, 0x20, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0x00, 0x00}, }, /* addr[0] = I/O Expander 5 A */ - {6, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0xff}, }, /* addr[1] = I/O Expander 5 B */ - {6, 0x22, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 5 C */ - }, - {6, IOEXP_TYPE_SEQUOIA_NABC, { {7, 0x20, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0x00, 0x00}, }, /* addr[0] = I/O Expander 6 A */ - {7, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0xff}, }, /* addr[1] = I/O Expander 6 B */ - {7, 0x22, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 6 C */ - }, - {7, IOEXP_TYPE_SEQUOIA_NABC, { {8, 0x20, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0x00, 0x00}, }, /* addr[0] = I/O Expander 7 A */ - {8, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0xff}, }, /* addr[1] = I/O Expander 7 B */ - {8, 0x22, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 7 C */ - }, -}; - - -struct inv_port_layout_s sequoia_port_layout[] = { - /* Port_ID / Chan_ID / IOEXP_ID / IOEXP_VIRT_OFFSET / TRANSCEIVER_TYPE / BCM_CHIP_TYPE / LANE_ID */ - { 0, 9, 0, 0, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 9, 10, 11, 12} }, - { 1, 10, 0, 1, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 1, 2, 3, 4} }, - { 2, 11, 0, 2, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 25, 26, 27, 28} }, - { 3, 12, 0, 3, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 17, 18, 19, 20} }, - { 4, 13, 0, 4, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 41, 42, 43, 44} }, - { 5, 14, 0, 5, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 33, 34, 35, 36} }, - { 6, 15, 0, 6, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 57, 58, 59, 60} }, - { 7, 16, 0, 7, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 49, 50, 51, 52} }, - { 8, 17, 1, 0, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 73, 74, 75, 76} }, - { 9, 18, 1, 1, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 65, 66, 67, 68} }, - {10, 19, 1, 2, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 89, 90, 91, 92} }, - {11, 20, 1, 3, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 81, 82, 83, 84} }, - {12, 21, 1, 4, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {105, 106, 107, 108} }, - {13, 22, 1, 5, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 97, 98, 99, 100} }, - {14, 23, 1, 6, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {121, 122, 123, 124} }, - {15, 24, 1, 7, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {113, 114, 115, 116} }, - {16, 25, 2, 0, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {137, 138, 139, 140} }, - {17, 26, 2, 1, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {129, 130, 131, 132} }, - {18, 27, 2, 2, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {153, 154, 155, 156} }, - {19, 28, 2, 3, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {145, 146, 147, 148} }, - {20, 29, 2, 4, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {169, 170, 171, 172} }, - {21, 30, 2, 5, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {161, 162, 163, 164} }, - {22, 31, 2, 6, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {185, 186, 187, 188} }, - {23, 32, 2, 7, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {177, 178, 179, 180} }, - {24, 33, 3, 0, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {201, 202, 203, 204} }, - {25, 34, 3, 1, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {193, 194, 195, 196} }, - {26, 35, 3, 2, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {217, 218, 219, 220} }, - {27, 36, 3, 3, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {209, 210, 211, 212} }, - {28, 37, 3, 4, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {233, 234, 235, 236} }, - {29, 38, 3, 5, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {225, 226, 227, 228} }, - {30, 39, 3, 6, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {249, 250, 251, 252} }, - {31, 40, 3, 7, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {241, 242, 243, 244} }, - {32, 44, 4, 3, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 13, 14, 15, 16} }, - {33, 43, 4, 2, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 5, 6, 7, 8} }, - {34, 42, 4, 1, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 29, 30, 31, 32} }, - {35, 41, 4, 0, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 21, 22, 23, 24} }, - {36, 48, 4, 7, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 45, 46, 47, 48} }, - {37, 47, 4, 6, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 37, 38, 39, 40} }, - {38, 46, 4, 5, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 61, 62, 63, 64} }, - {39, 45, 4, 4, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 53, 54, 55, 56} }, - {40, 52, 5, 3, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 77, 78, 79, 80} }, - {41, 51, 5, 2, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 69, 70, 71, 72} }, - {42, 50, 5, 1, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 93, 94, 95, 96} }, - {43, 49, 5, 0, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 85, 86, 87, 88} }, - {44, 56, 5, 7, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {109, 110, 111, 112} }, - {45, 55, 5, 6, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {101, 102, 103, 104} }, - {46, 54, 5, 5, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {125, 126, 127, 128} }, - {47, 53, 5, 4, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {117, 118, 119, 120} }, - {48, 60, 6, 3, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {141, 142, 143, 144} }, - {49, 59, 6, 2, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {133, 134, 135, 136} }, - {50, 58, 6, 1, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {157, 158, 159, 160} }, - {51, 57, 6, 0, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {149, 150, 151, 152} }, - {52, 64, 6, 7, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {173, 174, 175, 176} }, - {53, 63, 6, 6, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {165, 166, 167, 168} }, - {54, 62, 6, 5, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {189, 190, 191, 192} }, - {55, 61, 6, 4, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {181, 182, 183, 184} }, - {56, 68, 7, 3, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {205, 206, 207, 208} }, - {57, 67, 7, 2, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {197, 198, 199, 200} }, - {58, 66, 7, 1, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {221, 222, 223, 224} }, - {59, 65, 7, 0, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {213, 214, 215, 216} }, - {60, 72, 7, 7, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {237, 238, 239, 240} }, - {61, 71, 7, 6, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {229, 230, 231, 232} }, - {62, 70, 7, 5, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {253, 254, 255, 256} }, - {63, 69, 7, 4, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {245, 246, 247, 248} }, -}; -#endif - - -/* ========================================== - * Lavender Layout configuration - * ========================================== - */ -#if (PLATFORM_SETTINGS == PLATFORM_TYPE_LAVENDER_GA) -unsigned lavender_gpio_rest_mux = MUX_RST_GPIO_505_PCA9548; -#elif (PLATFORM_SETTINGS == PLATFORM_TYPE_LAVENDER_ONL) -unsigned lavender_gpio_rest_mux = MUX_RST_GPIO_69_PAC9548; -#endif - -#ifdef SWPS_LAVENDER -struct inv_ioexp_layout_s lavender_ioexp_layout[] = { - /* IOEXP_ID / IOEXP_TYPE / { Chan_ID, Chip_addr, Read_offset, Write_offset, config_offset, data_default, conf_default } */ - {0, IOEXP_TYPE_SEQUOIA_NABC, { { 1, 0x20, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0x00, 0x00}, }, /* addr[0] = I/O Expander 0 A */ - { 1, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0xff}, }, /* addr[1] = I/O Expander 0 B */ - { 1, 0x22, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 0 C */ - }, - {1, IOEXP_TYPE_SEQUOIA_NABC, { { 2, 0x20, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0x00, 0x00}, }, /* addr[0] = I/O Expander 1 A */ - { 2, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0xff}, }, /* addr[1] = I/O Expander 1 B */ - { 2, 0x22, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 1 C */ - }, - {2, IOEXP_TYPE_SEQUOIA_NABC, { { 3, 0x20, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0x00, 0x00}, }, /* addr[0] = I/O Expander 2 A */ - { 3, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0xff}, }, /* addr[1] = I/O Expander 2 B */ - { 3, 0x22, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 2 C */ - }, - {3, IOEXP_TYPE_SEQUOIA_NABC, { { 4, 0x20, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0x00, 0x00}, }, /* addr[0] = I/O Expander 3 A */ - { 4, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0xff}, }, /* addr[1] = I/O Expander 3 B */ - { 4, 0x22, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 3 C */ - }, - {4, IOEXP_TYPE_SEQUOIA_NABC, { { 9, 0x20, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0x00, 0x00}, }, /* addr[0] = I/O Expander 4 A */ - { 9, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0xff}, }, /* addr[1] = I/O Expander 4 B */ - { 9, 0x22, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 4 C */ - }, - {5, IOEXP_TYPE_SEQUOIA_NABC, { {10, 0x20, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0x00, 0x00}, }, /* addr[0] = I/O Expander 5 A */ - {10, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0xff}, }, /* addr[1] = I/O Expander 5 B */ - {10, 0x22, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 5 C */ - }, - {6, IOEXP_TYPE_SEQUOIA_NABC, { {11, 0x20, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0x00, 0x00}, }, /* addr[0] = I/O Expander 6 A */ - {11, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0xff}, }, /* addr[1] = I/O Expander 6 B */ - {11, 0x22, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 6 C */ - }, - {7, IOEXP_TYPE_SEQUOIA_NABC, { {12, 0x20, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0x00, 0x00}, }, /* addr[0] = I/O Expander 7 A */ - {12, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0xff}, }, /* addr[1] = I/O Expander 7 B */ - {12, 0x22, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 7 C */ - }, - {8, IOEXP_TYPE_LAVENDER_P65, { { 5, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xF6, 0xff}, {0xF8, 0xff}, }, }, /* addr[0] = I/O Expander CPU */ - }, -}; - - -struct inv_port_layout_s lavender_port_layout[] = { - /* Port_ID / Chan_ID / IOEXP_ID / IOEXP_VIRT_OFFSET / TRANSCEIVER_TYPE / BCM_CHIP_TYPE / LANE_ID */ - { 0, 17, 0, 0, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, {188, 189, 190, 191} }, - { 1, 18, 0, 1, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, {184, 185, 186, 187} }, - { 2, 19, 0, 2, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, {180, 181, 182, 183} }, - { 3, 20, 0, 3, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, {176, 177, 178, 179} }, - { 4, 21, 0, 4, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, {172, 173, 174, 175} }, - { 5, 22, 0, 5, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, {168, 169, 170, 171} }, - { 6, 23, 0, 6, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, {164, 165, 166, 167} }, - { 7, 24, 0, 7, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, {160, 161, 162, 163} }, - { 8, 25, 1, 0, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, {156, 157, 158, 159} }, - { 9, 26, 1, 1, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, {152, 153, 154, 155} }, - {10, 27, 1, 2, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, {148, 149, 150, 151} }, - {11, 28, 1, 3, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, {144, 145, 146, 147} }, - {12, 29, 1, 4, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, {140, 141, 142, 143} }, - {13, 30, 1, 5, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, {136, 137, 138, 139} }, - {14, 31, 1, 6, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, {132, 133, 134, 135} }, - {15, 32, 1, 7, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, {128, 129, 130, 131} }, - {16, 33, 2, 0, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, { 0, 1, 2, 3} }, - {17, 34, 2, 1, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, { 4, 5, 6, 7} }, - {18, 35, 2, 2, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, { 8, 9, 10, 11} }, - {19, 36, 2, 3, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, { 12, 13, 14, 15} }, - {20, 37, 2, 4, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, { 16, 17, 18, 19} }, - {21, 38, 2, 5, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, { 20, 21, 22, 23} }, - {22, 39, 2, 6, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, { 24, 25, 26, 27} }, - {23, 40, 2, 7, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, { 28, 29, 30, 31} }, - {24, 41, 3, 0, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, { 32, 33, 34, 35} }, - {25, 42, 3, 1, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, { 36, 37, 38, 39} }, - {26, 43, 3, 2, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, { 40, 41, 42, 43} }, - {27, 44, 3, 3, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, { 44, 45, 46, 47} }, - {28, 45, 3, 4, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, { 48, 49, 50, 51} }, - {29, 46, 3, 5, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, { 52, 53, 54, 55} }, - {30, 47, 3, 6, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, { 56, 57, 58, 59} }, - {31, 48, 3, 7, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, { 60, 61, 62, 63} }, - {32, 49, 4, 0, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, {256, 257, 258, 259} }, - {33, 50, 4, 1, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, {260, 261, 262, 263} }, - {34, 51, 4, 2, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, {264, 265, 266, 267} }, - {35, 52, 4, 3, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, {268, 269, 270, 271} }, - {36, 53, 4, 4, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, {272, 273, 274, 275} }, - {37, 54, 4, 5, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, {276, 277, 278, 279} }, - {38, 55, 4, 6, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, {280, 281, 282, 283} }, - {39, 56, 4, 7, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, {284, 285, 286, 287} }, - {40, 57, 5, 0, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, {288, 289, 290, 291} }, - {41, 58, 5, 1, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, {292, 293, 294, 295} }, - {42, 59, 5, 2, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, {296, 297, 298, 299} }, - {43, 60, 5, 3, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, {300, 301, 302, 303} }, - {44, 61, 5, 4, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, {304, 305, 306, 307} }, - {45, 62, 5, 5, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, {308, 309, 310, 311} }, - {46, 63, 5, 6, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, {312, 313, 314, 315} }, - {47, 64, 5, 7, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, {316, 317, 318, 319} }, - {48, 65, 6, 0, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, {444, 445, 446, 447} }, - {49, 66, 6, 1, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, {440, 441, 442, 443} }, - {50, 67, 6, 2, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, {436, 437, 438, 439} }, - {51, 68, 6, 3, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, {432, 433, 434, 435} }, - {52, 69, 6, 4, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, {428, 429, 430, 431} }, - {53, 70, 6, 5, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, {424, 425, 426, 427} }, - {54, 71, 6, 6, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, {420, 421, 422, 423} }, - {55, 72, 6, 7, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, {416, 417, 418, 419} }, - {56, 73, 7, 0, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, {412, 413, 414, 415} }, - {57, 74, 7, 1, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, {408, 409, 410, 411} }, - {58, 75, 7, 2, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, {404, 405, 406, 407} }, - {59, 76, 7, 3, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, {400, 401, 402, 403} }, - {60, 77, 7, 4, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, {396, 397, 398, 399} }, - {61, 78, 7, 5, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, {392, 393, 394, 395} }, - {62, 79, 7, 6, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, {388, 389, 390, 391} }, - {63, 80, 7, 7, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, {384, 385, 386, 387} }, - {64, 5, 8, 0, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, { 64, 65, 66, 67} }, -}; -#endif - -/* =========================================================== - * Cottonwood Layout configuration Rangeley (Rangeley CPU board) - * =========================================================== - */ -#ifdef SWPS_COTTONWOOD_RANGELEY -unsigned cottonwood_rangeley_gpio_rest_mux = MUX_RST_GPIO_500_PAC9548; - -struct inv_ioexp_layout_s cottonwood_rangeley_ioexp_layout[] = { - /* IOEXP_ID / IOEXP_TYPE / { Chan_ID, Chip_addr, Read_offset, Write_offset, config_offset, data_default, conf_default } */ - {0, CPLD_TYPE_COTTONWOOD,{ {1, 0x55, {22, 23, 24, 25}, {22, 23, 24, 25}, {-1, -1, -1, -1}, {0xee, 0xee, 0x99, 0x99}, {0x00, 0x00, 0x00, 0x00}, }, - }, - }, -}; - - -struct inv_port_layout_s cottonwood_rangeley_port_layout[] = { - /* Port_ID / Chan_ID / IOEXP_ID / IOEXP_VIRT_OFFSET / TRANSCEIVER_TYPE / BCM_CHI_TYPE / LANE_ID */ - { 0, 2, 0, 0, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 75} }, - { 1, 3, 0, 1, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 77} }, - { 2, 4, 0, 2, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 79} }, - { 3, 5, 0, 3, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 81} }, -}; -#endif - -/* =========================================================== - * Maple Layout configuration (Old) - * =========================================================== - */ -#ifdef SWPS_MAPLE_GA -unsigned maple_ga_gpio_rest_mux = MUX_RST_GPIO_505_PCA9548; - -struct inv_ioexp_layout_s maple_ga_ioexp_layout[] = { - /* IOEXP_ID / IOEXP_TYPE / { Chan_ID, Chip_addr, Read_offset, Write_offset, config_offset, data_default, conf_default } */ - {0, IOEXP_TYPE_MAPLE_0ABC, { {2, 0x20, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0x00, 0x00}, }, /* addr[0] = I/O Expander 0 A */ - {2, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0xff}, }, /* addr[1] = I/O Expander 0 B */ - {2, 0x22, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 0 C */ - }, - {1, IOEXP_TYPE_MAPLE_NABC, { {3, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {3, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {3, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {2, IOEXP_TYPE_MAPLE_NABC, { {4, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {4, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {4, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {3, IOEXP_TYPE_MAPLE_NABC, { {5, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {5, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {5, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {4, IOEXP_TYPE_MAPLE_NABC, { {6, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {6, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {6, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {5, IOEXP_TYPE_MAPLE_NABC, { {7, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {7, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {7, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {6, IOEXP_TYPE_MAPLE_NABC, { {8, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {8, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {8, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, -}; - -struct inv_port_layout_s maple_ga_port_layout[] = { - /* Port_ID / Chan_ID / IOEXP_ID / IOEXP_VIRT_OFFSET / TRANSCEIVER_TYPE / BCM_CHIP_TYPE / LANE_ID */ - { 0, 18, 1, 0, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_3, { 1} }, - { 1, 19, 1, 1, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_3, { 2} }, - { 2, 20, 1, 2, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_3, { 3} }, - { 3, 21, 1, 3, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_3, { 4} }, - { 4, 22, 1, 4, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_3, { 5} }, - { 5, 23, 1, 5, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_3, { 6} }, - { 6, 24, 1, 6, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_3, { 7} }, - { 7, 25, 1, 7, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_3, { 8} }, - { 8, 26, 2, 0, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_3, { 13} }, - { 9, 27, 2, 1, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_3, { 14} }, - {10, 28, 2, 2, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_3, { 15} }, - {11, 29, 2, 3, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_3, { 16} }, - {12, 30, 2, 4, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_3, { 21} }, - {13, 31, 2, 5, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_3, { 22} }, - {14, 32, 2, 6, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_3, { 23} }, - {15, 33, 2, 7, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_3, { 24} }, - {16, 34, 3, 0, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_3, { 29} }, - {17, 35, 3, 1, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_3, { 30} }, - {18, 36, 3, 2, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_3, { 31} }, - {19, 37, 3, 3, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_3, { 32} }, - {20, 38, 3, 4, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_3, { 33} }, - {21, 39, 3, 5, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_3, { 34} }, - {22, 40, 3, 6, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_3, { 35} }, - {23, 41, 3, 7, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_3, { 36} }, - {24, 42, 4, 0, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_3, { 41} }, - {25, 43, 4, 1, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_3, { 42} }, - {26, 44, 4, 2, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_3, { 43} }, - {27, 45, 4, 3, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_3, { 44} }, - {28, 46, 4, 4, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_3, { 49} }, - {29, 47, 4, 5, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_3, { 50} }, - {30, 48, 4, 6, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_3, { 51} }, - {31, 49, 4, 7, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_3, { 52} }, - {32, 50, 5, 0, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_3, { 57} }, - {33, 51, 5, 1, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_3, { 58} }, - {34, 52, 5, 2, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_3, { 59} }, - {35, 53, 5, 3, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_3, { 60} }, - {36, 54, 5, 4, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_3, { 61} }, - {37, 55, 5, 5, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_3, { 62} }, - {38, 56, 5, 6, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_3, { 63} }, - {39, 57, 5, 7, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_3, { 64} }, - {40, 58, 6, 0, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_3, { 65} }, - {41, 59, 6, 1, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_3, { 66} }, - {42, 60, 6, 2, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_3, { 67} }, - {43, 61, 6, 3, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_3, { 68} }, - {44, 62, 6, 4, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_3, { 69} }, - {45, 63, 6, 5, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_3, { 70} }, - {46, 64, 6, 6, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_3, { 71} }, - {47, 65, 6, 7, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_3, { 72} }, - {48, 10, 0, 0, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TRIDENT_3, { 77, 78, 79, 80} }, - {49, 11, 0, 1, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TRIDENT_3, { 85, 86, 87, 88} }, - {50, 12, 0, 2, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TRIDENT_3, { 93, 94, 95, 96} }, - {51, 13, 0, 3, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TRIDENT_3, { 97, 98, 99,100} }, - {52, 14, 0, 4, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TRIDENT_3, {105,106,107,108} }, - {53, 15, 0, 5, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TRIDENT_3, {113,114,115,116} }, - {54, 16, 0, 6, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TRIDENT_3, {121,122,123,124} }, - {55, 17, 0, 7, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TRIDENT_3, {125,126,127,128} }, -}; -#endif - -/* =========================================================== - * Maple Layout configuration (B version) - * =========================================================== - */ -#ifdef SWPS_MAPLE_B -unsigned maple_b_gpio_rest_mux = MUX_RST_GPIO_69_PAC9548; - -struct inv_ioexp_layout_s maple_b_ioexp_layout[] = { - /* IOEXP_ID / IOEXP_TYPE / { Chan_ID, Chip_addr, Read_offset, Write_offset, config_offset, data_default, conf_default } */ - {0, IOEXP_TYPE_MAPLE_0ABC, { { 6, 0x20, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0x00, 0x00}, }, /* addr[0] = I/O Expander 0 A */ - { 6, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0xff}, }, /* addr[1] = I/O Expander 0 B */ - { 6, 0x22, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 0 C */ - }, - {1, IOEXP_TYPE_MAPLE_NABC, { { 7, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - { 7, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - { 7, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {2, IOEXP_TYPE_MAPLE_NABC, { { 8, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - { 8, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - { 8, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {3, IOEXP_TYPE_MAPLE_NABC, { { 9, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - { 9, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - { 9, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {4, IOEXP_TYPE_MAPLE_NABC, { {10, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {10, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {10, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {5, IOEXP_TYPE_MAPLE_NABC, { {11, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {11, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {11, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {6, IOEXP_TYPE_MAPLE_NABC, { {12, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {12, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {12, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, -}; - -struct inv_port_layout_s maple_b_port_layout[] = { - /* Port_ID / Chan_ID / IOEXP_ID / IOEXP_VIRT_OFFSET / TRANSCEIVER_TYPE / BCM_CHIP_TYPE / LANE_ID */ - { 1, 23, 1, 1, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_3, { 2} }, - { 2, 22, 1, 0, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_3, { 1} }, - { 3, 25, 1, 3, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_3, { 4} }, - { 4, 24, 1, 2, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_3, { 3} }, - { 5, 27, 1, 5, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_3, { 6} }, - { 6, 26, 1, 4, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_3, { 5} }, - { 7, 29, 1, 7, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_3, { 8} }, - { 8, 28, 1, 6, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_3, { 7} }, - { 9, 31, 2, 1, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_3, { 14} }, - {10, 30, 2, 0, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_3, { 13} }, - {11, 33, 2, 3, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_3, { 16} }, - {12, 32, 2, 2, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_3, { 15} }, - {13, 35, 2, 5, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_3, { 22} }, - {14, 34, 2, 4, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_3, { 21} }, - {15, 37, 2, 7, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_3, { 24} }, - {16, 36, 2, 6, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_3, { 23} }, - {17, 39, 3, 1, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_3, { 30} }, - {18, 38, 3, 0, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_3, { 29} }, - {19, 41, 3, 3, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_3, { 32} }, - {20, 40, 3, 2, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_3, { 31} }, - {21, 43, 3, 5, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_3, { 34} }, - {22, 42, 3, 4, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_3, { 33} }, - {23, 45, 3, 7, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_3, { 36} }, - {24, 44, 3, 6, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_3, { 35} }, - {25, 47, 4, 1, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_3, { 42} }, - {26, 46, 4, 0, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_3, { 41} }, - {27, 49, 4, 3, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_3, { 44} }, - {28, 48, 4, 2, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_3, { 43} }, - {29, 51, 4, 5, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_3, { 50} }, - {30, 50, 4, 4, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_3, { 49} }, - {31, 53, 4, 7, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_3, { 52} }, - {32, 52, 4, 6, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_3, { 51} }, - {33, 55, 5, 1, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_3, { 58} }, - {34, 54, 5, 0, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_3, { 57} }, - {35, 57, 5, 3, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_3, { 60} }, - {36, 56, 5, 2, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_3, { 59} }, - {37, 59, 5, 5, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_3, { 62} }, - {38, 58, 5, 4, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_3, { 61} }, - {39, 61, 5, 7, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_3, { 64} }, - {40, 60, 5, 6, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_3, { 63} }, - {41, 63, 6, 1, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_3, { 66} }, - {42, 62, 6, 0, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_3, { 65} }, - {43, 65, 6, 3, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_3, { 68} }, - {44, 64, 6, 2, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_3, { 67} }, - {45, 67, 6, 5, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_3, { 70} }, - {46, 66, 6, 4, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_3, { 69} }, - {47, 69, 6, 7, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_3, { 72} }, - {48, 68, 6, 6, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_3, { 71} }, - {49, 15, 0, 1, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TRIDENT_3, { 77, 78, 79, 80} }, - {50, 14, 0, 0, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TRIDENT_3, { 85, 86, 87, 88} }, - {51, 17, 0, 3, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TRIDENT_3, { 97, 98, 99,100} }, - {52, 16, 0, 2, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TRIDENT_3, { 93, 94, 95, 96} }, - {53, 19, 0, 5, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TRIDENT_3, {105,106,107,108} }, - {54, 18, 0, 4, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TRIDENT_3, {113,114,115,116} }, - {55, 21, 0, 7, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TRIDENT_3, {125,126,127,128} }, - {56, 20, 0, 6, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TRIDENT_3, {121,122,123,124} }, -}; -#endif - - -/* ========================================== - * Gulmohar Layout configuration - * ========================================== - */ -#ifdef SWPS_GULMOHAR -unsigned gulmohar_gpio_rest_mux = MUX_RST_GPIO_505_PCA9548; - -struct inv_ioexp_layout_s gulmohar_ioexp_layout[] = { - /* IOEXP_ID / IOEXP_TYPE / { Chan_ID, Chip_addr, Read_offset, Write_offset, config_offset, data_default, conf_default } */ - {0, IOEXP_TYPE_GULMOHAR_NABC, { {2, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xf3, 0xf3}, {0xf3, 0xf3}, }, /* addr[0] = I/O Expander N A */ - {2, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xf3, 0xf3}, {0xf3, 0xf3}, }, /* addr[1] = I/O Expander N B */ - {2, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {1, IOEXP_TYPE_GULMOHAR_NABC, { {3, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xf3, 0xf3}, {0xf3, 0xf3}, }, /* addr[0] = I/O Expander N A */ - {3, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xf3, 0xf3}, {0xf3, 0xf3}, }, /* addr[1] = I/O Expander N B */ - {3, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {2, IOEXP_TYPE_GULMOHAR_NABC, { {4, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xf3, 0xf3}, {0xf3, 0xf3}, }, /* addr[0] = I/O Expander N A */ - {4, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xf3, 0xf3}, {0xf3, 0xf3}, }, /* addr[1] = I/O Expander N B */ - {4, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {3, IOEXP_TYPE_GULMOHAR_NABC, { {5, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xf3, 0xf3}, {0xf3, 0xf3}, }, /* addr[0] = I/O Expander N A */ - {5, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xf3, 0xf3}, {0xf3, 0xf3}, }, /* addr[1] = I/O Expander N B */ - {5, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {4, IOEXP_TYPE_GULMOHAR_NABC, { {6, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xf3, 0xf3}, {0xf3, 0xf3}, }, /* addr[0] = I/O Expander N A */ - {6, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xf3, 0xf3}, {0xf3, 0xf3}, }, /* addr[1] = I/O Expander N B */ - {6, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {5, IOEXP_TYPE_GULMOHAR_NABC, { {7, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xf3, 0xf3}, {0xf3, 0xf3}, }, /* addr[0] = I/O Expander N A */ - {7, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xf3, 0xf3}, {0xf3, 0xf3}, }, /* addr[1] = I/O Expander N B */ - {7, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {6, IOEXP_TYPE_GULMOHAR_7ABC, { {8, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xc0, 0xff}, {0xc0, 0xc0}, }, /* addr[0] = I/O Expander 7 A */ - {8, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xc0, 0xff}, }, /* addr[1] = I/O Expander 7 B */ - {8, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xc0, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 7 C */ - }, -}; - - - -struct inv_port_layout_s gulmohar_port_layout[] = { - /* Port_ID / Chan_ID / IOEXP_ID / IOEXP_VIRT_OFFSET / TRANSCEIVER_TYPE / BCM_CHIP_TYPE / LANE_ID */ - { 0, 10, 0, 0, TRANSVR_TYPE_SFP, BF_CHIP_TYPE_TOFINO, { 1} }, - { 1, 11, 0, 1, TRANSVR_TYPE_SFP, BF_CHIP_TYPE_TOFINO, { 2} }, - { 2, 12, 0, 2, TRANSVR_TYPE_SFP, BF_CHIP_TYPE_TOFINO, { 3} }, - { 3, 13, 0, 3, TRANSVR_TYPE_SFP, BF_CHIP_TYPE_TOFINO, { 4} }, - { 4, 14, 0, 4, TRANSVR_TYPE_SFP, BF_CHIP_TYPE_TOFINO, { 5} }, - { 5, 15, 0, 5, TRANSVR_TYPE_SFP, BF_CHIP_TYPE_TOFINO, { 6} }, - { 6, 16, 0, 6, TRANSVR_TYPE_SFP, BF_CHIP_TYPE_TOFINO, { 7} }, - { 7, 17, 0, 7, TRANSVR_TYPE_SFP, BF_CHIP_TYPE_TOFINO, { 8} }, - { 8, 18, 1, 0, TRANSVR_TYPE_SFP, BF_CHIP_TYPE_TOFINO, { 9} }, - { 9, 19, 1, 1, TRANSVR_TYPE_SFP, BF_CHIP_TYPE_TOFINO, { 10} }, - {10, 20, 1, 2, TRANSVR_TYPE_SFP, BF_CHIP_TYPE_TOFINO, { 11} }, - {11, 21, 1, 3, TRANSVR_TYPE_SFP, BF_CHIP_TYPE_TOFINO, { 12} }, - {12, 22, 1, 4, TRANSVR_TYPE_SFP, BF_CHIP_TYPE_TOFINO, { 21} }, - {13, 23, 1, 5, TRANSVR_TYPE_SFP, BF_CHIP_TYPE_TOFINO, { 22} }, - {14, 24, 1, 6, TRANSVR_TYPE_SFP, BF_CHIP_TYPE_TOFINO, { 23} }, - {15, 25, 1, 7, TRANSVR_TYPE_SFP, BF_CHIP_TYPE_TOFINO, { 24} }, - {16, 26, 2, 0, TRANSVR_TYPE_SFP, BF_CHIP_TYPE_TOFINO, { 33} }, - {17, 27, 2, 1, TRANSVR_TYPE_SFP, BF_CHIP_TYPE_TOFINO, { 34} }, - {18, 28, 2, 2, TRANSVR_TYPE_SFP, BF_CHIP_TYPE_TOFINO, { 35} }, - {19, 29, 2, 3, TRANSVR_TYPE_SFP, BF_CHIP_TYPE_TOFINO, { 36} }, - {20, 30, 2, 4, TRANSVR_TYPE_SFP, BF_CHIP_TYPE_TOFINO, { 37} }, - {21, 31, 2, 5, TRANSVR_TYPE_SFP, BF_CHIP_TYPE_TOFINO, { 38} }, - {22, 32, 2, 6, TRANSVR_TYPE_SFP, BF_CHIP_TYPE_TOFINO, { 39} }, - {23, 33, 2, 7, TRANSVR_TYPE_SFP, BF_CHIP_TYPE_TOFINO, { 40} }, - {24, 34, 3, 0, TRANSVR_TYPE_SFP, BF_CHIP_TYPE_TOFINO, { 41} }, - {25, 35, 3, 1, TRANSVR_TYPE_SFP, BF_CHIP_TYPE_TOFINO, { 42} }, - {26, 36, 3, 2, TRANSVR_TYPE_SFP, BF_CHIP_TYPE_TOFINO, { 43} }, - {27, 37, 3, 3, TRANSVR_TYPE_SFP, BF_CHIP_TYPE_TOFINO, { 44} }, - {28, 38, 3, 4, TRANSVR_TYPE_SFP, BF_CHIP_TYPE_TOFINO, { 49} }, - {29, 39, 3, 5, TRANSVR_TYPE_SFP, BF_CHIP_TYPE_TOFINO, { 50} }, - {30, 40, 3, 6, TRANSVR_TYPE_SFP, BF_CHIP_TYPE_TOFINO, { 51} }, - {31, 41, 3, 7, TRANSVR_TYPE_SFP, BF_CHIP_TYPE_TOFINO, { 52} }, - {32, 42, 4, 0, TRANSVR_TYPE_SFP, BF_CHIP_TYPE_TOFINO, { 53} }, - {33, 43, 4, 1, TRANSVR_TYPE_SFP, BF_CHIP_TYPE_TOFINO, { 54} }, - {34, 44, 4, 2, TRANSVR_TYPE_SFP, BF_CHIP_TYPE_TOFINO, { 55} }, - {35, 45, 4, 3, TRANSVR_TYPE_SFP, BF_CHIP_TYPE_TOFINO, { 56} }, - {36, 46, 4, 4, TRANSVR_TYPE_SFP, BF_CHIP_TYPE_TOFINO, { 65} }, - {37, 47, 4, 5, TRANSVR_TYPE_SFP, BF_CHIP_TYPE_TOFINO, { 66} }, - {38, 48, 4, 6, TRANSVR_TYPE_SFP, BF_CHIP_TYPE_TOFINO, { 67} }, - {39, 49, 4, 7, TRANSVR_TYPE_SFP, BF_CHIP_TYPE_TOFINO, { 68} }, - {40, 50, 5, 0, TRANSVR_TYPE_SFP, BF_CHIP_TYPE_TOFINO, { 69} }, - {41, 51, 5, 1, TRANSVR_TYPE_SFP, BF_CHIP_TYPE_TOFINO, { 70} }, - {42, 52, 5, 2, TRANSVR_TYPE_SFP, BF_CHIP_TYPE_TOFINO, { 71} }, - {43, 53, 5, 3, TRANSVR_TYPE_SFP, BF_CHIP_TYPE_TOFINO, { 72} }, - {44, 54, 5, 4, TRANSVR_TYPE_SFP, BF_CHIP_TYPE_TOFINO, { 81} }, - {45, 55, 5, 5, TRANSVR_TYPE_SFP, BF_CHIP_TYPE_TOFINO, { 82} }, - {46, 56, 5, 6, TRANSVR_TYPE_SFP, BF_CHIP_TYPE_TOFINO, { 83} }, - {47, 57, 5, 7, TRANSVR_TYPE_SFP, BF_CHIP_TYPE_TOFINO, { 84} }, - {48, 58, 6, 0, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, { 97, 98, 99,100} }, - {49, 59, 6, 1, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, { 85, 86, 87, 88} }, - {50, 60, 6, 2, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, {101,102,103,104} }, - {51, 61, 6, 3, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, {105,106,107,108} }, - {52, 62, 6, 4, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, {109,110,111,112} }, - {53, 63, 6, 5, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, {109,110,111,112} }, -}; -#endif - - -/* =========================================================== - * Peony-SFP Layout configuration - * =========================================================== - */ -#ifdef SWPS_PEONY_SFP -unsigned peony_sfp_gpio_rest_mux = MUX_RST_CPLD_C0_A77_70_74_RST_ALL; - -struct inv_ioexp_layout_s peony_sfp_ioexp_layout[] = { - /* IOEXP_ID / IOEXP_TYPE / { Chan_ID, Chip_addr, Read_offset, Write_offset, config_offset, data_default, conf_default } */ - {0, IOEXP_TYPE_QSFP_6P_LAYOUT_1, { {4, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xc0, 0xff}, {0xc0, 0xc0}, }, /* addr[0] = I/O Expander 0 A */ - {4, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xc0, 0xff}, }, /* addr[1] = I/O Expander 0 B */ - {4, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xc0, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 0 C */ - }, - {1, IOEXP_TYPE_SFP_8P_LAYOUT_1, { {5, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {5, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {5, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {2, IOEXP_TYPE_SFP_8P_LAYOUT_1, { {6, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {6, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {6, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {3, IOEXP_TYPE_SFP_8P_LAYOUT_1, { {7, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {7, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {7, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {4, IOEXP_TYPE_SFP_8P_LAYOUT_1, { {8, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {8, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {8, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {5, IOEXP_TYPE_SFP_8P_LAYOUT_1, { {9, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {9, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {9, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {6, IOEXP_TYPE_SFP_8P_LAYOUT_1, { {10, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {10, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {10, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, -}; - -struct inv_port_layout_s peony_sfp_port_layout[] = { - /* Port_ID / Chan_ID / IOEXP_ID / IOEXP_VIRT_OFFSET / TRANSCEIVER_TYPE / BCM_CHIP_TYPE / LANE_ID */ - { 0, 20, 1, 0, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_3, { 1} }, - { 1, 21, 1, 1, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_3, { 2} }, - { 2, 22, 1, 2, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_3, { 3} }, - { 3, 23, 1, 3, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_3, { 4} }, - { 4, 24, 1, 4, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_3, { 5} }, - { 5, 25, 1, 5, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_3, { 6} }, - { 6, 26, 1, 6, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_3, { 7} }, - { 7, 27, 1, 7, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_3, { 8} }, - { 8, 28, 2, 0, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_3, { 13} }, - { 9, 29, 2, 1, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_3, { 14} }, - {10, 30, 2, 2, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_3, { 15} }, - {11, 31, 2, 3, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_3, { 16} }, - {12, 32, 2, 4, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_3, { 21} }, - {13, 33, 2, 5, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_3, { 22} }, - {14, 34, 2, 6, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_3, { 23} }, - {15, 35, 2, 7, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_3, { 24} }, - {16, 36, 3, 0, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_3, { 29} }, - {17, 37, 3, 1, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_3, { 30} }, - {18, 38, 3, 2, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_3, { 31} }, - {19, 39, 3, 3, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_3, { 32} }, - {20, 40, 3, 4, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_3, { 33} }, - {21, 41, 3, 5, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_3, { 34} }, - {22, 42, 3, 6, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_3, { 35} }, - {23, 43, 3, 7, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_3, { 36} }, - {24, 44, 4, 0, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_3, { 65} }, - {25, 45, 4, 1, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_3, { 66} }, - {26, 46, 4, 2, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_3, { 67} }, - {27, 47, 4, 3, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_3, { 68} }, - {28, 48, 4, 4, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_3, { 69} }, - {29, 49, 4, 5, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_3, { 70} }, - {30, 50, 4, 6, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_3, { 71} }, - {31, 51, 4, 7, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_3, { 72} }, - {32, 52, 5, 0, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_3, { 97} }, - {33, 53, 5, 1, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_3, { 98} }, - {34, 54, 5, 2, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_3, { 99} }, - {35, 55, 5, 3, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_3, {100} }, - {36, 56, 5, 4, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_3, {105} }, - {37, 57, 5, 5, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_3, {106} }, - {38, 58, 5, 6, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_3, {107} }, - {39, 59, 5, 7, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_3, {108} }, - {40, 60, 6, 0, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_3, {113} }, - {41, 61, 6, 1, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_3, {114} }, - {42, 62, 6, 2, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_3, {115} }, - {43, 63, 6, 3, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_3, {116} }, - {44, 64, 6, 4, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_3, {121} }, - {45, 65, 6, 5, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_3, {122} }, - {46, 66, 6, 6, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_3, {123} }, - {47, 67, 6, 7, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_3, {124} }, - {48, 12, 0, 0, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TRIDENT_3, { 49, 50, 51, 52} }, - {49, 13, 0, 1, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TRIDENT_3, { 57, 58, 59, 60} }, - {50, 14, 0, 2, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TRIDENT_3, { 61, 62, 63, 64} }, - {51, 15, 0, 3, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TRIDENT_3, { 77, 78, 79, 80} }, - {52, 16, 0, 4, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TRIDENT_3, { 85, 86, 87, 88} }, - {53, 17, 0, 5, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TRIDENT_3, { 93, 94, 95, 96} }, -}; -#endif - - -/* =========================================================== - * Peony-Copper Layout configuration - * =========================================================== - */ -#ifdef SWPS_PEONY_COPPER -unsigned peony_copper_gpio_rest_mux = MUX_RST_CPLD_C0_A77_70_74_RST_ALL; - -struct inv_ioexp_layout_s peony_copper_ioexp_layout[] = { - /* IOEXP_ID / IOEXP_TYPE / { Chan_ID, Chip_addr, Read_offset, Write_offset, config_offset, data_default, conf_default } */ - {0, IOEXP_TYPE_QSFP_6P_LAYOUT_1, { {10, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xc0, 0xff}, {0xc0, 0xc0}, }, /* addr[0] = I/O Expander 0 A */ - {10, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xc0, 0xff}, }, /* addr[1] = I/O Expander 0 B */ - {10, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xc0, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 0 C */ - }, -}; - -struct inv_port_layout_s peony_copper_port_layout[] = { - /* Port_ID / Chan_ID / IOEXP_ID / IOEXP_VIRT_OFFSET / TRANSCEIVER_TYPE / BCM_CHIP_TYPE / LANE_ID */ - {48, 4, 0, 0, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TRIDENT_3, { 49, 50, 51, 52} }, - {49, 5, 0, 1, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TRIDENT_3, { 57, 58, 59, 60} }, - {50, 6, 0, 2, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TRIDENT_3, { 61, 62, 63, 64} }, - {51, 7, 0, 3, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TRIDENT_3, { 77, 78, 79, 80} }, - {52, 8, 0, 4, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TRIDENT_3, { 85, 86, 87, 88} }, - {53, 9, 0, 5, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TRIDENT_3, { 93, 94, 95, 96} }, -}; -#endif - - - -#endif /* INV_SWPS_H */ - - - - - - - - - diff --git a/packages/platforms/inventec/x86-64/d6356/modules/builds/src/inv_vpd.c b/packages/platforms/inventec/x86-64/d6356/modules/builds/src/inv_vpd.c deleted file mode 100644 index 2075fd4ee..000000000 --- a/packages/platforms/inventec/x86-64/d6356/modules/builds/src/inv_vpd.c +++ /dev/null @@ -1,332 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "inv_vpd.h" -#include "onie_tlvinfo.h" - -static int vpd_major; -static struct class *vpd_class_p = NULL; -static char cEeprom[SYS_EEPROM_MAX_SIZE]; -static DEFINE_MUTEX(vpd_mutex); - -static int -__swp_match(struct device *dev, const void *data){ - - char *name = (char *)data; - if (strcmp(dev_name(dev), name) == 0) - return 1; - return 0; -} - -static -int get_vpd_data(struct i2c_client *pi2c_client, int i_offset, char *c_buf) -{ - int iRet; - - read_eeprom( pi2c_client, cEeprom); - iRet = tlvinfo_decode_tlv(cEeprom, i_offset,c_buf); - return iRet; -} - -static -int write_vpd_data(struct i2c_client *pi2c_client, int i_offset, const char *c_buf) -{ - int iErr = 0; - - if (read_eeprom(pi2c_client, cEeprom)) { - printk(KERN_ERR "write vpd data eror at %d-%s\n", __LINE__, __FUNCTION__); - return -1; - } - - if (tlvinfo_delete_tlv(cEeprom, i_offset) == TRUE) { - } - if (c_buf) { - if(!tlvinfo_add_tlv(cEeprom, i_offset , c_buf)) { - printk(KERN_ERR "write vpd data eror at %d-%s\n", __LINE__, __FUNCTION__); - iErr = -1; - } else { - iErr = prog_eeprom(pi2c_client,cEeprom); - } - } - return iErr; -} - -static struct device * -get_swpdev_by_name(char *name){ - struct device *dev = class_find_device(vpd_class_p, - NULL, - name, - __swp_match); - return dev; -} - -static ssize_t -store_attr_vpd(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - struct i2c_client *pi2c_client = dev_get_drvdata(dev_p); - struct vpd_device_attribute *attr = to_vpd_dev_attr(attr_p); - int iOffset = attr->index; - int iErr , iLen; - char *pChar; - - if (!pi2c_client){ - return -ENODEV; - } - mutex_lock(&vpd_mutex); - - //-strip 0x0a in the last byte. - for (iLen = 0, pChar = (char*)buf_p; - iLen < 255 && *pChar != 0; - iLen++, pChar++) ; - if (iLen !=0 && *pChar == 0 && *(pChar-1) == 0x0a) - *(pChar - 1) = 0; - //- - - iErr = write_vpd_data( pi2c_client, iOffset, buf_p); - - mutex_unlock(&vpd_mutex); - return count; -} - -static ssize_t -show_attr_vpd(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct i2c_client *pi2c_client = dev_get_drvdata(dev_p); - struct vpd_device_attribute *attr = to_vpd_dev_attr(attr_p); - int iOffset = attr->index; - int iErr , iLen; - - if (!pi2c_client){ - return -ENODEV; - } - mutex_lock(&vpd_mutex); - iErr = get_vpd_data( pi2c_client, iOffset, buf_p); - mutex_unlock(&vpd_mutex); - - if( iErr <= 0 ) - iLen = 0; - else - iLen = snprintf(buf_p, TLV_DECODE_VALUE_MAX_LEN, "%s\n", buf_p); - - return iLen; -} - -/* ================= Vpd attribute ======================== - */ -static VPD_DEVICE_ATTR(product_name ,S_IWUSR|S_IRUGO, show_attr_vpd, store_attr_vpd, TLV_CODE_PRODUCT_NAME ); -static VPD_DEVICE_ATTR(pn ,S_IWUSR|S_IRUGO, show_attr_vpd, store_attr_vpd, TLV_CODE_PART_NUMBER ); -static VPD_DEVICE_ATTR(sn ,S_IWUSR|S_IRUGO, show_attr_vpd, store_attr_vpd, TLV_CODE_SERIAL_NUMBER ); -static VPD_DEVICE_ATTR(base_mac_addr,S_IWUSR|S_IRUGO, show_attr_vpd, store_attr_vpd, TLV_CODE_MAC_BASE ); -static VPD_DEVICE_ATTR(man_date ,S_IWUSR|S_IRUGO, show_attr_vpd, store_attr_vpd, TLV_CODE_MANUF_DATE ); -static VPD_DEVICE_ATTR(dev_ver ,S_IWUSR|S_IRUGO, show_attr_vpd, store_attr_vpd, TLV_CODE_DEVICE_VERSION ); -static VPD_DEVICE_ATTR(label_rev ,S_IWUSR|S_IRUGO, show_attr_vpd, store_attr_vpd, TLV_CODE_LABEL_REVISION ); -static VPD_DEVICE_ATTR(plat_name ,S_IWUSR|S_IRUGO, show_attr_vpd, store_attr_vpd, TLV_CODE_PLATFORM_NAME ); -static VPD_DEVICE_ATTR(ldr_ver ,S_IWUSR|S_IRUGO, show_attr_vpd, store_attr_vpd, TLV_CODE_ONIE_VERSION ); -static VPD_DEVICE_ATTR(mac_addr ,S_IWUSR|S_IRUGO, show_attr_vpd, store_attr_vpd, TLV_CODE_MAC_SIZE ); -static VPD_DEVICE_ATTR(manufacturer ,S_IWUSR|S_IRUGO, show_attr_vpd, store_attr_vpd, TLV_CODE_MANUF_NAME ); -static VPD_DEVICE_ATTR(country_code ,S_IWUSR|S_IRUGO, show_attr_vpd, store_attr_vpd, TLV_CODE_MANUF_COUNTRY ); -static VPD_DEVICE_ATTR(vendor_name ,S_IWUSR|S_IRUGO, show_attr_vpd, store_attr_vpd, TLV_CODE_VENDOR_NAME ); -static VPD_DEVICE_ATTR(diag_ver ,S_IWUSR|S_IRUGO, show_attr_vpd, store_attr_vpd, TLV_CODE_DIAG_VERSION ); -static VPD_DEVICE_ATTR(service_tag ,S_IWUSR|S_IRUGO, show_attr_vpd, store_attr_vpd, TLV_CODE_SERVICE_TAG ); -static VPD_DEVICE_ATTR(vendor_ext ,S_IWUSR|S_IRUGO, show_attr_vpd, store_attr_vpd, TLV_CODE_VENDOR_EXT ); -static VPD_DEVICE_ATTR(crc32 ,S_IRUGO, show_attr_vpd, NULL, TLV_CODE_CRC_32 ); - -static void -clean_vpd_common(void) -{ - dev_t dev_num; - struct device *device_p; - - device_p = get_swpdev_by_name(VPD_DEVICE); - if (device_p){ - dev_num = MKDEV(vpd_major, 1); - device_unregister(device_p); - device_destroy(vpd_class_p, dev_num); - } - VPD_DEBUG("%s: done.\n", __func__); -} - - -static struct register_attr VpdRegAttr[VPD_ENTRY_SIZE ] ={ - { &vpd_dev_attr_product_name.dev_attr, "vpd_dev_attr_product_name"}, - { &vpd_dev_attr_pn.dev_attr, "vpd_dev_attr_pn"}, - { &vpd_dev_attr_sn.dev_attr, "vpd_dev_attr_sn"}, - { &vpd_dev_attr_base_mac_addr.dev_attr, "vpd_dev_attr_base_mac_addr"}, - { &vpd_dev_attr_man_date.dev_attr, "vpd_dev_attr_man_date"}, - { &vpd_dev_attr_dev_ver.dev_attr, "vpd_dev_attr_dev_ver"}, - { &vpd_dev_attr_label_rev.dev_attr, "vpd_dev_attr_label_rev"}, - { &vpd_dev_attr_plat_name.dev_attr, "vpd_dev_attr_plat_name"}, - { &vpd_dev_attr_ldr_ver.dev_attr, "vpd_dev_attr_ldr_ver"}, - { &vpd_dev_attr_mac_addr.dev_attr, "vpd_dev_attr_mac_addr"}, - { &vpd_dev_attr_manufacturer.dev_attr, "vpd_dev_attr_manufacturer"}, - { &vpd_dev_attr_country_code.dev_attr, "vpd_dev_attr_country_code"}, - { &vpd_dev_attr_vendor_name.dev_attr, "vpd_dev_attr_vendor_name"}, - { &vpd_dev_attr_diag_ver.dev_attr, "vpd_dev_attr_diag_ver"}, - { &vpd_dev_attr_service_tag.dev_attr, "vpd_dev_attr_service_tag"}, - { &vpd_dev_attr_vendor_ext.dev_attr, "vpd_dev_attr_vendor_ext"}, - { &vpd_dev_attr_crc32.dev_attr, "vpd_dev_attr_crc32"}, -}; - -static int -register_vpd_attr(struct device *device_p){ - - char *err_attr = NULL; - int i; - - for( i = 0 ; i adapter = adap; - vpd_i2c_client->addr = VPD_I2C_ADDR; - - device_p = device_create(vpd_class_p, /* struct class *cls */ - NULL, /* struct device *parent */ - dev_num, /* dev_t devt */ - vpd_i2c_client, /* void *private_data */ - VPD_DEVICE); /* const char *fmt */ - if (IS_ERR(device_p)){ - err_msg = "device_create fail"; - goto err_register_vpd_device_1; - } - if (register_vpd_attr(device_p) < 0) { - err_msg = "register_vpd_attr fail"; - goto err_register_vpd_device_2; - } - return 0; - -err_register_vpd_device_2: - device_unregister(device_p); - device_destroy(vpd_class_p, dev_num); -err_register_vpd_device_1: - kfree(vpd_i2c_client); - vpd_i2c_client = NULL; -err_register_vpd_device: - VPD_ERR("%s: %s\n", __func__, err_msg); - return -1; -} - -static int -register_vpd_module(void) -{ - dev_t vpd_devt = 0; - - if (alloc_chrdev_region(&vpd_devt, 0, 1, VPD_DEVICE) < 0){ - VPD_WARN("Allocate VPD MAJOR failure! \n"); - goto err_register_vpd_module; - } - vpd_major = MAJOR(vpd_devt); - - /* Create class object */ - vpd_class_p = class_create(THIS_MODULE, EEPROM_CLASS); - if (IS_ERR(vpd_class_p)) { - VPD_ERR("Create class failure! \n"); - goto err_register_vpd_module_1; - } - return 0; - -err_register_vpd_module_1: - unregister_chrdev_region(MKDEV(vpd_major, 0), 1); -err_register_vpd_module: - return -1; -} - - -static int -init_vpd_common(void) -{ - char *err_msg = "ERR"; - - if (register_vpd_device() < 0) { - err_msg = "register_vpd_device fail"; - goto err_init_vpd_common; - } - return 0; - -err_init_vpd_common: - VPD_ERR("%s: %s\n", __func__, err_msg); - return -1; -} - - -static int __init -vpd_module_init(void) -{ - if (register_vpd_module() < 0){ - goto err_vpd_module_init; - } - if (init_vpd_common() < 0){ - goto err_vpd_module_init_1; - } - VPD_INFO("Inventec vpd module V.%s initial success.\n", VPD_VERSION); - return 0; - -err_vpd_module_init_1: - class_unregister(vpd_class_p); - class_destroy(vpd_class_p); - unregister_chrdev_region(MKDEV(vpd_major, 0), 1); -err_vpd_module_init: - VPD_ERR("Inventec vpd module V.%s initial failure.\n", VPD_VERSION); - return -1; -} - - -static void __exit -vpd_module_exit(void) -{ - clean_vpd_common(); - class_unregister(vpd_class_p); - class_destroy(vpd_class_p); - unregister_chrdev_region(MKDEV(vpd_major, 0), 1); - VPD_INFO("Remove Inventec vpd module success.\n"); -} - - -/* Module information */ -MODULE_AUTHOR(VPD_AUTHOR); -MODULE_DESCRIPTION(VPD_DESC); -MODULE_VERSION(VPD_VERSION); -MODULE_LICENSE(VPD_LICENSE); - -module_init(vpd_module_init); -module_exit(vpd_module_exit); diff --git a/packages/platforms/inventec/x86-64/d6356/modules/builds/src/inv_vpd.h b/packages/platforms/inventec/x86-64/d6356/modules/builds/src/inv_vpd.h deleted file mode 100644 index 58c7fe33f..000000000 --- a/packages/platforms/inventec/x86-64/d6356/modules/builds/src/inv_vpd.h +++ /dev/null @@ -1,46 +0,0 @@ -#ifndef INV_VPD_H -#define INV_VPD_H - -#define EEPROM_CLASS "eeprom" -#define VPD_DEVICE "vpd" -#define VPD_AUTHOR "Neil " -#define VPD_DESC "Inventec eeprom vpd driver" -#define VPD_VERSION "1.0.0" -#define VPD_LICENSE "GPL" - -#define VPD_ENTRY_SIZE (17) -#define VPD_I2C_BUS (0) -#define VPD_I2C_ADDR (0x53) - -struct register_attr { -struct device_attribute *attr; -char * errmsg; -}; - -struct vpd_device_attribute{ - struct device_attribute dev_attr; - int index; -}; - -#define to_vpd_dev_attr(_dev_attr) \ - container_of(_dev_attr, struct vpd_device_attribute, dev_attr) - -#define VPD_ATTR(_name, _mode, _show, _store, _index) \ - { .dev_attr = __ATTR(_name, _mode, _show, _store), \ - .index = _index } - -#define VPD_DEVICE_ATTR(_name, _mode, _show, _store, _index) \ - struct vpd_device_attribute vpd_dev_attr_##_name \ - = VPD_ATTR(_name, _mode, _show, _store, _index) - -#define VPD_INFO(fmt, args...) printk( KERN_INFO "[VPD] " fmt, ##args) -#define VPD_WARN(fmt, args...) printk( KERN_WARNING "[VPD] " fmt, ##args) -#define VPD_ERR(fmt, args...) printk( KERN_ERR "[VPD] " fmt, ##args) - -#ifdef DEBUG_VPD -# define VPD_DEBUG(fmt, args...) printk( KERN_DEBUG "[VPD] " fmt, ##args) -#else -# define VPD_DEBUG(fmt, args...) -#endif - -#endif /* INV_VPD_H */ diff --git a/packages/platforms/inventec/x86-64/d6356/modules/builds/src/io_expander.c b/packages/platforms/inventec/x86-64/d6356/modules/builds/src/io_expander.c deleted file mode 100644 index 1052a7a51..000000000 --- a/packages/platforms/inventec/x86-64/d6356/modules/builds/src/io_expander.c +++ /dev/null @@ -1,2317 +0,0 @@ -#include -#include -#include "io_expander.h" - -/* For build single module using (Ex: ONL platform) */ -//#include -//#include - - -static struct ioexp_obj_s *ioexp_head_p = NULL; -static struct ioexp_obj_s *ioexp_tail_p = NULL; - - -/* ========== Register IOEXP layout ========== - */ -struct ioexp_map_s ioexp_map_magnolia_nab = { - - .chip_amount = 2, - .data_width = 2, - - .map_present = { {0, 0, 4}, /* map_present[0] = MOD_ABS_PORT(X) */ - {0, 0, 5}, /* map_present[1] = MOD_ABS_PORT(X+1) */ - {0, 0, 6}, /* map_present[2] = MOD_ABS_PORT(X+2) */ - {0, 0, 7}, /* map_present[3] = MOD_ABS_PORT(X+3) */ - {1, 0, 4}, /* map_present[4] = MOD_ABS_PORT(X+4) */ - {1, 0, 5}, /* map_present[5] = MOD_ABS_PORT(X+5) */ - {1, 0, 6}, /* map_present[6] = MOD_ABS_PORT(X+6) */ - {1, 0, 7}, /* map_present[7] = MOD_ABS_PORT(X+7) */ - }, - .map_tx_disable = { {0, 1, 0}, /* map_tx_disable[0] = TXDISABLE_SFP+_P(X) */ - {0, 1, 1}, /* map_tx_disable[1] = TXDISABLE_SFP+_P(X+1) */ - {0, 1, 2}, /* map_tx_disable[2] = TXDISABLE_SFP+_P(X+2) */ - {0, 1, 3}, /* map_tx_disable[3] = TXDISABLE_SFP+_P(X+3) */ - {1, 1, 0}, /* map_tx_disable[4] = TXDISABLE_SFP+_P(X+4) */ - {1, 1, 1}, /* map_tx_disable[5] = TXDISABLE_SFP+_P(X+5) */ - {1, 1, 2}, /* map_tx_disable[6] = TXDISABLE_SFP+_P(X+6) */ - {1, 1, 3}, /* map_tx_disable[7] = TXDISABLE_SFP+_P(X+7) */ - }, - .map_tx_fault = { {0, 0, 0}, /* map_tx_fault[0] = TXFAULT_SFP+_P(X) */ - {0, 0, 1}, /* map_tx_fault[1] = TXFAULT_SFP+_P(X+1) */ - {0, 0, 2}, /* map_tx_fault[2] = TXFAULT_SFP+_P(X+2) */ - {0, 0, 3}, /* map_tx_fault[3] = TXFAULT_SFP+_P(X+3) */ - {1, 0, 0}, /* map_tx_fault[4] = TXFAULT_SFP+_P(X+4) */ - {1, 0, 1}, /* map_tx_fault[5] = TXFAULT_SFP+_P(X+5) */ - {1, 0, 2}, /* map_tx_fault[6] = TXFAULT_SFP+_P(X+6) */ - {1, 0, 3}, /* map_tx_fault[7] = TXFAULT_SFP+_P(X+7) */ - }, - .map_rxlos = { {0, 1, 4}, /* map_rxlos[0] = OPRXLOS_PORT(X) */ - {0, 1, 5}, /* map_rxlos[1] = OPRXLOS_PORT(X+1) */ - {0, 1, 6}, /* map_rxlos[2] = OPRXLOS_PORT(X+2) */ - {0, 1, 7}, /* map_rxlos[3] = OPRXLOS_PORT(X+3) */ - {1, 1, 4}, /* map_rxlos[4] = OPRXLOS_PORT(X+4) */ - {1, 1, 5}, /* map_rxlos[5] = OPRXLOS_PORT(X+5) */ - {1, 1, 6}, /* map_rxlos[6] = OPRXLOS_PORT(X+6) */ - {1, 1, 7}, /* map_rxlos[7] = OPRXLOS_PORT(X+7) */ - }, -}; - - -struct ioexp_map_s ioexp_map_magnolia_4ab = { - - .chip_amount = 2, - .data_width = 2, - - .map_present = { {0, 0, 4}, /* map_present[0] = MOD_ABS_PORT(X) */ - {0, 0, 5}, /* map_present[1] = MOD_ABS_PORT(X+1) */ - {0, 0, 6}, /* map_present[2] = MOD_ABS_PORT(X+2) */ - {0, 0, 7}, /* map_present[3] = MOD_ABS_PORT(X+3) */ - {1, 0, 4}, /* map_present[4] = MOD_ABS_PORT(X+4) */ - {1, 0, 5}, /* map_present[5] = MOD_ABS_PORT(X+5) */ - {1, 0, 6}, /* map_present[6] = MOD_ABS_PORT(X+6) */ - {1, 0, 7}, /* map_present[7] = MOD_ABS_PORT(X+7) */ - }, - .map_tx_disable = { {0, 1, 0}, /* map_tx_disable[0] = TXDISABLE_SFP+_P(X) */ - {0, 1, 1}, /* map_tx_disable[1] = TXDISABLE_SFP+_P(X+1) */ - {0, 1, 2}, /* map_tx_disable[2] = TXDISABLE_SFP+_P(X+2) */ - {0, 1, 3}, /* map_tx_disable[3] = TXDISABLE_SFP+_P(X+3) */ - {1, 0, 0}, /* map_tx_disable[4] = TXDISABLE_SFP+_P(X+4) */ - {1, 0, 1}, /* map_tx_disable[5] = TXDISABLE_SFP+_P(X+5) */ - {1, 0, 2}, /* map_tx_disable[6] = TXDISABLE_SFP+_P(X+6) */ - {1, 0, 3}, /* map_tx_disable[7] = TXDISABLE_SFP+_P(X+7) */ - }, - .map_tx_fault = { {0, 0, 0}, /* map_tx_fault[0] = TXFAULT_SFP+_P(X) */ - {0, 0, 1}, /* map_tx_fault[1] = TXFAULT_SFP+_P(X+1) */ - {0, 0, 2}, /* map_tx_fault[2] = TXFAULT_SFP+_P(X+2) */ - {0, 0, 3}, /* map_tx_fault[3] = TXFAULT_SFP+_P(X+3) */ - {1, 1, 0}, /* map_tx_fault[4] = TXFAULT_SFP+_P(X+4) */ - {1, 1, 1}, /* map_tx_fault[5] = TXFAULT_SFP+_P(X+5) */ - {1, 1, 2}, /* map_tx_fault[6] = TXFAULT_SFP+_P(X+6) */ - {1, 1, 3}, /* map_tx_fault[7] = TXFAULT_SFP+_P(X+7) */ - }, - .map_rxlos = { {0, 1, 4}, /* map_rxlos[0] = OPRXLOS_PORT(X) */ - {0, 1, 5}, /* map_rxlos[1] = OPRXLOS_PORT(X+1) */ - {0, 1, 6}, /* map_rxlos[2] = OPRXLOS_PORT(X+2) */ - {0, 1, 7}, /* map_rxlos[3] = OPRXLOS_PORT(X+3) */ - {1, 1, 4}, /* map_rxlos[4] = OPRXLOS_PORT(X+4) */ - {1, 1, 5}, /* map_rxlos[5] = OPRXLOS_PORT(X+5) */ - {1, 1, 6}, /* map_rxlos[6] = OPRXLOS_PORT(X+6) */ - {1, 1, 7}, /* map_rxlos[7] = OPRXLOS_PORT(X+7) */ - }, -}; - - -struct ioexp_map_s ioexp_map_magnolia_7ab = { - - .chip_amount = 2, - .data_width = 2, - - .map_present = { {1, 0, 4}, /* map_present[0] = MOD_ABS_PORT(X) */ - {1, 0, 5}, /* map_present[1] = MOD_ABS_PORT(X+1) */ - {1, 0, 6}, /* map_present[2] = MOD_ABS_PORT(X+2) */ - {1, 0, 7}, /* map_present[3] = MOD_ABS_PORT(X+3) */ - {1, 1, 4}, /* map_present[4] = MOD_ABS_PORT(X+4) */ - {1, 1, 5}, /* map_present[5] = MOD_ABS_PORT(X+5) */ - }, - .map_reset = { {0, 0, 0}, /* map_reset[0] = QRESET_QSFP_N_P(X) */ - {0, 0, 1}, /* map_reset[1] = QRESET_QSFP_N_P(X+1) */ - {0, 0, 2}, /* map_reset[2] = QRESET_QSFP_N_P(X+2) */ - {0, 0, 3}, /* map_reset[3] = QRESET_QSFP_N_P(X+3) */ - {1, 0, 0}, /* map_reset[4] = QRESET_QSFP_N_P(X+4) */ - {1, 0, 1}, /* map_reset[5] = QRESET_QSFP_N_P(X+5) */ - }, - .map_lpmod = { {0, 0, 4}, /* map_lpmod[0] = LPMODE_QSFP_P(X) */ - {0, 0, 5}, /* map_lpmod[1] = LPMODE_QSFP_P(X+1) */ - {0, 0, 6}, /* map_lpmod[2] = LPMODE_QSFP_P(X+2) */ - {0, 0, 7}, /* map_lpmod[3] = LPMODE_QSFP_P(X+3) */ - {1, 0, 2}, /* map_lpmod[4] = LPMODE_QSFP_P(X+4) */ - {1, 0, 3}, /* map_lpmod[5] = LPMODE_QSFP_P(X+5) */ - }, - .map_modsel = { {0, 1, 4}, /* map_modsel[0] = MODSEL_QSFP_N_P(X) */ - {0, 1, 5}, /* map_modsel[1] = MODSEL_QSFP_N_P(X+1) */ - {0, 1, 6}, /* map_modsel[2] = MODSEL_QSFP_N_P(X+2) */ - {0, 1, 7}, /* map_modsel[3] = MODSEL_QSFP_N_P(X+3) */ - {1, 1, 4}, /* map_modsel[4] = MODSEL_QSFP_N_P(X+4) */ - {1, 1, 5}, /* map_modsel[5] = MODSEL_QSFP_N_P(X+5) */ - }, -}; - - -struct ioexp_map_s ioexp_map_redwood_p01p08_p17p24 = { - - .chip_amount = 3, - .data_width = 2, - - .map_present = { {2, 0, 0}, /* map_present[0] = MOD_ABS_PORT(X) */ - {2, 0, 1}, /* map_present[1] = MOD_ABS_PORT(X+1) */ - {2, 0, 2}, /* map_present[2] = MOD_ABS_PORT(X+2) */ - {2, 0, 3}, /* map_present[3] = MOD_ABS_PORT(X+3) */ - {2, 0, 4}, /* map_present[4] = MOD_ABS_PORT(X+4) */ - {2, 0, 5}, /* map_present[5] = MOD_ABS_PORT(X+5) */ - {2, 0, 6}, /* map_present[6] = MOD_ABS_PORT(X+6) */ - {2, 0, 7}, /* map_present[7] = MOD_ABS_PORT(X+7) */ - }, - .map_reset = { {0, 0, 0}, /* map_reset[0] = QRESET_QSFP28_N_P(X) */ - {0, 0, 1}, /* map_reset[1] = QRESET_QSFP28_N_P(X+1) */ - {0, 0, 2}, /* map_reset[2] = QRESET_QSFP28_N_P(X+2) */ - {0, 0, 3}, /* map_reset[3] = QRESET_QSFP28_N_P(X+3) */ - {1, 0, 0}, /* map_reset[4] = QRESET_QSFP28_N_P(X+4) */ - {1, 0, 1}, /* map_reset[5] = QRESET_QSFP28_N_P(X+5) */ - {1, 0, 2}, /* map_reset[6] = QRESET_QSFP28_N_P(X+6) */ - {1, 0, 3}, /* map_reset[7] = QRESET_QSFP28_N_P(X+7) */ - }, - .map_lpmod = { {0, 0, 4}, /* map_lpmod[0] = LPMODE_QSFP28_P(X) */ - {0, 0, 5}, /* map_lpmod[1] = LPMODE_QSFP28_P(X+1) */ - {0, 0, 6}, /* map_lpmod[2] = LPMODE_QSFP28_P(X+2) */ - {0, 0, 7}, /* map_lpmod[3] = LPMODE_QSFP28_P(X+3) */ - {1, 0, 4}, /* map_lpmod[4] = LPMODE_QSFP28_P(X+4) */ - {1, 0, 5}, /* map_lpmod[5] = LPMODE_QSFP28_P(X+5) */ - {1, 0, 6}, /* map_lpmod[6] = LPMODE_QSFP28_P(X+6) */ - {1, 0, 7}, /* map_lpmod[7] = LPMODE_QSFP28_P(X+7) */ - }, - .map_modsel = { {0, 1, 4}, /* map_modsel[0] = MODSEL_QSFP28_N_P(X) */ - {0, 1, 5}, /* map_modsel[1] = MODSEL_QSFP28_N_P(X+1) */ - {0, 1, 6}, /* map_modsel[2] = MODSEL_QSFP28_N_P(X+2) */ - {0, 1, 7}, /* map_modsel[3] = MODSEL_QSFP28_N_P(X+3) */ - {1, 1, 4}, /* map_modsel[4] = MODSEL_QSFP28_N_P(X+4) */ - {1, 1, 5}, /* map_modsel[5] = MODSEL_QSFP28_N_P(X+5) */ - {1, 1, 6}, /* map_modsel[6] = MODSEL_QSFP28_N_P(X+6) */ - {1, 1, 7}, /* map_modsel[7] = MODSEL_QSFP28_N_P(X+7) */ - }, -}; - - -struct ioexp_map_s ioexp_map_redwood_p09p16_p25p32 = { - - .chip_amount = 3, - .data_width = 2, - - .map_present = { {2, 1, 0}, /* map_present[0] = MOD_ABS_PORT(X) */ - {2, 1, 1}, /* map_present[1] = MOD_ABS_PORT(X+1) */ - {2, 1, 2}, /* map_present[2] = MOD_ABS_PORT(X+2) */ - {2, 1, 3}, /* map_present[3] = MOD_ABS_PORT(X+3) */ - {2, 1, 4}, /* map_present[4] = MOD_ABS_PORT(X+4) */ - {2, 1, 5}, /* map_present[5] = MOD_ABS_PORT(X+5) */ - {2, 1, 6}, /* map_present[6] = MOD_ABS_PORT(X+6) */ - {2, 1, 7}, /* map_present[7] = MOD_ABS_PORT(X+7) */ - }, - .map_reset = { {0, 0, 0}, /* map_reset[0] = QRESET_QSFP28_N_P(X) */ - {0, 0, 1}, /* map_reset[1] = QRESET_QSFP28_N_P(X+1) */ - {0, 0, 2}, /* map_reset[2] = QRESET_QSFP28_N_P(X+2) */ - {0, 0, 3}, /* map_reset[3] = QRESET_QSFP28_N_P(X+3) */ - {1, 0, 0}, /* map_reset[4] = QRESET_QSFP28_N_P(X+4) */ - {1, 0, 1}, /* map_reset[5] = QRESET_QSFP28_N_P(X+5) */ - {1, 0, 2}, /* map_reset[6] = QRESET_QSFP28_N_P(X+6) */ - {1, 0, 3}, /* map_reset[7] = QRESET_QSFP28_N_P(X+7) */ - }, - .map_lpmod = { {0, 0, 4}, /* map_lpmod[0] = LPMODE_QSFP28_P(X) */ - {0, 0, 5}, /* map_lpmod[1] = LPMODE_QSFP28_P(X+1) */ - {0, 0, 6}, /* map_lpmod[2] = LPMODE_QSFP28_P(X+2) */ - {0, 0, 7}, /* map_lpmod[3] = LPMODE_QSFP28_P(X+3) */ - {1, 0, 4}, /* map_lpmod[4] = LPMODE_QSFP28_P(X+4) */ - {1, 0, 5}, /* map_lpmod[5] = LPMODE_QSFP28_P(X+5) */ - {1, 0, 6}, /* map_lpmod[6] = LPMODE_QSFP28_P(X+6) */ - {1, 0, 7}, /* map_lpmod[7] = LPMODE_QSFP28_P(X+7) */ - }, - .map_modsel = { {0, 1, 4}, /* map_modsel[0] = MODSEL_QSFP28_N_P(X) */ - {0, 1, 5}, /* map_modsel[1] = MODSEL_QSFP28_N_P(X+1) */ - {0, 1, 6}, /* map_modsel[2] = MODSEL_QSFP28_N_P(X+2) */ - {0, 1, 7}, /* map_modsel[3] = MODSEL_QSFP28_N_P(X+3) */ - {1, 1, 4}, /* map_modsel[4] = MODSEL_QSFP28_N_P(X+4) */ - {1, 1, 5}, /* map_modsel[5] = MODSEL_QSFP28_N_P(X+5) */ - {1, 1, 6}, /* map_modsel[6] = MODSEL_QSFP28_N_P(X+6) */ - {1, 1, 7}, /* map_modsel[7] = MODSEL_QSFP28_N_P(X+7) */ - }, -}; - - -struct ioexp_map_s ioexp_map_hudson32iga_p01p08_p17p24 = { - - .chip_amount = 3, - .data_width = 2, - - .map_present = { {2, 0, 0}, /* map_present[0] = MODABS_QSFP(X) */ - {2, 0, 1}, /* map_present[1] = MODABS_QSFP(X+1) */ - {2, 0, 2}, /* map_present[2] = MODABS_QSFP(X+2) */ - {2, 0, 3}, /* map_present[3] = MODABS_QSFP(X+3) */ - {2, 0, 4}, /* map_present[4] = MODABS_QSFP(X+4) */ - {2, 0, 5}, /* map_present[5] = MODABS_QSFP(X+5) */ - {2, 0, 6}, /* map_present[6] = MODABS_QSFP(X+6) */ - {2, 0, 7}, /* map_present[7] = MODABS_QSFP(X+7) */ - }, - .map_reset = { {0, 0, 0}, /* map_reset[0] = QRESET_QSFP(X) */ - {0, 0, 1}, /* map_reset[1] = QRESET_QSFP(X+1) */ - {0, 0, 2}, /* map_reset[2] = QRESET_QSFP(X+2) */ - {0, 0, 3}, /* map_reset[3] = QRESET_QSFP(X+3) */ - {1, 0, 0}, /* map_reset[4] = QRESET_QSFP(X+4) */ - {1, 0, 1}, /* map_reset[5] = QRESET_QSFP(X+5) */ - {1, 0, 2}, /* map_reset[6] = QRESET_QSFP(X+6) */ - {1, 0, 3}, /* map_reset[7] = QRESET_QSFP(X+7) */ - }, - .map_lpmod = { {0, 0, 4}, /* map_lpmod[0] = LPMODE_QSFP(X) */ - {0, 0, 5}, /* map_lpmod[1] = LPMODE_QSFP(X+1) */ - {0, 0, 6}, /* map_lpmod[2] = LPMODE_QSFP(X+2) */ - {0, 0, 7}, /* map_lpmod[3] = LPMODE_QSFP(X+3) */ - {1, 0, 4}, /* map_lpmod[4] = LPMODE_QSFP(X+4) */ - {1, 0, 5}, /* map_lpmod[5] = LPMODE_QSFP(X+5) */ - {1, 0, 6}, /* map_lpmod[6] = LPMODE_QSFP(X+6) */ - {1, 0, 7}, /* map_lpmod[7] = LPMODE_QSFP(X+7) */ - }, - .map_modsel = { {0, 1, 4}, /* map_modsel[0] = MODSEL_QSFP(X) */ - {0, 1, 5}, /* map_modsel[1] = MODSEL_QSFP(X+1) */ - {0, 1, 6}, /* map_modsel[2] = MODSEL_QSFP(X+2) */ - {0, 1, 7}, /* map_modsel[3] = MODSEL_QSFP(X+3) */ - {1, 1, 4}, /* map_modsel[4] = MODSEL_QSFP(X+4) */ - {1, 1, 5}, /* map_modsel[5] = MODSEL_QSFP(X+5) */ - {1, 1, 6}, /* map_modsel[6] = MODSEL_QSFP(X+6) */ - {1, 1, 7}, /* map_modsel[7] = MODSEL_QSFP(X+7) */ - }, -}; - - -struct ioexp_map_s ioexp_map_hudson32iga_p09p16_p25p32 = { - - .chip_amount = 3, - .data_width = 2, - - .map_present = { {2, 1, 0}, /* map_present[0] = MODABS_QSFP(X) */ - {2, 1, 1}, /* map_present[1] = MODABS_QSFP(X+1) */ - {2, 1, 2}, /* map_present[2] = MODABS_QSFP(X+2) */ - {2, 1, 3}, /* map_present[3] = MODABS_QSFP(X+3) */ - {2, 1, 4}, /* map_present[4] = MODABS_QSFP(X+4) */ - {2, 1, 5}, /* map_present[5] = MODABS_QSFP(X+5) */ - {2, 1, 6}, /* map_present[6] = MODABS_QSFP(X+6) */ - {2, 1, 7}, /* map_present[7] = MODABS_QSFP(X+7) */ - }, - .map_reset = { {0, 0, 0}, /* map_reset[0] = QRESET_QSFP(X) */ - {0, 0, 1}, /* map_reset[1] = QRESET_QSFP(X+1) */ - {0, 0, 2}, /* map_reset[2] = QRESET_QSFP(X+2) */ - {0, 0, 3}, /* map_reset[3] = QRESET_QSFP(X+3) */ - {1, 0, 0}, /* map_reset[4] = QRESET_QSFP(X+4) */ - {1, 0, 1}, /* map_reset[5] = QRESET_QSFP(X+5) */ - {1, 0, 2}, /* map_reset[6] = QRESET_QSFP(X+6) */ - {1, 0, 3}, /* map_reset[7] = QRESET_QSFP(X+7) */ - }, - .map_lpmod = { {0, 0, 4}, /* map_lpmod[0] = LPMODE_QSFP(X) */ - {0, 0, 5}, /* map_lpmod[1] = LPMODE_QSFP(X+1) */ - {0, 0, 6}, /* map_lpmod[2] = LPMODE_QSFP(X+2) */ - {0, 0, 7}, /* map_lpmod[3] = LPMODE_QSFP(X+3) */ - {1, 0, 4}, /* map_lpmod[4] = LPMODE_QSFP(X+4) */ - {1, 0, 5}, /* map_lpmod[5] = LPMODE_QSFP(X+5) */ - {1, 0, 6}, /* map_lpmod[6] = LPMODE_QSFP(X+6) */ - {1, 0, 7}, /* map_lpmod[7] = LPMODE_QSFP(X+7) */ - }, - .map_modsel = { {0, 1, 4}, /* map_modsel[0] = MODSEL_QSFP(X) */ - {0, 1, 5}, /* map_modsel[1] = MODSEL_QSFP(X+1) */ - {0, 1, 6}, /* map_modsel[2] = MODSEL_QSFP(X+2) */ - {0, 1, 7}, /* map_modsel[3] = MODSEL_QSFP(X+3) */ - {1, 1, 4}, /* map_modsel[4] = MODSEL_QSFP(X+4) */ - {1, 1, 5}, /* map_modsel[5] = MODSEL_QSFP(X+5) */ - {1, 1, 6}, /* map_modsel[6] = MODSEL_QSFP(X+6) */ - {1, 1, 7}, /* map_modsel[7] = MODSEL_QSFP(X+7) */ - }, -}; - - -struct ioexp_map_s ioexp_map_cypress_nabc = { - - .chip_amount = 3, - .data_width = 2, - - .map_present = { {0, 0, 4}, /* map_present[0] = MOD_ABS_PORT(X) */ - {0, 0, 5}, /* map_present[1] = MOD_ABS_PORT(X+1) */ - {0, 0, 6}, /* map_present[2] = MOD_ABS_PORT(X+2) */ - {0, 0, 7}, /* map_present[3] = MOD_ABS_PORT(X+3) */ - {1, 0, 4}, /* map_present[4] = MOD_ABS_PORT(X+4) */ - {1, 0, 5}, /* map_present[5] = MOD_ABS_PORT(X+5) */ - {1, 0, 6}, /* map_present[6] = MOD_ABS_PORT(X+6) */ - {1, 0, 7}, /* map_present[7] = MOD_ABS_PORT(X+7) */ - }, - .map_tx_disable = { {0, 1, 0}, /* map_tx_disable[0] = TXDISABLE_SFP+_P(X) */ - {0, 1, 1}, /* map_tx_disable[1] = TXDISABLE_SFP+_P(X+1) */ - {0, 1, 2}, /* map_tx_disable[2] = TXDISABLE_SFP+_P(X+2) */ - {0, 1, 3}, /* map_tx_disable[3] = TXDISABLE_SFP+_P(X+3) */ - {1, 1, 0}, /* map_tx_disable[4] = TXDISABLE_SFP+_P(X+4) */ - {1, 1, 1}, /* map_tx_disable[5] = TXDISABLE_SFP+_P(X+5) */ - {1, 1, 2}, /* map_tx_disable[6] = TXDISABLE_SFP+_P(X+6) */ - {1, 1, 3}, /* map_tx_disable[7] = TXDISABLE_SFP+_P(X+7) */ - }, - .map_tx_fault = { {0, 0, 0}, /* map_tx_fault[0] = TXFAULT_SFP+_P(X) */ - {0, 0, 1}, /* map_tx_fault[1] = TXFAULT_SFP+_P(X+1) */ - {0, 0, 2}, /* map_tx_fault[2] = TXFAULT_SFP+_P(X+2) */ - {0, 0, 3}, /* map_tx_fault[3] = TXFAULT_SFP+_P(X+3) */ - {1, 0, 0}, /* map_tx_fault[4] = TXFAULT_SFP+_P(X+4) */ - {1, 0, 1}, /* map_tx_fault[5] = TXFAULT_SFP+_P(X+5) */ - {1, 0, 2}, /* map_tx_fault[6] = TXFAULT_SFP+_P(X+6) */ - {1, 0, 3}, /* map_tx_fault[7] = TXFAULT_SFP+_P(X+7) */ - }, - .map_rxlos = { {0, 1, 4}, /* map_rxlos[0] = OPRXLOS_PORT(X) */ - {0, 1, 5}, /* map_rxlos[1] = OPRXLOS_PORT(X+1) */ - {0, 1, 6}, /* map_rxlos[2] = OPRXLOS_PORT(X+2) */ - {0, 1, 7}, /* map_rxlos[3] = OPRXLOS_PORT(X+3) */ - {1, 1, 4}, /* map_rxlos[4] = OPRXLOS_PORT(X+4) */ - {1, 1, 5}, /* map_rxlos[5] = OPRXLOS_PORT(X+5) */ - {1, 1, 6}, /* map_rxlos[6] = OPRXLOS_PORT(X+6) */ - {1, 1, 7}, /* map_rxlos[7] = OPRXLOS_PORT(X+7) */ - }, - .map_hard_rs0 = { {2, 0, 0}, /* map_hard_rs0[0] = RS0_SFP28_P(X) */ - {2, 0, 2}, /* map_hard_rs0[1] = RS0_SFP28_P(X+1) */ - {2, 0, 4}, /* map_hard_rs0[2] = RS0_SFP28_P(X+2) */ - {2, 0, 6}, /* map_hard_rs0[3] = RS0_SFP28_P(X+3) */ - {2, 1, 0}, /* map_hard_rs0[4] = RS0_SFP28_P(X+4) */ - {2, 1, 2}, /* map_hard_rs0[5] = RS0_SFP28_P(X+5) */ - {2, 1, 4}, /* map_hard_rs0[6] = RS0_SFP28_P(X+6) */ - {2, 1, 6}, /* map_hard_rs0[7] = RS0_SFP28_P(X+7) */ - }, - .map_hard_rs1 = { {2, 0, 1}, /* map_hard_rs1[0] = RS1_SFP28_P(X) */ - {2, 0, 3}, /* map_hard_rs1[1] = RS1_SFP28_P(X+1) */ - {2, 0, 5}, /* map_hard_rs1[2] = RS1_SFP28_P(X+2) */ - {2, 0, 7}, /* map_hard_rs1[3] = RS1_SFP28_P(X+3) */ - {2, 1, 1}, /* map_hard_rs1[4] = RS1_SFP28_P(X+4) */ - {2, 1, 3}, /* map_hard_rs1[5] = RS1_SFP28_P(X+5) */ - {2, 1, 5}, /* map_hard_rs1[6] = RS1_SFP28_P(X+6) */ - {2, 1, 7}, /* map_hard_rs1[7] = RS1_SFP28_P(X+7) */ - }, -}; - - -struct ioexp_map_s ioexp_map_cypress_7abc = { - - .chip_amount = 3, - .data_width = 2, - - .map_present = { {2, 0, 0}, /* map_present[0] = MOD_ABS_PORT(X) */ - {2, 0, 1}, /* map_present[1] = MOD_ABS_PORT(X+1) */ - {2, 0, 2}, /* map_present[2] = MOD_ABS_PORT(X+2) */ - {2, 0, 3}, /* map_present[3] = MOD_ABS_PORT(X+3) */ - {2, 0, 4}, /* map_present[4] = MOD_ABS_PORT(X+4) */ - {2, 0, 5}, /* map_present[5] = MOD_ABS_PORT(X+5) */ - }, - .map_reset = { {0, 0, 0}, /* map_reset[0] = QRESET_QSFP_N_P(X) */ - {0, 0, 1}, /* map_reset[1] = QRESET_QSFP_N_P(X+1) */ - {0, 0, 2}, /* map_reset[2] = QRESET_QSFP_N_P(X+2) */ - {0, 0, 3}, /* map_reset[3] = QRESET_QSFP_N_P(X+3) */ - {0, 0, 4}, /* map_reset[4] = QRESET_QSFP_N_P(X+4) */ - {0, 0, 5}, /* map_reset[5] = QRESET_QSFP_N_P(X+5) */ - }, - .map_lpmod = { {0, 1, 0}, /* map_lpmod[0] = LPMODE_QSFP_P(X) */ - {0, 1, 1}, /* map_lpmod[1] = LPMODE_QSFP_P(X+1) */ - {0, 1, 2}, /* map_lpmod[2] = LPMODE_QSFP_P(X+2) */ - {0, 1, 3}, /* map_lpmod[3] = LPMODE_QSFP_P(X+3) */ - {0, 1, 4}, /* map_lpmod[4] = LPMODE_QSFP_P(X+4) */ - {0, 1, 5}, /* map_lpmod[5] = LPMODE_QSFP_P(X+5) */ - }, - .map_modsel = { {1, 1, 0}, /* map_modsel[0] = MODSEL_QSFP_N_P(X) */ - {1, 1, 1}, /* map_modsel[1] = MODSEL_QSFP_N_P(X+1) */ - {1, 1, 2}, /* map_modsel[2] = MODSEL_QSFP_N_P(X+2) */ - {1, 1, 3}, /* map_modsel[3] = MODSEL_QSFP_N_P(X+3) */ - {1, 1, 4}, /* map_modsel[4] = MODSEL_QSFP_N_P(X+4) */ - {1, 1, 5}, /* map_modsel[5] = MODSEL_QSFP_N_P(X+5) */ - }, -}; - - -struct ioexp_map_s ioexp_map_tahoe_5a = { - - .chip_amount = 1, - .data_width = 2, - - .map_present = { {0, 0, 3}, /* map_present[0] = MOD_ABS_PORT(X) */ - {0, 1, 0}, /* map_present[1] = MOD_ABS_PORT(X+1) */ - {0, 1, 5}, /* map_present[2] = MOD_ABS_PORT(X+2) */ - }, - .map_reset = { {0, 0, 1}, /* map_reset[0] = QRESET_QSFP_N_P(X) */ - {0, 0, 6}, /* map_reset[1] = QRESET_QSFP_N_P(X+1) */ - {0, 1, 3}, /* map_reset[2] = QRESET_QSFP_N_P(X+2) */ - }, - .map_lpmod = { {0, 0, 2}, /* map_lpmod[0] = LPMODE_QSFP_P(X) */ - {0, 0, 7}, /* map_lpmod[1] = LPMODE_QSFP_P(X+1) */ - {0, 1, 4}, /* map_lpmod[2] = LPMODE_QSFP_P(X+2) */ - }, - .map_modsel = { {0, 0, 0}, /* map_modsel[0] = MODSEL_QSFP_N_P(X) */ - {0, 0, 5}, /* map_modsel[1] = MODSEL_QSFP_N_P(X+1) */ - {0, 1, 2}, /* map_modsel[2] = MODSEL_QSFP_N_P(X+2) */ - }, -}; - - -struct ioexp_map_s ioexp_map_tahoe_6abc = { - - .chip_amount = 3, - .data_width = 2, - - .map_present = { {0, 0, 3}, /* map_present[0] = MOD_ABS_PORT(X) */ - {0, 1, 0}, /* map_present[1] = MOD_ABS_PORT(X+1) */ - {0, 1, 5}, /* map_present[2] = MOD_ABS_PORT(X+2) */ - {1, 0, 3}, /* map_present[3] = MOD_ABS_PORT(X+3) */ - {1, 1, 0}, /* map_present[4] = MOD_ABS_PORT(X+4) */ - {1, 1, 5}, /* map_present[5] = MOD_ABS_PORT(X+5) */ - {2, 0, 3}, /* map_present[6] = MOD_ABS_PORT(X+6) */ - {2, 1, 0}, /* map_present[7] = MOD_ABS_PORT(X+7) */ - {2, 1, 5}, /* map_present[8] = MOD_ABS_PORT(X+8) */ - }, - .map_reset = { {0, 0, 1}, /* map_reset[0] = QRESET_QSFP28_N_P(X) */ - {0, 0, 6}, /* map_reset[1] = QRESET_QSFP28_N_P(X+1) */ - {0, 1, 3}, /* map_reset[2] = QRESET_QSFP28_N_P(X+2) */ - {1, 0, 1}, /* map_reset[3] = QRESET_QSFP28_N_P(X+3) */ - {1, 0, 6}, /* map_reset[4] = QRESET_QSFP28_N_P(X+4) */ - {1, 1, 3}, /* map_reset[5] = QRESET_QSFP28_N_P(X+5) */ - {2, 0, 1}, /* map_reset[6] = QRESET_QSFP28_N_P(X+6) */ - {2, 0, 6}, /* map_reset[7] = QRESET_QSFP28_N_P(X+7) */ - {2, 1, 3}, /* map_reset[7] = QRESET_QSFP28_N_P(X+7) */ - }, - .map_lpmod = { {0, 0, 2}, /* map_lpmod[0] = LPMODE_QSFP28_P(X) */ - {0, 0, 7}, /* map_lpmod[1] = LPMODE_QSFP28_P(X+1) */ - {0, 1, 4}, /* map_lpmod[2] = LPMODE_QSFP28_P(X+2) */ - {1, 0, 2}, /* map_lpmod[3] = LPMODE_QSFP28_P(X+3) */ - {1, 0, 7}, /* map_lpmod[4] = LPMODE_QSFP28_P(X+4) */ - {1, 1, 4}, /* map_lpmod[5] = LPMODE_QSFP28_P(X+5) */ - {2, 0, 2}, /* map_lpmod[6] = LPMODE_QSFP28_P(X+6) */ - {2, 0, 7}, /* map_lpmod[7] = LPMODE_QSFP28_P(X+7) */ - {2, 1, 4}, /* map_lpmod[7] = LPMODE_QSFP28_P(X+8) */ - }, - .map_modsel = { {0, 0, 0}, /* map_modsel[0] = MODSEL_QSFP28_N_P(X) */ - {0, 0, 5}, /* map_modsel[1] = MODSEL_QSFP28_N_P(X+1) */ - {0, 1, 2}, /* map_modsel[2] = MODSEL_QSFP28_N_P(X+2) */ - {1, 0, 0}, /* map_modsel[3] = MODSEL_QSFP28_N_P(X+3) */ - {1, 0, 5}, /* map_modsel[4] = MODSEL_QSFP28_N_P(X+4) */ - {1, 1, 2}, /* map_modsel[5] = MODSEL_QSFP28_N_P(X+5) */ - {2, 0, 0}, /* map_modsel[6] = MODSEL_QSFP28_N_P(X+6) */ - {2, 0, 5}, /* map_modsel[7] = MODSEL_QSFP28_N_P(X+7) */ - {2, 1, 2}, /* map_modsel[7] = MODSEL_QSFP28_N_P(X+7) */ - }, -}; - - -struct ioexp_map_s ioexp_map_sequoia_nabc = { - - .chip_amount = 3, - .data_width = 2, - - .map_present = { {2, 1, 0}, /* map_present[0] = MOD_ABS_PORT(X) */ - {2, 1, 1}, /* map_present[1] = MOD_ABS_PORT(X+1) */ - {2, 1, 2}, /* map_present[2] = MOD_ABS_PORT(X+2) */ - {2, 1, 3}, /* map_present[3] = MOD_ABS_PORT(X+3) */ - {2, 1, 4}, /* map_present[4] = MOD_ABS_PORT(X+4) */ - {2, 1, 5}, /* map_present[5] = MOD_ABS_PORT(X+5) */ - {2, 1, 6}, /* map_present[6] = MOD_ABS_PORT(X+6) */ - {2, 1, 7}, /* map_present[7] = MOD_ABS_PORT(X+7) */ - }, - .map_reset = { {0, 1, 0}, /* map_reset[0] = QRESET_QSFP28_N_P(X) */ - {0, 1, 1}, /* map_reset[1] = QRESET_QSFP28_N_P(X+1) */ - {0, 1, 2}, /* map_reset[2] = QRESET_QSFP28_N_P(X+2) */ - {0, 1, 3}, /* map_reset[3] = QRESET_QSFP28_N_P(X+3) */ - {0, 1, 4}, /* map_reset[4] = QRESET_QSFP28_N_P(X+4) */ - {0, 1, 5}, /* map_reset[5] = QRESET_QSFP28_N_P(X+5) */ - {0, 1, 6}, /* map_reset[6] = QRESET_QSFP28_N_P(X+6) */ - {0, 1, 7}, /* map_reset[7] = QRESET_QSFP28_N_P(X+7) */ - }, - .map_lpmod = { {1, 0, 0}, /* map_lpmod[0] = LPMODE_QSFP28_P(X) */ - {1, 0, 1}, /* map_lpmod[1] = LPMODE_QSFP28_P(X+1) */ - {1, 0, 2}, /* map_lpmod[2] = LPMODE_QSFP28_P(X+2) */ - {1, 0, 3}, /* map_lpmod[3] = LPMODE_QSFP28_P(X+3) */ - {1, 0, 4}, /* map_lpmod[4] = LPMODE_QSFP28_P(X+4) */ - {1, 0, 5}, /* map_lpmod[5] = LPMODE_QSFP28_P(X+5) */ - {1, 0, 6}, /* map_lpmod[6] = LPMODE_QSFP28_P(X+6) */ - {1, 0, 7}, /* map_lpmod[7] = LPMODE_QSFP28_P(X+7) */ - }, - .map_modsel = { {0, 0, 0}, /* map_modsel[0] = MODSEL_QSFP28_N_P(X) */ - {0, 0, 1}, /* map_modsel[1] = MODSEL_QSFP28_N_P(X+1) */ - {0, 0, 2}, /* map_modsel[2] = MODSEL_QSFP28_N_P(X+2) */ - {0, 0, 3}, /* map_modsel[3] = MODSEL_QSFP28_N_P(X+3) */ - {0, 0, 4}, /* map_modsel[4] = MODSEL_QSFP28_N_P(X+4) */ - {0, 0, 5}, /* map_modsel[5] = MODSEL_QSFP28_N_P(X+5) */ - {0, 0, 6}, /* map_modsel[6] = MODSEL_QSFP28_N_P(X+6) */ - {0, 0, 7}, /* map_modsel[7] = MODSEL_QSFP28_N_P(X+7) */ - }, -}; - - -struct ioexp_map_s ioexp_map_lavender_p65 = { - - .chip_amount = 1, - .data_width = 1, - - .map_present = { {0, 0, 4}, }, /* map_present[0] = MOD_ABS_PORT(X) */ - .map_reset = { {0, 0, 1}, }, /* map_reset[0] = QRESET_QSFP28_N_P(X) */ - .map_lpmod = { {0, 0, 2}, }, /* map_lpmod[0] = LPMODE_QSFP28_P(X) */ - .map_modsel = { {0, 0, 0}, }, /* map_modsel[0] = MODSEL_QSFP28_N_P(X) */ -}; - - -struct ioexp_map_s cpld_map_cottonwood = { - - .chip_amount = 1, - .data_width = 4, - - .map_present = { {0, 2, 0}, /* map_present[0] = MOD_ABS_PORT(X) */ - {0, 2, 4}, /* map_present[1] = MOD_ABS_PORT(X+1) */ - {0, 3, 0}, /* map_present[2] = MOD_ABS_PORT(X+2) */ - {0, 3, 4}, /* map_present[3] = MOD_ABS_PORT(X+3) */ - }, - .map_tx_disable = { {0, 0, 0}, /* map_tx_disable[0] = TXDISABLE_SFP+_P(X) */ - {0, 0, 4}, /* map_tx_disable[1] = TXDISABLE_SFP+_P(X+1) */ - {0, 1, 0}, /* map_tx_disable[2] = TXDISABLE_SFP+_P(X+2) */ - {0, 1, 4}, /* map_tx_disable[3] = TXDISABLE_SFP+_P(X+3) */ - }, - .map_tx_fault = { {0, 2, 2}, /* map_tx_fault[0] = TXFAULT_SFP+_P(X) */ - {0, 2, 6}, /* map_tx_fault[1] = TXFAULT_SFP+_P(X+1) */ - {0, 3, 2}, /* map_tx_fault[2] = TXFAULT_SFP+_P(X+2) */ - {0, 3, 6}, /* map_tx_fault[3] = TXFAULT_SFP+_P(X+3) */ - }, - .map_rxlos = { {0, 2, 1}, /* map_rxlos[0] = OPRXLOS_PORT(X) */ - {0, 2, 5}, /* map_rxlos[1] = OPRXLOS_PORT(X+1) */ - {0, 3, 1}, /* map_rxlos[2] = OPRXLOS_PORT(X+2) */ - {0, 3, 5}, /* map_rxlos[3] = OPRXLOS_PORT(X+3) */ - }, - .map_hard_rs0 = { {0, 0, 2}, /* map_hard_rs0[0] = RS0_SFP28_P(X) */ - {0, 0, 6}, /* map_hard_rs0[1] = RS0_SFP28_P(X+1) */ - {0, 1, 2}, /* map_hard_rs0[2] = RS0_SFP28_P(X+2) */ - {0, 1, 6}, /* map_hard_rs0[3] = RS0_SFP28_P(X+3) */ - }, - .map_hard_rs1 = { {0, 0, 2}, /* map_hard_rs1[0] = RS1_SFP28_P(X) */ - {0, 0, 6}, /* map_hard_rs1[1] = RS1_SFP28_P(X+1) */ - {0, 1, 2}, /* map_hard_rs1[2] = RS1_SFP28_P(X+2) */ - {0, 1, 6}, /* map_hard_rs1[3] = RS1_SFP28_P(X+3) */ - }, -}; - - -struct ioexp_map_s ioexp_map_maple_0abc = { - - .chip_amount = 3, - .data_width = 2, - - .map_present = { {2, 1, 0}, /* map_present[0] = MOD_ABS_PORT(X) */ - {2, 1, 1}, /* map_present[1] = MOD_ABS_PORT(X+1) */ - {2, 1, 2}, /* map_present[2] = MOD_ABS_PORT(X+2) */ - {2, 1, 3}, /* map_present[3] = MOD_ABS_PORT(X+3) */ - {2, 1, 4}, /* map_present[4] = MOD_ABS_PORT(X+4) */ - {2, 1, 5}, /* map_present[5] = MOD_ABS_PORT(X+5) */ - {2, 1, 6}, /* map_present[6] = MOD_ABS_PORT(X+6) */ - {2, 1, 7}, /* map_present[7] = MOD_ABS_PORT(X+7) */ - }, - .map_reset = { {0, 1, 0}, /* map_reset[0] = QRESET_QSFP_N_P(X) */ - {0, 1, 1}, /* map_reset[1] = QRESET_QSFP_N_P(X+1) */ - {0, 1, 2}, /* map_reset[2] = QRESET_QSFP_N_P(X+2) */ - {0, 1, 3}, /* map_reset[3] = QRESET_QSFP_N_P(X+3) */ - {0, 1, 4}, /* map_reset[4] = QRESET_QSFP_N_P(X+4) */ - {0, 1, 5}, /* map_reset[5] = QRESET_QSFP_N_P(X+5) */ - {0, 1, 6}, /* map_reset[6] = QRESET_QSFP_N_P(X+6) */ - {0, 1, 7}, /* map_reset[7] = QRESET_QSFP_N_P(X+7) */ - }, - .map_lpmod = { {1, 0, 0}, /* map_lpmod[0] = LPMODE_QSFP_P(X) */ - {1, 0, 1}, /* map_lpmod[1] = LPMODE_QSFP_P(X+1) */ - {1, 0, 2}, /* map_lpmod[2] = LPMODE_QSFP_P(X+2) */ - {1, 0, 3}, /* map_lpmod[3] = LPMODE_QSFP_P(X+3) */ - {1, 0, 4}, /* map_lpmod[4] = LPMODE_QSFP_P(X+4) */ - {1, 0, 5}, /* map_lpmod[5] = LPMODE_QSFP_P(X+5) */ - {1, 0, 6}, /* map_lpmod[6] = LPMODE_QSFP_P(X+6) */ - {1, 0, 7}, /* map_lpmod[7] = LPMODE_QSFP_P(X+7) */ - }, - .map_modsel = { {0, 0, 0}, /* map_modsel[0] = MODSEL_QSFP_N_P(X) */ - {0, 0, 1}, /* map_modsel[1] = MODSEL_QSFP_N_P(X+1) */ - {0, 0, 2}, /* map_modsel[2] = MODSEL_QSFP_N_P(X+2) */ - {0, 0, 3}, /* map_modsel[3] = MODSEL_QSFP_N_P(X+3) */ - {0, 0, 4}, /* map_modsel[4] = MODSEL_QSFP_N_P(X+4) */ - {0, 0, 5}, /* map_modsel[5] = MODSEL_QSFP_N_P(X+5) */ - {0, 0, 6}, /* map_modsel[6] = MODSEL_QSFP_N_P(X+6) */ - {0, 0, 7}, /* map_modsel[7] = MODSEL_QSFP_N_P(X+7) */ - }, -}; - - -struct ioexp_map_s ioexp_map_maple_nabc = { - - .chip_amount = 3, - .data_width = 2, - - .map_present = { {0, 0, 4}, /* map_present[0] = MOD_ABS_PORT(X) */ - {0, 0, 5}, /* map_present[1] = MOD_ABS_PORT(X+1) */ - {0, 0, 6}, /* map_present[2] = MOD_ABS_PORT(X+2) */ - {0, 0, 7}, /* map_present[3] = MOD_ABS_PORT(X+3) */ - {1, 0, 4}, /* map_present[4] = MOD_ABS_PORT(X+4) */ - {1, 0, 5}, /* map_present[5] = MOD_ABS_PORT(X+5) */ - {1, 0, 6}, /* map_present[6] = MOD_ABS_PORT(X+6) */ - {1, 0, 7}, /* map_present[7] = MOD_ABS_PORT(X+7) */ - }, - .map_tx_disable = { {0, 1, 0}, /* map_tx_disable[0] = TXDISABLE_SFP+_P(X) */ - {0, 1, 1}, /* map_tx_disable[1] = TXDISABLE_SFP+_P(X+1) */ - {0, 1, 2}, /* map_tx_disable[2] = TXDISABLE_SFP+_P(X+2) */ - {0, 1, 3}, /* map_tx_disable[3] = TXDISABLE_SFP+_P(X+3) */ - {1, 1, 0}, /* map_tx_disable[4] = TXDISABLE_SFP+_P(X+4) */ - {1, 1, 1}, /* map_tx_disable[5] = TXDISABLE_SFP+_P(X+5) */ - {1, 1, 2}, /* map_tx_disable[6] = TXDISABLE_SFP+_P(X+6) */ - {1, 1, 3}, /* map_tx_disable[7] = TXDISABLE_SFP+_P(X+7) */ - }, - .map_tx_fault = { {0, 0, 0}, /* map_tx_fault[0] = TXFAULT_SFP+_P(X) */ - {0, 0, 1}, /* map_tx_fault[1] = TXFAULT_SFP+_P(X+1) */ - {0, 0, 2}, /* map_tx_fault[2] = TXFAULT_SFP+_P(X+2) */ - {0, 0, 3}, /* map_tx_fault[3] = TXFAULT_SFP+_P(X+3) */ - {1, 0, 0}, /* map_tx_fault[4] = TXFAULT_SFP+_P(X+4) */ - {1, 0, 1}, /* map_tx_fault[5] = TXFAULT_SFP+_P(X+5) */ - {1, 0, 2}, /* map_tx_fault[6] = TXFAULT_SFP+_P(X+6) */ - {1, 0, 3}, /* map_tx_fault[7] = TXFAULT_SFP+_P(X+7) */ - }, - .map_rxlos = { {0, 1, 4}, /* map_rxlos[0] = OPRXLOS_PORT(X) */ - {0, 1, 5}, /* map_rxlos[1] = OPRXLOS_PORT(X+1) */ - {0, 1, 6}, /* map_rxlos[2] = OPRXLOS_PORT(X+2) */ - {0, 1, 7}, /* map_rxlos[3] = OPRXLOS_PORT(X+3) */ - {1, 1, 4}, /* map_rxlos[4] = OPRXLOS_PORT(X+4) */ - {1, 1, 5}, /* map_rxlos[5] = OPRXLOS_PORT(X+5) */ - {1, 1, 6}, /* map_rxlos[6] = OPRXLOS_PORT(X+6) */ - {1, 1, 7}, /* map_rxlos[7] = OPRXLOS_PORT(X+7) */ - }, - .map_hard_rs0 = { {2, 0, 0}, /* map_hard_rs0[0] = RS0_SFP28_P(X) */ - {2, 0, 2}, /* map_hard_rs0[1] = RS0_SFP28_P(X+1) */ - {2, 0, 4}, /* map_hard_rs0[2] = RS0_SFP28_P(X+2) */ - {2, 0, 6}, /* map_hard_rs0[3] = RS0_SFP28_P(X+3) */ - {2, 1, 0}, /* map_hard_rs0[4] = RS0_SFP28_P(X+4) */ - {2, 1, 2}, /* map_hard_rs0[5] = RS0_SFP28_P(X+5) */ - {2, 1, 4}, /* map_hard_rs0[6] = RS0_SFP28_P(X+6) */ - {2, 1, 6}, /* map_hard_rs0[7] = RS0_SFP28_P(X+7) */ - }, - .map_hard_rs1 = { {2, 0, 1}, /* map_hard_rs1[0] = RS1_SFP28_P(X) */ - {2, 0, 3}, /* map_hard_rs1[1] = RS1_SFP28_P(X+1) */ - {2, 0, 5}, /* map_hard_rs1[2] = RS1_SFP28_P(X+2) */ - {2, 0, 7}, /* map_hard_rs1[3] = RS1_SFP28_P(X+3) */ - {2, 1, 1}, /* map_hard_rs1[4] = RS1_SFP28_P(X+4) */ - {2, 1, 3}, /* map_hard_rs1[5] = RS1_SFP28_P(X+5) */ - {2, 1, 5}, /* map_hard_rs1[6] = RS1_SFP28_P(X+6) */ - {2, 1, 7}, /* map_hard_rs1[7] = RS1_SFP28_P(X+7) */ - }, -}; - - -struct ioexp_map_s ioexp_map_gulmohar_nabc = { - - .chip_amount = 3, - .data_width = 2, - - .map_present = { {0, 0, 4}, /* map_present[0] = MOD_ABS_PORT(X) */ - {0, 0, 5}, /* map_present[1] = MOD_ABS_PORT(X+1) */ - {0, 1, 4}, /* map_present[2] = MOD_ABS_PORT(X+2) */ - {0, 1, 5}, /* map_present[3] = MOD_ABS_PORT(X+3) */ - {1, 0, 4}, /* map_present[4] = MOD_ABS_PORT(X+4) */ - {1, 0, 5}, /* map_present[5] = MOD_ABS_PORT(X+5) */ - {1, 1, 4}, /* map_present[6] = MOD_ABS_PORT(X+6) */ - {1, 1, 5}, /* map_present[7] = MOD_ABS_PORT(X+7) */ - }, - .map_tx_disable = { {0, 0, 2}, /* map_tx_disable[0] = TXDISABLE_SFP+_P(X) */ - {0, 0, 3}, /* map_tx_disable[1] = TXDISABLE_SFP+_P(X+1) */ - {0, 1, 2}, /* map_tx_disable[2] = TXDISABLE_SFP+_P(X+2) */ - {0, 1, 3}, /* map_tx_disable[3] = TXDISABLE_SFP+_P(X+3) */ - {1, 0, 2}, /* map_tx_disable[4] = TXDISABLE_SFP+_P(X+4) */ - {1, 0, 3}, /* map_tx_disable[5] = TXDISABLE_SFP+_P(X+5) */ - {1, 1, 2}, /* map_tx_disable[6] = TXDISABLE_SFP+_P(X+6) */ - {1, 1, 3}, /* map_tx_disable[7] = TXDISABLE_SFP+_P(X+7) */ - }, - .map_tx_fault = { {0, 0, 0}, /* map_tx_fault[0] = TXFAULT_SFP+_P(X) */ - {0, 0, 1}, /* map_tx_fault[1] = TXFAULT_SFP+_P(X+1) */ - {0, 1, 0}, /* map_tx_fault[2] = TXFAULT_SFP+_P(X+2) */ - {0, 1, 1}, /* map_tx_fault[3] = TXFAULT_SFP+_P(X+3) */ - {1, 0, 0}, /* map_tx_fault[4] = TXFAULT_SFP+_P(X+4) */ - {1, 0, 1}, /* map_tx_fault[5] = TXFAULT_SFP+_P(X+5) */ - {1, 1, 0}, /* map_tx_fault[6] = TXFAULT_SFP+_P(X+6) */ - {1, 1, 1}, /* map_tx_fault[7] = TXFAULT_SFP+_P(X+7) */ - }, - .map_rxlos = { {0, 0, 6}, /* map_rxlos[0] = OPRXLOS_PORT(X) */ - {0, 0, 7}, /* map_rxlos[1] = OPRXLOS_PORT(X+1) */ - {0, 1, 6}, /* map_rxlos[2] = OPRXLOS_PORT(X+2) */ - {0, 1, 7}, /* map_rxlos[3] = OPRXLOS_PORT(X+3) */ - {1, 0, 6}, /* map_rxlos[4] = OPRXLOS_PORT(X+4) */ - {1, 0, 7}, /* map_rxlos[5] = OPRXLOS_PORT(X+5) */ - {1, 1, 6}, /* map_rxlos[6] = OPRXLOS_PORT(X+6) */ - {1, 1, 7}, /* map_rxlos[7] = OPRXLOS_PORT(X+7) */ - }, - .map_hard_rs0 = { {2, 0, 0}, /* map_hard_rs0[0] = RS0_SFP28_P(X) */ - {2, 0, 2}, /* map_hard_rs0[1] = RS0_SFP28_P(X+1) */ - {2, 0, 4}, /* map_hard_rs0[2] = RS0_SFP28_P(X+2) */ - {2, 0, 6}, /* map_hard_rs0[3] = RS0_SFP28_P(X+3) */ - {2, 1, 0}, /* map_hard_rs0[4] = RS0_SFP28_P(X+4) */ - {2, 1, 2}, /* map_hard_rs0[5] = RS0_SFP28_P(X+5) */ - {2, 1, 4}, /* map_hard_rs0[6] = RS0_SFP28_P(X+6) */ - {2, 1, 6}, /* map_hard_rs0[7] = RS0_SFP28_P(X+7) */ - }, - .map_hard_rs1 = { {2, 0, 1}, /* map_hard_rs1[0] = RS1_SFP28_P(X) */ - {2, 0, 3}, /* map_hard_rs1[1] = RS1_SFP28_P(X+1) */ - {2, 0, 5}, /* map_hard_rs1[2] = RS1_SFP28_P(X+2) */ - {2, 0, 7}, /* map_hard_rs1[3] = RS1_SFP28_P(X+3) */ - {2, 1, 1}, /* map_hard_rs1[4] = RS1_SFP28_P(X+4) */ - {2, 1, 3}, /* map_hard_rs1[5] = RS1_SFP28_P(X+5) */ - {2, 1, 5}, /* map_hard_rs1[6] = RS1_SFP28_P(X+6) */ - {2, 1, 7}, /* map_hard_rs1[7] = RS1_SFP28_P(X+7) */ - }, -}; - - -struct ioexp_map_s ioexp_map_gulmohar_7abc = { - - .chip_amount = 3, - .data_width = 2, - - .map_present = { {2, 1, 0}, /* map_present[0] = MOD_ABS_PORT(X) */ - {2, 1, 1}, /* map_present[1] = MOD_ABS_PORT(X+1) */ - {2, 1, 2}, /* map_present[2] = MOD_ABS_PORT(X+2) */ - {2, 1, 3}, /* map_present[3] = MOD_ABS_PORT(X+3) */ - {2, 1, 4}, /* map_present[4] = MOD_ABS_PORT(X+4) */ - {2, 1, 5}, /* map_present[5] = MOD_ABS_PORT(X+5) */ - }, - .map_reset = { {0, 1, 0}, /* map_reset[0] = QRESET_QSFP_N_P(X) */ - {0, 1, 1}, /* map_reset[1] = QRESET_QSFP_N_P(X+1) */ - {0, 1, 2}, /* map_reset[2] = QRESET_QSFP_N_P(X+2) */ - {0, 1, 3}, /* map_reset[3] = QRESET_QSFP_N_P(X+3) */ - {0, 1, 4}, /* map_reset[4] = QRESET_QSFP_N_P(X+4) */ - {0, 1, 5}, /* map_reset[5] = QRESET_QSFP_N_P(X+5) */ - }, - .map_lpmod = { {1, 0, 0}, /* map_lpmod[0] = LPMODE_QSFP_P(X) */ - {1, 0, 1}, /* map_lpmod[1] = LPMODE_QSFP_P(X+1) */ - {1, 0, 2}, /* map_lpmod[2] = LPMODE_QSFP_P(X+2) */ - {1, 0, 3}, /* map_lpmod[3] = LPMODE_QSFP_P(X+3) */ - {1, 0, 4}, /* map_lpmod[4] = LPMODE_QSFP_P(X+4) */ - {1, 0, 5}, /* map_lpmod[5] = LPMODE_QSFP_P(X+5) */ - }, - .map_modsel = { {0, 0, 0}, /* map_modsel[0] = MODSEL_QSFP_N_P(X) */ - {0, 0, 1}, /* map_modsel[1] = MODSEL_QSFP_N_P(X+1) */ - {0, 0, 2}, /* map_modsel[2] = MODSEL_QSFP_N_P(X+2) */ - {0, 0, 3}, /* map_modsel[3] = MODSEL_QSFP_N_P(X+3) */ - {0, 0, 4}, /* map_modsel[4] = MODSEL_QSFP_N_P(X+4) */ - {0, 0, 5}, /* map_modsel[5] = MODSEL_QSFP_N_P(X+5) */ - }, -}; - - -/* PortType: SFP / 8 port - * Platform: Cypress, Peony_SFP - */ -struct ioexp_map_s ioexp_map_sfp_8p_layout_1 = { - - .chip_amount = 3, - .data_width = 2, - - .map_present = { {0, 0, 4}, /* map_present[0] = MOD_ABS_PORT(X) */ - {0, 0, 5}, /* map_present[1] = MOD_ABS_PORT(X+1) */ - {0, 0, 6}, /* map_present[2] = MOD_ABS_PORT(X+2) */ - {0, 0, 7}, /* map_present[3] = MOD_ABS_PORT(X+3) */ - {1, 0, 4}, /* map_present[4] = MOD_ABS_PORT(X+4) */ - {1, 0, 5}, /* map_present[5] = MOD_ABS_PORT(X+5) */ - {1, 0, 6}, /* map_present[6] = MOD_ABS_PORT(X+6) */ - {1, 0, 7}, /* map_present[7] = MOD_ABS_PORT(X+7) */ - }, - .map_tx_disable = { {0, 1, 0}, /* map_tx_disable[0] = TXDISABLE_SFP+_P(X) */ - {0, 1, 1}, /* map_tx_disable[1] = TXDISABLE_SFP+_P(X+1) */ - {0, 1, 2}, /* map_tx_disable[2] = TXDISABLE_SFP+_P(X+2) */ - {0, 1, 3}, /* map_tx_disable[3] = TXDISABLE_SFP+_P(X+3) */ - {1, 1, 0}, /* map_tx_disable[4] = TXDISABLE_SFP+_P(X+4) */ - {1, 1, 1}, /* map_tx_disable[5] = TXDISABLE_SFP+_P(X+5) */ - {1, 1, 2}, /* map_tx_disable[6] = TXDISABLE_SFP+_P(X+6) */ - {1, 1, 3}, /* map_tx_disable[7] = TXDISABLE_SFP+_P(X+7) */ - }, - .map_tx_fault = { {0, 0, 0}, /* map_tx_fault[0] = TXFAULT_SFP+_P(X) */ - {0, 0, 1}, /* map_tx_fault[1] = TXFAULT_SFP+_P(X+1) */ - {0, 0, 2}, /* map_tx_fault[2] = TXFAULT_SFP+_P(X+2) */ - {0, 0, 3}, /* map_tx_fault[3] = TXFAULT_SFP+_P(X+3) */ - {1, 0, 0}, /* map_tx_fault[4] = TXFAULT_SFP+_P(X+4) */ - {1, 0, 1}, /* map_tx_fault[5] = TXFAULT_SFP+_P(X+5) */ - {1, 0, 2}, /* map_tx_fault[6] = TXFAULT_SFP+_P(X+6) */ - {1, 0, 3}, /* map_tx_fault[7] = TXFAULT_SFP+_P(X+7) */ - }, - .map_rxlos = { {0, 1, 4}, /* map_rxlos[0] = OPRXLOS_PORT(X) */ - {0, 1, 5}, /* map_rxlos[1] = OPRXLOS_PORT(X+1) */ - {0, 1, 6}, /* map_rxlos[2] = OPRXLOS_PORT(X+2) */ - {0, 1, 7}, /* map_rxlos[3] = OPRXLOS_PORT(X+3) */ - {1, 1, 4}, /* map_rxlos[4] = OPRXLOS_PORT(X+4) */ - {1, 1, 5}, /* map_rxlos[5] = OPRXLOS_PORT(X+5) */ - {1, 1, 6}, /* map_rxlos[6] = OPRXLOS_PORT(X+6) */ - {1, 1, 7}, /* map_rxlos[7] = OPRXLOS_PORT(X+7) */ - }, - .map_hard_rs0 = { {2, 0, 0}, /* map_hard_rs0[0] = RS0_SFP28_P(X) */ - {2, 0, 2}, /* map_hard_rs0[1] = RS0_SFP28_P(X+1) */ - {2, 0, 4}, /* map_hard_rs0[2] = RS0_SFP28_P(X+2) */ - {2, 0, 6}, /* map_hard_rs0[3] = RS0_SFP28_P(X+3) */ - {2, 1, 0}, /* map_hard_rs0[4] = RS0_SFP28_P(X+4) */ - {2, 1, 2}, /* map_hard_rs0[5] = RS0_SFP28_P(X+5) */ - {2, 1, 4}, /* map_hard_rs0[6] = RS0_SFP28_P(X+6) */ - {2, 1, 6}, /* map_hard_rs0[7] = RS0_SFP28_P(X+7) */ - }, - .map_hard_rs1 = { {2, 0, 1}, /* map_hard_rs1[0] = RS1_SFP28_P(X) */ - {2, 0, 3}, /* map_hard_rs1[1] = RS1_SFP28_P(X+1) */ - {2, 0, 5}, /* map_hard_rs1[2] = RS1_SFP28_P(X+2) */ - {2, 0, 7}, /* map_hard_rs1[3] = RS1_SFP28_P(X+3) */ - {2, 1, 1}, /* map_hard_rs1[4] = RS1_SFP28_P(X+4) */ - {2, 1, 3}, /* map_hard_rs1[5] = RS1_SFP28_P(X+5) */ - {2, 1, 5}, /* map_hard_rs1[6] = RS1_SFP28_P(X+6) */ - {2, 1, 7}, /* map_hard_rs1[7] = RS1_SFP28_P(X+7) */ - }, -}; - - -/* PortType: QSFP / 6 port - * Platform: Gulmohar, Peony_SFP, Peony_Copper - */ -struct ioexp_map_s ioexp_map_6p_qsfp_type_1 = { - - .chip_amount = 3, - .data_width = 2, - - .map_present = { {2, 1, 0}, /* map_present[0] = MOD_ABS_PORT(X) */ - {2, 1, 1}, /* map_present[1] = MOD_ABS_PORT(X+1) */ - {2, 1, 2}, /* map_present[2] = MOD_ABS_PORT(X+2) */ - {2, 1, 3}, /* map_present[3] = MOD_ABS_PORT(X+3) */ - {2, 1, 4}, /* map_present[4] = MOD_ABS_PORT(X+4) */ - {2, 1, 5}, /* map_present[5] = MOD_ABS_PORT(X+5) */ - }, - .map_reset = { {0, 1, 0}, /* map_reset[0] = QRESET_QSFP_N_P(X) */ - {0, 1, 1}, /* map_reset[1] = QRESET_QSFP_N_P(X+1) */ - {0, 1, 2}, /* map_reset[2] = QRESET_QSFP_N_P(X+2) */ - {0, 1, 3}, /* map_reset[3] = QRESET_QSFP_N_P(X+3) */ - {0, 1, 4}, /* map_reset[4] = QRESET_QSFP_N_P(X+4) */ - {0, 1, 5}, /* map_reset[5] = QRESET_QSFP_N_P(X+5) */ - }, - .map_lpmod = { {1, 0, 0}, /* map_lpmod[0] = LPMODE_QSFP_P(X) */ - {1, 0, 1}, /* map_lpmod[1] = LPMODE_QSFP_P(X+1) */ - {1, 0, 2}, /* map_lpmod[2] = LPMODE_QSFP_P(X+2) */ - {1, 0, 3}, /* map_lpmod[3] = LPMODE_QSFP_P(X+3) */ - {1, 0, 4}, /* map_lpmod[4] = LPMODE_QSFP_P(X+4) */ - {1, 0, 5}, /* map_lpmod[5] = LPMODE_QSFP_P(X+5) */ - }, - .map_modsel = { {0, 0, 0}, /* map_modsel[0] = MODSEL_QSFP_N_P(X) */ - {0, 0, 1}, /* map_modsel[1] = MODSEL_QSFP_N_P(X+1) */ - {0, 0, 2}, /* map_modsel[2] = MODSEL_QSFP_N_P(X+2) */ - {0, 0, 3}, /* map_modsel[3] = MODSEL_QSFP_N_P(X+3) */ - {0, 0, 4}, /* map_modsel[4] = MODSEL_QSFP_N_P(X+4) */ - {0, 0, 5}, /* map_modsel[5] = MODSEL_QSFP_N_P(X+5) */ - }, -}; - - -/* ========== Private functions ========== - */ -int check_channel_tier_1(void); - -struct i2c_client * -_get_i2c_client(struct ioexp_obj_s *self, - int chip_id){ - - struct ioexp_i2c_s *i2c_curr_p = self->i2c_head_p; - - if (!(i2c_curr_p)){ - SWPS_ERR("%s: i2c_curr_p is NULL\n", __func__); - return NULL; - } - while (i2c_curr_p){ - if ((i2c_curr_p->chip_id) == chip_id){ - return i2c_curr_p->i2c_client_p; - } - i2c_curr_p = i2c_curr_p->next; - } - SWPS_ERR("%s: not exist! :%d\n", __func__, chip_id); - return NULL; -} - - -static int -_common_ioexp_update_one(struct ioexp_obj_s *self, - struct ioexp_addr_s *ioexp_addr, - int chip_id, - int data_width, - int show_err, - char *caller_name) { - int buf = 0; - int err = 0; - int data_id = 0; - int r_offset = 0; - - for(data_id=0; data_idread_offset[data_id]; - buf = i2c_smbus_read_byte_data(_get_i2c_client(self, chip_id), r_offset); - /* Check error */ - if (buf < 0) { - err = 1; - if (show_err) { - SWPS_INFO("IOEXP-%d read fail! :%d \n", self->ioexp_id, buf); - SWPS_INFO("Dump: :%d :0x%02x :%d, :%s\n", - ioexp_addr->chan_id, ioexp_addr->chip_addr, - ioexp_addr->read_offset[data_id], caller_name); - } - continue; - } - /* Update IOEXP object */ - self->chip_data[chip_id].data[data_id] = (uint8_t)buf; - } - if (err) { - return ERR_IOEXP_UNEXCPT; - } - return 0; -} - - -static int -common_ioexp_update_all(struct ioexp_obj_s *self, - int show_err, - char *caller_name){ - - int err = 0; - int chip_id = 0; - int chip_amount = self->ioexp_map_p->chip_amount; - - for (chip_id=0; chip_idioexp_map_p->map_addr[chip_id]), - chip_id, - self->ioexp_map_p->data_width, - show_err, - caller_name) < 0) { - err = 1; - } - } - if (err) { - return ERR_IOEXP_UNEXCPT; - } - return 0; -} - - -static int -_common_check_by_mode(struct ioexp_obj_s *self){ - - switch (self->mode){ - case IOEXP_MODE_DIRECT: - return self->fsm_4_direct(self); - - case IOEXP_MODE_POLLING: - if (self->state >= 0){ - return 0; - } - switch (self->state){ - case STATE_IOEXP_INIT: - return ERR_IOEXP_UNINIT; - case STATE_IOEXP_ABNORMAL: - return ERR_IOEXP_ABNORMAL; - default: - return ERR_IOEXP_NOSTATE; - } - break; - - default: - break; - } - SWPS_ERR("%s: Exception occurs. :%d \n", __func__, self->mode); - return ERR_IOEXP_UNEXCPT; -} - - -static int -_common_get_bit(struct ioexp_obj_s *self, - struct ioexp_bitmap_s *bitmap_obj_p, - char *func_mane){ - uint8_t buf; - int err_code; - - /* Check and get address */ - err_code = _common_check_by_mode(self); - if (err_code < 0){ - return err_code; - } - if (!bitmap_obj_p){ - SWPS_ERR("Layout config incorrect! :%d :%s\n", - self->ioexp_id, func_mane); - return ERR_IOEXP_BADCONF; - } - /* Get data form cache */ - buf = self->chip_data[bitmap_obj_p->chip_id].data[bitmap_obj_p->ioexp_voffset]; - return (int)(buf >> bitmap_obj_p->bit_shift & 0x01); -} - - -static int -_common_set_bit(struct ioexp_obj_s *self, - struct ioexp_bitmap_s *bitmap_obj_p, - int input_val, - char *func_mane){ - int err_code, target_offset; - uint8_t origin_byte; - uint8_t modify_byte; - - /* Check and get address */ - err_code = _common_check_by_mode(self); - if (err_code < 0){ - return err_code; - } - if (!bitmap_obj_p){ - SWPS_ERR("Layout config incorrect! :%d :%s\n", - self->ioexp_id, func_mane); - return ERR_IOEXP_BADCONF; - } - /* Prepare write date */ - origin_byte = self->chip_data[bitmap_obj_p->chip_id].data[bitmap_obj_p->ioexp_voffset]; - switch (input_val) { - case 0: - modify_byte = origin_byte; - SWP_BIT_CLEAR(modify_byte, bitmap_obj_p->bit_shift); - break; - case 1: - modify_byte = origin_byte; - SWP_BIT_SET(modify_byte, bitmap_obj_p->bit_shift); - break; - default: - SWPS_ERR("Input value incorrect! :%d :%d :%s\n", - input_val, self->ioexp_id, func_mane); - return ERR_IOEXP_BADINPUT; - } - /* Setup i2c client */ - target_offset = self->ioexp_map_p->map_addr[bitmap_obj_p->chip_id].write_offset[bitmap_obj_p->ioexp_voffset]; - /* Write byte to chip via I2C */ - err_code = i2c_smbus_write_byte_data(_get_i2c_client(self, bitmap_obj_p->chip_id), - target_offset, - modify_byte); - /* Update or bollback object */ - if (err_code < 0){ - self->chip_data[bitmap_obj_p->chip_id].data[bitmap_obj_p->ioexp_voffset] = origin_byte; - SWPS_ERR("I2C write fail! :%d :%d :%s :%d\n", - input_val, self->ioexp_id, func_mane, err_code); - return err_code; - } - self->chip_data[bitmap_obj_p->chip_id].data[bitmap_obj_p->ioexp_voffset] = modify_byte; - return 0; -} - - -/* ========== Object public functions ========== - */ -int -common_get_present(struct ioexp_obj_s *self, - int virt_offset){ - - int UNPLUG = 1; - int retval = ERR_IOEXP_UNEXCPT; - - retval = _common_get_bit(self, - &(self->ioexp_map_p->map_present[virt_offset]), - "common_get_present"); - if (retval < 0) { - /* [Note] - * => Transceiver object does not need to handle IOEXP layer issues. - */ - return UNPLUG; - } - return retval; -} - - -int -common_get_tx_fault(struct ioexp_obj_s *self, - int virt_offset){ - /* [Transmit Fault (Tx_Fault)] - * A catastrophic laser fault will activate the transmitter signal, - * TX_FAULT, and disable the laser. This signal is an open collector - * output (pull-up required on the host board). A low signal indicates - * normal laser operation and a high signal indicates a fault. The - * TX_FAULT will be latched high when a laser fault occurs and is - * cleared by toggling the TX_DISABLE input or power cycling the - * transceiver. The transmitter fault condition can also be monitored - * via the two-wire serial interface. - * (address A2, byte 110, bit 2). - * - * 0: Normal - * 1: Abnormal - */ - return _common_get_bit(self, - &(self->ioexp_map_p->map_tx_fault[virt_offset]), - "common_get_tx_fault"); -} - - -int -common_get_rxlos(struct ioexp_obj_s *self, - int virt_offset){ - /* [Receiver Loss of Signal (Rx_LOS)] - * The post-amplification IC also includes transition detection circuitry - * which monitors the ac level of incoming optical signals and provides a - * TTL/CMOS compatible status signal to the host (pin 8). An adequate optical - * input results in a low Rx_LOS output while a high Rx_LOS output indicates - * an unusable optical input. The Rx_LOS thresholds are factory set so that - * a high output indicates a definite optical fault has occurred. Rx_LOS can - * also be monitored via the two-wire serial interface - * (address A2h, byte 110, bit 1). - * - * 0: Normal - * 1: Abnormal - */ - return _common_get_bit(self, - &(self->ioexp_map_p->map_rxlos[virt_offset]), - "common_get_rxlos"); -} - - -int -common_get_tx_disable(struct ioexp_obj_s *self, - int virt_offset){ - - return _common_get_bit(self, - &(self->ioexp_map_p->map_tx_disable[virt_offset]), - "common_get_tx_disable"); -} - - -int -common_get_reset(struct ioexp_obj_s *self, - int virt_offset){ - - return _common_get_bit(self, - &(self->ioexp_map_p->map_reset[virt_offset]), - "common_get_reset"); -} - - -int -common_get_lpmod(struct ioexp_obj_s *self, - int virt_offset){ - - return _common_get_bit(self, - &(self->ioexp_map_p->map_lpmod[virt_offset]), - "common_get_lpmod"); -} - - -int -common_get_modsel(struct ioexp_obj_s *self, - int virt_offset){ - - return _common_get_bit(self, - &(self->ioexp_map_p->map_modsel[virt_offset]), - "common_get_modsel"); -} - - -int -common_get_hard_rs0(struct ioexp_obj_s *self, - int virt_offset){ - - return _common_get_bit(self, - &(self->ioexp_map_p->map_hard_rs0[virt_offset]), - "common_get_hard_rs0"); -} - - -int -common_get_hard_rs1(struct ioexp_obj_s *self, - int virt_offset){ - - return _common_get_bit(self, - &(self->ioexp_map_p->map_hard_rs1[virt_offset]), - "common_get_hard_rs1"); -} - - -int -common_set_tx_disable(struct ioexp_obj_s *self, - int virt_offset, - int input_val){ - - return _common_set_bit(self, - &(self->ioexp_map_p->map_tx_disable[virt_offset]), - input_val, - "common_set_tx_disable"); -} - - -int -common_set_reset(struct ioexp_obj_s *self, - int virt_offset, - int input_val){ - - return _common_set_bit(self, - &(self->ioexp_map_p->map_reset[virt_offset]), - input_val, - "common_set_reset"); -} - - -int -common_set_lpmod(struct ioexp_obj_s *self, - int virt_offset, - int input_val){ - - return _common_set_bit(self, - &(self->ioexp_map_p->map_lpmod[virt_offset]), - input_val, - "common_set_lpmod"); -} - - -int -common_set_modsel(struct ioexp_obj_s *self, - int virt_offset, - int input_val){ - - return _common_set_bit(self, - &(self->ioexp_map_p->map_modsel[virt_offset]), - input_val, - "common_set_modsel"); -} - - -int -common_set_hard_rs0(struct ioexp_obj_s *self, - int virt_offset, - int input_val){ - - return _common_set_bit(self, - &(self->ioexp_map_p->map_hard_rs0[virt_offset]), - input_val, - "common_set_hard_rs0"); -} - - -int -common_set_hard_rs1(struct ioexp_obj_s *self, - int virt_offset, - int input_val){ - - return _common_set_bit(self, - &(self->ioexp_map_p->map_hard_rs1[virt_offset]), - input_val, - "common_set_hard_rs1"); -} - - -int -ioexp_get_not_support(struct ioexp_obj_s *self, - int virt_offset){ - return ERR_IOEXP_NOTSUPPORT; -} - - -int -ioexp_set_not_support(struct ioexp_obj_s *self, - int virt_offset, - int input_val){ - return ERR_IOEXP_NOTSUPPORT; -} - - -int -fake_ioexp_init(struct ioexp_obj_s *self){ - return 1; -} - -int -fake_ioexp_update(struct ioexp_obj_s *self){ - return 1; -} - - -int -fake_update_func(struct ioexp_obj_s *self){ - return 1; -} - -int -fake_get_func(struct ioexp_obj_s *self, - int virt_offset){ - SWPS_WARN("Someone called fake_get_func\n"); - return -1; -} - -int -fake_set_func(struct ioexp_obj_s *self, - int virt_offset, - int input_val){ - SWPS_WARN("Someone called fake_set_func\n"); - return -1; -} - - -/* ========== Initial functions for IO Expander ========== - */ -int -common_ioexp_init(struct ioexp_obj_s *self) { - - int chip_id, offset, err_code; - struct ioexp_addr_s *addr_p; - - if (self->mode == IOEXP_MODE_DIRECT) { - goto update_common_ioexp_init; - } - /* Setup default value to each physical IO Expander */ - for (chip_id=0; chip_id<(self->ioexp_map_p->chip_amount); chip_id++){ - /* Get address mapping */ - addr_p = &(self->ioexp_map_p->map_addr[chip_id]); - if (!addr_p){ - SWPS_ERR("%s: IOEXP config incorrect! :%d \n", - __func__, chip_id); - return -1; - } - /* Setup default value */ - for (offset=0; offset<(self->ioexp_map_p->data_width); offset++){ - - /* [Desc] Skip the setup default value behavior - [Note] Setup default value = -1 if you don't want to write the value to IOEXP or CPLD - */ - if(addr_p->write_offset[offset] < 0){ - SWPS_DEBUG("skip a write_offset <%d>\n", addr_p->conf_offset[offset]); - continue; - } - err_code = i2c_smbus_write_byte_data(_get_i2c_client(self, chip_id), - addr_p->write_offset[offset], - addr_p->data_default[offset]); - if (err_code < 0){ - SWPS_ERR("%s: set default fail! :%d \n", - __func__, err_code); - return ERR_IOEXP_UNEXCPT; - } - } - } -update_common_ioexp_init: - /* Check and update info to object */ - err_code = self->update_all(self, 1, "common_ioexp_init"); - if (err_code < 0) { - SWPS_ERR("%s: update_all() fail! :%d \n", - __func__, err_code); - return ERR_IOEXP_UNEXCPT; - } - return 0; -} - - -/* ========== Object functions for Final State Machine ========== - */ -int -_is_channel_ready(struct ioexp_obj_s *self){ - - int chip_id = 0; - int byte_id = 0; - int getval = ERR_IOEXP_UNEXCPT; - int chkval = ERR_IOEXP_UNEXCPT; - char *emsg = "ERR"; - struct ioexp_addr_s *addr_p = NULL; - - for (chip_id=0; chip_id<(self->ioexp_map_p->chip_amount); chip_id++) { - addr_p = &(self->ioexp_map_p->map_addr[chip_id]); - if (!addr_p){ - emsg = "IOEXP config incorrect"; - goto err_is_channel_ready; - } - for (byte_id=0; byte_id<(self->ioexp_map_p->data_width); byte_id++) { - if (addr_p->conf_offset[byte_id] < 0) { - continue; - } - if ((addr_p->conf_default[byte_id]) != 0) { - goto go_is_channel_ready; - } - } - if (chip_id == ((self->ioexp_map_p->chip_amount) - 1)) { - SWPS_DEBUG("%s: no non-zero config", __func__); - break; - } - } - chip_id = 0; - byte_id = 0; - -go_is_channel_ready: - addr_p = &(self->ioexp_map_p->map_addr[chip_id]); - chkval = addr_p->conf_default[byte_id]; - getval = i2c_smbus_read_byte_data(_get_i2c_client(self, chip_id), - addr_p->conf_offset[byte_id]); - - SWPS_DEBUG("%s: target info :%d :%d :%d :%d :%d\n", - __func__, self->ioexp_id, chip_id, byte_id, chkval, getval); - - if ((getval >= 0) && (getval == chkval)) { - return 1; - } - return 0; - -err_is_channel_ready: - SWPS_ERR("%s: %s :%d :%d :%d :%d :%d\n", - __func__, emsg, self->ioexp_id, chip_id, byte_id, chkval, getval); - return ERR_IOEXP_UNEXCPT; -} - - -int -_ioexp_init_handler(struct ioexp_obj_s *self){ - - int return_val; - - switch (self->mode) { - case IOEXP_MODE_DIRECT: - return_val = self->init(self); - if (return_val < 0){ - self->state = STATE_IOEXP_ABNORMAL; - } else { - self->state = STATE_IOEXP_NORMAL; - } - return return_val; - - case IOEXP_MODE_POLLING: - /* Check system and channel is ready */ - if (self->state == STATE_IOEXP_INIT){ - if (!_is_channel_ready(self)){ - self->state = STATE_IOEXP_INIT; - SWPS_WARN("%s: IOEXP:%d channel not ready.\n", - __func__, self->ioexp_id); - return 0; - } - } - /* Execute initial callback */ - return_val = self->init(self); - if (return_val < 0){ - self->state = STATE_IOEXP_ABNORMAL; - } else { - self->state = STATE_IOEXP_NORMAL; - } - return return_val; - - default: - break; - } - SWPS_ERR("%s: exception occur :%d\n", __func__, self->mode); - return ERR_IOEXP_UNEXCPT; -} - - -int -common_ioexp_fsm_4_direct(struct ioexp_obj_s *self){ - - int result_val; - int show_err = 1; - char *func_mane = "common_ioexp_fsm_4_direct"; - - switch (self->state){ - case STATE_IOEXP_INIT: - result_val = _ioexp_init_handler(self); - /* Exception case: terminate initial procedure */ - if(result_val < 0){ - /* Initial fail */ - return result_val; - } - if(self->state == STATE_IOEXP_INIT){ - /* Keep in INIT state, and return error */ - return ERR_IOEXP_UNINIT; - } - /* Case: Initial done */ - return 0; - - case STATE_IOEXP_NORMAL: - result_val = self->update_all(self, show_err, func_mane); - if (result_val < 0){ - SWPS_INFO("%s: NORMAL -> ABNORMAL :%d\n", - __func__, result_val); - self->state = STATE_IOEXP_ABNORMAL; - return result_val; - } - self->state = STATE_IOEXP_NORMAL; - return 0; - - case STATE_IOEXP_ABNORMAL: - result_val = self->update_all(self, show_err, func_mane); - if (result_val < 0){ - self->state = STATE_IOEXP_ABNORMAL; - return result_val; - } - SWPS_DEBUG("%s: ABNORMAL -> NORMAL :%d\n", - __func__, result_val); - self->state = STATE_IOEXP_NORMAL; - return 0; - - default: - break; - } - SWPS_ERR("%s: Exception occurs :%d\n", - __func__, self->state); - return ERR_IOEXP_UNEXCPT; -} - - -int -common_ioexp_fsm_4_polling(struct ioexp_obj_s *self){ - - int result_val, i, show_e; - int fail_retry = 3; - char *func_name = "common_ioexp_fsm_4_polling"; - -#ifdef DEBUG_SWPS - show_e = 1; -#else - show_e = 0; -#endif - - switch (self->state){ - case STATE_IOEXP_INIT: - result_val = _ioexp_init_handler(self); - /* Exception case: terminate initial procedure */ - if(result_val < 0){ - /* Initial fail */ - return result_val; - } - /* Case: System (Channel) not ready */ - if(self->state == STATE_IOEXP_INIT){ - /* Keep in INIT state, wait and retry */ - return 0; - } - /* Case: Initial done */ - SWPS_INFO("IOEXP-%d: initial done. :%d\n", - self->ioexp_id, self->ioexp_type); - return result_val; - - case STATE_IOEXP_NORMAL: - /* Retry mechanism for case of i2c topology not stable */ - for (i=0; iupdate_all(self, show_e, func_name); - if (result_val >= 0) { - self->state = STATE_IOEXP_NORMAL; - return 0; - } - if (check_channel_tier_1() < 0) { - SWPS_INFO("%s: detect I2C crash :%d\n", - __func__, self->ioexp_id); - break; - } - SWPS_DEBUG("IOEXP-%d: unstable :%d\n", - self->ioexp_id, result_val); - } - SWPS_INFO("IOEXP-%d: NORMAL -> ABNORMAL :%d\n", - self->ioexp_id, result_val); - self->state = STATE_IOEXP_ABNORMAL; - return result_val; - - case STATE_IOEXP_ABNORMAL: - result_val = self->update_all(self, show_e, func_name); - if (result_val < 0){ - self->state = STATE_IOEXP_ABNORMAL; - return result_val; - } - SWPS_INFO("IOEXP-%d: ABNORMAL -> NORMAL :%d\n", - self->ioexp_id, result_val); - self->state = STATE_IOEXP_NORMAL; - return 0; - - default: - break; - } - SWPS_ERR("IOEXP-%d: Exception occurs :%d\n", - self->ioexp_id, self->state); - return ERR_IOEXP_UNEXCPT; -} - - -/* ========== Object private functions for check & update ========== - */ -int -common_ioexp_check(struct ioexp_obj_s *self){ - - int result; - - if (self->mode != IOEXP_MODE_POLLING){ - SWPS_ERR("%s: not polling mode :%d\n", - __func__, self->mode); - return ERR_IOEXP_NOTSUPPORT; - } - mutex_lock(&self->lock); - result = self->fsm_4_polling(self); - mutex_unlock(&self->lock); - return result; -} - - -/* ========== Functions for Factory pattern ========== - */ -static struct ioexp_map_s * -get_ioexp_map(int ioexp_type){ - switch (ioexp_type){ - case IOEXP_TYPE_MAGINOLIA_NAB: - return &ioexp_map_magnolia_nab; - case IOEXP_TYPE_MAGINOLIA_4AB: - return &ioexp_map_magnolia_4ab; - case IOEXP_TYPE_MAGINOLIA_7AB: - case IOEXP_TYPE_SPRUCE_7AB: - return &ioexp_map_magnolia_7ab; - case IOEXP_TYPE_REDWOOD_P01P08: - return &ioexp_map_redwood_p01p08_p17p24; - case IOEXP_TYPE_REDWOOD_P09P16: - return &ioexp_map_redwood_p09p16_p25p32; - case IOEXP_TYPE_HUDSON32IGA_P01P08: - return &ioexp_map_hudson32iga_p01p08_p17p24; - case IOEXP_TYPE_HUDSON32IGA_P09P16: - return &ioexp_map_hudson32iga_p09p16_p25p32; - case IOEXP_TYPE_CYPRESS_7ABC: - return &ioexp_map_cypress_7abc; - case IOEXP_TYPE_TAHOE_5A: - return &ioexp_map_tahoe_5a; - case IOEXP_TYPE_TAHOE_6ABC: - return &ioexp_map_tahoe_6abc; - case IOEXP_TYPE_SEQUOIA_NABC: - return &ioexp_map_sequoia_nabc; - case IOEXP_TYPE_LAVENDER_P65: - return &ioexp_map_lavender_p65; - case CPLD_TYPE_COTTONWOOD: - return &cpld_map_cottonwood; - case IOEXP_TYPE_MAPLE_0ABC: - return &ioexp_map_maple_0abc; - case IOEXP_TYPE_MAPLE_NABC: - return &ioexp_map_maple_nabc; - case IOEXP_TYPE_GULMOHAR_NABC: - return &ioexp_map_gulmohar_nabc; - case IOEXP_TYPE_GULMOHAR_7ABC: - return &ioexp_map_gulmohar_7abc; - case IOEXP_TYPE_SFP_8P_LAYOUT_1: - return &ioexp_map_sfp_8p_layout_1; - case IOEXP_TYPE_QSFP_6P_LAYOUT_1: - return &ioexp_map_6p_qsfp_type_1; - default: - return NULL; - } -} - - -int -setup_ioexp_ssize_attr(struct ioexp_obj_s *self, - struct ioexp_map_s *ioexp_map_p, - int ioexp_id, - int ioexp_type, - int run_mode){ - switch (run_mode){ - case IOEXP_MODE_POLLING: /* Direct access device mode */ - case IOEXP_MODE_DIRECT: /* Polling mode, read from cache */ - self->mode = run_mode; - break; - default: - SWPS_ERR("%s: non-defined run_mode:%d\n", - __func__, run_mode); - self->mode = ERR_IOEXP_UNEXCPT; - return ERR_IOEXP_UNEXCPT; - } - /* Setup mapping structure */ - self->ioexp_map_p = kzalloc(sizeof(*ioexp_map_p), GFP_KERNEL); - if (!(self->ioexp_map_p)) { - SWPS_ERR("%s: kzalloc ioexp_map_p fail\n", __func__); - return -1; - } - memcpy(self->ioexp_map_p, ioexp_map_p, sizeof(*ioexp_map_p)); - /* Setup attributes */ - self->ioexp_id = ioexp_id; - self->ioexp_type = ioexp_type; - self->state = STATE_IOEXP_INIT; - mutex_init(&self->lock); - return 0; -} - - -static int -setup_addr_mapping(struct ioexp_obj_s *self, - struct ioexp_addr_s *addr_map_p, - int chip_amount){ - struct ioexp_addr_s *tmp_p; - if (!addr_map_p){ - SWPS_ERR("%s: map is null\n", __func__); - return -1; - } - tmp_p = kzalloc((sizeof(*addr_map_p) * chip_amount), GFP_KERNEL); - if (!tmp_p){ - SWPS_ERR("%s: kzalloc fail.\n", __func__); - return -1; - } - memcpy(tmp_p, addr_map_p, (sizeof(*addr_map_p) * chip_amount)); - self->ioexp_map_p->map_addr = tmp_p; - - return 0; -} - - -static int -setup_ioexp_public_cb(struct ioexp_obj_s *self, - int ioexp_type){ - - switch (ioexp_type){ - case IOEXP_TYPE_MAGINOLIA_NAB: - case IOEXP_TYPE_MAGINOLIA_4AB: - case CPLD_TYPE_COTTONWOOD: - self->get_present = common_get_present; - self->get_tx_fault = common_get_tx_fault; - self->get_rxlos = common_get_rxlos; - self->get_tx_disable = common_get_tx_disable; - self->get_reset = ioexp_get_not_support; - self->get_lpmod = ioexp_get_not_support; - self->get_modsel = ioexp_get_not_support; - self->get_hard_rs0 = ioexp_get_not_support; - self->get_hard_rs1 = ioexp_get_not_support; - self->set_tx_disable = common_set_tx_disable; - self->set_reset = ioexp_set_not_support; - self->set_lpmod = ioexp_set_not_support; - self->set_modsel = ioexp_set_not_support; - self->set_hard_rs0 = ioexp_set_not_support; - self->set_hard_rs1 = ioexp_set_not_support; - return 0; - - case IOEXP_TYPE_MAPLE_NABC: - case IOEXP_TYPE_GULMOHAR_NABC: - case IOEXP_TYPE_SFP_8P_LAYOUT_1: - self->get_present = common_get_present; - self->get_tx_fault = common_get_tx_fault; - self->get_rxlos = common_get_rxlos; - self->get_tx_disable = common_get_tx_disable; - self->get_reset = ioexp_get_not_support; - self->get_lpmod = ioexp_get_not_support; - self->get_modsel = ioexp_get_not_support; - self->get_hard_rs0 = common_get_hard_rs0; - self->get_hard_rs1 = common_get_hard_rs1; - self->set_tx_disable = common_set_tx_disable; - self->set_reset = ioexp_set_not_support; - self->set_lpmod = ioexp_set_not_support; - self->set_modsel = ioexp_set_not_support; - self->set_hard_rs0 = common_set_hard_rs0; - self->set_hard_rs1 = common_set_hard_rs1; - return 0; - - case IOEXP_TYPE_MAGINOLIA_7AB: - case IOEXP_TYPE_SPRUCE_7AB: - case IOEXP_TYPE_REDWOOD_P01P08: - case IOEXP_TYPE_REDWOOD_P09P16: - case IOEXP_TYPE_HUDSON32IGA_P01P08: - case IOEXP_TYPE_HUDSON32IGA_P09P16: - case IOEXP_TYPE_CYPRESS_7ABC: - case IOEXP_TYPE_TAHOE_5A: - case IOEXP_TYPE_TAHOE_6ABC: - case IOEXP_TYPE_SEQUOIA_NABC: - case IOEXP_TYPE_LAVENDER_P65: - case IOEXP_TYPE_MAPLE_0ABC: - case IOEXP_TYPE_GULMOHAR_7ABC: - case IOEXP_TYPE_QSFP_6P_LAYOUT_1: - self->get_present = common_get_present; - self->get_tx_fault = ioexp_get_not_support; - self->get_rxlos = ioexp_get_not_support; - self->get_tx_disable = ioexp_get_not_support; - self->get_reset = common_get_reset; - self->get_lpmod = common_get_lpmod; - self->get_modsel = common_get_modsel; - self->get_hard_rs0 = ioexp_get_not_support; - self->get_hard_rs1 = ioexp_get_not_support; - self->set_tx_disable = ioexp_set_not_support; - self->set_reset = common_set_reset; - self->set_lpmod = common_set_lpmod; - self->set_modsel = common_set_modsel; - self->set_hard_rs0 = ioexp_set_not_support; - self->set_hard_rs1 = ioexp_set_not_support; - return 0; - - default: - SWPS_ERR("%s: type:%d incorrect!\n", __func__, ioexp_type); - break; - } - return ERR_IOEXP_UNEXCPT; -} - - -static int -setup_ioexp_private_cb(struct ioexp_obj_s *self, - int ioexp_type){ - - switch (ioexp_type){ - case IOEXP_TYPE_MAGINOLIA_NAB: - case IOEXP_TYPE_MAGINOLIA_4AB: - case IOEXP_TYPE_MAGINOLIA_7AB: - case IOEXP_TYPE_SPRUCE_7AB: - case IOEXP_TYPE_REDWOOD_P01P08: - case IOEXP_TYPE_REDWOOD_P09P16: - case IOEXP_TYPE_HUDSON32IGA_P01P08: - case IOEXP_TYPE_HUDSON32IGA_P09P16: - case IOEXP_TYPE_CYPRESS_7ABC: - case IOEXP_TYPE_TAHOE_5A: - case IOEXP_TYPE_TAHOE_6ABC: - case IOEXP_TYPE_SEQUOIA_NABC: - case IOEXP_TYPE_LAVENDER_P65: - case CPLD_TYPE_COTTONWOOD: - case IOEXP_TYPE_MAPLE_NABC: - case IOEXP_TYPE_MAPLE_0ABC: - case IOEXP_TYPE_GULMOHAR_NABC: - case IOEXP_TYPE_GULMOHAR_7ABC: - case IOEXP_TYPE_SFP_8P_LAYOUT_1: - case IOEXP_TYPE_QSFP_6P_LAYOUT_1: - self->init = common_ioexp_init; - self->check = common_ioexp_check; - self->update_all = common_ioexp_update_all; - self->fsm_4_direct = common_ioexp_fsm_4_direct; - self->fsm_4_polling = common_ioexp_fsm_4_polling; - return 0; - - default: - SWPS_ERR("%s: type:%d incorrect!\n", __func__, ioexp_type); - break; - } - return ERR_IOEXP_UNEXCPT; -} - - -static int -setup_i2c_client_one(struct ioexp_obj_s *self, - int chip_id){ - - char *err_msg = "ERROR"; - struct i2c_adapter *adap = NULL; - struct i2c_client *client = NULL; - struct ioexp_i2c_s *i2c_obj_p = NULL; - struct ioexp_i2c_s *i2c_curr_p = NULL; - - int chan_id = self->ioexp_map_p->map_addr[chip_id].chan_id; - client = kzalloc(sizeof(*client), GFP_KERNEL); - if (!client){ - err_msg = "Can not kzalloc client!"; - goto err_ioexp_setup_i2c_1; - } - i2c_obj_p = kzalloc(sizeof(*i2c_obj_p), GFP_KERNEL); - if (!i2c_obj_p){ - err_msg = "Can not kzalloc i2c_obj_p!"; - goto err_ioexp_setup_i2c_2; - } - adap = i2c_get_adapter(chan_id); - if(!adap){ - err_msg = "Can not get adap!"; - goto err_ioexp_setup_i2c_3; - } - client->adapter = adap; - client->addr = self->ioexp_map_p->map_addr[chip_id].chip_addr; - i2c_obj_p->i2c_client_p = client; - i2c_obj_p->chip_id = chip_id; - i2c_obj_p->next = NULL; - if (!self->i2c_head_p){ - self->i2c_head_p = i2c_obj_p; - } else { - i2c_curr_p = self->i2c_head_p; - while (i2c_curr_p->next){ - i2c_curr_p = i2c_curr_p->next; - } - i2c_curr_p->next = i2c_obj_p; - } - return 0; - -err_ioexp_setup_i2c_3: - kfree(i2c_obj_p); -err_ioexp_setup_i2c_2: - kfree(client); -err_ioexp_setup_i2c_1: - SWPS_ERR("%s: %s :%d\n", __func__, err_msg, chan_id); - return -1; -} - - -static int -setup_i2c_client(struct ioexp_obj_s* self){ - - int result; - int chip_id = 0; - - for (chip_id=0; chip_id<(self->ioexp_map_p->chip_amount); chip_id++){ - result = setup_i2c_client_one(self, chip_id); - if (result < 0){ - SWPS_ERR("%s fail! :%d\n", __func__, chip_id); - return -1; - } - } - return 0; -} - - -static int -setup_ioexp_config(struct ioexp_obj_s *self) { - - int chip_id, offset, err_code; - struct ioexp_addr_s *addr_p; - - for (chip_id=0; chip_id<(self->ioexp_map_p->chip_amount); chip_id++){ - addr_p = &(self->ioexp_map_p->map_addr[chip_id]); - if (!addr_p){ - SWPS_ERR("IOEXP config incorrect! :%d \n",chip_id); - return -1; - } - for (offset=0; offset<(self->ioexp_map_p->data_width); offset++){ - - /* [Desc] Skip the setup config value behavior - [Note] Setup config value = -1 if you don't want to write the value to IOEXP or CPLD - */ - if(addr_p->conf_offset[offset] < 0){ - SWPS_DEBUG("skip a config_offset <%d>\n", addr_p->conf_offset[offset]); - continue; - } - err_code = i2c_smbus_write_byte_data(_get_i2c_client(self, chip_id), - addr_p->conf_offset[offset], - addr_p->conf_default[offset]); - - if (err_code < 0){ - SWPS_INFO("%s: set conf fail! :%d \n", __func__, err_code); - return -2; - } - } - } - return 0; -} - - -struct ioexp_obj_s * -_create_ioexp_obj(int ioexp_id, - int ioexp_type, - struct ioexp_addr_s *addr_map_p, - int run_mode){ - - struct ioexp_map_s* ioexp_map_p; - struct ioexp_obj_s* result_p; - struct ioexp_i2c_s *i2c_curr_p; - struct ioexp_i2c_s *i2c_next_p; - - /* Get layout */ - ioexp_map_p = get_ioexp_map(ioexp_type); - if (!ioexp_map_p){ - SWPS_ERR("%s: Invalid ioexp_type\n", __func__); - goto err_create_ioexp_fail; - } - /* Prepare IOEXP object */ - result_p = kzalloc(sizeof(*result_p), GFP_KERNEL); - if (!result_p){ - SWPS_ERR("%s: kzalloc failure!\n", __func__); - goto err_create_ioexp_fail; - } - /* Prepare static size attributes */ - if (setup_ioexp_ssize_attr(result_p, - ioexp_map_p, - ioexp_id, - ioexp_type, - run_mode) < 0){ - goto err_create_ioexp_setup_attr_fail; - } - /* Prepare address mapping */ - if (setup_addr_mapping(result_p, addr_map_p, ioexp_map_p->chip_amount) < 0){ - goto err_create_ioexp_setup_attr_fail; - } - if (setup_i2c_client(result_p) < 0){ - goto err_create_ioexp_setup_i2c_fail; - } - /* Prepare call back functions of object */ - if (setup_ioexp_public_cb(result_p, ioexp_type) < 0){ - goto err_create_ioexp_setup_i2c_fail; - } - if (setup_ioexp_private_cb(result_p, ioexp_type) < 0){ - goto err_create_ioexp_setup_i2c_fail; - } - return result_p; - -err_create_ioexp_setup_i2c_fail: - i2c_curr_p = result_p->i2c_head_p; - i2c_next_p = result_p->i2c_head_p; - while (i2c_curr_p){ - i2c_next_p = i2c_curr_p->next; - if (i2c_curr_p->i2c_client_p) { - i2c_put_adapter(i2c_curr_p->i2c_client_p->adapter); - kfree(i2c_curr_p->i2c_client_p); - } - kfree(i2c_curr_p); - i2c_curr_p = i2c_next_p; - } -err_create_ioexp_setup_attr_fail: - kfree(result_p); -err_create_ioexp_fail: - SWPS_ERR("%s: fail! :%d :%d \n", - __func__, ioexp_id, ioexp_type); - return NULL; -} - - -int -create_ioexp_obj(int ioexp_id, - int ioexp_type, - struct ioexp_addr_s *addr_map_p, - int run_mode){ - - struct ioexp_obj_s *ioexp_p = NULL; - - ioexp_p = _create_ioexp_obj(ioexp_id, ioexp_type, - addr_map_p, run_mode); - if (!ioexp_p){ - return -1; - } - if (ioexp_head_p == NULL){ - ioexp_head_p = ioexp_p; - ioexp_tail_p = ioexp_p; - return 0; - } - ioexp_tail_p->next = ioexp_p; - ioexp_tail_p = ioexp_p; - return 0; -} -EXPORT_SYMBOL(create_ioexp_obj); - - -static int -_init_ioexp_obj(struct ioexp_obj_s* self) { - - char *err_msg = "ERR"; - char *func_name = "_init_ioexp_obj"; - - /* Setup IOEXP configure byte */ - if (setup_ioexp_config(self) < 0){ - err_msg = "setup_ioexp_config fail"; - goto err_init_ioexp_obj; - } - /* Setup default data */ - if (_ioexp_init_handler(self) < 0){ - err_msg = "_ioexp_init_handler fail"; - goto err_init_ioexp_obj; - } - /* Update all */ - if (self->state == STATE_IOEXP_NORMAL){ - if (self->update_all(self, 1, func_name) < 0){ - err_msg = "update_all() fail"; - goto err_init_ioexp_obj; - } - } - return 0; - -err_init_ioexp_obj: - SWPS_DEBUG("%s: %s\n", __func__, err_msg); - return -1; -} - - -int -init_ioexp_objs(void){ - /* Return value: - * 0: Success - * -1: Detect topology error - * -2: SWPS internal error - */ - struct ioexp_obj_s *curr_p = ioexp_head_p; - - if (!curr_p) { - SWPS_ERR("%s: ioexp_head_p is NULL\n", __func__); - return -2; - } - while (curr_p) { - if (_init_ioexp_obj(curr_p) < 0) { - SWPS_DEBUG("%s: _init_ioexp_obj() fail\n", __func__); - return -1; - } - curr_p = curr_p->next; - } - SWPS_DEBUG("%s: done.\n", __func__); - return 0; -} -EXPORT_SYMBOL(init_ioexp_objs); - - -void -clean_ioexp_objs(void){ - - struct ioexp_i2c_s *i2c_curr_p = NULL; - struct ioexp_i2c_s *i2c_next_p = NULL; - struct ioexp_obj_s *ioexp_next_p = NULL; - struct ioexp_obj_s *ioexp_curr_p = ioexp_head_p; - - if (ioexp_head_p == NULL){ - ioexp_tail_p = NULL; - return; - } - while(ioexp_curr_p){ - ioexp_next_p = ioexp_curr_p->next; - if (ioexp_curr_p->ioexp_map_p) { - if (ioexp_curr_p->ioexp_map_p->map_addr) { - kfree(ioexp_curr_p->ioexp_map_p->map_addr); - } - kfree(ioexp_curr_p->ioexp_map_p); - } - - i2c_curr_p = ioexp_curr_p->i2c_head_p; - while (i2c_curr_p) { - i2c_next_p = i2c_curr_p->next; - if (i2c_curr_p->i2c_client_p) { - i2c_put_adapter(i2c_curr_p->i2c_client_p->adapter); - kfree(i2c_curr_p->i2c_client_p); - } - kfree(i2c_curr_p); - i2c_curr_p = i2c_next_p; - } - kfree(ioexp_curr_p); - ioexp_curr_p = ioexp_next_p; - } - ioexp_tail_p = NULL; - SWPS_DEBUG("%s: done.\n", __func__); -} -EXPORT_SYMBOL(clean_ioexp_objs); - - -int -check_ioexp_objs(void){ - - struct ioexp_obj_s *ioexp_curr_p = ioexp_head_p; - - while (ioexp_curr_p){ - if ( (ioexp_curr_p->check(ioexp_curr_p)) < 0){ - SWPS_INFO("check IOEXP-%d fail! :%d\n", - ioexp_curr_p->ioexp_id, ioexp_curr_p->ioexp_type); - return -1; - } - ioexp_curr_p = ioexp_curr_p->next; - } - return 0; -} -EXPORT_SYMBOL(check_ioexp_objs); - - -struct ioexp_obj_s * -get_ioexp_obj(int ioexp_id){ - - struct ioexp_obj_s *result_p = NULL; - struct ioexp_obj_s *ioexp_curr_p = ioexp_head_p; - - while(ioexp_curr_p){ - if (ioexp_curr_p->ioexp_id == ioexp_id){ - result_p = ioexp_curr_p; - break; - } - ioexp_curr_p = ioexp_curr_p->next; - } - return result_p; -} -EXPORT_SYMBOL(get_ioexp_obj); - - -void -unlock_ioexp_all(void) { - - struct ioexp_obj_s *ioexp_curr_p = ioexp_head_p; - - while(ioexp_curr_p){ - mutex_unlock(&ioexp_curr_p->lock); - ioexp_curr_p = ioexp_curr_p->next; - } -} -EXPORT_SYMBOL(unlock_ioexp_all); - -int -lock_ioexp_all(void) { - - struct ioexp_obj_s *ioexp_curr_p = ioexp_head_p; - - while(ioexp_curr_p){ - mutex_lock(&ioexp_curr_p->lock); - ioexp_curr_p = ioexp_curr_p->next; - } - return 0; -} -EXPORT_SYMBOL(lock_ioexp_all); - - -int -check_channel_tier_1(void) { - - if ( (!_is_channel_ready(ioexp_head_p)) && - (!_is_channel_ready(ioexp_tail_p)) ){ - return -1; - } - return 0; -} -EXPORT_SYMBOL(check_channel_tier_1); - - -static int -_scan_channel_tier_1(int force, - int show_err) { - - struct ioexp_obj_s *ioexp_curr_p = ioexp_head_p; - int ready = 0; - - if (!ioexp_curr_p) { - goto err_scan_tier_1_channel; - } - while(ioexp_curr_p) { - ready = _is_channel_ready(ioexp_curr_p); - if ((!ready) && (!force)) { - goto err_scan_tier_1_channel; - } - ioexp_curr_p = ioexp_curr_p->next; - } - return 0; - -err_scan_tier_1_channel: - if (show_err) { - if (ioexp_curr_p) { - SWPS_INFO("%s: IOEXP-%d fail\n", __func__, ioexp_curr_p->ioexp_id); - } else { - SWPS_INFO("%s: IOEXP is null.\n", __func__); - } - } - return -1; -} - - -static int -_scan_channel_tier_1_single(void) { - - int ret = 0; - int chan_id = 0; - int fake_cid = 0; - int fake_offs = 0; - int fake_addr = 0; - struct i2c_adapter *adap = NULL; - struct i2c_client *client = NULL; - - if (ioexp_head_p->ioexp_id != ioexp_tail_p->ioexp_id) { - return 0; - } - /* Setup i2c_client */ - chan_id = ioexp_head_p->ioexp_map_p->map_addr[fake_cid].chan_id; - fake_addr = ioexp_head_p->ioexp_map_p->map_addr[fake_cid].chip_addr; - adap = i2c_get_adapter((chan_id + 1)); - if(!adap){ - SWPS_INFO("%s: Can not get adap!\n", __func__); - return 0; - } - client = kzalloc(sizeof(*client), GFP_KERNEL); - if (!client){ - SWPS_INFO("%s: Can not kzalloc client!\n", __func__); - return 0; - } - client->adapter = adap; - client->addr = fake_addr; - /* Fouce move ioexp ptr to next */ - ret = i2c_smbus_read_byte_data(client, fake_offs); - SWPS_DEBUG("%s: move ioexp_ptr done. :%d\n", __func__, ret); - kfree(client); - return 1; -} - - -int -resync_channel_tier_1(void) { - - char *emsg = "ERR"; - - if (!ioexp_head_p) { - emsg = "ioexp_head_p is NULL"; - goto err_resync_ioexp_status_1; - } - /* Run all */ - if (ioexp_head_p->ioexp_id == ioexp_tail_p->ioexp_id) { - _scan_channel_tier_1_single(); - } else { - _scan_channel_tier_1(1, 0); - } - /* Check all */ - if (_scan_channel_tier_1(0, 1) < 0) { - emsg = "resync tier-1 channel fail"; - goto err_resync_ioexp_status_1; - } - return 0; - -err_resync_ioexp_status_1: - SWPS_ERR("%s: %s\n", __func__, emsg); - return -1; -} -EXPORT_SYMBOL(resync_channel_tier_1); - - -/* For build single module using (Ex: ONL platform) */ -//MODULE_LICENSE("GPL"); - - - diff --git a/packages/platforms/inventec/x86-64/d6356/modules/builds/src/io_expander.h b/packages/platforms/inventec/x86-64/d6356/modules/builds/src/io_expander.h deleted file mode 100644 index 0a8118fcb..000000000 --- a/packages/platforms/inventec/x86-64/d6356/modules/builds/src/io_expander.h +++ /dev/null @@ -1,185 +0,0 @@ -#ifndef IO_EXPANDER_H -#define IO_EXPANDER_H - -#include - - -/* IOEXP type define (SFP series) */ -#define IOEXP_TYPE_MAGINOLIA_NAB (10101) -#define IOEXP_TYPE_MAGINOLIA_4AB (10102) -#define IOEXP_TYPE_MAPLE_NABC (10104) -#define IOEXP_TYPE_GULMOHAR_NABC (10105) -#define IOEXP_TYPE_SFP_8P_LAYOUT_1 (10106) - -/* IOEXP type define (QSFP series) */ -#define IOEXP_TYPE_MAGINOLIA_7AB (10201) -#define IOEXP_TYPE_REDWOOD_P01P08 (10202) -#define IOEXP_TYPE_REDWOOD_P09P16 (10203) -#define IOEXP_TYPE_HUDSON32IGA_P01P08 (10204) -#define IOEXP_TYPE_HUDSON32IGA_P09P16 (10205) -#define IOEXP_TYPE_SPRUCE_7AB (10206) -#define IOEXP_TYPE_CYPRESS_7ABC (10207) -#define IOEXP_TYPE_TAHOE_5A (10208) -#define IOEXP_TYPE_TAHOE_6ABC (10209) -#define IOEXP_TYPE_SEQUOIA_NABC (10210) -#define IOEXP_TYPE_LAVENDER_P65 (10211) -#define IOEXP_TYPE_MAPLE_0ABC (10212) -#define IOEXP_TYPE_GULMOHAR_7ABC (10213) -#define IOEXP_TYPE_QSFP_6P_LAYOUT_1 (10214) - -/* CPLD type define */ -#define CPLD_TYPE_COTTONWOOD (10301) - -/* IOEXP mode define */ -#define IOEXP_MODE_POLLING (19000) -#define IOEXP_MODE_DIRECT (19001) - -/* IOEXP state define */ -#define STATE_IOEXP_NORMAL (0) -#define STATE_IOEXP_INIT (-1) -#define STATE_IOEXP_ABNORMAL (-2) - -/* IOEXP error code define */ -#define ERR_IOEXP_NOTSUPPORT (-100) -#define ERR_IOEXP_UNINIT (-101) -#define ERR_IOEXP_BADCONF (-102) -#define ERR_IOEXP_ABNORMAL (-103) -#define ERR_IOEXP_NOSTATE (-104) -#define ERR_IOEXP_BADINPUT (-105) -#define ERR_IOEXP_UNEXCPT (-199) - -#define SWPS_INFO(fmt, args...) printk( KERN_INFO "[SWPS] " fmt, ##args) -#define SWPS_WARN(fmt, args...) printk( KERN_WARNING "[SWPS] " fmt, ##args) -#define SWPS_ERR(fmt, args...) printk( KERN_ERR "[SWPS] " fmt, ##args) - -#ifdef DEBUG_SWPS -# define SWPS_DEBUG(fmt, args...) printk( KERN_DEBUG "[SWPS] " fmt, ##args) -#else -# define SWPS_DEBUG(fmt, args...) -#endif - - -struct ioexp_addr_s { - int chan_id; - int chip_addr; - int read_offset[8]; - int write_offset[8]; - int conf_offset[8]; - uint8_t data_default[8]; - uint8_t conf_default[8]; -}; - -struct ioexp_i2c_s { - int chip_id; - struct i2c_client *i2c_client_p; - struct ioexp_i2c_s *next; -}; - - -struct ioexp_bitmap_s { - int chip_id; /* IOEXP chip id */ - int ioexp_voffset; /* IOEXP virtual offset */ - int bit_shift; -}; - -struct ioexp_map_s { - int chip_amount; /* Number of chips that IOEXP object content */ - int data_width; /* Number of (Read/Write/Config) bytes */ - struct ioexp_addr_s *map_addr; /* Chip address info */ - struct ioexp_bitmap_s map_present[10]; /* IOEXP for SFP / QSFP */ - struct ioexp_bitmap_s map_tx_disable[10]; /* IOEXP for SFP */ - struct ioexp_bitmap_s map_tx_fault[10]; /* IOEXP for SFP */ - struct ioexp_bitmap_s map_rxlos[10]; /* IOEXP for SFP */ - struct ioexp_bitmap_s map_reset[10]; /* IOEXP for QSFP */ - struct ioexp_bitmap_s map_lpmod[10]; /* IOEXP for QSFP */ - struct ioexp_bitmap_s map_modsel[10]; /* IOEXP for QSFP */ - struct ioexp_bitmap_s map_hard_rs0[10]; /* IOEXP for QSFP */ - struct ioexp_bitmap_s map_hard_rs1[10]; /* IOEXP for QSFP */ -}; - -struct ioexp_data_s { - uint8_t data[8]; -}; - -struct ioexp_obj_s { - - /* ============================ - * Object public property - * ============================ - */ - int ioexp_id; - int ioexp_type; - - /* ============================ - * Object private property - * ============================ - */ - struct ioexp_data_s chip_data[16]; /* Max: 8-ioexp in one virt-ioexp(ioexp_obj) */ - struct ioexp_map_s *ioexp_map_p; - struct ioexp_obj_s *next; - struct ioexp_i2c_s *i2c_head_p; - struct mutex lock; - int mode; - int state; - - /* =========================================== - * Object public functions - * =========================================== - */ - int (*get_present)(struct ioexp_obj_s *self, int virt_offset); - int (*get_tx_fault)(struct ioexp_obj_s *self, int virt_offset); - int (*get_rxlos)(struct ioexp_obj_s *self, int virt_offset); - int (*get_tx_disable)(struct ioexp_obj_s *self, int virt_offset); - int (*get_reset)(struct ioexp_obj_s *self, int virt_offset); - int (*get_lpmod)(struct ioexp_obj_s *self, int virt_offset); - int (*get_modsel)(struct ioexp_obj_s *self, int virt_offset); - int (*get_hard_rs0)(struct ioexp_obj_s *self, int virt_offset); - int (*get_hard_rs1)(struct ioexp_obj_s *self, int virt_offset); - int (*set_tx_disable)(struct ioexp_obj_s *self, int virt_offset, int input_val); - int (*set_reset)(struct ioexp_obj_s *self, int virt_offset, int input_val); - int (*set_lpmod)(struct ioexp_obj_s *self, int virt_offset, int input_val); - int (*set_modsel)(struct ioexp_obj_s *self, int virt_offset, int input_val); - int (*set_hard_rs0)(struct ioexp_obj_s *self, int virt_offset, int input_val); - int (*set_hard_rs1)(struct ioexp_obj_s *self, int virt_offset, int input_val); - - /* =========================================== - * Object private functions - * =========================================== - */ - int (*init)(struct ioexp_obj_s *self); - int (*check)(struct ioexp_obj_s *self); - int (*update_all)(struct ioexp_obj_s *self, int show_err, char *caller_name); - int (*fsm_4_direct)(struct ioexp_obj_s* self); - int (*fsm_4_polling)(struct ioexp_obj_s* self); -}; - - -struct ioexp_obj_s* get_ioexp_obj(int ioexp_id); -int create_ioexp_obj(int ioexp_id, - int ioexp_type, - struct ioexp_addr_s *addr_map_p, - int run_mode); -int init_ioexp_objs(void); -int check_ioexp_objs(void); -void clean_ioexp_objs(void); - -void unlock_ioexp_all(void); -int lock_ioexp_all(void); - -int check_channel_tier_1(void); -int resync_channel_tier_1(void); - -/* Macro for bit control */ -#define SWP_BIT_SET(byte_val,bit_shift) ((byte_val) |= (1<<(bit_shift))) -#define SWP_BIT_CLEAR(byte_val,bit_shift) ((byte_val) &= ~(1<<(bit_shift))) - - -#endif /* IO_EXPANDER_H */ - - - - - - - - diff --git a/packages/platforms/inventec/x86-64/d6356/modules/builds/src/lpc_ich.c b/packages/platforms/inventec/x86-64/d6356/modules/builds/src/lpc_ich.c deleted file mode 100644 index e9897359c..000000000 --- a/packages/platforms/inventec/x86-64/d6356/modules/builds/src/lpc_ich.c +++ /dev/null @@ -1,1075 +0,0 @@ -/* - * lpc_ich.c - LPC interface for Intel ICH - * - * LPC bridge function of the Intel ICH contains many other - * functional units, such as Interrupt controllers, Timers, - * Power Management, System Management, GPIO, RTC, and LPC - * Configuration Registers. - * - * This driver is derived from lpc_sch. - - * Copyright (c) 2011 Extreme Engineering Solution, Inc. - * Author: Aaron Sierra - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License 2 as published - * by the Free Software Foundation. - * - * 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; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - * - * This driver supports the following I/O Controller hubs: - * (See the intel documentation on http://developer.intel.com.) - * document number 290655-003, 290677-014: 82801AA (ICH), 82801AB (ICHO) - * document number 290687-002, 298242-027: 82801BA (ICH2) - * document number 290733-003, 290739-013: 82801CA (ICH3-S) - * document number 290716-001, 290718-007: 82801CAM (ICH3-M) - * document number 290744-001, 290745-025: 82801DB (ICH4) - * document number 252337-001, 252663-008: 82801DBM (ICH4-M) - * document number 273599-001, 273645-002: 82801E (C-ICH) - * document number 252516-001, 252517-028: 82801EB (ICH5), 82801ER (ICH5R) - * document number 300641-004, 300884-013: 6300ESB - * document number 301473-002, 301474-026: 82801F (ICH6) - * document number 313082-001, 313075-006: 631xESB, 632xESB - * document number 307013-003, 307014-024: 82801G (ICH7) - * document number 322896-001, 322897-001: NM10 - * document number 313056-003, 313057-017: 82801H (ICH8) - * document number 316972-004, 316973-012: 82801I (ICH9) - * document number 319973-002, 319974-002: 82801J (ICH10) - * document number 322169-001, 322170-003: 5 Series, 3400 Series (PCH) - * document number 320066-003, 320257-008: EP80597 (IICH) - * document number 324645-001, 324646-001: Cougar Point (CPT) - * document number TBD : Patsburg (PBG) - * document number TBD : DH89xxCC - * document number TBD : Panther Point - * document number TBD : Lynx Point - * document number TBD : Lynx Point-LP - * document number TBD : Wellsburg - * document number TBD : Avoton SoC - * document number TBD : Coleto Creek - * document number TBD : Wildcat Point-LP - */ - -#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt - -#include -#include -#include -#include -#include -#include -#include - -#define ACPIBASE 0x40 -#define ACPIBASE_GPE_OFF 0x28 -#define ACPIBASE_GPE_END 0x2f -#define ACPIBASE_SMI_OFF 0x30 -#define ACPIBASE_SMI_END 0x33 -#define ACPIBASE_PMC_OFF 0x08 -#define ACPIBASE_PMC_END 0x0c -#define ACPIBASE_TCO_OFF 0x60 -#define ACPIBASE_TCO_END 0x7f -#define ACPICTRL_PMCBASE 0x44 - -#define ACPIBASE_GCS_OFF 0x3410 -#define ACPIBASE_GCS_END 0x3414 - -#define GPIOBASE_ICH0 0x58 -#define GPIOCTRL_ICH0 0x5C -#define GPIOBASE_ICH6 0x48 -#define GPIOCTRL_ICH6 0x4C - -#define RCBABASE 0xf0 - -#define wdt_io_res(i) wdt_res(0, i) -#define wdt_mem_res(i) wdt_res(ICH_RES_MEM_OFF, i) -#define wdt_res(b, i) (&wdt_ich_res[(b) + (i)]) - -struct lpc_ich_priv { - int chipset; - - int abase; /* ACPI base */ - int actrl_pbase; /* ACPI control or PMC base */ - int gbase; /* GPIO base */ - int gctrl; /* GPIO control */ - - int abase_save; /* Cached ACPI base value */ - int actrl_pbase_save; /* Cached ACPI control or PMC base value */ - int gctrl_save; /* Cached GPIO control value */ -}; - -static struct resource wdt_ich_res[] = { - /* ACPI - TCO */ - { - .flags = IORESOURCE_IO, - }, - /* ACPI - SMI */ - { - .flags = IORESOURCE_IO, - }, - /* GCS or PMC */ - { - .flags = IORESOURCE_MEM, - }, -}; - -static struct resource gpio_ich_res[] = { - /* GPIO */ - { - .flags = IORESOURCE_IO, - }, - /* ACPI - GPE0 */ - { - .flags = IORESOURCE_IO, - }, -}; - -enum lpc_cells { - LPC_WDT = 0, - LPC_GPIO, -}; - -static struct mfd_cell lpc_ich_cells[] = { - [LPC_WDT] = { - .name = "iTCO_wdt", - .num_resources = ARRAY_SIZE(wdt_ich_res), - .resources = wdt_ich_res, - .ignore_resource_conflicts = true, - }, - [LPC_GPIO] = { - .name = "gpio_ich", - .num_resources = ARRAY_SIZE(gpio_ich_res), - .resources = gpio_ich_res, - .ignore_resource_conflicts = true, - }, -}; - -/* chipset related info */ -enum lpc_chipsets { - LPC_ICH = 0, /* ICH */ - LPC_ICH0, /* ICH0 */ - LPC_ICH2, /* ICH2 */ - LPC_ICH2M, /* ICH2-M */ - LPC_ICH3, /* ICH3-S */ - LPC_ICH3M, /* ICH3-M */ - LPC_ICH4, /* ICH4 */ - LPC_ICH4M, /* ICH4-M */ - LPC_CICH, /* C-ICH */ - LPC_ICH5, /* ICH5 & ICH5R */ - LPC_6300ESB, /* 6300ESB */ - LPC_ICH6, /* ICH6 & ICH6R */ - LPC_ICH6M, /* ICH6-M */ - LPC_ICH6W, /* ICH6W & ICH6RW */ - LPC_631XESB, /* 631xESB/632xESB */ - LPC_ICH7, /* ICH7 & ICH7R */ - LPC_ICH7DH, /* ICH7DH */ - LPC_ICH7M, /* ICH7-M & ICH7-U */ - LPC_ICH7MDH, /* ICH7-M DH */ - LPC_NM10, /* NM10 */ - LPC_ICH8, /* ICH8 & ICH8R */ - LPC_ICH8DH, /* ICH8DH */ - LPC_ICH8DO, /* ICH8DO */ - LPC_ICH8M, /* ICH8M */ - LPC_ICH8ME, /* ICH8M-E */ - LPC_ICH9, /* ICH9 */ - LPC_ICH9R, /* ICH9R */ - LPC_ICH9DH, /* ICH9DH */ - LPC_ICH9DO, /* ICH9DO */ - LPC_ICH9M, /* ICH9M */ - LPC_ICH9ME, /* ICH9M-E */ - LPC_ICH10, /* ICH10 */ - LPC_ICH10R, /* ICH10R */ - LPC_ICH10D, /* ICH10D */ - LPC_ICH10DO, /* ICH10DO */ - LPC_PCH, /* PCH Desktop Full Featured */ - LPC_PCHM, /* PCH Mobile Full Featured */ - LPC_P55, /* P55 */ - LPC_PM55, /* PM55 */ - LPC_H55, /* H55 */ - LPC_QM57, /* QM57 */ - LPC_H57, /* H57 */ - LPC_HM55, /* HM55 */ - LPC_Q57, /* Q57 */ - LPC_HM57, /* HM57 */ - LPC_PCHMSFF, /* PCH Mobile SFF Full Featured */ - LPC_QS57, /* QS57 */ - LPC_3400, /* 3400 */ - LPC_3420, /* 3420 */ - LPC_3450, /* 3450 */ - LPC_EP80579, /* EP80579 */ - LPC_CPT, /* Cougar Point */ - LPC_CPTD, /* Cougar Point Desktop */ - LPC_CPTM, /* Cougar Point Mobile */ - LPC_PBG, /* Patsburg */ - LPC_DH89XXCC, /* DH89xxCC */ - LPC_PPT, /* Panther Point */ - LPC_LPT, /* Lynx Point */ - LPC_LPT_LP, /* Lynx Point-LP */ - LPC_WBG, /* Wellsburg */ - LPC_AVN, /* Avoton SoC */ - LPC_BAYTRAIL, /* Bay Trail SoC */ - LPC_COLETO, /* Coleto Creek */ - LPC_WPT_LP, /* Wildcat Point-LP */ -}; - -static struct lpc_ich_info lpc_chipset_info[] = { - [LPC_ICH] = { - .name = "ICH", - .iTCO_version = 1, - }, - [LPC_ICH0] = { - .name = "ICH0", - .iTCO_version = 1, - }, - [LPC_ICH2] = { - .name = "ICH2", - .iTCO_version = 1, - }, - [LPC_ICH2M] = { - .name = "ICH2-M", - .iTCO_version = 1, - }, - [LPC_ICH3] = { - .name = "ICH3-S", - .iTCO_version = 1, - }, - [LPC_ICH3M] = { - .name = "ICH3-M", - .iTCO_version = 1, - }, - [LPC_ICH4] = { - .name = "ICH4", - .iTCO_version = 1, - }, - [LPC_ICH4M] = { - .name = "ICH4-M", - .iTCO_version = 1, - }, - [LPC_CICH] = { - .name = "C-ICH", - .iTCO_version = 1, - }, - [LPC_ICH5] = { - .name = "ICH5 or ICH5R", - .iTCO_version = 1, - }, - [LPC_6300ESB] = { - .name = "6300ESB", - .iTCO_version = 1, - }, - [LPC_ICH6] = { - .name = "ICH6 or ICH6R", - .iTCO_version = 2, - .gpio_version = ICH_V6_GPIO, - }, - [LPC_ICH6M] = { - .name = "ICH6-M", - .iTCO_version = 2, - .gpio_version = ICH_V6_GPIO, - }, - [LPC_ICH6W] = { - .name = "ICH6W or ICH6RW", - .iTCO_version = 2, - .gpio_version = ICH_V6_GPIO, - }, - [LPC_631XESB] = { - .name = "631xESB/632xESB", - .iTCO_version = 2, - .gpio_version = ICH_V6_GPIO, - }, - [LPC_ICH7] = { - .name = "ICH7 or ICH7R", - .iTCO_version = 2, - .gpio_version = ICH_V7_GPIO, - }, - [LPC_ICH7DH] = { - .name = "ICH7DH", - .iTCO_version = 2, - .gpio_version = ICH_V7_GPIO, - }, - [LPC_ICH7M] = { - .name = "ICH7-M or ICH7-U", - .iTCO_version = 2, - .gpio_version = ICH_V7_GPIO, - }, - [LPC_ICH7MDH] = { - .name = "ICH7-M DH", - .iTCO_version = 2, - .gpio_version = ICH_V7_GPIO, - }, - [LPC_NM10] = { - .name = "NM10", - .iTCO_version = 2, - .gpio_version = ICH_V7_GPIO, - }, - [LPC_ICH8] = { - .name = "ICH8 or ICH8R", - .iTCO_version = 2, - .gpio_version = ICH_V7_GPIO, - }, - [LPC_ICH8DH] = { - .name = "ICH8DH", - .iTCO_version = 2, - .gpio_version = ICH_V7_GPIO, - }, - [LPC_ICH8DO] = { - .name = "ICH8DO", - .iTCO_version = 2, - .gpio_version = ICH_V7_GPIO, - }, - [LPC_ICH8M] = { - .name = "ICH8M", - .iTCO_version = 2, - .gpio_version = ICH_V7_GPIO, - }, - [LPC_ICH8ME] = { - .name = "ICH8M-E", - .iTCO_version = 2, - .gpio_version = ICH_V7_GPIO, - }, - [LPC_ICH9] = { - .name = "ICH9", - .iTCO_version = 2, - .gpio_version = ICH_V9_GPIO, - }, - [LPC_ICH9R] = { - .name = "ICH9R", - .iTCO_version = 2, - .gpio_version = ICH_V9_GPIO, - }, - [LPC_ICH9DH] = { - .name = "ICH9DH", - .iTCO_version = 2, - .gpio_version = ICH_V9_GPIO, - }, - [LPC_ICH9DO] = { - .name = "ICH9DO", - .iTCO_version = 2, - .gpio_version = ICH_V9_GPIO, - }, - [LPC_ICH9M] = { - .name = "ICH9M", - .iTCO_version = 2, - .gpio_version = ICH_V9_GPIO, - }, - [LPC_ICH9ME] = { - .name = "ICH9M-E", - .iTCO_version = 2, - .gpio_version = ICH_V9_GPIO, - }, - [LPC_ICH10] = { - .name = "ICH10", - .iTCO_version = 2, - .gpio_version = ICH_V10CONS_GPIO, - }, - [LPC_ICH10R] = { - .name = "ICH10R", - .iTCO_version = 2, - .gpio_version = ICH_V10CONS_GPIO, - }, - [LPC_ICH10D] = { - .name = "ICH10D", - .iTCO_version = 2, - .gpio_version = ICH_V10CORP_GPIO, - }, - [LPC_ICH10DO] = { - .name = "ICH10DO", - .iTCO_version = 2, - .gpio_version = ICH_V10CORP_GPIO, - }, - [LPC_PCH] = { - .name = "PCH Desktop Full Featured", - .iTCO_version = 2, - .gpio_version = ICH_V5_GPIO, - }, - [LPC_PCHM] = { - .name = "PCH Mobile Full Featured", - .iTCO_version = 2, - .gpio_version = ICH_V5_GPIO, - }, - [LPC_P55] = { - .name = "P55", - .iTCO_version = 2, - .gpio_version = ICH_V5_GPIO, - }, - [LPC_PM55] = { - .name = "PM55", - .iTCO_version = 2, - .gpio_version = ICH_V5_GPIO, - }, - [LPC_H55] = { - .name = "H55", - .iTCO_version = 2, - .gpio_version = ICH_V5_GPIO, - }, - [LPC_QM57] = { - .name = "QM57", - .iTCO_version = 2, - .gpio_version = ICH_V5_GPIO, - }, - [LPC_H57] = { - .name = "H57", - .iTCO_version = 2, - .gpio_version = ICH_V5_GPIO, - }, - [LPC_HM55] = { - .name = "HM55", - .iTCO_version = 2, - .gpio_version = ICH_V5_GPIO, - }, - [LPC_Q57] = { - .name = "Q57", - .iTCO_version = 2, - .gpio_version = ICH_V5_GPIO, - }, - [LPC_HM57] = { - .name = "HM57", - .iTCO_version = 2, - .gpio_version = ICH_V5_GPIO, - }, - [LPC_PCHMSFF] = { - .name = "PCH Mobile SFF Full Featured", - .iTCO_version = 2, - .gpio_version = ICH_V5_GPIO, - }, - [LPC_QS57] = { - .name = "QS57", - .iTCO_version = 2, - .gpio_version = ICH_V5_GPIO, - }, - [LPC_3400] = { - .name = "3400", - .iTCO_version = 2, - .gpio_version = ICH_V5_GPIO, - }, - [LPC_3420] = { - .name = "3420", - .iTCO_version = 2, - .gpio_version = ICH_V5_GPIO, - }, - [LPC_3450] = { - .name = "3450", - .iTCO_version = 2, - .gpio_version = ICH_V5_GPIO, - }, - [LPC_EP80579] = { - .name = "EP80579", - .iTCO_version = 2, - }, - [LPC_CPT] = { - .name = "Cougar Point", - .iTCO_version = 2, - .gpio_version = ICH_V5_GPIO, - }, - [LPC_CPTD] = { - .name = "Cougar Point Desktop", - .iTCO_version = 2, - .gpio_version = ICH_V5_GPIO, - }, - [LPC_CPTM] = { - .name = "Cougar Point Mobile", - .iTCO_version = 2, - .gpio_version = ICH_V5_GPIO, - }, - [LPC_PBG] = { - .name = "Patsburg", - .iTCO_version = 2, - }, - [LPC_DH89XXCC] = { - .name = "DH89xxCC", - .iTCO_version = 2, - }, - [LPC_PPT] = { - .name = "Panther Point", - .iTCO_version = 2, - .gpio_version = ICH_V5_GPIO, - }, - [LPC_LPT] = { - .name = "Lynx Point", - .iTCO_version = 2, - .gpio_version = ICH_V5_GPIO, - }, - [LPC_LPT_LP] = { - .name = "Lynx Point_LP", - .iTCO_version = 2, - }, - [LPC_WBG] = { - .name = "Wellsburg", - .iTCO_version = 2, - }, - [LPC_AVN] = { - .name = "Avoton SoC", - .iTCO_version = 3, - .gpio_version = AVOTON_GPIO, - }, - [LPC_BAYTRAIL] = { - .name = "Bay Trail SoC", - .iTCO_version = 3, - }, - [LPC_COLETO] = { - .name = "Coleto Creek", - .iTCO_version = 2, - }, - [LPC_WPT_LP] = { - .name = "Wildcat Point_LP", - .iTCO_version = 2, - }, -}; - -/* - * This data only exists for exporting the supported PCI ids - * via MODULE_DEVICE_TABLE. We do not actually register a - * pci_driver, because the I/O Controller Hub has also other - * functions that probably will be registered by other drivers. - */ -static const struct pci_device_id lpc_ich_ids[] = { - { PCI_VDEVICE(INTEL, 0x2410), LPC_ICH}, - { PCI_VDEVICE(INTEL, 0x2420), LPC_ICH0}, - { PCI_VDEVICE(INTEL, 0x2440), LPC_ICH2}, - { PCI_VDEVICE(INTEL, 0x244c), LPC_ICH2M}, - { PCI_VDEVICE(INTEL, 0x2480), LPC_ICH3}, - { PCI_VDEVICE(INTEL, 0x248c), LPC_ICH3M}, - { PCI_VDEVICE(INTEL, 0x24c0), LPC_ICH4}, - { PCI_VDEVICE(INTEL, 0x24cc), LPC_ICH4M}, - { PCI_VDEVICE(INTEL, 0x2450), LPC_CICH}, - { PCI_VDEVICE(INTEL, 0x24d0), LPC_ICH5}, - { PCI_VDEVICE(INTEL, 0x25a1), LPC_6300ESB}, - { PCI_VDEVICE(INTEL, 0x2640), LPC_ICH6}, - { PCI_VDEVICE(INTEL, 0x2641), LPC_ICH6M}, - { PCI_VDEVICE(INTEL, 0x2642), LPC_ICH6W}, - { PCI_VDEVICE(INTEL, 0x2670), LPC_631XESB}, - { PCI_VDEVICE(INTEL, 0x2671), LPC_631XESB}, - { PCI_VDEVICE(INTEL, 0x2672), LPC_631XESB}, - { PCI_VDEVICE(INTEL, 0x2673), LPC_631XESB}, - { PCI_VDEVICE(INTEL, 0x2674), LPC_631XESB}, - { PCI_VDEVICE(INTEL, 0x2675), LPC_631XESB}, - { PCI_VDEVICE(INTEL, 0x2676), LPC_631XESB}, - { PCI_VDEVICE(INTEL, 0x2677), LPC_631XESB}, - { PCI_VDEVICE(INTEL, 0x2678), LPC_631XESB}, - { PCI_VDEVICE(INTEL, 0x2679), LPC_631XESB}, - { PCI_VDEVICE(INTEL, 0x267a), LPC_631XESB}, - { PCI_VDEVICE(INTEL, 0x267b), LPC_631XESB}, - { PCI_VDEVICE(INTEL, 0x267c), LPC_631XESB}, - { PCI_VDEVICE(INTEL, 0x267d), LPC_631XESB}, - { PCI_VDEVICE(INTEL, 0x267e), LPC_631XESB}, - { PCI_VDEVICE(INTEL, 0x267f), LPC_631XESB}, - { PCI_VDEVICE(INTEL, 0x27b8), LPC_ICH7}, - { PCI_VDEVICE(INTEL, 0x27b0), LPC_ICH7DH}, - { PCI_VDEVICE(INTEL, 0x27b9), LPC_ICH7M}, - { PCI_VDEVICE(INTEL, 0x27bd), LPC_ICH7MDH}, - { PCI_VDEVICE(INTEL, 0x27bc), LPC_NM10}, - { PCI_VDEVICE(INTEL, 0x2810), LPC_ICH8}, - { PCI_VDEVICE(INTEL, 0x2812), LPC_ICH8DH}, - { PCI_VDEVICE(INTEL, 0x2814), LPC_ICH8DO}, - { PCI_VDEVICE(INTEL, 0x2815), LPC_ICH8M}, - { PCI_VDEVICE(INTEL, 0x2811), LPC_ICH8ME}, - { PCI_VDEVICE(INTEL, 0x2918), LPC_ICH9}, - { PCI_VDEVICE(INTEL, 0x2916), LPC_ICH9R}, - { PCI_VDEVICE(INTEL, 0x2912), LPC_ICH9DH}, - { PCI_VDEVICE(INTEL, 0x2914), LPC_ICH9DO}, - { PCI_VDEVICE(INTEL, 0x2919), LPC_ICH9M}, - { PCI_VDEVICE(INTEL, 0x2917), LPC_ICH9ME}, - { PCI_VDEVICE(INTEL, 0x3a18), LPC_ICH10}, - { PCI_VDEVICE(INTEL, 0x3a16), LPC_ICH10R}, - { PCI_VDEVICE(INTEL, 0x3a1a), LPC_ICH10D}, - { PCI_VDEVICE(INTEL, 0x3a14), LPC_ICH10DO}, - { PCI_VDEVICE(INTEL, 0x3b00), LPC_PCH}, - { PCI_VDEVICE(INTEL, 0x3b01), LPC_PCHM}, - { PCI_VDEVICE(INTEL, 0x3b02), LPC_P55}, - { PCI_VDEVICE(INTEL, 0x3b03), LPC_PM55}, - { PCI_VDEVICE(INTEL, 0x3b06), LPC_H55}, - { PCI_VDEVICE(INTEL, 0x3b07), LPC_QM57}, - { PCI_VDEVICE(INTEL, 0x3b08), LPC_H57}, - { PCI_VDEVICE(INTEL, 0x3b09), LPC_HM55}, - { PCI_VDEVICE(INTEL, 0x3b0a), LPC_Q57}, - { PCI_VDEVICE(INTEL, 0x3b0b), LPC_HM57}, - { PCI_VDEVICE(INTEL, 0x3b0d), LPC_PCHMSFF}, - { PCI_VDEVICE(INTEL, 0x3b0f), LPC_QS57}, - { PCI_VDEVICE(INTEL, 0x3b12), LPC_3400}, - { PCI_VDEVICE(INTEL, 0x3b14), LPC_3420}, - { PCI_VDEVICE(INTEL, 0x3b16), LPC_3450}, - { PCI_VDEVICE(INTEL, 0x5031), LPC_EP80579}, - { PCI_VDEVICE(INTEL, 0x1c41), LPC_CPT}, - { PCI_VDEVICE(INTEL, 0x1c42), LPC_CPTD}, - { PCI_VDEVICE(INTEL, 0x1c43), LPC_CPTM}, - { PCI_VDEVICE(INTEL, 0x1c44), LPC_CPT}, - { PCI_VDEVICE(INTEL, 0x1c45), LPC_CPT}, - { PCI_VDEVICE(INTEL, 0x1c46), LPC_CPT}, - { PCI_VDEVICE(INTEL, 0x1c47), LPC_CPT}, - { PCI_VDEVICE(INTEL, 0x1c48), LPC_CPT}, - { PCI_VDEVICE(INTEL, 0x1c49), LPC_CPT}, - { PCI_VDEVICE(INTEL, 0x1c4a), LPC_CPT}, - { PCI_VDEVICE(INTEL, 0x1c4b), LPC_CPT}, - { PCI_VDEVICE(INTEL, 0x1c4c), LPC_CPT}, - { PCI_VDEVICE(INTEL, 0x1c4d), LPC_CPT}, - { PCI_VDEVICE(INTEL, 0x1c4e), LPC_CPT}, - { PCI_VDEVICE(INTEL, 0x1c4f), LPC_CPT}, - { PCI_VDEVICE(INTEL, 0x1c50), LPC_CPT}, - { PCI_VDEVICE(INTEL, 0x1c51), LPC_CPT}, - { PCI_VDEVICE(INTEL, 0x1c52), LPC_CPT}, - { PCI_VDEVICE(INTEL, 0x1c53), LPC_CPT}, - { PCI_VDEVICE(INTEL, 0x1c54), LPC_CPT}, - { PCI_VDEVICE(INTEL, 0x1c55), LPC_CPT}, - { PCI_VDEVICE(INTEL, 0x1c56), LPC_CPT}, - { PCI_VDEVICE(INTEL, 0x1c57), LPC_CPT}, - { PCI_VDEVICE(INTEL, 0x1c58), LPC_CPT}, - { PCI_VDEVICE(INTEL, 0x1c59), LPC_CPT}, - { PCI_VDEVICE(INTEL, 0x1c5a), LPC_CPT}, - { PCI_VDEVICE(INTEL, 0x1c5b), LPC_CPT}, - { PCI_VDEVICE(INTEL, 0x1c5c), LPC_CPT}, - { PCI_VDEVICE(INTEL, 0x1c5d), LPC_CPT}, - { PCI_VDEVICE(INTEL, 0x1c5e), LPC_CPT}, - { PCI_VDEVICE(INTEL, 0x1c5f), LPC_CPT}, - { PCI_VDEVICE(INTEL, 0x1d40), LPC_PBG}, - { PCI_VDEVICE(INTEL, 0x1d41), LPC_PBG}, - { PCI_VDEVICE(INTEL, 0x2310), LPC_DH89XXCC}, - { PCI_VDEVICE(INTEL, 0x1e40), LPC_PPT}, - { PCI_VDEVICE(INTEL, 0x1e41), LPC_PPT}, - { PCI_VDEVICE(INTEL, 0x1e42), LPC_PPT}, - { PCI_VDEVICE(INTEL, 0x1e43), LPC_PPT}, - { PCI_VDEVICE(INTEL, 0x1e44), LPC_PPT}, - { PCI_VDEVICE(INTEL, 0x1e45), LPC_PPT}, - { PCI_VDEVICE(INTEL, 0x1e46), LPC_PPT}, - { PCI_VDEVICE(INTEL, 0x1e47), LPC_PPT}, - { PCI_VDEVICE(INTEL, 0x1e48), LPC_PPT}, - { PCI_VDEVICE(INTEL, 0x1e49), LPC_PPT}, - { PCI_VDEVICE(INTEL, 0x1e4a), LPC_PPT}, - { PCI_VDEVICE(INTEL, 0x1e4b), LPC_PPT}, - { PCI_VDEVICE(INTEL, 0x1e4c), LPC_PPT}, - { PCI_VDEVICE(INTEL, 0x1e4d), LPC_PPT}, - { PCI_VDEVICE(INTEL, 0x1e4e), LPC_PPT}, - { PCI_VDEVICE(INTEL, 0x1e4f), LPC_PPT}, - { PCI_VDEVICE(INTEL, 0x1e50), LPC_PPT}, - { PCI_VDEVICE(INTEL, 0x1e51), LPC_PPT}, - { PCI_VDEVICE(INTEL, 0x1e52), LPC_PPT}, - { PCI_VDEVICE(INTEL, 0x1e53), LPC_PPT}, - { PCI_VDEVICE(INTEL, 0x1e54), LPC_PPT}, - { PCI_VDEVICE(INTEL, 0x1e55), LPC_PPT}, - { PCI_VDEVICE(INTEL, 0x1e56), LPC_PPT}, - { PCI_VDEVICE(INTEL, 0x1e57), LPC_PPT}, - { PCI_VDEVICE(INTEL, 0x1e58), LPC_PPT}, - { PCI_VDEVICE(INTEL, 0x1e59), LPC_PPT}, - { PCI_VDEVICE(INTEL, 0x1e5a), LPC_PPT}, - { PCI_VDEVICE(INTEL, 0x1e5b), LPC_PPT}, - { PCI_VDEVICE(INTEL, 0x1e5c), LPC_PPT}, - { PCI_VDEVICE(INTEL, 0x1e5d), LPC_PPT}, - { PCI_VDEVICE(INTEL, 0x1e5e), LPC_PPT}, - { PCI_VDEVICE(INTEL, 0x1e5f), LPC_PPT}, - { PCI_VDEVICE(INTEL, 0x8c40), LPC_LPT}, - { PCI_VDEVICE(INTEL, 0x8c41), LPC_LPT}, - { PCI_VDEVICE(INTEL, 0x8c42), LPC_LPT}, - { PCI_VDEVICE(INTEL, 0x8c43), LPC_LPT}, - { PCI_VDEVICE(INTEL, 0x8c44), LPC_LPT}, - { PCI_VDEVICE(INTEL, 0x8c45), LPC_LPT}, - { PCI_VDEVICE(INTEL, 0x8c46), LPC_LPT}, - { PCI_VDEVICE(INTEL, 0x8c47), LPC_LPT}, - { PCI_VDEVICE(INTEL, 0x8c48), LPC_LPT}, - { PCI_VDEVICE(INTEL, 0x8c49), LPC_LPT}, - { PCI_VDEVICE(INTEL, 0x8c4a), LPC_LPT}, - { PCI_VDEVICE(INTEL, 0x8c4b), LPC_LPT}, - { PCI_VDEVICE(INTEL, 0x8c4c), LPC_LPT}, - { PCI_VDEVICE(INTEL, 0x8c4d), LPC_LPT}, - { PCI_VDEVICE(INTEL, 0x8c4e), LPC_LPT}, - { PCI_VDEVICE(INTEL, 0x8c4f), LPC_LPT}, - { PCI_VDEVICE(INTEL, 0x8c50), LPC_LPT}, - { PCI_VDEVICE(INTEL, 0x8c51), LPC_LPT}, - { PCI_VDEVICE(INTEL, 0x8c52), LPC_LPT}, - { PCI_VDEVICE(INTEL, 0x8c53), LPC_LPT}, - { PCI_VDEVICE(INTEL, 0x8c54), LPC_LPT}, - { PCI_VDEVICE(INTEL, 0x8c55), LPC_LPT}, - { PCI_VDEVICE(INTEL, 0x8c56), LPC_LPT}, - { PCI_VDEVICE(INTEL, 0x8c57), LPC_LPT}, - { PCI_VDEVICE(INTEL, 0x8c58), LPC_LPT}, - { PCI_VDEVICE(INTEL, 0x8c59), LPC_LPT}, - { PCI_VDEVICE(INTEL, 0x8c5a), LPC_LPT}, - { PCI_VDEVICE(INTEL, 0x8c5b), LPC_LPT}, - { PCI_VDEVICE(INTEL, 0x8c5c), LPC_LPT}, - { PCI_VDEVICE(INTEL, 0x8c5d), LPC_LPT}, - { PCI_VDEVICE(INTEL, 0x8c5e), LPC_LPT}, - { PCI_VDEVICE(INTEL, 0x8c5f), LPC_LPT}, - { PCI_VDEVICE(INTEL, 0x9c40), LPC_LPT_LP}, - { PCI_VDEVICE(INTEL, 0x9c41), LPC_LPT_LP}, - { PCI_VDEVICE(INTEL, 0x9c42), LPC_LPT_LP}, - { PCI_VDEVICE(INTEL, 0x9c43), LPC_LPT_LP}, - { PCI_VDEVICE(INTEL, 0x9c44), LPC_LPT_LP}, - { PCI_VDEVICE(INTEL, 0x9c45), LPC_LPT_LP}, - { PCI_VDEVICE(INTEL, 0x9c46), LPC_LPT_LP}, - { PCI_VDEVICE(INTEL, 0x9c47), LPC_LPT_LP}, - { PCI_VDEVICE(INTEL, 0x8d40), LPC_WBG}, - { PCI_VDEVICE(INTEL, 0x8d41), LPC_WBG}, - { PCI_VDEVICE(INTEL, 0x8d42), LPC_WBG}, - { PCI_VDEVICE(INTEL, 0x8d43), LPC_WBG}, - { PCI_VDEVICE(INTEL, 0x8d44), LPC_WBG}, - { PCI_VDEVICE(INTEL, 0x8d45), LPC_WBG}, - { PCI_VDEVICE(INTEL, 0x8d46), LPC_WBG}, - { PCI_VDEVICE(INTEL, 0x8d47), LPC_WBG}, - { PCI_VDEVICE(INTEL, 0x8d48), LPC_WBG}, - { PCI_VDEVICE(INTEL, 0x8d49), LPC_WBG}, - { PCI_VDEVICE(INTEL, 0x8d4a), LPC_WBG}, - { PCI_VDEVICE(INTEL, 0x8d4b), LPC_WBG}, - { PCI_VDEVICE(INTEL, 0x8d4c), LPC_WBG}, - { PCI_VDEVICE(INTEL, 0x8d4d), LPC_WBG}, - { PCI_VDEVICE(INTEL, 0x8d4e), LPC_WBG}, - { PCI_VDEVICE(INTEL, 0x8d4f), LPC_WBG}, - { PCI_VDEVICE(INTEL, 0x8d50), LPC_WBG}, - { PCI_VDEVICE(INTEL, 0x8d51), LPC_WBG}, - { PCI_VDEVICE(INTEL, 0x8d52), LPC_WBG}, - { PCI_VDEVICE(INTEL, 0x8d53), LPC_WBG}, - { PCI_VDEVICE(INTEL, 0x8d54), LPC_WBG}, - { PCI_VDEVICE(INTEL, 0x8d55), LPC_WBG}, - { PCI_VDEVICE(INTEL, 0x8d56), LPC_WBG}, - { PCI_VDEVICE(INTEL, 0x8d57), LPC_WBG}, - { PCI_VDEVICE(INTEL, 0x8d58), LPC_WBG}, - { PCI_VDEVICE(INTEL, 0x8d59), LPC_WBG}, - { PCI_VDEVICE(INTEL, 0x8d5a), LPC_WBG}, - { PCI_VDEVICE(INTEL, 0x8d5b), LPC_WBG}, - { PCI_VDEVICE(INTEL, 0x8d5c), LPC_WBG}, - { PCI_VDEVICE(INTEL, 0x8d5d), LPC_WBG}, - { PCI_VDEVICE(INTEL, 0x8d5e), LPC_WBG}, - { PCI_VDEVICE(INTEL, 0x8d5f), LPC_WBG}, - { PCI_VDEVICE(INTEL, 0x1f38), LPC_AVN}, - { PCI_VDEVICE(INTEL, 0x1f39), LPC_AVN}, - { PCI_VDEVICE(INTEL, 0x1f3a), LPC_AVN}, - { PCI_VDEVICE(INTEL, 0x1f3b), LPC_AVN}, - { PCI_VDEVICE(INTEL, 0x0f1c), LPC_BAYTRAIL}, - { PCI_VDEVICE(INTEL, 0x2390), LPC_COLETO}, - { PCI_VDEVICE(INTEL, 0x9cc1), LPC_WPT_LP}, - { PCI_VDEVICE(INTEL, 0x9cc2), LPC_WPT_LP}, - { PCI_VDEVICE(INTEL, 0x9cc3), LPC_WPT_LP}, - { PCI_VDEVICE(INTEL, 0x9cc5), LPC_WPT_LP}, - { PCI_VDEVICE(INTEL, 0x9cc6), LPC_WPT_LP}, - { PCI_VDEVICE(INTEL, 0x9cc7), LPC_WPT_LP}, - { PCI_VDEVICE(INTEL, 0x9cc9), LPC_WPT_LP}, - { 0, }, /* End of list */ -}; -MODULE_DEVICE_TABLE(pci, lpc_ich_ids); - -static void lpc_ich_restore_config_space(struct pci_dev *dev) -{ - struct lpc_ich_priv *priv = pci_get_drvdata(dev); - - if (priv->abase_save >= 0) { - pci_write_config_byte(dev, priv->abase, priv->abase_save); - priv->abase_save = -1; - } - - if (priv->actrl_pbase_save >= 0) { - pci_write_config_byte(dev, priv->actrl_pbase, - priv->actrl_pbase_save); - priv->actrl_pbase_save = -1; - } - - if (priv->gctrl_save >= 0) { - pci_write_config_byte(dev, priv->gctrl, priv->gctrl_save); - priv->gctrl_save = -1; - } -} - -static void lpc_ich_enable_acpi_space(struct pci_dev *dev) -{ - struct lpc_ich_priv *priv = pci_get_drvdata(dev); - u8 reg_save; - - switch (lpc_chipset_info[priv->chipset].iTCO_version) { - case 3: - /* - * Some chipsets (eg Avoton) enable the ACPI space in the - * ACPI BASE register. - */ - pci_read_config_byte(dev, priv->abase, ®_save); - pci_write_config_byte(dev, priv->abase, reg_save | 0x2); - priv->abase_save = reg_save; - break; - default: - /* - * Most chipsets enable the ACPI space in the ACPI control - * register. - */ - pci_read_config_byte(dev, priv->actrl_pbase, ®_save); - pci_write_config_byte(dev, priv->actrl_pbase, reg_save | 0x80); - priv->actrl_pbase_save = reg_save; - break; - } -} - -static void lpc_ich_enable_gpio_space(struct pci_dev *dev) -{ - struct lpc_ich_priv *priv = pci_get_drvdata(dev); - u8 reg_save; - - pci_read_config_byte(dev, priv->gctrl, ®_save); - pci_write_config_byte(dev, priv->gctrl, reg_save | 0x10); - priv->gctrl_save = reg_save; -} - -static void lpc_ich_enable_pmc_space(struct pci_dev *dev) -{ - struct lpc_ich_priv *priv = pci_get_drvdata(dev); - u8 reg_save; - - pci_read_config_byte(dev, priv->actrl_pbase, ®_save); - pci_write_config_byte(dev, priv->actrl_pbase, reg_save | 0x2); - - priv->actrl_pbase_save = reg_save; -} - -static void lpc_ich_finalize_cell(struct pci_dev *dev, struct mfd_cell *cell) -{ - struct lpc_ich_priv *priv = pci_get_drvdata(dev); - - cell->platform_data = &lpc_chipset_info[priv->chipset]; - cell->pdata_size = sizeof(struct lpc_ich_info); -} - -/* - * We don't check for resource conflict globally. There are 2 or 3 independent - * GPIO groups and it's enough to have access to one of these to instantiate - * the device. - */ -static int lpc_ich_check_conflict_gpio(struct resource *res) -{ - int ret; - u8 use_gpio = 0; - - if (resource_size(res) >= 0x50 && - !acpi_check_region(res->start + 0x40, 0x10, "LPC ICH GPIO3")) - use_gpio |= 1 << 2; - - if (!acpi_check_region(res->start + 0x30, 0x10, "LPC ICH GPIO2")) - use_gpio |= 1 << 1; - - ret = acpi_check_region(res->start + 0x00, 0x30, "LPC ICH GPIO1"); - if (!ret) - use_gpio |= 1 << 0; - - return use_gpio ? use_gpio : ret; -} - -static int lpc_ich_init_gpio(struct pci_dev *dev) -{ - struct lpc_ich_priv *priv = pci_get_drvdata(dev); - u32 base_addr_cfg; - u32 base_addr; - int ret; - bool acpi_conflict = false; - struct resource *res; - - /* Setup power management base register */ - pci_read_config_dword(dev, priv->abase, &base_addr_cfg); - base_addr = base_addr_cfg & 0x0000ff80; - if (!base_addr) { - dev_notice(&dev->dev, "I/O space for ACPI uninitialized\n"); - lpc_ich_cells[LPC_GPIO].num_resources--; - goto gpe0_done; - } - - res = &gpio_ich_res[ICH_RES_GPE0]; - res->start = base_addr + ACPIBASE_GPE_OFF; - res->end = base_addr + ACPIBASE_GPE_END; - ret = acpi_check_resource_conflict(res); - if (ret) { - /* - * This isn't fatal for the GPIO, but we have to make sure that - * the platform_device subsystem doesn't see this resource - * or it will register an invalid region. - */ - lpc_ich_cells[LPC_GPIO].num_resources--; - acpi_conflict = true; - } else { - lpc_ich_enable_acpi_space(dev); - } - -gpe0_done: - /* Setup GPIO base register */ - pci_read_config_dword(dev, priv->gbase, &base_addr_cfg); - base_addr = base_addr_cfg & 0x0000ff80; - if (!base_addr) { - dev_notice(&dev->dev, "I/O space for GPIO uninitialized\n"); - ret = -ENODEV; - goto gpio_done; - } - - /* Older devices provide fewer GPIO and have a smaller resource size. */ - res = &gpio_ich_res[ICH_RES_GPIO]; - res->start = base_addr; - switch (lpc_chipset_info[priv->chipset].gpio_version) { - case ICH_V5_GPIO: - case ICH_V10CORP_GPIO: - res->end = res->start + 128 - 1; - break; - default: - res->end = res->start + 64 - 1; - break; - } - - ret = lpc_ich_check_conflict_gpio(res); - if (ret < 0) { - /* this isn't necessarily fatal for the GPIO */ - acpi_conflict = true; - goto gpio_done; - } - lpc_chipset_info[priv->chipset].use_gpio = ret; - lpc_ich_enable_gpio_space(dev); - - lpc_ich_finalize_cell(dev, &lpc_ich_cells[LPC_GPIO]); - ret = mfd_add_devices(&dev->dev, -1, &lpc_ich_cells[LPC_GPIO], - 1, NULL, 0, NULL); - -gpio_done: - if (acpi_conflict) - pr_warn("Resource conflict(s) found affecting %s\n", - lpc_ich_cells[LPC_GPIO].name); - return ret; -} - -static int lpc_ich_init_wdt(struct pci_dev *dev) -{ - struct lpc_ich_priv *priv = pci_get_drvdata(dev); - u32 base_addr_cfg; - u32 base_addr; - int ret; - struct resource *res; - - /* Setup power management base register */ - pci_read_config_dword(dev, priv->abase, &base_addr_cfg); - base_addr = base_addr_cfg & 0x0000ff80; - if (!base_addr) { - dev_notice(&dev->dev, "I/O space for ACPI uninitialized\n"); - ret = -ENODEV; - goto wdt_done; - } - - res = wdt_io_res(ICH_RES_IO_TCO); - res->start = base_addr + ACPIBASE_TCO_OFF; - res->end = base_addr + ACPIBASE_TCO_END; - - res = wdt_io_res(ICH_RES_IO_SMI); - res->start = base_addr + ACPIBASE_SMI_OFF; - res->end = base_addr + ACPIBASE_SMI_END; - - lpc_ich_enable_acpi_space(dev); - - /* - * iTCO v2: - * Get the Memory-Mapped GCS register. To get access to it - * we have to read RCBA from PCI Config space 0xf0 and use - * it as base. GCS = RCBA + ICH6_GCS(0x3410). - * - * iTCO v3: - * Get the Power Management Configuration register. To get access - * to it we have to read the PMC BASE from config space and address - * the register at offset 0x8. - */ - if (lpc_chipset_info[priv->chipset].iTCO_version == 1) { - /* Don't register iomem for TCO ver 1 */ - lpc_ich_cells[LPC_WDT].num_resources--; - } else if (lpc_chipset_info[priv->chipset].iTCO_version == 2) { - pci_read_config_dword(dev, RCBABASE, &base_addr_cfg); - base_addr = base_addr_cfg & 0xffffc000; - if (!(base_addr_cfg & 1)) { - dev_notice(&dev->dev, "RCBA is disabled by " - "hardware/BIOS, device disabled\n"); - ret = -ENODEV; - goto wdt_done; - } - res = wdt_mem_res(ICH_RES_MEM_GCS_PMC); - res->start = base_addr + ACPIBASE_GCS_OFF; - res->end = base_addr + ACPIBASE_GCS_END; - } else if (lpc_chipset_info[priv->chipset].iTCO_version == 3) { - lpc_ich_enable_pmc_space(dev); - pci_read_config_dword(dev, ACPICTRL_PMCBASE, &base_addr_cfg); - base_addr = base_addr_cfg & 0xfffffe00; - - res = wdt_mem_res(ICH_RES_MEM_GCS_PMC); - res->start = base_addr + ACPIBASE_PMC_OFF; - res->end = base_addr + ACPIBASE_PMC_END; - } - - lpc_ich_finalize_cell(dev, &lpc_ich_cells[LPC_WDT]); - ret = mfd_add_devices(&dev->dev, -1, &lpc_ich_cells[LPC_WDT], - 1, NULL, 0, NULL); - -wdt_done: - return ret; -} - -static int lpc_ich_probe(struct pci_dev *dev, - const struct pci_device_id *id) -{ - struct lpc_ich_priv *priv; - int ret; - bool cell_added = false; - - priv = devm_kzalloc(&dev->dev, - sizeof(struct lpc_ich_priv), GFP_KERNEL); - if (!priv) - return -ENOMEM; - - priv->chipset = id->driver_data; - - priv->actrl_pbase_save = -1; - priv->abase_save = -1; - - priv->abase = ACPIBASE; - priv->actrl_pbase = ACPICTRL_PMCBASE; - - priv->gctrl_save = -1; - if (priv->chipset <= LPC_ICH5) { - priv->gbase = GPIOBASE_ICH0; - priv->gctrl = GPIOCTRL_ICH0; - } else { - priv->gbase = GPIOBASE_ICH6; - priv->gctrl = GPIOCTRL_ICH6; - } - - pci_set_drvdata(dev, priv); - - if (lpc_chipset_info[priv->chipset].iTCO_version) { - ret = lpc_ich_init_wdt(dev); - if (!ret) - cell_added = true; - } - - if (lpc_chipset_info[priv->chipset].gpio_version) { - ret = lpc_ich_init_gpio(dev); - if (!ret) - cell_added = true; - } - - /* - * We only care if at least one or none of the cells registered - * successfully. - */ - if (!cell_added) { - dev_warn(&dev->dev, "No MFD cells added\n"); - lpc_ich_restore_config_space(dev); - return -ENODEV; - } - - return 0; -} - -static void lpc_ich_remove(struct pci_dev *dev) -{ - mfd_remove_devices(&dev->dev); - lpc_ich_restore_config_space(dev); -} - -static struct pci_driver lpc_ich_driver = { - .name = "lpc_ich", - .id_table = lpc_ich_ids, - .probe = lpc_ich_probe, - .remove = lpc_ich_remove, -}; - -module_pci_driver(lpc_ich_driver); - -MODULE_AUTHOR("Aaron Sierra "); -MODULE_DESCRIPTION("LPC interface for Intel ICH"); -MODULE_LICENSE("GPL"); diff --git a/packages/platforms/inventec/x86-64/d6356/modules/builds/src/onie_tlvinfo.c b/packages/platforms/inventec/x86-64/d6356/modules/builds/src/onie_tlvinfo.c deleted file mode 100644 index aaa3d5070..000000000 --- a/packages/platforms/inventec/x86-64/d6356/modules/builds/src/onie_tlvinfo.c +++ /dev/null @@ -1,815 +0,0 @@ -#include -#include -#include -#include -//#include -#include - -//#include -//#include -#include "onie_tlvinfo.h" - -/* Set to 1 if we've read EEPROM into memory */ -static int has_been_read = 0; - -int read_sys_eeprom(struct i2c_client *pi2c_client,void *eeprom_data, int offset, int len); -int write_sys_eeprom(struct i2c_client *pi2c_client, void *eeprom_data, int len); - -static inline int is_multicast_ether_addr(const u_int8_t *addr) -{ - return 0x01 & addr[0]; -} - -static inline int is_zero_ether_addr(const u_int8_t *addr) -{ - return !(addr[0] | addr[1] | addr[2] | addr[3] | addr[4] | addr[5]); -} - -static inline int is_valid_ether_addr(const u_int8_t *addr) -{ - return !is_multicast_ether_addr(addr) && !is_zero_ether_addr(addr); -} - -#if 0 -static unsigned int crc32(unsigned char const *p, unsigned int len) -{ - int i; - unsigned int crc = 0; - while (len--) { - crc ^= *p++; - for (i = 0; i < 8; i++) - crc = (crc >> 1) ^ ((crc & 1) ? 0xedb88320 : 0); - } - return crc; -} -#else -static unsigned long crc32_tab[] = { - 0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f, - 0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988, - 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91, 0x1db71064, 0x6ab020f2, - 0xf3b97148, 0x84be41de, 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7, - 0x136c9856, 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, 0x14015c4f, 0x63066cd9, - 0xfa0f3d63, 0x8d080df5, 0x3b6e20c8, 0x4c69105e, 0xd56041e4, 0xa2677172, - 0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b, 0x35b5a8fa, 0x42b2986c, - 0xdbbbc9d6, 0xacbcf940, 0x32d86ce3, 0x45df5c75, 0xdcd60dcf, 0xabd13d59, - 0x26d930ac, 0x51de003a, 0xc8d75180, 0xbfd06116, 0x21b4f4b5, 0x56b3c423, - 0xcfba9599, 0xb8bda50f, 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924, - 0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d, 0x76dc4190, 0x01db7106, - 0x98d220bc, 0xefd5102a, 0x71b18589, 0x06b6b51f, 0x9fbfe4a5, 0xe8b8d433, - 0x7807c9a2, 0x0f00f934, 0x9609a88e, 0xe10e9818, 0x7f6a0dbb, 0x086d3d2d, - 0x91646c97, 0xe6635c01, 0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e, - 0x6c0695ed, 0x1b01a57b, 0x8208f4c1, 0xf50fc457, 0x65b0d9c6, 0x12b7e950, - 0x8bbeb8ea, 0xfcb9887c, 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, 0xfbd44c65, - 0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2, 0x4adfa541, 0x3dd895d7, - 0xa4d1c46d, 0xd3d6f4fb, 0x4369e96a, 0x346ed9fc, 0xad678846, 0xda60b8d0, - 0x44042d73, 0x33031de5, 0xaa0a4c5f, 0xdd0d7cc9, 0x5005713c, 0x270241aa, - 0xbe0b1010, 0xc90c2086, 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f, - 0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, 0x59b33d17, 0x2eb40d81, - 0xb7bd5c3b, 0xc0ba6cad, 0xedb88320, 0x9abfb3b6, 0x03b6e20c, 0x74b1d29a, - 0xead54739, 0x9dd277af, 0x04db2615, 0x73dc1683, 0xe3630b12, 0x94643b84, - 0x0d6d6a3e, 0x7a6a5aa8, 0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1, - 0xf00f9344, 0x8708a3d2, 0x1e01f268, 0x6906c2fe, 0xf762575d, 0x806567cb, - 0x196c3671, 0x6e6b06e7, 0xfed41b76, 0x89d32be0, 0x10da7a5a, 0x67dd4acc, - 0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5, 0xd6d6a3e8, 0xa1d1937e, - 0x38d8c2c4, 0x4fdff252, 0xd1bb67f1, 0xa6bc5767, 0x3fb506dd, 0x48b2364b, - 0xd80d2bda, 0xaf0a1b4c, 0x36034af6, 0x41047a60, 0xdf60efc3, 0xa867df55, - 0x316e8eef, 0x4669be79, 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236, - 0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f, 0xc5ba3bbe, 0xb2bd0b28, - 0x2bb45a92, 0x5cb36a04, 0xc2d7ffa7, 0xb5d0cf31, 0x2cd99e8b, 0x5bdeae1d, - 0x9b64c2b0, 0xec63f226, 0x756aa39c, 0x026d930a, 0x9c0906a9, 0xeb0e363f, - 0x72076785, 0x05005713, 0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38, - 0x92d28e9b, 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21, 0x86d3d2d4, 0xf1d4e242, - 0x68ddb3f8, 0x1fda836e, 0x81be16cd, 0xf6b9265b, 0x6fb077e1, 0x18b74777, - 0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c, 0x8f659eff, 0xf862ae69, - 0x616bffd3, 0x166ccf45, 0xa00ae278, 0xd70dd2ee, 0x4e048354, 0x3903b3c2, - 0xa7672661, 0xd06016f7, 0x4969474d, 0x3e6e77db, 0xaed16a4a, 0xd9d65adc, - 0x40df0b66, 0x37d83bf0, 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9, - 0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605, 0xcdd70693, - 0x54de5729, 0x23d967bf, 0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94, - 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d -}; - -static unsigned long crc32(unsigned char const *buf, unsigned int size) -{ - unsigned char *p = (unsigned char*)buf; - unsigned long crc = 0; - - crc = crc ^ ~0U; - - while (size--) - crc = crc32_tab[(crc ^ *p++) & 0xFF] ^ (crc >> 8); - - return crc ^ ~0U; -} -#endif - -static int set_bytes(char *buf, const char *string, int * converted_accum) -{ - char *p = (char *) string; - int i; - uint byte; - - if (!p) { - printk("ERROR: NULL string passed in.\n"); - return -1; - } - /* Convert string to bytes */ - for (i = 0, p = (char *)string; (i < TLV_VALUE_MAX_LEN) && (*p != 0); - i++) { - while ((*p == ' ') || (*p == '\t') || (*p == ',') || - (*p == ';')) { - p++; - } - if (*p != 0) { - if (!isdigit(*p)) { - printk("ERROR: Non-digit found in byte string: (%s)\n", string); - return -1; - } - byte = strtoul(p, &p, 0); - if (byte >= 256) { - printk("ERROR: The value specified is greater than 255: (%u) " \ - "in string: %s\n", byte, string); - return -1; - } - buf[i] = byte & 0xFF; - } - } - if ((i == TLV_VALUE_MAX_LEN) && (*p != 0)) { - printk("ERROR: Trying to assign too many bytes " - "(max: %d) in string: %s\n", TLV_VALUE_MAX_LEN, string); - return -1; - } - *converted_accum = i; - return 0; -} - -/* - * set_date - * - * Validates the format of the data string - * - * This function takes a pointer to a date string (i.e. MM/DD/YYYY hh:mm:ss) - * and validates that the format is correct. If so the string is copied - * to the supplied buffer. - */ -static int set_date(char *buf, const char *string) -{ - int i; - - if (!string) { - printk("ERROR: NULL date string passed in.\n"); - return -1; - } - if (strlen(string) != 19) { - printk("ERROR: Date strlen() != 19 -- %zd\n", strlen(string)); - printk("ERROR: Bad date format (MM/DD/YYYY hh:mm:ss): %s\n", string); - return -1; - } - for (i = 0; string[i] != 0; i++) { - switch (i) { - case 2: - case 5: - if (string[i] != '/') { - printk("ERROR: Bad date format (MM/DD/YYYY hh:mm:ss): %s\n", - string); - return -1; - } - break; - case 10: - if (string[i] != ' ') { - printk("ERROR: Bad date format (MM/DD/YYYY hh:mm:ss): %s\n", - string); - return -1; - } - break; - case 13: - case 16: - if (string[i] != ':') { - printk("ERROR: Bad date format (MM/DD/YYYY hh:mm:ss): %s\n", - string); - return -1; - } - break; - default: - if (!isdigit(string[i])) { - printk("ERROR: Bad date format (MM/DD/YYYY hh:mm:ss): %s\n", - string); - return -1; - } - break; - } - } - strcpy(buf, string); - return 0; -} - -/* - * is_valid_tlv - * - * Perform basic sanity checks on a TLV field. The TLV is pointed to - * by the parameter provided. - * 1. The type code is not reserved (0x00 or 0xFF) - */ -static inline bool is_valid_tlv(tlvinfo_tlv_t *tlv) -{ - return((tlv->type != 0x00) && (tlv->type != 0xFF)); -} - -/* - * set_mac - * - * Converts a string MAC address into a binary buffer. - * - * This function takes a pointer to a MAC address string - * (i.e."XX:XX:XX:XX:XX:XX", where "XX" is a two-digit hex number). - * The string format is verified and then converted to binary and - * stored in a buffer. - */ -static int set_mac(char *buf, const char *string) -{ - char *p = (char *) string; - int i; - int err = 0; - char *end; - - if (!p) { - printk("ERROR: NULL mac addr string passed in.\n"); - return -1; - } - if (strlen(p) != 17) { - printk("ERROR: MAC address strlen() != 17 -- %zd\n", strlen(p)); - printk("ERROR: Bad MAC address format: %s\n", string); - return -1; - } - for (i = 0; i < 17; i++) { - if ((i % 3) == 2) { - if (p[i] != ':') { - err++; - printk("ERROR: mac: p[%i] != :, found: `%c'\n", - i, p[i]); - break; - } - continue; - } else if (!isxdigit(p[i])) { - err++; - printk("ERROR: mac: p[%i] != hex digit, found: `%c'\n", - i, p[i]); - break; - } - } - if (err != 0) { - printk("ERROR: Bad MAC address format: %s\n", string); - return -1; - } - /* Convert string to binary */ - for (i = 0, p = (char *)string; i < 6; i++) { - buf[i] = p ? strtoul(p, &end, 16) : 0; - if (p) { - p = (*end) ? end + 1 : end; - } - } - if (!is_valid_ether_addr((char *)buf)) { - printk("ERROR: MAC address must not be 00:00:00:00:00:00, " - "a multicast address or FF:FF:FF:FF:FF:FF.\n"); - printk("ERROR: Bad MAC address format: %s\n", string); - return -1; - } - return 0; -} - -/* - * is_valid_tlvinfo_header - * - * Perform sanity checks on the first 11 bytes of the TlvInfo EEPROM - * data pointed to by the parameter: - * 1. First 8 bytes contain null-terminated ASCII string "TlvInfo" - * 2. Version byte is 1 - * 3. Total length bytes contain value which is less than or equal - * to the allowed maximum (2048-11) - * - */ -static inline bool is_valid_tlvinfo_header(tlvinfo_header_t *hdr) -{ - int max_size = TLV_TOTAL_LEN_MAX; - return((strcmp(hdr->signature, TLV_INFO_ID_STRING) == 0) && - (hdr->version == TLV_INFO_VERSION) && - (be16_to_cpu(hdr->totallen) <= max_size) ); -} - -/* - * decode_tlv_value - * - * Decode a single TLV value into a string. - - * The validity of EEPROM contents and the TLV field have been verified - * prior to calling this function. - */ -#define DECODE_NAME_MAX 20 - -static void decode_tlv_value(tlvinfo_tlv_t * tlv, char* value) -{ - int i; - - switch (tlv->type) { - case TLV_CODE_PRODUCT_NAME: - case TLV_CODE_PART_NUMBER: - case TLV_CODE_SERIAL_NUMBER: - case TLV_CODE_MANUF_DATE: - case TLV_CODE_LABEL_REVISION: - case TLV_CODE_PLATFORM_NAME: - case TLV_CODE_ONIE_VERSION: - case TLV_CODE_MANUF_NAME: - case TLV_CODE_MANUF_COUNTRY: - case TLV_CODE_VENDOR_NAME: - case TLV_CODE_DIAG_VERSION: - case TLV_CODE_SERVICE_TAG: - memcpy(value, tlv->value, tlv->length); - value[tlv->length] = 0; - break; - case TLV_CODE_MAC_BASE: - snprintf(value, MAX_STRING_SIZE, "%02X:%02X:%02X:%02X:%02X:%02X", - tlv->value[0], tlv->value[1], tlv->value[2], - tlv->value[3], tlv->value[4], tlv->value[5]); - break; - case TLV_CODE_DEVICE_VERSION: - snprintf(value, MAX_STRING_SIZE, "%u", tlv->value[0]); - break; - case TLV_CODE_MAC_SIZE: - snprintf(value, MAX_STRING_SIZE, "%u", (tlv->value[0] << 8) | tlv->value[1]); - break; - case TLV_CODE_VENDOR_EXT: - value[0] = 0; - for (i = 0; (i < (TLV_DECODE_VALUE_MAX_LEN/5)) && (i < tlv->length); - i++) { - snprintf(value, MAX_STRING_SIZE, "%s 0x%02X", value, tlv->value[i]); - } - break; - case TLV_CODE_CRC_32: - snprintf(value, MAX_STRING_SIZE, "0x%02X%02X%02X%02X", - tlv->value[0], tlv->value[1], tlv->value[2], - tlv->value[3]); - break; - default: - value[0] = 0; - for (i = 0; (i < (TLV_DECODE_VALUE_MAX_LEN/5)) && (i < tlv->length); - i++) { - snprintf(value, MAX_STRING_SIZE, "%s 0x%02X", value, tlv->value[i]); - } - break; - } - -} - -/* - * is_checksum_valid - * - * Validate the checksum in the provided TlvInfo EEPROM data. First, - * verify that the TlvInfo header is valid, then make sure the last - * TLV is a CRC-32 TLV. Then calculate the CRC over the EEPROM data - * and compare it to the value stored in the EEPROM CRC-32 TLV. - */ -static bool is_checksum_valid(u_int8_t *eeprom) -{ - tlvinfo_header_t * eeprom_hdr = (tlvinfo_header_t *) eeprom; - tlvinfo_tlv_t * eeprom_crc; - unsigned int calc_crc; - unsigned int stored_crc; - - // Is the eeprom header valid? - if (!is_valid_tlvinfo_header(eeprom_hdr)) { - return(FALSE); - } - - // Is the last TLV a CRC? - eeprom_crc = (tlvinfo_tlv_t *) &eeprom[sizeof(tlvinfo_header_t) + - be16_to_cpu(eeprom_hdr->totallen) - - (sizeof(tlvinfo_tlv_t) + 4)]; - if ((eeprom_crc->type != TLV_CODE_CRC_32) || (eeprom_crc->length != 4)) { - return(FALSE); - } - - // Calculate the checksum - calc_crc = crc32((void *)eeprom, sizeof(tlvinfo_header_t) + - be16_to_cpu(eeprom_hdr->totallen) - 4); - stored_crc = ((eeprom_crc->value[0] << 24) | (eeprom_crc->value[1] << 16) | - (eeprom_crc->value[2] << 8) | eeprom_crc->value[3]); - - //printk(KERN_ERR "[SWPS] cal_crc =0x%x, stored_crc =0x%x\n", calc_crc, stored_crc); - //return(calc_crc == stored_crc); - return 1; -} - -/* - * update_crc - * - * This function updates the CRC-32 TLV. If there is no CRC-32 TLV, then - * one is added. This function should be called after each update to the - * EEPROM structure, to make sure the CRC is always correct. - */ -static void update_crc(u_int8_t *eeprom) -{ - tlvinfo_header_t * eeprom_hdr = (tlvinfo_header_t *) eeprom; - tlvinfo_tlv_t * eeprom_crc; - unsigned int calc_crc; - - // Is the eeprom header valid? - if (!is_valid_tlvinfo_header(eeprom_hdr)) { - return; - } - // Is the last TLV a CRC? - eeprom_crc = (tlvinfo_tlv_t *) &eeprom[sizeof(tlvinfo_header_t) + - be16_to_cpu(eeprom_hdr->totallen) - - (sizeof(tlvinfo_tlv_t) + 4)]; - if (eeprom_crc->type != TLV_CODE_CRC_32) { - if ((be16_to_cpu(eeprom_hdr->totallen) + sizeof(tlvinfo_tlv_t) + 4) > - TLV_TOTAL_LEN_MAX) { - return; - } - eeprom_crc = (tlvinfo_tlv_t *) &eeprom[sizeof(tlvinfo_header_t) + - be16_to_cpu( - eeprom_hdr->totallen)]; - eeprom_hdr->totallen = cpu_to_be16(be16_to_cpu(eeprom_hdr->totallen) + - sizeof(tlvinfo_tlv_t) + 4); - eeprom_crc->type = TLV_CODE_CRC_32; - } - eeprom_crc->length = 4; - - // Calculate the checksum - calc_crc = crc32((void *)eeprom, - sizeof(tlvinfo_header_t) + - be16_to_cpu(eeprom_hdr->totallen) - 4); - - eeprom_crc->value[0] = (calc_crc >> 24) & 0xFF; - eeprom_crc->value[1] = (calc_crc >> 16) & 0xFF; - eeprom_crc->value[2] = (calc_crc >> 8) & 0xFF; - eeprom_crc->value[3] = (calc_crc >> 0) & 0xFF; -} - -/* - * show_eeprom - * - * Display the contents of the EEPROM - */ - -/* - * read_eeprom - * - * Read the EEPROM into memory, if it hasn't already been read. - */ -int read_eeprom( struct i2c_client *pi2c_client, u_int8_t *eeprom) -{ - int ret; - tlvinfo_header_t *eeprom_hdr = (tlvinfo_header_t *) eeprom; - tlvinfo_tlv_t *eeprom_tlv = (tlvinfo_tlv_t *)&eeprom[ - sizeof(tlvinfo_header_t)]; - - if (has_been_read) - return 0; - - /* Read the header */ - ret = read_sys_eeprom( pi2c_client,(void *)eeprom_hdr, 0, sizeof(tlvinfo_header_t)); - /* If the header was successfully read, read the TLVs */ - if ((ret == 0) && is_valid_tlvinfo_header(eeprom_hdr)) { - ret = read_sys_eeprom( pi2c_client, (void *)eeprom_tlv, sizeof(tlvinfo_header_t), - be16_to_cpu(eeprom_hdr->totallen)); - } - // If the contents are invalid, start over with default contents - if(!is_valid_tlvinfo_header(eeprom_hdr)) - printk(KERN_ERR - "Notice: Invalid TLV header found. Using default contents--1.\n"); - if(!is_checksum_valid(eeprom)) - printk(KERN_ERR - "Notice: Invalid TLV checksum found. Using default contents--2.\n"); - if ( !is_valid_tlvinfo_header(eeprom_hdr) || !is_checksum_valid(eeprom) ){ - strcpy(eeprom_hdr->signature, TLV_INFO_ID_STRING); - eeprom_hdr->version = TLV_INFO_VERSION; - eeprom_hdr->totallen = cpu_to_be16(0); - update_crc(eeprom); - } - has_been_read = 1; - - return ret; -} - -/* - * prog_eeprom - * Write the EEPROM data from CPU memory to the hardware. - */ -int prog_eeprom(struct i2c_client *pi2c_client, u_int8_t * eeprom) -{ - int ret = 0; - tlvinfo_header_t * eeprom_hdr = (tlvinfo_header_t *) eeprom; - int eeprom_len; - - eeprom_len = sizeof(tlvinfo_header_t) + be16_to_cpu(eeprom_hdr->totallen); - ret = write_sys_eeprom( pi2c_client, eeprom, eeprom_len); - if (ret) { - printk("Programming failed.\n"); - return -1; - } - has_been_read = 0; - return 0; -} - -/* - * tlvinfo_find_tlv - * - * This function finds the TLV with the supplied code in the EERPOM. - * An offset from the beginning of the EEPROM is returned in the - * eeprom_index parameter if the TLV is found. - */ -bool tlvinfo_find_tlv(u_int8_t *eeprom, u_int8_t tcode, - int *eeprom_index) -{ - tlvinfo_header_t * eeprom_hdr = (tlvinfo_header_t *) eeprom; - tlvinfo_tlv_t * eeprom_tlv; - int eeprom_end; - - // Make sure the EEPROM contents are valid - if (!is_valid_tlvinfo_header(eeprom_hdr) || !is_checksum_valid(eeprom)) { - return(FALSE); - } - // Search through the TLVs, looking for the first one which matches the - // supplied type code. - *eeprom_index = sizeof(tlvinfo_header_t); - eeprom_end = sizeof(tlvinfo_header_t) + be16_to_cpu(eeprom_hdr->totallen); - - while (*eeprom_index < eeprom_end) { - eeprom_tlv = (tlvinfo_tlv_t *) &eeprom[*eeprom_index]; - if (!is_valid_tlv(eeprom_tlv)) { - return(FALSE); - } - if (eeprom_tlv->type == tcode) { - return(TRUE); - } - *eeprom_index += sizeof(tlvinfo_tlv_t) + eeprom_tlv->length; - } - return(FALSE); -} - -/* - * tlvinfo_decode_tlv - * - * This function finds the TLV with the supplied code in the EERPOM - * and decodes the value into the buffer provided. - */ -bool tlvinfo_decode_tlv(u_int8_t *eeprom, u_int8_t tcode, char* value) -{ - int eeprom_index; - tlvinfo_tlv_t * eeprom_tlv; - - // Find the TLV and then decode it - - if (tlvinfo_find_tlv(eeprom, tcode, &eeprom_index)) { - eeprom_tlv = (tlvinfo_tlv_t *) &eeprom[eeprom_index]; - decode_tlv_value(eeprom_tlv, value); - return TRUE; - } - - return FALSE; -} - -/* - * tlvinfo_delete_tlv - * - * This function deletes the TLV with the specified type code from the - * EEPROM. - */ -bool tlvinfo_delete_tlv(u_int8_t * eeprom, u_int8_t code) -{ - int eeprom_index; - int tlength; - tlvinfo_header_t * eeprom_hdr = (tlvinfo_header_t *) eeprom; - tlvinfo_tlv_t * eeprom_tlv; - - // Find the TLV and then move all following TLVs "forward" - if (tlvinfo_find_tlv(eeprom, code, &eeprom_index)) { - eeprom_tlv = (tlvinfo_tlv_t *) &eeprom[eeprom_index]; - tlength = sizeof(tlvinfo_tlv_t) + eeprom_tlv->length; - memcpy(&eeprom[eeprom_index], &eeprom[eeprom_index+tlength], - sizeof(tlvinfo_header_t) + be16_to_cpu(eeprom_hdr->totallen) - - eeprom_index - tlength); - eeprom_hdr->totallen = cpu_to_be16(be16_to_cpu(eeprom_hdr->totallen) - - tlength); - update_crc(eeprom); - return(TRUE); - } - return(FALSE); -} - -/* - * tlvinfo_add_tlv - * - * This function adds a TLV to the EEPROM, converting the value (a string) to - * the format in which it will be stored in the EEPROM. - */ -#define MAX_TLV_VALUE_LEN 256 -bool tlvinfo_add_tlv(u_int8_t * eeprom, int tcode, const char *strval) -{ - tlvinfo_header_t * eeprom_hdr = (tlvinfo_header_t *) eeprom; - tlvinfo_tlv_t * eeprom_tlv; - int new_tlv_len = 0; - u_int32_t value; - char data[MAX_TLV_VALUE_LEN]; - int eeprom_index; - int max_size = TLV_TOTAL_LEN_MAX; - - // Encode each TLV type into the format to be stored in the EERPOM - switch (tcode) { - case TLV_CODE_PRODUCT_NAME: - case TLV_CODE_PART_NUMBER: - case TLV_CODE_SERIAL_NUMBER: - case TLV_CODE_LABEL_REVISION: - case TLV_CODE_PLATFORM_NAME: - case TLV_CODE_ONIE_VERSION: - case TLV_CODE_MANUF_NAME: - case TLV_CODE_MANUF_COUNTRY: - case TLV_CODE_VENDOR_NAME: - case TLV_CODE_DIAG_VERSION: - case TLV_CODE_SERVICE_TAG: - strncpy(data, strval, MAX_TLV_VALUE_LEN); - - if( strlen(strval) >= MAX_TLV_VALUE_LEN ) - new_tlv_len = MAX_TLV_VALUE_LEN; - else - new_tlv_len = strlen(strval); - - break; - case TLV_CODE_DEVICE_VERSION: - value = strtoul(strval, NULL, 0); - if (value >= 256) { - printk("ERROR: Device version must be 255 or less. Value " \ - "supplied: %u", value); - return(FALSE); - } - data[0] = value & 0xFF; - new_tlv_len = 1; - break; - case TLV_CODE_MAC_SIZE: - value = strtoul(strval, NULL, 0); - if (value >= 65536) { - printk("ERROR: MAC Size must be 65535 or less. Value " \ - "supplied: %u", value); - return(FALSE); - } - data[0] = (value >> 8) & 0xFF; - data[1] = value & 0xFF; - new_tlv_len = 2; - break; - case TLV_CODE_MANUF_DATE: - if (set_date(data, strval) != 0) { - return(FALSE); - } - new_tlv_len = 19; - break; - case TLV_CODE_MAC_BASE: - if (set_mac(data, strval) != 0) { - return(FALSE); - } - new_tlv_len = 6; - break; - case TLV_CODE_CRC_32: - printk("WARNING: The CRC TLV is set automatically and cannot be set " \ - "manually.\n"); - return(FALSE); - case TLV_CODE_VENDOR_EXT: - default: - if (set_bytes(data, strval, &new_tlv_len) != 0 ) { - return(FALSE); - } - break; - } - - // Is there room for this TLV? - if ((be16_to_cpu(eeprom_hdr->totallen) + sizeof(tlvinfo_tlv_t) + - new_tlv_len) > max_size) { - printk("ERROR: There is not enough room in the EERPOM to save data.\n"); - return(FALSE); - } - - // Add TLV at the end, overwriting CRC TLV if it exists - if (tlvinfo_find_tlv(eeprom, TLV_CODE_CRC_32, &eeprom_index)) { - eeprom_hdr->totallen = cpu_to_be16(be16_to_cpu(eeprom_hdr->totallen) - - sizeof(tlvinfo_tlv_t) - 4); - } else { - eeprom_index = sizeof(tlvinfo_header_t) + - be16_to_cpu(eeprom_hdr->totallen); - } - eeprom_tlv = (tlvinfo_tlv_t *) &eeprom[eeprom_index]; - eeprom_tlv->type = tcode; - eeprom_tlv->length = new_tlv_len; - memcpy(eeprom_tlv->value, data, new_tlv_len); - - // Update the total length and calculate (add) a new CRC-32 TLV - eeprom_hdr->totallen = cpu_to_be16(be16_to_cpu(eeprom_hdr->totallen) + - sizeof(tlvinfo_tlv_t) + new_tlv_len); - update_crc(eeprom); - - return(TRUE); -} - -/* - * read_sys_eeprom - read the hwinfo from i2c EEPROM - */ -int read_sys_eeprom(struct i2c_client *pi2c_client,void *eeprom_data, int offset, int len) -{ - int iRet = 0; - int i = 0; - unsigned char ucBuf[2]; - u_int8_t *c; - unsigned short usAddr = SYS_EEPROM_OFFSET + offset; - - c = eeprom_data; - for (i = 0; i < len; i++) { - ucBuf[0] = (usAddr & 0xFF00) >> 8; - ucBuf[1] = (usAddr & 0x00FF); - - iRet = i2c_smbus_write_byte_data(pi2c_client, ucBuf[0], ucBuf[1]); - if( iRet < 0 ){ - printk(KERN_ERR"Error!! VPD data read error\n"); - return -1; - } - - *c = i2c_smbus_read_byte(pi2c_client); - c++; usAddr++; - } - return 0; -} - -/* - * write_sys_eeprom - write the hwinfo to i2c EEPROM - */ -int write_sys_eeprom(struct i2c_client *pi2c_client, void *eeprom_data, int len) -{ - int iRet = 0; - int i = 0; - u_int8_t *c; - unsigned short usAddr = SYS_EEPROM_OFFSET; - unsigned char ucBuf[3]; - - c = eeprom_data; - for (i = 0; i < len; i++) { - ucBuf[ 0 ] = (usAddr & 0xFF00) >>8 ; - ucBuf[ 1 ] = (usAddr & 0x00FF); - ucBuf[ 2 ] = *c; - - iRet = i2c_smbus_write_word_data( pi2c_client, ucBuf[0], (ucBuf[2] << 8 | ucBuf[1])); - if (iRet < 0 ){ - printk(KERN_ERR"Error!! VPD data write error . \n"); - return -1; - } - - c++; usAddr++; - msleep_interruptible(10); - } - - return 0; -} - -void update_eeprom_header(u_int8_t *eeprom) -{ - tlvinfo_header_t * eeprom_hdr = (tlvinfo_header_t *) eeprom; - - strcpy(eeprom_hdr->signature, TLV_INFO_ID_STRING); - eeprom_hdr->version = TLV_INFO_VERSION; - eeprom_hdr->totallen = cpu_to_be16(0); - update_crc(eeprom); -} -#if 0 -int find_vpd_data(u_int8_t *eeprom, int i_offset, char *c_buf) -{ - int tlv_end; - int curr_tlv; - tlvinfo_header_t * eeprom_hdr = (tlvinfo_header_t *) eeprom; - tlvinfo_tlv_t * eeprom_tlv; - int iFind = 0; - - if( !is_valid_tlvinfo_header(eeprom_hdr) ) { - printk(KERN_ERR"EEPROM does not contain data in a valid TlvInfo format.\n"); - return -1; - } - - curr_tlv = sizeof(tlvinfo_header_t); - tlv_end = sizeof(tlvinfo_header_t) + be16_to_cpu(eeprom_hdr->totallen); - while(curr_tlv < tlv_end){ - eeprom_tlv = (tlvinfo_tlv_t *) &eeprom[curr_tlv]; - if (!is_valid_tlv(eeprom_tlv)) { - printk(KERN_ERR"Invalid TLV field starting at EEPROM offset %d\n", - curr_tlv); - return -1; - } - - decode_tlv_value(eeprom_tlv, c_buf); - if( eeprom_tlv->type == i_offset){ - iFind = 1; - break; - } - curr_tlv += sizeof(tlvinfo_tlv_t) + eeprom_tlv->length; - } - - if( iFind == 0 ) - return -1; - else - return 0; -} -#endif diff --git a/packages/platforms/inventec/x86-64/d6356/modules/builds/src/onie_tlvinfo.h b/packages/platforms/inventec/x86-64/d6356/modules/builds/src/onie_tlvinfo.h deleted file mode 100644 index da0a07590..000000000 --- a/packages/platforms/inventec/x86-64/d6356/modules/builds/src/onie_tlvinfo.h +++ /dev/null @@ -1,150 +0,0 @@ -/* - * The Definition of the TlvInfo EEPROM format can be found at onie.org or - * github.com/onie - */ -#include -#define strtoul simple_strtoul - -#define FALSE 0 -#define TRUE (!FALSE) -#define MAX_STRING_SIZE 128 -/* - * Tlvinf header: Layout of the header for the TlvInfo format - * - * See the end of this file for details of this eeprom format - */ -struct __attribute__ ((__packed__)) tlvinfo_header_s { - char signature[8]; /* 0x00 - 0x07 EEPROM Tag "TlvInfo" */ - u_int8_t version; /* 0x08 Structure version */ - u_int16_t totallen; /* 0x09 - 0x0A Length of all data which follows */ -}; -typedef struct tlvinfo_header_s tlvinfo_header_t; - -// Header Field Constants -#define TLV_INFO_ID_STRING "TlvInfo" -#define TLV_INFO_VERSION 0x01 -#define TLV_TOTAL_LEN_MAX (SYS_EEPROM_SIZE - sizeof(tlvinfo_header_t)) - -/* - * TlvInfo TLV: Layout of a TLV field - */ -struct __attribute__ ((__packed__)) tlvinfo_tlv_s { - u_int8_t type; - u_int8_t length; - u_int8_t value[0]; -}; -typedef struct tlvinfo_tlv_s tlvinfo_tlv_t; - -/* Maximum length of a TLV value in bytes */ -#define TLV_VALUE_MAX_LEN 255 - -/** - * The TLV Types. - * - * Keep these in sync with tlv_code_list in cmd_sys_eeprom.c - */ -#define TLV_CODE_PRODUCT_NAME 0x21 -#define TLV_CODE_PART_NUMBER 0x22 -#define TLV_CODE_SERIAL_NUMBER 0x23 -#define TLV_CODE_MAC_BASE 0x24 -#define TLV_CODE_MANUF_DATE 0x25 -#define TLV_CODE_DEVICE_VERSION 0x26 -#define TLV_CODE_LABEL_REVISION 0x27 -#define TLV_CODE_PLATFORM_NAME 0x28 -#define TLV_CODE_ONIE_VERSION 0x29 -#define TLV_CODE_MAC_SIZE 0x2A -#define TLV_CODE_MANUF_NAME 0x2B -#define TLV_CODE_MANUF_COUNTRY 0x2C -#define TLV_CODE_VENDOR_NAME 0x2D -#define TLV_CODE_DIAG_VERSION 0x2E -#define TLV_CODE_SERVICE_TAG 0x2F -#define TLV_CODE_VENDOR_EXT 0xFD -#define TLV_CODE_CRC_32 0xFE - -/* - * Struct for displaying the TLV codes and names. - */ -struct tlv_code_desc { - u_int8_t m_code; - char* m_name; -}; - -/* - * List of TLV codes and names. - */ -static const struct tlv_code_desc tlv_code_list[] = { - { TLV_CODE_PRODUCT_NAME , "Product Name"}, - { TLV_CODE_PART_NUMBER , "Part Number"}, - { TLV_CODE_SERIAL_NUMBER , "Serial Number"}, - { TLV_CODE_MAC_BASE , "Base MAC Address"}, - { TLV_CODE_MANUF_DATE , "Manufacture Date"}, - { TLV_CODE_DEVICE_VERSION , "Device Version"}, - { TLV_CODE_LABEL_REVISION , "Label Revision"}, - { TLV_CODE_PLATFORM_NAME , "Platform Name"}, - { TLV_CODE_ONIE_VERSION , "Loader Version"}, - { TLV_CODE_MAC_SIZE , "MAC Addresses"}, - { TLV_CODE_MANUF_NAME , "Manufacturer"}, - { TLV_CODE_MANUF_COUNTRY , "Country Code"}, - { TLV_CODE_VENDOR_NAME , "Vendor Name"}, - { TLV_CODE_DIAG_VERSION , "Diag Version"}, - { TLV_CODE_SERVICE_TAG , "Service Tag"}, - { TLV_CODE_VENDOR_EXT , "Vendor Extension"}, - { TLV_CODE_CRC_32 , "CRC-32"}, -}; - -static inline const char* tlv_type2name(u_int8_t type) -{ - char* name = "Unknown"; - int i; - - for (i = 0; i < sizeof(tlv_code_list)/sizeof(tlv_code_list[0]); i++) { - if (tlv_code_list[i].m_code == type) { - name = tlv_code_list[i].m_name; - break; - } - } - return name; -} - -/* - * The max decode value is currently for the 'raw' type or the 'vendor - * extension' type, both of which have the same decode format. The - * max decode string size is computed as follows: - * - * strlen(" 0xFF") * TLV_VALUE_MAX_LEN + 1 - * - */ -#define TLV_DECODE_VALUE_MAX_LEN ((5 * TLV_VALUE_MAX_LEN) + 1) - - -/* - * Each platform must define the following platform-specific macros - * in sys_eeprom_platform.h: - * SYS_EEPROM_SIZE: size of usable eeprom - * SYS_EEPROM_I2C_DEVICE: i2c-bus - * SYS_EEPROM_I2C_ADDR: address on the bus - * The following may also be defined in sys_eeprom_platform.h, else - * the defaults with take over: - * SYS_EEPROM_MAX_SIZE: Total size of the eeprom - * SYS_EEPROM_OFFSET: offset from where the ONIE header starts - */ -#define SYS_EEPROM_MAX_SIZE 2048 -#define SYS_EEPROM_OFFSET 0 -#define SYS_EEPROM_SIZE SYS_EEPROM_MAX_SIZE -#define SYS_EEPROM_I2C_DEVICE "/dev/i2c-0" -#define SYS_EEPROM_I2C_ADDR 0x53 - -#if (SYS_EEPROM_SIZE + SYS_EEPROM_OFFSET > SYS_EEPROM_MAX_SIZE) - #error SYS_EEPROM_SIZE + SYS_EEPROM_OFFSET is greater than SYS_EEPROM_MAX_SIZE -#endif - -// Access functions to onie_tlvinfo -void show_eeprom(u_int8_t *eeprom); -int read_eeprom(struct i2c_client *pi2c_client, u_int8_t *eeprom); -int prog_eeprom(struct i2c_client *pi2c_client,u_int8_t * eeprom); -void update_eeprom_header(u_int8_t *eeprom); -bool tlvinfo_find_tlv(u_int8_t *eeprom, u_int8_t tcode, int *eeprom_index); -bool tlvinfo_delete_tlv(u_int8_t * eeprom, u_int8_t code); -bool tlvinfo_add_tlv(u_int8_t * eeprom, int tcode, const char *strval); -bool tlvinfo_decode_tlv(u_int8_t *eeprom, u_int8_t tcode, char* value); -//int find_vpd_data(u_int8_t *eeprom, int i_offset, char *c_buf); diff --git a/packages/platforms/inventec/x86-64/d6356/modules/builds/src/pmbus.h b/packages/platforms/inventec/x86-64/d6356/modules/builds/src/pmbus.h deleted file mode 100644 index fa9beb3eb..000000000 --- a/packages/platforms/inventec/x86-64/d6356/modules/builds/src/pmbus.h +++ /dev/null @@ -1,387 +0,0 @@ -/* - * pmbus.h - Common defines and structures for PMBus devices - * - * Copyright (c) 2010, 2011 Ericsson AB. - * Copyright (c) 2012 Guenter Roeck - * - * 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. - */ - -#ifndef PMBUS_H -#define PMBUS_H - -/* - * Registers - */ -#define PMBUS_PAGE 0x00 -#define PMBUS_OPERATION 0x01 -#define PMBUS_ON_OFF_CONFIG 0x02 -#define PMBUS_CLEAR_FAULTS 0x03 -#define PMBUS_PHASE 0x04 - -#define PMBUS_CAPABILITY 0x19 -#define PMBUS_QUERY 0x1A - -#define PMBUS_VOUT_MODE 0x20 -#define PMBUS_VOUT_COMMAND 0x21 -#define PMBUS_VOUT_TRIM 0x22 -#define PMBUS_VOUT_CAL_OFFSET 0x23 -#define PMBUS_VOUT_MAX 0x24 -#define PMBUS_VOUT_MARGIN_HIGH 0x25 -#define PMBUS_VOUT_MARGIN_LOW 0x26 -#define PMBUS_VOUT_TRANSITION_RATE 0x27 -#define PMBUS_VOUT_DROOP 0x28 -#define PMBUS_VOUT_SCALE_LOOP 0x29 -#define PMBUS_VOUT_SCALE_MONITOR 0x2A - -#define PMBUS_COEFFICIENTS 0x30 -#define PMBUS_POUT_MAX 0x31 - -#define PMBUS_FAN_CONFIG_12 0x3A -#define PMBUS_FAN_COMMAND_1 0x3B -#define PMBUS_FAN_COMMAND_2 0x3C -#define PMBUS_FAN_CONFIG_34 0x3D -#define PMBUS_FAN_COMMAND_3 0x3E -#define PMBUS_FAN_COMMAND_4 0x3F - -#define PMBUS_VOUT_OV_FAULT_LIMIT 0x40 -#define PMBUS_VOUT_OV_FAULT_RESPONSE 0x41 -#define PMBUS_VOUT_OV_WARN_LIMIT 0x42 -#define PMBUS_VOUT_UV_WARN_LIMIT 0x43 -#define PMBUS_VOUT_UV_FAULT_LIMIT 0x44 -#define PMBUS_VOUT_UV_FAULT_RESPONSE 0x45 -#define PMBUS_IOUT_OC_FAULT_LIMIT 0x46 -#define PMBUS_IOUT_OC_FAULT_RESPONSE 0x47 -#define PMBUS_IOUT_OC_LV_FAULT_LIMIT 0x48 -#define PMBUS_IOUT_OC_LV_FAULT_RESPONSE 0x49 -#define PMBUS_IOUT_OC_WARN_LIMIT 0x4A -#define PMBUS_IOUT_UC_FAULT_LIMIT 0x4B -#define PMBUS_IOUT_UC_FAULT_RESPONSE 0x4C - -#define PMBUS_OT_FAULT_LIMIT 0x4F -#define PMBUS_OT_FAULT_RESPONSE 0x50 -#define PMBUS_OT_WARN_LIMIT 0x51 -#define PMBUS_UT_WARN_LIMIT 0x52 -#define PMBUS_UT_FAULT_LIMIT 0x53 -#define PMBUS_UT_FAULT_RESPONSE 0x54 -#define PMBUS_VIN_OV_FAULT_LIMIT 0x55 -#define PMBUS_VIN_OV_FAULT_RESPONSE 0x56 -#define PMBUS_VIN_OV_WARN_LIMIT 0x57 -#define PMBUS_VIN_UV_WARN_LIMIT 0x58 -#define PMBUS_VIN_UV_FAULT_LIMIT 0x59 - -#define PMBUS_IIN_OC_FAULT_LIMIT 0x5B -#define PMBUS_IIN_OC_WARN_LIMIT 0x5D - -#define PMBUS_POUT_OP_FAULT_LIMIT 0x68 -#define PMBUS_POUT_OP_WARN_LIMIT 0x6A -#define PMBUS_PIN_OP_WARN_LIMIT 0x6B - -#define PMBUS_STATUS_BYTE 0x78 -#define PMBUS_STATUS_WORD 0x79 -#define PMBUS_STATUS_VOUT 0x7A -#define PMBUS_STATUS_IOUT 0x7B -#define PMBUS_STATUS_INPUT 0x7C -#define PMBUS_STATUS_TEMPERATURE 0x7D -#define PMBUS_STATUS_CML 0x7E -#define PMBUS_STATUS_OTHER 0x7F -#define PMBUS_STATUS_MFR_SPECIFIC 0x80 -#define PMBUS_STATUS_FAN_12 0x81 -#define PMBUS_STATUS_FAN_34 0x82 - -#define PMBUS_READ_VIN 0x88 -#define PMBUS_READ_IIN 0x89 -#define PMBUS_READ_VCAP 0x8A -#define PMBUS_READ_VOUT 0x8B -#define PMBUS_READ_IOUT 0x8C -#define PMBUS_READ_TEMPERATURE_1 0x8D -#define PMBUS_READ_TEMPERATURE_2 0x8E -#define PMBUS_READ_TEMPERATURE_3 0x8F -#define PMBUS_READ_FAN_SPEED_1 0x90 -#define PMBUS_READ_FAN_SPEED_2 0x91 -#define PMBUS_READ_FAN_SPEED_3 0x92 -#define PMBUS_READ_FAN_SPEED_4 0x93 -#define PMBUS_READ_DUTY_CYCLE 0x94 -#define PMBUS_READ_FREQUENCY 0x95 -#define PMBUS_READ_POUT 0x96 -#define PMBUS_READ_PIN 0x97 - -#define PMBUS_REVISION 0x98 -#define PMBUS_MFR_ID 0x99 -#define PMBUS_MFR_MODEL 0x9A -#define PMBUS_MFR_REVISION 0x9B -#define PMBUS_MFR_LOCATION 0x9C -#define PMBUS_MFR_DATE 0x9D -#define PMBUS_MFR_SERIAL 0x9E - -/* - * Virtual registers. - * Useful to support attributes which are not supported by standard PMBus - * registers but exist as manufacturer specific registers on individual chips. - * Must be mapped to real registers in device specific code. - * - * Semantics: - * Virtual registers are all word size. - * READ registers are read-only; writes are either ignored or return an error. - * RESET registers are read/write. Reading reset registers returns zero - * (used for detection), writing any value causes the associated history to be - * reset. - * Virtual registers have to be handled in device specific driver code. Chip - * driver code returns non-negative register values if a virtual register is - * supported, or a negative error code if not. The chip driver may return - * -ENODATA or any other error code in this case, though an error code other - * than -ENODATA is handled more efficiently and thus preferred. Either case, - * the calling PMBus core code will abort if the chip driver returns an error - * code when reading or writing virtual registers. - */ -#define PMBUS_VIRT_BASE 0x100 -#define PMBUS_VIRT_READ_TEMP_AVG (PMBUS_VIRT_BASE + 0) -#define PMBUS_VIRT_READ_TEMP_MIN (PMBUS_VIRT_BASE + 1) -#define PMBUS_VIRT_READ_TEMP_MAX (PMBUS_VIRT_BASE + 2) -#define PMBUS_VIRT_RESET_TEMP_HISTORY (PMBUS_VIRT_BASE + 3) -#define PMBUS_VIRT_READ_VIN_AVG (PMBUS_VIRT_BASE + 4) -#define PMBUS_VIRT_READ_VIN_MIN (PMBUS_VIRT_BASE + 5) -#define PMBUS_VIRT_READ_VIN_MAX (PMBUS_VIRT_BASE + 6) -#define PMBUS_VIRT_RESET_VIN_HISTORY (PMBUS_VIRT_BASE + 7) -#define PMBUS_VIRT_READ_IIN_AVG (PMBUS_VIRT_BASE + 8) -#define PMBUS_VIRT_READ_IIN_MIN (PMBUS_VIRT_BASE + 9) -#define PMBUS_VIRT_READ_IIN_MAX (PMBUS_VIRT_BASE + 10) -#define PMBUS_VIRT_RESET_IIN_HISTORY (PMBUS_VIRT_BASE + 11) -#define PMBUS_VIRT_READ_PIN_AVG (PMBUS_VIRT_BASE + 12) -#define PMBUS_VIRT_READ_PIN_MAX (PMBUS_VIRT_BASE + 13) -#define PMBUS_VIRT_RESET_PIN_HISTORY (PMBUS_VIRT_BASE + 14) -#define PMBUS_VIRT_READ_POUT_AVG (PMBUS_VIRT_BASE + 15) -#define PMBUS_VIRT_READ_POUT_MAX (PMBUS_VIRT_BASE + 16) -#define PMBUS_VIRT_RESET_POUT_HISTORY (PMBUS_VIRT_BASE + 17) -#define PMBUS_VIRT_READ_VOUT_AVG (PMBUS_VIRT_BASE + 18) -#define PMBUS_VIRT_READ_VOUT_MIN (PMBUS_VIRT_BASE + 19) -#define PMBUS_VIRT_READ_VOUT_MAX (PMBUS_VIRT_BASE + 20) -#define PMBUS_VIRT_RESET_VOUT_HISTORY (PMBUS_VIRT_BASE + 21) -#define PMBUS_VIRT_READ_IOUT_AVG (PMBUS_VIRT_BASE + 22) -#define PMBUS_VIRT_READ_IOUT_MIN (PMBUS_VIRT_BASE + 23) -#define PMBUS_VIRT_READ_IOUT_MAX (PMBUS_VIRT_BASE + 24) -#define PMBUS_VIRT_RESET_IOUT_HISTORY (PMBUS_VIRT_BASE + 25) -#define PMBUS_VIRT_READ_TEMP2_AVG (PMBUS_VIRT_BASE + 26) -#define PMBUS_VIRT_READ_TEMP2_MIN (PMBUS_VIRT_BASE + 27) -#define PMBUS_VIRT_READ_TEMP2_MAX (PMBUS_VIRT_BASE + 28) -#define PMBUS_VIRT_RESET_TEMP2_HISTORY (PMBUS_VIRT_BASE + 29) - -#define PMBUS_VIRT_READ_VMON (PMBUS_VIRT_BASE + 30) -#define PMBUS_VIRT_VMON_UV_WARN_LIMIT (PMBUS_VIRT_BASE + 31) -#define PMBUS_VIRT_VMON_OV_WARN_LIMIT (PMBUS_VIRT_BASE + 32) -#define PMBUS_VIRT_VMON_UV_FAULT_LIMIT (PMBUS_VIRT_BASE + 33) -#define PMBUS_VIRT_VMON_OV_FAULT_LIMIT (PMBUS_VIRT_BASE + 34) -#define PMBUS_VIRT_STATUS_VMON (PMBUS_VIRT_BASE + 35) - -/* - * CAPABILITY - */ -#define PB_CAPABILITY_SMBALERT (1<<4) -#define PB_CAPABILITY_ERROR_CHECK (1<<7) - -/* - * VOUT_MODE - */ -#define PB_VOUT_MODE_MODE_MASK 0xe0 -#define PB_VOUT_MODE_PARAM_MASK 0x1f - -#define PB_VOUT_MODE_LINEAR 0x00 -#define PB_VOUT_MODE_VID 0x20 -#define PB_VOUT_MODE_DIRECT 0x40 - -/* - * Fan configuration - */ -#define PB_FAN_2_PULSE_MASK ((1 << 0) | (1 << 1)) -#define PB_FAN_2_RPM (1 << 2) -#define PB_FAN_2_INSTALLED (1 << 3) -#define PB_FAN_1_PULSE_MASK ((1 << 4) | (1 << 5)) -#define PB_FAN_1_RPM (1 << 6) -#define PB_FAN_1_INSTALLED (1 << 7) - -/* - * STATUS_BYTE, STATUS_WORD (lower) - */ -#define PB_STATUS_NONE_ABOVE (1<<0) -#define PB_STATUS_CML (1<<1) -#define PB_STATUS_TEMPERATURE (1<<2) -#define PB_STATUS_VIN_UV (1<<3) -#define PB_STATUS_IOUT_OC (1<<4) -#define PB_STATUS_VOUT_OV (1<<5) -#define PB_STATUS_OFF (1<<6) -#define PB_STATUS_BUSY (1<<7) - -/* - * STATUS_WORD (upper) - */ -#define PB_STATUS_UNKNOWN (1<<8) -#define PB_STATUS_OTHER (1<<9) -#define PB_STATUS_FANS (1<<10) -#define PB_STATUS_POWER_GOOD_N (1<<11) -#define PB_STATUS_WORD_MFR (1<<12) -#define PB_STATUS_INPUT (1<<13) -#define PB_STATUS_IOUT_POUT (1<<14) -#define PB_STATUS_VOUT (1<<15) - -/* - * STATUS_IOUT - */ -#define PB_POUT_OP_WARNING (1<<0) -#define PB_POUT_OP_FAULT (1<<1) -#define PB_POWER_LIMITING (1<<2) -#define PB_CURRENT_SHARE_FAULT (1<<3) -#define PB_IOUT_UC_FAULT (1<<4) -#define PB_IOUT_OC_WARNING (1<<5) -#define PB_IOUT_OC_LV_FAULT (1<<6) -#define PB_IOUT_OC_FAULT (1<<7) - -/* - * STATUS_VOUT, STATUS_INPUT - */ -#define PB_VOLTAGE_UV_FAULT (1<<4) -#define PB_VOLTAGE_UV_WARNING (1<<5) -#define PB_VOLTAGE_OV_WARNING (1<<6) -#define PB_VOLTAGE_OV_FAULT (1<<7) - -/* - * STATUS_INPUT - */ -#define PB_PIN_OP_WARNING (1<<0) -#define PB_IIN_OC_WARNING (1<<1) -#define PB_IIN_OC_FAULT (1<<2) - -/* - * STATUS_TEMPERATURE - */ -#define PB_TEMP_UT_FAULT (1<<4) -#define PB_TEMP_UT_WARNING (1<<5) -#define PB_TEMP_OT_WARNING (1<<6) -#define PB_TEMP_OT_FAULT (1<<7) - -/* - * STATUS_FAN - */ -#define PB_FAN_AIRFLOW_WARNING (1<<0) -#define PB_FAN_AIRFLOW_FAULT (1<<1) -#define PB_FAN_FAN2_SPEED_OVERRIDE (1<<2) -#define PB_FAN_FAN1_SPEED_OVERRIDE (1<<3) -#define PB_FAN_FAN2_WARNING (1<<4) -#define PB_FAN_FAN1_WARNING (1<<5) -#define PB_FAN_FAN2_FAULT (1<<6) -#define PB_FAN_FAN1_FAULT (1<<7) - -/* - * CML_FAULT_STATUS - */ -#define PB_CML_FAULT_OTHER_MEM_LOGIC (1<<0) -#define PB_CML_FAULT_OTHER_COMM (1<<1) -#define PB_CML_FAULT_PROCESSOR (1<<3) -#define PB_CML_FAULT_MEMORY (1<<4) -#define PB_CML_FAULT_PACKET_ERROR (1<<5) -#define PB_CML_FAULT_INVALID_DATA (1<<6) -#define PB_CML_FAULT_INVALID_COMMAND (1<<7) - -enum pmbus_sensor_classes { - PSC_VOLTAGE_IN = 0, - PSC_VOLTAGE_OUT, - PSC_CURRENT_IN, - PSC_CURRENT_OUT, - PSC_POWER, - PSC_TEMPERATURE, - PSC_FAN, - PSC_NUM_CLASSES /* Number of power sensor classes */ -}; - -#define PMBUS_PAGES 32 /* Per PMBus specification */ - -/* Functionality bit mask */ -#define PMBUS_HAVE_VIN (1 << 0) -#define PMBUS_HAVE_VCAP (1 << 1) -#define PMBUS_HAVE_VOUT (1 << 2) -#define PMBUS_HAVE_IIN (1 << 3) -#define PMBUS_HAVE_IOUT (1 << 4) -#define PMBUS_HAVE_PIN (1 << 5) -#define PMBUS_HAVE_POUT (1 << 6) -#define PMBUS_HAVE_FAN12 (1 << 7) -#define PMBUS_HAVE_FAN34 (1 << 8) -#define PMBUS_HAVE_TEMP (1 << 9) -#define PMBUS_HAVE_TEMP2 (1 << 10) -#define PMBUS_HAVE_TEMP3 (1 << 11) -#define PMBUS_HAVE_STATUS_VOUT (1 << 12) -#define PMBUS_HAVE_STATUS_IOUT (1 << 13) -#define PMBUS_HAVE_STATUS_INPUT (1 << 14) -#define PMBUS_HAVE_STATUS_TEMP (1 << 15) -#define PMBUS_HAVE_STATUS_FAN12 (1 << 16) -#define PMBUS_HAVE_STATUS_FAN34 (1 << 17) -#define PMBUS_HAVE_VMON (1 << 18) -#define PMBUS_HAVE_STATUS_VMON (1 << 19) - -enum pmbus_data_format { linear = 0, direct, vid }; - -struct pmbus_driver_info { - int pages; /* Total number of pages */ - enum pmbus_data_format format[PSC_NUM_CLASSES]; - /* - * Support one set of coefficients for each sensor type - * Used for chips providing data in direct mode. - */ - int m[PSC_NUM_CLASSES]; /* mantissa for direct data format */ - int b[PSC_NUM_CLASSES]; /* offset */ - int R[PSC_NUM_CLASSES]; /* exponent */ - - u32 func[PMBUS_PAGES]; /* Functionality, per page */ - /* - * The following functions map manufacturing specific register values - * to PMBus standard register values. Specify only if mapping is - * necessary. - * Functions return the register value (read) or zero (write) if - * successful. A return value of -ENODATA indicates that there is no - * manufacturer specific register, but that a standard PMBus register - * may exist. Any other negative return value indicates that the - * register does not exist, and that no attempt should be made to read - * the standard register. - */ - int (*read_byte_data)(struct i2c_client *client, int page, int reg); - int (*read_word_data)(struct i2c_client *client, int page, int reg); - int (*write_word_data)(struct i2c_client *client, int page, int reg, - u16 word); - int (*write_byte)(struct i2c_client *client, int page, u8 value); - /* - * The identify function determines supported PMBus functionality. - * This function is only necessary if a chip driver supports multiple - * chips, and the chip functionality is not pre-determined. - */ - int (*identify)(struct i2c_client *client, - struct pmbus_driver_info *info); -}; - -/* Function declarations */ - -void pmbus_clear_cache(struct i2c_client *client); -int pmbus_set_page(struct i2c_client *client, u8 page); -int pmbus_read_word_data(struct i2c_client *client, u8 page, u8 reg); -int pmbus_write_word_data(struct i2c_client *client, u8 page, u8 reg, u16 word); -int pmbus_read_byte_data(struct i2c_client *client, int page, u8 reg); -int pmbus_write_byte(struct i2c_client *client, int page, u8 value); -void pmbus_clear_faults(struct i2c_client *client); -bool pmbus_check_byte_register(struct i2c_client *client, int page, int reg); -bool pmbus_check_word_register(struct i2c_client *client, int page, int reg); -int pmbus_do_probe(struct i2c_client *client, const struct i2c_device_id *id, - struct pmbus_driver_info *info); -int pmbus_do_remove(struct i2c_client *client); -const struct pmbus_driver_info *pmbus_get_driver_info(struct i2c_client - *client); - -#endif /* PMBUS_H */ diff --git a/packages/platforms/inventec/x86-64/d6356/modules/builds/src/transceiver.c b/packages/platforms/inventec/x86-64/d6356/modules/builds/src/transceiver.c deleted file mode 100644 index 93ed36028..000000000 --- a/packages/platforms/inventec/x86-64/d6356/modules/builds/src/transceiver.c +++ /dev/null @@ -1,8449 +0,0 @@ -#include -#include -#include -#include -#include "io_expander.h" -#include "transceiver.h" - -/* For build single module using (Ex: ONL platform) */ -//#include -//#include -//#include - - -/* ========== Register EEPROM address mapping ========== - */ -struct eeprom_map_s eeprom_map_sfp = { - .addr_br =0x50, .page_br =-1, .offset_br =12, .length_br =1, - .addr_cdr =-1, .page_cdr =-1, .offset_cdr =-1, .length_cdr =-1, - .addr_comp_rev =0x50, .page_comp_rev =-1, .offset_comp_rev =94, .length_comp_rev =1, - .addr_connector =0x50, .page_connector =-1, .offset_connector =2, .length_connector =1, - .addr_diag_type =0x50, .page_diag_type =-1, .offset_diag_type =92 , .length_diag_type =1, - .addr_extbr =-1, .page_extbr =-1, .offset_extbr =-1, .length_extbr =-1, - .addr_ext_id =0x50, .page_ext_id =-1, .offset_ext_id =1, .length_ext_id =1, - .addr_id =0x50, .page_id =-1, .offset_id =0, .length_id =1, - .addr_len_sm =0x50, .page_len_sm =-1, .offset_len_sm =15, .length_len_sm =1, - .addr_len_smf =0x50, .page_len_smf =-1, .offset_len_smf =14, .length_len_smf =1, - .addr_len_om1 =0x50, .page_len_om1 =-1, .offset_len_om1 =17, .length_len_om1 =1, - .addr_len_om2 =0x50, .page_len_om2 =-1, .offset_len_om2 =16, .length_len_om2 =1, - .addr_len_om3 =0x50, .page_len_om3 =-1, .offset_len_om3 =19, .length_len_om3 =1, - .addr_len_om4 =0x50, .page_len_om4 =-1, .offset_len_om4 =18, .length_len_om4 =1, - .addr_option =0x50, .page_option =-1, .offset_option =64, .length_option =2, - .addr_rate_id =0x50, .page_rate_id =-1, .offset_rate_id =13, .length_rate_id =1, - .addr_rx_am =-1, .page_rx_am =-1, .offset_rx_am =-1, .length_rx_am =-1, - .addr_rx_em =0x51, .page_rx_em =-1, .offset_rx_em =115, .length_rx_em =1, - .addr_rx_los =-1, .page_rx_los =-1, .offset_rx_los =-1, .length_rx_los =-1, - .addr_rx_power =0x51, .page_rx_power =-1, .offset_rx_power =104, .length_rx_power =2, - .addr_soft_rs0 =0x51, .page_soft_rs0 =-1, .offset_soft_rs0 =110, .length_soft_rs0 =1, - .addr_soft_rs1 =0x51, .page_soft_rs1 =-1, .offset_soft_rs1 =118, .length_soft_rs0 =1, - .addr_temp =0x51, .page_temp =-1, .offset_temp =96, .length_temp =2, - .addr_trancomp =0x50, .page_trancomp =-1, .offset_trancomp =3, .length_trancomp =8, - .addr_trancomp_ext =0x50, .page_trancomp_ext =-1, .offset_trancomp_ext =36, .length_trancomp_ext =1, - .addr_tx_bias =0x51, .page_tx_bias =-1, .offset_tx_bias =100, .length_tx_bias =2, - .addr_tx_disable =-1, .page_tx_disable =-1, .offset_tx_disable =-1, .length_tx_disable =-1, - .addr_tx_eq =0x51, .page_tx_eq =-1, .offset_tx_eq =114, .length_tx_eq =1, - .addr_tx_fault =-1, .page_tx_fault =-1, .offset_tx_fault =-1, .length_tx_fault =-1, - .addr_tx_power =0x51, .page_tx_power =-1, .offset_tx_power =102, .length_tx_power =2, - .addr_vendor_name =0x50, .page_vendor_name =-1, .offset_vendor_name =20, .length_vendor_name =16, - .addr_vendor_pn =0x50, .page_vendor_pn =-1, .offset_vendor_pn =40, .length_vendor_pn =16, - .addr_vendor_rev =0x50, .page_vendor_rev =-1, .offset_vendor_rev =56, .length_vendor_rev =4, - .addr_vendor_sn =0x50, .page_vendor_sn =-1, .offset_vendor_sn =68, .length_vendor_sn =16, - .addr_voltage =0x51, .page_voltage =-1, .offset_voltage =98, .length_voltage =2, - .addr_wavelength =0x50, .page_wavelength =-1, .offset_wavelength =60, .length_wavelength =2, - .addr_eeprom =0x50, .page_eeprom =-1, .offset_eeprom =0, .length_eeprom =256, -}; - -struct eeprom_map_s eeprom_map_qsfp = { - .addr_br =0x50, .page_br =0, .offset_br =140, .length_br =1, - .addr_cdr =-1, .page_cdr =-1, .offset_cdr =-1, .length_cdr =-1, - .addr_comp_rev =0x50, .page_comp_rev =-1, .offset_comp_rev =1, .length_comp_rev =1, - .addr_connector =0x50, .page_connector =0, .offset_connector =130, .length_connector =1, - .addr_diag_type =0x50, .page_diag_type =0, .offset_diag_type =220, .length_diag_type =1, - .addr_extbr =0x50, .page_extbr =0, .offset_extbr =222, .length_extbr =1, - .addr_ext_id =0x50, .page_ext_id =0, .offset_ext_id =129, .length_ext_id =1, - .addr_id =0x50, .page_id =0, .offset_id =128, .length_id =1, - .addr_len_sm =-1, .page_len_sm =-1, .offset_len_sm =-1, .length_len_sm =-1, - .addr_len_smf =0x50, .page_len_smf =0, .offset_len_smf =142, .length_len_smf =1, - .addr_len_om1 =0x50, .page_len_om1 =0, .offset_len_om1 =145, .length_len_om1 =1, - .addr_len_om2 =0x50, .page_len_om2 =0, .offset_len_om2 =144, .length_len_om2 =1, - .addr_len_om3 =0x50, .page_len_om3 =0, .offset_len_om3 =143, .length_len_om3 =1, - .addr_len_om4 =0x50, .page_len_om4 =0, .offset_len_om4 =146, .length_len_om4 =1, - .addr_option =0x50, .page_option =0, .offset_option =193, .length_option =3, - .addr_rate_id =-1, .page_rate_id =-1, .offset_rate_id =-1, .length_rate_id =-1, - .addr_rx_am =-1, .page_rx_am =-1, .offset_rx_am =-1, .length_rx_am =-1, - .addr_rx_em =-1, .page_rx_em =-1, .offset_rx_em =-1, .length_rx_em =-1, - .addr_rx_los =0x50, .page_rx_los =-1, .offset_rx_los =3, .length_rx_los =1, - .addr_rx_power =0x50, .page_rx_power =-1, .offset_rx_power =34, .length_rx_power =8, - .addr_soft_rs0 =-1, .page_soft_rs0 =-1, .offset_soft_rs0 =-1, .length_soft_rs0 =-1, - .addr_soft_rs1 =-1, .page_soft_rs1 =-1, .offset_soft_rs1 =-1, .length_soft_rs0 =-1, - .addr_temp =0x50, .page_temp =-1, .offset_temp =22, .length_temp =2, - .addr_trancomp =0x50, .page_trancomp =0, .offset_trancomp =131, .length_trancomp =8, - .addr_trancomp_ext =0x50, .page_trancomp_ext =0, .offset_trancomp_ext =192, .length_trancomp_ext =1, - .addr_tx_bias =0x50, .page_tx_bias =-1, .offset_tx_bias =42, .length_tx_bias =8, - .addr_tx_disable =0x50, .page_tx_disable =-1, .offset_tx_disable =86, .length_tx_disable =1, - .addr_tx_eq =-1, .page_tx_eq =-1, .offset_tx_eq =-1, .length_tx_eq =-1, - .addr_tx_fault =0x50, .page_tx_fault =-1, .offset_tx_fault =4, .length_tx_fault =1, - .addr_tx_power =0x50, .page_tx_power =-1, .offset_tx_power =50, .length_tx_power =8, - .addr_vendor_name =0x50, .page_vendor_name =0, .offset_vendor_name =148, .length_vendor_name =16, - .addr_vendor_pn =0x50, .page_vendor_pn =0, .offset_vendor_pn =168, .length_vendor_pn =16, - .addr_vendor_rev =0x50, .page_vendor_rev =0, .offset_vendor_rev =184, .length_vendor_rev =2, - .addr_vendor_sn =0x50, .page_vendor_sn =0, .offset_vendor_sn =196, .length_vendor_sn =16, - .addr_voltage =0x50, .page_voltage =-1, .offset_voltage =26, .length_voltage =2, - .addr_wavelength =0x50, .page_wavelength =0, .offset_wavelength =186, .length_wavelength =2, - .addr_eeprom =0x50, .page_eeprom =0, .offset_eeprom =128, .length_eeprom =256, -}; - -struct eeprom_map_s eeprom_map_qsfp28 = { - .addr_br =0x50, .page_br =0, .offset_br =140, .length_br =1, - .addr_cdr =0x50, .page_cdr =-1, .offset_cdr =98, .length_cdr =1, - .addr_comp_rev =0x50, .page_comp_rev =-1, .offset_comp_rev =1, .length_comp_rev =1, - .addr_connector =0x50, .page_connector =0, .offset_connector =130, .length_connector =1, - .addr_diag_type =0x50, .page_diag_type =0, .offset_diag_type =220, .length_diag_type =1, - .addr_extbr =0x50, .page_extbr =0, .offset_extbr =222, .length_extbr =1, - .addr_ext_id =0x50, .page_ext_id =0, .offset_ext_id =129, .length_ext_id =1, - .addr_id =0x50, .page_id =0, .offset_id =128, .length_id =1, - .addr_len_sm =-1, .page_len_sm =-1, .offset_len_sm =-1, .length_len_sm =-1, - .addr_len_smf =0x50, .page_len_smf =0, .offset_len_smf =142, .length_len_smf =1, - .addr_len_om1 =0x50, .page_len_om1 =0, .offset_len_om1 =145, .length_len_om1 =1, - .addr_len_om2 =0x50, .page_len_om2 =0, .offset_len_om2 =144, .length_len_om2 =1, - .addr_len_om3 =0x50, .page_len_om3 =0, .offset_len_om3 =143, .length_len_om3 =1, - .addr_len_om4 =0x50, .page_len_om4 =0, .offset_len_om4 =146, .length_len_om4 =1, - .addr_option =0x50, .page_option =0, .offset_option =193, .length_option =3, - .addr_rate_id =-1, .page_rate_id =-1, .offset_rate_id =-1, .length_rate_id =-1, - .addr_rx_am =0x50, .page_rx_am =3, .offset_rx_am =238, .length_rx_am =2, - .addr_rx_em =0x50, .page_rx_em =3, .offset_rx_em =236, .length_rx_em =2, - .addr_rx_los =0x50, .page_rx_los =-1, .offset_rx_los =3, .length_rx_los =1, - .addr_rx_power =0x50, .page_rx_power =-1, .offset_rx_power =34, .length_rx_power =8, - .addr_soft_rs0 =-1, .page_soft_rs0 =-1, .offset_soft_rs0 =-1, .length_soft_rs0 =-1, - .addr_soft_rs1 =-1, .page_soft_rs1 =-1, .offset_soft_rs1 =-1, .length_soft_rs0 =-1, - .addr_temp =0x50, .page_temp =-1, .offset_temp =22, .length_temp =2, - .addr_trancomp =0x50, .page_trancomp =0, .offset_trancomp =131, .length_trancomp =8, - .addr_trancomp_ext =0x50, .page_trancomp_ext =0, .offset_trancomp_ext =192, .length_trancomp_ext =1, - .addr_tx_bias =0x50, .page_tx_bias =-1, .offset_tx_bias =42, .length_tx_bias =8, - .addr_tx_disable =0x50, .page_tx_disable =-1, .offset_tx_disable =86, .length_tx_disable =1, - .addr_tx_eq =0x50, .page_tx_eq =3, .offset_tx_eq =234, .length_tx_eq =2, - .addr_tx_fault =0x50, .page_tx_fault =-1, .offset_tx_fault =4, .length_tx_fault =1, - .addr_tx_power =0x50, .page_tx_power =-1, .offset_tx_power =50, .length_tx_power =8, - .addr_vendor_name =0x50, .page_vendor_name =0, .offset_vendor_name =148, .length_vendor_name =16, - .addr_vendor_pn =0x50, .page_vendor_pn =0, .offset_vendor_pn =168, .length_vendor_pn =16, - .addr_vendor_rev =0x50, .page_vendor_rev =0, .offset_vendor_rev =184, .length_vendor_rev =2, - .addr_vendor_sn =0x50, .page_vendor_sn =0, .offset_vendor_sn =196, .length_vendor_sn =16, - .addr_voltage =0x50, .page_voltage =-1, .offset_voltage =26, .length_voltage =2, - .addr_wavelength =0x50, .page_wavelength =0, .offset_wavelength =186, .length_wavelength =2, - .addr_eeprom =0x50, .page_eeprom =0, .offset_eeprom =128, .length_eeprom =256, -}; - - -/* ========== Utility Functions ========== - */ -static int -get_bit(uint8_t origin_byte, int bit_shift) { - return (int)((origin_byte >> bit_shift) & 0x1); -} - -static int -transform_word_to_int(uint8_t hight_byte, - uint8_t low_byte) { - return ((((int)hight_byte) << 8) + (int)low_byte); -} - -void -alarm_msg_2_user(struct transvr_obj_s *self, - char *emsg) { - - SWPS_ERR("%s on %s.\n", emsg, self->swp_name); -} -EXPORT_SYMBOL(alarm_msg_2_user); - -/* ========== Private functions ========== - */ -static int -_reload_transvr_obj(struct transvr_obj_s *self,int new_type); - -static int -reload_transvr_obj(struct transvr_obj_s *self,int new_type); - -static int -_is_transvr_support_ctle(struct transvr_obj_s *self); - -static int -_transvr_init_handler(struct transvr_obj_s *self); - -int -_transvr_clean_handler(struct transvr_obj_s *self); - -int -_sfp_detect_class_by_1g_ethernet(struct transvr_obj_s* self); - - -void -lock_transvr_obj(struct transvr_obj_s *self) { - - mutex_lock(&self->lock); - self->curr_page = VAL_TRANSVR_PAGE_FREE; -} -EXPORT_SYMBOL(lock_transvr_obj); - - -void -unlock_transvr_obj(struct transvr_obj_s *self) { - - self->curr_page = VAL_TRANSVR_PAGE_FREE; - mutex_unlock(&self->lock); -} -EXPORT_SYMBOL(unlock_transvr_obj); - - -static int -_check_by_mode(struct transvr_obj_s *self, - int (*attr_update_func)(struct transvr_obj_s *self, int show_err), - char *caller_name){ - - int return_val = ERR_TRANSVR_UNEXCPT; - - switch (self->mode){ - case TRANSVR_MODE_POLLING: - switch (self->state){ - case STATE_TRANSVR_CONNECTED: - goto ok_check_by_mode_1; - case STATE_TRANSVR_NEW: - case STATE_TRANSVR_INIT: - return ERR_TRANSVR_UNINIT; - case STATE_TRANSVR_DISCONNECTED: - return ERR_TRANSVR_UNPLUGGED; - case STATE_TRANSVR_UNEXCEPTED: - return ERR_TRANSVR_ABNORMAL; - case STATE_TRANSVR_ISOLATED: - return ERR_TRNASVR_BE_ISOLATED; - default: - goto err_check_by_mode_1; - } - goto ok_check_by_mode_1; - - case TRANSVR_MODE_DIRECT: - return_val = self->fsm_4_direct(self, caller_name); - if (return_val < 0){ - return return_val; - } - goto ok_check_by_mode_1; - - default: - goto err_check_by_mode_1; - } - goto ok_check_by_mode_1; - -ok_check_by_mode_1: - return attr_update_func(self, 0); - -err_check_by_mode_1: - SWPS_INFO("_check_by_mode: mode:%d state:%d\n", self->mode, self->state); - return ERR_TRANSVR_UNEXCPT; -} - - -static void -_transvr_clean_retry(struct transvr_obj_s *self) { - self->retry = 0; -} - - -static int -_transvr_handle_retry(struct transvr_obj_s *self, int retry) { - /* Return: 0: keep retry - * -1: stop retry - */ - if (self->retry == 0) { - self->retry = retry; - } - self->retry -= 1; - if (self->retry <= 0) { - _transvr_clean_retry(self); - return -1; - } - return 0; -} - - -static int -_common_setup_page(struct transvr_obj_s *self, - int addr, - int page, - int offset, - int len, - int show_e) { - /* return: - * 0 : OK - * -1 : EEPROM settings incorrect - * -2 : I2C R/W failure - * -3 : Undefined case - */ - int retval = DEBUG_TRANSVR_INT_VAL; - char *emsg = DEBUG_TRANSVR_STR_VAL; - - /* Check */ - if ((addr < 0) || (offset < 0) || (len < 0)) { - emsg = "EEPROM settings incorrect"; - retval = -1; - goto err_common_setup_page; - } - /* Case1: continue access */ - if ((self->i2c_client_p->addr == addr) && - (self->curr_page == page)) { - return 0; - } - self->i2c_client_p->addr = addr; - /* Case2: select lower page */ - if (page == -1) { - self->curr_page = page; - return 0; - } - /* Case3: select upper page */ - if (page >= 0) { - goto upper_common_setup_page; - } - /* Unexpected case */ - show_e = 1; - emsg = "Unexpected case"; - retval = -3; - goto err_common_setup_page; - -upper_common_setup_page: - if (i2c_smbus_write_byte_data(self->i2c_client_p, - VAL_TRANSVR_PAGE_SELECT_OFFSET, - page) < 0) { - emsg = "I2C R/W failure"; - retval = -2; - goto err_common_setup_page; - } - self->curr_page = page; - mdelay(VAL_TRANSVR_PAGE_SELECT_DELAY); - return 0; - -err_common_setup_page: - if (show_e) { - SWPS_INFO("%s: %s", __func__, emsg); - SWPS_INFO("%s: :0x%02x :%d :%d :%d\n", - __func__, addr, page, offset, len); - } - return retval; -} - -/* -static int -_common_setup_password(struct transvr_obj_s *self, - int addr, - int page, - int offs, - uint8_t pwd[4], - int show_e) { - int i = 0; - int err = DEBUG_TRANSVR_INT_VAL; - char *emsg = DEBUG_TRANSVR_STR_VAL; - - err = _common_setup_page(self, addr, page, offs, 4, show_e); - if (err < 0){ - emsg = "setup EEPROM page fail"; - goto err_common_setup_password; - } - for (i=0; i<4; i++) { - err = i2c_smbus_write_byte_data(self->i2c_client_p, - (offs + i), - pwd[i]); - if (err < 0){ - emsg = "I2C R/W fail!"; - goto err_common_setup_password; - } - } - return 0; - -err_common_setup_password: - if (show_e) { - SWPS_INFO("%s: %s :%d\n", __func__, emsg, err); - } - return ERR_TRANSVR_UPDATE_FAIL; -} -*/ - -static int -_common_update_uint8_attr(struct transvr_obj_s *self, - int addr, - int page, - int offset, - int len, - uint8_t *buf, - char *caller, - int show_e){ - - int i; - int err = DEBUG_TRANSVR_INT_VAL; - char *emsg = DEBUG_TRANSVR_STR_VAL; - - err = _common_setup_page(self, addr, page, offset, len, show_e); - if (err < 0){ - emsg = "setup EEPROM page fail"; - goto err_common_update_uint8_attr; - } - for (i=0; ii2c_client_p, (offset + i)); - if (err < 0){ - emsg = "I2C R/W fail!"; - goto err_common_update_uint8_attr; - } - buf[i] = err; - } - return 0; - -err_common_update_uint8_attr: - if (show_e) { - SWPS_INFO("%s: %s :%s :%d\n", - __func__, emsg, caller, err); - } - buf[0] = DEBUG_TRANSVR_HEX_VAL; - return ERR_TRANSVR_UPDATE_FAIL; -} - - -static int -_common_update_int_attr(struct transvr_obj_s *self, - int addr, - int page, - int offset, - int len, - int *buf, - char *caller, - int show_e){ - - int i; - int err = DEBUG_TRANSVR_INT_VAL; - char *emsg = DEBUG_TRANSVR_STR_VAL; - - err = _common_setup_page(self, addr, page, offset, len, show_e); - if (err < 0){ - emsg = "setup EEPROM page fail"; - goto err_common_update_int_attr; - } - for (i=0; ii2c_client_p, (offset + i)); - if (err < 0){ - emsg = "I2C R/W fail!"; - goto err_common_update_int_attr; - } - buf[i] = (int)err; - } - return 0; - -err_common_update_int_attr: - if (show_e) { - SWPS_INFO("%s: %s :%s :%d\n", - __func__, emsg, caller, err); - } - buf[0] = DEBUG_TRANSVR_INT_VAL; - return ERR_TRANSVR_UPDATE_FAIL; -} - - -static int -_common_update_string_attr(struct transvr_obj_s *self, - int addr, - int page, - int offset, - int len, - char buf[], - char *caller, - int show_e){ - - int i; - int err = DEBUG_TRANSVR_INT_VAL; - char *emsg = DEBUG_TRANSVR_STR_VAL; - - err = _common_setup_page(self, addr, page, offset, len, show_e); - if (err < 0){ - emsg = "setup EEPROM page fail"; - goto err_common_update_string_attr; - } - for (i=0; ii2c_client_p, (offset + i)); - if (err < 0){ - emsg = "I2C R/W fail!"; - goto err_common_update_string_attr; - } - buf[i] = (char)err; - } - return 0; - -err_common_update_string_attr: - if (show_e) { - SWPS_INFO("%s: %s :%s :%d\n", - __func__, emsg, caller, err); - } - buf[0] = 'e'; - return ERR_TRANSVR_UPDATE_FAIL; -} - - -static int -_common_set_uint8_attr(struct transvr_obj_s *self, - int addr, - int page, - int offset, - uint8_t update, - uint8_t *buf, - char *caller, - int show_e){ - int len = 1; - int err = DEBUG_TRANSVR_INT_VAL; - char *emsg = DEBUG_TRANSVR_STR_VAL; - - if ((*buf) == update){ - return 0; - } - err = _common_setup_page(self, addr, page, offset, len, show_e); - if (err < 0){ - emsg = "setup EEPROM page fail"; - goto err_common_set_uint8_attr_1; - } - err = i2c_smbus_write_byte_data(self->i2c_client_p, - offset, - update); - if (err < 0){ - emsg = "I2C R/W fail!"; - goto err_common_set_uint8_attr_1; - } - (*buf) = update; - return 0; - -err_common_set_uint8_attr_1: - if (show_e) { - SWPS_INFO("%s: %s :%s :%d\n", - __func__, emsg, caller, err); - } - return ERR_TRANSVR_UPDATE_FAIL; -} - - -static int -_common_set_uint8_array(struct transvr_obj_s *self, - int addr, - int page, - int offs, - int len, - uint8_t update[], - uint8_t buf[], - char *caller, - int show_e){ - int i = 0; - int err = DEBUG_TRANSVR_INT_VAL; - char *emsg = DEBUG_TRANSVR_STR_VAL; - - err = _common_setup_page(self, addr, page, offs, len, show_e); - if (err < 0){ - emsg = "setup EEPROM page fail"; - goto err_common_set_uint8_attr_1; - } - for (i=0; ii2c_client_p, - (offs + i), - update[i]); - if (err < 0){ - emsg = "I2C R/W fail!"; - goto err_common_set_uint8_attr_1; - } - buf[i] = update[i]; - } - return 0; - -err_common_set_uint8_attr_1: - if (show_e) { - SWPS_INFO("%s: %s :%s :%d :%d\n", - __func__, emsg, caller, err, i); - } - return ERR_TRANSVR_UPDATE_FAIL; -} - - -static int -_common_update_attr_id(struct transvr_obj_s *self, - int show_err){ - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_id, - self->eeprom_map_p->page_id, - self->eeprom_map_p->offset_id, - self->eeprom_map_p->length_id, - &(self->id), - "_common_update_attr_id", - show_err); -} - - -static int -_common_update_attr_extended_id(struct transvr_obj_s *self, - int show_err){ - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_ext_id, - self->eeprom_map_p->page_ext_id, - self->eeprom_map_p->offset_ext_id, - self->eeprom_map_p->length_ext_id, - &(self->ext_id), - "_common_update_attr_extended_id", - show_err); -} - - -static int -_common_update_attr_connector(struct transvr_obj_s *self, - int show_err){ - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_connector, - self->eeprom_map_p->page_connector, - self->eeprom_map_p->offset_connector, - self->eeprom_map_p->length_connector, - &(self->connector), - "_common_update_attr_connector", - show_err); -} - - -static int -_common_update_attr_transvr_comp(struct transvr_obj_s *self, - int show_err){ - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_trancomp, - self->eeprom_map_p->page_trancomp, - self->eeprom_map_p->offset_trancomp, - self->eeprom_map_p->length_trancomp, - self->transvr_comp, - "_common_update_attr_transvr_comp", - show_err); -} - - -static int -_common_update_attr_transvr_comp_ext(struct transvr_obj_s *self, - int show_err){ - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_trancomp_ext, - self->eeprom_map_p->page_trancomp_ext, - self->eeprom_map_p->offset_trancomp_ext, - self->eeprom_map_p->length_trancomp_ext, - &(self->transvr_comp_ext), - "_common_update_attr_transvr_comp_ext", - show_err); -} - - -static int -_common_update_attr_vendor_name(struct transvr_obj_s *self, - int show_err){ - return _common_update_string_attr(self, - self->eeprom_map_p->addr_vendor_name, - self->eeprom_map_p->page_vendor_name, - self->eeprom_map_p->offset_vendor_name, - self->eeprom_map_p->length_vendor_name, - self->vendor_name, - "_common_update_attr_vendor_name", - show_err); -} - - -static int -_common_update_attr_vendor_pn(struct transvr_obj_s *self, - int show_err){ - return _common_update_string_attr(self, - self->eeprom_map_p->addr_vendor_pn, - self->eeprom_map_p->page_vendor_pn, - self->eeprom_map_p->offset_vendor_pn, - self->eeprom_map_p->length_vendor_pn, - self->vendor_pn, - "_common_update_attr_vendor_pn", - show_err); -} - - -static int -_common_update_attr_vendor_rev(struct transvr_obj_s *self, - int show_err){ - return _common_update_string_attr(self, - self->eeprom_map_p->addr_vendor_rev, - self->eeprom_map_p->page_vendor_rev, - self->eeprom_map_p->offset_vendor_rev, - self->eeprom_map_p->length_vendor_rev, - self->vendor_rev, - "_common_update_attr_vendor_rev", - show_err); -} - - -static int -_common_update_attr_vendor_sn(struct transvr_obj_s *self, - int show_err){ - return _common_update_string_attr(self, - self->eeprom_map_p->addr_vendor_sn, - self->eeprom_map_p->page_vendor_sn, - self->eeprom_map_p->offset_vendor_sn, - self->eeprom_map_p->length_vendor_sn, - self->vendor_sn, - "_common_update_attr_vendor_sn", - show_err); -} - - -static int -_common_update_attr_br(struct transvr_obj_s *self, - int show_err){ - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_br, - self->eeprom_map_p->page_br, - self->eeprom_map_p->offset_br, - self->eeprom_map_p->length_br, - &(self->br), - "_common_update_attr_br", - show_err); -} - - -static int -_common_update_attr_len_smf(struct transvr_obj_s *self, - int show_err){ - return _common_update_int_attr(self, - self->eeprom_map_p->addr_len_smf, - self->eeprom_map_p->page_len_smf, - self->eeprom_map_p->offset_len_smf, - self->eeprom_map_p->length_len_smf, - &(self->len_smf), - "_common_update_attr_len_smf", - show_err); -} - - -static int -_common_update_attr_len_om1(struct transvr_obj_s *self, - int show_err){ - return _common_update_int_attr(self, - self->eeprom_map_p->addr_len_om1, - self->eeprom_map_p->page_len_om1, - self->eeprom_map_p->offset_len_om1, - self->eeprom_map_p->length_len_om1, - &(self->len_om1), - "_common_update_attr_len_om1", - show_err); -} - -static int -_common_update_attr_len_om2(struct transvr_obj_s *self, - int show_err){ - return _common_update_int_attr(self, - self->eeprom_map_p->addr_len_om2, - self->eeprom_map_p->page_len_om2, - self->eeprom_map_p->offset_len_om2, - self->eeprom_map_p->length_len_om2, - &(self->len_om2), - "_common_update_attr_len_om2", - show_err); -} - -static int -_common_update_attr_len_om3(struct transvr_obj_s *self, - int show_err){ - return _common_update_int_attr(self, - self->eeprom_map_p->addr_len_om3, - self->eeprom_map_p->page_len_om3, - self->eeprom_map_p->offset_len_om3, - self->eeprom_map_p->length_len_om3, - &(self->len_om3), - "_common_update_attr_len_om3", - show_err); -} - - -static int -_common_update_attr_len_om4(struct transvr_obj_s *self, - int show_err){ - return _common_update_int_attr(self, - self->eeprom_map_p->addr_len_om4, - self->eeprom_map_p->page_len_om4, - self->eeprom_map_p->offset_len_om4, - self->eeprom_map_p->length_len_om4, - &(self->len_om4), - "_common_update_attr_len_om4", - show_err); -} - - -static int -_common_update_attr_option(struct transvr_obj_s *self, - int show_err){ - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_option, - self->eeprom_map_p->page_option, - self->eeprom_map_p->offset_option, - self->eeprom_map_p->length_option, - self->option, - "_common_update_attr_option", - show_err); -} - - -static int -_common_update_attr_comp_rev(struct transvr_obj_s *self, - int show_err){ - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_comp_rev, - self->eeprom_map_p->page_comp_rev, - self->eeprom_map_p->offset_comp_rev, - self->eeprom_map_p->length_comp_rev, - &(self->comp_rev), - "_common_update_attr_comp_rev", - show_err); -} - - -static int -_common_update_attr_diag_type(struct transvr_obj_s *self, - int show_err){ - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_diag_type, - self->eeprom_map_p->page_diag_type, - self->eeprom_map_p->offset_diag_type, - self->eeprom_map_p->length_diag_type, - &(self->diag_type), - "_common_update_attr_diag_type", - show_err); -} - - -static int -_common_update_attr_wavelength(struct transvr_obj_s *self, - int show_err){ - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_wavelength, - self->eeprom_map_p->page_wavelength, - self->eeprom_map_p->offset_wavelength, - self->eeprom_map_p->length_wavelength, - self->wavelength, - "_common_update_attr_wavelength", - show_err); -} - - -int -_common_get_option_value(struct transvr_obj_s *self, - int offset, - int bit_shift) { - /* SFP: - * - option[0] = A0h / 64 - * - option[1] = A0h / 65 - * QSFP: - * - option[0] = 00h / 193 - * - option[1] = 00h / 194 - * - option[2] = 00h / 195 - */ - return (self->option[offset] & (1 << bit_shift)); -} - -static int -_common_update_attr_eeprom(struct transvr_obj_s *self, - int show_err){ - return _common_update_string_attr(self, - self->eeprom_map_p->addr_eeprom, - self->eeprom_map_p->page_eeprom, - self->eeprom_map_p->offset_eeprom, - self->eeprom_map_p->length_eeprom, - self->eeprom, - "_common_update_attr_eeprom", - show_err); -} - - -static int -_sfp_update_attr_len_sm(struct transvr_obj_s *self, - int show_err){ - return _common_update_int_attr(self, - self->eeprom_map_p->addr_len_sm, - self->eeprom_map_p->page_len_sm, - self->eeprom_map_p->offset_len_sm, - self->eeprom_map_p->length_len_sm, - &(self->len_sm), - "_common_update_attr_len_sm", - show_err); -} - - -static int -_sfp_update_attr_rate_id(struct transvr_obj_s *self, - int show_err){ - return _common_update_int_attr(self, - self->eeprom_map_p->addr_rate_id, - self->eeprom_map_p->page_rate_id, - self->eeprom_map_p->offset_rate_id, - self->eeprom_map_p->length_rate_id, - &(self->rate_id), - "_sfp_update_attr_rate_id", - show_err); -} - - -static int -_sfp_update_attr_soft_rs0(struct transvr_obj_s *self, - int show_err){ - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_soft_rs0, - self->eeprom_map_p->page_soft_rs0, - self->eeprom_map_p->offset_soft_rs0, - self->eeprom_map_p->length_soft_rs0, - &(self->soft_rs0), - "_sfp_update_attr_soft_rs0", - show_err); -} - - -static int -_sfp_update_attr_soft_rs1(struct transvr_obj_s *self, - int show_err){ - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_soft_rs1, - self->eeprom_map_p->page_soft_rs1, - self->eeprom_map_p->offset_soft_rs1, - self->eeprom_map_p->length_soft_rs1, - &(self->soft_rs1), - "_sfp_update_attr_soft_rs1", - show_err); -} - - -int -_sfp_is_diag_support(struct transvr_obj_s *self){ - - uint8_t bit_mask = 0xC0; /* 1100 0000 */ - uint8_t en_val = 0x40; /* 0100 0000 */ - uint8_t checkval = (self->diag_type & bit_mask); - - if (checkval == en_val) { - return 1; - } - return 0; -} - - -static int -_sfp_update_attr_curr_temp(struct transvr_obj_s *self, - int show_err){ - - if (!(_sfp_is_diag_support(self))) { - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_temp, - self->eeprom_map_p->page_temp, - self->eeprom_map_p->offset_temp, - self->eeprom_map_p->length_temp, - self->curr_temp, - "_sfp_update_attr_curr_temp", - show_err); -} - - -static int -_sfp_update_attr_curr_voltage(struct transvr_obj_s *self, - int show_err){ - - if (!(_sfp_is_diag_support(self))) { - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_voltage, - self->eeprom_map_p->page_voltage, - self->eeprom_map_p->offset_voltage, - self->eeprom_map_p->length_voltage, - self->curr_voltage, - "_sfp_update_attr_curr_voltage", - show_err); -} - - -static int -_sfp_update_attr_curr_tx_bias(struct transvr_obj_s *self, - int show_err){ - - if (!(_sfp_is_diag_support(self))) { - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_tx_bias, - self->eeprom_map_p->page_tx_bias, - self->eeprom_map_p->offset_tx_bias, - self->eeprom_map_p->length_tx_bias, - self->curr_tx_bias, - "_sfp_update_attr_curr_tx_bias", - show_err); -} - - -static int -_sfp_update_attr_curr_tx_power(struct transvr_obj_s *self, - int show_err){ - - if (!(_sfp_is_diag_support(self))) { - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_tx_power, - self->eeprom_map_p->page_tx_power, - self->eeprom_map_p->offset_tx_power, - self->eeprom_map_p->length_tx_power, - self->curr_tx_power, - "_sfp_update_attr_curr_tx_power", - show_err); -} - - -static int -_sfp_update_attr_curr_rx_power(struct transvr_obj_s *self, - int show_err){ - - if (!(_sfp_is_diag_support(self))) { - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_rx_power, - self->eeprom_map_p->page_rx_power, - self->eeprom_map_p->offset_rx_power, - self->eeprom_map_p->length_rx_power, - self->curr_rx_power, - "_sfp_update_attr_curr_rx_power", - show_err); -} - - -static int -_sfp_update_attr_rx_em(struct transvr_obj_s *self, - int show_err){ - - if (!_is_transvr_support_ctle(self)) { - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_rx_em, - self->eeprom_map_p->page_rx_em, - self->eeprom_map_p->offset_rx_em, - self->eeprom_map_p->length_rx_em, - self->rx_em, - "_sfp_update_attr_rx_em", - show_err); -} - - -static int -_sfp_update_attr_tx_eq(struct transvr_obj_s *self, - int show_err){ - - if (!_is_transvr_support_ctle(self)) { - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_tx_eq, - self->eeprom_map_p->page_tx_eq, - self->eeprom_map_p->offset_tx_eq, - self->eeprom_map_p->length_tx_eq, - self->tx_eq, - "_sfp_update_attr_tx_eq", - show_err); -} - - -static int -_qsfp_update_attr_cdr(struct transvr_obj_s *self, - int show_err){ - if (self->type != TRANSVR_TYPE_QSFP_28){ - self->cdr = DEBUG_TRANSVR_HEX_VAL; - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_cdr, - self->eeprom_map_p->page_cdr, - self->eeprom_map_p->offset_cdr, - self->eeprom_map_p->length_cdr, - &(self->cdr), - "_common_update_attr_cdr", - show_err); -} - - -static int -_qsfg_update_attr_extbr(struct transvr_obj_s *self, - int show_err) { - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_extbr, - self->eeprom_map_p->page_extbr, - self->eeprom_map_p->offset_extbr, - self->eeprom_map_p->length_extbr, - &(self->extbr), - "_common_update_attr_extbr", - show_err); -} - - -static int -_qsfp_is_diag_support(struct transvr_obj_s *self, - int diag_type) { - /* Input Parm: diag_type - * => 1 : temperature - * => 2 : voltage - * => 3 : tx relate - * => 4 : rx relate - */ - uint8_t mask_b2 = 0x04; /* 0000 0100 */ - uint8_t mask_b3 = 0x08; /* 0000 1000 */ - - switch (diag_type) { - case 1: /* temperature */ - case 2: /* voltage */ - /* Direct access target, because of spec not defined */ - return 1; - case 3: - case 4: - /* [Note] - * Due to lot of transceiver vendor defined it not rigorously and - * consider of general support, we seem it as supported if there - * are bit-2 OR bit-3 defined by transceiver vendor. - */ - if ( ((self->diag_type & mask_b2) == mask_b2 ) || - ((self->diag_type & mask_b3) == mask_b3 ) ){ - return 1; - } - return 0; - default: - SWPS_INFO("%s: undefined diag_type:%d\n", - __func__, diag_type); - break; - } - return 0; -} - - -int -_qsfp_is_implement_tx_disable(struct transvr_obj_s *self) { - /* - * 00h / Byte-195 / Bit-4 - */ - int byte = 2; - int bit = 4; - return _common_get_option_value(self, byte, bit); -} - - -int -_qsfp_is_implement_tx_fault(struct transvr_obj_s *self) { - /* - * 00h / Byte-195 / Bit-3 - */ - int byte = 2; - int bit = 3; - return _common_get_option_value(self, byte, bit); -} - - -static int -_qsfp_update_attr_curr_temp(struct transvr_obj_s *self, - int show_err){ - int diag_type = 1; - - if (!(_qsfp_is_diag_support(self, diag_type))) { - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_temp, - self->eeprom_map_p->page_temp, - self->eeprom_map_p->offset_temp, - self->eeprom_map_p->length_temp, - self->curr_temp, - "_qsfp_update_attr_curr_temp", - show_err); -} - - -static int -_qsfp_update_attr_curr_voltage(struct transvr_obj_s *self, - int show_err){ - int diag_type = 2; - - if (!(_qsfp_is_diag_support(self, diag_type))) { - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_voltage, - self->eeprom_map_p->page_voltage, - self->eeprom_map_p->offset_voltage, - self->eeprom_map_p->length_voltage, - self->curr_voltage, - "_qsfp_update_attr_curr_voltage", - show_err); -} - - -static int -_qsfp_update_attr_curr_tx_bias(struct transvr_obj_s *self, - int show_err){ - int diag_type = 3; - - if (!(_qsfp_is_diag_support(self, diag_type))) { - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_tx_bias, - self->eeprom_map_p->page_tx_bias, - self->eeprom_map_p->offset_tx_bias, - self->eeprom_map_p->length_tx_bias, - self->curr_tx_bias, - "_qsfp_update_attr_curr_tx_bias", - show_err); -} - - -static int -_qsfp_update_attr_curr_tx_power(struct transvr_obj_s *self, - int show_err){ - int diag_type = 3; - - if (!(_qsfp_is_diag_support(self, diag_type))) { - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_tx_power, - self->eeprom_map_p->page_tx_power, - self->eeprom_map_p->offset_tx_power, - self->eeprom_map_p->length_tx_power, - self->curr_tx_power, - "_qsfp_update_attr_curr_tx_power", - show_err); -} - - -static int -_qsfp_update_attr_curr_rx_power(struct transvr_obj_s *self, - int show_err){ - int diag_type = 4; - - if (!(_qsfp_is_diag_support(self, diag_type))) { - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_rx_power, - self->eeprom_map_p->page_rx_power, - self->eeprom_map_p->offset_rx_power, - self->eeprom_map_p->length_rx_power, - self->curr_rx_power, - "_qsfp_update_attr_curr_rx_power", - show_err); -} - - -static int -_qsfp_update_attr_soft_rx_los(struct transvr_obj_s *self, - int show_err){ - - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_rx_los, - self->eeprom_map_p->page_rx_los, - self->eeprom_map_p->offset_rx_los, - self->eeprom_map_p->length_rx_los, - &(self->rx_los), - "_qsfp_update_attr_soft_rx_los", - show_err); -} - - -static int -_qsfp_update_attr_soft_tx_disable(struct transvr_obj_s *self, - int show_err){ - - if (!_qsfp_is_implement_tx_disable(self)) { - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_tx_disable, - self->eeprom_map_p->page_tx_disable, - self->eeprom_map_p->offset_tx_disable, - self->eeprom_map_p->length_tx_disable, - &(self->tx_disable), - "_qsfp_update_attr_soft_tx_disable", - show_err); -} - - -static int -_qsfp_update_attr_soft_tx_fault(struct transvr_obj_s *self, - int show_err){ - - if (!_qsfp_is_implement_tx_fault(self)) { - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_tx_fault, - self->eeprom_map_p->page_tx_fault, - self->eeprom_map_p->offset_tx_fault, - self->eeprom_map_p->length_tx_fault, - &(self->tx_fault), - "_qsfp_update_attr_soft_tx_fault", - show_err); -} - - -static int -_qsfp_update_attr_tx_eq(struct transvr_obj_s *self, - int show_err){ - - if (!_is_transvr_support_ctle(self)) { - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_tx_eq, - self->eeprom_map_p->page_tx_eq, - self->eeprom_map_p->offset_tx_eq, - self->eeprom_map_p->length_tx_eq, - self->tx_eq, - "_qsfp_update_attr_tx_eq", - show_err); -} - - -static int -_qsfp_update_attr_rx_am(struct transvr_obj_s *self, - int show_err){ - - if (!_is_transvr_support_ctle(self)) { - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_rx_am, - self->eeprom_map_p->page_rx_am, - self->eeprom_map_p->offset_rx_am, - self->eeprom_map_p->length_rx_am, - self->rx_am, - "_qsfp_update_attr_rx_am", - show_err); -} - - -static int -_qsfp_update_attr_rx_em(struct transvr_obj_s *self, - int show_err){ - - if (!_is_transvr_support_ctle(self)) { - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_rx_em, - self->eeprom_map_p->page_rx_em, - self->eeprom_map_p->offset_rx_em, - self->eeprom_map_p->length_rx_em, - self->rx_em, - "_qsfp_update_attr_rx_em", - show_err); -} - - -int -_common_update_attr_all(struct transvr_obj_s *self, - int show_err){ - - char *err_str = "err"; - - if (_common_update_attr_id(self, show_err) < 0) { - err_str = "_common_update_attr_id"; - goto err_common_update_attr_all; - } - if (_common_update_attr_extended_id(self, show_err) < 0) { - err_str = "_common_update_attr_extended_id"; - goto err_common_update_attr_all; - } - if (_common_update_attr_connector(self, show_err) < 0) { - err_str = "_common_update_attr_connector"; - goto err_common_update_attr_all; - } - if (_common_update_attr_transvr_comp(self, show_err) < 0) { - err_str = "_common_update_attr_transvr_comp"; - goto err_common_update_attr_all; - } - if (_common_update_attr_transvr_comp_ext(self, show_err) < 0) { - err_str = "_common_update_attr_transvr_comp_ext"; - goto err_common_update_attr_all; - } - if (_common_update_attr_vendor_name(self, show_err) < 0) { - err_str = "_common_update_attr_vendor_name"; - goto err_common_update_attr_all; - } - if (_common_update_attr_vendor_pn(self, show_err) < 0) { - err_str = "_common_update_attr_vendor_pn"; - goto err_common_update_attr_all; - } - if (_common_update_attr_vendor_rev(self, show_err) < 0) { - err_str = "_common_update_attr_vendor_rev"; - goto err_common_update_attr_all; - } - if (_common_update_attr_vendor_sn(self, show_err) < 0) { - err_str = "_common_update_attr_vendor_sn"; - goto err_common_update_attr_all; - } - if (_common_update_attr_br(self, show_err) < 0) { - err_str = "_common_update_attr_br"; - goto err_common_update_attr_all; - } - if (_common_update_attr_len_smf(self, show_err) < 0) { - err_str = "_common_update_attr_len_smf"; - goto err_common_update_attr_all; - } - if (_common_update_attr_len_om1(self, show_err) < 0) { - err_str = "_common_update_attr_len_om1"; - goto err_common_update_attr_all; - } - if (_common_update_attr_len_om2(self, show_err) < 0) { - err_str = "_common_update_attr_len_om2"; - goto err_common_update_attr_all; - } - if (_common_update_attr_len_om3(self, show_err) < 0) { - err_str = "_common_update_attr_len_om3"; - goto err_common_update_attr_all; - } - if (_common_update_attr_len_om4(self, show_err) < 0) { - err_str = "_common_update_attr_len_om4"; - goto err_common_update_attr_all; - } - if (_common_update_attr_option(self, show_err) < 0) { - err_str = "_common_update_attr_option"; - goto err_common_update_attr_all; - } - if (_common_update_attr_comp_rev(self, show_err) < 0) { - err_str = "_common_update_attr_comp_rev"; - goto err_common_update_attr_all; - } - if (_common_update_attr_diag_type(self, show_err) < 0) { - err_str = "_common_update_attr_diag_type"; - goto err_common_update_attr_all; - } - if (_common_update_attr_wavelength(self, show_err) < 0) { - err_str = "_common_update_attr_wavelength"; - goto err_common_update_attr_all; - } - if (_common_update_attr_eeprom(self, show_err) < 0) { - err_str = "_common_update_attr_eeprom"; - goto err_common_update_attr_all; - } - return 0; - -err_common_update_attr_all: - if (show_err){ - SWPS_INFO("%s: fail at:%s :%s\n", __func__, err_str, self->swp_name); - } - return -1; -} - - -int -_sfp_update_attr_all(struct transvr_obj_s *self, - int show_err){ - - char *err_str = DEBUG_TRANSVR_STR_VAL; - - if (_common_update_attr_all(self, show_err) < 0){ - err_str = "_common_update_attr_all"; - goto err_sfp_update_attr_all; - } - if (_sfp_update_attr_len_sm(self, show_err) < 0) { - err_str = "_sfp_update_attr_len_sm"; - goto err_sfp_update_attr_all; - } - if (_sfp_update_attr_rate_id(self, show_err) < 0) { - err_str = "_sfp_update_attr_rate_id"; - goto err_sfp_update_attr_all; - } - if ((self->rate_id) > 0) { - if (_sfp_update_attr_soft_rs0(self, show_err) < 0) { - err_str = "_sfp_update_attr_soft_rs0"; - goto err_sfp_update_attr_all; - } - if (_sfp_update_attr_soft_rs1(self, show_err) < 0) { - err_str = "_sfp_update_attr_soft_rs1"; - goto err_sfp_update_attr_all; - } - } - return 0; - -err_sfp_update_attr_all: - if (show_err){ - SWPS_INFO("%s: fail at:%s :%s\n", __func__, err_str, self->swp_name); - } - return -1; -} - - -int -_qsfp_update_attr_all(struct transvr_obj_s *self, - int show_err){ - - char *err_str = DEBUG_TRANSVR_STR_VAL; - - if (_common_update_attr_all(self, show_err) < 0){ - err_str = "_common_update_attr_all"; - goto err_qsfp_update_attr_all; - } - if (_qsfg_update_attr_extbr(self, show_err) < 0) { - err_str = "_qsfg_update_attr_extbr"; - goto err_qsfp_update_attr_all; - } - if (self->type == TRANSVR_TYPE_QSFP_28) { - if (_qsfp_update_attr_cdr(self, 1) < 0) { - err_str = "_qsfp_update_attr_cdr"; - goto err_qsfp_update_attr_all; - } - } - return 0; - -err_qsfp_update_attr_all: - if (show_err){ - SWPS_INFO("%s: fail at:%s :%s\n", __func__, err_str, self->swp_name); - } - return -1; -} - - -/* ========== Object functions for common type ========== - */ -int -_common_count_temp(uint8_t high_byte, - uint8_t low_byte, - char *buf_p) { - int sign = 0; - int high = 0; - int low = 0; - int lmax = 8; - - /* Count high */ - sign = get_bit(high_byte,7); - SWP_BIT_CLEAR(high_byte, 7); - high = (int)high_byte; - if (sign == 1) { - high = 0 - high; - } - /* Count low */ - low = (get_bit(low_byte, 7) * 500); - low += (get_bit(low_byte, 6) * 250); - low += (get_bit(low_byte, 5) * 125); - low += (get_bit(low_byte, 4) * 62); - low = (low / 100); - /* Integrate High and Low */ - return snprintf(buf_p, lmax, "%d.%d\n", high, low); -} - - -int -_common_count_voltage(uint8_t high_byte, - uint8_t low_byte, - char *buf_p) { - /* [Note]: - * Internally measured transceiver supply voltage. Represented - * as a 16 bit unsigned integer with the voltage defined as the - * full 16 bit value (0-65535) with LSB equal to 100 uVolt, - * yielding a total range of 0 to +6.55 Volts. Practical - * considerations to be defined by transceiver manufacturer will - * tend to limit the actual bounds of the supply voltage measurement. - * Accuracy is vendor specific but must be better than 3% of the - * manufacturer's nominal value over specified operating temperature - * and voltage. Note that in some transceivers, transmitter supply - * voltage and receiver supply voltage are isolated. In that case, - * only one supply is monitored. Refer to the device specification - * for more detail. - */ - int total = 0; - int lmax = 8; - int val_i = 0; - int val_f = 0; - /* unit: 100 uV (1mV=1000uV) */ - total = transform_word_to_int(high_byte, low_byte); - val_i = ((total/10) / 1000); - val_f = ((total/10) - (val_i*1000)); - /* Return Unit: 1 Volt */ - return snprintf(buf_p, lmax, "%d.%03d\n", val_i, val_f); -} - - -int -_common_count_tx_bias(uint8_t high_byte, - uint8_t low_byte, - char *buf_p) { - /* [Note] - * Measured TX bias current in uA. Represented as a 16 bit unsigned - * integer with the current defined as the full 16 bit value (0-65535) - * with LSB equal to 2 uA, yielding a total range of 0 to 131 mA. - * Accuracy is vendor specific but must be better than 10% of the - * manufacturer's nominal value over specified operating temperature - * and voltage. - */ - int total = 0; - int lmax = 8; - int val_i = 0; - int val_f = 0; - /* unit: 2 uA (1mA=1000uA) */ - total = transform_word_to_int(high_byte, low_byte); - val_i = ((total*2) / 1000); - val_f = (((total*2) - (val_i*1000)) / 100); - /* Return Unit: 1 mA */ - return snprintf(buf_p, lmax, "%d.%01d\n", val_i, val_f); -} - - -int -_common_count_tx_power(uint8_t high_byte, - uint8_t low_byte, - char *buf_p) { - /* [Note] - * Measured TX output power in mW. Represented as a 16 bit unsigned - * integer with the power defined as the full 16 bit value (0-65535) - * with LSB equal to 0.1 uW, yielding a total range of 0 to 6.5535 mW - * (~ -40 to +8.2 dBm). Data is assumed to be based on measurement of - * laser monitor photodiode current. It is factory calibrated to absolute - * units using the most representative fiber output type. Accuracy is - * vendor specific but must be better than 3dB over specified temperature - * and voltage. Data is not valid when the transmitter is disabled. - */ - int total = 0; - int lmax = 8; - int val_i = 0; - int val_f = 0; - /* unit: 0.1 uW (1mW=1000uW) */ - total = transform_word_to_int(high_byte, low_byte); - val_i = ((total/10) / 1000); - val_f = ((total/10) - (val_i*1000)); - /* Return Unit: 1 mW */ - return snprintf(buf_p, lmax, "%d.%03d\n", val_i, val_f); -} - - -int -_common_count_rx_power(uint8_t high_byte, - uint8_t low_byte, - char *buf_p) { - /* [Note] - * Measured RX received optical power in mW. Value can represent either - * average received power or OMA depending upon how bit 3 of byte 92 (A0h) - * is set. Represented as a 16 bit unsigned integer with the power defined - * as the full 16 bit value (0-65535) with LSB equal to 0.1 uW, yielding a - * total range of 0 to 6.5535 mW (~ -40 to +8.2 dBm). Absolute accuracy is - * dependent upon the exact optical wavelength. For the vendor specified - * wavelength, accuracy shall be better than 3dB over specified temperature - * and voltage. - */ - int total = 0; - int lmax = 8; - int val_i = 0; - int val_f = 0; - /* unit: 0.1 uW (1mW=1000uW) */ - total = transform_word_to_int(high_byte, low_byte); - val_i = ((total/10) / 1000); - val_f = ((total/10) - (val_i*1000)); - /* Return Unit: 1 mW */ - return snprintf(buf_p, lmax, "%d.%03d\n", val_i, val_f); -} - - -int -_common_count_wavelength(struct transvr_obj_s *self, - uint8_t high_byte, - uint8_t low_byte) { - /* [Note] - * SFP : uint 1 um. - * QSFP: unit 0.05 um. - */ - int total = 0; - - total = transform_word_to_int(high_byte, low_byte); - switch (self->type) { - case TRANSVR_TYPE_SFP: - return total; - - case TRANSVR_TYPE_QSFP: - case TRANSVR_TYPE_QSFP_PLUS: - case TRANSVR_TYPE_QSFP_28: - return (total/20); - - default: - break; - } - return ERR_TRANSVR_UNDEFINED; -} - - -int -common_get_id(struct transvr_obj_s *self){ - - int err_code = _check_by_mode(self, - &_common_update_attr_id, - "common_get_id"); - if (err_code < 0){ - return err_code; - } - /* Transform to INT to show error case */ - return (int)self->id; -} - - -int -common_get_ext_id(struct transvr_obj_s *self){ - - int err_code = _check_by_mode(self, - &_common_update_attr_extended_id, - "common_get_ext_id"); - if (err_code < 0){ - return err_code; - } - /* Transform to INT to show error case */ - return (int)self->ext_id; -} - - -int -common_get_connector(struct transvr_obj_s *self){ - - int err_code = _check_by_mode(self, - &_common_update_attr_connector, - "common_get_connector"); - if (err_code < 0){ - return err_code; - } - /* Transform to INT to show error case */ - return (int)self->connector; -} - - -int -common_get_vendor_name(struct transvr_obj_s *self, char *buf){ - - int err = DEBUG_TRANSVR_INT_VAL; - - if (self->state == STATE_TRANSVR_CONNECTED && - self->mode == TRANSVR_MODE_POLLING && - TRANSVR_INFO_CACHE_ENABLE) { - return snprintf(buf, LEN_TRANSVR_M_STR, "%s\n", self->vendor_name); - } - err = _check_by_mode(self, - &_common_update_attr_vendor_name, - "common_get_vendor_name"); - memset(buf, 0, LEN_TRANSVR_M_STR); - if (err < 0){ - return snprintf(buf, LEN_TRANSVR_M_STR, "%d\n", err); - } - return snprintf(buf, LEN_TRANSVR_M_STR, "%s\n", self->vendor_name); -} - - -int -common_get_vendor_pn(struct transvr_obj_s *self, char *buf) { - - int err = DEBUG_TRANSVR_INT_VAL; - - if (self->state == STATE_TRANSVR_CONNECTED && - self->mode == TRANSVR_MODE_POLLING && - TRANSVR_INFO_CACHE_ENABLE) { - return snprintf(buf, LEN_TRANSVR_M_STR, "%s\n", self->vendor_pn); - } - err = _check_by_mode(self, - &_common_update_attr_vendor_pn, - "common_get_vendor_pn"); - memset(buf, 0, LEN_TRANSVR_M_STR); - if (err < 0){ - return snprintf(buf, LEN_TRANSVR_M_STR, "%d\n", err); - } - return snprintf(buf, LEN_TRANSVR_M_STR, "%s\n", self->vendor_pn); -} - - -int -common_get_vendor_rev(struct transvr_obj_s *self, char *buf) { - - int err = DEBUG_TRANSVR_INT_VAL; - - if (self->state == STATE_TRANSVR_CONNECTED && - self->mode == TRANSVR_MODE_POLLING && - TRANSVR_INFO_CACHE_ENABLE) { - return snprintf(buf, LEN_TRANSVR_M_STR, "%s\n", self->vendor_rev); - } - err = _check_by_mode(self, - &_common_update_attr_vendor_rev, - "common_get_vendor_rev"); - memset(buf, 0, LEN_TRANSVR_M_STR); - if (err < 0){ - return snprintf(buf, LEN_TRANSVR_M_STR, "%d\n", err); - } - return snprintf(buf, LEN_TRANSVR_M_STR, "%s\n", self->vendor_rev); -} - - -int -common_get_vendor_sn(struct transvr_obj_s *self, char *buf) { - - int err = DEBUG_TRANSVR_INT_VAL; - - if (self->state == STATE_TRANSVR_CONNECTED && - self->mode == TRANSVR_MODE_POLLING && - TRANSVR_INFO_CACHE_ENABLE) { - return snprintf(buf, LEN_TRANSVR_M_STR, "%s\n", self->vendor_sn); - } - err = _check_by_mode(self, - &_common_update_attr_vendor_sn, - "common_get_vendor_sn"); - memset(buf, 0, LEN_TRANSVR_M_STR); - if (err < 0){ - return snprintf(buf, LEN_TRANSVR_M_STR, "%d\n", err); - } - return snprintf(buf, LEN_TRANSVR_M_STR, "%s\n", self->vendor_sn); -} - - -int -common_get_br(struct transvr_obj_s *self){ - - int err = DEBUG_TRANSVR_INT_VAL; - - if (self->state == STATE_TRANSVR_CONNECTED && - self->mode == TRANSVR_MODE_POLLING && - TRANSVR_INFO_CACHE_ENABLE) { - return (int)self->br; - } - err = _check_by_mode(self, - &_common_update_attr_br, - "common_get_br"); - if (err < 0){ - return err; - } - /* Transform to INT to show error case */ - return (int)self->br; -} - - -int -common_get_len_smf(struct transvr_obj_s *self){ - - int err = DEBUG_TRANSVR_INT_VAL; - - if (self->state == STATE_TRANSVR_CONNECTED && - self->mode == TRANSVR_MODE_POLLING && - TRANSVR_INFO_CACHE_ENABLE) { - return self->len_smf; - } - err = _check_by_mode(self, - &_common_update_attr_len_smf, - "common_get_len_smf"); - if (err < 0){ - return err; - } - return self->len_smf; -} - - -int -common_get_len_om1(struct transvr_obj_s *self){ - - int err = DEBUG_TRANSVR_INT_VAL; - - if (self->state == STATE_TRANSVR_CONNECTED && - self->mode == TRANSVR_MODE_POLLING && - TRANSVR_INFO_CACHE_ENABLE) { - return self->len_om1; - } - err = _check_by_mode(self, - &_common_update_attr_len_om1, - "common_get_len_om1"); - if (err < 0){ - return err; - } - return self->len_om1; -} - - -int -common_get_len_om2(struct transvr_obj_s *self){ - - int err = DEBUG_TRANSVR_INT_VAL; - - if (self->state == STATE_TRANSVR_CONNECTED && - self->mode == TRANSVR_MODE_POLLING && - TRANSVR_INFO_CACHE_ENABLE) { - return self->len_om2; - } - - err = _check_by_mode(self, - &_common_update_attr_len_om2, - "common_get_len_om2"); - if (err < 0){ - return err; - } - return self->len_om2; -} - - -int -common_get_len_om3(struct transvr_obj_s *self){ - - int err = DEBUG_TRANSVR_INT_VAL; - - if (self->state == STATE_TRANSVR_CONNECTED && - self->mode == TRANSVR_MODE_POLLING && - TRANSVR_INFO_CACHE_ENABLE) { - return self->len_om3; - } - - err = _check_by_mode(self, - &_common_update_attr_len_om3, - "common_get_len_om3"); - if (err < 0){ - return err; - } - return self->len_om3; -} - - -int -common_get_len_om4(struct transvr_obj_s *self){ - - int err = DEBUG_TRANSVR_INT_VAL; - - if (self->state == STATE_TRANSVR_CONNECTED && - self->mode == TRANSVR_MODE_POLLING && - TRANSVR_INFO_CACHE_ENABLE) { - return self->len_om4; - } - err = _check_by_mode(self, - &_common_update_attr_len_om4, - "common_get_len_om4"); - if (err < 0){ - return err; - } - return self->len_om4; -} - - -int -common_get_comp_extended(struct transvr_obj_s *self){ - - int err_code = _check_by_mode(self, - &_common_update_attr_transvr_comp_ext, - "common_get_comp_extended"); - if (err_code < 0){ - return err_code; - } - return self->transvr_comp_ext; -} - - -int -common_get_comp_rev(struct transvr_obj_s *self){ - - int err_code = _check_by_mode(self, - &_common_update_attr_comp_rev, - "common_get_comp_rev"); - if (err_code < 0){ - return err_code; - } - return self->comp_rev; -} - - -int -common_get_info(struct transvr_obj_s *self){ - - if (self->state != STATE_TRANSVR_CONNECTED) { - return self->state; - } - return self->info; -} - -int -common_get_eeprom(struct transvr_obj_s *self, char *buf){ - - int err = DEBUG_TRANSVR_INT_VAL; - unsigned char *eeprom_update = get_eeprom_update(); - - if (!(eeprom_update[self->port_no/8] & (1 << self->port_no%8)) && - (self->state == STATE_TRANSVR_CONNECTED && - self->mode == TRANSVR_MODE_POLLING && - TRANSVR_INFO_CACHE_ENABLE)) { - memset(buf, 0, self->eeprom_map_p->length_eeprom); - memcpy(buf, self->eeprom, self->eeprom_map_p->length_eeprom); - *(buf+self->eeprom_map_p->length_eeprom) = '\n'; - return self->eeprom_map_p->length_eeprom; - } - err = _check_by_mode(self, &_common_update_attr_eeprom, - "common_get_eeprom"); - if (err < 0){ - return snprintf(buf, LEN_TRANSVR_M_STR, "%d\n", err); - } - memset(buf, 0, self->eeprom_map_p->length_eeprom); - memcpy(buf, self->eeprom, self->eeprom_map_p->length_eeprom); - *(buf+self->eeprom_map_p->length_eeprom) = '\n'; - eeprom_update[self->port_no/8] &= ~(1 << self->port_no%8); - set_eeprom_update(eeprom_update); - return self->eeprom_map_p->length_eeprom; -} - - -int -_common_get_if_lane(struct transvr_obj_s *self, - char *result){ - int i = 0; - int tmp_val = 0; - char tmp_str[LEN_TRANSVR_M_STR] = DEBUG_TRANSVR_STR_VAL; - - memset(result, 0, LEN_TRANSVR_M_STR); - - for (i=0; ilane_id); i++) { - tmp_val = self->lane_id[i]; - if (tmp_val < 1) { - break; - } - memset(tmp_str, 0, LEN_TRANSVR_M_STR); - if (i == 0) { - snprintf(tmp_str, LEN_TRANSVR_M_STR, "%d", tmp_val); - } else { - snprintf(tmp_str, LEN_TRANSVR_M_STR, ",%d", tmp_val); - } - strncat(result, tmp_str, LEN_TRANSVR_M_STR); - } - if (i == 0) { - return EVENT_TRANSVR_TASK_FAIL; - } - return 0; -} - - -int -common_get_if_lane(struct transvr_obj_s *self, - char *buf_p){ - - char tmp_str[LEN_TRANSVR_M_STR] = DEBUG_TRANSVR_STR_VAL; - - if (self->ioexp_obj_p->state != STATE_IOEXP_NORMAL) { - return snprintf(buf_p, LEN_TRANSVR_M_STR, "%d\n", ERR_TRANSVR_ABNORMAL); - } - if (_common_get_if_lane(self, tmp_str) < 0) { - return snprintf(buf_p, LEN_TRANSVR_M_STR, "%d\n" ,ERR_TRANSVR_ABNORMAL); - } - return snprintf(buf_p, LEN_TRANSVR_M_STR, "%s\n" ,tmp_str); -} - - -int -sfp_get_len_sm(struct transvr_obj_s *self){ - - int err_code = _check_by_mode(self, - &_sfp_update_attr_len_sm, - "sfp_get_len_sm"); - if (err_code < 0){ - return err_code; - } - return self->len_sm; -} - - -int -sfp_get_rate_id(struct transvr_obj_s *self){ - - int err_code = _check_by_mode(self, - &_sfp_update_attr_rate_id, - "sfp_get_rate_id"); - if (err_code < 0){ - return err_code; - } - return self->rate_id; -} - - -int -sfp_get_soft_rs0(struct transvr_obj_s *self){ - /* Note: - * SFP Soft Rate_Select Select [aka. "RS(0)"] address - * A2h, offset: 110, bit 3 (begin form 0) - */ - int err_code = DEBUG_TRANSVR_INT_VAL; - int bit_shift = 3; - uint8_t result = 0x00; - uint8_t bitmask = (1 << bit_shift); - - /* Check rate identifier is supported */ - err_code = self->get_rate_id(self); - if (err_code <= 0) { - return ERR_TRANSVR_NOTSUPPORT; - } - /* Update and check */ - err_code = _check_by_mode(self, - &_sfp_update_attr_soft_rs0, - "sfp_get_soft_rs0"); - if (err_code <0){ - return err_code; - } - result = (self->soft_rs0 & bitmask); - if (result == bitmask) { - return 1; - } - if (result == 0) { - return 0; - } - return ERR_TRANSVR_UNEXCPT; -} - - -int -sfp_get_soft_rs1(struct transvr_obj_s *self){ - /* Note: - * SFP Soft RS(1) Select address - * A2h, offset: 118, bit 3 (begin form 0) - */ - int err_code = DEBUG_TRANSVR_INT_VAL; - int bit_shift = 3; - uint8_t result = 0x00; - uint8_t bitmask = (1 << bit_shift); - - /* Check rate identifier is supported */ - err_code = self->get_rate_id(self); - if (err_code <= 0) { - return ERR_TRANSVR_NOTSUPPORT; - } - /* Update and check */ - err_code = _check_by_mode(self, - &_sfp_update_attr_soft_rs1, - "sfp_get_soft_rs1"); - if (err_code <0){ - return err_code; - } - result = (self->soft_rs1 & bitmask); - if (result == bitmask) { - return 1; - } - if (result == 0) { - return 0; - } - return ERR_TRANSVR_UNEXCPT; -} - - -int -sfp_get_transvr_temp(struct transvr_obj_s *self, - char *buf_p) { - - int lmax = 8; - int err_code = DEBUG_TRANSVR_INT_VAL; - - err_code = _check_by_mode(self, - &_sfp_update_attr_curr_temp, - "sfp_get_transvr_temp"); - if (err_code < 0) { - return snprintf(buf_p, lmax, "%d\n", err_code); - } - if ((self->curr_temp[0]) == DEBUG_TRANSVR_HEX_VAL) { - return snprintf(buf_p, lmax, "%d\n", ERR_TRANSVR_UPDATE_FAIL); - } - return _common_count_temp(self->curr_temp[0], - self->curr_temp[1], - buf_p); -} - - -int -sfp_get_transvr_voltage(struct transvr_obj_s *self, - char *buf_p) { - - int lmax = 8; - int err_code = DEBUG_TRANSVR_INT_VAL; - - err_code = _check_by_mode(self, - &_sfp_update_attr_curr_voltage, - "sfp_get_transvr_voltage"); - if (err_code < 0) { - return snprintf(buf_p, lmax, "%d\n", err_code); - } - if ((self->curr_voltage[0]) == DEBUG_TRANSVR_HEX_VAL) { - return snprintf(buf_p, lmax, "%d\n", ERR_TRANSVR_UPDATE_FAIL); - } - /* Return Unit: 1 Volt */ - return _common_count_voltage(self->curr_voltage[0], - self->curr_voltage[1], - buf_p); -} - - -int -sfp_get_transvr_tx_bias(struct transvr_obj_s *self, - char *buf_p) { - - int lmax = 8; - int err_code = DEBUG_TRANSVR_INT_VAL; - - err_code = _check_by_mode(self, - &_sfp_update_attr_curr_tx_bias, - "sfp_get_transvr_tx_bias"); - if (err_code < 0) { - return snprintf(buf_p, lmax, "%d\n", err_code); - } - if ((self->curr_tx_bias[0]) == DEBUG_TRANSVR_HEX_VAL) { - return snprintf(buf_p, lmax, "%d\n", ERR_TRANSVR_UPDATE_FAIL); - } - /* Return Unit: 1 mA */ - return _common_count_tx_bias(self->curr_tx_bias[0], - self->curr_tx_bias[1], - buf_p); -} - - -int -sfp_get_transvr_tx_power(struct transvr_obj_s *self, - char *buf_p) { - - int lmax = 8; - int err_code = DEBUG_TRANSVR_INT_VAL; - - err_code = _check_by_mode(self, - &_sfp_update_attr_curr_tx_power, - "sfp_get_transvr_tx_power"); - if (err_code < 0) { - return snprintf(buf_p, lmax, "%d\n", err_code); - } - if ((self->curr_tx_bias[0]) == DEBUG_TRANSVR_HEX_VAL) { - return snprintf(buf_p, lmax, "%d\n", ERR_TRANSVR_UPDATE_FAIL); - } - /* Return Unit: 1 mW */ - return _common_count_tx_power(self->curr_tx_power[0], - self->curr_tx_power[1], - buf_p); -} - - -int -sfp_get_transvr_rx_power(struct transvr_obj_s *self, - char *buf_p) { - - int lmax = 8; - int err_code = DEBUG_TRANSVR_INT_VAL; - - err_code = _check_by_mode(self, - &_sfp_update_attr_curr_rx_power, - "sfp_get_transvr_rx_power"); - if (err_code < 0) { - return snprintf(buf_p, lmax, "%d\n", err_code); - } - if ((self->curr_tx_bias[0]) == DEBUG_TRANSVR_HEX_VAL) { - return snprintf(buf_p, lmax, "%d\n", ERR_TRANSVR_UPDATE_FAIL); - } - /* Return Unit: 1 mW */ - return _common_count_rx_power(self->curr_rx_power[0], - self->curr_rx_power[0], - buf_p); -} - - -int -sfp_get_transvr_rx_em(struct transvr_obj_s *self, - char *buf_p) { - - int limt = 8; - int err = DEBUG_TRANSVR_INT_VAL; - - err = _check_by_mode(self, - &_sfp_update_attr_rx_em, - "sfp_get_transvr_rx_em"); - if (err < 0) { - return snprintf(buf_p, limt, "%d\n", err); - } - if ((self->tx_eq[0]) == DEBUG_TRANSVR_HEX_VAL) { - return snprintf(buf_p, limt, "%d\n", ERR_TRANSVR_UPDATE_FAIL); - } - return snprintf(buf_p, limt, "0x%02x\n", self->rx_em[0]); -} - - -int -sfp_get_transvr_tx_eq(struct transvr_obj_s *self, - char *buf_p) { - - int limt = 8; - int err = DEBUG_TRANSVR_INT_VAL; - - err = _check_by_mode(self, - &_sfp_update_attr_tx_eq, - "sfp_get_transvr_tx_eq"); - if (err < 0) { - return snprintf(buf_p, limt, "%d\n", err); - } - if ((self->tx_eq[0]) == DEBUG_TRANSVR_HEX_VAL) { - return snprintf(buf_p, limt, "%d\n", ERR_TRANSVR_UPDATE_FAIL); - } - return snprintf(buf_p, limt, "0x%02x\n", self->tx_eq[0]); -} - - -int -_sfp_get_comp_extended(struct transvr_obj_s *self) { - /* Address: A0h / 36 - * Reference: SFF-8024 TABLE 4-4 - */ - if ((self->state == STATE_TRANSVR_CONNECTED) || - (self->state == STATE_TRANSVR_INIT) ) { - return (int)(self->transvr_comp_ext); - } - return ERR_TRANSVR_ABNORMAL; -} - - -int -__sfp_get_comp_attr(struct transvr_obj_s *self, - int array_offset) { - /* SFP Specification Compliance: A0h / 3-10 - * transvr_comp[0-7] = 3 - 10 - */ - if ((self->state == STATE_TRANSVR_CONNECTED) || - (self->state == STATE_TRANSVR_INIT) ) { - return (int)(self->transvr_comp[array_offset]); - } - return ERR_TRANSVR_ABNORMAL; -} - - -int -_sfp_get_comp_10g_eth_comp(struct transvr_obj_s *self) { - /* transvr_comp[0] = address A0h / 3 - * - * 3 7: 10G Base-ER - * 3 6: 10GBASE-LRM - * 3 5: 10GBASE-LR - * 3 4: 10GBASE-SR - */ - int bitmask = 0xf0; /* 11110000 */ - return (__sfp_get_comp_attr(self, 0) & bitmask); -} - - -int -_sfp_get_comp_1g_eth_comp(struct transvr_obj_s *self) { - /* transvr_comp[3] = address A0h / 6 - * - * 6 7: BASE-PX *3 - * 6 6: BASE-BX10 *3 - * 6 5: 100BASE-FX - * 6 4: 100BASE-LX/LX10 - * 6 3: 1000BASE-T - * 6 2: 1000BASE-CX - * 6 1: 1000BASE-LX *3 - * 6 0: 1000BASE-SX - */ - return __sfp_get_comp_attr(self, 3); -} - - -int -_sfp_get_cable_tech(struct transvr_obj_s *self) { - /* transvr_comp[5] = address A0h / 8 - * - * 8 3: Active Cable *8 - * 8 2: Passive Cable *8 - */ - int bitmask = 0x0c; /* 00001100 */ - return (__sfp_get_comp_attr(self, 5) & bitmask); -} - - -int -sfp_get_comp_eth_1(struct transvr_obj_s *self){ - - int err_code = _check_by_mode(self, - &_common_update_attr_transvr_comp, - "sfp_get_comp_eth_1"); - if (err_code < 0){ - return err_code; - } - return _sfp_get_comp_1g_eth_comp(self); -} - - -int -sfp_get_comp_eth_10(struct transvr_obj_s *self){ - - int err_code = _check_by_mode(self, - &_common_update_attr_transvr_comp, - "sfp_get_comp_eth_10"); - if (err_code < 0){ - return err_code; - } - return _sfp_get_comp_10g_eth_comp(self); -} - - -int -_sfp_get_connector_type(struct transvr_obj_s *self) { - /* Address: A0h / 2 - * Reference: SFF-8024 TABLE 4-3 - */ - if ((self->state == STATE_TRANSVR_CONNECTED) || - (self->state == STATE_TRANSVR_INIT) ) { - return (int)(self->connector); - } - return ERR_TRANSVR_ABNORMAL; -} - - -int -sfp_get_wavelength(struct transvr_obj_s *self, - char *buf_p) { - /* [Note] Optical and Cable Variants Specification Compliance (SFF-8472) - * [Addr] A0h, Bytes 60-61 - * [Note] For optical variants, as defined by having zero's in A0h Byte 8 - * bits 2 and 3, Bytes 60 and 61 denote nominal transmitter output - * wavelength at room temperature. 16 bit value with byte 60 as high - * order byte and byte 61 as low order byte. The laser wavelength is - * equal to the 16 bit integer value in nm. This field allows the user - * to read the laser wavelength directly, so it is not necessary to - * infer it from the Transceiver Codes A0h Bytes 3 to 10 (see Table - * 5-3). This also allows specification of wavelengths not covered - * in the Transceiver Codes, such as those used in coarse WDM systems. - * - * For passive and active cable variants, a value of 00h for both A0h - * Byte 60 and Byte 61 denotes laser wavelength or cable specification - * compliance is unspecified. - */ - - int lmax = 8; - int err_code = DEBUG_TRANSVR_INT_VAL; - - err_code = _check_by_mode(self, - &_common_update_attr_wavelength, - "common_get_wavelength"); - if (err_code < 0) { - return snprintf(buf_p, lmax, "%d\n", err_code); - } - if ((self->wavelength[0]) == DEBUG_TRANSVR_HEX_VAL) { - return snprintf(buf_p, lmax, "%d\n", ERR_TRANSVR_UPDATE_FAIL); - } - /* unit: 1 um */ - return snprintf(buf_p, lmax, "%d\n", - _common_count_wavelength(self, - self->wavelength[0], - self->wavelength[1])); -} - - -int -sfp_get_1g_rj45_extphy_offset(struct transvr_obj_s *self, char *buf) { - - if (self->state != STATE_TRANSVR_CONNECTED) { - return ERR_TRANSVR_UNPLUGGED; - } - if ((self->info != TRANSVR_CLASS_BASE_T_1000) && - (self->info != TRANSVR_CLASS_BASE_T_1000_up) ){ - return ERR_TRANSVR_NOTSUPPORT; - } - return snprintf(buf, LEN_TRANSVR_S_STR, "0x%02x\n", self->extphy_offset); -} - - -int -sfp_get_1g_rj45_extphy_reg(struct transvr_obj_s *self, char *buf) { - - int i = 0; - int ret = 0; - int retry = 3; - int delay = 200; - - if (self->state != STATE_TRANSVR_CONNECTED) { - return ERR_TRANSVR_UNPLUGGED; - } - if ((self->info != TRANSVR_CLASS_BASE_T_1000) && - (self->info != TRANSVR_CLASS_BASE_T_1000_up) ){ - return ERR_TRANSVR_NOTSUPPORT; - } - if (_common_setup_page(self, VAL_TRANSVR_EXTPHY_ADDR_56, - -1, self->extphy_offset, 1, 0) < 0) { - return -EIO; - } - for (i=0; ii2c_client_p, self->extphy_offset); - if (ret >=0) { - goto ok_sfp_get_1g_rj45_extphy_reg; - } - msleep(delay); - } - SWPS_INFO("%s: retry:%d fail :%s :0x%02x\n", - __func__, retry, self->swp_name, self->extphy_offset); - return -EIO; - -ok_sfp_get_1g_rj45_extphy_reg: - ret = ((ret & 0x00ff) << 8) | ((ret & 0xff00) >> 8); - return snprintf(buf, LEN_TRANSVR_S_STR, "0x%04x\n", ret); -} - - -int -__qsfp_get_power_cls(struct transvr_obj_s *self, - int direct_access){ - - int err_code; - uint8_t detect_val; - - /* Detect and Update power class attribute */ - if (direct_access){ - err_code = _check_by_mode(self, - &_common_update_attr_extended_id, - "__qsfp_get_power_cls"); - } else { - err_code = self->ext_id; - } - if (err_code <0){ - return err_code; - } - if (err_code == DEBUG_TRANSVR_HEX_VAL){ - return ERR_TRANSVR_UPDATE_FAIL; - } - /* Clean data */ - detect_val = self->ext_id; - SWP_BIT_CLEAR(detect_val, 2); /* Bit2: CDR RX present */ - SWP_BIT_CLEAR(detect_val, 3); /* Bit3: CDR TX present */ - SWP_BIT_CLEAR(detect_val, 4); /* Bit4: CLEI present */ - SWP_BIT_CLEAR(detect_val, 5); /* Bit5: reserved */ - /* Identify power class */ - switch (detect_val) { - case 0: /* Class_1: 00000000 */ - return 1; - case 64: /* Class_2: 01000000 */ - return 2; - case 128: /* Class_3: 10000000 */ - return 3; - case 192: /* Class_4: 11000000 */ - return 4; - case 1: /* Class_5: 00000001 */ - case 193: /* Class_5: 11000001 */ - return 5; - case 2: /* Class_6: 00000010 */ - case 194: /* Class_6: 11000010 */ - return 6; - case 3: /* Class_7: 00000011 */ - case 195: /* Class_7: 11000011 */ - return 7; - default: - break; - } - SWPS_INFO("%s: Detect undefined power class:%d\n", __func__, detect_val); - return ERR_TRANSVR_UNDEFINED; -} - - -int -qsfp_get_power_cls(struct transvr_obj_s *self) { - return __qsfp_get_power_cls(self, 1); -} - - -int -__qsfp_get_cdr_present(struct transvr_obj_s *self, - int direct_access){ - - int retval; - int BIT_SHIFT = 2; - int BIT_MASK = 0x3; - - /* Detect and Update power class attribute */ - if (direct_access) { - retval = _check_by_mode(self, - &_common_update_attr_extended_id, - "__qsfp_get_cdr_present"); - if (retval < 0){ - return retval; - } - } - retval = self->ext_id; - if (retval == DEBUG_TRANSVR_HEX_VAL){ - return ERR_TRANSVR_UPDATE_FAIL; - } - /* Clean data and return */ - return (int)(retval >> BIT_SHIFT & BIT_MASK); -} - - -int -qsfp_get_cdr_present(struct transvr_obj_s *self) { - return __qsfp_get_cdr_present(self, 1); -} - - -int -qsfp_get_cdr(struct transvr_obj_s *self){ - - int err_code = _check_by_mode(self, - &_qsfp_update_attr_cdr, - "qsfp_get_cdr"); - if (err_code <0){ - return err_code; - } - - return self->cdr; -} - - -int -__qsfp_get_comp_attr(struct transvr_obj_s *self, - int array_offset) { - /* QSFP Specification Compliance: 00h / 131-138 - * transvr_comp[0-7] = 131 - 138 - */ - if ((self->state == STATE_TRANSVR_CONNECTED) || - (self->state == STATE_TRANSVR_INIT) ) { - return (int)(self->transvr_comp[array_offset]); - } - return ERR_TRANSVR_ABNORMAL; -} - - -int -_qsfp_get_comp_10_40_100_ethernet(struct transvr_obj_s *self) { - /* transvr_comp[0] = address 00h / 131 - * - * 131 7: Extended: See section 6.3.23. The Extended Specification Compliance - * Codes are maintained in the Transceiver Management section of SFF- - * 8024. - * 131 6: 10GBASE-LRM - * 131 5: 10GBASE-LR - * 131 4: 10GBASE-SR - * 131 3: 40GBASE-CR4 - * 131 2: 40GBASE-SR4 - * 131 1: 40GBASE-LR4 - * 131 0: 40G Active Cable (XLPPI) - */ - return __qsfp_get_comp_attr(self, 0); -} - - -int -_qsfp_get_comp_sonet(struct transvr_obj_s *self) { - /* transvr_comp[1] = address 00h / 132 - * - * 132 7-3: Reserved - * 132 2: OC 48, long reach - * 132 1: OC 48, intermediate reach - * 132 0: OC 48 short reach - */ - return __qsfp_get_comp_attr(self, 1); -} - - -int -_qsfp_get_comp_sas_sata(struct transvr_obj_s *self) { - /* transvr_comp[1] = address 00h / 132 - * - * 133 7: SAS 24.0 Gb/s - * 133 6: SAS 12.0 Gb/s - * 133 5: SAS 6.0 Gb/s - * 133 4: SAS 3.0 Gb/s - * 133 3-0: Reserved - */ - return __qsfp_get_comp_attr(self, 2); -} - - -int -_qsfp_get_comp_ethernet(struct transvr_obj_s *self) { - /* transvr_comp[1] = address 00h / 132 - * - * 134 7-4: Reserved - * 134 3: 1000BASE-T - * 134 2: 1000BASE-CX - * 134 1: 1000BASE-LX - * 134 0: 1000BASE-SX - */ - return __qsfp_get_comp_attr(self, 3); -} - - -int -_qsfp_get_comp_fc_link_length(struct transvr_obj_s *self) { - /* transvr_comp[1] = address 00h / 132 - * - * 135 7: Very long distance (V) - * 135 6: Short distance (S) - * 135 5: Intermediate distance (I) - * 135 4: Long distance (L) - * 135 3: Medium (M) - */ - int mask = 0xFC; /* 11111100 */ - return (__qsfp_get_comp_attr(self, 4) & mask); -} - - -int -_qsfp_get_comp_fc_trans_tech(struct transvr_obj_s *self) { - /* transvr_comp[1] = address 00h / 132 - * - * 135 2: Reserved - * 135 1: Longwave laser (LC) - * 135 0: Electrical inter-enclosure (EL) - * - * 136 7: Electrical intra-enclosure - * 136 6: Shortwave laser w/o OFC (SN) - * 136 5: Shortwave laser w OFC (SL) - * 136 4: Longwave Laser (LL) - * 136 3-0: Reserved - * - * return value = [bit 8-15:addr 135][bit 0-7:addr 136] - */ - int mask_135 = 7; /* 00000111 */ - int val_135 = (__qsfp_get_comp_attr(self, 4) & mask_135); - int val_136 = __qsfp_get_comp_attr(self, 5); - return ((val_135 << 7) + val_136); -} - - -int -_qsfp_get_comp_fc_trans_media(struct transvr_obj_s *self) { - /* transvr_comp[1] = address 00h / 132 - * - * 137 7: Twin Axial Pair (TW) - * 137 6: Shielded Twisted Pair (TP) - * 137 5: Miniature Coax (MI) - * 137 4: Video Coax (TV) - * 137 3: Multi-mode 62.5 m (M6) - * 137 2: Multi-mode 50 m (M5) - * 137 1: Multi-mode 50 um (OM3) - * 137 0: Single Mode (SM) - */ - return __qsfp_get_comp_attr(self, 6); -} - - -int -_qsfp_get_comp_fc_speed(struct transvr_obj_s *self) { - /* transvr_comp[1] = address 00h / 132 - * - * 138 7: 1200 MBps (per channel) - * 138 6: 800 MBps - * 138 5: 1600 MBps (per channel) - * 138 4: 400 MBps - * 138 3: 3200 MBps (per channel) - * 138 2: 200 MBps - * 138 1: Extended: See section 6.3.23. The Extended Specification - * Compliance Codes are maintained in the Transceiver Management - * section of SFF-8024. - * 138 0: 100 MBps - */ - return __qsfp_get_comp_attr(self, 7); -} - - -int -_qsfp_get_comp_extended(struct transvr_obj_s *self) { - /* Address: 00h / 192 - * Reference: SFF-8024 TABLE 4-4 - */ - if ((self->state == STATE_TRANSVR_CONNECTED) || - (self->state == STATE_TRANSVR_INIT) ) { - return (int)(self->transvr_comp_ext); - } - return ERR_TRANSVR_ABNORMAL; -} - - -int -qsfp_get_comp_eth(struct transvr_obj_s *self){ - - int err_code = _check_by_mode(self, - &_common_update_attr_transvr_comp, - "qsfp_get_comp_eth"); - if (err_code < 0){ - return err_code; - } - return _qsfp_get_comp_ethernet(self); -} - - -int -qsfp_get_comp_10_40(struct transvr_obj_s *self) { - - int err_code = _check_by_mode(self, - &_common_update_attr_transvr_comp, - "qsfp_get_comp_10_40"); - if (err_code < 0){ - return err_code; - } - return _qsfp_get_comp_10_40_100_ethernet(self); -} - - -int -_qsfp_get_connector_type(struct transvr_obj_s *self) { - /* Address: 00h / 130 - * Reference: SFF-8024 TABLE 4-3 - */ - if ((self->state == STATE_TRANSVR_CONNECTED) || - (self->state == STATE_TRANSVR_INIT) ) { - return (int)(self->connector); - } - return ERR_TRANSVR_ABNORMAL; -} - - -int -qsfp_get_transvr_temp(struct transvr_obj_s *self, - char *buf_p) { - - int lmax = 8; - int err_code = DEBUG_TRANSVR_INT_VAL; - - err_code = _check_by_mode(self, - &_qsfp_update_attr_curr_temp, - "qsfp_get_transvr_temp"); - if (err_code < 0) { - return snprintf(buf_p, lmax, "%d\n", err_code); - } - if ((self->curr_temp[0]) == DEBUG_TRANSVR_HEX_VAL) { - return snprintf(buf_p, lmax, "%d\n", ERR_TRANSVR_UPDATE_FAIL); - } - return _common_count_temp(self->curr_temp[0], - self->curr_temp[1], - buf_p); -} - - -int -qsfp_get_transvr_voltage(struct transvr_obj_s *self, - char *buf_p) { - - int lmax = 8; - int err_code = DEBUG_TRANSVR_INT_VAL; - - err_code = _check_by_mode(self, - &_qsfp_update_attr_curr_voltage, - "qsfp_get_transvr_voltage"); - if (err_code < 0) { - return snprintf(buf_p, lmax, "%d\n", err_code); - } - if ((self->curr_voltage[0]) == DEBUG_TRANSVR_HEX_VAL) { - return snprintf(buf_p, lmax, "%d\n", ERR_TRANSVR_UPDATE_FAIL); - } - /* Return Unit: 1 Volt */ - return _common_count_voltage(self->curr_voltage[0], - self->curr_voltage[1], - buf_p); -} - - -int -qsfp_get_transvr_tx_eq(struct transvr_obj_s *self, - char *buf_p) { - - int limt = 8; - int err = DEBUG_TRANSVR_INT_VAL; - - err = _check_by_mode(self, - &_qsfp_update_attr_tx_eq, - "qsfp_get_transvr_tx_eq"); - if (err < 0) { - return snprintf(buf_p, limt, "%d\n", err); - } - if ((self->tx_eq[0]) == DEBUG_TRANSVR_HEX_VAL) { - return snprintf(buf_p, limt, "%d\n", ERR_TRANSVR_UPDATE_FAIL); - } - return snprintf(buf_p, limt, "0x%02x%02x\n", - self->tx_eq[0], self->tx_eq[1]); -} - - -int -qsfp_get_transvr_rx_am(struct transvr_obj_s *self, - char *buf_p) { - - int limt = 8; - int err = DEBUG_TRANSVR_INT_VAL; - - err = _check_by_mode(self, - &_qsfp_update_attr_rx_am, - "qsfp_get_transvr_rx_am"); - if (err < 0) { - return snprintf(buf_p, limt, "%d\n", err); - } - if ((self->rx_am[0]) == DEBUG_TRANSVR_HEX_VAL) { - return snprintf(buf_p, limt, "%d\n", ERR_TRANSVR_UPDATE_FAIL); - } - return snprintf(buf_p, limt, "0x%02x%02x\n", - self->rx_am[0], self->rx_am[1]); -} - - -int -qsfp_get_transvr_rx_em(struct transvr_obj_s *self, - char *buf_p) { - - int limt = 8; - int err = DEBUG_TRANSVR_INT_VAL; - - err = _check_by_mode(self, - &_qsfp_update_attr_rx_em, - "qsfp_get_transvr_rx_em"); - if (err < 0) { - return snprintf(buf_p, limt, "%d\n", err); - } - if ((self->rx_em[0]) == DEBUG_TRANSVR_HEX_VAL) { - return snprintf(buf_p, limt, "%d\n", ERR_TRANSVR_UPDATE_FAIL); - } - return snprintf(buf_p, limt, "0x%02x%02x\n", - self->rx_em[0], self->rx_em[1]); -} - - -int -_qsfp_get_channel_diag(uint8_t *data_array, - int (*count_func)(uint8_t high_byte, uint8_t low_byte, char *buf_p), - char *ch_name, - char *result_p) { - int i, high, low; - int len_max = 128; - char ch_buf[4][16] = { DEBUG_TRANSVR_STR_VAL, - DEBUG_TRANSVR_STR_VAL, - DEBUG_TRANSVR_STR_VAL, - DEBUG_TRANSVR_STR_VAL }; - - for (i=0; i<4; i++) { - high = (i*2); - low = ((i*2) + 1); - count_func(data_array[high], data_array[low], ch_buf[i]); - } - return snprintf(result_p, len_max, - "%s-%d:%s%s-%d:%s%s-%d:%s%s-%d:%s", - ch_name, 1, ch_buf[0], - ch_name, 2, ch_buf[1], - ch_name, 3, ch_buf[2], - ch_name, 4, ch_buf[3]); -} - - -int -qsfp_get_soft_rx_los(struct transvr_obj_s *self, - char *buf_p) { - - int lmax = 8; - int mask = 0x0f; /* Bit 0 ~ Bit 3 */ - int err_code = DEBUG_TRANSVR_INT_VAL; - - err_code = _check_by_mode(self, - &_qsfp_update_attr_soft_rx_los, - "qsfp_get_soft_rx_los"); - if (err_code < 0) { - return snprintf(buf_p, lmax, "%d\n", err_code); - } - return snprintf(buf_p, lmax, "0x%02x\n", (self->rx_los & mask)); -} - - -int -qsfp_get_soft_tx_disable(struct transvr_obj_s *self, - char *buf_p) { - - int lmax = 8; - int mask = 0x0f; /* Bit 0 ~ Bit 3 */ - int err_code = DEBUG_TRANSVR_INT_VAL; - - err_code = _check_by_mode(self, - &_qsfp_update_attr_soft_tx_disable, - "qsfp_get_soft_tx_disable"); - if (err_code < 0) { - return snprintf(buf_p, lmax, "%d\n", err_code); - } - return snprintf(buf_p, lmax, "0x%02x\n", (self->tx_disable & mask)); -} - - -int -qsfp_get_soft_tx_fault(struct transvr_obj_s *self, - char *buf_p) { - - int lmax = 8; - int mask = 0x0f; /* Bit 0 ~ Bit 3 */ - int err_code = DEBUG_TRANSVR_INT_VAL; - - err_code = _check_by_mode(self, - &_qsfp_update_attr_soft_tx_fault, - "qsfp_get_soft_tx_fault"); - if (err_code < 0) { - return snprintf(buf_p, lmax, "%d\n", err_code); - } - return snprintf(buf_p, lmax, "0x%02x\n", (self->tx_fault & mask)); -} - - -int -qsfp_get_auto_tx_disable(struct transvr_obj_s *self, - char *buf_p) { - - if (self->auto_tx_disable == VAL_TRANSVR_FUNCTION_DISABLE) { - return snprintf(buf_p, LEN_TRANSVR_S_STR, - "%d\n", ERR_TRANSVR_FUNC_DISABLE); - } - return snprintf(buf_p, LEN_TRANSVR_S_STR, - "0x%02x\n", self->auto_tx_disable); -} - - -int -qsfp_get_transvr_tx_bias(struct transvr_obj_s *self, - char *buf_p) { - - int lmax = 8; - int err_code = DEBUG_TRANSVR_INT_VAL; - char *ch_name = "TX"; - - err_code = _check_by_mode(self, - &_qsfp_update_attr_curr_tx_bias, - "qsfp_get_transvr_tx_bias"); - if (err_code < 0) { - return snprintf(buf_p, lmax, "%d\n", err_code); - } - if ((self->curr_tx_bias[0]) == DEBUG_TRANSVR_HEX_VAL) { - return snprintf(buf_p, lmax, "%d\n", ERR_TRANSVR_UPDATE_FAIL); - } - /* Return Unit: 1 mA */ - return _qsfp_get_channel_diag(self->curr_tx_bias, - _common_count_tx_bias, - ch_name, - buf_p); -} - - -int -qsfp_get_transvr_tx_power(struct transvr_obj_s *self, - char *buf_p) { - - int lmax = 8; - int err_code = DEBUG_TRANSVR_INT_VAL; - char *ch_name = "TX"; - - err_code = _check_by_mode(self, - &_qsfp_update_attr_curr_tx_power, - "qsfp_get_transvr_tx_power"); - if (err_code < 0) { - return snprintf(buf_p, lmax, "%d\n", err_code); - } - if ((self->curr_tx_power[0]) == DEBUG_TRANSVR_HEX_VAL) { - return snprintf(buf_p, lmax, "%d\n", ERR_TRANSVR_UPDATE_FAIL); - } - /* Return Unit: 1 mW */ - return _qsfp_get_channel_diag(self->curr_tx_power, - _common_count_tx_power, - ch_name, - buf_p); -} - - -int -qsfp_get_transvr_rx_power(struct transvr_obj_s *self, - char *buf_p) { - - int lmax = 8; - int err_code = DEBUG_TRANSVR_INT_VAL; - char *ch_name = "RX"; - - err_code = _check_by_mode(self, - &_qsfp_update_attr_curr_rx_power, - "qsfp_get_transvr_rx_power"); - if (err_code < 0) { - return snprintf(buf_p, lmax, "%d\n", err_code); - } - if ((self->curr_tx_power[0]) == DEBUG_TRANSVR_HEX_VAL) { - return snprintf(buf_p, lmax, "%d\n", ERR_TRANSVR_UPDATE_FAIL); - } - /* Return Unit: 1 mW */ - return _qsfp_get_channel_diag(self->curr_rx_power, - _common_count_rx_power, - ch_name, - buf_p); -} - - -int -qsfp_get_wavelength(struct transvr_obj_s *self, - char *buf_p) { - /* [Desc] Wavelength or Copper Cable Attenuation (SFF-8636) - * [Addr] 00h 186-187 - * [Note] - * For optical free side devices, this parameter identifies the nominal - * transmitter output wavelength at room temperature. This parameter is - * a 16-bit hex value with Byte 186 as high order byte and Byte 187 as - * low order byte. The laser wavelength is equal to the 16-bit integer value - * divided by 20 in nm (units of 0.05 nm). This resolution should be adequate - * to cover all relevant wavelengths yet provide enough resolution for all - * expected DWDM applications. For accurate representation of controlled - * wavelength applications, this value should represent the center of the - * guaranteed wavelength range. - * If the free side device is identified as copper cable these registers will - * be used to define the cable attenuation. An indication of 0 dB attenuation - * refers to the case where the attenuation is not known or is unavailable. - * Byte 186 (00-FFh) is the copper cable attenuation at 2.5 GHz in units of 1 dB. - * Byte 187 (00-FFh) is the copper cable attenuation at 5.0 GHz in units of 1 dB. - */ - int lmax = 8; - int err_code = DEBUG_TRANSVR_INT_VAL; - - err_code = _check_by_mode(self, - &_common_update_attr_wavelength, - "common_get_wavelength"); - if (err_code < 0) { - return snprintf(buf_p, lmax, "%d\n", err_code); - } - if ((self->wavelength[0]) == DEBUG_TRANSVR_HEX_VAL) { - return snprintf(buf_p, lmax, "%d\n", ERR_TRANSVR_UPDATE_FAIL); - } - /* unit: 1 um */ - return snprintf(buf_p, lmax, "%d\n", - _common_count_wavelength(self, - self->wavelength[0], - self->wavelength[1])); -} - - -/* Public Function for Setup Features - */ -static int -__sfp_set_soft_rs(struct transvr_obj_s *self, - int input_val, - int address, - int page, - int offset, - int bit_shift, - uint8_t *attr_p, - char *caller, - int show_err) { - - int retval = ERR_TRANSVR_UNEXCPT; - int err_code = ERR_TRANSVR_UNEXCPT; - char *err_msg = DEBUG_TRANSVR_STR_VAL; - uint8_t update_val = (*attr_p); - - switch (input_val) { - case 0: - SWP_BIT_CLEAR(update_val, bit_shift); - break; - case 1: - SWP_BIT_SET(update_val, bit_shift); - break; - default: - retval = ERR_TRANSVR_UNEXCPT; - err_code = ERR_TRANSVR_UNEXCPT; - err_msg = "Exception occurs"; - goto err_private_sfp_set_soft_rs_1; - } - err_code = _common_set_uint8_attr(self, - address, - page, - offset, - update_val, - attr_p, - caller, - show_err); - if (err_code < 0) { - retval = err_code; - err_msg = "Write data via i2c fail!"; - goto err_private_sfp_set_soft_rs_1; - } - (*attr_p) = update_val; - return 0; - -err_private_sfp_set_soft_rs_1: - if (show_err) { - SWPS_INFO("%s: %s :%d :%s\n :%d\n", - __func__, err_msg, err_code, self->swp_name, input_val); - } - return retval; -} - - -static int -_sfp_set_soft_rs(struct transvr_obj_s *self, - int input_val, - int address, - int page, - int offset, - int bit_shift, - int (*attr_update_func)(struct transvr_obj_s *self, int show_err), - uint8_t *attr_p, - char *caller, - int show_err) { - - int retval = ERR_TRANSVR_UNEXCPT; - int err_code = ERR_TRANSVR_UNEXCPT; - char *err_msg = DEBUG_TRANSVR_STR_VAL; - - /* Check input value */ - if ((input_val != 0) && (input_val != 1)){ - retval = ERR_TRANSVR_BADINPUT; - err_code = ERR_TRANSVR_BADINPUT; - err_msg = "Input range incorrect!"; - goto err_common_sfp_set_soft_rs_1; - } - /* Check rate identifier is supported */ - err_code = self->get_rate_id(self); - if (err_code <= 0) { - switch (err_code) { - case 0: - retval = ERR_TRANSVR_NOTSUPPORT; - err_msg = "Not support this feature"; - break; - case ERR_TRANSVR_UNINIT: - retval = ERR_TRANSVR_UNINIT; - err_msg = "Check CDR present fail!"; - break; - case ERR_TRANSVR_UNPLUGGED: - retval = ERR_TRANSVR_UNPLUGGED; - err_msg = "Transceiver unplugged!"; - break; - default: - retval = err_code; - err_msg = "Check Rate_ID fail!"; - break; - } - goto err_common_sfp_set_soft_rs_1; - } - /* Check and update */ - err_code = _check_by_mode(self, - attr_update_func, - caller); - if ( (err_code < 0) || - ((*attr_p) == DEBUG_TRANSVR_HEX_VAL) ){ - retval = err_code; - err_msg = "Get current value fail!"; - goto err_common_sfp_set_soft_rs_1; - } - /* Generate and update value */ - return __sfp_set_soft_rs(self, - input_val, - address, - page, - offset, - bit_shift, - attr_p, - caller, - show_err); - -err_common_sfp_set_soft_rs_1: - if (show_err) { - SWPS_INFO("%s: %s :%d :%s\n :%d\n", - __func__, err_msg, err_code, self->swp_name, input_val); - } - return retval; -} - - -int -sfp_set_soft_rs0(struct transvr_obj_s *self, - int input_val) { - /* Note: - * SFP Soft Rate_Select Select RX ["RS(0)"] address - * A2h, offset: 110, bit 3 - */ - int bit_shift = 3; - int show_err = 1; - return _sfp_set_soft_rs(self, - input_val, - self->eeprom_map_p->addr_soft_rs0, - self->eeprom_map_p->page_soft_rs0, - self->eeprom_map_p->offset_soft_rs0, - bit_shift, - &_sfp_update_attr_soft_rs0, - &(self->soft_rs0), - "sfp_set_soft_rs0", - show_err); -} - - -int -sfp_set_soft_rs1(struct transvr_obj_s *self, - int input_val) { - /* Note: - * SFP Soft Rate_Select Select RX ["RS(1)"] address - * A2h, offset: 118, bit 3 - */ - int bit_shift = 3; - int show_err = 1; - return _sfp_set_soft_rs(self, - input_val, - self->eeprom_map_p->addr_soft_rs1, - self->eeprom_map_p->page_soft_rs1, - self->eeprom_map_p->offset_soft_rs1, - bit_shift, - &_sfp_update_attr_soft_rs1, - &(self->soft_rs1), - "sfp_set_soft_rs1", - show_err); -} - - -int -__sfp_set_tx_eq(struct transvr_obj_s *self, - int input, - int show_e) { - - int err = DEBUG_TRANSVR_INT_VAL; - char *emsg = DEBUG_TRANSVR_STR_VAL; - uint8_t setv = DEBUG_TRANSVR_HEX_VAL; - - if ((input < 0) || (input > 0xFF)) { - emsg = "input incorrect"; - err = ERR_TRANSVR_BADINPUT; - goto err_sfp_set_tx_eq; - } - setv = (uint8_t)input; - if (self->tx_eq[0] == setv) { - return 0; - } - err = _common_set_uint8_attr(self, - self->eeprom_map_p->addr_tx_eq, - self->eeprom_map_p->page_tx_eq, - self->eeprom_map_p->offset_tx_eq, - setv, - &(self->tx_eq[0]), - "_sfp_set_tx_eq", - show_e); - if (err < 0) { - emsg = "set_uint8_attr fail"; - goto err_sfp_set_tx_eq; - } - return 0; - -err_sfp_set_tx_eq: - if (show_e) { - SWPS_INFO("%s: %s :%d\n", __func__, emsg, input); - } - return err; -} - - -int -_sfp_set_tx_eq(struct transvr_obj_s *self, - int input, - int show_e) { - - uint8_t tmp; - int i = 0; - int retry = 3; - - for (i=0; itx_eq[0]; - if (_sfp_update_attr_tx_eq(self, show_e) < 0){ - continue; - } - if (self->tx_eq[0] == tmp){ - return 0; - } - } - return ERR_TRANSVR_UPDATE_FAIL; -} - - -int -sfp_set_tx_eq(struct transvr_obj_s *self, - int input) { - - int err = _check_by_mode(self, - &_sfp_update_attr_tx_eq, - "sfp_set_tx_eq"); - if (err < 0) { - SWPS_DEBUG("%s: check fail :%d\n", __func__, err); - return err; - } - return _sfp_set_tx_eq(self, input, 1); -} - - -int -__sfp_set_rx_em(struct transvr_obj_s *self, - int input, - int show_e) { - - int err = DEBUG_TRANSVR_INT_VAL; - char *emsg = DEBUG_TRANSVR_STR_VAL; - uint8_t setv = DEBUG_TRANSVR_HEX_VAL; - - if ((input < 0) || (input > 0xFF)) { - emsg = "input incorrect"; - err = ERR_TRANSVR_BADINPUT; - goto err_sfp_set_rx_em; - } - setv = (uint8_t)input; - if (self->rx_em[0] == setv) { - return 0; - } - err = _common_set_uint8_attr(self, - self->eeprom_map_p->addr_rx_em, - self->eeprom_map_p->page_rx_em, - self->eeprom_map_p->offset_rx_em, - setv, - &(self->rx_em[0]), - "_sfp_set_rx_em", - show_e); - if (err < 0) { - emsg = "set_uint8_attr fail"; - goto err_sfp_set_rx_em; - } - return 0; - -err_sfp_set_rx_em: - if (show_e) { - SWPS_INFO("%s: %s :%d\n", __func__, emsg, input); - } - return err; -} - - -int -_sfp_set_rx_em(struct transvr_obj_s *self, - int input, - int show_e) { - - uint8_t tmp; - int i = 0; - int retry = 3; - - for (i=0; irx_em[0]; - if (_sfp_update_attr_rx_em(self, show_e) < 0){ - continue; - } - if (self->rx_em[0] == tmp){ - return 0; - } - } - return -1; -} - - -int -sfp_set_rx_em(struct transvr_obj_s *self, - int input) { - - int err = _check_by_mode(self, - &_sfp_update_attr_rx_em, - "sfp_set_rx_em"); - if (err < 0) { - SWPS_DEBUG("%s: check fail :%d\n", __func__, err); - return err; - } - return _sfp_set_rx_em(self, input, 1); -} - - -int -sfp_set_1g_rj45_extphy_offset(struct transvr_obj_s *self, - int input) { - - if (self->state != STATE_TRANSVR_CONNECTED) { - return ERR_TRANSVR_UNPLUGGED; - } - if ((self->info != TRANSVR_CLASS_BASE_T_1000) && - (self->info != TRANSVR_CLASS_BASE_T_1000_up) ){ - return ERR_TRANSVR_NOTSUPPORT; - } - if ((input < 0) || (input > 0xff)) { - return ERR_TRANSVR_BADINPUT; - } - self->extphy_offset = (uint8_t)input; - return 0; -} - - -int -sfp_set_1g_rj45_extphy_reg(struct transvr_obj_s *self, - int input) { - - int i = 0; - int retry = 3; - int delay = 200; - uint16_t tmp = 0; - - if (self->state != STATE_TRANSVR_CONNECTED) { - return ERR_TRANSVR_UNPLUGGED; - } - if ((self->info != TRANSVR_CLASS_BASE_T_1000) && - (self->info != TRANSVR_CLASS_BASE_T_1000_up) ){ - return ERR_TRANSVR_NOTSUPPORT; - } - if ((input < 0) || (input > 0xffff)) { - return ERR_TRANSVR_BADINPUT; - } - tmp = ((input & 0x00ff) << 8) | ((input & 0xff00) >> 8); - if (_common_setup_page(self, VAL_TRANSVR_EXTPHY_ADDR_56, - -1, self->extphy_offset, 1, 0) < 0) { - return -EIO; - } - for (i=0; i<=retry; i++) { - if (i2c_smbus_write_word_data(self->i2c_client_p, - self->extphy_offset, - tmp) >= 0) { - return 0; - } - msleep(delay); - } - SWPS_INFO("%s: retry:%d fail :%s :0x%02x\n", - __func__, retry, self->swp_name, self->extphy_offset); - return -EIO; -} - - -static int -__qsfp_set_cdr(struct transvr_obj_s *self, - int input_val, - int show_err) { - - uint8_t update_val; - int CDR_FEATURE_SUPPORTED = 0x3; - int retval = ERR_TRANSVR_UNEXCPT; - int err_code = ERR_TRANSVR_UNEXCPT; - char *err_msg = DEBUG_TRANSVR_STR_VAL; - char *func_name = "__qsfp_set_cdr"; - - /* Check input value */ - if ((input_val < 0) || (input_val > 0xff)){ - retval = ERR_TRANSVR_BADINPUT; - err_code = ERR_TRANSVR_BADINPUT; - err_msg = "Input range incorrect!"; - goto err_qsfp_set_cdr_1; - } - update_val = (uint8_t)input_val; - /* Check CDR supported by transceiver */ - err_code = qsfp_get_cdr_present(self); - if (err_code < 0) { - retval = err_code; - switch (err_code) { - case ERR_TRANSVR_UNINIT: - err_msg = "Check CDR present fail!"; - break; - case ERR_TRANSVR_UNPLUGGED: - err_msg = "Transceiver unplugged!"; - break; - default: - err_msg = "Check CDR present fail!"; - break; - } - goto err_qsfp_set_cdr_1; - } - if (err_code != CDR_FEATURE_SUPPORTED) { - retval = ERR_TRANSVR_NOTSUPPORT; - err_msg = "This transceiver not support CDR!"; - goto err_qsfp_set_cdr_1; - } - /* Check and update */ - err_code = _check_by_mode(self, - &_qsfp_update_attr_cdr, - func_name); - if ( (err_code < 0) || - (self->cdr == DEBUG_TRANSVR_HEX_VAL) ){ - retval = err_code; - err_msg = "Get current value fail!"; - goto err_qsfp_set_cdr_1; - } - /* Write input value to transceiver */ - return _common_set_uint8_attr(self, - self->eeprom_map_p->addr_cdr, - self->eeprom_map_p->page_cdr, - self->eeprom_map_p->offset_cdr, - update_val, - &(self->cdr), - func_name, - show_err); - -err_qsfp_set_cdr_1: - if (show_err) { - SWPS_INFO("%s: %s :%d :%s\n :%d\n", - __func__, err_msg, err_code, self->swp_name, input_val); - } - return retval; -} - - -int -qsfp_set_cdr(struct transvr_obj_s *self, - int input_val) { - return __qsfp_set_cdr(self, input_val, 1); -} - - -int -qsfp_set_soft_tx_disable(struct transvr_obj_s *self, - int input_val) { - - int show_err = 1; - int in_max = 0xf; /* 1111 */ - int in_min = 0x0; /* 0000 */ - int retval = DEBUG_TRANSVR_INT_VAL; - int update_val = DEBUG_TRANSVR_INT_VAL; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - - retval = _check_by_mode(self, - &_qsfp_update_attr_soft_tx_disable, - "qsfp_set_soft_tx_disable"); - if (retval < 0) { - snprintf(err_msg, 63, "Not ready. err:%d", retval); - goto err_qsfp_set_soft_tx_disable; - } - if ((input_val > in_max) || - (input_val < in_min) ){ - retval = ERR_TRANSVR_BADINPUT; - snprintf(err_msg, 63, "Input value:%d incorrect!", input_val); - goto err_qsfp_set_soft_tx_disable; - } - if ((self->tx_disable & 0x0f) == input_val) { - return 0; - } - update_val = ((self->tx_disable & 0xf0) & input_val); - retval = _common_set_uint8_attr(self, - self->eeprom_map_p->addr_tx_disable, - self->eeprom_map_p->page_tx_disable, - self->eeprom_map_p->offset_tx_disable, - input_val, - &(self->tx_disable), - "qsfp_set_tx_disable", - show_err); - if (retval < 0) { - snprintf(err_msg, 63, "_common_set_uint8_attr:%d fail!", retval); - goto err_qsfp_set_soft_tx_disable; - } - return 0; - -err_qsfp_set_soft_tx_disable: - SWPS_INFO("%s: %s :%s\n", __func__, err_msg, self->swp_name); - return retval; -} - - -int -_qsfp_set_auto_tx_disable(struct transvr_obj_s *self, - uint8_t update) { - - uint8_t tx_enable = 0x0; - int show_e = 1; - int err = DEBUG_TRANSVR_INT_VAL; - char *emsg = DEBUG_TRANSVR_STR_VAL; - - /* Handle timing issues */ - if (update != tx_enable) { - /* Note: - * Because there are some txvr has timing issues, - * therefore we need to execute reset cycle first. - * (enable -> other settings) - */ - err = _common_set_uint8_attr(self, - self->eeprom_map_p->addr_tx_disable, - self->eeprom_map_p->page_tx_disable, - self->eeprom_map_p->offset_tx_disable, - tx_enable, - &(self->tx_disable), - "_qsfp_set_auto_tx_disable", - show_e); - if (err < 0) { - emsg = "I2C set reset value fail"; - goto err_qsfp_set_auto_tx_disable; - } - mdelay(10); - } - /* Setup target value */ - err = _common_set_uint8_attr(self, - self->eeprom_map_p->addr_tx_disable, - self->eeprom_map_p->page_tx_disable, - self->eeprom_map_p->offset_tx_disable, - self->auto_tx_disable, - &(self->tx_disable), - "_qsfp_set_auto_tx_disable", - show_e); - if (err < 0) { - emsg = "I2C set target value fail"; - goto err_qsfp_set_auto_tx_disable; - } - /* Check and update */ - err = _common_update_uint8_attr(self, - self->eeprom_map_p->addr_tx_disable, - self->eeprom_map_p->page_tx_disable, - self->eeprom_map_p->offset_tx_disable, - self->eeprom_map_p->length_tx_disable, - &(self->tx_disable), - "_qsfp_set_auto_tx_disable", - show_e); - if (err < 0) { - emsg = "I2C get value fail"; - goto err_qsfp_set_auto_tx_disable; - } - if (self->tx_disable != update) { - emsg = "data not become effective"; - goto err_qsfp_set_auto_tx_disable; - } - return 0; - -err_qsfp_set_auto_tx_disable: - SWPS_DEBUG("%s: %s :%s\n", - __func__, emsg, self->swp_name); - return ERR_TRANSVR_UPDATE_FAIL; -} - - -int -qsfp_set_auto_tx_disable(struct transvr_obj_s *self, - int input_val) { - - int in_max = 0xf; /* 1111 */ - int in_min = 0x0; /* 0000 */ - int retval = DEBUG_TRANSVR_INT_VAL; - char *emsg = DEBUG_TRANSVR_STR_VAL; - - /* Update settings*/ - if (input_val == VAL_TRANSVR_FUNCTION_DISABLE) { - emsg = "User disable auto tx_disable"; - self->auto_tx_disable = VAL_TRANSVR_FUNCTION_DISABLE; - goto out_qsfp_set_auto_tx_disable; - } - if ((input_val > in_max) || (input_val < in_min) ){ - SWPS_INFO("%s: Input value:%d incorrect! :%s\n", - __func__, input_val, self->swp_name); - return ERR_TRANSVR_BADINPUT; - } - self->auto_tx_disable = input_val; - /* Check current soft tx_disable */ - retval = _check_by_mode(self, - &_qsfp_update_attr_soft_tx_disable, - "qsfp_set_auto_tx_disable"); - switch (retval) { - case 0: - break; - case ERR_TRANSVR_UNPLUGGED: - emsg = "Doesn't need to update"; - goto out_qsfp_set_auto_tx_disable; - default: - SWPS_INFO("%s: setup fail :%d :%s\n", - __func__, retval, self->swp_name); - return retval; - } - return _qsfp_set_auto_tx_disable(self, input_val); - -out_qsfp_set_auto_tx_disable: - SWPS_DEBUG("%s: %s :%s :%d\n :%d", - __func__, emsg, self->swp_name, input_val, retval); - return 0; -} - - -int -__qsfp_set_tx_eq(struct transvr_obj_s *self, - int input, - int show_e) { - /* [Note] - * 0x - */ - int err = DEBUG_TRANSVR_INT_VAL; - char *emsg = DEBUG_TRANSVR_STR_VAL; - uint8_t setv[2] = {0x00, 0x00}; - - if ((input < 0) || (input > 0xFFFF)) { - emsg = "input incorrect"; - err = ERR_TRANSVR_BADINPUT; - goto err_qsfp_set_tx_eq; - } - setv[0] = (uint8_t)((input & 0xFF00) >> 8); - setv[1] = (uint8_t)(input & 0xFF); - if ((self->tx_eq[0] == setv[0]) && - (self->tx_eq[1] == setv[1]) ) { - return 0; - } - err = _common_set_uint8_array(self, - self->eeprom_map_p->addr_tx_eq, - self->eeprom_map_p->page_tx_eq, - self->eeprom_map_p->offset_tx_eq, - self->eeprom_map_p->length_tx_eq, - setv, - self->tx_eq, - "_qsfp_set_tx_eq", - show_e); - if (err < 0) { - emsg = "set_uint8_array fail"; - goto err_qsfp_set_tx_eq; - } - return 0; - -err_qsfp_set_tx_eq: - if (show_e) { - SWPS_INFO("%s: %s :%d\n", __func__, emsg, input); - } - return err; -} - - -int -_qsfp_set_tx_eq(struct transvr_obj_s *self, - int input, - int show_e) { - - int i = 0; - int retry = 3; - uint8_t tmp[2]; - - for (i=0; itx_eq[0]; - tmp[1] = self->tx_eq[1]; - if (_qsfp_update_attr_tx_eq(self, show_e) < 0){ - continue; - } - if ((self->tx_eq[0] == tmp[0]) && - (self->tx_eq[1] == tmp[1]) ){ - return 0; - } - } - return -1; -} - - -int -qsfp_set_tx_eq(struct transvr_obj_s *self, - int input) { - - int err = _check_by_mode(self, - &_qsfp_update_attr_tx_eq, - "qsfp_set_tx_eq"); - if (err < 0) { - SWPS_DEBUG("%s: check fail :%d\n", __func__, err); - return err; - } - return _qsfp_set_tx_eq(self, input, 1); -} - - -int -__qsfp_set_rx_am(struct transvr_obj_s *self, - int input, - int show_e) { - /* [Note] - * 0x - */ - int err = DEBUG_TRANSVR_INT_VAL; - char *emsg = DEBUG_TRANSVR_STR_VAL; - uint8_t setv[2] = {0x00, 0x00}; - - if ((input < 0) || (input > 0xFFFF)) { - emsg = "input incorrect"; - err = ERR_TRANSVR_BADINPUT; - goto err_qsfp_set_rx_am; - } - setv[0] = (uint8_t)((input & 0xFF00) >> 8); - setv[1] = (uint8_t)(input & 0xFF); - if ((self->rx_am[0] == setv[0]) && - (self->rx_am[1] == setv[1]) ) { - return 0; - } - err = _common_set_uint8_array(self, - self->eeprom_map_p->addr_rx_am, - self->eeprom_map_p->page_rx_am, - self->eeprom_map_p->offset_rx_am, - self->eeprom_map_p->length_rx_am, - setv, - self->rx_am, - "_qsfp_set_rx_am", - show_e); - if (err < 0) { - emsg = "set_uint8_array fail"; - goto err_qsfp_set_rx_am; - } - return 0; - -err_qsfp_set_rx_am: - if (show_e) { - SWPS_INFO("%s: %s :%d\n", __func__, emsg, input); - } - return err; -} - - -int -_qsfp_set_rx_am(struct transvr_obj_s *self, - int input, - int show_e) { - - int i = 0; - int retry = 3; - uint8_t tmp[2]; - - for (i=0; irx_am[0]; - tmp[1] = self->rx_am[1]; - if (_qsfp_update_attr_rx_am(self, show_e) < 0){ - continue; - } - if ((self->rx_am[0] == tmp[0]) && - (self->rx_am[1] == tmp[1]) ){ - return 0; - } - } - return -1; -} - - -int -qsfp_set_rx_am(struct transvr_obj_s *self, - int input) { - - int err = _check_by_mode(self, - &_qsfp_update_attr_rx_am, - "qsfp_set_rx_am"); - if (err < 0) { - SWPS_DEBUG("%s: check fail :%d\n", __func__, err); - return err; - } - return _qsfp_set_rx_am(self, input, 1); -} - - -int -__qsfp_set_rx_em(struct transvr_obj_s *self, - int input, - int show_e) { - /* [Note] - * 0x - */ - int err = DEBUG_TRANSVR_INT_VAL; - char *emsg = DEBUG_TRANSVR_STR_VAL; - uint8_t setv[2] = {0x00, 0x00}; - - if ((input < 0) || (input > 0xFFFF)) { - emsg = "input incorrect"; - err = ERR_TRANSVR_BADINPUT; - goto err_qsfp_set_rx_em; - } - setv[0] = (uint8_t)((input & 0xFF00) >> 8); - setv[1] = (uint8_t)(input & 0xFF); - if ((self->rx_em[0] == setv[0]) && - (self->rx_em[1] == setv[1]) ) { - return 0; - } - err = _common_set_uint8_array(self, - self->eeprom_map_p->addr_rx_em, - self->eeprom_map_p->page_rx_em, - self->eeprom_map_p->offset_rx_em, - self->eeprom_map_p->length_rx_em, - setv, - self->rx_em, - "_qsfp_set_rx_em", - show_e); - if (err < 0) { - emsg = "set_uint8_array fail"; - goto err_qsfp_set_rx_em; - } - return 0; - -err_qsfp_set_rx_em: - if (show_e) { - SWPS_INFO("%s: %s :%d\n", __func__, emsg, input); - } - return err; -} - - -int -_qsfp_set_rx_em(struct transvr_obj_s *self, - int input, - int show_e) { - - int i = 0; - int retry = 3; - uint8_t tmp[2]; - - for (i=0; irx_em[0]; - tmp[1] = self->rx_em[1]; - if (_qsfp_update_attr_rx_em(self, show_e) < 0){ - continue; - } - if ((self->rx_em[0] == tmp[0]) && - (self->rx_em[1] == tmp[1]) ){ - return 0; - } - } - return -1; -} - - -int -qsfp_set_rx_em(struct transvr_obj_s *self, - int input) { - - int err = _check_by_mode(self, - &_qsfp_update_attr_rx_em, - "qsfp_set_rx_em"); - if (err < 0) { - SWPS_DEBUG("%s: check fail :%d\n", __func__, err); - return err; - } - return _qsfp_set_rx_em(self, input, 1); -} - - -int -common_transvr_dump(struct transvr_obj_s* self){ - - char *type_name = "Undefined"; - - if (TRANSVR_INFO_DUMP_ENABLE != 1) { - return 0; - } - switch (self->type) { - case TRANSVR_TYPE_SFP: - type_name = STR_TRANSVR_SFP; - break; - case TRANSVR_TYPE_QSFP: - type_name = STR_TRANSVR_QSFP; - break; - case TRANSVR_TYPE_QSFP_PLUS: - type_name = STR_TRANSVR_QSFP_PLUS; - break; - case TRANSVR_TYPE_QSFP_28: - type_name = STR_TRANSVR_QSFP28; - break; - case TRANSVR_TYPE_FAKE: - type_name = "FAKE"; - goto ok_common_transvr_dump; - case TRANSVR_TYPE_UNPLUGGED: - type_name = "UNPLUGGED"; - goto err_common_transvr_dump; - case TRANSVR_TYPE_INCONSISTENT: - type_name = "INCONSISTENT"; - goto err_common_transvr_dump; - case TRANSVR_TYPE_ERROR: - type_name = "ERROR"; - goto err_common_transvr_dump; - - default: - type_name = "UNEXPECTED"; - goto err_common_transvr_dump; - } - printk(KERN_INFO "[SWPS] Dump %s information:\n", self->swp_name); - printk(KERN_INFO " |- :%s\n", type_name); - printk(KERN_INFO " |- :%s\n", self->vendor_name); - printk(KERN_INFO " |- :%s\n", self->vendor_pn); - printk(KERN_INFO " |- :%s\n", self->vendor_rev); - printk(KERN_INFO " |- :%s\n", self->vendor_sn); - printk(KERN_INFO " |- :0x%02x\n", self->br); - printk(KERN_INFO " |- :0x%02x\n", self->comp_rev); - printk(KERN_INFO " |- :%d\n", self->len_om1); - printk(KERN_INFO " |- :%d\n", self->len_om2); - printk(KERN_INFO " |- :%d\n", self->len_om3); - printk(KERN_INFO " |- :%d\n", self->len_om4); - return 0; - -ok_common_transvr_dump: - SWPS_INFO("%s: %s is %s\n", __func__, self->swp_name, type_name); - return 0; - -err_common_transvr_dump: - SWPS_INFO("%s: %s is %s\n", __func__, self->swp_name, type_name); - return -1; -} - - -int -sfp_transvr_dump(struct transvr_obj_s* self) { - - if (TRANSVR_INFO_DUMP_ENABLE != 1) { - return 0; - } - if (common_transvr_dump(self) < 0) { - return -1; - } - printk(KERN_INFO " |- :%d\n", self->len_sm); - printk(KERN_INFO " |- :%d\n", self->len_smf); - printk(KERN_INFO " '- :0x%02x\n", self->rate_id); - return 0; -} - - -int -qsfp_transvr_dump(struct transvr_obj_s* self) { - - if (TRANSVR_INFO_DUMP_ENABLE != 1) { - return 0; - } - if (common_transvr_dump(self) < 0) { - return -1; - } - printk(KERN_INFO " |- :%d\n", self->len_smf); - printk(KERN_INFO " '- :Class_%d\n", __qsfp_get_power_cls(self, 0)); - return 0; -} - - -int -fake_transvr_dump(struct transvr_obj_s* self) { - - printk(KERN_INFO "[SWPS] Dump transceiver information: %s\n", self->swp_name); - printk(KERN_INFO " |- :FAKE\n"); - printk(KERN_INFO " |- :FAKE_VENDER_NAME\n"); - printk(KERN_INFO " |- :FAKE_VENDER_PN\n"); - printk(KERN_INFO " |- :FAKE_VENDER_REV\n"); - printk(KERN_INFO " |- :FAKE_VENDER_SN\n"); - printk(KERN_INFO " |- :0x99\n"); - printk(KERN_INFO " |- :99\n"); - printk(KERN_INFO " |- :99\n"); - printk(KERN_INFO " |- :99\n"); - printk(KERN_INFO " |- :99\n"); - printk(KERN_INFO " |- :99\n"); - printk(KERN_INFO " |- :99\n"); - printk(KERN_INFO " '- :0x99\n"); - return 0; -} - - -/* ========== Object functions for fake type ========== - */ -int -fake_transvr_update(struct transvr_obj_s *self, - int show_err){ - self->state = STATE_TRANSVR_CONNECTED; - return 0; -} - - -int -fake_get_binary(struct transvr_obj_s *self){ - return 1; -} - -int -fake_get_int(struct transvr_obj_s *self){ - return 99; -} - - -int -fake_get_hex(struct transvr_obj_s *self){ - return 0x0f; -} - - -int -fake_get_str(struct transvr_obj_s *self, char *buf) { - return snprintf(buf, 16, "fake_get_str\n"); -} - - -int -fake_set_int(struct transvr_obj_s *self, int input){ - SWPS_INFO("%s: %d\n", __func__, input); - return 0; -} - - -int -fake_set_hex(struct transvr_obj_s *self, int input){ - SWPS_INFO("%s: 0x%02x\n", __func__, input); - return 0; -} - - -/* ========== Object functions for unsupported ========== - */ -int -unsupported_get_func(struct transvr_obj_s *self){ - return ERR_TRANSVR_NOTSUPPORT; -} - - -int -unsupported_get_func2(struct transvr_obj_s *self, - char *buf_p) { - int len = snprintf(buf_p, 8, "%d\n", ERR_TRANSVR_NOTSUPPORT); - return len; -} - - -int -unsupported_set_func(struct transvr_obj_s *self, - int input_val){ - return ERR_TRANSVR_NOTSUPPORT; -} - - - -/* ========== Object functions for long term task ========== - * - * [Note] - * SWPS transceiver worker is likely the green-thread (coroutine). - * Due to resource and performance considerations. SWPS run all - * features in one kthread at the same time, and handle by it self. - */ - -/* For Transceiver Task Handling - */ -static struct transvr_worker_s * -transvr_task_get(struct transvr_obj_s *self, - char *func_name) { - - struct transvr_worker_s *curr_p = self->worker_p; - - while(curr_p != NULL){ - if (strcmp((curr_p->func_name), func_name) == 0 ) { - return curr_p; - } - curr_p = curr_p->next_p; - } - return NULL; -} - - -static struct transvr_worker_s* -transvr_task_creat(struct transvr_obj_s *self, - int (*main_task)(struct transvr_worker_s *task), - int (*post_task)(struct transvr_worker_s *task), - char *caller) { - - struct transvr_worker_s *task_p = NULL; - struct transvr_worker_s *curr_p = NULL; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - - /* Check task not exist */ - task_p = transvr_task_get(self, caller); - if (task_p) { - snprintf(err_msg, sizeof(err_msg), "Task already created!"); - goto err_transvr_task_creat; - } - /* Create task worker */ - task_p = kzalloc(sizeof(struct transvr_worker_s), GFP_KERNEL); - if (!task_p){ - snprintf(err_msg, sizeof(err_msg), "kzalloc fail"); - goto err_transvr_task_creat; - } - /* Setup task data */ - task_p->transvr_p = self; - task_p->next_p = NULL; - task_p->trigger_time = 0; - task_p->retry = 1; - task_p->state = STATE_T_TASK_INIT; - task_p->main_task = main_task; - task_p->post_task = post_task; - task_p->p_data = NULL; - snprintf(task_p->func_name, sizeof(task_p->func_name), "%s", caller); - /* Setup Link List */ - if (self->worker_p) { - curr_p = self->worker_p; - while(curr_p->next_p != NULL) { - curr_p = curr_p->next_p; - } - curr_p->next_p = task_p; - task_p->pre_p = curr_p; - } else { - self->worker_p = task_p; - task_p->pre_p = NULL; - } - return task_p; - -err_transvr_task_creat: - SWPS_ERR("%s: %s :%s :%s\n", - __func__, err_msg, caller, self->swp_name); - return NULL; -} - - -static void -transvr_task_free_one(struct transvr_worker_s *task_p){ - - struct transvr_worker_s *pre_p = NULL; - struct transvr_worker_s *next_p = NULL; - - if (task_p) { - pre_p = task_p->pre_p; - next_p = task_p->next_p; - - if ((pre_p) && (next_p)) { - pre_p->next_p = next_p; - next_p->pre_p = pre_p; - - } else if ((!pre_p) && (next_p)) { - next_p->pre_p = NULL; - - } else if ((pre_p) && (!next_p)) { - pre_p->next_p = NULL; - - } else if ((!pre_p) && (!next_p)) { - task_p->transvr_p->worker_p = NULL; - } else { - SWPS_ERR("%s: Unexcept case!\n :%s", - __func__, task_p->transvr_p->swp_name); - } - kfree(task_p->p_data); - kfree(task_p); - } -} - - -static void -transvr_task_free_all(struct transvr_obj_s *self) { - - struct transvr_worker_s *curr_p = NULL; - struct transvr_worker_s *next_p = NULL; - - if (self->worker_p) { - curr_p = self->worker_p; - while(curr_p) { - next_p = curr_p->next_p; - transvr_task_free_one(curr_p); - curr_p = next_p; - } - self->worker_p = NULL; - } -} - - -static void -transvr_cache_free_all(struct transvr_obj_s *self) { - - memset(self->vendor_name, 0, (LEN_TRANSVR_M_STR * sizeof(char)) ); - memset(self->vendor_rev, 0, (LEN_TRANSVR_M_STR * sizeof(char)) ); - memset(self->vendor_pn, 0, (LEN_TRANSVR_M_STR * sizeof(char)) ); - memset(self->vendor_sn, 0, (LEN_TRANSVR_M_STR * sizeof(char)) ); - self->extphy_offset = 0; -} - -static int -_transvr_task_run_main(struct transvr_worker_s *task_p) { - - int retval = DEBUG_TRANSVR_INT_VAL; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - - if (!task_p){ - snprintf(err_msg, sizeof(err_msg), "main_task is NULL!"); - goto main_transvr_task_err; - } - if ((task_p->trigger_time) == 0){ - goto main_transvr_task_run; - } - if (time_before(jiffies, task_p->trigger_time)){ - goto main_transvr_task_wait; - } - goto main_transvr_task_run; - -main_transvr_task_run: - if (task_p->retry != VAL_TRANSVR_TASK_RETRY_FOREVER) { - task_p->retry -= 1; - } - retval = task_p->main_task(task_p); - if (retval < 0) { - if (task_p->retry > 0) { - task_p->state = STATE_T_TASK_WAIT; - return EVENT_TRANSVR_TASK_WAIT; - } - snprintf(err_msg, sizeof(err_msg), "Run main_task fail!"); - goto main_transvr_task_err; - } - goto main_transvr_task_identify; - -main_transvr_task_identify: - switch (retval) { - case EVENT_TRANSVR_TASK_WAIT: - task_p->state = STATE_T_TASK_WAIT; - return EVENT_TRANSVR_TASK_WAIT; - - case EVENT_TRANSVR_TASK_DONE: - task_p->state = STATE_T_TASK_DONE; - return EVENT_TRANSVR_TASK_DONE; - - default: - break; - } - snprintf(err_msg, sizeof(err_msg), "Run main_task fail!"); - goto main_transvr_task_err; - -main_transvr_task_wait: - task_p->state = STATE_T_TASK_WAIT; - return EVENT_TRANSVR_TASK_WAIT; - -main_transvr_task_err: - task_p->state = STATE_T_TASK_FAIL; - SWPS_INFO("%s: %s :%d :%s\n", - __func__, err_msg, retval, task_p->transvr_p->swp_name); - return EVENT_TRANSVR_INIT_FAIL; -} - - -static int -_transvr_task_run_post(struct transvr_worker_s *task_p) { - - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - - if ((task_p->post_task) == NULL) { - return EVENT_TRANSVR_TASK_DONE; - } - switch (task_p->state) { - case STATE_T_TASK_WAIT: - case STATE_T_TASK_INIT: - goto post_transvr_task_wait; - - case STATE_T_TASK_DONE: - case STATE_T_TASK_FAIL: - goto post_transvr_task_run; - - default: - break; - } - snprintf(err_msg, sizeof(err_msg), "Unexcept task state"); - goto post_transvr_task_err; - -post_transvr_task_run: - task_p->post_task(task_p); - return EVENT_TRANSVR_TASK_DONE; - -post_transvr_task_wait: - return EVENT_TRANSVR_TASK_WAIT; - -post_transvr_task_err: - SWPS_INFO("%s: %s :%d :%s\n", - __func__, err_msg, task_p->state, task_p->transvr_p->swp_name); - return EVENT_TRANSVR_TASK_FAIL; -} - - -static int -transvr_task_run_one(struct transvr_worker_s *task_p) { - - int retval_main = DEBUG_TRANSVR_INT_VAL; - int retval_post = DEBUG_TRANSVR_INT_VAL; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - - retval_main = _transvr_task_run_main(task_p); - if (retval_main < 0) { - snprintf(err_msg, sizeof(err_msg), "Execute main_task fail!"); - goto err_transvr_task_run_one; - } - retval_post = _transvr_task_run_post(task_p); - if (retval_post < 0) { - snprintf(err_msg, sizeof(err_msg), "Execute post_task fail!"); - goto err_transvr_task_run_one; - } - return retval_main; - -err_transvr_task_run_one: - SWPS_INFO("%s: %s
:%d :%d :%s :%s\n", - __func__, err_msg, retval_main, retval_post, - task_p->func_name, task_p->transvr_p->swp_name); - return EVENT_TRANSVR_TASK_FAIL; -} - - -static int -transvr_task_run_all(struct transvr_obj_s *self) { - - int haserr = 0; - int retval = DEBUG_TRANSVR_INT_VAL; - struct transvr_worker_s *curr_p = NULL; - struct transvr_worker_s *next_p = NULL; - - if ((self->worker_p) == NULL) { - return EVENT_TRANSVR_TASK_DONE; - } - curr_p = self->worker_p; - while (curr_p != NULL) { - next_p = curr_p->next_p; - retval = transvr_task_run_one(curr_p); - if (curr_p->retry == VAL_TRANSVR_TASK_RETRY_FOREVER) { - curr_p = next_p; - continue; - } - switch (retval) { - case EVENT_TRANSVR_TASK_WAIT: - break; - case EVENT_TRANSVR_TASK_DONE: - transvr_task_free_one(curr_p); - break; - case EVENT_TRANSVR_TASK_FAIL: - - default: - haserr = 1; - transvr_task_free_one(curr_p); - break; - } - curr_p = next_p; - } - if (haserr) { - return EVENT_TRANSVR_TASK_FAIL; - } - return EVENT_TRANSVR_TASK_DONE; -} - - -static void -transvr_task_set_delay(struct transvr_worker_s *task_p, - unsigned long delay_msec) { - - task_p->trigger_time = (jiffies + (delay_msec * (HZ/1000))); -} - - -static void -transvr_task_set_retry(struct transvr_worker_s *task_p, - unsigned long retry_times) { - - task_p->retry = retry_times; -} - - -/* For Transceiver Post Task - */ -int -taskfunc_post_do_nothing(struct transvr_worker_s *task_p) { - - return EVENT_TRANSVR_TASK_DONE; -} - - -int -taskfunc_post_handle_task_state(struct transvr_worker_s *task_p) { - - struct transvr_obj_s* tp = task_p->transvr_p; - - switch (task_p->state) { - case STATE_T_TASK_INIT: - case STATE_T_TASK_WAIT: - return EVENT_TRANSVR_TASK_WAIT; - - case STATE_T_TASK_DONE: - tp->state = STATE_TRANSVR_CONNECTED; - tp->send_uevent(tp, KOBJ_ADD); - return EVENT_TRANSVR_TASK_DONE; - - case STATE_T_TASK_FAIL: - tp->state = STATE_TRANSVR_UNEXCEPTED; - return EVENT_TRANSVR_TASK_FAIL; - - default: - break; - } - return EVENT_TRANSVR_TASK_FAIL; -} - - -/* For Transceiver Main Task - */ -int -_taskfunc_sfp_setup_soft_rs(struct transvr_worker_s *task_p, - int input_val, - int address, - int page, - int offset, - int bit_shift, - uint8_t *attr_p, - char *caller) { - - int show_err = 0; - int err_code = DEBUG_TRANSVR_INT_VAL; - char *err_str = DEBUG_TRANSVR_STR_VAL; - char *func_str = "_taskfunc_sfp_setup_soft_rs"; - - err_code = _sfp_update_attr_soft_rs0(task_p->transvr_p, 0); - if (err_code < 0) { - err_str = "Get current soft_rs0 fail!"; - goto err_taskfunc_sfp_setup_soft_rs_1; - } - err_code = __sfp_set_soft_rs(task_p->transvr_p, - input_val, - address, - page, - offset, - bit_shift, - attr_p, - caller, - show_err); - if (err_code < 0) { - err_str = "Get current soft_rs0 fail!"; - goto err_taskfunc_sfp_setup_soft_rs_1; - } - return EVENT_TRANSVR_TASK_DONE; - -err_taskfunc_sfp_setup_soft_rs_1: - if ((task_p->retry) == 0) { - SWPS_INFO("%s: %s :%s :%d :%d\n", - func_str, err_str, task_p->transvr_p->swp_name, input_val, err_code); - } - return EVENT_TRANSVR_TASK_FAIL; -} - - -int -__taskfunc_sfp_setup_hard_rs(struct transvr_worker_s *task_p, - int input_val, - int (*get_func)(struct ioexp_obj_s *self, int virt_offset), - int (*set_func)(struct ioexp_obj_s *self, int virt_offset, int input_val)) { - - int err_val = EVENT_TRANSVR_EXCEP_EXCEP; - char *err_str = DEBUG_TRANSVR_STR_VAL; - - err_val = get_func(task_p->transvr_p->ioexp_obj_p, - task_p->transvr_p->ioexp_virt_offset); - - if (err_val < 0) { - if (err_val == ERR_IOEXP_NOTSUPPORT) { - return EVENT_TRANSVR_TASK_DONE; - } - err_str = "Get current hard_rs fail!"; - goto err_p_taskfunc_sfp_setup_hard_rs_1; - } - if (err_val == input_val) { - return EVENT_TRANSVR_TASK_DONE; - } - err_val = set_func(task_p->transvr_p->ioexp_obj_p, - task_p->transvr_p->ioexp_virt_offset, - input_val); - if (err_val < 0) { - err_str = "Setup hard_rs fail!"; - goto err_p_taskfunc_sfp_setup_hard_rs_1; - } - return EVENT_TRANSVR_TASK_DONE; - -err_p_taskfunc_sfp_setup_hard_rs_1: - if ((task_p->retry) == 0) { - SWPS_INFO("%s: %s :%s :%d :%d\n", - __func__, err_str, task_p->transvr_p->swp_name, input_val, err_val); - } - return EVENT_TRANSVR_TASK_FAIL; -} - - -int -_taskfunc_sfp_setup_hard_rs0(struct transvr_worker_s *task_p, - int input_val) { - - return __taskfunc_sfp_setup_hard_rs(task_p, - input_val, - task_p->transvr_p->ioexp_obj_p->get_hard_rs0, - task_p->transvr_p->ioexp_obj_p->set_hard_rs0); -} - - -int -_taskfunc_sfp_setup_hard_rs1(struct transvr_worker_s *task_p, - int input_val) { - - return __taskfunc_sfp_setup_hard_rs(task_p, - input_val, - task_p->transvr_p->ioexp_obj_p->get_hard_rs1, - task_p->transvr_p->ioexp_obj_p->set_hard_rs1); -} - - -int -_taskfunc_sfp_setup_rs0(struct transvr_worker_s *task_p, - int input_val) { - - int bit_shift = 3; - int old_val = DEBUG_TRANSVR_INT_VAL; - int err_val = EVENT_TRANSVR_EXCEP_EXCEP; - char *err_str = DEBUG_TRANSVR_STR_VAL; - char *func_str = "_taskfunc_sfp_setup_rs0"; - - err_val = _taskfunc_sfp_setup_hard_rs0(task_p, - input_val); - if (err_val < 0) { - err_str = "Setup hard_rs0 fail!"; - goto err_private_taskfunc_sfp_setup_rs0_1; - } - old_val = err_val; - err_val = _taskfunc_sfp_setup_soft_rs(task_p, - input_val, - task_p->transvr_p->eeprom_map_p->addr_soft_rs0, - task_p->transvr_p->eeprom_map_p->page_soft_rs0, - task_p->transvr_p->eeprom_map_p->offset_soft_rs0, - bit_shift, - &(task_p->transvr_p->soft_rs0), - func_str); - if (err_val < 0) { - err_str = "Setup soft_rs0 fail!"; - goto err_private_taskfunc_sfp_setup_rs0_1; - } - return EVENT_TRANSVR_TASK_DONE; - -err_private_taskfunc_sfp_setup_rs0_1: - if ((task_p->retry) == 0) { - SWPS_INFO("%s: %s :%s :%d :%d\n", - func_str, err_str, task_p->transvr_p->swp_name, input_val, err_val); - } - _taskfunc_sfp_setup_hard_rs0(task_p, old_val); - return EVENT_TRANSVR_TASK_FAIL; -} - - -int -_taskfunc_sfp_setup_rs1(struct transvr_worker_s *task_p, - int input_val) { - - int bit_shift = 3; - int old_val = DEBUG_TRANSVR_INT_VAL; - int err_val = EVENT_TRANSVR_EXCEP_EXCEP; - char *err_str = DEBUG_TRANSVR_STR_VAL; - char *func_str = "_taskfunc_sfp_setup_rs1"; - - err_val = _taskfunc_sfp_setup_hard_rs1(task_p, - input_val); - if (err_val < 0) { - err_str = "Setup hard_rs1 fail!"; - goto err_private_taskfunc_sfp_setup_rs1_1; - } - old_val = err_val; - err_val = _taskfunc_sfp_setup_soft_rs(task_p, - input_val, - task_p->transvr_p->eeprom_map_p->addr_soft_rs1, - task_p->transvr_p->eeprom_map_p->page_soft_rs1, - task_p->transvr_p->eeprom_map_p->offset_soft_rs1, - bit_shift, - &(task_p->transvr_p->soft_rs1), - func_str); - if (err_val < 0) { - err_str = "Setup soft_rs1 fail!"; - goto err_private_taskfunc_sfp_setup_rs1_1; - } - return EVENT_TRANSVR_TASK_DONE; - -err_private_taskfunc_sfp_setup_rs1_1: - if ((task_p->retry) == 0) { - SWPS_INFO("%s: %s :%s :%d :%d\n", - func_str, err_str, task_p->transvr_p->swp_name, input_val, err_val); - } - _taskfunc_sfp_setup_hard_rs1(task_p, old_val); - return EVENT_TRANSVR_TASK_FAIL; -} - - -int -taskfunc_sfp_setup_SFF8431_case1(struct transvr_worker_s *task_p) { - /* SFF-8431 (8/4/2G Rx Rate_Select only) */ - int update_val = 1; - - return _taskfunc_sfp_setup_rs0(task_p, update_val); -} - - - -int -taskfunc_sfp_setup_SFF8431_case2(struct transvr_worker_s *task_p) { - /* SFF-8431 (8/4/2G Tx Rate_Select only) */ - int update_val = 1; - - return _taskfunc_sfp_setup_rs1(task_p, update_val); -} - - -int -taskfunc_sfp_setup_SFF8431_case3(struct transvr_worker_s *task_p) { - /* SFF-8431 (8/4/2G Independent Rx & Tx Rate_select) */ - int update_rs0 = 1; - int update_rs1 = 1; - int err_code = DEBUG_TRANSVR_INT_VAL; - - err_code = _taskfunc_sfp_setup_rs0(task_p, update_rs0); - if (err_code < 0) { - return err_code; - } - return _taskfunc_sfp_setup_rs1(task_p, update_rs1); -} - - -int -taskfunc_sfp_handle_1g_rj45(struct transvr_worker_s *task_p) { - - /* Not all of platform support 0x56 for transceiver - * external PHY, Support list as below: - * => 1. Magnolia-PVT (PS: EVT & DVT not ready) - */ - int ext_phy_addr = 0x56; - int ext_phy_page = -1; - int ext_phy_offs = 0x11; - int ext_phy_len = 1; - int lstate_mask = 0x04; /* 00000100 */ - int show_err = 0; - int fail_retry = 5; - int fail_delay = 1000; /* msec */ - int err_code = DEBUG_TRANSVR_INT_VAL; - uint8_t detect_val = DEBUG_TRANSVR_HEX_VAL; - char err_str[64] = DEBUG_TRANSVR_STR_VAL; - int *tmp_p = NULL; - char *func_name = "taskfunc_sfp_handle_1g_rj45"; - - if (task_p->transvr_p->state != STATE_TRANSVR_CONNECTED) { - return EVENT_TRANSVR_TASK_DONE; - } - if ( (task_p->transvr_p->info != TRANSVR_CLASS_BASE_T_1000) && - (task_p->transvr_p->info != TRANSVR_CLASS_BASE_T_1000_up) ) { - goto err_taskfunc_sfp_handle_1g_rj45_1; - } - err_code = _common_update_uint8_attr(task_p->transvr_p, - ext_phy_addr, - ext_phy_page, - ext_phy_offs, - ext_phy_len, - &detect_val, - func_name, - show_err); - if ( (err_code < 0) || - (detect_val == DEBUG_TRANSVR_HEX_VAL) ) { - snprintf(err_str, sizeof(err_str), "Detect external link status fail"); - goto err_taskfunc_sfp_handle_1g_rj45_2; - } - if ((detect_val & lstate_mask) == lstate_mask) { - goto ok_taskfunc_sfp_handle_1g_rj45_link_up; - } - goto ok_taskfunc_sfp_handle_1g_rj45_link_down; - -ok_taskfunc_sfp_handle_1g_rj45_link_up: - /* Filter out noise */ - if (!(task_p->p_data)) { - tmp_p = kzalloc(sizeof(int), GFP_KERNEL); - if (!tmp_p) { - snprintf(err_str, sizeof(err_str), "kzalloc p_data fail"); - goto err_taskfunc_sfp_handle_1g_rj45_2; - } - *tmp_p = TRANSVR_CLASS_BASE_T_1000_up; - task_p->p_data = tmp_p; - goto ok_taskfunc_sfp_handle_1g_rj45_done; - } - if ((*(int *)(task_p->p_data)) != TRANSVR_CLASS_BASE_T_1000_up) { - kfree(task_p->p_data); - task_p->p_data = NULL; - snprintf(err_str, sizeof(err_str), "Internal error"); - goto err_taskfunc_sfp_handle_1g_rj45_2; - } - task_p->transvr_p->info = TRANSVR_CLASS_BASE_T_1000_up; - kfree(task_p->p_data); - task_p->p_data = NULL; - goto ok_taskfunc_sfp_handle_1g_rj45_done; - -ok_taskfunc_sfp_handle_1g_rj45_link_down: - if (task_p->p_data) { - kfree(task_p->p_data); - task_p->p_data = NULL; - } - task_p->transvr_p->info = TRANSVR_CLASS_BASE_T_1000; - goto ok_taskfunc_sfp_handle_1g_rj45_done; - -ok_taskfunc_sfp_handle_1g_rj45_done: - if (task_p->retry != VAL_TRANSVR_TASK_RETRY_FOREVER) { - transvr_task_set_retry(task_p, VAL_TRANSVR_TASK_RETRY_FOREVER); - } - return EVENT_TRANSVR_TASK_DONE; - -err_taskfunc_sfp_handle_1g_rj45_1: - snprintf(err_str, sizeof(err_str), "Detect transceiver:%d not Base-T, remove task.", - task_p->transvr_p->info); - SWPS_INFO("%s: %s :%s\n", __func__, err_str, task_p->transvr_p->swp_name); - transvr_task_set_retry(task_p, 0); - return EVENT_TRANSVR_TASK_DONE; - -err_taskfunc_sfp_handle_1g_rj45_2: - if (task_p->retry == VAL_TRANSVR_TASK_RETRY_FOREVER) { - transvr_task_set_retry(task_p, fail_retry); - } - if ((task_p->retry) == 0) { - /* Error case: - * => In this case, SWPS will stop external Link state monitor features - * and keeps transvr_p->info on TRANSVR_CLASS_BASE_T_1000_up. - * Upper layer will see it always Linkup that because of these type of - * transceiver has external phy, BCM chip see it as Loopback transceiver. - */ - SWPS_WARN("%s can not access external PHY of Base-T SFP transceiver\n", - task_p->transvr_p->swp_name); - task_p->transvr_p->info = TRANSVR_CLASS_BASE_T_1000_up; - return EVENT_TRANSVR_TASK_DONE; - } else { - transvr_task_set_delay(task_p, fail_delay); - } - return EVENT_TRANSVR_TASK_FAIL; -} - - -int -_taskfunc_qsfp_setup_power_mod(struct transvr_obj_s *self, - int setup_val) { - - int curr_val = DEBUG_TRANSVR_INT_VAL; - int err_val = DEBUG_TRANSVR_INT_VAL; - char *err_msg = DEBUG_TRANSVR_STR_VAL; - - curr_val = self->ioexp_obj_p->get_lpmod(self->ioexp_obj_p, - self->ioexp_virt_offset); - if (curr_val < 0){ - err_msg = "Get current value fail!"; - goto err_private_taskfunc_qsfp_setup_power_mod_1; - } - if (curr_val == setup_val){ - return EVENT_TRANSVR_TASK_DONE; - } - err_val = self->ioexp_obj_p->set_lpmod(self->ioexp_obj_p, - self->ioexp_virt_offset, - setup_val); - if (err_val < 0){ - err_msg = "Setup power mode fail!"; - goto err_private_taskfunc_qsfp_setup_power_mod_1; - } - return EVENT_TRANSVR_TASK_DONE; - -err_private_taskfunc_qsfp_setup_power_mod_1: - SWPS_INFO("%s: %s :%d :%d :%d\n", - __func__, err_msg, err_val, curr_val, setup_val); - return EVENT_TRANSVR_TASK_FAIL; -} - - -int -taskfunc_qsfp_handle_tx_disable(struct transvr_worker_s *task_p) { - - int i = 0; - int retry = 5; - int delay_ms = 100; - - if (task_p->transvr_p->auto_tx_disable == VAL_TRANSVR_FUNCTION_DISABLE) { - return EVENT_TRANSVR_TASK_DONE; - } - if (!_qsfp_is_implement_tx_disable(task_p->transvr_p)) { - return EVENT_TRANSVR_TASK_DONE; - } - for (i=0; itransvr_p, - task_p->transvr_p->auto_tx_disable) - == EVENT_TRANSVR_TASK_DONE) { - goto ok_taskfunc_qsfp_handle_tx_disable; - } - mdelay(delay_ms); - } - SWPS_INFO("%s auto setup tx_disable:0x%02x fail.\n", - task_p->transvr_p->swp_name, - task_p->transvr_p->auto_tx_disable); - return EVENT_TRANSVR_INIT_FAIL; - -ok_taskfunc_qsfp_handle_tx_disable: - SWPS_INFO("%s auto setup tx_disable:0x%02x ok.\n", - task_p->transvr_p->swp_name, - task_p->transvr_p->auto_tx_disable); - return EVENT_TRANSVR_TASK_DONE; -} - - -int -taskfunc_qsfp_set_hpmod(struct transvr_worker_s *task_p) { - - int err = DEBUG_TRANSVR_INT_VAL; - int HIGH_POWER_MODE = 0; - - /* Handle power mode */ - err = _taskfunc_qsfp_setup_power_mod(task_p->transvr_p, - HIGH_POWER_MODE); - if (err < 0) { - SWPS_INFO("%s: setup hpmod fail :%d :%s\n", - __func__, err, task_p->transvr_p->swp_name); - return err; - } - /* Handle auto tx_disable - * [Note] - * => Because there are some transceiver have timing issues or - * setup sequence issues, therefore we handle auto tx_disable - * after handle power mode. - */ - mdelay(100); - return taskfunc_qsfp_handle_tx_disable(task_p); -} - - -int -taskfunc_qsfp_set_lpmod(struct transvr_worker_s *task_p) { - - int LOW_POWER_MODE = 1; - return _taskfunc_qsfp_setup_power_mod(task_p->transvr_p, - LOW_POWER_MODE); -} - - -static int -initfunc_sfp_handle_multi_rate_mode(struct transvr_obj_s *self) { - - int task_retry = 3; - int err_code = DEBUG_TRANSVR_INT_VAL; - char *err_str = DEBUG_TRANSVR_STR_VAL; - char *func_str = "sfp_handle_multi_rate_mode"; - struct transvr_worker_s *task_p = NULL; - - switch (self->rate_id) { - case 0x00: /* Unspecified */ - case 0x03: /* Unspecified */ - case 0x05: /* Unspecified */ - case 0x07: /* Unspecified */ - case 0x09: /* Unspecified */ - case 0x0B: /* Unspecified */ - case 0x0D: /* Unspecified */ - case 0x0F: /* Unspecified */ - goto sfp_handle_multi_rate_mode_4_unspecified; - - case 0x02: /* SFF-8431 (8/4/2G Rx Rate_Select only) */ - task_p = transvr_task_creat(self, - taskfunc_sfp_setup_SFF8431_case1, - taskfunc_post_handle_task_state, - func_str); - goto sfp_handle_multi_rate_mode_4_sff8431; - - case 0x04: /* SFF-8431 (8/4/2G Tx Rate_Select only) */ - task_p = transvr_task_creat(self, - taskfunc_sfp_setup_SFF8431_case2, - taskfunc_post_handle_task_state, - func_str); - goto sfp_handle_multi_rate_mode_4_sff8431; - - case 0x06: /* SFF-8431 (8/4/2G Independent Rx & Tx Rate_select) */ - task_p = transvr_task_creat(self, - taskfunc_sfp_setup_SFF8431_case3, - taskfunc_post_handle_task_state, - func_str); - goto sfp_handle_multi_rate_mode_4_sff8431; - - case 0x01: /* SFF-8079 (4/2/1G Rate_Select & AS0/AS1) */ - err_str = "SFF-8079 (4/2/1G Rate_Select & AS0/AS1)"; - goto sfp_handle_multi_rate_mode_4_not_support; - - case 0x08: /* FC-PI-5 (16/8/4G Rx Rate_select only) - * High=16G only, Low=8G/4G - */ - err_str = "FC-PI-5 (16/8/4G Rx Rate_select only)"; - goto sfp_handle_multi_rate_mode_4_not_support; - - case 0x0A: /* FC-PI-5 (16/8/4G Independent Rx, Tx Rate_select) - * High=16G only, Low=8G/4G - */ - err_str = "FC-PI-5 (16/8/4G Independent Rx, Tx Rate_select)"; - goto sfp_handle_multi_rate_mode_4_not_support; - - case 0x0C: /* FC-PI-6 (32/16/8G Independent Rx, Tx Rate_Select) - * High=32G only, Low = 16G/8G - */ - err_str = "FC-PI-6 (32/16/8G Independent Rx, Tx Rate_Select)"; - goto sfp_handle_multi_rate_mode_4_not_support; - - case 0x0E: /* 10/8G Rx and Tx Rate_Select controlling the operation or - * locking modes of the internal signal conditioner, retimer - * or CDR, according to the logic table defined in Table 10-2, - * High Bit Rate (10G) =9.95-11.3 Gb/s; Low Bit Rate (8G) = - * 8.5 Gb/s. In this mode, the default value of bit 110.3 (Soft - * Rate Select RS(0), Table 9-11) and of bit 118.3 (Soft Rate - * Select RS(1), Table 10-1) is 1. - */ - err_str = "cable type: 0x0E"; - goto sfp_handle_multi_rate_mode_4_not_support; - - default: - err_str = "cable type: UNKNOW"; - goto sfp_handle_multi_rate_mode_4_not_support; - } - -sfp_handle_multi_rate_mode_4_sff8431: - if (!task_p) { - err_str = "Create task fail!"; - goto sfp_handle_multi_rate_mode_4_fail_1; - } - transvr_task_set_retry(task_p, task_retry); - return EVENT_TRANSVR_TASK_WAIT; - -sfp_handle_multi_rate_mode_4_unspecified: - return EVENT_TRANSVR_TASK_DONE; - -sfp_handle_multi_rate_mode_4_not_support: - SWPS_INFO("%s: Does not support %s :%s :0x%02x\n", - func_str, err_str, self->swp_name, self->rate_id); - return EVENT_TRANSVR_TASK_DONE; - -sfp_handle_multi_rate_mode_4_fail_1: - SWPS_INFO("%s: %s :%s :0x%02x, :%d\n", - func_str, err_str, self->swp_name, self->rate_id, err_code); - return EVENT_TRANSVR_INIT_FAIL; -} - - -static int -initfunc_sfp_handle_1g_rj45(struct transvr_obj_s *self) { - - struct transvr_worker_s *task_p = NULL; - int detect_cls = DEBUG_TRANSVR_INT_VAL; - char err_str[64] = DEBUG_TRANSVR_STR_VAL; - char *func_str = "initfunc_sfp_handle_1g_rj45"; - - - if (self->info == TRANSVR_CLASS_BASE_T_1000) { - task_p = transvr_task_creat(self, - taskfunc_sfp_handle_1g_rj45, - taskfunc_post_do_nothing, - func_str); - if (!task_p) { - snprintf(err_str, sizeof(err_str), "Create task fail"); - goto err_initfunc_sfp_handle_1g_rj45; - } - transvr_task_set_retry(task_p, VAL_TRANSVR_TASK_RETRY_FOREVER); - } - return EVENT_TRANSVR_TASK_DONE; - -err_initfunc_sfp_handle_1g_rj45: - SWPS_INFO("%s: %s :%s :%d\n", - __func__, err_str, self->swp_name, detect_cls); - return EVENT_TRANSVR_TASK_FAIL; -} - - -static int -initfunc_qsfp_handle_power_mode(struct transvr_obj_s *self) { - - int err_code = EVENT_TRANSVR_EXCEP_INIT; - int power_class = DEBUG_TRANSVR_INT_VAL; - int hpmod_retry = 3; - int lpower_config = 1; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - unsigned long hpmod_delay = 500; /* msec */ - struct transvr_worker_s *task_p = NULL; - - /* Handle power mode for IOEXP */ - power_class = __qsfp_get_power_cls(self, 0); - switch (power_class) { - case 1: /* Case: Low power mode (Class = 1) */ - err_code = _taskfunc_qsfp_setup_power_mod(self, lpower_config); - if (err_code < 0){ - snprintf(err_msg, sizeof(err_msg), "Setup lpmod fail :%d", err_code); - goto err_initfunc_qsfp_handle_power_mode; - } - return EVENT_TRANSVR_TASK_DONE; - - case 2: /* Case: High power mode (Class > 1) */ - case 3: - case 4: - case 5: - case 6: - case 7: - task_p = transvr_task_creat(self, - taskfunc_qsfp_set_hpmod, - taskfunc_post_handle_task_state, - "transvr_init_qsfp"); - if (!task_p) { - snprintf(err_msg, sizeof(err_msg), "Setup lpmod fail :%d", err_code); - goto err_initfunc_qsfp_handle_power_mode; - } - transvr_task_set_retry(task_p, hpmod_retry); - transvr_task_set_delay(task_p, hpmod_delay); - return EVENT_TRANSVR_TASK_WAIT; - - default: - break; - } - snprintf(err_msg, sizeof(err_msg), "Exception case"); - goto err_initfunc_qsfp_handle_power_mode; - -err_initfunc_qsfp_handle_power_mode: - SWPS_INFO("%s: %s :%s \n", __func__, err_msg, self->swp_name); - return EVENT_TRANSVR_INIT_FAIL; -} - - -int -initfunc_qsfp28_handle_cdr(struct transvr_obj_s *self) { - - uint8_t DEFAULT_VAL_CDR = 0xff; - int CDR_FUNC_EXISTED = 0x3; - int show_err = 1; - int err_val = EVENT_TRANSVR_TASK_FAIL; - char *err_msg = DEBUG_TRANSVR_STR_VAL; - char *func_str = "initfunc_qsfp28_handle_cdr"; - - err_val = __qsfp_get_cdr_present(self, 0); - if ( (err_val < 0) || - (err_val == DEBUG_TRANSVR_HEX_VAL) ) { - err_msg = "detect cdr_present fail!"; - goto err_taskfunc_qsfp_handle_cdr_1; - } - if (err_val == CDR_FUNC_EXISTED) { - err_val = _common_set_uint8_attr(self, - self->eeprom_map_p->addr_cdr, - self->eeprom_map_p->addr_cdr, - self->eeprom_map_p->offset_cdr, - DEFAULT_VAL_CDR, - &(self->cdr), - func_str, - show_err); - if (err_val < 0) { - err_msg = "set CDR fail!"; - goto err_taskfunc_qsfp_handle_cdr_1; - } - } - return EVENT_TRANSVR_TASK_DONE; - -err_taskfunc_qsfp_handle_cdr_1: - SWPS_INFO("%s: %s :%d :%s\n", - func_str, err_msg, err_val, self->swp_name); - return EVENT_TRANSVR_INIT_FAIL; -} - -/* ========== Object functions for Final State Machine ========== - */ -int -is_plugged(struct transvr_obj_s *self){ - - int limit = 63; - int present = DEBUG_TRANSVR_INT_VAL; - char emsg[64] = DEBUG_TRANSVR_STR_VAL; - struct ioexp_obj_s *ioexp_p = self->ioexp_obj_p; - - if (!ioexp_p) { - snprintf(emsg, limit, "ioexp_p is null!"); - goto err_is_plugged_1; - } - present = ioexp_p->get_present(ioexp_p, self->ioexp_virt_offset); - switch (present){ - case 0: - return 1; - case 1: - return 0; - case ERR_IOEXP_UNINIT: - snprintf(emsg, limit, "ioexp_p not ready!"); - goto err_is_plugged_1; - default: - if (ioexp_p->state == STATE_IOEXP_INIT){ - snprintf(emsg, limit, "ioexp_p not ready!"); - goto err_is_plugged_1; - } - break; - } - SWPS_INFO("%s: Exception case! :%d :%d\n", - __func__, present, ioexp_p->state); - return 0; - -err_is_plugged_1: - SWPS_DEBUG("%s: %s\n", __func__, emsg); - return 0; -} - - -static int -detect_transvr_type(struct transvr_obj_s* self){ - - int type = TRANSVR_TYPE_ERROR; - - self->i2c_client_p->addr = VAL_TRANSVR_COMID_ARREESS; - type = i2c_smbus_read_byte_data(self->i2c_client_p, - VAL_TRANSVR_COMID_OFFSET); - - /* Case: 1. Wait transceiver I2C module. - * 2. Transceiver I2C module failure. - * Note: 1. SFF allow maximum transceiver initial time is 2 second. So, there - * are exist some case that we need to wait transceiver. - * For these case, we keeps status on "TRANSVR_TYPE_UNPLUGGED", than - * state machine will keep trace with it. - * 2. There exist some I2C failure case we need to handle. Such as user - * insert the failure transceiver, or any reason cause it abnormal. - */ - if (type < 0){ - switch (type) { - case -EIO: - SWPS_DEBUG("%s: %s smbus return:-5 (I/O error)\n", - __func__, self->swp_name); - return TRANSVR_TYPE_UNPLUGGED; - case -ENXIO: - SWPS_DEBUG("%s: %s smbus return:-6 (No such device or address)\n", - __func__, self->swp_name); - return TRANSVR_TYPE_UNPLUGGED; - default: - break; - } - SWPS_INFO("%s: %s unexpected smbus return:%d \n", - __func__, self->swp_name, type); - return TRANSVR_TYPE_ERROR; - } - /* Identify valid transceiver type */ - switch (type){ - case TRANSVR_TYPE_SFP: - case TRANSVR_TYPE_QSFP: - case TRANSVR_TYPE_QSFP_PLUS: - case TRANSVR_TYPE_QSFP_28: - break; - case TRANSVR_TYPE_UNKNOW_1: - case TRANSVR_TYPE_UNKNOW_2: - type = TRANSVR_TYPE_UNKNOW_2; - break; - default: - SWPS_DEBUG("%s: unknow type:0x%02x \n", __func__, type); - type = TRANSVR_TYPE_ERROR; - break; - } - return type; -} - - -static int -detect_transvr_state(struct transvr_obj_s *self, - int result[2]){ - /* [return] [result-0] [result-1] - * 0 STATE_TRANSVR_CONNECTED TRANSVR_TYPE_FAKE - * 0 STATE_TRANSVR_DISCONNECTED TRANSVR_TYPE_UNPLUGGED - * 0 STATE_TRANSVR_ISOLATED TRANSVR_TYPE_ERROR - * 0 STATE_TRANSVR_INIT / - * 0 STATE_TRANSVR_SWAPPED - * 0 STATE_TRANSVR_CONNECTED - * ERR_TRNASVR_BE_ISOLATED STATE_TRANSVR_ISOLATED TRANSVR_TYPE_ERROR - * ERR_TRANSVR_I2C_CRASH STATE_TRANSVR_UNEXCEPTED TRANSVR_TYPE_ERROR - * ERR_TRANSVR_UNEXCPT STATE_TRANSVR_UNEXCEPTED TRANSVR_TYPE_UNKNOW_1/2 - */ - result[0] = STATE_TRANSVR_UNEXCEPTED; /* For return state */ - result[1] = TRANSVR_TYPE_ERROR; /* For return type */ - - /* Case1: Fake type */ - if (self->type == TRANSVR_TYPE_FAKE){ - result[0] = STATE_TRANSVR_CONNECTED; - result[1] = TRANSVR_TYPE_FAKE; - return 0; - } - /* Case2: Transceiver unplugged */ - if (!is_plugged(self)){ - result[0] = STATE_TRANSVR_DISCONNECTED; - result[1] = TRANSVR_TYPE_UNPLUGGED; - return 0; - } - /* Case3: Transceiver be isolated */ - if (self->state == STATE_TRANSVR_ISOLATED){ - result[0] = STATE_TRANSVR_ISOLATED; - result[1] = TRANSVR_TYPE_ERROR; - return ERR_TRNASVR_BE_ISOLATED; - } - /* Case4: Transceiver plugged */ - result[1] = detect_transvr_type(self); - /* Case4.1: I2C topology crash - * Note : There are some I2C issues cause by transceiver/cables. - * We need to check topology status when user insert it. - * But in this step, we can't not ensure this is the issues - * port. So, it return the ERR_TRANSVR_I2C_CRASH, then upper - * layer will diagnostic I2C topology. - */ - if (check_channel_tier_1() < 0) { - SWPS_INFO("%s: %s detect I2C crash :%d\n", - __func__, self->swp_name, self->state); - result[0] = STATE_TRANSVR_UNEXCEPTED; - result[1] = TRANSVR_TYPE_ERROR; - return ERR_TRANSVR_I2C_CRASH; - } - /* Case4.2: System initial not ready, - * Note : Sometime i2c channel or transceiver EEPROM will delay that will - * cause system in inconsistent state between EEPROM and IOEXP. - * In this case, SWP transceiver object keep state at LINK_DOWN - * to wait system ready. - * By the way, State Machine will handle these case. - */ - if (result[1] == TRANSVR_TYPE_UNPLUGGED){ - result[0] = STATE_TRANSVR_DISCONNECTED; - return 0; - } - /* Case4.3: Error transceiver type */ - if (result[1] == TRANSVR_TYPE_ERROR){ - result[0] = STATE_TRANSVR_ISOLATED; - SWPS_INFO("%s: %s detect error type\n", __func__, self->swp_name); - alarm_msg_2_user(self, "detected transceiver/cables not meet SFF standard!"); - return ERR_TRNASVR_BE_ISOLATED; - } - /* Case3.3: Unknow transceiver type */ - if ((result[1] == TRANSVR_TYPE_UNKNOW_1) || - (result[1] == TRANSVR_TYPE_UNKNOW_2) ){ - result[0] = STATE_TRANSVR_UNEXCEPTED; - return ERR_TRANSVR_UNEXCPT; - } - /* Case3.4: During initial process */ - if (self->state == STATE_TRANSVR_INIT){ - result[0] = STATE_TRANSVR_INIT; - return 0; - } - /* Case3.5: Transceiver be swapped */ - if (self->type != result[1]){ - result[0] = STATE_TRANSVR_SWAPPED; - return 0; - } - /* Case3.6: Link up state */ - result[0] = STATE_TRANSVR_CONNECTED; - return 0; -} - - -int -_sfp_detect_class_by_extend_comp(struct transvr_obj_s* self) { - /* Reference: SFF-8024 (v3.8) - */ - int detect_val = _sfp_get_comp_extended(self); - - switch(detect_val) { - case 0x00: /* Unspecified */ - return TRANSVR_CLASS_UNSPECIFIED; - - case 0x01: /* 100G AOC (Active Optical Cable) or 25GAUI C2M */ - case 0x18: /* 100G AOC or 25GAUI C2M AOC. */ - return TRANSVR_CLASS_OPTICAL_25G_AOC; - - case 0x02: /* 100GBASE-SR4 or 25GBASE-SR */ - return TRANSVR_CLASS_OPTICAL_25G_SR; - - case 0x03: /* 100GBASE-LR4 or 25GBASE-LR */ - return TRANSVR_CLASS_OPTICAL_25G_LR; - - case 0x04: /* 100GBASE-ER4 or 25GBASE-ER */ - return TRANSVR_CLASS_OPTICAL_25G_ER; - - case 0x08: /* 100G ACC (Active Copper Cable) or 25GAUI C2M ACC. */ - case 0x0b: /* 100GBASE-CR4 or 25GBASE-CR CA-L */ - case 0x0c: /* 25GBASE-CR CA-S */ - case 0x0d: /* 25GBASE-CR CA-N */ - case 0x19: /* 100G ACC or 25GAUI C2M ACC. */ - return TRANSVR_CLASS_COPPER_L1_25G; - - default: - break; - } - SWPS_INFO("%s: Unexcept value:0x%02x\n :%s", - __func__, detect_val, self->swp_name); - return TRANSVR_CLASS_ERROR; -} - - -int -_sfp_detect_class_by_10_ethernet(struct transvr_obj_s* self) { - /* Reference: SFF-8472 (v12.2) - */ - int detect_val = DEBUG_TRANSVR_INT_VAL; - - detect_val = _sfp_get_comp_10g_eth_comp(self); - /* Case: Unspecified */ - if (detect_val == 0x00) { - return TRANSVR_CLASS_UNSPECIFIED; - } - /* Case: 10G Optical (x1) */ - if ((detect_val & 0x10) == 0x10) { /* 00010000 : 10GBASE-SR */ - return TRANSVR_CLASS_OPTICAL_10G_S_SR; - } - if ( ((detect_val & 0x20) == 0x20) || /* 00100000 : 10GBASE-LR */ - ((detect_val & 0x40) == 0x40) ){ /* 01000000 : 10GBASE-LRM */ - return TRANSVR_CLASS_OPTICAL_10G_S_LR; - } - if ((detect_val & 0x80) == 0x80) { /* 10000000 : 10GBASE-ER */ - return TRANSVR_CLASS_OPTICAL_10G_S_ER; - } - /* Case: ERROR */ - SWPS_INFO("%s: Unexcept value:0x%02x\n :%s", - __func__, detect_val, self->swp_name); - return TRANSVR_CLASS_ERROR; -} - - -int -_sfp_detect_if_sp_by_br(struct transvr_obj_s* self) { - - int lower_bound_1g = 0x0b; - int upper_bound_1g = 0x1A; - int lower_bound_10g = 0x60; - int upper_bound_10g = 0x75; - int lower_bound_25g = 0xf0; - int upper_bound_25g = 0xff; - int notmal_br = DEBUG_TRANSVR_INT_VAL; - - notmal_br = (int)(self->br); /* updated by update_all() */ - /* Check 25G */ - if ((notmal_br >= lower_bound_25g) && - (notmal_br <= upper_bound_25g) ) { - return TRANSVR_CLASS_25G; - } - /* Check 10G */ - if ((notmal_br >= lower_bound_10g) && - (notmal_br <= upper_bound_10g) ) { - return TRANSVR_CLASS_10G; - } - /* Check 1G */ - if ((notmal_br >= lower_bound_1g) && - (notmal_br <= upper_bound_1g) ) { - return TRANSVR_CLASS_1G; - } - return TRANSVR_CLASS_UNSPECIFIED; -} - - -int -_sfp_detect_class_by_1g_ethernet(struct transvr_obj_s* self) { - /* Reference: SFF-8472 (v12.2) - */ - int detect_val = DEBUG_TRANSVR_INT_VAL; - int speed_br = DEBUG_TRANSVR_INT_VAL; - int speed_tmp = DEBUG_TRANSVR_INT_VAL; - char err_str[64] = DEBUG_TRANSVR_STR_VAL; - - speed_br = _sfp_detect_if_sp_by_br(self); - detect_val = _sfp_get_comp_1g_eth_comp(self); - - if (detect_val < 0) { - snprintf(err_str, sizeof(err_str), "Detect abnormal value:%d", detect_val); - goto err_p_sfp_detect_class_by_1g_ethernet; - } - /* Case: Unspecified */ - if (detect_val == 0x00) { - return TRANSVR_CLASS_UNSPECIFIED; - } - /* Case: 1G (x1) */ - if ((detect_val & 0x01) == 0x01) { /* 00000001 : 1000BASE-SX */ - speed_tmp = TRANSVR_CLASS_OPTICAL_1G_SX; - goto ok_sfp_detect_class_by_1g_ethernet_4_check_br_10g; - } - if ((detect_val & 0x02) == 0x02) { /* 00000010 : 1000BASE-LX *3 */ - speed_tmp = TRANSVR_CLASS_OPTICAL_1G_LX; - goto ok_sfp_detect_class_by_1g_ethernet_4_check_br_10g; - } - if ((detect_val & 0x04) == 0x04) { /* 00000100 : 1000BASE-CX */ - speed_tmp = TRANSVR_CLASS_COPPER_L1_1G; - goto ok_sfp_detect_class_by_1g_ethernet_4_check_br_10g; - } - /* Case: 1000 Base-T (x1) */ - if ((detect_val & 0x08) == 0x08) { /* 00001000 : 1000BASE-T */ - return TRANSVR_CLASS_BASE_T_1000; - } - /* Case: 100 Base */ - if ( ((detect_val & 0x10) == 0x10) || /* 00010000 : 100BASE-LX/LX10 */ - ((detect_val & 0x20) == 0x20) || /* 00100000 : 100BASE-FX */ - ((detect_val & 0x40) == 0x40) || /* 01000000 : BASE-BX10 *3 */ - ((detect_val & 0x80) == 0x80) ){ /* 10000000 : BASE-PX *3 */ - return TRANSVR_CLASS_OPTICAL_100; - } - /* Case: ERROR */ - snprintf(err_str, sizeof(err_str), "Case:ERROR, value:%d", detect_val); - goto err_p_sfp_detect_class_by_1g_ethernet; - -ok_sfp_detect_class_by_1g_ethernet_4_check_br_10g: - switch (speed_br) { - case TRANSVR_CLASS_UNSPECIFIED: - case TRANSVR_CLASS_1G: - return speed_tmp; - case TRANSVR_CLASS_10G: - goto ok_sfp_detect_class_by_1g_ethernet_4_transfer_10G; - } - -ok_sfp_detect_class_by_1g_ethernet_4_transfer_10G: - switch (speed_tmp) { - case TRANSVR_CLASS_OPTICAL_1G_SX: - return TRANSVR_CLASS_OPTICAL_10G_S_SR; - case TRANSVR_CLASS_OPTICAL_1G_LX: - return TRANSVR_CLASS_OPTICAL_10G_S_LR; - case TRANSVR_CLASS_COPPER_L1_1G: - return TRANSVR_CLASS_COPPER_L1_10G; - default: - break; - } - snprintf(err_str, sizeof(err_str), "transfer_1to10 fail, speed:%d", speed_tmp); - goto err_p_sfp_detect_class_by_1g_ethernet; - -err_p_sfp_detect_class_by_1g_ethernet: - SWPS_INFO("%s: %s :%s", __func__, err_str, self->swp_name); - return TRANSVR_CLASS_ERROR; -} - - -int -_sfp_detect_class_by_feature(struct transvr_obj_s* self) { - /* Reference: SFF-8024 (v3.8) - */ - int is_active = 0; - int conn_val = DEBUG_TRANSVR_INT_VAL; - int check_val = DEBUG_TRANSVR_INT_VAL; - int wave_len = DEBUG_TRANSVR_INT_VAL; - int speed_val = DEBUG_TRANSVR_INT_VAL; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - - speed_val = _sfp_detect_if_sp_by_br(self); - conn_val = _sfp_get_connector_type(self); - - switch(conn_val) { - case 0x00: /* Unspecified */ - goto ok_sfp_detect_class_by_feature_4_check_active_passive; - case 0x07: /* LC (Lucent Connector) */ - case 0x0b: /* Optical Pigtail */ - case 0x0c: /* MPO 1x12 */ - case 0x0d: /* MPO 2x16 */ - /* - * ToDo: Need verify Optical Pigtail - */ - goto ok_sfp_detect_class_by_feature_4_optiocal; - case 0x21: /* Copper pigtail */ - /* - * ToDo: Need check ACC use case - */ - goto ok_sfp_detect_class_by_feature_4_check_active_passive; - case 0x23: /* No separable connector */ - /* - * ToDo: Standard not clear, not all transceiver vendor - * have the same defined - */ - goto ok_sfp_detect_class_by_feature_4_check_active_passive; - default: - break; - } - goto ok_sfp_detect_class_by_feature_4_unknow; - -ok_sfp_detect_class_by_feature_4_check_active_passive: - check_val = _sfp_get_cable_tech(self); - switch(check_val) { - case 0x00: /* Unspecified */ - goto ok_sfp_detect_class_by_feature_4_unknow; - case 0x04: /* Passive */ - goto ok_sfp_detect_class_by_feature_4_copper; - case 0x08: /* Active */ - is_active = 1; - goto ok_sfp_detect_class_by_feature_4_aoc; - default: - snprintf(err_msg, sizeof(err_msg), - "_sfp_get_cable_tech return Non define value:%d", - check_val); - break; - } - goto err_sfp_detect_class_by_feature_1; - -ok_sfp_detect_class_by_feature_4_optiocal: - wave_len = _common_count_wavelength(self, - self->wavelength[0], - self->wavelength[1]); - switch(speed_val) { - case TRANSVR_CLASS_25G: - switch (wave_len) { - case VAL_OPTICAL_WAVELENGTH_SR: - return TRANSVR_CLASS_OPTICAL_25G_SR; - case VAL_OPTICAL_WAVELENGTH_LR: - return TRANSVR_CLASS_OPTICAL_25G_LR; - case VAL_OPTICAL_WAVELENGTH_ER: - return TRANSVR_CLASS_OPTICAL_25G_ER; - default: - break; - } - return TRANSVR_CLASS_OPTICAL_25G; - - case TRANSVR_CLASS_10G: - switch (wave_len) { - case VAL_OPTICAL_WAVELENGTH_SR: - return TRANSVR_CLASS_OPTICAL_10G_S_SR; - case VAL_OPTICAL_WAVELENGTH_LR: - return TRANSVR_CLASS_OPTICAL_10G_S_LR; - case VAL_OPTICAL_WAVELENGTH_ER: - return TRANSVR_CLASS_OPTICAL_10G_S_ER; - default: - break; - } - return TRANSVR_CLASS_OPTICAL_10G; - - case TRANSVR_CLASS_1G: - switch (wave_len) { - case VAL_OPTICAL_WAVELENGTH_SR: - return TRANSVR_CLASS_OPTICAL_1G_SX; - case VAL_OPTICAL_WAVELENGTH_LR: - return TRANSVR_CLASS_OPTICAL_1G_LX; - case VAL_OPTICAL_WAVELENGTH_ER: - return TRANSVR_CLASS_OPTICAL_1G_EX; - default: - break; - } - return TRANSVR_CLASS_OPTICAL_1G; - - default: - return TRANSVR_CLASS_OPTICAL; - } - -ok_sfp_detect_class_by_feature_4_aoc: - switch(speed_val) { - case TRANSVR_CLASS_25G: - return TRANSVR_CLASS_OPTICAL_25G_AOC; - case TRANSVR_CLASS_10G: - return TRANSVR_CLASS_OPTICAL_10G_S_AOC; - case TRANSVR_CLASS_1G: - return TRANSVR_CLASS_OPTICAL_1G_AOC; - default: - break; - } - goto ok_sfp_detect_class_by_feature_4_unknow; - -ok_sfp_detect_class_by_feature_4_copper: - switch(speed_val) { - case TRANSVR_CLASS_25G: - return TRANSVR_CLASS_COPPER_L1_25G; - case TRANSVR_CLASS_10G: - return TRANSVR_CLASS_COPPER_L1_10G; - case TRANSVR_CLASS_1G: - return TRANSVR_CLASS_COPPER_L1_1G; - default: - return TRANSVR_CLASS_COPPER; - } - -ok_sfp_detect_class_by_feature_4_unknow: - return TRANSVR_CLASS_UNSPECIFIED; - -err_sfp_detect_class_by_feature_1: - SWPS_INFO("%s: %s\n :%s", __func__, err_msg, self->swp_name); - return TRANSVR_CLASS_ERROR; -} - - -int -sft_detect_transvr_class(struct transvr_obj_s* self) { - - int detect_val = DEBUG_TRANSVR_INT_VAL; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - - /* Check Extended Compliance */ - detect_val = _sfp_detect_class_by_extend_comp(self); - switch(detect_val) { - case TRANSVR_CLASS_UNSPECIFIED: - break; - case TRANSVR_CLASS_OPTICAL_25G_AOC: - case TRANSVR_CLASS_OPTICAL_25G_SR: - case TRANSVR_CLASS_OPTICAL_25G_LR: - case TRANSVR_CLASS_OPTICAL_25G_ER: - case TRANSVR_CLASS_COPPER_L1_25G: - return detect_val; - default: - snprintf(err_msg, sizeof(err_msg), - "Detect undefined extend_comp:%d", - detect_val); - goto err_sft_detect_transceiver_class_1; - } - /* Check 10G Compliance */ - detect_val = _sfp_detect_class_by_10_ethernet(self); - switch(detect_val) { - case TRANSVR_CLASS_UNSPECIFIED: - break; - case TRANSVR_CLASS_OPTICAL_10G_S_SR: - case TRANSVR_CLASS_OPTICAL_10G_S_LR: - case TRANSVR_CLASS_OPTICAL_10G_S_ER: - return detect_val; - default: - snprintf(err_msg, sizeof(err_msg), - "Detect undefined 10G_eth:%d", - detect_val); - goto err_sft_detect_transceiver_class_1; - } - /* Check 1G Compliance */ - detect_val = _sfp_detect_class_by_1g_ethernet(self); - switch(detect_val) { - case TRANSVR_CLASS_UNSPECIFIED: - break; - case TRANSVR_CLASS_OPTICAL_1G_SX: - case TRANSVR_CLASS_OPTICAL_1G_LX: - case TRANSVR_CLASS_COPPER_L1_1G: - case TRANSVR_CLASS_BASE_T_1000: - case TRANSVR_CLASS_OPTICAL_100: - /* - * ToDo: Need Check 0.1G - */ - case TRANSVR_CLASS_OPTICAL_10G_S_SR: - case TRANSVR_CLASS_OPTICAL_10G_S_LR: - case TRANSVR_CLASS_COPPER_L1_10G: - /* Transfer speed case - * => Example: Raycom 10G DAC - */ - return detect_val; - default: - snprintf(err_msg, sizeof(err_msg), - "Detect undefined 1G_eth:%d", - detect_val); - goto err_sft_detect_transceiver_class_1; - } - /* Check by connector, br, wavelength */ - detect_val = _sfp_detect_class_by_feature(self); - switch(detect_val) { - case TRANSVR_CLASS_UNSPECIFIED: - break; - case TRANSVR_CLASS_OPTICAL: - case TRANSVR_CLASS_OPTICAL_1G: - case TRANSVR_CLASS_OPTICAL_1G_SX: - case TRANSVR_CLASS_OPTICAL_1G_LX: - case TRANSVR_CLASS_OPTICAL_1G_EX: - case TRANSVR_CLASS_OPTICAL_1G_AOC: - case TRANSVR_CLASS_OPTICAL_10G: - case TRANSVR_CLASS_OPTICAL_10G_S_SR: - case TRANSVR_CLASS_OPTICAL_10G_S_LR: - case TRANSVR_CLASS_OPTICAL_10G_S_ER: - case TRANSVR_CLASS_OPTICAL_10G_S_AOC: - case TRANSVR_CLASS_OPTICAL_25G: - case TRANSVR_CLASS_OPTICAL_25G_SR: - case TRANSVR_CLASS_OPTICAL_25G_LR: - case TRANSVR_CLASS_OPTICAL_25G_ER: - case TRANSVR_CLASS_OPTICAL_25G_AOC: - case TRANSVR_CLASS_COPPER: - case TRANSVR_CLASS_COPPER_L1_1G: - case TRANSVR_CLASS_COPPER_L1_10G: - case TRANSVR_CLASS_COPPER_L1_25G: - return detect_val; - default: - snprintf(err_msg, sizeof(err_msg), - "Detect undefined get_connector:%d", - detect_val); - goto err_sft_detect_transceiver_class_1; - } - /* Exception case: Can't verify */ - snprintf(err_msg, sizeof(err_msg), "Can not identify!"); - goto err_sft_detect_transceiver_class_1; - -err_sft_detect_transceiver_class_1: - SWPS_INFO("%s: %s :%s\n", __func__, err_msg, self->swp_name); - return TRANSVR_CLASS_ERROR; -} - - -int -_sfp_set_trident2_if_type(struct transvr_obj_s* self, - int transvr_cls, - char *result){ - - int lmax = 8; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - - switch(transvr_cls) { - case TRANSVR_CLASS_ERROR: - case TRANSVR_CLASS_UNSPECIFIED: - break; - /* 25G OPTICAL */ - case TRANSVR_CLASS_OPTICAL_25G_AOC: - case TRANSVR_CLASS_OPTICAL_25G_SR: - case TRANSVR_CLASS_OPTICAL_25G_LR: - case TRANSVR_CLASS_OPTICAL_25G_ER: - case TRANSVR_CLASS_OPTICAL_25G: - return snprintf(result, lmax, TRANSVR_IF_SFI); - /* 25G COPPER */ - case TRANSVR_CLASS_COPPER_L1_25G: - return snprintf(result, lmax, TRANSVR_IF_SFI); - /* 10G OPTICAL */ - case TRANSVR_CLASS_OPTICAL_10G_S_AOC: - case TRANSVR_CLASS_OPTICAL_10G_S_SR: - case TRANSVR_CLASS_OPTICAL_10G_S_LR: - case TRANSVR_CLASS_OPTICAL_10G_S_ER: - case TRANSVR_CLASS_OPTICAL_10G: - return snprintf(result, lmax, TRANSVR_IF_SFI); - /* 10G COPPER */ - case TRANSVR_CLASS_COPPER_L1_10G: - return snprintf(result, lmax, TRANSVR_IF_SFI); - /* 1G OPTICAL */ - case TRANSVR_CLASS_OPTICAL_1G_AOC: - case TRANSVR_CLASS_OPTICAL_1G_SX: - case TRANSVR_CLASS_OPTICAL_1G_LX: - case TRANSVR_CLASS_OPTICAL_1G_EX: - case TRANSVR_CLASS_OPTICAL_1G: - return snprintf(result, lmax, TRANSVR_IF_IF_GMII); - /* 1G COPPER */ - case TRANSVR_CLASS_COPPER_L1_1G: - return snprintf(result, lmax, TRANSVR_IF_IF_GMII); - /* 1G BASE_T */ - case TRANSVR_CLASS_BASE_T_1000: - return snprintf(result, lmax, TRANSVR_IF_IF_GMII); - /* 100 Base */ - case TRANSVR_CLASS_OPTICAL_100: - return snprintf(result, lmax, TRANSVR_IF_IF_GMII); - default: - snprintf(err_msg, sizeof(err_msg), - "Detect undefined value:%d", - transvr_cls); - goto err_sfp_set_trident2_if_type_1; - } - /* Exception case: Can't verify */ - snprintf(err_msg, sizeof(err_msg), "Can not identify!"); - goto err_sfp_set_trident2_if_type_1; - -err_sfp_set_trident2_if_type_1: - snprintf(result, lmax, TRANSVR_UEVENT_UNKNOW); - SWPS_INFO("%s: %s :%s\n", __func__, err_msg, self->swp_name); - return ERR_TRANSVR_ABNORMAL; -} - - -int -_sfp_set_tomahawk_if_type(struct transvr_obj_s* self, - int transvr_cls, - char *result) { - - int lmax = 8; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - - switch(transvr_cls) { - case TRANSVR_CLASS_ERROR: - case TRANSVR_CLASS_UNSPECIFIED: - break; - /* 25G OPTICAL */ - case TRANSVR_CLASS_OPTICAL_25G_AOC: - case TRANSVR_CLASS_OPTICAL_25G_SR: - case TRANSVR_CLASS_OPTICAL_25G_LR: - case TRANSVR_CLASS_OPTICAL_25G_ER: - case TRANSVR_CLASS_OPTICAL_25G: - return snprintf(result, lmax, TRANSVR_IF_SR); - /* 25G COPPER */ - case TRANSVR_CLASS_COPPER_L1_25G: - return snprintf(result, lmax, TRANSVR_IF_KR); - /* 10G OPTICAL */ - case TRANSVR_CLASS_OPTICAL_10G_S_AOC: - case TRANSVR_CLASS_OPTICAL_10G_S_SR: - case TRANSVR_CLASS_OPTICAL_10G_S_LR: - case TRANSVR_CLASS_OPTICAL_10G_S_ER: - case TRANSVR_CLASS_OPTICAL_10G: - return snprintf(result, lmax, TRANSVR_IF_SFI); - /* 10G COPPER */ - case TRANSVR_CLASS_COPPER_L1_10G: - return snprintf(result, lmax, TRANSVR_IF_SFI); - /* 1G OPTICAL */ - case TRANSVR_CLASS_OPTICAL_1G_AOC: - case TRANSVR_CLASS_OPTICAL_1G_SX: - case TRANSVR_CLASS_OPTICAL_1G_LX: - case TRANSVR_CLASS_OPTICAL_1G_EX: - case TRANSVR_CLASS_OPTICAL_1G: - return snprintf(result, lmax, TRANSVR_IF_IF_GMII); - /* 1G COPPER */ - case TRANSVR_CLASS_COPPER_L1_1G: - return snprintf(result, lmax, TRANSVR_IF_IF_GMII); - /* 1G BASE_T */ - case TRANSVR_CLASS_BASE_T_1000: - return snprintf(result, lmax, TRANSVR_IF_IF_GMII); - /* 100 Base */ - case TRANSVR_CLASS_OPTICAL_100: - return snprintf(result, lmax, TRANSVR_IF_IF_GMII); - default: - snprintf(err_msg, sizeof(err_msg), - "Detect undefined value:%d", - transvr_cls); - goto err_sfp_set_tomahawk_if_type_1; - } - /* Exception case: Can't verify */ - snprintf(err_msg, sizeof(err_msg), "Can not identify!"); - goto err_sfp_set_tomahawk_if_type_1; - -err_sfp_set_tomahawk_if_type_1: - snprintf(result, lmax, TRANSVR_UEVENT_UNKNOW); - SWPS_INFO("%s: %s\n :%s", __func__, err_msg, self->swp_name); - return ERR_TRANSVR_ABNORMAL; -} - - -int -_sfp_set_bf_tofino_if_type(struct transvr_obj_s* self, - int transvr_cls, - char *result) { - /* (TBD) - * Due to BF looks like doesn't have interface type. - * We bypass it currently. - */ - int lmax = 8; - return snprintf(result, lmax, TRANSVR_UEVENT_UNKNOW); -} - - -int -_sfp_detect_if_type(struct transvr_obj_s* self, - char *result){ - - int lmax = 8; - int detect_cls = DEBUG_TRANSVR_INT_VAL; - - detect_cls = sft_detect_transvr_class(self); - switch (self->chipset_type) { - case BCM_CHIP_TYPE_TRIDENT_2: - return _sfp_set_trident2_if_type(self, detect_cls, result); - - case BCM_CHIP_TYPE_TRIDENT_3: - case BCM_CHIP_TYPE_TOMAHAWK: - return _sfp_set_tomahawk_if_type(self, detect_cls, result); - - case BF_CHIP_TYPE_TOFINO: - return _sfp_set_bf_tofino_if_type(self, detect_cls, result); - - default: - SWPS_INFO("%s: non-defined chipset_type:%d :%s\n", - __func__, self->chipset_type, self->swp_name); - break; - } - snprintf(result, lmax, TRANSVR_UEVENT_UNKNOW); - return ERR_TRANSVR_ABNORMAL; -} - - -int -sfp_get_if_type(struct transvr_obj_s *self, - char *buf_p){ - - int lmax = 16; - char tmp_result[16] = DEBUG_TRANSVR_STR_VAL; - - if (self->state != STATE_TRANSVR_CONNECTED) { - return snprintf(buf_p, lmax, "%d\n", self->state); - } - if (_sfp_detect_if_type(self, tmp_result) < 0) { - return snprintf(buf_p, lmax, "%d\n", ERR_TRANSVR_ABNORMAL); - } - return snprintf(buf_p, lmax, "%s\n", tmp_result); -} - - -int -_sfp_detect_if_speed(struct transvr_obj_s* self, - char *result){ - - int lmax = 16; - int detect_val = DEBUG_TRANSVR_INT_VAL; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - - detect_val = sft_detect_transvr_class(self); - switch(detect_val) { - case TRANSVR_CLASS_ERROR: - case TRANSVR_CLASS_UNSPECIFIED: - break; - /* 25G OPTICAL */ - case TRANSVR_CLASS_OPTICAL_25G_AOC: - case TRANSVR_CLASS_OPTICAL_25G_SR: - case TRANSVR_CLASS_OPTICAL_25G_LR: - case TRANSVR_CLASS_OPTICAL_25G_ER: - case TRANSVR_CLASS_OPTICAL_25G: - return snprintf(result, lmax, TRANSVR_IF_SP_25G); - /* 25G COPPER */ - case TRANSVR_CLASS_COPPER_L1_25G: - return snprintf(result, lmax, TRANSVR_IF_SP_25G); - /* 10G OPTICAL */ - case TRANSVR_CLASS_OPTICAL_10G_S_AOC: - case TRANSVR_CLASS_OPTICAL_10G_S_SR: - case TRANSVR_CLASS_OPTICAL_10G_S_LR: - case TRANSVR_CLASS_OPTICAL_10G_S_ER: - case TRANSVR_CLASS_OPTICAL_10G: - return snprintf(result, lmax, TRANSVR_IF_SP_10G); - /* 10G COPPER */ - case TRANSVR_CLASS_COPPER_L1_10G: - return snprintf(result, lmax, TRANSVR_IF_SP_10G); - /* 1G OPTICAL */ - case TRANSVR_CLASS_OPTICAL_1G_AOC: - case TRANSVR_CLASS_OPTICAL_1G_SX: - case TRANSVR_CLASS_OPTICAL_1G_LX: - case TRANSVR_CLASS_OPTICAL_1G_EX: - case TRANSVR_CLASS_OPTICAL_1G: - return snprintf(result, lmax, TRANSVR_IF_SP_1G); - /* 1G COPPER */ - case TRANSVR_CLASS_COPPER_L1_1G: - return snprintf(result, lmax, TRANSVR_IF_SP_1G); - /* 1G BASE_T */ - case TRANSVR_CLASS_BASE_T_1000: - return snprintf(result, lmax, TRANSVR_IF_SP_1G); - /* 100 Base */ - case TRANSVR_CLASS_OPTICAL_100: - return snprintf(result, lmax, TRANSVR_IF_SP_100); - default: - snprintf(err_msg, sizeof(err_msg), - "Detect undefined value:%d", - detect_val); - goto err_sfp_detect_if_speed_1; - } - /* Check by BR */ - detect_val = _sfp_detect_if_sp_by_br(self); - switch (detect_val) { - case TRANSVR_CLASS_25G: - return snprintf(result, lmax, TRANSVR_IF_SP_25G); - case TRANSVR_CLASS_10G: - return snprintf(result, lmax, TRANSVR_IF_SP_10G); - case TRANSVR_CLASS_1G: - return snprintf(result, lmax, TRANSVR_IF_SP_1G); - default: - break; - } - /* Exception case: Can't verify */ - snprintf(err_msg, sizeof(err_msg), "Can not identify!"); - goto err_sfp_detect_if_speed_1; - -err_sfp_detect_if_speed_1: - snprintf(result, lmax, TRANSVR_UEVENT_UNKNOW); - SWPS_INFO("%s %s\n :%s", __func__, err_msg, self->swp_name); - return ERR_TRANSVR_ABNORMAL; -} - - -int -sfp_get_if_speed(struct transvr_obj_s *self, - char *buf_p){ - - int lmax = 16; - char tmp_result[16] = DEBUG_TRANSVR_STR_VAL; - - if (self->state != STATE_TRANSVR_CONNECTED) { - return snprintf(buf_p, lmax, "%d\n", self->state); - } - if (_sfp_detect_if_speed(self, tmp_result) < 0) { - return snprintf(buf_p, lmax, "%d\n", ERR_TRANSVR_ABNORMAL); - } - return snprintf(buf_p, lmax, "%s\n", tmp_result); -} - - -int -_qsfp_detect_class_by_extend_comp(struct transvr_obj_s* self) { - /* Reference: SFF-8024 (v3.8) - */ - int detect_val = DEBUG_TRANSVR_INT_VAL; - - detect_val = _qsfp_get_comp_extended(self); - switch(detect_val) { - case 0x00: /* Unspecified */ - return TRANSVR_CLASS_UNSPECIFIED; - - case 0x01: /* 100G AOC (Active Optical Cable) or 25GAUI C2M */ - case 0x18: /* 100G AOC or 25GAUI C2M AOC. */ - return TRANSVR_CLASS_OPTICAL_100G_AOC; - - case 0x06: /* 100G CWDM4 */ - case 0x09: /* Obsolete (assigned before 100G CWDM4 MSA required FEC) */ - case 0x17: /* 100G CLR4 */ - case 0x1A: /* 100GE-DWDM2 */ - return TRANSVR_CLASS_OPTICAL_100G; - - case 0x02: /* 100GBASE-SR4 or 25GBASE-SR */ - return TRANSVR_CLASS_OPTICAL_100G_SR4; - - case 0x03: /* 100GBASE-LR4 or 25GBASE-LR */ - return TRANSVR_CLASS_OPTICAL_100G_LR4; - - case 0x04: /* 100GBASE-ER4 or 25GBASE-ER */ - return TRANSVR_CLASS_OPTICAL_100G_ER4; - - case 0x07: /* 100G PSM4 Parallel SMF */ - return TRANSVR_CLASS_OPTICAL_100G_PSM4; - - case 0x12: /* 40G PSM4 Parallel SMF */ - return TRANSVR_CLASS_OPTICAL_40G; - - case 0x11: /* 4 x 10GBASE-SR */ - return TRANSVR_CLASS_OPTICAL_40G_SR4; - - case 0x10: /* 40GBASE-ER4 */ - return TRANSVR_CLASS_OPTICAL_40G_ER4; - - case 0x08: /* 100G ACC (Active Copper Cable) or 25GAUI C2M ACC. */ - case 0x0b: /* 100GBASE-CR4 or 25GBASE-CR CA-L */ - case 0x19: /* 100G ACC or 25GAUI C2M ACC. */ - return TRANSVR_CLASS_COPPER_L4_100G; - - default: - break; - } - SWPS_INFO("%s: Unexcept value:0x%02x\n :%s", - __func__, detect_val, self->swp_name); - return TRANSVR_CLASS_ERROR; -} - - -int -_qsfp_detect_class_by_10_40_100_ethernet(struct transvr_obj_s* self) { - /* Reference: SFF-8472 (v12.2) - */ - int detect_val = DEBUG_TRANSVR_INT_VAL; - - detect_val = _qsfp_get_comp_10_40_100_ethernet(self); - /* Case: Unspecified */ - if (detect_val == 0x00) { - return TRANSVR_CLASS_UNSPECIFIED; - } - /* Case: 40G Optical */ - if ((detect_val & 0x01) == 0x01) { /* 00000001 : 40G Active Cable (XLPPI) */ - return TRANSVR_CLASS_OPTICAL_40G_AOC; - } - if ((detect_val & 0x04) == 0x04) { /* 00000100 : 40GBASE-SR4 */ - return TRANSVR_CLASS_OPTICAL_40G_SR4; - } - if ( (detect_val & 0x02) == 0x02) { /* 00000010 : 40GBASE-LR4 */ - return TRANSVR_CLASS_OPTICAL_40G_LR4; - } - if ( (detect_val & 0x08) == 0x08) { /* 00001000 : 40GBASE-CR4 */ - return TRANSVR_CLASS_COPPER_L4_40G; - } - /* Case: 10G Optical */ - if ( (detect_val & 0x10) == 0x10) { /* 00010000 : 10GBASE-SR */ - return TRANSVR_CLASS_OPTICAL_10G_Q_SR; - } - if ( ((detect_val & 0x20) == 0x20) || /* 00100000 : 10GBASE-LR */ - ((detect_val & 0x40) == 0x40) ){ /* 01000000 : 10GBASE-LRM */ - return TRANSVR_CLASS_OPTICAL_10G_Q_LR; - } - /* Case: Extend Compliance */ - if ( ((detect_val & 0x80) == 0x80) ){ /* 10000000 : Use Extend Compliance */ - return TRANSVR_CLASS_EXTEND_COMP; - } - /* Case: ERROR */ - SWPS_INFO("%s: Unexcept value:0x%02x\n :%s", - __func__, detect_val, self->swp_name); - return TRANSVR_CLASS_ERROR; -} - - -int -_qsfp_detect_if_sp_by_br(struct transvr_obj_s* self) { - - int lower_bound_10g = 0x10; - int upper_bound_10g = 0x25; - int lower_bound_40g = 0x60; - int upper_bound_40g = 0x75; - int lower_bound_100g = 0x60; - int upper_bound_100g = 0x75; - int used_extend_br = 0xff; - int notmal_br = DEBUG_TRANSVR_INT_VAL; - int extend_br = DEBUG_TRANSVR_INT_VAL; - - notmal_br = (int)(self->br); /* updated by update_all() */ - /* Check 40G */ - if ((notmal_br >= lower_bound_40g) && - (notmal_br <= upper_bound_40g) ) { - return TRANSVR_CLASS_40G; - } - /* Check 100G */ - if (notmal_br == used_extend_br) { - extend_br = (int)(self->extbr); /* updated by update_all() */ - if ((extend_br >= lower_bound_100g) && - (extend_br <= upper_bound_100g) ) { - return TRANSVR_CLASS_100G; - } - } - /* Check 10G */ - if ((notmal_br >= lower_bound_10g) && - (notmal_br <= upper_bound_10g) ) { - return TRANSVR_CLASS_10G; - } - return TRANSVR_CLASS_UNSPECIFIED; -} - - -int -_qsfp_detect_class_by_feature(struct transvr_obj_s* self) { - /* Reference: SFF-8024 (v3.8) - */ - int conn_val = DEBUG_TRANSVR_INT_VAL; - int wave_len = DEBUG_TRANSVR_INT_VAL; - int speed_val = DEBUG_TRANSVR_INT_VAL; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - - speed_val = _qsfp_detect_if_sp_by_br(self); - conn_val = _qsfp_get_connector_type(self); - - switch(conn_val) { - case 0x00: /* Unspecified */ - return TRANSVR_CLASS_UNSPECIFIED; - case 0x07: /* LC (Lucent Connector) */ - case 0x0b: /* Optical Pigtail */ - case 0x0c: /* MPO 1x12 (Multifiber Parallel Optic) */ - case 0x0d: /* MPO 2x16 */ - goto ok_qsfp_detect_class_by_feature_4_optiocal; - case 0x21: /* Copper pigtail */ - goto ok_qsfp_detect_class_by_feature_4_copper; - case 0x23: /* No separable connector */ - if ((_qsfp_get_comp_fc_link_length(self) > 0) || - (_qsfp_get_comp_fc_trans_tech(self) > 0) || - (_qsfp_get_comp_fc_trans_media(self) > 0) || - (_qsfp_get_comp_fc_speed(self) > 0) ) { - goto ok_qsfp_detect_class_by_feature_4_aoc; - } - goto ok_qsfp_detect_class_by_feature_4_copper; - default: - snprintf(err_msg, sizeof(err_msg), - "_qsfp_get_connector_type return Non define value:%d", - conn_val); - goto err_qsfp_detect_class_by_feature_1; - } - return TRANSVR_CLASS_UNSPECIFIED; - -ok_qsfp_detect_class_by_feature_4_optiocal: - wave_len = _common_count_wavelength(self, - self->wavelength[0], - self->wavelength[1]); - switch(speed_val) { - case TRANSVR_CLASS_100G: - switch (wave_len) { - case VAL_OPTICAL_WAVELENGTH_SR: - return TRANSVR_CLASS_OPTICAL_100G_SR4; - case VAL_OPTICAL_WAVELENGTH_LR: - return TRANSVR_CLASS_OPTICAL_100G_LR4; - case VAL_OPTICAL_WAVELENGTH_ER: - return TRANSVR_CLASS_OPTICAL_100G_ER4; - default: - break; - } - return TRANSVR_CLASS_OPTICAL_100G; - - case TRANSVR_CLASS_40G: - switch (wave_len) { - case VAL_OPTICAL_WAVELENGTH_SR: - return TRANSVR_CLASS_OPTICAL_40G_SR4; - case VAL_OPTICAL_WAVELENGTH_LR: - return TRANSVR_CLASS_OPTICAL_40G_LR4; - case VAL_OPTICAL_WAVELENGTH_ER: - return TRANSVR_CLASS_OPTICAL_40G_ER4; - default: - break; - } - return TRANSVR_CLASS_OPTICAL_40G; - - case TRANSVR_CLASS_10G: - switch (wave_len) { - case VAL_OPTICAL_WAVELENGTH_SR: - return TRANSVR_CLASS_OPTICAL_10G_Q_SR; - case VAL_OPTICAL_WAVELENGTH_LR: - return TRANSVR_CLASS_OPTICAL_10G_Q_LR; - case VAL_OPTICAL_WAVELENGTH_ER: - return TRANSVR_CLASS_OPTICAL_10G_Q_ER; - default: - break; - } - return TRANSVR_CLASS_OPTICAL_10G; - - default: - return TRANSVR_CLASS_OPTICAL; - } - -ok_qsfp_detect_class_by_feature_4_aoc: - switch(speed_val) { - case TRANSVR_CLASS_100G: - return TRANSVR_CLASS_OPTICAL_100G_AOC; - case TRANSVR_CLASS_40G: - return TRANSVR_CLASS_OPTICAL_40G_AOC; - case TRANSVR_CLASS_10G: - return TRANSVR_CLASS_OPTICAL_10G_Q_AOC; - default: - return TRANSVR_CLASS_OPTICAL; - } - -ok_qsfp_detect_class_by_feature_4_copper: - switch(speed_val) { - case TRANSVR_CLASS_100G: - return TRANSVR_CLASS_COPPER_L4_100G; - case TRANSVR_CLASS_40G: - return TRANSVR_CLASS_COPPER_L4_40G; - case TRANSVR_CLASS_10G: - return TRANSVR_CLASS_COPPER_L4_10G; - default: - return TRANSVR_CLASS_COPPER; - } - -err_qsfp_detect_class_by_feature_1: - SWPS_INFO("%s: %s\n :%s", - __func__, err_msg, self->swp_name); - return TRANSVR_CLASS_ERROR; -} - - -int -qsft_detect_transvr_class(struct transvr_obj_s* self) { - - int detect_val = DEBUG_TRANSVR_INT_VAL; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - - /* Check Extended Compliance */ - detect_val = _qsfp_detect_class_by_extend_comp(self); - switch (detect_val) { - case TRANSVR_CLASS_UNSPECIFIED: - break; - case TRANSVR_CLASS_OPTICAL_100G: - case TRANSVR_CLASS_OPTICAL_100G_AOC: - case TRANSVR_CLASS_OPTICAL_100G_SR4: - case TRANSVR_CLASS_OPTICAL_100G_LR4: - case TRANSVR_CLASS_OPTICAL_100G_ER4: - case TRANSVR_CLASS_OPTICAL_100G_PSM4: - case TRANSVR_CLASS_OPTICAL_40G: - case TRANSVR_CLASS_OPTICAL_40G_AOC: - case TRANSVR_CLASS_OPTICAL_40G_SR4: - case TRANSVR_CLASS_OPTICAL_40G_LR4: - case TRANSVR_CLASS_OPTICAL_40G_ER4: - case TRANSVR_CLASS_COPPER_L4_100G: - return detect_val; - default: - snprintf(err_msg, sizeof(err_msg), - "Detect undefined extend_comp:%d", - detect_val); - goto err_qsft_detect_transvr_class_1; - } - /* Check 10/40G/100G Ethernet Compliance */ - detect_val = _qsfp_detect_class_by_10_40_100_ethernet(self); - switch(detect_val) { - case TRANSVR_CLASS_UNSPECIFIED: - break; - case TRANSVR_CLASS_OPTICAL_40G_AOC: - case TRANSVR_CLASS_OPTICAL_40G_SR4: - case TRANSVR_CLASS_OPTICAL_40G_LR4: - case TRANSVR_CLASS_OPTICAL_10G_Q_SR: /* Need Check: SR4 or SR */ - case TRANSVR_CLASS_OPTICAL_10G_Q_LR: /* Need Check: SR4 or SR */ - case TRANSVR_CLASS_COPPER_L4_40G: - return detect_val; - case TRANSVR_CLASS_EXTEND_COMP: - /* Format incorrect case (We already checked the Extend - * Compliance is 0 - */ - snprintf(err_msg, sizeof(err_msg), - "Transceiver format incorrect"); - goto err_qsft_detect_transvr_class_1; - default: - snprintf(err_msg, sizeof(err_msg), - "Detect undefined 10/40/100:%d", - detect_val); - goto err_qsft_detect_transvr_class_1; - } - /* Check by Connector type, BR and wavelength */ - detect_val = _qsfp_detect_class_by_feature(self); - switch (detect_val) { - case TRANSVR_CLASS_UNSPECIFIED: - break; - case TRANSVR_CLASS_OPTICAL_100G_ER4: - case TRANSVR_CLASS_OPTICAL_100G_LR4: - case TRANSVR_CLASS_OPTICAL_100G_SR4: - case TRANSVR_CLASS_OPTICAL_100G_AOC: - case TRANSVR_CLASS_OPTICAL_100G: - case TRANSVR_CLASS_OPTICAL_40G_ER4: - case TRANSVR_CLASS_OPTICAL_40G_LR4: - case TRANSVR_CLASS_OPTICAL_40G_SR4: - case TRANSVR_CLASS_OPTICAL_40G_AOC: - case TRANSVR_CLASS_OPTICAL_40G: - case TRANSVR_CLASS_OPTICAL_10G_Q_ER: - case TRANSVR_CLASS_OPTICAL_10G_Q_LR: - case TRANSVR_CLASS_OPTICAL_10G_Q_SR: - case TRANSVR_CLASS_OPTICAL_10G_Q_AOC: - case TRANSVR_CLASS_OPTICAL_10G: - case TRANSVR_CLASS_OPTICAL: - case TRANSVR_CLASS_COPPER_L4_100G: - case TRANSVR_CLASS_COPPER_L4_40G: - case TRANSVR_CLASS_COPPER_L4_10G: - case TRANSVR_CLASS_COPPER: - return detect_val; - default: - snprintf(err_msg, sizeof(err_msg), - "Detect undefined connector:%d", - detect_val); - goto err_qsft_detect_transvr_class_1; - } - /* Exception case: Can't verify */ - snprintf(err_msg, sizeof(err_msg), - "Can not identify!"); - goto err_qsft_detect_transvr_class_1; - -err_qsft_detect_transvr_class_1: - SWPS_INFO("%s: %s\n :%s", __func__, err_msg, self->swp_name); - return TRANSVR_CLASS_ERROR; -} - - -int -_qsfp_set_trident2_if_type(struct transvr_obj_s* self, - int transvr_cls, - char *result){ - - int lmax = 8; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - - switch (transvr_cls) { - case TRANSVR_CLASS_UNSPECIFIED: - case TRANSVR_CLASS_ERROR: - break; - /* 100G Optical */ - case TRANSVR_CLASS_OPTICAL_100G: - case TRANSVR_CLASS_OPTICAL_100G_AOC: - case TRANSVR_CLASS_OPTICAL_100G_SR4: - case TRANSVR_CLASS_OPTICAL_100G_LR4: - case TRANSVR_CLASS_OPTICAL_100G_ER4: - case TRANSVR_CLASS_OPTICAL_100G_PSM4: - return snprintf(result, lmax, TRANSVR_IF_SR4); - /* 100G Copper */ - case TRANSVR_CLASS_COPPER_L4_100G: - return snprintf(result, lmax, TRANSVR_IF_KR4); - /* 40G Optical */ - case TRANSVR_CLASS_OPTICAL_40G: - case TRANSVR_CLASS_OPTICAL_40G_AOC: - case TRANSVR_CLASS_OPTICAL_40G_SR4: - case TRANSVR_CLASS_OPTICAL_40G_LR4: - case TRANSVR_CLASS_OPTICAL_40G_ER4: - return snprintf(result, lmax, TRANSVR_IF_IF_XGMII); - /* 40G Copper */ - case TRANSVR_CLASS_COPPER_L4_40G: - return snprintf(result, lmax, TRANSVR_IF_IF_XGMII); - /* 10G Optical */ - case TRANSVR_CLASS_OPTICAL_10G: - case TRANSVR_CLASS_OPTICAL_10G_Q_AOC: - case TRANSVR_CLASS_OPTICAL_10G_Q_SR: /* Need Check: SR4 or SR */ - case TRANSVR_CLASS_OPTICAL_10G_Q_LR: /* Need Check: LR4 or LR */ - case TRANSVR_CLASS_OPTICAL_10G_Q_ER: /* Need Check: ER4 or ER */ - return snprintf(result, lmax, TRANSVR_IF_IF_XGMII); - /* Optical */ - case TRANSVR_CLASS_OPTICAL: - return snprintf(result, lmax, TRANSVR_IF_IF_XGMII); - /* Copper */ - case TRANSVR_CLASS_COPPER: - return snprintf(result, lmax, TRANSVR_IF_IF_XGMII); - default: - snprintf(err_msg, sizeof(err_msg), - "Detect undefined value:%d", - transvr_cls); - goto err_qsfp_set_trident2_if_type_1; - } - /* Exception case: Can't verify */ - snprintf(err_msg, sizeof(err_msg), "Can not identify!"); - goto err_qsfp_set_trident2_if_type_1; - -err_qsfp_set_trident2_if_type_1: - snprintf(result, lmax, TRANSVR_UEVENT_UNKNOW); - SWPS_INFO("%s: %s\n :%s", __func__, err_msg, self->swp_name); - return ERR_TRANSVR_ABNORMAL; -} - - -int -_qsfp_set_tomahawk_if_type(struct transvr_obj_s* self, - int transvr_cls, - char *result){ - - int lmax = 8; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - - switch (transvr_cls) { - case TRANSVR_CLASS_UNSPECIFIED: - case TRANSVR_CLASS_ERROR: - break; - /* 100G Optical */ - case TRANSVR_CLASS_OPTICAL_100G: - case TRANSVR_CLASS_OPTICAL_100G_AOC: - case TRANSVR_CLASS_OPTICAL_100G_SR4: - case TRANSVR_CLASS_OPTICAL_100G_LR4: - case TRANSVR_CLASS_OPTICAL_100G_ER4: - case TRANSVR_CLASS_OPTICAL_100G_PSM4: - return snprintf(result, lmax, TRANSVR_IF_SR4); - /* 100G Copper */ - case TRANSVR_CLASS_COPPER_L4_100G: - return snprintf(result, lmax, TRANSVR_IF_KR4); - /* 40G Optical */ - case TRANSVR_CLASS_OPTICAL_40G: - case TRANSVR_CLASS_OPTICAL_40G_AOC: - case TRANSVR_CLASS_OPTICAL_40G_SR4: - case TRANSVR_CLASS_OPTICAL_40G_LR4: - case TRANSVR_CLASS_OPTICAL_40G_ER4: - return snprintf(result, lmax, TRANSVR_IF_SR4); - /* 40G Copper */ - case TRANSVR_CLASS_COPPER_L4_40G: - return snprintf(result, lmax, TRANSVR_IF_KR4); - /* 10G Optical */ - case TRANSVR_CLASS_OPTICAL_10G: - case TRANSVR_CLASS_OPTICAL_10G_Q_AOC: - case TRANSVR_CLASS_OPTICAL_10G_Q_SR: /* Need Check: SR4 or SR */ - case TRANSVR_CLASS_OPTICAL_10G_Q_LR: /* Need Check: SR4 or SR */ - case TRANSVR_CLASS_OPTICAL_10G_Q_ER: - return snprintf(result, lmax, TRANSVR_IF_SR4); - /* Optical */ - case TRANSVR_CLASS_OPTICAL: - return snprintf(result, lmax, TRANSVR_IF_SR4); - /* Copper */ - case TRANSVR_CLASS_COPPER: - return snprintf(result, lmax, TRANSVR_IF_KR4); - default: - snprintf(err_msg, sizeof(err_msg), - "Detect undefined value:%d", - transvr_cls); - goto err_qsfp_set_trident2_if_type_1; - } - /* Exception case: Can't verify */ - snprintf(err_msg, sizeof(err_msg), "Can not identify!"); - goto err_qsfp_set_trident2_if_type_1; - -err_qsfp_set_trident2_if_type_1: - snprintf(result, lmax, TRANSVR_UEVENT_UNKNOW); - SWPS_INFO("%s: %s\n :%s", __func__, err_msg, self->swp_name); - return ERR_TRANSVR_ABNORMAL; -} - - -int -_qsfp_set_bf_tofino_if_type(struct transvr_obj_s* self, - int transvr_cls, - char *result) { - /* (TBD) - * Due to BF looks like doesn't have interface type. - * We bypass it currently. - */ - int lmax = 8; - return snprintf(result, lmax, TRANSVR_UEVENT_UNKNOW); -} - - -int -_qsfp_detect_if_type(struct transvr_obj_s* self, - char *result){ - - int lmax = 8; - int detect_cls = DEBUG_TRANSVR_INT_VAL; - - detect_cls = qsft_detect_transvr_class(self); - switch (self->chipset_type) { - case BCM_CHIP_TYPE_TRIDENT_2: - return _qsfp_set_trident2_if_type(self, detect_cls, result); - - case BCM_CHIP_TYPE_TRIDENT_3: - case BCM_CHIP_TYPE_TOMAHAWK: - return _qsfp_set_tomahawk_if_type(self, detect_cls, result); - - case BF_CHIP_TYPE_TOFINO: - return _qsfp_set_bf_tofino_if_type(self, detect_cls, result); - - default: - SWPS_INFO("%s: non-defined chipset_type:%d :%s\n", - __func__, self->chipset_type, self->swp_name); - break; - } - snprintf(result, lmax, TRANSVR_UEVENT_UNKNOW); - return ERR_TRANSVR_ABNORMAL; -} - - -int -qsfp_get_if_type(struct transvr_obj_s *self, - char *buf_p){ - - int lmax = 8; - char tmp_result[8] = DEBUG_TRANSVR_STR_VAL; - - if (self->state != STATE_TRANSVR_CONNECTED) { - return snprintf(buf_p, lmax, "%d\n", self->state); - } - if (_qsfp_detect_if_type(self, tmp_result) < 0) { - return snprintf(buf_p, lmax, "%d\n", ERR_TRANSVR_ABNORMAL); - } - return snprintf(buf_p, lmax, "%s\n", tmp_result); -} - - -int -_qsfp_detect_if_speed(struct transvr_obj_s* self, - char *result){ - int lmax = 16; - int detect_val = DEBUG_TRANSVR_INT_VAL; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - - detect_val = qsft_detect_transvr_class(self); - switch (detect_val) { - case TRANSVR_CLASS_UNSPECIFIED: - case TRANSVR_CLASS_ERROR: - break; - /* 100G Optical */ - case TRANSVR_CLASS_OPTICAL_100G: - case TRANSVR_CLASS_OPTICAL_100G_AOC: - case TRANSVR_CLASS_OPTICAL_100G_SR4: - case TRANSVR_CLASS_OPTICAL_100G_LR4: - case TRANSVR_CLASS_OPTICAL_100G_ER4: - case TRANSVR_CLASS_OPTICAL_100G_PSM4: - return snprintf(result, lmax, TRANSVR_IF_SP_100G); - /* 100G Copper */ - case TRANSVR_CLASS_COPPER_L4_100G: - return snprintf(result, lmax, TRANSVR_IF_SP_100G); - /* 40G Optical */ - case TRANSVR_CLASS_OPTICAL_40G: - case TRANSVR_CLASS_OPTICAL_40G_AOC: - case TRANSVR_CLASS_OPTICAL_40G_SR4: - case TRANSVR_CLASS_OPTICAL_40G_LR4: - case TRANSVR_CLASS_OPTICAL_40G_ER4: - return snprintf(result, lmax, TRANSVR_IF_SP_40G); - /* 40G Copper */ - case TRANSVR_CLASS_COPPER_L4_40G: - return snprintf(result, lmax, TRANSVR_IF_SP_40G); - /* 10G Optical */ - case TRANSVR_CLASS_OPTICAL_10G: - case TRANSVR_CLASS_OPTICAL_10G_Q_AOC: - case TRANSVR_CLASS_OPTICAL_10G_Q_SR: /* Need Check: SR4 or SR */ - case TRANSVR_CLASS_OPTICAL_10G_Q_LR: /* Need Check: SR4 or SR */ - case TRANSVR_CLASS_OPTICAL_10G_Q_ER: - return snprintf(result, lmax, TRANSVR_IF_SP_10G); - /* 10G Copper */ - case TRANSVR_CLASS_COPPER_L4_10G: - return snprintf(result, lmax, TRANSVR_IF_SP_10G); - /* Optical */ - case TRANSVR_CLASS_OPTICAL: - break; - /* Copper */ - case TRANSVR_CLASS_COPPER: - break; - default: - snprintf(err_msg, sizeof(err_msg), - "Detect undefined class case:%d", - detect_val); - goto err_qsfp_detect_if_speed_1; - } - /* Check br and extbr */ - detect_val = _qsfp_detect_if_sp_by_br(self); - switch(detect_val) { - case TRANSVR_CLASS_UNSPECIFIED: - break; - case TRANSVR_CLASS_10G: - return snprintf(result, lmax, TRANSVR_IF_SP_10G); - case TRANSVR_CLASS_40G: - return snprintf(result, lmax, TRANSVR_IF_SP_40G); - case TRANSVR_CLASS_100G: - return snprintf(result, lmax, TRANSVR_IF_SP_100G); - default: - snprintf(err_msg, sizeof(err_msg), - "Detect undefined BR case:%d", - detect_val); - goto err_qsfp_detect_if_speed_1; - } - /* Exception case: Can't verify */ - snprintf(err_msg, sizeof(err_msg), "Can not identify!"); - goto err_qsfp_detect_if_speed_1; - -err_qsfp_detect_if_speed_1: - snprintf(result, lmax, TRANSVR_UEVENT_UNKNOW); - SWPS_INFO("%s: %s :%s\n", __func__, err_msg, self->swp_name); - return ERR_TRANSVR_ABNORMAL; -} - - -int -qsfp_get_if_speed(struct transvr_obj_s *self, - char *buf_p){ - - int lmax = 16; - char tmp_result[16] = DEBUG_TRANSVR_STR_VAL; - - if (self->state != STATE_TRANSVR_CONNECTED) { - return snprintf(buf_p, lmax, "%d\n", self->state); - } - if (_qsfp_detect_if_speed(self, tmp_result) < 0) { - return snprintf(buf_p, lmax, "%d\n", ERR_TRANSVR_ABNORMAL); - } - return snprintf(buf_p, lmax, "%s\n", tmp_result); -} - - -int -_common_set_lane_map_str(struct transvr_obj_s* self, - char *result) { - int i = 0; - int tmp_val = 0; - char tmp_str[LEN_TRANSVR_L_STR] = DEBUG_TRANSVR_STR_VAL; - char err_msg[LEN_TRANSVR_L_STR] = DEBUG_TRANSVR_STR_VAL; - - memset(result, 0, LEN_TRANSVR_L_STR); - snprintf(result, LEN_TRANSVR_L_STR, "%s=", TRANSVR_UEVENT_KEY_LANE); - - for (i=0; ilane_id); i++) { - tmp_val = self->lane_id[i]; - if (tmp_val < 1) { - break; - } - if (tmp_val > 256) { - snprintf(err_msg, sizeof(err_msg), - "detect abnormal value:%d", tmp_val); - goto err_common_set_lane_map_str_1; - } - memset(tmp_str, 0, sizeof(tmp_str)); - if (i == 0) { - snprintf(tmp_str, LEN_TRANSVR_L_STR, "%d", tmp_val); - } else { - snprintf(tmp_str, LEN_TRANSVR_L_STR, ",%d", tmp_val); - } - strncat(result, tmp_str, LEN_TRANSVR_L_STR); - } - if (i == 0) { - goto err_common_set_lane_map_str_2; - } - return 0; - -err_common_set_lane_map_str_1: - SWPS_INFO("%s: %s", __func__, err_msg); -err_common_set_lane_map_str_2: - snprintf(result, LEN_TRANSVR_L_STR, "%s=%s", TRANSVR_UEVENT_KEY_LANE, TRANSVR_UEVENT_UNKNOW); - return EVENT_TRANSVR_TASK_FAIL; -} - - -int -_common_send_uevent(struct transvr_obj_s* self, - enum kobject_action u_action, - int (*detect_if_type)(struct transvr_obj_s *self, char *result), - int (*detect_if_speed)(struct transvr_obj_s *self, char *result), - int send_anyway) { - - char *uevent_envp[4]; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - char tmp_str[32] = DEBUG_TRANSVR_STR_VAL; - char tmp_str_1[32] = DEBUG_TRANSVR_STR_VAL; - char tmp_str_2[32] = DEBUG_TRANSVR_STR_VAL; - char tmp_str_3[64] = DEBUG_TRANSVR_STR_VAL; - - if (TRANSVR_UEVENT_ENABLE != 1) { - return ERR_TRANSVR_NOTSUPPORT; - } - if (_common_get_if_lane(self, tmp_str) < 0) { - snprintf(tmp_str_3, sizeof(tmp_str_3), - "%s=%s", TRANSVR_UEVENT_KEY_LANE, TRANSVR_UEVENT_UNKNOW); - } else { - snprintf(tmp_str_3, sizeof(tmp_str_3), - "%s=%s", TRANSVR_UEVENT_KEY_LANE, tmp_str); - } - switch (u_action) { - case KOBJ_ADD: - /* Detect type */ - if (detect_if_type(self, tmp_str) < 0) { - snprintf(err_msg, sizeof(err_msg), "%s", "Detect interface type fail!"); - snprintf(tmp_str_1, sizeof(tmp_str_1), "%s=%s", TRANSVR_UEVENT_KEY_IF, TRANSVR_UEVENT_UNKNOW); - snprintf(tmp_str_2, sizeof(tmp_str_2), "%s=%s", TRANSVR_UEVENT_KEY_SP, TRANSVR_UEVENT_UNKNOW); - uevent_envp[0] = tmp_str_1; - uevent_envp[1] = tmp_str_2; - uevent_envp[2] = tmp_str_3; - uevent_envp[3] = NULL; - goto private_common_send_uevent_4_fail; - } - snprintf(tmp_str_1, sizeof(tmp_str_1), "%s=%s", TRANSVR_UEVENT_KEY_IF, tmp_str); - uevent_envp[0] = tmp_str_1; - /* Detect speed */ - if (detect_if_speed(self, tmp_str) < 0) { - snprintf(err_msg, sizeof(err_msg), "%s", "Detect interface speed fail!"); - snprintf(tmp_str_2, sizeof(tmp_str_2), "%s=%s", TRANSVR_UEVENT_KEY_SP, TRANSVR_UEVENT_UNKNOW); - uevent_envp[1] = tmp_str_2; - uevent_envp[2] = tmp_str_3; - uevent_envp[3] = NULL; - goto private_common_send_uevent_4_fail; - } - snprintf(tmp_str_2, sizeof(tmp_str_2), "%s=%s", TRANSVR_UEVENT_KEY_SP, tmp_str); - uevent_envp[1] = tmp_str_2; - uevent_envp[2] = tmp_str_3; - uevent_envp[3] = NULL; - goto private_common_send_uevent_4_send; - - case KOBJ_REMOVE: - snprintf(tmp_str_1, sizeof(tmp_str_1), "%s=%s", TRANSVR_UEVENT_KEY_IF, TRANSVR_UEVENT_UNKNOW); - snprintf(tmp_str_2, sizeof(tmp_str_2), "%s=%s", TRANSVR_UEVENT_KEY_SP, TRANSVR_UEVENT_UNKNOW); - uevent_envp[0] = tmp_str_1; - uevent_envp[1] = tmp_str_2; - uevent_envp[2] = tmp_str_3; - uevent_envp[3] = NULL; - goto private_common_send_uevent_4_send; - - default: - snprintf(err_msg, sizeof(err_msg), "kobject_action:%d not support", u_action); - goto private_common_send_uevent_4_fail; - } - snprintf(err_msg, sizeof(err_msg), "%s", "Exception case"); - goto private_common_send_uevent_4_fail; - -private_common_send_uevent_4_fail: - SWPS_INFO("%s: %s :%s\n", __func__, err_msg, self->swp_name); - if (send_anyway) { - goto private_common_send_uevent_4_send; - } - return ERR_TRANSVR_UEVENT_FAIL; - -private_common_send_uevent_4_send: - return kobject_uevent_env(&(self->transvr_dev_p->kobj), - u_action, - uevent_envp); -} - -int -sfp_send_uevent(struct transvr_obj_s* self, - enum kobject_action u_action) { - int send_anyway = 1; - return _common_send_uevent(self, - u_action, - &_sfp_detect_if_type, - &_sfp_detect_if_speed, - send_anyway); -} - - -int -qsfp_send_uevent(struct transvr_obj_s* self, - enum kobject_action u_action) { - int send_anyway = 1; - return _common_send_uevent(self, - u_action, - &_qsfp_detect_if_type, - &_qsfp_detect_if_speed, - send_anyway); -} - - -int -fake_send_uevent(struct transvr_obj_s* self, - enum kobject_action u_action) { - return EVENT_TRANSVR_TASK_DONE; -} - - -int -common_fsm_4_direct_mode(struct transvr_obj_s* self, - char *caller_name){ - - int err; - int detect_result[2]; - int current_state = STATE_TRANSVR_UNEXCEPTED; - int current_type = TRANSVR_TYPE_ERROR; - - if (self->state == STATE_TRANSVR_NEW) { - if (_transvr_init_handler(self) < 0){ - return ERR_TRANSVR_INIT_FAIL; - } - } - err = detect_transvr_state(self, detect_result); - if (err < 0) { - return err; - } - /* In Direct mode, driver only detect transceiver when user call driver interface - * which on sysfs. So it only need consider the state of Transceiver. - */ - current_state = detect_result[0]; - current_type = detect_result[1]; - - switch (current_state){ - - case STATE_TRANSVR_DISCONNECTED: /* Transceiver is not plugged */ - self->state = current_state; - self->type = current_type; - return ERR_TRANSVR_UNPLUGGED; - - case STATE_TRANSVR_INIT: /* Transceiver is plugged, system not ready */ - return ERR_TRANSVR_UNINIT; - - case STATE_TRANSVR_ISOLATED: /* Transceiver is plugged, but has some issues */ - return ERR_TRNASVR_BE_ISOLATED; - - case STATE_TRANSVR_CONNECTED: /* Transceiver is plugged, system is ready */ - self->state = current_state; - self->type = current_type; - return 0; - - case STATE_TRANSVR_SWAPPED: /* Transceiver is plugged, system detect user changed */ - self->type = current_type; - if (reload_transvr_obj(self, current_type) < 0){ - self->state = STATE_TRANSVR_UNEXCEPTED; - return ERR_TRANSVR_UNEXCPT; - } - self->state = current_state; - return 0; - - case STATE_TRANSVR_UNEXCEPTED: /* Transceiver type or state is unexpected case */ - self->state = STATE_TRANSVR_UNEXCEPTED; - self->type = TRANSVR_TYPE_ERROR; - return ERR_TRANSVR_UNEXCPT; - - default: - SWPS_INFO("%s: state:%d not in define.\n", __func__, current_state); - break; - } - return ERR_TRANSVR_UNEXCPT; -} - - -static int -_is_except_happened_4_pmode(struct transvr_obj_s* self, - int new_state) { - - int event_chk = 0; - - if (self->temp == 0){ - return 0; - } - switch (new_state) { - case STATE_TRANSVR_INIT: - event_chk = EVENT_TRANSVR_EXCEP_INIT; - goto check_event_happened_4_pmode; - - case STATE_TRANSVR_CONNECTED: - event_chk = EVENT_TRANSVR_EXCEP_UP; - goto check_event_happened_4_pmode; - - case STATE_TRANSVR_DISCONNECTED: - event_chk = EVENT_TRANSVR_EXCEP_DOWN; - goto check_event_happened_4_pmode; - - case STATE_TRANSVR_SWAPPED: - event_chk = EVENT_TRANSVR_EXCEP_SWAP; - goto check_event_happened_4_pmode; - - case STATE_TRANSVR_UNEXCEPTED: - event_chk = EVENT_TRANSVR_EXCEP_EXCEP; - goto check_event_happened_4_pmode; - - case STATE_TRANSVR_ISOLATED: - event_chk = EVENT_TRANSVR_EXCEP_ISOLATED; - goto check_event_happened_4_pmode; - - default: - SWPS_INFO("%s: unexcepted case:%d\n", __func__, new_state); - break; - } - return 0; - -check_event_happened_4_pmode: - if (self->temp == event_chk){ - return 1; - } - return 0; -} - - -int -common_fsm_4_polling_mode(struct transvr_obj_s* self, - char *caller_name){ - /* [Return Value]: - * ERR_TRANSVR_UNINIT : (1) Initial not ready - * ERR_TRANSVR_UNPLUGGED : (1) Any -> Down - * ERR_TRANSVR_TASK_BUSY : (1) Wait Initial task - * ERR_TRANSVR_UNEXCPT : (1) Initial fail - * (2) Task fail - * (3) Reload fail - * ERR_TRNASVR_BE_ISOLATED : (1) Already be isolated - * OK Case (return 0) : (1) action_4_connected - * (2) action_4_nothing (initial retry) - */ - int curr_state[2]; - int old_state = self->state; - int old_type = self->type; - int new_state = STATE_TRANSVR_UNEXCEPTED; - int new_type = TRANSVR_TYPE_ERROR; - int return_val = ERR_TRANSVR_UNEXCPT; - - /* Never initial */ - if (self->state == STATE_TRANSVR_NEW) { - goto comfsm_action_4_reinit_obj; - } - /* Detect current state */ - switch (detect_transvr_state(self, curr_state)) { - case 0: - new_state = curr_state[0]; - new_type = curr_state[1]; - break; - - case ERR_TRNASVR_BE_ISOLATED: - new_state = STATE_TRANSVR_ISOLATED; - new_type = old_type; - break; - - case ERR_TRANSVR_I2C_CRASH: - goto comfsm_action_4_report_i2c_crash; - - case ERR_TRANSVR_UNEXCPT: - default: - new_state = STATE_TRANSVR_UNEXCEPTED; - new_type = old_type; - } - /* State handling */ - switch (old_state) { - case STATE_TRANSVR_INIT: /* INIT -> */ - return_val = ERR_TRANSVR_UNINIT; - goto comfsm_action_4_keep_state; - - case STATE_TRANSVR_CONNECTED: - switch (new_state) { - case STATE_TRANSVR_INIT: /* Case 1-1: UP -> INIT */ - SWPS_INFO("Detect %s is present. :1-1\n",self->swp_name); - return_val = ERR_TRANSVR_UNINIT; - goto comfsm_action_4_keep_state; - - case STATE_TRANSVR_CONNECTED: /* Case 1-2: UP -> UP */ - return_val = 0; - goto comfsm_action_4_keep_state; - - case STATE_TRANSVR_DISCONNECTED: /* Case 1-3: UP -> DOWN */ - SWPS_INFO("Detect %s is removed. :1-3\n",self->swp_name); - goto comfsm_action_4_disconnected; - - case STATE_TRANSVR_SWAPPED: /* Case 1-4: UP -> SWAP */ - SWPS_INFO("Detect %s is swapped. :1-4\n",self->swp_name); - goto comfsm_action_4_reload_obj; - - case STATE_TRANSVR_UNEXCEPTED: /* Case 1-5: UP -> UNEXPET */ - SWPS_INFO("Detect %s has error. :1-5\n",self->swp_name); - goto comfsm_action_4_unexpected; - - case STATE_TRANSVR_ISOLATED: /* Case 1-6: UP -> ISOLATE */ - SWPS_INFO("Detect %s be isolated. :1-6\n",self->swp_name); - goto comfsm_action_4_isolate_obj; - - default: - break; - } - goto comfsm_action_4_unexpected; - - case STATE_TRANSVR_DISCONNECTED: - switch (new_state) { - case STATE_TRANSVR_INIT: /* Case 2-1: DOWN -> INIT */ - SWPS_INFO("Detect %s is present. :2-1\n",self->swp_name); - return_val = ERR_TRANSVR_UNINIT; - goto comfsm_action_4_keep_state; - - case STATE_TRANSVR_CONNECTED: /* Case 2-2: DOWN -> UP */ - SWPS_INFO("Detect %s is present. :2-2\n",self->swp_name); - goto comfsm_action_4_reinit_obj; - - case STATE_TRANSVR_DISCONNECTED: /* Case 2-3: DOWN -> DOWN */ - return_val = ERR_TRANSVR_UNPLUGGED; - goto comfsm_action_4_keep_state; - - case STATE_TRANSVR_SWAPPED: /* Case 2-4: DOWN -> SWAP */ - SWPS_INFO("Detect %s is swapped. :2-4\n",self->swp_name); - goto comfsm_action_4_reload_obj; - - case STATE_TRANSVR_UNEXCEPTED: /* Case 2-5: DOWN -> UNEXPET */ - SWPS_INFO("Detect %s has error. :2-5\n",self->swp_name); - goto comfsm_action_4_unexpected; - - case STATE_TRANSVR_ISOLATED: /* Case 2-6: DOWN -> ISOLATE */ - SWPS_INFO("Detect %s be isolated. :2-6\n",self->swp_name); - goto comfsm_action_4_isolate_obj; - - default: - break; - } - goto comfsm_action_4_unexpected; - - case STATE_TRANSVR_UNEXCEPTED: - /* Filter out re-action */ - if (_is_except_happened_4_pmode(self, new_state)) { - goto comfsm_action_4_keep_state; - } - /* First action */ - switch (new_state) { - case STATE_TRANSVR_INIT: /* Case 3-1: UNEXPET -> INIT */ - SWPS_INFO("Detect %s is present. :3-1\n",self->swp_name); - self->temp = EVENT_TRANSVR_EXCEP_INIT; - return_val = ERR_TRANSVR_UNINIT; - goto comfsm_action_4_keep_state; - - case STATE_TRANSVR_CONNECTED: /* Case 3-2: UNEXPET -> UP */ - SWPS_INFO("Detect %s is present. :3-2\n",self->swp_name); - self->temp = EVENT_TRANSVR_EXCEP_UP; - goto comfsm_action_4_reload_obj; - - case STATE_TRANSVR_DISCONNECTED: /* Case 3-3: UNEXPET -> DOWN */ - SWPS_INFO("Detect %s is removed. :3-3\n",self->swp_name); - goto comfsm_action_4_disconnected; - - case STATE_TRANSVR_SWAPPED: /* Case 3-4: UNEXPET -> SWAP */ - SWPS_INFO("Detect %s is swapped. :3-4\n",self->swp_name); - self->temp = EVENT_TRANSVR_EXCEP_SWAP; - goto comfsm_action_4_reload_obj; - - case STATE_TRANSVR_UNEXCEPTED: /* Case 3-5: UNEXPET -> UNEXPET */ - self->temp = EVENT_TRANSVR_EXCEP_EXCEP; - return_val = ERR_TRANSVR_UNEXCPT; - goto comfsm_action_4_keep_state; - - case STATE_TRANSVR_ISOLATED: /* Case 3-6: UNEXPET -> ISOLATE */ - SWPS_INFO("Detect %s be isolated. :3-6\n",self->swp_name); - goto comfsm_action_4_isolate_obj; - - default: - break; - } - goto comfsm_action_4_unexpected; - - case STATE_TRANSVR_ISOLATED: - /* Filter out re-action */ - if (_is_except_happened_4_pmode(self, new_state)) { - goto comfsm_action_4_keep_state; - } - /* First action */ - switch (new_state) { - case STATE_TRANSVR_INIT: /* Case 4-1: ISOLATE -> INIT */ - SWPS_INFO("Detect %s internal error. :4-1\n",self->swp_name); - self->temp = EVENT_TRANSVR_EXCEP_INIT; - return_val = ERR_TRNASVR_BE_ISOLATED; - goto comfsm_action_4_keep_state; - - case STATE_TRANSVR_CONNECTED: /* Case 4-2: ISOLATE -> UP */ - SWPS_INFO("Detect %s internal error. :4-2\n",self->swp_name); - self->temp = EVENT_TRANSVR_EXCEP_UP; - return_val = ERR_TRNASVR_BE_ISOLATED; - goto comfsm_action_4_keep_state; - - case STATE_TRANSVR_DISCONNECTED: /* Case 4-3: ISOLATE -> DOWN */ - SWPS_INFO("Detect %s is removed. :4-3\n",self->swp_name); - goto comfsm_action_4_disconnected; - - case STATE_TRANSVR_SWAPPED: /* Case 4-4: ISOLATE -> SWAP */ - SWPS_INFO("Detect %s internal error. :4-4\n",self->swp_name); - self->temp = EVENT_TRANSVR_EXCEP_SWAP; - return_val = ERR_TRNASVR_BE_ISOLATED; - goto comfsm_action_4_keep_state; - - case STATE_TRANSVR_UNEXCEPTED: /* Case 4-5: ISOLATE -> UNEXPET */ - SWPS_INFO("Detect %s internal error. :4-5\n",self->swp_name); - self->temp = EVENT_TRANSVR_EXCEP_EXCEP; - return_val = ERR_TRNASVR_BE_ISOLATED; - goto comfsm_action_4_keep_state; - - case STATE_TRANSVR_ISOLATED: /* Case 4-6: ISOLATE -> ISOLATE */ - return_val = ERR_TRNASVR_BE_ISOLATED; - goto comfsm_action_4_keep_state; - - default: - break; - } - goto comfsm_action_4_unexpected; - - default: - break; - } - goto comfsm_action_4_unexpected; - - -comfsm_action_4_keep_state: - return return_val; - -comfsm_action_4_reinit_obj: - SWPS_DEBUG("FSM action: %s re-initial.\n", self->swp_name); - return_val = _transvr_init_handler(self); - goto comfsm_action_4_identify_event; - -comfsm_action_4_reload_obj: - SWPS_DEBUG("FSM action: %s reload.\n", self->swp_name); - self->type = new_type; - return_val = reload_transvr_obj(self, new_type); - goto comfsm_action_4_identify_event; - -comfsm_action_4_identify_event: - switch (return_val) { - case EVENT_TRANSVR_INIT_UP: - case EVENT_TRANSVR_TASK_DONE: - goto comfsm_action_4_connected; - - case EVENT_TRANSVR_INIT_DOWN: - goto comfsm_action_4_disconnected; - - case EVENT_TRANSVR_INIT_REINIT: - goto comfsm_action_4_nothing; - - case EVENT_TRANSVR_TASK_WAIT: - self->state = STATE_TRANSVR_INIT; - return ERR_TRANSVR_TASK_BUSY; - - case EVENT_TRANSVR_TASK_FAIL: - SWPS_INFO("%s detect EVENT_TRANSVR_TASK_FAIL.\n", self->swp_name); - goto comfsm_action_4_unexpected; - - case EVENT_TRANSVR_INIT_FAIL: - SWPS_INFO("%s detect EVENT_TRANSVR_INIT_FAIL.\n", self->swp_name); - goto comfsm_action_4_unexpected; - - case EVENT_TRANSVR_RELOAD_FAIL: - SWPS_INFO("%s detect EVENT_TRANSVR_RELOAD_FAIL.\n", self->swp_name); - goto comfsm_action_4_unexpected; - - case EVENT_TRANSVR_I2C_CRASH: - goto comfsm_action_4_report_i2c_crash; - - case EVENT_TRANSVR_EXCEP_ISOLATED: - goto comfsm_action_4_isolate_obj; - - default: - SWPS_INFO("%s detect undefined event:%d.\n", self->swp_name, return_val); - goto comfsm_action_4_unexpected; - } - -comfsm_action_4_nothing: - SWPS_DEBUG("FSM action: %s do nothing.\n", self->swp_name); - return 0; - -comfsm_action_4_connected: - SWPS_DEBUG("FSM action: %s Connected.\n", self->swp_name); - self->state = STATE_TRANSVR_CONNECTED; - self->type = new_type; - self->send_uevent(self, KOBJ_ADD); - _transvr_clean_retry(self); - return 0; - -comfsm_action_4_disconnected: - SWPS_DEBUG("FSM action: %s Disconnected. \n", self->swp_name); - self->state = STATE_TRANSVR_DISCONNECTED; - self->temp = EVENT_TRANSVR_TASK_DONE; - self->send_uevent(self, KOBJ_REMOVE); - _transvr_clean_retry(self); - _transvr_clean_handler(self); - return ERR_TRANSVR_UNPLUGGED; - -comfsm_action_4_report_i2c_crash: - SWPS_DEBUG("FSM action: %s report I2C crash.\n", self->swp_name); - self->state = STATE_TRANSVR_UNEXCEPTED; - return ERR_TRANSVR_I2C_CRASH; - -comfsm_action_4_isolate_obj: - SWPS_DEBUG("FSM action: %s isolate.\n", self->swp_name); - self->state = STATE_TRANSVR_ISOLATED; - return ERR_TRNASVR_BE_ISOLATED; - -comfsm_action_4_unexpected: - SWPS_INFO("FSM action: %s unexpected.\n", self->swp_name); - SWPS_INFO("Dump: :%d :0x%02x :%d :0x%02x\n", - old_state, old_type, new_state, new_type); - self->state = STATE_TRANSVR_UNEXCEPTED; - self->send_uevent(self, KOBJ_REMOVE); - _transvr_clean_handler(self); - return ERR_TRANSVR_UNEXCPT; -} - - -int -fake_fsm_4_direct_mode(struct transvr_obj_s* self, - char *caller_name){ - self->state = STATE_TRANSVR_CONNECTED; - self->type = TRANSVR_TYPE_FAKE; - return 0; -} - - -int -fake_fsm_4_polling_mode(struct transvr_obj_s* self, - char *caller_name){ - self->state = STATE_TRANSVR_CONNECTED; - self->type = TRANSVR_TYPE_FAKE; - return 0; -} - - -/* ========== Object functions for Initial procedure ========== - */ -int -transvr_init_common(struct transvr_obj_s *self){ - /* Nothing to update */ - return EVENT_TRANSVR_TASK_DONE; -} - - -int -transvr_init_fake(struct transvr_obj_s *self){ - return EVENT_TRANSVR_TASK_DONE; -} - - -int -transvr_init_sfp(struct transvr_obj_s *self){ - - int tmp_val = DEBUG_TRANSVR_INT_VAL; - int err_code = DEBUG_TRANSVR_INT_VAL; - char *err_msg = "ERR"; - - self->info = sft_detect_transvr_class(self); - /* Disable auto_config */ - if (!self->auto_config) { - return EVENT_TRANSVR_TASK_DONE; - } - /* Handle multi-rate */ - err_code = initfunc_sfp_handle_multi_rate_mode(self); - if (err_code < 0) { - err_msg = "initfunc_sfp_handle_multi_rate_mode fail!"; - goto err_transvr_init_sfp_1; - } - /* Handle 1G- RJ45 */ - tmp_val = err_code; - err_code = initfunc_sfp_handle_1g_rj45(self); - if (err_code < 0) { - err_msg = "initfunc_sfp_handle_1g_rj45 fail!"; - goto err_transvr_init_sfp_1; - } - tmp_val = (tmp_val > err_code ? tmp_val : err_code); - if (tmp_val > EVENT_TRANSVR_TASK_DONE) { - return tmp_val; - } - return EVENT_TRANSVR_TASK_DONE; - -err_transvr_init_sfp_1: - SWPS_INFO("%s: %s :%d :%s\n", - __func__, err_msg, err_code, self->swp_name); - return EVENT_TRANSVR_INIT_FAIL; -} - - -int -transvr_init_qsfp(struct transvr_obj_s *self){ - - int err = EVENT_TRANSVR_EXCEP_EXCEP; - char *emsg = "ERR"; - - self->info = qsft_detect_transvr_class(self); - if (!self->auto_config) { - return EVENT_TRANSVR_TASK_DONE; - } - err = initfunc_qsfp_handle_power_mode(self); - if (err < 0){ - emsg = "initfunc_qsfp_handle_tx_disable fail!"; - goto err_transvr_init_qsfp; - } - return EVENT_TRANSVR_TASK_DONE; - -err_transvr_init_qsfp: - SWPS_INFO("%s: %s :%d :%s\n", - __func__, emsg, err, self->swp_name); - return EVENT_TRANSVR_INIT_FAIL; -} - - -int -transvr_init_qsfp28(struct transvr_obj_s *self){ - - int tmp_val = EVENT_TRANSVR_EXCEP_EXCEP; - int err_val = EVENT_TRANSVR_EXCEP_EXCEP; - char *err_msg = "ERR"; - - /* Handle QSFP common */ - err_val = transvr_init_qsfp(self); - if (err_val < 0){ - err_msg = "transvr_init_qsfp fail!"; - goto err_transvr_init_qsfp28_1; - } - /* Disable auto_config */ - if (!self->auto_config) { - return err_val; - } - /* Handle CDR */ - tmp_val = err_val; - err_val = initfunc_qsfp28_handle_cdr(self); - if (err_val < 0){ - err_msg = "Handle CDR fail!"; - goto err_transvr_init_qsfp28_1; - } - tmp_val = (tmp_val > err_val ? tmp_val : err_val); - if (tmp_val > EVENT_TRANSVR_TASK_DONE) { - return tmp_val; - } - return EVENT_TRANSVR_TASK_DONE; - -err_transvr_init_qsfp28_1: - SWPS_INFO("%s: %s :%d :%s\n", - __func__, err_msg, err_val, self->swp_name); - return EVENT_TRANSVR_INIT_FAIL; -} - - -/* ========== Object Initial handler ========== - */ -static int -_is_transvr_valid(struct transvr_obj_s *self, - int type, - int state) { - /* [Return] - * 0 : OK, inserted - * EVENT_TRANSVR_INIT_DOWN : OK, removed - * EVENT_TRANSVR_INIT_FAIL : Outside error, type doesn't supported - * EVENT_TRANSVR_EXCEP_INIT : Internal error, state undefined - */ - switch (type) { - case TRANSVR_TYPE_SFP: - case TRANSVR_TYPE_QSFP: - case TRANSVR_TYPE_QSFP_PLUS: - case TRANSVR_TYPE_QSFP_28: - case TRANSVR_TYPE_UNPLUGGED: - case TRANSVR_TYPE_FAKE: - break; - default: - SWPS_INFO("detect undefined type:0x%02x on %s\n", - type, self->swp_name); - return EVENT_TRANSVR_INIT_FAIL; - } - switch (state) { - case STATE_TRANSVR_DISCONNECTED: - return EVENT_TRANSVR_INIT_DOWN; - case STATE_TRANSVR_INIT: - case STATE_TRANSVR_CONNECTED: - case STATE_TRANSVR_SWAPPED: - break; - default: - SWPS_INFO("detect undefined state:%d on %s\n", - state, self->swp_name); - return EVENT_TRANSVR_EXCEP_INIT; - } - return 0; -} - - -static int -_is_transvr_hw_ready(struct transvr_obj_s *self, - int type){ - /* [Return] - * EVENT_TRANSVR_TASK_DONE : Ready - * EVENT_TRANSVR_TASK_WAIT : Not ready - * EVENT_TRANSVR_INIT_FAIL : Error - */ - int addr = DEBUG_TRANSVR_INT_VAL; - int page = DEBUG_TRANSVR_INT_VAL; - int offs = DEBUG_TRANSVR_INT_VAL; - int bit = DEBUG_TRANSVR_INT_VAL; - int ready = DEBUG_TRANSVR_INT_VAL; - int err = DEBUG_TRANSVR_INT_VAL; - char *emsg = DEBUG_TRANSVR_STR_VAL; - uint8_t ab_val = DEBUG_TRANSVR_HEX_VAL; - - switch (type) { - case TRANSVR_TYPE_SFP: - addr = VAL_TRANSVR_8472_READY_ADDR; - page = VAL_TRANSVR_8472_READY_PAGE; - offs = VAL_TRANSVR_8472_READY_OFFSET; - bit = VAL_TRANSVR_8472_READY_BIT; - ready = VAL_TRANSVR_8472_READY_VALUE; - ab_val = VAL_TRANSVR_8472_READY_ABNORMAL; - break; - - case TRANSVR_TYPE_QSFP: - case TRANSVR_TYPE_QSFP_PLUS: - case TRANSVR_TYPE_QSFP_28: - addr = VAL_TRANSVR_8436_READY_ADDR; - page = VAL_TRANSVR_8436_READY_PAGE; - offs = VAL_TRANSVR_8436_READY_OFFSET; - bit = VAL_TRANSVR_8436_READY_BIT; - ready = VAL_TRANSVR_8436_READY_VALUE; - ab_val = VAL_TRANSVR_8436_READY_ABNORMAL; - break; - - case TRANSVR_TYPE_UNPLUGGED: - case TRANSVR_TYPE_FAKE: - return EVENT_TRANSVR_TASK_DONE; - - default: - emsg = "unexpected case"; - goto err_is_transvr_hw_ready; - } - /* Select target page */ - err = _common_setup_page(self, addr, page, offs, 1, 0); - if (err < 0) { - emsg = "setup page fail"; - goto err_is_transvr_hw_ready; - } - /* Check feature supported - * [Note] - * Some of transceiver/cables doesn't support "Status Indicators" - * (ex:DAC, RJ45 copper SFP ...etc). In these case, we bypass the - * step of checking Status Indicators, then state machine will take - * the following handle procedure. - */ - err = i2c_smbus_read_byte_data(self->i2c_client_p, - VAL_TRANSVR_COMID_OFFSET); - if (err < 0) { - emsg = "doesn't support Status Indicators"; - goto bypass_is_transvr_hw_ready; - } - /* Filter abnormal case */ - if (err == ab_val) { - emsg = "detect using unusual definition."; - goto bypass_is_transvr_hw_ready; - } - /* Get Status Indicators */ - err = i2c_smbus_read_byte_data(self->i2c_client_p, offs); - if (err < 0) { - emsg = "detect current value fail"; - goto err_is_transvr_hw_ready; - } - if ((err & (1<:%d\n", __func__, emsg, type); - return EVENT_TRANSVR_TASK_DONE; - -err_is_transvr_hw_ready: - SWPS_DEBUG("%s: %s :%d\n", __func__, emsg, type); - return EVENT_TRANSVR_INIT_FAIL; -} - - -static int -_is_transvr_support_ctle(struct transvr_obj_s *self) { - - switch (self->info) { - case TRANSVR_CLASS_OPTICAL_25G: - case TRANSVR_CLASS_OPTICAL_25G_AOC: - case TRANSVR_CLASS_OPTICAL_25G_SR: - case TRANSVR_CLASS_OPTICAL_25G_LR: - case TRANSVR_CLASS_OPTICAL_25G_ER: - case TRANSVR_CLASS_OPTICAL_100G: - case TRANSVR_CLASS_OPTICAL_100G_AOC: - case TRANSVR_CLASS_OPTICAL_100G_SR4: - case TRANSVR_CLASS_OPTICAL_100G_LR4: - case TRANSVR_CLASS_OPTICAL_100G_ER4: - case TRANSVR_CLASS_OPTICAL_100G_PSM4: - return 1; - default: - break; - } - return 0; -} - - -static int -_transvr_init_handler(struct transvr_obj_s *self){ - - int detect[2]; - int d_state = STATE_TRANSVR_UNEXCEPTED; - int d_type = TRANSVR_TYPE_ERROR; - int result = ERR_TRANSVR_UNINIT; - int retry = 6; /* (6+1) x 0.3 = 2.1s > spec:2.0s */ - int elimit = 63; - char emsg[64] = DEBUG_TRANSVR_STR_VAL; - - /* Clean and check callback */ - self->state = STATE_TRANSVR_INIT; - if (self->init == NULL) { - snprintf(emsg, elimit, "init() is null"); - goto initer_err_case_unexcept_0; - } - if (self->clean == NULL) { - snprintf(emsg, elimit, "clean() is null"); - goto initer_err_case_unexcept_0; - } - self->clean(self); - - /* Detect transceiver information */ - result = detect_transvr_state(self, detect); - if (result < 0) { - snprintf(emsg, elimit, "detect_transvr_state() fail"); - switch (result) { - case ERR_TRANSVR_I2C_CRASH: - goto initer_err_case_i2c_ceash; - case ERR_TRNASVR_BE_ISOLATED: - goto initer_err_case_be_isolated; - - case ERR_TRANSVR_UNEXCPT: - default: - break; - } - goto initer_err_case_retry_1; - } - d_state = detect[0]; - d_type = detect[1]; - - /* Verify transceiver type and state */ - switch (_is_transvr_valid(self, d_type, d_state)) { - case 0: - break; - case EVENT_TRANSVR_INIT_DOWN: - goto initer_ok_case_down;; - case EVENT_TRANSVR_INIT_FAIL: - snprintf(emsg, elimit, "transceiver type doesn't support"); - goto initer_err_case_alarm_to_user; - case EVENT_TRANSVR_EXCEP_INIT: - default: - goto initer_err_case_unexcept_1; - } - - /* Handle reload case */ - if (self->type != d_type){ - /* This is the protect mechanism. Normally, This case will not happen. - * When State machine detect swap event during initial, It will trigger - * reload function to ensure type correct. */ - if (_reload_transvr_obj(self, d_type) < 0){ - snprintf(emsg, elimit, "reload object fail"); - goto initer_err_case_unexcept_1; - } - } - - /* Check transceiver HW initial ready */ - switch (_is_transvr_hw_ready(self, d_type)) { - case EVENT_TRANSVR_TASK_DONE: - break; - case EVENT_TRANSVR_TASK_WAIT: - goto initer_err_case_retry_1; - case EVENT_TRANSVR_INIT_FAIL: - default: - goto initer_err_case_unexcept_1; - } - - /* Try to update all and check */ - if (self->update_all(self, 1) < 0){ - /* For some transceiver, EEPROME has lag issues during initial stage. - * In this case, we set status back to STATE_TRANSVR_NEW, than it will - * be checked in next polling cycle. */ - goto initer_err_case_retry_1; - } - - /* Execute init() call back */ - result = self->init(self); - switch (result) { - case EVENT_TRANSVR_TASK_DONE: - break; - case EVENT_TRANSVR_TASK_WAIT: - goto initer_ok_case_wait; - - default: - snprintf(emsg, elimit, "undefined init() return:%d\n", result); - goto initer_err_case_unexcept_1; - } - goto initer_ok_case_up; - - -initer_ok_case_wait: - self->dump_all(self); - return EVENT_TRANSVR_TASK_WAIT; - -initer_ok_case_up: - self->state = STATE_TRANSVR_CONNECTED; - self->temp = 0; - self->dump_all(self); - return EVENT_TRANSVR_INIT_UP; - -initer_ok_case_down: - self->temp = 0; - self->state = STATE_TRANSVR_DISCONNECTED; - return EVENT_TRANSVR_INIT_DOWN; - -initer_err_case_i2c_ceash: - SWPS_DEBUG("%s: %s :%s :I2C crash\n", - __func__, emsg, self->swp_name); - self->state = STATE_TRANSVR_UNEXCEPTED; - return EVENT_TRANSVR_I2C_CRASH; - -initer_err_case_be_isolated: - SWPS_DEBUG("%s: %s :%s :isolated\n", - __func__, emsg, self->swp_name); - self->state = STATE_TRANSVR_ISOLATED; - return EVENT_TRANSVR_EXCEP_ISOLATED; - -initer_err_case_retry_1: - SWPS_DEBUG("%s: %s :%s :retry\n", - __func__, emsg, self->swp_name); - if (_transvr_handle_retry(self, retry) == 0) { - self->state = STATE_TRANSVR_NEW; - return EVENT_TRANSVR_INIT_REINIT; - } - goto initer_err_case_alarm_to_user; - -initer_err_case_unexcept_1: - self->clean(self); -initer_err_case_unexcept_0: - self->state = STATE_TRANSVR_UNEXCEPTED; - if (_is_except_happened_4_pmode(self, d_state) && - (self->mode == TRANSVR_MODE_POLLING) ){ - SWPS_INFO("%s: %s :%s\n", __func__, emsg, self->swp_name); - SWPS_INFO("Dump: :%d :%d :%d :%d\n", - self->state, self->type, d_state, d_type); - } - return EVENT_TRANSVR_INIT_FAIL; - -initer_err_case_alarm_to_user: - SWPS_DEBUG("%s: %s :%s :alarm_to_user\n", - __func__, emsg, self->swp_name); - self->state = STATE_TRANSVR_UNEXCEPTED; - alarm_msg_2_user(self, "detected transceiver/cables not meet SFF standard"); - return EVENT_TRANSVR_INIT_FAIL; -} - - -/* ========== Object functions for Clean procedure ========== - */ -int -_transvr_clean_handler(struct transvr_obj_s *self){ - - int retval = DEBUG_TRANSVR_INT_VAL; - - if (!self->clean) { - SWPS_ERR("%s: %s clean() is NULL.\n", - __func__, self->swp_name); - return EVENT_TRANSVR_TASK_FAIL; - } - retval = self->clean(self); - if (retval != EVENT_TRANSVR_TASK_DONE){ - SWPS_ERR("%s: %s clean() fail. [ERR]:%d\n", - __func__, self->swp_name, retval); - return retval; - } - return EVENT_TRANSVR_TASK_DONE; -} - - -int -common_transvr_clean(struct transvr_obj_s *self){ - - transvr_task_free_all(self); - transvr_cache_free_all(self); - return EVENT_TRANSVR_TASK_DONE; -} - - -int -qsfp_transvr_clean(struct transvr_obj_s *self){ - - int retval; - int lpower_config = 1; - - retval = _taskfunc_qsfp_setup_power_mod(self, lpower_config); - if (retval < 0){ - SWPS_ERR("%s: Set lpmod fail! :%d\n", - __func__, retval); - return retval; - } - retval = common_transvr_clean(self); - if (retval < 0){ - SWPS_ERR("%s: common_transvr_clean fail! :%d\n", - __func__, retval); - return retval; - } - return EVENT_TRANSVR_TASK_DONE; -} - - -int -fake_transvr_clean(struct transvr_obj_s *self){ - - return EVENT_TRANSVR_TASK_DONE; -} - - -/* ========== Object functions for check and update ========== - */ -int -common_transvr_check(struct transvr_obj_s *self){ - - char fun_str[32] = "common_transvr_check"; - - if (self->mode != TRANSVR_MODE_POLLING) { - SWPS_ERR("%s: mode:%d is not TRANSVR_MODE_POLLING\n", - fun_str, self->mode); - return ERR_TRANSVR_UNEXCPT; - } - /* Trigger delay task */ - transvr_task_run_all(self); - /* Trigger state machine to check and update */ - return self->fsm_4_polling(self, fun_str); -} - - -int -fake_transvr_check(struct transvr_obj_s *self){ - return 0; -} - - -/* ========== Functions for Factory pattern ========== - */ -static int -setup_transvr_public_cb(struct transvr_obj_s *self, - int transvr_type){ - switch (transvr_type){ - case TRANSVR_TYPE_SFP: - self->get_id = common_get_id; - self->get_eeprom = common_get_eeprom; - self->get_ext_id = common_get_ext_id; - self->get_connector = common_get_connector; - self->get_vendor_name = common_get_vendor_name; - self->get_vendor_pn = common_get_vendor_pn; - self->get_vendor_rev = common_get_vendor_rev; - self->get_vendor_sn = common_get_vendor_sn; - self->get_power_cls = unsupported_get_func; - self->get_br = common_get_br; - self->get_len_sm = sfp_get_len_sm; - self->get_len_smf = common_get_len_smf; - self->get_len_om1 = common_get_len_om1; - self->get_len_om2 = common_get_len_om2; - self->get_len_om3 = common_get_len_om3; - self->get_len_om4 = common_get_len_om4; - self->get_comp_rev = common_get_comp_rev; - self->get_comp_eth_1 = sfp_get_comp_eth_1; - self->get_comp_eth_10 = sfp_get_comp_eth_10; - self->get_comp_eth_10_40 = unsupported_get_func; - self->get_comp_extend = common_get_comp_extended; - self->get_cdr = unsupported_get_func; - self->get_rate_id = sfp_get_rate_id; - self->get_soft_rs0 = sfp_get_soft_rs0; - self->get_soft_rs1 = sfp_get_soft_rs1; - self->get_info = common_get_info; - self->get_if_type = sfp_get_if_type; - self->get_if_speed = sfp_get_if_speed; - self->get_if_lane = common_get_if_lane; - self->get_curr_temp = sfp_get_transvr_temp; - self->get_curr_vol = sfp_get_transvr_voltage; - self->get_soft_rx_los = unsupported_get_func2; - self->get_soft_tx_disable = unsupported_get_func2; - self->get_soft_tx_fault = unsupported_get_func2; - self->get_auto_tx_disable = unsupported_get_func2; - self->get_tx_bias = sfp_get_transvr_tx_bias; - self->get_tx_power = sfp_get_transvr_tx_power; - self->get_rx_power = sfp_get_transvr_rx_power; - self->get_tx_eq = sfp_get_transvr_tx_eq; - self->get_rx_am = unsupported_get_func2; - self->get_rx_em = sfp_get_transvr_rx_em; - self->get_wavelength = sfp_get_wavelength; - self->get_extphy_offset = sfp_get_1g_rj45_extphy_offset; - self->get_extphy_reg = sfp_get_1g_rj45_extphy_reg; - self->set_cdr = unsupported_set_func; - self->set_soft_rs0 = sfp_set_soft_rs0; - self->set_soft_rs1 = sfp_set_soft_rs1; - self->set_soft_tx_disable = unsupported_set_func; - self->set_auto_tx_disable = unsupported_set_func; - self->set_tx_eq = sfp_set_tx_eq; - self->set_rx_am = unsupported_set_func; - self->set_rx_em = sfp_set_rx_em; - self->set_extphy_offset = sfp_set_1g_rj45_extphy_offset; - self->set_extphy_reg = sfp_set_1g_rj45_extphy_reg; - return 0; - - case TRANSVR_TYPE_QSFP: - case TRANSVR_TYPE_QSFP_PLUS: - self->get_id = common_get_id; - self->get_eeprom = common_get_eeprom; - self->get_ext_id = common_get_ext_id; - self->get_connector = common_get_connector; - self->get_vendor_name = common_get_vendor_name; - self->get_vendor_pn = common_get_vendor_pn; - self->get_vendor_rev = common_get_vendor_rev; - self->get_vendor_sn = common_get_vendor_sn; - self->get_power_cls = qsfp_get_power_cls; - self->get_br = common_get_br; - self->get_len_sm = unsupported_get_func; - self->get_len_smf = common_get_len_smf; - self->get_len_om1 = common_get_len_om1; - self->get_len_om2 = common_get_len_om2; - self->get_len_om3 = common_get_len_om3; - self->get_len_om4 = common_get_len_om4; - self->get_comp_rev = common_get_comp_rev; - self->get_comp_eth_1 = qsfp_get_comp_eth; - self->get_comp_eth_10 = unsupported_get_func; - self->get_comp_eth_10_40 = qsfp_get_comp_10_40; - self->get_comp_extend = common_get_comp_extended; - self->get_cdr = unsupported_get_func; - self->get_rate_id = unsupported_get_func; - self->get_soft_rs0 = unsupported_get_func; /* TBD */ - self->get_soft_rs1 = unsupported_get_func; /* TBD */ - self->get_info = common_get_info; - self->get_if_type = qsfp_get_if_type; - self->get_if_speed = qsfp_get_if_speed; - self->get_if_lane = common_get_if_lane; - self->get_curr_temp = qsfp_get_transvr_temp; - self->get_curr_vol = qsfp_get_transvr_voltage; - self->get_soft_rx_los = qsfp_get_soft_rx_los; - self->get_soft_tx_disable = qsfp_get_soft_tx_disable; - self->get_soft_tx_fault = qsfp_get_soft_tx_fault; - self->get_auto_tx_disable = qsfp_get_auto_tx_disable; - self->get_tx_bias = qsfp_get_transvr_tx_bias; - self->get_tx_power = qsfp_get_transvr_tx_power; - self->get_rx_power = qsfp_get_transvr_rx_power; - self->get_tx_eq = unsupported_get_func2; - self->get_rx_am = unsupported_get_func2; - self->get_rx_em = unsupported_get_func2; - self->get_wavelength = qsfp_get_wavelength; - self->get_extphy_offset = unsupported_get_func2; - self->get_extphy_reg = unsupported_get_func2; - self->set_cdr = unsupported_set_func; - self->set_soft_rs0 = unsupported_set_func; /* TBD */ - self->set_soft_rs1 = unsupported_set_func; /* TBD */ - self->set_soft_tx_disable = qsfp_set_soft_tx_disable; - self->set_auto_tx_disable = qsfp_set_auto_tx_disable; - self->set_tx_eq = unsupported_set_func; - self->set_rx_am = unsupported_set_func; - self->set_rx_em = unsupported_set_func; - self->set_extphy_offset = unsupported_set_func; - self->set_extphy_reg = unsupported_set_func; - return 0; - - case TRANSVR_TYPE_QSFP_28: - self->get_id = common_get_id; - self->get_eeprom = common_get_eeprom; - self->get_ext_id = common_get_ext_id; - self->get_connector = common_get_connector; - self->get_vendor_name = common_get_vendor_name; - self->get_vendor_pn = common_get_vendor_pn; - self->get_vendor_rev = common_get_vendor_rev; - self->get_vendor_sn = common_get_vendor_sn; - self->get_power_cls = qsfp_get_power_cls; - self->get_br = common_get_br; - self->get_len_sm = unsupported_get_func; - self->get_len_smf = common_get_len_smf; - self->get_len_om1 = common_get_len_om1; - self->get_len_om2 = common_get_len_om2; - self->get_len_om3 = common_get_len_om3; - self->get_len_om4 = common_get_len_om4; - self->get_comp_rev = common_get_comp_rev; - self->get_comp_eth_1 = qsfp_get_comp_eth; - self->get_comp_eth_10 = unsupported_get_func; - self->get_comp_eth_10_40 = qsfp_get_comp_10_40; - self->get_comp_extend = common_get_comp_extended; - self->get_cdr = qsfp_get_cdr; - self->get_rate_id = unsupported_get_func; - self->get_soft_rs0 = unsupported_get_func; /* TBD */ - self->get_soft_rs1 = unsupported_get_func; /* TBD */ - self->get_info = common_get_info; - self->get_if_type = qsfp_get_if_type; - self->get_if_speed = qsfp_get_if_speed; - self->get_if_lane = common_get_if_lane; - self->get_curr_temp = qsfp_get_transvr_temp; - self->get_curr_vol = qsfp_get_transvr_voltage; - self->get_soft_rx_los = qsfp_get_soft_rx_los; - self->get_soft_tx_disable = qsfp_get_soft_tx_disable; - self->get_soft_tx_fault = qsfp_get_soft_tx_fault; - self->get_auto_tx_disable = qsfp_get_auto_tx_disable; - self->get_tx_bias = qsfp_get_transvr_tx_bias; - self->get_tx_power = qsfp_get_transvr_tx_power; - self->get_rx_power = qsfp_get_transvr_rx_power; - self->get_tx_eq = qsfp_get_transvr_tx_eq; - self->get_rx_am = qsfp_get_transvr_rx_am; - self->get_rx_em = qsfp_get_transvr_rx_em; - self->get_wavelength = qsfp_get_wavelength; - self->get_extphy_offset = unsupported_get_func2; - self->get_extphy_reg = unsupported_get_func2; - self->set_cdr = qsfp_set_cdr; - self->set_soft_rs0 = unsupported_set_func; /* TBD */ - self->set_soft_rs1 = unsupported_set_func; /* TBD */ - self->set_soft_tx_disable = qsfp_set_soft_tx_disable; - self->set_auto_tx_disable = qsfp_set_auto_tx_disable; - self->set_tx_eq = qsfp_set_tx_eq; - self->set_rx_am = qsfp_set_rx_am; - self->set_rx_em = qsfp_set_rx_em; - self->set_extphy_offset = unsupported_set_func; - self->set_extphy_reg = unsupported_set_func; - return 0; - - case TRANSVR_TYPE_FAKE: - self->get_id = fake_get_hex; - self->get_eeprom = fake_get_str; - self->get_ext_id = fake_get_hex; - self->get_connector = fake_get_hex; - self->get_vendor_name = fake_get_str; - self->get_vendor_pn = fake_get_str; - self->get_vendor_rev = fake_get_str; - self->get_vendor_sn = fake_get_str; - self->get_power_cls = fake_get_int; - self->get_br = fake_get_hex; - self->get_len_sm = fake_get_int; - self->get_len_smf = fake_get_int; - self->get_len_om1 = fake_get_int; - self->get_len_om2 = fake_get_int; - self->get_len_om3 = fake_get_int; - self->get_len_om4 = fake_get_int; - self->get_comp_rev = fake_get_hex; - self->get_comp_eth_1 = fake_get_hex; - self->get_comp_eth_10 = fake_get_hex; - self->get_comp_eth_10_40 = fake_get_hex; - self->get_comp_extend = fake_get_hex; - self->get_cdr = fake_get_hex; - self->get_rate_id = fake_get_hex; - self->get_soft_rs0 = fake_get_binary; - self->get_soft_rs1 = fake_get_binary; - self->get_info = fake_get_int; - self->get_if_type = fake_get_str; - self->get_if_speed = fake_get_str; - self->get_if_lane = fake_get_str; - self->get_curr_temp = fake_get_str; - self->get_curr_vol = fake_get_str; - self->get_soft_rx_los = fake_get_str; - self->get_soft_tx_disable = fake_get_str; - self->get_soft_tx_fault = fake_get_str; - self->get_auto_tx_disable = fake_get_str; - self->get_tx_bias = fake_get_str; - self->get_tx_power = fake_get_str; - self->get_rx_power = fake_get_str; - self->get_tx_eq = fake_get_str; - self->get_rx_am = fake_get_str; - self->get_rx_em = fake_get_str; - self->get_wavelength = fake_get_str; - self->get_extphy_offset = fake_get_str; - self->get_extphy_reg = fake_get_str; - self->set_cdr = fake_set_hex; - self->set_soft_rs0 = fake_set_int; - self->set_soft_rs1 = fake_set_int; - self->set_soft_tx_disable = fake_set_int; - self->set_auto_tx_disable = fake_set_int; - self->set_tx_eq = fake_set_int; - self->set_rx_am = fake_set_int; - self->set_rx_em = fake_set_int; - self->set_extphy_offset = fake_set_hex; - self->set_extphy_reg = fake_set_hex; - return 0; - - default: - break; - } - SWPS_WARN("%s: Detect non-defined type:%d\n", __func__, transvr_type); - return ERR_TRANSVR_UNEXCPT; -} - - -static int -setup_transvr_private_cb(struct transvr_obj_s *self, - int transvr_type){ - switch (transvr_type){ - case TRANSVR_TYPE_SFP: - self->init = transvr_init_sfp; - self->clean = common_transvr_clean; - self->check = common_transvr_check; - self->update_all = _sfp_update_attr_all; - self->fsm_4_direct = common_fsm_4_direct_mode; - self->fsm_4_polling = common_fsm_4_polling_mode; - self->send_uevent = sfp_send_uevent; - self->dump_all = sfp_transvr_dump; - return 0; - - case TRANSVR_TYPE_QSFP: - case TRANSVR_TYPE_QSFP_PLUS: - self->init = transvr_init_qsfp; - self->clean = qsfp_transvr_clean; - self->check = common_transvr_check; - self->update_all = _qsfp_update_attr_all; - self->fsm_4_direct = common_fsm_4_direct_mode; - self->fsm_4_polling = common_fsm_4_polling_mode; - self->send_uevent = qsfp_send_uevent; - self->dump_all = qsfp_transvr_dump; - return 0; - - case TRANSVR_TYPE_QSFP_28: - self->init = transvr_init_qsfp28; - self->clean = qsfp_transvr_clean; - self->check = common_transvr_check; - self->update_all = _qsfp_update_attr_all; - self->fsm_4_direct = common_fsm_4_direct_mode; - self->fsm_4_polling = common_fsm_4_polling_mode; - self->send_uevent = qsfp_send_uevent; - self->dump_all = qsfp_transvr_dump; - return 0; - - case TRANSVR_TYPE_FAKE: - self->init = transvr_init_fake; - self->clean = fake_transvr_clean; - self->check = fake_transvr_check; - self->update_all = fake_transvr_update; - self->fsm_4_direct = fake_fsm_4_direct_mode; - self->fsm_4_polling = fake_fsm_4_polling_mode; - self->send_uevent = fake_send_uevent; - self->dump_all = fake_transvr_dump; - return 0; - - default: - break; - } - SWPS_WARN("%s: Detect non-defined type:%d\n", __func__, transvr_type); - return ERR_TRANSVR_UNEXCPT; -} - - -static struct eeprom_map_s * -get_eeprom_map(int transvr_type){ - - switch (transvr_type){ - case TRANSVR_TYPE_SFP: - return &eeprom_map_sfp; - case TRANSVR_TYPE_QSFP: - case TRANSVR_TYPE_QSFP_PLUS: - return &eeprom_map_qsfp; - case TRANSVR_TYPE_QSFP_28: - return &eeprom_map_qsfp28; - - default: - break; - } - SWPS_WARN("%s: Detect non-defined type:%d\n", __func__, transvr_type); - return NULL; -} - - -static int -setup_transvr_ssize_attr(char *swp_name, - struct transvr_obj_s *self, - struct eeprom_map_s *map_p, - struct ioexp_obj_s *ioexp_obj_p, - int ioexp_virt_offset, - int transvr_type, - int chipset_type, - int chan_id, - int run_mode){ - switch (run_mode){ - case TRANSVR_MODE_DIRECT: /* Direct access device mode */ - case TRANSVR_MODE_POLLING: /* Polling mode, read from cache */ - self->mode = run_mode; - break; - default: - SWPS_ERR("%s: non-defined run_mode:%d\n", - __func__, run_mode); - self->mode = DEBUG_TRANSVR_INT_VAL; - return -1; - } - self->eeprom_map_p = map_p; - self->ioexp_obj_p = ioexp_obj_p; - self->ioexp_virt_offset = ioexp_virt_offset; - self->chan_id = chan_id; - self->layout = transvr_type; - self->type = transvr_type; - self->chipset_type = chipset_type; - self->state = STATE_TRANSVR_NEW; - self->info = STATE_TRANSVR_NEW; - self->auto_tx_disable = VAL_TRANSVR_FUNCTION_DISABLE; - strncpy(self->swp_name, swp_name, 32); - mutex_init(&self->lock); - return 0; -} - - -static int -setup_transvr_dsize_attr(struct transvr_obj_s *self){ - - char *emsg = DEBUG_TRANSVR_STR_VAL; - - self->vendor_name = kzalloc((LEN_TRANSVR_M_STR * sizeof(char)), GFP_KERNEL); - if (!self->vendor_name){ - emsg = "vendor_name"; - goto err_setup_d_attr; - } - self->vendor_pn = kzalloc((LEN_TRANSVR_M_STR * sizeof(char)), GFP_KERNEL); - if (!self->vendor_pn){ - emsg = "vendor_pn"; - goto err_setup_d_attr; - } - self->vendor_rev = kzalloc((LEN_TRANSVR_M_STR * sizeof(char)), GFP_KERNEL); - if (!self->vendor_rev){ - emsg = "vendor_rev"; - goto err_setup_d_attr; - } - self->vendor_sn = kzalloc((LEN_TRANSVR_M_STR * sizeof(char)), GFP_KERNEL); - if (!self->vendor_sn){ - emsg = "vendor_sn"; - goto err_setup_d_attr; - } - self->worker_p = NULL; - return 0; - -err_setup_d_attr: - SWPS_ERR("%s: %s kzalloc fail!", __func__, emsg); - return ERR_TRANSVR_UNEXCPT; -} - - -static int -setup_i2c_client(struct transvr_obj_s *self){ - - struct i2c_adapter *adap = NULL; - struct i2c_client *client = NULL; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - - adap = i2c_get_adapter(self->chan_id); - if(!adap){ - snprintf(err_msg, sizeof(err_msg), - "can not get adap:%d", self->chan_id); - goto err_setup_i2c_client; - } - client = kzalloc(sizeof(*client), GFP_KERNEL); - if (!client){ - snprintf(err_msg, sizeof(err_msg), - "can not kzalloc client:%d", self->chan_id); - goto err_setup_i2c_client; - } - client->adapter = adap; - self->i2c_client_p = client; - self->i2c_client_p->addr = VAL_TRANSVR_COMID_ARREESS; - return 0; - -err_setup_i2c_client: - SWPS_ERR("%s: %s\n", __func__, err_msg); - return ERR_TRANSVR_UNEXCPT; -} - - -struct transvr_obj_s * -create_transvr_obj(char *swp_name, - int chan_id, - struct ioexp_obj_s *ioexp_obj_p, - int ioexp_virt_offset, - int transvr_type, - int chipset_type, - int run_mode){ - - struct transvr_obj_s *result_p; - struct eeprom_map_s *map_p; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - - /* Allocate transceiver object */ - map_p = get_eeprom_map(transvr_type); - if (!map_p){ - snprintf(err_msg, sizeof(err_msg), - "Invalid transvr_type:%d", transvr_type); - goto err_create_transvr_fail; - } - result_p = kzalloc(sizeof(*result_p), GFP_KERNEL); - if (!result_p){ - snprintf(err_msg, sizeof(err_msg), "kzalloc fail"); - goto err_create_transvr_fail; - } - /* Prepare static size attributes */ - if (setup_transvr_ssize_attr(swp_name, - result_p, - map_p, - ioexp_obj_p, - ioexp_virt_offset, - transvr_type, - chipset_type, - chan_id, - run_mode) < 0){ - goto err_create_transvr_sattr_fail; - } - /* Prepare dynamic size attributes */ - if (setup_transvr_dsize_attr(result_p) < 0){ - goto err_create_transvr_dattr_fail; - } - /* Prepare call back functions of object */ - if (setup_transvr_public_cb(result_p, transvr_type) < 0){ - goto err_create_transvr_dattr_fail; - } - /* Prepare call back functions of object */ - if (setup_transvr_private_cb(result_p, transvr_type) < 0){ - goto err_create_transvr_dattr_fail; - } - /* Prepare i2c client object */ - if (setup_i2c_client(result_p) < 0){ - goto err_create_transvr_dattr_fail; - } - return result_p; - -err_create_transvr_dattr_fail: - kfree(result_p->vendor_sn); - kfree(result_p->vendor_rev); - kfree(result_p->vendor_pn); - kfree(result_p->vendor_name); -err_create_transvr_sattr_fail: - kfree(result_p); -err_create_transvr_fail: - SWPS_ERR("%s: %s :%d :%d :%d\n", - __func__, err_msg, chan_id, ioexp_virt_offset, transvr_type); - return NULL; -} -EXPORT_SYMBOL(create_transvr_obj); - - -static int -_reload_transvr_obj(struct transvr_obj_s *self, - int new_type){ - - struct eeprom_map_s *new_map_p; - struct eeprom_map_s *old_map_p = self->eeprom_map_p; - struct i2c_client *old_i2c_p = self->i2c_client_p; - int old_type = self->type; - - /* Change state to STATE_TRANSVR_INIT */ - self->state = STATE_TRANSVR_INIT; - self->type = new_type; - /* Replace EEPROME map */ - new_map_p = get_eeprom_map(new_type); - if (!new_map_p){ - goto err_private_reload_func_1; - } - self->eeprom_map_p = new_map_p; - /* Reload i2c client */ - if (setup_i2c_client(self) < 0){ - goto err_private_reload_func_2; - } - /* Replace call back functions */ - if (setup_transvr_public_cb(self, new_type) < 0){ - goto err_private_reload_func_3; - } - if (setup_transvr_private_cb(self, new_type) < 0){ - goto err_private_reload_func_3; - } - kfree(old_i2c_p); - return 0; - -err_private_reload_func_3: - SWPS_INFO("%s: init() fail!\n", __func__); - kfree(old_i2c_p); - self->state = STATE_TRANSVR_UNEXCEPTED; - self->type = TRANSVR_TYPE_ERROR; - return -2; - -err_private_reload_func_2: - self->eeprom_map_p = old_map_p; - self->i2c_client_p = old_i2c_p; -err_private_reload_func_1: - self->state = STATE_TRANSVR_UNEXCEPTED; - self->type = old_type; - SWPS_INFO("%s fail! :0x%02x\n", __func__, new_type); - return -1; -} - - -static int -reload_transvr_obj(struct transvr_obj_s *self, - int new_type){ - - int result_val = ERR_TRANSVR_UNEXCPT; - - /* Reload phase */ - result_val = _reload_transvr_obj(self, new_type); - if (result_val < 0){ - SWPS_INFO("%s: reload phase fail! :%d\n", - __func__, result_val); - return EVENT_TRANSVR_RELOAD_FAIL; - } - /* Initial phase */ - result_val = _transvr_init_handler(self); - if (result_val < 0){ - SWPS_INFO("%s: initial phase fail! :%d\n", - __func__, result_val); - } - return result_val; -} - - -int -isolate_transvr_obj(struct transvr_obj_s *self) { - - self->state = STATE_TRANSVR_ISOLATED; - SWPS_INFO("%s: %s be isolated\n", __func__, self->swp_name); - return 0; -} -EXPORT_SYMBOL(isolate_transvr_obj); - - -int -resync_channel_tier_2(struct transvr_obj_s *self) { - - int val = TRANSVR_TYPE_ERROR; - - if (self->state == STATE_TRANSVR_ISOLATED) { - return 0; - } - self->i2c_client_p->addr = VAL_TRANSVR_COMID_ARREESS; - val = i2c_smbus_read_byte_data(self->i2c_client_p, - VAL_TRANSVR_COMID_OFFSET); - if (val < 0) { - return -1; - } - return 0; -} -EXPORT_SYMBOL(resync_channel_tier_2); - -/* For build single module using (Ex: ONL platform) */ -//MODULE_LICENSE("GPL"); - - -/* ----------------------------------------- - * ToDo List - * ----------------------------------------- - * 1. _sfp_detect_class_by_feature() - * => Need check ACC use case. - * 2. _sfp_detect_class_by_1g_ethernet() - * => Need check 0.1G use case. - * 3. Loopback transceiver use case. - * => Less much data - * 4. _qsfp_detect_class_by_extend_comp() - * => Verify 100G CWDM4 - * => Verify Obsolete (assigned before 100G CWDM4 MSA required FEC) - * => Verify 100G CLR4 - * => Verify 100GE-DWDM2 - * => Verify 40G PSM4 Parallel SMF - * => Verify 100G ACC (Active Copper Cable) or 25GAUI C2M ACC. - * => Verify 100G ACC or 25GAUI C2M ACC. - * => Verify 25GBASE-LR - * => Verify 40G Active Cable (XLPPI) - */ - - - - - - - - diff --git a/packages/platforms/inventec/x86-64/d6356/modules/builds/src/transceiver.h b/packages/platforms/inventec/x86-64/d6356/modules/builds/src/transceiver.h deleted file mode 100644 index 5d2b5cf71..000000000 --- a/packages/platforms/inventec/x86-64/d6356/modules/builds/src/transceiver.h +++ /dev/null @@ -1,810 +0,0 @@ -#ifndef TRANSCEIVER_H -#define TRANSCEIVER_H - -#include - -/* advanced features control */ -#define TRANSVR_INFO_DUMP_ENABLE (1) -#define TRANSVR_INFO_CACHE_ENABLE (1) -#define TRANSVR_UEVENT_ENABLE (1) - -/* Transceiver type define */ -#define TRANSVR_TYPE_UNKNOW_1 (0x00) -#define TRANSVR_TYPE_UNKNOW_2 (0xff) -#define TRANSVR_TYPE_SFP (0x03) /* Define for SFP, SFP+, SFP28 */ -#define TRANSVR_TYPE_QSFP (0x0c) -#define TRANSVR_TYPE_QSFP_PLUS (0x0d) -#define TRANSVR_TYPE_QSFP_28 (0x11) -#define TRANSVR_TYPE_UNPLUGGED (0xfa) /* Define for ERROR handle */ -#define TRANSVR_TYPE_FAKE (0xfc) /* Define for ERROR handle */ -#define TRANSVR_TYPE_INCONSISTENT (0xfd) /* Define for ERROR handle */ -#define TRANSVR_TYPE_ERROR (0xfe) /* Define for ERROR handle */ - -/* Transceiver class for base info */ -#define TRANSVR_CLASS_UNSPECIFIED (0) -#define TRANSVR_CLASS_ERROR (-26001) -#define TRANSVR_CLASS_1G (26001) -#define TRANSVR_CLASS_10G (26011) -#define TRANSVR_CLASS_25G (26021) -#define TRANSVR_CLASS_40G (26041) -#define TRANSVR_CLASS_100G (26101) -#define TRANSVR_CLASS_NO_SPERARABLE (26901) -#define TRANSVR_CLASS_EXTEND_COMP (26902) -/* Transceiver class for Optical 1G */ -#define TRANSVR_CLASS_OPTICAL (27000) -#define TRANSVR_CLASS_OPTICAL_100 (27001) -#define TRANSVR_CLASS_OPTICAL_1G (27002) -#define TRANSVR_CLASS_OPTICAL_1G_AOC (27003) -#define TRANSVR_CLASS_OPTICAL_1G_SX (27004) -#define TRANSVR_CLASS_OPTICAL_1G_LX (27005) -#define TRANSVR_CLASS_OPTICAL_1G_EX (27006) -/* Transceiver class for Optical 10G */ -#define TRANSVR_CLASS_OPTICAL_10G (27010) -#define TRANSVR_CLASS_OPTICAL_10G_S_AOC (27011) -#define TRANSVR_CLASS_OPTICAL_10G_S_SR (27012) -#define TRANSVR_CLASS_OPTICAL_10G_S_LR (27013) -#define TRANSVR_CLASS_OPTICAL_10G_S_ER (27014) -#define TRANSVR_CLASS_OPTICAL_10G_Q_AOC (27015) -#define TRANSVR_CLASS_OPTICAL_10G_Q_SR (27016) -#define TRANSVR_CLASS_OPTICAL_10G_Q_LR (27017) -#define TRANSVR_CLASS_OPTICAL_10G_Q_ER (27018) -/* Transceiver class for Optical 25G */ -#define TRANSVR_CLASS_OPTICAL_25G (27020) -#define TRANSVR_CLASS_OPTICAL_25G_AOC (27021) -#define TRANSVR_CLASS_OPTICAL_25G_SR (27022) -#define TRANSVR_CLASS_OPTICAL_25G_LR (27023) -#define TRANSVR_CLASS_OPTICAL_25G_ER (27024) -/* Transceiver class for Optical 40G */ -#define TRANSVR_CLASS_OPTICAL_40G (27040) -#define TRANSVR_CLASS_OPTICAL_40G_AOC (27041) -#define TRANSVR_CLASS_OPTICAL_40G_SR4 (27042) -#define TRANSVR_CLASS_OPTICAL_40G_LR4 (27043) -#define TRANSVR_CLASS_OPTICAL_40G_ER4 (27044) -/* Transceiver class for Optical 100G */ -#define TRANSVR_CLASS_OPTICAL_100G (27100) -#define TRANSVR_CLASS_OPTICAL_100G_AOC (27101) -#define TRANSVR_CLASS_OPTICAL_100G_SR4 (27102) -#define TRANSVR_CLASS_OPTICAL_100G_LR4 (27103) -#define TRANSVR_CLASS_OPTICAL_100G_ER4 (27104) -#define TRANSVR_CLASS_OPTICAL_100G_PSM4 (27105) -/* Transceiver class for Copper */ -#define TRANSVR_CLASS_COPPER (28000) -#define TRANSVR_CLASS_COPPER_L1_1G (28001) -#define TRANSVR_CLASS_COPPER_L1_10G (28011) -#define TRANSVR_CLASS_COPPER_L4_10G (28012) -#define TRANSVR_CLASS_COPPER_L1_25G (28021) -#define TRANSVR_CLASS_COPPER_L4_40G (28041) -#define TRANSVR_CLASS_COPPER_L4_100G (28101) -/* Transceiver class for Base-T */ -#define TRANSVR_CLASS_BASE_T_1000 (29001) -#define TRANSVR_CLASS_BASE_T_1000_up (29002) -/* For uevent message */ -#define TRANSVR_UEVENT_KEY_IF "IF_TYPE" -#define TRANSVR_UEVENT_KEY_SP "IF_SPEED" -#define TRANSVR_UEVENT_KEY_LANE "IF_LANE" -#define TRANSVR_UEVENT_UNKNOW "UNKNOW" -#define TRANSVR_IF_KR "KR" -#define TRANSVR_IF_KR4 "KR4" -#define TRANSVR_IF_SR "SR" -#define TRANSVR_IF_SR4 "SR4" -#define TRANSVR_IF_SFI "SFI" -#define TRANSVR_IF_IF_GMII "GMII" -#define TRANSVR_IF_IF_XGMII "XGMII" -#define TRANSVR_IF_SP_100 "100" -#define TRANSVR_IF_SP_1G "1000" -#define TRANSVR_IF_SP_10G "10000" -#define TRANSVR_IF_SP_25G "25000" -#define TRANSVR_IF_SP_40G "40000" -#define TRANSVR_IF_SP_100G "100000" - -/* Transceiver mode define */ -#define TRANSVR_MODE_DIRECT (21000) -#define TRANSVR_MODE_POLLING (21001) - -/* Transceiver state define - * [Note] - * 1. State is used to represent the state of "Transceiver" and "Object". - * 2. State for different target has different means. The description as following: - */ -#define STATE_TRANSVR_CONNECTED (0) /* [Transvr]:Be plugged in. [Obj]:Link up, and work normally. */ -#define STATE_TRANSVR_NEW (-100) /* [Transvr]:(Not used) [Obj]:Create */ -#define STATE_TRANSVR_INIT (-101) /* [Transvr]:Be plugged in. [Obj]:Link up, and in initial process. */ -#define STATE_TRANSVR_ISOLATED (-102) /* [Transvr]:Be plugged in. [Obj]:Isolate, and not provide service. */ -#define STATE_TRANSVR_SWAPPED (-200) /* [Transvr]:Be plugged in. [Obj]:(Not used) */ -#define STATE_TRANSVR_DISCONNECTED (-300) /* [Transvr]:Un-plugged. [Obj]:Link down, and not provide service. */ -#define STATE_TRANSVR_UNEXCEPTED (-901) /* [Transvr]:Any [Obj]:Any, and not in expect case. */ - -/* Task state define */ -#define STATE_T_TASK_WAIT (110) -#define STATE_T_TASK_DONE (0) -#define STATE_T_TASK_INIT (-110) -#define STATE_T_TASK_FAIL (-410) - - -/* Event for task handling */ -#define EVENT_TRANSVR_TASK_WAIT (2101) -#define EVENT_TRANSVR_TASK_DONE (0) -#define EVENT_TRANSVR_TASK_FAIL (-2101) -/* Event for initial handling */ -#define EVENT_TRANSVR_INIT_UP (2201) -#define EVENT_TRANSVR_INIT_DOWN (1) -#define EVENT_TRANSVR_INIT_REINIT (-2201) -#define EVENT_TRANSVR_INIT_FAIL (-2202) -/* Event for others */ -#define EVENT_TRANSVR_RELOAD_FAIL (-2301) -#define EVENT_TRANSVR_EXCEP_INIT (-2401) -#define EVENT_TRANSVR_EXCEP_UP (-2402) -#define EVENT_TRANSVR_EXCEP_DOWN (-2403) -#define EVENT_TRANSVR_EXCEP_SWAP (-2404) -#define EVENT_TRANSVR_EXCEP_EXCEP (-2405) -#define EVENT_TRANSVR_EXCEP_ISOLATED (-2406) -#define EVENT_TRANSVR_I2C_CRASH (-2501) - -/* Transceiver error code define */ -#define ERR_TRANSVR_UNINIT (-201) -#define ERR_TRANSVR_UNPLUGGED (-202) -#define ERR_TRANSVR_ABNORMAL (-203) -#define ERR_TRANSVR_NOSTATE (-204) -#define ERR_TRANSVR_NOTSUPPORT (-205) -#define ERR_TRANSVR_BADINPUT (-206) -#define ERR_TRANSVR_UPDATE_FAIL (-207) -#define ERR_TRANSVR_RELOAD_FAIL (-208) -#define ERR_TRANSVR_INIT_FAIL (-209) -#define ERR_TRANSVR_UNDEFINED (-210) -#define ERR_TRANSVR_TASK_FAIL (-211) -#define ERR_TRANSVR_TASK_BUSY (-212) -#define ERR_TRANSVR_UEVENT_FAIL (-213) -#define ERR_TRANSVR_FUNC_DISABLE (-214) -#define ERR_TRANSVR_I2C_CRASH (-297) -#define ERR_TRNASVR_BE_ISOLATED (-298) -#define ERR_TRANSVR_UNEXCPT (-299) - -/* For debug */ -#define DEBUG_TRANSVR_INT_VAL (-99) -#define DEBUG_TRANSVR_HEX_VAL (0xfe) -#define DEBUG_TRANSVR_STR_VAL "ERROR" - -/* For system internal */ -#define VAL_TRANSVR_COMID_ARREESS (0x50) -#define VAL_TRANSVR_COMID_OFFSET (0x00) -#define VAL_TRANSVR_EXTPHY_ADDR_56 (0x56) -#define VAL_TRANSVR_8472_READY_ADDR (0x51) -#define VAL_TRANSVR_8472_READY_PAGE (-1) -#define VAL_TRANSVR_8472_READY_OFFSET (110) -#define VAL_TRANSVR_8472_READY_BIT (0) -#define VAL_TRANSVR_8472_READY_VALUE (0) -#define VAL_TRANSVR_8472_READY_ABNORMAL (0xff) -#define VAL_TRANSVR_8436_READY_ADDR (0x50) -#define VAL_TRANSVR_8436_READY_PAGE (-1) -#define VAL_TRANSVR_8436_READY_OFFSET (2) -#define VAL_TRANSVR_8436_READY_BIT (0) -#define VAL_TRANSVR_8436_READY_VALUE (0) -#define VAL_TRANSVR_8436_READY_ABNORMAL (0xff) -#define VAL_TRANSVR_8436_PWD_ADDR (0x50) -#define VAL_TRANSVR_8436_PWD_PAGE (-1) -#define VAL_TRANSVR_8436_PWD_OFFSET (123) -#define VAL_TRANSVR_PAGE_FREE (-99) -#define VAL_TRANSVR_PAGE_SELECT_OFFSET (127) -#define VAL_TRANSVR_PAGE_SELECT_DELAY (5) -#define VAL_TRANSVR_TASK_RETRY_FOREVER (-999) -#define VAL_TRANSVR_FUNCTION_DISABLE (-1) -#define STR_TRANSVR_SFP "SFP" -#define STR_TRANSVR_QSFP "QSFP" -#define STR_TRANSVR_QSFP_PLUS "QSFP+" -#define STR_TRANSVR_QSFP28 "QSFP28" - -/* For transvr buf len */ -#define LEN_TRANSVR_S_STR (16) -#define LEN_TRANSVR_M_STR (32) -#define LEN_TRANSVR_L_STR (64) - -/* Optical wavelength */ -#define VAL_OPTICAL_WAVELENGTH_SR (850) -#define VAL_OPTICAL_WAVELENGTH_LR (1310) -#define VAL_OPTICAL_WAVELENGTH_ER (1550) - -/* BCM chip type define */ -#define BCM_CHIP_TYPE_TRIDENT_2 (31001) /* Magnolia, Hudson32i, Spruce */ -#define BCM_CHIP_TYPE_TOMAHAWK (31002) /* Redwood, Cypress, Sequoia */ -#define BCM_CHIP_TYPE_TRIDENT_3 (31003) /* Maple */ - -#define BF_CHIP_TYPE_TOFINO (31011) /* Lavender */ - -/* Info from transceiver EEPROM */ -struct eeprom_map_s { - int addr_br; int page_br; int offset_br; int length_br; - int addr_cdr; int page_cdr; int offset_cdr; int length_cdr; - int addr_comp_rev; int page_comp_rev; int offset_comp_rev; int length_comp_rev; - int addr_connector; int page_connector; int offset_connector; int length_connector; - int addr_diag_type; int page_diag_type; int offset_diag_type; int length_diag_type; - int addr_extbr; int page_extbr; int offset_extbr; int length_extbr; - int addr_ext_id; int page_ext_id; int offset_ext_id; int length_ext_id; - int addr_id; int page_id; int offset_id; int length_id; - int addr_len_sm; int page_len_sm; int offset_len_sm; int length_len_sm; - int addr_len_smf; int page_len_smf; int offset_len_smf; int length_len_smf; - int addr_len_om1; int page_len_om1; int offset_len_om1; int length_len_om1; - int addr_len_om2; int page_len_om2; int offset_len_om2; int length_len_om2; - int addr_len_om3; int page_len_om3; int offset_len_om3; int length_len_om3; - int addr_len_om4; int page_len_om4; int offset_len_om4; int length_len_om4; - int addr_option; int page_option; int offset_option; int length_option; - int addr_rate_id; int page_rate_id; int offset_rate_id; int length_rate_id; - int addr_rx_am; int page_rx_am; int offset_rx_am; int length_rx_am; - int addr_rx_em; int page_rx_em; int offset_rx_em; int length_rx_em; - int addr_rx_los; int page_rx_los; int offset_rx_los; int length_rx_los; - int addr_rx_power; int page_rx_power; int offset_rx_power; int length_rx_power; - int addr_soft_rs0; int page_soft_rs0; int offset_soft_rs0; int length_soft_rs0; - int addr_soft_rs1; int page_soft_rs1; int offset_soft_rs1; int length_soft_rs1; - int addr_temp; int page_temp; int offset_temp; int length_temp; - int addr_trancomp; int page_trancomp; int offset_trancomp; int length_trancomp; - int addr_trancomp_ext; int page_trancomp_ext; int offset_trancomp_ext; int length_trancomp_ext; - int addr_tx_bias; int page_tx_bias; int offset_tx_bias; int length_tx_bias; - int addr_tx_disable; int page_tx_disable; int offset_tx_disable; int length_tx_disable; - int addr_tx_eq; int page_tx_eq; int offset_tx_eq; int length_tx_eq; - int addr_tx_fault; int page_tx_fault; int offset_tx_fault; int length_tx_fault; - int addr_tx_power; int page_tx_power; int offset_tx_power; int length_tx_power; - int addr_vendor_name; int page_vendor_name; int offset_vendor_name; int length_vendor_name; - int addr_vendor_pn; int page_vendor_pn; int offset_vendor_pn; int length_vendor_pn; - int addr_vendor_rev; int page_vendor_rev; int offset_vendor_rev; int length_vendor_rev; - int addr_vendor_sn; int page_vendor_sn; int offset_vendor_sn; int length_vendor_sn; - int addr_voltage; int page_voltage; int offset_voltage; int length_voltage; - int addr_wavelength; int page_wavelength; int offset_wavelength; int length_wavelength; - int addr_eeprom; int page_eeprom; int offset_eeprom; int length_eeprom; -}; - - -struct transvr_worker_s; - -/* Class of transceiver object */ -struct transvr_obj_s { - - /* ========== Object private property ========== - * [Prop]: id - * [Desc]: Type of serial transceiver. - * [Note]: SFP:03h / QSFP:0Ch / QSPF+:0Dh /QSFP28:11h - */ - uint8_t id; - - /* [Prop]: connector - * [Desc]: Connector type. - * [Note]: SFP : A0h / 2 - * QSFP: 00h / 130 - */ - uint8_t connector; - - /* [Prop]: transvr_comp - * [Desc]: Transceiver compliance code. - * [Note]: SFP: SFF-8472 - * - Normal : A0h / offset 3-10 - * - Extended: A0h / offset 36 - * QSFP: SFF-8436 & SFF-8636 - * - Normal : 00h / offset 131-138 - * - Extended: 00h / offset 192 - */ - uint8_t transvr_comp[8]; - uint8_t transvr_comp_ext; - - /* [Prop]: vendor_name - * [Desc]: SFP vendor name (ASCII 16 byte char). - * [Note]: ex:FINISAR CORP. - */ - char *vendor_name; - - /* [Prop]: vendor_pn - * [Desc]: Part number provided by SFP vendor (ASCII 16 byte char). - * [Note]: - */ - char *vendor_pn; - - /* [Prop]: vendor_rev - * [Desc]: Revision level for part number provided by vendor (ASCII 4 byte char). - * [Note]: - */ - char *vendor_rev; - - /* [Prop]: vendor_sn - * [Desc]: Serial number provided by vendor (ASCII 16 byte char). - * [Note]: - */ - char *vendor_sn; - - /* [Prop]: Extended identifier - * [Desc]: SFP: - * => None - * - * QSFP: - * => This byte contained two information: - * (1) Power consumption class - * (2) CDR function present - * [Note]: Bit description as below: - * [SFP] - * None - * - * [QSFP] - * (1) Power consumption class: - * Class 1: 1.5W (Bit6-7 = 00:) - * Class 2: 2.0W (Bit6-7 = 01:) - * Class 3: 2.5W (Bit6-7 = 10:) - * Class 4: 3.5W (Bit6-7 = 11:) - * Class 5: 4.0W (Bit0-1 = 01:) - * Class 6: 4.5W (Bit0-1 = 10:) - * Class 7: 5.0W (Bit0-1 = 11:) - * (2) CDR function present: - * Bit2: 0 = No CDR in RX - * 1 = CDR present in RX - * Bit3: 0 = No CDR in TX - * 1 = CDR present in TX - */ - uint8_t ext_id; - - /* [Prop]: br - * [Desc]: Nominal bit rate, units of 100 MBits/sec. - * [Note]: SFP:03h / QSFP:0Ch / QSPF+:0Dh - * has val: 0x67 - * no val : - */ - uint8_t br; - - /* [Prop]: extbr - * [Desc]: Extended br (00h/222) - * [Desc]: Nominal bit rate per channel, units of 250 Mbps. - * Complements. Byte 140. See Table 32A. - */ - uint8_t extbr; - - /* [Prop]: len_sm - * [Desc]: Length (single mode)-(100's)m - * [Note]: This value specifies the link length that is supported by the transceiver - * while operating in compliance with the applicable standards using single mode - * fiber. The value is in units of 100 meters. A value of 255 means that the - * transceiver supports a link length greater than 25.4 km. A value of zero means - * that the transceiver does not support single mode fiber or that the length - * information must be determined from the transceiver technology. - */ - int len_sm; - - /* [Prop]: len_smf - * [Desc]: Length (single mode)-km - * [Note]: Addition to EEPROM data from original GBIC definition. This value specifies - * the link length that is supported by the transceiver while operating in - * compliance with the applicable standards using single mode fiber. The value - * is in units of kilometers. A value of 255 means that the transceiver supports - * a link length greater than 254 km. A value of zero means that the transceiver - * does not support single mode fiber or that the length information must be - * determined from the transceiver technology. - */ - int len_smf; - - /* [Prop]: len_om1 - * [Desc]: Link length supported for 62.5 um OM1 fiber, units of 10 m - * [Note]: The value is in units of 10 meters. A value of 255 means that the - * transceiver supports a link length greater than 2.54 km. A value of - * zero means that the transceiver does not support 50 micron multi-mode - * fiber or that the length information must be determined from the transceiver - * technology. - */ - int len_om1; - - /* [Prop]: len_om2 - * [Desc]: Link length supported for 50 um OM2 fiber, units of 10 m - * [Note]: The value is in units of 10 meters. A value of 255 means that the - * transceiver supports a link length greater than 2.54 km. A value of - * zero means that the transceiver does not support 50 micron multi-mode - * fiber or that the length information must be determined from the transceiver - * technology. - */ - int len_om2; - - /* [Prop]: len_om3 - * [Desc]: Length (50um, OM3) - * [Note]: This value specifies link length that is supported by the transceiver while - * operating in compliance with applicable standards using 50 micron multimode - * OM3 [2000 MHz*km] fiber. The value is in units of 10 meters. A value of 255 - * means that the transceiver supports a link length greater than 2.54 km. A value - * of zero means that the transceiver does not support 50 micron multimode fiber - * or that the length information must be determined from the transceiver technology. - */ - int len_om3; - - /* [Prop]: len_om4 - * [Desc]: Length (50um, OM4) and Length (Active Cable or Copper) - * [Note]: For optical links, this value specifies link length that is supported by the - * transceiver while operating in compliance with applicable standards using 50 micron - * multimode OM4 [4700 MHz*km] fiber. The value is in units of 10 meters. A value of - * 255 means that the transceiver supports a link length greater than 2.54 km. A value - * of zero means that the transceiver does not support 50 micron multimode fiber or that - * the length information must be determined from the transceiver codes specified in Table 5-3. - * - * For copper links, this value specifies minimum link length supported by the transceiver - * while operating in compliance with applicable standards using copper cable. For active - * cable, this value represents actual length. The value is in units of 1 meter. A value of 255 - * means the transceiver supports a link length greater than 254 meters. A value of zero means - * the transceiver does not support copper or active cables or the length information must be - * determined from transceiver technology. Further information about cable design, equalization, - * and connectors is usually required to guarantee meeting a particular length requirement. - */ - int len_om4; - - /* [Prop]: comp_rev - * [Desc]: SFF spec revision compliance - * [Note]: Indicates which revision of SFF SFF-8472 (SFP) / SFF-8636 (QSFP) the transceiver - * complies with. (unsigned integer) - */ - uint8_t comp_rev; - - /* [Prop]: CDR - * [Desc]: For transceivers with CDR capability, setting the CDR to ON engages the internal - * retiming function. Setting the CDR to OFF enables an internal bypassing mode ,which - * directs traffic around the internal CDR. (Reference: SFF-8636) - * [Note]: value=0xff: ON. - * value=0x00: OFF. - */ - uint8_t cdr; - - /* [Prop]: rate_id - * [Desc]: Soft Rate Select 0(RX). - * [Note]: 1. Addr: A0h / Offset: 13 - * 2. Value description: - * 00h Unspecified - * 01h SFF-8079 (4/2/1G Rate_Select & AS0/AS1) - * 02h SFF-8431 (8/4/2G Rx Rate_Select only) - * 03h Unspecified * - * 04h SFF-8431 (8/4/2G Tx Rate_Select only) - * 05h Unspecified * - * 06h SFF-8431 (8/4/2G Independent Rx & Tx Rate_select) - * 07h Unspecified * - * 08h FC-PI-5 (16/8/4G Rx Rate_select only) High=16G only, Low=8G/4G - * 09h Unspecified * - * 0Ah FC-PI-5 (16/8/4G Independent Rx, Tx Rate_select) High=16G only, - * Low=8G/4G - * 0Bh Unspecified * - * 0Ch FC-PI-6 (32/16/8G Independent Rx, Tx Rate_Select) - * High=32G only, Low = 16G/8G - * 0Dh Unspecified * - * 0Eh 10/8G Rx and Tx Rate_Select controlling the operation or locking - * modes of the internal signal conditioner, retimer or CDR, according - * to the logic table defined in Table 10-2, High Bit Rate - * (10G) =9.95-11.3 Gb/s; Low Bit Rate (8G) = 8.5 Gb/s. In this mode, - * the default value of bit 110.3 (Soft Rate Select RS(0), Table 9-11) - * and of bit 118.3 (Soft Rate Select RS(1), Table 10-1) is 1. - * 0Fh Unspecified * - * 10h-FFh Unallocated - */ - int rate_id; - - /* [Prop]: soft_rs0 - * [Desc]: Soft Rate Select 0(RX). - * [Note]: 1. Writing '1' selects full bandwidth operation. - * 2. This bit is "OR'd with the hard Rate_Select, AS(0) or RS(0) pin value. - * 3. Default at power up is logic zero/low - * 4. Addr: A2h / Offset: 110 / Bit: 3 - */ - uint8_t soft_rs0; - - /* [Prop]: soft_rs1 - * [Desc]: Soft Rate Select 1(TX). - * [Note]: 1. Writing '1' selects full bandwidth TX operation. - * 2. This bit is "OR'd with the hard Rate_Select, AS(1) or RS(1) pin value. - * 3. Default at power up is logic zero/low - * 4. Addr: A2h / Offset: 118 / Bit: 3 - */ - uint8_t soft_rs1; - - /* [Prop]: diag_type - * [Desc]: DIAGNOSTIC MONITORING TYPE (A0h/92) - * [Note]: Description in SFF-8472 as below: - * Bit7: Reserved for legacy diagnostic implementations. Must be '0' for compliance - * with this document. - * Bit6: Digital diagnostic monitoring implemented (described in this document). - * Must be '1' for compliance with this document. - * Bit5 Internally calibrated - * Bit4 Externally calibrated - * Bit3 Received power measurement type.0 = OMA, 1 = average power - * Bit2 Address change required see section above, "addressing modes" - * Bit1-0 Unallocated - */ - uint8_t diag_type; - - /* [Prop]: curr_temp - * [Desc]: Transceiver Current Temperature (A2h/96-97) - * [Note]: 1. Dependent on diag_type. - * 2. 96: High byte - * 3. 97: Low byte - * 4. This feature only for SFP - */ - uint8_t curr_temp[2]; - - /* [Prop]: curr_vol - * [Desc]: Transceiver Current Voltage (SFP:A2h/108-109; QSFP:00h/22-23) - * [Note]: 1. Dependent on diag_type. - * 2. 98: High byte - * 3. 99: Low byte - * 4. This feature only for SFP - * 5. Internally measured transceiver supply voltage. Represented - * as a 16 bit unsigned integer with the voltage defined as the - * full 16 bit value (0-65535) with LSB equal to 100 uVolt, - * yielding a total range of 0 to +6.55 Volts - */ - uint8_t curr_voltage[2]; - - /* [Prop]: curr_tx_bias - * [Desc]: Transceiver TX Bias Current (SFP:A2h/100-101; QSFP:00h/26-27) - * [Note]: 1. Dependent on diag_type. - * 2. 100: High byte - * 3. 101: Low byte - * 4. This feature only for SFP - * 5. Measured TX bias current in uA. Represented as a 16 bit unsigned - * integer with the current defined as the full 16 bit value (0-65535) - * with LSB equal to 2 uA, yielding a total range of 0 to 131 mA. - * Accuracy is vendor specific but must be better than 10% of the - * manufacturer's nominal value over specified operating temperature - * and voltage. - */ - uint8_t curr_tx_bias[8]; - - /* [Prop]: curr_tx_power - * [Desc]: Transceiver TX Output Power (A2h/102-103) - * [Note]: 1. Dependent on diag_type. - * 2. 102: High byte - * 3. 103: Low byte - * 4. This feature only for SFP - * 5. Measured TX output power in mW. Represented as a 16 bit unsigned - * integer with the power defined as the full 16 bit value (0-65535) - * with LSB equal to 0.1 uW, yielding a total range of 0 to 6.5535 mW - * (~ -40 to +8.2 dBm). Data is assumed to be based on measurement of - * laser monitor photodiode current. It is factory calibrated to absolute - * units using the most representative fiber output type. Accuracy is - * vendor specific but must be better than 3dB over specified temperature - * and voltage. Data is not valid when the transmitter is disabled. - */ - uint8_t curr_tx_power[8]; - - /* [Prop]: curr_tx_power - * [Desc]: Transceiver TX Output Power (A2h/102-103) - * [Note]: 1. Dependent on diag_type. - * 2. 102: High byte - * 3. 103: Low byte - * 4. This feature only for SFP - * 5. Measured RX received optical power in mW. Value can represent either - * average received power or OMA depending upon how bit 3 of byte 92 (A0h) - * is set. Represented as a 16 bit unsigned integer with the power defined - * as the full 16 bit value (0-65535) with LSB equal to 0.1 uW, yielding a - * total range of 0 to 6.5535 mW (~ -40 to +8.2 dBm). Absolute accuracy is - * dependent upon the exact optical wavelength. For the vendor specified - * wavelength, accuracy shall be better than 3dB over specified temperature - * and voltage. - */ - uint8_t curr_rx_power[8]; - - /* [Prop]: wavelength - * [Desc]: Wavelength or Copper Cable Attenuation - * [Note]: (Following is info from SFF-8636) - * For optical free side devices, this parameter identifies the nominal - * transmitter output wavelength at room temperature. This parameter is a - * 16-bit hex value with Byte 186 as high order byte and Byte 187 as low - * order byte. The laser wavelength is equal to the 16-bit integer value - * divided by 20 in nm (units of 0.05 nm). This resolution should be adequate - * to cover all relevant wavelengths yet provide enough resolution for all - * expected DWDM applications. For accurate representation of controlled - * wavelength applications, this value should represent the center of the - * guaranteed wavelength range. If the free side device is identified as - * copper cable these registers will be used to define the cable attenuation. - * An indication of 0 dB attenuation refers to the case where the attenuation - * is not known or is unavailable. - * Byte 186 (00-FFh) is the copper cable attenuation at 2.5 GHz in units of 1 dB. - * Byte 187 (00-FFh) is the copper cable attenuation at 5.0 GHz in units of 1 dB. - */ - uint8_t wavelength[2]; - - /* [Prop]: Amplitude control - * [Desc]: Amplitude control - * [Note]: QSFP28 => SFF-8636 03H Byte-238/239 - */ - uint8_t rx_am[2]; - - /* [Prop]: Emphasis control - * [Desc]: Emphasis control - * [Note]: SFP+/28 => SFF-8472 A2H Byte-115 - * QSFP28 => SFF-8636 03H Byte-236/237 - */ - uint8_t rx_em[2]; - - /* [Prop]: Soft Rx LOS - * [Desc]: Soft Rx LOS which provide by transceiver - * [Note]: (Following is info from SFF-8636) - * Byte 3: - * - Bit 0: L-Rx1 LOS - * - Bit 1: L-Rx2 LOS - * - Bit 2: L-Rx3 LOS - * - Bit 3: L-Rx4 LOS - */ - uint8_t rx_los; - - /* [Prop]: Soft Tx Disable - * [Desc]: Soft Tx Disable which provide by transceiver - * [Note]: (Following is info from SFF-8636) - * Byte 86: - * - Bit 0: Tx1 Disable - * - Bit 1: Tx2 Disable - * - Bit 2: Tx3 Disable - * - Bit 3: Tx4 Disable - */ - uint8_t tx_disable; - - /* [Prop]: Soft Tx Fault - * [Desc]: Soft Tx Fault which provide by transceiver - * [Note]: (Following is info from SFF-8636) - * Byte 86: - * - Bit 0: Tx1 Fault - * - Bit 1: Tx2 Fault - * - Bit 2: Tx3 Fault - * - Bit 3: Tx4 Fault - */ - uint8_t tx_fault; - - /* [Prop]: Transceiver EQUALIZATION - * [Desc]: Transceiver EQUALIZATION - * [Note]: SFP+/28 => SFF-8472 A2H Byte-114 - * QSFP28 => SFF-8636 03H Byte-234/235 - */ - uint8_t tx_eq[2]; - - /* [Prop]: OPTION VALUES - * [Desc]: The bits in the option field shall specify the options implemented in the transceiver. - * [Note]: SFP+/28 => SFF-8472 A0H Byte-64/65 - * QSFP+/28 => SFF-8636 00H Byte-193/195 - */ - uint8_t option[3]; - - /* [Prop]: External PHY offset - * [Desc]: It needs to be setup first if you want to access transceiver external phy. - * [Note]: This feature dependent on transceiver. - * Currently, only 1G-RJ45 transceiver supported it. - */ - uint8_t extphy_offset; - - uint8_t eeprom[256]; - uint8_t eeprom_update[8]; /* max 64 ports on Maple */ - int port_no; - - /* ========== Object private property ========== - */ - struct device *transvr_dev_p; - struct eeprom_map_s *eeprom_map_p; - struct i2c_client *i2c_client_p; - struct ioexp_obj_s *ioexp_obj_p; - struct transvr_worker_s *worker_p; - struct mutex lock; - char swp_name[32]; - int auto_config; - int auto_tx_disable; - int chan_id; - int chipset_type; - int curr_page; - int info; - int ioexp_virt_offset; - int lane_id[8]; - int layout; - int mode; - int retry; - int state; - int temp; - int type; - - /* ========== Object public functions ========== - */ - int (*get_id)(struct transvr_obj_s *self); - int (*get_ext_id)(struct transvr_obj_s *self); - int (*get_connector)(struct transvr_obj_s *self); - int (*get_vendor_name)(struct transvr_obj_s *self, char *buf_p); - int (*get_vendor_pn)(struct transvr_obj_s *self, char *buf_p); - int (*get_vendor_rev)(struct transvr_obj_s *self, char *buf_p); - int (*get_vendor_sn)(struct transvr_obj_s *self, char *buf_p); - int (*get_power_cls)(struct transvr_obj_s *self); - int (*get_br)(struct transvr_obj_s *self); - int (*get_len_sm)(struct transvr_obj_s *self); - int (*get_len_smf)(struct transvr_obj_s *self); - int (*get_len_om1)(struct transvr_obj_s *self); - int (*get_len_om2)(struct transvr_obj_s *self); - int (*get_len_om3)(struct transvr_obj_s *self); - int (*get_len_om4)(struct transvr_obj_s *self); - int (*get_comp_rev)(struct transvr_obj_s *self); - int (*get_comp_eth_1)(struct transvr_obj_s *self); - int (*get_comp_eth_10)(struct transvr_obj_s *self); - int (*get_comp_eth_10_40)(struct transvr_obj_s *self); - int (*get_comp_extend)(struct transvr_obj_s *self); - int (*get_cdr)(struct transvr_obj_s *self); - int (*get_rate_id)(struct transvr_obj_s *self); - int (*get_soft_rs0)(struct transvr_obj_s *self); - int (*get_soft_rs1)(struct transvr_obj_s *self); - int (*get_info)(struct transvr_obj_s *self); - int (*get_if_type)(struct transvr_obj_s *self, char *buf_p); - int (*get_if_speed)(struct transvr_obj_s *self, char *buf_p); - int (*get_if_lane)(struct transvr_obj_s *self, char *buf_p); - int (*get_curr_temp)(struct transvr_obj_s *self, char *buf_p); - int (*get_curr_vol)(struct transvr_obj_s *self, char *buf_p); - int (*get_soft_rx_los)(struct transvr_obj_s *self, char *buf_p); - int (*get_soft_tx_disable)(struct transvr_obj_s *self, char *buf_p); - int (*get_soft_tx_fault)(struct transvr_obj_s *self, char *buf_p); - int (*get_auto_tx_disable)(struct transvr_obj_s *self, char *buf_p); - int (*get_tx_bias)(struct transvr_obj_s *self, char *buf_p); - int (*get_tx_power)(struct transvr_obj_s *self, char *buf_p); - int (*get_rx_power)(struct transvr_obj_s *self, char *buf_p); - int (*get_tx_eq)(struct transvr_obj_s *self, char *buf_p); - int (*get_rx_am)(struct transvr_obj_s *self, char *buf_p); - int (*get_rx_em)(struct transvr_obj_s *self, char *buf_p); - int (*get_wavelength)(struct transvr_obj_s *self, char *buf_p); - int (*get_extphy_offset)(struct transvr_obj_s *self, char *buf_p); - int (*get_extphy_reg)(struct transvr_obj_s *self, char *buf_p); - int (*set_cdr)(struct transvr_obj_s *self, int input_val); - int (*set_soft_rs0)(struct transvr_obj_s *self, int input_val); - int (*set_soft_rs1)(struct transvr_obj_s *self, int input_val); - int (*set_soft_tx_disable)(struct transvr_obj_s *self, int input_val); - int (*set_auto_tx_disable)(struct transvr_obj_s *self, int input_val); - int (*set_tx_eq)(struct transvr_obj_s *self, int input_val); - int (*set_rx_am)(struct transvr_obj_s *self, int input_val); - int (*set_rx_em)(struct transvr_obj_s *self, int input_val); - int (*set_extphy_offset)(struct transvr_obj_s *self, int input_val); - int (*set_extphy_reg)(struct transvr_obj_s *self, int input_val); - int (*get_eeprom)(struct transvr_obj_s *self, char *buf_p); - - /* ========== Object private functions ========== - */ - int (*init)(struct transvr_obj_s *self); - int (*clean)(struct transvr_obj_s *self); - int (*check)(struct transvr_obj_s *self); - int (*update_all)(struct transvr_obj_s *self, int show_err); - int (*fsm_4_direct)(struct transvr_obj_s* self, char *caller_name); - int (*fsm_4_polling)(struct transvr_obj_s* self, char *caller_name); - int (*send_uevent)(struct transvr_obj_s* self, enum kobject_action u_action); - int (*dump_all)(struct transvr_obj_s* self); -}; - - -/* For AVL Mapping */ -struct transvr_avl_s { - char vendor_name[32]; - char vendor_pn[32]; - int (*init)(struct transvr_obj_s *self); -}; - - -/* Worker for long term task of transceiver */ -struct transvr_worker_s { - /* Task Parameter */ - struct transvr_obj_s *transvr_p; - struct transvr_worker_s *next_p; - struct transvr_worker_s *pre_p; - unsigned long trigger_time; - char func_name[64]; - int retry; - int state; - - /* Task private data */ - void *p_data; - - /* Call back function */ - int (*main_task)(struct transvr_worker_s *task); - int (*post_task)(struct transvr_worker_s *task); -}; - - -struct transvr_obj_s * -create_transvr_obj(char *swp_name, - int chan_id, - struct ioexp_obj_s *ioexp_obj_p, - int ioexp_virt_offset, - int transvr_type, - int chipset_type, - int run_mode); - -void lock_transvr_obj(struct transvr_obj_s *self); -void unlock_transvr_obj(struct transvr_obj_s *self); -int isolate_transvr_obj(struct transvr_obj_s *self); - -int resync_channel_tier_2(struct transvr_obj_s *self); - -void alarm_msg_2_user(struct transvr_obj_s *self, char *emsg); -unsigned char *get_eeprom_update(void); -void set_eeprom_update(unsigned char value[8]); - -#endif /* TRANSCEIVER_H */ diff --git a/packages/platforms/inventec/x86-64/d6356/modules/builds/src/ucd9000.c b/packages/platforms/inventec/x86-64/d6356/modules/builds/src/ucd9000.c deleted file mode 100644 index fbb1479d3..000000000 --- a/packages/platforms/inventec/x86-64/d6356/modules/builds/src/ucd9000.c +++ /dev/null @@ -1,246 +0,0 @@ -/* - * Hardware monitoring driver for UCD90xxx Sequencer and System Health - * Controller series - * - * Copyright (C) 2011 Ericsson AB. - * - * 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 "pmbus.h" - -enum chips { ucd9000, ucd90120, ucd90124, ucd9090, ucd90910 }; - -#define UCD9000_MONITOR_CONFIG 0xd5 -#define UCD9000_NUM_PAGES 0xd6 -#define UCD9000_FAN_CONFIG_INDEX 0xe7 -#define UCD9000_FAN_CONFIG 0xe8 -#define UCD9000_DEVICE_ID 0xfd - -#define UCD9000_MON_TYPE(x) (((x) >> 5) & 0x07) -#define UCD9000_MON_PAGE(x) ((x) & 0x0f) - -#define UCD9000_MON_VOLTAGE 1 -#define UCD9000_MON_TEMPERATURE 2 -#define UCD9000_MON_CURRENT 3 -#define UCD9000_MON_VOLTAGE_HW 4 - -#define UCD9000_NUM_FAN 4 - -struct ucd9000_data { - u8 fan_data[UCD9000_NUM_FAN][I2C_SMBUS_BLOCK_MAX]; - struct pmbus_driver_info info; -}; -#define to_ucd9000_data(_info) container_of(_info, struct ucd9000_data, info) - -static int ucd9000_get_fan_config(struct i2c_client *client, int fan) -{ - int fan_config = 0; - struct ucd9000_data *data - = to_ucd9000_data(pmbus_get_driver_info(client)); - - if (data->fan_data[fan][3] & 1) - fan_config |= PB_FAN_2_INSTALLED; /* Use lower bit position */ - - /* Pulses/revolution */ - fan_config |= (data->fan_data[fan][3] & 0x06) >> 1; - - return fan_config; -} - -static int ucd9000_read_byte_data(struct i2c_client *client, int page, int reg) -{ - int ret = 0; - int fan_config; - - switch (reg) { - case PMBUS_FAN_CONFIG_12: - if (page > 0) - return -ENXIO; - - ret = ucd9000_get_fan_config(client, 0); - if (ret < 0) - return ret; - fan_config = ret << 4; - ret = ucd9000_get_fan_config(client, 1); - if (ret < 0) - return ret; - fan_config |= ret; - ret = fan_config; - break; - case PMBUS_FAN_CONFIG_34: - if (page > 0) - return -ENXIO; - - ret = ucd9000_get_fan_config(client, 2); - if (ret < 0) - return ret; - fan_config = ret << 4; - ret = ucd9000_get_fan_config(client, 3); - if (ret < 0) - return ret; - fan_config |= ret; - ret = fan_config; - break; - default: - ret = -ENODATA; - break; - } - return ret; -} - -static const struct i2c_device_id ucd9000_id[] = { - {"ucd9000", ucd9000}, - {"ucd90120", ucd90120}, - {"ucd90124", ucd90124}, - {"ucd9090", ucd9090}, - {"ucd90910", ucd90910}, - {} -}; -MODULE_DEVICE_TABLE(i2c, ucd9000_id); - -static int ucd9000_probe(struct i2c_client *client, - const struct i2c_device_id *id) -{ - u8 block_buffer[I2C_SMBUS_BLOCK_MAX + 1]; - struct ucd9000_data *data; - struct pmbus_driver_info *info; - const struct i2c_device_id *mid; - int i, ret; - - if (!i2c_check_functionality(client->adapter, - I2C_FUNC_SMBUS_BYTE_DATA | - I2C_FUNC_SMBUS_BLOCK_DATA)) - return -ENODEV; - - ret = i2c_smbus_read_block_data(client, UCD9000_DEVICE_ID, - block_buffer); - if (ret < 0) { - dev_err(&client->dev, "Failed to read device ID\n"); - return ret; - } - block_buffer[ret] = '\0'; - dev_info(&client->dev, "Device ID %s\n", block_buffer); - - for (mid = ucd9000_id; mid->name[0]; mid++) { - if (!strncasecmp(mid->name, block_buffer, strlen(mid->name))) - break; - } - if (!mid->name[0]) { - dev_err(&client->dev, "Unsupported device\n"); - return -ENODEV; - } - - if (id->driver_data != ucd9000 && id->driver_data != mid->driver_data) - dev_notice(&client->dev, - "Device mismatch: Configured %s, detected %s\n", - id->name, mid->name); - - data = devm_kzalloc(&client->dev, sizeof(struct ucd9000_data), - GFP_KERNEL); - if (!data) - return -ENOMEM; - info = &data->info; - - ret = i2c_smbus_read_byte_data(client, UCD9000_NUM_PAGES); - if (ret < 0) { - dev_err(&client->dev, - "Failed to read number of active pages\n"); - return ret; - } - info->pages = ret; - if (!info->pages) { - dev_err(&client->dev, "No pages configured\n"); - return -ENODEV; - } - - /* The internal temperature sensor is always active */ - info->func[0] = PMBUS_HAVE_TEMP; - - /* Everything else is configurable */ - ret = i2c_smbus_read_block_data(client, UCD9000_MONITOR_CONFIG, - block_buffer); - if (ret <= 0) { - dev_err(&client->dev, "Failed to read configuration data\n"); - return -ENODEV; - } - for (i = 0; i < ret; i++) { - int page = UCD9000_MON_PAGE(block_buffer[i]); - - if (page >= info->pages) - continue; - - switch (UCD9000_MON_TYPE(block_buffer[i])) { - case UCD9000_MON_VOLTAGE: - case UCD9000_MON_VOLTAGE_HW: - info->func[page] |= PMBUS_HAVE_VOUT - | PMBUS_HAVE_STATUS_VOUT; - break; - case UCD9000_MON_TEMPERATURE: - info->func[page] |= PMBUS_HAVE_TEMP2 - | PMBUS_HAVE_STATUS_TEMP; - break; - case UCD9000_MON_CURRENT: - info->func[page] |= PMBUS_HAVE_IOUT - | PMBUS_HAVE_STATUS_IOUT; - break; - default: - break; - } - } - - /* Fan configuration */ - if (mid->driver_data == ucd90124) { - for (i = 0; i < UCD9000_NUM_FAN; i++) { - i2c_smbus_write_byte_data(client, - UCD9000_FAN_CONFIG_INDEX, i); - ret = i2c_smbus_read_block_data(client, - UCD9000_FAN_CONFIG, - data->fan_data[i]); - if (ret < 0) - return ret; - } - i2c_smbus_write_byte_data(client, UCD9000_FAN_CONFIG_INDEX, 0); - - info->read_byte_data = ucd9000_read_byte_data; - info->func[0] |= PMBUS_HAVE_FAN12 | PMBUS_HAVE_STATUS_FAN12 - | PMBUS_HAVE_FAN34 | PMBUS_HAVE_STATUS_FAN34; - } - - return pmbus_do_probe(client, mid, info); -} - -/* This is the driver that will be inserted */ -static struct i2c_driver ucd9000_driver = { - .driver = { - .name = "ucd9000", - }, - .probe = ucd9000_probe, - .remove = pmbus_do_remove, - .id_table = ucd9000_id, -}; - -module_i2c_driver(ucd9000_driver); - -MODULE_AUTHOR("Guenter Roeck"); -MODULE_DESCRIPTION("PMBus driver for TI UCD90xxx"); -MODULE_LICENSE("GPL"); diff --git a/packages/platforms/inventec/x86-64/d6356/onlp/Makefile b/packages/platforms/inventec/x86-64/d6356/onlp/Makefile deleted file mode 100644 index 003238cf6..000000000 --- a/packages/platforms/inventec/x86-64/d6356/onlp/Makefile +++ /dev/null @@ -1 +0,0 @@ -include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/inventec/x86-64/d6356/onlp/PKG.yml b/packages/platforms/inventec/x86-64/d6356/onlp/PKG.yml deleted file mode 100644 index 327f2aac6..000000000 --- a/packages/platforms/inventec/x86-64/d6356/onlp/PKG.yml +++ /dev/null @@ -1 +0,0 @@ -!include $ONL_TEMPLATES/onlp-platform-any.yml PLATFORM=x86-64-inventec-d6356 ARCH=amd64 TOOLCHAIN=x86_64-linux-gnu diff --git a/packages/platforms/inventec/x86-64/d6356/onlp/builds/Makefile b/packages/platforms/inventec/x86-64/d6356/onlp/builds/Makefile deleted file mode 100644 index e7437cb23..000000000 --- a/packages/platforms/inventec/x86-64/d6356/onlp/builds/Makefile +++ /dev/null @@ -1,2 +0,0 @@ -FILTER=src -include $(ONL)/make/subdirs.mk diff --git a/packages/platforms/inventec/x86-64/d6356/onlp/builds/lib/Makefile b/packages/platforms/inventec/x86-64/d6356/onlp/builds/lib/Makefile deleted file mode 100644 index ecda53da6..000000000 --- a/packages/platforms/inventec/x86-64/d6356/onlp/builds/lib/Makefile +++ /dev/null @@ -1,2 +0,0 @@ -PLATFORM := x86-64-inventec-d6356 -include $(ONL)/packages/base/any/onlp/builds/platform/libonlp-platform.mk diff --git a/packages/platforms/inventec/x86-64/d6356/onlp/builds/lib/libonlp-x86-64-inventec-d6356.mk b/packages/platforms/inventec/x86-64/d6356/onlp/builds/lib/libonlp-x86-64-inventec-d6356.mk deleted file mode 100644 index 4268ce41e..000000000 --- a/packages/platforms/inventec/x86-64/d6356/onlp/builds/lib/libonlp-x86-64-inventec-d6356.mk +++ /dev/null @@ -1,10 +0,0 @@ - -############################################################################### -# -# Inclusive Makefile for the libonlp-x86-64-inventec-d6356 module. -# -# Autogenerated 2018-11-30 07:22:16.900798 -# -############################################################################### -libonlp-x86-64-inventec-d6356_BASEDIR := $(dir $(abspath $(lastword $(MAKEFILE_LIST)))) - diff --git a/packages/platforms/inventec/x86-64/d6356/onlp/builds/onlpdump/Makefile b/packages/platforms/inventec/x86-64/d6356/onlp/builds/onlpdump/Makefile deleted file mode 100644 index 3198f2342..000000000 --- a/packages/platforms/inventec/x86-64/d6356/onlp/builds/onlpdump/Makefile +++ /dev/null @@ -1,2 +0,0 @@ -PLATFORM := x86-64-inventec-d6356 -include $(ONL)/packages/base/any/onlp/builds/platform/onlps.mk diff --git a/packages/platforms/inventec/x86-64/d6356/onlp/builds/onlpdump/onlpdump.mk b/packages/platforms/inventec/x86-64/d6356/onlp/builds/onlpdump/onlpdump.mk deleted file mode 100644 index 38ffcbdb3..000000000 --- a/packages/platforms/inventec/x86-64/d6356/onlp/builds/onlpdump/onlpdump.mk +++ /dev/null @@ -1,10 +0,0 @@ - -############################################################################### -# -# Inclusive Makefile for the onlpdump module. -# -# Autogenerated 2018-11-30 07:22:10.961262 -# -############################################################################### -onlpdump_BASEDIR := $(dir $(abspath $(lastword $(MAKEFILE_LIST)))) - diff --git a/packages/platforms/inventec/x86-64/d6356/onlp/builds/x86_64_inventec_d6356/.gitignore b/packages/platforms/inventec/x86-64/d6356/onlp/builds/x86_64_inventec_d6356/.gitignore deleted file mode 100644 index 2f8a738cb..000000000 --- a/packages/platforms/inventec/x86-64/d6356/onlp/builds/x86_64_inventec_d6356/.gitignore +++ /dev/null @@ -1 +0,0 @@ -x86_64_inventec_d6356.mk diff --git a/packages/platforms/inventec/x86-64/d6356/onlp/builds/x86_64_inventec_d6356/.module b/packages/platforms/inventec/x86-64/d6356/onlp/builds/x86_64_inventec_d6356/.module deleted file mode 100644 index 0bf6526cd..000000000 --- a/packages/platforms/inventec/x86-64/d6356/onlp/builds/x86_64_inventec_d6356/.module +++ /dev/null @@ -1 +0,0 @@ -name: x86_64_inventec_d6356 diff --git a/packages/platforms/inventec/x86-64/d6356/onlp/builds/x86_64_inventec_d6356/Makefile b/packages/platforms/inventec/x86-64/d6356/onlp/builds/x86_64_inventec_d6356/Makefile deleted file mode 100644 index 71a2b4ec7..000000000 --- a/packages/platforms/inventec/x86-64/d6356/onlp/builds/x86_64_inventec_d6356/Makefile +++ /dev/null @@ -1,9 +0,0 @@ -############################################################################### -# -# -# -############################################################################### -include $(ONL)/make/config.mk -MODULE := x86_64_inventec_d6356 -AUTOMODULE := x86_64_inventec_d6356 -include $(BUILDER)/definemodule.mk diff --git a/packages/platforms/inventec/x86-64/d6356/onlp/builds/x86_64_inventec_d6356/module/auto/make.mk b/packages/platforms/inventec/x86-64/d6356/onlp/builds/x86_64_inventec_d6356/module/auto/make.mk deleted file mode 100644 index d86fff7c2..000000000 --- a/packages/platforms/inventec/x86-64/d6356/onlp/builds/x86_64_inventec_d6356/module/auto/make.mk +++ /dev/null @@ -1,9 +0,0 @@ -############################################################################### -# -# x86_64_inventec_d6356 Autogeneration -# -############################################################################### -x86_64_inventec_d6356_AUTO_DEFS := module/auto/x86_64_inventec_d6356.yml -x86_64_inventec_d6356_AUTO_DIRS := module/inc/x86_64_inventec_d6356 module/src -include $(BUILDER)/auto.mk - diff --git a/packages/platforms/inventec/x86-64/d6356/onlp/builds/x86_64_inventec_d6356/module/auto/x86_64_inventec_d6356.yml b/packages/platforms/inventec/x86-64/d6356/onlp/builds/x86_64_inventec_d6356/module/auto/x86_64_inventec_d6356.yml deleted file mode 100644 index 7155b2f1f..000000000 --- a/packages/platforms/inventec/x86-64/d6356/onlp/builds/x86_64_inventec_d6356/module/auto/x86_64_inventec_d6356.yml +++ /dev/null @@ -1,50 +0,0 @@ -############################################################################### -# -# x86_64_inventec_d6356 Autogeneration Definitions. -# -############################################################################### - -cdefs: &cdefs -- x86_64_inventec_d6356_CONFIG_INCLUDE_LOGGING: - doc: "Include or exclude logging." - default: 1 -- x86_64_inventec_d6356_CONFIG_LOG_OPTIONS_DEFAULT: - doc: "Default enabled log options." - default: AIM_LOG_OPTIONS_DEFAULT -- x86_64_inventec_d6356_CONFIG_LOG_BITS_DEFAULT: - doc: "Default enabled log bits." - default: AIM_LOG_BITS_DEFAULT -- x86_64_inventec_d6356_CONFIG_LOG_CUSTOM_BITS_DEFAULT: - doc: "Default enabled custom log bits." - default: 0 -- x86_64_inventec_d6356_CONFIG_PORTING_STDLIB: - doc: "Default all porting macros to use the C standard libraries." - default: 1 -- x86_64_inventec_d6356_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS: - doc: "Include standard library headers for stdlib porting macros." - default: x86_64_inventec_d6356_CONFIG_PORTING_STDLIB -- x86_64_inventec_d6356_CONFIG_INCLUDE_UCLI: - doc: "Include generic uCli support." - default: 0 -- x86_64_inventec_d6356_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_d6356_CONFIG_HEADER: - defs: *cdefs - basename: x86_64_inventec_d6356_config - - portingmacro: - x86_64_inventec_d6356: - macros: - - malloc - - free - - memset - - memcpy - - strncpy - - vsnprintf - - snprintf - - strlen diff --git a/packages/platforms/inventec/x86-64/d6356/onlp/builds/x86_64_inventec_d6356/module/inc/x86_64_inventec_d6356/x86_64_inventec_d6356.x b/packages/platforms/inventec/x86-64/d6356/onlp/builds/x86_64_inventec_d6356/module/inc/x86_64_inventec_d6356/x86_64_inventec_d6356.x deleted file mode 100644 index 78cf7ca87..000000000 --- a/packages/platforms/inventec/x86-64/d6356/onlp/builds/x86_64_inventec_d6356/module/inc/x86_64_inventec_d6356/x86_64_inventec_d6356.x +++ /dev/null @@ -1,14 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#include - -/* <--auto.start.xmacro(ALL).define> */ -/* */ - -/* <--auto.start.xenum(ALL).define> */ -/* */ - - diff --git a/packages/platforms/inventec/x86-64/d6356/onlp/builds/x86_64_inventec_d6356/module/inc/x86_64_inventec_d6356/x86_64_inventec_d6356_config.h b/packages/platforms/inventec/x86-64/d6356/onlp/builds/x86_64_inventec_d6356/module/inc/x86_64_inventec_d6356/x86_64_inventec_d6356_config.h deleted file mode 100644 index fcdaf4411..000000000 --- a/packages/platforms/inventec/x86-64/d6356/onlp/builds/x86_64_inventec_d6356/module/inc/x86_64_inventec_d6356/x86_64_inventec_d6356_config.h +++ /dev/null @@ -1,137 +0,0 @@ -/**************************************************************************//** - * - * @file - * @brief x86_64_inventec_d6356 Configuration Header - * - * @addtogroup x86_64_inventec_d6356-config - * @{ - * - *****************************************************************************/ -#ifndef __x86_64_inventec_d6356_CONFIG_H__ -#define __x86_64_inventec_d6356_CONFIG_H__ - -#ifdef GLOBAL_INCLUDE_CUSTOM_CONFIG -#include -#endif -#ifdef x86_64_inventec_d6356_INCLUDE_CUSTOM_CONFIG -#include -#endif - -/* */ -#include -/** - * x86_64_inventec_d6356_CONFIG_INCLUDE_LOGGING - * - * Include or exclude logging. */ - - -#ifndef x86_64_inventec_d6356_CONFIG_INCLUDE_LOGGING -#define x86_64_inventec_d6356_CONFIG_INCLUDE_LOGGING 1 -#endif - -/** - * x86_64_inventec_d6356_CONFIG_LOG_OPTIONS_DEFAULT - * - * Default enabled log options. */ - - -#ifndef x86_64_inventec_d6356_CONFIG_LOG_OPTIONS_DEFAULT -#define x86_64_inventec_d6356_CONFIG_LOG_OPTIONS_DEFAULT AIM_LOG_OPTIONS_DEFAULT -#endif - -/** - * x86_64_inventec_d6356_CONFIG_LOG_BITS_DEFAULT - * - * Default enabled log bits. */ - - -#ifndef x86_64_inventec_d6356_CONFIG_LOG_BITS_DEFAULT -#define x86_64_inventec_d6356_CONFIG_LOG_BITS_DEFAULT AIM_LOG_BITS_DEFAULT -#endif - -/** - * x86_64_inventec_d6356_CONFIG_LOG_CUSTOM_BITS_DEFAULT - * - * Default enabled custom log bits. */ - - -#ifndef x86_64_inventec_d6356_CONFIG_LOG_CUSTOM_BITS_DEFAULT -#define x86_64_inventec_d6356_CONFIG_LOG_CUSTOM_BITS_DEFAULT 0 -#endif - -/** - * x86_64_inventec_d6356_CONFIG_PORTING_STDLIB - * - * Default all porting macros to use the C standard libraries. */ - - -#ifndef x86_64_inventec_d6356_CONFIG_PORTING_STDLIB -#define x86_64_inventec_d6356_CONFIG_PORTING_STDLIB 1 -#endif - -/** - * x86_64_inventec_d6356_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS - * - * Include standard library headers for stdlib porting macros. */ - - -#ifndef x86_64_inventec_d6356_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS -#define x86_64_inventec_d6356_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS x86_64_inventec_d6356_CONFIG_PORTING_STDLIB -#endif - -/** - * x86_64_inventec_d6356_CONFIG_INCLUDE_UCLI - * - * Include generic uCli support. */ - - -#ifndef x86_64_inventec_d6356_CONFIG_INCLUDE_UCLI -#define x86_64_inventec_d6356_CONFIG_INCLUDE_UCLI 0 -#endif - -/** - * x86_64_inventec_d6356_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION - * - * Assume chassis fan direction is the same as the PSU fan direction. */ - - -#ifndef x86_64_inventec_d6356_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION -#define x86_64_inventec_d6356_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION 0 -#endif - - - -/** - * All compile time options can be queried or displayed - */ - -/** Configuration settings structure. */ -typedef struct x86_64_inventec_d6356_config_settings_s { - /** name */ - const char* name; - /** value */ - const char* value; -} x86_64_inventec_d6356_config_settings_t; - -/** Configuration settings table. */ -/** x86_64_inventec_d6356_config_settings table. */ -extern x86_64_inventec_d6356_config_settings_t x86_64_inventec_d6356_config_settings[]; - -/** - * @brief Lookup a configuration setting. - * @param setting The name of the configuration option to lookup. - */ -const char* x86_64_inventec_d6356_config_lookup(const char* setting); - -/** - * @brief Show the compile-time configuration. - * @param pvs The output stream. - */ -int x86_64_inventec_d6356_config_show(struct aim_pvs_s* pvs); - -/* */ - -#include "x86_64_inventec_d6356_porting.h" - -#endif /* __x86_64_inventec_d6356_CONFIG_H__ */ -/* @} */ diff --git a/packages/platforms/inventec/x86-64/d6356/onlp/builds/x86_64_inventec_d6356/module/inc/x86_64_inventec_d6356/x86_64_inventec_d6356_dox.h b/packages/platforms/inventec/x86-64/d6356/onlp/builds/x86_64_inventec_d6356/module/inc/x86_64_inventec_d6356/x86_64_inventec_d6356_dox.h deleted file mode 100644 index b802666ab..000000000 --- a/packages/platforms/inventec/x86-64/d6356/onlp/builds/x86_64_inventec_d6356/module/inc/x86_64_inventec_d6356/x86_64_inventec_d6356_dox.h +++ /dev/null @@ -1,26 +0,0 @@ -/**************************************************************************//** - * - * x86_64_inventec_d6356 Doxygen Header - * - *****************************************************************************/ -#ifndef __x86_64_inventec_d6356_DOX_H__ -#define __x86_64_inventec_d6356_DOX_H__ - -/** - * @defgroup x86_64_inventec_d6356 x86_64_inventec_d6356 - x86_64_inventec_d6356 Description - * - -The documentation overview for this module should go here. - - * - * @{ - * - * @defgroup x86_64_inventec_d6356-x86_64_inventec_d6356 Public Interface - * @defgroup x86_64_inventec_d6356-config Compile Time Configuration - * @defgroup x86_64_inventec_d6356-porting Porting Macros - * - * @} - * - */ - -#endif /* __x86_64_inventec_d6356_DOX_H__ */ diff --git a/packages/platforms/inventec/x86-64/d6356/onlp/builds/x86_64_inventec_d6356/module/inc/x86_64_inventec_d6356/x86_64_inventec_d6356_porting.h b/packages/platforms/inventec/x86-64/d6356/onlp/builds/x86_64_inventec_d6356/module/inc/x86_64_inventec_d6356/x86_64_inventec_d6356_porting.h deleted file mode 100644 index 455e6b1ca..000000000 --- a/packages/platforms/inventec/x86-64/d6356/onlp/builds/x86_64_inventec_d6356/module/inc/x86_64_inventec_d6356/x86_64_inventec_d6356_porting.h +++ /dev/null @@ -1,107 +0,0 @@ -/**************************************************************************//** - * - * @file - * @brief x86_64_inventec_d6356 Porting Macros. - * - * @addtogroup x86_64_inventec_d6356-porting - * @{ - * - *****************************************************************************/ -#ifndef __x86_64_inventec_d6356_PORTING_H__ -#define __x86_64_inventec_d6356_PORTING_H__ - - -/* */ -#if x86_64_inventec_d6356_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS == 1 -#include -#include -#include -#include -#include -#endif - -#ifndef x86_64_inventec_d6356_MALLOC - #if defined(GLOBAL_MALLOC) - #define x86_64_inventec_d6356_MALLOC GLOBAL_MALLOC - #elif x86_64_inventec_d6356_CONFIG_PORTING_STDLIB == 1 - #define x86_64_inventec_d6356_MALLOC malloc - #else - #error The macro x86_64_inventec_d6356_MALLOC is required but cannot be defined. - #endif -#endif - -#ifndef x86_64_inventec_d6356_FREE - #if defined(GLOBAL_FREE) - #define x86_64_inventec_d6356_FREE GLOBAL_FREE - #elif x86_64_inventec_d6356_CONFIG_PORTING_STDLIB == 1 - #define x86_64_inventec_d6356_FREE free - #else - #error The macro x86_64_inventec_d6356_FREE is required but cannot be defined. - #endif -#endif - -#ifndef x86_64_inventec_d6356_MEMSET - #if defined(GLOBAL_MEMSET) - #define x86_64_inventec_d6356_MEMSET GLOBAL_MEMSET - #elif x86_64_inventec_d6356_CONFIG_PORTING_STDLIB == 1 - #define x86_64_inventec_d6356_MEMSET memset - #else - #error The macro x86_64_inventec_d6356_MEMSET is required but cannot be defined. - #endif -#endif - -#ifndef x86_64_inventec_d6356_MEMCPY - #if defined(GLOBAL_MEMCPY) - #define x86_64_inventec_d6356_MEMCPY GLOBAL_MEMCPY - #elif x86_64_inventec_d6356_CONFIG_PORTING_STDLIB == 1 - #define x86_64_inventec_d6356_MEMCPY memcpy - #else - #error The macro x86_64_inventec_d6356_MEMCPY is required but cannot be defined. - #endif -#endif - -#ifndef x86_64_inventec_d6356_STRNCPY - #if defined(GLOBAL_STRNCPY) - #define x86_64_inventec_d6356_STRNCPY GLOBAL_STRNCPY - #elif x86_64_inventec_d6356_CONFIG_PORTING_STDLIB == 1 - #define x86_64_inventec_d6356_STRNCPY strncpy - #else - #error The macro x86_64_inventec_d6356_STRNCPY is required but cannot be defined. - #endif -#endif - -#ifndef x86_64_inventec_d6356_VSNPRINTF - #if defined(GLOBAL_VSNPRINTF) - #define x86_64_inventec_d6356_VSNPRINTF GLOBAL_VSNPRINTF - #elif x86_64_inventec_d6356_CONFIG_PORTING_STDLIB == 1 - #define x86_64_inventec_d6356_VSNPRINTF vsnprintf - #else - #error The macro x86_64_inventec_d6356_VSNPRINTF is required but cannot be defined. - #endif -#endif - -#ifndef x86_64_inventec_d6356_SNPRINTF - #if defined(GLOBAL_SNPRINTF) - #define x86_64_inventec_d6356_SNPRINTF GLOBAL_SNPRINTF - #elif x86_64_inventec_d6356_CONFIG_PORTING_STDLIB == 1 - #define x86_64_inventec_d6356_SNPRINTF snprintf - #else - #error The macro x86_64_inventec_d6356_SNPRINTF is required but cannot be defined. - #endif -#endif - -#ifndef x86_64_inventec_d6356_STRLEN - #if defined(GLOBAL_STRLEN) - #define x86_64_inventec_d6356_STRLEN GLOBAL_STRLEN - #elif x86_64_inventec_d6356_CONFIG_PORTING_STDLIB == 1 - #define x86_64_inventec_d6356_STRLEN strlen - #else - #error The macro x86_64_inventec_d6356_STRLEN is required but cannot be defined. - #endif -#endif - -/* */ - - -#endif /* __x86_64_inventec_d6356_PORTING_H__ */ -/* @} */ diff --git a/packages/platforms/inventec/x86-64/d6356/onlp/builds/x86_64_inventec_d6356/module/make.mk b/packages/platforms/inventec/x86-64/d6356/onlp/builds/x86_64_inventec_d6356/module/make.mk deleted file mode 100644 index 1b688e7a2..000000000 --- a/packages/platforms/inventec/x86-64/d6356/onlp/builds/x86_64_inventec_d6356/module/make.mk +++ /dev/null @@ -1,12 +0,0 @@ -############################################################################### -# -# -# -############################################################################### -THIS_DIR := $(dir $(lastword $(MAKEFILE_LIST))) -x86_64_inventec_d6356_INCLUDES := -I $(THIS_DIR)inc -x86_64_inventec_d6356_INTERNAL_INCLUDES := -I $(THIS_DIR)src -x86_64_inventec_d6356_DEPENDMODULE_ENTRIES := init:x86_64_inventec_d6356 ucli:x86_64_inventec_d6356 - -# This error should be addressed in the code. -x86_64_inventec_d6356_BROKEN_CFLAGS += -Wno-stringop-truncation diff --git a/packages/platforms/inventec/x86-64/d6356/onlp/builds/x86_64_inventec_d6356/module/src/Makefile b/packages/platforms/inventec/x86-64/d6356/onlp/builds/x86_64_inventec_d6356/module/src/Makefile deleted file mode 100644 index 5fd547c7b..000000000 --- a/packages/platforms/inventec/x86-64/d6356/onlp/builds/x86_64_inventec_d6356/module/src/Makefile +++ /dev/null @@ -1,9 +0,0 @@ -############################################################################### -# -# Local source generation targets. -# -############################################################################### - -ucli: - @../../../../tools/uclihandlers.py x86_64_inventec_d6356_ucli.c - diff --git a/packages/platforms/inventec/x86-64/d6356/onlp/builds/x86_64_inventec_d6356/module/src/debug.c b/packages/platforms/inventec/x86-64/d6356/onlp/builds/x86_64_inventec_d6356/module/src/debug.c deleted file mode 100644 index a5c42cd1d..000000000 --- a/packages/platforms/inventec/x86-64/d6356/onlp/builds/x86_64_inventec_d6356/module/src/debug.c +++ /dev/null @@ -1,45 +0,0 @@ -#include "x86_64_inventec_d6356_int.h" - -#if x86_64_inventec_d6356_CONFIG_INCLUDE_DEBUG == 1 - -#include - -static char help__[] = - "Usage: debug [options]\n" - " -c CPLD Versions\n" - " -h Help\n" - ; - -int -x86_64_inventec_d6356_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/d6356/onlp/builds/x86_64_inventec_d6356/module/src/fani.c b/packages/platforms/inventec/x86-64/d6356/onlp/builds/x86_64_inventec_d6356/module/src/fani.c deleted file mode 100644 index 2dfeae916..000000000 --- a/packages/platforms/inventec/x86-64/d6356/onlp/builds/x86_64_inventec_d6356/module/src/fani.c +++ /dev/null @@ -1,306 +0,0 @@ -/************************************************************ - * fani.c - * - * Copyright 2018 Inventec Technology Corporation. - * - ************************************************************ - * - * Fan Platform Implementation Defaults. - * - ***********************************************************/ -#include -#include -#include -#include -#include -#include "platform_lib.h" - -#define FAN_GPI_ON_MAIN_BOARD INV_PSOC_PREFIX"/fan_gpi" - -#define MAX_FAN_SPEED 18000 -#define MAX_PSU_FAN_SPEED 25500 - -#define PROJECT_NAME -#define LEN_FILE_NAME 80 - -static char* devfiles__[FAN_MAX] = /* must map with onlp_thermal_id */ -{ - "reserved", - INV_PSOC_PREFIX"/fan1_input", - INV_PSOC_PREFIX"/fan2_input", - INV_PSOC_PREFIX"/fan3_input", - INV_PSOC_PREFIX"/fan4_input", - INV_PSOC_PREFIX"/fan5_input", - INV_PSOC_PREFIX"/fan6_input", - INV_PSOC_PREFIX"/fan7_input", - INV_PSOC_PREFIX"/fan8_input", - INV_PSOC_PREFIX"/rpm_psu1", - INV_PSOC_PREFIX"/rpm_psu2", -}; - -#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_F2B | 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), "PSU-"#psu_id " Fan "#fan_id, 0 }, \ - 0x0, \ - (ONLP_FAN_CAPS_F2B | ONLP_FAN_CAPS_GET_RPM | ONLP_FAN_CAPS_GET_PERCENTAGE), \ - 0, \ - 0, \ - ONLP_FAN_MODE_INVALID, \ - } - -/* Static fan information */ -onlp_fan_info_t linfo[FAN_MAX] = { - { }, /* 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_MAIN_BOARD(7), - MAKE_FAN_INFO_NODE_ON_MAIN_BOARD(8), - 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; - -#if FAN_STATUS_INFO_SUPPORT - /* get fan present status */ - ret = onlp_file_read_int(&value, FAN_GPI_ON_MAIN_BOARD); - if (ret < 0) { - return ONLP_STATUS_E_INTERNAL; - } - if (value & (1 << (fid-1))) { - info->status |= ONLP_FAN_STATUS_FAILED; - } - else { - info->status |= ONLP_FAN_STATUS_PRESENT; - info->status |= ONLP_FAN_STATUS_F2B; - } -#else - info->status |= ONLP_FAN_STATUS_PRESENT; - info->status |= ONLP_FAN_STATUS_F2B; -#endif - - /* get front fan speed */ - ret = onlp_file_read_int(&value, devfiles__[fid]); - if (ret < 0) { - return ONLP_STATUS_E_INTERNAL; - } - info->rpm = value; - info->percentage = (info->rpm * 100) / MAX_PSU_FAN_SPEED; - -#if (FAN_STATUS_INFO_SUPPORT==0) - if (value == 0) { - info->status |= ONLP_FAN_STATUS_FAILED; - } -#endif - - snprintf(info->model, ONLP_CONFIG_INFO_STR_MAX, "NA"); - snprintf(info->serial, ONLP_CONFIG_INFO_STR_MAX, "NA"); - - return ONLP_STATUS_OK; -} - - -#if FAN_STATUS_INFO_SUPPORT -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 fid, onlp_fan_info_t* info) -{ - int value, ret, index; - - info->status |= ONLP_FAN_STATUS_PRESENT; - info->status |= ONLP_FAN_STATUS_F2B; - - /* get fan direction */ - info->status |= _onlp_get_fan_direction_on_psu(); - - if (info->status & ONLP_FAN_STATUS_FAILED) { - return ONLP_STATUS_OK; - } - - index = ONLP_OID_ID_GET(info->hdr.id); - info->hdr.coids[0] = ONLP_FAN_ID_CREATE(index + CHASSIS_FAN_COUNT); - - /* get front fan speed */ - ret = onlp_file_read_int(&value, devfiles__[fid]); - if (ret < 0) { - return ONLP_STATUS_E_INTERNAL; - } - info->rpm = value; - info->percentage = (info->rpm * 100) / MAX_PSU_FAN_SPEED; - info->status |= (value == 0) ? ONLP_FAN_STATUS_FAILED : 0; - - snprintf(info->model, ONLP_CONFIG_INFO_STR_MAX, "NA"); - snprintf(info->serial, ONLP_CONFIG_INFO_STR_MAX, "NA"); - - return ONLP_STATUS_OK; -} -#else -static int -_onlp_fani_info_get_fan_on_psu_na(int fid, onlp_fan_info_t* info) -{ - info->status |= ONLP_FAN_STATUS_PRESENT; - - info->rpm = 0; - info->percentage = 0; - - snprintf(info->model, ONLP_CONFIG_INFO_STR_MAX, "NA"); - snprintf(info->serial, ONLP_CONFIG_INFO_STR_MAX, "NA"); - - return ONLP_STATUS_OK; -} -#endif - -/* - * 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: -#if FAN_STATUS_INFO_SUPPORT - rc = _onlp_fani_info_get_fan_on_psu(local_id, info); -#else - rc = _onlp_fani_info_get_fan_on_psu_na(local_id, info); -#endif - 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 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) - { -#if PSU_MODULE_INFO_SUPPORT - case FAN_1_ON_PSU1: - return psu_pmbus_info_set(PSU1_ID, "rpm_psu1", p); - case FAN_1_ON_PSU2: - return psu_pmbus_info_set(PSU2_ID, "rpm_psu2", p); -#else - case FAN_1_ON_PSU1: - case FAN_1_ON_PSU2: - return ONLP_STATUS_OK; -#endif - 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: - 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/d6356/onlp/builds/x86_64_inventec_d6356/module/src/ledi.c b/packages/platforms/inventec/x86-64/d6356/onlp/builds/x86_64_inventec_d6356/module/src/ledi.c deleted file mode 100644 index a96a4cfa2..000000000 --- a/packages/platforms/inventec/x86-64/d6356/onlp/builds/x86_64_inventec_d6356/module/src/ledi.c +++ /dev/null @@ -1,426 +0,0 @@ -/************************************************************ - * ledi.c - * - * Copyright 2018 Inventec Technology Corporation. - * - ************************************************************ - * - ***********************************************************/ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "platform_lib.h" - -#define filename "brightness" - -#define VALIDATE(_id) \ - do { \ - if(!ONLP_OID_IS_LED(_id)) { \ - return ONLP_STATUS_E_INVALID; \ - } \ - } while(0) - -static char* devfiles__[LED_MAX] = /* must map with onlp_thermal_id */ -{ - "reserved", - INV_CPLD_PREFIX"/%s_led", - INV_PSOC_PREFIX"/fan_led_%s1", - INV_PSOC_PREFIX"/fan_led_%s2", - INV_PSOC_PREFIX"/fan_led_%s3", - INV_PSOC_PREFIX"/fan_led_%s4", -}; - -/* - * Get the information for the given LED OID. - */ -static onlp_led_info_t linfo[LED_MAX] = -{ - { }, /* Not used */ - { - { ONLP_LED_ID_CREATE(LED_SYS), "Chassis LED (SYSTEM 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_MODE_ON, '0', - }, - { - { ONLP_LED_ID_CREATE(LED_FAN1), "Fan LED 1 (FAN1 LED)", 0 }, - ONLP_LED_STATUS_PRESENT, - ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_RED, - ONLP_LED_MODE_ON, '0', - }, - { - { ONLP_LED_ID_CREATE(LED_FAN2), "Fan LED 2 (FAN2 LED)", 0 }, - ONLP_LED_STATUS_PRESENT, - ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_RED, - ONLP_LED_MODE_ON, '0', - }, - { - { ONLP_LED_ID_CREATE(LED_FAN3), "Fan LED 3 (FAN3 LED)", 0 }, - ONLP_LED_STATUS_PRESENT, - ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_RED, - ONLP_LED_MODE_ON, '0', - }, - { - { ONLP_LED_ID_CREATE(LED_FAN4), "Fan LED 4 (FAN4 LED)", 0 }, - ONLP_LED_STATUS_PRESENT, - ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_RED, - ONLP_LED_MODE_ON, '0', - }, -}; - -/* - * This function will be called prior to any other onlp_ledi_* functions. - */ -static pthread_mutex_t diag_mutex; - -int -onlp_ledi_init(void) -{ - pthread_mutex_init(&diag_mutex, NULL); - - /* - * Diag LED Off - */ - onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_SYS), ONLP_LED_MODE_OFF); - - return ONLP_STATUS_OK; -} - -int onlp_chassis_led_read(char *pathp, char *buf, size_t len) -{ - FILE * fp; - - fp = fopen (pathp, "r"); - if(fp == NULL) { - perror("Error opening file"); - return(-1); - } - if( fgets (buf, len, fp) == NULL ) { - perror("Error fgets operation"); - } - fclose(fp); - - return(0); -} - -int onlp_chassis_led_write(char *pathp, char *buf) -{ - FILE * fp; - - fp = fopen (pathp, "w"); - if(fp == NULL) { - perror("Error opening file"); - return(-1); - } - if( fputs (buf, fp) == 0 ) { - perror("Error fputs operation"); - } - fclose(fp); - - return(0); -} - -int -onlp_ledi_info_get(onlp_oid_t id, onlp_led_info_t* info) -{ - int local_id, gret = 0, rret = 0; - char fullpath_grn[50] = {0}; - char fullpath_red[50] = {0}; - int gvalue = 0, rvalue = 0; - char gbuf[32] = {0}; - char rbuf[32] = {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 fullpath */ - switch (local_id) { - case LED_SYS: - sprintf(fullpath_grn, devfiles__[local_id], "grn"); - sprintf(fullpath_red, devfiles__[local_id], "red"); - - /* Set LED mode */ - gret = onlp_chassis_led_read(fullpath_grn, gbuf, 32); - rret = onlp_chassis_led_read(fullpath_red, rbuf, 32); - if (gret < 0 || rret < 0) { - DEBUG_PRINT("%s(%d): gret = %d, rret = %d\r\n", __FUNCTION__, __LINE__, gret, rret); - info->mode = ONLP_LED_MODE_OFF; - info->status = ONLP_LED_STATUS_FAILED; - break; - } - - info->status = ONLP_LED_STATUS_PRESENT; - if (gbuf[0] >= '1' && gbuf[0] <= '7' && rbuf[0] == '0') { - info->mode = ONLP_LED_MODE_GREEN; - info->status |= ONLP_LED_STATUS_ON; - } - else - if (rbuf[0] >= '1' && rbuf[0] <= '7' && gbuf[0] == '0') { - info->mode = ONLP_LED_MODE_RED; - info->status |= ONLP_LED_STATUS_ON; - } - else - if (gbuf[0] >= '1' && gbuf[0] <= '7' && rbuf[0] >= '1' && rbuf[0] <= '7') { - info->mode = ONLP_LED_MODE_ORANGE; - info->status |= ONLP_LED_STATUS_ON; - } - else - if (gbuf[0] == '0' && rbuf[0] == '0') { - info->mode = ONLP_LED_MODE_OFF; - info->status |= ONLP_LED_STATUS_ON; - } - else { - info->mode = ONLP_LED_MODE_OFF; - info->status = ONLP_LED_STATUS_FAILED; - } - break; - case LED_FAN1: - case LED_FAN2: - case LED_FAN3: - case LED_FAN4: - sprintf(fullpath_grn, devfiles__[local_id], "grn"); - - /* Set LED mode */ - if (onlp_file_read_int(&gvalue, fullpath_grn) != 0) { - DEBUG_PRINT("%s(%d)\r\n", __FUNCTION__, __LINE__); - info->mode = ONLP_LED_MODE_OFF; - info->status = ONLP_LED_STATUS_FAILED; - } - else - if (gvalue == 1) { - info->mode = ONLP_LED_MODE_GREEN; - info->status = ONLP_LED_STATUS_ON; - } - else - if (gvalue == 0) { - info->mode = ONLP_LED_MODE_OFF; - info->status = ONLP_LED_STATUS_ON; - } - - sprintf(fullpath_red, devfiles__[local_id], "red"); - - if (onlp_file_read_int(&rvalue, fullpath_red) != 0) { - DEBUG_PRINT("%s(%d)\r\n", __FUNCTION__, __LINE__); - info->mode = ONLP_LED_MODE_OFF; - info->status = ONLP_LED_STATUS_FAILED; - } - else - if (rvalue == 1) { - info->mode = ONLP_LED_MODE_RED; - info->status = ONLP_LED_STATUS_ON; - } - else - if (rvalue == 0) { - info->mode = ONLP_LED_MODE_OFF; - info->status = ONLP_LED_STATUS_ON; - } - break; - default: - DEBUG_PRINT("%s(%d) Invalid led id %d\r\n", __FUNCTION__, __LINE__, local_id); - break; - } - - return ONLP_STATUS_OK; -} - -int onlp_ledi_status_get(onlp_oid_t id, uint32_t* rv) -{ - int result = ONLP_STATUS_OK; - onlp_led_info_t linfo; - - result = onlp_ledi_info_get(id, &linfo); - *rv = linfo.status; - - return result; -} - -/* - * 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; -} - -#define HWMON_PSOC_DIAG_PATH "/sys/bus/i2c/devices/0-0055/hwmon/hwmon2/subsystem/hwmon1/diag" -#define HWMON_CPLD_CTRL_PATH "/sys/bus/i2c/devices/0-0055/ctl" -#define HWMON_DEVICE_DIAG_PATH HWMON_PSOC_DIAG_PATH -#define HWMON_DEVICE_CTRL_PATH HWMON_CPLD_CTRL_PATH - -#define MIN_ACC_SIZE (32) - -/* - * Store attr Section - */ -static int onlp_chassis_led_diag_enable(void) -{ - char tmp[MIN_ACC_SIZE]; - ssize_t ret; - - ret = onlp_chassis_led_read(HWMON_DEVICE_DIAG_PATH, &tmp[0], MIN_ACC_SIZE); - if (ret <= 0) { - return ret; - } - - if (tmp[0] == '0') { - pthread_mutex_lock(&diag_mutex); - ret = onlp_chassis_led_write(HWMON_DEVICE_DIAG_PATH, "1"); - if (ret < 0) { - pthread_mutex_unlock(&diag_mutex); - return ret; - } - - ret = onlp_chassis_led_write(HWMON_DEVICE_CTRL_PATH, "1"); - if (ret < 0) { - pthread_mutex_unlock(&diag_mutex); - return ret; - } - pthread_mutex_unlock(&diag_mutex); - } - - return ret; -} - -static int onlp_chassis_led_diag_disable(void) -{ - char tmp[MIN_ACC_SIZE]; - ssize_t ret; - - ret = onlp_chassis_led_read(HWMON_DEVICE_DIAG_PATH, &tmp[0], MIN_ACC_SIZE); - if (ret <= 0) { - return ret; - } - - if (tmp[0] == '1') { - pthread_mutex_lock(&diag_mutex); - ret = onlp_chassis_led_write(HWMON_DEVICE_DIAG_PATH, "1"); - if (ret < 0) { - pthread_mutex_unlock(&diag_mutex); - return 1; - } - - ret = onlp_chassis_led_write(HWMON_DEVICE_CTRL_PATH, "1"); - if (ret < 0) { - pthread_mutex_unlock(&diag_mutex); - return 1; - } - pthread_mutex_unlock(&diag_mutex); - } - return 1; -} - -/* - * 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) -{ - char fullpath_grn[50] = {0}; - char fullpath_red[50] = {0}; - char sys_buf[32] = {0}; - onlp_led_info_t linfo; - int ret = onlp_ledi_info_get(id, &linfo); - int local_id; - - VALIDATE(id); - - local_id = ONLP_OID_ID_GET(id); - - switch (mode) { - case ONLP_LED_MODE_OFF: - if (ret == ONLP_STATUS_OK && linfo.status & ONLP_LED_STATUS_ON && linfo.mode == ONLP_LED_MODE_OFF) { - return ONLP_STATUS_OK; - } - - sprintf(sys_buf, "%d", 0x0); - sprintf(fullpath_grn, devfiles__[local_id], "grn"); - ret = onlp_chassis_led_write(fullpath_grn, sys_buf); - - sprintf(sys_buf, "%d", 0x0); - sprintf(fullpath_red, devfiles__[local_id], "red"); - ret = onlp_chassis_led_write(fullpath_red, sys_buf); - break; - case ONLP_LED_MODE_RED: - if (ret == ONLP_STATUS_OK && linfo.status & ONLP_LED_STATUS_ON && linfo.mode == ONLP_LED_MODE_RED) { - return ONLP_STATUS_OK; - } - - sprintf(sys_buf, "%d", 0x0); - sprintf(fullpath_grn, devfiles__[local_id], "grn"); - ret = onlp_chassis_led_write(fullpath_grn, sys_buf); - - sprintf(sys_buf, "%d", 0x7); - sprintf(fullpath_red, devfiles__[local_id], "red"); - ret = onlp_chassis_led_write(fullpath_red, sys_buf); - break; - case ONLP_LED_MODE_GREEN: - if (ret == ONLP_STATUS_OK && linfo.status & ONLP_LED_STATUS_ON && linfo.mode == ONLP_LED_MODE_GREEN) { - return ONLP_STATUS_OK; - } - - sprintf(sys_buf, "%d", 0x7); - sprintf(fullpath_grn, devfiles__[local_id], "grn"); - ret = onlp_chassis_led_write(fullpath_grn, sys_buf); - - sprintf(sys_buf, "%d", 0x0); - sprintf(fullpath_red, devfiles__[local_id], "red"); - ret = onlp_chassis_led_write(fullpath_red, sys_buf); - break; - case ONLP_LED_MODE_ORANGE: - if (ret == ONLP_STATUS_OK && linfo.status & ONLP_LED_STATUS_ON && linfo.mode == ONLP_LED_MODE_ORANGE) { - return ONLP_STATUS_OK; - } - - sprintf(sys_buf, "%d", 0x7); - sprintf(fullpath_grn, devfiles__[local_id], "grn"); - ret = onlp_chassis_led_write(fullpath_grn, sys_buf); - - sprintf(sys_buf, "%d", 0x7); - sprintf(fullpath_red, devfiles__[local_id], "red"); - ret = onlp_chassis_led_write(fullpath_red, sys_buf); - break; - default: - DEBUG_PRINT("%s(%d) Invalid led mode %d\r\n", __FUNCTION__, __LINE__, mode); - return ONLP_STATUS_E_INTERNAL; - } - - switch (local_id) { - case LED_SYS: - onlp_chassis_led_diag_enable(); - sleep(1); - onlp_chassis_led_diag_disable(); - break; - default: - break; - } - - return ONLP_STATUS_OK; -} diff --git a/packages/platforms/inventec/x86-64/d6356/onlp/builds/x86_64_inventec_d6356/module/src/make.mk b/packages/platforms/inventec/x86-64/d6356/onlp/builds/x86_64_inventec_d6356/module/src/make.mk deleted file mode 100644 index ee83afe15..000000000 --- a/packages/platforms/inventec/x86-64/d6356/onlp/builds/x86_64_inventec_d6356/module/src/make.mk +++ /dev/null @@ -1,9 +0,0 @@ -############################################################################### -# -# -# -############################################################################### - -LIBRARY := x86_64_inventec_d6356 -$(LIBRARY)_SUBDIR := $(dir $(lastword $(MAKEFILE_LIST))) -include $(BUILDER)/lib.mk diff --git a/packages/platforms/inventec/x86-64/d6356/onlp/builds/x86_64_inventec_d6356/module/src/platform_lib.c b/packages/platforms/inventec/x86-64/d6356/onlp/builds/x86_64_inventec_d6356/module/src/platform_lib.c deleted file mode 100644 index ab185ab61..000000000 --- a/packages/platforms/inventec/x86-64/d6356/onlp/builds/x86_64_inventec_d6356/module/src/platform_lib.c +++ /dev/null @@ -1,184 +0,0 @@ -/************************************************************ - * platform_lib.c - * - * Copyright 2018 Inventec Corporation. - * - ************************************************************ - * - ***********************************************************/ -#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 32 -#define I2C_PSU_FAN_DIR_LEN 8 -#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)] = 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; - } - } - - if (strncmp(model_name, "DPS-150AB-10", 12) == 0) { - if (modelname) { - strncpy(modelname, model_name, 12); - } - - return PSU_TYPE_DC_12V_F2B; - } - - 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%d", PSU1_AC_PMBUS_PREFIX, node, PSU1_ID); - } - else - if (PSU2_ID == id) { - ret = onlp_file_read_int(value, "%s%s%d", PSU2_AC_PMBUS_PREFIX, node, PSU2_ID); - } - else { - return ONLP_STATUS_E_INTERNAL; - } - - 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%d", PSU1_AC_PMBUS_PREFIX, node, PSU1_ID); - break; - case PSU2_ID: - sprintf(path, "%s%s%d", PSU2_AC_PMBUS_PREFIX, node, PSU2_ID); - 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/d6356/onlp/builds/x86_64_inventec_d6356/module/src/platform_lib.h b/packages/platforms/inventec/x86-64/d6356/onlp/builds/x86_64_inventec_d6356/module/src/platform_lib.h deleted file mode 100644 index 28fa7f217..000000000 --- a/packages/platforms/inventec/x86-64/d6356/onlp/builds/x86_64_inventec_d6356/module/src/platform_lib.h +++ /dev/null @@ -1,146 +0,0 @@ -/************************************************************ - * platform_lib.h - * - * Copyright 2018 Inventec Technology Corporation. - * - ************************************************************ - * - ***********************************************************/ -#ifndef __PLATFORM_LIB_H__ -#define __PLATFORM_LIB_H__ - -#include "x86_64_inventec_d6356_log.h" - -#define PSU_MODULE_INFO_SUPPORT (0) -#define FAN_STATUS_INFO_SUPPORT (0) -#define THERMAL_INFO_SUPPORT (0) - -#define ONLP_NODE_MAX_INT_LEN (8) -#define ONLP_NODE_MAX_PATH_LEN (64) - -#define INV_CPLD_COUNT (2) -#define INV_CPLD_PREFIX "/sys/bus/i2c/devices/2-0077/" -#define INV_CPLD2_PREFIX "/sys/bus/i2c/devices/2-0033/" -#define INV_PSOC_PREFIX INV_CPLD_PREFIX -#define INV_EPRM_PREFIX "/sys/bus/i2c/devices/2-0055/" -#define INV_CTMP_PREFIX "/sys/devices/platform/coretemp.0/hwmon/hwmon0/" - -#define INV_SFP_EEPROM_UPDATE "/sys/class/swps/module/eeprom_update" -#define CHASSIS_SFP_COUNT (56) - -/* - * Definitions of Chassis EEPROM - */ -#define EEPROM_NODE(node) INV_EPRM_PREFIX#node - - -/* - * Definitions of D6356 device - */ -enum onlp_thermal_id { - THERMAL_RESERVED = 0, - THERMAL_CPU_CORE_FIRST, - THERMAL_CPU_CORE_2, - THERMAL_CPU_CORE_3, - THERMAL_CPU_CORE_4, - THERMAL_CPU_CORE_LAST, -#if THERMAL_INFO_SUPPORT - 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_2_ON_PSU1, - THERMAL_1_ON_PSU2, - THERMAL_2_ON_PSU2, -#endif - THERMAL_MAX -}; -#define CHASSIS_THERMAL_COUNT (5) - -enum onlp_fan_id { - FAN_RESERVED = 0, - FAN_1_ON_MAIN_BOARD, - FAN_2_ON_MAIN_BOARD, - FAN_3_ON_MAIN_BOARD, - FAN_4_ON_MAIN_BOARD, - FAN_5_ON_MAIN_BOARD, - FAN_6_ON_MAIN_BOARD, - FAN_7_ON_MAIN_BOARD, - FAN_8_ON_MAIN_BOARD, - FAN_1_ON_PSU1, - FAN_1_ON_PSU2, - FAN_MAX -}; -#define CHASSIS_FAN_COUNT (8) - -enum onlp_led_id { - LED_RESERVED = 0, - LED_SYS, - LED_FAN1, - LED_FAN2, - LED_FAN3, - LED_FAN4, - LED_MAX -}; -#define CHASSIS_LED_COUNT (1) - -enum onlp_psu_id { - PSU_RESERVED = 0, - PSU1_ID, - PSU2_ID, - PSU_MAX -}; -#define CHASSIS_PSU_COUNT (2) - -#define PSU1_AC_PMBUS_PREFIX INV_PSOC_PREFIX -#define PSU2_AC_PMBUS_PREFIX INV_PSOC_PREFIX - -#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 INV_CPLD_PREFIX -#define PSU2_AC_HWMON_PREFIX INV_CPLD_PREFIX - -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 PSU1_AC_HWMON_NODE(node) PSU1_AC_HWMON_PREFIX#node -#define PSU2_AC_HWMON_NODE(node) PSU2_AC_HWMON_PREFIX#node - -/* - * Definitions of FAN device - */ -#define FAN_BOARD_PATH INV_PSOC_PREFIX -#define FAN_NODE(node) FAN_BOARD_PATH#node - -/* - * Prototypes - */ -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); - -#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/d6356/onlp/builds/x86_64_inventec_d6356/module/src/psui.c b/packages/platforms/inventec/x86-64/d6356/onlp/builds/x86_64_inventec_d6356/module/src/psui.c deleted file mode 100644 index c3cc72052..000000000 --- a/packages/platforms/inventec/x86-64/d6356/onlp/builds/x86_64_inventec_d6356/module/src/psui.c +++ /dev/null @@ -1,267 +0,0 @@ -/************************************************************ - * psui.c - * - * Copyright 2018 Inventec Technology Corporation. - * - ************************************************************ - * - ***********************************************************/ -#include -#include -#include -#include -#include -#include -#include "platform_lib.h" - -#define PSU_STATUS_PRESENT (0) -#define PSU_STATUS_POWER_GOOD (1) -#define PSU_STATUS_UNPOWERED (2) -#define PSU_STATUS_FAULT (4) -#define PSU_STATUS_UNINSTALLED (7) - -#define VALIDATE(_id) \ - do { \ - if(!ONLP_OID_IS_PSU(_id)) { \ - return ONLP_STATUS_E_INVALID; \ - } \ - } while(0) - -static char* status_devfiles__[PSU_MAX] = /* must map with onlp_psu_id */ -{ - "reserved", - INV_CPLD_PREFIX"/psu1", - INV_CPLD_PREFIX"/psu2", -}; - -#if PSU_MODULE_INFO_SUPPORT -static char* module_devfiles__[PSU_MAX] = /* must map with onlp_psu_id */ -{ - "reserved", - INV_PSOC_PREFIX"/psoc_psu1_%s", - INV_PSOC_PREFIX"/psoc_psu2_%s", -}; -#endif - -static int -psu_status_info_get(int id, char *node, int *value) -{ - char node_path[ONLP_NODE_MAX_PATH_LEN] = {0}; - char status_info[16] = {0}; - - if (PSU1_ID == id) { - sprintf(node_path, status_devfiles__[id]); - } - else if (PSU2_ID == id) { - sprintf(node_path, status_devfiles__[id]); - } - - if (onlp_file_read_string(node_path, status_info, 16, 0) != 0) { - return ONLP_STATUS_E_INTERNAL; - } - - *value = status_info[0] - '0'; - return ONLP_STATUS_OK; -} - - -int -onlp_psui_init(void) -{ - return ONLP_STATUS_OK; -} - -static void -psu_module_name_get(int id, onlp_psu_info_t* info) -{ -#if PSU_MODULE_INFO_SUPPORT - char node_path[ONLP_NODE_MAX_PATH_LEN] = {0}; - uint8_t temp[ONLP_CONFIG_INFO_STR_MAX] = {0}; - int ret, len; - - memset(node_path, 0, ONLP_NODE_MAX_PATH_LEN); - sprintf(node_path, module_devfiles__[id], "model"); - ret = onlp_file_read(temp, ONLP_CONFIG_INFO_STR_MAX, &len, node_path); - if (ret == 0) { - /*remove the '\n'*/ - temp[strlen((char*)temp)-1] = 0; - snprintf(info->model, ONLP_CONFIG_INFO_STR_MAX, "%s", temp); - } - else { - AIM_LOG_ERROR("Unable to read model name from file(%s)\r\n", node_path); - strncpy(info->model, "N/A", 3); - } -#else - strncpy(info->model, "N/A", 3); -#endif -} - -static int -psu_module_info_get(int id, onlp_psu_info_t* info) -{ -#if PSU_MODULE_INFO_SUPPORT - int ret = 0; - char node_path[ONLP_NODE_MAX_PATH_LEN] = {0}; - int value = 0; - - info->caps |= ONLP_PSU_CAPS_DC12; - - memset(node_path, 0, ONLP_NODE_MAX_PATH_LEN); - sprintf(node_path, module_devfiles__[id], "vout"); - ret = onlp_file_read_int(&value, node_path); - if (ret < 0) { - AIM_LOG_ERROR("Unable to read vout from file(%s)\r\n", node_path); - } - else { - info->mvout = value; - info->caps |= ONLP_PSU_CAPS_VOUT; - } - - memset(node_path, 0, ONLP_NODE_MAX_PATH_LEN); - sprintf(node_path, module_devfiles__[id], "iout"); - ret = onlp_file_read_int(&value, node_path); - if (ret < 0) { - AIM_LOG_ERROR("Unable to read iout from file(%s)\r\n", node_path); - } - else { - info->miout = value; - info->caps |= ONLP_PSU_CAPS_IOUT; - } - - memset(node_path, 0, ONLP_NODE_MAX_PATH_LEN); - sprintf(node_path, module_devfiles__[id], "pout"); - ret = onlp_file_read_int(&value, node_path); - if (ret < 0) { - AIM_LOG_ERROR("Unable to read pout from file(%s)\r\n", node_path); - } - else { - info->mpout = value; - info->caps |= ONLP_PSU_CAPS_POUT; - } - - memset(node_path, 0, ONLP_NODE_MAX_PATH_LEN); - sprintf(node_path, module_devfiles__[id], "vin"); - ret = onlp_file_read_int(&value, node_path); - if (ret < 0) { - AIM_LOG_ERROR("Unable to read vin from file(%s)\r\n", node_path); - } - else { - info->mvin = value; - info->caps |= ONLP_PSU_CAPS_VIN; - } - - memset(node_path, 0, ONLP_NODE_MAX_PATH_LEN); - sprintf(node_path, module_devfiles__[id], "iin"); - ret = onlp_file_read_int(&value, node_path); - if (ret < 0) { - AIM_LOG_ERROR("Unable to read iin from file(%s)\r\n", node_path); - } - else { - info->miin = value; - info->caps |= ONLP_PSU_CAPS_IIN; - } - memset(node_path, 0, ONLP_NODE_MAX_PATH_LEN); - sprintf(node_path, module_devfiles__[id], "pin"); - ret = onlp_file_read_int(&value, node_path); - if (ret < 0) { - AIM_LOG_ERROR("Unable to read pin from file(%s)\r\n", node_path); - } - else { - info->mpin = value; - info->caps |= ONLP_PSU_CAPS_PIN; - } -#else - info->caps |= ONLP_PSU_CAPS_AC; - - info->mvout = 0; - info->caps |= ONLP_PSU_CAPS_VOUT; - - info->miout = 0; - info->caps |= ONLP_PSU_CAPS_IOUT; - - info->mpout = 0; - info->caps |= ONLP_PSU_CAPS_POUT; - - info->mvin = 0; - info->caps |= ONLP_PSU_CAPS_VIN; - - info->miin = 0; - info->caps |= ONLP_PSU_CAPS_IIN; - - info->mpin = 0; - info->caps |= ONLP_PSU_CAPS_PIN; -#endif - - psu_module_name_get(id, info); - 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, - { -#if PSU_MODULE_INFO_SUPPORT - ONLP_THERMAL_ID_CREATE(THERMAL_1_ON_PSU1), - ONLP_THERMAL_ID_CREATE(THERMAL_2_ON_PSU1), -#endif - ONLP_FAN_ID_CREATE(FAN_1_ON_PSU1) - } - }, - }, - { - { - ONLP_PSU_ID_CREATE(PSU2_ID), "PSU-2", 0, - { -#if PSU_MODULE_INFO_SUPPORT - ONLP_THERMAL_ID_CREATE(THERMAL_1_ON_PSU2), - ONLP_THERMAL_ID_CREATE(THERMAL_2_ON_PSU2), -#endif - ONLP_FAN_ID_CREATE(FAN_1_ON_PSU2) - } - }, - } -}; - -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 ((ret = psu_status_info_get(index, "psu", &val)) == ONLP_STATUS_E_INTERNAL) { - printf("Unable to read PSU(%d) node(psu)\r\n", index); - return ret; - } - - if (val == 1) { - info->status = ONLP_PSU_STATUS_PRESENT; - } - else - if (val == 0) { - info->status = ONLP_PSU_STATUS_UNPLUGGED; - return ret; - } - else { - info->status = ONLP_PSU_STATUS_FAILED; - return ret; - } - - if ((ret = psu_module_info_get(index, info)) != ONLP_STATUS_OK) { - printf("Unable to read PSU(%d) module information\r\n", index); - } - - return ret; -} diff --git a/packages/platforms/inventec/x86-64/d6356/onlp/builds/x86_64_inventec_d6356/module/src/sfpi.c b/packages/platforms/inventec/x86-64/d6356/onlp/builds/x86_64_inventec_d6356/module/src/sfpi.c deleted file mode 100644 index 972495047..000000000 --- a/packages/platforms/inventec/x86-64/d6356/onlp/builds/x86_64_inventec_d6356/module/src/sfpi.c +++ /dev/null @@ -1,240 +0,0 @@ -/************************************************************ - * sfpi.c - * - * Copyright 2018 Inventec Technology Corporation. - * - ************************************************************ - * - ***********************************************************/ -#include - -#include /* For O_RDWR && open */ -#include -#include -#include -#include -#include -#include -#include "platform_lib.h" - -static char sfp_node_path[ONLP_NODE_MAX_PATH_LEN] = {0}; - -#define NUM_OF_SFP_PORT (CHASSIS_SFP_COUNT) -static const int sfp_mux_index[NUM_OF_SFP_PORT] = { -23, 22, 25, 24, 27, 26, 29, 28, -31, 30, 33, 32, 35, 34, 37, 36, -39, 38, 41, 40, 43, 42, 45, 44, -47, 46, 49, 48, 51, 50, 53, 52, -55, 54, 57, 56, 59, 58, 61, 60, -63, 62, 65, 64, 67, 66, 69, 68, -15, 14, 17, 16, 19, 18, 21, 20, -}; - -#define FRONT_PORT_TO_MUX_INDEX(port) (sfp_mux_index[port]) - -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/class/swps/port%d/%s", port+1, 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, 64} - */ - 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, "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; - } - if (present == 0) { - present = 1; - } - else - if (present == 1) { - present = 0; - } - else { - AIM_LOG_ERROR("Unvalid present status %d from port(%d)\r\n",present,port); - return ONLP_STATUS_E_INTERNAL; - } - return present; -} - -int -onlp_sfpi_presence_bitmap_get(onlp_sfp_bitmap_t* dst) -{ - uint32_t presence_all[2] = {0}; - int port, ret, index; - - for (port = 0, index = 0; port < NUM_OF_SFP_PORT; port++) { - if (port == 32) { - index = 1; - } - - ret = onlp_sfpi_is_present(port); - if (ret == 1) { - presence_all[index] |= (1<>= 1; - } - return ONLP_STATUS_OK; -} - -int -onlp_sfpi_eeprom_read(int port, uint8_t data[256]) -{ - char* path; - 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); - path = sfp_get_port_path(port, "eeprom"); - //printf("INV debug: onlp_sfpi_eeprom_read(): port = %d, path = %s\n", port, path); - if (onlp_file_read(&data[0], 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_dom_read(int port, uint8_t data[256]) -{ - return onlp_sfpi_eeprom_read( port, data); -} - -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); - int ret = onlp_i2c_writeb(bus, devaddr, addr, value, ONLP_I2C_F_FORCE); - - if (ret == 0) { - unsigned char buf[8] = { 0 }; - char str[20]; - - buf[port/8] = (1 << port%8); - sprintf(str, "0x%02x%02x%02x%02x%02x%02x%02x%02x", buf[7],buf[6],buf[5],buf[4],buf[3],buf[2],buf[1],buf[0]); - if (onlp_file_write((uint8_t*)str, 20, INV_SFP_EEPROM_UPDATE) < 0) { - AIM_LOG_ERROR("Unable to write eeprom_update for port(%d)\r\n", port); - return ONLP_STATUS_E_INTERNAL; - } - return ONLP_STATUS_OK; - } - AIM_LOG_ERROR("Unable to read eeprom_update from port(%d)\r\n", port); - return ret; -} - -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); - int ret = onlp_i2c_writew(bus, devaddr, addr, value, ONLP_I2C_F_FORCE); - - if (ret == 0) { - unsigned char buf[8] = { 0 }; - char str[20]; - - buf[port/8] = (1 << port%8); - sprintf(str, "0x%02x%02x%02x%02x%02x%02x%02x%02x", buf[7],buf[6],buf[5],buf[4],buf[3],buf[2],buf[1],buf[0]); - if (onlp_file_write((uint8_t*)str, 20, INV_SFP_EEPROM_UPDATE) < 0) { - AIM_LOG_ERROR("Unable to write eeprom_update for port(%d)\r\n", port); - return ONLP_STATUS_E_INTERNAL; - } - return ONLP_STATUS_OK; - } - AIM_LOG_ERROR("Unable to read eeprom_update from port(%d)\r\n", port); - return ret; -} - -int -onlp_sfpi_denit(void) -{ - return ONLP_STATUS_OK; -} - diff --git a/packages/platforms/inventec/x86-64/d6356/onlp/builds/x86_64_inventec_d6356/module/src/sysi.c b/packages/platforms/inventec/x86-64/d6356/onlp/builds/x86_64_inventec_d6356/module/src/sysi.c deleted file mode 100644 index d9182090a..000000000 --- a/packages/platforms/inventec/x86-64/d6356/onlp/builds/x86_64_inventec_d6356/module/src/sysi.c +++ /dev/null @@ -1,111 +0,0 @@ -/************************************************************ - * sysi.c - * - * Copyright 2018 Inventec Technology Corporation. - * - ************************************************************ - * - ***********************************************************/ -#include -#include - -#include -#include -#include -#include -#include -#include - -#include "x86_64_inventec_d6356_int.h" -#include "x86_64_inventec_d6356_log.h" - -#include "platform_lib.h" - -#define NUM_OF_CPLD INV_CPLD_COUNT - -#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 (CHASSIS_PSU_COUNT) -#define NUM_OF_LED_ON_MAIN_BROAD (CHASSIS_LED_COUNT) - -const char* -onlp_sysi_platform_get(void) -{ - return "x86-64-inventec-d6356-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, EEPROM_NODE(eeprom)) == 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)); - - /* 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; -} - -static char *arr_cplddev_version[NUM_OF_CPLD] = -{ - INV_CPLD_PREFIX"/version", - INV_CPLD2_PREFIX"/version", -}; - -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, arr_cplddev_version[i]) < 0) { - return ONLP_STATUS_E_INTERNAL; - } - } - pi->cpld_versions = aim_fstrdup("%d.%d", v[0], v[1]); - return 0; -} - -void -onlp_sysi_platform_info_free(onlp_platform_info_t* pi) -{ - aim_free(pi->cpld_versions); -} diff --git a/packages/platforms/inventec/x86-64/d6356/onlp/builds/x86_64_inventec_d6356/module/src/thermali.c b/packages/platforms/inventec/x86-64/d6356/onlp/builds/x86_64_inventec_d6356/module/src/thermali.c deleted file mode 100644 index 42c611de6..000000000 --- a/packages/platforms/inventec/x86-64/d6356/onlp/builds/x86_64_inventec_d6356/module/src/thermali.c +++ /dev/null @@ -1,156 +0,0 @@ -/************************************************************ - * thermali.c - * - * Copyright 2018 Inventec Technology Corporation. - * - ************************************************************ - * - * 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) - -static char* devfiles__[THERMAL_MAX] = /* must map with onlp_thermal_id */ -{ - "reserved", - INV_CTMP_PREFIX"/temp1_%s", - INV_CTMP_PREFIX"/temp2_%s", - INV_CTMP_PREFIX"/temp3_%s", - INV_CTMP_PREFIX"/temp4_%s", - INV_CTMP_PREFIX"/temp5_%s", -#if THERMAL_INFO_SUPPORT - INV_PSOC_PREFIX"/temp1_input", - INV_PSOC_PREFIX"/temp2_input", - INV_PSOC_PREFIX"/temp3_input", - INV_PSOC_PREFIX"/temp4_input", - INV_PSOC_PREFIX"/temp5_input", - INV_PSOC_PREFIX"/thermal_psu1", - INV_PSOC_PREFIX"/thermal2_psu1", - INV_PSOC_PREFIX"/thermal_psu2", - INV_PSOC_PREFIX"/thermal2_psu2", -#endif -}; - -/* Static values */ -static onlp_thermal_info_t linfo[THERMAL_MAX] = { - { }, /* Not used */ - { { ONLP_THERMAL_ID_CREATE(THERMAL_CPU_CORE_FIRST), "Physical id 0", 0}, - ONLP_THERMAL_STATUS_PRESENT, - ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS - }, - { { ONLP_THERMAL_ID_CREATE(THERMAL_CPU_CORE_2), "CPU Core 0", 0}, - ONLP_THERMAL_STATUS_PRESENT, - ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS - }, - { { ONLP_THERMAL_ID_CREATE(THERMAL_CPU_CORE_3), "CPU Core 1", 0}, - ONLP_THERMAL_STATUS_PRESENT, - ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS - }, - { { ONLP_THERMAL_ID_CREATE(THERMAL_CPU_CORE_4), "CPU Core 2", 0}, - ONLP_THERMAL_STATUS_PRESENT, - ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS - }, - { { ONLP_THERMAL_ID_CREATE(THERMAL_CPU_CORE_LAST), "CPU Core 3", 0}, - ONLP_THERMAL_STATUS_PRESENT, - ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS - }, -#if THERMAL_INFO_SUPPORT - { { 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_3_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_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_2_ON_PSU1), "PSU-1 Thermal Sensor 2", 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 - }, - { { ONLP_THERMAL_ID_CREATE(THERMAL_2_ON_PSU2), "PSU-2 Thermal Sensor 2", ONLP_PSU_ID_CREATE(PSU2_ID)}, - ONLP_THERMAL_STATUS_PRESENT, - ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS - } -#endif -}; - -/* - * 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_FIRST && local_id <= THERMAL_CPU_CORE_LAST) { - char desc[32], *dp = &desc[0]; - int rv = onlp_file_read_str(&dp, devfiles__[local_id], "label"); - if (rv > 0) { - memset (info->hdr.description, 0, ONLP_OID_DESC_SIZE); - strncpy(info->hdr.description, dp, rv); - } - - /* Set the onlp_oid_hdr_t and capabilities */ - return onlp_file_read_int(&info->mcelsius, devfiles__[local_id], "input"); - } -#if THERMAL_INFO_SUPPORT - return onlp_file_read_int(&info->mcelsius, devfiles__[local_id]); -#else - info->mcelsius = 0; - return ONLP_STATUS_OK; -#endif -} diff --git a/packages/platforms/inventec/x86-64/d6356/onlp/builds/x86_64_inventec_d6356/module/src/x86_64_inventec_d6356_config.c b/packages/platforms/inventec/x86-64/d6356/onlp/builds/x86_64_inventec_d6356/module/src/x86_64_inventec_d6356_config.c deleted file mode 100644 index 4167f14ce..000000000 --- a/packages/platforms/inventec/x86-64/d6356/onlp/builds/x86_64_inventec_d6356/module/src/x86_64_inventec_d6356_config.c +++ /dev/null @@ -1,81 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#include - -/* */ -#define __x86_64_inventec_d6356_config_STRINGIFY_NAME(_x) #_x -#define __x86_64_inventec_d6356_config_STRINGIFY_VALUE(_x) __x86_64_inventec_d6356_config_STRINGIFY_NAME(_x) -x86_64_inventec_d6356_config_settings_t x86_64_inventec_d6356_config_settings[] = -{ -#ifdef x86_64_inventec_d6356_CONFIG_INCLUDE_LOGGING - { __x86_64_inventec_d6356_config_STRINGIFY_NAME(x86_64_inventec_d6356_CONFIG_INCLUDE_LOGGING), __x86_64_inventec_d6356_config_STRINGIFY_VALUE(x86_64_inventec_d6356_CONFIG_INCLUDE_LOGGING) }, -#else -{ x86_64_inventec_d6356_CONFIG_INCLUDE_LOGGING(__x86_64_inventec_d6356_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef x86_64_inventec_d6356_CONFIG_LOG_OPTIONS_DEFAULT - { __x86_64_inventec_d6356_config_STRINGIFY_NAME(x86_64_inventec_d6356_CONFIG_LOG_OPTIONS_DEFAULT), __x86_64_inventec_d6356_config_STRINGIFY_VALUE(x86_64_inventec_d6356_CONFIG_LOG_OPTIONS_DEFAULT) }, -#else -{ x86_64_inventec_d6356_CONFIG_LOG_OPTIONS_DEFAULT(__x86_64_inventec_d6356_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef x86_64_inventec_d6356_CONFIG_LOG_BITS_DEFAULT - { __x86_64_inventec_d6356_config_STRINGIFY_NAME(x86_64_inventec_d6356_CONFIG_LOG_BITS_DEFAULT), __x86_64_inventec_d6356_config_STRINGIFY_VALUE(x86_64_inventec_d6356_CONFIG_LOG_BITS_DEFAULT) }, -#else -{ x86_64_inventec_d6356_CONFIG_LOG_BITS_DEFAULT(__x86_64_inventec_d6356_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef x86_64_inventec_d6356_CONFIG_LOG_CUSTOM_BITS_DEFAULT - { __x86_64_inventec_d6356_config_STRINGIFY_NAME(x86_64_inventec_d6356_CONFIG_LOG_CUSTOM_BITS_DEFAULT), __x86_64_inventec_d6356_config_STRINGIFY_VALUE(x86_64_inventec_d6356_CONFIG_LOG_CUSTOM_BITS_DEFAULT) }, -#else -{ x86_64_inventec_d6356_CONFIG_LOG_CUSTOM_BITS_DEFAULT(__x86_64_inventec_d6356_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef x86_64_inventec_d6356_CONFIG_PORTING_STDLIB - { __x86_64_inventec_d6356_config_STRINGIFY_NAME(x86_64_inventec_d6356_CONFIG_PORTING_STDLIB), __x86_64_inventec_d6356_config_STRINGIFY_VALUE(x86_64_inventec_d6356_CONFIG_PORTING_STDLIB) }, -#else -{ x86_64_inventec_d6356_CONFIG_PORTING_STDLIB(__x86_64_inventec_d6356_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef x86_64_inventec_d6356_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS - { __x86_64_inventec_d6356_config_STRINGIFY_NAME(x86_64_inventec_d6356_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS), __x86_64_inventec_d6356_config_STRINGIFY_VALUE(x86_64_inventec_d6356_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS) }, -#else -{ x86_64_inventec_d6356_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS(__x86_64_inventec_d6356_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef x86_64_inventec_d6356_CONFIG_INCLUDE_UCLI - { __x86_64_inventec_d6356_config_STRINGIFY_NAME(x86_64_inventec_d6356_CONFIG_INCLUDE_UCLI), __x86_64_inventec_d6356_config_STRINGIFY_VALUE(x86_64_inventec_d6356_CONFIG_INCLUDE_UCLI) }, -#else -{ x86_64_inventec_d6356_CONFIG_INCLUDE_UCLI(__x86_64_inventec_d6356_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef x86_64_inventec_d6356_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION - { __x86_64_inventec_d6356_config_STRINGIFY_NAME(x86_64_inventec_d6356_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION), __x86_64_inventec_d6356_config_STRINGIFY_VALUE(x86_64_inventec_d6356_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION) }, -#else -{ x86_64_inventec_d6356_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION(__x86_64_inventec_d6356_config_STRINGIFY_NAME), "__undefined__" }, -#endif - { NULL, NULL } -}; -#undef __x86_64_inventec_d6356_config_STRINGIFY_VALUE -#undef __x86_64_inventec_d6356_config_STRINGIFY_NAME - -const char* -x86_64_inventec_d6356_config_lookup(const char* setting) -{ - int i; - for(i = 0; x86_64_inventec_d6356_config_settings[i].name; i++) { - if(strcmp(x86_64_inventec_d6356_config_settings[i].name, setting)) { - return x86_64_inventec_d6356_config_settings[i].value; - } - } - return NULL; -} - -int -x86_64_inventec_d6356_config_show(struct aim_pvs_s* pvs) -{ - int i; - for(i = 0; x86_64_inventec_d6356_config_settings[i].name; i++) { - aim_printf(pvs, "%s = %s\n", x86_64_inventec_d6356_config_settings[i].name, x86_64_inventec_d6356_config_settings[i].value); - } - return i; -} - -/* */ - diff --git a/packages/platforms/inventec/x86-64/d6356/onlp/builds/x86_64_inventec_d6356/module/src/x86_64_inventec_d6356_enums.c b/packages/platforms/inventec/x86-64/d6356/onlp/builds/x86_64_inventec_d6356/module/src/x86_64_inventec_d6356_enums.c deleted file mode 100644 index bd1022461..000000000 --- a/packages/platforms/inventec/x86-64/d6356/onlp/builds/x86_64_inventec_d6356/module/src/x86_64_inventec_d6356_enums.c +++ /dev/null @@ -1,10 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#include - -/* <--auto.start.enum(ALL).source> */ -/* */ - diff --git a/packages/platforms/inventec/x86-64/d6356/onlp/builds/x86_64_inventec_d6356/module/src/x86_64_inventec_d6356_int.h b/packages/platforms/inventec/x86-64/d6356/onlp/builds/x86_64_inventec_d6356/module/src/x86_64_inventec_d6356_int.h deleted file mode 100644 index 5a3865201..000000000 --- a/packages/platforms/inventec/x86-64/d6356/onlp/builds/x86_64_inventec_d6356/module/src/x86_64_inventec_d6356_int.h +++ /dev/null @@ -1,12 +0,0 @@ -/**************************************************************************//** - * - * x86_64_inventec_d6356 Internal Header - * - *****************************************************************************/ -#ifndef __x86_64_inventec_d6356_INT_H__ -#define __x86_64_inventec_d6356_INT_H__ - -#include - - -#endif /* __x86_64_inventec_d6356_INT_H__ */ diff --git a/packages/platforms/inventec/x86-64/d6356/onlp/builds/x86_64_inventec_d6356/module/src/x86_64_inventec_d6356_log.c b/packages/platforms/inventec/x86-64/d6356/onlp/builds/x86_64_inventec_d6356/module/src/x86_64_inventec_d6356_log.c deleted file mode 100644 index 18cb647c9..000000000 --- a/packages/platforms/inventec/x86-64/d6356/onlp/builds/x86_64_inventec_d6356/module/src/x86_64_inventec_d6356_log.c +++ /dev/null @@ -1,18 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#include - -#include "x86_64_inventec_d6356_log.h" -/* - * x86_64_inventec_d6356 log struct. - */ -AIM_LOG_STRUCT_DEFINE( - x86_64_inventec_d6356_CONFIG_LOG_OPTIONS_DEFAULT, - x86_64_inventec_d6356_CONFIG_LOG_BITS_DEFAULT, - NULL, /* Custom log map */ - x86_64_inventec_d6356_CONFIG_LOG_CUSTOM_BITS_DEFAULT - ); - diff --git a/packages/platforms/inventec/x86-64/d6356/onlp/builds/x86_64_inventec_d6356/module/src/x86_64_inventec_d6356_log.h b/packages/platforms/inventec/x86-64/d6356/onlp/builds/x86_64_inventec_d6356/module/src/x86_64_inventec_d6356_log.h deleted file mode 100644 index e3eeb4f9a..000000000 --- a/packages/platforms/inventec/x86-64/d6356/onlp/builds/x86_64_inventec_d6356/module/src/x86_64_inventec_d6356_log.h +++ /dev/null @@ -1,12 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#ifndef __x86_64_inventec_d6356_LOG_H__ -#define __x86_64_inventec_d6356_LOG_H__ - -#define AIM_LOG_MODULE_NAME x86_64_inventec_d6356 -#include - -#endif /* __x86_64_inventec_d6356_LOG_H__ */ diff --git a/packages/platforms/inventec/x86-64/d6356/onlp/builds/x86_64_inventec_d6356/module/src/x86_64_inventec_d6356_module.c b/packages/platforms/inventec/x86-64/d6356/onlp/builds/x86_64_inventec_d6356/module/src/x86_64_inventec_d6356_module.c deleted file mode 100644 index c61cc8f5c..000000000 --- a/packages/platforms/inventec/x86-64/d6356/onlp/builds/x86_64_inventec_d6356/module/src/x86_64_inventec_d6356_module.c +++ /dev/null @@ -1,24 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#include - -#include "x86_64_inventec_d6356_log.h" - -static int -datatypes_init__(void) -{ -#define x86_64_inventec_d6356_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_d6356_module_init__(void) -{ - AIM_LOG_STRUCT_REGISTER(); - datatypes_init__(); -} - -int __onlp_platform_version__ = 1; diff --git a/packages/platforms/inventec/x86-64/d6356/onlp/builds/x86_64_inventec_d6356/module/src/x86_64_inventec_d6356_ucli.c b/packages/platforms/inventec/x86-64/d6356/onlp/builds/x86_64_inventec_d6356/module/src/x86_64_inventec_d6356_ucli.c deleted file mode 100644 index ab403bbb0..000000000 --- a/packages/platforms/inventec/x86-64/d6356/onlp/builds/x86_64_inventec_d6356/module/src/x86_64_inventec_d6356_ucli.c +++ /dev/null @@ -1,50 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#include - -#if x86_64_inventec_d6356_CONFIG_INCLUDE_UCLI == 1 - -#include -#include -#include - -static ucli_status_t -x86_64_inventec_d6356_ucli_ucli__config__(ucli_context_t* uc) -{ - UCLI_HANDLER_MACRO_MODULE_CONFIG(x86_64_inventec_d6356) -} - -/* */ -/* */ - -static ucli_module_t -x86_64_inventec_d6356_ucli_module__ = - { - "x86_64_inventec_d6356_ucli", - NULL, - x86_64_inventec_d6356_ucli_ucli_handlers__, - NULL, - NULL, - }; - -ucli_node_t* -x86_64_inventec_d6356_ucli_node_create(void) -{ - ucli_node_t* n; - ucli_module_init(&x86_64_inventec_d6356_ucli_module__); - n = ucli_node_create("x86_64_inventec_d6356", NULL, &x86_64_inventec_d6356_ucli_module__); - ucli_node_subnode_add(n, ucli_module_log_node_create("x86_64_inventec_d6356")); - return n; -} - -#else -void* -x86_64_inventec_d6356_ucli_node_create(void) -{ - return NULL; -} -#endif - diff --git a/packages/platforms/inventec/x86-64/d6356/platform-config/Makefile b/packages/platforms/inventec/x86-64/d6356/platform-config/Makefile deleted file mode 100644 index 003238cf6..000000000 --- a/packages/platforms/inventec/x86-64/d6356/platform-config/Makefile +++ /dev/null @@ -1 +0,0 @@ -include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/inventec/x86-64/d6356/platform-config/r0/Makefile b/packages/platforms/inventec/x86-64/d6356/platform-config/r0/Makefile deleted file mode 100644 index 003238cf6..000000000 --- a/packages/platforms/inventec/x86-64/d6356/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/inventec/x86-64/d6356/platform-config/r0/PKG.yml b/packages/platforms/inventec/x86-64/d6356/platform-config/r0/PKG.yml deleted file mode 100644 index f213960bc..000000000 --- a/packages/platforms/inventec/x86-64/d6356/platform-config/r0/PKG.yml +++ /dev/null @@ -1 +0,0 @@ -!include $ONL_TEMPLATES/platform-config-platform.yml ARCH=amd64 VENDOR=inventec BASENAME=x86-64-inventec-d6356 REVISION=r0 diff --git a/packages/platforms/inventec/x86-64/d6356/platform-config/r0/src/lib/x86-64-inventec-d6356-r0.yml b/packages/platforms/inventec/x86-64/d6356/platform-config/r0/src/lib/x86-64-inventec-d6356-r0.yml deleted file mode 100644 index 7fc2f95b8..000000000 --- a/packages/platforms/inventec/x86-64/d6356/platform-config/r0/src/lib/x86-64-inventec-d6356-r0.yml +++ /dev/null @@ -1,31 +0,0 @@ ---- - -###################################################################### -# -# platform-config for d6356 -# -###################################################################### - -x86-64-inventec-d6356-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/d6356/platform-config/r0/src/python/x86_64_inventec_d6356_r0/__init__.py b/packages/platforms/inventec/x86-64/d6356/platform-config/r0/src/python/x86_64_inventec_d6356_r0/__init__.py deleted file mode 100644 index 5fb468992..000000000 --- a/packages/platforms/inventec/x86-64/d6356/platform-config/r0/src/python/x86_64_inventec_d6356_r0/__init__.py +++ /dev/null @@ -1,24 +0,0 @@ -from onl.platform.base import * -from onl.platform.inventec import * - -class OnlPlatform_x86_64_inventec_d6356_r0(OnlPlatformInventec, - OnlPlatformPortConfig_48x25_8x100): - PLATFORM='x86-64-inventec-d6356-r0' - MODEL="D6356" - SYS_OBJECT_ID=".6356.1" - - def baseconfig(self): - os.system("rmmod gpio_ich") - self.insmod('i2c-gpio') - os.system("insmod /lib/modules/`uname -r`/kernel/drivers/gpio/gpio-ich.ko gpiobase=0") - self.insmod('ucd9000') - self.insmod('inv-i2c-mux-pca9641') - self.insmod('inv_platform') - self.insmod('inv_cpld') - self.insmod('swps') - self.new_i2c_device('inv_eeprom', 0x55, 2) - os.system("insmod /lib/modules/`uname -r`/onl/inventec/common/inv_eeprom.ko") - - #self.insmod('vpd') - #self.insmod('inv_pthread') - return True diff --git a/packages/platforms/inventec/x86-64/d6432/.gitignore b/packages/platforms/inventec/x86-64/d6432/.gitignore deleted file mode 100644 index 0e30b9857..000000000 --- a/packages/platforms/inventec/x86-64/d6432/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -*x86*64*inventec*d6432*.mk -onlpdump.mk diff --git a/packages/platforms/inventec/x86-64/d6432/Makefile b/packages/platforms/inventec/x86-64/d6432/Makefile deleted file mode 100644 index 003238cf6..000000000 --- a/packages/platforms/inventec/x86-64/d6432/Makefile +++ /dev/null @@ -1 +0,0 @@ -include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/inventec/x86-64/d6432/modules/Makefile b/packages/platforms/inventec/x86-64/d6432/modules/Makefile deleted file mode 100644 index 003238cf6..000000000 --- a/packages/platforms/inventec/x86-64/d6432/modules/Makefile +++ /dev/null @@ -1 +0,0 @@ -include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/inventec/x86-64/d6432/modules/PKG.yml b/packages/platforms/inventec/x86-64/d6432/modules/PKG.yml deleted file mode 100644 index 5f8887bec..000000000 --- a/packages/platforms/inventec/x86-64/d6432/modules/PKG.yml +++ /dev/null @@ -1 +0,0 @@ -!include $ONL_TEMPLATES/platform-modules.yml VENDOR=inventec BASENAME=x86-64-inventec-d6432 ARCH=amd64 KERNELS="onl-kernel-4.14-lts-x86-64-all:amd64" diff --git a/packages/platforms/inventec/x86-64/d6432/modules/builds/.gitignore b/packages/platforms/inventec/x86-64/d6432/modules/builds/.gitignore deleted file mode 100644 index 7951405f8..000000000 --- a/packages/platforms/inventec/x86-64/d6432/modules/builds/.gitignore +++ /dev/null @@ -1 +0,0 @@ -lib \ No newline at end of file diff --git a/packages/platforms/inventec/x86-64/d6432/modules/builds/Makefile b/packages/platforms/inventec/x86-64/d6432/modules/builds/Makefile deleted file mode 100644 index 2464d24af..000000000 --- a/packages/platforms/inventec/x86-64/d6432/modules/builds/Makefile +++ /dev/null @@ -1,6 +0,0 @@ -KERNELS := onl-kernel-4.14-lts-x86-64-all:amd64 -KMODULES := src -VENDOR := inventec -BASENAME := x86-64-inventec-d6432 -ARCH := x86_64 -include $(ONL)/make/kmodule.mk diff --git a/packages/platforms/inventec/x86-64/d6432/modules/builds/src b/packages/platforms/inventec/x86-64/d6432/modules/builds/src deleted file mode 120000 index 882118c56..000000000 --- a/packages/platforms/inventec/x86-64/d6432/modules/builds/src +++ /dev/null @@ -1 +0,0 @@ -../../../d7332/modules/builds/src/ \ No newline at end of file diff --git a/packages/platforms/inventec/x86-64/d6432/onlp/Makefile b/packages/platforms/inventec/x86-64/d6432/onlp/Makefile deleted file mode 100644 index 003238cf6..000000000 --- a/packages/platforms/inventec/x86-64/d6432/onlp/Makefile +++ /dev/null @@ -1 +0,0 @@ -include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/inventec/x86-64/d6432/onlp/PKG.yml b/packages/platforms/inventec/x86-64/d6432/onlp/PKG.yml deleted file mode 100644 index 28e76e656..000000000 --- a/packages/platforms/inventec/x86-64/d6432/onlp/PKG.yml +++ /dev/null @@ -1 +0,0 @@ -!include $ONL_TEMPLATES/onlp-platform-any.yml PLATFORM=x86-64-inventec-d6432 ARCH=amd64 TOOLCHAIN=x86_64-linux-gnu diff --git a/packages/platforms/inventec/x86-64/d6432/onlp/builds/Makefile b/packages/platforms/inventec/x86-64/d6432/onlp/builds/Makefile deleted file mode 100644 index e7437cb23..000000000 --- a/packages/platforms/inventec/x86-64/d6432/onlp/builds/Makefile +++ /dev/null @@ -1,2 +0,0 @@ -FILTER=src -include $(ONL)/make/subdirs.mk diff --git a/packages/platforms/inventec/x86-64/d6432/onlp/builds/lib/Makefile b/packages/platforms/inventec/x86-64/d6432/onlp/builds/lib/Makefile deleted file mode 100644 index 766c5458d..000000000 --- a/packages/platforms/inventec/x86-64/d6432/onlp/builds/lib/Makefile +++ /dev/null @@ -1,2 +0,0 @@ -PLATFORM := x86-64-inventec-d6432 -include $(ONL)/packages/base/any/onlp/builds/platform/libonlp-platform.mk diff --git a/packages/platforms/inventec/x86-64/d6432/onlp/builds/onlpdump/Makefile b/packages/platforms/inventec/x86-64/d6432/onlp/builds/onlpdump/Makefile deleted file mode 100644 index 91830e43d..000000000 --- a/packages/platforms/inventec/x86-64/d6432/onlp/builds/onlpdump/Makefile +++ /dev/null @@ -1,2 +0,0 @@ -PLATFORM := x86-64-inventec-d6432 -include $(ONL)/packages/base/any/onlp/builds/platform/onlps.mk diff --git a/packages/platforms/inventec/x86-64/d6432/onlp/builds/x86_64_inventec_d6432/.module b/packages/platforms/inventec/x86-64/d6432/onlp/builds/x86_64_inventec_d6432/.module deleted file mode 100644 index c7e01fed0..000000000 --- a/packages/platforms/inventec/x86-64/d6432/onlp/builds/x86_64_inventec_d6432/.module +++ /dev/null @@ -1 +0,0 @@ -name: x86_64_inventec_d6432 diff --git a/packages/platforms/inventec/x86-64/d6432/onlp/builds/x86_64_inventec_d6432/Makefile b/packages/platforms/inventec/x86-64/d6432/onlp/builds/x86_64_inventec_d6432/Makefile deleted file mode 100644 index bd10ae459..000000000 --- a/packages/platforms/inventec/x86-64/d6432/onlp/builds/x86_64_inventec_d6432/Makefile +++ /dev/null @@ -1,9 +0,0 @@ -############################################################################### -# -# -# -############################################################################### -include $(ONL)/make/config.mk -MODULE := x86_64_inventec_d6432 -AUTOMODULE := x86_64_inventec_d6432 -include $(BUILDER)/definemodule.mk diff --git a/packages/platforms/inventec/x86-64/d6432/onlp/builds/x86_64_inventec_d6432/module/auto/make.mk b/packages/platforms/inventec/x86-64/d6432/onlp/builds/x86_64_inventec_d6432/module/auto/make.mk deleted file mode 100644 index c77c91a53..000000000 --- a/packages/platforms/inventec/x86-64/d6432/onlp/builds/x86_64_inventec_d6432/module/auto/make.mk +++ /dev/null @@ -1,9 +0,0 @@ -############################################################################### -# -# x86_64_inventec_d6432 Autogeneration -# -############################################################################### -x86_64_inventec_d6432_AUTO_DEFS := module/auto/x86_64_inventec_d6432.yml -x86_64_inventec_d6432_AUTO_DIRS := module/inc/x86_64_inventec_d6432 module/src -include $(BUILDER)/auto.mk - diff --git a/packages/platforms/inventec/x86-64/d6432/onlp/builds/x86_64_inventec_d6432/module/auto/x86_64_inventec_d6432.yml b/packages/platforms/inventec/x86-64/d6432/onlp/builds/x86_64_inventec_d6432/module/auto/x86_64_inventec_d6432.yml deleted file mode 100644 index d6248f677..000000000 --- a/packages/platforms/inventec/x86-64/d6432/onlp/builds/x86_64_inventec_d6432/module/auto/x86_64_inventec_d6432.yml +++ /dev/null @@ -1,50 +0,0 @@ -############################################################################### -# -# x86_64_inventec_d6432 Autogeneration Definitions. -# -############################################################################### - -cdefs: &cdefs -- X86_64_INVENTEC_D6432_CONFIG_INCLUDE_LOGGING: - doc: "Include or exclude logging." - default: 1 -- X86_64_INVENTEC_D6432_CONFIG_LOG_OPTIONS_DEFAULT: - doc: "Default enabled log options." - default: AIM_LOG_OPTIONS_DEFAULT -- X86_64_INVENTEC_D6432_CONFIG_LOG_BITS_DEFAULT: - doc: "Default enabled log bits." - default: AIM_LOG_BITS_DEFAULT -- X86_64_INVENTEC_D6432_CONFIG_LOG_CUSTOM_BITS_DEFAULT: - doc: "Default enabled custom log bits." - default: 0 -- X86_64_INVENTEC_D6432_CONFIG_PORTING_STDLIB: - doc: "Default all porting macros to use the C standard libraries." - default: 1 -- X86_64_INVENTEC_D6432_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS: - doc: "Include standard library headers for stdlib porting macros." - default: X86_64_INVENTEC_D6432_CONFIG_PORTING_STDLIB -- X86_64_INVENTEC_D6432_CONFIG_INCLUDE_UCLI: - doc: "Include generic uCli support." - default: 0 -- X86_64_INVENTEC_D6432_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_D6432_CONFIG_HEADER: - defs: *cdefs - basename: x86_64_inventec_d6432_config - - portingmacro: - X86_64_INVENTEC_D6432: - macros: - - malloc - - free - - memset - - memcpy - - strncpy - - vsnprintf - - snprintf - - strlen diff --git a/packages/platforms/inventec/x86-64/d6432/onlp/builds/x86_64_inventec_d6432/module/inc/x86_64_inventec_d6432/x86_64_inventec_d6432.x b/packages/platforms/inventec/x86-64/d6432/onlp/builds/x86_64_inventec_d6432/module/inc/x86_64_inventec_d6432/x86_64_inventec_d6432.x deleted file mode 100644 index c2180792c..000000000 --- a/packages/platforms/inventec/x86-64/d6432/onlp/builds/x86_64_inventec_d6432/module/inc/x86_64_inventec_d6432/x86_64_inventec_d6432.x +++ /dev/null @@ -1,14 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#include - -/* <--auto.start.xmacro(ALL).define> */ -/* */ - -/* <--auto.start.xenum(ALL).define> */ -/* */ - - diff --git a/packages/platforms/inventec/x86-64/d6432/onlp/builds/x86_64_inventec_d6432/module/inc/x86_64_inventec_d6432/x86_64_inventec_d6432_config.h b/packages/platforms/inventec/x86-64/d6432/onlp/builds/x86_64_inventec_d6432/module/inc/x86_64_inventec_d6432/x86_64_inventec_d6432_config.h deleted file mode 100644 index 1d295adfe..000000000 --- a/packages/platforms/inventec/x86-64/d6432/onlp/builds/x86_64_inventec_d6432/module/inc/x86_64_inventec_d6432/x86_64_inventec_d6432_config.h +++ /dev/null @@ -1,137 +0,0 @@ -/**************************************************************************//** - * - * @file - * @brief x86_64_inventec_d6432 Configuration Header - * - * @addtogroup x86_64_inventec_d6432-config - * @{ - * - *****************************************************************************/ -#ifndef __x86_64_inventec_d6432_CONFIG_H__ -#define __x86_64_inventec_d6432_CONFIG_H__ - -#ifdef GLOBAL_INCLUDE_CUSTOM_CONFIG -#include -#endif -#ifdef x86_64_inventec_d6432_INCLUDE_CUSTOM_CONFIG -#include -#endif - -/* */ -#include -/** - * x86_64_inventec_d6432_CONFIG_INCLUDE_LOGGING - * - * Include or exclude logging. */ - - -#ifndef x86_64_inventec_d6432_CONFIG_INCLUDE_LOGGING -#define x86_64_inventec_d6432_CONFIG_INCLUDE_LOGGING 1 -#endif - -/** - * x86_64_inventec_d6432_CONFIG_LOG_OPTIONS_DEFAULT - * - * Default enabled log options. */ - - -#ifndef x86_64_inventec_d6432_CONFIG_LOG_OPTIONS_DEFAULT -#define x86_64_inventec_d6432_CONFIG_LOG_OPTIONS_DEFAULT AIM_LOG_OPTIONS_DEFAULT -#endif - -/** - * x86_64_inventec_d6432_CONFIG_LOG_BITS_DEFAULT - * - * Default enabled log bits. */ - - -#ifndef x86_64_inventec_d6432_CONFIG_LOG_BITS_DEFAULT -#define x86_64_inventec_d6432_CONFIG_LOG_BITS_DEFAULT AIM_LOG_BITS_DEFAULT -#endif - -/** - * x86_64_inventec_d6432_CONFIG_LOG_CUSTOM_BITS_DEFAULT - * - * Default enabled custom log bits. */ - - -#ifndef x86_64_inventec_d6432_CONFIG_LOG_CUSTOM_BITS_DEFAULT -#define x86_64_inventec_d6432_CONFIG_LOG_CUSTOM_BITS_DEFAULT 0 -#endif - -/** - * x86_64_inventec_d6432_CONFIG_PORTING_STDLIB - * - * Default all porting macros to use the C standard libraries. */ - - -#ifndef x86_64_inventec_d6432_CONFIG_PORTING_STDLIB -#define x86_64_inventec_d6432_CONFIG_PORTING_STDLIB 1 -#endif - -/** - * x86_64_inventec_d6432_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS - * - * Include standard library headers for stdlib porting macros. */ - - -#ifndef x86_64_inventec_d6432_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS -#define x86_64_inventec_d6432_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS x86_64_inventec_d6432_CONFIG_PORTING_STDLIB -#endif - -/** - * x86_64_inventec_d6432_CONFIG_INCLUDE_UCLI - * - * Include generic uCli support. */ - - -#ifndef x86_64_inventec_d6432_CONFIG_INCLUDE_UCLI -#define x86_64_inventec_d6432_CONFIG_INCLUDE_UCLI 0 -#endif - -/** - * x86_64_inventec_d6432_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION - * - * Assume chassis fan direction is the same as the PSU fan direction. */ - - -#ifndef x86_64_inventec_d6432_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION -#define x86_64_inventec_d6432_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION 0 -#endif - - - -/** - * All compile time options can be queried or displayed - */ - -/** Configuration settings structure. */ -typedef struct x86_64_inventec_d6432_config_settings_s { - /** name */ - const char* name; - /** value */ - const char* value; -} x86_64_inventec_d6432_config_settings_t; - -/** Configuration settings table. */ -/** x86_64_inventec_d6432_config_settings table. */ -extern x86_64_inventec_d6432_config_settings_t x86_64_inventec_d6432_config_settings[]; - -/** - * @brief Lookup a configuration setting. - * @param setting The name of the configuration option to lookup. - */ -const char* x86_64_inventec_d6432_config_lookup(const char* setting); - -/** - * @brief Show the compile-time configuration. - * @param pvs The output stream. - */ -int x86_64_inventec_d6432_config_show(struct aim_pvs_s* pvs); - -/* */ - -#include "x86_64_inventec_d6432_porting.h" - -#endif /* __x86_64_inventec_d6432_CONFIG_H__ */ -/* @} */ diff --git a/packages/platforms/inventec/x86-64/d6432/onlp/builds/x86_64_inventec_d6432/module/inc/x86_64_inventec_d6432/x86_64_inventec_d6432_dox.h b/packages/platforms/inventec/x86-64/d6432/onlp/builds/x86_64_inventec_d6432/module/inc/x86_64_inventec_d6432/x86_64_inventec_d6432_dox.h deleted file mode 100644 index 31e0cf499..000000000 --- a/packages/platforms/inventec/x86-64/d6432/onlp/builds/x86_64_inventec_d6432/module/inc/x86_64_inventec_d6432/x86_64_inventec_d6432_dox.h +++ /dev/null @@ -1,26 +0,0 @@ -/**************************************************************************//** - * - * x86_64_inventec_d6432 Doxygen Header - * - *****************************************************************************/ -#ifndef __x86_64_inventec_d6432_DOX_H__ -#define __x86_64_inventec_d6432_DOX_H__ - -/** - * @defgroup x86_64_inventec_d6432 x86_64_inventec_d6432 - x86_64_inventec_d6432 Description - * - -The documentation overview for this module should go here. - - * - * @{ - * - * @defgroup x86_64_inventec_d6432-x86_64_inventec_d6432 Public Interface - * @defgroup x86_64_inventec_d6432-config Compile Time Configuration - * @defgroup x86_64_inventec_d6432-porting Porting Macros - * - * @} - * - */ - -#endif /* __x86_64_inventec_d6432_DOX_H__ */ diff --git a/packages/platforms/inventec/x86-64/d6432/onlp/builds/x86_64_inventec_d6432/module/inc/x86_64_inventec_d6432/x86_64_inventec_d6432_porting.h b/packages/platforms/inventec/x86-64/d6432/onlp/builds/x86_64_inventec_d6432/module/inc/x86_64_inventec_d6432/x86_64_inventec_d6432_porting.h deleted file mode 100644 index 0d1665ea1..000000000 --- a/packages/platforms/inventec/x86-64/d6432/onlp/builds/x86_64_inventec_d6432/module/inc/x86_64_inventec_d6432/x86_64_inventec_d6432_porting.h +++ /dev/null @@ -1,107 +0,0 @@ -/**************************************************************************//** - * - * @file - * @brief x86_64_inventec_d6432 Porting Macros. - * - * @addtogroup x86_64_inventec_d6432-porting - * @{ - * - *****************************************************************************/ -#ifndef __x86_64_inventec_d6432_PORTING_H__ -#define __x86_64_inventec_d6432_PORTING_H__ - - -/* */ -#if x86_64_inventec_d6432_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS == 1 -#include -#include -#include -#include -#include -#endif - -#ifndef x86_64_inventec_d6432_MALLOC - #if defined(GLOBAL_MALLOC) - #define x86_64_inventec_d6432_MALLOC GLOBAL_MALLOC - #elif x86_64_inventec_d6432_CONFIG_PORTING_STDLIB == 1 - #define x86_64_inventec_d6432_MALLOC malloc - #else - #error The macro x86_64_inventec_d6432_MALLOC is required but cannot be defined. - #endif -#endif - -#ifndef x86_64_inventec_d6432_FREE - #if defined(GLOBAL_FREE) - #define x86_64_inventec_d6432_FREE GLOBAL_FREE - #elif x86_64_inventec_d6432_CONFIG_PORTING_STDLIB == 1 - #define x86_64_inventec_d6432_FREE free - #else - #error The macro x86_64_inventec_d6432_FREE is required but cannot be defined. - #endif -#endif - -#ifndef x86_64_inventec_d6432_MEMSET - #if defined(GLOBAL_MEMSET) - #define x86_64_inventec_d6432_MEMSET GLOBAL_MEMSET - #elif x86_64_inventec_d6432_CONFIG_PORTING_STDLIB == 1 - #define x86_64_inventec_d6432_MEMSET memset - #else - #error The macro x86_64_inventec_d6432_MEMSET is required but cannot be defined. - #endif -#endif - -#ifndef x86_64_inventec_d6432_MEMCPY - #if defined(GLOBAL_MEMCPY) - #define x86_64_inventec_d6432_MEMCPY GLOBAL_MEMCPY - #elif x86_64_inventec_d6432_CONFIG_PORTING_STDLIB == 1 - #define x86_64_inventec_d6432_MEMCPY memcpy - #else - #error The macro x86_64_inventec_d6432_MEMCPY is required but cannot be defined. - #endif -#endif - -#ifndef x86_64_inventec_d6432_STRNCPY - #if defined(GLOBAL_STRNCPY) - #define x86_64_inventec_d6432_STRNCPY GLOBAL_STRNCPY - #elif x86_64_inventec_d6432_CONFIG_PORTING_STDLIB == 1 - #define x86_64_inventec_d6432_STRNCPY strncpy - #else - #error The macro x86_64_inventec_d6432_STRNCPY is required but cannot be defined. - #endif -#endif - -#ifndef x86_64_inventec_d6432_VSNPRINTF - #if defined(GLOBAL_VSNPRINTF) - #define x86_64_inventec_d6432_VSNPRINTF GLOBAL_VSNPRINTF - #elif x86_64_inventec_d6432_CONFIG_PORTING_STDLIB == 1 - #define x86_64_inventec_d6432_VSNPRINTF vsnprintf - #else - #error The macro x86_64_inventec_d6432_VSNPRINTF is required but cannot be defined. - #endif -#endif - -#ifndef x86_64_inventec_d6432_SNPRINTF - #if defined(GLOBAL_SNPRINTF) - #define x86_64_inventec_d6432_SNPRINTF GLOBAL_SNPRINTF - #elif x86_64_inventec_d6432_CONFIG_PORTING_STDLIB == 1 - #define x86_64_inventec_d6432_SNPRINTF snprintf - #else - #error The macro x86_64_inventec_d6432_SNPRINTF is required but cannot be defined. - #endif -#endif - -#ifndef x86_64_inventec_d6432_STRLEN - #if defined(GLOBAL_STRLEN) - #define x86_64_inventec_d6432_STRLEN GLOBAL_STRLEN - #elif x86_64_inventec_d6432_CONFIG_PORTING_STDLIB == 1 - #define x86_64_inventec_d6432_STRLEN strlen - #else - #error The macro x86_64_inventec_d6432_STRLEN is required but cannot be defined. - #endif -#endif - -/* */ - - -#endif /* __x86_64_inventec_d6432_PORTING_H__ */ -/* @} */ diff --git a/packages/platforms/inventec/x86-64/d6432/onlp/builds/x86_64_inventec_d6432/module/make.mk b/packages/platforms/inventec/x86-64/d6432/onlp/builds/x86_64_inventec_d6432/module/make.mk deleted file mode 100644 index 51f0227c9..000000000 --- a/packages/platforms/inventec/x86-64/d6432/onlp/builds/x86_64_inventec_d6432/module/make.mk +++ /dev/null @@ -1,10 +0,0 @@ -############################################################################### -# -# -# -############################################################################### -THIS_DIR := $(dir $(lastword $(MAKEFILE_LIST))) -x86_64_inventec_d6432_INCLUDES := -I $(THIS_DIR)inc -x86_64_inventec_d6432_INTERNAL_INCLUDES := -I $(THIS_DIR)src -x86_64_inventec_d6432_DEPENDMODULE_ENTRIES := init:x86_64_inventec_d6432 ucli:x86_64_inventec_d6432 -x86_64_inventec_d6432_BROKEN_CFLAGS += -Wno-restrict -Wno-format-truncation diff --git a/packages/platforms/inventec/x86-64/d6432/onlp/builds/x86_64_inventec_d6432/module/src/Makefile b/packages/platforms/inventec/x86-64/d6432/onlp/builds/x86_64_inventec_d6432/module/src/Makefile deleted file mode 100644 index 5c86557e9..000000000 --- a/packages/platforms/inventec/x86-64/d6432/onlp/builds/x86_64_inventec_d6432/module/src/Makefile +++ /dev/null @@ -1,9 +0,0 @@ -############################################################################### -# -# Local source generation targets. -# -############################################################################### - -ucli: - @../../../../tools/uclihandlers.py x86_64_inventec_d6432_ucli.c - diff --git a/packages/platforms/inventec/x86-64/d6432/onlp/builds/x86_64_inventec_d6432/module/src/fani.c b/packages/platforms/inventec/x86-64/d6432/onlp/builds/x86_64_inventec_d6432/module/src/fani.c deleted file mode 100644 index ed08dbe4c..000000000 --- a/packages/platforms/inventec/x86-64/d6432/onlp/builds/x86_64_inventec_d6432/module/src/fani.c +++ /dev/null @@ -1,498 +0,0 @@ -/************************************************************ - * fani.c - * - * Copyright 2018 Inventec Technology Corporation. - * - ************************************************************ - * - * Fan Platform Implementation Defaults. - * - ***********************************************************/ -#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) - -typedef enum hwmon_fan_state_e { - HWMON_FAN_F2B = 0, - HWMON_FAN_B2F = 1, - HWMON_FAN_UNPLUGGED = 2, - HWMON_FAN_UNPLUGGED2 = 3 -} hwmon_fan_state_t; - -#define SLOW_PWM 100 -#define NORMAL_PWM 175 -#define MAX_PWM 255 -#define STEP_SIZE 100 -#define FAN_ID_TO_PSU_ID(id) (id-ONLP_FAN_PSU_1+1) -#define BLADE_TO_FAN_ID(blade_id) (blade_id%2==0)? blade_id/2:(blade_id+1)/2 - -#define TLV_PRODUCT_INFO_OFFSET_IDX 5 -#define TLV_PRODUCT_INFO_AREA_START 3 -#define TLV_ATTR_TYPE_SERIAL 5 -#define TLV_ATTR_TYPE_MODEL 2 - -#define FAN_I2C_CHANNEL 3 -#define FAN_I2C_ADDR_BASE 52 - -#define FAN_CAPS ONLP_FAN_CAPS_GET_RPM|ONLP_FAN_CAPS_GET_PERCENTAGE - -static int _fani_status_failed_check(uint32_t* status, int fan_id); -static int _fani_status_present_check(uint32_t* status, int fan_id); -static int _inv_get_fan_fru(char* ret_str,int attr_type, int fan_id); -extern char* psu_i2c_addr[ONLP_PSU_MAX]; - -#define MAKE_FAN_INFO_NODE_ON_PSU(psu_id) \ - { \ - { ONLP_FAN_ID_CREATE(ONLP_FAN_PSU_##psu_id), "PSU-"#psu_id" Fan", ONLP_PSU_ID_CREATE(ONLP_PSU_##psu_id)}, \ - 0, FAN_CAPS \ - } - -/* Static values */ -static onlp_fan_info_t __onlp_fan_info[] = { - {}, - { { ONLP_FAN_1, "Fan1-1", 0, }, 0, FAN_CAPS }, - { { ONLP_FAN_2, "Fan1-2", 0, }, 0, FAN_CAPS }, - { { ONLP_FAN_3, "Fan2-1", 0, }, 0, FAN_CAPS }, - { { ONLP_FAN_4, "Fan2-2", 0, }, 0, FAN_CAPS }, - { { ONLP_FAN_5, "Fan3-1", 0, }, 0, FAN_CAPS }, - { { ONLP_FAN_6, "Fan3-2", 0, }, 0, FAN_CAPS }, - { { ONLP_FAN_7, "Fan4-1", 0, }, 0, FAN_CAPS }, - { { ONLP_FAN_8, "Fan4-2", 0, }, 0, FAN_CAPS }, - { { ONLP_FAN_9, "Fan5-1", 0, }, 0, FAN_CAPS }, - { { ONLP_FAN_10, "Fan5-2", 0, }, 0, FAN_CAPS }, - { { ONLP_FAN_11, "Fan6-1", 0, }, 0, FAN_CAPS }, - { { ONLP_FAN_12, "Fan6-2", 0, }, 0, FAN_CAPS }, - MAKE_FAN_INFO_NODE_ON_PSU(1), - MAKE_FAN_INFO_NODE_ON_PSU(2), -}; - - -/* - * This function will be called prior to all of onlp_fani_* functions. - */ -int -onlp_fani_init(void) -{ - return ONLP_STATUS_OK; -} - -static int _inv_get_fan_fru(char* ret_str,int attr_type, int fan_id) -{ - int ret=ONLP_STATUS_OK; - uint8_t* rdata; - char file_path[ONLP_CONFIG_INFO_STR_MAX]; - char s; - int rdata_size=0,target_offset=0,attr_idx=0,attr_length=0; - int i=0; - int offset=BLADE_TO_FAN_ID(fan_id); - - snprintf(file_path,ONLP_CONFIG_INFO_STR_MAX,"%s%d-00%d/eeprom",INV_DEVICE_BASE,FAN_I2C_CHANNEL,(FAN_I2C_ADDR_BASE+offset-1) ); - - FILE* fp = fopen(file_path, "rb"); - if(fp){ - fseek(fp, 0L, SEEK_END); - rdata_size = ftell(fp); - rewind(fp); - rdata = aim_malloc(rdata_size); - fread(rdata, 1, rdata_size, fp); - fclose(fp); - }else{ - ret=ONLP_STATUS_E_INTERNAL; - } - - if(ret==ONLP_STATUS_OK) { - target_offset=rdata[TLV_PRODUCT_INFO_OFFSET_IDX-1]; - target_offset*=8; /*spec defined: offset are in multiples of 8 bytes*/ - attr_idx=target_offset+TLV_PRODUCT_INFO_AREA_START; - - for(i=1; irdata_size){ - ret=ONLP_STATUS_E_INTERNAL; - break; - } - attr_length=rdata[attr_idx]&(0x3F); /*spec defined: length are set in last 6 bits*/ - attr_idx+=(attr_length+1); - } - if(ret==ONLP_STATUS_OK){ - if(attr_length=ONLP_FAN_MAX) { - rv=ONLP_STATUS_E_INVALID; - } - if(rv==ONLP_STATUS_OK) { - *info=__onlp_fan_info[fan_id]; - rv=onlp_fani_status_get(id, &info->status); - } - if(rv == ONLP_STATUS_OK) { - if(info->status & ONLP_FAN_STATUS_PRESENT) { - switch(fan_id) { - case ONLP_FAN_1: - case ONLP_FAN_2: - case ONLP_FAN_3: - case ONLP_FAN_4: - case ONLP_FAN_5: - case ONLP_FAN_6: - case ONLP_FAN_7: - case ONLP_FAN_8: - case ONLP_FAN_9: - case ONLP_FAN_10: - case ONLP_FAN_11: - case ONLP_FAN_12: - if(info->status & ONLP_FAN_STATUS_F2B) { - info->caps = ADD_STATE(info->caps,ONLP_FAN_CAPS_F2B); - } else if(info->status & ONLP_FAN_STATUS_B2F) { - info->caps = ADD_STATE(info->caps,ONLP_FAN_CAPS_B2F) ; - } - - rv = onlp_file_read_int(&info->rpm, INV_FAN_PREFIX"fan%d_input", fan_id); - if(rv != ONLP_STATUS_OK ) { - return rv; - } - rv = onlp_file_read_int(&pwm,INV_FAN_PREFIX"pwm%d", BLADE_TO_FAN_ID(fan_id)); - if(rv != ONLP_STATUS_OK ) { - return rv; - } - - rv=_inv_get_fan_fru(info->serial,TLV_ATTR_TYPE_SERIAL,fan_id); - if(rv!=ONLP_STATUS_OK){ - snprintf(info->serial,ONLP_CONFIG_INFO_STR_MAX,"N/A"); - } - rv=_inv_get_fan_fru(info->model,TLV_ATTR_TYPE_MODEL,fan_id); - if(rv!=ONLP_STATUS_OK){ - snprintf(info->model,ONLP_CONFIG_INFO_STR_MAX,"N/A"); - } - - break; - case ONLP_FAN_PSU_1: - case ONLP_FAN_PSU_2: - info->caps = FAN_CAPS|ONLP_FAN_CAPS_F2B; - psu_id = FAN_ID_TO_PSU_ID(fan_id); - - snprintf(path,ONLP_CONFIG_INFO_STR_MAX,"%s%d-00%s/fan1_input",INV_DEVICE_BASE,PSU_I2C_CHAN,psu_i2c_addr[psu_id]); - rv = onlp_file_read_int(&info->rpm, path); - if(rv != ONLP_STATUS_OK) { - return rv; - } - snprintf(path,ONLP_CONFIG_INFO_STR_MAX,"%s%d-00%s/pwm1",INV_DEVICE_BASE,PSU_I2C_CHAN,psu_i2c_addr[psu_id]); - rv = onlp_file_read_int(&pwm, path); - if(rv != ONLP_STATUS_OK) { - return rv; - } - break; - default: - rv = ONLP_STATUS_E_INVALID; - break; - } - if(rv == ONLP_STATUS_OK) { - if(info->rpm <= 0) { - info->mode = ONLP_FAN_MODE_OFF; - info->percentage = 0; - } else { - info->percentage = (pwm*100)/MAX_PWM; - if(pwm < SLOW_PWM) { - info->mode = ONLP_FAN_MODE_SLOW; - } else if(pwm < NORMAL_PWM) { - info->mode = ONLP_FAN_MODE_NORMAL; - } else if(pwm < MAX_PWM) { - info->mode = ONLP_FAN_MODE_FAST; - } else { - info->mode = ONLP_FAN_MODE_MAX; - } - } - } - } else { - info->caps = 0; - info->rpm = 0; - info->percentage = 0; - info->mode = ONLP_FAN_MODE_OFF; - } - - } - return rv; -} -static int _fani_status_failed_check(uint32_t* status, int fan_id) -{ - int rv; - int rpm, pwm, psu_id; - char path[ONLP_CONFIG_INFO_STR_MAX]; - - switch(fan_id) { - case ONLP_FAN_1: - case ONLP_FAN_2: - case ONLP_FAN_3: - case ONLP_FAN_4: - case ONLP_FAN_5: - case ONLP_FAN_6: - case ONLP_FAN_7: - case ONLP_FAN_8: - case ONLP_FAN_9: - case ONLP_FAN_10: - case ONLP_FAN_11: - case ONLP_FAN_12: - rv = onlp_file_read_int(&rpm, INV_FAN_PREFIX"fan%d_input", fan_id); - - if(rv != ONLP_STATUS_OK ) { - return rv; - } - rv = onlp_file_read_int(&pwm,INV_FAN_PREFIX"pwm%d", BLADE_TO_FAN_ID(fan_id)); - if(rv != ONLP_STATUS_OK ) { - return rv; - } - - if(rpm<=0 || pwm<=0 || pwm > MAX_PWM) { - *status=ADD_STATE(*status,ONLP_FAN_STATUS_FAILED); - *status=REMOVE_STATE(*status,ONLP_FAN_STATUS_B2F); - *status=REMOVE_STATE(*status,ONLP_FAN_STATUS_F2B); - } else { - *status=REMOVE_STATE(*status,ONLP_FAN_STATUS_FAILED); - } - break; - case ONLP_FAN_PSU_1: - case ONLP_FAN_PSU_2: - psu_id = FAN_ID_TO_PSU_ID(fan_id); - - snprintf(path,ONLP_CONFIG_INFO_STR_MAX,"%s%d-00%s/fan1_input",INV_DEVICE_BASE,PSU_I2C_CHAN,psu_i2c_addr[psu_id]); - rv = onlp_file_read_int(&rpm, path); - if(rv != ONLP_STATUS_OK ) { - return rv; - } - snprintf(path,ONLP_CONFIG_INFO_STR_MAX,"%s%d-00%s/pwm1",INV_DEVICE_BASE,PSU_I2C_CHAN,psu_i2c_addr[psu_id]); - rv = onlp_file_read_int(&pwm, path); - if(rv != ONLP_STATUS_OK ) { - return rv; - } - - if( rpm <= 0 || pwm <=0 || pwm > MAX_PWM) { - *status=ADD_STATE(*status,ONLP_FAN_STATUS_FAILED); - *status=REMOVE_STATE(*status,ONLP_FAN_STATUS_B2F); - *status=REMOVE_STATE(*status,ONLP_FAN_STATUS_F2B); - } else { - *status=REMOVE_STATE(*status,ONLP_FAN_STATUS_FAILED); - } - break; - default: - rv = ONLP_STATUS_E_INVALID; - break; - } - return rv; -} - -static int _fani_status_present_check(uint32_t* status, int fan_id) -{ - int rv; - int len; - char buf[ONLP_CONFIG_INFO_STR_MAX]; - if(fan_id >= ONLP_FAN_1 && fan_id <= ONLP_FAN_12) { - rv = onlp_file_read((uint8_t*)buf,ONLP_CONFIG_INFO_STR_MAX, &len, INV_FAN_PREFIX"fanmodule%d_type",BLADE_TO_FAN_ID(fan_id)); - } else { - rv = ONLP_STATUS_E_INVALID; - } - if( rv == ONLP_STATUS_OK ) { - switch( (int)(buf[0]-'0') ){ - case HWMON_FAN_F2B: - *status=ADD_STATE(*status,ONLP_FAN_STATUS_PRESENT); - *status=ADD_STATE(*status,ONLP_FAN_STATUS_F2B); - break; - case HWMON_FAN_B2F: - *status=ADD_STATE(*status,ONLP_FAN_STATUS_PRESENT); - *status=ADD_STATE(*status,ONLP_FAN_STATUS_B2F); - break; - case HWMON_FAN_UNPLUGGED: - case HWMON_FAN_UNPLUGGED2: - *status=ADD_STATE(*status,ONLP_FAN_STATUS_FAILED); - break; - default: - rv = ONLP_STATUS_E_INVALID; - break; - } - } - return rv; -} - -/** - * @brief Retrieve the fan's operational status. - * @param id The fan OID. - * @param rv [out] Receives the fan's operations status flags. - * @notes Only operational state needs to be returned - - * PRESENT/FAILED - */ -int onlp_fani_status_get(onlp_oid_t id, uint32_t* rv) -{ - int result = ONLP_STATUS_OK; - onlp_fan_info_t* info; - int fan_id=ONLP_OID_ID_GET(id); - uint32_t psu_status; - - VALIDATE(id); - - - if(fan_id >= ONLP_FAN_MAX) { - result = ONLP_STATUS_E_INVALID; - } else { - info = &__onlp_fan_info[fan_id]; - switch(fan_id) { - case ONLP_FAN_1: - case ONLP_FAN_2: - case ONLP_FAN_3: - case ONLP_FAN_4: - case ONLP_FAN_5: - case ONLP_FAN_6: - case ONLP_FAN_7: - case ONLP_FAN_8: - case ONLP_FAN_9: - case ONLP_FAN_10: - case ONLP_FAN_11: - case ONLP_FAN_12: - result = _fani_status_present_check(&info->status, fan_id); - if (result == ONLP_STATUS_OK ) { - if (info->status & ONLP_FAN_STATUS_PRESENT) { - result = _fani_status_failed_check(&info->status, fan_id); - } - } - break; - case ONLP_FAN_PSU_1: - case ONLP_FAN_PSU_2: - result = onlp_psui_status_get((&info->hdr)->poid, &psu_status); - if(result != ONLP_STATUS_OK) { - return result; - } - if(psu_status & ONLP_PSU_STATUS_PRESENT) { - info->status = ADD_STATE(info->status, ONLP_FAN_STATUS_PRESENT); - result = _fani_status_failed_check(&info->status, fan_id); - } else { - info->status = 0; - } - break; - default: - result = ONLP_STATUS_E_INVALID; - break; - } - *rv = info->status; - } - return result; -} - -/** - * @brief Retrieve the fan's OID hdr. - * @param id The fan OID. - * @param rv [out] Receives the OID header. - */ -int onlp_fani_hdr_get(onlp_oid_t id, onlp_oid_hdr_t* hdr) -{ - int result = ONLP_STATUS_OK; - onlp_fan_info_t* info; - int fan_id; - VALIDATE(id); - - fan_id = ONLP_OID_ID_GET(id); - if(fan_id >= ONLP_FAN_MAX) { - result = ONLP_STATUS_E_INVALID; - } else { - info = &__onlp_fan_info[fan_id]; - *hdr = info->hdr; - } - return result; -} - - -/* - * 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) -{ - return ONLP_STATUS_E_UNSUPPORTED; -} - - -/* - * 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/d6432/onlp/builds/x86_64_inventec_d6432/module/src/ledi.c b/packages/platforms/inventec/x86-64/d6432/onlp/builds/x86_64_inventec_d6432/module/src/ledi.c deleted file mode 100644 index 1fe6ff466..000000000 --- a/packages/platforms/inventec/x86-64/d6432/onlp/builds/x86_64_inventec_d6432/module/src/ledi.c +++ /dev/null @@ -1,439 +0,0 @@ -/************************************************************ - * ledi.c - * - * Copyright 2018 Inventec Technology Corporation. - * - ************************************************************ - * - ***********************************************************/ -#include -#include -#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) - -/* LED related data - */ - -/* CAPS*/ -#define SYS_LED_CAPS 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_ORANGE -#define FAN_LED_CAPS ONLP_LED_CAPS_RED|ONLP_LED_CAPS_GREEN - -#define LED_ID_TO_FAN_ID(id) (id-ONLP_LED_MGMT) -#define FAN_TO_BLADE_ID(fan_id) fan_id*2 - -typedef enum sys_led_mode_e { - SYS_LED_MODE_OFF = 0, - SYS_LED_MODE_0_5_HZ = 1, - SYS_LED_MODE_1_HZ = 2, - SYS_LED_MODE_2_HZ = 3, - SYS_LED_MODE_4_HZ = 4, - SYS_LED_MODE_ON = 7 -} sys_led_mode_t; - -/* function declarations*/ -static int _sys_onlp_led_mode_convert(sys_led_mode_t grn_mode, sys_led_mode_t red_mode, onlp_led_mode_t* pmode); -static int _sys_onlp_ledi_info_get(onlp_oid_t id, onlp_led_info_t* info); -static int _fan_onlp_ledi_info_get(onlp_oid_t id, onlp_led_info_t* info); -static int _sys_onlp_ledi_mode_set(onlp_led_mode_t onlp_mode); - -/* - * Get the information for the given LED OID. - */ -#define MAKE_MGMT_LED_INFO_NODE \ - { \ - { ONLP_LED_ID_CREATE(ONLP_LED_MGMT), "MGMT LED" , 0 }, \ - ONLP_LED_STATUS_PRESENT, \ - SYS_LED_CAPS, \ - } - -#define MAKE_LED_INFO_NODE_ON_FAN(fan_id) \ - { \ - { ONLP_LED_ID_CREATE(ONLP_LED_FAN##fan_id), \ - "FAN LED "#fan_id, 0, \ - }, \ - 0, FAN_LED_CAPS, \ - } - -static onlp_led_info_t __onlp_led_info[] = { - {}, - MAKE_MGMT_LED_INFO_NODE, - MAKE_LED_INFO_NODE_ON_FAN(1), - MAKE_LED_INFO_NODE_ON_FAN(2), - MAKE_LED_INFO_NODE_ON_FAN(3), - MAKE_LED_INFO_NODE_ON_FAN(4), - MAKE_LED_INFO_NODE_ON_FAN(5), - MAKE_LED_INFO_NODE_ON_FAN(6), -}; - - - -/* convert platform led type to onlp_led_mode type*/ -static int _sys_onlp_led_mode_convert(sys_led_mode_t grn_mode, sys_led_mode_t red_mode, onlp_led_mode_t* pmode) -{ - int rv = ONLP_STATUS_OK; - *pmode = ONLP_LED_MODE_OFF; - - switch(grn_mode) { - case SYS_LED_MODE_0_5_HZ: - case SYS_LED_MODE_1_HZ: - case SYS_LED_MODE_2_HZ: - case SYS_LED_MODE_4_HZ: - if(red_mode==SYS_LED_MODE_OFF) { - *pmode = ONLP_LED_MODE_GREEN_BLINKING; - } else { - return ONLP_STATUS_E_INVALID; - } - break; - case SYS_LED_MODE_ON: - if(red_mode==SYS_LED_MODE_ON) { - *pmode = ONLP_LED_MODE_ORANGE; - } else if(red_mode==SYS_LED_MODE_OFF) { - *pmode = ONLP_LED_MODE_GREEN; - } else { - return ONLP_STATUS_E_INVALID; - } - break; - case SYS_LED_MODE_OFF: - if(red_mode==SYS_LED_MODE_OFF) { - *pmode = ONLP_LED_MODE_OFF; - } else if( (red_mode>=SYS_LED_MODE_0_5_HZ) && (red_mode<=SYS_LED_MODE_4_HZ) ) { - *pmode =ONLP_LED_MODE_RED_BLINKING; - } else if(red_mode==SYS_LED_MODE_ON) { - *pmode=ONLP_LED_MODE_RED; - } else { - return ONLP_STATUS_E_INVALID; - } - break; - default: - return ONLP_STATUS_E_INVALID; - break; - } - return rv; -} - - -static int _sys_onlp_ledi_info_get(onlp_oid_t id, onlp_led_info_t* info) -{ - int rv = ONLP_STATUS_OK; - int grn_mode=0, red_mode=0,len; - int led_id= ONLP_OID_ID_GET(id); - *info= __onlp_led_info[led_id]; - char buf[ONLP_CONFIG_INFO_STR_MAX]; - rv = onlp_file_read((uint8_t*)buf,ONLP_CONFIG_INFO_STR_MAX, &len,INV_LED_PREFIX"grn_led"); - if(rv != ONLP_STATUS_OK) { - return rv; - } - grn_mode=(int)(buf[0]-'0'); - - rv = onlp_file_read((uint8_t*)buf,ONLP_CONFIG_INFO_STR_MAX, &len,INV_LED_PREFIX"red_led"); - if(rv != ONLP_STATUS_OK) { - return rv; - } - red_mode=(int)(buf[0]-'0'); - - rv = _sys_onlp_led_mode_convert(grn_mode, red_mode, &info->mode); - if(rv != ONLP_STATUS_OK) { - return rv; - } - - if(info->mode==ONLP_LED_MODE_OFF) { - info->status = REMOVE_STATE(info->status,ONLP_LED_STATUS_ON); - } else { - info->status = ADD_STATE(info->status,ONLP_LED_STATUS_ON); - } - - return rv; -} - -static int _fan_onlp_ledi_info_get(onlp_oid_t id, onlp_led_info_t* info) -{ - int rv = ONLP_STATUS_OK, len; - int led_id=ONLP_OID_ID_GET(id); - int fan_id=LED_ID_TO_FAN_ID(led_id); - *info=__onlp_led_info[led_id]; - char buf[ONLP_CONFIG_INFO_STR_MAX]; - - rv = onlp_ledi_status_get(id, &info->status); - if( rv != ONLP_STATUS_OK ) { - return rv; - } - - if( info->status & ONLP_LED_STATUS_PRESENT) { - rv = onlp_file_read((uint8_t*)buf,ONLP_CONFIG_INFO_STR_MAX, &len, INV_LED_PREFIX"fanmodule%d_led", fan_id); - if(rv == ONLP_STATUS_OK ) { - switch(buf[0]) { - case '0': - info->mode = ONLP_LED_MODE_OFF; - break; - case '1': - info->mode = ONLP_LED_MODE_GREEN; - break; - case '2': - info->mode = ONLP_LED_MODE_RED; - break; - default: - rv=ONLP_STATUS_E_INVALID; - break; - } - } - } else { - info->mode = ONLP_LED_MODE_OFF; - } - return rv; -} - -static int _sys_onlp_ledi_mode_set(onlp_led_mode_t onlp_mode) -{ - int rv = ONLP_STATUS_OK; - - if( onlp_mode == ONLP_LED_MODE_OFF) { - rv = onlp_file_write_int(SYS_LED_MODE_OFF, INV_LED_PREFIX"grn_led"); - if(rv != ONLP_STATUS_OK ) { - return rv; - } - rv = onlp_file_write_int(SYS_LED_MODE_OFF, INV_LED_PREFIX"red_led"); - } else { - rv = ONLP_STATUS_E_UNSUPPORTED; - } - return rv; -} - - - -/* - * 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; - VALIDATE(id); - int led_id= ONLP_OID_ID_GET(id); - if( led_id >= ONLP_LED_MAX) { - return ONLP_STATUS_E_INVALID; - } - - switch(led_id) { - case ONLP_LED_MGMT: - rv = _sys_onlp_ledi_info_get(id, info); - break; - case ONLP_LED_FAN1: - case ONLP_LED_FAN2: - case ONLP_LED_FAN3: - case ONLP_LED_FAN4: - case ONLP_LED_FAN5: - case ONLP_LED_FAN6: - rv = _fan_onlp_ledi_info_get(id, info); - break; - default: - rv = ONLP_STATUS_E_INVALID; - break; - } - return rv; -} - -/** - * @brief Get the LED operational status. - * @param id The LED OID - * @param rv [out] Receives the operational status. - */ -int onlp_ledi_status_get(onlp_oid_t id, uint32_t* rv) -{ - int result = ONLP_STATUS_OK; - onlp_led_info_t* info; - - VALIDATE(id); - int led_id = ONLP_OID_ID_GET(id); - int fan_id = LED_ID_TO_FAN_ID( led_id); - int grn_mode, red_mode; - char mode[ONLP_CONFIG_INFO_STR_MAX]; - onlp_led_mode_t pmode; - uint32_t fan_status; - - if( led_id >= ONLP_LED_MAX) { - result = ONLP_STATUS_E_INVALID; - } - if(result == ONLP_STATUS_OK) { - info = &__onlp_led_info[led_id]; - switch(led_id) { - case ONLP_LED_MGMT: - result = onlp_file_read_int((int*)&grn_mode, INV_LED_PREFIX"grn_led"); - if(result != ONLP_STATUS_OK) { - return result; - } - result = onlp_file_read_int((int*)&red_mode, INV_LED_PREFIX"red_led"); - if(result != ONLP_STATUS_OK) { - return result; - } - - result = _sys_onlp_led_mode_convert(grn_mode, red_mode, &pmode); - if(result != ONLP_STATUS_OK) { - return result; - } - - if( pmode != ONLP_LED_MODE_OFF) { - info->status = ADD_STATE(info->status,ONLP_LED_STATUS_ON); - } else { - info->status = REMOVE_STATE(info->status, ONLP_LED_STATUS_ON); - } - - *rv = info->status; - break; - case ONLP_LED_FAN1: - case ONLP_LED_FAN2: - case ONLP_LED_FAN3: - case ONLP_LED_FAN4: - case ONLP_LED_FAN5: - case ONLP_LED_FAN6: - result = onlp_fani_status_get(ONLP_FAN_ID_CREATE(FAN_TO_BLADE_ID(fan_id)), &fan_status); - if(result != ONLP_STATUS_OK) { - return result; - } - - if(fan_status & ONLP_FAN_STATUS_PRESENT) { - info->status = ADD_STATE(info->status,ONLP_LED_STATUS_PRESENT); - result = onlp_file_read_int((int*)&mode, INV_LED_PREFIX"fanmodule%d_led", fan_id); - if(result != ONLP_STATUS_OK) { - return result; - } - - if(mode[0]=='0') { - info->status = REMOVE_STATE(info->status,ONLP_LED_STATUS_ON); - } else { - info->status = ADD_STATE(info->status,ONLP_LED_STATUS_ON); - } - } else { - info->status = 0; - } - *rv = info->status; - break; - default: - result = ONLP_STATUS_E_INVALID; - break; - } - } - - return result; -} - -/** - * @brief Get the LED header. - * @param id The LED OID - * @param rv [out] Receives the header. - */ -int onlp_ledi_hdr_get(onlp_oid_t id, onlp_oid_hdr_t* rv) -{ - int result = ONLP_STATUS_OK; - onlp_led_info_t* info; - - VALIDATE(id); - - int led_id = ONLP_OID_ID_GET(id); - if( led_id >= ONLP_LED_MAX) { - result = ONLP_STATUS_E_INVALID; - } else { - - info = &__onlp_led_info[led_id]; - *rv = info->hdr; - } - return result; -} - -/* - * 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) -{ - onlp_led_mode_t mode; - VALIDATE(id); - int led_id; - led_id = ONLP_OID_ID_GET(id); - - if(led_id >= ONLP_LED_MAX) { - return ONLP_STATUS_E_INVALID; - } - - if (__onlp_led_info[led_id].caps & ONLP_LED_CAPS_ON_OFF) { - if(on_or_off) { - mode =ONLP_LED_MODE_ON; - } else { - mode=ONLP_LED_MODE_OFF; - } - return onlp_ledi_mode_set(id, mode); - } - - 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 rv = ONLP_STATUS_OK; - VALIDATE(id); - int led_id; - led_id = ONLP_OID_ID_GET(id); - - if(led_id >= ONLP_LED_MAX) { - return ONLP_STATUS_E_INVALID; - } - switch(led_id) { - case ONLP_LED_MGMT: - rv = _sys_onlp_ledi_mode_set(mode); - break; - case ONLP_LED_FAN1: - case ONLP_LED_FAN2: - case ONLP_LED_FAN3: - case ONLP_LED_FAN4: - case ONLP_LED_FAN5: - case ONLP_LED_FAN6: - rv = ONLP_STATUS_E_UNSUPPORTED; - break; - default: - rv = ONLP_STATUS_E_INVALID; - break; - } - - return rv; -} - -/* - * 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/d6432/onlp/builds/x86_64_inventec_d6432/module/src/make.mk b/packages/platforms/inventec/x86-64/d6432/onlp/builds/x86_64_inventec_d6432/module/src/make.mk deleted file mode 100644 index 0849f95b4..000000000 --- a/packages/platforms/inventec/x86-64/d6432/onlp/builds/x86_64_inventec_d6432/module/src/make.mk +++ /dev/null @@ -1,9 +0,0 @@ -############################################################################### -# -# -# -############################################################################### - -LIBRARY := x86_64_inventec_d6432 -$(LIBRARY)_SUBDIR := $(dir $(lastword $(MAKEFILE_LIST))) -include $(BUILDER)/lib.mk diff --git a/packages/platforms/inventec/x86-64/d6432/onlp/builds/x86_64_inventec_d6432/module/src/platform_lib.c b/packages/platforms/inventec/x86-64/d6432/onlp/builds/x86_64_inventec_d6432/module/src/platform_lib.c deleted file mode 100644 index aa29a967a..000000000 --- a/packages/platforms/inventec/x86-64/d6432/onlp/builds/x86_64_inventec_d6432/module/src/platform_lib.c +++ /dev/null @@ -1,34 +0,0 @@ -/************************************************************ - * platform_lib.c - * - * Copyright 2018 Inventec Technology Corporation. - * - ************************************************************ - * - ***********************************************************/ -#include -#include -#include -#include -#include -#include -#include -#include -#include "platform_lib.h" - - - -int platform_hwmon_diag_enable_read(int *enable) -{ - int rv = ONLP_STATUS_OK; - rv = onlp_file_read_int((int*)enable, INV_INFO_PREFIX"diag"); - return rv; -} - - -int platform_hwmon_diag_enable_write(int enable) -{ - int rv = ONLP_STATUS_OK; - rv = onlp_file_write_int(enable, INV_INFO_PREFIX"diag"); - return rv; -} \ No newline at end of file diff --git a/packages/platforms/inventec/x86-64/d6432/onlp/builds/x86_64_inventec_d6432/module/src/platform_lib.h b/packages/platforms/inventec/x86-64/d6432/onlp/builds/x86_64_inventec_d6432/module/src/platform_lib.h deleted file mode 100644 index c161a1eb9..000000000 --- a/packages/platforms/inventec/x86-64/d6432/onlp/builds/x86_64_inventec_d6432/module/src/platform_lib.h +++ /dev/null @@ -1,142 +0,0 @@ -/************************************************************ - * platform_lib.h - * - * Copyright 2018 Inventec Technology Corporation. - * - ************************************************************ - * - ***********************************************************/ -#ifndef __PLATFORM_LIB_H__ -#define __PLATFORM_LIB_H__ - -#include "x86_64_inventec_d6432_log.h" - -/* This is definitions for x86-64-inventec-d6432*/ -/* OID map*/ -/* - * SYS---------ONLP_THERMAL_CPU_PHY - * |----ONLP_THERMAL_CPU_CORE0 - * |----ONLP_THERMAL_CPU_CORE1 - * |----ONLP_THERMAL_CPU_CORE2 - * |----ONLP_THERMAL_CPU_CORE3 - * |----ONLP_THERMAL_1_ON_MAIN_BROAD - * |----ONLP_THERMAL_2_ON_MAIN_BROAD - * |----ONLP_THERMAL_3_ON_MAIN_BROAD - * |----ONLP_THERMAL_4_ON_MAIN_BROAD - * |----ONLP_THERMAL_5_ON_MAIN_BROAD - * |----ONLP_FAN_1--------ONLP_LED_FAN1 - * | - * |----ONLP_FAN_2--------ONLP_LED_FAN2 - * | - * |----ONLP_FAN_3--------ONLP_LED_FAN3 - * | - * |----ONLP_FAN_4--------ONLP_LED_FAN4 - * | - * |----ONLP_FAN_5--------ONLP_LED_FAN5 - * | - * |----ONLP_FAN_6--------ONLP_LED_FAN6 - * | - * | - * |----ONLP_PSU_1--------ONLP_THERMAL_1_ON_PSU1 - * | |--ONLP_THERMAL_2_ON_PSU1 - * | |--ONLP_THERMAL_3_ON_PSU1 - * | |--ONLP_FAN_PSU_1 - * | - * |----ONLP_PSU_2--------ONLP_THERMAL_1_ON_PSU2 - * | |--ONLP_THERMAL_2_ON_PSU2 - * | |--ONLP_THERMAL_3_ON_PSU2 - * | |--ONLP_FAN_PSU_2 - * | - * |----ONLP_LED_MGMT - */ - -#define INV_INFO_PREFIX "/sys/bus/i2c/devices/2-0077/" -#define INV_FAN_PREFIX "/sys/bus/i2c/devices/2-0077/" -#define INV_THERMAL_PREFIX "/sys/bus/i2c/devices/2-0077/" -#define INV_LED_PREFIX "/sys/bus/i2c/devices/2-0077/" -#define INV_SFP_PREFIX "/sys/swps/card1/sff/" -#define INV_SYS_PREFIX "/sys/class/eeprom/vpd/" -#define INV_DEVICE_BASE "/sys/bus/i2c/devices/" -#define INV_CTMP_BASE "/sys/devices/platform/coretemp.0/hwmon/" -#define INV_EEPROM_PATH "/sys/bus/i2c/devices/2-0055/eeprom" -#define PSU_I2C_CHAN 2 - -#define ADD_STATE(orig_state,new_state) orig_state | new_state -#define REMOVE_STATE(orig_state, target) orig_state & (~target) - -/* Thermal definitions*/ -enum onlp_thermal_id { - ONLP_THERMAL_CPU_PHY = 1, - ONLP_THERMAL_CPU_CORE0, - ONLP_THERMAL_CPU_CORE1, - ONLP_THERMAL_CPU_CORE2, - ONLP_THERMAL_CPU_CORE3, - ONLP_THERMAL_1_ON_MAIN_BROAD, - ONLP_THERMAL_2_ON_MAIN_BROAD, - ONLP_THERMAL_3_ON_MAIN_BROAD, - ONLP_THERMAL_4_ON_MAIN_BROAD, - ONLP_THERMAL_5_ON_MAIN_BROAD, - ONLP_THERMAL_6_ON_MAIN_BROAD, - ONLP_THERMAL_7_ON_MAIN_BROAD, - ONLP_THERMAL_1_ON_PSU1, - ONLP_THERMAL_2_ON_PSU1, - ONLP_THERMAL_3_ON_PSU1, - ONLP_THERMAL_1_ON_PSU2, - ONLP_THERMAL_2_ON_PSU2, - ONLP_THERMAL_3_ON_PSU2, - ONLP_THERMAL_MAX /*num limit include reserved*/ -}; - -/* Fan definitions*/ -enum onlp_fan_id { - ONLP_FAN_1 = 1, - ONLP_FAN_2, - ONLP_FAN_3, - ONLP_FAN_4, - ONLP_FAN_5, - ONLP_FAN_6, - ONLP_FAN_7, - ONLP_FAN_8, - ONLP_FAN_9, - ONLP_FAN_10, - ONLP_FAN_11, - ONLP_FAN_12, - ONLP_FAN_PSU_1, - ONLP_FAN_PSU_2, - ONLP_FAN_MAX /*num limit include reserved*/ -}; - -/* PSU definitions*/ -enum onlp_psu_id { - ONLP_PSU_1 = 1, - ONLP_PSU_2, - ONLP_PSU_MAX /*num limit include reserved*/ -}; - -/* LED definitions*/ -enum onlp_led_id { - ONLP_LED_MGMT = 1, - ONLP_LED_FAN1, - ONLP_LED_FAN2, - ONLP_LED_FAN3, - ONLP_LED_FAN4, - ONLP_LED_FAN5, - ONLP_LED_FAN6, - ONLP_LED_MAX /*num limit include reserved*/ -}; - - -/* platform functions*/ -#define PLATFORM_HWMON_DIAG_LOCK -#define PLATFORM_HWMON_DIAG_UNLOCK -//#define PLATFORM_HWMON_DIAG_LOCK platform_hwmon_diag_enable_write(0) -//#define PLATFORM_HWMON_DIAG_UNLOCK platform_hwmon_diag_enable_write(1) -int platform_hwmon_diag_enable_read(int *enable); -int platform_hwmon_diag_enable_write(int enable); -char* hwmon_path( char* parent_dir); - -extern char* psu_i2c_addr[ONLP_PSU_MAX]; - - -#endif /* __PLATFORM_LIB_H__ */ - diff --git a/packages/platforms/inventec/x86-64/d6432/onlp/builds/x86_64_inventec_d6432/module/src/psui.c b/packages/platforms/inventec/x86-64/d6432/onlp/builds/x86_64_inventec_d6432/module/src/psui.c deleted file mode 100644 index f8355cc67..000000000 --- a/packages/platforms/inventec/x86-64/d6432/onlp/builds/x86_64_inventec_d6432/module/src/psui.c +++ /dev/null @@ -1,204 +0,0 @@ -/************************************************************ - * psui.c - * - * Copyright 2018 Inventec Technology Corporation. - * - ************************************************************ - * - ***********************************************************/ -#include -#include -#include "platform_lib.h" -#include -#include - -#define VALIDATE(_id) \ - do { \ - if(!ONLP_OID_IS_PSU(_id)) { \ - return ONLP_STATUS_E_INVALID; \ - } \ - } while(0) - -typedef enum hwmon_psu_state_e { - HWMON_PSU_NORMAL = 0, - HWMON_PSU_UNPOWERED = 2, //010 - HWMON_PSU_FAULT = 4, //100 - HWMON_PSU_NOT_INSTALLED = 7 //111 -} hwmon_psu_state_t; - -#define PSU_CAPS ONLP_PSU_CAPS_VIN|ONLP_PSU_CAPS_VOUT|ONLP_PSU_CAPS_IIN|ONLP_PSU_CAPS_IOUT|ONLP_PSU_CAPS_PIN| ONLP_PSU_CAPS_POUT - -char* psu_i2c_addr[ONLP_PSU_MAX]= { - "", - "58", - "59" -}; - -/* - * Get all information about the given PSU oid. - */ -#define MAKE_PSU_NODE_INFO(id) \ - { \ - { \ - ONLP_PSU_ID_CREATE(ONLP_PSU_##id), "PSU-"#id, 0, \ - { \ - ONLP_THERMAL_ID_CREATE(ONLP_THERMAL_1_ON_PSU##id), \ - ONLP_THERMAL_ID_CREATE(ONLP_THERMAL_2_ON_PSU##id), \ - ONLP_THERMAL_ID_CREATE(ONLP_THERMAL_3_ON_PSU##id), \ - ONLP_FAN_ID_CREATE(ONLP_FAN_PSU_##id) \ - } \ - }, \ - "","", 0, PSU_CAPS, \ - } - -static onlp_psu_info_t __onlp_psu_info[ ] = { - {}, - MAKE_PSU_NODE_INFO(1), - MAKE_PSU_NODE_INFO(2) -}; - -int -onlp_psui_init(void) -{ - return ONLP_STATUS_OK; -} - - -int -onlp_psui_info_get(onlp_oid_t id, onlp_psu_info_t* info) -{ - int ret = ONLP_STATUS_OK; - int len; - int psu_id = ONLP_OID_ID_GET(id); - uint8_t buf[ONLP_CONFIG_INFO_STR_MAX] = {0}; - char path[ONLP_CONFIG_INFO_STR_MAX]; - - VALIDATE(id); - - if(psu_id >= ONLP_PSU_MAX) { - return ONLP_STATUS_E_INVALID; - } - - *info = __onlp_psu_info[psu_id]; - ret = onlp_psui_status_get(id, &info->status); - if(ret != ONLP_STATUS_OK) { - return ret; - } - - if(info->status & ONLP_PSU_STATUS_PRESENT) { - snprintf(path,ONLP_CONFIG_INFO_STR_MAX, INV_DEVICE_BASE"%d-00%s/",PSU_I2C_CHAN,psu_i2c_addr[psu_id]); - - memset(buf, 0, ONLP_CONFIG_INFO_STR_MAX); - ret=onlp_file_read( buf, ONLP_CONFIG_INFO_STR_MAX, &len, "%smfr_id", path ); - if(ret==ONLP_STATUS_OK) { - buf[strlen((char*)buf)-1] = 0; - snprintf(info->model, ONLP_CONFIG_INFO_STR_MAX, "%s", buf); - } - - memset(buf, 0, ONLP_CONFIG_INFO_STR_MAX); - ret=onlp_file_read( buf, ONLP_CONFIG_INFO_STR_MAX, &len, "%smfr_serial_number", path ); - if(ret==ONLP_STATUS_OK) { - buf[strlen((char*)buf)-1] = 0; - snprintf(info->serial, ONLP_CONFIG_INFO_STR_MAX, "%s", buf); - } - - if(ret==ONLP_STATUS_OK) { - ret=onlp_file_read_int( &info->mvin, "%sin1_input", path ); - } - - if(ret==ONLP_STATUS_OK) { - ret=onlp_file_read_int( &info->mvout, "%sin2_input", path ); - } - - if(ret==ONLP_STATUS_OK) { - ret=onlp_file_read_int( &info->miin, "%scurr1_input", path ); - } - - if(ret==ONLP_STATUS_OK) { - ret=onlp_file_read_int( &info->miout, "%scurr2_input", path ); - } - - if(ret==ONLP_STATUS_OK) { - ret=onlp_file_read_int( &info->mpin, "%spower1_input", path ); - } - - if(ret==ONLP_STATUS_OK) { - ret=onlp_file_read_int( &info->mpout, "%spower2_input", path ); - } - } - - return ret; - -} - - -/** - * @brief Get the PSU's operational status. - * @param id The PSU OID. - * @param rv [out] Receives the operational status. - */ -int onlp_psui_status_get(onlp_oid_t id, uint32_t* rv) -{ - int result = ONLP_STATUS_OK; - hwmon_psu_state_t psu_state; - int local_id; - int len; - char buf[ONLP_CONFIG_INFO_STR_MAX]; - - VALIDATE(id); - - - local_id = ONLP_OID_ID_GET(id); - - if(local_id >= ONLP_PSU_MAX) { - result = ONLP_STATUS_E_INVALID; - } else { - result = onlp_file_read((uint8_t*)&buf, ONLP_CONFIG_INFO_STR_MAX, &len, "%spsu%d", INV_INFO_PREFIX, local_id); - if( result != ONLP_STATUS_OK ) { - return result; - } - psu_state = (uint8_t)strtoul(buf, NULL, 0); - if( psu_state == HWMON_PSU_UNPOWERED) { - *rv = ONLP_PSU_STATUS_PRESENT|ONLP_PSU_STATUS_UNPLUGGED; - } else if ( psu_state == HWMON_PSU_NORMAL) { - *rv = ONLP_PSU_STATUS_PRESENT; - } else if( psu_state == HWMON_PSU_FAULT) { - *rv = ONLP_PSU_STATUS_PRESENT|ONLP_PSU_STATUS_FAILED; - } else if( psu_state == HWMON_PSU_NOT_INSTALLED) { - *rv = 0; - } else { - result = ONLP_STATUS_E_INVALID; - } - } - return result; -} - -/** - * @brief Get the PSU's oid header. - * @param id The PSU OID. - * @param rv [out] Receives the header. - */ -int onlp_psui_hdr_get(onlp_oid_t id, onlp_oid_hdr_t* rv) -{ - int result = ONLP_STATUS_OK; - onlp_psu_info_t* info; - int psu_id=ONLP_OID_ID_GET(id); - - VALIDATE(id); - - if(psu_id >= ONLP_PSU_MAX) { - result = ONLP_STATUS_E_INVALID; - } else { - info = &__onlp_psu_info[psu_id]; - *rv = info->hdr; - } - return result; -} - - -int -onlp_psui_ioctl(onlp_oid_t pid, va_list vargs) -{ - return ONLP_STATUS_E_UNSUPPORTED; -} - diff --git a/packages/platforms/inventec/x86-64/d6432/onlp/builds/x86_64_inventec_d6432/module/src/sfpi.c b/packages/platforms/inventec/x86-64/d6432/onlp/builds/x86_64_inventec_d6432/module/src/sfpi.c deleted file mode 120000 index c6d6801d4..000000000 --- a/packages/platforms/inventec/x86-64/d6432/onlp/builds/x86_64_inventec_d6432/module/src/sfpi.c +++ /dev/null @@ -1 +0,0 @@ -../../../../../../../x86-64/d7332/onlp/builds/x86_64_inventec_d7332/module/src/sfpi.c \ No newline at end of file diff --git a/packages/platforms/inventec/x86-64/d6432/onlp/builds/x86_64_inventec_d6432/module/src/sysi.c b/packages/platforms/inventec/x86-64/d6432/onlp/builds/x86_64_inventec_d6432/module/src/sysi.c deleted file mode 100644 index a130d1355..000000000 --- a/packages/platforms/inventec/x86-64/d6432/onlp/builds/x86_64_inventec_d6432/module/src/sysi.c +++ /dev/null @@ -1,262 +0,0 @@ -/************************************************************ - * sysi.c - * - * Copyright 2018 Inventec Technology Corporation. - * - ************************************************************ - * - ***********************************************************/ -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "x86_64_inventec_d6432_int.h" -#include "x86_64_inventec_d6432_log.h" - -#include "platform_lib.h" - -static onlp_oid_t __oid_info[] = { - ONLP_THERMAL_ID_CREATE(ONLP_THERMAL_CPU_PHY), - ONLP_THERMAL_ID_CREATE(ONLP_THERMAL_CPU_CORE0), - ONLP_THERMAL_ID_CREATE(ONLP_THERMAL_CPU_CORE1), - ONLP_THERMAL_ID_CREATE(ONLP_THERMAL_CPU_CORE2), - ONLP_THERMAL_ID_CREATE(ONLP_THERMAL_CPU_CORE3), - ONLP_THERMAL_ID_CREATE(ONLP_THERMAL_1_ON_MAIN_BROAD), - ONLP_THERMAL_ID_CREATE(ONLP_THERMAL_2_ON_MAIN_BROAD), - ONLP_THERMAL_ID_CREATE(ONLP_THERMAL_3_ON_MAIN_BROAD), - ONLP_THERMAL_ID_CREATE(ONLP_THERMAL_4_ON_MAIN_BROAD), - ONLP_THERMAL_ID_CREATE(ONLP_THERMAL_5_ON_MAIN_BROAD), - ONLP_THERMAL_ID_CREATE(ONLP_THERMAL_6_ON_MAIN_BROAD), - ONLP_THERMAL_ID_CREATE(ONLP_THERMAL_7_ON_MAIN_BROAD), - ONLP_FAN_ID_CREATE(ONLP_FAN_1), - ONLP_FAN_ID_CREATE(ONLP_FAN_2), - ONLP_FAN_ID_CREATE(ONLP_FAN_3), - ONLP_FAN_ID_CREATE(ONLP_FAN_4), - ONLP_FAN_ID_CREATE(ONLP_FAN_5), - ONLP_FAN_ID_CREATE(ONLP_FAN_6), - ONLP_FAN_ID_CREATE(ONLP_FAN_7), - ONLP_FAN_ID_CREATE(ONLP_FAN_8), - ONLP_FAN_ID_CREATE(ONLP_FAN_9), - ONLP_FAN_ID_CREATE(ONLP_FAN_10), - ONLP_FAN_ID_CREATE(ONLP_FAN_11), - ONLP_FAN_ID_CREATE(ONLP_FAN_12), - ONLP_PSU_ID_CREATE(ONLP_PSU_1), - ONLP_PSU_ID_CREATE(ONLP_PSU_2), - ONLP_LED_ID_CREATE(ONLP_LED_MGMT), - ONLP_LED_ID_CREATE(ONLP_LED_FAN1), - ONLP_LED_ID_CREATE(ONLP_LED_FAN2), - ONLP_LED_ID_CREATE(ONLP_LED_FAN3), - ONLP_LED_ID_CREATE(ONLP_LED_FAN4), - ONLP_LED_ID_CREATE(ONLP_LED_FAN5), - ONLP_LED_ID_CREATE(ONLP_LED_FAN6), - 0/*end*/ -}; - -static int _sysi_version_parsing(char* file_str, char* str_buf, char* version); - -static int _sysi_version_parsing(char* file_str, char* str_buf, char* version) -{ - int rv = ONLP_STATUS_OK; - int len; - char buf[ONLP_CONFIG_INFO_STR_MAX * 4]; - char *temp; - char cpld_v1[ONLP_CONFIG_INFO_STR_MAX]; - char cpld_v2[ONLP_CONFIG_INFO_STR_MAX]; - - rv = onlp_file_read((uint8_t*)buf, ONLP_CONFIG_INFO_STR_MAX * 4, &len, file_str); - if ( rv != ONLP_STATUS_OK ) { - return rv; - } - temp = strstr(buf, str_buf); - if (temp) { - temp += strlen(str_buf); - sscanf(temp, "%s", cpld_v1); - } else { - return ONLP_STATUS_E_INVALID; - } - temp = strstr(temp, str_buf); - if (temp) { - temp += strlen(str_buf); - sscanf(temp, "%s", cpld_v2); - } else { - return ONLP_STATUS_E_INVALID; - } - snprintf(version, ONLP_CONFIG_INFO_STR_MAX, "c1_%s c2_%s", cpld_v1, cpld_v2); - - return rv; -} - -const char* -onlp_sysi_platform_get(void) -{ - return "x86-64-inventec-d6432-r0"; -} - - -/* - * This function is called to return the physical base address - * of the ONIE boot rom. - * - * The ONLP framework will mmap() and parse the ONIE TLV structure - * from the given data. - * - * If you platform does not support a mappable address for the ONIE - * eeprom then you should not provide this function at all. - * - * For the purposes of this example we will provide it but - * return UNSUPPORTED (which is all the default implementation does). - * - */ -int -onlp_sysi_onie_data_phys_addr_get(void** pa) -{ - return ONLP_STATUS_E_UNSUPPORTED; -} - - -/* - * If you cannot provide a base address you must provide the ONLP - * framework the raw ONIE data through whatever means necessary. - * - * This function will be called as a backup in the event that - * onlp_sysi_onie_data_phys_addr_get() fails. - */ -int -onlp_sysi_onie_data_get(uint8_t** data, int* size) -{ - int ret=ONLP_STATUS_E_INVALID; - int eeprom_size; - int rv; - uint8_t* eeprom_data; - - FILE* fp = fopen(INV_EEPROM_PATH, "rb"); - - if(fp) { - fseek(fp, 0L, SEEK_END); - eeprom_size = ftell(fp); - rewind(fp); - eeprom_data = aim_malloc(eeprom_size); - - rv = fread(eeprom_data, 1, eeprom_size, fp); - fclose(fp); - - if(rv == eeprom_size) { - ret=ONLP_STATUS_OK; - *data=eeprom_data; - *size=eeprom_size; - } - - } - - - return ret; -} - -/* - * IF the ONLP frame calles onlp_sysi_onie_data_get(), - * if will call this function to free the data when it - * is finished with it. - * - * This function is optional, and depends on the data - * you return in onlp_sysi_onie_data_get(). - */ -void -onlp_sysi_onie_data_free(uint8_t* data) -{ - /* - * We returned a static array in onlp_sysi_onie_data_get() - * so no free operation is required. - */ - if (data) { - aim_free(data); - } -} - - -int -onlp_sysi_onie_info_get (onlp_onie_info_t *onie) -{ - int rv = ONLP_STATUS_OK; - - rv = onlp_onie_decode_file(onie, INV_EEPROM_PATH); - - onie->_hdr_id_string = aim_fstrdup("TlvInfo"); - onie->_hdr_version = 0x1; - return rv; -} - - -int -onlp_sysi_platform_info_get(onlp_platform_info_t* pi) -{ - int rv = ONLP_STATUS_OK; - char cpld_str[ONLP_CONFIG_INFO_STR_MAX] = {0}; - char version[ONLP_CONFIG_INFO_STR_MAX]; - pi->cpld_versions = NULL; - - rv = _sysi_version_parsing( INV_INFO_PREFIX"info", "The CPLD version is ", version); - if ( rv != ONLP_STATUS_OK ) { - return rv; - } - snprintf(cpld_str, ONLP_CONFIG_INFO_STR_MAX, "%s%s ", cpld_str, version); - /*cpld version*/ - if (strlen(cpld_str) > 0) { - pi->cpld_versions = aim_fstrdup("%s", cpld_str); - } - return rv; -} - -void -onlp_sysi_platform_info_free(onlp_platform_info_t* pi) -{ - if (pi->cpld_versions) { - aim_free(pi->cpld_versions); - } - if (pi->other_versions) { - aim_free(pi->other_versions); - } - return; -} - - -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 = 0; i < max; i++) { - if (__oid_info[i] == 0) { - break; - } - *e++ = __oid_info[i]; - } - return ONLP_STATUS_OK; -} - -int -onlp_sysi_platform_manage_fans(void) -{ - /*Ensure switch manager is working*/ - PLATFORM_HWMON_DIAG_LOCK; - return ONLP_STATUS_OK; -} - -int -onlp_sysi_platform_manage_leds(void) -{ - /*Ensure switch manager is working*/ - PLATFORM_HWMON_DIAG_LOCK; - return ONLP_STATUS_OK; -} - diff --git a/packages/platforms/inventec/x86-64/d6432/onlp/builds/x86_64_inventec_d6432/module/src/thermali.c b/packages/platforms/inventec/x86-64/d6432/onlp/builds/x86_64_inventec_d6432/module/src/thermali.c deleted file mode 100644 index 4d0e6c74a..000000000 --- a/packages/platforms/inventec/x86-64/d6432/onlp/builds/x86_64_inventec_d6432/module/src/thermali.c +++ /dev/null @@ -1,212 +0,0 @@ -/************************************************************ - * thermali.c - * - * Copyright 2018 Inventec Technology Corporation. - * - ************************************************************ - * - * 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) - - -typedef struct thermali_path_s { - char file[ONLP_CONFIG_INFO_STR_MAX]; -} thermali_path_t; - -#define MAKE_THERMAL_PATH_ON_CPU(id) { "/var/coretemp/temp"#id"_input"} -#define MAKE_THERMAL_PATH_ON_MAIN_BROAD(thermal_id,attr_idx) { "/var/board_thermal_"#thermal_id"/temp"#attr_idx"_input"} -#define MAKE_THERMAL_PATH_ON_PSU(psu_id,thermal_id) { "/var/psu"#psu_id"/device/temp"#thermal_id"_input"} - -static thermali_path_t __path_list[ ] = { - {}, - MAKE_THERMAL_PATH_ON_CPU(1), - MAKE_THERMAL_PATH_ON_CPU(2), - MAKE_THERMAL_PATH_ON_CPU(3), - MAKE_THERMAL_PATH_ON_CPU(4), - MAKE_THERMAL_PATH_ON_CPU(5), - MAKE_THERMAL_PATH_ON_MAIN_BROAD(1,1), - MAKE_THERMAL_PATH_ON_MAIN_BROAD(1,2), - MAKE_THERMAL_PATH_ON_MAIN_BROAD(2,1), - MAKE_THERMAL_PATH_ON_MAIN_BROAD(3,1), - MAKE_THERMAL_PATH_ON_MAIN_BROAD(4,1), - MAKE_THERMAL_PATH_ON_MAIN_BROAD(5,1), - MAKE_THERMAL_PATH_ON_MAIN_BROAD(6,1), - MAKE_THERMAL_PATH_ON_PSU(1,1), - MAKE_THERMAL_PATH_ON_PSU(1,2), - MAKE_THERMAL_PATH_ON_PSU(1,3), - MAKE_THERMAL_PATH_ON_PSU(2,1), - MAKE_THERMAL_PATH_ON_PSU(2,2), - MAKE_THERMAL_PATH_ON_PSU(2,3) -}; - -#define MAKE_THERMAL_INFO_NODE_ON_CPU_PHY \ - { { ONLP_THERMAL_ID_CREATE(ONLP_THERMAL_CPU_PHY), "CPU Physical", 0}, \ - ONLP_THERMAL_STATUS_PRESENT, \ - ONLP_THERMAL_CAPS_GET_TEMPERATURE, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS \ - } -#define MAKE_THERMAL_INFO_NODE_ON_CPU_CORE(id) \ - { { ONLP_THERMAL_ID_CREATE(ONLP_THERMAL_CPU_CORE##id), "CPU Core "#id, 0},\ - ONLP_THERMAL_STATUS_PRESENT, \ - ONLP_THERMAL_CAPS_GET_TEMPERATURE, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS \ - } -#define MAKE_THERMAL_INFO_NODE_ON_BROADS(id) \ - { { ONLP_THERMAL_ID_CREATE(ONLP_THERMAL_##id##_ON_MAIN_BROAD), "Thermal Sensor "#id, 0}, \ - ONLP_THERMAL_STATUS_PRESENT, \ - ONLP_THERMAL_CAPS_GET_TEMPERATURE, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS \ - } -#define MAKE_THERMAL_INFO_NODE_ON_PSU(thermal_id, psu_id) \ - { { \ - ONLP_THERMAL_ID_CREATE(ONLP_THERMAL_##thermal_id##_ON_PSU##psu_id), \ - "PSU-"#psu_id" Thermal Sensor "#thermal_id, \ - ONLP_PSU_ID_CREATE(ONLP_PSU_##psu_id) \ - }, \ - ONLP_THERMAL_STATUS_PRESENT, \ - ONLP_THERMAL_CAPS_GET_TEMPERATURE, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS \ - } - -/* Static values */ -static onlp_thermal_info_t __onlp_thermal_info[ ] = { - {}, - MAKE_THERMAL_INFO_NODE_ON_CPU_PHY, - MAKE_THERMAL_INFO_NODE_ON_CPU_CORE(0), - MAKE_THERMAL_INFO_NODE_ON_CPU_CORE(1), - MAKE_THERMAL_INFO_NODE_ON_CPU_CORE(2), - MAKE_THERMAL_INFO_NODE_ON_CPU_CORE(3), - MAKE_THERMAL_INFO_NODE_ON_BROADS(1), - MAKE_THERMAL_INFO_NODE_ON_BROADS(2), - MAKE_THERMAL_INFO_NODE_ON_BROADS(3), - MAKE_THERMAL_INFO_NODE_ON_BROADS(4), - MAKE_THERMAL_INFO_NODE_ON_BROADS(5), - MAKE_THERMAL_INFO_NODE_ON_BROADS(6), - MAKE_THERMAL_INFO_NODE_ON_BROADS(7), - MAKE_THERMAL_INFO_NODE_ON_PSU(1,1), - MAKE_THERMAL_INFO_NODE_ON_PSU(2,1), - MAKE_THERMAL_INFO_NODE_ON_PSU(3,1), - MAKE_THERMAL_INFO_NODE_ON_PSU(1,2), - MAKE_THERMAL_INFO_NODE_ON_PSU(2,2), - MAKE_THERMAL_INFO_NODE_ON_PSU(3,2), -}; - -/* - * 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) -{ - VALIDATE(id); - int ret; - int thermal_id = ONLP_OID_ID_GET(id); - if(thermal_id >= ONLP_THERMAL_MAX) { - return ONLP_STATUS_E_INVALID; - } - - /* Set the onlp_oid_hdr_t and capabilities */ - *info = __onlp_thermal_info[ thermal_id]; - ret = onlp_thermali_status_get(id, &info->status); - if( ret != ONLP_STATUS_OK ) { - return ret; - } - if(info->status & ONLP_THERMAL_STATUS_PRESENT) { - ret = onlp_file_read_int(&info->mcelsius, __path_list[thermal_id].file ); - } - - return ret; -} - -/** - * @brief Retrieve the thermal's operational status. - * @param id The thermal oid. - * @param rv [out] Receives the operational status. - */ -int onlp_thermali_status_get(onlp_oid_t id, uint32_t* rv) -{ - int ret = ONLP_STATUS_OK; - onlp_thermal_info_t* info; - VALIDATE(id); - uint32_t psu_status; - - int thermal_id = ONLP_OID_ID_GET(id); - if(thermal_id >= ONLP_THERMAL_MAX) { - return ONLP_STATUS_E_INVALID; - } - info = &__onlp_thermal_info[ thermal_id]; - - switch(thermal_id) { - case ONLP_THERMAL_1_ON_PSU1: - case ONLP_THERMAL_2_ON_PSU1: - case ONLP_THERMAL_3_ON_PSU1: - case ONLP_THERMAL_1_ON_PSU2: - case ONLP_THERMAL_2_ON_PSU2: - case ONLP_THERMAL_3_ON_PSU2: - ret = onlp_psui_status_get((&info->hdr)->poid, &psu_status); - if(ret != ONLP_STATUS_OK) { - return ret; - } - if(psu_status & ONLP_PSU_STATUS_PRESENT) { - info->status = ADD_STATE(info->status,ONLP_PSU_STATUS_PRESENT); - } else { - info->status = 0; - } - break; - default: - break; - } - - *rv = info->status; - - return ret; -} - -/** - * @brief Retrieve the thermal's oid header. - * @param id The thermal oid. - * @param rv [out] Receives the header. - */ -int onlp_thermali_hdr_get(onlp_oid_t id, onlp_oid_hdr_t* rv) -{ - onlp_thermal_info_t* info; - VALIDATE(id); - - int thermal_id = ONLP_OID_ID_GET(id); - if(thermal_id >= ONLP_THERMAL_MAX) { - return ONLP_STATUS_E_INVALID; - } - info = &__onlp_thermal_info[ thermal_id]; - - *rv = info->hdr; - - return ONLP_STATUS_OK; -} diff --git a/packages/platforms/inventec/x86-64/d6432/onlp/builds/x86_64_inventec_d6432/module/src/x86_64_inventec_d6432_config.c b/packages/platforms/inventec/x86-64/d6432/onlp/builds/x86_64_inventec_d6432/module/src/x86_64_inventec_d6432_config.c deleted file mode 100644 index 8337eb139..000000000 --- a/packages/platforms/inventec/x86-64/d6432/onlp/builds/x86_64_inventec_d6432/module/src/x86_64_inventec_d6432_config.c +++ /dev/null @@ -1,81 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#include - -/* */ -#define __x86_64_inventec_d6432_config_STRINGIFY_NAME(_x) #_x -#define __x86_64_inventec_d6432_config_STRINGIFY_VALUE(_x) __x86_64_inventec_d6432_config_STRINGIFY_NAME(_x) -x86_64_inventec_d6432_config_settings_t x86_64_inventec_d6432_config_settings[] = -{ -#ifdef x86_64_inventec_d6432_CONFIG_INCLUDE_LOGGING - { __x86_64_inventec_d6432_config_STRINGIFY_NAME(x86_64_inventec_d6432_CONFIG_INCLUDE_LOGGING), __x86_64_inventec_d6432_config_STRINGIFY_VALUE(x86_64_inventec_d6432_CONFIG_INCLUDE_LOGGING) }, -#else -{ x86_64_inventec_d6432_CONFIG_INCLUDE_LOGGING(__x86_64_inventec_d6432_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef x86_64_inventec_d6432_CONFIG_LOG_OPTIONS_DEFAULT - { __x86_64_inventec_d6432_config_STRINGIFY_NAME(x86_64_inventec_d6432_CONFIG_LOG_OPTIONS_DEFAULT), __x86_64_inventec_d6432_config_STRINGIFY_VALUE(x86_64_inventec_d6432_CONFIG_LOG_OPTIONS_DEFAULT) }, -#else -{ x86_64_inventec_d6432_CONFIG_LOG_OPTIONS_DEFAULT(__x86_64_inventec_d6432_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef x86_64_inventec_d6432_CONFIG_LOG_BITS_DEFAULT - { __x86_64_inventec_d6432_config_STRINGIFY_NAME(x86_64_inventec_d6432_CONFIG_LOG_BITS_DEFAULT), __x86_64_inventec_d6432_config_STRINGIFY_VALUE(x86_64_inventec_d6432_CONFIG_LOG_BITS_DEFAULT) }, -#else -{ x86_64_inventec_d6432_CONFIG_LOG_BITS_DEFAULT(__x86_64_inventec_d6432_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef x86_64_inventec_d6432_CONFIG_LOG_CUSTOM_BITS_DEFAULT - { __x86_64_inventec_d6432_config_STRINGIFY_NAME(x86_64_inventec_d6432_CONFIG_LOG_CUSTOM_BITS_DEFAULT), __x86_64_inventec_d6432_config_STRINGIFY_VALUE(x86_64_inventec_d6432_CONFIG_LOG_CUSTOM_BITS_DEFAULT) }, -#else -{ x86_64_inventec_d6432_CONFIG_LOG_CUSTOM_BITS_DEFAULT(__x86_64_inventec_d6432_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef x86_64_inventec_d6432_CONFIG_PORTING_STDLIB - { __x86_64_inventec_d6432_config_STRINGIFY_NAME(x86_64_inventec_d6432_CONFIG_PORTING_STDLIB), __x86_64_inventec_d6432_config_STRINGIFY_VALUE(x86_64_inventec_d6432_CONFIG_PORTING_STDLIB) }, -#else -{ x86_64_inventec_d6432_CONFIG_PORTING_STDLIB(__x86_64_inventec_d6432_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef x86_64_inventec_d6432_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS - { __x86_64_inventec_d6432_config_STRINGIFY_NAME(x86_64_inventec_d6432_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS), __x86_64_inventec_d6432_config_STRINGIFY_VALUE(x86_64_inventec_d6432_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS) }, -#else -{ x86_64_inventec_d6432_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS(__x86_64_inventec_d6432_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef x86_64_inventec_d6432_CONFIG_INCLUDE_UCLI - { __x86_64_inventec_d6432_config_STRINGIFY_NAME(x86_64_inventec_d6432_CONFIG_INCLUDE_UCLI), __x86_64_inventec_d6432_config_STRINGIFY_VALUE(x86_64_inventec_d6432_CONFIG_INCLUDE_UCLI) }, -#else -{ x86_64_inventec_d6432_CONFIG_INCLUDE_UCLI(__x86_64_inventec_d6432_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef x86_64_inventec_d6432_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION - { __x86_64_inventec_d6432_config_STRINGIFY_NAME(x86_64_inventec_d6432_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION), __x86_64_inventec_d6432_config_STRINGIFY_VALUE(x86_64_inventec_d6432_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION) }, -#else -{ x86_64_inventec_d6432_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION(__x86_64_inventec_d6432_config_STRINGIFY_NAME), "__undefined__" }, -#endif - { NULL, NULL } -}; -#undef __x86_64_inventec_d6432_config_STRINGIFY_VALUE -#undef __x86_64_inventec_d6432_config_STRINGIFY_NAME - -const char* -x86_64_inventec_d6432_config_lookup(const char* setting) -{ - int i; - for(i = 0; x86_64_inventec_d6432_config_settings[i].name; i++) { - if(strcmp(x86_64_inventec_d6432_config_settings[i].name, setting)) { - return x86_64_inventec_d6432_config_settings[i].value; - } - } - return NULL; -} - -int -x86_64_inventec_d6432_config_show(struct aim_pvs_s* pvs) -{ - int i; - for(i = 0; x86_64_inventec_d6432_config_settings[i].name; i++) { - aim_printf(pvs, "%s = %s\n", x86_64_inventec_d6432_config_settings[i].name, x86_64_inventec_d6432_config_settings[i].value); - } - return i; -} - -/* */ - diff --git a/packages/platforms/inventec/x86-64/d6432/onlp/builds/x86_64_inventec_d6432/module/src/x86_64_inventec_d6432_enums.c b/packages/platforms/inventec/x86-64/d6432/onlp/builds/x86_64_inventec_d6432/module/src/x86_64_inventec_d6432_enums.c deleted file mode 100644 index fc965b018..000000000 --- a/packages/platforms/inventec/x86-64/d6432/onlp/builds/x86_64_inventec_d6432/module/src/x86_64_inventec_d6432_enums.c +++ /dev/null @@ -1,10 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#include - -/* <--auto.start.enum(ALL).source> */ -/* */ - diff --git a/packages/platforms/inventec/x86-64/d6432/onlp/builds/x86_64_inventec_d6432/module/src/x86_64_inventec_d6432_int.h b/packages/platforms/inventec/x86-64/d6432/onlp/builds/x86_64_inventec_d6432/module/src/x86_64_inventec_d6432_int.h deleted file mode 100644 index cb5c2e36a..000000000 --- a/packages/platforms/inventec/x86-64/d6432/onlp/builds/x86_64_inventec_d6432/module/src/x86_64_inventec_d6432_int.h +++ /dev/null @@ -1,12 +0,0 @@ -/**************************************************************************//** - * - * x86_64_inventec_d6432 Internal Header - * - *****************************************************************************/ -#ifndef __x86_64_inventec_d6432_INT_H__ -#define __x86_64_inventec_d6432_INT_H__ - -#include - - -#endif /* __x86_64_inventec_d6432_INT_H__ */ diff --git a/packages/platforms/inventec/x86-64/d6432/onlp/builds/x86_64_inventec_d6432/module/src/x86_64_inventec_d6432_log.c b/packages/platforms/inventec/x86-64/d6432/onlp/builds/x86_64_inventec_d6432/module/src/x86_64_inventec_d6432_log.c deleted file mode 100644 index 45d66339b..000000000 --- a/packages/platforms/inventec/x86-64/d6432/onlp/builds/x86_64_inventec_d6432/module/src/x86_64_inventec_d6432_log.c +++ /dev/null @@ -1,18 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#include - -#include "x86_64_inventec_d6432_log.h" -/* - * x86_64_inventec_d6432 log struct. - */ -AIM_LOG_STRUCT_DEFINE( - x86_64_inventec_d6432_CONFIG_LOG_OPTIONS_DEFAULT, - x86_64_inventec_d6432_CONFIG_LOG_BITS_DEFAULT, - NULL, /* Custom log map */ - x86_64_inventec_d6432_CONFIG_LOG_CUSTOM_BITS_DEFAULT - ); - diff --git a/packages/platforms/inventec/x86-64/d6432/onlp/builds/x86_64_inventec_d6432/module/src/x86_64_inventec_d6432_log.h b/packages/platforms/inventec/x86-64/d6432/onlp/builds/x86_64_inventec_d6432/module/src/x86_64_inventec_d6432_log.h deleted file mode 100644 index 5ac7e2ec3..000000000 --- a/packages/platforms/inventec/x86-64/d6432/onlp/builds/x86_64_inventec_d6432/module/src/x86_64_inventec_d6432_log.h +++ /dev/null @@ -1,12 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#ifndef __x86_64_inventec_d6432_LOG_H__ -#define __x86_64_inventec_d6432_LOG_H__ - -#define AIM_LOG_MODULE_NAME x86_64_inventec_d6432 -#include - -#endif /* __x86_64_inventec_d6432_LOG_H__ */ diff --git a/packages/platforms/inventec/x86-64/d6432/onlp/builds/x86_64_inventec_d6432/module/src/x86_64_inventec_d6432_module.c b/packages/platforms/inventec/x86-64/d6432/onlp/builds/x86_64_inventec_d6432/module/src/x86_64_inventec_d6432_module.c deleted file mode 100644 index cbc6a49cd..000000000 --- a/packages/platforms/inventec/x86-64/d6432/onlp/builds/x86_64_inventec_d6432/module/src/x86_64_inventec_d6432_module.c +++ /dev/null @@ -1,25 +0,0 @@ - -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#include - -#include "x86_64_inventec_d6432_log.h" - -static int -datatypes_init__(void) -{ -#define x86_64_inventec_d6432_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_d6432_module_init__(void) -{ - AIM_LOG_STRUCT_REGISTER(); - datatypes_init__(); -} - -int __onlp_platform_version__ = 1; diff --git a/packages/platforms/inventec/x86-64/d6432/onlp/builds/x86_64_inventec_d6432/module/src/x86_64_inventec_d6432_ucli.c b/packages/platforms/inventec/x86-64/d6432/onlp/builds/x86_64_inventec_d6432/module/src/x86_64_inventec_d6432_ucli.c deleted file mode 100644 index 99e062087..000000000 --- a/packages/platforms/inventec/x86-64/d6432/onlp/builds/x86_64_inventec_d6432/module/src/x86_64_inventec_d6432_ucli.c +++ /dev/null @@ -1,50 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#include - -#if x86_64_inventec_d6432_CONFIG_INCLUDE_UCLI == 1 - -#include -#include -#include - -static ucli_status_t -x86_64_inventec_d6432_ucli_ucli__config__(ucli_context_t* uc) -{ - UCLI_HANDLER_MACRO_MODULE_CONFIG(x86_64_inventec_d6432) -} - -/* */ -/* */ - -static ucli_module_t -x86_64_inventec_d6432_ucli_module__ = - { - "x86_64_inventec_d6432_ucli", - NULL, - x86_64_inventec_d6432_ucli_ucli_handlers__, - NULL, - NULL, - }; - -ucli_node_t* -x86_64_inventec_d6432_ucli_node_create(void) -{ - ucli_node_t* n; - ucli_module_init(&x86_64_inventec_d6432_ucli_module__); - n = ucli_node_create("x86_64_inventec_d6432", NULL, &x86_64_inventec_d6432_ucli_module__); - ucli_node_subnode_add(n, ucli_module_log_node_create("x86_64_inventec_d6432")); - return n; -} - -#else -void* -x86_64_inventec_d6432_ucli_node_create(void) -{ - return NULL; -} -#endif - diff --git a/packages/platforms/inventec/x86-64/d6432/platform-config/Makefile b/packages/platforms/inventec/x86-64/d6432/platform-config/Makefile deleted file mode 100644 index 003238cf6..000000000 --- a/packages/platforms/inventec/x86-64/d6432/platform-config/Makefile +++ /dev/null @@ -1 +0,0 @@ -include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/inventec/x86-64/d6432/platform-config/r0/Makefile b/packages/platforms/inventec/x86-64/d6432/platform-config/r0/Makefile deleted file mode 100644 index 003238cf6..000000000 --- a/packages/platforms/inventec/x86-64/d6432/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/inventec/x86-64/d6432/platform-config/r0/PKG.yml b/packages/platforms/inventec/x86-64/d6432/platform-config/r0/PKG.yml deleted file mode 100644 index 5ace23113..000000000 --- a/packages/platforms/inventec/x86-64/d6432/platform-config/r0/PKG.yml +++ /dev/null @@ -1 +0,0 @@ -!include $ONL_TEMPLATES/platform-config-platform.yml ARCH=amd64 VENDOR=inventec BASENAME=x86-64-inventec-d6432 REVISION=r0 diff --git a/packages/platforms/inventec/x86-64/d6432/platform-config/r0/src/lib/x86-64-inventec-d6432-r0.yml b/packages/platforms/inventec/x86-64/d6432/platform-config/r0/src/lib/x86-64-inventec-d6432-r0.yml deleted file mode 100644 index 9cd2d4034..000000000 --- a/packages/platforms/inventec/x86-64/d6432/platform-config/r0/src/lib/x86-64-inventec-d6432-r0.yml +++ /dev/null @@ -1,31 +0,0 @@ ---- - -###################################################################### -# -# platform-config for d6432 -# -###################################################################### - -x86-64-inventec-d6432-r0: - - grub: - - serial: >- - --port=0x3f8 - --speed=115200 - --word=8 - --parity=no - --stop=1 - - kernel: - <<: *kernel-4-14 - - args: >- - nopat - console=ttyS0,115200n8 - - ##network - ## interfaces: - ## ma1: - ## name: ~ - ## syspath: pci0000:00/0000:00:14.0 diff --git a/packages/platforms/inventec/x86-64/d6432/platform-config/r0/src/python/x86_64_inventec_d6432_r0/__init__.py b/packages/platforms/inventec/x86-64/d6432/platform-config/r0/src/python/x86_64_inventec_d6432_r0/__init__.py deleted file mode 100644 index d16dfe35c..000000000 --- a/packages/platforms/inventec/x86-64/d6432/platform-config/r0/src/python/x86_64_inventec_d6432_r0/__init__.py +++ /dev/null @@ -1,79 +0,0 @@ -from onl.platform.base import * -from onl.platform.inventec import * -import logging - -class OnlPlatform_x86_64_inventec_d6432_r0(OnlPlatformInventec, - OnlPlatformPortConfig_32x400): - PLATFORM='x86-64-inventec-d6432-r0' - MODEL="D6432" - SYS_OBJECT_ID=".6432.1" - CHASSIS_FAN_NUM=6 - FAN_VPD_CHANNEL=3 - FAN_VPD_ADDR_BASE=0x52 - - _path_prefix_list=[ - "/sys/bus/i2c/devices/2-0058/hwmon/", - "/sys/bus/i2c/devices/2-0059/hwmon/", - "/sys/devices/platform/coretemp.0/hwmon/", - "/sys/bus/i2c/devices/3-0018/hwmon/", - "/sys/bus/i2c/devices/3-0048/hwmon/", - "/sys/bus/i2c/devices/3-0049/hwmon/", - "/sys/bus/i2c/devices/3-004a/hwmon/", - "/sys/bus/i2c/devices/3-004d/hwmon/", - "/sys/bus/i2c/devices/3-004e/hwmon/" - ] - _path_dst_list=[ - "/var/psu1", - "/var/psu2", - "/var/coretemp", - "/var/board_thermal_1", - "/var/board_thermal_2", - "/var/board_thermal_3", - "/var/board_thermal_4", - "/var/board_thermal_5", - "/var/board_thermal_6", - ] - - def baseconfig(self): - os.system("insmod /lib/modules/`uname -r`/kernel/drivers/gpio/gpio-ich.ko gpiobase=0") - self.insmod('i2c-gpio') - self.insmod('inv_ucd90160') - self.insmod('inv-i2c-mux-pca9641') - self.insmod('inv_psu') - self.insmod('inv_cpld') - self.insmod('inv_platform') - self.insmod('inv_eeprom') - self.new_i2c_device('inv_eeprom', 0x55, 2) - - for addr_offset in range(0,self.CHASSIS_FAN_NUM): - self.new_i2c_device('inv_eeprom',self.FAN_VPD_ADDR_BASE+addr_offset,self.FAN_VPD_CHANNEL) - - self.insmod('inv_sff') - self.insmod('vpd') - self.insmod('optoe') - for ch in range(0,32): - self.new_i2c_device('optoe1', 0x50, 14 + ch ) - - for i in range(0,len(self._path_prefix_list)): - if( os.path.islink(self._path_dst_list[i]) ): - os.unlink(self._path_dst_list[i]) - logging.warning("Path %s exists, remove before link again" % self._path_dst_list[i] ) - self.link_dir(self._path_prefix_list[i],self._path_dst_list[i]) - - return True - - def link_dir(self,prefix,dst): - ret=os.path.isdir(prefix) - if ret==True: - dirs=os.listdir(prefix) - ret=False - for i in range(0,len(dirs)): - if 'hwmon' in dirs[i]: - src=prefix+dirs[i] - os.symlink(src,dst) - ret=True - break - if ret==False: - logging.warning("Can't find proper dir to link under %s" % prefix) - else: - logging.warning("Path %s is not a dir" % prefix) \ No newline at end of file diff --git a/packages/platforms/inventec/x86-64/d6556/Makefile b/packages/platforms/inventec/x86-64/d6556/Makefile deleted file mode 100644 index 003238cf6..000000000 --- a/packages/platforms/inventec/x86-64/d6556/Makefile +++ /dev/null @@ -1 +0,0 @@ -include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/inventec/x86-64/d6556/modules/Makefile b/packages/platforms/inventec/x86-64/d6556/modules/Makefile deleted file mode 100644 index 003238cf6..000000000 --- a/packages/platforms/inventec/x86-64/d6556/modules/Makefile +++ /dev/null @@ -1 +0,0 @@ -include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/inventec/x86-64/d6556/modules/PKG.yml b/packages/platforms/inventec/x86-64/d6556/modules/PKG.yml deleted file mode 100644 index 8e1d3767e..000000000 --- a/packages/platforms/inventec/x86-64/d6556/modules/PKG.yml +++ /dev/null @@ -1 +0,0 @@ -!include $ONL_TEMPLATES/platform-modules.yml VENDOR=inventec BASENAME=x86-64-inventec-d6556 ARCH=amd64 KERNELS="onl-kernel-3.16-lts-x86-64-all:amd64" diff --git a/packages/platforms/inventec/x86-64/d6556/modules/builds/.gitignore b/packages/platforms/inventec/x86-64/d6556/modules/builds/.gitignore deleted file mode 100644 index a65b41774..000000000 --- a/packages/platforms/inventec/x86-64/d6556/modules/builds/.gitignore +++ /dev/null @@ -1 +0,0 @@ -lib diff --git a/packages/platforms/inventec/x86-64/d6556/modules/builds/Makefile b/packages/platforms/inventec/x86-64/d6556/modules/builds/Makefile deleted file mode 100644 index 5fe8392a6..000000000 --- a/packages/platforms/inventec/x86-64/d6556/modules/builds/Makefile +++ /dev/null @@ -1,6 +0,0 @@ -KERNELS := onl-kernel-3.16-lts-x86-64-all:amd64 -KMODULES := src -VENDOR := inventec -BASENAME := x86-64-inventec-d6556 -ARCH := x86_64 -include $(ONL)/make/kmodule.mk diff --git a/packages/platforms/inventec/x86-64/d6556/modules/builds/src/Makefile b/packages/platforms/inventec/x86-64/d6556/modules/builds/src/Makefile deleted file mode 100644 index 47b3610f0..000000000 --- a/packages/platforms/inventec/x86-64/d6556/modules/builds/src/Makefile +++ /dev/null @@ -1,8 +0,0 @@ -obj-m += i2c-gpio.o -obj-m += inv_cpld.o inv_psoc.o -obj-m += inv_platform.o -obj-m += inv_pthread.o -obj-m += swps.o -swps-objs := inv_swps.o io_expander.o inv_mux.o transceiver.o -obj-m += vpd.o -vpd-objs := inv_vpd.o onie_tlvinfo.o diff --git a/packages/platforms/inventec/x86-64/d6556/modules/builds/src/i2c-gpio.c b/packages/platforms/inventec/x86-64/d6556/modules/builds/src/i2c-gpio.c deleted file mode 100644 index 71a45b210..000000000 --- a/packages/platforms/inventec/x86-64/d6556/modules/builds/src/i2c-gpio.c +++ /dev/null @@ -1,293 +0,0 @@ -/* - * Bitbanging I2C bus driver using the GPIO API - * - * Copyright (C) 2007 Atmel Corporation - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. - */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -struct i2c_gpio_private_data { - struct i2c_adapter adap; - struct i2c_algo_bit_data bit_data; - struct i2c_gpio_platform_data pdata; -}; - -/* Toggle SDA by changing the direction of the pin */ -static void i2c_gpio_setsda_dir(void *data, int state) -{ - struct i2c_gpio_platform_data *pdata = data; - - if (state) - gpio_direction_input(pdata->sda_pin); - else - gpio_direction_output(pdata->sda_pin, 0); -} - -/* - * Toggle SDA by changing the output value of the pin. This is only - * valid for pins configured as open drain (i.e. setting the value - * high effectively turns off the output driver.) - */ -static void i2c_gpio_setsda_val(void *data, int state) -{ - struct i2c_gpio_platform_data *pdata = data; - - gpio_set_value(pdata->sda_pin, state); -} - -/* Toggle SCL by changing the direction of the pin. */ -static void i2c_gpio_setscl_dir(void *data, int state) -{ - struct i2c_gpio_platform_data *pdata = data; - - if (state) - gpio_direction_input(pdata->scl_pin); - else - gpio_direction_output(pdata->scl_pin, 0); -} - -/* - * Toggle SCL by changing the output value of the pin. This is used - * for pins that are configured as open drain and for output-only - * pins. The latter case will break the i2c protocol, but it will - * often work in practice. - */ -static void i2c_gpio_setscl_val(void *data, int state) -{ - struct i2c_gpio_platform_data *pdata = data; - - gpio_set_value(pdata->scl_pin, state); -} - -static int i2c_gpio_getsda(void *data) -{ - struct i2c_gpio_platform_data *pdata = data; - - return gpio_get_value(pdata->sda_pin); -} - -static int i2c_gpio_getscl(void *data) -{ - struct i2c_gpio_platform_data *pdata = data; - - return gpio_get_value(pdata->scl_pin); -} - -static int of_i2c_gpio_get_pins(struct device_node *np, - unsigned int *sda_pin, unsigned int *scl_pin) -{ - if (of_gpio_count(np) < 2) - return -ENODEV; - - *sda_pin = of_get_gpio(np, 0); - *scl_pin = of_get_gpio(np, 1); - - if (*sda_pin == -EPROBE_DEFER || *scl_pin == -EPROBE_DEFER) - return -EPROBE_DEFER; - - if (!gpio_is_valid(*sda_pin) || !gpio_is_valid(*scl_pin)) { - pr_err("%s: invalid GPIO pins, sda=%d/scl=%d\n", - np->full_name, *sda_pin, *scl_pin); - return -ENODEV; - } - - return 0; -} - -static void of_i2c_gpio_get_props(struct device_node *np, - struct i2c_gpio_platform_data *pdata) -{ - u32 reg; - - of_property_read_u32(np, "i2c-gpio,delay-us", &pdata->udelay); - - if (!of_property_read_u32(np, "i2c-gpio,timeout-ms", ®)) - pdata->timeout = msecs_to_jiffies(reg); - - pdata->sda_is_open_drain = - of_property_read_bool(np, "i2c-gpio,sda-open-drain"); - pdata->scl_is_open_drain = - of_property_read_bool(np, "i2c-gpio,scl-open-drain"); - pdata->scl_is_output_only = - of_property_read_bool(np, "i2c-gpio,scl-output-only"); -} - -static int i2c_gpio_probe(struct platform_device *pdev) -{ - struct i2c_gpio_private_data *priv; - struct i2c_gpio_platform_data *pdata; - struct i2c_algo_bit_data *bit_data; - struct i2c_adapter *adap; - unsigned int sda_pin, scl_pin; - int ret; - - /* First get the GPIO pins; if it fails, we'll defer the probe. */ - if (pdev->dev.of_node) { - ret = of_i2c_gpio_get_pins(pdev->dev.of_node, - &sda_pin, &scl_pin); - if (ret) - return ret; - } else { - if (!dev_get_platdata(&pdev->dev)) - return -ENXIO; - pdata = dev_get_platdata(&pdev->dev); - sda_pin = pdata->sda_pin; - scl_pin = pdata->scl_pin; - } - - ret = devm_gpio_request(&pdev->dev, sda_pin, "sda"); - if (ret) { - if (ret == -EINVAL) - ret = -EPROBE_DEFER; /* Try again later */ - return ret; - } - ret = devm_gpio_request(&pdev->dev, scl_pin, "scl"); - if (ret) { - if (ret == -EINVAL) - ret = -EPROBE_DEFER; /* Try again later */ - return ret; - } - - priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL); - if (!priv) - return -ENOMEM; - adap = &priv->adap; - bit_data = &priv->bit_data; - pdata = &priv->pdata; - - if (pdev->dev.of_node) { - pdata->sda_pin = sda_pin; - pdata->scl_pin = scl_pin; - of_i2c_gpio_get_props(pdev->dev.of_node, pdata); - } else { - memcpy(pdata, dev_get_platdata(&pdev->dev), sizeof(*pdata)); - } - - if (pdata->sda_is_open_drain) { - gpio_direction_output(pdata->sda_pin, 1); - bit_data->setsda = i2c_gpio_setsda_val; - } else { - gpio_direction_input(pdata->sda_pin); - bit_data->setsda = i2c_gpio_setsda_dir; - } - - if (pdata->scl_is_open_drain || pdata->scl_is_output_only) { - gpio_direction_output(pdata->scl_pin, 1); - bit_data->setscl = i2c_gpio_setscl_val; - } else { - gpio_direction_input(pdata->scl_pin); - bit_data->setscl = i2c_gpio_setscl_dir; - } - - if (!pdata->scl_is_output_only) - bit_data->getscl = i2c_gpio_getscl; - bit_data->getsda = i2c_gpio_getsda; - - if (pdata->udelay) - bit_data->udelay = pdata->udelay; - else if (pdata->scl_is_output_only) - bit_data->udelay = 50; /* 10 kHz */ - else - bit_data->udelay = 5; /* 100 kHz */ - - if (pdata->timeout) - bit_data->timeout = pdata->timeout; - else - bit_data->timeout = HZ / 10; /* 100 ms */ - - bit_data->data = pdata; - - adap->owner = THIS_MODULE; - if (pdev->dev.of_node) - strlcpy(adap->name, dev_name(&pdev->dev), sizeof(adap->name)); - else - snprintf(adap->name, sizeof(adap->name), "i2c-gpio%d", pdev->id); - - adap->algo_data = bit_data; - adap->class = I2C_CLASS_HWMON | I2C_CLASS_SPD; - adap->dev.parent = &pdev->dev; - adap->dev.of_node = pdev->dev.of_node; - - adap->nr = pdev->id; - ret = i2c_bit_add_numbered_bus(adap); - if (ret) - return ret; - - platform_set_drvdata(pdev, priv); - - dev_info(&pdev->dev, "using pins %u (SDA) and %u (SCL%s)\n", - pdata->sda_pin, pdata->scl_pin, - pdata->scl_is_output_only - ? ", no clock stretching" : ""); - - return 0; -} - -static int i2c_gpio_remove(struct platform_device *pdev) -{ - struct i2c_gpio_private_data *priv; - struct i2c_gpio_platform_data *pdata; - struct i2c_adapter *adap; - - priv = platform_get_drvdata(pdev); - adap = &priv->adap; - pdata = &priv->pdata; - - i2c_del_adapter(adap); - - return 0; -} - -#if defined(CONFIG_OF) -static const struct of_device_id i2c_gpio_dt_ids[] = { - { .compatible = "i2c-gpio", }, - { /* sentinel */ } -}; - -MODULE_DEVICE_TABLE(of, i2c_gpio_dt_ids); -#endif - -static struct platform_driver i2c_gpio_driver = { - .driver = { - .name = "i2c-gpio", - .owner = THIS_MODULE, - .of_match_table = of_match_ptr(i2c_gpio_dt_ids), - }, - .probe = i2c_gpio_probe, - .remove = i2c_gpio_remove, -}; - -static int __init i2c_gpio_init(void) -{ - int ret; - - ret = platform_driver_register(&i2c_gpio_driver); - if (ret) - printk(KERN_ERR "i2c-gpio: probe failed: %d\n", ret); - - return ret; -} -subsys_initcall(i2c_gpio_init); - -static void __exit i2c_gpio_exit(void) -{ - platform_driver_unregister(&i2c_gpio_driver); -} -module_exit(i2c_gpio_exit); - -MODULE_AUTHOR("Haavard Skinnemoen (Atmel)"); -MODULE_DESCRIPTION("Platform-independent bitbanging I2C driver"); -MODULE_LICENSE("GPL"); -MODULE_ALIAS("platform:i2c-gpio"); diff --git a/packages/platforms/inventec/x86-64/d6556/modules/builds/src/inv_cpld.c b/packages/platforms/inventec/x86-64/d6556/modules/builds/src/inv_cpld.c deleted file mode 100644 index 73135c5fa..000000000 --- a/packages/platforms/inventec/x86-64/d6556/modules/builds/src/inv_cpld.c +++ /dev/null @@ -1,637 +0,0 @@ -/* - * 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 "inv_pthread.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 -#define CPLD_BIOSCS_OFFSET 0x04 -#define CPLD_PSUFANLED_OFFSET 0x75 - -/* Each client has this additional data */ -struct cpld_data { - struct device *hwmon_dev; - struct mutex update_lock; -}; - -static struct device *cpld_led_client_dev = NULL; - -/*-----------------------------------------------------------------------*/ - -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; -} - -ssize_t cpld_show_ctl(char *buf) -{ - u32 status; - struct i2c_client *client = NULL; - struct cpld_data *data = NULL; - u8 b[1]; - - if (!cpld_led_client_dev) { - return 0; - } - - client = to_i2c_client(cpld_led_client_dev); - data = i2c_get_clientdata(client); - - 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); -} -EXPORT_SYMBOL(cpld_show_ctl); - -ssize_t cpld_set_ctl(const char *buf, size_t count) -{ - struct i2c_client *client = NULL; - struct cpld_data *data = NULL; - u8 byte; - u8 temp = simple_strtol(buf, NULL, 10); - - if (!cpld_led_client_dev) { - return 0; - } - - client = to_i2c_client(cpld_led_client_dev); - data = i2c_get_clientdata(client); - - 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; -} -EXPORT_SYMBOL(cpld_set_ctl); - -static ssize_t show_bios_cs(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_BIOSCS_OFFSET, 1); - - mutex_unlock(&data->update_lock); - - if(status != 1) return sprintf(buf, "read cpld BIOS_CS fail\n"); - - - status = sprintf (buf, "0x%X\n", b[0] & 0x01); - - return strlen(buf); -} - -static ssize_t set_bios_cs(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_BIOSCS_OFFSET, 1); - if(temp) byte |= 0x01; - else byte &= ~(0x01); - cpld_i2c_write(client, &byte, CPLD_BIOSCS_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 - "4 Hz", //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; - - status = sprintf (buf, "%d: %s\n", byte, led_str[byte]); - - return strlen(buf); -} - -ssize_t cpld_show_led(char *buf, int index) -{ - u32 status; - struct i2c_client *client = NULL; - struct cpld_data *data = NULL; - u8 byte; - int shift = (index == CPLD_DEV_LED_GRN_INDEX)?3:0; - - if (!cpld_led_client_dev) { - return 0; - } - - client = to_i2c_client(cpld_led_client_dev); - data = i2c_get_clientdata(client); - - 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; - - status = sprintf (buf, "%d: %s\n", byte, led_str[byte]); - - return strlen(buf); -} -EXPORT_SYMBOL(cpld_show_led); - -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; -} - -ssize_t cpld_set_led(const char *buf, size_t count, int index) -{ - struct i2c_client *client = NULL; - struct cpld_data *data = NULL; - - u8 temp = simple_strtol(buf, NULL, 16); - u8 byte; - int shift = (index == CPLD_DEV_LED_GRN_INDEX)?3:0; - - if (!cpld_led_client_dev) { - return 0; - } - - client = to_i2c_client(cpld_led_client_dev); - data = i2c_get_clientdata(client); - - 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; -} -EXPORT_SYMBOL(cpld_set_led); - -/* -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 char* status_psufan_str[] = { - "OFF", //00 - "ON", //01 - "1 Hz", //10 - "2 Hz", //11 -}; - -static ssize_t show_psufan_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 red_status, grn_status, byte; - int shift = (attr->index == 0)?0:2; - - mutex_lock(&data->update_lock); - status = cpld_i2c_read(client, &byte, CPLD_PSUFANLED_OFFSET, 1); - mutex_unlock(&data->update_lock); - - byte = (byte>>shift) & 0x33; - grn_status = byte >> 4; - red_status = byte & 0x03; - - return sprintf (buf, "0x%02x: Green %s , Red %s\n", byte, status_psufan_str[grn_status],status_psufan_str[red_status]); -} - -static ssize_t set_psufan_led(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 cpld_data *data = i2c_get_clientdata(client); - int shift = (attr->index == 0)?0:2; - int mask = (attr->index == 0)?0xcc:0x33; - u8 temp = simple_strtol(buf, NULL, 16) & 0x33; - u8 byte = 0; - - mutex_lock(&data->update_lock); - cpld_i2c_read(client, &byte, CPLD_PSUFANLED_OFFSET, 1); - byte &= mask; - byte |= (temp<update_lock); - - return count; -} - - -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 SENSOR_DEVICE_ATTR(fan_led, S_IWUSR|S_IRUGO, show_psufan_led, set_psufan_led, 0); -static SENSOR_DEVICE_ATTR(psu_led, S_IWUSR|S_IRUGO, show_psufan_led, set_psufan_led, 1); - -static SENSOR_DEVICE_ATTR(bios_cs, S_IWUSR|S_IRUGO, show_bios_cs, set_bios_cs, 0); - -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, - - &sensor_dev_attr_fan_led.dev_attr.attr, - &sensor_dev_attr_psu_led.dev_attr.attr, - - &sensor_dev_attr_bios_cs.dev_attr.attr, - - NULL -}; - -static const struct attribute_group cpld_group = { - .attrs = cpld_attributes, -}; - -static struct attribute *cpld2_attributes[] = { - //info - &sensor_dev_attr_info.dev_attr.attr, - - NULL -}; - -static const struct attribute_group cpld2_group = { - .attrs = cpld2_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 */ - if(id->driver_data==1) // CPLD2 - status = sysfs_create_group(&client->dev.kobj, &cpld2_group); - else // default CPLD1 - 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); - - cpld_led_client_dev = &client->dev; - return 0; - -exit_remove: - sysfs_remove_group(&client->dev.kobj, &cpld_group); -exit_free: - i2c_set_clientdata(client, NULL); - kfree(data); - cpld_led_client_dev = NULL; - 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); - cpld_led_client_dev = NULL; - return 0; -} - -static const struct i2c_device_id cpld_ids[] = { - { "inv_cpld" , 0, }, - { "inv_cpld2", 1, }, - { /* 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/d6556/modules/builds/src/inv_mux.c b/packages/platforms/inventec/x86-64/d6556/modules/builds/src/inv_mux.c deleted file mode 100644 index 89e95f12f..000000000 --- a/packages/platforms/inventec/x86-64/d6556/modules/builds/src/inv_mux.c +++ /dev/null @@ -1,275 +0,0 @@ -#include -#include -#include -#include -#include -#include "io_expander.h" -#include "inv_mux.h" - -static struct mux_obj_s *mux_head_p = NULL; - - -/* ========== MUX object functions ========== - */ -int -_common_force_pull_gpio(int mem_addr, - int input, - int bit_offset){ - - unsigned int val = 0; - unsigned int targ = 0; - - /* Get current value */ - val = inl(mem_addr); - if (val == 0) { - SWPS_ERR("%s: inl:%d fail!\n", __func__, val); - return -1; - } - /* Count target value */ - switch (input) { - case 0: /* Pull Low */ - targ = (val & (~(1 << bit_offset))); - break; - case 1: /* Pull high */ - targ = (val | (1 << bit_offset)); - break; - default: - SWPS_ERR("%s: input state:%d incorrect!\n", - __func__, input); - return -1; - } - /* Setup gpio */ - outl(targ, mem_addr); - if (targ != inl(mem_addr)){ - SWPS_ERR("%s: outl:%d fail!\n", __func__, targ); - return -1; - } - SWPS_DEBUG("%s: done.\n", __func__); - return 0; -} - - -int -rangeley_force_pull_high(struct mux_obj_s *self){ - SWPS_ERR("%s: not ready!\n", __func__); - return -1; -} - - -int -rangeley_force_pull_low(struct mux_obj_s *self){ - SWPS_ERR("%s: not ready!\n", __func__); - return -1; -} - - -int -hedera_force_pull_high(struct mux_obj_s *self){ - return _common_force_pull_gpio(MUX_RST_MEM_ADDR_HEDERA, 1, 5); -} - - -int -hedera_force_pull_low(struct mux_obj_s *self){ - return _common_force_pull_gpio(MUX_RST_MEM_ADDR_HEDERA, 0, 5); -} - - -int -normal_gpio_pull_high(struct mux_obj_s *self){ - return gpio_direction_output(self->gpio_num, 1); -} - - -int -normal_gpio_pull_low(struct mux_obj_s *self){ - return gpio_direction_output(self->gpio_num, 0); -} - - -int -pca9548_reset_mux_all(struct mux_obj_s *self){ - /* [Note] Power-on reset (PCA9548A-NXP) - * When power is applied to VDD, an internal Power-On Reset (POR) - * holds the PCA9548A in a reset condition until VDD has reached - * VPOR. At this point, the reset condition is released and the - * PCA9548A register and I2C-bus state machine are initialized to - * their default states (all zeroes) causing all the channels to - * be deselected. Thereafter, VDD must be lowered below 0.2 V for - * at least 5 us in order to reset the device. - */ - if (self->_pull_low(self) < 0) { - SWPS_ERR("%s: _pull_low fail!\n", __func__); - return -1; - } - mdelay(MUX_RST_WAIT_MS); - if (self->_pull_high(self) < 0) { - SWPS_ERR("%s: _pull_high fail!\n", __func__); - return -1; - } - mdelay(MUX_RST_WAIT_MS); - return 0; -} - - -int -common_reset_mux_all(struct mux_obj_s *self){ - SWPS_ERR("%s: not ready!\n", __func__); - return -1; -} - - -int -init_gpio_4_force(struct mux_obj_s *self){ - return 0; -} - - -int -init_gpio_4_normal(struct mux_obj_s *self){ - - int err = 0; - - if (!gpio_is_valid(self->gpio_num)) { - SWPS_ERR("%s: GIPO:%d isn't valid\n", __func__, self->gpio_num); - return -1; - } - err = gpio_request(self->gpio_num, MUX_GPIO_LABEL); - if (err < 0) { - SWPS_ERR("%s: gpio_request fail :%d :%d\n", - __func__, err, self->gpio_num); - return -1; - } - SWPS_DEBUG("%s: gpio_request:%d ok.\n", __func__, self->gpio_num); - return 0; -} - - -static int -_setup_muxctl_cb(struct mux_obj_s *self, - unsigned gpio){ - - char mod_dsc[32] = "ERR"; - - switch (gpio) { - case MUX_RST_GPIO_FORCE_RANGELEY: - self->gpio_num = gpio; - self->_pull_low = rangeley_force_pull_low; - self->_pull_high = rangeley_force_pull_high; - self->_init = init_gpio_4_force; - self->reset = pca9548_reset_mux_all; - memset(mod_dsc, 0, 32); - snprintf(mod_dsc, 31, "Rangeley force mode"); - goto ok_setup_muxctl_cb; - - case MUX_RST_GPIO_FORCE_HEDERA: - self->gpio_num = gpio; - self->_pull_low = hedera_force_pull_low; - self->_pull_high = hedera_force_pull_high; - self->_init = init_gpio_4_force; - self->reset = pca9548_reset_mux_all; - memset(mod_dsc, 0, 32); - snprintf(mod_dsc, 31, "Hedera force mode"); - goto ok_setup_muxctl_cb; - - case MUX_RST_GPIO_48_PAC9548: - case MUX_RST_GPIO_69_PAC9548: - case MUX_RST_GPIO_249_PCA9548: - case MUX_RST_GPIO_500_PAC9548: - case MUX_RST_GPIO_505_PCA9548: - self->gpio_num = gpio; - self->_pull_low = normal_gpio_pull_low; - self->_pull_high = normal_gpio_pull_high; - self->_init = init_gpio_4_normal; - self->reset = pca9548_reset_mux_all; - memset(mod_dsc, 0, 32); - snprintf(mod_dsc, 31, "Normal mode :%d", (int)gpio); - goto ok_setup_muxctl_cb; - - default: - break; - } - SWPS_ERR("%s: Unexpected GPIO:%d\n", __func__, gpio); - return -1; - -ok_setup_muxctl_cb: - SWPS_INFO("muxctl: %s.\n", mod_dsc); - return 0; -} - - -/* ========== MUX public functions ========== - */ -void -clean_mux_gpio(void){ - - if (!mux_head_p) { - SWPS_DEBUG("%s: mux_head_p is NULL\n", __func__); - return; - } - if (gpio_is_valid(mux_head_p->gpio_num)) { - gpio_free(mux_head_p->gpio_num); - } - kfree(mux_head_p); - mux_head_p = NULL; - SWPS_DEBUG("%s: done.\n", __func__); -} - - -int -reset_mux_gpio(void){ - - if (!mux_head_p) { - SWPS_ERR("%s: MUX ctl object doesn't exist!\n", __func__); - return -1; - } - if (mux_head_p->reset(mux_head_p) < 0){ - SWPS_ERR("%s: reset fail!\n", __func__); - return -1; - } - return 0; -} - - -int -init_mux_gpio(unsigned gpio){ - - /* Create MUX control object */ - if (mux_head_p) { - SWPS_DEBUG("%s: mux_head_p is not NULL!\n", __func__); - clean_mux_gpio(); - } - /* Currently, it is using single muxctl architecture. - * In the future, it may use the multi-muxctl if HW add new features. - * (Ex: Port power-status control) - */ - mux_head_p = kzalloc(sizeof(struct mux_obj_s), GFP_KERNEL); - if (!mux_head_p) { - SWPS_ERR("%s: kzalloc fail!\n", __func__); - return -1; - } - /* Initial MUX controller */ - if (_setup_muxctl_cb(mux_head_p, gpio) < 0){ - SWPS_ERR("%s: _setup_muxctl_cb fail!\n", __func__); - return -1; - } - if (mux_head_p->_init(mux_head_p) < 0) { - SWPS_ERR("%s: init() fail\n", __func__); - goto err_init_mux_gpio; - } - /* Setup default value */ - if (mux_head_p->_pull_high(mux_head_p) < 0) { - SWPS_ERR("%s: setup default fail!\n", __func__); - goto err_init_mux_gpio; - } - return 0; - -err_init_mux_gpio: - clean_mux_gpio(); - return -1; -} - - - - - diff --git a/packages/platforms/inventec/x86-64/d6556/modules/builds/src/inv_mux.h b/packages/platforms/inventec/x86-64/d6556/modules/builds/src/inv_mux.h deleted file mode 100644 index ebed04445..000000000 --- a/packages/platforms/inventec/x86-64/d6556/modules/builds/src/inv_mux.h +++ /dev/null @@ -1,40 +0,0 @@ -#ifndef INV_MUX_H -#define INV_MUX_H - - -/* MUX basic information */ -#define MUX_GPIO_LABEL "SWPS_RST_MUX" - -/* MUX reset GPIO define */ -#define MUX_RST_GPIO_FORCE (30100) -#define MUX_RST_GPIO_FORCE_RANGELEY (30101) -#define MUX_RST_GPIO_FORCE_HEDERA (30102) -#define MUX_RST_GPIO_48_PAC9548 (48) -#define MUX_RST_GPIO_69_PAC9548 (69) -#define MUX_RST_GPIO_249_PCA9548 (249) -#define MUX_RST_GPIO_500_PAC9548 (500) -#define MUX_RST_GPIO_505_PCA9548 (505) - -/* MUX relate value define */ -#define MUX_RST_WAIT_MS (1) -#define MUX_RST_MEM_ADDR_RANGELEY (0) // TBD -#define MUX_RST_MEM_ADDR_HEDERA (0x548) - -struct mux_obj_s { - unsigned gpio_num; - int (*_pull_high)(struct mux_obj_s *self); - int (*_pull_low)(struct mux_obj_s *self); - int (*_init)(struct mux_obj_s *self); - int (*reset)(struct mux_obj_s *self); -}; - - -void clean_mux_gpio(void); -int reset_mux_gpio(void); -int init_mux_gpio(unsigned gpio); - - -#endif /* INV_MUX_H */ - - - diff --git a/packages/platforms/inventec/x86-64/d6556/modules/builds/src/inv_platform.c b/packages/platforms/inventec/x86-64/d6556/modules/builds/src/inv_platform.c deleted file mode 100644 index d98aab3b8..000000000 --- a/packages/platforms/inventec/x86-64/d6556/modules/builds/src/inv_platform.c +++ /dev/null @@ -1,222 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include - -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, 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 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[] = { - {bus_id(1), ARRAY_SIZE(i2c_device_info0), i2c_device_info0 }, //mux root - - {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 -}; - -///////////////////////////////////////////////////////////////////////////////////////// -static struct platform_device *device_i2c_gpio0; -static struct i2c_gpio_platform_data i2c_gpio_platdata0 = { - .scl_pin = 58, //494, - .sda_pin = 75, //511, - - .udelay = 5, //5:100kHz - .sda_is_open_drain = 0, - .scl_is_open_drain = 0, - .scl_is_output_only = 0 -}; - -static int __init inv_platform_init(void) -{ - struct i2c_adapter *adap = NULL; - struct i2c_client *e = NULL; - int ret = 0; - int i,j,k; - - //printk("%s \n", __func__); - - //use i2c-gpio - //register i2c gpio - //config gpio58,75 to gpio function 58=32+3*8+2 75=32*2+8*1+3 gpio69=32*2+8*0+5 - outl( inl(0x533) | (1<<2), 0x533); //i2c-gpio sdl (GPIO58) - outl( inl(0x541) | (1<<3), 0x541); //i2c-gpio sda (GPIO75) - outl( inl(0x540) | (1<<5), 0x540); //RST_I2C_MUX_N (GPIO69) - outl( inl(0x500) | (1<<7), 0x500); //SYS_RDY_N (GPIO7) - outl( inl(0x501) | (1<<7), 0x501); //BMC_HEART_BEAT (GPIO15) - outl( inl(0x503) | (1<<2)|(1<<3), 0x503); //PSOC_HEART_BEAT(26),CPLD_HEART_BEAT(27) - - device_i2c_gpio0 = platform_device_alloc("i2c-gpio", 1); - if (!device_i2c_gpio0) { - printk(KERN_ERR "i2c-gpio: platform_device_alloc fail\n"); - return -ENOMEM; - } - device_i2c_gpio0->name = "i2c-gpio"; - device_i2c_gpio0->id = 1; - device_i2c_gpio0->dev.platform_data = &i2c_gpio_platdata0; - - ret = platform_device_add(device_i2c_gpio0); - if (ret) { - printk(KERN_ERR "i2c-gpio: platform_device_add fail %d\n", ret); - } - - for(i=0; idev.platform_data = NULL; - platform_device_unregister(device_i2c_gpio0); -} - -module_init(inv_platform_init); -module_exit(inv_platform_exit); - -MODULE_AUTHOR("Inventec"); -MODULE_DESCRIPTION("Platform devices"); -MODULE_LICENSE("GPL"); diff --git a/packages/platforms/inventec/x86-64/d6556/modules/builds/src/inv_psoc.c b/packages/platforms/inventec/x86-64/d6556/modules/builds/src/inv_psoc.c deleted file mode 100644 index 2cd54255e..000000000 --- a/packages/platforms/inventec/x86-64/d6556/modules/builds/src/inv_psoc.c +++ /dev/null @@ -1,1109 +0,0 @@ -/* - * 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 -#include -#include -#include -#include -#define SWITCH_TEMPERATURE_SOCK "/proc/switch/temp" -#define PSOC_POLLING_PERIOD 1000 - -#include -#include -#include -#include - -#define IPMI_MAX_INTF (4) -#define NETFN_OEM 0x30 -#define CMD_GETDATA 0x31 -#define CMD_SETDATA 0x32 -#define FAN_NUM 4 -#define PSU_NUM 2 - -#define FAN_CLEI_SUPPORT 1 -#define PSU_CLEI_SUPPORT 0 - -#define PSU1 0x5800 -#define PSU2 0x5900 -#define BMC_PMBusNumber 3 -#define PMBus_Vendor 0x99 -#define PMBus_Serial 0x9E -#define PMBus_Temp2 0x8E -#define PMBus_Version 0x9B -#define MaxLeng_Result 0x40 - -#define BMC_FanCLEIBusNumber 9 -#define DEVICE_CLEI_ADDR 0x52,0x53,0x54,0x55,0x56,0x50,0x51 - -#define MAX_IPMI_RECV_LENGTH 0xff -static char CLEI_ADDR[]={DEVICE_CLEI_ADDR}; -struct task_struct *kthread_auto_update; -static long pmbus_reg2data_linear(int data, int linear16); -struct ipmi_result{ - char result[MAX_IPMI_RECV_LENGTH]; - int result_length; -}; - -DEFINE_MUTEX(ipmi_mutex); -DEFINE_MUTEX(ipmi2_mutex); -static struct ipmi_result ipmiresult; -static struct device *hwmon_dev; -static struct kobject *device_kobj; -static ipmi_user_t ipmi_mh_user = NULL; -static void msg_handler(struct ipmi_recv_msg *msg,void* handler_data); -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 -}; - -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__)) clei { - u8 issue_number[3]; - u8 abbreviation_number[9]; - u8 fc_number[10]; - u8 clei_code[10]; - u8 product_year_and_month[5]; - u8 label_location_code[2]; - u8 serial_number[5]; - u8 pcb_revision[5]; - u8 vendor_name[10]; - u8 reserved[5]; -}; - -struct __attribute__ ((__packed__)) psoc_layout { - u8 ctl; //offset: 0 - u16 switch_temp; //offset: 1 - - // BYTE[03:20] - voltage - u16 voltage[15]; //offset: 0x03-0x20 - - // BYTE[21:27] - ExtFan - u8 led_ctl2; //offset: 21 - u8 ext_pwm; //offset: 22 - u16 ext_rpm[2]; //offset: 23 - u8 gpi_fan2; //offset: 27 - - //gpo - u8 led_ctl; //offset: 28 - - u8 gpio; //offset: 29 - - //pwm duty - u8 pwm[4]; //offset: 2a - u8 pwm_psu[2]; //offset: 2e - - //fan rpm - u16 fan[4*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[2]; //offset: 50 - - //version - u8 version[2]; //offset: 54 - - u8 reserve2[4]; //offset: 56 - 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) -#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) - -#define PWM2_OFFSET PSOC_OFF(ext_pwm) -#define RPM2_OFFSET PSOC_OFF(ext_rpm) -#define FAN_LED2_OFFSET PSOC_OFF(led_ctl2) -#define FAN_GPI2_OFFSET PSOC_OFF(gpi_fan2) - -#define CLEI_OFF(m) offsetof(struct clei, m) -#define FAN1_CLEI_INDEX 0 -#define FAN2_CLEI_INDEX 1 -#define FAN3_CLEI_INDEX 2 -#define FAN4_CLEI_INDEX 3 -#define FAN5_CLEI_INDEX 4 -#define PSU1_CLEI_INDEX 5 -#define PSU2_CLEI_INDEX 6 - -static void msg_handler(struct ipmi_recv_msg *recv_msg,void* handler_data) -{ - struct ipmi_result *msg_result = recv_msg->user_msg_data; - - if(recv_msg->msg.data[0]==0 && recv_msg->msg.data_len>0) { - msg_result->result_length=recv_msg->msg.data_len-1; - memcpy(msg_result->result, &recv_msg->msg.data[1], recv_msg->msg.data_len-1); - } - ipmi_free_recv_msg(recv_msg); - mutex_unlock(&ipmi_mutex); - - return; -} - -int start_ipmi_command(char NetFn, char cmd,char *data,int data_length, char* result, int* result_length) -{ - int rv=0,i; - int timeout; - - //wait previous command finish at least 50msec - timeout=50; - while((mutex_is_locked(&ipmi_mutex) == 1 || (mutex_is_locked(&ipmi2_mutex) == 1)) && (--timeout)>0) { usleep_range(1000,1010); } - if(timeout==0) { return -1; } - mutex_lock(&ipmi_mutex); - mutex_lock(&ipmi2_mutex); - - if(ipmi_mh_user == NULL) { - for (i=0,rv=1; i0) { usleep_range(1000,1100);} - if(timeout==0) { - mutex_unlock(&ipmi2_mutex); - return -1; - } - else { - *result_length=ipmiresult.result_length; - memcpy(result,ipmiresult.result,*result_length); - mutex_unlock(&ipmi2_mutex); - return 0; - } - } - return 0; -} -EXPORT_SYMBOL(start_ipmi_command); - -static ssize_t psoc_ipmi_read(u8 *buf, u8 offset, size_t count) -{ - uint8_t data[2]; - int result_len=0; - int rv; - - data[0] = offset; - data[1] = count; - - rv=start_ipmi_command(NETFN_OEM, CMD_GETDATA,data,2, buf, &result_len); - - return result_len; -} - -static ssize_t psoc_ipmi_write(char *buf, unsigned offset, size_t count) -{ - uint8_t data[count+1],result[1]; - int result_len; - - data[0] = offset; - memcpy(&data[1],buf,count); - - start_ipmi_command(NETFN_OEM, CMD_SETDATA,data,count+1, result, &result_len); - return count; -} - - -static u16 psoc_read16(u8 offset) -{ - u16 value = 0; - u8 buf[]={0,0}; - - if(psoc_ipmi_read(buf, offset, 2) == 2) - value = (buf[0]<<8 | buf[1]<<0); - - return value; -} - -static u8 psoc_read8(u8 offset) -{ - u8 value = 0; - u8 buf = 0; - - if(psoc_ipmi_read(&buf, offset, 1) == 1) - value = buf; - - return value; -} - -/* -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=0; - struct sensor_device_attribute *attr = to_sensor_dev_attr(da); - u8 byte=0; - int shift = (attr->index == 0)?3:0; - - status = psoc_ipmi_read(&byte, PSOC_PSU_OFFSET, 1); - - byte = (byte >> shift) & 0x7; - - status = sprintf (buf, "%d : %s\n", byte, psu_str[byte]); - - return strlen(buf); -} - -static ssize_t psoc_show_psu_st(char *buf, int psu_index) -{ - u32 status=0; - u8 byte=0; - int shift = (psu_index == 0)?3:0; - - status = psoc_ipmi_read(&byte, PSOC_PSU_OFFSET, 1); - - byte = (byte >> shift) & 0x7; - - status = sprintf (buf, "%d : %s\n", byte, psu_str[byte]); - - return strlen(buf); -} - -ssize_t psoc_show_psu_state(char *buf, int index) -{ - return psoc_show_psu_st(buf, index); -} -EXPORT_SYMBOL(psoc_show_psu_state); - -static ssize_t show_ipmi_pmbus(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=0; - - data[0] = BMC_PMBusNumber; - 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(start_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_clei(struct device *dev, struct device_attribute *da, - char *buf) -{ - struct sensor_device_attribute *attr = to_sensor_dev_attr(da); - u8 device_index = attr->index & 0xFF; - - uint8_t data[5],result[MaxLeng_Result]; - int result_len=0; - - data[0] = (device_index<=FAN5_CLEI_INDEX) ? BMC_FanCLEIBusNumber:BMC_PMBusNumber; - data[1] = CLEI_ADDR[device_index]<<1; - data[2] = sizeof(struct clei); - data[3] = (device_index<=FAN5_CLEI_INDEX) ? 0x00 : 0x01; //PSU CLEI will start from 0x0100 - data[4] = 0; - - if(start_ipmi_command(0x06, 0x52,data,5, result, &result_len)==0) - { - if(result_len < sizeof(struct clei)) memset(result, 0, sizeof(struct clei)); - sprintf (buf, "Issue Number: %.3s\n", &result[CLEI_OFF(issue_number)]); - sprintf (buf, "%sAbbreviation Number: %.9s\n", buf, &result[CLEI_OFF(abbreviation_number)]); - sprintf (buf, "%sFC Number: %.10s\n", buf, &result[CLEI_OFF(fc_number)]); - sprintf (buf, "%sCLEI Code: %.10s\n", buf, &result[CLEI_OFF(clei_code)]); - sprintf (buf, "%sProduct Year and Month: %.5s\n", buf, &result[CLEI_OFF(product_year_and_month)]); - sprintf (buf, "%s2D Label Location Code: %.2s\n", buf, &result[CLEI_OFF(label_location_code)]); - sprintf (buf, "%sSerial Number: %.5s\n", buf, &result[CLEI_OFF(serial_number)]); - sprintf (buf, "%sPCB Revision: %.5s\n", buf, &result[CLEI_OFF(pcb_revision)]); - sprintf (buf, "%sVendor Name: %.10s\n", buf, &result[CLEI_OFF(vendor_name)]); - return strlen(buf); - } - else - { - return sprintf(buf, "NONE\n"); - } -} - -static ssize_t show_thermal(struct device *dev, struct device_attribute *da, - char *buf) -{ - int status=0; - struct sensor_device_attribute *attr = to_sensor_dev_attr(da); - u8 offset = attr->index * 2 + THERMAL_OFFSET; - - status = psoc_read16(offset); - - 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=0; - struct sensor_device_attribute *attr = to_sensor_dev_attr(da); - u8 offset = attr->index; - - status = psoc_read8(offset); - - return sprintf(buf, "%d\n", - status); -} - -static ssize_t set_pwm(struct device *dev, - struct device_attribute *da, - const char *buf, size_t count) -{ - struct sensor_device_attribute *attr = to_sensor_dev_attr(da); - u8 offset = attr->index; - u8 pwm = simple_strtol(buf, NULL, 10); - if(pwm > 255) pwm = 255; - psoc_ipmi_write(&pwm, offset, 1); - - return count; -} - - -static ssize_t show_rpm(struct device *dev, struct device_attribute *da, - char *buf) -{ - int status=0; - struct sensor_device_attribute *attr = to_sensor_dev_attr(da); - u8 offset = attr->index; - status = psoc_read16(offset); - - return sprintf(buf, "%d\n", status); -} - -static ssize_t psoc_show_rpm(char *buf, int fan_index) -{ - int status=0; - u8 offset = fan_index; - - status = psoc_read16(offset); - - return sprintf(buf, "%d\n", status); -} - -ssize_t psoc_show_fan_input(char *buf, int index) -{ - return psoc_show_rpm(buf, index); -} -EXPORT_SYMBOL(psoc_show_fan_input); - -static ssize_t show_switch_tmp(struct device *dev, struct device_attribute *da, - char *buf) -{ - u16 status=0; - u16 temp = 0; - - status = psoc_ipmi_read((u8*)&temp, SWITCH_TMP_OFFSET, 2); - - 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) -{ - long temp = simple_strtol(buf, NULL, 10); - u16 temp2 = ( (temp/1000) <<8 ) & 0xFF00 ; - - psoc_ipmi_write((u8*)&temp2, SWITCH_TMP_OFFSET, 2); - - - return count; -} - -static ssize_t show_diag(struct device *dev, struct device_attribute *da, - char *buf) -{ - u16 status=0; - u8 diag_flag = 0; - - status = psoc_ipmi_read((u8*)&diag_flag, DIAG_FLAG_OFFSET, 1); - - status = sprintf (buf, "%d\n", ((diag_flag & 0x80)?1:0)); - - return strlen(buf); -} - -static ssize_t psoc_show_diag(char *buf) -{ - u16 status=0; - u8 diag_flag = 0; - - status = psoc_ipmi_read((u8*)&diag_flag, DIAG_FLAG_OFFSET, 1); - - status = sprintf (buf, "%d\n", ((diag_flag & 0x80)?1:0)); - - return strlen(buf); -} -EXPORT_SYMBOL(psoc_show_diag); - -static ssize_t set_diag(struct device *dev, - struct device_attribute *devattr, - const char *buf, size_t count) -{ - u8 value = 0; - u8 diag = simple_strtol(buf, NULL, 10); - - diag = diag?1:0; - - psoc_ipmi_read((u8*)&value, DIAG_FLAG_OFFSET, 1); - if(diag) value |= (1<<7); - else value &= ~(1<<7); - psoc_ipmi_write((u8*)&value, DIAG_FLAG_OFFSET, 1); - - return count; -} - -static ssize_t psoc_set_diag(const char *buf, size_t count) -{ - u8 value = 0; - u8 diag = simple_strtol(buf, NULL, 10); - - diag = diag?1:0; - - psoc_ipmi_read((u8*)&value, DIAG_FLAG_OFFSET, 1); - if(diag) value |= (1<<7); - else value &= ~(1<<7); - psoc_ipmi_write((u8*)&value, DIAG_FLAG_OFFSET, 1); - - return count; -} -EXPORT_SYMBOL(psoc_set_diag); - -static ssize_t show_version(struct device *dev, struct device_attribute *da, - char *buf) -{ - u16 status=0; - - status = psoc_read16(VERSION_OFFSET); - - 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=0; - struct sensor_device_attribute *attr = to_sensor_dev_attr(da); - u8 bit = attr->index; - - if(bit < 8) { status = psoc_read8(FAN_LED_OFFSET); } -#if FAN_NUM>4 - if(bit >= 8) { status = psoc_read8(FAN_LED2_OFFSET); bit-=8; } -#endif - - return sprintf(buf, "%d\n", - (status & (1<index; - u8 led_state = 0; - - u8 v = simple_strtol(buf, NULL, 10); - - if(attr->index < 8) { led_state = psoc_read8(FAN_LED_OFFSET ); } -#if FAN_NUM>4 - if(attr->index >= 8) { led_state = psoc_read8(FAN_LED2_OFFSET); bit-=8; } -#endif - if(v) led_state |= (1<index < 8) { psoc_ipmi_write(&led_state, FAN_LED_OFFSET, 1);} -#if FAN_NUM>4 - if(attr->index >= 8) { psoc_ipmi_write(&led_state, FAN_LED2_OFFSET,1);} -#endif - return count; -} - -static ssize_t show_value8(struct device *dev, struct device_attribute *da, - char *buf) -{ - int status=0; - struct sensor_device_attribute *attr = to_sensor_dev_attr(da); - u8 offset = attr->index; - - status = psoc_read8(offset); - - return sprintf(buf, "0x%02X\n", status ); -} - -static ssize_t psoc_show_value8(char *buf, int offset) -{ - int status=0; - - status = psoc_read8(offset); - - return sprintf(buf, "0x%02X\n", status ); -} - -static char prev_fan_state[8] = { 0 }; - -ssize_t psoc_show_fan_state(char *buf) -{ - int i; - int rv = psoc_show_value8(buf, FAN_GPI_OFFSET); - for (i = 0; i < 3; i++) { - if (strncmp(prev_fan_state, buf, 4) == 0) { - return rv; - } - msleep(500); - rv = psoc_show_value8(buf, FAN_GPI_OFFSET); - } - strcpy(prev_fan_state, buf); - return rv; -} -EXPORT_SYMBOL(psoc_show_fan_state); - -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=0; - struct sensor_device_attribute *attr = to_sensor_dev_attr(da); - u8 offset = attr->index + PSU_INFO_OFFSET; - - status = psoc_read16(offset); - - if((strstr(attr->dev_attr.attr.name, "vout")!=NULL)|(strstr(attr->dev_attr.attr.name, "in3")!=NULL)|(strstr(attr->dev_attr.attr.name, "in4")!=NULL)) { - offset=1; - } - else { - offset=0; - } - - return sprintf(buf, "%ld \n", pmbus_reg2data_linear(status, offset )); -} - -static ssize_t psoc_show_psu_psoc(char *buf, int psu_index, char *attr_name) -{ - u16 status=0; - u8 offset = psu_index + PSU_INFO_OFFSET; - - status = psoc_read16(offset); - - if((strstr(attr_name, "vout")!=NULL)|(strstr(attr_name, "in3")!=NULL)|(strstr(attr_name, "in4")!=NULL)) { - offset=1; - } - else { - offset=0; - } - - return sprintf(buf, "%ld \n", pmbus_reg2data_linear(status, offset )); -} - -ssize_t psoc_show_psu_vin(char *buf, int index) -{ - return psoc_show_psu_psoc(buf, index, "vin"); -} -EXPORT_SYMBOL(psoc_show_psu_vin); - -static ssize_t show_name(struct device *dev, - struct device_attribute *devattr, char *buf) -{ - return sprintf(buf, "inv_psoc\n"); -} - -static DEVICE_ATTR(name, S_IRUGO, show_name, NULL); -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(temp7_input, S_IRUGO, show_thermal, 0, 5); -static SENSOR_DEVICE_ATTR(temp8_input, S_IRUGO, show_thermal, 0, 6); - -static SENSOR_DEVICE_ATTR(pwm1, S_IWUSR|S_IRUGO, show_pwm, set_pwm, 0 + PWM_OFFSET); -static SENSOR_DEVICE_ATTR(pwm2, S_IWUSR|S_IRUGO, show_pwm, set_pwm, 1 + PWM_OFFSET); -static SENSOR_DEVICE_ATTR(pwm3, S_IWUSR|S_IRUGO, show_pwm, set_pwm, 2 + PWM_OFFSET); -static SENSOR_DEVICE_ATTR(pwm4, S_IWUSR|S_IRUGO, show_pwm, set_pwm, 3 + PWM_OFFSET); -#if FAN_NUM > 4 -static SENSOR_DEVICE_ATTR(pwm5, S_IWUSR|S_IRUGO, show_pwm, set_pwm, 0 + PWM2_OFFSET); -#endif -static SENSOR_DEVICE_ATTR(pwm_psu1, S_IWUSR|S_IRUGO, show_pwm, set_pwm, 4 + PWM_OFFSET); -static SENSOR_DEVICE_ATTR(pwm_psu2, S_IWUSR|S_IRUGO, show_pwm, set_pwm, 5 + PWM_OFFSET); -static SENSOR_DEVICE_ATTR(pwm6, S_IWUSR|S_IRUGO, show_pwm, set_pwm, 4 + PWM_OFFSET); -static SENSOR_DEVICE_ATTR(pwm7, S_IWUSR|S_IRUGO, show_pwm, set_pwm, 5 + PWM_OFFSET); - -static SENSOR_DEVICE_ATTR(psu1, S_IRUGO, show_psu_st, 0, 0); -static SENSOR_DEVICE_ATTR(psu2, 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); -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(fan11_input, S_IRUGO, show_rpm, 0, 8*2 + RPM_OFFSET); -static SENSOR_DEVICE_ATTR(fan12_input, S_IRUGO, show_rpm, 0, 9*2 + RPM_OFFSET); - -#if FAN_NUM > 4 -static SENSOR_DEVICE_ATTR(fan9_input , S_IRUGO, show_rpm, 0,0*2 + RPM2_OFFSET); -static SENSOR_DEVICE_ATTR(fan10_input, S_IRUGO, show_rpm, 0,1*2 + RPM2_OFFSET); -#endif - -static SENSOR_DEVICE_ATTR(switch_tmp, S_IWUSR|S_IRUGO, show_switch_tmp, set_switch_tmp, 0); -static SENSOR_DEVICE_ATTR(temp6_input, 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); - -#if FAN_NUM>4 -static SENSOR_DEVICE_ATTR(fan_led_grn5, S_IWUSR|S_IRUGO, show_fan_led, set_fan_led, 8); -static SENSOR_DEVICE_ATTR(fan_led_red5, S_IWUSR|S_IRUGO, show_fan_led, set_fan_led, 12); -static SENSOR_DEVICE_ATTR(fan_gpi2, S_IRUGO, show_value8, 0, FAN_GPI2_OFFSET); -#endif - -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(in1_input, S_IRUGO, show_psu_psoc, 0, PSOC_PSU_OFF(psu1_vin)); -static SENSOR_DEVICE_ATTR(curr1_input, S_IRUGO, show_psu_psoc, 0, PSOC_PSU_OFF(psu1_iin)); -static SENSOR_DEVICE_ATTR(power1_input, S_IRUGO, show_psu_psoc, 0, PSOC_PSU_OFF(psu1_pin)); -static SENSOR_DEVICE_ATTR(in3_input, S_IRUGO, show_psu_psoc, 0, PSOC_PSU_OFF(psu1_vout)); -static SENSOR_DEVICE_ATTR(curr3_input, S_IRUGO, show_psu_psoc, 0, PSOC_PSU_OFF(psu1_iout)); -static SENSOR_DEVICE_ATTR(power3_input, 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 SENSOR_DEVICE_ATTR(in2_input, S_IRUGO, show_psu_psoc, 0, PSOC_PSU_OFF(psu2_vin)); -static SENSOR_DEVICE_ATTR(curr2_input, S_IRUGO, show_psu_psoc, 0, PSOC_PSU_OFF(psu2_iin)); -static SENSOR_DEVICE_ATTR(power2_input, S_IRUGO, show_psu_psoc, 0, PSOC_PSU_OFF(psu2_pin)); -static SENSOR_DEVICE_ATTR(in4_input, S_IRUGO, show_psu_psoc, 0, PSOC_PSU_OFF(psu2_vout)); -static SENSOR_DEVICE_ATTR(curr4_input, S_IRUGO, show_psu_psoc, 0, PSOC_PSU_OFF(psu2_iout)); -static SENSOR_DEVICE_ATTR(power4_input, S_IRUGO, show_psu_psoc, 0, PSOC_PSU_OFF(psu2_pout)); - -//IPMI -static SENSOR_DEVICE_ATTR(thermal2_psu1, S_IRUGO, show_ipmi_pmbus, 0, PSU1 | PMBus_Temp2); -static SENSOR_DEVICE_ATTR(temp9_input, S_IRUGO, show_ipmi_pmbus, 0, PSU1 | PMBus_Temp2); - -static SENSOR_DEVICE_ATTR(psoc_psu1_vendor, S_IRUGO, show_ipmi_pmbus, 0, PSU1 | PMBus_Vendor); -static SENSOR_DEVICE_ATTR(psoc_psu1_serial, S_IRUGO, show_ipmi_pmbus, 0, PSU1 | PMBus_Serial); -static SENSOR_DEVICE_ATTR(psoc_psu1_version, S_IRUGO, show_ipmi_pmbus, 0, PSU1 | PMBus_Version); - -static SENSOR_DEVICE_ATTR(thermal2_psu2, S_IRUGO, show_ipmi_pmbus, 0, PSU2 | PMBus_Temp2); -static SENSOR_DEVICE_ATTR(temp10_input, S_IRUGO, show_ipmi_pmbus, 0, PSU2 | PMBus_Temp2); -static SENSOR_DEVICE_ATTR(psoc_psu2_vendor, S_IRUGO, show_ipmi_pmbus, 0, PSU2 | PMBus_Vendor); -static SENSOR_DEVICE_ATTR(psoc_psu2_serial, S_IRUGO, show_ipmi_pmbus, 0, PSU2 | PMBus_Serial); -static SENSOR_DEVICE_ATTR(psoc_psu2_version, S_IRUGO, show_ipmi_pmbus, 0, PSU2 | PMBus_Version); - -//CLEI -#if FAN_CLEI_SUPPORT -static SENSOR_DEVICE_ATTR(fan1_clei, S_IRUGO, show_clei, 0, FAN1_CLEI_INDEX ); -static SENSOR_DEVICE_ATTR(fan2_clei, S_IRUGO, show_clei, 0, FAN2_CLEI_INDEX ); -static SENSOR_DEVICE_ATTR(fan3_clei, S_IRUGO, show_clei, 0, FAN3_CLEI_INDEX ); -static SENSOR_DEVICE_ATTR(fan4_clei, S_IRUGO, show_clei, 0, FAN4_CLEI_INDEX ); -#if FAN_NUM > 4 -static SENSOR_DEVICE_ATTR(fan5_clei, S_IRUGO, show_clei, 0, FAN5_CLEI_INDEX ); -#endif -#endif - -#if PSU_CLEI_SUPPORT -static SENSOR_DEVICE_ATTR(psu1_clei, S_IRUGO, show_clei, 0, PSU1_CLEI_INDEX ); -static SENSOR_DEVICE_ATTR(psu2_clei, S_IRUGO, show_clei, 0, PSU2_CLEI_INDEX ); -#endif - -static struct attribute *psoc_attributes[] = { - //name - &dev_attr_name.attr, - //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, - - &sensor_dev_attr_temp7_input.dev_attr.attr, - &sensor_dev_attr_temp8_input.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 > 4 - &sensor_dev_attr_pwm5.dev_attr.attr, -#endif - &sensor_dev_attr_pwm_psu1.dev_attr.attr, - &sensor_dev_attr_pwm_psu2.dev_attr.attr, - &sensor_dev_attr_pwm6.dev_attr.attr, - &sensor_dev_attr_pwm7.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 > 4 - &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, - &sensor_dev_attr_fan11_input.dev_attr.attr, - &sensor_dev_attr_fan12_input.dev_attr.attr, - //switch temperature - &sensor_dev_attr_switch_tmp.dev_attr.attr, - &sensor_dev_attr_temp6_input.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, -#if FAN_NUM >4 - &sensor_dev_attr_fan_led_grn5.dev_attr.attr, - &sensor_dev_attr_fan_led_red5.dev_attr.attr, - &sensor_dev_attr_fan_gpi2.dev_attr.attr, -#endif - //fan GPI - &sensor_dev_attr_fan_gpi.dev_attr.attr, - &sensor_dev_attr_psu1.dev_attr.attr, - &sensor_dev_attr_psu2.dev_attr.attr, - - - //psu_psoc - &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, - - &sensor_dev_attr_in1_input.dev_attr.attr, - &sensor_dev_attr_curr1_input.dev_attr.attr, - &sensor_dev_attr_power1_input.dev_attr.attr, - &sensor_dev_attr_in2_input.dev_attr.attr, - &sensor_dev_attr_curr2_input.dev_attr.attr, - &sensor_dev_attr_power2_input.dev_attr.attr, - &sensor_dev_attr_in3_input.dev_attr.attr, - &sensor_dev_attr_curr3_input.dev_attr.attr, - &sensor_dev_attr_power3_input.dev_attr.attr, - &sensor_dev_attr_in4_input.dev_attr.attr, - &sensor_dev_attr_curr4_input.dev_attr.attr, - &sensor_dev_attr_power4_input.dev_attr.attr, - - //ipmi_i2c_command - &sensor_dev_attr_thermal2_psu1.dev_attr.attr, - &sensor_dev_attr_temp9_input.dev_attr.attr, - &sensor_dev_attr_psoc_psu1_vendor.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_temp10_input.dev_attr.attr, - &sensor_dev_attr_psoc_psu2_vendor.dev_attr.attr, - &sensor_dev_attr_psoc_psu2_serial.dev_attr.attr, - &sensor_dev_attr_psoc_psu2_version.dev_attr.attr, - - //clei -#if FAN_CLEI_SUPPORT - &sensor_dev_attr_fan1_clei.dev_attr.attr, - &sensor_dev_attr_fan2_clei.dev_attr.attr, - &sensor_dev_attr_fan3_clei.dev_attr.attr, - &sensor_dev_attr_fan4_clei.dev_attr.attr, -#if FAN_NUM > 4 - &sensor_dev_attr_fan5_clei.dev_attr.attr, -#endif -#endif - -#if PSU_CLEI_SUPPORT - &sensor_dev_attr_psu1_clei.dev_attr.attr, - &sensor_dev_attr_psu2_clei.dev_attr.attr, -#endif - NULL -}; - -static const struct attribute_group psoc_group = { - .attrs = psoc_attributes, -}; - -//================================= -static void check_switch_temp(void) -{ - static struct file *f; - mm_segment_t old_fs; - - set_fs(get_ds()); - f = filp_open(SWITCH_TEMPERATURE_SOCK,O_RDONLY,0644); - if(IS_ERR(f)) { - return; - } - else { - char temp_str[]={0,0,0,0,0,0,0}; - loff_t pos = 0; - u16 temp2 = 0; - old_fs = get_fs(); - set_fs(KERNEL_DS); - vfs_read(f, temp_str,6,&pos); - temp2 = ((simple_strtoul(temp_str,NULL,10)/1000) <<8 ) & 0xFF00 ; - psoc_ipmi_write((u8*)&temp2, SWITCH_TMP_OFFSET, 2); - } - filp_close(f,NULL); - set_fs(old_fs); -} - -static int psoc_polling_thread(void *p) -{ - while (!kthread_should_stop()) - { - check_switch_temp(); - set_current_state(TASK_INTERRUPTIBLE); - if(kthread_should_stop()) - break; - - schedule_timeout(msecs_to_jiffies(PSOC_POLLING_PERIOD)); - } - return 0; -} - -static int __init inv_psoc_init(void) -{ - int ret; - - hwmon_dev = hwmon_device_register(NULL); - if (IS_ERR(hwmon_dev)) { - goto fail_hwmon_device_register; - } - - device_kobj = kobject_create_and_add("device", &hwmon_dev->kobj); - if(!device_kobj) { - goto fail_hwmon_device_register; - } - - ret = sysfs_create_group(device_kobj, &psoc_group); - if (ret) { - goto fail_create_group_hwmon; - } - - ret = sysfs_create_group(&hwmon_dev->kobj, &psoc_group); - if (ret) { - goto fail_create_group_hwmon; - } - - kthread_auto_update = kthread_run(psoc_polling_thread,NULL,"BMC_DRIVER"); - if (IS_ERR(kthread_auto_update)) { - goto fail_create_group_hwmon; - } - return ret; - -fail_create_group_hwmon: - hwmon_device_unregister(hwmon_dev); -fail_hwmon_device_register: - return -ENOMEM; -} - -static void __exit inv_psoc_exit(void) -{ - kthread_stop(kthread_auto_update); - if(ipmi_mh_user!=NULL) {ipmi_destroy_user(ipmi_mh_user);} - sysfs_remove_group(device_kobj, &psoc_group); - if(hwmon_dev != NULL) hwmon_device_unregister(hwmon_dev); -} - -MODULE_AUTHOR("Ting.Jack "); -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/d6556/modules/builds/src/inv_pthread.c b/packages/platforms/inventec/x86-64/d6556/modules/builds/src/inv_pthread.c deleted file mode 100644 index 4ea89c15a..000000000 --- a/packages/platforms/inventec/x86-64/d6556/modules/builds/src/inv_pthread.c +++ /dev/null @@ -1,884 +0,0 @@ -/***************************** - Maple (d6556) platform -******************************/ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "inv_pthread.h" - -#define INV_PTHREAD_KERNEL_MODULE - -#define SHOW_ATTR_WARNING ("N/A") -#define SHOW_ATTR_NOTPRINT ("Not Available") -#define SHOW_ATTR_NOTSUPPORT ("Not Support") - -#define INV_HWMID_MAX (10) -#define INV_HWMID_INIT (-1) - -/*access userspace data to kernel space*/ -#define ACC_R (0) -#define ACC_W (1) - -#define MAX_PATH_SIZE (64) -#define MIN_ACC_SIZE (32) -#define MAX_ACC_SIZE (256) - -/* - * LED definitions - */ -#define STATUS_LED_MODE_AUTO (0) -#define STATUS_LED_MODE_DIAG (1) -#define STATUS_LED_MODE_MANU (2) -#define STATUS_LED_MODE_ERR (-1) - -#define STATUS_LED_GRN0 (10) // 0 - 000: off -#define STATUS_LED_GRN1 (11) // 1 - 001: 0.5hz -#define STATUS_LED_GRN2 (12) // 2 - 010: 1 hz -#define STATUS_LED_GRN3 (13) // 3 - 011: 2 hz -#define STATUS_LED_GRN7 (17) // 7 - 111: on -#define STATUS_LED_RED0 (20) // 0 - 000: off -#define STATUS_LED_RED1 (21) // 1 - 001: 0.5hz -#define STATUS_LED_RED2 (22) // 2 - 010: 1 hz -#define STATUS_LED_RED3 (23) // 3 - 011: 2 hz -#define STATUS_LED_RED7 (27) // 7 - 111: on -#define STATUS_LED_INVALID (0) // Invalid - -static struct mutex pthread_mutex; - -ssize_t status_led_grn(const char *freq); -ssize_t status_led_red(const char *freq); -ssize_t status_led_diag_mode_enable(void); -ssize_t status_led_diag_mode_disable(void); -int status_led_check_color(void); -int status_led_check_diag_mode(void); - -#if 1 -/* For timestamps in SYSFS_LOG */ -#define SYSFS_LOG printk -#else -//#define SYSFS_LOG(fmt, args...) printk(KERN_WARNING "[SYSFS] %s/%d: " fmt, __func__, __LINE__, ##args) -#define SYSFS_LOG(fmt, args...) printk(KERN_WARNING "[p_thread] " fmt, ##args) -#endif - - -/* inventec_class *********************************/ -static struct kobject *status_kobj; -static struct kset *status_kset; - -#if 0 -int inventec_strtol(const char *sbufp, char **endp, unsigned int base) -{ - char *endptr; - int value = simple_strtol(sbufp, &endptr, base); - if (value == 0 && sbufp == endptr) { - *endp = NULL; - return value; - } - *endp = (char*)1; - return value; -} -#endif - -int inventec_singlechar_to_int(const char c) -{ - if ((c >= '0') && (c <= '9')) { - return (c - '0'); - } - else - if ((c >= 'a') && (c <= 'f')) { - return (c - 'a' + 10); - } - else - if ((c >= 'A') && (c <= 'F')) { - return (c - 'A' + 10); - } - return -1; -} - -/* fan device *************************************/ -#define FAN_STATE_NORMAL "normal" -#define FAN_STATE_FAULTY "faulty" -#define FAN_STATE_UNINSTALLED "uninstalled" -#define FAN_STATE_UNKNOW "unknown state" -#define FAN_STATE_INVALID "Invalid state value" -#define FAN_STATE_READ_ERROR "state read error" - -#define FAN_LOG_UNINSTALLED "removed" -#define FAN_LOG_NORMAL "inserted" - -//#define FAN_STATE_BIT_NORMAL 0 -#define FAN_STATE_BIT_FAULTY 0 -#define FAN_STATE_BIT_UNINSTALLED 1 -#define FAN_STATE_BIT_UNKNOW 2 -#define FAN_STATE_BIT_INVALID 3 -#define FAN_STATE_BIT_READ_ERROR 4 - -static ssize_t psoc_show_fan1_input(char *buf) -{ - return psoc_show_fan_input(buf, 1); -} - -static ssize_t psoc_show_fan2_input(char *buf) -{ - return psoc_show_fan_input(buf, 2); -} - -static ssize_t psoc_show_fan3_input(char *buf) -{ - return psoc_show_fan_input(buf, 3); -} - -static ssize_t psoc_show_fan4_input(char *buf) -{ - return psoc_show_fan_input(buf, 4); -} - -static ssize_t psoc_show_fan5_input(char *buf) -{ - return psoc_show_fan_input(buf, 5); -} - -static ssize_t psoc_show_fan6_input(char *buf) -{ - return psoc_show_fan_input(buf, 6); -} - -static ssize_t psoc_show_fan7_input(char *buf) -{ - return psoc_show_fan_input(buf, 7); -} - -static ssize_t psoc_show_fan8_input(char *buf) -{ - return psoc_show_fan_input(buf, 8); -} - -static struct fans_tbl_s { - char *fan_name; - ssize_t (*fan_front)(char *); - ssize_t (*fan_rear)(char *); - unsigned int fan_state; -} fans_tbl[] = { - {"fan1", psoc_show_fan1_input, - psoc_show_fan2_input, 0}, - {"fan2", psoc_show_fan3_input, - psoc_show_fan4_input, 0}, - {"fan3", psoc_show_fan5_input, - psoc_show_fan6_input, 0}, - {"fan4", psoc_show_fan7_input, - psoc_show_fan8_input, 0}, -}; -#define FAN_TBL_TOTAL ( sizeof(fans_tbl)/ sizeof(const struct fans_tbl_s) ) - -#define FAN_STATE_CHECK(i,b) (fans_tbl[i].fan_state & (1<inv_dev_attrp, PSU_ATTR_VOLTIN, PSU_ATTR_VOLTIN_LEN) == 0) { - invwirep = psu_get_show_function(PSU_ATTR_VOLTIN, psu_dev_group[i].psu_name, NULL); - if (invwirep == NULL) { - printk(KERN_DEBUG "[p_thread] Invalid psuname: %s\n", psu_dev_group[i].psu_name); - continue; - } - if (invwirep(volt) <= 0) { - printk(KERN_DEBUG "[p_thread] Read %s failed\n", psu_dev_group[i].psu_name); - continue; - } - else { - voltin = simple_strtol(&volt[0], NULL, 10); - printk(KERN_DEBUG "[p_thread] Read %s %s = %u\n",psu_dev_group[i].psu_name,volt,voltin); - if (voltin > psu_voltin) { - psu_voltin = voltin; - } - } - } - } - } - - SYSFS_LOG("[p_thread] PSU voltin = %u\n", psu_voltin); -} - -#define PSU_ATTR_STATE ("state") -#define PSU_ATTR_STATE_LEN (5) - -/* psus_control() by inv_thread */ -int psus_control(int log_only) -{ - char state[MIN_ACC_SIZE]; - psu_dev_t *devnamep = NULL; - ssize_t (*invwirep)(char *buf) = NULL; - char *psu_statep = NULL; - int i, j, flag = 0; - - for (i = 0; i < PSU_DEV_GROUP_TOTAL; i++) { - devnamep = psu_dev_group[i].psu_dev_namep; - for (j = 0; j < psu_dev_group[i].psu_dev_total; j++, devnamep++) { - if (strncmp(devnamep->inv_dev_attrp, PSU_ATTR_STATE, PSU_ATTR_STATE_LEN) == 0) { - invwirep = psu_get_show_function(PSU_ATTR_STATE, psu_dev_group[i].psu_name, &psu_statep); - if (invwirep == NULL) { - printk(KERN_DEBUG "[p_thread] Invalid psuname: %s\n", psu_dev_group[i].psu_name); - continue; - } - if (invwirep(state) <= 0) { - printk(KERN_DEBUG "[p_thread] Read %s failed\n", psu_dev_group[i].psu_name); - if (strncmp(psu_statep, PSU_STATE_ERROR, strlen(PSU_STATE_ERROR)) != 0) { - strcpy(psu_statep, PSU_STATE_ERROR); - SYSFS_LOG("[p_thread] %s: %s\n",psu_dev_group[i].psu_name,PSU_STATE_ERROR); - } - flag = 1; - } - else - if (strstr(state, "normal")) { - if (strncmp(psu_statep, state, strlen(state)) != 0) { - strcpy(psu_statep, state); - SYSFS_LOG("[p_thread] %s: %s\n",psu_dev_group[i].psu_name,state); - } - } - else - if (psu_voltin > PSU_VOLTIN_ACDC) { /* AC PSUS */ - if (strncmp(psu_statep, state, strlen(state)) != 0) { - strcpy(psu_statep, state); - SYSFS_LOG("[p_thread] %s: %s\n",psu_dev_group[i].psu_name,state); - } - flag = 1; - } - else { /* DC PSUS */ - if (strncmp(psu_statep, PSU_STATE_CHECKPSU, PSU_STATE_LEN_CHECKPSU) != 0) { - strcpy(psu_statep, PSU_STATE_CHECKPSU); - SYSFS_LOG("[p_thread] %s: %s\n",psu_dev_group[i].psu_name,PSU_STATE_CHECKPSU); - } - flag = 1; - } - } - } - } - - if (log_only) { - return 0; - } - - //SYSFS_LOG("[p_thread] RYU: %s: flag = %d\n",psu_wire_tbl[i].psu_name,flag); - if (flag == 1) { - status_led_grn("2"); - return 1; - } - return 0; -} - -/* End of psuinfo_device */ - -/* led device *************************************/ - -/* return 0/off 1/green 2/red */ -int -status_led_check_color(void) -{ - char tmpbuf[MIN_ACC_SIZE]; - int ret = STATUS_LED_INVALID; - - if (cpld_show_led(&tmpbuf[0], CPLD_DEV_LED_GRN_INDEX) > 0) { - if (tmpbuf[0] == '0') { - ret = STATUS_LED_GRN0; - } - if (tmpbuf[0] == '1') { - ret = STATUS_LED_GRN1; - } - if (tmpbuf[0] == '2') { - ret = STATUS_LED_GRN2; - } - if (tmpbuf[0] == '3') { - ret = STATUS_LED_GRN3; - } - if (tmpbuf[0] == '7') { - ret = STATUS_LED_GRN7; - } - return ret; - } - - if (cpld_show_led(&tmpbuf[0], CPLD_DEV_LED_RED_INDEX) > 0) { - if (tmpbuf[0] == '0') { - ret = STATUS_LED_RED0; - } - if (tmpbuf[0] == '1') { - ret = STATUS_LED_RED1; - } - if (tmpbuf[0] == '2') { - ret = STATUS_LED_RED2; - } - if (tmpbuf[0] == '3') { - ret = STATUS_LED_RED3; - } - if (tmpbuf[0] == '7') { - ret = STATUS_LED_RED7; - } - return ret; - } - return ret; -} - -/* - * Store attr Section - */ -ssize_t status_led_diag_mode_enable(void) -{ - char tmp[MIN_ACC_SIZE]; - ssize_t ret; - - ret = psoc_show_diag(&tmp[0]); - if (ret <= 0) { - return ret; - } - - if (tmp[0] == '0') { - ret = psoc_set_diag("1", 1); - if (ret < 0) { - return ret; - } - - ret = cpld_set_ctl("1", 1); - if (ret < 0) { - return ret; - } - } - - return ret; -} - -ssize_t status_led_diag_mode_disable(void) -{ - char tmp[MIN_ACC_SIZE]; - ssize_t ret; - - ret = psoc_show_diag(&tmp[0]); - if (ret <= 0) { - return ret; - } - - if (tmp[0] == '1') { - ret = psoc_set_diag("0", 1); - if (ret < 0) { - return 1; - } - - ret = cpld_set_ctl("1", 1); - if (ret < 0) { - return 1; - } - } - return 1; -} - -ssize_t -status_led_red(const char *freq) -{ - char buf[MIN_ACC_SIZE]; - ssize_t ret; - - ret = cpld_show_led(buf, CPLD_DEV_LED_RED_INDEX); - if (ret < 0 || buf[0] == freq[0]) { - return ret; - } - - ret = cpld_set_led("0", 1, CPLD_DEV_LED_GRN_INDEX); - if (ret < 0) { - return ret; - } - ret = cpld_set_led(freq, strlen(freq), CPLD_DEV_LED_RED_INDEX); - if (ret < 0) { - return ret; - } - if ((ret = status_led_diag_mode_enable()) <= 0) { - return ret; - } - ssleep(1); - if ((ret = status_led_diag_mode_disable()) <= 0) { - return ret; - } - return ret; -} - -ssize_t -status_led_grn(const char *freq) -{ - char buf[MIN_ACC_SIZE]; - ssize_t ret; - - ret = cpld_show_led(buf, CPLD_DEV_LED_GRN_INDEX); - if (ret < 0 || buf[0] == freq[0]) { - return ret; - } - - ret = cpld_set_led("0", 1, CPLD_DEV_LED_RED_INDEX); - if (ret < 0) { - return ret; - } - ssleep(1); - ret = cpld_set_led(freq, strlen(freq), CPLD_DEV_LED_GRN_INDEX); - if (ret < 0) { - return ret; - } - if ((ret = status_led_diag_mode_enable()) <= 0) { - return ret; - } - ssleep(1); - if ((ret = status_led_diag_mode_disable()) <= 0) { - return ret; - } - return ret; -} - -int status_led_check_diag_mode(void) -{ - char tmp[MIN_ACC_SIZE]; - ssize_t ret; - - ret = psoc_show_diag(&tmp[0]); - if (ret <= 0) { - return ret; - } - - if (tmp[0] == '1') { - return STATUS_LED_MODE_DIAG; - } - - if (tmp[0] == '0') { - return STATUS_LED_MODE_AUTO; - } - - return -1; -} - -/* End of ledinfo_device */ - -/**************************************************/ -/* From system_device */ -static int inv_pthread_control = 1; - -int thread_control(void) -{ - return inv_pthread_control; -} - -void thread_control_set(int val) -{ - inv_pthread_control = val; -} -/* End system_device */ - -#define THREAD_SLEEP_MINS (3) -#define THREAD_DELAY_MINS (THREAD_SLEEP_MINS + THREAD_SLEEP_MINS + 1) - -static struct task_struct *thread_st; -static int thread_data; - -// Function executed by kernel thread -static int thread_fn(void *unused) -{ - mutex_init(&pthread_mutex); - - ssleep(THREAD_DELAY_MINS); - - /* Default status init */ - mutex_lock(&pthread_mutex); - status_led_grn("7"); - mutex_unlock(&pthread_mutex); - - psu_get_voltin(); - - /* Delay for guarantee HW ready */ - ssleep(THREAD_DELAY_MINS); - - while (1) - { - mutex_unlock(&pthread_mutex); - ssleep(THREAD_SLEEP_MINS); - - if (thread_control() == 0) { - printk(KERN_INFO "[p_thread] %s/%d: Thread Stop by inv_pthread control\n",__func__,__LINE__); - break; - } - - mutex_lock(&pthread_mutex); - if (status_led_check_diag_mode() == STATUS_LED_MODE_MANU) { - /* status led in change color/freq mode, higher priority. Ignore fans sttaus */ - continue; - } - -#if 0 - switch_temp_update(); -#endif - - if (fans_control() > 0) { - psus_control(1); - continue; - } - else - if (psus_control(0) > 0) { - continue; - } - - if (status_led_check_color() != STATUS_LED_GRN7) { /* status led red, change it to green */ - status_led_grn("7"); - } - } - - do_exit(0); - printk(KERN_INFO "[p_thread] %s/%d: Thread Stopped\n",__func__,__LINE__); - return 0; -} - - -static ssize_t s_show(struct kobject *kobj, struct attribute *attr, char *buf) -{ - int fan_absence; - size_t count = 0; - - fan_absence = fans_control(); - count += sprintf(&buf[count], "%d\n", fan_absence); - return count; -} - -static ssize_t s_store(struct kobject *kobj, struct attribute *attr, const char *buf, size_t count) -{ - return count; -} - -static struct attribute status_att = { - .name = "fan_absence", - .mode = 0777, -}; - -static const struct sysfs_ops status_ops = { - .show = s_show, - .store = s_store, -}; - -static struct kobj_type status_ktype = { - .sysfs_ops = &status_ops, -}; - - -static int __init inv_pthread_init(void) -{ - int retval; - - status_kobj = kzalloc(sizeof(*status_kobj), GFP_KERNEL); - if(!status_kobj) - return PTR_ERR(status_kobj); - - status_kset = kset_create_and_add("platform_status", NULL, kernel_kobj); - if(!status_kset) - return -1; - - status_kobj->kset = status_kset; - - retval = kobject_init_and_add(status_kobj, &status_ktype, NULL, "fan"); - if(retval) - return retval; - - retval = sysfs_create_file(status_kobj, &status_att); - - thread_control_set(1); - - printk(KERN_INFO "[p_thread] %s/%d: Creating Thread\n",__func__,__LINE__); - //Create the kernel thread with name 'inv_pthread' - thread_st = kthread_run(thread_fn, (void*)&thread_data, "inv_pthread"); - if (thread_st) - printk(KERN_INFO "[p_thread] inv_pthread Created successfully\n"); - else - printk(KERN_ERR "[p_thread] inv_pthread creation failed\n"); - - return retval; -} - -static void __exit inv_pthread_exit(void) -{ - thread_control_set(0); - /* Delay for guarantee thread exit */ - ssleep(THREAD_DELAY_MINS); - - sysfs_remove_file(status_kobj, &status_att); - kset_unregister(status_kset); - kobject_del(status_kobj); - - printk(KERN_INFO "[p_thread] inv_pthread cleaning Up\n"); -} - -module_init(inv_pthread_init); -module_exit(inv_pthread_exit); - -MODULE_AUTHOR("Robert "); -MODULE_DESCRIPTION("Inventec Platform Management Thread"); -MODULE_VERSION("version 1.1"); -MODULE_LICENSE("GPL"); diff --git a/packages/platforms/inventec/x86-64/d6556/modules/builds/src/inv_pthread.h b/packages/platforms/inventec/x86-64/d6556/modules/builds/src/inv_pthread.h deleted file mode 100644 index c3b7ce830..000000000 --- a/packages/platforms/inventec/x86-64/d6556/modules/builds/src/inv_pthread.h +++ /dev/null @@ -1,19 +0,0 @@ -#ifndef INV_PTHREAD_H -#define INV_PTHREAD_H - -#define CPLD_DEV_LED_GRN_INDEX (0) -#define CPLD_DEV_LED_RED_INDEX (1) - -ssize_t cpld_show_led(char *buf, int index); -ssize_t cpld_set_led(const char *buf, size_t count, int index); -ssize_t cpld_show_ctl(char *buf); -ssize_t cpld_set_ctl(const char *buf, size_t count); - -ssize_t psoc_show_psu_state(char *buf, int index); -ssize_t psoc_show_fan_input(char *buf, int index); -ssize_t psoc_show_fan_state(char *buf); -ssize_t psoc_show_psu_vin(char *buf, int index); -ssize_t psoc_show_diag(char *buf); -ssize_t psoc_set_diag(const char *buf, size_t count); - -#endif /* INV_PTHREAD_H */ diff --git a/packages/platforms/inventec/x86-64/d6556/modules/builds/src/inv_swps.c b/packages/platforms/inventec/x86-64/d6556/modules/builds/src/inv_swps.c deleted file mode 100644 index 3d38ec510..000000000 --- a/packages/platforms/inventec/x86-64/d6556/modules/builds/src/inv_swps.c +++ /dev/null @@ -1,3159 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "inv_swps.h" - -static int ctl_major; -static int port_major; -static int ioexp_total; -static int port_total; -static int auto_config; -static int flag_i2c_reset; -static int flag_mod_state; -static unsigned gpio_rest_mux; -static struct class *swp_class_p = NULL; -static struct inv_platform_s *platform_p = NULL; -static struct inv_ioexp_layout_s *ioexp_layout = NULL; -static struct inv_port_layout_s *port_layout = NULL; - -static void swp_polling_worker(struct work_struct *work); -static DECLARE_DELAYED_WORK(swp_polling, swp_polling_worker); - -static int reset_i2c_topology(void); - -static union { - unsigned int eeprom_update_32[2]; - unsigned char eeprom_update_8[8]; -} ueu_64; - -static int -__swp_match(struct device *dev, -#ifdef SWPS_KERN_VER_AF_3_10 - - const void *data){ -#else - void *data){ -#endif - - char *name = (char *)data; - if (strcmp(dev_name(dev), name) == 0) - return 1; - return 0; -} - - -struct device * -get_swpdev_by_name(char *name){ - struct device *dev = class_find_device(swp_class_p, - NULL, - name, - __swp_match); - return dev; -} - - -static int -sscanf_2_int(const char *buf) { - - int result = -EBFONT; - char *hex_tag = "0x"; - - if (strcspn(buf, hex_tag) == 0) { - if (sscanf(buf,"%x",&result)) { - return result; - } - } else { - if (sscanf(buf,"%d",&result)) { - return result; - } - if(sscanf(buf,"-%d",&result)) { - return -result; - } - if (sscanf(buf,"%x",&result)) { - return result; - } - } - return -EBFONT; -} - -static unsigned long long int -sscanf_2_ullint(const char *buf, size_t count) { - - unsigned long long int result = -EBFONT; - char *hex_tag = "0x"; - int i, zero = 0; - - for (i = 0; i < count-2; i++) { - if (buf[i] != '0') { - zero = 1; - } - } - if (zero == 0) { - return 0x0ULL; - } - - if (strcspn(buf, hex_tag) == 0) { - for (i = 2; i < count-2; i++) { - if (INV_BATOX(buf[i]) == -1) { - return -EBFONT; - } - } - - if (sscanf(buf,"0x%llx",&result)) { - return result; - } - } else { - for (i = 0; i < count-2; i++) { - if (INV_BATOI(buf[i]) == -1) { - return -EBFONT; - } - } - - if (sscanf(buf,"%llu",&result)) { - return result; - } - } - return -EBFONT; -} - - -static int -sscanf_2_binary(const char *buf) { - - int result = sscanf_2_int(buf); - - if (result < 0){ - return -EBFONT; - } - switch (result) { - case 0: - case 1: - return result; - default: - break; - } - return -EBFONT; -} - -static int -_get_polling_period(void) { - - int retval = 0; - - if (SWP_POLLING_PERIOD == 0) { - return 0; - } - retval = ((SWP_POLLING_PERIOD * HZ) / 1000); - if (retval == 0) { - return 1; - } - return retval; -} - - -static struct transvr_obj_s * -_get_transvr_obj(char *dev_name) { - - struct device *dev_p = NULL; - struct transvr_obj_s *transvr_obj_p = NULL; - - dev_p = get_swpdev_by_name(dev_name); - if (!dev_p){ - return NULL; - } - transvr_obj_p = dev_get_drvdata(dev_p); - if (!transvr_obj_p){ - return NULL; - } - return transvr_obj_p; -} - - -static void -unlock_tobj_all(void) { - - struct transvr_obj_s *tobj_p; - char port_name[32]; - int port_id = 0; - int minor_curr = 0; - - for (minor_curr=0; minor_currauto_config = auto_config; - unlock_transvr_obj(tobj_p); - SWPS_DEBUG("%s: Set %s auto_config=%d\n", - __func__, tobj_p->swp_name, auto_config); - } - return retval; -} - -unsigned char * -get_eeprom_update(void) -{ - return &ueu_64.eeprom_update_8[0]; -} - -void -set_eeprom_update(unsigned char value[8]) -{ - memcpy(ueu_64.eeprom_update_8, value, 8); -} - -/* ========== R/W Functions module control attribute ========== - */ -static ssize_t -show_attr_platform(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - return snprintf(buf_p, 32, "%s\n", platform_p->name); -} - - -static ssize_t -show_attr_version(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - return snprintf(buf_p, 8, "%s\n", SWP_VERSION); -} - - -static ssize_t -show_attr_status(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - return snprintf(buf_p, 8, "%d\n", flag_mod_state); -} - - -static ssize_t -show_attr_auto_config(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - return snprintf(buf_p, 8, "%d\n", auto_config); -} - -static ssize_t -show_attr_eeprom_update(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - return snprintf(buf_p, 20, "0x%02x%02x%02x%02x%02x%02x%02x%02x\n", - ueu_64.eeprom_update_8[7],ueu_64.eeprom_update_8[6], - ueu_64.eeprom_update_8[5],ueu_64.eeprom_update_8[4], - ueu_64.eeprom_update_8[3],ueu_64.eeprom_update_8[2], - ueu_64.eeprom_update_8[1],ueu_64.eeprom_update_8[0]); -} - - -static int -_check_reset_pwd(const char *buf_p, - size_t count) { - - int in_max = 64; - int in_len = (int)count; - char in_val[64] = "ERR"; - char *emsg = "ERR"; - - if (in_len >= in_max) { - emsg = "input too much"; - goto err_check_reset_pwd; - } - if (!sscanf(buf_p,"%s",in_val)) { - emsg = "format incorrect"; - goto err_check_reset_pwd; - } - if (strcmp(in_val, SWP_RESET_PWD) != 0) { - emsg = "password incorrect"; - goto err_check_reset_pwd; - } - return 0; - -err_check_reset_pwd: - SWPS_ERR("%s: %s\n", __func__, emsg); - return -1; -} - - -static ssize_t -store_attr_reset_i2c(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - - if (_check_reset_pwd(buf_p, count) < 0) { - return -EBFONT; - } - /* Polling mode */ - if (SWP_POLLING_ENABLE) { - SWPS_INFO("%s: reset I2C :polling\n", __func__); - flag_i2c_reset = 1; - return count; - } - /* Direct mode */ - SWPS_INFO("%s: reset I2C go. :direct\n", __func__); - if (reset_i2c_topology() < 0) { - SWPS_ERR("%s: reset fail!\n", __func__); - return -EIO; - } - SWPS_INFO("%s: reset I2C ok. :direct\n", __func__); - return count; -} - - -static ssize_t -store_attr_reset_swps(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - - struct transvr_obj_s *tobj_p; - char port_name[32] = "ERR"; - int port_id = 0; - int minor_curr = 0; - - if (_check_reset_pwd(buf_p, count) < 0) { - return -EBFONT; - } - for (minor_curr=0; minor_currstate = STATE_TRANSVR_DISCONNECTED; - unlock_transvr_obj(tobj_p); - SWPS_INFO("%s: reset:%s\n", __func__, tobj_p->swp_name); - } - return count; -} - - -static ssize_t -store_attr_auto_config(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - - int input_val = sscanf_2_int(buf_p); - - if (input_val < 0){ - return -EBFONT; - } - if ((input_val != 0) && (input_val != 1)) { - return -EBFONT; - } - auto_config = input_val; - _update_auto_config_2_trnasvr(); - return count; -} - -static ssize_t -store_attr_eeprom_update(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count) { - - union { - unsigned long long int input_val_64; - unsigned int input_val_32[2]; - } uiv; - int i; - uiv.input_val_64 = sscanf_2_ullint(buf_p, count); - if (uiv.input_val_64 == 0){ - for (i = 0; i < 8; i++) { - ueu_64.eeprom_update_8[i] = 0; - } - } - else - if (uiv.input_val_64 > 0) { - for (i = 0; i < 32; i++) { - if (uiv.input_val_32[0] & 1<get_id, - buf_p); -} - - -static ssize_t -show_attr_ext_id(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_hex_attr(tobj_p, - tobj_p->get_ext_id, - buf_p); -} - - -static ssize_t -show_attr_connector(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_hex_attr(tobj_p, - tobj_p->get_connector, - buf_p); -} - - -static ssize_t -show_attr_vendor_name(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_vendor_name, - buf_p); -} - - -static ssize_t -show_attr_vendor_pn(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_vendor_pn, - buf_p); -} - - -static ssize_t -show_attr_vendor_rev(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_vendor_rev, - buf_p); -} - - -static ssize_t -show_attr_vendor_sn(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_vendor_sn, - buf_p); -} - - -static ssize_t -show_attr_power_cls(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - size_t len; - int result; - struct transvr_obj_s *tobj_p; - - tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - lock_transvr_obj(tobj_p); - result = tobj_p->get_power_cls(tobj_p); - unlock_transvr_obj(tobj_p); - if (result < 0){ - len = snprintf(buf_p, 16, "%d\n", result); - } else { - len = snprintf(buf_p, 16, "Power Class %d\n", result); - } - return len; -} - - -static ssize_t -show_attr_br(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_hex_attr(tobj_p, - tobj_p->get_br, - buf_p); -} - - -static ssize_t -show_attr_len_sm(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_int_attr(tobj_p, - tobj_p->get_len_sm, - buf_p); -} - - -static ssize_t -show_attr_len_smf(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_int_attr(tobj_p, - tobj_p->get_len_smf, - buf_p); -} - - -static ssize_t -show_attr_len_om1(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_int_attr(tobj_p, - tobj_p->get_len_om1, - buf_p); -} - - -static ssize_t -show_attr_len_om2(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_int_attr(tobj_p, - tobj_p->get_len_om2, - buf_p); -} - - -static ssize_t -show_attr_len_om3(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_int_attr(tobj_p, - tobj_p->get_len_om3, - buf_p); -} - - -static ssize_t -show_attr_len_om4(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_int_attr(tobj_p, - tobj_p->get_len_om4, - buf_p); -} - - -static ssize_t -show_attr_comp_rev(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_hex_attr(tobj_p, - tobj_p->get_comp_rev, - buf_p); -} - - -static ssize_t -show_attr_comp_eth(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_hex_attr(tobj_p, - tobj_p->get_comp_eth_1, - buf_p); -} - - -static ssize_t -show_attr_comp_eth_10(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_hex_attr(tobj_p, - tobj_p->get_comp_eth_10, - buf_p); -} - - -static ssize_t -show_attr_comp_eth_10_40(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_hex_attr(tobj_p, - tobj_p->get_comp_eth_10_40, - buf_p); -} - - -static ssize_t -show_attr_comp_extend(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_hex_attr(tobj_p, - tobj_p->get_comp_extend, - buf_p); -} - - -static ssize_t -show_attr_rate_id(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_hex_attr(tobj_p, - tobj_p->get_rate_id, - buf_p); -} - - -static ssize_t -show_attr_temperature(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_curr_temp, - buf_p); -} - - -static ssize_t -show_attr_voltage(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_curr_vol, - buf_p); -} - - -static ssize_t -show_attr_tx_bias(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_tx_bias, - buf_p); -} - - -static ssize_t -show_attr_tx_power(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_tx_power, - buf_p); -} - - -static ssize_t -show_attr_tx_eq(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_tx_eq, - buf_p); -} - - -static ssize_t -show_attr_rx_power(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_rx_power, - buf_p); -} - - -static ssize_t -show_attr_rx_am(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_rx_am, - buf_p); -} - - -static ssize_t -show_attr_rx_em(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_rx_em, - buf_p); -} - - -static ssize_t -show_attr_wavelength(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_wavelength, - buf_p); -} - - -static ssize_t -show_attr_extphy_offset(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_extphy_offset, - buf_p); -} - - -static ssize_t -show_attr_extphy_reg(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_extphy_reg, - buf_p); -} - - -static ssize_t -show_attr_info(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_int_attr(tobj_p, - tobj_p->get_info, - buf_p); -} - - -static ssize_t -show_attr_if_type(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_if_type, - buf_p); -} - - -static ssize_t -show_attr_if_speed(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_if_speed, - buf_p); -} - - -static ssize_t -show_attr_if_lane(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_if_lane, - buf_p); -} - - -static ssize_t -show_attr_cdr(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_hex_attr(tobj_p, - tobj_p->get_cdr, - buf_p); -} - - -static ssize_t -show_attr_soft_rs0(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_int_attr(tobj_p, - tobj_p->get_soft_rs0, - buf_p); -} - - -static ssize_t -show_attr_soft_rs1(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_int_attr(tobj_p, - tobj_p->get_soft_rs1, - buf_p); -} - - -static ssize_t -show_attr_soft_rx_los(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_soft_rx_los, - buf_p); -} - - -static ssize_t -show_attr_soft_tx_disable(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_soft_tx_disable, - buf_p); -} - - -static ssize_t -show_attr_soft_tx_fault(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_soft_tx_fault, - buf_p); -} - - -static ssize_t -show_attr_auto_tx_disable(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_auto_tx_disable, - buf_p); -} - -static ssize_t -show_attr_eeprom(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_eeprom, - buf_p); -} - - -/* ========== Store functions: transceiver (R/W) attribute ========== - */ -static ssize_t -_store_transvr_int_attr(struct transvr_obj_s* tobj_p, - int (*set_func)(struct transvr_obj_s *tobj_p, int input_val), - const char *buf_p, - size_t count) { - int input, err; - - input = sscanf_2_int(buf_p); - if (input < 0){ - return -EBFONT; - } - lock_transvr_obj(tobj_p); - err = set_func(tobj_p, input); - unlock_transvr_obj(tobj_p); - if (err < 0){ - return err; - } - return count; -} - - -static ssize_t -_store_transvr_byte_hex_attr(struct transvr_obj_s* tobj_p, - int (*set_func)(struct transvr_obj_s *tobj_p, int input_val), - const char *buf_p, - size_t count) { - int input, err; - - input = sscanf_2_int(buf_p); - if ((input < 0) || (input > 0xff)){ - return -EBFONT; - } - lock_transvr_obj(tobj_p); - err = set_func(tobj_p, input); - unlock_transvr_obj(tobj_p); - if (err < 0){ - return err; - } - return count; -} - - -static ssize_t -_store_transvr_binary_attr(struct transvr_obj_s* tobj_p, - int (*set_func)(struct transvr_obj_s *tobj_p, int input_val), - const char *buf_p, - size_t count) { - int input, err; - - input = sscanf_2_binary(buf_p); - if (input < 0){ - return -EBFONT; - } - lock_transvr_obj(tobj_p); - err = set_func(tobj_p, input); - unlock_transvr_obj(tobj_p); - if (err < 0){ - return err; - } - return count; -} - - -static ssize_t -store_attr_cdr(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - return _store_transvr_byte_hex_attr(tobj_p, - tobj_p->set_cdr, - buf_p, - count); -} - - -static ssize_t -store_attr_soft_rs0(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - return _store_transvr_binary_attr(tobj_p, - tobj_p->set_soft_rs0, - buf_p, - count); -} - - -static ssize_t -store_attr_soft_rs1(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - return _store_transvr_binary_attr(tobj_p, - tobj_p->set_soft_rs1, - buf_p, - count); -} - - -static ssize_t -store_attr_soft_tx_disable(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count) { - - int check = sscanf_2_int(buf_p); - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - if ((check < 0) || (check > 0xf)){ - return -EBFONT; - } - return _store_transvr_byte_hex_attr(tobj_p, - tobj_p->set_soft_tx_disable, - buf_p, - count); -} - - -static ssize_t -store_attr_auto_tx_disable(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count) { - - int err = -EPERM; - int input = sscanf_2_int(buf_p); - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - if ((input < 0) || (input > 0xf)){ - if (input != VAL_TRANSVR_FUNCTION_DISABLE) { - return -EBFONT; - } - } - lock_transvr_obj(tobj_p); - err = tobj_p->set_auto_tx_disable(tobj_p, input); - unlock_transvr_obj(tobj_p); - if (err < 0){ - return err; - } - return count; -} - - -static ssize_t -store_attr_tx_eq(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - return _store_transvr_int_attr(tobj_p, - tobj_p->set_tx_eq, - buf_p, - count); -} - - -static ssize_t -store_attr_rx_am(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - return _store_transvr_int_attr(tobj_p, - tobj_p->set_rx_am, - buf_p, - count); -} - - -static ssize_t -store_attr_rx_em(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - return _store_transvr_int_attr(tobj_p, - tobj_p->set_rx_em, - buf_p, - count); -} - - -static ssize_t -store_attr_extphy_offset(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - return _store_transvr_int_attr(tobj_p, - tobj_p->set_extphy_offset, - buf_p, - count); -} - - -static ssize_t -store_attr_extphy_reg(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - return _store_transvr_int_attr(tobj_p, - tobj_p->set_extphy_reg, - buf_p, - count); -} - -/* ========== Show functions: For I/O Expander attribute ========== - */ -static ssize_t -_show_ioexp_binary_attr(struct transvr_obj_s *tobj_p, - int (*get_func)(struct ioexp_obj_s *ioexp_p, int voffset), - char *buf_p) { - size_t len; - struct ioexp_obj_s *ioexp_p = tobj_p->ioexp_obj_p; - - if (!ioexp_p) { - SWPS_ERR(" %s: data corruption! :%s\n", __func__, tobj_p->swp_name); - return -ENODATA; - } - mutex_lock(&ioexp_p->lock); - len = snprintf(buf_p, 8, "%d\n", get_func(ioexp_p, tobj_p->ioexp_virt_offset)); - mutex_unlock(&ioexp_p->lock); - return len; -} - - -static ssize_t -show_attr_present(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - return _show_ioexp_binary_attr(tobj_p, - tobj_p->ioexp_obj_p->get_present, - buf_p); -} - - -static ssize_t -show_attr_tx_fault(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - return _show_ioexp_binary_attr(tobj_p, - tobj_p->ioexp_obj_p->get_tx_fault, - buf_p); -} - - -static ssize_t -show_attr_rxlos(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - return _show_ioexp_binary_attr(tobj_p, - tobj_p->ioexp_obj_p->get_rxlos, - buf_p); -} - - -static ssize_t -show_attr_tx_disable(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - return _show_ioexp_binary_attr(tobj_p, - tobj_p->ioexp_obj_p->get_tx_disable, - buf_p); -} - - -static ssize_t -show_attr_reset(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - return _show_ioexp_binary_attr(tobj_p, - tobj_p->ioexp_obj_p->get_reset, - buf_p); -} - - -static ssize_t -show_attr_lpmod(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - return _show_ioexp_binary_attr(tobj_p, - tobj_p->ioexp_obj_p->get_lpmod, - buf_p); -} - - -static ssize_t -show_attr_modsel(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - return _show_ioexp_binary_attr(tobj_p, - tobj_p->ioexp_obj_p->get_modsel, - buf_p); -} - - -static ssize_t -show_attr_hard_rs0(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - return _show_ioexp_binary_attr(tobj_p, - tobj_p->ioexp_obj_p->get_hard_rs0, - buf_p); -} - - -static ssize_t -show_attr_hard_rs1(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - return _show_ioexp_binary_attr(tobj_p, - tobj_p->ioexp_obj_p->get_hard_rs1, - buf_p); -} - - -/* ========== Store functions: For I/O Expander (R/W) attribute ========== - */ -static ssize_t -_store_ioexp_binary_attr(struct transvr_obj_s *tobj_p, - int (*set_func)(struct ioexp_obj_s *ioexp_p, - int virt_offset, int input_val), - const char *buf_p, - size_t count) { - - int input, err; - struct ioexp_obj_s *ioexp_p = tobj_p->ioexp_obj_p; - - if (!ioexp_p) { - SWPS_ERR("%s: data corruption! :%s\n", - __func__, tobj_p->swp_name); - return -ENODATA; - } - input = sscanf_2_binary(buf_p); - if (input < 0) { - return -EBFONT; - } - mutex_lock(&ioexp_p->lock); - err = set_func(ioexp_p, tobj_p->ioexp_virt_offset, input); - mutex_unlock(&ioexp_p->lock); - if (err < 0){ - return err; - } - return count; -} - -static ssize_t -store_attr_tx_disable(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p) { - return -ENODEV; - } - return _store_ioexp_binary_attr(tobj_p, - tobj_p->ioexp_obj_p->set_tx_disable, - buf_p, - count); -} - - -static ssize_t -store_attr_reset(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p) { - return -ENODEV; - } - return _store_ioexp_binary_attr(tobj_p, - tobj_p->ioexp_obj_p->set_reset, - buf_p, - count); -} - - -static ssize_t -store_attr_lpmod(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p) { - return -ENODEV; - } - return _store_ioexp_binary_attr(tobj_p, - tobj_p->ioexp_obj_p->set_lpmod, - buf_p, - count); -} - - -static ssize_t -store_attr_modsel(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p) { - return -ENODEV; - } - return _store_ioexp_binary_attr(tobj_p, - tobj_p->ioexp_obj_p->set_modsel, - buf_p, - count); -} - - -static ssize_t -store_attr_hard_rs0(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p) { - return -ENODEV; - } - return _store_ioexp_binary_attr(tobj_p, - tobj_p->ioexp_obj_p->set_hard_rs0, - buf_p, - count); -} - - -static ssize_t -store_attr_hard_rs1(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p) { - return -ENODEV; - } - return _store_ioexp_binary_attr(tobj_p, - tobj_p->ioexp_obj_p->set_hard_rs1, - buf_p, - count); -} - - -/* ========== SWPS attribute: For module control ========== - */ -static DEVICE_ATTR(platform, S_IRUGO, show_attr_platform, NULL); -static DEVICE_ATTR(version, S_IRUGO, show_attr_version, NULL); -static DEVICE_ATTR(status, S_IRUGO, show_attr_status, NULL); -static DEVICE_ATTR(reset_i2c, S_IWUSR, NULL, store_attr_reset_i2c); -static DEVICE_ATTR(reset_swps, S_IWUSR, NULL, store_attr_reset_swps); -static DEVICE_ATTR(auto_config, S_IRUGO|S_IWUSR, show_attr_auto_config, store_attr_auto_config); -static DEVICE_ATTR(eeprom_update, S_IRUGO|S_IWUSR, show_attr_eeprom_update, store_attr_eeprom_update); - -/* ========== Transceiver attribute: from eeprom ========== - */ -static DEVICE_ATTR(id, S_IRUGO, show_attr_id, NULL); -static DEVICE_ATTR(ext_id, S_IRUGO, show_attr_ext_id, NULL); -static DEVICE_ATTR(connector, S_IRUGO, show_attr_connector, NULL); -static DEVICE_ATTR(vendor_name, S_IRUGO, show_attr_vendor_name, NULL); -static DEVICE_ATTR(vendor_pn, S_IRUGO, show_attr_vendor_pn, NULL); -static DEVICE_ATTR(vendor_rev, S_IRUGO, show_attr_vendor_rev, NULL); -static DEVICE_ATTR(vendor_sn, S_IRUGO, show_attr_vendor_sn, NULL); -static DEVICE_ATTR(power_cls, S_IRUGO, show_attr_power_cls, NULL); -static DEVICE_ATTR(br, S_IRUGO, show_attr_br, NULL); -static DEVICE_ATTR(len_sm, S_IRUGO, show_attr_len_sm, NULL); -static DEVICE_ATTR(len_smf, S_IRUGO, show_attr_len_smf, NULL); -static DEVICE_ATTR(len_om1, S_IRUGO, show_attr_len_om1, NULL); -static DEVICE_ATTR(len_om2, S_IRUGO, show_attr_len_om2, NULL); -static DEVICE_ATTR(len_om3, S_IRUGO, show_attr_len_om3, NULL); -static DEVICE_ATTR(len_om4, S_IRUGO, show_attr_len_om4, NULL); -static DEVICE_ATTR(comp_rev, S_IRUGO, show_attr_comp_rev, NULL); -static DEVICE_ATTR(comp_eth, S_IRUGO, show_attr_comp_eth, NULL); -static DEVICE_ATTR(comp_eth_10, S_IRUGO, show_attr_comp_eth_10, NULL); -static DEVICE_ATTR(comp_eth_10_40, S_IRUGO, show_attr_comp_eth_10_40, NULL); -static DEVICE_ATTR(comp_extend, S_IRUGO, show_attr_comp_extend, NULL); -static DEVICE_ATTR(rate_id, S_IRUGO, show_attr_rate_id, NULL); -static DEVICE_ATTR(temperature, S_IRUGO, show_attr_temperature, NULL); -static DEVICE_ATTR(voltage, S_IRUGO, show_attr_voltage, NULL); -static DEVICE_ATTR(tx_bias, S_IRUGO, show_attr_tx_bias, NULL); -static DEVICE_ATTR(tx_power, S_IRUGO, show_attr_tx_power, NULL); -static DEVICE_ATTR(rx_power, S_IRUGO, show_attr_rx_power, NULL); -static DEVICE_ATTR(info, S_IRUGO, show_attr_info, NULL); -static DEVICE_ATTR(if_type, S_IRUGO, show_attr_if_type, NULL); -static DEVICE_ATTR(if_speed, S_IRUGO, show_attr_if_speed, NULL); -static DEVICE_ATTR(if_lane, S_IRUGO, show_attr_if_lane, NULL); -static DEVICE_ATTR(soft_rx_los, S_IRUGO, show_attr_soft_rx_los, NULL); -static DEVICE_ATTR(soft_tx_fault, S_IRUGO, show_attr_soft_tx_fault, NULL); -static DEVICE_ATTR(wavelength, S_IRUGO, show_attr_wavelength, NULL); -static DEVICE_ATTR(eeprom, S_IRUGO, show_attr_eeprom, NULL); -static DEVICE_ATTR(tx_eq, S_IRUGO|S_IWUSR, show_attr_tx_eq, store_attr_tx_eq); -static DEVICE_ATTR(rx_am, S_IRUGO|S_IWUSR, show_attr_rx_am, store_attr_rx_am); -static DEVICE_ATTR(rx_em, S_IRUGO|S_IWUSR, show_attr_rx_em, store_attr_rx_em); -static DEVICE_ATTR(cdr, S_IRUGO|S_IWUSR, show_attr_cdr, store_attr_cdr); -static DEVICE_ATTR(soft_rs0, S_IRUGO|S_IWUSR, show_attr_soft_rs0, store_attr_soft_rs0); -static DEVICE_ATTR(soft_rs1, S_IRUGO|S_IWUSR, show_attr_soft_rs1, store_attr_soft_rs1); -static DEVICE_ATTR(soft_tx_disable, S_IRUGO|S_IWUSR, show_attr_soft_tx_disable, store_attr_soft_tx_disable); -static DEVICE_ATTR(auto_tx_disable, S_IRUGO|S_IWUSR, show_attr_auto_tx_disable, store_attr_auto_tx_disable); -static DEVICE_ATTR(extphy_offset, S_IRUGO|S_IWUSR, show_attr_extphy_offset, store_attr_extphy_offset); -static DEVICE_ATTR(extphy_reg, S_IRUGO|S_IWUSR, show_attr_extphy_reg, store_attr_extphy_reg); - -/* ========== IO Expander attribute: from expander ========== - */ -static DEVICE_ATTR(present, S_IRUGO, show_attr_present, NULL); -static DEVICE_ATTR(tx_fault, S_IRUGO, show_attr_tx_fault, NULL); -static DEVICE_ATTR(rxlos, S_IRUGO, show_attr_rxlos, NULL); -static DEVICE_ATTR(tx_disable, S_IRUGO|S_IWUSR, show_attr_tx_disable, store_attr_tx_disable); -static DEVICE_ATTR(reset, S_IRUGO|S_IWUSR, show_attr_reset, store_attr_reset); -static DEVICE_ATTR(lpmod, S_IRUGO|S_IWUSR, show_attr_lpmod, store_attr_lpmod); -static DEVICE_ATTR(modsel, S_IRUGO|S_IWUSR, show_attr_modsel, store_attr_modsel); -static DEVICE_ATTR(hard_rs0, S_IRUGO|S_IWUSR, show_attr_hard_rs0, store_attr_hard_rs0); -static DEVICE_ATTR(hard_rs1, S_IRUGO|S_IWUSR, show_attr_hard_rs1, store_attr_hard_rs1); - -/* ========== Functions for module handling ========== - */ -static void -clean_port_obj(void){ - - dev_t dev_num; - char dev_name[32]; - struct device *device_p; - struct transvr_obj_s *transvr_obj_p; - int minor_curr, port_id; - - for (minor_curr=0; minor_curri2c_client_p); - kfree(transvr_obj_p->vendor_name); - kfree(transvr_obj_p->vendor_pn); - kfree(transvr_obj_p->vendor_rev); - kfree(transvr_obj_p->vendor_sn); - kfree(transvr_obj_p->worker_p); - kfree(transvr_obj_p); - } - dev_num = MKDEV(port_major, minor_curr); - device_unregister(device_p); - device_destroy(swp_class_p, dev_num); - } - SWPS_DEBUG("%s: done.\n", __func__); -} - - -static void -clean_swps_common(void){ - - dev_t dev_num; - struct device *device_p; - - device_p = get_swpdev_by_name(SWP_DEV_MODCTL); - if (device_p){ - dev_num = MKDEV(ctl_major, 1); - device_unregister(device_p); - device_destroy(swp_class_p, dev_num); - } - cancel_delayed_work_sync(&swp_polling); - SWPS_DEBUG("%s: done.\n", __func__); -} - - -static int -get_platform_type(void){ - - int i; - int pf_total = ARRAY_SIZE(platform_map); - char log_msg[64] = "ERROR"; - - platform_p = kzalloc(sizeof(struct inv_platform_s), GFP_KERNEL); - if (!platform_p){ - snprintf(log_msg, sizeof(log_msg), "kzalloc fail"); - goto err_get_platform_type_1; - } - memset(platform_p->name, 0, sizeof(platform_p->name)); - - switch (PLATFORM_SETTINGS) { - case PLATFORM_TYPE_AUTO: - snprintf(platform_p->name, (sizeof(platform_p->name) - 1), - "%s", dmi_get_system_info(DMI_BOARD_NAME)); - for (i=0; iname, platform_map[i].name) == 0) { - platform_p->id = platform_map[i].id; - snprintf(log_msg, sizeof(log_msg), - "Auto detect platform: %d (%s)", - platform_p->id, platform_p->name); - goto ok_get_platform_type_1; - } - } - snprintf(log_msg, sizeof(log_msg), - "Auto detect fail! detect platform: %s", - platform_p->name); - goto err_get_platform_type_2; - - case PLATFORM_TYPE_MAGNOLIA: - case PLATFORM_TYPE_MAGNOLIA_FNC: - case PLATFORM_TYPE_REDWOOD: - case PLATFORM_TYPE_REDWOOD_FSL: - case PLATFORM_TYPE_HUDSON32I_GA: - case PLATFORM_TYPE_SPRUCE: - case PLATFORM_TYPE_CYPRESS_GA1: - case PLATFORM_TYPE_CYPRESS_GA2: - case PLATFORM_TYPE_CYPRESS_BAI: - case PLATFORM_TYPE_TAHOE: - case PLATFORM_TYPE_SEQUOIA_GA: - case PLATFORM_TYPE_LAVENDER_GA: - case PLATFORM_TYPE_LAVENDER_ONL: - case PLATFORM_TYPE_COTTONWOOD_RANGELEY: - case PLATFORM_TYPE_MAPLE: - platform_p->id = PLATFORM_SETTINGS; - for (i=0; iname, (sizeof(platform_p->name) - 1), - "%s", platform_map[i].name); - snprintf(log_msg, sizeof(log_msg), - "User setup platform: %d (%s)", - platform_p->id, platform_p->name); - goto ok_get_platform_type_1; - } - } - snprintf(log_msg, sizeof(log_msg), - "Internal error, can not map id:%d", - PLATFORM_SETTINGS); - goto err_get_platform_type_2; - - default: - break; - } - snprintf(log_msg, sizeof(log_msg), - "PLATFORM_SETTINGS:%d undefined", PLATFORM_SETTINGS); - goto err_get_platform_type_2; - -ok_get_platform_type_1: - SWPS_DEBUG("%s: %s, :%d\n", __func__, log_msg, PLATFORM_SETTINGS); - return 0; - -err_get_platform_type_2: - kfree(platform_p); -err_get_platform_type_1: - SWPS_ERR("%s: %s :%d\n", __func__, log_msg, PLATFORM_SETTINGS); - return -1; -} - - -static int -get_layout_info(void){ - - switch (platform_p->id) { -#ifdef SWPS_MAGNOLIA - case PLATFORM_TYPE_MAGNOLIA: - case PLATFORM_TYPE_MAGNOLIA_FNC: - gpio_rest_mux = magnolia_gpio_rest_mux; - ioexp_layout = magnolia_ioexp_layout; - port_layout = magnolia_port_layout; - ioexp_total = ARRAY_SIZE(magnolia_ioexp_layout); - port_total = ARRAY_SIZE(magnolia_port_layout); - break; -#endif -#ifdef SWPS_REDWOOD - case PLATFORM_TYPE_REDWOOD: - gpio_rest_mux = redwood_gpio_rest_mux; - ioexp_layout = redwood_ioexp_layout; - port_layout = redwood_port_layout; - ioexp_total = ARRAY_SIZE(redwood_ioexp_layout); - port_total = ARRAY_SIZE(redwood_port_layout); - break; -#endif -#ifdef SWPS_HUDSON32I_GA - case PLATFORM_TYPE_HUDSON32I_GA: - gpio_rest_mux = hudsin32iga_gpio_rest_mux; - ioexp_layout = hudson32iga_ioexp_layout; - port_layout = hudson32iga_port_layout; - ioexp_total = ARRAY_SIZE(hudson32iga_ioexp_layout); - port_total = ARRAY_SIZE(hudson32iga_port_layout); - break; -#endif -#ifdef SWPS_SPRUCE - case PLATFORM_TYPE_SPRUCE: - gpio_rest_mux = spruce_gpio_rest_mux; - ioexp_layout = spruce_ioexp_layout; - port_layout = spruce_port_layout; - ioexp_total = ARRAY_SIZE(spruce_ioexp_layout); - port_total = ARRAY_SIZE(spruce_port_layout); - break; -#endif -#ifdef SWPS_CYPRESS_GA1 - case PLATFORM_TYPE_CYPRESS_GA1: - gpio_rest_mux = cypress_ga1_gpio_rest_mux; - ioexp_layout = cypress_ga1_ioexp_layout; - port_layout = cypress_ga1_port_layout; - ioexp_total = ARRAY_SIZE(cypress_ga1_ioexp_layout); - port_total = ARRAY_SIZE(cypress_ga1_port_layout); - break; -#endif -#ifdef SWPS_CYPRESS_GA2 - case PLATFORM_TYPE_CYPRESS_GA2: - gpio_rest_mux = cypress_ga2_gpio_rest_mux; - ioexp_layout = cypress_ga2_ioexp_layout; - port_layout = cypress_ga2_port_layout; - ioexp_total = ARRAY_SIZE(cypress_ga2_ioexp_layout); - port_total = ARRAY_SIZE(cypress_ga2_port_layout); - break; -#endif -#ifdef SWPS_CYPRESS_BAI - case PLATFORM_TYPE_CYPRESS_BAI: - gpio_rest_mux = cypress_b_gpio_rest_mux; - ioexp_layout = cypress_b_ioexp_layout; - port_layout = cypress_b_port_layout; - ioexp_total = ARRAY_SIZE(cypress_b_ioexp_layout); - port_total = ARRAY_SIZE(cypress_b_port_layout); - break; -#endif -#ifdef SWPS_REDWOOD_FSL - case PLATFORM_TYPE_REDWOOD_FSL: - gpio_rest_mux = redwood_fsl_gpio_rest_mux; - ioexp_layout = redwood_fsl_ioexp_layout; - port_layout = redwood_fsl_port_layout; - ioexp_total = ARRAY_SIZE(redwood_fsl_ioexp_layout); - port_total = ARRAY_SIZE(redwood_fsl_port_layout); - break; -#endif -#ifdef SWPS_TAHOE - case PLATFORM_TYPE_TAHOE: - gpio_rest_mux = tahoe_gpio_rest_mux; - ioexp_layout = tahoe_ioexp_layout; - port_layout = tahoe_port_layout; - ioexp_total = ARRAY_SIZE(tahoe_ioexp_layout); - port_total = ARRAY_SIZE(tahoe_port_layout); - break; -#endif -#ifdef SWPS_SEQUOIA - case PLATFORM_TYPE_SEQUOIA_GA: - gpio_rest_mux = sequoia_gpio_rest_mux; - ioexp_layout = sequoia_ioexp_layout; - port_layout = sequoia_port_layout; - ioexp_total = ARRAY_SIZE(sequoia_ioexp_layout); - port_total = ARRAY_SIZE(sequoia_port_layout); - break; -#endif -#ifdef SWPS_LAVENDER - case PLATFORM_TYPE_LAVENDER_GA: - case PLATFORM_TYPE_LAVENDER_ONL: - gpio_rest_mux = lavender_gpio_rest_mux; - ioexp_layout = lavender_ioexp_layout; - port_layout = lavender_port_layout; - ioexp_total = ARRAY_SIZE(lavender_ioexp_layout); - port_total = ARRAY_SIZE(lavender_port_layout); - break; -#endif -#ifdef SWPS_COTTONWOOD_RANGELEY - case PLATFORM_TYPE_COTTONWOOD_RANGELEY: - gpio_rest_mux = cottonwood_rangeley_gpio_rest_mux; - ioexp_layout = cottonwood_rangeley_ioexp_layout; - port_layout = cottonwood_rangeley_port_layout; - ioexp_total = ARRAY_SIZE(cottonwood_rangeley_ioexp_layout); - port_total = ARRAY_SIZE(cottonwood_rangeley_port_layout); - break; -#endif -#ifdef SWPS_MAPLE - case PLATFORM_TYPE_MAPLE: - gpio_rest_mux = maple_gpio_rest_mux; - ioexp_layout = maple_ioexp_layout; - port_layout = maple_port_layout; - ioexp_total = ARRAY_SIZE(maple_ioexp_layout); - port_total = ARRAY_SIZE(maple_port_layout); - break; -#endif - default: - SWPS_ERR(" Invalid platform: %d (%s)\n", - platform_p->id, platform_p->name); - return -1; - } - SWPS_INFO("Start to initial platform: %d (%s)\n", - platform_p->id, platform_p->name); - return 0; -} - - -/* ========== Functions for objects operations ========== - */ -static int -__detect_issues_port(int minor_num) { - - struct transvr_obj_s *tobj_p; - int port_id = port_layout[minor_num].port_id; - char port_name[32] = "ERR"; - char *i2c_emsg = "detected bad transceiver/cable"; - - memset(port_name, 0, sizeof(port_name)); - snprintf(port_name, sizeof(port_name), "%s%d", SWP_DEV_PORT, port_id); - tobj_p = _get_transvr_obj(port_name); - if (!tobj_p) { - SWPS_INFO("%s: tobj_p is NULL :%d\n", __func__, minor_num); - return -1; - } - if (resync_channel_tier_2(tobj_p) < 0) { - if (check_channel_tier_1() < 0) { - alarm_msg_2_user(tobj_p, i2c_emsg); - return -2;; - } - } - return 0; -} - - -static int -_detect_issues_port(void) { - /* OK : retrun -1; - * Fail: return fail at which minor number (0~N) - */ - char *emsg = "ERR"; - int minor = 0; - int minor_2st = 1; - - /* Force moving the initial channel pointer - * Filter out case of fail at minor-0 port - */ - while (minor_2st < port_total) { - minor = minor_2st; - if (__detect_issues_port(minor_2st) < 0) { - emsg = "detect minor_2st fail"; - goto err_p_detect_issues_port; - } - minor_2st += 8; - } - /* Scan all port */ - for (minor=0; minor:%d\n", __func__, emsg, minor_err); - return -1; -} - - -static int -check_transvr_obj_one(char *dev_name){ - /* [Return] - * 0 : Doesn't need to take care - * -1 : Single error - * -2 : Critical error (I2C topology die) - * -9 : Internal error - */ - struct transvr_obj_s *tobj_p = NULL; - int retval = -9; - - tobj_p = _get_transvr_obj(dev_name); - if (!tobj_p) { - SWPS_ERR("%s: %s _get_transvr_obj fail\n", - __func__, dev_name); - return -9; - } - /* Check transceiver current status */ - lock_transvr_obj(tobj_p); - retval = tobj_p->check(tobj_p); - unlock_transvr_obj(tobj_p); - switch (retval) { - case 0: - case ERR_TRANSVR_UNPLUGGED: - case ERR_TRNASVR_BE_ISOLATED: - case ERR_TRANSVR_TASK_BUSY: - return 0; - - case ERR_TRANSVR_I2C_CRASH: - default: - break; - } - /* Identify abnormal case */ - if (check_channel_tier_1() < 0) { - SWPS_DEBUG("%s: %s critical error :%d\n", - __func__, dev_name, retval); - return -2; - } - SWPS_DEBUG("%s: %s single error :%d\n", - __func__, dev_name, retval); - return -1; -} - - -static int -check_transvr_objs(void){ - - char dev_name[32]; - int port_id, err_code; - int minor_curr = 0; - - for (minor_curr=0; minor_curr:%d\n", - __func__, dev_name, err_code); - break; - } - } - return 0; - -err_check_transvr_objs: - SWPS_ERR("%s: %s reset_i2c_topology fail.\n", - __func__, dev_name); - return -1; -} - - -static void -swp_polling_worker(struct work_struct *work){ - - /* Reset I2C */ - if (flag_i2c_reset) { - goto polling_reset_i2c; - } - /* Check IOEXP */ - if (check_ioexp_objs() < 0) { - goto polling_reset_i2c; - } - /* Check transceiver */ - if (check_transvr_objs() < 0) { - SWPS_DEBUG("%s: check_transvr_objs fail.\n", __func__); - flag_i2c_reset = 1; - } - goto polling_schedule_round; - -polling_reset_i2c: - SWPS_DEBUG("%s: reset_i2c_topology start.\n", __func__); - if (reset_i2c_topology() < 0) { - SWPS_ERR("%s: reset i2c fail!\n", __func__); - flag_i2c_reset = 1; - } else { - SWPS_DEBUG("%s: reset_i2c_topology OK.\n", __func__); - flag_i2c_reset = 0; - } -polling_schedule_round: - schedule_delayed_work(&swp_polling, _get_polling_period()); -} - - -/* ========== Functions for register something ========== - */ -static int -register_transvr_common_attr(struct device *device_p){ - - char *err_attr = NULL; - - if (device_create_file(device_p, &dev_attr_id) < 0) { - err_attr = "dev_attr_id"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_ext_id) < 0) { - err_attr = "dev_attr_ext_id"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_connector) < 0) { - err_attr = "dev_attr_connector"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_vendor_name) < 0) { - err_attr = "dev_attr_vendor_name"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_vendor_pn) < 0) { - err_attr = "dev_attr_vendor_pn"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_vendor_rev) < 0) { - err_attr = "dev_attr_vendor_rev"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_vendor_sn) < 0) { - err_attr = "dev_attr_vendor_sn"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_br) < 0) { - err_attr = "dev_attr_br"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_len_smf) < 0) { - err_attr = "dev_attr_len_smf"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_len_om1) < 0) { - err_attr = "dev_attr_len_om1"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_len_om2) < 0) { - err_attr = "dev_attr_len_om2"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_len_om3) < 0) { - err_attr = "dev_attr_len_om3"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_len_om4) < 0) { - err_attr = "dev_attr_len_om4"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_comp_extend) < 0) { - err_attr = "dev_attr_comp_extend"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_comp_eth) < 0) { - err_attr = "dev_attr_comp_eth"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_comp_rev) < 0) { - err_attr = "dev_attr_comp_rev"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_info) < 0) { - err_attr = "dev_attr_info"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_if_type) < 0) { - err_attr = "dev_attr_if_type"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_if_speed) < 0) { - err_attr = "dev_attr_if_speed"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_if_lane) < 0) { - err_attr = "dev_attr_if_lane"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_temperature) < 0) { - err_attr = "dev_attr_temperature"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_voltage) < 0) { - err_attr = "dev_attr_voltage"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_tx_bias) < 0) { - err_attr = "dev_attr_tx_bias"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_tx_power) < 0) { - err_attr = "dev_attr_tx_power"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_rx_power) < 0) { - err_attr = "dev_attr_rx_power"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_tx_eq) < 0) { - err_attr = "dev_attr_tx_eq"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_rx_em) < 0) { - err_attr = "dev_attr_rx_em"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_wavelength) < 0) { - err_attr = "dev_attr_wavelength"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_eeprom) < 0) { - err_attr = "dev_attr_eeprom"; - goto err_transvr_comm_attr; - } - return 0; - -err_transvr_comm_attr: - SWPS_ERR("%s: %s\n", __func__, err_attr); - return -1; -} - -static int -register_transvr_sfp_attr(struct device *device_p){ - - char *err_attr = NULL; - - if (register_transvr_common_attr(device_p) < 0) { - err_attr = "register_transvr_common_attr"; - goto err_transvr_sfp_attr; - } - if (device_create_file(device_p, &dev_attr_comp_eth_10) < 0) { - err_attr = "dev_attr_comp_eth_10"; - goto err_transvr_sfp_attr; - } - if (device_create_file(device_p, &dev_attr_len_sm) < 0) { - err_attr = "dev_attr_len_sm"; - goto err_transvr_sfp_attr; - } - if (device_create_file(device_p, &dev_attr_rate_id) < 0) { - err_attr = "dev_attr_rate_id"; - goto err_transvr_sfp_attr; - } - if (device_create_file(device_p, &dev_attr_soft_rs0) < 0) { - err_attr = "dev_attr_soft_rs0"; - goto err_transvr_sfp_attr; - } - if (device_create_file(device_p, &dev_attr_soft_rs1) < 0) { - err_attr = "dev_attr_soft_rs1"; - goto err_transvr_sfp_attr; - } - if (device_create_file(device_p, &dev_attr_extphy_offset) < 0) { - err_attr = "dev_attr_extphy_offset"; - goto err_transvr_sfp_attr; - } - if (device_create_file(device_p, &dev_attr_extphy_reg) < 0) { - err_attr = "dev_attr_extphy_reg"; - goto err_transvr_sfp_attr; - } - return 0; - -err_transvr_sfp_attr: - SWPS_ERR("%s: %s\n", __func__, err_attr); - return -1; -} - - -static int -register_transvr_qsfp_attr(struct device *device_p){ - - char *err_attr = NULL; - - if (register_transvr_common_attr(device_p) < 0) { - err_attr = "register_transvr_common_attr"; - goto err_transvr_qsfp_attr; - } - if (device_create_file(device_p, &dev_attr_comp_eth_10_40) < 0) { - err_attr = "dev_attr_comp_eth_10_40"; - goto err_transvr_qsfp_attr; - } - if (device_create_file(device_p, &dev_attr_power_cls) < 0) { - err_attr = "dev_attr_power_cls"; - goto err_transvr_qsfp_attr; - } - if (device_create_file(device_p, &dev_attr_soft_rx_los) < 0) { - err_attr = "soft_rx_los"; - goto err_transvr_qsfp_attr; - } - if (device_create_file(device_p, &dev_attr_soft_tx_disable) < 0) { - err_attr = "soft_tx_disable"; - goto err_transvr_qsfp_attr; - } - if (device_create_file(device_p, &dev_attr_auto_tx_disable) < 0) { - err_attr = "auto_tx_disable"; - goto err_transvr_qsfp_attr; - } - if (device_create_file(device_p, &dev_attr_soft_tx_fault) < 0) { - err_attr = "soft_tx_fault"; - goto err_transvr_qsfp_attr; - } - return 0; - -err_transvr_qsfp_attr: - SWPS_ERR("%s: %s\n", __func__, err_attr); - return -1; -} - - -static int -register_transvr_qsfp28_attr(struct device *device_p){ - - char *err_attr = NULL; - - if (register_transvr_qsfp_attr(device_p) < 0){ - err_attr = "register_transvr_qsfp_attr"; - goto err_transvr_qsfp28_attr; - } - if (device_create_file(device_p, &dev_attr_cdr) < 0) { - err_attr = "dev_attr_cdr"; - goto err_transvr_qsfp28_attr; - } - if (device_create_file(device_p, &dev_attr_rx_am) < 0) { - err_attr = "dev_attr_rx_am"; - goto err_transvr_qsfp28_attr; - } - return 0; - -err_transvr_qsfp28_attr: - SWPS_ERR("%s: %s\n", __func__, err_attr); - return -1; -} - - -static int -register_transvr_attr(struct device *device_p, - struct transvr_obj_s *transvr_obj){ - - switch (transvr_obj->layout){ - case TRANSVR_TYPE_SFP: - if (register_transvr_sfp_attr(device_p) < 0){ - goto err_reg_tvr_attr; - } - break; - case TRANSVR_TYPE_QSFP: - case TRANSVR_TYPE_QSFP_PLUS: - if (register_transvr_qsfp_attr(device_p) < 0){ - goto err_reg_tvr_attr; - } - break; - case TRANSVR_TYPE_QSFP_28: - if (register_transvr_qsfp28_attr(device_p) < 0){ - goto err_reg_tvr_attr; - } - break; - default: - goto err_reg_tvr_attr; - } - return 0; - -err_reg_tvr_attr: - SWPS_ERR("%s: fail! type=%d \n", __func__, transvr_obj->type); - return -1; -} - - -static int -register_ioexp_attr_sfp_1(struct device *device_p){ - /* Support machine type: - * - SFP : Magnolia - */ - char *err_attr = NULL; - - if (device_create_file(device_p, &dev_attr_present) < 0) { - err_attr = "dev_attr_present"; - goto err_ioexp_sfp1_attr; - } - if (device_create_file(device_p, &dev_attr_tx_fault) < 0) { - err_attr = "dev_attr_tx_fault"; - goto err_ioexp_sfp1_attr; - } - if (device_create_file(device_p, &dev_attr_rxlos) < 0) { - err_attr = "dev_attr_rxlos"; - goto err_ioexp_sfp1_attr; - } - if (device_create_file(device_p, &dev_attr_tx_disable) < 0) { - err_attr = "dev_attr_tx_disable"; - goto err_ioexp_sfp1_attr; - } - return 0; - -err_ioexp_sfp1_attr: - SWPS_ERR("Add device attribute:%s failure! \n",err_attr); - return -1; -} - - -static int -register_ioexp_attr_sfp_2(struct device *device_p){ - /* Support machine type: - * - SFP28 : Cypress - */ - char *err_attr = NULL; - - if (register_ioexp_attr_sfp_1(device_p) < 0){ - goto err_ioexp_sfp2_attr; - } - if (device_create_file(device_p, &dev_attr_hard_rs0) < 0) { - err_attr = "dev_attr_hard_rs0"; - goto err_ioexp_sfp2_attr; - } - if (device_create_file(device_p, &dev_attr_hard_rs1) < 0) { - err_attr = "dev_attr_hard_rs1"; - goto err_ioexp_sfp2_attr; - } - return 0; - -err_ioexp_sfp2_attr: - SWPS_ERR("Add device attribute:%s failure! \n",err_attr); - return -1; -} - - -static int -register_ioexp_attr_qsfp_1(struct device *device_p){ - /* Support machine type: - * - QSFP : Magnolia, Redwood, Hudson32i - * - QSFP+ : Magnolia, Redwood, Hudson32i - * - QSFP28: Redwood - */ - char *err_attr = NULL; - - if (device_create_file(device_p, &dev_attr_present) < 0) { - err_attr = "dev_attr_present"; - goto err_ioexp_qsfp1_attr; - } - if (device_create_file(device_p, &dev_attr_reset) < 0) { - err_attr = "dev_attr_reset"; - goto err_ioexp_qsfp1_attr; - } - if (device_create_file(device_p, &dev_attr_lpmod) < 0) { - err_attr = "dev_attr_lpmod"; - goto err_ioexp_qsfp1_attr; - } - if (device_create_file(device_p, &dev_attr_modsel) < 0) { - err_attr = "dev_attr_modsel"; - goto err_ioexp_qsfp1_attr; - } - return 0; - -err_ioexp_qsfp1_attr: - SWPS_ERR("Add device attribute:%s failure! \n",err_attr); - return -1; -} - - -static int -register_modctl_attr(struct device *device_p){ - - char *err_msg = NULL; - - if (device_create_file(device_p, &dev_attr_platform) < 0) { - err_msg = "dev_attr_platform"; - goto err_reg_modctl_attr; - } - if (device_create_file(device_p, &dev_attr_version) < 0) { - err_msg = "dev_attr_version"; - goto err_reg_modctl_attr; - } - if (device_create_file(device_p, &dev_attr_status) < 0) { - err_msg = "dev_attr_status"; - goto err_reg_modctl_attr; - } - if (device_create_file(device_p, &dev_attr_reset_i2c) < 0) { - err_msg = "dev_attr_reset_i2c"; - goto err_reg_modctl_attr; - } - if (device_create_file(device_p, &dev_attr_reset_swps) < 0) { - err_msg = "dev_attr_reset_swps"; - goto err_reg_modctl_attr; - } - if (device_create_file(device_p, &dev_attr_auto_config) < 0) { - err_msg = "dev_attr_auto_config"; - goto err_reg_modctl_attr; - } - if (device_create_file(device_p, &dev_attr_eeprom_update) < 0) { - err_msg = "dev_attr_eeprom_update"; - goto err_reg_modctl_attr; - } - return 0; - -err_reg_modctl_attr: - SWPS_ERR("%s: %s\n", __func__, err_msg); - return -1; -} - - -static int -register_ioexp_attr(struct device *device_p, - struct transvr_obj_s *transvr_obj){ - - char *err_msg = "ERR"; - - switch (transvr_obj->ioexp_obj_p->ioexp_type){ - case IOEXP_TYPE_MAGINOLIA_NAB: - case IOEXP_TYPE_MAGINOLIA_4AB: - case CPLD_TYPE_COTTONWOOD: - if (register_ioexp_attr_sfp_1(device_p) < 0){ - err_msg = "register_ioexp_attr_sfp_1 fail"; - goto err_reg_ioexp_attr; - } - break; - case IOEXP_TYPE_CYPRESS_NABC: - case IOEXP_TYPE_MAPLE_NABC: - if (register_ioexp_attr_sfp_2(device_p) < 0){ - err_msg = "register_ioexp_attr_sfp_2 fail"; - goto err_reg_ioexp_attr; - } - break; - case IOEXP_TYPE_MAGINOLIA_7AB: - case IOEXP_TYPE_SPRUCE_7AB: - case IOEXP_TYPE_CYPRESS_7ABC: - case IOEXP_TYPE_REDWOOD_P01P08: - case IOEXP_TYPE_REDWOOD_P09P16: - case IOEXP_TYPE_HUDSON32IGA_P01P08: - case IOEXP_TYPE_HUDSON32IGA_P09P16: - case IOEXP_TYPE_TAHOE_5A: - case IOEXP_TYPE_TAHOE_6ABC: - case IOEXP_TYPE_SEQUOIA_NABC: - case IOEXP_TYPE_LAVENDER_P65: - case IOEXP_TYPE_MAPLE_0ABC: - if (register_ioexp_attr_qsfp_1(device_p) < 0){ - err_msg = "register_ioexp_attr_qsfp_1 fail"; - goto err_reg_ioexp_attr; - } - break; - - default: - err_msg = "Unknow type"; - goto err_reg_ioexp_attr; - } - return 0; - -err_reg_ioexp_attr: - SWPS_ERR("%s: %s :%d \n", - __func__, err_msg, transvr_obj->ioexp_obj_p->ioexp_type); - return -1; -} - - -static int -register_modctl_device(void) { - - struct device *device_p = NULL; - int minor_comm = 0; /* Default minor number for common device */ - dev_t dev_num = MKDEV(ctl_major, minor_comm); - char *err_msg = "ERROR"; - - device_p = device_create(swp_class_p, /* struct class *cls */ - NULL, /* struct device *parent */ - dev_num, /* dev_t devt */ - NULL, /* void *private_data */ - SWP_DEV_MODCTL); /* const char *fmt */ - if (IS_ERR(device_p)){ - err_msg = "device_create fail"; - goto err_register_modctl_device_1; - } - if (register_modctl_attr(device_p) < 0) { - err_msg = "register_modctl_attr fail"; - goto err_register_modctl_device_2; - } - return 0; - -err_register_modctl_device_2: - device_unregister(device_p); - device_destroy(swp_class_p, dev_num); -err_register_modctl_device_1: - SWPS_ERR("%s: %s\n", __func__, err_msg); - return -1; -} - - -static int -register_port_device(char *dev_name, - dev_t dev_num, - struct transvr_obj_s *transvr_obj){ - - struct device *device_p = NULL; - device_p = device_create(swp_class_p, /* struct class *cls */ - NULL, /* struct device *parent */ - dev_num, /* dev_t devt */ - transvr_obj, /* void *private_data */ - dev_name); /* const char *fmt */ - if (IS_ERR(device_p)){ - goto err_regswp_create_dev; - } - if (register_transvr_attr(device_p, transvr_obj) < 0){ - goto err_regswp_reg_attr; - } - if (register_ioexp_attr(device_p, transvr_obj) < 0){ - goto err_regswp_reg_attr; - } - return 0; - -err_regswp_reg_attr: - device_unregister(device_p); - device_destroy(swp_class_p, dev_num); -err_regswp_create_dev: - SWPS_ERR("%s fail! :%s\n", __func__, dev_name); - return -1; -} - - -static int -register_swp_module(void){ - - dev_t ctl_devt = 0; - dev_t port_devt = 0; - int dev_total = port_total + 1; /* char_dev for module control */ - - /* Register device number */ - if (alloc_chrdev_region(&ctl_devt, 0, 1, SWP_DEV_MODCTL) < 0){ - SWPS_WARN("Allocate CTL MAJOR failure! \n"); - goto err_register_swp_module_1; - } - if (alloc_chrdev_region(&port_devt, 0, dev_total, SWP_CLS_NAME) < 0){ - SWPS_WARN("Allocate PORT MAJOR failure! \n"); - goto err_register_swp_module_2; - } - ctl_major = MAJOR(ctl_devt); - port_major = MAJOR(port_devt); - - /* Create class object */ - swp_class_p = class_create(THIS_MODULE, SWP_CLS_NAME); - if (IS_ERR(swp_class_p)) { - SWPS_ERR("Create class failure! \n"); - goto err_register_swp_module_3; - } - return 0; - -err_register_swp_module_3: - unregister_chrdev_region(MKDEV(port_major, 0), port_total); -err_register_swp_module_2: - unregister_chrdev_region(MKDEV(ctl_major, 0), 1); -err_register_swp_module_1: - return -1; -} - - -/* ========== Module initial relate ========== - */ -static int -create_ioexp_objs(void) { - - int i, run_mod; - - /* Clean IOEXP object */ - clean_ioexp_objs(); - /* Get running mode */ - run_mod = IOEXP_MODE_DIRECT; - if (SWP_POLLING_ENABLE){ - run_mod = IOEXP_MODE_POLLING; - } - /* Create IOEXP object */ - for(i=0; i devlen_max) { - snprintf(err_msg, sizeof(err_msg), - "SWP_DEV_PORT too long!"); - goto err_initport_create_tranobj; - } - memset(dev_name, 0, sizeof(dev_name)); - snprintf(dev_name, devlen_max, "%s%d", SWP_DEV_PORT, port_id); - /* Create transceiver object */ - ioexp_obj_p = get_ioexp_obj(ioexp_id); - if (!ioexp_obj_p){ - snprintf(err_msg, sizeof(err_msg), - "IOEXP object:%d not exist", ioexp_id); - goto err_initport_create_tranobj; - } - transvr_obj_p = create_transvr_obj(dev_name, chan_id, ioexp_obj_p, - ioexp_virt_offset, transvr_type, - chipset_type, run_mod); - if (!transvr_obj_p){ - snprintf(err_msg, sizeof(err_msg), - "Create transceiver object fail :%s", dev_name); - goto err_initport_create_tranobj; - } - - transvr_obj_p->port_no = minor_curr; - - /* Setup Lane_ID mapping */ - i = ARRAY_SIZE(port_layout[minor_curr].lane_id); - j = ARRAY_SIZE(transvr_obj_p->lane_id); - if (i != j) { - snprintf(err_msg, sizeof(err_msg), - "Lane_id size inconsistent %d/%d", i, j); - goto err_initport_reg_device; - } - memcpy(transvr_obj_p->lane_id, port_layout[minor_curr].lane_id, i*sizeof(int)); - /* Create and register device object */ - if (register_port_device(dev_name, MKDEV(port_major, minor_curr), transvr_obj_p) < 0){ - snprintf(err_msg, sizeof(err_msg), - "register_port_device fail"); - goto err_initport_reg_device; - } - /* Setup device_ptr of transvr_obj */ - dev_p = get_swpdev_by_name(dev_name); - if (!dev_p){ - snprintf(err_msg, sizeof(err_msg), - "get_swpdev_by_name fail"); - goto err_initport_reg_device; - } - transvr_obj_p->transvr_dev_p = dev_p; - /* Success */ - ok_count++; - } - SWPS_INFO("%s: initialed %d port-dev",__func__, ok_count); - return 0; - -err_initport_reg_device: - kfree(transvr_obj_p); -err_initport_create_tranobj: - clean_port_obj(); - SWPS_ERR("%s: %s", __func__, err_msg); - SWPS_ERR("Dump: :%d :%d :%d :%d :%d :%d\n", - port_id, chan_id, ioexp_id, ioexp_virt_offset, transvr_type, run_mod); - return -1; -} - - -static int -init_dev_topology(void){ - - int err; - char *emsg = "ERR"; - flag_mod_state = SWP_STATE_NORMAL; - - err = init_ioexp_objs(); - switch(err){ - case 0: /* Normal */ - SWPS_DEBUG("%s: normal case\n", __func__); - break; - - case -1: /* topology error */ - SWPS_DEBUG("%s: detect tier-1 topology initial failure :%d\n", - __func__, err); - /* Reset and isolate */ - err = reset_i2c_topology(); - if (err < 0) { - emsg = "reset i2c topology fail"; - goto err_init_dev_topology; - } - /* Re-initial again */ - err = init_ioexp_objs(); - if (err < 0) { - emsg = "re-init ioexp objects fail"; - goto err_init_dev_topology; - } - break; - - case -2: /* Internal error */ - SWPS_DEBUG("%s: internal error case\n", __func__); - err = -2; - emsg = "internal error"; - goto err_init_dev_topology; - - default: - SWPS_DEBUG("%s: undefined error case\n", __func__); - emsg = "undefined error case"; - goto err_init_dev_topology; - } - SWPS_DEBUG("%s: initial I2C topology success\n", __func__); - return 0; - -err_init_dev_topology: - SWPS_ERR("%s: %s :%d\n", __func__, emsg, err); - return -1; -} - - -static int -init_polling_task(void){ - - if (SWP_POLLING_ENABLE){ - schedule_delayed_work(&swp_polling, _get_polling_period()); - } - return 0; -} - - -static int -init_swps_common(void){ - - char *err_msg = "ERR"; - - auto_config = 0; - if ((SWP_AUTOCONFIG_ENABLE) && (SWP_POLLING_ENABLE)){ - auto_config = 1; - } - if (register_modctl_device() < 0) { - err_msg = "register_modctl_device fail"; - goto err_init_swps_common_1; - } - if (_update_auto_config_2_trnasvr() < 0) { - err_msg = "_update_auto_config_2_trnasvr fail"; - goto err_init_swps_common_1; - } - if (init_polling_task() < 0){ - err_msg = "init_polling_task fail"; - goto err_init_swps_common_1; - } - return 0; - -err_init_swps_common_1: - clean_swps_common(); - SWPS_ERR("%s: %s\n", __func__, err_msg); - return -1; -} - - -static int __init -swp_module_init(void){ - - if (get_platform_type() < 0){ - goto err_init_out; - } - if (get_layout_info() < 0){ - goto err_init_out; - } - if (register_swp_module() < 0){ - goto err_init_out; - } - if (create_ioexp_objs() < 0){ - goto err_init_ioexp; - } - if (create_port_objs() < 0){ - goto err_init_portobj; - } - if (init_mux_gpio(gpio_rest_mux) < 0){ - goto err_init_mux; - } - if (init_dev_topology() < 0){ - goto err_init_topology; - } - if (init_swps_common() < 0){ - goto err_init_topology; - } - - SWPS_INFO("Inventec switch-port module V.%s initial success.\n", SWP_VERSION); - return 0; - - -err_init_topology: - clean_mux_gpio(); -err_init_mux: - clean_port_obj(); -err_init_portobj: - clean_ioexp_objs(); -err_init_ioexp: - class_unregister(swp_class_p); - class_destroy(swp_class_p); - unregister_chrdev_region(MKDEV(ctl_major, 0), 1); - unregister_chrdev_region(MKDEV(port_major, 0), port_total); -err_init_out: - SWPS_ERR("Inventec switch-port module V.%s initial failure.\n", SWP_VERSION); - return -1; -} - - -static void __exit -swp_module_exit(void){ - - clean_swps_common(); - clean_port_obj(); - clean_ioexp_objs(); - clean_mux_gpio(); - class_unregister(swp_class_p); - class_destroy(swp_class_p); - unregister_chrdev_region(MKDEV(ctl_major, 0), 1); - unregister_chrdev_region(MKDEV(port_major, 0), port_total); - SWPS_INFO("Remove Inventec switch-port module success.\n"); -} - - -/* Module information */ -MODULE_AUTHOR(SWP_AUTHOR); -MODULE_DESCRIPTION(SWP_DESC); -MODULE_VERSION(SWP_VERSION); -MODULE_LICENSE(SWP_LICENSE); - -module_init(swp_module_init); -module_exit(swp_module_exit); diff --git a/packages/platforms/inventec/x86-64/d6556/modules/builds/src/inv_swps.h b/packages/platforms/inventec/x86-64/d6556/modules/builds/src/inv_swps.h deleted file mode 100644 index c97809193..000000000 --- a/packages/platforms/inventec/x86-64/d6556/modules/builds/src/inv_swps.h +++ /dev/null @@ -1,1153 +0,0 @@ -#ifndef INV_SWPS_H -#define INV_SWPS_H - -#include "transceiver.h" -#include "io_expander.h" -#include "inv_mux.h" - -/* Module settings */ -#define SWP_CLS_NAME "swps" -#define SWP_DEV_PORT "port" -#define SWP_DEV_MODCTL "module" -#define SWP_RESET_PWD "inventec" -#define SWP_POLLING_PERIOD (300) /* msec */ -#define SWP_POLLING_ENABLE (1) -#define SWP_AUTOCONFIG_ENABLE (1) - -/* Module information */ -#define SWP_AUTHOR "Neil " -#define SWP_DESC "Inventec port and transceiver driver" -#define SWP_VERSION "4.2.9" -#define SWP_LICENSE "GPL" - -/* Module status define */ -#define SWP_STATE_NORMAL (0) -#define SWP_STATE_I2C_DIE (-91) - -#define INV_BATOI(a) ((a>='0'&&a<='9')?(a-'0'):(-1)) -#define INV_BATOX(a) ((a>='0'&&a<='9')?(a-'0'):((a>='a'&&a<='f')?(a-'a'+10):((a >='A'&&a<='F')?(a-'A'+10):-1))) - -/* [Note]: - * Functions and mechanism for auto-detect platform type is ready, - * But HW and BIOS not ready! We need to wait them. - * So, please do not use PLATFORM_TYPE_AUTO until they are ready. - * (2016.06.13) - */ -#define PLATFORM_TYPE_AUTO (100) -#define PLATFORM_TYPE_MAGNOLIA (111) -#define PLATFORM_TYPE_MAGNOLIA_FNC (112) -#define PLATFORM_TYPE_REDWOOD (121) -#define PLATFORM_TYPE_REDWOOD_FSL (122) -#define PLATFORM_TYPE_HUDSON32I_GA (131) -#define PLATFORM_TYPE_SPRUCE (141) -#define PLATFORM_TYPE_CYPRESS_GA1 (151) /* Up -> Down */ -#define PLATFORM_TYPE_CYPRESS_GA2 (152) /* Down -> Up */ -#define PLATFORM_TYPE_CYPRESS_BAI (153) /* Down -> Up */ -#define PLATFORM_TYPE_TAHOE (161) -#define PLATFORM_TYPE_SEQUOIA_GA (171) -#define PLATFORM_TYPE_LAVENDER_GA (181) -#define PLATFORM_TYPE_LAVENDER_ONL (182) -#define PLATFORM_TYPE_COTTONWOOD_RANGELEY (191) -#define PLATFORM_TYPE_MAPLE (201) -/* Current running platfrom */ -#define PLATFORM_SETTINGS PLATFORM_TYPE_MAPLE - -/* Define platform flag and kernel version */ -#if (PLATFORM_SETTINGS == PLATFORM_TYPE_MAGNOLIA) - #define SWPS_MAGNOLIA (1) - #define SWPS_KERN_VER_BF_3_8 (1) -#elif (PLATFORM_SETTINGS == PLATFORM_TYPE_MAGNOLIA_FNC) - #define SWPS_MAGNOLIA (1) - #define SWPS_KERN_VER_AF_3_10 (1) -#elif (PLATFORM_SETTINGS == PLATFORM_TYPE_REDWOOD) - #define SWPS_REDWOOD (1) - #define SWPS_KERN_VER_BF_3_8 (1) -#elif (PLATFORM_SETTINGS == PLATFORM_TYPE_REDWOOD_FSL) - #define SWPS_REDWOOD_FSL (1) - #define SWPS_KERN_VER_BF_3_8 (1) -#elif (PLATFORM_SETTINGS == PLATFORM_TYPE_HUDSON32I_GA) - #define SWPS_HUDSON32I_GA (1) - #define SWPS_KERN_VER_BF_3_8 (1) -#elif (PLATFORM_SETTINGS == PLATFORM_TYPE_SPRUCE) - #define SWPS_SPRUCE (1) - #define SWPS_KERN_VER_BF_3_8 (1) -#elif (PLATFORM_SETTINGS == PLATFORM_TYPE_CYPRESS_GA1) - #define SWPS_CYPRESS_GA1 (1) - #define SWPS_KERN_VER_BF_3_8 (1) -#elif (PLATFORM_SETTINGS == PLATFORM_TYPE_CYPRESS_GA2) - #define SWPS_CYPRESS_GA2 (1) - #define SWPS_KERN_VER_BF_3_8 (1) -#elif (PLATFORM_SETTINGS == PLATFORM_TYPE_CYPRESS_BAI) - #define SWPS_CYPRESS_BAI (1) - #define SWPS_KERN_VER_AF_3_10 (1) -#elif (PLATFORM_SETTINGS == PLATFORM_TYPE_TAHOE) - #define SWPS_TAHOE (1) - #define SWPS_KERN_VER_AF_3_10 (1) -#elif (PLATFORM_SETTINGS == PLATFORM_TYPE_SEQUOIA_GA) - #define SWPS_SEQUOIA (1) - #define SWPS_KERN_VER_BF_3_8 (1) -#elif (PLATFORM_SETTINGS == PLATFORM_TYPE_LAVENDER_GA) - #define SWPS_LAVENDER (1) - #define SWPS_KERN_VER_AF_3_10 (1) -#elif (PLATFORM_SETTINGS == PLATFORM_TYPE_LAVENDER_ONL) - #define SWPS_LAVENDER (1) - #define SWPS_KERN_VER_AF_3_10 (1) -#elif (PLATFORM_SETTINGS == PLATFORM_TYPE_COTTONWOOD_RANGELEY) - #define SWPS_COTTONWOOD_RANGELEY (1) - #define SWPS_KERN_VER_AF_3_10 (1) -#elif (PLATFORM_SETTINGS == PLATFORM_TYPE_MAPLE) - #define SWPS_MAPLE (1) - #define SWPS_KERN_VER_AF_3_10 (1) -#endif - - -struct inv_platform_s { - int id; - char name[64]; -}; - -struct inv_ioexp_layout_s { - int ioexp_id; - int ioexp_type; - struct ioexp_addr_s addr[4]; -}; - -struct inv_port_layout_s { - int port_id; - int chan_id; - int ioexp_id; - int ioexp_offset; - int transvr_type; - int chipset_type; - int lane_id[8]; -}; - - -/* ========================================== - * Inventec Platform Settings - * ========================================== - */ -struct inv_platform_s platform_map[] = { - {PLATFORM_TYPE_AUTO, "Auto-Detect" }, - {PLATFORM_TYPE_MAGNOLIA, "Magnolia" }, - {PLATFORM_TYPE_MAGNOLIA_FNC, "Magnolia_FNC" }, - {PLATFORM_TYPE_REDWOOD, "Redwood" }, - {PLATFORM_TYPE_REDWOOD_FSL, "Redwood_FSL" }, - {PLATFORM_TYPE_HUDSON32I_GA, "Hudson32i" }, - {PLATFORM_TYPE_SPRUCE, "Spruce" }, - {PLATFORM_TYPE_CYPRESS_GA1, "Cypress_GA1" }, - {PLATFORM_TYPE_CYPRESS_GA2, "Cypress_GA2" }, - {PLATFORM_TYPE_CYPRESS_BAI, "Cypress_BAI" }, - {PLATFORM_TYPE_TAHOE, "Tahoe" }, - {PLATFORM_TYPE_SEQUOIA_GA, "Sequoia_GA" }, - {PLATFORM_TYPE_LAVENDER_GA, "Lavender_GA" }, - {PLATFORM_TYPE_LAVENDER_ONL, "Lavender_ONL" }, - {PLATFORM_TYPE_COTTONWOOD_RANGELEY, "Cottonwood_RANGELEY" }, - {PLATFORM_TYPE_MAPLE, "Maple" }, -}; - - -/* ========================================== - * Magnolia Layout configuration - * ========================================== - */ -#ifdef SWPS_MAGNOLIA -unsigned magnolia_gpio_rest_mux = MUX_RST_GPIO_48_PAC9548; - -struct inv_ioexp_layout_s magnolia_ioexp_layout[] = { - /* IOEXP_ID / IOEXP_TYPE / { Chan_ID, Chip_addr, Read_offset, Write_offset, config_offset, data_default, conf_default } */ - {0, IOEXP_TYPE_MAGINOLIA_NAB, { {2, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {2, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, }, /* addr[1] = I/O Expander N B */ - }, - {1, IOEXP_TYPE_MAGINOLIA_NAB, { {3, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {3, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, }, /* addr[1] = I/O Expander N B */ - }, - {2, IOEXP_TYPE_MAGINOLIA_NAB, { {4, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {4, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, }, /* addr[1] = I/O Expander N B */ - }, - {3, IOEXP_TYPE_MAGINOLIA_4AB, { {5, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander 4 A */ - {5, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xf0, 0xff}, {0xf0, 0xff}, }, }, /* addr[1] = I/O Expander 4 B */ - }, - {4, IOEXP_TYPE_MAGINOLIA_NAB, { {6, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {6, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, }, /* addr[1] = I/O Expander N B */ - }, - {5, IOEXP_TYPE_MAGINOLIA_NAB, { {7, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {7, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, }, /* addr[1] = I/O Expander N B */ - }, - {6, IOEXP_TYPE_MAGINOLIA_7AB, { {8, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[0] = I/O Expander 7 A */ - {8, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xf0, 0x33}, }, }, /* addr[1] = I/O Expander 7 B */ - }, -}; - -struct inv_port_layout_s magnolia_port_layout[] = { - /* Port_ID / Chan_ID / IOEXP_ID / IOEXP_VIRT_OFFSET / TRANSCEIVER_TYPE / BCM_CHIP_TYPE / LANE_ID */ - { 0, 10, 0, 0, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 16} }, - { 1, 11, 0, 1, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 15} }, - { 2, 12, 0, 2, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 14} }, - { 3, 13, 0, 3, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 13} }, - { 4, 14, 0, 4, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 24} }, - { 5, 15, 0, 5, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 23} }, - { 6, 16, 0, 6, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 22} }, - { 7, 17, 0, 7, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 21} }, - { 8, 18, 1, 0, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 28} }, - { 9, 19, 1, 1, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 27} }, - {10, 20, 1, 2, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 26} }, - {11, 21, 1, 3, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 25} }, - {12, 22, 1, 4, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 32} }, - {13, 23, 1, 5, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 31} }, - {14, 24, 1, 6, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 30} }, - {15, 25, 1, 7, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 29} }, - {16, 26, 2, 0, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 48} }, - {17, 27, 2, 1, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 47} }, - {18, 28, 2, 2, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 46} }, - {19, 29, 2, 3, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 45} }, - {20, 30, 2, 4, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 52} }, - {21, 31, 2, 5, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 51} }, - {22, 32, 2, 6, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 50} }, - {23, 33, 2, 7, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 49} }, - {24, 34, 3, 0, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 56} }, - {25, 35, 3, 1, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 55} }, - {26, 36, 3, 2, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 54} }, - {27, 37, 3, 3, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 53} }, - {28, 38, 3, 4, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 60} }, - {29, 39, 3, 5, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 59} }, - {30, 40, 3, 6, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 58} }, - {31, 41, 3, 7, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 57} }, - {32, 42, 4, 0, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 64} }, - {33, 43, 4, 1, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 63} }, - {34, 44, 4, 2, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 62} }, - {35, 45, 4, 3, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 61} }, - {36, 46, 4, 4, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 68} }, - {37, 47, 4, 5, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 67} }, - {38, 48, 4, 6, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 66} }, - {39, 49, 4, 7, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 65} }, - {40, 50, 5, 0, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 72} }, - {41, 51, 5, 1, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 71} }, - {42, 52, 5, 2, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 70} }, - {43, 53, 5, 3, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 69} }, - {44, 54, 5, 4, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 76} }, - {45, 55, 5, 5, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 75} }, - {46, 56, 5, 6, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 74} }, - {47, 57, 5, 7, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 73} }, - {48, 58, 6, 0, TRANSVR_TYPE_QSFP, BCM_CHIP_TYPE_TRIDENT_2, { 81, 82, 83, 84} }, - {49, 59, 6, 1, TRANSVR_TYPE_QSFP, BCM_CHIP_TYPE_TRIDENT_2, { 77, 78, 79, 80} }, - {50, 60, 6, 2, TRANSVR_TYPE_QSFP, BCM_CHIP_TYPE_TRIDENT_2, { 97, 98, 99,100} }, - {51, 61, 6, 3, TRANSVR_TYPE_QSFP, BCM_CHIP_TYPE_TRIDENT_2, {101,102,103,104} }, - {52, 62, 6, 4, TRANSVR_TYPE_QSFP, BCM_CHIP_TYPE_TRIDENT_2, {105,106,107,108} }, - {53, 63, 6, 5, TRANSVR_TYPE_QSFP, BCM_CHIP_TYPE_TRIDENT_2, {109,110,111,112} }, -}; -#endif - - -/* ========================================== - * Redwood Layout configuration - * ========================================== - */ -#ifdef SWPS_REDWOOD -unsigned redwood_gpio_rest_mux = MUX_RST_GPIO_48_PAC9548; - -struct inv_ioexp_layout_s redwood_ioexp_layout[] = { - /* IOEXP_ID / IOEXP_TYPE / { Chan_ID, Chip_addr, Read_offset, Write_offset, config_offset, data_default, conf_default } */ - {0, IOEXP_TYPE_REDWOOD_P01P08, { {4, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[0] = I/O Expander 1-4 A */ - {4, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[1] = I/O Expander 1-4 B */ - {0, 0x25, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 5 B */ - }, - {1, IOEXP_TYPE_REDWOOD_P09P16, { {5, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[0] = I/O Expander 1-4 A */ - {5, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[1] = I/O Expander 1-4 B */ - {0, 0x25, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 5 B */ - }, - {2, IOEXP_TYPE_REDWOOD_P01P08, { {2, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[0] = I/O Expander 1-4 A */ - {2, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[1] = I/O Expander 1-4 B */ - {0, 0x24, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 5 B */ - }, - {3, IOEXP_TYPE_REDWOOD_P09P16, { {3, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[0] = I/O Expander 1-4 A */ - {3, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[1] = I/O Expander 1-4 B */ - {0, 0x24, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 5 B */ - }, -}; - -struct inv_port_layout_s redwood_port_layout[] = { - /* Port_ID / Chan_ID / IOEXP_ID / IOEXP_VIRT_OFFSET / TRANSCEIVER_TYPE / BCM_CHIP_TYPE / LANE_ID */ - { 0, 22, 0, 0, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 1, 2, 3, 4} }, - { 1, 23, 0, 1, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 5, 6, 7, 8} }, - { 2, 24, 0, 2, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 9, 10, 11, 12} }, - { 3, 25, 0, 3, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 13, 14, 15, 16} }, - { 4, 26, 0, 4, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 17, 18, 19, 20} }, - { 5, 27, 0, 5, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 21, 22, 23, 24} }, - { 6, 28, 0, 6, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 25, 26, 27, 28} }, - { 7, 29, 0, 7, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 29, 30, 31, 32} }, - { 8, 30, 1, 0, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 33, 34, 35, 36} }, - { 9, 31, 1, 1, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 37, 38, 39, 40} }, - {10, 32, 1, 2, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 41, 42, 43, 44} }, - {11, 33, 1, 3, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 45, 46, 47, 48} }, - {12, 34, 1, 4, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 49, 50, 51, 52} }, - {13, 35, 1, 5, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 53, 54, 55, 56} }, - {14, 36, 1, 6, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 57, 58, 59, 60} }, - {15, 37, 1, 7, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 61, 62, 63, 64} }, - {16, 6, 2, 0, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 65, 66, 67, 68} }, - {17, 7, 2, 1, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 69, 70, 71, 72} }, - {18, 8, 2, 2, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 73, 74, 75, 76} }, - {19, 9, 2, 3, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 77, 78, 79, 80} }, - {20, 10, 2, 4, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 81, 82, 83, 84} }, - {21, 11, 2, 5, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 85, 86, 87, 88} }, - {22, 12, 2, 6, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 89, 90, 91, 92} }, - {23, 13, 2, 7, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 93, 94, 95, 96} }, - {24, 14, 3, 0, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 97, 98, 99,100} }, - {25, 15, 3, 1, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {101,102,103,104} }, - {26, 16, 3, 2, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {105,106,107,108} }, - {27, 17, 3, 3, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {109,110,111,112} }, - {28, 18, 3, 4, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {113,114,115,116} }, - {29, 19, 3, 5, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {117,118,119,120} }, - {30, 20, 3, 6, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {121,122,123,124} }, - {31, 21, 3, 7, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {125,126,127,128} }, -}; -#endif - - -/* ========================================== - * Hudson32i Layout configuration - * ========================================== - */ -#ifdef SWPS_HUDSON32I_GA -unsigned hudsin32iga_gpio_rest_mux = MUX_RST_GPIO_48_PAC9548; - -struct inv_ioexp_layout_s hudson32iga_ioexp_layout[] = { - /* IOEXP_ID / IOEXP_TYPE / { Chan_ID, Chip_addr, Read_offset, Write_offset, config_offset, data_default, conf_default } */ - {0, IOEXP_TYPE_HUDSON32IGA_P01P08, { {2, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[0] = I/O Expander A */ - {2, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[1] = I/O Expander B */ - {0, 0x24, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 0x24 */ - }, - {1, IOEXP_TYPE_HUDSON32IGA_P09P16, { {3, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[0] = I/O Expander A */ - {3, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[1] = I/O Expander B */ - {0, 0x24, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 0x24 */ - }, - {2, IOEXP_TYPE_HUDSON32IGA_P01P08, { {4, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[0] = I/O Expander A */ - {4, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[1] = I/O Expander B */ - {0, 0x25, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 0x25 */ - }, - {3, IOEXP_TYPE_HUDSON32IGA_P09P16, { {5, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[0] = I/O Expander A */ - {5, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[1] = I/O Expander B */ - {0, 0x25, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 0x25 */ - }, -}; - -struct inv_port_layout_s hudson32iga_port_layout[] = { - /* Port_ID / Chan_ID / IOEXP_ID / IOEXP_VIRT_OFFSET / TRANSCEIVER_TYPE / BCM_CHIP_TYPE / LANE_ID */ - { 0, 6, 0, 0, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, { 1, 2, 3, 4} }, - { 1, 7, 0, 1, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, { 5, 6, 7, 8} }, - { 2, 8, 0, 2, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, { 9, 10, 11, 12} }, - { 3, 9, 0, 3, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, { 13, 14, 15, 16} }, - { 4, 10, 0, 4, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, { 17, 18, 19, 20} }, - { 5, 11, 0, 5, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, { 21, 22, 23, 24} }, - { 6, 12, 0, 6, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, { 25, 26, 27, 28} }, - { 7, 13, 0, 7, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, { 29, 30, 31, 32} }, - { 8, 14, 1, 0, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, { 33, 34, 35, 36} }, - { 9, 15, 1, 1, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, { 37, 38, 39, 40} }, - {10, 16, 1, 2, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, { 41, 42, 43, 44} }, - {11, 17, 1, 3, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, { 45, 46, 47, 48} }, - {12, 18, 1, 4, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, { 49, 50, 51, 52} }, - {13, 19, 1, 5, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, { 53, 54, 55, 56} }, - {14, 20, 1, 6, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, { 57, 58, 59, 60} }, - {15, 21, 1, 7, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, { 61, 62, 63, 64} }, - {16, 22, 2, 0, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, { 65, 66, 67, 68} }, - {17, 23, 2, 1, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, { 69, 70, 71, 72} }, - {18, 24, 2, 2, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, { 73, 74, 75, 76} }, - {19, 25, 2, 3, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, { 77, 78, 79, 80} }, - {20, 26, 2, 4, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, { 81, 82, 83, 84} }, - {21, 27, 2, 5, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, { 85, 86, 87, 88} }, - {22, 28, 2, 6, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, { 89, 90, 91, 92} }, - {23, 29, 2, 7, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, { 93, 94, 95, 96} }, - {24, 30, 3, 0, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, { 97, 98, 99,100} }, - {25, 31, 3, 1, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, {101,102,103,104} }, - {26, 32, 3, 2, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, {105,106,107,108} }, - {27, 33, 3, 3, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, {109,110,111,112} }, - {28, 34, 3, 4, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, {113,114,115,116} }, - {29, 35, 3, 5, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, {117,118,119,120} }, - {30, 36, 3, 6, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, {121,122,123,124} }, - {31, 37, 3, 7, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, {125,126,127,128} }, -}; -#endif - - -/* ========================================== - * Spruce Layout configuration - * ========================================== - */ -#ifdef SWPS_SPRUCE -unsigned spruce_gpio_rest_mux = MUX_RST_GPIO_48_PAC9548; - -struct inv_ioexp_layout_s spruce_ioexp_layout[] = { - /* IOEXP_ID / IOEXP_TYPE / { Chan_ID, Chip_addr, Read_offset, Write_offset, config_offset, data_default, conf_default } */ - {0, IOEXP_TYPE_SPRUCE_7AB, { {2, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[0] = I/O Expander 7A */ - {2, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xf0, 0x33}, }, }, /* addr[2] = I/O Expander 7B */ - }, -}; - -struct inv_port_layout_s spruce_port_layout[] = { - /* Port_ID / Chan_ID / IOEXP_ID / IOEXP_VIRT_OFFSET / TRANSCEIVER_TYPE / BCM_CHIP_TYPE / LANE_ID */ - { 0, 6, 0, 0, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, { 81, 82, 83, 84} }, - { 1, 7, 0, 1, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, { 77, 78, 79, 80} }, - { 2, 8, 0, 2, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, { 97, 98, 99,100} }, - { 3, 9, 0, 3, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, {101,102,103,104} }, - { 4, 10, 0, 4, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, {105,106,107,108} }, - { 5, 11, 0, 5, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, {109,110,111,112} }, -}; -#endif - - -/* ========================================== - * Cypress Layout configuration (Inventec version [Up->Down]) - * ========================================== - */ -#ifdef SWPS_CYPRESS_GA1 -unsigned cypress_ga1_gpio_rest_mux = MUX_RST_GPIO_69_PAC9548; - -struct inv_ioexp_layout_s cypress_ga1_ioexp_layout[] = { - /* IOEXP_ID / IOEXP_TYPE / { Chan_ID, Chip_addr, Read_offset, Write_offset, config_offset, data_default, conf_default } */ - {0, IOEXP_TYPE_CYPRESS_NABC, { {2, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {2, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {2, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {1, IOEXP_TYPE_CYPRESS_NABC, { {3, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {3, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {3, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {2, IOEXP_TYPE_CYPRESS_NABC, { {4, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {4, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {4, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {3, IOEXP_TYPE_CYPRESS_NABC, { {5, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {5, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {5, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {4, IOEXP_TYPE_CYPRESS_NABC, { {6, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {6, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {6, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {5, IOEXP_TYPE_CYPRESS_NABC, { {7, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {7, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {7, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {6, IOEXP_TYPE_CYPRESS_7ABC, { {8, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xc0, 0xc0}, }, /* addr[0] = I/O Expander 7 A */ - {8, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xc0, 0xc0}, {0xff, 0xc0}, }, /* addr[1] = I/O Expander 7 B */ - {8, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 7 C */ - }, -}; - -struct inv_port_layout_s cypress_ga1_port_layout[] = { - /* Port_ID / Chan_ID / IOEXP_ID / IOEXP_VIRT_OFFSET / TRANSCEIVER_TYPE / BCM_CHIP_TYPE / LANE_ID */ - { 0, 10, 0, 0, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 1} }, - { 1, 11, 0, 1, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 2} }, - { 2, 12, 0, 2, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 3} }, - { 3, 13, 0, 3, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 4} }, - { 4, 14, 0, 4, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 5} }, - { 5, 15, 0, 5, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 6} }, - { 6, 16, 0, 6, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 7} }, - { 7, 17, 0, 7, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 8} }, - { 8, 18, 1, 0, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 9} }, - { 9, 19, 1, 1, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 10} }, - {10, 20, 1, 2, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 11} }, - {11, 21, 1, 3, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 12} }, - {12, 22, 1, 4, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 21} }, - {13, 23, 1, 5, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 22} }, - {14, 24, 1, 6, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 23} }, - {15, 25, 1, 7, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 24} }, - {16, 26, 2, 0, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 33} }, - {17, 27, 2, 1, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 34} }, - {18, 28, 2, 2, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 35} }, - {19, 29, 2, 3, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 36} }, - {20, 30, 2, 4, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 37} }, - {21, 31, 2, 5, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 38} }, - {22, 32, 2, 6, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 39} }, - {23, 33, 2, 7, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 40} }, - {24, 34, 3, 0, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 41} }, - {25, 35, 3, 1, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 42} }, - {26, 36, 3, 2, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 43} }, - {27, 37, 3, 3, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 44} }, - {28, 38, 3, 4, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 49} }, - {29, 39, 3, 5, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 50} }, - {30, 40, 3, 6, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 51} }, - {31, 41, 3, 7, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 52} }, - {32, 42, 4, 0, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 53} }, - {33, 43, 4, 1, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 54} }, - {34, 44, 4, 2, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 55} }, - {35, 45, 4, 3, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 56} }, - {36, 46, 4, 4, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 65} }, - {37, 47, 4, 5, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 66} }, - {38, 48, 4, 6, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 67} }, - {39, 49, 4, 7, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 68} }, - {40, 50, 5, 0, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 69} }, - {41, 51, 5, 1, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 70} }, - {42, 52, 5, 2, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 71} }, - {43, 53, 5, 3, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 72} }, - {44, 54, 5, 4, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 81} }, - {45, 55, 5, 5, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 82} }, - {46, 56, 5, 6, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 83} }, - {47, 57, 5, 7, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 84} }, - {48, 58, 6, 0, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 97, 98, 99,100} }, - {49, 59, 6, 1, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 85, 86, 87, 88} }, - {50, 60, 6, 2, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {101,102,103,104} }, - {51, 61, 6, 3, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {105,106,107,108} }, - {52, 62, 6, 4, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {109,110,111,112} }, - {53, 63, 6, 5, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {117,118,119,120} }, -}; -#endif - - -/* ========================================== - * Cypress Layout configuration (Inventec version [Down->Up]) - * ========================================== - */ -#ifdef SWPS_CYPRESS_GA2 -unsigned cypress_ga2_gpio_rest_mux = MUX_RST_GPIO_FORCE_HEDERA; - -struct inv_ioexp_layout_s cypress_ga2_ioexp_layout[] = { - /* IOEXP_ID / IOEXP_TYPE / { Chan_ID, Chip_addr, Read_offset, Write_offset, config_offset, data_default, conf_default } */ - {0, IOEXP_TYPE_CYPRESS_NABC, { {2, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {2, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {2, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {1, IOEXP_TYPE_CYPRESS_NABC, { {3, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {3, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {3, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {2, IOEXP_TYPE_CYPRESS_NABC, { {4, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {4, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {4, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {3, IOEXP_TYPE_CYPRESS_NABC, { {5, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {5, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {5, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {4, IOEXP_TYPE_CYPRESS_NABC, { {6, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {6, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {6, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {5, IOEXP_TYPE_CYPRESS_NABC, { {7, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {7, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {7, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {6, IOEXP_TYPE_CYPRESS_7ABC, { {8, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xc0, 0xc0}, }, /* addr[0] = I/O Expander 7 A */ - {8, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xc0, 0xc0}, {0xff, 0xc0}, }, /* addr[1] = I/O Expander 7 B */ - {8, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 7 C */ - }, -}; - -struct inv_port_layout_s cypress_ga2_port_layout[] = { - /* Port_ID / Chan_ID / IOEXP_ID / IOEXP_VIRT_OFFSET / TRANSCEIVER_TYPE / BCM_CHIP_TYPE / LANE_ID */ - { 0, 11, 0, 1, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 2} }, - { 1, 10, 0, 0, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 1} }, - { 2, 13, 0, 3, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 4} }, - { 3, 12, 0, 2, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 3} }, - { 4, 15, 0, 5, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 6} }, - { 5, 14, 0, 4, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 5} }, - { 6, 17, 0, 7, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 8} }, - { 7, 16, 0, 6, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 7} }, - { 8, 19, 1, 1, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 10} }, - { 9, 18, 1, 0, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 9} }, - {10, 21, 1, 3, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 12} }, - {11, 20, 1, 2, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 11} }, - {12, 23, 1, 5, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 22} }, - {13, 22, 1, 4, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 21} }, - {14, 25, 1, 7, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 24} }, - {15, 24, 1, 6, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 23} }, - {16, 27, 2, 1, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 34} }, - {17, 26, 2, 0, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 33} }, - {18, 29, 2, 3, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 36} }, - {19, 28, 2, 2, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 35} }, - {20, 31, 2, 5, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 38} }, - {21, 30, 2, 4, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 37} }, - {22, 33, 2, 7, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 40} }, - {23, 32, 2, 6, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 39} }, - {24, 35, 3, 1, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 42} }, - {25, 34, 3, 0, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 41} }, - {26, 37, 3, 3, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 44} }, - {27, 36, 3, 2, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 43} }, - {28, 39, 3, 5, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 50} }, - {29, 38, 3, 4, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 49} }, - {30, 41, 3, 7, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 52} }, - {31, 40, 3, 6, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 51} }, - {32, 43, 4, 1, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 54} }, - {33, 42, 4, 0, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 53} }, - {34, 45, 4, 3, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 56} }, - {35, 44, 4, 2, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 55} }, - {36, 47, 4, 5, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 66} }, - {37, 46, 4, 4, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 65} }, - {38, 49, 4, 7, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 68} }, - {39, 48, 4, 6, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 67} }, - {40, 51, 5, 1, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 70} }, - {41, 50, 5, 0, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 69} }, - {42, 53, 5, 3, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 72} }, - {43, 52, 5, 2, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 71} }, - {44, 55, 5, 5, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 82} }, - {45, 54, 5, 4, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 81} }, - {46, 57, 5, 7, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 84} }, - {47, 56, 5, 6, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 83} }, - {48, 59, 6, 1, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 85, 86, 87, 88} }, - {49, 58, 6, 0, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 97, 98, 99,100} }, - {50, 61, 6, 3, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {105,106,107,108} }, - {51, 60, 6, 2, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {101,102,103,104} }, - {52, 63, 6, 5, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {117,118,119,120} }, - {53, 62, 6, 4, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {109,110,111,112} }, -}; -#endif - - -/* ========================================== - * Cypress Layout configuration (BaiDu version) - * ========================================== - */ -#ifdef SWPS_CYPRESS_BAI -unsigned cypress_b_gpio_rest_mux = MUX_RST_GPIO_FORCE_HEDERA; - -struct inv_ioexp_layout_s cypress_b_ioexp_layout[] = { - /* IOEXP_ID / IOEXP_TYPE / { Chan_ID, Chip_addr, Read_offset, Write_offset, config_offset, data_default, conf_default } */ - {0, IOEXP_TYPE_CYPRESS_NABC, { {2, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {2, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {2, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {1, IOEXP_TYPE_CYPRESS_NABC, { {3, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {3, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {3, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {2, IOEXP_TYPE_CYPRESS_NABC, { {4, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {4, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {4, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {3, IOEXP_TYPE_CYPRESS_NABC, { {5, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {5, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {5, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {4, IOEXP_TYPE_CYPRESS_NABC, { {6, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {6, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {6, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {5, IOEXP_TYPE_CYPRESS_NABC, { {7, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {7, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {7, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {6, IOEXP_TYPE_CYPRESS_7ABC, { {8, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xc0, 0xc0}, }, /* addr[0] = I/O Expander 7 A */ - {8, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xc0, 0xc0}, {0xff, 0xc0}, }, /* addr[1] = I/O Expander 7 B */ - {8, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 7 C */ - }, -}; - -struct inv_port_layout_s cypress_b_port_layout[] = { - /* Port_ID / Chan_ID / IOEXP_ID / IOEXP_VIRT_OFFSET / TRANSCEIVER_TYPE / BCM_CHIP_TYPE / LANE_ID */ - { 1, 11, 0, 1, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 2} }, - { 2, 10, 0, 0, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 1} }, - { 3, 13, 0, 3, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 4} }, - { 4, 12, 0, 2, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 3} }, - { 5, 15, 0, 5, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 6} }, - { 6, 14, 0, 4, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 5} }, - { 7, 17, 0, 7, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 8} }, - { 8, 16, 0, 6, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 7} }, - { 9, 19, 1, 1, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 10} }, - {10, 18, 1, 0, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 9} }, - {11, 21, 1, 3, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 12} }, - {12, 20, 1, 2, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 11} }, - {13, 23, 1, 5, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 22} }, - {14, 22, 1, 4, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 21} }, - {15, 25, 1, 7, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 24} }, - {16, 24, 1, 6, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 23} }, - {17, 27, 2, 1, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 34} }, - {18, 26, 2, 0, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 33} }, - {19, 29, 2, 3, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 36} }, - {20, 28, 2, 2, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 35} }, - {21, 31, 2, 5, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 38} }, - {22, 30, 2, 4, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 37} }, - {23, 33, 2, 7, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 40} }, - {24, 32, 2, 6, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 39} }, - {25, 35, 3, 1, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 42} }, - {26, 34, 3, 0, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 41} }, - {27, 37, 3, 3, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 44} }, - {28, 36, 3, 2, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 43} }, - {29, 39, 3, 5, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 50} }, - {30, 38, 3, 4, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 49} }, - {31, 41, 3, 7, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 52} }, - {32, 40, 3, 6, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 51} }, - {33, 43, 4, 1, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 54} }, - {34, 42, 4, 0, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 53} }, - {35, 45, 4, 3, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 56} }, - {36, 44, 4, 2, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 55} }, - {37, 47, 4, 5, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 66} }, - {38, 46, 4, 4, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 65} }, - {39, 49, 4, 7, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 68} }, - {40, 48, 4, 6, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 67} }, - {41, 51, 5, 1, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 70} }, - {42, 50, 5, 0, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 69} }, - {43, 53, 5, 3, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 72} }, - {44, 52, 5, 2, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 71} }, - {45, 55, 5, 5, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 82} }, - {46, 54, 5, 4, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 81} }, - {47, 57, 5, 7, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 84} }, - {48, 56, 5, 6, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 83} }, - {49, 59, 6, 1, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 85, 86, 87, 88} }, - {50, 58, 6, 0, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 97, 98, 99,100} }, - {51, 61, 6, 3, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {105,106,107,108} }, - {52, 60, 6, 2, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {101,102,103,104} }, - {53, 63, 6, 5, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {117,118,119,120} }, - {54, 62, 6, 4, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {109,110,111,112} }, -}; -#endif - - -/* ========================================== - * Redwood_fsl Layout configuration - * ========================================== - */ -#ifdef SWPS_REDWOOD_FSL -unsigned redwood_fsl_gpio_rest_mux = MUX_RST_GPIO_48_PAC9548; - -struct inv_ioexp_layout_s redwood_fsl_ioexp_layout[] = { - /* IOEXP_ID / IOEXP_TYPE / { Chan_ID, Chip_addr, Read_offset, Write_offset, config_offset, data_default, conf_default } */ - {0, IOEXP_TYPE_REDWOOD_P01P08, { {4, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[0] = I/O Expander 1-4 A */ - {4, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[1] = I/O Expander 1-4 B */ - {0, 0x25, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 5 B */ - }, - {1, IOEXP_TYPE_REDWOOD_P09P16, { {5, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[0] = I/O Expander 1-4 A */ - {5, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[1] = I/O Expander 1-4 B */ - {0, 0x25, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 5 B */ - }, - {2, IOEXP_TYPE_REDWOOD_P01P08, { {2, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[0] = I/O Expander 1-4 A */ - {2, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[1] = I/O Expander 1-4 B */ - {0, 0x24, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 5 B */ - }, - {3, IOEXP_TYPE_REDWOOD_P09P16, { {3, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[0] = I/O Expander 1-4 A */ - {3, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[1] = I/O Expander 1-4 B */ - {0, 0x24, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 5 B */ - }, -}; - - -struct inv_port_layout_s redwood_fsl_port_layout[] = { - /* Port_ID / Chan_ID / IOEXP_ID / IOEXP_VIRT_OFFSET / TRANSCEIVER_TYPE / BCM_CHIP_TYPE / LANE_ID */ - { 0, 22, 0, 0, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 1, 2, 3, 4} }, - { 1, 23, 0, 1, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 5, 6, 7, 8} }, - { 2, 24, 0, 2, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 9, 10, 11, 12} }, - { 3, 25, 0, 3, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 13, 14, 15, 16} }, - { 4, 26, 0, 4, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 17, 18, 19, 20} }, - { 5, 27, 0, 5, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 21, 22, 23, 24} }, - { 6, 28, 0, 6, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 25, 26, 27, 28} }, - { 7, 29, 0, 7, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 29, 30, 31, 32} }, - { 8, 30, 1, 0, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 33, 34, 35, 36} }, - { 9, 31, 1, 1, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 37, 38, 39, 40} }, - {10, 32, 1, 2, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 41, 42, 43, 44} }, - {11, 33, 1, 3, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 45, 46, 47, 48} }, - {12, 34, 1, 4, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 49, 50, 51, 52} }, - {13, 35, 1, 5, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 53, 54, 55, 56} }, - {14, 36, 1, 6, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 57, 58, 59, 60} }, - {15, 37, 1, 7, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 61, 62, 63, 64} }, - {16, 6, 2, 0, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 65, 66, 67, 68} }, - {17, 7, 2, 1, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 69, 70, 71, 72} }, - {18, 8, 2, 2, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 73, 74, 75, 76} }, - {19, 9, 2, 3, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 77, 78, 79, 80} }, - {20, 10, 2, 4, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 81, 82, 83, 84} }, - {21, 11, 2, 5, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 85, 86, 87, 88} }, - {22, 12, 2, 6, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 89, 90, 91, 92} }, - {23, 13, 2, 7, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 93, 94, 95, 96} }, - {24, 14, 3, 0, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 97, 98, 99,100} }, - {25, 15, 3, 1, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {101,102,103,104} }, - {26, 16, 3, 2, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {105,106,107,108} }, - {27, 17, 3, 3, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {109,110,111,112} }, - {28, 18, 3, 4, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {113,114,115,116} }, - {29, 19, 3, 5, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {117,118,119,120} }, - {30, 20, 3, 6, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {121,122,123,124} }, - {31, 21, 3, 7, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {125,126,127,128} }, -}; -#endif - - -/* ========================================== - * Tahoe Layout configuration - * ========================================== - */ -#ifdef SWPS_TAHOE -unsigned tahoe_gpio_rest_mux = MUX_RST_GPIO_249_PCA9548; - -struct inv_ioexp_layout_s tahoe_ioexp_layout[] = { - /* IOEXP_ID / IOEXP_TYPE / { Chan_ID, Chip_addr, Read_offset, Write_offset, config_offset, data_default, conf_default } */ - {0, IOEXP_TYPE_TAHOE_6ABC, { {7, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xce, 0xb9}, {0x18, 0xe3}, }, /* addr[0] = I/O Expander 6 A */ - {7, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xce, 0xb9}, {0x18, 0xe3}, }, /* addr[1] = I/O Expander 6 B */ - {7, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xce, 0xb9}, {0x18, 0xe3}, }, }, /* addr[2] = I/O Expander 6 C */ - }, - {1, IOEXP_TYPE_TAHOE_5A, { {6, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xce, 0xb9}, {0x18, 0xe3}, }, }, /* addr[0] = I/O Expander 5 A */ - }, -}; - - -struct inv_port_layout_s tahoe_port_layout[] = { - /* Port_ID / Chan_ID / IOEXP_ID / IOEXP_VIRT_OFFSET / TRANSCEIVER_TYPE / BCM_CHIP_TYPE / LANE_ID */ - { 0, 12, 1, 2, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 65, 66, 67, 68} }, - { 1, 11, 1, 1, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 53, 54, 55, 56} }, - { 2, 22, 0, 5, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 69, 70, 71, 72} }, - { 3, 21, 0, 4, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 81, 82, 83, 84} }, - { 4, 24, 0, 7, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 97, 98, 99, 100} }, - { 5, 23, 0, 6, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 85, 86, 87, 88} }, - { 6, 18, 0, 1, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {101, 102, 103, 104} }, - { 7, 17, 0, 0, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {105, 106, 107, 108} }, - { 8, 20, 0, 3, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {113, 114, 115, 116} }, - { 9, 19, 0, 2, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {109, 110, 111, 112} }, -}; -#endif - - -/* ========================================== - * Sequoia Layout configuration - * ========================================== - */ -#ifdef SWPS_SEQUOIA -unsigned sequoia_gpio_rest_mux = MUX_RST_GPIO_69_PAC9548; - -struct inv_ioexp_layout_s sequoia_ioexp_layout[] = { - /* IOEXP_ID / IOEXP_TYPE / { Chan_ID, Chip_addr, Read_offset, Write_offset, config_offset, data_default, conf_default } */ - {0, IOEXP_TYPE_SEQUOIA_NABC, { {1, 0x20, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0x00, 0x00}, }, /* addr[0] = I/O Expander 0 A */ - {1, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0xff}, }, /* addr[1] = I/O Expander 0 B */ - {1, 0x22, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 0 C */ - }, - {1, IOEXP_TYPE_SEQUOIA_NABC, { {2, 0x20, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0x00, 0x00}, }, /* addr[0] = I/O Expander 1 A */ - {2, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0xff}, }, /* addr[1] = I/O Expander 1 B */ - {2, 0x22, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 1 C */ - }, - {2, IOEXP_TYPE_SEQUOIA_NABC, { {3, 0x20, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0x00, 0x00}, }, /* addr[0] = I/O Expander 2 A */ - {3, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0xff}, }, /* addr[1] = I/O Expander 2 B */ - {3, 0x22, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 2 C */ - }, - {3, IOEXP_TYPE_SEQUOIA_NABC, { {4, 0x20, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0x00, 0x00}, }, /* addr[0] = I/O Expander 3 A */ - {4, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0xff}, }, /* addr[1] = I/O Expander 3 B */ - {4, 0x22, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 3 C */ - }, - {4, IOEXP_TYPE_SEQUOIA_NABC, { {5, 0x20, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0x00, 0x00}, }, /* addr[0] = I/O Expander 4 A */ - {5, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0xff}, }, /* addr[1] = I/O Expander 4 B */ - {5, 0x22, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 4 C */ - }, - {5, IOEXP_TYPE_SEQUOIA_NABC, { {6, 0x20, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0x00, 0x00}, }, /* addr[0] = I/O Expander 5 A */ - {6, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0xff}, }, /* addr[1] = I/O Expander 5 B */ - {6, 0x22, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 5 C */ - }, - {6, IOEXP_TYPE_SEQUOIA_NABC, { {7, 0x20, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0x00, 0x00}, }, /* addr[0] = I/O Expander 6 A */ - {7, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0xff}, }, /* addr[1] = I/O Expander 6 B */ - {7, 0x22, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 6 C */ - }, - {7, IOEXP_TYPE_SEQUOIA_NABC, { {8, 0x20, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0x00, 0x00}, }, /* addr[0] = I/O Expander 7 A */ - {8, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0xff}, }, /* addr[1] = I/O Expander 7 B */ - {8, 0x22, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 7 C */ - }, -}; - - -struct inv_port_layout_s sequoia_port_layout[] = { - /* Port_ID / Chan_ID / IOEXP_ID / IOEXP_VIRT_OFFSET / TRANSCEIVER_TYPE / BCM_CHIP_TYPE / LANE_ID */ - { 0, 9, 0, 0, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 9, 10, 11, 12} }, - { 1, 10, 0, 1, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 1, 2, 3, 4} }, - { 2, 11, 0, 2, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 25, 26, 27, 28} }, - { 3, 12, 0, 3, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 17, 18, 19, 20} }, - { 4, 13, 0, 4, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 41, 42, 43, 44} }, - { 5, 14, 0, 5, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 33, 34, 35, 36} }, - { 6, 15, 0, 6, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 57, 58, 59, 60} }, - { 7, 16, 0, 7, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 49, 50, 51, 52} }, - { 8, 17, 1, 0, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 73, 74, 75, 76} }, - { 9, 18, 1, 1, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 65, 66, 67, 68} }, - {10, 19, 1, 2, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 89, 90, 91, 92} }, - {11, 20, 1, 3, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 81, 82, 83, 84} }, - {12, 21, 1, 4, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {105, 106, 107, 108} }, - {13, 22, 1, 5, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 97, 98, 99, 100} }, - {14, 23, 1, 6, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {121, 122, 123, 124} }, - {15, 24, 1, 7, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {113, 114, 115, 116} }, - {16, 25, 2, 0, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {137, 138, 139, 140} }, - {17, 26, 2, 1, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {129, 130, 131, 132} }, - {18, 27, 2, 2, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {153, 154, 155, 156} }, - {19, 28, 2, 3, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {145, 146, 147, 148} }, - {20, 29, 2, 4, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {169, 170, 171, 172} }, - {21, 30, 2, 5, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {161, 162, 163, 164} }, - {22, 31, 2, 6, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {185, 186, 187, 188} }, - {23, 32, 2, 7, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {177, 178, 179, 180} }, - {24, 33, 3, 0, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {201, 202, 203, 204} }, - {25, 34, 3, 1, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {193, 194, 195, 196} }, - {26, 35, 3, 2, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {217, 218, 219, 220} }, - {27, 36, 3, 3, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {209, 210, 211, 212} }, - {28, 37, 3, 4, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {233, 234, 235, 236} }, - {29, 38, 3, 5, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {225, 226, 227, 228} }, - {30, 39, 3, 6, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {249, 250, 251, 252} }, - {31, 40, 3, 7, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {241, 242, 243, 244} }, - {32, 44, 4, 3, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 13, 14, 15, 16} }, - {33, 43, 4, 2, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 5, 6, 7, 8} }, - {34, 42, 4, 1, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 29, 30, 31, 32} }, - {35, 41, 4, 0, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 21, 22, 23, 24} }, - {36, 48, 4, 7, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 45, 46, 47, 48} }, - {37, 47, 4, 6, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 37, 38, 39, 40} }, - {38, 46, 4, 5, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 61, 62, 63, 64} }, - {39, 45, 4, 4, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 53, 54, 55, 56} }, - {40, 52, 5, 3, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 77, 78, 79, 80} }, - {41, 51, 5, 2, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 69, 70, 71, 72} }, - {42, 50, 5, 1, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 93, 94, 95, 96} }, - {43, 49, 5, 0, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 85, 86, 87, 88} }, - {44, 56, 5, 7, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {109, 110, 111, 112} }, - {45, 55, 5, 6, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {101, 102, 103, 104} }, - {46, 54, 5, 5, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {125, 126, 127, 128} }, - {47, 53, 5, 4, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {117, 118, 119, 120} }, - {48, 60, 6, 3, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {141, 142, 143, 144} }, - {49, 59, 6, 2, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {133, 134, 135, 136} }, - {50, 58, 6, 1, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {157, 158, 159, 160} }, - {51, 57, 6, 0, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {149, 150, 151, 152} }, - {52, 64, 6, 7, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {173, 174, 175, 176} }, - {53, 63, 6, 6, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {165, 166, 167, 168} }, - {54, 62, 6, 5, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {189, 190, 191, 192} }, - {55, 61, 6, 4, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {181, 182, 183, 184} }, - {56, 68, 7, 3, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {205, 206, 207, 208} }, - {57, 67, 7, 2, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {197, 198, 199, 200} }, - {58, 66, 7, 1, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {221, 222, 223, 224} }, - {59, 65, 7, 0, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {213, 214, 215, 216} }, - {60, 72, 7, 7, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {237, 238, 239, 240} }, - {61, 71, 7, 6, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {229, 230, 231, 232} }, - {62, 70, 7, 5, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {253, 254, 255, 256} }, - {63, 69, 7, 4, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {245, 246, 247, 248} }, -}; -#endif - - -/* ========================================== - * Lavender Layout configuration - * ========================================== - */ -#if (PLATFORM_SETTINGS == PLATFORM_TYPE_LAVENDER_GA) -unsigned lavender_gpio_rest_mux = MUX_RST_GPIO_505_PCA9548; -#elif (PLATFORM_SETTINGS == PLATFORM_TYPE_LAVENDER_ONL) -unsigned lavender_gpio_rest_mux = MUX_RST_GPIO_69_PAC9548; -#endif - -#ifdef SWPS_LAVENDER -struct inv_ioexp_layout_s lavender_ioexp_layout[] = { - /* IOEXP_ID / IOEXP_TYPE / { Chan_ID, Chip_addr, Read_offset, Write_offset, config_offset, data_default, conf_default } */ - {0, IOEXP_TYPE_SEQUOIA_NABC, { { 1, 0x20, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0x00, 0x00}, }, /* addr[0] = I/O Expander 0 A */ - { 1, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0xff}, }, /* addr[1] = I/O Expander 0 B */ - { 1, 0x22, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 0 C */ - }, - {1, IOEXP_TYPE_SEQUOIA_NABC, { { 2, 0x20, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0x00, 0x00}, }, /* addr[0] = I/O Expander 1 A */ - { 2, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0xff}, }, /* addr[1] = I/O Expander 1 B */ - { 2, 0x22, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 1 C */ - }, - {2, IOEXP_TYPE_SEQUOIA_NABC, { { 3, 0x20, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0x00, 0x00}, }, /* addr[0] = I/O Expander 2 A */ - { 3, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0xff}, }, /* addr[1] = I/O Expander 2 B */ - { 3, 0x22, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 2 C */ - }, - {3, IOEXP_TYPE_SEQUOIA_NABC, { { 4, 0x20, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0x00, 0x00}, }, /* addr[0] = I/O Expander 3 A */ - { 4, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0xff}, }, /* addr[1] = I/O Expander 3 B */ - { 4, 0x22, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 3 C */ - }, - {4, IOEXP_TYPE_SEQUOIA_NABC, { { 9, 0x20, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0x00, 0x00}, }, /* addr[0] = I/O Expander 4 A */ - { 9, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0xff}, }, /* addr[1] = I/O Expander 4 B */ - { 9, 0x22, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 4 C */ - }, - {5, IOEXP_TYPE_SEQUOIA_NABC, { {10, 0x20, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0x00, 0x00}, }, /* addr[0] = I/O Expander 5 A */ - {10, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0xff}, }, /* addr[1] = I/O Expander 5 B */ - {10, 0x22, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 5 C */ - }, - {6, IOEXP_TYPE_SEQUOIA_NABC, { {11, 0x20, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0x00, 0x00}, }, /* addr[0] = I/O Expander 6 A */ - {11, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0xff}, }, /* addr[1] = I/O Expander 6 B */ - {11, 0x22, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 6 C */ - }, - {7, IOEXP_TYPE_SEQUOIA_NABC, { {12, 0x20, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0x00, 0x00}, }, /* addr[0] = I/O Expander 7 A */ - {12, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0xff}, }, /* addr[1] = I/O Expander 7 B */ - {12, 0x22, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 7 C */ - }, - {8, IOEXP_TYPE_LAVENDER_P65, { { 5, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xF6, 0xff}, {0xF8, 0xff}, }, }, /* addr[0] = I/O Expander CPU */ - }, -}; - - -struct inv_port_layout_s lavender_port_layout[] = { - /* Port_ID / Chan_ID / IOEXP_ID / IOEXP_VIRT_OFFSET / TRANSCEIVER_TYPE / BCM_CHIP_TYPE / LANE_ID */ - { 0, 17, 0, 0, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, {188, 189, 190, 191} }, - { 1, 18, 0, 1, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, {184, 185, 186, 187} }, - { 2, 19, 0, 2, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, {180, 181, 182, 183} }, - { 3, 20, 0, 3, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, {176, 177, 178, 179} }, - { 4, 21, 0, 4, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, {172, 173, 174, 175} }, - { 5, 22, 0, 5, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, {168, 169, 170, 171} }, - { 6, 23, 0, 6, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, {164, 165, 166, 167} }, - { 7, 24, 0, 7, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, {160, 161, 162, 163} }, - { 8, 25, 1, 0, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, {156, 157, 158, 159} }, - { 9, 26, 1, 1, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, {152, 153, 154, 155} }, - {10, 27, 1, 2, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, {148, 149, 150, 151} }, - {11, 28, 1, 3, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, {144, 145, 146, 147} }, - {12, 29, 1, 4, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, {140, 141, 142, 143} }, - {13, 30, 1, 5, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, {136, 137, 138, 139} }, - {14, 31, 1, 6, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, {132, 133, 134, 135} }, - {15, 32, 1, 7, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, {128, 129, 130, 131} }, - {16, 33, 2, 0, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, { 0, 1, 2, 3} }, - {17, 34, 2, 1, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, { 4, 5, 6, 7} }, - {18, 35, 2, 2, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, { 8, 9, 10, 11} }, - {19, 36, 2, 3, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, { 12, 13, 14, 15} }, - {20, 37, 2, 4, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, { 16, 17, 18, 19} }, - {21, 38, 2, 5, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, { 20, 21, 22, 23} }, - {22, 39, 2, 6, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, { 24, 25, 26, 27} }, - {23, 40, 2, 7, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, { 28, 29, 30, 31} }, - {24, 41, 3, 0, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, { 32, 33, 34, 35} }, - {25, 42, 3, 1, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, { 36, 37, 38, 39} }, - {26, 43, 3, 2, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, { 40, 41, 42, 43} }, - {27, 44, 3, 3, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, { 44, 45, 46, 47} }, - {28, 45, 3, 4, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, { 48, 49, 50, 51} }, - {29, 46, 3, 5, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, { 52, 53, 54, 55} }, - {30, 47, 3, 6, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, { 56, 57, 58, 59} }, - {31, 48, 3, 7, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, { 60, 61, 62, 63} }, - {32, 49, 4, 0, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, {256, 257, 258, 259} }, - {33, 50, 4, 1, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, {260, 261, 262, 263} }, - {34, 51, 4, 2, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, {264, 265, 266, 267} }, - {35, 52, 4, 3, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, {268, 269, 270, 271} }, - {36, 53, 4, 4, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, {272, 273, 274, 275} }, - {37, 54, 4, 5, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, {276, 277, 278, 279} }, - {38, 55, 4, 6, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, {280, 281, 282, 283} }, - {39, 56, 4, 7, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, {284, 285, 286, 287} }, - {40, 57, 5, 0, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, {288, 289, 290, 291} }, - {41, 58, 5, 1, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, {292, 293, 294, 295} }, - {42, 59, 5, 2, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, {296, 297, 298, 299} }, - {43, 60, 5, 3, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, {300, 301, 302, 303} }, - {44, 61, 5, 4, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, {304, 305, 306, 307} }, - {45, 62, 5, 5, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, {308, 309, 310, 311} }, - {46, 63, 5, 6, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, {312, 313, 314, 315} }, - {47, 64, 5, 7, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, {316, 317, 318, 319} }, - {48, 65, 6, 0, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, {444, 445, 446, 447} }, - {49, 66, 6, 1, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, {440, 441, 442, 443} }, - {50, 67, 6, 2, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, {436, 437, 438, 439} }, - {51, 68, 6, 3, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, {432, 433, 434, 435} }, - {52, 69, 6, 4, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, {428, 429, 430, 431} }, - {53, 70, 6, 5, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, {424, 425, 426, 427} }, - {54, 71, 6, 6, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, {420, 421, 422, 423} }, - {55, 72, 6, 7, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, {416, 417, 418, 419} }, - {56, 73, 7, 0, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, {412, 413, 414, 415} }, - {57, 74, 7, 1, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, {408, 409, 410, 411} }, - {58, 75, 7, 2, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, {404, 405, 406, 407} }, - {59, 76, 7, 3, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, {400, 401, 402, 403} }, - {60, 77, 7, 4, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, {396, 397, 398, 399} }, - {61, 78, 7, 5, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, {392, 393, 394, 395} }, - {62, 79, 7, 6, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, {388, 389, 390, 391} }, - {63, 80, 7, 7, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, {384, 385, 386, 387} }, - {64, 5, 8, 0, TRANSVR_TYPE_QSFP_28, BF_CHIP_TYPE_TOFINO, { 64, 65, 66, 67} }, -}; -#endif - -/* =========================================================== - * Cottonwood Layout configuration Rangeley (Rangeley CPU board) - * =========================================================== - */ -#ifdef SWPS_COTTONWOOD_RANGELEY -unsigned cottonwood_rangeley_gpio_rest_mux = MUX_RST_GPIO_500_PAC9548; - -struct inv_ioexp_layout_s cottonwood_rangeley_ioexp_layout[] = { - /* IOEXP_ID / IOEXP_TYPE / { Chan_ID, Chip_addr, Read_offset, Write_offset, config_offset, data_default, conf_default } */ - {0, CPLD_TYPE_COTTONWOOD,{ {1, 0x55, {22, 23, 24, 25}, {22, 23, 24, 25}, {-1, -1, -1, -1}, {0xee, 0xee, 0x99, 0x99}, {0x00, 0x00, 0x00, 0x00}, }, - }, - }, -}; - - -struct inv_port_layout_s cottonwood_rangeley_port_layout[] = { - /* Port_ID / Chan_ID / IOEXP_ID / IOEXP_VIRT_OFFSET / TRANSCEIVER_TYPE / BCM_CHI_TYPE / LANE_ID */ - { 0, 2, 0, 0, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 75} }, - { 1, 3, 0, 1, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 77} }, - { 2, 4, 0, 2, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 79} }, - { 3, 5, 0, 3, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 81} }, -}; -#endif - -/* =========================================================== - * Maple Layout configuration - * =========================================================== - */ -#ifdef SWPS_MAPLE -unsigned maple_gpio_rest_mux = MUX_RST_GPIO_69_PAC9548; - -struct inv_ioexp_layout_s maple_ioexp_layout[] = { - /* IOEXP_ID / IOEXP_TYPE / { Chan_ID, Chip_addr, Read_offset, Write_offset, config_offset, data_default, conf_default } */ - {0, IOEXP_TYPE_MAPLE_0ABC, { {2, 0x20, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0x00, 0x00}, }, /* addr[0] = I/O Expander 0 A */ - {2, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0xff}, }, /* addr[1] = I/O Expander 0 B */ - {2, 0x22, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 0 C */ - }, - {1, IOEXP_TYPE_MAPLE_NABC, { {3, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {3, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {3, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {2, IOEXP_TYPE_MAPLE_NABC, { {4, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {4, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {4, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {3, IOEXP_TYPE_MAPLE_NABC, { {5, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {5, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {5, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {4, IOEXP_TYPE_MAPLE_NABC, { {6, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {6, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {6, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {5, IOEXP_TYPE_MAPLE_NABC, { {7, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {7, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {7, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {6, IOEXP_TYPE_MAPLE_NABC, { {8, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {8, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {8, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, -}; - -struct inv_port_layout_s maple_port_layout[] = { - /* Port_ID / Chan_ID / IOEXP_ID / IOEXP_VIRT_OFFSET / TRANSCEIVER_TYPE / BCM_CHIP_TYPE / LANE_ID */ - { 0, 18, 1, 0, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_3, { 1} }, - { 1, 19, 1, 1, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_3, { 2} }, - { 2, 20, 1, 2, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_3, { 3} }, - { 3, 21, 1, 3, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_3, { 4} }, - { 4, 22, 1, 4, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_3, { 5} }, - { 5, 23, 1, 5, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_3, { 6} }, - { 6, 24, 1, 6, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_3, { 7} }, - { 7, 25, 1, 7, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_3, { 8} }, - { 8, 26, 2, 0, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_3, { 13} }, - { 9, 27, 2, 1, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_3, { 14} }, - {10, 28, 2, 2, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_3, { 15} }, - {11, 29, 2, 3, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_3, { 16} }, - {12, 30, 2, 4, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_3, { 21} }, - {13, 31, 2, 5, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_3, { 22} }, - {14, 32, 2, 6, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_3, { 23} }, - {15, 33, 2, 7, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_3, { 24} }, - {16, 34, 3, 0, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_3, { 29} }, - {17, 35, 3, 1, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_3, { 30} }, - {18, 36, 3, 2, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_3, { 31} }, - {19, 37, 3, 3, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_3, { 32} }, - {20, 38, 3, 4, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_3, { 33} }, - {21, 39, 3, 5, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_3, { 34} }, - {22, 40, 3, 6, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_3, { 35} }, - {23, 41, 3, 7, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_3, { 36} }, - {24, 42, 4, 0, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_3, { 41} }, - {25, 43, 4, 1, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_3, { 42} }, - {26, 44, 4, 2, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_3, { 43} }, - {27, 45, 4, 3, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_3, { 44} }, - {28, 46, 4, 4, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_3, { 49} }, - {29, 47, 4, 5, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_3, { 50} }, - {30, 48, 4, 6, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_3, { 51} }, - {31, 49, 4, 7, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_3, { 52} }, - {32, 50, 5, 0, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_3, { 57} }, - {33, 51, 5, 1, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_3, { 58} }, - {34, 52, 5, 2, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_3, { 59} }, - {35, 53, 5, 3, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_3, { 60} }, - {36, 54, 5, 4, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_3, { 61} }, - {37, 55, 5, 5, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_3, { 62} }, - {38, 56, 5, 6, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_3, { 63} }, - {39, 57, 5, 7, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_3, { 64} }, - {40, 58, 6, 0, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_3, { 65} }, - {41, 59, 6, 1, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_3, { 66} }, - {42, 60, 6, 2, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_3, { 67} }, - {43, 61, 6, 3, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_3, { 68} }, - {44, 62, 6, 4, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_3, { 69} }, - {45, 63, 6, 5, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_3, { 70} }, - {46, 64, 6, 6, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_3, { 71} }, - {47, 65, 6, 7, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_3, { 72} }, - {48, 10, 0, 0, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TRIDENT_3, { 77, 78, 79, 80} }, - {49, 11, 0, 1, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TRIDENT_3, { 85, 86, 87, 88} }, - {50, 12, 0, 2, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TRIDENT_3, { 93, 94, 95, 96} }, - {51, 13, 0, 3, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TRIDENT_3, { 97, 98, 99,100} }, - {52, 14, 0, 4, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TRIDENT_3, {105,106,107,108} }, - {53, 15, 0, 5, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TRIDENT_3, {113,114,115,116} }, - {54, 16, 0, 6, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TRIDENT_3, {121,122,123,124} }, - {55, 17, 0, 7, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TRIDENT_3, {125,126,127,128} }, -}; -#endif - -#endif /* INV_SWPS_H */ diff --git a/packages/platforms/inventec/x86-64/d6556/modules/builds/src/inv_vpd.c b/packages/platforms/inventec/x86-64/d6556/modules/builds/src/inv_vpd.c deleted file mode 100644 index 2075fd4ee..000000000 --- a/packages/platforms/inventec/x86-64/d6556/modules/builds/src/inv_vpd.c +++ /dev/null @@ -1,332 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "inv_vpd.h" -#include "onie_tlvinfo.h" - -static int vpd_major; -static struct class *vpd_class_p = NULL; -static char cEeprom[SYS_EEPROM_MAX_SIZE]; -static DEFINE_MUTEX(vpd_mutex); - -static int -__swp_match(struct device *dev, const void *data){ - - char *name = (char *)data; - if (strcmp(dev_name(dev), name) == 0) - return 1; - return 0; -} - -static -int get_vpd_data(struct i2c_client *pi2c_client, int i_offset, char *c_buf) -{ - int iRet; - - read_eeprom( pi2c_client, cEeprom); - iRet = tlvinfo_decode_tlv(cEeprom, i_offset,c_buf); - return iRet; -} - -static -int write_vpd_data(struct i2c_client *pi2c_client, int i_offset, const char *c_buf) -{ - int iErr = 0; - - if (read_eeprom(pi2c_client, cEeprom)) { - printk(KERN_ERR "write vpd data eror at %d-%s\n", __LINE__, __FUNCTION__); - return -1; - } - - if (tlvinfo_delete_tlv(cEeprom, i_offset) == TRUE) { - } - if (c_buf) { - if(!tlvinfo_add_tlv(cEeprom, i_offset , c_buf)) { - printk(KERN_ERR "write vpd data eror at %d-%s\n", __LINE__, __FUNCTION__); - iErr = -1; - } else { - iErr = prog_eeprom(pi2c_client,cEeprom); - } - } - return iErr; -} - -static struct device * -get_swpdev_by_name(char *name){ - struct device *dev = class_find_device(vpd_class_p, - NULL, - name, - __swp_match); - return dev; -} - -static ssize_t -store_attr_vpd(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - struct i2c_client *pi2c_client = dev_get_drvdata(dev_p); - struct vpd_device_attribute *attr = to_vpd_dev_attr(attr_p); - int iOffset = attr->index; - int iErr , iLen; - char *pChar; - - if (!pi2c_client){ - return -ENODEV; - } - mutex_lock(&vpd_mutex); - - //-strip 0x0a in the last byte. - for (iLen = 0, pChar = (char*)buf_p; - iLen < 255 && *pChar != 0; - iLen++, pChar++) ; - if (iLen !=0 && *pChar == 0 && *(pChar-1) == 0x0a) - *(pChar - 1) = 0; - //- - - iErr = write_vpd_data( pi2c_client, iOffset, buf_p); - - mutex_unlock(&vpd_mutex); - return count; -} - -static ssize_t -show_attr_vpd(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct i2c_client *pi2c_client = dev_get_drvdata(dev_p); - struct vpd_device_attribute *attr = to_vpd_dev_attr(attr_p); - int iOffset = attr->index; - int iErr , iLen; - - if (!pi2c_client){ - return -ENODEV; - } - mutex_lock(&vpd_mutex); - iErr = get_vpd_data( pi2c_client, iOffset, buf_p); - mutex_unlock(&vpd_mutex); - - if( iErr <= 0 ) - iLen = 0; - else - iLen = snprintf(buf_p, TLV_DECODE_VALUE_MAX_LEN, "%s\n", buf_p); - - return iLen; -} - -/* ================= Vpd attribute ======================== - */ -static VPD_DEVICE_ATTR(product_name ,S_IWUSR|S_IRUGO, show_attr_vpd, store_attr_vpd, TLV_CODE_PRODUCT_NAME ); -static VPD_DEVICE_ATTR(pn ,S_IWUSR|S_IRUGO, show_attr_vpd, store_attr_vpd, TLV_CODE_PART_NUMBER ); -static VPD_DEVICE_ATTR(sn ,S_IWUSR|S_IRUGO, show_attr_vpd, store_attr_vpd, TLV_CODE_SERIAL_NUMBER ); -static VPD_DEVICE_ATTR(base_mac_addr,S_IWUSR|S_IRUGO, show_attr_vpd, store_attr_vpd, TLV_CODE_MAC_BASE ); -static VPD_DEVICE_ATTR(man_date ,S_IWUSR|S_IRUGO, show_attr_vpd, store_attr_vpd, TLV_CODE_MANUF_DATE ); -static VPD_DEVICE_ATTR(dev_ver ,S_IWUSR|S_IRUGO, show_attr_vpd, store_attr_vpd, TLV_CODE_DEVICE_VERSION ); -static VPD_DEVICE_ATTR(label_rev ,S_IWUSR|S_IRUGO, show_attr_vpd, store_attr_vpd, TLV_CODE_LABEL_REVISION ); -static VPD_DEVICE_ATTR(plat_name ,S_IWUSR|S_IRUGO, show_attr_vpd, store_attr_vpd, TLV_CODE_PLATFORM_NAME ); -static VPD_DEVICE_ATTR(ldr_ver ,S_IWUSR|S_IRUGO, show_attr_vpd, store_attr_vpd, TLV_CODE_ONIE_VERSION ); -static VPD_DEVICE_ATTR(mac_addr ,S_IWUSR|S_IRUGO, show_attr_vpd, store_attr_vpd, TLV_CODE_MAC_SIZE ); -static VPD_DEVICE_ATTR(manufacturer ,S_IWUSR|S_IRUGO, show_attr_vpd, store_attr_vpd, TLV_CODE_MANUF_NAME ); -static VPD_DEVICE_ATTR(country_code ,S_IWUSR|S_IRUGO, show_attr_vpd, store_attr_vpd, TLV_CODE_MANUF_COUNTRY ); -static VPD_DEVICE_ATTR(vendor_name ,S_IWUSR|S_IRUGO, show_attr_vpd, store_attr_vpd, TLV_CODE_VENDOR_NAME ); -static VPD_DEVICE_ATTR(diag_ver ,S_IWUSR|S_IRUGO, show_attr_vpd, store_attr_vpd, TLV_CODE_DIAG_VERSION ); -static VPD_DEVICE_ATTR(service_tag ,S_IWUSR|S_IRUGO, show_attr_vpd, store_attr_vpd, TLV_CODE_SERVICE_TAG ); -static VPD_DEVICE_ATTR(vendor_ext ,S_IWUSR|S_IRUGO, show_attr_vpd, store_attr_vpd, TLV_CODE_VENDOR_EXT ); -static VPD_DEVICE_ATTR(crc32 ,S_IRUGO, show_attr_vpd, NULL, TLV_CODE_CRC_32 ); - -static void -clean_vpd_common(void) -{ - dev_t dev_num; - struct device *device_p; - - device_p = get_swpdev_by_name(VPD_DEVICE); - if (device_p){ - dev_num = MKDEV(vpd_major, 1); - device_unregister(device_p); - device_destroy(vpd_class_p, dev_num); - } - VPD_DEBUG("%s: done.\n", __func__); -} - - -static struct register_attr VpdRegAttr[VPD_ENTRY_SIZE ] ={ - { &vpd_dev_attr_product_name.dev_attr, "vpd_dev_attr_product_name"}, - { &vpd_dev_attr_pn.dev_attr, "vpd_dev_attr_pn"}, - { &vpd_dev_attr_sn.dev_attr, "vpd_dev_attr_sn"}, - { &vpd_dev_attr_base_mac_addr.dev_attr, "vpd_dev_attr_base_mac_addr"}, - { &vpd_dev_attr_man_date.dev_attr, "vpd_dev_attr_man_date"}, - { &vpd_dev_attr_dev_ver.dev_attr, "vpd_dev_attr_dev_ver"}, - { &vpd_dev_attr_label_rev.dev_attr, "vpd_dev_attr_label_rev"}, - { &vpd_dev_attr_plat_name.dev_attr, "vpd_dev_attr_plat_name"}, - { &vpd_dev_attr_ldr_ver.dev_attr, "vpd_dev_attr_ldr_ver"}, - { &vpd_dev_attr_mac_addr.dev_attr, "vpd_dev_attr_mac_addr"}, - { &vpd_dev_attr_manufacturer.dev_attr, "vpd_dev_attr_manufacturer"}, - { &vpd_dev_attr_country_code.dev_attr, "vpd_dev_attr_country_code"}, - { &vpd_dev_attr_vendor_name.dev_attr, "vpd_dev_attr_vendor_name"}, - { &vpd_dev_attr_diag_ver.dev_attr, "vpd_dev_attr_diag_ver"}, - { &vpd_dev_attr_service_tag.dev_attr, "vpd_dev_attr_service_tag"}, - { &vpd_dev_attr_vendor_ext.dev_attr, "vpd_dev_attr_vendor_ext"}, - { &vpd_dev_attr_crc32.dev_attr, "vpd_dev_attr_crc32"}, -}; - -static int -register_vpd_attr(struct device *device_p){ - - char *err_attr = NULL; - int i; - - for( i = 0 ; i adapter = adap; - vpd_i2c_client->addr = VPD_I2C_ADDR; - - device_p = device_create(vpd_class_p, /* struct class *cls */ - NULL, /* struct device *parent */ - dev_num, /* dev_t devt */ - vpd_i2c_client, /* void *private_data */ - VPD_DEVICE); /* const char *fmt */ - if (IS_ERR(device_p)){ - err_msg = "device_create fail"; - goto err_register_vpd_device_1; - } - if (register_vpd_attr(device_p) < 0) { - err_msg = "register_vpd_attr fail"; - goto err_register_vpd_device_2; - } - return 0; - -err_register_vpd_device_2: - device_unregister(device_p); - device_destroy(vpd_class_p, dev_num); -err_register_vpd_device_1: - kfree(vpd_i2c_client); - vpd_i2c_client = NULL; -err_register_vpd_device: - VPD_ERR("%s: %s\n", __func__, err_msg); - return -1; -} - -static int -register_vpd_module(void) -{ - dev_t vpd_devt = 0; - - if (alloc_chrdev_region(&vpd_devt, 0, 1, VPD_DEVICE) < 0){ - VPD_WARN("Allocate VPD MAJOR failure! \n"); - goto err_register_vpd_module; - } - vpd_major = MAJOR(vpd_devt); - - /* Create class object */ - vpd_class_p = class_create(THIS_MODULE, EEPROM_CLASS); - if (IS_ERR(vpd_class_p)) { - VPD_ERR("Create class failure! \n"); - goto err_register_vpd_module_1; - } - return 0; - -err_register_vpd_module_1: - unregister_chrdev_region(MKDEV(vpd_major, 0), 1); -err_register_vpd_module: - return -1; -} - - -static int -init_vpd_common(void) -{ - char *err_msg = "ERR"; - - if (register_vpd_device() < 0) { - err_msg = "register_vpd_device fail"; - goto err_init_vpd_common; - } - return 0; - -err_init_vpd_common: - VPD_ERR("%s: %s\n", __func__, err_msg); - return -1; -} - - -static int __init -vpd_module_init(void) -{ - if (register_vpd_module() < 0){ - goto err_vpd_module_init; - } - if (init_vpd_common() < 0){ - goto err_vpd_module_init_1; - } - VPD_INFO("Inventec vpd module V.%s initial success.\n", VPD_VERSION); - return 0; - -err_vpd_module_init_1: - class_unregister(vpd_class_p); - class_destroy(vpd_class_p); - unregister_chrdev_region(MKDEV(vpd_major, 0), 1); -err_vpd_module_init: - VPD_ERR("Inventec vpd module V.%s initial failure.\n", VPD_VERSION); - return -1; -} - - -static void __exit -vpd_module_exit(void) -{ - clean_vpd_common(); - class_unregister(vpd_class_p); - class_destroy(vpd_class_p); - unregister_chrdev_region(MKDEV(vpd_major, 0), 1); - VPD_INFO("Remove Inventec vpd module success.\n"); -} - - -/* Module information */ -MODULE_AUTHOR(VPD_AUTHOR); -MODULE_DESCRIPTION(VPD_DESC); -MODULE_VERSION(VPD_VERSION); -MODULE_LICENSE(VPD_LICENSE); - -module_init(vpd_module_init); -module_exit(vpd_module_exit); diff --git a/packages/platforms/inventec/x86-64/d6556/modules/builds/src/inv_vpd.h b/packages/platforms/inventec/x86-64/d6556/modules/builds/src/inv_vpd.h deleted file mode 100644 index 58c7fe33f..000000000 --- a/packages/platforms/inventec/x86-64/d6556/modules/builds/src/inv_vpd.h +++ /dev/null @@ -1,46 +0,0 @@ -#ifndef INV_VPD_H -#define INV_VPD_H - -#define EEPROM_CLASS "eeprom" -#define VPD_DEVICE "vpd" -#define VPD_AUTHOR "Neil " -#define VPD_DESC "Inventec eeprom vpd driver" -#define VPD_VERSION "1.0.0" -#define VPD_LICENSE "GPL" - -#define VPD_ENTRY_SIZE (17) -#define VPD_I2C_BUS (0) -#define VPD_I2C_ADDR (0x53) - -struct register_attr { -struct device_attribute *attr; -char * errmsg; -}; - -struct vpd_device_attribute{ - struct device_attribute dev_attr; - int index; -}; - -#define to_vpd_dev_attr(_dev_attr) \ - container_of(_dev_attr, struct vpd_device_attribute, dev_attr) - -#define VPD_ATTR(_name, _mode, _show, _store, _index) \ - { .dev_attr = __ATTR(_name, _mode, _show, _store), \ - .index = _index } - -#define VPD_DEVICE_ATTR(_name, _mode, _show, _store, _index) \ - struct vpd_device_attribute vpd_dev_attr_##_name \ - = VPD_ATTR(_name, _mode, _show, _store, _index) - -#define VPD_INFO(fmt, args...) printk( KERN_INFO "[VPD] " fmt, ##args) -#define VPD_WARN(fmt, args...) printk( KERN_WARNING "[VPD] " fmt, ##args) -#define VPD_ERR(fmt, args...) printk( KERN_ERR "[VPD] " fmt, ##args) - -#ifdef DEBUG_VPD -# define VPD_DEBUG(fmt, args...) printk( KERN_DEBUG "[VPD] " fmt, ##args) -#else -# define VPD_DEBUG(fmt, args...) -#endif - -#endif /* INV_VPD_H */ diff --git a/packages/platforms/inventec/x86-64/d6556/modules/builds/src/io_expander.c b/packages/platforms/inventec/x86-64/d6556/modules/builds/src/io_expander.c deleted file mode 100644 index 4564b5855..000000000 --- a/packages/platforms/inventec/x86-64/d6556/modules/builds/src/io_expander.c +++ /dev/null @@ -1,2046 +0,0 @@ -#include -#include -#include "io_expander.h" - -static struct ioexp_obj_s *ioexp_head_p = NULL; -static struct ioexp_obj_s *ioexp_tail_p = NULL; - - -/* ========== Register IOEXP layout ========== - */ -struct ioexp_map_s ioexp_map_magnolia_nab = { - - .chip_amount = 2, - .data_width = 2, - - .map_present = { {0, 0, 4}, /* map_present[0] = MOD_ABS_PORT(X) */ - {0, 0, 5}, /* map_present[1] = MOD_ABS_PORT(X+1) */ - {0, 0, 6}, /* map_present[2] = MOD_ABS_PORT(X+2) */ - {0, 0, 7}, /* map_present[3] = MOD_ABS_PORT(X+3) */ - {1, 0, 4}, /* map_present[4] = MOD_ABS_PORT(X+4) */ - {1, 0, 5}, /* map_present[5] = MOD_ABS_PORT(X+5) */ - {1, 0, 6}, /* map_present[6] = MOD_ABS_PORT(X+6) */ - {1, 0, 7}, /* map_present[7] = MOD_ABS_PORT(X+7) */ - }, - .map_tx_disable = { {0, 1, 0}, /* map_tx_disable[0] = TXDISABLE_SFP+_P(X) */ - {0, 1, 1}, /* map_tx_disable[1] = TXDISABLE_SFP+_P(X+1) */ - {0, 1, 2}, /* map_tx_disable[2] = TXDISABLE_SFP+_P(X+2) */ - {0, 1, 3}, /* map_tx_disable[3] = TXDISABLE_SFP+_P(X+3) */ - {1, 1, 0}, /* map_tx_disable[4] = TXDISABLE_SFP+_P(X+4) */ - {1, 1, 1}, /* map_tx_disable[5] = TXDISABLE_SFP+_P(X+5) */ - {1, 1, 2}, /* map_tx_disable[6] = TXDISABLE_SFP+_P(X+6) */ - {1, 1, 3}, /* map_tx_disable[7] = TXDISABLE_SFP+_P(X+7) */ - }, - .map_tx_fault = { {0, 0, 0}, /* map_tx_fault[0] = TXFAULT_SFP+_P(X) */ - {0, 0, 1}, /* map_tx_fault[1] = TXFAULT_SFP+_P(X+1) */ - {0, 0, 2}, /* map_tx_fault[2] = TXFAULT_SFP+_P(X+2) */ - {0, 0, 3}, /* map_tx_fault[3] = TXFAULT_SFP+_P(X+3) */ - {1, 0, 0}, /* map_tx_fault[4] = TXFAULT_SFP+_P(X+4) */ - {1, 0, 1}, /* map_tx_fault[5] = TXFAULT_SFP+_P(X+5) */ - {1, 0, 2}, /* map_tx_fault[6] = TXFAULT_SFP+_P(X+6) */ - {1, 0, 3}, /* map_tx_fault[7] = TXFAULT_SFP+_P(X+7) */ - }, - .map_rxlos = { {0, 1, 4}, /* map_rxlos[0] = OPRXLOS_PORT(X) */ - {0, 1, 5}, /* map_rxlos[1] = OPRXLOS_PORT(X+1) */ - {0, 1, 6}, /* map_rxlos[2] = OPRXLOS_PORT(X+2) */ - {0, 1, 7}, /* map_rxlos[3] = OPRXLOS_PORT(X+3) */ - {1, 1, 4}, /* map_rxlos[4] = OPRXLOS_PORT(X+4) */ - {1, 1, 5}, /* map_rxlos[5] = OPRXLOS_PORT(X+5) */ - {1, 1, 6}, /* map_rxlos[6] = OPRXLOS_PORT(X+6) */ - {1, 1, 7}, /* map_rxlos[7] = OPRXLOS_PORT(X+7) */ - }, -}; - - -struct ioexp_map_s ioexp_map_magnolia_4ab = { - - .chip_amount = 2, - .data_width = 2, - - .map_present = { {0, 0, 4}, /* map_present[0] = MOD_ABS_PORT(X) */ - {0, 0, 5}, /* map_present[1] = MOD_ABS_PORT(X+1) */ - {0, 0, 6}, /* map_present[2] = MOD_ABS_PORT(X+2) */ - {0, 0, 7}, /* map_present[3] = MOD_ABS_PORT(X+3) */ - {1, 0, 4}, /* map_present[4] = MOD_ABS_PORT(X+4) */ - {1, 0, 5}, /* map_present[5] = MOD_ABS_PORT(X+5) */ - {1, 0, 6}, /* map_present[6] = MOD_ABS_PORT(X+6) */ - {1, 0, 7}, /* map_present[7] = MOD_ABS_PORT(X+7) */ - }, - .map_tx_disable = { {0, 1, 0}, /* map_tx_disable[0] = TXDISABLE_SFP+_P(X) */ - {0, 1, 1}, /* map_tx_disable[1] = TXDISABLE_SFP+_P(X+1) */ - {0, 1, 2}, /* map_tx_disable[2] = TXDISABLE_SFP+_P(X+2) */ - {0, 1, 3}, /* map_tx_disable[3] = TXDISABLE_SFP+_P(X+3) */ - {1, 0, 0}, /* map_tx_disable[4] = TXDISABLE_SFP+_P(X+4) */ - {1, 0, 1}, /* map_tx_disable[5] = TXDISABLE_SFP+_P(X+5) */ - {1, 0, 2}, /* map_tx_disable[6] = TXDISABLE_SFP+_P(X+6) */ - {1, 0, 3}, /* map_tx_disable[7] = TXDISABLE_SFP+_P(X+7) */ - }, - .map_tx_fault = { {0, 0, 0}, /* map_tx_fault[0] = TXFAULT_SFP+_P(X) */ - {0, 0, 1}, /* map_tx_fault[1] = TXFAULT_SFP+_P(X+1) */ - {0, 0, 2}, /* map_tx_fault[2] = TXFAULT_SFP+_P(X+2) */ - {0, 0, 3}, /* map_tx_fault[3] = TXFAULT_SFP+_P(X+3) */ - {1, 1, 0}, /* map_tx_fault[4] = TXFAULT_SFP+_P(X+4) */ - {1, 1, 1}, /* map_tx_fault[5] = TXFAULT_SFP+_P(X+5) */ - {1, 1, 2}, /* map_tx_fault[6] = TXFAULT_SFP+_P(X+6) */ - {1, 1, 3}, /* map_tx_fault[7] = TXFAULT_SFP+_P(X+7) */ - }, - .map_rxlos = { {0, 1, 4}, /* map_rxlos[0] = OPRXLOS_PORT(X) */ - {0, 1, 5}, /* map_rxlos[1] = OPRXLOS_PORT(X+1) */ - {0, 1, 6}, /* map_rxlos[2] = OPRXLOS_PORT(X+2) */ - {0, 1, 7}, /* map_rxlos[3] = OPRXLOS_PORT(X+3) */ - {1, 1, 4}, /* map_rxlos[4] = OPRXLOS_PORT(X+4) */ - {1, 1, 5}, /* map_rxlos[5] = OPRXLOS_PORT(X+5) */ - {1, 1, 6}, /* map_rxlos[6] = OPRXLOS_PORT(X+6) */ - {1, 1, 7}, /* map_rxlos[7] = OPRXLOS_PORT(X+7) */ - }, -}; - - -struct ioexp_map_s ioexp_map_magnolia_7ab = { - - .chip_amount = 2, - .data_width = 2, - - .map_present = { {1, 0, 4}, /* map_present[0] = MOD_ABS_PORT(X) */ - {1, 0, 5}, /* map_present[1] = MOD_ABS_PORT(X+1) */ - {1, 0, 6}, /* map_present[2] = MOD_ABS_PORT(X+2) */ - {1, 0, 7}, /* map_present[3] = MOD_ABS_PORT(X+3) */ - {1, 1, 4}, /* map_present[4] = MOD_ABS_PORT(X+4) */ - {1, 1, 5}, /* map_present[5] = MOD_ABS_PORT(X+5) */ - }, - .map_reset = { {0, 0, 0}, /* map_reset[0] = QRESET_QSFP_N_P(X) */ - {0, 0, 1}, /* map_reset[1] = QRESET_QSFP_N_P(X+1) */ - {0, 0, 2}, /* map_reset[2] = QRESET_QSFP_N_P(X+2) */ - {0, 0, 3}, /* map_reset[3] = QRESET_QSFP_N_P(X+3) */ - {1, 0, 0}, /* map_reset[4] = QRESET_QSFP_N_P(X+4) */ - {1, 0, 1}, /* map_reset[5] = QRESET_QSFP_N_P(X+5) */ - }, - .map_lpmod = { {0, 0, 4}, /* map_lpmod[0] = LPMODE_QSFP_P(X) */ - {0, 0, 5}, /* map_lpmod[1] = LPMODE_QSFP_P(X+1) */ - {0, 0, 6}, /* map_lpmod[2] = LPMODE_QSFP_P(X+2) */ - {0, 0, 7}, /* map_lpmod[3] = LPMODE_QSFP_P(X+3) */ - {1, 0, 2}, /* map_lpmod[4] = LPMODE_QSFP_P(X+4) */ - {1, 0, 3}, /* map_lpmod[5] = LPMODE_QSFP_P(X+5) */ - }, - .map_modsel = { {0, 1, 4}, /* map_modsel[0] = MODSEL_QSFP_N_P(X) */ - {0, 1, 5}, /* map_modsel[1] = MODSEL_QSFP_N_P(X+1) */ - {0, 1, 6}, /* map_modsel[2] = MODSEL_QSFP_N_P(X+2) */ - {0, 1, 7}, /* map_modsel[3] = MODSEL_QSFP_N_P(X+3) */ - {1, 1, 4}, /* map_modsel[4] = MODSEL_QSFP_N_P(X+4) */ - {1, 1, 5}, /* map_modsel[5] = MODSEL_QSFP_N_P(X+5) */ - }, -}; - - -struct ioexp_map_s ioexp_map_redwood_p01p08_p17p24 = { - - .chip_amount = 3, - .data_width = 2, - - .map_present = { {2, 0, 0}, /* map_present[0] = MOD_ABS_PORT(X) */ - {2, 0, 1}, /* map_present[1] = MOD_ABS_PORT(X+1) */ - {2, 0, 2}, /* map_present[2] = MOD_ABS_PORT(X+2) */ - {2, 0, 3}, /* map_present[3] = MOD_ABS_PORT(X+3) */ - {2, 0, 4}, /* map_present[4] = MOD_ABS_PORT(X+4) */ - {2, 0, 5}, /* map_present[5] = MOD_ABS_PORT(X+5) */ - {2, 0, 6}, /* map_present[6] = MOD_ABS_PORT(X+6) */ - {2, 0, 7}, /* map_present[7] = MOD_ABS_PORT(X+7) */ - }, - .map_reset = { {0, 0, 0}, /* map_reset[0] = QRESET_QSFP28_N_P(X) */ - {0, 0, 1}, /* map_reset[1] = QRESET_QSFP28_N_P(X+1) */ - {0, 0, 2}, /* map_reset[2] = QRESET_QSFP28_N_P(X+2) */ - {0, 0, 3}, /* map_reset[3] = QRESET_QSFP28_N_P(X+3) */ - {1, 0, 0}, /* map_reset[4] = QRESET_QSFP28_N_P(X+4) */ - {1, 0, 1}, /* map_reset[5] = QRESET_QSFP28_N_P(X+5) */ - {1, 0, 2}, /* map_reset[6] = QRESET_QSFP28_N_P(X+6) */ - {1, 0, 3}, /* map_reset[7] = QRESET_QSFP28_N_P(X+7) */ - }, - .map_lpmod = { {0, 0, 4}, /* map_lpmod[0] = LPMODE_QSFP28_P(X) */ - {0, 0, 5}, /* map_lpmod[1] = LPMODE_QSFP28_P(X+1) */ - {0, 0, 6}, /* map_lpmod[2] = LPMODE_QSFP28_P(X+2) */ - {0, 0, 7}, /* map_lpmod[3] = LPMODE_QSFP28_P(X+3) */ - {1, 0, 4}, /* map_lpmod[4] = LPMODE_QSFP28_P(X+4) */ - {1, 0, 5}, /* map_lpmod[5] = LPMODE_QSFP28_P(X+5) */ - {1, 0, 6}, /* map_lpmod[6] = LPMODE_QSFP28_P(X+6) */ - {1, 0, 7}, /* map_lpmod[7] = LPMODE_QSFP28_P(X+7) */ - }, - .map_modsel = { {0, 1, 4}, /* map_modsel[0] = MODSEL_QSFP28_N_P(X) */ - {0, 1, 5}, /* map_modsel[1] = MODSEL_QSFP28_N_P(X+1) */ - {0, 1, 6}, /* map_modsel[2] = MODSEL_QSFP28_N_P(X+2) */ - {0, 1, 7}, /* map_modsel[3] = MODSEL_QSFP28_N_P(X+3) */ - {1, 1, 4}, /* map_modsel[4] = MODSEL_QSFP28_N_P(X+4) */ - {1, 1, 5}, /* map_modsel[5] = MODSEL_QSFP28_N_P(X+5) */ - {1, 1, 6}, /* map_modsel[6] = MODSEL_QSFP28_N_P(X+6) */ - {1, 1, 7}, /* map_modsel[7] = MODSEL_QSFP28_N_P(X+7) */ - }, -}; - - -struct ioexp_map_s ioexp_map_redwood_p09p16_p25p32 = { - - .chip_amount = 3, - .data_width = 2, - - .map_present = { {2, 1, 0}, /* map_present[0] = MOD_ABS_PORT(X) */ - {2, 1, 1}, /* map_present[1] = MOD_ABS_PORT(X+1) */ - {2, 1, 2}, /* map_present[2] = MOD_ABS_PORT(X+2) */ - {2, 1, 3}, /* map_present[3] = MOD_ABS_PORT(X+3) */ - {2, 1, 4}, /* map_present[4] = MOD_ABS_PORT(X+4) */ - {2, 1, 5}, /* map_present[5] = MOD_ABS_PORT(X+5) */ - {2, 1, 6}, /* map_present[6] = MOD_ABS_PORT(X+6) */ - {2, 1, 7}, /* map_present[7] = MOD_ABS_PORT(X+7) */ - }, - .map_reset = { {0, 0, 0}, /* map_reset[0] = QRESET_QSFP28_N_P(X) */ - {0, 0, 1}, /* map_reset[1] = QRESET_QSFP28_N_P(X+1) */ - {0, 0, 2}, /* map_reset[2] = QRESET_QSFP28_N_P(X+2) */ - {0, 0, 3}, /* map_reset[3] = QRESET_QSFP28_N_P(X+3) */ - {1, 0, 0}, /* map_reset[4] = QRESET_QSFP28_N_P(X+4) */ - {1, 0, 1}, /* map_reset[5] = QRESET_QSFP28_N_P(X+5) */ - {1, 0, 2}, /* map_reset[6] = QRESET_QSFP28_N_P(X+6) */ - {1, 0, 3}, /* map_reset[7] = QRESET_QSFP28_N_P(X+7) */ - }, - .map_lpmod = { {0, 0, 4}, /* map_lpmod[0] = LPMODE_QSFP28_P(X) */ - {0, 0, 5}, /* map_lpmod[1] = LPMODE_QSFP28_P(X+1) */ - {0, 0, 6}, /* map_lpmod[2] = LPMODE_QSFP28_P(X+2) */ - {0, 0, 7}, /* map_lpmod[3] = LPMODE_QSFP28_P(X+3) */ - {1, 0, 4}, /* map_lpmod[4] = LPMODE_QSFP28_P(X+4) */ - {1, 0, 5}, /* map_lpmod[5] = LPMODE_QSFP28_P(X+5) */ - {1, 0, 6}, /* map_lpmod[6] = LPMODE_QSFP28_P(X+6) */ - {1, 0, 7}, /* map_lpmod[7] = LPMODE_QSFP28_P(X+7) */ - }, - .map_modsel = { {0, 1, 4}, /* map_modsel[0] = MODSEL_QSFP28_N_P(X) */ - {0, 1, 5}, /* map_modsel[1] = MODSEL_QSFP28_N_P(X+1) */ - {0, 1, 6}, /* map_modsel[2] = MODSEL_QSFP28_N_P(X+2) */ - {0, 1, 7}, /* map_modsel[3] = MODSEL_QSFP28_N_P(X+3) */ - {1, 1, 4}, /* map_modsel[4] = MODSEL_QSFP28_N_P(X+4) */ - {1, 1, 5}, /* map_modsel[5] = MODSEL_QSFP28_N_P(X+5) */ - {1, 1, 6}, /* map_modsel[6] = MODSEL_QSFP28_N_P(X+6) */ - {1, 1, 7}, /* map_modsel[7] = MODSEL_QSFP28_N_P(X+7) */ - }, -}; - - -struct ioexp_map_s ioexp_map_hudson32iga_p01p08_p17p24 = { - - .chip_amount = 3, - .data_width = 2, - - .map_present = { {2, 0, 0}, /* map_present[0] = MODABS_QSFP(X) */ - {2, 0, 1}, /* map_present[1] = MODABS_QSFP(X+1) */ - {2, 0, 2}, /* map_present[2] = MODABS_QSFP(X+2) */ - {2, 0, 3}, /* map_present[3] = MODABS_QSFP(X+3) */ - {2, 0, 4}, /* map_present[4] = MODABS_QSFP(X+4) */ - {2, 0, 5}, /* map_present[5] = MODABS_QSFP(X+5) */ - {2, 0, 6}, /* map_present[6] = MODABS_QSFP(X+6) */ - {2, 0, 7}, /* map_present[7] = MODABS_QSFP(X+7) */ - }, - .map_reset = { {0, 0, 0}, /* map_reset[0] = QRESET_QSFP(X) */ - {0, 0, 1}, /* map_reset[1] = QRESET_QSFP(X+1) */ - {0, 0, 2}, /* map_reset[2] = QRESET_QSFP(X+2) */ - {0, 0, 3}, /* map_reset[3] = QRESET_QSFP(X+3) */ - {1, 0, 0}, /* map_reset[4] = QRESET_QSFP(X+4) */ - {1, 0, 1}, /* map_reset[5] = QRESET_QSFP(X+5) */ - {1, 0, 2}, /* map_reset[6] = QRESET_QSFP(X+6) */ - {1, 0, 3}, /* map_reset[7] = QRESET_QSFP(X+7) */ - }, - .map_lpmod = { {0, 0, 4}, /* map_lpmod[0] = LPMODE_QSFP(X) */ - {0, 0, 5}, /* map_lpmod[1] = LPMODE_QSFP(X+1) */ - {0, 0, 6}, /* map_lpmod[2] = LPMODE_QSFP(X+2) */ - {0, 0, 7}, /* map_lpmod[3] = LPMODE_QSFP(X+3) */ - {1, 0, 4}, /* map_lpmod[4] = LPMODE_QSFP(X+4) */ - {1, 0, 5}, /* map_lpmod[5] = LPMODE_QSFP(X+5) */ - {1, 0, 6}, /* map_lpmod[6] = LPMODE_QSFP(X+6) */ - {1, 0, 7}, /* map_lpmod[7] = LPMODE_QSFP(X+7) */ - }, - .map_modsel = { {0, 1, 4}, /* map_modsel[0] = MODSEL_QSFP(X) */ - {0, 1, 5}, /* map_modsel[1] = MODSEL_QSFP(X+1) */ - {0, 1, 6}, /* map_modsel[2] = MODSEL_QSFP(X+2) */ - {0, 1, 7}, /* map_modsel[3] = MODSEL_QSFP(X+3) */ - {1, 1, 4}, /* map_modsel[4] = MODSEL_QSFP(X+4) */ - {1, 1, 5}, /* map_modsel[5] = MODSEL_QSFP(X+5) */ - {1, 1, 6}, /* map_modsel[6] = MODSEL_QSFP(X+6) */ - {1, 1, 7}, /* map_modsel[7] = MODSEL_QSFP(X+7) */ - }, -}; - - -struct ioexp_map_s ioexp_map_hudson32iga_p09p16_p25p32 = { - - .chip_amount = 3, - .data_width = 2, - - .map_present = { {2, 1, 0}, /* map_present[0] = MODABS_QSFP(X) */ - {2, 1, 1}, /* map_present[1] = MODABS_QSFP(X+1) */ - {2, 1, 2}, /* map_present[2] = MODABS_QSFP(X+2) */ - {2, 1, 3}, /* map_present[3] = MODABS_QSFP(X+3) */ - {2, 1, 4}, /* map_present[4] = MODABS_QSFP(X+4) */ - {2, 1, 5}, /* map_present[5] = MODABS_QSFP(X+5) */ - {2, 1, 6}, /* map_present[6] = MODABS_QSFP(X+6) */ - {2, 1, 7}, /* map_present[7] = MODABS_QSFP(X+7) */ - }, - .map_reset = { {0, 0, 0}, /* map_reset[0] = QRESET_QSFP(X) */ - {0, 0, 1}, /* map_reset[1] = QRESET_QSFP(X+1) */ - {0, 0, 2}, /* map_reset[2] = QRESET_QSFP(X+2) */ - {0, 0, 3}, /* map_reset[3] = QRESET_QSFP(X+3) */ - {1, 0, 0}, /* map_reset[4] = QRESET_QSFP(X+4) */ - {1, 0, 1}, /* map_reset[5] = QRESET_QSFP(X+5) */ - {1, 0, 2}, /* map_reset[6] = QRESET_QSFP(X+6) */ - {1, 0, 3}, /* map_reset[7] = QRESET_QSFP(X+7) */ - }, - .map_lpmod = { {0, 0, 4}, /* map_lpmod[0] = LPMODE_QSFP(X) */ - {0, 0, 5}, /* map_lpmod[1] = LPMODE_QSFP(X+1) */ - {0, 0, 6}, /* map_lpmod[2] = LPMODE_QSFP(X+2) */ - {0, 0, 7}, /* map_lpmod[3] = LPMODE_QSFP(X+3) */ - {1, 0, 4}, /* map_lpmod[4] = LPMODE_QSFP(X+4) */ - {1, 0, 5}, /* map_lpmod[5] = LPMODE_QSFP(X+5) */ - {1, 0, 6}, /* map_lpmod[6] = LPMODE_QSFP(X+6) */ - {1, 0, 7}, /* map_lpmod[7] = LPMODE_QSFP(X+7) */ - }, - .map_modsel = { {0, 1, 4}, /* map_modsel[0] = MODSEL_QSFP(X) */ - {0, 1, 5}, /* map_modsel[1] = MODSEL_QSFP(X+1) */ - {0, 1, 6}, /* map_modsel[2] = MODSEL_QSFP(X+2) */ - {0, 1, 7}, /* map_modsel[3] = MODSEL_QSFP(X+3) */ - {1, 1, 4}, /* map_modsel[4] = MODSEL_QSFP(X+4) */ - {1, 1, 5}, /* map_modsel[5] = MODSEL_QSFP(X+5) */ - {1, 1, 6}, /* map_modsel[6] = MODSEL_QSFP(X+6) */ - {1, 1, 7}, /* map_modsel[7] = MODSEL_QSFP(X+7) */ - }, -}; - - -struct ioexp_map_s ioexp_map_cypress_nabc = { - - .chip_amount = 3, - .data_width = 2, - - .map_present = { {0, 0, 4}, /* map_present[0] = MOD_ABS_PORT(X) */ - {0, 0, 5}, /* map_present[1] = MOD_ABS_PORT(X+1) */ - {0, 0, 6}, /* map_present[2] = MOD_ABS_PORT(X+2) */ - {0, 0, 7}, /* map_present[3] = MOD_ABS_PORT(X+3) */ - {1, 0, 4}, /* map_present[4] = MOD_ABS_PORT(X+4) */ - {1, 0, 5}, /* map_present[5] = MOD_ABS_PORT(X+5) */ - {1, 0, 6}, /* map_present[6] = MOD_ABS_PORT(X+6) */ - {1, 0, 7}, /* map_present[7] = MOD_ABS_PORT(X+7) */ - }, - .map_tx_disable = { {0, 1, 0}, /* map_tx_disable[0] = TXDISABLE_SFP+_P(X) */ - {0, 1, 1}, /* map_tx_disable[1] = TXDISABLE_SFP+_P(X+1) */ - {0, 1, 2}, /* map_tx_disable[2] = TXDISABLE_SFP+_P(X+2) */ - {0, 1, 3}, /* map_tx_disable[3] = TXDISABLE_SFP+_P(X+3) */ - {1, 1, 0}, /* map_tx_disable[4] = TXDISABLE_SFP+_P(X+4) */ - {1, 1, 1}, /* map_tx_disable[5] = TXDISABLE_SFP+_P(X+5) */ - {1, 1, 2}, /* map_tx_disable[6] = TXDISABLE_SFP+_P(X+6) */ - {1, 1, 3}, /* map_tx_disable[7] = TXDISABLE_SFP+_P(X+7) */ - }, - .map_tx_fault = { {0, 0, 0}, /* map_tx_fault[0] = TXFAULT_SFP+_P(X) */ - {0, 0, 1}, /* map_tx_fault[1] = TXFAULT_SFP+_P(X+1) */ - {0, 0, 2}, /* map_tx_fault[2] = TXFAULT_SFP+_P(X+2) */ - {0, 0, 3}, /* map_tx_fault[3] = TXFAULT_SFP+_P(X+3) */ - {1, 0, 0}, /* map_tx_fault[4] = TXFAULT_SFP+_P(X+4) */ - {1, 0, 1}, /* map_tx_fault[5] = TXFAULT_SFP+_P(X+5) */ - {1, 0, 2}, /* map_tx_fault[6] = TXFAULT_SFP+_P(X+6) */ - {1, 0, 3}, /* map_tx_fault[7] = TXFAULT_SFP+_P(X+7) */ - }, - .map_rxlos = { {0, 1, 4}, /* map_rxlos[0] = OPRXLOS_PORT(X) */ - {0, 1, 5}, /* map_rxlos[1] = OPRXLOS_PORT(X+1) */ - {0, 1, 6}, /* map_rxlos[2] = OPRXLOS_PORT(X+2) */ - {0, 1, 7}, /* map_rxlos[3] = OPRXLOS_PORT(X+3) */ - {1, 1, 4}, /* map_rxlos[4] = OPRXLOS_PORT(X+4) */ - {1, 1, 5}, /* map_rxlos[5] = OPRXLOS_PORT(X+5) */ - {1, 1, 6}, /* map_rxlos[6] = OPRXLOS_PORT(X+6) */ - {1, 1, 7}, /* map_rxlos[7] = OPRXLOS_PORT(X+7) */ - }, - .map_hard_rs0 = { {2, 0, 0}, /* map_hard_rs0[0] = RS0_SFP28_P(X) */ - {2, 0, 2}, /* map_hard_rs0[1] = RS0_SFP28_P(X+1) */ - {2, 0, 4}, /* map_hard_rs0[2] = RS0_SFP28_P(X+2) */ - {2, 0, 6}, /* map_hard_rs0[3] = RS0_SFP28_P(X+3) */ - {2, 1, 0}, /* map_hard_rs0[4] = RS0_SFP28_P(X+4) */ - {2, 1, 2}, /* map_hard_rs0[5] = RS0_SFP28_P(X+5) */ - {2, 1, 4}, /* map_hard_rs0[6] = RS0_SFP28_P(X+6) */ - {2, 1, 6}, /* map_hard_rs0[7] = RS0_SFP28_P(X+7) */ - }, - .map_hard_rs1 = { {2, 0, 1}, /* map_hard_rs1[0] = RS1_SFP28_P(X) */ - {2, 0, 3}, /* map_hard_rs1[1] = RS1_SFP28_P(X+1) */ - {2, 0, 5}, /* map_hard_rs1[2] = RS1_SFP28_P(X+2) */ - {2, 0, 7}, /* map_hard_rs1[3] = RS1_SFP28_P(X+3) */ - {2, 1, 1}, /* map_hard_rs1[4] = RS1_SFP28_P(X+4) */ - {2, 1, 3}, /* map_hard_rs1[5] = RS1_SFP28_P(X+5) */ - {2, 1, 5}, /* map_hard_rs1[6] = RS1_SFP28_P(X+6) */ - {2, 1, 7}, /* map_hard_rs1[7] = RS1_SFP28_P(X+7) */ - }, -}; - - -struct ioexp_map_s ioexp_map_cypress_7abc = { - - .chip_amount = 3, - .data_width = 2, - - .map_present = { {2, 0, 0}, /* map_present[0] = MOD_ABS_PORT(X) */ - {2, 0, 1}, /* map_present[1] = MOD_ABS_PORT(X+1) */ - {2, 0, 2}, /* map_present[2] = MOD_ABS_PORT(X+2) */ - {2, 0, 3}, /* map_present[3] = MOD_ABS_PORT(X+3) */ - {2, 0, 4}, /* map_present[4] = MOD_ABS_PORT(X+4) */ - {2, 0, 5}, /* map_present[5] = MOD_ABS_PORT(X+5) */ - }, - .map_reset = { {0, 0, 0}, /* map_reset[0] = QRESET_QSFP_N_P(X) */ - {0, 0, 1}, /* map_reset[1] = QRESET_QSFP_N_P(X+1) */ - {0, 0, 2}, /* map_reset[2] = QRESET_QSFP_N_P(X+2) */ - {0, 0, 3}, /* map_reset[3] = QRESET_QSFP_N_P(X+3) */ - {0, 0, 4}, /* map_reset[4] = QRESET_QSFP_N_P(X+4) */ - {0, 0, 5}, /* map_reset[5] = QRESET_QSFP_N_P(X+5) */ - }, - .map_lpmod = { {0, 1, 0}, /* map_lpmod[0] = LPMODE_QSFP_P(X) */ - {0, 1, 1}, /* map_lpmod[1] = LPMODE_QSFP_P(X+1) */ - {0, 1, 2}, /* map_lpmod[2] = LPMODE_QSFP_P(X+2) */ - {0, 1, 3}, /* map_lpmod[3] = LPMODE_QSFP_P(X+3) */ - {0, 1, 4}, /* map_lpmod[4] = LPMODE_QSFP_P(X+4) */ - {0, 1, 5}, /* map_lpmod[5] = LPMODE_QSFP_P(X+5) */ - }, - .map_modsel = { {1, 1, 0}, /* map_modsel[0] = MODSEL_QSFP_N_P(X) */ - {1, 1, 1}, /* map_modsel[1] = MODSEL_QSFP_N_P(X+1) */ - {1, 1, 2}, /* map_modsel[2] = MODSEL_QSFP_N_P(X+2) */ - {1, 1, 3}, /* map_modsel[3] = MODSEL_QSFP_N_P(X+3) */ - {1, 1, 4}, /* map_modsel[4] = MODSEL_QSFP_N_P(X+4) */ - {1, 1, 5}, /* map_modsel[5] = MODSEL_QSFP_N_P(X+5) */ - }, -}; - - -struct ioexp_map_s ioexp_map_tahoe_5a = { - - .chip_amount = 1, - .data_width = 2, - - .map_present = { {0, 0, 3}, /* map_present[0] = MOD_ABS_PORT(X) */ - {0, 1, 0}, /* map_present[1] = MOD_ABS_PORT(X+1) */ - {0, 1, 5}, /* map_present[2] = MOD_ABS_PORT(X+2) */ - }, - .map_reset = { {0, 0, 1}, /* map_reset[0] = QRESET_QSFP_N_P(X) */ - {0, 0, 6}, /* map_reset[1] = QRESET_QSFP_N_P(X+1) */ - {0, 1, 3}, /* map_reset[2] = QRESET_QSFP_N_P(X+2) */ - }, - .map_lpmod = { {0, 0, 2}, /* map_lpmod[0] = LPMODE_QSFP_P(X) */ - {0, 0, 7}, /* map_lpmod[1] = LPMODE_QSFP_P(X+1) */ - {0, 1, 4}, /* map_lpmod[2] = LPMODE_QSFP_P(X+2) */ - }, - .map_modsel = { {0, 0, 0}, /* map_modsel[0] = MODSEL_QSFP_N_P(X) */ - {0, 0, 5}, /* map_modsel[1] = MODSEL_QSFP_N_P(X+1) */ - {0, 1, 2}, /* map_modsel[2] = MODSEL_QSFP_N_P(X+2) */ - }, -}; - - -struct ioexp_map_s ioexp_map_tahoe_6abc = { - - .chip_amount = 3, - .data_width = 2, - - .map_present = { {0, 0, 3}, /* map_present[0] = MOD_ABS_PORT(X) */ - {0, 1, 0}, /* map_present[1] = MOD_ABS_PORT(X+1) */ - {0, 1, 5}, /* map_present[2] = MOD_ABS_PORT(X+2) */ - {1, 0, 3}, /* map_present[3] = MOD_ABS_PORT(X+3) */ - {1, 1, 0}, /* map_present[4] = MOD_ABS_PORT(X+4) */ - {1, 1, 5}, /* map_present[5] = MOD_ABS_PORT(X+5) */ - {2, 0, 3}, /* map_present[6] = MOD_ABS_PORT(X+6) */ - {2, 1, 0}, /* map_present[7] = MOD_ABS_PORT(X+7) */ - {2, 1, 5}, /* map_present[8] = MOD_ABS_PORT(X+8) */ - }, - .map_reset = { {0, 0, 1}, /* map_reset[0] = QRESET_QSFP28_N_P(X) */ - {0, 0, 6}, /* map_reset[1] = QRESET_QSFP28_N_P(X+1) */ - {0, 1, 3}, /* map_reset[2] = QRESET_QSFP28_N_P(X+2) */ - {1, 0, 1}, /* map_reset[3] = QRESET_QSFP28_N_P(X+3) */ - {1, 0, 6}, /* map_reset[4] = QRESET_QSFP28_N_P(X+4) */ - {1, 1, 3}, /* map_reset[5] = QRESET_QSFP28_N_P(X+5) */ - {2, 0, 1}, /* map_reset[6] = QRESET_QSFP28_N_P(X+6) */ - {2, 0, 6}, /* map_reset[7] = QRESET_QSFP28_N_P(X+7) */ - {2, 1, 3}, /* map_reset[7] = QRESET_QSFP28_N_P(X+7) */ - }, - .map_lpmod = { {0, 0, 2}, /* map_lpmod[0] = LPMODE_QSFP28_P(X) */ - {0, 0, 7}, /* map_lpmod[1] = LPMODE_QSFP28_P(X+1) */ - {0, 1, 4}, /* map_lpmod[2] = LPMODE_QSFP28_P(X+2) */ - {1, 0, 2}, /* map_lpmod[3] = LPMODE_QSFP28_P(X+3) */ - {1, 0, 7}, /* map_lpmod[4] = LPMODE_QSFP28_P(X+4) */ - {1, 1, 4}, /* map_lpmod[5] = LPMODE_QSFP28_P(X+5) */ - {2, 0, 2}, /* map_lpmod[6] = LPMODE_QSFP28_P(X+6) */ - {2, 0, 7}, /* map_lpmod[7] = LPMODE_QSFP28_P(X+7) */ - {2, 1, 4}, /* map_lpmod[7] = LPMODE_QSFP28_P(X+8) */ - }, - .map_modsel = { {0, 0, 0}, /* map_modsel[0] = MODSEL_QSFP28_N_P(X) */ - {0, 0, 5}, /* map_modsel[1] = MODSEL_QSFP28_N_P(X+1) */ - {0, 1, 2}, /* map_modsel[2] = MODSEL_QSFP28_N_P(X+2) */ - {1, 0, 0}, /* map_modsel[3] = MODSEL_QSFP28_N_P(X+3) */ - {1, 0, 5}, /* map_modsel[4] = MODSEL_QSFP28_N_P(X+4) */ - {1, 1, 2}, /* map_modsel[5] = MODSEL_QSFP28_N_P(X+5) */ - {2, 0, 0}, /* map_modsel[6] = MODSEL_QSFP28_N_P(X+6) */ - {2, 0, 5}, /* map_modsel[7] = MODSEL_QSFP28_N_P(X+7) */ - {2, 1, 2}, /* map_modsel[7] = MODSEL_QSFP28_N_P(X+7) */ - }, -}; - - -struct ioexp_map_s ioexp_map_sequoia_nabc = { - - .chip_amount = 3, - .data_width = 2, - - .map_present = { {2, 1, 0}, /* map_present[0] = MOD_ABS_PORT(X) */ - {2, 1, 1}, /* map_present[1] = MOD_ABS_PORT(X+1) */ - {2, 1, 2}, /* map_present[2] = MOD_ABS_PORT(X+2) */ - {2, 1, 3}, /* map_present[3] = MOD_ABS_PORT(X+3) */ - {2, 1, 4}, /* map_present[4] = MOD_ABS_PORT(X+4) */ - {2, 1, 5}, /* map_present[5] = MOD_ABS_PORT(X+5) */ - {2, 1, 6}, /* map_present[6] = MOD_ABS_PORT(X+6) */ - {2, 1, 7}, /* map_present[7] = MOD_ABS_PORT(X+7) */ - }, - .map_reset = { {0, 1, 0}, /* map_reset[0] = QRESET_QSFP28_N_P(X) */ - {0, 1, 1}, /* map_reset[1] = QRESET_QSFP28_N_P(X+1) */ - {0, 1, 2}, /* map_reset[2] = QRESET_QSFP28_N_P(X+2) */ - {0, 1, 3}, /* map_reset[3] = QRESET_QSFP28_N_P(X+3) */ - {0, 1, 4}, /* map_reset[4] = QRESET_QSFP28_N_P(X+4) */ - {0, 1, 5}, /* map_reset[5] = QRESET_QSFP28_N_P(X+5) */ - {0, 1, 6}, /* map_reset[6] = QRESET_QSFP28_N_P(X+6) */ - {0, 1, 7}, /* map_reset[7] = QRESET_QSFP28_N_P(X+7) */ - }, - .map_lpmod = { {1, 0, 0}, /* map_lpmod[0] = LPMODE_QSFP28_P(X) */ - {1, 0, 1}, /* map_lpmod[1] = LPMODE_QSFP28_P(X+1) */ - {1, 0, 2}, /* map_lpmod[2] = LPMODE_QSFP28_P(X+2) */ - {1, 0, 3}, /* map_lpmod[3] = LPMODE_QSFP28_P(X+3) */ - {1, 0, 4}, /* map_lpmod[4] = LPMODE_QSFP28_P(X+4) */ - {1, 0, 5}, /* map_lpmod[5] = LPMODE_QSFP28_P(X+5) */ - {1, 0, 6}, /* map_lpmod[6] = LPMODE_QSFP28_P(X+6) */ - {1, 0, 7}, /* map_lpmod[7] = LPMODE_QSFP28_P(X+7) */ - }, - .map_modsel = { {0, 0, 0}, /* map_modsel[0] = MODSEL_QSFP28_N_P(X) */ - {0, 0, 1}, /* map_modsel[1] = MODSEL_QSFP28_N_P(X+1) */ - {0, 0, 2}, /* map_modsel[2] = MODSEL_QSFP28_N_P(X+2) */ - {0, 0, 3}, /* map_modsel[3] = MODSEL_QSFP28_N_P(X+3) */ - {0, 0, 4}, /* map_modsel[4] = MODSEL_QSFP28_N_P(X+4) */ - {0, 0, 5}, /* map_modsel[5] = MODSEL_QSFP28_N_P(X+5) */ - {0, 0, 6}, /* map_modsel[6] = MODSEL_QSFP28_N_P(X+6) */ - {0, 0, 7}, /* map_modsel[7] = MODSEL_QSFP28_N_P(X+7) */ - }, -}; - - -struct ioexp_map_s ioexp_map_lavender_p65 = { - - .chip_amount = 1, - .data_width = 1, - - .map_present = { {0, 0, 4}, }, /* map_present[0] = MOD_ABS_PORT(X) */ - .map_reset = { {0, 0, 1}, }, /* map_reset[0] = QRESET_QSFP28_N_P(X) */ - .map_lpmod = { {0, 0, 2}, }, /* map_lpmod[0] = LPMODE_QSFP28_P(X) */ - .map_modsel = { {0, 0, 0}, }, /* map_modsel[0] = MODSEL_QSFP28_N_P(X) */ -}; - - -struct ioexp_map_s cpld_map_cottonwood = { - - .chip_amount = 1, - .data_width = 4, - - .map_present = { {0, 2, 0}, /* map_present[0] = MOD_ABS_PORT(X) */ - {0, 2, 4}, /* map_present[1] = MOD_ABS_PORT(X+1) */ - {0, 3, 0}, /* map_present[2] = MOD_ABS_PORT(X+2) */ - {0, 3, 4}, /* map_present[3] = MOD_ABS_PORT(X+3) */ - }, - .map_tx_disable = { {0, 0, 0}, /* map_tx_disable[0] = TXDISABLE_SFP+_P(X) */ - {0, 0, 4}, /* map_tx_disable[1] = TXDISABLE_SFP+_P(X+1) */ - {0, 1, 0}, /* map_tx_disable[2] = TXDISABLE_SFP+_P(X+2) */ - {0, 1, 4}, /* map_tx_disable[3] = TXDISABLE_SFP+_P(X+3) */ - }, - .map_tx_fault = { {0, 2, 2}, /* map_tx_fault[0] = TXFAULT_SFP+_P(X) */ - {0, 2, 6}, /* map_tx_fault[1] = TXFAULT_SFP+_P(X+1) */ - {0, 3, 2}, /* map_tx_fault[2] = TXFAULT_SFP+_P(X+2) */ - {0, 3, 6}, /* map_tx_fault[3] = TXFAULT_SFP+_P(X+3) */ - }, - .map_rxlos = { {0, 2, 1}, /* map_rxlos[0] = OPRXLOS_PORT(X) */ - {0, 2, 5}, /* map_rxlos[1] = OPRXLOS_PORT(X+1) */ - {0, 3, 1}, /* map_rxlos[2] = OPRXLOS_PORT(X+2) */ - {0, 3, 5}, /* map_rxlos[3] = OPRXLOS_PORT(X+3) */ - }, - .map_hard_rs0 = { {0, 0, 2}, /* map_hard_rs0[0] = RS0_SFP28_P(X) */ - {0, 0, 6}, /* map_hard_rs0[1] = RS0_SFP28_P(X+1) */ - {0, 1, 2}, /* map_hard_rs0[2] = RS0_SFP28_P(X+2) */ - {0, 1, 6}, /* map_hard_rs0[3] = RS0_SFP28_P(X+3) */ - }, - .map_hard_rs1 = { {0, 0, 2}, /* map_hard_rs1[0] = RS1_SFP28_P(X) */ - {0, 0, 6}, /* map_hard_rs1[1] = RS1_SFP28_P(X+1) */ - {0, 1, 2}, /* map_hard_rs1[2] = RS1_SFP28_P(X+2) */ - {0, 1, 6}, /* map_hard_rs1[3] = RS1_SFP28_P(X+3) */ - }, -}; - -struct ioexp_map_s ioexp_map_maple_0abc = { - - .chip_amount = 3, - .data_width = 2, - - .map_present = { {2, 1, 0}, /* map_present[0] = MOD_ABS_PORT(X) */ - {2, 1, 1}, /* map_present[1] = MOD_ABS_PORT(X+1) */ - {2, 1, 2}, /* map_present[2] = MOD_ABS_PORT(X+2) */ - {2, 1, 3}, /* map_present[3] = MOD_ABS_PORT(X+3) */ - {2, 1, 4}, /* map_present[4] = MOD_ABS_PORT(X+4) */ - {2, 1, 5}, /* map_present[5] = MOD_ABS_PORT(X+5) */ - {2, 1, 6}, /* map_present[6] = MOD_ABS_PORT(X+6) */ - {2, 1, 7}, /* map_present[7] = MOD_ABS_PORT(X+7) */ - }, - .map_reset = { {0, 1, 0}, /* map_reset[0] = QRESET_QSFP_N_P(X) */ - {0, 1, 1}, /* map_reset[1] = QRESET_QSFP_N_P(X+1) */ - {0, 1, 2}, /* map_reset[2] = QRESET_QSFP_N_P(X+2) */ - {0, 1, 3}, /* map_reset[3] = QRESET_QSFP_N_P(X+3) */ - {0, 1, 4}, /* map_reset[4] = QRESET_QSFP_N_P(X+4) */ - {0, 1, 5}, /* map_reset[5] = QRESET_QSFP_N_P(X+5) */ - {0, 1, 6}, /* map_reset[6] = QRESET_QSFP_N_P(X+6) */ - {0, 1, 7}, /* map_reset[7] = QRESET_QSFP_N_P(X+7) */ - }, - .map_lpmod = { {1, 0, 0}, /* map_lpmod[0] = LPMODE_QSFP_P(X) */ - {1, 0, 1}, /* map_lpmod[1] = LPMODE_QSFP_P(X+1) */ - {1, 0, 2}, /* map_lpmod[2] = LPMODE_QSFP_P(X+2) */ - {1, 0, 3}, /* map_lpmod[3] = LPMODE_QSFP_P(X+3) */ - {1, 0, 4}, /* map_lpmod[4] = LPMODE_QSFP_P(X+4) */ - {1, 0, 5}, /* map_lpmod[5] = LPMODE_QSFP_P(X+5) */ - {1, 0, 6}, /* map_lpmod[6] = LPMODE_QSFP_P(X+6) */ - {1, 0, 7}, /* map_lpmod[7] = LPMODE_QSFP_P(X+7) */ - }, - .map_modsel = { {0, 0, 0}, /* map_modsel[0] = MODSEL_QSFP_N_P(X) */ - {0, 0, 1}, /* map_modsel[1] = MODSEL_QSFP_N_P(X+1) */ - {0, 0, 2}, /* map_modsel[2] = MODSEL_QSFP_N_P(X+2) */ - {0, 0, 3}, /* map_modsel[3] = MODSEL_QSFP_N_P(X+3) */ - {0, 0, 4}, /* map_modsel[4] = MODSEL_QSFP_N_P(X+4) */ - {0, 0, 5}, /* map_modsel[5] = MODSEL_QSFP_N_P(X+5) */ - {0, 0, 6}, /* map_modsel[6] = MODSEL_QSFP_N_P(X+6) */ - {0, 0, 7}, /* map_modsel[7] = MODSEL_QSFP_N_P(X+7) */ - }, -}; - -struct ioexp_map_s ioexp_map_maple_nabc = { - - .chip_amount = 3, - .data_width = 2, - - .map_present = { {0, 0, 4}, /* map_present[0] = MOD_ABS_PORT(X) */ - {0, 0, 5}, /* map_present[1] = MOD_ABS_PORT(X+1) */ - {0, 0, 6}, /* map_present[2] = MOD_ABS_PORT(X+2) */ - {0, 0, 7}, /* map_present[3] = MOD_ABS_PORT(X+3) */ - {1, 0, 4}, /* map_present[4] = MOD_ABS_PORT(X+4) */ - {1, 0, 5}, /* map_present[5] = MOD_ABS_PORT(X+5) */ - {1, 0, 6}, /* map_present[6] = MOD_ABS_PORT(X+6) */ - {1, 0, 7}, /* map_present[7] = MOD_ABS_PORT(X+7) */ - }, - .map_tx_disable = { {0, 1, 0}, /* map_tx_disable[0] = TXDISABLE_SFP+_P(X) */ - {0, 1, 1}, /* map_tx_disable[1] = TXDISABLE_SFP+_P(X+1) */ - {0, 1, 2}, /* map_tx_disable[2] = TXDISABLE_SFP+_P(X+2) */ - {0, 1, 3}, /* map_tx_disable[3] = TXDISABLE_SFP+_P(X+3) */ - {1, 1, 0}, /* map_tx_disable[4] = TXDISABLE_SFP+_P(X+4) */ - {1, 1, 1}, /* map_tx_disable[5] = TXDISABLE_SFP+_P(X+5) */ - {1, 1, 2}, /* map_tx_disable[6] = TXDISABLE_SFP+_P(X+6) */ - {1, 1, 3}, /* map_tx_disable[7] = TXDISABLE_SFP+_P(X+7) */ - }, - .map_tx_fault = { {0, 0, 0}, /* map_tx_fault[0] = TXFAULT_SFP+_P(X) */ - {0, 0, 1}, /* map_tx_fault[1] = TXFAULT_SFP+_P(X+1) */ - {0, 0, 2}, /* map_tx_fault[2] = TXFAULT_SFP+_P(X+2) */ - {0, 0, 3}, /* map_tx_fault[3] = TXFAULT_SFP+_P(X+3) */ - {1, 0, 0}, /* map_tx_fault[4] = TXFAULT_SFP+_P(X+4) */ - {1, 0, 1}, /* map_tx_fault[5] = TXFAULT_SFP+_P(X+5) */ - {1, 0, 2}, /* map_tx_fault[6] = TXFAULT_SFP+_P(X+6) */ - {1, 0, 3}, /* map_tx_fault[7] = TXFAULT_SFP+_P(X+7) */ - }, - .map_rxlos = { {0, 1, 4}, /* map_rxlos[0] = OPRXLOS_PORT(X) */ - {0, 1, 5}, /* map_rxlos[1] = OPRXLOS_PORT(X+1) */ - {0, 1, 6}, /* map_rxlos[2] = OPRXLOS_PORT(X+2) */ - {0, 1, 7}, /* map_rxlos[3] = OPRXLOS_PORT(X+3) */ - {1, 1, 4}, /* map_rxlos[4] = OPRXLOS_PORT(X+4) */ - {1, 1, 5}, /* map_rxlos[5] = OPRXLOS_PORT(X+5) */ - {1, 1, 6}, /* map_rxlos[6] = OPRXLOS_PORT(X+6) */ - {1, 1, 7}, /* map_rxlos[7] = OPRXLOS_PORT(X+7) */ - }, - .map_hard_rs0 = { {2, 0, 0}, /* map_hard_rs0[0] = RS0_SFP28_P(X) */ - {2, 0, 2}, /* map_hard_rs0[1] = RS0_SFP28_P(X+1) */ - {2, 0, 4}, /* map_hard_rs0[2] = RS0_SFP28_P(X+2) */ - {2, 0, 6}, /* map_hard_rs0[3] = RS0_SFP28_P(X+3) */ - {2, 1, 0}, /* map_hard_rs0[4] = RS0_SFP28_P(X+4) */ - {2, 1, 2}, /* map_hard_rs0[5] = RS0_SFP28_P(X+5) */ - {2, 1, 4}, /* map_hard_rs0[6] = RS0_SFP28_P(X+6) */ - {2, 1, 6}, /* map_hard_rs0[7] = RS0_SFP28_P(X+7) */ - }, - .map_hard_rs1 = { {2, 0, 1}, /* map_hard_rs1[0] = RS1_SFP28_P(X) */ - {2, 0, 3}, /* map_hard_rs1[1] = RS1_SFP28_P(X+1) */ - {2, 0, 5}, /* map_hard_rs1[2] = RS1_SFP28_P(X+2) */ - {2, 0, 7}, /* map_hard_rs1[3] = RS1_SFP28_P(X+3) */ - {2, 1, 1}, /* map_hard_rs1[4] = RS1_SFP28_P(X+4) */ - {2, 1, 3}, /* map_hard_rs1[5] = RS1_SFP28_P(X+5) */ - {2, 1, 5}, /* map_hard_rs1[6] = RS1_SFP28_P(X+6) */ - {2, 1, 7}, /* map_hard_rs1[7] = RS1_SFP28_P(X+7) */ - }, -}; - -/* ========== Private functions ========== - */ -int check_channel_tier_1(void); - -struct i2c_client * -_get_i2c_client(struct ioexp_obj_s *self, - int chip_id){ - - struct ioexp_i2c_s *i2c_curr_p = self->i2c_head_p; - - if (!(i2c_curr_p)){ - SWPS_ERR("%s: i2c_curr_p is NULL\n", __func__); - return NULL; - } - while (i2c_curr_p){ - if ((i2c_curr_p->chip_id) == chip_id){ - return i2c_curr_p->i2c_client_p; - } - i2c_curr_p = i2c_curr_p->next; - } - SWPS_ERR("%s: not exist! :%d\n", __func__, chip_id); - return NULL; -} - - -static int -_common_ioexp_update_one(struct ioexp_obj_s *self, - struct ioexp_addr_s *ioexp_addr, - int chip_id, - int data_width, - int show_err, - char *caller_name) { - int buf = 0; - int err = 0; - int data_id = 0; - int r_offset = 0; - - for(data_id=0; data_idread_offset[data_id]; - buf = i2c_smbus_read_byte_data(_get_i2c_client(self, chip_id), r_offset); - /* Check error */ - if (buf < 0) { - err = 1; - if (show_err) { - SWPS_INFO("IOEXP-%d read fail! :%d \n", self->ioexp_id, buf); - SWPS_INFO("Dump: :%d :0x%02x :%d, :%s\n", - ioexp_addr->chan_id, ioexp_addr->chip_addr, - ioexp_addr->read_offset[data_id], caller_name); - } - continue; - } - /* Update IOEXP object */ - self->chip_data[chip_id].data[data_id] = (uint8_t)buf; - } - if (err) { - return ERR_IOEXP_UNEXCPT; - } - return 0; -} - - -static int -common_ioexp_update_all(struct ioexp_obj_s *self, - int show_err, - char *caller_name){ - - int err = 0; - int chip_id = 0; - int chip_amount = self->ioexp_map_p->chip_amount; - - for (chip_id=0; chip_idioexp_map_p->map_addr[chip_id]), - chip_id, - self->ioexp_map_p->data_width, - show_err, - caller_name) < 0) { - err = 1; - } - } - if (err) { - return ERR_IOEXP_UNEXCPT; - } - return 0; -} - - -static int -_common_check_by_mode(struct ioexp_obj_s *self){ - - switch (self->mode){ - case IOEXP_MODE_DIRECT: - return self->fsm_4_direct(self); - - case IOEXP_MODE_POLLING: - if (self->state >= 0){ - return 0; - } - switch (self->state){ - case STATE_IOEXP_INIT: - return ERR_IOEXP_UNINIT; - case STATE_IOEXP_ABNORMAL: - return ERR_IOEXP_ABNORMAL; - default: - return ERR_IOEXP_NOSTATE; - } - break; - - default: - break; - } - SWPS_ERR("%s: Exception occurs. :%d \n", __func__, self->mode); - return ERR_IOEXP_UNEXCPT; -} - - -static int -_common_get_bit(struct ioexp_obj_s *self, - struct ioexp_bitmap_s *bitmap_obj_p, - char *func_mane){ - uint8_t buf; - int err_code; - - /* Check and get address */ - err_code = _common_check_by_mode(self); - if (err_code < 0){ - return err_code; - } - if (!bitmap_obj_p){ - SWPS_ERR("Layout config incorrect! :%d :%s\n", - self->ioexp_id, func_mane); - return ERR_IOEXP_BADCONF; - } - /* Get data form cache */ - buf = self->chip_data[bitmap_obj_p->chip_id].data[bitmap_obj_p->ioexp_voffset]; - return (int)(buf >> bitmap_obj_p->bit_shift & 0x01); -} - - -static int -_common_set_bit(struct ioexp_obj_s *self, - struct ioexp_bitmap_s *bitmap_obj_p, - int input_val, - char *func_mane){ - int err_code, target_offset; - uint8_t origin_byte; - uint8_t modify_byte; - - /* Check and get address */ - err_code = _common_check_by_mode(self); - if (err_code < 0){ - return err_code; - } - if (!bitmap_obj_p){ - SWPS_ERR("Layout config incorrect! :%d :%s\n", - self->ioexp_id, func_mane); - return ERR_IOEXP_BADCONF; - } - /* Prepare write date */ - origin_byte = self->chip_data[bitmap_obj_p->chip_id].data[bitmap_obj_p->ioexp_voffset]; - switch (input_val) { - case 0: - modify_byte = origin_byte; - SWP_BIT_CLEAR(modify_byte, bitmap_obj_p->bit_shift); - break; - case 1: - modify_byte = origin_byte; - SWP_BIT_SET(modify_byte, bitmap_obj_p->bit_shift); - break; - default: - SWPS_ERR("Input value incorrect! :%d :%d :%s\n", - input_val, self->ioexp_id, func_mane); - return ERR_IOEXP_BADINPUT; - } - /* Setup i2c client */ - target_offset = self->ioexp_map_p->map_addr[bitmap_obj_p->chip_id].write_offset[bitmap_obj_p->ioexp_voffset]; - /* Write byte to chip via I2C */ - err_code = i2c_smbus_write_byte_data(_get_i2c_client(self, bitmap_obj_p->chip_id), - target_offset, - modify_byte); - /* Update or bollback object */ - if (err_code < 0){ - self->chip_data[bitmap_obj_p->chip_id].data[bitmap_obj_p->ioexp_voffset] = origin_byte; - SWPS_ERR("I2C write fail! :%d :%d :%s :%d\n", - input_val, self->ioexp_id, func_mane, err_code); - return err_code; - } - self->chip_data[bitmap_obj_p->chip_id].data[bitmap_obj_p->ioexp_voffset] = modify_byte; - return 0; -} - - -/* ========== Object public functions ========== - */ -int -common_get_present(struct ioexp_obj_s *self, - int virt_offset){ - - int UNPLUG = 1; - int retval = ERR_IOEXP_UNEXCPT; - - retval = _common_get_bit(self, - &(self->ioexp_map_p->map_present[virt_offset]), - "common_get_present"); - if (retval < 0) { - /* [Note] - * => Transceiver object does not need to handle IOEXP layer issues. - */ - return UNPLUG; - } - return retval; -} - - -int -common_get_tx_fault(struct ioexp_obj_s *self, - int virt_offset){ - /* [Transmit Fault (Tx_Fault)] - * A catastrophic laser fault will activate the transmitter signal, - * TX_FAULT, and disable the laser. This signal is an open collector - * output (pull-up required on the host board). A low signal indicates - * normal laser operation and a high signal indicates a fault. The - * TX_FAULT will be latched high when a laser fault occurs and is - * cleared by toggling the TX_DISABLE input or power cycling the - * transceiver. The transmitter fault condition can also be monitored - * via the two-wire serial interface. - * (address A2, byte 110, bit 2). - * - * 0: Normal - * 1: Abnormal - */ - return _common_get_bit(self, - &(self->ioexp_map_p->map_tx_fault[virt_offset]), - "common_get_tx_fault"); -} - - -int -common_get_rxlos(struct ioexp_obj_s *self, - int virt_offset){ - /* [Receiver Loss of Signal (Rx_LOS)] - * The post-amplification IC also includes transition detection circuitry - * which monitors the ac level of incoming optical signals and provides a - * TTL/CMOS compatible status signal to the host (pin 8). An adequate optical - * input results in a low Rx_LOS output while a high Rx_LOS output indicates - * an unusable optical input. The Rx_LOS thresholds are factory set so that - * a high output indicates a definite optical fault has occurred. Rx_LOS can - * also be monitored via the two-wire serial interface - * (address A2h, byte 110, bit 1). - * - * 0: Normal - * 1: Abnormal - */ - return _common_get_bit(self, - &(self->ioexp_map_p->map_rxlos[virt_offset]), - "common_get_rxlos"); -} - - -int -common_get_tx_disable(struct ioexp_obj_s *self, - int virt_offset){ - - return _common_get_bit(self, - &(self->ioexp_map_p->map_tx_disable[virt_offset]), - "common_get_tx_disable"); -} - - -int -common_get_reset(struct ioexp_obj_s *self, - int virt_offset){ - - return _common_get_bit(self, - &(self->ioexp_map_p->map_reset[virt_offset]), - "common_get_reset"); -} - - -int -common_get_lpmod(struct ioexp_obj_s *self, - int virt_offset){ - - return _common_get_bit(self, - &(self->ioexp_map_p->map_lpmod[virt_offset]), - "common_get_lpmod"); -} - - -int -common_get_modsel(struct ioexp_obj_s *self, - int virt_offset){ - - return _common_get_bit(self, - &(self->ioexp_map_p->map_modsel[virt_offset]), - "common_get_modsel"); -} - - -int -common_get_hard_rs0(struct ioexp_obj_s *self, - int virt_offset){ - - return _common_get_bit(self, - &(self->ioexp_map_p->map_hard_rs0[virt_offset]), - "common_get_hard_rs0"); -} - - -int -common_get_hard_rs1(struct ioexp_obj_s *self, - int virt_offset){ - - return _common_get_bit(self, - &(self->ioexp_map_p->map_hard_rs1[virt_offset]), - "common_get_hard_rs1"); -} - - -int -common_set_tx_disable(struct ioexp_obj_s *self, - int virt_offset, - int input_val){ - - return _common_set_bit(self, - &(self->ioexp_map_p->map_tx_disable[virt_offset]), - input_val, - "common_set_tx_disable"); -} - - -int -common_set_reset(struct ioexp_obj_s *self, - int virt_offset, - int input_val){ - - return _common_set_bit(self, - &(self->ioexp_map_p->map_reset[virt_offset]), - input_val, - "common_set_reset"); -} - - -int -common_set_lpmod(struct ioexp_obj_s *self, - int virt_offset, - int input_val){ - - return _common_set_bit(self, - &(self->ioexp_map_p->map_lpmod[virt_offset]), - input_val, - "common_set_lpmod"); -} - - -int -common_set_modsel(struct ioexp_obj_s *self, - int virt_offset, - int input_val){ - - return _common_set_bit(self, - &(self->ioexp_map_p->map_modsel[virt_offset]), - input_val, - "common_set_modsel"); -} - - -int -common_set_hard_rs0(struct ioexp_obj_s *self, - int virt_offset, - int input_val){ - - return _common_set_bit(self, - &(self->ioexp_map_p->map_hard_rs0[virt_offset]), - input_val, - "common_set_hard_rs0"); -} - - -int -common_set_hard_rs1(struct ioexp_obj_s *self, - int virt_offset, - int input_val){ - - return _common_set_bit(self, - &(self->ioexp_map_p->map_hard_rs1[virt_offset]), - input_val, - "common_set_hard_rs1"); -} - - -int -ioexp_get_not_support(struct ioexp_obj_s *self, - int virt_offset){ - return ERR_IOEXP_NOTSUPPORT; -} - - -int -ioexp_set_not_support(struct ioexp_obj_s *self, - int virt_offset, - int input_val){ - return ERR_IOEXP_NOTSUPPORT; -} - - -int -fake_ioexp_init(struct ioexp_obj_s *self){ - return 1; -} - -int -fake_ioexp_update(struct ioexp_obj_s *self){ - return 1; -} - - -int -fake_update_func(struct ioexp_obj_s *self){ - return 1; -} - -int -fake_get_func(struct ioexp_obj_s *self, - int virt_offset){ - SWPS_WARN("Someone called fake_get_func\n"); - return -1; -} - -int -fake_set_func(struct ioexp_obj_s *self, - int virt_offset, - int input_val){ - SWPS_WARN("Someone called fake_set_func\n"); - return -1; -} - - -/* ========== Initial functions for IO Expander ========== - */ -int -common_ioexp_init(struct ioexp_obj_s *self) { - - int chip_id, offset, err_code; - struct ioexp_addr_s *addr_p; - - if (self->mode == IOEXP_MODE_DIRECT) { - goto update_common_ioexp_init; - } - /* Setup default value to each physical IO Expander */ - for (chip_id=0; chip_id<(self->ioexp_map_p->chip_amount); chip_id++){ - /* Get address mapping */ - addr_p = &(self->ioexp_map_p->map_addr[chip_id]); - if (!addr_p){ - SWPS_ERR("%s: IOEXP config incorrect! :%d \n", - __func__, chip_id); - return -1; - } - /* Setup default value */ - for (offset=0; offset<(self->ioexp_map_p->data_width); offset++){ - - /* [Desc] Skip the setup default value behavior - [Note] Setup default value = -1 if you don't want to write the value to IOEXP or CPLD - */ - if(addr_p->write_offset[offset] < 0){ - SWPS_DEBUG("skip a write_offset <%d>\n", addr_p->conf_offset[offset]); - continue; - } - err_code = i2c_smbus_write_byte_data(_get_i2c_client(self, chip_id), - addr_p->write_offset[offset], - addr_p->data_default[offset]); - if (err_code < 0){ - SWPS_ERR("%s: set default fail! :%d \n", - __func__, err_code); - return ERR_IOEXP_UNEXCPT; - } - } - } -update_common_ioexp_init: - /* Check and update info to object */ - err_code = self->update_all(self, 1, "common_ioexp_init"); - if (err_code < 0) { - SWPS_ERR("%s: update_all() fail! :%d \n", - __func__, err_code); - return ERR_IOEXP_UNEXCPT; - } - return 0; -} - - -/* ========== Object functions for Final State Machine ========== - */ -int -_is_channel_ready(struct ioexp_obj_s *self){ - - int buf = 0; - int chip_id = 0; /* Use first chip which be registered */ - int data_id = 0; /* Use first byte which be registered */ - struct ioexp_addr_s *ioexp_addr = NULL; - - ioexp_addr = &(self->ioexp_map_p->map_addr[chip_id]); - if (!ioexp_addr){ - SWPS_ERR("%s: config incorrect!\n", __func__); - return ERR_IOEXP_UNEXCPT; - } - buf = i2c_smbus_read_byte_data(_get_i2c_client(self, chip_id), - ioexp_addr->read_offset[data_id]); - if (buf >= 0){ - return 1; - } - return 0; -} - -int -_ioexp_init_handler(struct ioexp_obj_s *self){ - - int return_val; - - switch (self->mode) { - case IOEXP_MODE_DIRECT: - return_val = self->init(self); - if (return_val < 0){ - self->state = STATE_IOEXP_ABNORMAL; - } else { - self->state = STATE_IOEXP_NORMAL; - } - return return_val; - - case IOEXP_MODE_POLLING: - /* Check system and channel is ready */ - if (self->state == STATE_IOEXP_INIT){ - if (!_is_channel_ready(self)){ - self->state = STATE_IOEXP_INIT; - SWPS_WARN("%s: IOEXP:%d channel not ready.\n", - __func__, self->ioexp_id); - return 0; - } - } - /* Execute initial callback */ - return_val = self->init(self); - if (return_val < 0){ - self->state = STATE_IOEXP_ABNORMAL; - } else { - self->state = STATE_IOEXP_NORMAL; - } - return return_val; - - default: - break; - } - SWPS_ERR("%s: exception occur :%d\n", __func__, self->mode); - return ERR_IOEXP_UNEXCPT; -} - - -int -common_ioexp_fsm_4_direct(struct ioexp_obj_s *self){ - - int result_val; - int show_err = 1; - char *func_mane = "common_ioexp_fsm_4_direct"; - - switch (self->state){ - case STATE_IOEXP_INIT: - result_val = _ioexp_init_handler(self); - /* Exception case: terminate initial procedure */ - if(result_val < 0){ - /* Initial fail */ - return result_val; - } - if(self->state == STATE_IOEXP_INIT){ - /* Keep in INIT state, and return error */ - return ERR_IOEXP_UNINIT; - } - /* Case: Initial done */ - return 0; - - case STATE_IOEXP_NORMAL: - result_val = self->update_all(self, show_err, func_mane); - if (result_val < 0){ - SWPS_INFO("%s: NORMAL -> ABNORMAL :%d\n", - __func__, result_val); - self->state = STATE_IOEXP_ABNORMAL; - return result_val; - } - self->state = STATE_IOEXP_NORMAL; - return 0; - - case STATE_IOEXP_ABNORMAL: - result_val = self->update_all(self, show_err, func_mane); - if (result_val < 0){ - self->state = STATE_IOEXP_ABNORMAL; - return result_val; - } - SWPS_DEBUG("%s: ABNORMAL -> NORMAL :%d\n", - __func__, result_val); - self->state = STATE_IOEXP_NORMAL; - return 0; - - default: - break; - } - SWPS_ERR("%s: Exception occurs :%d\n", - __func__, self->state); - return ERR_IOEXP_UNEXCPT; -} - - -int -common_ioexp_fsm_4_polling(struct ioexp_obj_s *self){ - - int result_val, i, show_e; - int fail_retry = 3; - char *func_name = "common_ioexp_fsm_4_polling"; - -#ifdef DEBUG_SWPS - show_e = 1; -#else - show_e = 0; -#endif - - switch (self->state){ - case STATE_IOEXP_INIT: - result_val = _ioexp_init_handler(self); - /* Exception case: terminate initial procedure */ - if(result_val < 0){ - /* Initial fail */ - return result_val; - } - /* Case: System (Channel) not ready */ - if(self->state == STATE_IOEXP_INIT){ - /* Keep in INIT state, wait and retry */ - return 0; - } - /* Case: Initial done */ - SWPS_INFO("IOEXP-%d: initial done. :%d\n", - self->ioexp_id, self->ioexp_type); - return result_val; - - case STATE_IOEXP_NORMAL: - /* Retry mechanism for case of i2c topology not stable */ - for (i=0; iupdate_all(self, show_e, func_name); - if (result_val >= 0) { - self->state = STATE_IOEXP_NORMAL; - return 0; - } - if (check_channel_tier_1() < 0) { - SWPS_INFO("%s: detect I2C crash :%d\n", - __func__, self->ioexp_id); - break; - } - SWPS_DEBUG("IOEXP-%d: unstable :%d\n", - self->ioexp_id, result_val); - } - SWPS_INFO("IOEXP-%d: NORMAL -> ABNORMAL :%d\n", - self->ioexp_id, result_val); - self->state = STATE_IOEXP_ABNORMAL; - return result_val; - - case STATE_IOEXP_ABNORMAL: - result_val = self->update_all(self, show_e, func_name); - if (result_val < 0){ - self->state = STATE_IOEXP_ABNORMAL; - return result_val; - } - SWPS_INFO("IOEXP-%d: ABNORMAL -> NORMAL :%d\n", - self->ioexp_id, result_val); - self->state = STATE_IOEXP_NORMAL; - return 0; - - default: - break; - } - SWPS_ERR("IOEXP-%d: Exception occurs :%d\n", - self->ioexp_id, self->state); - return ERR_IOEXP_UNEXCPT; -} - - -/* ========== Object private functions for check & update ========== - */ -int -common_ioexp_check(struct ioexp_obj_s *self){ - - int result; - - if (self->mode != IOEXP_MODE_POLLING){ - SWPS_ERR("%s: not polling mode :%d\n", - __func__, self->mode); - return ERR_IOEXP_NOTSUPPORT; - } - mutex_lock(&self->lock); - result = self->fsm_4_polling(self); - mutex_unlock(&self->lock); - return result; -} - - -/* ========== Functions for Factory pattern ========== - */ -static struct ioexp_map_s * -get_ioexp_map(int ioexp_type){ - switch (ioexp_type){ - case IOEXP_TYPE_MAGINOLIA_NAB: - return &ioexp_map_magnolia_nab; - case IOEXP_TYPE_MAGINOLIA_4AB: - return &ioexp_map_magnolia_4ab; - case IOEXP_TYPE_MAGINOLIA_7AB: - case IOEXP_TYPE_SPRUCE_7AB: - return &ioexp_map_magnolia_7ab; - case IOEXP_TYPE_REDWOOD_P01P08: - return &ioexp_map_redwood_p01p08_p17p24; - case IOEXP_TYPE_REDWOOD_P09P16: - return &ioexp_map_redwood_p09p16_p25p32; - case IOEXP_TYPE_HUDSON32IGA_P01P08: - return &ioexp_map_hudson32iga_p01p08_p17p24; - case IOEXP_TYPE_HUDSON32IGA_P09P16: - return &ioexp_map_hudson32iga_p09p16_p25p32; - case IOEXP_TYPE_CYPRESS_NABC: - return &ioexp_map_cypress_nabc; - case IOEXP_TYPE_CYPRESS_7ABC: - return &ioexp_map_cypress_7abc; - case IOEXP_TYPE_TAHOE_5A: - return &ioexp_map_tahoe_5a; - case IOEXP_TYPE_TAHOE_6ABC: - return &ioexp_map_tahoe_6abc; - case IOEXP_TYPE_SEQUOIA_NABC: - return &ioexp_map_sequoia_nabc; - case IOEXP_TYPE_LAVENDER_P65: - return &ioexp_map_lavender_p65; - case CPLD_TYPE_COTTONWOOD: - return &cpld_map_cottonwood; - case IOEXP_TYPE_MAPLE_0ABC: - return &ioexp_map_maple_0abc; - case IOEXP_TYPE_MAPLE_NABC: - return &ioexp_map_maple_nabc; - default: - return NULL; - } -} - - -int -setup_ioexp_ssize_attr(struct ioexp_obj_s *self, - struct ioexp_map_s *ioexp_map_p, - int ioexp_id, - int ioexp_type, - int run_mode){ - switch (run_mode){ - case IOEXP_MODE_POLLING: /* Direct access device mode */ - case IOEXP_MODE_DIRECT: /* Polling mode, read from cache */ - self->mode = run_mode; - break; - default: - SWPS_ERR("%s: non-defined run_mode:%d\n", - __func__, run_mode); - self->mode = ERR_IOEXP_UNEXCPT; - return ERR_IOEXP_UNEXCPT; - } - /* Setup mapping structure */ - self->ioexp_map_p = kzalloc(sizeof(*ioexp_map_p), GFP_KERNEL); - if (!(self->ioexp_map_p)) { - SWPS_ERR("%s: kzalloc ioexp_map_p fail\n", __func__); - return -1; - } - memcpy(self->ioexp_map_p, ioexp_map_p, sizeof(*ioexp_map_p)); - /* Setup attributes */ - self->ioexp_id = ioexp_id; - self->ioexp_type = ioexp_type; - self->state = STATE_IOEXP_INIT; - mutex_init(&self->lock); - return 0; -} - - -static int -setup_addr_mapping(struct ioexp_obj_s *self, - struct ioexp_addr_s *addr_map_p, - int chip_amount){ - struct ioexp_addr_s *tmp_p; - if (!addr_map_p){ - SWPS_ERR("%s: map is null\n", __func__); - return -1; - } - tmp_p = kzalloc((sizeof(*addr_map_p) * chip_amount), GFP_KERNEL); - if (!tmp_p){ - SWPS_ERR("%s: kzalloc fail.\n", __func__); - return -1; - } - memcpy(tmp_p, addr_map_p, (sizeof(*addr_map_p) * chip_amount)); - self->ioexp_map_p->map_addr = tmp_p; - - return 0; -} - - -static int -setup_ioexp_public_cb(struct ioexp_obj_s *self, - int ioexp_type){ - - switch (ioexp_type){ - case IOEXP_TYPE_MAGINOLIA_NAB: - case IOEXP_TYPE_MAGINOLIA_4AB: - case CPLD_TYPE_COTTONWOOD: - self->get_present = common_get_present; - self->get_tx_fault = common_get_tx_fault; - self->get_rxlos = common_get_rxlos; - self->get_tx_disable = common_get_tx_disable; - self->get_reset = ioexp_get_not_support; - self->get_lpmod = ioexp_get_not_support; - self->get_modsel = ioexp_get_not_support; - self->get_hard_rs0 = ioexp_get_not_support; - self->get_hard_rs1 = ioexp_get_not_support; - self->set_tx_disable = common_set_tx_disable; - self->set_reset = ioexp_set_not_support; - self->set_lpmod = ioexp_set_not_support; - self->set_modsel = ioexp_set_not_support; - self->set_hard_rs0 = ioexp_set_not_support; - self->set_hard_rs1 = ioexp_set_not_support; - return 0; - case IOEXP_TYPE_CYPRESS_NABC: - case IOEXP_TYPE_MAPLE_NABC: - self->get_present = common_get_present; - self->get_tx_fault = common_get_tx_fault; - self->get_rxlos = common_get_rxlos; - self->get_tx_disable = common_get_tx_disable; - self->get_reset = ioexp_get_not_support; - self->get_lpmod = ioexp_get_not_support; - self->get_modsel = ioexp_get_not_support; - self->get_hard_rs0 = common_get_hard_rs0; - self->get_hard_rs1 = common_get_hard_rs1; - self->set_tx_disable = common_set_tx_disable; - self->set_reset = ioexp_set_not_support; - self->set_lpmod = ioexp_set_not_support; - self->set_modsel = ioexp_set_not_support; - self->set_hard_rs0 = common_set_hard_rs0; - self->set_hard_rs1 = common_set_hard_rs1; - return 0; - case IOEXP_TYPE_MAGINOLIA_7AB: - case IOEXP_TYPE_SPRUCE_7AB: - case IOEXP_TYPE_REDWOOD_P01P08: - case IOEXP_TYPE_REDWOOD_P09P16: - case IOEXP_TYPE_HUDSON32IGA_P01P08: - case IOEXP_TYPE_HUDSON32IGA_P09P16: - case IOEXP_TYPE_CYPRESS_7ABC: - case IOEXP_TYPE_TAHOE_5A: - case IOEXP_TYPE_TAHOE_6ABC: - case IOEXP_TYPE_SEQUOIA_NABC: - case IOEXP_TYPE_LAVENDER_P65: - case IOEXP_TYPE_MAPLE_0ABC: - self->get_present = common_get_present; - self->get_tx_fault = ioexp_get_not_support; - self->get_rxlos = ioexp_get_not_support; - self->get_tx_disable = ioexp_get_not_support; - self->get_reset = common_get_reset; - self->get_lpmod = common_get_lpmod; - self->get_modsel = common_get_modsel; - self->get_hard_rs0 = ioexp_get_not_support; - self->get_hard_rs1 = ioexp_get_not_support; - self->set_tx_disable = ioexp_set_not_support; - self->set_reset = common_set_reset; - self->set_lpmod = common_set_lpmod; - self->set_modsel = common_set_modsel; - self->set_hard_rs0 = ioexp_set_not_support; - self->set_hard_rs1 = ioexp_set_not_support; - return 0; - - default: - SWPS_ERR("%s: type:%d incorrect!\n", __func__, ioexp_type); - break; - } - return ERR_IOEXP_UNEXCPT; -} - - -static int -setup_ioexp_private_cb(struct ioexp_obj_s *self, - int ioexp_type){ - - switch (ioexp_type){ - case IOEXP_TYPE_MAGINOLIA_NAB: - case IOEXP_TYPE_MAGINOLIA_4AB: - case IOEXP_TYPE_MAGINOLIA_7AB: - case IOEXP_TYPE_SPRUCE_7AB: - case IOEXP_TYPE_REDWOOD_P01P08: - case IOEXP_TYPE_REDWOOD_P09P16: - case IOEXP_TYPE_HUDSON32IGA_P01P08: - case IOEXP_TYPE_HUDSON32IGA_P09P16: - case IOEXP_TYPE_CYPRESS_NABC: - case IOEXP_TYPE_CYPRESS_7ABC: - case IOEXP_TYPE_TAHOE_5A: - case IOEXP_TYPE_TAHOE_6ABC: - case IOEXP_TYPE_SEQUOIA_NABC: - case IOEXP_TYPE_LAVENDER_P65: - case CPLD_TYPE_COTTONWOOD: - case IOEXP_TYPE_MAPLE_NABC: - case IOEXP_TYPE_MAPLE_0ABC: - self->init = common_ioexp_init; - self->check = common_ioexp_check; - self->update_all = common_ioexp_update_all; - self->fsm_4_direct = common_ioexp_fsm_4_direct; - self->fsm_4_polling = common_ioexp_fsm_4_polling; - return 0; - - default: - SWPS_ERR("%s: type:%d incorrect!\n", __func__, ioexp_type); - break; - } - return ERR_IOEXP_UNEXCPT; -} - - -static int -setup_i2c_client_one(struct ioexp_obj_s *self, - int chip_id){ - - char *err_msg = "ERROR"; - struct i2c_adapter *adap = NULL; - struct i2c_client *client = NULL; - struct ioexp_i2c_s *i2c_obj_p = NULL; - struct ioexp_i2c_s *i2c_curr_p = NULL; - - int chan_id = self->ioexp_map_p->map_addr[chip_id].chan_id; - adap = i2c_get_adapter(chan_id); - if(!adap){ - err_msg = "Can not get adap!"; - goto err_ioexp_setup_i2c_1; - } - client = kzalloc(sizeof(*client), GFP_KERNEL); - if (!client){ - err_msg = "Can not kzalloc client!"; - goto err_ioexp_setup_i2c_1; - } - i2c_obj_p = kzalloc(sizeof(*i2c_obj_p), GFP_KERNEL); - if (!i2c_obj_p){ - err_msg = "Can not kzalloc i2c_obj_p!"; - goto err_ioexp_setup_i2c_2; - } - client->adapter = adap; - client->addr = self->ioexp_map_p->map_addr[chip_id].chip_addr; - i2c_obj_p->i2c_client_p = client; - i2c_obj_p->chip_id = chip_id; - i2c_obj_p->next = NULL; - if (!self->i2c_head_p){ - self->i2c_head_p = i2c_obj_p; - } else { - i2c_curr_p = self->i2c_head_p; - while (i2c_curr_p->next){ - i2c_curr_p = i2c_curr_p->next; - } - i2c_curr_p->next = i2c_obj_p; - } - return 0; - -err_ioexp_setup_i2c_2: - kfree(client); -err_ioexp_setup_i2c_1: - SWPS_ERR("%s: %s :%d\n", __func__, err_msg, chan_id); - return -1; -} - - -static int -setup_i2c_client(struct ioexp_obj_s* self){ - - int result; - int chip_id = 0; - - for (chip_id=0; chip_id<(self->ioexp_map_p->chip_amount); chip_id++){ - result = setup_i2c_client_one(self, chip_id); - if (result < 0){ - SWPS_ERR("%s fail! :%d\n", __func__, chip_id); - return -1; - } - } - return 0; -} - - -static int -setup_ioexp_config(struct ioexp_obj_s *self) { - - int chip_id, offset, err_code; - struct ioexp_addr_s *addr_p; - - for (chip_id=0; chip_id<(self->ioexp_map_p->chip_amount); chip_id++){ - addr_p = &(self->ioexp_map_p->map_addr[chip_id]); - if (!addr_p){ - SWPS_ERR("IOEXP config incorrect! :%d \n",chip_id); - return -1; - } - for (offset=0; offset<(self->ioexp_map_p->data_width); offset++){ - - /* [Desc] Skip the setup config value behavior - [Note] Setup config value = -1 if you don't want to write the value to IOEXP or CPLD - */ - if(addr_p->conf_offset[offset] < 0){ - SWPS_DEBUG("skip a config_offset <%d>\n", addr_p->conf_offset[offset]); - continue; - } - err_code = i2c_smbus_write_byte_data(_get_i2c_client(self, chip_id), - addr_p->conf_offset[offset], - addr_p->conf_default[offset]); - - if (err_code < 0){ - SWPS_INFO("%s: set conf fail! :%d \n", __func__, err_code); - return -2; - } - } - } - return 0; -} - - -struct ioexp_obj_s * -_create_ioexp_obj(int ioexp_id, - int ioexp_type, - struct ioexp_addr_s *addr_map_p, - int run_mode){ - - struct ioexp_map_s* ioexp_map_p; - struct ioexp_obj_s* result_p; - struct ioexp_i2c_s *i2c_curr_p; - struct ioexp_i2c_s *i2c_next_p; - - /* Get layout */ - ioexp_map_p = get_ioexp_map(ioexp_type); - if (!ioexp_map_p){ - SWPS_ERR("%s: Invalid ioexp_type\n", __func__); - goto err_create_ioexp_fail; - } - /* Prepare IOEXP object */ - result_p = kzalloc(sizeof(*result_p), GFP_KERNEL); - if (!result_p){ - SWPS_ERR("%s: kzalloc failure!\n", __func__); - goto err_create_ioexp_fail; - } - /* Prepare static size attributes */ - if (setup_ioexp_ssize_attr(result_p, - ioexp_map_p, - ioexp_id, - ioexp_type, - run_mode) < 0){ - goto err_create_ioexp_setup_attr_fail; - } - /* Prepare address mapping */ - if (setup_addr_mapping(result_p, addr_map_p, ioexp_map_p->chip_amount) < 0){ - goto err_create_ioexp_setup_attr_fail; - } - if (setup_i2c_client(result_p) < 0){ - goto err_create_ioexp_setup_i2c_fail; - } - /* Prepare call back functions of object */ - if (setup_ioexp_public_cb(result_p, ioexp_type) < 0){ - goto err_create_ioexp_setup_i2c_fail; - } - if (setup_ioexp_private_cb(result_p, ioexp_type) < 0){ - goto err_create_ioexp_setup_i2c_fail; - } - return result_p; - -err_create_ioexp_setup_i2c_fail: - i2c_curr_p = result_p->i2c_head_p; - i2c_next_p = result_p->i2c_head_p; - while (i2c_curr_p){ - i2c_next_p = i2c_curr_p->next; - kfree(i2c_curr_p->i2c_client_p); - kfree(i2c_curr_p); - i2c_curr_p = i2c_next_p; - } -err_create_ioexp_setup_attr_fail: - kfree(result_p); -err_create_ioexp_fail: - SWPS_ERR("%s: fail! :%d :%d \n", - __func__, ioexp_id, ioexp_type); - return NULL; -} - - -int -create_ioexp_obj(int ioexp_id, - int ioexp_type, - struct ioexp_addr_s *addr_map_p, - int run_mode){ - - struct ioexp_obj_s *ioexp_p = NULL; - - ioexp_p = _create_ioexp_obj(ioexp_id, ioexp_type, - addr_map_p, run_mode); - if (!ioexp_p){ - return -1; - } - if (ioexp_head_p == NULL){ - ioexp_head_p = ioexp_p; - ioexp_tail_p = ioexp_p; - return 0; - } - ioexp_tail_p->next = ioexp_p; - ioexp_tail_p = ioexp_p; - return 0; -} - - -static int -_init_ioexp_obj(struct ioexp_obj_s* self) { - - char *err_msg = "ERR"; - char *func_name = "_init_ioexp_obj"; - - /* Setup IOEXP configure byte */ - if (setup_ioexp_config(self) < 0){ - err_msg = "setup_ioexp_config fail"; - goto err_init_ioexp_obj; - } - /* Setup default data */ - if (_ioexp_init_handler(self) < 0){ - err_msg = "_ioexp_init_handler fail"; - goto err_init_ioexp_obj; - } - /* Update all */ - if (self->state == STATE_IOEXP_NORMAL){ - if (self->update_all(self, 1, func_name) < 0){ - err_msg = "update_all() fail"; - goto err_init_ioexp_obj; - } - } - return 0; - -err_init_ioexp_obj: - SWPS_DEBUG("%s: %s\n", __func__, err_msg); - return -1; -} - - -int -init_ioexp_objs(void){ - /* Return value: - * 0: Success - * -1: Detect topology error - * -2: SWPS internal error - */ - - struct ioexp_obj_s *curr_p = ioexp_head_p; - - if (!curr_p) { - SWPS_ERR("%s: ioexp_head_p is NULL\n", __func__); - return -2; - } - while (curr_p) { - if (_init_ioexp_obj(curr_p) < 0) { - SWPS_DEBUG("%s: _init_ioexp_obj() fail\n", __func__); - return -1; - } - curr_p = curr_p->next; - } - SWPS_DEBUG("%s: done.\n", __func__); - return 0; -} - - -void -clean_ioexp_objs(void){ - - struct ioexp_i2c_s *i2c_curr_p = NULL; - struct ioexp_i2c_s *i2c_next_p = NULL; - struct ioexp_obj_s *ioexp_next_p = NULL; - struct ioexp_obj_s *ioexp_curr_p = ioexp_head_p; - - if (ioexp_head_p == NULL){ - ioexp_tail_p = NULL; - return; - } - while(ioexp_curr_p){ - ioexp_next_p = ioexp_curr_p->next; - if (ioexp_curr_p->ioexp_map_p) { - if (ioexp_curr_p->ioexp_map_p->map_addr) { - kfree(ioexp_curr_p->ioexp_map_p->map_addr); - } - kfree(ioexp_curr_p->ioexp_map_p); - } - - i2c_curr_p = ioexp_curr_p->i2c_head_p; - while (i2c_curr_p) { - i2c_next_p = i2c_curr_p->next; - kfree(i2c_curr_p->i2c_client_p); - kfree(i2c_curr_p); - i2c_curr_p = i2c_next_p; - } - kfree(ioexp_curr_p); - ioexp_curr_p = ioexp_next_p; - } - ioexp_tail_p = NULL; - SWPS_DEBUG("%s: done.\n", __func__); -} - - -int -check_ioexp_objs(void){ - - struct ioexp_obj_s *ioexp_curr_p = ioexp_head_p; - - while (ioexp_curr_p){ - if ( (ioexp_curr_p->check(ioexp_curr_p)) < 0){ - SWPS_INFO("check IOEXP-%d fail! :%d\n", - ioexp_curr_p->ioexp_id, ioexp_curr_p->ioexp_type); - return -1; - } - ioexp_curr_p = ioexp_curr_p->next; - } - return 0; -} - - -struct ioexp_obj_s * -get_ioexp_obj(int ioexp_id){ - - struct ioexp_obj_s *result_p = NULL; - struct ioexp_obj_s *ioexp_curr_p = ioexp_head_p; - - while(ioexp_curr_p){ - if (ioexp_curr_p->ioexp_id == ioexp_id){ - result_p = ioexp_curr_p; - break; - } - ioexp_curr_p = ioexp_curr_p->next; - } - return result_p; -} - - -void -unlock_ioexp_all(void) { - - struct ioexp_obj_s *ioexp_curr_p = ioexp_head_p; - - while(ioexp_curr_p){ - mutex_unlock(&ioexp_curr_p->lock); - ioexp_curr_p = ioexp_curr_p->next; - } -} - - -int -lock_ioexp_all(void) { - - struct ioexp_obj_s *ioexp_curr_p = ioexp_head_p; - - while(ioexp_curr_p){ - mutex_lock(&ioexp_curr_p->lock); - ioexp_curr_p = ioexp_curr_p->next; - } - return 0; -} - - -int -check_channel_tier_1(void) { - - if ( (!_is_channel_ready(ioexp_head_p)) && - (!_is_channel_ready(ioexp_tail_p)) ){ - return -1; - } - return 0; -} - - -static int -_scan_channel_tier_1(int force, - int show_err) { - - struct ioexp_obj_s *ioexp_curr_p = ioexp_head_p; - int ready = 0; - - if (!ioexp_curr_p) { - goto err_scan_tier_1_channel; - } - while(ioexp_curr_p) { - ready = _is_channel_ready(ioexp_curr_p); - if ((!ready) && (!force)) { - goto err_scan_tier_1_channel; - } - ioexp_curr_p = ioexp_curr_p->next; - } - return 0; - -err_scan_tier_1_channel: - if (show_err) { - if (ioexp_curr_p) { - SWPS_INFO("%s: IOEXP-%d fail\n", __func__, ioexp_curr_p->ioexp_id); - } else { - SWPS_INFO("%s: IOEXP is null.\n", __func__); - } - } - return -1; -} - - -static int -_scan_channel_tier_1_single(void) { - - int ret = 0; - int chan_id = 0; - int fake_cid = 0; - int fake_offs = 0; - int fake_addr = 0; - struct i2c_adapter *adap = NULL; - struct i2c_client *client = NULL; - - if (ioexp_head_p->ioexp_id != ioexp_tail_p->ioexp_id) { - return 0; - } - /* Setup i2c_client */ - chan_id = ioexp_head_p->ioexp_map_p->map_addr[fake_cid].chan_id; - fake_addr = ioexp_head_p->ioexp_map_p->map_addr[fake_cid].chip_addr; - adap = i2c_get_adapter((chan_id + 1)); - if(!adap){ - SWPS_INFO("%s: Can not get adap!\n", __func__); - return 0; - } - client = kzalloc(sizeof(*client), GFP_KERNEL); - if (!client){ - SWPS_INFO("%s: Can not kzalloc client!\n", __func__); - return 0; - } - client->adapter = adap; - client->addr = fake_addr; - /* Fouce move ioexp ptr to next */ - ret = i2c_smbus_read_byte_data(client, fake_offs); - SWPS_DEBUG("%s: move ioexp_ptr done. :%d\n", __func__, ret); - kfree(client); - return 1; -} - - -int -resync_channel_tier_1(void) { - - char *emsg = "ERR"; - - if (!ioexp_head_p) { - emsg = "ioexp_head_p is NULL"; - goto err_resync_ioexp_status_1; - } - /* Run all */ - if (ioexp_head_p->ioexp_id == ioexp_tail_p->ioexp_id) { - _scan_channel_tier_1_single(); - } else { - _scan_channel_tier_1(1, 0); - } - /* Check all */ - if (_scan_channel_tier_1(0, 1) < 0) { - emsg = "resync tier-1 channel fail"; - goto err_resync_ioexp_status_1; - } - return 0; - -err_resync_ioexp_status_1: - SWPS_ERR("%s: %s\n", __func__, emsg); - return -1; -} - - - - - - - diff --git a/packages/platforms/inventec/x86-64/d6556/modules/builds/src/io_expander.h b/packages/platforms/inventec/x86-64/d6556/modules/builds/src/io_expander.h deleted file mode 100644 index 810b730dc..000000000 --- a/packages/platforms/inventec/x86-64/d6556/modules/builds/src/io_expander.h +++ /dev/null @@ -1,180 +0,0 @@ -#ifndef IO_EXPANDER_H -#define IO_EXPANDER_H - -#include - - -/* IOEXP type define (SFP series) */ -#define IOEXP_TYPE_MAGINOLIA_NAB (10101) -#define IOEXP_TYPE_MAGINOLIA_4AB (10102) -#define IOEXP_TYPE_CYPRESS_NABC (10103) -#define IOEXP_TYPE_MAPLE_NABC (10104) - -/* IOEXP type define (QSFP series) */ -#define IOEXP_TYPE_MAGINOLIA_7AB (10201) -#define IOEXP_TYPE_REDWOOD_P01P08 (10202) -#define IOEXP_TYPE_REDWOOD_P09P16 (10203) -#define IOEXP_TYPE_HUDSON32IGA_P01P08 (10204) -#define IOEXP_TYPE_HUDSON32IGA_P09P16 (10205) -#define IOEXP_TYPE_SPRUCE_7AB (10206) -#define IOEXP_TYPE_CYPRESS_7ABC (10207) -#define IOEXP_TYPE_TAHOE_5A (10208) -#define IOEXP_TYPE_TAHOE_6ABC (10209) -#define IOEXP_TYPE_SEQUOIA_NABC (10210) -#define IOEXP_TYPE_LAVENDER_P65 (10211) -#define IOEXP_TYPE_MAPLE_0ABC (10212) - -/* CPLD type define */ -#define CPLD_TYPE_COTTONWOOD (10301) - -/* IOEXP mode define */ -#define IOEXP_MODE_POLLING (19000) -#define IOEXP_MODE_DIRECT (19001) - -/* IOEXP state define */ -#define STATE_IOEXP_NORMAL (0) -#define STATE_IOEXP_INIT (-1) -#define STATE_IOEXP_ABNORMAL (-2) - -/* IOEXP error code define */ -#define ERR_IOEXP_NOTSUPPORT (-100) -#define ERR_IOEXP_UNINIT (-101) -#define ERR_IOEXP_BADCONF (-102) -#define ERR_IOEXP_ABNORMAL (-103) -#define ERR_IOEXP_NOSTATE (-104) -#define ERR_IOEXP_BADINPUT (-105) -#define ERR_IOEXP_UNEXCPT (-199) - -#define SWPS_INFO(fmt, args...) printk( KERN_INFO "[SWPS] " fmt, ##args) -#define SWPS_WARN(fmt, args...) printk( KERN_WARNING "[SWPS] " fmt, ##args) -#define SWPS_ERR(fmt, args...) printk( KERN_ERR "[SWPS] " fmt, ##args) - -#ifdef DEBUG_SWPS -# define SWPS_DEBUG(fmt, args...) printk( KERN_DEBUG "[SWPS] " fmt, ##args) -#else -# define SWPS_DEBUG(fmt, args...) -#endif - - -struct ioexp_addr_s { - int chan_id; - int chip_addr; - int read_offset[8]; - int write_offset[8]; - int conf_offset[8]; - uint8_t data_default[8]; - uint8_t conf_default[8]; -}; - -struct ioexp_i2c_s { - int chip_id; - struct i2c_client *i2c_client_p; - struct ioexp_i2c_s *next; -}; - - -struct ioexp_bitmap_s { - int chip_id; /* IOEXP chip id */ - int ioexp_voffset; /* IOEXP virtual offset */ - int bit_shift; -}; - -struct ioexp_map_s { - int chip_amount; /* Number of chips that IOEXP object content */ - int data_width; /* Number of (Read/Write/Config) bytes */ - struct ioexp_addr_s *map_addr; /* Chip address info */ - struct ioexp_bitmap_s map_present[10]; /* IOEXP for SFP / QSFP */ - struct ioexp_bitmap_s map_tx_disable[10]; /* IOEXP for SFP */ - struct ioexp_bitmap_s map_tx_fault[10]; /* IOEXP for SFP */ - struct ioexp_bitmap_s map_rxlos[10]; /* IOEXP for SFP */ - struct ioexp_bitmap_s map_reset[10]; /* IOEXP for QSFP */ - struct ioexp_bitmap_s map_lpmod[10]; /* IOEXP for QSFP */ - struct ioexp_bitmap_s map_modsel[10]; /* IOEXP for QSFP */ - struct ioexp_bitmap_s map_hard_rs0[10]; /* IOEXP for QSFP */ - struct ioexp_bitmap_s map_hard_rs1[10]; /* IOEXP for QSFP */ -}; - -struct ioexp_data_s { - uint8_t data[8]; -}; - -struct ioexp_obj_s { - - /* ============================ - * Object public property - * ============================ - */ - int ioexp_id; - int ioexp_type; - - /* ============================ - * Object private property - * ============================ - */ - struct ioexp_data_s chip_data[16]; /* Max: 8-ioexp in one virt-ioexp(ioexp_obj) */ - struct ioexp_map_s *ioexp_map_p; - struct ioexp_obj_s *next; - struct ioexp_i2c_s *i2c_head_p; - struct mutex lock; - int mode; - int state; - - /* =========================================== - * Object public functions - * =========================================== - */ - int (*get_present)(struct ioexp_obj_s *self, int virt_offset); - int (*get_tx_fault)(struct ioexp_obj_s *self, int virt_offset); - int (*get_rxlos)(struct ioexp_obj_s *self, int virt_offset); - int (*get_tx_disable)(struct ioexp_obj_s *self, int virt_offset); - int (*get_reset)(struct ioexp_obj_s *self, int virt_offset); - int (*get_lpmod)(struct ioexp_obj_s *self, int virt_offset); - int (*get_modsel)(struct ioexp_obj_s *self, int virt_offset); - int (*get_hard_rs0)(struct ioexp_obj_s *self, int virt_offset); - int (*get_hard_rs1)(struct ioexp_obj_s *self, int virt_offset); - int (*set_tx_disable)(struct ioexp_obj_s *self, int virt_offset, int input_val); - int (*set_reset)(struct ioexp_obj_s *self, int virt_offset, int input_val); - int (*set_lpmod)(struct ioexp_obj_s *self, int virt_offset, int input_val); - int (*set_modsel)(struct ioexp_obj_s *self, int virt_offset, int input_val); - int (*set_hard_rs0)(struct ioexp_obj_s *self, int virt_offset, int input_val); - int (*set_hard_rs1)(struct ioexp_obj_s *self, int virt_offset, int input_val); - - /* =========================================== - * Object private functions - * =========================================== - */ - int (*init)(struct ioexp_obj_s *self); - int (*check)(struct ioexp_obj_s *self); - int (*update_all)(struct ioexp_obj_s *self, int show_err, char *caller_name); - int (*fsm_4_direct)(struct ioexp_obj_s* self); - int (*fsm_4_polling)(struct ioexp_obj_s* self); -}; - - -struct ioexp_obj_s* get_ioexp_obj(int ioexp_id); -int create_ioexp_obj(int ioexp_id, - int ioexp_type, - struct ioexp_addr_s *addr_map_p, - int run_mode); -int init_ioexp_objs(void); -int check_ioexp_objs(void); -void clean_ioexp_objs(void); - -void unlock_ioexp_all(void); -int lock_ioexp_all(void); - -int check_channel_tier_1(void); -int resync_channel_tier_1(void); - -/* Macro for bit control */ -#define SWP_BIT_SET(byte_val,bit_shift) ((byte_val) |= (1<<(bit_shift))) -#define SWP_BIT_CLEAR(byte_val,bit_shift) ((byte_val) &= ~(1<<(bit_shift))) - - -#endif /* IO_EXPANDER_H */ - - - - - - diff --git a/packages/platforms/inventec/x86-64/d6556/modules/builds/src/onie_tlvinfo.c b/packages/platforms/inventec/x86-64/d6556/modules/builds/src/onie_tlvinfo.c deleted file mode 100644 index aaa3d5070..000000000 --- a/packages/platforms/inventec/x86-64/d6556/modules/builds/src/onie_tlvinfo.c +++ /dev/null @@ -1,815 +0,0 @@ -#include -#include -#include -#include -//#include -#include - -//#include -//#include -#include "onie_tlvinfo.h" - -/* Set to 1 if we've read EEPROM into memory */ -static int has_been_read = 0; - -int read_sys_eeprom(struct i2c_client *pi2c_client,void *eeprom_data, int offset, int len); -int write_sys_eeprom(struct i2c_client *pi2c_client, void *eeprom_data, int len); - -static inline int is_multicast_ether_addr(const u_int8_t *addr) -{ - return 0x01 & addr[0]; -} - -static inline int is_zero_ether_addr(const u_int8_t *addr) -{ - return !(addr[0] | addr[1] | addr[2] | addr[3] | addr[4] | addr[5]); -} - -static inline int is_valid_ether_addr(const u_int8_t *addr) -{ - return !is_multicast_ether_addr(addr) && !is_zero_ether_addr(addr); -} - -#if 0 -static unsigned int crc32(unsigned char const *p, unsigned int len) -{ - int i; - unsigned int crc = 0; - while (len--) { - crc ^= *p++; - for (i = 0; i < 8; i++) - crc = (crc >> 1) ^ ((crc & 1) ? 0xedb88320 : 0); - } - return crc; -} -#else -static unsigned long crc32_tab[] = { - 0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f, - 0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988, - 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91, 0x1db71064, 0x6ab020f2, - 0xf3b97148, 0x84be41de, 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7, - 0x136c9856, 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, 0x14015c4f, 0x63066cd9, - 0xfa0f3d63, 0x8d080df5, 0x3b6e20c8, 0x4c69105e, 0xd56041e4, 0xa2677172, - 0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b, 0x35b5a8fa, 0x42b2986c, - 0xdbbbc9d6, 0xacbcf940, 0x32d86ce3, 0x45df5c75, 0xdcd60dcf, 0xabd13d59, - 0x26d930ac, 0x51de003a, 0xc8d75180, 0xbfd06116, 0x21b4f4b5, 0x56b3c423, - 0xcfba9599, 0xb8bda50f, 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924, - 0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d, 0x76dc4190, 0x01db7106, - 0x98d220bc, 0xefd5102a, 0x71b18589, 0x06b6b51f, 0x9fbfe4a5, 0xe8b8d433, - 0x7807c9a2, 0x0f00f934, 0x9609a88e, 0xe10e9818, 0x7f6a0dbb, 0x086d3d2d, - 0x91646c97, 0xe6635c01, 0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e, - 0x6c0695ed, 0x1b01a57b, 0x8208f4c1, 0xf50fc457, 0x65b0d9c6, 0x12b7e950, - 0x8bbeb8ea, 0xfcb9887c, 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, 0xfbd44c65, - 0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2, 0x4adfa541, 0x3dd895d7, - 0xa4d1c46d, 0xd3d6f4fb, 0x4369e96a, 0x346ed9fc, 0xad678846, 0xda60b8d0, - 0x44042d73, 0x33031de5, 0xaa0a4c5f, 0xdd0d7cc9, 0x5005713c, 0x270241aa, - 0xbe0b1010, 0xc90c2086, 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f, - 0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, 0x59b33d17, 0x2eb40d81, - 0xb7bd5c3b, 0xc0ba6cad, 0xedb88320, 0x9abfb3b6, 0x03b6e20c, 0x74b1d29a, - 0xead54739, 0x9dd277af, 0x04db2615, 0x73dc1683, 0xe3630b12, 0x94643b84, - 0x0d6d6a3e, 0x7a6a5aa8, 0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1, - 0xf00f9344, 0x8708a3d2, 0x1e01f268, 0x6906c2fe, 0xf762575d, 0x806567cb, - 0x196c3671, 0x6e6b06e7, 0xfed41b76, 0x89d32be0, 0x10da7a5a, 0x67dd4acc, - 0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5, 0xd6d6a3e8, 0xa1d1937e, - 0x38d8c2c4, 0x4fdff252, 0xd1bb67f1, 0xa6bc5767, 0x3fb506dd, 0x48b2364b, - 0xd80d2bda, 0xaf0a1b4c, 0x36034af6, 0x41047a60, 0xdf60efc3, 0xa867df55, - 0x316e8eef, 0x4669be79, 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236, - 0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f, 0xc5ba3bbe, 0xb2bd0b28, - 0x2bb45a92, 0x5cb36a04, 0xc2d7ffa7, 0xb5d0cf31, 0x2cd99e8b, 0x5bdeae1d, - 0x9b64c2b0, 0xec63f226, 0x756aa39c, 0x026d930a, 0x9c0906a9, 0xeb0e363f, - 0x72076785, 0x05005713, 0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38, - 0x92d28e9b, 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21, 0x86d3d2d4, 0xf1d4e242, - 0x68ddb3f8, 0x1fda836e, 0x81be16cd, 0xf6b9265b, 0x6fb077e1, 0x18b74777, - 0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c, 0x8f659eff, 0xf862ae69, - 0x616bffd3, 0x166ccf45, 0xa00ae278, 0xd70dd2ee, 0x4e048354, 0x3903b3c2, - 0xa7672661, 0xd06016f7, 0x4969474d, 0x3e6e77db, 0xaed16a4a, 0xd9d65adc, - 0x40df0b66, 0x37d83bf0, 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9, - 0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605, 0xcdd70693, - 0x54de5729, 0x23d967bf, 0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94, - 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d -}; - -static unsigned long crc32(unsigned char const *buf, unsigned int size) -{ - unsigned char *p = (unsigned char*)buf; - unsigned long crc = 0; - - crc = crc ^ ~0U; - - while (size--) - crc = crc32_tab[(crc ^ *p++) & 0xFF] ^ (crc >> 8); - - return crc ^ ~0U; -} -#endif - -static int set_bytes(char *buf, const char *string, int * converted_accum) -{ - char *p = (char *) string; - int i; - uint byte; - - if (!p) { - printk("ERROR: NULL string passed in.\n"); - return -1; - } - /* Convert string to bytes */ - for (i = 0, p = (char *)string; (i < TLV_VALUE_MAX_LEN) && (*p != 0); - i++) { - while ((*p == ' ') || (*p == '\t') || (*p == ',') || - (*p == ';')) { - p++; - } - if (*p != 0) { - if (!isdigit(*p)) { - printk("ERROR: Non-digit found in byte string: (%s)\n", string); - return -1; - } - byte = strtoul(p, &p, 0); - if (byte >= 256) { - printk("ERROR: The value specified is greater than 255: (%u) " \ - "in string: %s\n", byte, string); - return -1; - } - buf[i] = byte & 0xFF; - } - } - if ((i == TLV_VALUE_MAX_LEN) && (*p != 0)) { - printk("ERROR: Trying to assign too many bytes " - "(max: %d) in string: %s\n", TLV_VALUE_MAX_LEN, string); - return -1; - } - *converted_accum = i; - return 0; -} - -/* - * set_date - * - * Validates the format of the data string - * - * This function takes a pointer to a date string (i.e. MM/DD/YYYY hh:mm:ss) - * and validates that the format is correct. If so the string is copied - * to the supplied buffer. - */ -static int set_date(char *buf, const char *string) -{ - int i; - - if (!string) { - printk("ERROR: NULL date string passed in.\n"); - return -1; - } - if (strlen(string) != 19) { - printk("ERROR: Date strlen() != 19 -- %zd\n", strlen(string)); - printk("ERROR: Bad date format (MM/DD/YYYY hh:mm:ss): %s\n", string); - return -1; - } - for (i = 0; string[i] != 0; i++) { - switch (i) { - case 2: - case 5: - if (string[i] != '/') { - printk("ERROR: Bad date format (MM/DD/YYYY hh:mm:ss): %s\n", - string); - return -1; - } - break; - case 10: - if (string[i] != ' ') { - printk("ERROR: Bad date format (MM/DD/YYYY hh:mm:ss): %s\n", - string); - return -1; - } - break; - case 13: - case 16: - if (string[i] != ':') { - printk("ERROR: Bad date format (MM/DD/YYYY hh:mm:ss): %s\n", - string); - return -1; - } - break; - default: - if (!isdigit(string[i])) { - printk("ERROR: Bad date format (MM/DD/YYYY hh:mm:ss): %s\n", - string); - return -1; - } - break; - } - } - strcpy(buf, string); - return 0; -} - -/* - * is_valid_tlv - * - * Perform basic sanity checks on a TLV field. The TLV is pointed to - * by the parameter provided. - * 1. The type code is not reserved (0x00 or 0xFF) - */ -static inline bool is_valid_tlv(tlvinfo_tlv_t *tlv) -{ - return((tlv->type != 0x00) && (tlv->type != 0xFF)); -} - -/* - * set_mac - * - * Converts a string MAC address into a binary buffer. - * - * This function takes a pointer to a MAC address string - * (i.e."XX:XX:XX:XX:XX:XX", where "XX" is a two-digit hex number). - * The string format is verified and then converted to binary and - * stored in a buffer. - */ -static int set_mac(char *buf, const char *string) -{ - char *p = (char *) string; - int i; - int err = 0; - char *end; - - if (!p) { - printk("ERROR: NULL mac addr string passed in.\n"); - return -1; - } - if (strlen(p) != 17) { - printk("ERROR: MAC address strlen() != 17 -- %zd\n", strlen(p)); - printk("ERROR: Bad MAC address format: %s\n", string); - return -1; - } - for (i = 0; i < 17; i++) { - if ((i % 3) == 2) { - if (p[i] != ':') { - err++; - printk("ERROR: mac: p[%i] != :, found: `%c'\n", - i, p[i]); - break; - } - continue; - } else if (!isxdigit(p[i])) { - err++; - printk("ERROR: mac: p[%i] != hex digit, found: `%c'\n", - i, p[i]); - break; - } - } - if (err != 0) { - printk("ERROR: Bad MAC address format: %s\n", string); - return -1; - } - /* Convert string to binary */ - for (i = 0, p = (char *)string; i < 6; i++) { - buf[i] = p ? strtoul(p, &end, 16) : 0; - if (p) { - p = (*end) ? end + 1 : end; - } - } - if (!is_valid_ether_addr((char *)buf)) { - printk("ERROR: MAC address must not be 00:00:00:00:00:00, " - "a multicast address or FF:FF:FF:FF:FF:FF.\n"); - printk("ERROR: Bad MAC address format: %s\n", string); - return -1; - } - return 0; -} - -/* - * is_valid_tlvinfo_header - * - * Perform sanity checks on the first 11 bytes of the TlvInfo EEPROM - * data pointed to by the parameter: - * 1. First 8 bytes contain null-terminated ASCII string "TlvInfo" - * 2. Version byte is 1 - * 3. Total length bytes contain value which is less than or equal - * to the allowed maximum (2048-11) - * - */ -static inline bool is_valid_tlvinfo_header(tlvinfo_header_t *hdr) -{ - int max_size = TLV_TOTAL_LEN_MAX; - return((strcmp(hdr->signature, TLV_INFO_ID_STRING) == 0) && - (hdr->version == TLV_INFO_VERSION) && - (be16_to_cpu(hdr->totallen) <= max_size) ); -} - -/* - * decode_tlv_value - * - * Decode a single TLV value into a string. - - * The validity of EEPROM contents and the TLV field have been verified - * prior to calling this function. - */ -#define DECODE_NAME_MAX 20 - -static void decode_tlv_value(tlvinfo_tlv_t * tlv, char* value) -{ - int i; - - switch (tlv->type) { - case TLV_CODE_PRODUCT_NAME: - case TLV_CODE_PART_NUMBER: - case TLV_CODE_SERIAL_NUMBER: - case TLV_CODE_MANUF_DATE: - case TLV_CODE_LABEL_REVISION: - case TLV_CODE_PLATFORM_NAME: - case TLV_CODE_ONIE_VERSION: - case TLV_CODE_MANUF_NAME: - case TLV_CODE_MANUF_COUNTRY: - case TLV_CODE_VENDOR_NAME: - case TLV_CODE_DIAG_VERSION: - case TLV_CODE_SERVICE_TAG: - memcpy(value, tlv->value, tlv->length); - value[tlv->length] = 0; - break; - case TLV_CODE_MAC_BASE: - snprintf(value, MAX_STRING_SIZE, "%02X:%02X:%02X:%02X:%02X:%02X", - tlv->value[0], tlv->value[1], tlv->value[2], - tlv->value[3], tlv->value[4], tlv->value[5]); - break; - case TLV_CODE_DEVICE_VERSION: - snprintf(value, MAX_STRING_SIZE, "%u", tlv->value[0]); - break; - case TLV_CODE_MAC_SIZE: - snprintf(value, MAX_STRING_SIZE, "%u", (tlv->value[0] << 8) | tlv->value[1]); - break; - case TLV_CODE_VENDOR_EXT: - value[0] = 0; - for (i = 0; (i < (TLV_DECODE_VALUE_MAX_LEN/5)) && (i < tlv->length); - i++) { - snprintf(value, MAX_STRING_SIZE, "%s 0x%02X", value, tlv->value[i]); - } - break; - case TLV_CODE_CRC_32: - snprintf(value, MAX_STRING_SIZE, "0x%02X%02X%02X%02X", - tlv->value[0], tlv->value[1], tlv->value[2], - tlv->value[3]); - break; - default: - value[0] = 0; - for (i = 0; (i < (TLV_DECODE_VALUE_MAX_LEN/5)) && (i < tlv->length); - i++) { - snprintf(value, MAX_STRING_SIZE, "%s 0x%02X", value, tlv->value[i]); - } - break; - } - -} - -/* - * is_checksum_valid - * - * Validate the checksum in the provided TlvInfo EEPROM data. First, - * verify that the TlvInfo header is valid, then make sure the last - * TLV is a CRC-32 TLV. Then calculate the CRC over the EEPROM data - * and compare it to the value stored in the EEPROM CRC-32 TLV. - */ -static bool is_checksum_valid(u_int8_t *eeprom) -{ - tlvinfo_header_t * eeprom_hdr = (tlvinfo_header_t *) eeprom; - tlvinfo_tlv_t * eeprom_crc; - unsigned int calc_crc; - unsigned int stored_crc; - - // Is the eeprom header valid? - if (!is_valid_tlvinfo_header(eeprom_hdr)) { - return(FALSE); - } - - // Is the last TLV a CRC? - eeprom_crc = (tlvinfo_tlv_t *) &eeprom[sizeof(tlvinfo_header_t) + - be16_to_cpu(eeprom_hdr->totallen) - - (sizeof(tlvinfo_tlv_t) + 4)]; - if ((eeprom_crc->type != TLV_CODE_CRC_32) || (eeprom_crc->length != 4)) { - return(FALSE); - } - - // Calculate the checksum - calc_crc = crc32((void *)eeprom, sizeof(tlvinfo_header_t) + - be16_to_cpu(eeprom_hdr->totallen) - 4); - stored_crc = ((eeprom_crc->value[0] << 24) | (eeprom_crc->value[1] << 16) | - (eeprom_crc->value[2] << 8) | eeprom_crc->value[3]); - - //printk(KERN_ERR "[SWPS] cal_crc =0x%x, stored_crc =0x%x\n", calc_crc, stored_crc); - //return(calc_crc == stored_crc); - return 1; -} - -/* - * update_crc - * - * This function updates the CRC-32 TLV. If there is no CRC-32 TLV, then - * one is added. This function should be called after each update to the - * EEPROM structure, to make sure the CRC is always correct. - */ -static void update_crc(u_int8_t *eeprom) -{ - tlvinfo_header_t * eeprom_hdr = (tlvinfo_header_t *) eeprom; - tlvinfo_tlv_t * eeprom_crc; - unsigned int calc_crc; - - // Is the eeprom header valid? - if (!is_valid_tlvinfo_header(eeprom_hdr)) { - return; - } - // Is the last TLV a CRC? - eeprom_crc = (tlvinfo_tlv_t *) &eeprom[sizeof(tlvinfo_header_t) + - be16_to_cpu(eeprom_hdr->totallen) - - (sizeof(tlvinfo_tlv_t) + 4)]; - if (eeprom_crc->type != TLV_CODE_CRC_32) { - if ((be16_to_cpu(eeprom_hdr->totallen) + sizeof(tlvinfo_tlv_t) + 4) > - TLV_TOTAL_LEN_MAX) { - return; - } - eeprom_crc = (tlvinfo_tlv_t *) &eeprom[sizeof(tlvinfo_header_t) + - be16_to_cpu( - eeprom_hdr->totallen)]; - eeprom_hdr->totallen = cpu_to_be16(be16_to_cpu(eeprom_hdr->totallen) + - sizeof(tlvinfo_tlv_t) + 4); - eeprom_crc->type = TLV_CODE_CRC_32; - } - eeprom_crc->length = 4; - - // Calculate the checksum - calc_crc = crc32((void *)eeprom, - sizeof(tlvinfo_header_t) + - be16_to_cpu(eeprom_hdr->totallen) - 4); - - eeprom_crc->value[0] = (calc_crc >> 24) & 0xFF; - eeprom_crc->value[1] = (calc_crc >> 16) & 0xFF; - eeprom_crc->value[2] = (calc_crc >> 8) & 0xFF; - eeprom_crc->value[3] = (calc_crc >> 0) & 0xFF; -} - -/* - * show_eeprom - * - * Display the contents of the EEPROM - */ - -/* - * read_eeprom - * - * Read the EEPROM into memory, if it hasn't already been read. - */ -int read_eeprom( struct i2c_client *pi2c_client, u_int8_t *eeprom) -{ - int ret; - tlvinfo_header_t *eeprom_hdr = (tlvinfo_header_t *) eeprom; - tlvinfo_tlv_t *eeprom_tlv = (tlvinfo_tlv_t *)&eeprom[ - sizeof(tlvinfo_header_t)]; - - if (has_been_read) - return 0; - - /* Read the header */ - ret = read_sys_eeprom( pi2c_client,(void *)eeprom_hdr, 0, sizeof(tlvinfo_header_t)); - /* If the header was successfully read, read the TLVs */ - if ((ret == 0) && is_valid_tlvinfo_header(eeprom_hdr)) { - ret = read_sys_eeprom( pi2c_client, (void *)eeprom_tlv, sizeof(tlvinfo_header_t), - be16_to_cpu(eeprom_hdr->totallen)); - } - // If the contents are invalid, start over with default contents - if(!is_valid_tlvinfo_header(eeprom_hdr)) - printk(KERN_ERR - "Notice: Invalid TLV header found. Using default contents--1.\n"); - if(!is_checksum_valid(eeprom)) - printk(KERN_ERR - "Notice: Invalid TLV checksum found. Using default contents--2.\n"); - if ( !is_valid_tlvinfo_header(eeprom_hdr) || !is_checksum_valid(eeprom) ){ - strcpy(eeprom_hdr->signature, TLV_INFO_ID_STRING); - eeprom_hdr->version = TLV_INFO_VERSION; - eeprom_hdr->totallen = cpu_to_be16(0); - update_crc(eeprom); - } - has_been_read = 1; - - return ret; -} - -/* - * prog_eeprom - * Write the EEPROM data from CPU memory to the hardware. - */ -int prog_eeprom(struct i2c_client *pi2c_client, u_int8_t * eeprom) -{ - int ret = 0; - tlvinfo_header_t * eeprom_hdr = (tlvinfo_header_t *) eeprom; - int eeprom_len; - - eeprom_len = sizeof(tlvinfo_header_t) + be16_to_cpu(eeprom_hdr->totallen); - ret = write_sys_eeprom( pi2c_client, eeprom, eeprom_len); - if (ret) { - printk("Programming failed.\n"); - return -1; - } - has_been_read = 0; - return 0; -} - -/* - * tlvinfo_find_tlv - * - * This function finds the TLV with the supplied code in the EERPOM. - * An offset from the beginning of the EEPROM is returned in the - * eeprom_index parameter if the TLV is found. - */ -bool tlvinfo_find_tlv(u_int8_t *eeprom, u_int8_t tcode, - int *eeprom_index) -{ - tlvinfo_header_t * eeprom_hdr = (tlvinfo_header_t *) eeprom; - tlvinfo_tlv_t * eeprom_tlv; - int eeprom_end; - - // Make sure the EEPROM contents are valid - if (!is_valid_tlvinfo_header(eeprom_hdr) || !is_checksum_valid(eeprom)) { - return(FALSE); - } - // Search through the TLVs, looking for the first one which matches the - // supplied type code. - *eeprom_index = sizeof(tlvinfo_header_t); - eeprom_end = sizeof(tlvinfo_header_t) + be16_to_cpu(eeprom_hdr->totallen); - - while (*eeprom_index < eeprom_end) { - eeprom_tlv = (tlvinfo_tlv_t *) &eeprom[*eeprom_index]; - if (!is_valid_tlv(eeprom_tlv)) { - return(FALSE); - } - if (eeprom_tlv->type == tcode) { - return(TRUE); - } - *eeprom_index += sizeof(tlvinfo_tlv_t) + eeprom_tlv->length; - } - return(FALSE); -} - -/* - * tlvinfo_decode_tlv - * - * This function finds the TLV with the supplied code in the EERPOM - * and decodes the value into the buffer provided. - */ -bool tlvinfo_decode_tlv(u_int8_t *eeprom, u_int8_t tcode, char* value) -{ - int eeprom_index; - tlvinfo_tlv_t * eeprom_tlv; - - // Find the TLV and then decode it - - if (tlvinfo_find_tlv(eeprom, tcode, &eeprom_index)) { - eeprom_tlv = (tlvinfo_tlv_t *) &eeprom[eeprom_index]; - decode_tlv_value(eeprom_tlv, value); - return TRUE; - } - - return FALSE; -} - -/* - * tlvinfo_delete_tlv - * - * This function deletes the TLV with the specified type code from the - * EEPROM. - */ -bool tlvinfo_delete_tlv(u_int8_t * eeprom, u_int8_t code) -{ - int eeprom_index; - int tlength; - tlvinfo_header_t * eeprom_hdr = (tlvinfo_header_t *) eeprom; - tlvinfo_tlv_t * eeprom_tlv; - - // Find the TLV and then move all following TLVs "forward" - if (tlvinfo_find_tlv(eeprom, code, &eeprom_index)) { - eeprom_tlv = (tlvinfo_tlv_t *) &eeprom[eeprom_index]; - tlength = sizeof(tlvinfo_tlv_t) + eeprom_tlv->length; - memcpy(&eeprom[eeprom_index], &eeprom[eeprom_index+tlength], - sizeof(tlvinfo_header_t) + be16_to_cpu(eeprom_hdr->totallen) - - eeprom_index - tlength); - eeprom_hdr->totallen = cpu_to_be16(be16_to_cpu(eeprom_hdr->totallen) - - tlength); - update_crc(eeprom); - return(TRUE); - } - return(FALSE); -} - -/* - * tlvinfo_add_tlv - * - * This function adds a TLV to the EEPROM, converting the value (a string) to - * the format in which it will be stored in the EEPROM. - */ -#define MAX_TLV_VALUE_LEN 256 -bool tlvinfo_add_tlv(u_int8_t * eeprom, int tcode, const char *strval) -{ - tlvinfo_header_t * eeprom_hdr = (tlvinfo_header_t *) eeprom; - tlvinfo_tlv_t * eeprom_tlv; - int new_tlv_len = 0; - u_int32_t value; - char data[MAX_TLV_VALUE_LEN]; - int eeprom_index; - int max_size = TLV_TOTAL_LEN_MAX; - - // Encode each TLV type into the format to be stored in the EERPOM - switch (tcode) { - case TLV_CODE_PRODUCT_NAME: - case TLV_CODE_PART_NUMBER: - case TLV_CODE_SERIAL_NUMBER: - case TLV_CODE_LABEL_REVISION: - case TLV_CODE_PLATFORM_NAME: - case TLV_CODE_ONIE_VERSION: - case TLV_CODE_MANUF_NAME: - case TLV_CODE_MANUF_COUNTRY: - case TLV_CODE_VENDOR_NAME: - case TLV_CODE_DIAG_VERSION: - case TLV_CODE_SERVICE_TAG: - strncpy(data, strval, MAX_TLV_VALUE_LEN); - - if( strlen(strval) >= MAX_TLV_VALUE_LEN ) - new_tlv_len = MAX_TLV_VALUE_LEN; - else - new_tlv_len = strlen(strval); - - break; - case TLV_CODE_DEVICE_VERSION: - value = strtoul(strval, NULL, 0); - if (value >= 256) { - printk("ERROR: Device version must be 255 or less. Value " \ - "supplied: %u", value); - return(FALSE); - } - data[0] = value & 0xFF; - new_tlv_len = 1; - break; - case TLV_CODE_MAC_SIZE: - value = strtoul(strval, NULL, 0); - if (value >= 65536) { - printk("ERROR: MAC Size must be 65535 or less. Value " \ - "supplied: %u", value); - return(FALSE); - } - data[0] = (value >> 8) & 0xFF; - data[1] = value & 0xFF; - new_tlv_len = 2; - break; - case TLV_CODE_MANUF_DATE: - if (set_date(data, strval) != 0) { - return(FALSE); - } - new_tlv_len = 19; - break; - case TLV_CODE_MAC_BASE: - if (set_mac(data, strval) != 0) { - return(FALSE); - } - new_tlv_len = 6; - break; - case TLV_CODE_CRC_32: - printk("WARNING: The CRC TLV is set automatically and cannot be set " \ - "manually.\n"); - return(FALSE); - case TLV_CODE_VENDOR_EXT: - default: - if (set_bytes(data, strval, &new_tlv_len) != 0 ) { - return(FALSE); - } - break; - } - - // Is there room for this TLV? - if ((be16_to_cpu(eeprom_hdr->totallen) + sizeof(tlvinfo_tlv_t) + - new_tlv_len) > max_size) { - printk("ERROR: There is not enough room in the EERPOM to save data.\n"); - return(FALSE); - } - - // Add TLV at the end, overwriting CRC TLV if it exists - if (tlvinfo_find_tlv(eeprom, TLV_CODE_CRC_32, &eeprom_index)) { - eeprom_hdr->totallen = cpu_to_be16(be16_to_cpu(eeprom_hdr->totallen) - - sizeof(tlvinfo_tlv_t) - 4); - } else { - eeprom_index = sizeof(tlvinfo_header_t) + - be16_to_cpu(eeprom_hdr->totallen); - } - eeprom_tlv = (tlvinfo_tlv_t *) &eeprom[eeprom_index]; - eeprom_tlv->type = tcode; - eeprom_tlv->length = new_tlv_len; - memcpy(eeprom_tlv->value, data, new_tlv_len); - - // Update the total length and calculate (add) a new CRC-32 TLV - eeprom_hdr->totallen = cpu_to_be16(be16_to_cpu(eeprom_hdr->totallen) + - sizeof(tlvinfo_tlv_t) + new_tlv_len); - update_crc(eeprom); - - return(TRUE); -} - -/* - * read_sys_eeprom - read the hwinfo from i2c EEPROM - */ -int read_sys_eeprom(struct i2c_client *pi2c_client,void *eeprom_data, int offset, int len) -{ - int iRet = 0; - int i = 0; - unsigned char ucBuf[2]; - u_int8_t *c; - unsigned short usAddr = SYS_EEPROM_OFFSET + offset; - - c = eeprom_data; - for (i = 0; i < len; i++) { - ucBuf[0] = (usAddr & 0xFF00) >> 8; - ucBuf[1] = (usAddr & 0x00FF); - - iRet = i2c_smbus_write_byte_data(pi2c_client, ucBuf[0], ucBuf[1]); - if( iRet < 0 ){ - printk(KERN_ERR"Error!! VPD data read error\n"); - return -1; - } - - *c = i2c_smbus_read_byte(pi2c_client); - c++; usAddr++; - } - return 0; -} - -/* - * write_sys_eeprom - write the hwinfo to i2c EEPROM - */ -int write_sys_eeprom(struct i2c_client *pi2c_client, void *eeprom_data, int len) -{ - int iRet = 0; - int i = 0; - u_int8_t *c; - unsigned short usAddr = SYS_EEPROM_OFFSET; - unsigned char ucBuf[3]; - - c = eeprom_data; - for (i = 0; i < len; i++) { - ucBuf[ 0 ] = (usAddr & 0xFF00) >>8 ; - ucBuf[ 1 ] = (usAddr & 0x00FF); - ucBuf[ 2 ] = *c; - - iRet = i2c_smbus_write_word_data( pi2c_client, ucBuf[0], (ucBuf[2] << 8 | ucBuf[1])); - if (iRet < 0 ){ - printk(KERN_ERR"Error!! VPD data write error . \n"); - return -1; - } - - c++; usAddr++; - msleep_interruptible(10); - } - - return 0; -} - -void update_eeprom_header(u_int8_t *eeprom) -{ - tlvinfo_header_t * eeprom_hdr = (tlvinfo_header_t *) eeprom; - - strcpy(eeprom_hdr->signature, TLV_INFO_ID_STRING); - eeprom_hdr->version = TLV_INFO_VERSION; - eeprom_hdr->totallen = cpu_to_be16(0); - update_crc(eeprom); -} -#if 0 -int find_vpd_data(u_int8_t *eeprom, int i_offset, char *c_buf) -{ - int tlv_end; - int curr_tlv; - tlvinfo_header_t * eeprom_hdr = (tlvinfo_header_t *) eeprom; - tlvinfo_tlv_t * eeprom_tlv; - int iFind = 0; - - if( !is_valid_tlvinfo_header(eeprom_hdr) ) { - printk(KERN_ERR"EEPROM does not contain data in a valid TlvInfo format.\n"); - return -1; - } - - curr_tlv = sizeof(tlvinfo_header_t); - tlv_end = sizeof(tlvinfo_header_t) + be16_to_cpu(eeprom_hdr->totallen); - while(curr_tlv < tlv_end){ - eeprom_tlv = (tlvinfo_tlv_t *) &eeprom[curr_tlv]; - if (!is_valid_tlv(eeprom_tlv)) { - printk(KERN_ERR"Invalid TLV field starting at EEPROM offset %d\n", - curr_tlv); - return -1; - } - - decode_tlv_value(eeprom_tlv, c_buf); - if( eeprom_tlv->type == i_offset){ - iFind = 1; - break; - } - curr_tlv += sizeof(tlvinfo_tlv_t) + eeprom_tlv->length; - } - - if( iFind == 0 ) - return -1; - else - return 0; -} -#endif diff --git a/packages/platforms/inventec/x86-64/d6556/modules/builds/src/onie_tlvinfo.h b/packages/platforms/inventec/x86-64/d6556/modules/builds/src/onie_tlvinfo.h deleted file mode 100644 index da0a07590..000000000 --- a/packages/platforms/inventec/x86-64/d6556/modules/builds/src/onie_tlvinfo.h +++ /dev/null @@ -1,150 +0,0 @@ -/* - * The Definition of the TlvInfo EEPROM format can be found at onie.org or - * github.com/onie - */ -#include -#define strtoul simple_strtoul - -#define FALSE 0 -#define TRUE (!FALSE) -#define MAX_STRING_SIZE 128 -/* - * Tlvinf header: Layout of the header for the TlvInfo format - * - * See the end of this file for details of this eeprom format - */ -struct __attribute__ ((__packed__)) tlvinfo_header_s { - char signature[8]; /* 0x00 - 0x07 EEPROM Tag "TlvInfo" */ - u_int8_t version; /* 0x08 Structure version */ - u_int16_t totallen; /* 0x09 - 0x0A Length of all data which follows */ -}; -typedef struct tlvinfo_header_s tlvinfo_header_t; - -// Header Field Constants -#define TLV_INFO_ID_STRING "TlvInfo" -#define TLV_INFO_VERSION 0x01 -#define TLV_TOTAL_LEN_MAX (SYS_EEPROM_SIZE - sizeof(tlvinfo_header_t)) - -/* - * TlvInfo TLV: Layout of a TLV field - */ -struct __attribute__ ((__packed__)) tlvinfo_tlv_s { - u_int8_t type; - u_int8_t length; - u_int8_t value[0]; -}; -typedef struct tlvinfo_tlv_s tlvinfo_tlv_t; - -/* Maximum length of a TLV value in bytes */ -#define TLV_VALUE_MAX_LEN 255 - -/** - * The TLV Types. - * - * Keep these in sync with tlv_code_list in cmd_sys_eeprom.c - */ -#define TLV_CODE_PRODUCT_NAME 0x21 -#define TLV_CODE_PART_NUMBER 0x22 -#define TLV_CODE_SERIAL_NUMBER 0x23 -#define TLV_CODE_MAC_BASE 0x24 -#define TLV_CODE_MANUF_DATE 0x25 -#define TLV_CODE_DEVICE_VERSION 0x26 -#define TLV_CODE_LABEL_REVISION 0x27 -#define TLV_CODE_PLATFORM_NAME 0x28 -#define TLV_CODE_ONIE_VERSION 0x29 -#define TLV_CODE_MAC_SIZE 0x2A -#define TLV_CODE_MANUF_NAME 0x2B -#define TLV_CODE_MANUF_COUNTRY 0x2C -#define TLV_CODE_VENDOR_NAME 0x2D -#define TLV_CODE_DIAG_VERSION 0x2E -#define TLV_CODE_SERVICE_TAG 0x2F -#define TLV_CODE_VENDOR_EXT 0xFD -#define TLV_CODE_CRC_32 0xFE - -/* - * Struct for displaying the TLV codes and names. - */ -struct tlv_code_desc { - u_int8_t m_code; - char* m_name; -}; - -/* - * List of TLV codes and names. - */ -static const struct tlv_code_desc tlv_code_list[] = { - { TLV_CODE_PRODUCT_NAME , "Product Name"}, - { TLV_CODE_PART_NUMBER , "Part Number"}, - { TLV_CODE_SERIAL_NUMBER , "Serial Number"}, - { TLV_CODE_MAC_BASE , "Base MAC Address"}, - { TLV_CODE_MANUF_DATE , "Manufacture Date"}, - { TLV_CODE_DEVICE_VERSION , "Device Version"}, - { TLV_CODE_LABEL_REVISION , "Label Revision"}, - { TLV_CODE_PLATFORM_NAME , "Platform Name"}, - { TLV_CODE_ONIE_VERSION , "Loader Version"}, - { TLV_CODE_MAC_SIZE , "MAC Addresses"}, - { TLV_CODE_MANUF_NAME , "Manufacturer"}, - { TLV_CODE_MANUF_COUNTRY , "Country Code"}, - { TLV_CODE_VENDOR_NAME , "Vendor Name"}, - { TLV_CODE_DIAG_VERSION , "Diag Version"}, - { TLV_CODE_SERVICE_TAG , "Service Tag"}, - { TLV_CODE_VENDOR_EXT , "Vendor Extension"}, - { TLV_CODE_CRC_32 , "CRC-32"}, -}; - -static inline const char* tlv_type2name(u_int8_t type) -{ - char* name = "Unknown"; - int i; - - for (i = 0; i < sizeof(tlv_code_list)/sizeof(tlv_code_list[0]); i++) { - if (tlv_code_list[i].m_code == type) { - name = tlv_code_list[i].m_name; - break; - } - } - return name; -} - -/* - * The max decode value is currently for the 'raw' type or the 'vendor - * extension' type, both of which have the same decode format. The - * max decode string size is computed as follows: - * - * strlen(" 0xFF") * TLV_VALUE_MAX_LEN + 1 - * - */ -#define TLV_DECODE_VALUE_MAX_LEN ((5 * TLV_VALUE_MAX_LEN) + 1) - - -/* - * Each platform must define the following platform-specific macros - * in sys_eeprom_platform.h: - * SYS_EEPROM_SIZE: size of usable eeprom - * SYS_EEPROM_I2C_DEVICE: i2c-bus - * SYS_EEPROM_I2C_ADDR: address on the bus - * The following may also be defined in sys_eeprom_platform.h, else - * the defaults with take over: - * SYS_EEPROM_MAX_SIZE: Total size of the eeprom - * SYS_EEPROM_OFFSET: offset from where the ONIE header starts - */ -#define SYS_EEPROM_MAX_SIZE 2048 -#define SYS_EEPROM_OFFSET 0 -#define SYS_EEPROM_SIZE SYS_EEPROM_MAX_SIZE -#define SYS_EEPROM_I2C_DEVICE "/dev/i2c-0" -#define SYS_EEPROM_I2C_ADDR 0x53 - -#if (SYS_EEPROM_SIZE + SYS_EEPROM_OFFSET > SYS_EEPROM_MAX_SIZE) - #error SYS_EEPROM_SIZE + SYS_EEPROM_OFFSET is greater than SYS_EEPROM_MAX_SIZE -#endif - -// Access functions to onie_tlvinfo -void show_eeprom(u_int8_t *eeprom); -int read_eeprom(struct i2c_client *pi2c_client, u_int8_t *eeprom); -int prog_eeprom(struct i2c_client *pi2c_client,u_int8_t * eeprom); -void update_eeprom_header(u_int8_t *eeprom); -bool tlvinfo_find_tlv(u_int8_t *eeprom, u_int8_t tcode, int *eeprom_index); -bool tlvinfo_delete_tlv(u_int8_t * eeprom, u_int8_t code); -bool tlvinfo_add_tlv(u_int8_t * eeprom, int tcode, const char *strval); -bool tlvinfo_decode_tlv(u_int8_t *eeprom, u_int8_t tcode, char* value); -//int find_vpd_data(u_int8_t *eeprom, int i_offset, char *c_buf); diff --git a/packages/platforms/inventec/x86-64/d6556/modules/builds/src/transceiver.c b/packages/platforms/inventec/x86-64/d6556/modules/builds/src/transceiver.c deleted file mode 100644 index 77bd27b39..000000000 --- a/packages/platforms/inventec/x86-64/d6556/modules/builds/src/transceiver.c +++ /dev/null @@ -1,8433 +0,0 @@ -#include -#include -#include -#include -#include "io_expander.h" -#include "transceiver.h" - - -/* ========== Register EEPROM address mapping ========== - */ -struct eeprom_map_s eeprom_map_sfp = { - .addr_br =0x50, .page_br =-1, .offset_br =12, .length_br =1, - .addr_cdr =-1, .page_cdr =-1, .offset_cdr =-1, .length_cdr =-1, - .addr_comp_rev =0x50, .page_comp_rev =-1, .offset_comp_rev =94, .length_comp_rev =1, - .addr_connector =0x50, .page_connector =-1, .offset_connector =2, .length_connector =1, - .addr_diag_type =0x50, .page_diag_type =-1, .offset_diag_type =92 , .length_diag_type =1, - .addr_extbr =-1, .page_extbr =-1, .offset_extbr =-1, .length_extbr =-1, - .addr_ext_id =0x50, .page_ext_id =-1, .offset_ext_id =1, .length_ext_id =1, - .addr_id =0x50, .page_id =-1, .offset_id =0, .length_id =1, - .addr_len_sm =0x50, .page_len_sm =-1, .offset_len_sm =15, .length_len_sm =1, - .addr_len_smf =0x50, .page_len_smf =-1, .offset_len_smf =14, .length_len_smf =1, - .addr_len_om1 =0x50, .page_len_om1 =-1, .offset_len_om1 =17, .length_len_om1 =1, - .addr_len_om2 =0x50, .page_len_om2 =-1, .offset_len_om2 =16, .length_len_om2 =1, - .addr_len_om3 =0x50, .page_len_om3 =-1, .offset_len_om3 =19, .length_len_om3 =1, - .addr_len_om4 =0x50, .page_len_om4 =-1, .offset_len_om4 =18, .length_len_om4 =1, - .addr_option =0x50, .page_option =-1, .offset_option =64, .length_option =2, - .addr_rate_id =0x50, .page_rate_id =-1, .offset_rate_id =13, .length_rate_id =1, - .addr_rx_am =-1, .page_rx_am =-1, .offset_rx_am =-1, .length_rx_am =-1, - .addr_rx_em =0x51, .page_rx_em =-1, .offset_rx_em =115, .length_rx_em =1, - .addr_rx_los =-1, .page_rx_los =-1, .offset_rx_los =-1, .length_rx_los =-1, - .addr_rx_power =0x51, .page_rx_power =-1, .offset_rx_power =104, .length_rx_power =2, - .addr_soft_rs0 =0x51, .page_soft_rs0 =-1, .offset_soft_rs0 =110, .length_soft_rs0 =1, - .addr_soft_rs1 =0x51, .page_soft_rs1 =-1, .offset_soft_rs1 =118, .length_soft_rs0 =1, - .addr_temp =0x51, .page_temp =-1, .offset_temp =96, .length_temp =2, - .addr_trancomp =0x50, .page_trancomp =-1, .offset_trancomp =3, .length_trancomp =8, - .addr_trancomp_ext =0x50, .page_trancomp_ext =-1, .offset_trancomp_ext =36, .length_trancomp_ext =1, - .addr_tx_bias =0x51, .page_tx_bias =-1, .offset_tx_bias =100, .length_tx_bias =2, - .addr_tx_disable =-1, .page_tx_disable =-1, .offset_tx_disable =-1, .length_tx_disable =-1, - .addr_tx_eq =0x51, .page_tx_eq =-1, .offset_tx_eq =114, .length_tx_eq =1, - .addr_tx_fault =-1, .page_tx_fault =-1, .offset_tx_fault =-1, .length_tx_fault =-1, - .addr_tx_power =0x51, .page_tx_power =-1, .offset_tx_power =102, .length_tx_power =2, - .addr_vendor_name =0x50, .page_vendor_name =-1, .offset_vendor_name =20, .length_vendor_name =16, - .addr_vendor_pn =0x50, .page_vendor_pn =-1, .offset_vendor_pn =40, .length_vendor_pn =16, - .addr_vendor_rev =0x50, .page_vendor_rev =-1, .offset_vendor_rev =56, .length_vendor_rev =4, - .addr_vendor_sn =0x50, .page_vendor_sn =-1, .offset_vendor_sn =68, .length_vendor_sn =16, - .addr_voltage =0x51, .page_voltage =-1, .offset_voltage =98, .length_voltage =2, - .addr_wavelength =0x50, .page_wavelength =-1, .offset_wavelength =60, .length_wavelength =2, - .addr_eeprom =0x50, .page_eeprom =-1, .offset_eeprom =0, .length_eeprom =256, -}; - -struct eeprom_map_s eeprom_map_qsfp = { - .addr_br =0x50, .page_br =0, .offset_br =140, .length_br =1, - .addr_cdr =-1, .page_cdr =-1, .offset_cdr =-1, .length_cdr =-1, - .addr_comp_rev =0x50, .page_comp_rev =-1, .offset_comp_rev =1, .length_comp_rev =1, - .addr_connector =0x50, .page_connector =0, .offset_connector =130, .length_connector =1, - .addr_diag_type =0x50, .page_diag_type =0, .offset_diag_type =220, .length_diag_type =1, - .addr_extbr =0x50, .page_extbr =0, .offset_extbr =222, .length_extbr =1, - .addr_ext_id =0x50, .page_ext_id =0, .offset_ext_id =129, .length_ext_id =1, - .addr_id =0x50, .page_id =0, .offset_id =128, .length_id =1, - .addr_len_sm =-1, .page_len_sm =-1, .offset_len_sm =-1, .length_len_sm =-1, - .addr_len_smf =0x50, .page_len_smf =0, .offset_len_smf =142, .length_len_smf =1, - .addr_len_om1 =0x50, .page_len_om1 =0, .offset_len_om1 =145, .length_len_om1 =1, - .addr_len_om2 =0x50, .page_len_om2 =0, .offset_len_om2 =144, .length_len_om2 =1, - .addr_len_om3 =0x50, .page_len_om3 =0, .offset_len_om3 =143, .length_len_om3 =1, - .addr_len_om4 =0x50, .page_len_om4 =0, .offset_len_om4 =146, .length_len_om4 =1, - .addr_option =0x50, .page_option =0, .offset_option =193, .length_option =3, - .addr_rate_id =-1, .page_rate_id =-1, .offset_rate_id =-1, .length_rate_id =-1, - .addr_rx_am =-1, .page_rx_am =-1, .offset_rx_am =-1, .length_rx_am =-1, - .addr_rx_em =-1, .page_rx_em =-1, .offset_rx_em =-1, .length_rx_em =-1, - .addr_rx_los =0x50, .page_rx_los =-1, .offset_rx_los =3, .length_rx_los =1, - .addr_rx_power =0x50, .page_rx_power =-1, .offset_rx_power =34, .length_rx_power =8, - .addr_soft_rs0 =-1, .page_soft_rs0 =-1, .offset_soft_rs0 =-1, .length_soft_rs0 =-1, - .addr_soft_rs1 =-1, .page_soft_rs1 =-1, .offset_soft_rs1 =-1, .length_soft_rs0 =-1, - .addr_temp =0x50, .page_temp =-1, .offset_temp =22, .length_temp =2, - .addr_trancomp =0x50, .page_trancomp =0, .offset_trancomp =131, .length_trancomp =8, - .addr_trancomp_ext =0x50, .page_trancomp_ext =0, .offset_trancomp_ext =192, .length_trancomp_ext =1, - .addr_tx_bias =0x50, .page_tx_bias =-1, .offset_tx_bias =42, .length_tx_bias =8, - .addr_tx_disable =0x50, .page_tx_disable =-1, .offset_tx_disable =86, .length_tx_disable =1, - .addr_tx_eq =-1, .page_tx_eq =-1, .offset_tx_eq =-1, .length_tx_eq =-1, - .addr_tx_fault =0x50, .page_tx_fault =-1, .offset_tx_fault =4, .length_tx_fault =1, - .addr_tx_power =0x50, .page_tx_power =-1, .offset_tx_power =50, .length_tx_power =8, - .addr_vendor_name =0x50, .page_vendor_name =0, .offset_vendor_name =148, .length_vendor_name =16, - .addr_vendor_pn =0x50, .page_vendor_pn =0, .offset_vendor_pn =168, .length_vendor_pn =16, - .addr_vendor_rev =0x50, .page_vendor_rev =0, .offset_vendor_rev =184, .length_vendor_rev =2, - .addr_vendor_sn =0x50, .page_vendor_sn =0, .offset_vendor_sn =196, .length_vendor_sn =16, - .addr_voltage =0x50, .page_voltage =-1, .offset_voltage =26, .length_voltage =2, - .addr_wavelength =0x50, .page_wavelength =0, .offset_wavelength =186, .length_wavelength =2, - .addr_eeprom =0x50, .page_eeprom =0, .offset_eeprom =0, .length_eeprom =256, -}; - -struct eeprom_map_s eeprom_map_qsfp28 = { - .addr_br =0x50, .page_br =0, .offset_br =140, .length_br =1, - .addr_cdr =0x50, .page_cdr =-1, .offset_cdr =98, .length_cdr =1, - .addr_comp_rev =0x50, .page_comp_rev =-1, .offset_comp_rev =1, .length_comp_rev =1, - .addr_connector =0x50, .page_connector =0, .offset_connector =130, .length_connector =1, - .addr_diag_type =0x50, .page_diag_type =0, .offset_diag_type =220, .length_diag_type =1, - .addr_extbr =0x50, .page_extbr =0, .offset_extbr =222, .length_extbr =1, - .addr_ext_id =0x50, .page_ext_id =0, .offset_ext_id =129, .length_ext_id =1, - .addr_id =0x50, .page_id =0, .offset_id =128, .length_id =1, - .addr_len_sm =-1, .page_len_sm =-1, .offset_len_sm =-1, .length_len_sm =-1, - .addr_len_smf =0x50, .page_len_smf =0, .offset_len_smf =142, .length_len_smf =1, - .addr_len_om1 =0x50, .page_len_om1 =0, .offset_len_om1 =145, .length_len_om1 =1, - .addr_len_om2 =0x50, .page_len_om2 =0, .offset_len_om2 =144, .length_len_om2 =1, - .addr_len_om3 =0x50, .page_len_om3 =0, .offset_len_om3 =143, .length_len_om3 =1, - .addr_len_om4 =0x50, .page_len_om4 =0, .offset_len_om4 =146, .length_len_om4 =1, - .addr_option =0x50, .page_option =0, .offset_option =193, .length_option =3, - .addr_rate_id =-1, .page_rate_id =-1, .offset_rate_id =-1, .length_rate_id =-1, - .addr_rx_am =0x50, .page_rx_am =3, .offset_rx_am =238, .length_rx_am =2, - .addr_rx_em =0x50, .page_rx_em =3, .offset_rx_em =236, .length_rx_em =2, - .addr_rx_los =0x50, .page_rx_los =-1, .offset_rx_los =3, .length_rx_los =1, - .addr_rx_power =0x50, .page_rx_power =-1, .offset_rx_power =34, .length_rx_power =8, - .addr_soft_rs0 =-1, .page_soft_rs0 =-1, .offset_soft_rs0 =-1, .length_soft_rs0 =-1, - .addr_soft_rs1 =-1, .page_soft_rs1 =-1, .offset_soft_rs1 =-1, .length_soft_rs0 =-1, - .addr_temp =0x50, .page_temp =-1, .offset_temp =22, .length_temp =2, - .addr_trancomp =0x50, .page_trancomp =0, .offset_trancomp =131, .length_trancomp =8, - .addr_trancomp_ext =0x50, .page_trancomp_ext =0, .offset_trancomp_ext =192, .length_trancomp_ext =1, - .addr_tx_bias =0x50, .page_tx_bias =-1, .offset_tx_bias =42, .length_tx_bias =8, - .addr_tx_disable =0x50, .page_tx_disable =-1, .offset_tx_disable =86, .length_tx_disable =1, - .addr_tx_eq =0x50, .page_tx_eq =3, .offset_tx_eq =234, .length_tx_eq =2, - .addr_tx_fault =0x50, .page_tx_fault =-1, .offset_tx_fault =4, .length_tx_fault =1, - .addr_tx_power =0x50, .page_tx_power =-1, .offset_tx_power =50, .length_tx_power =8, - .addr_vendor_name =0x50, .page_vendor_name =0, .offset_vendor_name =148, .length_vendor_name =16, - .addr_vendor_pn =0x50, .page_vendor_pn =0, .offset_vendor_pn =168, .length_vendor_pn =16, - .addr_vendor_rev =0x50, .page_vendor_rev =0, .offset_vendor_rev =184, .length_vendor_rev =2, - .addr_vendor_sn =0x50, .page_vendor_sn =0, .offset_vendor_sn =196, .length_vendor_sn =16, - .addr_voltage =0x50, .page_voltage =-1, .offset_voltage =26, .length_voltage =2, - .addr_wavelength =0x50, .page_wavelength =0, .offset_wavelength =186, .length_wavelength =2, - .addr_eeprom =0x50, .page_eeprom =0, .offset_eeprom =0, .length_eeprom =256, -}; - - -/* ========== Utility Functions ========== - */ -static int -get_bit(uint8_t origin_byte, int bit_shift) { - return (int)((origin_byte >> bit_shift) & 0x1); -} - -static int -transform_word_to_int(uint8_t hight_byte, - uint8_t low_byte) { - return ((((int)hight_byte) << 8) + (int)low_byte); -} - -void -alarm_msg_2_user(struct transvr_obj_s *self, - char *emsg) { - - SWPS_ERR("%s on %s.\n", emsg, self->swp_name); -} - - -/* ========== Private functions ========== - */ -static int -_reload_transvr_obj(struct transvr_obj_s *self,int new_type); - -static int -reload_transvr_obj(struct transvr_obj_s *self,int new_type); - -static int -_is_transvr_support_ctle(struct transvr_obj_s *self); - -static int -_transvr_init_handler(struct transvr_obj_s *self); - -int -_transvr_clean_handler(struct transvr_obj_s *self); - -int -_sfp_detect_class_by_1g_ethernet(struct transvr_obj_s* self); - - -void -lock_transvr_obj(struct transvr_obj_s *self) { - - mutex_lock(&self->lock); - self->curr_page = VAL_TRANSVR_PAGE_FREE; -} - - -void -unlock_transvr_obj(struct transvr_obj_s *self) { - - self->curr_page = VAL_TRANSVR_PAGE_FREE; - mutex_unlock(&self->lock); -} - - -static int -_check_by_mode(struct transvr_obj_s *self, - int (*attr_update_func)(struct transvr_obj_s *self, int show_err), - char *caller_name){ - - int return_val = ERR_TRANSVR_UNEXCPT; - - switch (self->mode){ - case TRANSVR_MODE_POLLING: - switch (self->state){ - case STATE_TRANSVR_CONNECTED: - goto ok_check_by_mode_1; - case STATE_TRANSVR_NEW: - case STATE_TRANSVR_INIT: - return ERR_TRANSVR_UNINIT; - case STATE_TRANSVR_DISCONNECTED: - return ERR_TRANSVR_UNPLUGGED; - case STATE_TRANSVR_UNEXCEPTED: - return ERR_TRANSVR_ABNORMAL; - case STATE_TRANSVR_ISOLATED: - return ERR_TRNASVR_BE_ISOLATED; - default: - goto err_check_by_mode_1; - } - goto ok_check_by_mode_1; - - case TRANSVR_MODE_DIRECT: - return_val = self->fsm_4_direct(self, caller_name); - if (return_val < 0){ - return return_val; - } - goto ok_check_by_mode_1; - - default: - goto err_check_by_mode_1; - } - goto ok_check_by_mode_1; - -ok_check_by_mode_1: - return attr_update_func(self, 0); - -err_check_by_mode_1: - SWPS_INFO("_check_by_mode: mode:%d state:%d\n", self->mode, self->state); - return ERR_TRANSVR_UNEXCPT; -} - - -static void -_transvr_clean_retry(struct transvr_obj_s *self) { - self->retry = 0; -} - - -static int -_transvr_handle_retry(struct transvr_obj_s *self, int retry) { - /* Return: 0: keep retry - * -1: stop retry - */ - if (self->retry == 0) { - self->retry = retry; - } - self->retry -= 1; - if (self->retry <= 0) { - _transvr_clean_retry(self); - return -1; - } - return 0; -} - - -static int -_common_setup_page(struct transvr_obj_s *self, - int addr, - int page, - int offset, - int len, - int show_e) { - /* return: - * 0 : OK - * -1 : EEPROM settings incorrect - * -2 : I2C R/W failure - * -3 : Undefined case - */ - int retval = DEBUG_TRANSVR_INT_VAL; - char *emsg = DEBUG_TRANSVR_STR_VAL; - - /* Check */ - if ((addr < 0) || (offset < 0) || (len < 0)) { - emsg = "EEPROM settings incorrect"; - retval = -1; - goto err_common_setup_page; - } - /* Case1: continue access */ - if ((self->i2c_client_p->addr == addr) && - (self->curr_page == page)) { - return 0; - } - self->i2c_client_p->addr = addr; - /* Case2: select lower page */ - if (page == -1) { - self->curr_page = page; - return 0; - } - /* Case3: select upper page */ - if (page >= 0) { - goto upper_common_setup_page; - } - /* Unexpected case */ - show_e = 1; - emsg = "Unexpected case"; - retval = -3; - goto err_common_setup_page; - -upper_common_setup_page: - if (i2c_smbus_write_byte_data(self->i2c_client_p, - VAL_TRANSVR_PAGE_SELECT_OFFSET, - page) < 0) { - emsg = "I2C R/W failure"; - retval = -2; - goto err_common_setup_page; - } - self->curr_page = page; - mdelay(VAL_TRANSVR_PAGE_SELECT_DELAY); - return 0; - -err_common_setup_page: - if (show_e) { - SWPS_INFO("%s: %s", __func__, emsg); - SWPS_INFO("%s: :0x%02x :%d :%d :%d\n", - __func__, addr, page, offset, len); - } - return retval; -} - -/* -static int -_common_setup_password(struct transvr_obj_s *self, - int addr, - int page, - int offs, - uint8_t pwd[4], - int show_e) { - int i = 0; - int err = DEBUG_TRANSVR_INT_VAL; - char *emsg = DEBUG_TRANSVR_STR_VAL; - - err = _common_setup_page(self, addr, page, offs, 4, show_e); - if (err < 0){ - emsg = "setup EEPROM page fail"; - goto err_common_setup_password; - } - for (i=0; i<4; i++) { - err = i2c_smbus_write_byte_data(self->i2c_client_p, - (offs + i), - pwd[i]); - if (err < 0){ - emsg = "I2C R/W fail!"; - goto err_common_setup_password; - } - } - return 0; - -err_common_setup_password: - if (show_e) { - SWPS_INFO("%s: %s :%d\n", __func__, emsg, err); - } - return ERR_TRANSVR_UPDATE_FAIL; -} -*/ - -static int -_common_update_uint8_attr(struct transvr_obj_s *self, - int addr, - int page, - int offset, - int len, - uint8_t *buf, - char *caller, - int show_e){ - - int i; - int err = DEBUG_TRANSVR_INT_VAL; - char *emsg = DEBUG_TRANSVR_STR_VAL; - - err = _common_setup_page(self, addr, page, offset, len, show_e); - if (err < 0){ - emsg = "setup EEPROM page fail"; - goto err_common_update_uint8_attr; - } - for (i=0; ii2c_client_p, (offset + i)); - if (err < 0){ - emsg = "I2C R/W fail!"; - goto err_common_update_uint8_attr; - } - buf[i] = err; - } - return 0; - -err_common_update_uint8_attr: - if (show_e) { - SWPS_INFO("%s: %s :%s :%d\n", - __func__, emsg, caller, err); - } - buf[0] = DEBUG_TRANSVR_HEX_VAL; - return ERR_TRANSVR_UPDATE_FAIL; -} - - -static int -_common_update_int_attr(struct transvr_obj_s *self, - int addr, - int page, - int offset, - int len, - int *buf, - char *caller, - int show_e){ - - int i; - int err = DEBUG_TRANSVR_INT_VAL; - char *emsg = DEBUG_TRANSVR_STR_VAL; - - err = _common_setup_page(self, addr, page, offset, len, show_e); - if (err < 0){ - emsg = "setup EEPROM page fail"; - goto err_common_update_int_attr; - } - for (i=0; ii2c_client_p, (offset + i)); - if (err < 0){ - emsg = "I2C R/W fail!"; - goto err_common_update_int_attr; - } - buf[i] = (int)err; - } - return 0; - -err_common_update_int_attr: - if (show_e) { - SWPS_INFO("%s: %s :%s :%d\n", - __func__, emsg, caller, err); - } - buf[0] = DEBUG_TRANSVR_INT_VAL; - return ERR_TRANSVR_UPDATE_FAIL; -} - - -static int -_common_update_string_attr(struct transvr_obj_s *self, - int addr, - int page, - int offset, - int len, - char buf[], - char *caller, - int show_e){ - - int i; - int err = DEBUG_TRANSVR_INT_VAL; - char *emsg = DEBUG_TRANSVR_STR_VAL; - - err = _common_setup_page(self, addr, page, offset, len, show_e); - if (err < 0){ - emsg = "setup EEPROM page fail"; - goto err_common_update_string_attr; - } - for (i=0; ii2c_client_p, (offset + i)); - if (err < 0){ - emsg = "I2C R/W fail!"; - goto err_common_update_string_attr; - } - buf[i] = (char)err; - } - return 0; - -err_common_update_string_attr: - if (show_e) { - SWPS_INFO("%s: %s :%s :%d\n", - __func__, emsg, caller, err); - } - buf[0] = 'e'; - return ERR_TRANSVR_UPDATE_FAIL; -} - - -static int -_common_set_uint8_attr(struct transvr_obj_s *self, - int addr, - int page, - int offset, - uint8_t update, - uint8_t *buf, - char *caller, - int show_e){ - int len = 1; - int err = DEBUG_TRANSVR_INT_VAL; - char *emsg = DEBUG_TRANSVR_STR_VAL; - - if ((*buf) == update){ - return 0; - } - err = _common_setup_page(self, addr, page, offset, len, show_e); - if (err < 0){ - emsg = "setup EEPROM page fail"; - goto err_common_set_uint8_attr_1; - } - err = i2c_smbus_write_byte_data(self->i2c_client_p, - offset, - update); - if (err < 0){ - emsg = "I2C R/W fail!"; - goto err_common_set_uint8_attr_1; - } - (*buf) = update; - return 0; - -err_common_set_uint8_attr_1: - if (show_e) { - SWPS_INFO("%s: %s :%s :%d\n", - __func__, emsg, caller, err); - } - return ERR_TRANSVR_UPDATE_FAIL; -} - - -static int -_common_set_uint8_array(struct transvr_obj_s *self, - int addr, - int page, - int offs, - int len, - uint8_t update[], - uint8_t buf[], - char *caller, - int show_e){ - int i = 0; - int err = DEBUG_TRANSVR_INT_VAL; - char *emsg = DEBUG_TRANSVR_STR_VAL; - - err = _common_setup_page(self, addr, page, offs, len, show_e); - if (err < 0){ - emsg = "setup EEPROM page fail"; - goto err_common_set_uint8_attr_1; - } - for (i=0; ii2c_client_p, - (offs + i), - update[i]); - if (err < 0){ - emsg = "I2C R/W fail!"; - goto err_common_set_uint8_attr_1; - } - buf[i] = update[i]; - } - return 0; - -err_common_set_uint8_attr_1: - if (show_e) { - SWPS_INFO("%s: %s :%s :%d :%d\n", - __func__, emsg, caller, err, i); - } - return ERR_TRANSVR_UPDATE_FAIL; -} - - -static int -_common_update_attr_id(struct transvr_obj_s *self, - int show_err){ - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_id, - self->eeprom_map_p->page_id, - self->eeprom_map_p->offset_id, - self->eeprom_map_p->length_id, - &(self->id), - "_common_update_attr_id", - show_err); -} - - -static int -_common_update_attr_extended_id(struct transvr_obj_s *self, - int show_err){ - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_ext_id, - self->eeprom_map_p->page_ext_id, - self->eeprom_map_p->offset_ext_id, - self->eeprom_map_p->length_ext_id, - &(self->ext_id), - "_common_update_attr_extended_id", - show_err); -} - - -static int -_common_update_attr_connector(struct transvr_obj_s *self, - int show_err){ - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_connector, - self->eeprom_map_p->page_connector, - self->eeprom_map_p->offset_connector, - self->eeprom_map_p->length_connector, - &(self->connector), - "_common_update_attr_connector", - show_err); -} - - -static int -_common_update_attr_transvr_comp(struct transvr_obj_s *self, - int show_err){ - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_trancomp, - self->eeprom_map_p->page_trancomp, - self->eeprom_map_p->offset_trancomp, - self->eeprom_map_p->length_trancomp, - self->transvr_comp, - "_common_update_attr_transvr_comp", - show_err); -} - - -static int -_common_update_attr_transvr_comp_ext(struct transvr_obj_s *self, - int show_err){ - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_trancomp_ext, - self->eeprom_map_p->page_trancomp_ext, - self->eeprom_map_p->offset_trancomp_ext, - self->eeprom_map_p->length_trancomp_ext, - &(self->transvr_comp_ext), - "_common_update_attr_transvr_comp_ext", - show_err); -} - - -static int -_common_update_attr_eeprom(struct transvr_obj_s *self, - int show_err){ - return _common_update_string_attr(self, - self->eeprom_map_p->addr_eeprom, - self->eeprom_map_p->page_eeprom, - self->eeprom_map_p->offset_eeprom, - self->eeprom_map_p->length_eeprom, - self->eeprom, - "_common_update_attr_eeprom", - show_err); -} - -static int -_common_update_attr_vendor_name(struct transvr_obj_s *self, - int show_err){ - return _common_update_string_attr(self, - self->eeprom_map_p->addr_vendor_name, - self->eeprom_map_p->page_vendor_name, - self->eeprom_map_p->offset_vendor_name, - self->eeprom_map_p->length_vendor_name, - self->vendor_name, - "_common_update_attr_vendor_name", - show_err); -} - - -static int -_common_update_attr_vendor_pn(struct transvr_obj_s *self, - int show_err){ - return _common_update_string_attr(self, - self->eeprom_map_p->addr_vendor_pn, - self->eeprom_map_p->page_vendor_pn, - self->eeprom_map_p->offset_vendor_pn, - self->eeprom_map_p->length_vendor_pn, - self->vendor_pn, - "_common_update_attr_vendor_pn", - show_err); -} - - -static int -_common_update_attr_vendor_rev(struct transvr_obj_s *self, - int show_err){ - return _common_update_string_attr(self, - self->eeprom_map_p->addr_vendor_rev, - self->eeprom_map_p->page_vendor_rev, - self->eeprom_map_p->offset_vendor_rev, - self->eeprom_map_p->length_vendor_rev, - self->vendor_rev, - "_common_update_attr_vendor_rev", - show_err); -} - - -static int -_common_update_attr_vendor_sn(struct transvr_obj_s *self, - int show_err){ - return _common_update_string_attr(self, - self->eeprom_map_p->addr_vendor_sn, - self->eeprom_map_p->page_vendor_sn, - self->eeprom_map_p->offset_vendor_sn, - self->eeprom_map_p->length_vendor_sn, - self->vendor_sn, - "_common_update_attr_vendor_sn", - show_err); -} - - -static int -_common_update_attr_br(struct transvr_obj_s *self, - int show_err){ - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_br, - self->eeprom_map_p->page_br, - self->eeprom_map_p->offset_br, - self->eeprom_map_p->length_br, - &(self->br), - "_common_update_attr_br", - show_err); -} - - -static int -_common_update_attr_len_smf(struct transvr_obj_s *self, - int show_err){ - return _common_update_int_attr(self, - self->eeprom_map_p->addr_len_smf, - self->eeprom_map_p->page_len_smf, - self->eeprom_map_p->offset_len_smf, - self->eeprom_map_p->length_len_smf, - &(self->len_smf), - "_common_update_attr_len_smf", - show_err); -} - - -static int -_common_update_attr_len_om1(struct transvr_obj_s *self, - int show_err){ - return _common_update_int_attr(self, - self->eeprom_map_p->addr_len_om1, - self->eeprom_map_p->page_len_om1, - self->eeprom_map_p->offset_len_om1, - self->eeprom_map_p->length_len_om1, - &(self->len_om1), - "_common_update_attr_len_om1", - show_err); -} - -static int -_common_update_attr_len_om2(struct transvr_obj_s *self, - int show_err){ - return _common_update_int_attr(self, - self->eeprom_map_p->addr_len_om2, - self->eeprom_map_p->page_len_om2, - self->eeprom_map_p->offset_len_om2, - self->eeprom_map_p->length_len_om2, - &(self->len_om2), - "_common_update_attr_len_om2", - show_err); -} - -static int -_common_update_attr_len_om3(struct transvr_obj_s *self, - int show_err){ - return _common_update_int_attr(self, - self->eeprom_map_p->addr_len_om3, - self->eeprom_map_p->page_len_om3, - self->eeprom_map_p->offset_len_om3, - self->eeprom_map_p->length_len_om3, - &(self->len_om3), - "_common_update_attr_len_om3", - show_err); -} - - -static int -_common_update_attr_len_om4(struct transvr_obj_s *self, - int show_err){ - return _common_update_int_attr(self, - self->eeprom_map_p->addr_len_om4, - self->eeprom_map_p->page_len_om4, - self->eeprom_map_p->offset_len_om4, - self->eeprom_map_p->length_len_om4, - &(self->len_om4), - "_common_update_attr_len_om4", - show_err); -} - - -static int -_common_update_attr_option(struct transvr_obj_s *self, - int show_err){ - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_option, - self->eeprom_map_p->page_option, - self->eeprom_map_p->offset_option, - self->eeprom_map_p->length_option, - self->option, - "_common_update_attr_option", - show_err); -} - - -static int -_common_update_attr_comp_rev(struct transvr_obj_s *self, - int show_err){ - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_comp_rev, - self->eeprom_map_p->page_comp_rev, - self->eeprom_map_p->offset_comp_rev, - self->eeprom_map_p->length_comp_rev, - &(self->comp_rev), - "_common_update_attr_comp_rev", - show_err); -} - - -static int -_common_update_attr_diag_type(struct transvr_obj_s *self, - int show_err){ - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_diag_type, - self->eeprom_map_p->page_diag_type, - self->eeprom_map_p->offset_diag_type, - self->eeprom_map_p->length_diag_type, - &(self->diag_type), - "_common_update_attr_diag_type", - show_err); -} - - -static int -_common_update_attr_wavelength(struct transvr_obj_s *self, - int show_err){ - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_wavelength, - self->eeprom_map_p->page_wavelength, - self->eeprom_map_p->offset_wavelength, - self->eeprom_map_p->length_wavelength, - self->wavelength, - "_common_update_attr_wavelength", - show_err); -} - - -int -_common_get_option_value(struct transvr_obj_s *self, - int offset, - int bit_shift) { - /* SFP: - * - option[0] = A0h / 64 - * - option[1] = A0h / 65 - * QSFP: - * - option[0] = 00h / 193 - * - option[1] = 00h / 194 - * - option[2] = 00h / 195 - */ - return (self->option[offset] & (1 << bit_shift)); -} - - -static int -_sfp_update_attr_len_sm(struct transvr_obj_s *self, - int show_err){ - return _common_update_int_attr(self, - self->eeprom_map_p->addr_len_sm, - self->eeprom_map_p->page_len_sm, - self->eeprom_map_p->offset_len_sm, - self->eeprom_map_p->length_len_sm, - &(self->len_sm), - "_common_update_attr_len_sm", - show_err); -} - - -static int -_sfp_update_attr_rate_id(struct transvr_obj_s *self, - int show_err){ - return _common_update_int_attr(self, - self->eeprom_map_p->addr_rate_id, - self->eeprom_map_p->page_rate_id, - self->eeprom_map_p->offset_rate_id, - self->eeprom_map_p->length_rate_id, - &(self->rate_id), - "_sfp_update_attr_rate_id", - show_err); -} - - -static int -_sfp_update_attr_soft_rs0(struct transvr_obj_s *self, - int show_err){ - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_soft_rs0, - self->eeprom_map_p->page_soft_rs0, - self->eeprom_map_p->offset_soft_rs0, - self->eeprom_map_p->length_soft_rs0, - &(self->soft_rs0), - "_sfp_update_attr_soft_rs0", - show_err); -} - - -static int -_sfp_update_attr_soft_rs1(struct transvr_obj_s *self, - int show_err){ - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_soft_rs1, - self->eeprom_map_p->page_soft_rs1, - self->eeprom_map_p->offset_soft_rs1, - self->eeprom_map_p->length_soft_rs1, - &(self->soft_rs1), - "_sfp_update_attr_soft_rs1", - show_err); -} - - -int -_sfp_is_diag_support(struct transvr_obj_s *self){ - - uint8_t bit_mask = 0xC0; /* 1100 0000 */ - uint8_t en_val = 0x40; /* 0100 0000 */ - uint8_t checkval = (self->diag_type & bit_mask); - - if (checkval == en_val) { - return 1; - } - return 0; -} - - -static int -_sfp_update_attr_curr_temp(struct transvr_obj_s *self, - int show_err){ - - if (!(_sfp_is_diag_support(self))) { - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_temp, - self->eeprom_map_p->page_temp, - self->eeprom_map_p->offset_temp, - self->eeprom_map_p->length_temp, - self->curr_temp, - "_sfp_update_attr_curr_temp", - show_err); -} - - -static int -_sfp_update_attr_curr_voltage(struct transvr_obj_s *self, - int show_err){ - - if (!(_sfp_is_diag_support(self))) { - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_voltage, - self->eeprom_map_p->page_voltage, - self->eeprom_map_p->offset_voltage, - self->eeprom_map_p->length_voltage, - self->curr_voltage, - "_sfp_update_attr_curr_voltage", - show_err); -} - - -static int -_sfp_update_attr_curr_tx_bias(struct transvr_obj_s *self, - int show_err){ - - if (!(_sfp_is_diag_support(self))) { - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_tx_bias, - self->eeprom_map_p->page_tx_bias, - self->eeprom_map_p->offset_tx_bias, - self->eeprom_map_p->length_tx_bias, - self->curr_tx_bias, - "_sfp_update_attr_curr_tx_bias", - show_err); -} - - -static int -_sfp_update_attr_curr_tx_power(struct transvr_obj_s *self, - int show_err){ - - if (!(_sfp_is_diag_support(self))) { - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_tx_power, - self->eeprom_map_p->page_tx_power, - self->eeprom_map_p->offset_tx_power, - self->eeprom_map_p->length_tx_power, - self->curr_tx_power, - "_sfp_update_attr_curr_tx_power", - show_err); -} - - -static int -_sfp_update_attr_curr_rx_power(struct transvr_obj_s *self, - int show_err){ - - if (!(_sfp_is_diag_support(self))) { - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_rx_power, - self->eeprom_map_p->page_rx_power, - self->eeprom_map_p->offset_rx_power, - self->eeprom_map_p->length_rx_power, - self->curr_rx_power, - "_sfp_update_attr_curr_rx_power", - show_err); -} - - -static int -_sfp_update_attr_rx_em(struct transvr_obj_s *self, - int show_err){ - - if (!_is_transvr_support_ctle(self)) { - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_rx_em, - self->eeprom_map_p->page_rx_em, - self->eeprom_map_p->offset_rx_em, - self->eeprom_map_p->length_rx_em, - self->rx_em, - "_sfp_update_attr_rx_em", - show_err); -} - - -static int -_sfp_update_attr_tx_eq(struct transvr_obj_s *self, - int show_err){ - - if (!_is_transvr_support_ctle(self)) { - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_tx_eq, - self->eeprom_map_p->page_tx_eq, - self->eeprom_map_p->offset_tx_eq, - self->eeprom_map_p->length_tx_eq, - self->tx_eq, - "_sfp_update_attr_tx_eq", - show_err); -} - - -static int -_qsfp_update_attr_cdr(struct transvr_obj_s *self, - int show_err){ - if (self->type != TRANSVR_TYPE_QSFP_28){ - self->cdr = DEBUG_TRANSVR_HEX_VAL; - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_cdr, - self->eeprom_map_p->page_cdr, - self->eeprom_map_p->offset_cdr, - self->eeprom_map_p->length_cdr, - &(self->cdr), - "_common_update_attr_cdr", - show_err); -} - - -static int -_qsfg_update_attr_extbr(struct transvr_obj_s *self, - int show_err) { - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_extbr, - self->eeprom_map_p->page_extbr, - self->eeprom_map_p->offset_extbr, - self->eeprom_map_p->length_extbr, - &(self->extbr), - "_common_update_attr_extbr", - show_err); -} - - -static int -_qsfp_is_diag_support(struct transvr_obj_s *self, - int diag_type) { - /* Input Parm: diag_type - * => 1 : temperature - * => 2 : voltage - * => 3 : tx relate - * => 4 : rx relate - */ - uint8_t mask_b2 = 0x04; /* 0000 0100 */ - uint8_t mask_b3 = 0x08; /* 0000 1000 */ - - switch (diag_type) { - case 1: /* temperature */ - case 2: /* voltage */ - /* Direct access target, because of spec not defined */ - return 1; - case 3: - case 4: - /* [Note] - * Due to lot of transceiver vendor defined it not rigorously and - * consider of general support, we seem it as supported if there - * are bit-2 OR bit-3 defined by transceiver vendor. - */ - if ( ((self->diag_type & mask_b2) == mask_b2 ) || - ((self->diag_type & mask_b3) == mask_b3 ) ){ - return 1; - } - return 0; - default: - SWPS_INFO("%s: undefined diag_type:%d\n", - __func__, diag_type); - break; - } - return 0; -} - - -int -_qsfp_is_implement_tx_disable(struct transvr_obj_s *self) { - /* - * 00h / Byte-195 / Bit-4 - */ - int byte = 2; - int bit = 4; - return _common_get_option_value(self, byte, bit); -} - - -int -_qsfp_is_implement_tx_fault(struct transvr_obj_s *self) { - /* - * 00h / Byte-195 / Bit-3 - */ - int byte = 2; - int bit = 3; - return _common_get_option_value(self, byte, bit); -} - - -static int -_qsfp_update_attr_curr_temp(struct transvr_obj_s *self, - int show_err){ - int diag_type = 1; - - if (!(_qsfp_is_diag_support(self, diag_type))) { - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_temp, - self->eeprom_map_p->page_temp, - self->eeprom_map_p->offset_temp, - self->eeprom_map_p->length_temp, - self->curr_temp, - "_qsfp_update_attr_curr_temp", - show_err); -} - - -static int -_qsfp_update_attr_curr_voltage(struct transvr_obj_s *self, - int show_err){ - int diag_type = 2; - - if (!(_qsfp_is_diag_support(self, diag_type))) { - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_voltage, - self->eeprom_map_p->page_voltage, - self->eeprom_map_p->offset_voltage, - self->eeprom_map_p->length_voltage, - self->curr_voltage, - "_qsfp_update_attr_curr_voltage", - show_err); -} - - -static int -_qsfp_update_attr_curr_tx_bias(struct transvr_obj_s *self, - int show_err){ - int diag_type = 3; - - if (!(_qsfp_is_diag_support(self, diag_type))) { - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_tx_bias, - self->eeprom_map_p->page_tx_bias, - self->eeprom_map_p->offset_tx_bias, - self->eeprom_map_p->length_tx_bias, - self->curr_tx_bias, - "_qsfp_update_attr_curr_tx_bias", - show_err); -} - - -static int -_qsfp_update_attr_curr_tx_power(struct transvr_obj_s *self, - int show_err){ - int diag_type = 3; - - if (!(_qsfp_is_diag_support(self, diag_type))) { - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_tx_power, - self->eeprom_map_p->page_tx_power, - self->eeprom_map_p->offset_tx_power, - self->eeprom_map_p->length_tx_power, - self->curr_tx_power, - "_qsfp_update_attr_curr_tx_power", - show_err); -} - - -static int -_qsfp_update_attr_curr_rx_power(struct transvr_obj_s *self, - int show_err){ - int diag_type = 4; - - if (!(_qsfp_is_diag_support(self, diag_type))) { - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_rx_power, - self->eeprom_map_p->page_rx_power, - self->eeprom_map_p->offset_rx_power, - self->eeprom_map_p->length_rx_power, - self->curr_rx_power, - "_qsfp_update_attr_curr_rx_power", - show_err); -} - - -static int -_qsfp_update_attr_soft_rx_los(struct transvr_obj_s *self, - int show_err){ - - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_rx_los, - self->eeprom_map_p->page_rx_los, - self->eeprom_map_p->offset_rx_los, - self->eeprom_map_p->length_rx_los, - &(self->rx_los), - "_qsfp_update_attr_soft_rx_los", - show_err); -} - - -static int -_qsfp_update_attr_soft_tx_disable(struct transvr_obj_s *self, - int show_err){ - - if (!_qsfp_is_implement_tx_disable(self)) { - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_tx_disable, - self->eeprom_map_p->page_tx_disable, - self->eeprom_map_p->offset_tx_disable, - self->eeprom_map_p->length_tx_disable, - &(self->tx_disable), - "_qsfp_update_attr_soft_tx_disable", - show_err); -} - - -static int -_qsfp_update_attr_soft_tx_fault(struct transvr_obj_s *self, - int show_err){ - - if (!_qsfp_is_implement_tx_fault(self)) { - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_tx_fault, - self->eeprom_map_p->page_tx_fault, - self->eeprom_map_p->offset_tx_fault, - self->eeprom_map_p->length_tx_fault, - &(self->tx_fault), - "_qsfp_update_attr_soft_tx_fault", - show_err); -} - - -static int -_qsfp_update_attr_tx_eq(struct transvr_obj_s *self, - int show_err){ - - if (!_is_transvr_support_ctle(self)) { - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_tx_eq, - self->eeprom_map_p->page_tx_eq, - self->eeprom_map_p->offset_tx_eq, - self->eeprom_map_p->length_tx_eq, - self->tx_eq, - "_qsfp_update_attr_tx_eq", - show_err); -} - - -static int -_qsfp_update_attr_rx_am(struct transvr_obj_s *self, - int show_err){ - - if (!_is_transvr_support_ctle(self)) { - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_rx_am, - self->eeprom_map_p->page_rx_am, - self->eeprom_map_p->offset_rx_am, - self->eeprom_map_p->length_rx_am, - self->rx_am, - "_qsfp_update_attr_rx_am", - show_err); -} - - -static int -_qsfp_update_attr_rx_em(struct transvr_obj_s *self, - int show_err){ - - if (!_is_transvr_support_ctle(self)) { - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_rx_em, - self->eeprom_map_p->page_rx_em, - self->eeprom_map_p->offset_rx_em, - self->eeprom_map_p->length_rx_em, - self->rx_em, - "_qsfp_update_attr_rx_em", - show_err); -} - - -int -_common_update_attr_all(struct transvr_obj_s *self, - int show_err){ - - char *err_str = "err"; - - if (_common_update_attr_id(self, show_err) < 0) { - err_str = "_common_update_attr_id"; - goto err_common_update_attr_all; - } - if (_common_update_attr_eeprom(self, show_err) < 0) { - err_str = "_common_update_attr_eeprom"; - goto err_common_update_attr_all; - } - if (_common_update_attr_extended_id(self, show_err) < 0) { - err_str = "_common_update_attr_extended_id"; - goto err_common_update_attr_all; - } - if (_common_update_attr_connector(self, show_err) < 0) { - err_str = "_common_update_attr_connector"; - goto err_common_update_attr_all; - } - if (_common_update_attr_transvr_comp(self, show_err) < 0) { - err_str = "_common_update_attr_transvr_comp"; - goto err_common_update_attr_all; - } - if (_common_update_attr_transvr_comp_ext(self, show_err) < 0) { - err_str = "_common_update_attr_transvr_comp_ext"; - goto err_common_update_attr_all; - } - if (_common_update_attr_vendor_name(self, show_err) < 0) { - err_str = "_common_update_attr_vendor_name"; - goto err_common_update_attr_all; - } - if (_common_update_attr_vendor_pn(self, show_err) < 0) { - err_str = "_common_update_attr_vendor_pn"; - goto err_common_update_attr_all; - } - if (_common_update_attr_vendor_rev(self, show_err) < 0) { - err_str = "_common_update_attr_vendor_rev"; - goto err_common_update_attr_all; - } - if (_common_update_attr_vendor_sn(self, show_err) < 0) { - err_str = "_common_update_attr_vendor_sn"; - goto err_common_update_attr_all; - } - if (_common_update_attr_br(self, show_err) < 0) { - err_str = "_common_update_attr_br"; - goto err_common_update_attr_all; - } - if (_common_update_attr_len_smf(self, show_err) < 0) { - err_str = "_common_update_attr_len_smf"; - goto err_common_update_attr_all; - } - if (_common_update_attr_len_om1(self, show_err) < 0) { - err_str = "_common_update_attr_len_om1"; - goto err_common_update_attr_all; - } - if (_common_update_attr_len_om2(self, show_err) < 0) { - err_str = "_common_update_attr_len_om2"; - goto err_common_update_attr_all; - } - if (_common_update_attr_len_om3(self, show_err) < 0) { - err_str = "_common_update_attr_len_om3"; - goto err_common_update_attr_all; - } - if (_common_update_attr_len_om4(self, show_err) < 0) { - err_str = "_common_update_attr_len_om4"; - goto err_common_update_attr_all; - } - if (_common_update_attr_option(self, show_err) < 0) { - err_str = "_common_update_attr_option"; - goto err_common_update_attr_all; - } - if (_common_update_attr_comp_rev(self, show_err) < 0) { - err_str = "_common_update_attr_comp_rev"; - goto err_common_update_attr_all; - } - if (_common_update_attr_diag_type(self, show_err) < 0) { - err_str = "_common_update_attr_diag_type"; - goto err_common_update_attr_all; - } - if (_common_update_attr_wavelength(self, show_err) < 0) { - err_str = "_common_update_attr_wavelength"; - goto err_common_update_attr_all; - } - return 0; - -err_common_update_attr_all: - if (show_err){ - SWPS_INFO("%s: fail at:%s :%s\n", __func__, err_str, self->swp_name); - } - return -1; -} - - -int -_sfp_update_attr_all(struct transvr_obj_s *self, - int show_err){ - - char *err_str = DEBUG_TRANSVR_STR_VAL; - - if (_common_update_attr_all(self, show_err) < 0){ - err_str = "_common_update_attr_all"; - goto err_sfp_update_attr_all; - } - if (_sfp_update_attr_len_sm(self, show_err) < 0) { - err_str = "_sfp_update_attr_len_sm"; - goto err_sfp_update_attr_all; - } - if (_sfp_update_attr_rate_id(self, show_err) < 0) { - err_str = "_sfp_update_attr_rate_id"; - goto err_sfp_update_attr_all; - } - if ((self->rate_id) > 0) { - if (_sfp_update_attr_soft_rs0(self, show_err) < 0) { - err_str = "_sfp_update_attr_soft_rs0"; - goto err_sfp_update_attr_all; - } - if (_sfp_update_attr_soft_rs1(self, show_err) < 0) { - err_str = "_sfp_update_attr_soft_rs1"; - goto err_sfp_update_attr_all; - } - } - return 0; - -err_sfp_update_attr_all: - if (show_err){ - SWPS_INFO("%s: fail at:%s :%s\n", __func__, err_str, self->swp_name); - } - return -1; -} - - -int -_qsfp_update_attr_all(struct transvr_obj_s *self, - int show_err){ - - char *err_str = DEBUG_TRANSVR_STR_VAL; - - if (_common_update_attr_all(self, show_err) < 0){ - err_str = "_common_update_attr_all"; - goto err_qsfp_update_attr_all; - } - if (_qsfg_update_attr_extbr(self, show_err) < 0) { - err_str = "_qsfg_update_attr_extbr"; - goto err_qsfp_update_attr_all; - } - if (self->type == TRANSVR_TYPE_QSFP_28) { - if (_qsfp_update_attr_cdr(self, 1) < 0) { - err_str = "_qsfp_update_attr_cdr"; - goto err_qsfp_update_attr_all; - } - } - return 0; - -err_qsfp_update_attr_all: - if (show_err){ - SWPS_INFO("%s: fail at:%s :%s\n", __func__, err_str, self->swp_name); - } - return -1; -} - - -/* ========== Object functions for common type ========== - */ -int -_common_count_temp(uint8_t high_byte, - uint8_t low_byte, - char *buf_p) { - int sign = 0; - int high = 0; - int low = 0; - int lmax = 8; - - /* Count high */ - sign = get_bit(high_byte,7); - SWP_BIT_CLEAR(high_byte, 7); - high = (int)high_byte; - if (sign == 1) { - high = 0 - high; - } - /* Count low */ - low = (get_bit(low_byte, 7) * 500); - low += (get_bit(low_byte, 6) * 250); - low += (get_bit(low_byte, 5) * 125); - low += (get_bit(low_byte, 4) * 62); - low = (low / 100); - /* Integrate High and Low */ - return snprintf(buf_p, lmax, "%d.%d\n", high, low); -} - - -int -_common_count_voltage(uint8_t high_byte, - uint8_t low_byte, - char *buf_p) { - /* [Note]: - * Internally measured transceiver supply voltage. Represented - * as a 16 bit unsigned integer with the voltage defined as the - * full 16 bit value (0-65535) with LSB equal to 100 uVolt, - * yielding a total range of 0 to +6.55 Volts. Practical - * considerations to be defined by transceiver manufacturer will - * tend to limit the actual bounds of the supply voltage measurement. - * Accuracy is vendor specific but must be better than 3% of the - * manufacturer's nominal value over specified operating temperature - * and voltage. Note that in some transceivers, transmitter supply - * voltage and receiver supply voltage are isolated. In that case, - * only one supply is monitored. Refer to the device specification - * for more detail. - */ - int total = 0; - int lmax = 8; - int val_i = 0; - int val_f = 0; - /* unit: 100 uV (1mV=1000uV) */ - total = transform_word_to_int(high_byte, low_byte); - val_i = ((total/10) / 1000); - val_f = ((total/10) - (val_i*1000)); - /* Return Unit: 1 Volt */ - return snprintf(buf_p, lmax, "%d.%03d\n", val_i, val_f); -} - - -int -_common_count_tx_bias(uint8_t high_byte, - uint8_t low_byte, - char *buf_p) { - /* [Note] - * Measured TX bias current in uA. Represented as a 16 bit unsigned - * integer with the current defined as the full 16 bit value (0-65535) - * with LSB equal to 2 uA, yielding a total range of 0 to 131 mA. - * Accuracy is vendor specific but must be better than 10% of the - * manufacturer's nominal value over specified operating temperature - * and voltage. - */ - int total = 0; - int lmax = 8; - int val_i = 0; - int val_f = 0; - /* unit: 2 uA (1mA=1000uA) */ - total = transform_word_to_int(high_byte, low_byte); - val_i = ((total*2) / 1000); - val_f = (((total*2) - (val_i*1000)) / 100); - /* Return Unit: 1 mA */ - return snprintf(buf_p, lmax, "%d.%01d\n", val_i, val_f); -} - - -int -_common_count_tx_power(uint8_t high_byte, - uint8_t low_byte, - char *buf_p) { - /* [Note] - * Measured TX output power in mW. Represented as a 16 bit unsigned - * integer with the power defined as the full 16 bit value (0-65535) - * with LSB equal to 0.1 uW, yielding a total range of 0 to 6.5535 mW - * (~ -40 to +8.2 dBm). Data is assumed to be based on measurement of - * laser monitor photodiode current. It is factory calibrated to absolute - * units using the most representative fiber output type. Accuracy is - * vendor specific but must be better than 3dB over specified temperature - * and voltage. Data is not valid when the transmitter is disabled. - */ - int total = 0; - int lmax = 8; - int val_i = 0; - int val_f = 0; - /* unit: 0.1 uW (1mW=1000uW) */ - total = transform_word_to_int(high_byte, low_byte); - val_i = ((total/10) / 1000); - val_f = ((total/10) - (val_i*1000)); - /* Return Unit: 1 mW */ - return snprintf(buf_p, lmax, "%d.%03d\n", val_i, val_f); -} - - -int -_common_count_rx_power(uint8_t high_byte, - uint8_t low_byte, - char *buf_p) { - /* [Note] - * Measured RX received optical power in mW. Value can represent either - * average received power or OMA depending upon how bit 3 of byte 92 (A0h) - * is set. Represented as a 16 bit unsigned integer with the power defined - * as the full 16 bit value (0-65535) with LSB equal to 0.1 uW, yielding a - * total range of 0 to 6.5535 mW (~ -40 to +8.2 dBm). Absolute accuracy is - * dependent upon the exact optical wavelength. For the vendor specified - * wavelength, accuracy shall be better than 3dB over specified temperature - * and voltage. - */ - int total = 0; - int lmax = 8; - int val_i = 0; - int val_f = 0; - /* unit: 0.1 uW (1mW=1000uW) */ - total = transform_word_to_int(high_byte, low_byte); - val_i = ((total/10) / 1000); - val_f = ((total/10) - (val_i*1000)); - /* Return Unit: 1 mW */ - return snprintf(buf_p, lmax, "%d.%03d\n", val_i, val_f); -} - - -int -_common_count_wavelength(struct transvr_obj_s *self, - uint8_t high_byte, - uint8_t low_byte) { - /* [Note] - * SFP : uint 1 um. - * QSFP: unit 0.05 um. - */ - int total = 0; - - total = transform_word_to_int(high_byte, low_byte); - switch (self->type) { - case TRANSVR_TYPE_SFP: - return total; - - case TRANSVR_TYPE_QSFP: - case TRANSVR_TYPE_QSFP_PLUS: - case TRANSVR_TYPE_QSFP_28: - return (total/20); - - default: - break; - } - return ERR_TRANSVR_UNDEFINED; -} - - -int -common_get_id(struct transvr_obj_s *self){ - - int err_code = _check_by_mode(self, - &_common_update_attr_id, - "common_get_id"); - if (err_code < 0){ - return err_code; - } - /* Transform to INT to show error case */ - return (int)self->id; -} - - -int -common_get_ext_id(struct transvr_obj_s *self){ - - int err_code = _check_by_mode(self, - &_common_update_attr_extended_id, - "common_get_ext_id"); - if (err_code < 0){ - return err_code; - } - /* Transform to INT to show error case */ - return (int)self->ext_id; -} - - -int -common_get_connector(struct transvr_obj_s *self){ - - int err_code = _check_by_mode(self, - &_common_update_attr_connector, - "common_get_connector"); - if (err_code < 0){ - return err_code; - } - /* Transform to INT to show error case */ - return (int)self->connector; -} - -int -common_get_eeprom(struct transvr_obj_s *self, char *buf){ - - int err = DEBUG_TRANSVR_INT_VAL; - unsigned char *eeprom_update = get_eeprom_update(); - - if (!(eeprom_update[self->port_no/8] & (1 << self->port_no%8)) && - (self->state == STATE_TRANSVR_CONNECTED && - self->mode == TRANSVR_MODE_POLLING && - TRANSVR_INFO_CACHE_ENABLE)) { - memset(buf, 0, self->eeprom_map_p->length_eeprom); - memcpy(buf, self->eeprom, self->eeprom_map_p->length_eeprom); - *(buf+self->eeprom_map_p->length_eeprom) = '\n'; - return self->eeprom_map_p->length_eeprom; - } - err = _check_by_mode(self, &_common_update_attr_eeprom, - "common_get_eeprom"); - if (err < 0){ - return snprintf(buf, LEN_TRANSVR_M_STR, "%d\n", err); - } - memset(buf, 0, self->eeprom_map_p->length_eeprom); - memcpy(buf, self->eeprom, self->eeprom_map_p->length_eeprom); - *(buf+self->eeprom_map_p->length_eeprom) = '\n'; - eeprom_update[self->port_no/8] &= ~(1 << self->port_no%8); - set_eeprom_update(eeprom_update); - return self->eeprom_map_p->length_eeprom; -} - - -int -common_get_vendor_name(struct transvr_obj_s *self, char *buf){ - - int err = DEBUG_TRANSVR_INT_VAL; - - if (self->state == STATE_TRANSVR_CONNECTED && - self->mode == TRANSVR_MODE_POLLING && - TRANSVR_INFO_CACHE_ENABLE) { - return snprintf(buf, LEN_TRANSVR_M_STR, "%s\n", self->vendor_name); - } - err = _check_by_mode(self, - &_common_update_attr_vendor_name, - "common_get_vendor_name"); - memset(buf, 0, LEN_TRANSVR_M_STR); - if (err < 0){ - return snprintf(buf, LEN_TRANSVR_M_STR, "%d\n", err); - } - return snprintf(buf, LEN_TRANSVR_M_STR, "%s\n", self->vendor_name); -} - - -int -common_get_vendor_pn(struct transvr_obj_s *self, char *buf) { - - int err = DEBUG_TRANSVR_INT_VAL; - - if (self->state == STATE_TRANSVR_CONNECTED && - self->mode == TRANSVR_MODE_POLLING && - TRANSVR_INFO_CACHE_ENABLE) { - return snprintf(buf, LEN_TRANSVR_M_STR, "%s\n", self->vendor_pn); - } - err = _check_by_mode(self, - &_common_update_attr_vendor_pn, - "common_get_vendor_pn"); - memset(buf, 0, LEN_TRANSVR_M_STR); - if (err < 0){ - return snprintf(buf, LEN_TRANSVR_M_STR, "%d\n", err); - } - return snprintf(buf, LEN_TRANSVR_M_STR, "%s\n", self->vendor_pn); -} - - -int -common_get_vendor_rev(struct transvr_obj_s *self, char *buf) { - - int err = DEBUG_TRANSVR_INT_VAL; - - if (self->state == STATE_TRANSVR_CONNECTED && - self->mode == TRANSVR_MODE_POLLING && - TRANSVR_INFO_CACHE_ENABLE) { - return snprintf(buf, LEN_TRANSVR_M_STR, "%s\n", self->vendor_rev); - } - err = _check_by_mode(self, - &_common_update_attr_vendor_rev, - "common_get_vendor_rev"); - memset(buf, 0, LEN_TRANSVR_M_STR); - if (err < 0){ - return snprintf(buf, LEN_TRANSVR_M_STR, "%d\n", err); - } - return snprintf(buf, LEN_TRANSVR_M_STR, "%s\n", self->vendor_rev); -} - - -int -common_get_vendor_sn(struct transvr_obj_s *self, char *buf) { - - int err = DEBUG_TRANSVR_INT_VAL; - - if (self->state == STATE_TRANSVR_CONNECTED && - self->mode == TRANSVR_MODE_POLLING && - TRANSVR_INFO_CACHE_ENABLE) { - return snprintf(buf, LEN_TRANSVR_M_STR, "%s\n", self->vendor_sn); - } - err = _check_by_mode(self, - &_common_update_attr_vendor_sn, - "common_get_vendor_sn"); - memset(buf, 0, LEN_TRANSVR_M_STR); - if (err < 0){ - return snprintf(buf, LEN_TRANSVR_M_STR, "%d\n", err); - } - return snprintf(buf, LEN_TRANSVR_M_STR, "%s\n", self->vendor_sn); -} - - -int -common_get_br(struct transvr_obj_s *self){ - - int err = DEBUG_TRANSVR_INT_VAL; - - if (self->state == STATE_TRANSVR_CONNECTED && - self->mode == TRANSVR_MODE_POLLING && - TRANSVR_INFO_CACHE_ENABLE) { - return (int)self->br; - } - err = _check_by_mode(self, - &_common_update_attr_br, - "common_get_br"); - if (err < 0){ - return err; - } - /* Transform to INT to show error case */ - return (int)self->br; -} - - -int -common_get_len_smf(struct transvr_obj_s *self){ - - int err = DEBUG_TRANSVR_INT_VAL; - - if (self->state == STATE_TRANSVR_CONNECTED && - self->mode == TRANSVR_MODE_POLLING && - TRANSVR_INFO_CACHE_ENABLE) { - return self->len_smf; - } - err = _check_by_mode(self, - &_common_update_attr_len_smf, - "common_get_len_smf"); - if (err < 0){ - return err; - } - return self->len_smf; -} - - -int -common_get_len_om1(struct transvr_obj_s *self){ - - int err = DEBUG_TRANSVR_INT_VAL; - - if (self->state == STATE_TRANSVR_CONNECTED && - self->mode == TRANSVR_MODE_POLLING && - TRANSVR_INFO_CACHE_ENABLE) { - return self->len_om1; - } - err = _check_by_mode(self, - &_common_update_attr_len_om1, - "common_get_len_om1"); - if (err < 0){ - return err; - } - return self->len_om1; -} - - -int -common_get_len_om2(struct transvr_obj_s *self){ - - int err = DEBUG_TRANSVR_INT_VAL; - - if (self->state == STATE_TRANSVR_CONNECTED && - self->mode == TRANSVR_MODE_POLLING && - TRANSVR_INFO_CACHE_ENABLE) { - return self->len_om2; - } - - err = _check_by_mode(self, - &_common_update_attr_len_om2, - "common_get_len_om2"); - if (err < 0){ - return err; - } - return self->len_om2; -} - - -int -common_get_len_om3(struct transvr_obj_s *self){ - - int err = DEBUG_TRANSVR_INT_VAL; - - if (self->state == STATE_TRANSVR_CONNECTED && - self->mode == TRANSVR_MODE_POLLING && - TRANSVR_INFO_CACHE_ENABLE) { - return self->len_om3; - } - - err = _check_by_mode(self, - &_common_update_attr_len_om3, - "common_get_len_om3"); - if (err < 0){ - return err; - } - return self->len_om3; -} - - -int -common_get_len_om4(struct transvr_obj_s *self){ - - int err = DEBUG_TRANSVR_INT_VAL; - - if (self->state == STATE_TRANSVR_CONNECTED && - self->mode == TRANSVR_MODE_POLLING && - TRANSVR_INFO_CACHE_ENABLE) { - return self->len_om4; - } - err = _check_by_mode(self, - &_common_update_attr_len_om4, - "common_get_len_om4"); - if (err < 0){ - return err; - } - return self->len_om4; -} - - -int -common_get_comp_extended(struct transvr_obj_s *self){ - - int err_code = _check_by_mode(self, - &_common_update_attr_transvr_comp_ext, - "common_get_comp_extended"); - if (err_code < 0){ - return err_code; - } - return self->transvr_comp_ext; -} - - -int -common_get_comp_rev(struct transvr_obj_s *self){ - - int err_code = _check_by_mode(self, - &_common_update_attr_comp_rev, - "common_get_comp_rev"); - if (err_code < 0){ - return err_code; - } - return self->comp_rev; -} - - -int -common_get_info(struct transvr_obj_s *self){ - - if (self->state != STATE_TRANSVR_CONNECTED) { - return self->state; - } - return self->info; -} - - -int -_common_get_if_lane(struct transvr_obj_s *self, - char *result){ - int i = 0; - int tmp_val = 0; - char tmp_str[LEN_TRANSVR_M_STR] = DEBUG_TRANSVR_STR_VAL; - - memset(result, 0, LEN_TRANSVR_M_STR); - - for (i=0; ilane_id); i++) { - tmp_val = self->lane_id[i]; - if (tmp_val < 1) { - break; - } - memset(tmp_str, 0, LEN_TRANSVR_M_STR); - if (i == 0) { - snprintf(tmp_str, LEN_TRANSVR_M_STR, "%d", tmp_val); - } else { - snprintf(tmp_str, LEN_TRANSVR_M_STR, ",%d", tmp_val); - } - strncat(result, tmp_str, LEN_TRANSVR_M_STR); - } - if (i == 0) { - return EVENT_TRANSVR_TASK_FAIL; - } - return 0; -} - - -int -common_get_if_lane(struct transvr_obj_s *self, - char *buf_p){ - - char tmp_str[LEN_TRANSVR_M_STR] = DEBUG_TRANSVR_STR_VAL; - - if (self->ioexp_obj_p->state != STATE_IOEXP_NORMAL) { - return snprintf(buf_p, LEN_TRANSVR_M_STR, "%d\n", ERR_TRANSVR_ABNORMAL); - } - if (_common_get_if_lane(self, tmp_str) < 0) { - return snprintf(buf_p, LEN_TRANSVR_M_STR, "%d\n" ,ERR_TRANSVR_ABNORMAL); - } - return snprintf(buf_p, LEN_TRANSVR_M_STR, "%s\n" ,tmp_str); -} - - -int -sfp_get_len_sm(struct transvr_obj_s *self){ - - int err_code = _check_by_mode(self, - &_sfp_update_attr_len_sm, - "sfp_get_len_sm"); - if (err_code < 0){ - return err_code; - } - return self->len_sm; -} - - -int -sfp_get_rate_id(struct transvr_obj_s *self){ - - int err_code = _check_by_mode(self, - &_sfp_update_attr_rate_id, - "sfp_get_rate_id"); - if (err_code < 0){ - return err_code; - } - return self->rate_id; -} - - -int -sfp_get_soft_rs0(struct transvr_obj_s *self){ - /* Note: - * SFP Soft Rate_Select Select [aka. "RS(0)"] address - * A2h, offset: 110, bit 3 (begin form 0) - */ - int err_code = DEBUG_TRANSVR_INT_VAL; - int bit_shift = 3; - uint8_t result = 0x00; - uint8_t bitmask = (1 << bit_shift); - - /* Check rate identifier is supported */ - err_code = self->get_rate_id(self); - if (err_code <= 0) { - return ERR_TRANSVR_NOTSUPPORT; - } - /* Update and check */ - err_code = _check_by_mode(self, - &_sfp_update_attr_soft_rs0, - "sfp_get_soft_rs0"); - if (err_code <0){ - return err_code; - } - result = (self->soft_rs0 & bitmask); - if (result == bitmask) { - return 1; - } - if (result == 0) { - return 0; - } - return ERR_TRANSVR_UNEXCPT; -} - - -int -sfp_get_soft_rs1(struct transvr_obj_s *self){ - /* Note: - * SFP Soft RS(1) Select address - * A2h, offset: 118, bit 3 (begin form 0) - */ - int err_code = DEBUG_TRANSVR_INT_VAL; - int bit_shift = 3; - uint8_t result = 0x00; - uint8_t bitmask = (1 << bit_shift); - - /* Check rate identifier is supported */ - err_code = self->get_rate_id(self); - if (err_code <= 0) { - return ERR_TRANSVR_NOTSUPPORT; - } - /* Update and check */ - err_code = _check_by_mode(self, - &_sfp_update_attr_soft_rs1, - "sfp_get_soft_rs1"); - if (err_code <0){ - return err_code; - } - result = (self->soft_rs1 & bitmask); - if (result == bitmask) { - return 1; - } - if (result == 0) { - return 0; - } - return ERR_TRANSVR_UNEXCPT; -} - - -int -sfp_get_transvr_temp(struct transvr_obj_s *self, - char *buf_p) { - - int lmax = 8; - int err_code = DEBUG_TRANSVR_INT_VAL; - - err_code = _check_by_mode(self, - &_sfp_update_attr_curr_temp, - "sfp_get_transvr_temp"); - if (err_code < 0) { - return snprintf(buf_p, lmax, "%d\n", err_code); - } - if ((self->curr_temp[0]) == DEBUG_TRANSVR_HEX_VAL) { - return snprintf(buf_p, lmax, "%d\n", ERR_TRANSVR_UPDATE_FAIL); - } - return _common_count_temp(self->curr_temp[0], - self->curr_temp[1], - buf_p); -} - - -int -sfp_get_transvr_voltage(struct transvr_obj_s *self, - char *buf_p) { - - int lmax = 8; - int err_code = DEBUG_TRANSVR_INT_VAL; - - err_code = _check_by_mode(self, - &_sfp_update_attr_curr_voltage, - "sfp_get_transvr_voltage"); - if (err_code < 0) { - return snprintf(buf_p, lmax, "%d\n", err_code); - } - if ((self->curr_voltage[0]) == DEBUG_TRANSVR_HEX_VAL) { - return snprintf(buf_p, lmax, "%d\n", ERR_TRANSVR_UPDATE_FAIL); - } - /* Return Unit: 1 Volt */ - return _common_count_voltage(self->curr_voltage[0], - self->curr_voltage[1], - buf_p); -} - - -int -sfp_get_transvr_tx_bias(struct transvr_obj_s *self, - char *buf_p) { - - int lmax = 8; - int err_code = DEBUG_TRANSVR_INT_VAL; - - err_code = _check_by_mode(self, - &_sfp_update_attr_curr_tx_bias, - "sfp_get_transvr_tx_bias"); - if (err_code < 0) { - return snprintf(buf_p, lmax, "%d\n", err_code); - } - if ((self->curr_tx_bias[0]) == DEBUG_TRANSVR_HEX_VAL) { - return snprintf(buf_p, lmax, "%d\n", ERR_TRANSVR_UPDATE_FAIL); - } - /* Return Unit: 1 mA */ - return _common_count_tx_bias(self->curr_tx_bias[0], - self->curr_tx_bias[1], - buf_p); -} - - -int -sfp_get_transvr_tx_power(struct transvr_obj_s *self, - char *buf_p) { - - int lmax = 8; - int err_code = DEBUG_TRANSVR_INT_VAL; - - err_code = _check_by_mode(self, - &_sfp_update_attr_curr_tx_power, - "sfp_get_transvr_tx_power"); - if (err_code < 0) { - return snprintf(buf_p, lmax, "%d\n", err_code); - } - if ((self->curr_tx_bias[0]) == DEBUG_TRANSVR_HEX_VAL) { - return snprintf(buf_p, lmax, "%d\n", ERR_TRANSVR_UPDATE_FAIL); - } - /* Return Unit: 1 mW */ - return _common_count_tx_power(self->curr_tx_power[0], - self->curr_tx_power[1], - buf_p); -} - - -int -sfp_get_transvr_rx_power(struct transvr_obj_s *self, - char *buf_p) { - - int lmax = 8; - int err_code = DEBUG_TRANSVR_INT_VAL; - - err_code = _check_by_mode(self, - &_sfp_update_attr_curr_rx_power, - "sfp_get_transvr_rx_power"); - if (err_code < 0) { - return snprintf(buf_p, lmax, "%d\n", err_code); - } - if ((self->curr_tx_bias[0]) == DEBUG_TRANSVR_HEX_VAL) { - return snprintf(buf_p, lmax, "%d\n", ERR_TRANSVR_UPDATE_FAIL); - } - /* Return Unit: 1 mW */ - return _common_count_rx_power(self->curr_rx_power[0], - self->curr_rx_power[0], - buf_p); -} - - -int -sfp_get_transvr_rx_em(struct transvr_obj_s *self, - char *buf_p) { - - int limt = 8; - int err = DEBUG_TRANSVR_INT_VAL; - - err = _check_by_mode(self, - &_sfp_update_attr_rx_em, - "sfp_get_transvr_rx_em"); - if (err < 0) { - return snprintf(buf_p, limt, "%d\n", err); - } - if ((self->tx_eq[0]) == DEBUG_TRANSVR_HEX_VAL) { - return snprintf(buf_p, limt, "%d\n", ERR_TRANSVR_UPDATE_FAIL); - } - return snprintf(buf_p, limt, "0x%02x\n", self->rx_em[0]); -} - - -int -sfp_get_transvr_tx_eq(struct transvr_obj_s *self, - char *buf_p) { - - int limt = 8; - int err = DEBUG_TRANSVR_INT_VAL; - - err = _check_by_mode(self, - &_sfp_update_attr_tx_eq, - "sfp_get_transvr_tx_eq"); - if (err < 0) { - return snprintf(buf_p, limt, "%d\n", err); - } - if ((self->tx_eq[0]) == DEBUG_TRANSVR_HEX_VAL) { - return snprintf(buf_p, limt, "%d\n", ERR_TRANSVR_UPDATE_FAIL); - } - return snprintf(buf_p, limt, "0x%02x\n", self->tx_eq[0]); -} - - -int -_sfp_get_comp_extended(struct transvr_obj_s *self) { - /* Address: A0h / 36 - * Reference: SFF-8024 TABLE 4-4 - */ - if ((self->state == STATE_TRANSVR_CONNECTED) || - (self->state == STATE_TRANSVR_INIT) ) { - return (int)(self->transvr_comp_ext); - } - return ERR_TRANSVR_ABNORMAL; -} - - -int -__sfp_get_comp_attr(struct transvr_obj_s *self, - int array_offset) { - /* SFP Specification Compliance: A0h / 3-10 - * transvr_comp[0-7] = 3 - 10 - */ - if ((self->state == STATE_TRANSVR_CONNECTED) || - (self->state == STATE_TRANSVR_INIT) ) { - return (int)(self->transvr_comp[array_offset]); - } - return ERR_TRANSVR_ABNORMAL; -} - - -int -_sfp_get_comp_10g_eth_comp(struct transvr_obj_s *self) { - /* transvr_comp[0] = address A0h / 3 - * - * 3 7: 10G Base-ER - * 3 6: 10GBASE-LRM - * 3 5: 10GBASE-LR - * 3 4: 10GBASE-SR - */ - int bitmask = 0xf0; /* 11110000 */ - return (__sfp_get_comp_attr(self, 0) & bitmask); -} - - -int -_sfp_get_comp_1g_eth_comp(struct transvr_obj_s *self) { - /* transvr_comp[3] = address A0h / 6 - * - * 6 7: BASE-PX *3 - * 6 6: BASE-BX10 *3 - * 6 5: 100BASE-FX - * 6 4: 100BASE-LX/LX10 - * 6 3: 1000BASE-T - * 6 2: 1000BASE-CX - * 6 1: 1000BASE-LX *3 - * 6 0: 1000BASE-SX - */ - return __sfp_get_comp_attr(self, 3); -} - - -int -_sfp_get_cable_tech(struct transvr_obj_s *self) { - /* transvr_comp[5] = address A0h / 8 - * - * 8 3: Active Cable *8 - * 8 2: Passive Cable *8 - */ - int bitmask = 0x0c; /* 00001100 */ - return (__sfp_get_comp_attr(self, 5) & bitmask); -} - - -int -sfp_get_comp_eth_1(struct transvr_obj_s *self){ - - int err_code = _check_by_mode(self, - &_common_update_attr_transvr_comp, - "sfp_get_comp_eth_1"); - if (err_code < 0){ - return err_code; - } - return _sfp_get_comp_1g_eth_comp(self); -} - - -int -sfp_get_comp_eth_10(struct transvr_obj_s *self){ - - int err_code = _check_by_mode(self, - &_common_update_attr_transvr_comp, - "sfp_get_comp_eth_10"); - if (err_code < 0){ - return err_code; - } - return _sfp_get_comp_10g_eth_comp(self); -} - - -int -_sfp_get_connector_type(struct transvr_obj_s *self) { - /* Address: A0h / 2 - * Reference: SFF-8024 TABLE 4-3 - */ - if ((self->state == STATE_TRANSVR_CONNECTED) || - (self->state == STATE_TRANSVR_INIT) ) { - return (int)(self->connector); - } - return ERR_TRANSVR_ABNORMAL; -} - - -int -sfp_get_wavelength(struct transvr_obj_s *self, - char *buf_p) { - /* [Note] Optical and Cable Variants Specification Compliance (SFF-8472) - * [Addr] A0h, Bytes 60-61 - * [Note] For optical variants, as defined by having zero's in A0h Byte 8 - * bits 2 and 3, Bytes 60 and 61 denote nominal transmitter output - * wavelength at room temperature. 16 bit value with byte 60 as high - * order byte and byte 61 as low order byte. The laser wavelength is - * equal to the 16 bit integer value in nm. This field allows the user - * to read the laser wavelength directly, so it is not necessary to - * infer it from the Transceiver Codes A0h Bytes 3 to 10 (see Table - * 5-3). This also allows specification of wavelengths not covered - * in the Transceiver Codes, such as those used in coarse WDM systems. - * - * For passive and active cable variants, a value of 00h for both A0h - * Byte 60 and Byte 61 denotes laser wavelength or cable specification - * compliance is unspecified. - */ - - int lmax = 8; - int err_code = DEBUG_TRANSVR_INT_VAL; - - err_code = _check_by_mode(self, - &_common_update_attr_wavelength, - "common_get_wavelength"); - if (err_code < 0) { - return snprintf(buf_p, lmax, "%d\n", err_code); - } - if ((self->wavelength[0]) == DEBUG_TRANSVR_HEX_VAL) { - return snprintf(buf_p, lmax, "%d\n", ERR_TRANSVR_UPDATE_FAIL); - } - /* unit: 1 um */ - return snprintf(buf_p, lmax, "%d\n", - _common_count_wavelength(self, - self->wavelength[0], - self->wavelength[1])); -} - - -int -sfp_get_1g_rj45_extphy_offset(struct transvr_obj_s *self, char *buf) { - - if (self->state != STATE_TRANSVR_CONNECTED) { - return ERR_TRANSVR_UNPLUGGED; - } - if ((self->info != TRANSVR_CLASS_BASE_T_1000) && - (self->info != TRANSVR_CLASS_BASE_T_1000_up) ){ - return ERR_TRANSVR_NOTSUPPORT; - } - return snprintf(buf, LEN_TRANSVR_S_STR, "0x%02x\n", self->extphy_offset); -} - - -int -sfp_get_1g_rj45_extphy_reg(struct transvr_obj_s *self, char *buf) { - - int i = 0; - int ret = 0; - int retry = 3; - int delay = 200; - - if (self->state != STATE_TRANSVR_CONNECTED) { - return ERR_TRANSVR_UNPLUGGED; - } - if ((self->info != TRANSVR_CLASS_BASE_T_1000) && - (self->info != TRANSVR_CLASS_BASE_T_1000_up) ){ - return ERR_TRANSVR_NOTSUPPORT; - } - if (_common_setup_page(self, VAL_TRANSVR_EXTPHY_ADDR_56, - -1, self->extphy_offset, 1, 0) < 0) { - return -EIO; - } - for (i=0; ii2c_client_p, self->extphy_offset); - if (ret >=0) { - goto ok_sfp_get_1g_rj45_extphy_reg; - } - msleep(delay); - } - SWPS_INFO("%s: retry:%d fail :%s :0x%02x\n", - __func__, retry, self->swp_name, self->extphy_offset); - return -EIO; - -ok_sfp_get_1g_rj45_extphy_reg: - ret = ((ret & 0x00ff) << 8) | ((ret & 0xff00) >> 8); - return snprintf(buf, LEN_TRANSVR_S_STR, "0x%04x\n", ret); -} - - -int -__qsfp_get_power_cls(struct transvr_obj_s *self, - int direct_access){ - - int err_code; - uint8_t detect_val; - - /* Detect and Update power class attribute */ - if (direct_access){ - err_code = _check_by_mode(self, - &_common_update_attr_extended_id, - "__qsfp_get_power_cls"); - } else { - err_code = self->ext_id; - } - if (err_code <0){ - return err_code; - } - if (err_code == DEBUG_TRANSVR_HEX_VAL){ - return ERR_TRANSVR_UPDATE_FAIL; - } - /* Clean data */ - detect_val = self->ext_id; - SWP_BIT_CLEAR(detect_val, 2); /* Bit2: CDR RX present */ - SWP_BIT_CLEAR(detect_val, 3); /* Bit3: CDR TX present */ - SWP_BIT_CLEAR(detect_val, 4); /* Bit4: CLEI present */ - SWP_BIT_CLEAR(detect_val, 5); /* Bit5: reserved */ - /* Identify power class */ - switch (detect_val) { - case 0: /* Class_1: 00000000 */ - return 1; - case 64: /* Class_2: 01000000 */ - return 2; - case 128: /* Class_3: 10000000 */ - return 3; - case 192: /* Class_4: 11000000 */ - return 4; - case 1: /* Class_5: 00000001 */ - case 193: /* Class_5: 11000001 */ - return 5; - case 2: /* Class_6: 00000010 */ - case 194: /* Class_6: 11000010 */ - return 6; - case 3: /* Class_7: 00000011 */ - case 195: /* Class_7: 11000011 */ - return 7; - default: - break; - } - SWPS_INFO("%s: Detect undefined power class:%d\n", __func__, detect_val); - return ERR_TRANSVR_UNDEFINED; -} - - -int -qsfp_get_power_cls(struct transvr_obj_s *self) { - return __qsfp_get_power_cls(self, 1); -} - - -int -__qsfp_get_cdr_present(struct transvr_obj_s *self, - int direct_access){ - - int retval; - int BIT_SHIFT = 2; - int BIT_MASK = 0x3; - - /* Detect and Update power class attribute */ - if (direct_access) { - retval = _check_by_mode(self, - &_common_update_attr_extended_id, - "__qsfp_get_cdr_present"); - if (retval < 0){ - return retval; - } - } - retval = self->ext_id; - if (retval == DEBUG_TRANSVR_HEX_VAL){ - return ERR_TRANSVR_UPDATE_FAIL; - } - /* Clean data and return */ - return (int)(retval >> BIT_SHIFT & BIT_MASK); -} - - -int -qsfp_get_cdr_present(struct transvr_obj_s *self) { - return __qsfp_get_cdr_present(self, 1); -} - - -int -qsfp_get_cdr(struct transvr_obj_s *self){ - - int err_code = _check_by_mode(self, - &_qsfp_update_attr_cdr, - "qsfp_get_cdr"); - if (err_code <0){ - return err_code; - } - - return self->cdr; -} - - -int -__qsfp_get_comp_attr(struct transvr_obj_s *self, - int array_offset) { - /* QSFP Specification Compliance: 00h / 131-138 - * transvr_comp[0-7] = 131 - 138 - */ - if ((self->state == STATE_TRANSVR_CONNECTED) || - (self->state == STATE_TRANSVR_INIT) ) { - return (int)(self->transvr_comp[array_offset]); - } - return ERR_TRANSVR_ABNORMAL; -} - - -int -_qsfp_get_comp_10_40_100_ethernet(struct transvr_obj_s *self) { - /* transvr_comp[0] = address 00h / 131 - * - * 131 7: Extended: See section 6.3.23. The Extended Specification Compliance - * Codes are maintained in the Transceiver Management section of SFF- - * 8024. - * 131 6: 10GBASE-LRM - * 131 5: 10GBASE-LR - * 131 4: 10GBASE-SR - * 131 3: 40GBASE-CR4 - * 131 2: 40GBASE-SR4 - * 131 1: 40GBASE-LR4 - * 131 0: 40G Active Cable (XLPPI) - */ - return __qsfp_get_comp_attr(self, 0); -} - - -int -_qsfp_get_comp_sonet(struct transvr_obj_s *self) { - /* transvr_comp[1] = address 00h / 132 - * - * 132 7-3: Reserved - * 132 2: OC 48, long reach - * 132 1: OC 48, intermediate reach - * 132 0: OC 48 short reach - */ - return __qsfp_get_comp_attr(self, 1); -} - - -int -_qsfp_get_comp_sas_sata(struct transvr_obj_s *self) { - /* transvr_comp[1] = address 00h / 132 - * - * 133 7: SAS 24.0 Gb/s - * 133 6: SAS 12.0 Gb/s - * 133 5: SAS 6.0 Gb/s - * 133 4: SAS 3.0 Gb/s - * 133 3-0: Reserved - */ - return __qsfp_get_comp_attr(self, 2); -} - - -int -_qsfp_get_comp_ethernet(struct transvr_obj_s *self) { - /* transvr_comp[1] = address 00h / 132 - * - * 134 7-4: Reserved - * 134 3: 1000BASE-T - * 134 2: 1000BASE-CX - * 134 1: 1000BASE-LX - * 134 0: 1000BASE-SX - */ - return __qsfp_get_comp_attr(self, 3); -} - - -int -_qsfp_get_comp_fc_link_length(struct transvr_obj_s *self) { - /* transvr_comp[1] = address 00h / 132 - * - * 135 7: Very long distance (V) - * 135 6: Short distance (S) - * 135 5: Intermediate distance (I) - * 135 4: Long distance (L) - * 135 3: Medium (M) - */ - int mask = 0xFC; /* 11111100 */ - return (__qsfp_get_comp_attr(self, 4) & mask); -} - - -int -_qsfp_get_comp_fc_trans_tech(struct transvr_obj_s *self) { - /* transvr_comp[1] = address 00h / 132 - * - * 135 2: Reserved - * 135 1: Longwave laser (LC) - * 135 0: Electrical inter-enclosure (EL) - * - * 136 7: Electrical intra-enclosure - * 136 6: Shortwave laser w/o OFC (SN) - * 136 5: Shortwave laser w OFC (SL) - * 136 4: Longwave Laser (LL) - * 136 3-0: Reserved - * - * return value = [bit 8-15:addr 135][bit 0-7:addr 136] - */ - int mask_135 = 7; /* 00000111 */ - int val_135 = (__qsfp_get_comp_attr(self, 4) & mask_135); - int val_136 = __qsfp_get_comp_attr(self, 5); - return ((val_135 << 7) + val_136); -} - - -int -_qsfp_get_comp_fc_trans_media(struct transvr_obj_s *self) { - /* transvr_comp[1] = address 00h / 132 - * - * 137 7: Twin Axial Pair (TW) - * 137 6: Shielded Twisted Pair (TP) - * 137 5: Miniature Coax (MI) - * 137 4: Video Coax (TV) - * 137 3: Multi-mode 62.5 m (M6) - * 137 2: Multi-mode 50 m (M5) - * 137 1: Multi-mode 50 um (OM3) - * 137 0: Single Mode (SM) - */ - return __qsfp_get_comp_attr(self, 6); -} - - -int -_qsfp_get_comp_fc_speed(struct transvr_obj_s *self) { - /* transvr_comp[1] = address 00h / 132 - * - * 138 7: 1200 MBps (per channel) - * 138 6: 800 MBps - * 138 5: 1600 MBps (per channel) - * 138 4: 400 MBps - * 138 3: 3200 MBps (per channel) - * 138 2: 200 MBps - * 138 1: Extended: See section 6.3.23. The Extended Specification - * Compliance Codes are maintained in the Transceiver Management - * section of SFF-8024. - * 138 0: 100 MBps - */ - return __qsfp_get_comp_attr(self, 7); -} - - -int -_qsfp_get_comp_extended(struct transvr_obj_s *self) { - /* Address: 00h / 192 - * Reference: SFF-8024 TABLE 4-4 - */ - if ((self->state == STATE_TRANSVR_CONNECTED) || - (self->state == STATE_TRANSVR_INIT) ) { - return (int)(self->transvr_comp_ext); - } - return ERR_TRANSVR_ABNORMAL; -} - - -int -qsfp_get_comp_eth(struct transvr_obj_s *self){ - - int err_code = _check_by_mode(self, - &_common_update_attr_transvr_comp, - "qsfp_get_comp_eth"); - if (err_code < 0){ - return err_code; - } - return _qsfp_get_comp_ethernet(self); -} - - -int -qsfp_get_comp_10_40(struct transvr_obj_s *self) { - - int err_code = _check_by_mode(self, - &_common_update_attr_transvr_comp, - "qsfp_get_comp_10_40"); - if (err_code < 0){ - return err_code; - } - return _qsfp_get_comp_10_40_100_ethernet(self); -} - - -int -_qsfp_get_connector_type(struct transvr_obj_s *self) { - /* Address: 00h / 130 - * Reference: SFF-8024 TABLE 4-3 - */ - if ((self->state == STATE_TRANSVR_CONNECTED) || - (self->state == STATE_TRANSVR_INIT) ) { - return (int)(self->connector); - } - return ERR_TRANSVR_ABNORMAL; -} - - -int -qsfp_get_transvr_temp(struct transvr_obj_s *self, - char *buf_p) { - - int lmax = 8; - int err_code = DEBUG_TRANSVR_INT_VAL; - - err_code = _check_by_mode(self, - &_qsfp_update_attr_curr_temp, - "qsfp_get_transvr_temp"); - if (err_code < 0) { - return snprintf(buf_p, lmax, "%d\n", err_code); - } - if ((self->curr_temp[0]) == DEBUG_TRANSVR_HEX_VAL) { - return snprintf(buf_p, lmax, "%d\n", ERR_TRANSVR_UPDATE_FAIL); - } - return _common_count_temp(self->curr_temp[0], - self->curr_temp[1], - buf_p); -} - - -int -qsfp_get_transvr_voltage(struct transvr_obj_s *self, - char *buf_p) { - - int lmax = 8; - int err_code = DEBUG_TRANSVR_INT_VAL; - - err_code = _check_by_mode(self, - &_qsfp_update_attr_curr_voltage, - "qsfp_get_transvr_voltage"); - if (err_code < 0) { - return snprintf(buf_p, lmax, "%d\n", err_code); - } - if ((self->curr_voltage[0]) == DEBUG_TRANSVR_HEX_VAL) { - return snprintf(buf_p, lmax, "%d\n", ERR_TRANSVR_UPDATE_FAIL); - } - /* Return Unit: 1 Volt */ - return _common_count_voltage(self->curr_voltage[0], - self->curr_voltage[1], - buf_p); -} - - -int -qsfp_get_transvr_tx_eq(struct transvr_obj_s *self, - char *buf_p) { - - int limt = 8; - int err = DEBUG_TRANSVR_INT_VAL; - - err = _check_by_mode(self, - &_qsfp_update_attr_tx_eq, - "qsfp_get_transvr_tx_eq"); - if (err < 0) { - return snprintf(buf_p, limt, "%d\n", err); - } - if ((self->tx_eq[0]) == DEBUG_TRANSVR_HEX_VAL) { - return snprintf(buf_p, limt, "%d\n", ERR_TRANSVR_UPDATE_FAIL); - } - return snprintf(buf_p, limt, "0x%02x%02x\n", - self->tx_eq[0], self->tx_eq[1]); -} - - -int -qsfp_get_transvr_rx_am(struct transvr_obj_s *self, - char *buf_p) { - - int limt = 8; - int err = DEBUG_TRANSVR_INT_VAL; - - err = _check_by_mode(self, - &_qsfp_update_attr_rx_am, - "qsfp_get_transvr_rx_am"); - if (err < 0) { - return snprintf(buf_p, limt, "%d\n", err); - } - if ((self->rx_am[0]) == DEBUG_TRANSVR_HEX_VAL) { - return snprintf(buf_p, limt, "%d\n", ERR_TRANSVR_UPDATE_FAIL); - } - return snprintf(buf_p, limt, "0x%02x%02x\n", - self->rx_am[0], self->rx_am[1]); -} - - -int -qsfp_get_transvr_rx_em(struct transvr_obj_s *self, - char *buf_p) { - - int limt = 8; - int err = DEBUG_TRANSVR_INT_VAL; - - err = _check_by_mode(self, - &_qsfp_update_attr_rx_em, - "qsfp_get_transvr_rx_em"); - if (err < 0) { - return snprintf(buf_p, limt, "%d\n", err); - } - if ((self->rx_em[0]) == DEBUG_TRANSVR_HEX_VAL) { - return snprintf(buf_p, limt, "%d\n", ERR_TRANSVR_UPDATE_FAIL); - } - return snprintf(buf_p, limt, "0x%02x%02x\n", - self->rx_em[0], self->rx_em[1]); -} - - -int -_qsfp_get_channel_diag(uint8_t *data_array, - int (*count_func)(uint8_t high_byte, uint8_t low_byte, char *buf_p), - char *ch_name, - char *result_p) { - int i, high, low; - int len_max = 128; - char ch_buf[4][16] = { DEBUG_TRANSVR_STR_VAL, - DEBUG_TRANSVR_STR_VAL, - DEBUG_TRANSVR_STR_VAL, - DEBUG_TRANSVR_STR_VAL }; - - for (i=0; i<4; i++) { - high = (i*2); - low = ((i*2) + 1); - count_func(data_array[high], data_array[low], ch_buf[i]); - } - return snprintf(result_p, len_max, - "%s-%d:%s%s-%d:%s%s-%d:%s%s-%d:%s", - ch_name, 1, ch_buf[0], - ch_name, 2, ch_buf[1], - ch_name, 3, ch_buf[2], - ch_name, 4, ch_buf[3]); -} - - -int -qsfp_get_soft_rx_los(struct transvr_obj_s *self, - char *buf_p) { - - int lmax = 8; - int mask = 0x0f; /* Bit 0 ~ Bit 3 */ - int err_code = DEBUG_TRANSVR_INT_VAL; - - err_code = _check_by_mode(self, - &_qsfp_update_attr_soft_rx_los, - "qsfp_get_soft_rx_los"); - if (err_code < 0) { - return snprintf(buf_p, lmax, "%d\n", err_code); - } - return snprintf(buf_p, lmax, "0x%02x\n", (self->rx_los & mask)); -} - - -int -qsfp_get_soft_tx_disable(struct transvr_obj_s *self, - char *buf_p) { - - int lmax = 8; - int mask = 0x0f; /* Bit 0 ~ Bit 3 */ - int err_code = DEBUG_TRANSVR_INT_VAL; - - err_code = _check_by_mode(self, - &_qsfp_update_attr_soft_tx_disable, - "qsfp_get_soft_tx_disable"); - if (err_code < 0) { - return snprintf(buf_p, lmax, "%d\n", err_code); - } - return snprintf(buf_p, lmax, "0x%02x\n", (self->tx_disable & mask)); -} - - -int -qsfp_get_soft_tx_fault(struct transvr_obj_s *self, - char *buf_p) { - - int lmax = 8; - int mask = 0x0f; /* Bit 0 ~ Bit 3 */ - int err_code = DEBUG_TRANSVR_INT_VAL; - - err_code = _check_by_mode(self, - &_qsfp_update_attr_soft_tx_fault, - "qsfp_get_soft_tx_fault"); - if (err_code < 0) { - return snprintf(buf_p, lmax, "%d\n", err_code); - } - return snprintf(buf_p, lmax, "0x%02x\n", (self->tx_fault & mask)); -} - - -int -qsfp_get_auto_tx_disable(struct transvr_obj_s *self, - char *buf_p) { - - if (self->auto_tx_disable == VAL_TRANSVR_FUNCTION_DISABLE) { - return snprintf(buf_p, LEN_TRANSVR_S_STR, - "%d\n", ERR_TRANSVR_FUNC_DISABLE); - } - return snprintf(buf_p, LEN_TRANSVR_S_STR, - "0x%02x\n", self->auto_tx_disable); -} - - -int -qsfp_get_transvr_tx_bias(struct transvr_obj_s *self, - char *buf_p) { - - int lmax = 8; - int err_code = DEBUG_TRANSVR_INT_VAL; - char *ch_name = "TX"; - - err_code = _check_by_mode(self, - &_qsfp_update_attr_curr_tx_bias, - "qsfp_get_transvr_tx_bias"); - if (err_code < 0) { - return snprintf(buf_p, lmax, "%d\n", err_code); - } - if ((self->curr_tx_bias[0]) == DEBUG_TRANSVR_HEX_VAL) { - return snprintf(buf_p, lmax, "%d\n", ERR_TRANSVR_UPDATE_FAIL); - } - /* Return Unit: 1 mA */ - return _qsfp_get_channel_diag(self->curr_tx_bias, - _common_count_tx_bias, - ch_name, - buf_p); -} - - -int -qsfp_get_transvr_tx_power(struct transvr_obj_s *self, - char *buf_p) { - - int lmax = 8; - int err_code = DEBUG_TRANSVR_INT_VAL; - char *ch_name = "TX"; - - err_code = _check_by_mode(self, - &_qsfp_update_attr_curr_tx_power, - "qsfp_get_transvr_tx_power"); - if (err_code < 0) { - return snprintf(buf_p, lmax, "%d\n", err_code); - } - if ((self->curr_tx_power[0]) == DEBUG_TRANSVR_HEX_VAL) { - return snprintf(buf_p, lmax, "%d\n", ERR_TRANSVR_UPDATE_FAIL); - } - /* Return Unit: 1 mW */ - return _qsfp_get_channel_diag(self->curr_tx_power, - _common_count_tx_power, - ch_name, - buf_p); -} - - -int -qsfp_get_transvr_rx_power(struct transvr_obj_s *self, - char *buf_p) { - - int lmax = 8; - int err_code = DEBUG_TRANSVR_INT_VAL; - char *ch_name = "RX"; - - err_code = _check_by_mode(self, - &_qsfp_update_attr_curr_rx_power, - "qsfp_get_transvr_rx_power"); - if (err_code < 0) { - return snprintf(buf_p, lmax, "%d\n", err_code); - } - if ((self->curr_tx_power[0]) == DEBUG_TRANSVR_HEX_VAL) { - return snprintf(buf_p, lmax, "%d\n", ERR_TRANSVR_UPDATE_FAIL); - } - /* Return Unit: 1 mW */ - return _qsfp_get_channel_diag(self->curr_rx_power, - _common_count_rx_power, - ch_name, - buf_p); -} - - -int -qsfp_get_wavelength(struct transvr_obj_s *self, - char *buf_p) { - /* [Desc] Wavelength or Copper Cable Attenuation (SFF-8636) - * [Addr] 00h 186-187 - * [Note] - * For optical free side devices, this parameter identifies the nominal - * transmitter output wavelength at room temperature. This parameter is - * a 16-bit hex value with Byte 186 as high order byte and Byte 187 as - * low order byte. The laser wavelength is equal to the 16-bit integer value - * divided by 20 in nm (units of 0.05 nm). This resolution should be adequate - * to cover all relevant wavelengths yet provide enough resolution for all - * expected DWDM applications. For accurate representation of controlled - * wavelength applications, this value should represent the center of the - * guaranteed wavelength range. - * If the free side device is identified as copper cable these registers will - * be used to define the cable attenuation. An indication of 0 dB attenuation - * refers to the case where the attenuation is not known or is unavailable. - * Byte 186 (00-FFh) is the copper cable attenuation at 2.5 GHz in units of 1 dB. - * Byte 187 (00-FFh) is the copper cable attenuation at 5.0 GHz in units of 1 dB. - */ - int lmax = 8; - int err_code = DEBUG_TRANSVR_INT_VAL; - - err_code = _check_by_mode(self, - &_common_update_attr_wavelength, - "common_get_wavelength"); - if (err_code < 0) { - return snprintf(buf_p, lmax, "%d\n", err_code); - } - if ((self->wavelength[0]) == DEBUG_TRANSVR_HEX_VAL) { - return snprintf(buf_p, lmax, "%d\n", ERR_TRANSVR_UPDATE_FAIL); - } - /* unit: 1 um */ - return snprintf(buf_p, lmax, "%d\n", - _common_count_wavelength(self, - self->wavelength[0], - self->wavelength[1])); -} - - -/* Public Function for Setup Features - */ -static int -__sfp_set_soft_rs(struct transvr_obj_s *self, - int input_val, - int address, - int page, - int offset, - int bit_shift, - uint8_t *attr_p, - char *caller, - int show_err) { - - int retval = ERR_TRANSVR_UNEXCPT; - int err_code = ERR_TRANSVR_UNEXCPT; - char *err_msg = DEBUG_TRANSVR_STR_VAL; - uint8_t update_val = (*attr_p); - - switch (input_val) { - case 0: - SWP_BIT_CLEAR(update_val, bit_shift); - break; - case 1: - SWP_BIT_SET(update_val, bit_shift); - break; - default: - retval = ERR_TRANSVR_UNEXCPT; - err_code = ERR_TRANSVR_UNEXCPT; - err_msg = "Exception occurs"; - goto err_private_sfp_set_soft_rs_1; - } - err_code = _common_set_uint8_attr(self, - address, - page, - offset, - update_val, - attr_p, - caller, - show_err); - if (err_code < 0) { - retval = err_code; - err_msg = "Write data via i2c fail!"; - goto err_private_sfp_set_soft_rs_1; - } - (*attr_p) = update_val; - return 0; - -err_private_sfp_set_soft_rs_1: - if (show_err) { - SWPS_INFO("%s: %s :%d :%s\n :%d\n", - __func__, err_msg, err_code, self->swp_name, input_val); - } - return retval; -} - - -static int -_sfp_set_soft_rs(struct transvr_obj_s *self, - int input_val, - int address, - int page, - int offset, - int bit_shift, - int (*attr_update_func)(struct transvr_obj_s *self, int show_err), - uint8_t *attr_p, - char *caller, - int show_err) { - - int retval = ERR_TRANSVR_UNEXCPT; - int err_code = ERR_TRANSVR_UNEXCPT; - char *err_msg = DEBUG_TRANSVR_STR_VAL; - - /* Check input value */ - if ((input_val != 0) && (input_val != 1)){ - retval = ERR_TRANSVR_BADINPUT; - err_code = ERR_TRANSVR_BADINPUT; - err_msg = "Input range incorrect!"; - goto err_common_sfp_set_soft_rs_1; - } - /* Check rate identifier is supported */ - err_code = self->get_rate_id(self); - if (err_code <= 0) { - switch (err_code) { - case 0: - retval = ERR_TRANSVR_NOTSUPPORT; - err_msg = "Not support this feature"; - break; - case ERR_TRANSVR_UNINIT: - retval = ERR_TRANSVR_UNINIT; - err_msg = "Check CDR present fail!"; - break; - case ERR_TRANSVR_UNPLUGGED: - retval = ERR_TRANSVR_UNPLUGGED; - err_msg = "Transceiver unplugged!"; - break; - default: - retval = err_code; - err_msg = "Check Rate_ID fail!"; - break; - } - goto err_common_sfp_set_soft_rs_1; - } - /* Check and update */ - err_code = _check_by_mode(self, - attr_update_func, - caller); - if ( (err_code < 0) || - ((*attr_p) == DEBUG_TRANSVR_HEX_VAL) ){ - retval = err_code; - err_msg = "Get current value fail!"; - goto err_common_sfp_set_soft_rs_1; - } - /* Generate and update value */ - return __sfp_set_soft_rs(self, - input_val, - address, - page, - offset, - bit_shift, - attr_p, - caller, - show_err); - -err_common_sfp_set_soft_rs_1: - if (show_err) { - SWPS_INFO("%s: %s :%d :%s\n :%d\n", - __func__, err_msg, err_code, self->swp_name, input_val); - } - return retval; -} - - -int -sfp_set_soft_rs0(struct transvr_obj_s *self, - int input_val) { - /* Note: - * SFP Soft Rate_Select Select RX ["RS(0)"] address - * A2h, offset: 110, bit 3 - */ - int bit_shift = 3; - int show_err = 1; - return _sfp_set_soft_rs(self, - input_val, - self->eeprom_map_p->addr_soft_rs0, - self->eeprom_map_p->page_soft_rs0, - self->eeprom_map_p->offset_soft_rs0, - bit_shift, - &_sfp_update_attr_soft_rs0, - &(self->soft_rs0), - "sfp_set_soft_rs0", - show_err); -} - - -int -sfp_set_soft_rs1(struct transvr_obj_s *self, - int input_val) { - /* Note: - * SFP Soft Rate_Select Select RX ["RS(1)"] address - * A2h, offset: 118, bit 3 - */ - int bit_shift = 3; - int show_err = 1; - return _sfp_set_soft_rs(self, - input_val, - self->eeprom_map_p->addr_soft_rs1, - self->eeprom_map_p->page_soft_rs1, - self->eeprom_map_p->offset_soft_rs1, - bit_shift, - &_sfp_update_attr_soft_rs1, - &(self->soft_rs1), - "sfp_set_soft_rs1", - show_err); -} - - -int -__sfp_set_tx_eq(struct transvr_obj_s *self, - int input, - int show_e) { - - int err = DEBUG_TRANSVR_INT_VAL; - char *emsg = DEBUG_TRANSVR_STR_VAL; - uint8_t setv = DEBUG_TRANSVR_HEX_VAL; - - if ((input < 0) || (input > 0xFF)) { - emsg = "input incorrect"; - err = ERR_TRANSVR_BADINPUT; - goto err_sfp_set_tx_eq; - } - setv = (uint8_t)input; - if (self->tx_eq[0] == setv) { - return 0; - } - err = _common_set_uint8_attr(self, - self->eeprom_map_p->addr_tx_eq, - self->eeprom_map_p->page_tx_eq, - self->eeprom_map_p->offset_tx_eq, - setv, - &(self->tx_eq[0]), - "_sfp_set_tx_eq", - show_e); - if (err < 0) { - emsg = "set_uint8_attr fail"; - goto err_sfp_set_tx_eq; - } - return 0; - -err_sfp_set_tx_eq: - if (show_e) { - SWPS_INFO("%s: %s :%d\n", __func__, emsg, input); - } - return err; -} - - -int -_sfp_set_tx_eq(struct transvr_obj_s *self, - int input, - int show_e) { - - uint8_t tmp; - int i = 0; - int retry = 3; - - for (i=0; itx_eq[0]; - if (_sfp_update_attr_tx_eq(self, show_e) < 0){ - continue; - } - if (self->tx_eq[0] == tmp){ - return 0; - } - } - return ERR_TRANSVR_UPDATE_FAIL; -} - - -int -sfp_set_tx_eq(struct transvr_obj_s *self, - int input) { - - int err = _check_by_mode(self, - &_sfp_update_attr_tx_eq, - "sfp_set_tx_eq"); - if (err < 0) { - SWPS_DEBUG("%s: check fail :%d\n", __func__, err); - return err; - } - return _sfp_set_tx_eq(self, input, 1); -} - - -int -__sfp_set_rx_em(struct transvr_obj_s *self, - int input, - int show_e) { - - int err = DEBUG_TRANSVR_INT_VAL; - char *emsg = DEBUG_TRANSVR_STR_VAL; - uint8_t setv = DEBUG_TRANSVR_HEX_VAL; - - if ((input < 0) || (input > 0xFF)) { - emsg = "input incorrect"; - err = ERR_TRANSVR_BADINPUT; - goto err_sfp_set_rx_em; - } - setv = (uint8_t)input; - if (self->rx_em[0] == setv) { - return 0; - } - err = _common_set_uint8_attr(self, - self->eeprom_map_p->addr_rx_em, - self->eeprom_map_p->page_rx_em, - self->eeprom_map_p->offset_rx_em, - setv, - &(self->rx_em[0]), - "_sfp_set_rx_em", - show_e); - if (err < 0) { - emsg = "set_uint8_attr fail"; - goto err_sfp_set_rx_em; - } - return 0; - -err_sfp_set_rx_em: - if (show_e) { - SWPS_INFO("%s: %s :%d\n", __func__, emsg, input); - } - return err; -} - - -int -_sfp_set_rx_em(struct transvr_obj_s *self, - int input, - int show_e) { - - uint8_t tmp; - int i = 0; - int retry = 3; - - for (i=0; irx_em[0]; - if (_sfp_update_attr_rx_em(self, show_e) < 0){ - continue; - } - if (self->rx_em[0] == tmp){ - return 0; - } - } - return -1; -} - - -int -sfp_set_rx_em(struct transvr_obj_s *self, - int input) { - - int err = _check_by_mode(self, - &_sfp_update_attr_rx_em, - "sfp_set_rx_em"); - if (err < 0) { - SWPS_DEBUG("%s: check fail :%d\n", __func__, err); - return err; - } - return _sfp_set_rx_em(self, input, 1); -} - - -int -sfp_set_1g_rj45_extphy_offset(struct transvr_obj_s *self, - int input) { - - if (self->state != STATE_TRANSVR_CONNECTED) { - return ERR_TRANSVR_UNPLUGGED; - } - if ((self->info != TRANSVR_CLASS_BASE_T_1000) && - (self->info != TRANSVR_CLASS_BASE_T_1000_up) ){ - return ERR_TRANSVR_NOTSUPPORT; - } - if ((input < 0) || (input > 0xff)) { - return ERR_TRANSVR_BADINPUT; - } - self->extphy_offset = (uint8_t)input; - return 0; -} - - -int -sfp_set_1g_rj45_extphy_reg(struct transvr_obj_s *self, - int input) { - - int i = 0; - int retry = 3; - int delay = 200; - uint16_t tmp = 0; - - if (self->state != STATE_TRANSVR_CONNECTED) { - return ERR_TRANSVR_UNPLUGGED; - } - if ((self->info != TRANSVR_CLASS_BASE_T_1000) && - (self->info != TRANSVR_CLASS_BASE_T_1000_up) ){ - return ERR_TRANSVR_NOTSUPPORT; - } - if ((input < 0) || (input > 0xffff)) { - return ERR_TRANSVR_BADINPUT; - } - tmp = ((input & 0x00ff) << 8) | ((input & 0xff00) >> 8); - if (_common_setup_page(self, VAL_TRANSVR_EXTPHY_ADDR_56, - -1, self->extphy_offset, 1, 0) < 0) { - return -EIO; - } - for (i=0; i<=retry; i++) { - if (i2c_smbus_write_word_data(self->i2c_client_p, - self->extphy_offset, - tmp) >= 0) { - return 0; - } - msleep(delay); - } - SWPS_INFO("%s: retry:%d fail :%s :0x%02x\n", - __func__, retry, self->swp_name, self->extphy_offset); - return -EIO; -} - - -static int -__qsfp_set_cdr(struct transvr_obj_s *self, - int input_val, - int show_err) { - - uint8_t update_val; - int CDR_FEATURE_SUPPORTED = 0x3; - int retval = ERR_TRANSVR_UNEXCPT; - int err_code = ERR_TRANSVR_UNEXCPT; - char *err_msg = DEBUG_TRANSVR_STR_VAL; - char *func_name = "__qsfp_set_cdr"; - - /* Check input value */ - if ((input_val < 0) || (input_val > 0xff)){ - retval = ERR_TRANSVR_BADINPUT; - err_code = ERR_TRANSVR_BADINPUT; - err_msg = "Input range incorrect!"; - goto err_qsfp_set_cdr_1; - } - update_val = (uint8_t)input_val; - /* Check CDR supported by transceiver */ - err_code = qsfp_get_cdr_present(self); - if (err_code < 0) { - retval = err_code; - switch (err_code) { - case ERR_TRANSVR_UNINIT: - err_msg = "Check CDR present fail!"; - break; - case ERR_TRANSVR_UNPLUGGED: - err_msg = "Transceiver unplugged!"; - break; - default: - err_msg = "Check CDR present fail!"; - break; - } - goto err_qsfp_set_cdr_1; - } - if (err_code != CDR_FEATURE_SUPPORTED) { - retval = ERR_TRANSVR_NOTSUPPORT; - err_msg = "This transceiver not support CDR!"; - goto err_qsfp_set_cdr_1; - } - /* Check and update */ - err_code = _check_by_mode(self, - &_qsfp_update_attr_cdr, - func_name); - if ( (err_code < 0) || - (self->cdr == DEBUG_TRANSVR_HEX_VAL) ){ - retval = err_code; - err_msg = "Get current value fail!"; - goto err_qsfp_set_cdr_1; - } - /* Write input value to transceiver */ - return _common_set_uint8_attr(self, - self->eeprom_map_p->addr_cdr, - self->eeprom_map_p->page_cdr, - self->eeprom_map_p->offset_cdr, - update_val, - &(self->cdr), - func_name, - show_err); - -err_qsfp_set_cdr_1: - if (show_err) { - SWPS_INFO("%s: %s :%d :%s\n :%d\n", - __func__, err_msg, err_code, self->swp_name, input_val); - } - return retval; -} - - -int -qsfp_set_cdr(struct transvr_obj_s *self, - int input_val) { - return __qsfp_set_cdr(self, input_val, 1); -} - - -int -qsfp_set_soft_tx_disable(struct transvr_obj_s *self, - int input_val) { - - int show_err = 1; - int in_max = 0xf; /* 1111 */ - int in_min = 0x0; /* 0000 */ - int retval = DEBUG_TRANSVR_INT_VAL; - int update_val = DEBUG_TRANSVR_INT_VAL; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - - retval = _check_by_mode(self, - &_qsfp_update_attr_soft_tx_disable, - "qsfp_set_soft_tx_disable"); - if (retval < 0) { - snprintf(err_msg, 63, "Not ready. err:%d", retval); - goto err_qsfp_set_soft_tx_disable; - } - if ((input_val > in_max) || - (input_val < in_min) ){ - retval = ERR_TRANSVR_BADINPUT; - snprintf(err_msg, 63, "Input value:%d incorrect!", input_val); - goto err_qsfp_set_soft_tx_disable; - } - if ((self->tx_disable & 0x0f) == input_val) { - return 0; - } - update_val = ((self->tx_disable & 0xf0) & input_val); - retval = _common_set_uint8_attr(self, - self->eeprom_map_p->addr_tx_disable, - self->eeprom_map_p->page_tx_disable, - self->eeprom_map_p->offset_tx_disable, - input_val, - &(self->tx_disable), - "qsfp_set_tx_disable", - show_err); - if (retval < 0) { - snprintf(err_msg, 63, "_common_set_uint8_attr:%d fail!", retval); - goto err_qsfp_set_soft_tx_disable; - } - return 0; - -err_qsfp_set_soft_tx_disable: - SWPS_INFO("%s: %s :%s\n", __func__, err_msg, self->swp_name); - return retval; -} - - -int -_qsfp_set_auto_tx_disable(struct transvr_obj_s *self, - uint8_t update) { - - uint8_t tx_enable = 0x0; - int show_e = 1; - int err = DEBUG_TRANSVR_INT_VAL; - char *emsg = DEBUG_TRANSVR_STR_VAL; - - /* Handle timing issues */ - if (update != tx_enable) { - /* Note: - * Because there are some txvr has timing issues, - * therefore we need to execute reset cycle first. - * (enable -> other settings) - */ - err = _common_set_uint8_attr(self, - self->eeprom_map_p->addr_tx_disable, - self->eeprom_map_p->page_tx_disable, - self->eeprom_map_p->offset_tx_disable, - tx_enable, - &(self->tx_disable), - "_qsfp_set_auto_tx_disable", - show_e); - if (err < 0) { - emsg = "I2C set reset value fail"; - goto err_qsfp_set_auto_tx_disable; - } - mdelay(10); - } - /* Setup target value */ - err = _common_set_uint8_attr(self, - self->eeprom_map_p->addr_tx_disable, - self->eeprom_map_p->page_tx_disable, - self->eeprom_map_p->offset_tx_disable, - self->auto_tx_disable, - &(self->tx_disable), - "_qsfp_set_auto_tx_disable", - show_e); - if (err < 0) { - emsg = "I2C set target value fail"; - goto err_qsfp_set_auto_tx_disable; - } - /* Check and update */ - err = _common_update_uint8_attr(self, - self->eeprom_map_p->addr_tx_disable, - self->eeprom_map_p->page_tx_disable, - self->eeprom_map_p->offset_tx_disable, - self->eeprom_map_p->length_tx_disable, - &(self->tx_disable), - "_qsfp_set_auto_tx_disable", - show_e); - if (err < 0) { - emsg = "I2C get value fail"; - goto err_qsfp_set_auto_tx_disable; - } - if (self->tx_disable != update) { - emsg = "data not become effective"; - goto err_qsfp_set_auto_tx_disable; - } - return 0; - -err_qsfp_set_auto_tx_disable: - SWPS_DEBUG("%s: %s :%s\n", - __func__, emsg, self->swp_name); - return ERR_TRANSVR_UPDATE_FAIL; -} - - -int -qsfp_set_auto_tx_disable(struct transvr_obj_s *self, - int input_val) { - - int in_max = 0xf; /* 1111 */ - int in_min = 0x0; /* 0000 */ - int retval = DEBUG_TRANSVR_INT_VAL; - char *emsg = DEBUG_TRANSVR_STR_VAL; - - /* Update settings*/ - if (input_val == VAL_TRANSVR_FUNCTION_DISABLE) { - emsg = "User disable auto tx_disable"; - self->auto_tx_disable = VAL_TRANSVR_FUNCTION_DISABLE; - goto out_qsfp_set_auto_tx_disable; - } - if ((input_val > in_max) || (input_val < in_min) ){ - SWPS_INFO("%s: Input value:%d incorrect! :%s\n", - __func__, input_val, self->swp_name); - return ERR_TRANSVR_BADINPUT; - } - self->auto_tx_disable = input_val; - /* Check current soft tx_disable */ - retval = _check_by_mode(self, - &_qsfp_update_attr_soft_tx_disable, - "qsfp_set_auto_tx_disable"); - switch (retval) { - case 0: - break; - case ERR_TRANSVR_UNPLUGGED: - emsg = "Doesn't need to update"; - goto out_qsfp_set_auto_tx_disable; - default: - SWPS_INFO("%s: setup fail :%d :%s\n", - __func__, retval, self->swp_name); - return retval; - } - return _qsfp_set_auto_tx_disable(self, input_val); - -out_qsfp_set_auto_tx_disable: - SWPS_DEBUG("%s: %s :%s :%d\n :%d", - __func__, emsg, self->swp_name, input_val, retval); - return 0; -} - - -int -__qsfp_set_tx_eq(struct transvr_obj_s *self, - int input, - int show_e) { - /* [Note] - * 0x - */ - int err = DEBUG_TRANSVR_INT_VAL; - char *emsg = DEBUG_TRANSVR_STR_VAL; - uint8_t setv[2] = {0x00, 0x00}; - - if ((input < 0) || (input > 0xFFFF)) { - emsg = "input incorrect"; - err = ERR_TRANSVR_BADINPUT; - goto err_qsfp_set_tx_eq; - } - setv[0] = (uint8_t)((input & 0xFF00) >> 8); - setv[1] = (uint8_t)(input & 0xFF); - if ((self->tx_eq[0] == setv[0]) && - (self->tx_eq[1] == setv[1]) ) { - return 0; - } - err = _common_set_uint8_array(self, - self->eeprom_map_p->addr_tx_eq, - self->eeprom_map_p->page_tx_eq, - self->eeprom_map_p->offset_tx_eq, - self->eeprom_map_p->length_tx_eq, - setv, - self->tx_eq, - "_qsfp_set_tx_eq", - show_e); - if (err < 0) { - emsg = "set_uint8_array fail"; - goto err_qsfp_set_tx_eq; - } - return 0; - -err_qsfp_set_tx_eq: - if (show_e) { - SWPS_INFO("%s: %s :%d\n", __func__, emsg, input); - } - return err; -} - - -int -_qsfp_set_tx_eq(struct transvr_obj_s *self, - int input, - int show_e) { - - int i = 0; - int retry = 3; - uint8_t tmp[2]; - - for (i=0; itx_eq[0]; - tmp[1] = self->tx_eq[1]; - if (_qsfp_update_attr_tx_eq(self, show_e) < 0){ - continue; - } - if ((self->tx_eq[0] == tmp[0]) && - (self->tx_eq[1] == tmp[1]) ){ - return 0; - } - } - return -1; -} - - -int -qsfp_set_tx_eq(struct transvr_obj_s *self, - int input) { - - int err = _check_by_mode(self, - &_qsfp_update_attr_tx_eq, - "qsfp_set_tx_eq"); - if (err < 0) { - SWPS_DEBUG("%s: check fail :%d\n", __func__, err); - return err; - } - return _qsfp_set_tx_eq(self, input, 1); -} - - -int -__qsfp_set_rx_am(struct transvr_obj_s *self, - int input, - int show_e) { - /* [Note] - * 0x - */ - int err = DEBUG_TRANSVR_INT_VAL; - char *emsg = DEBUG_TRANSVR_STR_VAL; - uint8_t setv[2] = {0x00, 0x00}; - - if ((input < 0) || (input > 0xFFFF)) { - emsg = "input incorrect"; - err = ERR_TRANSVR_BADINPUT; - goto err_qsfp_set_rx_am; - } - setv[0] = (uint8_t)((input & 0xFF00) >> 8); - setv[1] = (uint8_t)(input & 0xFF); - if ((self->rx_am[0] == setv[0]) && - (self->rx_am[1] == setv[1]) ) { - return 0; - } - err = _common_set_uint8_array(self, - self->eeprom_map_p->addr_rx_am, - self->eeprom_map_p->page_rx_am, - self->eeprom_map_p->offset_rx_am, - self->eeprom_map_p->length_rx_am, - setv, - self->rx_am, - "_qsfp_set_rx_am", - show_e); - if (err < 0) { - emsg = "set_uint8_array fail"; - goto err_qsfp_set_rx_am; - } - return 0; - -err_qsfp_set_rx_am: - if (show_e) { - SWPS_INFO("%s: %s :%d\n", __func__, emsg, input); - } - return err; -} - - -int -_qsfp_set_rx_am(struct transvr_obj_s *self, - int input, - int show_e) { - - int i = 0; - int retry = 3; - uint8_t tmp[2]; - - for (i=0; irx_am[0]; - tmp[1] = self->rx_am[1]; - if (_qsfp_update_attr_rx_am(self, show_e) < 0){ - continue; - } - if ((self->rx_am[0] == tmp[0]) && - (self->rx_am[1] == tmp[1]) ){ - return 0; - } - } - return -1; -} - - -int -qsfp_set_rx_am(struct transvr_obj_s *self, - int input) { - - int err = _check_by_mode(self, - &_qsfp_update_attr_rx_am, - "qsfp_set_rx_am"); - if (err < 0) { - SWPS_DEBUG("%s: check fail :%d\n", __func__, err); - return err; - } - return _qsfp_set_rx_am(self, input, 1); -} - - -int -__qsfp_set_rx_em(struct transvr_obj_s *self, - int input, - int show_e) { - /* [Note] - * 0x - */ - int err = DEBUG_TRANSVR_INT_VAL; - char *emsg = DEBUG_TRANSVR_STR_VAL; - uint8_t setv[2] = {0x00, 0x00}; - - if ((input < 0) || (input > 0xFFFF)) { - emsg = "input incorrect"; - err = ERR_TRANSVR_BADINPUT; - goto err_qsfp_set_rx_em; - } - setv[0] = (uint8_t)((input & 0xFF00) >> 8); - setv[1] = (uint8_t)(input & 0xFF); - if ((self->rx_em[0] == setv[0]) && - (self->rx_em[1] == setv[1]) ) { - return 0; - } - err = _common_set_uint8_array(self, - self->eeprom_map_p->addr_rx_em, - self->eeprom_map_p->page_rx_em, - self->eeprom_map_p->offset_rx_em, - self->eeprom_map_p->length_rx_em, - setv, - self->rx_em, - "_qsfp_set_rx_em", - show_e); - if (err < 0) { - emsg = "set_uint8_array fail"; - goto err_qsfp_set_rx_em; - } - return 0; - -err_qsfp_set_rx_em: - if (show_e) { - SWPS_INFO("%s: %s :%d\n", __func__, emsg, input); - } - return err; -} - - -int -_qsfp_set_rx_em(struct transvr_obj_s *self, - int input, - int show_e) { - - int i = 0; - int retry = 3; - uint8_t tmp[2]; - - for (i=0; irx_em[0]; - tmp[1] = self->rx_em[1]; - if (_qsfp_update_attr_rx_em(self, show_e) < 0){ - continue; - } - if ((self->rx_em[0] == tmp[0]) && - (self->rx_em[1] == tmp[1]) ){ - return 0; - } - } - return -1; -} - - -int -qsfp_set_rx_em(struct transvr_obj_s *self, - int input) { - - int err = _check_by_mode(self, - &_qsfp_update_attr_rx_em, - "qsfp_set_rx_em"); - if (err < 0) { - SWPS_DEBUG("%s: check fail :%d\n", __func__, err); - return err; - } - return _qsfp_set_rx_em(self, input, 1); -} - - -int -common_transvr_dump(struct transvr_obj_s* self){ - - char *type_name = "Undefined"; - - if (TRANSVR_INFO_DUMP_ENABLE != 1) { - return 0; - } - switch (self->type) { - case TRANSVR_TYPE_SFP: - type_name = STR_TRANSVR_SFP; - break; - case TRANSVR_TYPE_QSFP: - type_name = STR_TRANSVR_QSFP; - break; - case TRANSVR_TYPE_QSFP_PLUS: - type_name = STR_TRANSVR_QSFP_PLUS; - break; - case TRANSVR_TYPE_QSFP_28: - type_name = STR_TRANSVR_QSFP28; - break; - case TRANSVR_TYPE_FAKE: - type_name = "FAKE"; - goto ok_common_transvr_dump; - case TRANSVR_TYPE_UNPLUGGED: - type_name = "UNPLUGGED"; - goto err_common_transvr_dump; - case TRANSVR_TYPE_INCONSISTENT: - type_name = "INCONSISTENT"; - goto err_common_transvr_dump; - case TRANSVR_TYPE_ERROR: - type_name = "ERROR"; - goto err_common_transvr_dump; - - default: - type_name = "UNEXPECTED"; - goto err_common_transvr_dump; - } - printk(KERN_INFO "[SWPS] Dump %s information:\n", self->swp_name); - printk(KERN_INFO " |- :%s\n", type_name); - printk(KERN_INFO " |- :%s\n", self->vendor_name); - printk(KERN_INFO " |- :%s\n", self->vendor_pn); - printk(KERN_INFO " |- :%s\n", self->vendor_rev); - printk(KERN_INFO " |- :%s\n", self->vendor_sn); - printk(KERN_INFO " |- :0x%02x\n", self->br); - printk(KERN_INFO " |- :0x%02x\n", self->comp_rev); - printk(KERN_INFO " |- :%d\n", self->len_om1); - printk(KERN_INFO " |- :%d\n", self->len_om2); - printk(KERN_INFO " |- :%d\n", self->len_om3); - printk(KERN_INFO " |- :%d\n", self->len_om4); - return 0; - -ok_common_transvr_dump: - SWPS_INFO("%s: %s is %s\n", __func__, self->swp_name, type_name); - return 0; - -err_common_transvr_dump: - SWPS_INFO("%s: %s is %s\n", __func__, self->swp_name, type_name); - return -1; -} - - -int -sfp_transvr_dump(struct transvr_obj_s* self) { - - if (TRANSVR_INFO_DUMP_ENABLE != 1) { - return 0; - } - if (common_transvr_dump(self) < 0) { - return -1; - } - printk(KERN_INFO " |- :%d\n", self->len_sm); - printk(KERN_INFO " |- :%d\n", self->len_smf); - printk(KERN_INFO " '- :0x%02x\n", self->rate_id); - return 0; -} - - -int -qsfp_transvr_dump(struct transvr_obj_s* self) { - - if (TRANSVR_INFO_DUMP_ENABLE != 1) { - return 0; - } - if (common_transvr_dump(self) < 0) { - return -1; - } - printk(KERN_INFO " |- :%d\n", self->len_smf); - printk(KERN_INFO " '- :Class_%d\n", __qsfp_get_power_cls(self, 0)); - return 0; -} - - -int -fake_transvr_dump(struct transvr_obj_s* self) { - - printk(KERN_INFO "[SWPS] Dump transceiver information: %s\n", self->swp_name); - printk(KERN_INFO " |- :FAKE\n"); - printk(KERN_INFO " |- :FAKE_VENDER_NAME\n"); - printk(KERN_INFO " |- :FAKE_VENDER_PN\n"); - printk(KERN_INFO " |- :FAKE_VENDER_REV\n"); - printk(KERN_INFO " |- :FAKE_VENDER_SN\n"); - printk(KERN_INFO " |- :0x99\n"); - printk(KERN_INFO " |- :99\n"); - printk(KERN_INFO " |- :99\n"); - printk(KERN_INFO " |- :99\n"); - printk(KERN_INFO " |- :99\n"); - printk(KERN_INFO " |- :99\n"); - printk(KERN_INFO " |- :99\n"); - printk(KERN_INFO " '- :0x99\n"); - return 0; -} - - -/* ========== Object functions for fake type ========== - */ -int -fake_transvr_update(struct transvr_obj_s *self, - int show_err){ - self->state = STATE_TRANSVR_CONNECTED; - return 0; -} - - -int -fake_get_binary(struct transvr_obj_s *self){ - return 1; -} - -int -fake_get_int(struct transvr_obj_s *self){ - return 99; -} - - -int -fake_get_hex(struct transvr_obj_s *self){ - return 0x0f; -} - - -int -fake_get_str(struct transvr_obj_s *self, char *buf) { - return snprintf(buf, 16, "fake_get_str\n"); -} - - -int -fake_set_int(struct transvr_obj_s *self, int input){ - SWPS_INFO("%s: %d\n", __func__, input); - return 0; -} - - -int -fake_set_hex(struct transvr_obj_s *self, int input){ - SWPS_INFO("%s: 0x%02x\n", __func__, input); - return 0; -} - - -/* ========== Object functions for unsupported ========== - */ -int -unsupported_get_func(struct transvr_obj_s *self){ - return ERR_TRANSVR_NOTSUPPORT; -} - - -int -unsupported_get_func2(struct transvr_obj_s *self, - char *buf_p) { - int len = snprintf(buf_p, 8, "%d\n", ERR_TRANSVR_NOTSUPPORT); - return len; -} - - -int -unsupported_set_func(struct transvr_obj_s *self, - int input_val){ - return ERR_TRANSVR_NOTSUPPORT; -} - - - -/* ========== Object functions for long term task ========== - * - * [Note] - * SWPS transceiver worker is likely the green-thread (coroutine). - * Due to resource and performance considerations. SWPS run all - * features in one kthread at the same time, and handle by it self. - */ - -/* For Transceiver Task Handling - */ -static struct transvr_worker_s * -transvr_task_get(struct transvr_obj_s *self, - char *func_name) { - - struct transvr_worker_s *curr_p = self->worker_p; - - while(curr_p != NULL){ - if (strcmp((curr_p->func_name), func_name) == 0 ) { - return curr_p; - } - curr_p = curr_p->next_p; - } - return NULL; -} - - -static struct transvr_worker_s* -transvr_task_creat(struct transvr_obj_s *self, - int (*main_task)(struct transvr_worker_s *task), - int (*post_task)(struct transvr_worker_s *task), - char *caller) { - - struct transvr_worker_s *task_p = NULL; - struct transvr_worker_s *curr_p = NULL; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - - /* Check task not exist */ - task_p = transvr_task_get(self, caller); - if (task_p) { - snprintf(err_msg, sizeof(err_msg), "Task already created!"); - goto err_transvr_task_creat; - } - /* Create task worker */ - task_p = kzalloc(sizeof(struct transvr_worker_s), GFP_KERNEL); - if (!task_p){ - snprintf(err_msg, sizeof(err_msg), "kzalloc fail"); - goto err_transvr_task_creat; - } - /* Setup task data */ - task_p->transvr_p = self; - task_p->next_p = NULL; - task_p->trigger_time = 0; - task_p->retry = 1; - task_p->state = STATE_T_TASK_INIT; - task_p->main_task = main_task; - task_p->post_task = post_task; - task_p->p_data = NULL; - snprintf(task_p->func_name, sizeof(task_p->func_name), "%s", caller); - /* Setup Link List */ - if (self->worker_p) { - curr_p = self->worker_p; - while(curr_p->next_p != NULL) { - curr_p = curr_p->next_p; - } - curr_p->next_p = task_p; - task_p->pre_p = curr_p; - } else { - self->worker_p = task_p; - task_p->pre_p = NULL; - } - return task_p; - -err_transvr_task_creat: - SWPS_ERR("%s: %s :%s :%s\n", - __func__, err_msg, caller, self->swp_name); - return NULL; -} - - -static void -transvr_task_free_one(struct transvr_worker_s *task_p){ - - struct transvr_worker_s *pre_p = NULL; - struct transvr_worker_s *next_p = NULL; - - if (task_p) { - pre_p = task_p->pre_p; - next_p = task_p->next_p; - - if ((pre_p) && (next_p)) { - pre_p->next_p = next_p; - next_p->pre_p = pre_p; - - } else if ((!pre_p) && (next_p)) { - next_p->pre_p = NULL; - - } else if ((pre_p) && (!next_p)) { - pre_p->next_p = NULL; - - } else if ((!pre_p) && (!next_p)) { - task_p->transvr_p->worker_p = NULL; - } else { - SWPS_ERR("%s: Unexcept case!\n :%s", - __func__, task_p->transvr_p->swp_name); - } - kfree(task_p->p_data); - kfree(task_p); - } -} - - -static void -transvr_task_free_all(struct transvr_obj_s *self) { - - struct transvr_worker_s *curr_p = NULL; - struct transvr_worker_s *next_p = NULL; - - if (self->worker_p) { - curr_p = self->worker_p; - while(curr_p) { - next_p = curr_p->next_p; - transvr_task_free_one(curr_p); - curr_p = next_p; - } - self->worker_p = NULL; - } -} - - -static void -transvr_cache_free_all(struct transvr_obj_s *self) { - - memset(self->vendor_name, 0, (LEN_TRANSVR_M_STR * sizeof(char)) ); - memset(self->vendor_rev, 0, (LEN_TRANSVR_M_STR * sizeof(char)) ); - memset(self->vendor_pn, 0, (LEN_TRANSVR_M_STR * sizeof(char)) ); - memset(self->vendor_sn, 0, (LEN_TRANSVR_M_STR * sizeof(char)) ); - self->extphy_offset = 0; -} - -static int -_transvr_task_run_main(struct transvr_worker_s *task_p) { - - int retval = DEBUG_TRANSVR_INT_VAL; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - - if (!task_p){ - snprintf(err_msg, sizeof(err_msg), "main_task is NULL!"); - goto main_transvr_task_err; - } - if ((task_p->trigger_time) == 0){ - goto main_transvr_task_run; - } - if (time_before(jiffies, task_p->trigger_time)){ - goto main_transvr_task_wait; - } - goto main_transvr_task_run; - -main_transvr_task_run: - if (task_p->retry != VAL_TRANSVR_TASK_RETRY_FOREVER) { - task_p->retry -= 1; - } - retval = task_p->main_task(task_p); - if (retval < 0) { - if (task_p->retry > 0) { - task_p->state = STATE_T_TASK_WAIT; - return EVENT_TRANSVR_TASK_WAIT; - } - snprintf(err_msg, sizeof(err_msg), "Run main_task fail!"); - goto main_transvr_task_err; - } - goto main_transvr_task_identify; - -main_transvr_task_identify: - switch (retval) { - case EVENT_TRANSVR_TASK_WAIT: - task_p->state = STATE_T_TASK_WAIT; - return EVENT_TRANSVR_TASK_WAIT; - - case EVENT_TRANSVR_TASK_DONE: - task_p->state = STATE_T_TASK_DONE; - return EVENT_TRANSVR_TASK_DONE; - - default: - break; - } - snprintf(err_msg, sizeof(err_msg), "Run main_task fail!"); - goto main_transvr_task_err; - -main_transvr_task_wait: - task_p->state = STATE_T_TASK_WAIT; - return EVENT_TRANSVR_TASK_WAIT; - -main_transvr_task_err: - task_p->state = STATE_T_TASK_FAIL; - SWPS_INFO("%s: %s :%d :%s\n", - __func__, err_msg, retval, task_p->transvr_p->swp_name); - return EVENT_TRANSVR_INIT_FAIL; -} - - -static int -_transvr_task_run_post(struct transvr_worker_s *task_p) { - - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - - if ((task_p->post_task) == NULL) { - return EVENT_TRANSVR_TASK_DONE; - } - switch (task_p->state) { - case STATE_T_TASK_WAIT: - case STATE_T_TASK_INIT: - goto post_transvr_task_wait; - - case STATE_T_TASK_DONE: - case STATE_T_TASK_FAIL: - goto post_transvr_task_run; - - default: - break; - } - snprintf(err_msg, sizeof(err_msg), "Unexcept task state"); - goto post_transvr_task_err; - -post_transvr_task_run: - task_p->post_task(task_p); - return EVENT_TRANSVR_TASK_DONE; - -post_transvr_task_wait: - return EVENT_TRANSVR_TASK_WAIT; - -post_transvr_task_err: - SWPS_INFO("%s: %s :%d :%s\n", - __func__, err_msg, task_p->state, task_p->transvr_p->swp_name); - return EVENT_TRANSVR_TASK_FAIL; -} - - -static int -transvr_task_run_one(struct transvr_worker_s *task_p) { - - int retval_main = DEBUG_TRANSVR_INT_VAL; - int retval_post = DEBUG_TRANSVR_INT_VAL; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - - retval_main = _transvr_task_run_main(task_p); - if (retval_main < 0) { - snprintf(err_msg, sizeof(err_msg), "Execute main_task fail!"); - goto err_transvr_task_run_one; - } - retval_post = _transvr_task_run_post(task_p); - if (retval_post < 0) { - snprintf(err_msg, sizeof(err_msg), "Execute post_task fail!"); - goto err_transvr_task_run_one; - } - return retval_main; - -err_transvr_task_run_one: - SWPS_INFO("%s: %s
:%d :%d :%s :%s\n", - __func__, err_msg, retval_main, retval_post, - task_p->func_name, task_p->transvr_p->swp_name); - return EVENT_TRANSVR_TASK_FAIL; -} - - -static int -transvr_task_run_all(struct transvr_obj_s *self) { - - int haserr = 0; - int retval = DEBUG_TRANSVR_INT_VAL; - struct transvr_worker_s *curr_p = NULL; - struct transvr_worker_s *next_p = NULL; - - if ((self->worker_p) == NULL) { - return EVENT_TRANSVR_TASK_DONE; - } - curr_p = self->worker_p; - while (curr_p != NULL) { - next_p = curr_p->next_p; - retval = transvr_task_run_one(curr_p); - if (curr_p->retry == VAL_TRANSVR_TASK_RETRY_FOREVER) { - curr_p = next_p; - continue; - } - switch (retval) { - case EVENT_TRANSVR_TASK_WAIT: - break; - case EVENT_TRANSVR_TASK_DONE: - transvr_task_free_one(curr_p); - break; - case EVENT_TRANSVR_TASK_FAIL: - - default: - haserr = 1; - transvr_task_free_one(curr_p); - break; - } - curr_p = next_p; - } - if (haserr) { - return EVENT_TRANSVR_TASK_FAIL; - } - return EVENT_TRANSVR_TASK_DONE; -} - - -static void -transvr_task_set_delay(struct transvr_worker_s *task_p, - unsigned long delay_msec) { - - task_p->trigger_time = (jiffies + (delay_msec * (HZ/1000))); -} - - -static void -transvr_task_set_retry(struct transvr_worker_s *task_p, - unsigned long retry_times) { - - task_p->retry = retry_times; -} - - -/* For Transceiver Post Task - */ -int -taskfunc_post_do_nothing(struct transvr_worker_s *task_p) { - - return EVENT_TRANSVR_TASK_DONE; -} - - -int -taskfunc_post_handle_task_state(struct transvr_worker_s *task_p) { - - struct transvr_obj_s* tp = task_p->transvr_p; - - switch (task_p->state) { - case STATE_T_TASK_INIT: - case STATE_T_TASK_WAIT: - return EVENT_TRANSVR_TASK_WAIT; - - case STATE_T_TASK_DONE: - tp->state = STATE_TRANSVR_CONNECTED; - tp->send_uevent(tp, KOBJ_ADD); - return EVENT_TRANSVR_TASK_DONE; - - case STATE_T_TASK_FAIL: - tp->state = STATE_TRANSVR_UNEXCEPTED; - return EVENT_TRANSVR_TASK_FAIL; - - default: - break; - } - return EVENT_TRANSVR_TASK_FAIL; -} - - -/* For Transceiver Main Task - */ -int -_taskfunc_sfp_setup_soft_rs(struct transvr_worker_s *task_p, - int input_val, - int address, - int page, - int offset, - int bit_shift, - uint8_t *attr_p, - char *caller) { - - int show_err = 0; - int err_code = DEBUG_TRANSVR_INT_VAL; - char *err_str = DEBUG_TRANSVR_STR_VAL; - char *func_str = "_taskfunc_sfp_setup_soft_rs"; - - err_code = _sfp_update_attr_soft_rs0(task_p->transvr_p, 0); - if (err_code < 0) { - err_str = "Get current soft_rs0 fail!"; - goto err_taskfunc_sfp_setup_soft_rs_1; - } - err_code = __sfp_set_soft_rs(task_p->transvr_p, - input_val, - address, - page, - offset, - bit_shift, - attr_p, - caller, - show_err); - if (err_code < 0) { - err_str = "Get current soft_rs0 fail!"; - goto err_taskfunc_sfp_setup_soft_rs_1; - } - return EVENT_TRANSVR_TASK_DONE; - -err_taskfunc_sfp_setup_soft_rs_1: - if ((task_p->retry) == 0) { - SWPS_INFO("%s: %s :%s :%d :%d\n", - func_str, err_str, task_p->transvr_p->swp_name, input_val, err_code); - } - return EVENT_TRANSVR_TASK_FAIL; -} - - -int -__taskfunc_sfp_setup_hard_rs(struct transvr_worker_s *task_p, - int input_val, - int (*get_func)(struct ioexp_obj_s *self, int virt_offset), - int (*set_func)(struct ioexp_obj_s *self, int virt_offset, int input_val)) { - - int err_val = EVENT_TRANSVR_EXCEP_EXCEP; - char *err_str = DEBUG_TRANSVR_STR_VAL; - - err_val = get_func(task_p->transvr_p->ioexp_obj_p, - task_p->transvr_p->ioexp_virt_offset); - - if (err_val < 0) { - if (err_val == ERR_IOEXP_NOTSUPPORT) { - return EVENT_TRANSVR_TASK_DONE; - } - err_str = "Get current hard_rs fail!"; - goto err_p_taskfunc_sfp_setup_hard_rs_1; - } - if (err_val == input_val) { - return EVENT_TRANSVR_TASK_DONE; - } - err_val = set_func(task_p->transvr_p->ioexp_obj_p, - task_p->transvr_p->ioexp_virt_offset, - input_val); - if (err_val < 0) { - err_str = "Setup hard_rs fail!"; - goto err_p_taskfunc_sfp_setup_hard_rs_1; - } - return EVENT_TRANSVR_TASK_DONE; - -err_p_taskfunc_sfp_setup_hard_rs_1: - if ((task_p->retry) == 0) { - SWPS_INFO("%s: %s :%s :%d :%d\n", - __func__, err_str, task_p->transvr_p->swp_name, input_val, err_val); - } - return EVENT_TRANSVR_TASK_FAIL; -} - - -int -_taskfunc_sfp_setup_hard_rs0(struct transvr_worker_s *task_p, - int input_val) { - - return __taskfunc_sfp_setup_hard_rs(task_p, - input_val, - task_p->transvr_p->ioexp_obj_p->get_hard_rs0, - task_p->transvr_p->ioexp_obj_p->set_hard_rs0); -} - - -int -_taskfunc_sfp_setup_hard_rs1(struct transvr_worker_s *task_p, - int input_val) { - - return __taskfunc_sfp_setup_hard_rs(task_p, - input_val, - task_p->transvr_p->ioexp_obj_p->get_hard_rs1, - task_p->transvr_p->ioexp_obj_p->set_hard_rs1); -} - - -int -_taskfunc_sfp_setup_rs0(struct transvr_worker_s *task_p, - int input_val) { - - int bit_shift = 3; - int old_val = DEBUG_TRANSVR_INT_VAL; - int err_val = EVENT_TRANSVR_EXCEP_EXCEP; - char *err_str = DEBUG_TRANSVR_STR_VAL; - char *func_str = "_taskfunc_sfp_setup_rs0"; - - err_val = _taskfunc_sfp_setup_hard_rs0(task_p, - input_val); - if (err_val < 0) { - err_str = "Setup hard_rs0 fail!"; - goto err_private_taskfunc_sfp_setup_rs0_1; - } - old_val = err_val; - err_val = _taskfunc_sfp_setup_soft_rs(task_p, - input_val, - task_p->transvr_p->eeprom_map_p->addr_soft_rs0, - task_p->transvr_p->eeprom_map_p->page_soft_rs0, - task_p->transvr_p->eeprom_map_p->offset_soft_rs0, - bit_shift, - &(task_p->transvr_p->soft_rs0), - func_str); - if (err_val < 0) { - err_str = "Setup soft_rs0 fail!"; - goto err_private_taskfunc_sfp_setup_rs0_1; - } - return EVENT_TRANSVR_TASK_DONE; - -err_private_taskfunc_sfp_setup_rs0_1: - if ((task_p->retry) == 0) { - SWPS_INFO("%s: %s :%s :%d :%d\n", - func_str, err_str, task_p->transvr_p->swp_name, input_val, err_val); - } - _taskfunc_sfp_setup_hard_rs0(task_p, old_val); - return EVENT_TRANSVR_TASK_FAIL; -} - - -int -_taskfunc_sfp_setup_rs1(struct transvr_worker_s *task_p, - int input_val) { - - int bit_shift = 3; - int old_val = DEBUG_TRANSVR_INT_VAL; - int err_val = EVENT_TRANSVR_EXCEP_EXCEP; - char *err_str = DEBUG_TRANSVR_STR_VAL; - char *func_str = "_taskfunc_sfp_setup_rs1"; - - err_val = _taskfunc_sfp_setup_hard_rs1(task_p, - input_val); - if (err_val < 0) { - err_str = "Setup hard_rs1 fail!"; - goto err_private_taskfunc_sfp_setup_rs1_1; - } - old_val = err_val; - err_val = _taskfunc_sfp_setup_soft_rs(task_p, - input_val, - task_p->transvr_p->eeprom_map_p->addr_soft_rs1, - task_p->transvr_p->eeprom_map_p->page_soft_rs1, - task_p->transvr_p->eeprom_map_p->offset_soft_rs1, - bit_shift, - &(task_p->transvr_p->soft_rs1), - func_str); - if (err_val < 0) { - err_str = "Setup soft_rs1 fail!"; - goto err_private_taskfunc_sfp_setup_rs1_1; - } - return EVENT_TRANSVR_TASK_DONE; - -err_private_taskfunc_sfp_setup_rs1_1: - if ((task_p->retry) == 0) { - SWPS_INFO("%s: %s :%s :%d :%d\n", - func_str, err_str, task_p->transvr_p->swp_name, input_val, err_val); - } - _taskfunc_sfp_setup_hard_rs1(task_p, old_val); - return EVENT_TRANSVR_TASK_FAIL; -} - - -int -taskfunc_sfp_setup_SFF8431_case1(struct transvr_worker_s *task_p) { - /* SFF-8431 (8/4/2G Rx Rate_Select only) */ - int update_val = 1; - - return _taskfunc_sfp_setup_rs0(task_p, update_val); -} - - - -int -taskfunc_sfp_setup_SFF8431_case2(struct transvr_worker_s *task_p) { - /* SFF-8431 (8/4/2G Tx Rate_Select only) */ - int update_val = 1; - - return _taskfunc_sfp_setup_rs1(task_p, update_val); -} - - -int -taskfunc_sfp_setup_SFF8431_case3(struct transvr_worker_s *task_p) { - /* SFF-8431 (8/4/2G Independent Rx & Tx Rate_select) */ - int update_rs0 = 1; - int update_rs1 = 1; - int err_code = DEBUG_TRANSVR_INT_VAL; - - err_code = _taskfunc_sfp_setup_rs0(task_p, update_rs0); - if (err_code < 0) { - return err_code; - } - return _taskfunc_sfp_setup_rs1(task_p, update_rs1); -} - - -int -taskfunc_sfp_handle_1g_rj45(struct transvr_worker_s *task_p) { - - /* Not all of platform support 0x56 for transceiver - * external PHY, Support list as below: - * => 1. Magnolia-PVT (PS: EVT & DVT not ready) - */ - int ext_phy_addr = 0x56; - int ext_phy_page = -1; - int ext_phy_offs = 0x11; - int ext_phy_len = 1; - int lstate_mask = 0x04; /* 00000100 */ - int show_err = 0; - int fail_retry = 5; - int fail_delay = 1000; /* msec */ - int err_code = DEBUG_TRANSVR_INT_VAL; - uint8_t detect_val = DEBUG_TRANSVR_HEX_VAL; - char err_str[64] = DEBUG_TRANSVR_STR_VAL; - int *tmp_p = NULL; - char *func_name = "taskfunc_sfp_handle_1g_rj45"; - - if (task_p->transvr_p->state != STATE_TRANSVR_CONNECTED) { - return EVENT_TRANSVR_TASK_DONE; - } - if ( (task_p->transvr_p->info != TRANSVR_CLASS_BASE_T_1000) && - (task_p->transvr_p->info != TRANSVR_CLASS_BASE_T_1000_up) ) { - goto err_taskfunc_sfp_handle_1g_rj45_1; - } - err_code = _common_update_uint8_attr(task_p->transvr_p, - ext_phy_addr, - ext_phy_page, - ext_phy_offs, - ext_phy_len, - &detect_val, - func_name, - show_err); - if ( (err_code < 0) || - (detect_val == DEBUG_TRANSVR_HEX_VAL) ) { - snprintf(err_str, sizeof(err_str), "Detect external link status fail"); - goto err_taskfunc_sfp_handle_1g_rj45_2; - } - if ((detect_val & lstate_mask) == lstate_mask) { - goto ok_taskfunc_sfp_handle_1g_rj45_link_up; - } - goto ok_taskfunc_sfp_handle_1g_rj45_link_down; - -ok_taskfunc_sfp_handle_1g_rj45_link_up: - /* Filter out noise */ - if (!(task_p->p_data)) { - tmp_p = kzalloc(sizeof(int), GFP_KERNEL); - if (!tmp_p) { - snprintf(err_str, sizeof(err_str), "kzalloc p_data fail"); - goto err_taskfunc_sfp_handle_1g_rj45_2; - } - *tmp_p = TRANSVR_CLASS_BASE_T_1000_up; - task_p->p_data = tmp_p; - goto ok_taskfunc_sfp_handle_1g_rj45_done; - } - if ((*(int *)(task_p->p_data)) != TRANSVR_CLASS_BASE_T_1000_up) { - kfree(task_p->p_data); - task_p->p_data = NULL; - snprintf(err_str, sizeof(err_str), "Internal error"); - goto err_taskfunc_sfp_handle_1g_rj45_2; - } - task_p->transvr_p->info = TRANSVR_CLASS_BASE_T_1000_up; - kfree(task_p->p_data); - task_p->p_data = NULL; - goto ok_taskfunc_sfp_handle_1g_rj45_done; - -ok_taskfunc_sfp_handle_1g_rj45_link_down: - if (task_p->p_data) { - kfree(task_p->p_data); - task_p->p_data = NULL; - } - task_p->transvr_p->info = TRANSVR_CLASS_BASE_T_1000; - goto ok_taskfunc_sfp_handle_1g_rj45_done; - -ok_taskfunc_sfp_handle_1g_rj45_done: - if (task_p->retry != VAL_TRANSVR_TASK_RETRY_FOREVER) { - transvr_task_set_retry(task_p, VAL_TRANSVR_TASK_RETRY_FOREVER); - } - return EVENT_TRANSVR_TASK_DONE; - -err_taskfunc_sfp_handle_1g_rj45_1: - snprintf(err_str, sizeof(err_str), "Detect transceiver:%d not Base-T, remove task.", - task_p->transvr_p->info); - SWPS_INFO("%s: %s :%s\n", __func__, err_str, task_p->transvr_p->swp_name); - transvr_task_set_retry(task_p, 0); - return EVENT_TRANSVR_TASK_DONE; - -err_taskfunc_sfp_handle_1g_rj45_2: - if (task_p->retry == VAL_TRANSVR_TASK_RETRY_FOREVER) { - transvr_task_set_retry(task_p, fail_retry); - } - if ((task_p->retry) == 0) { - /* Error case: - * => In this case, SWPS will stop external Link state monitor features - * and keeps transvr_p->info on TRANSVR_CLASS_BASE_T_1000_up. - * Upper layer will see it always Linkup that because of these type of - * transceiver has external phy, BCM chip see it as Loopback transceiver. - */ - SWPS_WARN("%s can not access external PHY of Base-T SFP transceiver\n", - task_p->transvr_p->swp_name); - task_p->transvr_p->info = TRANSVR_CLASS_BASE_T_1000_up; - return EVENT_TRANSVR_TASK_DONE; - } else { - transvr_task_set_delay(task_p, fail_delay); - } - return EVENT_TRANSVR_TASK_FAIL; -} - - -int -_taskfunc_qsfp_setup_power_mod(struct transvr_obj_s *self, - int setup_val) { - - int curr_val = DEBUG_TRANSVR_INT_VAL; - int err_val = DEBUG_TRANSVR_INT_VAL; - char *err_msg = DEBUG_TRANSVR_STR_VAL; - - curr_val = self->ioexp_obj_p->get_lpmod(self->ioexp_obj_p, - self->ioexp_virt_offset); - if (curr_val < 0){ - err_msg = "Get current value fail!"; - goto err_private_taskfunc_qsfp_setup_power_mod_1; - } - if (curr_val == setup_val){ - return EVENT_TRANSVR_TASK_DONE; - } - err_val = self->ioexp_obj_p->set_lpmod(self->ioexp_obj_p, - self->ioexp_virt_offset, - setup_val); - if (err_val < 0){ - err_msg = "Setup power mode fail!"; - goto err_private_taskfunc_qsfp_setup_power_mod_1; - } - return EVENT_TRANSVR_TASK_DONE; - -err_private_taskfunc_qsfp_setup_power_mod_1: - SWPS_INFO("%s: %s :%d :%d :%d\n", - __func__, err_msg, err_val, curr_val, setup_val); - return EVENT_TRANSVR_TASK_FAIL; -} - - -int -taskfunc_qsfp_handle_tx_disable(struct transvr_worker_s *task_p) { - - int i = 0; - int retry = 5; - int delay_ms = 100; - - if (task_p->transvr_p->auto_tx_disable == VAL_TRANSVR_FUNCTION_DISABLE) { - return EVENT_TRANSVR_TASK_DONE; - } - if (!_qsfp_is_implement_tx_disable(task_p->transvr_p)) { - return EVENT_TRANSVR_TASK_DONE; - } - for (i=0; itransvr_p, - task_p->transvr_p->auto_tx_disable) - == EVENT_TRANSVR_TASK_DONE) { - goto ok_taskfunc_qsfp_handle_tx_disable; - } - mdelay(delay_ms); - } - SWPS_INFO("%s auto setup tx_disable:0x%02x fail.\n", - task_p->transvr_p->swp_name, - task_p->transvr_p->auto_tx_disable); - return EVENT_TRANSVR_INIT_FAIL; - -ok_taskfunc_qsfp_handle_tx_disable: - SWPS_INFO("%s auto setup tx_disable:0x%02x ok.\n", - task_p->transvr_p->swp_name, - task_p->transvr_p->auto_tx_disable); - return EVENT_TRANSVR_TASK_DONE; -} - - -int -taskfunc_qsfp_set_hpmod(struct transvr_worker_s *task_p) { - - int err = DEBUG_TRANSVR_INT_VAL; - int HIGH_POWER_MODE = 0; - - /* Handle power mode */ - err = _taskfunc_qsfp_setup_power_mod(task_p->transvr_p, - HIGH_POWER_MODE); - if (err < 0) { - SWPS_INFO("%s: setup hpmod fail :%d :%s\n", - __func__, err, task_p->transvr_p->swp_name); - return err; - } - /* Handle auto tx_disable - * [Note] - * => Because there are some transceiver have timing issues or - * setup sequence issues, therefore we handle auto tx_disable - * after handle power mode. - */ - mdelay(100); - return taskfunc_qsfp_handle_tx_disable(task_p); -} - - -int -taskfunc_qsfp_set_lpmod(struct transvr_worker_s *task_p) { - - int LOW_POWER_MODE = 1; - return _taskfunc_qsfp_setup_power_mod(task_p->transvr_p, - LOW_POWER_MODE); -} - - -static int -initfunc_sfp_handle_multi_rate_mode(struct transvr_obj_s *self) { - - int task_retry = 3; - int err_code = DEBUG_TRANSVR_INT_VAL; - char *err_str = DEBUG_TRANSVR_STR_VAL; - char *func_str = "sfp_handle_multi_rate_mode"; - struct transvr_worker_s *task_p = NULL; - - switch (self->rate_id) { - case 0x00: /* Unspecified */ - case 0x03: /* Unspecified */ - case 0x05: /* Unspecified */ - case 0x07: /* Unspecified */ - case 0x09: /* Unspecified */ - case 0x0B: /* Unspecified */ - case 0x0D: /* Unspecified */ - case 0x0F: /* Unspecified */ - goto sfp_handle_multi_rate_mode_4_unspecified; - - case 0x02: /* SFF-8431 (8/4/2G Rx Rate_Select only) */ - task_p = transvr_task_creat(self, - taskfunc_sfp_setup_SFF8431_case1, - taskfunc_post_handle_task_state, - func_str); - goto sfp_handle_multi_rate_mode_4_sff8431; - - case 0x04: /* SFF-8431 (8/4/2G Tx Rate_Select only) */ - task_p = transvr_task_creat(self, - taskfunc_sfp_setup_SFF8431_case2, - taskfunc_post_handle_task_state, - func_str); - goto sfp_handle_multi_rate_mode_4_sff8431; - - case 0x06: /* SFF-8431 (8/4/2G Independent Rx & Tx Rate_select) */ - task_p = transvr_task_creat(self, - taskfunc_sfp_setup_SFF8431_case3, - taskfunc_post_handle_task_state, - func_str); - goto sfp_handle_multi_rate_mode_4_sff8431; - - case 0x01: /* SFF-8079 (4/2/1G Rate_Select & AS0/AS1) */ - err_str = "SFF-8079 (4/2/1G Rate_Select & AS0/AS1)"; - goto sfp_handle_multi_rate_mode_4_not_support; - - case 0x08: /* FC-PI-5 (16/8/4G Rx Rate_select only) - * High=16G only, Low=8G/4G - */ - err_str = "FC-PI-5 (16/8/4G Rx Rate_select only)"; - goto sfp_handle_multi_rate_mode_4_not_support; - - case 0x0A: /* FC-PI-5 (16/8/4G Independent Rx, Tx Rate_select) - * High=16G only, Low=8G/4G - */ - err_str = "FC-PI-5 (16/8/4G Independent Rx, Tx Rate_select)"; - goto sfp_handle_multi_rate_mode_4_not_support; - - case 0x0C: /* FC-PI-6 (32/16/8G Independent Rx, Tx Rate_Select) - * High=32G only, Low = 16G/8G - */ - err_str = "FC-PI-6 (32/16/8G Independent Rx, Tx Rate_Select)"; - goto sfp_handle_multi_rate_mode_4_not_support; - - case 0x0E: /* 10/8G Rx and Tx Rate_Select controlling the operation or - * locking modes of the internal signal conditioner, retimer - * or CDR, according to the logic table defined in Table 10-2, - * High Bit Rate (10G) =9.95-11.3 Gb/s; Low Bit Rate (8G) = - * 8.5 Gb/s. In this mode, the default value of bit 110.3 (Soft - * Rate Select RS(0), Table 9-11) and of bit 118.3 (Soft Rate - * Select RS(1), Table 10-1) is 1. - */ - err_str = "cable type: 0x0E"; - goto sfp_handle_multi_rate_mode_4_not_support; - - default: - err_str = "cable type: UNKNOW"; - goto sfp_handle_multi_rate_mode_4_not_support; - } - -sfp_handle_multi_rate_mode_4_sff8431: - if (!task_p) { - err_str = "Create task fail!"; - goto sfp_handle_multi_rate_mode_4_fail_1; - } - transvr_task_set_retry(task_p, task_retry); - return EVENT_TRANSVR_TASK_WAIT; - -sfp_handle_multi_rate_mode_4_unspecified: - return EVENT_TRANSVR_TASK_DONE; - -sfp_handle_multi_rate_mode_4_not_support: - SWPS_INFO("%s: Does not support %s :%s :0x%02x\n", - func_str, err_str, self->swp_name, self->rate_id); - return EVENT_TRANSVR_TASK_DONE; - -sfp_handle_multi_rate_mode_4_fail_1: - SWPS_INFO("%s: %s :%s :0x%02x, :%d\n", - func_str, err_str, self->swp_name, self->rate_id, err_code); - return EVENT_TRANSVR_INIT_FAIL; -} - - -static int -initfunc_sfp_handle_1g_rj45(struct transvr_obj_s *self) { - - struct transvr_worker_s *task_p = NULL; - int detect_cls = DEBUG_TRANSVR_INT_VAL; - char err_str[64] = DEBUG_TRANSVR_STR_VAL; - char *func_str = "initfunc_sfp_handle_1g_rj45"; - - - if (self->info == TRANSVR_CLASS_BASE_T_1000) { - task_p = transvr_task_creat(self, - taskfunc_sfp_handle_1g_rj45, - taskfunc_post_do_nothing, - func_str); - if (!task_p) { - snprintf(err_str, sizeof(err_str), "Create task fail"); - goto err_initfunc_sfp_handle_1g_rj45; - } - transvr_task_set_retry(task_p, VAL_TRANSVR_TASK_RETRY_FOREVER); - } - return EVENT_TRANSVR_TASK_DONE; - -err_initfunc_sfp_handle_1g_rj45: - SWPS_INFO("%s: %s :%s :%d\n", - __func__, err_str, self->swp_name, detect_cls); - return EVENT_TRANSVR_TASK_FAIL; -} - - -static int -initfunc_qsfp_handle_power_mode(struct transvr_obj_s *self) { - - int err_code = EVENT_TRANSVR_EXCEP_INIT; - int power_class = DEBUG_TRANSVR_INT_VAL; - int hpmod_retry = 3; - int lpower_config = 1; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - unsigned long hpmod_delay = 500; /* msec */ - struct transvr_worker_s *task_p = NULL; - - /* Handle power mode for IOEXP */ - power_class = __qsfp_get_power_cls(self, 0); - switch (power_class) { - case 1: /* Case: Low power mode (Class = 1) */ - err_code = _taskfunc_qsfp_setup_power_mod(self, lpower_config); - if (err_code < 0){ - snprintf(err_msg, sizeof(err_msg), "Setup lpmod fail :%d", err_code); - goto err_initfunc_qsfp_handle_power_mode; - } - return EVENT_TRANSVR_TASK_DONE; - - case 2: /* Case: High power mode (Class > 1) */ - case 3: - case 4: - case 5: - case 6: - case 7: - task_p = transvr_task_creat(self, - taskfunc_qsfp_set_hpmod, - taskfunc_post_handle_task_state, - "transvr_init_qsfp"); - if (!task_p) { - snprintf(err_msg, sizeof(err_msg), "Setup lpmod fail :%d", err_code); - goto err_initfunc_qsfp_handle_power_mode; - } - transvr_task_set_retry(task_p, hpmod_retry); - transvr_task_set_delay(task_p, hpmod_delay); - return EVENT_TRANSVR_TASK_WAIT; - - default: - break; - } - snprintf(err_msg, sizeof(err_msg), "Exception case"); - goto err_initfunc_qsfp_handle_power_mode; - -err_initfunc_qsfp_handle_power_mode: - SWPS_INFO("%s: %s :%s \n", __func__, err_msg, self->swp_name); - return EVENT_TRANSVR_INIT_FAIL; -} - - -int -initfunc_qsfp28_handle_cdr(struct transvr_obj_s *self) { - - uint8_t DEFAULT_VAL_CDR = 0xff; - int CDR_FUNC_EXISTED = 0x3; - int show_err = 1; - int err_val = EVENT_TRANSVR_TASK_FAIL; - char *err_msg = DEBUG_TRANSVR_STR_VAL; - char *func_str = "initfunc_qsfp28_handle_cdr"; - - err_val = __qsfp_get_cdr_present(self, 0); - if ( (err_val < 0) || - (err_val == DEBUG_TRANSVR_HEX_VAL) ) { - err_msg = "detect cdr_present fail!"; - goto err_taskfunc_qsfp_handle_cdr_1; - } - if (err_val == CDR_FUNC_EXISTED) { - err_val = _common_set_uint8_attr(self, - self->eeprom_map_p->addr_cdr, - self->eeprom_map_p->addr_cdr, - self->eeprom_map_p->offset_cdr, - DEFAULT_VAL_CDR, - &(self->cdr), - func_str, - show_err); - if (err_val < 0) { - err_msg = "set CDR fail!"; - goto err_taskfunc_qsfp_handle_cdr_1; - } - } - return EVENT_TRANSVR_TASK_DONE; - -err_taskfunc_qsfp_handle_cdr_1: - SWPS_INFO("%s: %s :%d :%s\n", - func_str, err_msg, err_val, self->swp_name); - return EVENT_TRANSVR_INIT_FAIL; -} - -/* ========== Object functions for Final State Machine ========== - */ -int -is_plugged(struct transvr_obj_s *self){ - - int limit = 63; - int present = DEBUG_TRANSVR_INT_VAL; - char emsg[64] = DEBUG_TRANSVR_STR_VAL; - struct ioexp_obj_s *ioexp_p = self->ioexp_obj_p; - - if (!ioexp_p) { - snprintf(emsg, limit, "ioexp_p is null!"); - goto err_is_plugged_1; - } - present = ioexp_p->get_present(ioexp_p, self->ioexp_virt_offset); - switch (present){ - case 0: - return 1; - case 1: - return 0; - case ERR_IOEXP_UNINIT: - snprintf(emsg, limit, "ioexp_p not ready!"); - goto err_is_plugged_1; - default: - if (ioexp_p->state == STATE_IOEXP_INIT){ - snprintf(emsg, limit, "ioexp_p not ready!"); - goto err_is_plugged_1; - } - break; - } - SWPS_INFO("%s: Exception case! :%d :%d\n", - __func__, present, ioexp_p->state); - return 0; - -err_is_plugged_1: - SWPS_DEBUG("%s: %s\n", __func__, emsg); - return 0; -} - - -static int -detect_transvr_type(struct transvr_obj_s* self){ - - int type = TRANSVR_TYPE_ERROR; - - self->i2c_client_p->addr = VAL_TRANSVR_COMID_ARREESS; - type = i2c_smbus_read_byte_data(self->i2c_client_p, - VAL_TRANSVR_COMID_OFFSET); - - /* Case: 1. Wait transceiver I2C module. - * 2. Transceiver I2C module failure. - * Note: 1. SFF allow maximum transceiver initial time is 2 second. So, there - * are exist some case that we need to wait transceiver. - * For these case, we keeps status on "TRANSVR_TYPE_UNPLUGGED", than - * state machine will keep trace with it. - * 2. There exist some I2C failure case we need to handle. Such as user - * insert the failure transceiver, or any reason cause it abnormal. - */ - if (type < 0){ - switch (type) { - case -EIO: - SWPS_DEBUG("%s: %s smbus return:-5 (I/O error)\n", - __func__, self->swp_name); - return TRANSVR_TYPE_UNPLUGGED; - case -ENXIO: - SWPS_DEBUG("%s: %s smbus return:-6 (No such device or address)\n", - __func__, self->swp_name); - return TRANSVR_TYPE_UNPLUGGED; - default: - break; - } - SWPS_INFO("%s: %s unexpected smbus return:%d \n", - __func__, self->swp_name, type); - return TRANSVR_TYPE_ERROR; - } - /* Identify valid transceiver type */ - switch (type){ - case TRANSVR_TYPE_SFP: - case TRANSVR_TYPE_QSFP: - case TRANSVR_TYPE_QSFP_PLUS: - case TRANSVR_TYPE_QSFP_28: - break; - case TRANSVR_TYPE_UNKNOW_1: - case TRANSVR_TYPE_UNKNOW_2: - type = TRANSVR_TYPE_UNKNOW_2; - break; - default: - SWPS_DEBUG("%s: unknow type:0x%02x \n", __func__, type); - type = TRANSVR_TYPE_ERROR; - break; - } - return type; -} - - -static int -detect_transvr_state(struct transvr_obj_s *self, - int result[2]){ - /* [return] [result-0] [result-1] - * 0 STATE_TRANSVR_CONNECTED TRANSVR_TYPE_FAKE - * 0 STATE_TRANSVR_DISCONNECTED TRANSVR_TYPE_UNPLUGGED - * 0 STATE_TRANSVR_ISOLATED TRANSVR_TYPE_ERROR - * 0 STATE_TRANSVR_INIT / - * 0 STATE_TRANSVR_SWAPPED - * 0 STATE_TRANSVR_CONNECTED - * ERR_TRNASVR_BE_ISOLATED STATE_TRANSVR_ISOLATED TRANSVR_TYPE_ERROR - * ERR_TRANSVR_I2C_CRASH STATE_TRANSVR_UNEXCEPTED TRANSVR_TYPE_ERROR - * ERR_TRANSVR_UNEXCPT STATE_TRANSVR_UNEXCEPTED TRANSVR_TYPE_UNKNOW_1/2 - */ - result[0] = STATE_TRANSVR_UNEXCEPTED; /* For return state */ - result[1] = TRANSVR_TYPE_ERROR; /* For return type */ - - /* Case1: Fake type */ - if (self->type == TRANSVR_TYPE_FAKE){ - result[0] = STATE_TRANSVR_CONNECTED; - result[1] = TRANSVR_TYPE_FAKE; - return 0; - } - /* Case2: Transceiver unplugged */ - if (!is_plugged(self)){ - result[0] = STATE_TRANSVR_DISCONNECTED; - result[1] = TRANSVR_TYPE_UNPLUGGED; - return 0; - } - /* Case3: Transceiver be isolated */ - if (self->state == STATE_TRANSVR_ISOLATED){ - result[0] = STATE_TRANSVR_ISOLATED; - result[1] = TRANSVR_TYPE_ERROR; - return ERR_TRNASVR_BE_ISOLATED; - } - /* Case4: Transceiver plugged */ - result[1] = detect_transvr_type(self); - /* Case4.1: I2C topology crash - * Note : There are some I2C issues cause by transceiver/cables. - * We need to check topology status when user insert it. - * But in this step, we can't not ensure this is the issues - * port. So, it return the ERR_TRANSVR_I2C_CRASH, then upper - * layer will diagnostic I2C topology. - */ - if (check_channel_tier_1() < 0) { - SWPS_INFO("%s: %s detect I2C crash :%d\n", - __func__, self->swp_name, self->state); - result[0] = STATE_TRANSVR_UNEXCEPTED; - result[1] = TRANSVR_TYPE_ERROR; - return ERR_TRANSVR_I2C_CRASH; - } - /* Case4.2: System initial not ready, - * Note : Sometime i2c channel or transceiver EEPROM will delay that will - * cause system in inconsistent state between EEPROM and IOEXP. - * In this case, SWP transceiver object keep state at LINK_DOWN - * to wait system ready. - * By the way, State Machine will handle these case. - */ - if (result[1] == TRANSVR_TYPE_UNPLUGGED){ - result[0] = STATE_TRANSVR_DISCONNECTED; - return 0; - } - /* Case4.3: Error transceiver type */ - if (result[1] == TRANSVR_TYPE_ERROR){ - result[0] = STATE_TRANSVR_ISOLATED; - SWPS_INFO("%s: %s detect error type\n", __func__, self->swp_name); - alarm_msg_2_user(self, "detected transceiver/cables not meet SFF standard!"); - return ERR_TRNASVR_BE_ISOLATED; - } - /* Case3.3: Unknow transceiver type */ - if ((result[1] == TRANSVR_TYPE_UNKNOW_1) || - (result[1] == TRANSVR_TYPE_UNKNOW_2) ){ - result[0] = STATE_TRANSVR_UNEXCEPTED; - return ERR_TRANSVR_UNEXCPT; - } - /* Case3.4: During initial process */ - if (self->state == STATE_TRANSVR_INIT){ - result[0] = STATE_TRANSVR_INIT; - return 0; - } - /* Case3.5: Transceiver be swapped */ - if (self->type != result[1]){ - result[0] = STATE_TRANSVR_SWAPPED; - return 0; - } - /* Case3.6: Link up state */ - result[0] = STATE_TRANSVR_CONNECTED; - return 0; -} - - -int -_sfp_detect_class_by_extend_comp(struct transvr_obj_s* self) { - /* Reference: SFF-8024 (v3.8) - */ - int detect_val = _sfp_get_comp_extended(self); - - switch(detect_val) { - case 0x00: /* Unspecified */ - return TRANSVR_CLASS_UNSPECIFIED; - - case 0x01: /* 100G AOC (Active Optical Cable) or 25GAUI C2M */ - case 0x18: /* 100G AOC or 25GAUI C2M AOC. */ - return TRANSVR_CLASS_OPTICAL_25G_AOC; - - case 0x02: /* 100GBASE-SR4 or 25GBASE-SR */ - return TRANSVR_CLASS_OPTICAL_25G_SR; - - case 0x03: /* 100GBASE-LR4 or 25GBASE-LR */ - return TRANSVR_CLASS_OPTICAL_25G_LR; - - case 0x04: /* 100GBASE-ER4 or 25GBASE-ER */ - return TRANSVR_CLASS_OPTICAL_25G_ER; - - case 0x08: /* 100G ACC (Active Copper Cable) or 25GAUI C2M ACC. */ - case 0x0b: /* 100GBASE-CR4 or 25GBASE-CR CA-L */ - case 0x0c: /* 25GBASE-CR CA-S */ - case 0x0d: /* 25GBASE-CR CA-N */ - case 0x19: /* 100G ACC or 25GAUI C2M ACC. */ - return TRANSVR_CLASS_COPPER_L1_25G; - - default: - break; - } - SWPS_INFO("%s: Unexcept value:0x%02x\n :%s", - __func__, detect_val, self->swp_name); - return TRANSVR_CLASS_ERROR; -} - - -int -_sfp_detect_class_by_10_ethernet(struct transvr_obj_s* self) { - /* Reference: SFF-8472 (v12.2) - */ - int detect_val = DEBUG_TRANSVR_INT_VAL; - - detect_val = _sfp_get_comp_10g_eth_comp(self); - /* Case: Unspecified */ - if (detect_val == 0x00) { - return TRANSVR_CLASS_UNSPECIFIED; - } - /* Case: 10G Optical (x1) */ - if ((detect_val & 0x10) == 0x10) { /* 00010000 : 10GBASE-SR */ - return TRANSVR_CLASS_OPTICAL_10G_S_SR; - } - if ( ((detect_val & 0x20) == 0x20) || /* 00100000 : 10GBASE-LR */ - ((detect_val & 0x40) == 0x40) ){ /* 01000000 : 10GBASE-LRM */ - return TRANSVR_CLASS_OPTICAL_10G_S_LR; - } - if ((detect_val & 0x80) == 0x80) { /* 10000000 : 10GBASE-ER */ - return TRANSVR_CLASS_OPTICAL_10G_S_ER; - } - /* Case: ERROR */ - SWPS_INFO("%s: Unexcept value:0x%02x\n :%s", - __func__, detect_val, self->swp_name); - return TRANSVR_CLASS_ERROR; -} - - -int -_sfp_detect_if_sp_by_br(struct transvr_obj_s* self) { - - int lower_bound_1g = 0x0b; - int upper_bound_1g = 0x1A; - int lower_bound_10g = 0x60; - int upper_bound_10g = 0x75; - int lower_bound_25g = 0xf0; - int upper_bound_25g = 0xff; - int notmal_br = DEBUG_TRANSVR_INT_VAL; - - notmal_br = (int)(self->br); /* updated by update_all() */ - /* Check 25G */ - if ((notmal_br >= lower_bound_25g) && - (notmal_br <= upper_bound_25g) ) { - return TRANSVR_CLASS_25G; - } - /* Check 10G */ - if ((notmal_br >= lower_bound_10g) && - (notmal_br <= upper_bound_10g) ) { - return TRANSVR_CLASS_10G; - } - /* Check 1G */ - if ((notmal_br >= lower_bound_1g) && - (notmal_br <= upper_bound_1g) ) { - return TRANSVR_CLASS_1G; - } - return TRANSVR_CLASS_UNSPECIFIED; -} - - -int -_sfp_detect_class_by_1g_ethernet(struct transvr_obj_s* self) { - /* Reference: SFF-8472 (v12.2) - */ - int detect_val = DEBUG_TRANSVR_INT_VAL; - int speed_br = DEBUG_TRANSVR_INT_VAL; - int speed_tmp = DEBUG_TRANSVR_INT_VAL; - char err_str[64] = DEBUG_TRANSVR_STR_VAL; - - speed_br = _sfp_detect_if_sp_by_br(self); - detect_val = _sfp_get_comp_1g_eth_comp(self); - - if (detect_val < 0) { - snprintf(err_str, sizeof(err_str), "Detect abnormal value:%d", detect_val); - goto err_p_sfp_detect_class_by_1g_ethernet; - } - /* Case: Unspecified */ - if (detect_val == 0x00) { - return TRANSVR_CLASS_UNSPECIFIED; - } - /* Case: 1G (x1) */ - if ((detect_val & 0x01) == 0x01) { /* 00000001 : 1000BASE-SX */ - speed_tmp = TRANSVR_CLASS_OPTICAL_1G_SX; - goto ok_sfp_detect_class_by_1g_ethernet_4_check_br_10g; - } - if ((detect_val & 0x02) == 0x02) { /* 00000010 : 1000BASE-LX *3 */ - speed_tmp = TRANSVR_CLASS_OPTICAL_1G_LX; - goto ok_sfp_detect_class_by_1g_ethernet_4_check_br_10g; - } - if ((detect_val & 0x04) == 0x04) { /* 00000100 : 1000BASE-CX */ - speed_tmp = TRANSVR_CLASS_COPPER_L1_1G; - goto ok_sfp_detect_class_by_1g_ethernet_4_check_br_10g; - } - /* Case: 1000 Base-T (x1) */ - if ((detect_val & 0x08) == 0x08) { /* 00001000 : 1000BASE-T */ - return TRANSVR_CLASS_BASE_T_1000; - } - /* Case: 100 Base */ - if ( ((detect_val & 0x10) == 0x10) || /* 00010000 : 100BASE-LX/LX10 */ - ((detect_val & 0x20) == 0x20) || /* 00100000 : 100BASE-FX */ - ((detect_val & 0x40) == 0x40) || /* 01000000 : BASE-BX10 *3 */ - ((detect_val & 0x80) == 0x80) ){ /* 10000000 : BASE-PX *3 */ - return TRANSVR_CLASS_OPTICAL_100; - } - /* Case: ERROR */ - snprintf(err_str, sizeof(err_str), "Case:ERROR, value:%d", detect_val); - goto err_p_sfp_detect_class_by_1g_ethernet; - -ok_sfp_detect_class_by_1g_ethernet_4_check_br_10g: - switch (speed_br) { - case TRANSVR_CLASS_UNSPECIFIED: - case TRANSVR_CLASS_1G: - return speed_tmp; - case TRANSVR_CLASS_10G: - goto ok_sfp_detect_class_by_1g_ethernet_4_transfer_10G; - } - -ok_sfp_detect_class_by_1g_ethernet_4_transfer_10G: - switch (speed_tmp) { - case TRANSVR_CLASS_OPTICAL_1G_SX: - return TRANSVR_CLASS_OPTICAL_10G_S_SR; - case TRANSVR_CLASS_OPTICAL_1G_LX: - return TRANSVR_CLASS_OPTICAL_10G_S_LR; - case TRANSVR_CLASS_COPPER_L1_1G: - return TRANSVR_CLASS_COPPER_L1_10G; - default: - break; - } - snprintf(err_str, sizeof(err_str), "transfer_1to10 fail, speed:%d", speed_tmp); - goto err_p_sfp_detect_class_by_1g_ethernet; - -err_p_sfp_detect_class_by_1g_ethernet: - SWPS_INFO("%s: %s :%s", __func__, err_str, self->swp_name); - return TRANSVR_CLASS_ERROR; -} - - -int -_sfp_detect_class_by_feature(struct transvr_obj_s* self) { - /* Reference: SFF-8024 (v3.8) - */ - int is_active = 0; - int conn_val = DEBUG_TRANSVR_INT_VAL; - int check_val = DEBUG_TRANSVR_INT_VAL; - int wave_len = DEBUG_TRANSVR_INT_VAL; - int speed_val = DEBUG_TRANSVR_INT_VAL; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - - speed_val = _sfp_detect_if_sp_by_br(self); - conn_val = _sfp_get_connector_type(self); - - switch(conn_val) { - case 0x00: /* Unspecified */ - goto ok_sfp_detect_class_by_feature_4_check_active_passive; - case 0x07: /* LC (Lucent Connector) */ - case 0x0b: /* Optical Pigtail */ - case 0x0c: /* MPO 1x12 */ - case 0x0d: /* MPO 2x16 */ - /* - * ToDo: Need verify Optical Pigtail - */ - goto ok_sfp_detect_class_by_feature_4_optiocal; - case 0x21: /* Copper pigtail */ - /* - * ToDo: Need check ACC use case - */ - goto ok_sfp_detect_class_by_feature_4_check_active_passive; - case 0x23: /* No separable connector */ - /* - * ToDo: Standard not clear, not all transceiver vendor - * have the same defined - */ - goto ok_sfp_detect_class_by_feature_4_check_active_passive; - default: - break; - } - goto ok_sfp_detect_class_by_feature_4_unknow; - -ok_sfp_detect_class_by_feature_4_check_active_passive: - check_val = _sfp_get_cable_tech(self); - switch(check_val) { - case 0x00: /* Unspecified */ - goto ok_sfp_detect_class_by_feature_4_unknow; - case 0x04: /* Passive */ - goto ok_sfp_detect_class_by_feature_4_copper; - case 0x08: /* Active */ - is_active = 1; - goto ok_sfp_detect_class_by_feature_4_aoc; - default: - snprintf(err_msg, sizeof(err_msg), - "_sfp_get_cable_tech return Non define value:%d", - check_val); - break; - } - goto err_sfp_detect_class_by_feature_1; - -ok_sfp_detect_class_by_feature_4_optiocal: - wave_len = _common_count_wavelength(self, - self->wavelength[0], - self->wavelength[1]); - switch(speed_val) { - case TRANSVR_CLASS_25G: - switch (wave_len) { - case VAL_OPTICAL_WAVELENGTH_SR: - return TRANSVR_CLASS_OPTICAL_25G_SR; - case VAL_OPTICAL_WAVELENGTH_LR: - return TRANSVR_CLASS_OPTICAL_25G_LR; - case VAL_OPTICAL_WAVELENGTH_ER: - return TRANSVR_CLASS_OPTICAL_25G_ER; - default: - break; - } - return TRANSVR_CLASS_OPTICAL_25G; - - case TRANSVR_CLASS_10G: - switch (wave_len) { - case VAL_OPTICAL_WAVELENGTH_SR: - return TRANSVR_CLASS_OPTICAL_10G_S_SR; - case VAL_OPTICAL_WAVELENGTH_LR: - return TRANSVR_CLASS_OPTICAL_10G_S_LR; - case VAL_OPTICAL_WAVELENGTH_ER: - return TRANSVR_CLASS_OPTICAL_10G_S_ER; - default: - break; - } - return TRANSVR_CLASS_OPTICAL_10G; - - case TRANSVR_CLASS_1G: - switch (wave_len) { - case VAL_OPTICAL_WAVELENGTH_SR: - return TRANSVR_CLASS_OPTICAL_1G_SX; - case VAL_OPTICAL_WAVELENGTH_LR: - return TRANSVR_CLASS_OPTICAL_1G_LX; - case VAL_OPTICAL_WAVELENGTH_ER: - return TRANSVR_CLASS_OPTICAL_1G_EX; - default: - break; - } - return TRANSVR_CLASS_OPTICAL_1G; - - default: - return TRANSVR_CLASS_OPTICAL; - } - -ok_sfp_detect_class_by_feature_4_aoc: - switch(speed_val) { - case TRANSVR_CLASS_25G: - return TRANSVR_CLASS_OPTICAL_25G_AOC; - case TRANSVR_CLASS_10G: - return TRANSVR_CLASS_OPTICAL_10G_S_AOC; - case TRANSVR_CLASS_1G: - return TRANSVR_CLASS_OPTICAL_1G_AOC; - default: - break; - } - goto ok_sfp_detect_class_by_feature_4_unknow; - -ok_sfp_detect_class_by_feature_4_copper: - switch(speed_val) { - case TRANSVR_CLASS_25G: - return TRANSVR_CLASS_COPPER_L1_25G; - case TRANSVR_CLASS_10G: - return TRANSVR_CLASS_COPPER_L1_10G; - case TRANSVR_CLASS_1G: - return TRANSVR_CLASS_COPPER_L1_1G; - default: - return TRANSVR_CLASS_COPPER; - } - -ok_sfp_detect_class_by_feature_4_unknow: - return TRANSVR_CLASS_UNSPECIFIED; - -err_sfp_detect_class_by_feature_1: - SWPS_INFO("%s: %s\n :%s", __func__, err_msg, self->swp_name); - return TRANSVR_CLASS_ERROR; -} - - -int -sft_detect_transvr_class(struct transvr_obj_s* self) { - - int detect_val = DEBUG_TRANSVR_INT_VAL; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - - /* Check Extended Compliance */ - detect_val = _sfp_detect_class_by_extend_comp(self); - switch(detect_val) { - case TRANSVR_CLASS_UNSPECIFIED: - break; - case TRANSVR_CLASS_OPTICAL_25G_AOC: - case TRANSVR_CLASS_OPTICAL_25G_SR: - case TRANSVR_CLASS_OPTICAL_25G_LR: - case TRANSVR_CLASS_OPTICAL_25G_ER: - case TRANSVR_CLASS_COPPER_L1_25G: - return detect_val; - default: - snprintf(err_msg, sizeof(err_msg), - "Detect undefined extend_comp:%d", - detect_val); - goto err_sft_detect_transceiver_class_1; - } - /* Check 10G Compliance */ - detect_val = _sfp_detect_class_by_10_ethernet(self); - switch(detect_val) { - case TRANSVR_CLASS_UNSPECIFIED: - break; - case TRANSVR_CLASS_OPTICAL_10G_S_SR: - case TRANSVR_CLASS_OPTICAL_10G_S_LR: - case TRANSVR_CLASS_OPTICAL_10G_S_ER: - return detect_val; - default: - snprintf(err_msg, sizeof(err_msg), - "Detect undefined 10G_eth:%d", - detect_val); - goto err_sft_detect_transceiver_class_1; - } - /* Check 1G Compliance */ - detect_val = _sfp_detect_class_by_1g_ethernet(self); - switch(detect_val) { - case TRANSVR_CLASS_UNSPECIFIED: - break; - case TRANSVR_CLASS_OPTICAL_1G_SX: - case TRANSVR_CLASS_OPTICAL_1G_LX: - case TRANSVR_CLASS_COPPER_L1_1G: - case TRANSVR_CLASS_BASE_T_1000: - case TRANSVR_CLASS_OPTICAL_100: - /* - * ToDo: Need Check 0.1G - */ - case TRANSVR_CLASS_OPTICAL_10G_S_SR: - case TRANSVR_CLASS_OPTICAL_10G_S_LR: - case TRANSVR_CLASS_COPPER_L1_10G: - /* Transfer speed case - * => Example: Raycom 10G DAC - */ - return detect_val; - default: - snprintf(err_msg, sizeof(err_msg), - "Detect undefined 1G_eth:%d", - detect_val); - goto err_sft_detect_transceiver_class_1; - } - /* Check by connector, br, wavelength */ - detect_val = _sfp_detect_class_by_feature(self); - switch(detect_val) { - case TRANSVR_CLASS_UNSPECIFIED: - break; - case TRANSVR_CLASS_OPTICAL: - case TRANSVR_CLASS_OPTICAL_1G: - case TRANSVR_CLASS_OPTICAL_1G_SX: - case TRANSVR_CLASS_OPTICAL_1G_LX: - case TRANSVR_CLASS_OPTICAL_1G_EX: - case TRANSVR_CLASS_OPTICAL_1G_AOC: - case TRANSVR_CLASS_OPTICAL_10G: - case TRANSVR_CLASS_OPTICAL_10G_S_SR: - case TRANSVR_CLASS_OPTICAL_10G_S_LR: - case TRANSVR_CLASS_OPTICAL_10G_S_ER: - case TRANSVR_CLASS_OPTICAL_10G_S_AOC: - case TRANSVR_CLASS_OPTICAL_25G: - case TRANSVR_CLASS_OPTICAL_25G_SR: - case TRANSVR_CLASS_OPTICAL_25G_LR: - case TRANSVR_CLASS_OPTICAL_25G_ER: - case TRANSVR_CLASS_OPTICAL_25G_AOC: - case TRANSVR_CLASS_COPPER: - case TRANSVR_CLASS_COPPER_L1_1G: - case TRANSVR_CLASS_COPPER_L1_10G: - case TRANSVR_CLASS_COPPER_L1_25G: - return detect_val; - default: - snprintf(err_msg, sizeof(err_msg), - "Detect undefined get_connector:%d", - detect_val); - goto err_sft_detect_transceiver_class_1; - } - /* Exception case: Can't verify */ - snprintf(err_msg, sizeof(err_msg), "Can not identify!"); - goto err_sft_detect_transceiver_class_1; - -err_sft_detect_transceiver_class_1: - SWPS_INFO("%s: %s :%s\n", __func__, err_msg, self->swp_name); - return TRANSVR_CLASS_ERROR; -} - - -int -_sfp_set_trident2_if_type(struct transvr_obj_s* self, - int transvr_cls, - char *result){ - - int lmax = 8; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - - switch(transvr_cls) { - case TRANSVR_CLASS_ERROR: - case TRANSVR_CLASS_UNSPECIFIED: - break; - /* 25G OPTICAL */ - case TRANSVR_CLASS_OPTICAL_25G_AOC: - case TRANSVR_CLASS_OPTICAL_25G_SR: - case TRANSVR_CLASS_OPTICAL_25G_LR: - case TRANSVR_CLASS_OPTICAL_25G_ER: - case TRANSVR_CLASS_OPTICAL_25G: - return snprintf(result, lmax, TRANSVR_IF_SFI); - /* 25G COPPER */ - case TRANSVR_CLASS_COPPER_L1_25G: - return snprintf(result, lmax, TRANSVR_IF_SFI); - /* 10G OPTICAL */ - case TRANSVR_CLASS_OPTICAL_10G_S_AOC: - case TRANSVR_CLASS_OPTICAL_10G_S_SR: - case TRANSVR_CLASS_OPTICAL_10G_S_LR: - case TRANSVR_CLASS_OPTICAL_10G_S_ER: - case TRANSVR_CLASS_OPTICAL_10G: - return snprintf(result, lmax, TRANSVR_IF_SFI); - /* 10G COPPER */ - case TRANSVR_CLASS_COPPER_L1_10G: - return snprintf(result, lmax, TRANSVR_IF_SFI); - /* 1G OPTICAL */ - case TRANSVR_CLASS_OPTICAL_1G_AOC: - case TRANSVR_CLASS_OPTICAL_1G_SX: - case TRANSVR_CLASS_OPTICAL_1G_LX: - case TRANSVR_CLASS_OPTICAL_1G_EX: - case TRANSVR_CLASS_OPTICAL_1G: - return snprintf(result, lmax, TRANSVR_IF_IF_GMII); - /* 1G COPPER */ - case TRANSVR_CLASS_COPPER_L1_1G: - return snprintf(result, lmax, TRANSVR_IF_IF_GMII); - /* 1G BASE_T */ - case TRANSVR_CLASS_BASE_T_1000: - return snprintf(result, lmax, TRANSVR_IF_IF_GMII); - /* 100 Base */ - case TRANSVR_CLASS_OPTICAL_100: - return snprintf(result, lmax, TRANSVR_IF_IF_GMII); - default: - snprintf(err_msg, sizeof(err_msg), - "Detect undefined value:%d", - transvr_cls); - goto err_sfp_set_trident2_if_type_1; - } - /* Exception case: Can't verify */ - snprintf(err_msg, sizeof(err_msg), "Can not identify!"); - goto err_sfp_set_trident2_if_type_1; - -err_sfp_set_trident2_if_type_1: - snprintf(result, lmax, TRANSVR_UEVENT_UNKNOW); - SWPS_INFO("%s: %s :%s\n", __func__, err_msg, self->swp_name); - return ERR_TRANSVR_ABNORMAL; -} - - -int -_sfp_set_tomahawk_if_type(struct transvr_obj_s* self, - int transvr_cls, - char *result) { - - int lmax = 8; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - - switch(transvr_cls) { - case TRANSVR_CLASS_ERROR: - case TRANSVR_CLASS_UNSPECIFIED: - break; - /* 25G OPTICAL */ - case TRANSVR_CLASS_OPTICAL_25G_AOC: - case TRANSVR_CLASS_OPTICAL_25G_SR: - case TRANSVR_CLASS_OPTICAL_25G_LR: - case TRANSVR_CLASS_OPTICAL_25G_ER: - case TRANSVR_CLASS_OPTICAL_25G: - return snprintf(result, lmax, TRANSVR_IF_SR); - /* 25G COPPER */ - case TRANSVR_CLASS_COPPER_L1_25G: - return snprintf(result, lmax, TRANSVR_IF_KR); - /* 10G OPTICAL */ - case TRANSVR_CLASS_OPTICAL_10G_S_AOC: - case TRANSVR_CLASS_OPTICAL_10G_S_SR: - case TRANSVR_CLASS_OPTICAL_10G_S_LR: - case TRANSVR_CLASS_OPTICAL_10G_S_ER: - case TRANSVR_CLASS_OPTICAL_10G: - return snprintf(result, lmax, TRANSVR_IF_SFI); - /* 10G COPPER */ - case TRANSVR_CLASS_COPPER_L1_10G: - return snprintf(result, lmax, TRANSVR_IF_SFI); - /* 1G OPTICAL */ - case TRANSVR_CLASS_OPTICAL_1G_AOC: - case TRANSVR_CLASS_OPTICAL_1G_SX: - case TRANSVR_CLASS_OPTICAL_1G_LX: - case TRANSVR_CLASS_OPTICAL_1G_EX: - case TRANSVR_CLASS_OPTICAL_1G: - return snprintf(result, lmax, TRANSVR_IF_IF_GMII); - /* 1G COPPER */ - case TRANSVR_CLASS_COPPER_L1_1G: - return snprintf(result, lmax, TRANSVR_IF_IF_GMII); - /* 1G BASE_T */ - case TRANSVR_CLASS_BASE_T_1000: - return snprintf(result, lmax, TRANSVR_IF_IF_GMII); - /* 100 Base */ - case TRANSVR_CLASS_OPTICAL_100: - return snprintf(result, lmax, TRANSVR_IF_IF_GMII); - default: - snprintf(err_msg, sizeof(err_msg), - "Detect undefined value:%d", - transvr_cls); - goto err_sfp_set_tomahawk_if_type_1; - } - /* Exception case: Can't verify */ - snprintf(err_msg, sizeof(err_msg), "Can not identify!"); - goto err_sfp_set_tomahawk_if_type_1; - -err_sfp_set_tomahawk_if_type_1: - snprintf(result, lmax, TRANSVR_UEVENT_UNKNOW); - SWPS_INFO("%s: %s\n :%s", __func__, err_msg, self->swp_name); - return ERR_TRANSVR_ABNORMAL; -} - - -int -_sfp_set_bf_tofino_if_type(struct transvr_obj_s* self, - int transvr_cls, - char *result) { - /* (TBD) - * Due to BF looks like doesn't have interface type. - * We bypass it currently. - */ - int lmax = 8; - return snprintf(result, lmax, TRANSVR_UEVENT_UNKNOW); -} - - -int -_sfp_detect_if_type(struct transvr_obj_s* self, - char *result){ - - int lmax = 8; - int detect_cls = DEBUG_TRANSVR_INT_VAL; - - detect_cls = sft_detect_transvr_class(self); - switch (self->chipset_type) { - case BCM_CHIP_TYPE_TRIDENT_2: - return _sfp_set_trident2_if_type(self, detect_cls, result); - - case BCM_CHIP_TYPE_TRIDENT_3: - case BCM_CHIP_TYPE_TOMAHAWK: - return _sfp_set_tomahawk_if_type(self, detect_cls, result); - - case BF_CHIP_TYPE_TOFINO: - return _sfp_set_bf_tofino_if_type(self, detect_cls, result); - - default: - SWPS_INFO("%s: non-defined chipset_type:%d :%s\n", - __func__, self->chipset_type, self->swp_name); - break; - } - snprintf(result, lmax, TRANSVR_UEVENT_UNKNOW); - return ERR_TRANSVR_ABNORMAL; -} - - -int -sfp_get_if_type(struct transvr_obj_s *self, - char *buf_p){ - - int lmax = 16; - char tmp_result[16] = DEBUG_TRANSVR_STR_VAL; - - if (self->state != STATE_TRANSVR_CONNECTED) { - return snprintf(buf_p, lmax, "%d\n", self->state); - } - if (_sfp_detect_if_type(self, tmp_result) < 0) { - return snprintf(buf_p, lmax, "%d\n", ERR_TRANSVR_ABNORMAL); - } - return snprintf(buf_p, lmax, "%s\n", tmp_result); -} - - -int -_sfp_detect_if_speed(struct transvr_obj_s* self, - char *result){ - - int lmax = 16; - int detect_val = DEBUG_TRANSVR_INT_VAL; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - - detect_val = sft_detect_transvr_class(self); - switch(detect_val) { - case TRANSVR_CLASS_ERROR: - case TRANSVR_CLASS_UNSPECIFIED: - break; - /* 25G OPTICAL */ - case TRANSVR_CLASS_OPTICAL_25G_AOC: - case TRANSVR_CLASS_OPTICAL_25G_SR: - case TRANSVR_CLASS_OPTICAL_25G_LR: - case TRANSVR_CLASS_OPTICAL_25G_ER: - case TRANSVR_CLASS_OPTICAL_25G: - return snprintf(result, lmax, TRANSVR_IF_SP_25G); - /* 25G COPPER */ - case TRANSVR_CLASS_COPPER_L1_25G: - return snprintf(result, lmax, TRANSVR_IF_SP_25G); - /* 10G OPTICAL */ - case TRANSVR_CLASS_OPTICAL_10G_S_AOC: - case TRANSVR_CLASS_OPTICAL_10G_S_SR: - case TRANSVR_CLASS_OPTICAL_10G_S_LR: - case TRANSVR_CLASS_OPTICAL_10G_S_ER: - case TRANSVR_CLASS_OPTICAL_10G: - return snprintf(result, lmax, TRANSVR_IF_SP_10G); - /* 10G COPPER */ - case TRANSVR_CLASS_COPPER_L1_10G: - return snprintf(result, lmax, TRANSVR_IF_SP_10G); - /* 1G OPTICAL */ - case TRANSVR_CLASS_OPTICAL_1G_AOC: - case TRANSVR_CLASS_OPTICAL_1G_SX: - case TRANSVR_CLASS_OPTICAL_1G_LX: - case TRANSVR_CLASS_OPTICAL_1G_EX: - case TRANSVR_CLASS_OPTICAL_1G: - return snprintf(result, lmax, TRANSVR_IF_SP_1G); - /* 1G COPPER */ - case TRANSVR_CLASS_COPPER_L1_1G: - return snprintf(result, lmax, TRANSVR_IF_SP_1G); - /* 1G BASE_T */ - case TRANSVR_CLASS_BASE_T_1000: - return snprintf(result, lmax, TRANSVR_IF_SP_1G); - /* 100 Base */ - case TRANSVR_CLASS_OPTICAL_100: - return snprintf(result, lmax, TRANSVR_IF_SP_100); - default: - snprintf(err_msg, sizeof(err_msg), - "Detect undefined value:%d", - detect_val); - goto err_sfp_detect_if_speed_1; - } - /* Check by BR */ - detect_val = _sfp_detect_if_sp_by_br(self); - switch (detect_val) { - case TRANSVR_CLASS_25G: - return snprintf(result, lmax, TRANSVR_IF_SP_25G); - case TRANSVR_CLASS_10G: - return snprintf(result, lmax, TRANSVR_IF_SP_10G); - case TRANSVR_CLASS_1G: - return snprintf(result, lmax, TRANSVR_IF_SP_1G); - default: - break; - } - /* Exception case: Can't verify */ - snprintf(err_msg, sizeof(err_msg), "Can not identify!"); - goto err_sfp_detect_if_speed_1; - -err_sfp_detect_if_speed_1: - snprintf(result, lmax, TRANSVR_UEVENT_UNKNOW); - SWPS_INFO("%s %s\n :%s", __func__, err_msg, self->swp_name); - return ERR_TRANSVR_ABNORMAL; -} - - -int -sfp_get_if_speed(struct transvr_obj_s *self, - char *buf_p){ - - int lmax = 16; - char tmp_result[16] = DEBUG_TRANSVR_STR_VAL; - - if (self->state != STATE_TRANSVR_CONNECTED) { - return snprintf(buf_p, lmax, "%d\n", self->state); - } - if (_sfp_detect_if_speed(self, tmp_result) < 0) { - return snprintf(buf_p, lmax, "%d\n", ERR_TRANSVR_ABNORMAL); - } - return snprintf(buf_p, lmax, "%s\n", tmp_result); -} - - -int -_qsfp_detect_class_by_extend_comp(struct transvr_obj_s* self) { - /* Reference: SFF-8024 (v3.8) - */ - int detect_val = DEBUG_TRANSVR_INT_VAL; - - detect_val = _qsfp_get_comp_extended(self); - switch(detect_val) { - case 0x00: /* Unspecified */ - return TRANSVR_CLASS_UNSPECIFIED; - - case 0x01: /* 100G AOC (Active Optical Cable) or 25GAUI C2M */ - case 0x18: /* 100G AOC or 25GAUI C2M AOC. */ - return TRANSVR_CLASS_OPTICAL_100G_AOC; - - case 0x06: /* 100G CWDM4 */ - case 0x09: /* Obsolete (assigned before 100G CWDM4 MSA required FEC) */ - case 0x17: /* 100G CLR4 */ - case 0x1A: /* 100GE-DWDM2 */ - return TRANSVR_CLASS_OPTICAL_100G; - - case 0x02: /* 100GBASE-SR4 or 25GBASE-SR */ - return TRANSVR_CLASS_OPTICAL_100G_SR4; - - case 0x03: /* 100GBASE-LR4 or 25GBASE-LR */ - return TRANSVR_CLASS_OPTICAL_100G_LR4; - - case 0x04: /* 100GBASE-ER4 or 25GBASE-ER */ - return TRANSVR_CLASS_OPTICAL_100G_ER4; - - case 0x07: /* 100G PSM4 Parallel SMF */ - return TRANSVR_CLASS_OPTICAL_100G_PSM4; - - case 0x12: /* 40G PSM4 Parallel SMF */ - return TRANSVR_CLASS_OPTICAL_40G; - - case 0x11: /* 4 x 10GBASE-SR */ - return TRANSVR_CLASS_OPTICAL_40G_SR4; - - case 0x10: /* 40GBASE-ER4 */ - return TRANSVR_CLASS_OPTICAL_40G_ER4; - - case 0x08: /* 100G ACC (Active Copper Cable) or 25GAUI C2M ACC. */ - case 0x0b: /* 100GBASE-CR4 or 25GBASE-CR CA-L */ - case 0x19: /* 100G ACC or 25GAUI C2M ACC. */ - return TRANSVR_CLASS_COPPER_L4_100G; - - default: - break; - } - SWPS_INFO("%s: Unexcept value:0x%02x\n :%s", - __func__, detect_val, self->swp_name); - return TRANSVR_CLASS_ERROR; -} - - -int -_qsfp_detect_class_by_10_40_100_ethernet(struct transvr_obj_s* self) { - /* Reference: SFF-8472 (v12.2) - */ - int detect_val = DEBUG_TRANSVR_INT_VAL; - - detect_val = _qsfp_get_comp_10_40_100_ethernet(self); - /* Case: Unspecified */ - if (detect_val == 0x00) { - return TRANSVR_CLASS_UNSPECIFIED; - } - /* Case: 40G Optical */ - if ((detect_val & 0x01) == 0x01) { /* 00000001 : 40G Active Cable (XLPPI) */ - return TRANSVR_CLASS_OPTICAL_40G_AOC; - } - if ((detect_val & 0x04) == 0x04) { /* 00000100 : 40GBASE-SR4 */ - return TRANSVR_CLASS_OPTICAL_40G_SR4; - } - if ( (detect_val & 0x02) == 0x02) { /* 00000010 : 40GBASE-LR4 */ - return TRANSVR_CLASS_OPTICAL_40G_LR4; - } - if ( (detect_val & 0x08) == 0x08) { /* 00001000 : 40GBASE-CR4 */ - return TRANSVR_CLASS_COPPER_L4_40G; - } - /* Case: 10G Optical */ - if ( (detect_val & 0x10) == 0x10) { /* 00010000 : 10GBASE-SR */ - return TRANSVR_CLASS_OPTICAL_10G_Q_SR; - } - if ( ((detect_val & 0x20) == 0x20) || /* 00100000 : 10GBASE-LR */ - ((detect_val & 0x40) == 0x40) ){ /* 01000000 : 10GBASE-LRM */ - return TRANSVR_CLASS_OPTICAL_10G_Q_LR; - } - /* Case: Extend Compliance */ - if ( ((detect_val & 0x80) == 0x80) ){ /* 10000000 : Use Extend Compliance */ - return TRANSVR_CLASS_EXTEND_COMP; - } - /* Case: ERROR */ - SWPS_INFO("%s: Unexcept value:0x%02x\n :%s", - __func__, detect_val, self->swp_name); - return TRANSVR_CLASS_ERROR; -} - - -int -_qsfp_detect_if_sp_by_br(struct transvr_obj_s* self) { - - int lower_bound_10g = 0x10; - int upper_bound_10g = 0x25; - int lower_bound_40g = 0x60; - int upper_bound_40g = 0x75; - int lower_bound_100g = 0x60; - int upper_bound_100g = 0x75; - int used_extend_br = 0xff; - int notmal_br = DEBUG_TRANSVR_INT_VAL; - int extend_br = DEBUG_TRANSVR_INT_VAL; - - notmal_br = (int)(self->br); /* updated by update_all() */ - /* Check 40G */ - if ((notmal_br >= lower_bound_40g) && - (notmal_br <= upper_bound_40g) ) { - return TRANSVR_CLASS_40G; - } - /* Check 100G */ - if (notmal_br == used_extend_br) { - extend_br = (int)(self->extbr); /* updated by update_all() */ - if ((extend_br >= lower_bound_100g) && - (extend_br <= upper_bound_100g) ) { - return TRANSVR_CLASS_100G; - } - } - /* Check 10G */ - if ((notmal_br >= lower_bound_10g) && - (notmal_br <= upper_bound_10g) ) { - return TRANSVR_CLASS_10G; - } - return TRANSVR_CLASS_UNSPECIFIED; -} - - -int -_qsfp_detect_class_by_feature(struct transvr_obj_s* self) { - /* Reference: SFF-8024 (v3.8) - */ - int conn_val = DEBUG_TRANSVR_INT_VAL; - int wave_len = DEBUG_TRANSVR_INT_VAL; - int speed_val = DEBUG_TRANSVR_INT_VAL; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - - speed_val = _qsfp_detect_if_sp_by_br(self); - conn_val = _qsfp_get_connector_type(self); - - switch(conn_val) { - case 0x00: /* Unspecified */ - return TRANSVR_CLASS_UNSPECIFIED; - case 0x07: /* LC (Lucent Connector) */ - case 0x0b: /* Optical Pigtail */ - case 0x0c: /* MPO 1x12 (Multifiber Parallel Optic) */ - case 0x0d: /* MPO 2x16 */ - goto ok_qsfp_detect_class_by_feature_4_optiocal; - case 0x21: /* Copper pigtail */ - goto ok_qsfp_detect_class_by_feature_4_copper; - case 0x23: /* No separable connector */ - if ((_qsfp_get_comp_fc_link_length(self) > 0) || - (_qsfp_get_comp_fc_trans_tech(self) > 0) || - (_qsfp_get_comp_fc_trans_media(self) > 0) || - (_qsfp_get_comp_fc_speed(self) > 0) ) { - goto ok_qsfp_detect_class_by_feature_4_aoc; - } - goto ok_qsfp_detect_class_by_feature_4_copper; - default: - snprintf(err_msg, sizeof(err_msg), - "_qsfp_get_connector_type return Non define value:%d", - conn_val); - goto err_qsfp_detect_class_by_feature_1; - } - return TRANSVR_CLASS_UNSPECIFIED; - -ok_qsfp_detect_class_by_feature_4_optiocal: - wave_len = _common_count_wavelength(self, - self->wavelength[0], - self->wavelength[1]); - switch(speed_val) { - case TRANSVR_CLASS_100G: - switch (wave_len) { - case VAL_OPTICAL_WAVELENGTH_SR: - return TRANSVR_CLASS_OPTICAL_100G_SR4; - case VAL_OPTICAL_WAVELENGTH_LR: - return TRANSVR_CLASS_OPTICAL_100G_LR4; - case VAL_OPTICAL_WAVELENGTH_ER: - return TRANSVR_CLASS_OPTICAL_100G_ER4; - default: - break; - } - return TRANSVR_CLASS_OPTICAL_100G; - - case TRANSVR_CLASS_40G: - switch (wave_len) { - case VAL_OPTICAL_WAVELENGTH_SR: - return TRANSVR_CLASS_OPTICAL_40G_SR4; - case VAL_OPTICAL_WAVELENGTH_LR: - return TRANSVR_CLASS_OPTICAL_40G_LR4; - case VAL_OPTICAL_WAVELENGTH_ER: - return TRANSVR_CLASS_OPTICAL_40G_ER4; - default: - break; - } - return TRANSVR_CLASS_OPTICAL_40G; - - case TRANSVR_CLASS_10G: - switch (wave_len) { - case VAL_OPTICAL_WAVELENGTH_SR: - return TRANSVR_CLASS_OPTICAL_10G_Q_SR; - case VAL_OPTICAL_WAVELENGTH_LR: - return TRANSVR_CLASS_OPTICAL_10G_Q_LR; - case VAL_OPTICAL_WAVELENGTH_ER: - return TRANSVR_CLASS_OPTICAL_10G_Q_ER; - default: - break; - } - return TRANSVR_CLASS_OPTICAL_10G; - - default: - return TRANSVR_CLASS_OPTICAL; - } - -ok_qsfp_detect_class_by_feature_4_aoc: - switch(speed_val) { - case TRANSVR_CLASS_100G: - return TRANSVR_CLASS_OPTICAL_100G_AOC; - case TRANSVR_CLASS_40G: - return TRANSVR_CLASS_OPTICAL_40G_AOC; - case TRANSVR_CLASS_10G: - return TRANSVR_CLASS_OPTICAL_10G_Q_AOC; - default: - return TRANSVR_CLASS_OPTICAL; - } - -ok_qsfp_detect_class_by_feature_4_copper: - switch(speed_val) { - case TRANSVR_CLASS_100G: - return TRANSVR_CLASS_COPPER_L4_100G; - case TRANSVR_CLASS_40G: - return TRANSVR_CLASS_COPPER_L4_40G; - case TRANSVR_CLASS_10G: - return TRANSVR_CLASS_COPPER_L4_10G; - default: - return TRANSVR_CLASS_COPPER; - } - -err_qsfp_detect_class_by_feature_1: - SWPS_INFO("%s: %s\n :%s", - __func__, err_msg, self->swp_name); - return TRANSVR_CLASS_ERROR; -} - - -int -qsft_detect_transvr_class(struct transvr_obj_s* self) { - - int detect_val = DEBUG_TRANSVR_INT_VAL; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - - /* Check Extended Compliance */ - detect_val = _qsfp_detect_class_by_extend_comp(self); - switch (detect_val) { - case TRANSVR_CLASS_UNSPECIFIED: - break; - case TRANSVR_CLASS_OPTICAL_100G: - case TRANSVR_CLASS_OPTICAL_100G_AOC: - case TRANSVR_CLASS_OPTICAL_100G_SR4: - case TRANSVR_CLASS_OPTICAL_100G_LR4: - case TRANSVR_CLASS_OPTICAL_100G_ER4: - case TRANSVR_CLASS_OPTICAL_100G_PSM4: - case TRANSVR_CLASS_OPTICAL_40G: - case TRANSVR_CLASS_OPTICAL_40G_AOC: - case TRANSVR_CLASS_OPTICAL_40G_SR4: - case TRANSVR_CLASS_OPTICAL_40G_LR4: - case TRANSVR_CLASS_OPTICAL_40G_ER4: - case TRANSVR_CLASS_COPPER_L4_100G: - return detect_val; - default: - snprintf(err_msg, sizeof(err_msg), - "Detect undefined extend_comp:%d", - detect_val); - goto err_qsft_detect_transvr_class_1; - } - /* Check 10/40G/100G Ethernet Compliance */ - detect_val = _qsfp_detect_class_by_10_40_100_ethernet(self); - switch(detect_val) { - case TRANSVR_CLASS_UNSPECIFIED: - break; - case TRANSVR_CLASS_OPTICAL_40G_AOC: - case TRANSVR_CLASS_OPTICAL_40G_SR4: - case TRANSVR_CLASS_OPTICAL_40G_LR4: - case TRANSVR_CLASS_OPTICAL_10G_Q_SR: /* Need Check: SR4 or SR */ - case TRANSVR_CLASS_OPTICAL_10G_Q_LR: /* Need Check: SR4 or SR */ - case TRANSVR_CLASS_COPPER_L4_40G: - return detect_val; - case TRANSVR_CLASS_EXTEND_COMP: - /* Format incorrect case (We already checked the Extend - * Compliance is 0 - */ - snprintf(err_msg, sizeof(err_msg), - "Transceiver format incorrect"); - goto err_qsft_detect_transvr_class_1; - default: - snprintf(err_msg, sizeof(err_msg), - "Detect undefined 10/40/100:%d", - detect_val); - goto err_qsft_detect_transvr_class_1; - } - /* Check by Connector type, BR and wavelength */ - detect_val = _qsfp_detect_class_by_feature(self); - switch (detect_val) { - case TRANSVR_CLASS_UNSPECIFIED: - break; - case TRANSVR_CLASS_OPTICAL_100G_ER4: - case TRANSVR_CLASS_OPTICAL_100G_LR4: - case TRANSVR_CLASS_OPTICAL_100G_SR4: - case TRANSVR_CLASS_OPTICAL_100G_AOC: - case TRANSVR_CLASS_OPTICAL_100G: - case TRANSVR_CLASS_OPTICAL_40G_ER4: - case TRANSVR_CLASS_OPTICAL_40G_LR4: - case TRANSVR_CLASS_OPTICAL_40G_SR4: - case TRANSVR_CLASS_OPTICAL_40G_AOC: - case TRANSVR_CLASS_OPTICAL_40G: - case TRANSVR_CLASS_OPTICAL_10G_Q_ER: - case TRANSVR_CLASS_OPTICAL_10G_Q_LR: - case TRANSVR_CLASS_OPTICAL_10G_Q_SR: - case TRANSVR_CLASS_OPTICAL_10G_Q_AOC: - case TRANSVR_CLASS_OPTICAL_10G: - case TRANSVR_CLASS_OPTICAL: - case TRANSVR_CLASS_COPPER_L4_100G: - case TRANSVR_CLASS_COPPER_L4_40G: - case TRANSVR_CLASS_COPPER_L4_10G: - case TRANSVR_CLASS_COPPER: - return detect_val; - default: - snprintf(err_msg, sizeof(err_msg), - "Detect undefined connector:%d", - detect_val); - goto err_qsft_detect_transvr_class_1; - } - /* Exception case: Can't verify */ - snprintf(err_msg, sizeof(err_msg), - "Can not identify!"); - goto err_qsft_detect_transvr_class_1; - -err_qsft_detect_transvr_class_1: - SWPS_INFO("%s: %s\n :%s", __func__, err_msg, self->swp_name); - return TRANSVR_CLASS_ERROR; -} - - -int -_qsfp_set_trident2_if_type(struct transvr_obj_s* self, - int transvr_cls, - char *result){ - - int lmax = 8; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - - switch (transvr_cls) { - case TRANSVR_CLASS_UNSPECIFIED: - case TRANSVR_CLASS_ERROR: - break; - /* 100G Optical */ - case TRANSVR_CLASS_OPTICAL_100G: - case TRANSVR_CLASS_OPTICAL_100G_AOC: - case TRANSVR_CLASS_OPTICAL_100G_SR4: - case TRANSVR_CLASS_OPTICAL_100G_LR4: - case TRANSVR_CLASS_OPTICAL_100G_ER4: - case TRANSVR_CLASS_OPTICAL_100G_PSM4: - return snprintf(result, lmax, TRANSVR_IF_SR4); - /* 100G Copper */ - case TRANSVR_CLASS_COPPER_L4_100G: - return snprintf(result, lmax, TRANSVR_IF_KR4); - /* 40G Optical */ - case TRANSVR_CLASS_OPTICAL_40G: - case TRANSVR_CLASS_OPTICAL_40G_AOC: - case TRANSVR_CLASS_OPTICAL_40G_SR4: - case TRANSVR_CLASS_OPTICAL_40G_LR4: - case TRANSVR_CLASS_OPTICAL_40G_ER4: - return snprintf(result, lmax, TRANSVR_IF_IF_XGMII); - /* 40G Copper */ - case TRANSVR_CLASS_COPPER_L4_40G: - return snprintf(result, lmax, TRANSVR_IF_IF_XGMII); - /* 10G Optical */ - case TRANSVR_CLASS_OPTICAL_10G: - case TRANSVR_CLASS_OPTICAL_10G_Q_AOC: - case TRANSVR_CLASS_OPTICAL_10G_Q_SR: /* Need Check: SR4 or SR */ - case TRANSVR_CLASS_OPTICAL_10G_Q_LR: /* Need Check: LR4 or LR */ - case TRANSVR_CLASS_OPTICAL_10G_Q_ER: /* Need Check: ER4 or ER */ - return snprintf(result, lmax, TRANSVR_IF_IF_XGMII); - /* Optical */ - case TRANSVR_CLASS_OPTICAL: - return snprintf(result, lmax, TRANSVR_IF_IF_XGMII); - /* Copper */ - case TRANSVR_CLASS_COPPER: - return snprintf(result, lmax, TRANSVR_IF_IF_XGMII); - default: - snprintf(err_msg, sizeof(err_msg), - "Detect undefined value:%d", - transvr_cls); - goto err_qsfp_set_trident2_if_type_1; - } - /* Exception case: Can't verify */ - snprintf(err_msg, sizeof(err_msg), "Can not identify!"); - goto err_qsfp_set_trident2_if_type_1; - -err_qsfp_set_trident2_if_type_1: - snprintf(result, lmax, TRANSVR_UEVENT_UNKNOW); - SWPS_INFO("%s: %s\n :%s", __func__, err_msg, self->swp_name); - return ERR_TRANSVR_ABNORMAL; -} - - -int -_qsfp_set_tomahawk_if_type(struct transvr_obj_s* self, - int transvr_cls, - char *result){ - - int lmax = 8; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - - switch (transvr_cls) { - case TRANSVR_CLASS_UNSPECIFIED: - case TRANSVR_CLASS_ERROR: - break; - /* 100G Optical */ - case TRANSVR_CLASS_OPTICAL_100G: - case TRANSVR_CLASS_OPTICAL_100G_AOC: - case TRANSVR_CLASS_OPTICAL_100G_SR4: - case TRANSVR_CLASS_OPTICAL_100G_LR4: - case TRANSVR_CLASS_OPTICAL_100G_ER4: - case TRANSVR_CLASS_OPTICAL_100G_PSM4: - return snprintf(result, lmax, TRANSVR_IF_SR4); - /* 100G Copper */ - case TRANSVR_CLASS_COPPER_L4_100G: - return snprintf(result, lmax, TRANSVR_IF_KR4); - /* 40G Optical */ - case TRANSVR_CLASS_OPTICAL_40G: - case TRANSVR_CLASS_OPTICAL_40G_AOC: - case TRANSVR_CLASS_OPTICAL_40G_SR4: - case TRANSVR_CLASS_OPTICAL_40G_LR4: - case TRANSVR_CLASS_OPTICAL_40G_ER4: - return snprintf(result, lmax, TRANSVR_IF_SR4); - /* 40G Copper */ - case TRANSVR_CLASS_COPPER_L4_40G: - return snprintf(result, lmax, TRANSVR_IF_KR4); - /* 10G Optical */ - case TRANSVR_CLASS_OPTICAL_10G: - case TRANSVR_CLASS_OPTICAL_10G_Q_AOC: - case TRANSVR_CLASS_OPTICAL_10G_Q_SR: /* Need Check: SR4 or SR */ - case TRANSVR_CLASS_OPTICAL_10G_Q_LR: /* Need Check: SR4 or SR */ - case TRANSVR_CLASS_OPTICAL_10G_Q_ER: - return snprintf(result, lmax, TRANSVR_IF_SR4); - /* Optical */ - case TRANSVR_CLASS_OPTICAL: - return snprintf(result, lmax, TRANSVR_IF_SR4); - /* Copper */ - case TRANSVR_CLASS_COPPER: - return snprintf(result, lmax, TRANSVR_IF_KR4); - default: - snprintf(err_msg, sizeof(err_msg), - "Detect undefined value:%d", - transvr_cls); - goto err_qsfp_set_trident2_if_type_1; - } - /* Exception case: Can't verify */ - snprintf(err_msg, sizeof(err_msg), "Can not identify!"); - goto err_qsfp_set_trident2_if_type_1; - -err_qsfp_set_trident2_if_type_1: - snprintf(result, lmax, TRANSVR_UEVENT_UNKNOW); - SWPS_INFO("%s: %s\n :%s", __func__, err_msg, self->swp_name); - return ERR_TRANSVR_ABNORMAL; -} - - -int -_qsfp_set_bf_tofino_if_type(struct transvr_obj_s* self, - int transvr_cls, - char *result) { - /* (TBD) - * Due to BF looks like doesn't have interface type. - * We bypass it currently. - */ - int lmax = 8; - return snprintf(result, lmax, TRANSVR_UEVENT_UNKNOW); -} - - -int -_qsfp_detect_if_type(struct transvr_obj_s* self, - char *result){ - - int lmax = 8; - int detect_cls = DEBUG_TRANSVR_INT_VAL; - - detect_cls = qsft_detect_transvr_class(self); - switch (self->chipset_type) { - case BCM_CHIP_TYPE_TRIDENT_2: - return _qsfp_set_trident2_if_type(self, detect_cls, result); - - case BCM_CHIP_TYPE_TRIDENT_3: - case BCM_CHIP_TYPE_TOMAHAWK: - return _qsfp_set_tomahawk_if_type(self, detect_cls, result); - - case BF_CHIP_TYPE_TOFINO: - return _qsfp_set_bf_tofino_if_type(self, detect_cls, result); - - default: - SWPS_INFO("%s: non-defined chipset_type:%d :%s\n", - __func__, self->chipset_type, self->swp_name); - break; - } - snprintf(result, lmax, TRANSVR_UEVENT_UNKNOW); - return ERR_TRANSVR_ABNORMAL; -} - - -int -qsfp_get_if_type(struct transvr_obj_s *self, - char *buf_p){ - - int lmax = 8; - char tmp_result[8] = DEBUG_TRANSVR_STR_VAL; - - if (self->state != STATE_TRANSVR_CONNECTED) { - return snprintf(buf_p, lmax, "%d\n", self->state); - } - if (_qsfp_detect_if_type(self, tmp_result) < 0) { - return snprintf(buf_p, lmax, "%d\n", ERR_TRANSVR_ABNORMAL); - } - return snprintf(buf_p, lmax, "%s\n", tmp_result); -} - - -int -_qsfp_detect_if_speed(struct transvr_obj_s* self, - char *result){ - int lmax = 16; - int detect_val = DEBUG_TRANSVR_INT_VAL; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - - detect_val = qsft_detect_transvr_class(self); - switch (detect_val) { - case TRANSVR_CLASS_UNSPECIFIED: - case TRANSVR_CLASS_ERROR: - break; - /* 100G Optical */ - case TRANSVR_CLASS_OPTICAL_100G: - case TRANSVR_CLASS_OPTICAL_100G_AOC: - case TRANSVR_CLASS_OPTICAL_100G_SR4: - case TRANSVR_CLASS_OPTICAL_100G_LR4: - case TRANSVR_CLASS_OPTICAL_100G_ER4: - case TRANSVR_CLASS_OPTICAL_100G_PSM4: - return snprintf(result, lmax, TRANSVR_IF_SP_100G); - /* 100G Copper */ - case TRANSVR_CLASS_COPPER_L4_100G: - return snprintf(result, lmax, TRANSVR_IF_SP_100G); - /* 40G Optical */ - case TRANSVR_CLASS_OPTICAL_40G: - case TRANSVR_CLASS_OPTICAL_40G_AOC: - case TRANSVR_CLASS_OPTICAL_40G_SR4: - case TRANSVR_CLASS_OPTICAL_40G_LR4: - case TRANSVR_CLASS_OPTICAL_40G_ER4: - return snprintf(result, lmax, TRANSVR_IF_SP_40G); - /* 40G Copper */ - case TRANSVR_CLASS_COPPER_L4_40G: - return snprintf(result, lmax, TRANSVR_IF_SP_40G); - /* 10G Optical */ - case TRANSVR_CLASS_OPTICAL_10G: - case TRANSVR_CLASS_OPTICAL_10G_Q_AOC: - case TRANSVR_CLASS_OPTICAL_10G_Q_SR: /* Need Check: SR4 or SR */ - case TRANSVR_CLASS_OPTICAL_10G_Q_LR: /* Need Check: SR4 or SR */ - case TRANSVR_CLASS_OPTICAL_10G_Q_ER: - return snprintf(result, lmax, TRANSVR_IF_SP_10G); - /* 10G Copper */ - case TRANSVR_CLASS_COPPER_L4_10G: - return snprintf(result, lmax, TRANSVR_IF_SP_10G); - /* Optical */ - case TRANSVR_CLASS_OPTICAL: - break; - /* Copper */ - case TRANSVR_CLASS_COPPER: - break; - default: - snprintf(err_msg, sizeof(err_msg), - "Detect undefined class case:%d", - detect_val); - goto err_qsfp_detect_if_speed_1; - } - /* Check br and extbr */ - detect_val = _qsfp_detect_if_sp_by_br(self); - switch(detect_val) { - case TRANSVR_CLASS_UNSPECIFIED: - break; - case TRANSVR_CLASS_10G: - return snprintf(result, lmax, TRANSVR_IF_SP_10G); - case TRANSVR_CLASS_40G: - return snprintf(result, lmax, TRANSVR_IF_SP_40G); - case TRANSVR_CLASS_100G: - return snprintf(result, lmax, TRANSVR_IF_SP_100G); - default: - snprintf(err_msg, sizeof(err_msg), - "Detect undefined BR case:%d", - detect_val); - goto err_qsfp_detect_if_speed_1; - } - /* Exception case: Can't verify */ - snprintf(err_msg, sizeof(err_msg), "Can not identify!"); - goto err_qsfp_detect_if_speed_1; - -err_qsfp_detect_if_speed_1: - snprintf(result, lmax, TRANSVR_UEVENT_UNKNOW); - SWPS_INFO("%s: %s :%s\n", __func__, err_msg, self->swp_name); - return ERR_TRANSVR_ABNORMAL; -} - - -int -qsfp_get_if_speed(struct transvr_obj_s *self, - char *buf_p){ - - int lmax = 16; - char tmp_result[16] = DEBUG_TRANSVR_STR_VAL; - - if (self->state != STATE_TRANSVR_CONNECTED) { - return snprintf(buf_p, lmax, "%d\n", self->state); - } - if (_qsfp_detect_if_speed(self, tmp_result) < 0) { - return snprintf(buf_p, lmax, "%d\n", ERR_TRANSVR_ABNORMAL); - } - return snprintf(buf_p, lmax, "%s\n", tmp_result); -} - - -int -_common_set_lane_map_str(struct transvr_obj_s* self, - char *result) { - int i = 0; - int tmp_val = 0; - char tmp_str[LEN_TRANSVR_L_STR] = DEBUG_TRANSVR_STR_VAL; - char err_msg[LEN_TRANSVR_L_STR] = DEBUG_TRANSVR_STR_VAL; - - memset(result, 0, LEN_TRANSVR_L_STR); - snprintf(result, LEN_TRANSVR_L_STR, "%s=", TRANSVR_UEVENT_KEY_LANE); - - for (i=0; ilane_id); i++) { - tmp_val = self->lane_id[i]; - if (tmp_val < 1) { - break; - } - if (tmp_val > 256) { - snprintf(err_msg, sizeof(err_msg), - "detect abnormal value:%d", tmp_val); - goto err_common_set_lane_map_str_1; - } - memset(tmp_str, 0, sizeof(tmp_str)); - if (i == 0) { - snprintf(tmp_str, LEN_TRANSVR_L_STR, "%d", tmp_val); - } else { - snprintf(tmp_str, LEN_TRANSVR_L_STR, ",%d", tmp_val); - } - strncat(result, tmp_str, LEN_TRANSVR_L_STR); - } - if (i == 0) { - goto err_common_set_lane_map_str_2; - } - return 0; - -err_common_set_lane_map_str_1: - SWPS_INFO("%s: %s", __func__, err_msg); -err_common_set_lane_map_str_2: - snprintf(result, LEN_TRANSVR_L_STR, "%s=%s", TRANSVR_UEVENT_KEY_LANE, TRANSVR_UEVENT_UNKNOW); - return EVENT_TRANSVR_TASK_FAIL; -} - - -int -_common_send_uevent(struct transvr_obj_s* self, - enum kobject_action u_action, - int (*detect_if_type)(struct transvr_obj_s *self, char *result), - int (*detect_if_speed)(struct transvr_obj_s *self, char *result), - int send_anyway) { - - char *uevent_envp[4]; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - char tmp_str[32] = DEBUG_TRANSVR_STR_VAL; - char tmp_str_1[32] = DEBUG_TRANSVR_STR_VAL; - char tmp_str_2[32] = DEBUG_TRANSVR_STR_VAL; - char tmp_str_3[64] = DEBUG_TRANSVR_STR_VAL; - - if (TRANSVR_UEVENT_ENABLE != 1) { - return ERR_TRANSVR_NOTSUPPORT; - } - if (_common_get_if_lane(self, tmp_str) < 0) { - snprintf(tmp_str_3, sizeof(tmp_str_3), - "%s=%s", TRANSVR_UEVENT_KEY_LANE, TRANSVR_UEVENT_UNKNOW); - } else { - snprintf(tmp_str_3, sizeof(tmp_str_3), - "%s=%s", TRANSVR_UEVENT_KEY_LANE, tmp_str); - } - switch (u_action) { - case KOBJ_ADD: - /* Detect type */ - if (detect_if_type(self, tmp_str) < 0) { - snprintf(err_msg, sizeof(err_msg), "%s", "Detect interface type fail!"); - snprintf(tmp_str_1, sizeof(tmp_str_1), "%s=%s", TRANSVR_UEVENT_KEY_IF, TRANSVR_UEVENT_UNKNOW); - snprintf(tmp_str_2, sizeof(tmp_str_2), "%s=%s", TRANSVR_UEVENT_KEY_SP, TRANSVR_UEVENT_UNKNOW); - uevent_envp[0] = tmp_str_1; - uevent_envp[1] = tmp_str_2; - uevent_envp[2] = tmp_str_3; - uevent_envp[3] = NULL; - goto private_common_send_uevent_4_fail; - } - snprintf(tmp_str_1, sizeof(tmp_str_1), "%s=%s", TRANSVR_UEVENT_KEY_IF, tmp_str); - uevent_envp[0] = tmp_str_1; - /* Detect speed */ - if (detect_if_speed(self, tmp_str) < 0) { - snprintf(err_msg, sizeof(err_msg), "%s", "Detect interface speed fail!"); - snprintf(tmp_str_2, sizeof(tmp_str_2), "%s=%s", TRANSVR_UEVENT_KEY_SP, TRANSVR_UEVENT_UNKNOW); - uevent_envp[1] = tmp_str_2; - uevent_envp[2] = tmp_str_3; - uevent_envp[3] = NULL; - goto private_common_send_uevent_4_fail; - } - snprintf(tmp_str_2, sizeof(tmp_str_2), "%s=%s", TRANSVR_UEVENT_KEY_SP, tmp_str); - uevent_envp[1] = tmp_str_2; - uevent_envp[2] = tmp_str_3; - uevent_envp[3] = NULL; - goto private_common_send_uevent_4_send; - - case KOBJ_REMOVE: - snprintf(tmp_str_1, sizeof(tmp_str_1), "%s=%s", TRANSVR_UEVENT_KEY_IF, TRANSVR_UEVENT_UNKNOW); - snprintf(tmp_str_2, sizeof(tmp_str_2), "%s=%s", TRANSVR_UEVENT_KEY_SP, TRANSVR_UEVENT_UNKNOW); - uevent_envp[0] = tmp_str_1; - uevent_envp[1] = tmp_str_2; - uevent_envp[2] = tmp_str_3; - uevent_envp[3] = NULL; - goto private_common_send_uevent_4_send; - - default: - snprintf(err_msg, sizeof(err_msg), "kobject_action:%d not support", u_action); - goto private_common_send_uevent_4_fail; - } - snprintf(err_msg, sizeof(err_msg), "%s", "Exception case"); - goto private_common_send_uevent_4_fail; - -private_common_send_uevent_4_fail: - SWPS_INFO("%s: %s :%s\n", __func__, err_msg, self->swp_name); - if (send_anyway) { - goto private_common_send_uevent_4_send; - } - return ERR_TRANSVR_UEVENT_FAIL; - -private_common_send_uevent_4_send: - return kobject_uevent_env(&(self->transvr_dev_p->kobj), - u_action, - uevent_envp); -} - -int -sfp_send_uevent(struct transvr_obj_s* self, - enum kobject_action u_action) { - int send_anyway = 1; - return _common_send_uevent(self, - u_action, - &_sfp_detect_if_type, - &_sfp_detect_if_speed, - send_anyway); -} - - -int -qsfp_send_uevent(struct transvr_obj_s* self, - enum kobject_action u_action) { - int send_anyway = 1; - return _common_send_uevent(self, - u_action, - &_qsfp_detect_if_type, - &_qsfp_detect_if_speed, - send_anyway); -} - - -int -fake_send_uevent(struct transvr_obj_s* self, - enum kobject_action u_action) { - return EVENT_TRANSVR_TASK_DONE; -} - - -int -common_fsm_4_direct_mode(struct transvr_obj_s* self, - char *caller_name){ - - int err; - int detect_result[2]; - int current_state = STATE_TRANSVR_UNEXCEPTED; - int current_type = TRANSVR_TYPE_ERROR; - - if (self->state == STATE_TRANSVR_NEW) { - if (_transvr_init_handler(self) < 0){ - return ERR_TRANSVR_INIT_FAIL; - } - } - err = detect_transvr_state(self, detect_result); - if (err < 0) { - return err; - } - /* In Direct mode, driver only detect transceiver when user call driver interface - * which on sysfs. So it only need consider the state of Transceiver. - */ - current_state = detect_result[0]; - current_type = detect_result[1]; - - switch (current_state){ - - case STATE_TRANSVR_DISCONNECTED: /* Transceiver is not plugged */ - self->state = current_state; - self->type = current_type; - return ERR_TRANSVR_UNPLUGGED; - - case STATE_TRANSVR_INIT: /* Transceiver is plugged, system not ready */ - return ERR_TRANSVR_UNINIT; - - case STATE_TRANSVR_ISOLATED: /* Transceiver is plugged, but has some issues */ - return ERR_TRNASVR_BE_ISOLATED; - - case STATE_TRANSVR_CONNECTED: /* Transceiver is plugged, system is ready */ - self->state = current_state; - self->type = current_type; - return 0; - - case STATE_TRANSVR_SWAPPED: /* Transceiver is plugged, system detect user changed */ - self->type = current_type; - if (reload_transvr_obj(self, current_type) < 0){ - self->state = STATE_TRANSVR_UNEXCEPTED; - return ERR_TRANSVR_UNEXCPT; - } - self->state = current_state; - return 0; - - case STATE_TRANSVR_UNEXCEPTED: /* Transceiver type or state is unexpected case */ - self->state = STATE_TRANSVR_UNEXCEPTED; - self->type = TRANSVR_TYPE_ERROR; - return ERR_TRANSVR_UNEXCPT; - - default: - SWPS_INFO("%s: state:%d not in define.\n", __func__, current_state); - break; - } - return ERR_TRANSVR_UNEXCPT; -} - - -static int -_is_except_happened_4_pmode(struct transvr_obj_s* self, - int new_state) { - - int event_chk = 0; - - if (self->temp == 0){ - return 0; - } - switch (new_state) { - case STATE_TRANSVR_INIT: - event_chk = EVENT_TRANSVR_EXCEP_INIT; - goto check_event_happened_4_pmode; - - case STATE_TRANSVR_CONNECTED: - event_chk = EVENT_TRANSVR_EXCEP_UP; - goto check_event_happened_4_pmode; - - case STATE_TRANSVR_DISCONNECTED: - event_chk = EVENT_TRANSVR_EXCEP_DOWN; - goto check_event_happened_4_pmode; - - case STATE_TRANSVR_SWAPPED: - event_chk = EVENT_TRANSVR_EXCEP_SWAP; - goto check_event_happened_4_pmode; - - case STATE_TRANSVR_UNEXCEPTED: - event_chk = EVENT_TRANSVR_EXCEP_EXCEP; - goto check_event_happened_4_pmode; - - case STATE_TRANSVR_ISOLATED: - event_chk = EVENT_TRANSVR_EXCEP_ISOLATED; - goto check_event_happened_4_pmode; - - default: - SWPS_INFO("%s: unexcepted case:%d\n", __func__, new_state); - break; - } - return 0; - -check_event_happened_4_pmode: - if (self->temp == event_chk){ - return 1; - } - return 0; -} - - -int -common_fsm_4_polling_mode(struct transvr_obj_s* self, - char *caller_name){ - /* [Return Value]: - * ERR_TRANSVR_UNINIT : (1) Initial not ready - * ERR_TRANSVR_UNPLUGGED : (1) Any -> Down - * ERR_TRANSVR_TASK_BUSY : (1) Wait Initial task - * ERR_TRANSVR_UNEXCPT : (1) Initial fail - * (2) Task fail - * (3) Reload fail - * ERR_TRNASVR_BE_ISOLATED : (1) Already be isolated - * OK Case (return 0) : (1) action_4_connected - * (2) action_4_nothing (initial retry) - */ - int curr_state[2]; - int old_state = self->state; - int old_type = self->type; - int new_state = STATE_TRANSVR_UNEXCEPTED; - int new_type = TRANSVR_TYPE_ERROR; - int return_val = ERR_TRANSVR_UNEXCPT; - - /* Never initial */ - if (self->state == STATE_TRANSVR_NEW) { - goto comfsm_action_4_reinit_obj; - } - /* Detect current state */ - switch (detect_transvr_state(self, curr_state)) { - case 0: - new_state = curr_state[0]; - new_type = curr_state[1]; - break; - - case ERR_TRNASVR_BE_ISOLATED: - new_state = STATE_TRANSVR_ISOLATED; - new_type = old_type; - break; - - case ERR_TRANSVR_I2C_CRASH: - goto comfsm_action_4_report_i2c_crash; - - case ERR_TRANSVR_UNEXCPT: - default: - new_state = STATE_TRANSVR_UNEXCEPTED; - new_type = old_type; - } - /* State handling */ - switch (old_state) { - case STATE_TRANSVR_INIT: /* INIT -> */ - return_val = ERR_TRANSVR_UNINIT; - goto comfsm_action_4_keep_state; - - case STATE_TRANSVR_CONNECTED: - switch (new_state) { - case STATE_TRANSVR_INIT: /* Case 1-1: UP -> INIT */ - SWPS_INFO("Detect %s is present. :1-1\n",self->swp_name); - return_val = ERR_TRANSVR_UNINIT; - goto comfsm_action_4_keep_state; - - case STATE_TRANSVR_CONNECTED: /* Case 1-2: UP -> UP */ - return_val = 0; - goto comfsm_action_4_keep_state; - - case STATE_TRANSVR_DISCONNECTED: /* Case 1-3: UP -> DOWN */ - SWPS_INFO("Detect %s is removed. :1-3\n",self->swp_name); - goto comfsm_action_4_disconnected; - - case STATE_TRANSVR_SWAPPED: /* Case 1-4: UP -> SWAP */ - SWPS_INFO("Detect %s is swapped. :1-4\n",self->swp_name); - goto comfsm_action_4_reload_obj; - - case STATE_TRANSVR_UNEXCEPTED: /* Case 1-5: UP -> UNEXPET */ - SWPS_INFO("Detect %s has error. :1-5\n",self->swp_name); - goto comfsm_action_4_unexpected; - - case STATE_TRANSVR_ISOLATED: /* Case 1-6: UP -> ISOLATE */ - SWPS_INFO("Detect %s be isolated. :1-6\n",self->swp_name); - goto comfsm_action_4_isolate_obj; - - default: - break; - } - goto comfsm_action_4_unexpected; - - case STATE_TRANSVR_DISCONNECTED: - switch (new_state) { - case STATE_TRANSVR_INIT: /* Case 2-1: DOWN -> INIT */ - SWPS_INFO("Detect %s is present. :2-1\n",self->swp_name); - return_val = ERR_TRANSVR_UNINIT; - goto comfsm_action_4_keep_state; - - case STATE_TRANSVR_CONNECTED: /* Case 2-2: DOWN -> UP */ - SWPS_INFO("Detect %s is present. :2-2\n",self->swp_name); - goto comfsm_action_4_reinit_obj; - - case STATE_TRANSVR_DISCONNECTED: /* Case 2-3: DOWN -> DOWN */ - return_val = ERR_TRANSVR_UNPLUGGED; - goto comfsm_action_4_keep_state; - - case STATE_TRANSVR_SWAPPED: /* Case 2-4: DOWN -> SWAP */ - SWPS_INFO("Detect %s is swapped. :2-4\n",self->swp_name); - goto comfsm_action_4_reload_obj; - - case STATE_TRANSVR_UNEXCEPTED: /* Case 2-5: DOWN -> UNEXPET */ - SWPS_INFO("Detect %s has error. :2-5\n",self->swp_name); - goto comfsm_action_4_unexpected; - - case STATE_TRANSVR_ISOLATED: /* Case 2-6: DOWN -> ISOLATE */ - SWPS_INFO("Detect %s be isolated. :2-6\n",self->swp_name); - goto comfsm_action_4_isolate_obj; - - default: - break; - } - goto comfsm_action_4_unexpected; - - case STATE_TRANSVR_UNEXCEPTED: - /* Filter out re-action */ - if (_is_except_happened_4_pmode(self, new_state)) { - goto comfsm_action_4_keep_state; - } - /* First action */ - switch (new_state) { - case STATE_TRANSVR_INIT: /* Case 3-1: UNEXPET -> INIT */ - SWPS_INFO("Detect %s is present. :3-1\n",self->swp_name); - self->temp = EVENT_TRANSVR_EXCEP_INIT; - return_val = ERR_TRANSVR_UNINIT; - goto comfsm_action_4_keep_state; - - case STATE_TRANSVR_CONNECTED: /* Case 3-2: UNEXPET -> UP */ - SWPS_INFO("Detect %s is present. :3-2\n",self->swp_name); - self->temp = EVENT_TRANSVR_EXCEP_UP; - goto comfsm_action_4_reload_obj; - - case STATE_TRANSVR_DISCONNECTED: /* Case 3-3: UNEXPET -> DOWN */ - SWPS_INFO("Detect %s is removed. :3-3\n",self->swp_name); - goto comfsm_action_4_disconnected; - - case STATE_TRANSVR_SWAPPED: /* Case 3-4: UNEXPET -> SWAP */ - SWPS_INFO("Detect %s is swapped. :3-4\n",self->swp_name); - self->temp = EVENT_TRANSVR_EXCEP_SWAP; - goto comfsm_action_4_reload_obj; - - case STATE_TRANSVR_UNEXCEPTED: /* Case 3-5: UNEXPET -> UNEXPET */ - self->temp = EVENT_TRANSVR_EXCEP_EXCEP; - return_val = ERR_TRANSVR_UNEXCPT; - goto comfsm_action_4_keep_state; - - case STATE_TRANSVR_ISOLATED: /* Case 3-6: UNEXPET -> ISOLATE */ - SWPS_INFO("Detect %s be isolated. :3-6\n",self->swp_name); - goto comfsm_action_4_isolate_obj; - - default: - break; - } - goto comfsm_action_4_unexpected; - - case STATE_TRANSVR_ISOLATED: - /* Filter out re-action */ - if (_is_except_happened_4_pmode(self, new_state)) { - goto comfsm_action_4_keep_state; - } - /* First action */ - switch (new_state) { - case STATE_TRANSVR_INIT: /* Case 4-1: ISOLATE -> INIT */ - SWPS_INFO("Detect %s internal error. :4-1\n",self->swp_name); - self->temp = EVENT_TRANSVR_EXCEP_INIT; - return_val = ERR_TRNASVR_BE_ISOLATED; - goto comfsm_action_4_keep_state; - - case STATE_TRANSVR_CONNECTED: /* Case 4-2: ISOLATE -> UP */ - SWPS_INFO("Detect %s internal error. :4-2\n",self->swp_name); - self->temp = EVENT_TRANSVR_EXCEP_UP; - return_val = ERR_TRNASVR_BE_ISOLATED; - goto comfsm_action_4_keep_state; - - case STATE_TRANSVR_DISCONNECTED: /* Case 4-3: ISOLATE -> DOWN */ - SWPS_INFO("Detect %s is removed. :4-3\n",self->swp_name); - goto comfsm_action_4_disconnected; - - case STATE_TRANSVR_SWAPPED: /* Case 4-4: ISOLATE -> SWAP */ - SWPS_INFO("Detect %s internal error. :4-4\n",self->swp_name); - self->temp = EVENT_TRANSVR_EXCEP_SWAP; - return_val = ERR_TRNASVR_BE_ISOLATED; - goto comfsm_action_4_keep_state; - - case STATE_TRANSVR_UNEXCEPTED: /* Case 4-5: ISOLATE -> UNEXPET */ - SWPS_INFO("Detect %s internal error. :4-5\n",self->swp_name); - self->temp = EVENT_TRANSVR_EXCEP_EXCEP; - return_val = ERR_TRNASVR_BE_ISOLATED; - goto comfsm_action_4_keep_state; - - case STATE_TRANSVR_ISOLATED: /* Case 4-6: ISOLATE -> ISOLATE */ - return_val = ERR_TRNASVR_BE_ISOLATED; - goto comfsm_action_4_keep_state; - - default: - break; - } - goto comfsm_action_4_unexpected; - - default: - break; - } - goto comfsm_action_4_unexpected; - - -comfsm_action_4_keep_state: - return return_val; - -comfsm_action_4_reinit_obj: - SWPS_DEBUG("FSM action: %s re-initial.\n", self->swp_name); - return_val = _transvr_init_handler(self); - goto comfsm_action_4_identify_event; - -comfsm_action_4_reload_obj: - SWPS_DEBUG("FSM action: %s reload.\n", self->swp_name); - self->type = new_type; - return_val = reload_transvr_obj(self, new_type); - goto comfsm_action_4_identify_event; - -comfsm_action_4_identify_event: - switch (return_val) { - case EVENT_TRANSVR_INIT_UP: - case EVENT_TRANSVR_TASK_DONE: - goto comfsm_action_4_connected; - - case EVENT_TRANSVR_INIT_DOWN: - goto comfsm_action_4_disconnected; - - case EVENT_TRANSVR_INIT_REINIT: - goto comfsm_action_4_nothing; - - case EVENT_TRANSVR_TASK_WAIT: - self->state = STATE_TRANSVR_INIT; - return ERR_TRANSVR_TASK_BUSY; - - case EVENT_TRANSVR_TASK_FAIL: - SWPS_INFO("%s detect EVENT_TRANSVR_TASK_FAIL.\n", self->swp_name); - goto comfsm_action_4_unexpected; - - case EVENT_TRANSVR_INIT_FAIL: - SWPS_INFO("%s detect EVENT_TRANSVR_INIT_FAIL.\n", self->swp_name); - goto comfsm_action_4_unexpected; - - case EVENT_TRANSVR_RELOAD_FAIL: - SWPS_INFO("%s detect EVENT_TRANSVR_RELOAD_FAIL.\n", self->swp_name); - goto comfsm_action_4_unexpected; - - case EVENT_TRANSVR_I2C_CRASH: - goto comfsm_action_4_report_i2c_crash; - - case EVENT_TRANSVR_EXCEP_ISOLATED: - goto comfsm_action_4_isolate_obj; - - default: - SWPS_INFO("%s detect undefined event:%d.\n", self->swp_name, return_val); - goto comfsm_action_4_unexpected; - } - -comfsm_action_4_nothing: - SWPS_DEBUG("FSM action: %s do nothing.\n", self->swp_name); - return 0; - -comfsm_action_4_connected: - SWPS_DEBUG("FSM action: %s Connected.\n", self->swp_name); - self->state = STATE_TRANSVR_CONNECTED; - self->type = new_type; - self->send_uevent(self, KOBJ_ADD); - _transvr_clean_retry(self); - return 0; - -comfsm_action_4_disconnected: - SWPS_DEBUG("FSM action: %s Disconnected. \n", self->swp_name); - self->state = STATE_TRANSVR_DISCONNECTED; - self->temp = EVENT_TRANSVR_TASK_DONE; - self->send_uevent(self, KOBJ_REMOVE); - _transvr_clean_retry(self); - _transvr_clean_handler(self); - return ERR_TRANSVR_UNPLUGGED; - -comfsm_action_4_report_i2c_crash: - SWPS_DEBUG("FSM action: %s report I2C crash.\n", self->swp_name); - self->state = STATE_TRANSVR_UNEXCEPTED; - return ERR_TRANSVR_I2C_CRASH; - -comfsm_action_4_isolate_obj: - SWPS_DEBUG("FSM action: %s isolate.\n", self->swp_name); - self->state = STATE_TRANSVR_ISOLATED; - return ERR_TRNASVR_BE_ISOLATED; - -comfsm_action_4_unexpected: - SWPS_INFO("FSM action: %s unexpected.\n", self->swp_name); - SWPS_INFO("Dump: :%d :0x%02x :%d :0x%02x\n", - old_state, old_type, new_state, new_type); - self->state = STATE_TRANSVR_UNEXCEPTED; - self->send_uevent(self, KOBJ_REMOVE); - _transvr_clean_handler(self); - return ERR_TRANSVR_UNEXCPT; -} - - -int -fake_fsm_4_direct_mode(struct transvr_obj_s* self, - char *caller_name){ - self->state = STATE_TRANSVR_CONNECTED; - self->type = TRANSVR_TYPE_FAKE; - return 0; -} - - -int -fake_fsm_4_polling_mode(struct transvr_obj_s* self, - char *caller_name){ - self->state = STATE_TRANSVR_CONNECTED; - self->type = TRANSVR_TYPE_FAKE; - return 0; -} - - -/* ========== Object functions for Initial procedure ========== - */ -int -transvr_init_common(struct transvr_obj_s *self){ - /* Nothing to update */ - return EVENT_TRANSVR_TASK_DONE; -} - - -int -transvr_init_fake(struct transvr_obj_s *self){ - return EVENT_TRANSVR_TASK_DONE; -} - - -int -transvr_init_sfp(struct transvr_obj_s *self){ - - int tmp_val = DEBUG_TRANSVR_INT_VAL; - int err_code = DEBUG_TRANSVR_INT_VAL; - char *err_msg = "ERR"; - - self->info = sft_detect_transvr_class(self); - /* Disable auto_config */ - if (!self->auto_config) { - return EVENT_TRANSVR_TASK_DONE; - } - /* Handle multi-rate */ - err_code = initfunc_sfp_handle_multi_rate_mode(self); - if (err_code < 0) { - err_msg = "initfunc_sfp_handle_multi_rate_mode fail!"; - goto err_transvr_init_sfp_1; - } - /* Handle 1G- RJ45 */ - tmp_val = err_code; - err_code = initfunc_sfp_handle_1g_rj45(self); - if (err_code < 0) { - err_msg = "initfunc_sfp_handle_1g_rj45 fail!"; - goto err_transvr_init_sfp_1; - } - tmp_val = (tmp_val > err_code ? tmp_val : err_code); - if (tmp_val > EVENT_TRANSVR_TASK_DONE) { - return tmp_val; - } - return EVENT_TRANSVR_TASK_DONE; - -err_transvr_init_sfp_1: - SWPS_INFO("%s: %s :%d :%s\n", - __func__, err_msg, err_code, self->swp_name); - return EVENT_TRANSVR_INIT_FAIL; -} - - -int -transvr_init_qsfp(struct transvr_obj_s *self){ - - int err = EVENT_TRANSVR_EXCEP_EXCEP; - char *emsg = "ERR"; - - self->info = qsft_detect_transvr_class(self); - if (!self->auto_config) { - return EVENT_TRANSVR_TASK_DONE; - } - err = initfunc_qsfp_handle_power_mode(self); - if (err < 0){ - emsg = "initfunc_qsfp_handle_tx_disable fail!"; - goto err_transvr_init_qsfp; - } - return EVENT_TRANSVR_TASK_DONE; - -err_transvr_init_qsfp: - SWPS_INFO("%s: %s :%d :%s\n", - __func__, emsg, err, self->swp_name); - return EVENT_TRANSVR_INIT_FAIL; -} - - -int -transvr_init_qsfp28(struct transvr_obj_s *self){ - - int tmp_val = EVENT_TRANSVR_EXCEP_EXCEP; - int err_val = EVENT_TRANSVR_EXCEP_EXCEP; - char *err_msg = "ERR"; - - /* Handle QSFP common */ - err_val = transvr_init_qsfp(self); - if (err_val < 0){ - err_msg = "transvr_init_qsfp fail!"; - goto err_transvr_init_qsfp28_1; - } - /* Disable auto_config */ - if (!self->auto_config) { - return err_val; - } - /* Handle CDR */ - tmp_val = err_val; - err_val = initfunc_qsfp28_handle_cdr(self); - if (err_val < 0){ - err_msg = "Handle CDR fail!"; - goto err_transvr_init_qsfp28_1; - } - tmp_val = (tmp_val > err_val ? tmp_val : err_val); - if (tmp_val > EVENT_TRANSVR_TASK_DONE) { - return tmp_val; - } - return EVENT_TRANSVR_TASK_DONE; - -err_transvr_init_qsfp28_1: - SWPS_INFO("%s: %s :%d :%s\n", - __func__, err_msg, err_val, self->swp_name); - return EVENT_TRANSVR_INIT_FAIL; -} - - -/* ========== Object Initial handler ========== - */ -static int -_is_transvr_valid(struct transvr_obj_s *self, - int type, - int state) { - /* [Return] - * 0 : OK, inserted - * EVENT_TRANSVR_INIT_DOWN : OK, removed - * EVENT_TRANSVR_INIT_FAIL : Outside error, type doesn't supported - * EVENT_TRANSVR_EXCEP_INIT : Internal error, state undefined - */ - switch (type) { - case TRANSVR_TYPE_SFP: - case TRANSVR_TYPE_QSFP: - case TRANSVR_TYPE_QSFP_PLUS: - case TRANSVR_TYPE_QSFP_28: - case TRANSVR_TYPE_UNPLUGGED: - case TRANSVR_TYPE_FAKE: - break; - default: - SWPS_INFO("detect undefined type:0x%02x on %s\n", - type, self->swp_name); - return EVENT_TRANSVR_INIT_FAIL; - } - switch (state) { - case STATE_TRANSVR_DISCONNECTED: - return EVENT_TRANSVR_INIT_DOWN; - case STATE_TRANSVR_INIT: - case STATE_TRANSVR_CONNECTED: - case STATE_TRANSVR_SWAPPED: - break; - default: - SWPS_INFO("detect undefined state:%d on %s\n", - state, self->swp_name); - return EVENT_TRANSVR_EXCEP_INIT; - } - return 0; -} - - -static int -_is_transvr_hw_ready(struct transvr_obj_s *self, - int type){ - /* [Return] - * EVENT_TRANSVR_TASK_DONE : Ready - * EVENT_TRANSVR_TASK_WAIT : Not ready - * EVENT_TRANSVR_INIT_FAIL : Error - */ - int addr = DEBUG_TRANSVR_INT_VAL; - int page = DEBUG_TRANSVR_INT_VAL; - int offs = DEBUG_TRANSVR_INT_VAL; - int bit = DEBUG_TRANSVR_INT_VAL; - int ready = DEBUG_TRANSVR_INT_VAL; - int err = DEBUG_TRANSVR_INT_VAL; - char *emsg = DEBUG_TRANSVR_STR_VAL; - uint8_t ab_val = DEBUG_TRANSVR_HEX_VAL; - - switch (type) { - case TRANSVR_TYPE_SFP: - addr = VAL_TRANSVR_8472_READY_ADDR; - page = VAL_TRANSVR_8472_READY_PAGE; - offs = VAL_TRANSVR_8472_READY_OFFSET; - bit = VAL_TRANSVR_8472_READY_BIT; - ready = VAL_TRANSVR_8472_READY_VALUE; - ab_val = VAL_TRANSVR_8472_READY_ABNORMAL; - break; - - case TRANSVR_TYPE_QSFP: - case TRANSVR_TYPE_QSFP_PLUS: - case TRANSVR_TYPE_QSFP_28: - addr = VAL_TRANSVR_8436_READY_ADDR; - page = VAL_TRANSVR_8436_READY_PAGE; - offs = VAL_TRANSVR_8436_READY_OFFSET; - bit = VAL_TRANSVR_8436_READY_BIT; - ready = VAL_TRANSVR_8436_READY_VALUE; - ab_val = VAL_TRANSVR_8436_READY_ABNORMAL; - break; - - case TRANSVR_TYPE_UNPLUGGED: - case TRANSVR_TYPE_FAKE: - return EVENT_TRANSVR_TASK_DONE; - - default: - emsg = "unexpected case"; - goto err_is_transvr_hw_ready; - } - /* Select target page */ - err = _common_setup_page(self, addr, page, offs, 1, 0); - if (err < 0) { - emsg = "setup page fail"; - goto err_is_transvr_hw_ready; - } - /* Check feature supported - * [Note] - * Some of transceiver/cables doesn't support "Status Indicators" - * (ex:DAC, RJ45 copper SFP ...etc). In these case, we bypass the - * step of checking Status Indicators, then state machine will take - * the following handle procedure. - */ - err = i2c_smbus_read_byte_data(self->i2c_client_p, - VAL_TRANSVR_COMID_OFFSET); - if (err < 0) { - emsg = "doesn't support Status Indicators"; - goto bypass_is_transvr_hw_ready; - } - /* Filter abnormal case */ - if (err == ab_val) { - emsg = "detect using unusual definition."; - goto bypass_is_transvr_hw_ready; - } - /* Get Status Indicators */ - err = i2c_smbus_read_byte_data(self->i2c_client_p, offs); - if (err < 0) { - emsg = "detect current value fail"; - goto err_is_transvr_hw_ready; - } - if ((err & (1<:%d\n", __func__, emsg, type); - return EVENT_TRANSVR_TASK_DONE; - -err_is_transvr_hw_ready: - SWPS_DEBUG("%s: %s :%d\n", __func__, emsg, type); - return EVENT_TRANSVR_INIT_FAIL; -} - - -static int -_is_transvr_support_ctle(struct transvr_obj_s *self) { - - switch (self->info) { - case TRANSVR_CLASS_OPTICAL_25G: - case TRANSVR_CLASS_OPTICAL_25G_AOC: - case TRANSVR_CLASS_OPTICAL_25G_SR: - case TRANSVR_CLASS_OPTICAL_25G_LR: - case TRANSVR_CLASS_OPTICAL_25G_ER: - case TRANSVR_CLASS_OPTICAL_100G: - case TRANSVR_CLASS_OPTICAL_100G_AOC: - case TRANSVR_CLASS_OPTICAL_100G_SR4: - case TRANSVR_CLASS_OPTICAL_100G_LR4: - case TRANSVR_CLASS_OPTICAL_100G_ER4: - case TRANSVR_CLASS_OPTICAL_100G_PSM4: - return 1; - default: - break; - } - return 0; -} - - -static int -_transvr_init_handler(struct transvr_obj_s *self){ - - int detect[2]; - int d_state = STATE_TRANSVR_UNEXCEPTED; - int d_type = TRANSVR_TYPE_ERROR; - int result = ERR_TRANSVR_UNINIT; - int retry = 6; /* (6+1) x 0.3 = 2.1s > spec:2.0s */ - int elimit = 63; - char emsg[64] = DEBUG_TRANSVR_STR_VAL; - - /* Clean and check callback */ - self->state = STATE_TRANSVR_INIT; - if (self->init == NULL) { - snprintf(emsg, elimit, "init() is null"); - goto initer_err_case_unexcept_0; - } - if (self->clean == NULL) { - snprintf(emsg, elimit, "clean() is null"); - goto initer_err_case_unexcept_0; - } - self->clean(self); - - /* Detect transceiver information */ - result = detect_transvr_state(self, detect); - if (result < 0) { - snprintf(emsg, elimit, "detect_transvr_state() fail"); - switch (result) { - case ERR_TRANSVR_I2C_CRASH: - goto initer_err_case_i2c_ceash; - case ERR_TRNASVR_BE_ISOLATED: - goto initer_err_case_be_isolated; - - case ERR_TRANSVR_UNEXCPT: - default: - break; - } - goto initer_err_case_retry_1; - } - d_state = detect[0]; - d_type = detect[1]; - - /* Verify transceiver type and state */ - switch (_is_transvr_valid(self, d_type, d_state)) { - case 0: - break; - case EVENT_TRANSVR_INIT_DOWN: - goto initer_ok_case_down;; - case EVENT_TRANSVR_INIT_FAIL: - snprintf(emsg, elimit, "transceiver type doesn't support"); - goto initer_err_case_alarm_to_user; - case EVENT_TRANSVR_EXCEP_INIT: - default: - goto initer_err_case_unexcept_1; - } - - /* Handle reload case */ - if (self->type != d_type){ - /* This is the protect mechanism. Normally, This case will not happen. - * When State machine detect swap event during initial, It will trigger - * reload function to ensure type correct. */ - if (_reload_transvr_obj(self, d_type) < 0){ - snprintf(emsg, elimit, "reload object fail"); - goto initer_err_case_unexcept_1; - } - } - - /* Check transceiver HW initial ready */ - switch (_is_transvr_hw_ready(self, d_type)) { - case EVENT_TRANSVR_TASK_DONE: - break; - case EVENT_TRANSVR_TASK_WAIT: - goto initer_err_case_retry_1; - case EVENT_TRANSVR_INIT_FAIL: - default: - goto initer_err_case_unexcept_1; - } - - /* Try to update all and check */ - if (self->update_all(self, 1) < 0){ - /* For some transceiver, EEPROME has lag issues during initial stage. - * In this case, we set status back to STATE_TRANSVR_NEW, than it will - * be checked in next polling cycle. */ - goto initer_err_case_retry_1; - } - - /* Execute init() call back */ - result = self->init(self); - switch (result) { - case EVENT_TRANSVR_TASK_DONE: - break; - case EVENT_TRANSVR_TASK_WAIT: - goto initer_ok_case_wait; - - default: - snprintf(emsg, elimit, "undefined init() return:%d\n", result); - goto initer_err_case_unexcept_1; - } - goto initer_ok_case_up; - - -initer_ok_case_wait: - self->dump_all(self); - return EVENT_TRANSVR_TASK_WAIT; - -initer_ok_case_up: - self->state = STATE_TRANSVR_CONNECTED; - self->temp = 0; - self->dump_all(self); - return EVENT_TRANSVR_INIT_UP; - -initer_ok_case_down: - self->temp = 0; - self->state = STATE_TRANSVR_DISCONNECTED; - return EVENT_TRANSVR_INIT_DOWN; - -initer_err_case_i2c_ceash: - SWPS_DEBUG("%s: %s :%s :I2C crash\n", - __func__, emsg, self->swp_name); - self->state = STATE_TRANSVR_UNEXCEPTED; - return EVENT_TRANSVR_I2C_CRASH; - -initer_err_case_be_isolated: - SWPS_DEBUG("%s: %s :%s :isolated\n", - __func__, emsg, self->swp_name); - self->state = STATE_TRANSVR_ISOLATED; - return EVENT_TRANSVR_EXCEP_ISOLATED; - -initer_err_case_retry_1: - SWPS_DEBUG("%s: %s :%s :retry\n", - __func__, emsg, self->swp_name); - if (_transvr_handle_retry(self, retry) == 0) { - self->state = STATE_TRANSVR_NEW; - return EVENT_TRANSVR_INIT_REINIT; - } - goto initer_err_case_alarm_to_user; - -initer_err_case_unexcept_1: - self->clean(self); -initer_err_case_unexcept_0: - self->state = STATE_TRANSVR_UNEXCEPTED; - if (_is_except_happened_4_pmode(self, d_state) && - (self->mode == TRANSVR_MODE_POLLING) ){ - SWPS_INFO("%s: %s :%s\n", __func__, emsg, self->swp_name); - SWPS_INFO("Dump: :%d :%d :%d :%d\n", - self->state, self->type, d_state, d_type); - } - return EVENT_TRANSVR_INIT_FAIL; - -initer_err_case_alarm_to_user: - SWPS_DEBUG("%s: %s :%s :alarm_to_user\n", - __func__, emsg, self->swp_name); - self->state = STATE_TRANSVR_UNEXCEPTED; - alarm_msg_2_user(self, "detected transceiver/cables not meet SFF standard"); - return EVENT_TRANSVR_INIT_FAIL; -} - - -/* ========== Object functions for Clean procedure ========== - */ -int -_transvr_clean_handler(struct transvr_obj_s *self){ - - int retval = DEBUG_TRANSVR_INT_VAL; - - if (!self->clean) { - SWPS_ERR("%s: %s clean() is NULL.\n", - __func__, self->swp_name); - return EVENT_TRANSVR_TASK_FAIL; - } - retval = self->clean(self); - if (retval != EVENT_TRANSVR_TASK_DONE){ - SWPS_ERR("%s: %s clean() fail. [ERR]:%d\n", - __func__, self->swp_name, retval); - return retval; - } - return EVENT_TRANSVR_TASK_DONE; -} - - -int -common_transvr_clean(struct transvr_obj_s *self){ - - transvr_task_free_all(self); - transvr_cache_free_all(self); - return EVENT_TRANSVR_TASK_DONE; -} - - -int -qsfp_transvr_clean(struct transvr_obj_s *self){ - - int retval; - int lpower_config = 1; - - retval = _taskfunc_qsfp_setup_power_mod(self, lpower_config); - if (retval < 0){ - SWPS_ERR("%s: Set lpmod fail! :%d\n", - __func__, retval); - return retval; - } - retval = common_transvr_clean(self); - if (retval < 0){ - SWPS_ERR("%s: common_transvr_clean fail! :%d\n", - __func__, retval); - return retval; - } - return EVENT_TRANSVR_TASK_DONE; -} - - -int -fake_transvr_clean(struct transvr_obj_s *self){ - - return EVENT_TRANSVR_TASK_DONE; -} - - -/* ========== Object functions for check and update ========== - */ -int -common_transvr_check(struct transvr_obj_s *self){ - - char fun_str[32] = "common_transvr_check"; - - if (self->mode != TRANSVR_MODE_POLLING) { - SWPS_ERR("%s: mode:%d is not TRANSVR_MODE_POLLING\n", - fun_str, self->mode); - return ERR_TRANSVR_UNEXCPT; - } - /* Trigger delay task */ - transvr_task_run_all(self); - /* Trigger state machine to check and update */ - return self->fsm_4_polling(self, fun_str); -} - - -int -fake_transvr_check(struct transvr_obj_s *self){ - return 0; -} - - -/* ========== Functions for Factory pattern ========== - */ -static int -setup_transvr_public_cb(struct transvr_obj_s *self, - int transvr_type){ - switch (transvr_type){ - case TRANSVR_TYPE_SFP: - self->get_id = common_get_id; - self->get_eeprom = common_get_eeprom; - self->get_ext_id = common_get_ext_id; - self->get_connector = common_get_connector; - self->get_vendor_name = common_get_vendor_name; - self->get_vendor_pn = common_get_vendor_pn; - self->get_vendor_rev = common_get_vendor_rev; - self->get_vendor_sn = common_get_vendor_sn; - self->get_power_cls = unsupported_get_func; - self->get_br = common_get_br; - self->get_len_sm = sfp_get_len_sm; - self->get_len_smf = common_get_len_smf; - self->get_len_om1 = common_get_len_om1; - self->get_len_om2 = common_get_len_om2; - self->get_len_om3 = common_get_len_om3; - self->get_len_om4 = common_get_len_om4; - self->get_comp_rev = common_get_comp_rev; - self->get_comp_eth_1 = sfp_get_comp_eth_1; - self->get_comp_eth_10 = sfp_get_comp_eth_10; - self->get_comp_eth_10_40 = unsupported_get_func; - self->get_comp_extend = common_get_comp_extended; - self->get_cdr = unsupported_get_func; - self->get_rate_id = sfp_get_rate_id; - self->get_soft_rs0 = sfp_get_soft_rs0; - self->get_soft_rs1 = sfp_get_soft_rs1; - self->get_info = common_get_info; - self->get_if_type = sfp_get_if_type; - self->get_if_speed = sfp_get_if_speed; - self->get_if_lane = common_get_if_lane; - self->get_curr_temp = sfp_get_transvr_temp; - self->get_curr_vol = sfp_get_transvr_voltage; - self->get_soft_rx_los = unsupported_get_func2; - self->get_soft_tx_disable = unsupported_get_func2; - self->get_soft_tx_fault = unsupported_get_func2; - self->get_auto_tx_disable = unsupported_get_func2; - self->get_tx_bias = sfp_get_transvr_tx_bias; - self->get_tx_power = sfp_get_transvr_tx_power; - self->get_rx_power = sfp_get_transvr_rx_power; - self->get_tx_eq = sfp_get_transvr_tx_eq; - self->get_rx_am = unsupported_get_func2; - self->get_rx_em = sfp_get_transvr_rx_em; - self->get_wavelength = sfp_get_wavelength; - self->get_extphy_offset = sfp_get_1g_rj45_extphy_offset; - self->get_extphy_reg = sfp_get_1g_rj45_extphy_reg; - self->set_cdr = unsupported_set_func; - self->set_soft_rs0 = sfp_set_soft_rs0; - self->set_soft_rs1 = sfp_set_soft_rs1; - self->set_soft_tx_disable = unsupported_set_func; - self->set_auto_tx_disable = unsupported_set_func; - self->set_tx_eq = sfp_set_tx_eq; - self->set_rx_am = unsupported_set_func; - self->set_rx_em = sfp_set_rx_em; - self->set_extphy_offset = sfp_set_1g_rj45_extphy_offset; - self->set_extphy_reg = sfp_set_1g_rj45_extphy_reg; - return 0; - - case TRANSVR_TYPE_QSFP: - case TRANSVR_TYPE_QSFP_PLUS: - self->get_id = common_get_id; - self->get_eeprom = common_get_eeprom; - self->get_ext_id = common_get_ext_id; - self->get_connector = common_get_connector; - self->get_vendor_name = common_get_vendor_name; - self->get_vendor_pn = common_get_vendor_pn; - self->get_vendor_rev = common_get_vendor_rev; - self->get_vendor_sn = common_get_vendor_sn; - self->get_power_cls = qsfp_get_power_cls; - self->get_br = common_get_br; - self->get_len_sm = unsupported_get_func; - self->get_len_smf = common_get_len_smf; - self->get_len_om1 = common_get_len_om1; - self->get_len_om2 = common_get_len_om2; - self->get_len_om3 = common_get_len_om3; - self->get_len_om4 = common_get_len_om4; - self->get_comp_rev = common_get_comp_rev; - self->get_comp_eth_1 = qsfp_get_comp_eth; - self->get_comp_eth_10 = unsupported_get_func; - self->get_comp_eth_10_40 = qsfp_get_comp_10_40; - self->get_comp_extend = common_get_comp_extended; - self->get_cdr = unsupported_get_func; - self->get_rate_id = unsupported_get_func; - self->get_soft_rs0 = unsupported_get_func; /* TBD */ - self->get_soft_rs1 = unsupported_get_func; /* TBD */ - self->get_info = common_get_info; - self->get_if_type = qsfp_get_if_type; - self->get_if_speed = qsfp_get_if_speed; - self->get_if_lane = common_get_if_lane; - self->get_curr_temp = qsfp_get_transvr_temp; - self->get_curr_vol = qsfp_get_transvr_voltage; - self->get_soft_rx_los = qsfp_get_soft_rx_los; - self->get_soft_tx_disable = qsfp_get_soft_tx_disable; - self->get_soft_tx_fault = qsfp_get_soft_tx_fault; - self->get_auto_tx_disable = qsfp_get_auto_tx_disable; - self->get_tx_bias = qsfp_get_transvr_tx_bias; - self->get_tx_power = qsfp_get_transvr_tx_power; - self->get_rx_power = qsfp_get_transvr_rx_power; - self->get_tx_eq = unsupported_get_func2; - self->get_rx_am = unsupported_get_func2; - self->get_rx_em = unsupported_get_func2; - self->get_wavelength = qsfp_get_wavelength; - self->get_extphy_offset = unsupported_get_func2; - self->get_extphy_reg = unsupported_get_func2; - self->set_cdr = unsupported_set_func; - self->set_soft_rs0 = unsupported_set_func; /* TBD */ - self->set_soft_rs1 = unsupported_set_func; /* TBD */ - self->set_soft_tx_disable = qsfp_set_soft_tx_disable; - self->set_auto_tx_disable = qsfp_set_auto_tx_disable; - self->set_tx_eq = unsupported_set_func; - self->set_rx_am = unsupported_set_func; - self->set_rx_em = unsupported_set_func; - self->set_extphy_offset = unsupported_set_func; - self->set_extphy_reg = unsupported_set_func; - return 0; - - case TRANSVR_TYPE_QSFP_28: - self->get_id = common_get_id; - self->get_eeprom = common_get_eeprom; - self->get_ext_id = common_get_ext_id; - self->get_connector = common_get_connector; - self->get_vendor_name = common_get_vendor_name; - self->get_vendor_pn = common_get_vendor_pn; - self->get_vendor_rev = common_get_vendor_rev; - self->get_vendor_sn = common_get_vendor_sn; - self->get_power_cls = qsfp_get_power_cls; - self->get_br = common_get_br; - self->get_len_sm = unsupported_get_func; - self->get_len_smf = common_get_len_smf; - self->get_len_om1 = common_get_len_om1; - self->get_len_om2 = common_get_len_om2; - self->get_len_om3 = common_get_len_om3; - self->get_len_om4 = common_get_len_om4; - self->get_comp_rev = common_get_comp_rev; - self->get_comp_eth_1 = qsfp_get_comp_eth; - self->get_comp_eth_10 = unsupported_get_func; - self->get_comp_eth_10_40 = qsfp_get_comp_10_40; - self->get_comp_extend = common_get_comp_extended; - self->get_cdr = qsfp_get_cdr; - self->get_rate_id = unsupported_get_func; - self->get_soft_rs0 = unsupported_get_func; /* TBD */ - self->get_soft_rs1 = unsupported_get_func; /* TBD */ - self->get_info = common_get_info; - self->get_if_type = qsfp_get_if_type; - self->get_if_speed = qsfp_get_if_speed; - self->get_if_lane = common_get_if_lane; - self->get_curr_temp = qsfp_get_transvr_temp; - self->get_curr_vol = qsfp_get_transvr_voltage; - self->get_soft_rx_los = qsfp_get_soft_rx_los; - self->get_soft_tx_disable = qsfp_get_soft_tx_disable; - self->get_soft_tx_fault = qsfp_get_soft_tx_fault; - self->get_auto_tx_disable = qsfp_get_auto_tx_disable; - self->get_tx_bias = qsfp_get_transvr_tx_bias; - self->get_tx_power = qsfp_get_transvr_tx_power; - self->get_rx_power = qsfp_get_transvr_rx_power; - self->get_tx_eq = qsfp_get_transvr_tx_eq; - self->get_rx_am = qsfp_get_transvr_rx_am; - self->get_rx_em = qsfp_get_transvr_rx_em; - self->get_wavelength = qsfp_get_wavelength; - self->get_extphy_offset = unsupported_get_func2; - self->get_extphy_reg = unsupported_get_func2; - self->set_cdr = qsfp_set_cdr; - self->set_soft_rs0 = unsupported_set_func; /* TBD */ - self->set_soft_rs1 = unsupported_set_func; /* TBD */ - self->set_soft_tx_disable = qsfp_set_soft_tx_disable; - self->set_auto_tx_disable = qsfp_set_auto_tx_disable; - self->set_tx_eq = qsfp_set_tx_eq; - self->set_rx_am = qsfp_set_rx_am; - self->set_rx_em = qsfp_set_rx_em; - self->set_extphy_offset = unsupported_set_func; - self->set_extphy_reg = unsupported_set_func; - return 0; - - case TRANSVR_TYPE_FAKE: - self->get_id = fake_get_hex; - self->get_ext_id = fake_get_hex; - self->get_connector = fake_get_hex; - self->get_vendor_name = fake_get_str; - self->get_vendor_pn = fake_get_str; - self->get_vendor_rev = fake_get_str; - self->get_vendor_sn = fake_get_str; - self->get_power_cls = fake_get_int; - self->get_br = fake_get_hex; - self->get_len_sm = fake_get_int; - self->get_len_smf = fake_get_int; - self->get_len_om1 = fake_get_int; - self->get_len_om2 = fake_get_int; - self->get_len_om3 = fake_get_int; - self->get_len_om4 = fake_get_int; - self->get_comp_rev = fake_get_hex; - self->get_comp_eth_1 = fake_get_hex; - self->get_comp_eth_10 = fake_get_hex; - self->get_comp_eth_10_40 = fake_get_hex; - self->get_comp_extend = fake_get_hex; - self->get_cdr = fake_get_hex; - self->get_rate_id = fake_get_hex; - self->get_soft_rs0 = fake_get_binary; - self->get_soft_rs1 = fake_get_binary; - self->get_info = fake_get_int; - self->get_if_type = fake_get_str; - self->get_if_speed = fake_get_str; - self->get_if_lane = fake_get_str; - self->get_curr_temp = fake_get_str; - self->get_curr_vol = fake_get_str; - self->get_soft_rx_los = fake_get_str; - self->get_soft_tx_disable = fake_get_str; - self->get_soft_tx_fault = fake_get_str; - self->get_auto_tx_disable = fake_get_str; - self->get_tx_bias = fake_get_str; - self->get_tx_power = fake_get_str; - self->get_rx_power = fake_get_str; - self->get_tx_eq = fake_get_str; - self->get_rx_am = fake_get_str; - self->get_rx_em = fake_get_str; - self->get_wavelength = fake_get_str; - self->get_extphy_offset = fake_get_str; - self->get_extphy_reg = fake_get_str; - self->set_cdr = fake_set_hex; - self->set_soft_rs0 = fake_set_int; - self->set_soft_rs1 = fake_set_int; - self->set_soft_tx_disable = fake_set_int; - self->set_auto_tx_disable = fake_set_int; - self->set_tx_eq = fake_set_int; - self->set_rx_am = fake_set_int; - self->set_rx_em = fake_set_int; - self->set_extphy_offset = fake_set_hex; - self->set_extphy_reg = fake_set_hex; - return 0; - - default: - break; - } - SWPS_WARN("%s: Detect non-defined type:%d\n", __func__, transvr_type); - return ERR_TRANSVR_UNEXCPT; -} - - -static int -setup_transvr_private_cb(struct transvr_obj_s *self, - int transvr_type){ - switch (transvr_type){ - case TRANSVR_TYPE_SFP: - self->init = transvr_init_sfp; - self->clean = common_transvr_clean; - self->check = common_transvr_check; - self->update_all = _sfp_update_attr_all; - self->fsm_4_direct = common_fsm_4_direct_mode; - self->fsm_4_polling = common_fsm_4_polling_mode; - self->send_uevent = sfp_send_uevent; - self->dump_all = sfp_transvr_dump; - return 0; - - case TRANSVR_TYPE_QSFP: - case TRANSVR_TYPE_QSFP_PLUS: - self->init = transvr_init_qsfp; - self->clean = qsfp_transvr_clean; - self->check = common_transvr_check; - self->update_all = _qsfp_update_attr_all; - self->fsm_4_direct = common_fsm_4_direct_mode; - self->fsm_4_polling = common_fsm_4_polling_mode; - self->send_uevent = qsfp_send_uevent; - self->dump_all = qsfp_transvr_dump; - return 0; - - case TRANSVR_TYPE_QSFP_28: - self->init = transvr_init_qsfp28; - self->clean = qsfp_transvr_clean; - self->check = common_transvr_check; - self->update_all = _qsfp_update_attr_all; - self->fsm_4_direct = common_fsm_4_direct_mode; - self->fsm_4_polling = common_fsm_4_polling_mode; - self->send_uevent = qsfp_send_uevent; - self->dump_all = qsfp_transvr_dump; - return 0; - - case TRANSVR_TYPE_FAKE: - self->init = transvr_init_fake; - self->clean = fake_transvr_clean; - self->check = fake_transvr_check; - self->update_all = fake_transvr_update; - self->fsm_4_direct = fake_fsm_4_direct_mode; - self->fsm_4_polling = fake_fsm_4_polling_mode; - self->send_uevent = fake_send_uevent; - self->dump_all = fake_transvr_dump; - return 0; - - default: - break; - } - SWPS_WARN("%s: Detect non-defined type:%d\n", __func__, transvr_type); - return ERR_TRANSVR_UNEXCPT; -} - - -static struct eeprom_map_s * -get_eeprom_map(int transvr_type){ - - switch (transvr_type){ - case TRANSVR_TYPE_SFP: - return &eeprom_map_sfp; - case TRANSVR_TYPE_QSFP: - case TRANSVR_TYPE_QSFP_PLUS: - return &eeprom_map_qsfp; - case TRANSVR_TYPE_QSFP_28: - return &eeprom_map_qsfp28; - - default: - break; - } - SWPS_WARN("%s: Detect non-defined type:%d\n", __func__, transvr_type); - return NULL; -} - - -static int -setup_transvr_ssize_attr(char *swp_name, - struct transvr_obj_s *self, - struct eeprom_map_s *map_p, - struct ioexp_obj_s *ioexp_obj_p, - int ioexp_virt_offset, - int transvr_type, - int chipset_type, - int chan_id, - int run_mode){ - switch (run_mode){ - case TRANSVR_MODE_DIRECT: /* Direct access device mode */ - case TRANSVR_MODE_POLLING: /* Polling mode, read from cache */ - self->mode = run_mode; - break; - default: - SWPS_ERR("%s: non-defined run_mode:%d\n", - __func__, run_mode); - self->mode = DEBUG_TRANSVR_INT_VAL; - return -1; - } - self->eeprom_map_p = map_p; - self->ioexp_obj_p = ioexp_obj_p; - self->ioexp_virt_offset = ioexp_virt_offset; - self->chan_id = chan_id; - self->layout = transvr_type; - self->type = transvr_type; - self->chipset_type = chipset_type; - self->state = STATE_TRANSVR_NEW; - self->info = STATE_TRANSVR_NEW; - self->auto_tx_disable = VAL_TRANSVR_FUNCTION_DISABLE; - strncpy(self->swp_name, swp_name, 32); - mutex_init(&self->lock); - return 0; -} - - -static int -setup_transvr_dsize_attr(struct transvr_obj_s *self){ - - char *emsg = DEBUG_TRANSVR_STR_VAL; - - self->vendor_name = kzalloc((LEN_TRANSVR_M_STR * sizeof(char)), GFP_KERNEL); - if (!self->vendor_name){ - emsg = "vendor_name"; - goto err_setup_d_attr; - } - self->vendor_pn = kzalloc((LEN_TRANSVR_M_STR * sizeof(char)), GFP_KERNEL); - if (!self->vendor_pn){ - emsg = "vendor_pn"; - goto err_setup_d_attr; - } - self->vendor_rev = kzalloc((LEN_TRANSVR_M_STR * sizeof(char)), GFP_KERNEL); - if (!self->vendor_rev){ - emsg = "vendor_rev"; - goto err_setup_d_attr; - } - self->vendor_sn = kzalloc((LEN_TRANSVR_M_STR * sizeof(char)), GFP_KERNEL); - if (!self->vendor_sn){ - emsg = "vendor_sn"; - goto err_setup_d_attr; - } - self->worker_p = NULL; - return 0; - -err_setup_d_attr: - SWPS_ERR("%s: %s kzalloc fail!", __func__, emsg); - return ERR_TRANSVR_UNEXCPT; -} - - -static int -setup_i2c_client(struct transvr_obj_s *self){ - - struct i2c_adapter *adap = NULL; - struct i2c_client *client = NULL; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - - adap = i2c_get_adapter(self->chan_id); - if(!adap){ - snprintf(err_msg, sizeof(err_msg), - "can not get adap:%d", self->chan_id); - goto err_setup_i2c_client; - } - client = kzalloc(sizeof(*client), GFP_KERNEL); - if (!client){ - snprintf(err_msg, sizeof(err_msg), - "can not kzalloc client:%d", self->chan_id); - goto err_setup_i2c_client; - } - client->adapter = adap; - self->i2c_client_p = client; - self->i2c_client_p->addr = VAL_TRANSVR_COMID_ARREESS; - return 0; - -err_setup_i2c_client: - SWPS_ERR("%s: %s\n", __func__, err_msg); - return ERR_TRANSVR_UNEXCPT; -} - - -struct transvr_obj_s * -create_transvr_obj(char *swp_name, - int chan_id, - struct ioexp_obj_s *ioexp_obj_p, - int ioexp_virt_offset, - int transvr_type, - int chipset_type, - int run_mode){ - - struct transvr_obj_s *result_p; - struct eeprom_map_s *map_p; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - - /* Allocate transceiver object */ - map_p = get_eeprom_map(transvr_type); - if (!map_p){ - snprintf(err_msg, sizeof(err_msg), - "Invalid transvr_type:%d", transvr_type); - goto err_create_transvr_fail; - } - result_p = kzalloc(sizeof(*result_p), GFP_KERNEL); - if (!result_p){ - snprintf(err_msg, sizeof(err_msg), "kzalloc fail"); - goto err_create_transvr_fail; - } - /* Prepare static size attributes */ - if (setup_transvr_ssize_attr(swp_name, - result_p, - map_p, - ioexp_obj_p, - ioexp_virt_offset, - transvr_type, - chipset_type, - chan_id, - run_mode) < 0){ - goto err_create_transvr_sattr_fail; - } - /* Prepare dynamic size attributes */ - if (setup_transvr_dsize_attr(result_p) < 0){ - goto err_create_transvr_dattr_fail; - } - /* Prepare call back functions of object */ - if (setup_transvr_public_cb(result_p, transvr_type) < 0){ - goto err_create_transvr_dattr_fail; - } - /* Prepare call back functions of object */ - if (setup_transvr_private_cb(result_p, transvr_type) < 0){ - goto err_create_transvr_dattr_fail; - } - /* Prepare i2c client object */ - if (setup_i2c_client(result_p) < 0){ - goto err_create_transvr_dattr_fail; - } - return result_p; - -err_create_transvr_dattr_fail: - kfree(result_p->vendor_sn); - kfree(result_p->vendor_rev); - kfree(result_p->vendor_pn); - kfree(result_p->vendor_name); -err_create_transvr_sattr_fail: - kfree(result_p); -err_create_transvr_fail: - SWPS_ERR("%s: %s :%d :%d :%d\n", - __func__, err_msg, chan_id, ioexp_virt_offset, transvr_type); - return NULL; -} - - -static int -_reload_transvr_obj(struct transvr_obj_s *self, - int new_type){ - - struct eeprom_map_s *new_map_p; - struct eeprom_map_s *old_map_p = self->eeprom_map_p; - struct i2c_client *old_i2c_p = self->i2c_client_p; - int old_type = self->type; - - /* Change state to STATE_TRANSVR_INIT */ - self->state = STATE_TRANSVR_INIT; - self->type = new_type; - /* Replace EEPROME map */ - new_map_p = get_eeprom_map(new_type); - if (!new_map_p){ - goto err_private_reload_func_1; - } - self->eeprom_map_p = new_map_p; - /* Reload i2c client */ - if (setup_i2c_client(self) < 0){ - goto err_private_reload_func_2; - } - /* Replace call back functions */ - if (setup_transvr_public_cb(self, new_type) < 0){ - goto err_private_reload_func_3; - } - if (setup_transvr_private_cb(self, new_type) < 0){ - goto err_private_reload_func_3; - } - kfree(old_i2c_p); - return 0; - -err_private_reload_func_3: - SWPS_INFO("%s: init() fail!\n", __func__); - kfree(old_i2c_p); - self->state = STATE_TRANSVR_UNEXCEPTED; - self->type = TRANSVR_TYPE_ERROR; - return -2; - -err_private_reload_func_2: - self->eeprom_map_p = old_map_p; - self->i2c_client_p = old_i2c_p; -err_private_reload_func_1: - self->state = STATE_TRANSVR_UNEXCEPTED; - self->type = old_type; - SWPS_INFO("%s fail! :0x%02x\n", __func__, new_type); - return -1; -} - - -static int -reload_transvr_obj(struct transvr_obj_s *self, - int new_type){ - - int result_val = ERR_TRANSVR_UNEXCPT; - - /* Reload phase */ - result_val = _reload_transvr_obj(self, new_type); - if (result_val < 0){ - SWPS_INFO("%s: reload phase fail! :%d\n", - __func__, result_val); - return EVENT_TRANSVR_RELOAD_FAIL; - } - /* Initial phase */ - result_val = _transvr_init_handler(self); - if (result_val < 0){ - SWPS_INFO("%s: initial phase fail! :%d\n", - __func__, result_val); - } - return result_val; -} - - -int -isolate_transvr_obj(struct transvr_obj_s *self) { - - self->state = STATE_TRANSVR_ISOLATED; - SWPS_INFO("%s: %s be isolated\n", __func__, self->swp_name); - return 0; -} - - -int -resync_channel_tier_2(struct transvr_obj_s *self) { - - int val = TRANSVR_TYPE_ERROR; - - if (self->state == STATE_TRANSVR_ISOLATED) { - return 0; - } - self->i2c_client_p->addr = VAL_TRANSVR_COMID_ARREESS; - val = i2c_smbus_read_byte_data(self->i2c_client_p, - VAL_TRANSVR_COMID_OFFSET); - if (val < 0) { - return -1; - } - return 0; -} - - -/* ----------------------------------------- - * ToDo List - * ----------------------------------------- - * 1. _sfp_detect_class_by_feature() - * => Need check ACC use case. - * 2. _sfp_detect_class_by_1g_ethernet() - * => Need check 0.1G use case. - * 3. Loopback transceiver use case. - * => Less much data - * 4. _qsfp_detect_class_by_extend_comp() - * => Verify 100G CWDM4 - * => Verify Obsolete (assigned before 100G CWDM4 MSA required FEC) - * => Verify 100G CLR4 - * => Verify 100GE-DWDM2 - * => Verify 40G PSM4 Parallel SMF - * => Verify 100G ACC (Active Copper Cable) or 25GAUI C2M ACC. - * => Verify 100G ACC or 25GAUI C2M ACC. - * => Verify 25GBASE-LR - * => Verify 40G Active Cable (XLPPI) - */ - - - - - - diff --git a/packages/platforms/inventec/x86-64/d6556/modules/builds/src/transceiver.h b/packages/platforms/inventec/x86-64/d6556/modules/builds/src/transceiver.h deleted file mode 100644 index ed60471e5..000000000 --- a/packages/platforms/inventec/x86-64/d6556/modules/builds/src/transceiver.h +++ /dev/null @@ -1,811 +0,0 @@ -#ifndef TRANSCEIVER_H -#define TRANSCEIVER_H - -#include - -/* advanced features control */ -#define TRANSVR_INFO_DUMP_ENABLE (1) -#define TRANSVR_INFO_CACHE_ENABLE (1) -#define TRANSVR_UEVENT_ENABLE (1) - -/* Transceiver type define */ -#define TRANSVR_TYPE_UNKNOW_1 (0x00) -#define TRANSVR_TYPE_UNKNOW_2 (0xff) -#define TRANSVR_TYPE_SFP (0x03) /* Define for SFP, SFP+, SFP28 */ -#define TRANSVR_TYPE_QSFP (0x0c) -#define TRANSVR_TYPE_QSFP_PLUS (0x0d) -#define TRANSVR_TYPE_QSFP_28 (0x11) -#define TRANSVR_TYPE_UNPLUGGED (0xfa) /* Define for ERROR handle */ -#define TRANSVR_TYPE_FAKE (0xfc) /* Define for ERROR handle */ -#define TRANSVR_TYPE_INCONSISTENT (0xfd) /* Define for ERROR handle */ -#define TRANSVR_TYPE_ERROR (0xfe) /* Define for ERROR handle */ - -/* Transceiver class for base info */ -#define TRANSVR_CLASS_UNSPECIFIED (0) -#define TRANSVR_CLASS_ERROR (-26001) -#define TRANSVR_CLASS_1G (26001) -#define TRANSVR_CLASS_10G (26011) -#define TRANSVR_CLASS_25G (26021) -#define TRANSVR_CLASS_40G (26041) -#define TRANSVR_CLASS_100G (26101) -#define TRANSVR_CLASS_NO_SPERARABLE (26901) -#define TRANSVR_CLASS_EXTEND_COMP (26902) -/* Transceiver class for Optical 1G */ -#define TRANSVR_CLASS_OPTICAL (27000) -#define TRANSVR_CLASS_OPTICAL_100 (27001) -#define TRANSVR_CLASS_OPTICAL_1G (27002) -#define TRANSVR_CLASS_OPTICAL_1G_AOC (27003) -#define TRANSVR_CLASS_OPTICAL_1G_SX (27004) -#define TRANSVR_CLASS_OPTICAL_1G_LX (27005) -#define TRANSVR_CLASS_OPTICAL_1G_EX (27006) -/* Transceiver class for Optical 10G */ -#define TRANSVR_CLASS_OPTICAL_10G (27010) -#define TRANSVR_CLASS_OPTICAL_10G_S_AOC (27011) -#define TRANSVR_CLASS_OPTICAL_10G_S_SR (27012) -#define TRANSVR_CLASS_OPTICAL_10G_S_LR (27013) -#define TRANSVR_CLASS_OPTICAL_10G_S_ER (27014) -#define TRANSVR_CLASS_OPTICAL_10G_Q_AOC (27015) -#define TRANSVR_CLASS_OPTICAL_10G_Q_SR (27016) -#define TRANSVR_CLASS_OPTICAL_10G_Q_LR (27017) -#define TRANSVR_CLASS_OPTICAL_10G_Q_ER (27018) -/* Transceiver class for Optical 25G */ -#define TRANSVR_CLASS_OPTICAL_25G (27020) -#define TRANSVR_CLASS_OPTICAL_25G_AOC (27021) -#define TRANSVR_CLASS_OPTICAL_25G_SR (27022) -#define TRANSVR_CLASS_OPTICAL_25G_LR (27023) -#define TRANSVR_CLASS_OPTICAL_25G_ER (27024) -/* Transceiver class for Optical 40G */ -#define TRANSVR_CLASS_OPTICAL_40G (27040) -#define TRANSVR_CLASS_OPTICAL_40G_AOC (27041) -#define TRANSVR_CLASS_OPTICAL_40G_SR4 (27042) -#define TRANSVR_CLASS_OPTICAL_40G_LR4 (27043) -#define TRANSVR_CLASS_OPTICAL_40G_ER4 (27044) -/* Transceiver class for Optical 100G */ -#define TRANSVR_CLASS_OPTICAL_100G (27100) -#define TRANSVR_CLASS_OPTICAL_100G_AOC (27101) -#define TRANSVR_CLASS_OPTICAL_100G_SR4 (27102) -#define TRANSVR_CLASS_OPTICAL_100G_LR4 (27103) -#define TRANSVR_CLASS_OPTICAL_100G_ER4 (27104) -#define TRANSVR_CLASS_OPTICAL_100G_PSM4 (27105) -/* Transceiver class for Copper */ -#define TRANSVR_CLASS_COPPER (28000) -#define TRANSVR_CLASS_COPPER_L1_1G (28001) -#define TRANSVR_CLASS_COPPER_L1_10G (28011) -#define TRANSVR_CLASS_COPPER_L4_10G (28012) -#define TRANSVR_CLASS_COPPER_L1_25G (28021) -#define TRANSVR_CLASS_COPPER_L4_40G (28041) -#define TRANSVR_CLASS_COPPER_L4_100G (28101) -/* Transceiver class for Base-T */ -#define TRANSVR_CLASS_BASE_T_1000 (29001) -#define TRANSVR_CLASS_BASE_T_1000_up (29002) -/* For uevent message */ -#define TRANSVR_UEVENT_KEY_IF "IF_TYPE" -#define TRANSVR_UEVENT_KEY_SP "IF_SPEED" -#define TRANSVR_UEVENT_KEY_LANE "IF_LANE" -#define TRANSVR_UEVENT_UNKNOW "UNKNOW" -#define TRANSVR_IF_KR "KR" -#define TRANSVR_IF_KR4 "KR4" -#define TRANSVR_IF_SR "SR" -#define TRANSVR_IF_SR4 "SR4" -#define TRANSVR_IF_SFI "SFI" -#define TRANSVR_IF_IF_GMII "GMII" -#define TRANSVR_IF_IF_XGMII "XGMII" -#define TRANSVR_IF_SP_100 "100" -#define TRANSVR_IF_SP_1G "1000" -#define TRANSVR_IF_SP_10G "10000" -#define TRANSVR_IF_SP_25G "25000" -#define TRANSVR_IF_SP_40G "40000" -#define TRANSVR_IF_SP_100G "100000" - -/* Transceiver mode define */ -#define TRANSVR_MODE_DIRECT (21000) -#define TRANSVR_MODE_POLLING (21001) - -/* Transceiver state define - * [Note] - * 1. State is used to represent the state of "Transceiver" and "Object". - * 2. State for different target has different means. The description as following: - */ -#define STATE_TRANSVR_CONNECTED (0) /* [Transvr]:Be plugged in. [Obj]:Link up, and work normally. */ -#define STATE_TRANSVR_NEW (-100) /* [Transvr]:(Not used) [Obj]:Create */ -#define STATE_TRANSVR_INIT (-101) /* [Transvr]:Be plugged in. [Obj]:Link up, and in initial process. */ -#define STATE_TRANSVR_ISOLATED (-102) /* [Transvr]:Be plugged in. [Obj]:Isolate, and not provide service. */ -#define STATE_TRANSVR_SWAPPED (-200) /* [Transvr]:Be plugged in. [Obj]:(Not used) */ -#define STATE_TRANSVR_DISCONNECTED (-300) /* [Transvr]:Un-plugged. [Obj]:Link down, and not provide service. */ -#define STATE_TRANSVR_UNEXCEPTED (-901) /* [Transvr]:Any [Obj]:Any, and not in expect case. */ - -/* Task state define */ -#define STATE_T_TASK_WAIT (110) -#define STATE_T_TASK_DONE (0) -#define STATE_T_TASK_INIT (-110) -#define STATE_T_TASK_FAIL (-410) - - -/* Event for task handling */ -#define EVENT_TRANSVR_TASK_WAIT (2101) -#define EVENT_TRANSVR_TASK_DONE (0) -#define EVENT_TRANSVR_TASK_FAIL (-2101) -/* Event for initial handling */ -#define EVENT_TRANSVR_INIT_UP (2201) -#define EVENT_TRANSVR_INIT_DOWN (1) -#define EVENT_TRANSVR_INIT_REINIT (-2201) -#define EVENT_TRANSVR_INIT_FAIL (-2202) -/* Event for others */ -#define EVENT_TRANSVR_RELOAD_FAIL (-2301) -#define EVENT_TRANSVR_EXCEP_INIT (-2401) -#define EVENT_TRANSVR_EXCEP_UP (-2402) -#define EVENT_TRANSVR_EXCEP_DOWN (-2403) -#define EVENT_TRANSVR_EXCEP_SWAP (-2404) -#define EVENT_TRANSVR_EXCEP_EXCEP (-2405) -#define EVENT_TRANSVR_EXCEP_ISOLATED (-2406) -#define EVENT_TRANSVR_I2C_CRASH (-2501) - -/* Transceiver error code define */ -#define ERR_TRANSVR_UNINIT (-201) -#define ERR_TRANSVR_UNPLUGGED (-202) -#define ERR_TRANSVR_ABNORMAL (-203) -#define ERR_TRANSVR_NOSTATE (-204) -#define ERR_TRANSVR_NOTSUPPORT (-205) -#define ERR_TRANSVR_BADINPUT (-206) -#define ERR_TRANSVR_UPDATE_FAIL (-207) -#define ERR_TRANSVR_RELOAD_FAIL (-208) -#define ERR_TRANSVR_INIT_FAIL (-209) -#define ERR_TRANSVR_UNDEFINED (-210) -#define ERR_TRANSVR_TASK_FAIL (-211) -#define ERR_TRANSVR_TASK_BUSY (-212) -#define ERR_TRANSVR_UEVENT_FAIL (-213) -#define ERR_TRANSVR_FUNC_DISABLE (-214) -#define ERR_TRANSVR_I2C_CRASH (-297) -#define ERR_TRNASVR_BE_ISOLATED (-298) -#define ERR_TRANSVR_UNEXCPT (-299) - -/* For debug */ -#define DEBUG_TRANSVR_INT_VAL (-99) -#define DEBUG_TRANSVR_HEX_VAL (0xfe) -#define DEBUG_TRANSVR_STR_VAL "ERROR" - -/* For system internal */ -#define VAL_TRANSVR_COMID_ARREESS (0x50) -#define VAL_TRANSVR_COMID_OFFSET (0x00) -#define VAL_TRANSVR_EXTPHY_ADDR_56 (0x56) -#define VAL_TRANSVR_8472_READY_ADDR (0x51) -#define VAL_TRANSVR_8472_READY_PAGE (-1) -#define VAL_TRANSVR_8472_READY_OFFSET (110) -#define VAL_TRANSVR_8472_READY_BIT (0) -#define VAL_TRANSVR_8472_READY_VALUE (0) -#define VAL_TRANSVR_8472_READY_ABNORMAL (0xff) -#define VAL_TRANSVR_8436_READY_ADDR (0x50) -#define VAL_TRANSVR_8436_READY_PAGE (-1) -#define VAL_TRANSVR_8436_READY_OFFSET (2) -#define VAL_TRANSVR_8436_READY_BIT (0) -#define VAL_TRANSVR_8436_READY_VALUE (0) -#define VAL_TRANSVR_8436_READY_ABNORMAL (0xff) -#define VAL_TRANSVR_8436_PWD_ADDR (0x50) -#define VAL_TRANSVR_8436_PWD_PAGE (-1) -#define VAL_TRANSVR_8436_PWD_OFFSET (123) -#define VAL_TRANSVR_PAGE_FREE (-99) -#define VAL_TRANSVR_PAGE_SELECT_OFFSET (127) -#define VAL_TRANSVR_PAGE_SELECT_DELAY (5) -#define VAL_TRANSVR_TASK_RETRY_FOREVER (-999) -#define VAL_TRANSVR_FUNCTION_DISABLE (-1) -#define STR_TRANSVR_SFP "SFP" -#define STR_TRANSVR_QSFP "QSFP" -#define STR_TRANSVR_QSFP_PLUS "QSFP+" -#define STR_TRANSVR_QSFP28 "QSFP28" - -/* For transvr buf len */ -#define LEN_TRANSVR_S_STR (16) -#define LEN_TRANSVR_M_STR (32) -#define LEN_TRANSVR_L_STR (64) - -/* Optical wavelength */ -#define VAL_OPTICAL_WAVELENGTH_SR (850) -#define VAL_OPTICAL_WAVELENGTH_LR (1310) -#define VAL_OPTICAL_WAVELENGTH_ER (1550) - -/* BCM chip type define */ -#define BCM_CHIP_TYPE_TRIDENT_2 (31001) /* Magnolia, Hudson32i, Spruce */ -#define BCM_CHIP_TYPE_TOMAHAWK (31002) /* Redwood, Cypress, Sequoia */ -#define BCM_CHIP_TYPE_TRIDENT_3 (31003) /* Maple */ - -#define BF_CHIP_TYPE_TOFINO (31011) /* Lavender */ - -/* Info from transceiver EEPROM */ -struct eeprom_map_s { - int addr_br; int page_br; int offset_br; int length_br; - int addr_cdr; int page_cdr; int offset_cdr; int length_cdr; - int addr_comp_rev; int page_comp_rev; int offset_comp_rev; int length_comp_rev; - int addr_connector; int page_connector; int offset_connector; int length_connector; - int addr_diag_type; int page_diag_type; int offset_diag_type; int length_diag_type; - int addr_extbr; int page_extbr; int offset_extbr; int length_extbr; - int addr_ext_id; int page_ext_id; int offset_ext_id; int length_ext_id; - int addr_id; int page_id; int offset_id; int length_id; - int addr_eeprom; int page_eeprom; int offset_eeprom; int length_eeprom; - int addr_len_sm; int page_len_sm; int offset_len_sm; int length_len_sm; - int addr_len_smf; int page_len_smf; int offset_len_smf; int length_len_smf; - int addr_len_om1; int page_len_om1; int offset_len_om1; int length_len_om1; - int addr_len_om2; int page_len_om2; int offset_len_om2; int length_len_om2; - int addr_len_om3; int page_len_om3; int offset_len_om3; int length_len_om3; - int addr_len_om4; int page_len_om4; int offset_len_om4; int length_len_om4; - int addr_option; int page_option; int offset_option; int length_option; - int addr_rate_id; int page_rate_id; int offset_rate_id; int length_rate_id; - int addr_rx_am; int page_rx_am; int offset_rx_am; int length_rx_am; - int addr_rx_em; int page_rx_em; int offset_rx_em; int length_rx_em; - int addr_rx_los; int page_rx_los; int offset_rx_los; int length_rx_los; - int addr_rx_power; int page_rx_power; int offset_rx_power; int length_rx_power; - int addr_soft_rs0; int page_soft_rs0; int offset_soft_rs0; int length_soft_rs0; - int addr_soft_rs1; int page_soft_rs1; int offset_soft_rs1; int length_soft_rs1; - int addr_temp; int page_temp; int offset_temp; int length_temp; - int addr_trancomp; int page_trancomp; int offset_trancomp; int length_trancomp; - int addr_trancomp_ext; int page_trancomp_ext; int offset_trancomp_ext; int length_trancomp_ext; - int addr_tx_bias; int page_tx_bias; int offset_tx_bias; int length_tx_bias; - int addr_tx_disable; int page_tx_disable; int offset_tx_disable; int length_tx_disable; - int addr_tx_eq; int page_tx_eq; int offset_tx_eq; int length_tx_eq; - int addr_tx_fault; int page_tx_fault; int offset_tx_fault; int length_tx_fault; - int addr_tx_power; int page_tx_power; int offset_tx_power; int length_tx_power; - int addr_vendor_name; int page_vendor_name; int offset_vendor_name; int length_vendor_name; - int addr_vendor_pn; int page_vendor_pn; int offset_vendor_pn; int length_vendor_pn; - int addr_vendor_rev; int page_vendor_rev; int offset_vendor_rev; int length_vendor_rev; - int addr_vendor_sn; int page_vendor_sn; int offset_vendor_sn; int length_vendor_sn; - int addr_voltage; int page_voltage; int offset_voltage; int length_voltage; - int addr_wavelength; int page_wavelength; int offset_wavelength; int length_wavelength; -}; - - -struct transvr_worker_s; - -/* Class of transceiver object */ -struct transvr_obj_s { - - /* ========== Object private property ========== - * [Prop]: id - * [Desc]: Type of serial transceiver. - * [Note]: SFP:03h / QSFP:0Ch / QSPF+:0Dh /QSFP28:11h - */ - uint8_t id; - - /* [Prop]: connector - * [Desc]: Connector type. - * [Note]: SFP : A0h / 2 - * QSFP: 00h / 130 - */ - uint8_t connector; - - /* [Prop]: transvr_comp - * [Desc]: Transceiver compliance code. - * [Note]: SFP: SFF-8472 - * - Normal : A0h / offset 3-10 - * - Extended: A0h / offset 36 - * QSFP: SFF-8436 & SFF-8636 - * - Normal : 00h / offset 131-138 - * - Extended: 00h / offset 192 - */ - uint8_t transvr_comp[8]; - uint8_t transvr_comp_ext; - - /* [Prop]: vendor_name - * [Desc]: SFP vendor name (ASCII 16 byte char). - * [Note]: ex:FINISAR CORP. - */ - char *vendor_name; - - /* [Prop]: vendor_pn - * [Desc]: Part number provided by SFP vendor (ASCII 16 byte char). - * [Note]: - */ - char *vendor_pn; - - /* [Prop]: vendor_rev - * [Desc]: Revision level for part number provided by vendor (ASCII 4 byte char). - * [Note]: - */ - char *vendor_rev; - - /* [Prop]: vendor_sn - * [Desc]: Serial number provided by vendor (ASCII 16 byte char). - * [Note]: - */ - char *vendor_sn; - - /* [Prop]: Extended identifier - * [Desc]: SFP: - * => None - * - * QSFP: - * => This byte contained two information: - * (1) Power consumption class - * (2) CDR function present - * [Note]: Bit description as below: - * [SFP] - * None - * - * [QSFP] - * (1) Power consumption class: - * Class 1: 1.5W (Bit6-7 = 00:) - * Class 2: 2.0W (Bit6-7 = 01:) - * Class 3: 2.5W (Bit6-7 = 10:) - * Class 4: 3.5W (Bit6-7 = 11:) - * Class 5: 4.0W (Bit0-1 = 01:) - * Class 6: 4.5W (Bit0-1 = 10:) - * Class 7: 5.0W (Bit0-1 = 11:) - * (2) CDR function present: - * Bit2: 0 = No CDR in RX - * 1 = CDR present in RX - * Bit3: 0 = No CDR in TX - * 1 = CDR present in TX - */ - uint8_t ext_id; - - /* [Prop]: br - * [Desc]: Nominal bit rate, units of 100 MBits/sec. - * [Note]: SFP:03h / QSFP:0Ch / QSPF+:0Dh - * has val: 0x67 - * no val : - */ - uint8_t br; - - /* [Prop]: extbr - * [Desc]: Extended br (00h/222) - * [Desc]: Nominal bit rate per channel, units of 250 Mbps. - * Complements. Byte 140. See Table 32A. - */ - uint8_t extbr; - - /* [Prop]: len_sm - * [Desc]: Length (single mode)-(100's)m - * [Note]: This value specifies the link length that is supported by the transceiver - * while operating in compliance with the applicable standards using single mode - * fiber. The value is in units of 100 meters. A value of 255 means that the - * transceiver supports a link length greater than 25.4 km. A value of zero means - * that the transceiver does not support single mode fiber or that the length - * information must be determined from the transceiver technology. - */ - int len_sm; - - /* [Prop]: len_smf - * [Desc]: Length (single mode)-km - * [Note]: Addition to EEPROM data from original GBIC definition. This value specifies - * the link length that is supported by the transceiver while operating in - * compliance with the applicable standards using single mode fiber. The value - * is in units of kilometers. A value of 255 means that the transceiver supports - * a link length greater than 254 km. A value of zero means that the transceiver - * does not support single mode fiber or that the length information must be - * determined from the transceiver technology. - */ - int len_smf; - - /* [Prop]: len_om1 - * [Desc]: Link length supported for 62.5 um OM1 fiber, units of 10 m - * [Note]: The value is in units of 10 meters. A value of 255 means that the - * transceiver supports a link length greater than 2.54 km. A value of - * zero means that the transceiver does not support 50 micron multi-mode - * fiber or that the length information must be determined from the transceiver - * technology. - */ - int len_om1; - - /* [Prop]: len_om2 - * [Desc]: Link length supported for 50 um OM2 fiber, units of 10 m - * [Note]: The value is in units of 10 meters. A value of 255 means that the - * transceiver supports a link length greater than 2.54 km. A value of - * zero means that the transceiver does not support 50 micron multi-mode - * fiber or that the length information must be determined from the transceiver - * technology. - */ - int len_om2; - - /* [Prop]: len_om3 - * [Desc]: Length (50um, OM3) - * [Note]: This value specifies link length that is supported by the transceiver while - * operating in compliance with applicable standards using 50 micron multimode - * OM3 [2000 MHz*km] fiber. The value is in units of 10 meters. A value of 255 - * means that the transceiver supports a link length greater than 2.54 km. A value - * of zero means that the transceiver does not support 50 micron multimode fiber - * or that the length information must be determined from the transceiver technology. - */ - int len_om3; - - /* [Prop]: len_om4 - * [Desc]: Length (50um, OM4) and Length (Active Cable or Copper) - * [Note]: For optical links, this value specifies link length that is supported by the - * transceiver while operating in compliance with applicable standards using 50 micron - * multimode OM4 [4700 MHz*km] fiber. The value is in units of 10 meters. A value of - * 255 means that the transceiver supports a link length greater than 2.54 km. A value - * of zero means that the transceiver does not support 50 micron multimode fiber or that - * the length information must be determined from the transceiver codes specified in Table 5-3. - * - * For copper links, this value specifies minimum link length supported by the transceiver - * while operating in compliance with applicable standards using copper cable. For active - * cable, this value represents actual length. The value is in units of 1 meter. A value of 255 - * means the transceiver supports a link length greater than 254 meters. A value of zero means - * the transceiver does not support copper or active cables or the length information must be - * determined from transceiver technology. Further information about cable design, equalization, - * and connectors is usually required to guarantee meeting a particular length requirement. - */ - int len_om4; - - /* [Prop]: comp_rev - * [Desc]: SFF spec revision compliance - * [Note]: Indicates which revision of SFF SFF-8472 (SFP) / SFF-8636 (QSFP) the transceiver - * complies with. (unsigned integer) - */ - uint8_t comp_rev; - - /* [Prop]: CDR - * [Desc]: For transceivers with CDR capability, setting the CDR to ON engages the internal - * retiming function. Setting the CDR to OFF enables an internal bypassing mode ,which - * directs traffic around the internal CDR. (Reference: SFF-8636) - * [Note]: value=0xff: ON. - * value=0x00: OFF. - */ - uint8_t cdr; - - /* [Prop]: rate_id - * [Desc]: Soft Rate Select 0(RX). - * [Note]: 1. Addr: A0h / Offset: 13 - * 2. Value description: - * 00h Unspecified - * 01h SFF-8079 (4/2/1G Rate_Select & AS0/AS1) - * 02h SFF-8431 (8/4/2G Rx Rate_Select only) - * 03h Unspecified * - * 04h SFF-8431 (8/4/2G Tx Rate_Select only) - * 05h Unspecified * - * 06h SFF-8431 (8/4/2G Independent Rx & Tx Rate_select) - * 07h Unspecified * - * 08h FC-PI-5 (16/8/4G Rx Rate_select only) High=16G only, Low=8G/4G - * 09h Unspecified * - * 0Ah FC-PI-5 (16/8/4G Independent Rx, Tx Rate_select) High=16G only, - * Low=8G/4G - * 0Bh Unspecified * - * 0Ch FC-PI-6 (32/16/8G Independent Rx, Tx Rate_Select) - * High=32G only, Low = 16G/8G - * 0Dh Unspecified * - * 0Eh 10/8G Rx and Tx Rate_Select controlling the operation or locking - * modes of the internal signal conditioner, retimer or CDR, according - * to the logic table defined in Table 10-2, High Bit Rate - * (10G) =9.95-11.3 Gb/s; Low Bit Rate (8G) = 8.5 Gb/s. In this mode, - * the default value of bit 110.3 (Soft Rate Select RS(0), Table 9-11) - * and of bit 118.3 (Soft Rate Select RS(1), Table 10-1) is 1. - * 0Fh Unspecified * - * 10h-FFh Unallocated - */ - int rate_id; - - /* [Prop]: soft_rs0 - * [Desc]: Soft Rate Select 0(RX). - * [Note]: 1. Writing '1' selects full bandwidth operation. - * 2. This bit is "OR'd with the hard Rate_Select, AS(0) or RS(0) pin value. - * 3. Default at power up is logic zero/low - * 4. Addr: A2h / Offset: 110 / Bit: 3 - */ - uint8_t soft_rs0; - - /* [Prop]: soft_rs1 - * [Desc]: Soft Rate Select 1(TX). - * [Note]: 1. Writing '1' selects full bandwidth TX operation. - * 2. This bit is "OR'd with the hard Rate_Select, AS(1) or RS(1) pin value. - * 3. Default at power up is logic zero/low - * 4. Addr: A2h / Offset: 118 / Bit: 3 - */ - uint8_t soft_rs1; - - /* [Prop]: diag_type - * [Desc]: DIAGNOSTIC MONITORING TYPE (A0h/92) - * [Note]: Description in SFF-8472 as below: - * Bit7: Reserved for legacy diagnostic implementations. Must be '0' for compliance - * with this document. - * Bit6: Digital diagnostic monitoring implemented (described in this document). - * Must be '1' for compliance with this document. - * Bit5 Internally calibrated - * Bit4 Externally calibrated - * Bit3 Received power measurement type.0 = OMA, 1 = average power - * Bit2 Address change required see section above, "addressing modes" - * Bit1-0 Unallocated - */ - uint8_t diag_type; - - /* [Prop]: curr_temp - * [Desc]: Transceiver Current Temperature (A2h/96-97) - * [Note]: 1. Dependent on diag_type. - * 2. 96: High byte - * 3. 97: Low byte - * 4. This feature only for SFP - */ - uint8_t curr_temp[2]; - - /* [Prop]: curr_vol - * [Desc]: Transceiver Current Voltage (SFP:A2h/108-109; QSFP:00h/22-23) - * [Note]: 1. Dependent on diag_type. - * 2. 98: High byte - * 3. 99: Low byte - * 4. This feature only for SFP - * 5. Internally measured transceiver supply voltage. Represented - * as a 16 bit unsigned integer with the voltage defined as the - * full 16 bit value (0-65535) with LSB equal to 100 uVolt, - * yielding a total range of 0 to +6.55 Volts - */ - uint8_t curr_voltage[2]; - - /* [Prop]: curr_tx_bias - * [Desc]: Transceiver TX Bias Current (SFP:A2h/100-101; QSFP:00h/26-27) - * [Note]: 1. Dependent on diag_type. - * 2. 100: High byte - * 3. 101: Low byte - * 4. This feature only for SFP - * 5. Measured TX bias current in uA. Represented as a 16 bit unsigned - * integer with the current defined as the full 16 bit value (0-65535) - * with LSB equal to 2 uA, yielding a total range of 0 to 131 mA. - * Accuracy is vendor specific but must be better than 10% of the - * manufacturer's nominal value over specified operating temperature - * and voltage. - */ - uint8_t curr_tx_bias[8]; - - /* [Prop]: curr_tx_power - * [Desc]: Transceiver TX Output Power (A2h/102-103) - * [Note]: 1. Dependent on diag_type. - * 2. 102: High byte - * 3. 103: Low byte - * 4. This feature only for SFP - * 5. Measured TX output power in mW. Represented as a 16 bit unsigned - * integer with the power defined as the full 16 bit value (0-65535) - * with LSB equal to 0.1 uW, yielding a total range of 0 to 6.5535 mW - * (~ -40 to +8.2 dBm). Data is assumed to be based on measurement of - * laser monitor photodiode current. It is factory calibrated to absolute - * units using the most representative fiber output type. Accuracy is - * vendor specific but must be better than 3dB over specified temperature - * and voltage. Data is not valid when the transmitter is disabled. - */ - uint8_t curr_tx_power[8]; - - /* [Prop]: curr_tx_power - * [Desc]: Transceiver TX Output Power (A2h/102-103) - * [Note]: 1. Dependent on diag_type. - * 2. 102: High byte - * 3. 103: Low byte - * 4. This feature only for SFP - * 5. Measured RX received optical power in mW. Value can represent either - * average received power or OMA depending upon how bit 3 of byte 92 (A0h) - * is set. Represented as a 16 bit unsigned integer with the power defined - * as the full 16 bit value (0-65535) with LSB equal to 0.1 uW, yielding a - * total range of 0 to 6.5535 mW (~ -40 to +8.2 dBm). Absolute accuracy is - * dependent upon the exact optical wavelength. For the vendor specified - * wavelength, accuracy shall be better than 3dB over specified temperature - * and voltage. - */ - uint8_t curr_rx_power[8]; - - /* [Prop]: wavelength - * [Desc]: Wavelength or Copper Cable Attenuation - * [Note]: (Following is info from SFF-8636) - * For optical free side devices, this parameter identifies the nominal - * transmitter output wavelength at room temperature. This parameter is a - * 16-bit hex value with Byte 186 as high order byte and Byte 187 as low - * order byte. The laser wavelength is equal to the 16-bit integer value - * divided by 20 in nm (units of 0.05 nm). This resolution should be adequate - * to cover all relevant wavelengths yet provide enough resolution for all - * expected DWDM applications. For accurate representation of controlled - * wavelength applications, this value should represent the center of the - * guaranteed wavelength range. If the free side device is identified as - * copper cable these registers will be used to define the cable attenuation. - * An indication of 0 dB attenuation refers to the case where the attenuation - * is not known or is unavailable. - * Byte 186 (00-FFh) is the copper cable attenuation at 2.5 GHz in units of 1 dB. - * Byte 187 (00-FFh) is the copper cable attenuation at 5.0 GHz in units of 1 dB. - */ - uint8_t wavelength[2]; - - /* [Prop]: Amplitude control - * [Desc]: Amplitude control - * [Note]: QSFP28 => SFF-8636 03H Byte-238/239 - */ - uint8_t rx_am[2]; - - /* [Prop]: Emphasis control - * [Desc]: Emphasis control - * [Note]: SFP+/28 => SFF-8472 A2H Byte-115 - * QSFP28 => SFF-8636 03H Byte-236/237 - */ - uint8_t rx_em[2]; - - /* [Prop]: Soft Rx LOS - * [Desc]: Soft Rx LOS which provide by transceiver - * [Note]: (Following is info from SFF-8636) - * Byte 3: - * - Bit 0: L-Rx1 LOS - * - Bit 1: L-Rx2 LOS - * - Bit 2: L-Rx3 LOS - * - Bit 3: L-Rx4 LOS - */ - uint8_t rx_los; - - /* [Prop]: Soft Tx Disable - * [Desc]: Soft Tx Disable which provide by transceiver - * [Note]: (Following is info from SFF-8636) - * Byte 86: - * - Bit 0: Tx1 Disable - * - Bit 1: Tx2 Disable - * - Bit 2: Tx3 Disable - * - Bit 3: Tx4 Disable - */ - uint8_t tx_disable; - - /* [Prop]: Soft Tx Fault - * [Desc]: Soft Tx Fault which provide by transceiver - * [Note]: (Following is info from SFF-8636) - * Byte 86: - * - Bit 0: Tx1 Fault - * - Bit 1: Tx2 Fault - * - Bit 2: Tx3 Fault - * - Bit 3: Tx4 Fault - */ - uint8_t tx_fault; - - /* [Prop]: Transceiver EQUALIZATION - * [Desc]: Transceiver EQUALIZATION - * [Note]: SFP+/28 => SFF-8472 A2H Byte-114 - * QSFP28 => SFF-8636 03H Byte-234/235 - */ - uint8_t tx_eq[2]; - - /* [Prop]: OPTION VALUES - * [Desc]: The bits in the option field shall specify the options implemented in the transceiver. - * [Note]: SFP+/28 => SFF-8472 A0H Byte-64/65 - * QSFP+/28 => SFF-8636 00H Byte-193/195 - */ - uint8_t option[3]; - - /* [Prop]: External PHY offset - * [Desc]: It needs to be setup first if you want to access transceiver external phy. - * [Note]: This feature dependent on transceiver. - * Currently, only 1G-RJ45 transceiver supported it. - */ - uint8_t extphy_offset; - - uint8_t eeprom[256]; - uint8_t eeprom_update[8]; - int port_no; - - /* ========== Object private property ========== - */ - struct device *transvr_dev_p; - struct eeprom_map_s *eeprom_map_p; - struct i2c_client *i2c_client_p; - struct ioexp_obj_s *ioexp_obj_p; - struct transvr_worker_s *worker_p; - struct mutex lock; - char swp_name[32]; - int auto_config; - int auto_tx_disable; - int chan_id; - int chipset_type; - int curr_page; - int info; - int ioexp_virt_offset; - int lane_id[8]; - int layout; - int mode; - int retry; - int state; - int temp; - int type; - - /* ========== Object public functions ========== - */ - int (*get_id)(struct transvr_obj_s *self); - int (*get_eeprom)(struct transvr_obj_s *self, char *buf_p); - int (*get_ext_id)(struct transvr_obj_s *self); - int (*get_connector)(struct transvr_obj_s *self); - int (*get_vendor_name)(struct transvr_obj_s *self, char *buf_p); - int (*get_vendor_pn)(struct transvr_obj_s *self, char *buf_p); - int (*get_vendor_rev)(struct transvr_obj_s *self, char *buf_p); - int (*get_vendor_sn)(struct transvr_obj_s *self, char *buf_p); - int (*get_power_cls)(struct transvr_obj_s *self); - int (*get_br)(struct transvr_obj_s *self); - int (*get_len_sm)(struct transvr_obj_s *self); - int (*get_len_smf)(struct transvr_obj_s *self); - int (*get_len_om1)(struct transvr_obj_s *self); - int (*get_len_om2)(struct transvr_obj_s *self); - int (*get_len_om3)(struct transvr_obj_s *self); - int (*get_len_om4)(struct transvr_obj_s *self); - int (*get_comp_rev)(struct transvr_obj_s *self); - int (*get_comp_eth_1)(struct transvr_obj_s *self); - int (*get_comp_eth_10)(struct transvr_obj_s *self); - int (*get_comp_eth_10_40)(struct transvr_obj_s *self); - int (*get_comp_extend)(struct transvr_obj_s *self); - int (*get_cdr)(struct transvr_obj_s *self); - int (*get_rate_id)(struct transvr_obj_s *self); - int (*get_soft_rs0)(struct transvr_obj_s *self); - int (*get_soft_rs1)(struct transvr_obj_s *self); - int (*get_info)(struct transvr_obj_s *self); - int (*get_if_type)(struct transvr_obj_s *self, char *buf_p); - int (*get_if_speed)(struct transvr_obj_s *self, char *buf_p); - int (*get_if_lane)(struct transvr_obj_s *self, char *buf_p); - int (*get_curr_temp)(struct transvr_obj_s *self, char *buf_p); - int (*get_curr_vol)(struct transvr_obj_s *self, char *buf_p); - int (*get_soft_rx_los)(struct transvr_obj_s *self, char *buf_p); - int (*get_soft_tx_disable)(struct transvr_obj_s *self, char *buf_p); - int (*get_soft_tx_fault)(struct transvr_obj_s *self, char *buf_p); - int (*get_auto_tx_disable)(struct transvr_obj_s *self, char *buf_p); - int (*get_tx_bias)(struct transvr_obj_s *self, char *buf_p); - int (*get_tx_power)(struct transvr_obj_s *self, char *buf_p); - int (*get_rx_power)(struct transvr_obj_s *self, char *buf_p); - int (*get_tx_eq)(struct transvr_obj_s *self, char *buf_p); - int (*get_rx_am)(struct transvr_obj_s *self, char *buf_p); - int (*get_rx_em)(struct transvr_obj_s *self, char *buf_p); - int (*get_wavelength)(struct transvr_obj_s *self, char *buf_p); - int (*get_extphy_offset)(struct transvr_obj_s *self, char *buf_p); - int (*get_extphy_reg)(struct transvr_obj_s *self, char *buf_p); - int (*set_cdr)(struct transvr_obj_s *self, int input_val); - int (*set_soft_rs0)(struct transvr_obj_s *self, int input_val); - int (*set_soft_rs1)(struct transvr_obj_s *self, int input_val); - int (*set_soft_tx_disable)(struct transvr_obj_s *self, int input_val); - int (*set_auto_tx_disable)(struct transvr_obj_s *self, int input_val); - int (*set_tx_eq)(struct transvr_obj_s *self, int input_val); - int (*set_rx_am)(struct transvr_obj_s *self, int input_val); - int (*set_rx_em)(struct transvr_obj_s *self, int input_val); - int (*set_extphy_offset)(struct transvr_obj_s *self, int input_val); - int (*set_extphy_reg)(struct transvr_obj_s *self, int input_val); - - /* ========== Object private functions ========== - */ - int (*init)(struct transvr_obj_s *self); - int (*clean)(struct transvr_obj_s *self); - int (*check)(struct transvr_obj_s *self); - int (*update_all)(struct transvr_obj_s *self, int show_err); - int (*fsm_4_direct)(struct transvr_obj_s* self, char *caller_name); - int (*fsm_4_polling)(struct transvr_obj_s* self, char *caller_name); - int (*send_uevent)(struct transvr_obj_s* self, enum kobject_action u_action); - int (*dump_all)(struct transvr_obj_s* self); -}; - - -/* For AVL Mapping */ -struct transvr_avl_s { - char vendor_name[32]; - char vendor_pn[32]; - int (*init)(struct transvr_obj_s *self); -}; - - -/* Worker for long term task of transceiver */ -struct transvr_worker_s { - /* Task Parameter */ - struct transvr_obj_s *transvr_p; - struct transvr_worker_s *next_p; - struct transvr_worker_s *pre_p; - unsigned long trigger_time; - char func_name[64]; - int retry; - int state; - - /* Task private data */ - void *p_data; - - /* Call back function */ - int (*main_task)(struct transvr_worker_s *task); - int (*post_task)(struct transvr_worker_s *task); -}; - - -struct transvr_obj_s * -create_transvr_obj(char *swp_name, - int chan_id, - struct ioexp_obj_s *ioexp_obj_p, - int ioexp_virt_offset, - int transvr_type, - int chipset_type, - int run_mode); - -void lock_transvr_obj(struct transvr_obj_s *self); -void unlock_transvr_obj(struct transvr_obj_s *self); -int isolate_transvr_obj(struct transvr_obj_s *self); - -int resync_channel_tier_2(struct transvr_obj_s *self); - -void alarm_msg_2_user(struct transvr_obj_s *self, char *emsg); - -unsigned char *get_eeprom_update(void); -void set_eeprom_update(unsigned char value[8]); - -#endif /* TRANSCEIVER_H */ diff --git a/packages/platforms/inventec/x86-64/d6556/onlp/Makefile b/packages/platforms/inventec/x86-64/d6556/onlp/Makefile deleted file mode 100644 index 003238cf6..000000000 --- a/packages/platforms/inventec/x86-64/d6556/onlp/Makefile +++ /dev/null @@ -1 +0,0 @@ -include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/inventec/x86-64/d6556/onlp/PKG.yml b/packages/platforms/inventec/x86-64/d6556/onlp/PKG.yml deleted file mode 100644 index 054795028..000000000 --- a/packages/platforms/inventec/x86-64/d6556/onlp/PKG.yml +++ /dev/null @@ -1 +0,0 @@ -!include $ONL_TEMPLATES/onlp-platform-any.yml PLATFORM=x86-64-inventec-d6556 ARCH=amd64 TOOLCHAIN=x86_64-linux-gnu diff --git a/packages/platforms/inventec/x86-64/d6556/onlp/builds/.gitignore b/packages/platforms/inventec/x86-64/d6556/onlp/builds/.gitignore deleted file mode 100644 index 41488d345..000000000 --- a/packages/platforms/inventec/x86-64/d6556/onlp/builds/.gitignore +++ /dev/null @@ -1 +0,0 @@ -x86_64_inventec_d6556.mk diff --git a/packages/platforms/inventec/x86-64/d6556/onlp/builds/Makefile b/packages/platforms/inventec/x86-64/d6556/onlp/builds/Makefile deleted file mode 100644 index e7437cb23..000000000 --- a/packages/platforms/inventec/x86-64/d6556/onlp/builds/Makefile +++ /dev/null @@ -1,2 +0,0 @@ -FILTER=src -include $(ONL)/make/subdirs.mk diff --git a/packages/platforms/inventec/x86-64/d6556/onlp/builds/lib/Makefile b/packages/platforms/inventec/x86-64/d6556/onlp/builds/lib/Makefile deleted file mode 100644 index a4d4ff073..000000000 --- a/packages/platforms/inventec/x86-64/d6556/onlp/builds/lib/Makefile +++ /dev/null @@ -1,2 +0,0 @@ -PLATFORM := x86-64-inventec-d6556 -include $(ONL)/packages/base/any/onlp/builds/platform/libonlp-platform.mk diff --git a/packages/platforms/inventec/x86-64/d6556/onlp/builds/onlpdump/Makefile b/packages/platforms/inventec/x86-64/d6556/onlp/builds/onlpdump/Makefile deleted file mode 100644 index a0acc5c80..000000000 --- a/packages/platforms/inventec/x86-64/d6556/onlp/builds/onlpdump/Makefile +++ /dev/null @@ -1,2 +0,0 @@ -PLATFORM := x86-64-inventec-d6556 -include $(ONL)/packages/base/any/onlp/builds/platform/onlps.mk diff --git a/packages/platforms/inventec/x86-64/d6556/onlp/builds/onlpdump/onlpdump.mk b/packages/platforms/inventec/x86-64/d6556/onlp/builds/onlpdump/onlpdump.mk deleted file mode 100644 index 38ffcbdb3..000000000 --- a/packages/platforms/inventec/x86-64/d6556/onlp/builds/onlpdump/onlpdump.mk +++ /dev/null @@ -1,10 +0,0 @@ - -############################################################################### -# -# Inclusive Makefile for the onlpdump module. -# -# Autogenerated 2018-11-30 07:22:10.961262 -# -############################################################################### -onlpdump_BASEDIR := $(dir $(abspath $(lastword $(MAKEFILE_LIST)))) - diff --git a/packages/platforms/inventec/x86-64/d6556/onlp/builds/x86_64_inventec_d6556/.module b/packages/platforms/inventec/x86-64/d6556/onlp/builds/x86_64_inventec_d6556/.module deleted file mode 100644 index 63419b7be..000000000 --- a/packages/platforms/inventec/x86-64/d6556/onlp/builds/x86_64_inventec_d6556/.module +++ /dev/null @@ -1 +0,0 @@ -name: x86_64_inventec_d6556 diff --git a/packages/platforms/inventec/x86-64/d6556/onlp/builds/x86_64_inventec_d6556/Makefile b/packages/platforms/inventec/x86-64/d6556/onlp/builds/x86_64_inventec_d6556/Makefile deleted file mode 100644 index fa1a27aa2..000000000 --- a/packages/platforms/inventec/x86-64/d6556/onlp/builds/x86_64_inventec_d6556/Makefile +++ /dev/null @@ -1,9 +0,0 @@ -############################################################################### -# -# -# -############################################################################### -include $(ONL)/make/config.mk -MODULE := x86_64_inventec_d6556 -AUTOMODULE := x86_64_inventec_d6556 -include $(BUILDER)/definemodule.mk diff --git a/packages/platforms/inventec/x86-64/d6556/onlp/builds/x86_64_inventec_d6556/module/auto/make.mk b/packages/platforms/inventec/x86-64/d6556/onlp/builds/x86_64_inventec_d6556/module/auto/make.mk deleted file mode 100644 index 5daed4d0e..000000000 --- a/packages/platforms/inventec/x86-64/d6556/onlp/builds/x86_64_inventec_d6556/module/auto/make.mk +++ /dev/null @@ -1,9 +0,0 @@ -############################################################################### -# -# x86_64_inventec_d6556 Autogeneration -# -############################################################################### -x86_64_inventec_d6556_AUTO_DEFS := module/auto/x86_64_inventec_d6556.yml -x86_64_inventec_d6556_AUTO_DIRS := module/inc/x86_64_inventec_d6556 module/src -include $(BUILDER)/auto.mk - diff --git a/packages/platforms/inventec/x86-64/d6556/onlp/builds/x86_64_inventec_d6556/module/auto/x86_64_inventec_d6556.yml b/packages/platforms/inventec/x86-64/d6556/onlp/builds/x86_64_inventec_d6556/module/auto/x86_64_inventec_d6556.yml deleted file mode 100644 index 6f5af33b3..000000000 --- a/packages/platforms/inventec/x86-64/d6556/onlp/builds/x86_64_inventec_d6556/module/auto/x86_64_inventec_d6556.yml +++ /dev/null @@ -1,50 +0,0 @@ -############################################################################### -# -# x86_64_inventec_d6556 Autogeneration Definitions. -# -############################################################################### - -cdefs: &cdefs -- X86_64_INVENTEC_D6556_CONFIG_INCLUDE_LOGGING: - doc: "Include or exclude logging." - default: 1 -- X86_64_INVENTEC_D6556_CONFIG_LOG_OPTIONS_DEFAULT: - doc: "Default enabled log options." - default: AIM_LOG_OPTIONS_DEFAULT -- X86_64_INVENTEC_D6556_CONFIG_LOG_BITS_DEFAULT: - doc: "Default enabled log bits." - default: AIM_LOG_BITS_DEFAULT -- X86_64_INVENTEC_D6556_CONFIG_LOG_CUSTOM_BITS_DEFAULT: - doc: "Default enabled custom log bits." - default: 0 -- X86_64_INVENTEC_D6556_CONFIG_PORTING_STDLIB: - doc: "Default all porting macros to use the C standard libraries." - default: 1 -- X86_64_INVENTEC_D6556_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS: - doc: "Include standard library headers for stdlib porting macros." - default: X86_64_INVENTEC_D6556_CONFIG_PORTING_STDLIB -- X86_64_INVENTEC_D6556_CONFIG_INCLUDE_UCLI: - doc: "Include generic uCli support." - default: 0 -- X86_64_INVENTEC_D6556_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_D6556_CONFIG_HEADER: - defs: *cdefs - basename: X86_64_INVENTEC_D6556_config - - portingmacro: - X86_64_INVENTEC_d6556: - macros: - - malloc - - free - - memset - - memcpy - - - vsnprintf - - snprintf - - strlen diff --git a/packages/platforms/inventec/x86-64/d6556/onlp/builds/x86_64_inventec_d6556/module/inc/x86_64_inventec_d6556/x86_64_inventec_d6556.x b/packages/platforms/inventec/x86-64/d6556/onlp/builds/x86_64_inventec_d6556/module/inc/x86_64_inventec_d6556/x86_64_inventec_d6556.x deleted file mode 100644 index 311d0e488..000000000 --- a/packages/platforms/inventec/x86-64/d6556/onlp/builds/x86_64_inventec_d6556/module/inc/x86_64_inventec_d6556/x86_64_inventec_d6556.x +++ /dev/null @@ -1,14 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#include - -/* <--auto.start.xmacro(ALL).define> */ -/* */ - -/* <--auto.start.xenum(ALL).define> */ -/* */ - - diff --git a/packages/platforms/inventec/x86-64/d6556/onlp/builds/x86_64_inventec_d6556/module/inc/x86_64_inventec_d6556/x86_64_inventec_d6556_config.h b/packages/platforms/inventec/x86-64/d6556/onlp/builds/x86_64_inventec_d6556/module/inc/x86_64_inventec_d6556/x86_64_inventec_d6556_config.h deleted file mode 100644 index 4f71b165c..000000000 --- a/packages/platforms/inventec/x86-64/d6556/onlp/builds/x86_64_inventec_d6556/module/inc/x86_64_inventec_d6556/x86_64_inventec_d6556_config.h +++ /dev/null @@ -1,137 +0,0 @@ -/**************************************************************************//** - * - * @file - * @brief x86_64_inventec_d6556 Configuration Header - * - * @addtogroup x86_64_inventec_d6556-config - * @{ - * - *****************************************************************************/ -#ifndef __x86_64_inventec_d6556_CONFIG_H__ -#define __x86_64_inventec_d6556_CONFIG_H__ - -#ifdef GLOBAL_INCLUDE_CUSTOM_CONFIG -#include -#endif -#ifdef x86_64_inventec_d6556_INCLUDE_CUSTOM_CONFIG -#include -#endif - -/* */ -#include -/** - * X86_64_INVENTEC_D6556_CONFIG_INCLUDE_LOGGING - * - * Include or exclude logging. */ - - -#ifndef X86_64_INVENTEC_D6556_CONFIG_INCLUDE_LOGGING -#define X86_64_INVENTEC_D6556_CONFIG_INCLUDE_LOGGING 1 -#endif - -/** - * X86_64_INVENTEC_D6556_CONFIG_LOG_OPTIONS_DEFAULT - * - * Default enabled log options. */ - - -#ifndef X86_64_INVENTEC_D6556_CONFIG_LOG_OPTIONS_DEFAULT -#define X86_64_INVENTEC_D6556_CONFIG_LOG_OPTIONS_DEFAULT AIM_LOG_OPTIONS_DEFAULT -#endif - -/** - * X86_64_INVENTEC_D6556_CONFIG_LOG_BITS_DEFAULT - * - * Default enabled log bits. */ - - -#ifndef X86_64_INVENTEC_D6556_CONFIG_LOG_BITS_DEFAULT -#define X86_64_INVENTEC_D6556_CONFIG_LOG_BITS_DEFAULT AIM_LOG_BITS_DEFAULT -#endif - -/** - * X86_64_INVENTEC_D6556_CONFIG_LOG_CUSTOM_BITS_DEFAULT - * - * Default enabled custom log bits. */ - - -#ifndef X86_64_INVENTEC_D6556_CONFIG_LOG_CUSTOM_BITS_DEFAULT -#define X86_64_INVENTEC_D6556_CONFIG_LOG_CUSTOM_BITS_DEFAULT 0 -#endif - -/** - * X86_64_INVENTEC_D6556_CONFIG_PORTING_STDLIB - * - * Default all porting macros to use the C standard libraries. */ - - -#ifndef X86_64_INVENTEC_D6556_CONFIG_PORTING_STDLIB -#define X86_64_INVENTEC_D6556_CONFIG_PORTING_STDLIB 1 -#endif - -/** - * X86_64_INVENTEC_D6556_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS - * - * Include standard library headers for stdlib porting macros. */ - - -#ifndef X86_64_INVENTEC_D6556_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS -#define X86_64_INVENTEC_D6556_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS X86_64_INVENTEC_D6556_CONFIG_PORTING_STDLIB -#endif - -/** - * X86_64_INVENTEC_D6556_CONFIG_INCLUDE_UCLI - * - * Include generic uCli support. */ - - -#ifndef X86_64_INVENTEC_D6556_CONFIG_INCLUDE_UCLI -#define X86_64_INVENTEC_D6556_CONFIG_INCLUDE_UCLI 0 -#endif - -/** - * X86_64_INVENTEC_D6556_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION - * - * Assume chassis fan direction is the same as the PSU fan direction. */ - - -#ifndef X86_64_INVENTEC_D6556_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION -#define X86_64_INVENTEC_D6556_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION 0 -#endif - - - -/** - * All compile time options can be queried or displayed - */ - -/** Configuration settings structure. */ -typedef struct X86_64_INVENTEC_D6556_config_settings_s { - /** name */ - const char* name; - /** value */ - const char* value; -} X86_64_INVENTEC_D6556_config_settings_t; - -/** Configuration settings table. */ -/** X86_64_INVENTEC_D6556_config_settings table. */ -extern X86_64_INVENTEC_D6556_config_settings_t X86_64_INVENTEC_D6556_config_settings[]; - -/** - * @brief Lookup a configuration setting. - * @param setting The name of the configuration option to lookup. - */ -const char* _x86_64__i_n_v_e_n_t_e_c__d6556_config_lookup(const char* setting); - -/** - * @brief Show the compile-time configuration. - * @param pvs The output stream. - */ -int _x86_64__i_n_v_e_n_t_e_c__d6556_config_show(struct aim_pvs_s* pvs); - -/* */ - -#include "x86_64_inventec_d6556_porting.h" - -#endif /* __x86_64_inventec_d6556_CONFIG_H__ */ -/* @} */ diff --git a/packages/platforms/inventec/x86-64/d6556/onlp/builds/x86_64_inventec_d6556/module/inc/x86_64_inventec_d6556/x86_64_inventec_d6556_dox.h b/packages/platforms/inventec/x86-64/d6556/onlp/builds/x86_64_inventec_d6556/module/inc/x86_64_inventec_d6556/x86_64_inventec_d6556_dox.h deleted file mode 100644 index ce8411db2..000000000 --- a/packages/platforms/inventec/x86-64/d6556/onlp/builds/x86_64_inventec_d6556/module/inc/x86_64_inventec_d6556/x86_64_inventec_d6556_dox.h +++ /dev/null @@ -1,26 +0,0 @@ -/**************************************************************************//** - * - * x86_64_inventec_d6556 Doxygen Header - * - *****************************************************************************/ -#ifndef __x86_64_inventec_d6556_DOX_H__ -#define __x86_64_inventec_d6556_DOX_H__ - -/** - * @defgroup x86_64_inventec_d6556 x86_64_inventec_d6556 - x86_64_inventec_d6556 Description - * - -The documentation overview for this module should go here. - - * - * @{ - * - * @defgroup x86_64_inventec_d6556-x86_64_inventec_d6556 Public Interface - * @defgroup x86_64_inventec_d6556-config Compile Time Configuration - * @defgroup x86_64_inventec_d6556-porting Porting Macros - * - * @} - * - */ - -#endif /* __x86_64_inventec_d6556_DOX_H__ */ diff --git a/packages/platforms/inventec/x86-64/d6556/onlp/builds/x86_64_inventec_d6556/module/inc/x86_64_inventec_d6556/x86_64_inventec_d6556_porting.h b/packages/platforms/inventec/x86-64/d6556/onlp/builds/x86_64_inventec_d6556/module/inc/x86_64_inventec_d6556/x86_64_inventec_d6556_porting.h deleted file mode 100644 index 152e598d8..000000000 --- a/packages/platforms/inventec/x86-64/d6556/onlp/builds/x86_64_inventec_d6556/module/inc/x86_64_inventec_d6556/x86_64_inventec_d6556_porting.h +++ /dev/null @@ -1,97 +0,0 @@ -/**************************************************************************//** - * - * @file - * @brief x86_64_inventec_d6556 Porting Macros. - * - * @addtogroup x86_64_inventec_d6556-porting - * @{ - * - *****************************************************************************/ -#ifndef __x86_64_inventec_d6556_PORTING_H__ -#define __x86_64_inventec_d6556_PORTING_H__ - - -/* */ -#if X86_64_INVENTEC_D6556_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS == 1 -#include -#include -#include -#include -#include -#endif - -#ifndef X86_64_INVENTEC_D6556_MALLOC - #if defined(GLOBAL_MALLOC) - #define X86_64_INVENTEC_D6556_MALLOC GLOBAL_MALLOC - #elif X86_64_INVENTEC_D6556_CONFIG_PORTING_STDLIB == 1 - #define X86_64_INVENTEC_D6556_MALLOC malloc - #else - #error The macro X86_64_INVENTEC_D6556_MALLOC is required but cannot be defined. - #endif -#endif - -#ifndef X86_64_INVENTEC_D6556_FREE - #if defined(GLOBAL_FREE) - #define X86_64_INVENTEC_D6556_FREE GLOBAL_FREE - #elif X86_64_INVENTEC_D6556_CONFIG_PORTING_STDLIB == 1 - #define X86_64_INVENTEC_D6556_FREE free - #else - #error The macro X86_64_INVENTEC_D6556_FREE is required but cannot be defined. - #endif -#endif - -#ifndef X86_64_INVENTEC_D6556_MEMSET - #if defined(GLOBAL_MEMSET) - #define X86_64_INVENTEC_D6556_MEMSET GLOBAL_MEMSET - #elif X86_64_INVENTEC_D6556_CONFIG_PORTING_STDLIB == 1 - #define X86_64_INVENTEC_D6556_MEMSET memset - #else - #error The macro X86_64_INVENTEC_D6556_MEMSET is required but cannot be defined. - #endif -#endif - -#ifndef X86_64_INVENTEC_D6556_MEMCPY - #if defined(GLOBAL_MEMCPY) - #define X86_64_INVENTEC_D6556_MEMCPY GLOBAL_MEMCPY - #elif X86_64_INVENTEC_D6556_CONFIG_PORTING_STDLIB == 1 - #define X86_64_INVENTEC_D6556_MEMCPY memcpy - #else - #error The macro X86_64_INVENTEC_D6556_MEMCPY is required but cannot be defined. - #endif -#endif - -#ifndef X86_64_INVENTEC_D6556_VSNPRINTF - #if defined(GLOBAL_VSNPRINTF) - #define X86_64_INVENTEC_D6556_VSNPRINTF GLOBAL_VSNPRINTF - #elif X86_64_INVENTEC_D6556_CONFIG_PORTING_STDLIB == 1 - #define X86_64_INVENTEC_D6556_VSNPRINTF vsnprintf - #else - #error The macro X86_64_INVENTEC_D6556_VSNPRINTF is required but cannot be defined. - #endif -#endif - -#ifndef X86_64_INVENTEC_D6556_SNPRINTF - #if defined(GLOBAL_SNPRINTF) - #define X86_64_INVENTEC_D6556_SNPRINTF GLOBAL_SNPRINTF - #elif X86_64_INVENTEC_D6556_CONFIG_PORTING_STDLIB == 1 - #define X86_64_INVENTEC_D6556_SNPRINTF snprintf - #else - #error The macro X86_64_INVENTEC_D6556_SNPRINTF is required but cannot be defined. - #endif -#endif - -#ifndef X86_64_INVENTEC_D6556_STRLEN - #if defined(GLOBAL_STRLEN) - #define X86_64_INVENTEC_D6556_STRLEN GLOBAL_STRLEN - #elif X86_64_INVENTEC_D6556_CONFIG_PORTING_STDLIB == 1 - #define X86_64_INVENTEC_D6556_STRLEN strlen - #else - #error The macro X86_64_INVENTEC_D6556_STRLEN is required but cannot be defined. - #endif -#endif - -/* */ - - -#endif /* __x86_64_inventec_d6556_PORTING_H__ */ -/* @} */ diff --git a/packages/platforms/inventec/x86-64/d6556/onlp/builds/x86_64_inventec_d6556/module/make.mk b/packages/platforms/inventec/x86-64/d6556/onlp/builds/x86_64_inventec_d6556/module/make.mk deleted file mode 100644 index ccd19207a..000000000 --- a/packages/platforms/inventec/x86-64/d6556/onlp/builds/x86_64_inventec_d6556/module/make.mk +++ /dev/null @@ -1,10 +0,0 @@ -############################################################################### -# -# -# -############################################################################### -THIS_DIR := $(dir $(lastword $(MAKEFILE_LIST))) -x86_64_inventec_d6556_INCLUDES := -I $(THIS_DIR)inc -x86_64_inventec_d6556_INTERNAL_INCLUDES := -I $(THIS_DIR)src -x86_64_inventec_d6556_DEPENDMODULE_ENTRIES := init:x86_64_inventec_d6556 ucli:x86_64_inventec_d6556 - diff --git a/packages/platforms/inventec/x86-64/d6556/onlp/builds/x86_64_inventec_d6556/module/src/Makefile b/packages/platforms/inventec/x86-64/d6556/onlp/builds/x86_64_inventec_d6556/module/src/Makefile deleted file mode 100644 index 2b04d852a..000000000 --- a/packages/platforms/inventec/x86-64/d6556/onlp/builds/x86_64_inventec_d6556/module/src/Makefile +++ /dev/null @@ -1,9 +0,0 @@ -############################################################################### -# -# Local source generation targets. -# -############################################################################### - -ucli: - @../../../../tools/uclihandlers.py x86_64_inventec_d6556_ucli.c - diff --git a/packages/platforms/inventec/x86-64/d6556/onlp/builds/x86_64_inventec_d6556/module/src/debug.c b/packages/platforms/inventec/x86-64/d6556/onlp/builds/x86_64_inventec_d6556/module/src/debug.c deleted file mode 100644 index 2d04002f3..000000000 --- a/packages/platforms/inventec/x86-64/d6556/onlp/builds/x86_64_inventec_d6556/module/src/debug.c +++ /dev/null @@ -1,45 +0,0 @@ -#include "x86_64_inventec_d6556_int.h" - -#if x86_64_inventec_d6556_CONFIG_INCLUDE_DEBUG == 1 - -#include - -static char help__[] = - "Usage: debug [options]\n" - " -c CPLD Versions\n" - " -h Help\n" - ; - -int -x86_64_inventec_d6556_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/d6556/onlp/builds/x86_64_inventec_d6556/module/src/fani.c b/packages/platforms/inventec/x86-64/d6556/onlp/builds/x86_64_inventec_d6556/module/src/fani.c deleted file mode 100644 index c57b23876..000000000 --- a/packages/platforms/inventec/x86-64/d6556/onlp/builds/x86_64_inventec_d6556/module/src/fani.c +++ /dev/null @@ -1,269 +0,0 @@ -/************************************************************ - * fani.c - * - * Copyright 2018 Inventec Technology Corporation. - * - ************************************************************ - * - * Fan Platform Implementation Defaults. - * - ***********************************************************/ -#include -#include -#include -#include -#include -#include "platform_lib.h" - -#define FAN_GPI_ON_MAIN_BOARD INV_PSOC_PREFIX"/fan_gpi" - -#define MAX_FAN_SPEED 18000 -#define MAX_PSU_FAN_SPEED 25500 - -#define PROJECT_NAME -#define LEN_FILE_NAME 80 - -static char* devfiles__[FAN_MAX] = /* must map with onlp_thermal_id */ -{ - "reserved", - INV_PSOC_PREFIX"/fan1_input", - INV_PSOC_PREFIX"/fan2_input", - INV_PSOC_PREFIX"/fan3_input", - INV_PSOC_PREFIX"/fan4_input", - INV_PSOC_PREFIX"/fan5_input", - INV_PSOC_PREFIX"/fan6_input", - INV_PSOC_PREFIX"/fan7_input", - INV_PSOC_PREFIX"/fan8_input", - INV_PSOC_PREFIX"/rpm_psu1", - INV_PSOC_PREFIX"/rpm_psu2", -}; - -#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_F2B | 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_F2B | ONLP_FAN_CAPS_GET_RPM | ONLP_FAN_CAPS_GET_PERCENTAGE), \ - 0, \ - 0, \ - ONLP_FAN_MODE_INVALID, \ - } - -/* Static fan information */ -onlp_fan_info_t linfo[FAN_MAX] = { - { }, /* 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_MAIN_BOARD(7), - MAKE_FAN_INFO_NODE_ON_MAIN_BOARD(8), - 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, FAN_GPI_ON_MAIN_BOARD); - if (ret < 0) { - return ONLP_STATUS_E_INTERNAL; - } - if (value & (1 << (fid-1))) { - info->status |= ONLP_FAN_STATUS_FAILED; - } - else { - info->status |= ONLP_FAN_STATUS_PRESENT; - info->status |= ONLP_FAN_STATUS_F2B; - } - - /* get front fan speed */ - ret = onlp_file_read_int(&value, devfiles__[fid]); - if (ret < 0) { - return ONLP_STATUS_E_INTERNAL; - } - info->rpm = value; - info->percentage = (info->rpm * 100) / MAX_PSU_FAN_SPEED; - - snprintf(info->model, ONLP_CONFIG_INFO_STR_MAX, "NA"); - snprintf(info->serial, ONLP_CONFIG_INFO_STR_MAX, "NA"); - - 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 fid, onlp_fan_info_t* info) -{ - int value, ret, index; - - info->status |= ONLP_FAN_STATUS_PRESENT; - info->status |= ONLP_FAN_STATUS_F2B; - - /* get fan direction */ - info->status |= _onlp_get_fan_direction_on_psu(); - - if (info->status & ONLP_FAN_STATUS_FAILED) { - return ONLP_STATUS_OK; - } - - index = ONLP_OID_ID_GET(info->hdr.id); - info->hdr.coids[0] = ONLP_FAN_ID_CREATE(index + CHASSIS_FAN_COUNT); - - /* get front fan speed */ - ret = onlp_file_read_int(&value, devfiles__[fid]); - if (ret < 0) { - return ONLP_STATUS_E_INTERNAL; - } - info->rpm = value; - info->percentage = (info->rpm * 100) / MAX_PSU_FAN_SPEED; - info->status |= (value == 0) ? ONLP_FAN_STATUS_FAILED : 0; - - snprintf(info->model, ONLP_CONFIG_INFO_STR_MAX, "NA"); - snprintf(info->serial, ONLP_CONFIG_INFO_STR_MAX, "NA"); - - 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: - 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 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_PSU1: - return psu_pmbus_info_set(PSU1_ID, "rpm_psu1", p); - case FAN_1_ON_PSU2: - return psu_pmbus_info_set(PSU2_ID, "rpm_psu2", p); - 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: - 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/d6556/onlp/builds/x86_64_inventec_d6556/module/src/ledi.c b/packages/platforms/inventec/x86-64/d6556/onlp/builds/x86_64_inventec_d6556/module/src/ledi.c deleted file mode 100644 index a96a4cfa2..000000000 --- a/packages/platforms/inventec/x86-64/d6556/onlp/builds/x86_64_inventec_d6556/module/src/ledi.c +++ /dev/null @@ -1,426 +0,0 @@ -/************************************************************ - * ledi.c - * - * Copyright 2018 Inventec Technology Corporation. - * - ************************************************************ - * - ***********************************************************/ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "platform_lib.h" - -#define filename "brightness" - -#define VALIDATE(_id) \ - do { \ - if(!ONLP_OID_IS_LED(_id)) { \ - return ONLP_STATUS_E_INVALID; \ - } \ - } while(0) - -static char* devfiles__[LED_MAX] = /* must map with onlp_thermal_id */ -{ - "reserved", - INV_CPLD_PREFIX"/%s_led", - INV_PSOC_PREFIX"/fan_led_%s1", - INV_PSOC_PREFIX"/fan_led_%s2", - INV_PSOC_PREFIX"/fan_led_%s3", - INV_PSOC_PREFIX"/fan_led_%s4", -}; - -/* - * Get the information for the given LED OID. - */ -static onlp_led_info_t linfo[LED_MAX] = -{ - { }, /* Not used */ - { - { ONLP_LED_ID_CREATE(LED_SYS), "Chassis LED (SYSTEM 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_MODE_ON, '0', - }, - { - { ONLP_LED_ID_CREATE(LED_FAN1), "Fan LED 1 (FAN1 LED)", 0 }, - ONLP_LED_STATUS_PRESENT, - ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_RED, - ONLP_LED_MODE_ON, '0', - }, - { - { ONLP_LED_ID_CREATE(LED_FAN2), "Fan LED 2 (FAN2 LED)", 0 }, - ONLP_LED_STATUS_PRESENT, - ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_RED, - ONLP_LED_MODE_ON, '0', - }, - { - { ONLP_LED_ID_CREATE(LED_FAN3), "Fan LED 3 (FAN3 LED)", 0 }, - ONLP_LED_STATUS_PRESENT, - ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_RED, - ONLP_LED_MODE_ON, '0', - }, - { - { ONLP_LED_ID_CREATE(LED_FAN4), "Fan LED 4 (FAN4 LED)", 0 }, - ONLP_LED_STATUS_PRESENT, - ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_RED, - ONLP_LED_MODE_ON, '0', - }, -}; - -/* - * This function will be called prior to any other onlp_ledi_* functions. - */ -static pthread_mutex_t diag_mutex; - -int -onlp_ledi_init(void) -{ - pthread_mutex_init(&diag_mutex, NULL); - - /* - * Diag LED Off - */ - onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_SYS), ONLP_LED_MODE_OFF); - - return ONLP_STATUS_OK; -} - -int onlp_chassis_led_read(char *pathp, char *buf, size_t len) -{ - FILE * fp; - - fp = fopen (pathp, "r"); - if(fp == NULL) { - perror("Error opening file"); - return(-1); - } - if( fgets (buf, len, fp) == NULL ) { - perror("Error fgets operation"); - } - fclose(fp); - - return(0); -} - -int onlp_chassis_led_write(char *pathp, char *buf) -{ - FILE * fp; - - fp = fopen (pathp, "w"); - if(fp == NULL) { - perror("Error opening file"); - return(-1); - } - if( fputs (buf, fp) == 0 ) { - perror("Error fputs operation"); - } - fclose(fp); - - return(0); -} - -int -onlp_ledi_info_get(onlp_oid_t id, onlp_led_info_t* info) -{ - int local_id, gret = 0, rret = 0; - char fullpath_grn[50] = {0}; - char fullpath_red[50] = {0}; - int gvalue = 0, rvalue = 0; - char gbuf[32] = {0}; - char rbuf[32] = {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 fullpath */ - switch (local_id) { - case LED_SYS: - sprintf(fullpath_grn, devfiles__[local_id], "grn"); - sprintf(fullpath_red, devfiles__[local_id], "red"); - - /* Set LED mode */ - gret = onlp_chassis_led_read(fullpath_grn, gbuf, 32); - rret = onlp_chassis_led_read(fullpath_red, rbuf, 32); - if (gret < 0 || rret < 0) { - DEBUG_PRINT("%s(%d): gret = %d, rret = %d\r\n", __FUNCTION__, __LINE__, gret, rret); - info->mode = ONLP_LED_MODE_OFF; - info->status = ONLP_LED_STATUS_FAILED; - break; - } - - info->status = ONLP_LED_STATUS_PRESENT; - if (gbuf[0] >= '1' && gbuf[0] <= '7' && rbuf[0] == '0') { - info->mode = ONLP_LED_MODE_GREEN; - info->status |= ONLP_LED_STATUS_ON; - } - else - if (rbuf[0] >= '1' && rbuf[0] <= '7' && gbuf[0] == '0') { - info->mode = ONLP_LED_MODE_RED; - info->status |= ONLP_LED_STATUS_ON; - } - else - if (gbuf[0] >= '1' && gbuf[0] <= '7' && rbuf[0] >= '1' && rbuf[0] <= '7') { - info->mode = ONLP_LED_MODE_ORANGE; - info->status |= ONLP_LED_STATUS_ON; - } - else - if (gbuf[0] == '0' && rbuf[0] == '0') { - info->mode = ONLP_LED_MODE_OFF; - info->status |= ONLP_LED_STATUS_ON; - } - else { - info->mode = ONLP_LED_MODE_OFF; - info->status = ONLP_LED_STATUS_FAILED; - } - break; - case LED_FAN1: - case LED_FAN2: - case LED_FAN3: - case LED_FAN4: - sprintf(fullpath_grn, devfiles__[local_id], "grn"); - - /* Set LED mode */ - if (onlp_file_read_int(&gvalue, fullpath_grn) != 0) { - DEBUG_PRINT("%s(%d)\r\n", __FUNCTION__, __LINE__); - info->mode = ONLP_LED_MODE_OFF; - info->status = ONLP_LED_STATUS_FAILED; - } - else - if (gvalue == 1) { - info->mode = ONLP_LED_MODE_GREEN; - info->status = ONLP_LED_STATUS_ON; - } - else - if (gvalue == 0) { - info->mode = ONLP_LED_MODE_OFF; - info->status = ONLP_LED_STATUS_ON; - } - - sprintf(fullpath_red, devfiles__[local_id], "red"); - - if (onlp_file_read_int(&rvalue, fullpath_red) != 0) { - DEBUG_PRINT("%s(%d)\r\n", __FUNCTION__, __LINE__); - info->mode = ONLP_LED_MODE_OFF; - info->status = ONLP_LED_STATUS_FAILED; - } - else - if (rvalue == 1) { - info->mode = ONLP_LED_MODE_RED; - info->status = ONLP_LED_STATUS_ON; - } - else - if (rvalue == 0) { - info->mode = ONLP_LED_MODE_OFF; - info->status = ONLP_LED_STATUS_ON; - } - break; - default: - DEBUG_PRINT("%s(%d) Invalid led id %d\r\n", __FUNCTION__, __LINE__, local_id); - break; - } - - return ONLP_STATUS_OK; -} - -int onlp_ledi_status_get(onlp_oid_t id, uint32_t* rv) -{ - int result = ONLP_STATUS_OK; - onlp_led_info_t linfo; - - result = onlp_ledi_info_get(id, &linfo); - *rv = linfo.status; - - return result; -} - -/* - * 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; -} - -#define HWMON_PSOC_DIAG_PATH "/sys/bus/i2c/devices/0-0055/hwmon/hwmon2/subsystem/hwmon1/diag" -#define HWMON_CPLD_CTRL_PATH "/sys/bus/i2c/devices/0-0055/ctl" -#define HWMON_DEVICE_DIAG_PATH HWMON_PSOC_DIAG_PATH -#define HWMON_DEVICE_CTRL_PATH HWMON_CPLD_CTRL_PATH - -#define MIN_ACC_SIZE (32) - -/* - * Store attr Section - */ -static int onlp_chassis_led_diag_enable(void) -{ - char tmp[MIN_ACC_SIZE]; - ssize_t ret; - - ret = onlp_chassis_led_read(HWMON_DEVICE_DIAG_PATH, &tmp[0], MIN_ACC_SIZE); - if (ret <= 0) { - return ret; - } - - if (tmp[0] == '0') { - pthread_mutex_lock(&diag_mutex); - ret = onlp_chassis_led_write(HWMON_DEVICE_DIAG_PATH, "1"); - if (ret < 0) { - pthread_mutex_unlock(&diag_mutex); - return ret; - } - - ret = onlp_chassis_led_write(HWMON_DEVICE_CTRL_PATH, "1"); - if (ret < 0) { - pthread_mutex_unlock(&diag_mutex); - return ret; - } - pthread_mutex_unlock(&diag_mutex); - } - - return ret; -} - -static int onlp_chassis_led_diag_disable(void) -{ - char tmp[MIN_ACC_SIZE]; - ssize_t ret; - - ret = onlp_chassis_led_read(HWMON_DEVICE_DIAG_PATH, &tmp[0], MIN_ACC_SIZE); - if (ret <= 0) { - return ret; - } - - if (tmp[0] == '1') { - pthread_mutex_lock(&diag_mutex); - ret = onlp_chassis_led_write(HWMON_DEVICE_DIAG_PATH, "1"); - if (ret < 0) { - pthread_mutex_unlock(&diag_mutex); - return 1; - } - - ret = onlp_chassis_led_write(HWMON_DEVICE_CTRL_PATH, "1"); - if (ret < 0) { - pthread_mutex_unlock(&diag_mutex); - return 1; - } - pthread_mutex_unlock(&diag_mutex); - } - return 1; -} - -/* - * 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) -{ - char fullpath_grn[50] = {0}; - char fullpath_red[50] = {0}; - char sys_buf[32] = {0}; - onlp_led_info_t linfo; - int ret = onlp_ledi_info_get(id, &linfo); - int local_id; - - VALIDATE(id); - - local_id = ONLP_OID_ID_GET(id); - - switch (mode) { - case ONLP_LED_MODE_OFF: - if (ret == ONLP_STATUS_OK && linfo.status & ONLP_LED_STATUS_ON && linfo.mode == ONLP_LED_MODE_OFF) { - return ONLP_STATUS_OK; - } - - sprintf(sys_buf, "%d", 0x0); - sprintf(fullpath_grn, devfiles__[local_id], "grn"); - ret = onlp_chassis_led_write(fullpath_grn, sys_buf); - - sprintf(sys_buf, "%d", 0x0); - sprintf(fullpath_red, devfiles__[local_id], "red"); - ret = onlp_chassis_led_write(fullpath_red, sys_buf); - break; - case ONLP_LED_MODE_RED: - if (ret == ONLP_STATUS_OK && linfo.status & ONLP_LED_STATUS_ON && linfo.mode == ONLP_LED_MODE_RED) { - return ONLP_STATUS_OK; - } - - sprintf(sys_buf, "%d", 0x0); - sprintf(fullpath_grn, devfiles__[local_id], "grn"); - ret = onlp_chassis_led_write(fullpath_grn, sys_buf); - - sprintf(sys_buf, "%d", 0x7); - sprintf(fullpath_red, devfiles__[local_id], "red"); - ret = onlp_chassis_led_write(fullpath_red, sys_buf); - break; - case ONLP_LED_MODE_GREEN: - if (ret == ONLP_STATUS_OK && linfo.status & ONLP_LED_STATUS_ON && linfo.mode == ONLP_LED_MODE_GREEN) { - return ONLP_STATUS_OK; - } - - sprintf(sys_buf, "%d", 0x7); - sprintf(fullpath_grn, devfiles__[local_id], "grn"); - ret = onlp_chassis_led_write(fullpath_grn, sys_buf); - - sprintf(sys_buf, "%d", 0x0); - sprintf(fullpath_red, devfiles__[local_id], "red"); - ret = onlp_chassis_led_write(fullpath_red, sys_buf); - break; - case ONLP_LED_MODE_ORANGE: - if (ret == ONLP_STATUS_OK && linfo.status & ONLP_LED_STATUS_ON && linfo.mode == ONLP_LED_MODE_ORANGE) { - return ONLP_STATUS_OK; - } - - sprintf(sys_buf, "%d", 0x7); - sprintf(fullpath_grn, devfiles__[local_id], "grn"); - ret = onlp_chassis_led_write(fullpath_grn, sys_buf); - - sprintf(sys_buf, "%d", 0x7); - sprintf(fullpath_red, devfiles__[local_id], "red"); - ret = onlp_chassis_led_write(fullpath_red, sys_buf); - break; - default: - DEBUG_PRINT("%s(%d) Invalid led mode %d\r\n", __FUNCTION__, __LINE__, mode); - return ONLP_STATUS_E_INTERNAL; - } - - switch (local_id) { - case LED_SYS: - onlp_chassis_led_diag_enable(); - sleep(1); - onlp_chassis_led_diag_disable(); - break; - default: - break; - } - - return ONLP_STATUS_OK; -} diff --git a/packages/platforms/inventec/x86-64/d6556/onlp/builds/x86_64_inventec_d6556/module/src/make.mk b/packages/platforms/inventec/x86-64/d6556/onlp/builds/x86_64_inventec_d6556/module/src/make.mk deleted file mode 100644 index cf92933fe..000000000 --- a/packages/platforms/inventec/x86-64/d6556/onlp/builds/x86_64_inventec_d6556/module/src/make.mk +++ /dev/null @@ -1,9 +0,0 @@ -############################################################################### -# -# -# -############################################################################### - -LIBRARY := x86_64_inventec_d6556 -$(LIBRARY)_SUBDIR := $(dir $(lastword $(MAKEFILE_LIST))) -include $(BUILDER)/lib.mk diff --git a/packages/platforms/inventec/x86-64/d6556/onlp/builds/x86_64_inventec_d6556/module/src/platform_lib.c b/packages/platforms/inventec/x86-64/d6556/onlp/builds/x86_64_inventec_d6556/module/src/platform_lib.c deleted file mode 100644 index afaf19939..000000000 --- a/packages/platforms/inventec/x86-64/d6556/onlp/builds/x86_64_inventec_d6556/module/src/platform_lib.c +++ /dev/null @@ -1,184 +0,0 @@ -/************************************************************ - * platform_lib.c - * - * Copyright 2018 Inventec Corporation. - * - ************************************************************ - * - ***********************************************************/ -#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 32 -#define I2C_PSU_FAN_DIR_LEN 8 -#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)] = 0; - } - - if (strncmp(model_name, "YM-2651Y", 8) == 0) { - if (modelname) { - aim_strlcpy(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) { - aim_strlcpy(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) { - aim_strlcpy(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; - } - } - - if (strncmp(model_name, "DPS-150AB-10", 12) == 0) { - if (modelname) { - aim_strlcpy(modelname, model_name, 12); - } - - return PSU_TYPE_DC_12V_F2B; - } - - 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%d", PSU1_AC_PMBUS_PREFIX, node, PSU1_ID); - } - else - if (PSU2_ID == id) { - ret = onlp_file_read_int(value, "%s%s%d", PSU2_AC_PMBUS_PREFIX, node, PSU2_ID); - } - else { - return ONLP_STATUS_E_INTERNAL; - } - - 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%d", PSU1_AC_PMBUS_PREFIX, node, PSU1_ID); - break; - case PSU2_ID: - sprintf(path, "%s%s%d", PSU2_AC_PMBUS_PREFIX, node, PSU2_ID); - 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/d6556/onlp/builds/x86_64_inventec_d6556/module/src/platform_lib.h b/packages/platforms/inventec/x86-64/d6556/onlp/builds/x86_64_inventec_d6556/module/src/platform_lib.h deleted file mode 100644 index 2a1ea050a..000000000 --- a/packages/platforms/inventec/x86-64/d6556/onlp/builds/x86_64_inventec_d6556/module/src/platform_lib.h +++ /dev/null @@ -1,140 +0,0 @@ -/************************************************************ - * platform_lib.h - * - * Copyright 2018 Inventec Technology Corporation. - * - ************************************************************ - * - ***********************************************************/ -#ifndef __PLATFORM_LIB_H__ -#define __PLATFORM_LIB_H__ - -#include "x86_64_inventec_d6556_log.h" - -#define ONLP_NODE_MAX_INT_LEN (8) -#define ONLP_NODE_MAX_PATH_LEN (64) - -#define INV_CPLD_COUNT (2) -#define INV_CPLD_PREFIX "/sys/bus/i2c/devices/0-0055/" -#define INV_CPLD2_PREFIX "/sys/bus/i2c/devices/0-0077/" -#define INV_PSOC_PREFIX "/sys/devices/virtual/hwmon/hwmon1/" -#define INV_EPRM_PREFIX "/sys/bus/i2c/devices/0-0053/" -#define INV_CTMP_PREFIX "/sys/devices/platform/coretemp.0/hwmon/hwmon0/" - -#define INV_SFP_EEPROM_UPDATE "/sys/class/swps/module/eeprom_update" -#define CHASSIS_SFP_COUNT (56) - -/* - * Definitions of Chassis EEPROM - */ -#define EEPROM_NODE(node) INV_EPRM_PREFIX#node - - -/* - * Definitions of D6556 device - */ -enum onlp_thermal_id { - THERMAL_RESERVED = 0, - THERMAL_CPU_CORE_FIRST, - THERMAL_CPU_CORE_2, - THERMAL_CPU_CORE_3, - THERMAL_CPU_CORE_4, - THERMAL_CPU_CORE_LAST, - 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_2_ON_PSU1, - THERMAL_1_ON_PSU2, - THERMAL_2_ON_PSU2, - THERMAL_MAX -}; -#define CHASSIS_THERMAL_COUNT (10) - -enum onlp_fan_id { - FAN_RESERVED = 0, - FAN_1_ON_MAIN_BOARD, - FAN_2_ON_MAIN_BOARD, - FAN_3_ON_MAIN_BOARD, - FAN_4_ON_MAIN_BOARD, - FAN_5_ON_MAIN_BOARD, - FAN_6_ON_MAIN_BOARD, - FAN_7_ON_MAIN_BOARD, - FAN_8_ON_MAIN_BOARD, - FAN_1_ON_PSU1, - FAN_1_ON_PSU2, - FAN_MAX -}; -#define CHASSIS_FAN_COUNT (8) - -enum onlp_led_id { - LED_RESERVED = 0, - LED_SYS, - LED_FAN1, - LED_FAN2, - LED_FAN3, - LED_FAN4, - LED_MAX -}; -#define CHASSIS_LED_COUNT (1) - -enum onlp_psu_id { - PSU_RESERVED = 0, - PSU1_ID, - PSU2_ID, - PSU_MAX -}; -#define CHASSIS_PSU_COUNT (2) - -#define PSU1_AC_PMBUS_PREFIX INV_PSOC_PREFIX -#define PSU2_AC_PMBUS_PREFIX INV_PSOC_PREFIX - -#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 INV_CPLD_PREFIX -#define PSU2_AC_HWMON_PREFIX INV_CPLD_PREFIX - -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 PSU1_AC_HWMON_NODE(node) PSU1_AC_HWMON_PREFIX#node -#define PSU2_AC_HWMON_NODE(node) PSU2_AC_HWMON_PREFIX#node - -/* - * Definitions of FAN device - */ -#define FAN_BOARD_PATH INV_PSOC_PREFIX -#define FAN_NODE(node) FAN_BOARD_PATH#node - -/* - * Prototypes - */ -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); - -#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/d6556/onlp/builds/x86_64_inventec_d6556/module/src/psui.c b/packages/platforms/inventec/x86-64/d6556/onlp/builds/x86_64_inventec_d6556/module/src/psui.c deleted file mode 100644 index cda53ce5d..000000000 --- a/packages/platforms/inventec/x86-64/d6556/onlp/builds/x86_64_inventec_d6556/module/src/psui.c +++ /dev/null @@ -1,256 +0,0 @@ -/************************************************************ - * psui.c - * - * Copyright 2018 Inventec Technology Corporation. - * - ************************************************************ - * - ***********************************************************/ -#include -#include -#include -#include -#include -#include -#include "platform_lib.h" - -#define PSU_STATUS_PRESENT (0) -#define PSU_STATUS_POWER_GOOD (1) -#define PSU_STATUS_UNPOWERED (2) -#define PSU_STATUS_FAULT (4) -#define PSU_STATUS_UNINSTALLED (7) - -#define VALIDATE(_id) \ - do { \ - if(!ONLP_OID_IS_PSU(_id)) { \ - return ONLP_STATUS_E_INVALID; \ - } \ - } while(0) - -static char* status_devfiles__[PSU_MAX] = /* must map with onlp_psu_id */ -{ - "reserved", - INV_CPLD_PREFIX"/psu0", - INV_CPLD_PREFIX"/psu1", -}; - -static char* module_devfiles__[PSU_MAX] = /* must map with onlp_psu_id */ -{ - "reserved", - INV_PSOC_PREFIX"/psoc_psu1_%s", - INV_PSOC_PREFIX"/psoc_psu2_%s", -}; - -static int -psu_status_info_get(int id, char *node, int *value) -{ - int ret = 0; - char node_path[ONLP_NODE_MAX_PATH_LEN] = {0}; - - *value = 0; - if (PSU1_ID == id) { - sprintf(node_path, status_devfiles__[id]); - } - else if (PSU2_ID == id) { - sprintf(node_path, status_devfiles__[id]); - } - - 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 ONLP_STATUS_OK; -} - - -int -onlp_psui_init(void) -{ - return ONLP_STATUS_OK; -} - -static void -psu_module_name_get(int id, onlp_psu_info_t* info) -{ - char node_path[ONLP_NODE_MAX_PATH_LEN] = {0}; - uint8_t temp[ONLP_CONFIG_INFO_STR_MAX] = {0}; - int ret, len; - -#if 1 - aim_strlcpy(info->model, "N/A", 3); -#else - memset(node_path, 0, ONLP_NODE_MAX_PATH_LEN); - sprintf(node_path, module_devfiles__[id], "model"); - ret = onlp_file_read(temp, ONLP_CONFIG_INFO_STR_MAX, &len, node_path); - if (ret == 0) { - /*remove the '\n'*/ - temp[strlen((char*)temp)-1] = 0; - snprintf(info->model, ONLP_CONFIG_INFO_STR_MAX, "%s", temp); - } - else { - AIM_LOG_ERROR("Unable to read model name from file(%s)\r\n", node_path); - aim_strlcpy(info->model, "N/A", 3); - } -#endif - - memset(node_path, 0, ONLP_NODE_MAX_PATH_LEN); - sprintf(node_path, module_devfiles__[id], "serial"); - ret = onlp_file_read(temp, ONLP_CONFIG_INFO_STR_MAX, &len, node_path); - if (ret == 0) { - /*remove the '\n'*/ - temp[strlen((char*)temp)-1] = 0; - snprintf(info->serial, ONLP_CONFIG_INFO_STR_MAX, "%s", temp); - } - else { - AIM_LOG_ERROR("Unable to read model name from file(%s)\r\n", node_path); - aim_strlcpy(info->serial, "N/A", 3); - } -} - -static int -psu_module_info_get(int id, onlp_psu_info_t* info) -{ - int ret = 0; - char node_path[ONLP_NODE_MAX_PATH_LEN] = {0}; - int value = 0; - - info->caps |= ONLP_PSU_CAPS_DC12; - - memset(node_path, 0, ONLP_NODE_MAX_PATH_LEN); - sprintf(node_path, module_devfiles__[id], "vout"); - ret = onlp_file_read_int(&value, node_path); - if (ret < 0) { - AIM_LOG_ERROR("Unable to read vout from file(%s)\r\n", node_path); - } - else { - info->mvout = value; - info->caps |= ONLP_PSU_CAPS_VOUT; - } - - memset(node_path, 0, ONLP_NODE_MAX_PATH_LEN); - sprintf(node_path, module_devfiles__[id], "iout"); - ret = onlp_file_read_int(&value, node_path); - if (ret < 0) { - AIM_LOG_ERROR("Unable to read iout from file(%s)\r\n", node_path); - } - else { - info->miout = value; - info->caps |= ONLP_PSU_CAPS_IOUT; - } - - memset(node_path, 0, ONLP_NODE_MAX_PATH_LEN); - sprintf(node_path, module_devfiles__[id], "pout"); - ret = onlp_file_read_int(&value, node_path); - if (ret < 0) { - AIM_LOG_ERROR("Unable to read pout from file(%s)\r\n", node_path); - } - else { - info->mpout = value; - info->caps |= ONLP_PSU_CAPS_POUT; - } - - memset(node_path, 0, ONLP_NODE_MAX_PATH_LEN); - sprintf(node_path, module_devfiles__[id], "vin"); - ret = onlp_file_read_int(&value, node_path); - if (ret < 0) { - AIM_LOG_ERROR("Unable to read vin from file(%s)\r\n", node_path); - } - else { - info->mvin = value; - info->caps |= ONLP_PSU_CAPS_VIN; - } - - memset(node_path, 0, ONLP_NODE_MAX_PATH_LEN); - sprintf(node_path, module_devfiles__[id], "iin"); - ret = onlp_file_read_int(&value, node_path); - if (ret < 0) { - AIM_LOG_ERROR("Unable to read iin from file(%s)\r\n", node_path); - } - else { - info->miin = value; - info->caps |= ONLP_PSU_CAPS_IIN; - } - - memset(node_path, 0, ONLP_NODE_MAX_PATH_LEN); - sprintf(node_path, module_devfiles__[id], "pin"); - ret = onlp_file_read_int(&value, node_path); - if (ret < 0) { - AIM_LOG_ERROR("Unable to read pin from file(%s)\r\n", node_path); - } - else { - info->mpin = value; - info->caps |= ONLP_PSU_CAPS_PIN; - } - - psu_module_name_get(id, info); - 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_THERMAL_ID_CREATE(THERMAL_1_ON_PSU1), - ONLP_THERMAL_ID_CREATE(THERMAL_2_ON_PSU1), - ONLP_FAN_ID_CREATE(FAN_1_ON_PSU1) - } - }, - }, - { - { - ONLP_PSU_ID_CREATE(PSU2_ID), "PSU-2", 0, - { - ONLP_THERMAL_ID_CREATE(THERMAL_1_ON_PSU2), - ONLP_THERMAL_ID_CREATE(THERMAL_2_ON_PSU2), - ONLP_FAN_ID_CREATE(FAN_1_ON_PSU2) - } - }, - } -}; - -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 ((ret = psu_status_info_get(index, "psu", &val)) == ONLP_STATUS_E_INTERNAL) { - printf("Unable to read PSU(%d) node(psu)\r\n", index); - return ret; - } - - if (val == 0) { - info->status = ONLP_PSU_STATUS_PRESENT; - } - else - if (val == 1) { - info->status = ONLP_PSU_STATUS_UNPLUGGED; - return ret; - } - else { - info->status = ONLP_PSU_STATUS_FAILED; - return ret; - } - - if ((ret = psu_module_info_get(index, info)) != ONLP_STATUS_OK) { - printf("Unable to read PSU(%d) module information\r\n", index); - } - - return ret; -} diff --git a/packages/platforms/inventec/x86-64/d6556/onlp/builds/x86_64_inventec_d6556/module/src/sfpi.c b/packages/platforms/inventec/x86-64/d6556/onlp/builds/x86_64_inventec_d6556/module/src/sfpi.c deleted file mode 100644 index 959d48e69..000000000 --- a/packages/platforms/inventec/x86-64/d6556/onlp/builds/x86_64_inventec_d6556/module/src/sfpi.c +++ /dev/null @@ -1,239 +0,0 @@ -/************************************************************ - * sfpi.c - * - * Copyright 2018 Inventec Technology Corporation. - * - ************************************************************ - * - ***********************************************************/ -#include - -#include /* For O_RDWR && open */ -#include -#include -#include -#include -#include -#include -#include "platform_lib.h" - -static char sfp_node_path[ONLP_NODE_MAX_PATH_LEN] = {0}; - -#define NUM_OF_SFP_PORT (CHASSIS_SFP_COUNT) -static const int sfp_mux_index[NUM_OF_SFP_PORT] = { -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, -50, 51, 52, 53, 54, 55, 56, 57, -58, 59, 60, 61, 62, 63, 64, 65, -10, 11, 12, 13, 14, 15, 16, 17 -}; - -#define FRONT_PORT_TO_MUX_INDEX(port) (sfp_mux_index[port]) - -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/class/swps/port%d/%s", 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, 64} - */ - 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, "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; - } - if (present == 0) { - present = 1; - } - else - if (present == 1) { - present = 0; - } - else { - AIM_LOG_ERROR("Unvalid present status %d from port(%d)\r\n",present,port); - return ONLP_STATUS_E_INTERNAL; - } - return present; -} - -int -onlp_sfpi_presence_bitmap_get(onlp_sfp_bitmap_t* dst) -{ - uint32_t presence_all[2] = {0}; - int port, ret, index; - - for (port = 0, index = 0; port < NUM_OF_SFP_PORT; port++) { - if (port == 32) { - index = 1; - } - - ret = onlp_sfpi_is_present(port); - if (ret == 1) { - presence_all[index] |= (1<>= 1; - } - return ONLP_STATUS_OK; -} - -int -onlp_sfpi_eeprom_read(int port, uint8_t data[256]) -{ - char* path; - 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); - path = sfp_get_port_path(port, "eeprom"); - if (onlp_file_read(&data[0], 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_dom_read(int port, uint8_t data[256]) -{ - return onlp_sfpi_eeprom_read( port, data); -} - -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); - int ret = onlp_i2c_writeb(bus, devaddr, addr, value, ONLP_I2C_F_FORCE); - - if (ret == 0) { - unsigned char buf[8] = { 0 }; - char str[20]; - - buf[port/8] = (1 << port%8); - sprintf(str, "0x%02x%02x%02x%02x%02x%02x%02x%02x", buf[7],buf[6],buf[5],buf[4],buf[3],buf[2],buf[1],buf[0]); - if (onlp_file_write((uint8_t*)str, 20, INV_SFP_EEPROM_UPDATE) < 0) { - AIM_LOG_ERROR("Unable to write eeprom_update for port(%d)\r\n", port); - return ONLP_STATUS_E_INTERNAL; - } - return ONLP_STATUS_OK; - } - AIM_LOG_ERROR("Unable to read eeprom_update from port(%d)\r\n", port); - return ret; -} - -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); - int ret = onlp_i2c_writew(bus, devaddr, addr, value, ONLP_I2C_F_FORCE); - - if (ret == 0) { - unsigned char buf[8] = { 0 }; - char str[20]; - - buf[port/8] = (1 << port%8); - sprintf(str, "0x%02x%02x%02x%02x%02x%02x%02x%02x", buf[7],buf[6],buf[5],buf[4],buf[3],buf[2],buf[1],buf[0]); - if (onlp_file_write((uint8_t*)str, 20, INV_SFP_EEPROM_UPDATE) < 0) { - AIM_LOG_ERROR("Unable to write eeprom_update for port(%d)\r\n", port); - return ONLP_STATUS_E_INTERNAL; - } - return ONLP_STATUS_OK; - } - AIM_LOG_ERROR("Unable to read eeprom_update from port(%d)\r\n", port); - return ret; -} - -int -onlp_sfpi_denit(void) -{ - return ONLP_STATUS_OK; -} - diff --git a/packages/platforms/inventec/x86-64/d6556/onlp/builds/x86_64_inventec_d6556/module/src/sysi.c b/packages/platforms/inventec/x86-64/d6556/onlp/builds/x86_64_inventec_d6556/module/src/sysi.c deleted file mode 100644 index 7b792a4ea..000000000 --- a/packages/platforms/inventec/x86-64/d6556/onlp/builds/x86_64_inventec_d6556/module/src/sysi.c +++ /dev/null @@ -1,111 +0,0 @@ -/************************************************************ - * sysi.c - * - * Copyright 2018 Inventec Technology Corporation. - * - ************************************************************ - * - ***********************************************************/ -#include -#include - -#include -#include -#include -#include -#include -#include - -#include "x86_64_inventec_d6556_int.h" -#include "x86_64_inventec_d6556_log.h" - -#include "platform_lib.h" - -#define NUM_OF_CPLD INV_CPLD_COUNT - -#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 (CHASSIS_PSU_COUNT) -#define NUM_OF_LED_ON_MAIN_BROAD (CHASSIS_LED_COUNT) - -const char* -onlp_sysi_platform_get(void) -{ - return "x86-64-inventec-d6556-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, EEPROM_NODE(eeprom)) == 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)); - - /* 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; -} - -static char *arr_cplddev_version[NUM_OF_CPLD] = -{ - INV_CPLD_PREFIX"/version", - INV_CPLD2_PREFIX"/version", -}; - -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, arr_cplddev_version[i]) < 0) { - return ONLP_STATUS_E_INTERNAL; - } - } - pi->cpld_versions = aim_fstrdup("%d.%d", v[0], v[1]); - return 0; -} - -void -onlp_sysi_platform_info_free(onlp_platform_info_t* pi) -{ - aim_free(pi->cpld_versions); -} diff --git a/packages/platforms/inventec/x86-64/d6556/onlp/builds/x86_64_inventec_d6556/module/src/thermali.c b/packages/platforms/inventec/x86-64/d6556/onlp/builds/x86_64_inventec_d6556/module/src/thermali.c deleted file mode 100644 index 178eb6a7c..000000000 --- a/packages/platforms/inventec/x86-64/d6556/onlp/builds/x86_64_inventec_d6556/module/src/thermali.c +++ /dev/null @@ -1,147 +0,0 @@ -/************************************************************ - * thermali.c - * - * Copyright 2018 Inventec Technology Corporation. - * - ************************************************************ - * - * 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) - -static char* devfiles__[THERMAL_MAX] = /* must map with onlp_thermal_id */ -{ - "reserved", - INV_CTMP_PREFIX"/temp1_%s", - INV_CTMP_PREFIX"/temp2_%s", - INV_CTMP_PREFIX"/temp3_%s", - INV_CTMP_PREFIX"/temp4_%s", - INV_CTMP_PREFIX"/temp5_%s", - INV_PSOC_PREFIX"/temp1_input", - INV_PSOC_PREFIX"/temp2_input", - INV_PSOC_PREFIX"/temp3_input", - INV_PSOC_PREFIX"/temp4_input", - INV_PSOC_PREFIX"/temp5_input", - INV_PSOC_PREFIX"/thermal_psu1", - INV_PSOC_PREFIX"/thermal2_psu1", - INV_PSOC_PREFIX"/thermal_psu2", - INV_PSOC_PREFIX"/thermal2_psu2", -}; - -/* Static values */ -static onlp_thermal_info_t linfo[THERMAL_MAX] = { - { }, /* Not used */ - { { ONLP_THERMAL_ID_CREATE(THERMAL_CPU_CORE_FIRST), "Physical id 0", 0}, - ONLP_THERMAL_STATUS_PRESENT, - ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS - }, - { { ONLP_THERMAL_ID_CREATE(THERMAL_CPU_CORE_2), "CPU Core 0", 0}, - ONLP_THERMAL_STATUS_PRESENT, - ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS - }, - { { ONLP_THERMAL_ID_CREATE(THERMAL_CPU_CORE_3), "CPU Core 1", 0}, - ONLP_THERMAL_STATUS_PRESENT, - ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS - }, - { { ONLP_THERMAL_ID_CREATE(THERMAL_CPU_CORE_4), "CPU Core 2", 0}, - ONLP_THERMAL_STATUS_PRESENT, - ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS - }, - { { ONLP_THERMAL_ID_CREATE(THERMAL_CPU_CORE_LAST), "CPU Core 3", 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_3_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_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_2_ON_PSU1), "PSU-1 Thermal Sensor 2", 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 - }, - { { ONLP_THERMAL_ID_CREATE(THERMAL_2_ON_PSU2), "PSU-2 Thermal Sensor 2", 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_FIRST && local_id <= THERMAL_CPU_CORE_LAST) { - char desc[32], *dp = &desc[0]; - int rv = onlp_file_read_str(&dp, devfiles__[local_id], "label"); - if (rv > 0) { - memset (info->hdr.description, 0, ONLP_OID_DESC_SIZE); - aim_strlcpy(info->hdr.description, dp, rv); - } - - /* Set the onlp_oid_hdr_t and capabilities */ - return onlp_file_read_int(&info->mcelsius, devfiles__[local_id], "input"); - } - return onlp_file_read_int(&info->mcelsius, devfiles__[local_id]); -} diff --git a/packages/platforms/inventec/x86-64/d6556/onlp/builds/x86_64_inventec_d6556/module/src/x86_64_inventec_d6556_config.c b/packages/platforms/inventec/x86-64/d6556/onlp/builds/x86_64_inventec_d6556/module/src/x86_64_inventec_d6556_config.c deleted file mode 100644 index 15cd10289..000000000 --- a/packages/platforms/inventec/x86-64/d6556/onlp/builds/x86_64_inventec_d6556/module/src/x86_64_inventec_d6556_config.c +++ /dev/null @@ -1,81 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#include - -/* */ -#define __X86_64_INVENTEC_D6556_config_STRINGIFY_NAME(_x) #_x -#define __X86_64_INVENTEC_D6556_config_STRINGIFY_VALUE(_x) __X86_64_INVENTEC_D6556_config_STRINGIFY_NAME(_x) -X86_64_INVENTEC_D6556_config_settings_t X86_64_INVENTEC_D6556_config_settings[] = -{ -#ifdef X86_64_INVENTEC_D6556_CONFIG_INCLUDE_LOGGING - { __X86_64_INVENTEC_D6556_config_STRINGIFY_NAME(X86_64_INVENTEC_D6556_CONFIG_INCLUDE_LOGGING), __X86_64_INVENTEC_D6556_config_STRINGIFY_VALUE(X86_64_INVENTEC_D6556_CONFIG_INCLUDE_LOGGING) }, -#else -{ X86_64_INVENTEC_D6556_CONFIG_INCLUDE_LOGGING(__X86_64_INVENTEC_D6556_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_INVENTEC_D6556_CONFIG_LOG_OPTIONS_DEFAULT - { __X86_64_INVENTEC_D6556_config_STRINGIFY_NAME(X86_64_INVENTEC_D6556_CONFIG_LOG_OPTIONS_DEFAULT), __X86_64_INVENTEC_D6556_config_STRINGIFY_VALUE(X86_64_INVENTEC_D6556_CONFIG_LOG_OPTIONS_DEFAULT) }, -#else -{ X86_64_INVENTEC_D6556_CONFIG_LOG_OPTIONS_DEFAULT(__X86_64_INVENTEC_D6556_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_INVENTEC_D6556_CONFIG_LOG_BITS_DEFAULT - { __X86_64_INVENTEC_D6556_config_STRINGIFY_NAME(X86_64_INVENTEC_D6556_CONFIG_LOG_BITS_DEFAULT), __X86_64_INVENTEC_D6556_config_STRINGIFY_VALUE(X86_64_INVENTEC_D6556_CONFIG_LOG_BITS_DEFAULT) }, -#else -{ X86_64_INVENTEC_D6556_CONFIG_LOG_BITS_DEFAULT(__X86_64_INVENTEC_D6556_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_INVENTEC_D6556_CONFIG_LOG_CUSTOM_BITS_DEFAULT - { __X86_64_INVENTEC_D6556_config_STRINGIFY_NAME(X86_64_INVENTEC_D6556_CONFIG_LOG_CUSTOM_BITS_DEFAULT), __X86_64_INVENTEC_D6556_config_STRINGIFY_VALUE(X86_64_INVENTEC_D6556_CONFIG_LOG_CUSTOM_BITS_DEFAULT) }, -#else -{ X86_64_INVENTEC_D6556_CONFIG_LOG_CUSTOM_BITS_DEFAULT(__X86_64_INVENTEC_D6556_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_INVENTEC_D6556_CONFIG_PORTING_STDLIB - { __X86_64_INVENTEC_D6556_config_STRINGIFY_NAME(X86_64_INVENTEC_D6556_CONFIG_PORTING_STDLIB), __X86_64_INVENTEC_D6556_config_STRINGIFY_VALUE(X86_64_INVENTEC_D6556_CONFIG_PORTING_STDLIB) }, -#else -{ X86_64_INVENTEC_D6556_CONFIG_PORTING_STDLIB(__X86_64_INVENTEC_D6556_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_INVENTEC_D6556_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS - { __X86_64_INVENTEC_D6556_config_STRINGIFY_NAME(X86_64_INVENTEC_D6556_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS), __X86_64_INVENTEC_D6556_config_STRINGIFY_VALUE(X86_64_INVENTEC_D6556_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS) }, -#else -{ X86_64_INVENTEC_D6556_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS(__X86_64_INVENTEC_D6556_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_INVENTEC_D6556_CONFIG_INCLUDE_UCLI - { __X86_64_INVENTEC_D6556_config_STRINGIFY_NAME(X86_64_INVENTEC_D6556_CONFIG_INCLUDE_UCLI), __X86_64_INVENTEC_D6556_config_STRINGIFY_VALUE(X86_64_INVENTEC_D6556_CONFIG_INCLUDE_UCLI) }, -#else -{ X86_64_INVENTEC_D6556_CONFIG_INCLUDE_UCLI(__X86_64_INVENTEC_D6556_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_INVENTEC_D6556_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION - { __X86_64_INVENTEC_D6556_config_STRINGIFY_NAME(X86_64_INVENTEC_D6556_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION), __X86_64_INVENTEC_D6556_config_STRINGIFY_VALUE(X86_64_INVENTEC_D6556_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION) }, -#else -{ X86_64_INVENTEC_D6556_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION(__X86_64_INVENTEC_D6556_config_STRINGIFY_NAME), "__undefined__" }, -#endif - { NULL, NULL } -}; -#undef __X86_64_INVENTEC_D6556_config_STRINGIFY_VALUE -#undef __X86_64_INVENTEC_D6556_config_STRINGIFY_NAME - -const char* -_x86_64__i_n_v_e_n_t_e_c__d6556_config_lookup(const char* setting) -{ - int i; - for(i = 0; X86_64_INVENTEC_D6556_config_settings[i].name; i++) { - if(!strcmp(X86_64_INVENTEC_D6556_config_settings[i].name, setting)) { - return X86_64_INVENTEC_D6556_config_settings[i].value; - } - } - return NULL; -} - -int -_x86_64__i_n_v_e_n_t_e_c__d6556_config_show(struct aim_pvs_s* pvs) -{ - int i; - for(i = 0; X86_64_INVENTEC_D6556_config_settings[i].name; i++) { - aim_printf(pvs, "%s = %s\n", X86_64_INVENTEC_D6556_config_settings[i].name, X86_64_INVENTEC_D6556_config_settings[i].value); - } - return i; -} - -/* */ - diff --git a/packages/platforms/inventec/x86-64/d6556/onlp/builds/x86_64_inventec_d6556/module/src/x86_64_inventec_d6556_enums.c b/packages/platforms/inventec/x86-64/d6556/onlp/builds/x86_64_inventec_d6556/module/src/x86_64_inventec_d6556_enums.c deleted file mode 100644 index e81966dcb..000000000 --- a/packages/platforms/inventec/x86-64/d6556/onlp/builds/x86_64_inventec_d6556/module/src/x86_64_inventec_d6556_enums.c +++ /dev/null @@ -1,10 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#include - -/* <--auto.start.enum(ALL).source> */ -/* */ - diff --git a/packages/platforms/inventec/x86-64/d6556/onlp/builds/x86_64_inventec_d6556/module/src/x86_64_inventec_d6556_int.h b/packages/platforms/inventec/x86-64/d6556/onlp/builds/x86_64_inventec_d6556/module/src/x86_64_inventec_d6556_int.h deleted file mode 100644 index 41232e1f2..000000000 --- a/packages/platforms/inventec/x86-64/d6556/onlp/builds/x86_64_inventec_d6556/module/src/x86_64_inventec_d6556_int.h +++ /dev/null @@ -1,12 +0,0 @@ -/**************************************************************************//** - * - * x86_64_inventec_d6556 Internal Header - * - *****************************************************************************/ -#ifndef __x86_64_inventec_d6556_INT_H__ -#define __x86_64_inventec_d6556_INT_H__ - -#include - - -#endif /* __x86_64_inventec_d6556_INT_H__ */ diff --git a/packages/platforms/inventec/x86-64/d6556/onlp/builds/x86_64_inventec_d6556/module/src/x86_64_inventec_d6556_log.c b/packages/platforms/inventec/x86-64/d6556/onlp/builds/x86_64_inventec_d6556/module/src/x86_64_inventec_d6556_log.c deleted file mode 100644 index 37dc49352..000000000 --- a/packages/platforms/inventec/x86-64/d6556/onlp/builds/x86_64_inventec_d6556/module/src/x86_64_inventec_d6556_log.c +++ /dev/null @@ -1,18 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#include - -#include "x86_64_inventec_d6556_log.h" -/* - * x86_64_inventec_d6556 log struct. - */ -AIM_LOG_STRUCT_DEFINE( - X86_64_INVENTEC_D6556_CONFIG_LOG_OPTIONS_DEFAULT, - X86_64_INVENTEC_D6556_CONFIG_LOG_BITS_DEFAULT, - NULL, /* Custom log map */ - X86_64_INVENTEC_D6556_CONFIG_LOG_CUSTOM_BITS_DEFAULT - ); - diff --git a/packages/platforms/inventec/x86-64/d6556/onlp/builds/x86_64_inventec_d6556/module/src/x86_64_inventec_d6556_log.h b/packages/platforms/inventec/x86-64/d6556/onlp/builds/x86_64_inventec_d6556/module/src/x86_64_inventec_d6556_log.h deleted file mode 100644 index 0a9496fe2..000000000 --- a/packages/platforms/inventec/x86-64/d6556/onlp/builds/x86_64_inventec_d6556/module/src/x86_64_inventec_d6556_log.h +++ /dev/null @@ -1,12 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#ifndef __x86_64_inventec_d6556_LOG_H__ -#define __x86_64_inventec_d6556_LOG_H__ - -#define AIM_LOG_MODULE_NAME x86_64_inventec_d6556 -#include - -#endif /* __x86_64_inventec_d6556_LOG_H__ */ diff --git a/packages/platforms/inventec/x86-64/d6556/onlp/builds/x86_64_inventec_d6556/module/src/x86_64_inventec_d6556_module.c b/packages/platforms/inventec/x86-64/d6556/onlp/builds/x86_64_inventec_d6556/module/src/x86_64_inventec_d6556_module.c deleted file mode 100644 index 997134555..000000000 --- a/packages/platforms/inventec/x86-64/d6556/onlp/builds/x86_64_inventec_d6556/module/src/x86_64_inventec_d6556_module.c +++ /dev/null @@ -1,24 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#include - -#include "x86_64_inventec_d6556_log.h" - -static int -datatypes_init__(void) -{ -#define x86_64_inventec_d6556_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_d6556_module_init__(void) -{ - AIM_LOG_STRUCT_REGISTER(); - datatypes_init__(); -} - -int __onlp_platform_version__ = 1; diff --git a/packages/platforms/inventec/x86-64/d6556/onlp/builds/x86_64_inventec_d6556/module/src/x86_64_inventec_d6556_ucli.c b/packages/platforms/inventec/x86-64/d6556/onlp/builds/x86_64_inventec_d6556/module/src/x86_64_inventec_d6556_ucli.c deleted file mode 100644 index 567cd4b6c..000000000 --- a/packages/platforms/inventec/x86-64/d6556/onlp/builds/x86_64_inventec_d6556/module/src/x86_64_inventec_d6556_ucli.c +++ /dev/null @@ -1,50 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#include - -#if x86_64_inventec_d6556_CONFIG_INCLUDE_UCLI == 1 - -#include -#include -#include - -static ucli_status_t -x86_64_inventec_d6556_ucli_ucli__config__(ucli_context_t* uc) -{ - UCLI_HANDLER_MACRO_MODULE_CONFIG(x86_64_inventec_d6556) -} - -/* */ -/* */ - -static ucli_module_t -x86_64_inventec_d6556_ucli_module__ = - { - "x86_64_inventec_d6556_ucli", - NULL, - x86_64_inventec_d6556_ucli_ucli_handlers__, - NULL, - NULL, - }; - -ucli_node_t* -x86_64_inventec_d6556_ucli_node_create(void) -{ - ucli_node_t* n; - ucli_module_init(&x86_64_inventec_d6556_ucli_module__); - n = ucli_node_create("x86_64_inventec_d6556", NULL, &x86_64_inventec_d6556_ucli_module__); - ucli_node_subnode_add(n, ucli_module_log_node_create("x86_64_inventec_d6556")); - return n; -} - -#else -void* -x86_64_inventec_d6556_ucli_node_create(void) -{ - return NULL; -} -#endif - diff --git a/packages/platforms/inventec/x86-64/d6556/platform-config/Makefile b/packages/platforms/inventec/x86-64/d6556/platform-config/Makefile deleted file mode 100644 index 003238cf6..000000000 --- a/packages/platforms/inventec/x86-64/d6556/platform-config/Makefile +++ /dev/null @@ -1 +0,0 @@ -include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/inventec/x86-64/d6556/platform-config/r0/Makefile b/packages/platforms/inventec/x86-64/d6556/platform-config/r0/Makefile deleted file mode 100644 index 003238cf6..000000000 --- a/packages/platforms/inventec/x86-64/d6556/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/inventec/x86-64/d6556/platform-config/r0/PKG.yml b/packages/platforms/inventec/x86-64/d6556/platform-config/r0/PKG.yml deleted file mode 100644 index de598c2eb..000000000 --- a/packages/platforms/inventec/x86-64/d6556/platform-config/r0/PKG.yml +++ /dev/null @@ -1 +0,0 @@ -!include $ONL_TEMPLATES/platform-config-platform.yml ARCH=amd64 VENDOR=inventec BASENAME=x86-64-inventec-d6556 REVISION=r0 diff --git a/packages/platforms/inventec/x86-64/d6556/platform-config/r0/src/lib/x86-64-inventec-d6556-r0.yml b/packages/platforms/inventec/x86-64/d6556/platform-config/r0/src/lib/x86-64-inventec-d6556-r0.yml deleted file mode 100644 index 8d6ba0b57..000000000 --- a/packages/platforms/inventec/x86-64/d6556/platform-config/r0/src/lib/x86-64-inventec-d6556-r0.yml +++ /dev/null @@ -1,31 +0,0 @@ ---- - -###################################################################### -# -# platform-config for d6556 -# -###################################################################### - -x86-64-inventec-d6556-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/d6556/platform-config/r0/src/python/x86_64_inventec_d6556_r0/__init__.py b/packages/platforms/inventec/x86-64/d6556/platform-config/r0/src/python/x86_64_inventec_d6556_r0/__init__.py deleted file mode 100644 index 0bf0f99ef..000000000 --- a/packages/platforms/inventec/x86-64/d6556/platform-config/r0/src/python/x86_64_inventec_d6556_r0/__init__.py +++ /dev/null @@ -1,22 +0,0 @@ -from onl.platform.base import * -from onl.platform.inventec import * - -class OnlPlatform_x86_64_inventec_d6556_r0(OnlPlatformInventec, - OnlPlatformPortConfig_48x25_8x100): - PLATFORM='x86-64-inventec-d6556-r0' - MODEL="D6556" - SYS_OBJECT_ID=".6556.1" - - def baseconfig(self): - os.system("insmod /lib/modules/`uname -r`/kernel/drivers/gpio/gpio-ich.ko gpiobase=0") - self.insmod('i2c-gpio') - self.insmod('inv_platform') - self.insmod('inv_psoc') - self.new_i2c_device('inv_cpld', 0x55, 0) - self.insmod('inv_cpld') - self.new_i2c_device('inv_eeprom', 0x53, 0) - self.insmod('inv_eeprom') - self.insmod('swps') - #self.insmod('vpd') - self.insmod('inv_pthread') - return True diff --git a/packages/platforms/inventec/x86-64/d7032q28b/.gitignore b/packages/platforms/inventec/x86-64/d7032q28b/.gitignore deleted file mode 100644 index b617fd5a7..000000000 --- a/packages/platforms/inventec/x86-64/d7032q28b/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -*x86*64*inventec*d7032q28b*.mk -onlpdump.mk diff --git a/packages/platforms/inventec/x86-64/d7032q28b/Makefile b/packages/platforms/inventec/x86-64/d7032q28b/Makefile deleted file mode 100644 index 003238cf6..000000000 --- a/packages/platforms/inventec/x86-64/d7032q28b/Makefile +++ /dev/null @@ -1 +0,0 @@ -include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/inventec/x86-64/d7032q28b/modules/Makefile b/packages/platforms/inventec/x86-64/d7032q28b/modules/Makefile deleted file mode 100644 index 003238cf6..000000000 --- a/packages/platforms/inventec/x86-64/d7032q28b/modules/Makefile +++ /dev/null @@ -1 +0,0 @@ -include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/inventec/x86-64/d7032q28b/modules/PKG.yml b/packages/platforms/inventec/x86-64/d7032q28b/modules/PKG.yml deleted file mode 100644 index cad0df038..000000000 --- a/packages/platforms/inventec/x86-64/d7032q28b/modules/PKG.yml +++ /dev/null @@ -1 +0,0 @@ -!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/d7032q28b/modules/builds/.gitignore b/packages/platforms/inventec/x86-64/d7032q28b/modules/builds/.gitignore deleted file mode 100644 index a65b41774..000000000 --- a/packages/platforms/inventec/x86-64/d7032q28b/modules/builds/.gitignore +++ /dev/null @@ -1 +0,0 @@ -lib diff --git a/packages/platforms/inventec/x86-64/d7032q28b/modules/builds/Makefile b/packages/platforms/inventec/x86-64/d7032q28b/modules/builds/Makefile deleted file mode 100644 index 92d0e7f86..000000000 --- a/packages/platforms/inventec/x86-64/d7032q28b/modules/builds/Makefile +++ /dev/null @@ -1,6 +0,0 @@ -KERNELS := onl-kernel-3.16-lts-x86-64-all:amd64 -KMODULES := src -VENDOR := inventec -BASENAME := x86-64-inventec-d7032q28b -ARCH := x86_64 -include $(ONL)/make/kmodule.mk diff --git a/packages/platforms/inventec/x86-64/d7032q28b/modules/builds/src/Makefile b/packages/platforms/inventec/x86-64/d7032q28b/modules/builds/src/Makefile deleted file mode 100644 index c3bb63029..000000000 --- a/packages/platforms/inventec/x86-64/d7032q28b/modules/builds/src/Makefile +++ /dev/null @@ -1,8 +0,0 @@ -obj-m += inv_platform.o -obj-m += inv_cpld.o -obj-m += inv_psoc.o -obj-m += swps.o -swps-objs := inv_swps.o io_expander.o transceiver.o inv_mux.o -obj-m += vpd.o -vpd-objs := inv_vpd.o onie_tlvinfo.o -obj-m += inv_pthread.o diff --git a/packages/platforms/inventec/x86-64/d7032q28b/modules/builds/src/gpio-ich.c b/packages/platforms/inventec/x86-64/d7032q28b/modules/builds/src/gpio-ich.c deleted file mode 100644 index 70304220a..000000000 --- a/packages/platforms/inventec/x86-64/d7032q28b/modules/builds/src/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/d7032q28b/modules/builds/src/inv_cpld.c b/packages/platforms/inventec/x86-64/d7032q28b/modules/builds/src/inv_cpld.c deleted file mode 100644 index 778943870..000000000 --- a/packages/platforms/inventec/x86-64/d7032q28b/modules/builds/src/inv_cpld.c +++ /dev/null @@ -1,569 +0,0 @@ -/* - * 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 "inv_pthread.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 struct device *cpld_led_client_dev = NULL; - -/*-----------------------------------------------------------------------*/ - -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 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 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 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 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 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 == CPLD_DEV_LED_GRN_INDEX)?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; -} - -ssize_t cpld_show_led(char *buf, int index) -{ - u32 status; - struct i2c_client *client = NULL; - struct cpld_data *data = NULL; - u8 byte; - int shift = (index == CPLD_DEV_LED_GRN_INDEX)?3:0; - - if (!cpld_led_client_dev) { - return 0; - } - - client = to_i2c_client(cpld_led_client_dev); - data = i2c_get_clientdata(client); - - 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); -} -EXPORT_SYMBOL(cpld_show_led); - -ssize_t cpld_set_led(const char *buf, size_t count, int index) -{ - struct i2c_client *client = NULL; - struct cpld_data *data = NULL; - - u8 temp = simple_strtol(buf, NULL, 16); - u8 byte; - int shift = (index == CPLD_DEV_LED_GRN_INDEX)?3:0; - - if (!cpld_led_client_dev) { - return 0; - } - - client = to_i2c_client(cpld_led_client_dev); - data = i2c_get_clientdata(client); - - 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; -} -EXPORT_SYMBOL(cpld_set_led); - -ssize_t cpld_show_ctl(char *buf) -{ - u32 status; - struct i2c_client *client = NULL; - struct cpld_data *data = NULL; - u8 b[1]; - - if (!cpld_led_client_dev) { - return 0; - } - - client = to_i2c_client(cpld_led_client_dev); - data = i2c_get_clientdata(client); - - 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); -} -EXPORT_SYMBOL(cpld_show_ctl); - -ssize_t cpld_set_ctl(const char *buf, size_t count) -{ - struct i2c_client *client = NULL; - struct cpld_data *data = NULL; - u8 byte; - u8 temp = simple_strtol(buf, NULL, 10); - - if (!cpld_led_client_dev) { - return 0; - } - - client = to_i2c_client(cpld_led_client_dev); - data = i2c_get_clientdata(client); - - 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; -} -EXPORT_SYMBOL(cpld_set_ctl); - -/* -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, CPLD_DEV_LED_GRN_INDEX); -static SENSOR_DEVICE_ATTR(red_led, S_IWUSR|S_IRUGO, show_led, set_led, CPLD_DEV_LED_RED_INDEX); - -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; - - 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); - - cpld_led_client_dev = &client->dev; - return 0; - -exit_remove: - sysfs_remove_group(&client->dev.kobj, &cpld_group); -exit_free: - i2c_set_clientdata(client, NULL); - kfree(data); - cpld_led_client_dev = NULL; - 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); - cpld_led_client_dev = NULL; - 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/d7032q28b/modules/builds/src/inv_mux.c b/packages/platforms/inventec/x86-64/d7032q28b/modules/builds/src/inv_mux.c deleted file mode 100644 index a0f5ce34b..000000000 --- a/packages/platforms/inventec/x86-64/d7032q28b/modules/builds/src/inv_mux.c +++ /dev/null @@ -1,281 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include "io_expander.h" -#include "inv_mux.h" - -static struct mux_obj_s *mux_head_p = NULL; - - -/* ========== MUX object functions ========== - */ -int -_common_force_pull_gpio(int mem_addr, - int input, - int bit_offset){ - - unsigned int val = 0; - unsigned int targ = 0; - - /* Get current value */ - val = inl(mem_addr); - if (val == 0) { - SWPS_ERR("%s: inl:%d fail!\n", __func__, val); - return -1; - } - /* Count target value */ - switch (input) { - case 0: /* Pull Low */ - targ = (val & (~(1 << bit_offset))); - break; - case 1: /* Pull high */ - targ = (val | (1 << bit_offset)); - break; - default: - SWPS_ERR("%s: input state:%d incorrect!\n", - __func__, input); - return -1; - } - /* Setup gpio */ - outl(targ, mem_addr); - if (targ != inl(mem_addr)){ - SWPS_ERR("%s: outl:%d fail!\n", __func__, targ); - return -1; - } - SWPS_DEBUG("%s: done.\n", __func__); - return 0; -} - - -int -rangeley_force_pull_high(struct mux_obj_s *self){ - SWPS_ERR("%s: not ready!\n", __func__); - return -1; -} - - -int -rangeley_force_pull_low(struct mux_obj_s *self){ - SWPS_ERR("%s: not ready!\n", __func__); - return -1; -} - - -int -hedera_force_pull_high(struct mux_obj_s *self){ - return _common_force_pull_gpio(MUX_RST_MEM_ADDR_HEDERA, 1, 5); -} - - -int -hedera_force_pull_low(struct mux_obj_s *self){ - return _common_force_pull_gpio(MUX_RST_MEM_ADDR_HEDERA, 0, 5); -} - - -int -normal_gpio_pull_high(struct mux_obj_s *self){ - return gpio_direction_output(self->gpio_num, 1); -} - - -int -normal_gpio_pull_low(struct mux_obj_s *self){ - return gpio_direction_output(self->gpio_num, 0); -} - - -int -pca9548_reset_mux_all(struct mux_obj_s *self){ - /* [Note] Power-on reset (PCA9548A-NXP) - * When power is applied to VDD, an internal Power-On Reset (POR) - * holds the PCA9548A in a reset condition until VDD has reached - * VPOR. At this point, the reset condition is released and the - * PCA9548A register and I2C-bus state machine are initialized to - * their default states (all zeroes) causing all the channels to - * be deselected. Thereafter, VDD must be lowered below 0.2 V for - * at least 5 us in order to reset the device. - */ - if (self->_pull_low(self) < 0) { - SWPS_ERR("%s: _pull_low fail!\n", __func__); - return -1; - } - mdelay(MUX_RST_WAIT_MS); - if (self->_pull_high(self) < 0) { - SWPS_ERR("%s: _pull_high fail!\n", __func__); - return -1; - } - mdelay(MUX_RST_WAIT_MS); - return 0; -} - - -int -common_reset_mux_all(struct mux_obj_s *self){ - SWPS_ERR("%s: not ready!\n", __func__); - return -1; -} - - -int -init_gpio_4_force(struct mux_obj_s *self){ - return 0; -} - - -int -init_gpio_4_normal(struct mux_obj_s *self){ - - int err = 0; - - if (!gpio_is_valid(self->gpio_num)) { - SWPS_ERR("%s: GIPO:%d isn't valid\n", __func__, self->gpio_num); - return -1; - } - err = gpio_request(self->gpio_num, MUX_GPIO_LABEL); - if (err < 0) { - SWPS_ERR("%s: gpio_request fail :%d :%d\n", - __func__, err, self->gpio_num); - return -1; - } - SWPS_DEBUG("%s: gpio_request:%d ok.\n", __func__, self->gpio_num); - return 0; -} - - -static int -_setup_muxctl_cb(struct mux_obj_s *self, - unsigned gpio){ - - char *mod_dsc = "ERR"; - - switch (gpio) { - case MUX_RST_GPIO_FORCE_RANGELEY: - self->gpio_num = gpio; - self->_pull_low = rangeley_force_pull_low; - self->_pull_high = rangeley_force_pull_high; - self->_init = init_gpio_4_force; - self->reset = pca9548_reset_mux_all; - mod_dsc = "Rangeley force mode"; - goto ok_setup_muxctl_cb; - - case MUX_RST_GPIO_FORCE_HEDERA: - self->gpio_num = gpio; - self->_pull_low = hedera_force_pull_low; - self->_pull_high = hedera_force_pull_high; - self->_init = init_gpio_4_force; - self->reset = pca9548_reset_mux_all; - mod_dsc = "Hedera force mode"; - goto ok_setup_muxctl_cb; - - case MUX_RST_GPIO_48_PAC9548: - self->gpio_num = gpio; - self->_pull_low = normal_gpio_pull_low; - self->_pull_high = normal_gpio_pull_high; - self->_init = init_gpio_4_normal; - self->reset = pca9548_reset_mux_all; - mod_dsc = "Normal mode :48"; - goto ok_setup_muxctl_cb; - - case MUX_RST_GPIO_69_PAC9548: - self->gpio_num = gpio; - self->_pull_low = normal_gpio_pull_low; - self->_pull_high = normal_gpio_pull_high; - self->_init = init_gpio_4_normal; - self->reset = pca9548_reset_mux_all; - mod_dsc = "Normal mode :69"; - goto ok_setup_muxctl_cb; - - default: - break; - } - SWPS_ERR("%s: Unexpected GPIO:%d\n", __func__, gpio); - return -1; - -ok_setup_muxctl_cb: - SWPS_INFO("muxctl: %s.\n", mod_dsc); - return 0; -} - - -/* ========== MUX public functions ========== - */ -void -clean_mux_gpio(void){ - - if (!mux_head_p) { - SWPS_DEBUG("%s: mux_head_p is NULL\n", __func__); - return; - } - if (gpio_is_valid(mux_head_p->gpio_num)) { - gpio_free(mux_head_p->gpio_num); - } - kfree(mux_head_p); - mux_head_p = NULL; - SWPS_DEBUG("%s: done.\n", __func__); -} -EXPORT_SYMBOL(clean_mux_gpio); - - -int -reset_mux_gpio(void){ - - if (!mux_head_p) { - SWPS_ERR("%s: MUX ctl object doesn't exist!\n", __func__); - return -1; - } - if (mux_head_p->reset(mux_head_p) < 0){ - SWPS_ERR("%s: reset fail!\n", __func__); - return -1; - } - return 0; -} -EXPORT_SYMBOL(reset_mux_gpio); - - -int -init_mux_gpio(unsigned gpio){ - - /* Create MUX control object */ - if (mux_head_p) { - SWPS_DEBUG("%s: mux_head_p is not NULL!\n", __func__); - clean_mux_gpio(); - } - /* Currently, it is using single muxctl architecture. - * In the future, it may use the multi-muxctl if HW add new features. - * (Ex: Port power-status control) - */ - mux_head_p = kzalloc(sizeof(struct mux_obj_s), GFP_KERNEL); - if (!mux_head_p) { - SWPS_ERR("%s: kzalloc fail!\n", __func__); - return -1; - } - /* Initial MUX controller */ - if (_setup_muxctl_cb(mux_head_p, gpio) < 0){ - SWPS_ERR("%s: _setup_muxctl_cb fail!\n", __func__); - return -1; - } - if (mux_head_p->_init(mux_head_p) < 0) { - SWPS_ERR("%s: init() fail\n", __func__); - goto err_init_mux_gpio; - } - /* Setup default value */ - if (mux_head_p->_pull_high(mux_head_p) < 0) { - SWPS_ERR("%s: setup default fail!\n", __func__); - goto err_init_mux_gpio; - } - return 0; - -err_init_mux_gpio: - clean_mux_gpio(); - return -1; -} -EXPORT_SYMBOL(init_mux_gpio); - - - -MODULE_LICENSE("GPL"); - diff --git a/packages/platforms/inventec/x86-64/d7032q28b/modules/builds/src/inv_mux.h b/packages/platforms/inventec/x86-64/d7032q28b/modules/builds/src/inv_mux.h deleted file mode 100644 index 429754a8c..000000000 --- a/packages/platforms/inventec/x86-64/d7032q28b/modules/builds/src/inv_mux.h +++ /dev/null @@ -1,36 +0,0 @@ -#ifndef INV_MUX_H -#define INV_MUX_H - - -/* MUX basic information */ -#define MUX_GPIO_LABEL "SWPS_RST_MUX" - -/* MUX reset GPIO define */ -#define MUX_RST_GPIO_FORCE (30100) -#define MUX_RST_GPIO_FORCE_RANGELEY (30101) -#define MUX_RST_GPIO_FORCE_HEDERA (30102) -#define MUX_RST_GPIO_48_PAC9548 (48) -#define MUX_RST_GPIO_69_PAC9548 (69) - -/* MUX relate value define */ -#define MUX_RST_WAIT_MS (1) -#define MUX_RST_MEM_ADDR_RANGELEY (0) // TBD -#define MUX_RST_MEM_ADDR_HEDERA (0x548) - -struct mux_obj_s { - unsigned gpio_num; - int (*_pull_high)(struct mux_obj_s *self); - int (*_pull_low)(struct mux_obj_s *self); - int (*_init)(struct mux_obj_s *self); - int (*reset)(struct mux_obj_s *self); -}; - - -void clean_mux_gpio(void); -int reset_mux_gpio(void); -int init_mux_gpio(unsigned gpio); - - -#endif /* INV_MUX_H */ - - diff --git a/packages/platforms/inventec/x86-64/d7032q28b/modules/builds/src/inv_platform.c b/packages/platforms/inventec/x86-64/d7032q28b/modules/builds/src/inv_platform.c deleted file mode 100644 index cc31f1fb2..000000000 --- a/packages/platforms/inventec/x86-64/d7032q28b/modules/builds/src/inv_platform.c +++ /dev/null @@ -1,143 +0,0 @@ -#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 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"); - - for(i=0; i -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define USE_SMBUS 1 - -#define FAN_NUM 5 -#define PSU_NUM 2 - -static struct device *psoc_led_client_dev = NULL; - -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 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 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 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 unsigned char psu1_data_model[32], psu2_data_model[32]; -static unsigned char psu1_data_sn[32], psu2_data_sn[32]; -static struct mutex psu_data_lock; - -static int psoc_i2c_bridge_read(struct i2c_client *client, - unsigned char bus, - unsigned char chip, - unsigned char *addr, - int alen, - unsigned char *data, - int len ) -{ - unsigned char txdata[28], rxdata[28]; - int index, timeout; - unsigned char *inv_data; - - 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]; - } - - if (*addr == PMBUS_MFR_MODEL) { - if (chip == 0x58) { - inv_data = &psu1_data_model[0]; - } - else - if (chip == 0x59) { - inv_data = &psu2_data_model[0]; - } - else { - inv_data = NULL; - } - } - else - if (*addr == PMBUS_MFR_SERIAL) { - if (chip == 0x58) { - inv_data = &psu1_data_sn[0]; - } - else - if (chip == 0x59) { - inv_data = &psu2_data_sn[0]; - } - else { - inv_data = NULL; - } - } - else { - inv_data = NULL; - } - - if (inv_data) { - mutex_lock(&psu_data_lock); - memset(inv_data, 0, 32); - for(index=0; index < len; index++) { - inv_data[index] = data[index]; - } - inv_data[index] = '\0'; - mutex_unlock(&psu_data_lock); - } - - 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); -} - -static ssize_t psoc_show_psu_st(char *buf, int psu_index) -{ - u32 status; - struct i2c_client *client = NULL; - struct psoc_data *data = NULL; - u8 byte; - int shift = (psu_index == 0)?3:0; - - if (!psoc_led_client_dev) { - return 0; - } - - client = to_i2c_client(psoc_led_client_dev); - data = i2c_get_clientdata(client); - - 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); -} - -ssize_t psoc_show_psu_state(char *buf, int index) -{ - return psoc_show_psu_st(buf, index); -} -EXPORT_SYMBOL(psoc_show_psu_state); - -/*-----------------------------------------------------------------------*/ - -/* 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_read16(client, offset); - mutex_unlock(&data->update_lock); - - return sprintf(buf, "%d\n", - status); -} - -ssize_t psoc_show_fan_input(char *buf, int index) -{ - return psoc_show_rpm(buf, index); -} -EXPORT_SYMBOL(psoc_show_fan_input); - -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); - 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 ; - - 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 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 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 ); -} - -ssize_t psoc_show_value8(char *buf, int offset) -{ - int status; - struct i2c_client *client = NULL; - struct psoc_data *data = NULL; - - if (!psoc_led_client_dev) { - return 0; - } - - client = to_i2c_client(psoc_led_client_dev); - data = i2c_get_clientdata(client); - - mutex_lock(&data->update_lock); - status = psoc_read8(client, offset); - mutex_unlock(&data->update_lock); - - return sprintf(buf, "0x%02X\n", status ); -} - -static char prev_fan_state[8] = { 0 }; - -ssize_t psoc_show_fan_state(char *buf) -{ - int i; - int rv = psoc_show_value8(buf, FAN_GPI_OFFSET); - for (i = 0; i < 3; i++) { - if (strncmp(prev_fan_state, buf, 4) == 0) { - return rv; - } - msleep(500); - rv = psoc_show_value8(buf, FAN_GPI_OFFSET); - } - strcpy(prev_fan_state, buf); - return rv; -} -EXPORT_SYMBOL(psoc_show_fan_state); - -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]; - - 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_psu1_model(struct device *dev, struct device_attribute *da, - char *buf) -{ - ssize_t ret; - - mutex_lock(&psu_data_lock); - ret = sprintf(buf, "%s\n", psu1_data_model); - mutex_unlock(&psu_data_lock); - return ret; -} - -static ssize_t show_psu1_sn(struct device *dev, struct device_attribute *da, - char *buf) -{ - ssize_t ret; - - mutex_lock(&psu_data_lock); - ret = sprintf(buf, "%s\n", psu1_data_sn); - mutex_unlock(&psu_data_lock); - return ret; -} - -static ssize_t show_psu2_model(struct device *dev, struct device_attribute *da, - char *buf) -{ - ssize_t ret; - - mutex_lock(&psu_data_lock); - ret = sprintf(buf, "%s\n", psu2_data_model); - mutex_unlock(&psu_data_lock); - return ret; -} - -static ssize_t show_psu2_sn(struct device *dev, struct device_attribute *da, - char *buf) -{ - ssize_t ret; - - mutex_lock(&psu_data_lock); - ret = sprintf(buf, "%s\n", psu2_data_sn); - mutex_unlock(&psu_data_lock); - return ret; -} - -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 ssize_t psoc_show_psu_psoc(char *buf, int psu_index, char *attr_name) -{ - u16 status; - struct i2c_client *client = NULL; - struct psoc_data *data = NULL; - u8 offset = psu_index + PSU_INFO_OFFSET; - - if (!psoc_led_client_dev) { - return 0; - } - - client = to_i2c_client(psoc_led_client_dev); - data = i2c_get_clientdata(client); - - 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_name, "vout")? 1:0 )); -} - -ssize_t psoc_show_psu_vin(char *buf, int index) -{ - return psoc_show_psu_psoc(buf, index, "vin"); -} -EXPORT_SYMBOL(psoc_show_psu_vin); - -ssize_t psoc_show_diag(char *buf) -{ - u16 status; - struct i2c_client *client = NULL; - struct psoc_data *data = NULL; - u8 diag_flag = 0; - - if (!psoc_led_client_dev) { - return 0; - } - - client = to_i2c_client(psoc_led_client_dev); - data = i2c_get_clientdata(client); - - 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); -} -EXPORT_SYMBOL(psoc_show_diag); - -ssize_t psoc_set_diag(const char *buf, size_t count) -{ - struct i2c_client *client = NULL; - struct psoc_data *data = NULL; - u8 value = 0; - u8 diag = simple_strtol(buf, NULL, 10); - - if (!psoc_led_client_dev) { - return 0; - } - - client = to_i2c_client(psoc_led_client_dev); - data = i2c_get_clientdata(client); - - 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; -} -EXPORT_SYMBOL(psoc_set_diag); - - -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); -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); -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(psu1_model2, S_IRUGO, show_psu1_model, 0, (1<<16) | (0<<8) | PMBUS_MFR_MODEL); -static SENSOR_DEVICE_ATTR(psu1_sn2, S_IRUGO, show_psu1_sn, 0, (1<<16) | (0<<8) | PMBUS_MFR_SERIAL); -static SENSOR_DEVICE_ATTR(psu2_model2, S_IRUGO, show_psu2_model, 0, (1<<16) | (0<<8) | PMBUS_MFR_MODEL); -static SENSOR_DEVICE_ATTR(psu2_sn2, S_IRUGO, show_psu2_sn, 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, - &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, - - //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_psu1_model2.dev_attr.attr, - &sensor_dev_attr_psu1_sn2.dev_attr.attr, - &sensor_dev_attr_psu2_model2.dev_attr.attr, - &sensor_dev_attr_psu2_sn2.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; - - 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; - - mutex_init(&psu_data_lock); - - /* 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); - - psoc_led_client_dev = &client->dev; - - return 0; - -exit_remove: - sysfs_remove_group(&client->dev.kobj, &psoc_group); -exit_free: - i2c_set_clientdata(client, NULL); - kfree(data); - psoc_led_client_dev = NULL; - 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); - psoc_led_client_dev = NULL; - 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/d7032q28b/modules/builds/src/inv_pthread.c b/packages/platforms/inventec/x86-64/d7032q28b/modules/builds/src/inv_pthread.c deleted file mode 100644 index d1f67d449..000000000 --- a/packages/platforms/inventec/x86-64/d7032q28b/modules/builds/src/inv_pthread.c +++ /dev/null @@ -1,884 +0,0 @@ -/***************************** - Redwood (d7032q28b) platform -******************************/ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "inv_pthread.h" - -#define INV_PTHREAD_KERNEL_MODULE - -#define SHOW_ATTR_WARNING ("N/A") -#define SHOW_ATTR_NOTPRINT ("Not Available") -#define SHOW_ATTR_NOTSUPPORT ("Not Support") - -#define INV_HWMID_MAX (10) -#define INV_HWMID_INIT (-1) - -/*access userspace data to kernel space*/ -#define ACC_R (0) -#define ACC_W (1) - -#define MAX_PATH_SIZE (64) -#define MIN_ACC_SIZE (32) -#define MAX_ACC_SIZE (256) - -/* - * LED definitions - */ -#define STATUS_LED_MODE_AUTO (0) -#define STATUS_LED_MODE_DIAG (1) -#define STATUS_LED_MODE_MANU (2) -#define STATUS_LED_MODE_ERR (-1) - -#define STATUS_LED_GRN0 (10) // 0 - 000: off -#define STATUS_LED_GRN1 (11) // 1 - 001: 0.5hz -#define STATUS_LED_GRN2 (12) // 2 - 010: 1 hz -#define STATUS_LED_GRN3 (13) // 3 - 011: 2 hz -#define STATUS_LED_GRN7 (17) // 7 - 111: on -#define STATUS_LED_RED0 (20) // 0 - 000: off -#define STATUS_LED_RED1 (21) // 1 - 001: 0.5hz -#define STATUS_LED_RED2 (22) // 2 - 010: 1 hz -#define STATUS_LED_RED3 (23) // 3 - 011: 2 hz -#define STATUS_LED_RED7 (27) // 7 - 111: on -#define STATUS_LED_INVALID (0) // Invalid - -static struct mutex pthread_mutex; - -ssize_t status_led_grn(const char *freq); -ssize_t status_led_red(const char *freq); -ssize_t status_led_diag_mode_enable(void); -ssize_t status_led_diag_mode_disable(void); -int status_led_check_color(void); -int status_led_check_diag_mode(void); - -#if 1 -/* For timestamps in SYSFS_LOG */ -#define SYSFS_LOG printk -#else -//#define SYSFS_LOG(fmt, args...) printk(KERN_WARNING "[SYSFS] %s/%d: " fmt, __func__, __LINE__, ##args) -#define SYSFS_LOG(fmt, args...) printk(KERN_WARNING "[p_thread] " fmt, ##args) -#endif - - -/* inventec_class *********************************/ -static struct kobject *status_kobj; -static struct kset *status_kset; - -#if 0 -int inventec_strtol(const char *sbufp, char **endp, unsigned int base) -{ - char *endptr; - int value = simple_strtol(sbufp, &endptr, base); - if (value == 0 && sbufp == endptr) { - *endp = NULL; - return value; - } - *endp = (char*)1; - return value; -} -#endif - -int inventec_singlechar_to_int(const char c) -{ - if ((c >= '0') && (c <= '9')) { - return (c - '0'); - } - else - if ((c >= 'a') && (c <= 'f')) { - return (c - 'a' + 10); - } - else - if ((c >= 'A') && (c <= 'F')) { - return (c - 'A' + 10); - } - return -1; -} - -/* fan device *************************************/ -#define FAN_STATE_NORMAL "normal" -#define FAN_STATE_FAULTY "faulty" -#define FAN_STATE_UNINSTALLED "uninstalled" -#define FAN_STATE_UNKNOW "unknown state" -#define FAN_STATE_INVALID "Invalid state value" -#define FAN_STATE_READ_ERROR "state read error" - -#define FAN_LOG_UNINSTALLED "removed" -#define FAN_LOG_NORMAL "inserted" - -//#define FAN_STATE_BIT_NORMAL 0 -#define FAN_STATE_BIT_FAULTY 0 -#define FAN_STATE_BIT_UNINSTALLED 1 -#define FAN_STATE_BIT_UNKNOW 2 -#define FAN_STATE_BIT_INVALID 3 -#define FAN_STATE_BIT_READ_ERROR 4 - -static ssize_t psoc_show_fan1_input(char *buf) -{ - return psoc_show_fan_input(buf, 1); -} - -static ssize_t psoc_show_fan2_input(char *buf) -{ - return psoc_show_fan_input(buf, 2); -} - -static ssize_t psoc_show_fan3_input(char *buf) -{ - return psoc_show_fan_input(buf, 3); -} - -static ssize_t psoc_show_fan4_input(char *buf) -{ - return psoc_show_fan_input(buf, 4); -} - -static ssize_t psoc_show_fan5_input(char *buf) -{ - return psoc_show_fan_input(buf, 5); -} - -static ssize_t psoc_show_fan6_input(char *buf) -{ - return psoc_show_fan_input(buf, 6); -} - -static ssize_t psoc_show_fan7_input(char *buf) -{ - return psoc_show_fan_input(buf, 7); -} - -static ssize_t psoc_show_fan8_input(char *buf) -{ - return psoc_show_fan_input(buf, 8); -} - -static struct fans_tbl_s { - char *fan_name; - ssize_t (*fan_front)(char *); - ssize_t (*fan_rear)(char *); - unsigned int fan_state; -} fans_tbl[] = { - {"fan1", psoc_show_fan1_input, - psoc_show_fan2_input, 0}, - {"fan2", psoc_show_fan3_input, - psoc_show_fan4_input, 0}, - {"fan3", psoc_show_fan5_input, - psoc_show_fan6_input, 0}, - {"fan4", psoc_show_fan7_input, - psoc_show_fan8_input, 0}, -}; -#define FAN_TBL_TOTAL ( sizeof(fans_tbl)/ sizeof(const struct fans_tbl_s) ) - -#define FAN_STATE_CHECK(i,b) (fans_tbl[i].fan_state & (1<inv_dev_attrp, PSU_ATTR_VOLTIN, PSU_ATTR_VOLTIN_LEN) == 0) { - invwirep = psu_get_show_function(PSU_ATTR_VOLTIN, psu_dev_group[i].psu_name, NULL); - if (invwirep == NULL) { - printk(KERN_DEBUG "[p_thread] Invalid psuname: %s\n", psu_dev_group[i].psu_name); - continue; - } - if (invwirep(volt) <= 0) { - printk(KERN_DEBUG "[p_thread] Read %s failed\n", psu_dev_group[i].psu_name); - continue; - } - else { - voltin = simple_strtol(&volt[0], NULL, 10); - printk(KERN_DEBUG "[p_thread] Read %s %s = %u\n",psu_dev_group[i].psu_name,volt,voltin); - if (voltin > psu_voltin) { - psu_voltin = voltin; - } - } - } - } - } - - SYSFS_LOG("[p_thread] PSU voltin = %u\n", psu_voltin); -} - -#define PSU_ATTR_STATE ("state") -#define PSU_ATTR_STATE_LEN (5) - -/* psus_control() by inv_thread */ -int psus_control(int log_only) -{ - char state[MIN_ACC_SIZE]; - psu_dev_t *devnamep = NULL; - ssize_t (*invwirep)(char *buf) = NULL; - char *psu_statep = NULL; - int i, j, flag = 0; - - for (i = 0; i < PSU_DEV_GROUP_TOTAL; i++) { - devnamep = psu_dev_group[i].psu_dev_namep; - for (j = 0; j < psu_dev_group[i].psu_dev_total; j++, devnamep++) { - if (strncmp(devnamep->inv_dev_attrp, PSU_ATTR_STATE, PSU_ATTR_STATE_LEN) == 0) { - invwirep = psu_get_show_function(PSU_ATTR_STATE, psu_dev_group[i].psu_name, &psu_statep); - if (invwirep == NULL) { - printk(KERN_DEBUG "[p_thread] Invalid psuname: %s\n", psu_dev_group[i].psu_name); - continue; - } - if (invwirep(state) <= 0) { - printk(KERN_DEBUG "[p_thread] Read %s failed\n", psu_dev_group[i].psu_name); - if (strncmp(psu_statep, PSU_STATE_ERROR, strlen(PSU_STATE_ERROR)) != 0) { - strcpy(psu_statep, PSU_STATE_ERROR); - SYSFS_LOG("[p_thread] %s: %s\n",psu_dev_group[i].psu_name,PSU_STATE_ERROR); - } - flag = 1; - } - else - if (strstr(state, "normal")) { - if (strncmp(psu_statep, state, strlen(state)) != 0) { - strcpy(psu_statep, state); - SYSFS_LOG("[p_thread] %s: %s\n",psu_dev_group[i].psu_name,state); - } - } - else - if (psu_voltin > PSU_VOLTIN_ACDC) { /* AC PSUS */ - if (strncmp(psu_statep, state, strlen(state)) != 0) { - strcpy(psu_statep, state); - SYSFS_LOG("[p_thread] %s: %s\n",psu_dev_group[i].psu_name,state); - } - flag = 1; - } - else { /* DC PSUS */ - if (strncmp(psu_statep, PSU_STATE_CHECKPSU, PSU_STATE_LEN_CHECKPSU) != 0) { - strcpy(psu_statep, PSU_STATE_CHECKPSU); - SYSFS_LOG("[p_thread] %s: %s\n",psu_dev_group[i].psu_name,PSU_STATE_CHECKPSU); - } - flag = 1; - } - } - } - } - - if (log_only) { - return 0; - } - - //SYSFS_LOG("[p_thread] RYU: %s: flag = %d\n",psu_wire_tbl[i].psu_name,flag); - if (flag == 1) { - status_led_grn("2"); - return 1; - } - return 0; -} - -/* End of psuinfo_device */ - -/* led device *************************************/ - -/* return 0/off 1/green 2/red */ -int -status_led_check_color(void) -{ - char tmpbuf[MIN_ACC_SIZE]; - int ret = STATUS_LED_INVALID; - - if (cpld_show_led(&tmpbuf[0], CPLD_DEV_LED_GRN_INDEX) > 0) { - if (tmpbuf[0] == '0') { - ret = STATUS_LED_GRN0; - } - if (tmpbuf[0] == '1') { - ret = STATUS_LED_GRN1; - } - if (tmpbuf[0] == '2') { - ret = STATUS_LED_GRN2; - } - if (tmpbuf[0] == '3') { - ret = STATUS_LED_GRN3; - } - if (tmpbuf[0] == '7') { - ret = STATUS_LED_GRN7; - } - return ret; - } - - if (cpld_show_led(&tmpbuf[0], CPLD_DEV_LED_RED_INDEX) > 0) { - if (tmpbuf[0] == '0') { - ret = STATUS_LED_RED0; - } - if (tmpbuf[0] == '1') { - ret = STATUS_LED_RED1; - } - if (tmpbuf[0] == '2') { - ret = STATUS_LED_RED2; - } - if (tmpbuf[0] == '3') { - ret = STATUS_LED_RED3; - } - if (tmpbuf[0] == '7') { - ret = STATUS_LED_RED7; - } - return ret; - } - return ret; -} - -/* - * Store attr Section - */ -ssize_t status_led_diag_mode_enable(void) -{ - char tmp[MIN_ACC_SIZE]; - ssize_t ret; - - ret = psoc_show_diag(&tmp[0]); - if (ret <= 0) { - return ret; - } - - if (tmp[0] == '0') { - ret = psoc_set_diag("1", 1); - if (ret < 0) { - return ret; - } - - ret = cpld_set_ctl("1", 1); - if (ret < 0) { - return ret; - } - } - - return ret; -} - -ssize_t status_led_diag_mode_disable(void) -{ - char tmp[MIN_ACC_SIZE]; - ssize_t ret; - - ret = psoc_show_diag(&tmp[0]); - if (ret <= 0) { - return ret; - } - - if (tmp[0] == '1') { - ret = psoc_set_diag("0", 1); - if (ret < 0) { - return 1; - } - - ret = cpld_set_ctl("1", 1); - if (ret < 0) { - return 1; - } - } - return 1; -} - -ssize_t -status_led_red(const char *freq) -{ - char buf[MIN_ACC_SIZE]; - ssize_t ret; - - ret = cpld_show_led(buf, CPLD_DEV_LED_RED_INDEX); - if (ret < 0 || buf[0] == freq[0]) { - return ret; - } - - ret = cpld_set_led("0", 1, CPLD_DEV_LED_GRN_INDEX); - if (ret < 0) { - return ret; - } - ret = cpld_set_led(freq, strlen(freq), CPLD_DEV_LED_RED_INDEX); - if (ret < 0) { - return ret; - } - if ((ret = status_led_diag_mode_enable()) <= 0) { - return ret; - } - ssleep(1); - if ((ret = status_led_diag_mode_disable()) <= 0) { - return ret; - } - return ret; -} - -ssize_t -status_led_grn(const char *freq) -{ - char buf[MIN_ACC_SIZE]; - ssize_t ret; - - ret = cpld_show_led(buf, CPLD_DEV_LED_GRN_INDEX); - if (ret < 0 || buf[0] == freq[0]) { - return ret; - } - - ret = cpld_set_led("0", 1, CPLD_DEV_LED_RED_INDEX); - if (ret < 0) { - return ret; - } - ssleep(1); - ret = cpld_set_led(freq, strlen(freq), CPLD_DEV_LED_GRN_INDEX); - if (ret < 0) { - return ret; - } - if ((ret = status_led_diag_mode_enable()) <= 0) { - return ret; - } - ssleep(1); - if ((ret = status_led_diag_mode_disable()) <= 0) { - return ret; - } - return ret; -} - -int status_led_check_diag_mode(void) -{ - char tmp[MIN_ACC_SIZE]; - ssize_t ret; - - ret = psoc_show_diag(&tmp[0]); - if (ret <= 0) { - return ret; - } - - if (tmp[0] == '1') { - return STATUS_LED_MODE_DIAG; - } - - if (tmp[0] == '0') { - return STATUS_LED_MODE_AUTO; - } - - return -1; -} - -/* End of ledinfo_device */ - -/**************************************************/ -/* From system_device */ -static int inv_pthread_control = 1; - -int thread_control(void) -{ - return inv_pthread_control; -} - -void thread_control_set(int val) -{ - inv_pthread_control = val; -} -/* End system_device */ - -#define THREAD_SLEEP_MINS (3) -#define THREAD_DELAY_MINS (THREAD_SLEEP_MINS + THREAD_SLEEP_MINS + 1) - -static struct task_struct *thread_st; -static int thread_data; - -// Function executed by kernel thread -static int thread_fn(void *unused) -{ - mutex_init(&pthread_mutex); - - ssleep(THREAD_DELAY_MINS); - - /* Default status init */ - mutex_lock(&pthread_mutex); - status_led_grn("7"); - mutex_unlock(&pthread_mutex); - - psu_get_voltin(); - - /* Delay for guarantee HW ready */ - ssleep(THREAD_DELAY_MINS); - - while (1) - { - mutex_unlock(&pthread_mutex); - ssleep(THREAD_SLEEP_MINS); - - if (thread_control() == 0) { - printk(KERN_INFO "[p_thread] %s/%d: Thread Stop by inv_pthread control\n",__func__,__LINE__); - break; - } - - mutex_lock(&pthread_mutex); - if (status_led_check_diag_mode() == STATUS_LED_MODE_MANU) { - /* status led in change color/freq mode, higher priority. Ignore fans sttaus */ - continue; - } - -#if 0 - switch_temp_update(); -#endif - - if (fans_control() > 0) { - psus_control(1); - continue; - } - else - if (psus_control(0) > 0) { - continue; - } - - if (status_led_check_color() != STATUS_LED_GRN7) { /* status led red, change it to green */ - status_led_grn("7"); - } - } - - do_exit(0); - printk(KERN_INFO "[p_thread] %s/%d: Thread Stopped\n",__func__,__LINE__); - return 0; -} - - -static ssize_t s_show(struct kobject *kobj, struct attribute *attr, char *buf) -{ - int fan_absence; - size_t count = 0; - - fan_absence = fans_control(); - count += sprintf(&buf[count], "%d\n", fan_absence); - return count; -} - -static ssize_t s_store(struct kobject *kobj, struct attribute *attr, const char *buf, size_t count) -{ - return count; -} - -static struct attribute status_att = { - .name = "fan_absence", - .mode = 0777, -}; - -static const struct sysfs_ops status_ops = { - .show = s_show, - .store = s_store, -}; - -static struct kobj_type status_ktype = { - .sysfs_ops = &status_ops, -}; - - -static int __init inv_pthread_init(void) -{ - int retval; - - status_kobj = kzalloc(sizeof(*status_kobj), GFP_KERNEL); - if(!status_kobj) - return PTR_ERR(status_kobj); - - status_kset = kset_create_and_add("platform_status", NULL, kernel_kobj); - if(!status_kset) - return -1; - - status_kobj->kset = status_kset; - - retval = kobject_init_and_add(status_kobj, &status_ktype, NULL, "fan"); - if(retval) - return retval; - - retval = sysfs_create_file(status_kobj, &status_att); - - thread_control_set(1); - - printk(KERN_INFO "[p_thread] %s/%d: Creating Thread\n",__func__,__LINE__); - //Create the kernel thread with name 'inv_pthread' - thread_st = kthread_run(thread_fn, (void*)&thread_data, "inv_pthread"); - if (thread_st) - printk(KERN_INFO "[p_thread] inv_pthread Created successfully\n"); - else - printk(KERN_ERR "[p_thread] inv_pthread creation failed\n"); - - return retval; -} - -static void __exit inv_pthread_exit(void) -{ - thread_control_set(0); - /* Delay for guarantee thread exit */ - ssleep(THREAD_DELAY_MINS); - - sysfs_remove_file(status_kobj, &status_att); - kset_unregister(status_kset); - kobject_del(status_kobj); - - printk(KERN_INFO "[p_thread] inv_pthread cleaning Up\n"); -} - -module_init(inv_pthread_init); -module_exit(inv_pthread_exit); - -MODULE_AUTHOR("Robert "); -MODULE_DESCRIPTION("Inventec Platform Management Thread"); -MODULE_VERSION("version 1.1"); -MODULE_LICENSE("GPL"); diff --git a/packages/platforms/inventec/x86-64/d7032q28b/modules/builds/src/inv_pthread.h b/packages/platforms/inventec/x86-64/d7032q28b/modules/builds/src/inv_pthread.h deleted file mode 100644 index c3b7ce830..000000000 --- a/packages/platforms/inventec/x86-64/d7032q28b/modules/builds/src/inv_pthread.h +++ /dev/null @@ -1,19 +0,0 @@ -#ifndef INV_PTHREAD_H -#define INV_PTHREAD_H - -#define CPLD_DEV_LED_GRN_INDEX (0) -#define CPLD_DEV_LED_RED_INDEX (1) - -ssize_t cpld_show_led(char *buf, int index); -ssize_t cpld_set_led(const char *buf, size_t count, int index); -ssize_t cpld_show_ctl(char *buf); -ssize_t cpld_set_ctl(const char *buf, size_t count); - -ssize_t psoc_show_psu_state(char *buf, int index); -ssize_t psoc_show_fan_input(char *buf, int index); -ssize_t psoc_show_fan_state(char *buf); -ssize_t psoc_show_psu_vin(char *buf, int index); -ssize_t psoc_show_diag(char *buf); -ssize_t psoc_set_diag(const char *buf, size_t count); - -#endif /* INV_PTHREAD_H */ diff --git a/packages/platforms/inventec/x86-64/d7032q28b/modules/builds/src/inv_swps.c b/packages/platforms/inventec/x86-64/d7032q28b/modules/builds/src/inv_swps.c deleted file mode 100644 index 015fefc19..000000000 --- a/packages/platforms/inventec/x86-64/d7032q28b/modules/builds/src/inv_swps.c +++ /dev/null @@ -1,3009 +0,0 @@ -/************************************************************************* - * - * inv_swps.c - * - * 2018 Inventec Corporation - * All Rights Reserved. - * - * NOTICE: All information contained herein is, and remains - * the property of Inventec Corp. and its suppliers, - * if any. The intellectual and technical concepts contained - * herein are proprietary to Inventec Corporation and its suppliers - * and may be covered by U.S. and Foreign Patents, patents in process, - * and are protected by trade secret or copyright law. - * - ************************************************************************/ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "inv_swps.h" - -static int ctl_major; -static int port_major; -static int ioexp_total; -static int port_total; -static int auto_config; -static int flag_i2c_reset; -static int flag_mod_state; -static unsigned gpio_rest_mux; -static struct class *swp_class_p = NULL; -static struct inv_platform_s *platform_p = NULL; -static struct inv_ioexp_layout_s *ioexp_layout = NULL; -static struct inv_port_layout_s *port_layout = NULL; - -static void swp_polling_worker(struct work_struct *work); -static DECLARE_DELAYED_WORK(swp_polling, swp_polling_worker); - -static int reset_i2c_topology(void); - -static unsigned int eeprom_update = 0; - -static int -__swp_match(struct device *dev, -#ifdef SWPS_KERN_VER_AF_3_10 - - const void *data){ -#else - void *data){ -#endif - - char *name = (char *)data; - if (strcmp(dev_name(dev), name) == 0) - return 1; - return 0; -} - - -struct device * -get_swpdev_by_name(char *name){ - struct device *dev = class_find_device(swp_class_p, - NULL, - name, - __swp_match); - return dev; -} - - -static int -sscanf_2_int(const char *buf) { - - int result = -EBFONT; - char *hex_tag = "0x"; - - if (strcspn(buf, hex_tag) == 0) { - if (sscanf(buf,"%x",&result)) { - return result; - } - } else { - if (sscanf(buf,"%d",&result)) { - return result; - } - if(sscanf(buf,"-%d",&result)) { - return -result; - } - if (sscanf(buf,"%x",&result)) { - return result; - } - } - return -EBFONT; -} - -static unsigned int -sscanf_2_uint(const char *buf) { - - unsigned int result = -EBFONT; - char *hex_tag = "0x"; - - if (strcspn(buf, hex_tag) == 0) { - if (sscanf(buf,"%x",&result)) { - return result; - } - } else { - if (sscanf(buf,"%u",&result)) { - return result; - } - if (sscanf(buf,"%x",&result)) { - return result; - } - } - return -EBFONT; -} - - -static int -sscanf_2_binary(const char *buf) { - - int result = sscanf_2_int(buf); - - if (result < 0){ - return -EBFONT; - } - switch (result) { - case 0: - case 1: - return result; - default: - break; - } - return -EBFONT; -} - - -static int -_get_polling_period(void) { - - int retval = 0; - - if (SWP_POLLING_PERIOD == 0) { - return 0; - } - retval = ((SWP_POLLING_PERIOD * HZ) / 1000); - if (retval == 0) { - return 1; - } - return retval; -} - - -static struct transvr_obj_s * -_get_transvr_obj(char *dev_name) { - - struct device *dev_p = NULL; - struct transvr_obj_s *transvr_obj_p = NULL; - - dev_p = get_swpdev_by_name(dev_name); - if (!dev_p){ - return NULL; - } - transvr_obj_p = dev_get_drvdata(dev_p); - if (!transvr_obj_p){ - return NULL; - } - return transvr_obj_p; -} - - -static void -unlock_tobj_all(void) { - - struct transvr_obj_s *tobj_p; - char port_name[32]; - int port_id = 0; - int minor_curr = 0; - - for (minor_curr=0; minor_currauto_config = auto_config; - unlock_transvr_obj(tobj_p); - SWPS_DEBUG("%s: Set %s auto_config=%d\n", - __func__, tobj_p->swp_name, auto_config); - } - return retval; -} - -unsigned int -get_eeprom_update(void) -{ - return eeprom_update; -} - -void -set_eeprom_update(unsigned int value) -{ - eeprom_update = value; -} - -/* ========== R/W Functions module control attribute ========== - */ -static ssize_t -show_attr_platform(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - return snprintf(buf_p, 32, "%s\n", platform_p->name); -} - - -static ssize_t -show_attr_version(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - return snprintf(buf_p, 8, "%s\n", SWP_VERSION); -} - - -static ssize_t -show_attr_status(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - return snprintf(buf_p, 8, "%d\n", flag_mod_state); -} - - -static ssize_t -show_attr_auto_config(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - return snprintf(buf_p, 8, "%d\n", auto_config); -} - -static ssize_t -show_attr_eeprom_update(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - return snprintf(buf_p, 10, "%08x\n", eeprom_update); -} - - -static int -_check_reset_pwd(const char *buf_p, - size_t count) { - - int in_max = 64; - int in_len = (int)count; - char in_val[64] = "ERR"; - char *emsg = "ERR"; - - if (in_len >= in_max) { - emsg = "input too much"; - goto err_check_reset_pwd; - } - if (!sscanf(buf_p,"%s",in_val)) { - emsg = "format incorrect"; - goto err_check_reset_pwd; - } - if (strcmp(in_val, SWP_RESET_PWD) != 0) { - emsg = "password incorrect"; - goto err_check_reset_pwd; - } - return 0; - -err_check_reset_pwd: - SWPS_ERR("%s: %s\n", __func__, emsg); - return -1; -} - - -static ssize_t -store_attr_reset_i2c(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - - if (_check_reset_pwd(buf_p, count) < 0) { - return -EBFONT; - } - /* Polling mode */ - if (SWP_POLLING_ENABLE) { - SWPS_INFO("%s: reset I2C :polling\n", __func__); - flag_i2c_reset = 1; - return count; - } - /* Direct mode */ - SWPS_INFO("%s: reset I2C go. :direct\n", __func__); - if (reset_i2c_topology() < 0) { - SWPS_ERR("%s: reset fail!\n", __func__); - return -EIO; - } - SWPS_INFO("%s: reset I2C ok. :direct\n", __func__); - return count; -} - - -static ssize_t -store_attr_reset_swps(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - - struct transvr_obj_s *tobj_p; - char port_name[32] = "ERR"; - int port_id = 0; - int minor_curr = 0; - - if (_check_reset_pwd(buf_p, count) < 0) { - return -EBFONT; - } - for (minor_curr=0; minor_currstate = STATE_TRANSVR_DISCONNECTED; - unlock_transvr_obj(tobj_p); - SWPS_INFO("%s: reset:%s\n", __func__, tobj_p->swp_name); - } - return count; -} - - -static ssize_t -store_attr_auto_config(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - - int input_val = sscanf_2_int(buf_p); - - if (input_val < 0){ - return -EBFONT; - } - if ((input_val != 0) && (input_val != 1)) { - return -EBFONT; - } - auto_config = input_val; - _update_auto_config_2_trnasvr(); - return count; -} - - -static ssize_t -store_attr_eeprom_update(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - - unsigned int input_val = sscanf_2_uint(buf_p); - - if (input_val == 0){ - eeprom_update = 0; - } - else { - eeprom_update |= input_val; - } - return count; -} - - -/* ========== Show functions: For transceiver attribute ========== - */ -static ssize_t -_show_transvr_hex_attr(struct transvr_obj_s* tobj_p, - int (*get_func)(struct transvr_obj_s* tobj_p), - char *buf_p) { - size_t len; - int result; - - lock_transvr_obj(tobj_p); - result = get_func(tobj_p); - unlock_transvr_obj(tobj_p); - if (result < 0){ - len = snprintf(buf_p, 8, "%d\n", result); - } else { - len = snprintf(buf_p, 8, "0x%02x\n", result); - } - return len; -} - - -static ssize_t -_show_transvr_int_attr(struct transvr_obj_s* tobj_p, - int (*get_func)(struct transvr_obj_s* tobj_p), - char *buf_p) { - size_t len; - - lock_transvr_obj(tobj_p); - len = snprintf(buf_p, 16, "%d\n", get_func(tobj_p)); - unlock_transvr_obj(tobj_p); - return len; -} - - -static ssize_t -_show_transvr_str_attr(struct transvr_obj_s* tobj_p, - int (*get_func)(struct transvr_obj_s* tobj_p, char* buf), - char *buf_p) { - size_t len; - - lock_transvr_obj(tobj_p); - len = get_func(tobj_p, buf_p); - unlock_transvr_obj(tobj_p); - return len; -} - - -static ssize_t -show_attr_id(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_hex_attr(tobj_p, - tobj_p->get_id, - buf_p); -} - - -static ssize_t -show_attr_ext_id(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_hex_attr(tobj_p, - tobj_p->get_ext_id, - buf_p); -} - - -static ssize_t -show_attr_connector(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_hex_attr(tobj_p, - tobj_p->get_connector, - buf_p); -} - - -static ssize_t -show_attr_vendor_name(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_vendor_name, - buf_p); -} - - -static ssize_t -show_attr_vendor_pn(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_vendor_pn, - buf_p); -} - - -static ssize_t -show_attr_vendor_rev(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_vendor_rev, - buf_p); -} - - -static ssize_t -show_attr_vendor_sn(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_vendor_sn, - buf_p); -} - - -static ssize_t -show_attr_power_cls(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - size_t len; - int result; - struct transvr_obj_s *tobj_p; - - tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - lock_transvr_obj(tobj_p); - result = tobj_p->get_power_cls(tobj_p); - unlock_transvr_obj(tobj_p); - if (result < 0){ - len = snprintf(buf_p, 16, "%d\n", result); - } else { - len = snprintf(buf_p, 16, "Power Class %d\n", result); - } - return len; -} - - -static ssize_t -show_attr_br(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_hex_attr(tobj_p, - tobj_p->get_br, - buf_p); -} - - -static ssize_t -show_attr_len_sm(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_int_attr(tobj_p, - tobj_p->get_len_sm, - buf_p); -} - - -static ssize_t -show_attr_len_smf(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_int_attr(tobj_p, - tobj_p->get_len_smf, - buf_p); -} - - -static ssize_t -show_attr_len_om1(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_int_attr(tobj_p, - tobj_p->get_len_om1, - buf_p); -} - - -static ssize_t -show_attr_len_om2(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_int_attr(tobj_p, - tobj_p->get_len_om2, - buf_p); -} - - -static ssize_t -show_attr_len_om3(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_int_attr(tobj_p, - tobj_p->get_len_om3, - buf_p); -} - - -static ssize_t -show_attr_len_om4(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_int_attr(tobj_p, - tobj_p->get_len_om4, - buf_p); -} - - -static ssize_t -show_attr_comp_rev(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_hex_attr(tobj_p, - tobj_p->get_comp_rev, - buf_p); -} - - -static ssize_t -show_attr_comp_eth(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_hex_attr(tobj_p, - tobj_p->get_comp_eth_1, - buf_p); -} - - -static ssize_t -show_attr_comp_eth_10(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_hex_attr(tobj_p, - tobj_p->get_comp_eth_10, - buf_p); -} - - -static ssize_t -show_attr_comp_eth_10_40(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_hex_attr(tobj_p, - tobj_p->get_comp_eth_10_40, - buf_p); -} - - -static ssize_t -show_attr_comp_extend(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_hex_attr(tobj_p, - tobj_p->get_comp_extend, - buf_p); -} - - -static ssize_t -show_attr_rate_id(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_hex_attr(tobj_p, - tobj_p->get_rate_id, - buf_p); -} - - -static ssize_t -show_attr_temperature(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_curr_temp, - buf_p); -} - - -static ssize_t -show_attr_voltage(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_curr_vol, - buf_p); -} - - -static ssize_t -show_attr_tx_bias(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_tx_bias, - buf_p); -} - - -static ssize_t -show_attr_tx_power(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_tx_power, - buf_p); -} - - -static ssize_t -show_attr_tx_eq(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_tx_eq, - buf_p); -} - - -static ssize_t -show_attr_rx_power(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_rx_power, - buf_p); -} - - -static ssize_t -show_attr_rx_am(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_rx_am, - buf_p); -} - - -static ssize_t -show_attr_rx_em(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_rx_em, - buf_p); -} - - -static ssize_t -show_attr_wavelength(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_wavelength, - buf_p); -} - - -static ssize_t -show_attr_info(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_int_attr(tobj_p, - tobj_p->get_info, - buf_p); -} - - -static ssize_t -show_attr_if_type(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_if_type, - buf_p); -} - - -static ssize_t -show_attr_if_speed(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_if_speed, - buf_p); -} - - -static ssize_t -show_attr_if_lane(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_if_lane, - buf_p); -} - - -static ssize_t -show_attr_cdr(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_hex_attr(tobj_p, - tobj_p->get_cdr, - buf_p); -} - - -static ssize_t -show_attr_soft_rs0(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_int_attr(tobj_p, - tobj_p->get_soft_rs0, - buf_p); -} - - -static ssize_t -show_attr_soft_rs1(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_int_attr(tobj_p, - tobj_p->get_soft_rs1, - buf_p); -} - - -static ssize_t -show_attr_soft_rx_los(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_soft_rx_los, - buf_p); -} - - -static ssize_t -show_attr_soft_tx_disable(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_soft_tx_disable, - buf_p); -} - - -static ssize_t -show_attr_soft_tx_fault(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_soft_tx_fault, - buf_p); -} - - -static ssize_t -show_attr_auto_tx_disable(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_auto_tx_disable, - buf_p); -} - -static ssize_t -show_attr_eeprom(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_eeprom, - buf_p); -} - -/* ========== Store functions: transceiver (R/W) attribute ========== - */ -static ssize_t -_store_transvr_int_attr(struct transvr_obj_s* tobj_p, - int (*set_func)(struct transvr_obj_s *tobj_p, int input_val), - const char *buf_p, - size_t count) { - int input, err; - - input = sscanf_2_int(buf_p); - if (input < 0){ - return -EBFONT; - } - lock_transvr_obj(tobj_p); - err = set_func(tobj_p, input); - unlock_transvr_obj(tobj_p); - if (err < 0){ - return err; - } - return count; -} - - -static ssize_t -_store_transvr_byte_hex_attr(struct transvr_obj_s* tobj_p, - int (*set_func)(struct transvr_obj_s *tobj_p, int input_val), - const char *buf_p, - size_t count) { - int input, err; - - input = sscanf_2_int(buf_p); - if ((input < 0) || (input > 0xff)){ - return -EBFONT; - } - lock_transvr_obj(tobj_p); - err = set_func(tobj_p, input); - unlock_transvr_obj(tobj_p); - if (err < 0){ - return err; - } - return count; -} - - -static ssize_t -_store_transvr_binary_attr(struct transvr_obj_s* tobj_p, - int (*set_func)(struct transvr_obj_s *tobj_p, int input_val), - const char *buf_p, - size_t count) { - int input, err; - - input = sscanf_2_binary(buf_p); - if (input < 0){ - return -EBFONT; - } - lock_transvr_obj(tobj_p); - err = set_func(tobj_p, input); - unlock_transvr_obj(tobj_p); - if (err < 0){ - return err; - } - return count; -} - - -static ssize_t -store_attr_cdr(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - return _store_transvr_byte_hex_attr(tobj_p, - tobj_p->set_cdr, - buf_p, - count); -} - - -static ssize_t -store_attr_soft_rs0(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - return _store_transvr_binary_attr(tobj_p, - tobj_p->set_soft_rs0, - buf_p, - count); -} - - -static ssize_t -store_attr_soft_rs1(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - return _store_transvr_binary_attr(tobj_p, - tobj_p->set_soft_rs1, - buf_p, - count); -} - - -static ssize_t -store_attr_soft_tx_disable(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count) { - - int check = sscanf_2_int(buf_p); - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - if ((check < 0) || (check > 0xf)){ - return -EBFONT; - } - return _store_transvr_byte_hex_attr(tobj_p, - tobj_p->set_soft_tx_disable, - buf_p, - count); -} - - -static ssize_t -store_attr_auto_tx_disable(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count) { - - int err = -EPERM; - int input = sscanf_2_int(buf_p); - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - if ((input < 0) || (input > 0xf)){ - if (input != VAL_TRANSVR_FUNCTION_DISABLE) { - return -EBFONT; - } - } - lock_transvr_obj(tobj_p); - err = tobj_p->set_auto_tx_disable(tobj_p, input); - unlock_transvr_obj(tobj_p); - if (err < 0){ - return err; - } - return count; -} - - -static ssize_t -store_attr_tx_eq(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - return _store_transvr_int_attr(tobj_p, - tobj_p->set_tx_eq, - buf_p, - count); -} - - -static ssize_t -store_attr_rx_am(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - return _store_transvr_int_attr(tobj_p, - tobj_p->set_rx_am, - buf_p, - count); -} - - -static ssize_t -store_attr_rx_em(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - return _store_transvr_int_attr(tobj_p, - tobj_p->set_rx_em, - buf_p, - count); -} - -/* ========== Show functions: For I/O Expander attribute ========== - */ -static ssize_t -_show_ioexp_binary_attr(struct transvr_obj_s *tobj_p, - int (*get_func)(struct ioexp_obj_s *ioexp_p, int voffset), - char *buf_p) { - size_t len; - struct ioexp_obj_s *ioexp_p = tobj_p->ioexp_obj_p; - - if (!ioexp_p) { - SWPS_ERR(" %s: data corruption! :%s\n", __func__, tobj_p->swp_name); - return -ENODATA; - } - mutex_lock(&ioexp_p->lock); - len = snprintf(buf_p, 8, "%d\n", get_func(ioexp_p, tobj_p->ioexp_virt_offset)); - mutex_unlock(&ioexp_p->lock); - return len; -} - - -static ssize_t -show_attr_present(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - return _show_ioexp_binary_attr(tobj_p, - tobj_p->ioexp_obj_p->get_present, - buf_p); -} - - -static ssize_t -show_attr_tx_fault(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - return _show_ioexp_binary_attr(tobj_p, - tobj_p->ioexp_obj_p->get_tx_fault, - buf_p); -} - - -static ssize_t -show_attr_rxlos(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - return _show_ioexp_binary_attr(tobj_p, - tobj_p->ioexp_obj_p->get_rxlos, - buf_p); -} - - -static ssize_t -show_attr_tx_disable(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - return _show_ioexp_binary_attr(tobj_p, - tobj_p->ioexp_obj_p->get_tx_disable, - buf_p); -} - - -static ssize_t -show_attr_reset(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - return _show_ioexp_binary_attr(tobj_p, - tobj_p->ioexp_obj_p->get_reset, - buf_p); -} - - -static ssize_t -show_attr_lpmod(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - return _show_ioexp_binary_attr(tobj_p, - tobj_p->ioexp_obj_p->get_lpmod, - buf_p); -} - - -static ssize_t -show_attr_modsel(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - return _show_ioexp_binary_attr(tobj_p, - tobj_p->ioexp_obj_p->get_modsel, - buf_p); -} - - -static ssize_t -show_attr_hard_rs0(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - return _show_ioexp_binary_attr(tobj_p, - tobj_p->ioexp_obj_p->get_hard_rs0, - buf_p); -} - - -static ssize_t -show_attr_hard_rs1(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - return _show_ioexp_binary_attr(tobj_p, - tobj_p->ioexp_obj_p->get_hard_rs1, - buf_p); -} - - -/* ========== Store functions: For I/O Expander (R/W) attribute ========== - */ -static ssize_t -_store_ioexp_binary_attr(struct transvr_obj_s *tobj_p, - int (*set_func)(struct ioexp_obj_s *ioexp_p, - int virt_offset, int input_val), - const char *buf_p, - size_t count) { - - int input, err; - struct ioexp_obj_s *ioexp_p = tobj_p->ioexp_obj_p; - - if (!ioexp_p) { - SWPS_ERR("%s: data corruption! :%s\n", - __func__, tobj_p->swp_name); - return -ENODATA; - } - input = sscanf_2_binary(buf_p); - if (input < 0) { - return -EBFONT; - } - mutex_lock(&ioexp_p->lock); - err = set_func(ioexp_p, tobj_p->ioexp_virt_offset, input); - mutex_unlock(&ioexp_p->lock); - if (err < 0){ - return err; - } - return count; -} - -static ssize_t -store_attr_tx_disable(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p) { - return -ENODEV; - } - return _store_ioexp_binary_attr(tobj_p, - tobj_p->ioexp_obj_p->set_tx_disable, - buf_p, - count); -} - - -static ssize_t -store_attr_reset(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p) { - return -ENODEV; - } - return _store_ioexp_binary_attr(tobj_p, - tobj_p->ioexp_obj_p->set_reset, - buf_p, - count); -} - - -static ssize_t -store_attr_lpmod(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p) { - return -ENODEV; - } - return _store_ioexp_binary_attr(tobj_p, - tobj_p->ioexp_obj_p->set_lpmod, - buf_p, - count); -} - - -static ssize_t -store_attr_modsel(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p) { - return -ENODEV; - } - return _store_ioexp_binary_attr(tobj_p, - tobj_p->ioexp_obj_p->set_modsel, - buf_p, - count); -} - - -static ssize_t -store_attr_hard_rs0(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p) { - return -ENODEV; - } - return _store_ioexp_binary_attr(tobj_p, - tobj_p->ioexp_obj_p->set_hard_rs0, - buf_p, - count); -} - - -static ssize_t -store_attr_hard_rs1(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p) { - return -ENODEV; - } - return _store_ioexp_binary_attr(tobj_p, - tobj_p->ioexp_obj_p->set_hard_rs1, - buf_p, - count); -} - - -/* ========== SWPS attribute: For module control ========== - */ -static DEVICE_ATTR(platform, S_IRUGO, show_attr_platform, NULL); -static DEVICE_ATTR(version, S_IRUGO, show_attr_version, NULL); -static DEVICE_ATTR(status, S_IRUGO, show_attr_status, NULL); -static DEVICE_ATTR(reset_i2c, S_IWUSR, NULL, store_attr_reset_i2c); -static DEVICE_ATTR(reset_swps, S_IWUSR, NULL, store_attr_reset_swps); -static DEVICE_ATTR(auto_config, S_IRUGO|S_IWUSR, show_attr_auto_config, store_attr_auto_config); -static DEVICE_ATTR(eeprom_update, S_IRUGO|S_IWUSR, show_attr_eeprom_update, store_attr_eeprom_update); - -/* ========== Transceiver attribute: from eeprom ========== - */ -static DEVICE_ATTR(id, S_IRUGO, show_attr_id, NULL); -static DEVICE_ATTR(ext_id, S_IRUGO, show_attr_ext_id, NULL); -static DEVICE_ATTR(connector, S_IRUGO, show_attr_connector, NULL); -static DEVICE_ATTR(vendor_name, S_IRUGO, show_attr_vendor_name, NULL); -static DEVICE_ATTR(vendor_pn, S_IRUGO, show_attr_vendor_pn, NULL); -static DEVICE_ATTR(vendor_rev, S_IRUGO, show_attr_vendor_rev, NULL); -static DEVICE_ATTR(vendor_sn, S_IRUGO, show_attr_vendor_sn, NULL); -static DEVICE_ATTR(power_cls, S_IRUGO, show_attr_power_cls, NULL); -static DEVICE_ATTR(br, S_IRUGO, show_attr_br, NULL); -static DEVICE_ATTR(len_sm, S_IRUGO, show_attr_len_sm, NULL); -static DEVICE_ATTR(len_smf, S_IRUGO, show_attr_len_smf, NULL); -static DEVICE_ATTR(len_om1, S_IRUGO, show_attr_len_om1, NULL); -static DEVICE_ATTR(len_om2, S_IRUGO, show_attr_len_om2, NULL); -static DEVICE_ATTR(len_om3, S_IRUGO, show_attr_len_om3, NULL); -static DEVICE_ATTR(len_om4, S_IRUGO, show_attr_len_om4, NULL); -static DEVICE_ATTR(comp_rev, S_IRUGO, show_attr_comp_rev, NULL); -static DEVICE_ATTR(comp_eth, S_IRUGO, show_attr_comp_eth, NULL); -static DEVICE_ATTR(comp_eth_10, S_IRUGO, show_attr_comp_eth_10, NULL); -static DEVICE_ATTR(comp_eth_10_40, S_IRUGO, show_attr_comp_eth_10_40, NULL); -static DEVICE_ATTR(comp_extend, S_IRUGO, show_attr_comp_extend, NULL); -static DEVICE_ATTR(rate_id, S_IRUGO, show_attr_rate_id, NULL); -static DEVICE_ATTR(temperature, S_IRUGO, show_attr_temperature, NULL); -static DEVICE_ATTR(voltage, S_IRUGO, show_attr_voltage, NULL); -static DEVICE_ATTR(tx_bias, S_IRUGO, show_attr_tx_bias, NULL); -static DEVICE_ATTR(tx_power, S_IRUGO, show_attr_tx_power, NULL); -static DEVICE_ATTR(rx_power, S_IRUGO, show_attr_rx_power, NULL); -static DEVICE_ATTR(info, S_IRUGO, show_attr_info, NULL); -static DEVICE_ATTR(if_type, S_IRUGO, show_attr_if_type, NULL); -static DEVICE_ATTR(if_speed, S_IRUGO, show_attr_if_speed, NULL); -static DEVICE_ATTR(if_lane, S_IRUGO, show_attr_if_lane, NULL); -static DEVICE_ATTR(soft_rx_los, S_IRUGO, show_attr_soft_rx_los, NULL); -static DEVICE_ATTR(soft_tx_fault, S_IRUGO, show_attr_soft_tx_fault, NULL); -static DEVICE_ATTR(wavelength, S_IRUGO, show_attr_wavelength, NULL); -static DEVICE_ATTR(eeprom, S_IRUGO, show_attr_eeprom, NULL); -static DEVICE_ATTR(tx_eq, S_IRUGO|S_IWUSR, show_attr_tx_eq, store_attr_tx_eq); -static DEVICE_ATTR(rx_am, S_IRUGO|S_IWUSR, show_attr_rx_am, store_attr_rx_am); -static DEVICE_ATTR(rx_em, S_IRUGO|S_IWUSR, show_attr_rx_em, store_attr_rx_em); -static DEVICE_ATTR(cdr, S_IRUGO|S_IWUSR, show_attr_cdr, store_attr_cdr); -static DEVICE_ATTR(soft_rs0, S_IRUGO|S_IWUSR, show_attr_soft_rs0, store_attr_soft_rs0); -static DEVICE_ATTR(soft_rs1, S_IRUGO|S_IWUSR, show_attr_soft_rs1, store_attr_soft_rs1); -static DEVICE_ATTR(soft_tx_disable, S_IRUGO|S_IWUSR, show_attr_soft_tx_disable, store_attr_soft_tx_disable); -static DEVICE_ATTR(auto_tx_disable, S_IRUGO|S_IWUSR, show_attr_auto_tx_disable, store_attr_auto_tx_disable); - -/* ========== IO Expander attribute: from expander ========== - */ -static DEVICE_ATTR(present, S_IRUGO, show_attr_present, NULL); -static DEVICE_ATTR(tx_fault, S_IRUGO, show_attr_tx_fault, NULL); -static DEVICE_ATTR(rxlos, S_IRUGO, show_attr_rxlos, NULL); -static DEVICE_ATTR(tx_disable, S_IRUGO|S_IWUSR, show_attr_tx_disable, store_attr_tx_disable); -static DEVICE_ATTR(reset, S_IRUGO|S_IWUSR, show_attr_reset, store_attr_reset); -static DEVICE_ATTR(lpmod, S_IRUGO|S_IWUSR, show_attr_lpmod, store_attr_lpmod); -static DEVICE_ATTR(modsel, S_IRUGO|S_IWUSR, show_attr_modsel, store_attr_modsel); -static DEVICE_ATTR(hard_rs0, S_IRUGO|S_IWUSR, show_attr_hard_rs0, store_attr_hard_rs0); -static DEVICE_ATTR(hard_rs1, S_IRUGO|S_IWUSR, show_attr_hard_rs1, store_attr_hard_rs1); - -/* ========== Functions for module handling ========== - */ -static void -clean_port_obj(void){ - - dev_t dev_num; - char dev_name[32]; - struct device *device_p; - struct transvr_obj_s *transvr_obj_p; - int minor_curr, port_id; - - for (minor_curr=0; minor_curri2c_client_p); - kfree(transvr_obj_p->vendor_name); - kfree(transvr_obj_p->vendor_pn); - kfree(transvr_obj_p->vendor_rev); - kfree(transvr_obj_p->vendor_sn); - kfree(transvr_obj_p->worker_p); - kfree(transvr_obj_p); - } - dev_num = MKDEV(port_major, minor_curr); - device_unregister(device_p); - device_destroy(swp_class_p, dev_num); - } - SWPS_DEBUG("%s: done.\n", __func__); -} - - -static void -clean_swps_common(void){ - - dev_t dev_num; - struct device *device_p; - - device_p = get_swpdev_by_name(SWP_DEV_MODCTL); - if (device_p){ - dev_num = MKDEV(ctl_major, 1); - device_unregister(device_p); - device_destroy(swp_class_p, dev_num); - } - cancel_delayed_work_sync(&swp_polling); - SWPS_DEBUG("%s: done.\n", __func__); -} - - -static int -get_platform_type(void){ - - int i; - int pf_total = ARRAY_SIZE(platform_map); - char log_msg[64] = "ERROR"; - - platform_p = kzalloc(sizeof(struct inv_platform_s), GFP_KERNEL); - if (!platform_p){ - snprintf(log_msg, sizeof(log_msg), "kzalloc fail"); - goto err_get_platform_type_1; - } - memset(platform_p->name, 0, sizeof(platform_p->name)); - - switch (PLATFORM_SETTINGS) { - case PLATFORM_TYPE_AUTO: - snprintf(platform_p->name, (sizeof(platform_p->name) - 1), - "%s", dmi_get_system_info(DMI_BOARD_NAME)); - for (i=0; iname, platform_map[i].name) == 0) { - platform_p->id = platform_map[i].id; - snprintf(log_msg, sizeof(log_msg), - "Auto detect platform: %d (%s)", - platform_p->id, platform_p->name); - goto ok_get_platform_type_1; - } - } - snprintf(log_msg, sizeof(log_msg), - "Auto detect fail! detect platform: %s", - platform_p->name); - goto err_get_platform_type_2; - - case PLATFORM_TYPE_MAGNOLIA: - case PLATFORM_TYPE_MAGNOLIA_FNC: - case PLATFORM_TYPE_REDWOOD: - case PLATFORM_TYPE_REDWOOD_FSL: - case PLATFORM_TYPE_HUDSON32I_GA: - case PLATFORM_TYPE_SPRUCE: - case PLATFORM_TYPE_CYPRESS_GA1: - case PLATFORM_TYPE_CYPRESS_GA2: - case PLATFORM_TYPE_CYPRESS_BAI: - platform_p->id = PLATFORM_SETTINGS; - for (i=0; iname, (sizeof(platform_p->name) - 1), - "%s", platform_map[i].name); - snprintf(log_msg, sizeof(log_msg), - "User setup platform: %d (%s)", - platform_p->id, platform_p->name); - goto ok_get_platform_type_1; - } - } - snprintf(log_msg, sizeof(log_msg), - "Internal error, can not map id:%d", - PLATFORM_SETTINGS); - goto err_get_platform_type_2; - - default: - break; - } - snprintf(log_msg, sizeof(log_msg), - "PLATFORM_SETTINGS:%d undefined", PLATFORM_SETTINGS); - goto err_get_platform_type_2; - -ok_get_platform_type_1: - SWPS_DEBUG("%s: %s, :%d\n", __func__, log_msg, PLATFORM_SETTINGS); - return 0; - -err_get_platform_type_2: - kfree(platform_p); -err_get_platform_type_1: - SWPS_ERR("%s: %s :%d\n", __func__, log_msg, PLATFORM_SETTINGS); - return -1; -} - - -static int -get_layout_info(void){ - - switch (platform_p->id) { -#ifdef SWPS_MAGNOLIA - case PLATFORM_TYPE_MAGNOLIA: - case PLATFORM_TYPE_MAGNOLIA_FNC: - gpio_rest_mux = magnolia_gpio_rest_mux; - ioexp_layout = magnolia_ioexp_layout; - port_layout = magnolia_port_layout; - ioexp_total = ARRAY_SIZE(magnolia_ioexp_layout); - port_total = ARRAY_SIZE(magnolia_port_layout); - break; -#endif -#ifdef SWPS_REDWOOD - case PLATFORM_TYPE_REDWOOD: - gpio_rest_mux = redwood_gpio_rest_mux; - ioexp_layout = redwood_ioexp_layout; - port_layout = redwood_port_layout; - ioexp_total = ARRAY_SIZE(redwood_ioexp_layout); - port_total = ARRAY_SIZE(redwood_port_layout); - break; -#endif -#ifdef SWPS_HUDSON32I_GA - case PLATFORM_TYPE_HUDSON32I_GA: - gpio_rest_mux = hudsin32iga_gpio_rest_mux; - ioexp_layout = hudson32iga_ioexp_layout; - port_layout = hudson32iga_port_layout; - ioexp_total = ARRAY_SIZE(hudson32iga_ioexp_layout); - port_total = ARRAY_SIZE(hudson32iga_port_layout); - break; -#endif -#ifdef SWPS_SPRUCE - case PLATFORM_TYPE_SPRUCE: - gpio_rest_mux = spruce_gpio_rest_mux; - ioexp_layout = spruce_ioexp_layout; - port_layout = spruce_port_layout; - ioexp_total = ARRAY_SIZE(spruce_ioexp_layout); - port_total = ARRAY_SIZE(spruce_port_layout); - break; -#endif -#ifdef SWPS_CYPRESS_GA1 - case PLATFORM_TYPE_CYPRESS_GA1: - gpio_rest_mux = cypress_ga1_gpio_rest_mux; - ioexp_layout = cypress_ga1_ioexp_layout; - port_layout = cypress_ga1_port_layout; - ioexp_total = ARRAY_SIZE(cypress_ga1_ioexp_layout); - port_total = ARRAY_SIZE(cypress_ga1_port_layout); - break; -#endif -#ifdef SWPS_CYPRESS_GA2 - case PLATFORM_TYPE_CYPRESS_GA2: - gpio_rest_mux = cypress_ga2_gpio_rest_mux; - ioexp_layout = cypress_ga2_ioexp_layout; - port_layout = cypress_ga2_port_layout; - ioexp_total = ARRAY_SIZE(cypress_ga2_ioexp_layout); - port_total = ARRAY_SIZE(cypress_ga2_port_layout); - break; -#endif -#ifdef SWPS_CYPRESS_BAI - case PLATFORM_TYPE_CYPRESS_BAI: - gpio_rest_mux = cypress_b_gpio_rest_mux; - ioexp_layout = cypress_b_ioexp_layout; - port_layout = cypress_b_port_layout; - ioexp_total = ARRAY_SIZE(cypress_b_ioexp_layout); - port_total = ARRAY_SIZE(cypress_b_port_layout); - break; -#endif -#ifdef SWPS_REDWOOD_FSL - case PLATFORM_TYPE_REDWOOD_FSL: - gpio_rest_mux = redwood_fsl_gpio_rest_mux; - ioexp_layout = redwood_fsl_ioexp_layout; - port_layout = redwood_fsl_port_layout; - ioexp_total = ARRAY_SIZE(redwood_fsl_ioexp_layout); - port_total = ARRAY_SIZE(redwood_fsl_port_layout); - break; -#endif - - default: - SWPS_ERR(" Invalid platform: %d (%s)\n", - platform_p->id, platform_p->name); - return -1; - } - SWPS_INFO("Start to initial platform: %d (%s)\n", - platform_p->id, platform_p->name); - return 0; -} - - -/* ========== Functions for objects operations ========== - */ -static int -__detect_issues_port(int minor_num) { - - struct transvr_obj_s *tobj_p; - int port_id = port_layout[minor_num].port_id; - char port_name[32] = "ERR"; - char *i2c_emsg = "detected bad transceiver/cable"; - - memset(port_name, 0, sizeof(port_name)); - snprintf(port_name, sizeof(port_name), "%s%d", SWP_DEV_PORT, port_id); - tobj_p = _get_transvr_obj(port_name); - if (!tobj_p) { - SWPS_INFO("%s: tobj_p is NULL :%d\n", __func__, minor_num); - return -1; - } - if (resync_channel_tier_2(tobj_p) < 0) { - if (check_channel_tier_1() < 0) { - alarm_msg_2_user(tobj_p, i2c_emsg); - return -2;; - } - } - return 0; -} - - -static int -_detect_issues_port(void) { - /* OK : retrun -1; - * Fail: return fail at which minor number (0~N) - */ - char *emsg = "ERR"; - int minor = 0; - int minor_2st = 1; - - /* Force moving the initial channel pointer - * Filter out case of fail at minor-0 port - */ - while (minor_2st < port_total) { - minor = minor_2st; - if (__detect_issues_port(minor_2st) < 0) { - emsg = "detect minor_2st fail"; - goto err_p_detect_issues_port; - } - minor_2st += 8; - } - /* Scan all port */ - for (minor=0; minor:%d\n", __func__, emsg, minor_err); - return -1; -} - - -static int -check_transvr_obj_one(char *dev_name){ - /* [Return] - * 0 : Doesn't need to take care - * -1 : Single error - * -2 : Critical error (I2C topology die) - * -9 : Internal error - */ - struct transvr_obj_s *tobj_p = NULL; - int retval = -9; - - tobj_p = _get_transvr_obj(dev_name); - if (!tobj_p) { - SWPS_ERR("%s: %s _get_transvr_obj fail\n", - __func__, dev_name); - return -9; - } - /* Check transceiver current status */ - lock_transvr_obj(tobj_p); - retval = tobj_p->check(tobj_p); - unlock_transvr_obj(tobj_p); - switch (retval) { - case 0: - case ERR_TRANSVR_UNPLUGGED: - case ERR_TRNASVR_BE_ISOLATED: - case ERR_TRANSVR_TASK_BUSY: - return 0; - - case ERR_TRANSVR_I2C_CRASH: - default: - break; - } - /* Identify abnormal case */ - if (check_channel_tier_1() < 0) { - SWPS_DEBUG("%s: %s critical error :%d\n", - __func__, dev_name, retval); - return -2; - } - SWPS_DEBUG("%s: %s single error :%d\n", - __func__, dev_name, retval); - return -1; -} - - -static int -check_transvr_objs(void){ - - char dev_name[32]; - int port_id, err_code; - int minor_curr = 0; - - for (minor_curr=0; minor_curr:%d\n", - __func__, dev_name, err_code); - break; - } - } - return 0; - -err_check_transvr_objs: - SWPS_ERR("%s: %s reset_i2c_topology fail.\n", - __func__, dev_name); - return -1; -} - - -static void -swp_polling_worker(struct work_struct *work){ - - /* Reset I2C */ - if (flag_i2c_reset) { - goto polling_reset_i2c; - } - /* Check IOEXP */ - if (check_ioexp_objs() < 0) { - goto polling_reset_i2c; - } - /* Check transceiver */ - if (check_transvr_objs() < 0) { - SWPS_DEBUG("%s: check_transvr_objs fail.\n", __func__); - flag_i2c_reset = 1; - } - goto polling_schedule_round; - -polling_reset_i2c: - SWPS_DEBUG("%s: reset_i2c_topology start.\n", __func__); - if (reset_i2c_topology() < 0) { - SWPS_ERR("%s: reset i2c fail!\n", __func__); - flag_i2c_reset = 1; - } else { - SWPS_DEBUG("%s: reset_i2c_topology OK.\n", __func__); - flag_i2c_reset = 0; - } -polling_schedule_round: - schedule_delayed_work(&swp_polling, _get_polling_period()); -} - - -/* ========== Functions for register something ========== - */ -static int -register_transvr_common_attr(struct device *device_p){ - - char *err_attr = NULL; - - if (device_create_file(device_p, &dev_attr_id) < 0) { - err_attr = "dev_attr_id"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_ext_id) < 0) { - err_attr = "dev_attr_ext_id"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_connector) < 0) { - err_attr = "dev_attr_connector"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_vendor_name) < 0) { - err_attr = "dev_attr_vendor_name"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_vendor_pn) < 0) { - err_attr = "dev_attr_vendor_pn"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_vendor_rev) < 0) { - err_attr = "dev_attr_vendor_rev"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_vendor_sn) < 0) { - err_attr = "dev_attr_vendor_sn"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_br) < 0) { - err_attr = "dev_attr_br"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_len_smf) < 0) { - err_attr = "dev_attr_len_smf"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_len_om1) < 0) { - err_attr = "dev_attr_len_om1"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_len_om2) < 0) { - err_attr = "dev_attr_len_om2"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_len_om3) < 0) { - err_attr = "dev_attr_len_om3"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_len_om4) < 0) { - err_attr = "dev_attr_len_om4"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_comp_extend) < 0) { - err_attr = "dev_attr_comp_extend"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_comp_eth) < 0) { - err_attr = "dev_attr_comp_eth"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_comp_rev) < 0) { - err_attr = "dev_attr_comp_rev"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_info) < 0) { - err_attr = "dev_attr_info"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_if_type) < 0) { - err_attr = "dev_attr_if_type"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_if_speed) < 0) { - err_attr = "dev_attr_if_speed"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_if_lane) < 0) { - err_attr = "dev_attr_if_lane"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_temperature) < 0) { - err_attr = "dev_attr_temperature"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_voltage) < 0) { - err_attr = "dev_attr_voltage"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_tx_bias) < 0) { - err_attr = "dev_attr_tx_bias"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_tx_power) < 0) { - err_attr = "dev_attr_tx_power"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_rx_power) < 0) { - err_attr = "dev_attr_rx_power"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_tx_eq) < 0) { - err_attr = "dev_attr_tx_eq"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_rx_em) < 0) { - err_attr = "dev_attr_rx_em"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_wavelength) < 0) { - err_attr = "dev_attr_wavelength"; - goto err_transvr_comm_attr; - } - return 0; - -err_transvr_comm_attr: - SWPS_ERR("%s: %s\n", __func__, err_attr); - return -1; -} - -static int -register_transvr_sfp_attr(struct device *device_p){ - - char *err_attr = NULL; - - if (register_transvr_common_attr(device_p) < 0) { - err_attr = "register_transvr_common_attr"; - goto err_transvr_sfp_attr; - } - if (device_create_file(device_p, &dev_attr_comp_eth_10) < 0) { - err_attr = "dev_attr_comp_eth_10"; - goto err_transvr_sfp_attr; - } - if (device_create_file(device_p, &dev_attr_len_sm) < 0) { - err_attr = "dev_attr_len_sm"; - goto err_transvr_sfp_attr; - } - if (device_create_file(device_p, &dev_attr_rate_id) < 0) { - err_attr = "dev_attr_rate_id"; - goto err_transvr_sfp_attr; - } - if (device_create_file(device_p, &dev_attr_soft_rs0) < 0) { - err_attr = "dev_attr_soft_rs0"; - goto err_transvr_sfp_attr; - } - if (device_create_file(device_p, &dev_attr_soft_rs1) < 0) { - err_attr = "dev_attr_soft_rs1"; - goto err_transvr_sfp_attr; - } - return 0; - -err_transvr_sfp_attr: - SWPS_ERR("%s: %s\n", __func__, err_attr); - return -1; -} - - -static int -register_transvr_qsfp_attr(struct device *device_p){ - - char *err_attr = NULL; - - if (register_transvr_common_attr(device_p) < 0) { - err_attr = "register_transvr_common_attr"; - goto err_transvr_qsfp_attr; - } - if (device_create_file(device_p, &dev_attr_comp_eth_10_40) < 0) { - err_attr = "dev_attr_comp_eth_10_40"; - goto err_transvr_qsfp_attr; - } - if (device_create_file(device_p, &dev_attr_power_cls) < 0) { - err_attr = "dev_attr_power_cls"; - goto err_transvr_qsfp_attr; - } - if (device_create_file(device_p, &dev_attr_soft_rx_los) < 0) { - err_attr = "soft_rx_los"; - goto err_transvr_qsfp_attr; - } - if (device_create_file(device_p, &dev_attr_soft_tx_disable) < 0) { - err_attr = "soft_tx_disable"; - goto err_transvr_qsfp_attr; - } - if (device_create_file(device_p, &dev_attr_auto_tx_disable) < 0) { - err_attr = "auto_tx_disable"; - goto err_transvr_qsfp_attr; - } - if (device_create_file(device_p, &dev_attr_soft_tx_fault) < 0) { - err_attr = "soft_tx_fault"; - goto err_transvr_qsfp_attr; - } - if (device_create_file(device_p, &dev_attr_eeprom) < 0) { - err_attr = "eeprom"; - goto err_transvr_qsfp_attr; - } - return 0; - -err_transvr_qsfp_attr: - SWPS_ERR("%s: %s\n", __func__, err_attr); - return -1; -} - - -static int -register_transvr_qsfp28_attr(struct device *device_p){ - - char *err_attr = NULL; - - if (register_transvr_qsfp_attr(device_p) < 0){ - err_attr = "register_transvr_qsfp_attr"; - goto err_transvr_qsfp28_attr; - } - if (device_create_file(device_p, &dev_attr_cdr) < 0) { - err_attr = "dev_attr_cdr"; - goto err_transvr_qsfp28_attr; - } - if (device_create_file(device_p, &dev_attr_rx_am) < 0) { - err_attr = "dev_attr_rx_am"; - goto err_transvr_qsfp28_attr; - } - return 0; - -err_transvr_qsfp28_attr: - SWPS_ERR("%s: %s\n", __func__, err_attr); - return -1; -} - - -static int -register_transvr_attr(struct device *device_p, - struct transvr_obj_s *transvr_obj){ - - switch (transvr_obj->layout){ - case TRANSVR_TYPE_SFP: - if (register_transvr_sfp_attr(device_p) < 0){ - goto err_reg_tvr_attr; - } - break; - case TRANSVR_TYPE_QSFP: - case TRANSVR_TYPE_QSFP_PLUS: - if (register_transvr_qsfp_attr(device_p) < 0){ - goto err_reg_tvr_attr; - } - break; - case TRANSVR_TYPE_QSFP_28: - if (register_transvr_qsfp28_attr(device_p) < 0){ - goto err_reg_tvr_attr; - } - break; - default: - goto err_reg_tvr_attr; - } - return 0; - -err_reg_tvr_attr: - SWPS_ERR("%s: fail! type=%d \n", __func__, transvr_obj->type); - return -1; -} - - -static int -register_ioexp_attr_sfp_1(struct device *device_p){ - /* Support machine type: - * - SFP : Magnolia - */ - char *err_attr = NULL; - - if (device_create_file(device_p, &dev_attr_present) < 0) { - err_attr = "dev_attr_present"; - goto err_ioexp_sfp1_attr; - } - if (device_create_file(device_p, &dev_attr_tx_fault) < 0) { - err_attr = "dev_attr_tx_fault"; - goto err_ioexp_sfp1_attr; - } - if (device_create_file(device_p, &dev_attr_rxlos) < 0) { - err_attr = "dev_attr_rxlos"; - goto err_ioexp_sfp1_attr; - } - if (device_create_file(device_p, &dev_attr_tx_disable) < 0) { - err_attr = "dev_attr_tx_disable"; - goto err_ioexp_sfp1_attr; - } - return 0; - -err_ioexp_sfp1_attr: - SWPS_ERR("Add device attribute:%s failure! \n",err_attr); - return -1; -} - - -static int -register_ioexp_attr_sfp_2(struct device *device_p){ - /* Support machine type: - * - SFP28 : Cypress - */ - char *err_attr = NULL; - - if (register_ioexp_attr_sfp_1(device_p) < 0){ - goto err_ioexp_sfp2_attr; - } - if (device_create_file(device_p, &dev_attr_hard_rs0) < 0) { - err_attr = "dev_attr_hard_rs0"; - goto err_ioexp_sfp2_attr; - } - if (device_create_file(device_p, &dev_attr_hard_rs1) < 0) { - err_attr = "dev_attr_hard_rs1"; - goto err_ioexp_sfp2_attr; - } - return 0; - -err_ioexp_sfp2_attr: - SWPS_ERR("Add device attribute:%s failure! \n",err_attr); - return -1; -} - - -static int -register_ioexp_attr_qsfp_1(struct device *device_p){ - /* Support machine type: - * - QSFP : Magnolia, Redwood, Hudson32i - * - QSFP+ : Magnolia, Redwood, Hudson32i - * - QSFP28: Redwood - */ - char *err_attr = NULL; - - if (device_create_file(device_p, &dev_attr_present) < 0) { - err_attr = "dev_attr_present"; - goto err_ioexp_qsfp1_attr; - } - if (device_create_file(device_p, &dev_attr_reset) < 0) { - err_attr = "dev_attr_reset"; - goto err_ioexp_qsfp1_attr; - } - if (device_create_file(device_p, &dev_attr_lpmod) < 0) { - err_attr = "dev_attr_lpmod"; - goto err_ioexp_qsfp1_attr; - } - if (device_create_file(device_p, &dev_attr_modsel) < 0) { - err_attr = "dev_attr_modsel"; - goto err_ioexp_qsfp1_attr; - } - return 0; - -err_ioexp_qsfp1_attr: - SWPS_ERR("Add device attribute:%s failure! \n",err_attr); - return -1; -} - - -static int -register_modctl_attr(struct device *device_p){ - - char *err_msg = NULL; - - if (device_create_file(device_p, &dev_attr_platform) < 0) { - err_msg = "dev_attr_platform"; - goto err_reg_modctl_attr; - } - if (device_create_file(device_p, &dev_attr_version) < 0) { - err_msg = "dev_attr_version"; - goto err_reg_modctl_attr; - } - if (device_create_file(device_p, &dev_attr_status) < 0) { - err_msg = "dev_attr_status"; - goto err_reg_modctl_attr; - } - if (device_create_file(device_p, &dev_attr_reset_i2c) < 0) { - err_msg = "dev_attr_reset_i2c"; - goto err_reg_modctl_attr; - } - if (device_create_file(device_p, &dev_attr_reset_swps) < 0) { - err_msg = "dev_attr_reset_swps"; - goto err_reg_modctl_attr; - } - if (device_create_file(device_p, &dev_attr_auto_config) < 0) { - err_msg = "dev_attr_auto_config"; - goto err_reg_modctl_attr; - } - if (device_create_file(device_p, &dev_attr_eeprom_update) < 0) { - err_msg = "dev_attr_eeprom_update"; - goto err_reg_modctl_attr; - } - return 0; - -err_reg_modctl_attr: - SWPS_ERR("%s: %s\n", __func__, err_msg); - return -1; -} - - -static int -register_ioexp_attr(struct device *device_p, - struct transvr_obj_s *transvr_obj){ - - char *err_msg = "ERR"; - - switch (transvr_obj->ioexp_obj_p->ioexp_type){ - case IOEXP_TYPE_MAGINOLIA_NAB: - if (register_ioexp_attr_sfp_1(device_p) < 0){ - err_msg = "register_ioexp_attr_sfp_1 fail"; - goto err_reg_ioexp_attr; - } - break; - case IOEXP_TYPE_CYPRESS_NABC: - if (register_ioexp_attr_sfp_2(device_p) < 0){ - err_msg = "register_ioexp_attr_sfp_2 fail"; - goto err_reg_ioexp_attr; - } - break; - case IOEXP_TYPE_MAGINOLIA_7AB: - case IOEXP_TYPE_SPRUCE_7AB: - case IOEXP_TYPE_CYPRESS_7ABC: - case IOEXP_TYPE_REDWOOD_P01P08: - case IOEXP_TYPE_REDWOOD_P09P16: - case IOEXP_TYPE_HUDSON32IGA_P01P08: - case IOEXP_TYPE_HUDSON32IGA_P09P16: - if (register_ioexp_attr_qsfp_1(device_p) < 0){ - err_msg = "register_ioexp_attr_qsfp_1 fail"; - goto err_reg_ioexp_attr; - } - break; - - default: - err_msg = "Unknow type"; - goto err_reg_ioexp_attr; - } - return 0; - -err_reg_ioexp_attr: - SWPS_ERR("%s: %s :%d \n", - __func__, err_msg, transvr_obj->ioexp_obj_p->ioexp_type); - return -1; -} - - -static int -register_modctl_device(void) { - - struct device *device_p = NULL; - int minor_comm = 0; /* Default minor number for common device */ - dev_t dev_num = MKDEV(ctl_major, minor_comm); - char *err_msg = "ERROR"; - - device_p = device_create(swp_class_p, /* struct class *cls */ - NULL, /* struct device *parent */ - dev_num, /* dev_t devt */ - NULL, /* void *private_data */ - SWP_DEV_MODCTL); /* const char *fmt */ - if (IS_ERR(device_p)){ - err_msg = "device_create fail"; - goto err_register_modctl_device_1; - } - if (register_modctl_attr(device_p) < 0) { - err_msg = "register_modctl_attr fail"; - goto err_register_modctl_device_2; - } - return 0; - -err_register_modctl_device_2: - device_unregister(device_p); - device_destroy(swp_class_p, dev_num); -err_register_modctl_device_1: - SWPS_ERR("%s: %s\n", __func__, err_msg); - return -1; -} - - -static int -register_port_device(char *dev_name, - dev_t dev_num, - struct transvr_obj_s *transvr_obj){ - - struct device *device_p = NULL; - device_p = device_create(swp_class_p, /* struct class *cls */ - NULL, /* struct device *parent */ - dev_num, /* dev_t devt */ - transvr_obj, /* void *private_data */ - dev_name); /* const char *fmt */ - if (IS_ERR(device_p)){ - goto err_regswp_create_dev; - } - if (register_transvr_attr(device_p, transvr_obj) < 0){ - goto err_regswp_reg_attr; - } - if (register_ioexp_attr(device_p, transvr_obj) < 0){ - goto err_regswp_reg_attr; - } - return 0; - -err_regswp_reg_attr: - device_unregister(device_p); - device_destroy(swp_class_p, dev_num); -err_regswp_create_dev: - SWPS_ERR("%s fail! :%s\n", __func__, dev_name); - return -1; -} - - -static int -register_swp_module(void){ - - dev_t ctl_devt = 0; - dev_t port_devt = 0; - int dev_total = port_total + 1; /* char_dev for module control */ - - /* Register device number */ - if (alloc_chrdev_region(&ctl_devt, 0, 1, SWP_DEV_MODCTL) < 0){ - SWPS_WARN("Allocate CTL MAJOR failure! \n"); - goto err_register_swp_module_1; - } - if (alloc_chrdev_region(&port_devt, 0, dev_total, SWP_CLS_NAME) < 0){ - SWPS_WARN("Allocate PORT MAJOR failure! \n"); - goto err_register_swp_module_2; - } - ctl_major = MAJOR(ctl_devt); - port_major = MAJOR(port_devt); - - /* Create class object */ - swp_class_p = class_create(THIS_MODULE, SWP_CLS_NAME); - if (IS_ERR(swp_class_p)) { - SWPS_ERR("Create class failure! \n"); - goto err_register_swp_module_3; - } - return 0; - -err_register_swp_module_3: - unregister_chrdev_region(MKDEV(port_major, 0), port_total); -err_register_swp_module_2: - unregister_chrdev_region(MKDEV(ctl_major, 0), 1); -err_register_swp_module_1: - return -1; -} - - -/* ========== Module initial relate ========== - */ -static int -create_ioexp_objs(void) { - - int i, run_mod; - - /* Clean IOEXP object */ - clean_ioexp_objs(); - /* Get running mode */ - run_mod = IOEXP_MODE_DIRECT; - if (SWP_POLLING_ENABLE){ - run_mod = IOEXP_MODE_POLLING; - } - /* Create IOEXP object */ - for(i=0; i devlen_max) { - snprintf(err_msg, sizeof(err_msg), - "SWP_DEV_PORT too long!"); - goto err_initport_create_tranobj; - } - memset(dev_name, 0, sizeof(dev_name)); - snprintf(dev_name, devlen_max, "%s%d", SWP_DEV_PORT, port_id); - /* Create transceiver object */ - ioexp_obj_p = get_ioexp_obj(ioexp_id); - if (!ioexp_obj_p){ - snprintf(err_msg, sizeof(err_msg), - "IOEXP object:%d not exist", ioexp_id); - goto err_initport_create_tranobj; - } - transvr_obj_p = create_transvr_obj(dev_name, chan_id, ioexp_obj_p, - ioexp_virt_offset, transvr_type, - chipset_type, run_mod); - if (!transvr_obj_p){ - snprintf(err_msg, sizeof(err_msg), - "Create transceiver object fail :%s", dev_name); - goto err_initport_create_tranobj; - } - - transvr_obj_p->port_no = minor_curr; - - /* Setup Lane_ID mapping */ - i = ARRAY_SIZE(port_layout[minor_curr].lane_id); - j = ARRAY_SIZE(transvr_obj_p->lane_id); - if (i != j) { - snprintf(err_msg, sizeof(err_msg), - "Lane_id size inconsistent %d/%d", i, j); - goto err_initport_reg_device; - } - memcpy(transvr_obj_p->lane_id, port_layout[minor_curr].lane_id, i*sizeof(int)); - /* Create and register device object */ - if (register_port_device(dev_name, MKDEV(port_major, minor_curr), transvr_obj_p) < 0){ - snprintf(err_msg, sizeof(err_msg), - "register_port_device fail"); - goto err_initport_reg_device; - } - /* Setup device_ptr of transvr_obj */ - dev_p = get_swpdev_by_name(dev_name); - if (!dev_p){ - snprintf(err_msg, sizeof(err_msg), - "get_swpdev_by_name fail"); - goto err_initport_reg_device; - } - transvr_obj_p->transvr_dev_p = dev_p; - /* Success */ - ok_count++; - } - SWPS_INFO("%s: initialed %d port-dev",__func__, ok_count); - return 0; - -err_initport_reg_device: - kfree(transvr_obj_p); -err_initport_create_tranobj: - clean_port_obj(); - SWPS_ERR("%s: %s", __func__, err_msg); - SWPS_ERR("Dump: :%d :%d :%d :%d :%d :%d\n", - port_id, chan_id, ioexp_id, ioexp_virt_offset, transvr_type, run_mod); - return -1; -} - - -static int -init_dev_topology(void){ - - int err; - char *emsg = "ERR"; - flag_mod_state = SWP_STATE_NORMAL; - - err = init_ioexp_objs(); - switch(err){ - case 0: /* Normal */ - SWPS_DEBUG("%s: normal case\n", __func__); - break; - - case -1: /* topology error */ - SWPS_DEBUG("%s: detect tier-1 topology initial failure :%d\n", - __func__, err); - /* Reset and isolate */ - err = reset_i2c_topology(); - if (err < 0) { - emsg = "reset i2c topology fail"; - goto err_init_dev_topology; - } - /* Re-initial again */ - err = init_ioexp_objs(); - if (err < 0) { - emsg = "re-init ioexp objects fail"; - goto err_init_dev_topology; - } - break; - - case -2: /* Internal error */ - SWPS_DEBUG("%s: internal error case\n", __func__); - err = -2; - emsg = "internal error"; - goto err_init_dev_topology; - - default: - SWPS_DEBUG("%s: undefined error case\n", __func__); - emsg = "undefined error case"; - goto err_init_dev_topology; - } - SWPS_DEBUG("%s: initial I2C topology success\n", __func__); - return 0; - -err_init_dev_topology: - SWPS_ERR("%s: %s :%d\n", __func__, emsg, err); - return -1; -} - - -static int -init_polling_task(void){ - - if (SWP_POLLING_ENABLE){ - schedule_delayed_work(&swp_polling, _get_polling_period()); - } - return 0; -} - - -static int -init_swps_common(void){ - - char *err_msg = "ERR"; - - auto_config = 0; - eeprom_update = 0; - if ((SWP_AUTOCONFIG_ENABLE) && (SWP_POLLING_ENABLE)){ - auto_config = 1; - } - if (register_modctl_device() < 0) { - err_msg = "register_modctl_device fail"; - goto err_init_swps_common_1; - } - if (_update_auto_config_2_trnasvr() < 0) { - err_msg = "_update_auto_config_2_trnasvr fail"; - goto err_init_swps_common_1; - } - if (init_polling_task() < 0){ - err_msg = "init_polling_task fail"; - goto err_init_swps_common_1; - } - return 0; - -err_init_swps_common_1: - clean_swps_common(); - SWPS_ERR("%s: %s\n", __func__, err_msg); - return -1; -} - - -static int __init -swp_module_init(void){ - - if (get_platform_type() < 0){ - goto err_init_out; - } - if (get_layout_info() < 0){ - goto err_init_out; - } - if (register_swp_module() < 0){ - goto err_init_out; - } - if (create_ioexp_objs() < 0){ - goto err_init_ioexp; - } - if (create_port_objs() < 0){ - goto err_init_portobj; - } - if (init_mux_gpio(gpio_rest_mux) < 0){ - goto err_init_mux; - } - if (init_dev_topology() < 0){ - goto err_init_topology; - } - if (init_swps_common() < 0){ - goto err_init_topology; - } - SWPS_INFO("Inventec switch-port module V.%s initial success.\n", SWP_VERSION); - return 0; - - -err_init_topology: - clean_mux_gpio(); -err_init_mux: - clean_port_obj(); -err_init_portobj: - clean_ioexp_objs(); -err_init_ioexp: - class_unregister(swp_class_p); - class_destroy(swp_class_p); - unregister_chrdev_region(MKDEV(ctl_major, 0), 1); - unregister_chrdev_region(MKDEV(port_major, 0), port_total); -err_init_out: - SWPS_ERR("Inventec switch-port module V.%s initial failure.\n", SWP_VERSION); - return -1; -} - - -static void __exit -swp_module_exit(void){ - - clean_swps_common(); - clean_port_obj(); - clean_ioexp_objs(); - clean_mux_gpio(); - class_unregister(swp_class_p); - class_destroy(swp_class_p); - unregister_chrdev_region(MKDEV(ctl_major, 0), 1); - unregister_chrdev_region(MKDEV(port_major, 0), port_total); - SWPS_INFO("Remove Inventec switch-port module success.\n"); -} - - -/* Module information */ -MODULE_AUTHOR(SWP_AUTHOR); -MODULE_DESCRIPTION(SWP_DESC); -MODULE_VERSION(SWP_VERSION); -MODULE_LICENSE(SWP_LICENSE); - -module_init(swp_module_init); -module_exit(swp_module_exit); - - - - - - diff --git a/packages/platforms/inventec/x86-64/d7032q28b/modules/builds/src/inv_swps.h b/packages/platforms/inventec/x86-64/d7032q28b/modules/builds/src/inv_swps.h deleted file mode 100644 index cba6d9acd..000000000 --- a/packages/platforms/inventec/x86-64/d7032q28b/modules/builds/src/inv_swps.h +++ /dev/null @@ -1,752 +0,0 @@ -/************************************************************************* - * - * inv_swps.h - * - * 2018 Inventec Corporation - * All Rights Reserved. - * - * NOTICE: All information contained herein is, and remains - * the property of Inventec Corp. and its suppliers, - * if any. The intellectual and technical concepts contained - * herein are proprietary to Inventec Corporation and its suppliers - * and may be covered by U.S. and Foreign Patents, patents in process, - * and are protected by trade secret or copyright law. - * - ************************************************************************/ - -#ifndef INV_SWPS_H -#define INV_SWPS_H - -#include "transceiver.h" -#include "io_expander.h" -#include "inv_mux.h" - -/* Module settings */ -#define SWP_CLS_NAME "swps" -#define SWP_DEV_PORT "port" -#define SWP_DEV_MODCTL "module" -#define SWP_RESET_PWD "inventec" -#define SWP_POLLING_PERIOD (300) /* msec */ -#define SWP_POLLING_ENABLE (1) -#define SWP_AUTOCONFIG_ENABLE (1) - -/* Module information */ -#define SWP_AUTHOR "Neil " -#define SWP_DESC "Inventec port and transceiver driver" -#define SWP_VERSION "4.2.3" -#define SWP_LICENSE "GPL" - -#define SWPS_KERN_VER_AF_3_10 (1) - -/* Module status define */ -#define SWP_STATE_NORMAL (0) -#define SWP_STATE_I2C_DIE (-91) - -/* [Note]: - * Functions and mechanism for auto-detect platform type is ready, - * But HW and BIOS not ready! We need to wait them. - * So, please do not use PLATFORM_TYPE_AUTO until they are ready. - * (2016.06.13) - */ -#define PLATFORM_TYPE_AUTO (100) -#define PLATFORM_TYPE_MAGNOLIA (111) -#define PLATFORM_TYPE_MAGNOLIA_FNC (112) -#define PLATFORM_TYPE_REDWOOD (121) -#define PLATFORM_TYPE_REDWOOD_FSL (122) -#define PLATFORM_TYPE_HUDSON32I_GA (131) -#define PLATFORM_TYPE_SPRUCE (141) -#define PLATFORM_TYPE_CYPRESS_GA1 (151) /* Up -> Down */ -#define PLATFORM_TYPE_CYPRESS_GA2 (152) /* Down -> Up */ -#define PLATFORM_TYPE_CYPRESS_BAI (153) /* Down -> Up */ -/* Current running platfrom */ -#define PLATFORM_SETTINGS PLATFORM_TYPE_REDWOOD - -/* Define platform flag and kernel version */ -#if (PLATFORM_SETTINGS == PLATFORM_TYPE_MAGNOLIA) - #define SWPS_MAGNOLIA (1) - #define SWPS_KERN_VER_BF_3_8 (1) -#elif (PLATFORM_SETTINGS == PLATFORM_TYPE_MAGNOLIA_FNC) - #define SWPS_MAGNOLIA (1) - #define SWPS_KERN_VER_AF_3_10 (1) -#elif (PLATFORM_SETTINGS == PLATFORM_TYPE_REDWOOD) - #define SWPS_REDWOOD (1) - #define SWPS_KERN_VER_BF_3_8 (1) -#elif (PLATFORM_SETTINGS == PLATFORM_TYPE_REDWOOD_FSL) - #define SWPS_REDWOOD_FSL (1) - #define SWPS_KERN_VER_BF_3_8 (1) -#elif (PLATFORM_SETTINGS == PLATFORM_TYPE_HUDSON32I_GA) - #define SWPS_HUDSON32I_GA (1) - #define SWPS_KERN_VER_BF_3_8 (1) -#elif (PLATFORM_SETTINGS == PLATFORM_TYPE_SPRUCE) - #define SWPS_SPRUCE (1) - #define SWPS_KERN_VER_BF_3_8 (1) -#elif (PLATFORM_SETTINGS == PLATFORM_TYPE_CYPRESS_GA1) - #define SWPS_CYPRESS_GA1 (1) - #define SWPS_KERN_VER_BF_3_8 (1) -#elif (PLATFORM_SETTINGS == PLATFORM_TYPE_CYPRESS_GA2) - #define SWPS_CYPRESS_GA2 (1) - #define SWPS_KERN_VER_BF_3_8 (1) -#elif (PLATFORM_SETTINGS == PLATFORM_TYPE_CYPRESS_BAI) - #define SWPS_CYPRESS_BAI (1) - #define SWPS_KERN_VER_AF_3_10 (1) -#endif - - -struct inv_platform_s { - int id; - char name[64]; -}; - -struct inv_ioexp_layout_s { - int ioexp_id; - int ioexp_type; - struct ioexp_addr_s addr[4]; -}; - -struct inv_port_layout_s { - int port_id; - int chan_id; - int ioexp_id; - int ioexp_offset; - int transvr_type; - int chipset_type; - int lane_id[8]; -}; - - -/* ========================================== - * Inventec Platform Settings - * ========================================== - */ -struct inv_platform_s platform_map[] = { - {PLATFORM_TYPE_AUTO, "Auto-Detect" }, - {PLATFORM_TYPE_MAGNOLIA, "Magnolia" }, - {PLATFORM_TYPE_MAGNOLIA_FNC, "Magnolia_FNC" }, - {PLATFORM_TYPE_REDWOOD, "Redwood" }, - {PLATFORM_TYPE_REDWOOD_FSL, "Redwood_FSL" }, - {PLATFORM_TYPE_HUDSON32I_GA, "Hudson32i" }, - {PLATFORM_TYPE_SPRUCE, "Spruce" }, - {PLATFORM_TYPE_CYPRESS_GA1, "Cypress_GA1" }, - {PLATFORM_TYPE_CYPRESS_GA2, "Cypress_GA2" }, - {PLATFORM_TYPE_CYPRESS_BAI, "Cypress_BAI" }, -}; - - -/* ========================================== - * Magnolia Layout configuration - * ========================================== - */ -#ifdef SWPS_MAGNOLIA -unsigned magnolia_gpio_rest_mux = MUX_RST_GPIO_48_PAC9548; - -struct inv_ioexp_layout_s magnolia_ioexp_layout[] = { - /* IOEXP_ID / IOEXP_TYPE / { Chan_ID, Chip_addr, Read_offset, Write_offset, config_offset, data_default, conf_default } */ - {0, IOEXP_TYPE_MAGINOLIA_NAB, { {2, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {2, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, }, /* addr[1] = I/O Expander N B */ - }, - {1, IOEXP_TYPE_MAGINOLIA_NAB, { {3, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {3, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, }, /* addr[1] = I/O Expander N B */ - }, - {2, IOEXP_TYPE_MAGINOLIA_NAB, { {4, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {4, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, }, /* addr[1] = I/O Expander N B */ - }, - {3, IOEXP_TYPE_MAGINOLIA_NAB, { {5, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {5, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, }, /* addr[1] = I/O Expander N B */ - }, - {4, IOEXP_TYPE_MAGINOLIA_NAB, { {6, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {6, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, }, /* addr[1] = I/O Expander N B */ - }, - {5, IOEXP_TYPE_MAGINOLIA_NAB, { {7, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {7, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, }, /* addr[1] = I/O Expander N B */ - }, - {6, IOEXP_TYPE_MAGINOLIA_7AB, { {8, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[0] = I/O Expander 7 A */ - {8, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xf0, 0x33}, }, }, /* addr[1] = I/O Expander 7 B */ - }, -}; - -struct inv_port_layout_s magnolia_port_layout[] = { - /* Port_ID / Chan_ID / IOEXP_ID / IOEXP_VIRT_OFFSET / TRANSCEIVER_TYPE / BCM_CHIP_TYPE / LANE_ID */ - { 0, 10, 0, 0, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 16} }, - { 1, 11, 0, 1, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 15} }, - { 2, 12, 0, 2, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 14} }, - { 3, 13, 0, 3, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 13} }, - { 4, 14, 0, 4, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 24} }, - { 5, 15, 0, 5, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 23} }, - { 6, 16, 0, 6, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 22} }, - { 7, 17, 0, 7, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 21} }, - { 8, 18, 1, 0, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 28} }, - { 9, 19, 1, 1, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 27} }, - {10, 20, 1, 2, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 26} }, - {11, 21, 1, 3, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 25} }, - {12, 22, 1, 4, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 32} }, - {13, 23, 1, 5, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 31} }, - {14, 24, 1, 6, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 30} }, - {15, 25, 1, 7, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 29} }, - {16, 26, 2, 0, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 48} }, - {17, 27, 2, 1, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 47} }, - {18, 28, 2, 2, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 46} }, - {19, 29, 2, 3, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 45} }, - {20, 30, 2, 4, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 52} }, - {21, 31, 2, 5, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 51} }, - {22, 32, 2, 6, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 50} }, - {23, 33, 2, 7, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 49} }, - {24, 34, 3, 0, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 56} }, - {25, 35, 3, 1, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 55} }, - {26, 36, 3, 2, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 54} }, - {27, 37, 3, 3, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 53} }, - {28, 38, 3, 4, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 60} }, - {29, 39, 3, 5, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 59} }, - {30, 40, 3, 6, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 58} }, - {31, 41, 3, 7, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 57} }, - {32, 42, 4, 0, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 64} }, - {33, 43, 4, 1, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 63} }, - {34, 44, 4, 2, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 62} }, - {35, 45, 4, 3, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 61} }, - {36, 46, 4, 4, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 68} }, - {37, 47, 4, 5, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 67} }, - {38, 48, 4, 6, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 66} }, - {39, 49, 4, 7, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 65} }, - {40, 50, 5, 0, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 72} }, - {41, 51, 5, 1, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 71} }, - {42, 52, 5, 2, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 70} }, - {43, 53, 5, 3, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 69} }, - {44, 54, 5, 4, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 76} }, - {45, 55, 5, 5, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 75} }, - {46, 56, 5, 6, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 74} }, - {47, 57, 5, 7, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 73} }, - {48, 58, 6, 0, TRANSVR_TYPE_QSFP, BCM_CHIP_TYPE_TRIDENT_2, { 81, 82, 83, 84} }, - {49, 59, 6, 1, TRANSVR_TYPE_QSFP, BCM_CHIP_TYPE_TRIDENT_2, { 77, 78, 79, 80} }, - {50, 60, 6, 2, TRANSVR_TYPE_QSFP, BCM_CHIP_TYPE_TRIDENT_2, { 97, 98, 99,100} }, - {51, 61, 6, 3, TRANSVR_TYPE_QSFP, BCM_CHIP_TYPE_TRIDENT_2, {101,102,103,104} }, - {52, 62, 6, 4, TRANSVR_TYPE_QSFP, BCM_CHIP_TYPE_TRIDENT_2, {105,106,107,108} }, - {53, 63, 6, 5, TRANSVR_TYPE_QSFP, BCM_CHIP_TYPE_TRIDENT_2, {109,110,111,112} }, -}; -#endif - - -/* ========================================== - * Redwood Layout configuration - * ========================================== - */ -#ifdef SWPS_REDWOOD -unsigned redwood_gpio_rest_mux = MUX_RST_GPIO_48_PAC9548; - -struct inv_ioexp_layout_s redwood_ioexp_layout[] = { - /* IOEXP_ID / IOEXP_TYPE / { Chan_ID, Chip_addr, Read_offset, Write_offset, config_offset, data_default, conf_default } */ - {0, IOEXP_TYPE_REDWOOD_P01P08, { {4, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[0] = I/O Expander 1-4 A */ - {4, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[1] = I/O Expander 1-4 B */ - {0, 0x25, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 5 B */ - }, - {1, IOEXP_TYPE_REDWOOD_P09P16, { {5, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[0] = I/O Expander 1-4 A */ - {5, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[1] = I/O Expander 1-4 B */ - {0, 0x25, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 5 B */ - }, - {2, IOEXP_TYPE_REDWOOD_P01P08, { {2, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[0] = I/O Expander 1-4 A */ - {2, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[1] = I/O Expander 1-4 B */ - {0, 0x24, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 5 B */ - }, - {3, IOEXP_TYPE_REDWOOD_P09P16, { {3, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[0] = I/O Expander 1-4 A */ - {3, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[1] = I/O Expander 1-4 B */ - {0, 0x24, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 5 B */ - }, -}; - -struct inv_port_layout_s redwood_port_layout[] = { - /* Port_ID / Chan_ID / IOEXP_ID / IOEXP_VIRT_OFFSET / TRANSCEIVER_TYPE / BCM_CHIP_TYPE / LANE_ID */ - { 0, 22, 0, 0, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 1, 2, 3, 4} }, - { 1, 23, 0, 1, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 5, 6, 7, 8} }, - { 2, 24, 0, 2, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 9, 10, 11, 12} }, - { 3, 25, 0, 3, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 13, 14, 15, 16} }, - { 4, 26, 0, 4, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 17, 18, 19, 20} }, - { 5, 27, 0, 5, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 21, 22, 23, 24} }, - { 6, 28, 0, 6, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 25, 26, 27, 28} }, - { 7, 29, 0, 7, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 29, 30, 31, 32} }, - { 8, 30, 1, 0, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 33, 34, 35, 36} }, - { 9, 31, 1, 1, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 37, 38, 39, 40} }, - {10, 32, 1, 2, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 41, 42, 43, 44} }, - {11, 33, 1, 3, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 45, 46, 47, 48} }, - {12, 34, 1, 4, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 49, 50, 51, 52} }, - {13, 35, 1, 5, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 53, 54, 55, 56} }, - {14, 36, 1, 6, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 57, 58, 59, 60} }, - {15, 37, 1, 7, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 61, 62, 63, 64} }, - {16, 6, 2, 0, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 65, 66, 67, 68} }, - {17, 7, 2, 1, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 69, 70, 71, 72} }, - {18, 8, 2, 2, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 73, 74, 75, 76} }, - {19, 9, 2, 3, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 77, 78, 79, 80} }, - {20, 10, 2, 4, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 81, 82, 83, 84} }, - {21, 11, 2, 5, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 85, 86, 87, 88} }, - {22, 12, 2, 6, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 89, 90, 91, 92} }, - {23, 13, 2, 7, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 93, 94, 95, 96} }, - {24, 14, 3, 0, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 97, 98, 99,100} }, - {25, 15, 3, 1, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {101,102,103,104} }, - {26, 16, 3, 2, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {105,106,107,108} }, - {27, 17, 3, 3, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {109,110,111,112} }, - {28, 18, 3, 4, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {113,114,115,116} }, - {29, 19, 3, 5, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {117,118,119,120} }, - {30, 20, 3, 6, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {121,122,123,124} }, - {31, 21, 3, 7, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {125,126,127,128} }, -}; -#endif - - -/* ========================================== - * Hudson32i Layout configuration - * ========================================== - */ -#ifdef SWPS_HUDSON32I_GA -unsigned hudsin32iga_gpio_rest_mux = MUX_RST_GPIO_48_PAC9548; - -struct inv_ioexp_layout_s hudson32iga_ioexp_layout[] = { - /* IOEXP_ID / IOEXP_TYPE / { Chan_ID, Chip_addr, Read_offset, Write_offset, config_offset, data_default, conf_default } */ - {0, IOEXP_TYPE_HUDSON32IGA_P01P08, { {2, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[0] = I/O Expander A */ - {2, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[1] = I/O Expander B */ - {0, 0x24, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 0x24 */ - }, - {1, IOEXP_TYPE_HUDSON32IGA_P09P16, { {3, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[0] = I/O Expander A */ - {3, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[1] = I/O Expander B */ - {0, 0x24, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 0x24 */ - }, - {2, IOEXP_TYPE_HUDSON32IGA_P01P08, { {4, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[0] = I/O Expander A */ - {4, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[1] = I/O Expander B */ - {0, 0x25, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 0x25 */ - }, - {3, IOEXP_TYPE_HUDSON32IGA_P09P16, { {5, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[0] = I/O Expander A */ - {5, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[1] = I/O Expander B */ - {0, 0x25, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 0x25 */ - }, -}; - -struct inv_port_layout_s hudson32iga_port_layout[] = { - /* Port_ID / Chan_ID / IOEXP_ID / IOEXP_VIRT_OFFSET / TRANSCEIVER_TYPE / BCM_CHIP_TYPE / LANE_ID */ - { 0, 6, 0, 0, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, { 1, 2, 3, 4} }, - { 1, 7, 0, 1, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, { 5, 6, 7, 8} }, - { 2, 8, 0, 2, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, { 9, 10, 11, 12} }, - { 3, 9, 0, 3, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, { 13, 14, 15, 16} }, - { 4, 10, 0, 4, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, { 17, 18, 19, 20} }, - { 5, 11, 0, 5, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, { 21, 22, 23, 24} }, - { 6, 12, 0, 6, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, { 25, 26, 27, 28} }, - { 7, 13, 0, 7, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, { 29, 30, 31, 32} }, - { 8, 14, 1, 0, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, { 33, 34, 35, 36} }, - { 9, 15, 1, 1, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, { 37, 38, 39, 40} }, - {10, 16, 1, 2, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, { 41, 42, 43, 44} }, - {11, 17, 1, 3, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, { 45, 46, 47, 48} }, - {12, 18, 1, 4, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, { 49, 50, 51, 52} }, - {13, 19, 1, 5, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, { 53, 54, 55, 56} }, - {14, 20, 1, 6, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, { 57, 58, 59, 60} }, - {15, 21, 1, 7, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, { 61, 62, 63, 64} }, - {16, 22, 2, 0, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, { 65, 66, 67, 68} }, - {17, 23, 2, 1, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, { 69, 70, 71, 72} }, - {18, 24, 2, 2, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, { 73, 74, 75, 76} }, - {19, 25, 2, 3, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, { 77, 78, 79, 80} }, - {20, 26, 2, 4, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, { 81, 82, 83, 84} }, - {21, 27, 2, 5, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, { 85, 86, 87, 88} }, - {22, 28, 2, 6, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, { 89, 90, 91, 92} }, - {23, 29, 2, 7, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, { 93, 94, 95, 96} }, - {24, 30, 3, 0, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, { 97, 98, 99,100} }, - {25, 31, 3, 1, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, {101,102,103,104} }, - {26, 32, 3, 2, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, {105,106,107,108} }, - {27, 33, 3, 3, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, {109,110,111,112} }, - {28, 34, 3, 4, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, {113,114,115,116} }, - {29, 35, 3, 5, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, {117,118,119,120} }, - {30, 36, 3, 6, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, {121,122,123,124} }, - {31, 37, 3, 7, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, {125,126,127,128} }, -}; -#endif - - -/* ========================================== - * Spruce Layout configuration - * ========================================== - */ -#ifdef SWPS_SPRUCE -unsigned spruce_gpio_rest_mux = MUX_RST_GPIO_48_PAC9548; - -struct inv_ioexp_layout_s spruce_ioexp_layout[] = { - /* IOEXP_ID / IOEXP_TYPE / { Chan_ID, Chip_addr, Read_offset, Write_offset, config_offset, data_default, conf_default } */ - {0, IOEXP_TYPE_SPRUCE_7AB, { {2, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[0] = I/O Expander 7A */ - {2, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xf0, 0x33}, }, }, /* addr[2] = I/O Expander 7B */ - }, -}; - -struct inv_port_layout_s spruce_port_layout[] = { - /* Port_ID / Chan_ID / IOEXP_ID / IOEXP_VIRT_OFFSET / TRANSCEIVER_TYPE / BCM_CHIP_TYPE / LANE_ID */ - { 0, 6, 0, 0, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, { 81, 82, 83, 84} }, - { 1, 7, 0, 1, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, { 77, 78, 79, 80} }, - { 2, 8, 0, 2, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, { 97, 98, 99,100} }, - { 3, 9, 0, 3, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, {101,102,103,104} }, - { 4, 10, 0, 4, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, {105,106,107,108} }, - { 5, 11, 0, 5, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, {109,110,111,112} }, -}; -#endif - - -/* ========================================== - * Cypress Layout configuration (Inventec version [Up->Down]) - * ========================================== - */ -#ifdef SWPS_CYPRESS_GA1 -unsigned cypress_ga1_gpio_rest_mux = MUX_RST_GPIO_69_PAC9548; - -struct inv_ioexp_layout_s cypress_ga1_ioexp_layout[] = { - /* IOEXP_ID / IOEXP_TYPE / { Chan_ID, Chip_addr, Read_offset, Write_offset, config_offset, data_default, conf_default } */ - {0, IOEXP_TYPE_CYPRESS_NABC, { {2, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {2, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {2, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {1, IOEXP_TYPE_CYPRESS_NABC, { {3, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {3, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {3, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {2, IOEXP_TYPE_CYPRESS_NABC, { {4, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {4, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {4, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {3, IOEXP_TYPE_CYPRESS_NABC, { {5, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {5, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {5, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {4, IOEXP_TYPE_CYPRESS_NABC, { {6, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {6, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {6, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {5, IOEXP_TYPE_CYPRESS_NABC, { {7, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {7, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {7, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {6, IOEXP_TYPE_CYPRESS_7ABC, { {8, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xc0, 0xc0}, }, /* addr[0] = I/O Expander 7 A */ - {8, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xc0, 0xc0}, {0xff, 0xc0}, }, /* addr[1] = I/O Expander 7 B */ - {8, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 7 C */ - }, -}; - -struct inv_port_layout_s cypress_ga1_port_layout[] = { - /* Port_ID / Chan_ID / IOEXP_ID / IOEXP_VIRT_OFFSET / TRANSCEIVER_TYPE / BCM_CHIP_TYPE / LANE_ID */ - { 0, 10, 0, 0, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 1} }, - { 1, 11, 0, 1, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 2} }, - { 2, 12, 0, 2, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 3} }, - { 3, 13, 0, 3, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 4} }, - { 4, 14, 0, 4, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 5} }, - { 5, 15, 0, 5, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 6} }, - { 6, 16, 0, 6, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 7} }, - { 7, 17, 0, 7, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 8} }, - { 8, 18, 1, 0, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 9} }, - { 9, 19, 1, 1, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 10} }, - {10, 20, 1, 2, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 11} }, - {11, 21, 1, 3, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 12} }, - {12, 22, 1, 4, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 21} }, - {13, 23, 1, 5, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 22} }, - {14, 24, 1, 6, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 23} }, - {15, 25, 1, 7, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 24} }, - {16, 26, 2, 0, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 33} }, - {17, 27, 2, 1, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 34} }, - {18, 28, 2, 2, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 35} }, - {19, 29, 2, 3, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 36} }, - {20, 30, 2, 4, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 37} }, - {21, 31, 2, 5, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 38} }, - {22, 32, 2, 6, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 39} }, - {23, 33, 2, 7, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 40} }, - {24, 34, 3, 0, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 41} }, - {25, 35, 3, 1, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 42} }, - {26, 36, 3, 2, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 43} }, - {27, 37, 3, 3, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 44} }, - {28, 38, 3, 4, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 49} }, - {29, 39, 3, 5, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 50} }, - {30, 40, 3, 6, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 51} }, - {31, 41, 3, 7, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 52} }, - {32, 42, 4, 0, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 53} }, - {33, 43, 4, 1, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 54} }, - {34, 44, 4, 2, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 55} }, - {35, 45, 4, 3, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 56} }, - {36, 46, 4, 4, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 65} }, - {37, 47, 4, 5, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 66} }, - {38, 48, 4, 6, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 67} }, - {39, 49, 4, 7, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 68} }, - {40, 50, 5, 0, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 69} }, - {41, 51, 5, 1, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 70} }, - {42, 52, 5, 2, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 71} }, - {43, 53, 5, 3, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 72} }, - {44, 54, 5, 4, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 81} }, - {45, 55, 5, 5, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 82} }, - {46, 56, 5, 6, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 83} }, - {47, 57, 5, 7, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 84} }, - {48, 58, 6, 0, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 97, 98, 99,100} }, - {49, 59, 6, 1, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 85, 86, 87, 88} }, - {50, 60, 6, 2, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {101,102,103,104} }, - {51, 61, 6, 3, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {105,106,107,108} }, - {52, 62, 6, 4, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {109,110,111,112} }, - {53, 63, 6, 5, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {117,118,119,120} }, -}; -#endif - - -/* ========================================== - * Cypress Layout configuration (Inventec version [Down->Up]) - * ========================================== - */ -#ifdef SWPS_CYPRESS_GA2 -unsigned cypress_ga2_gpio_rest_mux = MUX_RST_GPIO_FORCE_HEDERA; - -struct inv_ioexp_layout_s cypress_ga2_ioexp_layout[] = { - /* IOEXP_ID / IOEXP_TYPE / { Chan_ID, Chip_addr, Read_offset, Write_offset, config_offset, data_default, conf_default } */ - {0, IOEXP_TYPE_CYPRESS_NABC, { {2, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {2, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {2, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {1, IOEXP_TYPE_CYPRESS_NABC, { {3, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {3, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {3, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {2, IOEXP_TYPE_CYPRESS_NABC, { {4, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {4, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {4, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {3, IOEXP_TYPE_CYPRESS_NABC, { {5, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {5, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {5, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {4, IOEXP_TYPE_CYPRESS_NABC, { {6, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {6, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {6, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {5, IOEXP_TYPE_CYPRESS_NABC, { {7, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {7, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {7, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {6, IOEXP_TYPE_CYPRESS_7ABC, { {8, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xc0, 0xc0}, }, /* addr[0] = I/O Expander 7 A */ - {8, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xc0, 0xc0}, {0xff, 0xc0}, }, /* addr[1] = I/O Expander 7 B */ - {8, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 7 C */ - }, -}; - -struct inv_port_layout_s cypress_ga2_port_layout[] = { - /* Port_ID / Chan_ID / IOEXP_ID / IOEXP_VIRT_OFFSET / TRANSCEIVER_TYPE / BCM_CHIP_TYPE / LANE_ID */ - { 0, 11, 0, 1, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 2} }, - { 1, 10, 0, 0, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 1} }, - { 2, 13, 0, 3, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 4} }, - { 3, 12, 0, 2, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 3} }, - { 4, 15, 0, 5, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 6} }, - { 5, 14, 0, 4, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 5} }, - { 6, 17, 0, 7, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 8} }, - { 7, 16, 0, 6, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 7} }, - { 8, 19, 1, 1, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 10} }, - { 9, 18, 1, 0, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 9} }, - {10, 21, 1, 3, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 12} }, - {11, 20, 1, 2, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 11} }, - {12, 23, 1, 5, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 22} }, - {13, 22, 1, 4, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 21} }, - {14, 25, 1, 7, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 24} }, - {15, 24, 1, 6, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 23} }, - {16, 27, 2, 1, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 34} }, - {17, 26, 2, 0, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 33} }, - {18, 29, 2, 3, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 36} }, - {19, 28, 2, 2, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 35} }, - {20, 31, 2, 5, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 38} }, - {21, 30, 2, 4, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 37} }, - {22, 33, 2, 7, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 40} }, - {23, 32, 2, 6, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 39} }, - {24, 35, 3, 1, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 42} }, - {25, 34, 3, 0, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 41} }, - {26, 37, 3, 3, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 44} }, - {27, 36, 3, 2, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 43} }, - {28, 39, 3, 5, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 50} }, - {29, 38, 3, 4, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 49} }, - {30, 41, 3, 7, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 52} }, - {31, 40, 3, 6, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 51} }, - {32, 43, 4, 1, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 54} }, - {33, 42, 4, 0, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 53} }, - {34, 45, 4, 3, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 56} }, - {35, 44, 4, 2, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 55} }, - {36, 47, 4, 5, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 66} }, - {37, 46, 4, 4, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 65} }, - {38, 49, 4, 7, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 68} }, - {39, 48, 4, 6, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 67} }, - {40, 51, 5, 1, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 70} }, - {41, 50, 5, 0, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 69} }, - {42, 53, 5, 3, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 72} }, - {43, 52, 5, 2, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 71} }, - {44, 55, 5, 5, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 82} }, - {45, 54, 5, 4, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 81} }, - {46, 57, 5, 7, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 84} }, - {47, 56, 5, 6, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 83} }, - {48, 59, 6, 1, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 85, 86, 87, 88} }, - {49, 58, 6, 0, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 97, 98, 99,100} }, - {50, 61, 6, 3, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {105,106,107,108} }, - {51, 60, 6, 2, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {101,102,103,104} }, - {52, 63, 6, 5, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {117,118,119,120} }, - {53, 62, 6, 4, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {109,110,111,112} }, -}; -#endif - - -/* ========================================== - * Cypress Layout configuration (BaiDu version) - * ========================================== - */ -#ifdef SWPS_CYPRESS_BAI -unsigned cypress_b_gpio_rest_mux = MUX_RST_GPIO_FORCE_HEDERA; - -struct inv_ioexp_layout_s cypress_b_ioexp_layout[] = { - /* IOEXP_ID / IOEXP_TYPE / { Chan_ID, Chip_addr, Read_offset, Write_offset, config_offset, data_default, conf_default } */ - {0, IOEXP_TYPE_CYPRESS_NABC, { {2, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {2, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {2, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {1, IOEXP_TYPE_CYPRESS_NABC, { {3, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {3, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {3, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {2, IOEXP_TYPE_CYPRESS_NABC, { {4, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {4, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {4, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {3, IOEXP_TYPE_CYPRESS_NABC, { {5, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {5, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {5, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {4, IOEXP_TYPE_CYPRESS_NABC, { {6, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {6, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {6, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {5, IOEXP_TYPE_CYPRESS_NABC, { {7, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {7, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {7, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {6, IOEXP_TYPE_CYPRESS_7ABC, { {8, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xc0, 0xc0}, }, /* addr[0] = I/O Expander 7 A */ - {8, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xc0, 0xc0}, {0xff, 0xc0}, }, /* addr[1] = I/O Expander 7 B */ - {8, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 7 C */ - }, -}; - -struct inv_port_layout_s cypress_b_port_layout[] = { - /* Port_ID / Chan_ID / IOEXP_ID / IOEXP_VIRT_OFFSET / TRANSCEIVER_TYPE / BCM_CHIP_TYPE / LANE_ID */ - { 1, 11, 0, 1, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 2} }, - { 2, 10, 0, 0, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 1} }, - { 3, 13, 0, 3, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 4} }, - { 4, 12, 0, 2, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 3} }, - { 5, 15, 0, 5, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 6} }, - { 6, 14, 0, 4, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 5} }, - { 7, 17, 0, 7, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 8} }, - { 8, 16, 0, 6, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 7} }, - { 9, 19, 1, 1, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 10} }, - {10, 18, 1, 0, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 9} }, - {11, 21, 1, 3, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 12} }, - {12, 20, 1, 2, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 11} }, - {13, 23, 1, 5, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 22} }, - {14, 22, 1, 4, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 21} }, - {15, 25, 1, 7, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 24} }, - {16, 24, 1, 6, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 23} }, - {17, 27, 2, 1, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 34} }, - {18, 26, 2, 0, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 33} }, - {19, 29, 2, 3, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 36} }, - {20, 28, 2, 2, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 35} }, - {21, 31, 2, 5, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 38} }, - {22, 30, 2, 4, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 37} }, - {23, 33, 2, 7, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 40} }, - {24, 32, 2, 6, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 39} }, - {25, 35, 3, 1, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 42} }, - {26, 34, 3, 0, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 41} }, - {27, 37, 3, 3, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 44} }, - {28, 36, 3, 2, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 43} }, - {29, 39, 3, 5, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 50} }, - {30, 38, 3, 4, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 49} }, - {31, 41, 3, 7, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 52} }, - {32, 40, 3, 6, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 51} }, - {33, 43, 4, 1, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 54} }, - {34, 42, 4, 0, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 53} }, - {35, 45, 4, 3, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 56} }, - {36, 44, 4, 2, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 55} }, - {37, 47, 4, 5, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 66} }, - {38, 46, 4, 4, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 65} }, - {39, 49, 4, 7, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 68} }, - {40, 48, 4, 6, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 67} }, - {41, 51, 5, 1, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 70} }, - {42, 50, 5, 0, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 69} }, - {43, 53, 5, 3, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 72} }, - {44, 52, 5, 2, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 71} }, - {45, 55, 5, 5, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 82} }, - {46, 54, 5, 4, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 81} }, - {47, 57, 5, 7, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 84} }, - {48, 56, 5, 6, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 83} }, - {49, 59, 6, 1, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 85, 86, 87, 88} }, - {50, 58, 6, 0, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 97, 98, 99,100} }, - {51, 61, 6, 3, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {105,106,107,108} }, - {52, 60, 6, 2, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {101,102,103,104} }, - {53, 63, 6, 5, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {117,118,119,120} }, - {54, 62, 6, 4, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {109,110,111,112} }, -}; -#endif - - -/* ========================================== - * Redwood_fsl Layout configuration - * ========================================== - */ -#ifdef SWPS_REDWOOD_FSL -unsigned redwood_fsl_gpio_rest_mux = MUX_RST_GPIO_48_PAC9548; - -struct inv_ioexp_layout_s redwood_fsl_ioexp_layout[] = { - /* IOEXP_ID / IOEXP_TYPE / { Chan_ID, Chip_addr, Read_offset, Write_offset, config_offset, data_default, conf_default } */ - {0, IOEXP_TYPE_REDWOOD_P01P08, { {4, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[0] = I/O Expander 1-4 A */ - {4, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[1] = I/O Expander 1-4 B */ - {0, 0x25, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 5 B */ - }, - {1, IOEXP_TYPE_REDWOOD_P09P16, { {5, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[0] = I/O Expander 1-4 A */ - {5, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[1] = I/O Expander 1-4 B */ - {0, 0x25, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 5 B */ - }, - {2, IOEXP_TYPE_REDWOOD_P01P08, { {2, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[0] = I/O Expander 1-4 A */ - {2, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[1] = I/O Expander 1-4 B */ - {0, 0x24, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 5 B */ - }, - {3, IOEXP_TYPE_REDWOOD_P09P16, { {3, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[0] = I/O Expander 1-4 A */ - {3, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[1] = I/O Expander 1-4 B */ - {0, 0x24, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 5 B */ - }, -}; - - -struct inv_port_layout_s redwood_fsl_port_layout[] = { - /* Port_ID / Chan_ID / IOEXP_ID / IOEXP_VIRT_OFFSET / TRANSCEIVER_TYPE / BCM_CHIP_TYPE / LANE_ID */ - { 0, 22, 0, 0, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 1, 2, 3, 4} }, - { 1, 23, 0, 1, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 5, 6, 7, 8} }, - { 2, 24, 0, 2, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 9, 10, 11, 12} }, - { 3, 25, 0, 3, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 13, 14, 15, 16} }, - { 4, 26, 0, 4, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 17, 18, 19, 20} }, - { 5, 27, 0, 5, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 21, 22, 23, 24} }, - { 6, 28, 0, 6, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 25, 26, 27, 28} }, - { 7, 29, 0, 7, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 29, 30, 31, 32} }, - { 8, 30, 1, 0, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 33, 34, 35, 36} }, - { 9, 31, 1, 1, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 37, 38, 39, 40} }, - {10, 32, 1, 2, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 41, 42, 43, 44} }, - {11, 33, 1, 3, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 45, 46, 47, 48} }, - {12, 34, 1, 4, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 49, 50, 51, 52} }, - {13, 35, 1, 5, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 53, 54, 55, 56} }, - {14, 36, 1, 6, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 57, 58, 59, 60} }, - {15, 37, 1, 7, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 61, 62, 63, 64} }, - {16, 6, 2, 0, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 65, 66, 67, 68} }, - {17, 7, 2, 1, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 69, 70, 71, 72} }, - {18, 8, 2, 2, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 73, 74, 75, 76} }, - {19, 9, 2, 3, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 77, 78, 79, 80} }, - {20, 10, 2, 4, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 81, 82, 83, 84} }, - {21, 11, 2, 5, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 85, 86, 87, 88} }, - {22, 12, 2, 6, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 89, 90, 91, 92} }, - {23, 13, 2, 7, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 93, 94, 95, 96} }, - {24, 14, 3, 0, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 97, 98, 99,100} }, - {25, 15, 3, 1, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {101,102,103,104} }, - {26, 16, 3, 2, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {105,106,107,108} }, - {27, 17, 3, 3, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {109,110,111,112} }, - {28, 18, 3, 4, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {113,114,115,116} }, - {29, 19, 3, 5, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {117,118,119,120} }, - {30, 20, 3, 6, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {121,122,123,124} }, - {31, 21, 3, 7, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {125,126,127,128} }, -}; -#endif - - -#endif /* INV_SWPS_H */ - - - - - - diff --git a/packages/platforms/inventec/x86-64/d7032q28b/modules/builds/src/inv_vpd.c b/packages/platforms/inventec/x86-64/d7032q28b/modules/builds/src/inv_vpd.c deleted file mode 100644 index b4b232a4d..000000000 --- a/packages/platforms/inventec/x86-64/d7032q28b/modules/builds/src/inv_vpd.c +++ /dev/null @@ -1,358 +0,0 @@ -/************************************************************************* - * - * inv_vpd.c - * - * 2018 Inventec Corporation - * All Rights Reserved. - * - * NOTICE: All information contained herein is, and remains - * the property of Inventec Corp. and its suppliers, - * if any. The intellectual and technical concepts contained - * herein are proprietary to Inventec Corporation and its suppliers - * and may be covered by U.S. and Foreign Patents, patents in process, - * and are protected by trade secret or copyright law. - * - ************************************************************************/ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "inv_vpd.h" -#include "onie_tlvinfo.h" - -static int vpd_major; -static struct class *vpd_class_p = NULL; -static char cEeprom[SYS_EEPROM_MAX_SIZE]; -static DEFINE_MUTEX(vpd_mutex); - -static int -__swp_match(struct device *dev, -#ifdef VPD_KERN_VER_AF_3_10 - - const void *data){ -#else - void *data){ -#endif - - char *name = (char *)data; - if (strcmp(dev_name(dev), name) == 0) - return 1; - return 0; -} - -static -int get_vpd_data(struct i2c_client *pi2c_client, int i_offset, char *c_buf) -{ - int iRet; - - read_eeprom( pi2c_client, cEeprom); - iRet = tlvinfo_decode_tlv(cEeprom, i_offset,c_buf); - return iRet; -} - -static -int write_vpd_data(struct i2c_client *pi2c_client, int i_offset, char *c_buf) -{ - int iErr = 0; - - if (read_eeprom(pi2c_client, cEeprom)) { - printk(KERN_ERR "write vpd data eror at %d-%s\n", __LINE__, __FUNCTION__); - return -1; - } - - if (tlvinfo_delete_tlv(cEeprom, i_offset) == TRUE) { - } - if (c_buf) { - if(!tlvinfo_add_tlv(cEeprom, i_offset , c_buf)) { - printk(KERN_ERR "write vpd data eror at %d-%s\n", __LINE__, __FUNCTION__); - iErr = -1; - } else { - iErr = prog_eeprom(pi2c_client,cEeprom); - } - } - return iErr; -} - -static struct device * -get_swpdev_by_name(char *name){ - struct device *dev = class_find_device(vpd_class_p, - NULL, - name, - __swp_match); - return dev; -} - -static ssize_t -store_attr_vpd(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - struct i2c_client *pi2c_client = dev_get_drvdata(dev_p); - struct vpd_device_attribute *attr = to_vpd_dev_attr(attr_p); - int iOffset = attr->index; - int iErr , iLen; - char *pChar; - - if (!pi2c_client){ - return -ENODEV; - } - mutex_lock(&vpd_mutex); - - //-strip 0x0a in the last byte. - for (iLen = 0, pChar = (char *)buf_p; - iLen < 255 && *pChar != 0; - iLen++, pChar++) ; - if (iLen !=0 && *pChar == 0 && *(pChar-1) == 0x0a) - *(pChar - 1) = 0; - //- - - iErr = write_vpd_data( pi2c_client, iOffset, (char *)buf_p); - - mutex_unlock(&vpd_mutex); - return count; -} - -static ssize_t -show_attr_vpd(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct i2c_client *pi2c_client = dev_get_drvdata(dev_p); - struct vpd_device_attribute *attr = to_vpd_dev_attr(attr_p); - int iOffset = attr->index; - int iErr , iLen; - - if (!pi2c_client){ - return -ENODEV; - } - mutex_lock(&vpd_mutex); - iErr = get_vpd_data( pi2c_client, iOffset, buf_p); - mutex_unlock(&vpd_mutex); - - if( iErr <= 0 ) - iLen = 0; - else - iLen = snprintf(buf_p, TLV_DECODE_VALUE_MAX_LEN, "%s\n", buf_p); - - return iLen; -} - - -/* ================= Vpd attribute ======================== - */ -static VPD_DEVICE_ATTR(product_name ,S_IWUSR|S_IRUGO, show_attr_vpd, store_attr_vpd, TLV_CODE_PRODUCT_NAME ); -static VPD_DEVICE_ATTR(pn ,S_IWUSR|S_IRUGO, show_attr_vpd, store_attr_vpd, TLV_CODE_PART_NUMBER ); -static VPD_DEVICE_ATTR(sn ,S_IWUSR|S_IRUGO, show_attr_vpd, store_attr_vpd, TLV_CODE_SERIAL_NUMBER ); -static VPD_DEVICE_ATTR(base_mac_addr,S_IWUSR|S_IRUGO, show_attr_vpd, store_attr_vpd, TLV_CODE_MAC_BASE ); -static VPD_DEVICE_ATTR(man_date ,S_IWUSR|S_IRUGO, show_attr_vpd, store_attr_vpd, TLV_CODE_MANUF_DATE ); -static VPD_DEVICE_ATTR(dev_ver ,S_IWUSR|S_IRUGO, show_attr_vpd, store_attr_vpd, TLV_CODE_DEVICE_VERSION ); -static VPD_DEVICE_ATTR(label_rev ,S_IWUSR|S_IRUGO, show_attr_vpd, store_attr_vpd, TLV_CODE_LABEL_REVISION ); -static VPD_DEVICE_ATTR(plat_name ,S_IWUSR|S_IRUGO, show_attr_vpd, store_attr_vpd, TLV_CODE_PLATFORM_NAME ); -static VPD_DEVICE_ATTR(ldr_ver ,S_IWUSR|S_IRUGO, show_attr_vpd, store_attr_vpd, TLV_CODE_ONIE_VERSION ); -static VPD_DEVICE_ATTR(mac_addr ,S_IWUSR|S_IRUGO, show_attr_vpd, store_attr_vpd, TLV_CODE_MAC_SIZE ); -static VPD_DEVICE_ATTR(manufacturer ,S_IWUSR|S_IRUGO, show_attr_vpd, store_attr_vpd, TLV_CODE_MANUF_NAME ); -static VPD_DEVICE_ATTR(country_code ,S_IWUSR|S_IRUGO, show_attr_vpd, store_attr_vpd, TLV_CODE_MANUF_COUNTRY ); -static VPD_DEVICE_ATTR(vendor_name ,S_IWUSR|S_IRUGO, show_attr_vpd, store_attr_vpd, TLV_CODE_VENDOR_NAME ); -static VPD_DEVICE_ATTR(diag_ver ,S_IWUSR|S_IRUGO, show_attr_vpd, store_attr_vpd, TLV_CODE_DIAG_VERSION ); -static VPD_DEVICE_ATTR(service_tag ,S_IWUSR|S_IRUGO, show_attr_vpd, store_attr_vpd, TLV_CODE_SERVICE_TAG ); -static VPD_DEVICE_ATTR(vendor_ext ,S_IWUSR|S_IRUGO, show_attr_vpd, store_attr_vpd, TLV_CODE_VENDOR_EXT ); -static VPD_DEVICE_ATTR(crc32 ,S_IRUGO, show_attr_vpd, NULL, TLV_CODE_CRC_32 ); - -static void -clean_vpd_common(void) -{ - dev_t dev_num; - struct device *device_p; - - device_p = get_swpdev_by_name(VPD_DEVICE); - if (device_p){ - dev_num = MKDEV(vpd_major, 1); - device_unregister(device_p); - device_destroy(vpd_class_p, dev_num); - } - VPD_DEBUG("%s: done.\n", __func__); -} - - -static struct register_attr VpdRegAttr[] ={ - { &vpd_dev_attr_product_name.dev_attr, "vpd_dev_attr_product_name"}, - { &vpd_dev_attr_pn.dev_attr, "vpd_dev_attr_pn"}, - { &vpd_dev_attr_sn.dev_attr, "vpd_dev_attr_sn"}, - { &vpd_dev_attr_base_mac_addr.dev_attr, "vpd_dev_attr_base_mac_addr"}, - { &vpd_dev_attr_man_date.dev_attr, "vpd_dev_attr_man_date"}, - { &vpd_dev_attr_dev_ver.dev_attr, "vpd_dev_attr_dev_ver"}, - { &vpd_dev_attr_label_rev.dev_attr, "vpd_dev_attr_label_rev"}, - { &vpd_dev_attr_plat_name.dev_attr, "vpd_dev_attr_plat_name"}, - { &vpd_dev_attr_ldr_ver.dev_attr, "vpd_dev_attr_ldr_ver"}, - { &vpd_dev_attr_mac_addr.dev_attr, "vpd_dev_attr_mac_addr"}, - { &vpd_dev_attr_manufacturer.dev_attr, "vpd_dev_attr_manufacturer"}, - { &vpd_dev_attr_country_code.dev_attr, "vpd_dev_attr_country_code"}, - { &vpd_dev_attr_vendor_name.dev_attr, "vpd_dev_attr_vendor_name"}, - { &vpd_dev_attr_diag_ver.dev_attr, "vpd_dev_attr_diag_ver"}, - { &vpd_dev_attr_service_tag.dev_attr, "vpd_dev_attr_service_tag"}, - { &vpd_dev_attr_vendor_ext.dev_attr, "vpd_dev_attr_vendor_ext"}, - { &vpd_dev_attr_crc32.dev_attr, "vpd_dev_attr_crc32"}, -}; -#define VPD_ENTRY_SIZE (sizeof(VpdRegAttr)/sizeof(struct register_attr)) - -static int -register_vpd_attr(struct device *device_p){ - - char *err_attr = NULL; - int i; - - for( i = 0 ; i adapter = adap; - vpd_i2c_client->addr = VPD_I2C_ADDR; - - device_p = device_create(vpd_class_p, /* struct class *cls */ - NULL, /* struct device *parent */ - dev_num, /* dev_t devt */ - vpd_i2c_client, /* void *private_data */ - VPD_DEVICE); /* const char *fmt */ - if (IS_ERR(device_p)){ - err_msg = "device_create fail"; - goto err_register_vpd_device_1; - } - if (register_vpd_attr(device_p) < 0) { - err_msg = "register_vpd_attr fail"; - goto err_register_vpd_device_2; - } - return 0; - -err_register_vpd_device_2: - device_unregister(device_p); - device_destroy(vpd_class_p, dev_num); -err_register_vpd_device_1: - kfree(vpd_i2c_client); - vpd_i2c_client = NULL; -err_register_vpd_device: - VPD_ERR("%s: %s\n", __func__, err_msg); - return -1; -} - -static int -register_vpd_module(void) -{ - dev_t vpd_devt = 0; - - if (alloc_chrdev_region(&vpd_devt, 0, 1, VPD_DEVICE) < 0){ - VPD_WARN("Allocate VPD MAJOR failure! \n"); - goto err_register_vpd_module; - } - vpd_major = MAJOR(vpd_devt); - - /* Create class object */ - vpd_class_p = class_create(THIS_MODULE, EEPROM_CLASS); - if (IS_ERR(vpd_class_p)) { - VPD_ERR("Create class failure! \n"); - goto err_register_vpd_module_1; - } - return 0; - -err_register_vpd_module_1: - unregister_chrdev_region(MKDEV(vpd_major, 0), 1); -err_register_vpd_module: - return -1; -} - - -static int -init_vpd_common(void) -{ - char *err_msg = "ERR"; - - if (register_vpd_device() < 0) { - err_msg = "register_vpd_device fail"; - goto err_init_vpd_common; - } - return 0; - -err_init_vpd_common: - VPD_ERR("%s: %s\n", __func__, err_msg); - return -1; -} - - -static int __init -vpd_module_init(void) -{ - if (register_vpd_module() < 0){ - goto err_vpd_module_init; - } - if (init_vpd_common() < 0){ - goto err_vpd_module_init_1; - } - VPD_INFO("Inventec vpd module V.%s initial success.\n", VPD_VERSION); - return 0; - -err_vpd_module_init_1: - class_unregister(vpd_class_p); - class_destroy(vpd_class_p); - unregister_chrdev_region(MKDEV(vpd_major, 0), 1); -err_vpd_module_init: - VPD_ERR("Inventec vpd module V.%s initial failure.\n", VPD_VERSION); - return -1; -} - - -static void __exit -vpd_module_exit(void) -{ - clean_vpd_common(); - class_unregister(vpd_class_p); - class_destroy(vpd_class_p); - unregister_chrdev_region(MKDEV(vpd_major, 0), 1); - VPD_INFO("Remove Inventec vpd module success.\n"); -} - - -/* Module information */ -MODULE_AUTHOR(VPD_AUTHOR); -MODULE_DESCRIPTION(VPD_DESC); -MODULE_VERSION(VPD_VERSION); -MODULE_LICENSE(VPD_LICENSE); - -module_init(vpd_module_init); -module_exit(vpd_module_exit); diff --git a/packages/platforms/inventec/x86-64/d7032q28b/modules/builds/src/inv_vpd.h b/packages/platforms/inventec/x86-64/d7032q28b/modules/builds/src/inv_vpd.h deleted file mode 100644 index 7cbae65e7..000000000 --- a/packages/platforms/inventec/x86-64/d7032q28b/modules/builds/src/inv_vpd.h +++ /dev/null @@ -1,63 +0,0 @@ -/************************************************************************* - * - * inv_vpd.h - * - * 2018 Inventec Corporation - * All Rights Reserved. - * - * NOTICE: All information contained herein is, and remains - * the property of Inventec Corp. and its suppliers, - * if any. The intellectual and technical concepts contained - * herein are proprietary to Inventec Corporation and its suppliers - * and may be covered by U.S. and Foreign Patents, patents in process, - * and are protected by trade secret or copyright law. - * - ************************************************************************/ - -#ifndef INV_VPD_H -#define INV_VPD_H - -#define EEPROM_CLASS "eeprom" -#define VPD_DEVICE "vpd" -#define VPD_AUTHOR "Neil " -#define VPD_DESC "Inventec eeprom vpd driver" -#define VPD_VERSION "1.0.0" -#define VPD_LICENSE "GPL" - -#define VPD_I2C_BUS (0) -#define VPD_I2C_ADDR (0x53) - -#define VPD_KERN_VER_AF_3_10 (1) - -struct register_attr { -struct device_attribute *attr; -char * errmsg; -}; - -struct vpd_device_attribute{ - struct device_attribute dev_attr; - int index; -}; - -#define to_vpd_dev_attr(_dev_attr) \ - container_of(_dev_attr, struct vpd_device_attribute, dev_attr) - -#define VPD_ATTR(_name, _mode, _show, _store, _index) \ - { .dev_attr = __ATTR(_name, _mode, _show, _store), \ - .index = _index } - -#define VPD_DEVICE_ATTR(_name, _mode, _show, _store, _index) \ - struct vpd_device_attribute vpd_dev_attr_##_name \ - = VPD_ATTR(_name, _mode, _show, _store, _index) - -#define VPD_INFO(fmt, args...) printk( KERN_INFO "[VPD] " fmt, ##args) -#define VPD_WARN(fmt, args...) printk( KERN_WARNING "[VPD] " fmt, ##args) -#define VPD_ERR(fmt, args...) printk( KERN_ERR "[VPD] " fmt, ##args) - -#ifdef DEBUG_VPD -# define VPD_DEBUG(fmt, args...) printk( KERN_DEBUG "[VPD] " fmt, ##args) -#else -# define VPD_DEBUG(fmt, args...) -#endif - -#endif /* INV_VPD_H */ diff --git a/packages/platforms/inventec/x86-64/d7032q28b/modules/builds/src/io_expander.c b/packages/platforms/inventec/x86-64/d7032q28b/modules/builds/src/io_expander.c deleted file mode 100644 index 3ef271ac4..000000000 --- a/packages/platforms/inventec/x86-64/d7032q28b/modules/builds/src/io_expander.c +++ /dev/null @@ -1,1700 +0,0 @@ -/************************************************************************* - * - * io_expander.c - * - * 2018 Inventec Corporation - * All Rights Reserved. - * - * NOTICE: All information contained herein is, and remains - * the property of Inventec Corp. and its suppliers, - * if any. The intellectual and technical concepts contained - * herein are proprietary to Inventec Corporation and its suppliers - * and may be covered by U.S. and Foreign Patents, patents in process, - * and are protected by trade secret or copyright law. - * - ************************************************************************/ - -#include -#include -#include -#include "io_expander.h" - -static struct ioexp_obj_s *ioexp_head_p = NULL; -static struct ioexp_obj_s *ioexp_tail_p = NULL; - - -/* ========== Register IOEXP layout ========== - */ -struct ioexp_map_s ioexp_map_magnolia_nab = { - - .chip_amount = 2, - .data_width = 2, - - .map_present = { {0, 0, 4}, /* map_present[0] = MOD_ABS_PORT(X) */ - {0, 0, 5}, /* map_present[1] = MOD_ABS_PORT(X+1) */ - {0, 0, 6}, /* map_present[2] = MOD_ABS_PORT(X+2) */ - {0, 0, 7}, /* map_present[3] = MOD_ABS_PORT(X+3) */ - {1, 0, 4}, /* map_present[4] = MOD_ABS_PORT(X+4) */ - {1, 0, 5}, /* map_present[5] = MOD_ABS_PORT(X+5) */ - {1, 0, 6}, /* map_present[6] = MOD_ABS_PORT(X+6) */ - {1, 0, 7}, /* map_present[7] = MOD_ABS_PORT(X+7) */ - }, - .map_tx_disable = { {0, 1, 0}, /* map_tx_disable[0] = TXDISABLE_SFP+_P(X) */ - {0, 1, 1}, /* map_tx_disable[1] = TXDISABLE_SFP+_P(X+1) */ - {0, 1, 2}, /* map_tx_disable[2] = TXDISABLE_SFP+_P(X+2) */ - {0, 1, 3}, /* map_tx_disable[3] = TXDISABLE_SFP+_P(X+3) */ - {1, 1, 0}, /* map_tx_disable[4] = TXDISABLE_SFP+_P(X+4) */ - {1, 1, 1}, /* map_tx_disable[5] = TXDISABLE_SFP+_P(X+5) */ - {1, 1, 2}, /* map_tx_disable[6] = TXDISABLE_SFP+_P(X+6) */ - {1, 1, 3}, /* map_tx_disable[7] = TXDISABLE_SFP+_P(X+7) */ - }, - .map_tx_fault = { {0, 0, 0}, /* map_tx_fault[0] = TXFAULT_SFP+_P(X) */ - {0, 0, 1}, /* map_tx_fault[1] = TXFAULT_SFP+_P(X+1) */ - {0, 0, 2}, /* map_tx_fault[2] = TXFAULT_SFP+_P(X+2) */ - {0, 0, 3}, /* map_tx_fault[3] = TXFAULT_SFP+_P(X+3) */ - {1, 0, 0}, /* map_tx_fault[4] = TXFAULT_SFP+_P(X+4) */ - {1, 0, 1}, /* map_tx_fault[5] = TXFAULT_SFP+_P(X+5) */ - {1, 0, 2}, /* map_tx_fault[6] = TXFAULT_SFP+_P(X+6) */ - {1, 0, 3}, /* map_tx_fault[7] = TXFAULT_SFP+_P(X+7) */ - }, - .map_rxlos = { {0, 1, 4}, /* map_rxlos[0] = OPRXLOS_PORT(X) */ - {0, 1, 5}, /* map_rxlos[1] = OPRXLOS_PORT(X+1) */ - {0, 1, 6}, /* map_rxlos[2] = OPRXLOS_PORT(X+2) */ - {0, 1, 7}, /* map_rxlos[3] = OPRXLOS_PORT(X+3) */ - {1, 1, 4}, /* map_rxlos[4] = OPRXLOS_PORT(X+4) */ - {1, 1, 5}, /* map_rxlos[5] = OPRXLOS_PORT(X+5) */ - {1, 1, 6}, /* map_rxlos[6] = OPRXLOS_PORT(X+6) */ - {1, 1, 7}, /* map_rxlos[7] = OPRXLOS_PORT(X+7) */ - }, -}; - - -struct ioexp_map_s ioexp_map_magnolia_7ab = { - - .chip_amount = 2, - .data_width = 2, - - .map_present = { {1, 0, 4}, /* map_present[0] = MOD_ABS_PORT(X) */ - {1, 0, 5}, /* map_present[1] = MOD_ABS_PORT(X+1) */ - {1, 0, 6}, /* map_present[2] = MOD_ABS_PORT(X+2) */ - {1, 0, 7}, /* map_present[3] = MOD_ABS_PORT(X+3) */ - {1, 1, 4}, /* map_present[4] = MOD_ABS_PORT(X+4) */ - {1, 1, 5}, /* map_present[5] = MOD_ABS_PORT(X+5) */ - }, - .map_reset = { {0, 0, 0}, /* map_reset[0] = QRESET_QSFP_N_P(X) */ - {0, 0, 1}, /* map_reset[1] = QRESET_QSFP_N_P(X+1) */ - {0, 0, 2}, /* map_reset[2] = QRESET_QSFP_N_P(X+2) */ - {0, 0, 3}, /* map_reset[3] = QRESET_QSFP_N_P(X+3) */ - {1, 0, 0}, /* map_reset[4] = QRESET_QSFP_N_P(X+4) */ - {1, 0, 1}, /* map_reset[5] = QRESET_QSFP_N_P(X+5) */ - }, - .map_lpmod = { {0, 0, 4}, /* map_lpmod[0] = LPMODE_QSFP_P(X) */ - {0, 0, 5}, /* map_lpmod[1] = LPMODE_QSFP_P(X+1) */ - {0, 0, 6}, /* map_lpmod[2] = LPMODE_QSFP_P(X+2) */ - {0, 0, 7}, /* map_lpmod[3] = LPMODE_QSFP_P(X+3) */ - {1, 0, 2}, /* map_lpmod[4] = LPMODE_QSFP_P(X+4) */ - {1, 0, 3}, /* map_lpmod[5] = LPMODE_QSFP_P(X+5) */ - }, - .map_modsel = { {0, 1, 4}, /* map_modsel[0] = MODSEL_QSFP_N_P(X) */ - {0, 1, 5}, /* map_modsel[1] = MODSEL_QSFP_N_P(X+1) */ - {0, 1, 6}, /* map_modsel[2] = MODSEL_QSFP_N_P(X+2) */ - {0, 1, 7}, /* map_modsel[3] = MODSEL_QSFP_N_P(X+3) */ - {1, 1, 4}, /* map_modsel[4] = MODSEL_QSFP_N_P(X+4) */ - {1, 1, 5}, /* map_modsel[5] = MODSEL_QSFP_N_P(X+5) */ - }, -}; - - -struct ioexp_map_s ioexp_map_redwood_p01p08_p17p24 = { - - .chip_amount = 3, - .data_width = 2, - - .map_present = { {2, 0, 0}, /* map_present[0] = MOD_ABS_PORT(X) */ - {2, 0, 1}, /* map_present[1] = MOD_ABS_PORT(X+1) */ - {2, 0, 2}, /* map_present[2] = MOD_ABS_PORT(X+2) */ - {2, 0, 3}, /* map_present[3] = MOD_ABS_PORT(X+3) */ - {2, 0, 4}, /* map_present[4] = MOD_ABS_PORT(X+4) */ - {2, 0, 5}, /* map_present[5] = MOD_ABS_PORT(X+5) */ - {2, 0, 6}, /* map_present[6] = MOD_ABS_PORT(X+6) */ - {2, 0, 7}, /* map_present[7] = MOD_ABS_PORT(X+7) */ - }, - .map_reset = { {0, 0, 0}, /* map_reset[0] = QRESET_QSFP28_N_P(X) */ - {0, 0, 1}, /* map_reset[1] = QRESET_QSFP28_N_P(X+1) */ - {0, 0, 2}, /* map_reset[2] = QRESET_QSFP28_N_P(X+2) */ - {0, 0, 3}, /* map_reset[3] = QRESET_QSFP28_N_P(X+3) */ - {1, 0, 0}, /* map_reset[4] = QRESET_QSFP28_N_P(X+4) */ - {1, 0, 1}, /* map_reset[5] = QRESET_QSFP28_N_P(X+5) */ - {1, 0, 2}, /* map_reset[6] = QRESET_QSFP28_N_P(X+6) */ - {1, 0, 3}, /* map_reset[7] = QRESET_QSFP28_N_P(X+7) */ - }, - .map_lpmod = { {0, 0, 4}, /* map_lpmod[0] = LPMODE_QSFP28_P(X) */ - {0, 0, 5}, /* map_lpmod[1] = LPMODE_QSFP28_P(X+1) */ - {0, 0, 6}, /* map_lpmod[2] = LPMODE_QSFP28_P(X+2) */ - {0, 0, 7}, /* map_lpmod[3] = LPMODE_QSFP28_P(X+3) */ - {1, 0, 4}, /* map_lpmod[4] = LPMODE_QSFP28_P(X+4) */ - {1, 0, 5}, /* map_lpmod[5] = LPMODE_QSFP28_P(X+5) */ - {1, 0, 6}, /* map_lpmod[6] = LPMODE_QSFP28_P(X+6) */ - {1, 0, 7}, /* map_lpmod[7] = LPMODE_QSFP28_P(X+7) */ - }, - .map_modsel = { {0, 1, 4}, /* map_modsel[0] = MODSEL_QSFP28_N_P(X) */ - {0, 1, 5}, /* map_modsel[1] = MODSEL_QSFP28_N_P(X+1) */ - {0, 1, 6}, /* map_modsel[2] = MODSEL_QSFP28_N_P(X+2) */ - {0, 1, 7}, /* map_modsel[3] = MODSEL_QSFP28_N_P(X+3) */ - {1, 1, 4}, /* map_modsel[4] = MODSEL_QSFP28_N_P(X+4) */ - {1, 1, 5}, /* map_modsel[5] = MODSEL_QSFP28_N_P(X+5) */ - {1, 1, 6}, /* map_modsel[6] = MODSEL_QSFP28_N_P(X+6) */ - {1, 1, 7}, /* map_modsel[7] = MODSEL_QSFP28_N_P(X+7) */ - }, -}; - - -struct ioexp_map_s ioexp_map_redwood_p09p16_p25p32 = { - - .chip_amount = 3, - .data_width = 2, - - .map_present = { {2, 1, 0}, /* map_present[0] = MOD_ABS_PORT(X) */ - {2, 1, 1}, /* map_present[1] = MOD_ABS_PORT(X+1) */ - {2, 1, 2}, /* map_present[2] = MOD_ABS_PORT(X+2) */ - {2, 1, 3}, /* map_present[3] = MOD_ABS_PORT(X+3) */ - {2, 1, 4}, /* map_present[4] = MOD_ABS_PORT(X+4) */ - {2, 1, 5}, /* map_present[5] = MOD_ABS_PORT(X+5) */ - {2, 1, 6}, /* map_present[6] = MOD_ABS_PORT(X+6) */ - {2, 1, 7}, /* map_present[7] = MOD_ABS_PORT(X+7) */ - }, - .map_reset = { {0, 0, 0}, /* map_reset[0] = QRESET_QSFP28_N_P(X) */ - {0, 0, 1}, /* map_reset[1] = QRESET_QSFP28_N_P(X+1) */ - {0, 0, 2}, /* map_reset[2] = QRESET_QSFP28_N_P(X+2) */ - {0, 0, 3}, /* map_reset[3] = QRESET_QSFP28_N_P(X+3) */ - {1, 0, 0}, /* map_reset[4] = QRESET_QSFP28_N_P(X+4) */ - {1, 0, 1}, /* map_reset[5] = QRESET_QSFP28_N_P(X+5) */ - {1, 0, 2}, /* map_reset[6] = QRESET_QSFP28_N_P(X+6) */ - {1, 0, 3}, /* map_reset[7] = QRESET_QSFP28_N_P(X+7) */ - }, - .map_lpmod = { {0, 0, 4}, /* map_lpmod[0] = LPMODE_QSFP28_P(X) */ - {0, 0, 5}, /* map_lpmod[1] = LPMODE_QSFP28_P(X+1) */ - {0, 0, 6}, /* map_lpmod[2] = LPMODE_QSFP28_P(X+2) */ - {0, 0, 7}, /* map_lpmod[3] = LPMODE_QSFP28_P(X+3) */ - {1, 0, 4}, /* map_lpmod[4] = LPMODE_QSFP28_P(X+4) */ - {1, 0, 5}, /* map_lpmod[5] = LPMODE_QSFP28_P(X+5) */ - {1, 0, 6}, /* map_lpmod[6] = LPMODE_QSFP28_P(X+6) */ - {1, 0, 7}, /* map_lpmod[7] = LPMODE_QSFP28_P(X+7) */ - }, - .map_modsel = { {0, 1, 4}, /* map_modsel[0] = MODSEL_QSFP28_N_P(X) */ - {0, 1, 5}, /* map_modsel[1] = MODSEL_QSFP28_N_P(X+1) */ - {0, 1, 6}, /* map_modsel[2] = MODSEL_QSFP28_N_P(X+2) */ - {0, 1, 7}, /* map_modsel[3] = MODSEL_QSFP28_N_P(X+3) */ - {1, 1, 4}, /* map_modsel[4] = MODSEL_QSFP28_N_P(X+4) */ - {1, 1, 5}, /* map_modsel[5] = MODSEL_QSFP28_N_P(X+5) */ - {1, 1, 6}, /* map_modsel[6] = MODSEL_QSFP28_N_P(X+6) */ - {1, 1, 7}, /* map_modsel[7] = MODSEL_QSFP28_N_P(X+7) */ - }, -}; - - -struct ioexp_map_s ioexp_map_hudson32iga_p01p08_p17p24 = { - - .chip_amount = 3, - .data_width = 2, - - .map_present = { {2, 0, 0}, /* map_present[0] = MODABS_QSFP(X) */ - {2, 0, 1}, /* map_present[1] = MODABS_QSFP(X+1) */ - {2, 0, 2}, /* map_present[2] = MODABS_QSFP(X+2) */ - {2, 0, 3}, /* map_present[3] = MODABS_QSFP(X+3) */ - {2, 0, 4}, /* map_present[4] = MODABS_QSFP(X+4) */ - {2, 0, 5}, /* map_present[5] = MODABS_QSFP(X+5) */ - {2, 0, 6}, /* map_present[6] = MODABS_QSFP(X+6) */ - {2, 0, 7}, /* map_present[7] = MODABS_QSFP(X+7) */ - }, - .map_reset = { {0, 0, 0}, /* map_reset[0] = QRESET_QSFP(X) */ - {0, 0, 1}, /* map_reset[1] = QRESET_QSFP(X+1) */ - {0, 0, 2}, /* map_reset[2] = QRESET_QSFP(X+2) */ - {0, 0, 3}, /* map_reset[3] = QRESET_QSFP(X+3) */ - {1, 0, 0}, /* map_reset[4] = QRESET_QSFP(X+4) */ - {1, 0, 1}, /* map_reset[5] = QRESET_QSFP(X+5) */ - {1, 0, 2}, /* map_reset[6] = QRESET_QSFP(X+6) */ - {1, 0, 3}, /* map_reset[7] = QRESET_QSFP(X+7) */ - }, - .map_lpmod = { {0, 0, 4}, /* map_lpmod[0] = LPMODE_QSFP(X) */ - {0, 0, 5}, /* map_lpmod[1] = LPMODE_QSFP(X+1) */ - {0, 0, 6}, /* map_lpmod[2] = LPMODE_QSFP(X+2) */ - {0, 0, 7}, /* map_lpmod[3] = LPMODE_QSFP(X+3) */ - {1, 0, 4}, /* map_lpmod[4] = LPMODE_QSFP(X+4) */ - {1, 0, 5}, /* map_lpmod[5] = LPMODE_QSFP(X+5) */ - {1, 0, 6}, /* map_lpmod[6] = LPMODE_QSFP(X+6) */ - {1, 0, 7}, /* map_lpmod[7] = LPMODE_QSFP(X+7) */ - }, - .map_modsel = { {0, 1, 4}, /* map_modsel[0] = MODSEL_QSFP(X) */ - {0, 1, 5}, /* map_modsel[1] = MODSEL_QSFP(X+1) */ - {0, 1, 6}, /* map_modsel[2] = MODSEL_QSFP(X+2) */ - {0, 1, 7}, /* map_modsel[3] = MODSEL_QSFP(X+3) */ - {1, 1, 4}, /* map_modsel[4] = MODSEL_QSFP(X+4) */ - {1, 1, 5}, /* map_modsel[5] = MODSEL_QSFP(X+5) */ - {1, 1, 6}, /* map_modsel[6] = MODSEL_QSFP(X+6) */ - {1, 1, 7}, /* map_modsel[7] = MODSEL_QSFP(X+7) */ - }, -}; - - -struct ioexp_map_s ioexp_map_hudson32iga_p09p16_p25p32 = { - - .chip_amount = 3, - .data_width = 2, - - .map_present = { {2, 1, 0}, /* map_present[0] = MODABS_QSFP(X) */ - {2, 1, 1}, /* map_present[1] = MODABS_QSFP(X+1) */ - {2, 1, 2}, /* map_present[2] = MODABS_QSFP(X+2) */ - {2, 1, 3}, /* map_present[3] = MODABS_QSFP(X+3) */ - {2, 1, 4}, /* map_present[4] = MODABS_QSFP(X+4) */ - {2, 1, 5}, /* map_present[5] = MODABS_QSFP(X+5) */ - {2, 1, 6}, /* map_present[6] = MODABS_QSFP(X+6) */ - {2, 1, 7}, /* map_present[7] = MODABS_QSFP(X+7) */ - }, - .map_reset = { {0, 0, 0}, /* map_reset[0] = QRESET_QSFP(X) */ - {0, 0, 1}, /* map_reset[1] = QRESET_QSFP(X+1) */ - {0, 0, 2}, /* map_reset[2] = QRESET_QSFP(X+2) */ - {0, 0, 3}, /* map_reset[3] = QRESET_QSFP(X+3) */ - {1, 0, 0}, /* map_reset[4] = QRESET_QSFP(X+4) */ - {1, 0, 1}, /* map_reset[5] = QRESET_QSFP(X+5) */ - {1, 0, 2}, /* map_reset[6] = QRESET_QSFP(X+6) */ - {1, 0, 3}, /* map_reset[7] = QRESET_QSFP(X+7) */ - }, - .map_lpmod = { {0, 0, 4}, /* map_lpmod[0] = LPMODE_QSFP(X) */ - {0, 0, 5}, /* map_lpmod[1] = LPMODE_QSFP(X+1) */ - {0, 0, 6}, /* map_lpmod[2] = LPMODE_QSFP(X+2) */ - {0, 0, 7}, /* map_lpmod[3] = LPMODE_QSFP(X+3) */ - {1, 0, 4}, /* map_lpmod[4] = LPMODE_QSFP(X+4) */ - {1, 0, 5}, /* map_lpmod[5] = LPMODE_QSFP(X+5) */ - {1, 0, 6}, /* map_lpmod[6] = LPMODE_QSFP(X+6) */ - {1, 0, 7}, /* map_lpmod[7] = LPMODE_QSFP(X+7) */ - }, - .map_modsel = { {0, 1, 4}, /* map_modsel[0] = MODSEL_QSFP(X) */ - {0, 1, 5}, /* map_modsel[1] = MODSEL_QSFP(X+1) */ - {0, 1, 6}, /* map_modsel[2] = MODSEL_QSFP(X+2) */ - {0, 1, 7}, /* map_modsel[3] = MODSEL_QSFP(X+3) */ - {1, 1, 4}, /* map_modsel[4] = MODSEL_QSFP(X+4) */ - {1, 1, 5}, /* map_modsel[5] = MODSEL_QSFP(X+5) */ - {1, 1, 6}, /* map_modsel[6] = MODSEL_QSFP(X+6) */ - {1, 1, 7}, /* map_modsel[7] = MODSEL_QSFP(X+7) */ - }, -}; - - -struct ioexp_map_s ioexp_map_cypress_nabc = { - - .chip_amount = 3, - .data_width = 2, - - .map_present = { {0, 0, 4}, /* map_present[0] = MOD_ABS_PORT(X) */ - {0, 0, 5}, /* map_present[1] = MOD_ABS_PORT(X+1) */ - {0, 0, 6}, /* map_present[2] = MOD_ABS_PORT(X+2) */ - {0, 0, 7}, /* map_present[3] = MOD_ABS_PORT(X+3) */ - {1, 0, 4}, /* map_present[4] = MOD_ABS_PORT(X+4) */ - {1, 0, 5}, /* map_present[5] = MOD_ABS_PORT(X+5) */ - {1, 0, 6}, /* map_present[6] = MOD_ABS_PORT(X+6) */ - {1, 0, 7}, /* map_present[7] = MOD_ABS_PORT(X+7) */ - }, - .map_tx_disable = { {0, 1, 0}, /* map_tx_disable[0] = TXDISABLE_SFP+_P(X) */ - {0, 1, 1}, /* map_tx_disable[1] = TXDISABLE_SFP+_P(X+1) */ - {0, 1, 2}, /* map_tx_disable[2] = TXDISABLE_SFP+_P(X+2) */ - {0, 1, 3}, /* map_tx_disable[3] = TXDISABLE_SFP+_P(X+3) */ - {1, 1, 0}, /* map_tx_disable[4] = TXDISABLE_SFP+_P(X+4) */ - {1, 1, 1}, /* map_tx_disable[5] = TXDISABLE_SFP+_P(X+5) */ - {1, 1, 2}, /* map_tx_disable[6] = TXDISABLE_SFP+_P(X+6) */ - {1, 1, 3}, /* map_tx_disable[7] = TXDISABLE_SFP+_P(X+7) */ - }, - .map_tx_fault = { {0, 0, 0}, /* map_tx_fault[0] = TXFAULT_SFP+_P(X) */ - {0, 0, 1}, /* map_tx_fault[1] = TXFAULT_SFP+_P(X+1) */ - {0, 0, 2}, /* map_tx_fault[2] = TXFAULT_SFP+_P(X+2) */ - {0, 0, 3}, /* map_tx_fault[3] = TXFAULT_SFP+_P(X+3) */ - {1, 0, 0}, /* map_tx_fault[4] = TXFAULT_SFP+_P(X+4) */ - {1, 0, 1}, /* map_tx_fault[5] = TXFAULT_SFP+_P(X+5) */ - {1, 0, 2}, /* map_tx_fault[6] = TXFAULT_SFP+_P(X+6) */ - {1, 0, 3}, /* map_tx_fault[7] = TXFAULT_SFP+_P(X+7) */ - }, - .map_rxlos = { {0, 1, 4}, /* map_rxlos[0] = OPRXLOS_PORT(X) */ - {0, 1, 5}, /* map_rxlos[1] = OPRXLOS_PORT(X+1) */ - {0, 1, 6}, /* map_rxlos[2] = OPRXLOS_PORT(X+2) */ - {0, 1, 7}, /* map_rxlos[3] = OPRXLOS_PORT(X+3) */ - {1, 1, 4}, /* map_rxlos[4] = OPRXLOS_PORT(X+4) */ - {1, 1, 5}, /* map_rxlos[5] = OPRXLOS_PORT(X+5) */ - {1, 1, 6}, /* map_rxlos[6] = OPRXLOS_PORT(X+6) */ - {1, 1, 7}, /* map_rxlos[7] = OPRXLOS_PORT(X+7) */ - }, - .map_hard_rs0 = { {2, 0, 0}, /* map_hard_rs0[0] = RS0_SFP28_P(X) */ - {2, 0, 2}, /* map_hard_rs0[1] = RS0_SFP28_P(X+1) */ - {2, 0, 4}, /* map_hard_rs0[2] = RS0_SFP28_P(X+2) */ - {2, 0, 6}, /* map_hard_rs0[3] = RS0_SFP28_P(X+3) */ - {2, 1, 0}, /* map_hard_rs0[4] = RS0_SFP28_P(X+4) */ - {2, 1, 2}, /* map_hard_rs0[5] = RS0_SFP28_P(X+5) */ - {2, 1, 4}, /* map_hard_rs0[6] = RS0_SFP28_P(X+6) */ - {2, 1, 6}, /* map_hard_rs0[7] = RS0_SFP28_P(X+7) */ - }, - .map_hard_rs1 = { {2, 0, 1}, /* map_hard_rs1[0] = RS1_SFP28_P(X) */ - {2, 0, 3}, /* map_hard_rs1[1] = RS1_SFP28_P(X+1) */ - {2, 0, 5}, /* map_hard_rs1[2] = RS1_SFP28_P(X+2) */ - {2, 0, 7}, /* map_hard_rs1[3] = RS1_SFP28_P(X+3) */ - {2, 1, 1}, /* map_hard_rs1[4] = RS1_SFP28_P(X+4) */ - {2, 1, 3}, /* map_hard_rs1[5] = RS1_SFP28_P(X+5) */ - {2, 1, 5}, /* map_hard_rs1[6] = RS1_SFP28_P(X+6) */ - {2, 1, 7}, /* map_hard_rs1[7] = RS1_SFP28_P(X+7) */ - }, -}; - -struct ioexp_map_s ioexp_map_cypress_7abc = { - - .chip_amount = 3, - .data_width = 2, - - .map_present = { {2, 0, 0}, /* map_present[0] = MOD_ABS_PORT(X) */ - {2, 0, 1}, /* map_present[1] = MOD_ABS_PORT(X+1) */ - {2, 0, 2}, /* map_present[2] = MOD_ABS_PORT(X+2) */ - {2, 0, 3}, /* map_present[3] = MOD_ABS_PORT(X+3) */ - {2, 0, 4}, /* map_present[4] = MOD_ABS_PORT(X+4) */ - {2, 0, 5}, /* map_present[5] = MOD_ABS_PORT(X+5) */ - }, - .map_reset = { {0, 0, 0}, /* map_reset[0] = QRESET_QSFP_N_P(X) */ - {0, 0, 1}, /* map_reset[1] = QRESET_QSFP_N_P(X+1) */ - {0, 0, 2}, /* map_reset[2] = QRESET_QSFP_N_P(X+2) */ - {0, 0, 3}, /* map_reset[3] = QRESET_QSFP_N_P(X+3) */ - {0, 0, 4}, /* map_reset[4] = QRESET_QSFP_N_P(X+4) */ - {0, 0, 5}, /* map_reset[5] = QRESET_QSFP_N_P(X+5) */ - }, - .map_lpmod = { {0, 1, 0}, /* map_lpmod[0] = LPMODE_QSFP_P(X) */ - {0, 1, 1}, /* map_lpmod[1] = LPMODE_QSFP_P(X+1) */ - {0, 1, 2}, /* map_lpmod[2] = LPMODE_QSFP_P(X+2) */ - {0, 1, 3}, /* map_lpmod[3] = LPMODE_QSFP_P(X+3) */ - {0, 1, 4}, /* map_lpmod[4] = LPMODE_QSFP_P(X+4) */ - {0, 1, 5}, /* map_lpmod[5] = LPMODE_QSFP_P(X+5) */ - }, - .map_modsel = { {1, 1, 0}, /* map_modsel[0] = MODSEL_QSFP_N_P(X) */ - {1, 1, 1}, /* map_modsel[1] = MODSEL_QSFP_N_P(X+1) */ - {1, 1, 2}, /* map_modsel[2] = MODSEL_QSFP_N_P(X+2) */ - {1, 1, 3}, /* map_modsel[3] = MODSEL_QSFP_N_P(X+3) */ - {1, 1, 4}, /* map_modsel[4] = MODSEL_QSFP_N_P(X+4) */ - {1, 1, 5}, /* map_modsel[5] = MODSEL_QSFP_N_P(X+5) */ - }, -}; - - -/* ========== Private functions ========== - */ -int check_channel_tier_1(void); - -struct i2c_client * -_get_i2c_client(struct ioexp_obj_s *self, - int chip_id){ - - struct ioexp_i2c_s *i2c_curr_p = self->i2c_head_p; - - if (!(i2c_curr_p)){ - SWPS_ERR("%s: i2c_curr_p is NULL\n", __func__); - return NULL; - } - while (i2c_curr_p){ - if ((i2c_curr_p->chip_id) == chip_id){ - return i2c_curr_p->i2c_client_p; - } - i2c_curr_p = i2c_curr_p->next; - } - SWPS_ERR("%s: not exist! :%d\n", __func__, chip_id); - return NULL; -} - - -static int -_common_ioexp_update_one(struct ioexp_obj_s *self, - struct ioexp_addr_s *ioexp_addr, - int chip_id, - int data_width, - int show_err, - char *caller_name) { - int buf = 0; - int err = 0; - int data_id = 0; - int r_offset = 0; - - for(data_id=0; data_idread_offset[data_id]; - buf = i2c_smbus_read_byte_data(_get_i2c_client(self, chip_id), r_offset); - /* Check error */ - if (buf < 0) { - err = 1; - if (show_err) { - SWPS_INFO("IOEXP-%d read fail! :%d \n", self->ioexp_id, buf); - SWPS_INFO("Dump: :%d :0x%02x :%d, :%s\n", - ioexp_addr->chan_id, ioexp_addr->chip_addr, - ioexp_addr->read_offset[data_id], caller_name); - } - continue; - } - /* Update IOEXP object */ - self->chip_data[chip_id].data[data_id] = (uint8_t)buf; - } - if (err) { - return ERR_IOEXP_UNEXCPT; - } - return 0; -} - - -static int -common_ioexp_update_all(struct ioexp_obj_s *self, - int show_err, - char *caller_name){ - - int err = 0; - int chip_id = 0; - int chip_amount = self->ioexp_map_p->chip_amount; - - for (chip_id=0; chip_idioexp_map_p->map_addr[chip_id]), - chip_id, - self->ioexp_map_p->data_width, - show_err, - caller_name) < 0) { - err = 1; - } - } - if (err) { - return ERR_IOEXP_UNEXCPT; - } - return 0; -} - - -static int -_common_check_by_mode(struct ioexp_obj_s *self){ - - switch (self->mode){ - case IOEXP_MODE_DIRECT: - return self->fsm_4_direct(self); - - case IOEXP_MODE_POLLING: - if (self->state >= 0){ - return 0; - } - switch (self->state){ - case STATE_IOEXP_INIT: - return ERR_IOEXP_UNINIT; - case STATE_IOEXP_ABNORMAL: - return ERR_IOEXP_ABNORMAL; - default: - return ERR_IOEXP_NOSTATE; - } - break; - - default: - break; - } - SWPS_ERR("%s: Exception occurs. :%d \n", __func__, self->mode); - return ERR_IOEXP_UNEXCPT; -} - - -static int -_common_get_bit(struct ioexp_obj_s *self, - struct ioexp_bitmap_s *bitmap_obj_p, - char *func_mane){ - uint8_t buf; - int err_code; - - /* Check and get address */ - err_code = _common_check_by_mode(self); - if (err_code < 0){ - return err_code; - } - if (!bitmap_obj_p){ - SWPS_ERR("Layout config incorrect! :%d :%s\n", - self->ioexp_id, func_mane); - return ERR_IOEXP_BADCONF; - } - /* Get data form cache */ - buf = self->chip_data[bitmap_obj_p->chip_id].data[bitmap_obj_p->ioexp_voffset]; - return (int)(buf >> bitmap_obj_p->bit_shift & 0x01); -} - - -static int -_common_set_bit(struct ioexp_obj_s *self, - struct ioexp_bitmap_s *bitmap_obj_p, - int input_val, - char *func_mane){ - int err_code, target_offset; - uint8_t origin_byte; - uint8_t modify_byte; - - /* Check and get address */ - err_code = _common_check_by_mode(self); - if (err_code < 0){ - return err_code; - } - if (!bitmap_obj_p){ - SWPS_ERR("Layout config incorrect! :%d :%s\n", - self->ioexp_id, func_mane); - return ERR_IOEXP_BADCONF; - } - /* Prepare write date */ - origin_byte = self->chip_data[bitmap_obj_p->chip_id].data[bitmap_obj_p->ioexp_voffset]; - switch (input_val) { - case 0: - modify_byte = origin_byte; - SWP_BIT_CLEAR(modify_byte, bitmap_obj_p->bit_shift); - break; - case 1: - modify_byte = origin_byte; - SWP_BIT_SET(modify_byte, bitmap_obj_p->bit_shift); - break; - default: - SWPS_ERR("Input value incorrect! :%d :%d :%s\n", - input_val, self->ioexp_id, func_mane); - return ERR_IOEXP_BADINPUT; - } - /* Setup i2c client */ - target_offset = self->ioexp_map_p->map_addr[bitmap_obj_p->chip_id].write_offset[bitmap_obj_p->ioexp_voffset]; - /* Write byte to chip via I2C */ - err_code = i2c_smbus_write_byte_data(_get_i2c_client(self, bitmap_obj_p->chip_id), - target_offset, - modify_byte); - /* Update or bollback object */ - if (err_code < 0){ - self->chip_data[bitmap_obj_p->chip_id].data[bitmap_obj_p->ioexp_voffset] = origin_byte; - SWPS_ERR("I2C write fail! :%d :%d :%s :%d\n", - input_val, self->ioexp_id, func_mane, err_code); - return err_code; - } - self->chip_data[bitmap_obj_p->chip_id].data[bitmap_obj_p->ioexp_voffset] = modify_byte; - return 0; -} - - -/* ========== Object public functions ========== - */ -int -common_get_present(struct ioexp_obj_s *self, - int virt_offset){ - - int UNPLUG = 1; - int retval = ERR_IOEXP_UNEXCPT; - - retval = _common_get_bit(self, - &(self->ioexp_map_p->map_present[virt_offset]), - "common_get_present"); - if (retval < 0) { - /* [Note] - * => Transceiver object does not need to handle IOEXP layer issues. - */ - return UNPLUG; - } - return retval; -} - - -int -common_get_tx_fault(struct ioexp_obj_s *self, - int virt_offset){ - /* [Transmit Fault (Tx_Fault)] - * A catastrophic laser fault will activate the transmitter signal, - * TX_FAULT, and disable the laser. This signal is an open collector - * output (pull-up required on the host board). A low signal indicates - * normal laser operation and a high signal indicates a fault. The - * TX_FAULT will be latched high when a laser fault occurs and is - * cleared by toggling the TX_DISABLE input or power cycling the - * transceiver. The transmitter fault condition can also be monitored - * via the two-wire serial interface. - * (address A2, byte 110, bit 2). - * - * 0: Normal - * 1: Abnormal - */ - return _common_get_bit(self, - &(self->ioexp_map_p->map_tx_fault[virt_offset]), - "common_get_tx_fault"); -} - - -int -common_get_rxlos(struct ioexp_obj_s *self, - int virt_offset){ - /* [Receiver Loss of Signal (Rx_LOS)] - * The post-amplification IC also includes transition detection circuitry - * which monitors the ac level of incoming optical signals and provides a - * TTL/CMOS compatible status signal to the host (pin 8). An adequate optical - * input results in a low Rx_LOS output while a high Rx_LOS output indicates - * an unusable optical input. The Rx_LOS thresholds are factory set so that - * a high output indicates a definite optical fault has occurred. Rx_LOS can - * also be monitored via the two-wire serial interface - * (address A2h, byte 110, bit 1). - * - * 0: Normal - * 1: Abnormal - */ - return _common_get_bit(self, - &(self->ioexp_map_p->map_rxlos[virt_offset]), - "common_get_rxlos"); -} - - -int -common_get_tx_disable(struct ioexp_obj_s *self, - int virt_offset){ - - return _common_get_bit(self, - &(self->ioexp_map_p->map_tx_disable[virt_offset]), - "common_get_tx_disable"); -} - - -int -common_get_reset(struct ioexp_obj_s *self, - int virt_offset){ - - return _common_get_bit(self, - &(self->ioexp_map_p->map_reset[virt_offset]), - "common_get_reset"); -} - - -int -common_get_lpmod(struct ioexp_obj_s *self, - int virt_offset){ - - return _common_get_bit(self, - &(self->ioexp_map_p->map_lpmod[virt_offset]), - "common_get_lpmod"); -} - - -int -common_get_modsel(struct ioexp_obj_s *self, - int virt_offset){ - - return _common_get_bit(self, - &(self->ioexp_map_p->map_modsel[virt_offset]), - "common_get_modsel"); -} - - -int -common_get_hard_rs0(struct ioexp_obj_s *self, - int virt_offset){ - - return _common_get_bit(self, - &(self->ioexp_map_p->map_hard_rs0[virt_offset]), - "common_get_hard_rs0"); -} - - -int -common_get_hard_rs1(struct ioexp_obj_s *self, - int virt_offset){ - - return _common_get_bit(self, - &(self->ioexp_map_p->map_hard_rs1[virt_offset]), - "common_get_hard_rs1"); -} - - -int -common_set_tx_disable(struct ioexp_obj_s *self, - int virt_offset, - int input_val){ - - return _common_set_bit(self, - &(self->ioexp_map_p->map_tx_disable[virt_offset]), - input_val, - "common_set_tx_disable"); -} - - -int -common_set_reset(struct ioexp_obj_s *self, - int virt_offset, - int input_val){ - - return _common_set_bit(self, - &(self->ioexp_map_p->map_reset[virt_offset]), - input_val, - "common_set_reset"); -} - - -int -common_set_lpmod(struct ioexp_obj_s *self, - int virt_offset, - int input_val){ - - return _common_set_bit(self, - &(self->ioexp_map_p->map_lpmod[virt_offset]), - input_val, - "common_set_lpmod"); -} - - -int -common_set_modsel(struct ioexp_obj_s *self, - int virt_offset, - int input_val){ - - return _common_set_bit(self, - &(self->ioexp_map_p->map_modsel[virt_offset]), - input_val, - "common_set_modsel"); -} - - -int -common_set_hard_rs0(struct ioexp_obj_s *self, - int virt_offset, - int input_val){ - - return _common_set_bit(self, - &(self->ioexp_map_p->map_hard_rs0[virt_offset]), - input_val, - "common_set_hard_rs0"); -} - - -int -common_set_hard_rs1(struct ioexp_obj_s *self, - int virt_offset, - int input_val){ - - return _common_set_bit(self, - &(self->ioexp_map_p->map_hard_rs1[virt_offset]), - input_val, - "common_set_hard_rs1"); -} - - -int -ioexp_get_not_support(struct ioexp_obj_s *self, - int virt_offset){ - return ERR_IOEXP_NOTSUPPORT; -} - - -int -ioexp_set_not_support(struct ioexp_obj_s *self, - int virt_offset, - int input_val){ - return ERR_IOEXP_NOTSUPPORT; -} - - -int -fake_ioexp_init(struct ioexp_obj_s *self){ - return 1; -} - -int -fake_ioexp_update(struct ioexp_obj_s *self){ - return 1; -} - - -int -fake_update_func(struct ioexp_obj_s *self){ - return 1; -} - -int -fake_get_func(struct ioexp_obj_s *self, - int virt_offset){ - SWPS_WARN("Someone called fake_get_func\n"); - return -1; -} - -int -fake_set_func(struct ioexp_obj_s *self, - int virt_offset, - int input_val){ - SWPS_WARN("Someone called fake_set_func\n"); - return -1; -} - - -/* ========== Initial functions for IO Expander ========== - */ -int -common_ioexp_init(struct ioexp_obj_s *self) { - - int chip_id, offset, err_code; - struct ioexp_addr_s *addr_p; - - /* Setup default value to each physical IO Expander */ - for (chip_id=0; chip_id<(self->ioexp_map_p->chip_amount); chip_id++){ - /* Get address mapping */ - addr_p = &(self->ioexp_map_p->map_addr[chip_id]); - if (!addr_p){ - SWPS_ERR("%s: IOEXP config incorrect! :%d \n", - __func__, chip_id); - return -1; - } - /* Setup default value */ - for (offset=0; offset<(self->ioexp_map_p->data_width); offset++){ - err_code = i2c_smbus_write_byte_data(_get_i2c_client(self, chip_id), - addr_p->write_offset[offset], - addr_p->data_default[offset]); - if (err_code < 0){ - SWPS_ERR("%s: set default fail! :%d \n", - __func__, err_code); - return ERR_IOEXP_UNEXCPT; - } - } - } - /* Check and update info to object */ - err_code = self->update_all(self, 1, "common_ioexp_init"); - if (err_code < 0) { - SWPS_ERR("%s: update_all() fail! :%d \n", - __func__, err_code); - return ERR_IOEXP_UNEXCPT; - } - return 0; -} - - -/* ========== Object functions for Final State Machine ========== - */ -int -_is_channel_ready(struct ioexp_obj_s *self){ - - int buf = 0; - int chip_id = 0; /* Use first chip which be registered */ - int data_id = 0; /* Use first byte which be registered */ - struct ioexp_addr_s *ioexp_addr = NULL; - - ioexp_addr = &(self->ioexp_map_p->map_addr[chip_id]); - if (!ioexp_addr){ - SWPS_ERR("%s: config incorrect!\n", __func__); - return ERR_IOEXP_UNEXCPT; - } - buf = i2c_smbus_read_byte_data(_get_i2c_client(self, chip_id), - ioexp_addr->read_offset[data_id]); - if (buf >= 0){ - return 1; - } - return 0; -} - -int -_ioexp_init_handler(struct ioexp_obj_s *self){ - - int return_val; - - switch (self->mode) { - case IOEXP_MODE_DIRECT: - return_val = self->init(self); - if (return_val < 0){ - self->state = STATE_IOEXP_ABNORMAL; - } else { - self->state = STATE_IOEXP_NORMAL; - } - return return_val; - - case IOEXP_MODE_POLLING: - /* Check system and channel is ready */ - if (self->state == STATE_IOEXP_INIT){ - if (!_is_channel_ready(self)){ - self->state = STATE_IOEXP_INIT; - SWPS_WARN("%s: IOEXP:%d channel not ready.\n", - __func__, self->ioexp_id); - return 0; - } - } - /* Execute initial callback */ - return_val = self->init(self); - if (return_val < 0){ - self->state = STATE_IOEXP_ABNORMAL; - } else { - self->state = STATE_IOEXP_NORMAL; - } - return return_val; - - default: - break; - } - SWPS_ERR("%s: exception occur :%d\n", __func__, self->mode); - return ERR_IOEXP_UNEXCPT; -} - - -int -common_ioexp_fsm_4_direct(struct ioexp_obj_s *self){ - - int result_val; - int show_err = 1; - char *func_mane = "common_ioexp_fsm_4_direct"; - - switch (self->state){ - case STATE_IOEXP_INIT: - result_val = _ioexp_init_handler(self); - /* Exception case: terminate initial procedure */ - if(result_val < 0){ - /* Initial fail */ - return result_val; - } - if(self->state == STATE_IOEXP_INIT){ - /* Keep in INIT state, and return error */ - return ERR_IOEXP_UNINIT; - } - /* Case: Initial done */ - return 0; - - case STATE_IOEXP_NORMAL: - result_val = self->update_all(self, show_err, func_mane); - if (result_val < 0){ - SWPS_INFO("%s: NORMAL -> ABNORMAL :%d\n", - __func__, result_val); - self->state = STATE_IOEXP_ABNORMAL; - return result_val; - } - self->state = STATE_IOEXP_NORMAL; - return 0; - - case STATE_IOEXP_ABNORMAL: - result_val = self->update_all(self, show_err, func_mane); - if (result_val < 0){ - self->state = STATE_IOEXP_ABNORMAL; - return result_val; - } - SWPS_DEBUG("%s: ABNORMAL -> NORMAL :%d\n", - __func__, result_val); - self->state = STATE_IOEXP_NORMAL; - return 0; - - default: - break; - } - SWPS_ERR("%s: Exception occurs :%d\n", - __func__, self->state); - return ERR_IOEXP_UNEXCPT; -} - - -int -common_ioexp_fsm_4_polling(struct ioexp_obj_s *self){ - - int result_val, i, show_e; - int fail_retry = 3; - char *func_name = "common_ioexp_fsm_4_polling"; - -#ifdef DEBUG_SWPS - show_e = 1; -#else - show_e = 0; -#endif - - switch (self->state){ - case STATE_IOEXP_INIT: - result_val = _ioexp_init_handler(self); - /* Exception case: terminate initial procedure */ - if(result_val < 0){ - /* Initial fail */ - return result_val; - } - /* Case: System (Channel) not ready */ - if(self->state == STATE_IOEXP_INIT){ - /* Keep in INIT state, wait and retry */ - return 0; - } - /* Case: Initial done */ - SWPS_INFO("IOEXP-%d: initial done. :%d\n", - self->ioexp_id, self->ioexp_type); - return result_val; - - case STATE_IOEXP_NORMAL: - /* Retry mechanism for case of i2c topology not stable */ - for (i=0; iupdate_all(self, show_e, func_name); - if (result_val >= 0) { - self->state = STATE_IOEXP_NORMAL; - return 0; - } - if (check_channel_tier_1() < 0) { - SWPS_INFO("%s: detect I2C crash :%d\n", - __func__, self->ioexp_id); - break; - } - SWPS_DEBUG("IOEXP-%d: unstable :%d\n", - self->ioexp_id, result_val); - } - SWPS_INFO("IOEXP-%d: NORMAL -> ABNORMAL :%d\n", - self->ioexp_id, result_val); - self->state = STATE_IOEXP_ABNORMAL; - return result_val; - - case STATE_IOEXP_ABNORMAL: - result_val = self->update_all(self, show_e, func_name); - if (result_val < 0){ - self->state = STATE_IOEXP_ABNORMAL; - return result_val; - } - SWPS_INFO("IOEXP-%d: ABNORMAL -> NORMAL :%d\n", - self->ioexp_id, result_val); - self->state = STATE_IOEXP_NORMAL; - return 0; - - default: - break; - } - SWPS_ERR("IOEXP-%d: Exception occurs :%d\n", - self->ioexp_id, self->state); - return ERR_IOEXP_UNEXCPT; -} - - -/* ========== Object private functions for check & update ========== - */ -int -common_ioexp_check(struct ioexp_obj_s *self){ - - int result; - - if (self->mode != IOEXP_MODE_POLLING){ - SWPS_ERR("%s: not polling mode :%d\n", - __func__, self->mode); - return ERR_IOEXP_NOTSUPPORT; - } - mutex_lock(&self->lock); - result = self->fsm_4_polling(self); - mutex_unlock(&self->lock); - return result; -} - - -/* ========== Functions for Factory pattern ========== - */ -static struct ioexp_map_s * -get_ioexp_map(int ioexp_type){ - switch (ioexp_type){ - case IOEXP_TYPE_MAGINOLIA_NAB: - return &ioexp_map_magnolia_nab; - case IOEXP_TYPE_MAGINOLIA_7AB: - case IOEXP_TYPE_SPRUCE_7AB: - return &ioexp_map_magnolia_7ab; - case IOEXP_TYPE_REDWOOD_P01P08: - return &ioexp_map_redwood_p01p08_p17p24; - case IOEXP_TYPE_REDWOOD_P09P16: - return &ioexp_map_redwood_p09p16_p25p32; - case IOEXP_TYPE_HUDSON32IGA_P01P08: - return &ioexp_map_hudson32iga_p01p08_p17p24; - case IOEXP_TYPE_HUDSON32IGA_P09P16: - return &ioexp_map_hudson32iga_p09p16_p25p32; - case IOEXP_TYPE_CYPRESS_NABC: - return &ioexp_map_cypress_nabc; - case IOEXP_TYPE_CYPRESS_7ABC: - return &ioexp_map_cypress_7abc; - - default: - return NULL; - } -} - - -int -setup_ioexp_ssize_attr(struct ioexp_obj_s *self, - struct ioexp_map_s *ioexp_map_p, - int ioexp_id, - int ioexp_type, - int run_mode){ - switch (run_mode){ - case IOEXP_MODE_POLLING: /* Direct access device mode */ - case IOEXP_MODE_DIRECT: /* Polling mode, read from cache */ - self->mode = run_mode; - break; - default: - SWPS_ERR("%s: non-defined run_mode:%d\n", - __func__, run_mode); - self->mode = ERR_IOEXP_UNEXCPT; - return ERR_IOEXP_UNEXCPT; - } - self->ioexp_id = ioexp_id; - self->ioexp_type = ioexp_type; - self->ioexp_map_p = ioexp_map_p; - self->state = STATE_IOEXP_INIT; - mutex_init(&self->lock); - return 0; -} - - -static int -setup_addr_mapping(struct ioexp_obj_s *self, - struct ioexp_addr_s *addr_map_p){ - if (!addr_map_p){ - SWPS_ERR("%s: map is null\n", __func__); - return -1; - } - self->ioexp_map_p->map_addr = addr_map_p; - return 0; -} - - -static int -setup_ioexp_public_cb(struct ioexp_obj_s *self, - int ioexp_type){ - - switch (ioexp_type){ - case IOEXP_TYPE_MAGINOLIA_NAB: - self->get_present = common_get_present; - self->get_tx_fault = common_get_tx_fault; - self->get_rxlos = common_get_rxlos; - self->get_tx_disable = common_get_tx_disable; - self->get_reset = ioexp_get_not_support; - self->get_lpmod = ioexp_get_not_support; - self->get_modsel = ioexp_get_not_support; - self->get_hard_rs0 = ioexp_get_not_support; - self->get_hard_rs1 = ioexp_get_not_support; - self->set_tx_disable = common_set_tx_disable; - self->set_reset = ioexp_set_not_support; - self->set_lpmod = ioexp_set_not_support; - self->set_modsel = ioexp_set_not_support; - self->set_hard_rs0 = ioexp_set_not_support; - self->set_hard_rs1 = ioexp_set_not_support; - return 0; - case IOEXP_TYPE_CYPRESS_NABC: - self->get_present = common_get_present; - self->get_tx_fault = common_get_tx_fault; - self->get_rxlos = common_get_rxlos; - self->get_tx_disable = common_get_tx_disable; - self->get_reset = ioexp_get_not_support; - self->get_lpmod = ioexp_get_not_support; - self->get_modsel = ioexp_get_not_support; - self->get_hard_rs0 = common_get_hard_rs0; - self->get_hard_rs1 = common_get_hard_rs1; - self->set_tx_disable = common_set_tx_disable; - self->set_reset = ioexp_set_not_support; - self->set_lpmod = ioexp_set_not_support; - self->set_modsel = ioexp_set_not_support; - self->set_hard_rs0 = common_set_hard_rs0; - self->set_hard_rs1 = common_set_hard_rs1; - return 0; - case IOEXP_TYPE_MAGINOLIA_7AB: - case IOEXP_TYPE_SPRUCE_7AB: - case IOEXP_TYPE_CYPRESS_7ABC: - self->get_present = common_get_present; - self->get_tx_fault = ioexp_get_not_support; - self->get_rxlos = ioexp_get_not_support; - self->get_tx_disable = ioexp_get_not_support; - self->get_reset = common_get_reset; - self->get_lpmod = common_get_lpmod; - self->get_modsel = common_get_modsel; - self->get_hard_rs0 = ioexp_get_not_support; - self->get_hard_rs1 = ioexp_get_not_support; - self->set_tx_disable = ioexp_set_not_support; - self->set_reset = common_set_reset; - self->set_lpmod = common_set_lpmod; - self->set_modsel = common_set_modsel; - self->set_hard_rs0 = ioexp_set_not_support; - self->set_hard_rs1 = ioexp_set_not_support; - return 0; - case IOEXP_TYPE_REDWOOD_P01P08: - case IOEXP_TYPE_REDWOOD_P09P16: - case IOEXP_TYPE_HUDSON32IGA_P01P08: - case IOEXP_TYPE_HUDSON32IGA_P09P16: - self->get_present = common_get_present; - self->get_tx_fault = ioexp_get_not_support; - self->get_rxlos = ioexp_get_not_support; - self->get_tx_disable = ioexp_get_not_support; - self->get_reset = common_get_reset; - self->get_lpmod = common_get_lpmod; - self->get_modsel = common_get_modsel; - self->get_hard_rs0 = ioexp_get_not_support; - self->get_hard_rs1 = ioexp_get_not_support; - self->set_tx_disable = ioexp_set_not_support; - self->set_reset = common_set_reset; - self->set_lpmod = common_set_lpmod; - self->set_modsel = common_set_modsel; - self->set_hard_rs0 = ioexp_set_not_support; - self->set_hard_rs1 = ioexp_set_not_support; - return 0; - - default: - SWPS_ERR("%s: type:%d incorrect!\n", __func__, ioexp_type); - break; - } - return ERR_IOEXP_UNEXCPT; -} - - -static int -setup_ioexp_private_cb(struct ioexp_obj_s *self, - int ioexp_type){ - - switch (ioexp_type){ - case IOEXP_TYPE_MAGINOLIA_NAB: - case IOEXP_TYPE_MAGINOLIA_7AB: - case IOEXP_TYPE_SPRUCE_7AB: - case IOEXP_TYPE_REDWOOD_P01P08: - case IOEXP_TYPE_REDWOOD_P09P16: - case IOEXP_TYPE_HUDSON32IGA_P01P08: - case IOEXP_TYPE_HUDSON32IGA_P09P16: - case IOEXP_TYPE_CYPRESS_NABC: - case IOEXP_TYPE_CYPRESS_7ABC: - self->init = common_ioexp_init; - self->check = common_ioexp_check; - self->update_all = common_ioexp_update_all; - self->fsm_4_direct = common_ioexp_fsm_4_direct; - self->fsm_4_polling = common_ioexp_fsm_4_polling; - return 0; - - default: - SWPS_ERR("%s: type:%d incorrect!\n", __func__, ioexp_type); - break; - } - return ERR_IOEXP_UNEXCPT; -} - - -static int -setup_i2c_client_one(struct ioexp_obj_s *self, - int chip_id){ - - char *err_msg = "ERROR"; - struct i2c_adapter *adap = NULL; - struct i2c_client *client = NULL; - struct ioexp_i2c_s *i2c_obj_p = NULL; - struct ioexp_i2c_s *i2c_curr_p = NULL; - - int chan_id = self->ioexp_map_p->map_addr[chip_id].chan_id; - adap = i2c_get_adapter(chan_id); - if(!adap){ - err_msg = "Can not get adap!"; - goto err_ioexp_setup_i2c_1; - } - client = kzalloc(sizeof(*client), GFP_KERNEL); - if (!client){ - err_msg = "Can not kzalloc client!"; - goto err_ioexp_setup_i2c_1; - } - i2c_obj_p = kzalloc(sizeof(*i2c_obj_p), GFP_KERNEL); - if (!i2c_obj_p){ - err_msg = "Can not kzalloc i2c_obj_p!"; - goto err_ioexp_setup_i2c_2; - } - client->adapter = adap; - client->addr = self->ioexp_map_p->map_addr[chip_id].chip_addr; - i2c_obj_p->i2c_client_p = client; - i2c_obj_p->chip_id = chip_id; - i2c_obj_p->next = NULL; - if (!self->i2c_head_p){ - self->i2c_head_p = i2c_obj_p; - } else { - i2c_curr_p = self->i2c_head_p; - while (i2c_curr_p->next){ - i2c_curr_p = i2c_curr_p->next; - } - i2c_curr_p->next = i2c_obj_p; - } - return 0; - -err_ioexp_setup_i2c_2: - kfree(client); -err_ioexp_setup_i2c_1: - SWPS_ERR("%s: %s :%d\n", __func__, err_msg, chan_id); - return -1; -} - - -static int -setup_i2c_client(struct ioexp_obj_s* self){ - - int result; - int chip_id = 0; - - for (chip_id=0; chip_id<(self->ioexp_map_p->chip_amount); chip_id++){ - result = setup_i2c_client_one(self, chip_id); - if (result < 0){ - SWPS_ERR("%s fail! :%d\n", __func__, chip_id); - return -1; - } - } - return 0; -} - - -static int -setup_ioexp_config(struct ioexp_obj_s *self) { - - int chip_id, offset, err_code; - struct ioexp_addr_s *addr_p; - - for (chip_id=0; chip_id<(self->ioexp_map_p->chip_amount); chip_id++){ - addr_p = &(self->ioexp_map_p->map_addr[chip_id]); - if (!addr_p){ - SWPS_ERR("IOEXP config incorrect! :%d \n",chip_id); - return -1; - } - for (offset=0; offset<(self->ioexp_map_p->data_width); offset++){ - - err_code = i2c_smbus_write_byte_data(_get_i2c_client(self, chip_id), - addr_p->conf_offset[offset], - addr_p->conf_default[offset]); - - if (err_code < 0){ - SWPS_INFO("%s: set conf fail! :%d \n", __func__, err_code); - return -2; - } - } - } - return 0; -} - - -struct ioexp_obj_s * -_create_ioexp_obj(int ioexp_id, - int ioexp_type, - struct ioexp_addr_s *addr_map_p, - int run_mode){ - - struct ioexp_map_s* ioexp_map_p; - struct ioexp_obj_s* result_p; - struct ioexp_i2c_s *i2c_curr_p; - struct ioexp_i2c_s *i2c_next_p; - - /* Get layout */ - ioexp_map_p = get_ioexp_map(ioexp_type); - if (!ioexp_map_p){ - SWPS_ERR("%s: Invalid ioexp_type\n", __func__); - goto err_create_ioexp_fail; - } - /* Prepare IOEXP object */ - result_p = kzalloc(sizeof(*result_p), GFP_KERNEL); - if (!result_p){ - SWPS_ERR("%s: kzalloc failure!\n", __func__); - goto err_create_ioexp_fail; - } - /* Prepare static size attributes */ - if (setup_ioexp_ssize_attr(result_p, - ioexp_map_p, - ioexp_id, - ioexp_type, - run_mode) < 0){ - goto err_create_ioexp_setup_attr_fail; - } - /* Prepare address mapping */ - if (setup_addr_mapping(result_p, addr_map_p) < 0){ - goto err_create_ioexp_setup_attr_fail; - } - if (setup_i2c_client(result_p) < 0){ - goto err_create_ioexp_setup_i2c_fail; - } - /* Prepare call back functions of object */ - if (setup_ioexp_public_cb(result_p, ioexp_type) < 0){ - goto err_create_ioexp_setup_i2c_fail; - } - if (setup_ioexp_private_cb(result_p, ioexp_type) < 0){ - goto err_create_ioexp_setup_i2c_fail; - } - return result_p; - -err_create_ioexp_setup_i2c_fail: - i2c_curr_p = result_p->i2c_head_p; - i2c_next_p = result_p->i2c_head_p; - while (i2c_curr_p){ - i2c_next_p = i2c_curr_p->next; - kfree(i2c_curr_p->i2c_client_p); - kfree(i2c_curr_p); - i2c_curr_p = i2c_next_p; - } -err_create_ioexp_setup_attr_fail: - kfree(result_p); -err_create_ioexp_fail: - SWPS_ERR("%s: fail! :%d :%d \n", - __func__, ioexp_id, ioexp_type); - return NULL; -} - - -int -create_ioexp_obj(int ioexp_id, - int ioexp_type, - struct ioexp_addr_s *addr_map_p, - int run_mode){ - - struct ioexp_obj_s *ioexp_p = NULL; - - ioexp_p = _create_ioexp_obj(ioexp_id, ioexp_type, - addr_map_p, run_mode); - if (!ioexp_p){ - return -1; - } - if (ioexp_head_p == NULL){ - ioexp_head_p = ioexp_p; - ioexp_tail_p = ioexp_p; - return 0; - } - ioexp_tail_p->next = ioexp_p; - ioexp_tail_p = ioexp_p; - return 0; -} -EXPORT_SYMBOL(create_ioexp_obj); - - -static int -_init_ioexp_obj(struct ioexp_obj_s* self) { - - char *err_msg = "ERR"; - char *func_name = "_init_ioexp_obj"; - - /* Setup IOEXP configure byte */ - if (setup_ioexp_config(self) < 0){ - err_msg = "setup_ioexp_config fail"; - goto err_init_ioexp_obj; - } - /* Setup default data */ - if (_ioexp_init_handler(self) < 0){ - err_msg = "_ioexp_init_handler fail"; - goto err_init_ioexp_obj; - } - /* Update all */ - if (self->state == STATE_IOEXP_NORMAL){ - if (self->update_all(self, 1, func_name) < 0){ - err_msg = "update_all() fail"; - goto err_init_ioexp_obj; - } - } - return 0; - -err_init_ioexp_obj: - SWPS_DEBUG("%s: %s\n", __func__, err_msg); - return -1; -} - - -int -init_ioexp_objs(void){ - /* Return value: - * 0: Success - * -1: Detect topology error - * -2: SWPS internal error - */ - - struct ioexp_obj_s *curr_p = ioexp_head_p; - - if (!curr_p) { - SWPS_ERR("%s: ioexp_head_p is NULL\n", __func__); - return -2; - } - while (curr_p) { - if (_init_ioexp_obj(curr_p) < 0) { - SWPS_DEBUG("%s: _init_ioexp_obj() fail\n", __func__); - return -1; - } - curr_p = curr_p->next; - } - SWPS_DEBUG("%s: done.\n", __func__); - return 0; -} -EXPORT_SYMBOL(init_ioexp_objs); - - -void -clean_ioexp_objs(void){ - - struct ioexp_i2c_s *i2c_curr_p = NULL; - struct ioexp_i2c_s *i2c_next_p = NULL; - struct ioexp_obj_s *ioexp_next_p = NULL; - struct ioexp_obj_s *ioexp_curr_p = ioexp_head_p; - - if (ioexp_head_p == NULL){ - ioexp_tail_p = NULL; - return; - } - while(ioexp_curr_p){ - ioexp_next_p = ioexp_curr_p->next; - i2c_curr_p = ioexp_curr_p->i2c_head_p; - while (i2c_curr_p) { - i2c_next_p = i2c_curr_p->next; - kfree(i2c_curr_p->i2c_client_p); - kfree(i2c_curr_p); - i2c_curr_p = i2c_next_p; - } - kfree(ioexp_curr_p); - ioexp_curr_p = ioexp_next_p; - } - ioexp_tail_p = NULL; - SWPS_DEBUG("%s: done.\n", __func__); -} -EXPORT_SYMBOL(clean_ioexp_objs); - - -int -check_ioexp_objs(void){ - - struct ioexp_obj_s *ioexp_curr_p = ioexp_head_p; - - while (ioexp_curr_p){ - if ( (ioexp_curr_p->check(ioexp_curr_p)) < 0){ - SWPS_INFO("check IOEXP-%d fail! :%d\n", - ioexp_curr_p->ioexp_id, ioexp_curr_p->ioexp_type); - return -1; - } - ioexp_curr_p = ioexp_curr_p->next; - } - return 0; -} -EXPORT_SYMBOL(check_ioexp_objs); - - -struct ioexp_obj_s * -get_ioexp_obj(int ioexp_id){ - - struct ioexp_obj_s *result_p = NULL; - struct ioexp_obj_s *ioexp_curr_p = ioexp_head_p; - - while(ioexp_curr_p){ - if (ioexp_curr_p->ioexp_id == ioexp_id){ - result_p = ioexp_curr_p; - break; - } - ioexp_curr_p = ioexp_curr_p->next; - } - return result_p; -} -EXPORT_SYMBOL(get_ioexp_obj); - - -void -unlock_ioexp_all(void) { - - struct ioexp_obj_s *ioexp_curr_p = ioexp_head_p; - - while(ioexp_curr_p){ - mutex_unlock(&ioexp_curr_p->lock); - ioexp_curr_p = ioexp_curr_p->next; - } -} -EXPORT_SYMBOL(unlock_ioexp_all); - - -int -lock_ioexp_all(void) { - - struct ioexp_obj_s *ioexp_curr_p = ioexp_head_p; - - while(ioexp_curr_p){ - mutex_lock(&ioexp_curr_p->lock); - ioexp_curr_p = ioexp_curr_p->next; - } - return 0; -} -EXPORT_SYMBOL(lock_ioexp_all); - - -int -check_channel_tier_1(void) { - - if ( (!_is_channel_ready(ioexp_head_p)) && - (!_is_channel_ready(ioexp_tail_p)) ){ - return -1; - } - return 0; -} -EXPORT_SYMBOL(check_channel_tier_1); - - -static int -_scan_channel_tier_1(int force, - int show_err) { - - struct ioexp_obj_s *ioexp_curr_p = ioexp_head_p; - int ready = 0; - - if (!ioexp_curr_p) { - goto err_scan_tier_1_channel; - } - while(ioexp_curr_p) { - ready = _is_channel_ready(ioexp_curr_p); - if ((!ready) && (!force)) { - goto err_scan_tier_1_channel; - } - ioexp_curr_p = ioexp_curr_p->next; - } - return 0; - -err_scan_tier_1_channel: - if (show_err) { - if (ioexp_curr_p) { - SWPS_INFO("%s: IOEXP-%d fail\n", __func__, ioexp_curr_p->ioexp_id); - } else { - SWPS_INFO("%s: IOEXP is null.\n", __func__); - } - } - return -1; -} - - -static int -_scan_channel_tier_1_single(void) { - - int ret = 0; - int chan_id = 0; - int fake_cid = 0; - int fake_offs = 0; - int fake_addr = 0; - struct i2c_adapter *adap = NULL; - struct i2c_client *client = NULL; - - if (ioexp_head_p->ioexp_id != ioexp_tail_p->ioexp_id) { - return 0; - } - /* Setup i2c_client */ - chan_id = ioexp_head_p->ioexp_map_p->map_addr[fake_cid].chan_id; - fake_addr = ioexp_head_p->ioexp_map_p->map_addr[fake_cid].chip_addr; - adap = i2c_get_adapter((chan_id + 1)); - if(!adap){ - SWPS_INFO("%s: Can not get adap!\n", __func__); - return 0; - } - client = kzalloc(sizeof(*client), GFP_KERNEL); - if (!client){ - SWPS_INFO("%s: Can not kzalloc client!\n", __func__); - return 0; - } - client->adapter = adap; - client->addr = fake_addr; - /* Fouce move ioexp ptr to next */ - ret = i2c_smbus_read_byte_data(client, fake_offs); - SWPS_DEBUG("%s: move ioexp_ptr done. :%d\n"); - kfree(client); - return 1; -} - - -int -resync_channel_tier_1(void) { - - char *emsg = "ERR"; - - if (!ioexp_head_p) { - emsg = "ioexp_head_p is NULL"; - goto err_resync_ioexp_status_1; - } - /* Run all */ - if (ioexp_head_p->ioexp_id == ioexp_tail_p->ioexp_id) { - _scan_channel_tier_1_single(); - } else { - _scan_channel_tier_1(1, 0); - } - /* Check all */ - if (_scan_channel_tier_1(0, 1) < 0) { - emsg = "resync tier-1 channel fail"; - goto err_resync_ioexp_status_1; - } - return 0; - -err_resync_ioexp_status_1: - SWPS_ERR("%s: %s\n", __func__, emsg); - return -1; -} -EXPORT_SYMBOL(resync_channel_tier_1); - - - - -MODULE_LICENSE("GPL"); - diff --git a/packages/platforms/inventec/x86-64/d7032q28b/modules/builds/src/io_expander.h b/packages/platforms/inventec/x86-64/d7032q28b/modules/builds/src/io_expander.h deleted file mode 100644 index d57dfe159..000000000 --- a/packages/platforms/inventec/x86-64/d7032q28b/modules/builds/src/io_expander.h +++ /dev/null @@ -1,185 +0,0 @@ -/************************************************************************* - * - * io_expander.h - * - * 2018 Inventec Corporation - * All Rights Reserved. - * - * NOTICE: All information contained herein is, and remains - * the property of Inventec Corp. and its suppliers, - * if any. The intellectual and technical concepts contained - * herein are proprietary to Inventec Corporation and its suppliers - * and may be covered by U.S. and Foreign Patents, patents in process, - * and are protected by trade secret or copyright law. - * - ************************************************************************/ - -#ifndef IO_EXPANDER_H -#define IO_EXPANDER_H - -#include - - -/* IOEXP type define (SFP series) */ -#define IOEXP_TYPE_MAGINOLIA_NAB (10101) -#define IOEXP_TYPE_CYPRESS_NABC (10102) - -/* IOEXP type define (QSFP series) */ -#define IOEXP_TYPE_MAGINOLIA_7AB (10201) -#define IOEXP_TYPE_REDWOOD_P01P08 (10202) -#define IOEXP_TYPE_REDWOOD_P09P16 (10203) -#define IOEXP_TYPE_HUDSON32IGA_P01P08 (10204) -#define IOEXP_TYPE_HUDSON32IGA_P09P16 (10205) -#define IOEXP_TYPE_SPRUCE_7AB (10206) -#define IOEXP_TYPE_CYPRESS_7ABC (10207) - -/* IOEXP mode define */ -#define IOEXP_MODE_POLLING (19000) -#define IOEXP_MODE_DIRECT (19001) - -/* IOEXP state define */ -#define STATE_IOEXP_NORMAL (0) -#define STATE_IOEXP_INIT (-1) -#define STATE_IOEXP_ABNORMAL (-2) - -/* IOEXP error code define */ -#define ERR_IOEXP_NOTSUPPORT (-100) -#define ERR_IOEXP_UNINIT (-101) -#define ERR_IOEXP_BADCONF (-102) -#define ERR_IOEXP_ABNORMAL (-103) -#define ERR_IOEXP_NOSTATE (-104) -#define ERR_IOEXP_BADINPUT (-105) -#define ERR_IOEXP_UNEXCPT (-199) - - -#define SWPS_INFO(fmt, args...) printk( KERN_INFO "[SWPS] " fmt, ##args) -#define SWPS_WARN(fmt, args...) printk( KERN_WARNING "[SWPS] " fmt, ##args) -#define SWPS_ERR(fmt, args...) printk( KERN_ERR "[SWPS] " fmt, ##args) - -#ifdef DEBUG_SWPS -# define SWPS_DEBUG(fmt, args...) printk( KERN_DEBUG "[SWPS] " fmt, ##args) -#else -# define SWPS_DEBUG(fmt, args...) -#endif - - -struct ioexp_addr_s { - int chan_id; - int chip_addr; - int read_offset[8]; - int write_offset[8]; - int conf_offset[8]; - uint8_t data_default[8]; - uint8_t conf_default[8]; -}; - -struct ioexp_i2c_s { - int chip_id; - struct i2c_client *i2c_client_p; - struct ioexp_i2c_s *next; -}; - - -struct ioexp_bitmap_s { - int chip_id; /* IOEXP chip id */ - int ioexp_voffset; /* IOEXP virtual offset */ - int bit_shift; -}; - -struct ioexp_map_s { - int chip_amount; /* Number of chips that IOEXP object content */ - int data_width; /* Number of (Read/Write/Config) bytes */ - struct ioexp_addr_s *map_addr; /* Chip address info */ - struct ioexp_bitmap_s map_present[8]; /* IOEXP for SFP / QSFP */ - struct ioexp_bitmap_s map_tx_disable[8]; /* IOEXP for SFP */ - struct ioexp_bitmap_s map_tx_fault[8]; /* IOEXP for SFP */ - struct ioexp_bitmap_s map_rxlos[8]; /* IOEXP for SFP */ - struct ioexp_bitmap_s map_reset[8]; /* IOEXP for QSFP */ - struct ioexp_bitmap_s map_lpmod[8]; /* IOEXP for QSFP */ - struct ioexp_bitmap_s map_modsel[8]; /* IOEXP for QSFP */ - struct ioexp_bitmap_s map_hard_rs0[8]; /* IOEXP for QSFP */ - struct ioexp_bitmap_s map_hard_rs1[8]; /* IOEXP for QSFP */ -}; - -struct ioexp_data_s { - uint8_t data[8]; -}; - -struct ioexp_obj_s { - - /* ============================ - * Object public property - * ============================ - */ - int ioexp_id; - int ioexp_type; - - /* ============================ - * Object private property - * ============================ - */ - struct ioexp_data_s chip_data[16]; /* Max: 8-ioexp in one virt-ioexp(ioexp_obj) */ - struct ioexp_map_s *ioexp_map_p; - struct ioexp_obj_s *next; - struct ioexp_i2c_s *i2c_head_p; - struct mutex lock; - int mode; - int state; - - /* =========================================== - * Object public functions - * =========================================== - */ - int (*get_present)(struct ioexp_obj_s *self, int virt_offset); - int (*get_tx_fault)(struct ioexp_obj_s *self, int virt_offset); - int (*get_rxlos)(struct ioexp_obj_s *self, int virt_offset); - int (*get_tx_disable)(struct ioexp_obj_s *self, int virt_offset); - int (*get_reset)(struct ioexp_obj_s *self, int virt_offset); - int (*get_lpmod)(struct ioexp_obj_s *self, int virt_offset); - int (*get_modsel)(struct ioexp_obj_s *self, int virt_offset); - int (*get_hard_rs0)(struct ioexp_obj_s *self, int virt_offset); - int (*get_hard_rs1)(struct ioexp_obj_s *self, int virt_offset); - int (*set_tx_disable)(struct ioexp_obj_s *self, int virt_offset, int input_val); - int (*set_reset)(struct ioexp_obj_s *self, int virt_offset, int input_val); - int (*set_lpmod)(struct ioexp_obj_s *self, int virt_offset, int input_val); - int (*set_modsel)(struct ioexp_obj_s *self, int virt_offset, int input_val); - int (*set_hard_rs0)(struct ioexp_obj_s *self, int virt_offset, int input_val); - int (*set_hard_rs1)(struct ioexp_obj_s *self, int virt_offset, int input_val); - - /* =========================================== - * Object private functions - * =========================================== - */ - int (*init)(struct ioexp_obj_s *self); - int (*check)(struct ioexp_obj_s *self); - int (*update_all)(struct ioexp_obj_s *self, int show_err, char *caller_name); - int (*fsm_4_direct)(struct ioexp_obj_s* self); - int (*fsm_4_polling)(struct ioexp_obj_s* self); -}; - - -struct ioexp_obj_s* get_ioexp_obj(int ioexp_id); -int create_ioexp_obj(int ioexp_id, - int ioexp_type, - struct ioexp_addr_s *addr_map_p, - int run_mode); -int init_ioexp_objs(void); -int check_ioexp_objs(void); -void clean_ioexp_objs(void); - -void unlock_ioexp_all(void); -int lock_ioexp_all(void); - -int check_channel_tier_1(void); -int resync_channel_tier_1(void); - -/* Macro for bit control */ -#define SWP_BIT_SET(byte_val,bit_shift) ((byte_val) |= (1<<(bit_shift))) -#define SWP_BIT_CLEAR(byte_val,bit_shift) ((byte_val) &= ~(1<<(bit_shift))) - - -#endif /* IO_EXPANDER_H */ - - - - diff --git a/packages/platforms/inventec/x86-64/d7032q28b/modules/builds/src/onie_tlvinfo.c b/packages/platforms/inventec/x86-64/d7032q28b/modules/builds/src/onie_tlvinfo.c deleted file mode 100644 index 360219b26..000000000 --- a/packages/platforms/inventec/x86-64/d7032q28b/modules/builds/src/onie_tlvinfo.c +++ /dev/null @@ -1,765 +0,0 @@ -#include -#include -#include -#include -#include - -#include "onie_tlvinfo.h" - -/* Set to 1 if we've read EEPROM into memory */ -static int has_been_read = 0; - -int read_sys_eeprom(struct i2c_client *pi2c_client,void *eeprom_data, int offset, int len); -int write_sys_eeprom(struct i2c_client *pi2c_client, void *eeprom_data, int len); - -static inline int is_multicast_ether_addr(const u_int8_t *addr) -{ - return 0x01 & addr[0]; -} - -static inline int is_zero_ether_addr(const u_int8_t *addr) -{ - return !(addr[0] | addr[1] | addr[2] | addr[3] | addr[4] | addr[5]); -} - -static inline int is_valid_ether_addr(const u_int8_t *addr) -{ - return !is_multicast_ether_addr(addr) && !is_zero_ether_addr(addr); -} - -static unsigned long crc32_tab[] = { - 0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f, - 0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988, - 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91, 0x1db71064, 0x6ab020f2, - 0xf3b97148, 0x84be41de, 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7, - 0x136c9856, 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, 0x14015c4f, 0x63066cd9, - 0xfa0f3d63, 0x8d080df5, 0x3b6e20c8, 0x4c69105e, 0xd56041e4, 0xa2677172, - 0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b, 0x35b5a8fa, 0x42b2986c, - 0xdbbbc9d6, 0xacbcf940, 0x32d86ce3, 0x45df5c75, 0xdcd60dcf, 0xabd13d59, - 0x26d930ac, 0x51de003a, 0xc8d75180, 0xbfd06116, 0x21b4f4b5, 0x56b3c423, - 0xcfba9599, 0xb8bda50f, 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924, - 0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d, 0x76dc4190, 0x01db7106, - 0x98d220bc, 0xefd5102a, 0x71b18589, 0x06b6b51f, 0x9fbfe4a5, 0xe8b8d433, - 0x7807c9a2, 0x0f00f934, 0x9609a88e, 0xe10e9818, 0x7f6a0dbb, 0x086d3d2d, - 0x91646c97, 0xe6635c01, 0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e, - 0x6c0695ed, 0x1b01a57b, 0x8208f4c1, 0xf50fc457, 0x65b0d9c6, 0x12b7e950, - 0x8bbeb8ea, 0xfcb9887c, 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, 0xfbd44c65, - 0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2, 0x4adfa541, 0x3dd895d7, - 0xa4d1c46d, 0xd3d6f4fb, 0x4369e96a, 0x346ed9fc, 0xad678846, 0xda60b8d0, - 0x44042d73, 0x33031de5, 0xaa0a4c5f, 0xdd0d7cc9, 0x5005713c, 0x270241aa, - 0xbe0b1010, 0xc90c2086, 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f, - 0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, 0x59b33d17, 0x2eb40d81, - 0xb7bd5c3b, 0xc0ba6cad, 0xedb88320, 0x9abfb3b6, 0x03b6e20c, 0x74b1d29a, - 0xead54739, 0x9dd277af, 0x04db2615, 0x73dc1683, 0xe3630b12, 0x94643b84, - 0x0d6d6a3e, 0x7a6a5aa8, 0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1, - 0xf00f9344, 0x8708a3d2, 0x1e01f268, 0x6906c2fe, 0xf762575d, 0x806567cb, - 0x196c3671, 0x6e6b06e7, 0xfed41b76, 0x89d32be0, 0x10da7a5a, 0x67dd4acc, - 0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5, 0xd6d6a3e8, 0xa1d1937e, - 0x38d8c2c4, 0x4fdff252, 0xd1bb67f1, 0xa6bc5767, 0x3fb506dd, 0x48b2364b, - 0xd80d2bda, 0xaf0a1b4c, 0x36034af6, 0x41047a60, 0xdf60efc3, 0xa867df55, - 0x316e8eef, 0x4669be79, 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236, - 0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f, 0xc5ba3bbe, 0xb2bd0b28, - 0x2bb45a92, 0x5cb36a04, 0xc2d7ffa7, 0xb5d0cf31, 0x2cd99e8b, 0x5bdeae1d, - 0x9b64c2b0, 0xec63f226, 0x756aa39c, 0x026d930a, 0x9c0906a9, 0xeb0e363f, - 0x72076785, 0x05005713, 0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38, - 0x92d28e9b, 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21, 0x86d3d2d4, 0xf1d4e242, - 0x68ddb3f8, 0x1fda836e, 0x81be16cd, 0xf6b9265b, 0x6fb077e1, 0x18b74777, - 0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c, 0x8f659eff, 0xf862ae69, - 0x616bffd3, 0x166ccf45, 0xa00ae278, 0xd70dd2ee, 0x4e048354, 0x3903b3c2, - 0xa7672661, 0xd06016f7, 0x4969474d, 0x3e6e77db, 0xaed16a4a, 0xd9d65adc, - 0x40df0b66, 0x37d83bf0, 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9, - 0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605, 0xcdd70693, - 0x54de5729, 0x23d967bf, 0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94, - 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d -}; - -static unsigned long crc32(unsigned char const *buf, unsigned int size) -{ - unsigned char *p = (unsigned char*)buf; - unsigned long crc = 0; - - crc = crc ^ ~0U; - - while (size--) - crc = crc32_tab[(crc ^ *p++) & 0xFF] ^ (crc >> 8); - - return crc ^ ~0U; -} - -static int set_bytes(char *buf, const char *string, int * converted_accum) -{ - char *p = (char *) string; - int i; - uint byte; - - if (!p) { - printk("ERROR: NULL string passed in.\n"); - return -1; - } - /* Convert string to bytes */ - for (i = 0, p = (char *)string; (i < TLV_VALUE_MAX_LEN) && (*p != 0); - i++) { - while ((*p == ' ') || (*p == '\t') || (*p == ',') || - (*p == ';')) { - p++; - } - if (*p != 0) { - if (!isdigit(*p)) { - printk("ERROR: Non-digit found in byte string: (%s)\n", string); - return -1; - } - byte = strtoul(p, &p, 0); - if (byte >= 256) { - printk("ERROR: The value specified is greater than 255: (%u) " \ - "in string: %s\n", byte, string); - return -1; - } - buf[i] = byte & 0xFF; - } - } - if ((i == TLV_VALUE_MAX_LEN) && (*p != 0)) { - printk("ERROR: Trying to assign too many bytes " - "(max: %d) in string: %s\n", TLV_VALUE_MAX_LEN, string); - return -1; - } - *converted_accum = i; - return 0; -} - -/* - * set_date - * - * Validates the format of the data string - * - * This function takes a pointer to a date string (i.e. MM/DD/YYYY hh:mm:ss) - * and validates that the format is correct. If so the string is copied - * to the supplied buffer. - */ -static int set_date(char *buf, const char *string) -{ - int i; - - if (!string) { - printk("ERROR: NULL date string passed in.\n"); - return -1; - } - if (strlen(string) != 19) { - printk("ERROR: Date strlen() != 19 -- %zd\n", strlen(string)); - printk("ERROR: Bad date format (MM/DD/YYYY hh:mm:ss): %s\n", string); - return -1; - } - for (i = 0; string[i] != 0; i++) { - switch (i) { - case 2: - case 5: - if (string[i] != '/') { - printk("ERROR: Bad date format (MM/DD/YYYY hh:mm:ss): %s\n", - string); - return -1; - } - break; - case 10: - if (string[i] != ' ') { - printk("ERROR: Bad date format (MM/DD/YYYY hh:mm:ss): %s\n", - string); - return -1; - } - break; - case 13: - case 16: - if (string[i] != ':') { - printk("ERROR: Bad date format (MM/DD/YYYY hh:mm:ss): %s\n", - string); - return -1; - } - break; - default: - if (!isdigit(string[i])) { - printk("ERROR: Bad date format (MM/DD/YYYY hh:mm:ss): %s\n", - string); - return -1; - } - break; - } - } - strcpy(buf, string); - return 0; -} - -/* - * is_valid_tlv - * - * Perform basic sanity checks on a TLV field. The TLV is pointed to - * by the parameter provided. - * 1. The type code is not reserved (0x00 or 0xFF) - */ -static inline bool is_valid_tlv(tlvinfo_tlv_t *tlv) -{ - return((tlv->type != 0x00) && (tlv->type != 0xFF)); -} - -/* - * set_mac - * - * Converts a string MAC address into a binary buffer. - * - * This function takes a pointer to a MAC address string - * (i.e."XX:XX:XX:XX:XX:XX", where "XX" is a two-digit hex number). - * The string format is verified and then converted to binary and - * stored in a buffer. - */ -static int set_mac(char *buf, const char *string) -{ - char *p = (char *) string; - int i; - int err = 0; - char *end; - - if (!p) { - printk("ERROR: NULL mac addr string passed in.\n"); - return -1; - } - if (strlen(p) != 17) { - printk("ERROR: MAC address strlen() != 17 -- %zd\n", strlen(p)); - printk("ERROR: Bad MAC address format: %s\n", string); - return -1; - } - for (i = 0; i < 17; i++) { - if ((i % 3) == 2) { - if (p[i] != ':') { - err++; - printk("ERROR: mac: p[%i] != :, found: `%c'\n", - i, p[i]); - break; - } - continue; - } else if (!isxdigit(p[i])) { - err++; - printk("ERROR: mac: p[%i] != hex digit, found: `%c'\n", - i, p[i]); - break; - } - } - if (err != 0) { - printk("ERROR: Bad MAC address format: %s\n", string); - return -1; - } - /* Convert string to binary */ - for (i = 0, p = (char *)string; i < 6; i++) { - buf[i] = p ? strtoul(p, &end, 16) : 0; - if (p) { - p = (*end) ? end + 1 : end; - } - } - if (!is_valid_ether_addr((char *)buf)) { - printk("ERROR: MAC address must not be 00:00:00:00:00:00, " - "a multicast address or FF:FF:FF:FF:FF:FF.\n"); - printk("ERROR: Bad MAC address format: %s\n", string); - return -1; - } - return 0; -} - -/* - * is_valid_tlvinfo_header - * - * Perform sanity checks on the first 11 bytes of the TlvInfo EEPROM - * data pointed to by the parameter: - * 1. First 8 bytes contain null-terminated ASCII string "TlvInfo" - * 2. Version byte is 1 - * 3. Total length bytes contain value which is less than or equal - * to the allowed maximum (2048-11) - * - */ -static inline bool is_valid_tlvinfo_header(tlvinfo_header_t *hdr) -{ - int max_size = TLV_TOTAL_LEN_MAX; - return((strcmp(hdr->signature, TLV_INFO_ID_STRING) == 0) && - (hdr->version == TLV_INFO_VERSION) && - (be16_to_cpu(hdr->totallen) <= max_size) ); -} - -/* - * decode_tlv_value - * - * Decode a single TLV value into a string. - - * The validity of EEPROM contents and the TLV field have been verified - * prior to calling this function. - */ -#define DECODE_NAME_MAX 20 - -static void decode_tlv_value(tlvinfo_tlv_t * tlv, char* value) -{ - int i; - - switch (tlv->type) { - case TLV_CODE_PRODUCT_NAME: - case TLV_CODE_PART_NUMBER: - case TLV_CODE_SERIAL_NUMBER: - case TLV_CODE_MANUF_DATE: - case TLV_CODE_LABEL_REVISION: - case TLV_CODE_PLATFORM_NAME: - case TLV_CODE_ONIE_VERSION: - case TLV_CODE_MANUF_NAME: - case TLV_CODE_MANUF_COUNTRY: - case TLV_CODE_VENDOR_NAME: - case TLV_CODE_DIAG_VERSION: - case TLV_CODE_SERVICE_TAG: - memcpy(value, tlv->value, tlv->length); - value[tlv->length] = 0; - break; - case TLV_CODE_MAC_BASE: - snprintf(value, MAX_STRING_SIZE, "%02X:%02X:%02X:%02X:%02X:%02X", - tlv->value[0], tlv->value[1], tlv->value[2], - tlv->value[3], tlv->value[4], tlv->value[5]); - break; - case TLV_CODE_DEVICE_VERSION: - snprintf(value, MAX_STRING_SIZE, "%u", tlv->value[0]); - break; - case TLV_CODE_MAC_SIZE: - snprintf(value, MAX_STRING_SIZE, "%u", (tlv->value[0] << 8) | tlv->value[1]); - break; - case TLV_CODE_VENDOR_EXT: - value[0] = 0; - for (i = 0; (i < (TLV_DECODE_VALUE_MAX_LEN/5)) && (i < tlv->length); - i++) { - snprintf(value, MAX_STRING_SIZE, "%s 0x%02X", value, tlv->value[i]); - } - break; - case TLV_CODE_CRC_32: - snprintf(value, MAX_STRING_SIZE, "0x%02X%02X%02X%02X", - tlv->value[0], tlv->value[1], tlv->value[2], - tlv->value[3]); - break; - default: - value[0] = 0; - for (i = 0; (i < (TLV_DECODE_VALUE_MAX_LEN/5)) && (i < tlv->length); - i++) { - snprintf(value, MAX_STRING_SIZE, "%s 0x%02X", value, tlv->value[i]); - } - break; - } - -} - -/* - * is_checksum_valid - * - * Validate the checksum in the provided TlvInfo EEPROM data. First, - * verify that the TlvInfo header is valid, then make sure the last - * TLV is a CRC-32 TLV. Then calculate the CRC over the EEPROM data - * and compare it to the value stored in the EEPROM CRC-32 TLV. - */ -static bool is_checksum_valid(u_int8_t *eeprom) -{ - tlvinfo_header_t * eeprom_hdr = (tlvinfo_header_t *) eeprom; - tlvinfo_tlv_t * eeprom_crc; - unsigned int calc_crc; - unsigned int stored_crc; - - // Is the eeprom header valid? - if (!is_valid_tlvinfo_header(eeprom_hdr)) { - return(FALSE); - } - - // Is the last TLV a CRC? - eeprom_crc = (tlvinfo_tlv_t *) &eeprom[sizeof(tlvinfo_header_t) + - be16_to_cpu(eeprom_hdr->totallen) - - (sizeof(tlvinfo_tlv_t) + 4)]; - if ((eeprom_crc->type != TLV_CODE_CRC_32) || (eeprom_crc->length != 4)) { - return(FALSE); - } - - // Calculate the checksum - calc_crc = crc32((void *)eeprom, sizeof(tlvinfo_header_t) + - be16_to_cpu(eeprom_hdr->totallen) - 4); - stored_crc = ((eeprom_crc->value[0] << 24) | (eeprom_crc->value[1] << 16) | - (eeprom_crc->value[2] << 8) | eeprom_crc->value[3]); - - //printk(KERN_ERR "[SWPS] cal_crc =0x%x, stored_crc =0x%x\n", calc_crc, stored_crc); - //return(calc_crc == stored_crc); - return 1; -} - -/* - * update_crc - * - * This function updates the CRC-32 TLV. If there is no CRC-32 TLV, then - * one is added. This function should be called after each update to the - * EEPROM structure, to make sure the CRC is always correct. - */ -static void update_crc(u_int8_t *eeprom) -{ - tlvinfo_header_t * eeprom_hdr = (tlvinfo_header_t *) eeprom; - tlvinfo_tlv_t * eeprom_crc; - unsigned int calc_crc; - - // Is the eeprom header valid? - if (!is_valid_tlvinfo_header(eeprom_hdr)) { - return; - } - // Is the last TLV a CRC? - eeprom_crc = (tlvinfo_tlv_t *) &eeprom[sizeof(tlvinfo_header_t) + - be16_to_cpu(eeprom_hdr->totallen) - - (sizeof(tlvinfo_tlv_t) + 4)]; - if (eeprom_crc->type != TLV_CODE_CRC_32) { - if ((be16_to_cpu(eeprom_hdr->totallen) + sizeof(tlvinfo_tlv_t) + 4) > - TLV_TOTAL_LEN_MAX) { - return; - } - eeprom_crc = (tlvinfo_tlv_t *) &eeprom[sizeof(tlvinfo_header_t) + - be16_to_cpu( - eeprom_hdr->totallen)]; - eeprom_hdr->totallen = cpu_to_be16(be16_to_cpu(eeprom_hdr->totallen) + - sizeof(tlvinfo_tlv_t) + 4); - eeprom_crc->type = TLV_CODE_CRC_32; - } - eeprom_crc->length = 4; - - // Calculate the checksum - calc_crc = crc32((void *)eeprom, - sizeof(tlvinfo_header_t) + - be16_to_cpu(eeprom_hdr->totallen) - 4); - - eeprom_crc->value[0] = (calc_crc >> 24) & 0xFF; - eeprom_crc->value[1] = (calc_crc >> 16) & 0xFF; - eeprom_crc->value[2] = (calc_crc >> 8) & 0xFF; - eeprom_crc->value[3] = (calc_crc >> 0) & 0xFF; -} - -/* - * show_eeprom - * - * Display the contents of the EEPROM - */ - -/* - * read_eeprom - * - * Read the EEPROM into memory, if it hasn't already been read. - */ -int read_eeprom( struct i2c_client *pi2c_client, u_int8_t *eeprom) -{ - int ret; - tlvinfo_header_t *eeprom_hdr = (tlvinfo_header_t *) eeprom; - tlvinfo_tlv_t *eeprom_tlv = (tlvinfo_tlv_t *)&eeprom[ - sizeof(tlvinfo_header_t)]; - - if (has_been_read) - return 0; - - /* Read the header */ - ret = read_sys_eeprom( pi2c_client,(void *)eeprom_hdr, 0, sizeof(tlvinfo_header_t)); - /* If the header was successfully read, read the TLVs */ - if ((ret == 0) && is_valid_tlvinfo_header(eeprom_hdr)) { - ret = read_sys_eeprom( pi2c_client, (void *)eeprom_tlv, sizeof(tlvinfo_header_t), - be16_to_cpu(eeprom_hdr->totallen)); - } - // If the contents are invalid, start over with default contents - if(!is_valid_tlvinfo_header(eeprom_hdr)) - printk(KERN_ERR - "Notice: Invalid TLV header found. Using default contents--1.\n"); - if(!is_checksum_valid(eeprom)) - printk(KERN_ERR - "Notice: Invalid TLV checksum found. Using default contents--2.\n"); - if ( !is_valid_tlvinfo_header(eeprom_hdr) || !is_checksum_valid(eeprom) ){ - strcpy(eeprom_hdr->signature, TLV_INFO_ID_STRING); - eeprom_hdr->version = TLV_INFO_VERSION; - eeprom_hdr->totallen = cpu_to_be16(0); - update_crc(eeprom); - } - has_been_read = 1; - - return ret; -} -EXPORT_SYMBOL(read_eeprom); - -/* - * prog_eeprom - * Write the EEPROM data from CPU memory to the hardware. - */ -int prog_eeprom(struct i2c_client *pi2c_client, u_int8_t * eeprom) -{ - int ret = 0; - tlvinfo_header_t * eeprom_hdr = (tlvinfo_header_t *) eeprom; - int eeprom_len; - - eeprom_len = sizeof(tlvinfo_header_t) + be16_to_cpu(eeprom_hdr->totallen); - ret = write_sys_eeprom( pi2c_client, eeprom, eeprom_len); - if (ret) { - printk("Programming failed.\n"); - return -1; - } - has_been_read = 0; - return 0; -} -EXPORT_SYMBOL(prog_eeprom); - -/* - * tlvinfo_find_tlv - * - * This function finds the TLV with the supplied code in the EERPOM. - * An offset from the beginning of the EEPROM is returned in the - * eeprom_index parameter if the TLV is found. - */ -bool tlvinfo_find_tlv(u_int8_t *eeprom, u_int8_t tcode, - int *eeprom_index) -{ - tlvinfo_header_t * eeprom_hdr = (tlvinfo_header_t *) eeprom; - tlvinfo_tlv_t * eeprom_tlv; - int eeprom_end; - - // Make sure the EEPROM contents are valid - if (!is_valid_tlvinfo_header(eeprom_hdr) || !is_checksum_valid(eeprom)) { - return(FALSE); - } - // Search through the TLVs, looking for the first one which matches the - // supplied type code. - *eeprom_index = sizeof(tlvinfo_header_t); - eeprom_end = sizeof(tlvinfo_header_t) + be16_to_cpu(eeprom_hdr->totallen); - - while (*eeprom_index < eeprom_end) { - eeprom_tlv = (tlvinfo_tlv_t *) &eeprom[*eeprom_index]; - if (!is_valid_tlv(eeprom_tlv)) { - return(FALSE); - } - if (eeprom_tlv->type == tcode) { - return(TRUE); - } - *eeprom_index += sizeof(tlvinfo_tlv_t) + eeprom_tlv->length; - } - return(FALSE); -} - -/* - * tlvinfo_decode_tlv - * - * This function finds the TLV with the supplied code in the EERPOM - * and decodes the value into the buffer provided. - */ -bool tlvinfo_decode_tlv(u_int8_t *eeprom, u_int8_t tcode, char* value) -{ - int eeprom_index; - tlvinfo_tlv_t * eeprom_tlv; - - // Find the TLV and then decode it - - if (tlvinfo_find_tlv(eeprom, tcode, &eeprom_index)) { - eeprom_tlv = (tlvinfo_tlv_t *) &eeprom[eeprom_index]; - decode_tlv_value(eeprom_tlv, value); - return TRUE; - } - - return FALSE; -} -EXPORT_SYMBOL(tlvinfo_decode_tlv); - -/* - * tlvinfo_delete_tlv - * - * This function deletes the TLV with the specified type code from the - * EEPROM. - */ -bool tlvinfo_delete_tlv(u_int8_t * eeprom, u_int8_t code) -{ - int eeprom_index; - int tlength; - tlvinfo_header_t * eeprom_hdr = (tlvinfo_header_t *) eeprom; - tlvinfo_tlv_t * eeprom_tlv; - - // Find the TLV and then move all following TLVs "forward" - if (tlvinfo_find_tlv(eeprom, code, &eeprom_index)) { - eeprom_tlv = (tlvinfo_tlv_t *) &eeprom[eeprom_index]; - tlength = sizeof(tlvinfo_tlv_t) + eeprom_tlv->length; - memcpy(&eeprom[eeprom_index], &eeprom[eeprom_index+tlength], - sizeof(tlvinfo_header_t) + be16_to_cpu(eeprom_hdr->totallen) - - eeprom_index - tlength); - eeprom_hdr->totallen = cpu_to_be16(be16_to_cpu(eeprom_hdr->totallen) - - tlength); - update_crc(eeprom); - return(TRUE); - } - return(FALSE); -} -EXPORT_SYMBOL(tlvinfo_delete_tlv); - -/* - * tlvinfo_add_tlv - * - * This function adds a TLV to the EEPROM, converting the value (a string) to - * the format in which it will be stored in the EEPROM. - */ -#define MAX_TLV_VALUE_LEN 256 -bool tlvinfo_add_tlv(u_int8_t * eeprom, int tcode, char * strval) -{ - tlvinfo_header_t * eeprom_hdr = (tlvinfo_header_t *) eeprom; - tlvinfo_tlv_t * eeprom_tlv; - int new_tlv_len = 0; - u_int32_t value; - char data[MAX_TLV_VALUE_LEN]; - int eeprom_index; - int max_size = TLV_TOTAL_LEN_MAX; - - // Encode each TLV type into the format to be stored in the EERPOM - switch (tcode) { - case TLV_CODE_PRODUCT_NAME: - case TLV_CODE_PART_NUMBER: - case TLV_CODE_SERIAL_NUMBER: - case TLV_CODE_LABEL_REVISION: - case TLV_CODE_PLATFORM_NAME: - case TLV_CODE_ONIE_VERSION: - case TLV_CODE_MANUF_NAME: - case TLV_CODE_MANUF_COUNTRY: - case TLV_CODE_VENDOR_NAME: - case TLV_CODE_DIAG_VERSION: - case TLV_CODE_SERVICE_TAG: - strncpy(data, strval, MAX_TLV_VALUE_LEN); - - if( strlen(strval) >= MAX_TLV_VALUE_LEN ) - new_tlv_len = MAX_TLV_VALUE_LEN; - else - new_tlv_len = strlen(strval); - - break; - case TLV_CODE_DEVICE_VERSION: - value = strtoul(strval, NULL, 0); - if (value >= 256) { - printk("ERROR: Device version must be 255 or less. Value " \ - "supplied: %u", value); - return(FALSE); - } - data[0] = value & 0xFF; - new_tlv_len = 1; - break; - case TLV_CODE_MAC_SIZE: - value = strtoul(strval, NULL, 0); - if (value >= 65536) { - printk("ERROR: MAC Size must be 65535 or less. Value " \ - "supplied: %u", value); - return(FALSE); - } - data[0] = (value >> 8) & 0xFF; - data[1] = value & 0xFF; - new_tlv_len = 2; - break; - case TLV_CODE_MANUF_DATE: - if (set_date(data, strval) != 0) { - return(FALSE); - } - new_tlv_len = 19; - break; - case TLV_CODE_MAC_BASE: - if (set_mac(data, strval) != 0) { - return(FALSE); - } - new_tlv_len = 6; - break; - case TLV_CODE_CRC_32: - printk("WARNING: The CRC TLV is set automatically and cannot be set " \ - "manually.\n"); - return(FALSE); - case TLV_CODE_VENDOR_EXT: - default: - if (set_bytes(data, strval, &new_tlv_len) != 0 ) { - return(FALSE); - } - break; - } - - // Is there room for this TLV? - if ((be16_to_cpu(eeprom_hdr->totallen) + sizeof(tlvinfo_tlv_t) + - new_tlv_len) > max_size) { - printk("ERROR: There is not enough room in the EERPOM to save data.\n"); - return(FALSE); - } - - // Add TLV at the end, overwriting CRC TLV if it exists - if (tlvinfo_find_tlv(eeprom, TLV_CODE_CRC_32, &eeprom_index)) { - eeprom_hdr->totallen = cpu_to_be16(be16_to_cpu(eeprom_hdr->totallen) - - sizeof(tlvinfo_tlv_t) - 4); - } else { - eeprom_index = sizeof(tlvinfo_header_t) + - be16_to_cpu(eeprom_hdr->totallen); - } - eeprom_tlv = (tlvinfo_tlv_t *) &eeprom[eeprom_index]; - eeprom_tlv->type = tcode; - eeprom_tlv->length = new_tlv_len; - memcpy(eeprom_tlv->value, data, new_tlv_len); - - // Update the total length and calculate (add) a new CRC-32 TLV - eeprom_hdr->totallen = cpu_to_be16(be16_to_cpu(eeprom_hdr->totallen) + - sizeof(tlvinfo_tlv_t) + new_tlv_len); - update_crc(eeprom); - - return(TRUE); -} -EXPORT_SYMBOL(tlvinfo_add_tlv); - -/* - * read_sys_eeprom - read the hwinfo from i2c EEPROM - */ -int read_sys_eeprom(struct i2c_client *pi2c_client,void *eeprom_data, int offset, int len) -{ - int iRet = 0; - int i = 0; - unsigned char ucBuf[2]; - u_int8_t *c; - unsigned short usAddr = SYS_EEPROM_OFFSET + offset; - - c = eeprom_data; - for (i = 0; i < len; i++) { - ucBuf[0] = (usAddr & 0xFF00) >> 8; - ucBuf[1] = (usAddr & 0x00FF); - - iRet = i2c_smbus_write_byte_data(pi2c_client, ucBuf[0], ucBuf[1]); - if( iRet < 0 ){ - printk(KERN_ERR"Error!! VPD data read error\n"); - return -1; - } - - *c = i2c_smbus_read_byte(pi2c_client); - c++; usAddr++; - } - return 0; -} - -/* - * write_sys_eeprom - write the hwinfo to i2c EEPROM - */ -int write_sys_eeprom(struct i2c_client *pi2c_client, void *eeprom_data, int len) -{ - int iRet = 0; - int i = 0; - u_int8_t *c; - unsigned short usAddr = SYS_EEPROM_OFFSET; - unsigned char ucBuf[3]; - - c = eeprom_data; - for (i = 0; i < len; i++) { - ucBuf[ 0 ] = (usAddr & 0xFF00) >>8 ; - ucBuf[ 1 ] = (usAddr & 0x00FF); - ucBuf[ 2 ] = *c; - - iRet = i2c_smbus_write_word_data( pi2c_client, ucBuf[0], (ucBuf[2] << 8 | ucBuf[1])); - if (iRet < 0 ){ - printk(KERN_ERR"Error!! VPD data write error . \n"); - return -1; - } - - c++; usAddr++; - msleep_interruptible(10); - } - - return 0; -} - -void update_eeprom_header(u_int8_t *eeprom) -{ - tlvinfo_header_t * eeprom_hdr = (tlvinfo_header_t *) eeprom; - - strcpy(eeprom_hdr->signature, TLV_INFO_ID_STRING); - eeprom_hdr->version = TLV_INFO_VERSION; - eeprom_hdr->totallen = cpu_to_be16(0); - update_crc(eeprom); -} diff --git a/packages/platforms/inventec/x86-64/d7032q28b/modules/builds/src/onie_tlvinfo.h b/packages/platforms/inventec/x86-64/d7032q28b/modules/builds/src/onie_tlvinfo.h deleted file mode 100644 index 63df46202..000000000 --- a/packages/platforms/inventec/x86-64/d7032q28b/modules/builds/src/onie_tlvinfo.h +++ /dev/null @@ -1,150 +0,0 @@ -/* - * The Definition of the TlvInfo EEPROM format can be found at onie.org or - * github.com/onie - */ -#include -#define strtoul simple_strtoul - -#define FALSE 0 -#define TRUE (!FALSE) -#define MAX_STRING_SIZE 128 -/* - * Tlvinf header: Layout of the header for the TlvInfo format - * - * See the end of this file for details of this eeprom format - */ -struct __attribute__ ((__packed__)) tlvinfo_header_s { - char signature[8]; /* 0x00 - 0x07 EEPROM Tag "TlvInfo" */ - u_int8_t version; /* 0x08 Structure version */ - u_int16_t totallen; /* 0x09 - 0x0A Length of all data which follows */ -}; -typedef struct tlvinfo_header_s tlvinfo_header_t; - -// Header Field Constants -#define TLV_INFO_ID_STRING "TlvInfo" -#define TLV_INFO_VERSION 0x01 -#define TLV_TOTAL_LEN_MAX (SYS_EEPROM_SIZE - sizeof(tlvinfo_header_t)) - -/* - * TlvInfo TLV: Layout of a TLV field - */ -struct __attribute__ ((__packed__)) tlvinfo_tlv_s { - u_int8_t type; - u_int8_t length; - u_int8_t value[0]; -}; -typedef struct tlvinfo_tlv_s tlvinfo_tlv_t; - -/* Maximum length of a TLV value in bytes */ -#define TLV_VALUE_MAX_LEN 255 - -/** - * The TLV Types. - * - * Keep these in sync with tlv_code_list in cmd_sys_eeprom.c - */ -#define TLV_CODE_PRODUCT_NAME 0x21 -#define TLV_CODE_PART_NUMBER 0x22 -#define TLV_CODE_SERIAL_NUMBER 0x23 -#define TLV_CODE_MAC_BASE 0x24 -#define TLV_CODE_MANUF_DATE 0x25 -#define TLV_CODE_DEVICE_VERSION 0x26 -#define TLV_CODE_LABEL_REVISION 0x27 -#define TLV_CODE_PLATFORM_NAME 0x28 -#define TLV_CODE_ONIE_VERSION 0x29 -#define TLV_CODE_MAC_SIZE 0x2A -#define TLV_CODE_MANUF_NAME 0x2B -#define TLV_CODE_MANUF_COUNTRY 0x2C -#define TLV_CODE_VENDOR_NAME 0x2D -#define TLV_CODE_DIAG_VERSION 0x2E -#define TLV_CODE_SERVICE_TAG 0x2F -#define TLV_CODE_VENDOR_EXT 0xFD -#define TLV_CODE_CRC_32 0xFE -#define TLV_CODE_EEPROM_DATA 0x00 - -/* - * Struct for displaying the TLV codes and names. - */ -struct tlv_code_desc { - u_int8_t m_code; - char* m_name; -}; - -/* - * List of TLV codes and names. - */ -static const struct tlv_code_desc tlv_code_list[] = { - { TLV_CODE_PRODUCT_NAME , "Product Name"}, - { TLV_CODE_PART_NUMBER , "Part Number"}, - { TLV_CODE_SERIAL_NUMBER , "Serial Number"}, - { TLV_CODE_MAC_BASE , "Base MAC Address"}, - { TLV_CODE_MANUF_DATE , "Manufacture Date"}, - { TLV_CODE_DEVICE_VERSION , "Device Version"}, - { TLV_CODE_LABEL_REVISION , "Label Revision"}, - { TLV_CODE_PLATFORM_NAME , "Platform Name"}, - { TLV_CODE_ONIE_VERSION , "Loader Version"}, - { TLV_CODE_MAC_SIZE , "MAC Addresses"}, - { TLV_CODE_MANUF_NAME , "Manufacturer"}, - { TLV_CODE_MANUF_COUNTRY , "Country Code"}, - { TLV_CODE_VENDOR_NAME , "Vendor Name"}, - { TLV_CODE_DIAG_VERSION , "Diag Version"}, - { TLV_CODE_SERVICE_TAG , "Service Tag"}, - { TLV_CODE_VENDOR_EXT , "Vendor Extension"}, - { TLV_CODE_CRC_32 , "CRC-32"}, -}; - -static inline const char* tlv_type2name(u_int8_t type) -{ - char* name = "Unknown"; - int i; - - for (i = 0; i < sizeof(tlv_code_list)/sizeof(tlv_code_list[0]); i++) { - if (tlv_code_list[i].m_code == type) { - name = tlv_code_list[i].m_name; - break; - } - } - return name; -} - -/* - * The max decode value is currently for the 'raw' type or the 'vendor - * extension' type, both of which have the same decode format. The - * max decode string size is computed as follows: - * - * strlen(" 0xFF") * TLV_VALUE_MAX_LEN + 1 - * - */ -#define TLV_DECODE_VALUE_MAX_LEN ((5 * TLV_VALUE_MAX_LEN) + 1) - - -/* - * Each platform must define the following platform-specific macros - * in sys_eeprom_platform.h: - * SYS_EEPROM_SIZE: size of usable eeprom - * SYS_EEPROM_I2C_DEVICE: i2c-bus - * SYS_EEPROM_I2C_ADDR: address on the bus - * The following may also be defined in sys_eeprom_platform.h, else - * the defaults with take over: - * SYS_EEPROM_MAX_SIZE: Total size of the eeprom - * SYS_EEPROM_OFFSET: offset from where the ONIE header starts - */ -#define SYS_EEPROM_MAX_SIZE 2048 -#define SYS_EEPROM_OFFSET 0 -#define SYS_EEPROM_SIZE SYS_EEPROM_MAX_SIZE -#define SYS_EEPROM_I2C_DEVICE "/dev/i2c-0" -#define SYS_EEPROM_I2C_ADDR 0x53 - -#if (SYS_EEPROM_SIZE + SYS_EEPROM_OFFSET > SYS_EEPROM_MAX_SIZE) - #error SYS_EEPROM_SIZE + SYS_EEPROM_OFFSET is greater than SYS_EEPROM_MAX_SIZE -#endif - -// Access functions to onie_tlvinfo -void show_eeprom(u_int8_t *eeprom); -int read_eeprom(struct i2c_client *pi2c_client, u_int8_t *eeprom); -int prog_eeprom(struct i2c_client *pi2c_client,u_int8_t * eeprom); -void update_eeprom_header(u_int8_t *eeprom); -bool tlvinfo_find_tlv(u_int8_t *eeprom, u_int8_t tcode, int *eeprom_index); -bool tlvinfo_delete_tlv(u_int8_t * eeprom, u_int8_t code); -bool tlvinfo_add_tlv(u_int8_t * eeprom, int tcode, char * strval); -bool tlvinfo_decode_tlv(u_int8_t *eeprom, u_int8_t tcode, char* value); diff --git a/packages/platforms/inventec/x86-64/d7032q28b/modules/builds/src/transceiver.c b/packages/platforms/inventec/x86-64/d7032q28b/modules/builds/src/transceiver.c deleted file mode 100644 index 6a41ad6e1..000000000 --- a/packages/platforms/inventec/x86-64/d7032q28b/modules/builds/src/transceiver.c +++ /dev/null @@ -1,8285 +0,0 @@ -/************************************************************************* - * - * transceiver.c - * - * 2018 Inventec Corporation - * All Rights Reserved. - * - * NOTICE: All information contained herein is, and remains - * the property of Inventec Corp. and its suppliers, - * if any. The intellectual and technical concepts contained - * herein are proprietary to Inventec Corporation and its suppliers - * and may be covered by U.S. and Foreign Patents, patents in process, - * and are protected by trade secret or copyright law. - * - ************************************************************************/ - -#include -#include -#include -#include -#include -#include -#include "io_expander.h" -#include "transceiver.h" - - -/* ========== Register EEPROM address mapping ========== - */ -struct eeprom_map_s eeprom_map_sfp = { - .addr_br =0x50, .page_br =-1, .offset_br =12, .length_br =1, - .addr_cdr =-1, .page_cdr =-1, .offset_cdr =-1, .length_cdr =-1, - .addr_comp_rev =0x50, .page_comp_rev =-1, .offset_comp_rev =94, .length_comp_rev =1, - .addr_connector =0x50, .page_connector =-1, .offset_connector =2, .length_connector =1, - .addr_diag_type =0x50, .page_diag_type =-1, .offset_diag_type =92 , .length_diag_type =1, - .addr_extbr =-1, .page_extbr =-1, .offset_extbr =-1, .length_extbr =-1, - .addr_ext_id =0x50, .page_ext_id =-1, .offset_ext_id =1, .length_ext_id =1, - .addr_id =0x50, .page_id =-1, .offset_id =0, .length_id =1, - .addr_len_sm =0x50, .page_len_sm =-1, .offset_len_sm =15, .length_len_sm =1, - .addr_len_smf =0x50, .page_len_smf =-1, .offset_len_smf =14, .length_len_smf =1, - .addr_len_om1 =0x50, .page_len_om1 =-1, .offset_len_om1 =17, .length_len_om1 =1, - .addr_len_om2 =0x50, .page_len_om2 =-1, .offset_len_om2 =16, .length_len_om2 =1, - .addr_len_om3 =0x50, .page_len_om3 =-1, .offset_len_om3 =19, .length_len_om3 =1, - .addr_len_om4 =0x50, .page_len_om4 =-1, .offset_len_om4 =18, .length_len_om4 =1, - .addr_option =0x50, .page_option =-1, .offset_option =64, .length_option =2, - .addr_rate_id =0x50, .page_rate_id =-1, .offset_rate_id =13, .length_rate_id =1, - .addr_rx_am =-1, .page_rx_am =-1, .offset_rx_am =-1, .length_rx_am =-1, - .addr_rx_em =0x51, .page_rx_em =-1, .offset_rx_em =115, .length_rx_em =1, - .addr_rx_los =-1, .page_rx_los =-1, .offset_rx_los =-1, .length_rx_los =-1, - .addr_rx_power =0x51, .page_rx_power =-1, .offset_rx_power =104, .length_rx_power =2, - .addr_soft_rs0 =0x51, .page_soft_rs0 =-1, .offset_soft_rs0 =110, .length_soft_rs0 =1, - .addr_soft_rs1 =0x51, .page_soft_rs1 =-1, .offset_soft_rs1 =118, .length_soft_rs0 =1, - .addr_temp =0x51, .page_temp =-1, .offset_temp =96, .length_temp =2, - .addr_trancomp =0x50, .page_trancomp =-1, .offset_trancomp =3, .length_trancomp =8, - .addr_trancomp_ext =0x50, .page_trancomp_ext =-1, .offset_trancomp_ext =36, .length_trancomp_ext =1, - .addr_tx_bias =0x51, .page_tx_bias =-1, .offset_tx_bias =100, .length_tx_bias =2, - .addr_tx_disable =-1, .page_tx_disable =-1, .offset_tx_disable =-1, .length_tx_disable =-1, - .addr_tx_eq =0x51, .page_tx_eq =-1, .offset_tx_eq =114, .length_tx_eq =1, - .addr_tx_fault =-1, .page_tx_fault =-1, .offset_tx_fault =-1, .length_tx_fault =-1, - .addr_tx_power =0x51, .page_tx_power =-1, .offset_tx_power =102, .length_tx_power =2, - .addr_vendor_name =0x50, .page_vendor_name =-1, .offset_vendor_name =20, .length_vendor_name =16, - .addr_vendor_pn =0x50, .page_vendor_pn =-1, .offset_vendor_pn =40, .length_vendor_pn =16, - .addr_vendor_rev =0x50, .page_vendor_rev =-1, .offset_vendor_rev =56, .length_vendor_rev =4, - .addr_vendor_sn =0x50, .page_vendor_sn =-1, .offset_vendor_sn =68, .length_vendor_sn =16, - .addr_voltage =0x51, .page_voltage =-1, .offset_voltage =98, .length_voltage =2, - .addr_wavelength =0x50, .page_wavelength =-1, .offset_wavelength =60, .length_wavelength =2, - .addr_eeprom =0x50, .page_eeprom =-1, .offset_eeprom =0, .length_eeprom =256, -}; - -struct eeprom_map_s eeprom_map_qsfp = { - .addr_br =0x50, .page_br =0, .offset_br =140, .length_br =1, - .addr_cdr =-1, .page_cdr =-1, .offset_cdr =-1, .length_cdr =-1, - .addr_comp_rev =0x50, .page_comp_rev =-1, .offset_comp_rev =1, .length_comp_rev =1, - .addr_connector =0x50, .page_connector =0, .offset_connector =130, .length_connector =1, - .addr_diag_type =0x50, .page_diag_type =0, .offset_diag_type =220, .length_diag_type =1, - .addr_extbr =0x50, .page_extbr =0, .offset_extbr =222, .length_extbr =1, - .addr_ext_id =0x50, .page_ext_id =0, .offset_ext_id =129, .length_ext_id =1, - .addr_id =0x50, .page_id =0, .offset_id =128, .length_id =1, - .addr_len_sm =-1, .page_len_sm =-1, .offset_len_sm =-1, .length_len_sm =-1, - .addr_len_smf =0x50, .page_len_smf =0, .offset_len_smf =142, .length_len_smf =1, - .addr_len_om1 =0x50, .page_len_om1 =0, .offset_len_om1 =145, .length_len_om1 =1, - .addr_len_om2 =0x50, .page_len_om2 =0, .offset_len_om2 =144, .length_len_om2 =1, - .addr_len_om3 =0x50, .page_len_om3 =0, .offset_len_om3 =143, .length_len_om3 =1, - .addr_len_om4 =0x50, .page_len_om4 =0, .offset_len_om4 =146, .length_len_om4 =1, - .addr_option =0x50, .page_option =0, .offset_option =193, .length_option =3, - .addr_rate_id =-1, .page_rate_id =-1, .offset_rate_id =-1, .length_rate_id =-1, - .addr_rx_am =-1, .page_rx_am =-1, .offset_rx_am =-1, .length_rx_am =-1, - .addr_rx_em =-1, .page_rx_em =-1, .offset_rx_em =-1, .length_rx_em =-1, - .addr_rx_los =0x50, .page_rx_los =-1, .offset_rx_los =3, .length_rx_los =1, - .addr_rx_power =0x50, .page_rx_power =-1, .offset_rx_power =34, .length_rx_power =8, - .addr_soft_rs0 =-1, .page_soft_rs0 =-1, .offset_soft_rs0 =-1, .length_soft_rs0 =-1, - .addr_soft_rs1 =-1, .page_soft_rs1 =-1, .offset_soft_rs1 =-1, .length_soft_rs0 =-1, - .addr_temp =0x50, .page_temp =-1, .offset_temp =22, .length_temp =2, - .addr_trancomp =0x50, .page_trancomp =0, .offset_trancomp =131, .length_trancomp =8, - .addr_trancomp_ext =0x50, .page_trancomp_ext =0, .offset_trancomp_ext =192, .length_trancomp_ext =1, - .addr_tx_bias =0x50, .page_tx_bias =-1, .offset_tx_bias =42, .length_tx_bias =8, - .addr_tx_disable =0x50, .page_tx_disable =-1, .offset_tx_disable =86, .length_tx_disable =1, - .addr_tx_eq =-1, .page_tx_eq =-1, .offset_tx_eq =-1, .length_tx_eq =-1, - .addr_tx_fault =0x50, .page_tx_fault =-1, .offset_tx_fault =4, .length_tx_fault =1, - .addr_tx_power =0x50, .page_tx_power =-1, .offset_tx_power =50, .length_tx_power =8, - .addr_vendor_name =0x50, .page_vendor_name =0, .offset_vendor_name =148, .length_vendor_name =16, - .addr_vendor_pn =0x50, .page_vendor_pn =0, .offset_vendor_pn =168, .length_vendor_pn =16, - .addr_vendor_rev =0x50, .page_vendor_rev =0, .offset_vendor_rev =184, .length_vendor_rev =2, - .addr_vendor_sn =0x50, .page_vendor_sn =0, .offset_vendor_sn =196, .length_vendor_sn =16, - .addr_voltage =0x50, .page_voltage =-1, .offset_voltage =26, .length_voltage =2, - .addr_wavelength =0x50, .page_wavelength =0, .offset_wavelength =186, .length_wavelength =2, - .addr_eeprom =0x50, .page_eeprom =0, .offset_eeprom =0, .length_eeprom =256, -}; - -struct eeprom_map_s eeprom_map_qsfp28 = { - .addr_br =0x50, .page_br =0, .offset_br =140, .length_br =1, - .addr_cdr =0x50, .page_cdr =-1, .offset_cdr =98, .length_cdr =1, - .addr_comp_rev =0x50, .page_comp_rev =-1, .offset_comp_rev =1, .length_comp_rev =1, - .addr_connector =0x50, .page_connector =0, .offset_connector =130, .length_connector =1, - .addr_diag_type =0x50, .page_diag_type =0, .offset_diag_type =220, .length_diag_type =1, - .addr_extbr =0x50, .page_extbr =0, .offset_extbr =222, .length_extbr =1, - .addr_ext_id =0x50, .page_ext_id =0, .offset_ext_id =129, .length_ext_id =1, - .addr_id =0x50, .page_id =0, .offset_id =128, .length_id =1, - .addr_len_sm =-1, .page_len_sm =-1, .offset_len_sm =-1, .length_len_sm =-1, - .addr_len_smf =0x50, .page_len_smf =0, .offset_len_smf =142, .length_len_smf =1, - .addr_len_om1 =0x50, .page_len_om1 =0, .offset_len_om1 =145, .length_len_om1 =1, - .addr_len_om2 =0x50, .page_len_om2 =0, .offset_len_om2 =144, .length_len_om2 =1, - .addr_len_om3 =0x50, .page_len_om3 =0, .offset_len_om3 =143, .length_len_om3 =1, - .addr_len_om4 =0x50, .page_len_om4 =0, .offset_len_om4 =146, .length_len_om4 =1, - .addr_option =0x50, .page_option =0, .offset_option =193, .length_option =3, - .addr_rate_id =-1, .page_rate_id =-1, .offset_rate_id =-1, .length_rate_id =-1, - .addr_rx_am =0x50, .page_rx_am =3, .offset_rx_am =238, .length_rx_am =2, - .addr_rx_em =0x50, .page_rx_em =3, .offset_rx_em =236, .length_rx_em =2, - .addr_rx_los =0x50, .page_rx_los =-1, .offset_rx_los =3, .length_rx_los =1, - .addr_rx_power =0x50, .page_rx_power =-1, .offset_rx_power =34, .length_rx_power =8, - .addr_soft_rs0 =-1, .page_soft_rs0 =-1, .offset_soft_rs0 =-1, .length_soft_rs0 =-1, - .addr_soft_rs1 =-1, .page_soft_rs1 =-1, .offset_soft_rs1 =-1, .length_soft_rs0 =-1, - .addr_temp =0x50, .page_temp =-1, .offset_temp =22, .length_temp =2, - .addr_trancomp =0x50, .page_trancomp =0, .offset_trancomp =131, .length_trancomp =8, - .addr_trancomp_ext =0x50, .page_trancomp_ext =0, .offset_trancomp_ext =192, .length_trancomp_ext =1, - .addr_tx_bias =0x50, .page_tx_bias =-1, .offset_tx_bias =42, .length_tx_bias =8, - .addr_tx_disable =0x50, .page_tx_disable =-1, .offset_tx_disable =86, .length_tx_disable =1, - .addr_tx_eq =0x50, .page_tx_eq =3, .offset_tx_eq =234, .length_tx_eq =2, - .addr_tx_fault =0x50, .page_tx_fault =-1, .offset_tx_fault =4, .length_tx_fault =1, - .addr_tx_power =0x50, .page_tx_power =-1, .offset_tx_power =50, .length_tx_power =8, - .addr_vendor_name =0x50, .page_vendor_name =0, .offset_vendor_name =148, .length_vendor_name =16, - .addr_vendor_pn =0x50, .page_vendor_pn =0, .offset_vendor_pn =168, .length_vendor_pn =16, - .addr_vendor_rev =0x50, .page_vendor_rev =0, .offset_vendor_rev =184, .length_vendor_rev =2, - .addr_vendor_sn =0x50, .page_vendor_sn =0, .offset_vendor_sn =196, .length_vendor_sn =16, - .addr_voltage =0x50, .page_voltage =-1, .offset_voltage =26, .length_voltage =2, - .addr_wavelength =0x50, .page_wavelength =0, .offset_wavelength =186, .length_wavelength =2, - .addr_eeprom =0x50, .page_eeprom =0, .offset_eeprom =0, .length_eeprom =256, -}; - - -/* ========== Utility Functions ========== - */ -static int -get_bit(uint8_t origin_byte, int bit_shift) { - return (int)((origin_byte >> bit_shift) & 0x1); -} - -static int -transform_word_to_int(uint8_t hight_byte, - uint8_t low_byte) { - return ((((int)hight_byte) << 8) + (int)low_byte); -} - -void -alarm_msg_2_user(struct transvr_obj_s *self, - char *emsg) { - - SWPS_ERR("%s on %s.\n", emsg, self->swp_name); -} -EXPORT_SYMBOL(alarm_msg_2_user); - - -/* ========== Private functions ========== - */ -static int -_reload_transvr_obj(struct transvr_obj_s *self,int new_type); - -static int -reload_transvr_obj(struct transvr_obj_s *self,int new_type); - -static int -_is_transvr_support_ctle(struct transvr_obj_s *self); - -static int -_transvr_init_handler(struct transvr_obj_s *self); - -int -_transvr_clean_handler(struct transvr_obj_s *self); - -int -_sfp_detect_class_by_1g_ethernet(struct transvr_obj_s* self); - - -void -lock_transvr_obj(struct transvr_obj_s *self) { - - mutex_lock(&self->lock); - self->curr_page = VAL_TRANSVR_PAGE_FREE; -} -EXPORT_SYMBOL(lock_transvr_obj); - - -void -unlock_transvr_obj(struct transvr_obj_s *self) { - - self->curr_page = VAL_TRANSVR_PAGE_FREE; - mutex_unlock(&self->lock); -} -EXPORT_SYMBOL(unlock_transvr_obj); - - -static int -_check_by_mode(struct transvr_obj_s *self, - int (*attr_update_func)(struct transvr_obj_s *self, int show_err), - char *caller_name){ - - int return_val = ERR_TRANSVR_UNEXCPT; - - switch (self->mode){ - case TRANSVR_MODE_POLLING: - switch (self->state){ - case STATE_TRANSVR_CONNECTED: - goto ok_check_by_mode_1; - case STATE_TRANSVR_NEW: - case STATE_TRANSVR_INIT: - return ERR_TRANSVR_UNINIT; - case STATE_TRANSVR_DISCONNECTED: - return ERR_TRANSVR_UNPLUGGED; - case STATE_TRANSVR_UNEXCEPTED: - return ERR_TRANSVR_ABNORMAL; - case STATE_TRANSVR_ISOLATED: - return ERR_TRNASVR_BE_ISOLATED; - default: - goto err_check_by_mode_1; - } - goto ok_check_by_mode_1; - - case TRANSVR_MODE_DIRECT: - return_val = self->fsm_4_direct(self, caller_name); - if (return_val < 0){ - return return_val; - } - goto ok_check_by_mode_1; - - default: - goto err_check_by_mode_1; - } - goto ok_check_by_mode_1; - -ok_check_by_mode_1: - return attr_update_func(self, 0); - -err_check_by_mode_1: - SWPS_INFO("_check_by_mode: mode:%d state:%d\n", self->mode, self->state); - return ERR_TRANSVR_UNEXCPT; -} - - -static void -_transvr_clean_retry(struct transvr_obj_s *self) { - self->retry = 0; -} - - -static int -_transvr_handle_retry(struct transvr_obj_s *self, int retry) { - /* Return: 0: keep retry - * -1: stop retry - */ - if (self->retry == 0) { - self->retry = retry; - } - self->retry -= 1; - if (self->retry <= 0) { - _transvr_clean_retry(self); - return -1; - } - return 0; -} - - -static int -_common_setup_page(struct transvr_obj_s *self, - int addr, - int page, - int offset, - int len, - int show_e) { - /* return: - * 0 : OK - * -1 : EEPROM settings incorrect - * -2 : I2C R/W failure - * -3 : Undefined case - */ - int retval = DEBUG_TRANSVR_INT_VAL; - char *emsg = DEBUG_TRANSVR_STR_VAL; - - /* Check */ - if ((addr < 0) || (offset < 0) || (len < 0)) { - emsg = "EEPROM settings incorrect"; - retval = -1; - goto err_common_setup_page; - } - /* Case1: continue access */ - if ((self->i2c_client_p->addr == addr) && - (self->curr_page == page)) { - return 0; - } - self->i2c_client_p->addr = addr; - /* Case2: select lower page */ - if (page == -1) { - self->curr_page = page; - return 0; - } - /* Case3: select upper page */ - if (page >= 0) { - goto upper_common_setup_page; - } - /* Unexpected case */ - show_e = 1; - emsg = "Unexpected case"; - retval = -3; - goto err_common_setup_page; - -upper_common_setup_page: - if (i2c_smbus_write_byte_data(self->i2c_client_p, - VAL_TRANSVR_PAGE_SELECT_OFFSET, - page) < 0) { - emsg = "I2C R/W failure"; - retval = -2; - goto err_common_setup_page; - } - self->curr_page = page; - mdelay(VAL_TRANSVR_PAGE_SELECT_DELAY); - return 0; - -err_common_setup_page: - if (show_e) { - SWPS_INFO("%s: %s", __func__, emsg); - SWPS_INFO("%s: :0x%02x :%d :%d :%d\n", - __func__, addr, page, offset, len); - } - return retval; -} - -/* -static int -_common_setup_password(struct transvr_obj_s *self, - int addr, - int page, - int offs, - uint8_t pwd[4], - int show_e) { - int i = 0; - int err = DEBUG_TRANSVR_INT_VAL; - char *emsg = DEBUG_TRANSVR_STR_VAL; - - err = _common_setup_page(self, addr, page, offs, 4, show_e); - if (err < 0){ - emsg = "setup EEPROM page fail"; - goto err_common_setup_password; - } - for (i=0; i<4; i++) { - err = i2c_smbus_write_byte_data(self->i2c_client_p, - (offs + i), - pwd[i]); - if (err < 0){ - emsg = "I2C R/W fail!"; - goto err_common_setup_password; - } - } - return 0; - -err_common_setup_password: - if (show_e) { - SWPS_INFO("%s: %s :%d\n", __func__, emsg, err); - } - return ERR_TRANSVR_UPDATE_FAIL; -} -*/ - -static int -_common_update_uint8_attr(struct transvr_obj_s *self, - int addr, - int page, - int offset, - int len, - uint8_t *buf, - char *caller, - int show_e){ - - int i; - int err = DEBUG_TRANSVR_INT_VAL; - char *emsg = DEBUG_TRANSVR_STR_VAL; - - err = _common_setup_page(self, addr, page, offset, len, show_e); - if (err < 0){ - emsg = "setup EEPROM page fail"; - goto err_common_update_uint8_attr; - } - for (i=0; ii2c_client_p, (offset + i)); - if (err < 0){ - emsg = "I2C R/W fail!"; - goto err_common_update_uint8_attr; - } - buf[i] = err; - } - return 0; - -err_common_update_uint8_attr: - if (show_e) { - SWPS_INFO("%s: %s :%s :%d\n", - __func__, emsg, caller, err); - } - buf[0] = DEBUG_TRANSVR_HEX_VAL; - return ERR_TRANSVR_UPDATE_FAIL; -} - - -static int -_common_update_int_attr(struct transvr_obj_s *self, - int addr, - int page, - int offset, - int len, - int *buf, - char *caller, - int show_e){ - - int i; - int err = DEBUG_TRANSVR_INT_VAL; - char *emsg = DEBUG_TRANSVR_STR_VAL; - - err = _common_setup_page(self, addr, page, offset, len, show_e); - if (err < 0){ - emsg = "setup EEPROM page fail"; - goto err_common_update_int_attr; - } - for (i=0; ii2c_client_p, (offset + i)); - if (err < 0){ - emsg = "I2C R/W fail!"; - goto err_common_update_int_attr; - } - buf[i] = (int)err; - } - return 0; - -err_common_update_int_attr: - if (show_e) { - SWPS_INFO("%s: %s :%s :%d\n", - __func__, emsg, caller, err); - } - buf[0] = DEBUG_TRANSVR_INT_VAL; - return ERR_TRANSVR_UPDATE_FAIL; -} - - -static int -_common_update_string_attr(struct transvr_obj_s *self, - int addr, - int page, - int offset, - int len, - char buf[], - char *caller, - int show_e){ - - int i; - int err = DEBUG_TRANSVR_INT_VAL; - char *emsg = DEBUG_TRANSVR_STR_VAL; - - err = _common_setup_page(self, addr, page, offset, len, show_e); - if (err < 0){ - emsg = "setup EEPROM page fail"; - goto err_common_update_string_attr; - } - for (i=0; ii2c_client_p, (offset + i)); - if (err < 0){ - emsg = "I2C R/W fail!"; - goto err_common_update_string_attr; - } - buf[i] = (char)err; - } - return 0; - -err_common_update_string_attr: - if (show_e) { - SWPS_INFO("%s: %s :%s :%d\n", - __func__, emsg, caller, err); - } - buf[0] = 'e'; - return ERR_TRANSVR_UPDATE_FAIL; -} - - -static int -_common_set_uint8_attr(struct transvr_obj_s *self, - int addr, - int page, - int offset, - uint8_t update, - uint8_t *buf, - char *caller, - int show_e){ - int len = 1; - int err = DEBUG_TRANSVR_INT_VAL; - char *emsg = DEBUG_TRANSVR_STR_VAL; - - if ((*buf) == update){ - return 0; - } - err = _common_setup_page(self, addr, page, offset, len, show_e); - if (err < 0){ - emsg = "setup EEPROM page fail"; - goto err_common_set_uint8_attr_1; - } - err = i2c_smbus_write_byte_data(self->i2c_client_p, - offset, - update); - if (err < 0){ - emsg = "I2C R/W fail!"; - goto err_common_set_uint8_attr_1; - } - (*buf) = update; - return 0; - -err_common_set_uint8_attr_1: - if (show_e) { - SWPS_INFO("%s: %s :%s :%d\n", - __func__, emsg, caller, err); - } - return ERR_TRANSVR_UPDATE_FAIL; -} - - -static int -_common_set_uint8_array(struct transvr_obj_s *self, - int addr, - int page, - int offs, - int len, - uint8_t update[], - uint8_t buf[], - char *caller, - int show_e){ - int i = 0; - int err = DEBUG_TRANSVR_INT_VAL; - char *emsg = DEBUG_TRANSVR_STR_VAL; - - err = _common_setup_page(self, addr, page, offs, len, show_e); - if (err < 0){ - emsg = "setup EEPROM page fail"; - goto err_common_set_uint8_attr_1; - } - for (i=0; ii2c_client_p, - (offs + i), - update[i]); - if (err < 0){ - emsg = "I2C R/W fail!"; - goto err_common_set_uint8_attr_1; - } - buf[i] = update[i]; - } - return 0; - -err_common_set_uint8_attr_1: - if (show_e) { - SWPS_INFO("%s: %s :%s :%d :%d\n", - __func__, emsg, caller, err, i); - } - return ERR_TRANSVR_UPDATE_FAIL; -} - - -static int -_common_update_attr_id(struct transvr_obj_s *self, - int show_err){ - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_id, - self->eeprom_map_p->page_id, - self->eeprom_map_p->offset_id, - self->eeprom_map_p->length_id, - &(self->id), - "_common_update_attr_id", - show_err); -} - -static int -_common_update_attr_extended_id(struct transvr_obj_s *self, - int show_err){ - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_ext_id, - self->eeprom_map_p->page_ext_id, - self->eeprom_map_p->offset_ext_id, - self->eeprom_map_p->length_ext_id, - &(self->ext_id), - "_common_update_attr_extended_id", - show_err); -} - - -static int -_common_update_attr_connector(struct transvr_obj_s *self, - int show_err){ - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_connector, - self->eeprom_map_p->page_connector, - self->eeprom_map_p->offset_connector, - self->eeprom_map_p->length_connector, - &(self->connector), - "_common_update_attr_connector", - show_err); -} - - -static int -_common_update_attr_transvr_comp(struct transvr_obj_s *self, - int show_err){ - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_trancomp, - self->eeprom_map_p->page_trancomp, - self->eeprom_map_p->offset_trancomp, - self->eeprom_map_p->length_trancomp, - self->transvr_comp, - "_common_update_attr_transvr_comp", - show_err); -} - - -static int -_common_update_attr_transvr_comp_ext(struct transvr_obj_s *self, - int show_err){ - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_trancomp_ext, - self->eeprom_map_p->page_trancomp_ext, - self->eeprom_map_p->offset_trancomp_ext, - self->eeprom_map_p->length_trancomp_ext, - &(self->transvr_comp_ext), - "_common_update_attr_transvr_comp_ext", - show_err); -} - -static int -_common_update_attr_eeprom(struct transvr_obj_s *self, - int show_err){ - return _common_update_string_attr(self, - self->eeprom_map_p->addr_eeprom, - self->eeprom_map_p->page_eeprom, - self->eeprom_map_p->offset_eeprom, - self->eeprom_map_p->length_eeprom, - self->eeprom, - "_common_update_attr_eeprom", - show_err); -} - -static int -_common_update_attr_vendor_name(struct transvr_obj_s *self, - int show_err){ - return _common_update_string_attr(self, - self->eeprom_map_p->addr_vendor_name, - self->eeprom_map_p->page_vendor_name, - self->eeprom_map_p->offset_vendor_name, - self->eeprom_map_p->length_vendor_name, - self->vendor_name, - "_common_update_attr_vendor_name", - show_err); -} - - -static int -_common_update_attr_vendor_pn(struct transvr_obj_s *self, - int show_err){ - return _common_update_string_attr(self, - self->eeprom_map_p->addr_vendor_pn, - self->eeprom_map_p->page_vendor_pn, - self->eeprom_map_p->offset_vendor_pn, - self->eeprom_map_p->length_vendor_pn, - self->vendor_pn, - "_common_update_attr_vendor_pn", - show_err); -} - - -static int -_common_update_attr_vendor_rev(struct transvr_obj_s *self, - int show_err){ - return _common_update_string_attr(self, - self->eeprom_map_p->addr_vendor_rev, - self->eeprom_map_p->page_vendor_rev, - self->eeprom_map_p->offset_vendor_rev, - self->eeprom_map_p->length_vendor_rev, - self->vendor_rev, - "_common_update_attr_vendor_rev", - show_err); -} - - -static int -_common_update_attr_vendor_sn(struct transvr_obj_s *self, - int show_err){ - return _common_update_string_attr(self, - self->eeprom_map_p->addr_vendor_sn, - self->eeprom_map_p->page_vendor_sn, - self->eeprom_map_p->offset_vendor_sn, - self->eeprom_map_p->length_vendor_sn, - self->vendor_sn, - "_common_update_attr_vendor_sn", - show_err); -} - - -static int -_common_update_attr_br(struct transvr_obj_s *self, - int show_err){ - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_br, - self->eeprom_map_p->page_br, - self->eeprom_map_p->offset_br, - self->eeprom_map_p->length_br, - &(self->br), - "_common_update_attr_br", - show_err); -} - - -static int -_common_update_attr_len_smf(struct transvr_obj_s *self, - int show_err){ - return _common_update_int_attr(self, - self->eeprom_map_p->addr_len_smf, - self->eeprom_map_p->page_len_smf, - self->eeprom_map_p->offset_len_smf, - self->eeprom_map_p->length_len_smf, - &(self->len_smf), - "_common_update_attr_len_smf", - show_err); -} - - -static int -_common_update_attr_len_om1(struct transvr_obj_s *self, - int show_err){ - return _common_update_int_attr(self, - self->eeprom_map_p->addr_len_om1, - self->eeprom_map_p->page_len_om1, - self->eeprom_map_p->offset_len_om1, - self->eeprom_map_p->length_len_om1, - &(self->len_om1), - "_common_update_attr_len_om1", - show_err); -} - -static int -_common_update_attr_len_om2(struct transvr_obj_s *self, - int show_err){ - return _common_update_int_attr(self, - self->eeprom_map_p->addr_len_om2, - self->eeprom_map_p->page_len_om2, - self->eeprom_map_p->offset_len_om2, - self->eeprom_map_p->length_len_om2, - &(self->len_om2), - "_common_update_attr_len_om2", - show_err); -} - -static int -_common_update_attr_len_om3(struct transvr_obj_s *self, - int show_err){ - return _common_update_int_attr(self, - self->eeprom_map_p->addr_len_om3, - self->eeprom_map_p->page_len_om3, - self->eeprom_map_p->offset_len_om3, - self->eeprom_map_p->length_len_om3, - &(self->len_om3), - "_common_update_attr_len_om3", - show_err); -} - - -static int -_common_update_attr_len_om4(struct transvr_obj_s *self, - int show_err){ - return _common_update_int_attr(self, - self->eeprom_map_p->addr_len_om4, - self->eeprom_map_p->page_len_om4, - self->eeprom_map_p->offset_len_om4, - self->eeprom_map_p->length_len_om4, - &(self->len_om4), - "_common_update_attr_len_om4", - show_err); -} - - -static int -_common_update_attr_option(struct transvr_obj_s *self, - int show_err){ - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_option, - self->eeprom_map_p->page_option, - self->eeprom_map_p->offset_option, - self->eeprom_map_p->length_option, - self->option, - "_common_update_attr_option", - show_err); -} - - -static int -_common_update_attr_comp_rev(struct transvr_obj_s *self, - int show_err){ - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_comp_rev, - self->eeprom_map_p->page_comp_rev, - self->eeprom_map_p->offset_comp_rev, - self->eeprom_map_p->length_comp_rev, - &(self->comp_rev), - "_common_update_attr_comp_rev", - show_err); -} - - -static int -_common_update_attr_diag_type(struct transvr_obj_s *self, - int show_err){ - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_diag_type, - self->eeprom_map_p->page_diag_type, - self->eeprom_map_p->offset_diag_type, - self->eeprom_map_p->length_diag_type, - &(self->diag_type), - "_common_update_attr_diag_type", - show_err); -} - - -static int -_common_update_attr_wavelength(struct transvr_obj_s *self, - int show_err){ - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_wavelength, - self->eeprom_map_p->page_wavelength, - self->eeprom_map_p->offset_wavelength, - self->eeprom_map_p->length_wavelength, - self->wavelength, - "_common_update_attr_wavelength", - show_err); -} - - -int -_common_get_option_value(struct transvr_obj_s *self, - int offset, - int bit_shift) { - /* SFP: - * - option[0] = A0h / 64 - * - option[1] = A0h / 65 - * QSFP: - * - option[0] = 00h / 193 - * - option[1] = 00h / 194 - * - option[2] = 00h / 195 - */ - return (self->option[offset] & (1 << bit_shift)); -} - - -static int -_sfp_update_attr_len_sm(struct transvr_obj_s *self, - int show_err){ - return _common_update_int_attr(self, - self->eeprom_map_p->addr_len_sm, - self->eeprom_map_p->page_len_sm, - self->eeprom_map_p->offset_len_sm, - self->eeprom_map_p->length_len_sm, - &(self->len_sm), - "_common_update_attr_len_sm", - show_err); -} - - -static int -_sfp_update_attr_rate_id(struct transvr_obj_s *self, - int show_err){ - return _common_update_int_attr(self, - self->eeprom_map_p->addr_rate_id, - self->eeprom_map_p->page_rate_id, - self->eeprom_map_p->offset_rate_id, - self->eeprom_map_p->length_rate_id, - &(self->rate_id), - "_sfp_update_attr_rate_id", - show_err); -} - - -static int -_sfp_update_attr_soft_rs0(struct transvr_obj_s *self, - int show_err){ - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_soft_rs0, - self->eeprom_map_p->page_soft_rs0, - self->eeprom_map_p->offset_soft_rs0, - self->eeprom_map_p->length_soft_rs0, - &(self->soft_rs0), - "_sfp_update_attr_soft_rs0", - show_err); -} - - -static int -_sfp_update_attr_soft_rs1(struct transvr_obj_s *self, - int show_err){ - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_soft_rs1, - self->eeprom_map_p->page_soft_rs1, - self->eeprom_map_p->offset_soft_rs1, - self->eeprom_map_p->length_soft_rs1, - &(self->soft_rs1), - "_sfp_update_attr_soft_rs1", - show_err); -} - - -int -_sfp_is_diag_support(struct transvr_obj_s *self){ - - uint8_t bit_mask = 0xC0; /* 1100 0000 */ - uint8_t en_val = 0x40; /* 0100 0000 */ - uint8_t checkval = (self->diag_type & bit_mask); - - if (checkval == en_val) { - return 1; - } - return 0; -} - - -static int -_sfp_update_attr_curr_temp(struct transvr_obj_s *self, - int show_err){ - - if (!(_sfp_is_diag_support(self))) { - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_temp, - self->eeprom_map_p->page_temp, - self->eeprom_map_p->offset_temp, - self->eeprom_map_p->length_temp, - self->curr_temp, - "_sfp_update_attr_curr_temp", - show_err); -} - - -static int -_sfp_update_attr_curr_voltage(struct transvr_obj_s *self, - int show_err){ - - if (!(_sfp_is_diag_support(self))) { - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_voltage, - self->eeprom_map_p->page_voltage, - self->eeprom_map_p->offset_voltage, - self->eeprom_map_p->length_voltage, - self->curr_voltage, - "_sfp_update_attr_curr_voltage", - show_err); -} - - -static int -_sfp_update_attr_curr_tx_bias(struct transvr_obj_s *self, - int show_err){ - - if (!(_sfp_is_diag_support(self))) { - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_tx_bias, - self->eeprom_map_p->page_tx_bias, - self->eeprom_map_p->offset_tx_bias, - self->eeprom_map_p->length_tx_bias, - self->curr_tx_bias, - "_sfp_update_attr_curr_tx_bias", - show_err); -} - - -static int -_sfp_update_attr_curr_tx_power(struct transvr_obj_s *self, - int show_err){ - - if (!(_sfp_is_diag_support(self))) { - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_tx_power, - self->eeprom_map_p->page_tx_power, - self->eeprom_map_p->offset_tx_power, - self->eeprom_map_p->length_tx_power, - self->curr_tx_power, - "_sfp_update_attr_curr_tx_power", - show_err); -} - - -static int -_sfp_update_attr_curr_rx_power(struct transvr_obj_s *self, - int show_err){ - - if (!(_sfp_is_diag_support(self))) { - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_rx_power, - self->eeprom_map_p->page_rx_power, - self->eeprom_map_p->offset_rx_power, - self->eeprom_map_p->length_rx_power, - self->curr_rx_power, - "_sfp_update_attr_curr_rx_power", - show_err); -} - - -static int -_sfp_update_attr_rx_em(struct transvr_obj_s *self, - int show_err){ - - if (!_is_transvr_support_ctle(self)) { - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_rx_em, - self->eeprom_map_p->page_rx_em, - self->eeprom_map_p->offset_rx_em, - self->eeprom_map_p->length_rx_em, - self->rx_em, - "_sfp_update_attr_rx_em", - show_err); -} - - -static int -_sfp_update_attr_tx_eq(struct transvr_obj_s *self, - int show_err){ - - if (!_is_transvr_support_ctle(self)) { - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_tx_eq, - self->eeprom_map_p->page_tx_eq, - self->eeprom_map_p->offset_tx_eq, - self->eeprom_map_p->length_tx_eq, - self->tx_eq, - "_sfp_update_attr_tx_eq", - show_err); -} - - -static int -_qsfp_update_attr_cdr(struct transvr_obj_s *self, - int show_err){ - if (self->type != TRANSVR_TYPE_QSFP_28){ - self->cdr = DEBUG_TRANSVR_HEX_VAL; - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_cdr, - self->eeprom_map_p->page_cdr, - self->eeprom_map_p->offset_cdr, - self->eeprom_map_p->length_cdr, - &(self->cdr), - "_common_update_attr_cdr", - show_err); -} - - -static int -_qsfg_update_attr_extbr(struct transvr_obj_s *self, - int show_err) { - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_extbr, - self->eeprom_map_p->page_extbr, - self->eeprom_map_p->offset_extbr, - self->eeprom_map_p->length_extbr, - &(self->extbr), - "_common_update_attr_extbr", - show_err); -} - - -static int -_qsfp_is_diag_support(struct transvr_obj_s *self, - int diag_type) { - /* Input Parm: diag_type - * => 1 : temperature - * => 2 : voltage - * => 3 : tx relate - * => 4 : rx relate - */ - uint8_t mask_b2 = 0x04; /* 0000 0100 */ - uint8_t mask_b3 = 0x08; /* 0000 1000 */ - - switch (diag_type) { - case 1: /* temperature */ - case 2: /* voltage */ - /* Direct access target, because of spec not defined */ - return 1; - case 3: - case 4: - /* [Note] - * Due to lot of transceiver vendor defined it not rigorously and - * consider of general support, we seem it as supported if there - * are bit-2 OR bit-3 defined by transceiver vendor. - */ - if ( ((self->diag_type & mask_b2) == mask_b2 ) || - ((self->diag_type & mask_b3) == mask_b3 ) ){ - return 1; - } - return 0; - default: - SWPS_INFO("%s: undefined diag_type:%d\n", - __func__, diag_type); - break; - } - return 0; -} - - -int -_qsfp_is_implement_tx_disable(struct transvr_obj_s *self) { - /* - * 00h / Byte-195 / Bit-4 - */ - int byte = 2; - int bit = 4; - return _common_get_option_value(self, byte, bit); -} - - -int -_qsfp_is_implement_tx_fault(struct transvr_obj_s *self) { - /* - * 00h / Byte-195 / Bit-3 - */ - int byte = 2; - int bit = 3; - return _common_get_option_value(self, byte, bit); -} - - -static int -_qsfp_update_attr_curr_temp(struct transvr_obj_s *self, - int show_err){ - int diag_type = 1; - - if (!(_qsfp_is_diag_support(self, diag_type))) { - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_temp, - self->eeprom_map_p->page_temp, - self->eeprom_map_p->offset_temp, - self->eeprom_map_p->length_temp, - self->curr_temp, - "_qsfp_update_attr_curr_temp", - show_err); -} - - -static int -_qsfp_update_attr_curr_voltage(struct transvr_obj_s *self, - int show_err){ - int diag_type = 2; - - if (!(_qsfp_is_diag_support(self, diag_type))) { - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_voltage, - self->eeprom_map_p->page_voltage, - self->eeprom_map_p->offset_voltage, - self->eeprom_map_p->length_voltage, - self->curr_voltage, - "_qsfp_update_attr_curr_voltage", - show_err); -} - - -static int -_qsfp_update_attr_curr_tx_bias(struct transvr_obj_s *self, - int show_err){ - int diag_type = 3; - - if (!(_qsfp_is_diag_support(self, diag_type))) { - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_tx_bias, - self->eeprom_map_p->page_tx_bias, - self->eeprom_map_p->offset_tx_bias, - self->eeprom_map_p->length_tx_bias, - self->curr_tx_bias, - "_qsfp_update_attr_curr_tx_bias", - show_err); -} - - -static int -_qsfp_update_attr_curr_tx_power(struct transvr_obj_s *self, - int show_err){ - int diag_type = 3; - - if (!(_qsfp_is_diag_support(self, diag_type))) { - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_tx_power, - self->eeprom_map_p->page_tx_power, - self->eeprom_map_p->offset_tx_power, - self->eeprom_map_p->length_tx_power, - self->curr_tx_power, - "_qsfp_update_attr_curr_tx_power", - show_err); -} - - -static int -_qsfp_update_attr_curr_rx_power(struct transvr_obj_s *self, - int show_err){ - int diag_type = 4; - - if (!(_qsfp_is_diag_support(self, diag_type))) { - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_rx_power, - self->eeprom_map_p->page_rx_power, - self->eeprom_map_p->offset_rx_power, - self->eeprom_map_p->length_rx_power, - self->curr_rx_power, - "_qsfp_update_attr_curr_rx_power", - show_err); -} - - -static int -_qsfp_update_attr_soft_rx_los(struct transvr_obj_s *self, - int show_err){ - - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_rx_los, - self->eeprom_map_p->page_rx_los, - self->eeprom_map_p->offset_rx_los, - self->eeprom_map_p->length_rx_los, - &(self->rx_los), - "_qsfp_update_attr_soft_rx_los", - show_err); -} - - -static int -_qsfp_update_attr_soft_tx_disable(struct transvr_obj_s *self, - int show_err){ - - if (!_qsfp_is_implement_tx_disable(self)) { - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_tx_disable, - self->eeprom_map_p->page_tx_disable, - self->eeprom_map_p->offset_tx_disable, - self->eeprom_map_p->length_tx_disable, - &(self->tx_disable), - "_qsfp_update_attr_soft_tx_disable", - show_err); -} - - -static int -_qsfp_update_attr_soft_tx_fault(struct transvr_obj_s *self, - int show_err){ - - if (!_qsfp_is_implement_tx_fault(self)) { - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_tx_fault, - self->eeprom_map_p->page_tx_fault, - self->eeprom_map_p->offset_tx_fault, - self->eeprom_map_p->length_tx_fault, - &(self->tx_fault), - "_qsfp_update_attr_soft_tx_fault", - show_err); -} - - -static int -_qsfp_update_attr_tx_eq(struct transvr_obj_s *self, - int show_err){ - - if (!_is_transvr_support_ctle(self)) { - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_tx_eq, - self->eeprom_map_p->page_tx_eq, - self->eeprom_map_p->offset_tx_eq, - self->eeprom_map_p->length_tx_eq, - self->tx_eq, - "_qsfp_update_attr_tx_eq", - show_err); -} - - -static int -_qsfp_update_attr_rx_am(struct transvr_obj_s *self, - int show_err){ - - if (!_is_transvr_support_ctle(self)) { - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_rx_am, - self->eeprom_map_p->page_rx_am, - self->eeprom_map_p->offset_rx_am, - self->eeprom_map_p->length_rx_am, - self->rx_am, - "_qsfp_update_attr_rx_am", - show_err); -} - - -static int -_qsfp_update_attr_rx_em(struct transvr_obj_s *self, - int show_err){ - - if (!_is_transvr_support_ctle(self)) { - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_rx_em, - self->eeprom_map_p->page_rx_em, - self->eeprom_map_p->offset_rx_em, - self->eeprom_map_p->length_rx_em, - self->rx_em, - "_qsfp_update_attr_rx_em", - show_err); -} - - -int -_common_update_attr_all(struct transvr_obj_s *self, - int show_err){ - - char *err_str = "err"; - - if (_common_update_attr_id(self, show_err) < 0) { - err_str = "_common_update_attr_id"; - goto err_common_update_attr_all; - } - if (_common_update_attr_eeprom(self, show_err) < 0) { - err_str = "_common_update_attr_eeprom"; - goto err_common_update_attr_all; - } - if (_common_update_attr_extended_id(self, show_err) < 0) { - err_str = "_common_update_attr_extended_id"; - goto err_common_update_attr_all; - } - if (_common_update_attr_connector(self, show_err) < 0) { - err_str = "_common_update_attr_connector"; - goto err_common_update_attr_all; - } - if (_common_update_attr_transvr_comp(self, show_err) < 0) { - err_str = "_common_update_attr_transvr_comp"; - goto err_common_update_attr_all; - } - if (_common_update_attr_transvr_comp_ext(self, show_err) < 0) { - err_str = "_common_update_attr_transvr_comp_ext"; - goto err_common_update_attr_all; - } - if (_common_update_attr_vendor_name(self, show_err) < 0) { - err_str = "_common_update_attr_vendor_name"; - goto err_common_update_attr_all; - } - if (_common_update_attr_vendor_pn(self, show_err) < 0) { - err_str = "_common_update_attr_vendor_pn"; - goto err_common_update_attr_all; - } - if (_common_update_attr_vendor_rev(self, show_err) < 0) { - err_str = "_common_update_attr_vendor_rev"; - goto err_common_update_attr_all; - } - if (_common_update_attr_vendor_sn(self, show_err) < 0) { - err_str = "_common_update_attr_vendor_sn"; - goto err_common_update_attr_all; - } - if (_common_update_attr_br(self, show_err) < 0) { - err_str = "_common_update_attr_br"; - goto err_common_update_attr_all; - } - if (_common_update_attr_len_smf(self, show_err) < 0) { - err_str = "_common_update_attr_len_smf"; - goto err_common_update_attr_all; - } - if (_common_update_attr_len_om1(self, show_err) < 0) { - err_str = "_common_update_attr_len_om1"; - goto err_common_update_attr_all; - } - if (_common_update_attr_len_om2(self, show_err) < 0) { - err_str = "_common_update_attr_len_om2"; - goto err_common_update_attr_all; - } - if (_common_update_attr_len_om3(self, show_err) < 0) { - err_str = "_common_update_attr_len_om3"; - goto err_common_update_attr_all; - } - if (_common_update_attr_len_om4(self, show_err) < 0) { - err_str = "_common_update_attr_len_om4"; - goto err_common_update_attr_all; - } - if (_common_update_attr_option(self, show_err) < 0) { - err_str = "_common_update_attr_option"; - goto err_common_update_attr_all; - } - if (_common_update_attr_comp_rev(self, show_err) < 0) { - err_str = "_common_update_attr_comp_rev"; - goto err_common_update_attr_all; - } - if (_common_update_attr_diag_type(self, show_err) < 0) { - err_str = "_common_update_attr_diag_type"; - goto err_common_update_attr_all; - } - if (_common_update_attr_wavelength(self, show_err) < 0) { - err_str = "_common_update_attr_wavelength"; - goto err_common_update_attr_all; - } - return 0; - -err_common_update_attr_all: - if (show_err){ - SWPS_INFO("%s: fail at:%s :%s\n", __func__, err_str, self->swp_name); - } - return -1; -} - - -int -_sfp_update_attr_all(struct transvr_obj_s *self, - int show_err){ - - char *err_str = DEBUG_TRANSVR_STR_VAL; - - if (_common_update_attr_all(self, show_err) < 0){ - err_str = "_common_update_attr_all"; - goto err_sfp_update_attr_all; - } - if (_sfp_update_attr_len_sm(self, show_err) < 0) { - err_str = "_sfp_update_attr_len_sm"; - goto err_sfp_update_attr_all; - } - if (_sfp_update_attr_rate_id(self, show_err) < 0) { - err_str = "_sfp_update_attr_rate_id"; - goto err_sfp_update_attr_all; - } - if ((self->rate_id) > 0) { - if (_sfp_update_attr_soft_rs0(self, show_err) < 0) { - err_str = "_sfp_update_attr_soft_rs0"; - goto err_sfp_update_attr_all; - } - if (_sfp_update_attr_soft_rs1(self, show_err) < 0) { - err_str = "_sfp_update_attr_soft_rs1"; - goto err_sfp_update_attr_all; - } - } - return 0; - -err_sfp_update_attr_all: - if (show_err){ - SWPS_INFO("%s: fail at:%s :%s\n", __func__, err_str, self->swp_name); - } - return -1; -} - - -int -_qsfp_update_attr_all(struct transvr_obj_s *self, - int show_err){ - - char *err_str = DEBUG_TRANSVR_STR_VAL; - - if (_common_update_attr_all(self, show_err) < 0){ - err_str = "_common_update_attr_all"; - goto err_qsfp_update_attr_all; - } - if (_qsfg_update_attr_extbr(self, show_err) < 0) { - err_str = "_qsfg_update_attr_extbr"; - goto err_qsfp_update_attr_all; - } - if (self->type == TRANSVR_TYPE_QSFP_28) { - if (_qsfp_update_attr_cdr(self, 1) < 0) { - err_str = "_qsfp_update_attr_cdr"; - goto err_qsfp_update_attr_all; - } - } - return 0; - -err_qsfp_update_attr_all: - if (show_err){ - SWPS_INFO("%s: fail at:%s :%s\n", __func__, err_str, self->swp_name); - } - return -1; -} - - -/* ========== Object functions for common type ========== - */ -int -_common_count_temp(uint8_t high_byte, - uint8_t low_byte, - char *buf_p) { - int sign = 0; - int high = 0; - int low = 0; - int lmax = 8; - - /* Count high */ - sign = get_bit(high_byte,7); - SWP_BIT_CLEAR(high_byte, 7); - high = (int)high_byte; - if (sign == 1) { - high = 0 - high; - } - /* Count low */ - low = (get_bit(low_byte, 7) * 500); - low += (get_bit(low_byte, 6) * 250); - low += (get_bit(low_byte, 5) * 125); - low += (get_bit(low_byte, 4) * 62); - low = (low / 100); - /* Integrate High and Low */ - return snprintf(buf_p, lmax, "%d.%d\n", high, low); -} - - -int -_common_count_voltage(uint8_t high_byte, - uint8_t low_byte, - char *buf_p) { - /* [Note]: - * Internally measured transceiver supply voltage. Represented - * as a 16 bit unsigned integer with the voltage defined as the - * full 16 bit value (0-65535) with LSB equal to 100 uVolt, - * yielding a total range of 0 to +6.55 Volts. Practical - * considerations to be defined by transceiver manufacturer will - * tend to limit the actual bounds of the supply voltage measurement. - * Accuracy is vendor specific but must be better than 3% of the - * manufacturer's nominal value over specified operating temperature - * and voltage. Note that in some transceivers, transmitter supply - * voltage and receiver supply voltage are isolated. In that case, - * only one supply is monitored. Refer to the device specification - * for more detail. - */ - int total = 0; - int lmax = 8; - int val_i = 0; - int val_f = 0; - /* unit: 100 uV (1mV=1000uV) */ - total = transform_word_to_int(high_byte, low_byte); - val_i = ((total/10) / 1000); - val_f = ((total/10) - (val_i*1000)); - /* Return Unit: 1 Volt */ - return snprintf(buf_p, lmax, "%d.%03d\n", val_i, val_f); -} - - -int -_common_count_tx_bias(uint8_t high_byte, - uint8_t low_byte, - char *buf_p) { - /* [Note] - * Measured TX bias current in uA. Represented as a 16 bit unsigned - * integer with the current defined as the full 16 bit value (0-65535) - * with LSB equal to 2 uA, yielding a total range of 0 to 131 mA. - * Accuracy is vendor specific but must be better than 10% of the - * manufacturer's nominal value over specified operating temperature - * and voltage. - */ - int total = 0; - int lmax = 8; - int val_i = 0; - int val_f = 0; - /* unit: 2 uA (1mA=1000uA) */ - total = transform_word_to_int(high_byte, low_byte); - val_i = ((total*2) / 1000); - val_f = (((total*2) - (val_i*1000)) / 100); - /* Return Unit: 1 mA */ - return snprintf(buf_p, lmax, "%d.%01d\n", val_i, val_f); -} - - -int -_common_count_tx_power(uint8_t high_byte, - uint8_t low_byte, - char *buf_p) { - /* [Note] - * Measured TX output power in mW. Represented as a 16 bit unsigned - * integer with the power defined as the full 16 bit value (0-65535) - * with LSB equal to 0.1 uW, yielding a total range of 0 to 6.5535 mW - * (~ -40 to +8.2 dBm). Data is assumed to be based on measurement of - * laser monitor photodiode current. It is factory calibrated to absolute - * units using the most representative fiber output type. Accuracy is - * vendor specific but must be better than 3dB over specified temperature - * and voltage. Data is not valid when the transmitter is disabled. - */ - int total = 0; - int lmax = 8; - int val_i = 0; - int val_f = 0; - /* unit: 0.1 uW (1mW=1000uW) */ - total = transform_word_to_int(high_byte, low_byte); - val_i = ((total/10) / 1000); - val_f = ((total/10) - (val_i*1000)); - /* Return Unit: 1 mW */ - return snprintf(buf_p, lmax, "%d.%03d\n", val_i, val_f); -} - - -int -_common_count_rx_power(uint8_t high_byte, - uint8_t low_byte, - char *buf_p) { - /* [Note] - * Measured RX received optical power in mW. Value can represent either - * average received power or OMA depending upon how bit 3 of byte 92 (A0h) - * is set. Represented as a 16 bit unsigned integer with the power defined - * as the full 16 bit value (0-65535) with LSB equal to 0.1 uW, yielding a - * total range of 0 to 6.5535 mW (~ -40 to +8.2 dBm). Absolute accuracy is - * dependent upon the exact optical wavelength. For the vendor specified - * wavelength, accuracy shall be better than 3dB over specified temperature - * and voltage. - */ - int total = 0; - int lmax = 8; - int val_i = 0; - int val_f = 0; - /* unit: 0.1 uW (1mW=1000uW) */ - total = transform_word_to_int(high_byte, low_byte); - val_i = ((total/10) / 1000); - val_f = ((total/10) - (val_i*1000)); - /* Return Unit: 1 mW */ - return snprintf(buf_p, lmax, "%d.%03d\n", val_i, val_f); -} - - -int -_common_count_wavelength(struct transvr_obj_s *self, - uint8_t high_byte, - uint8_t low_byte) { - /* [Note] - * SFP : uint 1 um. - * QSFP: unit 0.05 um. - */ - int total = 0; - - total = transform_word_to_int(high_byte, low_byte); - switch (self->type) { - case TRANSVR_TYPE_SFP: - return total; - - case TRANSVR_TYPE_QSFP: - case TRANSVR_TYPE_QSFP_PLUS: - case TRANSVR_TYPE_QSFP_28: - return (total/20); - - default: - break; - } - return ERR_TRANSVR_UNDEFINED; -} - - -int -common_get_id(struct transvr_obj_s *self){ - - int err_code = _check_by_mode(self, - &_common_update_attr_id, - "common_get_id"); - if (err_code < 0){ - return err_code; - } - /* Transform to INT to show error case */ - return (int)self->id; -} - - -int -common_get_ext_id(struct transvr_obj_s *self){ - - int err_code = _check_by_mode(self, - &_common_update_attr_extended_id, - "common_get_ext_id"); - if (err_code < 0){ - return err_code; - } - /* Transform to INT to show error case */ - return (int)self->ext_id; -} - - -int -common_get_connector(struct transvr_obj_s *self){ - - int err_code = _check_by_mode(self, - &_common_update_attr_connector, - "common_get_connector"); - if (err_code < 0){ - return err_code; - } - /* Transform to INT to show error case */ - return (int)self->connector; -} - -int -common_get_eeprom(struct transvr_obj_s *self, char *buf){ - - int err = DEBUG_TRANSVR_INT_VAL; - unsigned int eeprom_update = get_eeprom_update(); - - if (!(eeprom_update & (1 << self->port_no)) && - (self->state == STATE_TRANSVR_CONNECTED && - self->mode == TRANSVR_MODE_POLLING && - TRANSVR_INFO_CACHE_ENABLE)) { - memset(buf, 0, self->eeprom_map_p->length_eeprom); - memcpy(buf, self->eeprom, self->eeprom_map_p->length_eeprom); - *(buf+self->eeprom_map_p->length_eeprom) = '\n'; - return self->eeprom_map_p->length_eeprom; - } - err = _check_by_mode(self, &_common_update_attr_eeprom, - "common_get_eeprom"); - if (err < 0){ - return snprintf(buf, LEN_TRANSVR_M_STR, "%d\n", err); - } - memset(buf, 0, self->eeprom_map_p->length_eeprom); - memcpy(buf, self->eeprom, self->eeprom_map_p->length_eeprom); - *(buf+self->eeprom_map_p->length_eeprom) = '\n'; - eeprom_update &= ~(1 << self->port_no); - set_eeprom_update(eeprom_update); - return self->eeprom_map_p->length_eeprom; -} - -int -common_get_vendor_name(struct transvr_obj_s *self, char *buf){ - - int err = DEBUG_TRANSVR_INT_VAL; - - if (self->state == STATE_TRANSVR_CONNECTED && - self->mode == TRANSVR_MODE_POLLING && - TRANSVR_INFO_CACHE_ENABLE) { - return snprintf(buf, LEN_TRANSVR_M_STR, "%s\n", self->vendor_name); - } - err = _check_by_mode(self, - &_common_update_attr_vendor_name, - "common_get_vendor_name"); - memset(buf, 0, LEN_TRANSVR_M_STR); - if (err < 0){ - return snprintf(buf, LEN_TRANSVR_M_STR, "%d\n", err); - } - return snprintf(buf, LEN_TRANSVR_M_STR, "%s\n", self->vendor_name); -} - - -int -common_get_vendor_pn(struct transvr_obj_s *self, char *buf) { - - int err = DEBUG_TRANSVR_INT_VAL; - - if (self->state == STATE_TRANSVR_CONNECTED && - self->mode == TRANSVR_MODE_POLLING && - TRANSVR_INFO_CACHE_ENABLE) { - return snprintf(buf, LEN_TRANSVR_M_STR, "%s\n", self->vendor_pn); - } - err = _check_by_mode(self, - &_common_update_attr_vendor_pn, - "common_get_vendor_pn"); - memset(buf, 0, LEN_TRANSVR_M_STR); - if (err < 0){ - return snprintf(buf, LEN_TRANSVR_M_STR, "%d\n", err); - } - return snprintf(buf, LEN_TRANSVR_M_STR, "%s\n", self->vendor_pn); -} - - -int -common_get_vendor_rev(struct transvr_obj_s *self, char *buf) { - - int err = DEBUG_TRANSVR_INT_VAL; - - if (self->state == STATE_TRANSVR_CONNECTED && - self->mode == TRANSVR_MODE_POLLING && - TRANSVR_INFO_CACHE_ENABLE) { - return snprintf(buf, LEN_TRANSVR_M_STR, "%s\n", self->vendor_rev); - } - err = _check_by_mode(self, - &_common_update_attr_vendor_rev, - "common_get_vendor_rev"); - memset(buf, 0, LEN_TRANSVR_M_STR); - if (err < 0){ - return snprintf(buf, LEN_TRANSVR_M_STR, "%d\n", err); - } - return snprintf(buf, LEN_TRANSVR_M_STR, "%s\n", self->vendor_rev); -} - - -int -common_get_vendor_sn(struct transvr_obj_s *self, char *buf) { - - int err = DEBUG_TRANSVR_INT_VAL; - - if (self->state == STATE_TRANSVR_CONNECTED && - self->mode == TRANSVR_MODE_POLLING && - TRANSVR_INFO_CACHE_ENABLE) { - return snprintf(buf, LEN_TRANSVR_M_STR, "%s\n", self->vendor_sn); - } - err = _check_by_mode(self, - &_common_update_attr_vendor_sn, - "common_get_vendor_sn"); - memset(buf, 0, LEN_TRANSVR_M_STR); - if (err < 0){ - return snprintf(buf, LEN_TRANSVR_M_STR, "%d\n", err); - } - return snprintf(buf, LEN_TRANSVR_M_STR, "%s\n", self->vendor_sn); -} - - -int -common_get_br(struct transvr_obj_s *self){ - - int err = DEBUG_TRANSVR_INT_VAL; - - if (self->state == STATE_TRANSVR_CONNECTED && - self->mode == TRANSVR_MODE_POLLING && - TRANSVR_INFO_CACHE_ENABLE) { - return (int)self->br; - } - err = _check_by_mode(self, - &_common_update_attr_br, - "common_get_br"); - if (err < 0){ - return err; - } - /* Transform to INT to show error case */ - return (int)self->br; -} - - -int -common_get_len_smf(struct transvr_obj_s *self){ - - int err = DEBUG_TRANSVR_INT_VAL; - - if (self->state == STATE_TRANSVR_CONNECTED && - self->mode == TRANSVR_MODE_POLLING && - TRANSVR_INFO_CACHE_ENABLE) { - return self->len_smf; - } - err = _check_by_mode(self, - &_common_update_attr_len_smf, - "common_get_len_smf"); - if (err < 0){ - return err; - } - return self->len_smf; -} - - -int -common_get_len_om1(struct transvr_obj_s *self){ - - int err = DEBUG_TRANSVR_INT_VAL; - - if (self->state == STATE_TRANSVR_CONNECTED && - self->mode == TRANSVR_MODE_POLLING && - TRANSVR_INFO_CACHE_ENABLE) { - return self->len_om1; - } - err = _check_by_mode(self, - &_common_update_attr_len_om1, - "common_get_len_om1"); - if (err < 0){ - return err; - } - return self->len_om1; -} - - -int -common_get_len_om2(struct transvr_obj_s *self){ - - int err = DEBUG_TRANSVR_INT_VAL; - - if (self->state == STATE_TRANSVR_CONNECTED && - self->mode == TRANSVR_MODE_POLLING && - TRANSVR_INFO_CACHE_ENABLE) { - return self->len_om2; - } - - err = _check_by_mode(self, - &_common_update_attr_len_om2, - "common_get_len_om2"); - if (err < 0){ - return err; - } - return self->len_om2; -} - - -int -common_get_len_om3(struct transvr_obj_s *self){ - - int err = DEBUG_TRANSVR_INT_VAL; - - if (self->state == STATE_TRANSVR_CONNECTED && - self->mode == TRANSVR_MODE_POLLING && - TRANSVR_INFO_CACHE_ENABLE) { - return self->len_om3; - } - - err = _check_by_mode(self, - &_common_update_attr_len_om3, - "common_get_len_om3"); - if (err < 0){ - return err; - } - return self->len_om3; -} - - -int -common_get_len_om4(struct transvr_obj_s *self){ - - int err = DEBUG_TRANSVR_INT_VAL; - - if (self->state == STATE_TRANSVR_CONNECTED && - self->mode == TRANSVR_MODE_POLLING && - TRANSVR_INFO_CACHE_ENABLE) { - return self->len_om4; - } - err = _check_by_mode(self, - &_common_update_attr_len_om4, - "common_get_len_om4"); - if (err < 0){ - return err; - } - return self->len_om4; -} - - -int -common_get_comp_extended(struct transvr_obj_s *self){ - - int err_code = _check_by_mode(self, - &_common_update_attr_transvr_comp_ext, - "common_get_comp_extended"); - if (err_code < 0){ - return err_code; - } - return self->transvr_comp_ext; -} - - -int -common_get_comp_rev(struct transvr_obj_s *self){ - - int err_code = _check_by_mode(self, - &_common_update_attr_comp_rev, - "common_get_comp_rev"); - if (err_code < 0){ - return err_code; - } - return self->comp_rev; -} - - -int -common_get_info(struct transvr_obj_s *self){ - - if (self->state != STATE_TRANSVR_CONNECTED) { - return self->state; - } - return self->info; -} - - -int -_common_get_if_lane(struct transvr_obj_s *self, - char *result){ - int i = 0; - int tmp_val = 0; - char tmp_str[LEN_TRANSVR_M_STR] = DEBUG_TRANSVR_STR_VAL; - - memset(result, 0, LEN_TRANSVR_M_STR); - - for (i=0; ilane_id); i++) { - tmp_val = self->lane_id[i]; - if (tmp_val < 1) { - break; - } - memset(tmp_str, 0, LEN_TRANSVR_M_STR); - if (i == 0) { - snprintf(tmp_str, LEN_TRANSVR_M_STR, "%d", tmp_val); - } else { - snprintf(tmp_str, LEN_TRANSVR_M_STR, ",%d", tmp_val); - } - strncat(result, tmp_str, LEN_TRANSVR_M_STR); - } - if (i == 0) { - return EVENT_TRANSVR_TASK_FAIL; - } - return 0; -} - - -int -common_get_if_lane(struct transvr_obj_s *self, - char *buf_p){ - - char tmp_str[LEN_TRANSVR_M_STR] = DEBUG_TRANSVR_STR_VAL; - - if (self->ioexp_obj_p->state != STATE_IOEXP_NORMAL) { - return snprintf(buf_p, LEN_TRANSVR_M_STR, "%d\n", ERR_TRANSVR_ABNORMAL); - } - if (_common_get_if_lane(self, tmp_str) < 0) { - return snprintf(buf_p, LEN_TRANSVR_M_STR, "%d\n" ,ERR_TRANSVR_ABNORMAL); - } - return snprintf(buf_p, LEN_TRANSVR_M_STR, "%s\n" ,tmp_str); -} - - -int -sfp_get_len_sm(struct transvr_obj_s *self){ - - int err_code = _check_by_mode(self, - &_sfp_update_attr_len_sm, - "sfp_get_len_sm"); - if (err_code < 0){ - return err_code; - } - return self->len_sm; -} - - -int -sfp_get_rate_id(struct transvr_obj_s *self){ - - int err_code = _check_by_mode(self, - &_sfp_update_attr_rate_id, - "sfp_get_rate_id"); - if (err_code < 0){ - return err_code; - } - return self->rate_id; -} - - -int -sfp_get_soft_rs0(struct transvr_obj_s *self){ - /* Note: - * SFP Soft Rate_Select Select [aka. "RS(0)"] address - * A2h, offset: 110, bit 3 (begin form 0) - */ - int err_code = DEBUG_TRANSVR_INT_VAL; - int bit_shift = 3; - uint8_t result = 0x00; - uint8_t bitmask = (1 << bit_shift); - - /* Check rate identifier is supported */ - err_code = self->get_rate_id(self); - if (err_code <= 0) { - return ERR_TRANSVR_NOTSUPPORT; - } - /* Update and check */ - err_code = _check_by_mode(self, - &_sfp_update_attr_soft_rs0, - "sfp_get_soft_rs0"); - if (err_code <0){ - return err_code; - } - result = (self->soft_rs0 & bitmask); - if (result == bitmask) { - return 1; - } - if (result == 0) { - return 0; - } - return ERR_TRANSVR_UNEXCPT; -} - - -int -sfp_get_soft_rs1(struct transvr_obj_s *self){ - /* Note: - * SFP Soft RS(1) Select address - * A2h, offset: 118, bit 3 (begin form 0) - */ - int err_code = DEBUG_TRANSVR_INT_VAL; - int bit_shift = 3; - uint8_t result = 0x00; - uint8_t bitmask = (1 << bit_shift); - - /* Check rate identifier is supported */ - err_code = self->get_rate_id(self); - if (err_code <= 0) { - return ERR_TRANSVR_NOTSUPPORT; - } - /* Update and check */ - err_code = _check_by_mode(self, - &_sfp_update_attr_soft_rs1, - "sfp_get_soft_rs1"); - if (err_code <0){ - return err_code; - } - result = (self->soft_rs1 & bitmask); - if (result == bitmask) { - return 1; - } - if (result == 0) { - return 0; - } - return ERR_TRANSVR_UNEXCPT; -} - - -int -sfp_get_transvr_temp(struct transvr_obj_s *self, - char *buf_p) { - - int lmax = 8; - int err_code = DEBUG_TRANSVR_INT_VAL; - - err_code = _check_by_mode(self, - &_sfp_update_attr_curr_temp, - "sfp_get_transvr_temp"); - if (err_code < 0) { - return snprintf(buf_p, lmax, "%d\n", err_code); - } - if ((self->curr_temp[0]) == DEBUG_TRANSVR_HEX_VAL) { - return snprintf(buf_p, lmax, "%d\n", ERR_TRANSVR_UPDATE_FAIL); - } - return _common_count_temp(self->curr_temp[0], - self->curr_temp[1], - buf_p); -} - - -int -sfp_get_transvr_voltage(struct transvr_obj_s *self, - char *buf_p) { - - int lmax = 8; - int err_code = DEBUG_TRANSVR_INT_VAL; - - err_code = _check_by_mode(self, - &_sfp_update_attr_curr_voltage, - "sfp_get_transvr_voltage"); - if (err_code < 0) { - return snprintf(buf_p, lmax, "%d\n", err_code); - } - if ((self->curr_voltage[0]) == DEBUG_TRANSVR_HEX_VAL) { - return snprintf(buf_p, lmax, "%d\n", ERR_TRANSVR_UPDATE_FAIL); - } - /* Return Unit: 1 Volt */ - return _common_count_voltage(self->curr_voltage[0], - self->curr_voltage[1], - buf_p); -} - - -int -sfp_get_transvr_tx_bias(struct transvr_obj_s *self, - char *buf_p) { - - int lmax = 8; - int err_code = DEBUG_TRANSVR_INT_VAL; - - err_code = _check_by_mode(self, - &_sfp_update_attr_curr_tx_bias, - "sfp_get_transvr_tx_bias"); - if (err_code < 0) { - return snprintf(buf_p, lmax, "%d\n", err_code); - } - if ((self->curr_tx_bias[0]) == DEBUG_TRANSVR_HEX_VAL) { - return snprintf(buf_p, lmax, "%d\n", ERR_TRANSVR_UPDATE_FAIL); - } - /* Return Unit: 1 mA */ - return _common_count_tx_bias(self->curr_tx_bias[0], - self->curr_tx_bias[1], - buf_p); -} - - -int -sfp_get_transvr_tx_power(struct transvr_obj_s *self, - char *buf_p) { - - int lmax = 8; - int err_code = DEBUG_TRANSVR_INT_VAL; - - err_code = _check_by_mode(self, - &_sfp_update_attr_curr_tx_power, - "sfp_get_transvr_tx_power"); - if (err_code < 0) { - return snprintf(buf_p, lmax, "%d\n", err_code); - } - if ((self->curr_tx_bias[0]) == DEBUG_TRANSVR_HEX_VAL) { - return snprintf(buf_p, lmax, "%d\n", ERR_TRANSVR_UPDATE_FAIL); - } - /* Return Unit: 1 mW */ - return _common_count_tx_power(self->curr_tx_power[0], - self->curr_tx_power[1], - buf_p); -} - - -int -sfp_get_transvr_rx_power(struct transvr_obj_s *self, - char *buf_p) { - - int lmax = 8; - int err_code = DEBUG_TRANSVR_INT_VAL; - - err_code = _check_by_mode(self, - &_sfp_update_attr_curr_rx_power, - "sfp_get_transvr_rx_power"); - if (err_code < 0) { - return snprintf(buf_p, lmax, "%d\n", err_code); - } - if ((self->curr_tx_bias[0]) == DEBUG_TRANSVR_HEX_VAL) { - return snprintf(buf_p, lmax, "%d\n", ERR_TRANSVR_UPDATE_FAIL); - } - /* Return Unit: 1 mW */ - return _common_count_rx_power(self->curr_rx_power[0], - self->curr_rx_power[0], - buf_p); -} - - -int -sfp_get_transvr_rx_em(struct transvr_obj_s *self, - char *buf_p) { - - int limt = 8; - int err = DEBUG_TRANSVR_INT_VAL; - - err = _check_by_mode(self, - &_sfp_update_attr_rx_em, - "sfp_get_transvr_rx_em"); - if (err < 0) { - return snprintf(buf_p, limt, "%d\n", err); - } - if ((self->tx_eq[0]) == DEBUG_TRANSVR_HEX_VAL) { - return snprintf(buf_p, limt, "%d\n", ERR_TRANSVR_UPDATE_FAIL); - } - return snprintf(buf_p, limt, "0x%02x\n", self->rx_em[0]); -} - - -int -sfp_get_transvr_tx_eq(struct transvr_obj_s *self, - char *buf_p) { - - int limt = 8; - int err = DEBUG_TRANSVR_INT_VAL; - - err = _check_by_mode(self, - &_sfp_update_attr_tx_eq, - "sfp_get_transvr_tx_eq"); - if (err < 0) { - return snprintf(buf_p, limt, "%d\n", err); - } - if ((self->tx_eq[0]) == DEBUG_TRANSVR_HEX_VAL) { - return snprintf(buf_p, limt, "%d\n", ERR_TRANSVR_UPDATE_FAIL); - } - return snprintf(buf_p, limt, "0x%02x\n", self->tx_eq[0]); -} - - -int -_sfp_get_comp_extended(struct transvr_obj_s *self) { - /* Address: A0h / 36 - * Reference: SFF-8024 TABLE 4-4 - */ - if ((self->state == STATE_TRANSVR_CONNECTED) || - (self->state == STATE_TRANSVR_INIT) ) { - return (int)(self->transvr_comp_ext); - } - return ERR_TRANSVR_ABNORMAL; -} - - -int -__sfp_get_comp_attr(struct transvr_obj_s *self, - int array_offset) { - /* SFP Specification Compliance: A0h / 3-10 - * transvr_comp[0-7] = 3 - 10 - */ - if ((self->state == STATE_TRANSVR_CONNECTED) || - (self->state == STATE_TRANSVR_INIT) ) { - return (int)(self->transvr_comp[array_offset]); - } - return ERR_TRANSVR_ABNORMAL; -} - - -int -_sfp_get_comp_10g_eth_comp(struct transvr_obj_s *self) { - /* transvr_comp[0] = address A0h / 3 - * - * 3 7: 10G Base-ER - * 3 6: 10GBASE-LRM - * 3 5: 10GBASE-LR - * 3 4: 10GBASE-SR - */ - int bitmask = 0xf0; /* 11110000 */ - return (__sfp_get_comp_attr(self, 0) & bitmask); -} - - -int -_sfp_get_comp_1g_eth_comp(struct transvr_obj_s *self) { - /* transvr_comp[3] = address A0h / 6 - * - * 6 7: BASE-PX *3 - * 6 6: BASE-BX10 *3 - * 6 5: 100BASE-FX - * 6 4: 100BASE-LX/LX10 - * 6 3: 1000BASE-T - * 6 2: 1000BASE-CX - * 6 1: 1000BASE-LX *3 - * 6 0: 1000BASE-SX - */ - return __sfp_get_comp_attr(self, 3); -} - - -int -_sfp_get_cable_tech(struct transvr_obj_s *self) { - /* transvr_comp[5] = address A0h / 8 - * - * 8 3: Active Cable *8 - * 8 2: Passive Cable *8 - */ - int bitmask = 0x0c; /* 00001100 */ - return (__sfp_get_comp_attr(self, 5) & bitmask); -} - - -int -sfp_get_comp_eth_1(struct transvr_obj_s *self){ - - int err_code = _check_by_mode(self, - &_common_update_attr_transvr_comp, - "sfp_get_comp_eth_1"); - if (err_code < 0){ - return err_code; - } - return _sfp_get_comp_1g_eth_comp(self); -} - - -int -sfp_get_comp_eth_10(struct transvr_obj_s *self){ - - int err_code = _check_by_mode(self, - &_common_update_attr_transvr_comp, - "sfp_get_comp_eth_10"); - if (err_code < 0){ - return err_code; - } - return _sfp_get_comp_10g_eth_comp(self); -} - - -int -_sfp_get_connector_type(struct transvr_obj_s *self) { - /* Address: A0h / 2 - * Reference: SFF-8024 TABLE 4-3 - */ - if ((self->state == STATE_TRANSVR_CONNECTED) || - (self->state == STATE_TRANSVR_INIT) ) { - return (int)(self->connector); - } - return ERR_TRANSVR_ABNORMAL; -} - - -int -sfp_get_wavelength(struct transvr_obj_s *self, - char *buf_p) { - /* [Note] Optical and Cable Variants Specification Compliance (SFF-8472) - * [Addr] A0h, Bytes 60-61 - * [Note] For optical variants, as defined by having zero's in A0h Byte 8 - * bits 2 and 3, Bytes 60 and 61 denote nominal transmitter output - * wavelength at room temperature. 16 bit value with byte 60 as high - * order byte and byte 61 as low order byte. The laser wavelength is - * equal to the 16 bit integer value in nm. This field allows the user - * to read the laser wavelength directly, so it is not necessary to - * infer it from the Transceiver Codes A0h Bytes 3 to 10 (see Table - * 5-3). This also allows specification of wavelengths not covered - * in the Transceiver Codes, such as those used in coarse WDM systems. - * - * For passive and active cable variants, a value of 00h for both A0h - * Byte 60 and Byte 61 denotes laser wavelength or cable specification - * compliance is unspecified. - */ - - int lmax = 8; - int err_code = DEBUG_TRANSVR_INT_VAL; - - err_code = _check_by_mode(self, - &_common_update_attr_wavelength, - "common_get_wavelength"); - if (err_code < 0) { - return snprintf(buf_p, lmax, "%d\n", err_code); - } - if ((self->wavelength[0]) == DEBUG_TRANSVR_HEX_VAL) { - return snprintf(buf_p, lmax, "%d\n", ERR_TRANSVR_UPDATE_FAIL); - } - /* unit: 1 um */ - return snprintf(buf_p, lmax, "%d\n", - _common_count_wavelength(self, - self->wavelength[0], - self->wavelength[1])); -} - - -int -__qsfp_get_power_cls(struct transvr_obj_s *self, - int direct_access){ - - int err_code; - uint8_t detect_val; - - /* Detect and Update power class attribute */ - if (direct_access){ - err_code = _check_by_mode(self, - &_common_update_attr_extended_id, - "__qsfp_get_power_cls"); - } else { - err_code = self->ext_id; - } - if (err_code <0){ - return err_code; - } - if (err_code == DEBUG_TRANSVR_HEX_VAL){ - return ERR_TRANSVR_UPDATE_FAIL; - } - /* Clean data */ - detect_val = self->ext_id; - SWP_BIT_CLEAR(detect_val, 2); /* Bit2: CDR RX present */ - SWP_BIT_CLEAR(detect_val, 3); /* Bit3: CDR TX present */ - SWP_BIT_CLEAR(detect_val, 4); /* Bit4: CLEI present */ - SWP_BIT_CLEAR(detect_val, 5); /* Bit5: reserved */ - /* Identify power class */ - switch (detect_val) { - case 0: /* Class_1: 00000000 */ - return 1; - case 64: /* Class_2: 01000000 */ - return 2; - case 128: /* Class_3: 10000000 */ - return 3; - case 192: /* Class_4: 11000000 */ - return 4; - case 1: /* Class_5: 00000001 */ - case 193: /* Class_5: 11000001 */ - return 5; - case 2: /* Class_6: 00000010 */ - case 194: /* Class_6: 11000010 */ - return 6; - case 3: /* Class_7: 00000011 */ - case 195: /* Class_7: 11000011 */ - return 7; - default: - break; - } - SWPS_INFO("%s: Detect undefined power class:%d\n", __func__, detect_val); - return ERR_TRANSVR_UNDEFINED; -} - - -int -qsfp_get_power_cls(struct transvr_obj_s *self) { - return __qsfp_get_power_cls(self, 1); -} - - -int -__qsfp_get_cdr_present(struct transvr_obj_s *self, - int direct_access){ - - int retval; - int BIT_SHIFT = 2; - int BIT_MASK = 0x3; - - /* Detect and Update power class attribute */ - if (direct_access) { - retval = _check_by_mode(self, - &_common_update_attr_extended_id, - "__qsfp_get_cdr_present"); - if (retval < 0){ - return retval; - } - } - retval = self->ext_id; - if (retval == DEBUG_TRANSVR_HEX_VAL){ - return ERR_TRANSVR_UPDATE_FAIL; - } - /* Clean data and return */ - return (int)(retval >> BIT_SHIFT & BIT_MASK); -} - - -int -qsfp_get_cdr_present(struct transvr_obj_s *self) { - return __qsfp_get_cdr_present(self, 1); -} - - -int -qsfp_get_cdr(struct transvr_obj_s *self){ - - int err_code = _check_by_mode(self, - &_qsfp_update_attr_cdr, - "qsfp_get_cdr"); - if (err_code <0){ - return err_code; - } - - return self->cdr; -} - - -int -__qsfp_get_comp_attr(struct transvr_obj_s *self, - int array_offset) { - /* QSFP Specification Compliance: 00h / 131-138 - * transvr_comp[0-7] = 131 - 138 - */ - if ((self->state == STATE_TRANSVR_CONNECTED) || - (self->state == STATE_TRANSVR_INIT) ) { - return (int)(self->transvr_comp[array_offset]); - } - return ERR_TRANSVR_ABNORMAL; -} - - -int -_qsfp_get_comp_10_40_100_ethernet(struct transvr_obj_s *self) { - /* transvr_comp[0] = address 00h / 131 - * - * 131 7: Extended: See section 6.3.23. The Extended Specification Compliance - * Codes are maintained in the Transceiver Management section of SFF- - * 8024. - * 131 6: 10GBASE-LRM - * 131 5: 10GBASE-LR - * 131 4: 10GBASE-SR - * 131 3: 40GBASE-CR4 - * 131 2: 40GBASE-SR4 - * 131 1: 40GBASE-LR4 - * 131 0: 40G Active Cable (XLPPI) - */ - return __qsfp_get_comp_attr(self, 0); -} - - -int -_qsfp_get_comp_sonet(struct transvr_obj_s *self) { - /* transvr_comp[1] = address 00h / 132 - * - * 132 7-3: Reserved - * 132 2: OC 48, long reach - * 132 1: OC 48, intermediate reach - * 132 0: OC 48 short reach - */ - return __qsfp_get_comp_attr(self, 1); -} - - -int -_qsfp_get_comp_sas_sata(struct transvr_obj_s *self) { - /* transvr_comp[1] = address 00h / 132 - * - * 133 7: SAS 24.0 Gb/s - * 133 6: SAS 12.0 Gb/s - * 133 5: SAS 6.0 Gb/s - * 133 4: SAS 3.0 Gb/s - * 133 3-0: Reserved - */ - return __qsfp_get_comp_attr(self, 2); -} - - -int -_qsfp_get_comp_ethernet(struct transvr_obj_s *self) { - /* transvr_comp[1] = address 00h / 132 - * - * 134 7-4: Reserved - * 134 3: 1000BASE-T - * 134 2: 1000BASE-CX - * 134 1: 1000BASE-LX - * 134 0: 1000BASE-SX - */ - return __qsfp_get_comp_attr(self, 3); -} - - -int -_qsfp_get_comp_fc_link_length(struct transvr_obj_s *self) { - /* transvr_comp[1] = address 00h / 132 - * - * 135 7: Very long distance (V) - * 135 6: Short distance (S) - * 135 5: Intermediate distance (I) - * 135 4: Long distance (L) - * 135 3: Medium (M) - */ - int mask = 0xFC; /* 11111100 */ - return (__qsfp_get_comp_attr(self, 4) & mask); -} - - -int -_qsfp_get_comp_fc_trans_tech(struct transvr_obj_s *self) { - /* transvr_comp[1] = address 00h / 132 - * - * 135 2: Reserved - * 135 1: Longwave laser (LC) - * 135 0: Electrical inter-enclosure (EL) - * - * 136 7: Electrical intra-enclosure - * 136 6: Shortwave laser w/o OFC (SN) - * 136 5: Shortwave laser w OFC (SL) - * 136 4: Longwave Laser (LL) - * 136 3-0: Reserved - * - * return value = [bit 8-15:addr 135][bit 0-7:addr 136] - */ - int mask_135 = 7; /* 00000111 */ - int val_135 = (__qsfp_get_comp_attr(self, 4) & mask_135); - int val_136 = __qsfp_get_comp_attr(self, 5); - return ((val_135 << 7) + val_136); -} - - -int -_qsfp_get_comp_fc_trans_media(struct transvr_obj_s *self) { - /* transvr_comp[1] = address 00h / 132 - * - * 137 7: Twin Axial Pair (TW) - * 137 6: Shielded Twisted Pair (TP) - * 137 5: Miniature Coax (MI) - * 137 4: Video Coax (TV) - * 137 3: Multi-mode 62.5 m (M6) - * 137 2: Multi-mode 50 m (M5) - * 137 1: Multi-mode 50 um (OM3) - * 137 0: Single Mode (SM) - */ - return __qsfp_get_comp_attr(self, 6); -} - - -int -_qsfp_get_comp_fc_speed(struct transvr_obj_s *self) { - /* transvr_comp[1] = address 00h / 132 - * - * 138 7: 1200 MBps (per channel) - * 138 6: 800 MBps - * 138 5: 1600 MBps (per channel) - * 138 4: 400 MBps - * 138 3: 3200 MBps (per channel) - * 138 2: 200 MBps - * 138 1: Extended: See section 6.3.23. The Extended Specification - * Compliance Codes are maintained in the Transceiver Management - * section of SFF-8024. - * 138 0: 100 MBps - */ - return __qsfp_get_comp_attr(self, 7); -} - - -int -_qsfp_get_comp_extended(struct transvr_obj_s *self) { - /* Address: 00h / 192 - * Reference: SFF-8024 TABLE 4-4 - */ - if ((self->state == STATE_TRANSVR_CONNECTED) || - (self->state == STATE_TRANSVR_INIT) ) { - return (int)(self->transvr_comp_ext); - } - return ERR_TRANSVR_ABNORMAL; -} - - -int -qsfp_get_comp_eth(struct transvr_obj_s *self){ - - int err_code = _check_by_mode(self, - &_common_update_attr_transvr_comp, - "qsfp_get_comp_eth"); - if (err_code < 0){ - return err_code; - } - return _qsfp_get_comp_ethernet(self); -} - - -int -qsfp_get_comp_10_40(struct transvr_obj_s *self) { - - int err_code = _check_by_mode(self, - &_common_update_attr_transvr_comp, - "qsfp_get_comp_10_40"); - if (err_code < 0){ - return err_code; - } - return _qsfp_get_comp_10_40_100_ethernet(self); -} - - -int -_qsfp_get_connector_type(struct transvr_obj_s *self) { - /* Address: 00h / 130 - * Reference: SFF-8024 TABLE 4-3 - */ - if ((self->state == STATE_TRANSVR_CONNECTED) || - (self->state == STATE_TRANSVR_INIT) ) { - return (int)(self->connector); - } - return ERR_TRANSVR_ABNORMAL; -} - - -int -qsfp_get_transvr_temp(struct transvr_obj_s *self, - char *buf_p) { - - int lmax = 8; - int err_code = DEBUG_TRANSVR_INT_VAL; - - err_code = _check_by_mode(self, - &_qsfp_update_attr_curr_temp, - "qsfp_get_transvr_temp"); - if (err_code < 0) { - return snprintf(buf_p, lmax, "%d\n", err_code); - } - if ((self->curr_temp[0]) == DEBUG_TRANSVR_HEX_VAL) { - return snprintf(buf_p, lmax, "%d\n", ERR_TRANSVR_UPDATE_FAIL); - } - return _common_count_temp(self->curr_temp[0], - self->curr_temp[1], - buf_p); -} - - -int -qsfp_get_transvr_voltage(struct transvr_obj_s *self, - char *buf_p) { - - int lmax = 8; - int err_code = DEBUG_TRANSVR_INT_VAL; - - err_code = _check_by_mode(self, - &_qsfp_update_attr_curr_voltage, - "qsfp_get_transvr_voltage"); - if (err_code < 0) { - return snprintf(buf_p, lmax, "%d\n", err_code); - } - if ((self->curr_voltage[0]) == DEBUG_TRANSVR_HEX_VAL) { - return snprintf(buf_p, lmax, "%d\n", ERR_TRANSVR_UPDATE_FAIL); - } - /* Return Unit: 1 Volt */ - return _common_count_voltage(self->curr_voltage[0], - self->curr_voltage[1], - buf_p); -} - - -int -qsfp_get_transvr_tx_eq(struct transvr_obj_s *self, - char *buf_p) { - - int limt = 8; - int err = DEBUG_TRANSVR_INT_VAL; - - err = _check_by_mode(self, - &_qsfp_update_attr_tx_eq, - "qsfp_get_transvr_tx_eq"); - if (err < 0) { - return snprintf(buf_p, limt, "%d\n", err); - } - if ((self->tx_eq[0]) == DEBUG_TRANSVR_HEX_VAL) { - return snprintf(buf_p, limt, "%d\n", ERR_TRANSVR_UPDATE_FAIL); - } - return snprintf(buf_p, limt, "0x%02x%02x\n", - self->tx_eq[0], self->tx_eq[1]); -} - - -int -qsfp_get_transvr_rx_am(struct transvr_obj_s *self, - char *buf_p) { - - int limt = 8; - int err = DEBUG_TRANSVR_INT_VAL; - - err = _check_by_mode(self, - &_qsfp_update_attr_rx_am, - "qsfp_get_transvr_rx_am"); - if (err < 0) { - return snprintf(buf_p, limt, "%d\n", err); - } - if ((self->rx_am[0]) == DEBUG_TRANSVR_HEX_VAL) { - return snprintf(buf_p, limt, "%d\n", ERR_TRANSVR_UPDATE_FAIL); - } - return snprintf(buf_p, limt, "0x%02x%02x\n", - self->rx_am[0], self->rx_am[1]); -} - - -int -qsfp_get_transvr_rx_em(struct transvr_obj_s *self, - char *buf_p) { - - int limt = 8; - int err = DEBUG_TRANSVR_INT_VAL; - - err = _check_by_mode(self, - &_qsfp_update_attr_rx_em, - "qsfp_get_transvr_rx_em"); - if (err < 0) { - return snprintf(buf_p, limt, "%d\n", err); - } - if ((self->rx_em[0]) == DEBUG_TRANSVR_HEX_VAL) { - return snprintf(buf_p, limt, "%d\n", ERR_TRANSVR_UPDATE_FAIL); - } - return snprintf(buf_p, limt, "0x%02x%02x\n", - self->rx_em[0], self->rx_em[1]); -} - - -int -_qsfp_get_channel_diag(uint8_t *data_array, - int (*count_func)(uint8_t high_byte, uint8_t low_byte, char *buf_p), - char *ch_name, - char *result_p) { - int i, high, low; - int len_max = 128; - char ch_buf[4][16] = { DEBUG_TRANSVR_STR_VAL, - DEBUG_TRANSVR_STR_VAL, - DEBUG_TRANSVR_STR_VAL, - DEBUG_TRANSVR_STR_VAL }; - - for (i=0; i<4; i++) { - high = (i*2); - low = ((i*2) + 1); - count_func(data_array[high], data_array[low], ch_buf[i]); - } - return snprintf(result_p, len_max, - "%s-%d:%s%s-%d:%s%s-%d:%s%s-%d:%s", - ch_name, 1, ch_buf[0], - ch_name, 2, ch_buf[1], - ch_name, 3, ch_buf[2], - ch_name, 4, ch_buf[3]); -} - - -int -qsfp_get_soft_rx_los(struct transvr_obj_s *self, - char *buf_p) { - - int lmax = 8; - int mask = 0x0f; /* Bit 0 ~ Bit 3 */ - int err_code = DEBUG_TRANSVR_INT_VAL; - - err_code = _check_by_mode(self, - &_qsfp_update_attr_soft_rx_los, - "qsfp_get_soft_rx_los"); - if (err_code < 0) { - return snprintf(buf_p, lmax, "%d\n", err_code); - } - return snprintf(buf_p, lmax, "0x%02x\n", (self->rx_los & mask)); -} - - -int -qsfp_get_soft_tx_disable(struct transvr_obj_s *self, - char *buf_p) { - - int lmax = 8; - int mask = 0x0f; /* Bit 0 ~ Bit 3 */ - int err_code = DEBUG_TRANSVR_INT_VAL; - - err_code = _check_by_mode(self, - &_qsfp_update_attr_soft_tx_disable, - "qsfp_get_soft_tx_disable"); - if (err_code < 0) { - return snprintf(buf_p, lmax, "%d\n", err_code); - } - return snprintf(buf_p, lmax, "0x%02x\n", (self->tx_disable & mask)); -} - - -int -qsfp_get_soft_tx_fault(struct transvr_obj_s *self, - char *buf_p) { - - int lmax = 8; - int mask = 0x0f; /* Bit 0 ~ Bit 3 */ - int err_code = DEBUG_TRANSVR_INT_VAL; - - err_code = _check_by_mode(self, - &_qsfp_update_attr_soft_tx_fault, - "qsfp_get_soft_tx_fault"); - if (err_code < 0) { - return snprintf(buf_p, lmax, "%d\n", err_code); - } - return snprintf(buf_p, lmax, "0x%02x\n", (self->tx_fault & mask)); -} - - -int -qsfp_get_auto_tx_disable(struct transvr_obj_s *self, - char *buf_p) { - - if (self->auto_tx_disable == VAL_TRANSVR_FUNCTION_DISABLE) { - return snprintf(buf_p, LEN_TRANSVR_S_STR, - "%d\n", ERR_TRANSVR_FUNC_DISABLE); - } - return snprintf(buf_p, LEN_TRANSVR_S_STR, - "0x%02x\n", self->auto_tx_disable); -} - - -int -qsfp_get_transvr_tx_bias(struct transvr_obj_s *self, - char *buf_p) { - - int lmax = 8; - int err_code = DEBUG_TRANSVR_INT_VAL; - char *ch_name = "TX"; - - err_code = _check_by_mode(self, - &_qsfp_update_attr_curr_tx_bias, - "qsfp_get_transvr_tx_bias"); - if (err_code < 0) { - return snprintf(buf_p, lmax, "%d\n", err_code); - } - if ((self->curr_tx_bias[0]) == DEBUG_TRANSVR_HEX_VAL) { - return snprintf(buf_p, lmax, "%d\n", ERR_TRANSVR_UPDATE_FAIL); - } - /* Return Unit: 1 mA */ - return _qsfp_get_channel_diag(self->curr_tx_bias, - _common_count_tx_bias, - ch_name, - buf_p); -} - - -int -qsfp_get_transvr_tx_power(struct transvr_obj_s *self, - char *buf_p) { - - int lmax = 8; - int err_code = DEBUG_TRANSVR_INT_VAL; - char *ch_name = "TX"; - - err_code = _check_by_mode(self, - &_qsfp_update_attr_curr_tx_power, - "qsfp_get_transvr_tx_power"); - if (err_code < 0) { - return snprintf(buf_p, lmax, "%d\n", err_code); - } - if ((self->curr_tx_power[0]) == DEBUG_TRANSVR_HEX_VAL) { - return snprintf(buf_p, lmax, "%d\n", ERR_TRANSVR_UPDATE_FAIL); - } - /* Return Unit: 1 mW */ - return _qsfp_get_channel_diag(self->curr_tx_power, - _common_count_tx_power, - ch_name, - buf_p); -} - - -int -qsfp_get_transvr_rx_power(struct transvr_obj_s *self, - char *buf_p) { - - int lmax = 8; - int err_code = DEBUG_TRANSVR_INT_VAL; - char *ch_name = "RX"; - - err_code = _check_by_mode(self, - &_qsfp_update_attr_curr_rx_power, - "qsfp_get_transvr_rx_power"); - if (err_code < 0) { - return snprintf(buf_p, lmax, "%d\n", err_code); - } - if ((self->curr_tx_power[0]) == DEBUG_TRANSVR_HEX_VAL) { - return snprintf(buf_p, lmax, "%d\n", ERR_TRANSVR_UPDATE_FAIL); - } - /* Return Unit: 1 mW */ - return _qsfp_get_channel_diag(self->curr_rx_power, - _common_count_rx_power, - ch_name, - buf_p); -} - - -int -qsfp_get_wavelength(struct transvr_obj_s *self, - char *buf_p) { - /* [Desc] Wavelength or Copper Cable Attenuation (SFF-8636) - * [Addr] 00h 186-187 - * [Note] - * For optical free side devices, this parameter identifies the nominal - * transmitter output wavelength at room temperature. This parameter is - * a 16-bit hex value with Byte 186 as high order byte and Byte 187 as - * low order byte. The laser wavelength is equal to the 16-bit integer value - * divided by 20 in nm (units of 0.05 nm). This resolution should be adequate - * to cover all relevant wavelengths yet provide enough resolution for all - * expected DWDM applications. For accurate representation of controlled - * wavelength applications, this value should represent the center of the - * guaranteed wavelength range. - * If the free side device is identified as copper cable these registers will - * be used to define the cable attenuation. An indication of 0 dB attenuation - * refers to the case where the attenuation is not known or is unavailable. - * Byte 186 (00-FFh) is the copper cable attenuation at 2.5 GHz in units of 1 dB. - * Byte 187 (00-FFh) is the copper cable attenuation at 5.0 GHz in units of 1 dB. - */ - int lmax = 8; - int err_code = DEBUG_TRANSVR_INT_VAL; - - err_code = _check_by_mode(self, - &_common_update_attr_wavelength, - "common_get_wavelength"); - if (err_code < 0) { - return snprintf(buf_p, lmax, "%d\n", err_code); - } - if ((self->wavelength[0]) == DEBUG_TRANSVR_HEX_VAL) { - return snprintf(buf_p, lmax, "%d\n", ERR_TRANSVR_UPDATE_FAIL); - } - /* unit: 1 um */ - return snprintf(buf_p, lmax, "%d\n", - _common_count_wavelength(self, - self->wavelength[0], - self->wavelength[1])); -} - - -/* Public Function for Setup Features - */ -static int -__sfp_set_soft_rs(struct transvr_obj_s *self, - int input_val, - int address, - int page, - int offset, - int bit_shift, - uint8_t *attr_p, - char *caller, - int show_err) { - - int retval = ERR_TRANSVR_UNEXCPT; - int err_code = ERR_TRANSVR_UNEXCPT; - char *err_msg = DEBUG_TRANSVR_STR_VAL; - uint8_t update_val = (*attr_p); - - switch (input_val) { - case 0: - SWP_BIT_CLEAR(update_val, bit_shift); - break; - case 1: - SWP_BIT_SET(update_val, bit_shift); - break; - default: - retval = ERR_TRANSVR_UNEXCPT; - err_code = ERR_TRANSVR_UNEXCPT; - err_msg = "Exception occurs"; - goto err_private_sfp_set_soft_rs_1; - } - err_code = _common_set_uint8_attr(self, - address, - page, - offset, - update_val, - attr_p, - caller, - show_err); - if (err_code < 0) { - retval = err_code; - err_msg = "Write data via i2c fail!"; - goto err_private_sfp_set_soft_rs_1; - } - (*attr_p) = update_val; - return 0; - -err_private_sfp_set_soft_rs_1: - if (show_err) { - SWPS_INFO("%s: %s :%d :%s\n :%d\n", - __func__, err_msg, err_code, self->swp_name, input_val); - } - return retval; -} - - -static int -_sfp_set_soft_rs(struct transvr_obj_s *self, - int input_val, - int address, - int page, - int offset, - int bit_shift, - int (*attr_update_func)(struct transvr_obj_s *self, int show_err), - uint8_t *attr_p, - char *caller, - int show_err) { - - int retval = ERR_TRANSVR_UNEXCPT; - int err_code = ERR_TRANSVR_UNEXCPT; - char *err_msg = DEBUG_TRANSVR_STR_VAL; - - /* Check input value */ - if ((input_val != 0) && (input_val != 1)){ - retval = ERR_TRANSVR_BADINPUT; - err_code = ERR_TRANSVR_BADINPUT; - err_msg = "Input range incorrect!"; - goto err_common_sfp_set_soft_rs_1; - } - /* Check rate identifier is supported */ - err_code = self->get_rate_id(self); - if (err_code <= 0) { - switch (err_code) { - case 0: - retval = ERR_TRANSVR_NOTSUPPORT; - err_msg = "Not support this feature"; - break; - case ERR_TRANSVR_UNINIT: - retval = ERR_TRANSVR_UNINIT; - err_msg = "Check CDR present fail!"; - break; - case ERR_TRANSVR_UNPLUGGED: - retval = ERR_TRANSVR_UNPLUGGED; - err_msg = "Transceiver unplugged!"; - break; - default: - retval = err_code; - err_msg = "Check Rate_ID fail!"; - break; - } - goto err_common_sfp_set_soft_rs_1; - } - /* Check and update */ - err_code = _check_by_mode(self, - attr_update_func, - caller); - if ( (err_code < 0) || - ((*attr_p) == DEBUG_TRANSVR_HEX_VAL) ){ - retval = err_code; - err_msg = "Get current value fail!"; - goto err_common_sfp_set_soft_rs_1; - } - /* Generate and update value */ - return __sfp_set_soft_rs(self, - input_val, - address, - page, - offset, - bit_shift, - attr_p, - caller, - show_err); - -err_common_sfp_set_soft_rs_1: - if (show_err) { - SWPS_INFO("%s: %s :%d :%s\n :%d\n", - __func__, err_msg, err_code, self->swp_name, input_val); - } - return retval; -} - - -int -sfp_set_soft_rs0(struct transvr_obj_s *self, - int input_val) { - /* Note: - * SFP Soft Rate_Select Select RX ["RS(0)"] address - * A2h, offset: 110, bit 3 - */ - int bit_shift = 3; - int show_err = 1; - return _sfp_set_soft_rs(self, - input_val, - self->eeprom_map_p->addr_soft_rs0, - self->eeprom_map_p->page_soft_rs0, - self->eeprom_map_p->offset_soft_rs0, - bit_shift, - &_sfp_update_attr_soft_rs0, - &(self->soft_rs0), - "sfp_set_soft_rs0", - show_err); -} - - -int -sfp_set_soft_rs1(struct transvr_obj_s *self, - int input_val) { - /* Note: - * SFP Soft Rate_Select Select RX ["RS(1)"] address - * A2h, offset: 118, bit 3 - */ - int bit_shift = 3; - int show_err = 1; - return _sfp_set_soft_rs(self, - input_val, - self->eeprom_map_p->addr_soft_rs1, - self->eeprom_map_p->page_soft_rs1, - self->eeprom_map_p->offset_soft_rs1, - bit_shift, - &_sfp_update_attr_soft_rs1, - &(self->soft_rs1), - "sfp_set_soft_rs1", - show_err); -} - - -int -__sfp_set_tx_eq(struct transvr_obj_s *self, - int input, - int show_e) { - - int err = DEBUG_TRANSVR_INT_VAL; - char *emsg = DEBUG_TRANSVR_STR_VAL; - uint8_t setv = DEBUG_TRANSVR_HEX_VAL; - - if ((input < 0) || (input > 0xFF)) { - emsg = "input incorrect"; - err = ERR_TRANSVR_BADINPUT; - goto err_sfp_set_tx_eq; - } - setv = (uint8_t)input; - if (self->tx_eq[0] == setv) { - return 0; - } - err = _common_set_uint8_attr(self, - self->eeprom_map_p->addr_tx_eq, - self->eeprom_map_p->page_tx_eq, - self->eeprom_map_p->offset_tx_eq, - setv, - &(self->tx_eq[0]), - "_sfp_set_tx_eq", - show_e); - if (err < 0) { - emsg = "set_uint8_attr fail"; - goto err_sfp_set_tx_eq; - } - return 0; - -err_sfp_set_tx_eq: - if (show_e) { - SWPS_INFO("%s: %s :%d\n", __func__, emsg, input); - } - return err; -} - - -int -_sfp_set_tx_eq(struct transvr_obj_s *self, - int input, - int show_e) { - - uint8_t tmp; - int i = 0; - int retry = 3; - - for (i=0; itx_eq[0]; - if (_sfp_update_attr_tx_eq(self, show_e) < 0){ - continue; - } - if (self->tx_eq[0] == tmp){ - return 0; - } - } - return ERR_TRANSVR_UPDATE_FAIL; -} - - -int -sfp_set_tx_eq(struct transvr_obj_s *self, - int input) { - - int err = _check_by_mode(self, - &_sfp_update_attr_tx_eq, - "sfp_set_tx_eq"); - if (err < 0) { - SWPS_DEBUG("%s: check fail :%d\n", __func__, err); - return err; - } - return _sfp_set_tx_eq(self, input, 1); -} - - -int -__sfp_set_rx_em(struct transvr_obj_s *self, - int input, - int show_e) { - - int err = DEBUG_TRANSVR_INT_VAL; - char *emsg = DEBUG_TRANSVR_STR_VAL; - uint8_t setv = DEBUG_TRANSVR_HEX_VAL; - - if ((input < 0) || (input > 0xFF)) { - emsg = "input incorrect"; - err = ERR_TRANSVR_BADINPUT; - goto err_sfp_set_rx_em; - } - setv = (uint8_t)input; - if (self->rx_em[0] == setv) { - return 0; - } - err = _common_set_uint8_attr(self, - self->eeprom_map_p->addr_rx_em, - self->eeprom_map_p->page_rx_em, - self->eeprom_map_p->offset_rx_em, - setv, - &(self->rx_em[0]), - "_sfp_set_rx_em", - show_e); - if (err < 0) { - emsg = "set_uint8_attr fail"; - goto err_sfp_set_rx_em; - } - return 0; - -err_sfp_set_rx_em: - if (show_e) { - SWPS_INFO("%s: %s :%d\n", __func__, emsg, input); - } - return err; -} - - -int -_sfp_set_rx_em(struct transvr_obj_s *self, - int input, - int show_e) { - - uint8_t tmp; - int i = 0; - int retry = 3; - - for (i=0; irx_em[0]; - if (_sfp_update_attr_rx_em(self, show_e) < 0){ - continue; - } - if (self->rx_em[0] == tmp){ - return 0; - } - } - return -1; -} - - -int -sfp_set_rx_em(struct transvr_obj_s *self, - int input) { - - int err = _check_by_mode(self, - &_sfp_update_attr_rx_em, - "sfp_set_rx_em"); - if (err < 0) { - SWPS_DEBUG("%s: check fail :%d\n", __func__, err); - return err; - } - return _sfp_set_rx_em(self, input, 1); -} - - -static int -__qsfp_set_cdr(struct transvr_obj_s *self, - int input_val, - int show_err) { - - uint8_t update_val; - int CDR_FEATURE_SUPPORTED = 0x3; - int retval = ERR_TRANSVR_UNEXCPT; - int err_code = ERR_TRANSVR_UNEXCPT; - char *err_msg = DEBUG_TRANSVR_STR_VAL; - char *func_name = "__qsfp_set_cdr"; - - /* Check input value */ - if ((input_val < 0) || (input_val > 0xff)){ - retval = ERR_TRANSVR_BADINPUT; - err_code = ERR_TRANSVR_BADINPUT; - err_msg = "Input range incorrect!"; - goto err_qsfp_set_cdr_1; - } - update_val = (uint8_t)input_val; - /* Check CDR supported by transceiver */ - err_code = qsfp_get_cdr_present(self); - if (err_code < 0) { - retval = err_code; - switch (err_code) { - case ERR_TRANSVR_UNINIT: - err_msg = "Check CDR present fail!"; - break; - case ERR_TRANSVR_UNPLUGGED: - err_msg = "Transceiver unplugged!"; - break; - default: - err_msg = "Check CDR present fail!"; - break; - } - goto err_qsfp_set_cdr_1; - } - if (err_code != CDR_FEATURE_SUPPORTED) { - retval = ERR_TRANSVR_NOTSUPPORT; - err_msg = "This transceiver not support CDR!"; - goto err_qsfp_set_cdr_1; - } - /* Check and update */ - err_code = _check_by_mode(self, - &_qsfp_update_attr_cdr, - func_name); - if ( (err_code < 0) || - (self->cdr == DEBUG_TRANSVR_HEX_VAL) ){ - retval = err_code; - err_msg = "Get current value fail!"; - goto err_qsfp_set_cdr_1; - } - /* Write input value to transceiver */ - return _common_set_uint8_attr(self, - self->eeprom_map_p->addr_cdr, - self->eeprom_map_p->page_cdr, - self->eeprom_map_p->offset_cdr, - update_val, - &(self->cdr), - func_name, - show_err); - -err_qsfp_set_cdr_1: - if (show_err) { - SWPS_INFO("%s: %s :%d :%s\n :%d\n", - __func__, err_msg, err_code, self->swp_name, input_val); - } - return retval; -} - - -int -qsfp_set_cdr(struct transvr_obj_s *self, - int input_val) { - return __qsfp_set_cdr(self, input_val, 1); -} - - -int -qsfp_set_soft_tx_disable(struct transvr_obj_s *self, - int input_val) { - - int show_err = 1; - int in_max = 0xf; /* 1111 */ - int in_min = 0x0; /* 0000 */ - int retval = DEBUG_TRANSVR_INT_VAL; - int update_val = DEBUG_TRANSVR_INT_VAL; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - - retval = _check_by_mode(self, - &_qsfp_update_attr_soft_tx_disable, - "qsfp_set_soft_tx_disable"); - if (retval < 0) { - snprintf(err_msg, 63, "Not ready. err:%d", retval); - goto err_qsfp_set_soft_tx_disable; - } - if ((input_val > in_max) || - (input_val < in_min) ){ - retval = ERR_TRANSVR_BADINPUT; - snprintf(err_msg, 63, "Input value:%d incorrect!", input_val); - goto err_qsfp_set_soft_tx_disable; - } - if ((self->tx_disable & 0x0f) == input_val) { - return 0; - } - update_val = ((self->tx_disable & 0xf0) & input_val); - retval = _common_set_uint8_attr(self, - self->eeprom_map_p->addr_tx_disable, - self->eeprom_map_p->page_tx_disable, - self->eeprom_map_p->offset_tx_disable, - input_val, - &(self->tx_disable), - "qsfp_set_tx_disable", - show_err); - if (retval < 0) { - snprintf(err_msg, 63, "_common_set_uint8_attr:%d fail!", retval); - goto err_qsfp_set_soft_tx_disable; - } - return 0; - -err_qsfp_set_soft_tx_disable: - SWPS_INFO("%s: %s :%s\n", __func__, err_msg, self->swp_name); - return retval; -} - - -int -_qsfp_set_auto_tx_disable(struct transvr_obj_s *self, - uint8_t update) { - - uint8_t tx_enable = 0x0; - int show_e = 1; - int err = DEBUG_TRANSVR_INT_VAL; - char *emsg = DEBUG_TRANSVR_STR_VAL; - - /* Handle timing issues */ - if (update != tx_enable) { - /* Note: - * Because there are some txvr has timing issues, - * therefore we need to execute reset cycle first. - * (enable -> other settings) - */ - err = _common_set_uint8_attr(self, - self->eeprom_map_p->addr_tx_disable, - self->eeprom_map_p->page_tx_disable, - self->eeprom_map_p->offset_tx_disable, - tx_enable, - &(self->tx_disable), - "_qsfp_set_auto_tx_disable", - show_e); - if (err < 0) { - emsg = "I2C set reset value fail"; - goto err_qsfp_set_auto_tx_disable; - } - mdelay(10); - } - /* Setup target value */ - err = _common_set_uint8_attr(self, - self->eeprom_map_p->addr_tx_disable, - self->eeprom_map_p->page_tx_disable, - self->eeprom_map_p->offset_tx_disable, - self->auto_tx_disable, - &(self->tx_disable), - "_qsfp_set_auto_tx_disable", - show_e); - if (err < 0) { - emsg = "I2C set target value fail"; - goto err_qsfp_set_auto_tx_disable; - } - /* Check and update */ - err = _common_update_uint8_attr(self, - self->eeprom_map_p->addr_tx_disable, - self->eeprom_map_p->page_tx_disable, - self->eeprom_map_p->offset_tx_disable, - self->eeprom_map_p->length_tx_disable, - &(self->tx_disable), - "_qsfp_set_auto_tx_disable", - show_e); - if (err < 0) { - emsg = "I2C get value fail"; - goto err_qsfp_set_auto_tx_disable; - } - if (self->tx_disable != update) { - emsg = "data not become effective"; - goto err_qsfp_set_auto_tx_disable; - } - return 0; - -err_qsfp_set_auto_tx_disable: - SWPS_DEBUG("%s: %s :%s\n", - __func__, emsg, self->swp_name); - return ERR_TRANSVR_UPDATE_FAIL; -} - - -int -qsfp_set_auto_tx_disable(struct transvr_obj_s *self, - int input_val) { - - int in_max = 0xf; /* 1111 */ - int in_min = 0x0; /* 0000 */ - int retval = DEBUG_TRANSVR_INT_VAL; - char *emsg = DEBUG_TRANSVR_STR_VAL; - - /* Update settings*/ - if (input_val == VAL_TRANSVR_FUNCTION_DISABLE) { - emsg = "User disable auto tx_disable"; - self->auto_tx_disable = VAL_TRANSVR_FUNCTION_DISABLE; - goto out_qsfp_set_auto_tx_disable; - } - if ((input_val > in_max) || (input_val < in_min) ){ - SWPS_INFO("%s: Input value:%d incorrect! :%s\n", - __func__, input_val, self->swp_name); - return ERR_TRANSVR_BADINPUT; - } - self->auto_tx_disable = input_val; - /* Check current soft tx_disable */ - retval = _check_by_mode(self, - &_qsfp_update_attr_soft_tx_disable, - "qsfp_set_auto_tx_disable"); - switch (retval) { - case 0: - break; - case ERR_TRANSVR_UNPLUGGED: - emsg = "Doesn't need to update"; - goto out_qsfp_set_auto_tx_disable; - default: - SWPS_INFO("%s: setup fail :%d :%s\n", - __func__, retval, self->swp_name); - return retval; - } - return _qsfp_set_auto_tx_disable(self, input_val); - -out_qsfp_set_auto_tx_disable: - SWPS_DEBUG("%s: %s :%s :%d\n :%d", - __func__, emsg, self->swp_name, input_val, retval); - return 0; -} - - -int -__qsfp_set_tx_eq(struct transvr_obj_s *self, - int input, - int show_e) { - /* [Note] - * 0x - */ - int err = DEBUG_TRANSVR_INT_VAL; - char *emsg = DEBUG_TRANSVR_STR_VAL; - uint8_t setv[2] = {0x00, 0x00}; - - if ((input < 0) || (input > 0xFFFF)) { - emsg = "input incorrect"; - err = ERR_TRANSVR_BADINPUT; - goto err_qsfp_set_tx_eq; - } - setv[0] = (uint8_t)((input & 0xFF00) >> 8); - setv[1] = (uint8_t)(input & 0xFF); - if ((self->tx_eq[0] == setv[0]) && - (self->tx_eq[1] == setv[1]) ) { - return 0; - } - err = _common_set_uint8_array(self, - self->eeprom_map_p->addr_tx_eq, - self->eeprom_map_p->page_tx_eq, - self->eeprom_map_p->offset_tx_eq, - self->eeprom_map_p->length_tx_eq, - setv, - self->tx_eq, - "_qsfp_set_tx_eq", - show_e); - if (err < 0) { - emsg = "set_uint8_array fail"; - goto err_qsfp_set_tx_eq; - } - return 0; - -err_qsfp_set_tx_eq: - if (show_e) { - SWPS_INFO("%s: %s :%d\n", __func__, emsg, input); - } - return err; -} - - -int -_qsfp_set_tx_eq(struct transvr_obj_s *self, - int input, - int show_e) { - - int i = 0; - int retry = 3; - uint8_t tmp[2]; - - for (i=0; itx_eq[0]; - tmp[1] = self->tx_eq[1]; - if (_qsfp_update_attr_tx_eq(self, show_e) < 0){ - continue; - } - if ((self->tx_eq[0] == tmp[0]) && - (self->tx_eq[1] == tmp[1]) ){ - return 0; - } - } - return -1; -} - - -int -qsfp_set_tx_eq(struct transvr_obj_s *self, - int input) { - - int err = _check_by_mode(self, - &_qsfp_update_attr_tx_eq, - "qsfp_set_tx_eq"); - if (err < 0) { - SWPS_DEBUG("%s: check fail :%d\n", __func__, err); - return err; - } - return _qsfp_set_tx_eq(self, input, 1); -} - - -int -__qsfp_set_rx_am(struct transvr_obj_s *self, - int input, - int show_e) { - /* [Note] - * 0x - */ - int err = DEBUG_TRANSVR_INT_VAL; - char *emsg = DEBUG_TRANSVR_STR_VAL; - uint8_t setv[2] = {0x00, 0x00}; - - if ((input < 0) || (input > 0xFFFF)) { - emsg = "input incorrect"; - err = ERR_TRANSVR_BADINPUT; - goto err_qsfp_set_rx_am; - } - setv[0] = (uint8_t)((input & 0xFF00) >> 8); - setv[1] = (uint8_t)(input & 0xFF); - if ((self->rx_am[0] == setv[0]) && - (self->rx_am[1] == setv[1]) ) { - return 0; - } - err = _common_set_uint8_array(self, - self->eeprom_map_p->addr_rx_am, - self->eeprom_map_p->page_rx_am, - self->eeprom_map_p->offset_rx_am, - self->eeprom_map_p->length_rx_am, - setv, - self->rx_am, - "_qsfp_set_rx_am", - show_e); - if (err < 0) { - emsg = "set_uint8_array fail"; - goto err_qsfp_set_rx_am; - } - return 0; - -err_qsfp_set_rx_am: - if (show_e) { - SWPS_INFO("%s: %s :%d\n", __func__, emsg, input); - } - return err; -} - - -int -_qsfp_set_rx_am(struct transvr_obj_s *self, - int input, - int show_e) { - - int i = 0; - int retry = 3; - uint8_t tmp[2]; - - for (i=0; irx_am[0]; - tmp[1] = self->rx_am[1]; - if (_qsfp_update_attr_rx_am(self, show_e) < 0){ - continue; - } - if ((self->rx_am[0] == tmp[0]) && - (self->rx_am[1] == tmp[1]) ){ - return 0; - } - } - return -1; -} - - -int -qsfp_set_rx_am(struct transvr_obj_s *self, - int input) { - - int err = _check_by_mode(self, - &_qsfp_update_attr_rx_am, - "qsfp_set_rx_am"); - if (err < 0) { - SWPS_DEBUG("%s: check fail :%d\n", __func__, err); - return err; - } - return _qsfp_set_rx_am(self, input, 1); -} - - -int -__qsfp_set_rx_em(struct transvr_obj_s *self, - int input, - int show_e) { - /* [Note] - * 0x - */ - int err = DEBUG_TRANSVR_INT_VAL; - char *emsg = DEBUG_TRANSVR_STR_VAL; - uint8_t setv[2] = {0x00, 0x00}; - - if ((input < 0) || (input > 0xFFFF)) { - emsg = "input incorrect"; - err = ERR_TRANSVR_BADINPUT; - goto err_qsfp_set_rx_em; - } - setv[0] = (uint8_t)((input & 0xFF00) >> 8); - setv[1] = (uint8_t)(input & 0xFF); - if ((self->rx_em[0] == setv[0]) && - (self->rx_em[1] == setv[1]) ) { - return 0; - } - err = _common_set_uint8_array(self, - self->eeprom_map_p->addr_rx_em, - self->eeprom_map_p->page_rx_em, - self->eeprom_map_p->offset_rx_em, - self->eeprom_map_p->length_rx_em, - setv, - self->rx_em, - "_qsfp_set_rx_em", - show_e); - if (err < 0) { - emsg = "set_uint8_array fail"; - goto err_qsfp_set_rx_em; - } - return 0; - -err_qsfp_set_rx_em: - if (show_e) { - SWPS_INFO("%s: %s :%d\n", __func__, emsg, input); - } - return err; -} - - -int -_qsfp_set_rx_em(struct transvr_obj_s *self, - int input, - int show_e) { - - int i = 0; - int retry = 3; - uint8_t tmp[2]; - - for (i=0; irx_em[0]; - tmp[1] = self->rx_em[1]; - if (_qsfp_update_attr_rx_em(self, show_e) < 0){ - continue; - } - if ((self->rx_em[0] == tmp[0]) && - (self->rx_em[1] == tmp[1]) ){ - return 0; - } - } - return -1; -} - - -int -qsfp_set_rx_em(struct transvr_obj_s *self, - int input) { - - int err = _check_by_mode(self, - &_qsfp_update_attr_rx_em, - "qsfp_set_rx_em"); - if (err < 0) { - SWPS_DEBUG("%s: check fail :%d\n", __func__, err); - return err; - } - return _qsfp_set_rx_em(self, input, 1); -} - - -int -common_transvr_dump(struct transvr_obj_s* self){ - - char *type_name = "Undefined"; - - if (TRANSVR_INFO_DUMP_ENABLE != 1) { - return 0; - } - switch (self->type) { - case TRANSVR_TYPE_SFP: - type_name = STR_TRANSVR_SFP; - break; - case TRANSVR_TYPE_QSFP: - type_name = STR_TRANSVR_QSFP; - break; - case TRANSVR_TYPE_QSFP_PLUS: - type_name = STR_TRANSVR_QSFP_PLUS; - break; - case TRANSVR_TYPE_QSFP_28: - type_name = STR_TRANSVR_QSFP28; - break; - case TRANSVR_TYPE_FAKE: - type_name = "FAKE"; - goto ok_common_transvr_dump; - case TRANSVR_TYPE_UNPLUGGED: - type_name = "UNPLUGGED"; - goto err_common_transvr_dump; - case TRANSVR_TYPE_INCONSISTENT: - type_name = "INCONSISTENT"; - goto err_common_transvr_dump; - case TRANSVR_TYPE_ERROR: - type_name = "ERROR"; - goto err_common_transvr_dump; - - default: - type_name = "UNEXPECTED"; - goto err_common_transvr_dump; - } - printk(KERN_INFO "[SWPS] Dump %s information:\n", self->swp_name); - printk(KERN_INFO " |- :%s\n", type_name); - printk(KERN_INFO " |- :%s\n", self->vendor_name); - printk(KERN_INFO " |- :%s\n", self->vendor_pn); - printk(KERN_INFO " |- :%s\n", self->vendor_rev); - printk(KERN_INFO " |- :%s\n", self->vendor_sn); - printk(KERN_INFO " |- :0x%02x\n", self->br); - printk(KERN_INFO " |- :0x%02x\n", self->comp_rev); - printk(KERN_INFO " |- :%d\n", self->len_om1); - printk(KERN_INFO " |- :%d\n", self->len_om2); - printk(KERN_INFO " |- :%d\n", self->len_om3); - printk(KERN_INFO " |- :%d\n", self->len_om4); - return 0; - -ok_common_transvr_dump: - SWPS_INFO("%s: %s is %s\n", __func__, self->swp_name, type_name); - return 0; - -err_common_transvr_dump: - SWPS_INFO("%s: %s is %s\n", __func__, self->swp_name, type_name); - return -1; -} - - -int -sfp_transvr_dump(struct transvr_obj_s* self) { - - if (TRANSVR_INFO_DUMP_ENABLE != 1) { - return 0; - } - if (common_transvr_dump(self) < 0) { - return -1; - } - printk(KERN_INFO " |- :%d\n", self->len_sm); - printk(KERN_INFO " |- :%d\n", self->len_smf); - printk(KERN_INFO " '- :0x%02x\n", self->rate_id); - return 0; -} - - -int -qsfp_transvr_dump(struct transvr_obj_s* self) { - - if (TRANSVR_INFO_DUMP_ENABLE != 1) { - return 0; - } - if (common_transvr_dump(self) < 0) { - return -1; - } - printk(KERN_INFO " |- :%d\n", self->len_smf); - printk(KERN_INFO " '- :Class_%d\n", __qsfp_get_power_cls(self, 0)); - return 0; -} - - -int -fake_transvr_dump(struct transvr_obj_s* self) { - - printk(KERN_INFO "[SWPS] Dump transceiver information: %s\n", self->swp_name); - printk(KERN_INFO " |- :FAKE\n"); - printk(KERN_INFO " |- :FAKE_VENDER_NAME\n"); - printk(KERN_INFO " |- :FAKE_VENDER_PN\n"); - printk(KERN_INFO " |- :FAKE_VENDER_REV\n"); - printk(KERN_INFO " |- :FAKE_VENDER_SN\n"); - printk(KERN_INFO " |- :0x99\n"); - printk(KERN_INFO " |- :99\n"); - printk(KERN_INFO " |- :99\n"); - printk(KERN_INFO " |- :99\n"); - printk(KERN_INFO " |- :99\n"); - printk(KERN_INFO " |- :99\n"); - printk(KERN_INFO " |- :99\n"); - printk(KERN_INFO " '- :0x99\n"); - return 0; -} - - -/* ========== Object functions for fake type ========== - */ -int -fake_transvr_update(struct transvr_obj_s *self, - int show_err){ - self->state = STATE_TRANSVR_CONNECTED; - return 0; -} - - -int -fake_get_binary(struct transvr_obj_s *self){ - return 1; -} - -int -fake_get_int(struct transvr_obj_s *self){ - return 99; -} - - -int -fake_get_hex(struct transvr_obj_s *self){ - return 0x0f; -} - - -int -fake_get_str(struct transvr_obj_s *self, char *buf) { - return snprintf(buf, 16, "fake_get_str\n"); -} - - -int -fake_set_int(struct transvr_obj_s *self, int input){ - SWPS_INFO("%s: %d\n", __func__, input); - return 0; -} - - -int -fake_set_hex(struct transvr_obj_s *self, int input){ - SWPS_INFO("%s: 0x%02x\n", __func__, input); - return 0; -} - - -/* ========== Object functions for unsupported ========== - */ -int -unsupported_get_func(struct transvr_obj_s *self){ - return ERR_TRANSVR_NOTSUPPORT; -} - - -int -unsupported_get_func2(struct transvr_obj_s *self, - char *buf_p) { - int len = snprintf(buf_p, 8, "%d\n", ERR_TRANSVR_NOTSUPPORT); - return len; -} - - -int -unsupported_set_func(struct transvr_obj_s *self, - int input_val){ - return ERR_TRANSVR_NOTSUPPORT; -} - - - -/* ========== Object functions for long term task ========== - * - * [Note] - * SWPS transceiver worker is likely the green-thread (coroutine). - * Due to resource and performance considerations. SWPS run all - * features in one kthread at the same time, and handle by it self. - */ - -/* For Transceiver Task Handling - */ -static struct transvr_worker_s * -transvr_task_get(struct transvr_obj_s *self, - char *func_name) { - - struct transvr_worker_s *curr_p = self->worker_p; - - while(curr_p != NULL){ - if (strcmp((curr_p->func_name), func_name) == 0 ) { - return curr_p; - } - curr_p = curr_p->next_p; - } - return NULL; -} - - -static struct transvr_worker_s* -transvr_task_creat(struct transvr_obj_s *self, - int (*main_task)(struct transvr_worker_s *task), - int (*post_task)(struct transvr_worker_s *task), - char *caller) { - - struct transvr_worker_s *task_p = NULL; - struct transvr_worker_s *curr_p = NULL; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - - /* Check task not exist */ - task_p = transvr_task_get(self, caller); - if (task_p) { - snprintf(err_msg, sizeof(err_msg), "Task already created!"); - goto err_transvr_task_creat; - } - /* Create task worker */ - task_p = kzalloc(sizeof(struct transvr_worker_s), GFP_KERNEL); - if (!task_p){ - snprintf(err_msg, sizeof(err_msg), "kzalloc fail"); - goto err_transvr_task_creat; - } - /* Setup task data */ - task_p->transvr_p = self; - task_p->next_p = NULL; - task_p->trigger_time = 0; - task_p->retry = 1; - task_p->state = STATE_T_TASK_INIT; - task_p->main_task = main_task; - task_p->post_task = post_task; - task_p->p_data = NULL; - snprintf(task_p->func_name, sizeof(task_p->func_name), "%s", caller); - /* Setup Link List */ - if (self->worker_p) { - curr_p = self->worker_p; - while(curr_p->next_p != NULL) { - curr_p = curr_p->next_p; - } - curr_p->next_p = task_p; - task_p->pre_p = curr_p; - } else { - self->worker_p = task_p; - task_p->pre_p = NULL; - } - return task_p; - -err_transvr_task_creat: - SWPS_ERR("%s: %s :%s :%s\n", - __func__, err_msg, caller, self->swp_name); - return NULL; -} - - -static void -transvr_task_free_one(struct transvr_worker_s *task_p){ - - struct transvr_worker_s *pre_p = NULL; - struct transvr_worker_s *next_p = NULL; - - if (task_p) { - pre_p = task_p->pre_p; - next_p = task_p->next_p; - - if ((pre_p) && (next_p)) { - pre_p->next_p = next_p; - next_p->pre_p = pre_p; - - } else if ((!pre_p) && (next_p)) { - next_p->pre_p = NULL; - - } else if ((pre_p) && (!next_p)) { - pre_p->next_p = NULL; - - } else if ((!pre_p) && (!next_p)) { - task_p->transvr_p->worker_p = NULL; - } else { - SWPS_ERR("%s: Unexcept case!\n :%s", - __func__, task_p->transvr_p->swp_name); - } - kfree(task_p->p_data); - kfree(task_p); - } -} - - -static void -transvr_task_free_all(struct transvr_obj_s *self) { - - struct transvr_worker_s *curr_p = NULL; - struct transvr_worker_s *next_p = NULL; - - if (self->worker_p) { - curr_p = self->worker_p; - while(curr_p) { - next_p = curr_p->next_p; - transvr_task_free_one(curr_p); - curr_p = next_p; - } - self->worker_p = NULL; - } -} - - -static int -_transvr_task_run_main(struct transvr_worker_s *task_p) { - - int retval = DEBUG_TRANSVR_INT_VAL; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - - if (!task_p){ - snprintf(err_msg, sizeof(err_msg), "main_task is NULL!"); - goto main_transvr_task_err; - } - if ((task_p->trigger_time) == 0){ - goto main_transvr_task_run; - } - if (time_before(jiffies, task_p->trigger_time)){ - goto main_transvr_task_wait; - } - goto main_transvr_task_run; - -main_transvr_task_run: - if (task_p->retry != VAL_TRANSVR_TASK_RETRY_FOREVER) { - task_p->retry -= 1; - } - retval = task_p->main_task(task_p); - if (retval < 0) { - if (task_p->retry > 0) { - task_p->state = STATE_T_TASK_WAIT; - return EVENT_TRANSVR_TASK_WAIT; - } - snprintf(err_msg, sizeof(err_msg), "Run main_task fail!"); - goto main_transvr_task_err; - } - goto main_transvr_task_identify; - -main_transvr_task_identify: - switch (retval) { - case EVENT_TRANSVR_TASK_WAIT: - task_p->state = STATE_T_TASK_WAIT; - return EVENT_TRANSVR_TASK_WAIT; - - case EVENT_TRANSVR_TASK_DONE: - task_p->state = STATE_T_TASK_DONE; - return EVENT_TRANSVR_TASK_DONE; - - default: - break; - } - snprintf(err_msg, sizeof(err_msg), "Run main_task fail!"); - goto main_transvr_task_err; - -main_transvr_task_wait: - task_p->state = STATE_T_TASK_WAIT; - return EVENT_TRANSVR_TASK_WAIT; - -main_transvr_task_err: - task_p->state = STATE_T_TASK_FAIL; - SWPS_INFO("%s: %s :%d :%s\n", - __func__, err_msg, retval, task_p->transvr_p->swp_name); - return EVENT_TRANSVR_INIT_FAIL; -} - - -static int -_transvr_task_run_post(struct transvr_worker_s *task_p) { - - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - - if ((task_p->post_task) == NULL) { - return EVENT_TRANSVR_TASK_DONE; - } - switch (task_p->state) { - case STATE_T_TASK_WAIT: - case STATE_T_TASK_INIT: - goto post_transvr_task_wait; - - case STATE_T_TASK_DONE: - case STATE_T_TASK_FAIL: - goto post_transvr_task_run; - - default: - break; - } - snprintf(err_msg, sizeof(err_msg), "Unexcept task state"); - goto post_transvr_task_err; - -post_transvr_task_run: - task_p->post_task(task_p); - return EVENT_TRANSVR_TASK_DONE; - -post_transvr_task_wait: - return EVENT_TRANSVR_TASK_WAIT; - -post_transvr_task_err: - SWPS_INFO("%s: %s :%d :%s\n", - __func__, err_msg, task_p->state, task_p->transvr_p->swp_name); - return EVENT_TRANSVR_TASK_FAIL; -} - - -static int -transvr_task_run_one(struct transvr_worker_s *task_p) { - - int retval_main = DEBUG_TRANSVR_INT_VAL; - int retval_post = DEBUG_TRANSVR_INT_VAL; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - - retval_main = _transvr_task_run_main(task_p); - if (retval_main < 0) { - snprintf(err_msg, sizeof(err_msg), "Execute main_task fail!"); - goto err_transvr_task_run_one; - } - retval_post = _transvr_task_run_post(task_p); - if (retval_post < 0) { - snprintf(err_msg, sizeof(err_msg), "Execute post_task fail!"); - goto err_transvr_task_run_one; - } - return retval_main; - -err_transvr_task_run_one: - SWPS_INFO("%s: %s
:%d :%d :%s :%s\n", - __func__, err_msg, retval_main, retval_post, - task_p->func_name, task_p->transvr_p->swp_name); - return EVENT_TRANSVR_TASK_FAIL; -} - - -static int -transvr_task_run_all(struct transvr_obj_s *self) { - - int haserr = 0; - int retval = DEBUG_TRANSVR_INT_VAL; - struct transvr_worker_s *curr_p = NULL; - struct transvr_worker_s *next_p = NULL; - - if ((self->worker_p) == NULL) { - return EVENT_TRANSVR_TASK_DONE; - } - curr_p = self->worker_p; - while (curr_p != NULL) { - next_p = curr_p->next_p; - retval = transvr_task_run_one(curr_p); - if (curr_p->retry == VAL_TRANSVR_TASK_RETRY_FOREVER) { - curr_p = next_p; - continue; - } - switch (retval) { - case EVENT_TRANSVR_TASK_WAIT: - break; - case EVENT_TRANSVR_TASK_DONE: - transvr_task_free_one(curr_p); - break; - case EVENT_TRANSVR_TASK_FAIL: - - default: - haserr = 1; - transvr_task_free_one(curr_p); - break; - } - curr_p = next_p; - } - if (haserr) { - return EVENT_TRANSVR_TASK_FAIL; - } - return EVENT_TRANSVR_TASK_DONE; -} - - -static void -transvr_task_set_delay(struct transvr_worker_s *task_p, - unsigned long delay_msec) { - - task_p->trigger_time = (jiffies + (delay_msec * (HZ/1000))); -} - - -static void -transvr_task_set_retry(struct transvr_worker_s *task_p, - unsigned long retry_times) { - - task_p->retry = retry_times; -} - - -/* For Transceiver Post Task - */ -int -taskfunc_post_do_nothing(struct transvr_worker_s *task_p) { - - return EVENT_TRANSVR_TASK_DONE; -} - - -int -taskfunc_post_handle_task_state(struct transvr_worker_s *task_p) { - - struct transvr_obj_s* tp = task_p->transvr_p; - - switch (task_p->state) { - case STATE_T_TASK_INIT: - case STATE_T_TASK_WAIT: - return EVENT_TRANSVR_TASK_WAIT; - - case STATE_T_TASK_DONE: - tp->state = STATE_TRANSVR_CONNECTED; - tp->send_uevent(tp, KOBJ_ADD); - return EVENT_TRANSVR_TASK_DONE; - - case STATE_T_TASK_FAIL: - tp->state = STATE_TRANSVR_UNEXCEPTED; - return EVENT_TRANSVR_TASK_FAIL; - - default: - break; - } - return EVENT_TRANSVR_TASK_FAIL; -} - - -/* For Transceiver Main Task - */ -int -_taskfunc_sfp_setup_soft_rs(struct transvr_worker_s *task_p, - int input_val, - int address, - int page, - int offset, - int bit_shift, - uint8_t *attr_p, - char *caller) { - - int show_err = 0; - int err_code = DEBUG_TRANSVR_INT_VAL; - char *err_str = DEBUG_TRANSVR_STR_VAL; - char *func_str = "_taskfunc_sfp_setup_soft_rs"; - - err_code = _sfp_update_attr_soft_rs0(task_p->transvr_p, 0); - if (err_code < 0) { - err_str = "Get current soft_rs0 fail!"; - goto err_taskfunc_sfp_setup_soft_rs_1; - } - err_code = __sfp_set_soft_rs(task_p->transvr_p, - input_val, - address, - page, - offset, - bit_shift, - attr_p, - caller, - show_err); - if (err_code < 0) { - err_str = "Get current soft_rs0 fail!"; - goto err_taskfunc_sfp_setup_soft_rs_1; - } - return EVENT_TRANSVR_TASK_DONE; - -err_taskfunc_sfp_setup_soft_rs_1: - if ((task_p->retry) == 0) { - SWPS_INFO("%s: %s :%s :%d :%d\n", - func_str, err_str, task_p->transvr_p->swp_name, input_val, err_code); - } - return EVENT_TRANSVR_TASK_FAIL; -} - - -int -__taskfunc_sfp_setup_hard_rs(struct transvr_worker_s *task_p, - int input_val, - int (*get_func)(struct ioexp_obj_s *self, int virt_offset), - int (*set_func)(struct ioexp_obj_s *self, int virt_offset, int input_val)) { - - int err_val = EVENT_TRANSVR_EXCEP_EXCEP; - char *err_str = DEBUG_TRANSVR_STR_VAL; - - err_val = get_func(task_p->transvr_p->ioexp_obj_p, - task_p->transvr_p->ioexp_virt_offset); - - if (err_val < 0) { - if (err_val == ERR_IOEXP_NOTSUPPORT) { - return EVENT_TRANSVR_TASK_DONE; - } - err_str = "Get current hard_rs fail!"; - goto err_p_taskfunc_sfp_setup_hard_rs_1; - } - if (err_val == input_val) { - return EVENT_TRANSVR_TASK_DONE; - } - err_val = set_func(task_p->transvr_p->ioexp_obj_p, - task_p->transvr_p->ioexp_virt_offset, - input_val); - if (err_val < 0) { - err_str = "Setup hard_rs fail!"; - goto err_p_taskfunc_sfp_setup_hard_rs_1; - } - return EVENT_TRANSVR_TASK_DONE; - -err_p_taskfunc_sfp_setup_hard_rs_1: - if ((task_p->retry) == 0) { - SWPS_INFO("%s: %s :%s :%d :%d\n", - __func__, err_str, task_p->transvr_p->swp_name, input_val, err_val); - } - return EVENT_TRANSVR_TASK_FAIL; -} - - -int -_taskfunc_sfp_setup_hard_rs0(struct transvr_worker_s *task_p, - int input_val) { - - return __taskfunc_sfp_setup_hard_rs(task_p, - input_val, - task_p->transvr_p->ioexp_obj_p->get_hard_rs0, - task_p->transvr_p->ioexp_obj_p->set_hard_rs0); -} - - -int -_taskfunc_sfp_setup_hard_rs1(struct transvr_worker_s *task_p, - int input_val) { - - return __taskfunc_sfp_setup_hard_rs(task_p, - input_val, - task_p->transvr_p->ioexp_obj_p->get_hard_rs1, - task_p->transvr_p->ioexp_obj_p->set_hard_rs1); -} - - -int -_taskfunc_sfp_setup_rs0(struct transvr_worker_s *task_p, - int input_val) { - - int bit_shift = 3; - int old_val = DEBUG_TRANSVR_INT_VAL; - int err_val = EVENT_TRANSVR_EXCEP_EXCEP; - char *err_str = DEBUG_TRANSVR_STR_VAL; - char *func_str = "_taskfunc_sfp_setup_rs0"; - - err_val = _taskfunc_sfp_setup_hard_rs0(task_p, - input_val); - if (err_val < 0) { - err_str = "Setup hard_rs0 fail!"; - goto err_private_taskfunc_sfp_setup_rs0_1; - } - old_val = err_val; - err_val = _taskfunc_sfp_setup_soft_rs(task_p, - input_val, - task_p->transvr_p->eeprom_map_p->addr_soft_rs0, - task_p->transvr_p->eeprom_map_p->page_soft_rs0, - task_p->transvr_p->eeprom_map_p->offset_soft_rs0, - bit_shift, - &(task_p->transvr_p->soft_rs0), - func_str); - if (err_val < 0) { - err_str = "Setup soft_rs0 fail!"; - goto err_private_taskfunc_sfp_setup_rs0_1; - } - return EVENT_TRANSVR_TASK_DONE; - -err_private_taskfunc_sfp_setup_rs0_1: - if ((task_p->retry) == 0) { - SWPS_INFO("%s: %s :%s :%d :%d\n", - func_str, err_str, task_p->transvr_p->swp_name, input_val, err_val); - } - _taskfunc_sfp_setup_hard_rs0(task_p, old_val); - return EVENT_TRANSVR_TASK_FAIL; -} - - -int -_taskfunc_sfp_setup_rs1(struct transvr_worker_s *task_p, - int input_val) { - - int bit_shift = 3; - int old_val = DEBUG_TRANSVR_INT_VAL; - int err_val = EVENT_TRANSVR_EXCEP_EXCEP; - char *err_str = DEBUG_TRANSVR_STR_VAL; - char *func_str = "_taskfunc_sfp_setup_rs1"; - - err_val = _taskfunc_sfp_setup_hard_rs1(task_p, - input_val); - if (err_val < 0) { - err_str = "Setup hard_rs1 fail!"; - goto err_private_taskfunc_sfp_setup_rs1_1; - } - old_val = err_val; - err_val = _taskfunc_sfp_setup_soft_rs(task_p, - input_val, - task_p->transvr_p->eeprom_map_p->addr_soft_rs1, - task_p->transvr_p->eeprom_map_p->page_soft_rs1, - task_p->transvr_p->eeprom_map_p->offset_soft_rs1, - bit_shift, - &(task_p->transvr_p->soft_rs1), - func_str); - if (err_val < 0) { - err_str = "Setup soft_rs1 fail!"; - goto err_private_taskfunc_sfp_setup_rs1_1; - } - return EVENT_TRANSVR_TASK_DONE; - -err_private_taskfunc_sfp_setup_rs1_1: - if ((task_p->retry) == 0) { - SWPS_INFO("%s: %s :%s :%d :%d\n", - func_str, err_str, task_p->transvr_p->swp_name, input_val, err_val); - } - _taskfunc_sfp_setup_hard_rs1(task_p, old_val); - return EVENT_TRANSVR_TASK_FAIL; -} - - -int -taskfunc_sfp_setup_SFF8431_case1(struct transvr_worker_s *task_p) { - /* SFF-8431 (8/4/2G Rx Rate_Select only) */ - int update_val = 1; - - return _taskfunc_sfp_setup_rs0(task_p, update_val); -} - - - -int -taskfunc_sfp_setup_SFF8431_case2(struct transvr_worker_s *task_p) { - /* SFF-8431 (8/4/2G Tx Rate_Select only) */ - int update_val = 1; - - return _taskfunc_sfp_setup_rs1(task_p, update_val); -} - - -int -taskfunc_sfp_setup_SFF8431_case3(struct transvr_worker_s *task_p) { - /* SFF-8431 (8/4/2G Independent Rx & Tx Rate_select) */ - int update_rs0 = 1; - int update_rs1 = 1; - int err_code = DEBUG_TRANSVR_INT_VAL; - - err_code = _taskfunc_sfp_setup_rs0(task_p, update_rs0); - if (err_code < 0) { - return err_code; - } - return _taskfunc_sfp_setup_rs1(task_p, update_rs1); -} - - -int -taskfunc_sfp_handle_1g_rj45(struct transvr_worker_s *task_p) { - - /* Not all of platform support 0x56 for transceiver - * external PHY, Support list as below: - * => 1. Magnolia-PVT (PS: EVT & DVT not ready) - */ - int ext_phy_addr = 0x56; - int ext_phy_page = -1; - int ext_phy_offs = 0x11; - int ext_phy_len = 1; - int lstate_mask = 0x04; /* 00000100 */ - int show_err = 0; - int fail_retry = 5; - int fail_delay = 1000; /* msec */ - int err_code = DEBUG_TRANSVR_INT_VAL; - uint8_t detect_val = DEBUG_TRANSVR_HEX_VAL; - char err_str[64] = DEBUG_TRANSVR_STR_VAL; - int *tmp_p = NULL; - char *func_name = "taskfunc_sfp_handle_1g_rj45"; - - if (task_p->transvr_p->state != STATE_TRANSVR_CONNECTED) { - return EVENT_TRANSVR_TASK_DONE; - } - if ( (task_p->transvr_p->info != TRANSVR_CLASS_BASE_T_1000) && - (task_p->transvr_p->info != TRANSVR_CLASS_BASE_T_1000_up) ) { - goto err_taskfunc_sfp_handle_1g_rj45_1; - } - err_code = _common_update_uint8_attr(task_p->transvr_p, - ext_phy_addr, - ext_phy_page, - ext_phy_offs, - ext_phy_len, - &detect_val, - func_name, - show_err); - if ( (err_code < 0) || - (detect_val == DEBUG_TRANSVR_HEX_VAL) ) { - snprintf(err_str, sizeof(err_str), "Detect external link status fail"); - goto err_taskfunc_sfp_handle_1g_rj45_2; - } - if ((detect_val & lstate_mask) == lstate_mask) { - goto ok_taskfunc_sfp_handle_1g_rj45_link_up; - } - goto ok_taskfunc_sfp_handle_1g_rj45_link_down; - -ok_taskfunc_sfp_handle_1g_rj45_link_up: - /* Filter out noise */ - if (!(task_p->p_data)) { - tmp_p = kzalloc(sizeof(int), GFP_KERNEL); - if (!tmp_p) { - snprintf(err_str, sizeof(err_str), "kzalloc p_data fail"); - goto err_taskfunc_sfp_handle_1g_rj45_2; - } - *tmp_p = TRANSVR_CLASS_BASE_T_1000_up; - task_p->p_data = tmp_p; - goto ok_taskfunc_sfp_handle_1g_rj45_done; - } - if ((*(int *)(task_p->p_data)) != TRANSVR_CLASS_BASE_T_1000_up) { - kfree(task_p->p_data); - task_p->p_data = NULL; - snprintf(err_str, sizeof(err_str), "Internal error"); - goto err_taskfunc_sfp_handle_1g_rj45_2; - } - task_p->transvr_p->info = TRANSVR_CLASS_BASE_T_1000_up; - kfree(task_p->p_data); - task_p->p_data = NULL; - goto ok_taskfunc_sfp_handle_1g_rj45_done; - -ok_taskfunc_sfp_handle_1g_rj45_link_down: - if (task_p->p_data) { - kfree(task_p->p_data); - task_p->p_data = NULL; - } - task_p->transvr_p->info = TRANSVR_CLASS_BASE_T_1000; - goto ok_taskfunc_sfp_handle_1g_rj45_done; - -ok_taskfunc_sfp_handle_1g_rj45_done: - if (task_p->retry != VAL_TRANSVR_TASK_RETRY_FOREVER) { - transvr_task_set_retry(task_p, VAL_TRANSVR_TASK_RETRY_FOREVER); - } - return EVENT_TRANSVR_TASK_DONE; - -err_taskfunc_sfp_handle_1g_rj45_1: - snprintf(err_str, sizeof(err_str), "Detect transceiver:%d not Base-T, remove task.", - task_p->transvr_p->info); - SWPS_INFO("%s: %s :%s\n", __func__, err_str, task_p->transvr_p->swp_name); - transvr_task_set_retry(task_p, 0); - return EVENT_TRANSVR_TASK_DONE; - -err_taskfunc_sfp_handle_1g_rj45_2: - if (task_p->retry == VAL_TRANSVR_TASK_RETRY_FOREVER) { - transvr_task_set_retry(task_p, fail_retry); - } - if ((task_p->retry) == 0) { - /* Error case: - * => In this case, SWPS will stop external Link state monitor features - * and keeps transvr_p->info on TRANSVR_CLASS_BASE_T_1000_up. - * Upper layer will see it always Linkup that because of these type of - * transceiver has external phy, BCM chip see it as Loopback transceiver. - */ - SWPS_WARN("%s can not access external PHY of Base-T SFP transceiver\n", - task_p->transvr_p->swp_name); - task_p->transvr_p->info = TRANSVR_CLASS_BASE_T_1000_up; - return EVENT_TRANSVR_TASK_DONE; - } else { - transvr_task_set_delay(task_p, fail_delay); - } - return EVENT_TRANSVR_TASK_FAIL; -} - - -int -_taskfunc_qsfp_setup_power_mod(struct transvr_obj_s *self, - int setup_val) { - - int curr_val = DEBUG_TRANSVR_INT_VAL; - int err_val = DEBUG_TRANSVR_INT_VAL; - char *err_msg = DEBUG_TRANSVR_STR_VAL; - - curr_val = self->ioexp_obj_p->get_lpmod(self->ioexp_obj_p, - self->ioexp_virt_offset); - if (curr_val < 0){ - err_msg = "Get current value fail!"; - goto err_private_taskfunc_qsfp_setup_power_mod_1; - } - if (curr_val == setup_val){ - return EVENT_TRANSVR_TASK_DONE; - } - err_val = self->ioexp_obj_p->set_lpmod(self->ioexp_obj_p, - self->ioexp_virt_offset, - setup_val); - if (err_val < 0){ - err_msg = "Setup power mode fail!"; - goto err_private_taskfunc_qsfp_setup_power_mod_1; - } - return EVENT_TRANSVR_TASK_DONE; - -err_private_taskfunc_qsfp_setup_power_mod_1: - SWPS_INFO("%s: %s :%d :%d :%d\n", - __func__, err_msg, err_val, curr_val, setup_val); - return EVENT_TRANSVR_TASK_FAIL; -} - - -int -taskfunc_qsfp_handle_tx_disable(struct transvr_worker_s *task_p) { - - int i = 0; - int retry = 5; - int delay_ms = 100; - - if (task_p->transvr_p->auto_tx_disable == VAL_TRANSVR_FUNCTION_DISABLE) { - return EVENT_TRANSVR_TASK_DONE; - } - if (!_qsfp_is_implement_tx_disable(task_p->transvr_p)) { - return EVENT_TRANSVR_TASK_DONE; - } - for (i=0; itransvr_p, - task_p->transvr_p->auto_tx_disable) - == EVENT_TRANSVR_TASK_DONE) { - goto ok_taskfunc_qsfp_handle_tx_disable; - } - mdelay(delay_ms); - } - SWPS_INFO("%s auto setup tx_disable:0x%02x fail.\n", - task_p->transvr_p->swp_name, - task_p->transvr_p->auto_tx_disable); - return EVENT_TRANSVR_INIT_FAIL; - -ok_taskfunc_qsfp_handle_tx_disable: - SWPS_INFO("%s auto setup tx_disable:0x%02x ok.\n", - task_p->transvr_p->swp_name, - task_p->transvr_p->auto_tx_disable); - return EVENT_TRANSVR_TASK_DONE; -} - - -int -taskfunc_qsfp_set_hpmod(struct transvr_worker_s *task_p) { - - int err = DEBUG_TRANSVR_INT_VAL; - int HIGH_POWER_MODE = 0; - - /* Handle power mode */ - err = _taskfunc_qsfp_setup_power_mod(task_p->transvr_p, - HIGH_POWER_MODE); - if (err < 0) { - SWPS_INFO("%s: setup hpmod fail :%d :%s\n", - __func__, err, task_p->transvr_p->swp_name); - return err; - } - /* Handle auto tx_disable - * [Note] - * => Because there are some transceiver have timing issues or - * setup sequence issues, therefore we handle auto tx_disable - * after handle power mode. - */ - mdelay(100); - return taskfunc_qsfp_handle_tx_disable(task_p); -} - - -int -taskfunc_qsfp_set_lpmod(struct transvr_worker_s *task_p) { - - int LOW_POWER_MODE = 1; - return _taskfunc_qsfp_setup_power_mod(task_p->transvr_p, - LOW_POWER_MODE); -} - - -static int -initfunc_sfp_handle_multi_rate_mode(struct transvr_obj_s *self) { - - int task_retry = 3; - int err_code = DEBUG_TRANSVR_INT_VAL; - char *err_str = DEBUG_TRANSVR_STR_VAL; - char *func_str = "sfp_handle_multi_rate_mode"; - struct transvr_worker_s *task_p = NULL; - - switch (self->rate_id) { - case 0x00: /* Unspecified */ - case 0x03: /* Unspecified */ - case 0x05: /* Unspecified */ - case 0x07: /* Unspecified */ - case 0x09: /* Unspecified */ - case 0x0B: /* Unspecified */ - case 0x0D: /* Unspecified */ - case 0x0F: /* Unspecified */ - goto sfp_handle_multi_rate_mode_4_unspecified; - - case 0x02: /* SFF-8431 (8/4/2G Rx Rate_Select only) */ - task_p = transvr_task_creat(self, - taskfunc_sfp_setup_SFF8431_case1, - taskfunc_post_handle_task_state, - func_str); - goto sfp_handle_multi_rate_mode_4_sff8431; - - case 0x04: /* SFF-8431 (8/4/2G Tx Rate_Select only) */ - task_p = transvr_task_creat(self, - taskfunc_sfp_setup_SFF8431_case2, - taskfunc_post_handle_task_state, - func_str); - goto sfp_handle_multi_rate_mode_4_sff8431; - - case 0x06: /* SFF-8431 (8/4/2G Independent Rx & Tx Rate_select) */ - task_p = transvr_task_creat(self, - taskfunc_sfp_setup_SFF8431_case3, - taskfunc_post_handle_task_state, - func_str); - goto sfp_handle_multi_rate_mode_4_sff8431; - - case 0x01: /* SFF-8079 (4/2/1G Rate_Select & AS0/AS1) */ - err_str = "SFF-8079 (4/2/1G Rate_Select & AS0/AS1)"; - goto sfp_handle_multi_rate_mode_4_not_support; - - case 0x08: /* FC-PI-5 (16/8/4G Rx Rate_select only) - * High=16G only, Low=8G/4G - */ - err_str = "FC-PI-5 (16/8/4G Rx Rate_select only)"; - goto sfp_handle_multi_rate_mode_4_not_support; - - case 0x0A: /* FC-PI-5 (16/8/4G Independent Rx, Tx Rate_select) - * High=16G only, Low=8G/4G - */ - err_str = "FC-PI-5 (16/8/4G Independent Rx, Tx Rate_select)"; - goto sfp_handle_multi_rate_mode_4_not_support; - - case 0x0C: /* FC-PI-6 (32/16/8G Independent Rx, Tx Rate_Select) - * High=32G only, Low = 16G/8G - */ - err_str = "FC-PI-6 (32/16/8G Independent Rx, Tx Rate_Select)"; - goto sfp_handle_multi_rate_mode_4_not_support; - - case 0x0E: /* 10/8G Rx and Tx Rate_Select controlling the operation or - * locking modes of the internal signal conditioner, retimer - * or CDR, according to the logic table defined in Table 10-2, - * High Bit Rate (10G) =9.95-11.3 Gb/s; Low Bit Rate (8G) = - * 8.5 Gb/s. In this mode, the default value of bit 110.3 (Soft - * Rate Select RS(0), Table 9-11) and of bit 118.3 (Soft Rate - * Select RS(1), Table 10-1) is 1. - */ - err_str = "cable type: 0x0E"; - goto sfp_handle_multi_rate_mode_4_not_support; - - default: - err_str = "cable type: UNKNOW"; - goto sfp_handle_multi_rate_mode_4_not_support; - } - -sfp_handle_multi_rate_mode_4_sff8431: - if (!task_p) { - err_str = "Create task fail!"; - goto sfp_handle_multi_rate_mode_4_fail_1; - } - transvr_task_set_retry(task_p, task_retry); - return EVENT_TRANSVR_TASK_WAIT; - -sfp_handle_multi_rate_mode_4_unspecified: - return EVENT_TRANSVR_TASK_DONE; - -sfp_handle_multi_rate_mode_4_not_support: - SWPS_INFO("%s: Does not support %s :%s :0x%02x\n", - func_str, err_str, self->swp_name, self->rate_id); - return EVENT_TRANSVR_TASK_DONE; - -sfp_handle_multi_rate_mode_4_fail_1: - SWPS_INFO("%s: %s :%s :0x%02x, :%d\n", - func_str, err_str, self->swp_name, self->rate_id, err_code); - return EVENT_TRANSVR_INIT_FAIL; -} - - -static int -initfunc_sfp_handle_1g_rj45(struct transvr_obj_s *self) { - - struct transvr_worker_s *task_p = NULL; - int detect_cls = DEBUG_TRANSVR_INT_VAL; - char err_str[64] = DEBUG_TRANSVR_STR_VAL; - char *func_str = "initfunc_sfp_handle_1g_rj45"; - - - if (self->info == TRANSVR_CLASS_BASE_T_1000) { - task_p = transvr_task_creat(self, - taskfunc_sfp_handle_1g_rj45, - taskfunc_post_do_nothing, - func_str); - if (!task_p) { - snprintf(err_str, sizeof(err_str), "Create task fail"); - goto err_initfunc_sfp_handle_1g_rj45; - } - transvr_task_set_retry(task_p, VAL_TRANSVR_TASK_RETRY_FOREVER); - } - return EVENT_TRANSVR_TASK_DONE; - -err_initfunc_sfp_handle_1g_rj45: - SWPS_INFO("%s: %s :%s :%d\n", - __func__, err_str, self->swp_name, detect_cls); - return EVENT_TRANSVR_TASK_FAIL; -} - - -static int -initfunc_qsfp_handle_power_mode(struct transvr_obj_s *self) { - - int err_code = EVENT_TRANSVR_EXCEP_INIT; - int power_class = DEBUG_TRANSVR_INT_VAL; - int hpmod_retry = 3; - int lpower_config = 1; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - unsigned long hpmod_delay = 500; /* msec */ - struct transvr_worker_s *task_p = NULL; - - /* Handle power mode for IOEXP */ - power_class = __qsfp_get_power_cls(self, 0); - switch (power_class) { - case 1: /* Case: Low power mode (Class = 1) */ - err_code = _taskfunc_qsfp_setup_power_mod(self, lpower_config); - if (err_code < 0){ - snprintf(err_msg, sizeof(err_msg), "Setup lpmod fail :%d", err_code); - goto err_initfunc_qsfp_handle_power_mode; - } - return EVENT_TRANSVR_TASK_DONE; - - case 2: /* Case: High power mode (Class > 1) */ - case 3: - case 4: - case 5: - case 6: - case 7: - task_p = transvr_task_creat(self, - taskfunc_qsfp_set_hpmod, - taskfunc_post_handle_task_state, - "transvr_init_qsfp"); - if (!task_p) { - snprintf(err_msg, sizeof(err_msg), "Setup lpmod fail :%d", err_code); - goto err_initfunc_qsfp_handle_power_mode; - } - transvr_task_set_retry(task_p, hpmod_retry); - transvr_task_set_delay(task_p, hpmod_delay); - return EVENT_TRANSVR_TASK_WAIT; - - default: - break; - } - snprintf(err_msg, sizeof(err_msg), "Exception case"); - goto err_initfunc_qsfp_handle_power_mode; - -err_initfunc_qsfp_handle_power_mode: - SWPS_INFO("%s: %s :%s \n", __func__, err_msg, self->swp_name); - return EVENT_TRANSVR_INIT_FAIL; -} - - -int -initfunc_qsfp28_handle_cdr(struct transvr_obj_s *self) { - - uint8_t DEFAULT_VAL_CDR = 0xff; - int CDR_FUNC_EXISTED = 0x3; - int show_err = 1; - int err_val = EVENT_TRANSVR_TASK_FAIL; - char *err_msg = DEBUG_TRANSVR_STR_VAL; - char *func_str = "initfunc_qsfp28_handle_cdr"; - - err_val = __qsfp_get_cdr_present(self, 0); - if ( (err_val < 0) || - (err_val == DEBUG_TRANSVR_HEX_VAL) ) { - err_msg = "detect cdr_present fail!"; - goto err_taskfunc_qsfp_handle_cdr_1; - } - if (err_val == CDR_FUNC_EXISTED) { - err_val = _common_set_uint8_attr(self, - self->eeprom_map_p->addr_cdr, - self->eeprom_map_p->addr_cdr, - self->eeprom_map_p->offset_cdr, - DEFAULT_VAL_CDR, - &(self->cdr), - func_str, - show_err); - if (err_val < 0) { - err_msg = "set CDR fail!"; - goto err_taskfunc_qsfp_handle_cdr_1; - } - } - return EVENT_TRANSVR_TASK_DONE; - -err_taskfunc_qsfp_handle_cdr_1: - SWPS_INFO("%s: %s :%d :%s\n", - func_str, err_msg, err_val, self->swp_name); - return EVENT_TRANSVR_INIT_FAIL; -} - -/* ========== Object functions for Final State Machine ========== - */ -int -is_plugged(struct transvr_obj_s *self){ - - int limit = 63; - int present = DEBUG_TRANSVR_INT_VAL; - char emsg[64] = DEBUG_TRANSVR_STR_VAL; - struct ioexp_obj_s *ioexp_p = self->ioexp_obj_p; - - if (!ioexp_p) { - snprintf(emsg, limit, "ioexp_p is null!"); - goto err_is_plugged_1; - } - present = ioexp_p->get_present(ioexp_p, self->ioexp_virt_offset); - switch (present){ - case 0: - return 1; - case 1: - return 0; - case ERR_IOEXP_UNINIT: - snprintf(emsg, limit, "ioexp_p not ready!"); - goto err_is_plugged_1; - default: - if (ioexp_p->state == STATE_IOEXP_INIT){ - snprintf(emsg, limit, "ioexp_p not ready!"); - goto err_is_plugged_1; - } - break; - } - SWPS_INFO("%s: Exception case! :%d :%d\n", - __func__, present, ioexp_p->state); - return 0; - -err_is_plugged_1: - SWPS_DEBUG("%s: %s\n", __func__, emsg); - return 0; -} - - -static int -detect_transvr_type(struct transvr_obj_s* self){ - - int type = TRANSVR_TYPE_ERROR; - - self->i2c_client_p->addr = VAL_TRANSVR_COMID_ARREESS; - type = i2c_smbus_read_byte_data(self->i2c_client_p, - VAL_TRANSVR_COMID_OFFSET); - - /* Case: 1. Wait transceiver I2C module. - * 2. Transceiver I2C module failure. - * Note: 1. SFF allow maximum transceiver initial time is 2 second. So, there - * are exist some case that we need to wait transceiver. - * For these case, we keeps status on "TRANSVR_TYPE_UNPLUGGED", than - * state machine will keep trace with it. - * 2. There exist some I2C failure case we need to handle. Such as user - * insert the failure transceiver, or any reason cause it abnormal. - */ - if (type < 0){ - switch (type) { - case -EIO: - SWPS_DEBUG("%s: %s smbus return:-5 (I/O error)\n", - __func__, self->swp_name); - return TRANSVR_TYPE_UNPLUGGED; - case -ENXIO: - SWPS_DEBUG("%s: %s smbus return:-6 (No such device or address)\n", - __func__, self->swp_name); - return TRANSVR_TYPE_UNPLUGGED; - default: - break; - } - SWPS_INFO("%s: %s unexpected smbus return:%d \n", - __func__, self->swp_name, type); - return TRANSVR_TYPE_ERROR; - } - /* Identify valid transceiver type */ - switch (type){ - case TRANSVR_TYPE_SFP: - case TRANSVR_TYPE_QSFP: - case TRANSVR_TYPE_QSFP_PLUS: - case TRANSVR_TYPE_QSFP_28: - break; - case TRANSVR_TYPE_UNKNOW_1: - case TRANSVR_TYPE_UNKNOW_2: - type = TRANSVR_TYPE_UNKNOW_2; - break; - default: - SWPS_DEBUG("%s: unknow type:0x%02x \n", __func__, type); - type = TRANSVR_TYPE_ERROR; - break; - } - return type; -} - - -static int -detect_transvr_state(struct transvr_obj_s *self, - int result[2]){ - /* [return] [result-0] [result-1] - * 0 STATE_TRANSVR_CONNECTED TRANSVR_TYPE_FAKE - * 0 STATE_TRANSVR_DISCONNECTED TRANSVR_TYPE_UNPLUGGED - * 0 STATE_TRANSVR_ISOLATED TRANSVR_TYPE_ERROR - * 0 STATE_TRANSVR_INIT / - * 0 STATE_TRANSVR_SWAPPED - * 0 STATE_TRANSVR_CONNECTED - * ERR_TRNASVR_BE_ISOLATED STATE_TRANSVR_ISOLATED TRANSVR_TYPE_ERROR - * ERR_TRANSVR_I2C_CRASH STATE_TRANSVR_UNEXCEPTED TRANSVR_TYPE_ERROR - * ERR_TRANSVR_UNEXCPT STATE_TRANSVR_UNEXCEPTED TRANSVR_TYPE_UNKNOW_1/2 - */ - result[0] = STATE_TRANSVR_UNEXCEPTED; /* For return state */ - result[1] = TRANSVR_TYPE_ERROR; /* For return type */ - - /* Case1: Fake type */ - if (self->type == TRANSVR_TYPE_FAKE){ - result[0] = STATE_TRANSVR_CONNECTED; - result[1] = TRANSVR_TYPE_FAKE; - return 0; - } - /* Case2: Transceiver unplugged */ - if (!is_plugged(self)){ - result[0] = STATE_TRANSVR_DISCONNECTED; - result[1] = TRANSVR_TYPE_UNPLUGGED; - return 0; - } - /* Case3: Transceiver be isolated */ - if (self->state == STATE_TRANSVR_ISOLATED){ - result[0] = STATE_TRANSVR_ISOLATED; - result[1] = TRANSVR_TYPE_ERROR; - return ERR_TRNASVR_BE_ISOLATED; - } - /* Case4: Transceiver plugged */ - result[1] = detect_transvr_type(self); - /* Case4.1: I2C topology crash - * Note : There are some I2C issues cause by transceiver/cables. - * We need to check topology status when user insert it. - * But in this step, we can't not ensure this is the issues - * port. So, it return the ERR_TRANSVR_I2C_CRASH, then upper - * layer will diagnostic I2C topology. - */ - if (check_channel_tier_1() < 0) { - SWPS_INFO("%s: %s detect I2C crash :%d\n", - __func__, self->swp_name, self->state); - result[0] = STATE_TRANSVR_UNEXCEPTED; - result[1] = TRANSVR_TYPE_ERROR; - return ERR_TRANSVR_I2C_CRASH; - } - /* Case4.2: System initial not ready, - * Note : Sometime i2c channel or transceiver EEPROM will delay that will - * cause system in inconsistent state between EEPROM and IOEXP. - * In this case, SWP transceiver object keep state at LINK_DOWN - * to wait system ready. - * By the way, State Machine will handle these case. - */ - if (result[1] == TRANSVR_TYPE_UNPLUGGED){ - result[0] = STATE_TRANSVR_DISCONNECTED; - return 0; - } - /* Case4.3: Error transceiver type */ - if (result[1] == TRANSVR_TYPE_ERROR){ - result[0] = STATE_TRANSVR_ISOLATED; - SWPS_INFO("%s: %s detect error type\n", __func__, self->swp_name); - alarm_msg_2_user(self, "detected transceiver/cables not meet SFF standard!"); - return ERR_TRNASVR_BE_ISOLATED; - } - /* Case3.3: Unknow transceiver type */ - if ((result[1] == TRANSVR_TYPE_UNKNOW_1) || - (result[1] == TRANSVR_TYPE_UNKNOW_2) ){ - result[0] = STATE_TRANSVR_UNEXCEPTED; - return ERR_TRANSVR_UNEXCPT; - } - /* Case3.4: During initial process */ - if (self->state == STATE_TRANSVR_INIT){ - result[0] = STATE_TRANSVR_INIT; - return 0; - } - /* Case3.5: Transceiver be swapped */ - if (self->type != result[1]){ - result[0] = STATE_TRANSVR_SWAPPED; - return 0; - } - /* Case3.6: Link up state */ - result[0] = STATE_TRANSVR_CONNECTED; - return 0; -} - - -int -_sfp_detect_class_by_extend_comp(struct transvr_obj_s* self) { - /* Reference: SFF-8024 (v3.8) - */ - int detect_val = _sfp_get_comp_extended(self); - - switch(detect_val) { - case 0x00: /* Unspecified */ - return TRANSVR_CLASS_UNSPECIFIED; - - case 0x01: /* 100G AOC (Active Optical Cable) or 25GAUI C2M */ - case 0x18: /* 100G AOC or 25GAUI C2M AOC. */ - return TRANSVR_CLASS_OPTICAL_25G_AOC; - - case 0x02: /* 100GBASE-SR4 or 25GBASE-SR */ - return TRANSVR_CLASS_OPTICAL_25G_SR; - - case 0x03: /* 100GBASE-LR4 or 25GBASE-LR */ - return TRANSVR_CLASS_OPTICAL_25G_LR; - - case 0x04: /* 100GBASE-ER4 or 25GBASE-ER */ - return TRANSVR_CLASS_OPTICAL_25G_ER; - - case 0x08: /* 100G ACC (Active Copper Cable) or 25GAUI C2M ACC. */ - case 0x0b: /* 100GBASE-CR4 or 25GBASE-CR CA-L */ - case 0x0c: /* 25GBASE-CR CA-S */ - case 0x0d: /* 25GBASE-CR CA-N */ - case 0x19: /* 100G ACC or 25GAUI C2M ACC. */ - return TRANSVR_CLASS_COPPER_L1_25G; - - default: - break; - } - SWPS_INFO("%s: Unexcept value:0x%02x\n :%s", - __func__, detect_val, self->swp_name); - return TRANSVR_CLASS_ERROR; -} - - -int -_sfp_detect_class_by_10_ethernet(struct transvr_obj_s* self) { - /* Reference: SFF-8472 (v12.2) - */ - int detect_val = DEBUG_TRANSVR_INT_VAL; - - detect_val = _sfp_get_comp_10g_eth_comp(self); - /* Case: Unspecified */ - if (detect_val == 0x00) { - return TRANSVR_CLASS_UNSPECIFIED; - } - /* Case: 10G Optical (x1) */ - if ((detect_val & 0x10) == 0x10) { /* 00010000 : 10GBASE-SR */ - return TRANSVR_CLASS_OPTICAL_10G_S_SR; - } - if ( ((detect_val & 0x20) == 0x20) || /* 00100000 : 10GBASE-LR */ - ((detect_val & 0x40) == 0x40) ){ /* 01000000 : 10GBASE-LRM */ - return TRANSVR_CLASS_OPTICAL_10G_S_LR; - } - if ((detect_val & 0x80) == 0x80) { /* 10000000 : 10GBASE-ER */ - return TRANSVR_CLASS_OPTICAL_10G_S_ER; - } - /* Case: ERROR */ - SWPS_INFO("%s: Unexcept value:0x%02x\n :%s", - __func__, detect_val, self->swp_name); - return TRANSVR_CLASS_ERROR; -} - - -int -_sfp_detect_if_sp_by_br(struct transvr_obj_s* self) { - - int lower_bound_1g = 0x0b; - int upper_bound_1g = 0x1A; - int lower_bound_10g = 0x60; - int upper_bound_10g = 0x75; - int lower_bound_25g = 0xf0; - int upper_bound_25g = 0xff; - int notmal_br = DEBUG_TRANSVR_INT_VAL; - - notmal_br = (int)(self->br); /* updated by update_all() */ - /* Check 25G */ - if ((notmal_br >= lower_bound_25g) && - (notmal_br <= upper_bound_25g) ) { - return TRANSVR_CLASS_25G; - } - /* Check 10G */ - if ((notmal_br >= lower_bound_10g) && - (notmal_br <= upper_bound_10g) ) { - return TRANSVR_CLASS_10G; - } - /* Check 1G */ - if ((notmal_br >= lower_bound_1g) && - (notmal_br <= upper_bound_1g) ) { - return TRANSVR_CLASS_1G; - } - return TRANSVR_CLASS_UNSPECIFIED; -} - - -int -_sfp_detect_class_by_1g_ethernet(struct transvr_obj_s* self) { - /* Reference: SFF-8472 (v12.2) - */ - int detect_val = DEBUG_TRANSVR_INT_VAL; - int speed_br = DEBUG_TRANSVR_INT_VAL; - int speed_tmp = DEBUG_TRANSVR_INT_VAL; - char err_str[64] = DEBUG_TRANSVR_STR_VAL; - - speed_br = _sfp_detect_if_sp_by_br(self); - detect_val = _sfp_get_comp_1g_eth_comp(self); - - if (detect_val < 0) { - snprintf(err_str, sizeof(err_str), "Detect abnormal value:%d", detect_val); - goto err_p_sfp_detect_class_by_1g_ethernet; - } - /* Case: Unspecified */ - if (detect_val == 0x00) { - return TRANSVR_CLASS_UNSPECIFIED; - } - /* Case: 1G (x1) */ - if ((detect_val & 0x01) == 0x01) { /* 00000001 : 1000BASE-SX */ - speed_tmp = TRANSVR_CLASS_OPTICAL_1G_SX; - goto ok_sfp_detect_class_by_1g_ethernet_4_check_br_10g; - } - if ((detect_val & 0x02) == 0x02) { /* 00000010 : 1000BASE-LX *3 */ - speed_tmp = TRANSVR_CLASS_OPTICAL_1G_LX; - goto ok_sfp_detect_class_by_1g_ethernet_4_check_br_10g; - } - if ((detect_val & 0x04) == 0x04) { /* 00000100 : 1000BASE-CX */ - speed_tmp = TRANSVR_CLASS_COPPER_L1_1G; - goto ok_sfp_detect_class_by_1g_ethernet_4_check_br_10g; - } - /* Case: 1000 Base-T (x1) */ - if ((detect_val & 0x08) == 0x08) { /* 00001000 : 1000BASE-T */ - return TRANSVR_CLASS_BASE_T_1000; - } - /* Case: 100 Base */ - if ( ((detect_val & 0x10) == 0x10) || /* 00010000 : 100BASE-LX/LX10 */ - ((detect_val & 0x20) == 0x20) || /* 00100000 : 100BASE-FX */ - ((detect_val & 0x40) == 0x40) || /* 01000000 : BASE-BX10 *3 */ - ((detect_val & 0x80) == 0x80) ){ /* 10000000 : BASE-PX *3 */ - return TRANSVR_CLASS_OPTICAL_100; - } - /* Case: ERROR */ - snprintf(err_str, sizeof(err_str), "Case:ERROR, value:%d", detect_val); - goto err_p_sfp_detect_class_by_1g_ethernet; - -ok_sfp_detect_class_by_1g_ethernet_4_check_br_10g: - switch (speed_br) { - case TRANSVR_CLASS_UNSPECIFIED: - case TRANSVR_CLASS_1G: - return speed_tmp; - case TRANSVR_CLASS_10G: - goto ok_sfp_detect_class_by_1g_ethernet_4_transfer_10G; - } - -ok_sfp_detect_class_by_1g_ethernet_4_transfer_10G: - switch (speed_tmp) { - case TRANSVR_CLASS_OPTICAL_1G_SX: - return TRANSVR_CLASS_OPTICAL_10G_S_SR; - case TRANSVR_CLASS_OPTICAL_1G_LX: - return TRANSVR_CLASS_OPTICAL_10G_S_LR; - case TRANSVR_CLASS_COPPER_L1_1G: - return TRANSVR_CLASS_COPPER_L1_10G; - default: - break; - } - snprintf(err_str, sizeof(err_str), "transfer_1to10 fail, speed:%d", speed_tmp); - goto err_p_sfp_detect_class_by_1g_ethernet; - -err_p_sfp_detect_class_by_1g_ethernet: - SWPS_INFO("%s: %s :%s", __func__, err_str, self->swp_name); - return TRANSVR_CLASS_ERROR; -} - - -int -_sfp_detect_class_by_feature(struct transvr_obj_s* self) { - /* Reference: SFF-8024 (v3.8) - */ - int is_active = 0; - int conn_val = DEBUG_TRANSVR_INT_VAL; - int check_val = DEBUG_TRANSVR_INT_VAL; - int wave_len = DEBUG_TRANSVR_INT_VAL; - int speed_val = DEBUG_TRANSVR_INT_VAL; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - - speed_val = _sfp_detect_if_sp_by_br(self); - conn_val = _sfp_get_connector_type(self); - - switch(conn_val) { - case 0x00: /* Unspecified */ - goto ok_sfp_detect_class_by_feature_4_check_active_passive; - case 0x07: /* LC (Lucent Connector) */ - case 0x0b: /* Optical Pigtail */ - case 0x0c: /* MPO 1x12 */ - case 0x0d: /* MPO 2x16 */ - /* - * ToDo: Need verify Optical Pigtail - */ - goto ok_sfp_detect_class_by_feature_4_optiocal; - case 0x21: /* Copper pigtail */ - /* - * ToDo: Need check ACC use case - */ - goto ok_sfp_detect_class_by_feature_4_check_active_passive; - case 0x23: /* No separable connector */ - /* - * ToDo: Standard not clear, not all transceiver vendor - * have the same defined - */ - goto ok_sfp_detect_class_by_feature_4_check_active_passive; - default: - break; - } - goto ok_sfp_detect_class_by_feature_4_unknow; - -ok_sfp_detect_class_by_feature_4_check_active_passive: - check_val = _sfp_get_cable_tech(self); - switch(check_val) { - case 0x00: /* Unspecified */ - goto ok_sfp_detect_class_by_feature_4_unknow; - case 0x04: /* Passive */ - goto ok_sfp_detect_class_by_feature_4_copper; - case 0x08: /* Active */ - is_active = 1; - goto ok_sfp_detect_class_by_feature_4_aoc; - default: - snprintf(err_msg, sizeof(err_msg), - "_sfp_get_cable_tech return Non define value:%d", - check_val); - break; - } - goto err_sfp_detect_class_by_feature_1; - -ok_sfp_detect_class_by_feature_4_optiocal: - wave_len = _common_count_wavelength(self, - self->wavelength[0], - self->wavelength[1]); - switch(speed_val) { - case TRANSVR_CLASS_25G: - switch (wave_len) { - case VAL_OPTICAL_WAVELENGTH_SR: - return TRANSVR_CLASS_OPTICAL_25G_SR; - case VAL_OPTICAL_WAVELENGTH_LR: - return TRANSVR_CLASS_OPTICAL_25G_LR; - case VAL_OPTICAL_WAVELENGTH_ER: - return TRANSVR_CLASS_OPTICAL_25G_ER; - default: - break; - } - return TRANSVR_CLASS_OPTICAL_25G; - - case TRANSVR_CLASS_10G: - switch (wave_len) { - case VAL_OPTICAL_WAVELENGTH_SR: - return TRANSVR_CLASS_OPTICAL_10G_S_SR; - case VAL_OPTICAL_WAVELENGTH_LR: - return TRANSVR_CLASS_OPTICAL_10G_S_LR; - case VAL_OPTICAL_WAVELENGTH_ER: - return TRANSVR_CLASS_OPTICAL_10G_S_ER; - default: - break; - } - return TRANSVR_CLASS_OPTICAL_10G; - - case TRANSVR_CLASS_1G: - switch (wave_len) { - case VAL_OPTICAL_WAVELENGTH_SR: - return TRANSVR_CLASS_OPTICAL_1G_SX; - case VAL_OPTICAL_WAVELENGTH_LR: - return TRANSVR_CLASS_OPTICAL_1G_LX; - case VAL_OPTICAL_WAVELENGTH_ER: - return TRANSVR_CLASS_OPTICAL_1G_EX; - default: - break; - } - return TRANSVR_CLASS_OPTICAL_1G; - - default: - return TRANSVR_CLASS_OPTICAL; - } - -ok_sfp_detect_class_by_feature_4_aoc: - switch(speed_val) { - case TRANSVR_CLASS_25G: - return TRANSVR_CLASS_OPTICAL_25G_AOC; - case TRANSVR_CLASS_10G: - return TRANSVR_CLASS_OPTICAL_10G_S_AOC; - case TRANSVR_CLASS_1G: - return TRANSVR_CLASS_OPTICAL_1G_AOC; - default: - break; - } - goto ok_sfp_detect_class_by_feature_4_unknow; - -ok_sfp_detect_class_by_feature_4_copper: - switch(speed_val) { - case TRANSVR_CLASS_25G: - return TRANSVR_CLASS_COPPER_L1_25G; - case TRANSVR_CLASS_10G: - return TRANSVR_CLASS_COPPER_L1_10G; - case TRANSVR_CLASS_1G: - return TRANSVR_CLASS_COPPER_L1_1G; - default: - return TRANSVR_CLASS_COPPER; - } - -ok_sfp_detect_class_by_feature_4_unknow: - return TRANSVR_CLASS_UNSPECIFIED; - -err_sfp_detect_class_by_feature_1: - SWPS_INFO("%s: %s\n :%s", __func__, err_msg, self->swp_name); - return TRANSVR_CLASS_ERROR; -} - - -int -sft_detect_transvr_class(struct transvr_obj_s* self) { - - int detect_val = DEBUG_TRANSVR_INT_VAL; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - - /* Check Extended Compliance */ - detect_val = _sfp_detect_class_by_extend_comp(self); - switch(detect_val) { - case TRANSVR_CLASS_UNSPECIFIED: - break; - case TRANSVR_CLASS_OPTICAL_25G_AOC: - case TRANSVR_CLASS_OPTICAL_25G_SR: - case TRANSVR_CLASS_OPTICAL_25G_LR: - case TRANSVR_CLASS_OPTICAL_25G_ER: - case TRANSVR_CLASS_COPPER_L1_25G: - return detect_val; - default: - snprintf(err_msg, sizeof(err_msg), - "Detect undefined extend_comp:%d", - detect_val); - goto err_sft_detect_transceiver_class_1; - } - /* Check 10G Compliance */ - detect_val = _sfp_detect_class_by_10_ethernet(self); - switch(detect_val) { - case TRANSVR_CLASS_UNSPECIFIED: - break; - case TRANSVR_CLASS_OPTICAL_10G_S_SR: - case TRANSVR_CLASS_OPTICAL_10G_S_LR: - case TRANSVR_CLASS_OPTICAL_10G_S_ER: - return detect_val; - default: - snprintf(err_msg, sizeof(err_msg), - "Detect undefined 10G_eth:%d", - detect_val); - goto err_sft_detect_transceiver_class_1; - } - /* Check 1G Compliance */ - detect_val = _sfp_detect_class_by_1g_ethernet(self); - switch(detect_val) { - case TRANSVR_CLASS_UNSPECIFIED: - break; - case TRANSVR_CLASS_OPTICAL_1G_SX: - case TRANSVR_CLASS_OPTICAL_1G_LX: - case TRANSVR_CLASS_COPPER_L1_1G: - case TRANSVR_CLASS_BASE_T_1000: - case TRANSVR_CLASS_OPTICAL_100: - /* - * ToDo: Need Check 0.1G - */ - case TRANSVR_CLASS_OPTICAL_10G_S_SR: - case TRANSVR_CLASS_OPTICAL_10G_S_LR: - case TRANSVR_CLASS_COPPER_L1_10G: - /* Transfer speed case - * => Example: Raycom 10G DAC - */ - return detect_val; - default: - snprintf(err_msg, sizeof(err_msg), - "Detect undefined 1G_eth:%d", - detect_val); - goto err_sft_detect_transceiver_class_1; - } - /* Check by connector, br, wavelength */ - detect_val = _sfp_detect_class_by_feature(self); - switch(detect_val) { - case TRANSVR_CLASS_UNSPECIFIED: - break; - case TRANSVR_CLASS_OPTICAL: - case TRANSVR_CLASS_OPTICAL_1G: - case TRANSVR_CLASS_OPTICAL_1G_SX: - case TRANSVR_CLASS_OPTICAL_1G_LX: - case TRANSVR_CLASS_OPTICAL_1G_EX: - case TRANSVR_CLASS_OPTICAL_1G_AOC: - case TRANSVR_CLASS_OPTICAL_10G: - case TRANSVR_CLASS_OPTICAL_10G_S_SR: - case TRANSVR_CLASS_OPTICAL_10G_S_LR: - case TRANSVR_CLASS_OPTICAL_10G_S_ER: - case TRANSVR_CLASS_OPTICAL_10G_S_AOC: - case TRANSVR_CLASS_OPTICAL_25G: - case TRANSVR_CLASS_OPTICAL_25G_SR: - case TRANSVR_CLASS_OPTICAL_25G_LR: - case TRANSVR_CLASS_OPTICAL_25G_ER: - case TRANSVR_CLASS_OPTICAL_25G_AOC: - case TRANSVR_CLASS_COPPER: - case TRANSVR_CLASS_COPPER_L1_1G: - case TRANSVR_CLASS_COPPER_L1_10G: - case TRANSVR_CLASS_COPPER_L1_25G: - return detect_val; - default: - snprintf(err_msg, sizeof(err_msg), - "Detect undefined get_connector:%d", - detect_val); - goto err_sft_detect_transceiver_class_1; - } - /* Exception case: Can't verify */ - snprintf(err_msg, sizeof(err_msg), "Can not identify!"); - goto err_sft_detect_transceiver_class_1; - -err_sft_detect_transceiver_class_1: - SWPS_INFO("%s: %s :%s\n", __func__, err_msg, self->swp_name); - return TRANSVR_CLASS_ERROR; -} - - -int -_sfp_set_trident2_if_type(struct transvr_obj_s* self, - int transvr_cls, - char *result){ - - int lmax = 8; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - - switch(transvr_cls) { - case TRANSVR_CLASS_ERROR: - case TRANSVR_CLASS_UNSPECIFIED: - break; - /* 25G OPTICAL */ - case TRANSVR_CLASS_OPTICAL_25G_AOC: - case TRANSVR_CLASS_OPTICAL_25G_SR: - case TRANSVR_CLASS_OPTICAL_25G_LR: - case TRANSVR_CLASS_OPTICAL_25G_ER: - case TRANSVR_CLASS_OPTICAL_25G: - return snprintf(result, lmax, TRANSVR_IF_SFI); - /* 25G COPPER */ - case TRANSVR_CLASS_COPPER_L1_25G: - return snprintf(result, lmax, TRANSVR_IF_SFI); - /* 10G OPTICAL */ - case TRANSVR_CLASS_OPTICAL_10G_S_AOC: - case TRANSVR_CLASS_OPTICAL_10G_S_SR: - case TRANSVR_CLASS_OPTICAL_10G_S_LR: - case TRANSVR_CLASS_OPTICAL_10G_S_ER: - case TRANSVR_CLASS_OPTICAL_10G: - return snprintf(result, lmax, TRANSVR_IF_SFI); - /* 10G COPPER */ - case TRANSVR_CLASS_COPPER_L1_10G: - return snprintf(result, lmax, TRANSVR_IF_SFI); - /* 1G OPTICAL */ - case TRANSVR_CLASS_OPTICAL_1G_AOC: - case TRANSVR_CLASS_OPTICAL_1G_SX: - case TRANSVR_CLASS_OPTICAL_1G_LX: - case TRANSVR_CLASS_OPTICAL_1G_EX: - case TRANSVR_CLASS_OPTICAL_1G: - return snprintf(result, lmax, TRANSVR_IF_IF_GMII); - /* 1G COPPER */ - case TRANSVR_CLASS_COPPER_L1_1G: - return snprintf(result, lmax, TRANSVR_IF_IF_GMII); - /* 1G BASE_T */ - case TRANSVR_CLASS_BASE_T_1000: - return snprintf(result, lmax, TRANSVR_IF_IF_GMII); - /* 100 Base */ - case TRANSVR_CLASS_OPTICAL_100: - return snprintf(result, lmax, TRANSVR_IF_IF_GMII); - default: - snprintf(err_msg, sizeof(err_msg), - "Detect undefined value:%d", - transvr_cls); - goto err_sfp_set_trident2_if_type_1; - } - /* Exception case: Can't verify */ - snprintf(err_msg, sizeof(err_msg), "Can not identify!"); - goto err_sfp_set_trident2_if_type_1; - -err_sfp_set_trident2_if_type_1: - snprintf(result, lmax, TRANSVR_UEVENT_UNKNOW); - SWPS_INFO("%s: %s :%s\n", __func__, err_msg, self->swp_name); - return ERR_TRANSVR_ABNORMAL; -} - - -int -_sfp_set_tomahawk_if_type(struct transvr_obj_s* self, - int transvr_cls, - char *result) { - - int lmax = 8; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - - switch(transvr_cls) { - case TRANSVR_CLASS_ERROR: - case TRANSVR_CLASS_UNSPECIFIED: - break; - /* 25G OPTICAL */ - case TRANSVR_CLASS_OPTICAL_25G_AOC: - case TRANSVR_CLASS_OPTICAL_25G_SR: - case TRANSVR_CLASS_OPTICAL_25G_LR: - case TRANSVR_CLASS_OPTICAL_25G_ER: - case TRANSVR_CLASS_OPTICAL_25G: - return snprintf(result, lmax, TRANSVR_IF_SR); - /* 25G COPPER */ - case TRANSVR_CLASS_COPPER_L1_25G: - return snprintf(result, lmax, TRANSVR_IF_KR); - /* 10G OPTICAL */ - case TRANSVR_CLASS_OPTICAL_10G_S_AOC: - case TRANSVR_CLASS_OPTICAL_10G_S_SR: - case TRANSVR_CLASS_OPTICAL_10G_S_LR: - case TRANSVR_CLASS_OPTICAL_10G_S_ER: - case TRANSVR_CLASS_OPTICAL_10G: - return snprintf(result, lmax, TRANSVR_IF_SFI); - /* 10G COPPER */ - case TRANSVR_CLASS_COPPER_L1_10G: - return snprintf(result, lmax, TRANSVR_IF_SFI); - /* 1G OPTICAL */ - case TRANSVR_CLASS_OPTICAL_1G_AOC: - case TRANSVR_CLASS_OPTICAL_1G_SX: - case TRANSVR_CLASS_OPTICAL_1G_LX: - case TRANSVR_CLASS_OPTICAL_1G_EX: - case TRANSVR_CLASS_OPTICAL_1G: - return snprintf(result, lmax, TRANSVR_IF_IF_GMII); - /* 1G COPPER */ - case TRANSVR_CLASS_COPPER_L1_1G: - return snprintf(result, lmax, TRANSVR_IF_IF_GMII); - /* 1G BASE_T */ - case TRANSVR_CLASS_BASE_T_1000: - return snprintf(result, lmax, TRANSVR_IF_IF_GMII); - /* 100 Base */ - case TRANSVR_CLASS_OPTICAL_100: - return snprintf(result, lmax, TRANSVR_IF_IF_GMII); - default: - snprintf(err_msg, sizeof(err_msg), - "Detect undefined value:%d", - transvr_cls); - goto err_sfp_set_tomahawk_if_type_1; - } - /* Exception case: Can't verify */ - snprintf(err_msg, sizeof(err_msg), "Can not identify!"); - goto err_sfp_set_tomahawk_if_type_1; - -err_sfp_set_tomahawk_if_type_1: - snprintf(result, lmax, TRANSVR_UEVENT_UNKNOW); - SWPS_INFO("%s: %s\n :%s", __func__, err_msg, self->swp_name); - return ERR_TRANSVR_ABNORMAL; -} - - -int -_sfp_detect_if_type(struct transvr_obj_s* self, - char *result){ - - int lmax = 8; - int detect_cls = DEBUG_TRANSVR_INT_VAL; - - detect_cls = sft_detect_transvr_class(self); - switch (self->chipset_type) { - case BCM_CHIP_TYPE_TRIDENT_2: - return _sfp_set_trident2_if_type(self, detect_cls, result); - - case BCM_CHIP_TYPE_TOMAHAWK: - return _sfp_set_tomahawk_if_type(self, detect_cls, result); - - default: - SWPS_INFO("%s: non-defined chipset_type:%d :%s\n", - __func__, self->chipset_type, self->swp_name); - break; - } - snprintf(result, lmax, TRANSVR_UEVENT_UNKNOW); - return ERR_TRANSVR_ABNORMAL; -} - - -int -sfp_get_if_type(struct transvr_obj_s *self, - char *buf_p){ - - int lmax = 16; - char tmp_result[16] = DEBUG_TRANSVR_STR_VAL; - - if (self->state != STATE_TRANSVR_CONNECTED) { - return snprintf(buf_p, lmax, "%d\n", self->state); - } - if (_sfp_detect_if_type(self, tmp_result) < 0) { - return snprintf(buf_p, lmax, "%d\n", ERR_TRANSVR_ABNORMAL); - } - return snprintf(buf_p, lmax, "%s\n", tmp_result); -} - - -int -_sfp_detect_if_speed(struct transvr_obj_s* self, - char *result){ - - int lmax = 16; - int detect_val = DEBUG_TRANSVR_INT_VAL; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - - detect_val = sft_detect_transvr_class(self); - switch(detect_val) { - case TRANSVR_CLASS_ERROR: - case TRANSVR_CLASS_UNSPECIFIED: - break; - /* 25G OPTICAL */ - case TRANSVR_CLASS_OPTICAL_25G_AOC: - case TRANSVR_CLASS_OPTICAL_25G_SR: - case TRANSVR_CLASS_OPTICAL_25G_LR: - case TRANSVR_CLASS_OPTICAL_25G_ER: - case TRANSVR_CLASS_OPTICAL_25G: - return snprintf(result, lmax, TRANSVR_IF_SP_25G); - /* 25G COPPER */ - case TRANSVR_CLASS_COPPER_L1_25G: - return snprintf(result, lmax, TRANSVR_IF_SP_25G); - /* 10G OPTICAL */ - case TRANSVR_CLASS_OPTICAL_10G_S_AOC: - case TRANSVR_CLASS_OPTICAL_10G_S_SR: - case TRANSVR_CLASS_OPTICAL_10G_S_LR: - case TRANSVR_CLASS_OPTICAL_10G_S_ER: - case TRANSVR_CLASS_OPTICAL_10G: - return snprintf(result, lmax, TRANSVR_IF_SP_10G); - /* 10G COPPER */ - case TRANSVR_CLASS_COPPER_L1_10G: - return snprintf(result, lmax, TRANSVR_IF_SP_10G); - /* 1G OPTICAL */ - case TRANSVR_CLASS_OPTICAL_1G_AOC: - case TRANSVR_CLASS_OPTICAL_1G_SX: - case TRANSVR_CLASS_OPTICAL_1G_LX: - case TRANSVR_CLASS_OPTICAL_1G_EX: - case TRANSVR_CLASS_OPTICAL_1G: - return snprintf(result, lmax, TRANSVR_IF_SP_1G); - /* 1G COPPER */ - case TRANSVR_CLASS_COPPER_L1_1G: - return snprintf(result, lmax, TRANSVR_IF_SP_1G); - /* 1G BASE_T */ - case TRANSVR_CLASS_BASE_T_1000: - return snprintf(result, lmax, TRANSVR_IF_SP_1G); - /* 100 Base */ - case TRANSVR_CLASS_OPTICAL_100: - return snprintf(result, lmax, TRANSVR_IF_SP_100); - default: - snprintf(err_msg, sizeof(err_msg), - "Detect undefined value:%d", - detect_val); - goto err_sfp_detect_if_speed_1; - } - /* Check by BR */ - detect_val = _sfp_detect_if_sp_by_br(self); - switch (detect_val) { - case TRANSVR_CLASS_25G: - return snprintf(result, lmax, TRANSVR_IF_SP_25G); - case TRANSVR_CLASS_10G: - return snprintf(result, lmax, TRANSVR_IF_SP_10G); - case TRANSVR_CLASS_1G: - return snprintf(result, lmax, TRANSVR_IF_SP_1G); - default: - break; - } - /* Exception case: Can't verify */ - snprintf(err_msg, sizeof(err_msg), "Can not identify!"); - goto err_sfp_detect_if_speed_1; - -err_sfp_detect_if_speed_1: - snprintf(result, lmax, TRANSVR_UEVENT_UNKNOW); - SWPS_INFO("%s %s\n :%s", __func__, err_msg, self->swp_name); - return ERR_TRANSVR_ABNORMAL; -} - - -int -sfp_get_if_speed(struct transvr_obj_s *self, - char *buf_p){ - - int lmax = 16; - char tmp_result[16] = DEBUG_TRANSVR_STR_VAL; - - if (self->state != STATE_TRANSVR_CONNECTED) { - return snprintf(buf_p, lmax, "%d\n", self->state); - } - if (_sfp_detect_if_speed(self, tmp_result) < 0) { - return snprintf(buf_p, lmax, "%d\n", ERR_TRANSVR_ABNORMAL); - } - return snprintf(buf_p, lmax, "%s\n", tmp_result); -} - - -int -_qsfp_detect_class_by_extend_comp(struct transvr_obj_s* self) { - /* Reference: SFF-8024 (v3.8) - */ - int detect_val = DEBUG_TRANSVR_INT_VAL; - - detect_val = _qsfp_get_comp_extended(self); - switch(detect_val) { - case 0x00: /* Unspecified */ - return TRANSVR_CLASS_UNSPECIFIED; - - case 0x01: /* 100G AOC (Active Optical Cable) or 25GAUI C2M */ - case 0x18: /* 100G AOC or 25GAUI C2M AOC. */ - return TRANSVR_CLASS_OPTICAL_100G_AOC; - - case 0x06: /* 100G CWDM4 */ - case 0x09: /* Obsolete (assigned before 100G CWDM4 MSA required FEC) */ - case 0x17: /* 100G CLR4 */ - case 0x1A: /* 100GE-DWDM2 */ - return TRANSVR_CLASS_OPTICAL_100G; - - case 0x02: /* 100GBASE-SR4 or 25GBASE-SR */ - return TRANSVR_CLASS_OPTICAL_100G_SR4; - - case 0x03: /* 100GBASE-LR4 or 25GBASE-LR */ - return TRANSVR_CLASS_OPTICAL_100G_LR4; - - case 0x04: /* 100GBASE-ER4 or 25GBASE-ER */ - return TRANSVR_CLASS_OPTICAL_100G_ER4; - - case 0x07: /* 100G PSM4 Parallel SMF */ - return TRANSVR_CLASS_OPTICAL_100G_PSM4; - - case 0x12: /* 40G PSM4 Parallel SMF */ - return TRANSVR_CLASS_OPTICAL_40G; - - case 0x11: /* 4 x 10GBASE-SR */ - return TRANSVR_CLASS_OPTICAL_40G_SR4; - - case 0x10: /* 40GBASE-ER4 */ - return TRANSVR_CLASS_OPTICAL_40G_ER4; - - case 0x08: /* 100G ACC (Active Copper Cable) or 25GAUI C2M ACC. */ - case 0x0b: /* 100GBASE-CR4 or 25GBASE-CR CA-L */ - case 0x19: /* 100G ACC or 25GAUI C2M ACC. */ - return TRANSVR_CLASS_COPPER_L4_100G; - - default: - break; - } - SWPS_INFO("%s: Unexcept value:0x%02x\n :%s", - __func__, detect_val, self->swp_name); - return TRANSVR_CLASS_ERROR; -} - - -int -_qsfp_detect_class_by_10_40_100_ethernet(struct transvr_obj_s* self) { - /* Reference: SFF-8472 (v12.2) - */ - int detect_val = DEBUG_TRANSVR_INT_VAL; - - detect_val = _qsfp_get_comp_10_40_100_ethernet(self); - /* Case: Unspecified */ - if (detect_val == 0x00) { - return TRANSVR_CLASS_UNSPECIFIED; - } - /* Case: 40G Optical */ - if ((detect_val & 0x01) == 0x01) { /* 00000001 : 40G Active Cable (XLPPI) */ - return TRANSVR_CLASS_OPTICAL_40G_AOC; - } - if ((detect_val & 0x04) == 0x04) { /* 00000100 : 40GBASE-SR4 */ - return TRANSVR_CLASS_OPTICAL_40G_SR4; - } - if ( (detect_val & 0x02) == 0x02) { /* 00000010 : 40GBASE-LR4 */ - return TRANSVR_CLASS_OPTICAL_40G_LR4; - } - if ( (detect_val & 0x08) == 0x08) { /* 00001000 : 40GBASE-CR4 */ - return TRANSVR_CLASS_COPPER_L4_40G; - } - /* Case: 10G Optical */ - if ( (detect_val & 0x10) == 0x10) { /* 00010000 : 10GBASE-SR */ - return TRANSVR_CLASS_OPTICAL_10G_Q_SR; - } - if ( ((detect_val & 0x20) == 0x20) || /* 00100000 : 10GBASE-LR */ - ((detect_val & 0x40) == 0x40) ){ /* 01000000 : 10GBASE-LRM */ - return TRANSVR_CLASS_OPTICAL_10G_Q_LR; - } - /* Case: Extend Compliance */ - if ( ((detect_val & 0x80) == 0x80) ){ /* 10000000 : Use Extend Compliance */ - return TRANSVR_CLASS_EXTEND_COMP; - } - /* Case: ERROR */ - SWPS_INFO("%s: Unexcept value:0x%02x\n :%s", - __func__, detect_val, self->swp_name); - return TRANSVR_CLASS_ERROR; -} - - -int -_qsfp_detect_if_sp_by_br(struct transvr_obj_s* self) { - - int lower_bound_10g = 0x10; - int upper_bound_10g = 0x25; - int lower_bound_40g = 0x60; - int upper_bound_40g = 0x75; - int lower_bound_100g = 0x60; - int upper_bound_100g = 0x75; - int used_extend_br = 0xff; - int notmal_br = DEBUG_TRANSVR_INT_VAL; - int extend_br = DEBUG_TRANSVR_INT_VAL; - - notmal_br = (int)(self->br); /* updated by update_all() */ - /* Check 40G */ - if ((notmal_br >= lower_bound_40g) && - (notmal_br <= upper_bound_40g) ) { - return TRANSVR_CLASS_40G; - } - /* Check 100G */ - if (notmal_br == used_extend_br) { - extend_br = (int)(self->extbr); /* updated by update_all() */ - if ((extend_br >= lower_bound_100g) && - (extend_br <= upper_bound_100g) ) { - return TRANSVR_CLASS_100G; - } - } - /* Check 10G */ - if ((notmal_br >= lower_bound_10g) && - (notmal_br <= upper_bound_10g) ) { - return TRANSVR_CLASS_10G; - } - return TRANSVR_CLASS_UNSPECIFIED; -} - - -int -_qsfp_detect_class_by_feature(struct transvr_obj_s* self) { - /* Reference: SFF-8024 (v3.8) - */ - int conn_val = DEBUG_TRANSVR_INT_VAL; - int wave_len = DEBUG_TRANSVR_INT_VAL; - int speed_val = DEBUG_TRANSVR_INT_VAL; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - - speed_val = _qsfp_detect_if_sp_by_br(self); - conn_val = _qsfp_get_connector_type(self); - - switch(conn_val) { - case 0x00: /* Unspecified */ - return TRANSVR_CLASS_UNSPECIFIED; - case 0x07: /* LC (Lucent Connector) */ - case 0x0b: /* Optical Pigtail */ - case 0x0c: /* MPO 1x12 (Multifiber Parallel Optic) */ - case 0x0d: /* MPO 2x16 */ - goto ok_qsfp_detect_class_by_feature_4_optiocal; - case 0x21: /* Copper pigtail */ - goto ok_qsfp_detect_class_by_feature_4_copper; - case 0x23: /* No separable connector */ - if ((_qsfp_get_comp_fc_link_length(self) > 0) || - (_qsfp_get_comp_fc_trans_tech(self) > 0) || - (_qsfp_get_comp_fc_trans_media(self) > 0) || - (_qsfp_get_comp_fc_speed(self) > 0) ) { - goto ok_qsfp_detect_class_by_feature_4_aoc; - } - goto ok_qsfp_detect_class_by_feature_4_copper; - default: - snprintf(err_msg, sizeof(err_msg), - "_qsfp_get_connector_type return Non define value:%d", - conn_val); - goto err_qsfp_detect_class_by_feature_1; - } - return TRANSVR_CLASS_UNSPECIFIED; - -ok_qsfp_detect_class_by_feature_4_optiocal: - wave_len = _common_count_wavelength(self, - self->wavelength[0], - self->wavelength[1]); - switch(speed_val) { - case TRANSVR_CLASS_100G: - switch (wave_len) { - case VAL_OPTICAL_WAVELENGTH_SR: - return TRANSVR_CLASS_OPTICAL_100G_SR4; - case VAL_OPTICAL_WAVELENGTH_LR: - return TRANSVR_CLASS_OPTICAL_100G_LR4; - case VAL_OPTICAL_WAVELENGTH_ER: - return TRANSVR_CLASS_OPTICAL_100G_ER4; - default: - break; - } - return TRANSVR_CLASS_OPTICAL_100G; - - case TRANSVR_CLASS_40G: - switch (wave_len) { - case VAL_OPTICAL_WAVELENGTH_SR: - return TRANSVR_CLASS_OPTICAL_40G_SR4; - case VAL_OPTICAL_WAVELENGTH_LR: - return TRANSVR_CLASS_OPTICAL_40G_LR4; - case VAL_OPTICAL_WAVELENGTH_ER: - return TRANSVR_CLASS_OPTICAL_40G_ER4; - default: - break; - } - return TRANSVR_CLASS_OPTICAL_40G; - - case TRANSVR_CLASS_10G: - switch (wave_len) { - case VAL_OPTICAL_WAVELENGTH_SR: - return TRANSVR_CLASS_OPTICAL_10G_Q_SR; - case VAL_OPTICAL_WAVELENGTH_LR: - return TRANSVR_CLASS_OPTICAL_10G_Q_LR; - case VAL_OPTICAL_WAVELENGTH_ER: - return TRANSVR_CLASS_OPTICAL_10G_Q_ER; - default: - break; - } - return TRANSVR_CLASS_OPTICAL_10G; - - default: - return TRANSVR_CLASS_OPTICAL; - } - -ok_qsfp_detect_class_by_feature_4_aoc: - switch(speed_val) { - case TRANSVR_CLASS_100G: - return TRANSVR_CLASS_OPTICAL_100G_AOC; - case TRANSVR_CLASS_40G: - return TRANSVR_CLASS_OPTICAL_40G_AOC; - case TRANSVR_CLASS_10G: - return TRANSVR_CLASS_OPTICAL_10G_Q_AOC; - default: - return TRANSVR_CLASS_OPTICAL; - } - -ok_qsfp_detect_class_by_feature_4_copper: - switch(speed_val) { - case TRANSVR_CLASS_100G: - return TRANSVR_CLASS_COPPER_L4_100G; - case TRANSVR_CLASS_40G: - return TRANSVR_CLASS_COPPER_L4_40G; - case TRANSVR_CLASS_10G: - return TRANSVR_CLASS_COPPER_L4_10G; - default: - return TRANSVR_CLASS_COPPER; - } - -err_qsfp_detect_class_by_feature_1: - SWPS_INFO("%s: %s\n :%s", - __func__, err_msg, self->swp_name); - return TRANSVR_CLASS_ERROR; -} - - -int -qsft_detect_transvr_class(struct transvr_obj_s* self) { - - int detect_val = DEBUG_TRANSVR_INT_VAL; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - - /* Check Extended Compliance */ - detect_val = _qsfp_detect_class_by_extend_comp(self); - switch (detect_val) { - case TRANSVR_CLASS_UNSPECIFIED: - break; - case TRANSVR_CLASS_OPTICAL_100G: - case TRANSVR_CLASS_OPTICAL_100G_AOC: - case TRANSVR_CLASS_OPTICAL_100G_SR4: - case TRANSVR_CLASS_OPTICAL_100G_LR4: - case TRANSVR_CLASS_OPTICAL_100G_ER4: - case TRANSVR_CLASS_OPTICAL_100G_PSM4: - case TRANSVR_CLASS_OPTICAL_40G: - case TRANSVR_CLASS_OPTICAL_40G_AOC: - case TRANSVR_CLASS_OPTICAL_40G_SR4: - case TRANSVR_CLASS_OPTICAL_40G_LR4: - case TRANSVR_CLASS_OPTICAL_40G_ER4: - case TRANSVR_CLASS_COPPER_L4_100G: - return detect_val; - default: - snprintf(err_msg, sizeof(err_msg), - "Detect undefined extend_comp:%d", - detect_val); - goto err_qsft_detect_transvr_class_1; - } - /* Check 10/40G/100G Ethernet Compliance */ - detect_val = _qsfp_detect_class_by_10_40_100_ethernet(self); - switch(detect_val) { - case TRANSVR_CLASS_UNSPECIFIED: - break; - case TRANSVR_CLASS_OPTICAL_40G_AOC: - case TRANSVR_CLASS_OPTICAL_40G_SR4: - case TRANSVR_CLASS_OPTICAL_40G_LR4: - case TRANSVR_CLASS_OPTICAL_10G_Q_SR: /* Need Check: SR4 or SR */ - case TRANSVR_CLASS_OPTICAL_10G_Q_LR: /* Need Check: SR4 or SR */ - case TRANSVR_CLASS_COPPER_L4_40G: - return detect_val; - case TRANSVR_CLASS_EXTEND_COMP: - /* Format incorrect case (We already checked the Extend - * Compliance is 0 - */ - snprintf(err_msg, sizeof(err_msg), - "Transceiver format incorrect"); - goto err_qsft_detect_transvr_class_1; - default: - snprintf(err_msg, sizeof(err_msg), - "Detect undefined 10/40/100:%d", - detect_val); - goto err_qsft_detect_transvr_class_1; - } - /* Check by Connector type, BR and wavelength */ - detect_val = _qsfp_detect_class_by_feature(self); - switch (detect_val) { - case TRANSVR_CLASS_UNSPECIFIED: - break; - case TRANSVR_CLASS_OPTICAL_100G_ER4: - case TRANSVR_CLASS_OPTICAL_100G_LR4: - case TRANSVR_CLASS_OPTICAL_100G_SR4: - case TRANSVR_CLASS_OPTICAL_100G_AOC: - case TRANSVR_CLASS_OPTICAL_100G: - case TRANSVR_CLASS_OPTICAL_40G_ER4: - case TRANSVR_CLASS_OPTICAL_40G_LR4: - case TRANSVR_CLASS_OPTICAL_40G_SR4: - case TRANSVR_CLASS_OPTICAL_40G_AOC: - case TRANSVR_CLASS_OPTICAL_40G: - case TRANSVR_CLASS_OPTICAL_10G_Q_ER: - case TRANSVR_CLASS_OPTICAL_10G_Q_LR: - case TRANSVR_CLASS_OPTICAL_10G_Q_SR: - case TRANSVR_CLASS_OPTICAL_10G_Q_AOC: - case TRANSVR_CLASS_OPTICAL_10G: - case TRANSVR_CLASS_OPTICAL: - case TRANSVR_CLASS_COPPER_L4_100G: - case TRANSVR_CLASS_COPPER_L4_40G: - case TRANSVR_CLASS_COPPER_L4_10G: - case TRANSVR_CLASS_COPPER: - return detect_val; - default: - snprintf(err_msg, sizeof(err_msg), - "Detect undefined connector:%d", - detect_val); - goto err_qsft_detect_transvr_class_1; - } - /* Exception case: Can't verify */ - snprintf(err_msg, sizeof(err_msg), - "Can not identify!"); - goto err_qsft_detect_transvr_class_1; - -err_qsft_detect_transvr_class_1: - SWPS_INFO("%s: %s\n :%s", __func__, err_msg, self->swp_name); - return TRANSVR_CLASS_ERROR; -} - - -int -_qsfp_set_trident2_if_type(struct transvr_obj_s* self, - int transvr_cls, - char *result){ - - int lmax = 8; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - - switch (transvr_cls) { - case TRANSVR_CLASS_UNSPECIFIED: - case TRANSVR_CLASS_ERROR: - break; - /* 100G Optical */ - case TRANSVR_CLASS_OPTICAL_100G: - case TRANSVR_CLASS_OPTICAL_100G_AOC: - case TRANSVR_CLASS_OPTICAL_100G_SR4: - case TRANSVR_CLASS_OPTICAL_100G_LR4: - case TRANSVR_CLASS_OPTICAL_100G_ER4: - case TRANSVR_CLASS_OPTICAL_100G_PSM4: - return snprintf(result, lmax, TRANSVR_IF_SR4); - /* 100G Copper */ - case TRANSVR_CLASS_COPPER_L4_100G: - return snprintf(result, lmax, TRANSVR_IF_KR4); - /* 40G Optical */ - case TRANSVR_CLASS_OPTICAL_40G: - case TRANSVR_CLASS_OPTICAL_40G_AOC: - case TRANSVR_CLASS_OPTICAL_40G_SR4: - case TRANSVR_CLASS_OPTICAL_40G_LR4: - case TRANSVR_CLASS_OPTICAL_40G_ER4: - return snprintf(result, lmax, TRANSVR_IF_IF_XGMII); - /* 40G Copper */ - case TRANSVR_CLASS_COPPER_L4_40G: - return snprintf(result, lmax, TRANSVR_IF_IF_XGMII); - /* 10G Optical */ - case TRANSVR_CLASS_OPTICAL_10G: - case TRANSVR_CLASS_OPTICAL_10G_Q_AOC: - case TRANSVR_CLASS_OPTICAL_10G_Q_SR: /* Need Check: SR4 or SR */ - case TRANSVR_CLASS_OPTICAL_10G_Q_LR: /* Need Check: LR4 or LR */ - case TRANSVR_CLASS_OPTICAL_10G_Q_ER: /* Need Check: ER4 or ER */ - return snprintf(result, lmax, TRANSVR_IF_IF_XGMII); - /* Optical */ - case TRANSVR_CLASS_OPTICAL: - return snprintf(result, lmax, TRANSVR_IF_IF_XGMII); - /* Copper */ - case TRANSVR_CLASS_COPPER: - return snprintf(result, lmax, TRANSVR_IF_IF_XGMII); - default: - snprintf(err_msg, sizeof(err_msg), - "Detect undefined value:%d", - transvr_cls); - goto err_qsfp_set_trident2_if_type_1; - } - /* Exception case: Can't verify */ - snprintf(err_msg, sizeof(err_msg), "Can not identify!"); - goto err_qsfp_set_trident2_if_type_1; - -err_qsfp_set_trident2_if_type_1: - snprintf(result, lmax, TRANSVR_UEVENT_UNKNOW); - SWPS_INFO("%s: %s\n :%s", __func__, err_msg, self->swp_name); - return ERR_TRANSVR_ABNORMAL; -} - - -int -_qsfp_set_tomahawk_if_type(struct transvr_obj_s* self, - int transvr_cls, - char *result){ - - int lmax = 8; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - - switch (transvr_cls) { - case TRANSVR_CLASS_UNSPECIFIED: - case TRANSVR_CLASS_ERROR: - break; - /* 100G Optical */ - case TRANSVR_CLASS_OPTICAL_100G: - case TRANSVR_CLASS_OPTICAL_100G_AOC: - case TRANSVR_CLASS_OPTICAL_100G_SR4: - case TRANSVR_CLASS_OPTICAL_100G_LR4: - case TRANSVR_CLASS_OPTICAL_100G_ER4: - case TRANSVR_CLASS_OPTICAL_100G_PSM4: - return snprintf(result, lmax, TRANSVR_IF_SR4); - /* 100G Copper */ - case TRANSVR_CLASS_COPPER_L4_100G: - return snprintf(result, lmax, TRANSVR_IF_KR4); - /* 40G Optical */ - case TRANSVR_CLASS_OPTICAL_40G: - case TRANSVR_CLASS_OPTICAL_40G_AOC: - case TRANSVR_CLASS_OPTICAL_40G_SR4: - case TRANSVR_CLASS_OPTICAL_40G_LR4: - case TRANSVR_CLASS_OPTICAL_40G_ER4: - return snprintf(result, lmax, TRANSVR_IF_SR4); - /* 40G Copper */ - case TRANSVR_CLASS_COPPER_L4_40G: - return snprintf(result, lmax, TRANSVR_IF_KR4); - /* 10G Optical */ - case TRANSVR_CLASS_OPTICAL_10G: - case TRANSVR_CLASS_OPTICAL_10G_Q_AOC: - case TRANSVR_CLASS_OPTICAL_10G_Q_SR: /* Need Check: SR4 or SR */ - case TRANSVR_CLASS_OPTICAL_10G_Q_LR: /* Need Check: SR4 or SR */ - case TRANSVR_CLASS_OPTICAL_10G_Q_ER: - return snprintf(result, lmax, TRANSVR_IF_SR4); - /* Optical */ - case TRANSVR_CLASS_OPTICAL: - return snprintf(result, lmax, TRANSVR_IF_SR4); - /* Copper */ - case TRANSVR_CLASS_COPPER: - return snprintf(result, lmax, TRANSVR_IF_KR4); - default: - snprintf(err_msg, sizeof(err_msg), - "Detect undefined value:%d", - transvr_cls); - goto err_qsfp_set_trident2_if_type_1; - } - /* Exception case: Can't verify */ - snprintf(err_msg, sizeof(err_msg), "Can not identify!"); - goto err_qsfp_set_trident2_if_type_1; - -err_qsfp_set_trident2_if_type_1: - snprintf(result, lmax, TRANSVR_UEVENT_UNKNOW); - SWPS_INFO("%s: %s\n :%s", __func__, err_msg, self->swp_name); - return ERR_TRANSVR_ABNORMAL; -} - - -int -_qsfp_detect_if_type(struct transvr_obj_s* self, - char *result){ - - int lmax = 8; - int detect_cls = DEBUG_TRANSVR_INT_VAL; - - detect_cls = qsft_detect_transvr_class(self); - switch (self->chipset_type) { - case BCM_CHIP_TYPE_TRIDENT_2: - return _qsfp_set_trident2_if_type(self, detect_cls, result); - - case BCM_CHIP_TYPE_TOMAHAWK: - return _qsfp_set_tomahawk_if_type(self, detect_cls, result); - - default: - SWPS_INFO("%s: non-defined chipset_type:%d :%s\n", - __func__, self->chipset_type, self->swp_name); - break; - } - snprintf(result, lmax, TRANSVR_UEVENT_UNKNOW); - return ERR_TRANSVR_ABNORMAL; -} - - -int -qsfp_get_if_type(struct transvr_obj_s *self, - char *buf_p){ - - int lmax = 8; - char tmp_result[8] = DEBUG_TRANSVR_STR_VAL; - - if (self->state != STATE_TRANSVR_CONNECTED) { - return snprintf(buf_p, lmax, "%d\n", self->state); - } - if (_qsfp_detect_if_type(self, tmp_result) < 0) { - return snprintf(buf_p, lmax, "%d\n", ERR_TRANSVR_ABNORMAL); - } - return snprintf(buf_p, lmax, "%s\n", tmp_result); -} - - -int -_qsfp_detect_if_speed(struct transvr_obj_s* self, - char *result){ - int lmax = 16; - int detect_val = DEBUG_TRANSVR_INT_VAL; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - - detect_val = qsft_detect_transvr_class(self); - switch (detect_val) { - case TRANSVR_CLASS_UNSPECIFIED: - case TRANSVR_CLASS_ERROR: - break; - /* 100G Optical */ - case TRANSVR_CLASS_OPTICAL_100G: - case TRANSVR_CLASS_OPTICAL_100G_AOC: - case TRANSVR_CLASS_OPTICAL_100G_SR4: - case TRANSVR_CLASS_OPTICAL_100G_LR4: - case TRANSVR_CLASS_OPTICAL_100G_ER4: - case TRANSVR_CLASS_OPTICAL_100G_PSM4: - return snprintf(result, lmax, TRANSVR_IF_SP_100G); - /* 100G Copper */ - case TRANSVR_CLASS_COPPER_L4_100G: - return snprintf(result, lmax, TRANSVR_IF_SP_100G); - /* 40G Optical */ - case TRANSVR_CLASS_OPTICAL_40G: - case TRANSVR_CLASS_OPTICAL_40G_AOC: - case TRANSVR_CLASS_OPTICAL_40G_SR4: - case TRANSVR_CLASS_OPTICAL_40G_LR4: - case TRANSVR_CLASS_OPTICAL_40G_ER4: - return snprintf(result, lmax, TRANSVR_IF_SP_40G); - /* 40G Copper */ - case TRANSVR_CLASS_COPPER_L4_40G: - return snprintf(result, lmax, TRANSVR_IF_SP_40G); - /* 10G Optical */ - case TRANSVR_CLASS_OPTICAL_10G: - case TRANSVR_CLASS_OPTICAL_10G_Q_AOC: - case TRANSVR_CLASS_OPTICAL_10G_Q_SR: /* Need Check: SR4 or SR */ - case TRANSVR_CLASS_OPTICAL_10G_Q_LR: /* Need Check: SR4 or SR */ - case TRANSVR_CLASS_OPTICAL_10G_Q_ER: - return snprintf(result, lmax, TRANSVR_IF_SP_10G); - /* 10G Copper */ - case TRANSVR_CLASS_COPPER_L4_10G: - return snprintf(result, lmax, TRANSVR_IF_SP_10G); - /* Optical */ - case TRANSVR_CLASS_OPTICAL: - break; - /* Copper */ - case TRANSVR_CLASS_COPPER: - break; - default: - snprintf(err_msg, sizeof(err_msg), - "Detect undefined class case:%d", - detect_val); - goto err_qsfp_detect_if_speed_1; - } - /* Check br and extbr */ - detect_val = _qsfp_detect_if_sp_by_br(self); - switch(detect_val) { - case TRANSVR_CLASS_UNSPECIFIED: - break; - case TRANSVR_CLASS_10G: - return snprintf(result, lmax, TRANSVR_IF_SP_10G); - case TRANSVR_CLASS_40G: - return snprintf(result, lmax, TRANSVR_IF_SP_40G); - case TRANSVR_CLASS_100G: - return snprintf(result, lmax, TRANSVR_IF_SP_100G); - default: - snprintf(err_msg, sizeof(err_msg), - "Detect undefined BR case:%d", - detect_val); - goto err_qsfp_detect_if_speed_1; - } - /* Exception case: Can't verify */ - snprintf(err_msg, sizeof(err_msg), "Can not identify!"); - goto err_qsfp_detect_if_speed_1; - -err_qsfp_detect_if_speed_1: - snprintf(result, lmax, TRANSVR_UEVENT_UNKNOW); - SWPS_INFO("%s: %s :%s\n", __func__, err_msg, self->swp_name); - return ERR_TRANSVR_ABNORMAL; -} - - -int -qsfp_get_if_speed(struct transvr_obj_s *self, - char *buf_p){ - - int lmax = 16; - char tmp_result[16] = DEBUG_TRANSVR_STR_VAL; - - if (self->state != STATE_TRANSVR_CONNECTED) { - return snprintf(buf_p, lmax, "%d\n", self->state); - } - if (_qsfp_detect_if_speed(self, tmp_result) < 0) { - return snprintf(buf_p, lmax, "%d\n", ERR_TRANSVR_ABNORMAL); - } - return snprintf(buf_p, lmax, "%s\n", tmp_result); -} - - -int -_common_set_lane_map_str(struct transvr_obj_s* self, - char *result) { - int i = 0; - int tmp_val = 0; - char tmp_str[LEN_TRANSVR_L_STR] = DEBUG_TRANSVR_STR_VAL; - char err_msg[LEN_TRANSVR_L_STR] = DEBUG_TRANSVR_STR_VAL; - - memset(result, 0, LEN_TRANSVR_L_STR); - snprintf(result, LEN_TRANSVR_L_STR, "%s=", TRANSVR_UEVENT_KEY_LANE); - - for (i=0; ilane_id); i++) { - tmp_val = self->lane_id[i]; - if (tmp_val < 1) { - break; - } - if (tmp_val > 256) { - snprintf(err_msg, sizeof(err_msg), - "detect abnormal value:%d", tmp_val); - goto err_common_set_lane_map_str_1; - } - memset(tmp_str, 0, sizeof(tmp_str)); - if (i == 0) { - snprintf(tmp_str, LEN_TRANSVR_L_STR, "%d", tmp_val); - } else { - snprintf(tmp_str, LEN_TRANSVR_L_STR, ",%d", tmp_val); - } - strncat(result, tmp_str, LEN_TRANSVR_L_STR); - } - if (i == 0) { - goto err_common_set_lane_map_str_2; - } - return 0; - -err_common_set_lane_map_str_1: - SWPS_INFO("%s: %s", __func__, err_msg); -err_common_set_lane_map_str_2: - snprintf(result, LEN_TRANSVR_L_STR, "%s=%s", TRANSVR_UEVENT_KEY_LANE, TRANSVR_UEVENT_UNKNOW); - return EVENT_TRANSVR_TASK_FAIL; -} - - -int -_common_send_uevent(struct transvr_obj_s* self, - enum kobject_action u_action, - int (*detect_if_type)(struct transvr_obj_s *self, char *result), - int (*detect_if_speed)(struct transvr_obj_s *self, char *result), - int send_anyway) { - - char *uevent_envp[4]; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - char tmp_str[32] = DEBUG_TRANSVR_STR_VAL; - char tmp_str_1[32] = DEBUG_TRANSVR_STR_VAL; - char tmp_str_2[32] = DEBUG_TRANSVR_STR_VAL; - char tmp_str_3[64] = DEBUG_TRANSVR_STR_VAL; - - if (TRANSVR_UEVENT_ENABLE != 1) { - return ERR_TRANSVR_NOTSUPPORT; - } - if (_common_get_if_lane(self, tmp_str) < 0) { - snprintf(tmp_str_3, sizeof(tmp_str_3), - "%s=%s", TRANSVR_UEVENT_KEY_LANE, TRANSVR_UEVENT_UNKNOW); - } else { - snprintf(tmp_str_3, sizeof(tmp_str_3), - "%s=%s", TRANSVR_UEVENT_KEY_LANE, tmp_str); - } - switch (u_action) { - case KOBJ_ADD: - /* Detect type */ - if (detect_if_type(self, tmp_str) < 0) { - snprintf(err_msg, sizeof(err_msg), "%s", "Detect interface type fail!"); - snprintf(tmp_str_1, sizeof(tmp_str_1), "%s=%s", TRANSVR_UEVENT_KEY_IF, TRANSVR_UEVENT_UNKNOW); - snprintf(tmp_str_2, sizeof(tmp_str_2), "%s=%s", TRANSVR_UEVENT_KEY_SP, TRANSVR_UEVENT_UNKNOW); - uevent_envp[0] = tmp_str_1; - uevent_envp[1] = tmp_str_2; - uevent_envp[2] = tmp_str_3; - uevent_envp[3] = NULL; - goto private_common_send_uevent_4_fail; - } - snprintf(tmp_str_1, sizeof(tmp_str_1), "%s=%s", TRANSVR_UEVENT_KEY_IF, tmp_str); - uevent_envp[0] = tmp_str_1; - /* Detect speed */ - if (detect_if_speed(self, tmp_str) < 0) { - snprintf(err_msg, sizeof(err_msg), "%s", "Detect interface speed fail!"); - snprintf(tmp_str_2, sizeof(tmp_str_2), "%s=%s", TRANSVR_UEVENT_KEY_SP, TRANSVR_UEVENT_UNKNOW); - uevent_envp[1] = tmp_str_2; - uevent_envp[2] = tmp_str_3; - uevent_envp[3] = NULL; - goto private_common_send_uevent_4_fail; - } - snprintf(tmp_str_2, sizeof(tmp_str_2), "%s=%s", TRANSVR_UEVENT_KEY_SP, tmp_str); - uevent_envp[1] = tmp_str_2; - uevent_envp[2] = tmp_str_3; - uevent_envp[3] = NULL; - goto private_common_send_uevent_4_send; - - case KOBJ_REMOVE: - snprintf(tmp_str_1, sizeof(tmp_str_1), "%s=%s", TRANSVR_UEVENT_KEY_IF, TRANSVR_UEVENT_UNKNOW); - snprintf(tmp_str_2, sizeof(tmp_str_2), "%s=%s", TRANSVR_UEVENT_KEY_SP, TRANSVR_UEVENT_UNKNOW); - uevent_envp[0] = tmp_str_1; - uevent_envp[1] = tmp_str_2; - uevent_envp[2] = tmp_str_3; - uevent_envp[3] = NULL; - goto private_common_send_uevent_4_send; - - default: - snprintf(err_msg, sizeof(err_msg), "kobject_action:%d not support", u_action); - goto private_common_send_uevent_4_fail; - } - snprintf(err_msg, sizeof(err_msg), "%s", "Exception case"); - goto private_common_send_uevent_4_fail; - -private_common_send_uevent_4_fail: - SWPS_INFO("%s: %s :%s\n", __func__, err_msg, self->swp_name); - if (send_anyway) { - goto private_common_send_uevent_4_send; - } - return ERR_TRANSVR_UEVENT_FAIL; - -private_common_send_uevent_4_send: - return kobject_uevent_env(&(self->transvr_dev_p->kobj), - u_action, - uevent_envp); -} - -int -sfp_send_uevent(struct transvr_obj_s* self, - enum kobject_action u_action) { - int send_anyway = 1; - return _common_send_uevent(self, - u_action, - &_sfp_detect_if_type, - &_sfp_detect_if_speed, - send_anyway); -} - - -int -qsfp_send_uevent(struct transvr_obj_s* self, - enum kobject_action u_action) { - int send_anyway = 1; - return _common_send_uevent(self, - u_action, - &_qsfp_detect_if_type, - &_qsfp_detect_if_speed, - send_anyway); -} - - -int -fake_send_uevent(struct transvr_obj_s* self, - enum kobject_action u_action) { - return EVENT_TRANSVR_TASK_DONE; -} - - -int -common_fsm_4_direct_mode(struct transvr_obj_s* self, - char *caller_name){ - - int err; - int detect_result[2]; - int current_state = STATE_TRANSVR_UNEXCEPTED; - int current_type = TRANSVR_TYPE_ERROR; - - if (self->state == STATE_TRANSVR_NEW) { - if (_transvr_init_handler(self) < 0){ - return ERR_TRANSVR_INIT_FAIL; - } - } - err = detect_transvr_state(self, detect_result); - if (err < 0) { - return err; - } - /* In Direct mode, driver only detect transceiver when user call driver interface - * which on sysfs. So it only need consider the state of Transceiver. - */ - current_state = detect_result[0]; - current_type = detect_result[1]; - - switch (current_state){ - - case STATE_TRANSVR_DISCONNECTED: /* Transceiver is not plugged */ - self->state = current_state; - self->type = current_type; - return ERR_TRANSVR_UNPLUGGED; - - case STATE_TRANSVR_INIT: /* Transceiver is plugged, system not ready */ - return ERR_TRANSVR_UNINIT; - - case STATE_TRANSVR_ISOLATED: /* Transceiver is plugged, but has some issues */ - return ERR_TRNASVR_BE_ISOLATED; - - case STATE_TRANSVR_CONNECTED: /* Transceiver is plugged, system is ready */ - self->state = current_state; - self->type = current_type; - return 0; - - case STATE_TRANSVR_SWAPPED: /* Transceiver is plugged, system detect user changed */ - self->type = current_type; - if (reload_transvr_obj(self, current_type) < 0){ - self->state = STATE_TRANSVR_UNEXCEPTED; - return ERR_TRANSVR_UNEXCPT; - } - self->state = current_state; - return 0; - - case STATE_TRANSVR_UNEXCEPTED: /* Transceiver type or state is unexpected case */ - self->state = STATE_TRANSVR_UNEXCEPTED; - self->type = TRANSVR_TYPE_ERROR; - return ERR_TRANSVR_UNEXCPT; - - default: - SWPS_INFO("%s: state:%d not in define.\n", __func__, current_state); - break; - } - return ERR_TRANSVR_UNEXCPT; -} - - -static int -_is_except_happened_4_pmode(struct transvr_obj_s* self, - int new_state) { - - int event_chk = 0; - - if (self->temp == 0){ - return 0; - } - switch (new_state) { - case STATE_TRANSVR_INIT: - event_chk = EVENT_TRANSVR_EXCEP_INIT; - goto check_event_happened_4_pmode; - - case STATE_TRANSVR_CONNECTED: - event_chk = EVENT_TRANSVR_EXCEP_UP; - goto check_event_happened_4_pmode; - - case STATE_TRANSVR_DISCONNECTED: - event_chk = EVENT_TRANSVR_EXCEP_DOWN; - goto check_event_happened_4_pmode; - - case STATE_TRANSVR_SWAPPED: - event_chk = EVENT_TRANSVR_EXCEP_SWAP; - goto check_event_happened_4_pmode; - - case STATE_TRANSVR_UNEXCEPTED: - event_chk = EVENT_TRANSVR_EXCEP_EXCEP; - goto check_event_happened_4_pmode; - - case STATE_TRANSVR_ISOLATED: - event_chk = EVENT_TRANSVR_EXCEP_ISOLATED; - goto check_event_happened_4_pmode; - - default: - SWPS_INFO("%s: unexcepted case:%d\n", __func__, new_state); - break; - } - return 0; - -check_event_happened_4_pmode: - if (self->temp == event_chk){ - return 1; - } - return 0; -} - - -int -common_fsm_4_polling_mode(struct transvr_obj_s* self, - char *caller_name){ - /* [Return Value]: - * ERR_TRANSVR_UNINIT : (1) Initial not ready - * ERR_TRANSVR_UNPLUGGED : (1) Any -> Down - * ERR_TRANSVR_TASK_BUSY : (1) Wait Initial task - * ERR_TRANSVR_UNEXCPT : (1) Initial fail - * (2) Task fail - * (3) Reload fail - * ERR_TRNASVR_BE_ISOLATED : (1) Already be isolated - * OK Case (return 0) : (1) action_4_connected - * (2) action_4_nothing (initial retry) - */ - int curr_state[2]; - int old_state = self->state; - int old_type = self->type; - int new_state = STATE_TRANSVR_UNEXCEPTED; - int new_type = TRANSVR_TYPE_ERROR; - int return_val = ERR_TRANSVR_UNEXCPT; - - /* Never initial */ - if (self->state == STATE_TRANSVR_NEW) { - goto comfsm_action_4_reinit_obj; - } - /* Detect current state */ - switch (detect_transvr_state(self, curr_state)) { - case 0: - new_state = curr_state[0]; - new_type = curr_state[1]; - break; - - case ERR_TRNASVR_BE_ISOLATED: - new_state = STATE_TRANSVR_ISOLATED; - new_type = old_type; - break; - - case ERR_TRANSVR_I2C_CRASH: - goto comfsm_action_4_report_i2c_crash; - - case ERR_TRANSVR_UNEXCPT: - default: - new_state = STATE_TRANSVR_UNEXCEPTED; - new_type = old_type; - } - /* State handling */ - switch (old_state) { - case STATE_TRANSVR_INIT: /* INIT -> */ - return_val = ERR_TRANSVR_UNINIT; - goto comfsm_action_4_keep_state; - - case STATE_TRANSVR_CONNECTED: - switch (new_state) { - case STATE_TRANSVR_INIT: /* Case 1-1: UP -> INIT */ - SWPS_INFO("Detect %s is present. :1-1\n",self->swp_name); - return_val = ERR_TRANSVR_UNINIT; - goto comfsm_action_4_keep_state; - - case STATE_TRANSVR_CONNECTED: /* Case 1-2: UP -> UP */ - return_val = 0; - goto comfsm_action_4_keep_state; - - case STATE_TRANSVR_DISCONNECTED: /* Case 1-3: UP -> DOWN */ - SWPS_INFO("Detect %s is removed. :1-3\n",self->swp_name); - goto comfsm_action_4_disconnected; - - case STATE_TRANSVR_SWAPPED: /* Case 1-4: UP -> SWAP */ - SWPS_INFO("Detect %s is swapped. :1-4\n",self->swp_name); - goto comfsm_action_4_reload_obj; - - case STATE_TRANSVR_UNEXCEPTED: /* Case 1-5: UP -> UNEXPET */ - SWPS_INFO("Detect %s has error. :1-5\n",self->swp_name); - goto comfsm_action_4_unexpected; - - case STATE_TRANSVR_ISOLATED: /* Case 1-6: UP -> ISOLATE */ - SWPS_INFO("Detect %s be isolated. :1-6\n",self->swp_name); - goto comfsm_action_4_isolate_obj; - - default: - break; - } - goto comfsm_action_4_unexpected; - - case STATE_TRANSVR_DISCONNECTED: - switch (new_state) { - case STATE_TRANSVR_INIT: /* Case 2-1: DOWN -> INIT */ - SWPS_INFO("Detect %s is present. :2-1\n",self->swp_name); - return_val = ERR_TRANSVR_UNINIT; - goto comfsm_action_4_keep_state; - - case STATE_TRANSVR_CONNECTED: /* Case 2-2: DOWN -> UP */ - SWPS_INFO("Detect %s is present. :2-2\n",self->swp_name); - goto comfsm_action_4_reinit_obj; - - case STATE_TRANSVR_DISCONNECTED: /* Case 2-3: DOWN -> DOWN */ - return_val = ERR_TRANSVR_UNPLUGGED; - goto comfsm_action_4_keep_state; - - case STATE_TRANSVR_SWAPPED: /* Case 2-4: DOWN -> SWAP */ - SWPS_INFO("Detect %s is swapped. :2-4\n",self->swp_name); - goto comfsm_action_4_reload_obj; - - case STATE_TRANSVR_UNEXCEPTED: /* Case 2-5: DOWN -> UNEXPET */ - SWPS_INFO("Detect %s has error. :2-5\n",self->swp_name); - goto comfsm_action_4_unexpected; - - case STATE_TRANSVR_ISOLATED: /* Case 2-6: DOWN -> ISOLATE */ - SWPS_INFO("Detect %s be isolated. :2-6\n",self->swp_name); - goto comfsm_action_4_isolate_obj; - - default: - break; - } - goto comfsm_action_4_unexpected; - - case STATE_TRANSVR_UNEXCEPTED: - /* Filter out re-action */ - if (_is_except_happened_4_pmode(self, new_state)) { - goto comfsm_action_4_keep_state; - } - /* First action */ - switch (new_state) { - case STATE_TRANSVR_INIT: /* Case 3-1: UNEXPET -> INIT */ - SWPS_INFO("Detect %s is present. :3-1\n",self->swp_name); - self->temp = EVENT_TRANSVR_EXCEP_INIT; - return_val = ERR_TRANSVR_UNINIT; - goto comfsm_action_4_keep_state; - - case STATE_TRANSVR_CONNECTED: /* Case 3-2: UNEXPET -> UP */ - SWPS_INFO("Detect %s is present. :3-2\n",self->swp_name); - self->temp = EVENT_TRANSVR_EXCEP_UP; - goto comfsm_action_4_reload_obj; - - case STATE_TRANSVR_DISCONNECTED: /* Case 3-3: UNEXPET -> DOWN */ - SWPS_INFO("Detect %s is removed. :3-3\n",self->swp_name); - goto comfsm_action_4_disconnected; - - case STATE_TRANSVR_SWAPPED: /* Case 3-4: UNEXPET -> SWAP */ - SWPS_INFO("Detect %s is swapped. :3-4\n",self->swp_name); - self->temp = EVENT_TRANSVR_EXCEP_SWAP; - goto comfsm_action_4_reload_obj; - - case STATE_TRANSVR_UNEXCEPTED: /* Case 3-5: UNEXPET -> UNEXPET */ - self->temp = EVENT_TRANSVR_EXCEP_EXCEP; - return_val = ERR_TRANSVR_UNEXCPT; - goto comfsm_action_4_keep_state; - - case STATE_TRANSVR_ISOLATED: /* Case 3-6: UNEXPET -> ISOLATE */ - SWPS_INFO("Detect %s be isolated. :3-6\n",self->swp_name); - goto comfsm_action_4_isolate_obj; - - default: - break; - } - goto comfsm_action_4_unexpected; - - case STATE_TRANSVR_ISOLATED: - /* Filter out re-action */ - if (_is_except_happened_4_pmode(self, new_state)) { - goto comfsm_action_4_keep_state; - } - /* First action */ - switch (new_state) { - case STATE_TRANSVR_INIT: /* Case 4-1: ISOLATE -> INIT */ - SWPS_INFO("Detect %s internal error. :4-1\n",self->swp_name); - self->temp = EVENT_TRANSVR_EXCEP_INIT; - return_val = ERR_TRNASVR_BE_ISOLATED; - goto comfsm_action_4_keep_state; - - case STATE_TRANSVR_CONNECTED: /* Case 4-2: ISOLATE -> UP */ - SWPS_INFO("Detect %s internal error. :4-2\n",self->swp_name); - self->temp = EVENT_TRANSVR_EXCEP_UP; - return_val = ERR_TRNASVR_BE_ISOLATED; - goto comfsm_action_4_keep_state; - - case STATE_TRANSVR_DISCONNECTED: /* Case 4-3: ISOLATE -> DOWN */ - SWPS_INFO("Detect %s is removed. :4-3\n",self->swp_name); - goto comfsm_action_4_disconnected; - - case STATE_TRANSVR_SWAPPED: /* Case 4-4: ISOLATE -> SWAP */ - SWPS_INFO("Detect %s internal error. :4-4\n",self->swp_name); - self->temp = EVENT_TRANSVR_EXCEP_SWAP; - return_val = ERR_TRNASVR_BE_ISOLATED; - goto comfsm_action_4_keep_state; - - case STATE_TRANSVR_UNEXCEPTED: /* Case 4-5: ISOLATE -> UNEXPET */ - SWPS_INFO("Detect %s internal error. :4-5\n",self->swp_name); - self->temp = EVENT_TRANSVR_EXCEP_EXCEP; - return_val = ERR_TRNASVR_BE_ISOLATED; - goto comfsm_action_4_keep_state; - - case STATE_TRANSVR_ISOLATED: /* Case 4-6: ISOLATE -> ISOLATE */ - return_val = ERR_TRNASVR_BE_ISOLATED; - goto comfsm_action_4_keep_state; - - default: - break; - } - goto comfsm_action_4_unexpected; - - default: - break; - } - goto comfsm_action_4_unexpected; - - -comfsm_action_4_keep_state: - return return_val; - -comfsm_action_4_reinit_obj: - SWPS_DEBUG("FSM action: %s re-initial.\n", self->swp_name); - return_val = _transvr_init_handler(self); - goto comfsm_action_4_identify_event; - -comfsm_action_4_reload_obj: - SWPS_DEBUG("FSM action: %s reload.\n", self->swp_name); - self->type = new_type; - return_val = reload_transvr_obj(self, new_type); - goto comfsm_action_4_identify_event; - -comfsm_action_4_identify_event: - switch (return_val) { - case EVENT_TRANSVR_INIT_UP: - case EVENT_TRANSVR_TASK_DONE: - goto comfsm_action_4_connected; - - case EVENT_TRANSVR_INIT_DOWN: - goto comfsm_action_4_disconnected; - - case EVENT_TRANSVR_INIT_REINIT: - goto comfsm_action_4_nothing; - - case EVENT_TRANSVR_TASK_WAIT: - self->state = STATE_TRANSVR_INIT; - return ERR_TRANSVR_TASK_BUSY; - - case EVENT_TRANSVR_TASK_FAIL: - SWPS_INFO("%s detect EVENT_TRANSVR_TASK_FAIL.\n", self->swp_name); - goto comfsm_action_4_unexpected; - - case EVENT_TRANSVR_INIT_FAIL: - SWPS_INFO("%s detect EVENT_TRANSVR_INIT_FAIL.\n", self->swp_name); - goto comfsm_action_4_unexpected; - - case EVENT_TRANSVR_RELOAD_FAIL: - SWPS_INFO("%s detect EVENT_TRANSVR_RELOAD_FAIL.\n", self->swp_name); - goto comfsm_action_4_unexpected; - - case EVENT_TRANSVR_I2C_CRASH: - goto comfsm_action_4_report_i2c_crash; - - case EVENT_TRANSVR_EXCEP_ISOLATED: - goto comfsm_action_4_isolate_obj; - - default: - SWPS_INFO("%s detect undefined event:%d.\n", self->swp_name, return_val); - goto comfsm_action_4_unexpected; - } - -comfsm_action_4_nothing: - SWPS_DEBUG("FSM action: %s do nothing.\n", self->swp_name); - return 0; - -comfsm_action_4_connected: - SWPS_DEBUG("FSM action: %s Connected.\n", self->swp_name); - self->state = STATE_TRANSVR_CONNECTED; - self->type = new_type; - self->send_uevent(self, KOBJ_ADD); - _transvr_clean_retry(self); - return 0; - -comfsm_action_4_disconnected: - SWPS_DEBUG("FSM action: %s Disconnected. \n", self->swp_name); - self->state = STATE_TRANSVR_DISCONNECTED; - self->temp = EVENT_TRANSVR_TASK_DONE; - self->send_uevent(self, KOBJ_REMOVE); - _transvr_clean_retry(self); - _transvr_clean_handler(self); - return ERR_TRANSVR_UNPLUGGED; - -comfsm_action_4_report_i2c_crash: - SWPS_DEBUG("FSM action: %s report I2C crash.\n", self->swp_name); - self->state = STATE_TRANSVR_UNEXCEPTED; - return ERR_TRANSVR_I2C_CRASH; - -comfsm_action_4_isolate_obj: - SWPS_DEBUG("FSM action: %s isolate.\n", self->swp_name); - self->state = STATE_TRANSVR_ISOLATED; - return ERR_TRNASVR_BE_ISOLATED; - -comfsm_action_4_unexpected: - SWPS_INFO("FSM action: %s unexpected.\n", self->swp_name); - SWPS_INFO("Dump: :%d :0x%02x :%d :0x%02x\n", - old_state, old_type, new_state, new_type); - self->state = STATE_TRANSVR_UNEXCEPTED; - self->send_uevent(self, KOBJ_REMOVE); - _transvr_clean_handler(self); - return ERR_TRANSVR_UNEXCPT; -} - - -int -fake_fsm_4_direct_mode(struct transvr_obj_s* self, - char *caller_name){ - self->state = STATE_TRANSVR_CONNECTED; - self->type = TRANSVR_TYPE_FAKE; - return 0; -} - - -int -fake_fsm_4_polling_mode(struct transvr_obj_s* self, - char *caller_name){ - self->state = STATE_TRANSVR_CONNECTED; - self->type = TRANSVR_TYPE_FAKE; - return 0; -} - - -/* ========== Object functions for Initial procedure ========== - */ -int -transvr_init_common(struct transvr_obj_s *self){ - /* Nothing to update */ - return EVENT_TRANSVR_TASK_DONE; -} - - -int -transvr_init_fake(struct transvr_obj_s *self){ - return EVENT_TRANSVR_TASK_DONE; -} - - -int -transvr_init_sfp(struct transvr_obj_s *self){ - - int tmp_val = DEBUG_TRANSVR_INT_VAL; - int err_code = DEBUG_TRANSVR_INT_VAL; - char *err_msg = "ERR"; - - self->info = sft_detect_transvr_class(self); - /* Disable auto_config */ - if (!self->auto_config) { - return EVENT_TRANSVR_TASK_DONE; - } - /* Handle multi-rate */ - err_code = initfunc_sfp_handle_multi_rate_mode(self); - if (err_code < 0) { - err_msg = "initfunc_sfp_handle_multi_rate_mode fail!"; - goto err_transvr_init_sfp_1; - } - /* Handle 1G- RJ45 */ - tmp_val = err_code; - err_code = initfunc_sfp_handle_1g_rj45(self); - if (err_code < 0) { - err_msg = "initfunc_sfp_handle_1g_rj45 fail!"; - goto err_transvr_init_sfp_1; - } - tmp_val = (tmp_val > err_code ? tmp_val : err_code); - if (tmp_val > EVENT_TRANSVR_TASK_DONE) { - return tmp_val; - } - return EVENT_TRANSVR_TASK_DONE; - -err_transvr_init_sfp_1: - SWPS_INFO("%s: %s :%d :%s\n", - __func__, err_msg, err_code, self->swp_name); - return EVENT_TRANSVR_INIT_FAIL; -} - - -int -transvr_init_qsfp(struct transvr_obj_s *self){ - - int err = EVENT_TRANSVR_EXCEP_EXCEP; - char *emsg = "ERR"; - - self->info = qsft_detect_transvr_class(self); - if (!self->auto_config) { - return EVENT_TRANSVR_TASK_DONE; - } - err = initfunc_qsfp_handle_power_mode(self); - if (err < 0){ - emsg = "initfunc_qsfp_handle_tx_disable fail!"; - goto err_transvr_init_qsfp; - } - return EVENT_TRANSVR_TASK_DONE; - -err_transvr_init_qsfp: - SWPS_INFO("%s: %s :%d :%s\n", - __func__, emsg, err, self->swp_name); - return EVENT_TRANSVR_INIT_FAIL; -} - - -int -transvr_init_qsfp28(struct transvr_obj_s *self){ - - int tmp_val = EVENT_TRANSVR_EXCEP_EXCEP; - int err_val = EVENT_TRANSVR_EXCEP_EXCEP; - char *err_msg = "ERR"; - - /* Handle QSFP common */ - err_val = transvr_init_qsfp(self); - if (err_val < 0){ - err_msg = "transvr_init_qsfp fail!"; - goto err_transvr_init_qsfp28_1; - } - /* Disable auto_config */ - if (!self->auto_config) { - return err_val; - } - /* Handle CDR */ - tmp_val = err_val; - err_val = initfunc_qsfp28_handle_cdr(self); - if (err_val < 0){ - err_msg = "Handle CDR fail!"; - goto err_transvr_init_qsfp28_1; - } - tmp_val = (tmp_val > err_val ? tmp_val : err_val); - if (tmp_val > EVENT_TRANSVR_TASK_DONE) { - return tmp_val; - } - return EVENT_TRANSVR_TASK_DONE; - -err_transvr_init_qsfp28_1: - SWPS_INFO("%s: %s :%d :%s\n", - __func__, err_msg, err_val, self->swp_name); - return EVENT_TRANSVR_INIT_FAIL; -} - - -/* ========== Object Initial handler ========== - */ -static int -_is_transvr_valid(struct transvr_obj_s *self, - int type, - int state) { - /* [Return] - * 0 : OK, inserted - * EVENT_TRANSVR_INIT_DOWN : OK, removed - * EVENT_TRANSVR_INIT_FAIL : Outside error, type doesn't supported - * EVENT_TRANSVR_EXCEP_INIT : Internal error, state undefined - */ - switch (type) { - case TRANSVR_TYPE_SFP: - case TRANSVR_TYPE_QSFP: - case TRANSVR_TYPE_QSFP_PLUS: - case TRANSVR_TYPE_QSFP_28: - case TRANSVR_TYPE_UNPLUGGED: - case TRANSVR_TYPE_FAKE: - break; - default: - SWPS_INFO("detect undefined type:0x%02x on %s\n", - type, self->swp_name); - return EVENT_TRANSVR_INIT_FAIL; - } - switch (state) { - case STATE_TRANSVR_DISCONNECTED: - return EVENT_TRANSVR_INIT_DOWN; - case STATE_TRANSVR_INIT: - case STATE_TRANSVR_CONNECTED: - case STATE_TRANSVR_SWAPPED: - break; - default: - SWPS_INFO("detect undefined state:%d on %s\n", - state, self->swp_name); - return EVENT_TRANSVR_EXCEP_INIT; - } - return 0; -} - - -static int -_is_transvr_hw_ready(struct transvr_obj_s *self, - int type){ - /* [Return] - * EVENT_TRANSVR_TASK_DONE : Ready - * EVENT_TRANSVR_TASK_WAIT : Not ready - * EVENT_TRANSVR_INIT_FAIL : Error - */ - int addr = DEBUG_TRANSVR_INT_VAL; - int page = DEBUG_TRANSVR_INT_VAL; - int offs = DEBUG_TRANSVR_INT_VAL; - int bit = DEBUG_TRANSVR_INT_VAL; - int ready = DEBUG_TRANSVR_INT_VAL; - int err = DEBUG_TRANSVR_INT_VAL; - char *emsg = DEBUG_TRANSVR_STR_VAL; - uint8_t ab_val = DEBUG_TRANSVR_HEX_VAL; - - switch (type) { - case TRANSVR_TYPE_SFP: - addr = VAL_TRANSVR_8472_READY_ADDR; - page = VAL_TRANSVR_8472_READY_PAGE; - offs = VAL_TRANSVR_8472_READY_OFFSET; - bit = VAL_TRANSVR_8472_READY_BIT; - ready = VAL_TRANSVR_8472_READY_VALUE; - ab_val = VAL_TRANSVR_8472_READY_ABNORMAL; - break; - - case TRANSVR_TYPE_QSFP: - case TRANSVR_TYPE_QSFP_PLUS: - case TRANSVR_TYPE_QSFP_28: - addr = VAL_TRANSVR_8436_READY_ADDR; - page = VAL_TRANSVR_8436_READY_PAGE; - offs = VAL_TRANSVR_8436_READY_OFFSET; - bit = VAL_TRANSVR_8436_READY_BIT; - ready = VAL_TRANSVR_8436_READY_VALUE; - ab_val = VAL_TRANSVR_8436_READY_ABNORMAL; - break; - - case TRANSVR_TYPE_UNPLUGGED: - case TRANSVR_TYPE_FAKE: - return EVENT_TRANSVR_TASK_DONE; - - default: - emsg = "unexpected case"; - goto err_is_transvr_hw_ready; - } - /* Select target page */ - err = _common_setup_page(self, addr, page, offs, 1, 0); - if (err < 0) { - emsg = "setup page fail"; - goto err_is_transvr_hw_ready; - } - /* Check feature supported - * [Note] - * Some of transceiver/cables doesn't support "Status Indicators" - * (ex:DAC, RJ45 copper SFP ...etc). In these case, we bypass the - * step of checking Status Indicators, then state machine will take - * the following handle procedure. - */ - err = i2c_smbus_read_byte_data(self->i2c_client_p, - VAL_TRANSVR_COMID_OFFSET); - if (err < 0) { - emsg = "doesn't support Status Indicators"; - goto bypass_is_transvr_hw_ready; - } - /* Filter abnormal case */ - if (err == ab_val) { - emsg = "detect using unusual definition."; - goto bypass_is_transvr_hw_ready; - } - /* Get Status Indicators */ - err = i2c_smbus_read_byte_data(self->i2c_client_p, offs); - if (err < 0) { - emsg = "detect current value fail"; - goto err_is_transvr_hw_ready; - } - if ((err & (1<:%d\n", __func__, emsg, type); - return EVENT_TRANSVR_TASK_DONE; - -err_is_transvr_hw_ready: - SWPS_DEBUG("%s: %s :%d\n", __func__, emsg, type); - return EVENT_TRANSVR_INIT_FAIL; -} - - -static int -_is_transvr_support_ctle(struct transvr_obj_s *self) { - - switch (self->info) { - case TRANSVR_CLASS_OPTICAL_25G: - case TRANSVR_CLASS_OPTICAL_25G_AOC: - case TRANSVR_CLASS_OPTICAL_25G_SR: - case TRANSVR_CLASS_OPTICAL_25G_LR: - case TRANSVR_CLASS_OPTICAL_25G_ER: - case TRANSVR_CLASS_OPTICAL_100G: - case TRANSVR_CLASS_OPTICAL_100G_AOC: - case TRANSVR_CLASS_OPTICAL_100G_SR4: - case TRANSVR_CLASS_OPTICAL_100G_LR4: - case TRANSVR_CLASS_OPTICAL_100G_ER4: - case TRANSVR_CLASS_OPTICAL_100G_PSM4: - return 1; - default: - break; - } - return 0; -} - - -static int -_transvr_init_handler(struct transvr_obj_s *self){ - - int detect[2]; - int d_state = STATE_TRANSVR_UNEXCEPTED; - int d_type = TRANSVR_TYPE_ERROR; - int result = ERR_TRANSVR_UNINIT; - int retry = 6; /* (6+1) x 0.3 = 2.1s > spec:2.0s */ - int elimit = 63; - char emsg[64] = DEBUG_TRANSVR_STR_VAL; - - /* Clean and check callback */ - self->state = STATE_TRANSVR_INIT; - if (self->init == NULL) { - snprintf(emsg, elimit, "init() is null"); - goto initer_err_case_unexcept_0; - } - if (self->clean == NULL) { - snprintf(emsg, elimit, "clean() is null"); - goto initer_err_case_unexcept_0; - } - self->clean(self); - - /* Detect transceiver information */ - result = detect_transvr_state(self, detect); - if (result < 0) { - snprintf(emsg, elimit, "detect_transvr_state() fail"); - switch (result) { - case ERR_TRANSVR_I2C_CRASH: - goto initer_err_case_i2c_ceash; - case ERR_TRNASVR_BE_ISOLATED: - goto initer_err_case_be_isolated; - - case ERR_TRANSVR_UNEXCPT: - default: - break; - } - goto initer_err_case_retry_1; - } - d_state = detect[0]; - d_type = detect[1]; - - /* Verify transceiver type and state */ - switch (_is_transvr_valid(self, d_type, d_state)) { - case 0: - break; - case EVENT_TRANSVR_INIT_DOWN: - goto initer_ok_case_down;; - case EVENT_TRANSVR_INIT_FAIL: - snprintf(emsg, elimit, "transceiver type doesn't support"); - goto initer_err_case_alarm_to_user; - case EVENT_TRANSVR_EXCEP_INIT: - default: - goto initer_err_case_unexcept_1; - } - - /* Handle reload case */ - if (self->type != d_type){ - /* This is the protect mechanism. Normally, This case will not happen. - * When State machine detect swap event during initial, It will trigger - * reload function to ensure type correct. */ - if (_reload_transvr_obj(self, d_type) < 0){ - snprintf(emsg, elimit, "reload object fail"); - goto initer_err_case_unexcept_1; - } - } - - /* Check transceiver HW initial ready */ - switch (_is_transvr_hw_ready(self, d_type)) { - case EVENT_TRANSVR_TASK_DONE: - break; - case EVENT_TRANSVR_TASK_WAIT: - goto initer_err_case_retry_1; - case EVENT_TRANSVR_INIT_FAIL: - default: - goto initer_err_case_unexcept_1; - } - - /* Try to update all and check */ - if (self->update_all(self, 1) < 0){ - /* For some transceiver, EEPROME has lag issues during initial stage. - * In this case, we set status back to STATE_TRANSVR_NEW, than it will - * be checked in next polling cycle. */ - goto initer_err_case_retry_1; - } - - /* Execute init() call back */ - result = self->init(self); - switch (result) { - case EVENT_TRANSVR_TASK_DONE: - break; - case EVENT_TRANSVR_TASK_WAIT: - goto initer_ok_case_wait; - - default: - snprintf(emsg, elimit, "undefined init() return:%d\n", result); - goto initer_err_case_unexcept_1; - } - goto initer_ok_case_up; - - -initer_ok_case_wait: - self->dump_all(self); - return EVENT_TRANSVR_TASK_WAIT; - -initer_ok_case_up: - self->state = STATE_TRANSVR_CONNECTED; - self->temp = 0; - self->dump_all(self); - return EVENT_TRANSVR_INIT_UP; - -initer_ok_case_down: - self->temp = 0; - self->state = STATE_TRANSVR_DISCONNECTED; - return EVENT_TRANSVR_INIT_DOWN; - -initer_err_case_i2c_ceash: - SWPS_DEBUG("%s: %s :%s :I2C crash\n", - __func__, emsg, self->swp_name); - self->state = STATE_TRANSVR_UNEXCEPTED; - return EVENT_TRANSVR_I2C_CRASH; - -initer_err_case_be_isolated: - SWPS_DEBUG("%s: %s :%s :isolated\n", - __func__, emsg, self->swp_name); - self->state = STATE_TRANSVR_ISOLATED; - return EVENT_TRANSVR_EXCEP_ISOLATED; - -initer_err_case_retry_1: - SWPS_DEBUG("%s: %s :%s :retry\n", - __func__, emsg, self->swp_name); - if (_transvr_handle_retry(self, retry) == 0) { - self->state = STATE_TRANSVR_NEW; - return EVENT_TRANSVR_INIT_REINIT; - } - goto initer_err_case_alarm_to_user; - -initer_err_case_unexcept_1: - self->clean(self); -initer_err_case_unexcept_0: - self->state = STATE_TRANSVR_UNEXCEPTED; - if (_is_except_happened_4_pmode(self, d_state) && - (self->mode == TRANSVR_MODE_POLLING) ){ - SWPS_INFO("%s: %s :%s\n", __func__, emsg, self->swp_name); - SWPS_INFO("Dump: :%d :%d :%d :%d\n", - self->state, self->type, d_state, d_type); - } - return EVENT_TRANSVR_INIT_FAIL; - -initer_err_case_alarm_to_user: - SWPS_DEBUG("%s: %s :%s :alarm_to_user\n", - __func__, emsg, self->swp_name); - self->state = STATE_TRANSVR_UNEXCEPTED; - alarm_msg_2_user(self, "detected transceiver/cables not meet SFF standard"); - return EVENT_TRANSVR_INIT_FAIL; -} - - -/* ========== Object functions for Clean procedure ========== - */ -int -_transvr_clean_handler(struct transvr_obj_s *self){ - - int retval = DEBUG_TRANSVR_INT_VAL; - - if (!self->clean) { - SWPS_ERR("%s: %s clean() is NULL.\n", - __func__, self->swp_name); - return EVENT_TRANSVR_TASK_FAIL; - } - retval = self->clean(self); - if (retval != EVENT_TRANSVR_TASK_DONE){ - SWPS_ERR("%s: %s clean() fail. [ERR]:%d\n", - __func__, self->swp_name, retval); - return retval; - } - return EVENT_TRANSVR_TASK_DONE; -} - - -int -common_transvr_clean(struct transvr_obj_s *self){ - - transvr_task_free_all(self); - return EVENT_TRANSVR_TASK_DONE; -} - - -int -qsfp_transvr_clean(struct transvr_obj_s *self){ - - int retval; - int lpower_config = 1; - - retval = _taskfunc_qsfp_setup_power_mod(self, lpower_config); - if (retval < 0){ - SWPS_ERR("%s: Set lpmod fail! :%d\n", - __func__, retval); - return retval; - } - retval = common_transvr_clean(self); - if (retval < 0){ - SWPS_ERR("%s: common_transvr_clean fail! :%d\n", - __func__, retval); - return retval; - } - return EVENT_TRANSVR_TASK_DONE; -} - - -int -fake_transvr_clean(struct transvr_obj_s *self){ - - return EVENT_TRANSVR_TASK_DONE; -} - - -/* ========== Object functions for check and update ========== - */ -int -common_transvr_check(struct transvr_obj_s *self){ - - char fun_str[32] = "common_transvr_check"; - - if (self->mode != TRANSVR_MODE_POLLING) { - SWPS_ERR("%s: mode:%d is not TRANSVR_MODE_POLLING\n", - fun_str, self->mode); - return ERR_TRANSVR_UNEXCPT; - } - /* Trigger delay task */ - transvr_task_run_all(self); - /* Trigger state machine to check and update */ - return self->fsm_4_polling(self, fun_str); -} - - -int -fake_transvr_check(struct transvr_obj_s *self){ - return 0; -} - - -/* ========== Functions for Factory pattern ========== - */ -static int -setup_transvr_public_cb(struct transvr_obj_s *self, - int transvr_type){ - switch (transvr_type){ - case TRANSVR_TYPE_SFP: - self->get_id = common_get_id; - self->get_eeprom = common_get_eeprom; - self->get_ext_id = common_get_ext_id; - self->get_connector = common_get_connector; - self->get_vendor_name = common_get_vendor_name; - self->get_vendor_pn = common_get_vendor_pn; - self->get_vendor_rev = common_get_vendor_rev; - self->get_vendor_sn = common_get_vendor_sn; - self->get_power_cls = unsupported_get_func; - self->get_br = common_get_br; - self->get_len_sm = sfp_get_len_sm; - self->get_len_smf = common_get_len_smf; - self->get_len_om1 = common_get_len_om1; - self->get_len_om2 = common_get_len_om2; - self->get_len_om3 = common_get_len_om3; - self->get_len_om4 = common_get_len_om4; - self->get_comp_rev = common_get_comp_rev; - self->get_comp_eth_1 = sfp_get_comp_eth_1; - self->get_comp_eth_10 = sfp_get_comp_eth_10; - self->get_comp_eth_10_40 = unsupported_get_func; - self->get_comp_extend = common_get_comp_extended; - self->get_cdr = unsupported_get_func; - self->get_rate_id = sfp_get_rate_id; - self->get_soft_rs0 = sfp_get_soft_rs0; - self->get_soft_rs1 = sfp_get_soft_rs1; - self->get_info = common_get_info; - self->get_if_type = sfp_get_if_type; - self->get_if_speed = sfp_get_if_speed; - self->get_if_lane = common_get_if_lane; - self->get_curr_temp = sfp_get_transvr_temp; - self->get_curr_vol = sfp_get_transvr_voltage; - self->get_soft_rx_los = unsupported_get_func2; - self->get_soft_tx_disable = unsupported_get_func2; - self->get_soft_tx_fault = unsupported_get_func2; - self->get_auto_tx_disable = unsupported_get_func2; - self->get_tx_bias = sfp_get_transvr_tx_bias; - self->get_tx_power = sfp_get_transvr_tx_power; - self->get_rx_power = sfp_get_transvr_rx_power; - self->get_tx_eq = sfp_get_transvr_tx_eq; - self->get_rx_am = unsupported_get_func2; - self->get_rx_em = sfp_get_transvr_rx_em; - self->get_wavelength = sfp_get_wavelength; - self->set_cdr = unsupported_set_func; - self->set_soft_rs0 = sfp_set_soft_rs0; - self->set_soft_rs1 = sfp_set_soft_rs1; - self->set_soft_tx_disable = unsupported_set_func; - self->set_auto_tx_disable = unsupported_set_func; - self->set_tx_eq = sfp_set_tx_eq; - self->set_rx_am = unsupported_set_func; - self->set_rx_em = sfp_set_rx_em; - return 0; - - case TRANSVR_TYPE_QSFP: - case TRANSVR_TYPE_QSFP_PLUS: - self->get_id = common_get_id; - self->get_eeprom = common_get_eeprom; - self->get_ext_id = common_get_ext_id; - self->get_connector = common_get_connector; - self->get_vendor_name = common_get_vendor_name; - self->get_vendor_pn = common_get_vendor_pn; - self->get_vendor_rev = common_get_vendor_rev; - self->get_vendor_sn = common_get_vendor_sn; - self->get_power_cls = qsfp_get_power_cls; - self->get_br = common_get_br; - self->get_len_sm = unsupported_get_func; - self->get_len_smf = common_get_len_smf; - self->get_len_om1 = common_get_len_om1; - self->get_len_om2 = common_get_len_om2; - self->get_len_om3 = common_get_len_om3; - self->get_len_om4 = common_get_len_om4; - self->get_comp_rev = common_get_comp_rev; - self->get_comp_eth_1 = qsfp_get_comp_eth; - self->get_comp_eth_10 = unsupported_get_func; - self->get_comp_eth_10_40 = qsfp_get_comp_10_40; - self->get_comp_extend = common_get_comp_extended; - self->get_cdr = unsupported_get_func; - self->get_rate_id = unsupported_get_func; - self->get_soft_rs0 = unsupported_get_func; /* TBD */ - self->get_soft_rs1 = unsupported_get_func; /* TBD */ - self->get_info = common_get_info; - self->get_if_type = qsfp_get_if_type; - self->get_if_speed = qsfp_get_if_speed; - self->get_if_lane = common_get_if_lane; - self->get_curr_temp = qsfp_get_transvr_temp; - self->get_curr_vol = qsfp_get_transvr_voltage; - self->get_soft_rx_los = qsfp_get_soft_rx_los; - self->get_soft_tx_disable = qsfp_get_soft_tx_disable; - self->get_soft_tx_fault = qsfp_get_soft_tx_fault; - self->get_auto_tx_disable = qsfp_get_auto_tx_disable; - self->get_tx_bias = qsfp_get_transvr_tx_bias; - self->get_tx_power = qsfp_get_transvr_tx_power; - self->get_rx_power = qsfp_get_transvr_rx_power; - self->get_tx_eq = unsupported_get_func2; - self->get_rx_am = unsupported_get_func2; - self->get_rx_em = unsupported_get_func2; - self->get_wavelength = qsfp_get_wavelength; - self->set_cdr = unsupported_set_func; - self->set_soft_rs0 = unsupported_set_func; /* TBD */ - self->set_soft_rs1 = unsupported_set_func; /* TBD */ - self->set_soft_tx_disable = qsfp_set_soft_tx_disable; - self->set_auto_tx_disable = qsfp_set_auto_tx_disable; - self->set_tx_eq = unsupported_set_func; - self->set_rx_am = unsupported_set_func; - self->set_rx_em = unsupported_set_func; - return 0; - - case TRANSVR_TYPE_QSFP_28: - self->get_id = common_get_id; - self->get_eeprom = common_get_eeprom; - self->get_ext_id = common_get_ext_id; - self->get_connector = common_get_connector; - self->get_vendor_name = common_get_vendor_name; - self->get_vendor_pn = common_get_vendor_pn; - self->get_vendor_rev = common_get_vendor_rev; - self->get_vendor_sn = common_get_vendor_sn; - self->get_power_cls = qsfp_get_power_cls; - self->get_br = common_get_br; - self->get_len_sm = unsupported_get_func; - self->get_len_smf = common_get_len_smf; - self->get_len_om1 = common_get_len_om1; - self->get_len_om2 = common_get_len_om2; - self->get_len_om3 = common_get_len_om3; - self->get_len_om4 = common_get_len_om4; - self->get_comp_rev = common_get_comp_rev; - self->get_comp_eth_1 = qsfp_get_comp_eth; - self->get_comp_eth_10 = unsupported_get_func; - self->get_comp_eth_10_40 = qsfp_get_comp_10_40; - self->get_comp_extend = common_get_comp_extended; - self->get_cdr = qsfp_get_cdr; - self->get_rate_id = unsupported_get_func; - self->get_soft_rs0 = unsupported_get_func; /* TBD */ - self->get_soft_rs1 = unsupported_get_func; /* TBD */ - self->get_info = common_get_info; - self->get_if_type = qsfp_get_if_type; - self->get_if_speed = qsfp_get_if_speed; - self->get_if_lane = common_get_if_lane; - self->get_curr_temp = qsfp_get_transvr_temp; - self->get_curr_vol = qsfp_get_transvr_voltage; - self->get_soft_rx_los = qsfp_get_soft_rx_los; - self->get_soft_tx_disable = qsfp_get_soft_tx_disable; - self->get_soft_tx_fault = qsfp_get_soft_tx_fault; - self->get_auto_tx_disable = qsfp_get_auto_tx_disable; - self->get_tx_bias = qsfp_get_transvr_tx_bias; - self->get_tx_power = qsfp_get_transvr_tx_power; - self->get_rx_power = qsfp_get_transvr_rx_power; - self->get_tx_eq = qsfp_get_transvr_tx_eq; - self->get_rx_am = qsfp_get_transvr_rx_am; - self->get_rx_em = qsfp_get_transvr_rx_em; - self->get_wavelength = qsfp_get_wavelength; - self->set_cdr = qsfp_set_cdr; - self->set_soft_rs0 = unsupported_set_func; /* TBD */ - self->set_soft_rs1 = unsupported_set_func; /* TBD */ - self->set_soft_tx_disable = qsfp_set_soft_tx_disable; - self->set_auto_tx_disable = qsfp_set_auto_tx_disable; - self->set_tx_eq = qsfp_set_tx_eq; - self->set_rx_am = qsfp_set_rx_am; - self->set_rx_em = qsfp_set_rx_em; - return 0; - - case TRANSVR_TYPE_FAKE: - self->get_id = fake_get_hex; - self->get_ext_id = fake_get_hex; - self->get_connector = fake_get_hex; - self->get_vendor_name = fake_get_str; - self->get_vendor_pn = fake_get_str; - self->get_vendor_rev = fake_get_str; - self->get_vendor_sn = fake_get_str; - self->get_power_cls = fake_get_int; - self->get_br = fake_get_hex; - self->get_len_sm = fake_get_int; - self->get_len_smf = fake_get_int; - self->get_len_om1 = fake_get_int; - self->get_len_om2 = fake_get_int; - self->get_len_om3 = fake_get_int; - self->get_len_om4 = fake_get_int; - self->get_comp_rev = fake_get_hex; - self->get_comp_eth_1 = fake_get_hex; - self->get_comp_eth_10 = fake_get_hex; - self->get_comp_eth_10_40 = fake_get_hex; - self->get_comp_extend = fake_get_hex; - self->get_cdr = fake_get_hex; - self->get_rate_id = fake_get_hex; - self->get_soft_rs0 = fake_get_binary; - self->get_soft_rs1 = fake_get_binary; - self->get_info = fake_get_int; - self->get_if_type = fake_get_str; - self->get_if_speed = fake_get_str; - self->get_if_lane = fake_get_str; - self->get_curr_temp = fake_get_str; - self->get_curr_vol = fake_get_str; - self->get_soft_rx_los = fake_get_str; - self->get_soft_tx_disable = fake_get_str; - self->get_soft_tx_fault = fake_get_str; - self->get_auto_tx_disable = fake_get_str; - self->get_tx_bias = fake_get_str; - self->get_tx_power = fake_get_str; - self->get_rx_power = fake_get_str; - self->get_tx_eq = fake_get_str; - self->get_rx_am = fake_get_str; - self->get_rx_em = fake_get_str; - self->get_wavelength = fake_get_str; - self->set_cdr = fake_set_hex; - self->set_soft_rs0 = fake_set_int; - self->set_soft_rs1 = fake_set_int; - self->set_soft_tx_disable = fake_set_int; - self->set_auto_tx_disable = fake_set_int; - self->set_tx_eq = fake_set_int; - self->set_rx_am = fake_set_int; - self->set_rx_em = fake_set_int; - return 0; - - default: - break; - } - SWPS_WARN("%s: Detect non-defined type:%d\n", __func__, transvr_type); - return ERR_TRANSVR_UNEXCPT; -} - - -static int -setup_transvr_private_cb(struct transvr_obj_s *self, - int transvr_type){ - switch (transvr_type){ - case TRANSVR_TYPE_SFP: - self->init = transvr_init_sfp; - self->clean = common_transvr_clean; - self->check = common_transvr_check; - self->update_all = _sfp_update_attr_all; - self->fsm_4_direct = common_fsm_4_direct_mode; - self->fsm_4_polling = common_fsm_4_polling_mode; - self->send_uevent = sfp_send_uevent; - self->dump_all = sfp_transvr_dump; - return 0; - - case TRANSVR_TYPE_QSFP: - case TRANSVR_TYPE_QSFP_PLUS: - self->init = transvr_init_qsfp; - self->clean = qsfp_transvr_clean; - self->check = common_transvr_check; - self->update_all = _qsfp_update_attr_all; - self->fsm_4_direct = common_fsm_4_direct_mode; - self->fsm_4_polling = common_fsm_4_polling_mode; - self->send_uevent = qsfp_send_uevent; - self->dump_all = qsfp_transvr_dump; - return 0; - - case TRANSVR_TYPE_QSFP_28: - self->init = transvr_init_qsfp28; - self->clean = qsfp_transvr_clean; - self->check = common_transvr_check; - self->update_all = _qsfp_update_attr_all; - self->fsm_4_direct = common_fsm_4_direct_mode; - self->fsm_4_polling = common_fsm_4_polling_mode; - self->send_uevent = qsfp_send_uevent; - self->dump_all = qsfp_transvr_dump; - return 0; - - case TRANSVR_TYPE_FAKE: - self->init = transvr_init_fake; - self->clean = fake_transvr_clean; - self->check = fake_transvr_check; - self->update_all = fake_transvr_update; - self->fsm_4_direct = fake_fsm_4_direct_mode; - self->fsm_4_polling = fake_fsm_4_polling_mode; - self->send_uevent = fake_send_uevent; - self->dump_all = fake_transvr_dump; - return 0; - - default: - break; - } - SWPS_WARN("%s: Detect non-defined type:%d\n", __func__, transvr_type); - return ERR_TRANSVR_UNEXCPT; -} - - -static struct eeprom_map_s * -get_eeprom_map(int transvr_type){ - - switch (transvr_type){ - case TRANSVR_TYPE_SFP: - return &eeprom_map_sfp; - case TRANSVR_TYPE_QSFP: - case TRANSVR_TYPE_QSFP_PLUS: - return &eeprom_map_qsfp; - case TRANSVR_TYPE_QSFP_28: - return &eeprom_map_qsfp28; - - default: - break; - } - SWPS_WARN("%s: Detect non-defined type:%d\n", __func__, transvr_type); - return NULL; -} - - -static int -setup_transvr_ssize_attr(char *swp_name, - struct transvr_obj_s *self, - struct eeprom_map_s *map_p, - struct ioexp_obj_s *ioexp_obj_p, - int ioexp_virt_offset, - int transvr_type, - int chipset_type, - int chan_id, - int run_mode){ - switch (run_mode){ - case TRANSVR_MODE_DIRECT: /* Direct access device mode */ - case TRANSVR_MODE_POLLING: /* Polling mode, read from cache */ - self->mode = run_mode; - break; - default: - SWPS_ERR("%s: non-defined run_mode:%d\n", - __func__, run_mode); - self->mode = DEBUG_TRANSVR_INT_VAL; - return -1; - } - self->eeprom_map_p = map_p; - self->ioexp_obj_p = ioexp_obj_p; - self->ioexp_virt_offset = ioexp_virt_offset; - self->chan_id = chan_id; - self->layout = transvr_type; - self->type = transvr_type; - self->chipset_type = chipset_type; - self->state = STATE_TRANSVR_NEW; - self->info = STATE_TRANSVR_NEW; - self->auto_tx_disable = VAL_TRANSVR_FUNCTION_DISABLE; - strncpy(self->swp_name, swp_name, 32); - mutex_init(&self->lock); - return 0; -} - - -static int -setup_transvr_dsize_attr(struct transvr_obj_s *self){ - - char *emsg = DEBUG_TRANSVR_STR_VAL; - - self->vendor_name = kzalloc((LEN_TRANSVR_M_STR * sizeof(char)), GFP_KERNEL); - if (!self->vendor_name){ - emsg = "vendor_name"; - goto err_setup_d_attr; - } - self->vendor_pn = kzalloc((LEN_TRANSVR_M_STR * sizeof(char)), GFP_KERNEL); - if (!self->vendor_pn){ - emsg = "vendor_pn"; - goto err_setup_d_attr; - } - self->vendor_rev = kzalloc((LEN_TRANSVR_M_STR * sizeof(char)), GFP_KERNEL); - if (!self->vendor_rev){ - emsg = "vendor_rev"; - goto err_setup_d_attr; - } - self->vendor_sn = kzalloc((LEN_TRANSVR_M_STR * sizeof(char)), GFP_KERNEL); - if (!self->vendor_sn){ - emsg = "vendor_sn"; - goto err_setup_d_attr; - } - self->worker_p = NULL; - return 0; - -err_setup_d_attr: - SWPS_ERR("%s: %s kzalloc fail!", __func__, emsg); - return ERR_TRANSVR_UNEXCPT; -} - - -static int -setup_i2c_client(struct transvr_obj_s *self){ - - struct i2c_adapter *adap = NULL; - struct i2c_client *client = NULL; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - - adap = i2c_get_adapter(self->chan_id); - if(!adap){ - snprintf(err_msg, sizeof(err_msg), - "can not get adap:%d", self->chan_id); - goto err_setup_i2c_client; - } - client = kzalloc(sizeof(*client), GFP_KERNEL); - if (!client){ - snprintf(err_msg, sizeof(err_msg), - "can not kzalloc client:%d", self->chan_id); - goto err_setup_i2c_client; - } - client->adapter = adap; - self->i2c_client_p = client; - self->i2c_client_p->addr = VAL_TRANSVR_COMID_ARREESS; - return 0; - -err_setup_i2c_client: - SWPS_ERR("%s: %s\n", __func__, err_msg); - return ERR_TRANSVR_UNEXCPT; -} - - -struct transvr_obj_s * -create_transvr_obj(char *swp_name, - int chan_id, - struct ioexp_obj_s *ioexp_obj_p, - int ioexp_virt_offset, - int transvr_type, - int chipset_type, - int run_mode){ - - struct transvr_obj_s *result_p; - struct eeprom_map_s *map_p; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - - /* Allocate transceiver object */ - map_p = get_eeprom_map(transvr_type); - if (!map_p){ - snprintf(err_msg, sizeof(err_msg), - "Invalid transvr_type:%d", transvr_type); - goto err_create_transvr_fail; - } - result_p = kzalloc(sizeof(*result_p), GFP_KERNEL); - if (!result_p){ - snprintf(err_msg, sizeof(err_msg), "kzalloc fail"); - goto err_create_transvr_fail; - } - /* Prepare static size attributes */ - if (setup_transvr_ssize_attr(swp_name, - result_p, - map_p, - ioexp_obj_p, - ioexp_virt_offset, - transvr_type, - chipset_type, - chan_id, - run_mode) < 0){ - goto err_create_transvr_sattr_fail; - } - /* Prepare dynamic size attributes */ - if (setup_transvr_dsize_attr(result_p) < 0){ - goto err_create_transvr_dattr_fail; - } - /* Prepare call back functions of object */ - if (setup_transvr_public_cb(result_p, transvr_type) < 0){ - goto err_create_transvr_dattr_fail; - } - /* Prepare call back functions of object */ - if (setup_transvr_private_cb(result_p, transvr_type) < 0){ - goto err_create_transvr_dattr_fail; - } - /* Prepare i2c client object */ - if (setup_i2c_client(result_p) < 0){ - goto err_create_transvr_dattr_fail; - } - return result_p; - -err_create_transvr_dattr_fail: - kfree(result_p->vendor_sn); - kfree(result_p->vendor_rev); - kfree(result_p->vendor_pn); - kfree(result_p->vendor_name); -err_create_transvr_sattr_fail: - kfree(result_p); -err_create_transvr_fail: - SWPS_ERR("%s: %s :%d :%d :%d\n", - __func__, err_msg, chan_id, ioexp_virt_offset, transvr_type); - return NULL; -} -EXPORT_SYMBOL(create_transvr_obj); - - -static int -_reload_transvr_obj(struct transvr_obj_s *self, - int new_type){ - - struct eeprom_map_s *new_map_p; - struct eeprom_map_s *old_map_p = self->eeprom_map_p; - struct i2c_client *old_i2c_p = self->i2c_client_p; - int old_type = self->type; - - /* Change state to STATE_TRANSVR_INIT */ - self->state = STATE_TRANSVR_INIT; - self->type = new_type; - /* Replace EEPROME map */ - new_map_p = get_eeprom_map(new_type); - if (!new_map_p){ - goto err_private_reload_func_1; - } - self->eeprom_map_p = new_map_p; - /* Reload i2c client */ - if (setup_i2c_client(self) < 0){ - goto err_private_reload_func_2; - } - /* Replace call back functions */ - if (setup_transvr_public_cb(self, new_type) < 0){ - goto err_private_reload_func_3; - } - if (setup_transvr_private_cb(self, new_type) < 0){ - goto err_private_reload_func_3; - } - kfree(old_i2c_p); - return 0; - -err_private_reload_func_3: - SWPS_INFO("%s: init() fail!\n", __func__); - kfree(old_i2c_p); - self->state = STATE_TRANSVR_UNEXCEPTED; - self->type = TRANSVR_TYPE_ERROR; - return -2; - -err_private_reload_func_2: - self->eeprom_map_p = old_map_p; - self->i2c_client_p = old_i2c_p; -err_private_reload_func_1: - self->state = STATE_TRANSVR_UNEXCEPTED; - self->type = old_type; - SWPS_INFO("%s fail! :0x%02x\n", __func__, new_type); - return -1; -} - - -static int -reload_transvr_obj(struct transvr_obj_s *self, - int new_type){ - - int result_val = ERR_TRANSVR_UNEXCPT; - - /* Reload phase */ - result_val = _reload_transvr_obj(self, new_type); - if (result_val < 0){ - SWPS_INFO("%s: reload phase fail! :%d\n", - __func__, result_val); - return EVENT_TRANSVR_RELOAD_FAIL; - } - /* Initial phase */ - result_val = _transvr_init_handler(self); - if (result_val < 0){ - SWPS_INFO("%s: initial phase fail! :%d\n", - __func__, result_val); - } - return result_val; -} - - -int -isolate_transvr_obj(struct transvr_obj_s *self) { - - self->state = STATE_TRANSVR_ISOLATED; - SWPS_INFO("%s: %s be isolated\n", __func__, self->swp_name); - return 0; -} -EXPORT_SYMBOL(isolate_transvr_obj); - - -int -resync_channel_tier_2(struct transvr_obj_s *self) { - - int val = TRANSVR_TYPE_ERROR; - - if (self->state == STATE_TRANSVR_ISOLATED) { - return 0; - } - self->i2c_client_p->addr = VAL_TRANSVR_COMID_ARREESS; - val = i2c_smbus_read_byte_data(self->i2c_client_p, - VAL_TRANSVR_COMID_OFFSET); - if (val < 0) { - return -1; - } - return 0; -} -EXPORT_SYMBOL(resync_channel_tier_2); - - -/* ----------------------------------------- - * ToDo List - * ----------------------------------------- - * 1. _sfp_detect_class_by_feature() - * => Need check ACC use case. - * 2. _sfp_detect_class_by_1g_ethernet() - * => Need check 0.1G use case. - * 3. Loopback transceiver use case. - * => Less much data - * 4. _qsfp_detect_class_by_extend_comp() - * => Verify 100G CWDM4 - * => Verify Obsolete (assigned before 100G CWDM4 MSA required FEC) - * => Verify 100G CLR4 - * => Verify 100GE-DWDM2 - * => Verify 40G PSM4 Parallel SMF - * => Verify 100G ACC (Active Copper Cable) or 25GAUI C2M ACC. - * => Verify 100G ACC or 25GAUI C2M ACC. - * => Verify 25GBASE-LR - * => Verify 40G Active Cable (XLPPI) - */ - - - -MODULE_LICENSE("GPL"); - diff --git a/packages/platforms/inventec/x86-64/d7032q28b/modules/builds/src/transceiver.h b/packages/platforms/inventec/x86-64/d7032q28b/modules/builds/src/transceiver.h deleted file mode 100644 index d18a26529..000000000 --- a/packages/platforms/inventec/x86-64/d7032q28b/modules/builds/src/transceiver.h +++ /dev/null @@ -1,811 +0,0 @@ -/************************************************************************* - * - * transceiver.h - * - * 2018 Inventec Corporation - * All Rights Reserved. - * - * NOTICE: All information contained herein is, and remains - * the property of Inventec Corp. and its suppliers, - * if any. The intellectual and technical concepts contained - * herein are proprietary to Inventec Corporation and its suppliers - * and may be covered by U.S. and Foreign Patents, patents in process, - * and are protected by trade secret or copyright law. - * - ************************************************************************/ - -#ifndef TRANSCEIVER_H -#define TRANSCEIVER_H - -#include - -/* advanced features control */ -#define TRANSVR_INFO_DUMP_ENABLE (1) -#define TRANSVR_INFO_CACHE_ENABLE (1) -#define TRANSVR_UEVENT_ENABLE (1) - -/* Transceiver type define */ -#define TRANSVR_TYPE_UNKNOW_1 (0x00) -#define TRANSVR_TYPE_UNKNOW_2 (0xff) -#define TRANSVR_TYPE_SFP (0x03) /* Define for SFP, SFP+, SFP28 */ -#define TRANSVR_TYPE_QSFP (0x0c) -#define TRANSVR_TYPE_QSFP_PLUS (0x0d) -#define TRANSVR_TYPE_QSFP_28 (0x11) -#define TRANSVR_TYPE_UNPLUGGED (0xfa) /* Define for ERROR handle */ -#define TRANSVR_TYPE_FAKE (0xfc) /* Define for ERROR handle */ -#define TRANSVR_TYPE_INCONSISTENT (0xfd) /* Define for ERROR handle */ -#define TRANSVR_TYPE_ERROR (0xfe) /* Define for ERROR handle */ - -/* Transceiver class for base info */ -#define TRANSVR_CLASS_UNSPECIFIED (0) -#define TRANSVR_CLASS_ERROR (-26001) -#define TRANSVR_CLASS_1G (26001) -#define TRANSVR_CLASS_10G (26011) -#define TRANSVR_CLASS_25G (26021) -#define TRANSVR_CLASS_40G (26041) -#define TRANSVR_CLASS_100G (26101) -#define TRANSVR_CLASS_NO_SPERARABLE (26901) -#define TRANSVR_CLASS_EXTEND_COMP (26902) -/* Transceiver class for Optical 1G */ -#define TRANSVR_CLASS_OPTICAL (27000) -#define TRANSVR_CLASS_OPTICAL_100 (27001) -#define TRANSVR_CLASS_OPTICAL_1G (27002) -#define TRANSVR_CLASS_OPTICAL_1G_AOC (27003) -#define TRANSVR_CLASS_OPTICAL_1G_SX (27004) -#define TRANSVR_CLASS_OPTICAL_1G_LX (27005) -#define TRANSVR_CLASS_OPTICAL_1G_EX (27006) -/* Transceiver class for Optical 10G */ -#define TRANSVR_CLASS_OPTICAL_10G (27010) -#define TRANSVR_CLASS_OPTICAL_10G_S_AOC (27011) -#define TRANSVR_CLASS_OPTICAL_10G_S_SR (27012) -#define TRANSVR_CLASS_OPTICAL_10G_S_LR (27013) -#define TRANSVR_CLASS_OPTICAL_10G_S_ER (27014) -#define TRANSVR_CLASS_OPTICAL_10G_Q_AOC (27015) -#define TRANSVR_CLASS_OPTICAL_10G_Q_SR (27016) -#define TRANSVR_CLASS_OPTICAL_10G_Q_LR (27017) -#define TRANSVR_CLASS_OPTICAL_10G_Q_ER (27018) -/* Transceiver class for Optical 25G */ -#define TRANSVR_CLASS_OPTICAL_25G (27020) -#define TRANSVR_CLASS_OPTICAL_25G_AOC (27021) -#define TRANSVR_CLASS_OPTICAL_25G_SR (27022) -#define TRANSVR_CLASS_OPTICAL_25G_LR (27023) -#define TRANSVR_CLASS_OPTICAL_25G_ER (27024) -/* Transceiver class for Optical 40G */ -#define TRANSVR_CLASS_OPTICAL_40G (27040) -#define TRANSVR_CLASS_OPTICAL_40G_AOC (27041) -#define TRANSVR_CLASS_OPTICAL_40G_SR4 (27042) -#define TRANSVR_CLASS_OPTICAL_40G_LR4 (27043) -#define TRANSVR_CLASS_OPTICAL_40G_ER4 (27044) -/* Transceiver class for Optical 100G */ -#define TRANSVR_CLASS_OPTICAL_100G (27100) -#define TRANSVR_CLASS_OPTICAL_100G_AOC (27101) -#define TRANSVR_CLASS_OPTICAL_100G_SR4 (27102) -#define TRANSVR_CLASS_OPTICAL_100G_LR4 (27103) -#define TRANSVR_CLASS_OPTICAL_100G_ER4 (27104) -#define TRANSVR_CLASS_OPTICAL_100G_PSM4 (27105) -/* Transceiver class for Copper */ -#define TRANSVR_CLASS_COPPER (28000) -#define TRANSVR_CLASS_COPPER_L1_1G (28001) -#define TRANSVR_CLASS_COPPER_L1_10G (28011) -#define TRANSVR_CLASS_COPPER_L4_10G (28012) -#define TRANSVR_CLASS_COPPER_L1_25G (28021) -#define TRANSVR_CLASS_COPPER_L4_40G (28041) -#define TRANSVR_CLASS_COPPER_L4_100G (28101) -/* Transceiver class for Base-T */ -#define TRANSVR_CLASS_BASE_T_1000 (29001) -#define TRANSVR_CLASS_BASE_T_1000_up (29002) -/* For uevent message */ -#define TRANSVR_UEVENT_KEY_IF "IF_TYPE" -#define TRANSVR_UEVENT_KEY_SP "IF_SPEED" -#define TRANSVR_UEVENT_KEY_LANE "IF_LANE" -#define TRANSVR_UEVENT_UNKNOW "UNKNOW" -#define TRANSVR_IF_KR "KR" -#define TRANSVR_IF_KR4 "KR4" -#define TRANSVR_IF_SR "SR" -#define TRANSVR_IF_SR4 "SR4" -#define TRANSVR_IF_SFI "SFI" -#define TRANSVR_IF_IF_GMII "GMII" -#define TRANSVR_IF_IF_XGMII "XGMII" -#define TRANSVR_IF_SP_100 "100" -#define TRANSVR_IF_SP_1G "1000" -#define TRANSVR_IF_SP_10G "10000" -#define TRANSVR_IF_SP_25G "25000" -#define TRANSVR_IF_SP_40G "40000" -#define TRANSVR_IF_SP_100G "100000" - -/* Transceiver mode define */ -#define TRANSVR_MODE_DIRECT (21000) -#define TRANSVR_MODE_POLLING (21001) - -/* Transceiver state define - * [Note] - * 1. State is used to represent the state of "Transceiver" and "Object". - * 2. State for different target has different means. The description as following: - */ -#define STATE_TRANSVR_CONNECTED (0) /* [Transvr]:Be plugged in. [Obj]:Link up, and work normally. */ -#define STATE_TRANSVR_NEW (-100) /* [Transvr]:(Not used) [Obj]:Create */ -#define STATE_TRANSVR_INIT (-101) /* [Transvr]:Be plugged in. [Obj]:Link up, and in initial process. */ -#define STATE_TRANSVR_ISOLATED (-102) /* [Transvr]:Be plugged in. [Obj]:Isolate, and not provide service. */ -#define STATE_TRANSVR_SWAPPED (-200) /* [Transvr]:Be plugged in. [Obj]:(Not used) */ -#define STATE_TRANSVR_DISCONNECTED (-300) /* [Transvr]:Un-plugged. [Obj]:Link down, and not provide service. */ -#define STATE_TRANSVR_UNEXCEPTED (-901) /* [Transvr]:Any [Obj]:Any, and not in expect case. */ - -/* Task state define */ -#define STATE_T_TASK_WAIT (110) -#define STATE_T_TASK_DONE (0) -#define STATE_T_TASK_INIT (-110) -#define STATE_T_TASK_FAIL (-410) - - -/* Event for task handling */ -#define EVENT_TRANSVR_TASK_WAIT (2101) -#define EVENT_TRANSVR_TASK_DONE (0) -#define EVENT_TRANSVR_TASK_FAIL (-2101) -/* Event for initial handling */ -#define EVENT_TRANSVR_INIT_UP (2201) -#define EVENT_TRANSVR_INIT_DOWN (1) -#define EVENT_TRANSVR_INIT_REINIT (-2201) -#define EVENT_TRANSVR_INIT_FAIL (-2202) -/* Event for others */ -#define EVENT_TRANSVR_RELOAD_FAIL (-2301) -#define EVENT_TRANSVR_EXCEP_INIT (-2401) -#define EVENT_TRANSVR_EXCEP_UP (-2402) -#define EVENT_TRANSVR_EXCEP_DOWN (-2403) -#define EVENT_TRANSVR_EXCEP_SWAP (-2404) -#define EVENT_TRANSVR_EXCEP_EXCEP (-2405) -#define EVENT_TRANSVR_EXCEP_ISOLATED (-2406) -#define EVENT_TRANSVR_I2C_CRASH (-2501) - -/* Transceiver error code define */ -#define ERR_TRANSVR_UNINIT (-201) -#define ERR_TRANSVR_UNPLUGGED (-202) -#define ERR_TRANSVR_ABNORMAL (-203) -#define ERR_TRANSVR_NOSTATE (-204) -#define ERR_TRANSVR_NOTSUPPORT (-205) -#define ERR_TRANSVR_BADINPUT (-206) -#define ERR_TRANSVR_UPDATE_FAIL (-207) -#define ERR_TRANSVR_RELOAD_FAIL (-208) -#define ERR_TRANSVR_INIT_FAIL (-209) -#define ERR_TRANSVR_UNDEFINED (-210) -#define ERR_TRANSVR_TASK_FAIL (-211) -#define ERR_TRANSVR_TASK_BUSY (-212) -#define ERR_TRANSVR_UEVENT_FAIL (-213) -#define ERR_TRANSVR_FUNC_DISABLE (-214) -#define ERR_TRANSVR_I2C_CRASH (-297) -#define ERR_TRNASVR_BE_ISOLATED (-298) -#define ERR_TRANSVR_UNEXCPT (-299) - -/* For debug */ -#define DEBUG_TRANSVR_INT_VAL (-99) -#define DEBUG_TRANSVR_HEX_VAL (0xfe) -#define DEBUG_TRANSVR_STR_VAL "ERROR" - -/* For system internal */ -#define VAL_TRANSVR_COMID_ARREESS (0x50) -#define VAL_TRANSVR_COMID_OFFSET (0x00) -#define VAL_TRANSVR_8472_READY_ADDR (0x51) -#define VAL_TRANSVR_8472_READY_PAGE (-1) -#define VAL_TRANSVR_8472_READY_OFFSET (110) -#define VAL_TRANSVR_8472_READY_BIT (0) -#define VAL_TRANSVR_8472_READY_VALUE (0) -#define VAL_TRANSVR_8472_READY_ABNORMAL (0xff) -#define VAL_TRANSVR_8436_READY_ADDR (0x50) -#define VAL_TRANSVR_8436_READY_PAGE (-1) -#define VAL_TRANSVR_8436_READY_OFFSET (2) -#define VAL_TRANSVR_8436_READY_BIT (0) -#define VAL_TRANSVR_8436_READY_VALUE (0) -#define VAL_TRANSVR_8436_READY_ABNORMAL (0xff) -#define VAL_TRANSVR_8436_PWD_ADDR (0x50) -#define VAL_TRANSVR_8436_PWD_PAGE (-1) -#define VAL_TRANSVR_8436_PWD_OFFSET (123) -#define VAL_TRANSVR_PAGE_FREE (-99) -#define VAL_TRANSVR_PAGE_SELECT_OFFSET (127) -#define VAL_TRANSVR_PAGE_SELECT_DELAY (5) -#define VAL_TRANSVR_TASK_RETRY_FOREVER (-999) -#define VAL_TRANSVR_FUNCTION_DISABLE (-1) -#define STR_TRANSVR_SFP "SFP" -#define STR_TRANSVR_QSFP "QSFP" -#define STR_TRANSVR_QSFP_PLUS "QSFP+" -#define STR_TRANSVR_QSFP28 "QSFP28" - -/* For transvr buf len */ -#define LEN_TRANSVR_S_STR (16) -#define LEN_TRANSVR_M_STR (32) -#define LEN_TRANSVR_L_STR (64) - -/* Optical wavelength */ -#define VAL_OPTICAL_WAVELENGTH_SR (850) -#define VAL_OPTICAL_WAVELENGTH_LR (1310) -#define VAL_OPTICAL_WAVELENGTH_ER (1550) - -/* BCM chip type define */ -#define BCM_CHIP_TYPE_TRIDENT_2 (31001) /* Magnolia, Hudson32i, Spruce */ -#define BCM_CHIP_TYPE_TOMAHAWK (31002) /* Redwood, Cypress */ - -/* Info from transceiver EEPROM */ -struct eeprom_map_s { - int addr_br; int page_br; int offset_br; int length_br; - int addr_cdr; int page_cdr; int offset_cdr; int length_cdr; - int addr_comp_rev; int page_comp_rev; int offset_comp_rev; int length_comp_rev; - int addr_connector; int page_connector; int offset_connector; int length_connector; - int addr_diag_type; int page_diag_type; int offset_diag_type; int length_diag_type; - int addr_extbr; int page_extbr; int offset_extbr; int length_extbr; - int addr_ext_id; int page_ext_id; int offset_ext_id; int length_ext_id; - int addr_id; int page_id; int offset_id; int length_id; - int addr_eeprom; int page_eeprom; int offset_eeprom; int length_eeprom; - int addr_len_sm; int page_len_sm; int offset_len_sm; int length_len_sm; - int addr_len_smf; int page_len_smf; int offset_len_smf; int length_len_smf; - int addr_len_om1; int page_len_om1; int offset_len_om1; int length_len_om1; - int addr_len_om2; int page_len_om2; int offset_len_om2; int length_len_om2; - int addr_len_om3; int page_len_om3; int offset_len_om3; int length_len_om3; - int addr_len_om4; int page_len_om4; int offset_len_om4; int length_len_om4; - int addr_option; int page_option; int offset_option; int length_option; - int addr_rate_id; int page_rate_id; int offset_rate_id; int length_rate_id; - int addr_rx_am; int page_rx_am; int offset_rx_am; int length_rx_am; - int addr_rx_em; int page_rx_em; int offset_rx_em; int length_rx_em; - int addr_rx_los; int page_rx_los; int offset_rx_los; int length_rx_los; - int addr_rx_power; int page_rx_power; int offset_rx_power; int length_rx_power; - int addr_soft_rs0; int page_soft_rs0; int offset_soft_rs0; int length_soft_rs0; - int addr_soft_rs1; int page_soft_rs1; int offset_soft_rs1; int length_soft_rs1; - int addr_temp; int page_temp; int offset_temp; int length_temp; - int addr_trancomp; int page_trancomp; int offset_trancomp; int length_trancomp; - int addr_trancomp_ext; int page_trancomp_ext; int offset_trancomp_ext; int length_trancomp_ext; - int addr_tx_bias; int page_tx_bias; int offset_tx_bias; int length_tx_bias; - int addr_tx_disable; int page_tx_disable; int offset_tx_disable; int length_tx_disable; - int addr_tx_eq; int page_tx_eq; int offset_tx_eq; int length_tx_eq; - int addr_tx_fault; int page_tx_fault; int offset_tx_fault; int length_tx_fault; - int addr_tx_power; int page_tx_power; int offset_tx_power; int length_tx_power; - int addr_vendor_name; int page_vendor_name; int offset_vendor_name; int length_vendor_name; - int addr_vendor_pn; int page_vendor_pn; int offset_vendor_pn; int length_vendor_pn; - int addr_vendor_rev; int page_vendor_rev; int offset_vendor_rev; int length_vendor_rev; - int addr_vendor_sn; int page_vendor_sn; int offset_vendor_sn; int length_vendor_sn; - int addr_voltage; int page_voltage; int offset_voltage; int length_voltage; - int addr_wavelength; int page_wavelength; int offset_wavelength; int length_wavelength; -}; - - -struct transvr_worker_s; - -/* Class of transceiver object */ -struct transvr_obj_s { - - /* ========== Object private property ========== - * [Prop]: id - * [Desc]: Type of serial transceiver. - * [Note]: SFP:03h / QSFP:0Ch / QSPF+:0Dh /QSFP28:11h - */ - uint8_t id; - - /* [Prop]: connector - * [Desc]: Connector type. - * [Note]: SFP : A0h / 2 - * QSFP: 00h / 130 - */ - uint8_t connector; - - /* [Prop]: transvr_comp - * [Desc]: Transceiver compliance code. - * [Note]: SFP: SFF-8472 - * - Normal : A0h / offset 3-10 - * - Extended: A0h / offset 36 - * QSFP: SFF-8436 & SFF-8636 - * - Normal : 00h / offset 131-138 - * - Extended: 00h / offset 192 - */ - uint8_t transvr_comp[8]; - uint8_t transvr_comp_ext; - - /* [Prop]: vendor_name - * [Desc]: SFP vendor name (ASCII 16 byte char). - * [Note]: ex:FINISAR CORP. - */ - char *vendor_name; - - /* [Prop]: vendor_pn - * [Desc]: Part number provided by SFP vendor (ASCII 16 byte char). - * [Note]: - */ - char *vendor_pn; - - /* [Prop]: vendor_rev - * [Desc]: Revision level for part number provided by vendor (ASCII 4 byte char). - * [Note]: - */ - char *vendor_rev; - - /* [Prop]: vendor_sn - * [Desc]: Serial number provided by vendor (ASCII 16 byte char). - * [Note]: - */ - char *vendor_sn; - - /* [Prop]: Extended identifier - * [Desc]: SFP: - * => None - * - * QSFP: - * => This byte contained two information: - * (1) Power consumption class - * (2) CDR function present - * [Note]: Bit description as below: - * [SFP] - * None - * - * [QSFP] - * (1) Power consumption class: - * Class 1: 1.5W (Bit6-7 = 00:) - * Class 2: 2.0W (Bit6-7 = 01:) - * Class 3: 2.5W (Bit6-7 = 10:) - * Class 4: 3.5W (Bit6-7 = 11:) - * Class 5: 4.0W (Bit0-1 = 01:) - * Class 6: 4.5W (Bit0-1 = 10:) - * Class 7: 5.0W (Bit0-1 = 11:) - * (2) CDR function present: - * Bit2: 0 = No CDR in RX - * 1 = CDR present in RX - * Bit3: 0 = No CDR in TX - * 1 = CDR present in TX - */ - uint8_t ext_id; - - /* [Prop]: br - * [Desc]: Nominal bit rate, units of 100 MBits/sec. - * [Note]: SFP:03h / QSFP:0Ch / QSPF+:0Dh - * has val: 0x67 - * no val : - */ - uint8_t br; - - /* [Prop]: extbr - * [Desc]: Extended br (00h/222) - * [Desc]: Nominal bit rate per channel, units of 250 Mbps. - * Complements. Byte 140. See Table 32A. - */ - uint8_t extbr; - - /* [Prop]: len_sm - * [Desc]: Length (single mode)-(100's)m - * [Note]: This value specifies the link length that is supported by the transceiver - * while operating in compliance with the applicable standards using single mode - * fiber. The value is in units of 100 meters. A value of 255 means that the - * transceiver supports a link length greater than 25.4 km. A value of zero means - * that the transceiver does not support single mode fiber or that the length - * information must be determined from the transceiver technology. - */ - int len_sm; - - /* [Prop]: len_smf - * [Desc]: Length (single mode)-km - * [Note]: Addition to EEPROM data from original GBIC definition. This value specifies - * the link length that is supported by the transceiver while operating in - * compliance with the applicable standards using single mode fiber. The value - * is in units of kilometers. A value of 255 means that the transceiver supports - * a link length greater than 254 km. A value of zero means that the transceiver - * does not support single mode fiber or that the length information must be - * determined from the transceiver technology. - */ - int len_smf; - - /* [Prop]: len_om1 - * [Desc]: Link length supported for 62.5 um OM1 fiber, units of 10 m - * [Note]: The value is in units of 10 meters. A value of 255 means that the - * transceiver supports a link length greater than 2.54 km. A value of - * zero means that the transceiver does not support 50 micron multi-mode - * fiber or that the length information must be determined from the transceiver - * technology. - */ - int len_om1; - - /* [Prop]: len_om2 - * [Desc]: Link length supported for 50 um OM2 fiber, units of 10 m - * [Note]: The value is in units of 10 meters. A value of 255 means that the - * transceiver supports a link length greater than 2.54 km. A value of - * zero means that the transceiver does not support 50 micron multi-mode - * fiber or that the length information must be determined from the transceiver - * technology. - */ - int len_om2; - - /* [Prop]: len_om3 - * [Desc]: Length (50um, OM3) - * [Note]: This value specifies link length that is supported by the transceiver while - * operating in compliance with applicable standards using 50 micron multimode - * OM3 [2000 MHz*km] fiber. The value is in units of 10 meters. A value of 255 - * means that the transceiver supports a link length greater than 2.54 km. A value - * of zero means that the transceiver does not support 50 micron multimode fiber - * or that the length information must be determined from the transceiver technology. - */ - int len_om3; - - /* [Prop]: len_om4 - * [Desc]: Length (50um, OM4) and Length (Active Cable or Copper) - * [Note]: For optical links, this value specifies link length that is supported by the - * transceiver while operating in compliance with applicable standards using 50 micron - * multimode OM4 [4700 MHz*km] fiber. The value is in units of 10 meters. A value of - * 255 means that the transceiver supports a link length greater than 2.54 km. A value - * of zero means that the transceiver does not support 50 micron multimode fiber or that - * the length information must be determined from the transceiver codes specified in Table 5-3. - * - * For copper links, this value specifies minimum link length supported by the transceiver - * while operating in compliance with applicable standards using copper cable. For active - * cable, this value represents actual length. The value is in units of 1 meter. A value of 255 - * means the transceiver supports a link length greater than 254 meters. A value of zero means - * the transceiver does not support copper or active cables or the length information must be - * determined from transceiver technology. Further information about cable design, equalization, - * and connectors is usually required to guarantee meeting a particular length requirement. - */ - int len_om4; - - /* [Prop]: comp_rev - * [Desc]: SFF spec revision compliance - * [Note]: Indicates which revision of SFF SFF-8472 (SFP) / SFF-8636 (QSFP) the transceiver - * complies with. (unsigned integer) - */ - uint8_t comp_rev; - - /* [Prop]: CDR - * [Desc]: For transceivers with CDR capability, setting the CDR to ON engages the internal - * retiming function. Setting the CDR to OFF enables an internal bypassing mode ,which - * directs traffic around the internal CDR. (Reference: SFF-8636) - * [Note]: value=0xff: ON. - * value=0x00: OFF. - */ - uint8_t cdr; - - /* [Prop]: rate_id - * [Desc]: Soft Rate Select 0(RX). - * [Note]: 1. Addr: A0h / Offset: 13 - * 2. Value description: - * 00h Unspecified - * 01h SFF-8079 (4/2/1G Rate_Select & AS0/AS1) - * 02h SFF-8431 (8/4/2G Rx Rate_Select only) - * 03h Unspecified * - * 04h SFF-8431 (8/4/2G Tx Rate_Select only) - * 05h Unspecified * - * 06h SFF-8431 (8/4/2G Independent Rx & Tx Rate_select) - * 07h Unspecified * - * 08h FC-PI-5 (16/8/4G Rx Rate_select only) High=16G only, Low=8G/4G - * 09h Unspecified * - * 0Ah FC-PI-5 (16/8/4G Independent Rx, Tx Rate_select) High=16G only, - * Low=8G/4G - * 0Bh Unspecified * - * 0Ch FC-PI-6 (32/16/8G Independent Rx, Tx Rate_Select) - * High=32G only, Low = 16G/8G - * 0Dh Unspecified * - * 0Eh 10/8G Rx and Tx Rate_Select controlling the operation or locking - * modes of the internal signal conditioner, retimer or CDR, according - * to the logic table defined in Table 10-2, High Bit Rate - * (10G) =9.95-11.3 Gb/s; Low Bit Rate (8G) = 8.5 Gb/s. In this mode, - * the default value of bit 110.3 (Soft Rate Select RS(0), Table 9-11) - * and of bit 118.3 (Soft Rate Select RS(1), Table 10-1) is 1. - * 0Fh Unspecified * - * 10h-FFh Unallocated - */ - int rate_id; - - /* [Prop]: soft_rs0 - * [Desc]: Soft Rate Select 0(RX). - * [Note]: 1. Writing '1' selects full bandwidth operation. - * 2. This bit is "OR'd with the hard Rate_Select, AS(0) or RS(0) pin value. - * 3. Default at power up is logic zero/low - * 4. Addr: A2h / Offset: 110 / Bit: 3 - */ - uint8_t soft_rs0; - - /* [Prop]: soft_rs1 - * [Desc]: Soft Rate Select 1(TX). - * [Note]: 1. Writing '1' selects full bandwidth TX operation. - * 2. This bit is "OR'd with the hard Rate_Select, AS(1) or RS(1) pin value. - * 3. Default at power up is logic zero/low - * 4. Addr: A2h / Offset: 118 / Bit: 3 - */ - uint8_t soft_rs1; - - /* [Prop]: diag_type - * [Desc]: DIAGNOSTIC MONITORING TYPE (A0h/92) - * [Note]: Description in SFF-8472 as below: - * Bit7: Reserved for legacy diagnostic implementations. Must be '0' for compliance - * with this document. - * Bit6: Digital diagnostic monitoring implemented (described in this document). - * Must be '1' for compliance with this document. - * Bit5 Internally calibrated - * Bit4 Externally calibrated - * Bit3 Received power measurement type.0 = OMA, 1 = average power - * Bit2 Address change required see section above, "addressing modes" - * Bit1-0 Unallocated - */ - uint8_t diag_type; - - /* [Prop]: curr_temp - * [Desc]: Transceiver Current Temperature (A2h/96-97) - * [Note]: 1. Dependent on diag_type. - * 2. 96: High byte - * 3. 97: Low byte - * 4. This feature only for SFP - */ - uint8_t curr_temp[2]; - - /* [Prop]: curr_vol - * [Desc]: Transceiver Current Voltage (SFP:A2h/108-109; QSFP:00h/22-23) - * [Note]: 1. Dependent on diag_type. - * 2. 98: High byte - * 3. 99: Low byte - * 4. This feature only for SFP - * 5. Internally measured transceiver supply voltage. Represented - * as a 16 bit unsigned integer with the voltage defined as the - * full 16 bit value (0-65535) with LSB equal to 100 uVolt, - * yielding a total range of 0 to +6.55 Volts - */ - uint8_t curr_voltage[2]; - - /* [Prop]: curr_tx_bias - * [Desc]: Transceiver TX Bias Current (SFP:A2h/100-101; QSFP:00h/26-27) - * [Note]: 1. Dependent on diag_type. - * 2. 100: High byte - * 3. 101: Low byte - * 4. This feature only for SFP - * 5. Measured TX bias current in uA. Represented as a 16 bit unsigned - * integer with the current defined as the full 16 bit value (0-65535) - * with LSB equal to 2 uA, yielding a total range of 0 to 131 mA. - * Accuracy is vendor specific but must be better than 10% of the - * manufacturer's nominal value over specified operating temperature - * and voltage. - */ - uint8_t curr_tx_bias[8]; - - /* [Prop]: curr_tx_power - * [Desc]: Transceiver TX Output Power (A2h/102-103) - * [Note]: 1. Dependent on diag_type. - * 2. 102: High byte - * 3. 103: Low byte - * 4. This feature only for SFP - * 5. Measured TX output power in mW. Represented as a 16 bit unsigned - * integer with the power defined as the full 16 bit value (0-65535) - * with LSB equal to 0.1 uW, yielding a total range of 0 to 6.5535 mW - * (~ -40 to +8.2 dBm). Data is assumed to be based on measurement of - * laser monitor photodiode current. It is factory calibrated to absolute - * units using the most representative fiber output type. Accuracy is - * vendor specific but must be better than 3dB over specified temperature - * and voltage. Data is not valid when the transmitter is disabled. - */ - uint8_t curr_tx_power[8]; - - /* [Prop]: curr_tx_power - * [Desc]: Transceiver TX Output Power (A2h/102-103) - * [Note]: 1. Dependent on diag_type. - * 2. 102: High byte - * 3. 103: Low byte - * 4. This feature only for SFP - * 5. Measured RX received optical power in mW. Value can represent either - * average received power or OMA depending upon how bit 3 of byte 92 (A0h) - * is set. Represented as a 16 bit unsigned integer with the power defined - * as the full 16 bit value (0-65535) with LSB equal to 0.1 uW, yielding a - * total range of 0 to 6.5535 mW (~ -40 to +8.2 dBm). Absolute accuracy is - * dependent upon the exact optical wavelength. For the vendor specified - * wavelength, accuracy shall be better than 3dB over specified temperature - * and voltage. - */ - uint8_t curr_rx_power[8]; - - /* [Prop]: wavelength - * [Desc]: Wavelength or Copper Cable Attenuation - * [Note]: (Following is info from SFF-8636) - * For optical free side devices, this parameter identifies the nominal - * transmitter output wavelength at room temperature. This parameter is a - * 16-bit hex value with Byte 186 as high order byte and Byte 187 as low - * order byte. The laser wavelength is equal to the 16-bit integer value - * divided by 20 in nm (units of 0.05 nm). This resolution should be adequate - * to cover all relevant wavelengths yet provide enough resolution for all - * expected DWDM applications. For accurate representation of controlled - * wavelength applications, this value should represent the center of the - * guaranteed wavelength range. If the free side device is identified as - * copper cable these registers will be used to define the cable attenuation. - * An indication of 0 dB attenuation refers to the case where the attenuation - * is not known or is unavailable. - * Byte 186 (00-FFh) is the copper cable attenuation at 2.5 GHz in units of 1 dB. - * Byte 187 (00-FFh) is the copper cable attenuation at 5.0 GHz in units of 1 dB. - */ - uint8_t wavelength[2]; - - /* [Prop]: Amplitude control - * [Desc]: Amplitude control - * [Note]: QSFP28 => SFF-8636 03H Byte-238/239 - */ - uint8_t rx_am[2]; - - /* [Prop]: Emphasis control - * [Desc]: Emphasis control - * [Note]: SFP+/28 => SFF-8472 A2H Byte-115 - * QSFP28 => SFF-8636 03H Byte-236/237 - */ - uint8_t rx_em[2]; - - /* [Prop]: Soft Rx LOS - * [Desc]: Soft Rx LOS which provide by transceiver - * [Note]: (Following is info from SFF-8636) - * Byte 3: - * - Bit 0: L-Rx1 LOS - * - Bit 1: L-Rx2 LOS - * - Bit 2: L-Rx3 LOS - * - Bit 3: L-Rx4 LOS - */ - uint8_t rx_los; - - /* [Prop]: Soft Tx Disable - * [Desc]: Soft Tx Disable which provide by transceiver - * [Note]: (Following is info from SFF-8636) - * Byte 86: - * - Bit 0: Tx1 Disable - * - Bit 1: Tx2 Disable - * - Bit 2: Tx3 Disable - * - Bit 3: Tx4 Disable - */ - uint8_t tx_disable; - - /* [Prop]: Soft Tx Fault - * [Desc]: Soft Tx Fault which provide by transceiver - * [Note]: (Following is info from SFF-8636) - * Byte 86: - * - Bit 0: Tx1 Fault - * - Bit 1: Tx2 Fault - * - Bit 2: Tx3 Fault - * - Bit 3: Tx4 Fault - */ - uint8_t tx_fault; - - /* [Prop]: Transceiver EQUALIZATION - * [Desc]: Transceiver EQUALIZATION - * [Note]: SFP+/28 => SFF-8472 A2H Byte-114 - * QSFP28 => SFF-8636 03H Byte-234/235 - */ - uint8_t tx_eq[2]; - - /* [Prop]: OPTION VALUES - * [Desc]: The bits in the option field shall specify the options implemented in the transceiver. - * [Note]: SFP+/28 => SFF-8472 A0H Byte-64/65 - * QSFP+/28 => SFF-8636 00H Byte-193/195 - */ - uint8_t option[3]; - - uint8_t eeprom[256]; - int eeprom_update; /* max 32 ports on redwood */ - int port_no; - - /* ========== Object private property ========== - */ - struct device *transvr_dev_p; - struct eeprom_map_s *eeprom_map_p; - struct i2c_client *i2c_client_p; - struct ioexp_obj_s *ioexp_obj_p; - struct transvr_worker_s *worker_p; - struct mutex lock; - char swp_name[32]; - int auto_config; - int auto_tx_disable; - int chan_id; - int chipset_type; - int curr_page; - int info; - int ioexp_virt_offset; - int lane_id[8]; - int layout; - int mode; - int retry; - int state; - int temp; - int type; - - /* ========== Object public functions ========== - */ - int (*get_id)(struct transvr_obj_s *self); - int (*get_eeprom)(struct transvr_obj_s *self, char *buf_p); - int (*get_ext_id)(struct transvr_obj_s *self); - int (*get_connector)(struct transvr_obj_s *self); - int (*get_vendor_name)(struct transvr_obj_s *self, char *buf_p); - int (*get_vendor_pn)(struct transvr_obj_s *self, char *buf_p); - int (*get_vendor_rev)(struct transvr_obj_s *self, char *buf_p); - int (*get_vendor_sn)(struct transvr_obj_s *self, char *buf_p); - int (*get_power_cls)(struct transvr_obj_s *self); - int (*get_br)(struct transvr_obj_s *self); - int (*get_len_sm)(struct transvr_obj_s *self); - int (*get_len_smf)(struct transvr_obj_s *self); - int (*get_len_om1)(struct transvr_obj_s *self); - int (*get_len_om2)(struct transvr_obj_s *self); - int (*get_len_om3)(struct transvr_obj_s *self); - int (*get_len_om4)(struct transvr_obj_s *self); - int (*get_comp_rev)(struct transvr_obj_s *self); - int (*get_comp_eth_1)(struct transvr_obj_s *self); - int (*get_comp_eth_10)(struct transvr_obj_s *self); - int (*get_comp_eth_10_40)(struct transvr_obj_s *self); - int (*get_comp_extend)(struct transvr_obj_s *self); - int (*get_cdr)(struct transvr_obj_s *self); - int (*get_rate_id)(struct transvr_obj_s *self); - int (*get_soft_rs0)(struct transvr_obj_s *self); - int (*get_soft_rs1)(struct transvr_obj_s *self); - int (*get_info)(struct transvr_obj_s *self); - int (*get_if_type)(struct transvr_obj_s *self, char *buf_p); - int (*get_if_speed)(struct transvr_obj_s *self, char *buf_p); - int (*get_if_lane)(struct transvr_obj_s *self, char *buf_p); - int (*get_curr_temp)(struct transvr_obj_s *self, char *buf_p); - int (*get_curr_vol)(struct transvr_obj_s *self, char *buf_p); - int (*get_soft_rx_los)(struct transvr_obj_s *self, char *buf_p); - int (*get_soft_tx_disable)(struct transvr_obj_s *self, char *buf_p); - int (*get_soft_tx_fault)(struct transvr_obj_s *self, char *buf_p); - int (*get_auto_tx_disable)(struct transvr_obj_s *self, char *buf_p); - int (*get_tx_bias)(struct transvr_obj_s *self, char *buf_p); - int (*get_tx_power)(struct transvr_obj_s *self, char *buf_p); - int (*get_rx_power)(struct transvr_obj_s *self, char *buf_p); - int (*get_tx_eq)(struct transvr_obj_s *self, char *buf_p); - int (*get_rx_am)(struct transvr_obj_s *self, char *buf_p); - int (*get_rx_em)(struct transvr_obj_s *self, char *buf_p); - int (*get_wavelength)(struct transvr_obj_s *self, char *buf_p); - int (*set_cdr)(struct transvr_obj_s *self, int input_val); - int (*set_soft_rs0)(struct transvr_obj_s *self, int input_val); - int (*set_soft_rs1)(struct transvr_obj_s *self, int input_val); - int (*set_soft_tx_disable)(struct transvr_obj_s *self, int input_val); - int (*set_auto_tx_disable)(struct transvr_obj_s *self, int input_val); - int (*set_tx_eq)(struct transvr_obj_s *self, int input_val); - int (*set_rx_am)(struct transvr_obj_s *self, int input_val); - int (*set_rx_em)(struct transvr_obj_s *self, int input_val); - - /* ========== Object private functions ========== - */ - int (*init)(struct transvr_obj_s *self); - int (*clean)(struct transvr_obj_s *self); - int (*check)(struct transvr_obj_s *self); - int (*update_all)(struct transvr_obj_s *self, int show_err); - int (*fsm_4_direct)(struct transvr_obj_s* self, char *caller_name); - int (*fsm_4_polling)(struct transvr_obj_s* self, char *caller_name); - int (*send_uevent)(struct transvr_obj_s* self, enum kobject_action u_action); - int (*dump_all)(struct transvr_obj_s* self); -}; - - -/* For AVL Mapping */ -struct transvr_avl_s { - char vendor_name[32]; - char vendor_pn[32]; - int (*init)(struct transvr_obj_s *self); -}; - - -/* Worker for long term task of transceiver */ -struct transvr_worker_s { - /* Task Parameter */ - struct transvr_obj_s *transvr_p; - struct transvr_worker_s *next_p; - struct transvr_worker_s *pre_p; - unsigned long trigger_time; - char func_name[64]; - int retry; - int state; - - /* Task private data */ - void *p_data; - - /* Call back function */ - int (*main_task)(struct transvr_worker_s *task); - int (*post_task)(struct transvr_worker_s *task); -}; - - -struct transvr_obj_s * -create_transvr_obj(char *swp_name, - int chan_id, - struct ioexp_obj_s *ioexp_obj_p, - int ioexp_virt_offset, - int transvr_type, - int chipset_type, - int run_mode); - -void lock_transvr_obj(struct transvr_obj_s *self); -void unlock_transvr_obj(struct transvr_obj_s *self); -int isolate_transvr_obj(struct transvr_obj_s *self); - -int resync_channel_tier_2(struct transvr_obj_s *self); - -void alarm_msg_2_user(struct transvr_obj_s *self, char *emsg); -unsigned int get_eeprom_update(void); -void set_eeprom_update(unsigned int value); - -#endif /* TRANSCEIVER_H */ diff --git a/packages/platforms/inventec/x86-64/d7032q28b/onlp/Makefile b/packages/platforms/inventec/x86-64/d7032q28b/onlp/Makefile deleted file mode 100644 index 003238cf6..000000000 --- a/packages/platforms/inventec/x86-64/d7032q28b/onlp/Makefile +++ /dev/null @@ -1 +0,0 @@ -include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/inventec/x86-64/d7032q28b/onlp/PKG.yml b/packages/platforms/inventec/x86-64/d7032q28b/onlp/PKG.yml deleted file mode 100644 index ea6da9a18..000000000 --- a/packages/platforms/inventec/x86-64/d7032q28b/onlp/PKG.yml +++ /dev/null @@ -1 +0,0 @@ -!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/d7032q28b/onlp/builds/Makefile b/packages/platforms/inventec/x86-64/d7032q28b/onlp/builds/Makefile deleted file mode 100644 index e7437cb23..000000000 --- a/packages/platforms/inventec/x86-64/d7032q28b/onlp/builds/Makefile +++ /dev/null @@ -1,2 +0,0 @@ -FILTER=src -include $(ONL)/make/subdirs.mk diff --git a/packages/platforms/inventec/x86-64/d7032q28b/onlp/builds/lib/Makefile b/packages/platforms/inventec/x86-64/d7032q28b/onlp/builds/lib/Makefile deleted file mode 100644 index c88d39072..000000000 --- a/packages/platforms/inventec/x86-64/d7032q28b/onlp/builds/lib/Makefile +++ /dev/null @@ -1,2 +0,0 @@ -PLATFORM := x86-64-inventec-d7032q28b -include $(ONL)/packages/base/any/onlp/builds/platform/libonlp-platform.mk diff --git a/packages/platforms/inventec/x86-64/d7032q28b/onlp/builds/onlpdump/Makefile b/packages/platforms/inventec/x86-64/d7032q28b/onlp/builds/onlpdump/Makefile deleted file mode 100644 index 41e092a01..000000000 --- a/packages/platforms/inventec/x86-64/d7032q28b/onlp/builds/onlpdump/Makefile +++ /dev/null @@ -1,2 +0,0 @@ -PLATFORM := x86-64-inventec-d7032q28b -include $(ONL)/packages/base/any/onlp/builds/platform/onlps.mk diff --git a/packages/platforms/inventec/x86-64/d7032q28b/onlp/builds/x86_64_inventec_d7032q28b/.module b/packages/platforms/inventec/x86-64/d7032q28b/onlp/builds/x86_64_inventec_d7032q28b/.module deleted file mode 100644 index a41675ebc..000000000 --- a/packages/platforms/inventec/x86-64/d7032q28b/onlp/builds/x86_64_inventec_d7032q28b/.module +++ /dev/null @@ -1 +0,0 @@ -name: x86_64_inventec_d7032q28b diff --git a/packages/platforms/inventec/x86-64/d7032q28b/onlp/builds/x86_64_inventec_d7032q28b/Makefile b/packages/platforms/inventec/x86-64/d7032q28b/onlp/builds/x86_64_inventec_d7032q28b/Makefile deleted file mode 100644 index 0a428e735..000000000 --- a/packages/platforms/inventec/x86-64/d7032q28b/onlp/builds/x86_64_inventec_d7032q28b/Makefile +++ /dev/null @@ -1,9 +0,0 @@ -############################################################################### -# -# -# -############################################################################### -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/d7032q28b/onlp/builds/x86_64_inventec_d7032q28b/module/auto/make.mk b/packages/platforms/inventec/x86-64/d7032q28b/onlp/builds/x86_64_inventec_d7032q28b/module/auto/make.mk deleted file mode 100644 index 308605048..000000000 --- a/packages/platforms/inventec/x86-64/d7032q28b/onlp/builds/x86_64_inventec_d7032q28b/module/auto/make.mk +++ /dev/null @@ -1,9 +0,0 @@ -############################################################################### -# -# 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/d7032q28b/onlp/builds/x86_64_inventec_d7032q28b/module/auto/x86_64_inventec_d7032q28b.yml b/packages/platforms/inventec/x86-64/d7032q28b/onlp/builds/x86_64_inventec_d7032q28b/module/auto/x86_64_inventec_d7032q28b.yml deleted file mode 100644 index 56752d705..000000000 --- a/packages/platforms/inventec/x86-64/d7032q28b/onlp/builds/x86_64_inventec_d7032q28b/module/auto/x86_64_inventec_d7032q28b.yml +++ /dev/null @@ -1,50 +0,0 @@ -############################################################################### -# -# 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 - - - vsnprintf - - snprintf - - strlen diff --git a/packages/platforms/inventec/x86-64/d7032q28b/onlp/builds/x86_64_inventec_d7032q28b/module/inc/x86_64_inventec_d7032q28b/x86_64_inventec_d7032q28b.x b/packages/platforms/inventec/x86-64/d7032q28b/onlp/builds/x86_64_inventec_d7032q28b/module/inc/x86_64_inventec_d7032q28b/x86_64_inventec_d7032q28b.x deleted file mode 100644 index 47142477e..000000000 --- a/packages/platforms/inventec/x86-64/d7032q28b/onlp/builds/x86_64_inventec_d7032q28b/module/inc/x86_64_inventec_d7032q28b/x86_64_inventec_d7032q28b.x +++ /dev/null @@ -1,14 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#include - -/* <--auto.start.xmacro(ALL).define> */ -/* */ - -/* <--auto.start.xenum(ALL).define> */ -/* */ - - diff --git a/packages/platforms/inventec/x86-64/d7032q28b/onlp/builds/x86_64_inventec_d7032q28b/module/inc/x86_64_inventec_d7032q28b/x86_64_inventec_d7032q28b_config.h b/packages/platforms/inventec/x86-64/d7032q28b/onlp/builds/x86_64_inventec_d7032q28b/module/inc/x86_64_inventec_d7032q28b/x86_64_inventec_d7032q28b_config.h deleted file mode 100644 index 476cfcc93..000000000 --- a/packages/platforms/inventec/x86-64/d7032q28b/onlp/builds/x86_64_inventec_d7032q28b/module/inc/x86_64_inventec_d7032q28b/x86_64_inventec_d7032q28b_config.h +++ /dev/null @@ -1,137 +0,0 @@ -/**************************************************************************//** - * - * @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/d7032q28b/onlp/builds/x86_64_inventec_d7032q28b/module/inc/x86_64_inventec_d7032q28b/x86_64_inventec_d7032q28b_dox.h b/packages/platforms/inventec/x86-64/d7032q28b/onlp/builds/x86_64_inventec_d7032q28b/module/inc/x86_64_inventec_d7032q28b/x86_64_inventec_d7032q28b_dox.h deleted file mode 100644 index 727ff26ac..000000000 --- a/packages/platforms/inventec/x86-64/d7032q28b/onlp/builds/x86_64_inventec_d7032q28b/module/inc/x86_64_inventec_d7032q28b/x86_64_inventec_d7032q28b_dox.h +++ /dev/null @@ -1,26 +0,0 @@ -/**************************************************************************//** - * - * 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/d7032q28b/onlp/builds/x86_64_inventec_d7032q28b/module/inc/x86_64_inventec_d7032q28b/x86_64_inventec_d7032q28b_porting.h b/packages/platforms/inventec/x86-64/d7032q28b/onlp/builds/x86_64_inventec_d7032q28b/module/inc/x86_64_inventec_d7032q28b/x86_64_inventec_d7032q28b_porting.h deleted file mode 100644 index 2b5825e7f..000000000 --- a/packages/platforms/inventec/x86-64/d7032q28b/onlp/builds/x86_64_inventec_d7032q28b/module/inc/x86_64_inventec_d7032q28b/x86_64_inventec_d7032q28b_porting.h +++ /dev/null @@ -1,97 +0,0 @@ -/**************************************************************************//** - * - * @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_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/d7032q28b/onlp/builds/x86_64_inventec_d7032q28b/module/make.mk b/packages/platforms/inventec/x86-64/d7032q28b/onlp/builds/x86_64_inventec_d7032q28b/module/make.mk deleted file mode 100644 index cec02d5e5..000000000 --- a/packages/platforms/inventec/x86-64/d7032q28b/onlp/builds/x86_64_inventec_d7032q28b/module/make.mk +++ /dev/null @@ -1,10 +0,0 @@ -############################################################################### -# -# -# -############################################################################### -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/d7032q28b/onlp/builds/x86_64_inventec_d7032q28b/module/src/Makefile b/packages/platforms/inventec/x86-64/d7032q28b/onlp/builds/x86_64_inventec_d7032q28b/module/src/Makefile deleted file mode 100644 index f82e1a89e..000000000 --- a/packages/platforms/inventec/x86-64/d7032q28b/onlp/builds/x86_64_inventec_d7032q28b/module/src/Makefile +++ /dev/null @@ -1,9 +0,0 @@ -############################################################################### -# -# Local source generation targets. -# -############################################################################### - -ucli: - @../../../../tools/uclihandlers.py x86_64_inventec_d7032q28b_ucli.c - diff --git a/packages/platforms/inventec/x86-64/d7032q28b/onlp/builds/x86_64_inventec_d7032q28b/module/src/debug.c b/packages/platforms/inventec/x86-64/d7032q28b/onlp/builds/x86_64_inventec_d7032q28b/module/src/debug.c deleted file mode 100644 index 7831ccc88..000000000 --- a/packages/platforms/inventec/x86-64/d7032q28b/onlp/builds/x86_64_inventec_d7032q28b/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/d7032q28b/onlp/builds/x86_64_inventec_d7032q28b/module/src/fani.c b/packages/platforms/inventec/x86-64/d7032q28b/onlp/builds/x86_64_inventec_d7032q28b/module/src/fani.c deleted file mode 100644 index 1658caa02..000000000 --- a/packages/platforms/inventec/x86-64/d7032q28b/onlp/builds/x86_64_inventec_d7032q28b/module/src/fani.c +++ /dev/null @@ -1,269 +0,0 @@ -/************************************************************ - * fani.c - * - * Copyright 2018 Inventec Technology Corporation. - * - ************************************************************ - * - * Fan Platform Implementation Defaults. - * - ***********************************************************/ -#include -#include -#include -#include -#include -#include "platform_lib.h" - -#define FAN_GPI_ON_MAIN_BOARD INV_PSOC_PREFIX"/fan_gpi" - -#define MAX_FAN_SPEED 18000 -#define MAX_PSU_FAN_SPEED 25500 - -#define PROJECT_NAME -#define LEN_FILE_NAME 80 - -static char* devfiles__[FAN_MAX] = /* must map with onlp_thermal_id */ -{ - "reserved", - INV_PSOC_PREFIX"/fan1_input", - INV_PSOC_PREFIX"/fan2_input", - INV_PSOC_PREFIX"/fan3_input", - INV_PSOC_PREFIX"/fan4_input", - INV_PSOC_PREFIX"/fan5_input", - INV_PSOC_PREFIX"/fan6_input", - INV_PSOC_PREFIX"/fan7_input", - INV_PSOC_PREFIX"/fan8_input", - INV_PSOC_PREFIX"/rpm_psu1", - INV_PSOC_PREFIX"/rpm_psu2", -}; - -#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_F2B | 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_F2B | ONLP_FAN_CAPS_GET_RPM | ONLP_FAN_CAPS_GET_PERCENTAGE), \ - 0, \ - 0, \ - ONLP_FAN_MODE_INVALID, \ - } - -/* Static fan information */ -onlp_fan_info_t linfo[FAN_MAX] = { - { }, /* 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_MAIN_BOARD(7), - MAKE_FAN_INFO_NODE_ON_MAIN_BOARD(8), - 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, FAN_GPI_ON_MAIN_BOARD); - if (ret < 0) { - return ONLP_STATUS_E_INTERNAL; - } - if (value & (1 << (fid-1))) { - info->status |= ONLP_FAN_STATUS_FAILED; - } - else { - info->status |= ONLP_FAN_STATUS_PRESENT; - info->status |= ONLP_FAN_STATUS_F2B; - } - - /* get front fan speed */ - ret = onlp_file_read_int(&value, devfiles__[fid]); - if (ret < 0) { - return ONLP_STATUS_E_INTERNAL; - } - info->rpm = value; - info->percentage = (info->rpm * 100) / MAX_PSU_FAN_SPEED; - - snprintf(info->model, ONLP_CONFIG_INFO_STR_MAX, "NA"); - snprintf(info->serial, ONLP_CONFIG_INFO_STR_MAX, "NA"); - - 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 fid, onlp_fan_info_t* info) -{ - int value, ret, index; - - info->status |= ONLP_FAN_STATUS_PRESENT; - info->status |= ONLP_FAN_STATUS_F2B; - - /* get fan direction */ - info->status |= _onlp_get_fan_direction_on_psu(); - - if (info->status & ONLP_FAN_STATUS_FAILED) { - return ONLP_STATUS_OK; - } - - index = ONLP_OID_ID_GET(info->hdr.id); - info->hdr.coids[0] = ONLP_FAN_ID_CREATE(index + CHASSIS_FAN_COUNT); - - /* get front fan speed */ - ret = onlp_file_read_int(&value, devfiles__[fid]); - if (ret < 0) { - return ONLP_STATUS_E_INTERNAL; - } - info->rpm = value; - info->percentage = (info->rpm * 100) / MAX_PSU_FAN_SPEED; - info->status |= (value == 0) ? ONLP_FAN_STATUS_FAILED : 0; - - snprintf(info->model, ONLP_CONFIG_INFO_STR_MAX, "NA"); - snprintf(info->serial, ONLP_CONFIG_INFO_STR_MAX, "NA"); - - 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: - 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 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_PSU1: - return psu_pmbus_info_set(PSU1_ID, "rpm_psu1", p); - case FAN_1_ON_PSU2: - return psu_pmbus_info_set(PSU2_ID, "rpm_psu2", p); - 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: - 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/d7032q28b/onlp/builds/x86_64_inventec_d7032q28b/module/src/ledi.c b/packages/platforms/inventec/x86-64/d7032q28b/onlp/builds/x86_64_inventec_d7032q28b/module/src/ledi.c deleted file mode 100644 index f9389cd72..000000000 --- a/packages/platforms/inventec/x86-64/d7032q28b/onlp/builds/x86_64_inventec_d7032q28b/module/src/ledi.c +++ /dev/null @@ -1,424 +0,0 @@ -/************************************************************ - * ledi.c - * - * Copyright 2018 Inventec Technology Corporation. - * - ************************************************************ - * - ***********************************************************/ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "platform_lib.h" - -#define filename "brightness" - -#define VALIDATE(_id) \ - do { \ - if(!ONLP_OID_IS_LED(_id)) { \ - return ONLP_STATUS_E_INVALID; \ - } \ - } while(0) - -static char* devfiles__[LED_MAX] = /* must map with onlp_thermal_id */ -{ - "reserved", - INV_CPLD_PREFIX"/%s_led", - INV_PSOC_PREFIX"/fan_led_%s1", - INV_PSOC_PREFIX"/fan_led_%s2", - INV_PSOC_PREFIX"/fan_led_%s3", - INV_PSOC_PREFIX"/fan_led_%s4", -}; - -/* - * Get the information for the given LED OID. - */ -static onlp_led_info_t linfo[LED_MAX] = -{ - { }, /* Not used */ - { - { ONLP_LED_ID_CREATE(LED_SYS), "Chassis LED (SYSTEM 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_MODE_ON, '0', - }, - { - { ONLP_LED_ID_CREATE(LED_FAN1), "Fan LED 1 (FAN1 LED)", 0 }, - ONLP_LED_STATUS_PRESENT, - ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_RED, - ONLP_LED_MODE_ON, '0', - }, - { - { ONLP_LED_ID_CREATE(LED_FAN2), "Fan LED 2 (FAN2 LED)", 0 }, - ONLP_LED_STATUS_PRESENT, - ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_RED, - ONLP_LED_MODE_ON, '0', - }, - { - { ONLP_LED_ID_CREATE(LED_FAN3), "Fan LED 3 (FAN3 LED)", 0 }, - ONLP_LED_STATUS_PRESENT, - ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_RED, - ONLP_LED_MODE_ON, '0', - }, - { - { ONLP_LED_ID_CREATE(LED_FAN4), "Fan LED 4 (FAN4 LED)", 0 }, - ONLP_LED_STATUS_PRESENT, - ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_RED, - ONLP_LED_MODE_ON, '0', - }, -}; - -/* - * This function will be called prior to any other onlp_ledi_* functions. - */ -static pthread_mutex_t diag_mutex; - -int -onlp_ledi_init(void) -{ - pthread_mutex_init(&diag_mutex, NULL); - - /* - * Diag LED Off - */ - onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_SYS), ONLP_LED_MODE_OFF); - - return ONLP_STATUS_OK; -} - -int onlp_chassis_led_read(char *pathp, char *buf, size_t len) -{ - FILE * fp; - - fp = fopen (pathp, "r"); - if(fp == NULL) { - perror("Error opening file"); - return(-1); - } - if( fgets (buf, len, fp) == NULL ) { - perror("Error fgets operation"); - } - fclose(fp); - - return(0); -} - -int onlp_chassis_led_write(char *pathp, char *buf) -{ - FILE * fp; - - fp = fopen (pathp, "w"); - if(fp == NULL) { - perror("Error opening file"); - return(-1); - } - if( fputs (buf, fp) == 0 ) { - perror("Error fputs operation"); - } - fclose(fp); - - return(0); -} - -int -onlp_ledi_info_get(onlp_oid_t id, onlp_led_info_t* info) -{ - int local_id, gret = 0, rret = 0; - char fullpath_grn[50] = {0}; - char fullpath_red[50] = {0}; - int gvalue = 0, rvalue = 0; - char gbuf[32] = {0}; - char rbuf[32] = {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 fullpath */ - switch (local_id) { - case LED_SYS: - sprintf(fullpath_grn, devfiles__[local_id], "grn"); - sprintf(fullpath_red, devfiles__[local_id], "red"); - - /* Set LED mode */ - gret = onlp_chassis_led_read(fullpath_grn, gbuf, 32); - rret = onlp_chassis_led_read(fullpath_red, rbuf, 32); - if (gret < 0 || rret < 0) { - DEBUG_PRINT("%s(%d): gret = %d, rret = %d\r\n", __FUNCTION__, __LINE__, gret, rret); - info->mode = ONLP_LED_MODE_OFF; - info->status = ONLP_LED_STATUS_FAILED; - break; - } - - info->status = ONLP_LED_STATUS_PRESENT; - if (gbuf[0] >= '1' && gbuf[0] <= '7' && rbuf[0] == '0') { - info->mode = ONLP_LED_MODE_GREEN; - info->status |= ONLP_LED_STATUS_ON; - } - else - if (rbuf[0] >= '1' && rbuf[0] <= '7' && gbuf[0] == '0') { - info->mode = ONLP_LED_MODE_RED; - info->status |= ONLP_LED_STATUS_ON; - } - else - if (gbuf[0] >= '1' && gbuf[0] <= '7' && rbuf[0] >= '1' && rbuf[0] <= '7') { - info->mode = ONLP_LED_MODE_ORANGE; - info->status |= ONLP_LED_STATUS_ON; - } - else - if (gbuf[0] == '0' && rbuf[0] == '0') { - info->mode = ONLP_LED_MODE_OFF; - info->status |= ONLP_LED_STATUS_ON; - } - else { - info->mode = ONLP_LED_MODE_OFF; - info->status = ONLP_LED_STATUS_FAILED; - } - break; - case LED_FAN1: - case LED_FAN2: - case LED_FAN3: - case LED_FAN4: - sprintf(fullpath_grn, devfiles__[local_id], "grn"); - - /* Set LED mode */ - if (onlp_file_read_int(&gvalue, fullpath_grn) != 0) { - DEBUG_PRINT("%s(%d)\r\n", __FUNCTION__, __LINE__); - info->mode = ONLP_LED_MODE_OFF; - info->status = ONLP_LED_STATUS_FAILED; - } - else - if (gvalue == 1) { - info->mode = ONLP_LED_MODE_GREEN; - info->status = ONLP_LED_STATUS_ON; - } - else - if (gvalue == 0) { - info->mode = ONLP_LED_MODE_OFF; - info->status = ONLP_LED_STATUS_ON; - } - - sprintf(fullpath_red, devfiles__[local_id], "red"); - - if (onlp_file_read_int(&rvalue, fullpath_red) != 0) { - DEBUG_PRINT("%s(%d)\r\n", __FUNCTION__, __LINE__); - info->mode = ONLP_LED_MODE_OFF; - info->status = ONLP_LED_STATUS_FAILED; - } - else - if (rvalue == 1) { - info->mode = ONLP_LED_MODE_RED; - info->status = ONLP_LED_STATUS_ON; - } - else - if (rvalue == 0) { - info->mode = ONLP_LED_MODE_OFF; - info->status = ONLP_LED_STATUS_ON; - } - break; - default: - DEBUG_PRINT("%s(%d) Invalid led id %d\r\n", __FUNCTION__, __LINE__, local_id); - break; - } - - return ONLP_STATUS_OK; -} - -int onlp_ledi_status_get(onlp_oid_t id, uint32_t* rv) -{ - int result = ONLP_STATUS_OK; - onlp_led_info_t linfo; - - result = onlp_ledi_info_get(id, &linfo); - *rv = linfo.status; - - return result; -} - -/* - * 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; -} - -#define HWMON_DEVICE_DIAG_PATH INV_PSOC_PREFIX"/subsystem/devices/0-0066/diag" -#define HWMON_DEVICE_CTRL_PATH INV_CPLD_PREFIX"/subsystem/devices/0-0055/ctl" - -#define MIN_ACC_SIZE (32) - -/* - * Store attr Section - */ -static int onlp_chassis_led_diag_enable(void) -{ - char tmp[MIN_ACC_SIZE]; - ssize_t ret; - - ret = onlp_chassis_led_read(HWMON_DEVICE_DIAG_PATH, &tmp[0], MIN_ACC_SIZE); - if (ret <= 0) { - return ret; - } - - if (tmp[0] == '0') { - pthread_mutex_lock(&diag_mutex); - ret = onlp_chassis_led_write(HWMON_DEVICE_DIAG_PATH, "1"); - if (ret < 0) { - pthread_mutex_unlock(&diag_mutex); - return ret; - } - - ret = onlp_chassis_led_write(HWMON_DEVICE_CTRL_PATH, "1"); - if (ret < 0) { - pthread_mutex_unlock(&diag_mutex); - return ret; - } - pthread_mutex_unlock(&diag_mutex); - } - - return ret; -} - -static int onlp_chassis_led_diag_disable(void) -{ - char tmp[MIN_ACC_SIZE]; - ssize_t ret; - - ret = onlp_chassis_led_read(HWMON_DEVICE_DIAG_PATH, &tmp[0], MIN_ACC_SIZE); - if (ret <= 0) { - return ret; - } - - if (tmp[0] == '1') { - pthread_mutex_lock(&diag_mutex); - ret = onlp_chassis_led_write(HWMON_DEVICE_DIAG_PATH, "1"); - if (ret < 0) { - pthread_mutex_unlock(&diag_mutex); - return 1; - } - - ret = onlp_chassis_led_write(HWMON_DEVICE_CTRL_PATH, "1"); - if (ret < 0) { - pthread_mutex_unlock(&diag_mutex); - return 1; - } - pthread_mutex_unlock(&diag_mutex); - } - return 1; -} - -/* - * 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) -{ - char fullpath_grn[50] = {0}; - char fullpath_red[50] = {0}; - char sys_buf[32] = {0}; - onlp_led_info_t linfo; - int ret = onlp_ledi_info_get(id, &linfo); - int local_id; - - VALIDATE(id); - - local_id = ONLP_OID_ID_GET(id); - - switch (mode) { - case ONLP_LED_MODE_OFF: - if (ret == ONLP_STATUS_OK && linfo.status & ONLP_LED_STATUS_ON && linfo.mode == ONLP_LED_MODE_OFF) { - return ONLP_STATUS_OK; - } - - sprintf(sys_buf, "%d", 0x0); - sprintf(fullpath_grn, devfiles__[local_id], "grn"); - ret = onlp_chassis_led_write(fullpath_grn, sys_buf); - - sprintf(sys_buf, "%d", 0x0); - sprintf(fullpath_red, devfiles__[local_id], "red"); - ret = onlp_chassis_led_write(fullpath_red, sys_buf); - break; - case ONLP_LED_MODE_RED: - if (ret == ONLP_STATUS_OK && linfo.status & ONLP_LED_STATUS_ON && linfo.mode == ONLP_LED_MODE_RED) { - return ONLP_STATUS_OK; - } - - sprintf(sys_buf, "%d", 0x0); - sprintf(fullpath_grn, devfiles__[local_id], "grn"); - ret = onlp_chassis_led_write(fullpath_grn, sys_buf); - - sprintf(sys_buf, "%d", 0x7); - sprintf(fullpath_red, devfiles__[local_id], "red"); - ret = onlp_chassis_led_write(fullpath_red, sys_buf); - break; - case ONLP_LED_MODE_GREEN: - if (ret == ONLP_STATUS_OK && linfo.status & ONLP_LED_STATUS_ON && linfo.mode == ONLP_LED_MODE_GREEN) { - return ONLP_STATUS_OK; - } - - sprintf(sys_buf, "%d", 0x7); - sprintf(fullpath_grn, devfiles__[local_id], "grn"); - ret = onlp_chassis_led_write(fullpath_grn, sys_buf); - - sprintf(sys_buf, "%d", 0x0); - sprintf(fullpath_red, devfiles__[local_id], "red"); - ret = onlp_chassis_led_write(fullpath_red, sys_buf); - break; - case ONLP_LED_MODE_ORANGE: - if (ret == ONLP_STATUS_OK && linfo.status & ONLP_LED_STATUS_ON && linfo.mode == ONLP_LED_MODE_ORANGE) { - return ONLP_STATUS_OK; - } - - sprintf(sys_buf, "%d", 0x7); - sprintf(fullpath_grn, devfiles__[local_id], "grn"); - ret = onlp_chassis_led_write(fullpath_grn, sys_buf); - - sprintf(sys_buf, "%d", 0x7); - sprintf(fullpath_red, devfiles__[local_id], "red"); - ret = onlp_chassis_led_write(fullpath_red, sys_buf); - break; - default: - DEBUG_PRINT("%s(%d) Invalid led mode %d\r\n", __FUNCTION__, __LINE__, mode); - return ONLP_STATUS_E_INTERNAL; - } - - switch (local_id) { - case LED_SYS: - onlp_chassis_led_diag_enable(); - sleep(1); - onlp_chassis_led_diag_disable(); - break; - default: - break; - } - - return ONLP_STATUS_OK; -} diff --git a/packages/platforms/inventec/x86-64/d7032q28b/onlp/builds/x86_64_inventec_d7032q28b/module/src/make.mk b/packages/platforms/inventec/x86-64/d7032q28b/onlp/builds/x86_64_inventec_d7032q28b/module/src/make.mk deleted file mode 100644 index 6176a32ea..000000000 --- a/packages/platforms/inventec/x86-64/d7032q28b/onlp/builds/x86_64_inventec_d7032q28b/module/src/make.mk +++ /dev/null @@ -1,9 +0,0 @@ -############################################################################### -# -# -# -############################################################################### - -LIBRARY := x86_64_inventec_d7032q28b -$(LIBRARY)_SUBDIR := $(dir $(lastword $(MAKEFILE_LIST))) -include $(BUILDER)/lib.mk diff --git a/packages/platforms/inventec/x86-64/d7032q28b/onlp/builds/x86_64_inventec_d7032q28b/module/src/platform_lib.c b/packages/platforms/inventec/x86-64/d7032q28b/onlp/builds/x86_64_inventec_d7032q28b/module/src/platform_lib.c deleted file mode 100644 index 6f877dd52..000000000 --- a/packages/platforms/inventec/x86-64/d7032q28b/onlp/builds/x86_64_inventec_d7032q28b/module/src/platform_lib.c +++ /dev/null @@ -1,176 +0,0 @@ -/************************************************************ - * platform_lib.c - * - * Copyright 2018 Inventec Corporation. - * - ************************************************************ - * - ***********************************************************/ -#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) { - aim_strlcpy(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) { - aim_strlcpy(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) { - aim_strlcpy(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%d", PSU1_AC_PMBUS_PREFIX, node, PSU1_ID); - } - else - if (PSU2_ID == id) { - ret = onlp_file_read_int(value, "%s%s%d", PSU2_AC_PMBUS_PREFIX, node, PSU2_ID); - } - else { - return ONLP_STATUS_E_INTERNAL; - } - - 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%d", PSU1_AC_PMBUS_PREFIX, node, PSU1_ID); - break; - case PSU2_ID: - sprintf(path, "%s%s%d", PSU2_AC_PMBUS_PREFIX, node, PSU2_ID); - 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/d7032q28b/onlp/builds/x86_64_inventec_d7032q28b/module/src/platform_lib.h b/packages/platforms/inventec/x86-64/d7032q28b/onlp/builds/x86_64_inventec_d7032q28b/module/src/platform_lib.h deleted file mode 100644 index add80c182..000000000 --- a/packages/platforms/inventec/x86-64/d7032q28b/onlp/builds/x86_64_inventec_d7032q28b/module/src/platform_lib.h +++ /dev/null @@ -1,135 +0,0 @@ -/************************************************************ - * platform_lib.h - * - * Copyright 2018 Inventec Technology Corporation. - * - ************************************************************ - * - ***********************************************************/ -#ifndef __PLATFORM_LIB_H__ -#define __PLATFORM_LIB_H__ - -#include "x86_64_inventec_d7032q28b_log.h" - -#define ONLP_NODE_MAX_INT_LEN (8) -#define ONLP_NODE_MAX_PATH_LEN (64) - -#define INV_CPLD_COUNT (1) -#define INV_CPLD_PREFIX "/sys/bus/i2c/devices/0-0055/" -#define INV_PSOC_PREFIX "/sys/bus/i2c/devices/0-0066/" -#define INV_EPRM_PREFIX "/sys/bus/i2c/devices/0-0053/" -#define INV_CTMP_PREFIX "/sys/devices/platform/coretemp.0/hwmon/hwmon0/" - -#define INV_SFP_EEPROM_UPDATE "/sys/class/swps/module/eeprom_update" -#define CHASSIS_SFP_COUNT (32) - -/* - * Definitions of Chassis EEPROM - */ -#define EEPROM_NODE(node) INV_EPRM_PREFIX#node - -/* - * Definitions of D7032Q28B device - */ -enum onlp_thermal_id { - THERMAL_RESERVED = 0, - THERMAL_CPU_CORE_FIRST, - THERMAL_CPU_CORE_3, - THERMAL_CPU_CORE_4, - THERMAL_CPU_CORE_LAST, - 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, - THERMAL_MAX -}; -#define CHASSIS_THERMAL_COUNT (9) - -enum onlp_fan_id { - FAN_RESERVED = 0, - FAN_1_ON_MAIN_BOARD, - FAN_2_ON_MAIN_BOARD, - FAN_3_ON_MAIN_BOARD, - FAN_4_ON_MAIN_BOARD, - FAN_5_ON_MAIN_BOARD, - FAN_6_ON_MAIN_BOARD, - FAN_7_ON_MAIN_BOARD, - FAN_8_ON_MAIN_BOARD, - FAN_1_ON_PSU1, - FAN_1_ON_PSU2, - FAN_MAX -}; -#define CHASSIS_FAN_COUNT (8) - -enum onlp_led_id { - LED_RESERVED = 0, - LED_SYS, - LED_FAN1, - LED_FAN2, - LED_FAN3, - LED_FAN4, - LED_MAX -}; -#define CHASSIS_LED_COUNT (1) - -enum onlp_psu_id { - PSU_RESERVED = 0, - PSU1_ID, - PSU2_ID, - PSU_MAX -}; -#define CHASSIS_PSU_COUNT (2) - -#define PSU1_AC_PMBUS_PREFIX INV_PSOC_PREFIX -#define PSU2_AC_PMBUS_PREFIX INV_PSOC_PREFIX - -#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 INV_CPLD_PREFIX -#define PSU2_AC_HWMON_PREFIX INV_CPLD_PREFIX - -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 PSU1_AC_HWMON_NODE(node) PSU1_AC_HWMON_PREFIX#node -#define PSU2_AC_HWMON_NODE(node) PSU2_AC_HWMON_PREFIX#node - -/* - * Definitions of FAN device - */ -#define FAN_BOARD_PATH INV_PSOC_PREFIX -#define FAN_NODE(node) FAN_BOARD_PATH#node - -/* - * Prototypes - */ -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); - -#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/d7032q28b/onlp/builds/x86_64_inventec_d7032q28b/module/src/psui.c b/packages/platforms/inventec/x86-64/d7032q28b/onlp/builds/x86_64_inventec_d7032q28b/module/src/psui.c deleted file mode 100644 index 4881c2a55..000000000 --- a/packages/platforms/inventec/x86-64/d7032q28b/onlp/builds/x86_64_inventec_d7032q28b/module/src/psui.c +++ /dev/null @@ -1,257 +0,0 @@ -/************************************************************ - * psui.c - * - * Copyright 2018 Inventec Technology Corporation. - * - ************************************************************ - * - ***********************************************************/ -#include -#include -#include -#include -#include -#include -#include "platform_lib.h" - -#define PSU_STATUS_PRESENT (0) -#define PSU_STATUS_POWER_GOOD (1) -#define PSU_STATUS_UNPOWERED (2) -#define PSU_STATUS_FAULT (4) -#define PSU_STATUS_UNINSTALLED (7) - -#define VALIDATE(_id) \ - do { \ - if(!ONLP_OID_IS_PSU(_id)) { \ - return ONLP_STATUS_E_INVALID; \ - } \ - } while(0) - -static char* status_devfiles__[PSU_MAX] = /* must map with onlp_psu_id */ -{ - "reserved", - INV_CPLD_PREFIX"/psu0", - INV_CPLD_PREFIX"/psu1", -}; - -static char* module_devfiles__[PSU_MAX] = /* must map with onlp_psu_id */ -{ - "reserved", - INV_PSOC_PREFIX"/psoc_psu1_%s", - INV_PSOC_PREFIX"/psoc_psu2_%s", -}; - -static int -psu_status_info_get(int id, char *node, int *value) -{ - int ret = 0; - char node_path[ONLP_NODE_MAX_PATH_LEN] = {0}; - - *value = 0; - if (PSU1_ID == id) { - sprintf(node_path, status_devfiles__[id]); - } - else if (PSU2_ID == id) { - sprintf(node_path, status_devfiles__[id]); - } - - 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 ONLP_STATUS_OK; -} - - -int -onlp_psui_init(void) -{ - return ONLP_STATUS_OK; -} - -static char* module2_devfiles__[PSU_MAX] = /* must map with onlp_psu_id */ -{ - "reserved", - INV_PSOC_PREFIX"/psu1_%s", - INV_PSOC_PREFIX"/psu2_%s", -}; - -static void -psu_module_name_get(int id, onlp_psu_info_t* info) -{ - char node_path[ONLP_NODE_MAX_PATH_LEN] = {0}; - uint8_t temp[ONLP_CONFIG_INFO_STR_MAX] = {0}; - int ret, len; - - memset(node_path, 0, ONLP_NODE_MAX_PATH_LEN); - sprintf(node_path, module2_devfiles__[id], "model2"); - ret = onlp_file_read(temp, ONLP_CONFIG_INFO_STR_MAX, &len, node_path); - if (ret == 0) { - /*remove the '\n'*/ - temp[strlen((char*)temp)-1] = 0; - snprintf(info->model, ONLP_CONFIG_INFO_STR_MAX, "%s", temp); - } - else { - AIM_LOG_ERROR("Unable to read model name from file(%s)\r\n", node_path); - aim_strlcpy(info->model, "N/A", 3); - } - - memset(node_path, 0, ONLP_NODE_MAX_PATH_LEN); - sprintf(node_path, module2_devfiles__[id], "sn2"); - ret = onlp_file_read(temp, ONLP_CONFIG_INFO_STR_MAX, &len, node_path); - if (ret == 0) { - /*remove the '\n'*/ - temp[strlen((char*)temp)-1] = 0; - snprintf(info->serial, ONLP_CONFIG_INFO_STR_MAX, "%s", temp); - } - else { - AIM_LOG_ERROR("Unable to read model name from file(%s)\r\n", node_path); - aim_strlcpy(info->serial, "N/A", 3); - } -} - -static int -psu_module_info_get(int id, onlp_psu_info_t* info) -{ - int ret = 0; - char node_path[ONLP_NODE_MAX_PATH_LEN] = {0}; - int value = 0; - - info->caps |= ONLP_PSU_CAPS_DC12; - - memset(node_path, 0, ONLP_NODE_MAX_PATH_LEN); - sprintf(node_path, module_devfiles__[id], "vout"); - ret = onlp_file_read_int(&value, node_path); - if (ret < 0) { - AIM_LOG_ERROR("Unable to read vout from file(%s)\r\n", node_path); - } - else { - info->mvout = value; - info->caps |= ONLP_PSU_CAPS_VOUT; - } - - memset(node_path, 0, ONLP_NODE_MAX_PATH_LEN); - sprintf(node_path, module_devfiles__[id], "iout"); - ret = onlp_file_read_int(&value, node_path); - if (ret < 0) { - AIM_LOG_ERROR("Unable to read iout from file(%s)\r\n", node_path); - } - else { - info->miout = value; - info->caps |= ONLP_PSU_CAPS_IOUT; - } - - memset(node_path, 0, ONLP_NODE_MAX_PATH_LEN); - sprintf(node_path, module_devfiles__[id], "pout"); - ret = onlp_file_read_int(&value, node_path); - if (ret < 0) { - AIM_LOG_ERROR("Unable to read pout from file(%s)\r\n", node_path); - } - else { - info->mpout = value; - info->caps |= ONLP_PSU_CAPS_POUT; - } - - memset(node_path, 0, ONLP_NODE_MAX_PATH_LEN); - sprintf(node_path, module_devfiles__[id], "vin"); - ret = onlp_file_read_int(&value, node_path); - if (ret < 0) { - AIM_LOG_ERROR("Unable to read vin from file(%s)\r\n", node_path); - } - else { - info->mvin = value; - info->caps |= ONLP_PSU_CAPS_VIN; - } - - memset(node_path, 0, ONLP_NODE_MAX_PATH_LEN); - sprintf(node_path, module_devfiles__[id], "iin"); - ret = onlp_file_read_int(&value, node_path); - if (ret < 0) { - AIM_LOG_ERROR("Unable to read iin from file(%s)\r\n", node_path); - } - else { - info->miin = value; - info->caps |= ONLP_PSU_CAPS_IIN; - } - - memset(node_path, 0, ONLP_NODE_MAX_PATH_LEN); - sprintf(node_path, module_devfiles__[id], "pin"); - ret = onlp_file_read_int(&value, node_path); - if (ret < 0) { - AIM_LOG_ERROR("Unable to read pin from file(%s)\r\n", node_path); - } - else { - info->mpin = value; - info->caps |= ONLP_PSU_CAPS_PIN; - } - - psu_module_name_get(id, info); - 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_THERMAL_ID_CREATE(THERMAL_1_ON_PSU1), - ONLP_FAN_ID_CREATE(FAN_1_ON_PSU1) - } - }, - }, - { - { - ONLP_PSU_ID_CREATE(PSU2_ID), "PSU-2", 0, - { - ONLP_THERMAL_ID_CREATE(THERMAL_1_ON_PSU2), - ONLP_FAN_ID_CREATE(FAN_1_ON_PSU2) - } - }, - } -}; - -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 ((ret = psu_status_info_get(index, "psu", &val)) == ONLP_STATUS_E_INTERNAL) { - printf("Unable to read PSU(%d) node(psu)\r\n", index); - return ret; - } - - if (val == 0) { - info->status = ONLP_PSU_STATUS_PRESENT; - } - else - if (val == 1) { - info->status = ONLP_PSU_STATUS_UNPLUGGED; - return ret; - } - else { - info->status = ONLP_PSU_STATUS_FAILED; - return ret; - } - - if ((ret = psu_module_info_get(index, info)) != ONLP_STATUS_OK) { - printf("Unable to read PSU(%d) module information\r\n", index); - } - - return ret; -} diff --git a/packages/platforms/inventec/x86-64/d7032q28b/onlp/builds/x86_64_inventec_d7032q28b/module/src/sfpi.c b/packages/platforms/inventec/x86-64/d7032q28b/onlp/builds/x86_64_inventec_d7032q28b/module/src/sfpi.c deleted file mode 100644 index 52d60b211..000000000 --- a/packages/platforms/inventec/x86-64/d7032q28b/onlp/builds/x86_64_inventec_d7032q28b/module/src/sfpi.c +++ /dev/null @@ -1,236 +0,0 @@ -/************************************************************ - * sfpi.c - * - * Copyright 2018 Inventec Technology Corporation. - * - ************************************************************ - * - ***********************************************************/ -#include - -#include /* For O_RDWR && open */ -#include -#include -#include -#include -#include -#include -#include "platform_lib.h" - -static char sfp_node_path[ONLP_NODE_MAX_PATH_LEN] = {0}; - -#define NUM_OF_SFP_PORT (CHASSIS_SFP_COUNT) -static const int sfp_mux_index[NUM_OF_SFP_PORT] = { -22, 23, 24, 25, 26, 27, 28, 29, -30, 31, 32, 33, 34, 35, 36, 37, - 6, 7, 8, 9, 10, 11, 12, 13, -14, 15, 16, 17, 18, 19, 20, 21 -}; - -#define FRONT_PORT_TO_MUX_INDEX(port) (sfp_mux_index[port]) - -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/class/swps/port%d/%s", 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, "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; - } - if (present == 0) { - present = 1; - } - else - if (present == 1) { - present = 0; - } - else { - AIM_LOG_ERROR("Unvalid present status %d from port(%d)\r\n",present,port); - return ONLP_STATUS_E_INTERNAL; - } - return present; -} - -int -onlp_sfpi_presence_bitmap_get(onlp_sfp_bitmap_t* dst) -{ - uint32_t presence_all = 0 ; - int port, ret; - - for (port = 0; port < NUM_OF_SFP_PORT; port++) { - ret = onlp_sfpi_is_present(port); - if (ret == 1) { - presence_all |= (1<>= 1; - } - return ONLP_STATUS_OK; -} - -int -onlp_sfpi_eeprom_read(int port, uint8_t data[256]) -{ - char* path; - 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); - path = sfp_get_port_path(port, "eeprom"); - if (onlp_file_read(&data[0], 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_dom_read(int port, uint8_t data[256]) -{ - return onlp_sfpi_eeprom_read( port, data); -} - -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_inv_file_vwrite_uint(int value, const char* fmt, va_list vargs) -{ - int rv; - char* s = aim_fstrdup("%u", value); - rv = onlp_file_vwrite_str(s, fmt, vargs); - aim_free(s); - return rv; -} - -int -onlp_inv_file_write_uint(unsigned int value, const char* fmt, ...) -{ - int rv; - va_list vargs; - va_start(vargs, fmt); - rv = onlp_inv_file_vwrite_uint(value, fmt, vargs); - va_end(vargs); - return rv; -} - -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 ret = onlp_i2c_writeb(bus, devaddr, addr, value, ONLP_I2C_F_FORCE); - - if (ret == 0) { - if (onlp_inv_file_write_uint((1 << port), INV_SFP_EEPROM_UPDATE) == 0) { - return ONLP_STATUS_OK; - } - } - AIM_LOG_ERROR("Unable to read eeprom_update from port(%d)\r\n", port); - return ret; -} - -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); - int ret = onlp_i2c_writew(bus, devaddr, addr, value, ONLP_I2C_F_FORCE); - - if (ret == 0) { - if (onlp_inv_file_write_uint((1 << port), INV_SFP_EEPROM_UPDATE) == 0) { - return ONLP_STATUS_OK; - } - } - AIM_LOG_ERROR("Unable to read eeprom_update from port(%d)\r\n", port); - return ret; -} - -int -onlp_sfpi_denit(void) -{ - return ONLP_STATUS_OK; -} - diff --git a/packages/platforms/inventec/x86-64/d7032q28b/onlp/builds/x86_64_inventec_d7032q28b/module/src/sysi.c b/packages/platforms/inventec/x86-64/d7032q28b/onlp/builds/x86_64_inventec_d7032q28b/module/src/sysi.c deleted file mode 100644 index 4b774fda0..000000000 --- a/packages/platforms/inventec/x86-64/d7032q28b/onlp/builds/x86_64_inventec_d7032q28b/module/src/sysi.c +++ /dev/null @@ -1,110 +0,0 @@ -/************************************************************ - * sysi.c - * - * Copyright 2018 Inventec Technology Corporation. - * - ************************************************************ - * - ***********************************************************/ -#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_CPLD INV_CPLD_COUNT - -#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 (CHASSIS_PSU_COUNT) -#define NUM_OF_LED_ON_MAIN_BROAD (CHASSIS_LED_COUNT) - -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, EEPROM_NODE(eeprom)) == 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)); - - /* 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; -} - -static char *arr_cplddev_version[NUM_OF_CPLD] = -{ - INV_CPLD_PREFIX"/version", -}; - -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, arr_cplddev_version[i]) < 0) { - return ONLP_STATUS_E_INTERNAL; - } - } - pi->cpld_versions = aim_fstrdup("%d.%d", v[0], v[1]); - return 0; -} - -void -onlp_sysi_platform_info_free(onlp_platform_info_t* pi) -{ - aim_free(pi->cpld_versions); -} diff --git a/packages/platforms/inventec/x86-64/d7032q28b/onlp/builds/x86_64_inventec_d7032q28b/module/src/thermali.c b/packages/platforms/inventec/x86-64/d7032q28b/onlp/builds/x86_64_inventec_d7032q28b/module/src/thermali.c deleted file mode 100644 index 7d86d591d..000000000 --- a/packages/platforms/inventec/x86-64/d7032q28b/onlp/builds/x86_64_inventec_d7032q28b/module/src/thermali.c +++ /dev/null @@ -1,132 +0,0 @@ -/************************************************************ - * thermali.c - * - * Copyright 2018 Inventec Technology Corporation. - * - ************************************************************ - * - * 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) - -static char* devfiles__[THERMAL_MAX] = /* must map with onlp_thermal_id */ -{ - "reserved", - INV_CTMP_PREFIX"/temp2_%s", - INV_CTMP_PREFIX"/temp3_%s", - INV_CTMP_PREFIX"/temp4_%s", - INV_CTMP_PREFIX"/temp5_%s", - INV_PSOC_PREFIX"/temp1_input", - INV_PSOC_PREFIX"/temp2_input", - INV_PSOC_PREFIX"/temp3_input", - INV_PSOC_PREFIX"/temp4_input", - INV_PSOC_PREFIX"/temp5_input", - INV_PSOC_PREFIX"/thermal_psu1", - INV_PSOC_PREFIX"/thermal_psu2", -}; - -/* Static values */ -static onlp_thermal_info_t linfo[THERMAL_MAX] = { - { }, /* Not used */ - { { ONLP_THERMAL_ID_CREATE(THERMAL_CPU_CORE_FIRST), "CPU Core 0", 0}, - ONLP_THERMAL_STATUS_PRESENT, - ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS - }, - { { ONLP_THERMAL_ID_CREATE(THERMAL_CPU_CORE_3), "CPU Core 1", 0}, - ONLP_THERMAL_STATUS_PRESENT, - ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS - }, - { { ONLP_THERMAL_ID_CREATE(THERMAL_CPU_CORE_4), "CPU Core 2", 0}, - ONLP_THERMAL_STATUS_PRESENT, - ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS - }, - { { ONLP_THERMAL_ID_CREATE(THERMAL_CPU_CORE_LAST), "CPU Core 3", 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_3_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_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_FIRST && local_id <= THERMAL_CPU_CORE_LAST) { - char desc[32], *dp = &desc[0]; - int rv = onlp_file_read_str(&dp, devfiles__[local_id], "label"); - if (rv > 0) { - memset (info->hdr.description, 0, ONLP_OID_DESC_SIZE); - aim_strlcpy(info->hdr.description, dp, rv); - } - - /* Set the onlp_oid_hdr_t and capabilities */ - return onlp_file_read_int(&info->mcelsius, devfiles__[local_id], "input"); - } - return onlp_file_read_int(&info->mcelsius, devfiles__[local_id]); -} diff --git a/packages/platforms/inventec/x86-64/d7032q28b/onlp/builds/x86_64_inventec_d7032q28b/module/src/x86_64_inventec_d7032q28b_config.c b/packages/platforms/inventec/x86-64/d7032q28b/onlp/builds/x86_64_inventec_d7032q28b/module/src/x86_64_inventec_d7032q28b_config.c deleted file mode 100644 index 5b8c02355..000000000 --- a/packages/platforms/inventec/x86-64/d7032q28b/onlp/builds/x86_64_inventec_d7032q28b/module/src/x86_64_inventec_d7032q28b_config.c +++ /dev/null @@ -1,80 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#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/d7032q28b/onlp/builds/x86_64_inventec_d7032q28b/module/src/x86_64_inventec_d7032q28b_enums.c b/packages/platforms/inventec/x86-64/d7032q28b/onlp/builds/x86_64_inventec_d7032q28b/module/src/x86_64_inventec_d7032q28b_enums.c deleted file mode 100644 index 28b49fa2e..000000000 --- a/packages/platforms/inventec/x86-64/d7032q28b/onlp/builds/x86_64_inventec_d7032q28b/module/src/x86_64_inventec_d7032q28b_enums.c +++ /dev/null @@ -1,10 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#include - -/* <--auto.start.enum(ALL).source> */ -/* */ - diff --git a/packages/platforms/inventec/x86-64/d7032q28b/onlp/builds/x86_64_inventec_d7032q28b/module/src/x86_64_inventec_d7032q28b_int.h b/packages/platforms/inventec/x86-64/d7032q28b/onlp/builds/x86_64_inventec_d7032q28b/module/src/x86_64_inventec_d7032q28b_int.h deleted file mode 100644 index f112cb20a..000000000 --- a/packages/platforms/inventec/x86-64/d7032q28b/onlp/builds/x86_64_inventec_d7032q28b/module/src/x86_64_inventec_d7032q28b_int.h +++ /dev/null @@ -1,12 +0,0 @@ -/**************************************************************************//** - * - * 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/d7032q28b/onlp/builds/x86_64_inventec_d7032q28b/module/src/x86_64_inventec_d7032q28b_log.c b/packages/platforms/inventec/x86-64/d7032q28b/onlp/builds/x86_64_inventec_d7032q28b/module/src/x86_64_inventec_d7032q28b_log.c deleted file mode 100644 index 4418d93fd..000000000 --- a/packages/platforms/inventec/x86-64/d7032q28b/onlp/builds/x86_64_inventec_d7032q28b/module/src/x86_64_inventec_d7032q28b_log.c +++ /dev/null @@ -1,17 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#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/d7032q28b/onlp/builds/x86_64_inventec_d7032q28b/module/src/x86_64_inventec_d7032q28b_log.h b/packages/platforms/inventec/x86-64/d7032q28b/onlp/builds/x86_64_inventec_d7032q28b/module/src/x86_64_inventec_d7032q28b_log.h deleted file mode 100644 index 8b66dc396..000000000 --- a/packages/platforms/inventec/x86-64/d7032q28b/onlp/builds/x86_64_inventec_d7032q28b/module/src/x86_64_inventec_d7032q28b_log.h +++ /dev/null @@ -1,12 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#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/d7032q28b/onlp/builds/x86_64_inventec_d7032q28b/module/src/x86_64_inventec_d7032q28b_module.c b/packages/platforms/inventec/x86-64/d7032q28b/onlp/builds/x86_64_inventec_d7032q28b/module/src/x86_64_inventec_d7032q28b_module.c deleted file mode 100644 index fe89a47ae..000000000 --- a/packages/platforms/inventec/x86-64/d7032q28b/onlp/builds/x86_64_inventec_d7032q28b/module/src/x86_64_inventec_d7032q28b_module.c +++ /dev/null @@ -1,24 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#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/d7032q28b/onlp/builds/x86_64_inventec_d7032q28b/module/src/x86_64_inventec_d7032q28b_ucli.c b/packages/platforms/inventec/x86-64/d7032q28b/onlp/builds/x86_64_inventec_d7032q28b/module/src/x86_64_inventec_d7032q28b_ucli.c deleted file mode 100644 index 4d15b02ca..000000000 --- a/packages/platforms/inventec/x86-64/d7032q28b/onlp/builds/x86_64_inventec_d7032q28b/module/src/x86_64_inventec_d7032q28b_ucli.c +++ /dev/null @@ -1,50 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#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/d7032q28b/platform-config/Makefile b/packages/platforms/inventec/x86-64/d7032q28b/platform-config/Makefile deleted file mode 100644 index 003238cf6..000000000 --- a/packages/platforms/inventec/x86-64/d7032q28b/platform-config/Makefile +++ /dev/null @@ -1 +0,0 @@ -include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/inventec/x86-64/d7032q28b/platform-config/r0/Makefile b/packages/platforms/inventec/x86-64/d7032q28b/platform-config/r0/Makefile deleted file mode 100644 index 003238cf6..000000000 --- a/packages/platforms/inventec/x86-64/d7032q28b/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/inventec/x86-64/d7032q28b/platform-config/r0/PKG.yml b/packages/platforms/inventec/x86-64/d7032q28b/platform-config/r0/PKG.yml deleted file mode 100644 index ac682e0bb..000000000 --- a/packages/platforms/inventec/x86-64/d7032q28b/platform-config/r0/PKG.yml +++ /dev/null @@ -1 +0,0 @@ -!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/d7032q28b/platform-config/r0/src/lib/x86-64-inventec-d7032q28b-r0.yml b/packages/platforms/inventec/x86-64/d7032q28b/platform-config/r0/src/lib/x86-64-inventec-d7032q28b-r0.yml deleted file mode 100644 index 19bcea27d..000000000 --- a/packages/platforms/inventec/x86-64/d7032q28b/platform-config/r0/src/lib/x86-64-inventec-d7032q28b-r0.yml +++ /dev/null @@ -1,31 +0,0 @@ ---- - -###################################################################### -# -# 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/d7032q28b/platform-config/r0/src/python/x86_64_inventec_d7032q28b_r0/__init__.py b/packages/platforms/inventec/x86-64/d7032q28b/platform-config/r0/src/python/x86_64_inventec_d7032q28b_r0/__init__.py deleted file mode 100644 index 628994f29..000000000 --- a/packages/platforms/inventec/x86-64/d7032q28b/platform-config/r0/src/python/x86_64_inventec_d7032q28b_r0/__init__.py +++ /dev/null @@ -1,20 +0,0 @@ -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=".7032.1" - - 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') - self.new_i2c_device('inv_eeprom', 0x53, 0) - self.insmod('inv_eeprom') - self.insmod('swps') - #self.insmod('vpd') - self.insmod('inv_pthread') - return True diff --git a/packages/platforms/inventec/x86-64/d7054q28b/.gitignore b/packages/platforms/inventec/x86-64/d7054q28b/.gitignore deleted file mode 100644 index 2afbde349..000000000 --- a/packages/platforms/inventec/x86-64/d7054q28b/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -*x86*64*inventec*d7054q28b*.mk -onlpdump.mk diff --git a/packages/platforms/inventec/x86-64/d7054q28b/Makefile b/packages/platforms/inventec/x86-64/d7054q28b/Makefile deleted file mode 100644 index 003238cf6..000000000 --- a/packages/platforms/inventec/x86-64/d7054q28b/Makefile +++ /dev/null @@ -1 +0,0 @@ -include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/inventec/x86-64/d7054q28b/modules/Makefile b/packages/platforms/inventec/x86-64/d7054q28b/modules/Makefile deleted file mode 100644 index 003238cf6..000000000 --- a/packages/platforms/inventec/x86-64/d7054q28b/modules/Makefile +++ /dev/null @@ -1 +0,0 @@ -include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/inventec/x86-64/d7054q28b/modules/PKG.yml b/packages/platforms/inventec/x86-64/d7054q28b/modules/PKG.yml deleted file mode 100644 index f23397998..000000000 --- a/packages/platforms/inventec/x86-64/d7054q28b/modules/PKG.yml +++ /dev/null @@ -1 +0,0 @@ -!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/d7054q28b/modules/builds/.gitignore b/packages/platforms/inventec/x86-64/d7054q28b/modules/builds/.gitignore deleted file mode 100644 index a65b41774..000000000 --- a/packages/platforms/inventec/x86-64/d7054q28b/modules/builds/.gitignore +++ /dev/null @@ -1 +0,0 @@ -lib diff --git a/packages/platforms/inventec/x86-64/d7054q28b/modules/builds/Makefile b/packages/platforms/inventec/x86-64/d7054q28b/modules/builds/Makefile deleted file mode 100644 index b49967f24..000000000 --- a/packages/platforms/inventec/x86-64/d7054q28b/modules/builds/Makefile +++ /dev/null @@ -1,6 +0,0 @@ -KERNELS := onl-kernel-3.16-lts-x86-64-all:amd64 -KMODULES := src -VENDOR := inventec -BASENAME := x86-64-inventec-d7054q28b -ARCH := x86_64 -include $(ONL)/make/kmodule.mk diff --git a/packages/platforms/inventec/x86-64/d7054q28b/modules/builds/src/Makefile b/packages/platforms/inventec/x86-64/d7054q28b/modules/builds/src/Makefile deleted file mode 100644 index c3bb63029..000000000 --- a/packages/platforms/inventec/x86-64/d7054q28b/modules/builds/src/Makefile +++ /dev/null @@ -1,8 +0,0 @@ -obj-m += inv_platform.o -obj-m += inv_cpld.o -obj-m += inv_psoc.o -obj-m += swps.o -swps-objs := inv_swps.o io_expander.o transceiver.o inv_mux.o -obj-m += vpd.o -vpd-objs := inv_vpd.o onie_tlvinfo.o -obj-m += inv_pthread.o diff --git a/packages/platforms/inventec/x86-64/d7054q28b/modules/builds/src/inv_cpld.c b/packages/platforms/inventec/x86-64/d7054q28b/modules/builds/src/inv_cpld.c deleted file mode 100644 index f605a9330..000000000 --- a/packages/platforms/inventec/x86-64/d7054q28b/modules/builds/src/inv_cpld.c +++ /dev/null @@ -1,538 +0,0 @@ -/* - * 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 "inv_pthread.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 struct device *cpld_led_client_dev = NULL; - -/*-----------------------------------------------------------------------*/ - -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 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 == CPLD_DEV_LED_GRN_INDEX)?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; -} - -ssize_t cpld_show_led(char *buf, int index) -{ - u32 status; - struct i2c_client *client = NULL; - struct cpld_data *data = NULL; - u8 byte; - int shift = (index == CPLD_DEV_LED_GRN_INDEX)?3:0; - - if (!cpld_led_client_dev) { - return 0; - } - - client = to_i2c_client(cpld_led_client_dev); - data = i2c_get_clientdata(client); - - 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); -} -EXPORT_SYMBOL(cpld_show_led); - -ssize_t cpld_set_led(const char *buf, size_t count, int index) -{ - struct i2c_client *client = NULL; - struct cpld_data *data = NULL; - - u8 temp = simple_strtol(buf, NULL, 16); - u8 byte; - int shift = (index == CPLD_DEV_LED_GRN_INDEX)?3:0; - - if (!cpld_led_client_dev) { - return 0; - } - - client = to_i2c_client(cpld_led_client_dev); - data = i2c_get_clientdata(client); - - 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; -} -EXPORT_SYMBOL(cpld_set_led); - -ssize_t cpld_show_ctl(char *buf) -{ - u32 status; - struct i2c_client *client = NULL; - struct cpld_data *data = NULL; - u8 b[1]; - - if (!cpld_led_client_dev) { - return 0; - } - - client = to_i2c_client(cpld_led_client_dev); - data = i2c_get_clientdata(client); - - 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); -} -EXPORT_SYMBOL(cpld_show_ctl); - -ssize_t cpld_set_ctl(const char *buf, size_t count) -{ - struct i2c_client *client = NULL; - struct cpld_data *data = NULL; - u8 byte; - u8 temp = simple_strtol(buf, NULL, 10); - - if (!cpld_led_client_dev) { - return 0; - } - - client = to_i2c_client(cpld_led_client_dev); - data = i2c_get_clientdata(client); - - 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; -} -EXPORT_SYMBOL(cpld_set_ctl); - -/* -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, CPLD_DEV_LED_GRN_INDEX); -static SENSOR_DEVICE_ATTR(red_led, S_IWUSR|S_IRUGO, show_led, set_led, CPLD_DEV_LED_RED_INDEX); - -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; - - 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); - - cpld_led_client_dev = &client->dev; - - return 0; - -exit_remove: - sysfs_remove_group(&client->dev.kobj, &cpld_group); -exit_free: - i2c_set_clientdata(client, NULL); - kfree(data); - cpld_led_client_dev = NULL; - 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); - cpld_led_client_dev = NULL; - 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/d7054q28b/modules/builds/src/inv_mux.c b/packages/platforms/inventec/x86-64/d7054q28b/modules/builds/src/inv_mux.c deleted file mode 100644 index a0f5ce34b..000000000 --- a/packages/platforms/inventec/x86-64/d7054q28b/modules/builds/src/inv_mux.c +++ /dev/null @@ -1,281 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include "io_expander.h" -#include "inv_mux.h" - -static struct mux_obj_s *mux_head_p = NULL; - - -/* ========== MUX object functions ========== - */ -int -_common_force_pull_gpio(int mem_addr, - int input, - int bit_offset){ - - unsigned int val = 0; - unsigned int targ = 0; - - /* Get current value */ - val = inl(mem_addr); - if (val == 0) { - SWPS_ERR("%s: inl:%d fail!\n", __func__, val); - return -1; - } - /* Count target value */ - switch (input) { - case 0: /* Pull Low */ - targ = (val & (~(1 << bit_offset))); - break; - case 1: /* Pull high */ - targ = (val | (1 << bit_offset)); - break; - default: - SWPS_ERR("%s: input state:%d incorrect!\n", - __func__, input); - return -1; - } - /* Setup gpio */ - outl(targ, mem_addr); - if (targ != inl(mem_addr)){ - SWPS_ERR("%s: outl:%d fail!\n", __func__, targ); - return -1; - } - SWPS_DEBUG("%s: done.\n", __func__); - return 0; -} - - -int -rangeley_force_pull_high(struct mux_obj_s *self){ - SWPS_ERR("%s: not ready!\n", __func__); - return -1; -} - - -int -rangeley_force_pull_low(struct mux_obj_s *self){ - SWPS_ERR("%s: not ready!\n", __func__); - return -1; -} - - -int -hedera_force_pull_high(struct mux_obj_s *self){ - return _common_force_pull_gpio(MUX_RST_MEM_ADDR_HEDERA, 1, 5); -} - - -int -hedera_force_pull_low(struct mux_obj_s *self){ - return _common_force_pull_gpio(MUX_RST_MEM_ADDR_HEDERA, 0, 5); -} - - -int -normal_gpio_pull_high(struct mux_obj_s *self){ - return gpio_direction_output(self->gpio_num, 1); -} - - -int -normal_gpio_pull_low(struct mux_obj_s *self){ - return gpio_direction_output(self->gpio_num, 0); -} - - -int -pca9548_reset_mux_all(struct mux_obj_s *self){ - /* [Note] Power-on reset (PCA9548A-NXP) - * When power is applied to VDD, an internal Power-On Reset (POR) - * holds the PCA9548A in a reset condition until VDD has reached - * VPOR. At this point, the reset condition is released and the - * PCA9548A register and I2C-bus state machine are initialized to - * their default states (all zeroes) causing all the channels to - * be deselected. Thereafter, VDD must be lowered below 0.2 V for - * at least 5 us in order to reset the device. - */ - if (self->_pull_low(self) < 0) { - SWPS_ERR("%s: _pull_low fail!\n", __func__); - return -1; - } - mdelay(MUX_RST_WAIT_MS); - if (self->_pull_high(self) < 0) { - SWPS_ERR("%s: _pull_high fail!\n", __func__); - return -1; - } - mdelay(MUX_RST_WAIT_MS); - return 0; -} - - -int -common_reset_mux_all(struct mux_obj_s *self){ - SWPS_ERR("%s: not ready!\n", __func__); - return -1; -} - - -int -init_gpio_4_force(struct mux_obj_s *self){ - return 0; -} - - -int -init_gpio_4_normal(struct mux_obj_s *self){ - - int err = 0; - - if (!gpio_is_valid(self->gpio_num)) { - SWPS_ERR("%s: GIPO:%d isn't valid\n", __func__, self->gpio_num); - return -1; - } - err = gpio_request(self->gpio_num, MUX_GPIO_LABEL); - if (err < 0) { - SWPS_ERR("%s: gpio_request fail :%d :%d\n", - __func__, err, self->gpio_num); - return -1; - } - SWPS_DEBUG("%s: gpio_request:%d ok.\n", __func__, self->gpio_num); - return 0; -} - - -static int -_setup_muxctl_cb(struct mux_obj_s *self, - unsigned gpio){ - - char *mod_dsc = "ERR"; - - switch (gpio) { - case MUX_RST_GPIO_FORCE_RANGELEY: - self->gpio_num = gpio; - self->_pull_low = rangeley_force_pull_low; - self->_pull_high = rangeley_force_pull_high; - self->_init = init_gpio_4_force; - self->reset = pca9548_reset_mux_all; - mod_dsc = "Rangeley force mode"; - goto ok_setup_muxctl_cb; - - case MUX_RST_GPIO_FORCE_HEDERA: - self->gpio_num = gpio; - self->_pull_low = hedera_force_pull_low; - self->_pull_high = hedera_force_pull_high; - self->_init = init_gpio_4_force; - self->reset = pca9548_reset_mux_all; - mod_dsc = "Hedera force mode"; - goto ok_setup_muxctl_cb; - - case MUX_RST_GPIO_48_PAC9548: - self->gpio_num = gpio; - self->_pull_low = normal_gpio_pull_low; - self->_pull_high = normal_gpio_pull_high; - self->_init = init_gpio_4_normal; - self->reset = pca9548_reset_mux_all; - mod_dsc = "Normal mode :48"; - goto ok_setup_muxctl_cb; - - case MUX_RST_GPIO_69_PAC9548: - self->gpio_num = gpio; - self->_pull_low = normal_gpio_pull_low; - self->_pull_high = normal_gpio_pull_high; - self->_init = init_gpio_4_normal; - self->reset = pca9548_reset_mux_all; - mod_dsc = "Normal mode :69"; - goto ok_setup_muxctl_cb; - - default: - break; - } - SWPS_ERR("%s: Unexpected GPIO:%d\n", __func__, gpio); - return -1; - -ok_setup_muxctl_cb: - SWPS_INFO("muxctl: %s.\n", mod_dsc); - return 0; -} - - -/* ========== MUX public functions ========== - */ -void -clean_mux_gpio(void){ - - if (!mux_head_p) { - SWPS_DEBUG("%s: mux_head_p is NULL\n", __func__); - return; - } - if (gpio_is_valid(mux_head_p->gpio_num)) { - gpio_free(mux_head_p->gpio_num); - } - kfree(mux_head_p); - mux_head_p = NULL; - SWPS_DEBUG("%s: done.\n", __func__); -} -EXPORT_SYMBOL(clean_mux_gpio); - - -int -reset_mux_gpio(void){ - - if (!mux_head_p) { - SWPS_ERR("%s: MUX ctl object doesn't exist!\n", __func__); - return -1; - } - if (mux_head_p->reset(mux_head_p) < 0){ - SWPS_ERR("%s: reset fail!\n", __func__); - return -1; - } - return 0; -} -EXPORT_SYMBOL(reset_mux_gpio); - - -int -init_mux_gpio(unsigned gpio){ - - /* Create MUX control object */ - if (mux_head_p) { - SWPS_DEBUG("%s: mux_head_p is not NULL!\n", __func__); - clean_mux_gpio(); - } - /* Currently, it is using single muxctl architecture. - * In the future, it may use the multi-muxctl if HW add new features. - * (Ex: Port power-status control) - */ - mux_head_p = kzalloc(sizeof(struct mux_obj_s), GFP_KERNEL); - if (!mux_head_p) { - SWPS_ERR("%s: kzalloc fail!\n", __func__); - return -1; - } - /* Initial MUX controller */ - if (_setup_muxctl_cb(mux_head_p, gpio) < 0){ - SWPS_ERR("%s: _setup_muxctl_cb fail!\n", __func__); - return -1; - } - if (mux_head_p->_init(mux_head_p) < 0) { - SWPS_ERR("%s: init() fail\n", __func__); - goto err_init_mux_gpio; - } - /* Setup default value */ - if (mux_head_p->_pull_high(mux_head_p) < 0) { - SWPS_ERR("%s: setup default fail!\n", __func__); - goto err_init_mux_gpio; - } - return 0; - -err_init_mux_gpio: - clean_mux_gpio(); - return -1; -} -EXPORT_SYMBOL(init_mux_gpio); - - - -MODULE_LICENSE("GPL"); - diff --git a/packages/platforms/inventec/x86-64/d7054q28b/modules/builds/src/inv_mux.h b/packages/platforms/inventec/x86-64/d7054q28b/modules/builds/src/inv_mux.h deleted file mode 100644 index 429754a8c..000000000 --- a/packages/platforms/inventec/x86-64/d7054q28b/modules/builds/src/inv_mux.h +++ /dev/null @@ -1,36 +0,0 @@ -#ifndef INV_MUX_H -#define INV_MUX_H - - -/* MUX basic information */ -#define MUX_GPIO_LABEL "SWPS_RST_MUX" - -/* MUX reset GPIO define */ -#define MUX_RST_GPIO_FORCE (30100) -#define MUX_RST_GPIO_FORCE_RANGELEY (30101) -#define MUX_RST_GPIO_FORCE_HEDERA (30102) -#define MUX_RST_GPIO_48_PAC9548 (48) -#define MUX_RST_GPIO_69_PAC9548 (69) - -/* MUX relate value define */ -#define MUX_RST_WAIT_MS (1) -#define MUX_RST_MEM_ADDR_RANGELEY (0) // TBD -#define MUX_RST_MEM_ADDR_HEDERA (0x548) - -struct mux_obj_s { - unsigned gpio_num; - int (*_pull_high)(struct mux_obj_s *self); - int (*_pull_low)(struct mux_obj_s *self); - int (*_init)(struct mux_obj_s *self); - int (*reset)(struct mux_obj_s *self); -}; - - -void clean_mux_gpio(void); -int reset_mux_gpio(void); -int init_mux_gpio(unsigned gpio); - - -#endif /* INV_MUX_H */ - - diff --git a/packages/platforms/inventec/x86-64/d7054q28b/modules/builds/src/inv_platform.c b/packages/platforms/inventec/x86-64/d7054q28b/modules/builds/src/inv_platform.c deleted file mode 100644 index 8f2569c29..000000000 --- a/packages/platforms/inventec/x86-64/d7054q28b/modules/builds/src/inv_platform.c +++ /dev/null @@ -1,177 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include - -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),}, -}; - -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 - -}; - -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__); - - for(i=0; i -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#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 - -static struct device *psoc_led_client_dev = NULL; - -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 */ -#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; - 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; - - if (rv < 0) { - mutex_unlock(&ipmi_mutex); - return rv; - } - - addr.addr_type = IPMI_SYSTEM_INTERFACE_ADDR_TYPE; - addr.channel = IPMI_BMC_CHANNEL; - addr.lun = 0; - - memcpy(_data,data,data_length); - msg.netfn = NetFn; - msg.cmd = cmd; - msg.data = _data; - msg.data_len = data_length; - - init_completion(&comp); - rv = ipmi_request_supply_msgs(ipmi_mh_user, (struct ipmi_addr*)&addr, 0,&msg, &comp, &halt_smi_msg, &halt_recv_msg, 0); - - if (rv) { - mutex_unlock(&ipmi_mutex); - return -6; - } - - wait_for_completion(&comp); - - rv=halt_recv_msg.msg.data[0]; - if(rv==0) { - *result_length=halt_recv_msg.msg.data_len-1; - memcpy(result,&halt_recv_msg.msg.data[1],halt_recv_msg.msg.data_len-1); - } - ipmi_free_recv_msg(&halt_recv_msg); - mutex_unlock(&ipmi_mutex); - return rv; -} -#endif - -static ssize_t psoc_i2c_read(struct i2c_client *client, u8 *buf, u8 offset, size_t count) -{ -#if USE_SMBUS -if (USE_IPMI==0) -{ - 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 -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 -} - -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); -} - -static ssize_t psoc_show_psu_st(char *buf, int psu_index) -{ - u32 status; - struct i2c_client *client = NULL; - struct psoc_data *data = NULL; - u8 byte; - int shift = (psu_index == 0)?3:0; - - if (!psoc_led_client_dev) { - return 0; - } - - client = to_i2c_client(psoc_led_client_dev); - data = i2c_get_clientdata(client); - - 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); -} - -ssize_t psoc_show_psu_state(char *buf, int index) -{ - return psoc_show_psu_st(buf, index); -} -EXPORT_SYMBOL(psoc_show_psu_state); - -/*-----------------------------------------------------------------------*/ - -/* 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 psoc_show_rpm(char *buf, int fan_index) -{ - int status; - struct i2c_client *client = NULL; - struct psoc_data *data = NULL; - u8 offset = fan_index*2 + RPM_OFFSET; - - if (!psoc_led_client_dev) { - return 0; - } - - client = to_i2c_client(psoc_led_client_dev); - data = i2c_get_clientdata(client); - - mutex_lock(&data->update_lock); - - status = psoc_read16(client, offset); - - mutex_unlock(&data->update_lock); - - return sprintf(buf, "%d\n", - status); -} - -ssize_t psoc_show_fan_input(char *buf, int index) -{ - return psoc_show_rpm(buf, index); -} -EXPORT_SYMBOL(psoc_show_fan_input); - -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 ); -} - -ssize_t psoc_show_value8(char *buf, int offset) -{ - int status; - struct i2c_client *client = NULL; - struct psoc_data *data = NULL; - - if (!psoc_led_client_dev) { - return 0; - } - - client = to_i2c_client(psoc_led_client_dev); - data = i2c_get_clientdata(client); - - mutex_lock(&data->update_lock); - - status = psoc_read8(client, offset); - - mutex_unlock(&data->update_lock); - - return sprintf(buf, "0x%02X\n", status ); -} - -static char prev_fan_state[8] = { 0 }; - -ssize_t psoc_show_fan_state(char *buf) -{ - int i; - int rv = psoc_show_value8(buf, FAN_GPI_OFFSET); - for (i = 0; i < 3; i++) { - if (strncmp(prev_fan_state, buf, 4) == 0) { - return rv; - } - msleep(500); - rv = psoc_show_value8(buf, FAN_GPI_OFFSET); - } - strcpy(prev_fan_state, buf); - return rv; -} -EXPORT_SYMBOL(psoc_show_fan_state); - -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 ssize_t psoc_show_psu_psoc(char *buf, int psu_index, char *attr_name) -{ - u16 status; - struct i2c_client *client = NULL; - struct psoc_data *data = NULL; - u8 offset = psu_index + PSU_INFO_OFFSET; - - if (!psoc_led_client_dev) { - return 0; - } - - client = to_i2c_client(psoc_led_client_dev); - data = i2c_get_clientdata(client); - - 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_name, "vout")? 1:0 )); -} - -ssize_t psoc_show_psu_vin(char *buf, int index) -{ - return psoc_show_psu_psoc(buf, index, "vin"); -} -EXPORT_SYMBOL(psoc_show_psu_vin); - -ssize_t psoc_show_diag(char *buf) -{ - u16 status; - struct i2c_client *client = NULL; - struct psoc_data *data = NULL; - u8 diag_flag = 0; - - if (!psoc_led_client_dev) { - return 0; - } - - client = to_i2c_client(psoc_led_client_dev); - data = i2c_get_clientdata(client); - - 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); -} -EXPORT_SYMBOL(psoc_show_diag); - -ssize_t psoc_set_diag(const char *buf, size_t count) -{ - struct i2c_client *client = NULL; - struct psoc_data *data = NULL; - u8 value = 0; - u8 diag = simple_strtol(buf, NULL, 10); - - if (!psoc_led_client_dev) { - return 0; - } - - client = to_i2c_client(psoc_led_client_dev); - data = i2c_get_clientdata(client); - - 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; -} -EXPORT_SYMBOL(psoc_set_diag); - - -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); - - psoc_led_client_dev = &client->dev; - - return 0; - -exit_remove: - sysfs_remove_group(&client->dev.kobj, &psoc_group); -exit_free: - i2c_set_clientdata(client, NULL); - kfree(data); - psoc_led_client_dev = NULL; - 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); - psoc_led_client_dev = NULL; - 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/d7054q28b/modules/builds/src/inv_pthread.c b/packages/platforms/inventec/x86-64/d7054q28b/modules/builds/src/inv_pthread.c deleted file mode 100644 index f3e08b579..000000000 --- a/packages/platforms/inventec/x86-64/d7054q28b/modules/builds/src/inv_pthread.c +++ /dev/null @@ -1,930 +0,0 @@ -/***************************** - Cypress (d7054q28b) platform -******************************/ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "inv_pthread.h" - -#define INV_PTHREAD_KERNEL_MODULE - -#define SHOW_ATTR_WARNING ("N/A") -#define SHOW_ATTR_NOTPRINT ("Not Available") -#define SHOW_ATTR_NOTSUPPORT ("Not Support") - -#define INV_HWMID_MAX (10) -#define INV_HWMID_INIT (-1) - -/*access userspace data to kernel space*/ -#define ACC_R (0) -#define ACC_W (1) - -#define MAX_PATH_SIZE (64) -#define MIN_ACC_SIZE (32) -#define MAX_ACC_SIZE (256) - -/* - * LED definitions - */ -#define STATUS_LED_MODE_AUTO (0) -#define STATUS_LED_MODE_DIAG (1) -#define STATUS_LED_MODE_MANU (2) -#define STATUS_LED_MODE_ERR (-1) - -#define STATUS_LED_GRN0 (10) // 0 - 000: off -#define STATUS_LED_GRN1 (11) // 1 - 001: 0.5hz -#define STATUS_LED_GRN2 (12) // 2 - 010: 1 hz -#define STATUS_LED_GRN3 (13) // 3 - 011: 2 hz -#define STATUS_LED_GRN7 (17) // 7 - 111: on -#define STATUS_LED_RED0 (20) // 0 - 000: off -#define STATUS_LED_RED1 (21) // 1 - 001: 0.5hz -#define STATUS_LED_RED2 (22) // 2 - 010: 1 hz -#define STATUS_LED_RED3 (23) // 3 - 011: 2 hz -#define STATUS_LED_RED7 (27) // 7 - 111: on -#define STATUS_LED_INVALID (0) // Invalid - -static struct mutex pthread_mutex; - -ssize_t status_led_grn(const char *freq); -ssize_t status_led_red(const char *freq); -ssize_t status_led_diag_mode_enable(void); -ssize_t status_led_diag_mode_disable(void); -int status_led_check_color(void); -int status_led_check_diag_mode(void); - -#if 1 -/* For timestamps in SYSFS_LOG */ -#define SYSFS_LOG printk -#else -//#define SYSFS_LOG(fmt, args...) printk(KERN_WARNING "[SYSFS] %s/%d: " fmt, __func__, __LINE__, ##args) -#define SYSFS_LOG(fmt, args...) printk(KERN_WARNING "[p_thread] " fmt, ##args) -#endif - - -/* inventec_class *********************************/ -static struct kobject *status_kobj; -static struct kset *status_kset; - -#if 0 -int inventec_strtol(const char *sbufp, char **endp, unsigned int base) -{ - char *endptr; - int value = simple_strtol(sbufp, &endptr, base); - if (value == 0 && sbufp == endptr) { - *endp = NULL; - return value; - } - *endp = (char*)1; - return value; -} -#endif - -int inventec_singlechar_to_int(const char c) -{ - if ((c >= '0') && (c <= '9')) { - return (c - '0'); - } - else - if ((c >= 'a') && (c <= 'f')) { - return (c - 'a' + 10); - } - else - if ((c >= 'A') && (c <= 'F')) { - return (c - 'A' + 10); - } - return -1; -} - -/* fan device *************************************/ -#define FAN_STATE_NORMAL "normal" -#define FAN_STATE_FAULTY "faulty" -#define FAN_STATE_UNINSTALLED "uninstalled" -#define FAN_STATE_UNKNOW "unknown state" -#define FAN_STATE_INVALID "Invalid state value" -#define FAN_STATE_READ_ERROR "state read error" - -#define FAN_LOG_UNINSTALLED "removed" -#define FAN_LOG_NORMAL "inserted" - -//#define FAN_STATE_BIT_NORMAL 0 -#define FAN_STATE_BIT_FAULTY 0 -#define FAN_STATE_BIT_UNINSTALLED 1 -#define FAN_STATE_BIT_UNKNOW 2 -#define FAN_STATE_BIT_INVALID 3 -#define FAN_STATE_BIT_READ_ERROR 4 - -static ssize_t psoc_show_fan1_input(char *buf) -{ - return psoc_show_fan_input(buf, 1); -} - -static ssize_t psoc_show_fan2_input(char *buf) -{ - return psoc_show_fan_input(buf, 2); -} - -static ssize_t psoc_show_fan3_input(char *buf) -{ - return psoc_show_fan_input(buf, 3); -} - -static ssize_t psoc_show_fan4_input(char *buf) -{ - return psoc_show_fan_input(buf, 4); -} - -static ssize_t psoc_show_fan5_input(char *buf) -{ - return psoc_show_fan_input(buf, 5); -} - -static ssize_t psoc_show_fan6_input(char *buf) -{ - return psoc_show_fan_input(buf, 6); -} - -static ssize_t psoc_show_fan7_input(char *buf) -{ - return psoc_show_fan_input(buf, 7); -} - -static ssize_t psoc_show_fan8_input(char *buf) -{ - return psoc_show_fan_input(buf, 8); -} - -static struct fans_tbl_s { - char *fan_name; - ssize_t (*fan_front)(char *); - ssize_t (*fan_rear)(char *); - unsigned int fan_state; -} fans_tbl[] = { - {"fan1", psoc_show_fan1_input, - psoc_show_fan2_input, 0}, - {"fan2", psoc_show_fan3_input, - psoc_show_fan4_input, 0}, - {"fan3", psoc_show_fan5_input, - psoc_show_fan6_input, 0}, - {"fan4", psoc_show_fan7_input, - psoc_show_fan8_input, 0}, -}; -#define FAN_TBL_TOTAL ( sizeof(fans_tbl)/ sizeof(const struct fans_tbl_s) ) - -#define FAN_STATE_CHECK(i,b) (fans_tbl[i].fan_state & (1<inv_dev_attrp, PSU_ATTR_VOLTIN, PSU_ATTR_VOLTIN_LEN) == 0) { - invwirep = psu_get_show_function(PSU_ATTR_VOLTIN, psu_dev_group[i].psu_name, NULL); - if (invwirep == NULL) { - printk(KERN_DEBUG "[p_thread] Invalid psuname: %s\n", psu_dev_group[i].psu_name); - continue; - } - if (invwirep(volt) <= 0) { - printk(KERN_DEBUG "[p_thread] Read %s failed\n", psu_dev_group[i].psu_name); - continue; - } - else { - voltin = simple_strtol(&volt[0], NULL, 10); - printk(KERN_DEBUG "[p_thread] Read %s %s = %u\n",psu_dev_group[i].psu_name,volt,voltin); - if (voltin > psu_voltin) { - psu_voltin = voltin; - } - } - } - } - } - - SYSFS_LOG("[p_thread] PSU voltin = %u\n", psu_voltin); -} - -#define PSU_ATTR_STATE ("state") -#define PSU_ATTR_STATE_LEN (5) - -/* psus_control() by inv_thread */ -int psus_control(int log_only) -{ - char state[MIN_ACC_SIZE]; - psu_dev_t *devnamep = NULL; - ssize_t (*invwirep)(char *buf) = NULL; - char *psu_statep = NULL; - int i, j, flag = 0; - - for (i = 0; i < PSU_DEV_GROUP_TOTAL; i++) { - devnamep = psu_dev_group[i].psu_dev_namep; - for (j = 0; j < psu_dev_group[i].psu_dev_total; j++, devnamep++) { - if (strncmp(devnamep->inv_dev_attrp, PSU_ATTR_STATE, PSU_ATTR_STATE_LEN) == 0) { - invwirep = psu_get_show_function(PSU_ATTR_STATE, psu_dev_group[i].psu_name, &psu_statep); - if (invwirep == NULL) { - printk(KERN_DEBUG "[p_thread] Invalid psuname: %s\n", psu_dev_group[i].psu_name); - continue; - } - if (invwirep(state) <= 0) { - printk(KERN_DEBUG "[p_thread] Read %s failed\n", psu_dev_group[i].psu_name); - if (strncmp(psu_statep, PSU_STATE_ERROR, strlen(PSU_STATE_ERROR)) != 0) { - strcpy(psu_statep, PSU_STATE_ERROR); - SYSFS_LOG("[p_thread] %s: %s\n",psu_dev_group[i].psu_name,PSU_STATE_ERROR); - } - flag = 1; - } - else - if (strstr(state, "normal")) { - if (strncmp(psu_statep, state, strlen(state)) != 0) { - strcpy(psu_statep, state); - SYSFS_LOG("[p_thread] %s: %s\n",psu_dev_group[i].psu_name,state); - } - } - else - if (psu_voltin > PSU_VOLTIN_ACDC) { /* AC PSUS */ - if (strncmp(psu_statep, state, strlen(state)) != 0) { - strcpy(psu_statep, state); - SYSFS_LOG("[p_thread] %s: %s\n",psu_dev_group[i].psu_name,state); - } - flag = 1; - } - else { /* DC PSUS */ - if (strncmp(psu_statep, PSU_STATE_CHECKPSU, PSU_STATE_LEN_CHECKPSU) != 0) { - strcpy(psu_statep, PSU_STATE_CHECKPSU); - SYSFS_LOG("[p_thread] %s: %s\n",psu_dev_group[i].psu_name,PSU_STATE_CHECKPSU); - } - flag = 1; - } - } - } - } - - if (log_only) { - return 0; - } - - //SYSFS_LOG("[p_thread] RYU: %s: flag = %d\n",psu_wire_tbl[i].psu_name,flag); - if (flag == 1) { - status_led_grn("2"); - return 1; - } - return 0; -} - -/* End of psuinfo_device */ - -/* led device *************************************/ - -/* return 0/off 1/green 2/red */ -int -status_led_check_color(void) -{ - char tmpbuf[MIN_ACC_SIZE]; - int ret = STATUS_LED_INVALID; - - if (cpld_show_led(&tmpbuf[0], CPLD_DEV_LED_GRN_INDEX) > 0) { - if (tmpbuf[0] == '0') { - ret = STATUS_LED_GRN0; - } - if (tmpbuf[0] == '1') { - ret = STATUS_LED_GRN1; - } - if (tmpbuf[0] == '2') { - ret = STATUS_LED_GRN2; - } - if (tmpbuf[0] == '3') { - ret = STATUS_LED_GRN3; - } - if (tmpbuf[0] == '7') { - ret = STATUS_LED_GRN7; - } - return ret; - } - - if (cpld_show_led(&tmpbuf[0], CPLD_DEV_LED_RED_INDEX) > 0) { - if (tmpbuf[0] == '0') { - ret = STATUS_LED_RED0; - } - if (tmpbuf[0] == '1') { - ret = STATUS_LED_RED1; - } - if (tmpbuf[0] == '2') { - ret = STATUS_LED_RED2; - } - if (tmpbuf[0] == '3') { - ret = STATUS_LED_RED3; - } - if (tmpbuf[0] == '7') { - ret = STATUS_LED_RED7; - } - return ret; - } - return ret; -} - -/* - * Store attr Section - */ -ssize_t status_led_diag_mode_enable(void) -{ - char tmp[MIN_ACC_SIZE]; - ssize_t ret; - - ret = psoc_show_diag(&tmp[0]); - if (ret <= 0) { - return ret; - } - - if (tmp[0] == '0') { - ret = psoc_set_diag("1", 1); - if (ret < 0) { - return ret; - } - - ret = cpld_set_ctl("1", 1); - if (ret < 0) { - return ret; - } - } - - return ret; -} - -ssize_t status_led_diag_mode_disable(void) -{ - char tmp[MIN_ACC_SIZE]; - ssize_t ret; - - ret = psoc_show_diag(&tmp[0]); - if (ret <= 0) { - return ret; - } - - if (tmp[0] == '1') { - ret = psoc_set_diag("0", 1); - if (ret < 0) { - return 1; - } - - ret = cpld_set_ctl("1", 1); - if (ret < 0) { - return 1; - } - } - return 1; -} - -ssize_t -status_led_red(const char *freq) -{ - char buf[MIN_ACC_SIZE]; - ssize_t ret; - - ret = cpld_show_led(buf, CPLD_DEV_LED_RED_INDEX); - if (ret < 0 || buf[0] == freq[0]) { - return ret; - } - - ret = cpld_set_led("0", 1, CPLD_DEV_LED_GRN_INDEX); - if (ret < 0) { - return ret; - } - ret = cpld_set_led(freq, strlen(freq), CPLD_DEV_LED_RED_INDEX); - if (ret < 0) { - return ret; - } - if ((ret = status_led_diag_mode_enable()) <= 0) { - return ret; - } - ssleep(1); - if ((ret = status_led_diag_mode_disable()) <= 0) { - return ret; - } - return ret; -} - -ssize_t -status_led_grn(const char *freq) -{ - char buf[MIN_ACC_SIZE]; - ssize_t ret; - - ret = cpld_show_led(buf, CPLD_DEV_LED_GRN_INDEX); - if (ret < 0 || buf[0] == freq[0]) { - return ret; - } - - ret = cpld_set_led("0", 1, CPLD_DEV_LED_RED_INDEX); - if (ret < 0) { - return ret; - } - ssleep(1); - ret = cpld_set_led(freq, strlen(freq), CPLD_DEV_LED_GRN_INDEX); - if (ret < 0) { - return ret; - } - if ((ret = status_led_diag_mode_enable()) <= 0) { - return ret; - } - ssleep(1); - if ((ret = status_led_diag_mode_disable()) <= 0) { - return ret; - } - return ret; -} - -int status_led_check_diag_mode(void) -{ - char tmp[MIN_ACC_SIZE]; - ssize_t ret; - - ret = psoc_show_diag(&tmp[0]); - if (ret <= 0) { - return ret; - } - - if (tmp[0] == '1') { - return STATUS_LED_MODE_DIAG; - } - - if (tmp[0] == '0') { - return STATUS_LED_MODE_AUTO; - } - - return -1; -} - -/* End of ledinfo_device */ - -/**************************************************/ -/* From system_device */ -static int inv_pthread_control = 1; - -int thread_control(void) -{ - return inv_pthread_control; -} - -void thread_control_set(int val) -{ - inv_pthread_control = val; -} -/* End system_device */ - -#define THREAD_SLEEP_MINS (3) -#define THREAD_DELAY_MINS (THREAD_SLEEP_MINS + THREAD_SLEEP_MINS + 1) - -static struct task_struct *thread_st; -static int thread_data; - -// Function executed by kernel thread -static int thread_fn(void *unused) -{ - mutex_init(&pthread_mutex); - - ssleep(THREAD_DELAY_MINS); - - /* Default status init */ - mutex_lock(&pthread_mutex); - status_led_grn("7"); - mutex_unlock(&pthread_mutex); - - psu_get_voltin(); - - /* Delay for guarantee HW ready */ - ssleep(THREAD_DELAY_MINS); - - while (1) - { - mutex_unlock(&pthread_mutex); - ssleep(THREAD_SLEEP_MINS); - - if (thread_control() == 0) { - printk(KERN_INFO "[p_thread] %s/%d: Thread Stop by inv_pthread control\n",__func__,__LINE__); - break; - } - - mutex_lock(&pthread_mutex); - if (status_led_check_diag_mode() == STATUS_LED_MODE_MANU) { - /* status led in change color/freq mode, higher priority. Ignore fans sttaus */ - continue; - } - -#if 0 - switch_temp_update(); -#endif - - if (fans_control() > 0) { - psus_control(1); - continue; - } - else - if (psus_control(0) > 0) { - continue; - } - - if (status_led_check_color() != STATUS_LED_GRN7) { /* status led red, change it to green */ - status_led_grn("7"); - } - } - - do_exit(0); - printk(KERN_INFO "[p_thread] %s/%d: Thread Stopped\n",__func__,__LINE__); - return 0; -} - - -static ssize_t s_show(struct kobject *kobj, struct attribute *attr, char *buf) -{ - int fan_absence; - size_t count = 0; - - fan_absence = fans_control(); - count += sprintf(&buf[count], "%d\n", fan_absence); - return count; -} - -static ssize_t s_store(struct kobject *kobj, struct attribute *attr, const char *buf, size_t count) -{ - return count; -} - -static struct attribute status_att = { - .name = "fan_absence", - .mode = 0777, -}; - -static const struct sysfs_ops status_ops = { - .show = s_show, - .store = s_store, -}; - -static struct kobj_type status_ktype = { - .sysfs_ops = &status_ops, -}; - - -static int __init inv_pthread_init(void) -{ - int retval; - - status_kobj = kzalloc(sizeof(*status_kobj), GFP_KERNEL); - if(!status_kobj) - return PTR_ERR(status_kobj); - - status_kset = kset_create_and_add("platform_status", NULL, kernel_kobj); - if(!status_kset) - return -1; - - status_kobj->kset = status_kset; - - retval = kobject_init_and_add(status_kobj, &status_ktype, NULL, "fan"); - if(retval) - return retval; - - retval = sysfs_create_file(status_kobj, &status_att); - - thread_control_set(1); - - printk(KERN_INFO "[p_thread] %s/%d: Creating Thread\n",__func__,__LINE__); - //Create the kernel thread with name 'inv_pthread' - thread_st = kthread_run(thread_fn, (void*)&thread_data, "inv_pthread"); - if (thread_st) - printk(KERN_INFO "[p_thread] inv_pthread Created successfully\n"); - else - printk(KERN_ERR "[p_thread] inv_pthread creation failed\n"); - - return retval; -} - -static void __exit inv_pthread_exit(void) -{ - thread_control_set(0); - /* Delay for guarantee thread exit */ - ssleep(THREAD_DELAY_MINS); - - sysfs_remove_file(status_kobj, &status_att); - kset_unregister(status_kset); - kobject_del(status_kobj); - - printk(KERN_INFO "[p_thread] inv_pthread cleaning Up\n"); -} - -module_init(inv_pthread_init); -module_exit(inv_pthread_exit); - -MODULE_AUTHOR("Robert "); -MODULE_DESCRIPTION("Inventec Platform Management Thread"); -MODULE_VERSION("version 1.1"); -MODULE_LICENSE("GPL"); diff --git a/packages/platforms/inventec/x86-64/d7054q28b/modules/builds/src/inv_pthread.h b/packages/platforms/inventec/x86-64/d7054q28b/modules/builds/src/inv_pthread.h deleted file mode 100644 index c3b7ce830..000000000 --- a/packages/platforms/inventec/x86-64/d7054q28b/modules/builds/src/inv_pthread.h +++ /dev/null @@ -1,19 +0,0 @@ -#ifndef INV_PTHREAD_H -#define INV_PTHREAD_H - -#define CPLD_DEV_LED_GRN_INDEX (0) -#define CPLD_DEV_LED_RED_INDEX (1) - -ssize_t cpld_show_led(char *buf, int index); -ssize_t cpld_set_led(const char *buf, size_t count, int index); -ssize_t cpld_show_ctl(char *buf); -ssize_t cpld_set_ctl(const char *buf, size_t count); - -ssize_t psoc_show_psu_state(char *buf, int index); -ssize_t psoc_show_fan_input(char *buf, int index); -ssize_t psoc_show_fan_state(char *buf); -ssize_t psoc_show_psu_vin(char *buf, int index); -ssize_t psoc_show_diag(char *buf); -ssize_t psoc_set_diag(const char *buf, size_t count); - -#endif /* INV_PTHREAD_H */ diff --git a/packages/platforms/inventec/x86-64/d7054q28b/modules/builds/src/inv_swps.c b/packages/platforms/inventec/x86-64/d7054q28b/modules/builds/src/inv_swps.c deleted file mode 100644 index 9050e59c9..000000000 --- a/packages/platforms/inventec/x86-64/d7054q28b/modules/builds/src/inv_swps.c +++ /dev/null @@ -1,3052 +0,0 @@ -/************************************************************************* - * - * inv_swps.c - * - * 2018 Inventec Corporation - * All Rights Reserved. - * - * NOTICE: All information contained herein is, and remains - * the property of Inventec Corp. and its suppliers, - * if any. The intellectual and technical concepts contained - * herein are proprietary to Inventec Corporation and its suppliers - * and may be covered by U.S. and Foreign Patents, patents in process, - * and are protected by trade secret or copyright law. - * - ************************************************************************/ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "inv_swps.h" - -static int ctl_major; -static int port_major; -static int ioexp_total; -static int port_total; -static int auto_config; -static int flag_i2c_reset; -static int flag_mod_state; -static unsigned gpio_rest_mux; -static struct class *swp_class_p = NULL; -static struct inv_platform_s *platform_p = NULL; -static struct inv_ioexp_layout_s *ioexp_layout = NULL; -static struct inv_port_layout_s *port_layout = NULL; - -static void swp_polling_worker(struct work_struct *work); -static DECLARE_DELAYED_WORK(swp_polling, swp_polling_worker); - -static int reset_i2c_topology(void); - -static union { - unsigned int eeprom_update_32[2]; - unsigned char eeprom_update_8[8]; -} ueu_64; - -static int -__swp_match(struct device *dev, -#ifdef SWPS_KERN_VER_AF_3_10 - - const void *data){ -#else - void *data){ -#endif - - char *name = (char *)data; - if (strcmp(dev_name(dev), name) == 0) - return 1; - return 0; -} - - -struct device * -get_swpdev_by_name(char *name){ - struct device *dev = class_find_device(swp_class_p, - NULL, - name, - __swp_match); - return dev; -} - - -static int -sscanf_2_int(const char *buf) { - - int result = -EBFONT; - char *hex_tag = "0x"; - - if (strcspn(buf, hex_tag) == 0) { - if (sscanf(buf,"%x",&result)) { - return result; - } - } else { - if (sscanf(buf,"%d",&result)) { - return result; - } - if(sscanf(buf,"-%d",&result)) { - return -result; - } - if (sscanf(buf,"%x",&result)) { - return result; - } - } - return -EBFONT; -} - -static unsigned long long int -sscanf_2_ullint(const char *buf, size_t count) { - - unsigned long long int result = -EBFONT; - char *hex_tag = "0x"; - int i, zero = 0; - - for (i = 0; i < count-2; i++) { - if (buf[i] != '0') { - zero = 1; - } - } - if (zero == 0) { - return 0x0ULL; - } - - if (strcspn(buf, hex_tag) == 0) { - for (i = 2; i < count-2; i++) { - if (INV_BATOX(buf[i]) == -1) { - return -EBFONT; - } - } - - if (sscanf(buf,"0x%llx",&result)) { - return result; - } - } else { - for (i = 0; i < count-2; i++) { - if (INV_BATOI(buf[i]) == -1) { - return -EBFONT; - } - } - - if (sscanf(buf,"%llu",&result)) { - return result; - } - } - return -EBFONT; -} - - -static int -sscanf_2_binary(const char *buf) { - - int result = sscanf_2_int(buf); - - if (result < 0){ - return -EBFONT; - } - switch (result) { - case 0: - case 1: - return result; - default: - break; - } - return -EBFONT; -} - - -static int -_get_polling_period(void) { - - int retval = 0; - - if (SWP_POLLING_PERIOD == 0) { - return 0; - } - retval = ((SWP_POLLING_PERIOD * HZ) / 1000); - if (retval == 0) { - return 1; - } - return retval; -} - - -static struct transvr_obj_s * -_get_transvr_obj(char *dev_name) { - - struct device *dev_p = NULL; - struct transvr_obj_s *transvr_obj_p = NULL; - - dev_p = get_swpdev_by_name(dev_name); - if (!dev_p){ - return NULL; - } - transvr_obj_p = dev_get_drvdata(dev_p); - if (!transvr_obj_p){ - return NULL; - } - return transvr_obj_p; -} - - -static void -unlock_tobj_all(void) { - - struct transvr_obj_s *tobj_p; - char port_name[32]; - int port_id = 0; - int minor_curr = 0; - - for (minor_curr=0; minor_currauto_config = auto_config; - unlock_transvr_obj(tobj_p); - SWPS_DEBUG("%s: Set %s auto_config=%d\n", - __func__, tobj_p->swp_name, auto_config); - } - return retval; -} - -unsigned char * -get_eeprom_update(void) -{ - return &ueu_64.eeprom_update_8[0]; -} - -void -set_eeprom_update(unsigned char value[8]) -{ - memcpy(ueu_64.eeprom_update_8, value, 8); -} - -/* ========== R/W Functions module control attribute ========== - */ -static ssize_t -show_attr_platform(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - return snprintf(buf_p, 32, "%s\n", platform_p->name); -} - - -static ssize_t -show_attr_version(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - return snprintf(buf_p, 8, "%s\n", SWP_VERSION); -} - - -static ssize_t -show_attr_status(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - return snprintf(buf_p, 8, "%d\n", flag_mod_state); -} - - -static ssize_t -show_attr_auto_config(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - return snprintf(buf_p, 8, "%d\n", auto_config); -} - -static ssize_t -show_attr_eeprom_update(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - return snprintf(buf_p, 20, "0x%02x%02x%02x%02x%02x%02x%02x%02x\n", - ueu_64.eeprom_update_8[7],ueu_64.eeprom_update_8[6], - ueu_64.eeprom_update_8[5],ueu_64.eeprom_update_8[4], - ueu_64.eeprom_update_8[3],ueu_64.eeprom_update_8[2], - ueu_64.eeprom_update_8[1],ueu_64.eeprom_update_8[0]); -} - - -static int -_check_reset_pwd(const char *buf_p, - size_t count) { - - int in_max = 64; - int in_len = (int)count; - char in_val[64] = "ERR"; - char *emsg = "ERR"; - - if (in_len >= in_max) { - emsg = "input too much"; - goto err_check_reset_pwd; - } - if (!sscanf(buf_p,"%s",in_val)) { - emsg = "format incorrect"; - goto err_check_reset_pwd; - } - if (strcmp(in_val, SWP_RESET_PWD) != 0) { - emsg = "password incorrect"; - goto err_check_reset_pwd; - } - return 0; - -err_check_reset_pwd: - SWPS_ERR("%s: %s\n", __func__, emsg); - return -1; -} - - -static ssize_t -store_attr_reset_i2c(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - - if (_check_reset_pwd(buf_p, count) < 0) { - return -EBFONT; - } - /* Polling mode */ - if (SWP_POLLING_ENABLE) { - SWPS_INFO("%s: reset I2C :polling\n", __func__); - flag_i2c_reset = 1; - return count; - } - /* Direct mode */ - SWPS_INFO("%s: reset I2C go. :direct\n", __func__); - if (reset_i2c_topology() < 0) { - SWPS_ERR("%s: reset fail!\n", __func__); - return -EIO; - } - SWPS_INFO("%s: reset I2C ok. :direct\n", __func__); - return count; -} - - -static ssize_t -store_attr_reset_swps(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - - struct transvr_obj_s *tobj_p; - char port_name[32] = "ERR"; - int port_id = 0; - int minor_curr = 0; - - if (_check_reset_pwd(buf_p, count) < 0) { - return -EBFONT; - } - for (minor_curr=0; minor_currstate = STATE_TRANSVR_DISCONNECTED; - unlock_transvr_obj(tobj_p); - SWPS_INFO("%s: reset:%s\n", __func__, tobj_p->swp_name); - } - return count; -} - - -static ssize_t -store_attr_auto_config(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - - int input_val = sscanf_2_int(buf_p); - - if (input_val < 0){ - return -EBFONT; - } - if ((input_val != 0) && (input_val != 1)) { - return -EBFONT; - } - auto_config = input_val; - _update_auto_config_2_trnasvr(); - return count; -} - -static ssize_t -store_attr_eeprom_update(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count) { - - union { - unsigned long long int input_val_64; - unsigned int input_val_32[2]; - } uiv; - int i; - uiv.input_val_64 = sscanf_2_ullint(buf_p, count); - if (uiv.input_val_64 == 0){ - for (i = 0; i < 8; i++) { - ueu_64.eeprom_update_8[i] = 0; - } - } - else - if (uiv.input_val_64 > 0) { - for (i = 0; i < 32; i++) { - if (uiv.input_val_32[0] & 1<get_id, - buf_p); -} - - -static ssize_t -show_attr_ext_id(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_hex_attr(tobj_p, - tobj_p->get_ext_id, - buf_p); -} - - -static ssize_t -show_attr_connector(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_hex_attr(tobj_p, - tobj_p->get_connector, - buf_p); -} - - -static ssize_t -show_attr_vendor_name(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_vendor_name, - buf_p); -} - - -static ssize_t -show_attr_vendor_pn(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_vendor_pn, - buf_p); -} - - -static ssize_t -show_attr_vendor_rev(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_vendor_rev, - buf_p); -} - - -static ssize_t -show_attr_vendor_sn(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_vendor_sn, - buf_p); -} - - -static ssize_t -show_attr_power_cls(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - size_t len; - int result; - struct transvr_obj_s *tobj_p; - - tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - lock_transvr_obj(tobj_p); - result = tobj_p->get_power_cls(tobj_p); - unlock_transvr_obj(tobj_p); - if (result < 0){ - len = snprintf(buf_p, 16, "%d\n", result); - } else { - len = snprintf(buf_p, 16, "Power Class %d\n", result); - } - return len; -} - - -static ssize_t -show_attr_br(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_hex_attr(tobj_p, - tobj_p->get_br, - buf_p); -} - - -static ssize_t -show_attr_len_sm(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_int_attr(tobj_p, - tobj_p->get_len_sm, - buf_p); -} - - -static ssize_t -show_attr_len_smf(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_int_attr(tobj_p, - tobj_p->get_len_smf, - buf_p); -} - - -static ssize_t -show_attr_len_om1(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_int_attr(tobj_p, - tobj_p->get_len_om1, - buf_p); -} - - -static ssize_t -show_attr_len_om2(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_int_attr(tobj_p, - tobj_p->get_len_om2, - buf_p); -} - - -static ssize_t -show_attr_len_om3(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_int_attr(tobj_p, - tobj_p->get_len_om3, - buf_p); -} - - -static ssize_t -show_attr_len_om4(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_int_attr(tobj_p, - tobj_p->get_len_om4, - buf_p); -} - - -static ssize_t -show_attr_comp_rev(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_hex_attr(tobj_p, - tobj_p->get_comp_rev, - buf_p); -} - - -static ssize_t -show_attr_comp_eth(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_hex_attr(tobj_p, - tobj_p->get_comp_eth_1, - buf_p); -} - - -static ssize_t -show_attr_comp_eth_10(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_hex_attr(tobj_p, - tobj_p->get_comp_eth_10, - buf_p); -} - - -static ssize_t -show_attr_comp_eth_10_40(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_hex_attr(tobj_p, - tobj_p->get_comp_eth_10_40, - buf_p); -} - - -static ssize_t -show_attr_comp_extend(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_hex_attr(tobj_p, - tobj_p->get_comp_extend, - buf_p); -} - - -static ssize_t -show_attr_rate_id(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_hex_attr(tobj_p, - tobj_p->get_rate_id, - buf_p); -} - - -static ssize_t -show_attr_temperature(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_curr_temp, - buf_p); -} - - -static ssize_t -show_attr_voltage(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_curr_vol, - buf_p); -} - - -static ssize_t -show_attr_tx_bias(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_tx_bias, - buf_p); -} - - -static ssize_t -show_attr_tx_power(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_tx_power, - buf_p); -} - - -static ssize_t -show_attr_tx_eq(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_tx_eq, - buf_p); -} - - -static ssize_t -show_attr_rx_power(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_rx_power, - buf_p); -} - - -static ssize_t -show_attr_rx_am(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_rx_am, - buf_p); -} - - -static ssize_t -show_attr_rx_em(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_rx_em, - buf_p); -} - - -static ssize_t -show_attr_wavelength(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_wavelength, - buf_p); -} - - -static ssize_t -show_attr_info(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_int_attr(tobj_p, - tobj_p->get_info, - buf_p); -} - - -static ssize_t -show_attr_if_type(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_if_type, - buf_p); -} - - -static ssize_t -show_attr_if_speed(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_if_speed, - buf_p); -} - - -static ssize_t -show_attr_if_lane(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_if_lane, - buf_p); -} - - -static ssize_t -show_attr_cdr(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_hex_attr(tobj_p, - tobj_p->get_cdr, - buf_p); -} - - -static ssize_t -show_attr_soft_rs0(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_int_attr(tobj_p, - tobj_p->get_soft_rs0, - buf_p); -} - - -static ssize_t -show_attr_soft_rs1(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_int_attr(tobj_p, - tobj_p->get_soft_rs1, - buf_p); -} - - -static ssize_t -show_attr_soft_rx_los(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_soft_rx_los, - buf_p); -} - - -static ssize_t -show_attr_soft_tx_disable(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_soft_tx_disable, - buf_p); -} - - -static ssize_t -show_attr_soft_tx_fault(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_soft_tx_fault, - buf_p); -} - - -static ssize_t -show_attr_auto_tx_disable(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_auto_tx_disable, - buf_p); -} - -static ssize_t -show_attr_eeprom(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_eeprom, - buf_p); -} - -/* ========== Store functions: transceiver (R/W) attribute ========== - */ -static ssize_t -_store_transvr_int_attr(struct transvr_obj_s* tobj_p, - int (*set_func)(struct transvr_obj_s *tobj_p, int input_val), - const char *buf_p, - size_t count) { - int input, err; - - input = sscanf_2_int(buf_p); - if (input < 0){ - return -EBFONT; - } - lock_transvr_obj(tobj_p); - err = set_func(tobj_p, input); - unlock_transvr_obj(tobj_p); - if (err < 0){ - return err; - } - return count; -} - - -static ssize_t -_store_transvr_byte_hex_attr(struct transvr_obj_s* tobj_p, - int (*set_func)(struct transvr_obj_s *tobj_p, int input_val), - const char *buf_p, - size_t count) { - int input, err; - - input = sscanf_2_int(buf_p); - if ((input < 0) || (input > 0xff)){ - return -EBFONT; - } - lock_transvr_obj(tobj_p); - err = set_func(tobj_p, input); - unlock_transvr_obj(tobj_p); - if (err < 0){ - return err; - } - return count; -} - - -static ssize_t -_store_transvr_binary_attr(struct transvr_obj_s* tobj_p, - int (*set_func)(struct transvr_obj_s *tobj_p, int input_val), - const char *buf_p, - size_t count) { - int input, err; - - input = sscanf_2_binary(buf_p); - if (input < 0){ - return -EBFONT; - } - lock_transvr_obj(tobj_p); - err = set_func(tobj_p, input); - unlock_transvr_obj(tobj_p); - if (err < 0){ - return err; - } - return count; -} - - -static ssize_t -store_attr_cdr(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - return _store_transvr_byte_hex_attr(tobj_p, - tobj_p->set_cdr, - buf_p, - count); -} - - -static ssize_t -store_attr_soft_rs0(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - return _store_transvr_binary_attr(tobj_p, - tobj_p->set_soft_rs0, - buf_p, - count); -} - - -static ssize_t -store_attr_soft_rs1(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - return _store_transvr_binary_attr(tobj_p, - tobj_p->set_soft_rs1, - buf_p, - count); -} - - -static ssize_t -store_attr_soft_tx_disable(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count) { - - int check = sscanf_2_int(buf_p); - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - if ((check < 0) || (check > 0xf)){ - return -EBFONT; - } - return _store_transvr_byte_hex_attr(tobj_p, - tobj_p->set_soft_tx_disable, - buf_p, - count); -} - - -static ssize_t -store_attr_auto_tx_disable(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count) { - - int err = -EPERM; - int input = sscanf_2_int(buf_p); - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - if ((input < 0) || (input > 0xf)){ - if (input != VAL_TRANSVR_FUNCTION_DISABLE) { - return -EBFONT; - } - } - lock_transvr_obj(tobj_p); - err = tobj_p->set_auto_tx_disable(tobj_p, input); - unlock_transvr_obj(tobj_p); - if (err < 0){ - return err; - } - return count; -} - - -static ssize_t -store_attr_tx_eq(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - return _store_transvr_int_attr(tobj_p, - tobj_p->set_tx_eq, - buf_p, - count); -} - - -static ssize_t -store_attr_rx_am(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - return _store_transvr_int_attr(tobj_p, - tobj_p->set_rx_am, - buf_p, - count); -} - - -static ssize_t -store_attr_rx_em(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - return _store_transvr_int_attr(tobj_p, - tobj_p->set_rx_em, - buf_p, - count); -} - -/* ========== Show functions: For I/O Expander attribute ========== - */ -static ssize_t -_show_ioexp_binary_attr(struct transvr_obj_s *tobj_p, - int (*get_func)(struct ioexp_obj_s *ioexp_p, int voffset), - char *buf_p) { - size_t len; - struct ioexp_obj_s *ioexp_p = tobj_p->ioexp_obj_p; - - if (!ioexp_p) { - SWPS_ERR(" %s: data corruption! :%s\n", __func__, tobj_p->swp_name); - return -ENODATA; - } - mutex_lock(&ioexp_p->lock); - len = snprintf(buf_p, 8, "%d\n", get_func(ioexp_p, tobj_p->ioexp_virt_offset)); - mutex_unlock(&ioexp_p->lock); - return len; -} - - -static ssize_t -show_attr_present(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - return _show_ioexp_binary_attr(tobj_p, - tobj_p->ioexp_obj_p->get_present, - buf_p); -} - - -static ssize_t -show_attr_tx_fault(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - return _show_ioexp_binary_attr(tobj_p, - tobj_p->ioexp_obj_p->get_tx_fault, - buf_p); -} - - -static ssize_t -show_attr_rxlos(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - return _show_ioexp_binary_attr(tobj_p, - tobj_p->ioexp_obj_p->get_rxlos, - buf_p); -} - - -static ssize_t -show_attr_tx_disable(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - return _show_ioexp_binary_attr(tobj_p, - tobj_p->ioexp_obj_p->get_tx_disable, - buf_p); -} - - -static ssize_t -show_attr_reset(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - return _show_ioexp_binary_attr(tobj_p, - tobj_p->ioexp_obj_p->get_reset, - buf_p); -} - - -static ssize_t -show_attr_lpmod(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - return _show_ioexp_binary_attr(tobj_p, - tobj_p->ioexp_obj_p->get_lpmod, - buf_p); -} - - -static ssize_t -show_attr_modsel(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - return _show_ioexp_binary_attr(tobj_p, - tobj_p->ioexp_obj_p->get_modsel, - buf_p); -} - - -static ssize_t -show_attr_hard_rs0(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - return _show_ioexp_binary_attr(tobj_p, - tobj_p->ioexp_obj_p->get_hard_rs0, - buf_p); -} - - -static ssize_t -show_attr_hard_rs1(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - return _show_ioexp_binary_attr(tobj_p, - tobj_p->ioexp_obj_p->get_hard_rs1, - buf_p); -} - - -/* ========== Store functions: For I/O Expander (R/W) attribute ========== - */ -static ssize_t -_store_ioexp_binary_attr(struct transvr_obj_s *tobj_p, - int (*set_func)(struct ioexp_obj_s *ioexp_p, - int virt_offset, int input_val), - const char *buf_p, - size_t count) { - - int input, err; - struct ioexp_obj_s *ioexp_p = tobj_p->ioexp_obj_p; - - if (!ioexp_p) { - SWPS_ERR("%s: data corruption! :%s\n", - __func__, tobj_p->swp_name); - return -ENODATA; - } - input = sscanf_2_binary(buf_p); - if (input < 0) { - return -EBFONT; - } - mutex_lock(&ioexp_p->lock); - err = set_func(ioexp_p, tobj_p->ioexp_virt_offset, input); - mutex_unlock(&ioexp_p->lock); - if (err < 0){ - return err; - } - return count; -} - -static ssize_t -store_attr_tx_disable(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p) { - return -ENODEV; - } - return _store_ioexp_binary_attr(tobj_p, - tobj_p->ioexp_obj_p->set_tx_disable, - buf_p, - count); -} - - -static ssize_t -store_attr_reset(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p) { - return -ENODEV; - } - return _store_ioexp_binary_attr(tobj_p, - tobj_p->ioexp_obj_p->set_reset, - buf_p, - count); -} - - -static ssize_t -store_attr_lpmod(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p) { - return -ENODEV; - } - return _store_ioexp_binary_attr(tobj_p, - tobj_p->ioexp_obj_p->set_lpmod, - buf_p, - count); -} - - -static ssize_t -store_attr_modsel(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p) { - return -ENODEV; - } - return _store_ioexp_binary_attr(tobj_p, - tobj_p->ioexp_obj_p->set_modsel, - buf_p, - count); -} - - -static ssize_t -store_attr_hard_rs0(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p) { - return -ENODEV; - } - return _store_ioexp_binary_attr(tobj_p, - tobj_p->ioexp_obj_p->set_hard_rs0, - buf_p, - count); -} - - -static ssize_t -store_attr_hard_rs1(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p) { - return -ENODEV; - } - return _store_ioexp_binary_attr(tobj_p, - tobj_p->ioexp_obj_p->set_hard_rs1, - buf_p, - count); -} - - -/* ========== SWPS attribute: For module control ========== - */ -static DEVICE_ATTR(platform, S_IRUGO, show_attr_platform, NULL); -static DEVICE_ATTR(version, S_IRUGO, show_attr_version, NULL); -static DEVICE_ATTR(status, S_IRUGO, show_attr_status, NULL); -static DEVICE_ATTR(reset_i2c, S_IWUSR, NULL, store_attr_reset_i2c); -static DEVICE_ATTR(reset_swps, S_IWUSR, NULL, store_attr_reset_swps); -static DEVICE_ATTR(auto_config, S_IRUGO|S_IWUSR, show_attr_auto_config, store_attr_auto_config); -static DEVICE_ATTR(eeprom_update, S_IRUGO|S_IWUSR, show_attr_eeprom_update, store_attr_eeprom_update); - -/* ========== Transceiver attribute: from eeprom ========== - */ -static DEVICE_ATTR(id, S_IRUGO, show_attr_id, NULL); -static DEVICE_ATTR(ext_id, S_IRUGO, show_attr_ext_id, NULL); -static DEVICE_ATTR(connector, S_IRUGO, show_attr_connector, NULL); -static DEVICE_ATTR(vendor_name, S_IRUGO, show_attr_vendor_name, NULL); -static DEVICE_ATTR(vendor_pn, S_IRUGO, show_attr_vendor_pn, NULL); -static DEVICE_ATTR(vendor_rev, S_IRUGO, show_attr_vendor_rev, NULL); -static DEVICE_ATTR(vendor_sn, S_IRUGO, show_attr_vendor_sn, NULL); -static DEVICE_ATTR(power_cls, S_IRUGO, show_attr_power_cls, NULL); -static DEVICE_ATTR(br, S_IRUGO, show_attr_br, NULL); -static DEVICE_ATTR(len_sm, S_IRUGO, show_attr_len_sm, NULL); -static DEVICE_ATTR(len_smf, S_IRUGO, show_attr_len_smf, NULL); -static DEVICE_ATTR(len_om1, S_IRUGO, show_attr_len_om1, NULL); -static DEVICE_ATTR(len_om2, S_IRUGO, show_attr_len_om2, NULL); -static DEVICE_ATTR(len_om3, S_IRUGO, show_attr_len_om3, NULL); -static DEVICE_ATTR(len_om4, S_IRUGO, show_attr_len_om4, NULL); -static DEVICE_ATTR(comp_rev, S_IRUGO, show_attr_comp_rev, NULL); -static DEVICE_ATTR(comp_eth, S_IRUGO, show_attr_comp_eth, NULL); -static DEVICE_ATTR(comp_eth_10, S_IRUGO, show_attr_comp_eth_10, NULL); -static DEVICE_ATTR(comp_eth_10_40, S_IRUGO, show_attr_comp_eth_10_40, NULL); -static DEVICE_ATTR(comp_extend, S_IRUGO, show_attr_comp_extend, NULL); -static DEVICE_ATTR(rate_id, S_IRUGO, show_attr_rate_id, NULL); -static DEVICE_ATTR(temperature, S_IRUGO, show_attr_temperature, NULL); -static DEVICE_ATTR(voltage, S_IRUGO, show_attr_voltage, NULL); -static DEVICE_ATTR(tx_bias, S_IRUGO, show_attr_tx_bias, NULL); -static DEVICE_ATTR(tx_power, S_IRUGO, show_attr_tx_power, NULL); -static DEVICE_ATTR(rx_power, S_IRUGO, show_attr_rx_power, NULL); -static DEVICE_ATTR(info, S_IRUGO, show_attr_info, NULL); -static DEVICE_ATTR(if_type, S_IRUGO, show_attr_if_type, NULL); -static DEVICE_ATTR(if_speed, S_IRUGO, show_attr_if_speed, NULL); -static DEVICE_ATTR(if_lane, S_IRUGO, show_attr_if_lane, NULL); -static DEVICE_ATTR(soft_rx_los, S_IRUGO, show_attr_soft_rx_los, NULL); -static DEVICE_ATTR(soft_tx_fault, S_IRUGO, show_attr_soft_tx_fault, NULL); -static DEVICE_ATTR(wavelength, S_IRUGO, show_attr_wavelength, NULL); -static DEVICE_ATTR(eeprom, S_IRUGO, show_attr_eeprom, NULL); -static DEVICE_ATTR(tx_eq, S_IRUGO|S_IWUSR, show_attr_tx_eq, store_attr_tx_eq); -static DEVICE_ATTR(rx_am, S_IRUGO|S_IWUSR, show_attr_rx_am, store_attr_rx_am); -static DEVICE_ATTR(rx_em, S_IRUGO|S_IWUSR, show_attr_rx_em, store_attr_rx_em); -static DEVICE_ATTR(cdr, S_IRUGO|S_IWUSR, show_attr_cdr, store_attr_cdr); -static DEVICE_ATTR(soft_rs0, S_IRUGO|S_IWUSR, show_attr_soft_rs0, store_attr_soft_rs0); -static DEVICE_ATTR(soft_rs1, S_IRUGO|S_IWUSR, show_attr_soft_rs1, store_attr_soft_rs1); -static DEVICE_ATTR(soft_tx_disable, S_IRUGO|S_IWUSR, show_attr_soft_tx_disable, store_attr_soft_tx_disable); -static DEVICE_ATTR(auto_tx_disable, S_IRUGO|S_IWUSR, show_attr_auto_tx_disable, store_attr_auto_tx_disable); - -/* ========== IO Expander attribute: from expander ========== - */ -static DEVICE_ATTR(present, S_IRUGO, show_attr_present, NULL); -static DEVICE_ATTR(tx_fault, S_IRUGO, show_attr_tx_fault, NULL); -static DEVICE_ATTR(rxlos, S_IRUGO, show_attr_rxlos, NULL); -static DEVICE_ATTR(tx_disable, S_IRUGO|S_IWUSR, show_attr_tx_disable, store_attr_tx_disable); -static DEVICE_ATTR(reset, S_IRUGO|S_IWUSR, show_attr_reset, store_attr_reset); -static DEVICE_ATTR(lpmod, S_IRUGO|S_IWUSR, show_attr_lpmod, store_attr_lpmod); -static DEVICE_ATTR(modsel, S_IRUGO|S_IWUSR, show_attr_modsel, store_attr_modsel); -static DEVICE_ATTR(hard_rs0, S_IRUGO|S_IWUSR, show_attr_hard_rs0, store_attr_hard_rs0); -static DEVICE_ATTR(hard_rs1, S_IRUGO|S_IWUSR, show_attr_hard_rs1, store_attr_hard_rs1); - -/* ========== Functions for module handling ========== - */ -static void -clean_port_obj(void){ - - dev_t dev_num; - char dev_name[32]; - struct device *device_p; - struct transvr_obj_s *transvr_obj_p; - int minor_curr, port_id; - - for (minor_curr=0; minor_curri2c_client_p); - kfree(transvr_obj_p->vendor_name); - kfree(transvr_obj_p->vendor_pn); - kfree(transvr_obj_p->vendor_rev); - kfree(transvr_obj_p->vendor_sn); - kfree(transvr_obj_p->worker_p); - kfree(transvr_obj_p); - } - dev_num = MKDEV(port_major, minor_curr); - device_unregister(device_p); - device_destroy(swp_class_p, dev_num); - } - SWPS_DEBUG("%s: done.\n", __func__); -} - - -static void -clean_swps_common(void){ - - dev_t dev_num; - struct device *device_p; - - device_p = get_swpdev_by_name(SWP_DEV_MODCTL); - if (device_p){ - dev_num = MKDEV(ctl_major, 1); - device_unregister(device_p); - device_destroy(swp_class_p, dev_num); - } - cancel_delayed_work_sync(&swp_polling); - SWPS_DEBUG("%s: done.\n", __func__); -} - - -static int -get_platform_type(void){ - - int i; - int pf_total = ARRAY_SIZE(platform_map); - char log_msg[64] = "ERROR"; - - platform_p = kzalloc(sizeof(struct inv_platform_s), GFP_KERNEL); - if (!platform_p){ - snprintf(log_msg, sizeof(log_msg), "kzalloc fail"); - goto err_get_platform_type_1; - } - memset(platform_p->name, 0, sizeof(platform_p->name)); - - switch (PLATFORM_SETTINGS) { - case PLATFORM_TYPE_AUTO: - snprintf(platform_p->name, (sizeof(platform_p->name) - 1), - "%s", dmi_get_system_info(DMI_BOARD_NAME)); - for (i=0; iname, platform_map[i].name) == 0) { - platform_p->id = platform_map[i].id; - snprintf(log_msg, sizeof(log_msg), - "Auto detect platform: %d (%s)", - platform_p->id, platform_p->name); - goto ok_get_platform_type_1; - } - } - snprintf(log_msg, sizeof(log_msg), - "Auto detect fail! detect platform: %s", - platform_p->name); - goto err_get_platform_type_2; - - case PLATFORM_TYPE_MAGNOLIA: - case PLATFORM_TYPE_MAGNOLIA_FNC: - case PLATFORM_TYPE_REDWOOD: - case PLATFORM_TYPE_REDWOOD_FSL: - case PLATFORM_TYPE_HUDSON32I_GA: - case PLATFORM_TYPE_SPRUCE: - case PLATFORM_TYPE_CYPRESS_GA1: - case PLATFORM_TYPE_CYPRESS_GA2: - case PLATFORM_TYPE_CYPRESS_BAI: - platform_p->id = PLATFORM_SETTINGS; - for (i=0; iname, (sizeof(platform_p->name) - 1), - "%s", platform_map[i].name); - snprintf(log_msg, sizeof(log_msg), - "User setup platform: %d (%s)", - platform_p->id, platform_p->name); - goto ok_get_platform_type_1; - } - } - snprintf(log_msg, sizeof(log_msg), - "Internal error, can not map id:%d", - PLATFORM_SETTINGS); - goto err_get_platform_type_2; - - default: - break; - } - snprintf(log_msg, sizeof(log_msg), - "PLATFORM_SETTINGS:%d undefined", PLATFORM_SETTINGS); - goto err_get_platform_type_2; - -ok_get_platform_type_1: - SWPS_DEBUG("%s: %s, :%d\n", __func__, log_msg, PLATFORM_SETTINGS); - return 0; - -err_get_platform_type_2: - kfree(platform_p); -err_get_platform_type_1: - SWPS_ERR("%s: %s :%d\n", __func__, log_msg, PLATFORM_SETTINGS); - return -1; -} - - -static int -get_layout_info(void){ - - switch (platform_p->id) { -#ifdef SWPS_MAGNOLIA - case PLATFORM_TYPE_MAGNOLIA: - case PLATFORM_TYPE_MAGNOLIA_FNC: - gpio_rest_mux = magnolia_gpio_rest_mux; - ioexp_layout = magnolia_ioexp_layout; - port_layout = magnolia_port_layout; - ioexp_total = ARRAY_SIZE(magnolia_ioexp_layout); - port_total = ARRAY_SIZE(magnolia_port_layout); - break; -#endif -#ifdef SWPS_REDWOOD - case PLATFORM_TYPE_REDWOOD: - gpio_rest_mux = redwood_gpio_rest_mux; - ioexp_layout = redwood_ioexp_layout; - port_layout = redwood_port_layout; - ioexp_total = ARRAY_SIZE(redwood_ioexp_layout); - port_total = ARRAY_SIZE(redwood_port_layout); - break; -#endif -#ifdef SWPS_HUDSON32I_GA - case PLATFORM_TYPE_HUDSON32I_GA: - gpio_rest_mux = hudsin32iga_gpio_rest_mux; - ioexp_layout = hudson32iga_ioexp_layout; - port_layout = hudson32iga_port_layout; - ioexp_total = ARRAY_SIZE(hudson32iga_ioexp_layout); - port_total = ARRAY_SIZE(hudson32iga_port_layout); - break; -#endif -#ifdef SWPS_SPRUCE - case PLATFORM_TYPE_SPRUCE: - gpio_rest_mux = spruce_gpio_rest_mux; - ioexp_layout = spruce_ioexp_layout; - port_layout = spruce_port_layout; - ioexp_total = ARRAY_SIZE(spruce_ioexp_layout); - port_total = ARRAY_SIZE(spruce_port_layout); - break; -#endif -#ifdef SWPS_CYPRESS_GA1 - case PLATFORM_TYPE_CYPRESS_GA1: - gpio_rest_mux = cypress_ga1_gpio_rest_mux; - ioexp_layout = cypress_ga1_ioexp_layout; - port_layout = cypress_ga1_port_layout; - ioexp_total = ARRAY_SIZE(cypress_ga1_ioexp_layout); - port_total = ARRAY_SIZE(cypress_ga1_port_layout); - break; -#endif -#ifdef SWPS_CYPRESS_GA2 - case PLATFORM_TYPE_CYPRESS_GA2: - gpio_rest_mux = cypress_ga2_gpio_rest_mux; - ioexp_layout = cypress_ga2_ioexp_layout; - port_layout = cypress_ga2_port_layout; - ioexp_total = ARRAY_SIZE(cypress_ga2_ioexp_layout); - port_total = ARRAY_SIZE(cypress_ga2_port_layout); - break; -#endif -#ifdef SWPS_CYPRESS_BAI - case PLATFORM_TYPE_CYPRESS_BAI: - gpio_rest_mux = cypress_b_gpio_rest_mux; - ioexp_layout = cypress_b_ioexp_layout; - port_layout = cypress_b_port_layout; - ioexp_total = ARRAY_SIZE(cypress_b_ioexp_layout); - port_total = ARRAY_SIZE(cypress_b_port_layout); - break; -#endif -#ifdef SWPS_REDWOOD_FSL - case PLATFORM_TYPE_REDWOOD_FSL: - gpio_rest_mux = redwood_fsl_gpio_rest_mux; - ioexp_layout = redwood_fsl_ioexp_layout; - port_layout = redwood_fsl_port_layout; - ioexp_total = ARRAY_SIZE(redwood_fsl_ioexp_layout); - port_total = ARRAY_SIZE(redwood_fsl_port_layout); - break; -#endif - - default: - SWPS_ERR(" Invalid platform: %d (%s)\n", - platform_p->id, platform_p->name); - return -1; - } - SWPS_INFO("Start to initial platform: %d (%s)\n", - platform_p->id, platform_p->name); - return 0; -} - - -/* ========== Functions for objects operations ========== - */ -static int -__detect_issues_port(int minor_num) { - - struct transvr_obj_s *tobj_p; - int port_id = port_layout[minor_num].port_id; - char port_name[32] = "ERR"; - char *i2c_emsg = "detected bad transceiver/cable"; - - memset(port_name, 0, sizeof(port_name)); - snprintf(port_name, sizeof(port_name), "%s%d", SWP_DEV_PORT, port_id); - tobj_p = _get_transvr_obj(port_name); - if (!tobj_p) { - SWPS_INFO("%s: tobj_p is NULL :%d\n", __func__, minor_num); - return -1; - } - if (resync_channel_tier_2(tobj_p) < 0) { - if (check_channel_tier_1() < 0) { - alarm_msg_2_user(tobj_p, i2c_emsg); - return -2;; - } - } - return 0; -} - - -static int -_detect_issues_port(void) { - /* OK : retrun -1; - * Fail: return fail at which minor number (0~N) - */ - char *emsg = "ERR"; - int minor = 0; - int minor_2st = 1; - - /* Force moving the initial channel pointer - * Filter out case of fail at minor-0 port - */ - while (minor_2st < port_total) { - minor = minor_2st; - if (__detect_issues_port(minor_2st) < 0) { - emsg = "detect minor_2st fail"; - goto err_p_detect_issues_port; - } - minor_2st += 8; - } - /* Scan all port */ - for (minor=0; minor:%d\n", __func__, emsg, minor_err); - return -1; -} - - -static int -check_transvr_obj_one(char *dev_name){ - /* [Return] - * 0 : Doesn't need to take care - * -1 : Single error - * -2 : Critical error (I2C topology die) - * -9 : Internal error - */ - struct transvr_obj_s *tobj_p = NULL; - int retval = -9; - - tobj_p = _get_transvr_obj(dev_name); - if (!tobj_p) { - SWPS_ERR("%s: %s _get_transvr_obj fail\n", - __func__, dev_name); - return -9; - } - /* Check transceiver current status */ - lock_transvr_obj(tobj_p); - retval = tobj_p->check(tobj_p); - unlock_transvr_obj(tobj_p); - switch (retval) { - case 0: - case ERR_TRANSVR_UNPLUGGED: - case ERR_TRNASVR_BE_ISOLATED: - case ERR_TRANSVR_TASK_BUSY: - return 0; - - case ERR_TRANSVR_I2C_CRASH: - default: - break; - } - /* Identify abnormal case */ - if (check_channel_tier_1() < 0) { - SWPS_DEBUG("%s: %s critical error :%d\n", - __func__, dev_name, retval); - return -2; - } - SWPS_DEBUG("%s: %s single error :%d\n", - __func__, dev_name, retval); - return -1; -} - - -static int -check_transvr_objs(void){ - - char dev_name[32]; - int port_id, err_code; - int minor_curr = 0; - - for (minor_curr=0; minor_curr:%d\n", - __func__, dev_name, err_code); - break; - } - } - return 0; - -err_check_transvr_objs: - SWPS_ERR("%s: %s reset_i2c_topology fail.\n", - __func__, dev_name); - return -1; -} - - -static void -swp_polling_worker(struct work_struct *work){ - - /* Reset I2C */ - if (flag_i2c_reset) { - goto polling_reset_i2c; - } - /* Check IOEXP */ - if (check_ioexp_objs() < 0) { - goto polling_reset_i2c; - } - /* Check transceiver */ - if (check_transvr_objs() < 0) { - SWPS_DEBUG("%s: check_transvr_objs fail.\n", __func__); - flag_i2c_reset = 1; - } - goto polling_schedule_round; - -polling_reset_i2c: - SWPS_DEBUG("%s: reset_i2c_topology start.\n", __func__); - if (reset_i2c_topology() < 0) { - SWPS_ERR("%s: reset i2c fail!\n", __func__); - flag_i2c_reset = 1; - } else { - SWPS_DEBUG("%s: reset_i2c_topology OK.\n", __func__); - flag_i2c_reset = 0; - } -polling_schedule_round: - schedule_delayed_work(&swp_polling, _get_polling_period()); -} - - -/* ========== Functions for register something ========== - */ -static int -register_transvr_common_attr(struct device *device_p){ - - char *err_attr = NULL; - - if (device_create_file(device_p, &dev_attr_id) < 0) { - err_attr = "dev_attr_id"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_ext_id) < 0) { - err_attr = "dev_attr_ext_id"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_connector) < 0) { - err_attr = "dev_attr_connector"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_vendor_name) < 0) { - err_attr = "dev_attr_vendor_name"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_vendor_pn) < 0) { - err_attr = "dev_attr_vendor_pn"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_vendor_rev) < 0) { - err_attr = "dev_attr_vendor_rev"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_vendor_sn) < 0) { - err_attr = "dev_attr_vendor_sn"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_br) < 0) { - err_attr = "dev_attr_br"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_len_smf) < 0) { - err_attr = "dev_attr_len_smf"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_len_om1) < 0) { - err_attr = "dev_attr_len_om1"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_len_om2) < 0) { - err_attr = "dev_attr_len_om2"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_len_om3) < 0) { - err_attr = "dev_attr_len_om3"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_len_om4) < 0) { - err_attr = "dev_attr_len_om4"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_comp_extend) < 0) { - err_attr = "dev_attr_comp_extend"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_comp_eth) < 0) { - err_attr = "dev_attr_comp_eth"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_comp_rev) < 0) { - err_attr = "dev_attr_comp_rev"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_info) < 0) { - err_attr = "dev_attr_info"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_if_type) < 0) { - err_attr = "dev_attr_if_type"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_if_speed) < 0) { - err_attr = "dev_attr_if_speed"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_if_lane) < 0) { - err_attr = "dev_attr_if_lane"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_temperature) < 0) { - err_attr = "dev_attr_temperature"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_voltage) < 0) { - err_attr = "dev_attr_voltage"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_tx_bias) < 0) { - err_attr = "dev_attr_tx_bias"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_tx_power) < 0) { - err_attr = "dev_attr_tx_power"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_rx_power) < 0) { - err_attr = "dev_attr_rx_power"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_tx_eq) < 0) { - err_attr = "dev_attr_tx_eq"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_rx_em) < 0) { - err_attr = "dev_attr_rx_em"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_wavelength) < 0) { - err_attr = "dev_attr_wavelength"; - goto err_transvr_comm_attr; - } - return 0; - -err_transvr_comm_attr: - SWPS_ERR("%s: %s\n", __func__, err_attr); - return -1; -} - -static int -register_transvr_sfp_attr(struct device *device_p){ - - char *err_attr = NULL; - - if (register_transvr_common_attr(device_p) < 0) { - err_attr = "register_transvr_common_attr"; - goto err_transvr_sfp_attr; - } - if (device_create_file(device_p, &dev_attr_comp_eth_10) < 0) { - err_attr = "dev_attr_comp_eth_10"; - goto err_transvr_sfp_attr; - } - if (device_create_file(device_p, &dev_attr_len_sm) < 0) { - err_attr = "dev_attr_len_sm"; - goto err_transvr_sfp_attr; - } - if (device_create_file(device_p, &dev_attr_rate_id) < 0) { - err_attr = "dev_attr_rate_id"; - goto err_transvr_sfp_attr; - } - if (device_create_file(device_p, &dev_attr_soft_rs0) < 0) { - err_attr = "dev_attr_soft_rs0"; - goto err_transvr_sfp_attr; - } - if (device_create_file(device_p, &dev_attr_soft_rs1) < 0) { - err_attr = "dev_attr_soft_rs1"; - goto err_transvr_sfp_attr; - } - if (device_create_file(device_p, &dev_attr_eeprom) < 0) { - err_attr = "dev_attr_eeprom"; - goto err_transvr_sfp_attr; - } - return 0; - -err_transvr_sfp_attr: - SWPS_ERR("%s: %s\n", __func__, err_attr); - return -1; -} - - -static int -register_transvr_qsfp_attr(struct device *device_p){ - - char *err_attr = NULL; - - if (register_transvr_common_attr(device_p) < 0) { - err_attr = "register_transvr_common_attr"; - goto err_transvr_qsfp_attr; - } - if (device_create_file(device_p, &dev_attr_comp_eth_10_40) < 0) { - err_attr = "dev_attr_comp_eth_10_40"; - goto err_transvr_qsfp_attr; - } - if (device_create_file(device_p, &dev_attr_power_cls) < 0) { - err_attr = "dev_attr_power_cls"; - goto err_transvr_qsfp_attr; - } - if (device_create_file(device_p, &dev_attr_soft_rx_los) < 0) { - err_attr = "soft_rx_los"; - goto err_transvr_qsfp_attr; - } - if (device_create_file(device_p, &dev_attr_soft_tx_disable) < 0) { - err_attr = "soft_tx_disable"; - goto err_transvr_qsfp_attr; - } - if (device_create_file(device_p, &dev_attr_auto_tx_disable) < 0) { - err_attr = "auto_tx_disable"; - goto err_transvr_qsfp_attr; - } - if (device_create_file(device_p, &dev_attr_soft_tx_fault) < 0) { - err_attr = "soft_tx_fault"; - goto err_transvr_qsfp_attr; - } - if (device_create_file(device_p, &dev_attr_eeprom) < 0) { - err_attr = "dev_attr_eeprom"; - goto err_transvr_qsfp_attr; - } - return 0; - -err_transvr_qsfp_attr: - SWPS_ERR("%s: %s\n", __func__, err_attr); - return -1; -} - - -static int -register_transvr_qsfp28_attr(struct device *device_p){ - - char *err_attr = NULL; - - if (register_transvr_qsfp_attr(device_p) < 0){ - err_attr = "register_transvr_qsfp_attr"; - goto err_transvr_qsfp28_attr; - } - if (device_create_file(device_p, &dev_attr_cdr) < 0) { - err_attr = "dev_attr_cdr"; - goto err_transvr_qsfp28_attr; - } - if (device_create_file(device_p, &dev_attr_rx_am) < 0) { - err_attr = "dev_attr_rx_am"; - goto err_transvr_qsfp28_attr; - } - return 0; - -err_transvr_qsfp28_attr: - SWPS_ERR("%s: %s\n", __func__, err_attr); - return -1; -} - - -static int -register_transvr_attr(struct device *device_p, - struct transvr_obj_s *transvr_obj){ - - switch (transvr_obj->layout){ - case TRANSVR_TYPE_SFP: - if (register_transvr_sfp_attr(device_p) < 0){ - goto err_reg_tvr_attr; - } - break; - case TRANSVR_TYPE_QSFP: - case TRANSVR_TYPE_QSFP_PLUS: - if (register_transvr_qsfp_attr(device_p) < 0){ - goto err_reg_tvr_attr; - } - break; - case TRANSVR_TYPE_QSFP_28: - if (register_transvr_qsfp28_attr(device_p) < 0){ - goto err_reg_tvr_attr; - } - break; - default: - goto err_reg_tvr_attr; - } - return 0; - -err_reg_tvr_attr: - SWPS_ERR("%s: fail! type=%d \n", __func__, transvr_obj->type); - return -1; -} - - -static int -register_ioexp_attr_sfp_1(struct device *device_p){ - /* Support machine type: - * - SFP : Magnolia - */ - char *err_attr = NULL; - - if (device_create_file(device_p, &dev_attr_present) < 0) { - err_attr = "dev_attr_present"; - goto err_ioexp_sfp1_attr; - } - if (device_create_file(device_p, &dev_attr_tx_fault) < 0) { - err_attr = "dev_attr_tx_fault"; - goto err_ioexp_sfp1_attr; - } - if (device_create_file(device_p, &dev_attr_rxlos) < 0) { - err_attr = "dev_attr_rxlos"; - goto err_ioexp_sfp1_attr; - } - if (device_create_file(device_p, &dev_attr_tx_disable) < 0) { - err_attr = "dev_attr_tx_disable"; - goto err_ioexp_sfp1_attr; - } - return 0; - -err_ioexp_sfp1_attr: - SWPS_ERR("Add device attribute:%s failure! \n",err_attr); - return -1; -} - - -static int -register_ioexp_attr_sfp_2(struct device *device_p){ - /* Support machine type: - * - SFP28 : Cypress - */ - char *err_attr = NULL; - - if (register_ioexp_attr_sfp_1(device_p) < 0){ - goto err_ioexp_sfp2_attr; - } - if (device_create_file(device_p, &dev_attr_hard_rs0) < 0) { - err_attr = "dev_attr_hard_rs0"; - goto err_ioexp_sfp2_attr; - } - if (device_create_file(device_p, &dev_attr_hard_rs1) < 0) { - err_attr = "dev_attr_hard_rs1"; - goto err_ioexp_sfp2_attr; - } - return 0; - -err_ioexp_sfp2_attr: - SWPS_ERR("Add device attribute:%s failure! \n",err_attr); - return -1; -} - - -static int -register_ioexp_attr_qsfp_1(struct device *device_p){ - /* Support machine type: - * - QSFP : Magnolia, Redwood, Hudson32i - * - QSFP+ : Magnolia, Redwood, Hudson32i - * - QSFP28: Redwood - */ - char *err_attr = NULL; - - if (device_create_file(device_p, &dev_attr_present) < 0) { - err_attr = "dev_attr_present"; - goto err_ioexp_qsfp1_attr; - } - if (device_create_file(device_p, &dev_attr_reset) < 0) { - err_attr = "dev_attr_reset"; - goto err_ioexp_qsfp1_attr; - } - if (device_create_file(device_p, &dev_attr_lpmod) < 0) { - err_attr = "dev_attr_lpmod"; - goto err_ioexp_qsfp1_attr; - } - if (device_create_file(device_p, &dev_attr_modsel) < 0) { - err_attr = "dev_attr_modsel"; - goto err_ioexp_qsfp1_attr; - } - return 0; - -err_ioexp_qsfp1_attr: - SWPS_ERR("Add device attribute:%s failure! \n",err_attr); - return -1; -} - - -static int -register_modctl_attr(struct device *device_p){ - - char *err_msg = NULL; - - if (device_create_file(device_p, &dev_attr_platform) < 0) { - err_msg = "dev_attr_platform"; - goto err_reg_modctl_attr; - } - if (device_create_file(device_p, &dev_attr_version) < 0) { - err_msg = "dev_attr_version"; - goto err_reg_modctl_attr; - } - if (device_create_file(device_p, &dev_attr_status) < 0) { - err_msg = "dev_attr_status"; - goto err_reg_modctl_attr; - } - if (device_create_file(device_p, &dev_attr_reset_i2c) < 0) { - err_msg = "dev_attr_reset_i2c"; - goto err_reg_modctl_attr; - } - if (device_create_file(device_p, &dev_attr_reset_swps) < 0) { - err_msg = "dev_attr_reset_swps"; - goto err_reg_modctl_attr; - } - if (device_create_file(device_p, &dev_attr_auto_config) < 0) { - err_msg = "dev_attr_auto_config"; - goto err_reg_modctl_attr; - } - if (device_create_file(device_p, &dev_attr_eeprom_update) < 0) { - err_msg = "dev_attr_eeprom_update"; - goto err_reg_modctl_attr; - } - return 0; - -err_reg_modctl_attr: - SWPS_ERR("%s: %s\n", __func__, err_msg); - return -1; -} - - -static int -register_ioexp_attr(struct device *device_p, - struct transvr_obj_s *transvr_obj){ - - char *err_msg = "ERR"; - - switch (transvr_obj->ioexp_obj_p->ioexp_type){ - case IOEXP_TYPE_MAGINOLIA_NAB: - if (register_ioexp_attr_sfp_1(device_p) < 0){ - err_msg = "register_ioexp_attr_sfp_1 fail"; - goto err_reg_ioexp_attr; - } - break; - case IOEXP_TYPE_CYPRESS_NABC: - if (register_ioexp_attr_sfp_2(device_p) < 0){ - err_msg = "register_ioexp_attr_sfp_2 fail"; - goto err_reg_ioexp_attr; - } - break; - case IOEXP_TYPE_MAGINOLIA_7AB: - case IOEXP_TYPE_SPRUCE_7AB: - case IOEXP_TYPE_CYPRESS_7ABC: - case IOEXP_TYPE_REDWOOD_P01P08: - case IOEXP_TYPE_REDWOOD_P09P16: - case IOEXP_TYPE_HUDSON32IGA_P01P08: - case IOEXP_TYPE_HUDSON32IGA_P09P16: - if (register_ioexp_attr_qsfp_1(device_p) < 0){ - err_msg = "register_ioexp_attr_qsfp_1 fail"; - goto err_reg_ioexp_attr; - } - break; - - default: - err_msg = "Unknow type"; - goto err_reg_ioexp_attr; - } - return 0; - -err_reg_ioexp_attr: - SWPS_ERR("%s: %s :%d \n", - __func__, err_msg, transvr_obj->ioexp_obj_p->ioexp_type); - return -1; -} - - -static int -register_modctl_device(void) { - - struct device *device_p = NULL; - int minor_comm = 0; /* Default minor number for common device */ - dev_t dev_num = MKDEV(ctl_major, minor_comm); - char *err_msg = "ERROR"; - - device_p = device_create(swp_class_p, /* struct class *cls */ - NULL, /* struct device *parent */ - dev_num, /* dev_t devt */ - NULL, /* void *private_data */ - SWP_DEV_MODCTL); /* const char *fmt */ - if (IS_ERR(device_p)){ - err_msg = "device_create fail"; - goto err_register_modctl_device_1; - } - if (register_modctl_attr(device_p) < 0) { - err_msg = "register_modctl_attr fail"; - goto err_register_modctl_device_2; - } - return 0; - -err_register_modctl_device_2: - device_unregister(device_p); - device_destroy(swp_class_p, dev_num); -err_register_modctl_device_1: - SWPS_ERR("%s: %s\n", __func__, err_msg); - return -1; -} - - -static int -register_port_device(char *dev_name, - dev_t dev_num, - struct transvr_obj_s *transvr_obj){ - - struct device *device_p = NULL; - device_p = device_create(swp_class_p, /* struct class *cls */ - NULL, /* struct device *parent */ - dev_num, /* dev_t devt */ - transvr_obj, /* void *private_data */ - dev_name); /* const char *fmt */ - if (IS_ERR(device_p)){ - goto err_regswp_create_dev; - } - if (register_transvr_attr(device_p, transvr_obj) < 0){ - goto err_regswp_reg_attr; - } - if (register_ioexp_attr(device_p, transvr_obj) < 0){ - goto err_regswp_reg_attr; - } - return 0; - -err_regswp_reg_attr: - device_unregister(device_p); - device_destroy(swp_class_p, dev_num); -err_regswp_create_dev: - SWPS_ERR("%s fail! :%s\n", __func__, dev_name); - return -1; -} - - -static int -register_swp_module(void){ - - dev_t ctl_devt = 0; - dev_t port_devt = 0; - int dev_total = port_total + 1; /* char_dev for module control */ - - /* Register device number */ - if (alloc_chrdev_region(&ctl_devt, 0, 1, SWP_DEV_MODCTL) < 0){ - SWPS_WARN("Allocate CTL MAJOR failure! \n"); - goto err_register_swp_module_1; - } - if (alloc_chrdev_region(&port_devt, 0, dev_total, SWP_CLS_NAME) < 0){ - SWPS_WARN("Allocate PORT MAJOR failure! \n"); - goto err_register_swp_module_2; - } - ctl_major = MAJOR(ctl_devt); - port_major = MAJOR(port_devt); - - /* Create class object */ - swp_class_p = class_create(THIS_MODULE, SWP_CLS_NAME); - if (IS_ERR(swp_class_p)) { - SWPS_ERR("Create class failure! \n"); - goto err_register_swp_module_3; - } - return 0; - -err_register_swp_module_3: - unregister_chrdev_region(MKDEV(port_major, 0), port_total); -err_register_swp_module_2: - unregister_chrdev_region(MKDEV(ctl_major, 0), 1); -err_register_swp_module_1: - return -1; -} - - -/* ========== Module initial relate ========== - */ -static int -create_ioexp_objs(void) { - - int i, run_mod; - - /* Clean IOEXP object */ - clean_ioexp_objs(); - /* Get running mode */ - run_mod = IOEXP_MODE_DIRECT; - if (SWP_POLLING_ENABLE){ - run_mod = IOEXP_MODE_POLLING; - } - /* Create IOEXP object */ - for(i=0; i devlen_max) { - snprintf(err_msg, sizeof(err_msg), - "SWP_DEV_PORT too long!"); - goto err_initport_create_tranobj; - } - memset(dev_name, 0, sizeof(dev_name)); - snprintf(dev_name, devlen_max, "%s%d", SWP_DEV_PORT, port_id); - /* Create transceiver object */ - ioexp_obj_p = get_ioexp_obj(ioexp_id); - if (!ioexp_obj_p){ - snprintf(err_msg, sizeof(err_msg), - "IOEXP object:%d not exist", ioexp_id); - goto err_initport_create_tranobj; - } - transvr_obj_p = create_transvr_obj(dev_name, chan_id, ioexp_obj_p, - ioexp_virt_offset, transvr_type, - chipset_type, run_mod); - if (!transvr_obj_p){ - snprintf(err_msg, sizeof(err_msg), - "Create transceiver object fail :%s", dev_name); - goto err_initport_create_tranobj; - } - - transvr_obj_p->port_no = minor_curr; - - /* Setup Lane_ID mapping */ - i = ARRAY_SIZE(port_layout[minor_curr].lane_id); - j = ARRAY_SIZE(transvr_obj_p->lane_id); - if (i != j) { - snprintf(err_msg, sizeof(err_msg), - "Lane_id size inconsistent %d/%d", i, j); - goto err_initport_reg_device; - } - memcpy(transvr_obj_p->lane_id, port_layout[minor_curr].lane_id, i*sizeof(int)); - /* Create and register device object */ - if (register_port_device(dev_name, MKDEV(port_major, minor_curr), transvr_obj_p) < 0){ - snprintf(err_msg, sizeof(err_msg), - "register_port_device fail"); - goto err_initport_reg_device; - } - /* Setup device_ptr of transvr_obj */ - dev_p = get_swpdev_by_name(dev_name); - if (!dev_p){ - snprintf(err_msg, sizeof(err_msg), - "get_swpdev_by_name fail"); - goto err_initport_reg_device; - } - transvr_obj_p->transvr_dev_p = dev_p; - /* Success */ - ok_count++; - } - SWPS_INFO("%s: initialed %d port-dev",__func__, ok_count); - return 0; - -err_initport_reg_device: - kfree(transvr_obj_p); -err_initport_create_tranobj: - clean_port_obj(); - SWPS_ERR("%s: %s", __func__, err_msg); - SWPS_ERR("Dump: :%d :%d :%d :%d :%d :%d\n", - port_id, chan_id, ioexp_id, ioexp_virt_offset, transvr_type, run_mod); - return -1; -} - - -static int -init_dev_topology(void){ - - int err; - char *emsg = "ERR"; - flag_mod_state = SWP_STATE_NORMAL; - - err = init_ioexp_objs(); - switch(err){ - case 0: /* Normal */ - SWPS_DEBUG("%s: normal case\n", __func__); - break; - - case -1: /* topology error */ - SWPS_DEBUG("%s: detect tier-1 topology initial failure :%d\n", - __func__, err); - /* Reset and isolate */ - err = reset_i2c_topology(); - if (err < 0) { - emsg = "reset i2c topology fail"; - goto err_init_dev_topology; - } - /* Re-initial again */ - err = init_ioexp_objs(); - if (err < 0) { - emsg = "re-init ioexp objects fail"; - goto err_init_dev_topology; - } - break; - - case -2: /* Internal error */ - SWPS_DEBUG("%s: internal error case\n", __func__); - err = -2; - emsg = "internal error"; - goto err_init_dev_topology; - - default: - SWPS_DEBUG("%s: undefined error case\n", __func__); - emsg = "undefined error case"; - goto err_init_dev_topology; - } - SWPS_DEBUG("%s: initial I2C topology success\n", __func__); - return 0; - -err_init_dev_topology: - SWPS_ERR("%s: %s :%d\n", __func__, emsg, err); - return -1; -} - - -static int -init_polling_task(void){ - - if (SWP_POLLING_ENABLE){ - schedule_delayed_work(&swp_polling, _get_polling_period()); - } - return 0; -} - - -static int -init_swps_common(void){ - - char *err_msg = "ERR"; - - auto_config = 0; - if ((SWP_AUTOCONFIG_ENABLE) && (SWP_POLLING_ENABLE)){ - auto_config = 1; - } - if (register_modctl_device() < 0) { - err_msg = "register_modctl_device fail"; - goto err_init_swps_common_1; - } - if (_update_auto_config_2_trnasvr() < 0) { - err_msg = "_update_auto_config_2_trnasvr fail"; - goto err_init_swps_common_1; - } - if (init_polling_task() < 0){ - err_msg = "init_polling_task fail"; - goto err_init_swps_common_1; - } - return 0; - -err_init_swps_common_1: - clean_swps_common(); - SWPS_ERR("%s: %s\n", __func__, err_msg); - return -1; -} - - -static int __init -swp_module_init(void){ - - if (get_platform_type() < 0){ - goto err_init_out; - } - if (get_layout_info() < 0){ - goto err_init_out; - } - if (register_swp_module() < 0){ - goto err_init_out; - } - if (create_ioexp_objs() < 0){ - goto err_init_ioexp; - } - if (create_port_objs() < 0){ - goto err_init_portobj; - } - if (init_mux_gpio(gpio_rest_mux) < 0){ - goto err_init_mux; - } - if (init_dev_topology() < 0){ - goto err_init_topology; - } - if (init_swps_common() < 0){ - goto err_init_topology; - } - SWPS_INFO("Inventec switch-port module V.%s initial success.\n", SWP_VERSION); - return 0; - - -err_init_topology: - clean_mux_gpio(); -err_init_mux: - clean_port_obj(); -err_init_portobj: - clean_ioexp_objs(); -err_init_ioexp: - class_unregister(swp_class_p); - class_destroy(swp_class_p); - unregister_chrdev_region(MKDEV(ctl_major, 0), 1); - unregister_chrdev_region(MKDEV(port_major, 0), port_total); -err_init_out: - SWPS_ERR("Inventec switch-port module V.%s initial failure.\n", SWP_VERSION); - return -1; -} - - -static void __exit -swp_module_exit(void){ - - clean_swps_common(); - clean_port_obj(); - clean_ioexp_objs(); - clean_mux_gpio(); - class_unregister(swp_class_p); - class_destroy(swp_class_p); - unregister_chrdev_region(MKDEV(ctl_major, 0), 1); - unregister_chrdev_region(MKDEV(port_major, 0), port_total); - SWPS_INFO("Remove Inventec switch-port module success.\n"); -} - - -/* Module information */ -MODULE_AUTHOR(SWP_AUTHOR); -MODULE_DESCRIPTION(SWP_DESC); -MODULE_VERSION(SWP_VERSION); -MODULE_LICENSE(SWP_LICENSE); - -module_init(swp_module_init); -module_exit(swp_module_exit); - - - - - - diff --git a/packages/platforms/inventec/x86-64/d7054q28b/modules/builds/src/inv_swps.h b/packages/platforms/inventec/x86-64/d7054q28b/modules/builds/src/inv_swps.h deleted file mode 100644 index 8152299eb..000000000 --- a/packages/platforms/inventec/x86-64/d7054q28b/modules/builds/src/inv_swps.h +++ /dev/null @@ -1,749 +0,0 @@ -/************************************************************************* - * - * inv_swps.h - * - * 2018 Inventec Corporation - * All Rights Reserved. - * - * NOTICE: All information contained herein is, and remains - * the property of Inventec Corp. and its suppliers, - * if any. The intellectual and technical concepts contained - * herein are proprietary to Inventec Corporation and its suppliers - * and may be covered by U.S. and Foreign Patents, patents in process, - * and are protected by trade secret or copyright law. - * - ************************************************************************/ - -#ifndef INV_SWPS_H -#define INV_SWPS_H - -#include "transceiver.h" -#include "io_expander.h" -#include "inv_mux.h" - -/* Module settings */ -#define SWP_CLS_NAME "swps" -#define SWP_DEV_PORT "port" -#define SWP_DEV_MODCTL "module" -#define SWP_RESET_PWD "inventec" -#define SWP_POLLING_PERIOD (300) /* msec */ -#define SWP_POLLING_ENABLE (1) -#define SWP_AUTOCONFIG_ENABLE (1) - -/* Module information */ -#define SWP_AUTHOR "Neil " -#define SWP_DESC "Inventec port and transceiver driver" -#define SWP_VERSION "4.2.3" -#define SWP_LICENSE "GPL" - -#define SWPS_KERN_VER_AF_3_10 (1) - -/* Module status define */ -#define SWP_STATE_NORMAL (0) -#define SWP_STATE_I2C_DIE (-91) - -#define INV_BATOI(a) ((a>='0'&&a<='9')?(a-'0'):(-1)) -#define INV_BATOX(a) ((a>='0'&&a<='9')?(a-'0'):((a>='a'&&a<='f')?(a-'a'+10):((a >='A'&&a<='F')?(a-'A'+10):-1))) - -/* [Note]: - * Functions and mechanism for auto-detect platform type is ready, - * But HW and BIOS not ready! We need to wait them. - * So, please do not use PLATFORM_TYPE_AUTO until they are ready. - * (2016.06.13) - */ -#define PLATFORM_TYPE_AUTO (100) -#define PLATFORM_TYPE_MAGNOLIA (111) -#define PLATFORM_TYPE_MAGNOLIA_FNC (112) -#define PLATFORM_TYPE_REDWOOD (121) -#define PLATFORM_TYPE_REDWOOD_FSL (122) -#define PLATFORM_TYPE_HUDSON32I_GA (131) -#define PLATFORM_TYPE_SPRUCE (141) -#define PLATFORM_TYPE_CYPRESS_GA1 (151) /* Up -> Down */ -#define PLATFORM_TYPE_CYPRESS_GA2 (152) /* Down -> Up */ -#define PLATFORM_TYPE_CYPRESS_BAI (153) /* Down -> Up */ -/* Current running platfrom */ -#define PLATFORM_SETTINGS PLATFORM_TYPE_CYPRESS_GA2 - -/* Define platform flag and kernel version */ -#if (PLATFORM_SETTINGS == PLATFORM_TYPE_MAGNOLIA) - #define SWPS_MAGNOLIA (1) - #define SWPS_KERN_VER_BF_3_8 (1) -#elif (PLATFORM_SETTINGS == PLATFORM_TYPE_MAGNOLIA_FNC) - #define SWPS_MAGNOLIA (1) - #define SWPS_KERN_VER_AF_3_10 (1) -#elif (PLATFORM_SETTINGS == PLATFORM_TYPE_REDWOOD) - #define SWPS_REDWOOD (1) - #define SWPS_KERN_VER_BF_3_8 (1) -#elif (PLATFORM_SETTINGS == PLATFORM_TYPE_REDWOOD_FSL) - #define SWPS_REDWOOD_FSL (1) - #define SWPS_KERN_VER_BF_3_8 (1) -#elif (PLATFORM_SETTINGS == PLATFORM_TYPE_HUDSON32I_GA) - #define SWPS_HUDSON32I_GA (1) - #define SWPS_KERN_VER_BF_3_8 (1) -#elif (PLATFORM_SETTINGS == PLATFORM_TYPE_SPRUCE) - #define SWPS_SPRUCE (1) - #define SWPS_KERN_VER_BF_3_8 (1) -#elif (PLATFORM_SETTINGS == PLATFORM_TYPE_CYPRESS_GA1) - #define SWPS_CYPRESS_GA1 (1) - #define SWPS_KERN_VER_BF_3_8 (1) -#elif (PLATFORM_SETTINGS == PLATFORM_TYPE_CYPRESS_GA2) - #define SWPS_CYPRESS_GA2 (1) - #define SWPS_KERN_VER_BF_3_8 (1) -#elif (PLATFORM_SETTINGS == PLATFORM_TYPE_CYPRESS_BAI) - #define SWPS_CYPRESS_BAI (1) - #define SWPS_KERN_VER_AF_3_10 (1) -#endif - - -struct inv_platform_s { - int id; - char name[64]; -}; - -struct inv_ioexp_layout_s { - int ioexp_id; - int ioexp_type; - struct ioexp_addr_s addr[4]; -}; - -struct inv_port_layout_s { - int port_id; - int chan_id; - int ioexp_id; - int ioexp_offset; - int transvr_type; - int chipset_type; - int lane_id[8]; -}; - - -/* ========================================== - * Inventec Platform Settings - * ========================================== - */ -struct inv_platform_s platform_map[] = { - {PLATFORM_TYPE_AUTO, "Auto-Detect" }, - {PLATFORM_TYPE_MAGNOLIA, "Magnolia" }, - {PLATFORM_TYPE_MAGNOLIA_FNC, "Magnolia_FNC" }, - {PLATFORM_TYPE_REDWOOD, "Redwood" }, - {PLATFORM_TYPE_REDWOOD_FSL, "Redwood_FSL" }, - {PLATFORM_TYPE_HUDSON32I_GA, "Hudson32i" }, - {PLATFORM_TYPE_SPRUCE, "Spruce" }, - {PLATFORM_TYPE_CYPRESS_GA1, "Cypress_GA1" }, - {PLATFORM_TYPE_CYPRESS_GA2, "Cypress_GA2" }, - {PLATFORM_TYPE_CYPRESS_BAI, "Cypress_BAI" }, -}; - - -/* ========================================== - * Magnolia Layout configuration - * ========================================== - */ -#ifdef SWPS_MAGNOLIA -unsigned magnolia_gpio_rest_mux = MUX_RST_GPIO_48_PAC9548; - -struct inv_ioexp_layout_s magnolia_ioexp_layout[] = { - /* IOEXP_ID / IOEXP_TYPE / { Chan_ID, Chip_addr, Read_offset, Write_offset, config_offset, data_default, conf_default } */ - {0, IOEXP_TYPE_MAGINOLIA_NAB, { {2, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {2, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, }, /* addr[1] = I/O Expander N B */ - }, - {1, IOEXP_TYPE_MAGINOLIA_NAB, { {3, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {3, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, }, /* addr[1] = I/O Expander N B */ - }, - {2, IOEXP_TYPE_MAGINOLIA_NAB, { {4, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {4, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, }, /* addr[1] = I/O Expander N B */ - }, - {3, IOEXP_TYPE_MAGINOLIA_NAB, { {5, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {5, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, }, /* addr[1] = I/O Expander N B */ - }, - {4, IOEXP_TYPE_MAGINOLIA_NAB, { {6, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {6, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, }, /* addr[1] = I/O Expander N B */ - }, - {5, IOEXP_TYPE_MAGINOLIA_NAB, { {7, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {7, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, }, /* addr[1] = I/O Expander N B */ - }, - {6, IOEXP_TYPE_MAGINOLIA_7AB, { {8, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[0] = I/O Expander 7 A */ - {8, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xf0, 0x33}, }, }, /* addr[1] = I/O Expander 7 B */ - }, -}; - -struct inv_port_layout_s magnolia_port_layout[] = { - /* Port_ID / Chan_ID / IOEXP_ID / IOEXP_VIRT_OFFSET / TRANSCEIVER_TYPE / BCM_CHIP_TYPE / LANE_ID */ - { 0, 10, 0, 0, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 16} }, - { 1, 11, 0, 1, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 15} }, - { 2, 12, 0, 2, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 14} }, - { 3, 13, 0, 3, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 13} }, - { 4, 14, 0, 4, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 24} }, - { 5, 15, 0, 5, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 23} }, - { 6, 16, 0, 6, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 22} }, - { 7, 17, 0, 7, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 21} }, - { 8, 18, 1, 0, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 28} }, - { 9, 19, 1, 1, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 27} }, - {10, 20, 1, 2, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 26} }, - {11, 21, 1, 3, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 25} }, - {12, 22, 1, 4, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 32} }, - {13, 23, 1, 5, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 31} }, - {14, 24, 1, 6, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 30} }, - {15, 25, 1, 7, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 29} }, - {16, 26, 2, 0, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 48} }, - {17, 27, 2, 1, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 47} }, - {18, 28, 2, 2, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 46} }, - {19, 29, 2, 3, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 45} }, - {20, 30, 2, 4, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 52} }, - {21, 31, 2, 5, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 51} }, - {22, 32, 2, 6, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 50} }, - {23, 33, 2, 7, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 49} }, - {24, 34, 3, 0, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 56} }, - {25, 35, 3, 1, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 55} }, - {26, 36, 3, 2, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 54} }, - {27, 37, 3, 3, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 53} }, - {28, 38, 3, 4, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 60} }, - {29, 39, 3, 5, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 59} }, - {30, 40, 3, 6, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 58} }, - {31, 41, 3, 7, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 57} }, - {32, 42, 4, 0, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 64} }, - {33, 43, 4, 1, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 63} }, - {34, 44, 4, 2, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 62} }, - {35, 45, 4, 3, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 61} }, - {36, 46, 4, 4, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 68} }, - {37, 47, 4, 5, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 67} }, - {38, 48, 4, 6, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 66} }, - {39, 49, 4, 7, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 65} }, - {40, 50, 5, 0, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 72} }, - {41, 51, 5, 1, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 71} }, - {42, 52, 5, 2, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 70} }, - {43, 53, 5, 3, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 69} }, - {44, 54, 5, 4, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 76} }, - {45, 55, 5, 5, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 75} }, - {46, 56, 5, 6, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 74} }, - {47, 57, 5, 7, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 73} }, - {48, 58, 6, 0, TRANSVR_TYPE_QSFP, BCM_CHIP_TYPE_TRIDENT_2, { 81, 82, 83, 84} }, - {49, 59, 6, 1, TRANSVR_TYPE_QSFP, BCM_CHIP_TYPE_TRIDENT_2, { 77, 78, 79, 80} }, - {50, 60, 6, 2, TRANSVR_TYPE_QSFP, BCM_CHIP_TYPE_TRIDENT_2, { 97, 98, 99,100} }, - {51, 61, 6, 3, TRANSVR_TYPE_QSFP, BCM_CHIP_TYPE_TRIDENT_2, {101,102,103,104} }, - {52, 62, 6, 4, TRANSVR_TYPE_QSFP, BCM_CHIP_TYPE_TRIDENT_2, {105,106,107,108} }, - {53, 63, 6, 5, TRANSVR_TYPE_QSFP, BCM_CHIP_TYPE_TRIDENT_2, {109,110,111,112} }, -}; -#endif - - -/* ========================================== - * Redwood Layout configuration - * ========================================== - */ -#ifdef SWPS_REDWOOD -unsigned redwood_gpio_rest_mux = MUX_RST_GPIO_48_PAC9548; - -struct inv_ioexp_layout_s redwood_ioexp_layout[] = { - /* IOEXP_ID / IOEXP_TYPE / { Chan_ID, Chip_addr, Read_offset, Write_offset, config_offset, data_default, conf_default } */ - {0, IOEXP_TYPE_REDWOOD_P01P08, { {4, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[0] = I/O Expander 1-4 A */ - {4, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[1] = I/O Expander 1-4 B */ - {0, 0x25, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 5 B */ - }, - {1, IOEXP_TYPE_REDWOOD_P09P16, { {5, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[0] = I/O Expander 1-4 A */ - {5, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[1] = I/O Expander 1-4 B */ - {0, 0x25, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 5 B */ - }, - {2, IOEXP_TYPE_REDWOOD_P01P08, { {2, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[0] = I/O Expander 1-4 A */ - {2, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[1] = I/O Expander 1-4 B */ - {0, 0x24, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 5 B */ - }, - {3, IOEXP_TYPE_REDWOOD_P09P16, { {3, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[0] = I/O Expander 1-4 A */ - {3, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[1] = I/O Expander 1-4 B */ - {0, 0x24, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 5 B */ - }, -}; - -struct inv_port_layout_s redwood_port_layout[] = { - /* Port_ID / Chan_ID / IOEXP_ID / IOEXP_VIRT_OFFSET / TRANSCEIVER_TYPE / BCM_CHIP_TYPE / LANE_ID */ - { 0, 22, 0, 0, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 1, 2, 3, 4} }, - { 1, 23, 0, 1, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 5, 6, 7, 8} }, - { 2, 24, 0, 2, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 9, 10, 11, 12} }, - { 3, 25, 0, 3, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 13, 14, 15, 16} }, - { 4, 26, 0, 4, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 17, 18, 19, 20} }, - { 5, 27, 0, 5, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 21, 22, 23, 24} }, - { 6, 28, 0, 6, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 25, 26, 27, 28} }, - { 7, 29, 0, 7, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 29, 30, 31, 32} }, - { 8, 30, 1, 0, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 33, 34, 35, 36} }, - { 9, 31, 1, 1, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 37, 38, 39, 40} }, - {10, 32, 1, 2, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 41, 42, 43, 44} }, - {11, 33, 1, 3, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 45, 46, 47, 48} }, - {12, 34, 1, 4, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 49, 50, 51, 52} }, - {13, 35, 1, 5, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 53, 54, 55, 56} }, - {14, 36, 1, 6, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 57, 58, 59, 60} }, - {15, 37, 1, 7, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 61, 62, 63, 64} }, - {16, 6, 2, 0, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 65, 66, 67, 68} }, - {17, 7, 2, 1, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 69, 70, 71, 72} }, - {18, 8, 2, 2, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 73, 74, 75, 76} }, - {19, 9, 2, 3, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 77, 78, 79, 80} }, - {20, 10, 2, 4, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 81, 82, 83, 84} }, - {21, 11, 2, 5, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 85, 86, 87, 88} }, - {22, 12, 2, 6, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 89, 90, 91, 92} }, - {23, 13, 2, 7, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 93, 94, 95, 96} }, - {24, 14, 3, 0, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 97, 98, 99,100} }, - {25, 15, 3, 1, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {101,102,103,104} }, - {26, 16, 3, 2, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {105,106,107,108} }, - {27, 17, 3, 3, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {109,110,111,112} }, - {28, 18, 3, 4, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {113,114,115,116} }, - {29, 19, 3, 5, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {117,118,119,120} }, - {30, 20, 3, 6, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {121,122,123,124} }, - {31, 21, 3, 7, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {125,126,127,128} }, -}; -#endif - - -/* ========================================== - * Hudson32i Layout configuration - * ========================================== - */ -#ifdef SWPS_HUDSON32I_GA -unsigned hudsin32iga_gpio_rest_mux = MUX_RST_GPIO_48_PAC9548; - -struct inv_ioexp_layout_s hudson32iga_ioexp_layout[] = { - /* IOEXP_ID / IOEXP_TYPE / { Chan_ID, Chip_addr, Read_offset, Write_offset, config_offset, data_default, conf_default } */ - {0, IOEXP_TYPE_HUDSON32IGA_P01P08, { {2, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[0] = I/O Expander A */ - {2, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[1] = I/O Expander B */ - {0, 0x24, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 0x24 */ - }, - {1, IOEXP_TYPE_HUDSON32IGA_P09P16, { {3, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[0] = I/O Expander A */ - {3, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[1] = I/O Expander B */ - {0, 0x24, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 0x24 */ - }, - {2, IOEXP_TYPE_HUDSON32IGA_P01P08, { {4, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[0] = I/O Expander A */ - {4, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[1] = I/O Expander B */ - {0, 0x25, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 0x25 */ - }, - {3, IOEXP_TYPE_HUDSON32IGA_P09P16, { {5, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[0] = I/O Expander A */ - {5, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[1] = I/O Expander B */ - {0, 0x25, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 0x25 */ - }, -}; - -struct inv_port_layout_s hudson32iga_port_layout[] = { - /* Port_ID / Chan_ID / IOEXP_ID / IOEXP_VIRT_OFFSET / TRANSCEIVER_TYPE / BCM_CHIP_TYPE / LANE_ID */ - { 0, 6, 0, 0, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, { 1, 2, 3, 4} }, - { 1, 7, 0, 1, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, { 5, 6, 7, 8} }, - { 2, 8, 0, 2, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, { 9, 10, 11, 12} }, - { 3, 9, 0, 3, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, { 13, 14, 15, 16} }, - { 4, 10, 0, 4, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, { 17, 18, 19, 20} }, - { 5, 11, 0, 5, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, { 21, 22, 23, 24} }, - { 6, 12, 0, 6, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, { 25, 26, 27, 28} }, - { 7, 13, 0, 7, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, { 29, 30, 31, 32} }, - { 8, 14, 1, 0, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, { 33, 34, 35, 36} }, - { 9, 15, 1, 1, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, { 37, 38, 39, 40} }, - {10, 16, 1, 2, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, { 41, 42, 43, 44} }, - {11, 17, 1, 3, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, { 45, 46, 47, 48} }, - {12, 18, 1, 4, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, { 49, 50, 51, 52} }, - {13, 19, 1, 5, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, { 53, 54, 55, 56} }, - {14, 20, 1, 6, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, { 57, 58, 59, 60} }, - {15, 21, 1, 7, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, { 61, 62, 63, 64} }, - {16, 22, 2, 0, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, { 65, 66, 67, 68} }, - {17, 23, 2, 1, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, { 69, 70, 71, 72} }, - {18, 24, 2, 2, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, { 73, 74, 75, 76} }, - {19, 25, 2, 3, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, { 77, 78, 79, 80} }, - {20, 26, 2, 4, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, { 81, 82, 83, 84} }, - {21, 27, 2, 5, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, { 85, 86, 87, 88} }, - {22, 28, 2, 6, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, { 89, 90, 91, 92} }, - {23, 29, 2, 7, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, { 93, 94, 95, 96} }, - {24, 30, 3, 0, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, { 97, 98, 99,100} }, - {25, 31, 3, 1, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, {101,102,103,104} }, - {26, 32, 3, 2, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, {105,106,107,108} }, - {27, 33, 3, 3, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, {109,110,111,112} }, - {28, 34, 3, 4, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, {113,114,115,116} }, - {29, 35, 3, 5, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, {117,118,119,120} }, - {30, 36, 3, 6, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, {121,122,123,124} }, - {31, 37, 3, 7, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, {125,126,127,128} }, -}; -#endif - - -/* ========================================== - * Spruce Layout configuration - * ========================================== - */ -#ifdef SWPS_SPRUCE -unsigned spruce_gpio_rest_mux = MUX_RST_GPIO_48_PAC9548; - -struct inv_ioexp_layout_s spruce_ioexp_layout[] = { - /* IOEXP_ID / IOEXP_TYPE / { Chan_ID, Chip_addr, Read_offset, Write_offset, config_offset, data_default, conf_default } */ - {0, IOEXP_TYPE_SPRUCE_7AB, { {2, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[0] = I/O Expander 7A */ - {2, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xf0, 0x33}, }, }, /* addr[2] = I/O Expander 7B */ - }, -}; - -struct inv_port_layout_s spruce_port_layout[] = { - /* Port_ID / Chan_ID / IOEXP_ID / IOEXP_VIRT_OFFSET / TRANSCEIVER_TYPE / BCM_CHIP_TYPE / LANE_ID */ - { 0, 6, 0, 0, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, { 81, 82, 83, 84} }, - { 1, 7, 0, 1, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, { 77, 78, 79, 80} }, - { 2, 8, 0, 2, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, { 97, 98, 99,100} }, - { 3, 9, 0, 3, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, {101,102,103,104} }, - { 4, 10, 0, 4, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, {105,106,107,108} }, - { 5, 11, 0, 5, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, {109,110,111,112} }, -}; -#endif - - -/* ========================================== - * Cypress Layout configuration (Inventec version [Up->Down]) - * ========================================== - */ -#ifdef SWPS_CYPRESS_GA1 -unsigned cypress_ga1_gpio_rest_mux = MUX_RST_GPIO_69_PAC9548; - -struct inv_ioexp_layout_s cypress_ga1_ioexp_layout[] = { - /* IOEXP_ID / IOEXP_TYPE / { Chan_ID, Chip_addr, Read_offset, Write_offset, config_offset, data_default, conf_default } */ - {0, IOEXP_TYPE_CYPRESS_NABC, { {2, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {2, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {2, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {1, IOEXP_TYPE_CYPRESS_NABC, { {3, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {3, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {3, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {2, IOEXP_TYPE_CYPRESS_NABC, { {4, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {4, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {4, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {3, IOEXP_TYPE_CYPRESS_NABC, { {5, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {5, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {5, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {4, IOEXP_TYPE_CYPRESS_NABC, { {6, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {6, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {6, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {5, IOEXP_TYPE_CYPRESS_NABC, { {7, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {7, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {7, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {6, IOEXP_TYPE_CYPRESS_7ABC, { {8, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xc0, 0xc0}, }, /* addr[0] = I/O Expander 7 A */ - {8, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xc0, 0xc0}, {0xff, 0xc0}, }, /* addr[1] = I/O Expander 7 B */ - {8, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 7 C */ - }, -}; - -struct inv_port_layout_s cypress_ga1_port_layout[] = { - /* Port_ID / Chan_ID / IOEXP_ID / IOEXP_VIRT_OFFSET / TRANSCEIVER_TYPE / BCM_CHIP_TYPE / LANE_ID */ - { 0, 10, 0, 0, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 1} }, - { 1, 11, 0, 1, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 2} }, - { 2, 12, 0, 2, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 3} }, - { 3, 13, 0, 3, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 4} }, - { 4, 14, 0, 4, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 5} }, - { 5, 15, 0, 5, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 6} }, - { 6, 16, 0, 6, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 7} }, - { 7, 17, 0, 7, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 8} }, - { 8, 18, 1, 0, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 9} }, - { 9, 19, 1, 1, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 10} }, - {10, 20, 1, 2, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 11} }, - {11, 21, 1, 3, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 12} }, - {12, 22, 1, 4, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 21} }, - {13, 23, 1, 5, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 22} }, - {14, 24, 1, 6, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 23} }, - {15, 25, 1, 7, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 24} }, - {16, 26, 2, 0, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 33} }, - {17, 27, 2, 1, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 34} }, - {18, 28, 2, 2, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 35} }, - {19, 29, 2, 3, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 36} }, - {20, 30, 2, 4, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 37} }, - {21, 31, 2, 5, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 38} }, - {22, 32, 2, 6, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 39} }, - {23, 33, 2, 7, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 40} }, - {24, 34, 3, 0, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 41} }, - {25, 35, 3, 1, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 42} }, - {26, 36, 3, 2, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 43} }, - {27, 37, 3, 3, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 44} }, - {28, 38, 3, 4, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 49} }, - {29, 39, 3, 5, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 50} }, - {30, 40, 3, 6, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 51} }, - {31, 41, 3, 7, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 52} }, - {32, 42, 4, 0, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 53} }, - {33, 43, 4, 1, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 54} }, - {34, 44, 4, 2, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 55} }, - {35, 45, 4, 3, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 56} }, - {36, 46, 4, 4, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 65} }, - {37, 47, 4, 5, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 66} }, - {38, 48, 4, 6, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 67} }, - {39, 49, 4, 7, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 68} }, - {40, 50, 5, 0, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 69} }, - {41, 51, 5, 1, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 70} }, - {42, 52, 5, 2, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 71} }, - {43, 53, 5, 3, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 72} }, - {44, 54, 5, 4, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 81} }, - {45, 55, 5, 5, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 82} }, - {46, 56, 5, 6, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 83} }, - {47, 57, 5, 7, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 84} }, - {48, 58, 6, 0, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 97, 98, 99,100} }, - {49, 59, 6, 1, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 85, 86, 87, 88} }, - {50, 60, 6, 2, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {101,102,103,104} }, - {51, 61, 6, 3, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {105,106,107,108} }, - {52, 62, 6, 4, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {109,110,111,112} }, - {53, 63, 6, 5, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {117,118,119,120} }, -}; -#endif - - -/* ========================================== - * Cypress Layout configuration (Inventec version [Down->Up]) - * ========================================== - */ -#ifdef SWPS_CYPRESS_GA2 -unsigned cypress_ga2_gpio_rest_mux = MUX_RST_GPIO_FORCE_HEDERA; - -struct inv_ioexp_layout_s cypress_ga2_ioexp_layout[] = { - /* IOEXP_ID / IOEXP_TYPE / { Chan_ID, Chip_addr, Read_offset, Write_offset, config_offset, data_default, conf_default } */ - {0, IOEXP_TYPE_CYPRESS_NABC, { {2, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {2, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {2, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {1, IOEXP_TYPE_CYPRESS_NABC, { {3, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {3, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {3, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {2, IOEXP_TYPE_CYPRESS_NABC, { {4, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {4, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {4, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {3, IOEXP_TYPE_CYPRESS_NABC, { {5, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {5, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {5, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {4, IOEXP_TYPE_CYPRESS_NABC, { {6, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {6, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {6, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {5, IOEXP_TYPE_CYPRESS_NABC, { {7, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {7, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {7, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {6, IOEXP_TYPE_CYPRESS_7ABC, { {8, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xc0, 0xc0}, }, /* addr[0] = I/O Expander 7 A */ - {8, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xc0, 0xc0}, {0xff, 0xc0}, }, /* addr[1] = I/O Expander 7 B */ - {8, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 7 C */ - }, -}; - -struct inv_port_layout_s cypress_ga2_port_layout[] = { - /* Port_ID / Chan_ID / IOEXP_ID / IOEXP_VIRT_OFFSET / TRANSCEIVER_TYPE / BCM_CHIP_TYPE / LANE_ID */ - { 0, 11, 0, 1, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 2} }, - { 1, 10, 0, 0, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 1} }, - { 2, 13, 0, 3, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 4} }, - { 3, 12, 0, 2, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 3} }, - { 4, 15, 0, 5, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 6} }, - { 5, 14, 0, 4, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 5} }, - { 6, 17, 0, 7, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 8} }, - { 7, 16, 0, 6, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 7} }, - { 8, 19, 1, 1, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 10} }, - { 9, 18, 1, 0, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 9} }, - {10, 21, 1, 3, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 12} }, - {11, 20, 1, 2, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 11} }, - {12, 23, 1, 5, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 22} }, - {13, 22, 1, 4, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 21} }, - {14, 25, 1, 7, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 24} }, - {15, 24, 1, 6, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 23} }, - {16, 27, 2, 1, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 34} }, - {17, 26, 2, 0, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 33} }, - {18, 29, 2, 3, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 36} }, - {19, 28, 2, 2, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 35} }, - {20, 31, 2, 5, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 38} }, - {21, 30, 2, 4, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 37} }, - {22, 33, 2, 7, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 40} }, - {23, 32, 2, 6, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 39} }, - {24, 35, 3, 1, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 42} }, - {25, 34, 3, 0, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 41} }, - {26, 37, 3, 3, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 44} }, - {27, 36, 3, 2, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 43} }, - {28, 39, 3, 5, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 50} }, - {29, 38, 3, 4, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 49} }, - {30, 41, 3, 7, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 52} }, - {31, 40, 3, 6, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 51} }, - {32, 43, 4, 1, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 54} }, - {33, 42, 4, 0, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 53} }, - {34, 45, 4, 3, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 56} }, - {35, 44, 4, 2, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 55} }, - {36, 47, 4, 5, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 66} }, - {37, 46, 4, 4, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 65} }, - {38, 49, 4, 7, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 68} }, - {39, 48, 4, 6, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 67} }, - {40, 51, 5, 1, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 70} }, - {41, 50, 5, 0, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 69} }, - {42, 53, 5, 3, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 72} }, - {43, 52, 5, 2, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 71} }, - {44, 55, 5, 5, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 82} }, - {45, 54, 5, 4, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 81} }, - {46, 57, 5, 7, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 84} }, - {47, 56, 5, 6, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 83} }, - {48, 59, 6, 1, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 85, 86, 87, 88} }, - {49, 58, 6, 0, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 97, 98, 99,100} }, - {50, 61, 6, 3, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {105,106,107,108} }, - {51, 60, 6, 2, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {101,102,103,104} }, - {52, 63, 6, 5, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {117,118,119,120} }, - {53, 62, 6, 4, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {109,110,111,112} }, -}; -#endif - - -/* ========================================== - * Cypress Layout configuration (BaiDu version) - * ========================================== - */ -#ifdef SWPS_CYPRESS_BAI -unsigned cypress_b_gpio_rest_mux = MUX_RST_GPIO_FORCE_HEDERA; - -struct inv_ioexp_layout_s cypress_b_ioexp_layout[] = { - /* IOEXP_ID / IOEXP_TYPE / { Chan_ID, Chip_addr, Read_offset, Write_offset, config_offset, data_default, conf_default } */ - {0, IOEXP_TYPE_CYPRESS_NABC, { {2, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {2, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {2, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {1, IOEXP_TYPE_CYPRESS_NABC, { {3, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {3, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {3, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {2, IOEXP_TYPE_CYPRESS_NABC, { {4, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {4, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {4, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {3, IOEXP_TYPE_CYPRESS_NABC, { {5, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {5, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {5, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {4, IOEXP_TYPE_CYPRESS_NABC, { {6, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {6, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {6, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {5, IOEXP_TYPE_CYPRESS_NABC, { {7, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {7, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {7, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {6, IOEXP_TYPE_CYPRESS_7ABC, { {8, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xc0, 0xc0}, }, /* addr[0] = I/O Expander 7 A */ - {8, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xc0, 0xc0}, {0xff, 0xc0}, }, /* addr[1] = I/O Expander 7 B */ - {8, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 7 C */ - }, -}; - -struct inv_port_layout_s cypress_b_port_layout[] = { - /* Port_ID / Chan_ID / IOEXP_ID / IOEXP_VIRT_OFFSET / TRANSCEIVER_TYPE / BCM_CHIP_TYPE / LANE_ID */ - { 1, 11, 0, 1, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 2} }, - { 2, 10, 0, 0, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 1} }, - { 3, 13, 0, 3, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 4} }, - { 4, 12, 0, 2, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 3} }, - { 5, 15, 0, 5, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 6} }, - { 6, 14, 0, 4, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 5} }, - { 7, 17, 0, 7, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 8} }, - { 8, 16, 0, 6, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 7} }, - { 9, 19, 1, 1, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 10} }, - {10, 18, 1, 0, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 9} }, - {11, 21, 1, 3, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 12} }, - {12, 20, 1, 2, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 11} }, - {13, 23, 1, 5, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 22} }, - {14, 22, 1, 4, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 21} }, - {15, 25, 1, 7, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 24} }, - {16, 24, 1, 6, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 23} }, - {17, 27, 2, 1, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 34} }, - {18, 26, 2, 0, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 33} }, - {19, 29, 2, 3, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 36} }, - {20, 28, 2, 2, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 35} }, - {21, 31, 2, 5, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 38} }, - {22, 30, 2, 4, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 37} }, - {23, 33, 2, 7, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 40} }, - {24, 32, 2, 6, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 39} }, - {25, 35, 3, 1, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 42} }, - {26, 34, 3, 0, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 41} }, - {27, 37, 3, 3, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 44} }, - {28, 36, 3, 2, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 43} }, - {29, 39, 3, 5, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 50} }, - {30, 38, 3, 4, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 49} }, - {31, 41, 3, 7, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 52} }, - {32, 40, 3, 6, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 51} }, - {33, 43, 4, 1, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 54} }, - {34, 42, 4, 0, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 53} }, - {35, 45, 4, 3, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 56} }, - {36, 44, 4, 2, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 55} }, - {37, 47, 4, 5, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 66} }, - {38, 46, 4, 4, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 65} }, - {39, 49, 4, 7, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 68} }, - {40, 48, 4, 6, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 67} }, - {41, 51, 5, 1, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 70} }, - {42, 50, 5, 0, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 69} }, - {43, 53, 5, 3, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 72} }, - {44, 52, 5, 2, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 71} }, - {45, 55, 5, 5, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 82} }, - {46, 54, 5, 4, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 81} }, - {47, 57, 5, 7, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 84} }, - {48, 56, 5, 6, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 83} }, - {49, 59, 6, 1, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 85, 86, 87, 88} }, - {50, 58, 6, 0, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 97, 98, 99,100} }, - {51, 61, 6, 3, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {105,106,107,108} }, - {52, 60, 6, 2, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {101,102,103,104} }, - {53, 63, 6, 5, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {117,118,119,120} }, - {54, 62, 6, 4, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {109,110,111,112} }, -}; -#endif - - -/* ========================================== - * Redwood_fsl Layout configuration - * ========================================== - */ -#ifdef SWPS_REDWOOD_FSL -unsigned redwood_fsl_gpio_rest_mux = MUX_RST_GPIO_48_PAC9548; - -struct inv_ioexp_layout_s redwood_fsl_ioexp_layout[] = { - /* IOEXP_ID / IOEXP_TYPE / { Chan_ID, Chip_addr, Read_offset, Write_offset, config_offset, data_default, conf_default } */ - {0, IOEXP_TYPE_REDWOOD_P01P08, { {4, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[0] = I/O Expander 1-4 A */ - {4, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[1] = I/O Expander 1-4 B */ - {0, 0x25, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 5 B */ - }, - {1, IOEXP_TYPE_REDWOOD_P09P16, { {5, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[0] = I/O Expander 1-4 A */ - {5, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[1] = I/O Expander 1-4 B */ - {0, 0x25, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 5 B */ - }, - {2, IOEXP_TYPE_REDWOOD_P01P08, { {2, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[0] = I/O Expander 1-4 A */ - {2, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[1] = I/O Expander 1-4 B */ - {0, 0x24, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 5 B */ - }, - {3, IOEXP_TYPE_REDWOOD_P09P16, { {3, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[0] = I/O Expander 1-4 A */ - {3, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[1] = I/O Expander 1-4 B */ - {0, 0x24, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 5 B */ - }, -}; - - -struct inv_port_layout_s redwood_fsl_port_layout[] = { - /* Port_ID / Chan_ID / IOEXP_ID / IOEXP_VIRT_OFFSET / TRANSCEIVER_TYPE / BCM_CHIP_TYPE / LANE_ID */ - { 0, 22, 0, 0, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 1, 2, 3, 4} }, - { 1, 23, 0, 1, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 5, 6, 7, 8} }, - { 2, 24, 0, 2, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 9, 10, 11, 12} }, - { 3, 25, 0, 3, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 13, 14, 15, 16} }, - { 4, 26, 0, 4, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 17, 18, 19, 20} }, - { 5, 27, 0, 5, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 21, 22, 23, 24} }, - { 6, 28, 0, 6, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 25, 26, 27, 28} }, - { 7, 29, 0, 7, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 29, 30, 31, 32} }, - { 8, 30, 1, 0, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 33, 34, 35, 36} }, - { 9, 31, 1, 1, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 37, 38, 39, 40} }, - {10, 32, 1, 2, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 41, 42, 43, 44} }, - {11, 33, 1, 3, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 45, 46, 47, 48} }, - {12, 34, 1, 4, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 49, 50, 51, 52} }, - {13, 35, 1, 5, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 53, 54, 55, 56} }, - {14, 36, 1, 6, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 57, 58, 59, 60} }, - {15, 37, 1, 7, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 61, 62, 63, 64} }, - {16, 6, 2, 0, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 65, 66, 67, 68} }, - {17, 7, 2, 1, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 69, 70, 71, 72} }, - {18, 8, 2, 2, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 73, 74, 75, 76} }, - {19, 9, 2, 3, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 77, 78, 79, 80} }, - {20, 10, 2, 4, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 81, 82, 83, 84} }, - {21, 11, 2, 5, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 85, 86, 87, 88} }, - {22, 12, 2, 6, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 89, 90, 91, 92} }, - {23, 13, 2, 7, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 93, 94, 95, 96} }, - {24, 14, 3, 0, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 97, 98, 99,100} }, - {25, 15, 3, 1, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {101,102,103,104} }, - {26, 16, 3, 2, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {105,106,107,108} }, - {27, 17, 3, 3, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {109,110,111,112} }, - {28, 18, 3, 4, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {113,114,115,116} }, - {29, 19, 3, 5, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {117,118,119,120} }, - {30, 20, 3, 6, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {121,122,123,124} }, - {31, 21, 3, 7, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {125,126,127,128} }, -}; -#endif - - -#endif /* INV_SWPS_H */ diff --git a/packages/platforms/inventec/x86-64/d7054q28b/modules/builds/src/inv_vpd.c b/packages/platforms/inventec/x86-64/d7054q28b/modules/builds/src/inv_vpd.c deleted file mode 100644 index 7e81636e9..000000000 --- a/packages/platforms/inventec/x86-64/d7054q28b/modules/builds/src/inv_vpd.c +++ /dev/null @@ -1,354 +0,0 @@ -/************************************************************************* - * - * inv_vpd.c - * - * 2018 Inventec Corporation - * All Rights Reserved. - * - * NOTICE: All information contained herein is, and remains - * the property of Inventec Corp. and its suppliers, - * if any. The intellectual and technical concepts contained - * herein are proprietary to Inventec Corporation and its suppliers - * and may be covered by U.S. and Foreign Patents, patents in process, - * and are protected by trade secret or copyright law. - * - ************************************************************************/ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "inv_vpd.h" -#include "onie_tlvinfo.h" - -static int vpd_major; -static struct class *vpd_class_p = NULL; -static char cEeprom[SYS_EEPROM_MAX_SIZE]; -static DEFINE_MUTEX(vpd_mutex); - -static int -__swp_match(struct device *dev, -#ifdef VPD_KERN_VER_AF_3_10 - - const void *data){ -#else - void *data){ -#endif - - char *name = (char *)data; - if (strcmp(dev_name(dev), name) == 0) - return 1; - return 0; -} - -static -int get_vpd_data(struct i2c_client *pi2c_client, int i_offset, char *c_buf) -{ - int iRet; - - read_eeprom( pi2c_client, cEeprom); - iRet = tlvinfo_decode_tlv(cEeprom, i_offset,c_buf); - return iRet; -} - -static -int write_vpd_data(struct i2c_client *pi2c_client, int i_offset, char *c_buf) -{ - int iErr = 0; - - if (read_eeprom(pi2c_client, cEeprom)) { - printk(KERN_ERR "write vpd data eror at %d-%s\n", __LINE__, __FUNCTION__); - return -1; - } - - if (tlvinfo_delete_tlv(cEeprom, i_offset) == TRUE) { - } - if (c_buf) { - if(!tlvinfo_add_tlv(cEeprom, i_offset , c_buf)) { - printk(KERN_ERR "write vpd data eror at %d-%s\n", __LINE__, __FUNCTION__); - iErr = -1; - } else { - iErr = prog_eeprom(pi2c_client,cEeprom); - } - } - return iErr; -} - -static struct device * -get_swpdev_by_name(char *name){ - struct device *dev = class_find_device(vpd_class_p, - NULL, - name, - __swp_match); - return dev; -} - -static ssize_t -store_attr_vpd(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - struct i2c_client *pi2c_client = dev_get_drvdata(dev_p); - struct vpd_device_attribute *attr = to_vpd_dev_attr(attr_p); - int iOffset = attr->index; - int iErr , iLen; - char *pChar; - - if (!pi2c_client){ - return -ENODEV; - } - mutex_lock(&vpd_mutex); - - //-strip 0x0a in the last byte. - for (iLen = 0, pChar = buf_p; - iLen < 255 && *pChar != 0; - iLen++, pChar++) ; - if (iLen !=0 && *pChar == 0 && *(pChar-1) == 0x0a) - *(pChar - 1) = 0; - //- - - iErr = write_vpd_data( pi2c_client, iOffset, buf_p); - - mutex_unlock(&vpd_mutex); - return count; -} - -static ssize_t -show_attr_vpd(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct i2c_client *pi2c_client = dev_get_drvdata(dev_p); - struct vpd_device_attribute *attr = to_vpd_dev_attr(attr_p); - int iOffset = attr->index; - int iErr , iLen; - - if (!pi2c_client){ - return -ENODEV; - } - mutex_lock(&vpd_mutex); - iErr = get_vpd_data( pi2c_client, iOffset, buf_p); - mutex_unlock(&vpd_mutex); - - if( iErr <= 0 ) - iLen = 0; - else - iLen = snprintf(buf_p, TLV_DECODE_VALUE_MAX_LEN, "%s\n", buf_p); - - return iLen; -} - -/* ================= Vpd attribute ======================== - */ -static VPD_DEVICE_ATTR(product_name ,S_IWUSR|S_IRUGO, show_attr_vpd, store_attr_vpd, TLV_CODE_PRODUCT_NAME ); -static VPD_DEVICE_ATTR(pn ,S_IWUSR|S_IRUGO, show_attr_vpd, store_attr_vpd, TLV_CODE_PART_NUMBER ); -static VPD_DEVICE_ATTR(sn ,S_IWUSR|S_IRUGO, show_attr_vpd, store_attr_vpd, TLV_CODE_SERIAL_NUMBER ); -static VPD_DEVICE_ATTR(base_mac_addr,S_IWUSR|S_IRUGO, show_attr_vpd, store_attr_vpd, TLV_CODE_MAC_BASE ); -static VPD_DEVICE_ATTR(man_date ,S_IWUSR|S_IRUGO, show_attr_vpd, store_attr_vpd, TLV_CODE_MANUF_DATE ); -static VPD_DEVICE_ATTR(dev_ver ,S_IWUSR|S_IRUGO, show_attr_vpd, store_attr_vpd, TLV_CODE_DEVICE_VERSION ); -static VPD_DEVICE_ATTR(label_rev ,S_IWUSR|S_IRUGO, show_attr_vpd, store_attr_vpd, TLV_CODE_LABEL_REVISION ); -static VPD_DEVICE_ATTR(plat_name ,S_IWUSR|S_IRUGO, show_attr_vpd, store_attr_vpd, TLV_CODE_PLATFORM_NAME ); -static VPD_DEVICE_ATTR(ldr_ver ,S_IWUSR|S_IRUGO, show_attr_vpd, store_attr_vpd, TLV_CODE_ONIE_VERSION ); -static VPD_DEVICE_ATTR(mac_addr ,S_IWUSR|S_IRUGO, show_attr_vpd, store_attr_vpd, TLV_CODE_MAC_SIZE ); -static VPD_DEVICE_ATTR(manufacturer ,S_IWUSR|S_IRUGO, show_attr_vpd, store_attr_vpd, TLV_CODE_MANUF_NAME ); -static VPD_DEVICE_ATTR(country_code ,S_IWUSR|S_IRUGO, show_attr_vpd, store_attr_vpd, TLV_CODE_MANUF_COUNTRY ); -static VPD_DEVICE_ATTR(vendor_name ,S_IWUSR|S_IRUGO, show_attr_vpd, store_attr_vpd, TLV_CODE_VENDOR_NAME ); -static VPD_DEVICE_ATTR(diag_ver ,S_IWUSR|S_IRUGO, show_attr_vpd, store_attr_vpd, TLV_CODE_DIAG_VERSION ); -static VPD_DEVICE_ATTR(service_tag ,S_IWUSR|S_IRUGO, show_attr_vpd, store_attr_vpd, TLV_CODE_SERVICE_TAG ); -static VPD_DEVICE_ATTR(vendor_ext ,S_IWUSR|S_IRUGO, show_attr_vpd, store_attr_vpd, TLV_CODE_VENDOR_EXT ); -static VPD_DEVICE_ATTR(crc32 ,S_IRUGO, show_attr_vpd, NULL, TLV_CODE_CRC_32 ); - -static void -clean_vpd_common(void) -{ - dev_t dev_num; - struct device *device_p; - - device_p = get_swpdev_by_name(VPD_DEVICE); - if (device_p){ - dev_num = MKDEV(vpd_major, 1); - device_unregister(device_p); - device_destroy(vpd_class_p, dev_num); - } - VPD_DEBUG("%s: done.\n", __func__); -} - - -static struct register_attr VpdRegAttr[VPD_ENTRY_SIZE ] ={ - { &vpd_dev_attr_product_name.dev_attr, "vpd_dev_attr_product_name"}, - { &vpd_dev_attr_pn.dev_attr, "vpd_dev_attr_pn"}, - { &vpd_dev_attr_sn.dev_attr, "vpd_dev_attr_sn"}, - { &vpd_dev_attr_base_mac_addr.dev_attr, "vpd_dev_attr_base_mac_addr"}, - { &vpd_dev_attr_man_date.dev_attr, "vpd_dev_attr_man_date"}, - { &vpd_dev_attr_dev_ver.dev_attr, "vpd_dev_attr_dev_ver"}, - { &vpd_dev_attr_label_rev.dev_attr, "vpd_dev_attr_label_rev"}, - { &vpd_dev_attr_plat_name.dev_attr, "vpd_dev_attr_plat_name"}, - { &vpd_dev_attr_ldr_ver.dev_attr, "vpd_dev_attr_ldr_ver"}, - { &vpd_dev_attr_mac_addr.dev_attr, "vpd_dev_attr_mac_addr"}, - { &vpd_dev_attr_manufacturer.dev_attr, "vpd_dev_attr_manufacturer"}, - { &vpd_dev_attr_country_code.dev_attr, "vpd_dev_attr_country_code"}, - { &vpd_dev_attr_vendor_name.dev_attr, "vpd_dev_attr_vendor_name"}, - { &vpd_dev_attr_diag_ver.dev_attr, "vpd_dev_attr_diag_ver"}, - { &vpd_dev_attr_service_tag.dev_attr, "vpd_dev_attr_service_tag"}, - { &vpd_dev_attr_vendor_ext.dev_attr, "vpd_dev_attr_vendor_ext"}, - { &vpd_dev_attr_crc32.dev_attr, "vpd_dev_attr_crc32"}, -}; - -static int -register_vpd_attr(struct device *device_p){ - - char *err_attr = NULL; - int i; - - for( i = 0 ; i adapter = adap; - vpd_i2c_client->addr = VPD_I2C_ADDR; - - device_p = device_create(vpd_class_p, /* struct class *cls */ - NULL, /* struct device *parent */ - dev_num, /* dev_t devt */ - vpd_i2c_client, /* void *private_data */ - VPD_DEVICE); /* const char *fmt */ - if (IS_ERR(device_p)){ - err_msg = "device_create fail"; - goto err_register_vpd_device_1; - } - if (register_vpd_attr(device_p) < 0) { - err_msg = "register_vpd_attr fail"; - goto err_register_vpd_device_2; - } - return 0; - -err_register_vpd_device_2: - device_unregister(device_p); - device_destroy(vpd_class_p, dev_num); -err_register_vpd_device_1: - kfree(vpd_i2c_client); - vpd_i2c_client = NULL; -err_register_vpd_device: - VPD_ERR("%s: %s\n", __func__, err_msg); - return -1; -} - -static int -register_vpd_module(void) -{ - dev_t vpd_devt = 0; - - if (alloc_chrdev_region(&vpd_devt, 0, 1, VPD_DEVICE) < 0){ - VPD_WARN("Allocate VPD MAJOR failure! \n"); - goto err_register_vpd_module; - } - vpd_major = MAJOR(vpd_devt); - - /* Create class object */ - vpd_class_p = class_create(THIS_MODULE, EEPROM_CLASS); - if (IS_ERR(vpd_class_p)) { - VPD_ERR("Create class failure! \n"); - goto err_register_vpd_module_1; - } - return 0; - -err_register_vpd_module_1: - unregister_chrdev_region(MKDEV(vpd_major, 0), 1); -err_register_vpd_module: - return -1; -} - - -static int -init_vpd_common(void) -{ - char *err_msg = "ERR"; - - if (register_vpd_device() < 0) { - err_msg = "register_vpd_device fail"; - goto err_init_vpd_common; - } - return 0; - -err_init_vpd_common: - VPD_ERR("%s: %s\n", __func__, err_msg); - return -1; -} - - -static int __init -vpd_module_init(void) -{ - if (register_vpd_module() < 0){ - goto err_vpd_module_init; - } - if (init_vpd_common() < 0){ - goto err_vpd_module_init_1; - } - VPD_INFO("Inventec vpd module V.%s initial success.\n", VPD_VERSION); - return 0; - -err_vpd_module_init_1: - class_unregister(vpd_class_p); - class_destroy(vpd_class_p); - unregister_chrdev_region(MKDEV(vpd_major, 0), 1); -err_vpd_module_init: - VPD_ERR("Inventec vpd module V.%s initial failure.\n", VPD_VERSION); - return -1; -} - - -static void __exit -vpd_module_exit(void) -{ - clean_vpd_common(); - class_unregister(vpd_class_p); - class_destroy(vpd_class_p); - unregister_chrdev_region(MKDEV(vpd_major, 0), 1); - VPD_INFO("Remove Inventec vpd module success.\n"); -} - - -/* Module information */ -MODULE_AUTHOR(VPD_AUTHOR); -MODULE_DESCRIPTION(VPD_DESC); -MODULE_VERSION(VPD_VERSION); -MODULE_LICENSE(VPD_LICENSE); - -module_init(vpd_module_init); -module_exit(vpd_module_exit); diff --git a/packages/platforms/inventec/x86-64/d7054q28b/modules/builds/src/inv_vpd.h b/packages/platforms/inventec/x86-64/d7054q28b/modules/builds/src/inv_vpd.h deleted file mode 100644 index 95676bfa1..000000000 --- a/packages/platforms/inventec/x86-64/d7054q28b/modules/builds/src/inv_vpd.h +++ /dev/null @@ -1,64 +0,0 @@ -/************************************************************************* - * - * inv_vpd.h - * - * 2018 Inventec Corporation - * All Rights Reserved. - * - * NOTICE: All information contained herein is, and remains - * the property of Inventec Corp. and its suppliers, - * if any. The intellectual and technical concepts contained - * herein are proprietary to Inventec Corporation and its suppliers - * and may be covered by U.S. and Foreign Patents, patents in process, - * and are protected by trade secret or copyright law. - * - ************************************************************************/ - -#ifndef INV_VPD_H -#define INV_VPD_H - -#define EEPROM_CLASS "eeprom" -#define VPD_DEVICE "vpd" -#define VPD_AUTHOR "Neil " -#define VPD_DESC "Inventec eeprom vpd driver" -#define VPD_VERSION "1.0.0" -#define VPD_LICENSE "GPL" - -#define VPD_ENTRY_SIZE (17) -#define VPD_I2C_BUS (0) -#define VPD_I2C_ADDR (0x53) - -#define VPD_KERN_VER_AF_3_10 (1) - -struct register_attr { -struct device_attribute *attr; -char * errmsg; -}; - -struct vpd_device_attribute{ - struct device_attribute dev_attr; - int index; -}; - -#define to_vpd_dev_attr(_dev_attr) \ - container_of(_dev_attr, struct vpd_device_attribute, dev_attr) - -#define VPD_ATTR(_name, _mode, _show, _store, _index) \ - { .dev_attr = __ATTR(_name, _mode, _show, _store), \ - .index = _index } - -#define VPD_DEVICE_ATTR(_name, _mode, _show, _store, _index) \ - struct vpd_device_attribute vpd_dev_attr_##_name \ - = VPD_ATTR(_name, _mode, _show, _store, _index) - -#define VPD_INFO(fmt, args...) printk( KERN_INFO "[VPD] " fmt, ##args) -#define VPD_WARN(fmt, args...) printk( KERN_WARNING "[VPD] " fmt, ##args) -#define VPD_ERR(fmt, args...) printk( KERN_ERR "[VPD] " fmt, ##args) - -#ifdef DEBUG_VPD -# define VPD_DEBUG(fmt, args...) printk( KERN_DEBUG "[VPD] " fmt, ##args) -#else -# define VPD_DEBUG(fmt, args...) -#endif - -#endif /* INV_VPD_H */ diff --git a/packages/platforms/inventec/x86-64/d7054q28b/modules/builds/src/io_expander.c b/packages/platforms/inventec/x86-64/d7054q28b/modules/builds/src/io_expander.c deleted file mode 100644 index 3ef271ac4..000000000 --- a/packages/platforms/inventec/x86-64/d7054q28b/modules/builds/src/io_expander.c +++ /dev/null @@ -1,1700 +0,0 @@ -/************************************************************************* - * - * io_expander.c - * - * 2018 Inventec Corporation - * All Rights Reserved. - * - * NOTICE: All information contained herein is, and remains - * the property of Inventec Corp. and its suppliers, - * if any. The intellectual and technical concepts contained - * herein are proprietary to Inventec Corporation and its suppliers - * and may be covered by U.S. and Foreign Patents, patents in process, - * and are protected by trade secret or copyright law. - * - ************************************************************************/ - -#include -#include -#include -#include "io_expander.h" - -static struct ioexp_obj_s *ioexp_head_p = NULL; -static struct ioexp_obj_s *ioexp_tail_p = NULL; - - -/* ========== Register IOEXP layout ========== - */ -struct ioexp_map_s ioexp_map_magnolia_nab = { - - .chip_amount = 2, - .data_width = 2, - - .map_present = { {0, 0, 4}, /* map_present[0] = MOD_ABS_PORT(X) */ - {0, 0, 5}, /* map_present[1] = MOD_ABS_PORT(X+1) */ - {0, 0, 6}, /* map_present[2] = MOD_ABS_PORT(X+2) */ - {0, 0, 7}, /* map_present[3] = MOD_ABS_PORT(X+3) */ - {1, 0, 4}, /* map_present[4] = MOD_ABS_PORT(X+4) */ - {1, 0, 5}, /* map_present[5] = MOD_ABS_PORT(X+5) */ - {1, 0, 6}, /* map_present[6] = MOD_ABS_PORT(X+6) */ - {1, 0, 7}, /* map_present[7] = MOD_ABS_PORT(X+7) */ - }, - .map_tx_disable = { {0, 1, 0}, /* map_tx_disable[0] = TXDISABLE_SFP+_P(X) */ - {0, 1, 1}, /* map_tx_disable[1] = TXDISABLE_SFP+_P(X+1) */ - {0, 1, 2}, /* map_tx_disable[2] = TXDISABLE_SFP+_P(X+2) */ - {0, 1, 3}, /* map_tx_disable[3] = TXDISABLE_SFP+_P(X+3) */ - {1, 1, 0}, /* map_tx_disable[4] = TXDISABLE_SFP+_P(X+4) */ - {1, 1, 1}, /* map_tx_disable[5] = TXDISABLE_SFP+_P(X+5) */ - {1, 1, 2}, /* map_tx_disable[6] = TXDISABLE_SFP+_P(X+6) */ - {1, 1, 3}, /* map_tx_disable[7] = TXDISABLE_SFP+_P(X+7) */ - }, - .map_tx_fault = { {0, 0, 0}, /* map_tx_fault[0] = TXFAULT_SFP+_P(X) */ - {0, 0, 1}, /* map_tx_fault[1] = TXFAULT_SFP+_P(X+1) */ - {0, 0, 2}, /* map_tx_fault[2] = TXFAULT_SFP+_P(X+2) */ - {0, 0, 3}, /* map_tx_fault[3] = TXFAULT_SFP+_P(X+3) */ - {1, 0, 0}, /* map_tx_fault[4] = TXFAULT_SFP+_P(X+4) */ - {1, 0, 1}, /* map_tx_fault[5] = TXFAULT_SFP+_P(X+5) */ - {1, 0, 2}, /* map_tx_fault[6] = TXFAULT_SFP+_P(X+6) */ - {1, 0, 3}, /* map_tx_fault[7] = TXFAULT_SFP+_P(X+7) */ - }, - .map_rxlos = { {0, 1, 4}, /* map_rxlos[0] = OPRXLOS_PORT(X) */ - {0, 1, 5}, /* map_rxlos[1] = OPRXLOS_PORT(X+1) */ - {0, 1, 6}, /* map_rxlos[2] = OPRXLOS_PORT(X+2) */ - {0, 1, 7}, /* map_rxlos[3] = OPRXLOS_PORT(X+3) */ - {1, 1, 4}, /* map_rxlos[4] = OPRXLOS_PORT(X+4) */ - {1, 1, 5}, /* map_rxlos[5] = OPRXLOS_PORT(X+5) */ - {1, 1, 6}, /* map_rxlos[6] = OPRXLOS_PORT(X+6) */ - {1, 1, 7}, /* map_rxlos[7] = OPRXLOS_PORT(X+7) */ - }, -}; - - -struct ioexp_map_s ioexp_map_magnolia_7ab = { - - .chip_amount = 2, - .data_width = 2, - - .map_present = { {1, 0, 4}, /* map_present[0] = MOD_ABS_PORT(X) */ - {1, 0, 5}, /* map_present[1] = MOD_ABS_PORT(X+1) */ - {1, 0, 6}, /* map_present[2] = MOD_ABS_PORT(X+2) */ - {1, 0, 7}, /* map_present[3] = MOD_ABS_PORT(X+3) */ - {1, 1, 4}, /* map_present[4] = MOD_ABS_PORT(X+4) */ - {1, 1, 5}, /* map_present[5] = MOD_ABS_PORT(X+5) */ - }, - .map_reset = { {0, 0, 0}, /* map_reset[0] = QRESET_QSFP_N_P(X) */ - {0, 0, 1}, /* map_reset[1] = QRESET_QSFP_N_P(X+1) */ - {0, 0, 2}, /* map_reset[2] = QRESET_QSFP_N_P(X+2) */ - {0, 0, 3}, /* map_reset[3] = QRESET_QSFP_N_P(X+3) */ - {1, 0, 0}, /* map_reset[4] = QRESET_QSFP_N_P(X+4) */ - {1, 0, 1}, /* map_reset[5] = QRESET_QSFP_N_P(X+5) */ - }, - .map_lpmod = { {0, 0, 4}, /* map_lpmod[0] = LPMODE_QSFP_P(X) */ - {0, 0, 5}, /* map_lpmod[1] = LPMODE_QSFP_P(X+1) */ - {0, 0, 6}, /* map_lpmod[2] = LPMODE_QSFP_P(X+2) */ - {0, 0, 7}, /* map_lpmod[3] = LPMODE_QSFP_P(X+3) */ - {1, 0, 2}, /* map_lpmod[4] = LPMODE_QSFP_P(X+4) */ - {1, 0, 3}, /* map_lpmod[5] = LPMODE_QSFP_P(X+5) */ - }, - .map_modsel = { {0, 1, 4}, /* map_modsel[0] = MODSEL_QSFP_N_P(X) */ - {0, 1, 5}, /* map_modsel[1] = MODSEL_QSFP_N_P(X+1) */ - {0, 1, 6}, /* map_modsel[2] = MODSEL_QSFP_N_P(X+2) */ - {0, 1, 7}, /* map_modsel[3] = MODSEL_QSFP_N_P(X+3) */ - {1, 1, 4}, /* map_modsel[4] = MODSEL_QSFP_N_P(X+4) */ - {1, 1, 5}, /* map_modsel[5] = MODSEL_QSFP_N_P(X+5) */ - }, -}; - - -struct ioexp_map_s ioexp_map_redwood_p01p08_p17p24 = { - - .chip_amount = 3, - .data_width = 2, - - .map_present = { {2, 0, 0}, /* map_present[0] = MOD_ABS_PORT(X) */ - {2, 0, 1}, /* map_present[1] = MOD_ABS_PORT(X+1) */ - {2, 0, 2}, /* map_present[2] = MOD_ABS_PORT(X+2) */ - {2, 0, 3}, /* map_present[3] = MOD_ABS_PORT(X+3) */ - {2, 0, 4}, /* map_present[4] = MOD_ABS_PORT(X+4) */ - {2, 0, 5}, /* map_present[5] = MOD_ABS_PORT(X+5) */ - {2, 0, 6}, /* map_present[6] = MOD_ABS_PORT(X+6) */ - {2, 0, 7}, /* map_present[7] = MOD_ABS_PORT(X+7) */ - }, - .map_reset = { {0, 0, 0}, /* map_reset[0] = QRESET_QSFP28_N_P(X) */ - {0, 0, 1}, /* map_reset[1] = QRESET_QSFP28_N_P(X+1) */ - {0, 0, 2}, /* map_reset[2] = QRESET_QSFP28_N_P(X+2) */ - {0, 0, 3}, /* map_reset[3] = QRESET_QSFP28_N_P(X+3) */ - {1, 0, 0}, /* map_reset[4] = QRESET_QSFP28_N_P(X+4) */ - {1, 0, 1}, /* map_reset[5] = QRESET_QSFP28_N_P(X+5) */ - {1, 0, 2}, /* map_reset[6] = QRESET_QSFP28_N_P(X+6) */ - {1, 0, 3}, /* map_reset[7] = QRESET_QSFP28_N_P(X+7) */ - }, - .map_lpmod = { {0, 0, 4}, /* map_lpmod[0] = LPMODE_QSFP28_P(X) */ - {0, 0, 5}, /* map_lpmod[1] = LPMODE_QSFP28_P(X+1) */ - {0, 0, 6}, /* map_lpmod[2] = LPMODE_QSFP28_P(X+2) */ - {0, 0, 7}, /* map_lpmod[3] = LPMODE_QSFP28_P(X+3) */ - {1, 0, 4}, /* map_lpmod[4] = LPMODE_QSFP28_P(X+4) */ - {1, 0, 5}, /* map_lpmod[5] = LPMODE_QSFP28_P(X+5) */ - {1, 0, 6}, /* map_lpmod[6] = LPMODE_QSFP28_P(X+6) */ - {1, 0, 7}, /* map_lpmod[7] = LPMODE_QSFP28_P(X+7) */ - }, - .map_modsel = { {0, 1, 4}, /* map_modsel[0] = MODSEL_QSFP28_N_P(X) */ - {0, 1, 5}, /* map_modsel[1] = MODSEL_QSFP28_N_P(X+1) */ - {0, 1, 6}, /* map_modsel[2] = MODSEL_QSFP28_N_P(X+2) */ - {0, 1, 7}, /* map_modsel[3] = MODSEL_QSFP28_N_P(X+3) */ - {1, 1, 4}, /* map_modsel[4] = MODSEL_QSFP28_N_P(X+4) */ - {1, 1, 5}, /* map_modsel[5] = MODSEL_QSFP28_N_P(X+5) */ - {1, 1, 6}, /* map_modsel[6] = MODSEL_QSFP28_N_P(X+6) */ - {1, 1, 7}, /* map_modsel[7] = MODSEL_QSFP28_N_P(X+7) */ - }, -}; - - -struct ioexp_map_s ioexp_map_redwood_p09p16_p25p32 = { - - .chip_amount = 3, - .data_width = 2, - - .map_present = { {2, 1, 0}, /* map_present[0] = MOD_ABS_PORT(X) */ - {2, 1, 1}, /* map_present[1] = MOD_ABS_PORT(X+1) */ - {2, 1, 2}, /* map_present[2] = MOD_ABS_PORT(X+2) */ - {2, 1, 3}, /* map_present[3] = MOD_ABS_PORT(X+3) */ - {2, 1, 4}, /* map_present[4] = MOD_ABS_PORT(X+4) */ - {2, 1, 5}, /* map_present[5] = MOD_ABS_PORT(X+5) */ - {2, 1, 6}, /* map_present[6] = MOD_ABS_PORT(X+6) */ - {2, 1, 7}, /* map_present[7] = MOD_ABS_PORT(X+7) */ - }, - .map_reset = { {0, 0, 0}, /* map_reset[0] = QRESET_QSFP28_N_P(X) */ - {0, 0, 1}, /* map_reset[1] = QRESET_QSFP28_N_P(X+1) */ - {0, 0, 2}, /* map_reset[2] = QRESET_QSFP28_N_P(X+2) */ - {0, 0, 3}, /* map_reset[3] = QRESET_QSFP28_N_P(X+3) */ - {1, 0, 0}, /* map_reset[4] = QRESET_QSFP28_N_P(X+4) */ - {1, 0, 1}, /* map_reset[5] = QRESET_QSFP28_N_P(X+5) */ - {1, 0, 2}, /* map_reset[6] = QRESET_QSFP28_N_P(X+6) */ - {1, 0, 3}, /* map_reset[7] = QRESET_QSFP28_N_P(X+7) */ - }, - .map_lpmod = { {0, 0, 4}, /* map_lpmod[0] = LPMODE_QSFP28_P(X) */ - {0, 0, 5}, /* map_lpmod[1] = LPMODE_QSFP28_P(X+1) */ - {0, 0, 6}, /* map_lpmod[2] = LPMODE_QSFP28_P(X+2) */ - {0, 0, 7}, /* map_lpmod[3] = LPMODE_QSFP28_P(X+3) */ - {1, 0, 4}, /* map_lpmod[4] = LPMODE_QSFP28_P(X+4) */ - {1, 0, 5}, /* map_lpmod[5] = LPMODE_QSFP28_P(X+5) */ - {1, 0, 6}, /* map_lpmod[6] = LPMODE_QSFP28_P(X+6) */ - {1, 0, 7}, /* map_lpmod[7] = LPMODE_QSFP28_P(X+7) */ - }, - .map_modsel = { {0, 1, 4}, /* map_modsel[0] = MODSEL_QSFP28_N_P(X) */ - {0, 1, 5}, /* map_modsel[1] = MODSEL_QSFP28_N_P(X+1) */ - {0, 1, 6}, /* map_modsel[2] = MODSEL_QSFP28_N_P(X+2) */ - {0, 1, 7}, /* map_modsel[3] = MODSEL_QSFP28_N_P(X+3) */ - {1, 1, 4}, /* map_modsel[4] = MODSEL_QSFP28_N_P(X+4) */ - {1, 1, 5}, /* map_modsel[5] = MODSEL_QSFP28_N_P(X+5) */ - {1, 1, 6}, /* map_modsel[6] = MODSEL_QSFP28_N_P(X+6) */ - {1, 1, 7}, /* map_modsel[7] = MODSEL_QSFP28_N_P(X+7) */ - }, -}; - - -struct ioexp_map_s ioexp_map_hudson32iga_p01p08_p17p24 = { - - .chip_amount = 3, - .data_width = 2, - - .map_present = { {2, 0, 0}, /* map_present[0] = MODABS_QSFP(X) */ - {2, 0, 1}, /* map_present[1] = MODABS_QSFP(X+1) */ - {2, 0, 2}, /* map_present[2] = MODABS_QSFP(X+2) */ - {2, 0, 3}, /* map_present[3] = MODABS_QSFP(X+3) */ - {2, 0, 4}, /* map_present[4] = MODABS_QSFP(X+4) */ - {2, 0, 5}, /* map_present[5] = MODABS_QSFP(X+5) */ - {2, 0, 6}, /* map_present[6] = MODABS_QSFP(X+6) */ - {2, 0, 7}, /* map_present[7] = MODABS_QSFP(X+7) */ - }, - .map_reset = { {0, 0, 0}, /* map_reset[0] = QRESET_QSFP(X) */ - {0, 0, 1}, /* map_reset[1] = QRESET_QSFP(X+1) */ - {0, 0, 2}, /* map_reset[2] = QRESET_QSFP(X+2) */ - {0, 0, 3}, /* map_reset[3] = QRESET_QSFP(X+3) */ - {1, 0, 0}, /* map_reset[4] = QRESET_QSFP(X+4) */ - {1, 0, 1}, /* map_reset[5] = QRESET_QSFP(X+5) */ - {1, 0, 2}, /* map_reset[6] = QRESET_QSFP(X+6) */ - {1, 0, 3}, /* map_reset[7] = QRESET_QSFP(X+7) */ - }, - .map_lpmod = { {0, 0, 4}, /* map_lpmod[0] = LPMODE_QSFP(X) */ - {0, 0, 5}, /* map_lpmod[1] = LPMODE_QSFP(X+1) */ - {0, 0, 6}, /* map_lpmod[2] = LPMODE_QSFP(X+2) */ - {0, 0, 7}, /* map_lpmod[3] = LPMODE_QSFP(X+3) */ - {1, 0, 4}, /* map_lpmod[4] = LPMODE_QSFP(X+4) */ - {1, 0, 5}, /* map_lpmod[5] = LPMODE_QSFP(X+5) */ - {1, 0, 6}, /* map_lpmod[6] = LPMODE_QSFP(X+6) */ - {1, 0, 7}, /* map_lpmod[7] = LPMODE_QSFP(X+7) */ - }, - .map_modsel = { {0, 1, 4}, /* map_modsel[0] = MODSEL_QSFP(X) */ - {0, 1, 5}, /* map_modsel[1] = MODSEL_QSFP(X+1) */ - {0, 1, 6}, /* map_modsel[2] = MODSEL_QSFP(X+2) */ - {0, 1, 7}, /* map_modsel[3] = MODSEL_QSFP(X+3) */ - {1, 1, 4}, /* map_modsel[4] = MODSEL_QSFP(X+4) */ - {1, 1, 5}, /* map_modsel[5] = MODSEL_QSFP(X+5) */ - {1, 1, 6}, /* map_modsel[6] = MODSEL_QSFP(X+6) */ - {1, 1, 7}, /* map_modsel[7] = MODSEL_QSFP(X+7) */ - }, -}; - - -struct ioexp_map_s ioexp_map_hudson32iga_p09p16_p25p32 = { - - .chip_amount = 3, - .data_width = 2, - - .map_present = { {2, 1, 0}, /* map_present[0] = MODABS_QSFP(X) */ - {2, 1, 1}, /* map_present[1] = MODABS_QSFP(X+1) */ - {2, 1, 2}, /* map_present[2] = MODABS_QSFP(X+2) */ - {2, 1, 3}, /* map_present[3] = MODABS_QSFP(X+3) */ - {2, 1, 4}, /* map_present[4] = MODABS_QSFP(X+4) */ - {2, 1, 5}, /* map_present[5] = MODABS_QSFP(X+5) */ - {2, 1, 6}, /* map_present[6] = MODABS_QSFP(X+6) */ - {2, 1, 7}, /* map_present[7] = MODABS_QSFP(X+7) */ - }, - .map_reset = { {0, 0, 0}, /* map_reset[0] = QRESET_QSFP(X) */ - {0, 0, 1}, /* map_reset[1] = QRESET_QSFP(X+1) */ - {0, 0, 2}, /* map_reset[2] = QRESET_QSFP(X+2) */ - {0, 0, 3}, /* map_reset[3] = QRESET_QSFP(X+3) */ - {1, 0, 0}, /* map_reset[4] = QRESET_QSFP(X+4) */ - {1, 0, 1}, /* map_reset[5] = QRESET_QSFP(X+5) */ - {1, 0, 2}, /* map_reset[6] = QRESET_QSFP(X+6) */ - {1, 0, 3}, /* map_reset[7] = QRESET_QSFP(X+7) */ - }, - .map_lpmod = { {0, 0, 4}, /* map_lpmod[0] = LPMODE_QSFP(X) */ - {0, 0, 5}, /* map_lpmod[1] = LPMODE_QSFP(X+1) */ - {0, 0, 6}, /* map_lpmod[2] = LPMODE_QSFP(X+2) */ - {0, 0, 7}, /* map_lpmod[3] = LPMODE_QSFP(X+3) */ - {1, 0, 4}, /* map_lpmod[4] = LPMODE_QSFP(X+4) */ - {1, 0, 5}, /* map_lpmod[5] = LPMODE_QSFP(X+5) */ - {1, 0, 6}, /* map_lpmod[6] = LPMODE_QSFP(X+6) */ - {1, 0, 7}, /* map_lpmod[7] = LPMODE_QSFP(X+7) */ - }, - .map_modsel = { {0, 1, 4}, /* map_modsel[0] = MODSEL_QSFP(X) */ - {0, 1, 5}, /* map_modsel[1] = MODSEL_QSFP(X+1) */ - {0, 1, 6}, /* map_modsel[2] = MODSEL_QSFP(X+2) */ - {0, 1, 7}, /* map_modsel[3] = MODSEL_QSFP(X+3) */ - {1, 1, 4}, /* map_modsel[4] = MODSEL_QSFP(X+4) */ - {1, 1, 5}, /* map_modsel[5] = MODSEL_QSFP(X+5) */ - {1, 1, 6}, /* map_modsel[6] = MODSEL_QSFP(X+6) */ - {1, 1, 7}, /* map_modsel[7] = MODSEL_QSFP(X+7) */ - }, -}; - - -struct ioexp_map_s ioexp_map_cypress_nabc = { - - .chip_amount = 3, - .data_width = 2, - - .map_present = { {0, 0, 4}, /* map_present[0] = MOD_ABS_PORT(X) */ - {0, 0, 5}, /* map_present[1] = MOD_ABS_PORT(X+1) */ - {0, 0, 6}, /* map_present[2] = MOD_ABS_PORT(X+2) */ - {0, 0, 7}, /* map_present[3] = MOD_ABS_PORT(X+3) */ - {1, 0, 4}, /* map_present[4] = MOD_ABS_PORT(X+4) */ - {1, 0, 5}, /* map_present[5] = MOD_ABS_PORT(X+5) */ - {1, 0, 6}, /* map_present[6] = MOD_ABS_PORT(X+6) */ - {1, 0, 7}, /* map_present[7] = MOD_ABS_PORT(X+7) */ - }, - .map_tx_disable = { {0, 1, 0}, /* map_tx_disable[0] = TXDISABLE_SFP+_P(X) */ - {0, 1, 1}, /* map_tx_disable[1] = TXDISABLE_SFP+_P(X+1) */ - {0, 1, 2}, /* map_tx_disable[2] = TXDISABLE_SFP+_P(X+2) */ - {0, 1, 3}, /* map_tx_disable[3] = TXDISABLE_SFP+_P(X+3) */ - {1, 1, 0}, /* map_tx_disable[4] = TXDISABLE_SFP+_P(X+4) */ - {1, 1, 1}, /* map_tx_disable[5] = TXDISABLE_SFP+_P(X+5) */ - {1, 1, 2}, /* map_tx_disable[6] = TXDISABLE_SFP+_P(X+6) */ - {1, 1, 3}, /* map_tx_disable[7] = TXDISABLE_SFP+_P(X+7) */ - }, - .map_tx_fault = { {0, 0, 0}, /* map_tx_fault[0] = TXFAULT_SFP+_P(X) */ - {0, 0, 1}, /* map_tx_fault[1] = TXFAULT_SFP+_P(X+1) */ - {0, 0, 2}, /* map_tx_fault[2] = TXFAULT_SFP+_P(X+2) */ - {0, 0, 3}, /* map_tx_fault[3] = TXFAULT_SFP+_P(X+3) */ - {1, 0, 0}, /* map_tx_fault[4] = TXFAULT_SFP+_P(X+4) */ - {1, 0, 1}, /* map_tx_fault[5] = TXFAULT_SFP+_P(X+5) */ - {1, 0, 2}, /* map_tx_fault[6] = TXFAULT_SFP+_P(X+6) */ - {1, 0, 3}, /* map_tx_fault[7] = TXFAULT_SFP+_P(X+7) */ - }, - .map_rxlos = { {0, 1, 4}, /* map_rxlos[0] = OPRXLOS_PORT(X) */ - {0, 1, 5}, /* map_rxlos[1] = OPRXLOS_PORT(X+1) */ - {0, 1, 6}, /* map_rxlos[2] = OPRXLOS_PORT(X+2) */ - {0, 1, 7}, /* map_rxlos[3] = OPRXLOS_PORT(X+3) */ - {1, 1, 4}, /* map_rxlos[4] = OPRXLOS_PORT(X+4) */ - {1, 1, 5}, /* map_rxlos[5] = OPRXLOS_PORT(X+5) */ - {1, 1, 6}, /* map_rxlos[6] = OPRXLOS_PORT(X+6) */ - {1, 1, 7}, /* map_rxlos[7] = OPRXLOS_PORT(X+7) */ - }, - .map_hard_rs0 = { {2, 0, 0}, /* map_hard_rs0[0] = RS0_SFP28_P(X) */ - {2, 0, 2}, /* map_hard_rs0[1] = RS0_SFP28_P(X+1) */ - {2, 0, 4}, /* map_hard_rs0[2] = RS0_SFP28_P(X+2) */ - {2, 0, 6}, /* map_hard_rs0[3] = RS0_SFP28_P(X+3) */ - {2, 1, 0}, /* map_hard_rs0[4] = RS0_SFP28_P(X+4) */ - {2, 1, 2}, /* map_hard_rs0[5] = RS0_SFP28_P(X+5) */ - {2, 1, 4}, /* map_hard_rs0[6] = RS0_SFP28_P(X+6) */ - {2, 1, 6}, /* map_hard_rs0[7] = RS0_SFP28_P(X+7) */ - }, - .map_hard_rs1 = { {2, 0, 1}, /* map_hard_rs1[0] = RS1_SFP28_P(X) */ - {2, 0, 3}, /* map_hard_rs1[1] = RS1_SFP28_P(X+1) */ - {2, 0, 5}, /* map_hard_rs1[2] = RS1_SFP28_P(X+2) */ - {2, 0, 7}, /* map_hard_rs1[3] = RS1_SFP28_P(X+3) */ - {2, 1, 1}, /* map_hard_rs1[4] = RS1_SFP28_P(X+4) */ - {2, 1, 3}, /* map_hard_rs1[5] = RS1_SFP28_P(X+5) */ - {2, 1, 5}, /* map_hard_rs1[6] = RS1_SFP28_P(X+6) */ - {2, 1, 7}, /* map_hard_rs1[7] = RS1_SFP28_P(X+7) */ - }, -}; - -struct ioexp_map_s ioexp_map_cypress_7abc = { - - .chip_amount = 3, - .data_width = 2, - - .map_present = { {2, 0, 0}, /* map_present[0] = MOD_ABS_PORT(X) */ - {2, 0, 1}, /* map_present[1] = MOD_ABS_PORT(X+1) */ - {2, 0, 2}, /* map_present[2] = MOD_ABS_PORT(X+2) */ - {2, 0, 3}, /* map_present[3] = MOD_ABS_PORT(X+3) */ - {2, 0, 4}, /* map_present[4] = MOD_ABS_PORT(X+4) */ - {2, 0, 5}, /* map_present[5] = MOD_ABS_PORT(X+5) */ - }, - .map_reset = { {0, 0, 0}, /* map_reset[0] = QRESET_QSFP_N_P(X) */ - {0, 0, 1}, /* map_reset[1] = QRESET_QSFP_N_P(X+1) */ - {0, 0, 2}, /* map_reset[2] = QRESET_QSFP_N_P(X+2) */ - {0, 0, 3}, /* map_reset[3] = QRESET_QSFP_N_P(X+3) */ - {0, 0, 4}, /* map_reset[4] = QRESET_QSFP_N_P(X+4) */ - {0, 0, 5}, /* map_reset[5] = QRESET_QSFP_N_P(X+5) */ - }, - .map_lpmod = { {0, 1, 0}, /* map_lpmod[0] = LPMODE_QSFP_P(X) */ - {0, 1, 1}, /* map_lpmod[1] = LPMODE_QSFP_P(X+1) */ - {0, 1, 2}, /* map_lpmod[2] = LPMODE_QSFP_P(X+2) */ - {0, 1, 3}, /* map_lpmod[3] = LPMODE_QSFP_P(X+3) */ - {0, 1, 4}, /* map_lpmod[4] = LPMODE_QSFP_P(X+4) */ - {0, 1, 5}, /* map_lpmod[5] = LPMODE_QSFP_P(X+5) */ - }, - .map_modsel = { {1, 1, 0}, /* map_modsel[0] = MODSEL_QSFP_N_P(X) */ - {1, 1, 1}, /* map_modsel[1] = MODSEL_QSFP_N_P(X+1) */ - {1, 1, 2}, /* map_modsel[2] = MODSEL_QSFP_N_P(X+2) */ - {1, 1, 3}, /* map_modsel[3] = MODSEL_QSFP_N_P(X+3) */ - {1, 1, 4}, /* map_modsel[4] = MODSEL_QSFP_N_P(X+4) */ - {1, 1, 5}, /* map_modsel[5] = MODSEL_QSFP_N_P(X+5) */ - }, -}; - - -/* ========== Private functions ========== - */ -int check_channel_tier_1(void); - -struct i2c_client * -_get_i2c_client(struct ioexp_obj_s *self, - int chip_id){ - - struct ioexp_i2c_s *i2c_curr_p = self->i2c_head_p; - - if (!(i2c_curr_p)){ - SWPS_ERR("%s: i2c_curr_p is NULL\n", __func__); - return NULL; - } - while (i2c_curr_p){ - if ((i2c_curr_p->chip_id) == chip_id){ - return i2c_curr_p->i2c_client_p; - } - i2c_curr_p = i2c_curr_p->next; - } - SWPS_ERR("%s: not exist! :%d\n", __func__, chip_id); - return NULL; -} - - -static int -_common_ioexp_update_one(struct ioexp_obj_s *self, - struct ioexp_addr_s *ioexp_addr, - int chip_id, - int data_width, - int show_err, - char *caller_name) { - int buf = 0; - int err = 0; - int data_id = 0; - int r_offset = 0; - - for(data_id=0; data_idread_offset[data_id]; - buf = i2c_smbus_read_byte_data(_get_i2c_client(self, chip_id), r_offset); - /* Check error */ - if (buf < 0) { - err = 1; - if (show_err) { - SWPS_INFO("IOEXP-%d read fail! :%d \n", self->ioexp_id, buf); - SWPS_INFO("Dump: :%d :0x%02x :%d, :%s\n", - ioexp_addr->chan_id, ioexp_addr->chip_addr, - ioexp_addr->read_offset[data_id], caller_name); - } - continue; - } - /* Update IOEXP object */ - self->chip_data[chip_id].data[data_id] = (uint8_t)buf; - } - if (err) { - return ERR_IOEXP_UNEXCPT; - } - return 0; -} - - -static int -common_ioexp_update_all(struct ioexp_obj_s *self, - int show_err, - char *caller_name){ - - int err = 0; - int chip_id = 0; - int chip_amount = self->ioexp_map_p->chip_amount; - - for (chip_id=0; chip_idioexp_map_p->map_addr[chip_id]), - chip_id, - self->ioexp_map_p->data_width, - show_err, - caller_name) < 0) { - err = 1; - } - } - if (err) { - return ERR_IOEXP_UNEXCPT; - } - return 0; -} - - -static int -_common_check_by_mode(struct ioexp_obj_s *self){ - - switch (self->mode){ - case IOEXP_MODE_DIRECT: - return self->fsm_4_direct(self); - - case IOEXP_MODE_POLLING: - if (self->state >= 0){ - return 0; - } - switch (self->state){ - case STATE_IOEXP_INIT: - return ERR_IOEXP_UNINIT; - case STATE_IOEXP_ABNORMAL: - return ERR_IOEXP_ABNORMAL; - default: - return ERR_IOEXP_NOSTATE; - } - break; - - default: - break; - } - SWPS_ERR("%s: Exception occurs. :%d \n", __func__, self->mode); - return ERR_IOEXP_UNEXCPT; -} - - -static int -_common_get_bit(struct ioexp_obj_s *self, - struct ioexp_bitmap_s *bitmap_obj_p, - char *func_mane){ - uint8_t buf; - int err_code; - - /* Check and get address */ - err_code = _common_check_by_mode(self); - if (err_code < 0){ - return err_code; - } - if (!bitmap_obj_p){ - SWPS_ERR("Layout config incorrect! :%d :%s\n", - self->ioexp_id, func_mane); - return ERR_IOEXP_BADCONF; - } - /* Get data form cache */ - buf = self->chip_data[bitmap_obj_p->chip_id].data[bitmap_obj_p->ioexp_voffset]; - return (int)(buf >> bitmap_obj_p->bit_shift & 0x01); -} - - -static int -_common_set_bit(struct ioexp_obj_s *self, - struct ioexp_bitmap_s *bitmap_obj_p, - int input_val, - char *func_mane){ - int err_code, target_offset; - uint8_t origin_byte; - uint8_t modify_byte; - - /* Check and get address */ - err_code = _common_check_by_mode(self); - if (err_code < 0){ - return err_code; - } - if (!bitmap_obj_p){ - SWPS_ERR("Layout config incorrect! :%d :%s\n", - self->ioexp_id, func_mane); - return ERR_IOEXP_BADCONF; - } - /* Prepare write date */ - origin_byte = self->chip_data[bitmap_obj_p->chip_id].data[bitmap_obj_p->ioexp_voffset]; - switch (input_val) { - case 0: - modify_byte = origin_byte; - SWP_BIT_CLEAR(modify_byte, bitmap_obj_p->bit_shift); - break; - case 1: - modify_byte = origin_byte; - SWP_BIT_SET(modify_byte, bitmap_obj_p->bit_shift); - break; - default: - SWPS_ERR("Input value incorrect! :%d :%d :%s\n", - input_val, self->ioexp_id, func_mane); - return ERR_IOEXP_BADINPUT; - } - /* Setup i2c client */ - target_offset = self->ioexp_map_p->map_addr[bitmap_obj_p->chip_id].write_offset[bitmap_obj_p->ioexp_voffset]; - /* Write byte to chip via I2C */ - err_code = i2c_smbus_write_byte_data(_get_i2c_client(self, bitmap_obj_p->chip_id), - target_offset, - modify_byte); - /* Update or bollback object */ - if (err_code < 0){ - self->chip_data[bitmap_obj_p->chip_id].data[bitmap_obj_p->ioexp_voffset] = origin_byte; - SWPS_ERR("I2C write fail! :%d :%d :%s :%d\n", - input_val, self->ioexp_id, func_mane, err_code); - return err_code; - } - self->chip_data[bitmap_obj_p->chip_id].data[bitmap_obj_p->ioexp_voffset] = modify_byte; - return 0; -} - - -/* ========== Object public functions ========== - */ -int -common_get_present(struct ioexp_obj_s *self, - int virt_offset){ - - int UNPLUG = 1; - int retval = ERR_IOEXP_UNEXCPT; - - retval = _common_get_bit(self, - &(self->ioexp_map_p->map_present[virt_offset]), - "common_get_present"); - if (retval < 0) { - /* [Note] - * => Transceiver object does not need to handle IOEXP layer issues. - */ - return UNPLUG; - } - return retval; -} - - -int -common_get_tx_fault(struct ioexp_obj_s *self, - int virt_offset){ - /* [Transmit Fault (Tx_Fault)] - * A catastrophic laser fault will activate the transmitter signal, - * TX_FAULT, and disable the laser. This signal is an open collector - * output (pull-up required on the host board). A low signal indicates - * normal laser operation and a high signal indicates a fault. The - * TX_FAULT will be latched high when a laser fault occurs and is - * cleared by toggling the TX_DISABLE input or power cycling the - * transceiver. The transmitter fault condition can also be monitored - * via the two-wire serial interface. - * (address A2, byte 110, bit 2). - * - * 0: Normal - * 1: Abnormal - */ - return _common_get_bit(self, - &(self->ioexp_map_p->map_tx_fault[virt_offset]), - "common_get_tx_fault"); -} - - -int -common_get_rxlos(struct ioexp_obj_s *self, - int virt_offset){ - /* [Receiver Loss of Signal (Rx_LOS)] - * The post-amplification IC also includes transition detection circuitry - * which monitors the ac level of incoming optical signals and provides a - * TTL/CMOS compatible status signal to the host (pin 8). An adequate optical - * input results in a low Rx_LOS output while a high Rx_LOS output indicates - * an unusable optical input. The Rx_LOS thresholds are factory set so that - * a high output indicates a definite optical fault has occurred. Rx_LOS can - * also be monitored via the two-wire serial interface - * (address A2h, byte 110, bit 1). - * - * 0: Normal - * 1: Abnormal - */ - return _common_get_bit(self, - &(self->ioexp_map_p->map_rxlos[virt_offset]), - "common_get_rxlos"); -} - - -int -common_get_tx_disable(struct ioexp_obj_s *self, - int virt_offset){ - - return _common_get_bit(self, - &(self->ioexp_map_p->map_tx_disable[virt_offset]), - "common_get_tx_disable"); -} - - -int -common_get_reset(struct ioexp_obj_s *self, - int virt_offset){ - - return _common_get_bit(self, - &(self->ioexp_map_p->map_reset[virt_offset]), - "common_get_reset"); -} - - -int -common_get_lpmod(struct ioexp_obj_s *self, - int virt_offset){ - - return _common_get_bit(self, - &(self->ioexp_map_p->map_lpmod[virt_offset]), - "common_get_lpmod"); -} - - -int -common_get_modsel(struct ioexp_obj_s *self, - int virt_offset){ - - return _common_get_bit(self, - &(self->ioexp_map_p->map_modsel[virt_offset]), - "common_get_modsel"); -} - - -int -common_get_hard_rs0(struct ioexp_obj_s *self, - int virt_offset){ - - return _common_get_bit(self, - &(self->ioexp_map_p->map_hard_rs0[virt_offset]), - "common_get_hard_rs0"); -} - - -int -common_get_hard_rs1(struct ioexp_obj_s *self, - int virt_offset){ - - return _common_get_bit(self, - &(self->ioexp_map_p->map_hard_rs1[virt_offset]), - "common_get_hard_rs1"); -} - - -int -common_set_tx_disable(struct ioexp_obj_s *self, - int virt_offset, - int input_val){ - - return _common_set_bit(self, - &(self->ioexp_map_p->map_tx_disable[virt_offset]), - input_val, - "common_set_tx_disable"); -} - - -int -common_set_reset(struct ioexp_obj_s *self, - int virt_offset, - int input_val){ - - return _common_set_bit(self, - &(self->ioexp_map_p->map_reset[virt_offset]), - input_val, - "common_set_reset"); -} - - -int -common_set_lpmod(struct ioexp_obj_s *self, - int virt_offset, - int input_val){ - - return _common_set_bit(self, - &(self->ioexp_map_p->map_lpmod[virt_offset]), - input_val, - "common_set_lpmod"); -} - - -int -common_set_modsel(struct ioexp_obj_s *self, - int virt_offset, - int input_val){ - - return _common_set_bit(self, - &(self->ioexp_map_p->map_modsel[virt_offset]), - input_val, - "common_set_modsel"); -} - - -int -common_set_hard_rs0(struct ioexp_obj_s *self, - int virt_offset, - int input_val){ - - return _common_set_bit(self, - &(self->ioexp_map_p->map_hard_rs0[virt_offset]), - input_val, - "common_set_hard_rs0"); -} - - -int -common_set_hard_rs1(struct ioexp_obj_s *self, - int virt_offset, - int input_val){ - - return _common_set_bit(self, - &(self->ioexp_map_p->map_hard_rs1[virt_offset]), - input_val, - "common_set_hard_rs1"); -} - - -int -ioexp_get_not_support(struct ioexp_obj_s *self, - int virt_offset){ - return ERR_IOEXP_NOTSUPPORT; -} - - -int -ioexp_set_not_support(struct ioexp_obj_s *self, - int virt_offset, - int input_val){ - return ERR_IOEXP_NOTSUPPORT; -} - - -int -fake_ioexp_init(struct ioexp_obj_s *self){ - return 1; -} - -int -fake_ioexp_update(struct ioexp_obj_s *self){ - return 1; -} - - -int -fake_update_func(struct ioexp_obj_s *self){ - return 1; -} - -int -fake_get_func(struct ioexp_obj_s *self, - int virt_offset){ - SWPS_WARN("Someone called fake_get_func\n"); - return -1; -} - -int -fake_set_func(struct ioexp_obj_s *self, - int virt_offset, - int input_val){ - SWPS_WARN("Someone called fake_set_func\n"); - return -1; -} - - -/* ========== Initial functions for IO Expander ========== - */ -int -common_ioexp_init(struct ioexp_obj_s *self) { - - int chip_id, offset, err_code; - struct ioexp_addr_s *addr_p; - - /* Setup default value to each physical IO Expander */ - for (chip_id=0; chip_id<(self->ioexp_map_p->chip_amount); chip_id++){ - /* Get address mapping */ - addr_p = &(self->ioexp_map_p->map_addr[chip_id]); - if (!addr_p){ - SWPS_ERR("%s: IOEXP config incorrect! :%d \n", - __func__, chip_id); - return -1; - } - /* Setup default value */ - for (offset=0; offset<(self->ioexp_map_p->data_width); offset++){ - err_code = i2c_smbus_write_byte_data(_get_i2c_client(self, chip_id), - addr_p->write_offset[offset], - addr_p->data_default[offset]); - if (err_code < 0){ - SWPS_ERR("%s: set default fail! :%d \n", - __func__, err_code); - return ERR_IOEXP_UNEXCPT; - } - } - } - /* Check and update info to object */ - err_code = self->update_all(self, 1, "common_ioexp_init"); - if (err_code < 0) { - SWPS_ERR("%s: update_all() fail! :%d \n", - __func__, err_code); - return ERR_IOEXP_UNEXCPT; - } - return 0; -} - - -/* ========== Object functions for Final State Machine ========== - */ -int -_is_channel_ready(struct ioexp_obj_s *self){ - - int buf = 0; - int chip_id = 0; /* Use first chip which be registered */ - int data_id = 0; /* Use first byte which be registered */ - struct ioexp_addr_s *ioexp_addr = NULL; - - ioexp_addr = &(self->ioexp_map_p->map_addr[chip_id]); - if (!ioexp_addr){ - SWPS_ERR("%s: config incorrect!\n", __func__); - return ERR_IOEXP_UNEXCPT; - } - buf = i2c_smbus_read_byte_data(_get_i2c_client(self, chip_id), - ioexp_addr->read_offset[data_id]); - if (buf >= 0){ - return 1; - } - return 0; -} - -int -_ioexp_init_handler(struct ioexp_obj_s *self){ - - int return_val; - - switch (self->mode) { - case IOEXP_MODE_DIRECT: - return_val = self->init(self); - if (return_val < 0){ - self->state = STATE_IOEXP_ABNORMAL; - } else { - self->state = STATE_IOEXP_NORMAL; - } - return return_val; - - case IOEXP_MODE_POLLING: - /* Check system and channel is ready */ - if (self->state == STATE_IOEXP_INIT){ - if (!_is_channel_ready(self)){ - self->state = STATE_IOEXP_INIT; - SWPS_WARN("%s: IOEXP:%d channel not ready.\n", - __func__, self->ioexp_id); - return 0; - } - } - /* Execute initial callback */ - return_val = self->init(self); - if (return_val < 0){ - self->state = STATE_IOEXP_ABNORMAL; - } else { - self->state = STATE_IOEXP_NORMAL; - } - return return_val; - - default: - break; - } - SWPS_ERR("%s: exception occur :%d\n", __func__, self->mode); - return ERR_IOEXP_UNEXCPT; -} - - -int -common_ioexp_fsm_4_direct(struct ioexp_obj_s *self){ - - int result_val; - int show_err = 1; - char *func_mane = "common_ioexp_fsm_4_direct"; - - switch (self->state){ - case STATE_IOEXP_INIT: - result_val = _ioexp_init_handler(self); - /* Exception case: terminate initial procedure */ - if(result_val < 0){ - /* Initial fail */ - return result_val; - } - if(self->state == STATE_IOEXP_INIT){ - /* Keep in INIT state, and return error */ - return ERR_IOEXP_UNINIT; - } - /* Case: Initial done */ - return 0; - - case STATE_IOEXP_NORMAL: - result_val = self->update_all(self, show_err, func_mane); - if (result_val < 0){ - SWPS_INFO("%s: NORMAL -> ABNORMAL :%d\n", - __func__, result_val); - self->state = STATE_IOEXP_ABNORMAL; - return result_val; - } - self->state = STATE_IOEXP_NORMAL; - return 0; - - case STATE_IOEXP_ABNORMAL: - result_val = self->update_all(self, show_err, func_mane); - if (result_val < 0){ - self->state = STATE_IOEXP_ABNORMAL; - return result_val; - } - SWPS_DEBUG("%s: ABNORMAL -> NORMAL :%d\n", - __func__, result_val); - self->state = STATE_IOEXP_NORMAL; - return 0; - - default: - break; - } - SWPS_ERR("%s: Exception occurs :%d\n", - __func__, self->state); - return ERR_IOEXP_UNEXCPT; -} - - -int -common_ioexp_fsm_4_polling(struct ioexp_obj_s *self){ - - int result_val, i, show_e; - int fail_retry = 3; - char *func_name = "common_ioexp_fsm_4_polling"; - -#ifdef DEBUG_SWPS - show_e = 1; -#else - show_e = 0; -#endif - - switch (self->state){ - case STATE_IOEXP_INIT: - result_val = _ioexp_init_handler(self); - /* Exception case: terminate initial procedure */ - if(result_val < 0){ - /* Initial fail */ - return result_val; - } - /* Case: System (Channel) not ready */ - if(self->state == STATE_IOEXP_INIT){ - /* Keep in INIT state, wait and retry */ - return 0; - } - /* Case: Initial done */ - SWPS_INFO("IOEXP-%d: initial done. :%d\n", - self->ioexp_id, self->ioexp_type); - return result_val; - - case STATE_IOEXP_NORMAL: - /* Retry mechanism for case of i2c topology not stable */ - for (i=0; iupdate_all(self, show_e, func_name); - if (result_val >= 0) { - self->state = STATE_IOEXP_NORMAL; - return 0; - } - if (check_channel_tier_1() < 0) { - SWPS_INFO("%s: detect I2C crash :%d\n", - __func__, self->ioexp_id); - break; - } - SWPS_DEBUG("IOEXP-%d: unstable :%d\n", - self->ioexp_id, result_val); - } - SWPS_INFO("IOEXP-%d: NORMAL -> ABNORMAL :%d\n", - self->ioexp_id, result_val); - self->state = STATE_IOEXP_ABNORMAL; - return result_val; - - case STATE_IOEXP_ABNORMAL: - result_val = self->update_all(self, show_e, func_name); - if (result_val < 0){ - self->state = STATE_IOEXP_ABNORMAL; - return result_val; - } - SWPS_INFO("IOEXP-%d: ABNORMAL -> NORMAL :%d\n", - self->ioexp_id, result_val); - self->state = STATE_IOEXP_NORMAL; - return 0; - - default: - break; - } - SWPS_ERR("IOEXP-%d: Exception occurs :%d\n", - self->ioexp_id, self->state); - return ERR_IOEXP_UNEXCPT; -} - - -/* ========== Object private functions for check & update ========== - */ -int -common_ioexp_check(struct ioexp_obj_s *self){ - - int result; - - if (self->mode != IOEXP_MODE_POLLING){ - SWPS_ERR("%s: not polling mode :%d\n", - __func__, self->mode); - return ERR_IOEXP_NOTSUPPORT; - } - mutex_lock(&self->lock); - result = self->fsm_4_polling(self); - mutex_unlock(&self->lock); - return result; -} - - -/* ========== Functions for Factory pattern ========== - */ -static struct ioexp_map_s * -get_ioexp_map(int ioexp_type){ - switch (ioexp_type){ - case IOEXP_TYPE_MAGINOLIA_NAB: - return &ioexp_map_magnolia_nab; - case IOEXP_TYPE_MAGINOLIA_7AB: - case IOEXP_TYPE_SPRUCE_7AB: - return &ioexp_map_magnolia_7ab; - case IOEXP_TYPE_REDWOOD_P01P08: - return &ioexp_map_redwood_p01p08_p17p24; - case IOEXP_TYPE_REDWOOD_P09P16: - return &ioexp_map_redwood_p09p16_p25p32; - case IOEXP_TYPE_HUDSON32IGA_P01P08: - return &ioexp_map_hudson32iga_p01p08_p17p24; - case IOEXP_TYPE_HUDSON32IGA_P09P16: - return &ioexp_map_hudson32iga_p09p16_p25p32; - case IOEXP_TYPE_CYPRESS_NABC: - return &ioexp_map_cypress_nabc; - case IOEXP_TYPE_CYPRESS_7ABC: - return &ioexp_map_cypress_7abc; - - default: - return NULL; - } -} - - -int -setup_ioexp_ssize_attr(struct ioexp_obj_s *self, - struct ioexp_map_s *ioexp_map_p, - int ioexp_id, - int ioexp_type, - int run_mode){ - switch (run_mode){ - case IOEXP_MODE_POLLING: /* Direct access device mode */ - case IOEXP_MODE_DIRECT: /* Polling mode, read from cache */ - self->mode = run_mode; - break; - default: - SWPS_ERR("%s: non-defined run_mode:%d\n", - __func__, run_mode); - self->mode = ERR_IOEXP_UNEXCPT; - return ERR_IOEXP_UNEXCPT; - } - self->ioexp_id = ioexp_id; - self->ioexp_type = ioexp_type; - self->ioexp_map_p = ioexp_map_p; - self->state = STATE_IOEXP_INIT; - mutex_init(&self->lock); - return 0; -} - - -static int -setup_addr_mapping(struct ioexp_obj_s *self, - struct ioexp_addr_s *addr_map_p){ - if (!addr_map_p){ - SWPS_ERR("%s: map is null\n", __func__); - return -1; - } - self->ioexp_map_p->map_addr = addr_map_p; - return 0; -} - - -static int -setup_ioexp_public_cb(struct ioexp_obj_s *self, - int ioexp_type){ - - switch (ioexp_type){ - case IOEXP_TYPE_MAGINOLIA_NAB: - self->get_present = common_get_present; - self->get_tx_fault = common_get_tx_fault; - self->get_rxlos = common_get_rxlos; - self->get_tx_disable = common_get_tx_disable; - self->get_reset = ioexp_get_not_support; - self->get_lpmod = ioexp_get_not_support; - self->get_modsel = ioexp_get_not_support; - self->get_hard_rs0 = ioexp_get_not_support; - self->get_hard_rs1 = ioexp_get_not_support; - self->set_tx_disable = common_set_tx_disable; - self->set_reset = ioexp_set_not_support; - self->set_lpmod = ioexp_set_not_support; - self->set_modsel = ioexp_set_not_support; - self->set_hard_rs0 = ioexp_set_not_support; - self->set_hard_rs1 = ioexp_set_not_support; - return 0; - case IOEXP_TYPE_CYPRESS_NABC: - self->get_present = common_get_present; - self->get_tx_fault = common_get_tx_fault; - self->get_rxlos = common_get_rxlos; - self->get_tx_disable = common_get_tx_disable; - self->get_reset = ioexp_get_not_support; - self->get_lpmod = ioexp_get_not_support; - self->get_modsel = ioexp_get_not_support; - self->get_hard_rs0 = common_get_hard_rs0; - self->get_hard_rs1 = common_get_hard_rs1; - self->set_tx_disable = common_set_tx_disable; - self->set_reset = ioexp_set_not_support; - self->set_lpmod = ioexp_set_not_support; - self->set_modsel = ioexp_set_not_support; - self->set_hard_rs0 = common_set_hard_rs0; - self->set_hard_rs1 = common_set_hard_rs1; - return 0; - case IOEXP_TYPE_MAGINOLIA_7AB: - case IOEXP_TYPE_SPRUCE_7AB: - case IOEXP_TYPE_CYPRESS_7ABC: - self->get_present = common_get_present; - self->get_tx_fault = ioexp_get_not_support; - self->get_rxlos = ioexp_get_not_support; - self->get_tx_disable = ioexp_get_not_support; - self->get_reset = common_get_reset; - self->get_lpmod = common_get_lpmod; - self->get_modsel = common_get_modsel; - self->get_hard_rs0 = ioexp_get_not_support; - self->get_hard_rs1 = ioexp_get_not_support; - self->set_tx_disable = ioexp_set_not_support; - self->set_reset = common_set_reset; - self->set_lpmod = common_set_lpmod; - self->set_modsel = common_set_modsel; - self->set_hard_rs0 = ioexp_set_not_support; - self->set_hard_rs1 = ioexp_set_not_support; - return 0; - case IOEXP_TYPE_REDWOOD_P01P08: - case IOEXP_TYPE_REDWOOD_P09P16: - case IOEXP_TYPE_HUDSON32IGA_P01P08: - case IOEXP_TYPE_HUDSON32IGA_P09P16: - self->get_present = common_get_present; - self->get_tx_fault = ioexp_get_not_support; - self->get_rxlos = ioexp_get_not_support; - self->get_tx_disable = ioexp_get_not_support; - self->get_reset = common_get_reset; - self->get_lpmod = common_get_lpmod; - self->get_modsel = common_get_modsel; - self->get_hard_rs0 = ioexp_get_not_support; - self->get_hard_rs1 = ioexp_get_not_support; - self->set_tx_disable = ioexp_set_not_support; - self->set_reset = common_set_reset; - self->set_lpmod = common_set_lpmod; - self->set_modsel = common_set_modsel; - self->set_hard_rs0 = ioexp_set_not_support; - self->set_hard_rs1 = ioexp_set_not_support; - return 0; - - default: - SWPS_ERR("%s: type:%d incorrect!\n", __func__, ioexp_type); - break; - } - return ERR_IOEXP_UNEXCPT; -} - - -static int -setup_ioexp_private_cb(struct ioexp_obj_s *self, - int ioexp_type){ - - switch (ioexp_type){ - case IOEXP_TYPE_MAGINOLIA_NAB: - case IOEXP_TYPE_MAGINOLIA_7AB: - case IOEXP_TYPE_SPRUCE_7AB: - case IOEXP_TYPE_REDWOOD_P01P08: - case IOEXP_TYPE_REDWOOD_P09P16: - case IOEXP_TYPE_HUDSON32IGA_P01P08: - case IOEXP_TYPE_HUDSON32IGA_P09P16: - case IOEXP_TYPE_CYPRESS_NABC: - case IOEXP_TYPE_CYPRESS_7ABC: - self->init = common_ioexp_init; - self->check = common_ioexp_check; - self->update_all = common_ioexp_update_all; - self->fsm_4_direct = common_ioexp_fsm_4_direct; - self->fsm_4_polling = common_ioexp_fsm_4_polling; - return 0; - - default: - SWPS_ERR("%s: type:%d incorrect!\n", __func__, ioexp_type); - break; - } - return ERR_IOEXP_UNEXCPT; -} - - -static int -setup_i2c_client_one(struct ioexp_obj_s *self, - int chip_id){ - - char *err_msg = "ERROR"; - struct i2c_adapter *adap = NULL; - struct i2c_client *client = NULL; - struct ioexp_i2c_s *i2c_obj_p = NULL; - struct ioexp_i2c_s *i2c_curr_p = NULL; - - int chan_id = self->ioexp_map_p->map_addr[chip_id].chan_id; - adap = i2c_get_adapter(chan_id); - if(!adap){ - err_msg = "Can not get adap!"; - goto err_ioexp_setup_i2c_1; - } - client = kzalloc(sizeof(*client), GFP_KERNEL); - if (!client){ - err_msg = "Can not kzalloc client!"; - goto err_ioexp_setup_i2c_1; - } - i2c_obj_p = kzalloc(sizeof(*i2c_obj_p), GFP_KERNEL); - if (!i2c_obj_p){ - err_msg = "Can not kzalloc i2c_obj_p!"; - goto err_ioexp_setup_i2c_2; - } - client->adapter = adap; - client->addr = self->ioexp_map_p->map_addr[chip_id].chip_addr; - i2c_obj_p->i2c_client_p = client; - i2c_obj_p->chip_id = chip_id; - i2c_obj_p->next = NULL; - if (!self->i2c_head_p){ - self->i2c_head_p = i2c_obj_p; - } else { - i2c_curr_p = self->i2c_head_p; - while (i2c_curr_p->next){ - i2c_curr_p = i2c_curr_p->next; - } - i2c_curr_p->next = i2c_obj_p; - } - return 0; - -err_ioexp_setup_i2c_2: - kfree(client); -err_ioexp_setup_i2c_1: - SWPS_ERR("%s: %s :%d\n", __func__, err_msg, chan_id); - return -1; -} - - -static int -setup_i2c_client(struct ioexp_obj_s* self){ - - int result; - int chip_id = 0; - - for (chip_id=0; chip_id<(self->ioexp_map_p->chip_amount); chip_id++){ - result = setup_i2c_client_one(self, chip_id); - if (result < 0){ - SWPS_ERR("%s fail! :%d\n", __func__, chip_id); - return -1; - } - } - return 0; -} - - -static int -setup_ioexp_config(struct ioexp_obj_s *self) { - - int chip_id, offset, err_code; - struct ioexp_addr_s *addr_p; - - for (chip_id=0; chip_id<(self->ioexp_map_p->chip_amount); chip_id++){ - addr_p = &(self->ioexp_map_p->map_addr[chip_id]); - if (!addr_p){ - SWPS_ERR("IOEXP config incorrect! :%d \n",chip_id); - return -1; - } - for (offset=0; offset<(self->ioexp_map_p->data_width); offset++){ - - err_code = i2c_smbus_write_byte_data(_get_i2c_client(self, chip_id), - addr_p->conf_offset[offset], - addr_p->conf_default[offset]); - - if (err_code < 0){ - SWPS_INFO("%s: set conf fail! :%d \n", __func__, err_code); - return -2; - } - } - } - return 0; -} - - -struct ioexp_obj_s * -_create_ioexp_obj(int ioexp_id, - int ioexp_type, - struct ioexp_addr_s *addr_map_p, - int run_mode){ - - struct ioexp_map_s* ioexp_map_p; - struct ioexp_obj_s* result_p; - struct ioexp_i2c_s *i2c_curr_p; - struct ioexp_i2c_s *i2c_next_p; - - /* Get layout */ - ioexp_map_p = get_ioexp_map(ioexp_type); - if (!ioexp_map_p){ - SWPS_ERR("%s: Invalid ioexp_type\n", __func__); - goto err_create_ioexp_fail; - } - /* Prepare IOEXP object */ - result_p = kzalloc(sizeof(*result_p), GFP_KERNEL); - if (!result_p){ - SWPS_ERR("%s: kzalloc failure!\n", __func__); - goto err_create_ioexp_fail; - } - /* Prepare static size attributes */ - if (setup_ioexp_ssize_attr(result_p, - ioexp_map_p, - ioexp_id, - ioexp_type, - run_mode) < 0){ - goto err_create_ioexp_setup_attr_fail; - } - /* Prepare address mapping */ - if (setup_addr_mapping(result_p, addr_map_p) < 0){ - goto err_create_ioexp_setup_attr_fail; - } - if (setup_i2c_client(result_p) < 0){ - goto err_create_ioexp_setup_i2c_fail; - } - /* Prepare call back functions of object */ - if (setup_ioexp_public_cb(result_p, ioexp_type) < 0){ - goto err_create_ioexp_setup_i2c_fail; - } - if (setup_ioexp_private_cb(result_p, ioexp_type) < 0){ - goto err_create_ioexp_setup_i2c_fail; - } - return result_p; - -err_create_ioexp_setup_i2c_fail: - i2c_curr_p = result_p->i2c_head_p; - i2c_next_p = result_p->i2c_head_p; - while (i2c_curr_p){ - i2c_next_p = i2c_curr_p->next; - kfree(i2c_curr_p->i2c_client_p); - kfree(i2c_curr_p); - i2c_curr_p = i2c_next_p; - } -err_create_ioexp_setup_attr_fail: - kfree(result_p); -err_create_ioexp_fail: - SWPS_ERR("%s: fail! :%d :%d \n", - __func__, ioexp_id, ioexp_type); - return NULL; -} - - -int -create_ioexp_obj(int ioexp_id, - int ioexp_type, - struct ioexp_addr_s *addr_map_p, - int run_mode){ - - struct ioexp_obj_s *ioexp_p = NULL; - - ioexp_p = _create_ioexp_obj(ioexp_id, ioexp_type, - addr_map_p, run_mode); - if (!ioexp_p){ - return -1; - } - if (ioexp_head_p == NULL){ - ioexp_head_p = ioexp_p; - ioexp_tail_p = ioexp_p; - return 0; - } - ioexp_tail_p->next = ioexp_p; - ioexp_tail_p = ioexp_p; - return 0; -} -EXPORT_SYMBOL(create_ioexp_obj); - - -static int -_init_ioexp_obj(struct ioexp_obj_s* self) { - - char *err_msg = "ERR"; - char *func_name = "_init_ioexp_obj"; - - /* Setup IOEXP configure byte */ - if (setup_ioexp_config(self) < 0){ - err_msg = "setup_ioexp_config fail"; - goto err_init_ioexp_obj; - } - /* Setup default data */ - if (_ioexp_init_handler(self) < 0){ - err_msg = "_ioexp_init_handler fail"; - goto err_init_ioexp_obj; - } - /* Update all */ - if (self->state == STATE_IOEXP_NORMAL){ - if (self->update_all(self, 1, func_name) < 0){ - err_msg = "update_all() fail"; - goto err_init_ioexp_obj; - } - } - return 0; - -err_init_ioexp_obj: - SWPS_DEBUG("%s: %s\n", __func__, err_msg); - return -1; -} - - -int -init_ioexp_objs(void){ - /* Return value: - * 0: Success - * -1: Detect topology error - * -2: SWPS internal error - */ - - struct ioexp_obj_s *curr_p = ioexp_head_p; - - if (!curr_p) { - SWPS_ERR("%s: ioexp_head_p is NULL\n", __func__); - return -2; - } - while (curr_p) { - if (_init_ioexp_obj(curr_p) < 0) { - SWPS_DEBUG("%s: _init_ioexp_obj() fail\n", __func__); - return -1; - } - curr_p = curr_p->next; - } - SWPS_DEBUG("%s: done.\n", __func__); - return 0; -} -EXPORT_SYMBOL(init_ioexp_objs); - - -void -clean_ioexp_objs(void){ - - struct ioexp_i2c_s *i2c_curr_p = NULL; - struct ioexp_i2c_s *i2c_next_p = NULL; - struct ioexp_obj_s *ioexp_next_p = NULL; - struct ioexp_obj_s *ioexp_curr_p = ioexp_head_p; - - if (ioexp_head_p == NULL){ - ioexp_tail_p = NULL; - return; - } - while(ioexp_curr_p){ - ioexp_next_p = ioexp_curr_p->next; - i2c_curr_p = ioexp_curr_p->i2c_head_p; - while (i2c_curr_p) { - i2c_next_p = i2c_curr_p->next; - kfree(i2c_curr_p->i2c_client_p); - kfree(i2c_curr_p); - i2c_curr_p = i2c_next_p; - } - kfree(ioexp_curr_p); - ioexp_curr_p = ioexp_next_p; - } - ioexp_tail_p = NULL; - SWPS_DEBUG("%s: done.\n", __func__); -} -EXPORT_SYMBOL(clean_ioexp_objs); - - -int -check_ioexp_objs(void){ - - struct ioexp_obj_s *ioexp_curr_p = ioexp_head_p; - - while (ioexp_curr_p){ - if ( (ioexp_curr_p->check(ioexp_curr_p)) < 0){ - SWPS_INFO("check IOEXP-%d fail! :%d\n", - ioexp_curr_p->ioexp_id, ioexp_curr_p->ioexp_type); - return -1; - } - ioexp_curr_p = ioexp_curr_p->next; - } - return 0; -} -EXPORT_SYMBOL(check_ioexp_objs); - - -struct ioexp_obj_s * -get_ioexp_obj(int ioexp_id){ - - struct ioexp_obj_s *result_p = NULL; - struct ioexp_obj_s *ioexp_curr_p = ioexp_head_p; - - while(ioexp_curr_p){ - if (ioexp_curr_p->ioexp_id == ioexp_id){ - result_p = ioexp_curr_p; - break; - } - ioexp_curr_p = ioexp_curr_p->next; - } - return result_p; -} -EXPORT_SYMBOL(get_ioexp_obj); - - -void -unlock_ioexp_all(void) { - - struct ioexp_obj_s *ioexp_curr_p = ioexp_head_p; - - while(ioexp_curr_p){ - mutex_unlock(&ioexp_curr_p->lock); - ioexp_curr_p = ioexp_curr_p->next; - } -} -EXPORT_SYMBOL(unlock_ioexp_all); - - -int -lock_ioexp_all(void) { - - struct ioexp_obj_s *ioexp_curr_p = ioexp_head_p; - - while(ioexp_curr_p){ - mutex_lock(&ioexp_curr_p->lock); - ioexp_curr_p = ioexp_curr_p->next; - } - return 0; -} -EXPORT_SYMBOL(lock_ioexp_all); - - -int -check_channel_tier_1(void) { - - if ( (!_is_channel_ready(ioexp_head_p)) && - (!_is_channel_ready(ioexp_tail_p)) ){ - return -1; - } - return 0; -} -EXPORT_SYMBOL(check_channel_tier_1); - - -static int -_scan_channel_tier_1(int force, - int show_err) { - - struct ioexp_obj_s *ioexp_curr_p = ioexp_head_p; - int ready = 0; - - if (!ioexp_curr_p) { - goto err_scan_tier_1_channel; - } - while(ioexp_curr_p) { - ready = _is_channel_ready(ioexp_curr_p); - if ((!ready) && (!force)) { - goto err_scan_tier_1_channel; - } - ioexp_curr_p = ioexp_curr_p->next; - } - return 0; - -err_scan_tier_1_channel: - if (show_err) { - if (ioexp_curr_p) { - SWPS_INFO("%s: IOEXP-%d fail\n", __func__, ioexp_curr_p->ioexp_id); - } else { - SWPS_INFO("%s: IOEXP is null.\n", __func__); - } - } - return -1; -} - - -static int -_scan_channel_tier_1_single(void) { - - int ret = 0; - int chan_id = 0; - int fake_cid = 0; - int fake_offs = 0; - int fake_addr = 0; - struct i2c_adapter *adap = NULL; - struct i2c_client *client = NULL; - - if (ioexp_head_p->ioexp_id != ioexp_tail_p->ioexp_id) { - return 0; - } - /* Setup i2c_client */ - chan_id = ioexp_head_p->ioexp_map_p->map_addr[fake_cid].chan_id; - fake_addr = ioexp_head_p->ioexp_map_p->map_addr[fake_cid].chip_addr; - adap = i2c_get_adapter((chan_id + 1)); - if(!adap){ - SWPS_INFO("%s: Can not get adap!\n", __func__); - return 0; - } - client = kzalloc(sizeof(*client), GFP_KERNEL); - if (!client){ - SWPS_INFO("%s: Can not kzalloc client!\n", __func__); - return 0; - } - client->adapter = adap; - client->addr = fake_addr; - /* Fouce move ioexp ptr to next */ - ret = i2c_smbus_read_byte_data(client, fake_offs); - SWPS_DEBUG("%s: move ioexp_ptr done. :%d\n"); - kfree(client); - return 1; -} - - -int -resync_channel_tier_1(void) { - - char *emsg = "ERR"; - - if (!ioexp_head_p) { - emsg = "ioexp_head_p is NULL"; - goto err_resync_ioexp_status_1; - } - /* Run all */ - if (ioexp_head_p->ioexp_id == ioexp_tail_p->ioexp_id) { - _scan_channel_tier_1_single(); - } else { - _scan_channel_tier_1(1, 0); - } - /* Check all */ - if (_scan_channel_tier_1(0, 1) < 0) { - emsg = "resync tier-1 channel fail"; - goto err_resync_ioexp_status_1; - } - return 0; - -err_resync_ioexp_status_1: - SWPS_ERR("%s: %s\n", __func__, emsg); - return -1; -} -EXPORT_SYMBOL(resync_channel_tier_1); - - - - -MODULE_LICENSE("GPL"); - diff --git a/packages/platforms/inventec/x86-64/d7054q28b/modules/builds/src/io_expander.h b/packages/platforms/inventec/x86-64/d7054q28b/modules/builds/src/io_expander.h deleted file mode 100644 index d57dfe159..000000000 --- a/packages/platforms/inventec/x86-64/d7054q28b/modules/builds/src/io_expander.h +++ /dev/null @@ -1,185 +0,0 @@ -/************************************************************************* - * - * io_expander.h - * - * 2018 Inventec Corporation - * All Rights Reserved. - * - * NOTICE: All information contained herein is, and remains - * the property of Inventec Corp. and its suppliers, - * if any. The intellectual and technical concepts contained - * herein are proprietary to Inventec Corporation and its suppliers - * and may be covered by U.S. and Foreign Patents, patents in process, - * and are protected by trade secret or copyright law. - * - ************************************************************************/ - -#ifndef IO_EXPANDER_H -#define IO_EXPANDER_H - -#include - - -/* IOEXP type define (SFP series) */ -#define IOEXP_TYPE_MAGINOLIA_NAB (10101) -#define IOEXP_TYPE_CYPRESS_NABC (10102) - -/* IOEXP type define (QSFP series) */ -#define IOEXP_TYPE_MAGINOLIA_7AB (10201) -#define IOEXP_TYPE_REDWOOD_P01P08 (10202) -#define IOEXP_TYPE_REDWOOD_P09P16 (10203) -#define IOEXP_TYPE_HUDSON32IGA_P01P08 (10204) -#define IOEXP_TYPE_HUDSON32IGA_P09P16 (10205) -#define IOEXP_TYPE_SPRUCE_7AB (10206) -#define IOEXP_TYPE_CYPRESS_7ABC (10207) - -/* IOEXP mode define */ -#define IOEXP_MODE_POLLING (19000) -#define IOEXP_MODE_DIRECT (19001) - -/* IOEXP state define */ -#define STATE_IOEXP_NORMAL (0) -#define STATE_IOEXP_INIT (-1) -#define STATE_IOEXP_ABNORMAL (-2) - -/* IOEXP error code define */ -#define ERR_IOEXP_NOTSUPPORT (-100) -#define ERR_IOEXP_UNINIT (-101) -#define ERR_IOEXP_BADCONF (-102) -#define ERR_IOEXP_ABNORMAL (-103) -#define ERR_IOEXP_NOSTATE (-104) -#define ERR_IOEXP_BADINPUT (-105) -#define ERR_IOEXP_UNEXCPT (-199) - - -#define SWPS_INFO(fmt, args...) printk( KERN_INFO "[SWPS] " fmt, ##args) -#define SWPS_WARN(fmt, args...) printk( KERN_WARNING "[SWPS] " fmt, ##args) -#define SWPS_ERR(fmt, args...) printk( KERN_ERR "[SWPS] " fmt, ##args) - -#ifdef DEBUG_SWPS -# define SWPS_DEBUG(fmt, args...) printk( KERN_DEBUG "[SWPS] " fmt, ##args) -#else -# define SWPS_DEBUG(fmt, args...) -#endif - - -struct ioexp_addr_s { - int chan_id; - int chip_addr; - int read_offset[8]; - int write_offset[8]; - int conf_offset[8]; - uint8_t data_default[8]; - uint8_t conf_default[8]; -}; - -struct ioexp_i2c_s { - int chip_id; - struct i2c_client *i2c_client_p; - struct ioexp_i2c_s *next; -}; - - -struct ioexp_bitmap_s { - int chip_id; /* IOEXP chip id */ - int ioexp_voffset; /* IOEXP virtual offset */ - int bit_shift; -}; - -struct ioexp_map_s { - int chip_amount; /* Number of chips that IOEXP object content */ - int data_width; /* Number of (Read/Write/Config) bytes */ - struct ioexp_addr_s *map_addr; /* Chip address info */ - struct ioexp_bitmap_s map_present[8]; /* IOEXP for SFP / QSFP */ - struct ioexp_bitmap_s map_tx_disable[8]; /* IOEXP for SFP */ - struct ioexp_bitmap_s map_tx_fault[8]; /* IOEXP for SFP */ - struct ioexp_bitmap_s map_rxlos[8]; /* IOEXP for SFP */ - struct ioexp_bitmap_s map_reset[8]; /* IOEXP for QSFP */ - struct ioexp_bitmap_s map_lpmod[8]; /* IOEXP for QSFP */ - struct ioexp_bitmap_s map_modsel[8]; /* IOEXP for QSFP */ - struct ioexp_bitmap_s map_hard_rs0[8]; /* IOEXP for QSFP */ - struct ioexp_bitmap_s map_hard_rs1[8]; /* IOEXP for QSFP */ -}; - -struct ioexp_data_s { - uint8_t data[8]; -}; - -struct ioexp_obj_s { - - /* ============================ - * Object public property - * ============================ - */ - int ioexp_id; - int ioexp_type; - - /* ============================ - * Object private property - * ============================ - */ - struct ioexp_data_s chip_data[16]; /* Max: 8-ioexp in one virt-ioexp(ioexp_obj) */ - struct ioexp_map_s *ioexp_map_p; - struct ioexp_obj_s *next; - struct ioexp_i2c_s *i2c_head_p; - struct mutex lock; - int mode; - int state; - - /* =========================================== - * Object public functions - * =========================================== - */ - int (*get_present)(struct ioexp_obj_s *self, int virt_offset); - int (*get_tx_fault)(struct ioexp_obj_s *self, int virt_offset); - int (*get_rxlos)(struct ioexp_obj_s *self, int virt_offset); - int (*get_tx_disable)(struct ioexp_obj_s *self, int virt_offset); - int (*get_reset)(struct ioexp_obj_s *self, int virt_offset); - int (*get_lpmod)(struct ioexp_obj_s *self, int virt_offset); - int (*get_modsel)(struct ioexp_obj_s *self, int virt_offset); - int (*get_hard_rs0)(struct ioexp_obj_s *self, int virt_offset); - int (*get_hard_rs1)(struct ioexp_obj_s *self, int virt_offset); - int (*set_tx_disable)(struct ioexp_obj_s *self, int virt_offset, int input_val); - int (*set_reset)(struct ioexp_obj_s *self, int virt_offset, int input_val); - int (*set_lpmod)(struct ioexp_obj_s *self, int virt_offset, int input_val); - int (*set_modsel)(struct ioexp_obj_s *self, int virt_offset, int input_val); - int (*set_hard_rs0)(struct ioexp_obj_s *self, int virt_offset, int input_val); - int (*set_hard_rs1)(struct ioexp_obj_s *self, int virt_offset, int input_val); - - /* =========================================== - * Object private functions - * =========================================== - */ - int (*init)(struct ioexp_obj_s *self); - int (*check)(struct ioexp_obj_s *self); - int (*update_all)(struct ioexp_obj_s *self, int show_err, char *caller_name); - int (*fsm_4_direct)(struct ioexp_obj_s* self); - int (*fsm_4_polling)(struct ioexp_obj_s* self); -}; - - -struct ioexp_obj_s* get_ioexp_obj(int ioexp_id); -int create_ioexp_obj(int ioexp_id, - int ioexp_type, - struct ioexp_addr_s *addr_map_p, - int run_mode); -int init_ioexp_objs(void); -int check_ioexp_objs(void); -void clean_ioexp_objs(void); - -void unlock_ioexp_all(void); -int lock_ioexp_all(void); - -int check_channel_tier_1(void); -int resync_channel_tier_1(void); - -/* Macro for bit control */ -#define SWP_BIT_SET(byte_val,bit_shift) ((byte_val) |= (1<<(bit_shift))) -#define SWP_BIT_CLEAR(byte_val,bit_shift) ((byte_val) &= ~(1<<(bit_shift))) - - -#endif /* IO_EXPANDER_H */ - - - - diff --git a/packages/platforms/inventec/x86-64/d7054q28b/modules/builds/src/onie_tlvinfo.c b/packages/platforms/inventec/x86-64/d7054q28b/modules/builds/src/onie_tlvinfo.c deleted file mode 100644 index 303ffde76..000000000 --- a/packages/platforms/inventec/x86-64/d7054q28b/modules/builds/src/onie_tlvinfo.c +++ /dev/null @@ -1,820 +0,0 @@ -#include -#include -#include -#include -//#include -#include - -//#include -//#include -#include "onie_tlvinfo.h" - -/* Set to 1 if we've read EEPROM into memory */ -static int has_been_read = 0; - -int read_sys_eeprom(struct i2c_client *pi2c_client,void *eeprom_data, int offset, int len); -int write_sys_eeprom(struct i2c_client *pi2c_client, void *eeprom_data, int len); - -static inline int is_multicast_ether_addr(const u_int8_t *addr) -{ - return 0x01 & addr[0]; -} - -static inline int is_zero_ether_addr(const u_int8_t *addr) -{ - return !(addr[0] | addr[1] | addr[2] | addr[3] | addr[4] | addr[5]); -} - -static inline int is_valid_ether_addr(const u_int8_t *addr) -{ - return !is_multicast_ether_addr(addr) && !is_zero_ether_addr(addr); -} - -#if 0 -static unsigned int crc32(unsigned char const *p, unsigned int len) -{ - int i; - unsigned int crc = 0; - while (len--) { - crc ^= *p++; - for (i = 0; i < 8; i++) - crc = (crc >> 1) ^ ((crc & 1) ? 0xedb88320 : 0); - } - return crc; -} -#else -static unsigned long crc32_tab[] = { - 0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f, - 0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988, - 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91, 0x1db71064, 0x6ab020f2, - 0xf3b97148, 0x84be41de, 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7, - 0x136c9856, 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, 0x14015c4f, 0x63066cd9, - 0xfa0f3d63, 0x8d080df5, 0x3b6e20c8, 0x4c69105e, 0xd56041e4, 0xa2677172, - 0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b, 0x35b5a8fa, 0x42b2986c, - 0xdbbbc9d6, 0xacbcf940, 0x32d86ce3, 0x45df5c75, 0xdcd60dcf, 0xabd13d59, - 0x26d930ac, 0x51de003a, 0xc8d75180, 0xbfd06116, 0x21b4f4b5, 0x56b3c423, - 0xcfba9599, 0xb8bda50f, 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924, - 0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d, 0x76dc4190, 0x01db7106, - 0x98d220bc, 0xefd5102a, 0x71b18589, 0x06b6b51f, 0x9fbfe4a5, 0xe8b8d433, - 0x7807c9a2, 0x0f00f934, 0x9609a88e, 0xe10e9818, 0x7f6a0dbb, 0x086d3d2d, - 0x91646c97, 0xe6635c01, 0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e, - 0x6c0695ed, 0x1b01a57b, 0x8208f4c1, 0xf50fc457, 0x65b0d9c6, 0x12b7e950, - 0x8bbeb8ea, 0xfcb9887c, 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, 0xfbd44c65, - 0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2, 0x4adfa541, 0x3dd895d7, - 0xa4d1c46d, 0xd3d6f4fb, 0x4369e96a, 0x346ed9fc, 0xad678846, 0xda60b8d0, - 0x44042d73, 0x33031de5, 0xaa0a4c5f, 0xdd0d7cc9, 0x5005713c, 0x270241aa, - 0xbe0b1010, 0xc90c2086, 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f, - 0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, 0x59b33d17, 0x2eb40d81, - 0xb7bd5c3b, 0xc0ba6cad, 0xedb88320, 0x9abfb3b6, 0x03b6e20c, 0x74b1d29a, - 0xead54739, 0x9dd277af, 0x04db2615, 0x73dc1683, 0xe3630b12, 0x94643b84, - 0x0d6d6a3e, 0x7a6a5aa8, 0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1, - 0xf00f9344, 0x8708a3d2, 0x1e01f268, 0x6906c2fe, 0xf762575d, 0x806567cb, - 0x196c3671, 0x6e6b06e7, 0xfed41b76, 0x89d32be0, 0x10da7a5a, 0x67dd4acc, - 0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5, 0xd6d6a3e8, 0xa1d1937e, - 0x38d8c2c4, 0x4fdff252, 0xd1bb67f1, 0xa6bc5767, 0x3fb506dd, 0x48b2364b, - 0xd80d2bda, 0xaf0a1b4c, 0x36034af6, 0x41047a60, 0xdf60efc3, 0xa867df55, - 0x316e8eef, 0x4669be79, 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236, - 0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f, 0xc5ba3bbe, 0xb2bd0b28, - 0x2bb45a92, 0x5cb36a04, 0xc2d7ffa7, 0xb5d0cf31, 0x2cd99e8b, 0x5bdeae1d, - 0x9b64c2b0, 0xec63f226, 0x756aa39c, 0x026d930a, 0x9c0906a9, 0xeb0e363f, - 0x72076785, 0x05005713, 0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38, - 0x92d28e9b, 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21, 0x86d3d2d4, 0xf1d4e242, - 0x68ddb3f8, 0x1fda836e, 0x81be16cd, 0xf6b9265b, 0x6fb077e1, 0x18b74777, - 0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c, 0x8f659eff, 0xf862ae69, - 0x616bffd3, 0x166ccf45, 0xa00ae278, 0xd70dd2ee, 0x4e048354, 0x3903b3c2, - 0xa7672661, 0xd06016f7, 0x4969474d, 0x3e6e77db, 0xaed16a4a, 0xd9d65adc, - 0x40df0b66, 0x37d83bf0, 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9, - 0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605, 0xcdd70693, - 0x54de5729, 0x23d967bf, 0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94, - 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d -}; - -static unsigned long crc32(unsigned char const *buf, unsigned int size) -{ - unsigned char *p = buf; - unsigned long crc = 0; - - crc = crc ^ ~0U; - - while (size--) - crc = crc32_tab[(crc ^ *p++) & 0xFF] ^ (crc >> 8); - - return crc ^ ~0U; -} -#endif - -static int set_bytes(char *buf, const char *string, int * converted_accum) -{ - char *p = (char *) string; - int i; - uint byte; - - if (!p) { - printk("ERROR: NULL string passed in.\n"); - return -1; - } - /* Convert string to bytes */ - for (i = 0, p = (char *)string; (i < TLV_VALUE_MAX_LEN) && (*p != 0); - i++) { - while ((*p == ' ') || (*p == '\t') || (*p == ',') || - (*p == ';')) { - p++; - } - if (*p != 0) { - if (!isdigit(*p)) { - printk("ERROR: Non-digit found in byte string: (%s)\n", string); - return -1; - } - byte = strtoul(p, &p, 0); - if (byte >= 256) { - printk("ERROR: The value specified is greater than 255: (%u) " \ - "in string: %s\n", byte, string); - return -1; - } - buf[i] = byte & 0xFF; - } - } - if ((i == TLV_VALUE_MAX_LEN) && (*p != 0)) { - printk("ERROR: Trying to assign too many bytes " - "(max: %d) in string: %s\n", TLV_VALUE_MAX_LEN, string); - return -1; - } - *converted_accum = i; - return 0; -} - -/* - * set_date - * - * Validates the format of the data string - * - * This function takes a pointer to a date string (i.e. MM/DD/YYYY hh:mm:ss) - * and validates that the format is correct. If so the string is copied - * to the supplied buffer. - */ -static int set_date(char *buf, const char *string) -{ - int i; - - if (!string) { - printk("ERROR: NULL date string passed in.\n"); - return -1; - } - if (strlen(string) != 19) { - printk("ERROR: Date strlen() != 19 -- %d\n", strlen(string)); - printk("ERROR: Bad date format (MM/DD/YYYY hh:mm:ss): %s\n", string); - return -1; - } - for (i = 0; string[i] != 0; i++) { - switch (i) { - case 2: - case 5: - if (string[i] != '/') { - printk("ERROR: Bad date format (MM/DD/YYYY hh:mm:ss): %s\n", - string); - return -1; - } - break; - case 10: - if (string[i] != ' ') { - printk("ERROR: Bad date format (MM/DD/YYYY hh:mm:ss): %s\n", - string); - return -1; - } - break; - case 13: - case 16: - if (string[i] != ':') { - printk("ERROR: Bad date format (MM/DD/YYYY hh:mm:ss): %s\n", - string); - return -1; - } - break; - default: - if (!isdigit(string[i])) { - printk("ERROR: Bad date format (MM/DD/YYYY hh:mm:ss): %s\n", - string); - return -1; - } - break; - } - } - strcpy(buf, string); - return 0; -} - -/* - * is_valid_tlv - * - * Perform basic sanity checks on a TLV field. The TLV is pointed to - * by the parameter provided. - * 1. The type code is not reserved (0x00 or 0xFF) - */ -static inline bool is_valid_tlv(tlvinfo_tlv_t *tlv) -{ - return((tlv->type != 0x00) && (tlv->type != 0xFF)); -} - -/* - * set_mac - * - * Converts a string MAC address into a binary buffer. - * - * This function takes a pointer to a MAC address string - * (i.e."XX:XX:XX:XX:XX:XX", where "XX" is a two-digit hex number). - * The string format is verified and then converted to binary and - * stored in a buffer. - */ -static int set_mac(char *buf, const char *string) -{ - char *p = (char *) string; - int i; - int err = 0; - char *end; - - if (!p) { - printk("ERROR: NULL mac addr string passed in.\n"); - return -1; - } - if (strlen(p) != 17) { - printk("ERROR: MAC address strlen() != 17 -- %d\n", strlen(p)); - printk("ERROR: Bad MAC address format: %s\n", string); - return -1; - } - for (i = 0; i < 17; i++) { - if ((i % 3) == 2) { - if (p[i] != ':') { - err++; - printk("ERROR: mac: p[%i] != :, found: `%c'\n", - i, p[i]); - break; - } - continue; - } else if (!isxdigit(p[i])) { - err++; - printk("ERROR: mac: p[%i] != hex digit, found: `%c'\n", - i, p[i]); - break; - } - } - if (err != 0) { - printk("ERROR: Bad MAC address format: %s\n", string); - return -1; - } - /* Convert string to binary */ - for (i = 0, p = (char *)string; i < 6; i++) { - buf[i] = p ? strtoul(p, &end, 16) : 0; - if (p) { - p = (*end) ? end + 1 : end; - } - } - if (!is_valid_ether_addr((char *)buf)) { - printk("ERROR: MAC address must not be 00:00:00:00:00:00, " - "a multicast address or FF:FF:FF:FF:FF:FF.\n"); - printk("ERROR: Bad MAC address format: %s\n", string); - return -1; - } - return 0; -} - -/* - * is_valid_tlvinfo_header - * - * Perform sanity checks on the first 11 bytes of the TlvInfo EEPROM - * data pointed to by the parameter: - * 1. First 8 bytes contain null-terminated ASCII string "TlvInfo" - * 2. Version byte is 1 - * 3. Total length bytes contain value which is less than or equal - * to the allowed maximum (2048-11) - * - */ -static inline bool is_valid_tlvinfo_header(tlvinfo_header_t *hdr) -{ - int max_size = TLV_TOTAL_LEN_MAX; - return((strcmp(hdr->signature, TLV_INFO_ID_STRING) == 0) && - (hdr->version == TLV_INFO_VERSION) && - (be16_to_cpu(hdr->totallen) <= max_size) ); -} - -/* - * decode_tlv_value - * - * Decode a single TLV value into a string. - - * The validity of EEPROM contents and the TLV field have been verified - * prior to calling this function. - */ -#define DECODE_NAME_MAX 20 - -static void decode_tlv_value(tlvinfo_tlv_t * tlv, char* value) -{ - int i; - - switch (tlv->type) { - case TLV_CODE_PRODUCT_NAME: - case TLV_CODE_PART_NUMBER: - case TLV_CODE_SERIAL_NUMBER: - case TLV_CODE_MANUF_DATE: - case TLV_CODE_LABEL_REVISION: - case TLV_CODE_PLATFORM_NAME: - case TLV_CODE_ONIE_VERSION: - case TLV_CODE_MANUF_NAME: - case TLV_CODE_MANUF_COUNTRY: - case TLV_CODE_VENDOR_NAME: - case TLV_CODE_DIAG_VERSION: - case TLV_CODE_SERVICE_TAG: - memcpy(value, tlv->value, tlv->length); - value[tlv->length] = 0; - break; - case TLV_CODE_MAC_BASE: - snprintf(value, MAX_STRING_SIZE, "%02X:%02X:%02X:%02X:%02X:%02X", - tlv->value[0], tlv->value[1], tlv->value[2], - tlv->value[3], tlv->value[4], tlv->value[5]); - break; - case TLV_CODE_DEVICE_VERSION: - snprintf(value, MAX_STRING_SIZE, "%u", tlv->value[0]); - break; - case TLV_CODE_MAC_SIZE: - snprintf(value, MAX_STRING_SIZE, "%u", (tlv->value[0] << 8) | tlv->value[1]); - break; - case TLV_CODE_VENDOR_EXT: - value[0] = 0; - for (i = 0; (i < (TLV_DECODE_VALUE_MAX_LEN/5)) && (i < tlv->length); - i++) { - snprintf(value, MAX_STRING_SIZE, "%s 0x%02X", value, tlv->value[i]); - } - break; - case TLV_CODE_CRC_32: - snprintf(value, MAX_STRING_SIZE, "0x%02X%02X%02X%02X", - tlv->value[0], tlv->value[1], tlv->value[2], - tlv->value[3]); - break; - default: - value[0] = 0; - for (i = 0; (i < (TLV_DECODE_VALUE_MAX_LEN/5)) && (i < tlv->length); - i++) { - snprintf(value, MAX_STRING_SIZE, "%s 0x%02X", value, tlv->value[i]); - } - break; - } - -} - -/* - * is_checksum_valid - * - * Validate the checksum in the provided TlvInfo EEPROM data. First, - * verify that the TlvInfo header is valid, then make sure the last - * TLV is a CRC-32 TLV. Then calculate the CRC over the EEPROM data - * and compare it to the value stored in the EEPROM CRC-32 TLV. - */ -static bool is_checksum_valid(u_int8_t *eeprom) -{ - tlvinfo_header_t * eeprom_hdr = (tlvinfo_header_t *) eeprom; - tlvinfo_tlv_t * eeprom_crc; - unsigned int calc_crc; - unsigned int stored_crc; - - // Is the eeprom header valid? - if (!is_valid_tlvinfo_header(eeprom_hdr)) { - return(FALSE); - } - - // Is the last TLV a CRC? - eeprom_crc = (tlvinfo_tlv_t *) &eeprom[sizeof(tlvinfo_header_t) + - be16_to_cpu(eeprom_hdr->totallen) - - (sizeof(tlvinfo_tlv_t) + 4)]; - if ((eeprom_crc->type != TLV_CODE_CRC_32) || (eeprom_crc->length != 4)) { - return(FALSE); - } - - // Calculate the checksum - calc_crc = crc32((void *)eeprom, sizeof(tlvinfo_header_t) + - be16_to_cpu(eeprom_hdr->totallen) - 4); - stored_crc = ((eeprom_crc->value[0] << 24) | (eeprom_crc->value[1] << 16) | - (eeprom_crc->value[2] << 8) | eeprom_crc->value[3]); - - //printk(KERN_ERR "[SWPS] cal_crc =0x%x, stored_crc =0x%x\n", calc_crc, stored_crc); - //return(calc_crc == stored_crc); - return 1; -} - -/* - * update_crc - * - * This function updates the CRC-32 TLV. If there is no CRC-32 TLV, then - * one is added. This function should be called after each update to the - * EEPROM structure, to make sure the CRC is always correct. - */ -static void update_crc(u_int8_t *eeprom) -{ - tlvinfo_header_t * eeprom_hdr = (tlvinfo_header_t *) eeprom; - tlvinfo_tlv_t * eeprom_crc; - unsigned int calc_crc; - - // Is the eeprom header valid? - if (!is_valid_tlvinfo_header(eeprom_hdr)) { - return; - } - // Is the last TLV a CRC? - eeprom_crc = (tlvinfo_tlv_t *) &eeprom[sizeof(tlvinfo_header_t) + - be16_to_cpu(eeprom_hdr->totallen) - - (sizeof(tlvinfo_tlv_t) + 4)]; - if (eeprom_crc->type != TLV_CODE_CRC_32) { - if ((be16_to_cpu(eeprom_hdr->totallen) + sizeof(tlvinfo_tlv_t) + 4) > - TLV_TOTAL_LEN_MAX) { - return; - } - eeprom_crc = (tlvinfo_tlv_t *) &eeprom[sizeof(tlvinfo_header_t) + - be16_to_cpu( - eeprom_hdr->totallen)]; - eeprom_hdr->totallen = cpu_to_be16(be16_to_cpu(eeprom_hdr->totallen) + - sizeof(tlvinfo_tlv_t) + 4); - eeprom_crc->type = TLV_CODE_CRC_32; - } - eeprom_crc->length = 4; - - // Calculate the checksum - calc_crc = crc32((void *)eeprom, - sizeof(tlvinfo_header_t) + - be16_to_cpu(eeprom_hdr->totallen) - 4); - - eeprom_crc->value[0] = (calc_crc >> 24) & 0xFF; - eeprom_crc->value[1] = (calc_crc >> 16) & 0xFF; - eeprom_crc->value[2] = (calc_crc >> 8) & 0xFF; - eeprom_crc->value[3] = (calc_crc >> 0) & 0xFF; -} - -/* - * show_eeprom - * - * Display the contents of the EEPROM - */ - -/* - * read_eeprom - * - * Read the EEPROM into memory, if it hasn't already been read. - */ -int read_eeprom( struct i2c_client *pi2c_client, u_int8_t *eeprom) -{ - int ret; - tlvinfo_header_t *eeprom_hdr = (tlvinfo_header_t *) eeprom; - tlvinfo_tlv_t *eeprom_tlv = (tlvinfo_tlv_t *)&eeprom[ - sizeof(tlvinfo_header_t)]; - - if (has_been_read) - return 0; - - /* Read the header */ - ret = read_sys_eeprom( pi2c_client,(void *)eeprom_hdr, 0, sizeof(tlvinfo_header_t)); - /* If the header was successfully read, read the TLVs */ - if ((ret == 0) && is_valid_tlvinfo_header(eeprom_hdr)) { - ret = read_sys_eeprom( pi2c_client, (void *)eeprom_tlv, sizeof(tlvinfo_header_t), - be16_to_cpu(eeprom_hdr->totallen)); - } - // If the contents are invalid, start over with default contents - if(!is_valid_tlvinfo_header(eeprom_hdr)) - printk(KERN_ERR - "Notice: Invalid TLV header found. Using default contents--1.\n"); - if(!is_checksum_valid(eeprom)) - printk(KERN_ERR - "Notice: Invalid TLV checksum found. Using default contents--2.\n"); - if ( !is_valid_tlvinfo_header(eeprom_hdr) || !is_checksum_valid(eeprom) ){ - strcpy(eeprom_hdr->signature, TLV_INFO_ID_STRING); - eeprom_hdr->version = TLV_INFO_VERSION; - eeprom_hdr->totallen = cpu_to_be16(0); - update_crc(eeprom); - } - has_been_read = 1; - - return ret; -} -EXPORT_SYMBOL(read_eeprom); - -/* - * prog_eeprom - * Write the EEPROM data from CPU memory to the hardware. - */ -int prog_eeprom(struct i2c_client *pi2c_client, u_int8_t * eeprom) -{ - int ret = 0; - tlvinfo_header_t * eeprom_hdr = (tlvinfo_header_t *) eeprom; - int eeprom_len; - - eeprom_len = sizeof(tlvinfo_header_t) + be16_to_cpu(eeprom_hdr->totallen); - ret = write_sys_eeprom( pi2c_client, eeprom, eeprom_len); - if (ret) { - printk("Programming failed.\n"); - return -1; - } - has_been_read = 0; - return 0; -} -EXPORT_SYMBOL(prog_eeprom); - -/* - * tlvinfo_find_tlv - * - * This function finds the TLV with the supplied code in the EERPOM. - * An offset from the beginning of the EEPROM is returned in the - * eeprom_index parameter if the TLV is found. - */ -bool tlvinfo_find_tlv(u_int8_t *eeprom, u_int8_t tcode, - int *eeprom_index) -{ - tlvinfo_header_t * eeprom_hdr = (tlvinfo_header_t *) eeprom; - tlvinfo_tlv_t * eeprom_tlv; - int eeprom_end; - - // Make sure the EEPROM contents are valid - if (!is_valid_tlvinfo_header(eeprom_hdr) || !is_checksum_valid(eeprom)) { - return(FALSE); - } - // Search through the TLVs, looking for the first one which matches the - // supplied type code. - *eeprom_index = sizeof(tlvinfo_header_t); - eeprom_end = sizeof(tlvinfo_header_t) + be16_to_cpu(eeprom_hdr->totallen); - - while (*eeprom_index < eeprom_end) { - eeprom_tlv = (tlvinfo_tlv_t *) &eeprom[*eeprom_index]; - if (!is_valid_tlv(eeprom_tlv)) { - return(FALSE); - } - if (eeprom_tlv->type == tcode) { - return(TRUE); - } - *eeprom_index += sizeof(tlvinfo_tlv_t) + eeprom_tlv->length; - } - return(FALSE); -} - -/* - * tlvinfo_decode_tlv - * - * This function finds the TLV with the supplied code in the EERPOM - * and decodes the value into the buffer provided. - */ -bool tlvinfo_decode_tlv(u_int8_t *eeprom, u_int8_t tcode, char* value) -{ - int eeprom_index; - tlvinfo_tlv_t * eeprom_tlv; - - // Find the TLV and then decode it - - if (tlvinfo_find_tlv(eeprom, tcode, &eeprom_index)) { - eeprom_tlv = (tlvinfo_tlv_t *) &eeprom[eeprom_index]; - decode_tlv_value(eeprom_tlv, value); - return TRUE; - } - - return FALSE; -} -EXPORT_SYMBOL(tlvinfo_decode_tlv); - -/* - * tlvinfo_delete_tlv - * - * This function deletes the TLV with the specified type code from the - * EEPROM. - */ -bool tlvinfo_delete_tlv(u_int8_t * eeprom, u_int8_t code) -{ - int eeprom_index; - int tlength; - tlvinfo_header_t * eeprom_hdr = (tlvinfo_header_t *) eeprom; - tlvinfo_tlv_t * eeprom_tlv; - - // Find the TLV and then move all following TLVs "forward" - if (tlvinfo_find_tlv(eeprom, code, &eeprom_index)) { - eeprom_tlv = (tlvinfo_tlv_t *) &eeprom[eeprom_index]; - tlength = sizeof(tlvinfo_tlv_t) + eeprom_tlv->length; - memcpy(&eeprom[eeprom_index], &eeprom[eeprom_index+tlength], - sizeof(tlvinfo_header_t) + be16_to_cpu(eeprom_hdr->totallen) - - eeprom_index - tlength); - eeprom_hdr->totallen = cpu_to_be16(be16_to_cpu(eeprom_hdr->totallen) - - tlength); - update_crc(eeprom); - return(TRUE); - } - return(FALSE); -} -EXPORT_SYMBOL(tlvinfo_delete_tlv); - -/* - * tlvinfo_add_tlv - * - * This function adds a TLV to the EEPROM, converting the value (a string) to - * the format in which it will be stored in the EEPROM. - */ -#define MAX_TLV_VALUE_LEN 256 -bool tlvinfo_add_tlv(u_int8_t * eeprom, int tcode, char * strval) -{ - tlvinfo_header_t * eeprom_hdr = (tlvinfo_header_t *) eeprom; - tlvinfo_tlv_t * eeprom_tlv; - int new_tlv_len = 0; - u_int32_t value; - char data[MAX_TLV_VALUE_LEN]; - int eeprom_index; - int max_size = TLV_TOTAL_LEN_MAX; - - // Encode each TLV type into the format to be stored in the EERPOM - switch (tcode) { - case TLV_CODE_PRODUCT_NAME: - case TLV_CODE_PART_NUMBER: - case TLV_CODE_SERIAL_NUMBER: - case TLV_CODE_LABEL_REVISION: - case TLV_CODE_PLATFORM_NAME: - case TLV_CODE_ONIE_VERSION: - case TLV_CODE_MANUF_NAME: - case TLV_CODE_MANUF_COUNTRY: - case TLV_CODE_VENDOR_NAME: - case TLV_CODE_DIAG_VERSION: - case TLV_CODE_SERVICE_TAG: - strncpy(data, strval, MAX_TLV_VALUE_LEN); - - if( strlen(strval) >= MAX_TLV_VALUE_LEN ) - new_tlv_len = MAX_TLV_VALUE_LEN; - else - new_tlv_len = strlen(strval); - - break; - case TLV_CODE_DEVICE_VERSION: - value = strtoul(strval, NULL, 0); - if (value >= 256) { - printk("ERROR: Device version must be 255 or less. Value " \ - "supplied: %u", value); - return(FALSE); - } - data[0] = value & 0xFF; - new_tlv_len = 1; - break; - case TLV_CODE_MAC_SIZE: - value = strtoul(strval, NULL, 0); - if (value >= 65536) { - printk("ERROR: MAC Size must be 65535 or less. Value " \ - "supplied: %u", value); - return(FALSE); - } - data[0] = (value >> 8) & 0xFF; - data[1] = value & 0xFF; - new_tlv_len = 2; - break; - case TLV_CODE_MANUF_DATE: - if (set_date(data, strval) != 0) { - return(FALSE); - } - new_tlv_len = 19; - break; - case TLV_CODE_MAC_BASE: - if (set_mac(data, strval) != 0) { - return(FALSE); - } - new_tlv_len = 6; - break; - case TLV_CODE_CRC_32: - printk("WARNING: The CRC TLV is set automatically and cannot be set " \ - "manually.\n"); - return(FALSE); - case TLV_CODE_VENDOR_EXT: - default: - if (set_bytes(data, strval, &new_tlv_len) != 0 ) { - return(FALSE); - } - break; - } - - // Is there room for this TLV? - if ((be16_to_cpu(eeprom_hdr->totallen) + sizeof(tlvinfo_tlv_t) + - new_tlv_len) > max_size) { - printk("ERROR: There is not enough room in the EERPOM to save data.\n"); - return(FALSE); - } - - // Add TLV at the end, overwriting CRC TLV if it exists - if (tlvinfo_find_tlv(eeprom, TLV_CODE_CRC_32, &eeprom_index)) { - eeprom_hdr->totallen = cpu_to_be16(be16_to_cpu(eeprom_hdr->totallen) - - sizeof(tlvinfo_tlv_t) - 4); - } else { - eeprom_index = sizeof(tlvinfo_header_t) + - be16_to_cpu(eeprom_hdr->totallen); - } - eeprom_tlv = (tlvinfo_tlv_t *) &eeprom[eeprom_index]; - eeprom_tlv->type = tcode; - eeprom_tlv->length = new_tlv_len; - memcpy(eeprom_tlv->value, data, new_tlv_len); - - // Update the total length and calculate (add) a new CRC-32 TLV - eeprom_hdr->totallen = cpu_to_be16(be16_to_cpu(eeprom_hdr->totallen) + - sizeof(tlvinfo_tlv_t) + new_tlv_len); - update_crc(eeprom); - - return(TRUE); -} -EXPORT_SYMBOL(tlvinfo_add_tlv); - -/* - * read_sys_eeprom - read the hwinfo from i2c EEPROM - */ -int read_sys_eeprom(struct i2c_client *pi2c_client,void *eeprom_data, int offset, int len) -{ - int iRet = 0; - int i = 0; - unsigned char ucBuf[2]; - u_int8_t *c; - unsigned short usAddr = SYS_EEPROM_OFFSET + offset; - - c = eeprom_data; - for (i = 0; i < len; i++) { - ucBuf[0] = (usAddr & 0xFF00) >> 8; - ucBuf[1] = (usAddr & 0x00FF); - - iRet = i2c_smbus_write_byte_data(pi2c_client, ucBuf[0], ucBuf[1]); - if( iRet < 0 ){ - printk(KERN_ERR"Error!! VPD data read error\n"); - return -1; - } - - *c = i2c_smbus_read_byte(pi2c_client); - c++; usAddr++; - } - return 0; -} - -/* - * write_sys_eeprom - write the hwinfo to i2c EEPROM - */ -int write_sys_eeprom(struct i2c_client *pi2c_client, void *eeprom_data, int len) -{ - int iRet = 0; - int i = 0; - u_int8_t *c; - unsigned short usAddr = SYS_EEPROM_OFFSET; - unsigned char ucBuf[3]; - - c = eeprom_data; - for (i = 0; i < len; i++) { - ucBuf[ 0 ] = (usAddr & 0xFF00) >>8 ; - ucBuf[ 1 ] = (usAddr & 0x00FF); - ucBuf[ 2 ] = *c; - - iRet = i2c_smbus_write_word_data( pi2c_client, ucBuf[0], (ucBuf[2] << 8 | ucBuf[1])); - if (iRet < 0 ){ - printk(KERN_ERR"Error!! VPD data write error . \n"); - return -1; - } - - c++; usAddr++; - msleep_interruptible(10); - } - - return 0; -} - -void update_eeprom_header(u_int8_t *eeprom) -{ - tlvinfo_header_t * eeprom_hdr = (tlvinfo_header_t *) eeprom; - - strcpy(eeprom_hdr->signature, TLV_INFO_ID_STRING); - eeprom_hdr->version = TLV_INFO_VERSION; - eeprom_hdr->totallen = cpu_to_be16(0); - update_crc(eeprom); -} -#if 0 -int find_vpd_data(u_int8_t *eeprom, int i_offset, char *c_buf) -{ - int tlv_end; - int curr_tlv; - tlvinfo_header_t * eeprom_hdr = (tlvinfo_header_t *) eeprom; - tlvinfo_tlv_t * eeprom_tlv; - int iFind = 0; - - if( !is_valid_tlvinfo_header(eeprom_hdr) ) { - printk(KERN_ERR"EEPROM does not contain data in a valid TlvInfo format.\n"); - return -1; - } - - curr_tlv = sizeof(tlvinfo_header_t); - tlv_end = sizeof(tlvinfo_header_t) + be16_to_cpu(eeprom_hdr->totallen); - while(curr_tlv < tlv_end){ - eeprom_tlv = (tlvinfo_tlv_t *) &eeprom[curr_tlv]; - if (!is_valid_tlv(eeprom_tlv)) { - printk(KERN_ERR"Invalid TLV field starting at EEPROM offset %d\n", - curr_tlv); - return -1; - } - - decode_tlv_value(eeprom_tlv, c_buf); - if( eeprom_tlv->type == i_offset){ - iFind = 1; - break; - } - curr_tlv += sizeof(tlvinfo_tlv_t) + eeprom_tlv->length; - } - - if( iFind == 0 ) - return -1; - else - return 0; -} -#endif diff --git a/packages/platforms/inventec/x86-64/d7054q28b/modules/builds/src/onie_tlvinfo.h b/packages/platforms/inventec/x86-64/d7054q28b/modules/builds/src/onie_tlvinfo.h deleted file mode 100644 index 74f3c9604..000000000 --- a/packages/platforms/inventec/x86-64/d7054q28b/modules/builds/src/onie_tlvinfo.h +++ /dev/null @@ -1,150 +0,0 @@ -/* - * The Definition of the TlvInfo EEPROM format can be found at onie.org or - * github.com/onie - */ -#include -#define strtoul simple_strtoul - -#define FALSE 0 -#define TRUE (!FALSE) -#define MAX_STRING_SIZE 128 -/* - * Tlvinf header: Layout of the header for the TlvInfo format - * - * See the end of this file for details of this eeprom format - */ -struct __attribute__ ((__packed__)) tlvinfo_header_s { - char signature[8]; /* 0x00 - 0x07 EEPROM Tag "TlvInfo" */ - u_int8_t version; /* 0x08 Structure version */ - u_int16_t totallen; /* 0x09 - 0x0A Length of all data which follows */ -}; -typedef struct tlvinfo_header_s tlvinfo_header_t; - -// Header Field Constants -#define TLV_INFO_ID_STRING "TlvInfo" -#define TLV_INFO_VERSION 0x01 -#define TLV_TOTAL_LEN_MAX (SYS_EEPROM_SIZE - sizeof(tlvinfo_header_t)) - -/* - * TlvInfo TLV: Layout of a TLV field - */ -struct __attribute__ ((__packed__)) tlvinfo_tlv_s { - u_int8_t type; - u_int8_t length; - u_int8_t value[0]; -}; -typedef struct tlvinfo_tlv_s tlvinfo_tlv_t; - -/* Maximum length of a TLV value in bytes */ -#define TLV_VALUE_MAX_LEN 255 - -/** - * The TLV Types. - * - * Keep these in sync with tlv_code_list in cmd_sys_eeprom.c - */ -#define TLV_CODE_PRODUCT_NAME 0x21 -#define TLV_CODE_PART_NUMBER 0x22 -#define TLV_CODE_SERIAL_NUMBER 0x23 -#define TLV_CODE_MAC_BASE 0x24 -#define TLV_CODE_MANUF_DATE 0x25 -#define TLV_CODE_DEVICE_VERSION 0x26 -#define TLV_CODE_LABEL_REVISION 0x27 -#define TLV_CODE_PLATFORM_NAME 0x28 -#define TLV_CODE_ONIE_VERSION 0x29 -#define TLV_CODE_MAC_SIZE 0x2A -#define TLV_CODE_MANUF_NAME 0x2B -#define TLV_CODE_MANUF_COUNTRY 0x2C -#define TLV_CODE_VENDOR_NAME 0x2D -#define TLV_CODE_DIAG_VERSION 0x2E -#define TLV_CODE_SERVICE_TAG 0x2F -#define TLV_CODE_VENDOR_EXT 0xFD -#define TLV_CODE_CRC_32 0xFE - -/* - * Struct for displaying the TLV codes and names. - */ -struct tlv_code_desc { - u_int8_t m_code; - char* m_name; -}; - -/* - * List of TLV codes and names. - */ -static const struct tlv_code_desc tlv_code_list[] = { - { TLV_CODE_PRODUCT_NAME , "Product Name"}, - { TLV_CODE_PART_NUMBER , "Part Number"}, - { TLV_CODE_SERIAL_NUMBER , "Serial Number"}, - { TLV_CODE_MAC_BASE , "Base MAC Address"}, - { TLV_CODE_MANUF_DATE , "Manufacture Date"}, - { TLV_CODE_DEVICE_VERSION , "Device Version"}, - { TLV_CODE_LABEL_REVISION , "Label Revision"}, - { TLV_CODE_PLATFORM_NAME , "Platform Name"}, - { TLV_CODE_ONIE_VERSION , "Loader Version"}, - { TLV_CODE_MAC_SIZE , "MAC Addresses"}, - { TLV_CODE_MANUF_NAME , "Manufacturer"}, - { TLV_CODE_MANUF_COUNTRY , "Country Code"}, - { TLV_CODE_VENDOR_NAME , "Vendor Name"}, - { TLV_CODE_DIAG_VERSION , "Diag Version"}, - { TLV_CODE_SERVICE_TAG , "Service Tag"}, - { TLV_CODE_VENDOR_EXT , "Vendor Extension"}, - { TLV_CODE_CRC_32 , "CRC-32"}, -}; - -static inline const char* tlv_type2name(u_int8_t type) -{ - char* name = "Unknown"; - int i; - - for (i = 0; i < sizeof(tlv_code_list)/sizeof(tlv_code_list[0]); i++) { - if (tlv_code_list[i].m_code == type) { - name = tlv_code_list[i].m_name; - break; - } - } - return name; -} - -/* - * The max decode value is currently for the 'raw' type or the 'vendor - * extension' type, both of which have the same decode format. The - * max decode string size is computed as follows: - * - * strlen(" 0xFF") * TLV_VALUE_MAX_LEN + 1 - * - */ -#define TLV_DECODE_VALUE_MAX_LEN ((5 * TLV_VALUE_MAX_LEN) + 1) - - -/* - * Each platform must define the following platform-specific macros - * in sys_eeprom_platform.h: - * SYS_EEPROM_SIZE: size of usable eeprom - * SYS_EEPROM_I2C_DEVICE: i2c-bus - * SYS_EEPROM_I2C_ADDR: address on the bus - * The following may also be defined in sys_eeprom_platform.h, else - * the defaults with take over: - * SYS_EEPROM_MAX_SIZE: Total size of the eeprom - * SYS_EEPROM_OFFSET: offset from where the ONIE header starts - */ -#define SYS_EEPROM_MAX_SIZE 2048 -#define SYS_EEPROM_OFFSET 0 -#define SYS_EEPROM_SIZE SYS_EEPROM_MAX_SIZE -#define SYS_EEPROM_I2C_DEVICE "/dev/i2c-0" -#define SYS_EEPROM_I2C_ADDR 0x53 - -#if (SYS_EEPROM_SIZE + SYS_EEPROM_OFFSET > SYS_EEPROM_MAX_SIZE) - #error SYS_EEPROM_SIZE + SYS_EEPROM_OFFSET is greater than SYS_EEPROM_MAX_SIZE -#endif - -// Access functions to onie_tlvinfo -void show_eeprom(u_int8_t *eeprom); -int read_eeprom(struct i2c_client *pi2c_client, u_int8_t *eeprom); -int prog_eeprom(struct i2c_client *pi2c_client,u_int8_t * eeprom); -void update_eeprom_header(u_int8_t *eeprom); -bool tlvinfo_find_tlv(u_int8_t *eeprom, u_int8_t tcode, int *eeprom_index); -bool tlvinfo_delete_tlv(u_int8_t * eeprom, u_int8_t code); -bool tlvinfo_add_tlv(u_int8_t * eeprom, int tcode, char * strval); -bool tlvinfo_decode_tlv(u_int8_t *eeprom, u_int8_t tcode, char* value); -//int find_vpd_data(u_int8_t *eeprom, int i_offset, char *c_buf); diff --git a/packages/platforms/inventec/x86-64/d7054q28b/modules/builds/src/transceiver.c b/packages/platforms/inventec/x86-64/d7054q28b/modules/builds/src/transceiver.c deleted file mode 100644 index 2b5b5b425..000000000 --- a/packages/platforms/inventec/x86-64/d7054q28b/modules/builds/src/transceiver.c +++ /dev/null @@ -1,8279 +0,0 @@ -/************************************************************************* - * - * transceiver.c - * - * 2018 Inventec Corporation - * All Rights Reserved. - * - * NOTICE: All information contained herein is, and remains - * the property of Inventec Corp. and its suppliers, - * if any. The intellectual and technical concepts contained - * herein are proprietary to Inventec Corporation and its suppliers - * and may be covered by U.S. and Foreign Patents, patents in process, - * and are protected by trade secret or copyright law. - * - ************************************************************************/ - -#include -#include -#include -#include -#include -#include -#include "io_expander.h" -#include "transceiver.h" - - -/* ========== Register EEPROM address mapping ========== - */ -struct eeprom_map_s eeprom_map_sfp = { - .addr_br =0x50, .page_br =-1, .offset_br =12, .length_br =1, - .addr_cdr =-1, .page_cdr =-1, .offset_cdr =-1, .length_cdr =-1, - .addr_comp_rev =0x50, .page_comp_rev =-1, .offset_comp_rev =94, .length_comp_rev =1, - .addr_connector =0x50, .page_connector =-1, .offset_connector =2, .length_connector =1, - .addr_diag_type =0x50, .page_diag_type =-1, .offset_diag_type =92 , .length_diag_type =1, - .addr_extbr =-1, .page_extbr =-1, .offset_extbr =-1, .length_extbr =-1, - .addr_ext_id =0x50, .page_ext_id =-1, .offset_ext_id =1, .length_ext_id =1, - .addr_id =0x50, .page_id =-1, .offset_id =0, .length_id =1, - .addr_len_sm =0x50, .page_len_sm =-1, .offset_len_sm =15, .length_len_sm =1, - .addr_len_smf =0x50, .page_len_smf =-1, .offset_len_smf =14, .length_len_smf =1, - .addr_len_om1 =0x50, .page_len_om1 =-1, .offset_len_om1 =17, .length_len_om1 =1, - .addr_len_om2 =0x50, .page_len_om2 =-1, .offset_len_om2 =16, .length_len_om2 =1, - .addr_len_om3 =0x50, .page_len_om3 =-1, .offset_len_om3 =19, .length_len_om3 =1, - .addr_len_om4 =0x50, .page_len_om4 =-1, .offset_len_om4 =18, .length_len_om4 =1, - .addr_option =0x50, .page_option =-1, .offset_option =64, .length_option =2, - .addr_rate_id =0x50, .page_rate_id =-1, .offset_rate_id =13, .length_rate_id =1, - .addr_rx_am =-1, .page_rx_am =-1, .offset_rx_am =-1, .length_rx_am =-1, - .addr_rx_em =0x51, .page_rx_em =-1, .offset_rx_em =115, .length_rx_em =1, - .addr_rx_los =-1, .page_rx_los =-1, .offset_rx_los =-1, .length_rx_los =-1, - .addr_rx_power =0x51, .page_rx_power =-1, .offset_rx_power =104, .length_rx_power =2, - .addr_soft_rs0 =0x51, .page_soft_rs0 =-1, .offset_soft_rs0 =110, .length_soft_rs0 =1, - .addr_soft_rs1 =0x51, .page_soft_rs1 =-1, .offset_soft_rs1 =118, .length_soft_rs0 =1, - .addr_temp =0x51, .page_temp =-1, .offset_temp =96, .length_temp =2, - .addr_trancomp =0x50, .page_trancomp =-1, .offset_trancomp =3, .length_trancomp =8, - .addr_trancomp_ext =0x50, .page_trancomp_ext =-1, .offset_trancomp_ext =36, .length_trancomp_ext =1, - .addr_tx_bias =0x51, .page_tx_bias =-1, .offset_tx_bias =100, .length_tx_bias =2, - .addr_tx_disable =-1, .page_tx_disable =-1, .offset_tx_disable =-1, .length_tx_disable =-1, - .addr_tx_eq =0x51, .page_tx_eq =-1, .offset_tx_eq =114, .length_tx_eq =1, - .addr_tx_fault =-1, .page_tx_fault =-1, .offset_tx_fault =-1, .length_tx_fault =-1, - .addr_tx_power =0x51, .page_tx_power =-1, .offset_tx_power =102, .length_tx_power =2, - .addr_vendor_name =0x50, .page_vendor_name =-1, .offset_vendor_name =20, .length_vendor_name =16, - .addr_vendor_pn =0x50, .page_vendor_pn =-1, .offset_vendor_pn =40, .length_vendor_pn =16, - .addr_vendor_rev =0x50, .page_vendor_rev =-1, .offset_vendor_rev =56, .length_vendor_rev =4, - .addr_vendor_sn =0x50, .page_vendor_sn =-1, .offset_vendor_sn =68, .length_vendor_sn =16, - .addr_voltage =0x51, .page_voltage =-1, .offset_voltage =98, .length_voltage =2, - .addr_wavelength =0x50, .page_wavelength =-1, .offset_wavelength =60, .length_wavelength =2, - .addr_eeprom =0x50, .page_eeprom =-1, .offset_eeprom =0, .length_eeprom =256, -}; - -struct eeprom_map_s eeprom_map_qsfp = { - .addr_br =0x50, .page_br =0, .offset_br =140, .length_br =1, - .addr_cdr =-1, .page_cdr =-1, .offset_cdr =-1, .length_cdr =-1, - .addr_comp_rev =0x50, .page_comp_rev =-1, .offset_comp_rev =1, .length_comp_rev =1, - .addr_connector =0x50, .page_connector =0, .offset_connector =130, .length_connector =1, - .addr_diag_type =0x50, .page_diag_type =0, .offset_diag_type =220, .length_diag_type =1, - .addr_extbr =0x50, .page_extbr =0, .offset_extbr =222, .length_extbr =1, - .addr_ext_id =0x50, .page_ext_id =0, .offset_ext_id =129, .length_ext_id =1, - .addr_id =0x50, .page_id =0, .offset_id =128, .length_id =1, - .addr_len_sm =-1, .page_len_sm =-1, .offset_len_sm =-1, .length_len_sm =-1, - .addr_len_smf =0x50, .page_len_smf =0, .offset_len_smf =142, .length_len_smf =1, - .addr_len_om1 =0x50, .page_len_om1 =0, .offset_len_om1 =145, .length_len_om1 =1, - .addr_len_om2 =0x50, .page_len_om2 =0, .offset_len_om2 =144, .length_len_om2 =1, - .addr_len_om3 =0x50, .page_len_om3 =0, .offset_len_om3 =143, .length_len_om3 =1, - .addr_len_om4 =0x50, .page_len_om4 =0, .offset_len_om4 =146, .length_len_om4 =1, - .addr_option =0x50, .page_option =0, .offset_option =193, .length_option =3, - .addr_rate_id =-1, .page_rate_id =-1, .offset_rate_id =-1, .length_rate_id =-1, - .addr_rx_am =-1, .page_rx_am =-1, .offset_rx_am =-1, .length_rx_am =-1, - .addr_rx_em =-1, .page_rx_em =-1, .offset_rx_em =-1, .length_rx_em =-1, - .addr_rx_los =0x50, .page_rx_los =-1, .offset_rx_los =3, .length_rx_los =1, - .addr_rx_power =0x50, .page_rx_power =-1, .offset_rx_power =34, .length_rx_power =8, - .addr_soft_rs0 =-1, .page_soft_rs0 =-1, .offset_soft_rs0 =-1, .length_soft_rs0 =-1, - .addr_soft_rs1 =-1, .page_soft_rs1 =-1, .offset_soft_rs1 =-1, .length_soft_rs0 =-1, - .addr_temp =0x50, .page_temp =-1, .offset_temp =22, .length_temp =2, - .addr_trancomp =0x50, .page_trancomp =0, .offset_trancomp =131, .length_trancomp =8, - .addr_trancomp_ext =0x50, .page_trancomp_ext =0, .offset_trancomp_ext =192, .length_trancomp_ext =1, - .addr_tx_bias =0x50, .page_tx_bias =-1, .offset_tx_bias =42, .length_tx_bias =8, - .addr_tx_disable =0x50, .page_tx_disable =-1, .offset_tx_disable =86, .length_tx_disable =1, - .addr_tx_eq =-1, .page_tx_eq =-1, .offset_tx_eq =-1, .length_tx_eq =-1, - .addr_tx_fault =0x50, .page_tx_fault =-1, .offset_tx_fault =4, .length_tx_fault =1, - .addr_tx_power =0x50, .page_tx_power =-1, .offset_tx_power =50, .length_tx_power =8, - .addr_vendor_name =0x50, .page_vendor_name =0, .offset_vendor_name =148, .length_vendor_name =16, - .addr_vendor_pn =0x50, .page_vendor_pn =0, .offset_vendor_pn =168, .length_vendor_pn =16, - .addr_vendor_rev =0x50, .page_vendor_rev =0, .offset_vendor_rev =184, .length_vendor_rev =2, - .addr_vendor_sn =0x50, .page_vendor_sn =0, .offset_vendor_sn =196, .length_vendor_sn =16, - .addr_voltage =0x50, .page_voltage =-1, .offset_voltage =26, .length_voltage =2, - .addr_wavelength =0x50, .page_wavelength =0, .offset_wavelength =186, .length_wavelength =2, - .addr_eeprom =0x50, .page_eeprom =0, .offset_eeprom =0, .length_eeprom =256, -}; - -struct eeprom_map_s eeprom_map_qsfp28 = { - .addr_br =0x50, .page_br =0, .offset_br =140, .length_br =1, - .addr_cdr =0x50, .page_cdr =-1, .offset_cdr =98, .length_cdr =1, - .addr_comp_rev =0x50, .page_comp_rev =-1, .offset_comp_rev =1, .length_comp_rev =1, - .addr_connector =0x50, .page_connector =0, .offset_connector =130, .length_connector =1, - .addr_diag_type =0x50, .page_diag_type =0, .offset_diag_type =220, .length_diag_type =1, - .addr_extbr =0x50, .page_extbr =0, .offset_extbr =222, .length_extbr =1, - .addr_ext_id =0x50, .page_ext_id =0, .offset_ext_id =129, .length_ext_id =1, - .addr_id =0x50, .page_id =0, .offset_id =128, .length_id =1, - .addr_len_sm =-1, .page_len_sm =-1, .offset_len_sm =-1, .length_len_sm =-1, - .addr_len_smf =0x50, .page_len_smf =0, .offset_len_smf =142, .length_len_smf =1, - .addr_len_om1 =0x50, .page_len_om1 =0, .offset_len_om1 =145, .length_len_om1 =1, - .addr_len_om2 =0x50, .page_len_om2 =0, .offset_len_om2 =144, .length_len_om2 =1, - .addr_len_om3 =0x50, .page_len_om3 =0, .offset_len_om3 =143, .length_len_om3 =1, - .addr_len_om4 =0x50, .page_len_om4 =0, .offset_len_om4 =146, .length_len_om4 =1, - .addr_option =0x50, .page_option =0, .offset_option =193, .length_option =3, - .addr_rate_id =-1, .page_rate_id =-1, .offset_rate_id =-1, .length_rate_id =-1, - .addr_rx_am =0x50, .page_rx_am =3, .offset_rx_am =238, .length_rx_am =2, - .addr_rx_em =0x50, .page_rx_em =3, .offset_rx_em =236, .length_rx_em =2, - .addr_rx_los =0x50, .page_rx_los =-1, .offset_rx_los =3, .length_rx_los =1, - .addr_rx_power =0x50, .page_rx_power =-1, .offset_rx_power =34, .length_rx_power =8, - .addr_soft_rs0 =-1, .page_soft_rs0 =-1, .offset_soft_rs0 =-1, .length_soft_rs0 =-1, - .addr_soft_rs1 =-1, .page_soft_rs1 =-1, .offset_soft_rs1 =-1, .length_soft_rs0 =-1, - .addr_temp =0x50, .page_temp =-1, .offset_temp =22, .length_temp =2, - .addr_trancomp =0x50, .page_trancomp =0, .offset_trancomp =131, .length_trancomp =8, - .addr_trancomp_ext =0x50, .page_trancomp_ext =0, .offset_trancomp_ext =192, .length_trancomp_ext =1, - .addr_tx_bias =0x50, .page_tx_bias =-1, .offset_tx_bias =42, .length_tx_bias =8, - .addr_tx_disable =0x50, .page_tx_disable =-1, .offset_tx_disable =86, .length_tx_disable =1, - .addr_tx_eq =0x50, .page_tx_eq =3, .offset_tx_eq =234, .length_tx_eq =2, - .addr_tx_fault =0x50, .page_tx_fault =-1, .offset_tx_fault =4, .length_tx_fault =1, - .addr_tx_power =0x50, .page_tx_power =-1, .offset_tx_power =50, .length_tx_power =8, - .addr_vendor_name =0x50, .page_vendor_name =0, .offset_vendor_name =148, .length_vendor_name =16, - .addr_vendor_pn =0x50, .page_vendor_pn =0, .offset_vendor_pn =168, .length_vendor_pn =16, - .addr_vendor_rev =0x50, .page_vendor_rev =0, .offset_vendor_rev =184, .length_vendor_rev =2, - .addr_vendor_sn =0x50, .page_vendor_sn =0, .offset_vendor_sn =196, .length_vendor_sn =16, - .addr_voltage =0x50, .page_voltage =-1, .offset_voltage =26, .length_voltage =2, - .addr_wavelength =0x50, .page_wavelength =0, .offset_wavelength =186, .length_wavelength =2, - .addr_eeprom =0x50, .page_eeprom =0, .offset_eeprom =0, .length_eeprom =256, -}; - - -/* ========== Utility Functions ========== - */ -static int -get_bit(uint8_t origin_byte, int bit_shift) { - return (int)((origin_byte >> bit_shift) & 0x1); -} - -static int -transform_word_to_int(uint8_t hight_byte, - uint8_t low_byte) { - return ((((int)hight_byte) << 8) + (int)low_byte); -} - -void -alarm_msg_2_user(struct transvr_obj_s *self, - char *emsg) { - - SWPS_ERR("%s on %s.\n", emsg, self->swp_name); -} -EXPORT_SYMBOL(alarm_msg_2_user); - -/* ========== Private functions ========== - */ -static int -_reload_transvr_obj(struct transvr_obj_s *self,int new_type); - -static int -reload_transvr_obj(struct transvr_obj_s *self,int new_type); - -static int -_is_transvr_support_ctle(struct transvr_obj_s *self); - -static int -_transvr_init_handler(struct transvr_obj_s *self); - -int -_transvr_clean_handler(struct transvr_obj_s *self); - -int -_sfp_detect_class_by_1g_ethernet(struct transvr_obj_s* self); - - -void -lock_transvr_obj(struct transvr_obj_s *self) { - - mutex_lock(&self->lock); - self->curr_page = VAL_TRANSVR_PAGE_FREE; -} -EXPORT_SYMBOL(lock_transvr_obj); - -void -unlock_transvr_obj(struct transvr_obj_s *self) { - - self->curr_page = VAL_TRANSVR_PAGE_FREE; - mutex_unlock(&self->lock); -} -EXPORT_SYMBOL(unlock_transvr_obj); - -static int -_check_by_mode(struct transvr_obj_s *self, - int (*attr_update_func)(struct transvr_obj_s *self, int show_err), - char *caller_name){ - - int return_val = ERR_TRANSVR_UNEXCPT; - - switch (self->mode){ - case TRANSVR_MODE_POLLING: - switch (self->state){ - case STATE_TRANSVR_CONNECTED: - goto ok_check_by_mode_1; - case STATE_TRANSVR_NEW: - case STATE_TRANSVR_INIT: - return ERR_TRANSVR_UNINIT; - case STATE_TRANSVR_DISCONNECTED: - return ERR_TRANSVR_UNPLUGGED; - case STATE_TRANSVR_UNEXCEPTED: - return ERR_TRANSVR_ABNORMAL; - case STATE_TRANSVR_ISOLATED: - return ERR_TRNASVR_BE_ISOLATED; - default: - goto err_check_by_mode_1; - } - goto ok_check_by_mode_1; - - case TRANSVR_MODE_DIRECT: - return_val = self->fsm_4_direct(self, caller_name); - if (return_val < 0){ - return return_val; - } - goto ok_check_by_mode_1; - - default: - goto err_check_by_mode_1; - } - goto ok_check_by_mode_1; - -ok_check_by_mode_1: - return attr_update_func(self, 0); - -err_check_by_mode_1: - SWPS_INFO("_check_by_mode: mode:%d state:%d\n", self->mode, self->state); - return ERR_TRANSVR_UNEXCPT; -} - - -static void -_transvr_clean_retry(struct transvr_obj_s *self) { - self->retry = 0; -} - - -static int -_transvr_handle_retry(struct transvr_obj_s *self, int retry) { - /* Return: 0: keep retry - * -1: stop retry - */ - if (self->retry == 0) { - self->retry = retry; - } - self->retry -= 1; - if (self->retry <= 0) { - _transvr_clean_retry(self); - return -1; - } - return 0; -} - - -static int -_common_setup_page(struct transvr_obj_s *self, - int addr, - int page, - int offset, - int len, - int show_e) { - /* return: - * 0 : OK - * -1 : EEPROM settings incorrect - * -2 : I2C R/W failure - * -3 : Undefined case - */ - int retval = DEBUG_TRANSVR_INT_VAL; - char *emsg = DEBUG_TRANSVR_STR_VAL; - - /* Check */ - if ((addr < 0) || (offset < 0) || (len < 0)) { - emsg = "EEPROM settings incorrect"; - retval = -1; - goto err_common_setup_page; - } - /* Case1: continue access */ - if ((self->i2c_client_p->addr == addr) && - (self->curr_page == page)) { - return 0; - } - self->i2c_client_p->addr = addr; - /* Case2: select lower page */ - if (page == -1) { - self->curr_page = page; - return 0; - } - /* Case3: select upper page */ - if (page >= 0) { - goto upper_common_setup_page; - } - /* Unexpected case */ - show_e = 1; - emsg = "Unexpected case"; - retval = -3; - goto err_common_setup_page; - -upper_common_setup_page: - if (i2c_smbus_write_byte_data(self->i2c_client_p, - VAL_TRANSVR_PAGE_SELECT_OFFSET, - page) < 0) { - emsg = "I2C R/W failure"; - retval = -2; - goto err_common_setup_page; - } - self->curr_page = page; - mdelay(VAL_TRANSVR_PAGE_SELECT_DELAY); - return 0; - -err_common_setup_page: - if (show_e) { - SWPS_INFO("%s: %s", __func__, emsg); - SWPS_INFO("%s: :0x%02x :%d :%d :%d\n", - __func__, addr, page, offset, len); - } - return retval; -} - -/* -static int -_common_setup_password(struct transvr_obj_s *self, - int addr, - int page, - int offs, - uint8_t pwd[4], - int show_e) { - int i = 0; - int err = DEBUG_TRANSVR_INT_VAL; - char *emsg = DEBUG_TRANSVR_STR_VAL; - - err = _common_setup_page(self, addr, page, offs, 4, show_e); - if (err < 0){ - emsg = "setup EEPROM page fail"; - goto err_common_setup_password; - } - for (i=0; i<4; i++) { - err = i2c_smbus_write_byte_data(self->i2c_client_p, - (offs + i), - pwd[i]); - if (err < 0){ - emsg = "I2C R/W fail!"; - goto err_common_setup_password; - } - } - return 0; - -err_common_setup_password: - if (show_e) { - SWPS_INFO("%s: %s :%d\n", __func__, emsg, err); - } - return ERR_TRANSVR_UPDATE_FAIL; -} -*/ - -static int -_common_update_uint8_attr(struct transvr_obj_s *self, - int addr, - int page, - int offset, - int len, - uint8_t *buf, - char *caller, - int show_e){ - - int i; - int err = DEBUG_TRANSVR_INT_VAL; - char *emsg = DEBUG_TRANSVR_STR_VAL; - - err = _common_setup_page(self, addr, page, offset, len, show_e); - if (err < 0){ - emsg = "setup EEPROM page fail"; - goto err_common_update_uint8_attr; - } - for (i=0; ii2c_client_p, (offset + i)); - if (err < 0){ - emsg = "I2C R/W fail!"; - goto err_common_update_uint8_attr; - } - buf[i] = err; - } - return 0; - -err_common_update_uint8_attr: - if (show_e) { - SWPS_INFO("%s: %s :%s :%d\n", - __func__, emsg, caller, err); - } - buf[0] = DEBUG_TRANSVR_HEX_VAL; - return ERR_TRANSVR_UPDATE_FAIL; -} - - -static int -_common_update_int_attr(struct transvr_obj_s *self, - int addr, - int page, - int offset, - int len, - int *buf, - char *caller, - int show_e){ - - int i; - int err = DEBUG_TRANSVR_INT_VAL; - char *emsg = DEBUG_TRANSVR_STR_VAL; - - err = _common_setup_page(self, addr, page, offset, len, show_e); - if (err < 0){ - emsg = "setup EEPROM page fail"; - goto err_common_update_int_attr; - } - for (i=0; ii2c_client_p, (offset + i)); - if (err < 0){ - emsg = "I2C R/W fail!"; - goto err_common_update_int_attr; - } - buf[i] = (int)err; - } - return 0; - -err_common_update_int_attr: - if (show_e) { - SWPS_INFO("%s: %s :%s :%d\n", - __func__, emsg, caller, err); - } - buf[0] = DEBUG_TRANSVR_INT_VAL; - return ERR_TRANSVR_UPDATE_FAIL; -} - - -static int -_common_update_string_attr(struct transvr_obj_s *self, - int addr, - int page, - int offset, - int len, - char buf[], - char *caller, - int show_e){ - - int i; - int err = DEBUG_TRANSVR_INT_VAL; - char *emsg = DEBUG_TRANSVR_STR_VAL; - - err = _common_setup_page(self, addr, page, offset, len, show_e); - if (err < 0){ - emsg = "setup EEPROM page fail"; - goto err_common_update_string_attr; - } - for (i=0; ii2c_client_p, (offset + i)); - if (err < 0){ - emsg = "I2C R/W fail!"; - goto err_common_update_string_attr; - } - buf[i] = (char)err; - } - return 0; - -err_common_update_string_attr: - if (show_e) { - SWPS_INFO("%s: %s :%s :%d\n", - __func__, emsg, caller, err); - } - buf[0] = 'e'; - return ERR_TRANSVR_UPDATE_FAIL; -} - - -static int -_common_set_uint8_attr(struct transvr_obj_s *self, - int addr, - int page, - int offset, - uint8_t update, - uint8_t *buf, - char *caller, - int show_e){ - int len = 1; - int err = DEBUG_TRANSVR_INT_VAL; - char *emsg = DEBUG_TRANSVR_STR_VAL; - - if ((*buf) == update){ - return 0; - } - err = _common_setup_page(self, addr, page, offset, len, show_e); - if (err < 0){ - emsg = "setup EEPROM page fail"; - goto err_common_set_uint8_attr_1; - } - err = i2c_smbus_write_byte_data(self->i2c_client_p, - offset, - update); - if (err < 0){ - emsg = "I2C R/W fail!"; - goto err_common_set_uint8_attr_1; - } - (*buf) = update; - return 0; - -err_common_set_uint8_attr_1: - if (show_e) { - SWPS_INFO("%s: %s :%s :%d\n", - __func__, emsg, caller, err); - } - return ERR_TRANSVR_UPDATE_FAIL; -} - - -static int -_common_set_uint8_array(struct transvr_obj_s *self, - int addr, - int page, - int offs, - int len, - uint8_t update[], - uint8_t buf[], - char *caller, - int show_e){ - int i = 0; - int err = DEBUG_TRANSVR_INT_VAL; - char *emsg = DEBUG_TRANSVR_STR_VAL; - - err = _common_setup_page(self, addr, page, offs, len, show_e); - if (err < 0){ - emsg = "setup EEPROM page fail"; - goto err_common_set_uint8_attr_1; - } - for (i=0; ii2c_client_p, - (offs + i), - update[i]); - if (err < 0){ - emsg = "I2C R/W fail!"; - goto err_common_set_uint8_attr_1; - } - buf[i] = update[i]; - } - return 0; - -err_common_set_uint8_attr_1: - if (show_e) { - SWPS_INFO("%s: %s :%s :%d :%d\n", - __func__, emsg, caller, err, i); - } - return ERR_TRANSVR_UPDATE_FAIL; -} - - -static int -_common_update_attr_id(struct transvr_obj_s *self, - int show_err){ - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_id, - self->eeprom_map_p->page_id, - self->eeprom_map_p->offset_id, - self->eeprom_map_p->length_id, - &(self->id), - "_common_update_attr_id", - show_err); -} - - -static int -_common_update_attr_extended_id(struct transvr_obj_s *self, - int show_err){ - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_ext_id, - self->eeprom_map_p->page_ext_id, - self->eeprom_map_p->offset_ext_id, - self->eeprom_map_p->length_ext_id, - &(self->ext_id), - "_common_update_attr_extended_id", - show_err); -} - - -static int -_common_update_attr_connector(struct transvr_obj_s *self, - int show_err){ - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_connector, - self->eeprom_map_p->page_connector, - self->eeprom_map_p->offset_connector, - self->eeprom_map_p->length_connector, - &(self->connector), - "_common_update_attr_connector", - show_err); -} - - -static int -_common_update_attr_transvr_comp(struct transvr_obj_s *self, - int show_err){ - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_trancomp, - self->eeprom_map_p->page_trancomp, - self->eeprom_map_p->offset_trancomp, - self->eeprom_map_p->length_trancomp, - self->transvr_comp, - "_common_update_attr_transvr_comp", - show_err); -} - - -static int -_common_update_attr_transvr_comp_ext(struct transvr_obj_s *self, - int show_err){ - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_trancomp_ext, - self->eeprom_map_p->page_trancomp_ext, - self->eeprom_map_p->offset_trancomp_ext, - self->eeprom_map_p->length_trancomp_ext, - &(self->transvr_comp_ext), - "_common_update_attr_transvr_comp_ext", - show_err); -} - -static int -_common_update_attr_eeprom(struct transvr_obj_s *self, - int show_err){ - return _common_update_string_attr(self, - self->eeprom_map_p->addr_eeprom, - self->eeprom_map_p->page_eeprom, - self->eeprom_map_p->offset_eeprom, - self->eeprom_map_p->length_eeprom, - self->eeprom, - "_common_update_attr_eeprom", - show_err); -} - -static int -_common_update_attr_vendor_name(struct transvr_obj_s *self, - int show_err){ - return _common_update_string_attr(self, - self->eeprom_map_p->addr_vendor_name, - self->eeprom_map_p->page_vendor_name, - self->eeprom_map_p->offset_vendor_name, - self->eeprom_map_p->length_vendor_name, - self->vendor_name, - "_common_update_attr_vendor_name", - show_err); -} - - -static int -_common_update_attr_vendor_pn(struct transvr_obj_s *self, - int show_err){ - return _common_update_string_attr(self, - self->eeprom_map_p->addr_vendor_pn, - self->eeprom_map_p->page_vendor_pn, - self->eeprom_map_p->offset_vendor_pn, - self->eeprom_map_p->length_vendor_pn, - self->vendor_pn, - "_common_update_attr_vendor_pn", - show_err); -} - - -static int -_common_update_attr_vendor_rev(struct transvr_obj_s *self, - int show_err){ - return _common_update_string_attr(self, - self->eeprom_map_p->addr_vendor_rev, - self->eeprom_map_p->page_vendor_rev, - self->eeprom_map_p->offset_vendor_rev, - self->eeprom_map_p->length_vendor_rev, - self->vendor_rev, - "_common_update_attr_vendor_rev", - show_err); -} - - -static int -_common_update_attr_vendor_sn(struct transvr_obj_s *self, - int show_err){ - return _common_update_string_attr(self, - self->eeprom_map_p->addr_vendor_sn, - self->eeprom_map_p->page_vendor_sn, - self->eeprom_map_p->offset_vendor_sn, - self->eeprom_map_p->length_vendor_sn, - self->vendor_sn, - "_common_update_attr_vendor_sn", - show_err); -} - - -static int -_common_update_attr_br(struct transvr_obj_s *self, - int show_err){ - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_br, - self->eeprom_map_p->page_br, - self->eeprom_map_p->offset_br, - self->eeprom_map_p->length_br, - &(self->br), - "_common_update_attr_br", - show_err); -} - - -static int -_common_update_attr_len_smf(struct transvr_obj_s *self, - int show_err){ - return _common_update_int_attr(self, - self->eeprom_map_p->addr_len_smf, - self->eeprom_map_p->page_len_smf, - self->eeprom_map_p->offset_len_smf, - self->eeprom_map_p->length_len_smf, - &(self->len_smf), - "_common_update_attr_len_smf", - show_err); -} - - -static int -_common_update_attr_len_om1(struct transvr_obj_s *self, - int show_err){ - return _common_update_int_attr(self, - self->eeprom_map_p->addr_len_om1, - self->eeprom_map_p->page_len_om1, - self->eeprom_map_p->offset_len_om1, - self->eeprom_map_p->length_len_om1, - &(self->len_om1), - "_common_update_attr_len_om1", - show_err); -} - -static int -_common_update_attr_len_om2(struct transvr_obj_s *self, - int show_err){ - return _common_update_int_attr(self, - self->eeprom_map_p->addr_len_om2, - self->eeprom_map_p->page_len_om2, - self->eeprom_map_p->offset_len_om2, - self->eeprom_map_p->length_len_om2, - &(self->len_om2), - "_common_update_attr_len_om2", - show_err); -} - -static int -_common_update_attr_len_om3(struct transvr_obj_s *self, - int show_err){ - return _common_update_int_attr(self, - self->eeprom_map_p->addr_len_om3, - self->eeprom_map_p->page_len_om3, - self->eeprom_map_p->offset_len_om3, - self->eeprom_map_p->length_len_om3, - &(self->len_om3), - "_common_update_attr_len_om3", - show_err); -} - - -static int -_common_update_attr_len_om4(struct transvr_obj_s *self, - int show_err){ - return _common_update_int_attr(self, - self->eeprom_map_p->addr_len_om4, - self->eeprom_map_p->page_len_om4, - self->eeprom_map_p->offset_len_om4, - self->eeprom_map_p->length_len_om4, - &(self->len_om4), - "_common_update_attr_len_om4", - show_err); -} - - -static int -_common_update_attr_option(struct transvr_obj_s *self, - int show_err){ - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_option, - self->eeprom_map_p->page_option, - self->eeprom_map_p->offset_option, - self->eeprom_map_p->length_option, - self->option, - "_common_update_attr_option", - show_err); -} - - -static int -_common_update_attr_comp_rev(struct transvr_obj_s *self, - int show_err){ - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_comp_rev, - self->eeprom_map_p->page_comp_rev, - self->eeprom_map_p->offset_comp_rev, - self->eeprom_map_p->length_comp_rev, - &(self->comp_rev), - "_common_update_attr_comp_rev", - show_err); -} - - -static int -_common_update_attr_diag_type(struct transvr_obj_s *self, - int show_err){ - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_diag_type, - self->eeprom_map_p->page_diag_type, - self->eeprom_map_p->offset_diag_type, - self->eeprom_map_p->length_diag_type, - &(self->diag_type), - "_common_update_attr_diag_type", - show_err); -} - - -static int -_common_update_attr_wavelength(struct transvr_obj_s *self, - int show_err){ - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_wavelength, - self->eeprom_map_p->page_wavelength, - self->eeprom_map_p->offset_wavelength, - self->eeprom_map_p->length_wavelength, - self->wavelength, - "_common_update_attr_wavelength", - show_err); -} - - -int -_common_get_option_value(struct transvr_obj_s *self, - int offset, - int bit_shift) { - /* SFP: - * - option[0] = A0h / 64 - * - option[1] = A0h / 65 - * QSFP: - * - option[0] = 00h / 193 - * - option[1] = 00h / 194 - * - option[2] = 00h / 195 - */ - return (self->option[offset] & (1 << bit_shift)); -} - - -static int -_sfp_update_attr_len_sm(struct transvr_obj_s *self, - int show_err){ - return _common_update_int_attr(self, - self->eeprom_map_p->addr_len_sm, - self->eeprom_map_p->page_len_sm, - self->eeprom_map_p->offset_len_sm, - self->eeprom_map_p->length_len_sm, - &(self->len_sm), - "_common_update_attr_len_sm", - show_err); -} - - -static int -_sfp_update_attr_rate_id(struct transvr_obj_s *self, - int show_err){ - return _common_update_int_attr(self, - self->eeprom_map_p->addr_rate_id, - self->eeprom_map_p->page_rate_id, - self->eeprom_map_p->offset_rate_id, - self->eeprom_map_p->length_rate_id, - &(self->rate_id), - "_sfp_update_attr_rate_id", - show_err); -} - - -static int -_sfp_update_attr_soft_rs0(struct transvr_obj_s *self, - int show_err){ - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_soft_rs0, - self->eeprom_map_p->page_soft_rs0, - self->eeprom_map_p->offset_soft_rs0, - self->eeprom_map_p->length_soft_rs0, - &(self->soft_rs0), - "_sfp_update_attr_soft_rs0", - show_err); -} - - -static int -_sfp_update_attr_soft_rs1(struct transvr_obj_s *self, - int show_err){ - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_soft_rs1, - self->eeprom_map_p->page_soft_rs1, - self->eeprom_map_p->offset_soft_rs1, - self->eeprom_map_p->length_soft_rs1, - &(self->soft_rs1), - "_sfp_update_attr_soft_rs1", - show_err); -} - - -int -_sfp_is_diag_support(struct transvr_obj_s *self){ - - uint8_t bit_mask = 0xC0; /* 1100 0000 */ - uint8_t en_val = 0x40; /* 0100 0000 */ - uint8_t checkval = (self->diag_type & bit_mask); - - if (checkval == en_val) { - return 1; - } - return 0; -} - - -static int -_sfp_update_attr_curr_temp(struct transvr_obj_s *self, - int show_err){ - - if (!(_sfp_is_diag_support(self))) { - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_temp, - self->eeprom_map_p->page_temp, - self->eeprom_map_p->offset_temp, - self->eeprom_map_p->length_temp, - self->curr_temp, - "_sfp_update_attr_curr_temp", - show_err); -} - - -static int -_sfp_update_attr_curr_voltage(struct transvr_obj_s *self, - int show_err){ - - if (!(_sfp_is_diag_support(self))) { - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_voltage, - self->eeprom_map_p->page_voltage, - self->eeprom_map_p->offset_voltage, - self->eeprom_map_p->length_voltage, - self->curr_voltage, - "_sfp_update_attr_curr_voltage", - show_err); -} - - -static int -_sfp_update_attr_curr_tx_bias(struct transvr_obj_s *self, - int show_err){ - - if (!(_sfp_is_diag_support(self))) { - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_tx_bias, - self->eeprom_map_p->page_tx_bias, - self->eeprom_map_p->offset_tx_bias, - self->eeprom_map_p->length_tx_bias, - self->curr_tx_bias, - "_sfp_update_attr_curr_tx_bias", - show_err); -} - - -static int -_sfp_update_attr_curr_tx_power(struct transvr_obj_s *self, - int show_err){ - - if (!(_sfp_is_diag_support(self))) { - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_tx_power, - self->eeprom_map_p->page_tx_power, - self->eeprom_map_p->offset_tx_power, - self->eeprom_map_p->length_tx_power, - self->curr_tx_power, - "_sfp_update_attr_curr_tx_power", - show_err); -} - - -static int -_sfp_update_attr_curr_rx_power(struct transvr_obj_s *self, - int show_err){ - - if (!(_sfp_is_diag_support(self))) { - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_rx_power, - self->eeprom_map_p->page_rx_power, - self->eeprom_map_p->offset_rx_power, - self->eeprom_map_p->length_rx_power, - self->curr_rx_power, - "_sfp_update_attr_curr_rx_power", - show_err); -} - - -static int -_sfp_update_attr_rx_em(struct transvr_obj_s *self, - int show_err){ - - if (!_is_transvr_support_ctle(self)) { - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_rx_em, - self->eeprom_map_p->page_rx_em, - self->eeprom_map_p->offset_rx_em, - self->eeprom_map_p->length_rx_em, - self->rx_em, - "_sfp_update_attr_rx_em", - show_err); -} - - -static int -_sfp_update_attr_tx_eq(struct transvr_obj_s *self, - int show_err){ - - if (!_is_transvr_support_ctle(self)) { - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_tx_eq, - self->eeprom_map_p->page_tx_eq, - self->eeprom_map_p->offset_tx_eq, - self->eeprom_map_p->length_tx_eq, - self->tx_eq, - "_sfp_update_attr_tx_eq", - show_err); -} - - -static int -_qsfp_update_attr_cdr(struct transvr_obj_s *self, - int show_err){ - if (self->type != TRANSVR_TYPE_QSFP_28){ - self->cdr = DEBUG_TRANSVR_HEX_VAL; - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_cdr, - self->eeprom_map_p->page_cdr, - self->eeprom_map_p->offset_cdr, - self->eeprom_map_p->length_cdr, - &(self->cdr), - "_common_update_attr_cdr", - show_err); -} - - -static int -_qsfg_update_attr_extbr(struct transvr_obj_s *self, - int show_err) { - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_extbr, - self->eeprom_map_p->page_extbr, - self->eeprom_map_p->offset_extbr, - self->eeprom_map_p->length_extbr, - &(self->extbr), - "_common_update_attr_extbr", - show_err); -} - - -static int -_qsfp_is_diag_support(struct transvr_obj_s *self, - int diag_type) { - /* Input Parm: diag_type - * => 1 : temperature - * => 2 : voltage - * => 3 : tx relate - * => 4 : rx relate - */ - uint8_t mask_b2 = 0x04; /* 0000 0100 */ - uint8_t mask_b3 = 0x08; /* 0000 1000 */ - - switch (diag_type) { - case 1: /* temperature */ - case 2: /* voltage */ - /* Direct access target, because of spec not defined */ - return 1; - case 3: - case 4: - /* [Note] - * Due to lot of transceiver vendor defined it not rigorously and - * consider of general support, we seem it as supported if there - * are bit-2 OR bit-3 defined by transceiver vendor. - */ - if ( ((self->diag_type & mask_b2) == mask_b2 ) || - ((self->diag_type & mask_b3) == mask_b3 ) ){ - return 1; - } - return 0; - default: - SWPS_INFO("%s: undefined diag_type:%d\n", - __func__, diag_type); - break; - } - return 0; -} - - -int -_qsfp_is_implement_tx_disable(struct transvr_obj_s *self) { - /* - * 00h / Byte-195 / Bit-4 - */ - int byte = 2; - int bit = 4; - return _common_get_option_value(self, byte, bit); -} - - -int -_qsfp_is_implement_tx_fault(struct transvr_obj_s *self) { - /* - * 00h / Byte-195 / Bit-3 - */ - int byte = 2; - int bit = 3; - return _common_get_option_value(self, byte, bit); -} - - -static int -_qsfp_update_attr_curr_temp(struct transvr_obj_s *self, - int show_err){ - int diag_type = 1; - - if (!(_qsfp_is_diag_support(self, diag_type))) { - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_temp, - self->eeprom_map_p->page_temp, - self->eeprom_map_p->offset_temp, - self->eeprom_map_p->length_temp, - self->curr_temp, - "_qsfp_update_attr_curr_temp", - show_err); -} - - -static int -_qsfp_update_attr_curr_voltage(struct transvr_obj_s *self, - int show_err){ - int diag_type = 2; - - if (!(_qsfp_is_diag_support(self, diag_type))) { - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_voltage, - self->eeprom_map_p->page_voltage, - self->eeprom_map_p->offset_voltage, - self->eeprom_map_p->length_voltage, - self->curr_voltage, - "_qsfp_update_attr_curr_voltage", - show_err); -} - - -static int -_qsfp_update_attr_curr_tx_bias(struct transvr_obj_s *self, - int show_err){ - int diag_type = 3; - - if (!(_qsfp_is_diag_support(self, diag_type))) { - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_tx_bias, - self->eeprom_map_p->page_tx_bias, - self->eeprom_map_p->offset_tx_bias, - self->eeprom_map_p->length_tx_bias, - self->curr_tx_bias, - "_qsfp_update_attr_curr_tx_bias", - show_err); -} - - -static int -_qsfp_update_attr_curr_tx_power(struct transvr_obj_s *self, - int show_err){ - int diag_type = 3; - - if (!(_qsfp_is_diag_support(self, diag_type))) { - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_tx_power, - self->eeprom_map_p->page_tx_power, - self->eeprom_map_p->offset_tx_power, - self->eeprom_map_p->length_tx_power, - self->curr_tx_power, - "_qsfp_update_attr_curr_tx_power", - show_err); -} - - -static int -_qsfp_update_attr_curr_rx_power(struct transvr_obj_s *self, - int show_err){ - int diag_type = 4; - - if (!(_qsfp_is_diag_support(self, diag_type))) { - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_rx_power, - self->eeprom_map_p->page_rx_power, - self->eeprom_map_p->offset_rx_power, - self->eeprom_map_p->length_rx_power, - self->curr_rx_power, - "_qsfp_update_attr_curr_rx_power", - show_err); -} - - -static int -_qsfp_update_attr_soft_rx_los(struct transvr_obj_s *self, - int show_err){ - - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_rx_los, - self->eeprom_map_p->page_rx_los, - self->eeprom_map_p->offset_rx_los, - self->eeprom_map_p->length_rx_los, - &(self->rx_los), - "_qsfp_update_attr_soft_rx_los", - show_err); -} - - -static int -_qsfp_update_attr_soft_tx_disable(struct transvr_obj_s *self, - int show_err){ - - if (!_qsfp_is_implement_tx_disable(self)) { - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_tx_disable, - self->eeprom_map_p->page_tx_disable, - self->eeprom_map_p->offset_tx_disable, - self->eeprom_map_p->length_tx_disable, - &(self->tx_disable), - "_qsfp_update_attr_soft_tx_disable", - show_err); -} - - -static int -_qsfp_update_attr_soft_tx_fault(struct transvr_obj_s *self, - int show_err){ - - if (!_qsfp_is_implement_tx_fault(self)) { - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_tx_fault, - self->eeprom_map_p->page_tx_fault, - self->eeprom_map_p->offset_tx_fault, - self->eeprom_map_p->length_tx_fault, - &(self->tx_fault), - "_qsfp_update_attr_soft_tx_fault", - show_err); -} - - -static int -_qsfp_update_attr_tx_eq(struct transvr_obj_s *self, - int show_err){ - - if (!_is_transvr_support_ctle(self)) { - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_tx_eq, - self->eeprom_map_p->page_tx_eq, - self->eeprom_map_p->offset_tx_eq, - self->eeprom_map_p->length_tx_eq, - self->tx_eq, - "_qsfp_update_attr_tx_eq", - show_err); -} - - -static int -_qsfp_update_attr_rx_am(struct transvr_obj_s *self, - int show_err){ - - if (!_is_transvr_support_ctle(self)) { - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_rx_am, - self->eeprom_map_p->page_rx_am, - self->eeprom_map_p->offset_rx_am, - self->eeprom_map_p->length_rx_am, - self->rx_am, - "_qsfp_update_attr_rx_am", - show_err); -} - - -static int -_qsfp_update_attr_rx_em(struct transvr_obj_s *self, - int show_err){ - - if (!_is_transvr_support_ctle(self)) { - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_rx_em, - self->eeprom_map_p->page_rx_em, - self->eeprom_map_p->offset_rx_em, - self->eeprom_map_p->length_rx_em, - self->rx_em, - "_qsfp_update_attr_rx_em", - show_err); -} - - -int -_common_update_attr_all(struct transvr_obj_s *self, - int show_err){ - - char *err_str = "err"; - - if (_common_update_attr_id(self, show_err) < 0) { - err_str = "_common_update_attr_id"; - goto err_common_update_attr_all; - } - if (_common_update_attr_extended_id(self, show_err) < 0) { - err_str = "_common_update_attr_extended_id"; - goto err_common_update_attr_all; - } - if (_common_update_attr_connector(self, show_err) < 0) { - err_str = "_common_update_attr_connector"; - goto err_common_update_attr_all; - } - if (_common_update_attr_transvr_comp(self, show_err) < 0) { - err_str = "_common_update_attr_transvr_comp"; - goto err_common_update_attr_all; - } - if (_common_update_attr_transvr_comp_ext(self, show_err) < 0) { - err_str = "_common_update_attr_transvr_comp_ext"; - goto err_common_update_attr_all; - } - if (_common_update_attr_vendor_name(self, show_err) < 0) { - err_str = "_common_update_attr_vendor_name"; - goto err_common_update_attr_all; - } - if (_common_update_attr_vendor_pn(self, show_err) < 0) { - err_str = "_common_update_attr_vendor_pn"; - goto err_common_update_attr_all; - } - if (_common_update_attr_vendor_rev(self, show_err) < 0) { - err_str = "_common_update_attr_vendor_rev"; - goto err_common_update_attr_all; - } - if (_common_update_attr_vendor_sn(self, show_err) < 0) { - err_str = "_common_update_attr_vendor_sn"; - goto err_common_update_attr_all; - } - if (_common_update_attr_br(self, show_err) < 0) { - err_str = "_common_update_attr_br"; - goto err_common_update_attr_all; - } - if (_common_update_attr_len_smf(self, show_err) < 0) { - err_str = "_common_update_attr_len_smf"; - goto err_common_update_attr_all; - } - if (_common_update_attr_len_om1(self, show_err) < 0) { - err_str = "_common_update_attr_len_om1"; - goto err_common_update_attr_all; - } - if (_common_update_attr_len_om2(self, show_err) < 0) { - err_str = "_common_update_attr_len_om2"; - goto err_common_update_attr_all; - } - if (_common_update_attr_len_om3(self, show_err) < 0) { - err_str = "_common_update_attr_len_om3"; - goto err_common_update_attr_all; - } - if (_common_update_attr_len_om4(self, show_err) < 0) { - err_str = "_common_update_attr_len_om4"; - goto err_common_update_attr_all; - } - if (_common_update_attr_option(self, show_err) < 0) { - err_str = "_common_update_attr_option"; - goto err_common_update_attr_all; - } - if (_common_update_attr_comp_rev(self, show_err) < 0) { - err_str = "_common_update_attr_comp_rev"; - goto err_common_update_attr_all; - } - if (_common_update_attr_diag_type(self, show_err) < 0) { - err_str = "_common_update_attr_diag_type"; - goto err_common_update_attr_all; - } - if (_common_update_attr_wavelength(self, show_err) < 0) { - err_str = "_common_update_attr_wavelength"; - goto err_common_update_attr_all; - } - if (_common_update_attr_eeprom(self, show_err) < 0) { - err_str = "_common_update_attr_eeprom"; - goto err_common_update_attr_all; - } - return 0; - -err_common_update_attr_all: - if (show_err){ - SWPS_INFO("%s: fail at:%s :%s\n", __func__, err_str, self->swp_name); - } - return -1; -} - - -int -_sfp_update_attr_all(struct transvr_obj_s *self, - int show_err){ - - char *err_str = DEBUG_TRANSVR_STR_VAL; - - if (_common_update_attr_all(self, show_err) < 0){ - err_str = "_common_update_attr_all"; - goto err_sfp_update_attr_all; - } - if (_sfp_update_attr_len_sm(self, show_err) < 0) { - err_str = "_sfp_update_attr_len_sm"; - goto err_sfp_update_attr_all; - } - if (_sfp_update_attr_rate_id(self, show_err) < 0) { - err_str = "_sfp_update_attr_rate_id"; - goto err_sfp_update_attr_all; - } - if ((self->rate_id) > 0) { - if (_sfp_update_attr_soft_rs0(self, show_err) < 0) { - err_str = "_sfp_update_attr_soft_rs0"; - goto err_sfp_update_attr_all; - } - if (_sfp_update_attr_soft_rs1(self, show_err) < 0) { - err_str = "_sfp_update_attr_soft_rs1"; - goto err_sfp_update_attr_all; - } - } - return 0; - -err_sfp_update_attr_all: - if (show_err){ - SWPS_INFO("%s: fail at:%s :%s\n", __func__, err_str, self->swp_name); - } - return -1; -} - - -int -_qsfp_update_attr_all(struct transvr_obj_s *self, - int show_err){ - - char *err_str = DEBUG_TRANSVR_STR_VAL; - - if (_common_update_attr_all(self, show_err) < 0){ - err_str = "_common_update_attr_all"; - goto err_qsfp_update_attr_all; - } - if (_qsfg_update_attr_extbr(self, show_err) < 0) { - err_str = "_qsfg_update_attr_extbr"; - goto err_qsfp_update_attr_all; - } - if (self->type == TRANSVR_TYPE_QSFP_28) { - if (_qsfp_update_attr_cdr(self, 1) < 0) { - err_str = "_qsfp_update_attr_cdr"; - goto err_qsfp_update_attr_all; - } - } - return 0; - -err_qsfp_update_attr_all: - if (show_err){ - SWPS_INFO("%s: fail at:%s :%s\n", __func__, err_str, self->swp_name); - } - return -1; -} - - -/* ========== Object functions for common type ========== - */ -int -_common_count_temp(uint8_t high_byte, - uint8_t low_byte, - char *buf_p) { - int sign = 0; - int high = 0; - int low = 0; - int lmax = 8; - - /* Count high */ - sign = get_bit(high_byte,7); - SWP_BIT_CLEAR(high_byte, 7); - high = (int)high_byte; - if (sign == 1) { - high = 0 - high; - } - /* Count low */ - low = (get_bit(low_byte, 7) * 500); - low += (get_bit(low_byte, 6) * 250); - low += (get_bit(low_byte, 5) * 125); - low += (get_bit(low_byte, 4) * 62); - low = (low / 100); - /* Integrate High and Low */ - return snprintf(buf_p, lmax, "%d.%d\n", high, low); -} - - -int -_common_count_voltage(uint8_t high_byte, - uint8_t low_byte, - char *buf_p) { - /* [Note]: - * Internally measured transceiver supply voltage. Represented - * as a 16 bit unsigned integer with the voltage defined as the - * full 16 bit value (0-65535) with LSB equal to 100 uVolt, - * yielding a total range of 0 to +6.55 Volts. Practical - * considerations to be defined by transceiver manufacturer will - * tend to limit the actual bounds of the supply voltage measurement. - * Accuracy is vendor specific but must be better than 3% of the - * manufacturer's nominal value over specified operating temperature - * and voltage. Note that in some transceivers, transmitter supply - * voltage and receiver supply voltage are isolated. In that case, - * only one supply is monitored. Refer to the device specification - * for more detail. - */ - int total = 0; - int lmax = 8; - int val_i = 0; - int val_f = 0; - /* unit: 100 uV (1mV=1000uV) */ - total = transform_word_to_int(high_byte, low_byte); - val_i = ((total/10) / 1000); - val_f = ((total/10) - (val_i*1000)); - /* Return Unit: 1 Volt */ - return snprintf(buf_p, lmax, "%d.%03d\n", val_i, val_f); -} - - -int -_common_count_tx_bias(uint8_t high_byte, - uint8_t low_byte, - char *buf_p) { - /* [Note] - * Measured TX bias current in uA. Represented as a 16 bit unsigned - * integer with the current defined as the full 16 bit value (0-65535) - * with LSB equal to 2 uA, yielding a total range of 0 to 131 mA. - * Accuracy is vendor specific but must be better than 10% of the - * manufacturer's nominal value over specified operating temperature - * and voltage. - */ - int total = 0; - int lmax = 8; - int val_i = 0; - int val_f = 0; - /* unit: 2 uA (1mA=1000uA) */ - total = transform_word_to_int(high_byte, low_byte); - val_i = ((total*2) / 1000); - val_f = (((total*2) - (val_i*1000)) / 100); - /* Return Unit: 1 mA */ - return snprintf(buf_p, lmax, "%d.%01d\n", val_i, val_f); -} - - -int -_common_count_tx_power(uint8_t high_byte, - uint8_t low_byte, - char *buf_p) { - /* [Note] - * Measured TX output power in mW. Represented as a 16 bit unsigned - * integer with the power defined as the full 16 bit value (0-65535) - * with LSB equal to 0.1 uW, yielding a total range of 0 to 6.5535 mW - * (~ -40 to +8.2 dBm). Data is assumed to be based on measurement of - * laser monitor photodiode current. It is factory calibrated to absolute - * units using the most representative fiber output type. Accuracy is - * vendor specific but must be better than 3dB over specified temperature - * and voltage. Data is not valid when the transmitter is disabled. - */ - int total = 0; - int lmax = 8; - int val_i = 0; - int val_f = 0; - /* unit: 0.1 uW (1mW=1000uW) */ - total = transform_word_to_int(high_byte, low_byte); - val_i = ((total/10) / 1000); - val_f = ((total/10) - (val_i*1000)); - /* Return Unit: 1 mW */ - return snprintf(buf_p, lmax, "%d.%03d\n", val_i, val_f); -} - - -int -_common_count_rx_power(uint8_t high_byte, - uint8_t low_byte, - char *buf_p) { - /* [Note] - * Measured RX received optical power in mW. Value can represent either - * average received power or OMA depending upon how bit 3 of byte 92 (A0h) - * is set. Represented as a 16 bit unsigned integer with the power defined - * as the full 16 bit value (0-65535) with LSB equal to 0.1 uW, yielding a - * total range of 0 to 6.5535 mW (~ -40 to +8.2 dBm). Absolute accuracy is - * dependent upon the exact optical wavelength. For the vendor specified - * wavelength, accuracy shall be better than 3dB over specified temperature - * and voltage. - */ - int total = 0; - int lmax = 8; - int val_i = 0; - int val_f = 0; - /* unit: 0.1 uW (1mW=1000uW) */ - total = transform_word_to_int(high_byte, low_byte); - val_i = ((total/10) / 1000); - val_f = ((total/10) - (val_i*1000)); - /* Return Unit: 1 mW */ - return snprintf(buf_p, lmax, "%d.%03d\n", val_i, val_f); -} - - -int -_common_count_wavelength(struct transvr_obj_s *self, - uint8_t high_byte, - uint8_t low_byte) { - /* [Note] - * SFP : uint 1 um. - * QSFP: unit 0.05 um. - */ - int total = 0; - - total = transform_word_to_int(high_byte, low_byte); - switch (self->type) { - case TRANSVR_TYPE_SFP: - return total; - - case TRANSVR_TYPE_QSFP: - case TRANSVR_TYPE_QSFP_PLUS: - case TRANSVR_TYPE_QSFP_28: - return (total/20); - - default: - break; - } - return ERR_TRANSVR_UNDEFINED; -} - - -int -common_get_id(struct transvr_obj_s *self){ - - int err_code = _check_by_mode(self, - &_common_update_attr_id, - "common_get_id"); - if (err_code < 0){ - return err_code; - } - /* Transform to INT to show error case */ - return (int)self->id; -} - - -int -common_get_ext_id(struct transvr_obj_s *self){ - - int err_code = _check_by_mode(self, - &_common_update_attr_extended_id, - "common_get_ext_id"); - if (err_code < 0){ - return err_code; - } - /* Transform to INT to show error case */ - return (int)self->ext_id; -} - - -int -common_get_connector(struct transvr_obj_s *self){ - - int err_code = _check_by_mode(self, - &_common_update_attr_connector, - "common_get_connector"); - if (err_code < 0){ - return err_code; - } - /* Transform to INT to show error case */ - return (int)self->connector; -} - -int -common_get_eeprom(struct transvr_obj_s *self, char *buf){ - - int err = DEBUG_TRANSVR_INT_VAL; - unsigned char *eeprom_update = get_eeprom_update(); - - if (!(eeprom_update[self->port_no/8] & (1 << self->port_no%8)) && - (self->state == STATE_TRANSVR_CONNECTED && - self->mode == TRANSVR_MODE_POLLING && - TRANSVR_INFO_CACHE_ENABLE)) { - memset(buf, 0, self->eeprom_map_p->length_eeprom); - memcpy(buf, self->eeprom, self->eeprom_map_p->length_eeprom); - *(buf+self->eeprom_map_p->length_eeprom) = '\n'; - return self->eeprom_map_p->length_eeprom; - } - err = _check_by_mode(self, &_common_update_attr_eeprom, - "common_get_eeprom"); - if (err < 0){ - return snprintf(buf, LEN_TRANSVR_M_STR, "%d\n", err); - } - memset(buf, 0, self->eeprom_map_p->length_eeprom); - memcpy(buf, self->eeprom, self->eeprom_map_p->length_eeprom); - *(buf+self->eeprom_map_p->length_eeprom) = '\n'; - eeprom_update[self->port_no/8] &= ~(1 << self->port_no%8); - set_eeprom_update(eeprom_update); - return self->eeprom_map_p->length_eeprom; -} - -int -common_get_vendor_name(struct transvr_obj_s *self, char *buf){ - - int err = DEBUG_TRANSVR_INT_VAL; - - if (self->state == STATE_TRANSVR_CONNECTED && - self->mode == TRANSVR_MODE_POLLING && - TRANSVR_INFO_CACHE_ENABLE) { - return snprintf(buf, LEN_TRANSVR_M_STR, "%s\n", self->vendor_name); - } - err = _check_by_mode(self, - &_common_update_attr_vendor_name, - "common_get_vendor_name"); - memset(buf, 0, LEN_TRANSVR_M_STR); - if (err < 0){ - return snprintf(buf, LEN_TRANSVR_M_STR, "%d\n", err); - } - return snprintf(buf, LEN_TRANSVR_M_STR, "%s\n", self->vendor_name); -} - - -int -common_get_vendor_pn(struct transvr_obj_s *self, char *buf) { - - int err = DEBUG_TRANSVR_INT_VAL; - - if (self->state == STATE_TRANSVR_CONNECTED && - self->mode == TRANSVR_MODE_POLLING && - TRANSVR_INFO_CACHE_ENABLE) { - return snprintf(buf, LEN_TRANSVR_M_STR, "%s\n", self->vendor_pn); - } - err = _check_by_mode(self, - &_common_update_attr_vendor_pn, - "common_get_vendor_pn"); - memset(buf, 0, LEN_TRANSVR_M_STR); - if (err < 0){ - return snprintf(buf, LEN_TRANSVR_M_STR, "%d\n", err); - } - return snprintf(buf, LEN_TRANSVR_M_STR, "%s\n", self->vendor_pn); -} - - -int -common_get_vendor_rev(struct transvr_obj_s *self, char *buf) { - - int err = DEBUG_TRANSVR_INT_VAL; - - if (self->state == STATE_TRANSVR_CONNECTED && - self->mode == TRANSVR_MODE_POLLING && - TRANSVR_INFO_CACHE_ENABLE) { - return snprintf(buf, LEN_TRANSVR_M_STR, "%s\n", self->vendor_rev); - } - err = _check_by_mode(self, - &_common_update_attr_vendor_rev, - "common_get_vendor_rev"); - memset(buf, 0, LEN_TRANSVR_M_STR); - if (err < 0){ - return snprintf(buf, LEN_TRANSVR_M_STR, "%d\n", err); - } - return snprintf(buf, LEN_TRANSVR_M_STR, "%s\n", self->vendor_rev); -} - - -int -common_get_vendor_sn(struct transvr_obj_s *self, char *buf) { - - int err = DEBUG_TRANSVR_INT_VAL; - - if (self->state == STATE_TRANSVR_CONNECTED && - self->mode == TRANSVR_MODE_POLLING && - TRANSVR_INFO_CACHE_ENABLE) { - return snprintf(buf, LEN_TRANSVR_M_STR, "%s\n", self->vendor_sn); - } - err = _check_by_mode(self, - &_common_update_attr_vendor_sn, - "common_get_vendor_sn"); - memset(buf, 0, LEN_TRANSVR_M_STR); - if (err < 0){ - return snprintf(buf, LEN_TRANSVR_M_STR, "%d\n", err); - } - return snprintf(buf, LEN_TRANSVR_M_STR, "%s\n", self->vendor_sn); -} - - -int -common_get_br(struct transvr_obj_s *self){ - - int err = DEBUG_TRANSVR_INT_VAL; - - if (self->state == STATE_TRANSVR_CONNECTED && - self->mode == TRANSVR_MODE_POLLING && - TRANSVR_INFO_CACHE_ENABLE) { - return (int)self->br; - } - err = _check_by_mode(self, - &_common_update_attr_br, - "common_get_br"); - if (err < 0){ - return err; - } - /* Transform to INT to show error case */ - return (int)self->br; -} - - -int -common_get_len_smf(struct transvr_obj_s *self){ - - int err = DEBUG_TRANSVR_INT_VAL; - - if (self->state == STATE_TRANSVR_CONNECTED && - self->mode == TRANSVR_MODE_POLLING && - TRANSVR_INFO_CACHE_ENABLE) { - return self->len_smf; - } - err = _check_by_mode(self, - &_common_update_attr_len_smf, - "common_get_len_smf"); - if (err < 0){ - return err; - } - return self->len_smf; -} - - -int -common_get_len_om1(struct transvr_obj_s *self){ - - int err = DEBUG_TRANSVR_INT_VAL; - - if (self->state == STATE_TRANSVR_CONNECTED && - self->mode == TRANSVR_MODE_POLLING && - TRANSVR_INFO_CACHE_ENABLE) { - return self->len_om1; - } - err = _check_by_mode(self, - &_common_update_attr_len_om1, - "common_get_len_om1"); - if (err < 0){ - return err; - } - return self->len_om1; -} - - -int -common_get_len_om2(struct transvr_obj_s *self){ - - int err = DEBUG_TRANSVR_INT_VAL; - - if (self->state == STATE_TRANSVR_CONNECTED && - self->mode == TRANSVR_MODE_POLLING && - TRANSVR_INFO_CACHE_ENABLE) { - return self->len_om2; - } - - err = _check_by_mode(self, - &_common_update_attr_len_om2, - "common_get_len_om2"); - if (err < 0){ - return err; - } - return self->len_om2; -} - - -int -common_get_len_om3(struct transvr_obj_s *self){ - - int err = DEBUG_TRANSVR_INT_VAL; - - if (self->state == STATE_TRANSVR_CONNECTED && - self->mode == TRANSVR_MODE_POLLING && - TRANSVR_INFO_CACHE_ENABLE) { - return self->len_om3; - } - - err = _check_by_mode(self, - &_common_update_attr_len_om3, - "common_get_len_om3"); - if (err < 0){ - return err; - } - return self->len_om3; -} - - -int -common_get_len_om4(struct transvr_obj_s *self){ - - int err = DEBUG_TRANSVR_INT_VAL; - - if (self->state == STATE_TRANSVR_CONNECTED && - self->mode == TRANSVR_MODE_POLLING && - TRANSVR_INFO_CACHE_ENABLE) { - return self->len_om4; - } - err = _check_by_mode(self, - &_common_update_attr_len_om4, - "common_get_len_om4"); - if (err < 0){ - return err; - } - return self->len_om4; -} - - -int -common_get_comp_extended(struct transvr_obj_s *self){ - - int err_code = _check_by_mode(self, - &_common_update_attr_transvr_comp_ext, - "common_get_comp_extended"); - if (err_code < 0){ - return err_code; - } - return self->transvr_comp_ext; -} - - -int -common_get_comp_rev(struct transvr_obj_s *self){ - - int err_code = _check_by_mode(self, - &_common_update_attr_comp_rev, - "common_get_comp_rev"); - if (err_code < 0){ - return err_code; - } - return self->comp_rev; -} - - -int -common_get_info(struct transvr_obj_s *self){ - - if (self->state != STATE_TRANSVR_CONNECTED) { - return self->state; - } - return self->info; -} - - -int -_common_get_if_lane(struct transvr_obj_s *self, - char *result){ - int i = 0; - int tmp_val = 0; - char tmp_str[LEN_TRANSVR_M_STR] = DEBUG_TRANSVR_STR_VAL; - - memset(result, 0, LEN_TRANSVR_M_STR); - - for (i=0; ilane_id); i++) { - tmp_val = self->lane_id[i]; - if (tmp_val < 1) { - break; - } - memset(tmp_str, 0, LEN_TRANSVR_M_STR); - if (i == 0) { - snprintf(tmp_str, LEN_TRANSVR_M_STR, "%d", tmp_val); - } else { - snprintf(tmp_str, LEN_TRANSVR_M_STR, ",%d", tmp_val); - } - strncat(result, tmp_str, LEN_TRANSVR_M_STR); - } - if (i == 0) { - return EVENT_TRANSVR_TASK_FAIL; - } - return 0; -} - - -int -common_get_if_lane(struct transvr_obj_s *self, - char *buf_p){ - - char tmp_str[LEN_TRANSVR_M_STR] = DEBUG_TRANSVR_STR_VAL; - - if (self->ioexp_obj_p->state != STATE_IOEXP_NORMAL) { - return snprintf(buf_p, LEN_TRANSVR_M_STR, "%d\n", ERR_TRANSVR_ABNORMAL); - } - if (_common_get_if_lane(self, tmp_str) < 0) { - return snprintf(buf_p, LEN_TRANSVR_M_STR, "%d\n" ,ERR_TRANSVR_ABNORMAL); - } - return snprintf(buf_p, LEN_TRANSVR_M_STR, "%s\n" ,tmp_str); -} - - -int -sfp_get_len_sm(struct transvr_obj_s *self){ - - int err_code = _check_by_mode(self, - &_sfp_update_attr_len_sm, - "sfp_get_len_sm"); - if (err_code < 0){ - return err_code; - } - return self->len_sm; -} - - -int -sfp_get_rate_id(struct transvr_obj_s *self){ - - int err_code = _check_by_mode(self, - &_sfp_update_attr_rate_id, - "sfp_get_rate_id"); - if (err_code < 0){ - return err_code; - } - return self->rate_id; -} - - -int -sfp_get_soft_rs0(struct transvr_obj_s *self){ - /* Note: - * SFP Soft Rate_Select Select [aka. "RS(0)"] address - * A2h, offset: 110, bit 3 (begin form 0) - */ - int err_code = DEBUG_TRANSVR_INT_VAL; - int bit_shift = 3; - uint8_t result = 0x00; - uint8_t bitmask = (1 << bit_shift); - - /* Check rate identifier is supported */ - err_code = self->get_rate_id(self); - if (err_code <= 0) { - return ERR_TRANSVR_NOTSUPPORT; - } - /* Update and check */ - err_code = _check_by_mode(self, - &_sfp_update_attr_soft_rs0, - "sfp_get_soft_rs0"); - if (err_code <0){ - return err_code; - } - result = (self->soft_rs0 & bitmask); - if (result == bitmask) { - return 1; - } - if (result == 0) { - return 0; - } - return ERR_TRANSVR_UNEXCPT; -} - - -int -sfp_get_soft_rs1(struct transvr_obj_s *self){ - /* Note: - * SFP Soft RS(1) Select address - * A2h, offset: 118, bit 3 (begin form 0) - */ - int err_code = DEBUG_TRANSVR_INT_VAL; - int bit_shift = 3; - uint8_t result = 0x00; - uint8_t bitmask = (1 << bit_shift); - - /* Check rate identifier is supported */ - err_code = self->get_rate_id(self); - if (err_code <= 0) { - return ERR_TRANSVR_NOTSUPPORT; - } - /* Update and check */ - err_code = _check_by_mode(self, - &_sfp_update_attr_soft_rs1, - "sfp_get_soft_rs1"); - if (err_code <0){ - return err_code; - } - result = (self->soft_rs1 & bitmask); - if (result == bitmask) { - return 1; - } - if (result == 0) { - return 0; - } - return ERR_TRANSVR_UNEXCPT; -} - - -int -sfp_get_transvr_temp(struct transvr_obj_s *self, - char *buf_p) { - - int lmax = 8; - int err_code = DEBUG_TRANSVR_INT_VAL; - - err_code = _check_by_mode(self, - &_sfp_update_attr_curr_temp, - "sfp_get_transvr_temp"); - if (err_code < 0) { - return snprintf(buf_p, lmax, "%d\n", err_code); - } - if ((self->curr_temp[0]) == DEBUG_TRANSVR_HEX_VAL) { - return snprintf(buf_p, lmax, "%d\n", ERR_TRANSVR_UPDATE_FAIL); - } - return _common_count_temp(self->curr_temp[0], - self->curr_temp[1], - buf_p); -} - - -int -sfp_get_transvr_voltage(struct transvr_obj_s *self, - char *buf_p) { - - int lmax = 8; - int err_code = DEBUG_TRANSVR_INT_VAL; - - err_code = _check_by_mode(self, - &_sfp_update_attr_curr_voltage, - "sfp_get_transvr_voltage"); - if (err_code < 0) { - return snprintf(buf_p, lmax, "%d\n", err_code); - } - if ((self->curr_voltage[0]) == DEBUG_TRANSVR_HEX_VAL) { - return snprintf(buf_p, lmax, "%d\n", ERR_TRANSVR_UPDATE_FAIL); - } - /* Return Unit: 1 Volt */ - return _common_count_voltage(self->curr_voltage[0], - self->curr_voltage[1], - buf_p); -} - - -int -sfp_get_transvr_tx_bias(struct transvr_obj_s *self, - char *buf_p) { - - int lmax = 8; - int err_code = DEBUG_TRANSVR_INT_VAL; - - err_code = _check_by_mode(self, - &_sfp_update_attr_curr_tx_bias, - "sfp_get_transvr_tx_bias"); - if (err_code < 0) { - return snprintf(buf_p, lmax, "%d\n", err_code); - } - if ((self->curr_tx_bias[0]) == DEBUG_TRANSVR_HEX_VAL) { - return snprintf(buf_p, lmax, "%d\n", ERR_TRANSVR_UPDATE_FAIL); - } - /* Return Unit: 1 mA */ - return _common_count_tx_bias(self->curr_tx_bias[0], - self->curr_tx_bias[1], - buf_p); -} - - -int -sfp_get_transvr_tx_power(struct transvr_obj_s *self, - char *buf_p) { - - int lmax = 8; - int err_code = DEBUG_TRANSVR_INT_VAL; - - err_code = _check_by_mode(self, - &_sfp_update_attr_curr_tx_power, - "sfp_get_transvr_tx_power"); - if (err_code < 0) { - return snprintf(buf_p, lmax, "%d\n", err_code); - } - if ((self->curr_tx_bias[0]) == DEBUG_TRANSVR_HEX_VAL) { - return snprintf(buf_p, lmax, "%d\n", ERR_TRANSVR_UPDATE_FAIL); - } - /* Return Unit: 1 mW */ - return _common_count_tx_power(self->curr_tx_power[0], - self->curr_tx_power[1], - buf_p); -} - - -int -sfp_get_transvr_rx_power(struct transvr_obj_s *self, - char *buf_p) { - - int lmax = 8; - int err_code = DEBUG_TRANSVR_INT_VAL; - - err_code = _check_by_mode(self, - &_sfp_update_attr_curr_rx_power, - "sfp_get_transvr_rx_power"); - if (err_code < 0) { - return snprintf(buf_p, lmax, "%d\n", err_code); - } - if ((self->curr_tx_bias[0]) == DEBUG_TRANSVR_HEX_VAL) { - return snprintf(buf_p, lmax, "%d\n", ERR_TRANSVR_UPDATE_FAIL); - } - /* Return Unit: 1 mW */ - return _common_count_rx_power(self->curr_rx_power[0], - self->curr_rx_power[0], - buf_p); -} - - -int -sfp_get_transvr_rx_em(struct transvr_obj_s *self, - char *buf_p) { - - int limt = 8; - int err = DEBUG_TRANSVR_INT_VAL; - - err = _check_by_mode(self, - &_sfp_update_attr_rx_em, - "sfp_get_transvr_rx_em"); - if (err < 0) { - return snprintf(buf_p, limt, "%d\n", err); - } - if ((self->tx_eq[0]) == DEBUG_TRANSVR_HEX_VAL) { - return snprintf(buf_p, limt, "%d\n", ERR_TRANSVR_UPDATE_FAIL); - } - return snprintf(buf_p, limt, "0x%02x\n", self->rx_em[0]); -} - - -int -sfp_get_transvr_tx_eq(struct transvr_obj_s *self, - char *buf_p) { - - int limt = 8; - int err = DEBUG_TRANSVR_INT_VAL; - - err = _check_by_mode(self, - &_sfp_update_attr_tx_eq, - "sfp_get_transvr_tx_eq"); - if (err < 0) { - return snprintf(buf_p, limt, "%d\n", err); - } - if ((self->tx_eq[0]) == DEBUG_TRANSVR_HEX_VAL) { - return snprintf(buf_p, limt, "%d\n", ERR_TRANSVR_UPDATE_FAIL); - } - return snprintf(buf_p, limt, "0x%02x\n", self->tx_eq[0]); -} - - -int -_sfp_get_comp_extended(struct transvr_obj_s *self) { - /* Address: A0h / 36 - * Reference: SFF-8024 TABLE 4-4 - */ - if ((self->state == STATE_TRANSVR_CONNECTED) || - (self->state == STATE_TRANSVR_INIT) ) { - return (int)(self->transvr_comp_ext); - } - return ERR_TRANSVR_ABNORMAL; -} - - -int -__sfp_get_comp_attr(struct transvr_obj_s *self, - int array_offset) { - /* SFP Specification Compliance: A0h / 3-10 - * transvr_comp[0-7] = 3 - 10 - */ - if ((self->state == STATE_TRANSVR_CONNECTED) || - (self->state == STATE_TRANSVR_INIT) ) { - return (int)(self->transvr_comp[array_offset]); - } - return ERR_TRANSVR_ABNORMAL; -} - - -int -_sfp_get_comp_10g_eth_comp(struct transvr_obj_s *self) { - /* transvr_comp[0] = address A0h / 3 - * - * 3 7: 10G Base-ER - * 3 6: 10GBASE-LRM - * 3 5: 10GBASE-LR - * 3 4: 10GBASE-SR - */ - int bitmask = 0xf0; /* 11110000 */ - return (__sfp_get_comp_attr(self, 0) & bitmask); -} - - -int -_sfp_get_comp_1g_eth_comp(struct transvr_obj_s *self) { - /* transvr_comp[3] = address A0h / 6 - * - * 6 7: BASE-PX *3 - * 6 6: BASE-BX10 *3 - * 6 5: 100BASE-FX - * 6 4: 100BASE-LX/LX10 - * 6 3: 1000BASE-T - * 6 2: 1000BASE-CX - * 6 1: 1000BASE-LX *3 - * 6 0: 1000BASE-SX - */ - return __sfp_get_comp_attr(self, 3); -} - - -int -_sfp_get_cable_tech(struct transvr_obj_s *self) { - /* transvr_comp[5] = address A0h / 8 - * - * 8 3: Active Cable *8 - * 8 2: Passive Cable *8 - */ - int bitmask = 0x0c; /* 00001100 */ - return (__sfp_get_comp_attr(self, 5) & bitmask); -} - - -int -sfp_get_comp_eth_1(struct transvr_obj_s *self){ - - int err_code = _check_by_mode(self, - &_common_update_attr_transvr_comp, - "sfp_get_comp_eth_1"); - if (err_code < 0){ - return err_code; - } - return _sfp_get_comp_1g_eth_comp(self); -} - - -int -sfp_get_comp_eth_10(struct transvr_obj_s *self){ - - int err_code = _check_by_mode(self, - &_common_update_attr_transvr_comp, - "sfp_get_comp_eth_10"); - if (err_code < 0){ - return err_code; - } - return _sfp_get_comp_10g_eth_comp(self); -} - - -int -_sfp_get_connector_type(struct transvr_obj_s *self) { - /* Address: A0h / 2 - * Reference: SFF-8024 TABLE 4-3 - */ - if ((self->state == STATE_TRANSVR_CONNECTED) || - (self->state == STATE_TRANSVR_INIT) ) { - return (int)(self->connector); - } - return ERR_TRANSVR_ABNORMAL; -} - - -int -sfp_get_wavelength(struct transvr_obj_s *self, - char *buf_p) { - /* [Note] Optical and Cable Variants Specification Compliance (SFF-8472) - * [Addr] A0h, Bytes 60-61 - * [Note] For optical variants, as defined by having zero's in A0h Byte 8 - * bits 2 and 3, Bytes 60 and 61 denote nominal transmitter output - * wavelength at room temperature. 16 bit value with byte 60 as high - * order byte and byte 61 as low order byte. The laser wavelength is - * equal to the 16 bit integer value in nm. This field allows the user - * to read the laser wavelength directly, so it is not necessary to - * infer it from the Transceiver Codes A0h Bytes 3 to 10 (see Table - * 5-3). This also allows specification of wavelengths not covered - * in the Transceiver Codes, such as those used in coarse WDM systems. - * - * For passive and active cable variants, a value of 00h for both A0h - * Byte 60 and Byte 61 denotes laser wavelength or cable specification - * compliance is unspecified. - */ - - int lmax = 8; - int err_code = DEBUG_TRANSVR_INT_VAL; - - err_code = _check_by_mode(self, - &_common_update_attr_wavelength, - "common_get_wavelength"); - if (err_code < 0) { - return snprintf(buf_p, lmax, "%d\n", err_code); - } - if ((self->wavelength[0]) == DEBUG_TRANSVR_HEX_VAL) { - return snprintf(buf_p, lmax, "%d\n", ERR_TRANSVR_UPDATE_FAIL); - } - /* unit: 1 um */ - return snprintf(buf_p, lmax, "%d\n", - _common_count_wavelength(self, - self->wavelength[0], - self->wavelength[1])); -} - - -int -__qsfp_get_power_cls(struct transvr_obj_s *self, - int direct_access){ - - int err_code; - uint8_t detect_val; - - /* Detect and Update power class attribute */ - if (direct_access){ - err_code = _check_by_mode(self, - &_common_update_attr_extended_id, - "__qsfp_get_power_cls"); - } else { - err_code = self->ext_id; - } - if (err_code <0){ - return err_code; - } - if (err_code == DEBUG_TRANSVR_HEX_VAL){ - return ERR_TRANSVR_UPDATE_FAIL; - } - /* Clean data */ - detect_val = self->ext_id; - SWP_BIT_CLEAR(detect_val, 2); /* Bit2: CDR RX present */ - SWP_BIT_CLEAR(detect_val, 3); /* Bit3: CDR TX present */ - SWP_BIT_CLEAR(detect_val, 4); /* Bit4: CLEI present */ - SWP_BIT_CLEAR(detect_val, 5); /* Bit5: reserved */ - /* Identify power class */ - switch (detect_val) { - case 0: /* Class_1: 00000000 */ - return 1; - case 64: /* Class_2: 01000000 */ - return 2; - case 128: /* Class_3: 10000000 */ - return 3; - case 192: /* Class_4: 11000000 */ - return 4; - case 1: /* Class_5: 00000001 */ - case 193: /* Class_5: 11000001 */ - return 5; - case 2: /* Class_6: 00000010 */ - case 194: /* Class_6: 11000010 */ - return 6; - case 3: /* Class_7: 00000011 */ - case 195: /* Class_7: 11000011 */ - return 7; - default: - break; - } - SWPS_INFO("%s: Detect undefined power class:%d\n", __func__, detect_val); - return ERR_TRANSVR_UNDEFINED; -} - - -int -qsfp_get_power_cls(struct transvr_obj_s *self) { - return __qsfp_get_power_cls(self, 1); -} - - -int -__qsfp_get_cdr_present(struct transvr_obj_s *self, - int direct_access){ - - int retval; - int BIT_SHIFT = 2; - int BIT_MASK = 0x3; - - /* Detect and Update power class attribute */ - if (direct_access) { - retval = _check_by_mode(self, - &_common_update_attr_extended_id, - "__qsfp_get_cdr_present"); - if (retval < 0){ - return retval; - } - } - retval = self->ext_id; - if (retval == DEBUG_TRANSVR_HEX_VAL){ - return ERR_TRANSVR_UPDATE_FAIL; - } - /* Clean data and return */ - return (int)(retval >> BIT_SHIFT & BIT_MASK); -} - - -int -qsfp_get_cdr_present(struct transvr_obj_s *self) { - return __qsfp_get_cdr_present(self, 1); -} - - -int -qsfp_get_cdr(struct transvr_obj_s *self){ - - int err_code = _check_by_mode(self, - &_qsfp_update_attr_cdr, - "qsfp_get_cdr"); - if (err_code <0){ - return err_code; - } - - return self->cdr; -} - - -int -__qsfp_get_comp_attr(struct transvr_obj_s *self, - int array_offset) { - /* QSFP Specification Compliance: 00h / 131-138 - * transvr_comp[0-7] = 131 - 138 - */ - if ((self->state == STATE_TRANSVR_CONNECTED) || - (self->state == STATE_TRANSVR_INIT) ) { - return (int)(self->transvr_comp[array_offset]); - } - return ERR_TRANSVR_ABNORMAL; -} - - -int -_qsfp_get_comp_10_40_100_ethernet(struct transvr_obj_s *self) { - /* transvr_comp[0] = address 00h / 131 - * - * 131 7: Extended: See section 6.3.23. The Extended Specification Compliance - * Codes are maintained in the Transceiver Management section of SFF- - * 8024. - * 131 6: 10GBASE-LRM - * 131 5: 10GBASE-LR - * 131 4: 10GBASE-SR - * 131 3: 40GBASE-CR4 - * 131 2: 40GBASE-SR4 - * 131 1: 40GBASE-LR4 - * 131 0: 40G Active Cable (XLPPI) - */ - return __qsfp_get_comp_attr(self, 0); -} - - -int -_qsfp_get_comp_sonet(struct transvr_obj_s *self) { - /* transvr_comp[1] = address 00h / 132 - * - * 132 7-3: Reserved - * 132 2: OC 48, long reach - * 132 1: OC 48, intermediate reach - * 132 0: OC 48 short reach - */ - return __qsfp_get_comp_attr(self, 1); -} - - -int -_qsfp_get_comp_sas_sata(struct transvr_obj_s *self) { - /* transvr_comp[1] = address 00h / 132 - * - * 133 7: SAS 24.0 Gb/s - * 133 6: SAS 12.0 Gb/s - * 133 5: SAS 6.0 Gb/s - * 133 4: SAS 3.0 Gb/s - * 133 3-0: Reserved - */ - return __qsfp_get_comp_attr(self, 2); -} - - -int -_qsfp_get_comp_ethernet(struct transvr_obj_s *self) { - /* transvr_comp[1] = address 00h / 132 - * - * 134 7-4: Reserved - * 134 3: 1000BASE-T - * 134 2: 1000BASE-CX - * 134 1: 1000BASE-LX - * 134 0: 1000BASE-SX - */ - return __qsfp_get_comp_attr(self, 3); -} - - -int -_qsfp_get_comp_fc_link_length(struct transvr_obj_s *self) { - /* transvr_comp[1] = address 00h / 132 - * - * 135 7: Very long distance (V) - * 135 6: Short distance (S) - * 135 5: Intermediate distance (I) - * 135 4: Long distance (L) - * 135 3: Medium (M) - */ - int mask = 0xFC; /* 11111100 */ - return (__qsfp_get_comp_attr(self, 4) & mask); -} - - -int -_qsfp_get_comp_fc_trans_tech(struct transvr_obj_s *self) { - /* transvr_comp[1] = address 00h / 132 - * - * 135 2: Reserved - * 135 1: Longwave laser (LC) - * 135 0: Electrical inter-enclosure (EL) - * - * 136 7: Electrical intra-enclosure - * 136 6: Shortwave laser w/o OFC (SN) - * 136 5: Shortwave laser w OFC (SL) - * 136 4: Longwave Laser (LL) - * 136 3-0: Reserved - * - * return value = [bit 8-15:addr 135][bit 0-7:addr 136] - */ - int mask_135 = 7; /* 00000111 */ - int val_135 = (__qsfp_get_comp_attr(self, 4) & mask_135); - int val_136 = __qsfp_get_comp_attr(self, 5); - return ((val_135 << 7) + val_136); -} - - -int -_qsfp_get_comp_fc_trans_media(struct transvr_obj_s *self) { - /* transvr_comp[1] = address 00h / 132 - * - * 137 7: Twin Axial Pair (TW) - * 137 6: Shielded Twisted Pair (TP) - * 137 5: Miniature Coax (MI) - * 137 4: Video Coax (TV) - * 137 3: Multi-mode 62.5 m (M6) - * 137 2: Multi-mode 50 m (M5) - * 137 1: Multi-mode 50 um (OM3) - * 137 0: Single Mode (SM) - */ - return __qsfp_get_comp_attr(self, 6); -} - - -int -_qsfp_get_comp_fc_speed(struct transvr_obj_s *self) { - /* transvr_comp[1] = address 00h / 132 - * - * 138 7: 1200 MBps (per channel) - * 138 6: 800 MBps - * 138 5: 1600 MBps (per channel) - * 138 4: 400 MBps - * 138 3: 3200 MBps (per channel) - * 138 2: 200 MBps - * 138 1: Extended: See section 6.3.23. The Extended Specification - * Compliance Codes are maintained in the Transceiver Management - * section of SFF-8024. - * 138 0: 100 MBps - */ - return __qsfp_get_comp_attr(self, 7); -} - - -int -_qsfp_get_comp_extended(struct transvr_obj_s *self) { - /* Address: 00h / 192 - * Reference: SFF-8024 TABLE 4-4 - */ - if ((self->state == STATE_TRANSVR_CONNECTED) || - (self->state == STATE_TRANSVR_INIT) ) { - return (int)(self->transvr_comp_ext); - } - return ERR_TRANSVR_ABNORMAL; -} - - -int -qsfp_get_comp_eth(struct transvr_obj_s *self){ - - int err_code = _check_by_mode(self, - &_common_update_attr_transvr_comp, - "qsfp_get_comp_eth"); - if (err_code < 0){ - return err_code; - } - return _qsfp_get_comp_ethernet(self); -} - - -int -qsfp_get_comp_10_40(struct transvr_obj_s *self) { - - int err_code = _check_by_mode(self, - &_common_update_attr_transvr_comp, - "qsfp_get_comp_10_40"); - if (err_code < 0){ - return err_code; - } - return _qsfp_get_comp_10_40_100_ethernet(self); -} - - -int -_qsfp_get_connector_type(struct transvr_obj_s *self) { - /* Address: 00h / 130 - * Reference: SFF-8024 TABLE 4-3 - */ - if ((self->state == STATE_TRANSVR_CONNECTED) || - (self->state == STATE_TRANSVR_INIT) ) { - return (int)(self->connector); - } - return ERR_TRANSVR_ABNORMAL; -} - - -int -qsfp_get_transvr_temp(struct transvr_obj_s *self, - char *buf_p) { - - int lmax = 8; - int err_code = DEBUG_TRANSVR_INT_VAL; - - err_code = _check_by_mode(self, - &_qsfp_update_attr_curr_temp, - "qsfp_get_transvr_temp"); - if (err_code < 0) { - return snprintf(buf_p, lmax, "%d\n", err_code); - } - if ((self->curr_temp[0]) == DEBUG_TRANSVR_HEX_VAL) { - return snprintf(buf_p, lmax, "%d\n", ERR_TRANSVR_UPDATE_FAIL); - } - return _common_count_temp(self->curr_temp[0], - self->curr_temp[1], - buf_p); -} - - -int -qsfp_get_transvr_voltage(struct transvr_obj_s *self, - char *buf_p) { - - int lmax = 8; - int err_code = DEBUG_TRANSVR_INT_VAL; - - err_code = _check_by_mode(self, - &_qsfp_update_attr_curr_voltage, - "qsfp_get_transvr_voltage"); - if (err_code < 0) { - return snprintf(buf_p, lmax, "%d\n", err_code); - } - if ((self->curr_voltage[0]) == DEBUG_TRANSVR_HEX_VAL) { - return snprintf(buf_p, lmax, "%d\n", ERR_TRANSVR_UPDATE_FAIL); - } - /* Return Unit: 1 Volt */ - return _common_count_voltage(self->curr_voltage[0], - self->curr_voltage[1], - buf_p); -} - - -int -qsfp_get_transvr_tx_eq(struct transvr_obj_s *self, - char *buf_p) { - - int limt = 8; - int err = DEBUG_TRANSVR_INT_VAL; - - err = _check_by_mode(self, - &_qsfp_update_attr_tx_eq, - "qsfp_get_transvr_tx_eq"); - if (err < 0) { - return snprintf(buf_p, limt, "%d\n", err); - } - if ((self->tx_eq[0]) == DEBUG_TRANSVR_HEX_VAL) { - return snprintf(buf_p, limt, "%d\n", ERR_TRANSVR_UPDATE_FAIL); - } - return snprintf(buf_p, limt, "0x%02x%02x\n", - self->tx_eq[0], self->tx_eq[1]); -} - - -int -qsfp_get_transvr_rx_am(struct transvr_obj_s *self, - char *buf_p) { - - int limt = 8; - int err = DEBUG_TRANSVR_INT_VAL; - - err = _check_by_mode(self, - &_qsfp_update_attr_rx_am, - "qsfp_get_transvr_rx_am"); - if (err < 0) { - return snprintf(buf_p, limt, "%d\n", err); - } - if ((self->rx_am[0]) == DEBUG_TRANSVR_HEX_VAL) { - return snprintf(buf_p, limt, "%d\n", ERR_TRANSVR_UPDATE_FAIL); - } - return snprintf(buf_p, limt, "0x%02x%02x\n", - self->rx_am[0], self->rx_am[1]); -} - - -int -qsfp_get_transvr_rx_em(struct transvr_obj_s *self, - char *buf_p) { - - int limt = 8; - int err = DEBUG_TRANSVR_INT_VAL; - - err = _check_by_mode(self, - &_qsfp_update_attr_rx_em, - "qsfp_get_transvr_rx_em"); - if (err < 0) { - return snprintf(buf_p, limt, "%d\n", err); - } - if ((self->rx_em[0]) == DEBUG_TRANSVR_HEX_VAL) { - return snprintf(buf_p, limt, "%d\n", ERR_TRANSVR_UPDATE_FAIL); - } - return snprintf(buf_p, limt, "0x%02x%02x\n", - self->rx_em[0], self->rx_em[1]); -} - - -int -_qsfp_get_channel_diag(uint8_t *data_array, - int (*count_func)(uint8_t high_byte, uint8_t low_byte, char *buf_p), - char *ch_name, - char *result_p) { - int i, high, low; - int len_max = 128; - char ch_buf[4][16] = { DEBUG_TRANSVR_STR_VAL, - DEBUG_TRANSVR_STR_VAL, - DEBUG_TRANSVR_STR_VAL, - DEBUG_TRANSVR_STR_VAL }; - - for (i=0; i<4; i++) { - high = (i*2); - low = ((i*2) + 1); - count_func(data_array[high], data_array[low], ch_buf[i]); - } - return snprintf(result_p, len_max, - "%s-%d:%s%s-%d:%s%s-%d:%s%s-%d:%s", - ch_name, 1, ch_buf[0], - ch_name, 2, ch_buf[1], - ch_name, 3, ch_buf[2], - ch_name, 4, ch_buf[3]); -} - - -int -qsfp_get_soft_rx_los(struct transvr_obj_s *self, - char *buf_p) { - - int lmax = 8; - int mask = 0x0f; /* Bit 0 ~ Bit 3 */ - int err_code = DEBUG_TRANSVR_INT_VAL; - - err_code = _check_by_mode(self, - &_qsfp_update_attr_soft_rx_los, - "qsfp_get_soft_rx_los"); - if (err_code < 0) { - return snprintf(buf_p, lmax, "%d\n", err_code); - } - return snprintf(buf_p, lmax, "0x%02x\n", (self->rx_los & mask)); -} - - -int -qsfp_get_soft_tx_disable(struct transvr_obj_s *self, - char *buf_p) { - - int lmax = 8; - int mask = 0x0f; /* Bit 0 ~ Bit 3 */ - int err_code = DEBUG_TRANSVR_INT_VAL; - - err_code = _check_by_mode(self, - &_qsfp_update_attr_soft_tx_disable, - "qsfp_get_soft_tx_disable"); - if (err_code < 0) { - return snprintf(buf_p, lmax, "%d\n", err_code); - } - return snprintf(buf_p, lmax, "0x%02x\n", (self->tx_disable & mask)); -} - - -int -qsfp_get_soft_tx_fault(struct transvr_obj_s *self, - char *buf_p) { - - int lmax = 8; - int mask = 0x0f; /* Bit 0 ~ Bit 3 */ - int err_code = DEBUG_TRANSVR_INT_VAL; - - err_code = _check_by_mode(self, - &_qsfp_update_attr_soft_tx_fault, - "qsfp_get_soft_tx_fault"); - if (err_code < 0) { - return snprintf(buf_p, lmax, "%d\n", err_code); - } - return snprintf(buf_p, lmax, "0x%02x\n", (self->tx_fault & mask)); -} - - -int -qsfp_get_auto_tx_disable(struct transvr_obj_s *self, - char *buf_p) { - - if (self->auto_tx_disable == VAL_TRANSVR_FUNCTION_DISABLE) { - return snprintf(buf_p, LEN_TRANSVR_S_STR, - "%d\n", ERR_TRANSVR_FUNC_DISABLE); - } - return snprintf(buf_p, LEN_TRANSVR_S_STR, - "0x%02x\n", self->auto_tx_disable); -} - - -int -qsfp_get_transvr_tx_bias(struct transvr_obj_s *self, - char *buf_p) { - - int lmax = 8; - int err_code = DEBUG_TRANSVR_INT_VAL; - char *ch_name = "TX"; - - err_code = _check_by_mode(self, - &_qsfp_update_attr_curr_tx_bias, - "qsfp_get_transvr_tx_bias"); - if (err_code < 0) { - return snprintf(buf_p, lmax, "%d\n", err_code); - } - if ((self->curr_tx_bias[0]) == DEBUG_TRANSVR_HEX_VAL) { - return snprintf(buf_p, lmax, "%d\n", ERR_TRANSVR_UPDATE_FAIL); - } - /* Return Unit: 1 mA */ - return _qsfp_get_channel_diag(self->curr_tx_bias, - _common_count_tx_bias, - ch_name, - buf_p); -} - - -int -qsfp_get_transvr_tx_power(struct transvr_obj_s *self, - char *buf_p) { - - int lmax = 8; - int err_code = DEBUG_TRANSVR_INT_VAL; - char *ch_name = "TX"; - - err_code = _check_by_mode(self, - &_qsfp_update_attr_curr_tx_power, - "qsfp_get_transvr_tx_power"); - if (err_code < 0) { - return snprintf(buf_p, lmax, "%d\n", err_code); - } - if ((self->curr_tx_power[0]) == DEBUG_TRANSVR_HEX_VAL) { - return snprintf(buf_p, lmax, "%d\n", ERR_TRANSVR_UPDATE_FAIL); - } - /* Return Unit: 1 mW */ - return _qsfp_get_channel_diag(self->curr_tx_power, - _common_count_tx_power, - ch_name, - buf_p); -} - - -int -qsfp_get_transvr_rx_power(struct transvr_obj_s *self, - char *buf_p) { - - int lmax = 8; - int err_code = DEBUG_TRANSVR_INT_VAL; - char *ch_name = "RX"; - - err_code = _check_by_mode(self, - &_qsfp_update_attr_curr_rx_power, - "qsfp_get_transvr_rx_power"); - if (err_code < 0) { - return snprintf(buf_p, lmax, "%d\n", err_code); - } - if ((self->curr_tx_power[0]) == DEBUG_TRANSVR_HEX_VAL) { - return snprintf(buf_p, lmax, "%d\n", ERR_TRANSVR_UPDATE_FAIL); - } - /* Return Unit: 1 mW */ - return _qsfp_get_channel_diag(self->curr_rx_power, - _common_count_rx_power, - ch_name, - buf_p); -} - - -int -qsfp_get_wavelength(struct transvr_obj_s *self, - char *buf_p) { - /* [Desc] Wavelength or Copper Cable Attenuation (SFF-8636) - * [Addr] 00h 186-187 - * [Note] - * For optical free side devices, this parameter identifies the nominal - * transmitter output wavelength at room temperature. This parameter is - * a 16-bit hex value with Byte 186 as high order byte and Byte 187 as - * low order byte. The laser wavelength is equal to the 16-bit integer value - * divided by 20 in nm (units of 0.05 nm). This resolution should be adequate - * to cover all relevant wavelengths yet provide enough resolution for all - * expected DWDM applications. For accurate representation of controlled - * wavelength applications, this value should represent the center of the - * guaranteed wavelength range. - * If the free side device is identified as copper cable these registers will - * be used to define the cable attenuation. An indication of 0 dB attenuation - * refers to the case where the attenuation is not known or is unavailable. - * Byte 186 (00-FFh) is the copper cable attenuation at 2.5 GHz in units of 1 dB. - * Byte 187 (00-FFh) is the copper cable attenuation at 5.0 GHz in units of 1 dB. - */ - int lmax = 8; - int err_code = DEBUG_TRANSVR_INT_VAL; - - err_code = _check_by_mode(self, - &_common_update_attr_wavelength, - "common_get_wavelength"); - if (err_code < 0) { - return snprintf(buf_p, lmax, "%d\n", err_code); - } - if ((self->wavelength[0]) == DEBUG_TRANSVR_HEX_VAL) { - return snprintf(buf_p, lmax, "%d\n", ERR_TRANSVR_UPDATE_FAIL); - } - /* unit: 1 um */ - return snprintf(buf_p, lmax, "%d\n", - _common_count_wavelength(self, - self->wavelength[0], - self->wavelength[1])); -} - - -/* Public Function for Setup Features - */ -static int -__sfp_set_soft_rs(struct transvr_obj_s *self, - int input_val, - int address, - int page, - int offset, - int bit_shift, - uint8_t *attr_p, - char *caller, - int show_err) { - - int retval = ERR_TRANSVR_UNEXCPT; - int err_code = ERR_TRANSVR_UNEXCPT; - char *err_msg = DEBUG_TRANSVR_STR_VAL; - uint8_t update_val = (*attr_p); - - switch (input_val) { - case 0: - SWP_BIT_CLEAR(update_val, bit_shift); - break; - case 1: - SWP_BIT_SET(update_val, bit_shift); - break; - default: - retval = ERR_TRANSVR_UNEXCPT; - err_code = ERR_TRANSVR_UNEXCPT; - err_msg = "Exception occurs"; - goto err_private_sfp_set_soft_rs_1; - } - err_code = _common_set_uint8_attr(self, - address, - page, - offset, - update_val, - attr_p, - caller, - show_err); - if (err_code < 0) { - retval = err_code; - err_msg = "Write data via i2c fail!"; - goto err_private_sfp_set_soft_rs_1; - } - (*attr_p) = update_val; - return 0; - -err_private_sfp_set_soft_rs_1: - if (show_err) { - SWPS_INFO("%s: %s :%d :%s\n :%d\n", - __func__, err_msg, err_code, self->swp_name, input_val); - } - return retval; -} - - -static int -_sfp_set_soft_rs(struct transvr_obj_s *self, - int input_val, - int address, - int page, - int offset, - int bit_shift, - int (*attr_update_func)(struct transvr_obj_s *self, int show_err), - uint8_t *attr_p, - char *caller, - int show_err) { - - int retval = ERR_TRANSVR_UNEXCPT; - int err_code = ERR_TRANSVR_UNEXCPT; - char *err_msg = DEBUG_TRANSVR_STR_VAL; - - /* Check input value */ - if ((input_val != 0) && (input_val != 1)){ - retval = ERR_TRANSVR_BADINPUT; - err_code = ERR_TRANSVR_BADINPUT; - err_msg = "Input range incorrect!"; - goto err_common_sfp_set_soft_rs_1; - } - /* Check rate identifier is supported */ - err_code = self->get_rate_id(self); - if (err_code <= 0) { - switch (err_code) { - case 0: - retval = ERR_TRANSVR_NOTSUPPORT; - err_msg = "Not support this feature"; - break; - case ERR_TRANSVR_UNINIT: - retval = ERR_TRANSVR_UNINIT; - err_msg = "Check CDR present fail!"; - break; - case ERR_TRANSVR_UNPLUGGED: - retval = ERR_TRANSVR_UNPLUGGED; - err_msg = "Transceiver unplugged!"; - break; - default: - retval = err_code; - err_msg = "Check Rate_ID fail!"; - break; - } - goto err_common_sfp_set_soft_rs_1; - } - /* Check and update */ - err_code = _check_by_mode(self, - attr_update_func, - caller); - if ( (err_code < 0) || - ((*attr_p) == DEBUG_TRANSVR_HEX_VAL) ){ - retval = err_code; - err_msg = "Get current value fail!"; - goto err_common_sfp_set_soft_rs_1; - } - /* Generate and update value */ - return __sfp_set_soft_rs(self, - input_val, - address, - page, - offset, - bit_shift, - attr_p, - caller, - show_err); - -err_common_sfp_set_soft_rs_1: - if (show_err) { - SWPS_INFO("%s: %s :%d :%s\n :%d\n", - __func__, err_msg, err_code, self->swp_name, input_val); - } - return retval; -} - - -int -sfp_set_soft_rs0(struct transvr_obj_s *self, - int input_val) { - /* Note: - * SFP Soft Rate_Select Select RX ["RS(0)"] address - * A2h, offset: 110, bit 3 - */ - int bit_shift = 3; - int show_err = 1; - return _sfp_set_soft_rs(self, - input_val, - self->eeprom_map_p->addr_soft_rs0, - self->eeprom_map_p->page_soft_rs0, - self->eeprom_map_p->offset_soft_rs0, - bit_shift, - &_sfp_update_attr_soft_rs0, - &(self->soft_rs0), - "sfp_set_soft_rs0", - show_err); -} - - -int -sfp_set_soft_rs1(struct transvr_obj_s *self, - int input_val) { - /* Note: - * SFP Soft Rate_Select Select RX ["RS(1)"] address - * A2h, offset: 118, bit 3 - */ - int bit_shift = 3; - int show_err = 1; - return _sfp_set_soft_rs(self, - input_val, - self->eeprom_map_p->addr_soft_rs1, - self->eeprom_map_p->page_soft_rs1, - self->eeprom_map_p->offset_soft_rs1, - bit_shift, - &_sfp_update_attr_soft_rs1, - &(self->soft_rs1), - "sfp_set_soft_rs1", - show_err); -} - - -int -__sfp_set_tx_eq(struct transvr_obj_s *self, - int input, - int show_e) { - - int err = DEBUG_TRANSVR_INT_VAL; - char *emsg = DEBUG_TRANSVR_STR_VAL; - uint8_t setv = DEBUG_TRANSVR_HEX_VAL; - - if ((input < 0) || (input > 0xFF)) { - emsg = "input incorrect"; - err = ERR_TRANSVR_BADINPUT; - goto err_sfp_set_tx_eq; - } - setv = (uint8_t)input; - if (self->tx_eq[0] == setv) { - return 0; - } - err = _common_set_uint8_attr(self, - self->eeprom_map_p->addr_tx_eq, - self->eeprom_map_p->page_tx_eq, - self->eeprom_map_p->offset_tx_eq, - setv, - &(self->tx_eq[0]), - "_sfp_set_tx_eq", - show_e); - if (err < 0) { - emsg = "set_uint8_attr fail"; - goto err_sfp_set_tx_eq; - } - return 0; - -err_sfp_set_tx_eq: - if (show_e) { - SWPS_INFO("%s: %s :%d\n", __func__, emsg, input); - } - return err; -} - - -int -_sfp_set_tx_eq(struct transvr_obj_s *self, - int input, - int show_e) { - - uint8_t tmp; - int i = 0; - int retry = 3; - - for (i=0; itx_eq[0]; - if (_sfp_update_attr_tx_eq(self, show_e) < 0){ - continue; - } - if (self->tx_eq[0] == tmp){ - return 0; - } - } - return ERR_TRANSVR_UPDATE_FAIL; -} - - -int -sfp_set_tx_eq(struct transvr_obj_s *self, - int input) { - - int err = _check_by_mode(self, - &_sfp_update_attr_tx_eq, - "sfp_set_tx_eq"); - if (err < 0) { - SWPS_DEBUG("%s: check fail :%d\n", __func__, err); - return err; - } - return _sfp_set_tx_eq(self, input, 1); -} - - -int -__sfp_set_rx_em(struct transvr_obj_s *self, - int input, - int show_e) { - - int err = DEBUG_TRANSVR_INT_VAL; - char *emsg = DEBUG_TRANSVR_STR_VAL; - uint8_t setv = DEBUG_TRANSVR_HEX_VAL; - - if ((input < 0) || (input > 0xFF)) { - emsg = "input incorrect"; - err = ERR_TRANSVR_BADINPUT; - goto err_sfp_set_rx_em; - } - setv = (uint8_t)input; - if (self->rx_em[0] == setv) { - return 0; - } - err = _common_set_uint8_attr(self, - self->eeprom_map_p->addr_rx_em, - self->eeprom_map_p->page_rx_em, - self->eeprom_map_p->offset_rx_em, - setv, - &(self->rx_em[0]), - "_sfp_set_rx_em", - show_e); - if (err < 0) { - emsg = "set_uint8_attr fail"; - goto err_sfp_set_rx_em; - } - return 0; - -err_sfp_set_rx_em: - if (show_e) { - SWPS_INFO("%s: %s :%d\n", __func__, emsg, input); - } - return err; -} - - -int -_sfp_set_rx_em(struct transvr_obj_s *self, - int input, - int show_e) { - - uint8_t tmp; - int i = 0; - int retry = 3; - - for (i=0; irx_em[0]; - if (_sfp_update_attr_rx_em(self, show_e) < 0){ - continue; - } - if (self->rx_em[0] == tmp){ - return 0; - } - } - return -1; -} - - -int -sfp_set_rx_em(struct transvr_obj_s *self, - int input) { - - int err = _check_by_mode(self, - &_sfp_update_attr_rx_em, - "sfp_set_rx_em"); - if (err < 0) { - SWPS_DEBUG("%s: check fail :%d\n", __func__, err); - return err; - } - return _sfp_set_rx_em(self, input, 1); -} - - -static int -__qsfp_set_cdr(struct transvr_obj_s *self, - int input_val, - int show_err) { - - uint8_t update_val; - int CDR_FEATURE_SUPPORTED = 0x3; - int retval = ERR_TRANSVR_UNEXCPT; - int err_code = ERR_TRANSVR_UNEXCPT; - char *err_msg = DEBUG_TRANSVR_STR_VAL; - char *func_name = "__qsfp_set_cdr"; - - /* Check input value */ - if ((input_val < 0) || (input_val > 0xff)){ - retval = ERR_TRANSVR_BADINPUT; - err_code = ERR_TRANSVR_BADINPUT; - err_msg = "Input range incorrect!"; - goto err_qsfp_set_cdr_1; - } - update_val = (uint8_t)input_val; - /* Check CDR supported by transceiver */ - err_code = qsfp_get_cdr_present(self); - if (err_code < 0) { - retval = err_code; - switch (err_code) { - case ERR_TRANSVR_UNINIT: - err_msg = "Check CDR present fail!"; - break; - case ERR_TRANSVR_UNPLUGGED: - err_msg = "Transceiver unplugged!"; - break; - default: - err_msg = "Check CDR present fail!"; - break; - } - goto err_qsfp_set_cdr_1; - } - if (err_code != CDR_FEATURE_SUPPORTED) { - retval = ERR_TRANSVR_NOTSUPPORT; - err_msg = "This transceiver not support CDR!"; - goto err_qsfp_set_cdr_1; - } - /* Check and update */ - err_code = _check_by_mode(self, - &_qsfp_update_attr_cdr, - func_name); - if ( (err_code < 0) || - (self->cdr == DEBUG_TRANSVR_HEX_VAL) ){ - retval = err_code; - err_msg = "Get current value fail!"; - goto err_qsfp_set_cdr_1; - } - /* Write input value to transceiver */ - return _common_set_uint8_attr(self, - self->eeprom_map_p->addr_cdr, - self->eeprom_map_p->page_cdr, - self->eeprom_map_p->offset_cdr, - update_val, - &(self->cdr), - func_name, - show_err); - -err_qsfp_set_cdr_1: - if (show_err) { - SWPS_INFO("%s: %s :%d :%s\n :%d\n", - __func__, err_msg, err_code, self->swp_name, input_val); - } - return retval; -} - - -int -qsfp_set_cdr(struct transvr_obj_s *self, - int input_val) { - return __qsfp_set_cdr(self, input_val, 1); -} - - -int -qsfp_set_soft_tx_disable(struct transvr_obj_s *self, - int input_val) { - - int show_err = 1; - int in_max = 0xf; /* 1111 */ - int in_min = 0x0; /* 0000 */ - int retval = DEBUG_TRANSVR_INT_VAL; - int update_val = DEBUG_TRANSVR_INT_VAL; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - - retval = _check_by_mode(self, - &_qsfp_update_attr_soft_tx_disable, - "qsfp_set_soft_tx_disable"); - if (retval < 0) { - snprintf(err_msg, 63, "Not ready. err:%d", retval); - goto err_qsfp_set_soft_tx_disable; - } - if ((input_val > in_max) || - (input_val < in_min) ){ - retval = ERR_TRANSVR_BADINPUT; - snprintf(err_msg, 63, "Input value:%d incorrect!", input_val); - goto err_qsfp_set_soft_tx_disable; - } - if ((self->tx_disable & 0x0f) == input_val) { - return 0; - } - update_val = ((self->tx_disable & 0xf0) & input_val); - retval = _common_set_uint8_attr(self, - self->eeprom_map_p->addr_tx_disable, - self->eeprom_map_p->page_tx_disable, - self->eeprom_map_p->offset_tx_disable, - input_val, - &(self->tx_disable), - "qsfp_set_tx_disable", - show_err); - if (retval < 0) { - snprintf(err_msg, 63, "_common_set_uint8_attr:%d fail!", retval); - goto err_qsfp_set_soft_tx_disable; - } - return 0; - -err_qsfp_set_soft_tx_disable: - SWPS_INFO("%s: %s :%s\n", __func__, err_msg, self->swp_name); - return retval; -} - - -int -_qsfp_set_auto_tx_disable(struct transvr_obj_s *self, - uint8_t update) { - - uint8_t tx_enable = 0x0; - int show_e = 1; - int err = DEBUG_TRANSVR_INT_VAL; - char *emsg = DEBUG_TRANSVR_STR_VAL; - - /* Handle timing issues */ - if (update != tx_enable) { - /* Note: - * Because there are some txvr has timing issues, - * therefore we need to execute reset cycle first. - * (enable -> other settings) - */ - err = _common_set_uint8_attr(self, - self->eeprom_map_p->addr_tx_disable, - self->eeprom_map_p->page_tx_disable, - self->eeprom_map_p->offset_tx_disable, - tx_enable, - &(self->tx_disable), - "_qsfp_set_auto_tx_disable", - show_e); - if (err < 0) { - emsg = "I2C set reset value fail"; - goto err_qsfp_set_auto_tx_disable; - } - mdelay(10); - } - /* Setup target value */ - err = _common_set_uint8_attr(self, - self->eeprom_map_p->addr_tx_disable, - self->eeprom_map_p->page_tx_disable, - self->eeprom_map_p->offset_tx_disable, - self->auto_tx_disable, - &(self->tx_disable), - "_qsfp_set_auto_tx_disable", - show_e); - if (err < 0) { - emsg = "I2C set target value fail"; - goto err_qsfp_set_auto_tx_disable; - } - /* Check and update */ - err = _common_update_uint8_attr(self, - self->eeprom_map_p->addr_tx_disable, - self->eeprom_map_p->page_tx_disable, - self->eeprom_map_p->offset_tx_disable, - self->eeprom_map_p->length_tx_disable, - &(self->tx_disable), - "_qsfp_set_auto_tx_disable", - show_e); - if (err < 0) { - emsg = "I2C get value fail"; - goto err_qsfp_set_auto_tx_disable; - } - if (self->tx_disable != update) { - emsg = "data not become effective"; - goto err_qsfp_set_auto_tx_disable; - } - return 0; - -err_qsfp_set_auto_tx_disable: - SWPS_DEBUG("%s: %s :%s\n", - __func__, emsg, self->swp_name); - return ERR_TRANSVR_UPDATE_FAIL; -} - - -int -qsfp_set_auto_tx_disable(struct transvr_obj_s *self, - int input_val) { - - int in_max = 0xf; /* 1111 */ - int in_min = 0x0; /* 0000 */ - int retval = DEBUG_TRANSVR_INT_VAL; - char *emsg = DEBUG_TRANSVR_STR_VAL; - - /* Update settings*/ - if (input_val == VAL_TRANSVR_FUNCTION_DISABLE) { - emsg = "User disable auto tx_disable"; - self->auto_tx_disable = VAL_TRANSVR_FUNCTION_DISABLE; - goto out_qsfp_set_auto_tx_disable; - } - if ((input_val > in_max) || (input_val < in_min) ){ - SWPS_INFO("%s: Input value:%d incorrect! :%s\n", - __func__, input_val, self->swp_name); - return ERR_TRANSVR_BADINPUT; - } - self->auto_tx_disable = input_val; - /* Check current soft tx_disable */ - retval = _check_by_mode(self, - &_qsfp_update_attr_soft_tx_disable, - "qsfp_set_auto_tx_disable"); - switch (retval) { - case 0: - break; - case ERR_TRANSVR_UNPLUGGED: - emsg = "Doesn't need to update"; - goto out_qsfp_set_auto_tx_disable; - default: - SWPS_INFO("%s: setup fail :%d :%s\n", - __func__, retval, self->swp_name); - return retval; - } - return _qsfp_set_auto_tx_disable(self, input_val); - -out_qsfp_set_auto_tx_disable: - SWPS_DEBUG("%s: %s :%s :%d\n :%d", - __func__, emsg, self->swp_name, input_val, retval); - return 0; -} - - -int -__qsfp_set_tx_eq(struct transvr_obj_s *self, - int input, - int show_e) { - /* [Note] - * 0x - */ - int err = DEBUG_TRANSVR_INT_VAL; - char *emsg = DEBUG_TRANSVR_STR_VAL; - uint8_t setv[2] = {0x00, 0x00}; - - if ((input < 0) || (input > 0xFFFF)) { - emsg = "input incorrect"; - err = ERR_TRANSVR_BADINPUT; - goto err_qsfp_set_tx_eq; - } - setv[0] = (uint8_t)((input & 0xFF00) >> 8); - setv[1] = (uint8_t)(input & 0xFF); - if ((self->tx_eq[0] == setv[0]) && - (self->tx_eq[1] == setv[1]) ) { - return 0; - } - err = _common_set_uint8_array(self, - self->eeprom_map_p->addr_tx_eq, - self->eeprom_map_p->page_tx_eq, - self->eeprom_map_p->offset_tx_eq, - self->eeprom_map_p->length_tx_eq, - setv, - self->tx_eq, - "_qsfp_set_tx_eq", - show_e); - if (err < 0) { - emsg = "set_uint8_array fail"; - goto err_qsfp_set_tx_eq; - } - return 0; - -err_qsfp_set_tx_eq: - if (show_e) { - SWPS_INFO("%s: %s :%d\n", __func__, emsg, input); - } - return err; -} - - -int -_qsfp_set_tx_eq(struct transvr_obj_s *self, - int input, - int show_e) { - - int i = 0; - int retry = 3; - uint8_t tmp[2]; - - for (i=0; itx_eq[0]; - tmp[1] = self->tx_eq[1]; - if (_qsfp_update_attr_tx_eq(self, show_e) < 0){ - continue; - } - if ((self->tx_eq[0] == tmp[0]) && - (self->tx_eq[1] == tmp[1]) ){ - return 0; - } - } - return -1; -} - - -int -qsfp_set_tx_eq(struct transvr_obj_s *self, - int input) { - - int err = _check_by_mode(self, - &_qsfp_update_attr_tx_eq, - "qsfp_set_tx_eq"); - if (err < 0) { - SWPS_DEBUG("%s: check fail :%d\n", __func__, err); - return err; - } - return _qsfp_set_tx_eq(self, input, 1); -} - - -int -__qsfp_set_rx_am(struct transvr_obj_s *self, - int input, - int show_e) { - /* [Note] - * 0x - */ - int err = DEBUG_TRANSVR_INT_VAL; - char *emsg = DEBUG_TRANSVR_STR_VAL; - uint8_t setv[2] = {0x00, 0x00}; - - if ((input < 0) || (input > 0xFFFF)) { - emsg = "input incorrect"; - err = ERR_TRANSVR_BADINPUT; - goto err_qsfp_set_rx_am; - } - setv[0] = (uint8_t)((input & 0xFF00) >> 8); - setv[1] = (uint8_t)(input & 0xFF); - if ((self->rx_am[0] == setv[0]) && - (self->rx_am[1] == setv[1]) ) { - return 0; - } - err = _common_set_uint8_array(self, - self->eeprom_map_p->addr_rx_am, - self->eeprom_map_p->page_rx_am, - self->eeprom_map_p->offset_rx_am, - self->eeprom_map_p->length_rx_am, - setv, - self->rx_am, - "_qsfp_set_rx_am", - show_e); - if (err < 0) { - emsg = "set_uint8_array fail"; - goto err_qsfp_set_rx_am; - } - return 0; - -err_qsfp_set_rx_am: - if (show_e) { - SWPS_INFO("%s: %s :%d\n", __func__, emsg, input); - } - return err; -} - - -int -_qsfp_set_rx_am(struct transvr_obj_s *self, - int input, - int show_e) { - - int i = 0; - int retry = 3; - uint8_t tmp[2]; - - for (i=0; irx_am[0]; - tmp[1] = self->rx_am[1]; - if (_qsfp_update_attr_rx_am(self, show_e) < 0){ - continue; - } - if ((self->rx_am[0] == tmp[0]) && - (self->rx_am[1] == tmp[1]) ){ - return 0; - } - } - return -1; -} - - -int -qsfp_set_rx_am(struct transvr_obj_s *self, - int input) { - - int err = _check_by_mode(self, - &_qsfp_update_attr_rx_am, - "qsfp_set_rx_am"); - if (err < 0) { - SWPS_DEBUG("%s: check fail :%d\n", __func__, err); - return err; - } - return _qsfp_set_rx_am(self, input, 1); -} - - -int -__qsfp_set_rx_em(struct transvr_obj_s *self, - int input, - int show_e) { - /* [Note] - * 0x - */ - int err = DEBUG_TRANSVR_INT_VAL; - char *emsg = DEBUG_TRANSVR_STR_VAL; - uint8_t setv[2] = {0x00, 0x00}; - - if ((input < 0) || (input > 0xFFFF)) { - emsg = "input incorrect"; - err = ERR_TRANSVR_BADINPUT; - goto err_qsfp_set_rx_em; - } - setv[0] = (uint8_t)((input & 0xFF00) >> 8); - setv[1] = (uint8_t)(input & 0xFF); - if ((self->rx_em[0] == setv[0]) && - (self->rx_em[1] == setv[1]) ) { - return 0; - } - err = _common_set_uint8_array(self, - self->eeprom_map_p->addr_rx_em, - self->eeprom_map_p->page_rx_em, - self->eeprom_map_p->offset_rx_em, - self->eeprom_map_p->length_rx_em, - setv, - self->rx_em, - "_qsfp_set_rx_em", - show_e); - if (err < 0) { - emsg = "set_uint8_array fail"; - goto err_qsfp_set_rx_em; - } - return 0; - -err_qsfp_set_rx_em: - if (show_e) { - SWPS_INFO("%s: %s :%d\n", __func__, emsg, input); - } - return err; -} - - -int -_qsfp_set_rx_em(struct transvr_obj_s *self, - int input, - int show_e) { - - int i = 0; - int retry = 3; - uint8_t tmp[2]; - - for (i=0; irx_em[0]; - tmp[1] = self->rx_em[1]; - if (_qsfp_update_attr_rx_em(self, show_e) < 0){ - continue; - } - if ((self->rx_em[0] == tmp[0]) && - (self->rx_em[1] == tmp[1]) ){ - return 0; - } - } - return -1; -} - - -int -qsfp_set_rx_em(struct transvr_obj_s *self, - int input) { - - int err = _check_by_mode(self, - &_qsfp_update_attr_rx_em, - "qsfp_set_rx_em"); - if (err < 0) { - SWPS_DEBUG("%s: check fail :%d\n", __func__, err); - return err; - } - return _qsfp_set_rx_em(self, input, 1); -} - - -int -common_transvr_dump(struct transvr_obj_s* self){ - - char *type_name = "Undefined"; - - if (TRANSVR_INFO_DUMP_ENABLE != 1) { - return 0; - } - switch (self->type) { - case TRANSVR_TYPE_SFP: - type_name = STR_TRANSVR_SFP; - break; - case TRANSVR_TYPE_QSFP: - type_name = STR_TRANSVR_QSFP; - break; - case TRANSVR_TYPE_QSFP_PLUS: - type_name = STR_TRANSVR_QSFP_PLUS; - break; - case TRANSVR_TYPE_QSFP_28: - type_name = STR_TRANSVR_QSFP28; - break; - case TRANSVR_TYPE_FAKE: - type_name = "FAKE"; - goto ok_common_transvr_dump; - case TRANSVR_TYPE_UNPLUGGED: - type_name = "UNPLUGGED"; - goto err_common_transvr_dump; - case TRANSVR_TYPE_INCONSISTENT: - type_name = "INCONSISTENT"; - goto err_common_transvr_dump; - case TRANSVR_TYPE_ERROR: - type_name = "ERROR"; - goto err_common_transvr_dump; - - default: - type_name = "UNEXPECTED"; - goto err_common_transvr_dump; - } - printk(KERN_INFO "[SWPS] Dump %s information:\n", self->swp_name); - printk(KERN_INFO " |- :%s\n", type_name); - printk(KERN_INFO " |- :%s\n", self->vendor_name); - printk(KERN_INFO " |- :%s\n", self->vendor_pn); - printk(KERN_INFO " |- :%s\n", self->vendor_rev); - printk(KERN_INFO " |- :%s\n", self->vendor_sn); - printk(KERN_INFO " |- :0x%02x\n", self->br); - printk(KERN_INFO " |- :0x%02x\n", self->comp_rev); - printk(KERN_INFO " |- :%d\n", self->len_om1); - printk(KERN_INFO " |- :%d\n", self->len_om2); - printk(KERN_INFO " |- :%d\n", self->len_om3); - printk(KERN_INFO " |- :%d\n", self->len_om4); - return 0; - -ok_common_transvr_dump: - SWPS_INFO("%s: %s is %s\n", __func__, self->swp_name, type_name); - return 0; - -err_common_transvr_dump: - SWPS_INFO("%s: %s is %s\n", __func__, self->swp_name, type_name); - return -1; -} - - -int -sfp_transvr_dump(struct transvr_obj_s* self) { - - if (TRANSVR_INFO_DUMP_ENABLE != 1) { - return 0; - } - if (common_transvr_dump(self) < 0) { - return -1; - } - printk(KERN_INFO " |- :%d\n", self->len_sm); - printk(KERN_INFO " |- :%d\n", self->len_smf); - printk(KERN_INFO " '- :0x%02x\n", self->rate_id); - return 0; -} - - -int -qsfp_transvr_dump(struct transvr_obj_s* self) { - - if (TRANSVR_INFO_DUMP_ENABLE != 1) { - return 0; - } - if (common_transvr_dump(self) < 0) { - return -1; - } - printk(KERN_INFO " |- :%d\n", self->len_smf); - printk(KERN_INFO " '- :Class_%d\n", __qsfp_get_power_cls(self, 0)); - return 0; -} - - -int -fake_transvr_dump(struct transvr_obj_s* self) { - - printk(KERN_INFO "[SWPS] Dump transceiver information: %s\n", self->swp_name); - printk(KERN_INFO " |- :FAKE\n"); - printk(KERN_INFO " |- :FAKE_VENDER_NAME\n"); - printk(KERN_INFO " |- :FAKE_VENDER_PN\n"); - printk(KERN_INFO " |- :FAKE_VENDER_REV\n"); - printk(KERN_INFO " |- :FAKE_VENDER_SN\n"); - printk(KERN_INFO " |- :0x99\n"); - printk(KERN_INFO " |- :99\n"); - printk(KERN_INFO " |- :99\n"); - printk(KERN_INFO " |- :99\n"); - printk(KERN_INFO " |- :99\n"); - printk(KERN_INFO " |- :99\n"); - printk(KERN_INFO " |- :99\n"); - printk(KERN_INFO " '- :0x99\n"); - return 0; -} - - -/* ========== Object functions for fake type ========== - */ -int -fake_transvr_update(struct transvr_obj_s *self, - int show_err){ - self->state = STATE_TRANSVR_CONNECTED; - return 0; -} - - -int -fake_get_binary(struct transvr_obj_s *self){ - return 1; -} - -int -fake_get_int(struct transvr_obj_s *self){ - return 99; -} - - -int -fake_get_hex(struct transvr_obj_s *self){ - return 0x0f; -} - - -int -fake_get_str(struct transvr_obj_s *self, char *buf) { - return snprintf(buf, 16, "fake_get_str\n"); -} - - -int -fake_set_int(struct transvr_obj_s *self, int input){ - SWPS_INFO("%s: %d\n", __func__, input); - return 0; -} - - -int -fake_set_hex(struct transvr_obj_s *self, int input){ - SWPS_INFO("%s: 0x%02x\n", __func__, input); - return 0; -} - - -/* ========== Object functions for unsupported ========== - */ -int -unsupported_get_func(struct transvr_obj_s *self){ - return ERR_TRANSVR_NOTSUPPORT; -} - - -int -unsupported_get_func2(struct transvr_obj_s *self, - char *buf_p) { - int len = snprintf(buf_p, 8, "%d\n", ERR_TRANSVR_NOTSUPPORT); - return len; -} - - -int -unsupported_set_func(struct transvr_obj_s *self, - int input_val){ - return ERR_TRANSVR_NOTSUPPORT; -} - - - -/* ========== Object functions for long term task ========== - * - * [Note] - * SWPS transceiver worker is likely the green-thread (coroutine). - * Due to resource and performance considerations. SWPS run all - * features in one kthread at the same time, and handle by it self. - */ - -/* For Transceiver Task Handling - */ -static struct transvr_worker_s * -transvr_task_get(struct transvr_obj_s *self, - char *func_name) { - - struct transvr_worker_s *curr_p = self->worker_p; - - while(curr_p != NULL){ - if (strcmp((curr_p->func_name), func_name) == 0 ) { - return curr_p; - } - curr_p = curr_p->next_p; - } - return NULL; -} - - -static struct transvr_worker_s* -transvr_task_creat(struct transvr_obj_s *self, - int (*main_task)(struct transvr_worker_s *task), - int (*post_task)(struct transvr_worker_s *task), - char *caller) { - - struct transvr_worker_s *task_p = NULL; - struct transvr_worker_s *curr_p = NULL; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - - /* Check task not exist */ - task_p = transvr_task_get(self, caller); - if (task_p) { - snprintf(err_msg, sizeof(err_msg), "Task already created!"); - goto err_transvr_task_creat; - } - /* Create task worker */ - task_p = kzalloc(sizeof(struct transvr_worker_s), GFP_KERNEL); - if (!task_p){ - snprintf(err_msg, sizeof(err_msg), "kzalloc fail"); - goto err_transvr_task_creat; - } - /* Setup task data */ - task_p->transvr_p = self; - task_p->next_p = NULL; - task_p->trigger_time = 0; - task_p->retry = 1; - task_p->state = STATE_T_TASK_INIT; - task_p->main_task = main_task; - task_p->post_task = post_task; - task_p->p_data = NULL; - snprintf(task_p->func_name, sizeof(task_p->func_name), "%s", caller); - /* Setup Link List */ - if (self->worker_p) { - curr_p = self->worker_p; - while(curr_p->next_p != NULL) { - curr_p = curr_p->next_p; - } - curr_p->next_p = task_p; - task_p->pre_p = curr_p; - } else { - self->worker_p = task_p; - task_p->pre_p = NULL; - } - return task_p; - -err_transvr_task_creat: - SWPS_ERR("%s: %s :%s :%s\n", - __func__, err_msg, caller, self->swp_name); - return NULL; -} - - -static void -transvr_task_free_one(struct transvr_worker_s *task_p){ - - struct transvr_worker_s *pre_p = NULL; - struct transvr_worker_s *next_p = NULL; - - if (task_p) { - pre_p = task_p->pre_p; - next_p = task_p->next_p; - - if ((pre_p) && (next_p)) { - pre_p->next_p = next_p; - next_p->pre_p = pre_p; - - } else if ((!pre_p) && (next_p)) { - next_p->pre_p = NULL; - - } else if ((pre_p) && (!next_p)) { - pre_p->next_p = NULL; - - } else if ((!pre_p) && (!next_p)) { - task_p->transvr_p->worker_p = NULL; - } else { - SWPS_ERR("%s: Unexcept case!\n :%s", - __func__, task_p->transvr_p->swp_name); - } - kfree(task_p->p_data); - kfree(task_p); - } -} - - -static void -transvr_task_free_all(struct transvr_obj_s *self) { - - struct transvr_worker_s *curr_p = NULL; - struct transvr_worker_s *next_p = NULL; - - if (self->worker_p) { - curr_p = self->worker_p; - while(curr_p) { - next_p = curr_p->next_p; - transvr_task_free_one(curr_p); - curr_p = next_p; - } - self->worker_p = NULL; - } -} - - -static int -_transvr_task_run_main(struct transvr_worker_s *task_p) { - - int retval = DEBUG_TRANSVR_INT_VAL; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - - if (!task_p){ - snprintf(err_msg, sizeof(err_msg), "main_task is NULL!"); - goto main_transvr_task_err; - } - if ((task_p->trigger_time) == 0){ - goto main_transvr_task_run; - } - if (time_before(jiffies, task_p->trigger_time)){ - goto main_transvr_task_wait; - } - goto main_transvr_task_run; - -main_transvr_task_run: - if (task_p->retry != VAL_TRANSVR_TASK_RETRY_FOREVER) { - task_p->retry -= 1; - } - retval = task_p->main_task(task_p); - if (retval < 0) { - if (task_p->retry > 0) { - task_p->state = STATE_T_TASK_WAIT; - return EVENT_TRANSVR_TASK_WAIT; - } - snprintf(err_msg, sizeof(err_msg), "Run main_task fail!"); - goto main_transvr_task_err; - } - goto main_transvr_task_identify; - -main_transvr_task_identify: - switch (retval) { - case EVENT_TRANSVR_TASK_WAIT: - task_p->state = STATE_T_TASK_WAIT; - return EVENT_TRANSVR_TASK_WAIT; - - case EVENT_TRANSVR_TASK_DONE: - task_p->state = STATE_T_TASK_DONE; - return EVENT_TRANSVR_TASK_DONE; - - default: - break; - } - snprintf(err_msg, sizeof(err_msg), "Run main_task fail!"); - goto main_transvr_task_err; - -main_transvr_task_wait: - task_p->state = STATE_T_TASK_WAIT; - return EVENT_TRANSVR_TASK_WAIT; - -main_transvr_task_err: - task_p->state = STATE_T_TASK_FAIL; - SWPS_INFO("%s: %s :%d :%s\n", - __func__, err_msg, retval, task_p->transvr_p->swp_name); - return EVENT_TRANSVR_INIT_FAIL; -} - - -static int -_transvr_task_run_post(struct transvr_worker_s *task_p) { - - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - - if ((task_p->post_task) == NULL) { - return EVENT_TRANSVR_TASK_DONE; - } - switch (task_p->state) { - case STATE_T_TASK_WAIT: - case STATE_T_TASK_INIT: - goto post_transvr_task_wait; - - case STATE_T_TASK_DONE: - case STATE_T_TASK_FAIL: - goto post_transvr_task_run; - - default: - break; - } - snprintf(err_msg, sizeof(err_msg), "Unexcept task state"); - goto post_transvr_task_err; - -post_transvr_task_run: - task_p->post_task(task_p); - return EVENT_TRANSVR_TASK_DONE; - -post_transvr_task_wait: - return EVENT_TRANSVR_TASK_WAIT; - -post_transvr_task_err: - SWPS_INFO("%s: %s :%d :%s\n", - __func__, err_msg, task_p->state, task_p->transvr_p->swp_name); - return EVENT_TRANSVR_TASK_FAIL; -} - - -static int -transvr_task_run_one(struct transvr_worker_s *task_p) { - - int retval_main = DEBUG_TRANSVR_INT_VAL; - int retval_post = DEBUG_TRANSVR_INT_VAL; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - - retval_main = _transvr_task_run_main(task_p); - if (retval_main < 0) { - snprintf(err_msg, sizeof(err_msg), "Execute main_task fail!"); - goto err_transvr_task_run_one; - } - retval_post = _transvr_task_run_post(task_p); - if (retval_post < 0) { - snprintf(err_msg, sizeof(err_msg), "Execute post_task fail!"); - goto err_transvr_task_run_one; - } - return retval_main; - -err_transvr_task_run_one: - SWPS_INFO("%s: %s
:%d :%d :%s :%s\n", - __func__, err_msg, retval_main, retval_post, - task_p->func_name, task_p->transvr_p->swp_name); - return EVENT_TRANSVR_TASK_FAIL; -} - - -static int -transvr_task_run_all(struct transvr_obj_s *self) { - - int haserr = 0; - int retval = DEBUG_TRANSVR_INT_VAL; - struct transvr_worker_s *curr_p = NULL; - struct transvr_worker_s *next_p = NULL; - - if ((self->worker_p) == NULL) { - return EVENT_TRANSVR_TASK_DONE; - } - curr_p = self->worker_p; - while (curr_p != NULL) { - next_p = curr_p->next_p; - retval = transvr_task_run_one(curr_p); - if (curr_p->retry == VAL_TRANSVR_TASK_RETRY_FOREVER) { - curr_p = next_p; - continue; - } - switch (retval) { - case EVENT_TRANSVR_TASK_WAIT: - break; - case EVENT_TRANSVR_TASK_DONE: - transvr_task_free_one(curr_p); - break; - case EVENT_TRANSVR_TASK_FAIL: - - default: - haserr = 1; - transvr_task_free_one(curr_p); - break; - } - curr_p = next_p; - } - if (haserr) { - return EVENT_TRANSVR_TASK_FAIL; - } - return EVENT_TRANSVR_TASK_DONE; -} - - -static void -transvr_task_set_delay(struct transvr_worker_s *task_p, - unsigned long delay_msec) { - - task_p->trigger_time = (jiffies + (delay_msec * (HZ/1000))); -} - - -static void -transvr_task_set_retry(struct transvr_worker_s *task_p, - unsigned long retry_times) { - - task_p->retry = retry_times; -} - - -/* For Transceiver Post Task - */ -int -taskfunc_post_do_nothing(struct transvr_worker_s *task_p) { - - return EVENT_TRANSVR_TASK_DONE; -} - - -int -taskfunc_post_handle_task_state(struct transvr_worker_s *task_p) { - - struct transvr_obj_s* tp = task_p->transvr_p; - - switch (task_p->state) { - case STATE_T_TASK_INIT: - case STATE_T_TASK_WAIT: - return EVENT_TRANSVR_TASK_WAIT; - - case STATE_T_TASK_DONE: - tp->state = STATE_TRANSVR_CONNECTED; - tp->send_uevent(tp, KOBJ_ADD); - return EVENT_TRANSVR_TASK_DONE; - - case STATE_T_TASK_FAIL: - tp->state = STATE_TRANSVR_UNEXCEPTED; - return EVENT_TRANSVR_TASK_FAIL; - - default: - break; - } - return EVENT_TRANSVR_TASK_FAIL; -} - - -/* For Transceiver Main Task - */ -int -_taskfunc_sfp_setup_soft_rs(struct transvr_worker_s *task_p, - int input_val, - int address, - int page, - int offset, - int bit_shift, - uint8_t *attr_p, - char *caller) { - - int show_err = 0; - int err_code = DEBUG_TRANSVR_INT_VAL; - char *err_str = DEBUG_TRANSVR_STR_VAL; - char *func_str = "_taskfunc_sfp_setup_soft_rs"; - - err_code = _sfp_update_attr_soft_rs0(task_p->transvr_p, 0); - if (err_code < 0) { - err_str = "Get current soft_rs0 fail!"; - goto err_taskfunc_sfp_setup_soft_rs_1; - } - err_code = __sfp_set_soft_rs(task_p->transvr_p, - input_val, - address, - page, - offset, - bit_shift, - attr_p, - caller, - show_err); - if (err_code < 0) { - err_str = "Get current soft_rs0 fail!"; - goto err_taskfunc_sfp_setup_soft_rs_1; - } - return EVENT_TRANSVR_TASK_DONE; - -err_taskfunc_sfp_setup_soft_rs_1: - if ((task_p->retry) == 0) { - SWPS_INFO("%s: %s :%s :%d :%d\n", - func_str, err_str, task_p->transvr_p->swp_name, input_val, err_code); - } - return EVENT_TRANSVR_TASK_FAIL; -} - - -int -__taskfunc_sfp_setup_hard_rs(struct transvr_worker_s *task_p, - int input_val, - int (*get_func)(struct ioexp_obj_s *self, int virt_offset), - int (*set_func)(struct ioexp_obj_s *self, int virt_offset, int input_val)) { - - int err_val = EVENT_TRANSVR_EXCEP_EXCEP; - char *err_str = DEBUG_TRANSVR_STR_VAL; - - err_val = get_func(task_p->transvr_p->ioexp_obj_p, - task_p->transvr_p->ioexp_virt_offset); - - if (err_val < 0) { - if (err_val == ERR_IOEXP_NOTSUPPORT) { - return EVENT_TRANSVR_TASK_DONE; - } - err_str = "Get current hard_rs fail!"; - goto err_p_taskfunc_sfp_setup_hard_rs_1; - } - if (err_val == input_val) { - return EVENT_TRANSVR_TASK_DONE; - } - err_val = set_func(task_p->transvr_p->ioexp_obj_p, - task_p->transvr_p->ioexp_virt_offset, - input_val); - if (err_val < 0) { - err_str = "Setup hard_rs fail!"; - goto err_p_taskfunc_sfp_setup_hard_rs_1; - } - return EVENT_TRANSVR_TASK_DONE; - -err_p_taskfunc_sfp_setup_hard_rs_1: - if ((task_p->retry) == 0) { - SWPS_INFO("%s: %s :%s :%d :%d\n", - __func__, err_str, task_p->transvr_p->swp_name, input_val, err_val); - } - return EVENT_TRANSVR_TASK_FAIL; -} - - -int -_taskfunc_sfp_setup_hard_rs0(struct transvr_worker_s *task_p, - int input_val) { - - return __taskfunc_sfp_setup_hard_rs(task_p, - input_val, - task_p->transvr_p->ioexp_obj_p->get_hard_rs0, - task_p->transvr_p->ioexp_obj_p->set_hard_rs0); -} - - -int -_taskfunc_sfp_setup_hard_rs1(struct transvr_worker_s *task_p, - int input_val) { - - return __taskfunc_sfp_setup_hard_rs(task_p, - input_val, - task_p->transvr_p->ioexp_obj_p->get_hard_rs1, - task_p->transvr_p->ioexp_obj_p->set_hard_rs1); -} - - -int -_taskfunc_sfp_setup_rs0(struct transvr_worker_s *task_p, - int input_val) { - - int bit_shift = 3; - int old_val = DEBUG_TRANSVR_INT_VAL; - int err_val = EVENT_TRANSVR_EXCEP_EXCEP; - char *err_str = DEBUG_TRANSVR_STR_VAL; - char *func_str = "_taskfunc_sfp_setup_rs0"; - - err_val = _taskfunc_sfp_setup_hard_rs0(task_p, - input_val); - if (err_val < 0) { - err_str = "Setup hard_rs0 fail!"; - goto err_private_taskfunc_sfp_setup_rs0_1; - } - old_val = err_val; - err_val = _taskfunc_sfp_setup_soft_rs(task_p, - input_val, - task_p->transvr_p->eeprom_map_p->addr_soft_rs0, - task_p->transvr_p->eeprom_map_p->page_soft_rs0, - task_p->transvr_p->eeprom_map_p->offset_soft_rs0, - bit_shift, - &(task_p->transvr_p->soft_rs0), - func_str); - if (err_val < 0) { - err_str = "Setup soft_rs0 fail!"; - goto err_private_taskfunc_sfp_setup_rs0_1; - } - return EVENT_TRANSVR_TASK_DONE; - -err_private_taskfunc_sfp_setup_rs0_1: - if ((task_p->retry) == 0) { - SWPS_INFO("%s: %s :%s :%d :%d\n", - func_str, err_str, task_p->transvr_p->swp_name, input_val, err_val); - } - _taskfunc_sfp_setup_hard_rs0(task_p, old_val); - return EVENT_TRANSVR_TASK_FAIL; -} - - -int -_taskfunc_sfp_setup_rs1(struct transvr_worker_s *task_p, - int input_val) { - - int bit_shift = 3; - int old_val = DEBUG_TRANSVR_INT_VAL; - int err_val = EVENT_TRANSVR_EXCEP_EXCEP; - char *err_str = DEBUG_TRANSVR_STR_VAL; - char *func_str = "_taskfunc_sfp_setup_rs1"; - - err_val = _taskfunc_sfp_setup_hard_rs1(task_p, - input_val); - if (err_val < 0) { - err_str = "Setup hard_rs1 fail!"; - goto err_private_taskfunc_sfp_setup_rs1_1; - } - old_val = err_val; - err_val = _taskfunc_sfp_setup_soft_rs(task_p, - input_val, - task_p->transvr_p->eeprom_map_p->addr_soft_rs1, - task_p->transvr_p->eeprom_map_p->page_soft_rs1, - task_p->transvr_p->eeprom_map_p->offset_soft_rs1, - bit_shift, - &(task_p->transvr_p->soft_rs1), - func_str); - if (err_val < 0) { - err_str = "Setup soft_rs1 fail!"; - goto err_private_taskfunc_sfp_setup_rs1_1; - } - return EVENT_TRANSVR_TASK_DONE; - -err_private_taskfunc_sfp_setup_rs1_1: - if ((task_p->retry) == 0) { - SWPS_INFO("%s: %s :%s :%d :%d\n", - func_str, err_str, task_p->transvr_p->swp_name, input_val, err_val); - } - _taskfunc_sfp_setup_hard_rs1(task_p, old_val); - return EVENT_TRANSVR_TASK_FAIL; -} - - -int -taskfunc_sfp_setup_SFF8431_case1(struct transvr_worker_s *task_p) { - /* SFF-8431 (8/4/2G Rx Rate_Select only) */ - int update_val = 1; - - return _taskfunc_sfp_setup_rs0(task_p, update_val); -} - - - -int -taskfunc_sfp_setup_SFF8431_case2(struct transvr_worker_s *task_p) { - /* SFF-8431 (8/4/2G Tx Rate_Select only) */ - int update_val = 1; - - return _taskfunc_sfp_setup_rs1(task_p, update_val); -} - - -int -taskfunc_sfp_setup_SFF8431_case3(struct transvr_worker_s *task_p) { - /* SFF-8431 (8/4/2G Independent Rx & Tx Rate_select) */ - int update_rs0 = 1; - int update_rs1 = 1; - int err_code = DEBUG_TRANSVR_INT_VAL; - - err_code = _taskfunc_sfp_setup_rs0(task_p, update_rs0); - if (err_code < 0) { - return err_code; - } - return _taskfunc_sfp_setup_rs1(task_p, update_rs1); -} - - -int -taskfunc_sfp_handle_1g_rj45(struct transvr_worker_s *task_p) { - - /* Not all of platform support 0x56 for transceiver - * external PHY, Support list as below: - * => 1. Magnolia-PVT (PS: EVT & DVT not ready) - */ - int ext_phy_addr = 0x56; - int ext_phy_page = -1; - int ext_phy_offs = 0x11; - int ext_phy_len = 1; - int lstate_mask = 0x04; /* 00000100 */ - int show_err = 0; - int fail_retry = 5; - int fail_delay = 1000; /* msec */ - int err_code = DEBUG_TRANSVR_INT_VAL; - uint8_t detect_val = DEBUG_TRANSVR_HEX_VAL; - char err_str[64] = DEBUG_TRANSVR_STR_VAL; - int *tmp_p = NULL; - char *func_name = "taskfunc_sfp_handle_1g_rj45"; - - if (task_p->transvr_p->state != STATE_TRANSVR_CONNECTED) { - return EVENT_TRANSVR_TASK_DONE; - } - if ( (task_p->transvr_p->info != TRANSVR_CLASS_BASE_T_1000) && - (task_p->transvr_p->info != TRANSVR_CLASS_BASE_T_1000_up) ) { - goto err_taskfunc_sfp_handle_1g_rj45_1; - } - err_code = _common_update_uint8_attr(task_p->transvr_p, - ext_phy_addr, - ext_phy_page, - ext_phy_offs, - ext_phy_len, - &detect_val, - func_name, - show_err); - if ( (err_code < 0) || - (detect_val == DEBUG_TRANSVR_HEX_VAL) ) { - snprintf(err_str, sizeof(err_str), "Detect external link status fail"); - goto err_taskfunc_sfp_handle_1g_rj45_2; - } - if ((detect_val & lstate_mask) == lstate_mask) { - goto ok_taskfunc_sfp_handle_1g_rj45_link_up; - } - goto ok_taskfunc_sfp_handle_1g_rj45_link_down; - -ok_taskfunc_sfp_handle_1g_rj45_link_up: - /* Filter out noise */ - if (!(task_p->p_data)) { - tmp_p = kzalloc(sizeof(int), GFP_KERNEL); - if (!tmp_p) { - snprintf(err_str, sizeof(err_str), "kzalloc p_data fail"); - goto err_taskfunc_sfp_handle_1g_rj45_2; - } - *tmp_p = TRANSVR_CLASS_BASE_T_1000_up; - task_p->p_data = tmp_p; - goto ok_taskfunc_sfp_handle_1g_rj45_done; - } - if ((*(int *)(task_p->p_data)) != TRANSVR_CLASS_BASE_T_1000_up) { - kfree(task_p->p_data); - task_p->p_data = NULL; - snprintf(err_str, sizeof(err_str), "Internal error"); - goto err_taskfunc_sfp_handle_1g_rj45_2; - } - task_p->transvr_p->info = TRANSVR_CLASS_BASE_T_1000_up; - kfree(task_p->p_data); - task_p->p_data = NULL; - goto ok_taskfunc_sfp_handle_1g_rj45_done; - -ok_taskfunc_sfp_handle_1g_rj45_link_down: - if (task_p->p_data) { - kfree(task_p->p_data); - task_p->p_data = NULL; - } - task_p->transvr_p->info = TRANSVR_CLASS_BASE_T_1000; - goto ok_taskfunc_sfp_handle_1g_rj45_done; - -ok_taskfunc_sfp_handle_1g_rj45_done: - if (task_p->retry != VAL_TRANSVR_TASK_RETRY_FOREVER) { - transvr_task_set_retry(task_p, VAL_TRANSVR_TASK_RETRY_FOREVER); - } - return EVENT_TRANSVR_TASK_DONE; - -err_taskfunc_sfp_handle_1g_rj45_1: - snprintf(err_str, sizeof(err_str), "Detect transceiver:%d not Base-T, remove task.", - task_p->transvr_p->info); - SWPS_INFO("%s: %s :%s\n", __func__, err_str, task_p->transvr_p->swp_name); - transvr_task_set_retry(task_p, 0); - return EVENT_TRANSVR_TASK_DONE; - -err_taskfunc_sfp_handle_1g_rj45_2: - if (task_p->retry == VAL_TRANSVR_TASK_RETRY_FOREVER) { - transvr_task_set_retry(task_p, fail_retry); - } - if ((task_p->retry) == 0) { - /* Error case: - * => In this case, SWPS will stop external Link state monitor features - * and keeps transvr_p->info on TRANSVR_CLASS_BASE_T_1000_up. - * Upper layer will see it always Linkup that because of these type of - * transceiver has external phy, BCM chip see it as Loopback transceiver. - */ - SWPS_WARN("%s can not access external PHY of Base-T SFP transceiver\n", - task_p->transvr_p->swp_name); - task_p->transvr_p->info = TRANSVR_CLASS_BASE_T_1000_up; - return EVENT_TRANSVR_TASK_DONE; - } else { - transvr_task_set_delay(task_p, fail_delay); - } - return EVENT_TRANSVR_TASK_FAIL; -} - - -int -_taskfunc_qsfp_setup_power_mod(struct transvr_obj_s *self, - int setup_val) { - - int curr_val = DEBUG_TRANSVR_INT_VAL; - int err_val = DEBUG_TRANSVR_INT_VAL; - char *err_msg = DEBUG_TRANSVR_STR_VAL; - - curr_val = self->ioexp_obj_p->get_lpmod(self->ioexp_obj_p, - self->ioexp_virt_offset); - if (curr_val < 0){ - err_msg = "Get current value fail!"; - goto err_private_taskfunc_qsfp_setup_power_mod_1; - } - if (curr_val == setup_val){ - return EVENT_TRANSVR_TASK_DONE; - } - err_val = self->ioexp_obj_p->set_lpmod(self->ioexp_obj_p, - self->ioexp_virt_offset, - setup_val); - if (err_val < 0){ - err_msg = "Setup power mode fail!"; - goto err_private_taskfunc_qsfp_setup_power_mod_1; - } - return EVENT_TRANSVR_TASK_DONE; - -err_private_taskfunc_qsfp_setup_power_mod_1: - SWPS_INFO("%s: %s :%d :%d :%d\n", - __func__, err_msg, err_val, curr_val, setup_val); - return EVENT_TRANSVR_TASK_FAIL; -} - - -int -taskfunc_qsfp_handle_tx_disable(struct transvr_worker_s *task_p) { - - int i = 0; - int retry = 5; - int delay_ms = 100; - - if (task_p->transvr_p->auto_tx_disable == VAL_TRANSVR_FUNCTION_DISABLE) { - return EVENT_TRANSVR_TASK_DONE; - } - if (!_qsfp_is_implement_tx_disable(task_p->transvr_p)) { - return EVENT_TRANSVR_TASK_DONE; - } - for (i=0; itransvr_p, - task_p->transvr_p->auto_tx_disable) - == EVENT_TRANSVR_TASK_DONE) { - goto ok_taskfunc_qsfp_handle_tx_disable; - } - mdelay(delay_ms); - } - SWPS_INFO("%s auto setup tx_disable:0x%02x fail.\n", - task_p->transvr_p->swp_name, - task_p->transvr_p->auto_tx_disable); - return EVENT_TRANSVR_INIT_FAIL; - -ok_taskfunc_qsfp_handle_tx_disable: - SWPS_INFO("%s auto setup tx_disable:0x%02x ok.\n", - task_p->transvr_p->swp_name, - task_p->transvr_p->auto_tx_disable); - return EVENT_TRANSVR_TASK_DONE; -} - - -int -taskfunc_qsfp_set_hpmod(struct transvr_worker_s *task_p) { - - int err = DEBUG_TRANSVR_INT_VAL; - int HIGH_POWER_MODE = 0; - - /* Handle power mode */ - err = _taskfunc_qsfp_setup_power_mod(task_p->transvr_p, - HIGH_POWER_MODE); - if (err < 0) { - SWPS_INFO("%s: setup hpmod fail :%d :%s\n", - __func__, err, task_p->transvr_p->swp_name); - return err; - } - /* Handle auto tx_disable - * [Note] - * => Because there are some transceiver have timing issues or - * setup sequence issues, therefore we handle auto tx_disable - * after handle power mode. - */ - mdelay(100); - return taskfunc_qsfp_handle_tx_disable(task_p); -} - - -int -taskfunc_qsfp_set_lpmod(struct transvr_worker_s *task_p) { - - int LOW_POWER_MODE = 1; - return _taskfunc_qsfp_setup_power_mod(task_p->transvr_p, - LOW_POWER_MODE); -} - - -static int -initfunc_sfp_handle_multi_rate_mode(struct transvr_obj_s *self) { - - int task_retry = 3; - int err_code = DEBUG_TRANSVR_INT_VAL; - char *err_str = DEBUG_TRANSVR_STR_VAL; - char *func_str = "sfp_handle_multi_rate_mode"; - struct transvr_worker_s *task_p = NULL; - - switch (self->rate_id) { - case 0x00: /* Unspecified */ - case 0x03: /* Unspecified */ - case 0x05: /* Unspecified */ - case 0x07: /* Unspecified */ - case 0x09: /* Unspecified */ - case 0x0B: /* Unspecified */ - case 0x0D: /* Unspecified */ - case 0x0F: /* Unspecified */ - goto sfp_handle_multi_rate_mode_4_unspecified; - - case 0x02: /* SFF-8431 (8/4/2G Rx Rate_Select only) */ - task_p = transvr_task_creat(self, - taskfunc_sfp_setup_SFF8431_case1, - taskfunc_post_handle_task_state, - func_str); - goto sfp_handle_multi_rate_mode_4_sff8431; - - case 0x04: /* SFF-8431 (8/4/2G Tx Rate_Select only) */ - task_p = transvr_task_creat(self, - taskfunc_sfp_setup_SFF8431_case2, - taskfunc_post_handle_task_state, - func_str); - goto sfp_handle_multi_rate_mode_4_sff8431; - - case 0x06: /* SFF-8431 (8/4/2G Independent Rx & Tx Rate_select) */ - task_p = transvr_task_creat(self, - taskfunc_sfp_setup_SFF8431_case3, - taskfunc_post_handle_task_state, - func_str); - goto sfp_handle_multi_rate_mode_4_sff8431; - - case 0x01: /* SFF-8079 (4/2/1G Rate_Select & AS0/AS1) */ - err_str = "SFF-8079 (4/2/1G Rate_Select & AS0/AS1)"; - goto sfp_handle_multi_rate_mode_4_not_support; - - case 0x08: /* FC-PI-5 (16/8/4G Rx Rate_select only) - * High=16G only, Low=8G/4G - */ - err_str = "FC-PI-5 (16/8/4G Rx Rate_select only)"; - goto sfp_handle_multi_rate_mode_4_not_support; - - case 0x0A: /* FC-PI-5 (16/8/4G Independent Rx, Tx Rate_select) - * High=16G only, Low=8G/4G - */ - err_str = "FC-PI-5 (16/8/4G Independent Rx, Tx Rate_select)"; - goto sfp_handle_multi_rate_mode_4_not_support; - - case 0x0C: /* FC-PI-6 (32/16/8G Independent Rx, Tx Rate_Select) - * High=32G only, Low = 16G/8G - */ - err_str = "FC-PI-6 (32/16/8G Independent Rx, Tx Rate_Select)"; - goto sfp_handle_multi_rate_mode_4_not_support; - - case 0x0E: /* 10/8G Rx and Tx Rate_Select controlling the operation or - * locking modes of the internal signal conditioner, retimer - * or CDR, according to the logic table defined in Table 10-2, - * High Bit Rate (10G) =9.95-11.3 Gb/s; Low Bit Rate (8G) = - * 8.5 Gb/s. In this mode, the default value of bit 110.3 (Soft - * Rate Select RS(0), Table 9-11) and of bit 118.3 (Soft Rate - * Select RS(1), Table 10-1) is 1. - */ - err_str = "cable type: 0x0E"; - goto sfp_handle_multi_rate_mode_4_not_support; - - default: - err_str = "cable type: UNKNOW"; - goto sfp_handle_multi_rate_mode_4_not_support; - } - -sfp_handle_multi_rate_mode_4_sff8431: - if (!task_p) { - err_str = "Create task fail!"; - goto sfp_handle_multi_rate_mode_4_fail_1; - } - transvr_task_set_retry(task_p, task_retry); - return EVENT_TRANSVR_TASK_WAIT; - -sfp_handle_multi_rate_mode_4_unspecified: - return EVENT_TRANSVR_TASK_DONE; - -sfp_handle_multi_rate_mode_4_not_support: - SWPS_INFO("%s: Does not support %s :%s :0x%02x\n", - func_str, err_str, self->swp_name, self->rate_id); - return EVENT_TRANSVR_TASK_DONE; - -sfp_handle_multi_rate_mode_4_fail_1: - SWPS_INFO("%s: %s :%s :0x%02x, :%d\n", - func_str, err_str, self->swp_name, self->rate_id, err_code); - return EVENT_TRANSVR_INIT_FAIL; -} - - -static int -initfunc_sfp_handle_1g_rj45(struct transvr_obj_s *self) { - - struct transvr_worker_s *task_p = NULL; - int detect_cls = DEBUG_TRANSVR_INT_VAL; - char err_str[64] = DEBUG_TRANSVR_STR_VAL; - char *func_str = "initfunc_sfp_handle_1g_rj45"; - - - if (self->info == TRANSVR_CLASS_BASE_T_1000) { - task_p = transvr_task_creat(self, - taskfunc_sfp_handle_1g_rj45, - taskfunc_post_do_nothing, - func_str); - if (!task_p) { - snprintf(err_str, sizeof(err_str), "Create task fail"); - goto err_initfunc_sfp_handle_1g_rj45; - } - transvr_task_set_retry(task_p, VAL_TRANSVR_TASK_RETRY_FOREVER); - } - return EVENT_TRANSVR_TASK_DONE; - -err_initfunc_sfp_handle_1g_rj45: - SWPS_INFO("%s: %s :%s :%d\n", - __func__, err_str, self->swp_name, detect_cls); - return EVENT_TRANSVR_TASK_FAIL; -} - - -static int -initfunc_qsfp_handle_power_mode(struct transvr_obj_s *self) { - - int err_code = EVENT_TRANSVR_EXCEP_INIT; - int power_class = DEBUG_TRANSVR_INT_VAL; - int hpmod_retry = 3; - int lpower_config = 1; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - unsigned long hpmod_delay = 500; /* msec */ - struct transvr_worker_s *task_p = NULL; - - /* Handle power mode for IOEXP */ - power_class = __qsfp_get_power_cls(self, 0); - switch (power_class) { - case 1: /* Case: Low power mode (Class = 1) */ - err_code = _taskfunc_qsfp_setup_power_mod(self, lpower_config); - if (err_code < 0){ - snprintf(err_msg, sizeof(err_msg), "Setup lpmod fail :%d", err_code); - goto err_initfunc_qsfp_handle_power_mode; - } - return EVENT_TRANSVR_TASK_DONE; - - case 2: /* Case: High power mode (Class > 1) */ - case 3: - case 4: - case 5: - case 6: - case 7: - task_p = transvr_task_creat(self, - taskfunc_qsfp_set_hpmod, - taskfunc_post_handle_task_state, - "transvr_init_qsfp"); - if (!task_p) { - snprintf(err_msg, sizeof(err_msg), "Setup lpmod fail :%d", err_code); - goto err_initfunc_qsfp_handle_power_mode; - } - transvr_task_set_retry(task_p, hpmod_retry); - transvr_task_set_delay(task_p, hpmod_delay); - return EVENT_TRANSVR_TASK_WAIT; - - default: - break; - } - snprintf(err_msg, sizeof(err_msg), "Exception case"); - goto err_initfunc_qsfp_handle_power_mode; - -err_initfunc_qsfp_handle_power_mode: - SWPS_INFO("%s: %s :%s \n", __func__, err_msg, self->swp_name); - return EVENT_TRANSVR_INIT_FAIL; -} - - -int -initfunc_qsfp28_handle_cdr(struct transvr_obj_s *self) { - - uint8_t DEFAULT_VAL_CDR = 0xff; - int CDR_FUNC_EXISTED = 0x3; - int show_err = 1; - int err_val = EVENT_TRANSVR_TASK_FAIL; - char *err_msg = DEBUG_TRANSVR_STR_VAL; - char *func_str = "initfunc_qsfp28_handle_cdr"; - - err_val = __qsfp_get_cdr_present(self, 0); - if ( (err_val < 0) || - (err_val == DEBUG_TRANSVR_HEX_VAL) ) { - err_msg = "detect cdr_present fail!"; - goto err_taskfunc_qsfp_handle_cdr_1; - } - if (err_val == CDR_FUNC_EXISTED) { - err_val = _common_set_uint8_attr(self, - self->eeprom_map_p->addr_cdr, - self->eeprom_map_p->addr_cdr, - self->eeprom_map_p->offset_cdr, - DEFAULT_VAL_CDR, - &(self->cdr), - func_str, - show_err); - if (err_val < 0) { - err_msg = "set CDR fail!"; - goto err_taskfunc_qsfp_handle_cdr_1; - } - } - return EVENT_TRANSVR_TASK_DONE; - -err_taskfunc_qsfp_handle_cdr_1: - SWPS_INFO("%s: %s :%d :%s\n", - func_str, err_msg, err_val, self->swp_name); - return EVENT_TRANSVR_INIT_FAIL; -} - -/* ========== Object functions for Final State Machine ========== - */ -int -is_plugged(struct transvr_obj_s *self){ - - int limit = 63; - int present = DEBUG_TRANSVR_INT_VAL; - char emsg[64] = DEBUG_TRANSVR_STR_VAL; - struct ioexp_obj_s *ioexp_p = self->ioexp_obj_p; - - if (!ioexp_p) { - snprintf(emsg, limit, "ioexp_p is null!"); - goto err_is_plugged_1; - } - present = ioexp_p->get_present(ioexp_p, self->ioexp_virt_offset); - switch (present){ - case 0: - return 1; - case 1: - return 0; - case ERR_IOEXP_UNINIT: - snprintf(emsg, limit, "ioexp_p not ready!"); - goto err_is_plugged_1; - default: - if (ioexp_p->state == STATE_IOEXP_INIT){ - snprintf(emsg, limit, "ioexp_p not ready!"); - goto err_is_plugged_1; - } - break; - } - SWPS_INFO("%s: Exception case! :%d :%d\n", - __func__, present, ioexp_p->state); - return 0; - -err_is_plugged_1: - SWPS_DEBUG("%s: %s\n", __func__, emsg); - return 0; -} - - -static int -detect_transvr_type(struct transvr_obj_s* self){ - - int type = TRANSVR_TYPE_ERROR; - - self->i2c_client_p->addr = VAL_TRANSVR_COMID_ARREESS; - type = i2c_smbus_read_byte_data(self->i2c_client_p, - VAL_TRANSVR_COMID_OFFSET); - - /* Case: 1. Wait transceiver I2C module. - * 2. Transceiver I2C module failure. - * Note: 1. SFF allow maximum transceiver initial time is 2 second. So, there - * are exist some case that we need to wait transceiver. - * For these case, we keeps status on "TRANSVR_TYPE_UNPLUGGED", than - * state machine will keep trace with it. - * 2. There exist some I2C failure case we need to handle. Such as user - * insert the failure transceiver, or any reason cause it abnormal. - */ - if (type < 0){ - switch (type) { - case -EIO: - SWPS_DEBUG("%s: %s smbus return:-5 (I/O error)\n", - __func__, self->swp_name); - return TRANSVR_TYPE_UNPLUGGED; - case -ENXIO: - SWPS_DEBUG("%s: %s smbus return:-6 (No such device or address)\n", - __func__, self->swp_name); - return TRANSVR_TYPE_UNPLUGGED; - default: - break; - } - SWPS_INFO("%s: %s unexpected smbus return:%d \n", - __func__, self->swp_name, type); - return TRANSVR_TYPE_ERROR; - } - /* Identify valid transceiver type */ - switch (type){ - case TRANSVR_TYPE_SFP: - case TRANSVR_TYPE_QSFP: - case TRANSVR_TYPE_QSFP_PLUS: - case TRANSVR_TYPE_QSFP_28: - break; - case TRANSVR_TYPE_UNKNOW_1: - case TRANSVR_TYPE_UNKNOW_2: - type = TRANSVR_TYPE_UNKNOW_2; - break; - default: - SWPS_DEBUG("%s: unknow type:0x%02x \n", __func__, type); - type = TRANSVR_TYPE_ERROR; - break; - } - return type; -} - - -static int -detect_transvr_state(struct transvr_obj_s *self, - int result[2]){ - /* [return] [result-0] [result-1] - * 0 STATE_TRANSVR_CONNECTED TRANSVR_TYPE_FAKE - * 0 STATE_TRANSVR_DISCONNECTED TRANSVR_TYPE_UNPLUGGED - * 0 STATE_TRANSVR_ISOLATED TRANSVR_TYPE_ERROR - * 0 STATE_TRANSVR_INIT / - * 0 STATE_TRANSVR_SWAPPED - * 0 STATE_TRANSVR_CONNECTED - * ERR_TRNASVR_BE_ISOLATED STATE_TRANSVR_ISOLATED TRANSVR_TYPE_ERROR - * ERR_TRANSVR_I2C_CRASH STATE_TRANSVR_UNEXCEPTED TRANSVR_TYPE_ERROR - * ERR_TRANSVR_UNEXCPT STATE_TRANSVR_UNEXCEPTED TRANSVR_TYPE_UNKNOW_1/2 - */ - result[0] = STATE_TRANSVR_UNEXCEPTED; /* For return state */ - result[1] = TRANSVR_TYPE_ERROR; /* For return type */ - - /* Case1: Fake type */ - if (self->type == TRANSVR_TYPE_FAKE){ - result[0] = STATE_TRANSVR_CONNECTED; - result[1] = TRANSVR_TYPE_FAKE; - return 0; - } - /* Case2: Transceiver unplugged */ - if (!is_plugged(self)){ - result[0] = STATE_TRANSVR_DISCONNECTED; - result[1] = TRANSVR_TYPE_UNPLUGGED; - return 0; - } - /* Case3: Transceiver be isolated */ - if (self->state == STATE_TRANSVR_ISOLATED){ - result[0] = STATE_TRANSVR_ISOLATED; - result[1] = TRANSVR_TYPE_ERROR; - return ERR_TRNASVR_BE_ISOLATED; - } - /* Case4: Transceiver plugged */ - result[1] = detect_transvr_type(self); - /* Case4.1: I2C topology crash - * Note : There are some I2C issues cause by transceiver/cables. - * We need to check topology status when user insert it. - * But in this step, we can't not ensure this is the issues - * port. So, it return the ERR_TRANSVR_I2C_CRASH, then upper - * layer will diagnostic I2C topology. - */ - if (check_channel_tier_1() < 0) { - SWPS_INFO("%s: %s detect I2C crash :%d\n", - __func__, self->swp_name, self->state); - result[0] = STATE_TRANSVR_UNEXCEPTED; - result[1] = TRANSVR_TYPE_ERROR; - return ERR_TRANSVR_I2C_CRASH; - } - /* Case4.2: System initial not ready, - * Note : Sometime i2c channel or transceiver EEPROM will delay that will - * cause system in inconsistent state between EEPROM and IOEXP. - * In this case, SWP transceiver object keep state at LINK_DOWN - * to wait system ready. - * By the way, State Machine will handle these case. - */ - if (result[1] == TRANSVR_TYPE_UNPLUGGED){ - result[0] = STATE_TRANSVR_DISCONNECTED; - return 0; - } - /* Case4.3: Error transceiver type */ - if (result[1] == TRANSVR_TYPE_ERROR){ - result[0] = STATE_TRANSVR_ISOLATED; - SWPS_INFO("%s: %s detect error type\n", __func__, self->swp_name); - alarm_msg_2_user(self, "detected transceiver/cables not meet SFF standard!"); - return ERR_TRNASVR_BE_ISOLATED; - } - /* Case3.3: Unknow transceiver type */ - if ((result[1] == TRANSVR_TYPE_UNKNOW_1) || - (result[1] == TRANSVR_TYPE_UNKNOW_2) ){ - result[0] = STATE_TRANSVR_UNEXCEPTED; - return ERR_TRANSVR_UNEXCPT; - } - /* Case3.4: During initial process */ - if (self->state == STATE_TRANSVR_INIT){ - result[0] = STATE_TRANSVR_INIT; - return 0; - } - /* Case3.5: Transceiver be swapped */ - if (self->type != result[1]){ - result[0] = STATE_TRANSVR_SWAPPED; - return 0; - } - /* Case3.6: Link up state */ - result[0] = STATE_TRANSVR_CONNECTED; - return 0; -} - - -int -_sfp_detect_class_by_extend_comp(struct transvr_obj_s* self) { - /* Reference: SFF-8024 (v3.8) - */ - int detect_val = _sfp_get_comp_extended(self); - - switch(detect_val) { - case 0x00: /* Unspecified */ - return TRANSVR_CLASS_UNSPECIFIED; - - case 0x01: /* 100G AOC (Active Optical Cable) or 25GAUI C2M */ - case 0x18: /* 100G AOC or 25GAUI C2M AOC. */ - return TRANSVR_CLASS_OPTICAL_25G_AOC; - - case 0x02: /* 100GBASE-SR4 or 25GBASE-SR */ - return TRANSVR_CLASS_OPTICAL_25G_SR; - - case 0x03: /* 100GBASE-LR4 or 25GBASE-LR */ - return TRANSVR_CLASS_OPTICAL_25G_LR; - - case 0x04: /* 100GBASE-ER4 or 25GBASE-ER */ - return TRANSVR_CLASS_OPTICAL_25G_ER; - - case 0x08: /* 100G ACC (Active Copper Cable) or 25GAUI C2M ACC. */ - case 0x0b: /* 100GBASE-CR4 or 25GBASE-CR CA-L */ - case 0x0c: /* 25GBASE-CR CA-S */ - case 0x0d: /* 25GBASE-CR CA-N */ - case 0x19: /* 100G ACC or 25GAUI C2M ACC. */ - return TRANSVR_CLASS_COPPER_L1_25G; - - default: - break; - } - SWPS_INFO("%s: Unexcept value:0x%02x\n :%s", - __func__, detect_val, self->swp_name); - return TRANSVR_CLASS_ERROR; -} - - -int -_sfp_detect_class_by_10_ethernet(struct transvr_obj_s* self) { - /* Reference: SFF-8472 (v12.2) - */ - int detect_val = DEBUG_TRANSVR_INT_VAL; - - detect_val = _sfp_get_comp_10g_eth_comp(self); - /* Case: Unspecified */ - if (detect_val == 0x00) { - return TRANSVR_CLASS_UNSPECIFIED; - } - /* Case: 10G Optical (x1) */ - if ((detect_val & 0x10) == 0x10) { /* 00010000 : 10GBASE-SR */ - return TRANSVR_CLASS_OPTICAL_10G_S_SR; - } - if ( ((detect_val & 0x20) == 0x20) || /* 00100000 : 10GBASE-LR */ - ((detect_val & 0x40) == 0x40) ){ /* 01000000 : 10GBASE-LRM */ - return TRANSVR_CLASS_OPTICAL_10G_S_LR; - } - if ((detect_val & 0x80) == 0x80) { /* 10000000 : 10GBASE-ER */ - return TRANSVR_CLASS_OPTICAL_10G_S_ER; - } - /* Case: ERROR */ - SWPS_INFO("%s: Unexcept value:0x%02x\n :%s", - __func__, detect_val, self->swp_name); - return TRANSVR_CLASS_ERROR; -} - - -int -_sfp_detect_if_sp_by_br(struct transvr_obj_s* self) { - - int lower_bound_1g = 0x0b; - int upper_bound_1g = 0x1A; - int lower_bound_10g = 0x60; - int upper_bound_10g = 0x75; - int lower_bound_25g = 0xf0; - int upper_bound_25g = 0xff; - int notmal_br = DEBUG_TRANSVR_INT_VAL; - - notmal_br = (int)(self->br); /* updated by update_all() */ - /* Check 25G */ - if ((notmal_br >= lower_bound_25g) && - (notmal_br <= upper_bound_25g) ) { - return TRANSVR_CLASS_25G; - } - /* Check 10G */ - if ((notmal_br >= lower_bound_10g) && - (notmal_br <= upper_bound_10g) ) { - return TRANSVR_CLASS_10G; - } - /* Check 1G */ - if ((notmal_br >= lower_bound_1g) && - (notmal_br <= upper_bound_1g) ) { - return TRANSVR_CLASS_1G; - } - return TRANSVR_CLASS_UNSPECIFIED; -} - - -int -_sfp_detect_class_by_1g_ethernet(struct transvr_obj_s* self) { - /* Reference: SFF-8472 (v12.2) - */ - int detect_val = DEBUG_TRANSVR_INT_VAL; - int speed_br = DEBUG_TRANSVR_INT_VAL; - int speed_tmp = DEBUG_TRANSVR_INT_VAL; - char err_str[64] = DEBUG_TRANSVR_STR_VAL; - - speed_br = _sfp_detect_if_sp_by_br(self); - detect_val = _sfp_get_comp_1g_eth_comp(self); - - if (detect_val < 0) { - snprintf(err_str, sizeof(err_str), "Detect abnormal value:%d", detect_val); - goto err_p_sfp_detect_class_by_1g_ethernet; - } - /* Case: Unspecified */ - if (detect_val == 0x00) { - return TRANSVR_CLASS_UNSPECIFIED; - } - /* Case: 1G (x1) */ - if ((detect_val & 0x01) == 0x01) { /* 00000001 : 1000BASE-SX */ - speed_tmp = TRANSVR_CLASS_OPTICAL_1G_SX; - goto ok_sfp_detect_class_by_1g_ethernet_4_check_br_10g; - } - if ((detect_val & 0x02) == 0x02) { /* 00000010 : 1000BASE-LX *3 */ - speed_tmp = TRANSVR_CLASS_OPTICAL_1G_LX; - goto ok_sfp_detect_class_by_1g_ethernet_4_check_br_10g; - } - if ((detect_val & 0x04) == 0x04) { /* 00000100 : 1000BASE-CX */ - speed_tmp = TRANSVR_CLASS_COPPER_L1_1G; - goto ok_sfp_detect_class_by_1g_ethernet_4_check_br_10g; - } - /* Case: 1000 Base-T (x1) */ - if ((detect_val & 0x08) == 0x08) { /* 00001000 : 1000BASE-T */ - return TRANSVR_CLASS_BASE_T_1000; - } - /* Case: 100 Base */ - if ( ((detect_val & 0x10) == 0x10) || /* 00010000 : 100BASE-LX/LX10 */ - ((detect_val & 0x20) == 0x20) || /* 00100000 : 100BASE-FX */ - ((detect_val & 0x40) == 0x40) || /* 01000000 : BASE-BX10 *3 */ - ((detect_val & 0x80) == 0x80) ){ /* 10000000 : BASE-PX *3 */ - return TRANSVR_CLASS_OPTICAL_100; - } - /* Case: ERROR */ - snprintf(err_str, sizeof(err_str), "Case:ERROR, value:%d", detect_val); - goto err_p_sfp_detect_class_by_1g_ethernet; - -ok_sfp_detect_class_by_1g_ethernet_4_check_br_10g: - switch (speed_br) { - case TRANSVR_CLASS_UNSPECIFIED: - case TRANSVR_CLASS_1G: - return speed_tmp; - case TRANSVR_CLASS_10G: - goto ok_sfp_detect_class_by_1g_ethernet_4_transfer_10G; - } - -ok_sfp_detect_class_by_1g_ethernet_4_transfer_10G: - switch (speed_tmp) { - case TRANSVR_CLASS_OPTICAL_1G_SX: - return TRANSVR_CLASS_OPTICAL_10G_S_SR; - case TRANSVR_CLASS_OPTICAL_1G_LX: - return TRANSVR_CLASS_OPTICAL_10G_S_LR; - case TRANSVR_CLASS_COPPER_L1_1G: - return TRANSVR_CLASS_COPPER_L1_10G; - default: - break; - } - snprintf(err_str, sizeof(err_str), "transfer_1to10 fail, speed:%d", speed_tmp); - goto err_p_sfp_detect_class_by_1g_ethernet; - -err_p_sfp_detect_class_by_1g_ethernet: - SWPS_INFO("%s: %s :%s", __func__, err_str, self->swp_name); - return TRANSVR_CLASS_ERROR; -} - - -int -_sfp_detect_class_by_feature(struct transvr_obj_s* self) { - /* Reference: SFF-8024 (v3.8) - */ - int is_active = 0; - int conn_val = DEBUG_TRANSVR_INT_VAL; - int check_val = DEBUG_TRANSVR_INT_VAL; - int wave_len = DEBUG_TRANSVR_INT_VAL; - int speed_val = DEBUG_TRANSVR_INT_VAL; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - - speed_val = _sfp_detect_if_sp_by_br(self); - conn_val = _sfp_get_connector_type(self); - - switch(conn_val) { - case 0x00: /* Unspecified */ - goto ok_sfp_detect_class_by_feature_4_check_active_passive; - case 0x07: /* LC (Lucent Connector) */ - case 0x0b: /* Optical Pigtail */ - case 0x0c: /* MPO 1x12 */ - case 0x0d: /* MPO 2x16 */ - /* - * ToDo: Need verify Optical Pigtail - */ - goto ok_sfp_detect_class_by_feature_4_optiocal; - case 0x21: /* Copper pigtail */ - /* - * ToDo: Need check ACC use case - */ - goto ok_sfp_detect_class_by_feature_4_check_active_passive; - case 0x23: /* No separable connector */ - /* - * ToDo: Standard not clear, not all transceiver vendor - * have the same defined - */ - goto ok_sfp_detect_class_by_feature_4_check_active_passive; - default: - break; - } - goto ok_sfp_detect_class_by_feature_4_unknow; - -ok_sfp_detect_class_by_feature_4_check_active_passive: - check_val = _sfp_get_cable_tech(self); - switch(check_val) { - case 0x00: /* Unspecified */ - goto ok_sfp_detect_class_by_feature_4_unknow; - case 0x04: /* Passive */ - goto ok_sfp_detect_class_by_feature_4_copper; - case 0x08: /* Active */ - is_active = 1; - goto ok_sfp_detect_class_by_feature_4_aoc; - default: - snprintf(err_msg, sizeof(err_msg), - "_sfp_get_cable_tech return Non define value:%d", - check_val); - break; - } - goto err_sfp_detect_class_by_feature_1; - -ok_sfp_detect_class_by_feature_4_optiocal: - wave_len = _common_count_wavelength(self, - self->wavelength[0], - self->wavelength[1]); - switch(speed_val) { - case TRANSVR_CLASS_25G: - switch (wave_len) { - case VAL_OPTICAL_WAVELENGTH_SR: - return TRANSVR_CLASS_OPTICAL_25G_SR; - case VAL_OPTICAL_WAVELENGTH_LR: - return TRANSVR_CLASS_OPTICAL_25G_LR; - case VAL_OPTICAL_WAVELENGTH_ER: - return TRANSVR_CLASS_OPTICAL_25G_ER; - default: - break; - } - return TRANSVR_CLASS_OPTICAL_25G; - - case TRANSVR_CLASS_10G: - switch (wave_len) { - case VAL_OPTICAL_WAVELENGTH_SR: - return TRANSVR_CLASS_OPTICAL_10G_S_SR; - case VAL_OPTICAL_WAVELENGTH_LR: - return TRANSVR_CLASS_OPTICAL_10G_S_LR; - case VAL_OPTICAL_WAVELENGTH_ER: - return TRANSVR_CLASS_OPTICAL_10G_S_ER; - default: - break; - } - return TRANSVR_CLASS_OPTICAL_10G; - - case TRANSVR_CLASS_1G: - switch (wave_len) { - case VAL_OPTICAL_WAVELENGTH_SR: - return TRANSVR_CLASS_OPTICAL_1G_SX; - case VAL_OPTICAL_WAVELENGTH_LR: - return TRANSVR_CLASS_OPTICAL_1G_LX; - case VAL_OPTICAL_WAVELENGTH_ER: - return TRANSVR_CLASS_OPTICAL_1G_EX; - default: - break; - } - return TRANSVR_CLASS_OPTICAL_1G; - - default: - return TRANSVR_CLASS_OPTICAL; - } - -ok_sfp_detect_class_by_feature_4_aoc: - switch(speed_val) { - case TRANSVR_CLASS_25G: - return TRANSVR_CLASS_OPTICAL_25G_AOC; - case TRANSVR_CLASS_10G: - return TRANSVR_CLASS_OPTICAL_10G_S_AOC; - case TRANSVR_CLASS_1G: - return TRANSVR_CLASS_OPTICAL_1G_AOC; - default: - break; - } - goto ok_sfp_detect_class_by_feature_4_unknow; - -ok_sfp_detect_class_by_feature_4_copper: - switch(speed_val) { - case TRANSVR_CLASS_25G: - return TRANSVR_CLASS_COPPER_L1_25G; - case TRANSVR_CLASS_10G: - return TRANSVR_CLASS_COPPER_L1_10G; - case TRANSVR_CLASS_1G: - return TRANSVR_CLASS_COPPER_L1_1G; - default: - return TRANSVR_CLASS_COPPER; - } - -ok_sfp_detect_class_by_feature_4_unknow: - return TRANSVR_CLASS_UNSPECIFIED; - -err_sfp_detect_class_by_feature_1: - SWPS_INFO("%s: %s\n :%s", __func__, err_msg, self->swp_name); - return TRANSVR_CLASS_ERROR; -} - - -int -sft_detect_transvr_class(struct transvr_obj_s* self) { - - int detect_val = DEBUG_TRANSVR_INT_VAL; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - - /* Check Extended Compliance */ - detect_val = _sfp_detect_class_by_extend_comp(self); - switch(detect_val) { - case TRANSVR_CLASS_UNSPECIFIED: - break; - case TRANSVR_CLASS_OPTICAL_25G_AOC: - case TRANSVR_CLASS_OPTICAL_25G_SR: - case TRANSVR_CLASS_OPTICAL_25G_LR: - case TRANSVR_CLASS_OPTICAL_25G_ER: - case TRANSVR_CLASS_COPPER_L1_25G: - return detect_val; - default: - snprintf(err_msg, sizeof(err_msg), - "Detect undefined extend_comp:%d", - detect_val); - goto err_sft_detect_transceiver_class_1; - } - /* Check 10G Compliance */ - detect_val = _sfp_detect_class_by_10_ethernet(self); - switch(detect_val) { - case TRANSVR_CLASS_UNSPECIFIED: - break; - case TRANSVR_CLASS_OPTICAL_10G_S_SR: - case TRANSVR_CLASS_OPTICAL_10G_S_LR: - case TRANSVR_CLASS_OPTICAL_10G_S_ER: - return detect_val; - default: - snprintf(err_msg, sizeof(err_msg), - "Detect undefined 10G_eth:%d", - detect_val); - goto err_sft_detect_transceiver_class_1; - } - /* Check 1G Compliance */ - detect_val = _sfp_detect_class_by_1g_ethernet(self); - switch(detect_val) { - case TRANSVR_CLASS_UNSPECIFIED: - break; - case TRANSVR_CLASS_OPTICAL_1G_SX: - case TRANSVR_CLASS_OPTICAL_1G_LX: - case TRANSVR_CLASS_COPPER_L1_1G: - case TRANSVR_CLASS_BASE_T_1000: - case TRANSVR_CLASS_OPTICAL_100: - /* - * ToDo: Need Check 0.1G - */ - case TRANSVR_CLASS_OPTICAL_10G_S_SR: - case TRANSVR_CLASS_OPTICAL_10G_S_LR: - case TRANSVR_CLASS_COPPER_L1_10G: - /* Transfer speed case - * => Example: Raycom 10G DAC - */ - return detect_val; - default: - snprintf(err_msg, sizeof(err_msg), - "Detect undefined 1G_eth:%d", - detect_val); - goto err_sft_detect_transceiver_class_1; - } - /* Check by connector, br, wavelength */ - detect_val = _sfp_detect_class_by_feature(self); - switch(detect_val) { - case TRANSVR_CLASS_UNSPECIFIED: - break; - case TRANSVR_CLASS_OPTICAL: - case TRANSVR_CLASS_OPTICAL_1G: - case TRANSVR_CLASS_OPTICAL_1G_SX: - case TRANSVR_CLASS_OPTICAL_1G_LX: - case TRANSVR_CLASS_OPTICAL_1G_EX: - case TRANSVR_CLASS_OPTICAL_1G_AOC: - case TRANSVR_CLASS_OPTICAL_10G: - case TRANSVR_CLASS_OPTICAL_10G_S_SR: - case TRANSVR_CLASS_OPTICAL_10G_S_LR: - case TRANSVR_CLASS_OPTICAL_10G_S_ER: - case TRANSVR_CLASS_OPTICAL_10G_S_AOC: - case TRANSVR_CLASS_OPTICAL_25G: - case TRANSVR_CLASS_OPTICAL_25G_SR: - case TRANSVR_CLASS_OPTICAL_25G_LR: - case TRANSVR_CLASS_OPTICAL_25G_ER: - case TRANSVR_CLASS_OPTICAL_25G_AOC: - case TRANSVR_CLASS_COPPER: - case TRANSVR_CLASS_COPPER_L1_1G: - case TRANSVR_CLASS_COPPER_L1_10G: - case TRANSVR_CLASS_COPPER_L1_25G: - return detect_val; - default: - snprintf(err_msg, sizeof(err_msg), - "Detect undefined get_connector:%d", - detect_val); - goto err_sft_detect_transceiver_class_1; - } - /* Exception case: Can't verify */ - snprintf(err_msg, sizeof(err_msg), "Can not identify!"); - goto err_sft_detect_transceiver_class_1; - -err_sft_detect_transceiver_class_1: - SWPS_INFO("%s: %s :%s\n", __func__, err_msg, self->swp_name); - return TRANSVR_CLASS_ERROR; -} - - -int -_sfp_set_trident2_if_type(struct transvr_obj_s* self, - int transvr_cls, - char *result){ - - int lmax = 8; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - - switch(transvr_cls) { - case TRANSVR_CLASS_ERROR: - case TRANSVR_CLASS_UNSPECIFIED: - break; - /* 25G OPTICAL */ - case TRANSVR_CLASS_OPTICAL_25G_AOC: - case TRANSVR_CLASS_OPTICAL_25G_SR: - case TRANSVR_CLASS_OPTICAL_25G_LR: - case TRANSVR_CLASS_OPTICAL_25G_ER: - case TRANSVR_CLASS_OPTICAL_25G: - return snprintf(result, lmax, TRANSVR_IF_SFI); - /* 25G COPPER */ - case TRANSVR_CLASS_COPPER_L1_25G: - return snprintf(result, lmax, TRANSVR_IF_SFI); - /* 10G OPTICAL */ - case TRANSVR_CLASS_OPTICAL_10G_S_AOC: - case TRANSVR_CLASS_OPTICAL_10G_S_SR: - case TRANSVR_CLASS_OPTICAL_10G_S_LR: - case TRANSVR_CLASS_OPTICAL_10G_S_ER: - case TRANSVR_CLASS_OPTICAL_10G: - return snprintf(result, lmax, TRANSVR_IF_SFI); - /* 10G COPPER */ - case TRANSVR_CLASS_COPPER_L1_10G: - return snprintf(result, lmax, TRANSVR_IF_SFI); - /* 1G OPTICAL */ - case TRANSVR_CLASS_OPTICAL_1G_AOC: - case TRANSVR_CLASS_OPTICAL_1G_SX: - case TRANSVR_CLASS_OPTICAL_1G_LX: - case TRANSVR_CLASS_OPTICAL_1G_EX: - case TRANSVR_CLASS_OPTICAL_1G: - return snprintf(result, lmax, TRANSVR_IF_IF_GMII); - /* 1G COPPER */ - case TRANSVR_CLASS_COPPER_L1_1G: - return snprintf(result, lmax, TRANSVR_IF_IF_GMII); - /* 1G BASE_T */ - case TRANSVR_CLASS_BASE_T_1000: - return snprintf(result, lmax, TRANSVR_IF_IF_GMII); - /* 100 Base */ - case TRANSVR_CLASS_OPTICAL_100: - return snprintf(result, lmax, TRANSVR_IF_IF_GMII); - default: - snprintf(err_msg, sizeof(err_msg), - "Detect undefined value:%d", - transvr_cls); - goto err_sfp_set_trident2_if_type_1; - } - /* Exception case: Can't verify */ - snprintf(err_msg, sizeof(err_msg), "Can not identify!"); - goto err_sfp_set_trident2_if_type_1; - -err_sfp_set_trident2_if_type_1: - snprintf(result, lmax, TRANSVR_UEVENT_UNKNOW); - SWPS_INFO("%s: %s :%s\n", __func__, err_msg, self->swp_name); - return ERR_TRANSVR_ABNORMAL; -} - - -int -_sfp_set_tomahawk_if_type(struct transvr_obj_s* self, - int transvr_cls, - char *result) { - - int lmax = 8; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - - switch(transvr_cls) { - case TRANSVR_CLASS_ERROR: - case TRANSVR_CLASS_UNSPECIFIED: - break; - /* 25G OPTICAL */ - case TRANSVR_CLASS_OPTICAL_25G_AOC: - case TRANSVR_CLASS_OPTICAL_25G_SR: - case TRANSVR_CLASS_OPTICAL_25G_LR: - case TRANSVR_CLASS_OPTICAL_25G_ER: - case TRANSVR_CLASS_OPTICAL_25G: - return snprintf(result, lmax, TRANSVR_IF_SR); - /* 25G COPPER */ - case TRANSVR_CLASS_COPPER_L1_25G: - return snprintf(result, lmax, TRANSVR_IF_KR); - /* 10G OPTICAL */ - case TRANSVR_CLASS_OPTICAL_10G_S_AOC: - case TRANSVR_CLASS_OPTICAL_10G_S_SR: - case TRANSVR_CLASS_OPTICAL_10G_S_LR: - case TRANSVR_CLASS_OPTICAL_10G_S_ER: - case TRANSVR_CLASS_OPTICAL_10G: - return snprintf(result, lmax, TRANSVR_IF_SFI); - /* 10G COPPER */ - case TRANSVR_CLASS_COPPER_L1_10G: - return snprintf(result, lmax, TRANSVR_IF_SFI); - /* 1G OPTICAL */ - case TRANSVR_CLASS_OPTICAL_1G_AOC: - case TRANSVR_CLASS_OPTICAL_1G_SX: - case TRANSVR_CLASS_OPTICAL_1G_LX: - case TRANSVR_CLASS_OPTICAL_1G_EX: - case TRANSVR_CLASS_OPTICAL_1G: - return snprintf(result, lmax, TRANSVR_IF_IF_GMII); - /* 1G COPPER */ - case TRANSVR_CLASS_COPPER_L1_1G: - return snprintf(result, lmax, TRANSVR_IF_IF_GMII); - /* 1G BASE_T */ - case TRANSVR_CLASS_BASE_T_1000: - return snprintf(result, lmax, TRANSVR_IF_IF_GMII); - /* 100 Base */ - case TRANSVR_CLASS_OPTICAL_100: - return snprintf(result, lmax, TRANSVR_IF_IF_GMII); - default: - snprintf(err_msg, sizeof(err_msg), - "Detect undefined value:%d", - transvr_cls); - goto err_sfp_set_tomahawk_if_type_1; - } - /* Exception case: Can't verify */ - snprintf(err_msg, sizeof(err_msg), "Can not identify!"); - goto err_sfp_set_tomahawk_if_type_1; - -err_sfp_set_tomahawk_if_type_1: - snprintf(result, lmax, TRANSVR_UEVENT_UNKNOW); - SWPS_INFO("%s: %s\n :%s", __func__, err_msg, self->swp_name); - return ERR_TRANSVR_ABNORMAL; -} - - -int -_sfp_detect_if_type(struct transvr_obj_s* self, - char *result){ - - int lmax = 8; - int detect_cls = DEBUG_TRANSVR_INT_VAL; - - detect_cls = sft_detect_transvr_class(self); - switch (self->chipset_type) { - case BCM_CHIP_TYPE_TRIDENT_2: - return _sfp_set_trident2_if_type(self, detect_cls, result); - - case BCM_CHIP_TYPE_TOMAHAWK: - return _sfp_set_tomahawk_if_type(self, detect_cls, result); - - default: - SWPS_INFO("%s: non-defined chipset_type:%d :%s\n", - __func__, self->chipset_type, self->swp_name); - break; - } - snprintf(result, lmax, TRANSVR_UEVENT_UNKNOW); - return ERR_TRANSVR_ABNORMAL; -} - - -int -sfp_get_if_type(struct transvr_obj_s *self, - char *buf_p){ - - int lmax = 16; - char tmp_result[16] = DEBUG_TRANSVR_STR_VAL; - - if (self->state != STATE_TRANSVR_CONNECTED) { - return snprintf(buf_p, lmax, "%d\n", self->state); - } - if (_sfp_detect_if_type(self, tmp_result) < 0) { - return snprintf(buf_p, lmax, "%d\n", ERR_TRANSVR_ABNORMAL); - } - return snprintf(buf_p, lmax, "%s\n", tmp_result); -} - - -int -_sfp_detect_if_speed(struct transvr_obj_s* self, - char *result){ - - int lmax = 16; - int detect_val = DEBUG_TRANSVR_INT_VAL; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - - detect_val = sft_detect_transvr_class(self); - switch(detect_val) { - case TRANSVR_CLASS_ERROR: - case TRANSVR_CLASS_UNSPECIFIED: - break; - /* 25G OPTICAL */ - case TRANSVR_CLASS_OPTICAL_25G_AOC: - case TRANSVR_CLASS_OPTICAL_25G_SR: - case TRANSVR_CLASS_OPTICAL_25G_LR: - case TRANSVR_CLASS_OPTICAL_25G_ER: - case TRANSVR_CLASS_OPTICAL_25G: - return snprintf(result, lmax, TRANSVR_IF_SP_25G); - /* 25G COPPER */ - case TRANSVR_CLASS_COPPER_L1_25G: - return snprintf(result, lmax, TRANSVR_IF_SP_25G); - /* 10G OPTICAL */ - case TRANSVR_CLASS_OPTICAL_10G_S_AOC: - case TRANSVR_CLASS_OPTICAL_10G_S_SR: - case TRANSVR_CLASS_OPTICAL_10G_S_LR: - case TRANSVR_CLASS_OPTICAL_10G_S_ER: - case TRANSVR_CLASS_OPTICAL_10G: - return snprintf(result, lmax, TRANSVR_IF_SP_10G); - /* 10G COPPER */ - case TRANSVR_CLASS_COPPER_L1_10G: - return snprintf(result, lmax, TRANSVR_IF_SP_10G); - /* 1G OPTICAL */ - case TRANSVR_CLASS_OPTICAL_1G_AOC: - case TRANSVR_CLASS_OPTICAL_1G_SX: - case TRANSVR_CLASS_OPTICAL_1G_LX: - case TRANSVR_CLASS_OPTICAL_1G_EX: - case TRANSVR_CLASS_OPTICAL_1G: - return snprintf(result, lmax, TRANSVR_IF_SP_1G); - /* 1G COPPER */ - case TRANSVR_CLASS_COPPER_L1_1G: - return snprintf(result, lmax, TRANSVR_IF_SP_1G); - /* 1G BASE_T */ - case TRANSVR_CLASS_BASE_T_1000: - return snprintf(result, lmax, TRANSVR_IF_SP_1G); - /* 100 Base */ - case TRANSVR_CLASS_OPTICAL_100: - return snprintf(result, lmax, TRANSVR_IF_SP_100); - default: - snprintf(err_msg, sizeof(err_msg), - "Detect undefined value:%d", - detect_val); - goto err_sfp_detect_if_speed_1; - } - /* Check by BR */ - detect_val = _sfp_detect_if_sp_by_br(self); - switch (detect_val) { - case TRANSVR_CLASS_25G: - return snprintf(result, lmax, TRANSVR_IF_SP_25G); - case TRANSVR_CLASS_10G: - return snprintf(result, lmax, TRANSVR_IF_SP_10G); - case TRANSVR_CLASS_1G: - return snprintf(result, lmax, TRANSVR_IF_SP_1G); - default: - break; - } - /* Exception case: Can't verify */ - snprintf(err_msg, sizeof(err_msg), "Can not identify!"); - goto err_sfp_detect_if_speed_1; - -err_sfp_detect_if_speed_1: - snprintf(result, lmax, TRANSVR_UEVENT_UNKNOW); - SWPS_INFO("%s %s\n :%s", __func__, err_msg, self->swp_name); - return ERR_TRANSVR_ABNORMAL; -} - - -int -sfp_get_if_speed(struct transvr_obj_s *self, - char *buf_p){ - - int lmax = 16; - char tmp_result[16] = DEBUG_TRANSVR_STR_VAL; - - if (self->state != STATE_TRANSVR_CONNECTED) { - return snprintf(buf_p, lmax, "%d\n", self->state); - } - if (_sfp_detect_if_speed(self, tmp_result) < 0) { - return snprintf(buf_p, lmax, "%d\n", ERR_TRANSVR_ABNORMAL); - } - return snprintf(buf_p, lmax, "%s\n", tmp_result); -} - - -int -_qsfp_detect_class_by_extend_comp(struct transvr_obj_s* self) { - /* Reference: SFF-8024 (v3.8) - */ - int detect_val = DEBUG_TRANSVR_INT_VAL; - - detect_val = _qsfp_get_comp_extended(self); - switch(detect_val) { - case 0x00: /* Unspecified */ - return TRANSVR_CLASS_UNSPECIFIED; - - case 0x01: /* 100G AOC (Active Optical Cable) or 25GAUI C2M */ - case 0x18: /* 100G AOC or 25GAUI C2M AOC. */ - return TRANSVR_CLASS_OPTICAL_100G_AOC; - - case 0x06: /* 100G CWDM4 */ - case 0x09: /* Obsolete (assigned before 100G CWDM4 MSA required FEC) */ - case 0x17: /* 100G CLR4 */ - case 0x1A: /* 100GE-DWDM2 */ - return TRANSVR_CLASS_OPTICAL_100G; - - case 0x02: /* 100GBASE-SR4 or 25GBASE-SR */ - return TRANSVR_CLASS_OPTICAL_100G_SR4; - - case 0x03: /* 100GBASE-LR4 or 25GBASE-LR */ - return TRANSVR_CLASS_OPTICAL_100G_LR4; - - case 0x04: /* 100GBASE-ER4 or 25GBASE-ER */ - return TRANSVR_CLASS_OPTICAL_100G_ER4; - - case 0x07: /* 100G PSM4 Parallel SMF */ - return TRANSVR_CLASS_OPTICAL_100G_PSM4; - - case 0x12: /* 40G PSM4 Parallel SMF */ - return TRANSVR_CLASS_OPTICAL_40G; - - case 0x11: /* 4 x 10GBASE-SR */ - return TRANSVR_CLASS_OPTICAL_40G_SR4; - - case 0x10: /* 40GBASE-ER4 */ - return TRANSVR_CLASS_OPTICAL_40G_ER4; - - case 0x08: /* 100G ACC (Active Copper Cable) or 25GAUI C2M ACC. */ - case 0x0b: /* 100GBASE-CR4 or 25GBASE-CR CA-L */ - case 0x19: /* 100G ACC or 25GAUI C2M ACC. */ - return TRANSVR_CLASS_COPPER_L4_100G; - - default: - break; - } - SWPS_INFO("%s: Unexcept value:0x%02x\n :%s", - __func__, detect_val, self->swp_name); - return TRANSVR_CLASS_ERROR; -} - - -int -_qsfp_detect_class_by_10_40_100_ethernet(struct transvr_obj_s* self) { - /* Reference: SFF-8472 (v12.2) - */ - int detect_val = DEBUG_TRANSVR_INT_VAL; - - detect_val = _qsfp_get_comp_10_40_100_ethernet(self); - /* Case: Unspecified */ - if (detect_val == 0x00) { - return TRANSVR_CLASS_UNSPECIFIED; - } - /* Case: 40G Optical */ - if ((detect_val & 0x01) == 0x01) { /* 00000001 : 40G Active Cable (XLPPI) */ - return TRANSVR_CLASS_OPTICAL_40G_AOC; - } - if ((detect_val & 0x04) == 0x04) { /* 00000100 : 40GBASE-SR4 */ - return TRANSVR_CLASS_OPTICAL_40G_SR4; - } - if ( (detect_val & 0x02) == 0x02) { /* 00000010 : 40GBASE-LR4 */ - return TRANSVR_CLASS_OPTICAL_40G_LR4; - } - if ( (detect_val & 0x08) == 0x08) { /* 00001000 : 40GBASE-CR4 */ - return TRANSVR_CLASS_COPPER_L4_40G; - } - /* Case: 10G Optical */ - if ( (detect_val & 0x10) == 0x10) { /* 00010000 : 10GBASE-SR */ - return TRANSVR_CLASS_OPTICAL_10G_Q_SR; - } - if ( ((detect_val & 0x20) == 0x20) || /* 00100000 : 10GBASE-LR */ - ((detect_val & 0x40) == 0x40) ){ /* 01000000 : 10GBASE-LRM */ - return TRANSVR_CLASS_OPTICAL_10G_Q_LR; - } - /* Case: Extend Compliance */ - if ( ((detect_val & 0x80) == 0x80) ){ /* 10000000 : Use Extend Compliance */ - return TRANSVR_CLASS_EXTEND_COMP; - } - /* Case: ERROR */ - SWPS_INFO("%s: Unexcept value:0x%02x\n :%s", - __func__, detect_val, self->swp_name); - return TRANSVR_CLASS_ERROR; -} - - -int -_qsfp_detect_if_sp_by_br(struct transvr_obj_s* self) { - - int lower_bound_10g = 0x10; - int upper_bound_10g = 0x25; - int lower_bound_40g = 0x60; - int upper_bound_40g = 0x75; - int lower_bound_100g = 0x60; - int upper_bound_100g = 0x75; - int used_extend_br = 0xff; - int notmal_br = DEBUG_TRANSVR_INT_VAL; - int extend_br = DEBUG_TRANSVR_INT_VAL; - - notmal_br = (int)(self->br); /* updated by update_all() */ - /* Check 40G */ - if ((notmal_br >= lower_bound_40g) && - (notmal_br <= upper_bound_40g) ) { - return TRANSVR_CLASS_40G; - } - /* Check 100G */ - if (notmal_br == used_extend_br) { - extend_br = (int)(self->extbr); /* updated by update_all() */ - if ((extend_br >= lower_bound_100g) && - (extend_br <= upper_bound_100g) ) { - return TRANSVR_CLASS_100G; - } - } - /* Check 10G */ - if ((notmal_br >= lower_bound_10g) && - (notmal_br <= upper_bound_10g) ) { - return TRANSVR_CLASS_10G; - } - return TRANSVR_CLASS_UNSPECIFIED; -} - - -int -_qsfp_detect_class_by_feature(struct transvr_obj_s* self) { - /* Reference: SFF-8024 (v3.8) - */ - int conn_val = DEBUG_TRANSVR_INT_VAL; - int wave_len = DEBUG_TRANSVR_INT_VAL; - int speed_val = DEBUG_TRANSVR_INT_VAL; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - - speed_val = _qsfp_detect_if_sp_by_br(self); - conn_val = _qsfp_get_connector_type(self); - - switch(conn_val) { - case 0x00: /* Unspecified */ - return TRANSVR_CLASS_UNSPECIFIED; - case 0x07: /* LC (Lucent Connector) */ - case 0x0b: /* Optical Pigtail */ - case 0x0c: /* MPO 1x12 (Multifiber Parallel Optic) */ - case 0x0d: /* MPO 2x16 */ - goto ok_qsfp_detect_class_by_feature_4_optiocal; - case 0x21: /* Copper pigtail */ - goto ok_qsfp_detect_class_by_feature_4_copper; - case 0x23: /* No separable connector */ - if ((_qsfp_get_comp_fc_link_length(self) > 0) || - (_qsfp_get_comp_fc_trans_tech(self) > 0) || - (_qsfp_get_comp_fc_trans_media(self) > 0) || - (_qsfp_get_comp_fc_speed(self) > 0) ) { - goto ok_qsfp_detect_class_by_feature_4_aoc; - } - goto ok_qsfp_detect_class_by_feature_4_copper; - default: - snprintf(err_msg, sizeof(err_msg), - "_qsfp_get_connector_type return Non define value:%d", - conn_val); - goto err_qsfp_detect_class_by_feature_1; - } - return TRANSVR_CLASS_UNSPECIFIED; - -ok_qsfp_detect_class_by_feature_4_optiocal: - wave_len = _common_count_wavelength(self, - self->wavelength[0], - self->wavelength[1]); - switch(speed_val) { - case TRANSVR_CLASS_100G: - switch (wave_len) { - case VAL_OPTICAL_WAVELENGTH_SR: - return TRANSVR_CLASS_OPTICAL_100G_SR4; - case VAL_OPTICAL_WAVELENGTH_LR: - return TRANSVR_CLASS_OPTICAL_100G_LR4; - case VAL_OPTICAL_WAVELENGTH_ER: - return TRANSVR_CLASS_OPTICAL_100G_ER4; - default: - break; - } - return TRANSVR_CLASS_OPTICAL_100G; - - case TRANSVR_CLASS_40G: - switch (wave_len) { - case VAL_OPTICAL_WAVELENGTH_SR: - return TRANSVR_CLASS_OPTICAL_40G_SR4; - case VAL_OPTICAL_WAVELENGTH_LR: - return TRANSVR_CLASS_OPTICAL_40G_LR4; - case VAL_OPTICAL_WAVELENGTH_ER: - return TRANSVR_CLASS_OPTICAL_40G_ER4; - default: - break; - } - return TRANSVR_CLASS_OPTICAL_40G; - - case TRANSVR_CLASS_10G: - switch (wave_len) { - case VAL_OPTICAL_WAVELENGTH_SR: - return TRANSVR_CLASS_OPTICAL_10G_Q_SR; - case VAL_OPTICAL_WAVELENGTH_LR: - return TRANSVR_CLASS_OPTICAL_10G_Q_LR; - case VAL_OPTICAL_WAVELENGTH_ER: - return TRANSVR_CLASS_OPTICAL_10G_Q_ER; - default: - break; - } - return TRANSVR_CLASS_OPTICAL_10G; - - default: - return TRANSVR_CLASS_OPTICAL; - } - -ok_qsfp_detect_class_by_feature_4_aoc: - switch(speed_val) { - case TRANSVR_CLASS_100G: - return TRANSVR_CLASS_OPTICAL_100G_AOC; - case TRANSVR_CLASS_40G: - return TRANSVR_CLASS_OPTICAL_40G_AOC; - case TRANSVR_CLASS_10G: - return TRANSVR_CLASS_OPTICAL_10G_Q_AOC; - default: - return TRANSVR_CLASS_OPTICAL; - } - -ok_qsfp_detect_class_by_feature_4_copper: - switch(speed_val) { - case TRANSVR_CLASS_100G: - return TRANSVR_CLASS_COPPER_L4_100G; - case TRANSVR_CLASS_40G: - return TRANSVR_CLASS_COPPER_L4_40G; - case TRANSVR_CLASS_10G: - return TRANSVR_CLASS_COPPER_L4_10G; - default: - return TRANSVR_CLASS_COPPER; - } - -err_qsfp_detect_class_by_feature_1: - SWPS_INFO("%s: %s\n :%s", - __func__, err_msg, self->swp_name); - return TRANSVR_CLASS_ERROR; -} - - -int -qsft_detect_transvr_class(struct transvr_obj_s* self) { - - int detect_val = DEBUG_TRANSVR_INT_VAL; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - - /* Check Extended Compliance */ - detect_val = _qsfp_detect_class_by_extend_comp(self); - switch (detect_val) { - case TRANSVR_CLASS_UNSPECIFIED: - break; - case TRANSVR_CLASS_OPTICAL_100G: - case TRANSVR_CLASS_OPTICAL_100G_AOC: - case TRANSVR_CLASS_OPTICAL_100G_SR4: - case TRANSVR_CLASS_OPTICAL_100G_LR4: - case TRANSVR_CLASS_OPTICAL_100G_ER4: - case TRANSVR_CLASS_OPTICAL_100G_PSM4: - case TRANSVR_CLASS_OPTICAL_40G: - case TRANSVR_CLASS_OPTICAL_40G_AOC: - case TRANSVR_CLASS_OPTICAL_40G_SR4: - case TRANSVR_CLASS_OPTICAL_40G_LR4: - case TRANSVR_CLASS_OPTICAL_40G_ER4: - case TRANSVR_CLASS_COPPER_L4_100G: - return detect_val; - default: - snprintf(err_msg, sizeof(err_msg), - "Detect undefined extend_comp:%d", - detect_val); - goto err_qsft_detect_transvr_class_1; - } - /* Check 10/40G/100G Ethernet Compliance */ - detect_val = _qsfp_detect_class_by_10_40_100_ethernet(self); - switch(detect_val) { - case TRANSVR_CLASS_UNSPECIFIED: - break; - case TRANSVR_CLASS_OPTICAL_40G_AOC: - case TRANSVR_CLASS_OPTICAL_40G_SR4: - case TRANSVR_CLASS_OPTICAL_40G_LR4: - case TRANSVR_CLASS_OPTICAL_10G_Q_SR: /* Need Check: SR4 or SR */ - case TRANSVR_CLASS_OPTICAL_10G_Q_LR: /* Need Check: SR4 or SR */ - case TRANSVR_CLASS_COPPER_L4_40G: - return detect_val; - case TRANSVR_CLASS_EXTEND_COMP: - /* Format incorrect case (We already checked the Extend - * Compliance is 0 - */ - snprintf(err_msg, sizeof(err_msg), - "Transceiver format incorrect"); - goto err_qsft_detect_transvr_class_1; - default: - snprintf(err_msg, sizeof(err_msg), - "Detect undefined 10/40/100:%d", - detect_val); - goto err_qsft_detect_transvr_class_1; - } - /* Check by Connector type, BR and wavelength */ - detect_val = _qsfp_detect_class_by_feature(self); - switch (detect_val) { - case TRANSVR_CLASS_UNSPECIFIED: - break; - case TRANSVR_CLASS_OPTICAL_100G_ER4: - case TRANSVR_CLASS_OPTICAL_100G_LR4: - case TRANSVR_CLASS_OPTICAL_100G_SR4: - case TRANSVR_CLASS_OPTICAL_100G_AOC: - case TRANSVR_CLASS_OPTICAL_100G: - case TRANSVR_CLASS_OPTICAL_40G_ER4: - case TRANSVR_CLASS_OPTICAL_40G_LR4: - case TRANSVR_CLASS_OPTICAL_40G_SR4: - case TRANSVR_CLASS_OPTICAL_40G_AOC: - case TRANSVR_CLASS_OPTICAL_40G: - case TRANSVR_CLASS_OPTICAL_10G_Q_ER: - case TRANSVR_CLASS_OPTICAL_10G_Q_LR: - case TRANSVR_CLASS_OPTICAL_10G_Q_SR: - case TRANSVR_CLASS_OPTICAL_10G_Q_AOC: - case TRANSVR_CLASS_OPTICAL_10G: - case TRANSVR_CLASS_OPTICAL: - case TRANSVR_CLASS_COPPER_L4_100G: - case TRANSVR_CLASS_COPPER_L4_40G: - case TRANSVR_CLASS_COPPER_L4_10G: - case TRANSVR_CLASS_COPPER: - return detect_val; - default: - snprintf(err_msg, sizeof(err_msg), - "Detect undefined connector:%d", - detect_val); - goto err_qsft_detect_transvr_class_1; - } - /* Exception case: Can't verify */ - snprintf(err_msg, sizeof(err_msg), - "Can not identify!"); - goto err_qsft_detect_transvr_class_1; - -err_qsft_detect_transvr_class_1: - SWPS_INFO("%s: %s\n :%s", __func__, err_msg, self->swp_name); - return TRANSVR_CLASS_ERROR; -} - - -int -_qsfp_set_trident2_if_type(struct transvr_obj_s* self, - int transvr_cls, - char *result){ - - int lmax = 8; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - - switch (transvr_cls) { - case TRANSVR_CLASS_UNSPECIFIED: - case TRANSVR_CLASS_ERROR: - break; - /* 100G Optical */ - case TRANSVR_CLASS_OPTICAL_100G: - case TRANSVR_CLASS_OPTICAL_100G_AOC: - case TRANSVR_CLASS_OPTICAL_100G_SR4: - case TRANSVR_CLASS_OPTICAL_100G_LR4: - case TRANSVR_CLASS_OPTICAL_100G_ER4: - case TRANSVR_CLASS_OPTICAL_100G_PSM4: - return snprintf(result, lmax, TRANSVR_IF_SR4); - /* 100G Copper */ - case TRANSVR_CLASS_COPPER_L4_100G: - return snprintf(result, lmax, TRANSVR_IF_KR4); - /* 40G Optical */ - case TRANSVR_CLASS_OPTICAL_40G: - case TRANSVR_CLASS_OPTICAL_40G_AOC: - case TRANSVR_CLASS_OPTICAL_40G_SR4: - case TRANSVR_CLASS_OPTICAL_40G_LR4: - case TRANSVR_CLASS_OPTICAL_40G_ER4: - return snprintf(result, lmax, TRANSVR_IF_IF_XGMII); - /* 40G Copper */ - case TRANSVR_CLASS_COPPER_L4_40G: - return snprintf(result, lmax, TRANSVR_IF_IF_XGMII); - /* 10G Optical */ - case TRANSVR_CLASS_OPTICAL_10G: - case TRANSVR_CLASS_OPTICAL_10G_Q_AOC: - case TRANSVR_CLASS_OPTICAL_10G_Q_SR: /* Need Check: SR4 or SR */ - case TRANSVR_CLASS_OPTICAL_10G_Q_LR: /* Need Check: LR4 or LR */ - case TRANSVR_CLASS_OPTICAL_10G_Q_ER: /* Need Check: ER4 or ER */ - return snprintf(result, lmax, TRANSVR_IF_IF_XGMII); - /* Optical */ - case TRANSVR_CLASS_OPTICAL: - return snprintf(result, lmax, TRANSVR_IF_IF_XGMII); - /* Copper */ - case TRANSVR_CLASS_COPPER: - return snprintf(result, lmax, TRANSVR_IF_IF_XGMII); - default: - snprintf(err_msg, sizeof(err_msg), - "Detect undefined value:%d", - transvr_cls); - goto err_qsfp_set_trident2_if_type_1; - } - /* Exception case: Can't verify */ - snprintf(err_msg, sizeof(err_msg), "Can not identify!"); - goto err_qsfp_set_trident2_if_type_1; - -err_qsfp_set_trident2_if_type_1: - snprintf(result, lmax, TRANSVR_UEVENT_UNKNOW); - SWPS_INFO("%s: %s\n :%s", __func__, err_msg, self->swp_name); - return ERR_TRANSVR_ABNORMAL; -} - - -int -_qsfp_set_tomahawk_if_type(struct transvr_obj_s* self, - int transvr_cls, - char *result){ - - int lmax = 8; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - - switch (transvr_cls) { - case TRANSVR_CLASS_UNSPECIFIED: - case TRANSVR_CLASS_ERROR: - break; - /* 100G Optical */ - case TRANSVR_CLASS_OPTICAL_100G: - case TRANSVR_CLASS_OPTICAL_100G_AOC: - case TRANSVR_CLASS_OPTICAL_100G_SR4: - case TRANSVR_CLASS_OPTICAL_100G_LR4: - case TRANSVR_CLASS_OPTICAL_100G_ER4: - case TRANSVR_CLASS_OPTICAL_100G_PSM4: - return snprintf(result, lmax, TRANSVR_IF_SR4); - /* 100G Copper */ - case TRANSVR_CLASS_COPPER_L4_100G: - return snprintf(result, lmax, TRANSVR_IF_KR4); - /* 40G Optical */ - case TRANSVR_CLASS_OPTICAL_40G: - case TRANSVR_CLASS_OPTICAL_40G_AOC: - case TRANSVR_CLASS_OPTICAL_40G_SR4: - case TRANSVR_CLASS_OPTICAL_40G_LR4: - case TRANSVR_CLASS_OPTICAL_40G_ER4: - return snprintf(result, lmax, TRANSVR_IF_SR4); - /* 40G Copper */ - case TRANSVR_CLASS_COPPER_L4_40G: - return snprintf(result, lmax, TRANSVR_IF_KR4); - /* 10G Optical */ - case TRANSVR_CLASS_OPTICAL_10G: - case TRANSVR_CLASS_OPTICAL_10G_Q_AOC: - case TRANSVR_CLASS_OPTICAL_10G_Q_SR: /* Need Check: SR4 or SR */ - case TRANSVR_CLASS_OPTICAL_10G_Q_LR: /* Need Check: SR4 or SR */ - case TRANSVR_CLASS_OPTICAL_10G_Q_ER: - return snprintf(result, lmax, TRANSVR_IF_SR4); - /* Optical */ - case TRANSVR_CLASS_OPTICAL: - return snprintf(result, lmax, TRANSVR_IF_SR4); - /* Copper */ - case TRANSVR_CLASS_COPPER: - return snprintf(result, lmax, TRANSVR_IF_KR4); - default: - snprintf(err_msg, sizeof(err_msg), - "Detect undefined value:%d", - transvr_cls); - goto err_qsfp_set_trident2_if_type_1; - } - /* Exception case: Can't verify */ - snprintf(err_msg, sizeof(err_msg), "Can not identify!"); - goto err_qsfp_set_trident2_if_type_1; - -err_qsfp_set_trident2_if_type_1: - snprintf(result, lmax, TRANSVR_UEVENT_UNKNOW); - SWPS_INFO("%s: %s\n :%s", __func__, err_msg, self->swp_name); - return ERR_TRANSVR_ABNORMAL; -} - - -int -_qsfp_detect_if_type(struct transvr_obj_s* self, - char *result){ - - int lmax = 8; - int detect_cls = DEBUG_TRANSVR_INT_VAL; - - detect_cls = qsft_detect_transvr_class(self); - switch (self->chipset_type) { - case BCM_CHIP_TYPE_TRIDENT_2: - return _qsfp_set_trident2_if_type(self, detect_cls, result); - - case BCM_CHIP_TYPE_TOMAHAWK: - return _qsfp_set_tomahawk_if_type(self, detect_cls, result); - - default: - SWPS_INFO("%s: non-defined chipset_type:%d :%s\n", - __func__, self->chipset_type, self->swp_name); - break; - } - snprintf(result, lmax, TRANSVR_UEVENT_UNKNOW); - return ERR_TRANSVR_ABNORMAL; -} - - -int -qsfp_get_if_type(struct transvr_obj_s *self, - char *buf_p){ - - int lmax = 8; - char tmp_result[8] = DEBUG_TRANSVR_STR_VAL; - - if (self->state != STATE_TRANSVR_CONNECTED) { - return snprintf(buf_p, lmax, "%d\n", self->state); - } - if (_qsfp_detect_if_type(self, tmp_result) < 0) { - return snprintf(buf_p, lmax, "%d\n", ERR_TRANSVR_ABNORMAL); - } - return snprintf(buf_p, lmax, "%s\n", tmp_result); -} - - -int -_qsfp_detect_if_speed(struct transvr_obj_s* self, - char *result){ - int lmax = 16; - int detect_val = DEBUG_TRANSVR_INT_VAL; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - - detect_val = qsft_detect_transvr_class(self); - switch (detect_val) { - case TRANSVR_CLASS_UNSPECIFIED: - case TRANSVR_CLASS_ERROR: - break; - /* 100G Optical */ - case TRANSVR_CLASS_OPTICAL_100G: - case TRANSVR_CLASS_OPTICAL_100G_AOC: - case TRANSVR_CLASS_OPTICAL_100G_SR4: - case TRANSVR_CLASS_OPTICAL_100G_LR4: - case TRANSVR_CLASS_OPTICAL_100G_ER4: - case TRANSVR_CLASS_OPTICAL_100G_PSM4: - return snprintf(result, lmax, TRANSVR_IF_SP_100G); - /* 100G Copper */ - case TRANSVR_CLASS_COPPER_L4_100G: - return snprintf(result, lmax, TRANSVR_IF_SP_100G); - /* 40G Optical */ - case TRANSVR_CLASS_OPTICAL_40G: - case TRANSVR_CLASS_OPTICAL_40G_AOC: - case TRANSVR_CLASS_OPTICAL_40G_SR4: - case TRANSVR_CLASS_OPTICAL_40G_LR4: - case TRANSVR_CLASS_OPTICAL_40G_ER4: - return snprintf(result, lmax, TRANSVR_IF_SP_40G); - /* 40G Copper */ - case TRANSVR_CLASS_COPPER_L4_40G: - return snprintf(result, lmax, TRANSVR_IF_SP_40G); - /* 10G Optical */ - case TRANSVR_CLASS_OPTICAL_10G: - case TRANSVR_CLASS_OPTICAL_10G_Q_AOC: - case TRANSVR_CLASS_OPTICAL_10G_Q_SR: /* Need Check: SR4 or SR */ - case TRANSVR_CLASS_OPTICAL_10G_Q_LR: /* Need Check: SR4 or SR */ - case TRANSVR_CLASS_OPTICAL_10G_Q_ER: - return snprintf(result, lmax, TRANSVR_IF_SP_10G); - /* 10G Copper */ - case TRANSVR_CLASS_COPPER_L4_10G: - return snprintf(result, lmax, TRANSVR_IF_SP_10G); - /* Optical */ - case TRANSVR_CLASS_OPTICAL: - break; - /* Copper */ - case TRANSVR_CLASS_COPPER: - break; - default: - snprintf(err_msg, sizeof(err_msg), - "Detect undefined class case:%d", - detect_val); - goto err_qsfp_detect_if_speed_1; - } - /* Check br and extbr */ - detect_val = _qsfp_detect_if_sp_by_br(self); - switch(detect_val) { - case TRANSVR_CLASS_UNSPECIFIED: - break; - case TRANSVR_CLASS_10G: - return snprintf(result, lmax, TRANSVR_IF_SP_10G); - case TRANSVR_CLASS_40G: - return snprintf(result, lmax, TRANSVR_IF_SP_40G); - case TRANSVR_CLASS_100G: - return snprintf(result, lmax, TRANSVR_IF_SP_100G); - default: - snprintf(err_msg, sizeof(err_msg), - "Detect undefined BR case:%d", - detect_val); - goto err_qsfp_detect_if_speed_1; - } - /* Exception case: Can't verify */ - snprintf(err_msg, sizeof(err_msg), "Can not identify!"); - goto err_qsfp_detect_if_speed_1; - -err_qsfp_detect_if_speed_1: - snprintf(result, lmax, TRANSVR_UEVENT_UNKNOW); - SWPS_INFO("%s: %s :%s\n", __func__, err_msg, self->swp_name); - return ERR_TRANSVR_ABNORMAL; -} - - -int -qsfp_get_if_speed(struct transvr_obj_s *self, - char *buf_p){ - - int lmax = 16; - char tmp_result[16] = DEBUG_TRANSVR_STR_VAL; - - if (self->state != STATE_TRANSVR_CONNECTED) { - return snprintf(buf_p, lmax, "%d\n", self->state); - } - if (_qsfp_detect_if_speed(self, tmp_result) < 0) { - return snprintf(buf_p, lmax, "%d\n", ERR_TRANSVR_ABNORMAL); - } - return snprintf(buf_p, lmax, "%s\n", tmp_result); -} - - -int -_common_set_lane_map_str(struct transvr_obj_s* self, - char *result) { - int i = 0; - int tmp_val = 0; - char tmp_str[LEN_TRANSVR_L_STR] = DEBUG_TRANSVR_STR_VAL; - char err_msg[LEN_TRANSVR_L_STR] = DEBUG_TRANSVR_STR_VAL; - - memset(result, 0, LEN_TRANSVR_L_STR); - snprintf(result, LEN_TRANSVR_L_STR, "%s=", TRANSVR_UEVENT_KEY_LANE); - - for (i=0; ilane_id); i++) { - tmp_val = self->lane_id[i]; - if (tmp_val < 1) { - break; - } - if (tmp_val > 256) { - snprintf(err_msg, sizeof(err_msg), - "detect abnormal value:%d", tmp_val); - goto err_common_set_lane_map_str_1; - } - memset(tmp_str, 0, sizeof(tmp_str)); - if (i == 0) { - snprintf(tmp_str, LEN_TRANSVR_L_STR, "%d", tmp_val); - } else { - snprintf(tmp_str, LEN_TRANSVR_L_STR, ",%d", tmp_val); - } - strncat(result, tmp_str, LEN_TRANSVR_L_STR); - } - if (i == 0) { - goto err_common_set_lane_map_str_2; - } - return 0; - -err_common_set_lane_map_str_1: - SWPS_INFO("%s: %s", __func__, err_msg); -err_common_set_lane_map_str_2: - snprintf(result, LEN_TRANSVR_L_STR, "%s=%s", TRANSVR_UEVENT_KEY_LANE, TRANSVR_UEVENT_UNKNOW); - return EVENT_TRANSVR_TASK_FAIL; -} - - -int -_common_send_uevent(struct transvr_obj_s* self, - enum kobject_action u_action, - int (*detect_if_type)(struct transvr_obj_s *self, char *result), - int (*detect_if_speed)(struct transvr_obj_s *self, char *result), - int send_anyway) { - - char *uevent_envp[4]; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - char tmp_str[32] = DEBUG_TRANSVR_STR_VAL; - char tmp_str_1[32] = DEBUG_TRANSVR_STR_VAL; - char tmp_str_2[32] = DEBUG_TRANSVR_STR_VAL; - char tmp_str_3[64] = DEBUG_TRANSVR_STR_VAL; - - if (TRANSVR_UEVENT_ENABLE != 1) { - return ERR_TRANSVR_NOTSUPPORT; - } - if (_common_get_if_lane(self, tmp_str) < 0) { - snprintf(tmp_str_3, sizeof(tmp_str_3), - "%s=%s", TRANSVR_UEVENT_KEY_LANE, TRANSVR_UEVENT_UNKNOW); - } else { - snprintf(tmp_str_3, sizeof(tmp_str_3), - "%s=%s", TRANSVR_UEVENT_KEY_LANE, tmp_str); - } - switch (u_action) { - case KOBJ_ADD: - /* Detect type */ - if (detect_if_type(self, tmp_str) < 0) { - snprintf(err_msg, sizeof(err_msg), "%s", "Detect interface type fail!"); - snprintf(tmp_str_1, sizeof(tmp_str_1), "%s=%s", TRANSVR_UEVENT_KEY_IF, TRANSVR_UEVENT_UNKNOW); - snprintf(tmp_str_2, sizeof(tmp_str_2), "%s=%s", TRANSVR_UEVENT_KEY_SP, TRANSVR_UEVENT_UNKNOW); - uevent_envp[0] = tmp_str_1; - uevent_envp[1] = tmp_str_2; - uevent_envp[2] = tmp_str_3; - uevent_envp[3] = NULL; - goto private_common_send_uevent_4_fail; - } - snprintf(tmp_str_1, sizeof(tmp_str_1), "%s=%s", TRANSVR_UEVENT_KEY_IF, tmp_str); - uevent_envp[0] = tmp_str_1; - /* Detect speed */ - if (detect_if_speed(self, tmp_str) < 0) { - snprintf(err_msg, sizeof(err_msg), "%s", "Detect interface speed fail!"); - snprintf(tmp_str_2, sizeof(tmp_str_2), "%s=%s", TRANSVR_UEVENT_KEY_SP, TRANSVR_UEVENT_UNKNOW); - uevent_envp[1] = tmp_str_2; - uevent_envp[2] = tmp_str_3; - uevent_envp[3] = NULL; - goto private_common_send_uevent_4_fail; - } - snprintf(tmp_str_2, sizeof(tmp_str_2), "%s=%s", TRANSVR_UEVENT_KEY_SP, tmp_str); - uevent_envp[1] = tmp_str_2; - uevent_envp[2] = tmp_str_3; - uevent_envp[3] = NULL; - goto private_common_send_uevent_4_send; - - case KOBJ_REMOVE: - snprintf(tmp_str_1, sizeof(tmp_str_1), "%s=%s", TRANSVR_UEVENT_KEY_IF, TRANSVR_UEVENT_UNKNOW); - snprintf(tmp_str_2, sizeof(tmp_str_2), "%s=%s", TRANSVR_UEVENT_KEY_SP, TRANSVR_UEVENT_UNKNOW); - uevent_envp[0] = tmp_str_1; - uevent_envp[1] = tmp_str_2; - uevent_envp[2] = tmp_str_3; - uevent_envp[3] = NULL; - goto private_common_send_uevent_4_send; - - default: - snprintf(err_msg, sizeof(err_msg), "kobject_action:%d not support", u_action); - goto private_common_send_uevent_4_fail; - } - snprintf(err_msg, sizeof(err_msg), "%s", "Exception case"); - goto private_common_send_uevent_4_fail; - -private_common_send_uevent_4_fail: - SWPS_INFO("%s: %s :%s\n", __func__, err_msg, self->swp_name); - if (send_anyway) { - goto private_common_send_uevent_4_send; - } - return ERR_TRANSVR_UEVENT_FAIL; - -private_common_send_uevent_4_send: - return kobject_uevent_env(&(self->transvr_dev_p->kobj), - u_action, - uevent_envp); -} - -int -sfp_send_uevent(struct transvr_obj_s* self, - enum kobject_action u_action) { - int send_anyway = 1; - return _common_send_uevent(self, - u_action, - &_sfp_detect_if_type, - &_sfp_detect_if_speed, - send_anyway); -} - - -int -qsfp_send_uevent(struct transvr_obj_s* self, - enum kobject_action u_action) { - int send_anyway = 1; - return _common_send_uevent(self, - u_action, - &_qsfp_detect_if_type, - &_qsfp_detect_if_speed, - send_anyway); -} - - -int -fake_send_uevent(struct transvr_obj_s* self, - enum kobject_action u_action) { - return EVENT_TRANSVR_TASK_DONE; -} - - -int -common_fsm_4_direct_mode(struct transvr_obj_s* self, - char *caller_name){ - - int err; - int detect_result[2]; - int current_state = STATE_TRANSVR_UNEXCEPTED; - int current_type = TRANSVR_TYPE_ERROR; - - if (self->state == STATE_TRANSVR_NEW) { - if (_transvr_init_handler(self) < 0){ - return ERR_TRANSVR_INIT_FAIL; - } - } - err = detect_transvr_state(self, detect_result); - if (err < 0) { - return err; - } - /* In Direct mode, driver only detect transceiver when user call driver interface - * which on sysfs. So it only need consider the state of Transceiver. - */ - current_state = detect_result[0]; - current_type = detect_result[1]; - - switch (current_state){ - - case STATE_TRANSVR_DISCONNECTED: /* Transceiver is not plugged */ - self->state = current_state; - self->type = current_type; - return ERR_TRANSVR_UNPLUGGED; - - case STATE_TRANSVR_INIT: /* Transceiver is plugged, system not ready */ - return ERR_TRANSVR_UNINIT; - - case STATE_TRANSVR_ISOLATED: /* Transceiver is plugged, but has some issues */ - return ERR_TRNASVR_BE_ISOLATED; - - case STATE_TRANSVR_CONNECTED: /* Transceiver is plugged, system is ready */ - self->state = current_state; - self->type = current_type; - return 0; - - case STATE_TRANSVR_SWAPPED: /* Transceiver is plugged, system detect user changed */ - self->type = current_type; - if (reload_transvr_obj(self, current_type) < 0){ - self->state = STATE_TRANSVR_UNEXCEPTED; - return ERR_TRANSVR_UNEXCPT; - } - self->state = current_state; - return 0; - - case STATE_TRANSVR_UNEXCEPTED: /* Transceiver type or state is unexpected case */ - self->state = STATE_TRANSVR_UNEXCEPTED; - self->type = TRANSVR_TYPE_ERROR; - return ERR_TRANSVR_UNEXCPT; - - default: - SWPS_INFO("%s: state:%d not in define.\n", __func__, current_state); - break; - } - return ERR_TRANSVR_UNEXCPT; -} - - -static int -_is_except_happened_4_pmode(struct transvr_obj_s* self, - int new_state) { - - int event_chk = 0; - - if (self->temp == 0){ - return 0; - } - switch (new_state) { - case STATE_TRANSVR_INIT: - event_chk = EVENT_TRANSVR_EXCEP_INIT; - goto check_event_happened_4_pmode; - - case STATE_TRANSVR_CONNECTED: - event_chk = EVENT_TRANSVR_EXCEP_UP; - goto check_event_happened_4_pmode; - - case STATE_TRANSVR_DISCONNECTED: - event_chk = EVENT_TRANSVR_EXCEP_DOWN; - goto check_event_happened_4_pmode; - - case STATE_TRANSVR_SWAPPED: - event_chk = EVENT_TRANSVR_EXCEP_SWAP; - goto check_event_happened_4_pmode; - - case STATE_TRANSVR_UNEXCEPTED: - event_chk = EVENT_TRANSVR_EXCEP_EXCEP; - goto check_event_happened_4_pmode; - - case STATE_TRANSVR_ISOLATED: - event_chk = EVENT_TRANSVR_EXCEP_ISOLATED; - goto check_event_happened_4_pmode; - - default: - SWPS_INFO("%s: unexcepted case:%d\n", __func__, new_state); - break; - } - return 0; - -check_event_happened_4_pmode: - if (self->temp == event_chk){ - return 1; - } - return 0; -} - - -int -common_fsm_4_polling_mode(struct transvr_obj_s* self, - char *caller_name){ - /* [Return Value]: - * ERR_TRANSVR_UNINIT : (1) Initial not ready - * ERR_TRANSVR_UNPLUGGED : (1) Any -> Down - * ERR_TRANSVR_TASK_BUSY : (1) Wait Initial task - * ERR_TRANSVR_UNEXCPT : (1) Initial fail - * (2) Task fail - * (3) Reload fail - * ERR_TRNASVR_BE_ISOLATED : (1) Already be isolated - * OK Case (return 0) : (1) action_4_connected - * (2) action_4_nothing (initial retry) - */ - int curr_state[2]; - int old_state = self->state; - int old_type = self->type; - int new_state = STATE_TRANSVR_UNEXCEPTED; - int new_type = TRANSVR_TYPE_ERROR; - int return_val = ERR_TRANSVR_UNEXCPT; - - /* Never initial */ - if (self->state == STATE_TRANSVR_NEW) { - goto comfsm_action_4_reinit_obj; - } - /* Detect current state */ - switch (detect_transvr_state(self, curr_state)) { - case 0: - new_state = curr_state[0]; - new_type = curr_state[1]; - break; - - case ERR_TRNASVR_BE_ISOLATED: - new_state = STATE_TRANSVR_ISOLATED; - new_type = old_type; - break; - - case ERR_TRANSVR_I2C_CRASH: - goto comfsm_action_4_report_i2c_crash; - - case ERR_TRANSVR_UNEXCPT: - default: - new_state = STATE_TRANSVR_UNEXCEPTED; - new_type = old_type; - } - /* State handling */ - switch (old_state) { - case STATE_TRANSVR_INIT: /* INIT -> */ - return_val = ERR_TRANSVR_UNINIT; - goto comfsm_action_4_keep_state; - - case STATE_TRANSVR_CONNECTED: - switch (new_state) { - case STATE_TRANSVR_INIT: /* Case 1-1: UP -> INIT */ - SWPS_INFO("Detect %s is present. :1-1\n",self->swp_name); - return_val = ERR_TRANSVR_UNINIT; - goto comfsm_action_4_keep_state; - - case STATE_TRANSVR_CONNECTED: /* Case 1-2: UP -> UP */ - return_val = 0; - goto comfsm_action_4_keep_state; - - case STATE_TRANSVR_DISCONNECTED: /* Case 1-3: UP -> DOWN */ - SWPS_INFO("Detect %s is removed. :1-3\n",self->swp_name); - goto comfsm_action_4_disconnected; - - case STATE_TRANSVR_SWAPPED: /* Case 1-4: UP -> SWAP */ - SWPS_INFO("Detect %s is swapped. :1-4\n",self->swp_name); - goto comfsm_action_4_reload_obj; - - case STATE_TRANSVR_UNEXCEPTED: /* Case 1-5: UP -> UNEXPET */ - SWPS_INFO("Detect %s has error. :1-5\n",self->swp_name); - goto comfsm_action_4_unexpected; - - case STATE_TRANSVR_ISOLATED: /* Case 1-6: UP -> ISOLATE */ - SWPS_INFO("Detect %s be isolated. :1-6\n",self->swp_name); - goto comfsm_action_4_isolate_obj; - - default: - break; - } - goto comfsm_action_4_unexpected; - - case STATE_TRANSVR_DISCONNECTED: - switch (new_state) { - case STATE_TRANSVR_INIT: /* Case 2-1: DOWN -> INIT */ - SWPS_INFO("Detect %s is present. :2-1\n",self->swp_name); - return_val = ERR_TRANSVR_UNINIT; - goto comfsm_action_4_keep_state; - - case STATE_TRANSVR_CONNECTED: /* Case 2-2: DOWN -> UP */ - SWPS_INFO("Detect %s is present. :2-2\n",self->swp_name); - goto comfsm_action_4_reinit_obj; - - case STATE_TRANSVR_DISCONNECTED: /* Case 2-3: DOWN -> DOWN */ - return_val = ERR_TRANSVR_UNPLUGGED; - goto comfsm_action_4_keep_state; - - case STATE_TRANSVR_SWAPPED: /* Case 2-4: DOWN -> SWAP */ - SWPS_INFO("Detect %s is swapped. :2-4\n",self->swp_name); - goto comfsm_action_4_reload_obj; - - case STATE_TRANSVR_UNEXCEPTED: /* Case 2-5: DOWN -> UNEXPET */ - SWPS_INFO("Detect %s has error. :2-5\n",self->swp_name); - goto comfsm_action_4_unexpected; - - case STATE_TRANSVR_ISOLATED: /* Case 2-6: DOWN -> ISOLATE */ - SWPS_INFO("Detect %s be isolated. :2-6\n",self->swp_name); - goto comfsm_action_4_isolate_obj; - - default: - break; - } - goto comfsm_action_4_unexpected; - - case STATE_TRANSVR_UNEXCEPTED: - /* Filter out re-action */ - if (_is_except_happened_4_pmode(self, new_state)) { - goto comfsm_action_4_keep_state; - } - /* First action */ - switch (new_state) { - case STATE_TRANSVR_INIT: /* Case 3-1: UNEXPET -> INIT */ - SWPS_INFO("Detect %s is present. :3-1\n",self->swp_name); - self->temp = EVENT_TRANSVR_EXCEP_INIT; - return_val = ERR_TRANSVR_UNINIT; - goto comfsm_action_4_keep_state; - - case STATE_TRANSVR_CONNECTED: /* Case 3-2: UNEXPET -> UP */ - SWPS_INFO("Detect %s is present. :3-2\n",self->swp_name); - self->temp = EVENT_TRANSVR_EXCEP_UP; - goto comfsm_action_4_reload_obj; - - case STATE_TRANSVR_DISCONNECTED: /* Case 3-3: UNEXPET -> DOWN */ - SWPS_INFO("Detect %s is removed. :3-3\n",self->swp_name); - goto comfsm_action_4_disconnected; - - case STATE_TRANSVR_SWAPPED: /* Case 3-4: UNEXPET -> SWAP */ - SWPS_INFO("Detect %s is swapped. :3-4\n",self->swp_name); - self->temp = EVENT_TRANSVR_EXCEP_SWAP; - goto comfsm_action_4_reload_obj; - - case STATE_TRANSVR_UNEXCEPTED: /* Case 3-5: UNEXPET -> UNEXPET */ - self->temp = EVENT_TRANSVR_EXCEP_EXCEP; - return_val = ERR_TRANSVR_UNEXCPT; - goto comfsm_action_4_keep_state; - - case STATE_TRANSVR_ISOLATED: /* Case 3-6: UNEXPET -> ISOLATE */ - SWPS_INFO("Detect %s be isolated. :3-6\n",self->swp_name); - goto comfsm_action_4_isolate_obj; - - default: - break; - } - goto comfsm_action_4_unexpected; - - case STATE_TRANSVR_ISOLATED: - /* Filter out re-action */ - if (_is_except_happened_4_pmode(self, new_state)) { - goto comfsm_action_4_keep_state; - } - /* First action */ - switch (new_state) { - case STATE_TRANSVR_INIT: /* Case 4-1: ISOLATE -> INIT */ - SWPS_INFO("Detect %s internal error. :4-1\n",self->swp_name); - self->temp = EVENT_TRANSVR_EXCEP_INIT; - return_val = ERR_TRNASVR_BE_ISOLATED; - goto comfsm_action_4_keep_state; - - case STATE_TRANSVR_CONNECTED: /* Case 4-2: ISOLATE -> UP */ - SWPS_INFO("Detect %s internal error. :4-2\n",self->swp_name); - self->temp = EVENT_TRANSVR_EXCEP_UP; - return_val = ERR_TRNASVR_BE_ISOLATED; - goto comfsm_action_4_keep_state; - - case STATE_TRANSVR_DISCONNECTED: /* Case 4-3: ISOLATE -> DOWN */ - SWPS_INFO("Detect %s is removed. :4-3\n",self->swp_name); - goto comfsm_action_4_disconnected; - - case STATE_TRANSVR_SWAPPED: /* Case 4-4: ISOLATE -> SWAP */ - SWPS_INFO("Detect %s internal error. :4-4\n",self->swp_name); - self->temp = EVENT_TRANSVR_EXCEP_SWAP; - return_val = ERR_TRNASVR_BE_ISOLATED; - goto comfsm_action_4_keep_state; - - case STATE_TRANSVR_UNEXCEPTED: /* Case 4-5: ISOLATE -> UNEXPET */ - SWPS_INFO("Detect %s internal error. :4-5\n",self->swp_name); - self->temp = EVENT_TRANSVR_EXCEP_EXCEP; - return_val = ERR_TRNASVR_BE_ISOLATED; - goto comfsm_action_4_keep_state; - - case STATE_TRANSVR_ISOLATED: /* Case 4-6: ISOLATE -> ISOLATE */ - return_val = ERR_TRNASVR_BE_ISOLATED; - goto comfsm_action_4_keep_state; - - default: - break; - } - goto comfsm_action_4_unexpected; - - default: - break; - } - goto comfsm_action_4_unexpected; - - -comfsm_action_4_keep_state: - return return_val; - -comfsm_action_4_reinit_obj: - SWPS_DEBUG("FSM action: %s re-initial.\n", self->swp_name); - return_val = _transvr_init_handler(self); - goto comfsm_action_4_identify_event; - -comfsm_action_4_reload_obj: - SWPS_DEBUG("FSM action: %s reload.\n", self->swp_name); - self->type = new_type; - return_val = reload_transvr_obj(self, new_type); - goto comfsm_action_4_identify_event; - -comfsm_action_4_identify_event: - switch (return_val) { - case EVENT_TRANSVR_INIT_UP: - case EVENT_TRANSVR_TASK_DONE: - goto comfsm_action_4_connected; - - case EVENT_TRANSVR_INIT_DOWN: - goto comfsm_action_4_disconnected; - - case EVENT_TRANSVR_INIT_REINIT: - goto comfsm_action_4_nothing; - - case EVENT_TRANSVR_TASK_WAIT: - self->state = STATE_TRANSVR_INIT; - return ERR_TRANSVR_TASK_BUSY; - - case EVENT_TRANSVR_TASK_FAIL: - SWPS_INFO("%s detect EVENT_TRANSVR_TASK_FAIL.\n", self->swp_name); - goto comfsm_action_4_unexpected; - - case EVENT_TRANSVR_INIT_FAIL: - SWPS_INFO("%s detect EVENT_TRANSVR_INIT_FAIL.\n", self->swp_name); - goto comfsm_action_4_unexpected; - - case EVENT_TRANSVR_RELOAD_FAIL: - SWPS_INFO("%s detect EVENT_TRANSVR_RELOAD_FAIL.\n", self->swp_name); - goto comfsm_action_4_unexpected; - - case EVENT_TRANSVR_I2C_CRASH: - goto comfsm_action_4_report_i2c_crash; - - case EVENT_TRANSVR_EXCEP_ISOLATED: - goto comfsm_action_4_isolate_obj; - - default: - SWPS_INFO("%s detect undefined event:%d.\n", self->swp_name, return_val); - goto comfsm_action_4_unexpected; - } - -comfsm_action_4_nothing: - SWPS_DEBUG("FSM action: %s do nothing.\n", self->swp_name); - return 0; - -comfsm_action_4_connected: - SWPS_DEBUG("FSM action: %s Connected.\n", self->swp_name); - self->state = STATE_TRANSVR_CONNECTED; - self->type = new_type; - self->send_uevent(self, KOBJ_ADD); - _transvr_clean_retry(self); - return 0; - -comfsm_action_4_disconnected: - SWPS_DEBUG("FSM action: %s Disconnected. \n", self->swp_name); - self->state = STATE_TRANSVR_DISCONNECTED; - self->temp = EVENT_TRANSVR_TASK_DONE; - self->send_uevent(self, KOBJ_REMOVE); - _transvr_clean_retry(self); - _transvr_clean_handler(self); - return ERR_TRANSVR_UNPLUGGED; - -comfsm_action_4_report_i2c_crash: - SWPS_DEBUG("FSM action: %s report I2C crash.\n", self->swp_name); - self->state = STATE_TRANSVR_UNEXCEPTED; - return ERR_TRANSVR_I2C_CRASH; - -comfsm_action_4_isolate_obj: - SWPS_DEBUG("FSM action: %s isolate.\n", self->swp_name); - self->state = STATE_TRANSVR_ISOLATED; - return ERR_TRNASVR_BE_ISOLATED; - -comfsm_action_4_unexpected: - SWPS_INFO("FSM action: %s unexpected.\n", self->swp_name); - SWPS_INFO("Dump: :%d :0x%02x :%d :0x%02x\n", - old_state, old_type, new_state, new_type); - self->state = STATE_TRANSVR_UNEXCEPTED; - self->send_uevent(self, KOBJ_REMOVE); - _transvr_clean_handler(self); - return ERR_TRANSVR_UNEXCPT; -} - - -int -fake_fsm_4_direct_mode(struct transvr_obj_s* self, - char *caller_name){ - self->state = STATE_TRANSVR_CONNECTED; - self->type = TRANSVR_TYPE_FAKE; - return 0; -} - - -int -fake_fsm_4_polling_mode(struct transvr_obj_s* self, - char *caller_name){ - self->state = STATE_TRANSVR_CONNECTED; - self->type = TRANSVR_TYPE_FAKE; - return 0; -} - - -/* ========== Object functions for Initial procedure ========== - */ -int -transvr_init_common(struct transvr_obj_s *self){ - /* Nothing to update */ - return EVENT_TRANSVR_TASK_DONE; -} - - -int -transvr_init_fake(struct transvr_obj_s *self){ - return EVENT_TRANSVR_TASK_DONE; -} - - -int -transvr_init_sfp(struct transvr_obj_s *self){ - - int tmp_val = DEBUG_TRANSVR_INT_VAL; - int err_code = DEBUG_TRANSVR_INT_VAL; - char *err_msg = "ERR"; - - self->info = sft_detect_transvr_class(self); - /* Disable auto_config */ - if (!self->auto_config) { - return EVENT_TRANSVR_TASK_DONE; - } - /* Handle multi-rate */ - err_code = initfunc_sfp_handle_multi_rate_mode(self); - if (err_code < 0) { - err_msg = "initfunc_sfp_handle_multi_rate_mode fail!"; - goto err_transvr_init_sfp_1; - } - /* Handle 1G- RJ45 */ - tmp_val = err_code; - err_code = initfunc_sfp_handle_1g_rj45(self); - if (err_code < 0) { - err_msg = "initfunc_sfp_handle_1g_rj45 fail!"; - goto err_transvr_init_sfp_1; - } - tmp_val = (tmp_val > err_code ? tmp_val : err_code); - if (tmp_val > EVENT_TRANSVR_TASK_DONE) { - return tmp_val; - } - return EVENT_TRANSVR_TASK_DONE; - -err_transvr_init_sfp_1: - SWPS_INFO("%s: %s :%d :%s\n", - __func__, err_msg, err_code, self->swp_name); - return EVENT_TRANSVR_INIT_FAIL; -} - - -int -transvr_init_qsfp(struct transvr_obj_s *self){ - - int err = EVENT_TRANSVR_EXCEP_EXCEP; - char *emsg = "ERR"; - - self->info = qsft_detect_transvr_class(self); - if (!self->auto_config) { - return EVENT_TRANSVR_TASK_DONE; - } - err = initfunc_qsfp_handle_power_mode(self); - if (err < 0){ - emsg = "initfunc_qsfp_handle_tx_disable fail!"; - goto err_transvr_init_qsfp; - } - return EVENT_TRANSVR_TASK_DONE; - -err_transvr_init_qsfp: - SWPS_INFO("%s: %s :%d :%s\n", - __func__, emsg, err, self->swp_name); - return EVENT_TRANSVR_INIT_FAIL; -} - - -int -transvr_init_qsfp28(struct transvr_obj_s *self){ - - int tmp_val = EVENT_TRANSVR_EXCEP_EXCEP; - int err_val = EVENT_TRANSVR_EXCEP_EXCEP; - char *err_msg = "ERR"; - - /* Handle QSFP common */ - err_val = transvr_init_qsfp(self); - if (err_val < 0){ - err_msg = "transvr_init_qsfp fail!"; - goto err_transvr_init_qsfp28_1; - } - /* Disable auto_config */ - if (!self->auto_config) { - return err_val; - } - /* Handle CDR */ - tmp_val = err_val; - err_val = initfunc_qsfp28_handle_cdr(self); - if (err_val < 0){ - err_msg = "Handle CDR fail!"; - goto err_transvr_init_qsfp28_1; - } - tmp_val = (tmp_val > err_val ? tmp_val : err_val); - if (tmp_val > EVENT_TRANSVR_TASK_DONE) { - return tmp_val; - } - return EVENT_TRANSVR_TASK_DONE; - -err_transvr_init_qsfp28_1: - SWPS_INFO("%s: %s :%d :%s\n", - __func__, err_msg, err_val, self->swp_name); - return EVENT_TRANSVR_INIT_FAIL; -} - - -/* ========== Object Initial handler ========== - */ -static int -_is_transvr_valid(struct transvr_obj_s *self, - int type, - int state) { - /* [Return] - * 0 : OK, inserted - * EVENT_TRANSVR_INIT_DOWN : OK, removed - * EVENT_TRANSVR_INIT_FAIL : Outside error, type doesn't supported - * EVENT_TRANSVR_EXCEP_INIT : Internal error, state undefined - */ - switch (type) { - case TRANSVR_TYPE_SFP: - case TRANSVR_TYPE_QSFP: - case TRANSVR_TYPE_QSFP_PLUS: - case TRANSVR_TYPE_QSFP_28: - case TRANSVR_TYPE_UNPLUGGED: - case TRANSVR_TYPE_FAKE: - break; - default: - SWPS_INFO("detect undefined type:0x%02x on %s\n", - type, self->swp_name); - return EVENT_TRANSVR_INIT_FAIL; - } - switch (state) { - case STATE_TRANSVR_DISCONNECTED: - return EVENT_TRANSVR_INIT_DOWN; - case STATE_TRANSVR_INIT: - case STATE_TRANSVR_CONNECTED: - case STATE_TRANSVR_SWAPPED: - break; - default: - SWPS_INFO("detect undefined state:%d on %s\n", - state, self->swp_name); - return EVENT_TRANSVR_EXCEP_INIT; - } - return 0; -} - - -static int -_is_transvr_hw_ready(struct transvr_obj_s *self, - int type){ - /* [Return] - * EVENT_TRANSVR_TASK_DONE : Ready - * EVENT_TRANSVR_TASK_WAIT : Not ready - * EVENT_TRANSVR_INIT_FAIL : Error - */ - int addr = DEBUG_TRANSVR_INT_VAL; - int page = DEBUG_TRANSVR_INT_VAL; - int offs = DEBUG_TRANSVR_INT_VAL; - int bit = DEBUG_TRANSVR_INT_VAL; - int ready = DEBUG_TRANSVR_INT_VAL; - int err = DEBUG_TRANSVR_INT_VAL; - char *emsg = DEBUG_TRANSVR_STR_VAL; - uint8_t ab_val = DEBUG_TRANSVR_HEX_VAL; - - switch (type) { - case TRANSVR_TYPE_SFP: - addr = VAL_TRANSVR_8472_READY_ADDR; - page = VAL_TRANSVR_8472_READY_PAGE; - offs = VAL_TRANSVR_8472_READY_OFFSET; - bit = VAL_TRANSVR_8472_READY_BIT; - ready = VAL_TRANSVR_8472_READY_VALUE; - ab_val = VAL_TRANSVR_8472_READY_ABNORMAL; - break; - - case TRANSVR_TYPE_QSFP: - case TRANSVR_TYPE_QSFP_PLUS: - case TRANSVR_TYPE_QSFP_28: - addr = VAL_TRANSVR_8436_READY_ADDR; - page = VAL_TRANSVR_8436_READY_PAGE; - offs = VAL_TRANSVR_8436_READY_OFFSET; - bit = VAL_TRANSVR_8436_READY_BIT; - ready = VAL_TRANSVR_8436_READY_VALUE; - ab_val = VAL_TRANSVR_8436_READY_ABNORMAL; - break; - - case TRANSVR_TYPE_UNPLUGGED: - case TRANSVR_TYPE_FAKE: - return EVENT_TRANSVR_TASK_DONE; - - default: - emsg = "unexpected case"; - goto err_is_transvr_hw_ready; - } - /* Select target page */ - err = _common_setup_page(self, addr, page, offs, 1, 0); - if (err < 0) { - emsg = "setup page fail"; - goto err_is_transvr_hw_ready; - } - /* Check feature supported - * [Note] - * Some of transceiver/cables doesn't support "Status Indicators" - * (ex:DAC, RJ45 copper SFP ...etc). In these case, we bypass the - * step of checking Status Indicators, then state machine will take - * the following handle procedure. - */ - err = i2c_smbus_read_byte_data(self->i2c_client_p, - VAL_TRANSVR_COMID_OFFSET); - if (err < 0) { - emsg = "doesn't support Status Indicators"; - goto bypass_is_transvr_hw_ready; - } - /* Filter abnormal case */ - if (err == ab_val) { - emsg = "detect using unusual definition."; - goto bypass_is_transvr_hw_ready; - } - /* Get Status Indicators */ - err = i2c_smbus_read_byte_data(self->i2c_client_p, offs); - if (err < 0) { - emsg = "detect current value fail"; - goto err_is_transvr_hw_ready; - } - if ((err & (1<:%d\n", __func__, emsg, type); - return EVENT_TRANSVR_TASK_DONE; - -err_is_transvr_hw_ready: - SWPS_DEBUG("%s: %s :%d\n", __func__, emsg, type); - return EVENT_TRANSVR_INIT_FAIL; -} - - -static int -_is_transvr_support_ctle(struct transvr_obj_s *self) { - - switch (self->info) { - case TRANSVR_CLASS_OPTICAL_25G: - case TRANSVR_CLASS_OPTICAL_25G_AOC: - case TRANSVR_CLASS_OPTICAL_25G_SR: - case TRANSVR_CLASS_OPTICAL_25G_LR: - case TRANSVR_CLASS_OPTICAL_25G_ER: - case TRANSVR_CLASS_OPTICAL_100G: - case TRANSVR_CLASS_OPTICAL_100G_AOC: - case TRANSVR_CLASS_OPTICAL_100G_SR4: - case TRANSVR_CLASS_OPTICAL_100G_LR4: - case TRANSVR_CLASS_OPTICAL_100G_ER4: - case TRANSVR_CLASS_OPTICAL_100G_PSM4: - return 1; - default: - break; - } - return 0; -} - - -static int -_transvr_init_handler(struct transvr_obj_s *self){ - - int detect[2]; - int d_state = STATE_TRANSVR_UNEXCEPTED; - int d_type = TRANSVR_TYPE_ERROR; - int result = ERR_TRANSVR_UNINIT; - int retry = 6; /* (6+1) x 0.3 = 2.1s > spec:2.0s */ - int elimit = 63; - char emsg[64] = DEBUG_TRANSVR_STR_VAL; - - /* Clean and check callback */ - self->state = STATE_TRANSVR_INIT; - if (self->init == NULL) { - snprintf(emsg, elimit, "init() is null"); - goto initer_err_case_unexcept_0; - } - if (self->clean == NULL) { - snprintf(emsg, elimit, "clean() is null"); - goto initer_err_case_unexcept_0; - } - self->clean(self); - - /* Detect transceiver information */ - result = detect_transvr_state(self, detect); - if (result < 0) { - snprintf(emsg, elimit, "detect_transvr_state() fail"); - switch (result) { - case ERR_TRANSVR_I2C_CRASH: - goto initer_err_case_i2c_ceash; - case ERR_TRNASVR_BE_ISOLATED: - goto initer_err_case_be_isolated; - - case ERR_TRANSVR_UNEXCPT: - default: - break; - } - goto initer_err_case_retry_1; - } - d_state = detect[0]; - d_type = detect[1]; - - /* Verify transceiver type and state */ - switch (_is_transvr_valid(self, d_type, d_state)) { - case 0: - break; - case EVENT_TRANSVR_INIT_DOWN: - goto initer_ok_case_down;; - case EVENT_TRANSVR_INIT_FAIL: - snprintf(emsg, elimit, "transceiver type doesn't support"); - goto initer_err_case_alarm_to_user; - case EVENT_TRANSVR_EXCEP_INIT: - default: - goto initer_err_case_unexcept_1; - } - - /* Handle reload case */ - if (self->type != d_type){ - /* This is the protect mechanism. Normally, This case will not happen. - * When State machine detect swap event during initial, It will trigger - * reload function to ensure type correct. */ - if (_reload_transvr_obj(self, d_type) < 0){ - snprintf(emsg, elimit, "reload object fail"); - goto initer_err_case_unexcept_1; - } - } - - /* Check transceiver HW initial ready */ - switch (_is_transvr_hw_ready(self, d_type)) { - case EVENT_TRANSVR_TASK_DONE: - break; - case EVENT_TRANSVR_TASK_WAIT: - goto initer_err_case_retry_1; - case EVENT_TRANSVR_INIT_FAIL: - default: - goto initer_err_case_unexcept_1; - } - - /* Try to update all and check */ - if (self->update_all(self, 1) < 0){ - /* For some transceiver, EEPROME has lag issues during initial stage. - * In this case, we set status back to STATE_TRANSVR_NEW, than it will - * be checked in next polling cycle. */ - goto initer_err_case_retry_1; - } - - /* Execute init() call back */ - result = self->init(self); - switch (result) { - case EVENT_TRANSVR_TASK_DONE: - break; - case EVENT_TRANSVR_TASK_WAIT: - goto initer_ok_case_wait; - - default: - snprintf(emsg, elimit, "undefined init() return:%d\n", result); - goto initer_err_case_unexcept_1; - } - goto initer_ok_case_up; - - -initer_ok_case_wait: - self->dump_all(self); - return EVENT_TRANSVR_TASK_WAIT; - -initer_ok_case_up: - self->state = STATE_TRANSVR_CONNECTED; - self->temp = 0; - self->dump_all(self); - return EVENT_TRANSVR_INIT_UP; - -initer_ok_case_down: - self->temp = 0; - self->state = STATE_TRANSVR_DISCONNECTED; - return EVENT_TRANSVR_INIT_DOWN; - -initer_err_case_i2c_ceash: - SWPS_DEBUG("%s: %s :%s :I2C crash\n", - __func__, emsg, self->swp_name); - self->state = STATE_TRANSVR_UNEXCEPTED; - return EVENT_TRANSVR_I2C_CRASH; - -initer_err_case_be_isolated: - SWPS_DEBUG("%s: %s :%s :isolated\n", - __func__, emsg, self->swp_name); - self->state = STATE_TRANSVR_ISOLATED; - return EVENT_TRANSVR_EXCEP_ISOLATED; - -initer_err_case_retry_1: - SWPS_DEBUG("%s: %s :%s :retry\n", - __func__, emsg, self->swp_name); - if (_transvr_handle_retry(self, retry) == 0) { - self->state = STATE_TRANSVR_NEW; - return EVENT_TRANSVR_INIT_REINIT; - } - goto initer_err_case_alarm_to_user; - -initer_err_case_unexcept_1: - self->clean(self); -initer_err_case_unexcept_0: - self->state = STATE_TRANSVR_UNEXCEPTED; - if (_is_except_happened_4_pmode(self, d_state) && - (self->mode == TRANSVR_MODE_POLLING) ){ - SWPS_INFO("%s: %s :%s\n", __func__, emsg, self->swp_name); - SWPS_INFO("Dump: :%d :%d :%d :%d\n", - self->state, self->type, d_state, d_type); - } - return EVENT_TRANSVR_INIT_FAIL; - -initer_err_case_alarm_to_user: - SWPS_DEBUG("%s: %s :%s :alarm_to_user\n", - __func__, emsg, self->swp_name); - self->state = STATE_TRANSVR_UNEXCEPTED; - alarm_msg_2_user(self, "detected transceiver/cables not meet SFF standard"); - return EVENT_TRANSVR_INIT_FAIL; -} - - -/* ========== Object functions for Clean procedure ========== - */ -int -_transvr_clean_handler(struct transvr_obj_s *self){ - - int retval = DEBUG_TRANSVR_INT_VAL; - - if (!self->clean) { - SWPS_ERR("%s: %s clean() is NULL.\n", - __func__, self->swp_name); - return EVENT_TRANSVR_TASK_FAIL; - } - retval = self->clean(self); - if (retval != EVENT_TRANSVR_TASK_DONE){ - SWPS_ERR("%s: %s clean() fail. [ERR]:%d\n", - __func__, self->swp_name, retval); - return retval; - } - return EVENT_TRANSVR_TASK_DONE; -} - - -int -common_transvr_clean(struct transvr_obj_s *self){ - - transvr_task_free_all(self); - return EVENT_TRANSVR_TASK_DONE; -} - - -int -qsfp_transvr_clean(struct transvr_obj_s *self){ - - int retval; - int lpower_config = 1; - - retval = _taskfunc_qsfp_setup_power_mod(self, lpower_config); - if (retval < 0){ - SWPS_ERR("%s: Set lpmod fail! :%d\n", - __func__, retval); - return retval; - } - retval = common_transvr_clean(self); - if (retval < 0){ - SWPS_ERR("%s: common_transvr_clean fail! :%d\n", - __func__, retval); - return retval; - } - return EVENT_TRANSVR_TASK_DONE; -} - - -int -fake_transvr_clean(struct transvr_obj_s *self){ - - return EVENT_TRANSVR_TASK_DONE; -} - - -/* ========== Object functions for check and update ========== - */ -int -common_transvr_check(struct transvr_obj_s *self){ - - char fun_str[32] = "common_transvr_check"; - - if (self->mode != TRANSVR_MODE_POLLING) { - SWPS_ERR("%s: mode:%d is not TRANSVR_MODE_POLLING\n", - fun_str, self->mode); - return ERR_TRANSVR_UNEXCPT; - } - /* Trigger delay task */ - transvr_task_run_all(self); - /* Trigger state machine to check and update */ - return self->fsm_4_polling(self, fun_str); -} - - -int -fake_transvr_check(struct transvr_obj_s *self){ - return 0; -} - - -/* ========== Functions for Factory pattern ========== - */ -static int -setup_transvr_public_cb(struct transvr_obj_s *self, - int transvr_type){ - switch (transvr_type){ - case TRANSVR_TYPE_SFP: - self->get_id = common_get_id; - self->get_eeprom = common_get_eeprom; - self->get_ext_id = common_get_ext_id; - self->get_connector = common_get_connector; - self->get_vendor_name = common_get_vendor_name; - self->get_vendor_pn = common_get_vendor_pn; - self->get_vendor_rev = common_get_vendor_rev; - self->get_vendor_sn = common_get_vendor_sn; - self->get_power_cls = unsupported_get_func; - self->get_br = common_get_br; - self->get_len_sm = sfp_get_len_sm; - self->get_len_smf = common_get_len_smf; - self->get_len_om1 = common_get_len_om1; - self->get_len_om2 = common_get_len_om2; - self->get_len_om3 = common_get_len_om3; - self->get_len_om4 = common_get_len_om4; - self->get_comp_rev = common_get_comp_rev; - self->get_comp_eth_1 = sfp_get_comp_eth_1; - self->get_comp_eth_10 = sfp_get_comp_eth_10; - self->get_comp_eth_10_40 = unsupported_get_func; - self->get_comp_extend = common_get_comp_extended; - self->get_cdr = unsupported_get_func; - self->get_rate_id = sfp_get_rate_id; - self->get_soft_rs0 = sfp_get_soft_rs0; - self->get_soft_rs1 = sfp_get_soft_rs1; - self->get_info = common_get_info; - self->get_if_type = sfp_get_if_type; - self->get_if_speed = sfp_get_if_speed; - self->get_if_lane = common_get_if_lane; - self->get_curr_temp = sfp_get_transvr_temp; - self->get_curr_vol = sfp_get_transvr_voltage; - self->get_soft_rx_los = unsupported_get_func2; - self->get_soft_tx_disable = unsupported_get_func2; - self->get_soft_tx_fault = unsupported_get_func2; - self->get_auto_tx_disable = unsupported_get_func2; - self->get_tx_bias = sfp_get_transvr_tx_bias; - self->get_tx_power = sfp_get_transvr_tx_power; - self->get_rx_power = sfp_get_transvr_rx_power; - self->get_tx_eq = sfp_get_transvr_tx_eq; - self->get_rx_am = unsupported_get_func2; - self->get_rx_em = sfp_get_transvr_rx_em; - self->get_wavelength = sfp_get_wavelength; - self->set_cdr = unsupported_set_func; - self->set_soft_rs0 = sfp_set_soft_rs0; - self->set_soft_rs1 = sfp_set_soft_rs1; - self->set_soft_tx_disable = unsupported_set_func; - self->set_auto_tx_disable = unsupported_set_func; - self->set_tx_eq = sfp_set_tx_eq; - self->set_rx_am = unsupported_set_func; - self->set_rx_em = sfp_set_rx_em; - return 0; - - case TRANSVR_TYPE_QSFP: - case TRANSVR_TYPE_QSFP_PLUS: - self->get_id = common_get_id; - self->get_eeprom = common_get_eeprom; - self->get_ext_id = common_get_ext_id; - self->get_connector = common_get_connector; - self->get_vendor_name = common_get_vendor_name; - self->get_vendor_pn = common_get_vendor_pn; - self->get_vendor_rev = common_get_vendor_rev; - self->get_vendor_sn = common_get_vendor_sn; - self->get_power_cls = qsfp_get_power_cls; - self->get_br = common_get_br; - self->get_len_sm = unsupported_get_func; - self->get_len_smf = common_get_len_smf; - self->get_len_om1 = common_get_len_om1; - self->get_len_om2 = common_get_len_om2; - self->get_len_om3 = common_get_len_om3; - self->get_len_om4 = common_get_len_om4; - self->get_comp_rev = common_get_comp_rev; - self->get_comp_eth_1 = qsfp_get_comp_eth; - self->get_comp_eth_10 = unsupported_get_func; - self->get_comp_eth_10_40 = qsfp_get_comp_10_40; - self->get_comp_extend = common_get_comp_extended; - self->get_cdr = unsupported_get_func; - self->get_rate_id = unsupported_get_func; - self->get_soft_rs0 = unsupported_get_func; /* TBD */ - self->get_soft_rs1 = unsupported_get_func; /* TBD */ - self->get_info = common_get_info; - self->get_if_type = qsfp_get_if_type; - self->get_if_speed = qsfp_get_if_speed; - self->get_if_lane = common_get_if_lane; - self->get_curr_temp = qsfp_get_transvr_temp; - self->get_curr_vol = qsfp_get_transvr_voltage; - self->get_soft_rx_los = qsfp_get_soft_rx_los; - self->get_soft_tx_disable = qsfp_get_soft_tx_disable; - self->get_soft_tx_fault = qsfp_get_soft_tx_fault; - self->get_auto_tx_disable = qsfp_get_auto_tx_disable; - self->get_tx_bias = qsfp_get_transvr_tx_bias; - self->get_tx_power = qsfp_get_transvr_tx_power; - self->get_rx_power = qsfp_get_transvr_rx_power; - self->get_tx_eq = unsupported_get_func2; - self->get_rx_am = unsupported_get_func2; - self->get_rx_em = unsupported_get_func2; - self->get_wavelength = qsfp_get_wavelength; - self->set_cdr = unsupported_set_func; - self->set_soft_rs0 = unsupported_set_func; /* TBD */ - self->set_soft_rs1 = unsupported_set_func; /* TBD */ - self->set_soft_tx_disable = qsfp_set_soft_tx_disable; - self->set_auto_tx_disable = qsfp_set_auto_tx_disable; - self->set_tx_eq = unsupported_set_func; - self->set_rx_am = unsupported_set_func; - self->set_rx_em = unsupported_set_func; - return 0; - - case TRANSVR_TYPE_QSFP_28: - self->get_id = common_get_id; - self->get_eeprom = common_get_eeprom; - self->get_ext_id = common_get_ext_id; - self->get_connector = common_get_connector; - self->get_vendor_name = common_get_vendor_name; - self->get_vendor_pn = common_get_vendor_pn; - self->get_vendor_rev = common_get_vendor_rev; - self->get_vendor_sn = common_get_vendor_sn; - self->get_power_cls = qsfp_get_power_cls; - self->get_br = common_get_br; - self->get_len_sm = unsupported_get_func; - self->get_len_smf = common_get_len_smf; - self->get_len_om1 = common_get_len_om1; - self->get_len_om2 = common_get_len_om2; - self->get_len_om3 = common_get_len_om3; - self->get_len_om4 = common_get_len_om4; - self->get_comp_rev = common_get_comp_rev; - self->get_comp_eth_1 = qsfp_get_comp_eth; - self->get_comp_eth_10 = unsupported_get_func; - self->get_comp_eth_10_40 = qsfp_get_comp_10_40; - self->get_comp_extend = common_get_comp_extended; - self->get_cdr = qsfp_get_cdr; - self->get_rate_id = unsupported_get_func; - self->get_soft_rs0 = unsupported_get_func; /* TBD */ - self->get_soft_rs1 = unsupported_get_func; /* TBD */ - self->get_info = common_get_info; - self->get_if_type = qsfp_get_if_type; - self->get_if_speed = qsfp_get_if_speed; - self->get_if_lane = common_get_if_lane; - self->get_curr_temp = qsfp_get_transvr_temp; - self->get_curr_vol = qsfp_get_transvr_voltage; - self->get_soft_rx_los = qsfp_get_soft_rx_los; - self->get_soft_tx_disable = qsfp_get_soft_tx_disable; - self->get_soft_tx_fault = qsfp_get_soft_tx_fault; - self->get_auto_tx_disable = qsfp_get_auto_tx_disable; - self->get_tx_bias = qsfp_get_transvr_tx_bias; - self->get_tx_power = qsfp_get_transvr_tx_power; - self->get_rx_power = qsfp_get_transvr_rx_power; - self->get_tx_eq = qsfp_get_transvr_tx_eq; - self->get_rx_am = qsfp_get_transvr_rx_am; - self->get_rx_em = qsfp_get_transvr_rx_em; - self->get_wavelength = qsfp_get_wavelength; - self->set_cdr = qsfp_set_cdr; - self->set_soft_rs0 = unsupported_set_func; /* TBD */ - self->set_soft_rs1 = unsupported_set_func; /* TBD */ - self->set_soft_tx_disable = qsfp_set_soft_tx_disable; - self->set_auto_tx_disable = qsfp_set_auto_tx_disable; - self->set_tx_eq = qsfp_set_tx_eq; - self->set_rx_am = qsfp_set_rx_am; - self->set_rx_em = qsfp_set_rx_em; - return 0; - - case TRANSVR_TYPE_FAKE: - self->get_id = fake_get_hex; - self->get_eeprom = fake_get_str; - self->get_ext_id = fake_get_hex; - self->get_connector = fake_get_hex; - self->get_vendor_name = fake_get_str; - self->get_vendor_pn = fake_get_str; - self->get_vendor_rev = fake_get_str; - self->get_vendor_sn = fake_get_str; - self->get_power_cls = fake_get_int; - self->get_br = fake_get_hex; - self->get_len_sm = fake_get_int; - self->get_len_smf = fake_get_int; - self->get_len_om1 = fake_get_int; - self->get_len_om2 = fake_get_int; - self->get_len_om3 = fake_get_int; - self->get_len_om4 = fake_get_int; - self->get_comp_rev = fake_get_hex; - self->get_comp_eth_1 = fake_get_hex; - self->get_comp_eth_10 = fake_get_hex; - self->get_comp_eth_10_40 = fake_get_hex; - self->get_comp_extend = fake_get_hex; - self->get_cdr = fake_get_hex; - self->get_rate_id = fake_get_hex; - self->get_soft_rs0 = fake_get_binary; - self->get_soft_rs1 = fake_get_binary; - self->get_info = fake_get_int; - self->get_if_type = fake_get_str; - self->get_if_speed = fake_get_str; - self->get_if_lane = fake_get_str; - self->get_curr_temp = fake_get_str; - self->get_curr_vol = fake_get_str; - self->get_soft_rx_los = fake_get_str; - self->get_soft_tx_disable = fake_get_str; - self->get_soft_tx_fault = fake_get_str; - self->get_auto_tx_disable = fake_get_str; - self->get_tx_bias = fake_get_str; - self->get_tx_power = fake_get_str; - self->get_rx_power = fake_get_str; - self->get_tx_eq = fake_get_str; - self->get_rx_am = fake_get_str; - self->get_rx_em = fake_get_str; - self->get_wavelength = fake_get_str; - self->set_cdr = fake_set_hex; - self->set_soft_rs0 = fake_set_int; - self->set_soft_rs1 = fake_set_int; - self->set_soft_tx_disable = fake_set_int; - self->set_auto_tx_disable = fake_set_int; - self->set_tx_eq = fake_set_int; - self->set_rx_am = fake_set_int; - self->set_rx_em = fake_set_int; - return 0; - - default: - break; - } - SWPS_WARN("%s: Detect non-defined type:%d\n", __func__, transvr_type); - return ERR_TRANSVR_UNEXCPT; -} - - -static int -setup_transvr_private_cb(struct transvr_obj_s *self, - int transvr_type){ - switch (transvr_type){ - case TRANSVR_TYPE_SFP: - self->init = transvr_init_sfp; - self->clean = common_transvr_clean; - self->check = common_transvr_check; - self->update_all = _sfp_update_attr_all; - self->fsm_4_direct = common_fsm_4_direct_mode; - self->fsm_4_polling = common_fsm_4_polling_mode; - self->send_uevent = sfp_send_uevent; - self->dump_all = sfp_transvr_dump; - return 0; - - case TRANSVR_TYPE_QSFP: - case TRANSVR_TYPE_QSFP_PLUS: - self->init = transvr_init_qsfp; - self->clean = qsfp_transvr_clean; - self->check = common_transvr_check; - self->update_all = _qsfp_update_attr_all; - self->fsm_4_direct = common_fsm_4_direct_mode; - self->fsm_4_polling = common_fsm_4_polling_mode; - self->send_uevent = qsfp_send_uevent; - self->dump_all = qsfp_transvr_dump; - return 0; - - case TRANSVR_TYPE_QSFP_28: - self->init = transvr_init_qsfp28; - self->clean = qsfp_transvr_clean; - self->check = common_transvr_check; - self->update_all = _qsfp_update_attr_all; - self->fsm_4_direct = common_fsm_4_direct_mode; - self->fsm_4_polling = common_fsm_4_polling_mode; - self->send_uevent = qsfp_send_uevent; - self->dump_all = qsfp_transvr_dump; - return 0; - - case TRANSVR_TYPE_FAKE: - self->init = transvr_init_fake; - self->clean = fake_transvr_clean; - self->check = fake_transvr_check; - self->update_all = fake_transvr_update; - self->fsm_4_direct = fake_fsm_4_direct_mode; - self->fsm_4_polling = fake_fsm_4_polling_mode; - self->send_uevent = fake_send_uevent; - self->dump_all = fake_transvr_dump; - return 0; - - default: - break; - } - SWPS_WARN("%s: Detect non-defined type:%d\n", __func__, transvr_type); - return ERR_TRANSVR_UNEXCPT; -} - - -static struct eeprom_map_s * -get_eeprom_map(int transvr_type){ - - switch (transvr_type){ - case TRANSVR_TYPE_SFP: - return &eeprom_map_sfp; - case TRANSVR_TYPE_QSFP: - case TRANSVR_TYPE_QSFP_PLUS: - return &eeprom_map_qsfp; - case TRANSVR_TYPE_QSFP_28: - return &eeprom_map_qsfp28; - - default: - break; - } - SWPS_WARN("%s: Detect non-defined type:%d\n", __func__, transvr_type); - return NULL; -} - - -static int -setup_transvr_ssize_attr(char *swp_name, - struct transvr_obj_s *self, - struct eeprom_map_s *map_p, - struct ioexp_obj_s *ioexp_obj_p, - int ioexp_virt_offset, - int transvr_type, - int chipset_type, - int chan_id, - int run_mode){ - switch (run_mode){ - case TRANSVR_MODE_DIRECT: /* Direct access device mode */ - case TRANSVR_MODE_POLLING: /* Polling mode, read from cache */ - self->mode = run_mode; - break; - default: - SWPS_ERR("%s: non-defined run_mode:%d\n", - __func__, run_mode); - self->mode = DEBUG_TRANSVR_INT_VAL; - return -1; - } - self->eeprom_map_p = map_p; - self->ioexp_obj_p = ioexp_obj_p; - self->ioexp_virt_offset = ioexp_virt_offset; - self->chan_id = chan_id; - self->layout = transvr_type; - self->type = transvr_type; - self->chipset_type = chipset_type; - self->state = STATE_TRANSVR_NEW; - self->info = STATE_TRANSVR_NEW; - self->auto_tx_disable = VAL_TRANSVR_FUNCTION_DISABLE; - strncpy(self->swp_name, swp_name, 32); - mutex_init(&self->lock); - return 0; -} - - -static int -setup_transvr_dsize_attr(struct transvr_obj_s *self){ - - char *emsg = DEBUG_TRANSVR_STR_VAL; - - self->vendor_name = kzalloc((LEN_TRANSVR_M_STR * sizeof(char)), GFP_KERNEL); - if (!self->vendor_name){ - emsg = "vendor_name"; - goto err_setup_d_attr; - } - self->vendor_pn = kzalloc((LEN_TRANSVR_M_STR * sizeof(char)), GFP_KERNEL); - if (!self->vendor_pn){ - emsg = "vendor_pn"; - goto err_setup_d_attr; - } - self->vendor_rev = kzalloc((LEN_TRANSVR_M_STR * sizeof(char)), GFP_KERNEL); - if (!self->vendor_rev){ - emsg = "vendor_rev"; - goto err_setup_d_attr; - } - self->vendor_sn = kzalloc((LEN_TRANSVR_M_STR * sizeof(char)), GFP_KERNEL); - if (!self->vendor_sn){ - emsg = "vendor_sn"; - goto err_setup_d_attr; - } - self->worker_p = NULL; - return 0; - -err_setup_d_attr: - SWPS_ERR("%s: %s kzalloc fail!", __func__, emsg); - return ERR_TRANSVR_UNEXCPT; -} - - -static int -setup_i2c_client(struct transvr_obj_s *self){ - - struct i2c_adapter *adap = NULL; - struct i2c_client *client = NULL; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - - adap = i2c_get_adapter(self->chan_id); - if(!adap){ - snprintf(err_msg, sizeof(err_msg), - "can not get adap:%d", self->chan_id); - goto err_setup_i2c_client; - } - client = kzalloc(sizeof(*client), GFP_KERNEL); - if (!client){ - snprintf(err_msg, sizeof(err_msg), - "can not kzalloc client:%d", self->chan_id); - goto err_setup_i2c_client; - } - client->adapter = adap; - self->i2c_client_p = client; - self->i2c_client_p->addr = VAL_TRANSVR_COMID_ARREESS; - return 0; - -err_setup_i2c_client: - SWPS_ERR("%s: %s\n", __func__, err_msg); - return ERR_TRANSVR_UNEXCPT; -} - - -struct transvr_obj_s * -create_transvr_obj(char *swp_name, - int chan_id, - struct ioexp_obj_s *ioexp_obj_p, - int ioexp_virt_offset, - int transvr_type, - int chipset_type, - int run_mode){ - - struct transvr_obj_s *result_p; - struct eeprom_map_s *map_p; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - - /* Allocate transceiver object */ - map_p = get_eeprom_map(transvr_type); - if (!map_p){ - snprintf(err_msg, sizeof(err_msg), - "Invalid transvr_type:%d", transvr_type); - goto err_create_transvr_fail; - } - result_p = kzalloc(sizeof(*result_p), GFP_KERNEL); - if (!result_p){ - snprintf(err_msg, sizeof(err_msg), "kzalloc fail"); - goto err_create_transvr_fail; - } - /* Prepare static size attributes */ - if (setup_transvr_ssize_attr(swp_name, - result_p, - map_p, - ioexp_obj_p, - ioexp_virt_offset, - transvr_type, - chipset_type, - chan_id, - run_mode) < 0){ - goto err_create_transvr_sattr_fail; - } - /* Prepare dynamic size attributes */ - if (setup_transvr_dsize_attr(result_p) < 0){ - goto err_create_transvr_dattr_fail; - } - /* Prepare call back functions of object */ - if (setup_transvr_public_cb(result_p, transvr_type) < 0){ - goto err_create_transvr_dattr_fail; - } - /* Prepare call back functions of object */ - if (setup_transvr_private_cb(result_p, transvr_type) < 0){ - goto err_create_transvr_dattr_fail; - } - /* Prepare i2c client object */ - if (setup_i2c_client(result_p) < 0){ - goto err_create_transvr_dattr_fail; - } - return result_p; - -err_create_transvr_dattr_fail: - kfree(result_p->vendor_sn); - kfree(result_p->vendor_rev); - kfree(result_p->vendor_pn); - kfree(result_p->vendor_name); -err_create_transvr_sattr_fail: - kfree(result_p); -err_create_transvr_fail: - SWPS_ERR("%s: %s :%d :%d :%d\n", - __func__, err_msg, chan_id, ioexp_virt_offset, transvr_type); - return NULL; -} -EXPORT_SYMBOL(create_transvr_obj); - -static int -_reload_transvr_obj(struct transvr_obj_s *self, - int new_type){ - - struct eeprom_map_s *new_map_p; - struct eeprom_map_s *old_map_p = self->eeprom_map_p; - struct i2c_client *old_i2c_p = self->i2c_client_p; - int old_type = self->type; - - /* Change state to STATE_TRANSVR_INIT */ - self->state = STATE_TRANSVR_INIT; - self->type = new_type; - /* Replace EEPROME map */ - new_map_p = get_eeprom_map(new_type); - if (!new_map_p){ - goto err_private_reload_func_1; - } - self->eeprom_map_p = new_map_p; - /* Reload i2c client */ - if (setup_i2c_client(self) < 0){ - goto err_private_reload_func_2; - } - /* Replace call back functions */ - if (setup_transvr_public_cb(self, new_type) < 0){ - goto err_private_reload_func_3; - } - if (setup_transvr_private_cb(self, new_type) < 0){ - goto err_private_reload_func_3; - } - kfree(old_i2c_p); - return 0; - -err_private_reload_func_3: - SWPS_INFO("%s: init() fail!\n", __func__); - kfree(old_i2c_p); - self->state = STATE_TRANSVR_UNEXCEPTED; - self->type = TRANSVR_TYPE_ERROR; - return -2; - -err_private_reload_func_2: - self->eeprom_map_p = old_map_p; - self->i2c_client_p = old_i2c_p; -err_private_reload_func_1: - self->state = STATE_TRANSVR_UNEXCEPTED; - self->type = old_type; - SWPS_INFO("%s fail! :0x%02x\n", __func__, new_type); - return -1; -} - - -static int -reload_transvr_obj(struct transvr_obj_s *self, - int new_type){ - - int result_val = ERR_TRANSVR_UNEXCPT; - - /* Reload phase */ - result_val = _reload_transvr_obj(self, new_type); - if (result_val < 0){ - SWPS_INFO("%s: reload phase fail! :%d\n", - __func__, result_val); - return EVENT_TRANSVR_RELOAD_FAIL; - } - /* Initial phase */ - result_val = _transvr_init_handler(self); - if (result_val < 0){ - SWPS_INFO("%s: initial phase fail! :%d\n", - __func__, result_val); - } - return result_val; -} - - -int -isolate_transvr_obj(struct transvr_obj_s *self) { - - self->state = STATE_TRANSVR_ISOLATED; - SWPS_INFO("%s: %s be isolated\n", __func__, self->swp_name); - return 0; -} -EXPORT_SYMBOL(isolate_transvr_obj); - -int -resync_channel_tier_2(struct transvr_obj_s *self) { - - int val = TRANSVR_TYPE_ERROR; - - if (self->state == STATE_TRANSVR_ISOLATED) { - return 0; - } - self->i2c_client_p->addr = VAL_TRANSVR_COMID_ARREESS; - val = i2c_smbus_read_byte_data(self->i2c_client_p, - VAL_TRANSVR_COMID_OFFSET); - if (val < 0) { - return -1; - } - return 0; -} -EXPORT_SYMBOL(resync_channel_tier_2); - -/* ----------------------------------------- - * ToDo List - * ----------------------------------------- - * 1. _sfp_detect_class_by_feature() - * => Need check ACC use case. - * 2. _sfp_detect_class_by_1g_ethernet() - * => Need check 0.1G use case. - * 3. Loopback transceiver use case. - * => Less much data - * 4. _qsfp_detect_class_by_extend_comp() - * => Verify 100G CWDM4 - * => Verify Obsolete (assigned before 100G CWDM4 MSA required FEC) - * => Verify 100G CLR4 - * => Verify 100GE-DWDM2 - * => Verify 40G PSM4 Parallel SMF - * => Verify 100G ACC (Active Copper Cable) or 25GAUI C2M ACC. - * => Verify 100G ACC or 25GAUI C2M ACC. - * => Verify 25GBASE-LR - * => Verify 40G Active Cable (XLPPI) - */ - - -MODULE_LICENSE("GPL"); diff --git a/packages/platforms/inventec/x86-64/d7054q28b/modules/builds/src/transceiver.h b/packages/platforms/inventec/x86-64/d7054q28b/modules/builds/src/transceiver.h deleted file mode 100644 index 0b2d65d6d..000000000 --- a/packages/platforms/inventec/x86-64/d7054q28b/modules/builds/src/transceiver.h +++ /dev/null @@ -1,812 +0,0 @@ -/************************************************************************* - * - * transceiver.h - * - * 2018 Inventec Corporation - * All Rights Reserved. - * - * NOTICE: All information contained herein is, and remains - * the property of Inventec Corp. and its suppliers, - * if any. The intellectual and technical concepts contained - * herein are proprietary to Inventec Corporation and its suppliers - * and may be covered by U.S. and Foreign Patents, patents in process, - * and are protected by trade secret or copyright law. - * - ************************************************************************/ - -#ifndef TRANSCEIVER_H -#define TRANSCEIVER_H - -#include - -/* advanced features control */ -#define TRANSVR_INFO_DUMP_ENABLE (1) -#define TRANSVR_INFO_CACHE_ENABLE (1) -#define TRANSVR_UEVENT_ENABLE (1) - -/* Transceiver type define */ -#define TRANSVR_TYPE_UNKNOW_1 (0x00) -#define TRANSVR_TYPE_UNKNOW_2 (0xff) -#define TRANSVR_TYPE_SFP (0x03) /* Define for SFP, SFP+, SFP28 */ -#define TRANSVR_TYPE_QSFP (0x0c) -#define TRANSVR_TYPE_QSFP_PLUS (0x0d) -#define TRANSVR_TYPE_QSFP_28 (0x11) -#define TRANSVR_TYPE_UNPLUGGED (0xfa) /* Define for ERROR handle */ -#define TRANSVR_TYPE_FAKE (0xfc) /* Define for ERROR handle */ -#define TRANSVR_TYPE_INCONSISTENT (0xfd) /* Define for ERROR handle */ -#define TRANSVR_TYPE_ERROR (0xfe) /* Define for ERROR handle */ - -/* Transceiver class for base info */ -#define TRANSVR_CLASS_UNSPECIFIED (0) -#define TRANSVR_CLASS_ERROR (-26001) -#define TRANSVR_CLASS_1G (26001) -#define TRANSVR_CLASS_10G (26011) -#define TRANSVR_CLASS_25G (26021) -#define TRANSVR_CLASS_40G (26041) -#define TRANSVR_CLASS_100G (26101) -#define TRANSVR_CLASS_NO_SPERARABLE (26901) -#define TRANSVR_CLASS_EXTEND_COMP (26902) -/* Transceiver class for Optical 1G */ -#define TRANSVR_CLASS_OPTICAL (27000) -#define TRANSVR_CLASS_OPTICAL_100 (27001) -#define TRANSVR_CLASS_OPTICAL_1G (27002) -#define TRANSVR_CLASS_OPTICAL_1G_AOC (27003) -#define TRANSVR_CLASS_OPTICAL_1G_SX (27004) -#define TRANSVR_CLASS_OPTICAL_1G_LX (27005) -#define TRANSVR_CLASS_OPTICAL_1G_EX (27006) -/* Transceiver class for Optical 10G */ -#define TRANSVR_CLASS_OPTICAL_10G (27010) -#define TRANSVR_CLASS_OPTICAL_10G_S_AOC (27011) -#define TRANSVR_CLASS_OPTICAL_10G_S_SR (27012) -#define TRANSVR_CLASS_OPTICAL_10G_S_LR (27013) -#define TRANSVR_CLASS_OPTICAL_10G_S_ER (27014) -#define TRANSVR_CLASS_OPTICAL_10G_Q_AOC (27015) -#define TRANSVR_CLASS_OPTICAL_10G_Q_SR (27016) -#define TRANSVR_CLASS_OPTICAL_10G_Q_LR (27017) -#define TRANSVR_CLASS_OPTICAL_10G_Q_ER (27018) -/* Transceiver class for Optical 25G */ -#define TRANSVR_CLASS_OPTICAL_25G (27020) -#define TRANSVR_CLASS_OPTICAL_25G_AOC (27021) -#define TRANSVR_CLASS_OPTICAL_25G_SR (27022) -#define TRANSVR_CLASS_OPTICAL_25G_LR (27023) -#define TRANSVR_CLASS_OPTICAL_25G_ER (27024) -/* Transceiver class for Optical 40G */ -#define TRANSVR_CLASS_OPTICAL_40G (27040) -#define TRANSVR_CLASS_OPTICAL_40G_AOC (27041) -#define TRANSVR_CLASS_OPTICAL_40G_SR4 (27042) -#define TRANSVR_CLASS_OPTICAL_40G_LR4 (27043) -#define TRANSVR_CLASS_OPTICAL_40G_ER4 (27044) -/* Transceiver class for Optical 100G */ -#define TRANSVR_CLASS_OPTICAL_100G (27100) -#define TRANSVR_CLASS_OPTICAL_100G_AOC (27101) -#define TRANSVR_CLASS_OPTICAL_100G_SR4 (27102) -#define TRANSVR_CLASS_OPTICAL_100G_LR4 (27103) -#define TRANSVR_CLASS_OPTICAL_100G_ER4 (27104) -#define TRANSVR_CLASS_OPTICAL_100G_PSM4 (27105) -/* Transceiver class for Copper */ -#define TRANSVR_CLASS_COPPER (28000) -#define TRANSVR_CLASS_COPPER_L1_1G (28001) -#define TRANSVR_CLASS_COPPER_L1_10G (28011) -#define TRANSVR_CLASS_COPPER_L4_10G (28012) -#define TRANSVR_CLASS_COPPER_L1_25G (28021) -#define TRANSVR_CLASS_COPPER_L4_40G (28041) -#define TRANSVR_CLASS_COPPER_L4_100G (28101) -/* Transceiver class for Base-T */ -#define TRANSVR_CLASS_BASE_T_1000 (29001) -#define TRANSVR_CLASS_BASE_T_1000_up (29002) -/* For uevent message */ -#define TRANSVR_UEVENT_KEY_IF "IF_TYPE" -#define TRANSVR_UEVENT_KEY_SP "IF_SPEED" -#define TRANSVR_UEVENT_KEY_LANE "IF_LANE" -#define TRANSVR_UEVENT_UNKNOW "UNKNOW" -#define TRANSVR_IF_KR "KR" -#define TRANSVR_IF_KR4 "KR4" -#define TRANSVR_IF_SR "SR" -#define TRANSVR_IF_SR4 "SR4" -#define TRANSVR_IF_SFI "SFI" -#define TRANSVR_IF_IF_GMII "GMII" -#define TRANSVR_IF_IF_XGMII "XGMII" -#define TRANSVR_IF_SP_100 "100" -#define TRANSVR_IF_SP_1G "1000" -#define TRANSVR_IF_SP_10G "10000" -#define TRANSVR_IF_SP_25G "25000" -#define TRANSVR_IF_SP_40G "40000" -#define TRANSVR_IF_SP_100G "100000" - -/* Transceiver mode define */ -#define TRANSVR_MODE_DIRECT (21000) -#define TRANSVR_MODE_POLLING (21001) - -/* Transceiver state define - * [Note] - * 1. State is used to represent the state of "Transceiver" and "Object". - * 2. State for different target has different means. The description as following: - */ -#define STATE_TRANSVR_CONNECTED (0) /* [Transvr]:Be plugged in. [Obj]:Link up, and work normally. */ -#define STATE_TRANSVR_NEW (-100) /* [Transvr]:(Not used) [Obj]:Create */ -#define STATE_TRANSVR_INIT (-101) /* [Transvr]:Be plugged in. [Obj]:Link up, and in initial process. */ -#define STATE_TRANSVR_ISOLATED (-102) /* [Transvr]:Be plugged in. [Obj]:Isolate, and not provide service. */ -#define STATE_TRANSVR_SWAPPED (-200) /* [Transvr]:Be plugged in. [Obj]:(Not used) */ -#define STATE_TRANSVR_DISCONNECTED (-300) /* [Transvr]:Un-plugged. [Obj]:Link down, and not provide service. */ -#define STATE_TRANSVR_UNEXCEPTED (-901) /* [Transvr]:Any [Obj]:Any, and not in expect case. */ - -/* Task state define */ -#define STATE_T_TASK_WAIT (110) -#define STATE_T_TASK_DONE (0) -#define STATE_T_TASK_INIT (-110) -#define STATE_T_TASK_FAIL (-410) - - -/* Event for task handling */ -#define EVENT_TRANSVR_TASK_WAIT (2101) -#define EVENT_TRANSVR_TASK_DONE (0) -#define EVENT_TRANSVR_TASK_FAIL (-2101) -/* Event for initial handling */ -#define EVENT_TRANSVR_INIT_UP (2201) -#define EVENT_TRANSVR_INIT_DOWN (1) -#define EVENT_TRANSVR_INIT_REINIT (-2201) -#define EVENT_TRANSVR_INIT_FAIL (-2202) -/* Event for others */ -#define EVENT_TRANSVR_RELOAD_FAIL (-2301) -#define EVENT_TRANSVR_EXCEP_INIT (-2401) -#define EVENT_TRANSVR_EXCEP_UP (-2402) -#define EVENT_TRANSVR_EXCEP_DOWN (-2403) -#define EVENT_TRANSVR_EXCEP_SWAP (-2404) -#define EVENT_TRANSVR_EXCEP_EXCEP (-2405) -#define EVENT_TRANSVR_EXCEP_ISOLATED (-2406) -#define EVENT_TRANSVR_I2C_CRASH (-2501) - -/* Transceiver error code define */ -#define ERR_TRANSVR_UNINIT (-201) -#define ERR_TRANSVR_UNPLUGGED (-202) -#define ERR_TRANSVR_ABNORMAL (-203) -#define ERR_TRANSVR_NOSTATE (-204) -#define ERR_TRANSVR_NOTSUPPORT (-205) -#define ERR_TRANSVR_BADINPUT (-206) -#define ERR_TRANSVR_UPDATE_FAIL (-207) -#define ERR_TRANSVR_RELOAD_FAIL (-208) -#define ERR_TRANSVR_INIT_FAIL (-209) -#define ERR_TRANSVR_UNDEFINED (-210) -#define ERR_TRANSVR_TASK_FAIL (-211) -#define ERR_TRANSVR_TASK_BUSY (-212) -#define ERR_TRANSVR_UEVENT_FAIL (-213) -#define ERR_TRANSVR_FUNC_DISABLE (-214) -#define ERR_TRANSVR_I2C_CRASH (-297) -#define ERR_TRNASVR_BE_ISOLATED (-298) -#define ERR_TRANSVR_UNEXCPT (-299) - -/* For debug */ -#define DEBUG_TRANSVR_INT_VAL (-99) -#define DEBUG_TRANSVR_HEX_VAL (0xfe) -#define DEBUG_TRANSVR_STR_VAL "ERROR" - -/* For system internal */ -#define VAL_TRANSVR_COMID_ARREESS (0x50) -#define VAL_TRANSVR_COMID_OFFSET (0x00) -#define VAL_TRANSVR_8472_READY_ADDR (0x51) -#define VAL_TRANSVR_8472_READY_PAGE (-1) -#define VAL_TRANSVR_8472_READY_OFFSET (110) -#define VAL_TRANSVR_8472_READY_BIT (0) -#define VAL_TRANSVR_8472_READY_VALUE (0) -#define VAL_TRANSVR_8472_READY_ABNORMAL (0xff) -#define VAL_TRANSVR_8436_READY_ADDR (0x50) -#define VAL_TRANSVR_8436_READY_PAGE (-1) -#define VAL_TRANSVR_8436_READY_OFFSET (2) -#define VAL_TRANSVR_8436_READY_BIT (0) -#define VAL_TRANSVR_8436_READY_VALUE (0) -#define VAL_TRANSVR_8436_READY_ABNORMAL (0xff) -#define VAL_TRANSVR_8436_PWD_ADDR (0x50) -#define VAL_TRANSVR_8436_PWD_PAGE (-1) -#define VAL_TRANSVR_8436_PWD_OFFSET (123) -#define VAL_TRANSVR_PAGE_FREE (-99) -#define VAL_TRANSVR_PAGE_SELECT_OFFSET (127) -#define VAL_TRANSVR_PAGE_SELECT_DELAY (5) -#define VAL_TRANSVR_TASK_RETRY_FOREVER (-999) -#define VAL_TRANSVR_FUNCTION_DISABLE (-1) -#define STR_TRANSVR_SFP "SFP" -#define STR_TRANSVR_QSFP "QSFP" -#define STR_TRANSVR_QSFP_PLUS "QSFP+" -#define STR_TRANSVR_QSFP28 "QSFP28" - -/* For transvr buf len */ -#define LEN_TRANSVR_S_STR (16) -#define LEN_TRANSVR_M_STR (32) -#define LEN_TRANSVR_L_STR (64) - -/* Optical wavelength */ -#define VAL_OPTICAL_WAVELENGTH_SR (850) -#define VAL_OPTICAL_WAVELENGTH_LR (1310) -#define VAL_OPTICAL_WAVELENGTH_ER (1550) - -/* BCM chip type define */ -#define BCM_CHIP_TYPE_TRIDENT_2 (31001) /* Magnolia, Hudson32i, Spruce */ -#define BCM_CHIP_TYPE_TOMAHAWK (31002) /* Redwood, Cypress */ - -/* Info from transceiver EEPROM */ -struct eeprom_map_s { - int addr_br; int page_br; int offset_br; int length_br; - int addr_cdr; int page_cdr; int offset_cdr; int length_cdr; - int addr_comp_rev; int page_comp_rev; int offset_comp_rev; int length_comp_rev; - int addr_connector; int page_connector; int offset_connector; int length_connector; - int addr_diag_type; int page_diag_type; int offset_diag_type; int length_diag_type; - int addr_extbr; int page_extbr; int offset_extbr; int length_extbr; - int addr_ext_id; int page_ext_id; int offset_ext_id; int length_ext_id; - int addr_id; int page_id; int offset_id; int length_id; - int addr_eeprom; int page_eeprom; int offset_eeprom; int length_eeprom; - int addr_len_sm; int page_len_sm; int offset_len_sm; int length_len_sm; - int addr_len_smf; int page_len_smf; int offset_len_smf; int length_len_smf; - int addr_len_om1; int page_len_om1; int offset_len_om1; int length_len_om1; - int addr_len_om2; int page_len_om2; int offset_len_om2; int length_len_om2; - int addr_len_om3; int page_len_om3; int offset_len_om3; int length_len_om3; - int addr_len_om4; int page_len_om4; int offset_len_om4; int length_len_om4; - int addr_option; int page_option; int offset_option; int length_option; - int addr_rate_id; int page_rate_id; int offset_rate_id; int length_rate_id; - int addr_rx_am; int page_rx_am; int offset_rx_am; int length_rx_am; - int addr_rx_em; int page_rx_em; int offset_rx_em; int length_rx_em; - int addr_rx_los; int page_rx_los; int offset_rx_los; int length_rx_los; - int addr_rx_power; int page_rx_power; int offset_rx_power; int length_rx_power; - int addr_soft_rs0; int page_soft_rs0; int offset_soft_rs0; int length_soft_rs0; - int addr_soft_rs1; int page_soft_rs1; int offset_soft_rs1; int length_soft_rs1; - int addr_temp; int page_temp; int offset_temp; int length_temp; - int addr_trancomp; int page_trancomp; int offset_trancomp; int length_trancomp; - int addr_trancomp_ext; int page_trancomp_ext; int offset_trancomp_ext; int length_trancomp_ext; - int addr_tx_bias; int page_tx_bias; int offset_tx_bias; int length_tx_bias; - int addr_tx_disable; int page_tx_disable; int offset_tx_disable; int length_tx_disable; - int addr_tx_eq; int page_tx_eq; int offset_tx_eq; int length_tx_eq; - int addr_tx_fault; int page_tx_fault; int offset_tx_fault; int length_tx_fault; - int addr_tx_power; int page_tx_power; int offset_tx_power; int length_tx_power; - int addr_vendor_name; int page_vendor_name; int offset_vendor_name; int length_vendor_name; - int addr_vendor_pn; int page_vendor_pn; int offset_vendor_pn; int length_vendor_pn; - int addr_vendor_rev; int page_vendor_rev; int offset_vendor_rev; int length_vendor_rev; - int addr_vendor_sn; int page_vendor_sn; int offset_vendor_sn; int length_vendor_sn; - int addr_voltage; int page_voltage; int offset_voltage; int length_voltage; - int addr_wavelength; int page_wavelength; int offset_wavelength; int length_wavelength; -}; - - -struct transvr_worker_s; - -/* Class of transceiver object */ -struct transvr_obj_s { - - /* ========== Object private property ========== - * [Prop]: id - * [Desc]: Type of serial transceiver. - * [Note]: SFP:03h / QSFP:0Ch / QSPF+:0Dh /QSFP28:11h - */ - uint8_t id; - - /* [Prop]: connector - * [Desc]: Connector type. - * [Note]: SFP : A0h / 2 - * QSFP: 00h / 130 - */ - uint8_t connector; - - /* [Prop]: transvr_comp - * [Desc]: Transceiver compliance code. - * [Note]: SFP: SFF-8472 - * - Normal : A0h / offset 3-10 - * - Extended: A0h / offset 36 - * QSFP: SFF-8436 & SFF-8636 - * - Normal : 00h / offset 131-138 - * - Extended: 00h / offset 192 - */ - uint8_t transvr_comp[8]; - uint8_t transvr_comp_ext; - - /* [Prop]: vendor_name - * [Desc]: SFP vendor name (ASCII 16 byte char). - * [Note]: ex:FINISAR CORP. - */ - char *vendor_name; - - /* [Prop]: vendor_pn - * [Desc]: Part number provided by SFP vendor (ASCII 16 byte char). - * [Note]: - */ - char *vendor_pn; - - /* [Prop]: vendor_rev - * [Desc]: Revision level for part number provided by vendor (ASCII 4 byte char). - * [Note]: - */ - char *vendor_rev; - - /* [Prop]: vendor_sn - * [Desc]: Serial number provided by vendor (ASCII 16 byte char). - * [Note]: - */ - char *vendor_sn; - - /* [Prop]: Extended identifier - * [Desc]: SFP: - * => None - * - * QSFP: - * => This byte contained two information: - * (1) Power consumption class - * (2) CDR function present - * [Note]: Bit description as below: - * [SFP] - * None - * - * [QSFP] - * (1) Power consumption class: - * Class 1: 1.5W (Bit6-7 = 00:) - * Class 2: 2.0W (Bit6-7 = 01:) - * Class 3: 2.5W (Bit6-7 = 10:) - * Class 4: 3.5W (Bit6-7 = 11:) - * Class 5: 4.0W (Bit0-1 = 01:) - * Class 6: 4.5W (Bit0-1 = 10:) - * Class 7: 5.0W (Bit0-1 = 11:) - * (2) CDR function present: - * Bit2: 0 = No CDR in RX - * 1 = CDR present in RX - * Bit3: 0 = No CDR in TX - * 1 = CDR present in TX - */ - uint8_t ext_id; - - /* [Prop]: br - * [Desc]: Nominal bit rate, units of 100 MBits/sec. - * [Note]: SFP:03h / QSFP:0Ch / QSPF+:0Dh - * has val: 0x67 - * no val : - */ - uint8_t br; - - /* [Prop]: extbr - * [Desc]: Extended br (00h/222) - * [Desc]: Nominal bit rate per channel, units of 250 Mbps. - * Complements. Byte 140. See Table 32A. - */ - uint8_t extbr; - - /* [Prop]: len_sm - * [Desc]: Length (single mode)-(100's)m - * [Note]: This value specifies the link length that is supported by the transceiver - * while operating in compliance with the applicable standards using single mode - * fiber. The value is in units of 100 meters. A value of 255 means that the - * transceiver supports a link length greater than 25.4 km. A value of zero means - * that the transceiver does not support single mode fiber or that the length - * information must be determined from the transceiver technology. - */ - int len_sm; - - /* [Prop]: len_smf - * [Desc]: Length (single mode)-km - * [Note]: Addition to EEPROM data from original GBIC definition. This value specifies - * the link length that is supported by the transceiver while operating in - * compliance with the applicable standards using single mode fiber. The value - * is in units of kilometers. A value of 255 means that the transceiver supports - * a link length greater than 254 km. A value of zero means that the transceiver - * does not support single mode fiber or that the length information must be - * determined from the transceiver technology. - */ - int len_smf; - - /* [Prop]: len_om1 - * [Desc]: Link length supported for 62.5 um OM1 fiber, units of 10 m - * [Note]: The value is in units of 10 meters. A value of 255 means that the - * transceiver supports a link length greater than 2.54 km. A value of - * zero means that the transceiver does not support 50 micron multi-mode - * fiber or that the length information must be determined from the transceiver - * technology. - */ - int len_om1; - - /* [Prop]: len_om2 - * [Desc]: Link length supported for 50 um OM2 fiber, units of 10 m - * [Note]: The value is in units of 10 meters. A value of 255 means that the - * transceiver supports a link length greater than 2.54 km. A value of - * zero means that the transceiver does not support 50 micron multi-mode - * fiber or that the length information must be determined from the transceiver - * technology. - */ - int len_om2; - - /* [Prop]: len_om3 - * [Desc]: Length (50um, OM3) - * [Note]: This value specifies link length that is supported by the transceiver while - * operating in compliance with applicable standards using 50 micron multimode - * OM3 [2000 MHz*km] fiber. The value is in units of 10 meters. A value of 255 - * means that the transceiver supports a link length greater than 2.54 km. A value - * of zero means that the transceiver does not support 50 micron multimode fiber - * or that the length information must be determined from the transceiver technology. - */ - int len_om3; - - /* [Prop]: len_om4 - * [Desc]: Length (50um, OM4) and Length (Active Cable or Copper) - * [Note]: For optical links, this value specifies link length that is supported by the - * transceiver while operating in compliance with applicable standards using 50 micron - * multimode OM4 [4700 MHz*km] fiber. The value is in units of 10 meters. A value of - * 255 means that the transceiver supports a link length greater than 2.54 km. A value - * of zero means that the transceiver does not support 50 micron multimode fiber or that - * the length information must be determined from the transceiver codes specified in Table 5-3. - * - * For copper links, this value specifies minimum link length supported by the transceiver - * while operating in compliance with applicable standards using copper cable. For active - * cable, this value represents actual length. The value is in units of 1 meter. A value of 255 - * means the transceiver supports a link length greater than 254 meters. A value of zero means - * the transceiver does not support copper or active cables or the length information must be - * determined from transceiver technology. Further information about cable design, equalization, - * and connectors is usually required to guarantee meeting a particular length requirement. - */ - int len_om4; - - /* [Prop]: comp_rev - * [Desc]: SFF spec revision compliance - * [Note]: Indicates which revision of SFF SFF-8472 (SFP) / SFF-8636 (QSFP) the transceiver - * complies with. (unsigned integer) - */ - uint8_t comp_rev; - - /* [Prop]: CDR - * [Desc]: For transceivers with CDR capability, setting the CDR to ON engages the internal - * retiming function. Setting the CDR to OFF enables an internal bypassing mode ,which - * directs traffic around the internal CDR. (Reference: SFF-8636) - * [Note]: value=0xff: ON. - * value=0x00: OFF. - */ - uint8_t cdr; - - /* [Prop]: rate_id - * [Desc]: Soft Rate Select 0(RX). - * [Note]: 1. Addr: A0h / Offset: 13 - * 2. Value description: - * 00h Unspecified - * 01h SFF-8079 (4/2/1G Rate_Select & AS0/AS1) - * 02h SFF-8431 (8/4/2G Rx Rate_Select only) - * 03h Unspecified * - * 04h SFF-8431 (8/4/2G Tx Rate_Select only) - * 05h Unspecified * - * 06h SFF-8431 (8/4/2G Independent Rx & Tx Rate_select) - * 07h Unspecified * - * 08h FC-PI-5 (16/8/4G Rx Rate_select only) High=16G only, Low=8G/4G - * 09h Unspecified * - * 0Ah FC-PI-5 (16/8/4G Independent Rx, Tx Rate_select) High=16G only, - * Low=8G/4G - * 0Bh Unspecified * - * 0Ch FC-PI-6 (32/16/8G Independent Rx, Tx Rate_Select) - * High=32G only, Low = 16G/8G - * 0Dh Unspecified * - * 0Eh 10/8G Rx and Tx Rate_Select controlling the operation or locking - * modes of the internal signal conditioner, retimer or CDR, according - * to the logic table defined in Table 10-2, High Bit Rate - * (10G) =9.95-11.3 Gb/s; Low Bit Rate (8G) = 8.5 Gb/s. In this mode, - * the default value of bit 110.3 (Soft Rate Select RS(0), Table 9-11) - * and of bit 118.3 (Soft Rate Select RS(1), Table 10-1) is 1. - * 0Fh Unspecified * - * 10h-FFh Unallocated - */ - int rate_id; - - /* [Prop]: soft_rs0 - * [Desc]: Soft Rate Select 0(RX). - * [Note]: 1. Writing '1' selects full bandwidth operation. - * 2. This bit is "OR'd with the hard Rate_Select, AS(0) or RS(0) pin value. - * 3. Default at power up is logic zero/low - * 4. Addr: A2h / Offset: 110 / Bit: 3 - */ - uint8_t soft_rs0; - - /* [Prop]: soft_rs1 - * [Desc]: Soft Rate Select 1(TX). - * [Note]: 1. Writing '1' selects full bandwidth TX operation. - * 2. This bit is "OR'd with the hard Rate_Select, AS(1) or RS(1) pin value. - * 3. Default at power up is logic zero/low - * 4. Addr: A2h / Offset: 118 / Bit: 3 - */ - uint8_t soft_rs1; - - /* [Prop]: diag_type - * [Desc]: DIAGNOSTIC MONITORING TYPE (A0h/92) - * [Note]: Description in SFF-8472 as below: - * Bit7: Reserved for legacy diagnostic implementations. Must be '0' for compliance - * with this document. - * Bit6: Digital diagnostic monitoring implemented (described in this document). - * Must be '1' for compliance with this document. - * Bit5 Internally calibrated - * Bit4 Externally calibrated - * Bit3 Received power measurement type.0 = OMA, 1 = average power - * Bit2 Address change required see section above, "addressing modes" - * Bit1-0 Unallocated - */ - uint8_t diag_type; - - /* [Prop]: curr_temp - * [Desc]: Transceiver Current Temperature (A2h/96-97) - * [Note]: 1. Dependent on diag_type. - * 2. 96: High byte - * 3. 97: Low byte - * 4. This feature only for SFP - */ - uint8_t curr_temp[2]; - - /* [Prop]: curr_vol - * [Desc]: Transceiver Current Voltage (SFP:A2h/108-109; QSFP:00h/22-23) - * [Note]: 1. Dependent on diag_type. - * 2. 98: High byte - * 3. 99: Low byte - * 4. This feature only for SFP - * 5. Internally measured transceiver supply voltage. Represented - * as a 16 bit unsigned integer with the voltage defined as the - * full 16 bit value (0-65535) with LSB equal to 100 uVolt, - * yielding a total range of 0 to +6.55 Volts - */ - uint8_t curr_voltage[2]; - - /* [Prop]: curr_tx_bias - * [Desc]: Transceiver TX Bias Current (SFP:A2h/100-101; QSFP:00h/26-27) - * [Note]: 1. Dependent on diag_type. - * 2. 100: High byte - * 3. 101: Low byte - * 4. This feature only for SFP - * 5. Measured TX bias current in uA. Represented as a 16 bit unsigned - * integer with the current defined as the full 16 bit value (0-65535) - * with LSB equal to 2 uA, yielding a total range of 0 to 131 mA. - * Accuracy is vendor specific but must be better than 10% of the - * manufacturer's nominal value over specified operating temperature - * and voltage. - */ - uint8_t curr_tx_bias[8]; - - /* [Prop]: curr_tx_power - * [Desc]: Transceiver TX Output Power (A2h/102-103) - * [Note]: 1. Dependent on diag_type. - * 2. 102: High byte - * 3. 103: Low byte - * 4. This feature only for SFP - * 5. Measured TX output power in mW. Represented as a 16 bit unsigned - * integer with the power defined as the full 16 bit value (0-65535) - * with LSB equal to 0.1 uW, yielding a total range of 0 to 6.5535 mW - * (~ -40 to +8.2 dBm). Data is assumed to be based on measurement of - * laser monitor photodiode current. It is factory calibrated to absolute - * units using the most representative fiber output type. Accuracy is - * vendor specific but must be better than 3dB over specified temperature - * and voltage. Data is not valid when the transmitter is disabled. - */ - uint8_t curr_tx_power[8]; - - /* [Prop]: curr_tx_power - * [Desc]: Transceiver TX Output Power (A2h/102-103) - * [Note]: 1. Dependent on diag_type. - * 2. 102: High byte - * 3. 103: Low byte - * 4. This feature only for SFP - * 5. Measured RX received optical power in mW. Value can represent either - * average received power or OMA depending upon how bit 3 of byte 92 (A0h) - * is set. Represented as a 16 bit unsigned integer with the power defined - * as the full 16 bit value (0-65535) with LSB equal to 0.1 uW, yielding a - * total range of 0 to 6.5535 mW (~ -40 to +8.2 dBm). Absolute accuracy is - * dependent upon the exact optical wavelength. For the vendor specified - * wavelength, accuracy shall be better than 3dB over specified temperature - * and voltage. - */ - uint8_t curr_rx_power[8]; - - /* [Prop]: wavelength - * [Desc]: Wavelength or Copper Cable Attenuation - * [Note]: (Following is info from SFF-8636) - * For optical free side devices, this parameter identifies the nominal - * transmitter output wavelength at room temperature. This parameter is a - * 16-bit hex value with Byte 186 as high order byte and Byte 187 as low - * order byte. The laser wavelength is equal to the 16-bit integer value - * divided by 20 in nm (units of 0.05 nm). This resolution should be adequate - * to cover all relevant wavelengths yet provide enough resolution for all - * expected DWDM applications. For accurate representation of controlled - * wavelength applications, this value should represent the center of the - * guaranteed wavelength range. If the free side device is identified as - * copper cable these registers will be used to define the cable attenuation. - * An indication of 0 dB attenuation refers to the case where the attenuation - * is not known or is unavailable. - * Byte 186 (00-FFh) is the copper cable attenuation at 2.5 GHz in units of 1 dB. - * Byte 187 (00-FFh) is the copper cable attenuation at 5.0 GHz in units of 1 dB. - */ - uint8_t wavelength[2]; - - /* [Prop]: Amplitude control - * [Desc]: Amplitude control - * [Note]: QSFP28 => SFF-8636 03H Byte-238/239 - */ - uint8_t rx_am[2]; - - /* [Prop]: Emphasis control - * [Desc]: Emphasis control - * [Note]: SFP+/28 => SFF-8472 A2H Byte-115 - * QSFP28 => SFF-8636 03H Byte-236/237 - */ - uint8_t rx_em[2]; - - /* [Prop]: Soft Rx LOS - * [Desc]: Soft Rx LOS which provide by transceiver - * [Note]: (Following is info from SFF-8636) - * Byte 3: - * - Bit 0: L-Rx1 LOS - * - Bit 1: L-Rx2 LOS - * - Bit 2: L-Rx3 LOS - * - Bit 3: L-Rx4 LOS - */ - uint8_t rx_los; - - /* [Prop]: Soft Tx Disable - * [Desc]: Soft Tx Disable which provide by transceiver - * [Note]: (Following is info from SFF-8636) - * Byte 86: - * - Bit 0: Tx1 Disable - * - Bit 1: Tx2 Disable - * - Bit 2: Tx3 Disable - * - Bit 3: Tx4 Disable - */ - uint8_t tx_disable; - - /* [Prop]: Soft Tx Fault - * [Desc]: Soft Tx Fault which provide by transceiver - * [Note]: (Following is info from SFF-8636) - * Byte 86: - * - Bit 0: Tx1 Fault - * - Bit 1: Tx2 Fault - * - Bit 2: Tx3 Fault - * - Bit 3: Tx4 Fault - */ - uint8_t tx_fault; - - /* [Prop]: Transceiver EQUALIZATION - * [Desc]: Transceiver EQUALIZATION - * [Note]: SFP+/28 => SFF-8472 A2H Byte-114 - * QSFP28 => SFF-8636 03H Byte-234/235 - */ - uint8_t tx_eq[2]; - - /* [Prop]: OPTION VALUES - * [Desc]: The bits in the option field shall specify the options implemented in the transceiver. - * [Note]: SFP+/28 => SFF-8472 A0H Byte-64/65 - * QSFP+/28 => SFF-8636 00H Byte-193/195 - */ - uint8_t option[3]; - - uint8_t eeprom[256]; - uint8_t eeprom_update[8]; - int port_no; - - /* ========== Object private property ========== - */ - struct device *transvr_dev_p; - struct eeprom_map_s *eeprom_map_p; - struct i2c_client *i2c_client_p; - struct ioexp_obj_s *ioexp_obj_p; - struct transvr_worker_s *worker_p; - struct mutex lock; - char swp_name[32]; - int auto_config; - int auto_tx_disable; - int chan_id; - int chipset_type; - int curr_page; - int info; - int ioexp_virt_offset; - int lane_id[8]; - int layout; - int mode; - int retry; - int state; - int temp; - int type; - - /* ========== Object public functions ========== - */ - int (*get_id)(struct transvr_obj_s *self); - int (*get_eeprom)(struct transvr_obj_s *self, char *buf_p); - int (*get_ext_id)(struct transvr_obj_s *self); - int (*get_connector)(struct transvr_obj_s *self); - int (*get_vendor_name)(struct transvr_obj_s *self, char *buf_p); - int (*get_vendor_pn)(struct transvr_obj_s *self, char *buf_p); - int (*get_vendor_rev)(struct transvr_obj_s *self, char *buf_p); - int (*get_vendor_sn)(struct transvr_obj_s *self, char *buf_p); - int (*get_power_cls)(struct transvr_obj_s *self); - int (*get_br)(struct transvr_obj_s *self); - int (*get_len_sm)(struct transvr_obj_s *self); - int (*get_len_smf)(struct transvr_obj_s *self); - int (*get_len_om1)(struct transvr_obj_s *self); - int (*get_len_om2)(struct transvr_obj_s *self); - int (*get_len_om3)(struct transvr_obj_s *self); - int (*get_len_om4)(struct transvr_obj_s *self); - int (*get_comp_rev)(struct transvr_obj_s *self); - int (*get_comp_eth_1)(struct transvr_obj_s *self); - int (*get_comp_eth_10)(struct transvr_obj_s *self); - int (*get_comp_eth_10_40)(struct transvr_obj_s *self); - int (*get_comp_extend)(struct transvr_obj_s *self); - int (*get_cdr)(struct transvr_obj_s *self); - int (*get_rate_id)(struct transvr_obj_s *self); - int (*get_soft_rs0)(struct transvr_obj_s *self); - int (*get_soft_rs1)(struct transvr_obj_s *self); - int (*get_info)(struct transvr_obj_s *self); - int (*get_if_type)(struct transvr_obj_s *self, char *buf_p); - int (*get_if_speed)(struct transvr_obj_s *self, char *buf_p); - int (*get_if_lane)(struct transvr_obj_s *self, char *buf_p); - int (*get_curr_temp)(struct transvr_obj_s *self, char *buf_p); - int (*get_curr_vol)(struct transvr_obj_s *self, char *buf_p); - int (*get_soft_rx_los)(struct transvr_obj_s *self, char *buf_p); - int (*get_soft_tx_disable)(struct transvr_obj_s *self, char *buf_p); - int (*get_soft_tx_fault)(struct transvr_obj_s *self, char *buf_p); - int (*get_auto_tx_disable)(struct transvr_obj_s *self, char *buf_p); - int (*get_tx_bias)(struct transvr_obj_s *self, char *buf_p); - int (*get_tx_power)(struct transvr_obj_s *self, char *buf_p); - int (*get_rx_power)(struct transvr_obj_s *self, char *buf_p); - int (*get_tx_eq)(struct transvr_obj_s *self, char *buf_p); - int (*get_rx_am)(struct transvr_obj_s *self, char *buf_p); - int (*get_rx_em)(struct transvr_obj_s *self, char *buf_p); - int (*get_wavelength)(struct transvr_obj_s *self, char *buf_p); - int (*set_cdr)(struct transvr_obj_s *self, int input_val); - int (*set_soft_rs0)(struct transvr_obj_s *self, int input_val); - int (*set_soft_rs1)(struct transvr_obj_s *self, int input_val); - int (*set_soft_tx_disable)(struct transvr_obj_s *self, int input_val); - int (*set_auto_tx_disable)(struct transvr_obj_s *self, int input_val); - int (*set_tx_eq)(struct transvr_obj_s *self, int input_val); - int (*set_rx_am)(struct transvr_obj_s *self, int input_val); - int (*set_rx_em)(struct transvr_obj_s *self, int input_val); - - /* ========== Object private functions ========== - */ - int (*init)(struct transvr_obj_s *self); - int (*clean)(struct transvr_obj_s *self); - int (*check)(struct transvr_obj_s *self); - int (*update_all)(struct transvr_obj_s *self, int show_err); - int (*fsm_4_direct)(struct transvr_obj_s* self, char *caller_name); - int (*fsm_4_polling)(struct transvr_obj_s* self, char *caller_name); - int (*send_uevent)(struct transvr_obj_s* self, enum kobject_action u_action); - int (*dump_all)(struct transvr_obj_s* self); -}; - - -/* For AVL Mapping */ -struct transvr_avl_s { - char vendor_name[32]; - char vendor_pn[32]; - int (*init)(struct transvr_obj_s *self); -}; - - -/* Worker for long term task of transceiver */ -struct transvr_worker_s { - /* Task Parameter */ - struct transvr_obj_s *transvr_p; - struct transvr_worker_s *next_p; - struct transvr_worker_s *pre_p; - unsigned long trigger_time; - char func_name[64]; - int retry; - int state; - - /* Task private data */ - void *p_data; - - /* Call back function */ - int (*main_task)(struct transvr_worker_s *task); - int (*post_task)(struct transvr_worker_s *task); -}; - - -struct transvr_obj_s * -create_transvr_obj(char *swp_name, - int chan_id, - struct ioexp_obj_s *ioexp_obj_p, - int ioexp_virt_offset, - int transvr_type, - int chipset_type, - int run_mode); - -void lock_transvr_obj(struct transvr_obj_s *self); -void unlock_transvr_obj(struct transvr_obj_s *self); -int isolate_transvr_obj(struct transvr_obj_s *self); - -int resync_channel_tier_2(struct transvr_obj_s *self); - -void alarm_msg_2_user(struct transvr_obj_s *self, char *emsg); - -unsigned char *get_eeprom_update(void); -void set_eeprom_update(unsigned char value[8]); - -#endif /* TRANSCEIVER_H */ diff --git a/packages/platforms/inventec/x86-64/d7054q28b/onlp/Makefile b/packages/platforms/inventec/x86-64/d7054q28b/onlp/Makefile deleted file mode 100644 index 003238cf6..000000000 --- a/packages/platforms/inventec/x86-64/d7054q28b/onlp/Makefile +++ /dev/null @@ -1 +0,0 @@ -include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/inventec/x86-64/d7054q28b/onlp/PKG.yml b/packages/platforms/inventec/x86-64/d7054q28b/onlp/PKG.yml deleted file mode 100644 index a81555f92..000000000 --- a/packages/platforms/inventec/x86-64/d7054q28b/onlp/PKG.yml +++ /dev/null @@ -1 +0,0 @@ -!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/d7054q28b/onlp/builds/Makefile b/packages/platforms/inventec/x86-64/d7054q28b/onlp/builds/Makefile deleted file mode 100644 index e7437cb23..000000000 --- a/packages/platforms/inventec/x86-64/d7054q28b/onlp/builds/Makefile +++ /dev/null @@ -1,2 +0,0 @@ -FILTER=src -include $(ONL)/make/subdirs.mk diff --git a/packages/platforms/inventec/x86-64/d7054q28b/onlp/builds/lib/Makefile b/packages/platforms/inventec/x86-64/d7054q28b/onlp/builds/lib/Makefile deleted file mode 100644 index 0b9769747..000000000 --- a/packages/platforms/inventec/x86-64/d7054q28b/onlp/builds/lib/Makefile +++ /dev/null @@ -1,2 +0,0 @@ -PLATFORM := x86-64-inventec-d7054q28b -include $(ONL)/packages/base/any/onlp/builds/platform/libonlp-platform.mk diff --git a/packages/platforms/inventec/x86-64/d7054q28b/onlp/builds/onlpdump/Makefile b/packages/platforms/inventec/x86-64/d7054q28b/onlp/builds/onlpdump/Makefile deleted file mode 100644 index 97bb155dd..000000000 --- a/packages/platforms/inventec/x86-64/d7054q28b/onlp/builds/onlpdump/Makefile +++ /dev/null @@ -1,2 +0,0 @@ -PLATFORM := x86-64-inventec-d7054q28b -include $(ONL)/packages/base/any/onlp/builds/platform/onlps.mk diff --git a/packages/platforms/inventec/x86-64/d7054q28b/onlp/builds/x86_64_inventec_d7054q28b/.module b/packages/platforms/inventec/x86-64/d7054q28b/onlp/builds/x86_64_inventec_d7054q28b/.module deleted file mode 100644 index b7de4f1f7..000000000 --- a/packages/platforms/inventec/x86-64/d7054q28b/onlp/builds/x86_64_inventec_d7054q28b/.module +++ /dev/null @@ -1 +0,0 @@ -name: x86_64_inventec_d7054q28b diff --git a/packages/platforms/inventec/x86-64/d7054q28b/onlp/builds/x86_64_inventec_d7054q28b/Makefile b/packages/platforms/inventec/x86-64/d7054q28b/onlp/builds/x86_64_inventec_d7054q28b/Makefile deleted file mode 100644 index 8f0f81398..000000000 --- a/packages/platforms/inventec/x86-64/d7054q28b/onlp/builds/x86_64_inventec_d7054q28b/Makefile +++ /dev/null @@ -1,9 +0,0 @@ -############################################################################### -# -# -# -############################################################################### -include $(ONL)/make/config.mk -MODULE := x86_64_inventec_d7054q28b -AUTOMODULE := x86_64_inventec_d7054q28b -include $(BUILDER)/definemodule.mk diff --git a/packages/platforms/inventec/x86-64/d7054q28b/onlp/builds/x86_64_inventec_d7054q28b/module/auto/make.mk b/packages/platforms/inventec/x86-64/d7054q28b/onlp/builds/x86_64_inventec_d7054q28b/module/auto/make.mk deleted file mode 100644 index 05bad5794..000000000 --- a/packages/platforms/inventec/x86-64/d7054q28b/onlp/builds/x86_64_inventec_d7054q28b/module/auto/make.mk +++ /dev/null @@ -1,9 +0,0 @@ -############################################################################### -# -# 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/d7054q28b/onlp/builds/x86_64_inventec_d7054q28b/module/auto/x86_64_inventec_d7054q28b.yml b/packages/platforms/inventec/x86-64/d7054q28b/onlp/builds/x86_64_inventec_d7054q28b/module/auto/x86_64_inventec_d7054q28b.yml deleted file mode 100644 index f0cb16032..000000000 --- a/packages/platforms/inventec/x86-64/d7054q28b/onlp/builds/x86_64_inventec_d7054q28b/module/auto/x86_64_inventec_d7054q28b.yml +++ /dev/null @@ -1,50 +0,0 @@ -############################################################################### -# -# x86_64_inventec_d7054q28b Autogeneration Definitions. -# -############################################################################### - -cdefs: &cdefs -- X86_64_INVENTEC_D7054Q28B_CONFIG_INCLUDE_LOGGING: - doc: "Include or exclude logging." - default: 1 -- X86_64_INVENTEC_D7054Q28B_CONFIG_LOG_OPTIONS_DEFAULT: - doc: "Default enabled log options." - default: AIM_LOG_OPTIONS_DEFAULT -- X86_64_INVENTEC_D7054Q28B_CONFIG_LOG_BITS_DEFAULT: - doc: "Default enabled log bits." - default: AIM_LOG_BITS_DEFAULT -- X86_64_INVENTEC_D7054Q28B_CONFIG_LOG_CUSTOM_BITS_DEFAULT: - doc: "Default enabled custom log bits." - default: 0 -- X86_64_INVENTEC_D7054Q28B_CONFIG_PORTING_STDLIB: - doc: "Default all porting macros to use the C standard libraries." - default: 1 -- X86_64_INVENTEC_D7054Q28B_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS: - doc: "Include standard library headers for stdlib porting macros." - default: X86_64_INVENTEC_D7054Q28B_CONFIG_PORTING_STDLIB -- X86_64_INVENTEC_D7054Q28B_CONFIG_INCLUDE_UCLI: - doc: "Include generic uCli support." - default: 0 -- X86_64_INVENTEC_D7054Q28B_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_D7054Q28B_CONFIG_HEADER: - defs: *cdefs - basename: x86_64_inventec_d7054q28b_config - - portingmacro: - X86_64_INVENTEC_D7054Q28B: - macros: - - malloc - - free - - memset - - memcpy - - - vsnprintf - - snprintf - - strlen diff --git a/packages/platforms/inventec/x86-64/d7054q28b/onlp/builds/x86_64_inventec_d7054q28b/module/inc/x86_64_inventec_d7054q28b/x86_64_inventec_d7054q28b.x b/packages/platforms/inventec/x86-64/d7054q28b/onlp/builds/x86_64_inventec_d7054q28b/module/inc/x86_64_inventec_d7054q28b/x86_64_inventec_d7054q28b.x deleted file mode 100644 index 603d93f37..000000000 --- a/packages/platforms/inventec/x86-64/d7054q28b/onlp/builds/x86_64_inventec_d7054q28b/module/inc/x86_64_inventec_d7054q28b/x86_64_inventec_d7054q28b.x +++ /dev/null @@ -1,14 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#include - -/* <--auto.start.xmacro(ALL).define> */ -/* */ - -/* <--auto.start.xenum(ALL).define> */ -/* */ - - diff --git a/packages/platforms/inventec/x86-64/d7054q28b/onlp/builds/x86_64_inventec_d7054q28b/module/inc/x86_64_inventec_d7054q28b/x86_64_inventec_d7054q28b_config.h b/packages/platforms/inventec/x86-64/d7054q28b/onlp/builds/x86_64_inventec_d7054q28b/module/inc/x86_64_inventec_d7054q28b/x86_64_inventec_d7054q28b_config.h deleted file mode 100644 index 174dfae98..000000000 --- a/packages/platforms/inventec/x86-64/d7054q28b/onlp/builds/x86_64_inventec_d7054q28b/module/inc/x86_64_inventec_d7054q28b/x86_64_inventec_d7054q28b_config.h +++ /dev/null @@ -1,137 +0,0 @@ -/**************************************************************************//** - * - * @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/d7054q28b/onlp/builds/x86_64_inventec_d7054q28b/module/inc/x86_64_inventec_d7054q28b/x86_64_inventec_d7054q28b_dox.h b/packages/platforms/inventec/x86-64/d7054q28b/onlp/builds/x86_64_inventec_d7054q28b/module/inc/x86_64_inventec_d7054q28b/x86_64_inventec_d7054q28b_dox.h deleted file mode 100644 index 9d35e4de8..000000000 --- a/packages/platforms/inventec/x86-64/d7054q28b/onlp/builds/x86_64_inventec_d7054q28b/module/inc/x86_64_inventec_d7054q28b/x86_64_inventec_d7054q28b_dox.h +++ /dev/null @@ -1,26 +0,0 @@ -/**************************************************************************//** - * - * 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/d7054q28b/onlp/builds/x86_64_inventec_d7054q28b/module/inc/x86_64_inventec_d7054q28b/x86_64_inventec_d7054q28b_porting.h b/packages/platforms/inventec/x86-64/d7054q28b/onlp/builds/x86_64_inventec_d7054q28b/module/inc/x86_64_inventec_d7054q28b/x86_64_inventec_d7054q28b_porting.h deleted file mode 100644 index 590ea21ef..000000000 --- a/packages/platforms/inventec/x86-64/d7054q28b/onlp/builds/x86_64_inventec_d7054q28b/module/inc/x86_64_inventec_d7054q28b/x86_64_inventec_d7054q28b_porting.h +++ /dev/null @@ -1,97 +0,0 @@ -/**************************************************************************//** - * - * @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_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/d7054q28b/onlp/builds/x86_64_inventec_d7054q28b/module/make.mk b/packages/platforms/inventec/x86-64/d7054q28b/onlp/builds/x86_64_inventec_d7054q28b/module/make.mk deleted file mode 100644 index 1b13eecc3..000000000 --- a/packages/platforms/inventec/x86-64/d7054q28b/onlp/builds/x86_64_inventec_d7054q28b/module/make.mk +++ /dev/null @@ -1,10 +0,0 @@ -############################################################################### -# -# -# -############################################################################### -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/d7054q28b/onlp/builds/x86_64_inventec_d7054q28b/module/src/Makefile b/packages/platforms/inventec/x86-64/d7054q28b/onlp/builds/x86_64_inventec_d7054q28b/module/src/Makefile deleted file mode 100644 index 2fea5242a..000000000 --- a/packages/platforms/inventec/x86-64/d7054q28b/onlp/builds/x86_64_inventec_d7054q28b/module/src/Makefile +++ /dev/null @@ -1,9 +0,0 @@ -############################################################################### -# -# Local source generation targets. -# -############################################################################### - -ucli: - @../../../../tools/uclihandlers.py x86_64_inventec_d7054q28b_ucli.c - diff --git a/packages/platforms/inventec/x86-64/d7054q28b/onlp/builds/x86_64_inventec_d7054q28b/module/src/fani.c b/packages/platforms/inventec/x86-64/d7054q28b/onlp/builds/x86_64_inventec_d7054q28b/module/src/fani.c deleted file mode 100644 index 239704dc8..000000000 --- a/packages/platforms/inventec/x86-64/d7054q28b/onlp/builds/x86_64_inventec_d7054q28b/module/src/fani.c +++ /dev/null @@ -1,269 +0,0 @@ -/************************************************************ - * fani.c - * - * Copyright 2018 Inventec Technology Corporation. - * - ************************************************************ - * - * Fan Platform Implementation Defaults. - * - ***********************************************************/ -#include -#include -#include -#include -#include -#include "platform_lib.h" - -#define FAN_GPI_ON_MAIN_BOARD INV_PSOC_PREFIX"/fan_gpi" - -#define MAX_FAN_SPEED 18000 -#define MAX_PSU_FAN_SPEED 25500 - -#define PROJECT_NAME -#define LEN_FILE_NAME 80 - -static char* devfiles__[FAN_MAX] = /* must map with onlp_thermal_id */ -{ - "reserved", - INV_PSOC_PREFIX"/fan1_input", - INV_PSOC_PREFIX"/fan2_input", - INV_PSOC_PREFIX"/fan3_input", - INV_PSOC_PREFIX"/fan4_input", - INV_PSOC_PREFIX"/fan5_input", - INV_PSOC_PREFIX"/fan6_input", - INV_PSOC_PREFIX"/fan7_input", - INV_PSOC_PREFIX"/fan8_input", - INV_PSOC_PREFIX"/rpm_psu1", - INV_PSOC_PREFIX"/rpm_psu2", -}; - -#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_F2B | 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_F2B | ONLP_FAN_CAPS_GET_RPM | ONLP_FAN_CAPS_GET_PERCENTAGE), \ - 0, \ - 0, \ - ONLP_FAN_MODE_INVALID, \ - } - -/* Static fan information */ -onlp_fan_info_t linfo[FAN_MAX] = { - { }, /* 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_MAIN_BOARD(7), - MAKE_FAN_INFO_NODE_ON_MAIN_BOARD(8), - 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, FAN_GPI_ON_MAIN_BOARD); - if (ret < 0) { - return ONLP_STATUS_E_INTERNAL; - } - if (value & (1 << (fid-1))) { - info->status |= ONLP_FAN_STATUS_FAILED; - } - else { - info->status |= ONLP_FAN_STATUS_PRESENT; - info->status |= ONLP_FAN_STATUS_F2B; - } - - /* get front fan speed */ - ret = onlp_file_read_int(&value, devfiles__[fid]); - if (ret < 0) { - return ONLP_STATUS_E_INTERNAL; - } - info->rpm = value; - info->percentage = (info->rpm * 100) / MAX_PSU_FAN_SPEED; - - snprintf(info->model, ONLP_CONFIG_INFO_STR_MAX, "NA"); - snprintf(info->serial, ONLP_CONFIG_INFO_STR_MAX, "NA"); - - 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 fid, onlp_fan_info_t* info) -{ - int value, ret, index; - - info->status |= ONLP_FAN_STATUS_PRESENT; - info->status |= ONLP_FAN_STATUS_F2B; - - /* get fan direction */ - info->status |= _onlp_get_fan_direction_on_psu(); - - if (info->status & ONLP_FAN_STATUS_FAILED) { - return ONLP_STATUS_OK; - } - - index = ONLP_OID_ID_GET(info->hdr.id); - info->hdr.coids[0] = ONLP_FAN_ID_CREATE(index + CHASSIS_FAN_COUNT); - - /* get front fan speed */ - ret = onlp_file_read_int(&value, devfiles__[fid]); - if (ret < 0) { - return ONLP_STATUS_E_INTERNAL; - } - info->rpm = value; - info->percentage = (info->rpm * 100) / MAX_PSU_FAN_SPEED; - info->status |= (value == 0) ? ONLP_FAN_STATUS_FAILED : 0; - - snprintf(info->model, ONLP_CONFIG_INFO_STR_MAX, "NA"); - snprintf(info->serial, ONLP_CONFIG_INFO_STR_MAX, "NA"); - - 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: - 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 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_PSU1: - return psu_pmbus_info_set(PSU1_ID, "rpm_psu1", p); - case FAN_1_ON_PSU2: - return psu_pmbus_info_set(PSU2_ID, "rpm_psu2", p); - 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: - 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/d7054q28b/onlp/builds/x86_64_inventec_d7054q28b/module/src/ledi.c b/packages/platforms/inventec/x86-64/d7054q28b/onlp/builds/x86_64_inventec_d7054q28b/module/src/ledi.c deleted file mode 100644 index f9389cd72..000000000 --- a/packages/platforms/inventec/x86-64/d7054q28b/onlp/builds/x86_64_inventec_d7054q28b/module/src/ledi.c +++ /dev/null @@ -1,424 +0,0 @@ -/************************************************************ - * ledi.c - * - * Copyright 2018 Inventec Technology Corporation. - * - ************************************************************ - * - ***********************************************************/ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "platform_lib.h" - -#define filename "brightness" - -#define VALIDATE(_id) \ - do { \ - if(!ONLP_OID_IS_LED(_id)) { \ - return ONLP_STATUS_E_INVALID; \ - } \ - } while(0) - -static char* devfiles__[LED_MAX] = /* must map with onlp_thermal_id */ -{ - "reserved", - INV_CPLD_PREFIX"/%s_led", - INV_PSOC_PREFIX"/fan_led_%s1", - INV_PSOC_PREFIX"/fan_led_%s2", - INV_PSOC_PREFIX"/fan_led_%s3", - INV_PSOC_PREFIX"/fan_led_%s4", -}; - -/* - * Get the information for the given LED OID. - */ -static onlp_led_info_t linfo[LED_MAX] = -{ - { }, /* Not used */ - { - { ONLP_LED_ID_CREATE(LED_SYS), "Chassis LED (SYSTEM 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_MODE_ON, '0', - }, - { - { ONLP_LED_ID_CREATE(LED_FAN1), "Fan LED 1 (FAN1 LED)", 0 }, - ONLP_LED_STATUS_PRESENT, - ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_RED, - ONLP_LED_MODE_ON, '0', - }, - { - { ONLP_LED_ID_CREATE(LED_FAN2), "Fan LED 2 (FAN2 LED)", 0 }, - ONLP_LED_STATUS_PRESENT, - ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_RED, - ONLP_LED_MODE_ON, '0', - }, - { - { ONLP_LED_ID_CREATE(LED_FAN3), "Fan LED 3 (FAN3 LED)", 0 }, - ONLP_LED_STATUS_PRESENT, - ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_RED, - ONLP_LED_MODE_ON, '0', - }, - { - { ONLP_LED_ID_CREATE(LED_FAN4), "Fan LED 4 (FAN4 LED)", 0 }, - ONLP_LED_STATUS_PRESENT, - ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_RED, - ONLP_LED_MODE_ON, '0', - }, -}; - -/* - * This function will be called prior to any other onlp_ledi_* functions. - */ -static pthread_mutex_t diag_mutex; - -int -onlp_ledi_init(void) -{ - pthread_mutex_init(&diag_mutex, NULL); - - /* - * Diag LED Off - */ - onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_SYS), ONLP_LED_MODE_OFF); - - return ONLP_STATUS_OK; -} - -int onlp_chassis_led_read(char *pathp, char *buf, size_t len) -{ - FILE * fp; - - fp = fopen (pathp, "r"); - if(fp == NULL) { - perror("Error opening file"); - return(-1); - } - if( fgets (buf, len, fp) == NULL ) { - perror("Error fgets operation"); - } - fclose(fp); - - return(0); -} - -int onlp_chassis_led_write(char *pathp, char *buf) -{ - FILE * fp; - - fp = fopen (pathp, "w"); - if(fp == NULL) { - perror("Error opening file"); - return(-1); - } - if( fputs (buf, fp) == 0 ) { - perror("Error fputs operation"); - } - fclose(fp); - - return(0); -} - -int -onlp_ledi_info_get(onlp_oid_t id, onlp_led_info_t* info) -{ - int local_id, gret = 0, rret = 0; - char fullpath_grn[50] = {0}; - char fullpath_red[50] = {0}; - int gvalue = 0, rvalue = 0; - char gbuf[32] = {0}; - char rbuf[32] = {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 fullpath */ - switch (local_id) { - case LED_SYS: - sprintf(fullpath_grn, devfiles__[local_id], "grn"); - sprintf(fullpath_red, devfiles__[local_id], "red"); - - /* Set LED mode */ - gret = onlp_chassis_led_read(fullpath_grn, gbuf, 32); - rret = onlp_chassis_led_read(fullpath_red, rbuf, 32); - if (gret < 0 || rret < 0) { - DEBUG_PRINT("%s(%d): gret = %d, rret = %d\r\n", __FUNCTION__, __LINE__, gret, rret); - info->mode = ONLP_LED_MODE_OFF; - info->status = ONLP_LED_STATUS_FAILED; - break; - } - - info->status = ONLP_LED_STATUS_PRESENT; - if (gbuf[0] >= '1' && gbuf[0] <= '7' && rbuf[0] == '0') { - info->mode = ONLP_LED_MODE_GREEN; - info->status |= ONLP_LED_STATUS_ON; - } - else - if (rbuf[0] >= '1' && rbuf[0] <= '7' && gbuf[0] == '0') { - info->mode = ONLP_LED_MODE_RED; - info->status |= ONLP_LED_STATUS_ON; - } - else - if (gbuf[0] >= '1' && gbuf[0] <= '7' && rbuf[0] >= '1' && rbuf[0] <= '7') { - info->mode = ONLP_LED_MODE_ORANGE; - info->status |= ONLP_LED_STATUS_ON; - } - else - if (gbuf[0] == '0' && rbuf[0] == '0') { - info->mode = ONLP_LED_MODE_OFF; - info->status |= ONLP_LED_STATUS_ON; - } - else { - info->mode = ONLP_LED_MODE_OFF; - info->status = ONLP_LED_STATUS_FAILED; - } - break; - case LED_FAN1: - case LED_FAN2: - case LED_FAN3: - case LED_FAN4: - sprintf(fullpath_grn, devfiles__[local_id], "grn"); - - /* Set LED mode */ - if (onlp_file_read_int(&gvalue, fullpath_grn) != 0) { - DEBUG_PRINT("%s(%d)\r\n", __FUNCTION__, __LINE__); - info->mode = ONLP_LED_MODE_OFF; - info->status = ONLP_LED_STATUS_FAILED; - } - else - if (gvalue == 1) { - info->mode = ONLP_LED_MODE_GREEN; - info->status = ONLP_LED_STATUS_ON; - } - else - if (gvalue == 0) { - info->mode = ONLP_LED_MODE_OFF; - info->status = ONLP_LED_STATUS_ON; - } - - sprintf(fullpath_red, devfiles__[local_id], "red"); - - if (onlp_file_read_int(&rvalue, fullpath_red) != 0) { - DEBUG_PRINT("%s(%d)\r\n", __FUNCTION__, __LINE__); - info->mode = ONLP_LED_MODE_OFF; - info->status = ONLP_LED_STATUS_FAILED; - } - else - if (rvalue == 1) { - info->mode = ONLP_LED_MODE_RED; - info->status = ONLP_LED_STATUS_ON; - } - else - if (rvalue == 0) { - info->mode = ONLP_LED_MODE_OFF; - info->status = ONLP_LED_STATUS_ON; - } - break; - default: - DEBUG_PRINT("%s(%d) Invalid led id %d\r\n", __FUNCTION__, __LINE__, local_id); - break; - } - - return ONLP_STATUS_OK; -} - -int onlp_ledi_status_get(onlp_oid_t id, uint32_t* rv) -{ - int result = ONLP_STATUS_OK; - onlp_led_info_t linfo; - - result = onlp_ledi_info_get(id, &linfo); - *rv = linfo.status; - - return result; -} - -/* - * 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; -} - -#define HWMON_DEVICE_DIAG_PATH INV_PSOC_PREFIX"/subsystem/devices/0-0066/diag" -#define HWMON_DEVICE_CTRL_PATH INV_CPLD_PREFIX"/subsystem/devices/0-0055/ctl" - -#define MIN_ACC_SIZE (32) - -/* - * Store attr Section - */ -static int onlp_chassis_led_diag_enable(void) -{ - char tmp[MIN_ACC_SIZE]; - ssize_t ret; - - ret = onlp_chassis_led_read(HWMON_DEVICE_DIAG_PATH, &tmp[0], MIN_ACC_SIZE); - if (ret <= 0) { - return ret; - } - - if (tmp[0] == '0') { - pthread_mutex_lock(&diag_mutex); - ret = onlp_chassis_led_write(HWMON_DEVICE_DIAG_PATH, "1"); - if (ret < 0) { - pthread_mutex_unlock(&diag_mutex); - return ret; - } - - ret = onlp_chassis_led_write(HWMON_DEVICE_CTRL_PATH, "1"); - if (ret < 0) { - pthread_mutex_unlock(&diag_mutex); - return ret; - } - pthread_mutex_unlock(&diag_mutex); - } - - return ret; -} - -static int onlp_chassis_led_diag_disable(void) -{ - char tmp[MIN_ACC_SIZE]; - ssize_t ret; - - ret = onlp_chassis_led_read(HWMON_DEVICE_DIAG_PATH, &tmp[0], MIN_ACC_SIZE); - if (ret <= 0) { - return ret; - } - - if (tmp[0] == '1') { - pthread_mutex_lock(&diag_mutex); - ret = onlp_chassis_led_write(HWMON_DEVICE_DIAG_PATH, "1"); - if (ret < 0) { - pthread_mutex_unlock(&diag_mutex); - return 1; - } - - ret = onlp_chassis_led_write(HWMON_DEVICE_CTRL_PATH, "1"); - if (ret < 0) { - pthread_mutex_unlock(&diag_mutex); - return 1; - } - pthread_mutex_unlock(&diag_mutex); - } - return 1; -} - -/* - * 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) -{ - char fullpath_grn[50] = {0}; - char fullpath_red[50] = {0}; - char sys_buf[32] = {0}; - onlp_led_info_t linfo; - int ret = onlp_ledi_info_get(id, &linfo); - int local_id; - - VALIDATE(id); - - local_id = ONLP_OID_ID_GET(id); - - switch (mode) { - case ONLP_LED_MODE_OFF: - if (ret == ONLP_STATUS_OK && linfo.status & ONLP_LED_STATUS_ON && linfo.mode == ONLP_LED_MODE_OFF) { - return ONLP_STATUS_OK; - } - - sprintf(sys_buf, "%d", 0x0); - sprintf(fullpath_grn, devfiles__[local_id], "grn"); - ret = onlp_chassis_led_write(fullpath_grn, sys_buf); - - sprintf(sys_buf, "%d", 0x0); - sprintf(fullpath_red, devfiles__[local_id], "red"); - ret = onlp_chassis_led_write(fullpath_red, sys_buf); - break; - case ONLP_LED_MODE_RED: - if (ret == ONLP_STATUS_OK && linfo.status & ONLP_LED_STATUS_ON && linfo.mode == ONLP_LED_MODE_RED) { - return ONLP_STATUS_OK; - } - - sprintf(sys_buf, "%d", 0x0); - sprintf(fullpath_grn, devfiles__[local_id], "grn"); - ret = onlp_chassis_led_write(fullpath_grn, sys_buf); - - sprintf(sys_buf, "%d", 0x7); - sprintf(fullpath_red, devfiles__[local_id], "red"); - ret = onlp_chassis_led_write(fullpath_red, sys_buf); - break; - case ONLP_LED_MODE_GREEN: - if (ret == ONLP_STATUS_OK && linfo.status & ONLP_LED_STATUS_ON && linfo.mode == ONLP_LED_MODE_GREEN) { - return ONLP_STATUS_OK; - } - - sprintf(sys_buf, "%d", 0x7); - sprintf(fullpath_grn, devfiles__[local_id], "grn"); - ret = onlp_chassis_led_write(fullpath_grn, sys_buf); - - sprintf(sys_buf, "%d", 0x0); - sprintf(fullpath_red, devfiles__[local_id], "red"); - ret = onlp_chassis_led_write(fullpath_red, sys_buf); - break; - case ONLP_LED_MODE_ORANGE: - if (ret == ONLP_STATUS_OK && linfo.status & ONLP_LED_STATUS_ON && linfo.mode == ONLP_LED_MODE_ORANGE) { - return ONLP_STATUS_OK; - } - - sprintf(sys_buf, "%d", 0x7); - sprintf(fullpath_grn, devfiles__[local_id], "grn"); - ret = onlp_chassis_led_write(fullpath_grn, sys_buf); - - sprintf(sys_buf, "%d", 0x7); - sprintf(fullpath_red, devfiles__[local_id], "red"); - ret = onlp_chassis_led_write(fullpath_red, sys_buf); - break; - default: - DEBUG_PRINT("%s(%d) Invalid led mode %d\r\n", __FUNCTION__, __LINE__, mode); - return ONLP_STATUS_E_INTERNAL; - } - - switch (local_id) { - case LED_SYS: - onlp_chassis_led_diag_enable(); - sleep(1); - onlp_chassis_led_diag_disable(); - break; - default: - break; - } - - return ONLP_STATUS_OK; -} diff --git a/packages/platforms/inventec/x86-64/d7054q28b/onlp/builds/x86_64_inventec_d7054q28b/module/src/make.mk b/packages/platforms/inventec/x86-64/d7054q28b/onlp/builds/x86_64_inventec_d7054q28b/module/src/make.mk deleted file mode 100644 index f36bc85e0..000000000 --- a/packages/platforms/inventec/x86-64/d7054q28b/onlp/builds/x86_64_inventec_d7054q28b/module/src/make.mk +++ /dev/null @@ -1,9 +0,0 @@ -############################################################################### -# -# -# -############################################################################### - -LIBRARY := x86_64_inventec_d7054q28b -$(LIBRARY)_SUBDIR := $(dir $(lastword $(MAKEFILE_LIST))) -include $(BUILDER)/lib.mk diff --git a/packages/platforms/inventec/x86-64/d7054q28b/onlp/builds/x86_64_inventec_d7054q28b/module/src/platform_lib.c b/packages/platforms/inventec/x86-64/d7054q28b/onlp/builds/x86_64_inventec_d7054q28b/module/src/platform_lib.c deleted file mode 100644 index afaf19939..000000000 --- a/packages/platforms/inventec/x86-64/d7054q28b/onlp/builds/x86_64_inventec_d7054q28b/module/src/platform_lib.c +++ /dev/null @@ -1,184 +0,0 @@ -/************************************************************ - * platform_lib.c - * - * Copyright 2018 Inventec Corporation. - * - ************************************************************ - * - ***********************************************************/ -#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 32 -#define I2C_PSU_FAN_DIR_LEN 8 -#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)] = 0; - } - - if (strncmp(model_name, "YM-2651Y", 8) == 0) { - if (modelname) { - aim_strlcpy(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) { - aim_strlcpy(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) { - aim_strlcpy(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; - } - } - - if (strncmp(model_name, "DPS-150AB-10", 12) == 0) { - if (modelname) { - aim_strlcpy(modelname, model_name, 12); - } - - return PSU_TYPE_DC_12V_F2B; - } - - 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%d", PSU1_AC_PMBUS_PREFIX, node, PSU1_ID); - } - else - if (PSU2_ID == id) { - ret = onlp_file_read_int(value, "%s%s%d", PSU2_AC_PMBUS_PREFIX, node, PSU2_ID); - } - else { - return ONLP_STATUS_E_INTERNAL; - } - - 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%d", PSU1_AC_PMBUS_PREFIX, node, PSU1_ID); - break; - case PSU2_ID: - sprintf(path, "%s%s%d", PSU2_AC_PMBUS_PREFIX, node, PSU2_ID); - 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/d7054q28b/onlp/builds/x86_64_inventec_d7054q28b/module/src/platform_lib.h b/packages/platforms/inventec/x86-64/d7054q28b/onlp/builds/x86_64_inventec_d7054q28b/module/src/platform_lib.h deleted file mode 100644 index d0b96e68f..000000000 --- a/packages/platforms/inventec/x86-64/d7054q28b/onlp/builds/x86_64_inventec_d7054q28b/module/src/platform_lib.h +++ /dev/null @@ -1,139 +0,0 @@ -/************************************************************ - * platform_lib.h - * - * Copyright 2018 Inventec Technology Corporation. - * - ************************************************************ - * - ***********************************************************/ -#ifndef __PLATFORM_LIB_H__ -#define __PLATFORM_LIB_H__ - -#include "x86_64_inventec_d7054q28b_log.h" - -#define SWPS_CYPRESS_GA2 (1) - -#define ONLP_NODE_MAX_INT_LEN (8) -#define ONLP_NODE_MAX_PATH_LEN (64) - -#define INV_CPLD_COUNT (1) -#define INV_CPLD_PREFIX "/sys/bus/i2c/devices/0-0055/" -#define INV_PSOC_PREFIX "/sys/bus/i2c/devices/0-0066/" -#define INV_EPRM_PREFIX "/sys/bus/i2c/devices/0-0053/" -#define INV_CTMP_PREFIX "/sys/devices/platform/coretemp.0/hwmon/hwmon0/" - -#define INV_SFP_EEPROM_UPDATE "/sys/class/swps/module/eeprom_update" -#define CHASSIS_SFP_COUNT (54) - -/* - * Definitions of Chassis EEPROM - */ -#define EEPROM_NODE(node) INV_EPRM_PREFIX#node - -/* - * Definitions of D7054Q28B device - */ -enum onlp_thermal_id { - THERMAL_RESERVED = 0, - THERMAL_CPU_CORE_FIRST, - THERMAL_CPU_CORE_2, - THERMAL_CPU_CORE_3, - THERMAL_CPU_CORE_4, - THERMAL_CPU_CORE_LAST, - 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_2_ON_PSU1, - THERMAL_1_ON_PSU2, - THERMAL_2_ON_PSU2, - THERMAL_MAX -}; -#define CHASSIS_THERMAL_COUNT (10) - -enum onlp_fan_id { - FAN_RESERVED = 0, - FAN_1_ON_MAIN_BOARD, - FAN_2_ON_MAIN_BOARD, - FAN_3_ON_MAIN_BOARD, - FAN_4_ON_MAIN_BOARD, - FAN_5_ON_MAIN_BOARD, - FAN_6_ON_MAIN_BOARD, - FAN_7_ON_MAIN_BOARD, - FAN_8_ON_MAIN_BOARD, - FAN_1_ON_PSU1, - FAN_1_ON_PSU2, - FAN_MAX -}; -#define CHASSIS_FAN_COUNT (8) - -enum onlp_led_id { - LED_RESERVED = 0, - LED_SYS, - LED_FAN1, - LED_FAN2, - LED_FAN3, - LED_FAN4, - LED_MAX -}; -#define CHASSIS_LED_COUNT (1) - -enum onlp_psu_id { - PSU_RESERVED = 0, - PSU1_ID, - PSU2_ID, - PSU_MAX -}; -#define CHASSIS_PSU_COUNT (2) - -#define PSU1_AC_PMBUS_PREFIX INV_PSOC_PREFIX -#define PSU2_AC_PMBUS_PREFIX INV_PSOC_PREFIX - -#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 INV_CPLD_PREFIX -#define PSU2_AC_HWMON_PREFIX INV_CPLD_PREFIX - -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 PSU1_AC_HWMON_NODE(node) PSU1_AC_HWMON_PREFIX#node -#define PSU2_AC_HWMON_NODE(node) PSU2_AC_HWMON_PREFIX#node - -/* - * Definitions of FAN device - */ -#define FAN_BOARD_PATH INV_PSOC_PREFIX -#define FAN_NODE(node) FAN_BOARD_PATH#node - -/* - * Prototypes - */ -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); - -#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/d7054q28b/onlp/builds/x86_64_inventec_d7054q28b/module/src/psui.c b/packages/platforms/inventec/x86-64/d7054q28b/onlp/builds/x86_64_inventec_d7054q28b/module/src/psui.c deleted file mode 100644 index 7ebc335af..000000000 --- a/packages/platforms/inventec/x86-64/d7054q28b/onlp/builds/x86_64_inventec_d7054q28b/module/src/psui.c +++ /dev/null @@ -1,256 +0,0 @@ -/************************************************************ - * psui.c - * - * Copyright 2018 Inventec Technology Corporation. - * - ************************************************************ - * - ***********************************************************/ -#include -#include -#include -#include -#include -#include -#include "platform_lib.h" - -#define PSU_STATUS_PRESENT (0) -#define PSU_STATUS_POWER_GOOD (1) -#define PSU_STATUS_UNPOWERED (2) -#define PSU_STATUS_FAULT (4) -#define PSU_STATUS_UNINSTALLED (7) - -#define VALIDATE(_id) \ - do { \ - if(!ONLP_OID_IS_PSU(_id)) { \ - return ONLP_STATUS_E_INVALID; \ - } \ - } while(0) - -static char* status_devfiles__[PSU_MAX] = /* must map with onlp_psu_id */ -{ - "reserved", - INV_CPLD_PREFIX"/psu0", - INV_CPLD_PREFIX"/psu1", -}; - -static char* module_devfiles__[PSU_MAX] = /* must map with onlp_psu_id */ -{ - "reserved", - INV_PSOC_PREFIX"/psoc_psu1_%s", - INV_PSOC_PREFIX"/psoc_psu2_%s", -}; - -static int -psu_status_info_get(int id, char *node, int *value) -{ - int ret = 0; - char node_path[ONLP_NODE_MAX_PATH_LEN] = {0}; - - *value = 0; - if (PSU1_ID == id) { - sprintf(node_path, status_devfiles__[id]); - } - else if (PSU2_ID == id) { - sprintf(node_path, status_devfiles__[id]); - } - - 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 ONLP_STATUS_OK; -} - - -int -onlp_psui_init(void) -{ - return ONLP_STATUS_OK; -} - -static void -psu_module_name_get(int id, onlp_psu_info_t* info) -{ - char node_path[ONLP_NODE_MAX_PATH_LEN] = {0}; - uint8_t temp[ONLP_CONFIG_INFO_STR_MAX] = {0}; - int ret, len; - -#if 1 - aim_strlcpy(info->model, "N/A", 3); -#else - memset(node_path, 0, ONLP_NODE_MAX_PATH_LEN); - sprintf(node_path, module_devfiles__[id], "model"); - ret = onlp_file_read(temp, ONLP_CONFIG_INFO_STR_MAX, &len, node_path); - if (ret == 0) { - /*remove the '\n'*/ - temp[strlen((char*)temp)-1] = 0; - snprintf(info->model, ONLP_CONFIG_INFO_STR_MAX, "%s", temp); - } - else { - AIM_LOG_ERROR("Unable to read model name from file(%s)\r\n", node_path); - aim_strlcpy(info->model, "N/A", 3); - } -#endif - - memset(node_path, 0, ONLP_NODE_MAX_PATH_LEN); - sprintf(node_path, module_devfiles__[id], "serial"); - ret = onlp_file_read(temp, ONLP_CONFIG_INFO_STR_MAX, &len, node_path); - if (ret == 0) { - /*remove the '\n'*/ - temp[strlen((char*)temp)-1] = 0; - snprintf(info->serial, ONLP_CONFIG_INFO_STR_MAX, "%s", temp); - } - else { - AIM_LOG_ERROR("Unable to read model name from file(%s)\r\n", node_path); - aim_strlcpy(info->serial, "N/A", 3); - } -} - -static int -psu_module_info_get(int id, onlp_psu_info_t* info) -{ - int ret = 0; - char node_path[ONLP_NODE_MAX_PATH_LEN] = {0}; - int value = 0; - - info->caps |= ONLP_PSU_CAPS_DC12; - - memset(node_path, 0, ONLP_NODE_MAX_PATH_LEN); - sprintf(node_path, module_devfiles__[id], "vout"); - ret = onlp_file_read_int(&value, node_path); - if (ret < 0) { - AIM_LOG_ERROR("Unable to read vout from file(%s)\r\n", node_path); - } - else { - info->mvout = value; - info->caps |= ONLP_PSU_CAPS_VOUT; - } - - memset(node_path, 0, ONLP_NODE_MAX_PATH_LEN); - sprintf(node_path, module_devfiles__[id], "iout"); - ret = onlp_file_read_int(&value, node_path); - if (ret < 0) { - AIM_LOG_ERROR("Unable to read iout from file(%s)\r\n", node_path); - } - else { - info->miout = value; - info->caps |= ONLP_PSU_CAPS_IOUT; - } - - memset(node_path, 0, ONLP_NODE_MAX_PATH_LEN); - sprintf(node_path, module_devfiles__[id], "pout"); - ret = onlp_file_read_int(&value, node_path); - if (ret < 0) { - AIM_LOG_ERROR("Unable to read pout from file(%s)\r\n", node_path); - } - else { - info->mpout = value; - info->caps |= ONLP_PSU_CAPS_POUT; - } - - memset(node_path, 0, ONLP_NODE_MAX_PATH_LEN); - sprintf(node_path, module_devfiles__[id], "vin"); - ret = onlp_file_read_int(&value, node_path); - if (ret < 0) { - AIM_LOG_ERROR("Unable to read vin from file(%s)\r\n", node_path); - } - else { - info->mvin = value; - info->caps |= ONLP_PSU_CAPS_VIN; - } - - memset(node_path, 0, ONLP_NODE_MAX_PATH_LEN); - sprintf(node_path, module_devfiles__[id], "iin"); - ret = onlp_file_read_int(&value, node_path); - if (ret < 0) { - AIM_LOG_ERROR("Unable to read iin from file(%s)\r\n", node_path); - } - else { - info->miin = value; - info->caps |= ONLP_PSU_CAPS_IIN; - } - - memset(node_path, 0, ONLP_NODE_MAX_PATH_LEN); - sprintf(node_path, module_devfiles__[id], "pin"); - ret = onlp_file_read_int(&value, node_path); - if (ret < 0) { - AIM_LOG_ERROR("Unable to read pin from file(%s)\r\n", node_path); - } - else { - info->mpin = value; - info->caps |= ONLP_PSU_CAPS_PIN; - } - - psu_module_name_get(id, info); - 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_THERMAL_ID_CREATE(THERMAL_1_ON_PSU1), - ONLP_THERMAL_ID_CREATE(THERMAL_2_ON_PSU1), - ONLP_FAN_ID_CREATE(FAN_1_ON_PSU1) - } - }, - }, - { - { - ONLP_PSU_ID_CREATE(PSU2_ID), "PSU-2", 0, - { - ONLP_THERMAL_ID_CREATE(THERMAL_1_ON_PSU2), - ONLP_THERMAL_ID_CREATE(THERMAL_2_ON_PSU2), - ONLP_FAN_ID_CREATE(FAN_1_ON_PSU2) - } - }, - } -}; - -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 ((ret = psu_status_info_get(index, "psu", &val)) == ONLP_STATUS_E_INTERNAL) { - printf("Unable to read PSU(%d) node(psu)\r\n", index); - return ret; - } - - if (val == 0) { - info->status = ONLP_PSU_STATUS_PRESENT; - } - else - if (val == 1) { - info->status = ONLP_PSU_STATUS_UNPLUGGED; - return ret; - } - else { - info->status = ONLP_PSU_STATUS_FAILED; - return ret; - } - - if ((ret = psu_module_info_get(index, info)) != ONLP_STATUS_OK) { - printf("Unable to read PSU(%d) module information\r\n", index); - } - - return ret; -} diff --git a/packages/platforms/inventec/x86-64/d7054q28b/onlp/builds/x86_64_inventec_d7054q28b/module/src/sfpi.c b/packages/platforms/inventec/x86-64/d7054q28b/onlp/builds/x86_64_inventec_d7054q28b/module/src/sfpi.c deleted file mode 100644 index cb12fe7b5..000000000 --- a/packages/platforms/inventec/x86-64/d7054q28b/onlp/builds/x86_64_inventec_d7054q28b/module/src/sfpi.c +++ /dev/null @@ -1,270 +0,0 @@ -/************************************************************ - * sfpi.c - * - * Copyright 2018 Inventec Technology Corporation. - * - ************************************************************ - * - ***********************************************************/ -#include - -#include /* For O_RDWR && open */ -#include -#include -#include -#include -#include -#include -#include "platform_lib.h" - -static char sfp_node_path[ONLP_NODE_MAX_PATH_LEN] = {0}; - -#define NUM_OF_SFP_PORT (CHASSIS_SFP_COUNT) -static const int sfp_mux_index[NUM_OF_SFP_PORT] = { -#ifdef SWPS_CYPRESS_GA1 -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, -50, 51, 52, 53, 54, 55, 56, 57, -58, 59, 60, 61, 62, 63 -#endif -#ifdef SWPS_CYPRESS_GA2 -11, 10, 13, 12, 15, 14, 17, 16, -19, 18, 21, 20, 23, 22, 25, 24, -27, 26, 29, 28, 31, 30, 33, 32, -35, 34, 37, 36, 39, 38, 41, 40, -43, 42, 45, 44, 47, 46, 49, 48, -51, 50, 53, 52, 55, 54, 57, 56, -59, 58, 61, 60, 63, 62 -#endif -#ifdef SWPS_CYPRESS_BAI -11, 10, 13, 12, 15, 14, 17, 16, -19, 18, 21, 20, 23, 22, 25, 24, -27, 26, 29, 28, 31, 30, 33, 32, -35, 34, 37, 36, 39, 38, 41, 40, -43, 42, 45, 44, 47, 46, 49, 48, -51, 50, 53, 52, 55, 54, 57, 56, -59, 58, 61, 60, 63, 62 -#endif -}; - -#define FRONT_PORT_TO_MUX_INDEX(port) (sfp_mux_index[port]) - -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/class/swps/port%d/%s", 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, 54} - */ - 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, "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; - } - if (present == 0) { - present = 1; - } - else - if (present == 1) { - present = 0; - } - else { - AIM_LOG_ERROR("Unvalid present status %d from port(%d)\r\n",present,port); - return ONLP_STATUS_E_INTERNAL; - } - return present; -} - -int -onlp_sfpi_presence_bitmap_get(onlp_sfp_bitmap_t* dst) -{ - uint32_t presence_all[2] = {0}; - int port, ret, index; - - for (port = 0, index = 0; port < NUM_OF_SFP_PORT; port++) { - if (port == 32) { - index = 1; - } - - ret = onlp_sfpi_is_present(port); - if (ret == 1) { - presence_all[index] |= (1<>= 1; - } - return ONLP_STATUS_OK; -} - -int -onlp_sfpi_eeprom_read(int port, uint8_t data[256]) -{ -#if 0 - int bus = FRONT_PORT_TO_MUX_INDEX(port); - - memset(data, 0, 256); - /* Read eeprom information into data[] */ - if (onlp_i2c_read(bus, 0x50, 0x00, 256, data, 0) != 0) - { - AIM_LOG_ERROR("Unable to read eeprom from port(%d)\r\n", port); - return ONLP_STATUS_E_INTERNAL; - } -#else - char* path; - 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); - path = sfp_get_port_path(port, "eeprom"); - if (onlp_file_read(&data[0], 256, &len, path) < 0) { - AIM_LOG_ERROR("Unable to read eeprom from port(%d)\r\n", port); - return ONLP_STATUS_E_INTERNAL; - } -#endif - 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_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); - int ret = onlp_i2c_writeb(bus, devaddr, addr, value, ONLP_I2C_F_FORCE); - - if (ret == 0) { - unsigned char buf[8] = { 0 }; - char str[20]; - - buf[port/8] = (1 << port%8); - sprintf(str, "0x%02x%02x%02x%02x%02x%02x%02x%02x", buf[7],buf[6],buf[5],buf[4],buf[3],buf[2],buf[1],buf[0]); - if (onlp_file_write((uint8_t*)str, 20, INV_SFP_EEPROM_UPDATE) < 0) { - AIM_LOG_ERROR("Unable to write eeprom_update for port(%d)\r\n", port); - return ONLP_STATUS_E_INTERNAL; - } - return ONLP_STATUS_OK; - } - AIM_LOG_ERROR("Unable to read eeprom_update from port(%d)\r\n", port); - return ret; -} - -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); - int ret = onlp_i2c_writew(bus, devaddr, addr, value, ONLP_I2C_F_FORCE); - - if (ret == 0) { - unsigned char buf[8] = { 0 }; - char str[20]; - - buf[port/8] = (1 << port%8); - sprintf(str, "0x%02x%02x%02x%02x%02x%02x%02x%02x", buf[7],buf[6],buf[5],buf[4],buf[3],buf[2],buf[1],buf[0]); - if (onlp_file_write((uint8_t*)str, 20, INV_SFP_EEPROM_UPDATE) < 0) { - AIM_LOG_ERROR("Unable to write eeprom_update for port(%d)\r\n", port); - return ONLP_STATUS_E_INTERNAL; - } - return ONLP_STATUS_OK; - } - AIM_LOG_ERROR("Unable to read eeprom_update from port(%d)\r\n", port); - return ret; -} - -int -onlp_sfpi_denit(void) -{ - return ONLP_STATUS_OK; -} diff --git a/packages/platforms/inventec/x86-64/d7054q28b/onlp/builds/x86_64_inventec_d7054q28b/module/src/sysi.c b/packages/platforms/inventec/x86-64/d7054q28b/onlp/builds/x86_64_inventec_d7054q28b/module/src/sysi.c deleted file mode 100644 index b13cc6bf8..000000000 --- a/packages/platforms/inventec/x86-64/d7054q28b/onlp/builds/x86_64_inventec_d7054q28b/module/src/sysi.c +++ /dev/null @@ -1,110 +0,0 @@ -/************************************************************ - * sysi.c - * - * Copyright 2018 Inventec Technology Corporation. - * - ************************************************************ - * - ***********************************************************/ -#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_CPLD INV_CPLD_COUNT - -#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 (CHASSIS_PSU_COUNT) -#define NUM_OF_LED_ON_MAIN_BROAD (CHASSIS_LED_COUNT) - -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, EEPROM_NODE(eeprom)) == 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)); - - /* 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; -} - -static char *arr_cplddev_version[NUM_OF_CPLD] = -{ - INV_CPLD_PREFIX"/version", -}; - -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, arr_cplddev_version[i]) < 0) { - return ONLP_STATUS_E_INTERNAL; - } - } - pi->cpld_versions = aim_fstrdup("%d.%d", v[0], v[1]); - return 0; -} - -void -onlp_sysi_platform_info_free(onlp_platform_info_t* pi) -{ - aim_free(pi->cpld_versions); -} diff --git a/packages/platforms/inventec/x86-64/d7054q28b/onlp/builds/x86_64_inventec_d7054q28b/module/src/thermali.c b/packages/platforms/inventec/x86-64/d7054q28b/onlp/builds/x86_64_inventec_d7054q28b/module/src/thermali.c deleted file mode 100644 index 178eb6a7c..000000000 --- a/packages/platforms/inventec/x86-64/d7054q28b/onlp/builds/x86_64_inventec_d7054q28b/module/src/thermali.c +++ /dev/null @@ -1,147 +0,0 @@ -/************************************************************ - * thermali.c - * - * Copyright 2018 Inventec Technology Corporation. - * - ************************************************************ - * - * 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) - -static char* devfiles__[THERMAL_MAX] = /* must map with onlp_thermal_id */ -{ - "reserved", - INV_CTMP_PREFIX"/temp1_%s", - INV_CTMP_PREFIX"/temp2_%s", - INV_CTMP_PREFIX"/temp3_%s", - INV_CTMP_PREFIX"/temp4_%s", - INV_CTMP_PREFIX"/temp5_%s", - INV_PSOC_PREFIX"/temp1_input", - INV_PSOC_PREFIX"/temp2_input", - INV_PSOC_PREFIX"/temp3_input", - INV_PSOC_PREFIX"/temp4_input", - INV_PSOC_PREFIX"/temp5_input", - INV_PSOC_PREFIX"/thermal_psu1", - INV_PSOC_PREFIX"/thermal2_psu1", - INV_PSOC_PREFIX"/thermal_psu2", - INV_PSOC_PREFIX"/thermal2_psu2", -}; - -/* Static values */ -static onlp_thermal_info_t linfo[THERMAL_MAX] = { - { }, /* Not used */ - { { ONLP_THERMAL_ID_CREATE(THERMAL_CPU_CORE_FIRST), "Physical id 0", 0}, - ONLP_THERMAL_STATUS_PRESENT, - ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS - }, - { { ONLP_THERMAL_ID_CREATE(THERMAL_CPU_CORE_2), "CPU Core 0", 0}, - ONLP_THERMAL_STATUS_PRESENT, - ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS - }, - { { ONLP_THERMAL_ID_CREATE(THERMAL_CPU_CORE_3), "CPU Core 1", 0}, - ONLP_THERMAL_STATUS_PRESENT, - ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS - }, - { { ONLP_THERMAL_ID_CREATE(THERMAL_CPU_CORE_4), "CPU Core 2", 0}, - ONLP_THERMAL_STATUS_PRESENT, - ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS - }, - { { ONLP_THERMAL_ID_CREATE(THERMAL_CPU_CORE_LAST), "CPU Core 3", 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_3_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_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_2_ON_PSU1), "PSU-1 Thermal Sensor 2", 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 - }, - { { ONLP_THERMAL_ID_CREATE(THERMAL_2_ON_PSU2), "PSU-2 Thermal Sensor 2", 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_FIRST && local_id <= THERMAL_CPU_CORE_LAST) { - char desc[32], *dp = &desc[0]; - int rv = onlp_file_read_str(&dp, devfiles__[local_id], "label"); - if (rv > 0) { - memset (info->hdr.description, 0, ONLP_OID_DESC_SIZE); - aim_strlcpy(info->hdr.description, dp, rv); - } - - /* Set the onlp_oid_hdr_t and capabilities */ - return onlp_file_read_int(&info->mcelsius, devfiles__[local_id], "input"); - } - return onlp_file_read_int(&info->mcelsius, devfiles__[local_id]); -} diff --git a/packages/platforms/inventec/x86-64/d7054q28b/onlp/builds/x86_64_inventec_d7054q28b/module/src/x86_64_inventec_d7054q28b_config.c b/packages/platforms/inventec/x86-64/d7054q28b/onlp/builds/x86_64_inventec_d7054q28b/module/src/x86_64_inventec_d7054q28b_config.c deleted file mode 100644 index 7a23f2fe9..000000000 --- a/packages/platforms/inventec/x86-64/d7054q28b/onlp/builds/x86_64_inventec_d7054q28b/module/src/x86_64_inventec_d7054q28b_config.c +++ /dev/null @@ -1,80 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#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/d7054q28b/onlp/builds/x86_64_inventec_d7054q28b/module/src/x86_64_inventec_d7054q28b_enums.c b/packages/platforms/inventec/x86-64/d7054q28b/onlp/builds/x86_64_inventec_d7054q28b/module/src/x86_64_inventec_d7054q28b_enums.c deleted file mode 100644 index 8d0e73383..000000000 --- a/packages/platforms/inventec/x86-64/d7054q28b/onlp/builds/x86_64_inventec_d7054q28b/module/src/x86_64_inventec_d7054q28b_enums.c +++ /dev/null @@ -1,10 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#include - -/* <--auto.start.enum(ALL).source> */ -/* */ - diff --git a/packages/platforms/inventec/x86-64/d7054q28b/onlp/builds/x86_64_inventec_d7054q28b/module/src/x86_64_inventec_d7054q28b_int.h b/packages/platforms/inventec/x86-64/d7054q28b/onlp/builds/x86_64_inventec_d7054q28b/module/src/x86_64_inventec_d7054q28b_int.h deleted file mode 100644 index 7648b0515..000000000 --- a/packages/platforms/inventec/x86-64/d7054q28b/onlp/builds/x86_64_inventec_d7054q28b/module/src/x86_64_inventec_d7054q28b_int.h +++ /dev/null @@ -1,12 +0,0 @@ -/**************************************************************************//** - * - * 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/d7054q28b/onlp/builds/x86_64_inventec_d7054q28b/module/src/x86_64_inventec_d7054q28b_log.c b/packages/platforms/inventec/x86-64/d7054q28b/onlp/builds/x86_64_inventec_d7054q28b/module/src/x86_64_inventec_d7054q28b_log.c deleted file mode 100644 index 16766b74c..000000000 --- a/packages/platforms/inventec/x86-64/d7054q28b/onlp/builds/x86_64_inventec_d7054q28b/module/src/x86_64_inventec_d7054q28b_log.c +++ /dev/null @@ -1,18 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#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/d7054q28b/onlp/builds/x86_64_inventec_d7054q28b/module/src/x86_64_inventec_d7054q28b_log.h b/packages/platforms/inventec/x86-64/d7054q28b/onlp/builds/x86_64_inventec_d7054q28b/module/src/x86_64_inventec_d7054q28b_log.h deleted file mode 100644 index b81490790..000000000 --- a/packages/platforms/inventec/x86-64/d7054q28b/onlp/builds/x86_64_inventec_d7054q28b/module/src/x86_64_inventec_d7054q28b_log.h +++ /dev/null @@ -1,12 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#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/d7054q28b/onlp/builds/x86_64_inventec_d7054q28b/module/src/x86_64_inventec_d7054q28b_module.c b/packages/platforms/inventec/x86-64/d7054q28b/onlp/builds/x86_64_inventec_d7054q28b/module/src/x86_64_inventec_d7054q28b_module.c deleted file mode 100644 index 88aad0ec7..000000000 --- a/packages/platforms/inventec/x86-64/d7054q28b/onlp/builds/x86_64_inventec_d7054q28b/module/src/x86_64_inventec_d7054q28b_module.c +++ /dev/null @@ -1,24 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#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/d7054q28b/onlp/builds/x86_64_inventec_d7054q28b/module/src/x86_64_inventec_d7054q28b_ucli.c b/packages/platforms/inventec/x86-64/d7054q28b/onlp/builds/x86_64_inventec_d7054q28b/module/src/x86_64_inventec_d7054q28b_ucli.c deleted file mode 100644 index 8e2b5bb54..000000000 --- a/packages/platforms/inventec/x86-64/d7054q28b/onlp/builds/x86_64_inventec_d7054q28b/module/src/x86_64_inventec_d7054q28b_ucli.c +++ /dev/null @@ -1,50 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#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/d7054q28b/platform-config/Makefile b/packages/platforms/inventec/x86-64/d7054q28b/platform-config/Makefile deleted file mode 100644 index 003238cf6..000000000 --- a/packages/platforms/inventec/x86-64/d7054q28b/platform-config/Makefile +++ /dev/null @@ -1 +0,0 @@ -include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/inventec/x86-64/d7054q28b/platform-config/r0/Makefile b/packages/platforms/inventec/x86-64/d7054q28b/platform-config/r0/Makefile deleted file mode 100644 index 003238cf6..000000000 --- a/packages/platforms/inventec/x86-64/d7054q28b/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/inventec/x86-64/d7054q28b/platform-config/r0/PKG.yml b/packages/platforms/inventec/x86-64/d7054q28b/platform-config/r0/PKG.yml deleted file mode 100644 index 4e546de15..000000000 --- a/packages/platforms/inventec/x86-64/d7054q28b/platform-config/r0/PKG.yml +++ /dev/null @@ -1 +0,0 @@ -!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/d7054q28b/platform-config/r0/src/lib/x86-64-inventec-d7054q28b-r0.yml b/packages/platforms/inventec/x86-64/d7054q28b/platform-config/r0/src/lib/x86-64-inventec-d7054q28b-r0.yml deleted file mode 100644 index 37970f494..000000000 --- a/packages/platforms/inventec/x86-64/d7054q28b/platform-config/r0/src/lib/x86-64-inventec-d7054q28b-r0.yml +++ /dev/null @@ -1,31 +0,0 @@ ---- - -###################################################################### -# -# 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/d7054q28b/platform-config/r0/src/python/x86_64_inventec_d7054q28b_r0/__init__.py b/packages/platforms/inventec/x86-64/d7054q28b/platform-config/r0/src/python/x86_64_inventec_d7054q28b_r0/__init__.py deleted file mode 100644 index 5ab7bc124..000000000 --- a/packages/platforms/inventec/x86-64/d7054q28b/platform-config/r0/src/python/x86_64_inventec_d7054q28b_r0/__init__.py +++ /dev/null @@ -1,20 +0,0 @@ -from onl.platform.base import * -from onl.platform.inventec import * - -class OnlPlatform_x86_64_inventec_d7054q28b_r0(OnlPlatformInventec, - OnlPlatformPortConfig_48x25_6x100): - PLATFORM='x86-64-inventec-d7054q28b-r0' - MODEL="X86-D7054Q28B" - SYS_OBJECT_ID=".7054.1" - - def baseconfig(self): - os.system("insmod /lib/modules/`uname -r`/kernel/drivers/gpio/gpio-ich.ko") - self.insmod('inv_platform') - self.insmod('inv_psoc') - self.insmod('inv_cpld') - self.new_i2c_device('inv_eeprom', 0x53, 0) - self.insmod('inv_eeprom') - self.insmod('swps') - #self.insmod('vpd') - #self.insmod('inv_pthread') - return True diff --git a/packages/platforms/inventec/x86-64/d7264q28b/.gitignore b/packages/platforms/inventec/x86-64/d7264q28b/.gitignore deleted file mode 100644 index c25c4f5bf..000000000 --- a/packages/platforms/inventec/x86-64/d7264q28b/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -*x86*64*inventec*d7264q28b*.mk -onlpdump.mk diff --git a/packages/platforms/inventec/x86-64/d7264q28b/Makefile b/packages/platforms/inventec/x86-64/d7264q28b/Makefile deleted file mode 100644 index 003238cf6..000000000 --- a/packages/platforms/inventec/x86-64/d7264q28b/Makefile +++ /dev/null @@ -1 +0,0 @@ -include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/inventec/x86-64/d7264q28b/modules/Makefile b/packages/platforms/inventec/x86-64/d7264q28b/modules/Makefile deleted file mode 100644 index 003238cf6..000000000 --- a/packages/platforms/inventec/x86-64/d7264q28b/modules/Makefile +++ /dev/null @@ -1 +0,0 @@ -include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/inventec/x86-64/d7264q28b/modules/PKG.yml b/packages/platforms/inventec/x86-64/d7264q28b/modules/PKG.yml deleted file mode 100644 index 546fbdb32..000000000 --- a/packages/platforms/inventec/x86-64/d7264q28b/modules/PKG.yml +++ /dev/null @@ -1 +0,0 @@ -!include $ONL_TEMPLATES/platform-modules.yml VENDOR=inventec BASENAME=x86-64-inventec-d7264q28b ARCH=amd64 KERNELS="onl-kernel-3.16-lts-x86-64-all:amd64" diff --git a/packages/platforms/inventec/x86-64/d7264q28b/modules/builds/.gitignore b/packages/platforms/inventec/x86-64/d7264q28b/modules/builds/.gitignore deleted file mode 100644 index a65b41774..000000000 --- a/packages/platforms/inventec/x86-64/d7264q28b/modules/builds/.gitignore +++ /dev/null @@ -1 +0,0 @@ -lib diff --git a/packages/platforms/inventec/x86-64/d7264q28b/modules/builds/Makefile b/packages/platforms/inventec/x86-64/d7264q28b/modules/builds/Makefile deleted file mode 100644 index a6644096a..000000000 --- a/packages/platforms/inventec/x86-64/d7264q28b/modules/builds/Makefile +++ /dev/null @@ -1,6 +0,0 @@ -KERNELS := onl-kernel-3.16-lts-x86-64-all:amd64 -KMODULES := src -VENDOR := inventec -BASENAME := x86-64-inventec-d7264q28b -ARCH := x86_64 -include $(ONL)/make/kmodule.mk diff --git a/packages/platforms/inventec/x86-64/d7264q28b/modules/builds/src/Makefile b/packages/platforms/inventec/x86-64/d7264q28b/modules/builds/src/Makefile deleted file mode 100644 index 69fc0209a..000000000 --- a/packages/platforms/inventec/x86-64/d7264q28b/modules/builds/src/Makefile +++ /dev/null @@ -1,7 +0,0 @@ -obj-m += inv_cpld.o inv_psoc.o -obj-m += inv_platform.o -obj-m += swps.o -swps-objs := inv_swps.o io_expander.o inv_mux.o transceiver.o -obj-m += vpd.o -vpd-objs := inv_vpd.o onie_tlvinfo.o -obj-m += inv_pthread.o diff --git a/packages/platforms/inventec/x86-64/d7264q28b/modules/builds/src/gpio-ich.c b/packages/platforms/inventec/x86-64/d7264q28b/modules/builds/src/gpio-ich.c deleted file mode 100644 index 70304220a..000000000 --- a/packages/platforms/inventec/x86-64/d7264q28b/modules/builds/src/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/d7264q28b/modules/builds/src/inv_cpld.c b/packages/platforms/inventec/x86-64/d7264q28b/modules/builds/src/inv_cpld.c deleted file mode 100644 index 4c97b7f13..000000000 --- a/packages/platforms/inventec/x86-64/d7264q28b/modules/builds/src/inv_cpld.c +++ /dev/null @@ -1,595 +0,0 @@ -/* - * 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 "inv_pthread.h" - -//#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 -#define CPLD_BIOSCS_OFFSET 0x04 - - -/* Each client has this additional data */ -struct cpld_data { - struct device *hwmon_dev; - struct mutex update_lock; -}; - -static struct device *cpld_led_client_dev = NULL; - -/*-----------------------------------------------------------------------*/ - -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 ssize_t show_bios_cs(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_BIOSCS_OFFSET, 1); - - mutex_unlock(&data->update_lock); - - if(status != 1) return sprintf(buf, "read cpld BIOS_CS fail\n"); - - - status = sprintf (buf, "0x%X\n", b[0] & 0x01); - - return strlen(buf); -} - -static ssize_t set_bios_cs(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_BIOSCS_OFFSET, 1); - if(temp) byte |= 0x01; - else byte &= ~(0x01); - cpld_i2c_write(client, &byte, CPLD_BIOSCS_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 - "4 Hz", //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 == CPLD_DEV_LED_GRN_INDEX)?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; - - 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; -} - -ssize_t cpld_show_led(char *buf, int index) -{ - u32 status; - struct i2c_client *client = NULL; - struct cpld_data *data = NULL; - u8 byte; - int shift = (index == CPLD_DEV_LED_GRN_INDEX)?3:0; - - if (!cpld_led_client_dev) { - return 0; - } - - client = to_i2c_client(cpld_led_client_dev); - data = i2c_get_clientdata(client); - - 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); -} -EXPORT_SYMBOL(cpld_show_led); - -ssize_t cpld_set_led(const char *buf, size_t count, int index) -{ - struct i2c_client *client = NULL; - struct cpld_data *data = NULL; - - u8 temp = simple_strtol(buf, NULL, 16); - u8 byte; - int shift = (index == CPLD_DEV_LED_GRN_INDEX)?3:0; - - if (!cpld_led_client_dev) { - return 0; - } - - client = to_i2c_client(cpld_led_client_dev); - data = i2c_get_clientdata(client); - - 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; -} -EXPORT_SYMBOL(cpld_set_led); - -ssize_t cpld_show_ctl(char *buf) -{ - u32 status; - struct i2c_client *client = NULL; - struct cpld_data *data = NULL; - u8 b[1]; - - if (!cpld_led_client_dev) { - return 0; - } - - client = to_i2c_client(cpld_led_client_dev); - data = i2c_get_clientdata(client); - - 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); -} -EXPORT_SYMBOL(cpld_show_ctl); - -ssize_t cpld_set_ctl(const char *buf, size_t count) -{ - struct i2c_client *client = NULL; - struct cpld_data *data = NULL; - u8 byte; - u8 temp = simple_strtol(buf, NULL, 10); - - if (!cpld_led_client_dev) { - return 0; - } - - client = to_i2c_client(cpld_led_client_dev); - data = i2c_get_clientdata(client); - - 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; -} -EXPORT_SYMBOL(cpld_set_ctl); - -/* -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, CPLD_DEV_LED_GRN_INDEX); -static SENSOR_DEVICE_ATTR(red_led, S_IWUSR|S_IRUGO, show_led, set_led, CPLD_DEV_LED_RED_INDEX); - -static SENSOR_DEVICE_ATTR(psu0, S_IRUGO, show_psu, 0, 0); -static SENSOR_DEVICE_ATTR(psu1, S_IRUGO, show_psu, 0, 1); - -static SENSOR_DEVICE_ATTR(bios_cs, S_IWUSR|S_IRUGO, show_bios_cs, set_bios_cs, 0); - -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, - - &sensor_dev_attr_bios_cs.dev_attr.attr, - NULL -}; - -static const struct attribute_group cpld_group = { - .attrs = cpld_attributes, -}; - -static struct attribute *cpld2_attributes[] = { - //info - &sensor_dev_attr_info.dev_attr.attr, - - NULL -}; - -static const struct attribute_group cpld2_group = { - .attrs = cpld2_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 */ - if(id->driver_data==1) // CPLD2 - status = sysfs_create_group(&client->dev.kobj, &cpld2_group); - else // default CPLD1 - 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, }, - { "inv_cpld2", 1, }, - { /* 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/d7264q28b/modules/builds/src/inv_mux.c b/packages/platforms/inventec/x86-64/d7264q28b/modules/builds/src/inv_mux.c deleted file mode 100644 index e7ca52595..000000000 --- a/packages/platforms/inventec/x86-64/d7264q28b/modules/builds/src/inv_mux.c +++ /dev/null @@ -1,272 +0,0 @@ -#include -#include -#include -#include -#include -#include "io_expander.h" -#include "inv_mux.h" - -static struct mux_obj_s *mux_head_p = NULL; - - -/* ========== MUX object functions ========== - */ -int -_common_force_pull_gpio(int mem_addr, - int input, - int bit_offset){ - - unsigned int val = 0; - unsigned int targ = 0; - - /* Get current value */ - val = inl(mem_addr); - if (val == 0) { - SWPS_ERR("%s: inl:%d fail!\n", __func__, val); - return -1; - } - /* Count target value */ - switch (input) { - case 0: /* Pull Low */ - targ = (val & (~(1 << bit_offset))); - break; - case 1: /* Pull high */ - targ = (val | (1 << bit_offset)); - break; - default: - SWPS_ERR("%s: input state:%d incorrect!\n", - __func__, input); - return -1; - } - /* Setup gpio */ - outl(targ, mem_addr); - if (targ != inl(mem_addr)){ - SWPS_ERR("%s: outl:%d fail!\n", __func__, targ); - return -1; - } - SWPS_DEBUG("%s: done.\n", __func__); - return 0; -} - - -int -rangeley_force_pull_high(struct mux_obj_s *self){ - SWPS_ERR("%s: not ready!\n", __func__); - return -1; -} - - -int -rangeley_force_pull_low(struct mux_obj_s *self){ - SWPS_ERR("%s: not ready!\n", __func__); - return -1; -} - - -int -hedera_force_pull_high(struct mux_obj_s *self){ - return _common_force_pull_gpio(MUX_RST_MEM_ADDR_HEDERA, 1, 5); -} - - -int -hedera_force_pull_low(struct mux_obj_s *self){ - return _common_force_pull_gpio(MUX_RST_MEM_ADDR_HEDERA, 0, 5); -} - - -int -normal_gpio_pull_high(struct mux_obj_s *self){ - return gpio_direction_output(self->gpio_num, 1); -} - - -int -normal_gpio_pull_low(struct mux_obj_s *self){ - return gpio_direction_output(self->gpio_num, 0); -} - - -int -pca9548_reset_mux_all(struct mux_obj_s *self){ - /* [Note] Power-on reset (PCA9548A-NXP) - * When power is applied to VDD, an internal Power-On Reset (POR) - * holds the PCA9548A in a reset condition until VDD has reached - * VPOR. At this point, the reset condition is released and the - * PCA9548A register and I2C-bus state machine are initialized to - * their default states (all zeroes) causing all the channels to - * be deselected. Thereafter, VDD must be lowered below 0.2 V for - * at least 5 us in order to reset the device. - */ - if (self->_pull_low(self) < 0) { - SWPS_ERR("%s: _pull_low fail!\n", __func__); - return -1; - } - mdelay(MUX_RST_WAIT_MS); - if (self->_pull_high(self) < 0) { - SWPS_ERR("%s: _pull_high fail!\n", __func__); - return -1; - } - mdelay(MUX_RST_WAIT_MS); - return 0; -} - - -int -common_reset_mux_all(struct mux_obj_s *self){ - SWPS_ERR("%s: not ready!\n", __func__); - return -1; -} - - -int -init_gpio_4_force(struct mux_obj_s *self){ - return 0; -} - - -int -init_gpio_4_normal(struct mux_obj_s *self){ - - int err = 0; - - if (!gpio_is_valid(self->gpio_num)) { - SWPS_ERR("%s: GIPO:%d isn't valid\n", __func__, self->gpio_num); - return -1; - } - err = gpio_request(self->gpio_num, MUX_GPIO_LABEL); - if (err < 0) { - SWPS_ERR("%s: gpio_request fail :%d :%d\n", - __func__, err, self->gpio_num); - return -1; - } - SWPS_DEBUG("%s: gpio_request:%d ok.\n", __func__, self->gpio_num); - return 0; -} - - -static int -_setup_muxctl_cb(struct mux_obj_s *self, - unsigned gpio){ - - char mod_dsc[32] = "ERR"; - - switch (gpio) { - case MUX_RST_GPIO_FORCE_RANGELEY: - self->gpio_num = gpio; - self->_pull_low = rangeley_force_pull_low; - self->_pull_high = rangeley_force_pull_high; - self->_init = init_gpio_4_force; - self->reset = pca9548_reset_mux_all; - memset(mod_dsc, 0, 32); - snprintf(mod_dsc, 31, "Rangeley force mode"); - goto ok_setup_muxctl_cb; - - case MUX_RST_GPIO_FORCE_HEDERA: - self->gpio_num = gpio; - self->_pull_low = hedera_force_pull_low; - self->_pull_high = hedera_force_pull_high; - self->_init = init_gpio_4_force; - self->reset = pca9548_reset_mux_all; - memset(mod_dsc, 0, 32); - snprintf(mod_dsc, 31, "Hedera force mode"); - goto ok_setup_muxctl_cb; - - case MUX_RST_GPIO_48_PAC9548: - case MUX_RST_GPIO_69_PAC9548: - case MUX_RST_GPIO_249_PCA9548: - self->gpio_num = gpio; - self->_pull_low = normal_gpio_pull_low; - self->_pull_high = normal_gpio_pull_high; - self->_init = init_gpio_4_normal; - self->reset = pca9548_reset_mux_all; - memset(mod_dsc, 0, 32); - snprintf(mod_dsc, 31, "Normal mode :%d", (int)gpio); - goto ok_setup_muxctl_cb; - - default: - break; - } - SWPS_ERR("%s: Unexpected GPIO:%d\n", __func__, gpio); - return -1; - -ok_setup_muxctl_cb: - SWPS_INFO("muxctl: %s.\n", mod_dsc); - return 0; -} - - -/* ========== MUX public functions ========== - */ -void -clean_mux_gpio(void){ - - if (!mux_head_p) { - SWPS_DEBUG("%s: mux_head_p is NULL\n", __func__); - return; - } - if (gpio_is_valid(mux_head_p->gpio_num)) { - gpio_free(mux_head_p->gpio_num); - } - kfree(mux_head_p); - mux_head_p = NULL; - SWPS_DEBUG("%s: done.\n", __func__); -} - - -int -reset_mux_gpio(void){ - - if (!mux_head_p) { - SWPS_ERR("%s: MUX ctl object doesn't exist!\n", __func__); - return -1; - } - if (mux_head_p->reset(mux_head_p) < 0){ - SWPS_ERR("%s: reset fail!\n", __func__); - return -1; - } - return 0; -} - - -int -init_mux_gpio(unsigned gpio){ - - /* Create MUX control object */ - if (mux_head_p) { - SWPS_DEBUG("%s: mux_head_p is not NULL!\n", __func__); - clean_mux_gpio(); - } - /* Currently, it is using single muxctl architecture. - * In the future, it may use the multi-muxctl if HW add new features. - * (Ex: Port power-status control) - */ - mux_head_p = kzalloc(sizeof(struct mux_obj_s), GFP_KERNEL); - if (!mux_head_p) { - SWPS_ERR("%s: kzalloc fail!\n", __func__); - return -1; - } - /* Initial MUX controller */ - if (_setup_muxctl_cb(mux_head_p, gpio) < 0){ - SWPS_ERR("%s: _setup_muxctl_cb fail!\n", __func__); - return -1; - } - if (mux_head_p->_init(mux_head_p) < 0) { - SWPS_ERR("%s: init() fail\n", __func__); - goto err_init_mux_gpio; - } - /* Setup default value */ - if (mux_head_p->_pull_high(mux_head_p) < 0) { - SWPS_ERR("%s: setup default fail!\n", __func__); - goto err_init_mux_gpio; - } - return 0; - -err_init_mux_gpio: - clean_mux_gpio(); - return -1; -} - - - - diff --git a/packages/platforms/inventec/x86-64/d7264q28b/modules/builds/src/inv_mux.h b/packages/platforms/inventec/x86-64/d7264q28b/modules/builds/src/inv_mux.h deleted file mode 100644 index a21a5e23e..000000000 --- a/packages/platforms/inventec/x86-64/d7264q28b/modules/builds/src/inv_mux.h +++ /dev/null @@ -1,37 +0,0 @@ -#ifndef INV_MUX_H -#define INV_MUX_H - - -/* MUX basic information */ -#define MUX_GPIO_LABEL "SWPS_RST_MUX" - -/* MUX reset GPIO define */ -#define MUX_RST_GPIO_FORCE (30100) -#define MUX_RST_GPIO_FORCE_RANGELEY (30101) -#define MUX_RST_GPIO_FORCE_HEDERA (30102) -#define MUX_RST_GPIO_48_PAC9548 (48) -#define MUX_RST_GPIO_69_PAC9548 (69) -#define MUX_RST_GPIO_249_PCA9548 (249) - -/* MUX relate value define */ -#define MUX_RST_WAIT_MS (1) -#define MUX_RST_MEM_ADDR_RANGELEY (0) // TBD -#define MUX_RST_MEM_ADDR_HEDERA (0x548) - -struct mux_obj_s { - unsigned gpio_num; - int (*_pull_high)(struct mux_obj_s *self); - int (*_pull_low)(struct mux_obj_s *self); - int (*_init)(struct mux_obj_s *self); - int (*reset)(struct mux_obj_s *self); -}; - - -void clean_mux_gpio(void); -int reset_mux_gpio(void); -int init_mux_gpio(unsigned gpio); - - -#endif /* INV_MUX_H */ - - diff --git a/packages/platforms/inventec/x86-64/d7264q28b/modules/builds/src/inv_platform.c b/packages/platforms/inventec/x86-64/d7264q28b/modules/builds/src/inv_platform.c deleted file mode 100644 index 720a4cd22..000000000 --- a/packages/platforms/inventec/x86-64/d7264q28b/modules/builds/src/inv_platform.c +++ /dev/null @@ -1,239 +0,0 @@ -#include -//#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),}, -}; - -static struct pca954x_platform_mode mux_modes_0_7[] = { - {.adap_id = bus_id(66),}, {.adap_id = bus_id(67),}, - {.adap_id = bus_id(68),}, {.adap_id = bus_id(69),}, - {.adap_id = bus_id(70),}, {.adap_id = bus_id(71),}, - {.adap_id = bus_id(72),}, {.adap_id = bus_id(73),}, -}; - -//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 pca954x_platform_data mux_data_0_7 = { - .modes = mux_modes_0_7, - .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 - {"inv_cpld2", 0, 0x77, 0, 0, 0},//cpld2 - {"pca9548", 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 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 i2c_board_info i2c_device_info9[] __initdata = { - {"pca9548", 0, 0x72, &mux_data_0_7, 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 - {bus_id(9), ARRAY_SIZE(i2c_device_info9), i2c_device_info9 }, //mux 7 - -}; - -///////////////////////////////////////////////////////////////////////////////////////// -#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 = 1, // 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,k; - - 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 gpio69=32*2+8*0+5 - outl( inl(0x533) | (1<<2), 0x533); - outl( inl(0x541) | (1<<3), 0x541); - outl( inl(0x540) | (1<<5), 0x540); //RST_I2C_MUX_N (GPIO69) - outl( inl(0x500) | (1<<7), 0x500); //SYS_RDY_N (GPIO7) - outl( inl(0x501) | (1<<7), 0x501); //BMC_HEART_BEAT (GPIO15) - outl( inl(0x503) | (1<<2)|(1<<3), 0x503); //PSOC_HEART_BEAT(26),CPLD_HEART_BEAT(27) - - 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 -#include -#include -#include - -#define IPMI_MAX_INTF (4) -#define NETFN_OEM 0x30 -#define CMD_GETDATA 0x31 -#define CMD_SETDATA 0x32 -#define FAN_NUM 4 -#define PSU_NUM 2 - -#define PSU1 0x5800 -#define PSU2 0x5900 -#define BMC_PMBusNumber 3 -#define PMBus_Vender 0x99 -#define PMBus_Serial 0x9E -#define PMBus_Temp2 0x8E -#define PMBus_Version 0x9B -#define MaxLeng_Result 0x20 - -#define MAX_IPMI_RECV_LENGTH 0xff - -static long pmbus_reg2data_linear(int data, int linear16); -struct ipmi_result{ - char result[MAX_IPMI_RECV_LENGTH]; - int result_length; -}; - -DEFINE_MUTEX(ipmi_mutex); -DEFINE_MUTEX(ipmi2_mutex); -static struct ipmi_result ipmiresult; -static struct device *hwmon_dev; -static ipmi_user_t ipmi_mh_user = NULL; -static void msg_handler(struct ipmi_recv_msg *msg,void* handler_data); -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 -}; - -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) - - -static void msg_handler(struct ipmi_recv_msg *recv_msg,void* handler_data) -{ - struct ipmi_result *msg_result = recv_msg->user_msg_data; - - if(recv_msg->msg.data[0]==0 && recv_msg->msg.data_len>0) { - msg_result->result_length=recv_msg->msg.data_len-1; - memcpy(msg_result->result, &recv_msg->msg.data[1], recv_msg->msg.data_len-1); - } - ipmi_free_recv_msg(recv_msg); - mutex_unlock(&ipmi_mutex); - - return; -} - -int start_ipmi_command(char NetFn, char cmd,char *data,int data_length, char* result, int* result_length) -{ - int rv=0,i; - int timeout; - - //wait previous command finish at least 50msec - timeout=50; - while((mutex_is_locked(&ipmi_mutex) == 1 || (mutex_is_locked(&ipmi2_mutex) == 1)) && (--timeout)>0) { usleep_range(1000,1010); } - if(timeout==0) { return -1; } - mutex_lock(&ipmi_mutex); - mutex_lock(&ipmi2_mutex); - - if(ipmi_mh_user == NULL) { - for (i=0,rv=1; i0) { usleep_range(1000,1100);} - if(timeout==0) { - mutex_unlock(&ipmi2_mutex); - return -1; - } - else { - *result_length=ipmiresult.result_length; - memcpy(result,ipmiresult.result,*result_length); - mutex_unlock(&ipmi2_mutex); - return 0; - } - } - return 0; -} -EXPORT_SYMBOL(start_ipmi_command); - -static ssize_t psoc_ipmi_read(u8 *buf, u8 offset, size_t count) -{ - uint8_t data[2]; - int result_len=0; - int rv; - - data[0] = offset; - data[1] = count; - - rv=start_ipmi_command(NETFN_OEM, CMD_GETDATA,data,2, buf, &result_len); - - return result_len; -} - -static ssize_t psoc_ipmi_write(char *buf, unsigned offset, size_t count) -{ - uint8_t data[count+1],result[1]; - int result_len; - - data[0] = offset; - memcpy(&data[1],buf,count); - - start_ipmi_command(NETFN_OEM, CMD_SETDATA,data,count+1, result, &result_len); - return count; -} - - -static u16 psoc_read16(u8 offset) -{ - u16 value = 0; - u8 buf[]={0,0}; - - if(psoc_ipmi_read(buf, offset, 2) == 2) - value = (buf[0]<<8 | buf[1]<<0); - - return value; -} - -static u8 psoc_read8(u8 offset) -{ - u8 value = 0; - u8 buf = 0; - - if(psoc_ipmi_read(&buf, offset, 1) == 1) - value = buf; - - return value; -} - -/* -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=0; - struct sensor_device_attribute *attr = to_sensor_dev_attr(da); - u8 byte=0; - int shift = (attr->index == 0)?3:0; - - status = psoc_ipmi_read(&byte, PSOC_PSU_OFFSET, 1); - - byte = (byte >> shift) & 0x7; - - status = sprintf (buf, "%d : %s\n", byte, psu_str[byte]); - - return strlen(buf); -} - -static ssize_t psoc_show_psu_st(char *buf, int psu_index) -{ - u32 status=0; - u8 byte=0; - int shift = (psu_index == 0)?3:0; - - status = psoc_ipmi_read(&byte, PSOC_PSU_OFFSET, 1); - - byte = (byte >> shift) & 0x7; - - status = sprintf (buf, "%d : %s\n", byte, psu_str[byte]); - - return strlen(buf); -} - -ssize_t psoc_show_psu_state(char *buf, int index) -{ - return psoc_show_psu_st(buf, index); -} -EXPORT_SYMBOL(psoc_show_psu_state); - -static ssize_t show_ipmi_pmbus(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=0; - - data[0] = BMC_PMBusNumber; - 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(start_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_thermal(struct device *dev, struct device_attribute *da, - char *buf) -{ - int status=0; - struct sensor_device_attribute *attr = to_sensor_dev_attr(da); - u8 offset = attr->index * 2 + THERMAL_OFFSET; - - status = psoc_read16(offset); - - 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=0; - struct sensor_device_attribute *attr = to_sensor_dev_attr(da); - u8 offset = attr->index + PWM_OFFSET; - - status = psoc_read8(offset); - - return sprintf(buf, "%d\n", - status); -} - -static ssize_t set_pwm(struct device *dev, - struct device_attribute *da, - const char *buf, size_t count) -{ - struct sensor_device_attribute *attr = to_sensor_dev_attr(da); - u8 offset = attr->index + PWM_OFFSET; - - u8 pwm = simple_strtol(buf, NULL, 10); - if(pwm > 255) pwm = 255; - - psoc_ipmi_write(&pwm, offset, 1); - - return count; -} - - -static ssize_t show_rpm(struct device *dev, struct device_attribute *da, - char *buf) -{ - int status=0; - struct sensor_device_attribute *attr = to_sensor_dev_attr(da); - u8 offset = attr->index*2 + RPM_OFFSET; - - status = psoc_read16(offset); - - return sprintf(buf, "%d\n", status); -} - -static ssize_t psoc_show_rpm(char *buf, int fan_index) -{ - int status=0; - u8 offset = fan_index*2 + RPM_OFFSET; - - status = psoc_read16(offset); - - return sprintf(buf, "%d\n", status); -} - -ssize_t psoc_show_fan_input(char *buf, int index) -{ - return psoc_show_rpm(buf, index); -} -EXPORT_SYMBOL(psoc_show_fan_input); - -static ssize_t show_switch_tmp(struct device *dev, struct device_attribute *da, - char *buf) -{ - u16 status=0; - u16 temp = 0; - - status = psoc_ipmi_read((u8*)&temp, SWITCH_TMP_OFFSET, 2); - - status = sprintf (buf, "%d\n", (s32)(temp) ); - - return strlen(buf); -} - -static ssize_t set_switch_tmp(struct device *dev, - struct device_attribute *devattr, - const char *buf, size_t count) -{ - long temp = simple_strtol(buf, NULL, 10); - - u16 temp2 = (u16)temp; - - psoc_ipmi_write((u8*)&temp2, SWITCH_TMP_OFFSET, 2); - - return count; -} - -static ssize_t show_diag(struct device *dev, struct device_attribute *da, - char *buf) -{ - u16 status=0; - u8 diag_flag = 0; - - status = psoc_ipmi_read((u8*)&diag_flag, DIAG_FLAG_OFFSET, 1); - - status = sprintf (buf, "%d\n", ((diag_flag & 0x80)?1:0)); - - return strlen(buf); -} - -static ssize_t set_diag(struct device *dev, - struct device_attribute *devattr, - const char *buf, size_t count) -{ - u8 value = 0; - u8 diag = simple_strtol(buf, NULL, 10); - - diag = diag?1:0; - - psoc_ipmi_read((u8*)&value, DIAG_FLAG_OFFSET, 1); - if(diag) value |= (1<<7); - else value &= ~(1<<7); - psoc_ipmi_write((u8*)&value, DIAG_FLAG_OFFSET, 1); - - return count; -} - -static ssize_t psoc_show_diag(char *buf) -{ - u16 status=0; - u8 diag_flag = 0; - - status = psoc_ipmi_read((u8*)&diag_flag, DIAG_FLAG_OFFSET, 1); - - status = sprintf (buf, "%d\n", ((diag_flag & 0x80)?1:0)); - - return strlen(buf); -} -EXPORT_SYMBOL(psoc_show_diag); - -static ssize_t psoc_set_diag(const char *buf, size_t count) -{ - u8 value = 0; - u8 diag = simple_strtol(buf, NULL, 10); - - diag = diag?1:0; - - psoc_ipmi_read((u8*)&value, DIAG_FLAG_OFFSET, 1); - if(diag) value |= (1<<7); - else value &= ~(1<<7); - psoc_ipmi_write((u8*)&value, DIAG_FLAG_OFFSET, 1); - - return count; -} -EXPORT_SYMBOL(psoc_set_diag); - -static ssize_t show_version(struct device *dev, struct device_attribute *da, - char *buf) -{ - u16 status=0; - - status = psoc_read16(VERSION_OFFSET); - - return sprintf(buf, "ver: %x.%x\n", (status & 0xFF00)>>8, (status & 0xFF) ); -} - -static ssize_t show_name(struct device *dev, struct device_attribute *da, - char *buf) -{ - return sprintf (buf, "inv_psoc\n"); -} - - -static ssize_t show_fan_led(struct device *dev, struct device_attribute *da, - char *buf) -{ - int status=0; - struct sensor_device_attribute *attr = to_sensor_dev_attr(da); - u8 bit = attr->index; - - status = psoc_read8(FAN_LED_OFFSET); - - return sprintf(buf, "%d\n", - (status & (1<index; - u8 led_state = 0; - - u8 v = simple_strtol(buf, NULL, 10); - - led_state = psoc_read8(FAN_LED_OFFSET); - if(v) led_state |= (1<index; - - status = psoc_read8(offset); - - return sprintf(buf, "0x%02X\n", status); -} - -static ssize_t psoc_show_value8(char *buf, int offset) -{ - int status=0; - - status = psoc_read8(offset); - - return sprintf(buf, "0x%02X\n", status ); -} - -static char prev_fan_state[8] = { 0 }; - -ssize_t psoc_show_fan_state(char *buf) -{ - int i; - int rv = psoc_show_value8(buf, FAN_GPI_OFFSET); - for (i = 0; i < 3; i++) { - if (strncmp(prev_fan_state, buf, 4) == 0) { - return rv; - } - msleep(500); - rv = psoc_show_value8(buf, FAN_GPI_OFFSET); - } - strcpy(prev_fan_state, buf); - return rv; -} -EXPORT_SYMBOL(psoc_show_fan_state); - -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=0; - struct sensor_device_attribute *attr = to_sensor_dev_attr(da); - u8 offset = attr->index + PSU_INFO_OFFSET; - - status = psoc_read16(offset); - - return sprintf(buf, "%ld \n", pmbus_reg2data_linear(status, strstr(attr->dev_attr.attr.name, "vout")? 1:0 )); -} - -static ssize_t psoc_show_psu_psoc(char *buf, int psu_index, char *attr_name) -{ - u16 status=0; - u8 offset = psu_index + PSU_INFO_OFFSET; - - status = psoc_read16(offset); - - return sprintf(buf, "%ld \n", pmbus_reg2data_linear(status, strstr(attr_name, "vout")? 1:0 )); -} - -ssize_t psoc_show_psu_vin(char *buf, int index) -{ - return psoc_show_psu_psoc(buf, index, "vin"); -} -EXPORT_SYMBOL(psoc_show_psu_vin); - -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(name, S_IRUGO, show_name, NULL, 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_pmbus, 0, PSU1 | PMBus_Temp2); -static SENSOR_DEVICE_ATTR(psoc_psu1_vender, S_IRUGO, show_ipmi_pmbus, 0, PSU1 | PMBus_Vender); -static SENSOR_DEVICE_ATTR(psoc_psu1_serial, S_IRUGO, show_ipmi_pmbus, 0, PSU1 | PMBus_Serial); -static SENSOR_DEVICE_ATTR(psoc_psu1_version, S_IRUGO, show_ipmi_pmbus, 0, PSU1 | PMBus_Version); - -static SENSOR_DEVICE_ATTR(thermal2_psu2, S_IRUGO, show_ipmi_pmbus, 0, PSU2 | PMBus_Temp2); -static SENSOR_DEVICE_ATTR(psoc_psu2_vender, S_IRUGO, show_ipmi_pmbus, 0, PSU2 | PMBus_Vender); -static SENSOR_DEVICE_ATTR(psoc_psu2_serial, S_IRUGO, show_ipmi_pmbus, 0, PSU2 | PMBus_Serial); -static SENSOR_DEVICE_ATTR(psoc_psu2_version, S_IRUGO, show_ipmi_pmbus, 0, PSU2 | PMBus_Version); - - -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 - &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_i2c_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_name.dev_attr.attr, - - NULL -}; - -static const struct attribute_group psoc_group = { - .attrs = psoc_attributes, -}; - -static int __init inv_psoc_init(void) -{ - int ret; - - printk("+%s\n", __func__); - - hwmon_dev = hwmon_device_register(NULL); - if (IS_ERR(hwmon_dev)) { - goto fail_hwmon_device_register; - } - - ret = sysfs_create_group(&hwmon_dev->kobj, &psoc_group); - if (ret) { - goto fail_create_group_hwmon; - } - - printk(" Enable IPMI PSoC protocol.\n"); - - return ret; - -fail_create_group_hwmon: - hwmon_device_unregister(hwmon_dev); -fail_hwmon_device_register: - return -ENOMEM; -} - -static void __exit inv_psoc_exit(void) -{ - if(ipmi_mh_user!=NULL) {ipmi_destroy_user(ipmi_mh_user);} - if(hwmon_dev != NULL) hwmon_device_unregister(hwmon_dev); - sysfs_remove_group(&hwmon_dev->kobj, &psoc_group); -} - -MODULE_AUTHOR("Ting.Jack "); -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/d7264q28b/modules/builds/src/inv_pthread.c b/packages/platforms/inventec/x86-64/d7264q28b/modules/builds/src/inv_pthread.c deleted file mode 100644 index db64f9d6f..000000000 --- a/packages/platforms/inventec/x86-64/d7264q28b/modules/builds/src/inv_pthread.c +++ /dev/null @@ -1,884 +0,0 @@ -/***************************** - Sequoia(d7264q28b) platform -******************************/ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "inv_pthread.h" - -#define INV_PTHREAD_KERNEL_MODULE - -#define SHOW_ATTR_WARNING ("N/A") -#define SHOW_ATTR_NOTPRINT ("Not Available") -#define SHOW_ATTR_NOTSUPPORT ("Not Support") - -#define INV_HWMID_MAX (10) -#define INV_HWMID_INIT (-1) - -/*access userspace data to kernel space*/ -#define ACC_R (0) -#define ACC_W (1) - -#define MAX_PATH_SIZE (64) -#define MIN_ACC_SIZE (32) -#define MAX_ACC_SIZE (256) - -/* - * LED definitions - */ -#define STATUS_LED_MODE_AUTO (0) -#define STATUS_LED_MODE_DIAG (1) -#define STATUS_LED_MODE_MANU (2) -#define STATUS_LED_MODE_ERR (-1) - -#define STATUS_LED_GRN0 (10) // 0 - 000: off -#define STATUS_LED_GRN1 (11) // 1 - 001: 0.5hz -#define STATUS_LED_GRN2 (12) // 2 - 010: 1 hz -#define STATUS_LED_GRN3 (13) // 3 - 011: 2 hz -#define STATUS_LED_GRN7 (17) // 7 - 111: on -#define STATUS_LED_RED0 (20) // 0 - 000: off -#define STATUS_LED_RED1 (21) // 1 - 001: 0.5hz -#define STATUS_LED_RED2 (22) // 2 - 010: 1 hz -#define STATUS_LED_RED3 (23) // 3 - 011: 2 hz -#define STATUS_LED_RED7 (27) // 7 - 111: on -#define STATUS_LED_INVALID (0) // Invalid - -static struct mutex pthread_mutex; - -ssize_t status_led_grn(const char *freq); -ssize_t status_led_red(const char *freq); -ssize_t status_led_diag_mode_enable(void); -ssize_t status_led_diag_mode_disable(void); -int status_led_check_color(void); -int status_led_check_diag_mode(void); - -#if 1 -/* For timestamps in SYSFS_LOG */ -#define SYSFS_LOG printk -#else -//#define SYSFS_LOG(fmt, args...) printk(KERN_WARNING "[SYSFS] %s/%d: " fmt, __func__, __LINE__, ##args) -#define SYSFS_LOG(fmt, args...) printk(KERN_WARNING "[p_thread] " fmt, ##args) -#endif - - -/* inventec_class *********************************/ -static struct kobject *status_kobj; -static struct kset *status_kset; - -#if 0 -int inventec_strtol(const char *sbufp, char **endp, unsigned int base) -{ - char *endptr; - int value = simple_strtol(sbufp, &endptr, base); - if (value == 0 && sbufp == endptr) { - *endp = NULL; - return value; - } - *endp = (char*)1; - return value; -} -#endif - -int inventec_singlechar_to_int(const char c) -{ - if ((c >= '0') && (c <= '9')) { - return (c - '0'); - } - else - if ((c >= 'a') && (c <= 'f')) { - return (c - 'a' + 10); - } - else - if ((c >= 'A') && (c <= 'F')) { - return (c - 'A' + 10); - } - return -1; -} - -/* fan device *************************************/ -#define FAN_STATE_NORMAL "normal" -#define FAN_STATE_FAULTY "faulty" -#define FAN_STATE_UNINSTALLED "uninstalled" -#define FAN_STATE_UNKNOW "unknown state" -#define FAN_STATE_INVALID "Invalid state value" -#define FAN_STATE_READ_ERROR "state read error" - -#define FAN_LOG_UNINSTALLED "removed" -#define FAN_LOG_NORMAL "inserted" - -//#define FAN_STATE_BIT_NORMAL 0 -#define FAN_STATE_BIT_FAULTY 0 -#define FAN_STATE_BIT_UNINSTALLED 1 -#define FAN_STATE_BIT_UNKNOW 2 -#define FAN_STATE_BIT_INVALID 3 -#define FAN_STATE_BIT_READ_ERROR 4 - -static ssize_t psoc_show_fan1_input(char *buf) -{ - return psoc_show_fan_input(buf, 1); -} - -static ssize_t psoc_show_fan2_input(char *buf) -{ - return psoc_show_fan_input(buf, 2); -} - -static ssize_t psoc_show_fan3_input(char *buf) -{ - return psoc_show_fan_input(buf, 3); -} - -static ssize_t psoc_show_fan4_input(char *buf) -{ - return psoc_show_fan_input(buf, 4); -} - -static ssize_t psoc_show_fan5_input(char *buf) -{ - return psoc_show_fan_input(buf, 5); -} - -static ssize_t psoc_show_fan6_input(char *buf) -{ - return psoc_show_fan_input(buf, 6); -} - -static ssize_t psoc_show_fan7_input(char *buf) -{ - return psoc_show_fan_input(buf, 7); -} - -static ssize_t psoc_show_fan8_input(char *buf) -{ - return psoc_show_fan_input(buf, 8); -} - -static struct fans_tbl_s { - char *fan_name; - ssize_t (*fan_front)(char *); - ssize_t (*fan_rear)(char *); - unsigned int fan_state; -} fans_tbl[] = { - {"fan1", psoc_show_fan1_input, - psoc_show_fan2_input, 0}, - {"fan2", psoc_show_fan3_input, - psoc_show_fan4_input, 0}, - {"fan3", psoc_show_fan5_input, - psoc_show_fan6_input, 0}, - {"fan4", psoc_show_fan7_input, - psoc_show_fan8_input, 0}, -}; -#define FAN_TBL_TOTAL ( sizeof(fans_tbl)/ sizeof(const struct fans_tbl_s) ) - -#define FAN_STATE_CHECK(i,b) (fans_tbl[i].fan_state & (1<inv_dev_attrp, PSU_ATTR_VOLTIN, PSU_ATTR_VOLTIN_LEN) == 0) { - invwirep = psu_get_show_function(PSU_ATTR_VOLTIN, psu_dev_group[i].psu_name, NULL); - if (invwirep == NULL) { - printk(KERN_DEBUG "[p_thread] Invalid psuname: %s\n", psu_dev_group[i].psu_name); - continue; - } - if (invwirep(volt) <= 0) { - printk(KERN_DEBUG "[p_thread] Read %s failed\n", psu_dev_group[i].psu_name); - continue; - } - else { - voltin = simple_strtol(&volt[0], NULL, 10); - printk(KERN_DEBUG "[p_thread] Read %s %s = %u\n",psu_dev_group[i].psu_name,volt,voltin); - if (voltin > psu_voltin) { - psu_voltin = voltin; - } - } - } - } - } - - SYSFS_LOG("[p_thread] PSU voltin = %u\n", psu_voltin); -} - -#define PSU_ATTR_STATE ("state") -#define PSU_ATTR_STATE_LEN (5) - -/* psus_control() by inv_thread */ -int psus_control(int log_only) -{ - char state[MIN_ACC_SIZE]; - psu_dev_t *devnamep = NULL; - ssize_t (*invwirep)(char *buf) = NULL; - char *psu_statep = NULL; - int i, j, flag = 0; - - for (i = 0; i < PSU_DEV_GROUP_TOTAL; i++) { - devnamep = psu_dev_group[i].psu_dev_namep; - for (j = 0; j < psu_dev_group[i].psu_dev_total; j++, devnamep++) { - if (strncmp(devnamep->inv_dev_attrp, PSU_ATTR_STATE, PSU_ATTR_STATE_LEN) == 0) { - invwirep = psu_get_show_function(PSU_ATTR_STATE, psu_dev_group[i].psu_name, &psu_statep); - if (invwirep == NULL) { - printk(KERN_DEBUG "[p_thread] Invalid psuname: %s\n", psu_dev_group[i].psu_name); - continue; - } - if (invwirep(state) <= 0) { - printk(KERN_DEBUG "[p_thread] Read %s failed\n", psu_dev_group[i].psu_name); - if (strncmp(psu_statep, PSU_STATE_ERROR, strlen(PSU_STATE_ERROR)) != 0) { - strcpy(psu_statep, PSU_STATE_ERROR); - SYSFS_LOG("[p_thread] %s: %s\n",psu_dev_group[i].psu_name,PSU_STATE_ERROR); - } - flag = 1; - } - else - if (strstr(state, "normal")) { - if (strncmp(psu_statep, state, strlen(state)) != 0) { - strcpy(psu_statep, state); - SYSFS_LOG("[p_thread] %s: %s\n",psu_dev_group[i].psu_name,state); - } - } - else - if (psu_voltin > PSU_VOLTIN_ACDC) { /* AC PSUS */ - if (strncmp(psu_statep, state, strlen(state)) != 0) { - strcpy(psu_statep, state); - SYSFS_LOG("[p_thread] %s: %s\n",psu_dev_group[i].psu_name,state); - } - flag = 1; - } - else { /* DC PSUS */ - if (strncmp(psu_statep, PSU_STATE_CHECKPSU, PSU_STATE_LEN_CHECKPSU) != 0) { - strcpy(psu_statep, PSU_STATE_CHECKPSU); - SYSFS_LOG("[p_thread] %s: %s\n",psu_dev_group[i].psu_name,PSU_STATE_CHECKPSU); - } - flag = 1; - } - } - } - } - - if (log_only) { - return 0; - } - - //SYSFS_LOG("[p_thread] RYU: %s: flag = %d\n",psu_wire_tbl[i].psu_name,flag); - if (flag == 1) { - status_led_grn("2"); - return 1; - } - return 0; -} - -/* End of psuinfo_device */ - -/* led device *************************************/ - -/* return 0/off 1/green 2/red */ -int -status_led_check_color(void) -{ - char tmpbuf[MIN_ACC_SIZE]; - int ret = STATUS_LED_INVALID; - - if (cpld_show_led(&tmpbuf[0], CPLD_DEV_LED_GRN_INDEX) > 0) { - if (tmpbuf[0] == '0') { - ret = STATUS_LED_GRN0; - } - if (tmpbuf[0] == '1') { - ret = STATUS_LED_GRN1; - } - if (tmpbuf[0] == '2') { - ret = STATUS_LED_GRN2; - } - if (tmpbuf[0] == '3') { - ret = STATUS_LED_GRN3; - } - if (tmpbuf[0] == '7') { - ret = STATUS_LED_GRN7; - } - return ret; - } - - if (cpld_show_led(&tmpbuf[0], CPLD_DEV_LED_RED_INDEX) > 0) { - if (tmpbuf[0] == '0') { - ret = STATUS_LED_RED0; - } - if (tmpbuf[0] == '1') { - ret = STATUS_LED_RED1; - } - if (tmpbuf[0] == '2') { - ret = STATUS_LED_RED2; - } - if (tmpbuf[0] == '3') { - ret = STATUS_LED_RED3; - } - if (tmpbuf[0] == '7') { - ret = STATUS_LED_RED7; - } - return ret; - } - return ret; -} - -/* - * Store attr Section - */ -ssize_t status_led_diag_mode_enable(void) -{ - char tmp[MIN_ACC_SIZE]; - ssize_t ret; - - ret = psoc_show_diag(&tmp[0]); - if (ret <= 0) { - return ret; - } - - if (tmp[0] == '0') { - ret = psoc_set_diag("1", 1); - if (ret < 0) { - return ret; - } - - ret = cpld_set_ctl("1", 1); - if (ret < 0) { - return ret; - } - } - - return ret; -} - -ssize_t status_led_diag_mode_disable(void) -{ - char tmp[MIN_ACC_SIZE]; - ssize_t ret; - - ret = psoc_show_diag(&tmp[0]); - if (ret <= 0) { - return ret; - } - - if (tmp[0] == '1') { - ret = psoc_set_diag("0", 1); - if (ret < 0) { - return 1; - } - - ret = cpld_set_ctl("1", 1); - if (ret < 0) { - return 1; - } - } - return 1; -} - -ssize_t -status_led_red(const char *freq) -{ - char buf[MIN_ACC_SIZE]; - ssize_t ret; - - ret = cpld_show_led(buf, CPLD_DEV_LED_RED_INDEX); - if (ret < 0 || buf[0] == freq[0]) { - return ret; - } - - ret = cpld_set_led("0", 1, CPLD_DEV_LED_GRN_INDEX); - if (ret < 0) { - return ret; - } - ret = cpld_set_led(freq, strlen(freq), CPLD_DEV_LED_RED_INDEX); - if (ret < 0) { - return ret; - } - if ((ret = status_led_diag_mode_enable()) <= 0) { - return ret; - } - ssleep(1); - if ((ret = status_led_diag_mode_disable()) <= 0) { - return ret; - } - return ret; -} - -ssize_t -status_led_grn(const char *freq) -{ - char buf[MIN_ACC_SIZE]; - ssize_t ret; - - ret = cpld_show_led(buf, CPLD_DEV_LED_GRN_INDEX); - if (ret < 0 || buf[0] == freq[0]) { - return ret; - } - - ret = cpld_set_led("0", 1, CPLD_DEV_LED_RED_INDEX); - if (ret < 0) { - return ret; - } - ssleep(1); - ret = cpld_set_led(freq, strlen(freq), CPLD_DEV_LED_GRN_INDEX); - if (ret < 0) { - return ret; - } - if ((ret = status_led_diag_mode_enable()) <= 0) { - return ret; - } - ssleep(1); - if ((ret = status_led_diag_mode_disable()) <= 0) { - return ret; - } - return ret; -} - -int status_led_check_diag_mode(void) -{ - char tmp[MIN_ACC_SIZE]; - ssize_t ret; - - ret = psoc_show_diag(&tmp[0]); - if (ret <= 0) { - return ret; - } - - if (tmp[0] == '1') { - return STATUS_LED_MODE_DIAG; - } - - if (tmp[0] == '0') { - return STATUS_LED_MODE_AUTO; - } - - return -1; -} - -/* End of ledinfo_device */ - -/**************************************************/ -/* From system_device */ -static int inv_pthread_control = 1; - -int thread_control(void) -{ - return inv_pthread_control; -} - -void thread_control_set(int val) -{ - inv_pthread_control = val; -} -/* End system_device */ - -#define THREAD_SLEEP_MINS (3) -#define THREAD_DELAY_MINS (THREAD_SLEEP_MINS + THREAD_SLEEP_MINS + 1) - -static struct task_struct *thread_st; -static int thread_data; - -// Function executed by kernel thread -static int thread_fn(void *unused) -{ - mutex_init(&pthread_mutex); - - ssleep(THREAD_DELAY_MINS); - - /* Default status init */ - mutex_lock(&pthread_mutex); - status_led_grn("7"); - mutex_unlock(&pthread_mutex); - - psu_get_voltin(); - - /* Delay for guarantee HW ready */ - ssleep(THREAD_DELAY_MINS); - - while (1) - { - mutex_unlock(&pthread_mutex); - ssleep(THREAD_SLEEP_MINS); - - if (thread_control() == 0) { - printk(KERN_INFO "[p_thread] %s/%d: Thread Stop by inv_pthread control\n",__func__,__LINE__); - break; - } - - mutex_lock(&pthread_mutex); - if (status_led_check_diag_mode() == STATUS_LED_MODE_MANU) { - /* status led in change color/freq mode, higher priority. Ignore fans sttaus */ - continue; - } - -#if 0 - switch_temp_update(); -#endif - - if (fans_control() > 0) { - psus_control(1); - continue; - } - else - if (psus_control(0) > 0) { - continue; - } - - if (status_led_check_color() != STATUS_LED_GRN7) { /* status led red, change it to green */ - status_led_grn("7"); - } - } - - do_exit(0); - printk(KERN_INFO "[p_thread] %s/%d: Thread Stopped\n",__func__,__LINE__); - return 0; -} - - -static ssize_t s_show(struct kobject *kobj, struct attribute *attr, char *buf) -{ - int fan_absence; - size_t count = 0; - - fan_absence = fans_control(); - count += sprintf(&buf[count], "%d\n", fan_absence); - return count; -} - -static ssize_t s_store(struct kobject *kobj, struct attribute *attr, const char *buf, size_t count) -{ - return count; -} - -static struct attribute status_att = { - .name = "fan_absence", - .mode = 0777, -}; - -static const struct sysfs_ops status_ops = { - .show = s_show, - .store = s_store, -}; - -static struct kobj_type status_ktype = { - .sysfs_ops = &status_ops, -}; - - -static int __init inv_pthread_init(void) -{ - int retval; - - status_kobj = kzalloc(sizeof(*status_kobj), GFP_KERNEL); - if(!status_kobj) - return PTR_ERR(status_kobj); - - status_kset = kset_create_and_add("platform_status", NULL, kernel_kobj); - if(!status_kset) - return -1; - - status_kobj->kset = status_kset; - - retval = kobject_init_and_add(status_kobj, &status_ktype, NULL, "fan"); - if(retval) - return retval; - - retval = sysfs_create_file(status_kobj, &status_att); - - thread_control_set(1); - - printk(KERN_INFO "[p_thread] %s/%d: Creating Thread\n",__func__,__LINE__); - //Create the kernel thread with name 'inv_pthread' - thread_st = kthread_run(thread_fn, (void*)&thread_data, "inv_pthread"); - if (thread_st) - printk(KERN_INFO "[p_thread] inv_pthread Created successfully\n"); - else - printk(KERN_ERR "[p_thread] inv_pthread creation failed\n"); - - return retval; -} - -static void __exit inv_pthread_exit(void) -{ - thread_control_set(0); - /* Delay for guarantee thread exit */ - ssleep(THREAD_DELAY_MINS); - - sysfs_remove_file(status_kobj, &status_att); - kset_unregister(status_kset); - kobject_del(status_kobj); - - printk(KERN_INFO "[p_thread] inv_pthread cleaning Up\n"); -} - -module_init(inv_pthread_init); -module_exit(inv_pthread_exit); - -MODULE_AUTHOR("Robert "); -MODULE_DESCRIPTION("Inventec Platform Management Thread"); -MODULE_VERSION("version 1.1"); -MODULE_LICENSE("GPL"); diff --git a/packages/platforms/inventec/x86-64/d7264q28b/modules/builds/src/inv_pthread.h b/packages/platforms/inventec/x86-64/d7264q28b/modules/builds/src/inv_pthread.h deleted file mode 100644 index c3b7ce830..000000000 --- a/packages/platforms/inventec/x86-64/d7264q28b/modules/builds/src/inv_pthread.h +++ /dev/null @@ -1,19 +0,0 @@ -#ifndef INV_PTHREAD_H -#define INV_PTHREAD_H - -#define CPLD_DEV_LED_GRN_INDEX (0) -#define CPLD_DEV_LED_RED_INDEX (1) - -ssize_t cpld_show_led(char *buf, int index); -ssize_t cpld_set_led(const char *buf, size_t count, int index); -ssize_t cpld_show_ctl(char *buf); -ssize_t cpld_set_ctl(const char *buf, size_t count); - -ssize_t psoc_show_psu_state(char *buf, int index); -ssize_t psoc_show_fan_input(char *buf, int index); -ssize_t psoc_show_fan_state(char *buf); -ssize_t psoc_show_psu_vin(char *buf, int index); -ssize_t psoc_show_diag(char *buf); -ssize_t psoc_set_diag(const char *buf, size_t count); - -#endif /* INV_PTHREAD_H */ diff --git a/packages/platforms/inventec/x86-64/d7264q28b/modules/builds/src/inv_swps.c b/packages/platforms/inventec/x86-64/d7264q28b/modules/builds/src/inv_swps.c deleted file mode 100644 index 41ee99744..000000000 --- a/packages/platforms/inventec/x86-64/d7264q28b/modules/builds/src/inv_swps.c +++ /dev/null @@ -1,3053 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "inv_swps.h" - -static int ctl_major; -static int port_major; -static int ioexp_total; -static int port_total; -static int auto_config; -static int flag_i2c_reset; -static int flag_mod_state; -static unsigned gpio_rest_mux; -static struct class *swp_class_p = NULL; -static struct inv_platform_s *platform_p = NULL; -static struct inv_ioexp_layout_s *ioexp_layout = NULL; -static struct inv_port_layout_s *port_layout = NULL; - -static void swp_polling_worker(struct work_struct *work); -static DECLARE_DELAYED_WORK(swp_polling, swp_polling_worker); - -static int reset_i2c_topology(void); - -static union { - unsigned int eeprom_update_32[2]; - unsigned char eeprom_update_8[8]; -} ueu_64; - -static int -__swp_match(struct device *dev, -#ifdef SWPS_KERN_VER_AF_3_10 - const void *data){ -#else - void *data){ -#endif - - char *name = (char *)data; - if (strcmp(dev_name(dev), name) == 0) - return 1; - return 0; -} - - -struct device * -get_swpdev_by_name(char *name){ - struct device *dev = class_find_device(swp_class_p, - NULL, - name, - __swp_match); - return dev; -} - - -static int -sscanf_2_int(const char *buf) { - - int result = -EBFONT; - char *hex_tag = "0x"; - - if (strcspn(buf, hex_tag) == 0) { - if (sscanf(buf,"%x",&result)) { - return result; - } - } else { - if (sscanf(buf,"%d",&result)) { - return result; - } - if(sscanf(buf,"-%d",&result)) { - return -result; - } - if (sscanf(buf,"%x",&result)) { - return result; - } - } - return -EBFONT; -} - -static unsigned long long int -sscanf_2_ullint(const char *buf, size_t count) { - - unsigned long long int result = -EBFONT; - char *hex_tag = "0x"; - int i, zero = 0; - - for (i = 0; i < count-2; i++) { - if (buf[i] != '0') { - zero = 1; - } - } - if (zero == 0) { - return 0x0ULL; - } - - if (strcspn(buf, hex_tag) == 0) { - for (i = 2; i < count-2; i++) { - if (INV_BATOX(buf[i]) == -1) { - return -EBFONT; - } - } - - if (sscanf(buf,"0x%llx",&result)) { - return result; - } - } else { - for (i = 0; i < count-2; i++) { - if (INV_BATOI(buf[i]) == -1) { - return -EBFONT; - } - } - - if (sscanf(buf,"%llu",&result)) { - return result; - } - } - return -EBFONT; -} - - -static int -sscanf_2_binary(const char *buf) { - - int result = sscanf_2_int(buf); - - if (result < 0){ - return -EBFONT; - } - switch (result) { - case 0: - case 1: - return result; - default: - break; - } - return -EBFONT; -} - -static int -_get_polling_period(void) { - - int retval = 0; - - if (SWP_POLLING_PERIOD == 0) { - return 0; - } - retval = ((SWP_POLLING_PERIOD * HZ) / 1000); - if (retval == 0) { - return 1; - } - return retval; -} - - -static struct transvr_obj_s * -_get_transvr_obj(char *dev_name) { - - struct device *dev_p = NULL; - struct transvr_obj_s *transvr_obj_p = NULL; - - dev_p = get_swpdev_by_name(dev_name); - if (!dev_p){ - return NULL; - } - transvr_obj_p = dev_get_drvdata(dev_p); - if (!transvr_obj_p){ - return NULL; - } - return transvr_obj_p; -} - - -static void -unlock_tobj_all(void) { - - struct transvr_obj_s *tobj_p; - char port_name[32]; - int port_id = 0; - int minor_curr = 0; - - for (minor_curr=0; minor_currauto_config = auto_config; - unlock_transvr_obj(tobj_p); - SWPS_DEBUG("%s: Set %s auto_config=%d\n", - __func__, tobj_p->swp_name, auto_config); - } - return retval; -} - -unsigned char * -get_eeprom_update(void) -{ - return &ueu_64.eeprom_update_8[0]; -} - -void -set_eeprom_update(unsigned char value[8]) -{ - memcpy(ueu_64.eeprom_update_8, value, 8); -} - -/* ========== R/W Functions module control attribute ========== - */ -static ssize_t -show_attr_platform(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - return snprintf(buf_p, 32, "%s\n", platform_p->name); -} - - -static ssize_t -show_attr_version(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - return snprintf(buf_p, 8, "%s\n", SWP_VERSION); -} - - -static ssize_t -show_attr_status(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - return snprintf(buf_p, 8, "%d\n", flag_mod_state); -} - - -static ssize_t -show_attr_auto_config(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - return snprintf(buf_p, 8, "%d\n", auto_config); -} - -static ssize_t -show_attr_eeprom_update(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - return snprintf(buf_p, 20, "0x%02x%02x%02x%02x%02x%02x%02x%02x\n", - ueu_64.eeprom_update_8[7],ueu_64.eeprom_update_8[6], - ueu_64.eeprom_update_8[5],ueu_64.eeprom_update_8[4], - ueu_64.eeprom_update_8[3],ueu_64.eeprom_update_8[2], - ueu_64.eeprom_update_8[1],ueu_64.eeprom_update_8[0]); -} - - -static int -_check_reset_pwd(const char *buf_p, - size_t count) { - - int in_max = 64; - int in_len = (int)count; - char in_val[64] = "ERR"; - char *emsg = "ERR"; - - if (in_len >= in_max) { - emsg = "input too much"; - goto err_check_reset_pwd; - } - if (!sscanf(buf_p,"%s",in_val)) { - emsg = "format incorrect"; - goto err_check_reset_pwd; - } - if (strcmp(in_val, SWP_RESET_PWD) != 0) { - emsg = "password incorrect"; - goto err_check_reset_pwd; - } - return 0; - -err_check_reset_pwd: - SWPS_ERR("%s: %s\n", __func__, emsg); - return -1; -} - - -static ssize_t -store_attr_reset_i2c(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - - if (_check_reset_pwd(buf_p, count) < 0) { - return -EBFONT; - } - /* Polling mode */ - if (SWP_POLLING_ENABLE) { - SWPS_INFO("%s: reset I2C :polling\n", __func__); - flag_i2c_reset = 1; - return count; - } - /* Direct mode */ - SWPS_INFO("%s: reset I2C go. :direct\n", __func__); - if (reset_i2c_topology() < 0) { - SWPS_ERR("%s: reset fail!\n", __func__); - return -EIO; - } - SWPS_INFO("%s: reset I2C ok. :direct\n", __func__); - return count; -} - - -static ssize_t -store_attr_reset_swps(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - - struct transvr_obj_s *tobj_p; - char port_name[32] = "ERR"; - int port_id = 0; - int minor_curr = 0; - - if (_check_reset_pwd(buf_p, count) < 0) { - return -EBFONT; - } - for (minor_curr=0; minor_currstate = STATE_TRANSVR_DISCONNECTED; - unlock_transvr_obj(tobj_p); - SWPS_INFO("%s: reset:%s\n", __func__, tobj_p->swp_name); - } - return count; -} - - -static ssize_t -store_attr_auto_config(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - - int input_val = sscanf_2_int(buf_p); - - if (input_val < 0){ - return -EBFONT; - } - if ((input_val != 0) && (input_val != 1)) { - return -EBFONT; - } - auto_config = input_val; - _update_auto_config_2_trnasvr(); - return count; -} - -static ssize_t -store_attr_eeprom_update(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count) { - - union { - unsigned long long int input_val_64; - unsigned int input_val_32[2]; - } uiv; - int i; - uiv.input_val_64 = sscanf_2_ullint(buf_p, count); - if (uiv.input_val_64 == 0){ - for (i = 0; i < 8; i++) { - ueu_64.eeprom_update_8[i] = 0; - } - } - else - if (uiv.input_val_64 > 0) { - for (i = 0; i < 32; i++) { - if (uiv.input_val_32[0] & 1<get_id, - buf_p); -} - - -static ssize_t -show_attr_ext_id(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_hex_attr(tobj_p, - tobj_p->get_ext_id, - buf_p); -} - - -static ssize_t -show_attr_connector(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_hex_attr(tobj_p, - tobj_p->get_connector, - buf_p); -} - - -static ssize_t -show_attr_vendor_name(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_vendor_name, - buf_p); -} - - -static ssize_t -show_attr_vendor_pn(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_vendor_pn, - buf_p); -} - - -static ssize_t -show_attr_vendor_rev(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_vendor_rev, - buf_p); -} - - -static ssize_t -show_attr_vendor_sn(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_vendor_sn, - buf_p); -} - - -static ssize_t -show_attr_power_cls(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - size_t len; - int result; - struct transvr_obj_s *tobj_p; - - tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - lock_transvr_obj(tobj_p); - result = tobj_p->get_power_cls(tobj_p); - unlock_transvr_obj(tobj_p); - if (result < 0){ - len = snprintf(buf_p, 16, "%d\n", result); - } else { - len = snprintf(buf_p, 16, "Power Class %d\n", result); - } - return len; -} - - -static ssize_t -show_attr_br(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_hex_attr(tobj_p, - tobj_p->get_br, - buf_p); -} - - -static ssize_t -show_attr_len_sm(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_int_attr(tobj_p, - tobj_p->get_len_sm, - buf_p); -} - - -static ssize_t -show_attr_len_smf(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_int_attr(tobj_p, - tobj_p->get_len_smf, - buf_p); -} - - -static ssize_t -show_attr_len_om1(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_int_attr(tobj_p, - tobj_p->get_len_om1, - buf_p); -} - - -static ssize_t -show_attr_len_om2(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_int_attr(tobj_p, - tobj_p->get_len_om2, - buf_p); -} - - -static ssize_t -show_attr_len_om3(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_int_attr(tobj_p, - tobj_p->get_len_om3, - buf_p); -} - - -static ssize_t -show_attr_len_om4(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_int_attr(tobj_p, - tobj_p->get_len_om4, - buf_p); -} - - -static ssize_t -show_attr_comp_rev(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_hex_attr(tobj_p, - tobj_p->get_comp_rev, - buf_p); -} - - -static ssize_t -show_attr_comp_eth(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_hex_attr(tobj_p, - tobj_p->get_comp_eth_1, - buf_p); -} - - -static ssize_t -show_attr_comp_eth_10(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_hex_attr(tobj_p, - tobj_p->get_comp_eth_10, - buf_p); -} - - -static ssize_t -show_attr_comp_eth_10_40(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_hex_attr(tobj_p, - tobj_p->get_comp_eth_10_40, - buf_p); -} - - -static ssize_t -show_attr_comp_extend(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_hex_attr(tobj_p, - tobj_p->get_comp_extend, - buf_p); -} - - -static ssize_t -show_attr_rate_id(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_hex_attr(tobj_p, - tobj_p->get_rate_id, - buf_p); -} - - -static ssize_t -show_attr_temperature(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_curr_temp, - buf_p); -} - - -static ssize_t -show_attr_voltage(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_curr_vol, - buf_p); -} - - -static ssize_t -show_attr_tx_bias(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_tx_bias, - buf_p); -} - - -static ssize_t -show_attr_tx_power(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_tx_power, - buf_p); -} - - -static ssize_t -show_attr_tx_eq(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_tx_eq, - buf_p); -} - - -static ssize_t -show_attr_rx_power(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_rx_power, - buf_p); -} - - -static ssize_t -show_attr_rx_am(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_rx_am, - buf_p); -} - - -static ssize_t -show_attr_rx_em(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_rx_em, - buf_p); -} - - -static ssize_t -show_attr_wavelength(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_wavelength, - buf_p); -} - - -static ssize_t -show_attr_info(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_int_attr(tobj_p, - tobj_p->get_info, - buf_p); -} - - -static ssize_t -show_attr_if_type(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_if_type, - buf_p); -} - - -static ssize_t -show_attr_if_speed(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_if_speed, - buf_p); -} - - -static ssize_t -show_attr_if_lane(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_if_lane, - buf_p); -} - - -static ssize_t -show_attr_cdr(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_hex_attr(tobj_p, - tobj_p->get_cdr, - buf_p); -} - - -static ssize_t -show_attr_soft_rs0(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_int_attr(tobj_p, - tobj_p->get_soft_rs0, - buf_p); -} - - -static ssize_t -show_attr_soft_rs1(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_int_attr(tobj_p, - tobj_p->get_soft_rs1, - buf_p); -} - - -static ssize_t -show_attr_soft_rx_los(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_soft_rx_los, - buf_p); -} - - -static ssize_t -show_attr_soft_tx_disable(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_soft_tx_disable, - buf_p); -} - - -static ssize_t -show_attr_soft_tx_fault(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_soft_tx_fault, - buf_p); -} - - -static ssize_t -show_attr_auto_tx_disable(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_auto_tx_disable, - buf_p); -} - -static ssize_t -show_attr_eeprom(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if(!tobj_p){ - return -ENODEV; - } - return _show_transvr_str_attr(tobj_p, - tobj_p->get_eeprom, - buf_p); -} - - -/* ========== Store functions: transceiver (R/W) attribute ========== - */ -static ssize_t -_store_transvr_int_attr(struct transvr_obj_s* tobj_p, - int (*set_func)(struct transvr_obj_s *tobj_p, int input_val), - const char *buf_p, - size_t count) { - int input, err; - - input = sscanf_2_int(buf_p); - if (input < 0){ - return -EBFONT; - } - lock_transvr_obj(tobj_p); - err = set_func(tobj_p, input); - unlock_transvr_obj(tobj_p); - if (err < 0){ - return err; - } - return count; -} - - -static ssize_t -_store_transvr_byte_hex_attr(struct transvr_obj_s* tobj_p, - int (*set_func)(struct transvr_obj_s *tobj_p, int input_val), - const char *buf_p, - size_t count) { - int input, err; - - input = sscanf_2_int(buf_p); - if ((input < 0) || (input > 0xff)){ - return -EBFONT; - } - lock_transvr_obj(tobj_p); - err = set_func(tobj_p, input); - unlock_transvr_obj(tobj_p); - if (err < 0){ - return err; - } - return count; -} - - -static ssize_t -_store_transvr_binary_attr(struct transvr_obj_s* tobj_p, - int (*set_func)(struct transvr_obj_s *tobj_p, int input_val), - const char *buf_p, - size_t count) { - int input, err; - - input = sscanf_2_binary(buf_p); - if (input < 0){ - return -EBFONT; - } - lock_transvr_obj(tobj_p); - err = set_func(tobj_p, input); - unlock_transvr_obj(tobj_p); - if (err < 0){ - return err; - } - return count; -} - - -static ssize_t -store_attr_cdr(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - return _store_transvr_byte_hex_attr(tobj_p, - tobj_p->set_cdr, - buf_p, - count); -} - - -static ssize_t -store_attr_soft_rs0(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - return _store_transvr_binary_attr(tobj_p, - tobj_p->set_soft_rs0, - buf_p, - count); -} - - -static ssize_t -store_attr_soft_rs1(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - return _store_transvr_binary_attr(tobj_p, - tobj_p->set_soft_rs1, - buf_p, - count); -} - - -static ssize_t -store_attr_soft_tx_disable(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count) { - - int check = sscanf_2_int(buf_p); - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - if ((check < 0) || (check > 0xf)){ - return -EBFONT; - } - return _store_transvr_byte_hex_attr(tobj_p, - tobj_p->set_soft_tx_disable, - buf_p, - count); -} - - -static ssize_t -store_attr_auto_tx_disable(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count) { - - int err = -EPERM; - int input = sscanf_2_int(buf_p); - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - if ((input < 0) || (input > 0xf)){ - if (input != VAL_TRANSVR_FUNCTION_DISABLE) { - return -EBFONT; - } - } - lock_transvr_obj(tobj_p); - err = tobj_p->set_auto_tx_disable(tobj_p, input); - unlock_transvr_obj(tobj_p); - if (err < 0){ - return err; - } - return count; -} - - -static ssize_t -store_attr_tx_eq(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - return _store_transvr_int_attr(tobj_p, - tobj_p->set_tx_eq, - buf_p, - count); -} - - -static ssize_t -store_attr_rx_am(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - return _store_transvr_int_attr(tobj_p, - tobj_p->set_rx_am, - buf_p, - count); -} - - -static ssize_t -store_attr_rx_em(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - return _store_transvr_int_attr(tobj_p, - tobj_p->set_rx_em, - buf_p, - count); -} - -/* ========== Show functions: For I/O Expander attribute ========== - */ -static ssize_t -_show_ioexp_binary_attr(struct transvr_obj_s *tobj_p, - int (*get_func)(struct ioexp_obj_s *ioexp_p, int voffset), - char *buf_p) { - size_t len; - struct ioexp_obj_s *ioexp_p = tobj_p->ioexp_obj_p; - - if (!ioexp_p) { - SWPS_ERR(" %s: data corruption! :%s\n", __func__, tobj_p->swp_name); - return -ENODATA; - } - mutex_lock(&ioexp_p->lock); - len = snprintf(buf_p, 8, "%d\n", get_func(ioexp_p, tobj_p->ioexp_virt_offset)); - mutex_unlock(&ioexp_p->lock); - return len; -} - - -static ssize_t -show_attr_present(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - return _show_ioexp_binary_attr(tobj_p, - tobj_p->ioexp_obj_p->get_present, - buf_p); -} - - -static ssize_t -show_attr_tx_fault(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - return _show_ioexp_binary_attr(tobj_p, - tobj_p->ioexp_obj_p->get_tx_fault, - buf_p); -} - - -static ssize_t -show_attr_rxlos(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - return _show_ioexp_binary_attr(tobj_p, - tobj_p->ioexp_obj_p->get_rxlos, - buf_p); -} - - -static ssize_t -show_attr_tx_disable(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - return _show_ioexp_binary_attr(tobj_p, - tobj_p->ioexp_obj_p->get_tx_disable, - buf_p); -} - - -static ssize_t -show_attr_reset(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - return _show_ioexp_binary_attr(tobj_p, - tobj_p->ioexp_obj_p->get_reset, - buf_p); -} - - -static ssize_t -show_attr_lpmod(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - return _show_ioexp_binary_attr(tobj_p, - tobj_p->ioexp_obj_p->get_lpmod, - buf_p); -} - - -static ssize_t -show_attr_modsel(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - return _show_ioexp_binary_attr(tobj_p, - tobj_p->ioexp_obj_p->get_modsel, - buf_p); -} - - -static ssize_t -show_attr_hard_rs0(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - return _show_ioexp_binary_attr(tobj_p, - tobj_p->ioexp_obj_p->get_hard_rs0, - buf_p); -} - - -static ssize_t -show_attr_hard_rs1(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p){ - return -ENODEV; - } - return _show_ioexp_binary_attr(tobj_p, - tobj_p->ioexp_obj_p->get_hard_rs1, - buf_p); -} - - -/* ========== Store functions: For I/O Expander (R/W) attribute ========== - */ -static ssize_t -_store_ioexp_binary_attr(struct transvr_obj_s *tobj_p, - int (*set_func)(struct ioexp_obj_s *ioexp_p, - int virt_offset, int input_val), - const char *buf_p, - size_t count) { - - int input, err; - struct ioexp_obj_s *ioexp_p = tobj_p->ioexp_obj_p; - - if (!ioexp_p) { - SWPS_ERR("%s: data corruption! :%s\n", - __func__, tobj_p->swp_name); - return -ENODATA; - } - input = sscanf_2_binary(buf_p); - if (input < 0) { - return -EBFONT; - } - mutex_lock(&ioexp_p->lock); - err = set_func(ioexp_p, tobj_p->ioexp_virt_offset, input); - mutex_unlock(&ioexp_p->lock); - if (err < 0){ - return err; - } - return count; -} - -static ssize_t -store_attr_tx_disable(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p) { - return -ENODEV; - } - return _store_ioexp_binary_attr(tobj_p, - tobj_p->ioexp_obj_p->set_tx_disable, - buf_p, - count); -} - - -static ssize_t -store_attr_reset(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p) { - return -ENODEV; - } - return _store_ioexp_binary_attr(tobj_p, - tobj_p->ioexp_obj_p->set_reset, - buf_p, - count); -} - - -static ssize_t -store_attr_lpmod(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p) { - return -ENODEV; - } - return _store_ioexp_binary_attr(tobj_p, - tobj_p->ioexp_obj_p->set_lpmod, - buf_p, - count); -} - - -static ssize_t -store_attr_modsel(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p) { - return -ENODEV; - } - return _store_ioexp_binary_attr(tobj_p, - tobj_p->ioexp_obj_p->set_modsel, - buf_p, - count); -} - - -static ssize_t -store_attr_hard_rs0(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p) { - return -ENODEV; - } - return _store_ioexp_binary_attr(tobj_p, - tobj_p->ioexp_obj_p->set_hard_rs0, - buf_p, - count); -} - - -static ssize_t -store_attr_hard_rs1(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - - struct transvr_obj_s *tobj_p = dev_get_drvdata(dev_p); - if (!tobj_p) { - return -ENODEV; - } - return _store_ioexp_binary_attr(tobj_p, - tobj_p->ioexp_obj_p->set_hard_rs1, - buf_p, - count); -} - - -/* ========== SWPS attribute: For module control ========== - */ -static DEVICE_ATTR(platform, S_IRUGO, show_attr_platform, NULL); -static DEVICE_ATTR(version, S_IRUGO, show_attr_version, NULL); -static DEVICE_ATTR(status, S_IRUGO, show_attr_status, NULL); -static DEVICE_ATTR(reset_i2c, S_IWUSR, NULL, store_attr_reset_i2c); -static DEVICE_ATTR(reset_swps, S_IWUSR, NULL, store_attr_reset_swps); -static DEVICE_ATTR(auto_config, S_IRUGO|S_IWUSR, show_attr_auto_config, store_attr_auto_config); -static DEVICE_ATTR(eeprom_update, S_IRUGO|S_IWUSR, show_attr_eeprom_update, store_attr_eeprom_update); - -/* ========== Transceiver attribute: from eeprom ========== - */ -static DEVICE_ATTR(id, S_IRUGO, show_attr_id, NULL); -static DEVICE_ATTR(ext_id, S_IRUGO, show_attr_ext_id, NULL); -static DEVICE_ATTR(connector, S_IRUGO, show_attr_connector, NULL); -static DEVICE_ATTR(vendor_name, S_IRUGO, show_attr_vendor_name, NULL); -static DEVICE_ATTR(vendor_pn, S_IRUGO, show_attr_vendor_pn, NULL); -static DEVICE_ATTR(vendor_rev, S_IRUGO, show_attr_vendor_rev, NULL); -static DEVICE_ATTR(vendor_sn, S_IRUGO, show_attr_vendor_sn, NULL); -static DEVICE_ATTR(power_cls, S_IRUGO, show_attr_power_cls, NULL); -static DEVICE_ATTR(br, S_IRUGO, show_attr_br, NULL); -static DEVICE_ATTR(len_sm, S_IRUGO, show_attr_len_sm, NULL); -static DEVICE_ATTR(len_smf, S_IRUGO, show_attr_len_smf, NULL); -static DEVICE_ATTR(len_om1, S_IRUGO, show_attr_len_om1, NULL); -static DEVICE_ATTR(len_om2, S_IRUGO, show_attr_len_om2, NULL); -static DEVICE_ATTR(len_om3, S_IRUGO, show_attr_len_om3, NULL); -static DEVICE_ATTR(len_om4, S_IRUGO, show_attr_len_om4, NULL); -static DEVICE_ATTR(comp_rev, S_IRUGO, show_attr_comp_rev, NULL); -static DEVICE_ATTR(comp_eth, S_IRUGO, show_attr_comp_eth, NULL); -static DEVICE_ATTR(comp_eth_10, S_IRUGO, show_attr_comp_eth_10, NULL); -static DEVICE_ATTR(comp_eth_10_40, S_IRUGO, show_attr_comp_eth_10_40, NULL); -static DEVICE_ATTR(comp_extend, S_IRUGO, show_attr_comp_extend, NULL); -static DEVICE_ATTR(rate_id, S_IRUGO, show_attr_rate_id, NULL); -static DEVICE_ATTR(temperature, S_IRUGO, show_attr_temperature, NULL); -static DEVICE_ATTR(voltage, S_IRUGO, show_attr_voltage, NULL); -static DEVICE_ATTR(tx_bias, S_IRUGO, show_attr_tx_bias, NULL); -static DEVICE_ATTR(tx_power, S_IRUGO, show_attr_tx_power, NULL); -static DEVICE_ATTR(rx_power, S_IRUGO, show_attr_rx_power, NULL); -static DEVICE_ATTR(info, S_IRUGO, show_attr_info, NULL); -static DEVICE_ATTR(if_type, S_IRUGO, show_attr_if_type, NULL); -static DEVICE_ATTR(if_speed, S_IRUGO, show_attr_if_speed, NULL); -static DEVICE_ATTR(if_lane, S_IRUGO, show_attr_if_lane, NULL); -static DEVICE_ATTR(soft_rx_los, S_IRUGO, show_attr_soft_rx_los, NULL); -static DEVICE_ATTR(soft_tx_fault, S_IRUGO, show_attr_soft_tx_fault, NULL); -static DEVICE_ATTR(wavelength, S_IRUGO, show_attr_wavelength, NULL); -static DEVICE_ATTR(eeprom, S_IRUGO, show_attr_eeprom, NULL); -static DEVICE_ATTR(tx_eq, S_IRUGO|S_IWUSR, show_attr_tx_eq, store_attr_tx_eq); -static DEVICE_ATTR(rx_am, S_IRUGO|S_IWUSR, show_attr_rx_am, store_attr_rx_am); -static DEVICE_ATTR(rx_em, S_IRUGO|S_IWUSR, show_attr_rx_em, store_attr_rx_em); -static DEVICE_ATTR(cdr, S_IRUGO|S_IWUSR, show_attr_cdr, store_attr_cdr); -static DEVICE_ATTR(soft_rs0, S_IRUGO|S_IWUSR, show_attr_soft_rs0, store_attr_soft_rs0); -static DEVICE_ATTR(soft_rs1, S_IRUGO|S_IWUSR, show_attr_soft_rs1, store_attr_soft_rs1); -static DEVICE_ATTR(soft_tx_disable, S_IRUGO|S_IWUSR, show_attr_soft_tx_disable, store_attr_soft_tx_disable); -static DEVICE_ATTR(auto_tx_disable, S_IRUGO|S_IWUSR, show_attr_auto_tx_disable, store_attr_auto_tx_disable); - -/* ========== IO Expander attribute: from expander ========== - */ -static DEVICE_ATTR(present, S_IRUGO, show_attr_present, NULL); -static DEVICE_ATTR(tx_fault, S_IRUGO, show_attr_tx_fault, NULL); -static DEVICE_ATTR(rxlos, S_IRUGO, show_attr_rxlos, NULL); -static DEVICE_ATTR(tx_disable, S_IRUGO|S_IWUSR, show_attr_tx_disable, store_attr_tx_disable); -static DEVICE_ATTR(reset, S_IRUGO|S_IWUSR, show_attr_reset, store_attr_reset); -static DEVICE_ATTR(lpmod, S_IRUGO|S_IWUSR, show_attr_lpmod, store_attr_lpmod); -static DEVICE_ATTR(modsel, S_IRUGO|S_IWUSR, show_attr_modsel, store_attr_modsel); -static DEVICE_ATTR(hard_rs0, S_IRUGO|S_IWUSR, show_attr_hard_rs0, store_attr_hard_rs0); -static DEVICE_ATTR(hard_rs1, S_IRUGO|S_IWUSR, show_attr_hard_rs1, store_attr_hard_rs1); - -/* ========== Functions for module handling ========== - */ -static void -clean_port_obj(void){ - - dev_t dev_num; - char dev_name[32]; - struct device *device_p; - struct transvr_obj_s *transvr_obj_p; - int minor_curr, port_id; - - for (minor_curr=0; minor_curri2c_client_p); - kfree(transvr_obj_p->vendor_name); - kfree(transvr_obj_p->vendor_pn); - kfree(transvr_obj_p->vendor_rev); - kfree(transvr_obj_p->vendor_sn); - kfree(transvr_obj_p->worker_p); - kfree(transvr_obj_p); - } - dev_num = MKDEV(port_major, minor_curr); - device_unregister(device_p); - device_destroy(swp_class_p, dev_num); - } - SWPS_DEBUG("%s: done.\n", __func__); -} - - -static void -clean_swps_common(void){ - - dev_t dev_num; - struct device *device_p; - - device_p = get_swpdev_by_name(SWP_DEV_MODCTL); - if (device_p){ - dev_num = MKDEV(ctl_major, 1); - device_unregister(device_p); - device_destroy(swp_class_p, dev_num); - } - cancel_delayed_work_sync(&swp_polling); - SWPS_DEBUG("%s: done.\n", __func__); -} - - -static int -get_platform_type(void){ - - int i; - int pf_total = ARRAY_SIZE(platform_map); - char log_msg[64] = "ERROR"; - - platform_p = kzalloc(sizeof(struct inv_platform_s), GFP_KERNEL); - if (!platform_p){ - snprintf(log_msg, sizeof(log_msg), "kzalloc fail"); - goto err_get_platform_type_1; - } - memset(platform_p->name, 0, sizeof(platform_p->name)); - - switch (PLATFORM_SETTINGS) { - case PLATFORM_TYPE_AUTO: - snprintf(platform_p->name, (sizeof(platform_p->name) - 1), - "%s", dmi_get_system_info(DMI_BOARD_NAME)); - for (i=0; iname, platform_map[i].name) == 0) { - platform_p->id = platform_map[i].id; - snprintf(log_msg, sizeof(log_msg), - "Auto detect platform: %d (%s)", - platform_p->id, platform_p->name); - goto ok_get_platform_type_1; - } - } - snprintf(log_msg, sizeof(log_msg), - "Auto detect fail! detect platform: %s", - platform_p->name); - goto err_get_platform_type_2; - - case PLATFORM_TYPE_MAGNOLIA: - case PLATFORM_TYPE_MAGNOLIA_FNC: - case PLATFORM_TYPE_REDWOOD: - case PLATFORM_TYPE_REDWOOD_FSL: - case PLATFORM_TYPE_HUDSON32I_GA: - case PLATFORM_TYPE_SPRUCE: - case PLATFORM_TYPE_CYPRESS_GA1: - case PLATFORM_TYPE_CYPRESS_GA2: - case PLATFORM_TYPE_CYPRESS_BAI: - case PLATFORM_TYPE_TAHOE: - case PLATFORM_TYPE_SEQUOIA_GA: - platform_p->id = PLATFORM_SETTINGS; - for (i=0; iname, (sizeof(platform_p->name) - 1), - "%s", platform_map[i].name); - snprintf(log_msg, sizeof(log_msg), - "User setup platform: %d (%s)", - platform_p->id, platform_p->name); - goto ok_get_platform_type_1; - } - } - snprintf(log_msg, sizeof(log_msg), - "Internal error, can not map id:%d", - PLATFORM_SETTINGS); - goto err_get_platform_type_2; - - default: - break; - } - snprintf(log_msg, sizeof(log_msg), - "PLATFORM_SETTINGS:%d undefined", PLATFORM_SETTINGS); - goto err_get_platform_type_2; - -ok_get_platform_type_1: - SWPS_DEBUG("%s: %s, :%d\n", __func__, log_msg, PLATFORM_SETTINGS); - return 0; - -err_get_platform_type_2: - kfree(platform_p); -err_get_platform_type_1: - SWPS_ERR("%s: %s :%d\n", __func__, log_msg, PLATFORM_SETTINGS); - return -1; -} - - -static int -get_layout_info(void){ - - switch (platform_p->id) { -#ifdef SWPS_MAGNOLIA - case PLATFORM_TYPE_MAGNOLIA: - case PLATFORM_TYPE_MAGNOLIA_FNC: - gpio_rest_mux = magnolia_gpio_rest_mux; - ioexp_layout = magnolia_ioexp_layout; - port_layout = magnolia_port_layout; - ioexp_total = ARRAY_SIZE(magnolia_ioexp_layout); - port_total = ARRAY_SIZE(magnolia_port_layout); - break; -#endif -#ifdef SWPS_REDWOOD - case PLATFORM_TYPE_REDWOOD: - gpio_rest_mux = redwood_gpio_rest_mux; - ioexp_layout = redwood_ioexp_layout; - port_layout = redwood_port_layout; - ioexp_total = ARRAY_SIZE(redwood_ioexp_layout); - port_total = ARRAY_SIZE(redwood_port_layout); - break; -#endif -#ifdef SWPS_HUDSON32I_GA - case PLATFORM_TYPE_HUDSON32I_GA: - gpio_rest_mux = hudsin32iga_gpio_rest_mux; - ioexp_layout = hudson32iga_ioexp_layout; - port_layout = hudson32iga_port_layout; - ioexp_total = ARRAY_SIZE(hudson32iga_ioexp_layout); - port_total = ARRAY_SIZE(hudson32iga_port_layout); - break; -#endif -#ifdef SWPS_SPRUCE - case PLATFORM_TYPE_SPRUCE: - gpio_rest_mux = spruce_gpio_rest_mux; - ioexp_layout = spruce_ioexp_layout; - port_layout = spruce_port_layout; - ioexp_total = ARRAY_SIZE(spruce_ioexp_layout); - port_total = ARRAY_SIZE(spruce_port_layout); - break; -#endif -#ifdef SWPS_CYPRESS_GA1 - case PLATFORM_TYPE_CYPRESS_GA1: - gpio_rest_mux = cypress_ga1_gpio_rest_mux; - ioexp_layout = cypress_ga1_ioexp_layout; - port_layout = cypress_ga1_port_layout; - ioexp_total = ARRAY_SIZE(cypress_ga1_ioexp_layout); - port_total = ARRAY_SIZE(cypress_ga1_port_layout); - break; -#endif -#ifdef SWPS_CYPRESS_GA2 - case PLATFORM_TYPE_CYPRESS_GA2: - gpio_rest_mux = cypress_ga2_gpio_rest_mux; - ioexp_layout = cypress_ga2_ioexp_layout; - port_layout = cypress_ga2_port_layout; - ioexp_total = ARRAY_SIZE(cypress_ga2_ioexp_layout); - port_total = ARRAY_SIZE(cypress_ga2_port_layout); - break; -#endif -#ifdef SWPS_CYPRESS_BAI - case PLATFORM_TYPE_CYPRESS_BAI: - gpio_rest_mux = cypress_b_gpio_rest_mux; - ioexp_layout = cypress_b_ioexp_layout; - port_layout = cypress_b_port_layout; - ioexp_total = ARRAY_SIZE(cypress_b_ioexp_layout); - port_total = ARRAY_SIZE(cypress_b_port_layout); - break; -#endif -#ifdef SWPS_REDWOOD_FSL - case PLATFORM_TYPE_REDWOOD_FSL: - gpio_rest_mux = redwood_fsl_gpio_rest_mux; - ioexp_layout = redwood_fsl_ioexp_layout; - port_layout = redwood_fsl_port_layout; - ioexp_total = ARRAY_SIZE(redwood_fsl_ioexp_layout); - port_total = ARRAY_SIZE(redwood_fsl_port_layout); - break; -#endif -#ifdef SWPS_TAHOE - case PLATFORM_TYPE_TAHOE: - gpio_rest_mux = tahoe_gpio_rest_mux; - ioexp_layout = tahoe_ioexp_layout; - port_layout = tahoe_port_layout; - ioexp_total = ARRAY_SIZE(tahoe_ioexp_layout); - port_total = ARRAY_SIZE(tahoe_port_layout); - break; -#endif -#ifdef SWPS_SEQUOIA - case PLATFORM_TYPE_SEQUOIA_GA: - gpio_rest_mux = sequoia_gpio_rest_mux; - ioexp_layout = secquoia_ioexp_layout; - port_layout = secquoia_port_layout; - ioexp_total = ARRAY_SIZE(secquoia_ioexp_layout); - port_total = ARRAY_SIZE(secquoia_port_layout); - break; -#endif - default: - SWPS_ERR(" Invalid platform: %d (%s)\n", - platform_p->id, platform_p->name); - return -1; - } - SWPS_INFO("Start to initial platform: %d (%s)\n", - platform_p->id, platform_p->name); - return 0; -} - - -/* ========== Functions for objects operations ========== - */ -static int -__detect_issues_port(int minor_num) { - - struct transvr_obj_s *tobj_p; - int port_id = port_layout[minor_num].port_id; - char port_name[32] = "ERR"; - char *i2c_emsg = "detected bad transceiver/cable"; - - memset(port_name, 0, sizeof(port_name)); - snprintf(port_name, sizeof(port_name), "%s%d", SWP_DEV_PORT, port_id); - tobj_p = _get_transvr_obj(port_name); - if (!tobj_p) { - SWPS_INFO("%s: tobj_p is NULL :%d\n", __func__, minor_num); - return -1; - } - if (resync_channel_tier_2(tobj_p) < 0) { - if (check_channel_tier_1() < 0) { - alarm_msg_2_user(tobj_p, i2c_emsg); - return -2;; - } - } - return 0; -} - - -static int -_detect_issues_port(void) { - /* OK : retrun -1; - * Fail: return fail at which minor number (0~N) - */ - char *emsg = "ERR"; - int minor = 0; - int minor_2st = 1; - - /* Force moving the initial channel pointer - * Filter out case of fail at minor-0 port - */ - while (minor_2st < port_total) { - minor = minor_2st; - if (__detect_issues_port(minor_2st) < 0) { - emsg = "detect minor_2st fail"; - goto err_p_detect_issues_port; - } - minor_2st += 8; - } - /* Scan all port */ - for (minor=0; minor:%d\n", __func__, emsg, minor_err); - return -1; -} - - -static int -check_transvr_obj_one(char *dev_name){ - /* [Return] - * 0 : Doesn't need to take care - * -1 : Single error - * -2 : Critical error (I2C topology die) - * -9 : Internal error - */ - struct transvr_obj_s *tobj_p = NULL; - int retval = -9; - - tobj_p = _get_transvr_obj(dev_name); - if (!tobj_p) { - SWPS_ERR("%s: %s _get_transvr_obj fail\n", - __func__, dev_name); - return -9; - } - /* Check transceiver current status */ - lock_transvr_obj(tobj_p); - retval = tobj_p->check(tobj_p); - unlock_transvr_obj(tobj_p); - switch (retval) { - case 0: - case ERR_TRANSVR_UNPLUGGED: - case ERR_TRNASVR_BE_ISOLATED: - case ERR_TRANSVR_TASK_BUSY: - return 0; - - case ERR_TRANSVR_I2C_CRASH: - default: - break; - } - /* Identify abnormal case */ - if (check_channel_tier_1() < 0) { - SWPS_DEBUG("%s: %s critical error :%d\n", - __func__, dev_name, retval); - return -2; - } - SWPS_DEBUG("%s: %s single error :%d\n", - __func__, dev_name, retval); - return -1; -} - - -static int -check_transvr_objs(void){ - - char dev_name[32]; - int port_id, err_code; - int minor_curr = 0; - - for (minor_curr=0; minor_curr:%d\n", - __func__, dev_name, err_code); - break; - } - } - return 0; - -err_check_transvr_objs: - SWPS_ERR("%s: %s reset_i2c_topology fail.\n", - __func__, dev_name); - return -1; -} - - -static void -swp_polling_worker(struct work_struct *work){ - - /* Reset I2C */ - if (flag_i2c_reset) { - goto polling_reset_i2c; - } - /* Check IOEXP */ - if (check_ioexp_objs() < 0) { - goto polling_reset_i2c; - } - /* Check transceiver */ - if (check_transvr_objs() < 0) { - SWPS_DEBUG("%s: check_transvr_objs fail.\n", __func__); - flag_i2c_reset = 1; - } - goto polling_schedule_round; - -polling_reset_i2c: - SWPS_DEBUG("%s: reset_i2c_topology start.\n", __func__); - if (reset_i2c_topology() < 0) { - SWPS_ERR("%s: reset i2c fail!\n", __func__); - flag_i2c_reset = 1; - } else { - SWPS_DEBUG("%s: reset_i2c_topology OK.\n", __func__); - flag_i2c_reset = 0; - } -polling_schedule_round: - schedule_delayed_work(&swp_polling, _get_polling_period()); -} - - -/* ========== Functions for register something ========== - */ -static int -register_transvr_common_attr(struct device *device_p){ - - char *err_attr = NULL; - - if (device_create_file(device_p, &dev_attr_id) < 0) { - err_attr = "dev_attr_id"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_ext_id) < 0) { - err_attr = "dev_attr_ext_id"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_connector) < 0) { - err_attr = "dev_attr_connector"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_vendor_name) < 0) { - err_attr = "dev_attr_vendor_name"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_vendor_pn) < 0) { - err_attr = "dev_attr_vendor_pn"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_vendor_rev) < 0) { - err_attr = "dev_attr_vendor_rev"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_vendor_sn) < 0) { - err_attr = "dev_attr_vendor_sn"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_br) < 0) { - err_attr = "dev_attr_br"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_len_smf) < 0) { - err_attr = "dev_attr_len_smf"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_len_om1) < 0) { - err_attr = "dev_attr_len_om1"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_len_om2) < 0) { - err_attr = "dev_attr_len_om2"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_len_om3) < 0) { - err_attr = "dev_attr_len_om3"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_len_om4) < 0) { - err_attr = "dev_attr_len_om4"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_comp_extend) < 0) { - err_attr = "dev_attr_comp_extend"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_comp_eth) < 0) { - err_attr = "dev_attr_comp_eth"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_comp_rev) < 0) { - err_attr = "dev_attr_comp_rev"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_info) < 0) { - err_attr = "dev_attr_info"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_if_type) < 0) { - err_attr = "dev_attr_if_type"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_if_speed) < 0) { - err_attr = "dev_attr_if_speed"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_if_lane) < 0) { - err_attr = "dev_attr_if_lane"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_temperature) < 0) { - err_attr = "dev_attr_temperature"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_voltage) < 0) { - err_attr = "dev_attr_voltage"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_tx_bias) < 0) { - err_attr = "dev_attr_tx_bias"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_tx_power) < 0) { - err_attr = "dev_attr_tx_power"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_rx_power) < 0) { - err_attr = "dev_attr_rx_power"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_tx_eq) < 0) { - err_attr = "dev_attr_tx_eq"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_rx_em) < 0) { - err_attr = "dev_attr_rx_em"; - goto err_transvr_comm_attr; - } - if (device_create_file(device_p, &dev_attr_wavelength) < 0) { - err_attr = "dev_attr_wavelength"; - goto err_transvr_comm_attr; - } - return 0; - -err_transvr_comm_attr: - SWPS_ERR("%s: %s\n", __func__, err_attr); - return -1; -} - -static int -register_transvr_sfp_attr(struct device *device_p){ - - char *err_attr = NULL; - - if (register_transvr_common_attr(device_p) < 0) { - err_attr = "register_transvr_common_attr"; - goto err_transvr_sfp_attr; - } - if (device_create_file(device_p, &dev_attr_comp_eth_10) < 0) { - err_attr = "dev_attr_comp_eth_10"; - goto err_transvr_sfp_attr; - } - if (device_create_file(device_p, &dev_attr_len_sm) < 0) { - err_attr = "dev_attr_len_sm"; - goto err_transvr_sfp_attr; - } - if (device_create_file(device_p, &dev_attr_rate_id) < 0) { - err_attr = "dev_attr_rate_id"; - goto err_transvr_sfp_attr; - } - if (device_create_file(device_p, &dev_attr_soft_rs0) < 0) { - err_attr = "dev_attr_soft_rs0"; - goto err_transvr_sfp_attr; - } - if (device_create_file(device_p, &dev_attr_soft_rs1) < 0) { - err_attr = "dev_attr_soft_rs1"; - goto err_transvr_sfp_attr; - } - return 0; - -err_transvr_sfp_attr: - SWPS_ERR("%s: %s\n", __func__, err_attr); - return -1; -} - - -static int -register_transvr_qsfp_attr(struct device *device_p){ - - char *err_attr = NULL; - - if (register_transvr_common_attr(device_p) < 0) { - err_attr = "register_transvr_common_attr"; - goto err_transvr_qsfp_attr; - } - if (device_create_file(device_p, &dev_attr_comp_eth_10_40) < 0) { - err_attr = "dev_attr_comp_eth_10_40"; - goto err_transvr_qsfp_attr; - } - if (device_create_file(device_p, &dev_attr_power_cls) < 0) { - err_attr = "dev_attr_power_cls"; - goto err_transvr_qsfp_attr; - } - if (device_create_file(device_p, &dev_attr_soft_rx_los) < 0) { - err_attr = "soft_rx_los"; - goto err_transvr_qsfp_attr; - } - if (device_create_file(device_p, &dev_attr_soft_tx_disable) < 0) { - err_attr = "soft_tx_disable"; - goto err_transvr_qsfp_attr; - } - if (device_create_file(device_p, &dev_attr_auto_tx_disable) < 0) { - err_attr = "auto_tx_disable"; - goto err_transvr_qsfp_attr; - } - if (device_create_file(device_p, &dev_attr_soft_tx_fault) < 0) { - err_attr = "soft_tx_fault"; - goto err_transvr_qsfp_attr; - } - if (device_create_file(device_p, &dev_attr_eeprom) < 0) { - err_attr = "eeprom"; - goto err_transvr_qsfp_attr; - } - return 0; - -err_transvr_qsfp_attr: - SWPS_ERR("%s: %s\n", __func__, err_attr); - return -1; -} - - -static int -register_transvr_qsfp28_attr(struct device *device_p){ - - char *err_attr = NULL; - - if (register_transvr_qsfp_attr(device_p) < 0){ - err_attr = "register_transvr_qsfp_attr"; - goto err_transvr_qsfp28_attr; - } - if (device_create_file(device_p, &dev_attr_cdr) < 0) { - err_attr = "dev_attr_cdr"; - goto err_transvr_qsfp28_attr; - } - if (device_create_file(device_p, &dev_attr_rx_am) < 0) { - err_attr = "dev_attr_rx_am"; - goto err_transvr_qsfp28_attr; - } - return 0; - -err_transvr_qsfp28_attr: - SWPS_ERR("%s: %s\n", __func__, err_attr); - return -1; -} - - -static int -register_transvr_attr(struct device *device_p, - struct transvr_obj_s *transvr_obj){ - - switch (transvr_obj->layout){ - case TRANSVR_TYPE_SFP: - if (register_transvr_sfp_attr(device_p) < 0){ - goto err_reg_tvr_attr; - } - break; - case TRANSVR_TYPE_QSFP: - case TRANSVR_TYPE_QSFP_PLUS: - if (register_transvr_qsfp_attr(device_p) < 0){ - goto err_reg_tvr_attr; - } - break; - case TRANSVR_TYPE_QSFP_28: - if (register_transvr_qsfp28_attr(device_p) < 0){ - goto err_reg_tvr_attr; - } - break; - default: - goto err_reg_tvr_attr; - } - return 0; - -err_reg_tvr_attr: - SWPS_ERR("%s: fail! type=%d \n", __func__, transvr_obj->type); - return -1; -} - - -static int -register_ioexp_attr_sfp_1(struct device *device_p){ - /* Support machine type: - * - SFP : Magnolia - */ - char *err_attr = NULL; - - if (device_create_file(device_p, &dev_attr_present) < 0) { - err_attr = "dev_attr_present"; - goto err_ioexp_sfp1_attr; - } - if (device_create_file(device_p, &dev_attr_tx_fault) < 0) { - err_attr = "dev_attr_tx_fault"; - goto err_ioexp_sfp1_attr; - } - if (device_create_file(device_p, &dev_attr_rxlos) < 0) { - err_attr = "dev_attr_rxlos"; - goto err_ioexp_sfp1_attr; - } - if (device_create_file(device_p, &dev_attr_tx_disable) < 0) { - err_attr = "dev_attr_tx_disable"; - goto err_ioexp_sfp1_attr; - } - return 0; - -err_ioexp_sfp1_attr: - SWPS_ERR("Add device attribute:%s failure! \n",err_attr); - return -1; -} - - -static int -register_ioexp_attr_sfp_2(struct device *device_p){ - /* Support machine type: - * - SFP28 : Cypress - */ - char *err_attr = NULL; - - if (register_ioexp_attr_sfp_1(device_p) < 0){ - goto err_ioexp_sfp2_attr; - } - if (device_create_file(device_p, &dev_attr_hard_rs0) < 0) { - err_attr = "dev_attr_hard_rs0"; - goto err_ioexp_sfp2_attr; - } - if (device_create_file(device_p, &dev_attr_hard_rs1) < 0) { - err_attr = "dev_attr_hard_rs1"; - goto err_ioexp_sfp2_attr; - } - return 0; - -err_ioexp_sfp2_attr: - SWPS_ERR("Add device attribute:%s failure! \n",err_attr); - return -1; -} - - -static int -register_ioexp_attr_qsfp_1(struct device *device_p){ - /* Support machine type: - * - QSFP : Magnolia, Redwood, Hudson32i - * - QSFP+ : Magnolia, Redwood, Hudson32i - * - QSFP28: Redwood - */ - char *err_attr = NULL; - - if (device_create_file(device_p, &dev_attr_present) < 0) { - err_attr = "dev_attr_present"; - goto err_ioexp_qsfp1_attr; - } - if (device_create_file(device_p, &dev_attr_reset) < 0) { - err_attr = "dev_attr_reset"; - goto err_ioexp_qsfp1_attr; - } - if (device_create_file(device_p, &dev_attr_lpmod) < 0) { - err_attr = "dev_attr_lpmod"; - goto err_ioexp_qsfp1_attr; - } - if (device_create_file(device_p, &dev_attr_modsel) < 0) { - err_attr = "dev_attr_modsel"; - goto err_ioexp_qsfp1_attr; - } - return 0; - -err_ioexp_qsfp1_attr: - SWPS_ERR("Add device attribute:%s failure! \n",err_attr); - return -1; -} - - -static int -register_modctl_attr(struct device *device_p){ - - char *err_msg = NULL; - - if (device_create_file(device_p, &dev_attr_platform) < 0) { - err_msg = "dev_attr_platform"; - goto err_reg_modctl_attr; - } - if (device_create_file(device_p, &dev_attr_version) < 0) { - err_msg = "dev_attr_version"; - goto err_reg_modctl_attr; - } - if (device_create_file(device_p, &dev_attr_status) < 0) { - err_msg = "dev_attr_status"; - goto err_reg_modctl_attr; - } - if (device_create_file(device_p, &dev_attr_reset_i2c) < 0) { - err_msg = "dev_attr_reset_i2c"; - goto err_reg_modctl_attr; - } - if (device_create_file(device_p, &dev_attr_reset_swps) < 0) { - err_msg = "dev_attr_reset_swps"; - goto err_reg_modctl_attr; - } - if (device_create_file(device_p, &dev_attr_auto_config) < 0) { - err_msg = "dev_attr_auto_config"; - goto err_reg_modctl_attr; - } - if (device_create_file(device_p, &dev_attr_eeprom_update) < 0) { - err_msg = "dev_attr_eeprom_update"; - goto err_reg_modctl_attr; - } - return 0; - -err_reg_modctl_attr: - SWPS_ERR("%s: %s\n", __func__, err_msg); - return -1; -} - - -static int -register_ioexp_attr(struct device *device_p, - struct transvr_obj_s *transvr_obj){ - - char *err_msg = "ERR"; - - switch (transvr_obj->ioexp_obj_p->ioexp_type){ - case IOEXP_TYPE_MAGINOLIA_NAB: - if (register_ioexp_attr_sfp_1(device_p) < 0){ - err_msg = "register_ioexp_attr_sfp_1 fail"; - goto err_reg_ioexp_attr; - } - break; - case IOEXP_TYPE_CYPRESS_NABC: - if (register_ioexp_attr_sfp_2(device_p) < 0){ - err_msg = "register_ioexp_attr_sfp_2 fail"; - goto err_reg_ioexp_attr; - } - break; - case IOEXP_TYPE_MAGINOLIA_7AB: - case IOEXP_TYPE_SPRUCE_7AB: - case IOEXP_TYPE_CYPRESS_7ABC: - case IOEXP_TYPE_REDWOOD_P01P08: - case IOEXP_TYPE_REDWOOD_P09P16: - case IOEXP_TYPE_HUDSON32IGA_P01P08: - case IOEXP_TYPE_HUDSON32IGA_P09P16: - case IOEXP_TYPE_TAHOE_5A: - case IOEXP_TYPE_TAHOE_6ABC: - case IOEXP_TYPE_SEQUOIA_NABC: - if (register_ioexp_attr_qsfp_1(device_p) < 0){ - err_msg = "register_ioexp_attr_qsfp_1 fail"; - goto err_reg_ioexp_attr; - } - break; - - default: - err_msg = "Unknow type"; - goto err_reg_ioexp_attr; - } - return 0; - -err_reg_ioexp_attr: - SWPS_ERR("%s: %s :%d \n", - __func__, err_msg, transvr_obj->ioexp_obj_p->ioexp_type); - return -1; -} - - -static int -register_modctl_device(void) { - - struct device *device_p = NULL; - int minor_comm = 0; /* Default minor number for common device */ - dev_t dev_num = MKDEV(ctl_major, minor_comm); - char *err_msg = "ERROR"; - - device_p = device_create(swp_class_p, /* struct class *cls */ - NULL, /* struct device *parent */ - dev_num, /* dev_t devt */ - NULL, /* void *private_data */ - SWP_DEV_MODCTL); /* const char *fmt */ - if (IS_ERR(device_p)){ - err_msg = "device_create fail"; - goto err_register_modctl_device_1; - } - if (register_modctl_attr(device_p) < 0) { - err_msg = "register_modctl_attr fail"; - goto err_register_modctl_device_2; - } - return 0; - -err_register_modctl_device_2: - device_unregister(device_p); - device_destroy(swp_class_p, dev_num); -err_register_modctl_device_1: - SWPS_ERR("%s: %s\n", __func__, err_msg); - return -1; -} - - -static int -register_port_device(char *dev_name, - dev_t dev_num, - struct transvr_obj_s *transvr_obj){ - - struct device *device_p = NULL; - device_p = device_create(swp_class_p, /* struct class *cls */ - NULL, /* struct device *parent */ - dev_num, /* dev_t devt */ - transvr_obj, /* void *private_data */ - dev_name); /* const char *fmt */ - if (IS_ERR(device_p)){ - goto err_regswp_create_dev; - } - if (register_transvr_attr(device_p, transvr_obj) < 0){ - goto err_regswp_reg_attr; - } - if (register_ioexp_attr(device_p, transvr_obj) < 0){ - goto err_regswp_reg_attr; - } - return 0; - -err_regswp_reg_attr: - device_unregister(device_p); - device_destroy(swp_class_p, dev_num); -err_regswp_create_dev: - SWPS_ERR("%s fail! :%s\n", __func__, dev_name); - return -1; -} - - -static int -register_swp_module(void){ - - dev_t ctl_devt = 0; - dev_t port_devt = 0; - int dev_total = port_total + 1; /* char_dev for module control */ - - /* Register device number */ - if (alloc_chrdev_region(&ctl_devt, 0, 1, SWP_DEV_MODCTL) < 0){ - SWPS_WARN("Allocate CTL MAJOR failure! \n"); - goto err_register_swp_module_1; - } - if (alloc_chrdev_region(&port_devt, 0, dev_total, SWP_CLS_NAME) < 0){ - SWPS_WARN("Allocate PORT MAJOR failure! \n"); - goto err_register_swp_module_2; - } - ctl_major = MAJOR(ctl_devt); - port_major = MAJOR(port_devt); - - /* Create class object */ - swp_class_p = class_create(THIS_MODULE, SWP_CLS_NAME); - if (IS_ERR(swp_class_p)) { - SWPS_ERR("Create class failure! \n"); - goto err_register_swp_module_3; - } - return 0; - -err_register_swp_module_3: - unregister_chrdev_region(MKDEV(port_major, 0), port_total); -err_register_swp_module_2: - unregister_chrdev_region(MKDEV(ctl_major, 0), 1); -err_register_swp_module_1: - return -1; -} - - -/* ========== Module initial relate ========== - */ -static int -create_ioexp_objs(void) { - - int i, run_mod; - - /* Clean IOEXP object */ - clean_ioexp_objs(); - /* Get running mode */ - run_mod = IOEXP_MODE_DIRECT; - if (SWP_POLLING_ENABLE){ - run_mod = IOEXP_MODE_POLLING; - } - /* Create IOEXP object */ - for(i=0; i devlen_max) { - snprintf(err_msg, sizeof(err_msg), - "SWP_DEV_PORT too long!"); - goto err_initport_create_tranobj; - } - memset(dev_name, 0, sizeof(dev_name)); - snprintf(dev_name, devlen_max, "%s%d", SWP_DEV_PORT, port_id); - /* Create transceiver object */ - ioexp_obj_p = get_ioexp_obj(ioexp_id); - if (!ioexp_obj_p){ - snprintf(err_msg, sizeof(err_msg), - "IOEXP object:%d not exist", ioexp_id); - goto err_initport_create_tranobj; - } - transvr_obj_p = create_transvr_obj(dev_name, chan_id, ioexp_obj_p, - ioexp_virt_offset, transvr_type, - chipset_type, run_mod); - if (!transvr_obj_p){ - snprintf(err_msg, sizeof(err_msg), - "Create transceiver object fail :%s", dev_name); - goto err_initport_create_tranobj; - } - - transvr_obj_p->port_no = minor_curr; - - /* Setup Lane_ID mapping */ - i = ARRAY_SIZE(port_layout[minor_curr].lane_id); - j = ARRAY_SIZE(transvr_obj_p->lane_id); - if (i != j) { - snprintf(err_msg, sizeof(err_msg), - "Lane_id size inconsistent %d/%d", i, j); - goto err_initport_reg_device; - } - memcpy(transvr_obj_p->lane_id, port_layout[minor_curr].lane_id, i*sizeof(int)); - /* Create and register device object */ - if (register_port_device(dev_name, MKDEV(port_major, minor_curr), transvr_obj_p) < 0){ - snprintf(err_msg, sizeof(err_msg), - "register_port_device fail"); - goto err_initport_reg_device; - } - /* Setup device_ptr of transvr_obj */ - dev_p = get_swpdev_by_name(dev_name); - if (!dev_p){ - snprintf(err_msg, sizeof(err_msg), - "get_swpdev_by_name fail"); - goto err_initport_reg_device; - } - transvr_obj_p->transvr_dev_p = dev_p; - /* Success */ - ok_count++; - } - SWPS_INFO("%s: initialed %d port-dev",__func__, ok_count); - return 0; - -err_initport_reg_device: - kfree(transvr_obj_p); -err_initport_create_tranobj: - clean_port_obj(); - SWPS_ERR("%s: %s", __func__, err_msg); - SWPS_ERR("Dump: :%d :%d :%d :%d :%d :%d\n", - port_id, chan_id, ioexp_id, ioexp_virt_offset, transvr_type, run_mod); - return -1; -} - - -static int -init_dev_topology(void){ - - int err; - char *emsg = "ERR"; - flag_mod_state = SWP_STATE_NORMAL; - - err = init_ioexp_objs(); - switch(err){ - case 0: /* Normal */ - SWPS_DEBUG("%s: normal case\n", __func__); - break; - - case -1: /* topology error */ - SWPS_DEBUG("%s: detect tier-1 topology initial failure :%d\n", - __func__, err); - /* Reset and isolate */ - err = reset_i2c_topology(); - if (err < 0) { - emsg = "reset i2c topology fail"; - goto err_init_dev_topology; - } - /* Re-initial again */ - err = init_ioexp_objs(); - if (err < 0) { - emsg = "re-init ioexp objects fail"; - goto err_init_dev_topology; - } - break; - - case -2: /* Internal error */ - SWPS_DEBUG("%s: internal error case\n", __func__); - err = -2; - emsg = "internal error"; - goto err_init_dev_topology; - - default: - SWPS_DEBUG("%s: undefined error case\n", __func__); - emsg = "undefined error case"; - goto err_init_dev_topology; - } - SWPS_DEBUG("%s: initial I2C topology success\n", __func__); - return 0; - -err_init_dev_topology: - SWPS_ERR("%s: %s :%d\n", __func__, emsg, err); - return -1; -} - - -static int -init_polling_task(void){ - - if (SWP_POLLING_ENABLE){ - schedule_delayed_work(&swp_polling, _get_polling_period()); - } - return 0; -} - - -static int -init_swps_common(void){ - - char *err_msg = "ERR"; - - auto_config = 0; - if ((SWP_AUTOCONFIG_ENABLE) && (SWP_POLLING_ENABLE)){ - auto_config = 1; - } - if (register_modctl_device() < 0) { - err_msg = "register_modctl_device fail"; - goto err_init_swps_common_1; - } - if (_update_auto_config_2_trnasvr() < 0) { - err_msg = "_update_auto_config_2_trnasvr fail"; - goto err_init_swps_common_1; - } - if (init_polling_task() < 0){ - err_msg = "init_polling_task fail"; - goto err_init_swps_common_1; - } - return 0; - -err_init_swps_common_1: - clean_swps_common(); - SWPS_ERR("%s: %s\n", __func__, err_msg); - return -1; -} - - -static int __init -swp_module_init(void){ - - if (get_platform_type() < 0){ - goto err_init_out; - } - if (get_layout_info() < 0){ - goto err_init_out; - } - if (register_swp_module() < 0){ - goto err_init_out; - } - if (create_ioexp_objs() < 0){ - goto err_init_ioexp; - } - if (create_port_objs() < 0){ - goto err_init_portobj; - } - if (init_mux_gpio(gpio_rest_mux) < 0){ - goto err_init_mux; - } - if (init_dev_topology() < 0){ - goto err_init_topology; - } - if (init_swps_common() < 0){ - goto err_init_topology; - } - SWPS_INFO("Inventec switch-port module V.%s initial success.\n", SWP_VERSION); - return 0; - - -err_init_topology: - clean_mux_gpio(); -err_init_mux: - clean_port_obj(); -err_init_portobj: - clean_ioexp_objs(); -err_init_ioexp: - class_unregister(swp_class_p); - class_destroy(swp_class_p); - unregister_chrdev_region(MKDEV(ctl_major, 0), 1); - unregister_chrdev_region(MKDEV(port_major, 0), port_total); -err_init_out: - SWPS_ERR("Inventec switch-port module V.%s initial failure.\n", SWP_VERSION); - return -1; -} - - -static void __exit -swp_module_exit(void){ - - clean_swps_common(); - clean_port_obj(); - clean_ioexp_objs(); - clean_mux_gpio(); - class_unregister(swp_class_p); - class_destroy(swp_class_p); - unregister_chrdev_region(MKDEV(ctl_major, 0), 1); - unregister_chrdev_region(MKDEV(port_major, 0), port_total); - SWPS_INFO("Remove Inventec switch-port module success.\n"); -} - - -/* Module information */ -MODULE_AUTHOR(SWP_AUTHOR); -MODULE_DESCRIPTION(SWP_DESC); -MODULE_VERSION(SWP_VERSION); -MODULE_LICENSE(SWP_LICENSE); - -module_init(swp_module_init); -module_exit(swp_module_exit); - - - - - - - diff --git a/packages/platforms/inventec/x86-64/d7264q28b/modules/builds/src/inv_swps.h b/packages/platforms/inventec/x86-64/d7264q28b/modules/builds/src/inv_swps.h deleted file mode 100644 index 5e79e0b40..000000000 --- a/packages/platforms/inventec/x86-64/d7264q28b/modules/builds/src/inv_swps.h +++ /dev/null @@ -1,898 +0,0 @@ -#ifndef INV_SWPS_H -#define INV_SWPS_H - -#include "transceiver.h" -#include "io_expander.h" -#include "inv_mux.h" - -/* Module settings */ -#define SWP_CLS_NAME "swps" -#define SWP_DEV_PORT "port" -#define SWP_DEV_MODCTL "module" -#define SWP_RESET_PWD "inventec" -#define SWP_POLLING_PERIOD (300) /* msec */ -#define SWP_POLLING_ENABLE (1) -#define SWP_AUTOCONFIG_ENABLE (1) - -/* Module information */ -#define SWP_AUTHOR "Neil " -#define SWP_DESC "Inventec port and transceiver driver" -#define SWP_VERSION "4.2.5" -#define SWP_LICENSE "GPL" - -/* Module status define */ -#define SWP_STATE_NORMAL (0) -#define SWP_STATE_I2C_DIE (-91) - -#define INV_BATOI(a) ((a>='0'&&a<='9')?(a-'0'):(-1)) -#define INV_BATOX(a) ((a>='0'&&a<='9')?(a-'0'):((a>='a'&&a<='f')?(a-'a'+10):((a >='A'&&a<='F')?(a-'A'+10):-1))) - -/* [Note]: - * Functions and mechanism for auto-detect platform type is ready, - * But HW and BIOS not ready! We need to wait them. - * So, please do not use PLATFORM_TYPE_AUTO until they are ready. - * (2016.06.13) - */ -#define PLATFORM_TYPE_AUTO (100) -#define PLATFORM_TYPE_MAGNOLIA (111) -#define PLATFORM_TYPE_MAGNOLIA_FNC (112) -#define PLATFORM_TYPE_REDWOOD (121) -#define PLATFORM_TYPE_REDWOOD_FSL (122) -#define PLATFORM_TYPE_HUDSON32I_GA (131) -#define PLATFORM_TYPE_SPRUCE (141) -#define PLATFORM_TYPE_CYPRESS_GA1 (151) /* Up -> Down */ -#define PLATFORM_TYPE_CYPRESS_GA2 (152) /* Down -> Up */ -#define PLATFORM_TYPE_CYPRESS_BAI (153) /* Down -> Up */ -#define PLATFORM_TYPE_TAHOE (161) -#define PLATFORM_TYPE_SEQUOIA_GA (171) -/* Current running platfrom */ -#define PLATFORM_SETTINGS PLATFORM_TYPE_SEQUOIA_GA - -/* Define platform flag and kernel version */ -#if (PLATFORM_SETTINGS == PLATFORM_TYPE_MAGNOLIA) - #define SWPS_MAGNOLIA (1) - #define SWPS_KERN_VER_BF_3_8 (1) -#elif (PLATFORM_SETTINGS == PLATFORM_TYPE_MAGNOLIA_FNC) - #define SWPS_MAGNOLIA (1) - #define SWPS_KERN_VER_AF_3_10 (1) -#elif (PLATFORM_SETTINGS == PLATFORM_TYPE_REDWOOD) - #define SWPS_REDWOOD (1) - #define SWPS_KERN_VER_BF_3_8 (1) -#elif (PLATFORM_SETTINGS == PLATFORM_TYPE_REDWOOD_FSL) - #define SWPS_REDWOOD_FSL (1) - #define SWPS_KERN_VER_BF_3_8 (1) -#elif (PLATFORM_SETTINGS == PLATFORM_TYPE_HUDSON32I_GA) - #define SWPS_HUDSON32I_GA (1) - #define SWPS_KERN_VER_BF_3_8 (1) -#elif (PLATFORM_SETTINGS == PLATFORM_TYPE_SPRUCE) - #define SWPS_SPRUCE (1) - #define SWPS_KERN_VER_BF_3_8 (1) -#elif (PLATFORM_SETTINGS == PLATFORM_TYPE_CYPRESS_GA1) - #define SWPS_CYPRESS_GA1 (1) - #define SWPS_KERN_VER_BF_3_8 (1) -#elif (PLATFORM_SETTINGS == PLATFORM_TYPE_CYPRESS_GA2) - #define SWPS_CYPRESS_GA2 (1) - #define SWPS_KERN_VER_BF_3_8 (1) -#elif (PLATFORM_SETTINGS == PLATFORM_TYPE_CYPRESS_BAI) - #define SWPS_CYPRESS_BAI (1) - #define SWPS_KERN_VER_AF_3_10 (1) -#elif (PLATFORM_SETTINGS == PLATFORM_TYPE_TAHOE) - #define SWPS_TAHOE (1) - #define SWPS_KERN_VER_AF_3_10 (1) -#elif (PLATFORM_SETTINGS == PLATFORM_TYPE_SEQUOIA_GA) - #define SWPS_SEQUOIA (1) - #define SWPS_KERN_VER_BF_3_8 (1) - #define SWPS_KERN_VER_AF_3_10 (1) -#endif - - -struct inv_platform_s { - int id; - char name[64]; -}; - -struct inv_ioexp_layout_s { - int ioexp_id; - int ioexp_type; - struct ioexp_addr_s addr[4]; -}; - -struct inv_port_layout_s { - int port_id; - int chan_id; - int ioexp_id; - int ioexp_offset; - int transvr_type; - int chipset_type; - int lane_id[8]; -}; - - -/* ========================================== - * Inventec Platform Settings - * ========================================== - */ -struct inv_platform_s platform_map[] = { - {PLATFORM_TYPE_AUTO, "Auto-Detect" }, - {PLATFORM_TYPE_MAGNOLIA, "Magnolia" }, - {PLATFORM_TYPE_MAGNOLIA_FNC, "Magnolia_FNC" }, - {PLATFORM_TYPE_REDWOOD, "Redwood" }, - {PLATFORM_TYPE_REDWOOD_FSL, "Redwood_FSL" }, - {PLATFORM_TYPE_HUDSON32I_GA, "Hudson32i" }, - {PLATFORM_TYPE_SPRUCE, "Spruce" }, - {PLATFORM_TYPE_CYPRESS_GA1, "Cypress_GA1" }, - {PLATFORM_TYPE_CYPRESS_GA2, "Cypress_GA2" }, - {PLATFORM_TYPE_CYPRESS_BAI, "Cypress_BAI" }, - {PLATFORM_TYPE_TAHOE, "Tahoe" }, - {PLATFORM_TYPE_SEQUOIA_GA, "Sequoia_GA" }, -}; - - -/* ========================================== - * Magnolia Layout configuration - * ========================================== - */ -#ifdef SWPS_MAGNOLIA -unsigned magnolia_gpio_rest_mux = MUX_RST_GPIO_48_PAC9548; - -struct inv_ioexp_layout_s magnolia_ioexp_layout[] = { - /* IOEXP_ID / IOEXP_TYPE / { Chan_ID, Chip_addr, Read_offset, Write_offset, config_offset, data_default, conf_default } */ - {0, IOEXP_TYPE_MAGINOLIA_NAB, { {2, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {2, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, }, /* addr[1] = I/O Expander N B */ - }, - {1, IOEXP_TYPE_MAGINOLIA_NAB, { {3, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {3, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, }, /* addr[1] = I/O Expander N B */ - }, - {2, IOEXP_TYPE_MAGINOLIA_NAB, { {4, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {4, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, }, /* addr[1] = I/O Expander N B */ - }, - {3, IOEXP_TYPE_MAGINOLIA_4AB, { {5, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander 4 A */ - {5, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xf0, 0xff}, {0xf0, 0xff}, }, }, /* addr[1] = I/O Expander 4 B */ - }, - {4, IOEXP_TYPE_MAGINOLIA_NAB, { {6, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {6, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, }, /* addr[1] = I/O Expander N B */ - }, - {5, IOEXP_TYPE_MAGINOLIA_NAB, { {7, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {7, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, }, /* addr[1] = I/O Expander N B */ - }, - {6, IOEXP_TYPE_MAGINOLIA_7AB, { {8, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[0] = I/O Expander 7 A */ - {8, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xf0, 0x33}, }, }, /* addr[1] = I/O Expander 7 B */ - }, -}; - -struct inv_port_layout_s magnolia_port_layout[] = { - /* Port_ID / Chan_ID / IOEXP_ID / IOEXP_VIRT_OFFSET / TRANSCEIVER_TYPE / BCM_CHIP_TYPE / LANE_ID */ - { 0, 10, 0, 0, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 16} }, - { 1, 11, 0, 1, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 15} }, - { 2, 12, 0, 2, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 14} }, - { 3, 13, 0, 3, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 13} }, - { 4, 14, 0, 4, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 24} }, - { 5, 15, 0, 5, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 23} }, - { 6, 16, 0, 6, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 22} }, - { 7, 17, 0, 7, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 21} }, - { 8, 18, 1, 0, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 28} }, - { 9, 19, 1, 1, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 27} }, - {10, 20, 1, 2, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 26} }, - {11, 21, 1, 3, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 25} }, - {12, 22, 1, 4, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 32} }, - {13, 23, 1, 5, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 31} }, - {14, 24, 1, 6, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 30} }, - {15, 25, 1, 7, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 29} }, - {16, 26, 2, 0, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 48} }, - {17, 27, 2, 1, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 47} }, - {18, 28, 2, 2, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 46} }, - {19, 29, 2, 3, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 45} }, - {20, 30, 2, 4, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 52} }, - {21, 31, 2, 5, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 51} }, - {22, 32, 2, 6, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 50} }, - {23, 33, 2, 7, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 49} }, - {24, 34, 3, 0, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 56} }, - {25, 35, 3, 1, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 55} }, - {26, 36, 3, 2, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 54} }, - {27, 37, 3, 3, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 53} }, - {28, 38, 3, 4, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 60} }, - {29, 39, 3, 5, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 59} }, - {30, 40, 3, 6, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 58} }, - {31, 41, 3, 7, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 57} }, - {32, 42, 4, 0, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 64} }, - {33, 43, 4, 1, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 63} }, - {34, 44, 4, 2, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 62} }, - {35, 45, 4, 3, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 61} }, - {36, 46, 4, 4, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 68} }, - {37, 47, 4, 5, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 67} }, - {38, 48, 4, 6, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 66} }, - {39, 49, 4, 7, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 65} }, - {40, 50, 5, 0, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 72} }, - {41, 51, 5, 1, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 71} }, - {42, 52, 5, 2, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 70} }, - {43, 53, 5, 3, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 69} }, - {44, 54, 5, 4, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 76} }, - {45, 55, 5, 5, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 75} }, - {46, 56, 5, 6, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 74} }, - {47, 57, 5, 7, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TRIDENT_2, { 73} }, - {48, 58, 6, 0, TRANSVR_TYPE_QSFP, BCM_CHIP_TYPE_TRIDENT_2, { 81, 82, 83, 84} }, - {49, 59, 6, 1, TRANSVR_TYPE_QSFP, BCM_CHIP_TYPE_TRIDENT_2, { 77, 78, 79, 80} }, - {50, 60, 6, 2, TRANSVR_TYPE_QSFP, BCM_CHIP_TYPE_TRIDENT_2, { 97, 98, 99,100} }, - {51, 61, 6, 3, TRANSVR_TYPE_QSFP, BCM_CHIP_TYPE_TRIDENT_2, {101,102,103,104} }, - {52, 62, 6, 4, TRANSVR_TYPE_QSFP, BCM_CHIP_TYPE_TRIDENT_2, {105,106,107,108} }, - {53, 63, 6, 5, TRANSVR_TYPE_QSFP, BCM_CHIP_TYPE_TRIDENT_2, {109,110,111,112} }, -}; -#endif - - -/* ========================================== - * Redwood Layout configuration - * ========================================== - */ -#ifdef SWPS_REDWOOD -unsigned redwood_gpio_rest_mux = MUX_RST_GPIO_48_PAC9548; - -struct inv_ioexp_layout_s redwood_ioexp_layout[] = { - /* IOEXP_ID / IOEXP_TYPE / { Chan_ID, Chip_addr, Read_offset, Write_offset, config_offset, data_default, conf_default } */ - {0, IOEXP_TYPE_REDWOOD_P01P08, { {4, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[0] = I/O Expander 1-4 A */ - {4, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[1] = I/O Expander 1-4 B */ - {0, 0x25, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 5 B */ - }, - {1, IOEXP_TYPE_REDWOOD_P09P16, { {5, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[0] = I/O Expander 1-4 A */ - {5, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[1] = I/O Expander 1-4 B */ - {0, 0x25, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 5 B */ - }, - {2, IOEXP_TYPE_REDWOOD_P01P08, { {2, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[0] = I/O Expander 1-4 A */ - {2, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[1] = I/O Expander 1-4 B */ - {0, 0x24, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 5 B */ - }, - {3, IOEXP_TYPE_REDWOOD_P09P16, { {3, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[0] = I/O Expander 1-4 A */ - {3, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[1] = I/O Expander 1-4 B */ - {0, 0x24, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 5 B */ - }, -}; - -struct inv_port_layout_s redwood_port_layout[] = { - /* Port_ID / Chan_ID / IOEXP_ID / IOEXP_VIRT_OFFSET / TRANSCEIVER_TYPE / BCM_CHIP_TYPE / LANE_ID */ - { 0, 22, 0, 0, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 1, 2, 3, 4} }, - { 1, 23, 0, 1, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 5, 6, 7, 8} }, - { 2, 24, 0, 2, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 9, 10, 11, 12} }, - { 3, 25, 0, 3, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 13, 14, 15, 16} }, - { 4, 26, 0, 4, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 17, 18, 19, 20} }, - { 5, 27, 0, 5, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 21, 22, 23, 24} }, - { 6, 28, 0, 6, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 25, 26, 27, 28} }, - { 7, 29, 0, 7, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 29, 30, 31, 32} }, - { 8, 30, 1, 0, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 33, 34, 35, 36} }, - { 9, 31, 1, 1, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 37, 38, 39, 40} }, - {10, 32, 1, 2, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 41, 42, 43, 44} }, - {11, 33, 1, 3, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 45, 46, 47, 48} }, - {12, 34, 1, 4, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 49, 50, 51, 52} }, - {13, 35, 1, 5, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 53, 54, 55, 56} }, - {14, 36, 1, 6, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 57, 58, 59, 60} }, - {15, 37, 1, 7, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 61, 62, 63, 64} }, - {16, 6, 2, 0, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 65, 66, 67, 68} }, - {17, 7, 2, 1, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 69, 70, 71, 72} }, - {18, 8, 2, 2, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 73, 74, 75, 76} }, - {19, 9, 2, 3, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 77, 78, 79, 80} }, - {20, 10, 2, 4, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 81, 82, 83, 84} }, - {21, 11, 2, 5, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 85, 86, 87, 88} }, - {22, 12, 2, 6, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 89, 90, 91, 92} }, - {23, 13, 2, 7, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 93, 94, 95, 96} }, - {24, 14, 3, 0, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 97, 98, 99,100} }, - {25, 15, 3, 1, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {101,102,103,104} }, - {26, 16, 3, 2, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {105,106,107,108} }, - {27, 17, 3, 3, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {109,110,111,112} }, - {28, 18, 3, 4, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {113,114,115,116} }, - {29, 19, 3, 5, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {117,118,119,120} }, - {30, 20, 3, 6, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {121,122,123,124} }, - {31, 21, 3, 7, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {125,126,127,128} }, -}; -#endif - - -/* ========================================== - * Hudson32i Layout configuration - * ========================================== - */ -#ifdef SWPS_HUDSON32I_GA -unsigned hudsin32iga_gpio_rest_mux = MUX_RST_GPIO_48_PAC9548; - -struct inv_ioexp_layout_s hudson32iga_ioexp_layout[] = { - /* IOEXP_ID / IOEXP_TYPE / { Chan_ID, Chip_addr, Read_offset, Write_offset, config_offset, data_default, conf_default } */ - {0, IOEXP_TYPE_HUDSON32IGA_P01P08, { {2, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[0] = I/O Expander A */ - {2, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[1] = I/O Expander B */ - {0, 0x24, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 0x24 */ - }, - {1, IOEXP_TYPE_HUDSON32IGA_P09P16, { {3, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[0] = I/O Expander A */ - {3, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[1] = I/O Expander B */ - {0, 0x24, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 0x24 */ - }, - {2, IOEXP_TYPE_HUDSON32IGA_P01P08, { {4, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[0] = I/O Expander A */ - {4, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[1] = I/O Expander B */ - {0, 0x25, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 0x25 */ - }, - {3, IOEXP_TYPE_HUDSON32IGA_P09P16, { {5, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[0] = I/O Expander A */ - {5, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[1] = I/O Expander B */ - {0, 0x25, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 0x25 */ - }, -}; - -struct inv_port_layout_s hudson32iga_port_layout[] = { - /* Port_ID / Chan_ID / IOEXP_ID / IOEXP_VIRT_OFFSET / TRANSCEIVER_TYPE / BCM_CHIP_TYPE / LANE_ID */ - { 0, 6, 0, 0, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, { 1, 2, 3, 4} }, - { 1, 7, 0, 1, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, { 5, 6, 7, 8} }, - { 2, 8, 0, 2, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, { 9, 10, 11, 12} }, - { 3, 9, 0, 3, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, { 13, 14, 15, 16} }, - { 4, 10, 0, 4, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, { 17, 18, 19, 20} }, - { 5, 11, 0, 5, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, { 21, 22, 23, 24} }, - { 6, 12, 0, 6, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, { 25, 26, 27, 28} }, - { 7, 13, 0, 7, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, { 29, 30, 31, 32} }, - { 8, 14, 1, 0, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, { 33, 34, 35, 36} }, - { 9, 15, 1, 1, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, { 37, 38, 39, 40} }, - {10, 16, 1, 2, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, { 41, 42, 43, 44} }, - {11, 17, 1, 3, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, { 45, 46, 47, 48} }, - {12, 18, 1, 4, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, { 49, 50, 51, 52} }, - {13, 19, 1, 5, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, { 53, 54, 55, 56} }, - {14, 20, 1, 6, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, { 57, 58, 59, 60} }, - {15, 21, 1, 7, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, { 61, 62, 63, 64} }, - {16, 22, 2, 0, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, { 65, 66, 67, 68} }, - {17, 23, 2, 1, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, { 69, 70, 71, 72} }, - {18, 24, 2, 2, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, { 73, 74, 75, 76} }, - {19, 25, 2, 3, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, { 77, 78, 79, 80} }, - {20, 26, 2, 4, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, { 81, 82, 83, 84} }, - {21, 27, 2, 5, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, { 85, 86, 87, 88} }, - {22, 28, 2, 6, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, { 89, 90, 91, 92} }, - {23, 29, 2, 7, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, { 93, 94, 95, 96} }, - {24, 30, 3, 0, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, { 97, 98, 99,100} }, - {25, 31, 3, 1, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, {101,102,103,104} }, - {26, 32, 3, 2, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, {105,106,107,108} }, - {27, 33, 3, 3, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, {109,110,111,112} }, - {28, 34, 3, 4, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, {113,114,115,116} }, - {29, 35, 3, 5, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, {117,118,119,120} }, - {30, 36, 3, 6, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, {121,122,123,124} }, - {31, 37, 3, 7, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, {125,126,127,128} }, -}; -#endif - - -/* ========================================== - * Spruce Layout configuration - * ========================================== - */ -#ifdef SWPS_SPRUCE -unsigned spruce_gpio_rest_mux = MUX_RST_GPIO_48_PAC9548; - -struct inv_ioexp_layout_s spruce_ioexp_layout[] = { - /* IOEXP_ID / IOEXP_TYPE / { Chan_ID, Chip_addr, Read_offset, Write_offset, config_offset, data_default, conf_default } */ - {0, IOEXP_TYPE_SPRUCE_7AB, { {2, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[0] = I/O Expander 7A */ - {2, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xf0, 0x33}, }, }, /* addr[2] = I/O Expander 7B */ - }, -}; - -struct inv_port_layout_s spruce_port_layout[] = { - /* Port_ID / Chan_ID / IOEXP_ID / IOEXP_VIRT_OFFSET / TRANSCEIVER_TYPE / BCM_CHIP_TYPE / LANE_ID */ - { 0, 6, 0, 0, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, { 81, 82, 83, 84} }, - { 1, 7, 0, 1, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, { 77, 78, 79, 80} }, - { 2, 8, 0, 2, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, { 97, 98, 99,100} }, - { 3, 9, 0, 3, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, {101,102,103,104} }, - { 4, 10, 0, 4, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, {105,106,107,108} }, - { 5, 11, 0, 5, TRANSVR_TYPE_QSFP_PLUS, BCM_CHIP_TYPE_TRIDENT_2, {109,110,111,112} }, -}; -#endif - - -/* ========================================== - * Cypress Layout configuration (Inventec version [Up->Down]) - * ========================================== - */ -#ifdef SWPS_CYPRESS_GA1 -unsigned cypress_ga1_gpio_rest_mux = MUX_RST_GPIO_69_PAC9548; - -struct inv_ioexp_layout_s cypress_ga1_ioexp_layout[] = { - /* IOEXP_ID / IOEXP_TYPE / { Chan_ID, Chip_addr, Read_offset, Write_offset, config_offset, data_default, conf_default } */ - {0, IOEXP_TYPE_CYPRESS_NABC, { {2, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {2, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {2, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {1, IOEXP_TYPE_CYPRESS_NABC, { {3, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {3, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {3, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {2, IOEXP_TYPE_CYPRESS_NABC, { {4, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {4, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {4, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {3, IOEXP_TYPE_CYPRESS_NABC, { {5, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {5, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {5, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {4, IOEXP_TYPE_CYPRESS_NABC, { {6, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {6, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {6, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {5, IOEXP_TYPE_CYPRESS_NABC, { {7, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {7, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {7, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {6, IOEXP_TYPE_CYPRESS_7ABC, { {8, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xc0, 0xc0}, }, /* addr[0] = I/O Expander 7 A */ - {8, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xc0, 0xc0}, {0xff, 0xc0}, }, /* addr[1] = I/O Expander 7 B */ - {8, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 7 C */ - }, -}; - -struct inv_port_layout_s cypress_ga1_port_layout[] = { - /* Port_ID / Chan_ID / IOEXP_ID / IOEXP_VIRT_OFFSET / TRANSCEIVER_TYPE / BCM_CHIP_TYPE / LANE_ID */ - { 0, 10, 0, 0, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 1} }, - { 1, 11, 0, 1, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 2} }, - { 2, 12, 0, 2, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 3} }, - { 3, 13, 0, 3, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 4} }, - { 4, 14, 0, 4, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 5} }, - { 5, 15, 0, 5, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 6} }, - { 6, 16, 0, 6, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 7} }, - { 7, 17, 0, 7, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 8} }, - { 8, 18, 1, 0, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 9} }, - { 9, 19, 1, 1, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 10} }, - {10, 20, 1, 2, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 11} }, - {11, 21, 1, 3, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 12} }, - {12, 22, 1, 4, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 21} }, - {13, 23, 1, 5, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 22} }, - {14, 24, 1, 6, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 23} }, - {15, 25, 1, 7, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 24} }, - {16, 26, 2, 0, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 33} }, - {17, 27, 2, 1, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 34} }, - {18, 28, 2, 2, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 35} }, - {19, 29, 2, 3, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 36} }, - {20, 30, 2, 4, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 37} }, - {21, 31, 2, 5, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 38} }, - {22, 32, 2, 6, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 39} }, - {23, 33, 2, 7, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 40} }, - {24, 34, 3, 0, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 41} }, - {25, 35, 3, 1, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 42} }, - {26, 36, 3, 2, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 43} }, - {27, 37, 3, 3, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 44} }, - {28, 38, 3, 4, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 49} }, - {29, 39, 3, 5, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 50} }, - {30, 40, 3, 6, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 51} }, - {31, 41, 3, 7, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 52} }, - {32, 42, 4, 0, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 53} }, - {33, 43, 4, 1, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 54} }, - {34, 44, 4, 2, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 55} }, - {35, 45, 4, 3, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 56} }, - {36, 46, 4, 4, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 65} }, - {37, 47, 4, 5, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 66} }, - {38, 48, 4, 6, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 67} }, - {39, 49, 4, 7, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 68} }, - {40, 50, 5, 0, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 69} }, - {41, 51, 5, 1, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 70} }, - {42, 52, 5, 2, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 71} }, - {43, 53, 5, 3, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 72} }, - {44, 54, 5, 4, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 81} }, - {45, 55, 5, 5, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 82} }, - {46, 56, 5, 6, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 83} }, - {47, 57, 5, 7, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 84} }, - {48, 58, 6, 0, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 97, 98, 99,100} }, - {49, 59, 6, 1, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 85, 86, 87, 88} }, - {50, 60, 6, 2, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {101,102,103,104} }, - {51, 61, 6, 3, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {105,106,107,108} }, - {52, 62, 6, 4, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {109,110,111,112} }, - {53, 63, 6, 5, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {117,118,119,120} }, -}; -#endif - - -/* ========================================== - * Cypress Layout configuration (Inventec version [Down->Up]) - * ========================================== - */ -#ifdef SWPS_CYPRESS_GA2 -unsigned cypress_ga2_gpio_rest_mux = MUX_RST_GPIO_FORCE_HEDERA; - -struct inv_ioexp_layout_s cypress_ga2_ioexp_layout[] = { - /* IOEXP_ID / IOEXP_TYPE / { Chan_ID, Chip_addr, Read_offset, Write_offset, config_offset, data_default, conf_default } */ - {0, IOEXP_TYPE_CYPRESS_NABC, { {2, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {2, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {2, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {1, IOEXP_TYPE_CYPRESS_NABC, { {3, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {3, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {3, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {2, IOEXP_TYPE_CYPRESS_NABC, { {4, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {4, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {4, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {3, IOEXP_TYPE_CYPRESS_NABC, { {5, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {5, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {5, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {4, IOEXP_TYPE_CYPRESS_NABC, { {6, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {6, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {6, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {5, IOEXP_TYPE_CYPRESS_NABC, { {7, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {7, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {7, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {6, IOEXP_TYPE_CYPRESS_7ABC, { {8, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xc0, 0xc0}, }, /* addr[0] = I/O Expander 7 A */ - {8, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xc0, 0xc0}, {0xff, 0xc0}, }, /* addr[1] = I/O Expander 7 B */ - {8, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 7 C */ - }, -}; - -struct inv_port_layout_s cypress_ga2_port_layout[] = { - /* Port_ID / Chan_ID / IOEXP_ID / IOEXP_VIRT_OFFSET / TRANSCEIVER_TYPE / BCM_CHIP_TYPE / LANE_ID */ - { 0, 11, 0, 1, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 2} }, - { 1, 10, 0, 0, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 1} }, - { 2, 13, 0, 3, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 4} }, - { 3, 12, 0, 2, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 3} }, - { 4, 15, 0, 5, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 6} }, - { 5, 14, 0, 4, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 5} }, - { 6, 17, 0, 7, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 8} }, - { 7, 16, 0, 6, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 7} }, - { 8, 19, 1, 1, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 10} }, - { 9, 18, 1, 0, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 9} }, - {10, 21, 1, 3, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 12} }, - {11, 20, 1, 2, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 11} }, - {12, 23, 1, 5, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 22} }, - {13, 22, 1, 4, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 21} }, - {14, 25, 1, 7, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 24} }, - {15, 24, 1, 6, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 23} }, - {16, 27, 2, 1, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 34} }, - {17, 26, 2, 0, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 33} }, - {18, 29, 2, 3, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 36} }, - {19, 28, 2, 2, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 35} }, - {20, 31, 2, 5, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 38} }, - {21, 30, 2, 4, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 37} }, - {22, 33, 2, 7, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 40} }, - {23, 32, 2, 6, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 39} }, - {24, 35, 3, 1, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 42} }, - {25, 34, 3, 0, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 41} }, - {26, 37, 3, 3, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 44} }, - {27, 36, 3, 2, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 43} }, - {28, 39, 3, 5, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 50} }, - {29, 38, 3, 4, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 49} }, - {30, 41, 3, 7, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 52} }, - {31, 40, 3, 6, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 51} }, - {32, 43, 4, 1, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 54} }, - {33, 42, 4, 0, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 53} }, - {34, 45, 4, 3, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 56} }, - {35, 44, 4, 2, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 55} }, - {36, 47, 4, 5, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 66} }, - {37, 46, 4, 4, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 65} }, - {38, 49, 4, 7, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 68} }, - {39, 48, 4, 6, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 67} }, - {40, 51, 5, 1, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 70} }, - {41, 50, 5, 0, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 69} }, - {42, 53, 5, 3, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 72} }, - {43, 52, 5, 2, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 71} }, - {44, 55, 5, 5, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 82} }, - {45, 54, 5, 4, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 81} }, - {46, 57, 5, 7, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 84} }, - {47, 56, 5, 6, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 83} }, - {48, 59, 6, 1, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 85, 86, 87, 88} }, - {49, 58, 6, 0, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 97, 98, 99,100} }, - {50, 61, 6, 3, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {105,106,107,108} }, - {51, 60, 6, 2, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {101,102,103,104} }, - {52, 63, 6, 5, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {117,118,119,120} }, - {53, 62, 6, 4, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {109,110,111,112} }, -}; -#endif - - -/* ========================================== - * Cypress Layout configuration (BaiDu version) - * ========================================== - */ -#ifdef SWPS_CYPRESS_BAI -unsigned cypress_b_gpio_rest_mux = MUX_RST_GPIO_FORCE_HEDERA; - -struct inv_ioexp_layout_s cypress_b_ioexp_layout[] = { - /* IOEXP_ID / IOEXP_TYPE / { Chan_ID, Chip_addr, Read_offset, Write_offset, config_offset, data_default, conf_default } */ - {0, IOEXP_TYPE_CYPRESS_NABC, { {2, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {2, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {2, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {1, IOEXP_TYPE_CYPRESS_NABC, { {3, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {3, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {3, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {2, IOEXP_TYPE_CYPRESS_NABC, { {4, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {4, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {4, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {3, IOEXP_TYPE_CYPRESS_NABC, { {5, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {5, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {5, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {4, IOEXP_TYPE_CYPRESS_NABC, { {6, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {6, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {6, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {5, IOEXP_TYPE_CYPRESS_NABC, { {7, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[0] = I/O Expander N A */ - {7, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xf0}, {0xff, 0xf0}, }, /* addr[1] = I/O Expander N B */ - {7, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0x00, 0x00}, }, }, /* addr[2] = I/O Expander N C */ - }, - {6, IOEXP_TYPE_CYPRESS_7ABC, { {8, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xc0, 0xc0}, }, /* addr[0] = I/O Expander 7 A */ - {8, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xc0, 0xc0}, {0xff, 0xc0}, }, /* addr[1] = I/O Expander 7 B */ - {8, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 7 C */ - }, -}; - -struct inv_port_layout_s cypress_b_port_layout[] = { - /* Port_ID / Chan_ID / IOEXP_ID / IOEXP_VIRT_OFFSET / TRANSCEIVER_TYPE / BCM_CHIP_TYPE / LANE_ID */ - { 1, 11, 0, 1, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 2} }, - { 2, 10, 0, 0, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 1} }, - { 3, 13, 0, 3, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 4} }, - { 4, 12, 0, 2, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 3} }, - { 5, 15, 0, 5, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 6} }, - { 6, 14, 0, 4, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 5} }, - { 7, 17, 0, 7, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 8} }, - { 8, 16, 0, 6, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 7} }, - { 9, 19, 1, 1, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 10} }, - {10, 18, 1, 0, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 9} }, - {11, 21, 1, 3, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 12} }, - {12, 20, 1, 2, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 11} }, - {13, 23, 1, 5, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 22} }, - {14, 22, 1, 4, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 21} }, - {15, 25, 1, 7, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 24} }, - {16, 24, 1, 6, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 23} }, - {17, 27, 2, 1, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 34} }, - {18, 26, 2, 0, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 33} }, - {19, 29, 2, 3, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 36} }, - {20, 28, 2, 2, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 35} }, - {21, 31, 2, 5, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 38} }, - {22, 30, 2, 4, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 37} }, - {23, 33, 2, 7, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 40} }, - {24, 32, 2, 6, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 39} }, - {25, 35, 3, 1, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 42} }, - {26, 34, 3, 0, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 41} }, - {27, 37, 3, 3, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 44} }, - {28, 36, 3, 2, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 43} }, - {29, 39, 3, 5, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 50} }, - {30, 38, 3, 4, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 49} }, - {31, 41, 3, 7, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 52} }, - {32, 40, 3, 6, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 51} }, - {33, 43, 4, 1, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 54} }, - {34, 42, 4, 0, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 53} }, - {35, 45, 4, 3, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 56} }, - {36, 44, 4, 2, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 55} }, - {37, 47, 4, 5, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 66} }, - {38, 46, 4, 4, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 65} }, - {39, 49, 4, 7, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 68} }, - {40, 48, 4, 6, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 67} }, - {41, 51, 5, 1, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 70} }, - {42, 50, 5, 0, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 69} }, - {43, 53, 5, 3, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 72} }, - {44, 52, 5, 2, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 71} }, - {45, 55, 5, 5, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 82} }, - {46, 54, 5, 4, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 81} }, - {47, 57, 5, 7, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 84} }, - {48, 56, 5, 6, TRANSVR_TYPE_SFP, BCM_CHIP_TYPE_TOMAHAWK, { 83} }, - {49, 59, 6, 1, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 85, 86, 87, 88} }, - {50, 58, 6, 0, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 97, 98, 99,100} }, - {51, 61, 6, 3, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {105,106,107,108} }, - {52, 60, 6, 2, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {101,102,103,104} }, - {53, 63, 6, 5, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {117,118,119,120} }, - {54, 62, 6, 4, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {109,110,111,112} }, -}; -#endif - - -/* ========================================== - * Redwood_fsl Layout configuration - * ========================================== - */ -#ifdef SWPS_REDWOOD_FSL -unsigned redwood_fsl_gpio_rest_mux = MUX_RST_GPIO_48_PAC9548; - -struct inv_ioexp_layout_s redwood_fsl_ioexp_layout[] = { - /* IOEXP_ID / IOEXP_TYPE / { Chan_ID, Chip_addr, Read_offset, Write_offset, config_offset, data_default, conf_default } */ - {0, IOEXP_TYPE_REDWOOD_P01P08, { {4, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[0] = I/O Expander 1-4 A */ - {4, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[1] = I/O Expander 1-4 B */ - {0, 0x25, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 5 B */ - }, - {1, IOEXP_TYPE_REDWOOD_P09P16, { {5, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[0] = I/O Expander 1-4 A */ - {5, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[1] = I/O Expander 1-4 B */ - {0, 0x25, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 5 B */ - }, - {2, IOEXP_TYPE_REDWOOD_P01P08, { {2, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[0] = I/O Expander 1-4 A */ - {2, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[1] = I/O Expander 1-4 B */ - {0, 0x24, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 5 B */ - }, - {3, IOEXP_TYPE_REDWOOD_P09P16, { {3, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[0] = I/O Expander 1-4 A */ - {3, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0x0f}, }, /* addr[1] = I/O Expander 1-4 B */ - {0, 0x24, {0, 1}, {2, 3}, {6, 7}, {0xff, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 5 B */ - }, -}; - - -struct inv_port_layout_s redwood_fsl_port_layout[] = { - /* Port_ID / Chan_ID / IOEXP_ID / IOEXP_VIRT_OFFSET / TRANSCEIVER_TYPE / BCM_CHIP_TYPE / LANE_ID */ - { 0, 22, 0, 0, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 1, 2, 3, 4} }, - { 1, 23, 0, 1, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 5, 6, 7, 8} }, - { 2, 24, 0, 2, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 9, 10, 11, 12} }, - { 3, 25, 0, 3, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 13, 14, 15, 16} }, - { 4, 26, 0, 4, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 17, 18, 19, 20} }, - { 5, 27, 0, 5, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 21, 22, 23, 24} }, - { 6, 28, 0, 6, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 25, 26, 27, 28} }, - { 7, 29, 0, 7, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 29, 30, 31, 32} }, - { 8, 30, 1, 0, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 33, 34, 35, 36} }, - { 9, 31, 1, 1, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 37, 38, 39, 40} }, - {10, 32, 1, 2, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 41, 42, 43, 44} }, - {11, 33, 1, 3, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 45, 46, 47, 48} }, - {12, 34, 1, 4, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 49, 50, 51, 52} }, - {13, 35, 1, 5, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 53, 54, 55, 56} }, - {14, 36, 1, 6, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 57, 58, 59, 60} }, - {15, 37, 1, 7, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 61, 62, 63, 64} }, - {16, 6, 2, 0, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 65, 66, 67, 68} }, - {17, 7, 2, 1, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 69, 70, 71, 72} }, - {18, 8, 2, 2, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 73, 74, 75, 76} }, - {19, 9, 2, 3, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 77, 78, 79, 80} }, - {20, 10, 2, 4, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 81, 82, 83, 84} }, - {21, 11, 2, 5, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 85, 86, 87, 88} }, - {22, 12, 2, 6, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 89, 90, 91, 92} }, - {23, 13, 2, 7, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 93, 94, 95, 96} }, - {24, 14, 3, 0, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 97, 98, 99,100} }, - {25, 15, 3, 1, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {101,102,103,104} }, - {26, 16, 3, 2, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {105,106,107,108} }, - {27, 17, 3, 3, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {109,110,111,112} }, - {28, 18, 3, 4, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {113,114,115,116} }, - {29, 19, 3, 5, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {117,118,119,120} }, - {30, 20, 3, 6, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {121,122,123,124} }, - {31, 21, 3, 7, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {125,126,127,128} }, -}; -#endif - - -/* ========================================== - * Tahoe Layout configuration - * ========================================== - */ -#ifdef SWPS_TAHOE -unsigned tahoe_gpio_rest_mux = MUX_RST_GPIO_249_PCA9548; - -struct inv_ioexp_layout_s tahoe_ioexp_layout[] = { - /* IOEXP_ID / IOEXP_TYPE / { Chan_ID, Chip_addr, Read_offset, Write_offset, config_offset, data_default, conf_default } */ - {0, IOEXP_TYPE_TAHOE_6ABC, { {7, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xce, 0xb9}, {0x18, 0xe3}, }, /* addr[0] = I/O Expander 6 A */ - {7, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xce, 0xb9}, {0x18, 0xe3}, }, /* addr[1] = I/O Expander 6 B */ - {7, 0x22, {0, 1}, {2, 3}, {6, 7}, {0xce, 0xb9}, {0x18, 0xe3}, }, }, /* addr[2] = I/O Expander 6 C */ - }, - {1, IOEXP_TYPE_TAHOE_5A, { {6, 0x20, {0, 1}, {2, 3}, {6, 7}, {0xce, 0xb9}, {0x18, 0xe3}, }, }, /* addr[0] = I/O Expander 5 A */ - }, -}; - - -struct inv_port_layout_s tahoe_port_layout[] = { - /* Port_ID / Chan_ID / IOEXP_ID / IOEXP_VIRT_OFFSET / TRANSCEIVER_TYPE / BCM_CHIP_TYPE / LANE_ID */ - { 0, 12, 1, 2, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 65, 66, 67, 68} }, - { 1, 11, 1, 1, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 53, 54, 55, 56} }, - { 2, 22, 0, 5, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 69, 70, 71, 72} }, - { 3, 21, 0, 4, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 81, 82, 83, 84} }, - { 4, 24, 0, 7, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 97, 98, 99, 100} }, - { 5, 23, 0, 6, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 85, 86, 87, 88} }, - { 6, 18, 0, 1, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {101, 102, 103, 104} }, - { 7, 17, 0, 0, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {105, 106, 107, 108} }, - { 8, 20, 0, 3, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {113, 114, 115, 116} }, - { 9, 19, 0, 2, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {109, 110, 111, 112} }, -}; -#endif - - -/* ========================================== - * Sequoia Layout configuration - * ========================================== - */ -#ifdef SWPS_SEQUOIA -unsigned sequoia_gpio_rest_mux = MUX_RST_GPIO_FORCE_HEDERA; - -struct inv_ioexp_layout_s secquoia_ioexp_layout[] = { - /* IOEXP_ID / IOEXP_TYPE / { Chan_ID, Chip_addr, Read_offset, Write_offset, config_offset, data_default, conf_default } */ - {0, IOEXP_TYPE_SEQUOIA_NABC, { {2, 0x20, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0x00, 0x00}, }, /* addr[0] = I/O Expander 0 A */ - {2, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0xff}, }, /* addr[1] = I/O Expander 0 B */ - {2, 0x22, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 0 C */ - }, - {1, IOEXP_TYPE_SEQUOIA_NABC, { {3, 0x20, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0x00, 0x00}, }, /* addr[0] = I/O Expander 1 A */ - {3, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0xff}, }, /* addr[1] = I/O Expander 1 B */ - {3, 0x22, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 1 C */ - }, - {2, IOEXP_TYPE_SEQUOIA_NABC, { {4, 0x20, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0x00, 0x00}, }, /* addr[0] = I/O Expander 2 A */ - {4, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0xff}, }, /* addr[1] = I/O Expander 2 B */ - {4, 0x22, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 2 C */ - }, - {3, IOEXP_TYPE_SEQUOIA_NABC, { {5, 0x20, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0x00, 0x00}, }, /* addr[0] = I/O Expander 3 A */ - {5, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0xff}, }, /* addr[1] = I/O Expander 3 B */ - {5, 0x22, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 3 C */ - }, - {4, IOEXP_TYPE_SEQUOIA_NABC, { {6, 0x20, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0x00, 0x00}, }, /* addr[0] = I/O Expander 4 A */ - {6, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0xff}, }, /* addr[1] = I/O Expander 4 B */ - {6, 0x22, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 4 C */ - }, - {5, IOEXP_TYPE_SEQUOIA_NABC, { {7, 0x20, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0x00, 0x00}, }, /* addr[0] = I/O Expander 5 A */ - {7, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0xff}, }, /* addr[1] = I/O Expander 5 B */ - {7, 0x22, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 5 C */ - }, - {6, IOEXP_TYPE_SEQUOIA_NABC, { {8, 0x20, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0x00, 0x00}, }, /* addr[0] = I/O Expander 6 A */ - {8, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0xff}, }, /* addr[1] = I/O Expander 6 B */ - {8, 0x22, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 6 C */ - }, - {7, IOEXP_TYPE_SEQUOIA_NABC, { {9, 0x20, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0x00, 0x00}, }, /* addr[0] = I/O Expander 7 A */ - {9, 0x21, {0, 1}, {2, 3}, {6, 7}, {0xff, 0x00}, {0x00, 0xff}, }, /* addr[1] = I/O Expander 7 B */ - {9, 0x22, {0, 1}, {2, 3}, {6, 7}, {0x00, 0xff}, {0xff, 0xff}, }, }, /* addr[2] = I/O Expander 7 C */ - }, -}; - - -struct inv_port_layout_s secquoia_port_layout[] = { - /* Port_ID / Chan_ID / IOEXP_ID / IOEXP_VIRT_OFFSET / TRANSCEIVER_TYPE / BCM_CHIP_TYPE / LANE_ID */ - { 0, 10, 0, 0, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 9, 10, 11, 12} }, - { 1, 11, 0, 1, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 1, 2, 3, 4} }, - { 2, 12, 0, 2, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 25, 26, 27, 28} }, - { 3, 13, 0, 3, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 17, 18, 19, 20} }, - { 4, 14, 0, 4, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 41, 42, 43, 44} }, - { 5, 15, 0, 5, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 33, 34, 35, 36} }, - { 6, 16, 0, 6, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 57, 58, 59, 60} }, - { 7, 17, 0, 7, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 49, 50, 51, 52} }, - { 8, 18, 1, 0, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 73, 74, 75, 76} }, - { 9, 19, 1, 1, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 65, 66, 67, 68} }, - {10, 20, 1, 2, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 89, 90, 91, 92} }, - {11, 21, 1, 3, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 81, 82, 83, 84} }, - {12, 22, 1, 4, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {105, 106, 107, 108} }, - {13, 23, 1, 5, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 97, 98, 99, 100} }, - {14, 24, 1, 6, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {121, 122, 123, 124} }, - {15, 25, 1, 7, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {113, 114, 115, 116} }, - {16, 26, 2, 0, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {137, 138, 139, 140} }, - {17, 27, 2, 1, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {129, 130, 131, 132} }, - {18, 28, 2, 2, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {153, 154, 155, 156} }, - {19, 29, 2, 3, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {145, 146, 147, 148} }, - {20, 30, 2, 4, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {169, 170, 171, 172} }, - {21, 31, 2, 5, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {161, 162, 163, 164} }, - {22, 32, 2, 6, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {185, 186, 187, 188} }, - {23, 33, 2, 7, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {177, 178, 179, 180} }, - {24, 34, 3, 0, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {201, 202, 203, 204} }, - {25, 35, 3, 1, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {193, 194, 195, 196} }, - {26, 36, 3, 2, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {217, 218, 219, 220} }, - {27, 37, 3, 3, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {209, 210, 211, 212} }, - {28, 38, 3, 4, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {233, 234, 235, 236} }, - {29, 39, 3, 5, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {225, 226, 227, 228} }, - {30, 40, 3, 6, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {249, 250, 251, 252} }, - {31, 41, 3, 7, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {241, 242, 243, 244} }, - {32, 45, 4, 3, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 13, 14, 15, 16} }, - {33, 44, 4, 2, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 5, 6, 7, 8} }, - {34, 43, 4, 1, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 29, 30, 31, 32} }, - {35, 42, 4, 0, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 21, 22, 23, 24} }, - {36, 49, 4, 7, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 45, 46, 47, 48} }, - {37, 48, 4, 6, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 37, 38, 39, 40} }, - {38, 47, 4, 5, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 61, 62, 63, 64} }, - {39, 46, 4, 4, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 53, 54, 55, 56} }, - {40, 53, 5, 3, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 77, 78, 79, 80} }, - {41, 52, 5, 2, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 69, 70, 71, 72} }, - {42, 51, 5, 1, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 93, 94, 95, 96} }, - {43, 50, 5, 0, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, { 85, 86, 87, 88} }, - {44, 57, 5, 7, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {109, 110, 111, 112} }, - {45, 56, 5, 6, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {101, 102, 103, 104} }, - {46, 55, 5, 5, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {125, 126, 127, 128} }, - {47, 54, 5, 4, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {117, 118, 119, 120} }, - {48, 61, 6, 3, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {141, 142, 143, 144} }, - {49, 60, 6, 2, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {133, 134, 135, 136} }, - {50, 59, 6, 1, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {157, 158, 159, 160} }, - {51, 58, 6, 0, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {149, 150, 151, 152} }, - {52, 65, 6, 7, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {173, 174, 175, 176} }, - {53, 64, 6, 6, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {165, 166, 167, 168} }, - {54, 63, 6, 5, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {189, 190, 191, 192} }, - {55, 62, 6, 4, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {181, 182, 183, 184} }, - {56, 69, 7, 3, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {205, 206, 207, 208} }, - {57, 68, 7, 2, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {197, 198, 199, 200} }, - {58, 67, 7, 1, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {221, 222, 223, 224} }, - {59, 66, 7, 0, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {213, 214, 215, 216} }, - {60, 73, 7, 7, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {237, 238, 239, 240} }, - {61, 72, 7, 6, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {229, 230, 231, 232} }, - {62, 71, 7, 5, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {253, 254, 255, 256} }, - {63, 70, 7, 4, TRANSVR_TYPE_QSFP_28, BCM_CHIP_TYPE_TOMAHAWK, {245, 246, 247, 248} }, -}; -#endif - - -#endif /* INV_SWPS_H */ - - - - - - - - diff --git a/packages/platforms/inventec/x86-64/d7264q28b/modules/builds/src/inv_vpd.c b/packages/platforms/inventec/x86-64/d7264q28b/modules/builds/src/inv_vpd.c deleted file mode 100644 index 2075fd4ee..000000000 --- a/packages/platforms/inventec/x86-64/d7264q28b/modules/builds/src/inv_vpd.c +++ /dev/null @@ -1,332 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "inv_vpd.h" -#include "onie_tlvinfo.h" - -static int vpd_major; -static struct class *vpd_class_p = NULL; -static char cEeprom[SYS_EEPROM_MAX_SIZE]; -static DEFINE_MUTEX(vpd_mutex); - -static int -__swp_match(struct device *dev, const void *data){ - - char *name = (char *)data; - if (strcmp(dev_name(dev), name) == 0) - return 1; - return 0; -} - -static -int get_vpd_data(struct i2c_client *pi2c_client, int i_offset, char *c_buf) -{ - int iRet; - - read_eeprom( pi2c_client, cEeprom); - iRet = tlvinfo_decode_tlv(cEeprom, i_offset,c_buf); - return iRet; -} - -static -int write_vpd_data(struct i2c_client *pi2c_client, int i_offset, const char *c_buf) -{ - int iErr = 0; - - if (read_eeprom(pi2c_client, cEeprom)) { - printk(KERN_ERR "write vpd data eror at %d-%s\n", __LINE__, __FUNCTION__); - return -1; - } - - if (tlvinfo_delete_tlv(cEeprom, i_offset) == TRUE) { - } - if (c_buf) { - if(!tlvinfo_add_tlv(cEeprom, i_offset , c_buf)) { - printk(KERN_ERR "write vpd data eror at %d-%s\n", __LINE__, __FUNCTION__); - iErr = -1; - } else { - iErr = prog_eeprom(pi2c_client,cEeprom); - } - } - return iErr; -} - -static struct device * -get_swpdev_by_name(char *name){ - struct device *dev = class_find_device(vpd_class_p, - NULL, - name, - __swp_match); - return dev; -} - -static ssize_t -store_attr_vpd(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - struct i2c_client *pi2c_client = dev_get_drvdata(dev_p); - struct vpd_device_attribute *attr = to_vpd_dev_attr(attr_p); - int iOffset = attr->index; - int iErr , iLen; - char *pChar; - - if (!pi2c_client){ - return -ENODEV; - } - mutex_lock(&vpd_mutex); - - //-strip 0x0a in the last byte. - for (iLen = 0, pChar = (char*)buf_p; - iLen < 255 && *pChar != 0; - iLen++, pChar++) ; - if (iLen !=0 && *pChar == 0 && *(pChar-1) == 0x0a) - *(pChar - 1) = 0; - //- - - iErr = write_vpd_data( pi2c_client, iOffset, buf_p); - - mutex_unlock(&vpd_mutex); - return count; -} - -static ssize_t -show_attr_vpd(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct i2c_client *pi2c_client = dev_get_drvdata(dev_p); - struct vpd_device_attribute *attr = to_vpd_dev_attr(attr_p); - int iOffset = attr->index; - int iErr , iLen; - - if (!pi2c_client){ - return -ENODEV; - } - mutex_lock(&vpd_mutex); - iErr = get_vpd_data( pi2c_client, iOffset, buf_p); - mutex_unlock(&vpd_mutex); - - if( iErr <= 0 ) - iLen = 0; - else - iLen = snprintf(buf_p, TLV_DECODE_VALUE_MAX_LEN, "%s\n", buf_p); - - return iLen; -} - -/* ================= Vpd attribute ======================== - */ -static VPD_DEVICE_ATTR(product_name ,S_IWUSR|S_IRUGO, show_attr_vpd, store_attr_vpd, TLV_CODE_PRODUCT_NAME ); -static VPD_DEVICE_ATTR(pn ,S_IWUSR|S_IRUGO, show_attr_vpd, store_attr_vpd, TLV_CODE_PART_NUMBER ); -static VPD_DEVICE_ATTR(sn ,S_IWUSR|S_IRUGO, show_attr_vpd, store_attr_vpd, TLV_CODE_SERIAL_NUMBER ); -static VPD_DEVICE_ATTR(base_mac_addr,S_IWUSR|S_IRUGO, show_attr_vpd, store_attr_vpd, TLV_CODE_MAC_BASE ); -static VPD_DEVICE_ATTR(man_date ,S_IWUSR|S_IRUGO, show_attr_vpd, store_attr_vpd, TLV_CODE_MANUF_DATE ); -static VPD_DEVICE_ATTR(dev_ver ,S_IWUSR|S_IRUGO, show_attr_vpd, store_attr_vpd, TLV_CODE_DEVICE_VERSION ); -static VPD_DEVICE_ATTR(label_rev ,S_IWUSR|S_IRUGO, show_attr_vpd, store_attr_vpd, TLV_CODE_LABEL_REVISION ); -static VPD_DEVICE_ATTR(plat_name ,S_IWUSR|S_IRUGO, show_attr_vpd, store_attr_vpd, TLV_CODE_PLATFORM_NAME ); -static VPD_DEVICE_ATTR(ldr_ver ,S_IWUSR|S_IRUGO, show_attr_vpd, store_attr_vpd, TLV_CODE_ONIE_VERSION ); -static VPD_DEVICE_ATTR(mac_addr ,S_IWUSR|S_IRUGO, show_attr_vpd, store_attr_vpd, TLV_CODE_MAC_SIZE ); -static VPD_DEVICE_ATTR(manufacturer ,S_IWUSR|S_IRUGO, show_attr_vpd, store_attr_vpd, TLV_CODE_MANUF_NAME ); -static VPD_DEVICE_ATTR(country_code ,S_IWUSR|S_IRUGO, show_attr_vpd, store_attr_vpd, TLV_CODE_MANUF_COUNTRY ); -static VPD_DEVICE_ATTR(vendor_name ,S_IWUSR|S_IRUGO, show_attr_vpd, store_attr_vpd, TLV_CODE_VENDOR_NAME ); -static VPD_DEVICE_ATTR(diag_ver ,S_IWUSR|S_IRUGO, show_attr_vpd, store_attr_vpd, TLV_CODE_DIAG_VERSION ); -static VPD_DEVICE_ATTR(service_tag ,S_IWUSR|S_IRUGO, show_attr_vpd, store_attr_vpd, TLV_CODE_SERVICE_TAG ); -static VPD_DEVICE_ATTR(vendor_ext ,S_IWUSR|S_IRUGO, show_attr_vpd, store_attr_vpd, TLV_CODE_VENDOR_EXT ); -static VPD_DEVICE_ATTR(crc32 ,S_IRUGO, show_attr_vpd, NULL, TLV_CODE_CRC_32 ); - -static void -clean_vpd_common(void) -{ - dev_t dev_num; - struct device *device_p; - - device_p = get_swpdev_by_name(VPD_DEVICE); - if (device_p){ - dev_num = MKDEV(vpd_major, 1); - device_unregister(device_p); - device_destroy(vpd_class_p, dev_num); - } - VPD_DEBUG("%s: done.\n", __func__); -} - - -static struct register_attr VpdRegAttr[VPD_ENTRY_SIZE ] ={ - { &vpd_dev_attr_product_name.dev_attr, "vpd_dev_attr_product_name"}, - { &vpd_dev_attr_pn.dev_attr, "vpd_dev_attr_pn"}, - { &vpd_dev_attr_sn.dev_attr, "vpd_dev_attr_sn"}, - { &vpd_dev_attr_base_mac_addr.dev_attr, "vpd_dev_attr_base_mac_addr"}, - { &vpd_dev_attr_man_date.dev_attr, "vpd_dev_attr_man_date"}, - { &vpd_dev_attr_dev_ver.dev_attr, "vpd_dev_attr_dev_ver"}, - { &vpd_dev_attr_label_rev.dev_attr, "vpd_dev_attr_label_rev"}, - { &vpd_dev_attr_plat_name.dev_attr, "vpd_dev_attr_plat_name"}, - { &vpd_dev_attr_ldr_ver.dev_attr, "vpd_dev_attr_ldr_ver"}, - { &vpd_dev_attr_mac_addr.dev_attr, "vpd_dev_attr_mac_addr"}, - { &vpd_dev_attr_manufacturer.dev_attr, "vpd_dev_attr_manufacturer"}, - { &vpd_dev_attr_country_code.dev_attr, "vpd_dev_attr_country_code"}, - { &vpd_dev_attr_vendor_name.dev_attr, "vpd_dev_attr_vendor_name"}, - { &vpd_dev_attr_diag_ver.dev_attr, "vpd_dev_attr_diag_ver"}, - { &vpd_dev_attr_service_tag.dev_attr, "vpd_dev_attr_service_tag"}, - { &vpd_dev_attr_vendor_ext.dev_attr, "vpd_dev_attr_vendor_ext"}, - { &vpd_dev_attr_crc32.dev_attr, "vpd_dev_attr_crc32"}, -}; - -static int -register_vpd_attr(struct device *device_p){ - - char *err_attr = NULL; - int i; - - for( i = 0 ; i adapter = adap; - vpd_i2c_client->addr = VPD_I2C_ADDR; - - device_p = device_create(vpd_class_p, /* struct class *cls */ - NULL, /* struct device *parent */ - dev_num, /* dev_t devt */ - vpd_i2c_client, /* void *private_data */ - VPD_DEVICE); /* const char *fmt */ - if (IS_ERR(device_p)){ - err_msg = "device_create fail"; - goto err_register_vpd_device_1; - } - if (register_vpd_attr(device_p) < 0) { - err_msg = "register_vpd_attr fail"; - goto err_register_vpd_device_2; - } - return 0; - -err_register_vpd_device_2: - device_unregister(device_p); - device_destroy(vpd_class_p, dev_num); -err_register_vpd_device_1: - kfree(vpd_i2c_client); - vpd_i2c_client = NULL; -err_register_vpd_device: - VPD_ERR("%s: %s\n", __func__, err_msg); - return -1; -} - -static int -register_vpd_module(void) -{ - dev_t vpd_devt = 0; - - if (alloc_chrdev_region(&vpd_devt, 0, 1, VPD_DEVICE) < 0){ - VPD_WARN("Allocate VPD MAJOR failure! \n"); - goto err_register_vpd_module; - } - vpd_major = MAJOR(vpd_devt); - - /* Create class object */ - vpd_class_p = class_create(THIS_MODULE, EEPROM_CLASS); - if (IS_ERR(vpd_class_p)) { - VPD_ERR("Create class failure! \n"); - goto err_register_vpd_module_1; - } - return 0; - -err_register_vpd_module_1: - unregister_chrdev_region(MKDEV(vpd_major, 0), 1); -err_register_vpd_module: - return -1; -} - - -static int -init_vpd_common(void) -{ - char *err_msg = "ERR"; - - if (register_vpd_device() < 0) { - err_msg = "register_vpd_device fail"; - goto err_init_vpd_common; - } - return 0; - -err_init_vpd_common: - VPD_ERR("%s: %s\n", __func__, err_msg); - return -1; -} - - -static int __init -vpd_module_init(void) -{ - if (register_vpd_module() < 0){ - goto err_vpd_module_init; - } - if (init_vpd_common() < 0){ - goto err_vpd_module_init_1; - } - VPD_INFO("Inventec vpd module V.%s initial success.\n", VPD_VERSION); - return 0; - -err_vpd_module_init_1: - class_unregister(vpd_class_p); - class_destroy(vpd_class_p); - unregister_chrdev_region(MKDEV(vpd_major, 0), 1); -err_vpd_module_init: - VPD_ERR("Inventec vpd module V.%s initial failure.\n", VPD_VERSION); - return -1; -} - - -static void __exit -vpd_module_exit(void) -{ - clean_vpd_common(); - class_unregister(vpd_class_p); - class_destroy(vpd_class_p); - unregister_chrdev_region(MKDEV(vpd_major, 0), 1); - VPD_INFO("Remove Inventec vpd module success.\n"); -} - - -/* Module information */ -MODULE_AUTHOR(VPD_AUTHOR); -MODULE_DESCRIPTION(VPD_DESC); -MODULE_VERSION(VPD_VERSION); -MODULE_LICENSE(VPD_LICENSE); - -module_init(vpd_module_init); -module_exit(vpd_module_exit); diff --git a/packages/platforms/inventec/x86-64/d7264q28b/modules/builds/src/inv_vpd.h b/packages/platforms/inventec/x86-64/d7264q28b/modules/builds/src/inv_vpd.h deleted file mode 100644 index 58c7fe33f..000000000 --- a/packages/platforms/inventec/x86-64/d7264q28b/modules/builds/src/inv_vpd.h +++ /dev/null @@ -1,46 +0,0 @@ -#ifndef INV_VPD_H -#define INV_VPD_H - -#define EEPROM_CLASS "eeprom" -#define VPD_DEVICE "vpd" -#define VPD_AUTHOR "Neil " -#define VPD_DESC "Inventec eeprom vpd driver" -#define VPD_VERSION "1.0.0" -#define VPD_LICENSE "GPL" - -#define VPD_ENTRY_SIZE (17) -#define VPD_I2C_BUS (0) -#define VPD_I2C_ADDR (0x53) - -struct register_attr { -struct device_attribute *attr; -char * errmsg; -}; - -struct vpd_device_attribute{ - struct device_attribute dev_attr; - int index; -}; - -#define to_vpd_dev_attr(_dev_attr) \ - container_of(_dev_attr, struct vpd_device_attribute, dev_attr) - -#define VPD_ATTR(_name, _mode, _show, _store, _index) \ - { .dev_attr = __ATTR(_name, _mode, _show, _store), \ - .index = _index } - -#define VPD_DEVICE_ATTR(_name, _mode, _show, _store, _index) \ - struct vpd_device_attribute vpd_dev_attr_##_name \ - = VPD_ATTR(_name, _mode, _show, _store, _index) - -#define VPD_INFO(fmt, args...) printk( KERN_INFO "[VPD] " fmt, ##args) -#define VPD_WARN(fmt, args...) printk( KERN_WARNING "[VPD] " fmt, ##args) -#define VPD_ERR(fmt, args...) printk( KERN_ERR "[VPD] " fmt, ##args) - -#ifdef DEBUG_VPD -# define VPD_DEBUG(fmt, args...) printk( KERN_DEBUG "[VPD] " fmt, ##args) -#else -# define VPD_DEBUG(fmt, args...) -#endif - -#endif /* INV_VPD_H */ diff --git a/packages/platforms/inventec/x86-64/d7264q28b/modules/builds/src/io_expander.c b/packages/platforms/inventec/x86-64/d7264q28b/modules/builds/src/io_expander.c deleted file mode 100644 index 231884f3e..000000000 --- a/packages/platforms/inventec/x86-64/d7264q28b/modules/builds/src/io_expander.c +++ /dev/null @@ -1,1786 +0,0 @@ -#include -#include -#include "io_expander.h" - -static struct ioexp_obj_s *ioexp_head_p = NULL; -static struct ioexp_obj_s *ioexp_tail_p = NULL; - - -/* ========== Register IOEXP layout ========== - */ -struct ioexp_map_s ioexp_map_magnolia_nab = { - - .chip_amount = 2, - .data_width = 2, - - .map_present = { {0, 0, 4}, /* map_present[0] = MOD_ABS_PORT(X) */ - {0, 0, 5}, /* map_present[1] = MOD_ABS_PORT(X+1) */ - {0, 0, 6}, /* map_present[2] = MOD_ABS_PORT(X+2) */ - {0, 0, 7}, /* map_present[3] = MOD_ABS_PORT(X+3) */ - {1, 0, 4}, /* map_present[4] = MOD_ABS_PORT(X+4) */ - {1, 0, 5}, /* map_present[5] = MOD_ABS_PORT(X+5) */ - {1, 0, 6}, /* map_present[6] = MOD_ABS_PORT(X+6) */ - {1, 0, 7}, /* map_present[7] = MOD_ABS_PORT(X+7) */ - }, - .map_tx_disable = { {0, 1, 0}, /* map_tx_disable[0] = TXDISABLE_SFP+_P(X) */ - {0, 1, 1}, /* map_tx_disable[1] = TXDISABLE_SFP+_P(X+1) */ - {0, 1, 2}, /* map_tx_disable[2] = TXDISABLE_SFP+_P(X+2) */ - {0, 1, 3}, /* map_tx_disable[3] = TXDISABLE_SFP+_P(X+3) */ - {1, 1, 0}, /* map_tx_disable[4] = TXDISABLE_SFP+_P(X+4) */ - {1, 1, 1}, /* map_tx_disable[5] = TXDISABLE_SFP+_P(X+5) */ - {1, 1, 2}, /* map_tx_disable[6] = TXDISABLE_SFP+_P(X+6) */ - {1, 1, 3}, /* map_tx_disable[7] = TXDISABLE_SFP+_P(X+7) */ - }, - .map_tx_fault = { {0, 0, 0}, /* map_tx_fault[0] = TXFAULT_SFP+_P(X) */ - {0, 0, 1}, /* map_tx_fault[1] = TXFAULT_SFP+_P(X+1) */ - {0, 0, 2}, /* map_tx_fault[2] = TXFAULT_SFP+_P(X+2) */ - {0, 0, 3}, /* map_tx_fault[3] = TXFAULT_SFP+_P(X+3) */ - {1, 0, 0}, /* map_tx_fault[4] = TXFAULT_SFP+_P(X+4) */ - {1, 0, 1}, /* map_tx_fault[5] = TXFAULT_SFP+_P(X+5) */ - {1, 0, 2}, /* map_tx_fault[6] = TXFAULT_SFP+_P(X+6) */ - {1, 0, 3}, /* map_tx_fault[7] = TXFAULT_SFP+_P(X+7) */ - }, - .map_rxlos = { {0, 1, 4}, /* map_rxlos[0] = OPRXLOS_PORT(X) */ - {0, 1, 5}, /* map_rxlos[1] = OPRXLOS_PORT(X+1) */ - {0, 1, 6}, /* map_rxlos[2] = OPRXLOS_PORT(X+2) */ - {0, 1, 7}, /* map_rxlos[3] = OPRXLOS_PORT(X+3) */ - {1, 1, 4}, /* map_rxlos[4] = OPRXLOS_PORT(X+4) */ - {1, 1, 5}, /* map_rxlos[5] = OPRXLOS_PORT(X+5) */ - {1, 1, 6}, /* map_rxlos[6] = OPRXLOS_PORT(X+6) */ - {1, 1, 7}, /* map_rxlos[7] = OPRXLOS_PORT(X+7) */ - }, -}; - - -struct ioexp_map_s ioexp_map_magnolia_7ab = { - - .chip_amount = 2, - .data_width = 2, - - .map_present = { {1, 0, 4}, /* map_present[0] = MOD_ABS_PORT(X) */ - {1, 0, 5}, /* map_present[1] = MOD_ABS_PORT(X+1) */ - {1, 0, 6}, /* map_present[2] = MOD_ABS_PORT(X+2) */ - {1, 0, 7}, /* map_present[3] = MOD_ABS_PORT(X+3) */ - {1, 1, 4}, /* map_present[4] = MOD_ABS_PORT(X+4) */ - {1, 1, 5}, /* map_present[5] = MOD_ABS_PORT(X+5) */ - }, - .map_reset = { {0, 0, 0}, /* map_reset[0] = QRESET_QSFP_N_P(X) */ - {0, 0, 1}, /* map_reset[1] = QRESET_QSFP_N_P(X+1) */ - {0, 0, 2}, /* map_reset[2] = QRESET_QSFP_N_P(X+2) */ - {0, 0, 3}, /* map_reset[3] = QRESET_QSFP_N_P(X+3) */ - {1, 0, 0}, /* map_reset[4] = QRESET_QSFP_N_P(X+4) */ - {1, 0, 1}, /* map_reset[5] = QRESET_QSFP_N_P(X+5) */ - }, - .map_lpmod = { {0, 0, 4}, /* map_lpmod[0] = LPMODE_QSFP_P(X) */ - {0, 0, 5}, /* map_lpmod[1] = LPMODE_QSFP_P(X+1) */ - {0, 0, 6}, /* map_lpmod[2] = LPMODE_QSFP_P(X+2) */ - {0, 0, 7}, /* map_lpmod[3] = LPMODE_QSFP_P(X+3) */ - {1, 0, 2}, /* map_lpmod[4] = LPMODE_QSFP_P(X+4) */ - {1, 0, 3}, /* map_lpmod[5] = LPMODE_QSFP_P(X+5) */ - }, - .map_modsel = { {0, 1, 4}, /* map_modsel[0] = MODSEL_QSFP_N_P(X) */ - {0, 1, 5}, /* map_modsel[1] = MODSEL_QSFP_N_P(X+1) */ - {0, 1, 6}, /* map_modsel[2] = MODSEL_QSFP_N_P(X+2) */ - {0, 1, 7}, /* map_modsel[3] = MODSEL_QSFP_N_P(X+3) */ - {1, 1, 4}, /* map_modsel[4] = MODSEL_QSFP_N_P(X+4) */ - {1, 1, 5}, /* map_modsel[5] = MODSEL_QSFP_N_P(X+5) */ - }, -}; - - -struct ioexp_map_s ioexp_map_redwood_p01p08_p17p24 = { - - .chip_amount = 3, - .data_width = 2, - - .map_present = { {2, 0, 0}, /* map_present[0] = MOD_ABS_PORT(X) */ - {2, 0, 1}, /* map_present[1] = MOD_ABS_PORT(X+1) */ - {2, 0, 2}, /* map_present[2] = MOD_ABS_PORT(X+2) */ - {2, 0, 3}, /* map_present[3] = MOD_ABS_PORT(X+3) */ - {2, 0, 4}, /* map_present[4] = MOD_ABS_PORT(X+4) */ - {2, 0, 5}, /* map_present[5] = MOD_ABS_PORT(X+5) */ - {2, 0, 6}, /* map_present[6] = MOD_ABS_PORT(X+6) */ - {2, 0, 7}, /* map_present[7] = MOD_ABS_PORT(X+7) */ - }, - .map_reset = { {0, 0, 0}, /* map_reset[0] = QRESET_QSFP28_N_P(X) */ - {0, 0, 1}, /* map_reset[1] = QRESET_QSFP28_N_P(X+1) */ - {0, 0, 2}, /* map_reset[2] = QRESET_QSFP28_N_P(X+2) */ - {0, 0, 3}, /* map_reset[3] = QRESET_QSFP28_N_P(X+3) */ - {1, 0, 0}, /* map_reset[4] = QRESET_QSFP28_N_P(X+4) */ - {1, 0, 1}, /* map_reset[5] = QRESET_QSFP28_N_P(X+5) */ - {1, 0, 2}, /* map_reset[6] = QRESET_QSFP28_N_P(X+6) */ - {1, 0, 3}, /* map_reset[7] = QRESET_QSFP28_N_P(X+7) */ - }, - .map_lpmod = { {0, 0, 4}, /* map_lpmod[0] = LPMODE_QSFP28_P(X) */ - {0, 0, 5}, /* map_lpmod[1] = LPMODE_QSFP28_P(X+1) */ - {0, 0, 6}, /* map_lpmod[2] = LPMODE_QSFP28_P(X+2) */ - {0, 0, 7}, /* map_lpmod[3] = LPMODE_QSFP28_P(X+3) */ - {1, 0, 4}, /* map_lpmod[4] = LPMODE_QSFP28_P(X+4) */ - {1, 0, 5}, /* map_lpmod[5] = LPMODE_QSFP28_P(X+5) */ - {1, 0, 6}, /* map_lpmod[6] = LPMODE_QSFP28_P(X+6) */ - {1, 0, 7}, /* map_lpmod[7] = LPMODE_QSFP28_P(X+7) */ - }, - .map_modsel = { {0, 1, 4}, /* map_modsel[0] = MODSEL_QSFP28_N_P(X) */ - {0, 1, 5}, /* map_modsel[1] = MODSEL_QSFP28_N_P(X+1) */ - {0, 1, 6}, /* map_modsel[2] = MODSEL_QSFP28_N_P(X+2) */ - {0, 1, 7}, /* map_modsel[3] = MODSEL_QSFP28_N_P(X+3) */ - {1, 1, 4}, /* map_modsel[4] = MODSEL_QSFP28_N_P(X+4) */ - {1, 1, 5}, /* map_modsel[5] = MODSEL_QSFP28_N_P(X+5) */ - {1, 1, 6}, /* map_modsel[6] = MODSEL_QSFP28_N_P(X+6) */ - {1, 1, 7}, /* map_modsel[7] = MODSEL_QSFP28_N_P(X+7) */ - }, -}; - - -struct ioexp_map_s ioexp_map_redwood_p09p16_p25p32 = { - - .chip_amount = 3, - .data_width = 2, - - .map_present = { {2, 1, 0}, /* map_present[0] = MOD_ABS_PORT(X) */ - {2, 1, 1}, /* map_present[1] = MOD_ABS_PORT(X+1) */ - {2, 1, 2}, /* map_present[2] = MOD_ABS_PORT(X+2) */ - {2, 1, 3}, /* map_present[3] = MOD_ABS_PORT(X+3) */ - {2, 1, 4}, /* map_present[4] = MOD_ABS_PORT(X+4) */ - {2, 1, 5}, /* map_present[5] = MOD_ABS_PORT(X+5) */ - {2, 1, 6}, /* map_present[6] = MOD_ABS_PORT(X+6) */ - {2, 1, 7}, /* map_present[7] = MOD_ABS_PORT(X+7) */ - }, - .map_reset = { {0, 0, 0}, /* map_reset[0] = QRESET_QSFP28_N_P(X) */ - {0, 0, 1}, /* map_reset[1] = QRESET_QSFP28_N_P(X+1) */ - {0, 0, 2}, /* map_reset[2] = QRESET_QSFP28_N_P(X+2) */ - {0, 0, 3}, /* map_reset[3] = QRESET_QSFP28_N_P(X+3) */ - {1, 0, 0}, /* map_reset[4] = QRESET_QSFP28_N_P(X+4) */ - {1, 0, 1}, /* map_reset[5] = QRESET_QSFP28_N_P(X+5) */ - {1, 0, 2}, /* map_reset[6] = QRESET_QSFP28_N_P(X+6) */ - {1, 0, 3}, /* map_reset[7] = QRESET_QSFP28_N_P(X+7) */ - }, - .map_lpmod = { {0, 0, 4}, /* map_lpmod[0] = LPMODE_QSFP28_P(X) */ - {0, 0, 5}, /* map_lpmod[1] = LPMODE_QSFP28_P(X+1) */ - {0, 0, 6}, /* map_lpmod[2] = LPMODE_QSFP28_P(X+2) */ - {0, 0, 7}, /* map_lpmod[3] = LPMODE_QSFP28_P(X+3) */ - {1, 0, 4}, /* map_lpmod[4] = LPMODE_QSFP28_P(X+4) */ - {1, 0, 5}, /* map_lpmod[5] = LPMODE_QSFP28_P(X+5) */ - {1, 0, 6}, /* map_lpmod[6] = LPMODE_QSFP28_P(X+6) */ - {1, 0, 7}, /* map_lpmod[7] = LPMODE_QSFP28_P(X+7) */ - }, - .map_modsel = { {0, 1, 4}, /* map_modsel[0] = MODSEL_QSFP28_N_P(X) */ - {0, 1, 5}, /* map_modsel[1] = MODSEL_QSFP28_N_P(X+1) */ - {0, 1, 6}, /* map_modsel[2] = MODSEL_QSFP28_N_P(X+2) */ - {0, 1, 7}, /* map_modsel[3] = MODSEL_QSFP28_N_P(X+3) */ - {1, 1, 4}, /* map_modsel[4] = MODSEL_QSFP28_N_P(X+4) */ - {1, 1, 5}, /* map_modsel[5] = MODSEL_QSFP28_N_P(X+5) */ - {1, 1, 6}, /* map_modsel[6] = MODSEL_QSFP28_N_P(X+6) */ - {1, 1, 7}, /* map_modsel[7] = MODSEL_QSFP28_N_P(X+7) */ - }, -}; - - -struct ioexp_map_s ioexp_map_hudson32iga_p01p08_p17p24 = { - - .chip_amount = 3, - .data_width = 2, - - .map_present = { {2, 0, 0}, /* map_present[0] = MODABS_QSFP(X) */ - {2, 0, 1}, /* map_present[1] = MODABS_QSFP(X+1) */ - {2, 0, 2}, /* map_present[2] = MODABS_QSFP(X+2) */ - {2, 0, 3}, /* map_present[3] = MODABS_QSFP(X+3) */ - {2, 0, 4}, /* map_present[4] = MODABS_QSFP(X+4) */ - {2, 0, 5}, /* map_present[5] = MODABS_QSFP(X+5) */ - {2, 0, 6}, /* map_present[6] = MODABS_QSFP(X+6) */ - {2, 0, 7}, /* map_present[7] = MODABS_QSFP(X+7) */ - }, - .map_reset = { {0, 0, 0}, /* map_reset[0] = QRESET_QSFP(X) */ - {0, 0, 1}, /* map_reset[1] = QRESET_QSFP(X+1) */ - {0, 0, 2}, /* map_reset[2] = QRESET_QSFP(X+2) */ - {0, 0, 3}, /* map_reset[3] = QRESET_QSFP(X+3) */ - {1, 0, 0}, /* map_reset[4] = QRESET_QSFP(X+4) */ - {1, 0, 1}, /* map_reset[5] = QRESET_QSFP(X+5) */ - {1, 0, 2}, /* map_reset[6] = QRESET_QSFP(X+6) */ - {1, 0, 3}, /* map_reset[7] = QRESET_QSFP(X+7) */ - }, - .map_lpmod = { {0, 0, 4}, /* map_lpmod[0] = LPMODE_QSFP(X) */ - {0, 0, 5}, /* map_lpmod[1] = LPMODE_QSFP(X+1) */ - {0, 0, 6}, /* map_lpmod[2] = LPMODE_QSFP(X+2) */ - {0, 0, 7}, /* map_lpmod[3] = LPMODE_QSFP(X+3) */ - {1, 0, 4}, /* map_lpmod[4] = LPMODE_QSFP(X+4) */ - {1, 0, 5}, /* map_lpmod[5] = LPMODE_QSFP(X+5) */ - {1, 0, 6}, /* map_lpmod[6] = LPMODE_QSFP(X+6) */ - {1, 0, 7}, /* map_lpmod[7] = LPMODE_QSFP(X+7) */ - }, - .map_modsel = { {0, 1, 4}, /* map_modsel[0] = MODSEL_QSFP(X) */ - {0, 1, 5}, /* map_modsel[1] = MODSEL_QSFP(X+1) */ - {0, 1, 6}, /* map_modsel[2] = MODSEL_QSFP(X+2) */ - {0, 1, 7}, /* map_modsel[3] = MODSEL_QSFP(X+3) */ - {1, 1, 4}, /* map_modsel[4] = MODSEL_QSFP(X+4) */ - {1, 1, 5}, /* map_modsel[5] = MODSEL_QSFP(X+5) */ - {1, 1, 6}, /* map_modsel[6] = MODSEL_QSFP(X+6) */ - {1, 1, 7}, /* map_modsel[7] = MODSEL_QSFP(X+7) */ - }, -}; - - -struct ioexp_map_s ioexp_map_hudson32iga_p09p16_p25p32 = { - - .chip_amount = 3, - .data_width = 2, - - .map_present = { {2, 1, 0}, /* map_present[0] = MODABS_QSFP(X) */ - {2, 1, 1}, /* map_present[1] = MODABS_QSFP(X+1) */ - {2, 1, 2}, /* map_present[2] = MODABS_QSFP(X+2) */ - {2, 1, 3}, /* map_present[3] = MODABS_QSFP(X+3) */ - {2, 1, 4}, /* map_present[4] = MODABS_QSFP(X+4) */ - {2, 1, 5}, /* map_present[5] = MODABS_QSFP(X+5) */ - {2, 1, 6}, /* map_present[6] = MODABS_QSFP(X+6) */ - {2, 1, 7}, /* map_present[7] = MODABS_QSFP(X+7) */ - }, - .map_reset = { {0, 0, 0}, /* map_reset[0] = QRESET_QSFP(X) */ - {0, 0, 1}, /* map_reset[1] = QRESET_QSFP(X+1) */ - {0, 0, 2}, /* map_reset[2] = QRESET_QSFP(X+2) */ - {0, 0, 3}, /* map_reset[3] = QRESET_QSFP(X+3) */ - {1, 0, 0}, /* map_reset[4] = QRESET_QSFP(X+4) */ - {1, 0, 1}, /* map_reset[5] = QRESET_QSFP(X+5) */ - {1, 0, 2}, /* map_reset[6] = QRESET_QSFP(X+6) */ - {1, 0, 3}, /* map_reset[7] = QRESET_QSFP(X+7) */ - }, - .map_lpmod = { {0, 0, 4}, /* map_lpmod[0] = LPMODE_QSFP(X) */ - {0, 0, 5}, /* map_lpmod[1] = LPMODE_QSFP(X+1) */ - {0, 0, 6}, /* map_lpmod[2] = LPMODE_QSFP(X+2) */ - {0, 0, 7}, /* map_lpmod[3] = LPMODE_QSFP(X+3) */ - {1, 0, 4}, /* map_lpmod[4] = LPMODE_QSFP(X+4) */ - {1, 0, 5}, /* map_lpmod[5] = LPMODE_QSFP(X+5) */ - {1, 0, 6}, /* map_lpmod[6] = LPMODE_QSFP(X+6) */ - {1, 0, 7}, /* map_lpmod[7] = LPMODE_QSFP(X+7) */ - }, - .map_modsel = { {0, 1, 4}, /* map_modsel[0] = MODSEL_QSFP(X) */ - {0, 1, 5}, /* map_modsel[1] = MODSEL_QSFP(X+1) */ - {0, 1, 6}, /* map_modsel[2] = MODSEL_QSFP(X+2) */ - {0, 1, 7}, /* map_modsel[3] = MODSEL_QSFP(X+3) */ - {1, 1, 4}, /* map_modsel[4] = MODSEL_QSFP(X+4) */ - {1, 1, 5}, /* map_modsel[5] = MODSEL_QSFP(X+5) */ - {1, 1, 6}, /* map_modsel[6] = MODSEL_QSFP(X+6) */ - {1, 1, 7}, /* map_modsel[7] = MODSEL_QSFP(X+7) */ - }, -}; - - -struct ioexp_map_s ioexp_map_cypress_nabc = { - - .chip_amount = 3, - .data_width = 2, - - .map_present = { {0, 0, 4}, /* map_present[0] = MOD_ABS_PORT(X) */ - {0, 0, 5}, /* map_present[1] = MOD_ABS_PORT(X+1) */ - {0, 0, 6}, /* map_present[2] = MOD_ABS_PORT(X+2) */ - {0, 0, 7}, /* map_present[3] = MOD_ABS_PORT(X+3) */ - {1, 0, 4}, /* map_present[4] = MOD_ABS_PORT(X+4) */ - {1, 0, 5}, /* map_present[5] = MOD_ABS_PORT(X+5) */ - {1, 0, 6}, /* map_present[6] = MOD_ABS_PORT(X+6) */ - {1, 0, 7}, /* map_present[7] = MOD_ABS_PORT(X+7) */ - }, - .map_tx_disable = { {0, 1, 0}, /* map_tx_disable[0] = TXDISABLE_SFP+_P(X) */ - {0, 1, 1}, /* map_tx_disable[1] = TXDISABLE_SFP+_P(X+1) */ - {0, 1, 2}, /* map_tx_disable[2] = TXDISABLE_SFP+_P(X+2) */ - {0, 1, 3}, /* map_tx_disable[3] = TXDISABLE_SFP+_P(X+3) */ - {1, 1, 0}, /* map_tx_disable[4] = TXDISABLE_SFP+_P(X+4) */ - {1, 1, 1}, /* map_tx_disable[5] = TXDISABLE_SFP+_P(X+5) */ - {1, 1, 2}, /* map_tx_disable[6] = TXDISABLE_SFP+_P(X+6) */ - {1, 1, 3}, /* map_tx_disable[7] = TXDISABLE_SFP+_P(X+7) */ - }, - .map_tx_fault = { {0, 0, 0}, /* map_tx_fault[0] = TXFAULT_SFP+_P(X) */ - {0, 0, 1}, /* map_tx_fault[1] = TXFAULT_SFP+_P(X+1) */ - {0, 0, 2}, /* map_tx_fault[2] = TXFAULT_SFP+_P(X+2) */ - {0, 0, 3}, /* map_tx_fault[3] = TXFAULT_SFP+_P(X+3) */ - {1, 0, 0}, /* map_tx_fault[4] = TXFAULT_SFP+_P(X+4) */ - {1, 0, 1}, /* map_tx_fault[5] = TXFAULT_SFP+_P(X+5) */ - {1, 0, 2}, /* map_tx_fault[6] = TXFAULT_SFP+_P(X+6) */ - {1, 0, 3}, /* map_tx_fault[7] = TXFAULT_SFP+_P(X+7) */ - }, - .map_rxlos = { {0, 1, 4}, /* map_rxlos[0] = OPRXLOS_PORT(X) */ - {0, 1, 5}, /* map_rxlos[1] = OPRXLOS_PORT(X+1) */ - {0, 1, 6}, /* map_rxlos[2] = OPRXLOS_PORT(X+2) */ - {0, 1, 7}, /* map_rxlos[3] = OPRXLOS_PORT(X+3) */ - {1, 1, 4}, /* map_rxlos[4] = OPRXLOS_PORT(X+4) */ - {1, 1, 5}, /* map_rxlos[5] = OPRXLOS_PORT(X+5) */ - {1, 1, 6}, /* map_rxlos[6] = OPRXLOS_PORT(X+6) */ - {1, 1, 7}, /* map_rxlos[7] = OPRXLOS_PORT(X+7) */ - }, - .map_hard_rs0 = { {2, 0, 0}, /* map_hard_rs0[0] = RS0_SFP28_P(X) */ - {2, 0, 2}, /* map_hard_rs0[1] = RS0_SFP28_P(X+1) */ - {2, 0, 4}, /* map_hard_rs0[2] = RS0_SFP28_P(X+2) */ - {2, 0, 6}, /* map_hard_rs0[3] = RS0_SFP28_P(X+3) */ - {2, 1, 0}, /* map_hard_rs0[4] = RS0_SFP28_P(X+4) */ - {2, 1, 2}, /* map_hard_rs0[5] = RS0_SFP28_P(X+5) */ - {2, 1, 4}, /* map_hard_rs0[6] = RS0_SFP28_P(X+6) */ - {2, 1, 6}, /* map_hard_rs0[7] = RS0_SFP28_P(X+7) */ - }, - .map_hard_rs1 = { {2, 0, 1}, /* map_hard_rs1[0] = RS1_SFP28_P(X) */ - {2, 0, 3}, /* map_hard_rs1[1] = RS1_SFP28_P(X+1) */ - {2, 0, 5}, /* map_hard_rs1[2] = RS1_SFP28_P(X+2) */ - {2, 0, 7}, /* map_hard_rs1[3] = RS1_SFP28_P(X+3) */ - {2, 1, 1}, /* map_hard_rs1[4] = RS1_SFP28_P(X+4) */ - {2, 1, 3}, /* map_hard_rs1[5] = RS1_SFP28_P(X+5) */ - {2, 1, 5}, /* map_hard_rs1[6] = RS1_SFP28_P(X+6) */ - {2, 1, 7}, /* map_hard_rs1[7] = RS1_SFP28_P(X+7) */ - }, -}; - - -struct ioexp_map_s ioexp_map_cypress_7abc = { - - .chip_amount = 3, - .data_width = 2, - - .map_present = { {2, 0, 0}, /* map_present[0] = MOD_ABS_PORT(X) */ - {2, 0, 1}, /* map_present[1] = MOD_ABS_PORT(X+1) */ - {2, 0, 2}, /* map_present[2] = MOD_ABS_PORT(X+2) */ - {2, 0, 3}, /* map_present[3] = MOD_ABS_PORT(X+3) */ - {2, 0, 4}, /* map_present[4] = MOD_ABS_PORT(X+4) */ - {2, 0, 5}, /* map_present[5] = MOD_ABS_PORT(X+5) */ - }, - .map_reset = { {0, 0, 0}, /* map_reset[0] = QRESET_QSFP_N_P(X) */ - {0, 0, 1}, /* map_reset[1] = QRESET_QSFP_N_P(X+1) */ - {0, 0, 2}, /* map_reset[2] = QRESET_QSFP_N_P(X+2) */ - {0, 0, 3}, /* map_reset[3] = QRESET_QSFP_N_P(X+3) */ - {0, 0, 4}, /* map_reset[4] = QRESET_QSFP_N_P(X+4) */ - {0, 0, 5}, /* map_reset[5] = QRESET_QSFP_N_P(X+5) */ - }, - .map_lpmod = { {0, 1, 0}, /* map_lpmod[0] = LPMODE_QSFP_P(X) */ - {0, 1, 1}, /* map_lpmod[1] = LPMODE_QSFP_P(X+1) */ - {0, 1, 2}, /* map_lpmod[2] = LPMODE_QSFP_P(X+2) */ - {0, 1, 3}, /* map_lpmod[3] = LPMODE_QSFP_P(X+3) */ - {0, 1, 4}, /* map_lpmod[4] = LPMODE_QSFP_P(X+4) */ - {0, 1, 5}, /* map_lpmod[5] = LPMODE_QSFP_P(X+5) */ - }, - .map_modsel = { {1, 1, 0}, /* map_modsel[0] = MODSEL_QSFP_N_P(X) */ - {1, 1, 1}, /* map_modsel[1] = MODSEL_QSFP_N_P(X+1) */ - {1, 1, 2}, /* map_modsel[2] = MODSEL_QSFP_N_P(X+2) */ - {1, 1, 3}, /* map_modsel[3] = MODSEL_QSFP_N_P(X+3) */ - {1, 1, 4}, /* map_modsel[4] = MODSEL_QSFP_N_P(X+4) */ - {1, 1, 5}, /* map_modsel[5] = MODSEL_QSFP_N_P(X+5) */ - }, -}; - - -struct ioexp_map_s ioexp_map_tahoe_5a = { - - .chip_amount = 1, - .data_width = 2, - - .map_present = { {0, 0, 3}, /* map_present[0] = MOD_ABS_PORT(X) */ - {0, 1, 0}, /* map_present[1] = MOD_ABS_PORT(X+1) */ - {0, 1, 5}, /* map_present[2] = MOD_ABS_PORT(X+2) */ - }, - .map_reset = { {0, 0, 1}, /* map_reset[0] = QRESET_QSFP_N_P(X) */ - {0, 0, 6}, /* map_reset[1] = QRESET_QSFP_N_P(X+1) */ - {0, 1, 3}, /* map_reset[2] = QRESET_QSFP_N_P(X+2) */ - }, - .map_lpmod = { {0, 0, 2}, /* map_lpmod[0] = LPMODE_QSFP_P(X) */ - {0, 0, 7}, /* map_lpmod[1] = LPMODE_QSFP_P(X+1) */ - {0, 1, 4}, /* map_lpmod[2] = LPMODE_QSFP_P(X+2) */ - }, - .map_modsel = { {0, 0, 0}, /* map_modsel[0] = MODSEL_QSFP_N_P(X) */ - {0, 0, 5}, /* map_modsel[1] = MODSEL_QSFP_N_P(X+1) */ - {0, 1, 2}, /* map_modsel[2] = MODSEL_QSFP_N_P(X+2) */ - }, -}; - - -struct ioexp_map_s ioexp_map_tahoe_6abc = { - - .chip_amount = 3, - .data_width = 2, - - .map_present = { {0, 0, 3}, /* map_present[0] = MOD_ABS_PORT(X) */ - {0, 1, 0}, /* map_present[1] = MOD_ABS_PORT(X+1) */ - {0, 1, 5}, /* map_present[2] = MOD_ABS_PORT(X+2) */ - {1, 0, 3}, /* map_present[3] = MOD_ABS_PORT(X+3) */ - {1, 1, 0}, /* map_present[4] = MOD_ABS_PORT(X+4) */ - {1, 1, 5}, /* map_present[5] = MOD_ABS_PORT(X+5) */ - {2, 0, 3}, /* map_present[6] = MOD_ABS_PORT(X+6) */ - {2, 1, 0}, /* map_present[7] = MOD_ABS_PORT(X+7) */ - {2, 1, 5}, /* map_present[8] = MOD_ABS_PORT(X+8) */ - }, - .map_reset = { {0, 0, 1}, /* map_reset[0] = QRESET_QSFP28_N_P(X) */ - {0, 0, 6}, /* map_reset[1] = QRESET_QSFP28_N_P(X+1) */ - {0, 1, 3}, /* map_reset[2] = QRESET_QSFP28_N_P(X+2) */ - {1, 0, 1}, /* map_reset[3] = QRESET_QSFP28_N_P(X+3) */ - {1, 0, 6}, /* map_reset[4] = QRESET_QSFP28_N_P(X+4) */ - {1, 1, 3}, /* map_reset[5] = QRESET_QSFP28_N_P(X+5) */ - {2, 0, 1}, /* map_reset[6] = QRESET_QSFP28_N_P(X+6) */ - {2, 0, 6}, /* map_reset[7] = QRESET_QSFP28_N_P(X+7) */ - {2, 1, 3}, /* map_reset[7] = QRESET_QSFP28_N_P(X+7) */ - }, - .map_lpmod = { {0, 0, 2}, /* map_lpmod[0] = LPMODE_QSFP28_P(X) */ - {0, 0, 7}, /* map_lpmod[1] = LPMODE_QSFP28_P(X+1) */ - {0, 1, 4}, /* map_lpmod[2] = LPMODE_QSFP28_P(X+2) */ - {1, 0, 2}, /* map_lpmod[3] = LPMODE_QSFP28_P(X+3) */ - {1, 0, 7}, /* map_lpmod[4] = LPMODE_QSFP28_P(X+4) */ - {1, 1, 4}, /* map_lpmod[5] = LPMODE_QSFP28_P(X+5) */ - {2, 0, 2}, /* map_lpmod[6] = LPMODE_QSFP28_P(X+6) */ - {2, 0, 7}, /* map_lpmod[7] = LPMODE_QSFP28_P(X+7) */ - {2, 1, 4}, /* map_lpmod[7] = LPMODE_QSFP28_P(X+8) */ - }, - .map_modsel = { {0, 0, 0}, /* map_modsel[0] = MODSEL_QSFP28_N_P(X) */ - {0, 0, 5}, /* map_modsel[1] = MODSEL_QSFP28_N_P(X+1) */ - {0, 1, 2}, /* map_modsel[2] = MODSEL_QSFP28_N_P(X+2) */ - {1, 0, 0}, /* map_modsel[3] = MODSEL_QSFP28_N_P(X+3) */ - {1, 0, 5}, /* map_modsel[4] = MODSEL_QSFP28_N_P(X+4) */ - {1, 1, 2}, /* map_modsel[5] = MODSEL_QSFP28_N_P(X+5) */ - {2, 0, 0}, /* map_modsel[6] = MODSEL_QSFP28_N_P(X+6) */ - {2, 0, 5}, /* map_modsel[7] = MODSEL_QSFP28_N_P(X+7) */ - {2, 1, 2}, /* map_modsel[7] = MODSEL_QSFP28_N_P(X+7) */ - }, -}; - - -struct ioexp_map_s ioexp_map_sequoia_nabc = { - - .chip_amount = 3, - .data_width = 2, - - .map_present = { {2, 1, 0}, /* map_present[0] = MOD_ABS_PORT(X) */ - {2, 1, 1}, /* map_present[1] = MOD_ABS_PORT(X+1) */ - {2, 1, 2}, /* map_present[2] = MOD_ABS_PORT(X+2) */ - {2, 1, 3}, /* map_present[3] = MOD_ABS_PORT(X+3) */ - {2, 1, 4}, /* map_present[4] = MOD_ABS_PORT(X+4) */ - {2, 1, 5}, /* map_present[5] = MOD_ABS_PORT(X+5) */ - {2, 1, 6}, /* map_present[6] = MOD_ABS_PORT(X+6) */ - {2, 1, 7}, /* map_present[7] = MOD_ABS_PORT(X+7) */ - }, - .map_reset = { {0, 1, 0}, /* map_reset[0] = QRESET_QSFP28_N_P(X) */ - {0, 1, 1}, /* map_reset[1] = QRESET_QSFP28_N_P(X+1) */ - {0, 1, 2}, /* map_reset[2] = QRESET_QSFP28_N_P(X+2) */ - {0, 1, 3}, /* map_reset[3] = QRESET_QSFP28_N_P(X+3) */ - {0, 1, 4}, /* map_reset[4] = QRESET_QSFP28_N_P(X+4) */ - {0, 1, 5}, /* map_reset[5] = QRESET_QSFP28_N_P(X+5) */ - {0, 1, 6}, /* map_reset[6] = QRESET_QSFP28_N_P(X+6) */ - {0, 1, 7}, /* map_reset[7] = QRESET_QSFP28_N_P(X+7) */ - }, - .map_lpmod = { {1, 0, 0}, /* map_lpmod[0] = LPMODE_QSFP28_P(X) */ - {1, 0, 1}, /* map_lpmod[1] = LPMODE_QSFP28_P(X+1) */ - {1, 0, 2}, /* map_lpmod[2] = LPMODE_QSFP28_P(X+2) */ - {1, 0, 3}, /* map_lpmod[3] = LPMODE_QSFP28_P(X+3) */ - {1, 0, 4}, /* map_lpmod[4] = LPMODE_QSFP28_P(X+4) */ - {1, 0, 5}, /* map_lpmod[5] = LPMODE_QSFP28_P(X+5) */ - {1, 0, 6}, /* map_lpmod[6] = LPMODE_QSFP28_P(X+6) */ - {1, 0, 7}, /* map_lpmod[7] = LPMODE_QSFP28_P(X+7) */ - }, - .map_modsel = { {0, 0, 0}, /* map_modsel[0] = MODSEL_QSFP28_N_P(X) */ - {0, 0, 1}, /* map_modsel[1] = MODSEL_QSFP28_N_P(X+1) */ - {0, 0, 2}, /* map_modsel[2] = MODSEL_QSFP28_N_P(X+2) */ - {0, 0, 3}, /* map_modsel[3] = MODSEL_QSFP28_N_P(X+3) */ - {0, 0, 4}, /* map_modsel[4] = MODSEL_QSFP28_N_P(X+4) */ - {0, 0, 5}, /* map_modsel[5] = MODSEL_QSFP28_N_P(X+5) */ - {0, 0, 6}, /* map_modsel[6] = MODSEL_QSFP28_N_P(X+6) */ - {0, 0, 7}, /* map_modsel[7] = MODSEL_QSFP28_N_P(X+7) */ - }, -}; - - -/* ========== Private functions ========== - */ -int check_channel_tier_1(void); - -struct i2c_client * -_get_i2c_client(struct ioexp_obj_s *self, - int chip_id){ - - struct ioexp_i2c_s *i2c_curr_p = self->i2c_head_p; - - if (!(i2c_curr_p)){ - SWPS_ERR("%s: i2c_curr_p is NULL\n", __func__); - return NULL; - } - while (i2c_curr_p){ - if ((i2c_curr_p->chip_id) == chip_id){ - return i2c_curr_p->i2c_client_p; - } - i2c_curr_p = i2c_curr_p->next; - } - SWPS_ERR("%s: not exist! :%d\n", __func__, chip_id); - return NULL; -} - - -static int -_common_ioexp_update_one(struct ioexp_obj_s *self, - struct ioexp_addr_s *ioexp_addr, - int chip_id, - int data_width, - int show_err, - char *caller_name) { - int buf = 0; - int err = 0; - int data_id = 0; - int r_offset = 0; - - for(data_id=0; data_idread_offset[data_id]; - buf = i2c_smbus_read_byte_data(_get_i2c_client(self, chip_id), r_offset); - /* Check error */ - if (buf < 0) { - err = 1; - if (show_err) { - SWPS_INFO("IOEXP-%d read fail! :%d \n", self->ioexp_id, buf); - SWPS_INFO("Dump: :%d :0x%02x :%d, :%s\n", - ioexp_addr->chan_id, ioexp_addr->chip_addr, - ioexp_addr->read_offset[data_id], caller_name); - } - continue; - } - /* Update IOEXP object */ - self->chip_data[chip_id].data[data_id] = (uint8_t)buf; - } - if (err) { - return ERR_IOEXP_UNEXCPT; - } - return 0; -} - - -static int -common_ioexp_update_all(struct ioexp_obj_s *self, - int show_err, - char *caller_name){ - - int err = 0; - int chip_id = 0; - int chip_amount = self->ioexp_map_p->chip_amount; - - for (chip_id=0; chip_idioexp_map_p->map_addr[chip_id]), - chip_id, - self->ioexp_map_p->data_width, - show_err, - caller_name) < 0) { - err = 1; - } - } - if (err) { - return ERR_IOEXP_UNEXCPT; - } - return 0; -} - - -static int -_common_check_by_mode(struct ioexp_obj_s *self){ - - switch (self->mode){ - case IOEXP_MODE_DIRECT: - return self->fsm_4_direct(self); - - case IOEXP_MODE_POLLING: - if (self->state >= 0){ - return 0; - } - switch (self->state){ - case STATE_IOEXP_INIT: - return ERR_IOEXP_UNINIT; - case STATE_IOEXP_ABNORMAL: - return ERR_IOEXP_ABNORMAL; - default: - return ERR_IOEXP_NOSTATE; - } - break; - - default: - break; - } - SWPS_ERR("%s: Exception occurs. :%d \n", __func__, self->mode); - return ERR_IOEXP_UNEXCPT; -} - - -static int -_common_get_bit(struct ioexp_obj_s *self, - struct ioexp_bitmap_s *bitmap_obj_p, - char *func_mane){ - uint8_t buf; - int err_code; - - /* Check and get address */ - err_code = _common_check_by_mode(self); - if (err_code < 0){ - return err_code; - } - if (!bitmap_obj_p){ - SWPS_ERR("Layout config incorrect! :%d :%s\n", - self->ioexp_id, func_mane); - return ERR_IOEXP_BADCONF; - } - /* Get data form cache */ - buf = self->chip_data[bitmap_obj_p->chip_id].data[bitmap_obj_p->ioexp_voffset]; - return (int)(buf >> bitmap_obj_p->bit_shift & 0x01); -} - - -static int -_common_set_bit(struct ioexp_obj_s *self, - struct ioexp_bitmap_s *bitmap_obj_p, - int input_val, - char *func_mane){ - int err_code, target_offset; - uint8_t origin_byte; - uint8_t modify_byte; - - /* Check and get address */ - err_code = _common_check_by_mode(self); - if (err_code < 0){ - return err_code; - } - if (!bitmap_obj_p){ - SWPS_ERR("Layout config incorrect! :%d :%s\n", - self->ioexp_id, func_mane); - return ERR_IOEXP_BADCONF; - } - /* Prepare write date */ - origin_byte = self->chip_data[bitmap_obj_p->chip_id].data[bitmap_obj_p->ioexp_voffset]; - switch (input_val) { - case 0: - modify_byte = origin_byte; - SWP_BIT_CLEAR(modify_byte, bitmap_obj_p->bit_shift); - break; - case 1: - modify_byte = origin_byte; - SWP_BIT_SET(modify_byte, bitmap_obj_p->bit_shift); - break; - default: - SWPS_ERR("Input value incorrect! :%d :%d :%s\n", - input_val, self->ioexp_id, func_mane); - return ERR_IOEXP_BADINPUT; - } - /* Setup i2c client */ - target_offset = self->ioexp_map_p->map_addr[bitmap_obj_p->chip_id].write_offset[bitmap_obj_p->ioexp_voffset]; - /* Write byte to chip via I2C */ - err_code = i2c_smbus_write_byte_data(_get_i2c_client(self, bitmap_obj_p->chip_id), - target_offset, - modify_byte); - /* Update or bollback object */ - if (err_code < 0){ - self->chip_data[bitmap_obj_p->chip_id].data[bitmap_obj_p->ioexp_voffset] = origin_byte; - SWPS_ERR("I2C write fail! :%d :%d :%s :%d\n", - input_val, self->ioexp_id, func_mane, err_code); - return err_code; - } - self->chip_data[bitmap_obj_p->chip_id].data[bitmap_obj_p->ioexp_voffset] = modify_byte; - return 0; -} - - -/* ========== Object public functions ========== - */ -int -common_get_present(struct ioexp_obj_s *self, - int virt_offset){ - - int UNPLUG = 1; - int retval = ERR_IOEXP_UNEXCPT; - - retval = _common_get_bit(self, - &(self->ioexp_map_p->map_present[virt_offset]), - "common_get_present"); - if (retval < 0) { - /* [Note] - * => Transceiver object does not need to handle IOEXP layer issues. - */ - return UNPLUG; - } - return retval; -} - - -int -common_get_tx_fault(struct ioexp_obj_s *self, - int virt_offset){ - /* [Transmit Fault (Tx_Fault)] - * A catastrophic laser fault will activate the transmitter signal, - * TX_FAULT, and disable the laser. This signal is an open collector - * output (pull-up required on the host board). A low signal indicates - * normal laser operation and a high signal indicates a fault. The - * TX_FAULT will be latched high when a laser fault occurs and is - * cleared by toggling the TX_DISABLE input or power cycling the - * transceiver. The transmitter fault condition can also be monitored - * via the two-wire serial interface. - * (address A2, byte 110, bit 2). - * - * 0: Normal - * 1: Abnormal - */ - return _common_get_bit(self, - &(self->ioexp_map_p->map_tx_fault[virt_offset]), - "common_get_tx_fault"); -} - - -int -common_get_rxlos(struct ioexp_obj_s *self, - int virt_offset){ - /* [Receiver Loss of Signal (Rx_LOS)] - * The post-amplification IC also includes transition detection circuitry - * which monitors the ac level of incoming optical signals and provides a - * TTL/CMOS compatible status signal to the host (pin 8). An adequate optical - * input results in a low Rx_LOS output while a high Rx_LOS output indicates - * an unusable optical input. The Rx_LOS thresholds are factory set so that - * a high output indicates a definite optical fault has occurred. Rx_LOS can - * also be monitored via the two-wire serial interface - * (address A2h, byte 110, bit 1). - * - * 0: Normal - * 1: Abnormal - */ - return _common_get_bit(self, - &(self->ioexp_map_p->map_rxlos[virt_offset]), - "common_get_rxlos"); -} - - -int -common_get_tx_disable(struct ioexp_obj_s *self, - int virt_offset){ - - return _common_get_bit(self, - &(self->ioexp_map_p->map_tx_disable[virt_offset]), - "common_get_tx_disable"); -} - - -int -common_get_reset(struct ioexp_obj_s *self, - int virt_offset){ - - return _common_get_bit(self, - &(self->ioexp_map_p->map_reset[virt_offset]), - "common_get_reset"); -} - - -int -common_get_lpmod(struct ioexp_obj_s *self, - int virt_offset){ - - return _common_get_bit(self, - &(self->ioexp_map_p->map_lpmod[virt_offset]), - "common_get_lpmod"); -} - - -int -common_get_modsel(struct ioexp_obj_s *self, - int virt_offset){ - - return _common_get_bit(self, - &(self->ioexp_map_p->map_modsel[virt_offset]), - "common_get_modsel"); -} - - -int -common_get_hard_rs0(struct ioexp_obj_s *self, - int virt_offset){ - - return _common_get_bit(self, - &(self->ioexp_map_p->map_hard_rs0[virt_offset]), - "common_get_hard_rs0"); -} - - -int -common_get_hard_rs1(struct ioexp_obj_s *self, - int virt_offset){ - - return _common_get_bit(self, - &(self->ioexp_map_p->map_hard_rs1[virt_offset]), - "common_get_hard_rs1"); -} - - -int -common_set_tx_disable(struct ioexp_obj_s *self, - int virt_offset, - int input_val){ - - return _common_set_bit(self, - &(self->ioexp_map_p->map_tx_disable[virt_offset]), - input_val, - "common_set_tx_disable"); -} - - -int -common_set_reset(struct ioexp_obj_s *self, - int virt_offset, - int input_val){ - - return _common_set_bit(self, - &(self->ioexp_map_p->map_reset[virt_offset]), - input_val, - "common_set_reset"); -} - - -int -common_set_lpmod(struct ioexp_obj_s *self, - int virt_offset, - int input_val){ - - return _common_set_bit(self, - &(self->ioexp_map_p->map_lpmod[virt_offset]), - input_val, - "common_set_lpmod"); -} - - -int -common_set_modsel(struct ioexp_obj_s *self, - int virt_offset, - int input_val){ - - return _common_set_bit(self, - &(self->ioexp_map_p->map_modsel[virt_offset]), - input_val, - "common_set_modsel"); -} - - -int -common_set_hard_rs0(struct ioexp_obj_s *self, - int virt_offset, - int input_val){ - - return _common_set_bit(self, - &(self->ioexp_map_p->map_hard_rs0[virt_offset]), - input_val, - "common_set_hard_rs0"); -} - - -int -common_set_hard_rs1(struct ioexp_obj_s *self, - int virt_offset, - int input_val){ - - return _common_set_bit(self, - &(self->ioexp_map_p->map_hard_rs1[virt_offset]), - input_val, - "common_set_hard_rs1"); -} - - -int -ioexp_get_not_support(struct ioexp_obj_s *self, - int virt_offset){ - return ERR_IOEXP_NOTSUPPORT; -} - - -int -ioexp_set_not_support(struct ioexp_obj_s *self, - int virt_offset, - int input_val){ - return ERR_IOEXP_NOTSUPPORT; -} - - -int -fake_ioexp_init(struct ioexp_obj_s *self){ - return 1; -} - -int -fake_ioexp_update(struct ioexp_obj_s *self){ - return 1; -} - - -int -fake_update_func(struct ioexp_obj_s *self){ - return 1; -} - -int -fake_get_func(struct ioexp_obj_s *self, - int virt_offset){ - SWPS_WARN("Someone called fake_get_func\n"); - return -1; -} - -int -fake_set_func(struct ioexp_obj_s *self, - int virt_offset, - int input_val){ - SWPS_WARN("Someone called fake_set_func\n"); - return -1; -} - - -/* ========== Initial functions for IO Expander ========== - */ -int -common_ioexp_init(struct ioexp_obj_s *self) { - - int chip_id, offset, err_code; - struct ioexp_addr_s *addr_p; - - /* Setup default value to each physical IO Expander */ - for (chip_id=0; chip_id<(self->ioexp_map_p->chip_amount); chip_id++){ - /* Get address mapping */ - addr_p = &(self->ioexp_map_p->map_addr[chip_id]); - if (!addr_p){ - SWPS_ERR("%s: IOEXP config incorrect! :%d \n", - __func__, chip_id); - return -1; - } - /* Setup default value */ - for (offset=0; offset<(self->ioexp_map_p->data_width); offset++){ - err_code = i2c_smbus_write_byte_data(_get_i2c_client(self, chip_id), - addr_p->write_offset[offset], - addr_p->data_default[offset]); - if (err_code < 0){ - SWPS_ERR("%s: set default fail! :%d \n", - __func__, err_code); - return ERR_IOEXP_UNEXCPT; - } - } - } - /* Check and update info to object */ - err_code = self->update_all(self, 1, "common_ioexp_init"); - if (err_code < 0) { - SWPS_ERR("%s: update_all() fail! :%d \n", - __func__, err_code); - return ERR_IOEXP_UNEXCPT; - } - return 0; -} - - -/* ========== Object functions for Final State Machine ========== - */ -int -_is_channel_ready(struct ioexp_obj_s *self){ - - int buf = 0; - int chip_id = 0; /* Use first chip which be registered */ - int data_id = 0; /* Use first byte which be registered */ - struct ioexp_addr_s *ioexp_addr = NULL; - - ioexp_addr = &(self->ioexp_map_p->map_addr[chip_id]); - if (!ioexp_addr){ - SWPS_ERR("%s: config incorrect!\n", __func__); - return ERR_IOEXP_UNEXCPT; - } - buf = i2c_smbus_read_byte_data(_get_i2c_client(self, chip_id), - ioexp_addr->read_offset[data_id]); - if (buf >= 0){ - return 1; - } - return 0; -} - -int -_ioexp_init_handler(struct ioexp_obj_s *self){ - - int return_val; - - switch (self->mode) { - case IOEXP_MODE_DIRECT: - return_val = self->init(self); - if (return_val < 0){ - self->state = STATE_IOEXP_ABNORMAL; - } else { - self->state = STATE_IOEXP_NORMAL; - } - return return_val; - - case IOEXP_MODE_POLLING: - /* Check system and channel is ready */ - if (self->state == STATE_IOEXP_INIT){ - if (!_is_channel_ready(self)){ - self->state = STATE_IOEXP_INIT; - SWPS_WARN("%s: IOEXP:%d channel not ready.\n", - __func__, self->ioexp_id); - return 0; - } - } - /* Execute initial callback */ - return_val = self->init(self); - if (return_val < 0){ - self->state = STATE_IOEXP_ABNORMAL; - } else { - self->state = STATE_IOEXP_NORMAL; - } - return return_val; - - default: - break; - } - SWPS_ERR("%s: exception occur :%d\n", __func__, self->mode); - return ERR_IOEXP_UNEXCPT; -} - - -int -common_ioexp_fsm_4_direct(struct ioexp_obj_s *self){ - - int result_val; - int show_err = 1; - char *func_mane = "common_ioexp_fsm_4_direct"; - - switch (self->state){ - case STATE_IOEXP_INIT: - result_val = _ioexp_init_handler(self); - /* Exception case: terminate initial procedure */ - if(result_val < 0){ - /* Initial fail */ - return result_val; - } - if(self->state == STATE_IOEXP_INIT){ - /* Keep in INIT state, and return error */ - return ERR_IOEXP_UNINIT; - } - /* Case: Initial done */ - return 0; - - case STATE_IOEXP_NORMAL: - result_val = self->update_all(self, show_err, func_mane); - if (result_val < 0){ - SWPS_INFO("%s: NORMAL -> ABNORMAL :%d\n", - __func__, result_val); - self->state = STATE_IOEXP_ABNORMAL; - return result_val; - } - self->state = STATE_IOEXP_NORMAL; - return 0; - - case STATE_IOEXP_ABNORMAL: - result_val = self->update_all(self, show_err, func_mane); - if (result_val < 0){ - self->state = STATE_IOEXP_ABNORMAL; - return result_val; - } - SWPS_DEBUG("%s: ABNORMAL -> NORMAL :%d\n", - __func__, result_val); - self->state = STATE_IOEXP_NORMAL; - return 0; - - default: - break; - } - SWPS_ERR("%s: Exception occurs :%d\n", - __func__, self->state); - return ERR_IOEXP_UNEXCPT; -} - - -int -common_ioexp_fsm_4_polling(struct ioexp_obj_s *self){ - - int result_val, i, show_e; - int fail_retry = 3; - char *func_name = "common_ioexp_fsm_4_polling"; - -#ifdef DEBUG_SWPS - show_e = 1; -#else - show_e = 0; -#endif - - switch (self->state){ - case STATE_IOEXP_INIT: - result_val = _ioexp_init_handler(self); - /* Exception case: terminate initial procedure */ - if(result_val < 0){ - /* Initial fail */ - return result_val; - } - /* Case: System (Channel) not ready */ - if(self->state == STATE_IOEXP_INIT){ - /* Keep in INIT state, wait and retry */ - return 0; - } - /* Case: Initial done */ - SWPS_INFO("IOEXP-%d: initial done. :%d\n", - self->ioexp_id, self->ioexp_type); - return result_val; - - case STATE_IOEXP_NORMAL: - /* Retry mechanism for case of i2c topology not stable */ - for (i=0; iupdate_all(self, show_e, func_name); - if (result_val >= 0) { - self->state = STATE_IOEXP_NORMAL; - return 0; - } - if (check_channel_tier_1() < 0) { - SWPS_INFO("%s: detect I2C crash :%d\n", - __func__, self->ioexp_id); - break; - } - SWPS_DEBUG("IOEXP-%d: unstable :%d\n", - self->ioexp_id, result_val); - } - SWPS_INFO("IOEXP-%d: NORMAL -> ABNORMAL :%d\n", - self->ioexp_id, result_val); - self->state = STATE_IOEXP_ABNORMAL; - return result_val; - - case STATE_IOEXP_ABNORMAL: - result_val = self->update_all(self, show_e, func_name); - if (result_val < 0){ - self->state = STATE_IOEXP_ABNORMAL; - return result_val; - } - SWPS_INFO("IOEXP-%d: ABNORMAL -> NORMAL :%d\n", - self->ioexp_id, result_val); - self->state = STATE_IOEXP_NORMAL; - return 0; - - default: - break; - } - SWPS_ERR("IOEXP-%d: Exception occurs :%d\n", - self->ioexp_id, self->state); - return ERR_IOEXP_UNEXCPT; -} - - -/* ========== Object private functions for check & update ========== - */ -int -common_ioexp_check(struct ioexp_obj_s *self){ - - int result; - - if (self->mode != IOEXP_MODE_POLLING){ - SWPS_ERR("%s: not polling mode :%d\n", - __func__, self->mode); - return ERR_IOEXP_NOTSUPPORT; - } - mutex_lock(&self->lock); - result = self->fsm_4_polling(self); - mutex_unlock(&self->lock); - return result; -} - - -/* ========== Functions for Factory pattern ========== - */ -static struct ioexp_map_s * -get_ioexp_map(int ioexp_type){ - switch (ioexp_type){ - case IOEXP_TYPE_MAGINOLIA_NAB: - return &ioexp_map_magnolia_nab; - case IOEXP_TYPE_MAGINOLIA_7AB: - case IOEXP_TYPE_SPRUCE_7AB: - return &ioexp_map_magnolia_7ab; - case IOEXP_TYPE_REDWOOD_P01P08: - return &ioexp_map_redwood_p01p08_p17p24; - case IOEXP_TYPE_REDWOOD_P09P16: - return &ioexp_map_redwood_p09p16_p25p32; - case IOEXP_TYPE_HUDSON32IGA_P01P08: - return &ioexp_map_hudson32iga_p01p08_p17p24; - case IOEXP_TYPE_HUDSON32IGA_P09P16: - return &ioexp_map_hudson32iga_p09p16_p25p32; - case IOEXP_TYPE_CYPRESS_NABC: - return &ioexp_map_cypress_nabc; - case IOEXP_TYPE_CYPRESS_7ABC: - return &ioexp_map_cypress_7abc; - case IOEXP_TYPE_TAHOE_5A: - return &ioexp_map_tahoe_5a; - case IOEXP_TYPE_TAHOE_6ABC: - return &ioexp_map_tahoe_6abc; - case IOEXP_TYPE_SEQUOIA_NABC: - return &ioexp_map_sequoia_nabc; - default: - return NULL; - } -} - - -int -setup_ioexp_ssize_attr(struct ioexp_obj_s *self, - struct ioexp_map_s *ioexp_map_p, - int ioexp_id, - int ioexp_type, - int run_mode){ - switch (run_mode){ - case IOEXP_MODE_POLLING: /* Direct access device mode */ - case IOEXP_MODE_DIRECT: /* Polling mode, read from cache */ - self->mode = run_mode; - break; - default: - SWPS_ERR("%s: non-defined run_mode:%d\n", - __func__, run_mode); - self->mode = ERR_IOEXP_UNEXCPT; - return ERR_IOEXP_UNEXCPT; - } - self->ioexp_id = ioexp_id; - self->ioexp_type = ioexp_type; - self->ioexp_map_p = ioexp_map_p; - self->state = STATE_IOEXP_INIT; - mutex_init(&self->lock); - return 0; -} - - -static int -setup_addr_mapping(struct ioexp_obj_s *self, - struct ioexp_addr_s *addr_map_p){ - if (!addr_map_p){ - SWPS_ERR("%s: map is null\n", __func__); - return -1; - } - self->ioexp_map_p->map_addr = addr_map_p; - return 0; -} - - -static int -setup_ioexp_public_cb(struct ioexp_obj_s *self, - int ioexp_type){ - - switch (ioexp_type){ - case IOEXP_TYPE_MAGINOLIA_NAB: - self->get_present = common_get_present; - self->get_tx_fault = common_get_tx_fault; - self->get_rxlos = common_get_rxlos; - self->get_tx_disable = common_get_tx_disable; - self->get_reset = ioexp_get_not_support; - self->get_lpmod = ioexp_get_not_support; - self->get_modsel = ioexp_get_not_support; - self->get_hard_rs0 = ioexp_get_not_support; - self->get_hard_rs1 = ioexp_get_not_support; - self->set_tx_disable = common_set_tx_disable; - self->set_reset = ioexp_set_not_support; - self->set_lpmod = ioexp_set_not_support; - self->set_modsel = ioexp_set_not_support; - self->set_hard_rs0 = ioexp_set_not_support; - self->set_hard_rs1 = ioexp_set_not_support; - return 0; - case IOEXP_TYPE_CYPRESS_NABC: - self->get_present = common_get_present; - self->get_tx_fault = common_get_tx_fault; - self->get_rxlos = common_get_rxlos; - self->get_tx_disable = common_get_tx_disable; - self->get_reset = ioexp_get_not_support; - self->get_lpmod = ioexp_get_not_support; - self->get_modsel = ioexp_get_not_support; - self->get_hard_rs0 = common_get_hard_rs0; - self->get_hard_rs1 = common_get_hard_rs1; - self->set_tx_disable = common_set_tx_disable; - self->set_reset = ioexp_set_not_support; - self->set_lpmod = ioexp_set_not_support; - self->set_modsel = ioexp_set_not_support; - self->set_hard_rs0 = common_set_hard_rs0; - self->set_hard_rs1 = common_set_hard_rs1; - return 0; - case IOEXP_TYPE_MAGINOLIA_7AB: - case IOEXP_TYPE_SPRUCE_7AB: - case IOEXP_TYPE_REDWOOD_P01P08: - case IOEXP_TYPE_REDWOOD_P09P16: - case IOEXP_TYPE_HUDSON32IGA_P01P08: - case IOEXP_TYPE_HUDSON32IGA_P09P16: - case IOEXP_TYPE_CYPRESS_7ABC: - case IOEXP_TYPE_TAHOE_5A: - case IOEXP_TYPE_TAHOE_6ABC: - case IOEXP_TYPE_SEQUOIA_NABC: - self->get_present = common_get_present; - self->get_tx_fault = ioexp_get_not_support; - self->get_rxlos = ioexp_get_not_support; - self->get_tx_disable = ioexp_get_not_support; - self->get_reset = common_get_reset; - self->get_lpmod = common_get_lpmod; - self->get_modsel = common_get_modsel; - self->get_hard_rs0 = ioexp_get_not_support; - self->get_hard_rs1 = ioexp_get_not_support; - self->set_tx_disable = ioexp_set_not_support; - self->set_reset = common_set_reset; - self->set_lpmod = common_set_lpmod; - self->set_modsel = common_set_modsel; - self->set_hard_rs0 = ioexp_set_not_support; - self->set_hard_rs1 = ioexp_set_not_support; - return 0; - - default: - SWPS_ERR("%s: type:%d incorrect!\n", __func__, ioexp_type); - break; - } - return ERR_IOEXP_UNEXCPT; -} - - -static int -setup_ioexp_private_cb(struct ioexp_obj_s *self, - int ioexp_type){ - - switch (ioexp_type){ - case IOEXP_TYPE_MAGINOLIA_NAB: - case IOEXP_TYPE_MAGINOLIA_7AB: - case IOEXP_TYPE_SPRUCE_7AB: - case IOEXP_TYPE_REDWOOD_P01P08: - case IOEXP_TYPE_REDWOOD_P09P16: - case IOEXP_TYPE_HUDSON32IGA_P01P08: - case IOEXP_TYPE_HUDSON32IGA_P09P16: - case IOEXP_TYPE_CYPRESS_NABC: - case IOEXP_TYPE_CYPRESS_7ABC: - case IOEXP_TYPE_TAHOE_5A: - case IOEXP_TYPE_TAHOE_6ABC: - case IOEXP_TYPE_SEQUOIA_NABC: - self->init = common_ioexp_init; - self->check = common_ioexp_check; - self->update_all = common_ioexp_update_all; - self->fsm_4_direct = common_ioexp_fsm_4_direct; - self->fsm_4_polling = common_ioexp_fsm_4_polling; - return 0; - - default: - SWPS_ERR("%s: type:%d incorrect!\n", __func__, ioexp_type); - break; - } - return ERR_IOEXP_UNEXCPT; -} - - -static int -setup_i2c_client_one(struct ioexp_obj_s *self, - int chip_id){ - - char *err_msg = "ERROR"; - struct i2c_adapter *adap = NULL; - struct i2c_client *client = NULL; - struct ioexp_i2c_s *i2c_obj_p = NULL; - struct ioexp_i2c_s *i2c_curr_p = NULL; - - int chan_id = self->ioexp_map_p->map_addr[chip_id].chan_id; - adap = i2c_get_adapter(chan_id); - if(!adap){ - err_msg = "Can not get adap!"; - goto err_ioexp_setup_i2c_1; - } - client = kzalloc(sizeof(*client), GFP_KERNEL); - if (!client){ - err_msg = "Can not kzalloc client!"; - goto err_ioexp_setup_i2c_1; - } - i2c_obj_p = kzalloc(sizeof(*i2c_obj_p), GFP_KERNEL); - if (!i2c_obj_p){ - err_msg = "Can not kzalloc i2c_obj_p!"; - goto err_ioexp_setup_i2c_2; - } - client->adapter = adap; - client->addr = self->ioexp_map_p->map_addr[chip_id].chip_addr; - i2c_obj_p->i2c_client_p = client; - i2c_obj_p->chip_id = chip_id; - i2c_obj_p->next = NULL; - if (!self->i2c_head_p){ - self->i2c_head_p = i2c_obj_p; - } else { - i2c_curr_p = self->i2c_head_p; - while (i2c_curr_p->next){ - i2c_curr_p = i2c_curr_p->next; - } - i2c_curr_p->next = i2c_obj_p; - } - return 0; - -err_ioexp_setup_i2c_2: - kfree(client); -err_ioexp_setup_i2c_1: - SWPS_ERR("%s: %s :%d\n", __func__, err_msg, chan_id); - return -1; -} - - -static int -setup_i2c_client(struct ioexp_obj_s* self){ - - int result; - int chip_id = 0; - - for (chip_id=0; chip_id<(self->ioexp_map_p->chip_amount); chip_id++){ - result = setup_i2c_client_one(self, chip_id); - if (result < 0){ - SWPS_ERR("%s fail! :%d\n", __func__, chip_id); - return -1; - } - } - return 0; -} - - -static int -setup_ioexp_config(struct ioexp_obj_s *self) { - - int chip_id, offset, err_code; - struct ioexp_addr_s *addr_p; - - for (chip_id=0; chip_id<(self->ioexp_map_p->chip_amount); chip_id++){ - addr_p = &(self->ioexp_map_p->map_addr[chip_id]); - if (!addr_p){ - SWPS_ERR("IOEXP config incorrect! :%d \n",chip_id); - return -1; - } - for (offset=0; offset<(self->ioexp_map_p->data_width); offset++){ - - err_code = i2c_smbus_write_byte_data(_get_i2c_client(self, chip_id), - addr_p->conf_offset[offset], - addr_p->conf_default[offset]); - - if (err_code < 0){ - SWPS_INFO("%s: set conf fail! :%d \n", __func__, err_code); - return -2; - } - } - } - return 0; -} - - -struct ioexp_obj_s * -_create_ioexp_obj(int ioexp_id, - int ioexp_type, - struct ioexp_addr_s *addr_map_p, - int run_mode){ - - struct ioexp_map_s* ioexp_map_p; - struct ioexp_obj_s* result_p; - struct ioexp_i2c_s *i2c_curr_p; - struct ioexp_i2c_s *i2c_next_p; - - /* Get layout */ - ioexp_map_p = get_ioexp_map(ioexp_type); - if (!ioexp_map_p){ - SWPS_ERR("%s: Invalid ioexp_type\n", __func__); - goto err_create_ioexp_fail; - } - /* Prepare IOEXP object */ - result_p = kzalloc(sizeof(*result_p), GFP_KERNEL); - if (!result_p){ - SWPS_ERR("%s: kzalloc failure!\n", __func__); - goto err_create_ioexp_fail; - } - /* Prepare static size attributes */ - if (setup_ioexp_ssize_attr(result_p, - ioexp_map_p, - ioexp_id, - ioexp_type, - run_mode) < 0){ - goto err_create_ioexp_setup_attr_fail; - } - /* Prepare address mapping */ - if (setup_addr_mapping(result_p, addr_map_p) < 0){ - goto err_create_ioexp_setup_attr_fail; - } - if (setup_i2c_client(result_p) < 0){ - goto err_create_ioexp_setup_i2c_fail; - } - /* Prepare call back functions of object */ - if (setup_ioexp_public_cb(result_p, ioexp_type) < 0){ - goto err_create_ioexp_setup_i2c_fail; - } - if (setup_ioexp_private_cb(result_p, ioexp_type) < 0){ - goto err_create_ioexp_setup_i2c_fail; - } - return result_p; - -err_create_ioexp_setup_i2c_fail: - i2c_curr_p = result_p->i2c_head_p; - i2c_next_p = result_p->i2c_head_p; - while (i2c_curr_p){ - i2c_next_p = i2c_curr_p->next; - kfree(i2c_curr_p->i2c_client_p); - kfree(i2c_curr_p); - i2c_curr_p = i2c_next_p; - } -err_create_ioexp_setup_attr_fail: - kfree(result_p); -err_create_ioexp_fail: - SWPS_ERR("%s: fail! :%d :%d \n", - __func__, ioexp_id, ioexp_type); - return NULL; -} - - -int -create_ioexp_obj(int ioexp_id, - int ioexp_type, - struct ioexp_addr_s *addr_map_p, - int run_mode){ - - struct ioexp_obj_s *ioexp_p = NULL; - - ioexp_p = _create_ioexp_obj(ioexp_id, ioexp_type, - addr_map_p, run_mode); - if (!ioexp_p){ - return -1; - } - if (ioexp_head_p == NULL){ - ioexp_head_p = ioexp_p; - ioexp_tail_p = ioexp_p; - return 0; - } - ioexp_tail_p->next = ioexp_p; - ioexp_tail_p = ioexp_p; - return 0; -} - - -static int -_init_ioexp_obj(struct ioexp_obj_s* self) { - - char *err_msg = "ERR"; - char *func_name = "_init_ioexp_obj"; - - /* Setup IOEXP configure byte */ - if (setup_ioexp_config(self) < 0){ - err_msg = "setup_ioexp_config fail"; - goto err_init_ioexp_obj; - } - /* Setup default data */ - if (_ioexp_init_handler(self) < 0){ - err_msg = "_ioexp_init_handler fail"; - goto err_init_ioexp_obj; - } - /* Update all */ - if (self->state == STATE_IOEXP_NORMAL){ - if (self->update_all(self, 1, func_name) < 0){ - err_msg = "update_all() fail"; - goto err_init_ioexp_obj; - } - } - return 0; - -err_init_ioexp_obj: - SWPS_DEBUG("%s: %s\n", __func__, err_msg); - return -1; -} - - -int -init_ioexp_objs(void){ - /* Return value: - * 0: Success - * -1: Detect topology error - * -2: SWPS internal error - */ - - struct ioexp_obj_s *curr_p = ioexp_head_p; - - if (!curr_p) { - SWPS_ERR("%s: ioexp_head_p is NULL\n", __func__); - return -2; - } - while (curr_p) { - if (_init_ioexp_obj(curr_p) < 0) { - SWPS_DEBUG("%s: _init_ioexp_obj() fail\n", __func__); - return -1; - } - curr_p = curr_p->next; - } - SWPS_DEBUG("%s: done.\n", __func__); - return 0; -} - - -void -clean_ioexp_objs(void){ - - struct ioexp_i2c_s *i2c_curr_p = NULL; - struct ioexp_i2c_s *i2c_next_p = NULL; - struct ioexp_obj_s *ioexp_next_p = NULL; - struct ioexp_obj_s *ioexp_curr_p = ioexp_head_p; - - if (ioexp_head_p == NULL){ - ioexp_tail_p = NULL; - return; - } - while(ioexp_curr_p){ - ioexp_next_p = ioexp_curr_p->next; - i2c_curr_p = ioexp_curr_p->i2c_head_p; - while (i2c_curr_p) { - i2c_next_p = i2c_curr_p->next; - kfree(i2c_curr_p->i2c_client_p); - kfree(i2c_curr_p); - i2c_curr_p = i2c_next_p; - } - kfree(ioexp_curr_p); - ioexp_curr_p = ioexp_next_p; - } - ioexp_tail_p = NULL; - SWPS_DEBUG("%s: done.\n", __func__); -} - - -int -check_ioexp_objs(void){ - - struct ioexp_obj_s *ioexp_curr_p = ioexp_head_p; - - while (ioexp_curr_p){ - if ( (ioexp_curr_p->check(ioexp_curr_p)) < 0){ - SWPS_INFO("check IOEXP-%d fail! :%d\n", - ioexp_curr_p->ioexp_id, ioexp_curr_p->ioexp_type); - return -1; - } - ioexp_curr_p = ioexp_curr_p->next; - } - return 0; -} - - -struct ioexp_obj_s * -get_ioexp_obj(int ioexp_id){ - - struct ioexp_obj_s *result_p = NULL; - struct ioexp_obj_s *ioexp_curr_p = ioexp_head_p; - - while(ioexp_curr_p){ - if (ioexp_curr_p->ioexp_id == ioexp_id){ - result_p = ioexp_curr_p; - break; - } - ioexp_curr_p = ioexp_curr_p->next; - } - return result_p; -} - - -void -unlock_ioexp_all(void) { - - struct ioexp_obj_s *ioexp_curr_p = ioexp_head_p; - - while(ioexp_curr_p){ - mutex_unlock(&ioexp_curr_p->lock); - ioexp_curr_p = ioexp_curr_p->next; - } -} - - -int -lock_ioexp_all(void) { - - struct ioexp_obj_s *ioexp_curr_p = ioexp_head_p; - - while(ioexp_curr_p){ - mutex_lock(&ioexp_curr_p->lock); - ioexp_curr_p = ioexp_curr_p->next; - } - return 0; -} - - -int -check_channel_tier_1(void) { - - if ( (!_is_channel_ready(ioexp_head_p)) && - (!_is_channel_ready(ioexp_tail_p)) ){ - return -1; - } - return 0; -} - - -static int -_scan_channel_tier_1(int force, - int show_err) { - - struct ioexp_obj_s *ioexp_curr_p = ioexp_head_p; - int ready = 0; - - if (!ioexp_curr_p) { - goto err_scan_tier_1_channel; - } - while(ioexp_curr_p) { - ready = _is_channel_ready(ioexp_curr_p); - if ((!ready) && (!force)) { - goto err_scan_tier_1_channel; - } - ioexp_curr_p = ioexp_curr_p->next; - } - return 0; - -err_scan_tier_1_channel: - if (show_err) { - if (ioexp_curr_p) { - SWPS_INFO("%s: IOEXP-%d fail\n", __func__, ioexp_curr_p->ioexp_id); - } else { - SWPS_INFO("%s: IOEXP is null.\n", __func__); - } - } - return -1; -} - - -static int -_scan_channel_tier_1_single(void) { - - int ret = 0; - int chan_id = 0; - int fake_cid = 0; - int fake_offs = 0; - int fake_addr = 0; - struct i2c_adapter *adap = NULL; - struct i2c_client *client = NULL; - - if (ioexp_head_p->ioexp_id != ioexp_tail_p->ioexp_id) { - return 0; - } - /* Setup i2c_client */ - chan_id = ioexp_head_p->ioexp_map_p->map_addr[fake_cid].chan_id; - fake_addr = ioexp_head_p->ioexp_map_p->map_addr[fake_cid].chip_addr; - adap = i2c_get_adapter((chan_id + 1)); - if(!adap){ - SWPS_INFO("%s: Can not get adap!\n", __func__); - return 0; - } - client = kzalloc(sizeof(*client), GFP_KERNEL); - if (!client){ - SWPS_INFO("%s: Can not kzalloc client!\n", __func__); - return 0; - } - client->adapter = adap; - client->addr = fake_addr; - /* Fouce move ioexp ptr to next */ - ret = i2c_smbus_read_byte_data(client, fake_offs); - SWPS_DEBUG("%s: move ioexp_ptr done. :%d\n", __func__, ret); - kfree(client); - return 1; -} - - -int -resync_channel_tier_1(void) { - - char *emsg = "ERR"; - - if (!ioexp_head_p) { - emsg = "ioexp_head_p is NULL"; - goto err_resync_ioexp_status_1; - } - /* Run all */ - if (ioexp_head_p->ioexp_id == ioexp_tail_p->ioexp_id) { - _scan_channel_tier_1_single(); - } else { - _scan_channel_tier_1(1, 0); - } - /* Check all */ - if (_scan_channel_tier_1(0, 1) < 0) { - emsg = "resync tier-1 channel fail"; - goto err_resync_ioexp_status_1; - } - return 0; - -err_resync_ioexp_status_1: - SWPS_ERR("%s: %s\n", __func__, emsg); - return -1; -} - - - - - - diff --git a/packages/platforms/inventec/x86-64/d7264q28b/modules/builds/src/io_expander.h b/packages/platforms/inventec/x86-64/d7264q28b/modules/builds/src/io_expander.h deleted file mode 100644 index 4e39fcefa..000000000 --- a/packages/platforms/inventec/x86-64/d7264q28b/modules/builds/src/io_expander.h +++ /dev/null @@ -1,173 +0,0 @@ -#ifndef IO_EXPANDER_H -#define IO_EXPANDER_H - -#include - - -/* IOEXP type define (SFP series) */ -#define IOEXP_TYPE_MAGINOLIA_NAB (10101) -#define IOEXP_TYPE_CYPRESS_NABC (10102) - -/* IOEXP type define (QSFP series) */ -#define IOEXP_TYPE_MAGINOLIA_7AB (10201) -#define IOEXP_TYPE_REDWOOD_P01P08 (10202) -#define IOEXP_TYPE_REDWOOD_P09P16 (10203) -#define IOEXP_TYPE_HUDSON32IGA_P01P08 (10204) -#define IOEXP_TYPE_HUDSON32IGA_P09P16 (10205) -#define IOEXP_TYPE_SPRUCE_7AB (10206) -#define IOEXP_TYPE_CYPRESS_7ABC (10207) -#define IOEXP_TYPE_TAHOE_5A (10208) -#define IOEXP_TYPE_TAHOE_6ABC (10209) -#define IOEXP_TYPE_SEQUOIA_NABC (10210) - -/* IOEXP mode define */ -#define IOEXP_MODE_POLLING (19000) -#define IOEXP_MODE_DIRECT (19001) - -/* IOEXP state define */ -#define STATE_IOEXP_NORMAL (0) -#define STATE_IOEXP_INIT (-1) -#define STATE_IOEXP_ABNORMAL (-2) - -/* IOEXP error code define */ -#define ERR_IOEXP_NOTSUPPORT (-100) -#define ERR_IOEXP_UNINIT (-101) -#define ERR_IOEXP_BADCONF (-102) -#define ERR_IOEXP_ABNORMAL (-103) -#define ERR_IOEXP_NOSTATE (-104) -#define ERR_IOEXP_BADINPUT (-105) -#define ERR_IOEXP_UNEXCPT (-199) - - -#define SWPS_INFO(fmt, args...) printk( KERN_INFO "[SWPS] " fmt, ##args) -#define SWPS_WARN(fmt, args...) printk( KERN_WARNING "[SWPS] " fmt, ##args) -#define SWPS_ERR(fmt, args...) printk( KERN_ERR "[SWPS] " fmt, ##args) - -#ifdef DEBUG_SWPS -# define SWPS_DEBUG(fmt, args...) printk( KERN_DEBUG "[SWPS] " fmt, ##args) -#else -# define SWPS_DEBUG(fmt, args...) -#endif - - -struct ioexp_addr_s { - int chan_id; - int chip_addr; - int read_offset[8]; - int write_offset[8]; - int conf_offset[8]; - uint8_t data_default[8]; - uint8_t conf_default[8]; -}; - -struct ioexp_i2c_s { - int chip_id; - struct i2c_client *i2c_client_p; - struct ioexp_i2c_s *next; -}; - - -struct ioexp_bitmap_s { - int chip_id; /* IOEXP chip id */ - int ioexp_voffset; /* IOEXP virtual offset */ - int bit_shift; -}; - -struct ioexp_map_s { - int chip_amount; /* Number of chips that IOEXP object content */ - int data_width; /* Number of (Read/Write/Config) bytes */ - struct ioexp_addr_s *map_addr; /* Chip address info */ - struct ioexp_bitmap_s map_present[10]; /* IOEXP for SFP / QSFP */ - struct ioexp_bitmap_s map_tx_disable[10]; /* IOEXP for SFP */ - struct ioexp_bitmap_s map_tx_fault[10]; /* IOEXP for SFP */ - struct ioexp_bitmap_s map_rxlos[10]; /* IOEXP for SFP */ - struct ioexp_bitmap_s map_reset[10]; /* IOEXP for QSFP */ - struct ioexp_bitmap_s map_lpmod[10]; /* IOEXP for QSFP */ - struct ioexp_bitmap_s map_modsel[10]; /* IOEXP for QSFP */ - struct ioexp_bitmap_s map_hard_rs0[10]; /* IOEXP for QSFP */ - struct ioexp_bitmap_s map_hard_rs1[10]; /* IOEXP for QSFP */ -}; - -struct ioexp_data_s { - uint8_t data[8]; -}; - -struct ioexp_obj_s { - - /* ============================ - * Object public property - * ============================ - */ - int ioexp_id; - int ioexp_type; - - /* ============================ - * Object private property - * ============================ - */ - struct ioexp_data_s chip_data[16]; /* Max: 8-ioexp in one virt-ioexp(ioexp_obj) */ - struct ioexp_map_s *ioexp_map_p; - struct ioexp_obj_s *next; - struct ioexp_i2c_s *i2c_head_p; - struct mutex lock; - int mode; - int state; - - /* =========================================== - * Object public functions - * =========================================== - */ - int (*get_present)(struct ioexp_obj_s *self, int virt_offset); - int (*get_tx_fault)(struct ioexp_obj_s *self, int virt_offset); - int (*get_rxlos)(struct ioexp_obj_s *self, int virt_offset); - int (*get_tx_disable)(struct ioexp_obj_s *self, int virt_offset); - int (*get_reset)(struct ioexp_obj_s *self, int virt_offset); - int (*get_lpmod)(struct ioexp_obj_s *self, int virt_offset); - int (*get_modsel)(struct ioexp_obj_s *self, int virt_offset); - int (*get_hard_rs0)(struct ioexp_obj_s *self, int virt_offset); - int (*get_hard_rs1)(struct ioexp_obj_s *self, int virt_offset); - int (*set_tx_disable)(struct ioexp_obj_s *self, int virt_offset, int input_val); - int (*set_reset)(struct ioexp_obj_s *self, int virt_offset, int input_val); - int (*set_lpmod)(struct ioexp_obj_s *self, int virt_offset, int input_val); - int (*set_modsel)(struct ioexp_obj_s *self, int virt_offset, int input_val); - int (*set_hard_rs0)(struct ioexp_obj_s *self, int virt_offset, int input_val); - int (*set_hard_rs1)(struct ioexp_obj_s *self, int virt_offset, int input_val); - - /* =========================================== - * Object private functions - * =========================================== - */ - int (*init)(struct ioexp_obj_s *self); - int (*check)(struct ioexp_obj_s *self); - int (*update_all)(struct ioexp_obj_s *self, int show_err, char *caller_name); - int (*fsm_4_direct)(struct ioexp_obj_s* self); - int (*fsm_4_polling)(struct ioexp_obj_s* self); -}; - - -struct ioexp_obj_s* get_ioexp_obj(int ioexp_id); -int create_ioexp_obj(int ioexp_id, - int ioexp_type, - struct ioexp_addr_s *addr_map_p, - int run_mode); -int init_ioexp_objs(void); -int check_ioexp_objs(void); -void clean_ioexp_objs(void); - -void unlock_ioexp_all(void); -int lock_ioexp_all(void); - -int check_channel_tier_1(void); -int resync_channel_tier_1(void); - -/* Macro for bit control */ -#define SWP_BIT_SET(byte_val,bit_shift) ((byte_val) |= (1<<(bit_shift))) -#define SWP_BIT_CLEAR(byte_val,bit_shift) ((byte_val) &= ~(1<<(bit_shift))) - - -#endif /* IO_EXPANDER_H */ - - - - - diff --git a/packages/platforms/inventec/x86-64/d7264q28b/modules/builds/src/onie_tlvinfo.c b/packages/platforms/inventec/x86-64/d7264q28b/modules/builds/src/onie_tlvinfo.c deleted file mode 100644 index aaa3d5070..000000000 --- a/packages/platforms/inventec/x86-64/d7264q28b/modules/builds/src/onie_tlvinfo.c +++ /dev/null @@ -1,815 +0,0 @@ -#include -#include -#include -#include -//#include -#include - -//#include -//#include -#include "onie_tlvinfo.h" - -/* Set to 1 if we've read EEPROM into memory */ -static int has_been_read = 0; - -int read_sys_eeprom(struct i2c_client *pi2c_client,void *eeprom_data, int offset, int len); -int write_sys_eeprom(struct i2c_client *pi2c_client, void *eeprom_data, int len); - -static inline int is_multicast_ether_addr(const u_int8_t *addr) -{ - return 0x01 & addr[0]; -} - -static inline int is_zero_ether_addr(const u_int8_t *addr) -{ - return !(addr[0] | addr[1] | addr[2] | addr[3] | addr[4] | addr[5]); -} - -static inline int is_valid_ether_addr(const u_int8_t *addr) -{ - return !is_multicast_ether_addr(addr) && !is_zero_ether_addr(addr); -} - -#if 0 -static unsigned int crc32(unsigned char const *p, unsigned int len) -{ - int i; - unsigned int crc = 0; - while (len--) { - crc ^= *p++; - for (i = 0; i < 8; i++) - crc = (crc >> 1) ^ ((crc & 1) ? 0xedb88320 : 0); - } - return crc; -} -#else -static unsigned long crc32_tab[] = { - 0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f, - 0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988, - 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91, 0x1db71064, 0x6ab020f2, - 0xf3b97148, 0x84be41de, 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7, - 0x136c9856, 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, 0x14015c4f, 0x63066cd9, - 0xfa0f3d63, 0x8d080df5, 0x3b6e20c8, 0x4c69105e, 0xd56041e4, 0xa2677172, - 0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b, 0x35b5a8fa, 0x42b2986c, - 0xdbbbc9d6, 0xacbcf940, 0x32d86ce3, 0x45df5c75, 0xdcd60dcf, 0xabd13d59, - 0x26d930ac, 0x51de003a, 0xc8d75180, 0xbfd06116, 0x21b4f4b5, 0x56b3c423, - 0xcfba9599, 0xb8bda50f, 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924, - 0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d, 0x76dc4190, 0x01db7106, - 0x98d220bc, 0xefd5102a, 0x71b18589, 0x06b6b51f, 0x9fbfe4a5, 0xe8b8d433, - 0x7807c9a2, 0x0f00f934, 0x9609a88e, 0xe10e9818, 0x7f6a0dbb, 0x086d3d2d, - 0x91646c97, 0xe6635c01, 0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e, - 0x6c0695ed, 0x1b01a57b, 0x8208f4c1, 0xf50fc457, 0x65b0d9c6, 0x12b7e950, - 0x8bbeb8ea, 0xfcb9887c, 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, 0xfbd44c65, - 0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2, 0x4adfa541, 0x3dd895d7, - 0xa4d1c46d, 0xd3d6f4fb, 0x4369e96a, 0x346ed9fc, 0xad678846, 0xda60b8d0, - 0x44042d73, 0x33031de5, 0xaa0a4c5f, 0xdd0d7cc9, 0x5005713c, 0x270241aa, - 0xbe0b1010, 0xc90c2086, 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f, - 0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, 0x59b33d17, 0x2eb40d81, - 0xb7bd5c3b, 0xc0ba6cad, 0xedb88320, 0x9abfb3b6, 0x03b6e20c, 0x74b1d29a, - 0xead54739, 0x9dd277af, 0x04db2615, 0x73dc1683, 0xe3630b12, 0x94643b84, - 0x0d6d6a3e, 0x7a6a5aa8, 0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1, - 0xf00f9344, 0x8708a3d2, 0x1e01f268, 0x6906c2fe, 0xf762575d, 0x806567cb, - 0x196c3671, 0x6e6b06e7, 0xfed41b76, 0x89d32be0, 0x10da7a5a, 0x67dd4acc, - 0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5, 0xd6d6a3e8, 0xa1d1937e, - 0x38d8c2c4, 0x4fdff252, 0xd1bb67f1, 0xa6bc5767, 0x3fb506dd, 0x48b2364b, - 0xd80d2bda, 0xaf0a1b4c, 0x36034af6, 0x41047a60, 0xdf60efc3, 0xa867df55, - 0x316e8eef, 0x4669be79, 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236, - 0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f, 0xc5ba3bbe, 0xb2bd0b28, - 0x2bb45a92, 0x5cb36a04, 0xc2d7ffa7, 0xb5d0cf31, 0x2cd99e8b, 0x5bdeae1d, - 0x9b64c2b0, 0xec63f226, 0x756aa39c, 0x026d930a, 0x9c0906a9, 0xeb0e363f, - 0x72076785, 0x05005713, 0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38, - 0x92d28e9b, 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21, 0x86d3d2d4, 0xf1d4e242, - 0x68ddb3f8, 0x1fda836e, 0x81be16cd, 0xf6b9265b, 0x6fb077e1, 0x18b74777, - 0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c, 0x8f659eff, 0xf862ae69, - 0x616bffd3, 0x166ccf45, 0xa00ae278, 0xd70dd2ee, 0x4e048354, 0x3903b3c2, - 0xa7672661, 0xd06016f7, 0x4969474d, 0x3e6e77db, 0xaed16a4a, 0xd9d65adc, - 0x40df0b66, 0x37d83bf0, 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9, - 0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605, 0xcdd70693, - 0x54de5729, 0x23d967bf, 0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94, - 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d -}; - -static unsigned long crc32(unsigned char const *buf, unsigned int size) -{ - unsigned char *p = (unsigned char*)buf; - unsigned long crc = 0; - - crc = crc ^ ~0U; - - while (size--) - crc = crc32_tab[(crc ^ *p++) & 0xFF] ^ (crc >> 8); - - return crc ^ ~0U; -} -#endif - -static int set_bytes(char *buf, const char *string, int * converted_accum) -{ - char *p = (char *) string; - int i; - uint byte; - - if (!p) { - printk("ERROR: NULL string passed in.\n"); - return -1; - } - /* Convert string to bytes */ - for (i = 0, p = (char *)string; (i < TLV_VALUE_MAX_LEN) && (*p != 0); - i++) { - while ((*p == ' ') || (*p == '\t') || (*p == ',') || - (*p == ';')) { - p++; - } - if (*p != 0) { - if (!isdigit(*p)) { - printk("ERROR: Non-digit found in byte string: (%s)\n", string); - return -1; - } - byte = strtoul(p, &p, 0); - if (byte >= 256) { - printk("ERROR: The value specified is greater than 255: (%u) " \ - "in string: %s\n", byte, string); - return -1; - } - buf[i] = byte & 0xFF; - } - } - if ((i == TLV_VALUE_MAX_LEN) && (*p != 0)) { - printk("ERROR: Trying to assign too many bytes " - "(max: %d) in string: %s\n", TLV_VALUE_MAX_LEN, string); - return -1; - } - *converted_accum = i; - return 0; -} - -/* - * set_date - * - * Validates the format of the data string - * - * This function takes a pointer to a date string (i.e. MM/DD/YYYY hh:mm:ss) - * and validates that the format is correct. If so the string is copied - * to the supplied buffer. - */ -static int set_date(char *buf, const char *string) -{ - int i; - - if (!string) { - printk("ERROR: NULL date string passed in.\n"); - return -1; - } - if (strlen(string) != 19) { - printk("ERROR: Date strlen() != 19 -- %zd\n", strlen(string)); - printk("ERROR: Bad date format (MM/DD/YYYY hh:mm:ss): %s\n", string); - return -1; - } - for (i = 0; string[i] != 0; i++) { - switch (i) { - case 2: - case 5: - if (string[i] != '/') { - printk("ERROR: Bad date format (MM/DD/YYYY hh:mm:ss): %s\n", - string); - return -1; - } - break; - case 10: - if (string[i] != ' ') { - printk("ERROR: Bad date format (MM/DD/YYYY hh:mm:ss): %s\n", - string); - return -1; - } - break; - case 13: - case 16: - if (string[i] != ':') { - printk("ERROR: Bad date format (MM/DD/YYYY hh:mm:ss): %s\n", - string); - return -1; - } - break; - default: - if (!isdigit(string[i])) { - printk("ERROR: Bad date format (MM/DD/YYYY hh:mm:ss): %s\n", - string); - return -1; - } - break; - } - } - strcpy(buf, string); - return 0; -} - -/* - * is_valid_tlv - * - * Perform basic sanity checks on a TLV field. The TLV is pointed to - * by the parameter provided. - * 1. The type code is not reserved (0x00 or 0xFF) - */ -static inline bool is_valid_tlv(tlvinfo_tlv_t *tlv) -{ - return((tlv->type != 0x00) && (tlv->type != 0xFF)); -} - -/* - * set_mac - * - * Converts a string MAC address into a binary buffer. - * - * This function takes a pointer to a MAC address string - * (i.e."XX:XX:XX:XX:XX:XX", where "XX" is a two-digit hex number). - * The string format is verified and then converted to binary and - * stored in a buffer. - */ -static int set_mac(char *buf, const char *string) -{ - char *p = (char *) string; - int i; - int err = 0; - char *end; - - if (!p) { - printk("ERROR: NULL mac addr string passed in.\n"); - return -1; - } - if (strlen(p) != 17) { - printk("ERROR: MAC address strlen() != 17 -- %zd\n", strlen(p)); - printk("ERROR: Bad MAC address format: %s\n", string); - return -1; - } - for (i = 0; i < 17; i++) { - if ((i % 3) == 2) { - if (p[i] != ':') { - err++; - printk("ERROR: mac: p[%i] != :, found: `%c'\n", - i, p[i]); - break; - } - continue; - } else if (!isxdigit(p[i])) { - err++; - printk("ERROR: mac: p[%i] != hex digit, found: `%c'\n", - i, p[i]); - break; - } - } - if (err != 0) { - printk("ERROR: Bad MAC address format: %s\n", string); - return -1; - } - /* Convert string to binary */ - for (i = 0, p = (char *)string; i < 6; i++) { - buf[i] = p ? strtoul(p, &end, 16) : 0; - if (p) { - p = (*end) ? end + 1 : end; - } - } - if (!is_valid_ether_addr((char *)buf)) { - printk("ERROR: MAC address must not be 00:00:00:00:00:00, " - "a multicast address or FF:FF:FF:FF:FF:FF.\n"); - printk("ERROR: Bad MAC address format: %s\n", string); - return -1; - } - return 0; -} - -/* - * is_valid_tlvinfo_header - * - * Perform sanity checks on the first 11 bytes of the TlvInfo EEPROM - * data pointed to by the parameter: - * 1. First 8 bytes contain null-terminated ASCII string "TlvInfo" - * 2. Version byte is 1 - * 3. Total length bytes contain value which is less than or equal - * to the allowed maximum (2048-11) - * - */ -static inline bool is_valid_tlvinfo_header(tlvinfo_header_t *hdr) -{ - int max_size = TLV_TOTAL_LEN_MAX; - return((strcmp(hdr->signature, TLV_INFO_ID_STRING) == 0) && - (hdr->version == TLV_INFO_VERSION) && - (be16_to_cpu(hdr->totallen) <= max_size) ); -} - -/* - * decode_tlv_value - * - * Decode a single TLV value into a string. - - * The validity of EEPROM contents and the TLV field have been verified - * prior to calling this function. - */ -#define DECODE_NAME_MAX 20 - -static void decode_tlv_value(tlvinfo_tlv_t * tlv, char* value) -{ - int i; - - switch (tlv->type) { - case TLV_CODE_PRODUCT_NAME: - case TLV_CODE_PART_NUMBER: - case TLV_CODE_SERIAL_NUMBER: - case TLV_CODE_MANUF_DATE: - case TLV_CODE_LABEL_REVISION: - case TLV_CODE_PLATFORM_NAME: - case TLV_CODE_ONIE_VERSION: - case TLV_CODE_MANUF_NAME: - case TLV_CODE_MANUF_COUNTRY: - case TLV_CODE_VENDOR_NAME: - case TLV_CODE_DIAG_VERSION: - case TLV_CODE_SERVICE_TAG: - memcpy(value, tlv->value, tlv->length); - value[tlv->length] = 0; - break; - case TLV_CODE_MAC_BASE: - snprintf(value, MAX_STRING_SIZE, "%02X:%02X:%02X:%02X:%02X:%02X", - tlv->value[0], tlv->value[1], tlv->value[2], - tlv->value[3], tlv->value[4], tlv->value[5]); - break; - case TLV_CODE_DEVICE_VERSION: - snprintf(value, MAX_STRING_SIZE, "%u", tlv->value[0]); - break; - case TLV_CODE_MAC_SIZE: - snprintf(value, MAX_STRING_SIZE, "%u", (tlv->value[0] << 8) | tlv->value[1]); - break; - case TLV_CODE_VENDOR_EXT: - value[0] = 0; - for (i = 0; (i < (TLV_DECODE_VALUE_MAX_LEN/5)) && (i < tlv->length); - i++) { - snprintf(value, MAX_STRING_SIZE, "%s 0x%02X", value, tlv->value[i]); - } - break; - case TLV_CODE_CRC_32: - snprintf(value, MAX_STRING_SIZE, "0x%02X%02X%02X%02X", - tlv->value[0], tlv->value[1], tlv->value[2], - tlv->value[3]); - break; - default: - value[0] = 0; - for (i = 0; (i < (TLV_DECODE_VALUE_MAX_LEN/5)) && (i < tlv->length); - i++) { - snprintf(value, MAX_STRING_SIZE, "%s 0x%02X", value, tlv->value[i]); - } - break; - } - -} - -/* - * is_checksum_valid - * - * Validate the checksum in the provided TlvInfo EEPROM data. First, - * verify that the TlvInfo header is valid, then make sure the last - * TLV is a CRC-32 TLV. Then calculate the CRC over the EEPROM data - * and compare it to the value stored in the EEPROM CRC-32 TLV. - */ -static bool is_checksum_valid(u_int8_t *eeprom) -{ - tlvinfo_header_t * eeprom_hdr = (tlvinfo_header_t *) eeprom; - tlvinfo_tlv_t * eeprom_crc; - unsigned int calc_crc; - unsigned int stored_crc; - - // Is the eeprom header valid? - if (!is_valid_tlvinfo_header(eeprom_hdr)) { - return(FALSE); - } - - // Is the last TLV a CRC? - eeprom_crc = (tlvinfo_tlv_t *) &eeprom[sizeof(tlvinfo_header_t) + - be16_to_cpu(eeprom_hdr->totallen) - - (sizeof(tlvinfo_tlv_t) + 4)]; - if ((eeprom_crc->type != TLV_CODE_CRC_32) || (eeprom_crc->length != 4)) { - return(FALSE); - } - - // Calculate the checksum - calc_crc = crc32((void *)eeprom, sizeof(tlvinfo_header_t) + - be16_to_cpu(eeprom_hdr->totallen) - 4); - stored_crc = ((eeprom_crc->value[0] << 24) | (eeprom_crc->value[1] << 16) | - (eeprom_crc->value[2] << 8) | eeprom_crc->value[3]); - - //printk(KERN_ERR "[SWPS] cal_crc =0x%x, stored_crc =0x%x\n", calc_crc, stored_crc); - //return(calc_crc == stored_crc); - return 1; -} - -/* - * update_crc - * - * This function updates the CRC-32 TLV. If there is no CRC-32 TLV, then - * one is added. This function should be called after each update to the - * EEPROM structure, to make sure the CRC is always correct. - */ -static void update_crc(u_int8_t *eeprom) -{ - tlvinfo_header_t * eeprom_hdr = (tlvinfo_header_t *) eeprom; - tlvinfo_tlv_t * eeprom_crc; - unsigned int calc_crc; - - // Is the eeprom header valid? - if (!is_valid_tlvinfo_header(eeprom_hdr)) { - return; - } - // Is the last TLV a CRC? - eeprom_crc = (tlvinfo_tlv_t *) &eeprom[sizeof(tlvinfo_header_t) + - be16_to_cpu(eeprom_hdr->totallen) - - (sizeof(tlvinfo_tlv_t) + 4)]; - if (eeprom_crc->type != TLV_CODE_CRC_32) { - if ((be16_to_cpu(eeprom_hdr->totallen) + sizeof(tlvinfo_tlv_t) + 4) > - TLV_TOTAL_LEN_MAX) { - return; - } - eeprom_crc = (tlvinfo_tlv_t *) &eeprom[sizeof(tlvinfo_header_t) + - be16_to_cpu( - eeprom_hdr->totallen)]; - eeprom_hdr->totallen = cpu_to_be16(be16_to_cpu(eeprom_hdr->totallen) + - sizeof(tlvinfo_tlv_t) + 4); - eeprom_crc->type = TLV_CODE_CRC_32; - } - eeprom_crc->length = 4; - - // Calculate the checksum - calc_crc = crc32((void *)eeprom, - sizeof(tlvinfo_header_t) + - be16_to_cpu(eeprom_hdr->totallen) - 4); - - eeprom_crc->value[0] = (calc_crc >> 24) & 0xFF; - eeprom_crc->value[1] = (calc_crc >> 16) & 0xFF; - eeprom_crc->value[2] = (calc_crc >> 8) & 0xFF; - eeprom_crc->value[3] = (calc_crc >> 0) & 0xFF; -} - -/* - * show_eeprom - * - * Display the contents of the EEPROM - */ - -/* - * read_eeprom - * - * Read the EEPROM into memory, if it hasn't already been read. - */ -int read_eeprom( struct i2c_client *pi2c_client, u_int8_t *eeprom) -{ - int ret; - tlvinfo_header_t *eeprom_hdr = (tlvinfo_header_t *) eeprom; - tlvinfo_tlv_t *eeprom_tlv = (tlvinfo_tlv_t *)&eeprom[ - sizeof(tlvinfo_header_t)]; - - if (has_been_read) - return 0; - - /* Read the header */ - ret = read_sys_eeprom( pi2c_client,(void *)eeprom_hdr, 0, sizeof(tlvinfo_header_t)); - /* If the header was successfully read, read the TLVs */ - if ((ret == 0) && is_valid_tlvinfo_header(eeprom_hdr)) { - ret = read_sys_eeprom( pi2c_client, (void *)eeprom_tlv, sizeof(tlvinfo_header_t), - be16_to_cpu(eeprom_hdr->totallen)); - } - // If the contents are invalid, start over with default contents - if(!is_valid_tlvinfo_header(eeprom_hdr)) - printk(KERN_ERR - "Notice: Invalid TLV header found. Using default contents--1.\n"); - if(!is_checksum_valid(eeprom)) - printk(KERN_ERR - "Notice: Invalid TLV checksum found. Using default contents--2.\n"); - if ( !is_valid_tlvinfo_header(eeprom_hdr) || !is_checksum_valid(eeprom) ){ - strcpy(eeprom_hdr->signature, TLV_INFO_ID_STRING); - eeprom_hdr->version = TLV_INFO_VERSION; - eeprom_hdr->totallen = cpu_to_be16(0); - update_crc(eeprom); - } - has_been_read = 1; - - return ret; -} - -/* - * prog_eeprom - * Write the EEPROM data from CPU memory to the hardware. - */ -int prog_eeprom(struct i2c_client *pi2c_client, u_int8_t * eeprom) -{ - int ret = 0; - tlvinfo_header_t * eeprom_hdr = (tlvinfo_header_t *) eeprom; - int eeprom_len; - - eeprom_len = sizeof(tlvinfo_header_t) + be16_to_cpu(eeprom_hdr->totallen); - ret = write_sys_eeprom( pi2c_client, eeprom, eeprom_len); - if (ret) { - printk("Programming failed.\n"); - return -1; - } - has_been_read = 0; - return 0; -} - -/* - * tlvinfo_find_tlv - * - * This function finds the TLV with the supplied code in the EERPOM. - * An offset from the beginning of the EEPROM is returned in the - * eeprom_index parameter if the TLV is found. - */ -bool tlvinfo_find_tlv(u_int8_t *eeprom, u_int8_t tcode, - int *eeprom_index) -{ - tlvinfo_header_t * eeprom_hdr = (tlvinfo_header_t *) eeprom; - tlvinfo_tlv_t * eeprom_tlv; - int eeprom_end; - - // Make sure the EEPROM contents are valid - if (!is_valid_tlvinfo_header(eeprom_hdr) || !is_checksum_valid(eeprom)) { - return(FALSE); - } - // Search through the TLVs, looking for the first one which matches the - // supplied type code. - *eeprom_index = sizeof(tlvinfo_header_t); - eeprom_end = sizeof(tlvinfo_header_t) + be16_to_cpu(eeprom_hdr->totallen); - - while (*eeprom_index < eeprom_end) { - eeprom_tlv = (tlvinfo_tlv_t *) &eeprom[*eeprom_index]; - if (!is_valid_tlv(eeprom_tlv)) { - return(FALSE); - } - if (eeprom_tlv->type == tcode) { - return(TRUE); - } - *eeprom_index += sizeof(tlvinfo_tlv_t) + eeprom_tlv->length; - } - return(FALSE); -} - -/* - * tlvinfo_decode_tlv - * - * This function finds the TLV with the supplied code in the EERPOM - * and decodes the value into the buffer provided. - */ -bool tlvinfo_decode_tlv(u_int8_t *eeprom, u_int8_t tcode, char* value) -{ - int eeprom_index; - tlvinfo_tlv_t * eeprom_tlv; - - // Find the TLV and then decode it - - if (tlvinfo_find_tlv(eeprom, tcode, &eeprom_index)) { - eeprom_tlv = (tlvinfo_tlv_t *) &eeprom[eeprom_index]; - decode_tlv_value(eeprom_tlv, value); - return TRUE; - } - - return FALSE; -} - -/* - * tlvinfo_delete_tlv - * - * This function deletes the TLV with the specified type code from the - * EEPROM. - */ -bool tlvinfo_delete_tlv(u_int8_t * eeprom, u_int8_t code) -{ - int eeprom_index; - int tlength; - tlvinfo_header_t * eeprom_hdr = (tlvinfo_header_t *) eeprom; - tlvinfo_tlv_t * eeprom_tlv; - - // Find the TLV and then move all following TLVs "forward" - if (tlvinfo_find_tlv(eeprom, code, &eeprom_index)) { - eeprom_tlv = (tlvinfo_tlv_t *) &eeprom[eeprom_index]; - tlength = sizeof(tlvinfo_tlv_t) + eeprom_tlv->length; - memcpy(&eeprom[eeprom_index], &eeprom[eeprom_index+tlength], - sizeof(tlvinfo_header_t) + be16_to_cpu(eeprom_hdr->totallen) - - eeprom_index - tlength); - eeprom_hdr->totallen = cpu_to_be16(be16_to_cpu(eeprom_hdr->totallen) - - tlength); - update_crc(eeprom); - return(TRUE); - } - return(FALSE); -} - -/* - * tlvinfo_add_tlv - * - * This function adds a TLV to the EEPROM, converting the value (a string) to - * the format in which it will be stored in the EEPROM. - */ -#define MAX_TLV_VALUE_LEN 256 -bool tlvinfo_add_tlv(u_int8_t * eeprom, int tcode, const char *strval) -{ - tlvinfo_header_t * eeprom_hdr = (tlvinfo_header_t *) eeprom; - tlvinfo_tlv_t * eeprom_tlv; - int new_tlv_len = 0; - u_int32_t value; - char data[MAX_TLV_VALUE_LEN]; - int eeprom_index; - int max_size = TLV_TOTAL_LEN_MAX; - - // Encode each TLV type into the format to be stored in the EERPOM - switch (tcode) { - case TLV_CODE_PRODUCT_NAME: - case TLV_CODE_PART_NUMBER: - case TLV_CODE_SERIAL_NUMBER: - case TLV_CODE_LABEL_REVISION: - case TLV_CODE_PLATFORM_NAME: - case TLV_CODE_ONIE_VERSION: - case TLV_CODE_MANUF_NAME: - case TLV_CODE_MANUF_COUNTRY: - case TLV_CODE_VENDOR_NAME: - case TLV_CODE_DIAG_VERSION: - case TLV_CODE_SERVICE_TAG: - strncpy(data, strval, MAX_TLV_VALUE_LEN); - - if( strlen(strval) >= MAX_TLV_VALUE_LEN ) - new_tlv_len = MAX_TLV_VALUE_LEN; - else - new_tlv_len = strlen(strval); - - break; - case TLV_CODE_DEVICE_VERSION: - value = strtoul(strval, NULL, 0); - if (value >= 256) { - printk("ERROR: Device version must be 255 or less. Value " \ - "supplied: %u", value); - return(FALSE); - } - data[0] = value & 0xFF; - new_tlv_len = 1; - break; - case TLV_CODE_MAC_SIZE: - value = strtoul(strval, NULL, 0); - if (value >= 65536) { - printk("ERROR: MAC Size must be 65535 or less. Value " \ - "supplied: %u", value); - return(FALSE); - } - data[0] = (value >> 8) & 0xFF; - data[1] = value & 0xFF; - new_tlv_len = 2; - break; - case TLV_CODE_MANUF_DATE: - if (set_date(data, strval) != 0) { - return(FALSE); - } - new_tlv_len = 19; - break; - case TLV_CODE_MAC_BASE: - if (set_mac(data, strval) != 0) { - return(FALSE); - } - new_tlv_len = 6; - break; - case TLV_CODE_CRC_32: - printk("WARNING: The CRC TLV is set automatically and cannot be set " \ - "manually.\n"); - return(FALSE); - case TLV_CODE_VENDOR_EXT: - default: - if (set_bytes(data, strval, &new_tlv_len) != 0 ) { - return(FALSE); - } - break; - } - - // Is there room for this TLV? - if ((be16_to_cpu(eeprom_hdr->totallen) + sizeof(tlvinfo_tlv_t) + - new_tlv_len) > max_size) { - printk("ERROR: There is not enough room in the EERPOM to save data.\n"); - return(FALSE); - } - - // Add TLV at the end, overwriting CRC TLV if it exists - if (tlvinfo_find_tlv(eeprom, TLV_CODE_CRC_32, &eeprom_index)) { - eeprom_hdr->totallen = cpu_to_be16(be16_to_cpu(eeprom_hdr->totallen) - - sizeof(tlvinfo_tlv_t) - 4); - } else { - eeprom_index = sizeof(tlvinfo_header_t) + - be16_to_cpu(eeprom_hdr->totallen); - } - eeprom_tlv = (tlvinfo_tlv_t *) &eeprom[eeprom_index]; - eeprom_tlv->type = tcode; - eeprom_tlv->length = new_tlv_len; - memcpy(eeprom_tlv->value, data, new_tlv_len); - - // Update the total length and calculate (add) a new CRC-32 TLV - eeprom_hdr->totallen = cpu_to_be16(be16_to_cpu(eeprom_hdr->totallen) + - sizeof(tlvinfo_tlv_t) + new_tlv_len); - update_crc(eeprom); - - return(TRUE); -} - -/* - * read_sys_eeprom - read the hwinfo from i2c EEPROM - */ -int read_sys_eeprom(struct i2c_client *pi2c_client,void *eeprom_data, int offset, int len) -{ - int iRet = 0; - int i = 0; - unsigned char ucBuf[2]; - u_int8_t *c; - unsigned short usAddr = SYS_EEPROM_OFFSET + offset; - - c = eeprom_data; - for (i = 0; i < len; i++) { - ucBuf[0] = (usAddr & 0xFF00) >> 8; - ucBuf[1] = (usAddr & 0x00FF); - - iRet = i2c_smbus_write_byte_data(pi2c_client, ucBuf[0], ucBuf[1]); - if( iRet < 0 ){ - printk(KERN_ERR"Error!! VPD data read error\n"); - return -1; - } - - *c = i2c_smbus_read_byte(pi2c_client); - c++; usAddr++; - } - return 0; -} - -/* - * write_sys_eeprom - write the hwinfo to i2c EEPROM - */ -int write_sys_eeprom(struct i2c_client *pi2c_client, void *eeprom_data, int len) -{ - int iRet = 0; - int i = 0; - u_int8_t *c; - unsigned short usAddr = SYS_EEPROM_OFFSET; - unsigned char ucBuf[3]; - - c = eeprom_data; - for (i = 0; i < len; i++) { - ucBuf[ 0 ] = (usAddr & 0xFF00) >>8 ; - ucBuf[ 1 ] = (usAddr & 0x00FF); - ucBuf[ 2 ] = *c; - - iRet = i2c_smbus_write_word_data( pi2c_client, ucBuf[0], (ucBuf[2] << 8 | ucBuf[1])); - if (iRet < 0 ){ - printk(KERN_ERR"Error!! VPD data write error . \n"); - return -1; - } - - c++; usAddr++; - msleep_interruptible(10); - } - - return 0; -} - -void update_eeprom_header(u_int8_t *eeprom) -{ - tlvinfo_header_t * eeprom_hdr = (tlvinfo_header_t *) eeprom; - - strcpy(eeprom_hdr->signature, TLV_INFO_ID_STRING); - eeprom_hdr->version = TLV_INFO_VERSION; - eeprom_hdr->totallen = cpu_to_be16(0); - update_crc(eeprom); -} -#if 0 -int find_vpd_data(u_int8_t *eeprom, int i_offset, char *c_buf) -{ - int tlv_end; - int curr_tlv; - tlvinfo_header_t * eeprom_hdr = (tlvinfo_header_t *) eeprom; - tlvinfo_tlv_t * eeprom_tlv; - int iFind = 0; - - if( !is_valid_tlvinfo_header(eeprom_hdr) ) { - printk(KERN_ERR"EEPROM does not contain data in a valid TlvInfo format.\n"); - return -1; - } - - curr_tlv = sizeof(tlvinfo_header_t); - tlv_end = sizeof(tlvinfo_header_t) + be16_to_cpu(eeprom_hdr->totallen); - while(curr_tlv < tlv_end){ - eeprom_tlv = (tlvinfo_tlv_t *) &eeprom[curr_tlv]; - if (!is_valid_tlv(eeprom_tlv)) { - printk(KERN_ERR"Invalid TLV field starting at EEPROM offset %d\n", - curr_tlv); - return -1; - } - - decode_tlv_value(eeprom_tlv, c_buf); - if( eeprom_tlv->type == i_offset){ - iFind = 1; - break; - } - curr_tlv += sizeof(tlvinfo_tlv_t) + eeprom_tlv->length; - } - - if( iFind == 0 ) - return -1; - else - return 0; -} -#endif diff --git a/packages/platforms/inventec/x86-64/d7264q28b/modules/builds/src/onie_tlvinfo.h b/packages/platforms/inventec/x86-64/d7264q28b/modules/builds/src/onie_tlvinfo.h deleted file mode 100644 index da0a07590..000000000 --- a/packages/platforms/inventec/x86-64/d7264q28b/modules/builds/src/onie_tlvinfo.h +++ /dev/null @@ -1,150 +0,0 @@ -/* - * The Definition of the TlvInfo EEPROM format can be found at onie.org or - * github.com/onie - */ -#include -#define strtoul simple_strtoul - -#define FALSE 0 -#define TRUE (!FALSE) -#define MAX_STRING_SIZE 128 -/* - * Tlvinf header: Layout of the header for the TlvInfo format - * - * See the end of this file for details of this eeprom format - */ -struct __attribute__ ((__packed__)) tlvinfo_header_s { - char signature[8]; /* 0x00 - 0x07 EEPROM Tag "TlvInfo" */ - u_int8_t version; /* 0x08 Structure version */ - u_int16_t totallen; /* 0x09 - 0x0A Length of all data which follows */ -}; -typedef struct tlvinfo_header_s tlvinfo_header_t; - -// Header Field Constants -#define TLV_INFO_ID_STRING "TlvInfo" -#define TLV_INFO_VERSION 0x01 -#define TLV_TOTAL_LEN_MAX (SYS_EEPROM_SIZE - sizeof(tlvinfo_header_t)) - -/* - * TlvInfo TLV: Layout of a TLV field - */ -struct __attribute__ ((__packed__)) tlvinfo_tlv_s { - u_int8_t type; - u_int8_t length; - u_int8_t value[0]; -}; -typedef struct tlvinfo_tlv_s tlvinfo_tlv_t; - -/* Maximum length of a TLV value in bytes */ -#define TLV_VALUE_MAX_LEN 255 - -/** - * The TLV Types. - * - * Keep these in sync with tlv_code_list in cmd_sys_eeprom.c - */ -#define TLV_CODE_PRODUCT_NAME 0x21 -#define TLV_CODE_PART_NUMBER 0x22 -#define TLV_CODE_SERIAL_NUMBER 0x23 -#define TLV_CODE_MAC_BASE 0x24 -#define TLV_CODE_MANUF_DATE 0x25 -#define TLV_CODE_DEVICE_VERSION 0x26 -#define TLV_CODE_LABEL_REVISION 0x27 -#define TLV_CODE_PLATFORM_NAME 0x28 -#define TLV_CODE_ONIE_VERSION 0x29 -#define TLV_CODE_MAC_SIZE 0x2A -#define TLV_CODE_MANUF_NAME 0x2B -#define TLV_CODE_MANUF_COUNTRY 0x2C -#define TLV_CODE_VENDOR_NAME 0x2D -#define TLV_CODE_DIAG_VERSION 0x2E -#define TLV_CODE_SERVICE_TAG 0x2F -#define TLV_CODE_VENDOR_EXT 0xFD -#define TLV_CODE_CRC_32 0xFE - -/* - * Struct for displaying the TLV codes and names. - */ -struct tlv_code_desc { - u_int8_t m_code; - char* m_name; -}; - -/* - * List of TLV codes and names. - */ -static const struct tlv_code_desc tlv_code_list[] = { - { TLV_CODE_PRODUCT_NAME , "Product Name"}, - { TLV_CODE_PART_NUMBER , "Part Number"}, - { TLV_CODE_SERIAL_NUMBER , "Serial Number"}, - { TLV_CODE_MAC_BASE , "Base MAC Address"}, - { TLV_CODE_MANUF_DATE , "Manufacture Date"}, - { TLV_CODE_DEVICE_VERSION , "Device Version"}, - { TLV_CODE_LABEL_REVISION , "Label Revision"}, - { TLV_CODE_PLATFORM_NAME , "Platform Name"}, - { TLV_CODE_ONIE_VERSION , "Loader Version"}, - { TLV_CODE_MAC_SIZE , "MAC Addresses"}, - { TLV_CODE_MANUF_NAME , "Manufacturer"}, - { TLV_CODE_MANUF_COUNTRY , "Country Code"}, - { TLV_CODE_VENDOR_NAME , "Vendor Name"}, - { TLV_CODE_DIAG_VERSION , "Diag Version"}, - { TLV_CODE_SERVICE_TAG , "Service Tag"}, - { TLV_CODE_VENDOR_EXT , "Vendor Extension"}, - { TLV_CODE_CRC_32 , "CRC-32"}, -}; - -static inline const char* tlv_type2name(u_int8_t type) -{ - char* name = "Unknown"; - int i; - - for (i = 0; i < sizeof(tlv_code_list)/sizeof(tlv_code_list[0]); i++) { - if (tlv_code_list[i].m_code == type) { - name = tlv_code_list[i].m_name; - break; - } - } - return name; -} - -/* - * The max decode value is currently for the 'raw' type or the 'vendor - * extension' type, both of which have the same decode format. The - * max decode string size is computed as follows: - * - * strlen(" 0xFF") * TLV_VALUE_MAX_LEN + 1 - * - */ -#define TLV_DECODE_VALUE_MAX_LEN ((5 * TLV_VALUE_MAX_LEN) + 1) - - -/* - * Each platform must define the following platform-specific macros - * in sys_eeprom_platform.h: - * SYS_EEPROM_SIZE: size of usable eeprom - * SYS_EEPROM_I2C_DEVICE: i2c-bus - * SYS_EEPROM_I2C_ADDR: address on the bus - * The following may also be defined in sys_eeprom_platform.h, else - * the defaults with take over: - * SYS_EEPROM_MAX_SIZE: Total size of the eeprom - * SYS_EEPROM_OFFSET: offset from where the ONIE header starts - */ -#define SYS_EEPROM_MAX_SIZE 2048 -#define SYS_EEPROM_OFFSET 0 -#define SYS_EEPROM_SIZE SYS_EEPROM_MAX_SIZE -#define SYS_EEPROM_I2C_DEVICE "/dev/i2c-0" -#define SYS_EEPROM_I2C_ADDR 0x53 - -#if (SYS_EEPROM_SIZE + SYS_EEPROM_OFFSET > SYS_EEPROM_MAX_SIZE) - #error SYS_EEPROM_SIZE + SYS_EEPROM_OFFSET is greater than SYS_EEPROM_MAX_SIZE -#endif - -// Access functions to onie_tlvinfo -void show_eeprom(u_int8_t *eeprom); -int read_eeprom(struct i2c_client *pi2c_client, u_int8_t *eeprom); -int prog_eeprom(struct i2c_client *pi2c_client,u_int8_t * eeprom); -void update_eeprom_header(u_int8_t *eeprom); -bool tlvinfo_find_tlv(u_int8_t *eeprom, u_int8_t tcode, int *eeprom_index); -bool tlvinfo_delete_tlv(u_int8_t * eeprom, u_int8_t code); -bool tlvinfo_add_tlv(u_int8_t * eeprom, int tcode, const char *strval); -bool tlvinfo_decode_tlv(u_int8_t *eeprom, u_int8_t tcode, char* value); -//int find_vpd_data(u_int8_t *eeprom, int i_offset, char *c_buf); diff --git a/packages/platforms/inventec/x86-64/d7264q28b/modules/builds/src/transceiver.c b/packages/platforms/inventec/x86-64/d7264q28b/modules/builds/src/transceiver.c deleted file mode 100644 index 1b6c3b556..000000000 --- a/packages/platforms/inventec/x86-64/d7264q28b/modules/builds/src/transceiver.c +++ /dev/null @@ -1,8260 +0,0 @@ -#include -#include -#include -#include -#include "io_expander.h" -#include "transceiver.h" - - -/* ========== Register EEPROM address mapping ========== - */ -struct eeprom_map_s eeprom_map_sfp = { - .addr_br =0x50, .page_br =-1, .offset_br =12, .length_br =1, - .addr_cdr =-1, .page_cdr =-1, .offset_cdr =-1, .length_cdr =-1, - .addr_comp_rev =0x50, .page_comp_rev =-1, .offset_comp_rev =94, .length_comp_rev =1, - .addr_connector =0x50, .page_connector =-1, .offset_connector =2, .length_connector =1, - .addr_diag_type =0x50, .page_diag_type =-1, .offset_diag_type =92 , .length_diag_type =1, - .addr_extbr =-1, .page_extbr =-1, .offset_extbr =-1, .length_extbr =-1, - .addr_ext_id =0x50, .page_ext_id =-1, .offset_ext_id =1, .length_ext_id =1, - .addr_id =0x50, .page_id =-1, .offset_id =0, .length_id =1, - .addr_len_sm =0x50, .page_len_sm =-1, .offset_len_sm =15, .length_len_sm =1, - .addr_len_smf =0x50, .page_len_smf =-1, .offset_len_smf =14, .length_len_smf =1, - .addr_len_om1 =0x50, .page_len_om1 =-1, .offset_len_om1 =17, .length_len_om1 =1, - .addr_len_om2 =0x50, .page_len_om2 =-1, .offset_len_om2 =16, .length_len_om2 =1, - .addr_len_om3 =0x50, .page_len_om3 =-1, .offset_len_om3 =19, .length_len_om3 =1, - .addr_len_om4 =0x50, .page_len_om4 =-1, .offset_len_om4 =18, .length_len_om4 =1, - .addr_option =0x50, .page_option =-1, .offset_option =64, .length_option =2, - .addr_rate_id =0x50, .page_rate_id =-1, .offset_rate_id =13, .length_rate_id =1, - .addr_rx_am =-1, .page_rx_am =-1, .offset_rx_am =-1, .length_rx_am =-1, - .addr_rx_em =0x51, .page_rx_em =-1, .offset_rx_em =115, .length_rx_em =1, - .addr_rx_los =-1, .page_rx_los =-1, .offset_rx_los =-1, .length_rx_los =-1, - .addr_rx_power =0x51, .page_rx_power =-1, .offset_rx_power =104, .length_rx_power =2, - .addr_soft_rs0 =0x51, .page_soft_rs0 =-1, .offset_soft_rs0 =110, .length_soft_rs0 =1, - .addr_soft_rs1 =0x51, .page_soft_rs1 =-1, .offset_soft_rs1 =118, .length_soft_rs0 =1, - .addr_temp =0x51, .page_temp =-1, .offset_temp =96, .length_temp =2, - .addr_trancomp =0x50, .page_trancomp =-1, .offset_trancomp =3, .length_trancomp =8, - .addr_trancomp_ext =0x50, .page_trancomp_ext =-1, .offset_trancomp_ext =36, .length_trancomp_ext =1, - .addr_tx_bias =0x51, .page_tx_bias =-1, .offset_tx_bias =100, .length_tx_bias =2, - .addr_tx_disable =-1, .page_tx_disable =-1, .offset_tx_disable =-1, .length_tx_disable =-1, - .addr_tx_eq =0x51, .page_tx_eq =-1, .offset_tx_eq =114, .length_tx_eq =1, - .addr_tx_fault =-1, .page_tx_fault =-1, .offset_tx_fault =-1, .length_tx_fault =-1, - .addr_tx_power =0x51, .page_tx_power =-1, .offset_tx_power =102, .length_tx_power =2, - .addr_vendor_name =0x50, .page_vendor_name =-1, .offset_vendor_name =20, .length_vendor_name =16, - .addr_vendor_pn =0x50, .page_vendor_pn =-1, .offset_vendor_pn =40, .length_vendor_pn =16, - .addr_vendor_rev =0x50, .page_vendor_rev =-1, .offset_vendor_rev =56, .length_vendor_rev =4, - .addr_vendor_sn =0x50, .page_vendor_sn =-1, .offset_vendor_sn =68, .length_vendor_sn =16, - .addr_voltage =0x51, .page_voltage =-1, .offset_voltage =98, .length_voltage =2, - .addr_wavelength =0x50, .page_wavelength =-1, .offset_wavelength =60, .length_wavelength =2, - .addr_eeprom =0x50, .page_eeprom =-1, .offset_eeprom =0, .length_eeprom =256, -}; - -struct eeprom_map_s eeprom_map_qsfp = { - .addr_br =0x50, .page_br =0, .offset_br =140, .length_br =1, - .addr_cdr =-1, .page_cdr =-1, .offset_cdr =-1, .length_cdr =-1, - .addr_comp_rev =0x50, .page_comp_rev =-1, .offset_comp_rev =1, .length_comp_rev =1, - .addr_connector =0x50, .page_connector =0, .offset_connector =130, .length_connector =1, - .addr_diag_type =0x50, .page_diag_type =0, .offset_diag_type =220, .length_diag_type =1, - .addr_extbr =0x50, .page_extbr =0, .offset_extbr =222, .length_extbr =1, - .addr_ext_id =0x50, .page_ext_id =0, .offset_ext_id =129, .length_ext_id =1, - .addr_id =0x50, .page_id =0, .offset_id =128, .length_id =1, - .addr_len_sm =-1, .page_len_sm =-1, .offset_len_sm =-1, .length_len_sm =-1, - .addr_len_smf =0x50, .page_len_smf =0, .offset_len_smf =142, .length_len_smf =1, - .addr_len_om1 =0x50, .page_len_om1 =0, .offset_len_om1 =145, .length_len_om1 =1, - .addr_len_om2 =0x50, .page_len_om2 =0, .offset_len_om2 =144, .length_len_om2 =1, - .addr_len_om3 =0x50, .page_len_om3 =0, .offset_len_om3 =143, .length_len_om3 =1, - .addr_len_om4 =0x50, .page_len_om4 =0, .offset_len_om4 =146, .length_len_om4 =1, - .addr_option =0x50, .page_option =0, .offset_option =193, .length_option =3, - .addr_rate_id =-1, .page_rate_id =-1, .offset_rate_id =-1, .length_rate_id =-1, - .addr_rx_am =-1, .page_rx_am =-1, .offset_rx_am =-1, .length_rx_am =-1, - .addr_rx_em =-1, .page_rx_em =-1, .offset_rx_em =-1, .length_rx_em =-1, - .addr_rx_los =0x50, .page_rx_los =-1, .offset_rx_los =3, .length_rx_los =1, - .addr_rx_power =0x50, .page_rx_power =-1, .offset_rx_power =34, .length_rx_power =8, - .addr_soft_rs0 =-1, .page_soft_rs0 =-1, .offset_soft_rs0 =-1, .length_soft_rs0 =-1, - .addr_soft_rs1 =-1, .page_soft_rs1 =-1, .offset_soft_rs1 =-1, .length_soft_rs0 =-1, - .addr_temp =0x50, .page_temp =-1, .offset_temp =22, .length_temp =2, - .addr_trancomp =0x50, .page_trancomp =0, .offset_trancomp =131, .length_trancomp =8, - .addr_trancomp_ext =0x50, .page_trancomp_ext =0, .offset_trancomp_ext =192, .length_trancomp_ext =1, - .addr_tx_bias =0x50, .page_tx_bias =-1, .offset_tx_bias =42, .length_tx_bias =8, - .addr_tx_disable =0x50, .page_tx_disable =-1, .offset_tx_disable =86, .length_tx_disable =1, - .addr_tx_eq =-1, .page_tx_eq =-1, .offset_tx_eq =-1, .length_tx_eq =-1, - .addr_tx_fault =0x50, .page_tx_fault =-1, .offset_tx_fault =4, .length_tx_fault =1, - .addr_tx_power =0x50, .page_tx_power =-1, .offset_tx_power =50, .length_tx_power =8, - .addr_vendor_name =0x50, .page_vendor_name =0, .offset_vendor_name =148, .length_vendor_name =16, - .addr_vendor_pn =0x50, .page_vendor_pn =0, .offset_vendor_pn =168, .length_vendor_pn =16, - .addr_vendor_rev =0x50, .page_vendor_rev =0, .offset_vendor_rev =184, .length_vendor_rev =2, - .addr_vendor_sn =0x50, .page_vendor_sn =0, .offset_vendor_sn =196, .length_vendor_sn =16, - .addr_voltage =0x50, .page_voltage =-1, .offset_voltage =26, .length_voltage =2, - .addr_wavelength =0x50, .page_wavelength =0, .offset_wavelength =186, .length_wavelength =2, - .addr_eeprom =0x50, .page_eeprom =0, .offset_eeprom =0, .length_eeprom =256, -}; - -struct eeprom_map_s eeprom_map_qsfp28 = { - .addr_br =0x50, .page_br =0, .offset_br =140, .length_br =1, - .addr_cdr =0x50, .page_cdr =-1, .offset_cdr =98, .length_cdr =1, - .addr_comp_rev =0x50, .page_comp_rev =-1, .offset_comp_rev =1, .length_comp_rev =1, - .addr_connector =0x50, .page_connector =0, .offset_connector =130, .length_connector =1, - .addr_diag_type =0x50, .page_diag_type =0, .offset_diag_type =220, .length_diag_type =1, - .addr_extbr =0x50, .page_extbr =0, .offset_extbr =222, .length_extbr =1, - .addr_ext_id =0x50, .page_ext_id =0, .offset_ext_id =129, .length_ext_id =1, - .addr_id =0x50, .page_id =0, .offset_id =128, .length_id =1, - .addr_len_sm =-1, .page_len_sm =-1, .offset_len_sm =-1, .length_len_sm =-1, - .addr_len_smf =0x50, .page_len_smf =0, .offset_len_smf =142, .length_len_smf =1, - .addr_len_om1 =0x50, .page_len_om1 =0, .offset_len_om1 =145, .length_len_om1 =1, - .addr_len_om2 =0x50, .page_len_om2 =0, .offset_len_om2 =144, .length_len_om2 =1, - .addr_len_om3 =0x50, .page_len_om3 =0, .offset_len_om3 =143, .length_len_om3 =1, - .addr_len_om4 =0x50, .page_len_om4 =0, .offset_len_om4 =146, .length_len_om4 =1, - .addr_option =0x50, .page_option =0, .offset_option =193, .length_option =3, - .addr_rate_id =-1, .page_rate_id =-1, .offset_rate_id =-1, .length_rate_id =-1, - .addr_rx_am =0x50, .page_rx_am =3, .offset_rx_am =238, .length_rx_am =2, - .addr_rx_em =0x50, .page_rx_em =3, .offset_rx_em =236, .length_rx_em =2, - .addr_rx_los =0x50, .page_rx_los =-1, .offset_rx_los =3, .length_rx_los =1, - .addr_rx_power =0x50, .page_rx_power =-1, .offset_rx_power =34, .length_rx_power =8, - .addr_soft_rs0 =-1, .page_soft_rs0 =-1, .offset_soft_rs0 =-1, .length_soft_rs0 =-1, - .addr_soft_rs1 =-1, .page_soft_rs1 =-1, .offset_soft_rs1 =-1, .length_soft_rs0 =-1, - .addr_temp =0x50, .page_temp =-1, .offset_temp =22, .length_temp =2, - .addr_trancomp =0x50, .page_trancomp =0, .offset_trancomp =131, .length_trancomp =8, - .addr_trancomp_ext =0x50, .page_trancomp_ext =0, .offset_trancomp_ext =192, .length_trancomp_ext =1, - .addr_tx_bias =0x50, .page_tx_bias =-1, .offset_tx_bias =42, .length_tx_bias =8, - .addr_tx_disable =0x50, .page_tx_disable =-1, .offset_tx_disable =86, .length_tx_disable =1, - .addr_tx_eq =0x50, .page_tx_eq =3, .offset_tx_eq =234, .length_tx_eq =2, - .addr_tx_fault =0x50, .page_tx_fault =-1, .offset_tx_fault =4, .length_tx_fault =1, - .addr_tx_power =0x50, .page_tx_power =-1, .offset_tx_power =50, .length_tx_power =8, - .addr_vendor_name =0x50, .page_vendor_name =0, .offset_vendor_name =148, .length_vendor_name =16, - .addr_vendor_pn =0x50, .page_vendor_pn =0, .offset_vendor_pn =168, .length_vendor_pn =16, - .addr_vendor_rev =0x50, .page_vendor_rev =0, .offset_vendor_rev =184, .length_vendor_rev =2, - .addr_vendor_sn =0x50, .page_vendor_sn =0, .offset_vendor_sn =196, .length_vendor_sn =16, - .addr_voltage =0x50, .page_voltage =-1, .offset_voltage =26, .length_voltage =2, - .addr_wavelength =0x50, .page_wavelength =0, .offset_wavelength =186, .length_wavelength =2, - .addr_eeprom =0x50, .page_eeprom =0, .offset_eeprom =0, .length_eeprom =256, -}; - - -/* ========== Utility Functions ========== - */ -static int -get_bit(uint8_t origin_byte, int bit_shift) { - return (int)((origin_byte >> bit_shift) & 0x1); -} - -static int -transform_word_to_int(uint8_t hight_byte, - uint8_t low_byte) { - return ((((int)hight_byte) << 8) + (int)low_byte); -} - -void -alarm_msg_2_user(struct transvr_obj_s *self, - char *emsg) { - - SWPS_ERR("%s on %s.\n", emsg, self->swp_name); -} - - -/* ========== Private functions ========== - */ -static int -_reload_transvr_obj(struct transvr_obj_s *self,int new_type); - -static int -reload_transvr_obj(struct transvr_obj_s *self,int new_type); - -static int -_is_transvr_support_ctle(struct transvr_obj_s *self); - -static int -_transvr_init_handler(struct transvr_obj_s *self); - -int -_transvr_clean_handler(struct transvr_obj_s *self); - -int -_sfp_detect_class_by_1g_ethernet(struct transvr_obj_s* self); - - -void -lock_transvr_obj(struct transvr_obj_s *self) { - - mutex_lock(&self->lock); - self->curr_page = VAL_TRANSVR_PAGE_FREE; -} - - -void -unlock_transvr_obj(struct transvr_obj_s *self) { - - self->curr_page = VAL_TRANSVR_PAGE_FREE; - mutex_unlock(&self->lock); -} - - -static int -_check_by_mode(struct transvr_obj_s *self, - int (*attr_update_func)(struct transvr_obj_s *self, int show_err), - char *caller_name){ - - int return_val = ERR_TRANSVR_UNEXCPT; - - switch (self->mode){ - case TRANSVR_MODE_POLLING: - switch (self->state){ - case STATE_TRANSVR_CONNECTED: - goto ok_check_by_mode_1; - case STATE_TRANSVR_NEW: - case STATE_TRANSVR_INIT: - return ERR_TRANSVR_UNINIT; - case STATE_TRANSVR_DISCONNECTED: - return ERR_TRANSVR_UNPLUGGED; - case STATE_TRANSVR_UNEXCEPTED: - return ERR_TRANSVR_ABNORMAL; - case STATE_TRANSVR_ISOLATED: - return ERR_TRNASVR_BE_ISOLATED; - default: - goto err_check_by_mode_1; - } - goto ok_check_by_mode_1; - - case TRANSVR_MODE_DIRECT: - return_val = self->fsm_4_direct(self, caller_name); - if (return_val < 0){ - return return_val; - } - goto ok_check_by_mode_1; - - default: - goto err_check_by_mode_1; - } - goto ok_check_by_mode_1; - -ok_check_by_mode_1: - return attr_update_func(self, 0); - -err_check_by_mode_1: - SWPS_INFO("_check_by_mode: mode:%d state:%d\n", self->mode, self->state); - return ERR_TRANSVR_UNEXCPT; -} - - -static void -_transvr_clean_retry(struct transvr_obj_s *self) { - self->retry = 0; -} - - -static int -_transvr_handle_retry(struct transvr_obj_s *self, int retry) { - /* Return: 0: keep retry - * -1: stop retry - */ - if (self->retry == 0) { - self->retry = retry; - } - self->retry -= 1; - if (self->retry <= 0) { - _transvr_clean_retry(self); - return -1; - } - return 0; -} - - -static int -_common_setup_page(struct transvr_obj_s *self, - int addr, - int page, - int offset, - int len, - int show_e) { - /* return: - * 0 : OK - * -1 : EEPROM settings incorrect - * -2 : I2C R/W failure - * -3 : Undefined case - */ - int retval = DEBUG_TRANSVR_INT_VAL; - char *emsg = DEBUG_TRANSVR_STR_VAL; - - /* Check */ - if ((addr < 0) || (offset < 0) || (len < 0)) { - emsg = "EEPROM settings incorrect"; - retval = -1; - goto err_common_setup_page; - } - /* Case1: continue access */ - if ((self->i2c_client_p->addr == addr) && - (self->curr_page == page)) { - return 0; - } - self->i2c_client_p->addr = addr; - /* Case2: select lower page */ - if (page == -1) { - self->curr_page = page; - return 0; - } - /* Case3: select upper page */ - if (page >= 0) { - goto upper_common_setup_page; - } - /* Unexpected case */ - show_e = 1; - emsg = "Unexpected case"; - retval = -3; - goto err_common_setup_page; - -upper_common_setup_page: - if (i2c_smbus_write_byte_data(self->i2c_client_p, - VAL_TRANSVR_PAGE_SELECT_OFFSET, - page) < 0) { - emsg = "I2C R/W failure"; - retval = -2; - goto err_common_setup_page; - } - self->curr_page = page; - mdelay(VAL_TRANSVR_PAGE_SELECT_DELAY); - return 0; - -err_common_setup_page: - if (show_e) { - SWPS_INFO("%s: %s", __func__, emsg); - SWPS_INFO("%s: :0x%02x :%d :%d :%d\n", - __func__, addr, page, offset, len); - } - return retval; -} - -/* -static int -_common_setup_password(struct transvr_obj_s *self, - int addr, - int page, - int offs, - uint8_t pwd[4], - int show_e) { - int i = 0; - int err = DEBUG_TRANSVR_INT_VAL; - char *emsg = DEBUG_TRANSVR_STR_VAL; - - err = _common_setup_page(self, addr, page, offs, 4, show_e); - if (err < 0){ - emsg = "setup EEPROM page fail"; - goto err_common_setup_password; - } - for (i=0; i<4; i++) { - err = i2c_smbus_write_byte_data(self->i2c_client_p, - (offs + i), - pwd[i]); - if (err < 0){ - emsg = "I2C R/W fail!"; - goto err_common_setup_password; - } - } - return 0; - -err_common_setup_password: - if (show_e) { - SWPS_INFO("%s: %s :%d\n", __func__, emsg, err); - } - return ERR_TRANSVR_UPDATE_FAIL; -} -*/ - -static int -_common_update_uint8_attr(struct transvr_obj_s *self, - int addr, - int page, - int offset, - int len, - uint8_t *buf, - char *caller, - int show_e){ - - int i; - int err = DEBUG_TRANSVR_INT_VAL; - char *emsg = DEBUG_TRANSVR_STR_VAL; - - err = _common_setup_page(self, addr, page, offset, len, show_e); - if (err < 0){ - emsg = "setup EEPROM page fail"; - goto err_common_update_uint8_attr; - } - for (i=0; ii2c_client_p, (offset + i)); - if (err < 0){ - emsg = "I2C R/W fail!"; - goto err_common_update_uint8_attr; - } - buf[i] = err; - } - return 0; - -err_common_update_uint8_attr: - if (show_e) { - SWPS_INFO("%s: %s :%s :%d\n", - __func__, emsg, caller, err); - } - buf[0] = DEBUG_TRANSVR_HEX_VAL; - return ERR_TRANSVR_UPDATE_FAIL; -} - - -static int -_common_update_int_attr(struct transvr_obj_s *self, - int addr, - int page, - int offset, - int len, - int *buf, - char *caller, - int show_e){ - - int i; - int err = DEBUG_TRANSVR_INT_VAL; - char *emsg = DEBUG_TRANSVR_STR_VAL; - - err = _common_setup_page(self, addr, page, offset, len, show_e); - if (err < 0){ - emsg = "setup EEPROM page fail"; - goto err_common_update_int_attr; - } - for (i=0; ii2c_client_p, (offset + i)); - if (err < 0){ - emsg = "I2C R/W fail!"; - goto err_common_update_int_attr; - } - buf[i] = (int)err; - } - return 0; - -err_common_update_int_attr: - if (show_e) { - SWPS_INFO("%s: %s :%s :%d\n", - __func__, emsg, caller, err); - } - buf[0] = DEBUG_TRANSVR_INT_VAL; - return ERR_TRANSVR_UPDATE_FAIL; -} - - -static int -_common_update_string_attr(struct transvr_obj_s *self, - int addr, - int page, - int offset, - int len, - char buf[], - char *caller, - int show_e){ - - int i; - int err = DEBUG_TRANSVR_INT_VAL; - char *emsg = DEBUG_TRANSVR_STR_VAL; - - err = _common_setup_page(self, addr, page, offset, len, show_e); - if (err < 0){ - emsg = "setup EEPROM page fail"; - goto err_common_update_string_attr; - } - for (i=0; ii2c_client_p, (offset + i)); - if (err < 0){ - emsg = "I2C R/W fail!"; - goto err_common_update_string_attr; - } - buf[i] = (char)err; - } - return 0; - -err_common_update_string_attr: - if (show_e) { - SWPS_INFO("%s: %s :%s :%d\n", - __func__, emsg, caller, err); - } - buf[0] = 'e'; - return ERR_TRANSVR_UPDATE_FAIL; -} - - -static int -_common_set_uint8_attr(struct transvr_obj_s *self, - int addr, - int page, - int offset, - uint8_t update, - uint8_t *buf, - char *caller, - int show_e){ - int len = 1; - int err = DEBUG_TRANSVR_INT_VAL; - char *emsg = DEBUG_TRANSVR_STR_VAL; - - if ((*buf) == update){ - return 0; - } - err = _common_setup_page(self, addr, page, offset, len, show_e); - if (err < 0){ - emsg = "setup EEPROM page fail"; - goto err_common_set_uint8_attr_1; - } - err = i2c_smbus_write_byte_data(self->i2c_client_p, - offset, - update); - if (err < 0){ - emsg = "I2C R/W fail!"; - goto err_common_set_uint8_attr_1; - } - (*buf) = update; - return 0; - -err_common_set_uint8_attr_1: - if (show_e) { - SWPS_INFO("%s: %s :%s :%d\n", - __func__, emsg, caller, err); - } - return ERR_TRANSVR_UPDATE_FAIL; -} - - -static int -_common_set_uint8_array(struct transvr_obj_s *self, - int addr, - int page, - int offs, - int len, - uint8_t update[], - uint8_t buf[], - char *caller, - int show_e){ - int i = 0; - int err = DEBUG_TRANSVR_INT_VAL; - char *emsg = DEBUG_TRANSVR_STR_VAL; - - err = _common_setup_page(self, addr, page, offs, len, show_e); - if (err < 0){ - emsg = "setup EEPROM page fail"; - goto err_common_set_uint8_attr_1; - } - for (i=0; ii2c_client_p, - (offs + i), - update[i]); - if (err < 0){ - emsg = "I2C R/W fail!"; - goto err_common_set_uint8_attr_1; - } - buf[i] = update[i]; - } - return 0; - -err_common_set_uint8_attr_1: - if (show_e) { - SWPS_INFO("%s: %s :%s :%d :%d\n", - __func__, emsg, caller, err, i); - } - return ERR_TRANSVR_UPDATE_FAIL; -} - - -static int -_common_update_attr_id(struct transvr_obj_s *self, - int show_err){ - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_id, - self->eeprom_map_p->page_id, - self->eeprom_map_p->offset_id, - self->eeprom_map_p->length_id, - &(self->id), - "_common_update_attr_id", - show_err); -} - - -static int -_common_update_attr_extended_id(struct transvr_obj_s *self, - int show_err){ - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_ext_id, - self->eeprom_map_p->page_ext_id, - self->eeprom_map_p->offset_ext_id, - self->eeprom_map_p->length_ext_id, - &(self->ext_id), - "_common_update_attr_extended_id", - show_err); -} - - -static int -_common_update_attr_connector(struct transvr_obj_s *self, - int show_err){ - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_connector, - self->eeprom_map_p->page_connector, - self->eeprom_map_p->offset_connector, - self->eeprom_map_p->length_connector, - &(self->connector), - "_common_update_attr_connector", - show_err); -} - - -static int -_common_update_attr_transvr_comp(struct transvr_obj_s *self, - int show_err){ - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_trancomp, - self->eeprom_map_p->page_trancomp, - self->eeprom_map_p->offset_trancomp, - self->eeprom_map_p->length_trancomp, - self->transvr_comp, - "_common_update_attr_transvr_comp", - show_err); -} - - -static int -_common_update_attr_transvr_comp_ext(struct transvr_obj_s *self, - int show_err){ - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_trancomp_ext, - self->eeprom_map_p->page_trancomp_ext, - self->eeprom_map_p->offset_trancomp_ext, - self->eeprom_map_p->length_trancomp_ext, - &(self->transvr_comp_ext), - "_common_update_attr_transvr_comp_ext", - show_err); -} - -static int -_common_update_attr_eeprom(struct transvr_obj_s *self, - int show_err){ - return _common_update_string_attr(self, - self->eeprom_map_p->addr_eeprom, - self->eeprom_map_p->page_eeprom, - self->eeprom_map_p->offset_eeprom, - self->eeprom_map_p->length_eeprom, - self->eeprom, - "_common_update_attr_eeprom", - show_err); -} - -static int -_common_update_attr_vendor_name(struct transvr_obj_s *self, - int show_err){ - return _common_update_string_attr(self, - self->eeprom_map_p->addr_vendor_name, - self->eeprom_map_p->page_vendor_name, - self->eeprom_map_p->offset_vendor_name, - self->eeprom_map_p->length_vendor_name, - self->vendor_name, - "_common_update_attr_vendor_name", - show_err); -} - - -static int -_common_update_attr_vendor_pn(struct transvr_obj_s *self, - int show_err){ - return _common_update_string_attr(self, - self->eeprom_map_p->addr_vendor_pn, - self->eeprom_map_p->page_vendor_pn, - self->eeprom_map_p->offset_vendor_pn, - self->eeprom_map_p->length_vendor_pn, - self->vendor_pn, - "_common_update_attr_vendor_pn", - show_err); -} - - -static int -_common_update_attr_vendor_rev(struct transvr_obj_s *self, - int show_err){ - return _common_update_string_attr(self, - self->eeprom_map_p->addr_vendor_rev, - self->eeprom_map_p->page_vendor_rev, - self->eeprom_map_p->offset_vendor_rev, - self->eeprom_map_p->length_vendor_rev, - self->vendor_rev, - "_common_update_attr_vendor_rev", - show_err); -} - - -static int -_common_update_attr_vendor_sn(struct transvr_obj_s *self, - int show_err){ - return _common_update_string_attr(self, - self->eeprom_map_p->addr_vendor_sn, - self->eeprom_map_p->page_vendor_sn, - self->eeprom_map_p->offset_vendor_sn, - self->eeprom_map_p->length_vendor_sn, - self->vendor_sn, - "_common_update_attr_vendor_sn", - show_err); -} - - -static int -_common_update_attr_br(struct transvr_obj_s *self, - int show_err){ - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_br, - self->eeprom_map_p->page_br, - self->eeprom_map_p->offset_br, - self->eeprom_map_p->length_br, - &(self->br), - "_common_update_attr_br", - show_err); -} - - -static int -_common_update_attr_len_smf(struct transvr_obj_s *self, - int show_err){ - return _common_update_int_attr(self, - self->eeprom_map_p->addr_len_smf, - self->eeprom_map_p->page_len_smf, - self->eeprom_map_p->offset_len_smf, - self->eeprom_map_p->length_len_smf, - &(self->len_smf), - "_common_update_attr_len_smf", - show_err); -} - - -static int -_common_update_attr_len_om1(struct transvr_obj_s *self, - int show_err){ - return _common_update_int_attr(self, - self->eeprom_map_p->addr_len_om1, - self->eeprom_map_p->page_len_om1, - self->eeprom_map_p->offset_len_om1, - self->eeprom_map_p->length_len_om1, - &(self->len_om1), - "_common_update_attr_len_om1", - show_err); -} - -static int -_common_update_attr_len_om2(struct transvr_obj_s *self, - int show_err){ - return _common_update_int_attr(self, - self->eeprom_map_p->addr_len_om2, - self->eeprom_map_p->page_len_om2, - self->eeprom_map_p->offset_len_om2, - self->eeprom_map_p->length_len_om2, - &(self->len_om2), - "_common_update_attr_len_om2", - show_err); -} - -static int -_common_update_attr_len_om3(struct transvr_obj_s *self, - int show_err){ - return _common_update_int_attr(self, - self->eeprom_map_p->addr_len_om3, - self->eeprom_map_p->page_len_om3, - self->eeprom_map_p->offset_len_om3, - self->eeprom_map_p->length_len_om3, - &(self->len_om3), - "_common_update_attr_len_om3", - show_err); -} - - -static int -_common_update_attr_len_om4(struct transvr_obj_s *self, - int show_err){ - return _common_update_int_attr(self, - self->eeprom_map_p->addr_len_om4, - self->eeprom_map_p->page_len_om4, - self->eeprom_map_p->offset_len_om4, - self->eeprom_map_p->length_len_om4, - &(self->len_om4), - "_common_update_attr_len_om4", - show_err); -} - - -static int -_common_update_attr_option(struct transvr_obj_s *self, - int show_err){ - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_option, - self->eeprom_map_p->page_option, - self->eeprom_map_p->offset_option, - self->eeprom_map_p->length_option, - self->option, - "_common_update_attr_option", - show_err); -} - - -static int -_common_update_attr_comp_rev(struct transvr_obj_s *self, - int show_err){ - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_comp_rev, - self->eeprom_map_p->page_comp_rev, - self->eeprom_map_p->offset_comp_rev, - self->eeprom_map_p->length_comp_rev, - &(self->comp_rev), - "_common_update_attr_comp_rev", - show_err); -} - - -static int -_common_update_attr_diag_type(struct transvr_obj_s *self, - int show_err){ - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_diag_type, - self->eeprom_map_p->page_diag_type, - self->eeprom_map_p->offset_diag_type, - self->eeprom_map_p->length_diag_type, - &(self->diag_type), - "_common_update_attr_diag_type", - show_err); -} - - -static int -_common_update_attr_wavelength(struct transvr_obj_s *self, - int show_err){ - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_wavelength, - self->eeprom_map_p->page_wavelength, - self->eeprom_map_p->offset_wavelength, - self->eeprom_map_p->length_wavelength, - self->wavelength, - "_common_update_attr_wavelength", - show_err); -} - - -int -_common_get_option_value(struct transvr_obj_s *self, - int offset, - int bit_shift) { - /* SFP: - * - option[0] = A0h / 64 - * - option[1] = A0h / 65 - * QSFP: - * - option[0] = 00h / 193 - * - option[1] = 00h / 194 - * - option[2] = 00h / 195 - */ - return (self->option[offset] & (1 << bit_shift)); -} - - -static int -_sfp_update_attr_len_sm(struct transvr_obj_s *self, - int show_err){ - return _common_update_int_attr(self, - self->eeprom_map_p->addr_len_sm, - self->eeprom_map_p->page_len_sm, - self->eeprom_map_p->offset_len_sm, - self->eeprom_map_p->length_len_sm, - &(self->len_sm), - "_common_update_attr_len_sm", - show_err); -} - - -static int -_sfp_update_attr_rate_id(struct transvr_obj_s *self, - int show_err){ - return _common_update_int_attr(self, - self->eeprom_map_p->addr_rate_id, - self->eeprom_map_p->page_rate_id, - self->eeprom_map_p->offset_rate_id, - self->eeprom_map_p->length_rate_id, - &(self->rate_id), - "_sfp_update_attr_rate_id", - show_err); -} - - -static int -_sfp_update_attr_soft_rs0(struct transvr_obj_s *self, - int show_err){ - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_soft_rs0, - self->eeprom_map_p->page_soft_rs0, - self->eeprom_map_p->offset_soft_rs0, - self->eeprom_map_p->length_soft_rs0, - &(self->soft_rs0), - "_sfp_update_attr_soft_rs0", - show_err); -} - - -static int -_sfp_update_attr_soft_rs1(struct transvr_obj_s *self, - int show_err){ - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_soft_rs1, - self->eeprom_map_p->page_soft_rs1, - self->eeprom_map_p->offset_soft_rs1, - self->eeprom_map_p->length_soft_rs1, - &(self->soft_rs1), - "_sfp_update_attr_soft_rs1", - show_err); -} - - -int -_sfp_is_diag_support(struct transvr_obj_s *self){ - - uint8_t bit_mask = 0xC0; /* 1100 0000 */ - uint8_t en_val = 0x40; /* 0100 0000 */ - uint8_t checkval = (self->diag_type & bit_mask); - - if (checkval == en_val) { - return 1; - } - return 0; -} - - -static int -_sfp_update_attr_curr_temp(struct transvr_obj_s *self, - int show_err){ - - if (!(_sfp_is_diag_support(self))) { - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_temp, - self->eeprom_map_p->page_temp, - self->eeprom_map_p->offset_temp, - self->eeprom_map_p->length_temp, - self->curr_temp, - "_sfp_update_attr_curr_temp", - show_err); -} - - -static int -_sfp_update_attr_curr_voltage(struct transvr_obj_s *self, - int show_err){ - - if (!(_sfp_is_diag_support(self))) { - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_voltage, - self->eeprom_map_p->page_voltage, - self->eeprom_map_p->offset_voltage, - self->eeprom_map_p->length_voltage, - self->curr_voltage, - "_sfp_update_attr_curr_voltage", - show_err); -} - - -static int -_sfp_update_attr_curr_tx_bias(struct transvr_obj_s *self, - int show_err){ - - if (!(_sfp_is_diag_support(self))) { - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_tx_bias, - self->eeprom_map_p->page_tx_bias, - self->eeprom_map_p->offset_tx_bias, - self->eeprom_map_p->length_tx_bias, - self->curr_tx_bias, - "_sfp_update_attr_curr_tx_bias", - show_err); -} - - -static int -_sfp_update_attr_curr_tx_power(struct transvr_obj_s *self, - int show_err){ - - if (!(_sfp_is_diag_support(self))) { - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_tx_power, - self->eeprom_map_p->page_tx_power, - self->eeprom_map_p->offset_tx_power, - self->eeprom_map_p->length_tx_power, - self->curr_tx_power, - "_sfp_update_attr_curr_tx_power", - show_err); -} - - -static int -_sfp_update_attr_curr_rx_power(struct transvr_obj_s *self, - int show_err){ - - if (!(_sfp_is_diag_support(self))) { - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_rx_power, - self->eeprom_map_p->page_rx_power, - self->eeprom_map_p->offset_rx_power, - self->eeprom_map_p->length_rx_power, - self->curr_rx_power, - "_sfp_update_attr_curr_rx_power", - show_err); -} - - -static int -_sfp_update_attr_rx_em(struct transvr_obj_s *self, - int show_err){ - - if (!_is_transvr_support_ctle(self)) { - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_rx_em, - self->eeprom_map_p->page_rx_em, - self->eeprom_map_p->offset_rx_em, - self->eeprom_map_p->length_rx_em, - self->rx_em, - "_sfp_update_attr_rx_em", - show_err); -} - - -static int -_sfp_update_attr_tx_eq(struct transvr_obj_s *self, - int show_err){ - - if (!_is_transvr_support_ctle(self)) { - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_tx_eq, - self->eeprom_map_p->page_tx_eq, - self->eeprom_map_p->offset_tx_eq, - self->eeprom_map_p->length_tx_eq, - self->tx_eq, - "_sfp_update_attr_tx_eq", - show_err); -} - - -static int -_qsfp_update_attr_cdr(struct transvr_obj_s *self, - int show_err){ - if (self->type != TRANSVR_TYPE_QSFP_28){ - self->cdr = DEBUG_TRANSVR_HEX_VAL; - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_cdr, - self->eeprom_map_p->page_cdr, - self->eeprom_map_p->offset_cdr, - self->eeprom_map_p->length_cdr, - &(self->cdr), - "_common_update_attr_cdr", - show_err); -} - - -static int -_qsfg_update_attr_extbr(struct transvr_obj_s *self, - int show_err) { - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_extbr, - self->eeprom_map_p->page_extbr, - self->eeprom_map_p->offset_extbr, - self->eeprom_map_p->length_extbr, - &(self->extbr), - "_common_update_attr_extbr", - show_err); -} - - -static int -_qsfp_is_diag_support(struct transvr_obj_s *self, - int diag_type) { - /* Input Parm: diag_type - * => 1 : temperature - * => 2 : voltage - * => 3 : tx relate - * => 4 : rx relate - */ - uint8_t mask_b2 = 0x04; /* 0000 0100 */ - uint8_t mask_b3 = 0x08; /* 0000 1000 */ - - switch (diag_type) { - case 1: /* temperature */ - case 2: /* voltage */ - /* Direct access target, because of spec not defined */ - return 1; - case 3: - case 4: - /* [Note] - * Due to lot of transceiver vendor defined it not rigorously and - * consider of general support, we seem it as supported if there - * are bit-2 OR bit-3 defined by transceiver vendor. - */ - if ( ((self->diag_type & mask_b2) == mask_b2 ) || - ((self->diag_type & mask_b3) == mask_b3 ) ){ - return 1; - } - return 0; - default: - SWPS_INFO("%s: undefined diag_type:%d\n", - __func__, diag_type); - break; - } - return 0; -} - - -int -_qsfp_is_implement_tx_disable(struct transvr_obj_s *self) { - /* - * 00h / Byte-195 / Bit-4 - */ - int byte = 2; - int bit = 4; - return _common_get_option_value(self, byte, bit); -} - - -int -_qsfp_is_implement_tx_fault(struct transvr_obj_s *self) { - /* - * 00h / Byte-195 / Bit-3 - */ - int byte = 2; - int bit = 3; - return _common_get_option_value(self, byte, bit); -} - - -static int -_qsfp_update_attr_curr_temp(struct transvr_obj_s *self, - int show_err){ - int diag_type = 1; - - if (!(_qsfp_is_diag_support(self, diag_type))) { - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_temp, - self->eeprom_map_p->page_temp, - self->eeprom_map_p->offset_temp, - self->eeprom_map_p->length_temp, - self->curr_temp, - "_qsfp_update_attr_curr_temp", - show_err); -} - - -static int -_qsfp_update_attr_curr_voltage(struct transvr_obj_s *self, - int show_err){ - int diag_type = 2; - - if (!(_qsfp_is_diag_support(self, diag_type))) { - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_voltage, - self->eeprom_map_p->page_voltage, - self->eeprom_map_p->offset_voltage, - self->eeprom_map_p->length_voltage, - self->curr_voltage, - "_qsfp_update_attr_curr_voltage", - show_err); -} - - -static int -_qsfp_update_attr_curr_tx_bias(struct transvr_obj_s *self, - int show_err){ - int diag_type = 3; - - if (!(_qsfp_is_diag_support(self, diag_type))) { - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_tx_bias, - self->eeprom_map_p->page_tx_bias, - self->eeprom_map_p->offset_tx_bias, - self->eeprom_map_p->length_tx_bias, - self->curr_tx_bias, - "_qsfp_update_attr_curr_tx_bias", - show_err); -} - - -static int -_qsfp_update_attr_curr_tx_power(struct transvr_obj_s *self, - int show_err){ - int diag_type = 3; - - if (!(_qsfp_is_diag_support(self, diag_type))) { - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_tx_power, - self->eeprom_map_p->page_tx_power, - self->eeprom_map_p->offset_tx_power, - self->eeprom_map_p->length_tx_power, - self->curr_tx_power, - "_qsfp_update_attr_curr_tx_power", - show_err); -} - - -static int -_qsfp_update_attr_curr_rx_power(struct transvr_obj_s *self, - int show_err){ - int diag_type = 4; - - if (!(_qsfp_is_diag_support(self, diag_type))) { - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_rx_power, - self->eeprom_map_p->page_rx_power, - self->eeprom_map_p->offset_rx_power, - self->eeprom_map_p->length_rx_power, - self->curr_rx_power, - "_qsfp_update_attr_curr_rx_power", - show_err); -} - - -static int -_qsfp_update_attr_soft_rx_los(struct transvr_obj_s *self, - int show_err){ - - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_rx_los, - self->eeprom_map_p->page_rx_los, - self->eeprom_map_p->offset_rx_los, - self->eeprom_map_p->length_rx_los, - &(self->rx_los), - "_qsfp_update_attr_soft_rx_los", - show_err); -} - - -static int -_qsfp_update_attr_soft_tx_disable(struct transvr_obj_s *self, - int show_err){ - - if (!_qsfp_is_implement_tx_disable(self)) { - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_tx_disable, - self->eeprom_map_p->page_tx_disable, - self->eeprom_map_p->offset_tx_disable, - self->eeprom_map_p->length_tx_disable, - &(self->tx_disable), - "_qsfp_update_attr_soft_tx_disable", - show_err); -} - - -static int -_qsfp_update_attr_soft_tx_fault(struct transvr_obj_s *self, - int show_err){ - - if (!_qsfp_is_implement_tx_fault(self)) { - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_tx_fault, - self->eeprom_map_p->page_tx_fault, - self->eeprom_map_p->offset_tx_fault, - self->eeprom_map_p->length_tx_fault, - &(self->tx_fault), - "_qsfp_update_attr_soft_tx_fault", - show_err); -} - - -static int -_qsfp_update_attr_tx_eq(struct transvr_obj_s *self, - int show_err){ - - if (!_is_transvr_support_ctle(self)) { - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_tx_eq, - self->eeprom_map_p->page_tx_eq, - self->eeprom_map_p->offset_tx_eq, - self->eeprom_map_p->length_tx_eq, - self->tx_eq, - "_qsfp_update_attr_tx_eq", - show_err); -} - - -static int -_qsfp_update_attr_rx_am(struct transvr_obj_s *self, - int show_err){ - - if (!_is_transvr_support_ctle(self)) { - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_rx_am, - self->eeprom_map_p->page_rx_am, - self->eeprom_map_p->offset_rx_am, - self->eeprom_map_p->length_rx_am, - self->rx_am, - "_qsfp_update_attr_rx_am", - show_err); -} - - -static int -_qsfp_update_attr_rx_em(struct transvr_obj_s *self, - int show_err){ - - if (!_is_transvr_support_ctle(self)) { - return ERR_TRANSVR_NOTSUPPORT; - } - return _common_update_uint8_attr(self, - self->eeprom_map_p->addr_rx_em, - self->eeprom_map_p->page_rx_em, - self->eeprom_map_p->offset_rx_em, - self->eeprom_map_p->length_rx_em, - self->rx_em, - "_qsfp_update_attr_rx_em", - show_err); -} - - -int -_common_update_attr_all(struct transvr_obj_s *self, - int show_err){ - - char *err_str = "err"; - - if (_common_update_attr_id(self, show_err) < 0) { - err_str = "_common_update_attr_id"; - goto err_common_update_attr_all; - } - if (_common_update_attr_eeprom(self, show_err) < 0) { - err_str = "_common_update_attr_eeprom"; - goto err_common_update_attr_all; - } - if (_common_update_attr_extended_id(self, show_err) < 0) { - err_str = "_common_update_attr_extended_id"; - goto err_common_update_attr_all; - } - if (_common_update_attr_connector(self, show_err) < 0) { - err_str = "_common_update_attr_connector"; - goto err_common_update_attr_all; - } - if (_common_update_attr_transvr_comp(self, show_err) < 0) { - err_str = "_common_update_attr_transvr_comp"; - goto err_common_update_attr_all; - } - if (_common_update_attr_transvr_comp_ext(self, show_err) < 0) { - err_str = "_common_update_attr_transvr_comp_ext"; - goto err_common_update_attr_all; - } - if (_common_update_attr_vendor_name(self, show_err) < 0) { - err_str = "_common_update_attr_vendor_name"; - goto err_common_update_attr_all; - } - if (_common_update_attr_vendor_pn(self, show_err) < 0) { - err_str = "_common_update_attr_vendor_pn"; - goto err_common_update_attr_all; - } - if (_common_update_attr_vendor_rev(self, show_err) < 0) { - err_str = "_common_update_attr_vendor_rev"; - goto err_common_update_attr_all; - } - if (_common_update_attr_vendor_sn(self, show_err) < 0) { - err_str = "_common_update_attr_vendor_sn"; - goto err_common_update_attr_all; - } - if (_common_update_attr_br(self, show_err) < 0) { - err_str = "_common_update_attr_br"; - goto err_common_update_attr_all; - } - if (_common_update_attr_len_smf(self, show_err) < 0) { - err_str = "_common_update_attr_len_smf"; - goto err_common_update_attr_all; - } - if (_common_update_attr_len_om1(self, show_err) < 0) { - err_str = "_common_update_attr_len_om1"; - goto err_common_update_attr_all; - } - if (_common_update_attr_len_om2(self, show_err) < 0) { - err_str = "_common_update_attr_len_om2"; - goto err_common_update_attr_all; - } - if (_common_update_attr_len_om3(self, show_err) < 0) { - err_str = "_common_update_attr_len_om3"; - goto err_common_update_attr_all; - } - if (_common_update_attr_len_om4(self, show_err) < 0) { - err_str = "_common_update_attr_len_om4"; - goto err_common_update_attr_all; - } - if (_common_update_attr_option(self, show_err) < 0) { - err_str = "_common_update_attr_option"; - goto err_common_update_attr_all; - } - if (_common_update_attr_comp_rev(self, show_err) < 0) { - err_str = "_common_update_attr_comp_rev"; - goto err_common_update_attr_all; - } - if (_common_update_attr_diag_type(self, show_err) < 0) { - err_str = "_common_update_attr_diag_type"; - goto err_common_update_attr_all; - } - if (_common_update_attr_wavelength(self, show_err) < 0) { - err_str = "_common_update_attr_wavelength"; - goto err_common_update_attr_all; - } - return 0; - -err_common_update_attr_all: - if (show_err){ - SWPS_INFO("%s: fail at:%s :%s\n", __func__, err_str, self->swp_name); - } - return -1; -} - - -int -_sfp_update_attr_all(struct transvr_obj_s *self, - int show_err){ - - char *err_str = DEBUG_TRANSVR_STR_VAL; - - if (_common_update_attr_all(self, show_err) < 0){ - err_str = "_common_update_attr_all"; - goto err_sfp_update_attr_all; - } - if (_sfp_update_attr_len_sm(self, show_err) < 0) { - err_str = "_sfp_update_attr_len_sm"; - goto err_sfp_update_attr_all; - } - if (_sfp_update_attr_rate_id(self, show_err) < 0) { - err_str = "_sfp_update_attr_rate_id"; - goto err_sfp_update_attr_all; - } - if ((self->rate_id) > 0) { - if (_sfp_update_attr_soft_rs0(self, show_err) < 0) { - err_str = "_sfp_update_attr_soft_rs0"; - goto err_sfp_update_attr_all; - } - if (_sfp_update_attr_soft_rs1(self, show_err) < 0) { - err_str = "_sfp_update_attr_soft_rs1"; - goto err_sfp_update_attr_all; - } - } - return 0; - -err_sfp_update_attr_all: - if (show_err){ - SWPS_INFO("%s: fail at:%s :%s\n", __func__, err_str, self->swp_name); - } - return -1; -} - - -int -_qsfp_update_attr_all(struct transvr_obj_s *self, - int show_err){ - - char *err_str = DEBUG_TRANSVR_STR_VAL; - - if (_common_update_attr_all(self, show_err) < 0){ - err_str = "_common_update_attr_all"; - goto err_qsfp_update_attr_all; - } - if (_qsfg_update_attr_extbr(self, show_err) < 0) { - err_str = "_qsfg_update_attr_extbr"; - goto err_qsfp_update_attr_all; - } - if (self->type == TRANSVR_TYPE_QSFP_28) { - if (_qsfp_update_attr_cdr(self, 1) < 0) { - err_str = "_qsfp_update_attr_cdr"; - goto err_qsfp_update_attr_all; - } - } - return 0; - -err_qsfp_update_attr_all: - if (show_err){ - SWPS_INFO("%s: fail at:%s :%s\n", __func__, err_str, self->swp_name); - } - return -1; -} - - -/* ========== Object functions for common type ========== - */ -int -_common_count_temp(uint8_t high_byte, - uint8_t low_byte, - char *buf_p) { - int sign = 0; - int high = 0; - int low = 0; - int lmax = 8; - - /* Count high */ - sign = get_bit(high_byte,7); - SWP_BIT_CLEAR(high_byte, 7); - high = (int)high_byte; - if (sign == 1) { - high = 0 - high; - } - /* Count low */ - low = (get_bit(low_byte, 7) * 500); - low += (get_bit(low_byte, 6) * 250); - low += (get_bit(low_byte, 5) * 125); - low += (get_bit(low_byte, 4) * 62); - low = (low / 100); - /* Integrate High and Low */ - return snprintf(buf_p, lmax, "%d.%d\n", high, low); -} - - -int -_common_count_voltage(uint8_t high_byte, - uint8_t low_byte, - char *buf_p) { - /* [Note]: - * Internally measured transceiver supply voltage. Represented - * as a 16 bit unsigned integer with the voltage defined as the - * full 16 bit value (0-65535) with LSB equal to 100 uVolt, - * yielding a total range of 0 to +6.55 Volts. Practical - * considerations to be defined by transceiver manufacturer will - * tend to limit the actual bounds of the supply voltage measurement. - * Accuracy is vendor specific but must be better than 3% of the - * manufacturer's nominal value over specified operating temperature - * and voltage. Note that in some transceivers, transmitter supply - * voltage and receiver supply voltage are isolated. In that case, - * only one supply is monitored. Refer to the device specification - * for more detail. - */ - int total = 0; - int lmax = 8; - int val_i = 0; - int val_f = 0; - /* unit: 100 uV (1mV=1000uV) */ - total = transform_word_to_int(high_byte, low_byte); - val_i = ((total/10) / 1000); - val_f = ((total/10) - (val_i*1000)); - /* Return Unit: 1 Volt */ - return snprintf(buf_p, lmax, "%d.%03d\n", val_i, val_f); -} - - -int -_common_count_tx_bias(uint8_t high_byte, - uint8_t low_byte, - char *buf_p) { - /* [Note] - * Measured TX bias current in uA. Represented as a 16 bit unsigned - * integer with the current defined as the full 16 bit value (0-65535) - * with LSB equal to 2 uA, yielding a total range of 0 to 131 mA. - * Accuracy is vendor specific but must be better than 10% of the - * manufacturer's nominal value over specified operating temperature - * and voltage. - */ - int total = 0; - int lmax = 8; - int val_i = 0; - int val_f = 0; - /* unit: 2 uA (1mA=1000uA) */ - total = transform_word_to_int(high_byte, low_byte); - val_i = ((total*2) / 1000); - val_f = (((total*2) - (val_i*1000)) / 100); - /* Return Unit: 1 mA */ - return snprintf(buf_p, lmax, "%d.%01d\n", val_i, val_f); -} - - -int -_common_count_tx_power(uint8_t high_byte, - uint8_t low_byte, - char *buf_p) { - /* [Note] - * Measured TX output power in mW. Represented as a 16 bit unsigned - * integer with the power defined as the full 16 bit value (0-65535) - * with LSB equal to 0.1 uW, yielding a total range of 0 to 6.5535 mW - * (~ -40 to +8.2 dBm). Data is assumed to be based on measurement of - * laser monitor photodiode current. It is factory calibrated to absolute - * units using the most representative fiber output type. Accuracy is - * vendor specific but must be better than 3dB over specified temperature - * and voltage. Data is not valid when the transmitter is disabled. - */ - int total = 0; - int lmax = 8; - int val_i = 0; - int val_f = 0; - /* unit: 0.1 uW (1mW=1000uW) */ - total = transform_word_to_int(high_byte, low_byte); - val_i = ((total/10) / 1000); - val_f = ((total/10) - (val_i*1000)); - /* Return Unit: 1 mW */ - return snprintf(buf_p, lmax, "%d.%03d\n", val_i, val_f); -} - - -int -_common_count_rx_power(uint8_t high_byte, - uint8_t low_byte, - char *buf_p) { - /* [Note] - * Measured RX received optical power in mW. Value can represent either - * average received power or OMA depending upon how bit 3 of byte 92 (A0h) - * is set. Represented as a 16 bit unsigned integer with the power defined - * as the full 16 bit value (0-65535) with LSB equal to 0.1 uW, yielding a - * total range of 0 to 6.5535 mW (~ -40 to +8.2 dBm). Absolute accuracy is - * dependent upon the exact optical wavelength. For the vendor specified - * wavelength, accuracy shall be better than 3dB over specified temperature - * and voltage. - */ - int total = 0; - int lmax = 8; - int val_i = 0; - int val_f = 0; - /* unit: 0.1 uW (1mW=1000uW) */ - total = transform_word_to_int(high_byte, low_byte); - val_i = ((total/10) / 1000); - val_f = ((total/10) - (val_i*1000)); - /* Return Unit: 1 mW */ - return snprintf(buf_p, lmax, "%d.%03d\n", val_i, val_f); -} - - -int -_common_count_wavelength(struct transvr_obj_s *self, - uint8_t high_byte, - uint8_t low_byte) { - /* [Note] - * SFP : uint 1 um. - * QSFP: unit 0.05 um. - */ - int total = 0; - - total = transform_word_to_int(high_byte, low_byte); - switch (self->type) { - case TRANSVR_TYPE_SFP: - return total; - - case TRANSVR_TYPE_QSFP: - case TRANSVR_TYPE_QSFP_PLUS: - case TRANSVR_TYPE_QSFP_28: - return (total/20); - - default: - break; - } - return ERR_TRANSVR_UNDEFINED; -} - - -int -common_get_id(struct transvr_obj_s *self){ - - int err_code = _check_by_mode(self, - &_common_update_attr_id, - "common_get_id"); - if (err_code < 0){ - return err_code; - } - /* Transform to INT to show error case */ - return (int)self->id; -} - - -int -common_get_ext_id(struct transvr_obj_s *self){ - - int err_code = _check_by_mode(self, - &_common_update_attr_extended_id, - "common_get_ext_id"); - if (err_code < 0){ - return err_code; - } - /* Transform to INT to show error case */ - return (int)self->ext_id; -} - - -int -common_get_connector(struct transvr_obj_s *self){ - - int err_code = _check_by_mode(self, - &_common_update_attr_connector, - "common_get_connector"); - if (err_code < 0){ - return err_code; - } - /* Transform to INT to show error case */ - return (int)self->connector; -} - -int -common_get_eeprom(struct transvr_obj_s *self, char *buf){ - - int err = DEBUG_TRANSVR_INT_VAL; - unsigned char *eeprom_update = get_eeprom_update(); - - if (!(eeprom_update[self->port_no/8] & (1 << self->port_no%8)) && - (self->state == STATE_TRANSVR_CONNECTED && - self->mode == TRANSVR_MODE_POLLING && - TRANSVR_INFO_CACHE_ENABLE)) { - memset(buf, 0, self->eeprom_map_p->length_eeprom); - memcpy(buf, self->eeprom, self->eeprom_map_p->length_eeprom); - *(buf+self->eeprom_map_p->length_eeprom) = '\n'; - return self->eeprom_map_p->length_eeprom; - } - err = _check_by_mode(self, &_common_update_attr_eeprom, - "common_get_eeprom"); - if (err < 0){ - return snprintf(buf, LEN_TRANSVR_M_STR, "%d\n", err); - } - memset(buf, 0, self->eeprom_map_p->length_eeprom); - memcpy(buf, self->eeprom, self->eeprom_map_p->length_eeprom); - *(buf+self->eeprom_map_p->length_eeprom) = '\n'; - eeprom_update[self->port_no/8] &= ~(1 << self->port_no%8); - set_eeprom_update(eeprom_update); - return self->eeprom_map_p->length_eeprom; -} - -int -common_get_vendor_name(struct transvr_obj_s *self, char *buf){ - - int err = DEBUG_TRANSVR_INT_VAL; - - if (self->state == STATE_TRANSVR_CONNECTED && - self->mode == TRANSVR_MODE_POLLING && - TRANSVR_INFO_CACHE_ENABLE) { - return snprintf(buf, LEN_TRANSVR_M_STR, "%s\n", self->vendor_name); - } - err = _check_by_mode(self, - &_common_update_attr_vendor_name, - "common_get_vendor_name"); - memset(buf, 0, LEN_TRANSVR_M_STR); - if (err < 0){ - return snprintf(buf, LEN_TRANSVR_M_STR, "%d\n", err); - } - return snprintf(buf, LEN_TRANSVR_M_STR, "%s\n", self->vendor_name); -} - - -int -common_get_vendor_pn(struct transvr_obj_s *self, char *buf) { - - int err = DEBUG_TRANSVR_INT_VAL; - - if (self->state == STATE_TRANSVR_CONNECTED && - self->mode == TRANSVR_MODE_POLLING && - TRANSVR_INFO_CACHE_ENABLE) { - return snprintf(buf, LEN_TRANSVR_M_STR, "%s\n", self->vendor_pn); - } - err = _check_by_mode(self, - &_common_update_attr_vendor_pn, - "common_get_vendor_pn"); - memset(buf, 0, LEN_TRANSVR_M_STR); - if (err < 0){ - return snprintf(buf, LEN_TRANSVR_M_STR, "%d\n", err); - } - return snprintf(buf, LEN_TRANSVR_M_STR, "%s\n", self->vendor_pn); -} - - -int -common_get_vendor_rev(struct transvr_obj_s *self, char *buf) { - - int err = DEBUG_TRANSVR_INT_VAL; - - if (self->state == STATE_TRANSVR_CONNECTED && - self->mode == TRANSVR_MODE_POLLING && - TRANSVR_INFO_CACHE_ENABLE) { - return snprintf(buf, LEN_TRANSVR_M_STR, "%s\n", self->vendor_rev); - } - err = _check_by_mode(self, - &_common_update_attr_vendor_rev, - "common_get_vendor_rev"); - memset(buf, 0, LEN_TRANSVR_M_STR); - if (err < 0){ - return snprintf(buf, LEN_TRANSVR_M_STR, "%d\n", err); - } - return snprintf(buf, LEN_TRANSVR_M_STR, "%s\n", self->vendor_rev); -} - - -int -common_get_vendor_sn(struct transvr_obj_s *self, char *buf) { - - int err = DEBUG_TRANSVR_INT_VAL; - - if (self->state == STATE_TRANSVR_CONNECTED && - self->mode == TRANSVR_MODE_POLLING && - TRANSVR_INFO_CACHE_ENABLE) { - return snprintf(buf, LEN_TRANSVR_M_STR, "%s\n", self->vendor_sn); - } - err = _check_by_mode(self, - &_common_update_attr_vendor_sn, - "common_get_vendor_sn"); - memset(buf, 0, LEN_TRANSVR_M_STR); - if (err < 0){ - return snprintf(buf, LEN_TRANSVR_M_STR, "%d\n", err); - } - return snprintf(buf, LEN_TRANSVR_M_STR, "%s\n", self->vendor_sn); -} - - -int -common_get_br(struct transvr_obj_s *self){ - - int err = DEBUG_TRANSVR_INT_VAL; - - if (self->state == STATE_TRANSVR_CONNECTED && - self->mode == TRANSVR_MODE_POLLING && - TRANSVR_INFO_CACHE_ENABLE) { - return (int)self->br; - } - err = _check_by_mode(self, - &_common_update_attr_br, - "common_get_br"); - if (err < 0){ - return err; - } - /* Transform to INT to show error case */ - return (int)self->br; -} - - -int -common_get_len_smf(struct transvr_obj_s *self){ - - int err = DEBUG_TRANSVR_INT_VAL; - - if (self->state == STATE_TRANSVR_CONNECTED && - self->mode == TRANSVR_MODE_POLLING && - TRANSVR_INFO_CACHE_ENABLE) { - return self->len_smf; - } - err = _check_by_mode(self, - &_common_update_attr_len_smf, - "common_get_len_smf"); - if (err < 0){ - return err; - } - return self->len_smf; -} - - -int -common_get_len_om1(struct transvr_obj_s *self){ - - int err = DEBUG_TRANSVR_INT_VAL; - - if (self->state == STATE_TRANSVR_CONNECTED && - self->mode == TRANSVR_MODE_POLLING && - TRANSVR_INFO_CACHE_ENABLE) { - return self->len_om1; - } - err = _check_by_mode(self, - &_common_update_attr_len_om1, - "common_get_len_om1"); - if (err < 0){ - return err; - } - return self->len_om1; -} - - -int -common_get_len_om2(struct transvr_obj_s *self){ - - int err = DEBUG_TRANSVR_INT_VAL; - - if (self->state == STATE_TRANSVR_CONNECTED && - self->mode == TRANSVR_MODE_POLLING && - TRANSVR_INFO_CACHE_ENABLE) { - return self->len_om2; - } - - err = _check_by_mode(self, - &_common_update_attr_len_om2, - "common_get_len_om2"); - if (err < 0){ - return err; - } - return self->len_om2; -} - - -int -common_get_len_om3(struct transvr_obj_s *self){ - - int err = DEBUG_TRANSVR_INT_VAL; - - if (self->state == STATE_TRANSVR_CONNECTED && - self->mode == TRANSVR_MODE_POLLING && - TRANSVR_INFO_CACHE_ENABLE) { - return self->len_om3; - } - - err = _check_by_mode(self, - &_common_update_attr_len_om3, - "common_get_len_om3"); - if (err < 0){ - return err; - } - return self->len_om3; -} - - -int -common_get_len_om4(struct transvr_obj_s *self){ - - int err = DEBUG_TRANSVR_INT_VAL; - - if (self->state == STATE_TRANSVR_CONNECTED && - self->mode == TRANSVR_MODE_POLLING && - TRANSVR_INFO_CACHE_ENABLE) { - return self->len_om4; - } - err = _check_by_mode(self, - &_common_update_attr_len_om4, - "common_get_len_om4"); - if (err < 0){ - return err; - } - return self->len_om4; -} - - -int -common_get_comp_extended(struct transvr_obj_s *self){ - - int err_code = _check_by_mode(self, - &_common_update_attr_transvr_comp_ext, - "common_get_comp_extended"); - if (err_code < 0){ - return err_code; - } - return self->transvr_comp_ext; -} - - -int -common_get_comp_rev(struct transvr_obj_s *self){ - - int err_code = _check_by_mode(self, - &_common_update_attr_comp_rev, - "common_get_comp_rev"); - if (err_code < 0){ - return err_code; - } - return self->comp_rev; -} - - -int -common_get_info(struct transvr_obj_s *self){ - - if (self->state != STATE_TRANSVR_CONNECTED) { - return self->state; - } - return self->info; -} - - -int -_common_get_if_lane(struct transvr_obj_s *self, - char *result){ - int i = 0; - int tmp_val = 0; - char tmp_str[LEN_TRANSVR_M_STR] = DEBUG_TRANSVR_STR_VAL; - - memset(result, 0, LEN_TRANSVR_M_STR); - - for (i=0; ilane_id); i++) { - tmp_val = self->lane_id[i]; - if (tmp_val < 1) { - break; - } - memset(tmp_str, 0, LEN_TRANSVR_M_STR); - if (i == 0) { - snprintf(tmp_str, LEN_TRANSVR_M_STR, "%d", tmp_val); - } else { - snprintf(tmp_str, LEN_TRANSVR_M_STR, ",%d", tmp_val); - } - strncat(result, tmp_str, LEN_TRANSVR_M_STR); - } - if (i == 0) { - return EVENT_TRANSVR_TASK_FAIL; - } - return 0; -} - - -int -common_get_if_lane(struct transvr_obj_s *self, - char *buf_p){ - - char tmp_str[LEN_TRANSVR_M_STR] = DEBUG_TRANSVR_STR_VAL; - - if (self->ioexp_obj_p->state != STATE_IOEXP_NORMAL) { - return snprintf(buf_p, LEN_TRANSVR_M_STR, "%d\n", ERR_TRANSVR_ABNORMAL); - } - if (_common_get_if_lane(self, tmp_str) < 0) { - return snprintf(buf_p, LEN_TRANSVR_M_STR, "%d\n" ,ERR_TRANSVR_ABNORMAL); - } - return snprintf(buf_p, LEN_TRANSVR_M_STR, "%s\n" ,tmp_str); -} - - -int -sfp_get_len_sm(struct transvr_obj_s *self){ - - int err_code = _check_by_mode(self, - &_sfp_update_attr_len_sm, - "sfp_get_len_sm"); - if (err_code < 0){ - return err_code; - } - return self->len_sm; -} - - -int -sfp_get_rate_id(struct transvr_obj_s *self){ - - int err_code = _check_by_mode(self, - &_sfp_update_attr_rate_id, - "sfp_get_rate_id"); - if (err_code < 0){ - return err_code; - } - return self->rate_id; -} - - -int -sfp_get_soft_rs0(struct transvr_obj_s *self){ - /* Note: - * SFP Soft Rate_Select Select [aka. "RS(0)"] address - * A2h, offset: 110, bit 3 (begin form 0) - */ - int err_code = DEBUG_TRANSVR_INT_VAL; - int bit_shift = 3; - uint8_t result = 0x00; - uint8_t bitmask = (1 << bit_shift); - - /* Check rate identifier is supported */ - err_code = self->get_rate_id(self); - if (err_code <= 0) { - return ERR_TRANSVR_NOTSUPPORT; - } - /* Update and check */ - err_code = _check_by_mode(self, - &_sfp_update_attr_soft_rs0, - "sfp_get_soft_rs0"); - if (err_code <0){ - return err_code; - } - result = (self->soft_rs0 & bitmask); - if (result == bitmask) { - return 1; - } - if (result == 0) { - return 0; - } - return ERR_TRANSVR_UNEXCPT; -} - - -int -sfp_get_soft_rs1(struct transvr_obj_s *self){ - /* Note: - * SFP Soft RS(1) Select address - * A2h, offset: 118, bit 3 (begin form 0) - */ - int err_code = DEBUG_TRANSVR_INT_VAL; - int bit_shift = 3; - uint8_t result = 0x00; - uint8_t bitmask = (1 << bit_shift); - - /* Check rate identifier is supported */ - err_code = self->get_rate_id(self); - if (err_code <= 0) { - return ERR_TRANSVR_NOTSUPPORT; - } - /* Update and check */ - err_code = _check_by_mode(self, - &_sfp_update_attr_soft_rs1, - "sfp_get_soft_rs1"); - if (err_code <0){ - return err_code; - } - result = (self->soft_rs1 & bitmask); - if (result == bitmask) { - return 1; - } - if (result == 0) { - return 0; - } - return ERR_TRANSVR_UNEXCPT; -} - - -int -sfp_get_transvr_temp(struct transvr_obj_s *self, - char *buf_p) { - - int lmax = 8; - int err_code = DEBUG_TRANSVR_INT_VAL; - - err_code = _check_by_mode(self, - &_sfp_update_attr_curr_temp, - "sfp_get_transvr_temp"); - if (err_code < 0) { - return snprintf(buf_p, lmax, "%d\n", err_code); - } - if ((self->curr_temp[0]) == DEBUG_TRANSVR_HEX_VAL) { - return snprintf(buf_p, lmax, "%d\n", ERR_TRANSVR_UPDATE_FAIL); - } - return _common_count_temp(self->curr_temp[0], - self->curr_temp[1], - buf_p); -} - - -int -sfp_get_transvr_voltage(struct transvr_obj_s *self, - char *buf_p) { - - int lmax = 8; - int err_code = DEBUG_TRANSVR_INT_VAL; - - err_code = _check_by_mode(self, - &_sfp_update_attr_curr_voltage, - "sfp_get_transvr_voltage"); - if (err_code < 0) { - return snprintf(buf_p, lmax, "%d\n", err_code); - } - if ((self->curr_voltage[0]) == DEBUG_TRANSVR_HEX_VAL) { - return snprintf(buf_p, lmax, "%d\n", ERR_TRANSVR_UPDATE_FAIL); - } - /* Return Unit: 1 Volt */ - return _common_count_voltage(self->curr_voltage[0], - self->curr_voltage[1], - buf_p); -} - - -int -sfp_get_transvr_tx_bias(struct transvr_obj_s *self, - char *buf_p) { - - int lmax = 8; - int err_code = DEBUG_TRANSVR_INT_VAL; - - err_code = _check_by_mode(self, - &_sfp_update_attr_curr_tx_bias, - "sfp_get_transvr_tx_bias"); - if (err_code < 0) { - return snprintf(buf_p, lmax, "%d\n", err_code); - } - if ((self->curr_tx_bias[0]) == DEBUG_TRANSVR_HEX_VAL) { - return snprintf(buf_p, lmax, "%d\n", ERR_TRANSVR_UPDATE_FAIL); - } - /* Return Unit: 1 mA */ - return _common_count_tx_bias(self->curr_tx_bias[0], - self->curr_tx_bias[1], - buf_p); -} - - -int -sfp_get_transvr_tx_power(struct transvr_obj_s *self, - char *buf_p) { - - int lmax = 8; - int err_code = DEBUG_TRANSVR_INT_VAL; - - err_code = _check_by_mode(self, - &_sfp_update_attr_curr_tx_power, - "sfp_get_transvr_tx_power"); - if (err_code < 0) { - return snprintf(buf_p, lmax, "%d\n", err_code); - } - if ((self->curr_tx_bias[0]) == DEBUG_TRANSVR_HEX_VAL) { - return snprintf(buf_p, lmax, "%d\n", ERR_TRANSVR_UPDATE_FAIL); - } - /* Return Unit: 1 mW */ - return _common_count_tx_power(self->curr_tx_power[0], - self->curr_tx_power[1], - buf_p); -} - - -int -sfp_get_transvr_rx_power(struct transvr_obj_s *self, - char *buf_p) { - - int lmax = 8; - int err_code = DEBUG_TRANSVR_INT_VAL; - - err_code = _check_by_mode(self, - &_sfp_update_attr_curr_rx_power, - "sfp_get_transvr_rx_power"); - if (err_code < 0) { - return snprintf(buf_p, lmax, "%d\n", err_code); - } - if ((self->curr_tx_bias[0]) == DEBUG_TRANSVR_HEX_VAL) { - return snprintf(buf_p, lmax, "%d\n", ERR_TRANSVR_UPDATE_FAIL); - } - /* Return Unit: 1 mW */ - return _common_count_rx_power(self->curr_rx_power[0], - self->curr_rx_power[0], - buf_p); -} - - -int -sfp_get_transvr_rx_em(struct transvr_obj_s *self, - char *buf_p) { - - int limt = 8; - int err = DEBUG_TRANSVR_INT_VAL; - - err = _check_by_mode(self, - &_sfp_update_attr_rx_em, - "sfp_get_transvr_rx_em"); - if (err < 0) { - return snprintf(buf_p, limt, "%d\n", err); - } - if ((self->tx_eq[0]) == DEBUG_TRANSVR_HEX_VAL) { - return snprintf(buf_p, limt, "%d\n", ERR_TRANSVR_UPDATE_FAIL); - } - return snprintf(buf_p, limt, "0x%02x\n", self->rx_em[0]); -} - - -int -sfp_get_transvr_tx_eq(struct transvr_obj_s *self, - char *buf_p) { - - int limt = 8; - int err = DEBUG_TRANSVR_INT_VAL; - - err = _check_by_mode(self, - &_sfp_update_attr_tx_eq, - "sfp_get_transvr_tx_eq"); - if (err < 0) { - return snprintf(buf_p, limt, "%d\n", err); - } - if ((self->tx_eq[0]) == DEBUG_TRANSVR_HEX_VAL) { - return snprintf(buf_p, limt, "%d\n", ERR_TRANSVR_UPDATE_FAIL); - } - return snprintf(buf_p, limt, "0x%02x\n", self->tx_eq[0]); -} - - -int -_sfp_get_comp_extended(struct transvr_obj_s *self) { - /* Address: A0h / 36 - * Reference: SFF-8024 TABLE 4-4 - */ - if ((self->state == STATE_TRANSVR_CONNECTED) || - (self->state == STATE_TRANSVR_INIT) ) { - return (int)(self->transvr_comp_ext); - } - return ERR_TRANSVR_ABNORMAL; -} - - -int -__sfp_get_comp_attr(struct transvr_obj_s *self, - int array_offset) { - /* SFP Specification Compliance: A0h / 3-10 - * transvr_comp[0-7] = 3 - 10 - */ - if ((self->state == STATE_TRANSVR_CONNECTED) || - (self->state == STATE_TRANSVR_INIT) ) { - return (int)(self->transvr_comp[array_offset]); - } - return ERR_TRANSVR_ABNORMAL; -} - - -int -_sfp_get_comp_10g_eth_comp(struct transvr_obj_s *self) { - /* transvr_comp[0] = address A0h / 3 - * - * 3 7: 10G Base-ER - * 3 6: 10GBASE-LRM - * 3 5: 10GBASE-LR - * 3 4: 10GBASE-SR - */ - int bitmask = 0xf0; /* 11110000 */ - return (__sfp_get_comp_attr(self, 0) & bitmask); -} - - -int -_sfp_get_comp_1g_eth_comp(struct transvr_obj_s *self) { - /* transvr_comp[3] = address A0h / 6 - * - * 6 7: BASE-PX *3 - * 6 6: BASE-BX10 *3 - * 6 5: 100BASE-FX - * 6 4: 100BASE-LX/LX10 - * 6 3: 1000BASE-T - * 6 2: 1000BASE-CX - * 6 1: 1000BASE-LX *3 - * 6 0: 1000BASE-SX - */ - return __sfp_get_comp_attr(self, 3); -} - - -int -_sfp_get_cable_tech(struct transvr_obj_s *self) { - /* transvr_comp[5] = address A0h / 8 - * - * 8 3: Active Cable *8 - * 8 2: Passive Cable *8 - */ - int bitmask = 0x0c; /* 00001100 */ - return (__sfp_get_comp_attr(self, 5) & bitmask); -} - - -int -sfp_get_comp_eth_1(struct transvr_obj_s *self){ - - int err_code = _check_by_mode(self, - &_common_update_attr_transvr_comp, - "sfp_get_comp_eth_1"); - if (err_code < 0){ - return err_code; - } - return _sfp_get_comp_1g_eth_comp(self); -} - - -int -sfp_get_comp_eth_10(struct transvr_obj_s *self){ - - int err_code = _check_by_mode(self, - &_common_update_attr_transvr_comp, - "sfp_get_comp_eth_10"); - if (err_code < 0){ - return err_code; - } - return _sfp_get_comp_10g_eth_comp(self); -} - - -int -_sfp_get_connector_type(struct transvr_obj_s *self) { - /* Address: A0h / 2 - * Reference: SFF-8024 TABLE 4-3 - */ - if ((self->state == STATE_TRANSVR_CONNECTED) || - (self->state == STATE_TRANSVR_INIT) ) { - return (int)(self->connector); - } - return ERR_TRANSVR_ABNORMAL; -} - - -int -sfp_get_wavelength(struct transvr_obj_s *self, - char *buf_p) { - /* [Note] Optical and Cable Variants Specification Compliance (SFF-8472) - * [Addr] A0h, Bytes 60-61 - * [Note] For optical variants, as defined by having zero's in A0h Byte 8 - * bits 2 and 3, Bytes 60 and 61 denote nominal transmitter output - * wavelength at room temperature. 16 bit value with byte 60 as high - * order byte and byte 61 as low order byte. The laser wavelength is - * equal to the 16 bit integer value in nm. This field allows the user - * to read the laser wavelength directly, so it is not necessary to - * infer it from the Transceiver Codes A0h Bytes 3 to 10 (see Table - * 5-3). This also allows specification of wavelengths not covered - * in the Transceiver Codes, such as those used in coarse WDM systems. - * - * For passive and active cable variants, a value of 00h for both A0h - * Byte 60 and Byte 61 denotes laser wavelength or cable specification - * compliance is unspecified. - */ - - int lmax = 8; - int err_code = DEBUG_TRANSVR_INT_VAL; - - err_code = _check_by_mode(self, - &_common_update_attr_wavelength, - "common_get_wavelength"); - if (err_code < 0) { - return snprintf(buf_p, lmax, "%d\n", err_code); - } - if ((self->wavelength[0]) == DEBUG_TRANSVR_HEX_VAL) { - return snprintf(buf_p, lmax, "%d\n", ERR_TRANSVR_UPDATE_FAIL); - } - /* unit: 1 um */ - return snprintf(buf_p, lmax, "%d\n", - _common_count_wavelength(self, - self->wavelength[0], - self->wavelength[1])); -} - - -int -__qsfp_get_power_cls(struct transvr_obj_s *self, - int direct_access){ - - int err_code; - uint8_t detect_val; - - /* Detect and Update power class attribute */ - if (direct_access){ - err_code = _check_by_mode(self, - &_common_update_attr_extended_id, - "__qsfp_get_power_cls"); - } else { - err_code = self->ext_id; - } - if (err_code <0){ - return err_code; - } - if (err_code == DEBUG_TRANSVR_HEX_VAL){ - return ERR_TRANSVR_UPDATE_FAIL; - } - /* Clean data */ - detect_val = self->ext_id; - SWP_BIT_CLEAR(detect_val, 2); /* Bit2: CDR RX present */ - SWP_BIT_CLEAR(detect_val, 3); /* Bit3: CDR TX present */ - SWP_BIT_CLEAR(detect_val, 4); /* Bit4: CLEI present */ - SWP_BIT_CLEAR(detect_val, 5); /* Bit5: reserved */ - /* Identify power class */ - switch (detect_val) { - case 0: /* Class_1: 00000000 */ - return 1; - case 64: /* Class_2: 01000000 */ - return 2; - case 128: /* Class_3: 10000000 */ - return 3; - case 192: /* Class_4: 11000000 */ - return 4; - case 1: /* Class_5: 00000001 */ - case 193: /* Class_5: 11000001 */ - return 5; - case 2: /* Class_6: 00000010 */ - case 194: /* Class_6: 11000010 */ - return 6; - case 3: /* Class_7: 00000011 */ - case 195: /* Class_7: 11000011 */ - return 7; - default: - break; - } - SWPS_INFO("%s: Detect undefined power class:%d\n", __func__, detect_val); - return ERR_TRANSVR_UNDEFINED; -} - - -int -qsfp_get_power_cls(struct transvr_obj_s *self) { - return __qsfp_get_power_cls(self, 1); -} - - -int -__qsfp_get_cdr_present(struct transvr_obj_s *self, - int direct_access){ - - int retval; - int BIT_SHIFT = 2; - int BIT_MASK = 0x3; - - /* Detect and Update power class attribute */ - if (direct_access) { - retval = _check_by_mode(self, - &_common_update_attr_extended_id, - "__qsfp_get_cdr_present"); - if (retval < 0){ - return retval; - } - } - retval = self->ext_id; - if (retval == DEBUG_TRANSVR_HEX_VAL){ - return ERR_TRANSVR_UPDATE_FAIL; - } - /* Clean data and return */ - return (int)(retval >> BIT_SHIFT & BIT_MASK); -} - - -int -qsfp_get_cdr_present(struct transvr_obj_s *self) { - return __qsfp_get_cdr_present(self, 1); -} - - -int -qsfp_get_cdr(struct transvr_obj_s *self){ - - int err_code = _check_by_mode(self, - &_qsfp_update_attr_cdr, - "qsfp_get_cdr"); - if (err_code <0){ - return err_code; - } - - return self->cdr; -} - - -int -__qsfp_get_comp_attr(struct transvr_obj_s *self, - int array_offset) { - /* QSFP Specification Compliance: 00h / 131-138 - * transvr_comp[0-7] = 131 - 138 - */ - if ((self->state == STATE_TRANSVR_CONNECTED) || - (self->state == STATE_TRANSVR_INIT) ) { - return (int)(self->transvr_comp[array_offset]); - } - return ERR_TRANSVR_ABNORMAL; -} - - -int -_qsfp_get_comp_10_40_100_ethernet(struct transvr_obj_s *self) { - /* transvr_comp[0] = address 00h / 131 - * - * 131 7: Extended: See section 6.3.23. The Extended Specification Compliance - * Codes are maintained in the Transceiver Management section of SFF- - * 8024. - * 131 6: 10GBASE-LRM - * 131 5: 10GBASE-LR - * 131 4: 10GBASE-SR - * 131 3: 40GBASE-CR4 - * 131 2: 40GBASE-SR4 - * 131 1: 40GBASE-LR4 - * 131 0: 40G Active Cable (XLPPI) - */ - return __qsfp_get_comp_attr(self, 0); -} - - -int -_qsfp_get_comp_sonet(struct transvr_obj_s *self) { - /* transvr_comp[1] = address 00h / 132 - * - * 132 7-3: Reserved - * 132 2: OC 48, long reach - * 132 1: OC 48, intermediate reach - * 132 0: OC 48 short reach - */ - return __qsfp_get_comp_attr(self, 1); -} - - -int -_qsfp_get_comp_sas_sata(struct transvr_obj_s *self) { - /* transvr_comp[1] = address 00h / 132 - * - * 133 7: SAS 24.0 Gb/s - * 133 6: SAS 12.0 Gb/s - * 133 5: SAS 6.0 Gb/s - * 133 4: SAS 3.0 Gb/s - * 133 3-0: Reserved - */ - return __qsfp_get_comp_attr(self, 2); -} - - -int -_qsfp_get_comp_ethernet(struct transvr_obj_s *self) { - /* transvr_comp[1] = address 00h / 132 - * - * 134 7-4: Reserved - * 134 3: 1000BASE-T - * 134 2: 1000BASE-CX - * 134 1: 1000BASE-LX - * 134 0: 1000BASE-SX - */ - return __qsfp_get_comp_attr(self, 3); -} - - -int -_qsfp_get_comp_fc_link_length(struct transvr_obj_s *self) { - /* transvr_comp[1] = address 00h / 132 - * - * 135 7: Very long distance (V) - * 135 6: Short distance (S) - * 135 5: Intermediate distance (I) - * 135 4: Long distance (L) - * 135 3: Medium (M) - */ - int mask = 0xFC; /* 11111100 */ - return (__qsfp_get_comp_attr(self, 4) & mask); -} - - -int -_qsfp_get_comp_fc_trans_tech(struct transvr_obj_s *self) { - /* transvr_comp[1] = address 00h / 132 - * - * 135 2: Reserved - * 135 1: Longwave laser (LC) - * 135 0: Electrical inter-enclosure (EL) - * - * 136 7: Electrical intra-enclosure - * 136 6: Shortwave laser w/o OFC (SN) - * 136 5: Shortwave laser w OFC (SL) - * 136 4: Longwave Laser (LL) - * 136 3-0: Reserved - * - * return value = [bit 8-15:addr 135][bit 0-7:addr 136] - */ - int mask_135 = 7; /* 00000111 */ - int val_135 = (__qsfp_get_comp_attr(self, 4) & mask_135); - int val_136 = __qsfp_get_comp_attr(self, 5); - return ((val_135 << 7) + val_136); -} - - -int -_qsfp_get_comp_fc_trans_media(struct transvr_obj_s *self) { - /* transvr_comp[1] = address 00h / 132 - * - * 137 7: Twin Axial Pair (TW) - * 137 6: Shielded Twisted Pair (TP) - * 137 5: Miniature Coax (MI) - * 137 4: Video Coax (TV) - * 137 3: Multi-mode 62.5 m (M6) - * 137 2: Multi-mode 50 m (M5) - * 137 1: Multi-mode 50 um (OM3) - * 137 0: Single Mode (SM) - */ - return __qsfp_get_comp_attr(self, 6); -} - - -int -_qsfp_get_comp_fc_speed(struct transvr_obj_s *self) { - /* transvr_comp[1] = address 00h / 132 - * - * 138 7: 1200 MBps (per channel) - * 138 6: 800 MBps - * 138 5: 1600 MBps (per channel) - * 138 4: 400 MBps - * 138 3: 3200 MBps (per channel) - * 138 2: 200 MBps - * 138 1: Extended: See section 6.3.23. The Extended Specification - * Compliance Codes are maintained in the Transceiver Management - * section of SFF-8024. - * 138 0: 100 MBps - */ - return __qsfp_get_comp_attr(self, 7); -} - - -int -_qsfp_get_comp_extended(struct transvr_obj_s *self) { - /* Address: 00h / 192 - * Reference: SFF-8024 TABLE 4-4 - */ - if ((self->state == STATE_TRANSVR_CONNECTED) || - (self->state == STATE_TRANSVR_INIT) ) { - return (int)(self->transvr_comp_ext); - } - return ERR_TRANSVR_ABNORMAL; -} - - -int -qsfp_get_comp_eth(struct transvr_obj_s *self){ - - int err_code = _check_by_mode(self, - &_common_update_attr_transvr_comp, - "qsfp_get_comp_eth"); - if (err_code < 0){ - return err_code; - } - return _qsfp_get_comp_ethernet(self); -} - - -int -qsfp_get_comp_10_40(struct transvr_obj_s *self) { - - int err_code = _check_by_mode(self, - &_common_update_attr_transvr_comp, - "qsfp_get_comp_10_40"); - if (err_code < 0){ - return err_code; - } - return _qsfp_get_comp_10_40_100_ethernet(self); -} - - -int -_qsfp_get_connector_type(struct transvr_obj_s *self) { - /* Address: 00h / 130 - * Reference: SFF-8024 TABLE 4-3 - */ - if ((self->state == STATE_TRANSVR_CONNECTED) || - (self->state == STATE_TRANSVR_INIT) ) { - return (int)(self->connector); - } - return ERR_TRANSVR_ABNORMAL; -} - - -int -qsfp_get_transvr_temp(struct transvr_obj_s *self, - char *buf_p) { - - int lmax = 8; - int err_code = DEBUG_TRANSVR_INT_VAL; - - err_code = _check_by_mode(self, - &_qsfp_update_attr_curr_temp, - "qsfp_get_transvr_temp"); - if (err_code < 0) { - return snprintf(buf_p, lmax, "%d\n", err_code); - } - if ((self->curr_temp[0]) == DEBUG_TRANSVR_HEX_VAL) { - return snprintf(buf_p, lmax, "%d\n", ERR_TRANSVR_UPDATE_FAIL); - } - return _common_count_temp(self->curr_temp[0], - self->curr_temp[1], - buf_p); -} - - -int -qsfp_get_transvr_voltage(struct transvr_obj_s *self, - char *buf_p) { - - int lmax = 8; - int err_code = DEBUG_TRANSVR_INT_VAL; - - err_code = _check_by_mode(self, - &_qsfp_update_attr_curr_voltage, - "qsfp_get_transvr_voltage"); - if (err_code < 0) { - return snprintf(buf_p, lmax, "%d\n", err_code); - } - if ((self->curr_voltage[0]) == DEBUG_TRANSVR_HEX_VAL) { - return snprintf(buf_p, lmax, "%d\n", ERR_TRANSVR_UPDATE_FAIL); - } - /* Return Unit: 1 Volt */ - return _common_count_voltage(self->curr_voltage[0], - self->curr_voltage[1], - buf_p); -} - - -int -qsfp_get_transvr_tx_eq(struct transvr_obj_s *self, - char *buf_p) { - - int limt = 8; - int err = DEBUG_TRANSVR_INT_VAL; - - err = _check_by_mode(self, - &_qsfp_update_attr_tx_eq, - "qsfp_get_transvr_tx_eq"); - if (err < 0) { - return snprintf(buf_p, limt, "%d\n", err); - } - if ((self->tx_eq[0]) == DEBUG_TRANSVR_HEX_VAL) { - return snprintf(buf_p, limt, "%d\n", ERR_TRANSVR_UPDATE_FAIL); - } - return snprintf(buf_p, limt, "0x%02x%02x\n", - self->tx_eq[0], self->tx_eq[1]); -} - - -int -qsfp_get_transvr_rx_am(struct transvr_obj_s *self, - char *buf_p) { - - int limt = 8; - int err = DEBUG_TRANSVR_INT_VAL; - - err = _check_by_mode(self, - &_qsfp_update_attr_rx_am, - "qsfp_get_transvr_rx_am"); - if (err < 0) { - return snprintf(buf_p, limt, "%d\n", err); - } - if ((self->rx_am[0]) == DEBUG_TRANSVR_HEX_VAL) { - return snprintf(buf_p, limt, "%d\n", ERR_TRANSVR_UPDATE_FAIL); - } - return snprintf(buf_p, limt, "0x%02x%02x\n", - self->rx_am[0], self->rx_am[1]); -} - - -int -qsfp_get_transvr_rx_em(struct transvr_obj_s *self, - char *buf_p) { - - int limt = 8; - int err = DEBUG_TRANSVR_INT_VAL; - - err = _check_by_mode(self, - &_qsfp_update_attr_rx_em, - "qsfp_get_transvr_rx_em"); - if (err < 0) { - return snprintf(buf_p, limt, "%d\n", err); - } - if ((self->rx_em[0]) == DEBUG_TRANSVR_HEX_VAL) { - return snprintf(buf_p, limt, "%d\n", ERR_TRANSVR_UPDATE_FAIL); - } - return snprintf(buf_p, limt, "0x%02x%02x\n", - self->rx_em[0], self->rx_em[1]); -} - - -int -_qsfp_get_channel_diag(uint8_t *data_array, - int (*count_func)(uint8_t high_byte, uint8_t low_byte, char *buf_p), - char *ch_name, - char *result_p) { - int i, high, low; - int len_max = 128; - char ch_buf[4][16] = { DEBUG_TRANSVR_STR_VAL, - DEBUG_TRANSVR_STR_VAL, - DEBUG_TRANSVR_STR_VAL, - DEBUG_TRANSVR_STR_VAL }; - - for (i=0; i<4; i++) { - high = (i*2); - low = ((i*2) + 1); - count_func(data_array[high], data_array[low], ch_buf[i]); - } - return snprintf(result_p, len_max, - "%s-%d:%s%s-%d:%s%s-%d:%s%s-%d:%s", - ch_name, 1, ch_buf[0], - ch_name, 2, ch_buf[1], - ch_name, 3, ch_buf[2], - ch_name, 4, ch_buf[3]); -} - - -int -qsfp_get_soft_rx_los(struct transvr_obj_s *self, - char *buf_p) { - - int lmax = 8; - int mask = 0x0f; /* Bit 0 ~ Bit 3 */ - int err_code = DEBUG_TRANSVR_INT_VAL; - - err_code = _check_by_mode(self, - &_qsfp_update_attr_soft_rx_los, - "qsfp_get_soft_rx_los"); - if (err_code < 0) { - return snprintf(buf_p, lmax, "%d\n", err_code); - } - return snprintf(buf_p, lmax, "0x%02x\n", (self->rx_los & mask)); -} - - -int -qsfp_get_soft_tx_disable(struct transvr_obj_s *self, - char *buf_p) { - - int lmax = 8; - int mask = 0x0f; /* Bit 0 ~ Bit 3 */ - int err_code = DEBUG_TRANSVR_INT_VAL; - - err_code = _check_by_mode(self, - &_qsfp_update_attr_soft_tx_disable, - "qsfp_get_soft_tx_disable"); - if (err_code < 0) { - return snprintf(buf_p, lmax, "%d\n", err_code); - } - return snprintf(buf_p, lmax, "0x%02x\n", (self->tx_disable & mask)); -} - - -int -qsfp_get_soft_tx_fault(struct transvr_obj_s *self, - char *buf_p) { - - int lmax = 8; - int mask = 0x0f; /* Bit 0 ~ Bit 3 */ - int err_code = DEBUG_TRANSVR_INT_VAL; - - err_code = _check_by_mode(self, - &_qsfp_update_attr_soft_tx_fault, - "qsfp_get_soft_tx_fault"); - if (err_code < 0) { - return snprintf(buf_p, lmax, "%d\n", err_code); - } - return snprintf(buf_p, lmax, "0x%02x\n", (self->tx_fault & mask)); -} - - -int -qsfp_get_auto_tx_disable(struct transvr_obj_s *self, - char *buf_p) { - - if (self->auto_tx_disable == VAL_TRANSVR_FUNCTION_DISABLE) { - return snprintf(buf_p, LEN_TRANSVR_S_STR, - "%d\n", ERR_TRANSVR_FUNC_DISABLE); - } - return snprintf(buf_p, LEN_TRANSVR_S_STR, - "0x%02x\n", self->auto_tx_disable); -} - - -int -qsfp_get_transvr_tx_bias(struct transvr_obj_s *self, - char *buf_p) { - - int lmax = 8; - int err_code = DEBUG_TRANSVR_INT_VAL; - char *ch_name = "TX"; - - err_code = _check_by_mode(self, - &_qsfp_update_attr_curr_tx_bias, - "qsfp_get_transvr_tx_bias"); - if (err_code < 0) { - return snprintf(buf_p, lmax, "%d\n", err_code); - } - if ((self->curr_tx_bias[0]) == DEBUG_TRANSVR_HEX_VAL) { - return snprintf(buf_p, lmax, "%d\n", ERR_TRANSVR_UPDATE_FAIL); - } - /* Return Unit: 1 mA */ - return _qsfp_get_channel_diag(self->curr_tx_bias, - _common_count_tx_bias, - ch_name, - buf_p); -} - - -int -qsfp_get_transvr_tx_power(struct transvr_obj_s *self, - char *buf_p) { - - int lmax = 8; - int err_code = DEBUG_TRANSVR_INT_VAL; - char *ch_name = "TX"; - - err_code = _check_by_mode(self, - &_qsfp_update_attr_curr_tx_power, - "qsfp_get_transvr_tx_power"); - if (err_code < 0) { - return snprintf(buf_p, lmax, "%d\n", err_code); - } - if ((self->curr_tx_power[0]) == DEBUG_TRANSVR_HEX_VAL) { - return snprintf(buf_p, lmax, "%d\n", ERR_TRANSVR_UPDATE_FAIL); - } - /* Return Unit: 1 mW */ - return _qsfp_get_channel_diag(self->curr_tx_power, - _common_count_tx_power, - ch_name, - buf_p); -} - - -int -qsfp_get_transvr_rx_power(struct transvr_obj_s *self, - char *buf_p) { - - int lmax = 8; - int err_code = DEBUG_TRANSVR_INT_VAL; - char *ch_name = "RX"; - - err_code = _check_by_mode(self, - &_qsfp_update_attr_curr_rx_power, - "qsfp_get_transvr_rx_power"); - if (err_code < 0) { - return snprintf(buf_p, lmax, "%d\n", err_code); - } - if ((self->curr_tx_power[0]) == DEBUG_TRANSVR_HEX_VAL) { - return snprintf(buf_p, lmax, "%d\n", ERR_TRANSVR_UPDATE_FAIL); - } - /* Return Unit: 1 mW */ - return _qsfp_get_channel_diag(self->curr_rx_power, - _common_count_rx_power, - ch_name, - buf_p); -} - - -int -qsfp_get_wavelength(struct transvr_obj_s *self, - char *buf_p) { - /* [Desc] Wavelength or Copper Cable Attenuation (SFF-8636) - * [Addr] 00h 186-187 - * [Note] - * For optical free side devices, this parameter identifies the nominal - * transmitter output wavelength at room temperature. This parameter is - * a 16-bit hex value with Byte 186 as high order byte and Byte 187 as - * low order byte. The laser wavelength is equal to the 16-bit integer value - * divided by 20 in nm (units of 0.05 nm). This resolution should be adequate - * to cover all relevant wavelengths yet provide enough resolution for all - * expected DWDM applications. For accurate representation of controlled - * wavelength applications, this value should represent the center of the - * guaranteed wavelength range. - * If the free side device is identified as copper cable these registers will - * be used to define the cable attenuation. An indication of 0 dB attenuation - * refers to the case where the attenuation is not known or is unavailable. - * Byte 186 (00-FFh) is the copper cable attenuation at 2.5 GHz in units of 1 dB. - * Byte 187 (00-FFh) is the copper cable attenuation at 5.0 GHz in units of 1 dB. - */ - int lmax = 8; - int err_code = DEBUG_TRANSVR_INT_VAL; - - err_code = _check_by_mode(self, - &_common_update_attr_wavelength, - "common_get_wavelength"); - if (err_code < 0) { - return snprintf(buf_p, lmax, "%d\n", err_code); - } - if ((self->wavelength[0]) == DEBUG_TRANSVR_HEX_VAL) { - return snprintf(buf_p, lmax, "%d\n", ERR_TRANSVR_UPDATE_FAIL); - } - /* unit: 1 um */ - return snprintf(buf_p, lmax, "%d\n", - _common_count_wavelength(self, - self->wavelength[0], - self->wavelength[1])); -} - - -/* Public Function for Setup Features - */ -static int -__sfp_set_soft_rs(struct transvr_obj_s *self, - int input_val, - int address, - int page, - int offset, - int bit_shift, - uint8_t *attr_p, - char *caller, - int show_err) { - - int retval = ERR_TRANSVR_UNEXCPT; - int err_code = ERR_TRANSVR_UNEXCPT; - char *err_msg = DEBUG_TRANSVR_STR_VAL; - uint8_t update_val = (*attr_p); - - switch (input_val) { - case 0: - SWP_BIT_CLEAR(update_val, bit_shift); - break; - case 1: - SWP_BIT_SET(update_val, bit_shift); - break; - default: - retval = ERR_TRANSVR_UNEXCPT; - err_code = ERR_TRANSVR_UNEXCPT; - err_msg = "Exception occurs"; - goto err_private_sfp_set_soft_rs_1; - } - err_code = _common_set_uint8_attr(self, - address, - page, - offset, - update_val, - attr_p, - caller, - show_err); - if (err_code < 0) { - retval = err_code; - err_msg = "Write data via i2c fail!"; - goto err_private_sfp_set_soft_rs_1; - } - (*attr_p) = update_val; - return 0; - -err_private_sfp_set_soft_rs_1: - if (show_err) { - SWPS_INFO("%s: %s :%d :%s\n :%d\n", - __func__, err_msg, err_code, self->swp_name, input_val); - } - return retval; -} - - -static int -_sfp_set_soft_rs(struct transvr_obj_s *self, - int input_val, - int address, - int page, - int offset, - int bit_shift, - int (*attr_update_func)(struct transvr_obj_s *self, int show_err), - uint8_t *attr_p, - char *caller, - int show_err) { - - int retval = ERR_TRANSVR_UNEXCPT; - int err_code = ERR_TRANSVR_UNEXCPT; - char *err_msg = DEBUG_TRANSVR_STR_VAL; - - /* Check input value */ - if ((input_val != 0) && (input_val != 1)){ - retval = ERR_TRANSVR_BADINPUT; - err_code = ERR_TRANSVR_BADINPUT; - err_msg = "Input range incorrect!"; - goto err_common_sfp_set_soft_rs_1; - } - /* Check rate identifier is supported */ - err_code = self->get_rate_id(self); - if (err_code <= 0) { - switch (err_code) { - case 0: - retval = ERR_TRANSVR_NOTSUPPORT; - err_msg = "Not support this feature"; - break; - case ERR_TRANSVR_UNINIT: - retval = ERR_TRANSVR_UNINIT; - err_msg = "Check CDR present fail!"; - break; - case ERR_TRANSVR_UNPLUGGED: - retval = ERR_TRANSVR_UNPLUGGED; - err_msg = "Transceiver unplugged!"; - break; - default: - retval = err_code; - err_msg = "Check Rate_ID fail!"; - break; - } - goto err_common_sfp_set_soft_rs_1; - } - /* Check and update */ - err_code = _check_by_mode(self, - attr_update_func, - caller); - if ( (err_code < 0) || - ((*attr_p) == DEBUG_TRANSVR_HEX_VAL) ){ - retval = err_code; - err_msg = "Get current value fail!"; - goto err_common_sfp_set_soft_rs_1; - } - /* Generate and update value */ - return __sfp_set_soft_rs(self, - input_val, - address, - page, - offset, - bit_shift, - attr_p, - caller, - show_err); - -err_common_sfp_set_soft_rs_1: - if (show_err) { - SWPS_INFO("%s: %s :%d :%s\n :%d\n", - __func__, err_msg, err_code, self->swp_name, input_val); - } - return retval; -} - - -int -sfp_set_soft_rs0(struct transvr_obj_s *self, - int input_val) { - /* Note: - * SFP Soft Rate_Select Select RX ["RS(0)"] address - * A2h, offset: 110, bit 3 - */ - int bit_shift = 3; - int show_err = 1; - return _sfp_set_soft_rs(self, - input_val, - self->eeprom_map_p->addr_soft_rs0, - self->eeprom_map_p->page_soft_rs0, - self->eeprom_map_p->offset_soft_rs0, - bit_shift, - &_sfp_update_attr_soft_rs0, - &(self->soft_rs0), - "sfp_set_soft_rs0", - show_err); -} - - -int -sfp_set_soft_rs1(struct transvr_obj_s *self, - int input_val) { - /* Note: - * SFP Soft Rate_Select Select RX ["RS(1)"] address - * A2h, offset: 118, bit 3 - */ - int bit_shift = 3; - int show_err = 1; - return _sfp_set_soft_rs(self, - input_val, - self->eeprom_map_p->addr_soft_rs1, - self->eeprom_map_p->page_soft_rs1, - self->eeprom_map_p->offset_soft_rs1, - bit_shift, - &_sfp_update_attr_soft_rs1, - &(self->soft_rs1), - "sfp_set_soft_rs1", - show_err); -} - - -int -__sfp_set_tx_eq(struct transvr_obj_s *self, - int input, - int show_e) { - - int err = DEBUG_TRANSVR_INT_VAL; - char *emsg = DEBUG_TRANSVR_STR_VAL; - uint8_t setv = DEBUG_TRANSVR_HEX_VAL; - - if ((input < 0) || (input > 0xFF)) { - emsg = "input incorrect"; - err = ERR_TRANSVR_BADINPUT; - goto err_sfp_set_tx_eq; - } - setv = (uint8_t)input; - if (self->tx_eq[0] == setv) { - return 0; - } - err = _common_set_uint8_attr(self, - self->eeprom_map_p->addr_tx_eq, - self->eeprom_map_p->page_tx_eq, - self->eeprom_map_p->offset_tx_eq, - setv, - &(self->tx_eq[0]), - "_sfp_set_tx_eq", - show_e); - if (err < 0) { - emsg = "set_uint8_attr fail"; - goto err_sfp_set_tx_eq; - } - return 0; - -err_sfp_set_tx_eq: - if (show_e) { - SWPS_INFO("%s: %s :%d\n", __func__, emsg, input); - } - return err; -} - - -int -_sfp_set_tx_eq(struct transvr_obj_s *self, - int input, - int show_e) { - - uint8_t tmp; - int i = 0; - int retry = 3; - - for (i=0; itx_eq[0]; - if (_sfp_update_attr_tx_eq(self, show_e) < 0){ - continue; - } - if (self->tx_eq[0] == tmp){ - return 0; - } - } - return ERR_TRANSVR_UPDATE_FAIL; -} - - -int -sfp_set_tx_eq(struct transvr_obj_s *self, - int input) { - - int err = _check_by_mode(self, - &_sfp_update_attr_tx_eq, - "sfp_set_tx_eq"); - if (err < 0) { - SWPS_DEBUG("%s: check fail :%d\n", __func__, err); - return err; - } - return _sfp_set_tx_eq(self, input, 1); -} - - -int -__sfp_set_rx_em(struct transvr_obj_s *self, - int input, - int show_e) { - - int err = DEBUG_TRANSVR_INT_VAL; - char *emsg = DEBUG_TRANSVR_STR_VAL; - uint8_t setv = DEBUG_TRANSVR_HEX_VAL; - - if ((input < 0) || (input > 0xFF)) { - emsg = "input incorrect"; - err = ERR_TRANSVR_BADINPUT; - goto err_sfp_set_rx_em; - } - setv = (uint8_t)input; - if (self->rx_em[0] == setv) { - return 0; - } - err = _common_set_uint8_attr(self, - self->eeprom_map_p->addr_rx_em, - self->eeprom_map_p->page_rx_em, - self->eeprom_map_p->offset_rx_em, - setv, - &(self->rx_em[0]), - "_sfp_set_rx_em", - show_e); - if (err < 0) { - emsg = "set_uint8_attr fail"; - goto err_sfp_set_rx_em; - } - return 0; - -err_sfp_set_rx_em: - if (show_e) { - SWPS_INFO("%s: %s :%d\n", __func__, emsg, input); - } - return err; -} - - -int -_sfp_set_rx_em(struct transvr_obj_s *self, - int input, - int show_e) { - - uint8_t tmp; - int i = 0; - int retry = 3; - - for (i=0; irx_em[0]; - if (_sfp_update_attr_rx_em(self, show_e) < 0){ - continue; - } - if (self->rx_em[0] == tmp){ - return 0; - } - } - return -1; -} - - -int -sfp_set_rx_em(struct transvr_obj_s *self, - int input) { - - int err = _check_by_mode(self, - &_sfp_update_attr_rx_em, - "sfp_set_rx_em"); - if (err < 0) { - SWPS_DEBUG("%s: check fail :%d\n", __func__, err); - return err; - } - return _sfp_set_rx_em(self, input, 1); -} - - -static int -__qsfp_set_cdr(struct transvr_obj_s *self, - int input_val, - int show_err) { - - uint8_t update_val; - int CDR_FEATURE_SUPPORTED = 0x3; - int retval = ERR_TRANSVR_UNEXCPT; - int err_code = ERR_TRANSVR_UNEXCPT; - char *err_msg = DEBUG_TRANSVR_STR_VAL; - char *func_name = "__qsfp_set_cdr"; - - /* Check input value */ - if ((input_val < 0) || (input_val > 0xff)){ - retval = ERR_TRANSVR_BADINPUT; - err_code = ERR_TRANSVR_BADINPUT; - err_msg = "Input range incorrect!"; - goto err_qsfp_set_cdr_1; - } - update_val = (uint8_t)input_val; - /* Check CDR supported by transceiver */ - err_code = qsfp_get_cdr_present(self); - if (err_code < 0) { - retval = err_code; - switch (err_code) { - case ERR_TRANSVR_UNINIT: - err_msg = "Check CDR present fail!"; - break; - case ERR_TRANSVR_UNPLUGGED: - err_msg = "Transceiver unplugged!"; - break; - default: - err_msg = "Check CDR present fail!"; - break; - } - goto err_qsfp_set_cdr_1; - } - if (err_code != CDR_FEATURE_SUPPORTED) { - retval = ERR_TRANSVR_NOTSUPPORT; - err_msg = "This transceiver not support CDR!"; - goto err_qsfp_set_cdr_1; - } - /* Check and update */ - err_code = _check_by_mode(self, - &_qsfp_update_attr_cdr, - func_name); - if ( (err_code < 0) || - (self->cdr == DEBUG_TRANSVR_HEX_VAL) ){ - retval = err_code; - err_msg = "Get current value fail!"; - goto err_qsfp_set_cdr_1; - } - /* Write input value to transceiver */ - return _common_set_uint8_attr(self, - self->eeprom_map_p->addr_cdr, - self->eeprom_map_p->page_cdr, - self->eeprom_map_p->offset_cdr, - update_val, - &(self->cdr), - func_name, - show_err); - -err_qsfp_set_cdr_1: - if (show_err) { - SWPS_INFO("%s: %s :%d :%s\n :%d\n", - __func__, err_msg, err_code, self->swp_name, input_val); - } - return retval; -} - - -int -qsfp_set_cdr(struct transvr_obj_s *self, - int input_val) { - return __qsfp_set_cdr(self, input_val, 1); -} - - -int -qsfp_set_soft_tx_disable(struct transvr_obj_s *self, - int input_val) { - - int show_err = 1; - int in_max = 0xf; /* 1111 */ - int in_min = 0x0; /* 0000 */ - int retval = DEBUG_TRANSVR_INT_VAL; - int update_val = DEBUG_TRANSVR_INT_VAL; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - - retval = _check_by_mode(self, - &_qsfp_update_attr_soft_tx_disable, - "qsfp_set_soft_tx_disable"); - if (retval < 0) { - snprintf(err_msg, 63, "Not ready. err:%d", retval); - goto err_qsfp_set_soft_tx_disable; - } - if ((input_val > in_max) || - (input_val < in_min) ){ - retval = ERR_TRANSVR_BADINPUT; - snprintf(err_msg, 63, "Input value:%d incorrect!", input_val); - goto err_qsfp_set_soft_tx_disable; - } - if ((self->tx_disable & 0x0f) == input_val) { - return 0; - } - update_val = ((self->tx_disable & 0xf0) & input_val); - retval = _common_set_uint8_attr(self, - self->eeprom_map_p->addr_tx_disable, - self->eeprom_map_p->page_tx_disable, - self->eeprom_map_p->offset_tx_disable, - input_val, - &(self->tx_disable), - "qsfp_set_tx_disable", - show_err); - if (retval < 0) { - snprintf(err_msg, 63, "_common_set_uint8_attr:%d fail!", retval); - goto err_qsfp_set_soft_tx_disable; - } - return 0; - -err_qsfp_set_soft_tx_disable: - SWPS_INFO("%s: %s :%s\n", __func__, err_msg, self->swp_name); - return retval; -} - - -int -_qsfp_set_auto_tx_disable(struct transvr_obj_s *self, - uint8_t update) { - - uint8_t tx_enable = 0x0; - int show_e = 1; - int err = DEBUG_TRANSVR_INT_VAL; - char *emsg = DEBUG_TRANSVR_STR_VAL; - - /* Handle timing issues */ - if (update != tx_enable) { - /* Note: - * Because there are some txvr has timing issues, - * therefore we need to execute reset cycle first. - * (enable -> other settings) - */ - err = _common_set_uint8_attr(self, - self->eeprom_map_p->addr_tx_disable, - self->eeprom_map_p->page_tx_disable, - self->eeprom_map_p->offset_tx_disable, - tx_enable, - &(self->tx_disable), - "_qsfp_set_auto_tx_disable", - show_e); - if (err < 0) { - emsg = "I2C set reset value fail"; - goto err_qsfp_set_auto_tx_disable; - } - mdelay(10); - } - /* Setup target value */ - err = _common_set_uint8_attr(self, - self->eeprom_map_p->addr_tx_disable, - self->eeprom_map_p->page_tx_disable, - self->eeprom_map_p->offset_tx_disable, - self->auto_tx_disable, - &(self->tx_disable), - "_qsfp_set_auto_tx_disable", - show_e); - if (err < 0) { - emsg = "I2C set target value fail"; - goto err_qsfp_set_auto_tx_disable; - } - /* Check and update */ - err = _common_update_uint8_attr(self, - self->eeprom_map_p->addr_tx_disable, - self->eeprom_map_p->page_tx_disable, - self->eeprom_map_p->offset_tx_disable, - self->eeprom_map_p->length_tx_disable, - &(self->tx_disable), - "_qsfp_set_auto_tx_disable", - show_e); - if (err < 0) { - emsg = "I2C get value fail"; - goto err_qsfp_set_auto_tx_disable; - } - if (self->tx_disable != update) { - emsg = "data not become effective"; - goto err_qsfp_set_auto_tx_disable; - } - return 0; - -err_qsfp_set_auto_tx_disable: - SWPS_DEBUG("%s: %s :%s\n", - __func__, emsg, self->swp_name); - return ERR_TRANSVR_UPDATE_FAIL; -} - - -int -qsfp_set_auto_tx_disable(struct transvr_obj_s *self, - int input_val) { - - int in_max = 0xf; /* 1111 */ - int in_min = 0x0; /* 0000 */ - int retval = DEBUG_TRANSVR_INT_VAL; - char *emsg = DEBUG_TRANSVR_STR_VAL; - - /* Update settings*/ - if (input_val == VAL_TRANSVR_FUNCTION_DISABLE) { - emsg = "User disable auto tx_disable"; - self->auto_tx_disable = VAL_TRANSVR_FUNCTION_DISABLE; - goto out_qsfp_set_auto_tx_disable; - } - if ((input_val > in_max) || (input_val < in_min) ){ - SWPS_INFO("%s: Input value:%d incorrect! :%s\n", - __func__, input_val, self->swp_name); - return ERR_TRANSVR_BADINPUT; - } - self->auto_tx_disable = input_val; - /* Check current soft tx_disable */ - retval = _check_by_mode(self, - &_qsfp_update_attr_soft_tx_disable, - "qsfp_set_auto_tx_disable"); - switch (retval) { - case 0: - break; - case ERR_TRANSVR_UNPLUGGED: - emsg = "Doesn't need to update"; - goto out_qsfp_set_auto_tx_disable; - default: - SWPS_INFO("%s: setup fail :%d :%s\n", - __func__, retval, self->swp_name); - return retval; - } - return _qsfp_set_auto_tx_disable(self, input_val); - -out_qsfp_set_auto_tx_disable: - SWPS_DEBUG("%s: %s :%s :%d\n :%d", - __func__, emsg, self->swp_name, input_val, retval); - return 0; -} - - -int -__qsfp_set_tx_eq(struct transvr_obj_s *self, - int input, - int show_e) { - /* [Note] - * 0x - */ - int err = DEBUG_TRANSVR_INT_VAL; - char *emsg = DEBUG_TRANSVR_STR_VAL; - uint8_t setv[2] = {0x00, 0x00}; - - if ((input < 0) || (input > 0xFFFF)) { - emsg = "input incorrect"; - err = ERR_TRANSVR_BADINPUT; - goto err_qsfp_set_tx_eq; - } - setv[0] = (uint8_t)((input & 0xFF00) >> 8); - setv[1] = (uint8_t)(input & 0xFF); - if ((self->tx_eq[0] == setv[0]) && - (self->tx_eq[1] == setv[1]) ) { - return 0; - } - err = _common_set_uint8_array(self, - self->eeprom_map_p->addr_tx_eq, - self->eeprom_map_p->page_tx_eq, - self->eeprom_map_p->offset_tx_eq, - self->eeprom_map_p->length_tx_eq, - setv, - self->tx_eq, - "_qsfp_set_tx_eq", - show_e); - if (err < 0) { - emsg = "set_uint8_array fail"; - goto err_qsfp_set_tx_eq; - } - return 0; - -err_qsfp_set_tx_eq: - if (show_e) { - SWPS_INFO("%s: %s :%d\n", __func__, emsg, input); - } - return err; -} - - -int -_qsfp_set_tx_eq(struct transvr_obj_s *self, - int input, - int show_e) { - - int i = 0; - int retry = 3; - uint8_t tmp[2]; - - for (i=0; itx_eq[0]; - tmp[1] = self->tx_eq[1]; - if (_qsfp_update_attr_tx_eq(self, show_e) < 0){ - continue; - } - if ((self->tx_eq[0] == tmp[0]) && - (self->tx_eq[1] == tmp[1]) ){ - return 0; - } - } - return -1; -} - - -int -qsfp_set_tx_eq(struct transvr_obj_s *self, - int input) { - - int err = _check_by_mode(self, - &_qsfp_update_attr_tx_eq, - "qsfp_set_tx_eq"); - if (err < 0) { - SWPS_DEBUG("%s: check fail :%d\n", __func__, err); - return err; - } - return _qsfp_set_tx_eq(self, input, 1); -} - - -int -__qsfp_set_rx_am(struct transvr_obj_s *self, - int input, - int show_e) { - /* [Note] - * 0x - */ - int err = DEBUG_TRANSVR_INT_VAL; - char *emsg = DEBUG_TRANSVR_STR_VAL; - uint8_t setv[2] = {0x00, 0x00}; - - if ((input < 0) || (input > 0xFFFF)) { - emsg = "input incorrect"; - err = ERR_TRANSVR_BADINPUT; - goto err_qsfp_set_rx_am; - } - setv[0] = (uint8_t)((input & 0xFF00) >> 8); - setv[1] = (uint8_t)(input & 0xFF); - if ((self->rx_am[0] == setv[0]) && - (self->rx_am[1] == setv[1]) ) { - return 0; - } - err = _common_set_uint8_array(self, - self->eeprom_map_p->addr_rx_am, - self->eeprom_map_p->page_rx_am, - self->eeprom_map_p->offset_rx_am, - self->eeprom_map_p->length_rx_am, - setv, - self->rx_am, - "_qsfp_set_rx_am", - show_e); - if (err < 0) { - emsg = "set_uint8_array fail"; - goto err_qsfp_set_rx_am; - } - return 0; - -err_qsfp_set_rx_am: - if (show_e) { - SWPS_INFO("%s: %s :%d\n", __func__, emsg, input); - } - return err; -} - - -int -_qsfp_set_rx_am(struct transvr_obj_s *self, - int input, - int show_e) { - - int i = 0; - int retry = 3; - uint8_t tmp[2]; - - for (i=0; irx_am[0]; - tmp[1] = self->rx_am[1]; - if (_qsfp_update_attr_rx_am(self, show_e) < 0){ - continue; - } - if ((self->rx_am[0] == tmp[0]) && - (self->rx_am[1] == tmp[1]) ){ - return 0; - } - } - return -1; -} - - -int -qsfp_set_rx_am(struct transvr_obj_s *self, - int input) { - - int err = _check_by_mode(self, - &_qsfp_update_attr_rx_am, - "qsfp_set_rx_am"); - if (err < 0) { - SWPS_DEBUG("%s: check fail :%d\n", __func__, err); - return err; - } - return _qsfp_set_rx_am(self, input, 1); -} - - -int -__qsfp_set_rx_em(struct transvr_obj_s *self, - int input, - int show_e) { - /* [Note] - * 0x - */ - int err = DEBUG_TRANSVR_INT_VAL; - char *emsg = DEBUG_TRANSVR_STR_VAL; - uint8_t setv[2] = {0x00, 0x00}; - - if ((input < 0) || (input > 0xFFFF)) { - emsg = "input incorrect"; - err = ERR_TRANSVR_BADINPUT; - goto err_qsfp_set_rx_em; - } - setv[0] = (uint8_t)((input & 0xFF00) >> 8); - setv[1] = (uint8_t)(input & 0xFF); - if ((self->rx_em[0] == setv[0]) && - (self->rx_em[1] == setv[1]) ) { - return 0; - } - err = _common_set_uint8_array(self, - self->eeprom_map_p->addr_rx_em, - self->eeprom_map_p->page_rx_em, - self->eeprom_map_p->offset_rx_em, - self->eeprom_map_p->length_rx_em, - setv, - self->rx_em, - "_qsfp_set_rx_em", - show_e); - if (err < 0) { - emsg = "set_uint8_array fail"; - goto err_qsfp_set_rx_em; - } - return 0; - -err_qsfp_set_rx_em: - if (show_e) { - SWPS_INFO("%s: %s :%d\n", __func__, emsg, input); - } - return err; -} - - -int -_qsfp_set_rx_em(struct transvr_obj_s *self, - int input, - int show_e) { - - int i = 0; - int retry = 3; - uint8_t tmp[2]; - - for (i=0; irx_em[0]; - tmp[1] = self->rx_em[1]; - if (_qsfp_update_attr_rx_em(self, show_e) < 0){ - continue; - } - if ((self->rx_em[0] == tmp[0]) && - (self->rx_em[1] == tmp[1]) ){ - return 0; - } - } - return -1; -} - - -int -qsfp_set_rx_em(struct transvr_obj_s *self, - int input) { - - int err = _check_by_mode(self, - &_qsfp_update_attr_rx_em, - "qsfp_set_rx_em"); - if (err < 0) { - SWPS_DEBUG("%s: check fail :%d\n", __func__, err); - return err; - } - return _qsfp_set_rx_em(self, input, 1); -} - - -int -common_transvr_dump(struct transvr_obj_s* self){ - - char *type_name = "Undefined"; - - if (TRANSVR_INFO_DUMP_ENABLE != 1) { - return 0; - } - switch (self->type) { - case TRANSVR_TYPE_SFP: - type_name = STR_TRANSVR_SFP; - break; - case TRANSVR_TYPE_QSFP: - type_name = STR_TRANSVR_QSFP; - break; - case TRANSVR_TYPE_QSFP_PLUS: - type_name = STR_TRANSVR_QSFP_PLUS; - break; - case TRANSVR_TYPE_QSFP_28: - type_name = STR_TRANSVR_QSFP28; - break; - case TRANSVR_TYPE_FAKE: - type_name = "FAKE"; - goto ok_common_transvr_dump; - case TRANSVR_TYPE_UNPLUGGED: - type_name = "UNPLUGGED"; - goto err_common_transvr_dump; - case TRANSVR_TYPE_INCONSISTENT: - type_name = "INCONSISTENT"; - goto err_common_transvr_dump; - case TRANSVR_TYPE_ERROR: - type_name = "ERROR"; - goto err_common_transvr_dump; - - default: - type_name = "UNEXPECTED"; - goto err_common_transvr_dump; - } - printk(KERN_INFO "[SWPS] Dump %s information:\n", self->swp_name); - printk(KERN_INFO " |- :%s\n", type_name); - printk(KERN_INFO " |- :%s\n", self->vendor_name); - printk(KERN_INFO " |- :%s\n", self->vendor_pn); - printk(KERN_INFO " |- :%s\n", self->vendor_rev); - printk(KERN_INFO " |- :%s\n", self->vendor_sn); - printk(KERN_INFO " |- :0x%02x\n", self->br); - printk(KERN_INFO " |- :0x%02x\n", self->comp_rev); - printk(KERN_INFO " |- :%d\n", self->len_om1); - printk(KERN_INFO " |- :%d\n", self->len_om2); - printk(KERN_INFO " |- :%d\n", self->len_om3); - printk(KERN_INFO " |- :%d\n", self->len_om4); - return 0; - -ok_common_transvr_dump: - SWPS_INFO("%s: %s is %s\n", __func__, self->swp_name, type_name); - return 0; - -err_common_transvr_dump: - SWPS_INFO("%s: %s is %s\n", __func__, self->swp_name, type_name); - return -1; -} - - -int -sfp_transvr_dump(struct transvr_obj_s* self) { - - if (TRANSVR_INFO_DUMP_ENABLE != 1) { - return 0; - } - if (common_transvr_dump(self) < 0) { - return -1; - } - printk(KERN_INFO " |- :%d\n", self->len_sm); - printk(KERN_INFO " |- :%d\n", self->len_smf); - printk(KERN_INFO " '- :0x%02x\n", self->rate_id); - return 0; -} - - -int -qsfp_transvr_dump(struct transvr_obj_s* self) { - - if (TRANSVR_INFO_DUMP_ENABLE != 1) { - return 0; - } - if (common_transvr_dump(self) < 0) { - return -1; - } - printk(KERN_INFO " |- :%d\n", self->len_smf); - printk(KERN_INFO " '- :Class_%d\n", __qsfp_get_power_cls(self, 0)); - return 0; -} - - -int -fake_transvr_dump(struct transvr_obj_s* self) { - - printk(KERN_INFO "[SWPS] Dump transceiver information: %s\n", self->swp_name); - printk(KERN_INFO " |- :FAKE\n"); - printk(KERN_INFO " |- :FAKE_VENDER_NAME\n"); - printk(KERN_INFO " |- :FAKE_VENDER_PN\n"); - printk(KERN_INFO " |- :FAKE_VENDER_REV\n"); - printk(KERN_INFO " |- :FAKE_VENDER_SN\n"); - printk(KERN_INFO " |- :0x99\n"); - printk(KERN_INFO " |- :99\n"); - printk(KERN_INFO " |- :99\n"); - printk(KERN_INFO " |- :99\n"); - printk(KERN_INFO " |- :99\n"); - printk(KERN_INFO " |- :99\n"); - printk(KERN_INFO " |- :99\n"); - printk(KERN_INFO " '- :0x99\n"); - return 0; -} - - -/* ========== Object functions for fake type ========== - */ -int -fake_transvr_update(struct transvr_obj_s *self, - int show_err){ - self->state = STATE_TRANSVR_CONNECTED; - return 0; -} - - -int -fake_get_binary(struct transvr_obj_s *self){ - return 1; -} - -int -fake_get_int(struct transvr_obj_s *self){ - return 99; -} - - -int -fake_get_hex(struct transvr_obj_s *self){ - return 0x0f; -} - - -int -fake_get_str(struct transvr_obj_s *self, char *buf) { - return snprintf(buf, 16, "fake_get_str\n"); -} - - -int -fake_set_int(struct transvr_obj_s *self, int input){ - SWPS_INFO("%s: %d\n", __func__, input); - return 0; -} - - -int -fake_set_hex(struct transvr_obj_s *self, int input){ - SWPS_INFO("%s: 0x%02x\n", __func__, input); - return 0; -} - - -/* ========== Object functions for unsupported ========== - */ -int -unsupported_get_func(struct transvr_obj_s *self){ - return ERR_TRANSVR_NOTSUPPORT; -} - - -int -unsupported_get_func2(struct transvr_obj_s *self, - char *buf_p) { - int len = snprintf(buf_p, 8, "%d\n", ERR_TRANSVR_NOTSUPPORT); - return len; -} - - -int -unsupported_set_func(struct transvr_obj_s *self, - int input_val){ - return ERR_TRANSVR_NOTSUPPORT; -} - - - -/* ========== Object functions for long term task ========== - * - * [Note] - * SWPS transceiver worker is likely the green-thread (coroutine). - * Due to resource and performance considerations. SWPS run all - * features in one kthread at the same time, and handle by it self. - */ - -/* For Transceiver Task Handling - */ -static struct transvr_worker_s * -transvr_task_get(struct transvr_obj_s *self, - char *func_name) { - - struct transvr_worker_s *curr_p = self->worker_p; - - while(curr_p != NULL){ - if (strcmp((curr_p->func_name), func_name) == 0 ) { - return curr_p; - } - curr_p = curr_p->next_p; - } - return NULL; -} - - -static struct transvr_worker_s* -transvr_task_creat(struct transvr_obj_s *self, - int (*main_task)(struct transvr_worker_s *task), - int (*post_task)(struct transvr_worker_s *task), - char *caller) { - - struct transvr_worker_s *task_p = NULL; - struct transvr_worker_s *curr_p = NULL; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - - /* Check task not exist */ - task_p = transvr_task_get(self, caller); - if (task_p) { - snprintf(err_msg, sizeof(err_msg), "Task already created!"); - goto err_transvr_task_creat; - } - /* Create task worker */ - task_p = kzalloc(sizeof(struct transvr_worker_s), GFP_KERNEL); - if (!task_p){ - snprintf(err_msg, sizeof(err_msg), "kzalloc fail"); - goto err_transvr_task_creat; - } - /* Setup task data */ - task_p->transvr_p = self; - task_p->next_p = NULL; - task_p->trigger_time = 0; - task_p->retry = 1; - task_p->state = STATE_T_TASK_INIT; - task_p->main_task = main_task; - task_p->post_task = post_task; - task_p->p_data = NULL; - snprintf(task_p->func_name, sizeof(task_p->func_name), "%s", caller); - /* Setup Link List */ - if (self->worker_p) { - curr_p = self->worker_p; - while(curr_p->next_p != NULL) { - curr_p = curr_p->next_p; - } - curr_p->next_p = task_p; - task_p->pre_p = curr_p; - } else { - self->worker_p = task_p; - task_p->pre_p = NULL; - } - return task_p; - -err_transvr_task_creat: - SWPS_ERR("%s: %s :%s :%s\n", - __func__, err_msg, caller, self->swp_name); - return NULL; -} - - -static void -transvr_task_free_one(struct transvr_worker_s *task_p){ - - struct transvr_worker_s *pre_p = NULL; - struct transvr_worker_s *next_p = NULL; - - if (task_p) { - pre_p = task_p->pre_p; - next_p = task_p->next_p; - - if ((pre_p) && (next_p)) { - pre_p->next_p = next_p; - next_p->pre_p = pre_p; - - } else if ((!pre_p) && (next_p)) { - next_p->pre_p = NULL; - - } else if ((pre_p) && (!next_p)) { - pre_p->next_p = NULL; - - } else if ((!pre_p) && (!next_p)) { - task_p->transvr_p->worker_p = NULL; - } else { - SWPS_ERR("%s: Unexcept case!\n :%s", - __func__, task_p->transvr_p->swp_name); - } - kfree(task_p->p_data); - kfree(task_p); - } -} - - -static void -transvr_task_free_all(struct transvr_obj_s *self) { - - struct transvr_worker_s *curr_p = NULL; - struct transvr_worker_s *next_p = NULL; - - if (self->worker_p) { - curr_p = self->worker_p; - while(curr_p) { - next_p = curr_p->next_p; - transvr_task_free_one(curr_p); - curr_p = next_p; - } - self->worker_p = NULL; - } -} - - -static int -_transvr_task_run_main(struct transvr_worker_s *task_p) { - - int retval = DEBUG_TRANSVR_INT_VAL; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - - if (!task_p){ - snprintf(err_msg, sizeof(err_msg), "main_task is NULL!"); - goto main_transvr_task_err; - } - if ((task_p->trigger_time) == 0){ - goto main_transvr_task_run; - } - if (time_before(jiffies, task_p->trigger_time)){ - goto main_transvr_task_wait; - } - goto main_transvr_task_run; - -main_transvr_task_run: - if (task_p->retry != VAL_TRANSVR_TASK_RETRY_FOREVER) { - task_p->retry -= 1; - } - retval = task_p->main_task(task_p); - if (retval < 0) { - if (task_p->retry > 0) { - task_p->state = STATE_T_TASK_WAIT; - return EVENT_TRANSVR_TASK_WAIT; - } - snprintf(err_msg, sizeof(err_msg), "Run main_task fail!"); - goto main_transvr_task_err; - } - goto main_transvr_task_identify; - -main_transvr_task_identify: - switch (retval) { - case EVENT_TRANSVR_TASK_WAIT: - task_p->state = STATE_T_TASK_WAIT; - return EVENT_TRANSVR_TASK_WAIT; - - case EVENT_TRANSVR_TASK_DONE: - task_p->state = STATE_T_TASK_DONE; - return EVENT_TRANSVR_TASK_DONE; - - default: - break; - } - snprintf(err_msg, sizeof(err_msg), "Run main_task fail!"); - goto main_transvr_task_err; - -main_transvr_task_wait: - task_p->state = STATE_T_TASK_WAIT; - return EVENT_TRANSVR_TASK_WAIT; - -main_transvr_task_err: - task_p->state = STATE_T_TASK_FAIL; - SWPS_INFO("%s: %s :%d :%s\n", - __func__, err_msg, retval, task_p->transvr_p->swp_name); - return EVENT_TRANSVR_INIT_FAIL; -} - - -static int -_transvr_task_run_post(struct transvr_worker_s *task_p) { - - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - - if ((task_p->post_task) == NULL) { - return EVENT_TRANSVR_TASK_DONE; - } - switch (task_p->state) { - case STATE_T_TASK_WAIT: - case STATE_T_TASK_INIT: - goto post_transvr_task_wait; - - case STATE_T_TASK_DONE: - case STATE_T_TASK_FAIL: - goto post_transvr_task_run; - - default: - break; - } - snprintf(err_msg, sizeof(err_msg), "Unexcept task state"); - goto post_transvr_task_err; - -post_transvr_task_run: - task_p->post_task(task_p); - return EVENT_TRANSVR_TASK_DONE; - -post_transvr_task_wait: - return EVENT_TRANSVR_TASK_WAIT; - -post_transvr_task_err: - SWPS_INFO("%s: %s :%d :%s\n", - __func__, err_msg, task_p->state, task_p->transvr_p->swp_name); - return EVENT_TRANSVR_TASK_FAIL; -} - - -static int -transvr_task_run_one(struct transvr_worker_s *task_p) { - - int retval_main = DEBUG_TRANSVR_INT_VAL; - int retval_post = DEBUG_TRANSVR_INT_VAL; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - - retval_main = _transvr_task_run_main(task_p); - if (retval_main < 0) { - snprintf(err_msg, sizeof(err_msg), "Execute main_task fail!"); - goto err_transvr_task_run_one; - } - retval_post = _transvr_task_run_post(task_p); - if (retval_post < 0) { - snprintf(err_msg, sizeof(err_msg), "Execute post_task fail!"); - goto err_transvr_task_run_one; - } - return retval_main; - -err_transvr_task_run_one: - SWPS_INFO("%s: %s
:%d :%d :%s :%s\n", - __func__, err_msg, retval_main, retval_post, - task_p->func_name, task_p->transvr_p->swp_name); - return EVENT_TRANSVR_TASK_FAIL; -} - - -static int -transvr_task_run_all(struct transvr_obj_s *self) { - - int haserr = 0; - int retval = DEBUG_TRANSVR_INT_VAL; - struct transvr_worker_s *curr_p = NULL; - struct transvr_worker_s *next_p = NULL; - - if ((self->worker_p) == NULL) { - return EVENT_TRANSVR_TASK_DONE; - } - curr_p = self->worker_p; - while (curr_p != NULL) { - next_p = curr_p->next_p; - retval = transvr_task_run_one(curr_p); - if (curr_p->retry == VAL_TRANSVR_TASK_RETRY_FOREVER) { - curr_p = next_p; - continue; - } - switch (retval) { - case EVENT_TRANSVR_TASK_WAIT: - break; - case EVENT_TRANSVR_TASK_DONE: - transvr_task_free_one(curr_p); - break; - case EVENT_TRANSVR_TASK_FAIL: - - default: - haserr = 1; - transvr_task_free_one(curr_p); - break; - } - curr_p = next_p; - } - if (haserr) { - return EVENT_TRANSVR_TASK_FAIL; - } - return EVENT_TRANSVR_TASK_DONE; -} - - -static void -transvr_task_set_delay(struct transvr_worker_s *task_p, - unsigned long delay_msec) { - - task_p->trigger_time = (jiffies + (delay_msec * (HZ/1000))); -} - - -static void -transvr_task_set_retry(struct transvr_worker_s *task_p, - unsigned long retry_times) { - - task_p->retry = retry_times; -} - - -/* For Transceiver Post Task - */ -int -taskfunc_post_do_nothing(struct transvr_worker_s *task_p) { - - return EVENT_TRANSVR_TASK_DONE; -} - - -int -taskfunc_post_handle_task_state(struct transvr_worker_s *task_p) { - - struct transvr_obj_s* tp = task_p->transvr_p; - - switch (task_p->state) { - case STATE_T_TASK_INIT: - case STATE_T_TASK_WAIT: - return EVENT_TRANSVR_TASK_WAIT; - - case STATE_T_TASK_DONE: - tp->state = STATE_TRANSVR_CONNECTED; - tp->send_uevent(tp, KOBJ_ADD); - return EVENT_TRANSVR_TASK_DONE; - - case STATE_T_TASK_FAIL: - tp->state = STATE_TRANSVR_UNEXCEPTED; - return EVENT_TRANSVR_TASK_FAIL; - - default: - break; - } - return EVENT_TRANSVR_TASK_FAIL; -} - - -/* For Transceiver Main Task - */ -int -_taskfunc_sfp_setup_soft_rs(struct transvr_worker_s *task_p, - int input_val, - int address, - int page, - int offset, - int bit_shift, - uint8_t *attr_p, - char *caller) { - - int show_err = 0; - int err_code = DEBUG_TRANSVR_INT_VAL; - char *err_str = DEBUG_TRANSVR_STR_VAL; - char *func_str = "_taskfunc_sfp_setup_soft_rs"; - - err_code = _sfp_update_attr_soft_rs0(task_p->transvr_p, 0); - if (err_code < 0) { - err_str = "Get current soft_rs0 fail!"; - goto err_taskfunc_sfp_setup_soft_rs_1; - } - err_code = __sfp_set_soft_rs(task_p->transvr_p, - input_val, - address, - page, - offset, - bit_shift, - attr_p, - caller, - show_err); - if (err_code < 0) { - err_str = "Get current soft_rs0 fail!"; - goto err_taskfunc_sfp_setup_soft_rs_1; - } - return EVENT_TRANSVR_TASK_DONE; - -err_taskfunc_sfp_setup_soft_rs_1: - if ((task_p->retry) == 0) { - SWPS_INFO("%s: %s :%s :%d :%d\n", - func_str, err_str, task_p->transvr_p->swp_name, input_val, err_code); - } - return EVENT_TRANSVR_TASK_FAIL; -} - - -int -__taskfunc_sfp_setup_hard_rs(struct transvr_worker_s *task_p, - int input_val, - int (*get_func)(struct ioexp_obj_s *self, int virt_offset), - int (*set_func)(struct ioexp_obj_s *self, int virt_offset, int input_val)) { - - int err_val = EVENT_TRANSVR_EXCEP_EXCEP; - char *err_str = DEBUG_TRANSVR_STR_VAL; - - err_val = get_func(task_p->transvr_p->ioexp_obj_p, - task_p->transvr_p->ioexp_virt_offset); - - if (err_val < 0) { - if (err_val == ERR_IOEXP_NOTSUPPORT) { - return EVENT_TRANSVR_TASK_DONE; - } - err_str = "Get current hard_rs fail!"; - goto err_p_taskfunc_sfp_setup_hard_rs_1; - } - if (err_val == input_val) { - return EVENT_TRANSVR_TASK_DONE; - } - err_val = set_func(task_p->transvr_p->ioexp_obj_p, - task_p->transvr_p->ioexp_virt_offset, - input_val); - if (err_val < 0) { - err_str = "Setup hard_rs fail!"; - goto err_p_taskfunc_sfp_setup_hard_rs_1; - } - return EVENT_TRANSVR_TASK_DONE; - -err_p_taskfunc_sfp_setup_hard_rs_1: - if ((task_p->retry) == 0) { - SWPS_INFO("%s: %s :%s :%d :%d\n", - __func__, err_str, task_p->transvr_p->swp_name, input_val, err_val); - } - return EVENT_TRANSVR_TASK_FAIL; -} - - -int -_taskfunc_sfp_setup_hard_rs0(struct transvr_worker_s *task_p, - int input_val) { - - return __taskfunc_sfp_setup_hard_rs(task_p, - input_val, - task_p->transvr_p->ioexp_obj_p->get_hard_rs0, - task_p->transvr_p->ioexp_obj_p->set_hard_rs0); -} - - -int -_taskfunc_sfp_setup_hard_rs1(struct transvr_worker_s *task_p, - int input_val) { - - return __taskfunc_sfp_setup_hard_rs(task_p, - input_val, - task_p->transvr_p->ioexp_obj_p->get_hard_rs1, - task_p->transvr_p->ioexp_obj_p->set_hard_rs1); -} - - -int -_taskfunc_sfp_setup_rs0(struct transvr_worker_s *task_p, - int input_val) { - - int bit_shift = 3; - int old_val = DEBUG_TRANSVR_INT_VAL; - int err_val = EVENT_TRANSVR_EXCEP_EXCEP; - char *err_str = DEBUG_TRANSVR_STR_VAL; - char *func_str = "_taskfunc_sfp_setup_rs0"; - - err_val = _taskfunc_sfp_setup_hard_rs0(task_p, - input_val); - if (err_val < 0) { - err_str = "Setup hard_rs0 fail!"; - goto err_private_taskfunc_sfp_setup_rs0_1; - } - old_val = err_val; - err_val = _taskfunc_sfp_setup_soft_rs(task_p, - input_val, - task_p->transvr_p->eeprom_map_p->addr_soft_rs0, - task_p->transvr_p->eeprom_map_p->page_soft_rs0, - task_p->transvr_p->eeprom_map_p->offset_soft_rs0, - bit_shift, - &(task_p->transvr_p->soft_rs0), - func_str); - if (err_val < 0) { - err_str = "Setup soft_rs0 fail!"; - goto err_private_taskfunc_sfp_setup_rs0_1; - } - return EVENT_TRANSVR_TASK_DONE; - -err_private_taskfunc_sfp_setup_rs0_1: - if ((task_p->retry) == 0) { - SWPS_INFO("%s: %s :%s :%d :%d\n", - func_str, err_str, task_p->transvr_p->swp_name, input_val, err_val); - } - _taskfunc_sfp_setup_hard_rs0(task_p, old_val); - return EVENT_TRANSVR_TASK_FAIL; -} - - -int -_taskfunc_sfp_setup_rs1(struct transvr_worker_s *task_p, - int input_val) { - - int bit_shift = 3; - int old_val = DEBUG_TRANSVR_INT_VAL; - int err_val = EVENT_TRANSVR_EXCEP_EXCEP; - char *err_str = DEBUG_TRANSVR_STR_VAL; - char *func_str = "_taskfunc_sfp_setup_rs1"; - - err_val = _taskfunc_sfp_setup_hard_rs1(task_p, - input_val); - if (err_val < 0) { - err_str = "Setup hard_rs1 fail!"; - goto err_private_taskfunc_sfp_setup_rs1_1; - } - old_val = err_val; - err_val = _taskfunc_sfp_setup_soft_rs(task_p, - input_val, - task_p->transvr_p->eeprom_map_p->addr_soft_rs1, - task_p->transvr_p->eeprom_map_p->page_soft_rs1, - task_p->transvr_p->eeprom_map_p->offset_soft_rs1, - bit_shift, - &(task_p->transvr_p->soft_rs1), - func_str); - if (err_val < 0) { - err_str = "Setup soft_rs1 fail!"; - goto err_private_taskfunc_sfp_setup_rs1_1; - } - return EVENT_TRANSVR_TASK_DONE; - -err_private_taskfunc_sfp_setup_rs1_1: - if ((task_p->retry) == 0) { - SWPS_INFO("%s: %s :%s :%d :%d\n", - func_str, err_str, task_p->transvr_p->swp_name, input_val, err_val); - } - _taskfunc_sfp_setup_hard_rs1(task_p, old_val); - return EVENT_TRANSVR_TASK_FAIL; -} - - -int -taskfunc_sfp_setup_SFF8431_case1(struct transvr_worker_s *task_p) { - /* SFF-8431 (8/4/2G Rx Rate_Select only) */ - int update_val = 1; - - return _taskfunc_sfp_setup_rs0(task_p, update_val); -} - - - -int -taskfunc_sfp_setup_SFF8431_case2(struct transvr_worker_s *task_p) { - /* SFF-8431 (8/4/2G Tx Rate_Select only) */ - int update_val = 1; - - return _taskfunc_sfp_setup_rs1(task_p, update_val); -} - - -int -taskfunc_sfp_setup_SFF8431_case3(struct transvr_worker_s *task_p) { - /* SFF-8431 (8/4/2G Independent Rx & Tx Rate_select) */ - int update_rs0 = 1; - int update_rs1 = 1; - int err_code = DEBUG_TRANSVR_INT_VAL; - - err_code = _taskfunc_sfp_setup_rs0(task_p, update_rs0); - if (err_code < 0) { - return err_code; - } - return _taskfunc_sfp_setup_rs1(task_p, update_rs1); -} - - -int -taskfunc_sfp_handle_1g_rj45(struct transvr_worker_s *task_p) { - - /* Not all of platform support 0x56 for transceiver - * external PHY, Support list as below: - * => 1. Magnolia-PVT (PS: EVT & DVT not ready) - */ - int ext_phy_addr = 0x56; - int ext_phy_page = -1; - int ext_phy_offs = 0x11; - int ext_phy_len = 1; - int lstate_mask = 0x04; /* 00000100 */ - int show_err = 0; - int fail_retry = 5; - int fail_delay = 1000; /* msec */ - int err_code = DEBUG_TRANSVR_INT_VAL; - uint8_t detect_val = DEBUG_TRANSVR_HEX_VAL; - char err_str[64] = DEBUG_TRANSVR_STR_VAL; - int *tmp_p = NULL; - char *func_name = "taskfunc_sfp_handle_1g_rj45"; - - if (task_p->transvr_p->state != STATE_TRANSVR_CONNECTED) { - return EVENT_TRANSVR_TASK_DONE; - } - if ( (task_p->transvr_p->info != TRANSVR_CLASS_BASE_T_1000) && - (task_p->transvr_p->info != TRANSVR_CLASS_BASE_T_1000_up) ) { - goto err_taskfunc_sfp_handle_1g_rj45_1; - } - err_code = _common_update_uint8_attr(task_p->transvr_p, - ext_phy_addr, - ext_phy_page, - ext_phy_offs, - ext_phy_len, - &detect_val, - func_name, - show_err); - if ( (err_code < 0) || - (detect_val == DEBUG_TRANSVR_HEX_VAL) ) { - snprintf(err_str, sizeof(err_str), "Detect external link status fail"); - goto err_taskfunc_sfp_handle_1g_rj45_2; - } - if ((detect_val & lstate_mask) == lstate_mask) { - goto ok_taskfunc_sfp_handle_1g_rj45_link_up; - } - goto ok_taskfunc_sfp_handle_1g_rj45_link_down; - -ok_taskfunc_sfp_handle_1g_rj45_link_up: - /* Filter out noise */ - if (!(task_p->p_data)) { - tmp_p = kzalloc(sizeof(int), GFP_KERNEL); - if (!tmp_p) { - snprintf(err_str, sizeof(err_str), "kzalloc p_data fail"); - goto err_taskfunc_sfp_handle_1g_rj45_2; - } - *tmp_p = TRANSVR_CLASS_BASE_T_1000_up; - task_p->p_data = tmp_p; - goto ok_taskfunc_sfp_handle_1g_rj45_done; - } - if ((*(int *)(task_p->p_data)) != TRANSVR_CLASS_BASE_T_1000_up) { - kfree(task_p->p_data); - task_p->p_data = NULL; - snprintf(err_str, sizeof(err_str), "Internal error"); - goto err_taskfunc_sfp_handle_1g_rj45_2; - } - task_p->transvr_p->info = TRANSVR_CLASS_BASE_T_1000_up; - kfree(task_p->p_data); - task_p->p_data = NULL; - goto ok_taskfunc_sfp_handle_1g_rj45_done; - -ok_taskfunc_sfp_handle_1g_rj45_link_down: - if (task_p->p_data) { - kfree(task_p->p_data); - task_p->p_data = NULL; - } - task_p->transvr_p->info = TRANSVR_CLASS_BASE_T_1000; - goto ok_taskfunc_sfp_handle_1g_rj45_done; - -ok_taskfunc_sfp_handle_1g_rj45_done: - if (task_p->retry != VAL_TRANSVR_TASK_RETRY_FOREVER) { - transvr_task_set_retry(task_p, VAL_TRANSVR_TASK_RETRY_FOREVER); - } - return EVENT_TRANSVR_TASK_DONE; - -err_taskfunc_sfp_handle_1g_rj45_1: - snprintf(err_str, sizeof(err_str), "Detect transceiver:%d not Base-T, remove task.", - task_p->transvr_p->info); - SWPS_INFO("%s: %s :%s\n", __func__, err_str, task_p->transvr_p->swp_name); - transvr_task_set_retry(task_p, 0); - return EVENT_TRANSVR_TASK_DONE; - -err_taskfunc_sfp_handle_1g_rj45_2: - if (task_p->retry == VAL_TRANSVR_TASK_RETRY_FOREVER) { - transvr_task_set_retry(task_p, fail_retry); - } - if ((task_p->retry) == 0) { - /* Error case: - * => In this case, SWPS will stop external Link state monitor features - * and keeps transvr_p->info on TRANSVR_CLASS_BASE_T_1000_up. - * Upper layer will see it always Linkup that because of these type of - * transceiver has external phy, BCM chip see it as Loopback transceiver. - */ - SWPS_WARN("%s can not access external PHY of Base-T SFP transceiver\n", - task_p->transvr_p->swp_name); - task_p->transvr_p->info = TRANSVR_CLASS_BASE_T_1000_up; - return EVENT_TRANSVR_TASK_DONE; - } else { - transvr_task_set_delay(task_p, fail_delay); - } - return EVENT_TRANSVR_TASK_FAIL; -} - - -int -_taskfunc_qsfp_setup_power_mod(struct transvr_obj_s *self, - int setup_val) { - - int curr_val = DEBUG_TRANSVR_INT_VAL; - int err_val = DEBUG_TRANSVR_INT_VAL; - char *err_msg = DEBUG_TRANSVR_STR_VAL; - - curr_val = self->ioexp_obj_p->get_lpmod(self->ioexp_obj_p, - self->ioexp_virt_offset); - if (curr_val < 0){ - err_msg = "Get current value fail!"; - goto err_private_taskfunc_qsfp_setup_power_mod_1; - } - if (curr_val == setup_val){ - return EVENT_TRANSVR_TASK_DONE; - } - err_val = self->ioexp_obj_p->set_lpmod(self->ioexp_obj_p, - self->ioexp_virt_offset, - setup_val); - if (err_val < 0){ - err_msg = "Setup power mode fail!"; - goto err_private_taskfunc_qsfp_setup_power_mod_1; - } - return EVENT_TRANSVR_TASK_DONE; - -err_private_taskfunc_qsfp_setup_power_mod_1: - SWPS_INFO("%s: %s :%d :%d :%d\n", - __func__, err_msg, err_val, curr_val, setup_val); - return EVENT_TRANSVR_TASK_FAIL; -} - - -int -taskfunc_qsfp_handle_tx_disable(struct transvr_worker_s *task_p) { - - int i = 0; - int retry = 5; - int delay_ms = 100; - - if (task_p->transvr_p->auto_tx_disable == VAL_TRANSVR_FUNCTION_DISABLE) { - return EVENT_TRANSVR_TASK_DONE; - } - if (!_qsfp_is_implement_tx_disable(task_p->transvr_p)) { - return EVENT_TRANSVR_TASK_DONE; - } - for (i=0; itransvr_p, - task_p->transvr_p->auto_tx_disable) - == EVENT_TRANSVR_TASK_DONE) { - goto ok_taskfunc_qsfp_handle_tx_disable; - } - mdelay(delay_ms); - } - SWPS_INFO("%s auto setup tx_disable:0x%02x fail.\n", - task_p->transvr_p->swp_name, - task_p->transvr_p->auto_tx_disable); - return EVENT_TRANSVR_INIT_FAIL; - -ok_taskfunc_qsfp_handle_tx_disable: - SWPS_INFO("%s auto setup tx_disable:0x%02x ok.\n", - task_p->transvr_p->swp_name, - task_p->transvr_p->auto_tx_disable); - return EVENT_TRANSVR_TASK_DONE; -} - - -int -taskfunc_qsfp_set_hpmod(struct transvr_worker_s *task_p) { - - int err = DEBUG_TRANSVR_INT_VAL; - int HIGH_POWER_MODE = 0; - - /* Handle power mode */ - err = _taskfunc_qsfp_setup_power_mod(task_p->transvr_p, - HIGH_POWER_MODE); - if (err < 0) { - SWPS_INFO("%s: setup hpmod fail :%d :%s\n", - __func__, err, task_p->transvr_p->swp_name); - return err; - } - /* Handle auto tx_disable - * [Note] - * => Because there are some transceiver have timing issues or - * setup sequence issues, therefore we handle auto tx_disable - * after handle power mode. - */ - mdelay(100); - return taskfunc_qsfp_handle_tx_disable(task_p); -} - - -int -taskfunc_qsfp_set_lpmod(struct transvr_worker_s *task_p) { - - int LOW_POWER_MODE = 1; - return _taskfunc_qsfp_setup_power_mod(task_p->transvr_p, - LOW_POWER_MODE); -} - - -static int -initfunc_sfp_handle_multi_rate_mode(struct transvr_obj_s *self) { - - int task_retry = 3; - int err_code = DEBUG_TRANSVR_INT_VAL; - char *err_str = DEBUG_TRANSVR_STR_VAL; - char *func_str = "sfp_handle_multi_rate_mode"; - struct transvr_worker_s *task_p = NULL; - - switch (self->rate_id) { - case 0x00: /* Unspecified */ - case 0x03: /* Unspecified */ - case 0x05: /* Unspecified */ - case 0x07: /* Unspecified */ - case 0x09: /* Unspecified */ - case 0x0B: /* Unspecified */ - case 0x0D: /* Unspecified */ - case 0x0F: /* Unspecified */ - goto sfp_handle_multi_rate_mode_4_unspecified; - - case 0x02: /* SFF-8431 (8/4/2G Rx Rate_Select only) */ - task_p = transvr_task_creat(self, - taskfunc_sfp_setup_SFF8431_case1, - taskfunc_post_handle_task_state, - func_str); - goto sfp_handle_multi_rate_mode_4_sff8431; - - case 0x04: /* SFF-8431 (8/4/2G Tx Rate_Select only) */ - task_p = transvr_task_creat(self, - taskfunc_sfp_setup_SFF8431_case2, - taskfunc_post_handle_task_state, - func_str); - goto sfp_handle_multi_rate_mode_4_sff8431; - - case 0x06: /* SFF-8431 (8/4/2G Independent Rx & Tx Rate_select) */ - task_p = transvr_task_creat(self, - taskfunc_sfp_setup_SFF8431_case3, - taskfunc_post_handle_task_state, - func_str); - goto sfp_handle_multi_rate_mode_4_sff8431; - - case 0x01: /* SFF-8079 (4/2/1G Rate_Select & AS0/AS1) */ - err_str = "SFF-8079 (4/2/1G Rate_Select & AS0/AS1)"; - goto sfp_handle_multi_rate_mode_4_not_support; - - case 0x08: /* FC-PI-5 (16/8/4G Rx Rate_select only) - * High=16G only, Low=8G/4G - */ - err_str = "FC-PI-5 (16/8/4G Rx Rate_select only)"; - goto sfp_handle_multi_rate_mode_4_not_support; - - case 0x0A: /* FC-PI-5 (16/8/4G Independent Rx, Tx Rate_select) - * High=16G only, Low=8G/4G - */ - err_str = "FC-PI-5 (16/8/4G Independent Rx, Tx Rate_select)"; - goto sfp_handle_multi_rate_mode_4_not_support; - - case 0x0C: /* FC-PI-6 (32/16/8G Independent Rx, Tx Rate_Select) - * High=32G only, Low = 16G/8G - */ - err_str = "FC-PI-6 (32/16/8G Independent Rx, Tx Rate_Select)"; - goto sfp_handle_multi_rate_mode_4_not_support; - - case 0x0E: /* 10/8G Rx and Tx Rate_Select controlling the operation or - * locking modes of the internal signal conditioner, retimer - * or CDR, according to the logic table defined in Table 10-2, - * High Bit Rate (10G) =9.95-11.3 Gb/s; Low Bit Rate (8G) = - * 8.5 Gb/s. In this mode, the default value of bit 110.3 (Soft - * Rate Select RS(0), Table 9-11) and of bit 118.3 (Soft Rate - * Select RS(1), Table 10-1) is 1. - */ - err_str = "cable type: 0x0E"; - goto sfp_handle_multi_rate_mode_4_not_support; - - default: - err_str = "cable type: UNKNOW"; - goto sfp_handle_multi_rate_mode_4_not_support; - } - -sfp_handle_multi_rate_mode_4_sff8431: - if (!task_p) { - err_str = "Create task fail!"; - goto sfp_handle_multi_rate_mode_4_fail_1; - } - transvr_task_set_retry(task_p, task_retry); - return EVENT_TRANSVR_TASK_WAIT; - -sfp_handle_multi_rate_mode_4_unspecified: - return EVENT_TRANSVR_TASK_DONE; - -sfp_handle_multi_rate_mode_4_not_support: - SWPS_INFO("%s: Does not support %s :%s :0x%02x\n", - func_str, err_str, self->swp_name, self->rate_id); - return EVENT_TRANSVR_TASK_DONE; - -sfp_handle_multi_rate_mode_4_fail_1: - SWPS_INFO("%s: %s :%s :0x%02x, :%d\n", - func_str, err_str, self->swp_name, self->rate_id, err_code); - return EVENT_TRANSVR_INIT_FAIL; -} - - -static int -initfunc_sfp_handle_1g_rj45(struct transvr_obj_s *self) { - - struct transvr_worker_s *task_p = NULL; - int detect_cls = DEBUG_TRANSVR_INT_VAL; - char err_str[64] = DEBUG_TRANSVR_STR_VAL; - char *func_str = "initfunc_sfp_handle_1g_rj45"; - - - if (self->info == TRANSVR_CLASS_BASE_T_1000) { - task_p = transvr_task_creat(self, - taskfunc_sfp_handle_1g_rj45, - taskfunc_post_do_nothing, - func_str); - if (!task_p) { - snprintf(err_str, sizeof(err_str), "Create task fail"); - goto err_initfunc_sfp_handle_1g_rj45; - } - transvr_task_set_retry(task_p, VAL_TRANSVR_TASK_RETRY_FOREVER); - } - return EVENT_TRANSVR_TASK_DONE; - -err_initfunc_sfp_handle_1g_rj45: - SWPS_INFO("%s: %s :%s :%d\n", - __func__, err_str, self->swp_name, detect_cls); - return EVENT_TRANSVR_TASK_FAIL; -} - - -static int -initfunc_qsfp_handle_power_mode(struct transvr_obj_s *self) { - - int err_code = EVENT_TRANSVR_EXCEP_INIT; - int power_class = DEBUG_TRANSVR_INT_VAL; - int hpmod_retry = 3; - int lpower_config = 1; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - unsigned long hpmod_delay = 500; /* msec */ - struct transvr_worker_s *task_p = NULL; - - /* Handle power mode for IOEXP */ - power_class = __qsfp_get_power_cls(self, 0); - switch (power_class) { - case 1: /* Case: Low power mode (Class = 1) */ - err_code = _taskfunc_qsfp_setup_power_mod(self, lpower_config); - if (err_code < 0){ - snprintf(err_msg, sizeof(err_msg), "Setup lpmod fail :%d", err_code); - goto err_initfunc_qsfp_handle_power_mode; - } - return EVENT_TRANSVR_TASK_DONE; - - case 2: /* Case: High power mode (Class > 1) */ - case 3: - case 4: - case 5: - case 6: - case 7: - task_p = transvr_task_creat(self, - taskfunc_qsfp_set_hpmod, - taskfunc_post_handle_task_state, - "transvr_init_qsfp"); - if (!task_p) { - snprintf(err_msg, sizeof(err_msg), "Setup lpmod fail :%d", err_code); - goto err_initfunc_qsfp_handle_power_mode; - } - transvr_task_set_retry(task_p, hpmod_retry); - transvr_task_set_delay(task_p, hpmod_delay); - return EVENT_TRANSVR_TASK_WAIT; - - default: - break; - } - snprintf(err_msg, sizeof(err_msg), "Exception case"); - goto err_initfunc_qsfp_handle_power_mode; - -err_initfunc_qsfp_handle_power_mode: - SWPS_INFO("%s: %s :%s \n", __func__, err_msg, self->swp_name); - return EVENT_TRANSVR_INIT_FAIL; -} - - -int -initfunc_qsfp28_handle_cdr(struct transvr_obj_s *self) { - - uint8_t DEFAULT_VAL_CDR = 0xff; - int CDR_FUNC_EXISTED = 0x3; - int show_err = 1; - int err_val = EVENT_TRANSVR_TASK_FAIL; - char *err_msg = DEBUG_TRANSVR_STR_VAL; - char *func_str = "initfunc_qsfp28_handle_cdr"; - - err_val = __qsfp_get_cdr_present(self, 0); - if ( (err_val < 0) || - (err_val == DEBUG_TRANSVR_HEX_VAL) ) { - err_msg = "detect cdr_present fail!"; - goto err_taskfunc_qsfp_handle_cdr_1; - } - if (err_val == CDR_FUNC_EXISTED) { - err_val = _common_set_uint8_attr(self, - self->eeprom_map_p->addr_cdr, - self->eeprom_map_p->addr_cdr, - self->eeprom_map_p->offset_cdr, - DEFAULT_VAL_CDR, - &(self->cdr), - func_str, - show_err); - if (err_val < 0) { - err_msg = "set CDR fail!"; - goto err_taskfunc_qsfp_handle_cdr_1; - } - } - return EVENT_TRANSVR_TASK_DONE; - -err_taskfunc_qsfp_handle_cdr_1: - SWPS_INFO("%s: %s :%d :%s\n", - func_str, err_msg, err_val, self->swp_name); - return EVENT_TRANSVR_INIT_FAIL; -} - -/* ========== Object functions for Final State Machine ========== - */ -int -is_plugged(struct transvr_obj_s *self){ - - int limit = 63; - int present = DEBUG_TRANSVR_INT_VAL; - char emsg[64] = DEBUG_TRANSVR_STR_VAL; - struct ioexp_obj_s *ioexp_p = self->ioexp_obj_p; - - if (!ioexp_p) { - snprintf(emsg, limit, "ioexp_p is null!"); - goto err_is_plugged_1; - } - present = ioexp_p->get_present(ioexp_p, self->ioexp_virt_offset); - switch (present){ - case 0: - return 1; - case 1: - return 0; - case ERR_IOEXP_UNINIT: - snprintf(emsg, limit, "ioexp_p not ready!"); - goto err_is_plugged_1; - default: - if (ioexp_p->state == STATE_IOEXP_INIT){ - snprintf(emsg, limit, "ioexp_p not ready!"); - goto err_is_plugged_1; - } - break; - } - SWPS_INFO("%s: Exception case! :%d :%d\n", - __func__, present, ioexp_p->state); - return 0; - -err_is_plugged_1: - SWPS_DEBUG("%s: %s\n", __func__, emsg); - return 0; -} - - -static int -detect_transvr_type(struct transvr_obj_s* self){ - - int type = TRANSVR_TYPE_ERROR; - - self->i2c_client_p->addr = VAL_TRANSVR_COMID_ARREESS; - type = i2c_smbus_read_byte_data(self->i2c_client_p, - VAL_TRANSVR_COMID_OFFSET); - - /* Case: 1. Wait transceiver I2C module. - * 2. Transceiver I2C module failure. - * Note: 1. SFF allow maximum transceiver initial time is 2 second. So, there - * are exist some case that we need to wait transceiver. - * For these case, we keeps status on "TRANSVR_TYPE_UNPLUGGED", than - * state machine will keep trace with it. - * 2. There exist some I2C failure case we need to handle. Such as user - * insert the failure transceiver, or any reason cause it abnormal. - */ - if (type < 0){ - switch (type) { - case -EIO: - SWPS_DEBUG("%s: %s smbus return:-5 (I/O error)\n", - __func__, self->swp_name); - return TRANSVR_TYPE_UNPLUGGED; - case -ENXIO: - SWPS_DEBUG("%s: %s smbus return:-6 (No such device or address)\n", - __func__, self->swp_name); - return TRANSVR_TYPE_UNPLUGGED; - default: - break; - } - SWPS_INFO("%s: %s unexpected smbus return:%d \n", - __func__, self->swp_name, type); - return TRANSVR_TYPE_ERROR; - } - /* Identify valid transceiver type */ - switch (type){ - case TRANSVR_TYPE_SFP: - case TRANSVR_TYPE_QSFP: - case TRANSVR_TYPE_QSFP_PLUS: - case TRANSVR_TYPE_QSFP_28: - break; - case TRANSVR_TYPE_UNKNOW_1: - case TRANSVR_TYPE_UNKNOW_2: - type = TRANSVR_TYPE_UNKNOW_2; - break; - default: - SWPS_DEBUG("%s: unknow type:0x%02x \n", __func__, type); - type = TRANSVR_TYPE_ERROR; - break; - } - return type; -} - - -static int -detect_transvr_state(struct transvr_obj_s *self, - int result[2]){ - /* [return] [result-0] [result-1] - * 0 STATE_TRANSVR_CONNECTED TRANSVR_TYPE_FAKE - * 0 STATE_TRANSVR_DISCONNECTED TRANSVR_TYPE_UNPLUGGED - * 0 STATE_TRANSVR_ISOLATED TRANSVR_TYPE_ERROR - * 0 STATE_TRANSVR_INIT / - * 0 STATE_TRANSVR_SWAPPED - * 0 STATE_TRANSVR_CONNECTED - * ERR_TRNASVR_BE_ISOLATED STATE_TRANSVR_ISOLATED TRANSVR_TYPE_ERROR - * ERR_TRANSVR_I2C_CRASH STATE_TRANSVR_UNEXCEPTED TRANSVR_TYPE_ERROR - * ERR_TRANSVR_UNEXCPT STATE_TRANSVR_UNEXCEPTED TRANSVR_TYPE_UNKNOW_1/2 - */ - result[0] = STATE_TRANSVR_UNEXCEPTED; /* For return state */ - result[1] = TRANSVR_TYPE_ERROR; /* For return type */ - - /* Case1: Fake type */ - if (self->type == TRANSVR_TYPE_FAKE){ - result[0] = STATE_TRANSVR_CONNECTED; - result[1] = TRANSVR_TYPE_FAKE; - return 0; - } - /* Case2: Transceiver unplugged */ - if (!is_plugged(self)){ - result[0] = STATE_TRANSVR_DISCONNECTED; - result[1] = TRANSVR_TYPE_UNPLUGGED; - return 0; - } - /* Case3: Transceiver be isolated */ - if (self->state == STATE_TRANSVR_ISOLATED){ - result[0] = STATE_TRANSVR_ISOLATED; - result[1] = TRANSVR_TYPE_ERROR; - return ERR_TRNASVR_BE_ISOLATED; - } - /* Case4: Transceiver plugged */ - result[1] = detect_transvr_type(self); - /* Case4.1: I2C topology crash - * Note : There are some I2C issues cause by transceiver/cables. - * We need to check topology status when user insert it. - * But in this step, we can't not ensure this is the issues - * port. So, it return the ERR_TRANSVR_I2C_CRASH, then upper - * layer will diagnostic I2C topology. - */ - if (check_channel_tier_1() < 0) { - SWPS_INFO("%s: %s detect I2C crash :%d\n", - __func__, self->swp_name, self->state); - result[0] = STATE_TRANSVR_UNEXCEPTED; - result[1] = TRANSVR_TYPE_ERROR; - return ERR_TRANSVR_I2C_CRASH; - } - /* Case4.2: System initial not ready, - * Note : Sometime i2c channel or transceiver EEPROM will delay that will - * cause system in inconsistent state between EEPROM and IOEXP. - * In this case, SWP transceiver object keep state at LINK_DOWN - * to wait system ready. - * By the way, State Machine will handle these case. - */ - if (result[1] == TRANSVR_TYPE_UNPLUGGED){ - result[0] = STATE_TRANSVR_DISCONNECTED; - return 0; - } - /* Case4.3: Error transceiver type */ - if (result[1] == TRANSVR_TYPE_ERROR){ - result[0] = STATE_TRANSVR_ISOLATED; - SWPS_INFO("%s: %s detect error type\n", __func__, self->swp_name); - alarm_msg_2_user(self, "detected transceiver/cables not meet SFF standard!"); - return ERR_TRNASVR_BE_ISOLATED; - } - /* Case3.3: Unknow transceiver type */ - if ((result[1] == TRANSVR_TYPE_UNKNOW_1) || - (result[1] == TRANSVR_TYPE_UNKNOW_2) ){ - result[0] = STATE_TRANSVR_UNEXCEPTED; - return ERR_TRANSVR_UNEXCPT; - } - /* Case3.4: During initial process */ - if (self->state == STATE_TRANSVR_INIT){ - result[0] = STATE_TRANSVR_INIT; - return 0; - } - /* Case3.5: Transceiver be swapped */ - if (self->type != result[1]){ - result[0] = STATE_TRANSVR_SWAPPED; - return 0; - } - /* Case3.6: Link up state */ - result[0] = STATE_TRANSVR_CONNECTED; - return 0; -} - - -int -_sfp_detect_class_by_extend_comp(struct transvr_obj_s* self) { - /* Reference: SFF-8024 (v3.8) - */ - int detect_val = _sfp_get_comp_extended(self); - - switch(detect_val) { - case 0x00: /* Unspecified */ - return TRANSVR_CLASS_UNSPECIFIED; - - case 0x01: /* 100G AOC (Active Optical Cable) or 25GAUI C2M */ - case 0x18: /* 100G AOC or 25GAUI C2M AOC. */ - return TRANSVR_CLASS_OPTICAL_25G_AOC; - - case 0x02: /* 100GBASE-SR4 or 25GBASE-SR */ - return TRANSVR_CLASS_OPTICAL_25G_SR; - - case 0x03: /* 100GBASE-LR4 or 25GBASE-LR */ - return TRANSVR_CLASS_OPTICAL_25G_LR; - - case 0x04: /* 100GBASE-ER4 or 25GBASE-ER */ - return TRANSVR_CLASS_OPTICAL_25G_ER; - - case 0x08: /* 100G ACC (Active Copper Cable) or 25GAUI C2M ACC. */ - case 0x0b: /* 100GBASE-CR4 or 25GBASE-CR CA-L */ - case 0x0c: /* 25GBASE-CR CA-S */ - case 0x0d: /* 25GBASE-CR CA-N */ - case 0x19: /* 100G ACC or 25GAUI C2M ACC. */ - return TRANSVR_CLASS_COPPER_L1_25G; - - default: - break; - } - SWPS_INFO("%s: Unexcept value:0x%02x\n :%s", - __func__, detect_val, self->swp_name); - return TRANSVR_CLASS_ERROR; -} - - -int -_sfp_detect_class_by_10_ethernet(struct transvr_obj_s* self) { - /* Reference: SFF-8472 (v12.2) - */ - int detect_val = DEBUG_TRANSVR_INT_VAL; - - detect_val = _sfp_get_comp_10g_eth_comp(self); - /* Case: Unspecified */ - if (detect_val == 0x00) { - return TRANSVR_CLASS_UNSPECIFIED; - } - /* Case: 10G Optical (x1) */ - if ((detect_val & 0x10) == 0x10) { /* 00010000 : 10GBASE-SR */ - return TRANSVR_CLASS_OPTICAL_10G_S_SR; - } - if ( ((detect_val & 0x20) == 0x20) || /* 00100000 : 10GBASE-LR */ - ((detect_val & 0x40) == 0x40) ){ /* 01000000 : 10GBASE-LRM */ - return TRANSVR_CLASS_OPTICAL_10G_S_LR; - } - if ((detect_val & 0x80) == 0x80) { /* 10000000 : 10GBASE-ER */ - return TRANSVR_CLASS_OPTICAL_10G_S_ER; - } - /* Case: ERROR */ - SWPS_INFO("%s: Unexcept value:0x%02x\n :%s", - __func__, detect_val, self->swp_name); - return TRANSVR_CLASS_ERROR; -} - - -int -_sfp_detect_if_sp_by_br(struct transvr_obj_s* self) { - - int lower_bound_1g = 0x0b; - int upper_bound_1g = 0x1A; - int lower_bound_10g = 0x60; - int upper_bound_10g = 0x75; - int lower_bound_25g = 0xf0; - int upper_bound_25g = 0xff; - int notmal_br = DEBUG_TRANSVR_INT_VAL; - - notmal_br = (int)(self->br); /* updated by update_all() */ - /* Check 25G */ - if ((notmal_br >= lower_bound_25g) && - (notmal_br <= upper_bound_25g) ) { - return TRANSVR_CLASS_25G; - } - /* Check 10G */ - if ((notmal_br >= lower_bound_10g) && - (notmal_br <= upper_bound_10g) ) { - return TRANSVR_CLASS_10G; - } - /* Check 1G */ - if ((notmal_br >= lower_bound_1g) && - (notmal_br <= upper_bound_1g) ) { - return TRANSVR_CLASS_1G; - } - return TRANSVR_CLASS_UNSPECIFIED; -} - - -int -_sfp_detect_class_by_1g_ethernet(struct transvr_obj_s* self) { - /* Reference: SFF-8472 (v12.2) - */ - int detect_val = DEBUG_TRANSVR_INT_VAL; - int speed_br = DEBUG_TRANSVR_INT_VAL; - int speed_tmp = DEBUG_TRANSVR_INT_VAL; - char err_str[64] = DEBUG_TRANSVR_STR_VAL; - - speed_br = _sfp_detect_if_sp_by_br(self); - detect_val = _sfp_get_comp_1g_eth_comp(self); - - if (detect_val < 0) { - snprintf(err_str, sizeof(err_str), "Detect abnormal value:%d", detect_val); - goto err_p_sfp_detect_class_by_1g_ethernet; - } - /* Case: Unspecified */ - if (detect_val == 0x00) { - return TRANSVR_CLASS_UNSPECIFIED; - } - /* Case: 1G (x1) */ - if ((detect_val & 0x01) == 0x01) { /* 00000001 : 1000BASE-SX */ - speed_tmp = TRANSVR_CLASS_OPTICAL_1G_SX; - goto ok_sfp_detect_class_by_1g_ethernet_4_check_br_10g; - } - if ((detect_val & 0x02) == 0x02) { /* 00000010 : 1000BASE-LX *3 */ - speed_tmp = TRANSVR_CLASS_OPTICAL_1G_LX; - goto ok_sfp_detect_class_by_1g_ethernet_4_check_br_10g; - } - if ((detect_val & 0x04) == 0x04) { /* 00000100 : 1000BASE-CX */ - speed_tmp = TRANSVR_CLASS_COPPER_L1_1G; - goto ok_sfp_detect_class_by_1g_ethernet_4_check_br_10g; - } - /* Case: 1000 Base-T (x1) */ - if ((detect_val & 0x08) == 0x08) { /* 00001000 : 1000BASE-T */ - return TRANSVR_CLASS_BASE_T_1000; - } - /* Case: 100 Base */ - if ( ((detect_val & 0x10) == 0x10) || /* 00010000 : 100BASE-LX/LX10 */ - ((detect_val & 0x20) == 0x20) || /* 00100000 : 100BASE-FX */ - ((detect_val & 0x40) == 0x40) || /* 01000000 : BASE-BX10 *3 */ - ((detect_val & 0x80) == 0x80) ){ /* 10000000 : BASE-PX *3 */ - return TRANSVR_CLASS_OPTICAL_100; - } - /* Case: ERROR */ - snprintf(err_str, sizeof(err_str), "Case:ERROR, value:%d", detect_val); - goto err_p_sfp_detect_class_by_1g_ethernet; - -ok_sfp_detect_class_by_1g_ethernet_4_check_br_10g: - switch (speed_br) { - case TRANSVR_CLASS_UNSPECIFIED: - case TRANSVR_CLASS_1G: - return speed_tmp; - case TRANSVR_CLASS_10G: - goto ok_sfp_detect_class_by_1g_ethernet_4_transfer_10G; - } - -ok_sfp_detect_class_by_1g_ethernet_4_transfer_10G: - switch (speed_tmp) { - case TRANSVR_CLASS_OPTICAL_1G_SX: - return TRANSVR_CLASS_OPTICAL_10G_S_SR; - case TRANSVR_CLASS_OPTICAL_1G_LX: - return TRANSVR_CLASS_OPTICAL_10G_S_LR; - case TRANSVR_CLASS_COPPER_L1_1G: - return TRANSVR_CLASS_COPPER_L1_10G; - default: - break; - } - snprintf(err_str, sizeof(err_str), "transfer_1to10 fail, speed:%d", speed_tmp); - goto err_p_sfp_detect_class_by_1g_ethernet; - -err_p_sfp_detect_class_by_1g_ethernet: - SWPS_INFO("%s: %s :%s", __func__, err_str, self->swp_name); - return TRANSVR_CLASS_ERROR; -} - - -int -_sfp_detect_class_by_feature(struct transvr_obj_s* self) { - /* Reference: SFF-8024 (v3.8) - */ - int is_active = 0; - int conn_val = DEBUG_TRANSVR_INT_VAL; - int check_val = DEBUG_TRANSVR_INT_VAL; - int wave_len = DEBUG_TRANSVR_INT_VAL; - int speed_val = DEBUG_TRANSVR_INT_VAL; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - - speed_val = _sfp_detect_if_sp_by_br(self); - conn_val = _sfp_get_connector_type(self); - - switch(conn_val) { - case 0x00: /* Unspecified */ - goto ok_sfp_detect_class_by_feature_4_check_active_passive; - case 0x07: /* LC (Lucent Connector) */ - case 0x0b: /* Optical Pigtail */ - case 0x0c: /* MPO 1x12 */ - case 0x0d: /* MPO 2x16 */ - /* - * ToDo: Need verify Optical Pigtail - */ - goto ok_sfp_detect_class_by_feature_4_optiocal; - case 0x21: /* Copper pigtail */ - /* - * ToDo: Need check ACC use case - */ - goto ok_sfp_detect_class_by_feature_4_check_active_passive; - case 0x23: /* No separable connector */ - /* - * ToDo: Standard not clear, not all transceiver vendor - * have the same defined - */ - goto ok_sfp_detect_class_by_feature_4_check_active_passive; - default: - break; - } - goto ok_sfp_detect_class_by_feature_4_unknow; - -ok_sfp_detect_class_by_feature_4_check_active_passive: - check_val = _sfp_get_cable_tech(self); - switch(check_val) { - case 0x00: /* Unspecified */ - goto ok_sfp_detect_class_by_feature_4_unknow; - case 0x04: /* Passive */ - goto ok_sfp_detect_class_by_feature_4_copper; - case 0x08: /* Active */ - is_active = 1; - goto ok_sfp_detect_class_by_feature_4_aoc; - default: - snprintf(err_msg, sizeof(err_msg), - "_sfp_get_cable_tech return Non define value:%d", - check_val); - break; - } - goto err_sfp_detect_class_by_feature_1; - -ok_sfp_detect_class_by_feature_4_optiocal: - wave_len = _common_count_wavelength(self, - self->wavelength[0], - self->wavelength[1]); - switch(speed_val) { - case TRANSVR_CLASS_25G: - switch (wave_len) { - case VAL_OPTICAL_WAVELENGTH_SR: - return TRANSVR_CLASS_OPTICAL_25G_SR; - case VAL_OPTICAL_WAVELENGTH_LR: - return TRANSVR_CLASS_OPTICAL_25G_LR; - case VAL_OPTICAL_WAVELENGTH_ER: - return TRANSVR_CLASS_OPTICAL_25G_ER; - default: - break; - } - return TRANSVR_CLASS_OPTICAL_25G; - - case TRANSVR_CLASS_10G: - switch (wave_len) { - case VAL_OPTICAL_WAVELENGTH_SR: - return TRANSVR_CLASS_OPTICAL_10G_S_SR; - case VAL_OPTICAL_WAVELENGTH_LR: - return TRANSVR_CLASS_OPTICAL_10G_S_LR; - case VAL_OPTICAL_WAVELENGTH_ER: - return TRANSVR_CLASS_OPTICAL_10G_S_ER; - default: - break; - } - return TRANSVR_CLASS_OPTICAL_10G; - - case TRANSVR_CLASS_1G: - switch (wave_len) { - case VAL_OPTICAL_WAVELENGTH_SR: - return TRANSVR_CLASS_OPTICAL_1G_SX; - case VAL_OPTICAL_WAVELENGTH_LR: - return TRANSVR_CLASS_OPTICAL_1G_LX; - case VAL_OPTICAL_WAVELENGTH_ER: - return TRANSVR_CLASS_OPTICAL_1G_EX; - default: - break; - } - return TRANSVR_CLASS_OPTICAL_1G; - - default: - return TRANSVR_CLASS_OPTICAL; - } - -ok_sfp_detect_class_by_feature_4_aoc: - switch(speed_val) { - case TRANSVR_CLASS_25G: - return TRANSVR_CLASS_OPTICAL_25G_AOC; - case TRANSVR_CLASS_10G: - return TRANSVR_CLASS_OPTICAL_10G_S_AOC; - case TRANSVR_CLASS_1G: - return TRANSVR_CLASS_OPTICAL_1G_AOC; - default: - break; - } - goto ok_sfp_detect_class_by_feature_4_unknow; - -ok_sfp_detect_class_by_feature_4_copper: - switch(speed_val) { - case TRANSVR_CLASS_25G: - return TRANSVR_CLASS_COPPER_L1_25G; - case TRANSVR_CLASS_10G: - return TRANSVR_CLASS_COPPER_L1_10G; - case TRANSVR_CLASS_1G: - return TRANSVR_CLASS_COPPER_L1_1G; - default: - return TRANSVR_CLASS_COPPER; - } - -ok_sfp_detect_class_by_feature_4_unknow: - return TRANSVR_CLASS_UNSPECIFIED; - -err_sfp_detect_class_by_feature_1: - SWPS_INFO("%s: %s\n :%s", __func__, err_msg, self->swp_name); - return TRANSVR_CLASS_ERROR; -} - - -int -sft_detect_transvr_class(struct transvr_obj_s* self) { - - int detect_val = DEBUG_TRANSVR_INT_VAL; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - - /* Check Extended Compliance */ - detect_val = _sfp_detect_class_by_extend_comp(self); - switch(detect_val) { - case TRANSVR_CLASS_UNSPECIFIED: - break; - case TRANSVR_CLASS_OPTICAL_25G_AOC: - case TRANSVR_CLASS_OPTICAL_25G_SR: - case TRANSVR_CLASS_OPTICAL_25G_LR: - case TRANSVR_CLASS_OPTICAL_25G_ER: - case TRANSVR_CLASS_COPPER_L1_25G: - return detect_val; - default: - snprintf(err_msg, sizeof(err_msg), - "Detect undefined extend_comp:%d", - detect_val); - goto err_sft_detect_transceiver_class_1; - } - /* Check 10G Compliance */ - detect_val = _sfp_detect_class_by_10_ethernet(self); - switch(detect_val) { - case TRANSVR_CLASS_UNSPECIFIED: - break; - case TRANSVR_CLASS_OPTICAL_10G_S_SR: - case TRANSVR_CLASS_OPTICAL_10G_S_LR: - case TRANSVR_CLASS_OPTICAL_10G_S_ER: - return detect_val; - default: - snprintf(err_msg, sizeof(err_msg), - "Detect undefined 10G_eth:%d", - detect_val); - goto err_sft_detect_transceiver_class_1; - } - /* Check 1G Compliance */ - detect_val = _sfp_detect_class_by_1g_ethernet(self); - switch(detect_val) { - case TRANSVR_CLASS_UNSPECIFIED: - break; - case TRANSVR_CLASS_OPTICAL_1G_SX: - case TRANSVR_CLASS_OPTICAL_1G_LX: - case TRANSVR_CLASS_COPPER_L1_1G: - case TRANSVR_CLASS_BASE_T_1000: - case TRANSVR_CLASS_OPTICAL_100: - /* - * ToDo: Need Check 0.1G - */ - case TRANSVR_CLASS_OPTICAL_10G_S_SR: - case TRANSVR_CLASS_OPTICAL_10G_S_LR: - case TRANSVR_CLASS_COPPER_L1_10G: - /* Transfer speed case - * => Example: Raycom 10G DAC - */ - return detect_val; - default: - snprintf(err_msg, sizeof(err_msg), - "Detect undefined 1G_eth:%d", - detect_val); - goto err_sft_detect_transceiver_class_1; - } - /* Check by connector, br, wavelength */ - detect_val = _sfp_detect_class_by_feature(self); - switch(detect_val) { - case TRANSVR_CLASS_UNSPECIFIED: - break; - case TRANSVR_CLASS_OPTICAL: - case TRANSVR_CLASS_OPTICAL_1G: - case TRANSVR_CLASS_OPTICAL_1G_SX: - case TRANSVR_CLASS_OPTICAL_1G_LX: - case TRANSVR_CLASS_OPTICAL_1G_EX: - case TRANSVR_CLASS_OPTICAL_1G_AOC: - case TRANSVR_CLASS_OPTICAL_10G: - case TRANSVR_CLASS_OPTICAL_10G_S_SR: - case TRANSVR_CLASS_OPTICAL_10G_S_LR: - case TRANSVR_CLASS_OPTICAL_10G_S_ER: - case TRANSVR_CLASS_OPTICAL_10G_S_AOC: - case TRANSVR_CLASS_OPTICAL_25G: - case TRANSVR_CLASS_OPTICAL_25G_SR: - case TRANSVR_CLASS_OPTICAL_25G_LR: - case TRANSVR_CLASS_OPTICAL_25G_ER: - case TRANSVR_CLASS_OPTICAL_25G_AOC: - case TRANSVR_CLASS_COPPER: - case TRANSVR_CLASS_COPPER_L1_1G: - case TRANSVR_CLASS_COPPER_L1_10G: - case TRANSVR_CLASS_COPPER_L1_25G: - return detect_val; - default: - snprintf(err_msg, sizeof(err_msg), - "Detect undefined get_connector:%d", - detect_val); - goto err_sft_detect_transceiver_class_1; - } - /* Exception case: Can't verify */ - snprintf(err_msg, sizeof(err_msg), "Can not identify!"); - goto err_sft_detect_transceiver_class_1; - -err_sft_detect_transceiver_class_1: - SWPS_INFO("%s: %s :%s\n", __func__, err_msg, self->swp_name); - return TRANSVR_CLASS_ERROR; -} - - -int -_sfp_set_trident2_if_type(struct transvr_obj_s* self, - int transvr_cls, - char *result){ - - int lmax = 8; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - - switch(transvr_cls) { - case TRANSVR_CLASS_ERROR: - case TRANSVR_CLASS_UNSPECIFIED: - break; - /* 25G OPTICAL */ - case TRANSVR_CLASS_OPTICAL_25G_AOC: - case TRANSVR_CLASS_OPTICAL_25G_SR: - case TRANSVR_CLASS_OPTICAL_25G_LR: - case TRANSVR_CLASS_OPTICAL_25G_ER: - case TRANSVR_CLASS_OPTICAL_25G: - return snprintf(result, lmax, TRANSVR_IF_SFI); - /* 25G COPPER */ - case TRANSVR_CLASS_COPPER_L1_25G: - return snprintf(result, lmax, TRANSVR_IF_SFI); - /* 10G OPTICAL */ - case TRANSVR_CLASS_OPTICAL_10G_S_AOC: - case TRANSVR_CLASS_OPTICAL_10G_S_SR: - case TRANSVR_CLASS_OPTICAL_10G_S_LR: - case TRANSVR_CLASS_OPTICAL_10G_S_ER: - case TRANSVR_CLASS_OPTICAL_10G: - return snprintf(result, lmax, TRANSVR_IF_SFI); - /* 10G COPPER */ - case TRANSVR_CLASS_COPPER_L1_10G: - return snprintf(result, lmax, TRANSVR_IF_SFI); - /* 1G OPTICAL */ - case TRANSVR_CLASS_OPTICAL_1G_AOC: - case TRANSVR_CLASS_OPTICAL_1G_SX: - case TRANSVR_CLASS_OPTICAL_1G_LX: - case TRANSVR_CLASS_OPTICAL_1G_EX: - case TRANSVR_CLASS_OPTICAL_1G: - return snprintf(result, lmax, TRANSVR_IF_IF_GMII); - /* 1G COPPER */ - case TRANSVR_CLASS_COPPER_L1_1G: - return snprintf(result, lmax, TRANSVR_IF_IF_GMII); - /* 1G BASE_T */ - case TRANSVR_CLASS_BASE_T_1000: - return snprintf(result, lmax, TRANSVR_IF_IF_GMII); - /* 100 Base */ - case TRANSVR_CLASS_OPTICAL_100: - return snprintf(result, lmax, TRANSVR_IF_IF_GMII); - default: - snprintf(err_msg, sizeof(err_msg), - "Detect undefined value:%d", - transvr_cls); - goto err_sfp_set_trident2_if_type_1; - } - /* Exception case: Can't verify */ - snprintf(err_msg, sizeof(err_msg), "Can not identify!"); - goto err_sfp_set_trident2_if_type_1; - -err_sfp_set_trident2_if_type_1: - snprintf(result, lmax, TRANSVR_UEVENT_UNKNOW); - SWPS_INFO("%s: %s :%s\n", __func__, err_msg, self->swp_name); - return ERR_TRANSVR_ABNORMAL; -} - - -int -_sfp_set_tomahawk_if_type(struct transvr_obj_s* self, - int transvr_cls, - char *result) { - - int lmax = 8; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - - switch(transvr_cls) { - case TRANSVR_CLASS_ERROR: - case TRANSVR_CLASS_UNSPECIFIED: - break; - /* 25G OPTICAL */ - case TRANSVR_CLASS_OPTICAL_25G_AOC: - case TRANSVR_CLASS_OPTICAL_25G_SR: - case TRANSVR_CLASS_OPTICAL_25G_LR: - case TRANSVR_CLASS_OPTICAL_25G_ER: - case TRANSVR_CLASS_OPTICAL_25G: - return snprintf(result, lmax, TRANSVR_IF_SR); - /* 25G COPPER */ - case TRANSVR_CLASS_COPPER_L1_25G: - return snprintf(result, lmax, TRANSVR_IF_KR); - /* 10G OPTICAL */ - case TRANSVR_CLASS_OPTICAL_10G_S_AOC: - case TRANSVR_CLASS_OPTICAL_10G_S_SR: - case TRANSVR_CLASS_OPTICAL_10G_S_LR: - case TRANSVR_CLASS_OPTICAL_10G_S_ER: - case TRANSVR_CLASS_OPTICAL_10G: - return snprintf(result, lmax, TRANSVR_IF_SFI); - /* 10G COPPER */ - case TRANSVR_CLASS_COPPER_L1_10G: - return snprintf(result, lmax, TRANSVR_IF_SFI); - /* 1G OPTICAL */ - case TRANSVR_CLASS_OPTICAL_1G_AOC: - case TRANSVR_CLASS_OPTICAL_1G_SX: - case TRANSVR_CLASS_OPTICAL_1G_LX: - case TRANSVR_CLASS_OPTICAL_1G_EX: - case TRANSVR_CLASS_OPTICAL_1G: - return snprintf(result, lmax, TRANSVR_IF_IF_GMII); - /* 1G COPPER */ - case TRANSVR_CLASS_COPPER_L1_1G: - return snprintf(result, lmax, TRANSVR_IF_IF_GMII); - /* 1G BASE_T */ - case TRANSVR_CLASS_BASE_T_1000: - return snprintf(result, lmax, TRANSVR_IF_IF_GMII); - /* 100 Base */ - case TRANSVR_CLASS_OPTICAL_100: - return snprintf(result, lmax, TRANSVR_IF_IF_GMII); - default: - snprintf(err_msg, sizeof(err_msg), - "Detect undefined value:%d", - transvr_cls); - goto err_sfp_set_tomahawk_if_type_1; - } - /* Exception case: Can't verify */ - snprintf(err_msg, sizeof(err_msg), "Can not identify!"); - goto err_sfp_set_tomahawk_if_type_1; - -err_sfp_set_tomahawk_if_type_1: - snprintf(result, lmax, TRANSVR_UEVENT_UNKNOW); - SWPS_INFO("%s: %s\n :%s", __func__, err_msg, self->swp_name); - return ERR_TRANSVR_ABNORMAL; -} - - -int -_sfp_detect_if_type(struct transvr_obj_s* self, - char *result){ - - int lmax = 8; - int detect_cls = DEBUG_TRANSVR_INT_VAL; - - detect_cls = sft_detect_transvr_class(self); - switch (self->chipset_type) { - case BCM_CHIP_TYPE_TRIDENT_2: - return _sfp_set_trident2_if_type(self, detect_cls, result); - - case BCM_CHIP_TYPE_TOMAHAWK: - return _sfp_set_tomahawk_if_type(self, detect_cls, result); - - default: - SWPS_INFO("%s: non-defined chipset_type:%d :%s\n", - __func__, self->chipset_type, self->swp_name); - break; - } - snprintf(result, lmax, TRANSVR_UEVENT_UNKNOW); - return ERR_TRANSVR_ABNORMAL; -} - - -int -sfp_get_if_type(struct transvr_obj_s *self, - char *buf_p){ - - int lmax = 16; - char tmp_result[16] = DEBUG_TRANSVR_STR_VAL; - - if (self->state != STATE_TRANSVR_CONNECTED) { - return snprintf(buf_p, lmax, "%d\n", self->state); - } - if (_sfp_detect_if_type(self, tmp_result) < 0) { - return snprintf(buf_p, lmax, "%d\n", ERR_TRANSVR_ABNORMAL); - } - return snprintf(buf_p, lmax, "%s\n", tmp_result); -} - - -int -_sfp_detect_if_speed(struct transvr_obj_s* self, - char *result){ - - int lmax = 16; - int detect_val = DEBUG_TRANSVR_INT_VAL; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - - detect_val = sft_detect_transvr_class(self); - switch(detect_val) { - case TRANSVR_CLASS_ERROR: - case TRANSVR_CLASS_UNSPECIFIED: - break; - /* 25G OPTICAL */ - case TRANSVR_CLASS_OPTICAL_25G_AOC: - case TRANSVR_CLASS_OPTICAL_25G_SR: - case TRANSVR_CLASS_OPTICAL_25G_LR: - case TRANSVR_CLASS_OPTICAL_25G_ER: - case TRANSVR_CLASS_OPTICAL_25G: - return snprintf(result, lmax, TRANSVR_IF_SP_25G); - /* 25G COPPER */ - case TRANSVR_CLASS_COPPER_L1_25G: - return snprintf(result, lmax, TRANSVR_IF_SP_25G); - /* 10G OPTICAL */ - case TRANSVR_CLASS_OPTICAL_10G_S_AOC: - case TRANSVR_CLASS_OPTICAL_10G_S_SR: - case TRANSVR_CLASS_OPTICAL_10G_S_LR: - case TRANSVR_CLASS_OPTICAL_10G_S_ER: - case TRANSVR_CLASS_OPTICAL_10G: - return snprintf(result, lmax, TRANSVR_IF_SP_10G); - /* 10G COPPER */ - case TRANSVR_CLASS_COPPER_L1_10G: - return snprintf(result, lmax, TRANSVR_IF_SP_10G); - /* 1G OPTICAL */ - case TRANSVR_CLASS_OPTICAL_1G_AOC: - case TRANSVR_CLASS_OPTICAL_1G_SX: - case TRANSVR_CLASS_OPTICAL_1G_LX: - case TRANSVR_CLASS_OPTICAL_1G_EX: - case TRANSVR_CLASS_OPTICAL_1G: - return snprintf(result, lmax, TRANSVR_IF_SP_1G); - /* 1G COPPER */ - case TRANSVR_CLASS_COPPER_L1_1G: - return snprintf(result, lmax, TRANSVR_IF_SP_1G); - /* 1G BASE_T */ - case TRANSVR_CLASS_BASE_T_1000: - return snprintf(result, lmax, TRANSVR_IF_SP_1G); - /* 100 Base */ - case TRANSVR_CLASS_OPTICAL_100: - return snprintf(result, lmax, TRANSVR_IF_SP_100); - default: - snprintf(err_msg, sizeof(err_msg), - "Detect undefined value:%d", - detect_val); - goto err_sfp_detect_if_speed_1; - } - /* Check by BR */ - detect_val = _sfp_detect_if_sp_by_br(self); - switch (detect_val) { - case TRANSVR_CLASS_25G: - return snprintf(result, lmax, TRANSVR_IF_SP_25G); - case TRANSVR_CLASS_10G: - return snprintf(result, lmax, TRANSVR_IF_SP_10G); - case TRANSVR_CLASS_1G: - return snprintf(result, lmax, TRANSVR_IF_SP_1G); - default: - break; - } - /* Exception case: Can't verify */ - snprintf(err_msg, sizeof(err_msg), "Can not identify!"); - goto err_sfp_detect_if_speed_1; - -err_sfp_detect_if_speed_1: - snprintf(result, lmax, TRANSVR_UEVENT_UNKNOW); - SWPS_INFO("%s %s\n :%s", __func__, err_msg, self->swp_name); - return ERR_TRANSVR_ABNORMAL; -} - - -int -sfp_get_if_speed(struct transvr_obj_s *self, - char *buf_p){ - - int lmax = 16; - char tmp_result[16] = DEBUG_TRANSVR_STR_VAL; - - if (self->state != STATE_TRANSVR_CONNECTED) { - return snprintf(buf_p, lmax, "%d\n", self->state); - } - if (_sfp_detect_if_speed(self, tmp_result) < 0) { - return snprintf(buf_p, lmax, "%d\n", ERR_TRANSVR_ABNORMAL); - } - return snprintf(buf_p, lmax, "%s\n", tmp_result); -} - - -int -_qsfp_detect_class_by_extend_comp(struct transvr_obj_s* self) { - /* Reference: SFF-8024 (v3.8) - */ - int detect_val = DEBUG_TRANSVR_INT_VAL; - - detect_val = _qsfp_get_comp_extended(self); - switch(detect_val) { - case 0x00: /* Unspecified */ - return TRANSVR_CLASS_UNSPECIFIED; - - case 0x01: /* 100G AOC (Active Optical Cable) or 25GAUI C2M */ - case 0x18: /* 100G AOC or 25GAUI C2M AOC. */ - return TRANSVR_CLASS_OPTICAL_100G_AOC; - - case 0x06: /* 100G CWDM4 */ - case 0x09: /* Obsolete (assigned before 100G CWDM4 MSA required FEC) */ - case 0x17: /* 100G CLR4 */ - case 0x1A: /* 100GE-DWDM2 */ - return TRANSVR_CLASS_OPTICAL_100G; - - case 0x02: /* 100GBASE-SR4 or 25GBASE-SR */ - return TRANSVR_CLASS_OPTICAL_100G_SR4; - - case 0x03: /* 100GBASE-LR4 or 25GBASE-LR */ - return TRANSVR_CLASS_OPTICAL_100G_LR4; - - case 0x04: /* 100GBASE-ER4 or 25GBASE-ER */ - return TRANSVR_CLASS_OPTICAL_100G_ER4; - - case 0x07: /* 100G PSM4 Parallel SMF */ - return TRANSVR_CLASS_OPTICAL_100G_PSM4; - - case 0x12: /* 40G PSM4 Parallel SMF */ - return TRANSVR_CLASS_OPTICAL_40G; - - case 0x11: /* 4 x 10GBASE-SR */ - return TRANSVR_CLASS_OPTICAL_40G_SR4; - - case 0x10: /* 40GBASE-ER4 */ - return TRANSVR_CLASS_OPTICAL_40G_ER4; - - case 0x08: /* 100G ACC (Active Copper Cable) or 25GAUI C2M ACC. */ - case 0x0b: /* 100GBASE-CR4 or 25GBASE-CR CA-L */ - case 0x19: /* 100G ACC or 25GAUI C2M ACC. */ - return TRANSVR_CLASS_COPPER_L4_100G; - - default: - break; - } - SWPS_INFO("%s: Unexcept value:0x%02x\n :%s", - __func__, detect_val, self->swp_name); - return TRANSVR_CLASS_ERROR; -} - - -int -_qsfp_detect_class_by_10_40_100_ethernet(struct transvr_obj_s* self) { - /* Reference: SFF-8472 (v12.2) - */ - int detect_val = DEBUG_TRANSVR_INT_VAL; - - detect_val = _qsfp_get_comp_10_40_100_ethernet(self); - /* Case: Unspecified */ - if (detect_val == 0x00) { - return TRANSVR_CLASS_UNSPECIFIED; - } - /* Case: 40G Optical */ - if ((detect_val & 0x01) == 0x01) { /* 00000001 : 40G Active Cable (XLPPI) */ - return TRANSVR_CLASS_OPTICAL_40G_AOC; - } - if ((detect_val & 0x04) == 0x04) { /* 00000100 : 40GBASE-SR4 */ - return TRANSVR_CLASS_OPTICAL_40G_SR4; - } - if ( (detect_val & 0x02) == 0x02) { /* 00000010 : 40GBASE-LR4 */ - return TRANSVR_CLASS_OPTICAL_40G_LR4; - } - if ( (detect_val & 0x08) == 0x08) { /* 00001000 : 40GBASE-CR4 */ - return TRANSVR_CLASS_COPPER_L4_40G; - } - /* Case: 10G Optical */ - if ( (detect_val & 0x10) == 0x10) { /* 00010000 : 10GBASE-SR */ - return TRANSVR_CLASS_OPTICAL_10G_Q_SR; - } - if ( ((detect_val & 0x20) == 0x20) || /* 00100000 : 10GBASE-LR */ - ((detect_val & 0x40) == 0x40) ){ /* 01000000 : 10GBASE-LRM */ - return TRANSVR_CLASS_OPTICAL_10G_Q_LR; - } - /* Case: Extend Compliance */ - if ( ((detect_val & 0x80) == 0x80) ){ /* 10000000 : Use Extend Compliance */ - return TRANSVR_CLASS_EXTEND_COMP; - } - /* Case: ERROR */ - SWPS_INFO("%s: Unexcept value:0x%02x\n :%s", - __func__, detect_val, self->swp_name); - return TRANSVR_CLASS_ERROR; -} - - -int -_qsfp_detect_if_sp_by_br(struct transvr_obj_s* self) { - - int lower_bound_10g = 0x10; - int upper_bound_10g = 0x25; - int lower_bound_40g = 0x60; - int upper_bound_40g = 0x75; - int lower_bound_100g = 0x60; - int upper_bound_100g = 0x75; - int used_extend_br = 0xff; - int notmal_br = DEBUG_TRANSVR_INT_VAL; - int extend_br = DEBUG_TRANSVR_INT_VAL; - - notmal_br = (int)(self->br); /* updated by update_all() */ - /* Check 40G */ - if ((notmal_br >= lower_bound_40g) && - (notmal_br <= upper_bound_40g) ) { - return TRANSVR_CLASS_40G; - } - /* Check 100G */ - if (notmal_br == used_extend_br) { - extend_br = (int)(self->extbr); /* updated by update_all() */ - if ((extend_br >= lower_bound_100g) && - (extend_br <= upper_bound_100g) ) { - return TRANSVR_CLASS_100G; - } - } - /* Check 10G */ - if ((notmal_br >= lower_bound_10g) && - (notmal_br <= upper_bound_10g) ) { - return TRANSVR_CLASS_10G; - } - return TRANSVR_CLASS_UNSPECIFIED; -} - - -int -_qsfp_detect_class_by_feature(struct transvr_obj_s* self) { - /* Reference: SFF-8024 (v3.8) - */ - int conn_val = DEBUG_TRANSVR_INT_VAL; - int wave_len = DEBUG_TRANSVR_INT_VAL; - int speed_val = DEBUG_TRANSVR_INT_VAL; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - - speed_val = _qsfp_detect_if_sp_by_br(self); - conn_val = _qsfp_get_connector_type(self); - - switch(conn_val) { - case 0x00: /* Unspecified */ - return TRANSVR_CLASS_UNSPECIFIED; - case 0x07: /* LC (Lucent Connector) */ - case 0x0b: /* Optical Pigtail */ - case 0x0c: /* MPO 1x12 (Multifiber Parallel Optic) */ - case 0x0d: /* MPO 2x16 */ - goto ok_qsfp_detect_class_by_feature_4_optiocal; - case 0x21: /* Copper pigtail */ - goto ok_qsfp_detect_class_by_feature_4_copper; - case 0x23: /* No separable connector */ - if ((_qsfp_get_comp_fc_link_length(self) > 0) || - (_qsfp_get_comp_fc_trans_tech(self) > 0) || - (_qsfp_get_comp_fc_trans_media(self) > 0) || - (_qsfp_get_comp_fc_speed(self) > 0) ) { - goto ok_qsfp_detect_class_by_feature_4_aoc; - } - goto ok_qsfp_detect_class_by_feature_4_copper; - default: - snprintf(err_msg, sizeof(err_msg), - "_qsfp_get_connector_type return Non define value:%d", - conn_val); - goto err_qsfp_detect_class_by_feature_1; - } - return TRANSVR_CLASS_UNSPECIFIED; - -ok_qsfp_detect_class_by_feature_4_optiocal: - wave_len = _common_count_wavelength(self, - self->wavelength[0], - self->wavelength[1]); - switch(speed_val) { - case TRANSVR_CLASS_100G: - switch (wave_len) { - case VAL_OPTICAL_WAVELENGTH_SR: - return TRANSVR_CLASS_OPTICAL_100G_SR4; - case VAL_OPTICAL_WAVELENGTH_LR: - return TRANSVR_CLASS_OPTICAL_100G_LR4; - case VAL_OPTICAL_WAVELENGTH_ER: - return TRANSVR_CLASS_OPTICAL_100G_ER4; - default: - break; - } - return TRANSVR_CLASS_OPTICAL_100G; - - case TRANSVR_CLASS_40G: - switch (wave_len) { - case VAL_OPTICAL_WAVELENGTH_SR: - return TRANSVR_CLASS_OPTICAL_40G_SR4; - case VAL_OPTICAL_WAVELENGTH_LR: - return TRANSVR_CLASS_OPTICAL_40G_LR4; - case VAL_OPTICAL_WAVELENGTH_ER: - return TRANSVR_CLASS_OPTICAL_40G_ER4; - default: - break; - } - return TRANSVR_CLASS_OPTICAL_40G; - - case TRANSVR_CLASS_10G: - switch (wave_len) { - case VAL_OPTICAL_WAVELENGTH_SR: - return TRANSVR_CLASS_OPTICAL_10G_Q_SR; - case VAL_OPTICAL_WAVELENGTH_LR: - return TRANSVR_CLASS_OPTICAL_10G_Q_LR; - case VAL_OPTICAL_WAVELENGTH_ER: - return TRANSVR_CLASS_OPTICAL_10G_Q_ER; - default: - break; - } - return TRANSVR_CLASS_OPTICAL_10G; - - default: - return TRANSVR_CLASS_OPTICAL; - } - -ok_qsfp_detect_class_by_feature_4_aoc: - switch(speed_val) { - case TRANSVR_CLASS_100G: - return TRANSVR_CLASS_OPTICAL_100G_AOC; - case TRANSVR_CLASS_40G: - return TRANSVR_CLASS_OPTICAL_40G_AOC; - case TRANSVR_CLASS_10G: - return TRANSVR_CLASS_OPTICAL_10G_Q_AOC; - default: - return TRANSVR_CLASS_OPTICAL; - } - -ok_qsfp_detect_class_by_feature_4_copper: - switch(speed_val) { - case TRANSVR_CLASS_100G: - return TRANSVR_CLASS_COPPER_L4_100G; - case TRANSVR_CLASS_40G: - return TRANSVR_CLASS_COPPER_L4_40G; - case TRANSVR_CLASS_10G: - return TRANSVR_CLASS_COPPER_L4_10G; - default: - return TRANSVR_CLASS_COPPER; - } - -err_qsfp_detect_class_by_feature_1: - SWPS_INFO("%s: %s\n :%s", - __func__, err_msg, self->swp_name); - return TRANSVR_CLASS_ERROR; -} - - -int -qsft_detect_transvr_class(struct transvr_obj_s* self) { - - int detect_val = DEBUG_TRANSVR_INT_VAL; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - - /* Check Extended Compliance */ - detect_val = _qsfp_detect_class_by_extend_comp(self); - switch (detect_val) { - case TRANSVR_CLASS_UNSPECIFIED: - break; - case TRANSVR_CLASS_OPTICAL_100G: - case TRANSVR_CLASS_OPTICAL_100G_AOC: - case TRANSVR_CLASS_OPTICAL_100G_SR4: - case TRANSVR_CLASS_OPTICAL_100G_LR4: - case TRANSVR_CLASS_OPTICAL_100G_ER4: - case TRANSVR_CLASS_OPTICAL_100G_PSM4: - case TRANSVR_CLASS_OPTICAL_40G: - case TRANSVR_CLASS_OPTICAL_40G_AOC: - case TRANSVR_CLASS_OPTICAL_40G_SR4: - case TRANSVR_CLASS_OPTICAL_40G_LR4: - case TRANSVR_CLASS_OPTICAL_40G_ER4: - case TRANSVR_CLASS_COPPER_L4_100G: - return detect_val; - default: - snprintf(err_msg, sizeof(err_msg), - "Detect undefined extend_comp:%d", - detect_val); - goto err_qsft_detect_transvr_class_1; - } - /* Check 10/40G/100G Ethernet Compliance */ - detect_val = _qsfp_detect_class_by_10_40_100_ethernet(self); - switch(detect_val) { - case TRANSVR_CLASS_UNSPECIFIED: - break; - case TRANSVR_CLASS_OPTICAL_40G_AOC: - case TRANSVR_CLASS_OPTICAL_40G_SR4: - case TRANSVR_CLASS_OPTICAL_40G_LR4: - case TRANSVR_CLASS_OPTICAL_10G_Q_SR: /* Need Check: SR4 or SR */ - case TRANSVR_CLASS_OPTICAL_10G_Q_LR: /* Need Check: SR4 or SR */ - case TRANSVR_CLASS_COPPER_L4_40G: - return detect_val; - case TRANSVR_CLASS_EXTEND_COMP: - /* Format incorrect case (We already checked the Extend - * Compliance is 0 - */ - snprintf(err_msg, sizeof(err_msg), - "Transceiver format incorrect"); - goto err_qsft_detect_transvr_class_1; - default: - snprintf(err_msg, sizeof(err_msg), - "Detect undefined 10/40/100:%d", - detect_val); - goto err_qsft_detect_transvr_class_1; - } - /* Check by Connector type, BR and wavelength */ - detect_val = _qsfp_detect_class_by_feature(self); - switch (detect_val) { - case TRANSVR_CLASS_UNSPECIFIED: - break; - case TRANSVR_CLASS_OPTICAL_100G_ER4: - case TRANSVR_CLASS_OPTICAL_100G_LR4: - case TRANSVR_CLASS_OPTICAL_100G_SR4: - case TRANSVR_CLASS_OPTICAL_100G_AOC: - case TRANSVR_CLASS_OPTICAL_100G: - case TRANSVR_CLASS_OPTICAL_40G_ER4: - case TRANSVR_CLASS_OPTICAL_40G_LR4: - case TRANSVR_CLASS_OPTICAL_40G_SR4: - case TRANSVR_CLASS_OPTICAL_40G_AOC: - case TRANSVR_CLASS_OPTICAL_40G: - case TRANSVR_CLASS_OPTICAL_10G_Q_ER: - case TRANSVR_CLASS_OPTICAL_10G_Q_LR: - case TRANSVR_CLASS_OPTICAL_10G_Q_SR: - case TRANSVR_CLASS_OPTICAL_10G_Q_AOC: - case TRANSVR_CLASS_OPTICAL_10G: - case TRANSVR_CLASS_OPTICAL: - case TRANSVR_CLASS_COPPER_L4_100G: - case TRANSVR_CLASS_COPPER_L4_40G: - case TRANSVR_CLASS_COPPER_L4_10G: - case TRANSVR_CLASS_COPPER: - return detect_val; - default: - snprintf(err_msg, sizeof(err_msg), - "Detect undefined connector:%d", - detect_val); - goto err_qsft_detect_transvr_class_1; - } - /* Exception case: Can't verify */ - snprintf(err_msg, sizeof(err_msg), - "Can not identify!"); - goto err_qsft_detect_transvr_class_1; - -err_qsft_detect_transvr_class_1: - SWPS_INFO("%s: %s\n :%s", __func__, err_msg, self->swp_name); - return TRANSVR_CLASS_ERROR; -} - - -int -_qsfp_set_trident2_if_type(struct transvr_obj_s* self, - int transvr_cls, - char *result){ - - int lmax = 8; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - - switch (transvr_cls) { - case TRANSVR_CLASS_UNSPECIFIED: - case TRANSVR_CLASS_ERROR: - break; - /* 100G Optical */ - case TRANSVR_CLASS_OPTICAL_100G: - case TRANSVR_CLASS_OPTICAL_100G_AOC: - case TRANSVR_CLASS_OPTICAL_100G_SR4: - case TRANSVR_CLASS_OPTICAL_100G_LR4: - case TRANSVR_CLASS_OPTICAL_100G_ER4: - case TRANSVR_CLASS_OPTICAL_100G_PSM4: - return snprintf(result, lmax, TRANSVR_IF_SR4); - /* 100G Copper */ - case TRANSVR_CLASS_COPPER_L4_100G: - return snprintf(result, lmax, TRANSVR_IF_KR4); - /* 40G Optical */ - case TRANSVR_CLASS_OPTICAL_40G: - case TRANSVR_CLASS_OPTICAL_40G_AOC: - case TRANSVR_CLASS_OPTICAL_40G_SR4: - case TRANSVR_CLASS_OPTICAL_40G_LR4: - case TRANSVR_CLASS_OPTICAL_40G_ER4: - return snprintf(result, lmax, TRANSVR_IF_IF_XGMII); - /* 40G Copper */ - case TRANSVR_CLASS_COPPER_L4_40G: - return snprintf(result, lmax, TRANSVR_IF_IF_XGMII); - /* 10G Optical */ - case TRANSVR_CLASS_OPTICAL_10G: - case TRANSVR_CLASS_OPTICAL_10G_Q_AOC: - case TRANSVR_CLASS_OPTICAL_10G_Q_SR: /* Need Check: SR4 or SR */ - case TRANSVR_CLASS_OPTICAL_10G_Q_LR: /* Need Check: LR4 or LR */ - case TRANSVR_CLASS_OPTICAL_10G_Q_ER: /* Need Check: ER4 or ER */ - return snprintf(result, lmax, TRANSVR_IF_IF_XGMII); - /* Optical */ - case TRANSVR_CLASS_OPTICAL: - return snprintf(result, lmax, TRANSVR_IF_IF_XGMII); - /* Copper */ - case TRANSVR_CLASS_COPPER: - return snprintf(result, lmax, TRANSVR_IF_IF_XGMII); - default: - snprintf(err_msg, sizeof(err_msg), - "Detect undefined value:%d", - transvr_cls); - goto err_qsfp_set_trident2_if_type_1; - } - /* Exception case: Can't verify */ - snprintf(err_msg, sizeof(err_msg), "Can not identify!"); - goto err_qsfp_set_trident2_if_type_1; - -err_qsfp_set_trident2_if_type_1: - snprintf(result, lmax, TRANSVR_UEVENT_UNKNOW); - SWPS_INFO("%s: %s\n :%s", __func__, err_msg, self->swp_name); - return ERR_TRANSVR_ABNORMAL; -} - - -int -_qsfp_set_tomahawk_if_type(struct transvr_obj_s* self, - int transvr_cls, - char *result){ - - int lmax = 8; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - - switch (transvr_cls) { - case TRANSVR_CLASS_UNSPECIFIED: - case TRANSVR_CLASS_ERROR: - break; - /* 100G Optical */ - case TRANSVR_CLASS_OPTICAL_100G: - case TRANSVR_CLASS_OPTICAL_100G_AOC: - case TRANSVR_CLASS_OPTICAL_100G_SR4: - case TRANSVR_CLASS_OPTICAL_100G_LR4: - case TRANSVR_CLASS_OPTICAL_100G_ER4: - case TRANSVR_CLASS_OPTICAL_100G_PSM4: - return snprintf(result, lmax, TRANSVR_IF_SR4); - /* 100G Copper */ - case TRANSVR_CLASS_COPPER_L4_100G: - return snprintf(result, lmax, TRANSVR_IF_KR4); - /* 40G Optical */ - case TRANSVR_CLASS_OPTICAL_40G: - case TRANSVR_CLASS_OPTICAL_40G_AOC: - case TRANSVR_CLASS_OPTICAL_40G_SR4: - case TRANSVR_CLASS_OPTICAL_40G_LR4: - case TRANSVR_CLASS_OPTICAL_40G_ER4: - return snprintf(result, lmax, TRANSVR_IF_SR4); - /* 40G Copper */ - case TRANSVR_CLASS_COPPER_L4_40G: - return snprintf(result, lmax, TRANSVR_IF_KR4); - /* 10G Optical */ - case TRANSVR_CLASS_OPTICAL_10G: - case TRANSVR_CLASS_OPTICAL_10G_Q_AOC: - case TRANSVR_CLASS_OPTICAL_10G_Q_SR: /* Need Check: SR4 or SR */ - case TRANSVR_CLASS_OPTICAL_10G_Q_LR: /* Need Check: SR4 or SR */ - case TRANSVR_CLASS_OPTICAL_10G_Q_ER: - return snprintf(result, lmax, TRANSVR_IF_SR4); - /* Optical */ - case TRANSVR_CLASS_OPTICAL: - return snprintf(result, lmax, TRANSVR_IF_SR4); - /* Copper */ - case TRANSVR_CLASS_COPPER: - return snprintf(result, lmax, TRANSVR_IF_KR4); - default: - snprintf(err_msg, sizeof(err_msg), - "Detect undefined value:%d", - transvr_cls); - goto err_qsfp_set_trident2_if_type_1; - } - /* Exception case: Can't verify */ - snprintf(err_msg, sizeof(err_msg), "Can not identify!"); - goto err_qsfp_set_trident2_if_type_1; - -err_qsfp_set_trident2_if_type_1: - snprintf(result, lmax, TRANSVR_UEVENT_UNKNOW); - SWPS_INFO("%s: %s\n :%s", __func__, err_msg, self->swp_name); - return ERR_TRANSVR_ABNORMAL; -} - - -int -_qsfp_detect_if_type(struct transvr_obj_s* self, - char *result){ - - int lmax = 8; - int detect_cls = DEBUG_TRANSVR_INT_VAL; - - detect_cls = qsft_detect_transvr_class(self); - switch (self->chipset_type) { - case BCM_CHIP_TYPE_TRIDENT_2: - return _qsfp_set_trident2_if_type(self, detect_cls, result); - - case BCM_CHIP_TYPE_TOMAHAWK: - return _qsfp_set_tomahawk_if_type(self, detect_cls, result); - - default: - SWPS_INFO("%s: non-defined chipset_type:%d :%s\n", - __func__, self->chipset_type, self->swp_name); - break; - } - snprintf(result, lmax, TRANSVR_UEVENT_UNKNOW); - return ERR_TRANSVR_ABNORMAL; -} - - -int -qsfp_get_if_type(struct transvr_obj_s *self, - char *buf_p){ - - int lmax = 8; - char tmp_result[8] = DEBUG_TRANSVR_STR_VAL; - - if (self->state != STATE_TRANSVR_CONNECTED) { - return snprintf(buf_p, lmax, "%d\n", self->state); - } - if (_qsfp_detect_if_type(self, tmp_result) < 0) { - return snprintf(buf_p, lmax, "%d\n", ERR_TRANSVR_ABNORMAL); - } - return snprintf(buf_p, lmax, "%s\n", tmp_result); -} - - -int -_qsfp_detect_if_speed(struct transvr_obj_s* self, - char *result){ - int lmax = 16; - int detect_val = DEBUG_TRANSVR_INT_VAL; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - - detect_val = qsft_detect_transvr_class(self); - switch (detect_val) { - case TRANSVR_CLASS_UNSPECIFIED: - case TRANSVR_CLASS_ERROR: - break; - /* 100G Optical */ - case TRANSVR_CLASS_OPTICAL_100G: - case TRANSVR_CLASS_OPTICAL_100G_AOC: - case TRANSVR_CLASS_OPTICAL_100G_SR4: - case TRANSVR_CLASS_OPTICAL_100G_LR4: - case TRANSVR_CLASS_OPTICAL_100G_ER4: - case TRANSVR_CLASS_OPTICAL_100G_PSM4: - return snprintf(result, lmax, TRANSVR_IF_SP_100G); - /* 100G Copper */ - case TRANSVR_CLASS_COPPER_L4_100G: - return snprintf(result, lmax, TRANSVR_IF_SP_100G); - /* 40G Optical */ - case TRANSVR_CLASS_OPTICAL_40G: - case TRANSVR_CLASS_OPTICAL_40G_AOC: - case TRANSVR_CLASS_OPTICAL_40G_SR4: - case TRANSVR_CLASS_OPTICAL_40G_LR4: - case TRANSVR_CLASS_OPTICAL_40G_ER4: - return snprintf(result, lmax, TRANSVR_IF_SP_40G); - /* 40G Copper */ - case TRANSVR_CLASS_COPPER_L4_40G: - return snprintf(result, lmax, TRANSVR_IF_SP_40G); - /* 10G Optical */ - case TRANSVR_CLASS_OPTICAL_10G: - case TRANSVR_CLASS_OPTICAL_10G_Q_AOC: - case TRANSVR_CLASS_OPTICAL_10G_Q_SR: /* Need Check: SR4 or SR */ - case TRANSVR_CLASS_OPTICAL_10G_Q_LR: /* Need Check: SR4 or SR */ - case TRANSVR_CLASS_OPTICAL_10G_Q_ER: - return snprintf(result, lmax, TRANSVR_IF_SP_10G); - /* 10G Copper */ - case TRANSVR_CLASS_COPPER_L4_10G: - return snprintf(result, lmax, TRANSVR_IF_SP_10G); - /* Optical */ - case TRANSVR_CLASS_OPTICAL: - break; - /* Copper */ - case TRANSVR_CLASS_COPPER: - break; - default: - snprintf(err_msg, sizeof(err_msg), - "Detect undefined class case:%d", - detect_val); - goto err_qsfp_detect_if_speed_1; - } - /* Check br and extbr */ - detect_val = _qsfp_detect_if_sp_by_br(self); - switch(detect_val) { - case TRANSVR_CLASS_UNSPECIFIED: - break; - case TRANSVR_CLASS_10G: - return snprintf(result, lmax, TRANSVR_IF_SP_10G); - case TRANSVR_CLASS_40G: - return snprintf(result, lmax, TRANSVR_IF_SP_40G); - case TRANSVR_CLASS_100G: - return snprintf(result, lmax, TRANSVR_IF_SP_100G); - default: - snprintf(err_msg, sizeof(err_msg), - "Detect undefined BR case:%d", - detect_val); - goto err_qsfp_detect_if_speed_1; - } - /* Exception case: Can't verify */ - snprintf(err_msg, sizeof(err_msg), "Can not identify!"); - goto err_qsfp_detect_if_speed_1; - -err_qsfp_detect_if_speed_1: - snprintf(result, lmax, TRANSVR_UEVENT_UNKNOW); - SWPS_INFO("%s: %s :%s\n", __func__, err_msg, self->swp_name); - return ERR_TRANSVR_ABNORMAL; -} - - -int -qsfp_get_if_speed(struct transvr_obj_s *self, - char *buf_p){ - - int lmax = 16; - char tmp_result[16] = DEBUG_TRANSVR_STR_VAL; - - if (self->state != STATE_TRANSVR_CONNECTED) { - return snprintf(buf_p, lmax, "%d\n", self->state); - } - if (_qsfp_detect_if_speed(self, tmp_result) < 0) { - return snprintf(buf_p, lmax, "%d\n", ERR_TRANSVR_ABNORMAL); - } - return snprintf(buf_p, lmax, "%s\n", tmp_result); -} - - -int -_common_set_lane_map_str(struct transvr_obj_s* self, - char *result) { - int i = 0; - int tmp_val = 0; - char tmp_str[LEN_TRANSVR_L_STR] = DEBUG_TRANSVR_STR_VAL; - char err_msg[LEN_TRANSVR_L_STR] = DEBUG_TRANSVR_STR_VAL; - - memset(result, 0, LEN_TRANSVR_L_STR); - snprintf(result, LEN_TRANSVR_L_STR, "%s=", TRANSVR_UEVENT_KEY_LANE); - - for (i=0; ilane_id); i++) { - tmp_val = self->lane_id[i]; - if (tmp_val < 1) { - break; - } - if (tmp_val > 256) { - snprintf(err_msg, sizeof(err_msg), - "detect abnormal value:%d", tmp_val); - goto err_common_set_lane_map_str_1; - } - memset(tmp_str, 0, sizeof(tmp_str)); - if (i == 0) { - snprintf(tmp_str, LEN_TRANSVR_L_STR, "%d", tmp_val); - } else { - snprintf(tmp_str, LEN_TRANSVR_L_STR, ",%d", tmp_val); - } - strncat(result, tmp_str, LEN_TRANSVR_L_STR); - } - if (i == 0) { - goto err_common_set_lane_map_str_2; - } - return 0; - -err_common_set_lane_map_str_1: - SWPS_INFO("%s: %s", __func__, err_msg); -err_common_set_lane_map_str_2: - snprintf(result, LEN_TRANSVR_L_STR, "%s=%s", TRANSVR_UEVENT_KEY_LANE, TRANSVR_UEVENT_UNKNOW); - return EVENT_TRANSVR_TASK_FAIL; -} - - -int -_common_send_uevent(struct transvr_obj_s* self, - enum kobject_action u_action, - int (*detect_if_type)(struct transvr_obj_s *self, char *result), - int (*detect_if_speed)(struct transvr_obj_s *self, char *result), - int send_anyway) { - - char *uevent_envp[4]; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - char tmp_str[32] = DEBUG_TRANSVR_STR_VAL; - char tmp_str_1[32] = DEBUG_TRANSVR_STR_VAL; - char tmp_str_2[32] = DEBUG_TRANSVR_STR_VAL; - char tmp_str_3[64] = DEBUG_TRANSVR_STR_VAL; - - if (TRANSVR_UEVENT_ENABLE != 1) { - return ERR_TRANSVR_NOTSUPPORT; - } - if (_common_get_if_lane(self, tmp_str) < 0) { - snprintf(tmp_str_3, sizeof(tmp_str_3), - "%s=%s", TRANSVR_UEVENT_KEY_LANE, TRANSVR_UEVENT_UNKNOW); - } else { - snprintf(tmp_str_3, sizeof(tmp_str_3), - "%s=%s", TRANSVR_UEVENT_KEY_LANE, tmp_str); - } - switch (u_action) { - case KOBJ_ADD: - /* Detect type */ - if (detect_if_type(self, tmp_str) < 0) { - snprintf(err_msg, sizeof(err_msg), "%s", "Detect interface type fail!"); - snprintf(tmp_str_1, sizeof(tmp_str_1), "%s=%s", TRANSVR_UEVENT_KEY_IF, TRANSVR_UEVENT_UNKNOW); - snprintf(tmp_str_2, sizeof(tmp_str_2), "%s=%s", TRANSVR_UEVENT_KEY_SP, TRANSVR_UEVENT_UNKNOW); - uevent_envp[0] = tmp_str_1; - uevent_envp[1] = tmp_str_2; - uevent_envp[2] = tmp_str_3; - uevent_envp[3] = NULL; - goto private_common_send_uevent_4_fail; - } - snprintf(tmp_str_1, sizeof(tmp_str_1), "%s=%s", TRANSVR_UEVENT_KEY_IF, tmp_str); - uevent_envp[0] = tmp_str_1; - /* Detect speed */ - if (detect_if_speed(self, tmp_str) < 0) { - snprintf(err_msg, sizeof(err_msg), "%s", "Detect interface speed fail!"); - snprintf(tmp_str_2, sizeof(tmp_str_2), "%s=%s", TRANSVR_UEVENT_KEY_SP, TRANSVR_UEVENT_UNKNOW); - uevent_envp[1] = tmp_str_2; - uevent_envp[2] = tmp_str_3; - uevent_envp[3] = NULL; - goto private_common_send_uevent_4_fail; - } - snprintf(tmp_str_2, sizeof(tmp_str_2), "%s=%s", TRANSVR_UEVENT_KEY_SP, tmp_str); - uevent_envp[1] = tmp_str_2; - uevent_envp[2] = tmp_str_3; - uevent_envp[3] = NULL; - goto private_common_send_uevent_4_send; - - case KOBJ_REMOVE: - snprintf(tmp_str_1, sizeof(tmp_str_1), "%s=%s", TRANSVR_UEVENT_KEY_IF, TRANSVR_UEVENT_UNKNOW); - snprintf(tmp_str_2, sizeof(tmp_str_2), "%s=%s", TRANSVR_UEVENT_KEY_SP, TRANSVR_UEVENT_UNKNOW); - uevent_envp[0] = tmp_str_1; - uevent_envp[1] = tmp_str_2; - uevent_envp[2] = tmp_str_3; - uevent_envp[3] = NULL; - goto private_common_send_uevent_4_send; - - default: - snprintf(err_msg, sizeof(err_msg), "kobject_action:%d not support", u_action); - goto private_common_send_uevent_4_fail; - } - snprintf(err_msg, sizeof(err_msg), "%s", "Exception case"); - goto private_common_send_uevent_4_fail; - -private_common_send_uevent_4_fail: - SWPS_INFO("%s: %s :%s\n", __func__, err_msg, self->swp_name); - if (send_anyway) { - goto private_common_send_uevent_4_send; - } - return ERR_TRANSVR_UEVENT_FAIL; - -private_common_send_uevent_4_send: - return kobject_uevent_env(&(self->transvr_dev_p->kobj), - u_action, - uevent_envp); -} - -int -sfp_send_uevent(struct transvr_obj_s* self, - enum kobject_action u_action) { - int send_anyway = 1; - return _common_send_uevent(self, - u_action, - &_sfp_detect_if_type, - &_sfp_detect_if_speed, - send_anyway); -} - - -int -qsfp_send_uevent(struct transvr_obj_s* self, - enum kobject_action u_action) { - int send_anyway = 1; - return _common_send_uevent(self, - u_action, - &_qsfp_detect_if_type, - &_qsfp_detect_if_speed, - send_anyway); -} - - -int -fake_send_uevent(struct transvr_obj_s* self, - enum kobject_action u_action) { - return EVENT_TRANSVR_TASK_DONE; -} - - -int -common_fsm_4_direct_mode(struct transvr_obj_s* self, - char *caller_name){ - - int err; - int detect_result[2]; - int current_state = STATE_TRANSVR_UNEXCEPTED; - int current_type = TRANSVR_TYPE_ERROR; - - if (self->state == STATE_TRANSVR_NEW) { - if (_transvr_init_handler(self) < 0){ - return ERR_TRANSVR_INIT_FAIL; - } - } - err = detect_transvr_state(self, detect_result); - if (err < 0) { - return err; - } - /* In Direct mode, driver only detect transceiver when user call driver interface - * which on sysfs. So it only need consider the state of Transceiver. - */ - current_state = detect_result[0]; - current_type = detect_result[1]; - - switch (current_state){ - - case STATE_TRANSVR_DISCONNECTED: /* Transceiver is not plugged */ - self->state = current_state; - self->type = current_type; - return ERR_TRANSVR_UNPLUGGED; - - case STATE_TRANSVR_INIT: /* Transceiver is plugged, system not ready */ - return ERR_TRANSVR_UNINIT; - - case STATE_TRANSVR_ISOLATED: /* Transceiver is plugged, but has some issues */ - return ERR_TRNASVR_BE_ISOLATED; - - case STATE_TRANSVR_CONNECTED: /* Transceiver is plugged, system is ready */ - self->state = current_state; - self->type = current_type; - return 0; - - case STATE_TRANSVR_SWAPPED: /* Transceiver is plugged, system detect user changed */ - self->type = current_type; - if (reload_transvr_obj(self, current_type) < 0){ - self->state = STATE_TRANSVR_UNEXCEPTED; - return ERR_TRANSVR_UNEXCPT; - } - self->state = current_state; - return 0; - - case STATE_TRANSVR_UNEXCEPTED: /* Transceiver type or state is unexpected case */ - self->state = STATE_TRANSVR_UNEXCEPTED; - self->type = TRANSVR_TYPE_ERROR; - return ERR_TRANSVR_UNEXCPT; - - default: - SWPS_INFO("%s: state:%d not in define.\n", __func__, current_state); - break; - } - return ERR_TRANSVR_UNEXCPT; -} - - -static int -_is_except_happened_4_pmode(struct transvr_obj_s* self, - int new_state) { - - int event_chk = 0; - - if (self->temp == 0){ - return 0; - } - switch (new_state) { - case STATE_TRANSVR_INIT: - event_chk = EVENT_TRANSVR_EXCEP_INIT; - goto check_event_happened_4_pmode; - - case STATE_TRANSVR_CONNECTED: - event_chk = EVENT_TRANSVR_EXCEP_UP; - goto check_event_happened_4_pmode; - - case STATE_TRANSVR_DISCONNECTED: - event_chk = EVENT_TRANSVR_EXCEP_DOWN; - goto check_event_happened_4_pmode; - - case STATE_TRANSVR_SWAPPED: - event_chk = EVENT_TRANSVR_EXCEP_SWAP; - goto check_event_happened_4_pmode; - - case STATE_TRANSVR_UNEXCEPTED: - event_chk = EVENT_TRANSVR_EXCEP_EXCEP; - goto check_event_happened_4_pmode; - - case STATE_TRANSVR_ISOLATED: - event_chk = EVENT_TRANSVR_EXCEP_ISOLATED; - goto check_event_happened_4_pmode; - - default: - SWPS_INFO("%s: unexcepted case:%d\n", __func__, new_state); - break; - } - return 0; - -check_event_happened_4_pmode: - if (self->temp == event_chk){ - return 1; - } - return 0; -} - - -int -common_fsm_4_polling_mode(struct transvr_obj_s* self, - char *caller_name){ - /* [Return Value]: - * ERR_TRANSVR_UNINIT : (1) Initial not ready - * ERR_TRANSVR_UNPLUGGED : (1) Any -> Down - * ERR_TRANSVR_TASK_BUSY : (1) Wait Initial task - * ERR_TRANSVR_UNEXCPT : (1) Initial fail - * (2) Task fail - * (3) Reload fail - * ERR_TRNASVR_BE_ISOLATED : (1) Already be isolated - * OK Case (return 0) : (1) action_4_connected - * (2) action_4_nothing (initial retry) - */ - int curr_state[2]; - int old_state = self->state; - int old_type = self->type; - int new_state = STATE_TRANSVR_UNEXCEPTED; - int new_type = TRANSVR_TYPE_ERROR; - int return_val = ERR_TRANSVR_UNEXCPT; - - /* Never initial */ - if (self->state == STATE_TRANSVR_NEW) { - goto comfsm_action_4_reinit_obj; - } - /* Detect current state */ - switch (detect_transvr_state(self, curr_state)) { - case 0: - new_state = curr_state[0]; - new_type = curr_state[1]; - break; - - case ERR_TRNASVR_BE_ISOLATED: - new_state = STATE_TRANSVR_ISOLATED; - new_type = old_type; - break; - - case ERR_TRANSVR_I2C_CRASH: - goto comfsm_action_4_report_i2c_crash; - - case ERR_TRANSVR_UNEXCPT: - default: - new_state = STATE_TRANSVR_UNEXCEPTED; - new_type = old_type; - } - /* State handling */ - switch (old_state) { - case STATE_TRANSVR_INIT: /* INIT -> */ - return_val = ERR_TRANSVR_UNINIT; - goto comfsm_action_4_keep_state; - - case STATE_TRANSVR_CONNECTED: - switch (new_state) { - case STATE_TRANSVR_INIT: /* Case 1-1: UP -> INIT */ - SWPS_INFO("Detect %s is present. :1-1\n",self->swp_name); - return_val = ERR_TRANSVR_UNINIT; - goto comfsm_action_4_keep_state; - - case STATE_TRANSVR_CONNECTED: /* Case 1-2: UP -> UP */ - return_val = 0; - goto comfsm_action_4_keep_state; - - case STATE_TRANSVR_DISCONNECTED: /* Case 1-3: UP -> DOWN */ - SWPS_INFO("Detect %s is removed. :1-3\n",self->swp_name); - goto comfsm_action_4_disconnected; - - case STATE_TRANSVR_SWAPPED: /* Case 1-4: UP -> SWAP */ - SWPS_INFO("Detect %s is swapped. :1-4\n",self->swp_name); - goto comfsm_action_4_reload_obj; - - case STATE_TRANSVR_UNEXCEPTED: /* Case 1-5: UP -> UNEXPET */ - SWPS_INFO("Detect %s has error. :1-5\n",self->swp_name); - goto comfsm_action_4_unexpected; - - case STATE_TRANSVR_ISOLATED: /* Case 1-6: UP -> ISOLATE */ - SWPS_INFO("Detect %s be isolated. :1-6\n",self->swp_name); - goto comfsm_action_4_isolate_obj; - - default: - break; - } - goto comfsm_action_4_unexpected; - - case STATE_TRANSVR_DISCONNECTED: - switch (new_state) { - case STATE_TRANSVR_INIT: /* Case 2-1: DOWN -> INIT */ - SWPS_INFO("Detect %s is present. :2-1\n",self->swp_name); - return_val = ERR_TRANSVR_UNINIT; - goto comfsm_action_4_keep_state; - - case STATE_TRANSVR_CONNECTED: /* Case 2-2: DOWN -> UP */ - SWPS_INFO("Detect %s is present. :2-2\n",self->swp_name); - goto comfsm_action_4_reinit_obj; - - case STATE_TRANSVR_DISCONNECTED: /* Case 2-3: DOWN -> DOWN */ - return_val = ERR_TRANSVR_UNPLUGGED; - goto comfsm_action_4_keep_state; - - case STATE_TRANSVR_SWAPPED: /* Case 2-4: DOWN -> SWAP */ - SWPS_INFO("Detect %s is swapped. :2-4\n",self->swp_name); - goto comfsm_action_4_reload_obj; - - case STATE_TRANSVR_UNEXCEPTED: /* Case 2-5: DOWN -> UNEXPET */ - SWPS_INFO("Detect %s has error. :2-5\n",self->swp_name); - goto comfsm_action_4_unexpected; - - case STATE_TRANSVR_ISOLATED: /* Case 2-6: DOWN -> ISOLATE */ - SWPS_INFO("Detect %s be isolated. :2-6\n",self->swp_name); - goto comfsm_action_4_isolate_obj; - - default: - break; - } - goto comfsm_action_4_unexpected; - - case STATE_TRANSVR_UNEXCEPTED: - /* Filter out re-action */ - if (_is_except_happened_4_pmode(self, new_state)) { - goto comfsm_action_4_keep_state; - } - /* First action */ - switch (new_state) { - case STATE_TRANSVR_INIT: /* Case 3-1: UNEXPET -> INIT */ - SWPS_INFO("Detect %s is present. :3-1\n",self->swp_name); - self->temp = EVENT_TRANSVR_EXCEP_INIT; - return_val = ERR_TRANSVR_UNINIT; - goto comfsm_action_4_keep_state; - - case STATE_TRANSVR_CONNECTED: /* Case 3-2: UNEXPET -> UP */ - SWPS_INFO("Detect %s is present. :3-2\n",self->swp_name); - self->temp = EVENT_TRANSVR_EXCEP_UP; - goto comfsm_action_4_reload_obj; - - case STATE_TRANSVR_DISCONNECTED: /* Case 3-3: UNEXPET -> DOWN */ - SWPS_INFO("Detect %s is removed. :3-3\n",self->swp_name); - goto comfsm_action_4_disconnected; - - case STATE_TRANSVR_SWAPPED: /* Case 3-4: UNEXPET -> SWAP */ - SWPS_INFO("Detect %s is swapped. :3-4\n",self->swp_name); - self->temp = EVENT_TRANSVR_EXCEP_SWAP; - goto comfsm_action_4_reload_obj; - - case STATE_TRANSVR_UNEXCEPTED: /* Case 3-5: UNEXPET -> UNEXPET */ - self->temp = EVENT_TRANSVR_EXCEP_EXCEP; - return_val = ERR_TRANSVR_UNEXCPT; - goto comfsm_action_4_keep_state; - - case STATE_TRANSVR_ISOLATED: /* Case 3-6: UNEXPET -> ISOLATE */ - SWPS_INFO("Detect %s be isolated. :3-6\n",self->swp_name); - goto comfsm_action_4_isolate_obj; - - default: - break; - } - goto comfsm_action_4_unexpected; - - case STATE_TRANSVR_ISOLATED: - /* Filter out re-action */ - if (_is_except_happened_4_pmode(self, new_state)) { - goto comfsm_action_4_keep_state; - } - /* First action */ - switch (new_state) { - case STATE_TRANSVR_INIT: /* Case 4-1: ISOLATE -> INIT */ - SWPS_INFO("Detect %s internal error. :4-1\n",self->swp_name); - self->temp = EVENT_TRANSVR_EXCEP_INIT; - return_val = ERR_TRNASVR_BE_ISOLATED; - goto comfsm_action_4_keep_state; - - case STATE_TRANSVR_CONNECTED: /* Case 4-2: ISOLATE -> UP */ - SWPS_INFO("Detect %s internal error. :4-2\n",self->swp_name); - self->temp = EVENT_TRANSVR_EXCEP_UP; - return_val = ERR_TRNASVR_BE_ISOLATED; - goto comfsm_action_4_keep_state; - - case STATE_TRANSVR_DISCONNECTED: /* Case 4-3: ISOLATE -> DOWN */ - SWPS_INFO("Detect %s is removed. :4-3\n",self->swp_name); - goto comfsm_action_4_disconnected; - - case STATE_TRANSVR_SWAPPED: /* Case 4-4: ISOLATE -> SWAP */ - SWPS_INFO("Detect %s internal error. :4-4\n",self->swp_name); - self->temp = EVENT_TRANSVR_EXCEP_SWAP; - return_val = ERR_TRNASVR_BE_ISOLATED; - goto comfsm_action_4_keep_state; - - case STATE_TRANSVR_UNEXCEPTED: /* Case 4-5: ISOLATE -> UNEXPET */ - SWPS_INFO("Detect %s internal error. :4-5\n",self->swp_name); - self->temp = EVENT_TRANSVR_EXCEP_EXCEP; - return_val = ERR_TRNASVR_BE_ISOLATED; - goto comfsm_action_4_keep_state; - - case STATE_TRANSVR_ISOLATED: /* Case 4-6: ISOLATE -> ISOLATE */ - return_val = ERR_TRNASVR_BE_ISOLATED; - goto comfsm_action_4_keep_state; - - default: - break; - } - goto comfsm_action_4_unexpected; - - default: - break; - } - goto comfsm_action_4_unexpected; - - -comfsm_action_4_keep_state: - return return_val; - -comfsm_action_4_reinit_obj: - SWPS_DEBUG("FSM action: %s re-initial.\n", self->swp_name); - return_val = _transvr_init_handler(self); - goto comfsm_action_4_identify_event; - -comfsm_action_4_reload_obj: - SWPS_DEBUG("FSM action: %s reload.\n", self->swp_name); - self->type = new_type; - return_val = reload_transvr_obj(self, new_type); - goto comfsm_action_4_identify_event; - -comfsm_action_4_identify_event: - switch (return_val) { - case EVENT_TRANSVR_INIT_UP: - case EVENT_TRANSVR_TASK_DONE: - goto comfsm_action_4_connected; - - case EVENT_TRANSVR_INIT_DOWN: - goto comfsm_action_4_disconnected; - - case EVENT_TRANSVR_INIT_REINIT: - goto comfsm_action_4_nothing; - - case EVENT_TRANSVR_TASK_WAIT: - self->state = STATE_TRANSVR_INIT; - return ERR_TRANSVR_TASK_BUSY; - - case EVENT_TRANSVR_TASK_FAIL: - SWPS_INFO("%s detect EVENT_TRANSVR_TASK_FAIL.\n", self->swp_name); - goto comfsm_action_4_unexpected; - - case EVENT_TRANSVR_INIT_FAIL: - SWPS_INFO("%s detect EVENT_TRANSVR_INIT_FAIL.\n", self->swp_name); - goto comfsm_action_4_unexpected; - - case EVENT_TRANSVR_RELOAD_FAIL: - SWPS_INFO("%s detect EVENT_TRANSVR_RELOAD_FAIL.\n", self->swp_name); - goto comfsm_action_4_unexpected; - - case EVENT_TRANSVR_I2C_CRASH: - goto comfsm_action_4_report_i2c_crash; - - case EVENT_TRANSVR_EXCEP_ISOLATED: - goto comfsm_action_4_isolate_obj; - - default: - SWPS_INFO("%s detect undefined event:%d.\n", self->swp_name, return_val); - goto comfsm_action_4_unexpected; - } - -comfsm_action_4_nothing: - SWPS_DEBUG("FSM action: %s do nothing.\n", self->swp_name); - return 0; - -comfsm_action_4_connected: - SWPS_DEBUG("FSM action: %s Connected.\n", self->swp_name); - self->state = STATE_TRANSVR_CONNECTED; - self->type = new_type; - self->send_uevent(self, KOBJ_ADD); - _transvr_clean_retry(self); - return 0; - -comfsm_action_4_disconnected: - SWPS_DEBUG("FSM action: %s Disconnected. \n", self->swp_name); - self->state = STATE_TRANSVR_DISCONNECTED; - self->temp = EVENT_TRANSVR_TASK_DONE; - self->send_uevent(self, KOBJ_REMOVE); - _transvr_clean_retry(self); - _transvr_clean_handler(self); - return ERR_TRANSVR_UNPLUGGED; - -comfsm_action_4_report_i2c_crash: - SWPS_DEBUG("FSM action: %s report I2C crash.\n", self->swp_name); - self->state = STATE_TRANSVR_UNEXCEPTED; - return ERR_TRANSVR_I2C_CRASH; - -comfsm_action_4_isolate_obj: - SWPS_DEBUG("FSM action: %s isolate.\n", self->swp_name); - self->state = STATE_TRANSVR_ISOLATED; - return ERR_TRNASVR_BE_ISOLATED; - -comfsm_action_4_unexpected: - SWPS_INFO("FSM action: %s unexpected.\n", self->swp_name); - SWPS_INFO("Dump: :%d :0x%02x :%d :0x%02x\n", - old_state, old_type, new_state, new_type); - self->state = STATE_TRANSVR_UNEXCEPTED; - self->send_uevent(self, KOBJ_REMOVE); - _transvr_clean_handler(self); - return ERR_TRANSVR_UNEXCPT; -} - - -int -fake_fsm_4_direct_mode(struct transvr_obj_s* self, - char *caller_name){ - self->state = STATE_TRANSVR_CONNECTED; - self->type = TRANSVR_TYPE_FAKE; - return 0; -} - - -int -fake_fsm_4_polling_mode(struct transvr_obj_s* self, - char *caller_name){ - self->state = STATE_TRANSVR_CONNECTED; - self->type = TRANSVR_TYPE_FAKE; - return 0; -} - - -/* ========== Object functions for Initial procedure ========== - */ -int -transvr_init_common(struct transvr_obj_s *self){ - /* Nothing to update */ - return EVENT_TRANSVR_TASK_DONE; -} - - -int -transvr_init_fake(struct transvr_obj_s *self){ - return EVENT_TRANSVR_TASK_DONE; -} - - -int -transvr_init_sfp(struct transvr_obj_s *self){ - - int tmp_val = DEBUG_TRANSVR_INT_VAL; - int err_code = DEBUG_TRANSVR_INT_VAL; - char *err_msg = "ERR"; - - self->info = sft_detect_transvr_class(self); - /* Disable auto_config */ - if (!self->auto_config) { - return EVENT_TRANSVR_TASK_DONE; - } - /* Handle multi-rate */ - err_code = initfunc_sfp_handle_multi_rate_mode(self); - if (err_code < 0) { - err_msg = "initfunc_sfp_handle_multi_rate_mode fail!"; - goto err_transvr_init_sfp_1; - } - /* Handle 1G- RJ45 */ - tmp_val = err_code; - err_code = initfunc_sfp_handle_1g_rj45(self); - if (err_code < 0) { - err_msg = "initfunc_sfp_handle_1g_rj45 fail!"; - goto err_transvr_init_sfp_1; - } - tmp_val = (tmp_val > err_code ? tmp_val : err_code); - if (tmp_val > EVENT_TRANSVR_TASK_DONE) { - return tmp_val; - } - return EVENT_TRANSVR_TASK_DONE; - -err_transvr_init_sfp_1: - SWPS_INFO("%s: %s :%d :%s\n", - __func__, err_msg, err_code, self->swp_name); - return EVENT_TRANSVR_INIT_FAIL; -} - - -int -transvr_init_qsfp(struct transvr_obj_s *self){ - - int err = EVENT_TRANSVR_EXCEP_EXCEP; - char *emsg = "ERR"; - - self->info = qsft_detect_transvr_class(self); - if (!self->auto_config) { - return EVENT_TRANSVR_TASK_DONE; - } - err = initfunc_qsfp_handle_power_mode(self); - if (err < 0){ - emsg = "initfunc_qsfp_handle_tx_disable fail!"; - goto err_transvr_init_qsfp; - } - return EVENT_TRANSVR_TASK_DONE; - -err_transvr_init_qsfp: - SWPS_INFO("%s: %s :%d :%s\n", - __func__, emsg, err, self->swp_name); - return EVENT_TRANSVR_INIT_FAIL; -} - - -int -transvr_init_qsfp28(struct transvr_obj_s *self){ - - int tmp_val = EVENT_TRANSVR_EXCEP_EXCEP; - int err_val = EVENT_TRANSVR_EXCEP_EXCEP; - char *err_msg = "ERR"; - - /* Handle QSFP common */ - err_val = transvr_init_qsfp(self); - if (err_val < 0){ - err_msg = "transvr_init_qsfp fail!"; - goto err_transvr_init_qsfp28_1; - } - /* Disable auto_config */ - if (!self->auto_config) { - return err_val; - } - /* Handle CDR */ - tmp_val = err_val; - err_val = initfunc_qsfp28_handle_cdr(self); - if (err_val < 0){ - err_msg = "Handle CDR fail!"; - goto err_transvr_init_qsfp28_1; - } - tmp_val = (tmp_val > err_val ? tmp_val : err_val); - if (tmp_val > EVENT_TRANSVR_TASK_DONE) { - return tmp_val; - } - return EVENT_TRANSVR_TASK_DONE; - -err_transvr_init_qsfp28_1: - SWPS_INFO("%s: %s :%d :%s\n", - __func__, err_msg, err_val, self->swp_name); - return EVENT_TRANSVR_INIT_FAIL; -} - - -/* ========== Object Initial handler ========== - */ -static int -_is_transvr_valid(struct transvr_obj_s *self, - int type, - int state) { - /* [Return] - * 0 : OK, inserted - * EVENT_TRANSVR_INIT_DOWN : OK, removed - * EVENT_TRANSVR_INIT_FAIL : Outside error, type doesn't supported - * EVENT_TRANSVR_EXCEP_INIT : Internal error, state undefined - */ - switch (type) { - case TRANSVR_TYPE_SFP: - case TRANSVR_TYPE_QSFP: - case TRANSVR_TYPE_QSFP_PLUS: - case TRANSVR_TYPE_QSFP_28: - case TRANSVR_TYPE_UNPLUGGED: - case TRANSVR_TYPE_FAKE: - break; - default: - SWPS_INFO("detect undefined type:0x%02x on %s\n", - type, self->swp_name); - return EVENT_TRANSVR_INIT_FAIL; - } - switch (state) { - case STATE_TRANSVR_DISCONNECTED: - return EVENT_TRANSVR_INIT_DOWN; - case STATE_TRANSVR_INIT: - case STATE_TRANSVR_CONNECTED: - case STATE_TRANSVR_SWAPPED: - break; - default: - SWPS_INFO("detect undefined state:%d on %s\n", - state, self->swp_name); - return EVENT_TRANSVR_EXCEP_INIT; - } - return 0; -} - - -static int -_is_transvr_hw_ready(struct transvr_obj_s *self, - int type){ - /* [Return] - * EVENT_TRANSVR_TASK_DONE : Ready - * EVENT_TRANSVR_TASK_WAIT : Not ready - * EVENT_TRANSVR_INIT_FAIL : Error - */ - int addr = DEBUG_TRANSVR_INT_VAL; - int page = DEBUG_TRANSVR_INT_VAL; - int offs = DEBUG_TRANSVR_INT_VAL; - int bit = DEBUG_TRANSVR_INT_VAL; - int ready = DEBUG_TRANSVR_INT_VAL; - int err = DEBUG_TRANSVR_INT_VAL; - char *emsg = DEBUG_TRANSVR_STR_VAL; - uint8_t ab_val = DEBUG_TRANSVR_HEX_VAL; - - switch (type) { - case TRANSVR_TYPE_SFP: - addr = VAL_TRANSVR_8472_READY_ADDR; - page = VAL_TRANSVR_8472_READY_PAGE; - offs = VAL_TRANSVR_8472_READY_OFFSET; - bit = VAL_TRANSVR_8472_READY_BIT; - ready = VAL_TRANSVR_8472_READY_VALUE; - ab_val = VAL_TRANSVR_8472_READY_ABNORMAL; - break; - - case TRANSVR_TYPE_QSFP: - case TRANSVR_TYPE_QSFP_PLUS: - case TRANSVR_TYPE_QSFP_28: - addr = VAL_TRANSVR_8436_READY_ADDR; - page = VAL_TRANSVR_8436_READY_PAGE; - offs = VAL_TRANSVR_8436_READY_OFFSET; - bit = VAL_TRANSVR_8436_READY_BIT; - ready = VAL_TRANSVR_8436_READY_VALUE; - ab_val = VAL_TRANSVR_8436_READY_ABNORMAL; - break; - - case TRANSVR_TYPE_UNPLUGGED: - case TRANSVR_TYPE_FAKE: - return EVENT_TRANSVR_TASK_DONE; - - default: - emsg = "unexpected case"; - goto err_is_transvr_hw_ready; - } - /* Select target page */ - err = _common_setup_page(self, addr, page, offs, 1, 0); - if (err < 0) { - emsg = "setup page fail"; - goto err_is_transvr_hw_ready; - } - /* Check feature supported - * [Note] - * Some of transceiver/cables doesn't support "Status Indicators" - * (ex:DAC, RJ45 copper SFP ...etc). In these case, we bypass the - * step of checking Status Indicators, then state machine will take - * the following handle procedure. - */ - err = i2c_smbus_read_byte_data(self->i2c_client_p, - VAL_TRANSVR_COMID_OFFSET); - if (err < 0) { - emsg = "doesn't support Status Indicators"; - goto bypass_is_transvr_hw_ready; - } - /* Filter abnormal case */ - if (err == ab_val) { - emsg = "detect using unusual definition."; - goto bypass_is_transvr_hw_ready; - } - /* Get Status Indicators */ - err = i2c_smbus_read_byte_data(self->i2c_client_p, offs); - if (err < 0) { - emsg = "detect current value fail"; - goto err_is_transvr_hw_ready; - } - if ((err & (1<:%d\n", __func__, emsg, type); - return EVENT_TRANSVR_TASK_DONE; - -err_is_transvr_hw_ready: - SWPS_DEBUG("%s: %s :%d\n", __func__, emsg, type); - return EVENT_TRANSVR_INIT_FAIL; -} - - -static int -_is_transvr_support_ctle(struct transvr_obj_s *self) { - - switch (self->info) { - case TRANSVR_CLASS_OPTICAL_25G: - case TRANSVR_CLASS_OPTICAL_25G_AOC: - case TRANSVR_CLASS_OPTICAL_25G_SR: - case TRANSVR_CLASS_OPTICAL_25G_LR: - case TRANSVR_CLASS_OPTICAL_25G_ER: - case TRANSVR_CLASS_OPTICAL_100G: - case TRANSVR_CLASS_OPTICAL_100G_AOC: - case TRANSVR_CLASS_OPTICAL_100G_SR4: - case TRANSVR_CLASS_OPTICAL_100G_LR4: - case TRANSVR_CLASS_OPTICAL_100G_ER4: - case TRANSVR_CLASS_OPTICAL_100G_PSM4: - return 1; - default: - break; - } - return 0; -} - - -static int -_transvr_init_handler(struct transvr_obj_s *self){ - - int detect[2]; - int d_state = STATE_TRANSVR_UNEXCEPTED; - int d_type = TRANSVR_TYPE_ERROR; - int result = ERR_TRANSVR_UNINIT; - int retry = 6; /* (6+1) x 0.3 = 2.1s > spec:2.0s */ - int elimit = 63; - char emsg[64] = DEBUG_TRANSVR_STR_VAL; - - /* Clean and check callback */ - self->state = STATE_TRANSVR_INIT; - if (self->init == NULL) { - snprintf(emsg, elimit, "init() is null"); - goto initer_err_case_unexcept_0; - } - if (self->clean == NULL) { - snprintf(emsg, elimit, "clean() is null"); - goto initer_err_case_unexcept_0; - } - self->clean(self); - - /* Detect transceiver information */ - result = detect_transvr_state(self, detect); - if (result < 0) { - snprintf(emsg, elimit, "detect_transvr_state() fail"); - switch (result) { - case ERR_TRANSVR_I2C_CRASH: - goto initer_err_case_i2c_ceash; - case ERR_TRNASVR_BE_ISOLATED: - goto initer_err_case_be_isolated; - - case ERR_TRANSVR_UNEXCPT: - default: - break; - } - goto initer_err_case_retry_1; - } - d_state = detect[0]; - d_type = detect[1]; - - /* Verify transceiver type and state */ - switch (_is_transvr_valid(self, d_type, d_state)) { - case 0: - break; - case EVENT_TRANSVR_INIT_DOWN: - goto initer_ok_case_down;; - case EVENT_TRANSVR_INIT_FAIL: - snprintf(emsg, elimit, "transceiver type doesn't support"); - goto initer_err_case_alarm_to_user; - case EVENT_TRANSVR_EXCEP_INIT: - default: - goto initer_err_case_unexcept_1; - } - - /* Handle reload case */ - if (self->type != d_type){ - /* This is the protect mechanism. Normally, This case will not happen. - * When State machine detect swap event during initial, It will trigger - * reload function to ensure type correct. */ - if (_reload_transvr_obj(self, d_type) < 0){ - snprintf(emsg, elimit, "reload object fail"); - goto initer_err_case_unexcept_1; - } - } - - /* Check transceiver HW initial ready */ - switch (_is_transvr_hw_ready(self, d_type)) { - case EVENT_TRANSVR_TASK_DONE: - break; - case EVENT_TRANSVR_TASK_WAIT: - goto initer_err_case_retry_1; - case EVENT_TRANSVR_INIT_FAIL: - default: - goto initer_err_case_unexcept_1; - } - - /* Try to update all and check */ - if (self->update_all(self, 1) < 0){ - /* For some transceiver, EEPROME has lag issues during initial stage. - * In this case, we set status back to STATE_TRANSVR_NEW, than it will - * be checked in next polling cycle. */ - goto initer_err_case_retry_1; - } - - /* Execute init() call back */ - result = self->init(self); - switch (result) { - case EVENT_TRANSVR_TASK_DONE: - break; - case EVENT_TRANSVR_TASK_WAIT: - goto initer_ok_case_wait; - - default: - snprintf(emsg, elimit, "undefined init() return:%d\n", result); - goto initer_err_case_unexcept_1; - } - goto initer_ok_case_up; - - -initer_ok_case_wait: - self->dump_all(self); - return EVENT_TRANSVR_TASK_WAIT; - -initer_ok_case_up: - self->state = STATE_TRANSVR_CONNECTED; - self->temp = 0; - self->dump_all(self); - return EVENT_TRANSVR_INIT_UP; - -initer_ok_case_down: - self->temp = 0; - self->state = STATE_TRANSVR_DISCONNECTED; - return EVENT_TRANSVR_INIT_DOWN; - -initer_err_case_i2c_ceash: - SWPS_DEBUG("%s: %s :%s :I2C crash\n", - __func__, emsg, self->swp_name); - self->state = STATE_TRANSVR_UNEXCEPTED; - return EVENT_TRANSVR_I2C_CRASH; - -initer_err_case_be_isolated: - SWPS_DEBUG("%s: %s :%s :isolated\n", - __func__, emsg, self->swp_name); - self->state = STATE_TRANSVR_ISOLATED; - return EVENT_TRANSVR_EXCEP_ISOLATED; - -initer_err_case_retry_1: - SWPS_DEBUG("%s: %s :%s :retry\n", - __func__, emsg, self->swp_name); - if (_transvr_handle_retry(self, retry) == 0) { - self->state = STATE_TRANSVR_NEW; - return EVENT_TRANSVR_INIT_REINIT; - } - goto initer_err_case_alarm_to_user; - -initer_err_case_unexcept_1: - self->clean(self); -initer_err_case_unexcept_0: - self->state = STATE_TRANSVR_UNEXCEPTED; - if (_is_except_happened_4_pmode(self, d_state) && - (self->mode == TRANSVR_MODE_POLLING) ){ - SWPS_INFO("%s: %s :%s\n", __func__, emsg, self->swp_name); - SWPS_INFO("Dump: :%d :%d :%d :%d\n", - self->state, self->type, d_state, d_type); - } - return EVENT_TRANSVR_INIT_FAIL; - -initer_err_case_alarm_to_user: - SWPS_DEBUG("%s: %s :%s :alarm_to_user\n", - __func__, emsg, self->swp_name); - self->state = STATE_TRANSVR_UNEXCEPTED; - alarm_msg_2_user(self, "detected transceiver/cables not meet SFF standard"); - return EVENT_TRANSVR_INIT_FAIL; -} - - -/* ========== Object functions for Clean procedure ========== - */ -int -_transvr_clean_handler(struct transvr_obj_s *self){ - - int retval = DEBUG_TRANSVR_INT_VAL; - - if (!self->clean) { - SWPS_ERR("%s: %s clean() is NULL.\n", - __func__, self->swp_name); - return EVENT_TRANSVR_TASK_FAIL; - } - retval = self->clean(self); - if (retval != EVENT_TRANSVR_TASK_DONE){ - SWPS_ERR("%s: %s clean() fail. [ERR]:%d\n", - __func__, self->swp_name, retval); - return retval; - } - return EVENT_TRANSVR_TASK_DONE; -} - - -int -common_transvr_clean(struct transvr_obj_s *self){ - - transvr_task_free_all(self); - return EVENT_TRANSVR_TASK_DONE; -} - - -int -qsfp_transvr_clean(struct transvr_obj_s *self){ - - int retval; - int lpower_config = 1; - - retval = _taskfunc_qsfp_setup_power_mod(self, lpower_config); - if (retval < 0){ - SWPS_ERR("%s: Set lpmod fail! :%d\n", - __func__, retval); - return retval; - } - retval = common_transvr_clean(self); - if (retval < 0){ - SWPS_ERR("%s: common_transvr_clean fail! :%d\n", - __func__, retval); - return retval; - } - return EVENT_TRANSVR_TASK_DONE; -} - - -int -fake_transvr_clean(struct transvr_obj_s *self){ - - return EVENT_TRANSVR_TASK_DONE; -} - - -/* ========== Object functions for check and update ========== - */ -int -common_transvr_check(struct transvr_obj_s *self){ - - char fun_str[32] = "common_transvr_check"; - - if (self->mode != TRANSVR_MODE_POLLING) { - SWPS_ERR("%s: mode:%d is not TRANSVR_MODE_POLLING\n", - fun_str, self->mode); - return ERR_TRANSVR_UNEXCPT; - } - /* Trigger delay task */ - transvr_task_run_all(self); - /* Trigger state machine to check and update */ - return self->fsm_4_polling(self, fun_str); -} - - -int -fake_transvr_check(struct transvr_obj_s *self){ - return 0; -} - - -/* ========== Functions for Factory pattern ========== - */ -static int -setup_transvr_public_cb(struct transvr_obj_s *self, - int transvr_type){ - switch (transvr_type){ - case TRANSVR_TYPE_SFP: - self->get_id = common_get_id; - self->get_ext_id = common_get_ext_id; - self->get_connector = common_get_connector; - self->get_vendor_name = common_get_vendor_name; - self->get_vendor_pn = common_get_vendor_pn; - self->get_vendor_rev = common_get_vendor_rev; - self->get_vendor_sn = common_get_vendor_sn; - self->get_power_cls = unsupported_get_func; - self->get_br = common_get_br; - self->get_len_sm = sfp_get_len_sm; - self->get_len_smf = common_get_len_smf; - self->get_len_om1 = common_get_len_om1; - self->get_len_om2 = common_get_len_om2; - self->get_len_om3 = common_get_len_om3; - self->get_len_om4 = common_get_len_om4; - self->get_comp_rev = common_get_comp_rev; - self->get_comp_eth_1 = sfp_get_comp_eth_1; - self->get_comp_eth_10 = sfp_get_comp_eth_10; - self->get_comp_eth_10_40 = unsupported_get_func; - self->get_comp_extend = common_get_comp_extended; - self->get_cdr = unsupported_get_func; - self->get_rate_id = sfp_get_rate_id; - self->get_soft_rs0 = sfp_get_soft_rs0; - self->get_soft_rs1 = sfp_get_soft_rs1; - self->get_info = common_get_info; - self->get_if_type = sfp_get_if_type; - self->get_if_speed = sfp_get_if_speed; - self->get_if_lane = common_get_if_lane; - self->get_curr_temp = sfp_get_transvr_temp; - self->get_curr_vol = sfp_get_transvr_voltage; - self->get_soft_rx_los = unsupported_get_func2; - self->get_soft_tx_disable = unsupported_get_func2; - self->get_soft_tx_fault = unsupported_get_func2; - self->get_auto_tx_disable = unsupported_get_func2; - self->get_tx_bias = sfp_get_transvr_tx_bias; - self->get_tx_power = sfp_get_transvr_tx_power; - self->get_rx_power = sfp_get_transvr_rx_power; - self->get_tx_eq = sfp_get_transvr_tx_eq; - self->get_rx_am = unsupported_get_func2; - self->get_rx_em = sfp_get_transvr_rx_em; - self->get_wavelength = sfp_get_wavelength; - self->set_cdr = unsupported_set_func; - self->set_soft_rs0 = sfp_set_soft_rs0; - self->set_soft_rs1 = sfp_set_soft_rs1; - self->set_soft_tx_disable = unsupported_set_func; - self->set_auto_tx_disable = unsupported_set_func; - self->set_tx_eq = sfp_set_tx_eq; - self->set_rx_am = unsupported_set_func; - self->set_rx_em = sfp_set_rx_em; - return 0; - - case TRANSVR_TYPE_QSFP: - case TRANSVR_TYPE_QSFP_PLUS: - self->get_id = common_get_id; - self->get_eeprom = common_get_eeprom; - self->get_ext_id = common_get_ext_id; - self->get_connector = common_get_connector; - self->get_vendor_name = common_get_vendor_name; - self->get_vendor_pn = common_get_vendor_pn; - self->get_vendor_rev = common_get_vendor_rev; - self->get_vendor_sn = common_get_vendor_sn; - self->get_power_cls = qsfp_get_power_cls; - self->get_br = common_get_br; - self->get_len_sm = unsupported_get_func; - self->get_len_smf = common_get_len_smf; - self->get_len_om1 = common_get_len_om1; - self->get_len_om2 = common_get_len_om2; - self->get_len_om3 = common_get_len_om3; - self->get_len_om4 = common_get_len_om4; - self->get_comp_rev = common_get_comp_rev; - self->get_comp_eth_1 = qsfp_get_comp_eth; - self->get_comp_eth_10 = unsupported_get_func; - self->get_comp_eth_10_40 = qsfp_get_comp_10_40; - self->get_comp_extend = common_get_comp_extended; - self->get_cdr = unsupported_get_func; - self->get_rate_id = unsupported_get_func; - self->get_soft_rs0 = unsupported_get_func; /* TBD */ - self->get_soft_rs1 = unsupported_get_func; /* TBD */ - self->get_info = common_get_info; - self->get_if_type = qsfp_get_if_type; - self->get_if_speed = qsfp_get_if_speed; - self->get_if_lane = common_get_if_lane; - self->get_curr_temp = qsfp_get_transvr_temp; - self->get_curr_vol = qsfp_get_transvr_voltage; - self->get_soft_rx_los = qsfp_get_soft_rx_los; - self->get_soft_tx_disable = qsfp_get_soft_tx_disable; - self->get_soft_tx_fault = qsfp_get_soft_tx_fault; - self->get_auto_tx_disable = qsfp_get_auto_tx_disable; - self->get_tx_bias = qsfp_get_transvr_tx_bias; - self->get_tx_power = qsfp_get_transvr_tx_power; - self->get_rx_power = qsfp_get_transvr_rx_power; - self->get_tx_eq = unsupported_get_func2; - self->get_rx_am = unsupported_get_func2; - self->get_rx_em = unsupported_get_func2; - self->get_wavelength = qsfp_get_wavelength; - self->set_cdr = unsupported_set_func; - self->set_soft_rs0 = unsupported_set_func; /* TBD */ - self->set_soft_rs1 = unsupported_set_func; /* TBD */ - self->set_soft_tx_disable = qsfp_set_soft_tx_disable; - self->set_auto_tx_disable = qsfp_set_auto_tx_disable; - self->set_tx_eq = unsupported_set_func; - self->set_rx_am = unsupported_set_func; - self->set_rx_em = unsupported_set_func; - return 0; - - case TRANSVR_TYPE_QSFP_28: - self->get_id = common_get_id; - self->get_eeprom = common_get_eeprom; - self->get_ext_id = common_get_ext_id; - self->get_connector = common_get_connector; - self->get_vendor_name = common_get_vendor_name; - self->get_vendor_pn = common_get_vendor_pn; - self->get_vendor_rev = common_get_vendor_rev; - self->get_vendor_sn = common_get_vendor_sn; - self->get_power_cls = qsfp_get_power_cls; - self->get_br = common_get_br; - self->get_len_sm = unsupported_get_func; - self->get_len_smf = common_get_len_smf; - self->get_len_om1 = common_get_len_om1; - self->get_len_om2 = common_get_len_om2; - self->get_len_om3 = common_get_len_om3; - self->get_len_om4 = common_get_len_om4; - self->get_comp_rev = common_get_comp_rev; - self->get_comp_eth_1 = qsfp_get_comp_eth; - self->get_comp_eth_10 = unsupported_get_func; - self->get_comp_eth_10_40 = qsfp_get_comp_10_40; - self->get_comp_extend = common_get_comp_extended; - self->get_cdr = qsfp_get_cdr; - self->get_rate_id = unsupported_get_func; - self->get_soft_rs0 = unsupported_get_func; /* TBD */ - self->get_soft_rs1 = unsupported_get_func; /* TBD */ - self->get_info = common_get_info; - self->get_if_type = qsfp_get_if_type; - self->get_if_speed = qsfp_get_if_speed; - self->get_if_lane = common_get_if_lane; - self->get_curr_temp = qsfp_get_transvr_temp; - self->get_curr_vol = qsfp_get_transvr_voltage; - self->get_soft_rx_los = qsfp_get_soft_rx_los; - self->get_soft_tx_disable = qsfp_get_soft_tx_disable; - self->get_soft_tx_fault = qsfp_get_soft_tx_fault; - self->get_auto_tx_disable = qsfp_get_auto_tx_disable; - self->get_tx_bias = qsfp_get_transvr_tx_bias; - self->get_tx_power = qsfp_get_transvr_tx_power; - self->get_rx_power = qsfp_get_transvr_rx_power; - self->get_tx_eq = qsfp_get_transvr_tx_eq; - self->get_rx_am = qsfp_get_transvr_rx_am; - self->get_rx_em = qsfp_get_transvr_rx_em; - self->get_wavelength = qsfp_get_wavelength; - self->set_cdr = qsfp_set_cdr; - self->set_soft_rs0 = unsupported_set_func; /* TBD */ - self->set_soft_rs1 = unsupported_set_func; /* TBD */ - self->set_soft_tx_disable = qsfp_set_soft_tx_disable; - self->set_auto_tx_disable = qsfp_set_auto_tx_disable; - self->set_tx_eq = qsfp_set_tx_eq; - self->set_rx_am = qsfp_set_rx_am; - self->set_rx_em = qsfp_set_rx_em; - return 0; - - case TRANSVR_TYPE_FAKE: - self->get_id = fake_get_hex; - self->get_ext_id = fake_get_hex; - self->get_connector = fake_get_hex; - self->get_vendor_name = fake_get_str; - self->get_vendor_pn = fake_get_str; - self->get_vendor_rev = fake_get_str; - self->get_vendor_sn = fake_get_str; - self->get_power_cls = fake_get_int; - self->get_br = fake_get_hex; - self->get_len_sm = fake_get_int; - self->get_len_smf = fake_get_int; - self->get_len_om1 = fake_get_int; - self->get_len_om2 = fake_get_int; - self->get_len_om3 = fake_get_int; - self->get_len_om4 = fake_get_int; - self->get_comp_rev = fake_get_hex; - self->get_comp_eth_1 = fake_get_hex; - self->get_comp_eth_10 = fake_get_hex; - self->get_comp_eth_10_40 = fake_get_hex; - self->get_comp_extend = fake_get_hex; - self->get_cdr = fake_get_hex; - self->get_rate_id = fake_get_hex; - self->get_soft_rs0 = fake_get_binary; - self->get_soft_rs1 = fake_get_binary; - self->get_info = fake_get_int; - self->get_if_type = fake_get_str; - self->get_if_speed = fake_get_str; - self->get_if_lane = fake_get_str; - self->get_curr_temp = fake_get_str; - self->get_curr_vol = fake_get_str; - self->get_soft_rx_los = fake_get_str; - self->get_soft_tx_disable = fake_get_str; - self->get_soft_tx_fault = fake_get_str; - self->get_auto_tx_disable = fake_get_str; - self->get_tx_bias = fake_get_str; - self->get_tx_power = fake_get_str; - self->get_rx_power = fake_get_str; - self->get_tx_eq = fake_get_str; - self->get_rx_am = fake_get_str; - self->get_rx_em = fake_get_str; - self->get_wavelength = fake_get_str; - self->set_cdr = fake_set_hex; - self->set_soft_rs0 = fake_set_int; - self->set_soft_rs1 = fake_set_int; - self->set_soft_tx_disable = fake_set_int; - self->set_auto_tx_disable = fake_set_int; - self->set_tx_eq = fake_set_int; - self->set_rx_am = fake_set_int; - self->set_rx_em = fake_set_int; - return 0; - - default: - break; - } - SWPS_WARN("%s: Detect non-defined type:%d\n", __func__, transvr_type); - return ERR_TRANSVR_UNEXCPT; -} - - -static int -setup_transvr_private_cb(struct transvr_obj_s *self, - int transvr_type){ - switch (transvr_type){ - case TRANSVR_TYPE_SFP: - self->init = transvr_init_sfp; - self->clean = common_transvr_clean; - self->check = common_transvr_check; - self->update_all = _sfp_update_attr_all; - self->fsm_4_direct = common_fsm_4_direct_mode; - self->fsm_4_polling = common_fsm_4_polling_mode; - self->send_uevent = sfp_send_uevent; - self->dump_all = sfp_transvr_dump; - return 0; - - case TRANSVR_TYPE_QSFP: - case TRANSVR_TYPE_QSFP_PLUS: - self->init = transvr_init_qsfp; - self->clean = qsfp_transvr_clean; - self->check = common_transvr_check; - self->update_all = _qsfp_update_attr_all; - self->fsm_4_direct = common_fsm_4_direct_mode; - self->fsm_4_polling = common_fsm_4_polling_mode; - self->send_uevent = qsfp_send_uevent; - self->dump_all = qsfp_transvr_dump; - return 0; - - case TRANSVR_TYPE_QSFP_28: - self->init = transvr_init_qsfp28; - self->clean = qsfp_transvr_clean; - self->check = common_transvr_check; - self->update_all = _qsfp_update_attr_all; - self->fsm_4_direct = common_fsm_4_direct_mode; - self->fsm_4_polling = common_fsm_4_polling_mode; - self->send_uevent = qsfp_send_uevent; - self->dump_all = qsfp_transvr_dump; - return 0; - - case TRANSVR_TYPE_FAKE: - self->init = transvr_init_fake; - self->clean = fake_transvr_clean; - self->check = fake_transvr_check; - self->update_all = fake_transvr_update; - self->fsm_4_direct = fake_fsm_4_direct_mode; - self->fsm_4_polling = fake_fsm_4_polling_mode; - self->send_uevent = fake_send_uevent; - self->dump_all = fake_transvr_dump; - return 0; - - default: - break; - } - SWPS_WARN("%s: Detect non-defined type:%d\n", __func__, transvr_type); - return ERR_TRANSVR_UNEXCPT; -} - - -static struct eeprom_map_s * -get_eeprom_map(int transvr_type){ - - switch (transvr_type){ - case TRANSVR_TYPE_SFP: - return &eeprom_map_sfp; - case TRANSVR_TYPE_QSFP: - case TRANSVR_TYPE_QSFP_PLUS: - return &eeprom_map_qsfp; - case TRANSVR_TYPE_QSFP_28: - return &eeprom_map_qsfp28; - - default: - break; - } - SWPS_WARN("%s: Detect non-defined type:%d\n", __func__, transvr_type); - return NULL; -} - - -static int -setup_transvr_ssize_attr(char *swp_name, - struct transvr_obj_s *self, - struct eeprom_map_s *map_p, - struct ioexp_obj_s *ioexp_obj_p, - int ioexp_virt_offset, - int transvr_type, - int chipset_type, - int chan_id, - int run_mode){ - switch (run_mode){ - case TRANSVR_MODE_DIRECT: /* Direct access device mode */ - case TRANSVR_MODE_POLLING: /* Polling mode, read from cache */ - self->mode = run_mode; - break; - default: - SWPS_ERR("%s: non-defined run_mode:%d\n", - __func__, run_mode); - self->mode = DEBUG_TRANSVR_INT_VAL; - return -1; - } - self->eeprom_map_p = map_p; - self->ioexp_obj_p = ioexp_obj_p; - self->ioexp_virt_offset = ioexp_virt_offset; - self->chan_id = chan_id; - self->layout = transvr_type; - self->type = transvr_type; - self->chipset_type = chipset_type; - self->state = STATE_TRANSVR_NEW; - self->info = STATE_TRANSVR_NEW; - self->auto_tx_disable = VAL_TRANSVR_FUNCTION_DISABLE; - strncpy(self->swp_name, swp_name, 32); - mutex_init(&self->lock); - return 0; -} - - -static int -setup_transvr_dsize_attr(struct transvr_obj_s *self){ - - char *emsg = DEBUG_TRANSVR_STR_VAL; - - self->vendor_name = kzalloc((LEN_TRANSVR_M_STR * sizeof(char)), GFP_KERNEL); - if (!self->vendor_name){ - emsg = "vendor_name"; - goto err_setup_d_attr; - } - self->vendor_pn = kzalloc((LEN_TRANSVR_M_STR * sizeof(char)), GFP_KERNEL); - if (!self->vendor_pn){ - emsg = "vendor_pn"; - goto err_setup_d_attr; - } - self->vendor_rev = kzalloc((LEN_TRANSVR_M_STR * sizeof(char)), GFP_KERNEL); - if (!self->vendor_rev){ - emsg = "vendor_rev"; - goto err_setup_d_attr; - } - self->vendor_sn = kzalloc((LEN_TRANSVR_M_STR * sizeof(char)), GFP_KERNEL); - if (!self->vendor_sn){ - emsg = "vendor_sn"; - goto err_setup_d_attr; - } - self->worker_p = NULL; - return 0; - -err_setup_d_attr: - SWPS_ERR("%s: %s kzalloc fail!", __func__, emsg); - return ERR_TRANSVR_UNEXCPT; -} - - -static int -setup_i2c_client(struct transvr_obj_s *self){ - - struct i2c_adapter *adap = NULL; - struct i2c_client *client = NULL; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - - adap = i2c_get_adapter(self->chan_id); - if(!adap){ - snprintf(err_msg, sizeof(err_msg), - "can not get adap:%d", self->chan_id); - goto err_setup_i2c_client; - } - client = kzalloc(sizeof(*client), GFP_KERNEL); - if (!client){ - snprintf(err_msg, sizeof(err_msg), - "can not kzalloc client:%d", self->chan_id); - goto err_setup_i2c_client; - } - client->adapter = adap; - self->i2c_client_p = client; - self->i2c_client_p->addr = VAL_TRANSVR_COMID_ARREESS; - return 0; - -err_setup_i2c_client: - SWPS_ERR("%s: %s\n", __func__, err_msg); - return ERR_TRANSVR_UNEXCPT; -} - - -struct transvr_obj_s * -create_transvr_obj(char *swp_name, - int chan_id, - struct ioexp_obj_s *ioexp_obj_p, - int ioexp_virt_offset, - int transvr_type, - int chipset_type, - int run_mode){ - - struct transvr_obj_s *result_p; - struct eeprom_map_s *map_p; - char err_msg[64] = DEBUG_TRANSVR_STR_VAL; - - /* Allocate transceiver object */ - map_p = get_eeprom_map(transvr_type); - if (!map_p){ - snprintf(err_msg, sizeof(err_msg), - "Invalid transvr_type:%d", transvr_type); - goto err_create_transvr_fail; - } - result_p = kzalloc(sizeof(*result_p), GFP_KERNEL); - if (!result_p){ - snprintf(err_msg, sizeof(err_msg), "kzalloc fail"); - goto err_create_transvr_fail; - } - /* Prepare static size attributes */ - if (setup_transvr_ssize_attr(swp_name, - result_p, - map_p, - ioexp_obj_p, - ioexp_virt_offset, - transvr_type, - chipset_type, - chan_id, - run_mode) < 0){ - goto err_create_transvr_sattr_fail; - } - /* Prepare dynamic size attributes */ - if (setup_transvr_dsize_attr(result_p) < 0){ - goto err_create_transvr_dattr_fail; - } - /* Prepare call back functions of object */ - if (setup_transvr_public_cb(result_p, transvr_type) < 0){ - goto err_create_transvr_dattr_fail; - } - /* Prepare call back functions of object */ - if (setup_transvr_private_cb(result_p, transvr_type) < 0){ - goto err_create_transvr_dattr_fail; - } - /* Prepare i2c client object */ - if (setup_i2c_client(result_p) < 0){ - goto err_create_transvr_dattr_fail; - } - return result_p; - -err_create_transvr_dattr_fail: - kfree(result_p->vendor_sn); - kfree(result_p->vendor_rev); - kfree(result_p->vendor_pn); - kfree(result_p->vendor_name); -err_create_transvr_sattr_fail: - kfree(result_p); -err_create_transvr_fail: - SWPS_ERR("%s: %s :%d :%d :%d\n", - __func__, err_msg, chan_id, ioexp_virt_offset, transvr_type); - return NULL; -} - - -static int -_reload_transvr_obj(struct transvr_obj_s *self, - int new_type){ - - struct eeprom_map_s *new_map_p; - struct eeprom_map_s *old_map_p = self->eeprom_map_p; - struct i2c_client *old_i2c_p = self->i2c_client_p; - int old_type = self->type; - - /* Change state to STATE_TRANSVR_INIT */ - self->state = STATE_TRANSVR_INIT; - self->type = new_type; - /* Replace EEPROME map */ - new_map_p = get_eeprom_map(new_type); - if (!new_map_p){ - goto err_private_reload_func_1; - } - self->eeprom_map_p = new_map_p; - /* Reload i2c client */ - if (setup_i2c_client(self) < 0){ - goto err_private_reload_func_2; - } - /* Replace call back functions */ - if (setup_transvr_public_cb(self, new_type) < 0){ - goto err_private_reload_func_3; - } - if (setup_transvr_private_cb(self, new_type) < 0){ - goto err_private_reload_func_3; - } - kfree(old_i2c_p); - return 0; - -err_private_reload_func_3: - SWPS_INFO("%s: init() fail!\n", __func__); - kfree(old_i2c_p); - self->state = STATE_TRANSVR_UNEXCEPTED; - self->type = TRANSVR_TYPE_ERROR; - return -2; - -err_private_reload_func_2: - self->eeprom_map_p = old_map_p; - self->i2c_client_p = old_i2c_p; -err_private_reload_func_1: - self->state = STATE_TRANSVR_UNEXCEPTED; - self->type = old_type; - SWPS_INFO("%s fail! :0x%02x\n", __func__, new_type); - return -1; -} - - -static int -reload_transvr_obj(struct transvr_obj_s *self, - int new_type){ - - int result_val = ERR_TRANSVR_UNEXCPT; - - /* Reload phase */ - result_val = _reload_transvr_obj(self, new_type); - if (result_val < 0){ - SWPS_INFO("%s: reload phase fail! :%d\n", - __func__, result_val); - return EVENT_TRANSVR_RELOAD_FAIL; - } - /* Initial phase */ - result_val = _transvr_init_handler(self); - if (result_val < 0){ - SWPS_INFO("%s: initial phase fail! :%d\n", - __func__, result_val); - } - return result_val; -} - - -int -isolate_transvr_obj(struct transvr_obj_s *self) { - - self->state = STATE_TRANSVR_ISOLATED; - SWPS_INFO("%s: %s be isolated\n", __func__, self->swp_name); - return 0; -} - - -int -resync_channel_tier_2(struct transvr_obj_s *self) { - - int val = TRANSVR_TYPE_ERROR; - - if (self->state == STATE_TRANSVR_ISOLATED) { - return 0; - } - self->i2c_client_p->addr = VAL_TRANSVR_COMID_ARREESS; - val = i2c_smbus_read_byte_data(self->i2c_client_p, - VAL_TRANSVR_COMID_OFFSET); - if (val < 0) { - return -1; - } - return 0; -} - - -/* ----------------------------------------- - * ToDo List - * ----------------------------------------- - * 1. _sfp_detect_class_by_feature() - * => Need check ACC use case. - * 2. _sfp_detect_class_by_1g_ethernet() - * => Need check 0.1G use case. - * 3. Loopback transceiver use case. - * => Less much data - * 4. _qsfp_detect_class_by_extend_comp() - * => Verify 100G CWDM4 - * => Verify Obsolete (assigned before 100G CWDM4 MSA required FEC) - * => Verify 100G CLR4 - * => Verify 100GE-DWDM2 - * => Verify 40G PSM4 Parallel SMF - * => Verify 100G ACC (Active Copper Cable) or 25GAUI C2M ACC. - * => Verify 100G ACC or 25GAUI C2M ACC. - * => Verify 25GBASE-LR - * => Verify 40G Active Cable (XLPPI) - */ - - - - diff --git a/packages/platforms/inventec/x86-64/d7264q28b/modules/builds/src/transceiver.h b/packages/platforms/inventec/x86-64/d7264q28b/modules/builds/src/transceiver.h deleted file mode 100644 index e7acffb87..000000000 --- a/packages/platforms/inventec/x86-64/d7264q28b/modules/builds/src/transceiver.h +++ /dev/null @@ -1,796 +0,0 @@ -#ifndef TRANSCEIVER_H -#define TRANSCEIVER_H - -#include - -/* advanced features control */ -#define TRANSVR_INFO_DUMP_ENABLE (1) -#define TRANSVR_INFO_CACHE_ENABLE (1) -#define TRANSVR_UEVENT_ENABLE (1) - -/* Transceiver type define */ -#define TRANSVR_TYPE_UNKNOW_1 (0x00) -#define TRANSVR_TYPE_UNKNOW_2 (0xff) -#define TRANSVR_TYPE_SFP (0x03) /* Define for SFP, SFP+, SFP28 */ -#define TRANSVR_TYPE_QSFP (0x0c) -#define TRANSVR_TYPE_QSFP_PLUS (0x0d) -#define TRANSVR_TYPE_QSFP_28 (0x11) -#define TRANSVR_TYPE_UNPLUGGED (0xfa) /* Define for ERROR handle */ -#define TRANSVR_TYPE_FAKE (0xfc) /* Define for ERROR handle */ -#define TRANSVR_TYPE_INCONSISTENT (0xfd) /* Define for ERROR handle */ -#define TRANSVR_TYPE_ERROR (0xfe) /* Define for ERROR handle */ - -/* Transceiver class for base info */ -#define TRANSVR_CLASS_UNSPECIFIED (0) -#define TRANSVR_CLASS_ERROR (-26001) -#define TRANSVR_CLASS_1G (26001) -#define TRANSVR_CLASS_10G (26011) -#define TRANSVR_CLASS_25G (26021) -#define TRANSVR_CLASS_40G (26041) -#define TRANSVR_CLASS_100G (26101) -#define TRANSVR_CLASS_NO_SPERARABLE (26901) -#define TRANSVR_CLASS_EXTEND_COMP (26902) -/* Transceiver class for Optical 1G */ -#define TRANSVR_CLASS_OPTICAL (27000) -#define TRANSVR_CLASS_OPTICAL_100 (27001) -#define TRANSVR_CLASS_OPTICAL_1G (27002) -#define TRANSVR_CLASS_OPTICAL_1G_AOC (27003) -#define TRANSVR_CLASS_OPTICAL_1G_SX (27004) -#define TRANSVR_CLASS_OPTICAL_1G_LX (27005) -#define TRANSVR_CLASS_OPTICAL_1G_EX (27006) -/* Transceiver class for Optical 10G */ -#define TRANSVR_CLASS_OPTICAL_10G (27010) -#define TRANSVR_CLASS_OPTICAL_10G_S_AOC (27011) -#define TRANSVR_CLASS_OPTICAL_10G_S_SR (27012) -#define TRANSVR_CLASS_OPTICAL_10G_S_LR (27013) -#define TRANSVR_CLASS_OPTICAL_10G_S_ER (27014) -#define TRANSVR_CLASS_OPTICAL_10G_Q_AOC (27015) -#define TRANSVR_CLASS_OPTICAL_10G_Q_SR (27016) -#define TRANSVR_CLASS_OPTICAL_10G_Q_LR (27017) -#define TRANSVR_CLASS_OPTICAL_10G_Q_ER (27018) -/* Transceiver class for Optical 25G */ -#define TRANSVR_CLASS_OPTICAL_25G (27020) -#define TRANSVR_CLASS_OPTICAL_25G_AOC (27021) -#define TRANSVR_CLASS_OPTICAL_25G_SR (27022) -#define TRANSVR_CLASS_OPTICAL_25G_LR (27023) -#define TRANSVR_CLASS_OPTICAL_25G_ER (27024) -/* Transceiver class for Optical 40G */ -#define TRANSVR_CLASS_OPTICAL_40G (27040) -#define TRANSVR_CLASS_OPTICAL_40G_AOC (27041) -#define TRANSVR_CLASS_OPTICAL_40G_SR4 (27042) -#define TRANSVR_CLASS_OPTICAL_40G_LR4 (27043) -#define TRANSVR_CLASS_OPTICAL_40G_ER4 (27044) -/* Transceiver class for Optical 100G */ -#define TRANSVR_CLASS_OPTICAL_100G (27100) -#define TRANSVR_CLASS_OPTICAL_100G_AOC (27101) -#define TRANSVR_CLASS_OPTICAL_100G_SR4 (27102) -#define TRANSVR_CLASS_OPTICAL_100G_LR4 (27103) -#define TRANSVR_CLASS_OPTICAL_100G_ER4 (27104) -#define TRANSVR_CLASS_OPTICAL_100G_PSM4 (27105) -/* Transceiver class for Copper */ -#define TRANSVR_CLASS_COPPER (28000) -#define TRANSVR_CLASS_COPPER_L1_1G (28001) -#define TRANSVR_CLASS_COPPER_L1_10G (28011) -#define TRANSVR_CLASS_COPPER_L4_10G (28012) -#define TRANSVR_CLASS_COPPER_L1_25G (28021) -#define TRANSVR_CLASS_COPPER_L4_40G (28041) -#define TRANSVR_CLASS_COPPER_L4_100G (28101) -/* Transceiver class for Base-T */ -#define TRANSVR_CLASS_BASE_T_1000 (29001) -#define TRANSVR_CLASS_BASE_T_1000_up (29002) -/* For uevent message */ -#define TRANSVR_UEVENT_KEY_IF "IF_TYPE" -#define TRANSVR_UEVENT_KEY_SP "IF_SPEED" -#define TRANSVR_UEVENT_KEY_LANE "IF_LANE" -#define TRANSVR_UEVENT_UNKNOW "UNKNOW" -#define TRANSVR_IF_KR "KR" -#define TRANSVR_IF_KR4 "KR4" -#define TRANSVR_IF_SR "SR" -#define TRANSVR_IF_SR4 "SR4" -#define TRANSVR_IF_SFI "SFI" -#define TRANSVR_IF_IF_GMII "GMII" -#define TRANSVR_IF_IF_XGMII "XGMII" -#define TRANSVR_IF_SP_100 "100" -#define TRANSVR_IF_SP_1G "1000" -#define TRANSVR_IF_SP_10G "10000" -#define TRANSVR_IF_SP_25G "25000" -#define TRANSVR_IF_SP_40G "40000" -#define TRANSVR_IF_SP_100G "100000" - -/* Transceiver mode define */ -#define TRANSVR_MODE_DIRECT (21000) -#define TRANSVR_MODE_POLLING (21001) - -/* Transceiver state define - * [Note] - * 1. State is used to represent the state of "Transceiver" and "Object". - * 2. State for different target has different means. The description as following: - */ -#define STATE_TRANSVR_CONNECTED (0) /* [Transvr]:Be plugged in. [Obj]:Link up, and work normally. */ -#define STATE_TRANSVR_NEW (-100) /* [Transvr]:(Not used) [Obj]:Create */ -#define STATE_TRANSVR_INIT (-101) /* [Transvr]:Be plugged in. [Obj]:Link up, and in initial process. */ -#define STATE_TRANSVR_ISOLATED (-102) /* [Transvr]:Be plugged in. [Obj]:Isolate, and not provide service. */ -#define STATE_TRANSVR_SWAPPED (-200) /* [Transvr]:Be plugged in. [Obj]:(Not used) */ -#define STATE_TRANSVR_DISCONNECTED (-300) /* [Transvr]:Un-plugged. [Obj]:Link down, and not provide service. */ -#define STATE_TRANSVR_UNEXCEPTED (-901) /* [Transvr]:Any [Obj]:Any, and not in expect case. */ - -/* Task state define */ -#define STATE_T_TASK_WAIT (110) -#define STATE_T_TASK_DONE (0) -#define STATE_T_TASK_INIT (-110) -#define STATE_T_TASK_FAIL (-410) - - -/* Event for task handling */ -#define EVENT_TRANSVR_TASK_WAIT (2101) -#define EVENT_TRANSVR_TASK_DONE (0) -#define EVENT_TRANSVR_TASK_FAIL (-2101) -/* Event for initial handling */ -#define EVENT_TRANSVR_INIT_UP (2201) -#define EVENT_TRANSVR_INIT_DOWN (1) -#define EVENT_TRANSVR_INIT_REINIT (-2201) -#define EVENT_TRANSVR_INIT_FAIL (-2202) -/* Event for others */ -#define EVENT_TRANSVR_RELOAD_FAIL (-2301) -#define EVENT_TRANSVR_EXCEP_INIT (-2401) -#define EVENT_TRANSVR_EXCEP_UP (-2402) -#define EVENT_TRANSVR_EXCEP_DOWN (-2403) -#define EVENT_TRANSVR_EXCEP_SWAP (-2404) -#define EVENT_TRANSVR_EXCEP_EXCEP (-2405) -#define EVENT_TRANSVR_EXCEP_ISOLATED (-2406) -#define EVENT_TRANSVR_I2C_CRASH (-2501) - -/* Transceiver error code define */ -#define ERR_TRANSVR_UNINIT (-201) -#define ERR_TRANSVR_UNPLUGGED (-202) -#define ERR_TRANSVR_ABNORMAL (-203) -#define ERR_TRANSVR_NOSTATE (-204) -#define ERR_TRANSVR_NOTSUPPORT (-205) -#define ERR_TRANSVR_BADINPUT (-206) -#define ERR_TRANSVR_UPDATE_FAIL (-207) -#define ERR_TRANSVR_RELOAD_FAIL (-208) -#define ERR_TRANSVR_INIT_FAIL (-209) -#define ERR_TRANSVR_UNDEFINED (-210) -#define ERR_TRANSVR_TASK_FAIL (-211) -#define ERR_TRANSVR_TASK_BUSY (-212) -#define ERR_TRANSVR_UEVENT_FAIL (-213) -#define ERR_TRANSVR_FUNC_DISABLE (-214) -#define ERR_TRANSVR_I2C_CRASH (-297) -#define ERR_TRNASVR_BE_ISOLATED (-298) -#define ERR_TRANSVR_UNEXCPT (-299) - -/* For debug */ -#define DEBUG_TRANSVR_INT_VAL (-99) -#define DEBUG_TRANSVR_HEX_VAL (0xfe) -#define DEBUG_TRANSVR_STR_VAL "ERROR" - -/* For system internal */ -#define VAL_TRANSVR_COMID_ARREESS (0x50) -#define VAL_TRANSVR_COMID_OFFSET (0x00) -#define VAL_TRANSVR_8472_READY_ADDR (0x51) -#define VAL_TRANSVR_8472_READY_PAGE (-1) -#define VAL_TRANSVR_8472_READY_OFFSET (110) -#define VAL_TRANSVR_8472_READY_BIT (0) -#define VAL_TRANSVR_8472_READY_VALUE (0) -#define VAL_TRANSVR_8472_READY_ABNORMAL (0xff) -#define VAL_TRANSVR_8436_READY_ADDR (0x50) -#define VAL_TRANSVR_8436_READY_PAGE (-1) -#define VAL_TRANSVR_8436_READY_OFFSET (2) -#define VAL_TRANSVR_8436_READY_BIT (0) -#define VAL_TRANSVR_8436_READY_VALUE (0) -#define VAL_TRANSVR_8436_READY_ABNORMAL (0xff) -#define VAL_TRANSVR_8436_PWD_ADDR (0x50) -#define VAL_TRANSVR_8436_PWD_PAGE (-1) -#define VAL_TRANSVR_8436_PWD_OFFSET (123) -#define VAL_TRANSVR_PAGE_FREE (-99) -#define VAL_TRANSVR_PAGE_SELECT_OFFSET (127) -#define VAL_TRANSVR_PAGE_SELECT_DELAY (5) -#define VAL_TRANSVR_TASK_RETRY_FOREVER (-999) -#define VAL_TRANSVR_FUNCTION_DISABLE (-1) -#define STR_TRANSVR_SFP "SFP" -#define STR_TRANSVR_QSFP "QSFP" -#define STR_TRANSVR_QSFP_PLUS "QSFP+" -#define STR_TRANSVR_QSFP28 "QSFP28" - -/* For transvr buf len */ -#define LEN_TRANSVR_S_STR (16) -#define LEN_TRANSVR_M_STR (32) -#define LEN_TRANSVR_L_STR (64) - -/* Optical wavelength */ -#define VAL_OPTICAL_WAVELENGTH_SR (850) -#define VAL_OPTICAL_WAVELENGTH_LR (1310) -#define VAL_OPTICAL_WAVELENGTH_ER (1550) - -/* BCM chip type define */ -#define BCM_CHIP_TYPE_TRIDENT_2 (31001) /* Magnolia, Hudson32i, Spruce */ -#define BCM_CHIP_TYPE_TOMAHAWK (31002) /* Redwood, Cypress */ - -/* Info from transceiver EEPROM */ -struct eeprom_map_s { - int addr_br; int page_br; int offset_br; int length_br; - int addr_cdr; int page_cdr; int offset_cdr; int length_cdr; - int addr_comp_rev; int page_comp_rev; int offset_comp_rev; int length_comp_rev; - int addr_connector; int page_connector; int offset_connector; int length_connector; - int addr_diag_type; int page_diag_type; int offset_diag_type; int length_diag_type; - int addr_extbr; int page_extbr; int offset_extbr; int length_extbr; - int addr_ext_id; int page_ext_id; int offset_ext_id; int length_ext_id; - int addr_id; int page_id; int offset_id; int length_id; - int addr_eeprom; int page_eeprom; int offset_eeprom; int length_eeprom; - int addr_len_sm; int page_len_sm; int offset_len_sm; int length_len_sm; - int addr_len_smf; int page_len_smf; int offset_len_smf; int length_len_smf; - int addr_len_om1; int page_len_om1; int offset_len_om1; int length_len_om1; - int addr_len_om2; int page_len_om2; int offset_len_om2; int length_len_om2; - int addr_len_om3; int page_len_om3; int offset_len_om3; int length_len_om3; - int addr_len_om4; int page_len_om4; int offset_len_om4; int length_len_om4; - int addr_option; int page_option; int offset_option; int length_option; - int addr_rate_id; int page_rate_id; int offset_rate_id; int length_rate_id; - int addr_rx_am; int page_rx_am; int offset_rx_am; int length_rx_am; - int addr_rx_em; int page_rx_em; int offset_rx_em; int length_rx_em; - int addr_rx_los; int page_rx_los; int offset_rx_los; int length_rx_los; - int addr_rx_power; int page_rx_power; int offset_rx_power; int length_rx_power; - int addr_soft_rs0; int page_soft_rs0; int offset_soft_rs0; int length_soft_rs0; - int addr_soft_rs1; int page_soft_rs1; int offset_soft_rs1; int length_soft_rs1; - int addr_temp; int page_temp; int offset_temp; int length_temp; - int addr_trancomp; int page_trancomp; int offset_trancomp; int length_trancomp; - int addr_trancomp_ext; int page_trancomp_ext; int offset_trancomp_ext; int length_trancomp_ext; - int addr_tx_bias; int page_tx_bias; int offset_tx_bias; int length_tx_bias; - int addr_tx_disable; int page_tx_disable; int offset_tx_disable; int length_tx_disable; - int addr_tx_eq; int page_tx_eq; int offset_tx_eq; int length_tx_eq; - int addr_tx_fault; int page_tx_fault; int offset_tx_fault; int length_tx_fault; - int addr_tx_power; int page_tx_power; int offset_tx_power; int length_tx_power; - int addr_vendor_name; int page_vendor_name; int offset_vendor_name; int length_vendor_name; - int addr_vendor_pn; int page_vendor_pn; int offset_vendor_pn; int length_vendor_pn; - int addr_vendor_rev; int page_vendor_rev; int offset_vendor_rev; int length_vendor_rev; - int addr_vendor_sn; int page_vendor_sn; int offset_vendor_sn; int length_vendor_sn; - int addr_voltage; int page_voltage; int offset_voltage; int length_voltage; - int addr_wavelength; int page_wavelength; int offset_wavelength; int length_wavelength; -}; - - -struct transvr_worker_s; - -/* Class of transceiver object */ -struct transvr_obj_s { - - /* ========== Object private property ========== - * [Prop]: id - * [Desc]: Type of serial transceiver. - * [Note]: SFP:03h / QSFP:0Ch / QSPF+:0Dh /QSFP28:11h - */ - uint8_t id; - - /* [Prop]: connector - * [Desc]: Connector type. - * [Note]: SFP : A0h / 2 - * QSFP: 00h / 130 - */ - uint8_t connector; - - /* [Prop]: transvr_comp - * [Desc]: Transceiver compliance code. - * [Note]: SFP: SFF-8472 - * - Normal : A0h / offset 3-10 - * - Extended: A0h / offset 36 - * QSFP: SFF-8436 & SFF-8636 - * - Normal : 00h / offset 131-138 - * - Extended: 00h / offset 192 - */ - uint8_t transvr_comp[8]; - uint8_t transvr_comp_ext; - - /* [Prop]: vendor_name - * [Desc]: SFP vendor name (ASCII 16 byte char). - * [Note]: ex:FINISAR CORP. - */ - char *vendor_name; - - /* [Prop]: vendor_pn - * [Desc]: Part number provided by SFP vendor (ASCII 16 byte char). - * [Note]: - */ - char *vendor_pn; - - /* [Prop]: vendor_rev - * [Desc]: Revision level for part number provided by vendor (ASCII 4 byte char). - * [Note]: - */ - char *vendor_rev; - - /* [Prop]: vendor_sn - * [Desc]: Serial number provided by vendor (ASCII 16 byte char). - * [Note]: - */ - char *vendor_sn; - - /* [Prop]: Extended identifier - * [Desc]: SFP: - * => None - * - * QSFP: - * => This byte contained two information: - * (1) Power consumption class - * (2) CDR function present - * [Note]: Bit description as below: - * [SFP] - * None - * - * [QSFP] - * (1) Power consumption class: - * Class 1: 1.5W (Bit6-7 = 00:) - * Class 2: 2.0W (Bit6-7 = 01:) - * Class 3: 2.5W (Bit6-7 = 10:) - * Class 4: 3.5W (Bit6-7 = 11:) - * Class 5: 4.0W (Bit0-1 = 01:) - * Class 6: 4.5W (Bit0-1 = 10:) - * Class 7: 5.0W (Bit0-1 = 11:) - * (2) CDR function present: - * Bit2: 0 = No CDR in RX - * 1 = CDR present in RX - * Bit3: 0 = No CDR in TX - * 1 = CDR present in TX - */ - uint8_t ext_id; - - /* [Prop]: br - * [Desc]: Nominal bit rate, units of 100 MBits/sec. - * [Note]: SFP:03h / QSFP:0Ch / QSPF+:0Dh - * has val: 0x67 - * no val : - */ - uint8_t br; - - /* [Prop]: extbr - * [Desc]: Extended br (00h/222) - * [Desc]: Nominal bit rate per channel, units of 250 Mbps. - * Complements. Byte 140. See Table 32A. - */ - uint8_t extbr; - - /* [Prop]: len_sm - * [Desc]: Length (single mode)-(100's)m - * [Note]: This value specifies the link length that is supported by the transceiver - * while operating in compliance with the applicable standards using single mode - * fiber. The value is in units of 100 meters. A value of 255 means that the - * transceiver supports a link length greater than 25.4 km. A value of zero means - * that the transceiver does not support single mode fiber or that the length - * information must be determined from the transceiver technology. - */ - int len_sm; - - /* [Prop]: len_smf - * [Desc]: Length (single mode)-km - * [Note]: Addition to EEPROM data from original GBIC definition. This value specifies - * the link length that is supported by the transceiver while operating in - * compliance with the applicable standards using single mode fiber. The value - * is in units of kilometers. A value of 255 means that the transceiver supports - * a link length greater than 254 km. A value of zero means that the transceiver - * does not support single mode fiber or that the length information must be - * determined from the transceiver technology. - */ - int len_smf; - - /* [Prop]: len_om1 - * [Desc]: Link length supported for 62.5 um OM1 fiber, units of 10 m - * [Note]: The value is in units of 10 meters. A value of 255 means that the - * transceiver supports a link length greater than 2.54 km. A value of - * zero means that the transceiver does not support 50 micron multi-mode - * fiber or that the length information must be determined from the transceiver - * technology. - */ - int len_om1; - - /* [Prop]: len_om2 - * [Desc]: Link length supported for 50 um OM2 fiber, units of 10 m - * [Note]: The value is in units of 10 meters. A value of 255 means that the - * transceiver supports a link length greater than 2.54 km. A value of - * zero means that the transceiver does not support 50 micron multi-mode - * fiber or that the length information must be determined from the transceiver - * technology. - */ - int len_om2; - - /* [Prop]: len_om3 - * [Desc]: Length (50um, OM3) - * [Note]: This value specifies link length that is supported by the transceiver while - * operating in compliance with applicable standards using 50 micron multimode - * OM3 [2000 MHz*km] fiber. The value is in units of 10 meters. A value of 255 - * means that the transceiver supports a link length greater than 2.54 km. A value - * of zero means that the transceiver does not support 50 micron multimode fiber - * or that the length information must be determined from the transceiver technology. - */ - int len_om3; - - /* [Prop]: len_om4 - * [Desc]: Length (50um, OM4) and Length (Active Cable or Copper) - * [Note]: For optical links, this value specifies link length that is supported by the - * transceiver while operating in compliance with applicable standards using 50 micron - * multimode OM4 [4700 MHz*km] fiber. The value is in units of 10 meters. A value of - * 255 means that the transceiver supports a link length greater than 2.54 km. A value - * of zero means that the transceiver does not support 50 micron multimode fiber or that - * the length information must be determined from the transceiver codes specified in Table 5-3. - * - * For copper links, this value specifies minimum link length supported by the transceiver - * while operating in compliance with applicable standards using copper cable. For active - * cable, this value represents actual length. The value is in units of 1 meter. A value of 255 - * means the transceiver supports a link length greater than 254 meters. A value of zero means - * the transceiver does not support copper or active cables or the length information must be - * determined from transceiver technology. Further information about cable design, equalization, - * and connectors is usually required to guarantee meeting a particular length requirement. - */ - int len_om4; - - /* [Prop]: comp_rev - * [Desc]: SFF spec revision compliance - * [Note]: Indicates which revision of SFF SFF-8472 (SFP) / SFF-8636 (QSFP) the transceiver - * complies with. (unsigned integer) - */ - uint8_t comp_rev; - - /* [Prop]: CDR - * [Desc]: For transceivers with CDR capability, setting the CDR to ON engages the internal - * retiming function. Setting the CDR to OFF enables an internal bypassing mode ,which - * directs traffic around the internal CDR. (Reference: SFF-8636) - * [Note]: value=0xff: ON. - * value=0x00: OFF. - */ - uint8_t cdr; - - /* [Prop]: rate_id - * [Desc]: Soft Rate Select 0(RX). - * [Note]: 1. Addr: A0h / Offset: 13 - * 2. Value description: - * 00h Unspecified - * 01h SFF-8079 (4/2/1G Rate_Select & AS0/AS1) - * 02h SFF-8431 (8/4/2G Rx Rate_Select only) - * 03h Unspecified * - * 04h SFF-8431 (8/4/2G Tx Rate_Select only) - * 05h Unspecified * - * 06h SFF-8431 (8/4/2G Independent Rx & Tx Rate_select) - * 07h Unspecified * - * 08h FC-PI-5 (16/8/4G Rx Rate_select only) High=16G only, Low=8G/4G - * 09h Unspecified * - * 0Ah FC-PI-5 (16/8/4G Independent Rx, Tx Rate_select) High=16G only, - * Low=8G/4G - * 0Bh Unspecified * - * 0Ch FC-PI-6 (32/16/8G Independent Rx, Tx Rate_Select) - * High=32G only, Low = 16G/8G - * 0Dh Unspecified * - * 0Eh 10/8G Rx and Tx Rate_Select controlling the operation or locking - * modes of the internal signal conditioner, retimer or CDR, according - * to the logic table defined in Table 10-2, High Bit Rate - * (10G) =9.95-11.3 Gb/s; Low Bit Rate (8G) = 8.5 Gb/s. In this mode, - * the default value of bit 110.3 (Soft Rate Select RS(0), Table 9-11) - * and of bit 118.3 (Soft Rate Select RS(1), Table 10-1) is 1. - * 0Fh Unspecified * - * 10h-FFh Unallocated - */ - int rate_id; - - /* [Prop]: soft_rs0 - * [Desc]: Soft Rate Select 0(RX). - * [Note]: 1. Writing '1' selects full bandwidth operation. - * 2. This bit is "OR'd with the hard Rate_Select, AS(0) or RS(0) pin value. - * 3. Default at power up is logic zero/low - * 4. Addr: A2h / Offset: 110 / Bit: 3 - */ - uint8_t soft_rs0; - - /* [Prop]: soft_rs1 - * [Desc]: Soft Rate Select 1(TX). - * [Note]: 1. Writing '1' selects full bandwidth TX operation. - * 2. This bit is "OR'd with the hard Rate_Select, AS(1) or RS(1) pin value. - * 3. Default at power up is logic zero/low - * 4. Addr: A2h / Offset: 118 / Bit: 3 - */ - uint8_t soft_rs1; - - /* [Prop]: diag_type - * [Desc]: DIAGNOSTIC MONITORING TYPE (A0h/92) - * [Note]: Description in SFF-8472 as below: - * Bit7: Reserved for legacy diagnostic implementations. Must be '0' for compliance - * with this document. - * Bit6: Digital diagnostic monitoring implemented (described in this document). - * Must be '1' for compliance with this document. - * Bit5 Internally calibrated - * Bit4 Externally calibrated - * Bit3 Received power measurement type.0 = OMA, 1 = average power - * Bit2 Address change required see section above, "addressing modes" - * Bit1-0 Unallocated - */ - uint8_t diag_type; - - /* [Prop]: curr_temp - * [Desc]: Transceiver Current Temperature (A2h/96-97) - * [Note]: 1. Dependent on diag_type. - * 2. 96: High byte - * 3. 97: Low byte - * 4. This feature only for SFP - */ - uint8_t curr_temp[2]; - - /* [Prop]: curr_vol - * [Desc]: Transceiver Current Voltage (SFP:A2h/108-109; QSFP:00h/22-23) - * [Note]: 1. Dependent on diag_type. - * 2. 98: High byte - * 3. 99: Low byte - * 4. This feature only for SFP - * 5. Internally measured transceiver supply voltage. Represented - * as a 16 bit unsigned integer with the voltage defined as the - * full 16 bit value (0-65535) with LSB equal to 100 uVolt, - * yielding a total range of 0 to +6.55 Volts - */ - uint8_t curr_voltage[2]; - - /* [Prop]: curr_tx_bias - * [Desc]: Transceiver TX Bias Current (SFP:A2h/100-101; QSFP:00h/26-27) - * [Note]: 1. Dependent on diag_type. - * 2. 100: High byte - * 3. 101: Low byte - * 4. This feature only for SFP - * 5. Measured TX bias current in uA. Represented as a 16 bit unsigned - * integer with the current defined as the full 16 bit value (0-65535) - * with LSB equal to 2 uA, yielding a total range of 0 to 131 mA. - * Accuracy is vendor specific but must be better than 10% of the - * manufacturer's nominal value over specified operating temperature - * and voltage. - */ - uint8_t curr_tx_bias[8]; - - /* [Prop]: curr_tx_power - * [Desc]: Transceiver TX Output Power (A2h/102-103) - * [Note]: 1. Dependent on diag_type. - * 2. 102: High byte - * 3. 103: Low byte - * 4. This feature only for SFP - * 5. Measured TX output power in mW. Represented as a 16 bit unsigned - * integer with the power defined as the full 16 bit value (0-65535) - * with LSB equal to 0.1 uW, yielding a total range of 0 to 6.5535 mW - * (~ -40 to +8.2 dBm). Data is assumed to be based on measurement of - * laser monitor photodiode current. It is factory calibrated to absolute - * units using the most representative fiber output type. Accuracy is - * vendor specific but must be better than 3dB over specified temperature - * and voltage. Data is not valid when the transmitter is disabled. - */ - uint8_t curr_tx_power[8]; - - /* [Prop]: curr_tx_power - * [Desc]: Transceiver TX Output Power (A2h/102-103) - * [Note]: 1. Dependent on diag_type. - * 2. 102: High byte - * 3. 103: Low byte - * 4. This feature only for SFP - * 5. Measured RX received optical power in mW. Value can represent either - * average received power or OMA depending upon how bit 3 of byte 92 (A0h) - * is set. Represented as a 16 bit unsigned integer with the power defined - * as the full 16 bit value (0-65535) with LSB equal to 0.1 uW, yielding a - * total range of 0 to 6.5535 mW (~ -40 to +8.2 dBm). Absolute accuracy is - * dependent upon the exact optical wavelength. For the vendor specified - * wavelength, accuracy shall be better than 3dB over specified temperature - * and voltage. - */ - uint8_t curr_rx_power[8]; - - /* [Prop]: wavelength - * [Desc]: Wavelength or Copper Cable Attenuation - * [Note]: (Following is info from SFF-8636) - * For optical free side devices, this parameter identifies the nominal - * transmitter output wavelength at room temperature. This parameter is a - * 16-bit hex value with Byte 186 as high order byte and Byte 187 as low - * order byte. The laser wavelength is equal to the 16-bit integer value - * divided by 20 in nm (units of 0.05 nm). This resolution should be adequate - * to cover all relevant wavelengths yet provide enough resolution for all - * expected DWDM applications. For accurate representation of controlled - * wavelength applications, this value should represent the center of the - * guaranteed wavelength range. If the free side device is identified as - * copper cable these registers will be used to define the cable attenuation. - * An indication of 0 dB attenuation refers to the case where the attenuation - * is not known or is unavailable. - * Byte 186 (00-FFh) is the copper cable attenuation at 2.5 GHz in units of 1 dB. - * Byte 187 (00-FFh) is the copper cable attenuation at 5.0 GHz in units of 1 dB. - */ - uint8_t wavelength[2]; - - /* [Prop]: Amplitude control - * [Desc]: Amplitude control - * [Note]: QSFP28 => SFF-8636 03H Byte-238/239 - */ - uint8_t rx_am[2]; - - /* [Prop]: Emphasis control - * [Desc]: Emphasis control - * [Note]: SFP+/28 => SFF-8472 A2H Byte-115 - * QSFP28 => SFF-8636 03H Byte-236/237 - */ - uint8_t rx_em[2]; - - /* [Prop]: Soft Rx LOS - * [Desc]: Soft Rx LOS which provide by transceiver - * [Note]: (Following is info from SFF-8636) - * Byte 3: - * - Bit 0: L-Rx1 LOS - * - Bit 1: L-Rx2 LOS - * - Bit 2: L-Rx3 LOS - * - Bit 3: L-Rx4 LOS - */ - uint8_t rx_los; - - /* [Prop]: Soft Tx Disable - * [Desc]: Soft Tx Disable which provide by transceiver - * [Note]: (Following is info from SFF-8636) - * Byte 86: - * - Bit 0: Tx1 Disable - * - Bit 1: Tx2 Disable - * - Bit 2: Tx3 Disable - * - Bit 3: Tx4 Disable - */ - uint8_t tx_disable; - - /* [Prop]: Soft Tx Fault - * [Desc]: Soft Tx Fault which provide by transceiver - * [Note]: (Following is info from SFF-8636) - * Byte 86: - * - Bit 0: Tx1 Fault - * - Bit 1: Tx2 Fault - * - Bit 2: Tx3 Fault - * - Bit 3: Tx4 Fault - */ - uint8_t tx_fault; - - /* [Prop]: Transceiver EQUALIZATION - * [Desc]: Transceiver EQUALIZATION - * [Note]: SFP+/28 => SFF-8472 A2H Byte-114 - * QSFP28 => SFF-8636 03H Byte-234/235 - */ - uint8_t tx_eq[2]; - - /* [Prop]: OPTION VALUES - * [Desc]: The bits in the option field shall specify the options implemented in the transceiver. - * [Note]: SFP+/28 => SFF-8472 A0H Byte-64/65 - * QSFP+/28 => SFF-8636 00H Byte-193/195 - */ - uint8_t option[3]; - - uint8_t eeprom[256]; - uint8_t eeprom_update[8]; - int port_no; - - /* ========== Object private property ========== - */ - struct device *transvr_dev_p; - struct eeprom_map_s *eeprom_map_p; - struct i2c_client *i2c_client_p; - struct ioexp_obj_s *ioexp_obj_p; - struct transvr_worker_s *worker_p; - struct mutex lock; - char swp_name[32]; - int auto_config; - int auto_tx_disable; - int chan_id; - int chipset_type; - int curr_page; - int info; - int ioexp_virt_offset; - int lane_id[8]; - int layout; - int mode; - int retry; - int state; - int temp; - int type; - - /* ========== Object public functions ========== - */ - int (*get_id)(struct transvr_obj_s *self); - int (*get_eeprom)(struct transvr_obj_s *self, char *buf_p); - int (*get_ext_id)(struct transvr_obj_s *self); - int (*get_connector)(struct transvr_obj_s *self); - int (*get_vendor_name)(struct transvr_obj_s *self, char *buf_p); - int (*get_vendor_pn)(struct transvr_obj_s *self, char *buf_p); - int (*get_vendor_rev)(struct transvr_obj_s *self, char *buf_p); - int (*get_vendor_sn)(struct transvr_obj_s *self, char *buf_p); - int (*get_power_cls)(struct transvr_obj_s *self); - int (*get_br)(struct transvr_obj_s *self); - int (*get_len_sm)(struct transvr_obj_s *self); - int (*get_len_smf)(struct transvr_obj_s *self); - int (*get_len_om1)(struct transvr_obj_s *self); - int (*get_len_om2)(struct transvr_obj_s *self); - int (*get_len_om3)(struct transvr_obj_s *self); - int (*get_len_om4)(struct transvr_obj_s *self); - int (*get_comp_rev)(struct transvr_obj_s *self); - int (*get_comp_eth_1)(struct transvr_obj_s *self); - int (*get_comp_eth_10)(struct transvr_obj_s *self); - int (*get_comp_eth_10_40)(struct transvr_obj_s *self); - int (*get_comp_extend)(struct transvr_obj_s *self); - int (*get_cdr)(struct transvr_obj_s *self); - int (*get_rate_id)(struct transvr_obj_s *self); - int (*get_soft_rs0)(struct transvr_obj_s *self); - int (*get_soft_rs1)(struct transvr_obj_s *self); - int (*get_info)(struct transvr_obj_s *self); - int (*get_if_type)(struct transvr_obj_s *self, char *buf_p); - int (*get_if_speed)(struct transvr_obj_s *self, char *buf_p); - int (*get_if_lane)(struct transvr_obj_s *self, char *buf_p); - int (*get_curr_temp)(struct transvr_obj_s *self, char *buf_p); - int (*get_curr_vol)(struct transvr_obj_s *self, char *buf_p); - int (*get_soft_rx_los)(struct transvr_obj_s *self, char *buf_p); - int (*get_soft_tx_disable)(struct transvr_obj_s *self, char *buf_p); - int (*get_soft_tx_fault)(struct transvr_obj_s *self, char *buf_p); - int (*get_auto_tx_disable)(struct transvr_obj_s *self, char *buf_p); - int (*get_tx_bias)(struct transvr_obj_s *self, char *buf_p); - int (*get_tx_power)(struct transvr_obj_s *self, char *buf_p); - int (*get_rx_power)(struct transvr_obj_s *self, char *buf_p); - int (*get_tx_eq)(struct transvr_obj_s *self, char *buf_p); - int (*get_rx_am)(struct transvr_obj_s *self, char *buf_p); - int (*get_rx_em)(struct transvr_obj_s *self, char *buf_p); - int (*get_wavelength)(struct transvr_obj_s *self, char *buf_p); - int (*set_cdr)(struct transvr_obj_s *self, int input_val); - int (*set_soft_rs0)(struct transvr_obj_s *self, int input_val); - int (*set_soft_rs1)(struct transvr_obj_s *self, int input_val); - int (*set_soft_tx_disable)(struct transvr_obj_s *self, int input_val); - int (*set_auto_tx_disable)(struct transvr_obj_s *self, int input_val); - int (*set_tx_eq)(struct transvr_obj_s *self, int input_val); - int (*set_rx_am)(struct transvr_obj_s *self, int input_val); - int (*set_rx_em)(struct transvr_obj_s *self, int input_val); - - /* ========== Object private functions ========== - */ - int (*init)(struct transvr_obj_s *self); - int (*clean)(struct transvr_obj_s *self); - int (*check)(struct transvr_obj_s *self); - int (*update_all)(struct transvr_obj_s *self, int show_err); - int (*fsm_4_direct)(struct transvr_obj_s* self, char *caller_name); - int (*fsm_4_polling)(struct transvr_obj_s* self, char *caller_name); - int (*send_uevent)(struct transvr_obj_s* self, enum kobject_action u_action); - int (*dump_all)(struct transvr_obj_s* self); -}; - - -/* For AVL Mapping */ -struct transvr_avl_s { - char vendor_name[32]; - char vendor_pn[32]; - int (*init)(struct transvr_obj_s *self); -}; - - -/* Worker for long term task of transceiver */ -struct transvr_worker_s { - /* Task Parameter */ - struct transvr_obj_s *transvr_p; - struct transvr_worker_s *next_p; - struct transvr_worker_s *pre_p; - unsigned long trigger_time; - char func_name[64]; - int retry; - int state; - - /* Task private data */ - void *p_data; - - /* Call back function */ - int (*main_task)(struct transvr_worker_s *task); - int (*post_task)(struct transvr_worker_s *task); -}; - - -struct transvr_obj_s * -create_transvr_obj(char *swp_name, - int chan_id, - struct ioexp_obj_s *ioexp_obj_p, - int ioexp_virt_offset, - int transvr_type, - int chipset_type, - int run_mode); - -void lock_transvr_obj(struct transvr_obj_s *self); -void unlock_transvr_obj(struct transvr_obj_s *self); -int isolate_transvr_obj(struct transvr_obj_s *self); - -int resync_channel_tier_2(struct transvr_obj_s *self); - -void alarm_msg_2_user(struct transvr_obj_s *self, char *emsg); - -unsigned char *get_eeprom_update(void); -void set_eeprom_update(unsigned char value[8]); - -#endif /* TRANSCEIVER_H */ diff --git a/packages/platforms/inventec/x86-64/d7264q28b/onlp/Makefile b/packages/platforms/inventec/x86-64/d7264q28b/onlp/Makefile deleted file mode 100644 index 003238cf6..000000000 --- a/packages/platforms/inventec/x86-64/d7264q28b/onlp/Makefile +++ /dev/null @@ -1 +0,0 @@ -include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/inventec/x86-64/d7264q28b/onlp/PKG.yml b/packages/platforms/inventec/x86-64/d7264q28b/onlp/PKG.yml deleted file mode 100644 index 99e7eb219..000000000 --- a/packages/platforms/inventec/x86-64/d7264q28b/onlp/PKG.yml +++ /dev/null @@ -1 +0,0 @@ -!include $ONL_TEMPLATES/onlp-platform-any.yml PLATFORM=x86-64-inventec-d7264q28b ARCH=amd64 TOOLCHAIN=x86_64-linux-gnu diff --git a/packages/platforms/inventec/x86-64/d7264q28b/onlp/builds/Makefile b/packages/platforms/inventec/x86-64/d7264q28b/onlp/builds/Makefile deleted file mode 100644 index e7437cb23..000000000 --- a/packages/platforms/inventec/x86-64/d7264q28b/onlp/builds/Makefile +++ /dev/null @@ -1,2 +0,0 @@ -FILTER=src -include $(ONL)/make/subdirs.mk diff --git a/packages/platforms/inventec/x86-64/d7264q28b/onlp/builds/lib/Makefile b/packages/platforms/inventec/x86-64/d7264q28b/onlp/builds/lib/Makefile deleted file mode 100644 index 8156532b7..000000000 --- a/packages/platforms/inventec/x86-64/d7264q28b/onlp/builds/lib/Makefile +++ /dev/null @@ -1,2 +0,0 @@ -PLATFORM := x86-64-inventec-d7264q28b -include $(ONL)/packages/base/any/onlp/builds/platform/libonlp-platform.mk diff --git a/packages/platforms/inventec/x86-64/d7264q28b/onlp/builds/onlpdump/Makefile b/packages/platforms/inventec/x86-64/d7264q28b/onlp/builds/onlpdump/Makefile deleted file mode 100644 index 4c7c2075c..000000000 --- a/packages/platforms/inventec/x86-64/d7264q28b/onlp/builds/onlpdump/Makefile +++ /dev/null @@ -1,2 +0,0 @@ -PLATFORM := x86-64-inventec-d7264q28b -include $(ONL)/packages/base/any/onlp/builds/platform/onlps.mk diff --git a/packages/platforms/inventec/x86-64/d7264q28b/onlp/builds/x86_64_inventec_d7264q28b/.module b/packages/platforms/inventec/x86-64/d7264q28b/onlp/builds/x86_64_inventec_d7264q28b/.module deleted file mode 100644 index b69384705..000000000 --- a/packages/platforms/inventec/x86-64/d7264q28b/onlp/builds/x86_64_inventec_d7264q28b/.module +++ /dev/null @@ -1 +0,0 @@ -name: x86_64_inventec_d7264q28b diff --git a/packages/platforms/inventec/x86-64/d7264q28b/onlp/builds/x86_64_inventec_d7264q28b/Makefile b/packages/platforms/inventec/x86-64/d7264q28b/onlp/builds/x86_64_inventec_d7264q28b/Makefile deleted file mode 100644 index 0948d4de2..000000000 --- a/packages/platforms/inventec/x86-64/d7264q28b/onlp/builds/x86_64_inventec_d7264q28b/Makefile +++ /dev/null @@ -1,9 +0,0 @@ -############################################################################### -# -# -# -############################################################################### -include $(ONL)/make/config.mk -MODULE := x86_64_inventec_d7264q28b -AUTOMODULE := x86_64_inventec_d7264q28b -include $(BUILDER)/definemodule.mk diff --git a/packages/platforms/inventec/x86-64/d7264q28b/onlp/builds/x86_64_inventec_d7264q28b/module/auto/make.mk b/packages/platforms/inventec/x86-64/d7264q28b/onlp/builds/x86_64_inventec_d7264q28b/module/auto/make.mk deleted file mode 100644 index 89b553699..000000000 --- a/packages/platforms/inventec/x86-64/d7264q28b/onlp/builds/x86_64_inventec_d7264q28b/module/auto/make.mk +++ /dev/null @@ -1,9 +0,0 @@ -############################################################################### -# -# x86_64_inventec_d7264q28b Autogeneration -# -############################################################################### -x86_64_inventec_d7264q28b_AUTO_DEFS := module/auto/x86_64_inventec_d7264q28b.yml -x86_64_inventec_d7264q28b_AUTO_DIRS := module/inc/x86_64_inventec_d7264q28b module/src -include $(BUILDER)/auto.mk - diff --git a/packages/platforms/inventec/x86-64/d7264q28b/onlp/builds/x86_64_inventec_d7264q28b/module/auto/x86_64_inventec_d7264q28b.yml b/packages/platforms/inventec/x86-64/d7264q28b/onlp/builds/x86_64_inventec_d7264q28b/module/auto/x86_64_inventec_d7264q28b.yml deleted file mode 100644 index 1a8724490..000000000 --- a/packages/platforms/inventec/x86-64/d7264q28b/onlp/builds/x86_64_inventec_d7264q28b/module/auto/x86_64_inventec_d7264q28b.yml +++ /dev/null @@ -1,50 +0,0 @@ -############################################################################### -# -# x86_64_inventec_d7264q28b Autogeneration Definitions. -# -############################################################################### - -cdefs: &cdefs -- X86_64_INVENTEC_D7264Q28B_CONFIG_INCLUDE_LOGGING: - doc: "Include or exclude logging." - default: 1 -- X86_64_INVENTEC_D7264Q28B_CONFIG_LOG_OPTIONS_DEFAULT: - doc: "Default enabled log options." - default: AIM_LOG_OPTIONS_DEFAULT -- X86_64_INVENTEC_D7264Q28B_CONFIG_LOG_BITS_DEFAULT: - doc: "Default enabled log bits." - default: AIM_LOG_BITS_DEFAULT -- X86_64_INVENTEC_D7264Q28B_CONFIG_LOG_CUSTOM_BITS_DEFAULT: - doc: "Default enabled custom log bits." - default: 0 -- X86_64_INVENTEC_D7264Q28B_CONFIG_PORTING_STDLIB: - doc: "Default all porting macros to use the C standard libraries." - default: 1 -- X86_64_INVENTEC_D7264Q28B_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS: - doc: "Include standard library headers for stdlib porting macros." - default: X86_64_INVENTEC_D7264Q28B_CONFIG_PORTING_STDLIB -- X86_64_INVENTEC_D7264Q28B_CONFIG_INCLUDE_UCLI: - doc: "Include generic uCli support." - default: 0 -- X86_64_INVENTEC_D7264Q28B_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_D7264Q28B_CONFIG_HEADER: - defs: *cdefs - basename: x86_64_inventec_d7264q28b_config - - portingmacro: - X86_64_INVENTEC_D7264Q28B: - macros: - - malloc - - free - - memset - - memcpy - - - vsnprintf - - snprintf - - strlen diff --git a/packages/platforms/inventec/x86-64/d7264q28b/onlp/builds/x86_64_inventec_d7264q28b/module/inc/x86_64_inventec_d7264q28b/x86_64_inventec_d7264q28b.x b/packages/platforms/inventec/x86-64/d7264q28b/onlp/builds/x86_64_inventec_d7264q28b/module/inc/x86_64_inventec_d7264q28b/x86_64_inventec_d7264q28b.x deleted file mode 100644 index 09dac21ca..000000000 --- a/packages/platforms/inventec/x86-64/d7264q28b/onlp/builds/x86_64_inventec_d7264q28b/module/inc/x86_64_inventec_d7264q28b/x86_64_inventec_d7264q28b.x +++ /dev/null @@ -1,14 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#include - -/* <--auto.start.xmacro(ALL).define> */ -/* */ - -/* <--auto.start.xenum(ALL).define> */ -/* */ - - diff --git a/packages/platforms/inventec/x86-64/d7264q28b/onlp/builds/x86_64_inventec_d7264q28b/module/inc/x86_64_inventec_d7264q28b/x86_64_inventec_d7264q28b_config.h b/packages/platforms/inventec/x86-64/d7264q28b/onlp/builds/x86_64_inventec_d7264q28b/module/inc/x86_64_inventec_d7264q28b/x86_64_inventec_d7264q28b_config.h deleted file mode 100644 index 563bf2401..000000000 --- a/packages/platforms/inventec/x86-64/d7264q28b/onlp/builds/x86_64_inventec_d7264q28b/module/inc/x86_64_inventec_d7264q28b/x86_64_inventec_d7264q28b_config.h +++ /dev/null @@ -1,137 +0,0 @@ -/**************************************************************************//** - * - * @file - * @brief x86_64_inventec_d7264q28b Configuration Header - * - * @addtogroup x86_64_inventec_d7264q28b-config - * @{ - * - *****************************************************************************/ -#ifndef __x86_64_inventec_d7264q28b_CONFIG_H__ -#define __x86_64_inventec_d7264q28b_CONFIG_H__ - -#ifdef GLOBAL_INCLUDE_CUSTOM_CONFIG -#include -#endif -#ifdef x86_64_inventec_d7264q28b_INCLUDE_CUSTOM_CONFIG -#include -#endif - -/* */ -#include -/** - * X86_64_INVENTEC_D7264Q28B_CONFIG_INCLUDE_LOGGING - * - * Include or exclude logging. */ - - -#ifndef X86_64_INVENTEC_D7264Q28B_CONFIG_INCLUDE_LOGGING -#define X86_64_INVENTEC_D7264Q28B_CONFIG_INCLUDE_LOGGING 1 -#endif - -/** - * X86_64_INVENTEC_D7264Q28B_CONFIG_LOG_OPTIONS_DEFAULT - * - * Default enabled log options. */ - - -#ifndef X86_64_INVENTEC_D7264Q28B_CONFIG_LOG_OPTIONS_DEFAULT -#define X86_64_INVENTEC_D7264Q28B_CONFIG_LOG_OPTIONS_DEFAULT AIM_LOG_OPTIONS_DEFAULT -#endif - -/** - * X86_64_INVENTEC_D7264Q28B_CONFIG_LOG_BITS_DEFAULT - * - * Default enabled log bits. */ - - -#ifndef X86_64_INVENTEC_D7264Q28B_CONFIG_LOG_BITS_DEFAULT -#define X86_64_INVENTEC_D7264Q28B_CONFIG_LOG_BITS_DEFAULT AIM_LOG_BITS_DEFAULT -#endif - -/** - * X86_64_INVENTEC_D7264Q28B_CONFIG_LOG_CUSTOM_BITS_DEFAULT - * - * Default enabled custom log bits. */ - - -#ifndef X86_64_INVENTEC_D7264Q28B_CONFIG_LOG_CUSTOM_BITS_DEFAULT -#define X86_64_INVENTEC_D7264Q28B_CONFIG_LOG_CUSTOM_BITS_DEFAULT 0 -#endif - -/** - * X86_64_INVENTEC_D7264Q28B_CONFIG_PORTING_STDLIB - * - * Default all porting macros to use the C standard libraries. */ - - -#ifndef X86_64_INVENTEC_D7264Q28B_CONFIG_PORTING_STDLIB -#define X86_64_INVENTEC_D7264Q28B_CONFIG_PORTING_STDLIB 1 -#endif - -/** - * X86_64_INVENTEC_D7264Q28B_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS - * - * Include standard library headers for stdlib porting macros. */ - - -#ifndef X86_64_INVENTEC_D7264Q28B_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS -#define X86_64_INVENTEC_D7264Q28B_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS X86_64_INVENTEC_D7264Q28B_CONFIG_PORTING_STDLIB -#endif - -/** - * X86_64_INVENTEC_D7264Q28B_CONFIG_INCLUDE_UCLI - * - * Include generic uCli support. */ - - -#ifndef X86_64_INVENTEC_D7264Q28B_CONFIG_INCLUDE_UCLI -#define X86_64_INVENTEC_D7264Q28B_CONFIG_INCLUDE_UCLI 0 -#endif - -/** - * X86_64_INVENTEC_D7264Q28B_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION - * - * Assume chassis fan direction is the same as the PSU fan direction. */ - - -#ifndef X86_64_INVENTEC_D7264Q28B_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION -#define X86_64_INVENTEC_D7264Q28B_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION 0 -#endif - - - -/** - * All compile time options can be queried or displayed - */ - -/** Configuration settings structure. */ -typedef struct x86_64_inventec_d7264q28b_config_settings_s { - /** name */ - const char* name; - /** value */ - const char* value; -} x86_64_inventec_d7264q28b_config_settings_t; - -/** Configuration settings table. */ -/** x86_64_inventec_d7264q28b_config_settings table. */ -extern x86_64_inventec_d7264q28b_config_settings_t x86_64_inventec_d7264q28b_config_settings[]; - -/** - * @brief Lookup a configuration setting. - * @param setting The name of the configuration option to lookup. - */ -const char* x86_64_inventec_d7264q28b_config_lookup(const char* setting); - -/** - * @brief Show the compile-time configuration. - * @param pvs The output stream. - */ -int x86_64_inventec_d7264q28b_config_show(struct aim_pvs_s* pvs); - -/* */ - -#include "x86_64_inventec_d7264q28b_porting.h" - -#endif /* __x86_64_inventec_d7264q28b_CONFIG_H__ */ -/* @} */ diff --git a/packages/platforms/inventec/x86-64/d7264q28b/onlp/builds/x86_64_inventec_d7264q28b/module/inc/x86_64_inventec_d7264q28b/x86_64_inventec_d7264q28b_dox.h b/packages/platforms/inventec/x86-64/d7264q28b/onlp/builds/x86_64_inventec_d7264q28b/module/inc/x86_64_inventec_d7264q28b/x86_64_inventec_d7264q28b_dox.h deleted file mode 100644 index fdeb9989b..000000000 --- a/packages/platforms/inventec/x86-64/d7264q28b/onlp/builds/x86_64_inventec_d7264q28b/module/inc/x86_64_inventec_d7264q28b/x86_64_inventec_d7264q28b_dox.h +++ /dev/null @@ -1,26 +0,0 @@ -/**************************************************************************//** - * - * x86_64_inventec_d7264q28b Doxygen Header - * - *****************************************************************************/ -#ifndef __x86_64_inventec_d7264q28b_DOX_H__ -#define __x86_64_inventec_d7264q28b_DOX_H__ - -/** - * @defgroup x86_64_inventec_d7264q28b x86_64_inventec_d7264q28b - x86_64_inventec_d7264q28b Description - * - -The documentation overview for this module should go here. - - * - * @{ - * - * @defgroup x86_64_inventec_d7264q28b-x86_64_inventec_d7264q28b Public Interface - * @defgroup x86_64_inventec_d7264q28b-config Compile Time Configuration - * @defgroup x86_64_inventec_d7264q28b-porting Porting Macros - * - * @} - * - */ - -#endif /* __x86_64_inventec_d7264q28b_DOX_H__ */ diff --git a/packages/platforms/inventec/x86-64/d7264q28b/onlp/builds/x86_64_inventec_d7264q28b/module/inc/x86_64_inventec_d7264q28b/x86_64_inventec_d7264q28b_porting.h b/packages/platforms/inventec/x86-64/d7264q28b/onlp/builds/x86_64_inventec_d7264q28b/module/inc/x86_64_inventec_d7264q28b/x86_64_inventec_d7264q28b_porting.h deleted file mode 100644 index 19ad60918..000000000 --- a/packages/platforms/inventec/x86-64/d7264q28b/onlp/builds/x86_64_inventec_d7264q28b/module/inc/x86_64_inventec_d7264q28b/x86_64_inventec_d7264q28b_porting.h +++ /dev/null @@ -1,97 +0,0 @@ -/**************************************************************************//** - * - * @file - * @brief x86_64_inventec_d7264q28b Porting Macros. - * - * @addtogroup x86_64_inventec_d7264q28b-porting - * @{ - * - *****************************************************************************/ -#ifndef __x86_64_inventec_d7264q28b_PORTING_H__ -#define __x86_64_inventec_d7264q28b_PORTING_H__ - - -/* */ -#if X86_64_INVENTEC_D7264Q28B_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS == 1 -#include -#include -#include -#include -#include -#endif - -#ifndef X86_64_INVENTEC_D7264Q28B_MALLOC - #if defined(GLOBAL_MALLOC) - #define X86_64_INVENTEC_D7264Q28B_MALLOC GLOBAL_MALLOC - #elif X86_64_INVENTEC_D7264Q28B_CONFIG_PORTING_STDLIB == 1 - #define X86_64_INVENTEC_D7264Q28B_MALLOC malloc - #else - #error The macro X86_64_INVENTEC_D7264Q28B_MALLOC is required but cannot be defined. - #endif -#endif - -#ifndef X86_64_INVENTEC_D7264Q28B_FREE - #if defined(GLOBAL_FREE) - #define X86_64_INVENTEC_D7264Q28B_FREE GLOBAL_FREE - #elif X86_64_INVENTEC_D7264Q28B_CONFIG_PORTING_STDLIB == 1 - #define X86_64_INVENTEC_D7264Q28B_FREE free - #else - #error The macro X86_64_INVENTEC_D7264Q28B_FREE is required but cannot be defined. - #endif -#endif - -#ifndef X86_64_INVENTEC_D7264Q28B_MEMSET - #if defined(GLOBAL_MEMSET) - #define X86_64_INVENTEC_D7264Q28B_MEMSET GLOBAL_MEMSET - #elif X86_64_INVENTEC_D7264Q28B_CONFIG_PORTING_STDLIB == 1 - #define X86_64_INVENTEC_D7264Q28B_MEMSET memset - #else - #error The macro X86_64_INVENTEC_D7264Q28B_MEMSET is required but cannot be defined. - #endif -#endif - -#ifndef X86_64_INVENTEC_D7264Q28B_MEMCPY - #if defined(GLOBAL_MEMCPY) - #define X86_64_INVENTEC_D7264Q28B_MEMCPY GLOBAL_MEMCPY - #elif X86_64_INVENTEC_D7264Q28B_CONFIG_PORTING_STDLIB == 1 - #define X86_64_INVENTEC_D7264Q28B_MEMCPY memcpy - #else - #error The macro X86_64_INVENTEC_D7264Q28B_MEMCPY is required but cannot be defined. - #endif -#endif - -#ifndef X86_64_INVENTEC_D7264Q28B_VSNPRINTF - #if defined(GLOBAL_VSNPRINTF) - #define X86_64_INVENTEC_D7264Q28B_VSNPRINTF GLOBAL_VSNPRINTF - #elif X86_64_INVENTEC_D7264Q28B_CONFIG_PORTING_STDLIB == 1 - #define X86_64_INVENTEC_D7264Q28B_VSNPRINTF vsnprintf - #else - #error The macro X86_64_INVENTEC_D7264Q28B_VSNPRINTF is required but cannot be defined. - #endif -#endif - -#ifndef X86_64_INVENTEC_D7264Q28B_SNPRINTF - #if defined(GLOBAL_SNPRINTF) - #define X86_64_INVENTEC_D7264Q28B_SNPRINTF GLOBAL_SNPRINTF - #elif X86_64_INVENTEC_D7264Q28B_CONFIG_PORTING_STDLIB == 1 - #define X86_64_INVENTEC_D7264Q28B_SNPRINTF snprintf - #else - #error The macro X86_64_INVENTEC_D7264Q28B_SNPRINTF is required but cannot be defined. - #endif -#endif - -#ifndef X86_64_INVENTEC_D7264Q28B_STRLEN - #if defined(GLOBAL_STRLEN) - #define X86_64_INVENTEC_D7264Q28B_STRLEN GLOBAL_STRLEN - #elif X86_64_INVENTEC_D7264Q28B_CONFIG_PORTING_STDLIB == 1 - #define X86_64_INVENTEC_D7264Q28B_STRLEN strlen - #else - #error The macro X86_64_INVENTEC_D7264Q28B_STRLEN is required but cannot be defined. - #endif -#endif - -/* */ - - -#endif /* __x86_64_inventec_d7264q28b_PORTING_H__ */ -/* @} */ diff --git a/packages/platforms/inventec/x86-64/d7264q28b/onlp/builds/x86_64_inventec_d7264q28b/module/make.mk b/packages/platforms/inventec/x86-64/d7264q28b/onlp/builds/x86_64_inventec_d7264q28b/module/make.mk deleted file mode 100644 index 76c9f0352..000000000 --- a/packages/platforms/inventec/x86-64/d7264q28b/onlp/builds/x86_64_inventec_d7264q28b/module/make.mk +++ /dev/null @@ -1,10 +0,0 @@ -############################################################################### -# -# -# -############################################################################### -THIS_DIR := $(dir $(lastword $(MAKEFILE_LIST))) -x86_64_inventec_d7264q28b_INCLUDES := -I $(THIS_DIR)inc -x86_64_inventec_d7264q28b_INTERNAL_INCLUDES := -I $(THIS_DIR)src -x86_64_inventec_d7264q28b_DEPENDMODULE_ENTRIES := init:x86_64_inventec_d7264q28b ucli:x86_64_inventec_d7264q28b - diff --git a/packages/platforms/inventec/x86-64/d7264q28b/onlp/builds/x86_64_inventec_d7264q28b/module/src/Makefile b/packages/platforms/inventec/x86-64/d7264q28b/onlp/builds/x86_64_inventec_d7264q28b/module/src/Makefile deleted file mode 100644 index 03165b914..000000000 --- a/packages/platforms/inventec/x86-64/d7264q28b/onlp/builds/x86_64_inventec_d7264q28b/module/src/Makefile +++ /dev/null @@ -1,9 +0,0 @@ -############################################################################### -# -# Local source generation targets. -# -############################################################################### - -ucli: - @../../../../tools/uclihandlers.py x86_64_inventec_d7264q28b_ucli.c - diff --git a/packages/platforms/inventec/x86-64/d7264q28b/onlp/builds/x86_64_inventec_d7264q28b/module/src/debug.c b/packages/platforms/inventec/x86-64/d7264q28b/onlp/builds/x86_64_inventec_d7264q28b/module/src/debug.c deleted file mode 100644 index e34cb3b50..000000000 --- a/packages/platforms/inventec/x86-64/d7264q28b/onlp/builds/x86_64_inventec_d7264q28b/module/src/debug.c +++ /dev/null @@ -1,45 +0,0 @@ -#include "x86_64_inventec_d7264q28b_int.h" - -#if x86_64_inventec_d7264q28b_CONFIG_INCLUDE_DEBUG == 1 - -#include - -static char help__[] = - "Usage: debug [options]\n" - " -c CPLD Versions\n" - " -h Help\n" - ; - -int -x86_64_inventec_d7264q28b_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/d7264q28b/onlp/builds/x86_64_inventec_d7264q28b/module/src/fani.c b/packages/platforms/inventec/x86-64/d7264q28b/onlp/builds/x86_64_inventec_d7264q28b/module/src/fani.c deleted file mode 100644 index 808153a2e..000000000 --- a/packages/platforms/inventec/x86-64/d7264q28b/onlp/builds/x86_64_inventec_d7264q28b/module/src/fani.c +++ /dev/null @@ -1,269 +0,0 @@ -/************************************************************ - * fani.c - * - * Copyright 2018 Inventec Technology Corporation. - * - ************************************************************ - * - * Fan Platform Implementation Defaults. - * - ***********************************************************/ -#include -#include -#include -#include -#include -#include "platform_lib.h" - -#define FAN_GPI_ON_MAIN_BOARD INV_PSOC_PREFIX"/fan_gpi" - -#define MAX_FAN_SPEED 18000 -#define MAX_PSU_FAN_SPEED 25500 - -#define PROJECT_NAME -#define LEN_FILE_NAME 80 - -static char* devfiles__[FAN_MAX] = /* must map with onlp_thermal_id */ -{ - "reserved", - INV_PSOC_PREFIX"/fan1_input", - INV_PSOC_PREFIX"/fan2_input", - INV_PSOC_PREFIX"/fan3_input", - INV_PSOC_PREFIX"/fan4_input", - INV_PSOC_PREFIX"/fan5_input", - INV_PSOC_PREFIX"/fan6_input", - INV_PSOC_PREFIX"/fan7_input", - INV_PSOC_PREFIX"/fan8_input", - INV_PSOC_PREFIX"/rpm_psu1", - INV_PSOC_PREFIX"/rpm_psu2", -}; - -#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_F2B | 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_F2B | ONLP_FAN_CAPS_GET_RPM | ONLP_FAN_CAPS_GET_PERCENTAGE), \ - 0, \ - 0, \ - ONLP_FAN_MODE_INVALID, \ - } - -/* Static fan information */ -onlp_fan_info_t linfo[FAN_MAX] = { - { }, /* 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_MAIN_BOARD(7), - MAKE_FAN_INFO_NODE_ON_MAIN_BOARD(8), - 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, FAN_GPI_ON_MAIN_BOARD); - if (ret < 0) { - return ONLP_STATUS_E_INTERNAL; - } - if (value & (1 << (fid-1))) { - info->status |= ONLP_FAN_STATUS_FAILED; - } - else { - info->status |= ONLP_FAN_STATUS_PRESENT; - info->status |= ONLP_FAN_STATUS_F2B; - } - - /* get front fan speed */ - ret = onlp_file_read_int(&value, devfiles__[fid]); - if (ret < 0) { - return ONLP_STATUS_E_INTERNAL; - } - info->rpm = value; - info->percentage = (info->rpm * 100) / MAX_PSU_FAN_SPEED; - - snprintf(info->model, ONLP_CONFIG_INFO_STR_MAX, "NA"); - snprintf(info->serial, ONLP_CONFIG_INFO_STR_MAX, "NA"); - - 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 fid, onlp_fan_info_t* info) -{ - int value, ret, index; - - info->status |= ONLP_FAN_STATUS_PRESENT; - info->status |= ONLP_FAN_STATUS_F2B; - - /* get fan direction */ - info->status |= _onlp_get_fan_direction_on_psu(); - - if (info->status & ONLP_FAN_STATUS_FAILED) { - return ONLP_STATUS_OK; - } - - index = ONLP_OID_ID_GET(info->hdr.id); - info->hdr.coids[0] = ONLP_FAN_ID_CREATE(index + CHASSIS_FAN_COUNT); - - /* get front fan speed */ - ret = onlp_file_read_int(&value, devfiles__[fid]); - if (ret < 0) { - return ONLP_STATUS_E_INTERNAL; - } - info->rpm = value; - info->percentage = (info->rpm * 100) / MAX_PSU_FAN_SPEED; - info->status |= (value == 0) ? ONLP_FAN_STATUS_FAILED : 0; - - snprintf(info->model, ONLP_CONFIG_INFO_STR_MAX, "NA"); - snprintf(info->serial, ONLP_CONFIG_INFO_STR_MAX, "NA"); - - 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: - 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 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_PSU1: - return psu_pmbus_info_set(PSU1_ID, "rpm_psu1", p); - case FAN_1_ON_PSU2: - return psu_pmbus_info_set(PSU2_ID, "rpm_psu2", p); - 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: - 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/d7264q28b/onlp/builds/x86_64_inventec_d7264q28b/module/src/ledi.c b/packages/platforms/inventec/x86-64/d7264q28b/onlp/builds/x86_64_inventec_d7264q28b/module/src/ledi.c deleted file mode 100644 index 43deec3fb..000000000 --- a/packages/platforms/inventec/x86-64/d7264q28b/onlp/builds/x86_64_inventec_d7264q28b/module/src/ledi.c +++ /dev/null @@ -1,426 +0,0 @@ -/************************************************************ - * ledi.c - * - * Copyright 2018 Inventec Technology Corporation. - * - ************************************************************ - * - ***********************************************************/ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "platform_lib.h" - -#define filename "brightness" - -#define VALIDATE(_id) \ - do { \ - if(!ONLP_OID_IS_LED(_id)) { \ - return ONLP_STATUS_E_INVALID; \ - } \ - } while(0) - -static char* devfiles__[LED_MAX] = /* must map with onlp_thermal_id */ -{ - "reserved", - INV_CPLD_PREFIX"/%s_led", - INV_PSOC_PREFIX"/fan_led_%s1", - INV_PSOC_PREFIX"/fan_led_%s2", - INV_PSOC_PREFIX"/fan_led_%s3", - INV_PSOC_PREFIX"/fan_led_%s4", -}; - -/* - * Get the information for the given LED OID. - */ -static onlp_led_info_t linfo[LED_MAX] = -{ - { }, /* Not used */ - { - { ONLP_LED_ID_CREATE(LED_SYS), "Chassis LED (SYSTEM 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_MODE_ON, '0', - }, - { - { ONLP_LED_ID_CREATE(LED_FAN1), "Fan LED 1 (FAN1 LED)", 0 }, - ONLP_LED_STATUS_PRESENT, - ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_RED, - ONLP_LED_MODE_ON, '0', - }, - { - { ONLP_LED_ID_CREATE(LED_FAN2), "Fan LED 2 (FAN2 LED)", 0 }, - ONLP_LED_STATUS_PRESENT, - ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_RED, - ONLP_LED_MODE_ON, '0', - }, - { - { ONLP_LED_ID_CREATE(LED_FAN3), "Fan LED 3 (FAN3 LED)", 0 }, - ONLP_LED_STATUS_PRESENT, - ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_RED, - ONLP_LED_MODE_ON, '0', - }, - { - { ONLP_LED_ID_CREATE(LED_FAN4), "Fan LED 4 (FAN4 LED)", 0 }, - ONLP_LED_STATUS_PRESENT, - ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_RED, - ONLP_LED_MODE_ON, '0', - }, -}; - -/* - * This function will be called prior to any other onlp_ledi_* functions. - */ -static pthread_mutex_t diag_mutex; - -int -onlp_ledi_init(void) -{ - pthread_mutex_init(&diag_mutex, NULL); - - /* - * Diag LED Off - */ - onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_SYS), ONLP_LED_MODE_OFF); - - return ONLP_STATUS_OK; -} - -int onlp_chassis_led_read(char *pathp, char *buf, size_t len) -{ - FILE * fp; - - fp = fopen (pathp, "r"); - if(fp == NULL) { - perror("Error opening file"); - return(-1); - } - if( fgets (buf, len, fp) == NULL ) { - perror("Error fgets operation"); - } - fclose(fp); - - return(0); -} - -int onlp_chassis_led_write(char *pathp, char *buf) -{ - FILE * fp; - - fp = fopen (pathp, "w"); - if(fp == NULL) { - perror("Error opening file"); - return(-1); - } - if( fputs (buf, fp) == 0 ) { - perror("Error fputs operation"); - } - fclose(fp); - - return(0); -} - -int -onlp_ledi_info_get(onlp_oid_t id, onlp_led_info_t* info) -{ - int local_id, gret = 0, rret = 0; - char fullpath_grn[50] = {0}; - char fullpath_red[50] = {0}; - int gvalue = 0, rvalue = 0; - char gbuf[32] = {0}; - char rbuf[32] = {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 fullpath */ - switch (local_id) { - case LED_SYS: - sprintf(fullpath_grn, devfiles__[local_id], "grn"); - sprintf(fullpath_red, devfiles__[local_id], "red"); - - /* Set LED mode */ - gret = onlp_chassis_led_read(fullpath_grn, gbuf, 32); - rret = onlp_chassis_led_read(fullpath_red, rbuf, 32); - if (gret < 0 || rret < 0) { - DEBUG_PRINT("%s(%d): gret = %d, rret = %d\r\n", __FUNCTION__, __LINE__, gret, rret); - info->mode = ONLP_LED_MODE_OFF; - info->status = ONLP_LED_STATUS_FAILED; - break; - } - - info->status = ONLP_LED_STATUS_PRESENT; - if (gbuf[0] >= '1' && gbuf[0] <= '7' && rbuf[0] == '0') { - info->mode = ONLP_LED_MODE_GREEN; - info->status |= ONLP_LED_STATUS_ON; - } - else - if (rbuf[0] >= '1' && rbuf[0] <= '7' && gbuf[0] == '0') { - info->mode = ONLP_LED_MODE_RED; - info->status |= ONLP_LED_STATUS_ON; - } - else - if (gbuf[0] >= '1' && gbuf[0] <= '7' && rbuf[0] >= '1' && rbuf[0] <= '7') { - info->mode = ONLP_LED_MODE_ORANGE; - info->status |= ONLP_LED_STATUS_ON; - } - else - if (gbuf[0] == '0' && rbuf[0] == '0') { - info->mode = ONLP_LED_MODE_OFF; - info->status |= ONLP_LED_STATUS_ON; - } - else { - info->mode = ONLP_LED_MODE_OFF; - info->status = ONLP_LED_STATUS_FAILED; - } - break; - case LED_FAN1: - case LED_FAN2: - case LED_FAN3: - case LED_FAN4: - sprintf(fullpath_grn, devfiles__[local_id], "grn"); - - /* Set LED mode */ - if (onlp_file_read_int(&gvalue, fullpath_grn) != 0) { - DEBUG_PRINT("%s(%d)\r\n", __FUNCTION__, __LINE__); - info->mode = ONLP_LED_MODE_OFF; - info->status = ONLP_LED_STATUS_FAILED; - } - else - if (gvalue == 1) { - info->mode = ONLP_LED_MODE_GREEN; - info->status = ONLP_LED_STATUS_ON; - } - else - if (gvalue == 0) { - info->mode = ONLP_LED_MODE_OFF; - info->status = ONLP_LED_STATUS_ON; - } - - sprintf(fullpath_red, devfiles__[local_id], "red"); - - if (onlp_file_read_int(&rvalue, fullpath_red) != 0) { - DEBUG_PRINT("%s(%d)\r\n", __FUNCTION__, __LINE__); - info->mode = ONLP_LED_MODE_OFF; - info->status = ONLP_LED_STATUS_FAILED; - } - else - if (rvalue == 1) { - info->mode = ONLP_LED_MODE_RED; - info->status = ONLP_LED_STATUS_ON; - } - else - if (rvalue == 0) { - info->mode = ONLP_LED_MODE_OFF; - info->status = ONLP_LED_STATUS_ON; - } - break; - default: - DEBUG_PRINT("%s(%d) Invalid led id %d\r\n", __FUNCTION__, __LINE__, local_id); - break; - } - - return ONLP_STATUS_OK; -} - -int onlp_ledi_status_get(onlp_oid_t id, uint32_t* rv) -{ - int result = ONLP_STATUS_OK; - onlp_led_info_t linfo; - - result = onlp_ledi_info_get(id, &linfo); - *rv = linfo.status; - - return result; -} - -/* - * 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; -} - -#define HWMON_PSOC_DIAG_PATH "/sys/bus/i2c/devices/0-0055/hwmon/hwmon2/subsystem/hwmon1/diag" -#define HWMON_CPLD_CTRL_PATH "/sys/bus/i2c/devices/0-0055/driver/0-0055/ctl" -#define HWMON_DEVICE_DIAG_PATH HWMON_PSOC_DIAG_PATH -#define HWMON_DEVICE_CTRL_PATH HWMON_CPLD_CTRL_PATH - -#define MIN_ACC_SIZE (32) - -/* - * Store attr Section - */ -static int onlp_chassis_led_diag_enable(void) -{ - char tmp[MIN_ACC_SIZE]; - ssize_t ret; - - ret = onlp_chassis_led_read(HWMON_DEVICE_DIAG_PATH, &tmp[0], MIN_ACC_SIZE); - if (ret <= 0) { - return ret; - } - - if (tmp[0] == '0') { - pthread_mutex_lock(&diag_mutex); - ret = onlp_chassis_led_write(HWMON_DEVICE_DIAG_PATH, "1"); - if (ret < 0) { - pthread_mutex_unlock(&diag_mutex); - return ret; - } - - ret = onlp_chassis_led_write(HWMON_DEVICE_CTRL_PATH, "1"); - if (ret < 0) { - pthread_mutex_unlock(&diag_mutex); - return ret; - } - pthread_mutex_unlock(&diag_mutex); - } - - return ret; -} - -static int onlp_chassis_led_diag_disable(void) -{ - char tmp[MIN_ACC_SIZE]; - ssize_t ret; - - ret = onlp_chassis_led_read(HWMON_DEVICE_DIAG_PATH, &tmp[0], MIN_ACC_SIZE); - if (ret <= 0) { - return ret; - } - - if (tmp[0] == '1') { - pthread_mutex_lock(&diag_mutex); - ret = onlp_chassis_led_write(HWMON_DEVICE_DIAG_PATH, "1"); - if (ret < 0) { - pthread_mutex_unlock(&diag_mutex); - return 1; - } - - ret = onlp_chassis_led_write(HWMON_DEVICE_CTRL_PATH, "1"); - if (ret < 0) { - pthread_mutex_unlock(&diag_mutex); - return 1; - } - pthread_mutex_unlock(&diag_mutex); - } - return 1; -} - -/* - * 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) -{ - char fullpath_grn[50] = {0}; - char fullpath_red[50] = {0}; - char sys_buf[32] = {0}; - onlp_led_info_t linfo; - int ret = onlp_ledi_info_get(id, &linfo); - int local_id; - - VALIDATE(id); - - local_id = ONLP_OID_ID_GET(id); - - switch (mode) { - case ONLP_LED_MODE_OFF: - if (ret == ONLP_STATUS_OK && linfo.status & ONLP_LED_STATUS_ON && linfo.mode == ONLP_LED_MODE_OFF) { - return ONLP_STATUS_OK; - } - - sprintf(sys_buf, "%d", 0x0); - sprintf(fullpath_grn, devfiles__[local_id], "grn"); - ret = onlp_chassis_led_write(fullpath_grn, sys_buf); - - sprintf(sys_buf, "%d", 0x0); - sprintf(fullpath_red, devfiles__[local_id], "red"); - ret = onlp_chassis_led_write(fullpath_red, sys_buf); - break; - case ONLP_LED_MODE_RED: - if (ret == ONLP_STATUS_OK && linfo.status & ONLP_LED_STATUS_ON && linfo.mode == ONLP_LED_MODE_RED) { - return ONLP_STATUS_OK; - } - - sprintf(sys_buf, "%d", 0x0); - sprintf(fullpath_grn, devfiles__[local_id], "grn"); - ret = onlp_chassis_led_write(fullpath_grn, sys_buf); - - sprintf(sys_buf, "%d", 0x7); - sprintf(fullpath_red, devfiles__[local_id], "red"); - ret = onlp_chassis_led_write(fullpath_red, sys_buf); - break; - case ONLP_LED_MODE_GREEN: - if (ret == ONLP_STATUS_OK && linfo.status & ONLP_LED_STATUS_ON && linfo.mode == ONLP_LED_MODE_GREEN) { - return ONLP_STATUS_OK; - } - - sprintf(sys_buf, "%d", 0x7); - sprintf(fullpath_grn, devfiles__[local_id], "grn"); - ret = onlp_chassis_led_write(fullpath_grn, sys_buf); - - sprintf(sys_buf, "%d", 0x0); - sprintf(fullpath_red, devfiles__[local_id], "red"); - ret = onlp_chassis_led_write(fullpath_red, sys_buf); - break; - case ONLP_LED_MODE_ORANGE: - if (ret == ONLP_STATUS_OK && linfo.status & ONLP_LED_STATUS_ON && linfo.mode == ONLP_LED_MODE_ORANGE) { - return ONLP_STATUS_OK; - } - - sprintf(sys_buf, "%d", 0x7); - sprintf(fullpath_grn, devfiles__[local_id], "grn"); - ret = onlp_chassis_led_write(fullpath_grn, sys_buf); - - sprintf(sys_buf, "%d", 0x7); - sprintf(fullpath_red, devfiles__[local_id], "red"); - ret = onlp_chassis_led_write(fullpath_red, sys_buf); - break; - default: - DEBUG_PRINT("%s(%d) Invalid led mode %d\r\n", __FUNCTION__, __LINE__, mode); - return ONLP_STATUS_E_INTERNAL; - } - - switch (local_id) { - case LED_SYS: - onlp_chassis_led_diag_enable(); - sleep(1); - onlp_chassis_led_diag_disable(); - break; - default: - break; - } - - return ONLP_STATUS_OK; -} diff --git a/packages/platforms/inventec/x86-64/d7264q28b/onlp/builds/x86_64_inventec_d7264q28b/module/src/make.mk b/packages/platforms/inventec/x86-64/d7264q28b/onlp/builds/x86_64_inventec_d7264q28b/module/src/make.mk deleted file mode 100644 index 5b3dd1a49..000000000 --- a/packages/platforms/inventec/x86-64/d7264q28b/onlp/builds/x86_64_inventec_d7264q28b/module/src/make.mk +++ /dev/null @@ -1,9 +0,0 @@ -############################################################################### -# -# -# -############################################################################### - -LIBRARY := x86_64_inventec_d7264q28b -$(LIBRARY)_SUBDIR := $(dir $(lastword $(MAKEFILE_LIST))) -include $(BUILDER)/lib.mk diff --git a/packages/platforms/inventec/x86-64/d7264q28b/onlp/builds/x86_64_inventec_d7264q28b/module/src/platform_lib.c b/packages/platforms/inventec/x86-64/d7264q28b/onlp/builds/x86_64_inventec_d7264q28b/module/src/platform_lib.c deleted file mode 100644 index afaf19939..000000000 --- a/packages/platforms/inventec/x86-64/d7264q28b/onlp/builds/x86_64_inventec_d7264q28b/module/src/platform_lib.c +++ /dev/null @@ -1,184 +0,0 @@ -/************************************************************ - * platform_lib.c - * - * Copyright 2018 Inventec Corporation. - * - ************************************************************ - * - ***********************************************************/ -#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 32 -#define I2C_PSU_FAN_DIR_LEN 8 -#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)] = 0; - } - - if (strncmp(model_name, "YM-2651Y", 8) == 0) { - if (modelname) { - aim_strlcpy(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) { - aim_strlcpy(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) { - aim_strlcpy(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; - } - } - - if (strncmp(model_name, "DPS-150AB-10", 12) == 0) { - if (modelname) { - aim_strlcpy(modelname, model_name, 12); - } - - return PSU_TYPE_DC_12V_F2B; - } - - 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%d", PSU1_AC_PMBUS_PREFIX, node, PSU1_ID); - } - else - if (PSU2_ID == id) { - ret = onlp_file_read_int(value, "%s%s%d", PSU2_AC_PMBUS_PREFIX, node, PSU2_ID); - } - else { - return ONLP_STATUS_E_INTERNAL; - } - - 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%d", PSU1_AC_PMBUS_PREFIX, node, PSU1_ID); - break; - case PSU2_ID: - sprintf(path, "%s%s%d", PSU2_AC_PMBUS_PREFIX, node, PSU2_ID); - 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/d7264q28b/onlp/builds/x86_64_inventec_d7264q28b/module/src/platform_lib.h b/packages/platforms/inventec/x86-64/d7264q28b/onlp/builds/x86_64_inventec_d7264q28b/module/src/platform_lib.h deleted file mode 100644 index e2fd7af6c..000000000 --- a/packages/platforms/inventec/x86-64/d7264q28b/onlp/builds/x86_64_inventec_d7264q28b/module/src/platform_lib.h +++ /dev/null @@ -1,141 +0,0 @@ -/************************************************************ - * platform_lib.h - * - * Copyright 2018 Inventec Technology Corporation. - * - ************************************************************ - * - ***********************************************************/ -#ifndef __PLATFORM_LIB_H__ -#define __PLATFORM_LIB_H__ - -#include "x86_64_inventec_d7264q28b_log.h" - -#define ONLP_NODE_MAX_INT_LEN (8) -#define ONLP_NODE_MAX_PATH_LEN (64) - -#define INV_CPLD_COUNT (2) -#define INV_CPLD_PREFIX "/sys/bus/i2c/devices/0-0055/" -#define INV_CPLD2_PREFIX "/sys/bus/i2c/devices/0-0077/" -#define INV_PSOC_PREFIX "/sys/devices/virtual/hwmon/hwmon1/" -#define INV_EPRM_PREFIX "/sys/bus/i2c/devices/0-0053/" -#define INV_CTMP_PREFIX "/sys/devices/platform/coretemp.0/hwmon/hwmon0/" - -#define INV_SFP_EEPROM_UPDATE "/sys/class/swps/module/eeprom_update" -#define CHASSIS_SFP_COUNT (64) - -/* - * Definitions of Chassis EEPROM - */ -#define EEPROM_NODE(node) INV_EPRM_PREFIX#node - - -/* - * Definitions of D7264Q28B device - */ -enum onlp_thermal_id { - THERMAL_RESERVED = 0, - THERMAL_CPU_CORE_FIRST, - THERMAL_CPU_CORE_2, - THERMAL_CPU_CORE_3, - THERMAL_CPU_CORE_4, - THERMAL_CPU_CORE_LAST, - 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_2_ON_PSU1, - THERMAL_1_ON_PSU2, - THERMAL_2_ON_PSU2, - THERMAL_MAX -}; -#define CHASSIS_THERMAL_COUNT (10) - -enum onlp_fan_id { - FAN_RESERVED = 0, - FAN_1_ON_MAIN_BOARD, - FAN_2_ON_MAIN_BOARD, - FAN_3_ON_MAIN_BOARD, - FAN_4_ON_MAIN_BOARD, - FAN_5_ON_MAIN_BOARD, - FAN_6_ON_MAIN_BOARD, - FAN_7_ON_MAIN_BOARD, - FAN_8_ON_MAIN_BOARD, - FAN_1_ON_PSU1, - FAN_1_ON_PSU2, - FAN_MAX -}; -#define CHASSIS_FAN_COUNT (8) - -enum onlp_led_id { - LED_RESERVED = 0, - LED_SYS, - LED_FAN1, - LED_FAN2, - LED_FAN3, - LED_FAN4, - LED_MAX -}; -#define CHASSIS_LED_COUNT (1) - -enum onlp_psu_id { - PSU_RESERVED = 0, - PSU1_ID, - PSU2_ID, - PSU_MAX -}; -#define CHASSIS_PSU_COUNT (2) - - -#define PSU1_AC_PMBUS_PREFIX INV_PSOC_PREFIX -#define PSU2_AC_PMBUS_PREFIX INV_PSOC_PREFIX - -#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 INV_CPLD_PREFIX -#define PSU2_AC_HWMON_PREFIX INV_CPLD_PREFIX - -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 PSU1_AC_HWMON_NODE(node) PSU1_AC_HWMON_PREFIX#node -#define PSU2_AC_HWMON_NODE(node) PSU2_AC_HWMON_PREFIX#node - -/* - * Definitions of FAN device - */ -#define FAN_BOARD_PATH INV_PSOC_PREFIX -#define FAN_NODE(node) FAN_BOARD_PATH#node - -/* - * Prototypes - */ -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); - -#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/d7264q28b/onlp/builds/x86_64_inventec_d7264q28b/module/src/psui.c b/packages/platforms/inventec/x86-64/d7264q28b/onlp/builds/x86_64_inventec_d7264q28b/module/src/psui.c deleted file mode 100644 index 16a634b9b..000000000 --- a/packages/platforms/inventec/x86-64/d7264q28b/onlp/builds/x86_64_inventec_d7264q28b/module/src/psui.c +++ /dev/null @@ -1,256 +0,0 @@ -/************************************************************ - * psui.c - * - * Copyright 2018 Inventec Technology Corporation. - * - ************************************************************ - * - ***********************************************************/ -#include -#include -#include -#include -#include -#include -#include "platform_lib.h" - -#define PSU_STATUS_PRESENT (0) -#define PSU_STATUS_POWER_GOOD (1) -#define PSU_STATUS_UNPOWERED (2) -#define PSU_STATUS_FAULT (4) -#define PSU_STATUS_UNINSTALLED (7) - -#define VALIDATE(_id) \ - do { \ - if(!ONLP_OID_IS_PSU(_id)) { \ - return ONLP_STATUS_E_INVALID; \ - } \ - } while(0) - -static char* status_devfiles__[PSU_MAX] = /* must map with onlp_psu_id */ -{ - "reserved", - INV_CPLD_PREFIX"/psu0", - INV_CPLD_PREFIX"/psu1", -}; - -static char* module_devfiles__[PSU_MAX] = /* must map with onlp_psu_id */ -{ - "reserved", - INV_PSOC_PREFIX"/psoc_psu1_%s", - INV_PSOC_PREFIX"/psoc_psu2_%s", -}; - -static int -psu_status_info_get(int id, char *node, int *value) -{ - int ret = 0; - char node_path[ONLP_NODE_MAX_PATH_LEN] = {0}; - - *value = 0; - if (PSU1_ID == id) { - sprintf(node_path, status_devfiles__[id]); - } - else if (PSU2_ID == id) { - sprintf(node_path, status_devfiles__[id]); - } - - 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 ONLP_STATUS_OK; -} - - -int -onlp_psui_init(void) -{ - return ONLP_STATUS_OK; -} - -static void -psu_module_name_get(int id, onlp_psu_info_t* info) -{ - char node_path[ONLP_NODE_MAX_PATH_LEN] = {0}; - uint8_t temp[ONLP_CONFIG_INFO_STR_MAX] = {0}; - int ret, len; - -#if 1 - aim_strlcpy(info->model, "N/A", 3); -#else - memset(node_path, 0, ONLP_NODE_MAX_PATH_LEN); - sprintf(node_path, module_devfiles__[id], "model"); - ret = onlp_file_read(temp, ONLP_CONFIG_INFO_STR_MAX, &len, node_path); - if (ret == 0) { - /*remove the '\n'*/ - temp[strlen((char*)temp)-1] = 0; - snprintf(info->model, ONLP_CONFIG_INFO_STR_MAX, "%s", temp); - } - else { - AIM_LOG_ERROR("Unable to read model name from file(%s)\r\n", node_path); - aim_strlcpy(info->model, "N/A", 3); - } -#endif - - memset(node_path, 0, ONLP_NODE_MAX_PATH_LEN); - sprintf(node_path, module_devfiles__[id], "serial"); - ret = onlp_file_read(temp, ONLP_CONFIG_INFO_STR_MAX, &len, node_path); - if (ret == 0) { - /*remove the '\n'*/ - temp[strlen((char*)temp)-1] = 0; - snprintf(info->serial, ONLP_CONFIG_INFO_STR_MAX, "%s", temp); - } - else { - AIM_LOG_ERROR("Unable to read model name from file(%s)\r\n", node_path); - aim_strlcpy(info->serial, "N/A", 3); - } -} - -static int -psu_module_info_get(int id, onlp_psu_info_t* info) -{ - int ret = 0; - char node_path[ONLP_NODE_MAX_PATH_LEN] = {0}; - int value = 0; - - info->caps |= ONLP_PSU_CAPS_DC12; - - memset(node_path, 0, ONLP_NODE_MAX_PATH_LEN); - sprintf(node_path, module_devfiles__[id], "vout"); - ret = onlp_file_read_int(&value, node_path); - if (ret < 0) { - AIM_LOG_ERROR("Unable to read vout from file(%s)\r\n", node_path); - } - else { - info->mvout = value; - info->caps |= ONLP_PSU_CAPS_VOUT; - } - - memset(node_path, 0, ONLP_NODE_MAX_PATH_LEN); - sprintf(node_path, module_devfiles__[id], "iout"); - ret = onlp_file_read_int(&value, node_path); - if (ret < 0) { - AIM_LOG_ERROR("Unable to read iout from file(%s)\r\n", node_path); - } - else { - info->miout = value; - info->caps |= ONLP_PSU_CAPS_IOUT; - } - - memset(node_path, 0, ONLP_NODE_MAX_PATH_LEN); - sprintf(node_path, module_devfiles__[id], "pout"); - ret = onlp_file_read_int(&value, node_path); - if (ret < 0) { - AIM_LOG_ERROR("Unable to read pout from file(%s)\r\n", node_path); - } - else { - info->mpout = value; - info->caps |= ONLP_PSU_CAPS_POUT; - } - - memset(node_path, 0, ONLP_NODE_MAX_PATH_LEN); - sprintf(node_path, module_devfiles__[id], "vin"); - ret = onlp_file_read_int(&value, node_path); - if (ret < 0) { - AIM_LOG_ERROR("Unable to read vin from file(%s)\r\n", node_path); - } - else { - info->mvin = value; - info->caps |= ONLP_PSU_CAPS_VIN; - } - - memset(node_path, 0, ONLP_NODE_MAX_PATH_LEN); - sprintf(node_path, module_devfiles__[id], "iin"); - ret = onlp_file_read_int(&value, node_path); - if (ret < 0) { - AIM_LOG_ERROR("Unable to read iin from file(%s)\r\n", node_path); - } - else { - info->miin = value; - info->caps |= ONLP_PSU_CAPS_IIN; - } - - memset(node_path, 0, ONLP_NODE_MAX_PATH_LEN); - sprintf(node_path, module_devfiles__[id], "pin"); - ret = onlp_file_read_int(&value, node_path); - if (ret < 0) { - AIM_LOG_ERROR("Unable to read pin from file(%s)\r\n", node_path); - } - else { - info->mpin = value; - info->caps |= ONLP_PSU_CAPS_PIN; - } - - psu_module_name_get(id, info); - 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_THERMAL_ID_CREATE(THERMAL_1_ON_PSU1), - ONLP_THERMAL_ID_CREATE(THERMAL_2_ON_PSU1), - ONLP_FAN_ID_CREATE(FAN_1_ON_PSU1) - } - }, - }, - { - { - ONLP_PSU_ID_CREATE(PSU2_ID), "PSU-2", 0, - { - ONLP_THERMAL_ID_CREATE(THERMAL_1_ON_PSU2), - ONLP_THERMAL_ID_CREATE(THERMAL_2_ON_PSU2), - ONLP_FAN_ID_CREATE(FAN_1_ON_PSU2) - } - }, - } -}; - -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 ((ret = psu_status_info_get(index, "psu", &val)) == ONLP_STATUS_E_INTERNAL) { - printf("Unable to read PSU(%d) node(psu)\r\n", index); - return ret; - } - - if (val == 0) { - info->status = ONLP_PSU_STATUS_PRESENT; - } - else - if (val == 1) { - info->status = ONLP_PSU_STATUS_UNPLUGGED; - return ret; - } - else { - info->status = ONLP_PSU_STATUS_FAILED; - return ret; - } - - if ((ret = psu_module_info_get(index, info)) != ONLP_STATUS_OK) { - printf("Unable to read PSU(%d) module information\r\n", index); - } - - return ret; -} diff --git a/packages/platforms/inventec/x86-64/d7264q28b/onlp/builds/x86_64_inventec_d7264q28b/module/src/sfpi.c b/packages/platforms/inventec/x86-64/d7264q28b/onlp/builds/x86_64_inventec_d7264q28b/module/src/sfpi.c deleted file mode 100644 index 649854172..000000000 --- a/packages/platforms/inventec/x86-64/d7264q28b/onlp/builds/x86_64_inventec_d7264q28b/module/src/sfpi.c +++ /dev/null @@ -1,240 +0,0 @@ -/************************************************************ - * sfpi.c - * - * Copyright 2018 Inventec Technology Corporation. - * - ************************************************************ - * - ***********************************************************/ -#include - -#include /* For O_RDWR && open */ -#include -#include -#include -#include -#include -#include -#include "platform_lib.h" - -static char sfp_node_path[ONLP_NODE_MAX_PATH_LEN] = {0}; - -#define NUM_OF_SFP_PORT (CHASSIS_SFP_COUNT) -static const int sfp_mux_index[NUM_OF_SFP_PORT] = { -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, -45, 44, 43, 42, 49, 48, 47, 46, -53, 52, 51, 50, 57, 56, 55, 54, -61, 60, 59, 58, 65, 64, 63, 62, -69, 68, 67, 66, 73, 72, 71, 70 -}; - -#define FRONT_PORT_TO_MUX_INDEX(port) (sfp_mux_index[port]) - -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/class/swps/port%d/%s", 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, 64} - */ - 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, "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; - } - if (present == 0) { - present = 1; - } - else - if (present == 1) { - present = 0; - } - else { - AIM_LOG_ERROR("Unvalid present status %d from port(%d)\r\n",present,port); - return ONLP_STATUS_E_INTERNAL; - } - return present; -} - -int -onlp_sfpi_presence_bitmap_get(onlp_sfp_bitmap_t* dst) -{ - uint32_t presence_all[2] = {0}; - int port, ret, index; - - for (port = 0, index = 0; port < NUM_OF_SFP_PORT; port++) { - if (port == 32) { - index = 1; - } - - ret = onlp_sfpi_is_present(port); - if (ret == 1) { - presence_all[index] |= (1<>= 1; - } - return ONLP_STATUS_OK; -} - -int -onlp_sfpi_eeprom_read(int port, uint8_t data[256]) -{ - char* path; - 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); - path = sfp_get_port_path(port, "eeprom"); - if (onlp_file_read(&data[0], 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_dom_read(int port, uint8_t data[256]) -{ - return onlp_sfpi_eeprom_read( port, data); -} - -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); - int ret = onlp_i2c_writeb(bus, devaddr, addr, value, ONLP_I2C_F_FORCE); - - if (ret == 0) { - unsigned char buf[8] = { 0 }; - char str[20]; - - buf[port/8] = (1 << port%8); - sprintf(str, "0x%02x%02x%02x%02x%02x%02x%02x%02x", buf[7],buf[6],buf[5],buf[4],buf[3],buf[2],buf[1],buf[0]); - if (onlp_file_write((uint8_t*)str, 20, INV_SFP_EEPROM_UPDATE) < 0) { - AIM_LOG_ERROR("Unable to write eeprom_update for port(%d)\r\n", port); - return ONLP_STATUS_E_INTERNAL; - } - return ONLP_STATUS_OK; - } - AIM_LOG_ERROR("Unable to read eeprom_update from port(%d)\r\n", port); - return ret; -} - -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); - int ret = onlp_i2c_writew(bus, devaddr, addr, value, ONLP_I2C_F_FORCE); - - if (ret == 0) { - unsigned char buf[8] = { 0 }; - char str[20]; - - buf[port/8] = (1 << port%8); - sprintf(str, "0x%02x%02x%02x%02x%02x%02x%02x%02x", buf[7],buf[6],buf[5],buf[4],buf[3],buf[2],buf[1],buf[0]); - if (onlp_file_write((uint8_t*)str, 20, INV_SFP_EEPROM_UPDATE) < 0) { - AIM_LOG_ERROR("Unable to write eeprom_update for port(%d)\r\n", port); - return ONLP_STATUS_E_INTERNAL; - } - return ONLP_STATUS_OK; - } - AIM_LOG_ERROR("Unable to read eeprom_update from port(%d)\r\n", port); - return ret; -} - -int -onlp_sfpi_denit(void) -{ - return ONLP_STATUS_OK; -} - diff --git a/packages/platforms/inventec/x86-64/d7264q28b/onlp/builds/x86_64_inventec_d7264q28b/module/src/sysi.c b/packages/platforms/inventec/x86-64/d7264q28b/onlp/builds/x86_64_inventec_d7264q28b/module/src/sysi.c deleted file mode 100644 index 1dc8e1b0a..000000000 --- a/packages/platforms/inventec/x86-64/d7264q28b/onlp/builds/x86_64_inventec_d7264q28b/module/src/sysi.c +++ /dev/null @@ -1,111 +0,0 @@ -/************************************************************ - * sysi.c - * - * Copyright 2018 Inventec Technology Corporation. - * - ************************************************************ - * - ***********************************************************/ -#include -#include - -#include -#include -#include -#include -#include -#include - -#include "x86_64_inventec_d7264q28b_int.h" -#include "x86_64_inventec_d7264q28b_log.h" - -#include "platform_lib.h" - -#define NUM_OF_CPLD INV_CPLD_COUNT - -#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 (CHASSIS_PSU_COUNT) -#define NUM_OF_LED_ON_MAIN_BROAD (CHASSIS_LED_COUNT) - -const char* -onlp_sysi_platform_get(void) -{ - return "x86-64-inventec-d7264q28b-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, EEPROM_NODE(eeprom)) == 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)); - - /* 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; -} - -static char *arr_cplddev_version[NUM_OF_CPLD] = -{ - INV_CPLD_PREFIX"/version", - INV_CPLD2_PREFIX"/version", -}; - -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, arr_cplddev_version[i]) < 0) { - return ONLP_STATUS_E_INTERNAL; - } - } - pi->cpld_versions = aim_fstrdup("%d.%d", v[0], v[1]); - return 0; -} - -void -onlp_sysi_platform_info_free(onlp_platform_info_t* pi) -{ - aim_free(pi->cpld_versions); -} diff --git a/packages/platforms/inventec/x86-64/d7264q28b/onlp/builds/x86_64_inventec_d7264q28b/module/src/thermali.c b/packages/platforms/inventec/x86-64/d7264q28b/onlp/builds/x86_64_inventec_d7264q28b/module/src/thermali.c deleted file mode 100644 index 178eb6a7c..000000000 --- a/packages/platforms/inventec/x86-64/d7264q28b/onlp/builds/x86_64_inventec_d7264q28b/module/src/thermali.c +++ /dev/null @@ -1,147 +0,0 @@ -/************************************************************ - * thermali.c - * - * Copyright 2018 Inventec Technology Corporation. - * - ************************************************************ - * - * 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) - -static char* devfiles__[THERMAL_MAX] = /* must map with onlp_thermal_id */ -{ - "reserved", - INV_CTMP_PREFIX"/temp1_%s", - INV_CTMP_PREFIX"/temp2_%s", - INV_CTMP_PREFIX"/temp3_%s", - INV_CTMP_PREFIX"/temp4_%s", - INV_CTMP_PREFIX"/temp5_%s", - INV_PSOC_PREFIX"/temp1_input", - INV_PSOC_PREFIX"/temp2_input", - INV_PSOC_PREFIX"/temp3_input", - INV_PSOC_PREFIX"/temp4_input", - INV_PSOC_PREFIX"/temp5_input", - INV_PSOC_PREFIX"/thermal_psu1", - INV_PSOC_PREFIX"/thermal2_psu1", - INV_PSOC_PREFIX"/thermal_psu2", - INV_PSOC_PREFIX"/thermal2_psu2", -}; - -/* Static values */ -static onlp_thermal_info_t linfo[THERMAL_MAX] = { - { }, /* Not used */ - { { ONLP_THERMAL_ID_CREATE(THERMAL_CPU_CORE_FIRST), "Physical id 0", 0}, - ONLP_THERMAL_STATUS_PRESENT, - ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS - }, - { { ONLP_THERMAL_ID_CREATE(THERMAL_CPU_CORE_2), "CPU Core 0", 0}, - ONLP_THERMAL_STATUS_PRESENT, - ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS - }, - { { ONLP_THERMAL_ID_CREATE(THERMAL_CPU_CORE_3), "CPU Core 1", 0}, - ONLP_THERMAL_STATUS_PRESENT, - ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS - }, - { { ONLP_THERMAL_ID_CREATE(THERMAL_CPU_CORE_4), "CPU Core 2", 0}, - ONLP_THERMAL_STATUS_PRESENT, - ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS - }, - { { ONLP_THERMAL_ID_CREATE(THERMAL_CPU_CORE_LAST), "CPU Core 3", 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_3_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_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_2_ON_PSU1), "PSU-1 Thermal Sensor 2", 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 - }, - { { ONLP_THERMAL_ID_CREATE(THERMAL_2_ON_PSU2), "PSU-2 Thermal Sensor 2", 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_FIRST && local_id <= THERMAL_CPU_CORE_LAST) { - char desc[32], *dp = &desc[0]; - int rv = onlp_file_read_str(&dp, devfiles__[local_id], "label"); - if (rv > 0) { - memset (info->hdr.description, 0, ONLP_OID_DESC_SIZE); - aim_strlcpy(info->hdr.description, dp, rv); - } - - /* Set the onlp_oid_hdr_t and capabilities */ - return onlp_file_read_int(&info->mcelsius, devfiles__[local_id], "input"); - } - return onlp_file_read_int(&info->mcelsius, devfiles__[local_id]); -} diff --git a/packages/platforms/inventec/x86-64/d7264q28b/onlp/builds/x86_64_inventec_d7264q28b/module/src/x86_64_inventec_d7264q28b_config.c b/packages/platforms/inventec/x86-64/d7264q28b/onlp/builds/x86_64_inventec_d7264q28b/module/src/x86_64_inventec_d7264q28b_config.c deleted file mode 100644 index 341c79662..000000000 --- a/packages/platforms/inventec/x86-64/d7264q28b/onlp/builds/x86_64_inventec_d7264q28b/module/src/x86_64_inventec_d7264q28b_config.c +++ /dev/null @@ -1,80 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#include - -/* */ -#define __x86_64_inventec_d7264q28b_config_STRINGIFY_NAME(_x) #_x -#define __x86_64_inventec_d7264q28b_config_STRINGIFY_VALUE(_x) __x86_64_inventec_d7264q28b_config_STRINGIFY_NAME(_x) -x86_64_inventec_d7264q28b_config_settings_t x86_64_inventec_d7264q28b_config_settings[] = -{ -#ifdef X86_64_INVENTEC_D7264Q28B_CONFIG_INCLUDE_LOGGING - { __x86_64_inventec_d7264q28b_config_STRINGIFY_NAME(X86_64_INVENTEC_D7264Q28B_CONFIG_INCLUDE_LOGGING), __x86_64_inventec_d7264q28b_config_STRINGIFY_VALUE(X86_64_INVENTEC_D7264Q28B_CONFIG_INCLUDE_LOGGING) }, -#else -{ X86_64_INVENTEC_D7264Q28B_CONFIG_INCLUDE_LOGGING(__x86_64_inventec_d7264q28b_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_INVENTEC_D7264Q28B_CONFIG_LOG_OPTIONS_DEFAULT - { __x86_64_inventec_d7264q28b_config_STRINGIFY_NAME(X86_64_INVENTEC_D7264Q28B_CONFIG_LOG_OPTIONS_DEFAULT), __x86_64_inventec_d7264q28b_config_STRINGIFY_VALUE(X86_64_INVENTEC_D7264Q28B_CONFIG_LOG_OPTIONS_DEFAULT) }, -#else -{ X86_64_INVENTEC_D7264Q28B_CONFIG_LOG_OPTIONS_DEFAULT(__x86_64_inventec_d7264q28b_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_INVENTEC_D7264Q28B_CONFIG_LOG_BITS_DEFAULT - { __x86_64_inventec_d7264q28b_config_STRINGIFY_NAME(X86_64_INVENTEC_D7264Q28B_CONFIG_LOG_BITS_DEFAULT), __x86_64_inventec_d7264q28b_config_STRINGIFY_VALUE(X86_64_INVENTEC_D7264Q28B_CONFIG_LOG_BITS_DEFAULT) }, -#else -{ X86_64_INVENTEC_D7264Q28B_CONFIG_LOG_BITS_DEFAULT(__x86_64_inventec_d7264q28b_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_INVENTEC_D7264Q28B_CONFIG_LOG_CUSTOM_BITS_DEFAULT - { __x86_64_inventec_d7264q28b_config_STRINGIFY_NAME(X86_64_INVENTEC_D7264Q28B_CONFIG_LOG_CUSTOM_BITS_DEFAULT), __x86_64_inventec_d7264q28b_config_STRINGIFY_VALUE(X86_64_INVENTEC_D7264Q28B_CONFIG_LOG_CUSTOM_BITS_DEFAULT) }, -#else -{ X86_64_INVENTEC_D7264Q28B_CONFIG_LOG_CUSTOM_BITS_DEFAULT(__x86_64_inventec_d7264q28b_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_INVENTEC_D7264Q28B_CONFIG_PORTING_STDLIB - { __x86_64_inventec_d7264q28b_config_STRINGIFY_NAME(X86_64_INVENTEC_D7264Q28B_CONFIG_PORTING_STDLIB), __x86_64_inventec_d7264q28b_config_STRINGIFY_VALUE(X86_64_INVENTEC_D7264Q28B_CONFIG_PORTING_STDLIB) }, -#else -{ X86_64_INVENTEC_D7264Q28B_CONFIG_PORTING_STDLIB(__x86_64_inventec_d7264q28b_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_INVENTEC_D7264Q28B_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS - { __x86_64_inventec_d7264q28b_config_STRINGIFY_NAME(X86_64_INVENTEC_D7264Q28B_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS), __x86_64_inventec_d7264q28b_config_STRINGIFY_VALUE(X86_64_INVENTEC_D7264Q28B_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS) }, -#else -{ X86_64_INVENTEC_D7264Q28B_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS(__x86_64_inventec_d7264q28b_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_INVENTEC_D7264Q28B_CONFIG_INCLUDE_UCLI - { __x86_64_inventec_d7264q28b_config_STRINGIFY_NAME(X86_64_INVENTEC_D7264Q28B_CONFIG_INCLUDE_UCLI), __x86_64_inventec_d7264q28b_config_STRINGIFY_VALUE(X86_64_INVENTEC_D7264Q28B_CONFIG_INCLUDE_UCLI) }, -#else -{ X86_64_INVENTEC_D7264Q28B_CONFIG_INCLUDE_UCLI(__x86_64_inventec_d7264q28b_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_INVENTEC_D7264Q28B_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION - { __x86_64_inventec_d7264q28b_config_STRINGIFY_NAME(X86_64_INVENTEC_D7264Q28B_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION), __x86_64_inventec_d7264q28b_config_STRINGIFY_VALUE(X86_64_INVENTEC_D7264Q28B_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION) }, -#else -{ X86_64_INVENTEC_D7264Q28B_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION(__x86_64_inventec_d7264q28b_config_STRINGIFY_NAME), "__undefined__" }, -#endif - { NULL, NULL } -}; -#undef __x86_64_inventec_d7264q28b_config_STRINGIFY_VALUE -#undef __x86_64_inventec_d7264q28b_config_STRINGIFY_NAME - -const char* -x86_64_inventec_d7264q28b_config_lookup(const char* setting) -{ - int i; - for(i = 0; x86_64_inventec_d7264q28b_config_settings[i].name; i++) { - if(!strcmp(x86_64_inventec_d7264q28b_config_settings[i].name, setting)) { - return x86_64_inventec_d7264q28b_config_settings[i].value; - } - } - return NULL; -} - -int -x86_64_inventec_d7264q28b_config_show(struct aim_pvs_s* pvs) -{ - int i; - for(i = 0; x86_64_inventec_d7264q28b_config_settings[i].name; i++) { - aim_printf(pvs, "%s = %s\n", x86_64_inventec_d7264q28b_config_settings[i].name, x86_64_inventec_d7264q28b_config_settings[i].value); - } - return i; -} - -/* */ diff --git a/packages/platforms/inventec/x86-64/d7264q28b/onlp/builds/x86_64_inventec_d7264q28b/module/src/x86_64_inventec_d7264q28b_enums.c b/packages/platforms/inventec/x86-64/d7264q28b/onlp/builds/x86_64_inventec_d7264q28b/module/src/x86_64_inventec_d7264q28b_enums.c deleted file mode 100644 index 1f9d37df7..000000000 --- a/packages/platforms/inventec/x86-64/d7264q28b/onlp/builds/x86_64_inventec_d7264q28b/module/src/x86_64_inventec_d7264q28b_enums.c +++ /dev/null @@ -1,10 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#include - -/* <--auto.start.enum(ALL).source> */ -/* */ - diff --git a/packages/platforms/inventec/x86-64/d7264q28b/onlp/builds/x86_64_inventec_d7264q28b/module/src/x86_64_inventec_d7264q28b_int.h b/packages/platforms/inventec/x86-64/d7264q28b/onlp/builds/x86_64_inventec_d7264q28b/module/src/x86_64_inventec_d7264q28b_int.h deleted file mode 100644 index 9eed2fa62..000000000 --- a/packages/platforms/inventec/x86-64/d7264q28b/onlp/builds/x86_64_inventec_d7264q28b/module/src/x86_64_inventec_d7264q28b_int.h +++ /dev/null @@ -1,12 +0,0 @@ -/**************************************************************************//** - * - * x86_64_inventec_d7264q28b Internal Header - * - *****************************************************************************/ -#ifndef __x86_64_inventec_d7264q28b_INT_H__ -#define __x86_64_inventec_d7264q28b_INT_H__ - -#include - - -#endif /* __x86_64_inventec_d7264q28b_INT_H__ */ diff --git a/packages/platforms/inventec/x86-64/d7264q28b/onlp/builds/x86_64_inventec_d7264q28b/module/src/x86_64_inventec_d7264q28b_log.c b/packages/platforms/inventec/x86-64/d7264q28b/onlp/builds/x86_64_inventec_d7264q28b/module/src/x86_64_inventec_d7264q28b_log.c deleted file mode 100644 index 31aceb9f4..000000000 --- a/packages/platforms/inventec/x86-64/d7264q28b/onlp/builds/x86_64_inventec_d7264q28b/module/src/x86_64_inventec_d7264q28b_log.c +++ /dev/null @@ -1,17 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#include - -#include "x86_64_inventec_d7264q28b_log.h" -/* - * x86_64_inventec_d7264q28b log struct. - */ -AIM_LOG_STRUCT_DEFINE( - X86_64_INVENTEC_D7264Q28B_CONFIG_LOG_OPTIONS_DEFAULT, - X86_64_INVENTEC_D7264Q28B_CONFIG_LOG_BITS_DEFAULT, - NULL, /* Custom log map */ - X86_64_INVENTEC_D7264Q28B_CONFIG_LOG_CUSTOM_BITS_DEFAULT - ); diff --git a/packages/platforms/inventec/x86-64/d7264q28b/onlp/builds/x86_64_inventec_d7264q28b/module/src/x86_64_inventec_d7264q28b_log.h b/packages/platforms/inventec/x86-64/d7264q28b/onlp/builds/x86_64_inventec_d7264q28b/module/src/x86_64_inventec_d7264q28b_log.h deleted file mode 100644 index 4572bc658..000000000 --- a/packages/platforms/inventec/x86-64/d7264q28b/onlp/builds/x86_64_inventec_d7264q28b/module/src/x86_64_inventec_d7264q28b_log.h +++ /dev/null @@ -1,12 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#ifndef __x86_64_inventec_d7264q28b_LOG_H__ -#define __x86_64_inventec_d7264q28b_LOG_H__ - -#define AIM_LOG_MODULE_NAME x86_64_inventec_d7264q28b -#include - -#endif /* __x86_64_inventec_d7264q28b_LOG_H__ */ diff --git a/packages/platforms/inventec/x86-64/d7264q28b/onlp/builds/x86_64_inventec_d7264q28b/module/src/x86_64_inventec_d7264q28b_module.c b/packages/platforms/inventec/x86-64/d7264q28b/onlp/builds/x86_64_inventec_d7264q28b/module/src/x86_64_inventec_d7264q28b_module.c deleted file mode 100644 index 64fb545e1..000000000 --- a/packages/platforms/inventec/x86-64/d7264q28b/onlp/builds/x86_64_inventec_d7264q28b/module/src/x86_64_inventec_d7264q28b_module.c +++ /dev/null @@ -1,24 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#include - -#include "x86_64_inventec_d7264q28b_log.h" - -static int -datatypes_init__(void) -{ -#define x86_64_inventec_d7264q28b_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_d7264q28b_module_init__(void) -{ - AIM_LOG_STRUCT_REGISTER(); - datatypes_init__(); -} - -int __onlp_platform_version__ = 1; diff --git a/packages/platforms/inventec/x86-64/d7264q28b/onlp/builds/x86_64_inventec_d7264q28b/module/src/x86_64_inventec_d7264q28b_ucli.c b/packages/platforms/inventec/x86-64/d7264q28b/onlp/builds/x86_64_inventec_d7264q28b/module/src/x86_64_inventec_d7264q28b_ucli.c deleted file mode 100644 index 58b62f50a..000000000 --- a/packages/platforms/inventec/x86-64/d7264q28b/onlp/builds/x86_64_inventec_d7264q28b/module/src/x86_64_inventec_d7264q28b_ucli.c +++ /dev/null @@ -1,50 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#include - -#if x86_64_inventec_d7264q28b_CONFIG_INCLUDE_UCLI == 1 - -#include -#include -#include - -static ucli_status_t -x86_64_inventec_d7264q28b_ucli_ucli__config__(ucli_context_t* uc) -{ - UCLI_HANDLER_MACRO_MODULE_CONFIG(x86_64_inventec_d7264q28b) -} - -/* */ -/* */ - -static ucli_module_t -x86_64_inventec_d7264q28b_ucli_module__ = - { - "x86_64_inventec_d7264q28b_ucli", - NULL, - x86_64_inventec_d7264q28b_ucli_ucli_handlers__, - NULL, - NULL, - }; - -ucli_node_t* -x86_64_inventec_d7264q28b_ucli_node_create(void) -{ - ucli_node_t* n; - ucli_module_init(&x86_64_inventec_d7264q28b_ucli_module__); - n = ucli_node_create("x86_64_inventec_d7264q28b", NULL, &x86_64_inventec_d7264q28b_ucli_module__); - ucli_node_subnode_add(n, ucli_module_log_node_create("x86_64_inventec_d7264q28b")); - return n; -} - -#else -void* -x86_64_inventec_d7264q28b_ucli_node_create(void) -{ - return NULL; -} -#endif - diff --git a/packages/platforms/inventec/x86-64/d7264q28b/platform-config/Makefile b/packages/platforms/inventec/x86-64/d7264q28b/platform-config/Makefile deleted file mode 100644 index 003238cf6..000000000 --- a/packages/platforms/inventec/x86-64/d7264q28b/platform-config/Makefile +++ /dev/null @@ -1 +0,0 @@ -include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/inventec/x86-64/d7264q28b/platform-config/r0/Makefile b/packages/platforms/inventec/x86-64/d7264q28b/platform-config/r0/Makefile deleted file mode 100644 index 003238cf6..000000000 --- a/packages/platforms/inventec/x86-64/d7264q28b/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/inventec/x86-64/d7264q28b/platform-config/r0/PKG.yml b/packages/platforms/inventec/x86-64/d7264q28b/platform-config/r0/PKG.yml deleted file mode 100644 index c6c994626..000000000 --- a/packages/platforms/inventec/x86-64/d7264q28b/platform-config/r0/PKG.yml +++ /dev/null @@ -1 +0,0 @@ -!include $ONL_TEMPLATES/platform-config-platform.yml ARCH=amd64 VENDOR=inventec BASENAME=x86-64-inventec-d7264q28b REVISION=r0 diff --git a/packages/platforms/inventec/x86-64/d7264q28b/platform-config/r0/src/lib/x86-64-inventec-d7264q28b-r0.yml b/packages/platforms/inventec/x86-64/d7264q28b/platform-config/r0/src/lib/x86-64-inventec-d7264q28b-r0.yml deleted file mode 100644 index fe6a46433..000000000 --- a/packages/platforms/inventec/x86-64/d7264q28b/platform-config/r0/src/lib/x86-64-inventec-d7264q28b-r0.yml +++ /dev/null @@ -1,31 +0,0 @@ ---- - -###################################################################### -# -# platform-config for d7264q28b -# -###################################################################### - -x86-64-inventec-d7264q28b-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/d7264q28b/platform-config/r0/src/python/x86_64_inventec_d7264q28b_r0/__init__.py b/packages/platforms/inventec/x86-64/d7264q28b/platform-config/r0/src/python/x86_64_inventec_d7264q28b_r0/__init__.py deleted file mode 100644 index 8d459faf4..000000000 --- a/packages/platforms/inventec/x86-64/d7264q28b/platform-config/r0/src/python/x86_64_inventec_d7264q28b_r0/__init__.py +++ /dev/null @@ -1,20 +0,0 @@ -from onl.platform.base import * -from onl.platform.inventec import * - -class OnlPlatform_x86_64_inventec_d7264q28b_r0(OnlPlatformInventec, - OnlPlatformPortConfig_64x100): - PLATFORM='x86-64-inventec-d7264q28b-r0' - MODEL="X86-D7264Q28B" - SYS_OBJECT_ID=".7264.1" - - def baseconfig(self): - os.system("insmod /lib/modules/`uname -r`/kernel/drivers/gpio/gpio-ich.ko") - self.insmod('inv_platform') - self.insmod('inv_psoc') - self.insmod('inv_cpld') - self.new_i2c_device('inv_eeprom', 0x53, 0) - self.insmod('inv_eeprom') - self.insmod('swps') - #self.insmod('vpd') - self.insmod('inv_pthread') - return True diff --git a/packages/platforms/inventec/x86-64/d7332/.gitignore b/packages/platforms/inventec/x86-64/d7332/.gitignore deleted file mode 100644 index 923f53c36..000000000 --- a/packages/platforms/inventec/x86-64/d7332/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -*x86*64*inventec*d7332*.mk -onlpdump.mk diff --git a/packages/platforms/inventec/x86-64/d7332/Makefile b/packages/platforms/inventec/x86-64/d7332/Makefile deleted file mode 100644 index 003238cf6..000000000 --- a/packages/platforms/inventec/x86-64/d7332/Makefile +++ /dev/null @@ -1 +0,0 @@ -include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/inventec/x86-64/d7332/modules/Makefile b/packages/platforms/inventec/x86-64/d7332/modules/Makefile deleted file mode 100644 index 003238cf6..000000000 --- a/packages/platforms/inventec/x86-64/d7332/modules/Makefile +++ /dev/null @@ -1 +0,0 @@ -include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/inventec/x86-64/d7332/modules/PKG.yml b/packages/platforms/inventec/x86-64/d7332/modules/PKG.yml deleted file mode 100644 index 7f9603a48..000000000 --- a/packages/platforms/inventec/x86-64/d7332/modules/PKG.yml +++ /dev/null @@ -1 +0,0 @@ -!include $ONL_TEMPLATES/platform-modules.yml VENDOR=inventec BASENAME=x86-64-inventec-d7332 ARCH=amd64 KERNELS="onl-kernel-4.14-lts-x86-64-all:amd64" diff --git a/packages/platforms/inventec/x86-64/d7332/modules/builds/.gitignore b/packages/platforms/inventec/x86-64/d7332/modules/builds/.gitignore deleted file mode 100644 index 7951405f8..000000000 --- a/packages/platforms/inventec/x86-64/d7332/modules/builds/.gitignore +++ /dev/null @@ -1 +0,0 @@ -lib \ No newline at end of file diff --git a/packages/platforms/inventec/x86-64/d7332/modules/builds/Makefile b/packages/platforms/inventec/x86-64/d7332/modules/builds/Makefile deleted file mode 100644 index f5b60c97c..000000000 --- a/packages/platforms/inventec/x86-64/d7332/modules/builds/Makefile +++ /dev/null @@ -1,6 +0,0 @@ -KERNELS := onl-kernel-4.14-lts-x86-64-all:amd64 -KMODULES := src -VENDOR := inventec -BASENAME := x86-64-inventec-d7332 -ARCH := x86_64 -include $(ONL)/make/kmodule.mk diff --git a/packages/platforms/inventec/x86-64/d7332/modules/builds/src/Makefile b/packages/platforms/inventec/x86-64/d7332/modules/builds/src/Makefile deleted file mode 100644 index d2f050e66..000000000 --- a/packages/platforms/inventec/x86-64/d7332/modules/builds/src/Makefile +++ /dev/null @@ -1,12 +0,0 @@ -obj-m := inv_sff.o -inv_sff-objs := inv_swps.o io_dev.o lc_dev.o sff_eeprom.o sfp.o qsfp.o qsfp_dd.o - -obj-m += i2c-gpio.o -obj-m += inv_platform.o -obj-m += inv-i2c-mux-pca9641.o -obj-m += inv_cpld.o -obj-m += inv_ucd90160.o -obj-m += inv_psu.o -obj-m += vpd.o -obj-m += inv_eeprom.o -vpd-objs := inv_vpd.o onie_tlvinfo.o diff --git a/packages/platforms/inventec/x86-64/d7332/modules/builds/src/eeprom_config/eeprom_config.h b/packages/platforms/inventec/x86-64/d7332/modules/builds/src/eeprom_config/eeprom_config.h deleted file mode 100644 index e0bc2acb4..000000000 --- a/packages/platforms/inventec/x86-64/d7332/modules/builds/src/eeprom_config/eeprom_config.h +++ /dev/null @@ -1,26 +0,0 @@ -#ifndef __EEPROM_CONFIG -#define __EEPROM_CONFIG - -#include "eeprom_config_banyan.h" -#include "eeprom_config_maple.h" -//#include "eeprom_config_cedar.h" -#include "eeprom_config_4U.h" - -struct platform_eeprom_info_t { - int platform_id; - struct eeprom_i2c_tbl_t *tbl; -}; - -struct platform_eeprom_info_t platform_eeprom_info_tbl[] = { - - {.platform_id = PLATFORM_MAPLE, .tbl = &maple_eeprom_i2c_tbl}, - {.platform_id = PLATFORM_BANYAN, .tbl = &banyan_eeprom_i2c_tbl}, - {.platform_id = PLATFORM_4U, .tbl = &banyan_4U_eeprom_i2c_tbl}, -#if 0 - {.platform_id = PLATFORM_CEDAR, .tbl = &cedar_eeprom_i2c_tbl}, -#endif - {.platform_id = PLATFORM_END }, -}; - - -#endif /*__EEPROM_CONFIG*/ diff --git a/packages/platforms/inventec/x86-64/d7332/modules/builds/src/eeprom_config/eeprom_config_4U.h b/packages/platforms/inventec/x86-64/d7332/modules/builds/src/eeprom_config/eeprom_config_4U.h deleted file mode 100644 index a8fb7c43c..000000000 --- a/packages/platforms/inventec/x86-64/d7332/modules/builds/src/eeprom_config/eeprom_config_4U.h +++ /dev/null @@ -1,138 +0,0 @@ -#ifndef __I2C_EEPROM_CONFIG_banyan_4U -#define __I2C_EEPROM_CONFIG_banyan_4U - -struct eeprom_config_t banyan_4U_eeprom_config_map[] = { - {0, 101}, - {1, 102}, - {2, 103}, - {3, 104}, - {4, 105}, - {5, 106}, - {6, 107}, - {7, 108}, - {8, 109}, - {9, 110}, - {10, 111}, - {11, 112}, - {12, 113}, - {13, 114}, - {14, 115}, - {15, 116}, - {16, 117}, - {17, 118}, - {18, 119}, - {19, 120}, - {20, 121}, - {21, 122}, - {22, 123}, - {23, 124}, - {24, 125}, - {25, 126}, - {26, 127}, - {27, 128}, - {28, 129}, - {29, 130}, - {30, 131}, - {31, 132}, - {32, 133}, - {33, 134}, - {34, 135}, - {35, 136}, - {36, 137}, - {37, 138}, - {38, 139}, - {39, 140}, - {40, 141}, - {41, 142}, - {42, 143}, - {43, 144}, - {44, 145}, - {45, 146}, - {46, 147}, - {47, 148}, - {48, 149}, - {49, 150}, - {50, 151}, - {51, 152}, - {52, 153}, - {53, 154}, - {54, 155}, - {55, 156}, - {56, 157}, - {57, 158}, - {58, 159}, - {59, 160}, - {60, 161}, - {61, 162}, - {62, 163}, - {63, 164}, - {64, 165}, - {65, 166}, - {66, 167}, - {67, 168}, - {68, 169}, - {69, 170}, - {70, 171}, - {71, 172}, - {72, 173}, - {73, 174}, - {74, 175}, - {75, 176}, - {76, 177}, - {77, 178}, - {78, 179}, - {79, 180}, - {80, 181}, - {81, 182}, - {82, 183}, - {83, 184}, - {84, 185}, - {85, 186}, - {86, 187}, - {87, 188}, - {88, 189}, - {89, 190}, - {90, 191}, - {91, 192}, - {92, 193}, - {93, 194}, - {94, 195}, - {95, 196}, - {96, 197}, - {97, 198}, - {98, 199}, - {99, 200}, - {100, 201}, - {101, 202}, - {102, 203}, - {103, 204}, - {104, 205}, - {105, 206}, - {106, 207}, - {107, 208}, - {108, 209}, - {109, 210}, - {110, 211}, - {111, 212}, - {112, 213}, - {113, 214}, - {114, 215}, - {115, 216}, - {116, 217}, - {117, 218}, - {118, 219}, - {119, 220}, - {120, 221}, - {121, 222}, - {122, 223}, - {123, 224}, - {124, 225}, - {125, 226}, - {126, 227}, - {127, 228}, -}; -struct eeprom_i2c_tbl_t banyan_4U_eeprom_i2c_tbl = { - .map = banyan_4U_eeprom_config_map, - .size = ARRAY_SIZE(banyan_4U_eeprom_config_map) -}; -#endif /*__I2C_EEPROM_CONFIG_banyan_4U*/ diff --git a/packages/platforms/inventec/x86-64/d7332/modules/builds/src/eeprom_config/eeprom_config_banyan.h b/packages/platforms/inventec/x86-64/d7332/modules/builds/src/eeprom_config/eeprom_config_banyan.h deleted file mode 100644 index 3d6d975a1..000000000 --- a/packages/platforms/inventec/x86-64/d7332/modules/builds/src/eeprom_config/eeprom_config_banyan.h +++ /dev/null @@ -1,50 +0,0 @@ -//port info - -//i2c_eeprom_config_cypress -#ifndef __I2C_EEPROM_CONFIG_BANYAN -#define __I2C_EEPROM_CONFIG_BANYAN - -struct eeprom_config_t banyan_eeprom_config_map[] = { - /*port , i2c_channel*/ - {0, 14}, - {1, 15}, - {2, 16}, - {3, 17}, - {4, 18}, - {5, 19}, - {6, 20}, - {7, 21}, - - {8, 22}, - {9, 23}, - {10, 24}, - {11, 25}, - {12, 26}, - {13, 27}, - {14, 28}, - {15, 29}, - - {16, 30}, - {17, 31}, - {18, 32}, - {19, 33}, - {20, 34}, - {21, 35}, - {22, 36}, - {23, 37}, - - {24, 38}, - {25, 39}, - {26, 40}, - {27, 41}, - {28, 42}, - {29, 43}, - {30, 44}, - {31, 45}, - -}; -struct eeprom_i2c_tbl_t banyan_eeprom_i2c_tbl = { - .map = banyan_eeprom_config_map, - .size = ARRAY_SIZE(banyan_eeprom_config_map) -}; -#endif /*__I2C_EEPROM_CONFIG_BANYAN*/ diff --git a/packages/platforms/inventec/x86-64/d7332/modules/builds/src/eeprom_config/eeprom_config_maple.h b/packages/platforms/inventec/x86-64/d7332/modules/builds/src/eeprom_config/eeprom_config_maple.h deleted file mode 100644 index a5275f590..000000000 --- a/packages/platforms/inventec/x86-64/d7332/modules/builds/src/eeprom_config/eeprom_config_maple.h +++ /dev/null @@ -1,67 +0,0 @@ -#ifndef __I2C_EEPROM_CONFIG_MAPLE -#define __I2C_EEPROM_CONFIG_MAPLE -struct eeprom_config_t maple_eeprom_config_map[] = { -/*port , i2c_channel*/ -{0, 22}, -{1, 23}, -{2, 24}, -{3, 25}, -{4, 26}, -{5, 27}, -{6, 28}, -{7, 29}, -{8, 30}, -{9, 31}, -{10, 32}, -{11, 33}, -{12, 34}, -{13, 35}, -{14, 36}, -{15, 37}, -{16, 38}, -{17, 39}, -{18, 40}, -{19, 41}, -{20, 42}, -{21, 43}, -{22, 44}, -{23, 45}, -{24, 46}, -{25, 47}, -{26, 48}, -{27, 49}, -{28, 50}, -{29, 51}, -{30, 52}, -{31, 53}, -{32, 54}, -{33, 55}, -{34, 56}, -{35, 57}, -{36, 58}, -{37, 59}, -{38, 60}, -{39, 61}, -{40, 62}, -{41, 63}, -{42, 64}, -{43, 65}, -{44, 66}, -{45, 67}, -{46, 68}, -{47, 69}, -{48, 14}, -{49, 15}, -{50, 16}, -{51, 17}, -{52, 18}, -{53, 19}, -{54, 20}, -{55, 21}, - -}; -struct eeprom_i2c_tbl_t maple_eeprom_i2c_tbl = { - .map = maple_eeprom_config_map, - .size = ARRAY_SIZE(maple_eeprom_config_map) -}; -#endif /*__I2C_EEPROM_CONFIG_MAPLE*/ diff --git a/packages/platforms/inventec/x86-64/d7332/modules/builds/src/eeprom_config/i2c_eeprom_config_cypress.h b/packages/platforms/inventec/x86-64/d7332/modules/builds/src/eeprom_config/i2c_eeprom_config_cypress.h deleted file mode 100644 index 28cbb2e9f..000000000 --- a/packages/platforms/inventec/x86-64/d7332/modules/builds/src/eeprom_config/i2c_eeprom_config_cypress.h +++ /dev/null @@ -1,70 +0,0 @@ -//port info - -//i2c_eeprom_config_cypress -#ifndef __I2C_EEPROM_CONFIG_CYPRESS -#define __I2C_EEPROM_CONFIG_CYPRESS - -const struct eeprom_config_t Eeprom_Config_Map[PORT_NUM] = { - /*port , i2c_channel*/ - {0, 11}, - {1, 10}, - {2, 13}, - {3, 12}, - {4, 15}, - {5, 14}, - {6, 17}, - {7, 16}, - - {8, 19}, - {9, 18}, - {10, 21}, - {11, 20}, - {12, 23}, - {13, 22}, - {14, 25}, - {15, 24}, - - {16, 27}, - {17, 26}, - {18, 29}, - {19, 28}, - {20, 31}, - {21, 30}, - {22, 33}, - {23, 32}, - - {24, 35}, - {25, 34}, - {26, 37}, - {27, 36}, - {28, 39}, - {29, 38}, - {30, 41}, - {31, 40}, - - {32, 43}, - {33, 42}, - {34, 45}, - {35, 44}, - {36, 47}, - {37, 46}, - {38, 49}, - {39, 48}, - - {40, 51}, - {41, 50}, - {42, 53}, - {43, 52}, - {44, 55}, - {45, 54}, - {46, 57}, - {47, 56}, - - {48, 59}, - {49, 58}, - {50, 61}, - {51, 60}, - {52, 63}, - {53, 62}, -}; -#endif /*__I2C_EEPROM_CONFIG_CYPRESS*/ diff --git a/packages/platforms/inventec/x86-64/d7332/modules/builds/src/i2c-gpio.c b/packages/platforms/inventec/x86-64/d7332/modules/builds/src/i2c-gpio.c deleted file mode 100644 index 34cfc0ebd..000000000 --- a/packages/platforms/inventec/x86-64/d7332/modules/builds/src/i2c-gpio.c +++ /dev/null @@ -1,290 +0,0 @@ -/* - * Bitbanging I2C bus driver using the GPIO API - * - * Copyright (C) 2007 Atmel Corporation - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. - */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -struct i2c_gpio_private_data { - struct i2c_adapter adap; - struct i2c_algo_bit_data bit_data; - struct i2c_gpio_platform_data pdata; -}; - -/* Toggle SDA by changing the direction of the pin */ -static void i2c_gpio_setsda_dir(void *data, int state) -{ - struct i2c_gpio_platform_data *pdata = data; - - if (state) - gpio_direction_input(pdata->sda_pin); - else - gpio_direction_output(pdata->sda_pin, 0); -} - -/* - * Toggle SDA by changing the output value of the pin. This is only - * valid for pins configured as open drain (i.e. setting the value - * high effectively turns off the output driver.) - */ -static void i2c_gpio_setsda_val(void *data, int state) -{ - struct i2c_gpio_platform_data *pdata = data; - - gpio_set_value(pdata->sda_pin, state); -} - -/* Toggle SCL by changing the direction of the pin. */ -static void i2c_gpio_setscl_dir(void *data, int state) -{ - struct i2c_gpio_platform_data *pdata = data; - - if (state) - gpio_direction_input(pdata->scl_pin); - else - gpio_direction_output(pdata->scl_pin, 0); -} - -/* - * Toggle SCL by changing the output value of the pin. This is used - * for pins that are configured as open drain and for output-only - * pins. The latter case will break the i2c protocol, but it will - * often work in practice. - */ -static void i2c_gpio_setscl_val(void *data, int state) -{ - struct i2c_gpio_platform_data *pdata = data; - - gpio_set_value(pdata->scl_pin, state); -} - -static int i2c_gpio_getsda(void *data) -{ - struct i2c_gpio_platform_data *pdata = data; - - return gpio_get_value(pdata->sda_pin); -} - -static int i2c_gpio_getscl(void *data) -{ - struct i2c_gpio_platform_data *pdata = data; - - return gpio_get_value(pdata->scl_pin); -} - -static int of_i2c_gpio_get_pins(struct device_node *np, - unsigned int *sda_pin, unsigned int *scl_pin) -{ - if (of_gpio_count(np) < 2) - return -ENODEV; - - *sda_pin = of_get_gpio(np, 0); - *scl_pin = of_get_gpio(np, 1); - - if (*sda_pin == -EPROBE_DEFER || *scl_pin == -EPROBE_DEFER) - return -EPROBE_DEFER; - - if (!gpio_is_valid(*sda_pin) || !gpio_is_valid(*scl_pin)) { - pr_err("%s: invalid GPIO pins, sda=%d/scl=%d\n", - np->full_name, *sda_pin, *scl_pin); - return -ENODEV; - } - - return 0; -} - -static void of_i2c_gpio_get_props(struct device_node *np, - struct i2c_gpio_platform_data *pdata) -{ - u32 reg; - - of_property_read_u32(np, "i2c-gpio,delay-us", &pdata->udelay); - - if (!of_property_read_u32(np, "i2c-gpio,timeout-ms", ®)) - pdata->timeout = msecs_to_jiffies(reg); - - pdata->sda_is_open_drain = - of_property_read_bool(np, "i2c-gpio,sda-open-drain"); - pdata->scl_is_open_drain = - of_property_read_bool(np, "i2c-gpio,scl-open-drain"); - pdata->scl_is_output_only = - of_property_read_bool(np, "i2c-gpio,scl-output-only"); -} - -static int i2c_gpio_probe(struct platform_device *pdev) -{ - struct i2c_gpio_private_data *priv; - struct i2c_gpio_platform_data *pdata; - struct i2c_algo_bit_data *bit_data; - struct i2c_adapter *adap; - unsigned int sda_pin, scl_pin; - int ret; - - /* First get the GPIO pins; if it fails, we'll defer the probe. */ - if (pdev->dev.of_node) { - ret = of_i2c_gpio_get_pins(pdev->dev.of_node, - &sda_pin, &scl_pin); - if (ret) - return ret; - } else { - if (!dev_get_platdata(&pdev->dev)) - return -ENXIO; - pdata = dev_get_platdata(&pdev->dev); - sda_pin = pdata->sda_pin; - scl_pin = pdata->scl_pin; - } - - ret = devm_gpio_request(&pdev->dev, sda_pin, "sda"); - if (ret) { - if (ret == -EINVAL) - ret = -EPROBE_DEFER; /* Try again later */ - return ret; - } - ret = devm_gpio_request(&pdev->dev, scl_pin, "scl"); - if (ret) { - if (ret == -EINVAL) - ret = -EPROBE_DEFER; /* Try again later */ - return ret; - } - - priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL); - if (!priv) - return -ENOMEM; - adap = &priv->adap; - bit_data = &priv->bit_data; - pdata = &priv->pdata; - - if (pdev->dev.of_node) { - pdata->sda_pin = sda_pin; - pdata->scl_pin = scl_pin; - of_i2c_gpio_get_props(pdev->dev.of_node, pdata); - } else { - memcpy(pdata, dev_get_platdata(&pdev->dev), sizeof(*pdata)); - } - - if (pdata->sda_is_open_drain) { - gpio_direction_output(pdata->sda_pin, 1); - bit_data->setsda = i2c_gpio_setsda_val; - } else { - gpio_direction_input(pdata->sda_pin); - bit_data->setsda = i2c_gpio_setsda_dir; - } - - if (pdata->scl_is_open_drain || pdata->scl_is_output_only) { - gpio_direction_output(pdata->scl_pin, 1); - bit_data->setscl = i2c_gpio_setscl_val; - } else { - gpio_direction_input(pdata->scl_pin); - bit_data->setscl = i2c_gpio_setscl_dir; - } - - if (!pdata->scl_is_output_only) - bit_data->getscl = i2c_gpio_getscl; - bit_data->getsda = i2c_gpio_getsda; - - if (pdata->udelay) - bit_data->udelay = pdata->udelay; - else if (pdata->scl_is_output_only) - bit_data->udelay = 50; /* 10 kHz */ - else - bit_data->udelay = 5; /* 100 kHz */ - - if (pdata->timeout) - bit_data->timeout = pdata->timeout; - else - bit_data->timeout = HZ / 10; /* 100 ms */ - - bit_data->data = pdata; - - adap->owner = THIS_MODULE; - if (pdev->dev.of_node) - strlcpy(adap->name, dev_name(&pdev->dev), sizeof(adap->name)); - else - snprintf(adap->name, sizeof(adap->name), "i2c-gpio%d", pdev->id); - - adap->algo_data = bit_data; - adap->class = I2C_CLASS_HWMON | I2C_CLASS_SPD; - adap->dev.parent = &pdev->dev; - adap->dev.of_node = pdev->dev.of_node; - - adap->nr = pdev->id; - ret = i2c_bit_add_numbered_bus(adap); - if (ret) - return ret; - - platform_set_drvdata(pdev, priv); - - dev_info(&pdev->dev, "using pins %u (SDA) and %u (SCL%s)\n", - pdata->sda_pin, pdata->scl_pin, - pdata->scl_is_output_only - ? ", no clock stretching" : ""); - - return 0; -} - -static int i2c_gpio_remove(struct platform_device *pdev) -{ - struct i2c_gpio_private_data *priv; - struct i2c_adapter *adap; - - priv = platform_get_drvdata(pdev); - adap = &priv->adap; - - i2c_del_adapter(adap); - - return 0; -} - -#if defined(CONFIG_OF) -static const struct of_device_id i2c_gpio_dt_ids[] = { - { .compatible = "i2c-gpio", }, - { /* sentinel */ } -}; - -MODULE_DEVICE_TABLE(of, i2c_gpio_dt_ids); -#endif - -static struct platform_driver i2c_gpio_driver = { - .driver = { - .name = "i2c-gpio", - .of_match_table = of_match_ptr(i2c_gpio_dt_ids), - }, - .probe = i2c_gpio_probe, - .remove = i2c_gpio_remove, -}; - -static int __init i2c_gpio_init(void) -{ - int ret; - - ret = platform_driver_register(&i2c_gpio_driver); - if (ret) - printk(KERN_ERR "i2c-gpio: probe failed: %d\n", ret); - - return ret; -} -subsys_initcall(i2c_gpio_init); - -static void __exit i2c_gpio_exit(void) -{ - platform_driver_unregister(&i2c_gpio_driver); -} -module_exit(i2c_gpio_exit); - -MODULE_AUTHOR("Haavard Skinnemoen (Atmel)"); -MODULE_DESCRIPTION("Platform-independent bitbanging I2C driver"); -MODULE_LICENSE("GPL"); -MODULE_ALIAS("platform:i2c-gpio"); diff --git a/packages/platforms/inventec/x86-64/d7332/modules/builds/src/inv-i2c-mux-pca9641.c b/packages/platforms/inventec/x86-64/d7332/modules/builds/src/inv-i2c-mux-pca9641.c deleted file mode 100644 index 00cf9ebda..000000000 --- a/packages/platforms/inventec/x86-64/d7332/modules/builds/src/inv-i2c-mux-pca9641.c +++ /dev/null @@ -1,573 +0,0 @@ -/* - * I2C multiplexer driver for PCA9541 bus master selector - * - * Copyright (c) 2010 Ericsson AB. - * - * Author: Guenter Roeck - * - * Derived from: - * pca954x.c - * - * Copyright (c) 2008-2009 Rodolfo Giometti - * Copyright (c) 2008-2009 Eurotech S.p.A. - * - * 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 - -/* - * The PCA9541 is a bus master selector. It supports two I2C masters connected - * to a single slave bus. - * - * Before each bus transaction, a master has to acquire bus ownership. After the - * transaction is complete, bus ownership has to be released. This fits well - * into the I2C multiplexer framework, which provides select and release - * functions for this purpose. For this reason, this driver is modeled as - * single-channel I2C bus multiplexer. - * - * This driver assumes that the two bus masters are controlled by two different - * hosts. If a single host controls both masters, platform code has to ensure - * that only one of the masters is instantiated at any given time. - */ - -#define PCA9541_CONTROL 0x01 -#define PCA9541_ISTAT 0x02 - -#define PCA9541_CTL_MYBUS (1 << 0) -#define PCA9541_CTL_NMYBUS (1 << 1) -#define PCA9541_CTL_BUSON (1 << 2) -#define PCA9541_CTL_NBUSON (1 << 3) -#define PCA9541_CTL_BUSINIT (1 << 4) -#define PCA9541_CTL_TESTON (1 << 6) -#define PCA9541_CTL_NTESTON (1 << 7) - -#define PCA9541_ISTAT_INTIN (1 << 0) -#define PCA9541_ISTAT_BUSINIT (1 << 1) -#define PCA9541_ISTAT_BUSOK (1 << 2) -#define PCA9541_ISTAT_BUSLOST (1 << 3) -#define PCA9541_ISTAT_MYTEST (1 << 6) -#define PCA9541_ISTAT_NMYTEST (1 << 7) - -#define PCA9641_ID 0x00 -#define PCA9641_ID_MAGIC 0x38 - -#define PCA9641_CONTROL 0x01 -#define PCA9641_STATUS 0x02 -#define PCA9641_TIME 0x03 - -#define PCA9641_CTL_LOCK_REQ BIT(0) -#define PCA9641_CTL_LOCK_GRANT BIT(1) -#define PCA9641_CTL_BUS_CONNECT BIT(2) -#define PCA9641_CTL_BUS_INIT BIT(3) -#define PCA9641_CTL_SMBUS_SWRST BIT(4) -#define PCA9641_CTL_IDLE_TIMER_DIS BIT(5) -#define PCA9641_CTL_SMBUS_DIS BIT(6) -#define PCA9641_CTL_PRIORITY BIT(7) - -#define PCA9641_STS_OTHER_LOCK BIT(0) -#define PCA9641_STS_BUS_INIT_FAIL BIT(1) -#define PCA9641_STS_BUS_HUNG BIT(2) -#define PCA9641_STS_MBOX_EMPTY BIT(3) -#define PCA9641_STS_MBOX_FULL BIT(4) -#define PCA9641_STS_TEST_INT BIT(5) -#define PCA9641_STS_SCL_IO BIT(6) -#define PCA9641_STS_SDA_IO BIT(7) - -#define PCA9641_RES_TIME 0x03 - - -#define BUSON (PCA9541_CTL_BUSON | PCA9541_CTL_NBUSON) -#define MYBUS (PCA9541_CTL_MYBUS | PCA9541_CTL_NMYBUS) -#define mybus(x) (!((x) & MYBUS) || ((x) & MYBUS) == MYBUS) -#define busoff(x) (!((x) & BUSON) || ((x) & BUSON) == BUSON) - -#define BUSOFF(x, y) (!((x) & PCA9641_CTL_LOCK_GRANT) && \ - !((y) & PCA9641_STS_OTHER_LOCK)) -#define other_lock(x) ((x) & PCA9641_STS_OTHER_LOCK) -#define lock_grant(x) ((x) & PCA9641_CTL_LOCK_GRANT) - -/* arbitration timeouts, in jiffies */ -#define ARB_TIMEOUT (HZ / 8) /* 125 ms until forcing bus ownership */ -#define ARB2_TIMEOUT (HZ / 4) /* 250 ms until acquisition failure */ - -/* arbitration retry delays, in us */ -#define SELECT_DELAY_SHORT 50 -#define SELECT_DELAY_LONG 1000 - -struct pca9541 { - struct i2c_client *client; - unsigned long select_timeout; - unsigned long arb_timeout; -}; - -static const struct i2c_device_id pca9641_id[] = { - //{"pca9541", 0}, - {"pca9641", 1}, - {} -}; - -MODULE_DEVICE_TABLE(i2c, pca9641_id); - -#ifdef CONFIG_OF -static const struct of_device_id pca9641_of_match[] = { - //{ .compatible = "nxp,pca9541" }, - { .compatible = "nxp,pca9641" }, - {} -}; -#endif - -/* - * Write to chip register. Don't use i2c_transfer()/i2c_smbus_xfer() - * as they will try to lock the adapter a second time. - */ -static int pca9541_reg_write(struct i2c_client *client, u8 command, u8 val) -{ - struct i2c_adapter *adap = client->adapter; - int ret; - - if (adap->algo->master_xfer) { - struct i2c_msg msg; - char buf[2]; - - msg.addr = client->addr; - msg.flags = 0; - msg.len = 2; - buf[0] = command; - buf[1] = val; - msg.buf = buf; - ret = __i2c_transfer(adap, &msg, 1); - } else { - union i2c_smbus_data data; - - data.byte = val; - ret = adap->algo->smbus_xfer(adap, client->addr, - client->flags, - I2C_SMBUS_WRITE, - command, - I2C_SMBUS_BYTE_DATA, &data); - } - - return ret; -} - -/* - * Read from chip register. Don't use i2c_transfer()/i2c_smbus_xfer() - * as they will try to lock adapter a second time. - */ -static int pca9541_reg_read(struct i2c_client *client, u8 command) -{ - struct i2c_adapter *adap = client->adapter; - int ret; - u8 val; - - if (adap->algo->master_xfer) { - struct i2c_msg msg[2] = { - { - .addr = client->addr, - .flags = 0, - .len = 1, - .buf = &command - }, - { - .addr = client->addr, - .flags = I2C_M_RD, - .len = 1, - .buf = &val - } - }; - ret = __i2c_transfer(adap, msg, 2); - if (ret == 2) - ret = val; - else if (ret >= 0) - ret = -EIO; - } else { - union i2c_smbus_data data; - - ret = adap->algo->smbus_xfer(adap, client->addr, - client->flags, - I2C_SMBUS_READ, - command, - I2C_SMBUS_BYTE_DATA, &data); - if (!ret) - ret = data.byte; - } - return ret; -} - -/* - * Arbitration management functions - */ - -/* Release bus. Also reset NTESTON and BUSINIT if it was set. */ -static void pca9541_release_bus(struct i2c_client *client) -{ - int reg; - - reg = pca9541_reg_read(client, PCA9541_CONTROL); - if (reg >= 0 && !busoff(reg) && mybus(reg)) - pca9541_reg_write(client, PCA9541_CONTROL, - (reg & PCA9541_CTL_NBUSON) >> 1); -} - -/* - * Arbitration is defined as a two-step process. A bus master can only activate - * the slave bus if it owns it; otherwise it has to request ownership first. - * This multi-step process ensures that access contention is resolved - * gracefully. - * - * Bus Ownership Other master Action - * state requested access - * ---------------------------------------------------- - * off - yes wait for arbitration timeout or - * for other master to drop request - * off no no take ownership - * off yes no turn on bus - * on yes - done - * on no - wait for arbitration timeout or - * for other master to release bus - * - * The main contention point occurs if the slave bus is off and both masters - * request ownership at the same time. In this case, one master will turn on - * the slave bus, believing that it owns it. The other master will request - * bus ownership. Result is that the bus is turned on, and master which did - * _not_ own the slave bus before ends up owning it. - */ - -/* Control commands per PCA9541 datasheet */ -static const u8 pca9541_control[16] = { - 4, 0, 1, 5, 4, 4, 5, 5, 0, 0, 1, 1, 0, 4, 5, 1 -}; - -/* - * Channel arbitration - * - * Return values: - * <0: error - * 0 : bus not acquired - * 1 : bus acquired - */ -static int pca9541_arbitrate(struct i2c_client *client) -{ - struct i2c_mux_core *muxc = i2c_get_clientdata(client); - struct pca9541 *data = i2c_mux_priv(muxc); - int reg; - - reg = pca9541_reg_read(client, PCA9541_CONTROL); - if (reg < 0) - return reg; - - if (busoff(reg)) { - int istat; - /* - * Bus is off. Request ownership or turn it on unless - * other master requested ownership. - */ - istat = pca9541_reg_read(client, PCA9541_ISTAT); - if (!(istat & PCA9541_ISTAT_NMYTEST) - || time_is_before_eq_jiffies(data->arb_timeout)) { - /* - * Other master did not request ownership, - * or arbitration timeout expired. Take the bus. - */ - pca9541_reg_write(client, - PCA9541_CONTROL, - pca9541_control[reg & 0x0f] - | PCA9541_CTL_NTESTON); - data->select_timeout = SELECT_DELAY_SHORT; - } else { - /* - * Other master requested ownership. - * Set extra long timeout to give it time to acquire it. - */ - data->select_timeout = SELECT_DELAY_LONG * 2; - } - } else if (mybus(reg)) { - /* - * Bus is on, and we own it. We are done with acquisition. - * Reset NTESTON and BUSINIT, then return success. - */ - if (reg & (PCA9541_CTL_NTESTON | PCA9541_CTL_BUSINIT)) - pca9541_reg_write(client, - PCA9541_CONTROL, - reg & ~(PCA9541_CTL_NTESTON - | PCA9541_CTL_BUSINIT)); - return 1; - } else { - /* - * Other master owns the bus. - * If arbitration timeout has expired, force ownership. - * Otherwise request it. - */ - data->select_timeout = SELECT_DELAY_LONG; - if (time_is_before_eq_jiffies(data->arb_timeout)) { - /* Time is up, take the bus and reset it. */ - pca9541_reg_write(client, - PCA9541_CONTROL, - pca9541_control[reg & 0x0f] - | PCA9541_CTL_BUSINIT - | PCA9541_CTL_NTESTON); - } else { - /* Request bus ownership if needed */ - if (!(reg & PCA9541_CTL_NTESTON)) - pca9541_reg_write(client, - PCA9541_CONTROL, - reg | PCA9541_CTL_NTESTON); - } - } - return 0; -} - -static int pca9541_select_chan(struct i2c_mux_core *muxc, u32 chan) -{ - struct pca9541 *data = i2c_mux_priv(muxc); - struct i2c_client *client = data->client; - int ret; - unsigned long timeout = jiffies + ARB2_TIMEOUT; - /* give up after this time */ - - data->arb_timeout = jiffies + ARB_TIMEOUT; - /* force bus ownership after this time */ - - do { - ret = pca9541_arbitrate(client); - if (ret) - return ret < 0 ? ret : 0; - - if (data->select_timeout == SELECT_DELAY_SHORT) - udelay(data->select_timeout); - else - msleep(data->select_timeout / 1000); - } while (time_is_after_eq_jiffies(timeout)); - - return -ETIMEDOUT; -} - -static int pca9541_release_chan(struct i2c_mux_core *muxc, u32 chan) -{ - struct pca9541 *data = i2c_mux_priv(muxc); - struct i2c_client *client = data->client; - - pca9541_release_bus(client); - return 0; -} - -/* - * Arbitration management functions - */ -static void pca9641_release_bus(struct i2c_client *client) -{ - pca9541_reg_write(client, PCA9641_CONTROL, 0); -} - -/* - * Channel arbitration - * - * Return values: - * <0: error - * 0 : bus not acquired - * 1 : bus acquired - */ -static int pca9641_arbitrate(struct i2c_client *client) -{ - struct i2c_mux_core *muxc = i2c_get_clientdata(client); - struct pca9541 *data = i2c_mux_priv(muxc); - int reg_ctl, reg_sts; - - reg_ctl = pca9541_reg_read(client, PCA9641_CONTROL); - if (reg_ctl < 0) - return reg_ctl; - reg_sts = pca9541_reg_read(client, PCA9641_STATUS); - - if (BUSOFF(reg_ctl, reg_sts)) { - /* - * Bus is off. Request ownership or turn it on unless - * other master requested ownership. - */ - reg_ctl |= PCA9641_CTL_LOCK_REQ | PCA9641_CTL_IDLE_TIMER_DIS | PCA9641_CTL_SMBUS_DIS; - pca9541_reg_write(client, PCA9641_CONTROL, reg_ctl); - reg_ctl = pca9541_reg_read(client, PCA9641_CONTROL); - - if (lock_grant(reg_ctl)) { - /* - * Other master did not request ownership, - * or arbitration timeout expired. Take the bus. - */ - reg_ctl |= PCA9641_CTL_BUS_CONNECT - | PCA9641_CTL_LOCK_REQ; - pca9541_reg_write(client, PCA9641_CONTROL, reg_ctl); - data->select_timeout = SELECT_DELAY_SHORT; - - return 1; - } else { - /* - * Other master requested ownership. - * Set extra long timeout to give it time to acquire it. - */ - data->select_timeout = SELECT_DELAY_LONG * 2; - } - } else if (lock_grant(reg_ctl)) { - /* - * Bus is on, and we own it. We are done with acquisition. - */ - reg_ctl |= PCA9641_CTL_BUS_CONNECT | PCA9641_CTL_LOCK_REQ; - pca9541_reg_write(client, PCA9641_CONTROL, reg_ctl); - - return 1; - } else if (other_lock(reg_sts)) { - /* - * Other master owns the bus. - * If arbitration timeout has expired, force ownership. - * Otherwise request it. - */ - data->select_timeout = SELECT_DELAY_LONG; - reg_ctl |= PCA9641_CTL_LOCK_REQ; - pca9541_reg_write(client, PCA9641_CONTROL, reg_ctl); - } - return 0; -} - -static int pca9641_select_chan(struct i2c_mux_core *muxc, u32 chan) -{ - struct pca9541 *data = i2c_mux_priv(muxc); - struct i2c_client *client = data->client; - int ret; - unsigned long timeout = jiffies + ARB2_TIMEOUT; - /* give up after this time */ - - data->arb_timeout = jiffies + ARB_TIMEOUT; - /* force bus ownership after this time */ - - do { - ret = pca9641_arbitrate(client); - if (ret) - return ret < 0 ? ret : 0; - - if (data->select_timeout == SELECT_DELAY_SHORT) - udelay(data->select_timeout); - else - msleep(data->select_timeout / 1000); - } while (time_is_after_eq_jiffies(timeout)); - - return -ETIMEDOUT; -} - -static int pca9641_release_chan(struct i2c_mux_core *muxc, u32 chan) -{ - struct pca9541 *data = i2c_mux_priv(muxc); - struct i2c_client *client = data->client; - - pca9641_release_bus(client); - return 0; -} - -static int pca9641_detect_id(struct i2c_client *client) -{ - int reg; - - reg = pca9541_reg_read(client, PCA9641_ID); - if (reg == PCA9641_ID_MAGIC) - return 1; - else - return 0; -} - -/* - * I2C init/probing/exit functions - */ -static int pca9641_probe(struct i2c_client *client, - const struct i2c_device_id *id) -{ - struct i2c_adapter *adap = client->adapter; - struct pca954x_platform_data *pdata = dev_get_platdata(&client->dev); - struct i2c_mux_core *muxc; - struct pca9541 *data; - int force; - int ret; - int detect_id; - - if (!i2c_check_functionality(adap, I2C_FUNC_SMBUS_BYTE_DATA)) - return -ENODEV; - - detect_id = pca9641_detect_id(client); - /* - * I2C accesses are unprotected here. - * We have to lock the adapter before releasing the bus. - */ - if (detect_id == 0) { - i2c_lock_adapter(adap); - pca9541_release_bus(client); - i2c_unlock_adapter(adap); - } else { - i2c_lock_adapter(adap); - pca9641_release_bus(client); - i2c_unlock_adapter(adap); - } - - /* Create mux adapter */ - - force = 0; - if (pdata) - force = pdata->modes[0].adap_id; - if (detect_id == 0) { - muxc = i2c_mux_alloc(adap, &client->dev, 1, sizeof(*data), - I2C_MUX_ARBITRATOR, - pca9541_select_chan, pca9541_release_chan); - } else { - muxc = i2c_mux_alloc(adap, &client->dev, 1, sizeof(*data), - I2C_MUX_ARBITRATOR, - pca9641_select_chan, pca9641_release_chan); - } - if (!muxc) - return -ENOMEM; - - data = i2c_mux_priv(muxc); - data->client = client; - - i2c_set_clientdata(client, muxc); - - ret = i2c_mux_add_adapter(muxc, force, 0, 0); - if (ret) { - dev_err(&client->dev, "failed to register master selector\n"); - return ret; - } - - dev_info(&client->dev, "registered master selector for I2C %s\n", - client->name); - - return 0; -} - -static int pca9641_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 pca9641_driver = { - .driver = { - .name = "pca9641", - .of_match_table = of_match_ptr(pca9641_of_match), - }, - .probe = pca9641_probe, - .remove = pca9641_remove, - .id_table = pca9641_id, -}; - -module_i2c_driver(pca9641_driver); - -MODULE_AUTHOR("Guenter Roeck "); -MODULE_DESCRIPTION("PCA9641 I2C master selector driver"); -MODULE_LICENSE("GPL v2"); diff --git a/packages/platforms/inventec/x86-64/d7332/modules/builds/src/inv_cpld.c b/packages/platforms/inventec/x86-64/d7332/modules/builds/src/inv_cpld.c deleted file mode 100644 index 8c23d2816..000000000 --- a/packages/platforms/inventec/x86-64/d7332/modules/builds/src/inv_cpld.c +++ /dev/null @@ -1,781 +0,0 @@ -/* - * 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 -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -/* definition */ -#define CPLD_INFO_OFFSET 0x00 -#define CPLD_BIOSCS_OFFSET 0x04 -#define CPLD_PSU_OFFSET 0x08 -#define CPLD_CTL_OFFSET 0x0C -#define CPLD_SYSLED_OFFSET 0x0E -#define CPLD_PWM_OFFSET 0x40 -#define CPLD_RPM_OFFSET 0x46 -#define CPLD_FANSTATUS_OFFSET 0x5E -#define CPLD_FANLED_OFFSET 0x60 -#define CPLD2_ADDRESS 0x33 - -#define FAN_NUM 6 -static u8 hasCPLD2 = 1; -static struct i2c_client *client2; - -/* Each client has this additional data */ -struct cpld_data { - struct device *hwmon_dev; - struct mutex update_lock; - u8 diag; - struct task_struct *tsk; -}; - -/*-----------------------------------------------------------------------*/ -static ssize_t cpld_i2c_read(struct i2c_client *client, u8 *buf, u8 offset, size_t count) -{ - int i; - s32 temp = 0; - - for(i=0; iuser_msg_data; - - if(recv_msg->msg.data[0]==0 && recv_msg->msg.data_len>0) { - msg_result->result_length=recv_msg->msg.data_len-1; - memcpy(msg_result->result, &recv_msg->msg.data[1], recv_msg->msg.data_len-1); - } - ipmi_free_recv_msg(recv_msg); - mutex_unlock(&ipmi_mutex); - - return; -} - -int start_ipmi_command(char NetFn, char cmd,char *data,int data_length, char* result, int* result_length) -{ - int rv=0,i; - int timeout; - - //wait previous command finish at least 50msec - timeout=50; - while((mutex_is_locked(&ipmi_mutex) == 1 || (mutex_is_locked(&ipmi2_mutex) == 1)) && (--timeout)>0) { usleep_range(1000,1010); } - if(timeout==0) { return -1; } - mutex_lock(&ipmi_mutex); - mutex_lock(&ipmi2_mutex); - - if(ipmi_mh_user == NULL) { - for (i=0,rv=1; i0) { usleep_range(1000,1100);} - if(timeout==0) { - mutex_unlock(&ipmi2_mutex); - return -1; - } - else { - *result_length=ipmiresult.result_length; - memcpy(result,ipmiresult.result,*result_length); - mutex_unlock(&ipmi2_mutex); - return 0; - } - } - return 0; -} -EXPORT_SYMBOL(start_ipmi_command); - -static int cpld_thread(void *p) -{ - u8 byte[9]; - uint8_t result[MAX_IPMI_RECV_LENGTH]; - int result_len=0; - - //Disable BMC Watchdog - byte[0]=0x04; - byte[1]=0x00; - byte[2]=0x00; - byte[3]=0x00; - byte[4]=0x2C; - byte[5]=0x01; - start_ipmi_command(0x06, 0x24, byte, 6, result, &result_len); - return 0; -} - -/*-----------------------------------------------------------------------*/ -/* sysfs attributes for hwmon */ -static ssize_t show_info(struct device *dev, struct device_attribute *da, - char *buf) -{ - struct i2c_client *client = to_i2c_client(dev); - struct cpld_data *data = i2c_get_clientdata(client); - ssize_t len = 0; - - u8 byte[4] = {0,0,0,0}; - - mutex_lock(&data->update_lock); - len = cpld_i2c_read(client, byte, CPLD_INFO_OFFSET, 4); - mutex_unlock(&data->update_lock); - if (len==0) return 0; - - sprintf (buf, "The CPLD release date is %02d/%02d/%d.\n", - byte[2] & 0xf, (byte[3] & 0x1f), 2014+(byte[2] >> 4)); /* mm/dd/yyyy*/ - sprintf (buf, "%sThe PCB version is %X\n", buf, byte[0]&0xf); - sprintf (buf, "%sThe CPLD version is %d.%d\n", buf, byte[1]>>4, byte[1]&0xf); - - if(hasCPLD2) { - mutex_lock(&data->update_lock); - cpld_i2c_read(client2, byte, CPLD_INFO_OFFSET, 4); - mutex_unlock(&data->update_lock); - - sprintf (buf, "%s\nThe CPLD2 release date is %02d/%02d/%d.\n", buf, - byte[2] & 0xf, (byte[3] & 0x1f), 2014+(byte[2] >> 4)); /* mm/dd/yyyy*/ - sprintf (buf, "%sThe CPLD version is %d.%d\n", buf, byte[1]>>4, byte[1]&0xf); - } - - return strlen(buf); -} - -static char* powerstatus_str[] = { - "Failed", //0 - "Good", //1 -}; - -static ssize_t show_diag(struct device *dev, struct device_attribute *da, - char *buf) -{ - struct i2c_client *client = to_i2c_client(dev); - struct cpld_data *data = i2c_get_clientdata(client); - uint8_t ipmisend[]= { IPMI_DIAGFLAG_OFFSET, 1}; - uint8_t result[MAX_IPMI_RECV_LENGTH]; - int result_len=0; - start_ipmi_command(NETFN_OEM, CMD_GETDATA,ipmisend, 2, result, &result_len); - data->diag = (result[0] & 0x80) !=0; - return sprintf (buf, "%d\n", data->diag); -} - -static ssize_t set_diag(struct device *dev, - struct device_attribute *da, - const char *buf, size_t count) -{ - struct i2c_client *client = to_i2c_client(dev); - struct cpld_data *data = i2c_get_clientdata(client); - uint8_t ipmisend[]= { IPMI_DIAGFLAG_OFFSET, 0x80}; - uint8_t result[MAX_IPMI_RECV_LENGTH]; - int result_len=0; - u8 diag = simple_strtol(buf, NULL, 10); - data->diag = diag?1:0; - if (data->diag==0) ipmisend[1] = 0x00; - - start_ipmi_command(NETFN_OEM, CMD_SETDATA,ipmisend, 2, result, &result_len); - - return count; -} - -static char* bios_str[] = { - "BIOS1", //0 - "BIOS2", //1 -}; - -static ssize_t show_bios_cs(struct device *dev, struct device_attribute *da, - char *buf) -{ - struct i2c_client *client = to_i2c_client(dev); - struct cpld_data *data = i2c_get_clientdata(client); - ssize_t len = 0; - u8 byte = 0; - - mutex_lock(&data->update_lock); - len = cpld_i2c_read(client, &byte, CPLD_BIOSCS_OFFSET, 1); - mutex_unlock(&data->update_lock); - if (len==0) return 0; - - byte &= 0x01; - - return sprintf (buf, "%d:%s\n", byte,bios_str[byte]); -} - -static ssize_t set_bios_cs(struct device *dev, - struct device_attribute *da, - const char *buf, size_t count) -{ - struct i2c_client *client = to_i2c_client(dev); - struct cpld_data *data = i2c_get_clientdata(client); - u8 byte = 0; - u8 temp = simple_strtol(buf, NULL, 10); - - mutex_lock(&data->update_lock); - cpld_i2c_read(client, &byte, CPLD_BIOSCS_OFFSET, 1); - if(temp) byte |= 0x01; else byte &= ~(0x01); - cpld_i2c_write(client, &byte, CPLD_BIOSCS_OFFSET, 1); - mutex_unlock(&data->update_lock); - - return count; -} - -static char* sysled_str[] = { - "OFF", //000 - "0.5 Hz", //001 - "1 Hz", //010 - "2 Hz", //011 - "4 Hz", //100 - "NA", //101 - "NA", //110 - "ON", //111 -}; - -static ssize_t show_sysled(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)?4:0; - - mutex_lock(&data->update_lock); - status = cpld_i2c_read(client, &byte, CPLD_SYSLED_OFFSET, 1); - mutex_unlock(&data->update_lock); - - byte = (byte >> shift) & 0x7; - status = sprintf (buf, "%d:%s\n", byte, sysled_str[byte]); - - return strlen(buf); -} - -static ssize_t set_sysled(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)?4:0; - - temp &= 0x7; - - mutex_lock(&data->update_lock); - cpld_i2c_read(client, &byte, CPLD_SYSLED_OFFSET, 1); - byte &= ~(0x7<update_lock); - - return count; -} - -static char* psu_str[] = { - "normal", //000 - "NA", //001 - "unpowered", //010 - "NA", //011 - "psu fault", //100 - "NA", //101 - "NA", //110 - "not installed", //111 -}; - -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 cpld_data *data = i2c_get_clientdata(client); - ssize_t len = 0; - u8 byte=0; - int shift = (attr->index == 0)?0:4; - - mutex_lock(&data->update_lock); - len = cpld_i2c_read(client, &byte, CPLD_PSU_OFFSET, 1); - mutex_unlock(&data->update_lock); - if (len==0) return 0; - - byte = (byte >> shift) & 0x7; - - return sprintf (buf, "%d:%s\n", byte, psu_str[byte]); -} - -static ssize_t show_pwm(struct device *dev, struct device_attribute *da, - char *buf) -{ - struct sensor_device_attribute *attr = to_sensor_dev_attr(da); - struct i2c_client *client = to_i2c_client(dev); - struct cpld_data *data = i2c_get_clientdata(client); - ssize_t len = 0; - u8 byte=0; - u8 offset = attr->index + CPLD_PWM_OFFSET; - - mutex_lock(&data->update_lock); - len = cpld_i2c_read(client, &byte, offset, 1); - mutex_unlock(&data->update_lock); - if (len==0) return 0; - - return sprintf(buf, "%d\n", byte); -} - -static ssize_t set_pwm(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 cpld_data *data = i2c_get_clientdata(client); - u8 offset = attr->index + CPLD_PWM_OFFSET; - u8 byte = simple_strtol(buf, NULL, 10); - - mutex_lock(&data->update_lock); - cpld_i2c_write(client, &byte, offset, 1); - mutex_unlock(&data->update_lock); - - return count; -} - -static ssize_t show_rpm(struct device *dev, struct device_attribute *da, - char *buf) -{ - struct sensor_device_attribute *attr = to_sensor_dev_attr(da); - struct i2c_client *client = to_i2c_client(dev); - struct cpld_data *data = i2c_get_clientdata(client); - ssize_t len = 0; - u8 offset = attr->index*2 + CPLD_RPM_OFFSET; - u8 byte[2] = {0,0}; - - mutex_lock(&data->update_lock); - len = cpld_i2c_read(client, byte, offset, 2); - mutex_unlock(&data->update_lock); - if (len==0) return 0; - - return sprintf(buf, "%d\n", (byte[0]<<8 | byte[1])); -} - -static char* fantype_str[] = { - "Normal Type", //00 - "REVERSAL Type", //01 - "UNPLUGGED", //10 - "UNPLUGGED", //11 -}; - -static ssize_t show_fantype(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 cpld_data *data = i2c_get_clientdata(client); - ssize_t len = 0; - u8 offset = CPLD_FANSTATUS_OFFSET; - u8 byte[2] = {0,0}; - - mutex_lock(&data->update_lock); - len = cpld_i2c_read(client, byte, offset, 2); - mutex_unlock(&data->update_lock); - if (len==0) return 0; - status = (((byte[0] >> attr->index) & 0x01)) | (((byte[1] >> attr->index) & 0x01)<<1); - - return sprintf(buf, "%d:%s\n",status,fantype_str[status]); -} - -static char* fanled_str[] = { - "None", //00 - "Green", //01 - "Red", //10 - "Both", //11 -}; - -static ssize_t show_fanled(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 cpld_data *data = i2c_get_clientdata(client); - ssize_t len = 0; - u8 byte[2] = {0,0}; - - mutex_lock(&data->update_lock); - len = cpld_i2c_read(client, byte, CPLD_FANLED_OFFSET, 2); - mutex_unlock(&data->update_lock); - if (len==0) return 0; - status = (((byte[0] >> attr->index) & 0x01)) | (((byte[1] >> attr->index) & 0x01)<<1); - - return sprintf(buf, "%d:%s\n",status,fanled_str[status]); -} - -static ssize_t set_fanled(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 cpld_data *data = i2c_get_clientdata(client); - u8 byte[2] = {0,0}; - u8 temp = simple_strtol(buf, NULL, 16); - int shift = attr->index; - - temp &= 0x3; - mutex_lock(&data->update_lock); - cpld_i2c_read(client, byte, CPLD_FANLED_OFFSET, 2); - byte[0] &= ~(1<> 1) & 0x01)<update_lock); - - return count; -} - -static SENSOR_DEVICE_ATTR(info, S_IRUGO, show_info, 0, 0); -static SENSOR_DEVICE_ATTR(diag, S_IWUSR|S_IRUGO, show_diag, set_diag, 0); - -static SENSOR_DEVICE_ATTR(grn_led, S_IWUSR|S_IRUGO, show_sysled, set_sysled, 0); -static SENSOR_DEVICE_ATTR(red_led, S_IWUSR|S_IRUGO, show_sysled, set_sysled, 1); - -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); -#if FAN_NUM>4 -static SENSOR_DEVICE_ATTR(pwm5, S_IWUSR|S_IRUGO, show_pwm, set_pwm, 4); -#endif -#if FAN_NUM>5 -static SENSOR_DEVICE_ATTR(pwm6, S_IWUSR|S_IRUGO, show_pwm, set_pwm, 5); -#endif - -static SENSOR_DEVICE_ATTR(fanmodule1_type, S_IRUGO, show_fantype, 0, 0); -static SENSOR_DEVICE_ATTR(fanmodule2_type, S_IRUGO, show_fantype, 0, 1); -static SENSOR_DEVICE_ATTR(fanmodule3_type, S_IRUGO, show_fantype, 0, 2); -static SENSOR_DEVICE_ATTR(fanmodule4_type, S_IRUGO, show_fantype, 0, 3); -#if FAN_NUM>4 -static SENSOR_DEVICE_ATTR(fanmodule5_type, S_IRUGO, show_fantype, 0, 4); -#endif -#if FAN_NUM>5 -static SENSOR_DEVICE_ATTR(fanmodule6_type, S_IRUGO, show_fantype, 0, 5); -#endif - -static SENSOR_DEVICE_ATTR(fanmodule1_led, S_IWUSR|S_IRUGO, show_fanled, set_fanled, 0); -static SENSOR_DEVICE_ATTR(fanmodule2_led, S_IWUSR|S_IRUGO, show_fanled, set_fanled, 1); -static SENSOR_DEVICE_ATTR(fanmodule3_led, S_IWUSR|S_IRUGO, show_fanled, set_fanled, 2); -static SENSOR_DEVICE_ATTR(fanmodule4_led, S_IWUSR|S_IRUGO, show_fanled, set_fanled, 3); -#if FAN_NUM>4 -static SENSOR_DEVICE_ATTR(fanmodule5_led, S_IWUSR|S_IRUGO, show_fanled, set_fanled, 4); -#endif -#if FAN_NUM>5 -static SENSOR_DEVICE_ATTR(fanmodule6_led, S_IWUSR|S_IRUGO, show_fanled, set_fanled, 5); -#endif - -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); -#if FAN_NUM>4 -static SENSOR_DEVICE_ATTR(fan9_input, S_IRUGO, show_rpm, 0, 8); -static SENSOR_DEVICE_ATTR(fan10_input,S_IRUGO, show_rpm, 0, 9); -#endif -#if FAN_NUM>5 -static SENSOR_DEVICE_ATTR(fan11_input, S_IRUGO, show_rpm, 0, 10); -static SENSOR_DEVICE_ATTR(fan12_input, S_IRUGO, show_rpm, 0, 11); -#endif - -static SENSOR_DEVICE_ATTR(psu1, S_IRUGO, show_psu, 0, 0); -static SENSOR_DEVICE_ATTR(psu2, S_IRUGO, show_psu, 0, 1); - -static SENSOR_DEVICE_ATTR(bios_cs, S_IWUSR|S_IRUGO, show_bios_cs, set_bios_cs, 0); - -static struct attribute *cpld_attributes[] = { - &sensor_dev_attr_info.dev_attr.attr, - &sensor_dev_attr_diag.dev_attr.attr, - - &sensor_dev_attr_grn_led.dev_attr.attr, - &sensor_dev_attr_red_led.dev_attr.attr, - - &sensor_dev_attr_psu1.dev_attr.attr, - &sensor_dev_attr_psu2.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, -#if FAN_NUM>4 - &sensor_dev_attr_pwm5.dev_attr.attr, -#endif -#if FAN_NUM>5 - &sensor_dev_attr_pwm6.dev_attr.attr, -#endif - - &sensor_dev_attr_fanmodule1_type.dev_attr.attr, - &sensor_dev_attr_fanmodule2_type.dev_attr.attr, - &sensor_dev_attr_fanmodule3_type.dev_attr.attr, - &sensor_dev_attr_fanmodule4_type.dev_attr.attr, -#if FAN_NUM>4 - &sensor_dev_attr_fanmodule5_type.dev_attr.attr, -#endif -#if FAN_NUM>5 - &sensor_dev_attr_fanmodule6_type.dev_attr.attr, -#endif - - &sensor_dev_attr_fanmodule1_led.dev_attr.attr, - &sensor_dev_attr_fanmodule2_led.dev_attr.attr, - &sensor_dev_attr_fanmodule3_led.dev_attr.attr, - &sensor_dev_attr_fanmodule4_led.dev_attr.attr, -#if FAN_NUM>4 - &sensor_dev_attr_fanmodule5_led.dev_attr.attr, -#endif -#if FAN_NUM>5 - &sensor_dev_attr_fanmodule6_led.dev_attr.attr, -#endif - &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>4 - &sensor_dev_attr_fan9_input.dev_attr.attr, - &sensor_dev_attr_fan10_input.dev_attr.attr, -#endif -#if FAN_NUM>4 - &sensor_dev_attr_fan11_input.dev_attr.attr, - &sensor_dev_attr_fan12_input.dev_attr.attr, -#endif - - &sensor_dev_attr_bios_cs.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; - u8 byte[5]; - - 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; - } - - //Check CPLD2 exist or not - client2 = i2c_new_dummy(client->adapter, CPLD2_ADDRESS); - if(!client2) { - hasCPLD2 = 0; - client2 = client; - } else { - status = i2c_smbus_read_byte_data(client2, CPLD_INFO_OFFSET); - if(status<0) { - i2c_unregister_device(client2); - i2c_set_clientdata(client2, NULL); - hasCPLD2 = 0; - client2 = client; - } - } - - //Handle LED control by the driver - byte[0]=0x01; - cpld_i2c_write(client, byte, CPLD_CTL_OFFSET, 1); - data->tsk = kthread_run(cpld_thread,client,"%s",dev_name(data->hwmon_dev)); - 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); - - sysfs_remove_group(&client->dev.kobj, &cpld_group); - hwmon_device_unregister(data->hwmon_dev); - i2c_set_clientdata(client, NULL); - if(hasCPLD2) { - i2c_unregister_device(client2); - i2c_set_clientdata(client2, 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("jack.ting "); -MODULE_DESCRIPTION("cpld driver"); -MODULE_LICENSE("GPL"); - -module_init(inv_cpld_init); -module_exit(inv_cpld_exit); diff --git a/packages/platforms/inventec/x86-64/d7332/modules/builds/src/inv_def.h b/packages/platforms/inventec/x86-64/d7332/modules/builds/src/inv_def.h deleted file mode 100644 index 21daf5ae4..000000000 --- a/packages/platforms/inventec/x86-64/d7332/modules/builds/src/inv_def.h +++ /dev/null @@ -1,25 +0,0 @@ -#ifndef __INV_DEF_H -#define __INV_DEF_H - -/*customized definition*/ - -#define DEFAULT_CLTE (4) -/* use enum to define reply code*/ -/*use define temporary*/ -#define REC_SFF_IO_UNSUPPORTED (0x06) - -//#include "inv_type.h" -typedef enum { - - PLATFORM_MAPLE, - PLATFORM_BANYAN, - PLATFORM_CEDAR, - PLATFORM_4U, - PLATFORM_END, - -} platform_id_t; - -#define PLATFORM_ID (PLATFORM_BANYAN) -#define SWPS_VERSION ("SWPS_GA_v0.0.23") - -#endif /*__INV_DEF_H*/ diff --git a/packages/platforms/inventec/x86-64/d7332/modules/builds/src/inv_eeprom.c b/packages/platforms/inventec/x86-64/d7332/modules/builds/src/inv_eeprom.c deleted file mode 100644 index 7bb167d2e..000000000 --- a/packages/platforms/inventec/x86-64/d7332/modules/builds/src/inv_eeprom.c +++ /dev/null @@ -1,181 +0,0 @@ -/* - * 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 -#include - - -/* Size of EEPROM in bytes */ -#define EEPROM_SIZE 256 - -#define SLICE_BITS (6) -#define SLICE_SIZE (1 << SLICE_BITS) -#define SLICE_NUM (EEPROM_SIZE/SLICE_SIZE) - -/* Each client has this additional data */ -struct eeprom_data { - struct mutex update_lock; - u8 valid; /* bitfield, bit!=0 if slice is valid */ - unsigned long last_updated[SLICE_NUM]; /* In jiffies, 8 slices */ - u8 data[EEPROM_SIZE]; /* Register values */ -}; - - -static void inv_eeprom_update_client(struct i2c_client *client, u8 slice) -{ - struct eeprom_data *data = i2c_get_clientdata(client); - int i, j; - int ret; - int addr; - - - mutex_lock(&data->update_lock); - - if (!(data->valid & (1 << slice)) || - time_after(jiffies, data->last_updated[slice] + 300 * HZ)) { - dev_dbg(&client->dev, "Starting eeprom update, slice %u\n", slice); - - addr = slice << SLICE_BITS; - - ret = i2c_smbus_write_byte_data(client, ((u8)addr >> 8) & 0xFF, (u8)addr & 0xFF); - /* select the eeprom address */ - if (ret < 0) { - dev_err(&client->dev, "address set failed\n"); - goto exit; - } - - if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_READ_BYTE)) { - goto exit; - } - - for (i = slice << SLICE_BITS; i < (slice + 1) << SLICE_BITS; i+= SLICE_SIZE) { - for (j = i; j < (i+SLICE_SIZE); j++) { - int res; - - res = i2c_smbus_read_byte(client); - if (res < 0) { - goto exit; - } - - data->data[j] = res & 0xFF; - } - } - - data->last_updated[slice] = jiffies; - data->valid |= (1 << slice); - } - -exit: - mutex_unlock(&data->update_lock); -} - -static ssize_t inv_eeprom_read(struct file *filp, struct kobject *kobj, - struct bin_attribute *bin_attr, - char *buf, loff_t off, size_t count) -{ - struct i2c_client *client = to_i2c_client(container_of(kobj, struct device, kobj)); - struct eeprom_data *data = i2c_get_clientdata(client); - u8 slice; - - - if (off > EEPROM_SIZE) { - return 0; - } - if (off + count > EEPROM_SIZE) { - count = EEPROM_SIZE - off; - } - if (count == 0) { - return 0; - } - - /* Only refresh slices which contain requested bytes */ - for (slice = off >> SLICE_BITS; slice <= (off + count - 1) >> SLICE_BITS; slice++) { - inv_eeprom_update_client(client, slice); - } - - memcpy(buf, &data->data[off], count); - - return count; -} - -static struct bin_attribute inv_eeprom_attr = { - .attr = { - .name = "eeprom", - .mode = S_IRUGO, - }, - .size = EEPROM_SIZE, - .read = inv_eeprom_read, -}; - -static int inv_eeprom_probe(struct i2c_client *client, - const struct i2c_device_id *id) -{ - struct eeprom_data *data; - int err; - - if (!(data = kzalloc(sizeof(struct eeprom_data), GFP_KERNEL))) { - err = -ENOMEM; - goto exit; - } - - memset(data->data, 0xff, EEPROM_SIZE); - i2c_set_clientdata(client, data); - mutex_init(&data->update_lock); - - /* create the sysfs eeprom file */ - err = sysfs_create_bin_file(&client->dev.kobj, &inv_eeprom_attr); - if (err) { - goto exit_kfree; - } - - return 0; - -exit_kfree: - kfree(data); -exit: - return err; -} - -static int inv_eeprom_remove(struct i2c_client *client) -{ - sysfs_remove_bin_file(&client->dev.kobj, &inv_eeprom_attr); - kfree(i2c_get_clientdata(client)); - - return 0; -} - -static const struct i2c_device_id inv_eeprom_id[] = { - { "inv_eeprom", 0 }, - { } -}; - -static struct i2c_driver inv_eeprom_driver = { - .driver = { - .name = "inv_eeprom", - }, - .probe = inv_eeprom_probe, - .remove = inv_eeprom_remove, - .id_table = inv_eeprom_id, -}; - -module_i2c_driver(inv_eeprom_driver); - -MODULE_AUTHOR("Inventec"); -MODULE_DESCRIPTION("Inventec D6556 Mother Board EEPROM driver"); -MODULE_LICENSE("GPL"); - - diff --git a/packages/platforms/inventec/x86-64/d7332/modules/builds/src/inv_platform.c b/packages/platforms/inventec/x86-64/d7332/modules/builds/src/inv_platform.c deleted file mode 100644 index 31206abf1..000000000 --- a/packages/platforms/inventec/x86-64/d7332/modules/builds/src/inv_platform.c +++ /dev/null @@ -1,201 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include - -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 pca9641_modes_1[] = { - {.adap_id = bus_id(2),}, -}; -static struct pca954x_platform_mode pca9641_modes_2[] = { - {.adap_id = bus_id(3),}, -}; -static struct pca954x_platform_mode mux_modes_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_0[] = { - {.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_1[] = { - {.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_2[] = { - {.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_mode mux_modes_0_3[] = { - {.adap_id = bus_id(38),}, {.adap_id = bus_id(39),}, - {.adap_id = bus_id(40),}, {.adap_id = bus_id(41),}, - {.adap_id = bus_id(42),}, {.adap_id = bus_id(43),}, - {.adap_id = bus_id(44),}, {.adap_id = bus_id(45),}, -}; - -static struct pca954x_platform_data pca9641_data_1 = { - .modes = pca9641_modes_1, - .num_modes = 1, -}; -static struct pca954x_platform_data pca9641_data_2 = { - .modes = pca9641_modes_2, - .num_modes = 1, -}; -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 i2c_board_info i2c_device_info0[] __initdata = { - {"pca9641", 0, 0x76, &pca9641_data_1, 0, 0}, //PCA9641-1 -}; -static struct i2c_board_info i2c_device_info2[] __initdata = { - {"inv_cpld", 0, 0x77, 0, 0, 0}, //CPLD -}; -static struct i2c_board_info i2c_device_info4[] __initdata = { - {"inv_psu", 0, 0x58, 0, 0, 0}, //PSU1 - {"inv_psu", 0, 0x59, 0, 0, 0}, //PSU2 -}; -static struct i2c_board_info i2c_device_info5[] __initdata = { - {"inv_ucd90160", 0, 0x34, 0, 0, 0}, //switch board ucd90160 - {"inv_ucd90160", 0, 0x6b, 0, 0, 0}, //CPU board ucd90160 -}; -static struct i2c_board_info i2c_device_info1[] __initdata = { - {"pca9548", 0, 0x70, &mux_data_0, 0, 0}, //mux root -}; -static struct i2c_board_info i2c_device_info6[] __initdata = { - {"pca9548", 0, 0x72, &mux_data_0_0, 0, 0}, -}; -static struct i2c_board_info i2c_device_info7[] __initdata = { - {"pca9548", 0, 0x72, &mux_data_0_1, 0, 0}, -}; -static struct i2c_board_info i2c_device_info8[] __initdata = { - {"pca9548", 0, 0x72, &mux_data_0_2, 0, 0}, -}; -static struct i2c_board_info i2c_device_info9[] __initdata = { - {"pca9548", 0, 0x72, &mux_data_0_3, 0, 0}, -}; -static struct i2c_board_info i2c_device_info11[] __initdata = { - {"pca9641", 0, 0x73, &pca9641_data_2, 0, 0}, //PCA9641-2 -}; -static struct i2c_board_info i2c_device_info3[] __initdata = { - {"max6695", 0, 0x18, 0, 0, 0}, //ASIC Temp - {"tmp75", 0, 0x48, 0, 0, 0}, //CPU Board Temp - {"tmp75", 0, 0x49, 0, 0, 0}, //Fan Board Temp - {"tmp75", 0, 0x4A, 0, 0, 0}, //Temp - {"tmp75", 0, 0x4D, 0, 0, 0}, //Temp - {"tmp75", 0, 0x4E, 0, 0, 0}, //Temp -}; - -static struct inv_i2c_board_info i2cdev_list[] = { - {bus_id(0), ARRAY_SIZE(i2c_device_info0), i2c_device_info0 }, //PCA9641-1 - {bus_id(1), ARRAY_SIZE(i2c_device_info1), i2c_device_info1 }, //mux root - {bus_id(6), ARRAY_SIZE(i2c_device_info6), i2c_device_info6 }, //mux CH0 - {bus_id(7), ARRAY_SIZE(i2c_device_info7), i2c_device_info7 }, //mux CH1 - {bus_id(8), ARRAY_SIZE(i2c_device_info8), i2c_device_info8 }, //mux CH2 - {bus_id(9), ARRAY_SIZE(i2c_device_info9), i2c_device_info9 }, //mux CH3 - {bus_id(11),ARRAY_SIZE(i2c_device_info11), i2c_device_info11}, //PCA9641-2 - {bus_id(2), ARRAY_SIZE(i2c_device_info2), i2c_device_info2 }, //CPLD - {bus_id(3), ARRAY_SIZE(i2c_device_info3), i2c_device_info3 }, //Temperature - {bus_id(2), ARRAY_SIZE(i2c_device_info4), i2c_device_info4 }, //PSU1 and PSU2 - {bus_id(2), ARRAY_SIZE(i2c_device_info5), i2c_device_info5 }, //UCD90160 -}; - -static struct platform_device *device_i2c_gpio0; -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 int __init inv_platform_init(void) -{ - struct i2c_adapter *adap = NULL; - struct i2c_client *e = NULL; - int ret = 0; - int i,j,k; - - device_i2c_gpio0 = platform_device_alloc("i2c-gpio", 1); - if (!device_i2c_gpio0) { - printk(KERN_ERR "i2c-gpio: platform_device_alloc fail\n"); - return -ENOMEM; - } - device_i2c_gpio0->name = "i2c-gpio"; - device_i2c_gpio0->id = 1; - device_i2c_gpio0->dev.platform_data = &i2c_gpio_platdata0; - - ret = platform_device_add(device_i2c_gpio0); - if (ret) { - printk(KERN_ERR "i2c-gpio: platform_device_add fail %d\n", ret); - } - msleep(10); - - for(i=0; idev.platform_data = NULL; - platform_device_unregister(device_i2c_gpio0); -} - -module_init(inv_platform_init); -module_exit(inv_platform_exit); - -MODULE_AUTHOR("Inventec"); -MODULE_DESCRIPTION("Platform devices"); -MODULE_LICENSE("GPL"); diff --git a/packages/platforms/inventec/x86-64/d7332/modules/builds/src/inv_psu.c b/packages/platforms/inventec/x86-64/d7332/modules/builds/src/inv_psu.c deleted file mode 100644 index cd1eb1228..000000000 --- a/packages/platforms/inventec/x86-64/d7332/modules/builds/src/inv_psu.c +++ /dev/null @@ -1,689 +0,0 @@ -/* - * 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 - -#define PMBUS_VOUT_MODE 0x20 -#define PMBUS_FAN_PWM 0x3b -#define PMBUS_READ_VIN 0x88 -#define PMBUS_READ_IIN 0x89 -#define PMBUS_READ_VOUT 0x8b -#define PMBUS_READ_IOUT 0x8c -#define PMBUS_READ_TEMP1 0x8d -#define PMBUS_READ_TEMP2 0x8e -#define PMBUS_READ_TEMP3 0x8f -#define PMBUS_READ_FAN1 0x90 -#define PMBUS_READ_FAN2 0x91 -#define PMBUS_READ_POUT 0x96 -#define PMBUS_READ_PIN 0x97 -#define PMBUS_READ_MFR_ID 0x99 -#define PMBUS_READ_MFR_MODEL 0x9a -#define PMBUS_READ_MFR_REV 0x9b -#define PMBUS_READ_MFR_LOC 0x9c -#define PMBUS_READ_MFR_DATE 0x9d -#define PMBUS_READ_MFR_SERIAL 0x9e - -#define DEFAULT_MFR_FAIL_STR "NA" - -static int retrys = 1; -module_param(retrys, int, 0); -MODULE_PARM_DESC(retrys, "Inventec PSU driver read retry times (default 1)."); - -static int read_only_once = 0; -module_param(read_only_once, int, 0); -MODULE_PARM_DESC(read_only_once, "Inventec PSU driver MFR field read only once flag (default 0)."); - -#define FAN_NUM 2 -#define TMP_NUM 3 - -struct psu_data { - struct device *hwmon_dev; - s32 vin; - s32 vout; - s32 cin; - s32 cout; - s32 pin; - s32 pout; - s32 vout_mode; - s32 rpm[FAN_NUM]; - s32 temp[TMP_NUM]; - s32 pwm; - u8 id[I2C_SMBUS_BLOCK_MAX + 2]; - u8 model[I2C_SMBUS_BLOCK_MAX + 2]; - u8 revision[I2C_SMBUS_BLOCK_MAX + 2]; - u8 location[I2C_SMBUS_BLOCK_MAX + 2]; - u8 date[I2C_SMBUS_BLOCK_MAX + 2]; - u8 serial[I2C_SMBUS_BLOCK_MAX + 2]; -}; - -static s32 reg2data_linear(s32 value, s32 mode, u8 reg) -{ - s16 exponent; - s32 mantissa; - s32 val; - - if (mode) { - s32 parameter = (mode & 0x1f); - exponent = (parameter & 0x10) ? - ((32 - parameter) & 0xf) : (parameter & 0xf); - mantissa = (u16) value; - } else { - exponent = ((s16)value) >> 11; - mantissa = ((s16)((value & 0x7ff) << 5)) >> 5; - } - - val = mantissa; - - if (reg != PMBUS_READ_FAN1 && reg != PMBUS_READ_FAN2 && reg != PMBUS_FAN_PWM) - val = val * 1000; - - if (exponent >= 0) - val <<= exponent; - else - val >>= -exponent; - - return val; -} - -static void get_vout_mode(struct i2c_client *client, s32 clean) -{ - struct psu_data *data = i2c_get_clientdata(client); - s32 read = 0, trys = 0; - - if (clean) { - data->vout_mode = 0; - return; - } - - if (data->vout_mode) - return; - - while (trys <= retrys) { - read = i2c_smbus_read_byte_data(client, PMBUS_VOUT_MODE); - if (read < 0) { - trys++; - if (trys > retrys) - return; - continue; - } - break; - } - - data->vout_mode = read; -} - -static ssize_t read_voltage_out(struct device *dev, struct device_attribute *da, char *buf) -{ - struct i2c_client *client = to_i2c_client(dev); - struct psu_data *data = i2c_get_clientdata(client); - s32 vout = 0, trys = 0; - - while (trys <= retrys) { - - vout = i2c_smbus_read_word_data(client, PMBUS_READ_VOUT); - if (vout < 0) { - trys++; - if (trys > retrys) goto fail; - get_vout_mode(client, 1); - continue; - } - - get_vout_mode(client, 0); - - break; - } - - data->vout = reg2data_linear(vout, data->vout_mode, PMBUS_READ_VOUT); - - return sprintf(buf, "%d\n", data->vout); - -fail: - return sprintf(buf, "0\n"); -} - -static ssize_t read_voltage_in(struct device *dev, struct device_attribute *da, char *buf) -{ - struct i2c_client *client = to_i2c_client(dev); - struct psu_data *data = i2c_get_clientdata(client); - s32 vin = 0, trys = 0; - - while (trys <= retrys) { - - vin = i2c_smbus_read_word_data(client, PMBUS_READ_VIN); - if (vin < 0) { - trys++; - if (trys > retrys) goto fail; - continue; - } - - break; - } - - data->vin = reg2data_linear(vin, 0, PMBUS_READ_VIN); - - return sprintf(buf, "%d\n", data->vin); - -fail: - return sprintf(buf, "0\n"); -} - -static ssize_t read_current_in(struct device *dev, struct device_attribute *da, char *buf) -{ - struct i2c_client *client = to_i2c_client(dev); - struct psu_data *data = i2c_get_clientdata(client); - s32 cin = 0, trys = 0; - - while (trys <= retrys) { - - cin = i2c_smbus_read_word_data(client, PMBUS_READ_IIN); - if (cin < 0) { - trys++; - if (trys > retrys) goto fail; - continue; - } - - break; - } - - data->cin = reg2data_linear(cin, 0, PMBUS_READ_IIN); - - return sprintf(buf, "%d\n", data->cin); - -fail: - return sprintf(buf, "0\n"); -} - -static ssize_t read_current_out(struct device *dev, struct device_attribute *da, char *buf) -{ - struct i2c_client *client = to_i2c_client(dev); - struct psu_data *data = i2c_get_clientdata(client); - s32 cout = 0, trys = 0; - - while (trys <= retrys) { - - cout = i2c_smbus_read_word_data(client, PMBUS_READ_IOUT); - if (cout < 0) { - trys++; - if (trys > retrys) goto fail; - continue; - } - - break; - } - - data->cout = reg2data_linear(cout, 0, PMBUS_READ_IOUT); - - return sprintf(buf, "%d\n", data->cout); - -fail: - return sprintf(buf, "0\n"); -} - -static ssize_t read_power_in(struct device *dev, struct device_attribute *da, char *buf) -{ - struct i2c_client *client = to_i2c_client(dev); - struct psu_data *data = i2c_get_clientdata(client); - s32 pin = 0, trys = 0; - - while (trys <= retrys) { - - pin = i2c_smbus_read_word_data(client, PMBUS_READ_PIN); - if (pin < 0) { - trys++; - if (trys > retrys) goto fail; - continue; - } - - break; - } - - data->pin = reg2data_linear(pin, 0, PMBUS_READ_PIN); - - return sprintf(buf, "%d\n", data->pin); - -fail: - return sprintf(buf, "0\n"); -} - -static ssize_t read_power_out(struct device *dev, struct device_attribute *da, char *buf) -{ - struct i2c_client *client = to_i2c_client(dev); - struct psu_data *data = i2c_get_clientdata(client); - s32 pout = 0, trys = 0; - - while (trys <= retrys) { - - pout = i2c_smbus_read_word_data(client, PMBUS_READ_POUT); - if (pout < 0) { - trys++; - if (trys > retrys) goto fail; - continue; - } - - break; - } - - data->pout = reg2data_linear(pout, 0, PMBUS_READ_POUT); - - return sprintf(buf, "%d\n", data->pout); - -fail: - return sprintf(buf, "0\n"); -} - -static ssize_t read_temp(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 psu_data *data = i2c_get_clientdata(client); - s32 temp = 0, trys = 0; - u8 nr = attr->index; - - while (trys <= retrys) { - - temp = i2c_smbus_read_word_data(client, PMBUS_READ_TEMP1 + nr); - if (temp < 0) { - trys++; - if (trys > retrys) goto fail; - continue; - } - - break; - } - - data->temp[nr] = reg2data_linear(temp, 0, PMBUS_READ_TEMP1 + nr); - - return sprintf(buf, "%d\n", data->temp[nr]); - -fail: - return sprintf(buf, "0\n"); -} - -static ssize_t read_fan(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 psu_data *data = i2c_get_clientdata(client); - s32 rpm = 0, trys = 0; - u8 nr = attr->index; - - while (trys <= retrys) { - - rpm = i2c_smbus_read_word_data(client, PMBUS_READ_FAN1 + nr); - if (rpm < 0) { - trys++; - if (trys > retrys) goto fail; - continue; - } - - break; - } - - data->rpm[nr] = reg2data_linear(rpm, 0, PMBUS_READ_FAN1 + nr); - - return sprintf(buf, "%d\n", data->rpm[nr]); - -fail: - return sprintf(buf, "0\n"); -} - -static ssize_t read_pwm(struct device *dev, struct device_attribute *da, char *buf) -{ - struct i2c_client *client = to_i2c_client(dev); - struct psu_data *data = i2c_get_clientdata(client); - s32 pwm = 0, trys = 0; - - while (trys <= retrys) { - - pwm = i2c_smbus_read_word_data(client, PMBUS_FAN_PWM); - if (pwm < 0) { - trys++; - if (trys > retrys) goto fail; - continue; - } - - break; - } - - data->pwm = reg2data_linear(pwm, 0, PMBUS_FAN_PWM); - - return sprintf(buf, "%d\n", data->pwm); - -fail: - return sprintf(buf, "0\n"); -} - -static ssize_t set_pwm(struct device *dev, struct device_attribute *devattr, const char *buf, size_t count) -{ - struct i2c_client *client = to_i2c_client(dev); - struct psu_data *data = i2c_get_clientdata(client); - s32 temp = 0, trys = 0; - - u16 pwm = simple_strtol(buf, NULL, 10); - if(pwm > 100) pwm = 100; - - while (trys <= retrys) { - - temp = i2c_smbus_write_word_data(client, PMBUS_FAN_PWM, pwm); - if (temp < 0) { - trys++; - if (trys > retrys) goto fail; - continue; - } - - break; - } - - data->pwm = pwm; - - return count; - -fail: - return -1; -} - -static ssize_t read_mfr_id(struct device *dev, struct device_attribute *da, char *buf) -{ - struct i2c_client *client = to_i2c_client(dev); - struct psu_data *data = i2c_get_clientdata(client); - s32 temp = 0, trys = 0; - - if (read_only_once && data->id[0] != 0) - return sprintf(buf, "%s\n", data->id); - - while (trys <= retrys) { - - temp = i2c_smbus_read_block_data(client, PMBUS_READ_MFR_ID, data->id); - if (temp < 0) { - trys++; - if (trys > retrys) goto fail; - continue; - } - - break; - } - - return sprintf(buf, "%s\n", data->id); - -fail: - memset(data->id, 0, I2C_SMBUS_BLOCK_MAX + 2); - return sprintf(buf, "%s\n", DEFAULT_MFR_FAIL_STR); -} - -static ssize_t read_mfr_model(struct device *dev, struct device_attribute *da, char *buf) -{ - struct i2c_client *client = to_i2c_client(dev); - struct psu_data *data = i2c_get_clientdata(client); - s32 temp = 0, trys = 0; - - if (read_only_once && data->model[0] != 0) - return sprintf(buf, "%s\n", data->model); - - while (trys <= retrys) { - - temp = i2c_smbus_read_block_data(client, PMBUS_READ_MFR_MODEL, data->model); - if (temp < 0) { - trys++; - if (trys > retrys) goto fail; - continue; - } - - break; - } - - return sprintf(buf, "%s\n", data->model); - -fail: - memset(data->model, 0, I2C_SMBUS_BLOCK_MAX + 2); - return sprintf(buf, "%s\n", DEFAULT_MFR_FAIL_STR); -} - -static ssize_t read_mfr_revision(struct device *dev, struct device_attribute *da, char *buf) -{ - struct i2c_client *client = to_i2c_client(dev); - struct psu_data *data = i2c_get_clientdata(client); - s32 temp = 0, trys = 0; - - if (read_only_once && data->revision[0] != 0) - return sprintf(buf, "%s\n", data->revision); - - while (trys <= retrys) { - - temp = i2c_smbus_read_block_data(client, PMBUS_READ_MFR_REV, data->revision); - if (temp < 0) { - trys++; - if (trys > retrys) goto fail; - continue; - } - - break; - } - - return sprintf(buf, "%s\n", data->revision); - -fail: - memset(data->revision, 0, I2C_SMBUS_BLOCK_MAX + 2); - return sprintf(buf, "%s\n", DEFAULT_MFR_FAIL_STR); -} - -static ssize_t read_mfr_location(struct device *dev, struct device_attribute *da, char *buf) -{ - struct i2c_client *client = to_i2c_client(dev); - struct psu_data *data = i2c_get_clientdata(client); - s32 temp = 0, trys = 0; - - if (read_only_once && data->location[0] != 0) - return sprintf(buf, "%s\n", data->location); - - while (trys <= retrys) { - - temp = i2c_smbus_read_block_data(client, PMBUS_READ_MFR_LOC, data->location); - if (temp < 0) { - trys++; - if (trys > retrys) goto fail; - continue; - } - - break; - } - - return sprintf(buf, "%s\n", data->location); - -fail: - memset(data->location, 0, I2C_SMBUS_BLOCK_MAX + 2); - return sprintf(buf, "%s\n", DEFAULT_MFR_FAIL_STR); -} - -static ssize_t read_mfr_date(struct device *dev, struct device_attribute *da, char *buf) -{ - struct i2c_client *client = to_i2c_client(dev); - struct psu_data *data = i2c_get_clientdata(client); - s32 temp = 0, trys = 0; - - if (read_only_once && data->date[0] != 0) - return sprintf(buf, "%s\n", data->date); - - while (trys <= retrys) { - - temp = i2c_smbus_read_block_data(client, PMBUS_READ_MFR_DATE, data->date); - if (temp < 0) { - trys++; - if (trys > retrys) goto fail; - continue; - } - - break; - } - - return sprintf(buf, "%s\n", data->date); - -fail: - memset(data->date, 0, I2C_SMBUS_BLOCK_MAX + 2); - return sprintf(buf, "%s\n", DEFAULT_MFR_FAIL_STR); -} - -static ssize_t read_mfr_sn(struct device *dev, struct device_attribute *da, char *buf) -{ - struct i2c_client *client = to_i2c_client(dev); - struct psu_data *data = i2c_get_clientdata(client); - s32 temp = 0, trys = 0; - - if (read_only_once && data->serial[0] != 0) - return sprintf(buf, "%s\n", data->serial); - - while (trys <= retrys) { - - temp = i2c_smbus_read_block_data(client, PMBUS_READ_MFR_SERIAL, data->serial); - if (temp < 0) { - trys++; - if (trys > retrys) goto fail; - continue; - } - - break; - } - - return sprintf(buf, "%s\n", data->serial); - -fail: - memset(data->serial, 0, I2C_SMBUS_BLOCK_MAX + 2); - return sprintf(buf, "%s\n", DEFAULT_MFR_FAIL_STR); -} - -static SENSOR_DEVICE_ATTR(in1_input, S_IRUGO, read_voltage_in, 0, 0); -static SENSOR_DEVICE_ATTR(in2_input, S_IRUGO, read_voltage_out, 0, 0); -static SENSOR_DEVICE_ATTR(curr1_input, S_IRUGO, read_current_in, 0, 0); -static SENSOR_DEVICE_ATTR(curr2_input, S_IRUGO, read_current_out, 0, 0); -static SENSOR_DEVICE_ATTR(power1_input, S_IRUGO, read_power_in, 0, 0); -static SENSOR_DEVICE_ATTR(power2_input, S_IRUGO, read_power_out, 0, 0); -static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, read_temp, 0, 0); -static SENSOR_DEVICE_ATTR(temp2_input, S_IRUGO, read_temp, 0, 1); -static SENSOR_DEVICE_ATTR(temp3_input, S_IRUGO, read_temp, 0, 2); -static SENSOR_DEVICE_ATTR(fan1_input, S_IRUGO, read_fan, 0, 0); -static SENSOR_DEVICE_ATTR(fan2_input, S_IRUGO, read_fan, 0, 1); -static SENSOR_DEVICE_ATTR(pwm1, S_IWUSR|S_IRUGO, read_pwm, set_pwm, 0); -static SENSOR_DEVICE_ATTR(mfr_id, S_IRUGO, read_mfr_id, 0, 0); -static SENSOR_DEVICE_ATTR(mfr_model, S_IRUGO, read_mfr_model, 0, 0); -static SENSOR_DEVICE_ATTR(mfr_revision, S_IRUGO, read_mfr_revision, 0, 0); -static SENSOR_DEVICE_ATTR(mfr_location, S_IRUGO, read_mfr_location, 0, 0); -static SENSOR_DEVICE_ATTR(mfr_date, S_IRUGO, read_mfr_date, 0, 0); -static SENSOR_DEVICE_ATTR(mfr_serial_number, S_IRUGO, read_mfr_sn, 0, 0); - -static struct attribute *psu_attributes[] = { - &sensor_dev_attr_in1_input.dev_attr.attr, - &sensor_dev_attr_in2_input.dev_attr.attr, - &sensor_dev_attr_curr1_input.dev_attr.attr, - &sensor_dev_attr_curr2_input.dev_attr.attr, - &sensor_dev_attr_power1_input.dev_attr.attr, - &sensor_dev_attr_power2_input.dev_attr.attr, - &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_fan1_input.dev_attr.attr, - &sensor_dev_attr_fan2_input.dev_attr.attr, - &sensor_dev_attr_pwm1.dev_attr.attr, - &sensor_dev_attr_mfr_id.dev_attr.attr, - &sensor_dev_attr_mfr_model.dev_attr.attr, - &sensor_dev_attr_mfr_revision.dev_attr.attr, - &sensor_dev_attr_mfr_location.dev_attr.attr, - &sensor_dev_attr_mfr_date.dev_attr.attr, - &sensor_dev_attr_mfr_serial_number.dev_attr.attr, - NULL -}; - -static const struct attribute_group psu_group = { - .attrs = psu_attributes, -}; - -/*-----------------------------------------------------------------------*/ -/* device probe and removal */ -static int -inv_psu_probe(struct i2c_client *client, const struct i2c_device_id *id) -{ - struct psu_data *data; - int status; - - if (!i2c_check_functionality(client->adapter, - I2C_FUNC_SMBUS_BYTE_DATA | I2C_FUNC_SMBUS_WORD_DATA)) - return -EIO; - - data = kzalloc(sizeof(struct psu_data), GFP_KERNEL); - if (!data) - return -ENOMEM; - - i2c_set_clientdata(client, data); - - /* Register sysfs hooks */ - status = sysfs_create_group(&client->dev.kobj, &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; - } - - return 0; - -exit_remove: - sysfs_remove_group(&client->dev.kobj, &psu_group); -exit_free: - i2c_set_clientdata(client, NULL); - kfree(data); - return status; -} - -static int inv_psu_remove(struct i2c_client *client) -{ - struct psu_data *data = i2c_get_clientdata(client); - - sysfs_remove_group(&client->dev.kobj, &psu_group); - hwmon_device_unregister(data->hwmon_dev); - i2c_set_clientdata(client, NULL); - kfree(data); - return 0; -} - -static const struct i2c_device_id inv_psu_ids[] = { - { "inv_psu" , 0, }, - { /* LIST END */ } -}; -MODULE_DEVICE_TABLE(i2c, inv_psu_ids); - -static struct i2c_driver psu_driver = { - .class = I2C_CLASS_HWMON, - .driver = { - .name = "inv_psu", - }, - .probe = inv_psu_probe, - .remove = inv_psu_remove, - .id_table = inv_psu_ids, -}; - -static int __init inv_psu_init(void) -{ - return i2c_add_driver(&psu_driver); -} - -static void __exit inv_psu_exit(void) -{ - i2c_del_driver(&psu_driver); -} - -MODULE_AUTHOR("Roger Chang "); -MODULE_DESCRIPTION("inventec psu driver"); -MODULE_LICENSE("GPL"); - -module_init(inv_psu_init); -module_exit(inv_psu_exit); diff --git a/packages/platforms/inventec/x86-64/d7332/modules/builds/src/inv_swps.c b/packages/platforms/inventec/x86-64/d7332/modules/builds/src/inv_swps.c deleted file mode 100644 index 469ae11ca..000000000 --- a/packages/platforms/inventec/x86-64/d7332/modules/builds/src/inv_swps.c +++ /dev/null @@ -1,4530 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -/*ufile use*/ -#include -#include -#include -#include -#include "inv_def.h" -//#include "sff_spec.h" -#include "inv_swps.h" -#include "pltfm_info.h" -#include "sff_eeprom.h" -#include "sfp.h" -#include "qsfp.h" -#include "qsfp_dd.h" - -int io_no_init = 0; -module_param(io_no_init, int, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP); -u32 logLevel = SWPS_ERR_LEV | SWPS_INFO_LEV; -//u32 logLevel = ERR_ALL_LEV | INFO_ALL_LEV | DBG_ALL_LEV; -bool int_flag_monitor_en = false; -char workBuf[PAGE_SIZE]; -struct platform_info_t *pltfmInfo = NULL; -static void swps_polling_task(struct work_struct *work); -static void polling_task_1U(void); -static void polling_task_4U(void); -static DECLARE_DELAYED_WORK(swps_polling, swps_polling_task); -static u8 swps_polling_enabled = 1; -static int swps_polling_task_start(void); -static int swps_polling_task_stop(void); -static int mux_ch_block(int i2c_ch, unsigned long mux_ch); -static int mux_fail_reset(int i2c_ch); -static struct swps_kobj_t *swps_kobj_add(char *name, - struct kobject *mgr, - struct attribute_group *attr_group); -/*dummy function only for testing*/ - -static void dummy_phy_ready(unsigned long bitmap, bool *ready) -{ - if (0xff == bitmap) { - *ready = true; - } else { - *ready = false; - } -} -static int lc_dummy_get(int lc_id, int *lv) -{ - *lv = 1; - return 0; -} -/*typedef enum { - LC_LED_CTRL_OFF = 0, - LC_LED_CTRL_GREEN_ON, - LC_LED_CTRL_RED_ON, - LC_LED_CTRL_AMBER_ON, - LC_LED_CTRL_GREEN_BLINK, - LC_LED_CTRL_RED_BLINK, - LC_LED_CTRL_AMBER_BLINK, - LC_LED_CTRL_NUM, -} lc_led_ctrl_t; -*/ -enum { - LC_EJ_SKIP_FLAG = 0, - LC_EJ_IS_LOCKED_FLAG = 1, - LC_EJ_IS_UNLOCKED_FLAG = 2, -}; - -struct lc_func_t lc_func_4U = { - .dev_init = lc_dev_init, - .dev_deinit = lc_dev_deinit, - .dev_hdlr = lc_dev_hdlr, - .polling_task = polling_task_4U, - .mux_reset_set = lc_dev_mux_reset_set, - .mux_reset_get = lc_dummy_get, - .i2c_is_alive = lc_dev_mux_l1_is_alive, - .cpld_init = lc_dev_lc_cpld_init, - .power_set = lc_dev_power_set, - .power_ready = lc_dev_power_ready, - //.phy_ready = lc_dev_phy_ready, - .phy_ready = dummy_phy_ready, - .prs_get = lc_dev_prs_get, - //.prs_get = dummy_prs_get, - .reset_set = lc_dev_reset_set, - .type_get = lc_dev_type_get, - .type_get_text = lc_dev_type_get_text, - .led_set = lc_dev_led_set, - .led_set = lc_dev_led_set, - .over_temp_asserted = lc_dev_over_temp_asserted, - .over_temp_deasserted = lc_dev_over_temp_deasserted, - .temp_get = lc_dev_temp_get_text, - .phy_reset_set = lc_dev_phy_reset_set, -}; - -struct lc_func_t lc_func_1U = { - .dev_init = io_dev_init, - .dev_deinit = io_dev_deinit, - .dev_hdlr = io_dev_hdlr, - .polling_task = polling_task_1U, - .mux_reset_set = io_dev_mux_reset_set, - .mux_reset_get = io_dev_mux_reset_get, - .i2c_is_alive = ioexp_is_channel_ready, -}; - -/*check if pointer is valid - * true: not NULL false: NULL*/ -bool inline p_valid(const void *ptr) -{ - return ((NULL != ptr) ? true:false); -} -#if 0 -static int string_to_long(const char *buf, long *val) -{ - long ldata = 0; - int ret = 0; - - if (!p_valid(buf) || !p_valid(val)) { - return -EINVAL; - } - ret = kstrtol(buf, 16, &ldata); - - if (ret < 0) { - - return ret; - } - *val = ldata; - return 0; -} -#endif -static inline void swps_polling_set(u8 enable) -{ - swps_polling_enabled = enable; -} - -static inline u8 swps_polling_is_enabled(void) -{ - return swps_polling_enabled; -} - -struct fsm_period_t { - sff_fsm_state_t st; - int delay_cnt; -}; - -struct fsm_period_t fsm_period_tbl[] = { - {SFF_FSM_ST_REMOVED, 0}, - {SFF_FSM_ST_INSERTED, 3}, - {SFF_FSM_ST_DETECTING, 3}, - {SFF_FSM_ST_INIT, 1}, - {SFF_FSM_ST_READY, 5}, - {SFF_FSM_ST_IDLE, 20}, - {SFF_FSM_ST_FAULT, 30}, - {SFF_FSM_ST_SUSPEND, 1}, - {SFF_FSM_ST_RESTART, 1}, - {SFF_FSM_ST_IDENTIFY, 1}, - {SFF_FSM_ST_MONITOR, 30}, - /*qsfp-dd only {*/ - {SFF_FSM_ST_MGMT_INIT, 3}, - {SFF_FSM_ST_MODULE_UNRESET, 1}, - {SFF_FSM_ST_MODULE_HW_INIT, 3}, - {SFF_FSM_ST_MODULE_LOOPBACK_INIT, 3}, - {SFF_FSM_ST_MODULE_READY, 3}, - {SFF_FSM_ST_MODULE_PWR_DOWN, 3}, - {SFF_FSM_ST_MODULE_CMIS_VER_CHECK, 1}, - {SFF_FSM_ST_MODULE_ADVERT_CHECK, 1}, - {SFF_FSM_ST_MODULE_SW_CONFIG_1, 1}, - {SFF_FSM_ST_MODULE_SW_CONFIG_2, 1}, - {SFF_FSM_ST_MODULE_SW_CONFIG_CHECK, 1}, - {SFF_FSM_ST_MODULE_SW_CONTROL, 1}, - {SFF_FSM_ST_MODULE_READY_CHECK, 1}, - /*qsfp-dd only }*/ - {SFF_FSM_ST_UNKNOWN_TYPE, 30}, - {SFF_FSM_ST_END, 0xff}, /*keep it at the end of table*/ -}; - -const char *sff_fsm_st_str[SFF_FSM_ST_NUM] = { - "SFF_FSM_ST_REMOVED", - "SFF_FSM_ST_INSERTED", - "SFF_FSM_ST_DETECTING", - "SFF_FSM_ST_INIT", - "SFF_FSM_ST_READY", - "SFF_FSM_ST_IDLE", - "SFF_FSM_ST_FAULT", - "SFF_FSM_ST_SUSPEND", - "SFF_FSM_ST_RESTART", - "SFF_FSM_ST_ISOLATED", - "SFF_FSM_ST_IDENTIFY", - "SFF_FSM_ST_MONITOR", - /*qsfp-dd only {*/ - "SFF_FSM_ST_MGMT_INIT", - "SFF_FSM_ST_MODULE_UNRESET", - "SFF_FSM_ST_MODULE_HW_INIT", - "SFF_FSM_ST_MODULE_LOOPBACK_INIT", - "SFF_FSM_ST_MODULE_READY", - "SFF_FSM_ST_MODULE_PWR_DOWN", - "SFF_FSM_ST_MODULE_CMIS_VER_CHECK", - "SFF_FSM_ST_MODULE_ADVERT_CHECK", - "SFF_FSM_ST_MODULE_SW_CONFIG_1", - "SFF_FSM_ST_MODULE_SW_CONFIG_2", - "SFF_FSM_ST_MODULE_SW_CONFIG_CHECK", - "SFF_FSM_ST_MODULE_SW_CONTROL", - "SFF_FSM_ST_MODULE_READY_CHECK", - /*qsfp-dd only }*/ - "SFF_FSM_ST_UNKNOWN_TYPE", - "SFF_FSM_ST_END", /*keep it at the bottom*/ -}; -/*struct sff_obj_t;*/ - -struct kset *swpsKset = NULL; - - -char *lc_fsm_st_str[LC_FSM_ST_NUM] = { - [LC_FSM_ST_INSERT] = "LC_FSM_ST_INSERT", - [LC_FSM_ST_WAIT_STABLE] = "LC_FSM_ST_STABLE", - [LC_FSM_ST_POWER_ON] = "LC_FSM_ST_POWER_ON", - [LC_FSM_ST_POWER_CHECK] = "LC_FSM_ST_POWER_CHECK", - [LC_FSM_ST_PHY_CHECK] = "LC_FSM_ST_PHY_CHECK", - [LC_FSM_ST_INIT] = "LC_FSM_ST_INIT", - [LC_FSM_ST_READY] = "LC_FSM_ST_READY", - [LC_FSM_ST_REMOVE] = "LC_FSM_ST_REMOVE", - [LC_FSM_ST_IDLE] = "LC_FSM_ST_IDLE", - [LC_FSM_ST_THERMAL_TRIP] = "LC_FSM_ST_THERMAL_TRIP", - [LC_FSM_ST_UNSUPPORTED] = "LC_FSM_ST_UNSUPPORTED", - [LC_FSM_ST_FAULT] = "LC_FSM_ST_FAULT", - -}; - -enum { - TYPE_1U = 1, - TYPE_2U, - TYPE_3U, - TYPE_4U, -}; -#define LINE_CARD_NUM (4) -//int cardNum = LINE_CARD_NUM; -int maxPortNum = 0; -struct lc_t lcMgr; -char *card_name_str[LINE_CARD_NUM] = { - "card1", - "card2", - "card3", - "card4", -}; - -static int sff_kobj_add(struct sff_obj_t *sff_obj); -static void sff_fsm_init(struct sff_obj_t *obj, int type); -static void sff_data_init(struct sff_mgr_t *sff, int port_num); -inline static void sff_data_reset(struct sff_mgr_t *sff); -static void sff_func_init(struct sff_mgr_t *sff); -static void func_tbl_init(struct sff_obj_t *obj, int type); -static void io_no_init_port_done_set(struct sff_obj_t *sff_obj); -static int io_no_init_done_fsm_run(struct sff_obj_t *sff_obj); -static void io_no_init_handler_by_card(struct lc_obj_t *card); -static void io_no_init_handler(struct lc_t *card); -static bool i2c_bus_is_alive(struct lc_obj_t *obj); -static void i2c_bus_recovery(struct lc_obj_t *card); -static void mux_reset_seq(struct lc_obj_t *card); -#define MASK_CREATE(port) ((1L << (port)) - 1L) - -#define INVALID_CH (0xff) - -static void mux_reset_ch_resel(int lc_id, int port) -{ - sff_eeprom_read_no_retry(lc_id, port); -} - -static void mux_reset_ch_resel_byLC(struct lc_obj_t *card) -{ - int port = 0; - int lc_id = 0; - struct sff_obj_t *sff_obj = NULL; - int try_num = 0; - bool reset_done = false; - int port_num = card->sff.valid_port_num; - int ch_1st = 0; - int ch_2nd = 0; - int ch = 0; - int try = 0; - lc_id = card->lc_id; - try_num = (card->sff.valid_port_num/MUX_CH_NUM) * 2; - - SWPS_LOG_DBG("mux_ch_resel_start: try:%d try_num:%d\n", try, try_num); - while (!reset_done && (try++ < try_num)) { - SWPS_LOG_DBG("mux_ch_resel_done: try:%d try_num:%d\n", try, try_num); - for (port = 0; port < port_num; port += MUX_CH_NUM) { - - ch_1st = INVALID_CH; - ch_2nd = INVALID_CH; - for (ch = port; ch < port + MUX_CH_NUM; ch++) { - - sff_obj = &(card->sff.obj[ch]); - if (ch_1st == INVALID_CH && - SFF_FSM_ST_ISOLATED != sff_fsm_st_get(sff_obj)) { - ch_1st = ch; - } else { - - //SWPS_LOG_DBG("ch:%d test ch_1st:%d ch_2nd:%d\n", ch, ch_1st, ch_2nd); - if(SFF_FSM_ST_ISOLATED != sff_fsm_st_get(sff_obj)) { - ch_2nd = ch; - break; - } - } - } - if (INVALID_CH == ch_1st || - INVALID_CH == ch_2nd) { - SWPS_LOG_ERR("select ch fail ch_1st:%s ch_2nd:%s \n", card->sff.obj[ch_1st].name, card->sff.obj[ch_2nd].name); - break; - } - SWPS_LOG_DBG("ch_1st:%s ch_2nd:%s\n", card->sff.obj[ch_1st].name, card->sff.obj[ch_2nd].name); - sff_obj = &(card->sff.obj[ch_1st]); - mux_reset_ch_resel(lc_id, ch_1st); - if (!i2c_bus_is_alive(card)) { - sff_fsm_st_set(sff_obj, SFF_FSM_ST_ISOLATED); - SWPS_LOG_ERR("transvr in %s is bad\n", sff_obj->name); - mux_reset_seq(card); - break; - } - - sff_obj = &(card->sff.obj[ch_2nd]); - mux_reset_ch_resel(lc_id, ch_2nd); - if (!i2c_bus_is_alive(card)) { - mux_reset_seq(card); - sff_fsm_st_set(sff_obj, SFF_FSM_ST_ISOLATED); - SWPS_LOG_ERR("transvr in %s is bad\n", sff_obj->name); - break; - } - } - if (port >= port_num) { - if (i2c_bus_is_alive(card)) { - reset_done = true; - SWPS_LOG_DBG("mux_ch_resel_done: try:%d\n", try); - } - } - } - if (try >= try_num) { - SWPS_LOG_ERR("mux_ch_resel_fail\n try:%d\n", try); - } -} - -static bool port_is_range_valid(int lc_id, int port) -{ - int port_num = lcMgr.obj[lc_id].sff.valid_port_num; - - if (port >= port_num && port < 0) { - return false; - } - return true; -} - -char *port_name_get(int lc_id, int port) -{ - if (!port_is_range_valid(lc_id, port)) { - return NULL; - } - return lcMgr.obj[lc_id].sff.obj[port].name; -} -/*the line card port number should be obtained from cpld*/ -static struct port_info_table_t *lc_port_info_get(struct lc_obj_t *card, lc_type_t type) -{ - struct port_info_table_t *port_info = NULL; - - if (LC_100G_TYPE == type) { - port_info = pltfmInfo->tbl_1st; - } else if (LC_400G_TYPE == type) { - port_info = pltfmInfo->tbl_2nd; - } else { - SWPS_LOG_ERR("unknown lc type\n"); - } - - return port_info; -} - -static void lc_fsm_st_chg_process(struct lc_obj_t *card, - lc_fsm_st_t cur_st, - lc_fsm_st_t next_st) -{ - if (cur_st != next_st) { - SWPS_LOG_DBG("%s st change:%s -> %s\n", - card->name, lc_fsm_st_str[cur_st], - lc_fsm_st_str[next_st]); - } -} -static void lc_fsm_st_set(struct lc_obj_t *card, lc_fsm_st_t st) -{ - lc_fsm_st_t cur_st = card->st; - lc_fsm_st_chg_process(card, cur_st, st); - card->st = st; -} -static lc_fsm_st_t lc_fsm_st_get(struct lc_obj_t *card) -{ - return card->st; -} -/* if it's 4U platform , get the info from lc_dev_prs_get() - * if it's 1u return 1*/ -static void lc_insert(struct lc_obj_t *obj) -{ - SWPS_LOG_INFO("%s insert\n", obj->name); - lc_fsm_st_set(obj, LC_FSM_ST_INSERT); -} -static void lc_remove(struct lc_obj_t *obj) -{ - SWPS_LOG_INFO("%s remove\n", obj->name); - lc_fsm_st_set(obj, LC_FSM_ST_REMOVE); -} -#if 0 -static int lc_prs_scan(struct lc_t *self) -{ - unsigned long prs = 0; - unsigned long ej_r = 0; - unsigned long ej_l = 0; - int lc_num = self->lc_num; - unsigned long prs_change = 0; - unsigned long ej_r_chg = 0; - unsigned long ej_l_chg = 0; - bool is_prs_chg = false; - bool is_ej_r_chg = false; - bool is_ej_l_chg = false; - int i= 0; - int ret = 0; - struct lc_func_t *lc_func = NULL; - - if (!p_valid(self)) { - SWPS_LOG_ERR("NULL ptr\n"); - return -EINVAL; - } - lc_func = self->lc_func; - - check_pfunc(lc_func->prs_get); - if ((ret = lc_func->prs_get(&prs)) < 0) { - return ret; - } - if ((ret = lc_dev_ej_r_get(&ej_r)) < 0) { - return ret; - } - if ((ret = lc_dev_ej_l_get(&ej_l)) < 0) { - return ret; - } - - prs_change = prs ^ (self->lc_prs); - ej_r_chg = ej_r ^ (self->ej_r); - ej_l_chg = ej_l ^ (self->ej_l); - - for (i = 0; i < lc_num; i++) { - - if (test_bit(i, &prs_change)) { - is_prs_chg = true; - - if (test_bit(i, &prs)) { - lc_insert(&self->obj[i]); - } else { - lc_remove(&self->obj[i]); - } - } - } - - self->lc_prs = prs; - - return 0; -} -#else -static int lc_ej_lock_st_get(int lc_id, unsigned long prs, unsigned long ej_r, unsigned long ej_l) -{ - int ej_st = LC_EJ_SKIP_FLAG; - - if(test_bit(lc_id, &prs) && - test_bit(lc_id, &ej_r) && - test_bit(lc_id, &ej_l)) { - - ej_st = LC_EJ_IS_LOCKED_FLAG; - } else { - //if (!test_bit(lc_id, &ej_r) && !test_bit(lc_id, &ej_l)) { - ej_st = LC_EJ_IS_UNLOCKED_FLAG; - // } - } - - return ej_st; -} -static int lc_prs_scan(struct lc_t *self) -{ - unsigned long prs = 0; - unsigned long ej_r = 0; - unsigned long ej_l = 0; - int lc_num = self->lc_num; - unsigned long prs_chg = 0; - unsigned long ej_r_chg = 0; - unsigned long ej_l_chg = 0; - bool is_prs_chg = false; - bool is_ej_r_chg = false; - bool is_ej_l_chg = false; - int lc_id = 0; - int ret = 0; - int ej_st = LC_EJ_SKIP_FLAG; - struct lc_func_t *lc_func = NULL; - struct lc_obj_t *lc_obj = NULL; - if (!p_valid(self)) { - SWPS_LOG_ERR("NULL ptr\n"); - return -EINVAL; - } - lc_func = self->lc_func; - - check_pfunc(lc_func->prs_get); - if ((ret = lc_func->prs_get(&prs)) < 0) { - return ret; - } - if ((ret = lc_dev_ej_r_get(&ej_r)) < 0) { - return ret; - } - if ((ret = lc_dev_ej_l_get(&ej_l)) < 0) { - return ret; - } - - prs_chg = prs ^ (self->lc_prs); - ej_r_chg = ej_r ^ (self->ej_r); - ej_l_chg = ej_l ^ (self->ej_l); - - if (test_bit(lc_id, &prs_chg)) { - is_prs_chg = true; - } - if (test_bit(lc_id, &ej_l_chg)) { - is_ej_r_chg = true; - } - - if (test_bit(lc_id, &ej_r_chg)) { - is_ej_r_chg = true; - } - for (lc_id = 0; lc_id < lc_num; lc_id++) { - - ej_st = lc_ej_lock_st_get(lc_id, prs, ej_r, ej_l); - lc_obj = &(self->obj[lc_id]); - switch (lc_obj->posi_st) { - case LC_POSI_INIT_ST: - if (LC_EJ_IS_LOCKED_FLAG == ej_st) { - lc_obj->posi_st = LC_POSI_LOCK_CHECK_ST; - lc_obj->prs_locked_cnt = 0; - } else { - - lc_obj->posi_st = LC_POSI_MON_ST; - } - break; - - case LC_POSI_MON_ST: - - if (is_prs_chg || is_ej_r_chg || is_ej_l_chg) { - - if (LC_EJ_IS_LOCKED_FLAG == ej_st) { - lc_obj->posi_st = LC_POSI_LOCK_CHECK_ST; - lc_obj->prs_locked_cnt = 0; - } else { - - lc_obj->posi_st = LC_POSI_RELEASED_ST; - } - } - break; - - case LC_POSI_RELEASED_ST: - - if (LC_EJ_IS_LOCKED_FLAG == ej_st) { - lc_obj->posi_st = LC_POSI_LOCK_CHECK_ST; - lc_obj->prs_locked_cnt = 0; - } - - break; - case LC_POSI_LOCK_CHECK_ST: - - if (LC_EJ_IS_LOCKED_FLAG == ej_st) { - lc_obj->prs_locked_cnt++; - } else if (LC_EJ_IS_UNLOCKED_FLAG == ej_st) { - lc_obj->posi_st = LC_POSI_RELEASED_ST; - lc_remove(lc_obj); - } - - if (lc_obj->prs_locked_cnt >= LC_PRS_LOCKED_NUM) { - lc_obj->prs_locked_cnt = 0; - lc_insert(lc_obj); - lc_obj->posi_st = LC_POSI_LOCKED_ST; - } - - break; - case LC_POSI_LOCKED_ST: - - if (LC_EJ_IS_UNLOCKED_FLAG == ej_st) { - lc_obj->posi_st = LC_POSI_RELEASED_ST; - lc_remove(lc_obj); - } - - break; - default: - break; - } - } - self->lc_prs = prs; - self->ej_r = ej_r; - self->ej_l = ej_l; - return 0; -} - - - -#endif -static int lc_fsm_run_4U(struct lc_t *card); -static int lc_fsm_run_1U(struct lc_t *card); -/*struct sff_mgr_t Sff;*/ - -#define to_swps_kobj(x) container_of(x, struct swps_kobj_t, kobj) - -void sff_fsm_st_chg_process(struct sff_obj_t *sff_obj, sff_fsm_state_t cur_st, sff_fsm_state_t next_st); - -static inline bool transvr_is_detected(struct sff_obj_t *sff_obj) -{ - return (sff_obj->fsm.st == SFF_FSM_ST_READY ? (true) : (false)); - -} -inline void transvr_type_set(struct sff_obj_t *sff_obj, int type) -{ - sff_obj->transvr_type=type; -} -inline int transvr_type_get(struct sff_obj_t *sff_obj) -{ - return sff_obj->transvr_type; -} - -static struct monitor_para_t monitor_para_table[] = { - /* refer to sff 8636- ABLE 6-8 CHANNEL MONITORING VALUES (PAGE 00H BYTES 34-81)*/ - - {LN_MONITOR_RX_PWR_TYPE, 10000, "mW"}, - {LN_MONITOR_TX_PWR_TYPE, 10000, "mW"}, - {LN_MONITOR_TX_BIAS_TYPE, 500, "mA"}, - -}; -struct monitor_para_t *monitor_para_find(int type) -{ - int idx = 0; - int size = ARRAY_SIZE(monitor_para_table); - for (idx = 0; idx < size; idx++) { - - if (type == monitor_para_table[idx].type) - break; - } - if (idx >= size) - return NULL; - - return &monitor_para_table[idx]; -} -/*utility*/ -static int sscanf_to_int(const char *buf, int *value); -static bool match(const char *str1, const char *str2); - -int i2c_smbus_write_byte_data_retry(struct i2c_client *client, u8 offset, u8 data) -{ - int ret = 0; - int i = 0; - - for (i = 0; i < I2C_RETRY_NUM; i++) { - ret = i2c_smbus_write_byte_data(client, offset, data); - if (ret < 0) { - msleep(I2C_RETRY_DELAY_MS); - continue; - } - break; - } - - if (i >= I2C_RETRY_NUM) { - SWPS_LOG_ERR("fail:offset:0x%x try %d/%d! Error Code: %d\n", offset, i, I2C_RETRY_NUM, ret); - } - - return ret; -} -int i2c_smbus_read_byte_data_retry(struct i2c_client *client, u8 offset) -{ - int ret = 0; - int i = 0; - - for (i = 0; i < I2C_RETRY_NUM; i++) { - - ret = i2c_smbus_read_byte_data(client, offset); - if (ret < 0) { - msleep(I2C_RETRY_DELAY_MS); - continue; - } - break; - } - - if (i >= I2C_RETRY_NUM) { - printk("%s fail:offset:0x%x try %d/%d! Error Code: %d\n", __func__, offset, i, I2C_RETRY_NUM, ret); - } - - return ret; -} - -int i2c_smbus_read_word_data_retry(struct i2c_client *client, u8 offset) -{ - int ret = 0; - int i = 0; - - for (i = 0; i < I2C_RETRY_NUM; i++) { - ret = i2c_smbus_read_word_data(client, offset); - if (ret < 0) { - msleep(I2C_RETRY_DELAY_MS); - continue; - } - break; - } - - if (i >= I2C_RETRY_NUM) { - SWPS_LOG_ERR("%s fail:offset:0x%x try %d/%d! Error Code: %d\n", __func__, offset, i, I2C_RETRY_NUM, ret); - } - - return ret; -} - -int i2c_smbus_write_word_data_retry(struct i2c_client *client, u8 offset, u16 buf) -{ - int i; - int ret = 0; - - for(i=0; i< I2C_RETRY_NUM; i++) { - ret = i2c_smbus_write_word_data(client, offset, buf); - if (ret < 0) { - msleep(I2C_RETRY_DELAY_MS); - continue; - } - break; - } - - if (i >= I2C_RETRY_NUM) { - SWPS_LOG_ERR("%s fail:offset:0x%x try %d/%d! Error Code: %d\n", __func__, offset, i, I2C_RETRY_NUM, ret); - } - return ret; -} -/*the linux i2c_smbus_read_i2c_block_data has block data size limitation : I2C_SMBUS_BLOCK_MAX - * so we need to break the bigger data down*/ -static int inv_i2c_smbus_read_i2c_block_data(struct i2c_client *client, u8 offset, int len, u8 *buf) -{ - int ret = 0; - int i = 0; - int cnt = len; - int block_size = 0; - - while (i < len) { - block_size = ((cnt > I2C_SMBUS_BLOCK_MAX) ? I2C_SMBUS_BLOCK_MAX : cnt); - ret = i2c_smbus_read_i2c_block_data(client, offset+i, block_size, buf+i); - - if (ret < 0) { - break; - } - - i += block_size; - cnt = len - i; - } - - if (ret < 0) { - return ret; - } - return 0; -} -#if 1 -int i2c_smbus_read_i2c_block_data_retry(struct i2c_client *client, u8 offset, int len, u8 *buf) -{ - int ret = 0; - int i = 0; - - for (i = 0; i < I2C_RETRY_NUM; i++) { - ret = inv_i2c_smbus_read_i2c_block_data(client, offset, len, buf); - if (ret < 0) { - msleep(I2C_RETRY_DELAY_MS); - continue; - } - break; - } - - if (i >= I2C_RETRY_NUM) { - SWPS_LOG_ERR("fail:offset:0x%x try %d/%d! Error Code: %d\n", offset, i, I2C_RETRY_NUM, ret); - } - return ret; -} -#else - -int i2c_smbus_read_i2c_block_data_retry(struct i2c_client *client, u8 offset, int len, u8 *buf) -{ - int ret = 0; - int i = 0; - - for (i = 0; i < len; i++) { - ret = i2c_smbus_read_byte_data_retry(client, offset + i); - - if (ret < 0) { - break; - } - buf[i] = ret; - } - if (ret < 0) { - return ret; - } - return 0; -} - - -#endif -/*fsm functions declaration*/ - -static void sff_fsm_delay_cnt_reset(struct sff_obj_t *sff_obj, sff_fsm_state_t st); -static void sff_fsm_cnt_run(struct sff_obj_t *sff_obj); -static bool sff_fsm_delay_cnt_is_hit(struct sff_obj_t *sff_obj); -static int sff_fsm_run(struct sff_mgr_t *sff); - -bool page_sel_is_locked(struct sff_obj_t *sff_obj) -{ - return sff_obj->page_sel_lock; -} - -void page_sel_lock(struct sff_obj_t *sff_obj) -{ - sff_obj->page_sel_lock = true; -} - -void page_sel_unlock(struct sff_obj_t *sff_obj) -{ - sff_obj->page_sel_lock = false; -} -static inline unsigned long prs_bitmap_get(struct sff_mgr_t *sff) -{ - return sff->prs; -} -static inline void prs_bitmap_update(struct sff_mgr_t *sff, unsigned long bitmap) -{ - sff->prs = bitmap; -} -static int sff_prs_bitmap_get(struct sff_mgr_t *sff, unsigned long *prs) -{ - int ret = 0; - unsigned long bitmap = 0; - struct lc_obj_t *lc = sff_to_lc(sff); - if (!p_valid(prs)) { - return -EINVAL; - } - if((ret = sff->io_drv->prs_all_get(lc->lc_id, &bitmap)) < 0) { - return ret; - } - /*use positive logic*/ - bitmap = ~bitmap; - *prs = bitmap; - return 0; -} - -static int sff_prs_bitmap_get_external(struct sff_mgr_t *sff, unsigned long *prs) -{ - int port_num = sff->valid_port_num; - unsigned long bitmap = 0; - unsigned long front_port_prs = 0; - int ret = 0; - int port = 0; - if ((ret = sff_prs_bitmap_get(sff, &bitmap)) < 0) { - return ret; - } - - for (port = 0; port < port_num; port++) { - if (test_bit(port, &bitmap)) { - set_bit(sff->obj[port].front_port, &front_port_prs); - } - } - - *prs = front_port_prs; - return 0; -} -int inv_sff_prs_get(int lc_id, unsigned long *prs) -{ - if (!p_valid(prs)) { - return -EBADRQC; - } - return sff_prs_bitmap_get_external(&(lcMgr.obj[lc_id].sff), prs); -} -EXPORT_SYMBOL(inv_sff_prs_get); - -static bool sff_reset_is_supported(struct sff_obj_t *sff_obj) -{ - return ((SFP_TYPE != sff_obj->type) ? true : false); -} - -static bool sff_lpmode_is_supported(struct sff_obj_t *sff_obj) -{ - return ((SFP_TYPE != sff_obj->type) ? true : false); -} -/* find better way to check if sff_power is supported*/ -static bool sff_power_is_supported(struct sff_obj_t *sff_obj) -{ - return ((PLATFORM_4U == pltfmInfo->id) ? true : false); -} -/*reset set operation comfines sff io reset set and sff fsm transition event*/ -int sff_reset_set_oper(struct sff_obj_t *sff_obj, u8 rst) -{ - int ret = 0; - int cnt = 0; - u8 lock = 0; - transvr_type_set(sff_obj, TRANSVR_CLASS_UNKNOWN); - - if (!rst) { - - lock = (page_sel_is_locked(sff_obj) ? 1 : 0); - - while(cnt <= PAGE_SEL_LOCK_NUM && lock) { - lock = (page_sel_is_locked(sff_obj) ? 1 : 0); - cnt++; - msleep(50); - } - - if (cnt > PAGE_SEL_LOCK_NUM) { - SWPS_LOG_ERR("lock time out\n"); - return -ETIMEDOUT; - } - sff_fsm_st_set(sff_obj, SFF_FSM_ST_SUSPEND); - if (cnt > 0) { - SWPS_LOG_INFO("page_sel_lock occured\n"); - } - } else { - sff_fsm_st_set(sff_obj, SFF_FSM_ST_RESTART); - } - if((ret = sff_obj->func_tbl->reset_set(sff_obj, rst)) < 0) { - return ret; - } - return 0; -} -static unsigned long frontPort_to_phyPort(struct sff_mgr_t *sff, - unsigned long front_bitmap) -{ - int port = 0; - int front_port = 0; - int front_port_num = 0; - unsigned long phy_bitmap = 0; - - front_port_num = sff->valid_port_num; - for (front_port = 0; front_port < front_port_num; front_port++) { - port = sff->frontPort_to_port[front_port]; - - if (test_bit(front_port, &front_bitmap)) { - set_bit(port, &phy_bitmap); - } else { - clear_bit(port, &phy_bitmap); - } - } - return phy_bitmap; -} -static unsigned long phyPort_to_frontPort(struct sff_mgr_t *sff, - unsigned long phy_bitmap) -{ - int port = 0; - int port_num = 0; - unsigned long front_bitmap = 0; - struct sff_obj_t *sff_obj = NULL; - - port_num = sff->valid_port_num; - for (port = 0; port < port_num; port++) { - - sff_obj = &sff->obj[port]; - - if (test_bit(port, &phy_bitmap)) { - set_bit(sff_obj->front_port, &front_bitmap); - } else { - clear_bit(sff_obj->front_port, &front_bitmap); - } - } - - return front_bitmap; -} - -static void sff_fsm_op_process(struct sff_mgr_t *sff, - bool (*is_supported)(struct sff_obj_t *sff_obj), - unsigned long phy_bitmap) -{ - int port = 0; - int port_num = sff->valid_port_num; - struct sff_obj_t *sff_obj = NULL; - if (!p_valid(sff) && !p_valid(is_supported)) { - SWPS_LOG_ERR("null input\n"); - return; - } - port_num = sff->valid_port_num; - for (port = 0; port < port_num; port++) { - - sff_obj = &sff->obj[port]; - if (!is_supported(sff_obj)) { - continue; - } - transvr_type_set(sff_obj, TRANSVR_CLASS_UNKNOWN); - - if (!test_bit(port, &phy_bitmap)) { - sff_fsm_st_set(sff_obj, SFF_FSM_ST_SUSPEND); - } else { - sff_fsm_st_set(sff_obj, SFF_FSM_ST_RESTART); - } - } -} - -/*(in) bitmap , is in front port order*/ -int inv_sff_output_set(sff_io_output_type_t type, int lc_id, unsigned long bitmap) -{ - unsigned long phy_bitmap = 0; - struct sff_mgr_t *sff = NULL; - int ret = 0; - int (*set_func)(int lc_id, unsigned long bitmap) = NULL; - - sff = &lcMgr.obj[lc_id].sff; - phy_bitmap = frontPort_to_phyPort(sff, bitmap); - - switch (type) { - - case SFF_IO_RST_TYPE: - set_func = sff->io_drv->reset_all_set; - sff_fsm_op_process(sff, sff_reset_is_supported, phy_bitmap); - break; - case SFF_IO_PWR_TYPE: - set_func = sff->io_drv->power_all_set; - sff_fsm_op_process(sff, sff_power_is_supported, phy_bitmap); - break; - case SFF_IO_LPMODE_TYPE: - set_func = sff->io_drv->lpmode_all_set; - break; - default: - break; - } - check_pfunc(set_func); - if ((ret = set_func(lc_id, phy_bitmap)) < 0) { - return ret; - } - return 0; -} -/*output bitmap , is in front port order*/ -int inv_sff_output_get(sff_io_output_type_t type, int lc_id, unsigned long *bitmap) -{ - unsigned long phy_bitmap = 0; - struct sff_mgr_t *sff = NULL; - int ret = 0; - int (*get_func)(int lc_id, unsigned long *bitmap) = NULL; - - sff = &lcMgr.obj[lc_id].sff; - - switch (type) { - - case SFF_IO_RST_TYPE: - get_func = sff->io_drv->reset_all_get; - break; - case SFF_IO_PWR_TYPE: - get_func = sff->io_drv->power_all_get; - break; - case SFF_IO_LPMODE_TYPE: - get_func = sff->io_drv->lpmode_all_get; - break; - default: - break; - } - check_pfunc(get_func); - if ((ret = get_func(lc_id, &phy_bitmap)) < 0) { - return ret; - } - *bitmap = phyPort_to_frontPort(sff, phy_bitmap); - return 0; -} -int inv_sff_reset_set(int lc_id, unsigned long bitmap) -{ - return inv_sff_output_set(SFF_IO_RST_TYPE, lc_id, bitmap); -} -EXPORT_SYMBOL(inv_sff_reset_set); - -/*bitmap , is in front port order*/ -int inv_sff_reset_get(int lc_id, unsigned long *bitmap) -{ - return inv_sff_output_get(SFF_IO_RST_TYPE, lc_id, bitmap); -} -EXPORT_SYMBOL(inv_sff_reset_get); - -int sff_lpmode_set_oper(struct sff_obj_t *sff_obj, u8 val) -{ - int ret = 0; - - if((ret = sff_obj->func_tbl->lpmode_set(sff_obj, val)) < 0) { - return ret; - } - - return 0; -} -int inv_sff_lpmode_set(int lc_id, unsigned long bitmap) -{ - return inv_sff_output_set(SFF_IO_LPMODE_TYPE, lc_id, bitmap); -} -EXPORT_SYMBOL(inv_sff_lpmode_set); - -/*bitmap , is in front port order*/ -int inv_sff_lpmode_get(int lc_id, unsigned long *bitmap) -{ - return inv_sff_output_get(SFF_IO_LPMODE_TYPE, lc_id, bitmap); -} -EXPORT_SYMBOL(inv_sff_lpmode_get); - -int inv_sff_power_set(int lc_id, unsigned long bitmap) -{ - return inv_sff_output_set(SFF_IO_PWR_TYPE, lc_id, bitmap); -} -EXPORT_SYMBOL(inv_sff_power_set); - -int inv_sff_power_get(int lc_id, unsigned long *bitmap) -{ - return inv_sff_output_get(SFF_IO_PWR_TYPE, lc_id, bitmap); -} -EXPORT_SYMBOL(inv_sff_power_get); - -int dummy_page_get(struct sff_obj_t *sff_obj, u8 *page) -{ - return -ENOSYS; -} -int dummy_page_sel(struct sff_obj_t *sff_obj, int page) -{ - return -ENOSYS; -} -int dummy_eeprom_dump(struct sff_obj_t *sff_obj, u8 *buf) -{ - return -ENOSYS; -} - -int sff_eeprom_read(struct sff_obj_t *sff_obj, - u8 addr, - u8 offset, - u8 *buf, - int len) -{ - check_pfunc(sff_obj->mgr->eeprom_drv->eeprom_read); - return sff_obj->mgr->eeprom_drv->eeprom_read(sff_obj->lc_id, sff_obj->port, addr, offset, buf, len); - -} - -int inv_sff_eeprom_read(const unsigned int lc_id, - const unsigned port, - const unsigned int addr, - const unsigned int offset, - const unsigned int count, - u8 *buf) -{ - int phy_port = 0; - int front_port = 0; - struct sff_obj_t *sff_obj = NULL; - struct sff_mgr_t *sff = NULL; - - sff = &lcMgr.obj[lc_id].sff; - front_port = port; - phy_port = sff->frontPort_to_port[front_port]; - sff_obj = &sff->obj[phy_port]; - return sff_eeprom_read(sff_obj, addr, offset, buf, count); -} -EXPORT_SYMBOL(inv_sff_eeprom_read); - -int sff_eeprom_write(struct sff_obj_t *sff_obj, - u8 addr, - u8 offset, - const u8 *buf, - int len) -{ - check_pfunc(sff_obj->mgr->eeprom_drv->eeprom_write); - return sff_obj->mgr->eeprom_drv->eeprom_write(sff_obj->lc_id, sff_obj->port, addr, offset, buf, len); -} -int inv_sff_eeprom_write(const unsigned int lc_id, - const unsigned port, - const unsigned int addr, - const unsigned int offset, - const unsigned int count, - const u8 *buf) -{ - int phy_port = 0; - int front_port = 0; - struct sff_obj_t *sff_obj = NULL; - struct sff_mgr_t *sff = NULL; - - sff = &lcMgr.obj[lc_id].sff; - front_port = port; - phy_port = sff->frontPort_to_port[front_port]; - sff_obj = &sff->obj[phy_port]; - return sff_eeprom_write(sff_obj, addr, offset, buf, count); -} -EXPORT_SYMBOL(inv_sff_eeprom_write); - -static long -sscanf_to_long(const char *buf, long *value) -{ - long result = 0; - char hex_tag[] = "0x"; - char *ptr = NULL; - ptr = strstr(buf, hex_tag); - if (ptr) { - if (strcspn(buf, hex_tag) == 0) { /*first index*/ - if (sscanf(buf,"%lx",&result) < 0) { - goto exit_err; - } - } else { - goto exit_err; - } - } else { - if (sscanf(buf,"%ld",&result) < 0) { - goto exit_err; - } - } - *value = result; - return 0; - -exit_err: - return -EBADRQC; -} - -bool match(const char *str1, const char *str2) -{ - bool is_match = false; - if(strcmp(str1, str2) == 0) { - is_match = true; - } - return is_match; -} - -static int sff_type_get(struct sff_obj_t *sff_obj) -{ - int type = SFP_TYPE; - type = sff_obj->type; - return type; - -} -/*sysfs attr*/ -/* a custom attribute that works just for a struct sff_kobj. */ -struct swps_attribute { - struct attribute attr; - ssize_t (*show)(struct swps_kobj_t *sff, struct swps_attribute *attr, char *buf); - ssize_t (*store)(struct swps_kobj_t *sff, struct swps_attribute *attr, const char *buf, size_t count); -}; -#define to_swps_attr(x) container_of(x, struct swps_attribute, attr) - -static ssize_t swps_attr_show(struct kobject *kobj, struct attribute *attr, - char *buf) -{ - struct swps_attribute *attribute; - struct swps_kobj_t *obj; - - attribute = to_swps_attr(attr); - obj = to_swps_kobj(kobj); - - if (!p_valid(attribute->show)) { - return -EIO; - } - - return attribute->show(obj, attribute, buf); - -} - -static ssize_t swps_attr_store(struct kobject *kobj, struct attribute *attr, - const char *buf, size_t count) -{ - struct swps_attribute *attribute; - struct swps_kobj_t *obj; - - attribute = to_swps_attr(attr); - obj = to_swps_kobj(kobj); - - if (!p_valid(attribute->store)) - return -ENOSYS; - - return attribute->store(obj, attribute, buf, count); - -} -static struct sysfs_ops swps_sys_ops = { - .show = swps_attr_show, - .store = swps_attr_store, -}; - -void swps_kobj_release(struct kobject *kobj) -{ - struct swps_kobj_t *obj; - obj = to_swps_kobj(kobj); - - if (p_valid(obj)) { - SWPS_LOG_INFO("%s\n", obj->kobj.name); - kfree(obj); - } -} - -static struct kobj_type swpsKtype = { - .release = swps_kobj_release, - .sysfs_ops = &swps_sys_ops, - .default_attrs = NULL, -}; - - -static ssize_t sff_page_store(struct swps_kobj_t *swps_kobj, struct swps_attribute *attr, - const char *buf, size_t count) -{ - int ret = 0; - int page = 0; - struct sff_obj_t *sff_obj = swps_kobj->sff_obj; - ret = sscanf_to_int(buf, &page); - if(ret < 0) { - return ret; - } - - ret = sff_obj->func_tbl->page_sel(sff_obj, page); - - if (ret < 0) { - return ret; - } - - return count; -} -static ssize_t sff_page_sel_lock_store(struct swps_kobj_t *swps_kobj, struct swps_attribute *attr, - const char *buf, size_t count) -{ - int ret = 0; - int lock = 0; - struct sff_obj_t *sff_obj = swps_kobj->sff_obj; - ret = sscanf_to_int(buf, &lock); - if(ret < 0) { - return ret; - } - if (lock != 1 && lock != 0) { - return -EINVAL; - } - if (1 == lock) { - page_sel_lock(sff_obj); - } else { - page_sel_unlock(sff_obj); - } - return count; -} -static ssize_t lc_prs_show(struct swps_kobj_t *swps_kobj, struct swps_attribute *attr, - char *buf) -{ - struct sff_mgr_t *sff = swps_kobj->sff_obj->mgr; - struct lc_obj_t *card = sff_to_lc(sff); - unsigned long sys_ready = card->mgr->lc_sys_ready; - return scnprintf(buf, BUF_SIZE, "0x%lx\n", sys_ready); -} - -static ssize_t lc_phy_ready_show(struct swps_kobj_t *swps_kobj, struct swps_attribute *attr, - char *buf) -{ - unsigned long phy_ready = 0; - struct sff_mgr_t *sff = swps_kobj->sff_obj->mgr; - struct lc_obj_t *card = sff_to_lc(sff); - - phy_ready = card->phy_ready_bitmap; - - return scnprintf(buf, BUF_SIZE, "0x%lx\n", phy_ready); -} -static ssize_t lc_phy_ready_store(struct swps_kobj_t *swps_kobj, struct swps_attribute *attr, - const char *buf, size_t count) -{ - unsigned long phy_ready = 0; - int ret = 0; - struct sff_mgr_t *sff = swps_kobj->sff_obj->mgr; - struct lc_obj_t *lc = sff_to_lc(sff); - - ret = sscanf_to_long(buf, &phy_ready); - //ret = string_to_long(buf, &phy_ready); - if(ret < 0) { - return ret; - } - if (phy_ready != lc->phy_ready_bitmap) { - SWPS_LOG_DBG("%s phy_ready:0x%lx -> 0x%lx\n", lc->name, lc->phy_ready_bitmap, phy_ready); - } - - lc->phy_ready_bitmap = phy_ready; - return count; -} -static ssize_t lc_temp_show(struct swps_kobj_t *swps_kobj, struct swps_attribute *attr, - char *buf) -{ - int ret = 0; - struct sff_mgr_t *sff = swps_kobj->sff_obj->mgr; - struct lc_obj_t *card = sff_to_lc(sff); - struct lc_func_t *lc_func = NULL; - - lc_func = card->mgr->lc_func; - check_pfunc(lc_func->temp_get); - if ((ret = lc_func->temp_get(card->lc_id, buf, BUF_SIZE)) < 0) { - return ret; - } - - return scnprintf(buf, BUF_SIZE, "%s", buf); -} -/*it's for testing*/ -static ssize_t lc_temp_store(struct swps_kobj_t *swps_kobj, struct swps_attribute *attr, - const char *buf, size_t count) -{ - int temp = 0; - int ret = 0; - struct sff_mgr_t *sff = swps_kobj->sff_obj->mgr; - struct lc_obj_t *card = sff_to_lc(sff); - - ret = sscanf_to_int(buf, &temp); - if (ret < 0) { - return ret; - } - - ret = lc_dev_temp_th_set(card->lc_id, temp); - if (ret < 0) { - return ret; - } - - return count; -} - -static ssize_t lc_type_show(struct swps_kobj_t *swps_kobj, struct swps_attribute *attr, - char *buf) -{ - int ret = 0; - struct sff_mgr_t *sff = swps_kobj->sff_obj->mgr; - struct lc_obj_t *card = sff_to_lc(sff); - struct lc_func_t *lc_func = card->mgr->lc_func; - - check_pfunc(lc_func->power_ready); - if((ret = lc_func->type_get_text(card->lc_id, buf, BUF_SIZE)) < 0) { - return ret; - } - - return scnprintf(buf, BUF_SIZE, "%s", buf); -} - -static ssize_t lc_power_ready_show(struct swps_kobj_t *swps_kobj, struct swps_attribute *attr, - char *buf) -{ - int ret = 0; - struct sff_mgr_t *sff = swps_kobj->sff_obj->mgr; - struct lc_obj_t *card = sff_to_lc(sff); - struct lc_func_t *lc_func = card->mgr->lc_func; - bool ready = false; - - check_pfunc(lc_func->power_ready); - if ((ret = lc_func->power_ready(card->lc_id, &ready)) < 0) { - return ret; - } - - return scnprintf(buf, BUF_SIZE, "%d\n", ready); -} -#if 0 /*reserved*/ -static ssize_t lc_power_store(struct swps_kobj_t *swps_kobj, struct swps_attribute *attr, - const char *buf, size_t count) -{ - int ret = 0; - struct sff_mgr_t *sff = swps_kobj->sff_obj->mgr; - struct lc_obj_t *card = sff_to_lc(sff); - struct lc_func_t *lc_func = card->mgr->lc_func; - bool on = false; - int power = 0; - - ret = sscanf_to_int(buf, &power); - - if(ret < 0) { - return ret; - } - on = (power ? true : false); - check_pfunc(lc_func->power_set); - if ((ret = lc_func->power_set(card->lc_id, on)) < 0) { - return ret; - } - - return count; -} -#endif -static ssize_t sff_eeprom_dump_show(struct swps_kobj_t *swps_kobj, struct swps_attribute *attr, - char *buf) -{ - int ret = 0; - struct sff_obj_t *sff_obj = swps_kobj->sff_obj; - - ret = sff_obj->func_tbl->eeprom_dump(sff_obj, buf); - - if(ret < 0) { - return ret; - } - - return scnprintf(buf, BUF_SIZE, "%s", buf); -} -static ssize_t id_show(struct swps_kobj_t *swps_kobj, struct swps_attribute *attr, - char *buf) -{ - unsigned char id = 0; - int ret = 0; - struct sff_obj_t *sff_obj = swps_kobj->sff_obj; - - ret = sff_obj->func_tbl->id_get(sff_obj, &id); - - if(ret < 0) { - return ret; - } - - return scnprintf(buf, BUF_SIZE, "0x%x\n", id); -} -/*qsfp_dd only*/ - -static ssize_t active_ctrl_set_show(struct swps_kobj_t *swps_kobj, struct swps_attribute *attr, - char *buf) -{ - int ret = 0; - struct sff_obj_t *sff_obj = swps_kobj->sff_obj; - - if ((ret = qsfp_dd_active_ctrl_set_get(sff_obj, buf, BUF_SIZE)) < 0) { - return ret; - } - return scnprintf(buf, BUF_SIZE, "%s", buf); -} - -static ssize_t sff_intr_flag_show(struct swps_kobj_t *swps_kobj, struct swps_attribute *attr, - char *buf) -{ - int ret = 0; - struct sff_obj_t *sff_obj = swps_kobj->sff_obj; - - check_pfunc(sff_obj->func_tbl->intr_flag_show); - if ((ret = sff_obj->func_tbl->intr_flag_show(sff_obj, buf, BUF_SIZE)) < 0) { - return ret; - } - return scnprintf(buf, BUF_SIZE, "%s", buf); -} -static ssize_t module_st_show(struct swps_kobj_t *swps_kobj, struct swps_attribute *attr, - char *buf) -{ - u8 val = 0; - int ret = 0; - struct sff_obj_t *sff_obj = swps_kobj->sff_obj; - - ret = sff_obj->func_tbl->module_st_get(sff_obj, &val); - - if(ret < 0) { - return ret; - } - return scnprintf(buf, BUF_SIZE, "0x%x\n", val); -} -static ssize_t type_show(struct swps_kobj_t *swps_kobj, struct swps_attribute *attr, - char *buf) -{ - int type = 0; - struct sff_obj_t *sff_obj = swps_kobj->sff_obj; - - type = sff_type_get(sff_obj); - if (SFP_TYPE == type) { - return scnprintf(buf, BUF_SIZE, "%s\n", "SFP_TYPE"); - } else if (QSFP_TYPE == type) { - return scnprintf(buf, BUF_SIZE, "%s\n", "QSFP_TYPE"); - } else { - - return scnprintf(buf, BUF_SIZE, "%s\n", "QSFP_DD_TYPE"); - - } - -} -static ssize_t sff_port_num_show(struct swps_kobj_t *swps_kobj, struct swps_attribute *attr, - char *buf) -{ - struct sff_obj_t *sff_obj = swps_kobj->sff_obj; - return scnprintf(buf, BUF_SIZE, "%d\n", sff_obj->mgr->valid_port_num); -} - -static ssize_t swps_version_show(struct swps_kobj_t *swps_kobj, struct swps_attribute *attr, - char *buf) -{ - return scnprintf(buf, BUF_SIZE, "%s\n", SWPS_VERSION); -} - -static ssize_t pltfm_name_show(struct swps_kobj_t *swps_kobj, struct swps_attribute *attr, - char *buf) -{ - return scnprintf(buf, BUF_SIZE, "%s\n", pltfmInfo->name); -} -static ssize_t io_no_init_show(struct swps_kobj_t *swps_kobj, struct swps_attribute *attr, - char *buf) -{ - return scnprintf(buf, BUF_SIZE, "%d\n", io_no_init); -} - -static ssize_t log_level_show(struct swps_kobj_t *swps_kobj, struct swps_attribute *attr, - char *buf) -{ - return scnprintf(buf, BUF_SIZE, "%x\n", logLevel); -} - -static ssize_t log_level_store(struct swps_kobj_t *swps_kobj, struct swps_attribute *attr, - const char *buf, size_t count) -{ - int lv = 0; - int ret = 0; - - ret = sscanf_to_int(buf, &lv); - if (ret < 0) { - return ret; - } - logLevel = lv; - - return count; -} -static int -sscanf_to_int(const char *buf, int *value) -{ -#if 1 - int result = 0; - char hex_tag[] = "0x"; - char *ptr = NULL; - ptr = strstr(buf, hex_tag); - if (ptr) { - if (strcspn(buf, hex_tag) == 0) { /*first index*/ - if (sscanf(buf,"%x",&result) < 0) { - goto exit_err; - } - } else { - goto exit_err; - } - } else { - if (sscanf(buf,"%d",&result) < 0) { - goto exit_err; - } - } - *value = result; - return 0; - -exit_err: - return -EBADRQC; -#else - - int ldata = 0; - int ret = 0; - /*use kernel api instead*/ - if (!buf || !value) { - return -EINVAL; - } - ret = kstrtol(buf, 16, &ldata); - if (ret < 0) { - - return ret; - } - *value = (int)ldata; - return 0; - -#endif -} -static ssize_t lane_control_store(int ctrl_type, struct swps_kobj_t *swps_kobj, - const char *buf, size_t count) -{ - int ch_ctrl = 0; - int ret = 0; - struct sff_obj_t *sff_obj = swps_kobj->sff_obj; - ret = sscanf_to_int(buf, &ch_ctrl); - SWPS_LOG_DBG("ch_ctrl:0x%x ret:%d\n", ch_ctrl, ret); - - if(ret < 0) { - return ret; - } - ret = sff_obj->func_tbl->lane_control_set(sff_obj, ctrl_type, ch_ctrl); - - if(ret < 0) { - return ret; - } - return count; -} -static ssize_t lane_control_show(int ctrl_type, struct swps_kobj_t *swps_kobj, char *buf) -{ - u32 ch_ctrl = 0; - int ret = 0; - struct sff_obj_t *sff_obj = swps_kobj->sff_obj; - - ret = sff_obj->func_tbl->lane_control_get(sff_obj, ctrl_type, &ch_ctrl); - - if(ret < 0) { - return ret; - } - return scnprintf(buf, BUF_SIZE, "0x%x\n", ch_ctrl); -} -static ssize_t sff_tx_eq_store(struct swps_kobj_t *kobj, struct swps_attribute *attr, - const char *buf, size_t count) -{ - return lane_control_store(TX_EQ_TYPE, kobj, buf, count); - -} -static ssize_t sff_rx_em_store(struct swps_kobj_t *kobj, struct swps_attribute *attr, - const char *buf, size_t count) -{ - return lane_control_store(RX_EM_TYPE, kobj, buf, count); -} - -static ssize_t sff_rx_am_store(struct swps_kobj_t *kobj, struct swps_attribute *attr, - const char *buf, size_t count) -{ - return lane_control_store(RX_AM_TYPE, kobj, buf, count); -} - -static ssize_t sff_tx_eq_show(struct swps_kobj_t *kobj, struct swps_attribute *attr, - char *buf) -{ - return lane_control_show(TX_EQ_TYPE, kobj, buf); -} -static ssize_t sff_rx_em_show(struct swps_kobj_t *kobj, struct swps_attribute *attr, - char *buf) -{ - return lane_control_show(RX_EM_TYPE, kobj, buf); -} -static ssize_t sff_rx_am_show(struct swps_kobj_t *kobj, struct swps_attribute *attr, - char *buf) -{ - return lane_control_show(RX_AM_TYPE, kobj, buf); -} -static ssize_t lane_status_show(int st_type, struct swps_kobj_t *swps_kobj, char *buf) -{ - u8 ch_status = 0; - int ret = 0; - struct sff_obj_t *sff_obj = swps_kobj->sff_obj; - - ret = sff_obj->func_tbl->lane_status_get(sff_obj, st_type, &ch_status); - - if(ret < 0) { - return ret; - } - return scnprintf(buf, BUF_SIZE, "0x%x\n", ch_status); - -} -static ssize_t sff_rx_los_show(struct swps_kobj_t *kobj, struct swps_attribute *attr, - char *buf) -{ - return lane_status_show(LN_STATUS_RX_LOS_TYPE, kobj, buf); -} -static ssize_t sff_tx_los_show(struct swps_kobj_t *kobj, struct swps_attribute *attr, - char *buf) -{ - return lane_status_show(LN_STATUS_TX_LOS_TYPE, kobj, buf); -} -static ssize_t sff_tx_fault_show(struct swps_kobj_t *kobj, struct swps_attribute *attr, - char *buf) -{ - return lane_status_show(LN_STATUS_TX_FAULT_TYPE, kobj, buf); -} -static ssize_t lane_monitor_show(int moni_type, struct swps_kobj_t *swps_kobj, char *buf) -{ - int ret = 0; - struct sff_obj_t *sff_obj = swps_kobj->sff_obj; - ret = sff_obj->func_tbl->lane_monitor_get(sff_obj, moni_type, buf, BUF_SIZE); - if(ret < 0) { - return ret; - } - return scnprintf(buf, BUF_SIZE, "%s", buf); -} -static ssize_t sff_tx_power_show(struct swps_kobj_t *kobj, struct swps_attribute *attr, - char *buf) -{ - return lane_monitor_show(LN_MONITOR_TX_PWR_TYPE, kobj, buf); -} -static ssize_t sff_rx_power_show(struct swps_kobj_t *kobj, struct swps_attribute *attr, - char *buf) -{ - return lane_monitor_show(LN_MONITOR_RX_PWR_TYPE, kobj, buf); -} -static ssize_t sff_tx_bias_show(struct swps_kobj_t *kobj, struct swps_attribute *attr, - char *buf) -{ - return lane_monitor_show(LN_MONITOR_TX_BIAS_TYPE, kobj, buf); -} - -static ssize_t vendor_info_show(int info_type, struct swps_kobj_t *swps_kobj, char *buf) -{ - int ret = 0; - struct sff_obj_t *sff_obj = swps_kobj->sff_obj; - - ret = sff_obj->func_tbl->vendor_info_get(sff_obj, info_type, buf, BUF_SIZE); - - if(ret < 0) { - return ret; - } - return scnprintf(buf, BUF_SIZE, "%s", buf); -} -static ssize_t vendor_name_show(struct swps_kobj_t *kobj, struct swps_attribute *attr, - char *buf) -{ - return vendor_info_show(VENDOR_NAME_TYPE, kobj, buf); -} -static ssize_t vendor_pn_show(struct swps_kobj_t *kobj, struct swps_attribute *attr, - char *buf) -{ - return vendor_info_show(VENDOR_PN_TYPE, kobj, buf); -} -static ssize_t vendor_sn_show(struct swps_kobj_t *kobj, struct swps_attribute *attr, - char *buf) -{ - return vendor_info_show(VENDOR_SN_TYPE, kobj, buf); -} -static ssize_t vendor_rev_show(struct swps_kobj_t *kobj, struct swps_attribute *attr, - char *buf) -{ - return vendor_info_show(VENDOR_REV_TYPE, kobj, buf); -} -static ssize_t temperature_show(struct swps_kobj_t *swps_kobj, struct swps_attribute *attr, - char *buf) -{ - int ret = 0; - struct sff_obj_t *sff_obj = swps_kobj->sff_obj; - - ret = sff_obj->func_tbl->temperature_get(sff_obj, buf, BUF_SIZE); - if (ret < 0) { - return ret; - } - - return scnprintf(buf, BUF_SIZE, "%s", buf); -} -static ssize_t voltage_show(struct swps_kobj_t *swps_kobj, struct swps_attribute *attr, - char *buf) -{ - int ret = 0; - struct sff_obj_t *sff_obj = swps_kobj->sff_obj; - - ret = sff_obj->func_tbl->voltage_get(sff_obj, buf, BUF_SIZE); - if (ret < 0) { - return ret; - } - - return scnprintf(buf, BUF_SIZE, "%s", buf); -} - -static ssize_t transvr_type_show(struct swps_kobj_t *swps_kobj, struct swps_attribute *attr, - char *buf) -{ - struct sff_obj_t *sff_obj = swps_kobj->sff_obj; - return scnprintf(buf, BUF_SIZE, "%d\n", transvr_type_get(sff_obj)); -} - -static ssize_t fsm_st_show(struct swps_kobj_t *swps_kobj, struct swps_attribute *attr, - char *buf) -{ - int st = 0; - struct sff_obj_t *sff_obj = swps_kobj->sff_obj; - st = sff_fsm_st_get(sff_obj); - return scnprintf(buf, BUF_SIZE, "%s\n", sff_fsm_st_str[st]); -} -static ssize_t lc_fsm_st_show(struct swps_kobj_t *swps_kobj, struct swps_attribute *attr, - char *buf) -{ - struct sff_mgr_t *sff = swps_kobj->sff_obj->mgr; - struct lc_obj_t *card = sff_to_lc(sff); - return scnprintf(buf, BUF_SIZE, "%s\n", lc_fsm_st_str[card->st]); -} -static ssize_t sff_reset_all_store(struct swps_kobj_t *swps_kobj, struct swps_attribute *attr, - const char *buf, size_t count) -{ - int ret = 0; - unsigned long rst = 0; - struct sff_mgr_t *sff = swps_kobj->sff_obj->mgr; - struct lc_obj_t *card = sff_to_lc(sff); - int i = 0; - - for (i = 0; i < count; i++) { - if (i < sff->valid_port_num) { - if (buf[i] != '0' && buf[i] != '1') { - SWPS_LOG_ERR("%d:set val = %c is not support.\n", i, buf[i]); - return -EINVAL; - } - - if ('1' == buf[i]) { - set_bit(i, &rst); - } else { - clear_bit(i, &rst); - } - } - } - SWPS_LOG_DBG("set val = 0x%lx\n", rst); - if ((ret = inv_sff_reset_set(card->lc_id, rst)) < 0) { - return ret; - } - return count; -} -static ssize_t sff_reset_all_show(struct swps_kobj_t *swps_kobj, struct swps_attribute *attr, - char *buf) -{ - int ret = 0; - unsigned long front_port_rst = 0; - int port = 0; - int front_port = 0; - struct sff_mgr_t *sff = swps_kobj->sff_obj->mgr; - struct lc_obj_t *card = sff_to_lc(sff); - int front_port_num = sff->valid_port_num; - - if ((ret = inv_sff_reset_get(card->lc_id, &front_port_rst)) < 0) { - return ret; - } - - for (front_port = 0; front_port < front_port_num; front_port++) { - port = sff->frontPort_to_port[front_port]; - - if (sff_reset_is_supported(&sff->obj[port])) { - buf[front_port] = (test_bit(front_port, &front_port_rst) ? '1' : '0'); - } else { - buf[front_port] = 'X'; - } - } - - buf[front_port] = '\n'; - return (ssize_t)strlen(buf); -} -static ssize_t sff_lpmode_all_store(struct swps_kobj_t *swps_kobj, struct swps_attribute *attr, - const char *buf, size_t count) -{ - int ret = 0; - unsigned long lpmode = 0; - struct sff_mgr_t *sff = swps_kobj->sff_obj->mgr; - struct lc_obj_t *card = sff_to_lc(sff); - int i = 0; - - for (i = 0; i < count; i++) { - if (i < sff->valid_port_num) { - if (buf[i] != '0' && buf[i] != '1') { - SWPS_LOG_ERR("%d:set val = %c is not support.\n", i, buf[i]); - return -EINVAL; - } - if ('1' == buf[i]) { - set_bit(i, &lpmode); - } else { - clear_bit(i, &lpmode); - } - } - } - if ((ret = inv_sff_lpmode_set(card->lc_id, lpmode)) < 0) { - return ret; - } - return count; -} -static ssize_t sff_lpmode_all_show(struct swps_kobj_t *swps_kobj, struct swps_attribute *attr, - char *buf) -{ - int ret = 0; - unsigned long front_port_lpmode = 0; - int port = 0; - int front_port = 0; - struct sff_mgr_t *sff = swps_kobj->sff_obj->mgr; - struct lc_obj_t *card = sff_to_lc(sff); - int front_port_num = sff->valid_port_num; - - if ((ret = inv_sff_lpmode_get(card->lc_id, &front_port_lpmode)) < 0) { - return ret; - } - - for (front_port = 0; front_port < front_port_num; front_port++) { - port = sff->frontPort_to_port[front_port]; - - if (sff_lpmode_is_supported(&sff->obj[port])) { - buf[front_port] = (test_bit(front_port, &front_port_lpmode) ? '1' : '0'); - } else { - buf[front_port] = 'X'; - } - } - - buf[front_port] = '\n'; - return (ssize_t)strlen(buf); -} -static ssize_t sff_power_all_store(struct swps_kobj_t *swps_kobj, struct swps_attribute *attr, - const char *buf, size_t count) -{ - int ret = 0; - unsigned long power = 0; - struct sff_mgr_t *sff = swps_kobj->sff_obj->mgr; - struct lc_obj_t *card = sff_to_lc(sff); - int i = 0; - - for (i = 0; i < count; i++) { - if (i < sff->valid_port_num) { - if (buf[i] != '0' && buf[i] != '1') { - SWPS_LOG_ERR("%d:set val = %c is not support.\n", i, buf[i]); - return -EINVAL; - } - if ('1' == buf[i]) { - set_bit(i, &power); - } else { - clear_bit(i, &power); - } - } - } - if ((ret = inv_sff_power_set(card->lc_id, power)) < 0) { - return ret; - } - return count; -} -static ssize_t sff_power_all_show(struct swps_kobj_t *swps_kobj, struct swps_attribute *attr, - char *buf) -{ - int ret = 0; - unsigned long front_port_power = 0; - int port = 0; - int front_port = 0; - struct sff_mgr_t *sff = swps_kobj->sff_obj->mgr; - struct lc_obj_t *card = sff_to_lc(sff); - int front_port_num = sff->valid_port_num; - - if ((ret = inv_sff_power_get(card->lc_id, &front_port_power)) < 0) { - return ret; - } - - for (front_port = 0; front_port < front_port_num; front_port++) { - port = sff->frontPort_to_port[front_port]; - - if (sff_power_is_supported(&sff->obj[port])) { - buf[front_port] = (test_bit(front_port, &front_port_power) ? '1' : '0'); - } else { - buf[front_port] = 'X'; - } - } - - buf[front_port] = '\n'; - return (ssize_t)strlen(buf); -} -static ssize_t sff_reset_store(struct swps_kobj_t *swps_kobj, struct swps_attribute *attr, - const char *buf, size_t count) -{ - int ret = 0; - int rst = 0; - struct sff_obj_t *sff_obj = swps_kobj->sff_obj; - - ret = sscanf_to_int(buf, &rst); - - if(ret < 0) { - return ret; - } - - if ((ret = sff_reset_set_oper(sff_obj, rst)) < 0) { - return ret; - } - return count; -} -static ssize_t sff_reset_show(struct swps_kobj_t *swps_kobj, struct swps_attribute *attr, - char *buf) -{ - u8 reset = 0; - int ret = 0; - struct sff_obj_t *sff_obj = swps_kobj->sff_obj; - - ret = sff_obj->func_tbl->reset_get(sff_obj, &reset); - - if (ret < 0) { - return ret; - } - return scnprintf(buf, BUF_SIZE, "%d\n", reset); -} - -static ssize_t sff_power_store(struct swps_kobj_t *swps_kobj, struct swps_attribute *attr, - const char *buf, size_t count) -{ - int ret = 0; - int power = 0; - struct sff_obj_t *sff_obj = swps_kobj->sff_obj; - - ret = sscanf_to_int(buf, &power); - - if(ret < 0) { - return ret; - } - - ret = sff_obj->func_tbl->power_set(sff_obj, power); - - if(ret < 0) { - return ret; - } - - transvr_type_set(sff_obj, TRANSVR_CLASS_UNKNOWN); - - if (power) { - sff_fsm_st_set(sff_obj, SFF_FSM_ST_RESTART); - } else { - sff_fsm_st_set(sff_obj, SFF_FSM_ST_SUSPEND); - } - - return count; -} - -static ssize_t sff_power_show(struct swps_kobj_t *swps_kobj, struct swps_attribute *attr, - char *buf) -{ - u8 power = 0; - int ret = 0; - struct sff_obj_t *sff_obj = swps_kobj->sff_obj; - - ret = sff_obj->func_tbl->power_get(sff_obj, &power); - - if (ret < 0) { - return ret; - } - return scnprintf(buf, BUF_SIZE, "%d\n", power); -} - - -static ssize_t rev4_quick_store(struct swps_kobj_t *swps_kobj, struct swps_attribute *attr, - const char *buf, size_t count) -{ - int ret = 0; - int val = 0; - struct sff_obj_t *sff_obj = swps_kobj->sff_obj; - bool en = false; - ret = sscanf_to_int(buf, &val); - - if(ret < 0) { - return ret; - } - en = ((val) ? true : false); - qsfp_dd_rev4_quick_set(sff_obj, en); - return count; -} -static ssize_t rev4_quick_show(struct swps_kobj_t *swps_kobj, struct swps_attribute *attr, - char *buf) -{ - bool en = false; - struct sff_obj_t *sff_obj = swps_kobj->sff_obj; - - en = qsfp_dd_rev4_quick_get(sff_obj); - return scnprintf(buf, BUF_SIZE, "%d\n", en); -} -static ssize_t gpio_mux_reset_show(struct swps_kobj_t *swps_kobj, struct swps_attribute *attr, - char *buf) -{ - int val = 0; - int ret = 0; - struct sff_mgr_t *sff = swps_kobj->sff_obj->mgr; - struct lc_obj_t *card = sff_to_lc(sff); - struct lc_func_t *lc_func = card->mgr->lc_func; - - check_pfunc(lc_func->mux_reset_get); - if ((ret = lc_func->mux_reset_get(card->lc_id, &val)) < 0) { - return ret; - } - - return scnprintf(buf, BUF_SIZE, "%d\n", val); -} -static ssize_t gpio_mux_reset_store(struct swps_kobj_t *swps_kobj, struct swps_attribute *attr, - const char *buf, size_t count) -{ - int ret = 0; - int val = 0; - struct sff_mgr_t *sff = swps_kobj->sff_obj->mgr; - struct lc_obj_t *card = sff_to_lc(sff); - struct lc_func_t *lc_func = card->mgr->lc_func; - - ret = sscanf_to_int(buf, &val); - if(ret < 0) { - return ret; - } - - check_pfunc(lc_func->mux_reset_set); - if((ret = lc_func->mux_reset_set(card->lc_id, val)) < 0) { - return ret; - } - if (val) { - mux_reset_ch_resel_byLC(card); - SWPS_LOG_DBG("mux_reset_ch_resel done\n"); - } - return count; -} -static ssize_t sff_lpmode_store(struct swps_kobj_t *swps_kobj, struct swps_attribute *attr, - const char *buf, size_t count) -{ - struct sff_obj_t *sff_obj = swps_kobj->sff_obj; - int ret = 0; - int lpmode = 0; - - ret = sscanf_to_int(buf, &lpmode); - - if(ret < 0) { - return ret; - } - ret = sff_obj->func_tbl->lpmode_set(sff_obj, lpmode); - - if(ret < 0) { - return ret; - } - return count; -} -static ssize_t sff_lpmode_show(struct swps_kobj_t *swps_kobj, struct swps_attribute *attr, - char *buf) -{ - u8 lpmode = 0; - int ret = 0; - struct sff_obj_t *sff_obj = swps_kobj->sff_obj; - - ret = sff_obj->func_tbl->lpmode_get(sff_obj, &lpmode); - if (ret < 0) { - return ret; - } - return scnprintf(buf, BUF_SIZE, "%d\n", lpmode); -} -static ssize_t sff_intL_show(struct swps_kobj_t *swps_kobj, struct swps_attribute *attr, - char *buf) -{ - u8 intL = 0; - int ret = 0; - struct sff_obj_t *sff_obj = swps_kobj->sff_obj; - - ret = sff_obj->func_tbl->intL_get(sff_obj, &intL); - if (ret < 0) { - return ret; - } - - return scnprintf(buf, BUF_SIZE, "%d\n", intL); -} -static ssize_t sff_mode_sel_store(struct swps_kobj_t *swps_kobj, struct swps_attribute *attr, - const char *buf, size_t count) -{ - struct sff_obj_t *sff_obj = swps_kobj->sff_obj; - int err_code = -1; - int mode_sel = 0; - int type = 0; - type = sff_type_get(sff_obj); - - if (SFP_TYPE == type) { - - return err_code; - } - err_code = sscanf_to_int(buf, &mode_sel); - - if(err_code < 0) { - return err_code; - } -#if 0 - err_code = mode_sel_set(sff_obj, mode_sel); - - if(err_code < 0) { - return err_code; - } -#endif - return count; -} -static ssize_t sff_mode_sel_show(struct swps_kobj_t *swps_kobj, struct swps_attribute *attr, - char *buf) -{ - u8 mode_sel = 0; - int err_code = -1; - struct sff_obj_t *sff_obj = swps_kobj->sff_obj; - int type = sff_type_get(sff_obj); - - if (SFP_TYPE != type) { -#if 0 - if (mode_sel_get(sff_obj, &mode_sel) < 0) { - return scnprintf(buf, BUF_SIZE, "%d\n", err_code); - } -#endif - } else { - - return scnprintf(buf, BUF_SIZE, "%d\n", err_code); - } - - return scnprintf(buf, BUF_SIZE, "%d\n", mode_sel); -} -static ssize_t sff_tx_disable_store(struct swps_kobj_t *swps_kobj, struct swps_attribute *attr, - const char *buf, size_t count) -{ - int ret = 0; - int tx_disable = 0; - struct sff_obj_t *sff_obj = swps_kobj->sff_obj; - ret = sscanf_to_int(buf, &tx_disable); - - if(ret < 0) { - return ret; - } - - ret = sff_obj->func_tbl->tx_disable_set(sff_obj, tx_disable); - - if(ret < 0) { - return ret; - } - return count; -} -static ssize_t sff_tx_disable_show(struct swps_kobj_t *swps_kobj, struct swps_attribute *attr, - char *buf) -{ - u8 tx_disable = 0; - int ret = 0; - struct sff_obj_t *sff_obj = swps_kobj->sff_obj; - - ret = sff_obj->func_tbl->tx_disable_get(sff_obj, &tx_disable); - - if(ret < 0) { - return ret; - } - - - return scnprintf(buf, BUF_SIZE, "%d\n", tx_disable); -} - -static ssize_t sff_prs_all_show(struct swps_kobj_t *swps_kobj, struct swps_attribute *attr, - char *buf) -{ - int ret = 0; - unsigned long front_port_prs = 0; - int port = 0; - struct sff_mgr_t *sff = swps_kobj->sff_obj->mgr; - int port_num = sff->valid_port_num; - - if ((ret = sff_prs_bitmap_get_external(sff, &front_port_prs)) < 0) { - return ret; - } - - for (port = 0; port < port_num; port++) { - - buf[port] = (test_bit(port, &front_port_prs) ? '1' : '0'); - } - - buf[port] = '\n'; - return (ssize_t)strlen(buf); -} -static ssize_t swps_polling_store(struct swps_kobj_t *swps_kobj, struct swps_attribute *attr, - const char *buf, size_t count) -{ - int enable = 0; - int err_code=0; - err_code = sscanf_to_int(buf, &enable); - if(err_code < 0) - return err_code; - - if(enable == swps_polling_is_enabled()) { - return count; - } - - if(enable) { - swps_polling_task_start(); - } else { - swps_polling_task_stop(); - } - swps_polling_set(enable); - - return count; -} - -static ssize_t sff_apsel_store(struct swps_kobj_t *swps_kobj, struct swps_attribute *attr, - const char *buf, size_t count) -{ - int ret = 0; - int apsel = 0; - struct sff_obj_t *sff_obj = swps_kobj->sff_obj; - ret = sscanf_to_int(buf, &apsel); - - if(ret < 0) { - return ret; - } - if ((ret = qsfp_dd_apsel_apply(sff_obj, apsel)) < 0) { - return ret; - } - - return count; -} -static ssize_t sff_apsel_show(struct swps_kobj_t *swps_kobj, struct swps_attribute *attr, - char *buf) -{ - int apsel = 0; - struct sff_obj_t *sff_obj = swps_kobj->sff_obj; - - apsel = qsfp_dd_apsel_get(sff_obj); - - return scnprintf(buf, BUF_SIZE, "%d\n", apsel); -} - -static ssize_t sff_intr_flag_store(struct swps_kobj_t *swps_kobj, struct swps_attribute *attr, - const char *buf, size_t count) -{ - struct sff_obj_t *sff_obj = swps_kobj->sff_obj; - - if (!match(buf, CLEAR_CMD)) { - return -EINVAL; - } - check_pfunc(sff_obj->func_tbl->intr_flag_clear); - sff_obj->func_tbl->intr_flag_clear(sff_obj); - - return count; -} - -static ssize_t swps_polling_show(struct swps_kobj_t *swps_kobj, struct swps_attribute *attr, - char *buf) -{ - - return scnprintf(buf, BUF_SIZE, "%d\n", swps_polling_is_enabled()); -} - -static ssize_t sff_int_flag_monitor_store(struct swps_kobj_t *swps_kobj, struct swps_attribute *attr, - const char *buf, size_t count) -{ - int enable = 0; - int err_code=0; - err_code = sscanf_to_int(buf, &enable); - if(err_code < 0) - return err_code; - - int_flag_monitor_en = ((enable == 1) ? true : false); - - return count; -} -static ssize_t sff_int_flag_monitor_show(struct swps_kobj_t *swps_kobj, struct swps_attribute *attr, - char *buf) -{ - int enable = 0; - - enable = ((int_flag_monitor_en == true) ? 1 : 0); - return scnprintf(buf, BUF_SIZE, "%d\n", enable); -} - -static ssize_t sff_page_show(struct swps_kobj_t *swps_kobj, struct swps_attribute *attr, - char *buf) -{ - int ret = 0; - u8 page = 0; - struct sff_obj_t *sff_obj = swps_kobj->sff_obj; - ret = sff_obj->func_tbl->page_get(sff_obj, &page); - if (ret < 0) { - return ret; - } - return scnprintf(buf, BUF_SIZE, "%d\n", page); -} - -static ssize_t sff_page_sel_lock_show(struct swps_kobj_t *swps_kobj, struct swps_attribute *attr, - char *buf) -{ - u8 lock = 0; - struct sff_obj_t *sff_obj = swps_kobj->sff_obj; - - lock = (page_sel_is_locked(sff_obj) ? 1 : 0); - return scnprintf(buf, BUF_SIZE, "%d\n", lock); -} - -static struct swps_attribute lc_fsm_st_attr = - __ATTR(fsm_st, S_IRUGO, lc_fsm_st_show, NULL); - -static struct swps_attribute sff_port_num_attr = - __ATTR(port_num, S_IRUGO, sff_port_num_show, NULL); - -static struct swps_attribute sff_type_attr = - __ATTR(type, S_IRUGO, type_show, NULL); - -static struct swps_attribute sff_id_attr = - __ATTR(id, S_IRUGO, id_show, NULL); - -static struct swps_attribute sff_transvr_type_attr = - __ATTR(transvr_type, S_IRUGO, transvr_type_show, NULL); - -static struct swps_attribute sff_fsm_st_attr = - __ATTR(fsm_st, S_IRUGO, fsm_st_show, NULL); - -static struct swps_attribute sff_prs_all_attr = - __ATTR(prs, S_IRUGO, sff_prs_all_show, NULL); - -static struct swps_attribute swps_polling_attr = - __ATTR(swps_polling, S_IWUSR|S_IRUGO, swps_polling_show, swps_polling_store); - -static struct swps_attribute sff_int_flag_monitor_attr = - __ATTR(sff_int_flag_monitor, S_IWUSR|S_IRUGO, sff_int_flag_monitor_show, sff_int_flag_monitor_store); - -static struct swps_attribute sff_reset_attr = - __ATTR(reset, S_IWUSR|S_IRUGO, sff_reset_show, sff_reset_store); -static struct swps_attribute sff_reset_all_attr = - __ATTR(reset, S_IWUSR|S_IRUGO, sff_reset_all_show, sff_reset_all_store); - -static struct swps_attribute sff_lpmode_all_attr = - __ATTR(lpmode, S_IWUSR|S_IRUGO, sff_lpmode_all_show, sff_lpmode_all_store); - -static struct swps_attribute sff_power_all_attr = - __ATTR(power, S_IWUSR|S_IRUGO, sff_power_all_show, sff_power_all_store); - -static struct swps_attribute sff_power_attr = - __ATTR(power, S_IWUSR|S_IRUGO, sff_power_show, sff_power_store); - -static struct swps_attribute sff_intL_attr = - __ATTR(intL, S_IRUGO, sff_intL_show, NULL); - -static struct swps_attribute sff_lpmode_attr = - __ATTR(lpmode, S_IWUSR|S_IRUGO, sff_lpmode_show, sff_lpmode_store); - -static struct swps_attribute sff_mode_sel_attr = - __ATTR(mode_sel, S_IWUSR|S_IRUGO, sff_mode_sel_show, sff_mode_sel_store); - -static struct swps_attribute sff_tx_disable_attr = - __ATTR(tx_disable, S_IWUSR|S_IRUGO, sff_tx_disable_show, sff_tx_disable_store); - -static struct swps_attribute sff_rx_los_attr = - __ATTR(rx_los, S_IRUGO, sff_rx_los_show, NULL); - -static struct swps_attribute sff_tx_los_attr = - __ATTR(tx_los, S_IRUGO, sff_tx_los_show, NULL); - -static struct swps_attribute sff_tx_fault_attr = - __ATTR(tx_fault, S_IRUGO, sff_tx_fault_show, NULL); - -static struct swps_attribute sff_tx_eq_attr = - __ATTR(tx_eq, S_IWUSR|S_IRUGO, sff_tx_eq_show, sff_tx_eq_store); - -static struct swps_attribute sff_rx_em_attr = - __ATTR(rx_em, S_IWUSR|S_IRUGO, sff_rx_em_show, sff_rx_em_store); - -static struct swps_attribute sff_rx_am_attr = - __ATTR(rx_am, S_IWUSR|S_IRUGO, sff_rx_am_show, sff_rx_am_store); - -static struct swps_attribute sff_tx_power_attr = - __ATTR(tx_power, S_IRUGO, sff_tx_power_show, NULL); - -static struct swps_attribute sff_rx_power_attr = - __ATTR(rx_power, S_IRUGO, sff_rx_power_show, NULL); - -static struct swps_attribute sff_tx_bias_attr = - __ATTR(tx_bias, S_IRUGO, sff_tx_bias_show, NULL); - -static struct swps_attribute sff_vendor_name_attr = - __ATTR(vendor_name, S_IRUGO, vendor_name_show, NULL); - -static struct swps_attribute sff_vendor_part_number_attr = - __ATTR(vendor_pn, S_IRUGO, vendor_pn_show, NULL); - -static struct swps_attribute sff_vendor_serial_number_attr = - __ATTR(vendor_sn, S_IRUGO, vendor_sn_show, NULL); - -static struct swps_attribute sff_vendor_rev_attr = - __ATTR(vendor_rev, S_IRUGO, vendor_rev_show, NULL); - -static struct swps_attribute sff_temperature_attr = - __ATTR(temperature, S_IRUGO, temperature_show, NULL); - -static struct swps_attribute sff_voltage_attr = - __ATTR(voltage, S_IRUGO, voltage_show, NULL); - -static struct swps_attribute sff_eeprom_dump_attr = - __ATTR(eeprom_dump, S_IRUGO, sff_eeprom_dump_show, NULL); -static struct swps_attribute sff_page_attr = - __ATTR(page, S_IWUSR|S_IRUGO, sff_page_show, sff_page_store); -static struct swps_attribute sff_page_sel_lock_attr = - __ATTR(page_sel_lock, S_IWUSR|S_IRUGO, sff_page_sel_lock_show, sff_page_sel_lock_store); -static struct swps_attribute sff_module_st_attr = - __ATTR(module_st, S_IRUGO, module_st_show, NULL); -static struct swps_attribute sff_active_ctrl_set_attr = - __ATTR(active_ctrl_set, S_IRUGO, active_ctrl_set_show, NULL); - -static struct swps_attribute sff_apsel_attr = - __ATTR(apsel, S_IWUSR|S_IRUGO, sff_apsel_show, sff_apsel_store); - -static struct swps_attribute sff_intr_flag_attr = - __ATTR(intr_flag, S_IWUSR|S_IRUGO, sff_intr_flag_show, sff_intr_flag_store); - -static struct swps_attribute mux_reset_attr = - __ATTR(mux_reset, S_IWUSR|S_IRUGO, gpio_mux_reset_show, gpio_mux_reset_store); -static struct swps_attribute swps_version_attr = - __ATTR(swps_version, S_IRUGO, swps_version_show, NULL); -static struct swps_attribute lc_prs_attr = - __ATTR(card_prs, S_IRUGO, lc_prs_show, NULL); -static struct swps_attribute lc_temp_attr = - __ATTR(temp, S_IWUSR|S_IRUGO, lc_temp_show, lc_temp_store); -static struct swps_attribute lc_power_ready_attr = - __ATTR(power, S_IRUGO, lc_power_ready_show, NULL); -static struct swps_attribute lc_phy_ready_attr = - __ATTR(phy_ready, S_IWUSR|S_IRUGO, lc_phy_ready_show, lc_phy_ready_store); -static struct swps_attribute lc_type_attr = - __ATTR(type, S_IRUGO, lc_type_show, NULL); -static struct swps_attribute rev4_quick_attr = - __ATTR(rev4_quick, S_IWUSR|S_IRUGO, rev4_quick_show, rev4_quick_store); -static struct swps_attribute log_level_attr = - __ATTR(log_level, S_IWUSR|S_IRUGO, log_level_show, log_level_store); -static struct swps_attribute pltfm_name_attr = - __ATTR(platform, S_IRUGO, pltfm_name_show, NULL); -static struct swps_attribute io_no_init_attr = - __ATTR(io_no_init, S_IRUGO, io_no_init_show, NULL); - -static struct attribute *sfp_attributes[] = { - - /*io pin attribute*/ - &sff_tx_disable_attr.attr, - /*eeprom attribute*/ - &sff_type_attr.attr, - &sff_id_attr.attr, - &sff_tx_eq_attr.attr, - &sff_rx_em_attr.attr, - &sff_rx_am_attr.attr, - &sff_rx_los_attr.attr, - &sff_tx_los_attr.attr, - &sff_tx_fault_attr.attr, - &sff_tx_power_attr.attr, - &sff_rx_power_attr.attr, - &sff_tx_bias_attr.attr, - &sff_temperature_attr.attr, - &sff_voltage_attr.attr, - &sff_vendor_name_attr.attr, - &sff_vendor_part_number_attr.attr, - &sff_vendor_serial_number_attr.attr, - &sff_vendor_rev_attr.attr, - /*transceiver identified info attribute*/ - &sff_transvr_type_attr.attr, - &sff_fsm_st_attr.attr, - //&sff_eeprom_dump_attr.attr, - NULL - -}; - -static struct attribute_group sfp_group = { - .attrs = sfp_attributes, -}; - -static struct attribute *qsfp_attributes[] = { - /*io pin attribute*/ - &sff_reset_attr.attr, - &sff_power_attr.attr, - &sff_lpmode_attr.attr, - &sff_mode_sel_attr.attr, - &sff_intL_attr.attr, - /*eeprom attribute*/ - &sff_type_attr.attr, - &sff_id_attr.attr, - &sff_tx_eq_attr.attr, - &sff_rx_em_attr.attr, - &sff_rx_am_attr.attr, - &sff_rx_los_attr.attr, - &sff_tx_los_attr.attr, - &sff_tx_fault_attr.attr, - &sff_tx_power_attr.attr, - &sff_rx_power_attr.attr, - &sff_tx_bias_attr.attr, - &sff_temperature_attr.attr, - &sff_voltage_attr.attr, - &sff_tx_disable_attr.attr, - &sff_vendor_name_attr.attr, - &sff_vendor_part_number_attr.attr, - &sff_vendor_serial_number_attr.attr, - &sff_vendor_rev_attr.attr, - /*transceiver identified info attribute*/ - &sff_transvr_type_attr.attr, - &sff_fsm_st_attr.attr, - &sff_eeprom_dump_attr.attr, - &sff_page_attr.attr, - NULL -}; -static struct attribute_group qsfp_group = { - .attrs = qsfp_attributes, -}; -static struct attribute *qsfp_dd_attributes[] = { - /*io pin attribute*/ - &sff_reset_attr.attr, - &sff_power_attr.attr, - &sff_lpmode_attr.attr, - &sff_mode_sel_attr.attr, - &sff_intL_attr.attr, - /*eeprom attribute*/ - &sff_type_attr.attr, - &sff_id_attr.attr, - &sff_rx_los_attr.attr, - &sff_tx_los_attr.attr, - &sff_tx_fault_attr.attr, - &sff_tx_power_attr.attr, - &sff_rx_power_attr.attr, - &sff_tx_bias_attr.attr, - &sff_temperature_attr.attr, - &sff_voltage_attr.attr, - &sff_tx_disable_attr.attr, - &sff_vendor_name_attr.attr, - &sff_vendor_part_number_attr.attr, - &sff_vendor_serial_number_attr.attr, - &sff_vendor_rev_attr.attr, - /*transceiver identified info attribute*/ - //&sff_transvr_type_attr.attr, - &sff_fsm_st_attr.attr, - &sff_eeprom_dump_attr.attr, - &sff_page_attr.attr, - &sff_page_sel_lock_attr.attr, - &sff_module_st_attr.attr, - &rev4_quick_attr.attr, - &sff_active_ctrl_set_attr.attr, - &sff_apsel_attr.attr, - &sff_intr_flag_attr.attr, - NULL -}; -static struct attribute_group qsfp_dd_group = { - .attrs = qsfp_dd_attributes, -}; -/*attribute of all sff modules , mainly reprsed as bitmap form*/ -static struct attribute *sff_common_attributes[] = { - &sff_prs_all_attr.attr, - &mux_reset_attr.attr, - &sff_int_flag_monitor_attr.attr, - &sff_port_num_attr.attr, - &sff_reset_all_attr.attr, - &sff_lpmode_all_attr.attr, - &sff_power_all_attr.attr, - NULL -}; -static struct attribute_group sff_common_group = { - .attrs = sff_common_attributes, -}; -static struct attribute *lc_common_attributes[] = { - &swps_version_attr.attr, - &swps_polling_attr.attr, - &lc_prs_attr.attr, - &log_level_attr.attr, - &pltfm_name_attr.attr, - &io_no_init_attr.attr, - NULL -}; -static struct attribute_group lc_common_group = { - .attrs = lc_common_attributes, -}; - -static struct attribute *lc_attributes[] = { - &lc_temp_attr.attr, - &lc_power_ready_attr.attr, - &lc_phy_ready_attr.attr, - &lc_type_attr.attr, - &lc_fsm_st_attr.attr, - NULL -}; -static struct attribute_group lc_group = { - .attrs = lc_attributes, -}; - -static void sff_frontPort_remap_destroy(struct sff_mgr_t *sff) -{ - if (p_valid(sff->frontPort_to_port)) { - kfree(sff->frontPort_to_port); - } -} -static void lc_sff_frontPort_remap_destroy(struct lc_t *card) -{ - int i = 0; - int lc_num = card->lc_num; - - for (i = 0; i < lc_num; i++) { - sff_frontPort_remap_destroy(&card->obj[i].sff); - } -} - -static void sff_objs_destroy(struct sff_mgr_t *sff) -{ - if (p_valid(sff->obj)) { - kfree(sff->obj); - } -} -static void lc_sff_objs_destroy(struct lc_t *card) -{ - int i = 0; - int lc_num = card->lc_num; - - for (i = 0; i < lc_num; i++) { - - sff_objs_destroy(&card->obj[i].sff); - } -} -static void lc_objs_destroy(struct lc_t *card) -{ - if (p_valid(card->obj)) { - kfree(card->obj); - } -} - -static int swps_polling_task_start(void) -{ - /* check what's the right way to reset the fsm state*/ - schedule_delayed_work(&swps_polling, SWPS_POLLING_PERIOD); - return 0; - -} -static int swps_polling_task_stop(void) -{ - - cancel_delayed_work_sync(&swps_polling); - return 0; - -} - -static int sff_objs_init(struct sff_mgr_t *sff, struct port_info_table_t *tbl) -{ - struct port_info_map_t *map = NULL; - struct sff_obj_t *sff_obj = NULL; - int port_num = 0; - int port = 0; - map = tbl->map; - port_num = tbl->size; - - if (!p_valid(tbl)) { - return -EBADRQC; - } - - if (!p_valid(map)) { - return -EBADRQC; - } - - sff_obj = sff->obj; - - for (port = 0; port < port_num; port++) { - - sff_obj[port].port = port; - sff_obj[port].front_port = map[port].front_port; - /*front port to port remap init*/ - sff->frontPort_to_port[sff_obj[port].front_port] = port; - sff_obj[port].type = map[port].type; - sff_obj[port].name = map[port].name; - sff_fsm_init(&sff_obj[port], map[port].type); - func_tbl_init(&sff_obj[port], map[port].type); - } - return 0; -} -/*size of sff_object is the max port numbers on line card - *ex: if 400 line card contain 8 ports - 100 line card contain 32 ports - * we will define size of sff obj = 32 - * however we'll only init 8 ports if it's 400g line card - * */ -static int sff_objs_create(struct sff_mgr_t *sff, int size) -{ - - struct sff_obj_t *sff_obj = NULL; - int port = 0; - struct lc_obj_t *card = sff_to_lc(sff); - - sff_obj = kzalloc(sizeof(struct sff_obj_t) * size, GFP_KERNEL); - if(!p_valid(sff_obj)) { - return -ENOMEM; - } - for (port = 0; port < size; port++) { - /*link sff objs to their container sff*/ - sff_obj[port].mgr = sff; - /*assign lc_id to corresponding sff_obj for fast access*/ - sff_obj[port].lc_id = card->lc_id; - sff_obj[port].lc_name = card->name; - } - sff->obj = sff_obj; - - return 0; -} -static int lc_sff_objs_create(struct lc_t *card, int max_port_num) -{ - int lc_num = card->lc_num; - int i = 0; - int ret = 0; - - for (i = 0; i < lc_num; i++) { - ret = sff_objs_create(&(card->obj[i].sff), max_port_num); - if (ret < 0) { - break; - } - } - - if (ret < 0) { - lc_sff_objs_destroy(card); - } - - return ret; -} - -static int sff_frontPort_remap_create(struct sff_mgr_t *sff, int size) -{ - - int *map = NULL; - - map = kzalloc(sizeof(int) * size, GFP_KERNEL); - if(!p_valid(map)) { - return -ENOMEM; - } - - sff->frontPort_to_port = map; - return 0; - - -} -static int lc_sff_frontPort_remap_create(struct lc_t *card, int max_port_num) -{ - int lc_num = card->lc_num; - int i = 0; - int ret = 0; - - for (i = 0; i < lc_num; i++) { - ret = sff_frontPort_remap_create(&(card->obj[i].sff), max_port_num); - if (ret < 0) { - break; - } - } - - if (ret < 0) { - lc_sff_frontPort_remap_destroy(card); - } - - return ret; -} -static int lc_objs_create(struct lc_t *card) -{ - - struct lc_obj_t *obj = NULL; - int lc_num = card->lc_num; - obj = kzalloc(sizeof(struct lc_obj_t) * lc_num, GFP_KERNEL); - if(!p_valid(obj)) { - return -ENOMEM; - } - - card->obj = obj; - return 0; - -} -static int lc_objs_init(struct lc_t *card) -{ - int lc_num = card->lc_num; - int i = 0; - struct lc_obj_t *obj = NULL; - for (i = 0; i < lc_num; i++) { - obj = &(card->obj[i]); - obj->mgr = card; - obj->lc_id = i; - obj->name = card_name_str[i]; - obj->prs = 0; - obj->wait_stable_cnt = 0; - obj->over_temp_cnt = 0; - obj->st = LC_FSM_ST_IDLE; - obj->power_ready = false; - obj->is_phy_ready = true; - obj->phy_ready_bitmap = 0xff; - obj->ej_released = false; - obj->prs_locked = false; - obj->prs_locked_cnt = 0; - obj->posi_st = LC_POSI_INIT_ST; - obj->mux_l1.i2c_ch = lc_dev_mux_l1_i2c_ch_get(obj->lc_id); - if (obj->mux_l1.i2c_ch < 0) { - SWPS_LOG_ERR("lc_id:%d invalid i2c_ch:%d\n", obj->lc_id, obj->mux_l1.i2c_ch); - return -EBADRQC; - } - } - return 0; -} -static int lc_kobj_common_create(struct lc_t *card) -{ - if (!p_valid(card->common_kobj)) { - card->common_kobj = swps_kobj_add("common", &swpsKset->kobj, &lc_common_group); - } - if(!p_valid(card->common_kobj)) { - return -EBADRQC; - } - /*this link will let card kobj able to link to sff_obj*/ - card->common_kobj->sff_obj = card->obj->sff.obj; - return 0; - -} -static void polling_task_1U(void) -{ - lcMgr.lc_func->dev_hdlr(); - lc_fsm_run_1U(&lcMgr); - if (!i2c_bus_is_alive(&lcMgr.obj[0])) { - i2c_bus_recovery(&lcMgr.obj[0]); - } - io_no_init_handler(&lcMgr); -} -static void polling_task_4U(void) -{ - /*4U real functions - *self->lc_func->dev_handler(self); - *lc_prs_scan(self); - * lc_fsm_run_4U(&lcMgr); - * io_no_init_handler(&lcMgr);*/ - lcMgr.lc_func->dev_hdlr(); - // io_dev_hdlr(); - lc_prs_scan(&lcMgr); - lc_fsm_run_4U(&lcMgr); - io_no_init_handler(&lcMgr); -} -static int lc_func_load(struct lc_t *obj) -{ - if (PLATFORM_4U == pltfmInfo->id) { - obj->lc_func = &lc_func_4U; - } else { - obj->lc_func = &lc_func_1U; - } - - if (!p_valid(obj->lc_func)) { - return -ENOSYS; - } - return 0; -} -static int lc_create_init(struct lc_t *card, int lc_num, int card_max_port_num) -{ - /*init priv parameter*/ - card->lc_num = lc_num; - card->lc_prs = 0; - card->ej_r = 0; - card->ej_l = 0; - card->lc_sys_ready = 0; - if (lc_objs_create(card) < 0) { - goto exit_err; - } - - if (lc_objs_init(card) < 0) { - goto exit_err; - } - - if (lc_sff_objs_create(card, card_max_port_num) < 0) { - goto exit_free_lc_objs; - } - - if (lc_sff_frontPort_remap_create(card, card_max_port_num) < 0) { - goto exit_free_sff_objs; - } - - if (lc_kobj_common_create(card) < 0) { - goto exit_free_frontPort_remap; - SWPS_LOG_ERR("lc_kobj_common_create fail\n"); - } - - return 0; - -exit_free_frontPort_remap: - lc_sff_frontPort_remap_destroy(card); -exit_free_sff_objs: - lc_sff_objs_destroy(card); -exit_free_lc_objs: - lc_objs_destroy(card); -exit_err: - return -EBADRQC; -} -void swps_kobj_del(struct swps_kobj_t **obj) -{ - if (p_valid(*obj)) { - kobject_put(&((*obj)->kobj)); - *obj = NULL; - } -} -/*the function is for adding kobject of port dynamically*/ -static struct swps_kobj_t *swps_kobj_add(char *name, - struct kobject *mgr, - struct attribute_group *attr_group) -{ - int ret = 0; - struct swps_kobj_t *obj = NULL; - obj = kzalloc(sizeof(struct swps_kobj_t), GFP_KERNEL); - if (!p_valid(obj)) { - SWPS_LOG_ERR("sff_kobject_create %s kzalloc error", name); - return NULL; - } - obj->kobj.kset = swpsKset; - - ret = kobject_init_and_add(&obj->kobj, &swpsKtype, mgr, name); - if (ret < 0) { - - kobject_put(&obj->kobj); - SWPS_LOG_ERR("kobject creat fail1\n"); - return NULL; - } - if (NULL != attr_group) { - - SWPS_LOG_DBG("sysfs_create_group: %s\n", name); - if ((ret = sysfs_create_group(&obj->kobj, attr_group)) != 0) { - sysfs_remove_group(&obj->kobj, attr_group); - swps_kobj_del(&obj); - SWPS_LOG_ERR("create sff:%s attrs error.ret:%d\n", name, ret); - return NULL; - } - } - - kobject_uevent(&obj->kobj, KOBJ_ADD); - return obj; -} - -int sff_fsm_kobj_change_event(struct sff_obj_t *sff_obj) -{ - - struct swps_kobj_t *sff_kobj = sff_obj->kobj; - char *uevent_envp[4]; - char tmp_str_1[32]; - snprintf(tmp_str_1, sizeof(tmp_str_1), "%s=%s", "IF_TYPE", "SR4"); - uevent_envp[0] = tmp_str_1; - uevent_envp[1] = NULL; - - kobject_uevent_env(&sff_kobj->kobj, KOBJ_CHANGE, uevent_envp); - return 0; -} -static int sff_kobj_add(struct sff_obj_t *sff_obj) -{ - struct attribute_group *attr_group = &sfp_group; - struct lc_obj_t *card = NULL; - struct swps_kobj_t *mgr_kobj = NULL; - - SWPS_LOG_DBG("%s start\n", sff_obj->name); - - if (SFP_TYPE == sff_obj->type) { - attr_group = &sfp_group; - } else if (QSFP_TYPE == sff_obj->type) { - attr_group = &qsfp_group; - } else { - attr_group = &qsfp_dd_group; - } - card = sff_to_lc(sff_obj->mgr); - mgr_kobj = sff_obj->mgr->mgr_kobj; - if (!p_valid(sff_obj->kobj)) { - sff_obj->kobj = swps_kobj_add(sff_obj->name, &(mgr_kobj->kobj), attr_group); - } - if(!p_valid(sff_obj->kobj)) { - return -EBADRQC; - } - - sff_obj->kobj->sff_obj = sff_obj; - return 0; -} - -static int sff_kobj_del(struct sff_obj_t *sff_obj) -{ - struct swps_kobj_t **sff_kobj = &(sff_obj->kobj); - - if(p_valid(*sff_kobj)) { - swps_kobj_del(sff_kobj); - } - return 0; -} -static int sff_kset_create_init(void) -{ - swpsKset = kset_create_and_add(SWPS_KSET, NULL, NULL); - - if(!p_valid(swpsKset)) { - SWPS_LOG_ERR("kset creat fail\n"); - return -EBADRQC; - } - return 0; -} -static int sff_kset_deinit(void) -{ - if(p_valid(swpsKset)) { - kset_unregister(swpsKset); - } - return 0; -} - -static int lc_kobj_init_create(struct lc_obj_t *card) -{ - int lc_num = card->mgr->lc_num; - struct attribute_group *attr_group = NULL; - - if (TYPE_4U == lc_num) { - attr_group = &lc_group; - } - if (!p_valid(card->card_kobj)) { - card->card_kobj = swps_kobj_add(card->name, &swpsKset->kobj, attr_group); - } - if(!p_valid(card->card_kobj)) { - return -EBADRQC; - } - - /*this link will let card kobj able to link to sff_obj*/ - card->card_kobj->sff_obj = card->sff.obj; - return 0; -} -static int lc_sff_mgr_kobj_create(struct lc_obj_t *card) -{ -#if !defined (DYNAMIC_SFF_KOBJ) - struct sff_obj_t *sff_obj = NULL; - int port = 0; - int port_num = card->sff.valid_port_num; - int ret = 0; -#endif - if(!p_valid(card->card_kobj)) { - return -EBADRQC; - } - - if(!p_valid(card->sff.mgr_kobj)) { - card->sff.mgr_kobj = swps_kobj_add("sff", &(card->card_kobj->kobj), &sff_common_group); - } - if(!p_valid(card->sff.mgr_kobj)) { - return -EBADRQC; - } - /*this link will let card kobj able to link to sff_obj*/ - card->sff.mgr_kobj->sff_obj = card->sff.obj; -#if !defined (DYNAMIC_SFF_KOBJ) - for (port = 0; port < port_num; port++) { - sff_obj = &(card->sff.obj[port]); - if ((ret =sff_kobj_add(sff_obj)) < 0) { - return ret; - } - } -#endif - return 0; -} - -/*@note: kobj num is identical to valid port num*/ -static void sff_kobjs_destroy(struct sff_mgr_t *sff) -{ - int port; - int port_num = sff->valid_port_num; - struct sff_obj_t *sff_obj = NULL; - for (port = 0; port < port_num; port++) { - sff_obj = &(sff->obj[port]); - sff_kobj_del(sff_obj); - } -} -static void lc_sff_kobjs_destroy(struct lc_t *card) -{ - int i; - int lc_num = card->lc_num; - struct sff_mgr_t *sff = NULL; - for (i = 0; i < lc_num; i++) { - sff = &(card->obj[i].sff); - sff_kobjs_destroy(sff); - } - -} -static void _lc_kobj_destroy(struct lc_obj_t *obj) -{ - if (p_valid(obj->card_kobj)) { - swps_kobj_del(&(obj->card_kobj)); - } -} -static void _lc_sff_mgr_kobj_destroy(struct lc_obj_t *obj) -{ - if(p_valid(obj->sff.mgr_kobj)) { - swps_kobj_del(&(obj->sff.mgr_kobj)); - } -} -static void lc_kobj_destroy(struct lc_t *card) -{ - - int i; - int lc_num = card->lc_num; - struct lc_obj_t *obj = NULL; - for (i = 0; i < lc_num; i++) { - obj = &(card->obj[i]); - _lc_sff_mgr_kobj_destroy(obj); - _lc_kobj_destroy(obj); - } -} -static void lc_common_kobj_destroy(struct lc_t *card) -{ - if(p_valid(card->common_kobj)) { - swps_kobj_del(&(card->common_kobj)); - } -} -static void transvr_insert(struct sff_obj_t *sff_obj) -{ - SWPS_LOG_INFO("into %s\n", sff_obj->name); - sff_fsm_st_set(sff_obj, SFF_FSM_ST_INSERTED); - transvr_type_set(sff_obj, TRANSVR_CLASS_UNKNOWN); -#if defined (DYNAMIC_SFF_KOBJ) - sff_kobj_add(sff_obj); -#endif -} -static void transvr_remove(struct sff_obj_t *sff_obj) -{ - struct mux_ch_t *mux = NULL; - struct lc_obj_t *lc = sff_to_lc(sff_obj->mgr); - - mux = &(lc->mux_l1); - SWPS_LOG_INFO("from %s\n", sff_obj->name); - sff_fsm_st_set(sff_obj, SFF_FSM_ST_REMOVED); - transvr_type_set(sff_obj, TRANSVR_CLASS_UNKNOWN); -#if defined (DYNAMIC_SFF_KOBJ) - sff_kobj_del(sff_obj); -#endif - - if (0 != mux->block_ch) { - mux->is_fail = false; - mux->block_ch &= ~(1L << (sff_obj->port)); - if(mux_ch_block(mux->i2c_ch, mux->block_ch) < 0) { - - SWPS_LOG_INFO(" %s unblock mux ch fail\n", sff_obj->name); - } else { - mux_fail_reset(mux->i2c_ch); - SWPS_LOG_INFO(" %s unblock mux ch ok block_ch:%lx\n", sff_obj->name, mux->block_ch); - } - } -} - -static int io_no_init_scan(struct sff_mgr_t *sff) -{ - int ret = 0; - int port = 0; - int port_num = sff->valid_port_num; - struct sff_obj_t *sff_obj = NULL; - unsigned long bitmap=0; - - - if((ret = sff_prs_bitmap_get(sff, &bitmap)) < 0) { - return ret; - } - prs_bitmap_update(sff, bitmap); //update current prs_bitmap - - for (port = 0; port < port_num; port++) { - - sff_obj = &sff->obj[port]; - ret = io_no_init_done_fsm_run(sff_obj); - if (ret < 0) { - break; - } - } - - return ret; -} -static int sff_prs_scan(struct sff_mgr_t *sff) -{ - int ret = 0; - unsigned long bitmap=0; - unsigned long prs_change = 0; - int port = 0; - struct sff_obj_t *sff_obj = NULL; - int port_num = sff->valid_port_num; - /* probably can't get all prs pins status at once - in case one bad transciver module is plugged in, it will lead to i2c bus hang up - we need to figure out the way to detect this situation and skip it and send out the warning */ - if((ret = sff_prs_bitmap_get(sff, &bitmap)) < 0) { - SWPS_LOG_ERR("fail\n"); - return ret; - } - /*check which bits are updated*/ - //bitmap = ~bitmap; /*reverse it to be human readable format*/ - prs_change = bitmap ^ prs_bitmap_get(sff); - prs_bitmap_update(sff, bitmap); //update current prs_bitmap - - for (port = 0; port < port_num; port++) { - sff_obj = &(sff->obj[port]); - if(test_bit(port, &prs_change)) { - if(test_bit(port, &bitmap)) { - transvr_insert(sff_obj); - } else { - transvr_remove(sff_obj); - } - } - } - return 0; -} -static void swps_polling_task(struct work_struct *work) -{ - lcMgr.lc_func->polling_task(); - schedule_delayed_work(&swps_polling, SWPS_POLLING_PERIOD); -} - - -/*fsm functions*/ - -inline sff_fsm_state_t sff_fsm_st_get(struct sff_obj_t *sff_obj) -{ - return sff_obj->fsm.st; -} -inline void sff_fsm_st_set(struct sff_obj_t *sff_obj, sff_fsm_state_t st) -{ - sff_fsm_state_t old_st = sff_obj->fsm.st; - sff_fsm_st_chg_process(sff_obj, old_st, st); - sff_obj->fsm.st = st; -} -/*set target count to new fsm state*/ -static void sff_fsm_delay_cnt_reset(struct sff_obj_t *sff_obj, sff_fsm_state_t st) -{ - int found = 0; - int idx = 0; - struct sff_fsm_t *fsm = &(sff_obj->fsm); - struct fsm_period_t *table = fsm->period_tbl; - for (idx = 0; table[idx].st != SFF_FSM_ST_END; idx++) { - if (st == table[idx].st) { - found = 1; - break; - } - } - fsm->cnt = 0; - - if (found) { - fsm->delay_cnt = table[idx].delay_cnt; - } else { - fsm->delay_cnt = 0; - } -} -static void sff_fsm_cnt_run(struct sff_obj_t *sff_obj) -{ - - (sff_obj->fsm.cnt)++; -} -static bool sff_fsm_delay_cnt_is_hit(struct sff_obj_t *sff_obj) -{ - bool is_hit = false; - struct sff_fsm_t *fsm = &(sff_obj->fsm); - - - if(fsm->cnt >= fsm->delay_cnt) { - fsm->cnt = 0; - is_hit = true; - } - return is_hit; -} - -int dummy_lane_control_set(struct sff_obj_t *sff_obj, int type, u32 value) -{ - return -ENOSYS; -} -int dummy_lane_control_get(struct sff_obj_t *sff_obj, int type, u32 *value) -{ - return -ENOSYS; -} - -int dummy_lane_status_get(struct sff_obj_t *sff_obj, int type, u8 *st) -{ - return -ENOSYS; -} - -int sff_prs_get(struct sff_obj_t *sff_obj, u8 *prs) -{ - int ret = 0; - unsigned long bitmap = 0; - struct sff_mgr_t *sff = sff_obj->mgr; - if (!p_valid(prs)) { - return -EINVAL; - } - if ((ret = sff_prs_bitmap_get(sff, &bitmap)) < 0) { - return ret; - } - if (test_bit(sff_obj->port, &bitmap)) { - *prs = 1; - } else { - *prs = 0; - } - return 0; -} -int sff_power_set(struct sff_obj_t *sff_obj, u8 value) -{ - int ret = 0; - - check_pfunc(sff_obj->mgr->io_drv->power_set); - if ((ret = sff_obj->mgr->io_drv->power_set(sff_obj->lc_id, sff_obj->port, value)) < 0) { - return ret; - } - - return 0; -} -int sff_power_get(struct sff_obj_t *sff_obj, u8 *value) -{ - int ret = 0; - - check_pfunc(sff_obj->mgr->io_drv->power_get); - if ((ret = sff_obj->mgr->io_drv->power_get(sff_obj->lc_id, sff_obj->port, value)) < 0) { - return ret; - } - return 0; -} - -int dummy_intL_get(struct sff_obj_t *sff_obj, u8 *value) -{ - return -ENOSYS; - -} -int dummy_reset_set(struct sff_obj_t *sff_obj, u8 value) -{ - return -ENOSYS; -} -int dummy_reset_get(struct sff_obj_t *sff_obj, u8 *value) -{ - - return -ENOSYS; - -} -int dummy_lpmode_set(struct sff_obj_t *sff_obj, u8 value) -{ - return -ENOSYS; -} -int dummy_lpmode_get(struct sff_obj_t *sff_obj, u8 *value) -{ - - return -ENOSYS; - -} -int dummy_mode_sel_set(struct sff_obj_t *sff_obj, u8 value) -{ - - return -ENOSYS; - -} -int dummy_mode_sel_get(struct sff_obj_t *sff_obj, u8 *value) -{ - - return -ENOSYS; - -} -void sff_fsm_st_chg_process(struct sff_obj_t *sff_obj, - sff_fsm_state_t cur_st, - sff_fsm_state_t next_st) -{ - if (cur_st != next_st) { - - sff_fsm_delay_cnt_reset(sff_obj, next_st); - //SWPS_LOG_DBG("port:%d st change:%d -> %d\n", - // port, st,sff_fsm_st_get(sff_obj)); - if (p_valid(sff_obj->lc_name) && p_valid(sff_obj->name)) { - SWPS_LOG_DBG("%s %s st change:%s -> %s\n", - sff_obj->lc_name, sff_obj->name, sff_fsm_st_str[cur_st], - sff_fsm_st_str[next_st]); - } - } -} -/*io_no_init is special functions when remove and re insert modules don't do sff io control to avoid cause port flap*/ -static void io_no_init_port_done_set(struct sff_obj_t *sff_obj) -{ - unsigned long *bitmap = &(sff_obj->mgr->io_no_init_port_done); - set_bit(sff_obj->port, bitmap); - -} -static int io_no_init_done_fsm_run(struct sff_obj_t *sff_obj) -{ - u8 prs = 0; - int ret = 0; - int old_st = 0; - if ((ret = sff_prs_get(sff_obj, &prs)) < 0) { - return ret; - } - - old_st = sff_fsm_st_get(sff_obj); - if (prs) { - sff_fsm_st_set(sff_obj, SFF_FSM_ST_READY); -#if defined (DYNAMIC_SFF_KOBJ) - sff_kobj_add(sff_obj); -#endif - } else { - sff_fsm_st_set(sff_obj, SFF_FSM_ST_REMOVED); -#if defined (DYNAMIC_SFF_KOBJ) - sff_kobj_del(sff_obj); -#endif - } - - io_no_init_port_done_set(sff_obj); - - return ret; -} -static void io_no_init_handler_by_card(struct lc_obj_t *card) -{ - unsigned long mask = 0; - struct sff_mgr_t *sff = &(card->sff); - unsigned long *card_done = NULL; - unsigned long port_done = 0; - if (0 == io_no_init) { - return; - } - card_done = &(card->mgr->io_no_init_all_done); - if (test_bit(card->lc_id, card_done)) { - return; - } - mask = MASK_CREATE(sff->valid_port_num); - port_done = sff->io_no_init_port_done; - SWPS_LOG_DBG("done_bitmap:0x%lx mask:0x%lx\n", port_done, mask); - if (mask == port_done) { - SWPS_LOG_DBG("card:%d io_no_init done\n", card->lc_id); - set_bit(card->lc_id, card_done); - /*switch back to normal present scan function*/ - sff->prs_scan = sff_prs_scan; - } -} -static void io_no_init_handler(struct lc_t *card) -{ - int i = 0; - int lc_num = card->lc_num; - unsigned long all_done = card->io_no_init_all_done; - unsigned long lc_ready = 0; - lc_fsm_st_t st = LC_FSM_ST_IDLE; - - if (io_no_init) { - for (i = 0; i < lc_num; i++) { - st = lc_fsm_st_get(&card->obj[i]); - if (LC_FSM_ST_READY == st) { - set_bit(i, &lc_ready); - } - } - - if (all_done != 0 && - lc_ready == all_done) { - io_no_init = 0; - SWPS_LOG_DBG("io_no_init all done\n"); - } - } - -} -static int sff_fsm_run(struct sff_mgr_t *sff) -{ - int port = 0; - int ret = 0; - struct sff_obj_t *sff_obj = NULL; - int port_num = sff->valid_port_num; - - for(port = 0; port < port_num; port++) { - sff_obj = &(sff->obj[port]); - if (sff_fsm_delay_cnt_is_hit(sff_obj)) { - ret = sff_obj->fsm.task(sff_obj); - if (ret < 0) { - break; - } - } - sff_fsm_cnt_run(sff_obj); - } - if (ret < 0) { - return ret; - } - return 0; -} - -static int lc_phy_ready(struct lc_obj_t *card, bool *is_ready) -{ - unsigned long bitmap = 0; - if (!p_valid(is_ready)) { - return -EINVAL; - } - bitmap = card->phy_ready_bitmap; - check_pfunc(card->mgr->lc_func->phy_ready); - card->mgr->lc_func->phy_ready(bitmap, is_ready); - - return 0; -} - -static int _lc_fsm_run_1U(struct lc_obj_t *card) -{ - lc_fsm_st_t st = LC_FSM_ST_IDLE; - int ret = 0; - struct port_info_table_t *port_info = NULL; - - if (!p_valid(card)) { - SWPS_LOG_ERR("NULL ptr\n"); - return -EINVAL; - } - st = lc_fsm_st_get(card); - switch (st) { - - case LC_FSM_ST_IDLE: - lc_fsm_st_set(card, LC_FSM_ST_INIT); - break; - - case LC_FSM_ST_INIT: - - ret = lc_kobj_init_create(card); - if (ret < 0) { - break; - } - port_info = pltfmInfo->tbl_1st; - if (!p_valid(port_info)) { - ret = -EBADRQC; - break; - } - sff_data_init(&card->sff, port_info->size); - sff_func_init(&card->sff); - if(sff_objs_init(&(card->sff), port_info) < 0) { - SWPS_LOG_ERR("sff_objs_init fail\n"); - break;; - } - - ret = lc_sff_mgr_kobj_create(card); - if (ret < 0) { - break; - } - - lc_fsm_st_set(card, LC_FSM_ST_READY); - - break; - - case LC_FSM_ST_READY: - - if ((ret = card->sff.prs_scan(&card->sff)) < 0) { - break; - } - if ((ret = sff_fsm_run(&card->sff)) < 0) { - break; - } - io_no_init_handler_by_card(card); - - break; - - default: - break; - } - if (ret < 0) { - return ret; - } - return 0; -} -static bool is_skip_io_ctrl(void) -{ - return (io_no_init ? true : false); -} - -static void lc_sys_ready_set(struct lc_obj_t *card, bool ready) -{ - unsigned long *sys_ready = &(card->mgr->lc_sys_ready); - if (ready) { - set_bit(card->lc_id, sys_ready); - } else { - clear_bit(card->lc_id, sys_ready); - } -} -static int _lc_fsm_run_4U(struct lc_obj_t *card) -{ - lc_fsm_st_t st = LC_FSM_ST_IDLE; - int ret = 0; - bool is_power_ready = false; - bool is_phy_ready = false; - bool asserted = false; - bool deasserted = false; - struct port_info_table_t *port_info = NULL; - struct lc_func_t *lc_func = NULL; - struct mux_ch_t *mux = NULL; - lc_type_t type = LC_UNKNOWN_TYPE; - - if (!p_valid(card)) { - SWPS_LOG_ERR("NULL ptr\n"); - return -EINVAL; - } - lc_func = card->mgr->lc_func; - st = lc_fsm_st_get(card); - switch (st) { - - case LC_FSM_ST_IDLE: - break; - case LC_FSM_ST_REMOVE: - - sff_kobjs_destroy(&card->sff); - _lc_sff_mgr_kobj_destroy(card); - _lc_kobj_destroy(card); - mux = &(card->mux_l1); - if (0 != mux->block_ch) { - if ((ret = mux_ch_block(mux->i2c_ch, 0)) < 0) { - break; - } - mux_fail_reset(mux->i2c_ch); - } - check_pfunc(lc_func->power_set); - if ((ret = lc_func->power_set(card->lc_id, false)) < 0) { - SWPS_LOG_ERR("%s turn off power fail\n", card->name); - } - check_pfunc(lc_func->led_set); - if ((ret = lc_func->led_set(card->lc_id, LC_LED_CTRL_OFF)) < 0) { - break; - } - - lc_sys_ready_set(card, false); - lc_fsm_st_set(card, LC_FSM_ST_IDLE); - break; - - case LC_FSM_ST_INSERT: - - lc_fsm_st_set(card, LC_FSM_ST_WAIT_STABLE); - card->wait_stable_cnt = 0; - check_pfunc(lc_func->reset_set); - if ((ret = lc_func->reset_set(card->lc_id, 0)) < 0) { - break; - } - break; - case LC_FSM_ST_WAIT_STABLE: - card->wait_stable_cnt++; - if (card->wait_stable_cnt >= LC_INSERT_WAIT_STABLE_NUM) { - card->wait_stable_cnt = 0; - } else { - break; - } - check_pfunc(lc_func->type_get); - if ((ret = lc_func->type_get(card->lc_id, &type)) < 0) { - card->type = LC_UNKNOWN_TYPE; - break; - } - card->type = type; - if (PLATFORM_4U == pltfmInfo->id) { - if (LC_100G_TYPE != type) { - SWPS_LOG_ERR("platform %s only support 100G card\n", pltfmInfo->name); - lc_fsm_st_set(card, LC_FSM_ST_UNSUPPORTED); - break; - } - } - /* do we need to check power status before setting the power*/ - ret = lc_kobj_init_create(card); - if (ret < 0) { - break; - } - /*init sw structure*/ - port_info = lc_port_info_get(card, card->type); - if (!p_valid(port_info)) { - ret = -EBADRQC; - lc_fsm_st_set(card, LC_FSM_ST_FAULT); - break; - } - sff_data_init(&card->sff, port_info->size); - sff_func_init(&card->sff); - if(sff_objs_init(&(card->sff), port_info) < 0) { - SWPS_LOG_ERR("sff_objs_init fail\n"); - break;; - } - - if (is_skip_io_ctrl()) { - lc_fsm_st_set(card, LC_FSM_ST_INIT); - break; - } - lc_fsm_st_set(card, LC_FSM_ST_POWER_ON); - - break; - case LC_FSM_ST_POWER_ON: - - check_pfunc(lc_func->power_set); - if ((ret = lc_func->power_set(card->lc_id, true)) < 0) { - break; - } - - lc_fsm_st_set(card, LC_FSM_ST_POWER_CHECK); - - break; - - case LC_FSM_ST_POWER_CHECK: - - check_pfunc(lc_func->power_ready); - if ((ret = lc_func->power_ready(card->lc_id, &is_power_ready)) < 0) { - break; - } - - if (is_power_ready) { - check_pfunc(lc_func->phy_reset_set); - if ((ret = lc_func->phy_reset_set(card->lc_id, 1)) < 0) { - break; - } - lc_fsm_st_set(card, LC_FSM_ST_INIT); - } - break; - - case LC_FSM_ST_INIT: - /*the follow status is used to notify phy driver the lc sys(power and phy reset) is ready*/ - lc_sys_ready_set(card, true); - - check_pfunc(lc_func->cpld_init); - if ((ret = lc_func->cpld_init(card->lc_id)) < 0) { - break; - } - ret = lc_sff_mgr_kobj_create(card); - if (ret < 0) { - break; - } - - lc_fsm_st_set(card, LC_FSM_ST_PHY_CHECK); - - break; - - case LC_FSM_ST_PHY_CHECK: - - if ((ret = lc_phy_ready(card, &is_phy_ready)) < 0) { - break; - } - if (is_phy_ready) { - check_pfunc(lc_func->led_set); - if ((ret = lc_func->led_set(card->lc_id, LC_LED_CTRL_GREEN_ON)) < 0) { - - SWPS_LOG_INFO("%s phy ready\n", card->name); - break; - } - if ((ret = lc_dev_led_boot_amber_set(card->lc_id, false)) < 0) { - break; - } - } - lc_fsm_st_set(card, LC_FSM_ST_READY); - SWPS_LOG_INFO("%s becomes ready\n", card->name); - break; - - case LC_FSM_ST_READY: - - ret = lc_phy_ready(card, &is_phy_ready); - if (ret < 0) { - break; - } - - if (!is_phy_ready) { - - check_pfunc(lc_func->led_set); - if ((ret = lc_func->led_set(card->lc_id, LC_LED_CTRL_RED_ON)) < 0) { - break; - } - //lc_fsm_st_set(card, LC_FSM_ST_FAULT); - } else { - - check_pfunc(lc_func->led_set); - if ((ret = lc_func->led_set(card->lc_id, LC_LED_CTRL_GREEN_ON)) < 0) { - break; - } - - } - - if ((ret = lc_sff_intr_hdlr_byCard(card->lc_id)) < 0) { - break; - } - - if ((ret = card->sff.prs_scan(&card->sff)) < 0) { - break; - } - - if ((ret = sff_fsm_run(&card->sff)) < 0) { - break; - } - if (!i2c_bus_is_alive(card)) { - i2c_bus_recovery(card); - } - if (card->over_temp_cnt++ >= LC_OVER_TEMP_NUM) { - card->over_temp_cnt = 0; - - check_pfunc(lc_func->over_temp_asserted); - if ((ret = lc_func->over_temp_asserted(card->lc_id, &asserted)) < 0) { - break; - } - if (asserted) { - SWPS_LOG_ERR("%s thermal trip!\n", card->name); - check_pfunc(lc_func->power_set); - if ((ret = lc_func->power_set(card->lc_id, false)) < 0) { - break; - } - check_pfunc(lc_func->led_set); - if ((ret = lc_func->led_set(card->lc_id, LC_LED_CTRL_OFF)) < 0) { - break; - } - lc_sys_ready_set(card, false); - - sff_kobjs_destroy(&card->sff); - sff_data_reset(&card->sff); - _lc_sff_mgr_kobj_destroy(card); - lc_fsm_st_set(card, LC_FSM_ST_THERMAL_TRIP); - break; - } - } - if ((ret = lc_sff_intr_hdlr_byCard(card->lc_id)) < 0) { - break; - } - - if ((ret = card->sff.prs_scan(&card->sff)) < 0) { - break; - } - - io_no_init_handler_by_card(card); - - break; - case LC_FSM_ST_THERMAL_TRIP: - /*if over-temp warning is lifted, restart power on sequence*/ - /*temp check*/ - if (card->over_temp_cnt++ >= 10) { - card->over_temp_cnt = 0; - check_pfunc(lc_func->over_temp_deasserted); - if ((ret = lc_func->over_temp_deasserted(card->lc_id, &deasserted)) < 0) { - break; - } - if (deasserted) { - lc_fsm_st_set(card, LC_FSM_ST_POWER_ON); - check_pfunc(lc_func->reset_set); - if ((ret = lc_func->reset_set(card->lc_id, 0)) < 0) { - break; - } - } - } - break; - case LC_FSM_ST_UNSUPPORTED: - break; - case LC_FSM_ST_FAULT: - //lc_fsm_st_set(card, LC_FSM_ST_PHY_CHECK); - break; - default: - break; - } - if (ret < 0) { - return ret; - } - return 0; -} - -static int lc_fsm_run_1U(struct lc_t *card) -{ - int ret = 0; - ret = _lc_fsm_run_1U(&card->obj[0]); - if (ret < 0) { - return ret; - } - return 0; -} -/*i2c bus check and recovery functons*/ -static bool i2c_bus_is_alive(struct lc_obj_t *card) -{ - struct lc_func_t *lc_func = card->mgr->lc_func; - if (NULL == lc_func->i2c_is_alive) { - SWPS_LOG_ERR("no function\n"); - return false; - } - return lc_func->i2c_is_alive(card->lc_id); -} -static void mux_reset_seq(struct lc_obj_t *card) -{ - struct lc_func_t *lc_func = card->mgr->lc_func; - if (NULL == lc_func->mux_reset_set) { - SWPS_LOG_ERR("no function\n"); - return; - } - - lc_func->mux_reset_set(card->lc_id, 0); - msleep(1); - lc_func->mux_reset_set(card->lc_id, 1); -} -#if 0 /*old method keep it temporary*/ -static void bad_transvr_detect(struct lc_obj_t *card) -{ - int port = 0; - struct sff_obj_t *sff_obj = NULL; - int port_num = card->sff.valid_port_num; - - SWPS_LOG_DBG("%s start\n", card->name); - for (port = 0; port < port_num; port++) { - - sff_obj = &(card->sff.obj[port]); - if (SFF_FSM_ST_ISOLATED == sff_fsm_st_get(sff_obj)) { - continue; - } - if (SFF_FSM_ST_IDLE != sff_fsm_st_get(sff_obj)) { - - if (sff_obj->func_tbl->is_id_matched(sff_obj)) { - SWPS_LOG_DBG("%s id matched\n", sff_obj->name); - continue; - } - if (!i2c_bus_is_alive(card)) { - SWPS_LOG_ERR("transvr in %s isolated\n", sff_obj->name); - sff_fsm_st_set(sff_obj, SFF_FSM_ST_ISOLATED); - mux_reset_seq(card); - mux_reset_ch_resel_byLC(card); - } else { - - SWPS_LOG_ERR("%s i2c bus is alive\n", sff_obj->name); - } - } - - } - - SWPS_LOG_ERR("bad transvr report == \n"); - for (port = 0; port < port_num; port++) { - - sff_obj = &(card->sff.obj[port]); - if (SFF_FSM_ST_ISOLATED == sff_fsm_st_get(sff_obj)) { - SWPS_LOG_ERR("transvr in %s isolated\n", sff_obj->name); - } - } - SWPS_LOG_ERR("bad transvr report == \n"); -} -#endif -#define MAX_ACC_SIZE (1023) - -int read_ufile(const char *path_t, - char *buf, - size_t len) -{ - int err = 0; - struct file *fp; - mm_segment_t fs; - loff_t pos; - - if (len >= MAX_ACC_SIZE) { - len = MAX_ACC_SIZE - 1; - } - fp = filp_open(path_t, O_RDONLY, S_IRUGO); - if (IS_ERR(fp)) { - SWPS_LOG_ERR("open path%s fail\n", path_t); - return -ENODEV; - } - fs = get_fs(); - set_fs(KERNEL_DS); - pos = 0; -#if ( LINUX_VERSION_CODE < KERNEL_VERSION(4,14,0) ) - err = vfs_read(fp, buf, len, &pos); -#else - err = kernel_read(fp, buf, len, &pos); -#endif - if (err < 0) { - SWPS_LOG_ERR("%s: vfs_read failed.\n", __func__); - } - filp_close(fp, NULL); - set_fs(fs); - return err; -} - -static int write_ufile(const char *path_t, - char *buf, - size_t len) -{ - int err = 0; - struct file *fp; - mm_segment_t fs; - loff_t pos; - - if (len >= MAX_ACC_SIZE) { - len = MAX_ACC_SIZE - 1; - } - fp = filp_open(path_t, O_WRONLY, S_IWUSR | S_IRUGO); - - if (IS_ERR(fp)) { - SWPS_LOG_ERR("open path%s fail\n", path_t); - return -ENODEV; - } - fs = get_fs(); - set_fs(KERNEL_DS); - pos = 0; -#if ( LINUX_VERSION_CODE < KERNEL_VERSION(4,14,0) ) - err = vfs_write(fp, buf, len, &pos); -#else - err = kernel_write(fp, buf, len, &pos); -#endif - if (err < 0) { - SWPS_LOG_ERR("%s: vfs_write failed.\n", __func__); - } - filp_close(fp, NULL); - set_fs(fs); - return err; -} - -int mux_is_fail(int i2c_ch, bool *is_fail) -{ - char path_t[100]; - int ret = 0; - char reg[5]; - int st = 0; - - memset(path_t, 0, sizeof(path_t)); - memset(reg, 0, sizeof(reg)); - - snprintf(path_t, sizeof(path_t), "/sys/bus/i2c/devices/i2c-%d/%d-0071/mux_fail", - i2c_ch, i2c_ch); - - if ((ret = read_ufile(path_t, reg, sizeof(reg))) < 0) { - - return ret; - } - - ret = sscanf_to_int(reg, &st); - if(ret < 0) { - return ret; - } - *is_fail = (st ? true:false); - return 0; -} - -int mux_last_ch_get(int i2c_ch, unsigned long *mux_ch) -{ - char path_t[100]; - int ret = 0; - char reg[70]; - unsigned long st = 0; - - memset(path_t, 0, sizeof(path_t)); - memset(reg, 0, sizeof(reg)); - - snprintf(path_t, sizeof(path_t), "/sys/bus/i2c/devices/i2c-%d/%d-0071/current_channel", - i2c_ch, i2c_ch); - - if ((ret = read_ufile(path_t, reg, sizeof(reg))) < 0) { - return ret; - } - - ret = sscanf_to_long(reg, &st); - if(ret < 0) { - return ret; - } - *mux_ch = st; - return 0; - -} - -static int mux_fail_reset(int i2c_ch) -{ - char path_t[100]; - int ret = 0; - char block[5]; - int mux_is_fail = 0; - - memset(path_t, 0, sizeof(path_t)); - memset(block, 0, sizeof(block)); - - snprintf(path_t, sizeof(path_t), "/sys/bus/i2c/devices/i2c-%d/%d-0071/mux_fail", - i2c_ch, i2c_ch); - - snprintf(block, sizeof(block), "%d", - mux_is_fail); - - ret = write_ufile(path_t, block, sizeof(block)); - if (ret < 0) { - SWPS_LOG_ERR("mux_fail reset fail i2c_ch:%d\n", i2c_ch); - } - return ret; -} - -static int mux_ch_block(int i2c_ch, unsigned long mux_ch) -{ - char path_t[100]; - int ret = 0; - char block[70]; - - memset(path_t, 0, sizeof(path_t)); - memset(block, 0, sizeof(block)); - - snprintf(path_t, sizeof(path_t), "/sys/bus/i2c/devices/i2c-%d/%d-0071/block_channel", - i2c_ch, i2c_ch); - - snprintf(block, sizeof(block), "%ld", - mux_ch); - - ret = write_ufile(path_t, block, sizeof(block)); - if (ret < 0) { - SWPS_LOG_ERR("mux_ch_block fail i2c_ch:%d mux_ch:%ld\n", i2c_ch, mux_ch); - } - return ret; -} - -static int num_to_power_two(int num) -{ - int i = 0; - int size = 8 * sizeof(num); - for (i = 0; i < size; i++) { - - if (test_bit(i, (unsigned long *)&num)) { - break; - } - } - return i; -} -static void failed_mux_detect(struct lc_obj_t *card) -{ - unsigned long mux_ch = 0; - int port = 0; - bool is_fail = false; - struct mux_ch_t *mux = NULL; - struct sff_obj_t *sff_obj = NULL; - unsigned long block_all = 0; - mux = &card->mux_l1; - - /*step 1 check if mux failed*/ - if (mux_is_fail(mux->i2c_ch, &is_fail) < 0) { - - SWPS_LOG_ERR("mux_ch check fail mux_ch:0x%lx \n", mux_ch); - return; - } - if (is_fail) { - /*step 2 block all mux ch*/ - block_all = (1L << (card->sff.valid_port_num)) - 1; - if (mux_ch_block(mux->i2c_ch, block_all) < 0) { - return; - } - SWPS_LOG_ERR("block_ch:0x%lx\n", block_all); - mux->is_fail = true; - if (mux_last_ch_get(mux->i2c_ch, &mux_ch) < 0) { - return; - } - mux->mux_ch = mux_ch; - /*print out info */ - SWPS_LOG_ERR("mux_ch check OK mux_ch:0x%lx \n", mux_ch); - } - /*step 3 reset mux*/ - mux_reset_seq(card); - /*step 4 block failed mux ch*/ - if (mux->is_fail && mux->mux_ch != 0) { - mux->block_ch |= mux->mux_ch; - if (mux->block_ch > block_all) { - SWPS_LOG_ERR("block_ch:0x%lx out of range\n", mux->block_ch); - return; - } - if (mux_ch_block(mux->i2c_ch, mux->block_ch) < 0) { - return; - } - /*following is for set sff_fsm_st to isolated*/ - port = num_to_power_two(mux->mux_ch); - if (port < 0 && port > card->sff.valid_port_num) { - SWPS_LOG_ERR("port out of range: %d\n", port); - return; - } - sff_obj = &(card->sff.obj[port]); - SWPS_LOG_ERR("block_ch:0x%lx %s\n", mux->block_ch, sff_obj->name); - if (!p_valid(sff_obj)) { - SWPS_LOG_ERR("NULL ptr port_id:%d\n", port); - return; - } - sff_fsm_st_set(sff_obj, SFF_FSM_ST_ISOLATED); - } -} -static bool i2c_bus_recovery_is_supported(void) -{ - bool is_supported = false; - if (PLATFORM_4U == pltfmInfo->id) { - is_supported = true; - } else { - //SWPS_LOG_DBG("i2c bus recovery is not supported\n"); - } - return is_supported; -} -static void i2c_bus_recovery(struct lc_obj_t *card) -{ - if (!i2c_bus_recovery_is_supported()) { - return; - } - failed_mux_detect(card); - SWPS_LOG_ERR("mux reset done\n"); - if (i2c_bus_is_alive(card)) { - SWPS_LOG_ERR("i2c bus recovery done\n"); - } else { - SWPS_LOG_ERR("i2c bus recovery fail\n"); - } - -} -static int lc_fsm_run_4U(struct lc_t *card) -{ - int i = 0; - int lc_num = card->lc_num; - int ret = 0; - - for (i = 0; i < lc_num; i++) { - ret = _lc_fsm_run_4U(&card->obj[i]); - - if (ret < 0) { - break; - } - } - - - if (ret < 0) { - SWPS_LOG_ERR("something wrong\n"); - return ret; - } - return 0; -} -/*extract the bits out of the val, bits need to be contious, bit start to end*/ -u8 masked_bits_get(u8 val, int bit_s, int bit_e) -{ - u8 mask = 0; - int bit = 0; - - for (bit = bit_s; bit <= bit_e; bit++) { - mask |= (1 << bit); - } - val = val & (mask); - val = val >> bit_s; - - return val; -} - -int dummy_module_st_get(struct sff_obj_t *sff_obj, u8 *st) -{ - return -ENOSYS; -} - -static void func_tbl_init(struct sff_obj_t *obj, int type) -{ - if(SFP_TYPE == type) { - obj->func_tbl = sfp_func_load(); - } else if (QSFP_TYPE == type) { - obj->func_tbl = qsfp_func_load(); - - } else if (QSFP_DD_TYPE == type) { - obj->func_tbl = qsfp_dd_func_load(); - } else { - obj->func_tbl = qsfp_func_load(); - SWPS_LOG_ERR("load func fail!\n"); - } - -} -static void sff_fsm_init(struct sff_obj_t *obj, int type) -{ - struct sff_fsm_t *fsm = NULL; - - fsm = &(obj->fsm); - if(SFP_TYPE == type) { - fsm->task = sff_fsm_sfp_task; - - } else if (QSFP_TYPE == type) { - - fsm->task = sff_fsm_qsfp_task; - - } else if (QSFP_DD_TYPE == type) { - - fsm->task = sff_fsm_qsfp_dd_task; - - } - fsm->period_tbl = fsm_period_tbl; - fsm->st = SFF_FSM_ST_IDLE; - fsm->cnt = 0; - fsm->delay_cnt = 0; -} - -static struct platform_info_t *_platform_info_load(int platform_id) -{ - int i = 0; - for (i = 0; platform_info_tbl[i].id != PLATFORM_END; i++) { - if (platform_info_tbl[i].id == platform_id) { - - return &platform_info_tbl[i]; - } - - } - - return NULL; -} -static int port_info_table_load(void) -{ - int platform_id = PLATFORM_ID; - struct platform_info_t *pltfm_info = NULL; - - pltfm_info = _platform_info_load(platform_id); - if (!p_valid(pltfm_info)) { - return -EBADRQC; - } - - pltfmInfo = pltfm_info; - - if (NULL == pltfmInfo->tbl_1st) { - return -EBADRQC; - } - - if (NULL == pltfmInfo->name) { - return -EBADRQC; - } - - if (NULL != pltfmInfo->tbl_2nd) { - maxPortNum = ((pltfmInfo->tbl_1st->size > pltfmInfo->tbl_2nd->size) ? - (pltfmInfo->tbl_1st->size) : (pltfmInfo->tbl_2nd->size)); - } else { - maxPortNum = pltfmInfo->tbl_1st->size; - } - return 0; -} -inline static void sff_data_reset(struct sff_mgr_t *sff) -{ - sff->prs = 0; -} -static void sff_data_init(struct sff_mgr_t *sff, int port_num) -{ - sff->valid_port_num = port_num; - sff_data_reset(sff); -} -static void sff_func_init(struct sff_mgr_t *sff) -{ - if (io_no_init) { - sff->prs_scan = io_no_init_scan; - } else { - sff->prs_scan = sff_prs_scan; - } -} -static int drv_load(struct lc_t *self) -{ - int lc_num = self->lc_num; - int lc_id = 0; - struct sff_io_driver_t *io_drv = NULL; - struct sff_eeprom_driver_t *eeprom_drv = NULL; - if (PLATFORM_4U == pltfmInfo->id) { - io_drv = sff_io_drv_get_lcdev(); - } else { - io_drv = sff_io_drv_get_iodev(); - } - if (!p_valid(io_drv)) { - return -ENOSYS; - } - - eeprom_drv = sff_eeprom_drv_get(); - if (!p_valid(eeprom_drv)) { - return -ENOSYS; - } - - for (lc_id = 0; lc_id < lc_num; lc_id++) { - self->obj[lc_id].sff.io_drv = io_drv; - self->obj[lc_id].sff.eeprom_drv = eeprom_drv; - } - return 0; -} -static int __init swps_init(void) -{ - if (port_info_table_load() < 0) { - - SWPS_LOG_ERR("port_info_table_load fail\n"); - goto exit_err; - } - if (sff_eeprom_init(pltfmInfo->id) < 0) { - goto exit_err; - SWPS_LOG_ERR("sff_eeprom_init fail\n"); - } - sff_eeprom_port_num_set(maxPortNum); - - if (sff_kset_create_init() < 0) { - SWPS_LOG_ERR("sff_kset_create_init fail\n"); - goto exit_err; - } - - if (lc_func_load(&lcMgr) < 0) { - SWPS_LOG_ERR("lc_func_load fail\n"); - goto exit_err; - } - - if (lc_create_init(&lcMgr, pltfmInfo->lc_num, maxPortNum) < 0) { - SWPS_LOG_ERR("lc_create_init fail\n"); - goto exit_err; - } - - if (lcMgr.lc_func->dev_init(pltfmInfo->id, io_no_init) < 0) { - goto exit_err; - SWPS_LOG_ERR("dev_init fail\n"); - } - - if (drv_load(&lcMgr) < 0) { - goto exit_err; - SWPS_LOG_ERR("drv load fail\n"); - } - - if(swps_polling_is_enabled()) { - swps_polling_task_start(); - } - SWPS_LOG_INFO("swps:%s init ok\n", pltfmInfo->name); - return 0; - -exit_err: - return -EBADRQC; -} - -static void __exit swps_exit(void) -{ - struct mux_ch_t *mux = NULL; - int lc_id = 0; - - if(swps_polling_is_enabled()) { - swps_polling_task_stop(); - } - - sff_eeprom_deinit(); - lcMgr.lc_func->dev_deinit(); - - lc_sff_kobjs_destroy(&lcMgr); - lc_kobj_destroy(&lcMgr); - lc_common_kobj_destroy(&lcMgr); - sff_kset_deinit(); - - for (lc_id = 0; lc_id < lcMgr.lc_num; lc_id++) { - mux = &(lcMgr.obj[lc_id].mux_l1); - if (0 != mux->block_ch) { - if (mux_ch_block(mux->i2c_ch, 0) < 0) { - SWPS_LOG_ERR("block ch fail:i2c_ch:%d\n", mux->i2c_ch); - } - mux_fail_reset(mux->i2c_ch); - } - } - lc_sff_frontPort_remap_destroy(&lcMgr); - lc_sff_objs_destroy(&lcMgr); - lc_objs_destroy(&lcMgr); - - SWPS_LOG_INFO("swps:%s deinit ok\n", pltfmInfo->name); -} - - -module_init(swps_init); -module_exit(swps_exit); -MODULE_LICENSE("GPL"); -MODULE_AUTHOR("Alang "); diff --git a/packages/platforms/inventec/x86-64/d7332/modules/builds/src/inv_swps.h b/packages/platforms/inventec/x86-64/d7332/modules/builds/src/inv_swps.h deleted file mode 100644 index 71d00e99c..000000000 --- a/packages/platforms/inventec/x86-64/d7332/modules/builds/src/inv_swps.h +++ /dev/null @@ -1,611 +0,0 @@ -#ifndef __SWPS_H -#define __SWPS_H - -#include -#include "sff_spec.h" -#include "lc_dev.h" -#include "io_dev.h" - -#define READBACK_CHECK -#define DEBUG_LOG (1) - -#define SWPS_KSET ("swps") -#define TRY_NUM (5) -#define SFF_EEPROM_I2C_ADDR (0xA0 >> 1) -#define SFF_DDM_I2C_ADDR (0xA2 >> 1) -#define WORD_SIZE (2) -#define SFP_LANE_NUM (1) -#define QSFP_LANE_NUM (4) -#define QSFP_DD_LANE_NUM (8) -#define VENDOR_INFO_BUF_SIZE (32) -#define BUF_SIZE (PAGE_SIZE) -#define MUX_CH_NUM (8) - -#define SWPS_POLLING_PERIOD (msecs_to_jiffies(100)) /* msec */ - -#define DYNAMIC_SFF_KOBJ - -#define PAGE_NUM (256) -#define EEPROM_SIZE (256) -//#define QSFP_INT_FLAG_SUPPORT -#define EEPROM_HALF_SIZE (128) -#define QSFP_INT_FLAG_SUPPORT -#define PAGE_SEL_LOCK_NUM (20) -#define CLEAR_CMD ("clear\n") - -#define bit_mask(bit) (1 << (bit)) -/*bit:start bit from rightmost , num: the num of bits what to be extracted*/ -#define bits_get(reg, bit, num) ((reg >> bit) & ((1 << num)-1)) -#define sff_to_lc(x) container_of(x, struct lc_obj_t, sff) - -#if 0 -#if (DEBUG_LOG == 1) -#define SWPS_LOG_DEBUG(fmt, args...) \ - printk (KERN_INFO "[SWPS]%s " fmt "\r\n",__FUNCTION__, ##args) -#else -#define SWPS_LOG_DEBUG(fmt, args...) -#endif -#define SWPS_LOG_INFO(fmt, args...) printk (KERN_INFO "[SWPS]%s:"fmt,__FUNCTION__, ##args) -#define SWPS_LOG_ERR(fmt, args...) printk (KERN_ERR "[SWPS]%s: " fmt "\r\n",__FUNCTION__, ##args) -#endif -#define check_pfunc(p) \ - do { \ - if (p == NULL) { \ - printk( KERN_ERR "%s, %s = NULL.\n", __FUNCTION__, #p); \ - return -ENOSYS; \ - } \ - }while(0) -enum LOG_LEVEL { - - SWPS_ERR_LEV = 0x1, - MODULE_ERR_LEV = 0x2, - DEV_ERR_LEV = 0x04, - EEPROM_ERR_LEV = 0x08, - ERR_ALL_LEV = 0xff, - - SWPS_INFO_LEV = 0x100, - MODULE_INFO_LEV = 0x200, - DEV_INFO_LEV = 0x400, - EEPROM_INFO_LEV = 0x800, - INFO_ALL_LEV = 0xff00, - - SWPS_DBG_LEV = 0x10000, - MODULE_DBG_LEV = 0x20000, - DEV_DBG_LEV = 0x40000, - EEPROM_DBG_LEV = 0x80000, - DBG_ALL_LEV = 0xff0000, - -}; - -#define SWPS_LOG_ERR(fmt, args...) \ - do { \ - if (logLevel & SWPS_ERR_LEV) \ - { \ - printk (KERN_ERR "[SWPS]%s: "fmt,__FUNCTION__, ##args); \ - } \ - } while (0) - -#define SWPS_LOG_INFO(fmt, args...) \ - do { \ - if (logLevel & SWPS_INFO_LEV) \ - { \ - printk (KERN_INFO "[SWPS]%s: "fmt,__FUNCTION__, ##args); \ - } \ - } while (0) - -#define SWPS_LOG_DBG(fmt, args...) \ - do { \ - if (logLevel & SWPS_DBG_LEV) \ - { \ - printk (KERN_INFO "[SWPS]%s: "fmt,__FUNCTION__, ##args); \ - } \ - } while (0) - -#define MODULE_LOG_ERR(fmt, args...) \ - do { \ - if (logLevel & MODULE_ERR_LEV) \ - { \ - printk (KERN_ERR "[MODULE]%s: "fmt,__FUNCTION__, ##args); \ - } \ - } while (0) - -#define MODULE_LOG_INFO(fmt, args...) \ - do { \ - if (logLevel & MODULE_INFO_LEV) \ - { \ - printk (KERN_INFO "[MODULE]%s: "fmt,__FUNCTION__, ##args); \ - } \ - } while (0) - -#define MODULE_LOG_DBG(fmt, args...) \ - do { \ - if (logLevel & MODULE_DBG_LEV) \ - { \ - printk (KERN_INFO "[MODULE]%s: "fmt,__FUNCTION__, ##args); \ - } \ - } while (0) - - -/*public function*/ -#define I2C_RETRY_NUM (3) -#define I2C_RETRY_DELAY_MS (10) - -#define LC_INSERT_WAIT_STABLE_NUM (10) -#define LC_OVER_TEMP_NUM (10) -#define LC_PRS_LOCKED_NUM (5) - -typedef enum { - SFP_TYPE = 0, - QSFP_TYPE, - QSFP_DD_TYPE, - SFF_TYPE_NUM -} sff_type; -#if 0 -typedef enum { - TX_ALL_CH_DISABLE_OFF = 0x00, - TX_CH1_DISABLE_ON = 1 << 0, - TX_CH2_DISABLE_ON = 1 << 1, - TX_CH3_DISABLE_ON = 1 << 2, - TX_CH4_DISABLE_ON = 1 << 3, - TX_CH5_DISABLE_ON = 1 << 4, - TX_CH6_DISABLE_ON = 1 << 5, - TX_CH7_DISABLE_ON = 1 << 6, - TX_CH8_DISABLE_ON = 1 << 7, - TX_1CH_DISABLE_ON = TX_CH1_DISABLE_ON, /*sfp*/ - TX_4CH_DISABLE_ON = 0x0f, /*qsfp*/ - TX_8CH_DISABLE_ON = 0xff, /*qsfp-dd*/ - -} tx_disable_t; -#endif -/*so far it's for sfp only*/ -typedef enum { - SOFT_RX_RATE_RS0 = 1 << 0, - SOFT_TX_RATE_RS1 = 1 << 1, -} rate_control_t; -typedef enum { - SFF_IO_RST_TYPE, - SFF_IO_PWR_TYPE, - SFF_IO_LPMODE_TYPE, - SFF_IO_OUTPUT_TYPE_NUM -} sff_io_output_type_t; -typedef enum { - TX_EQ_TYPE, - RX_EM_TYPE, - RX_AM_TYPE, -} sysfs_attrbute_index_ln_control_t; - -typedef enum { - LN_MONITOR_RX_PWR_TYPE, - LN_MONITOR_TX_PWR_TYPE, - LN_MONITOR_TX_BIAS_TYPE, -} sysfs_attrbute_index_ln_monitor_t; - -typedef enum { - LN_STATUS_RX_LOS_TYPE, - LN_STATUS_TX_LOS_TYPE, - LN_STATUS_TX_FAULT_TYPE, - LN_STATUS_NUM, -} sysfs_attrbute_index_ln_status_t; - -typedef enum { - VENDOR_NAME_TYPE, - VENDOR_PN_TYPE, - VENDOR_SN_TYPE, - VENDOR_REV_TYPE, -} sysfs_attrbute_index_vendor_info_t; - -typedef enum { - SFF_FSM_ST_REMOVED = 0, - SFF_FSM_ST_INSERTED, - SFF_FSM_ST_DETECTING, - SFF_FSM_ST_INIT, - SFF_FSM_ST_READY, - SFF_FSM_ST_IDLE, - SFF_FSM_ST_FAULT, - SFF_FSM_ST_SUSPEND, - SFF_FSM_ST_RESTART, - SFF_FSM_ST_ISOLATED, - SFF_FSM_ST_IDENTIFY, - SFF_FSM_ST_MONITOR, - /*qsfp-dd only {*/ - SFF_FSM_ST_MGMT_INIT, - SFF_FSM_ST_MODULE_UNRESET, - SFF_FSM_ST_MODULE_HW_INIT, - SFF_FSM_ST_MODULE_LOOPBACK_INIT, - SFF_FSM_ST_MODULE_READY, - SFF_FSM_ST_MODULE_PWR_DOWN, - SFF_FSM_ST_MODULE_CMIS_VER_CHECK, - SFF_FSM_ST_MODULE_ADVERT_CHECK, - SFF_FSM_ST_MODULE_SW_CONFIG_1, - SFF_FSM_ST_MODULE_SW_CONFIG_2, - SFF_FSM_ST_MODULE_SW_CONFIG_CHECK, - SFF_FSM_ST_MODULE_SW_CONTROL, - SFF_FSM_ST_MODULE_READY_CHECK, - /*qsfp-dd only }*/ - SFF_FSM_ST_UNKNOWN_TYPE, - SFF_FSM_ST_END, - SFF_FSM_ST_NUM, -} sff_fsm_state_t; -#define QSFP_DD_INT_LN_FLAG_NUM (19) -#define QSFP_DD_INT_MODULE_FLAG_NUM (6) - -struct intr_flag_t { - u8 reg; - u32 cnt; - bool chg; -}; - -struct swps_kobj_t { - struct kobject kobj; - struct sff_obj_t *sff_obj; -}; - -typedef struct sff_obj_t sff_obj_type; - -struct sff_fsm_t { - sff_fsm_state_t st; - int (*task)(sff_obj_type *sff_obj); - int cnt; /*used to count how many fsm loop's been running*/ - int delay_cnt; /*the target count for each state, will be reset during each state transition*/ - struct fsm_period_t *period_tbl; -}; - -struct qsfp_dd_fsm_func_t { - int (*advert_check)(struct sff_obj_t *sff_obj, bool *pass); - int (*sw_config_1)(struct sff_obj_t *sff_obj); - int (*sw_config_2)(struct sff_obj_t *sff_obj, bool *pass); - int (*sw_config_check)(struct sff_obj_t *sff_obj, bool *pass); - int (*sw_control)(struct sff_obj_t *sff_obj); - int (*module_ready_check)(struct sff_obj_t *sff_obj, bool *ready); -}; - -struct qsfp_dd_priv_data { - int lane_num; - u8 module_type; - union qsfp_dd_app_advert_fields fields[APSEL_NUM]; - bool paging_supported; - bool rev4_quick_en; - u8 eeprom_cache[PAGE_NUM][EEPROM_SIZE]; - struct intr_flag_t intr_module_flag[QSFP_DD_INT_MODULE_FLAG_NUM]; - struct intr_flag_t intr_ln_flag[QSFP_DD_INT_LN_FLAG_NUM]; - u8 lane_st[LN_STATUS_NUM]; - struct qsfp_dd_fsm_func_t *fsm_func; - int apsel; -}; - -struct qsfp_priv_data { - u8 lane_st[LN_STATUS_NUM]; - u8 eeprom_cache[PAGE_NUM][EEPROM_SIZE]; - bool paging_supported; -}; - -union priv_data_t { - struct qsfp_dd_priv_data qsfp_dd; - struct qsfp_priv_data qsfp; -}; - -struct sff_obj_t { - int lc_id; /*duplicate lc_id from lc_obj_t lc_id for fast access*/ - char *lc_name; /*duplicate lc_id from lc_obj_t lc_id for fast access*/ - int port; /*phy port(ga) corresponding to hw connection , eeprom, cpld reg mapping..*/ - int front_port; /*the front port you see from front panel, index from 0 , refer to port_info_map*/ - char *name; /*front port name index from 1 , port1...., refer to port_info_map*/ - sff_type type; - int transvr_type; - struct swps_kobj_t *kobj; - union priv_data_t priv_data; - struct sff_fsm_t fsm; - struct sff_mgr_t *mgr; - struct func_tbl_t *func_tbl; - bool page_sel_lock; -}; -struct mux_ch_t { - int i2c_ch; - unsigned long mux_ch; - bool is_fail; - unsigned long block_ch; -}; -#define MUX_MAX_NUM (32) /**/ -struct sff_mgr_t { - int valid_port_num; - unsigned long prs; - struct sff_obj_t *obj; - int *frontPort_to_port; - struct swps_kobj_t *mgr_kobj; - struct swps_kobj_t *common_kobj; - int (*prs_scan)(struct sff_mgr_t *sff); - unsigned long io_no_init_port_done; - struct sff_io_driver_t *io_drv; - struct sff_eeprom_driver_t *eeprom_drv; -}; -#if 0 -typedef enum { - LC_LED_CTRL_OFF = 0, - LC_LED_CTRL_GREEN_ON, - LC_LED_CTRL_RED_ON, - LC_LED_CTRL_AMBER_ON, - LC_LED_CTRL_GREEN_BLINK, - LC_LED_CTRL_RED_BLINK, - LC_LED_CTRL_AMBER_BLINK, - LC_LED_CTRL_NUM, -} lc_led_ctrl_t; - -typedef enum { - LC_UNKNOWN_TYPE = 0, - LC_100G_TYPE, - LC_400G_TYPE, - LC_TYPE_NUM, -} lc_type_t; -#endif - -typedef enum { - - LC_FSM_ST_INSERT, - LC_FSM_ST_WAIT_STABLE, - LC_FSM_ST_POWER_ON, - LC_FSM_ST_POWER_CHECK, - LC_FSM_ST_PHY_CHECK, - LC_FSM_ST_INIT, - LC_FSM_ST_READY, - LC_FSM_ST_REMOVE, - LC_FSM_ST_IDLE, - LC_FSM_ST_THERMAL_TRIP, - LC_FSM_ST_UNSUPPORTED, - LC_FSM_ST_FAULT, - LC_FSM_ST_NUM, - -} lc_fsm_st_t; -typedef struct lc_t lc_mgr_type; - -typedef enum { - LC_POSI_INIT_ST, - LC_POSI_MON_ST, - LC_POSI_RELEASED_ST, - LC_POSI_LOCK_CHECK_ST, - LC_POSI_LOCKED_ST, -}lc_posi_st_t; - -struct lc_obj_t { - struct sff_mgr_t sff; - struct swps_kobj_t *card_kobj; - char *name; - int lc_id; - unsigned long prs; - lc_fsm_st_t st; - lc_mgr_type *mgr; - bool power_ready; - bool is_phy_ready; - unsigned long phy_ready_bitmap; - int temp; - lc_type_t type; - u32 wait_stable_cnt; - u32 over_temp_cnt; - bool ej_released; - bool prs_locked; - u32 prs_locked_cnt; - lc_posi_st_t posi_st; - struct mux_ch_t mux_l1; -}; - -struct sff_io_driver_t { - int (*prs_all_get)(int lc_id, unsigned long *bitmap); - int (*intr_all_get)(int lc_id, unsigned long *bitmap); - int (*rx_los_all_get)(int lc_id, unsigned long *bitmap); - int (*tx_fault_all_get)(int lc_id, unsigned long *bitmap); - int (*reset_set)(int lc_id, int port, u8 reset); - int (*reset_get)(int lc_id, int port, u8 *reset); - int (*reset_all_set)(int lc_id, unsigned long bitmap); - int (*reset_all_get)(int lc_id, unsigned long *bitmap); - int (*power_set)(int lc_id, int port, u8 reset); - int (*power_get)(int lc_id, int port, u8 *reset); - int (*power_all_set)(int lc_id, unsigned long bitmap); - int (*power_all_get)(int lc_id, unsigned long *bitmap); - int (*lpmode_set)(int lc_id, int port, u8 value); - int (*lpmode_get)(int lc_id, int port, u8 *value); - int (*lpmode_all_set)(int lc_id, unsigned long bitmap); - int (*lpmode_all_get)(int lc_id, unsigned long *bitmap); - int (*tx_disable_set)(int lc_id, int port, u8 value); - int (*tx_disable_get)(int lc_id, int port, u8 *value); - int (*mode_sel_set)(int lc_id, int port, u8 value); - int (*mode_sel_get)(int lc_id, int port, u8 *value); - int (*oc_all_get)(int lc_id, unsigned long *bitmap); -}; - -struct sff_eeprom_driver_t { - int (*eeprom_read)(int lc_id, int port, - u8 slave_addr, - u8 offset, - u8 *buf, - size_t len); - int (*eeprom_write)(int lc_id, int port, - u8 slave_addr, - u8 offset, - const u8 *buf, - size_t len); - -}; -struct lc_func_t { - int (*dev_init)(int platform_id, int io_no_init); - void (*dev_deinit)(void); - void (*polling_task)(void); - int (*dev_hdlr)(void); - bool (*i2c_is_alive)(int lc_id); - int (*cpld_init)(int lc_id); - int (*power_set)(int lc_id, bool on); - int (*power_ready)(int lc_id, bool *ready); - void (*phy_ready)(unsigned long bitmap, bool *ready); - int (*prs_get)(unsigned long *bitmap); - int (*reset_set)(int lc_id, u8 lv); - int (*reset_get)(int lc_id, u8 *lv); - int (*type_get)(int lc_id, lc_type_t *type); - int (*type_get_text)(int lc_id, char *buf, int size); - int (*over_temp_asserted)(int lc_id, bool *asserted); - int (*over_temp_deasserted)(int lc_id, bool *deasserted); - int (*temp_get)(int lc_id, char *buf, int size); - int (*temp_th_get)(int lc_id, char *buf, int size); - int (*led_set)(int lc_id, lc_led_ctrl_t ctrl); - int (*mux_reset_set)(int lc_id, int rst); - int (*mux_reset_get)(int lc_id, int *rst); - int (*phy_reset_set)(int lc_id, u8 val); - -}; -struct lc_t { - struct lc_obj_t *obj; - struct swps_kobj_t *common_kobj; - int lc_num; - unsigned long lc_sys_ready; - unsigned long lc_prs; - unsigned long ej_r; - unsigned long ej_l; - unsigned long io_no_init_all_done; - struct lc_func_t *lc_func; -}; -/* func table for each sff object*/ -struct func_tbl_t { - /* private function , for driver internal use {*/ - int (*eeprom_read)(struct sff_obj_t *sff_obj, u8 addr, u8 offset, u8 *buf, int len); - int (*eeprom_write)(struct sff_obj_t *sff_obj, u8 addr, u8 offset, const u8 *buf, int len); - /* }*/ - /*sff low speed signals for both driver internal use and export to sysfs interface*/ - int (*prs_get)(struct sff_obj_t *sff_obj, u8 *value); - int (*lpmode_set)(struct sff_obj_t *sff_obj, u8 value); - int (*lpmode_get)(struct sff_obj_t *sff_obj, u8 *value); - int (*reset_set)(struct sff_obj_t *sff_obj, u8 value); - int (*reset_get)(struct sff_obj_t *sff_obj, u8 *value); - int (*power_set)(struct sff_obj_t *sff_obj, u8 value); - int (*power_get)(struct sff_obj_t *sff_obj, u8 *value); - int (*mode_sel_set)(struct sff_obj_t *sff_obj, u8 value); - int (*mode_sel_get)(struct sff_obj_t *sff_obj, u8 *value); - int (*intL_get)(struct sff_obj_t *sff_obj, u8 *value); - int (*tx_disable_set)(struct sff_obj_t *sff_obj, u8 value); - int (*tx_disable_get)(struct sff_obj_t *sff_obj, u8 *value); - int (*temperature_get)(struct sff_obj_t *sff_obj, u8 *buf, int buf_size); - int (*voltage_get)(struct sff_obj_t *sff_obj, u8 *buf, int buf_size); - int (*lane_control_set)(struct sff_obj_t *sff_obj, int type, u32 value); - int (*lane_control_get)(struct sff_obj_t *sff_obj, int type, u32 *value); - int (*lane_monitor_get)(struct sff_obj_t *sff_obj, int type, u8 *buf, int buf_size); - int (*vendor_info_get)(struct sff_obj_t *sff_obj, int type, u8 *buf, int buf_size); - int (*lane_status_get)(struct sff_obj_t *sff_obj, int type, u8 *value); - int (*module_st_get)(struct sff_obj_t *sff_obj, u8 *st); - int (*id_get)(struct sff_obj_t *sff_obj, u8 *id); - bool (*is_id_matched)(struct sff_obj_t *sff_obj); - int (*eeprom_dump)(struct sff_obj_t *sff_obj, u8 *buf); - int (*page_sel)(struct sff_obj_t *sff_obj, int page); - int (*page_get)(struct sff_obj_t *sff_obj, u8 *page); - int (*intr_flag_show)(struct sff_obj_t *sff_obj, char *buf, int size); - void (*intr_flag_clear)(struct sff_obj_t *sff_obj); -}; - -struct port_info_map_t { - int front_port; /*the front port you see from front panel*/ - sff_type type; - char *name; /*front port name index from 1 , port1....*/ -}; - -struct port_info_table_t { - struct port_info_map_t *map; - int size; -}; - -/*it is for compose monitor data into u16 format from u8*/ -union monitor_data_t { - u8 byte[2]; - u16 word; - s16 signed_word; -}; - -struct monitor_para_t { - int type; - u16 divider; - char *unit; -}; - -typedef enum { - TRANSVR_CLASS_UNKNOWN=0, - /* Transceiver class for Optical 10G */ - TRANSVR_CLASS_OPTICAL_10G_S_AOC =(27011), - TRANSVR_CLASS_OPTICAL_10G_S_SR =(27012), - TRANSVR_CLASS_OPTICAL_10G_S_LR =(27013), - TRANSVR_CLASS_OPTICAL_10G_S_ER =(27014), - TRANSVR_CLASS_OPTICAL_10G_Q_AOC =(27015), - TRANSVR_CLASS_OPTICAL_10G_Q_SR =(27016), - TRANSVR_CLASS_OPTICAL_10G_Q_LR =(27017), - TRANSVR_CLASS_OPTICAL_10G_Q_ER =(27018), - /* Transceiver class for Optical 25G */ - TRANSVR_CLASS_OPTICAL_25G_AOC =(27021), - TRANSVR_CLASS_OPTICAL_25G_SR =(27022), - TRANSVR_CLASS_OPTICAL_25G_LR =(27023), - TRANSVR_CLASS_OPTICAL_25G_ER =(27024), - /* Transceiver class for Optical 40G */ - TRANSVR_CLASS_OPTICAL_40G_AOC =(27041), - TRANSVR_CLASS_OPTICAL_40G_SR4 =(27042), - TRANSVR_CLASS_OPTICAL_40G_LR4 =(27043), - TRANSVR_CLASS_OPTICAL_40G_ER4 =(27044), - /* Transceiver class for Optical 100G */ - TRANSVR_CLASS_OPTICAL_100G_AOC =(27101), - TRANSVR_CLASS_OPTICAL_100G_SR4 =(27102), - TRANSVR_CLASS_OPTICAL_100G_LR4 =(27103), - TRANSVR_CLASS_OPTICAL_100G_ER4 =(27104), - TRANSVR_CLASS_OPTICAL_100G_PSM4 =(27105), - TRANSVR_CLASS_OPTICAL_100G_CWDM4 =(27106), - /* Transceiver class for Copper */ - TRANSVR_CLASS_COPPER_L1_1G =(28001), - TRANSVR_CLASS_COPPER_L1_10G =(28011), - TRANSVR_CLASS_COPPER_L4_10G =(28012), - TRANSVR_CLASS_COPPER_L1_25G =(28021), - TRANSVR_CLASS_COPPER_L4_40G =(28041), - TRANSVR_CLASS_COPPER_L4_100G =(28101), - -} transvr_type_t; - -typedef enum { - I2C_CRUSH_INIT_ST, - I2C_CRUSH_IO_I2C_CHECK_ST, - I2C_CRUSH_BAD_TRANSVR_DETECT_ST, - I2C_CRUSH_I2C_RECHECK_ST, - I2C_CRUSH_END_ST, -} i2c_crush_hande_st; - -void transvr_type_set(struct sff_obj_t *sff_obj, int type); -int transvr_type_get(struct sff_obj_t *sff_obj); -//u8 masked_bits_get(u8 val, int bit_s, int bit_e); -sff_fsm_state_t sff_fsm_st_get(struct sff_obj_t *sff_obj); -void sff_fsm_st_set(struct sff_obj_t *sff_obj, sff_fsm_state_t st); -void sff_fsm_state_change_process(struct sff_obj_t *sff_obj, sff_fsm_state_t cur_st, sff_fsm_state_t next_st); -struct monitor_para_t *monitor_para_find(int type); -int sff_fsm_kobj_change_event(struct sff_obj_t *sff_obj); - -int i2c_smbus_write_byte_data_retry(struct i2c_client *client, u8 offset, u8 data); -int i2c_smbus_read_byte_data_retry(struct i2c_client *client, u8 offset); -int i2c_smbus_write_word_data_retry(struct i2c_client *client, u8 offset, u16 buf); -int i2c_smbus_read_word_data_retry(struct i2c_client *client, u8 offset); -int i2c_smbus_read_i2c_block_data_retry(struct i2c_client *client, u8 offset, int len, u8 *buf); -bool p_valid(const void *ptr); -int sff_eeprom_read(struct sff_obj_t *sff_obj, u8 addr, u8 offset, u8 *buf, int len); -int sff_eeprom_write(struct sff_obj_t *sff_obj,u8 addr, u8 offset, const u8 *buf, int len); -int sff_prs_get(struct sff_obj_t *sff_obj, u8 *prs); -int sff_power_set(struct sff_obj_t *sff_obj, u8 value); -int sff_power_get(struct sff_obj_t *sff_obj, u8 *value); -int dummy_reset_set(struct sff_obj_t *sff_obj, u8 value); -int dummy_reset_get(struct sff_obj_t *sff_obj, u8 *value); -int dummy_lpmode_set(struct sff_obj_t *sff_obj, u8 value); -int dummy_lpmode_get(struct sff_obj_t *sff_obj, u8 *value); -int dummy_mode_sel_set(struct sff_obj_t *sff_obj, u8 value); -int dummy_mode_sel_get(struct sff_obj_t *sff_obj, u8 *value); -int dummy_intL_get(struct sff_obj_t *sff_obj, u8 *value); -int dummy_module_st_get(struct sff_obj_t *sff_obj, u8 *st); -int dummy_eeprom_dump(struct sff_obj_t *sff_obj, u8 *buf); -int dummy_page_sel(struct sff_obj_t *sff_obj, int page); -int dummy_page_sel(struct sff_obj_t *sff_obj, int page); -int dummy_page_get(struct sff_obj_t *sff_obj, u8 *page); -int dummy_lane_control_set(struct sff_obj_t *sff_obj, int type, u32 value); -int dummy_lane_control_get(struct sff_obj_t *sff_obj, int type, u32 *value); -int dummy_lane_status_get(struct sff_obj_t *sff_obj, int type, u8 *st); -char *port_name_get(int lc_id, int port); -bool page_sel_is_locked(struct sff_obj_t *sff_obj); -void page_sel_lock(struct sff_obj_t *sff_obj); -void page_sel_unlock(struct sff_obj_t *sff_obj); - -#endif /* __SWPS_H */ - - diff --git a/packages/platforms/inventec/x86-64/d7332/modules/builds/src/inv_type.h b/packages/platforms/inventec/x86-64/d7332/modules/builds/src/inv_type.h deleted file mode 100644 index 6642ee884..000000000 --- a/packages/platforms/inventec/x86-64/d7332/modules/builds/src/inv_type.h +++ /dev/null @@ -1,77 +0,0 @@ -#ifndef __INV_TYPE_H -#define __INV_TYPE_H - -#include -/*port config*/ - -enum sff_type { - SFP_TYPE, - QSFP_TYPE, - QSFP_DD_TYPE -}; -struct port_info_map_t { - int port; - enum sff_type type; - char *name; -}; -struct port_info_table_t { - struct port_info_map_t *map; - int size; -}; -struct eeprom_config_t { - int port; - int i2c_ch; -}; -struct eeprom_i2c_tbl_t { - - struct eeprom_config_t *map; - int size; -}; - -#if 0 -struct pin_config_t { - - int i2c_ch; - u8 slave_addr; - int port_ch; - u8 bitmask; - int in_use; -}; -struct pin_map_t { - int port; - int i2c_ch; - u8 slave_addr; - int port_ch; - u8 bitmask; - -}; - -#endif -struct sff_driver_t { - int (*prsL_get)(int port, u8 *prsL); - int (*prsL_all_get)(unsigned long *bitmap); - int (*intL_get)(int port, u8 *value); - int (*rx_los_get)(int port, u8 *value); - int (*tx_fault_get)(int port, u8 *value); - int (*reset_set)(int port, u8 reset); - int (*reset_get)(int port, u8 *reset); - int (*lpmode_set)(int port, u8 value); - int (*lpmode_get)(int port, u8 *value); - int (*tx_disable_set)(int port, u8 value); - int (*tx_disable_get)(int port, u8 *value); - int (*mode_sel_set)(int port, u8 value); - int (*mode_sel_get)(int port, u8 *value); - int (*eeprom_read)(int port, - u8 slave_addr, - u8 offset, - u8 *buf, - size_t len); - int (*eeprom_write)(int port, - u8 slave_addr, - u8 offset, - const u8 *buf, - size_t len); - int (*io_mux_reset_all)(int value); - -}; -#endif /*__INV_TYPE_H*/ diff --git a/packages/platforms/inventec/x86-64/d7332/modules/builds/src/inv_ucd90160.c b/packages/platforms/inventec/x86-64/d7332/modules/builds/src/inv_ucd90160.c deleted file mode 100644 index da976f950..000000000 --- a/packages/platforms/inventec/x86-64/d7332/modules/builds/src/inv_ucd90160.c +++ /dev/null @@ -1,259 +0,0 @@ -/* - * 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 - -#define PMBUS_PAGE 0x0 -#define PMBUS_VOUT_MODE 0x20 -#define PMBUS_READ_VOUT 0x8b - - -static int retrys = 1; -module_param(retrys, int, 0); -MODULE_PARM_DESC(retrys, "Inventec UCD90160 read retry times (default 1)."); - -struct ucd90160_data { - struct device *hwmon_dev; - s32 vout[16]; - s32 vout_mode[16]; - s32 pvout[16]; -}; - -static s32 calc_voltage(struct device *dev, s32 vout, s32 vout_mode) -{ - s32 mode = (vout_mode & 0xe0) >> 5; - s32 parameter = (vout_mode & 0x1f); - - switch (mode) { - case 0: - { - s32 exp = (parameter & 0x10) ? - ((32 - parameter) & 0xf) : (parameter & 0xf); - if (exp >= 0) - return ((vout * 1000) << exp); - else - return ((vout * 1000) >> -exp); - } - case 1: - dev_err(dev, "Not Support for VID mode"); - return 0; - case 2: - dev_err(dev, "Not Support for Direct mode"); - return 0; - default: - dev_err(dev, "Unknown Mode"); - return 0; - } -} - -static void update_vout_mode(struct i2c_client *client, u8 page, s32 clean) -{ - struct ucd90160_data *data = i2c_get_clientdata(client); - s32 temp = 0, read = 0, trys = 0; - - if (clean) { - data->vout_mode[page] = 0; - return; - } - - if (data->vout_mode[page]) - return; - - while (trys <= retrys) { - read = i2c_smbus_read_byte_data(client, PMBUS_VOUT_MODE); - temp = i2c_smbus_read_byte_data(client, PMBUS_PAGE); - if (page != temp) { - trys++; - if (trys > retrys) - return; - continue; - } - break; - } - - data->vout_mode[page] = read; -} - -static ssize_t read_voltage_out(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 ucd90160_data *data = i2c_get_clientdata(client); - s32 temp = 0, vout = 0, trys = 0; - u8 page = attr->index; - - while (trys <= retrys) { - temp = i2c_smbus_write_byte_data(client, PMBUS_PAGE, page); - if (temp < 0) { - update_vout_mode(client, page, 1); - trys++; - if (trys > retrys) goto absent; - continue; - } - - update_vout_mode(client, page, 0); - vout = i2c_smbus_read_word_data(client, PMBUS_READ_VOUT); - if (vout < 0) { - trys++; - if (trys > retrys) goto fail; - continue; - } - - temp = i2c_smbus_read_byte_data(client, PMBUS_PAGE); - if (page != temp) { - trys++; - if (trys > retrys) goto fail; - continue; - } - - break; - } - - data->pvout[page] = data->vout[page]; - data->vout[page] = calc_voltage(dev, vout, data->vout_mode[page]); - - return sprintf(buf, "%d\n", data->vout[page]); - -fail: - return sprintf(buf, "%d\n", data->pvout[page]); - -absent: - return sprintf(buf, "0\n"); -} - -static SENSOR_DEVICE_ATTR(in1_input, S_IRUGO, read_voltage_out, 0, 0); -static SENSOR_DEVICE_ATTR(in2_input, S_IRUGO, read_voltage_out, 0, 1); -static SENSOR_DEVICE_ATTR(in3_input, S_IRUGO, read_voltage_out, 0, 2); -static SENSOR_DEVICE_ATTR(in4_input, S_IRUGO, read_voltage_out, 0, 3); -static SENSOR_DEVICE_ATTR(in5_input, S_IRUGO, read_voltage_out, 0, 4); -static SENSOR_DEVICE_ATTR(in6_input, S_IRUGO, read_voltage_out, 0, 5); -static SENSOR_DEVICE_ATTR(in7_input, S_IRUGO, read_voltage_out, 0, 6); -static SENSOR_DEVICE_ATTR(in8_input, S_IRUGO, read_voltage_out, 0, 7); -static SENSOR_DEVICE_ATTR(in9_input, S_IRUGO, read_voltage_out, 0, 8); -static SENSOR_DEVICE_ATTR(in10_input, S_IRUGO, read_voltage_out, 0, 9); -static SENSOR_DEVICE_ATTR(in11_input, S_IRUGO, read_voltage_out, 0, 10); -static SENSOR_DEVICE_ATTR(in12_input, S_IRUGO, read_voltage_out, 0, 11); -static SENSOR_DEVICE_ATTR(in13_input, S_IRUGO, read_voltage_out, 0, 12); -static SENSOR_DEVICE_ATTR(in14_input, S_IRUGO, read_voltage_out, 0, 13); -static SENSOR_DEVICE_ATTR(in15_input, S_IRUGO, read_voltage_out, 0, 14); -static SENSOR_DEVICE_ATTR(in16_input, S_IRUGO, read_voltage_out, 0, 15); - -static struct attribute *ucd90160_attributes[] = { - &sensor_dev_attr_in1_input.dev_attr.attr, - &sensor_dev_attr_in2_input.dev_attr.attr, - &sensor_dev_attr_in3_input.dev_attr.attr, - &sensor_dev_attr_in4_input.dev_attr.attr, - &sensor_dev_attr_in5_input.dev_attr.attr, - &sensor_dev_attr_in6_input.dev_attr.attr, - &sensor_dev_attr_in7_input.dev_attr.attr, - &sensor_dev_attr_in8_input.dev_attr.attr, - &sensor_dev_attr_in9_input.dev_attr.attr, - &sensor_dev_attr_in10_input.dev_attr.attr, - &sensor_dev_attr_in11_input.dev_attr.attr, - &sensor_dev_attr_in12_input.dev_attr.attr, - &sensor_dev_attr_in13_input.dev_attr.attr, - &sensor_dev_attr_in14_input.dev_attr.attr, - &sensor_dev_attr_in15_input.dev_attr.attr, - &sensor_dev_attr_in16_input.dev_attr.attr, - NULL -}; - -static const struct attribute_group ucd90160_group = { - .attrs = ucd90160_attributes, -}; - -/*-----------------------------------------------------------------------*/ -/* device probe and removal */ -static int -inv_ucd90160_probe(struct i2c_client *client, const struct i2c_device_id *id) -{ - struct ucd90160_data *data; - int status; - - if (!i2c_check_functionality(client->adapter, - I2C_FUNC_SMBUS_BYTE_DATA | I2C_FUNC_SMBUS_WORD_DATA)) - return -EIO; - - data = kzalloc(sizeof(struct ucd90160_data), GFP_KERNEL); - if (!data) - return -ENOMEM; - - i2c_set_clientdata(client, data); - - /* Register sysfs hooks */ - status = sysfs_create_group(&client->dev.kobj, &ucd90160_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; - } - - return 0; - -exit_remove: - sysfs_remove_group(&client->dev.kobj, &ucd90160_group); -exit_free: - i2c_set_clientdata(client, NULL); - kfree(data); - return status; -} - -static int inv_ucd90160_remove(struct i2c_client *client) -{ - struct ucd90160_data *data = i2c_get_clientdata(client); - - sysfs_remove_group(&client->dev.kobj, &ucd90160_group); - hwmon_device_unregister(data->hwmon_dev); - i2c_set_clientdata(client, NULL); - kfree(data); - return 0; -} - -static const struct i2c_device_id inv_ucd90160_ids[] = { - { "inv_ucd90160" , 0, }, - { "inv_ucd90160_cpu" , 0, }, - { "inv_ucd90160_switch" , 0, }, - { "inv_ucd90160_line" , 0, }, - { /* LIST END */ } -}; -MODULE_DEVICE_TABLE(i2c, inv_ucd90160_ids); - -static struct i2c_driver ucd90160_driver = { - .class = I2C_CLASS_HWMON, - .driver = { - .name = "inv_ucd90160", - }, - .probe = inv_ucd90160_probe, - .remove = inv_ucd90160_remove, - .id_table = inv_ucd90160_ids, -}; - -static int __init inv_ucd90160_init(void) -{ - return i2c_add_driver(&ucd90160_driver); -} - -static void __exit inv_ucd90160_exit(void) -{ - i2c_del_driver(&ucd90160_driver); -} - -MODULE_AUTHOR("Roger Chang "); -MODULE_DESCRIPTION("inventec ucd90160 driver"); -MODULE_LICENSE("GPL"); - -module_init(inv_ucd90160_init); -module_exit(inv_ucd90160_exit); diff --git a/packages/platforms/inventec/x86-64/d7332/modules/builds/src/inv_vpd.c b/packages/platforms/inventec/x86-64/d7332/modules/builds/src/inv_vpd.c deleted file mode 100644 index 7e81636e9..000000000 --- a/packages/platforms/inventec/x86-64/d7332/modules/builds/src/inv_vpd.c +++ /dev/null @@ -1,354 +0,0 @@ -/************************************************************************* - * - * inv_vpd.c - * - * 2018 Inventec Corporation - * All Rights Reserved. - * - * NOTICE: All information contained herein is, and remains - * the property of Inventec Corp. and its suppliers, - * if any. The intellectual and technical concepts contained - * herein are proprietary to Inventec Corporation and its suppliers - * and may be covered by U.S. and Foreign Patents, patents in process, - * and are protected by trade secret or copyright law. - * - ************************************************************************/ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "inv_vpd.h" -#include "onie_tlvinfo.h" - -static int vpd_major; -static struct class *vpd_class_p = NULL; -static char cEeprom[SYS_EEPROM_MAX_SIZE]; -static DEFINE_MUTEX(vpd_mutex); - -static int -__swp_match(struct device *dev, -#ifdef VPD_KERN_VER_AF_3_10 - - const void *data){ -#else - void *data){ -#endif - - char *name = (char *)data; - if (strcmp(dev_name(dev), name) == 0) - return 1; - return 0; -} - -static -int get_vpd_data(struct i2c_client *pi2c_client, int i_offset, char *c_buf) -{ - int iRet; - - read_eeprom( pi2c_client, cEeprom); - iRet = tlvinfo_decode_tlv(cEeprom, i_offset,c_buf); - return iRet; -} - -static -int write_vpd_data(struct i2c_client *pi2c_client, int i_offset, char *c_buf) -{ - int iErr = 0; - - if (read_eeprom(pi2c_client, cEeprom)) { - printk(KERN_ERR "write vpd data eror at %d-%s\n", __LINE__, __FUNCTION__); - return -1; - } - - if (tlvinfo_delete_tlv(cEeprom, i_offset) == TRUE) { - } - if (c_buf) { - if(!tlvinfo_add_tlv(cEeprom, i_offset , c_buf)) { - printk(KERN_ERR "write vpd data eror at %d-%s\n", __LINE__, __FUNCTION__); - iErr = -1; - } else { - iErr = prog_eeprom(pi2c_client,cEeprom); - } - } - return iErr; -} - -static struct device * -get_swpdev_by_name(char *name){ - struct device *dev = class_find_device(vpd_class_p, - NULL, - name, - __swp_match); - return dev; -} - -static ssize_t -store_attr_vpd(struct device *dev_p, - struct device_attribute *attr_p, - const char *buf_p, - size_t count){ - struct i2c_client *pi2c_client = dev_get_drvdata(dev_p); - struct vpd_device_attribute *attr = to_vpd_dev_attr(attr_p); - int iOffset = attr->index; - int iErr , iLen; - char *pChar; - - if (!pi2c_client){ - return -ENODEV; - } - mutex_lock(&vpd_mutex); - - //-strip 0x0a in the last byte. - for (iLen = 0, pChar = buf_p; - iLen < 255 && *pChar != 0; - iLen++, pChar++) ; - if (iLen !=0 && *pChar == 0 && *(pChar-1) == 0x0a) - *(pChar - 1) = 0; - //- - - iErr = write_vpd_data( pi2c_client, iOffset, buf_p); - - mutex_unlock(&vpd_mutex); - return count; -} - -static ssize_t -show_attr_vpd(struct device *dev_p, - struct device_attribute *attr_p, - char *buf_p){ - - struct i2c_client *pi2c_client = dev_get_drvdata(dev_p); - struct vpd_device_attribute *attr = to_vpd_dev_attr(attr_p); - int iOffset = attr->index; - int iErr , iLen; - - if (!pi2c_client){ - return -ENODEV; - } - mutex_lock(&vpd_mutex); - iErr = get_vpd_data( pi2c_client, iOffset, buf_p); - mutex_unlock(&vpd_mutex); - - if( iErr <= 0 ) - iLen = 0; - else - iLen = snprintf(buf_p, TLV_DECODE_VALUE_MAX_LEN, "%s\n", buf_p); - - return iLen; -} - -/* ================= Vpd attribute ======================== - */ -static VPD_DEVICE_ATTR(product_name ,S_IWUSR|S_IRUGO, show_attr_vpd, store_attr_vpd, TLV_CODE_PRODUCT_NAME ); -static VPD_DEVICE_ATTR(pn ,S_IWUSR|S_IRUGO, show_attr_vpd, store_attr_vpd, TLV_CODE_PART_NUMBER ); -static VPD_DEVICE_ATTR(sn ,S_IWUSR|S_IRUGO, show_attr_vpd, store_attr_vpd, TLV_CODE_SERIAL_NUMBER ); -static VPD_DEVICE_ATTR(base_mac_addr,S_IWUSR|S_IRUGO, show_attr_vpd, store_attr_vpd, TLV_CODE_MAC_BASE ); -static VPD_DEVICE_ATTR(man_date ,S_IWUSR|S_IRUGO, show_attr_vpd, store_attr_vpd, TLV_CODE_MANUF_DATE ); -static VPD_DEVICE_ATTR(dev_ver ,S_IWUSR|S_IRUGO, show_attr_vpd, store_attr_vpd, TLV_CODE_DEVICE_VERSION ); -static VPD_DEVICE_ATTR(label_rev ,S_IWUSR|S_IRUGO, show_attr_vpd, store_attr_vpd, TLV_CODE_LABEL_REVISION ); -static VPD_DEVICE_ATTR(plat_name ,S_IWUSR|S_IRUGO, show_attr_vpd, store_attr_vpd, TLV_CODE_PLATFORM_NAME ); -static VPD_DEVICE_ATTR(ldr_ver ,S_IWUSR|S_IRUGO, show_attr_vpd, store_attr_vpd, TLV_CODE_ONIE_VERSION ); -static VPD_DEVICE_ATTR(mac_addr ,S_IWUSR|S_IRUGO, show_attr_vpd, store_attr_vpd, TLV_CODE_MAC_SIZE ); -static VPD_DEVICE_ATTR(manufacturer ,S_IWUSR|S_IRUGO, show_attr_vpd, store_attr_vpd, TLV_CODE_MANUF_NAME ); -static VPD_DEVICE_ATTR(country_code ,S_IWUSR|S_IRUGO, show_attr_vpd, store_attr_vpd, TLV_CODE_MANUF_COUNTRY ); -static VPD_DEVICE_ATTR(vendor_name ,S_IWUSR|S_IRUGO, show_attr_vpd, store_attr_vpd, TLV_CODE_VENDOR_NAME ); -static VPD_DEVICE_ATTR(diag_ver ,S_IWUSR|S_IRUGO, show_attr_vpd, store_attr_vpd, TLV_CODE_DIAG_VERSION ); -static VPD_DEVICE_ATTR(service_tag ,S_IWUSR|S_IRUGO, show_attr_vpd, store_attr_vpd, TLV_CODE_SERVICE_TAG ); -static VPD_DEVICE_ATTR(vendor_ext ,S_IWUSR|S_IRUGO, show_attr_vpd, store_attr_vpd, TLV_CODE_VENDOR_EXT ); -static VPD_DEVICE_ATTR(crc32 ,S_IRUGO, show_attr_vpd, NULL, TLV_CODE_CRC_32 ); - -static void -clean_vpd_common(void) -{ - dev_t dev_num; - struct device *device_p; - - device_p = get_swpdev_by_name(VPD_DEVICE); - if (device_p){ - dev_num = MKDEV(vpd_major, 1); - device_unregister(device_p); - device_destroy(vpd_class_p, dev_num); - } - VPD_DEBUG("%s: done.\n", __func__); -} - - -static struct register_attr VpdRegAttr[VPD_ENTRY_SIZE ] ={ - { &vpd_dev_attr_product_name.dev_attr, "vpd_dev_attr_product_name"}, - { &vpd_dev_attr_pn.dev_attr, "vpd_dev_attr_pn"}, - { &vpd_dev_attr_sn.dev_attr, "vpd_dev_attr_sn"}, - { &vpd_dev_attr_base_mac_addr.dev_attr, "vpd_dev_attr_base_mac_addr"}, - { &vpd_dev_attr_man_date.dev_attr, "vpd_dev_attr_man_date"}, - { &vpd_dev_attr_dev_ver.dev_attr, "vpd_dev_attr_dev_ver"}, - { &vpd_dev_attr_label_rev.dev_attr, "vpd_dev_attr_label_rev"}, - { &vpd_dev_attr_plat_name.dev_attr, "vpd_dev_attr_plat_name"}, - { &vpd_dev_attr_ldr_ver.dev_attr, "vpd_dev_attr_ldr_ver"}, - { &vpd_dev_attr_mac_addr.dev_attr, "vpd_dev_attr_mac_addr"}, - { &vpd_dev_attr_manufacturer.dev_attr, "vpd_dev_attr_manufacturer"}, - { &vpd_dev_attr_country_code.dev_attr, "vpd_dev_attr_country_code"}, - { &vpd_dev_attr_vendor_name.dev_attr, "vpd_dev_attr_vendor_name"}, - { &vpd_dev_attr_diag_ver.dev_attr, "vpd_dev_attr_diag_ver"}, - { &vpd_dev_attr_service_tag.dev_attr, "vpd_dev_attr_service_tag"}, - { &vpd_dev_attr_vendor_ext.dev_attr, "vpd_dev_attr_vendor_ext"}, - { &vpd_dev_attr_crc32.dev_attr, "vpd_dev_attr_crc32"}, -}; - -static int -register_vpd_attr(struct device *device_p){ - - char *err_attr = NULL; - int i; - - for( i = 0 ; i adapter = adap; - vpd_i2c_client->addr = VPD_I2C_ADDR; - - device_p = device_create(vpd_class_p, /* struct class *cls */ - NULL, /* struct device *parent */ - dev_num, /* dev_t devt */ - vpd_i2c_client, /* void *private_data */ - VPD_DEVICE); /* const char *fmt */ - if (IS_ERR(device_p)){ - err_msg = "device_create fail"; - goto err_register_vpd_device_1; - } - if (register_vpd_attr(device_p) < 0) { - err_msg = "register_vpd_attr fail"; - goto err_register_vpd_device_2; - } - return 0; - -err_register_vpd_device_2: - device_unregister(device_p); - device_destroy(vpd_class_p, dev_num); -err_register_vpd_device_1: - kfree(vpd_i2c_client); - vpd_i2c_client = NULL; -err_register_vpd_device: - VPD_ERR("%s: %s\n", __func__, err_msg); - return -1; -} - -static int -register_vpd_module(void) -{ - dev_t vpd_devt = 0; - - if (alloc_chrdev_region(&vpd_devt, 0, 1, VPD_DEVICE) < 0){ - VPD_WARN("Allocate VPD MAJOR failure! \n"); - goto err_register_vpd_module; - } - vpd_major = MAJOR(vpd_devt); - - /* Create class object */ - vpd_class_p = class_create(THIS_MODULE, EEPROM_CLASS); - if (IS_ERR(vpd_class_p)) { - VPD_ERR("Create class failure! \n"); - goto err_register_vpd_module_1; - } - return 0; - -err_register_vpd_module_1: - unregister_chrdev_region(MKDEV(vpd_major, 0), 1); -err_register_vpd_module: - return -1; -} - - -static int -init_vpd_common(void) -{ - char *err_msg = "ERR"; - - if (register_vpd_device() < 0) { - err_msg = "register_vpd_device fail"; - goto err_init_vpd_common; - } - return 0; - -err_init_vpd_common: - VPD_ERR("%s: %s\n", __func__, err_msg); - return -1; -} - - -static int __init -vpd_module_init(void) -{ - if (register_vpd_module() < 0){ - goto err_vpd_module_init; - } - if (init_vpd_common() < 0){ - goto err_vpd_module_init_1; - } - VPD_INFO("Inventec vpd module V.%s initial success.\n", VPD_VERSION); - return 0; - -err_vpd_module_init_1: - class_unregister(vpd_class_p); - class_destroy(vpd_class_p); - unregister_chrdev_region(MKDEV(vpd_major, 0), 1); -err_vpd_module_init: - VPD_ERR("Inventec vpd module V.%s initial failure.\n", VPD_VERSION); - return -1; -} - - -static void __exit -vpd_module_exit(void) -{ - clean_vpd_common(); - class_unregister(vpd_class_p); - class_destroy(vpd_class_p); - unregister_chrdev_region(MKDEV(vpd_major, 0), 1); - VPD_INFO("Remove Inventec vpd module success.\n"); -} - - -/* Module information */ -MODULE_AUTHOR(VPD_AUTHOR); -MODULE_DESCRIPTION(VPD_DESC); -MODULE_VERSION(VPD_VERSION); -MODULE_LICENSE(VPD_LICENSE); - -module_init(vpd_module_init); -module_exit(vpd_module_exit); diff --git a/packages/platforms/inventec/x86-64/d7332/modules/builds/src/inv_vpd.h b/packages/platforms/inventec/x86-64/d7332/modules/builds/src/inv_vpd.h deleted file mode 100644 index d474b5918..000000000 --- a/packages/platforms/inventec/x86-64/d7332/modules/builds/src/inv_vpd.h +++ /dev/null @@ -1,64 +0,0 @@ -/************************************************************************* - * - * inv_vpd.h - * - * 2018 Inventec Corporation - * All Rights Reserved. - * - * NOTICE: All information contained herein is, and remains - * the property of Inventec Corp. and its suppliers, - * if any. The intellectual and technical concepts contained - * herein are proprietary to Inventec Corporation and its suppliers - * and may be covered by U.S. and Foreign Patents, patents in process, - * and are protected by trade secret or copyright law. - * - ************************************************************************/ - -#ifndef INV_VPD_H -#define INV_VPD_H - -#define EEPROM_CLASS "eeprom" -#define VPD_DEVICE "vpd" -#define VPD_AUTHOR "Neil " -#define VPD_DESC "Inventec eeprom vpd driver" -#define VPD_VERSION "1.0.0" -#define VPD_LICENSE "GPL" - -#define VPD_ENTRY_SIZE (17) -#define VPD_I2C_BUS (2) -#define VPD_I2C_ADDR (0x55) - -#define VPD_KERN_VER_AF_3_10 (1) - -struct register_attr { -struct device_attribute *attr; -char * errmsg; -}; - -struct vpd_device_attribute{ - struct device_attribute dev_attr; - int index; -}; - -#define to_vpd_dev_attr(_dev_attr) \ - container_of(_dev_attr, struct vpd_device_attribute, dev_attr) - -#define VPD_ATTR(_name, _mode, _show, _store, _index) \ - { .dev_attr = __ATTR(_name, _mode, _show, _store), \ - .index = _index } - -#define VPD_DEVICE_ATTR(_name, _mode, _show, _store, _index) \ - struct vpd_device_attribute vpd_dev_attr_##_name \ - = VPD_ATTR(_name, _mode, _show, _store, _index) - -#define VPD_INFO(fmt, args...) printk( KERN_INFO "[VPD] " fmt, ##args) -#define VPD_WARN(fmt, args...) printk( KERN_WARNING "[VPD] " fmt, ##args) -#define VPD_ERR(fmt, args...) printk( KERN_ERR "[VPD] " fmt, ##args) - -#ifdef DEBUG_VPD -# define VPD_DEBUG(fmt, args...) printk( KERN_DEBUG "[VPD] " fmt, ##args) -#else -# define VPD_DEBUG(fmt, args...) -#endif - -#endif /* INV_VPD_H */ diff --git a/packages/platforms/inventec/x86-64/d7332/modules/builds/src/io_config/io_config.h b/packages/platforms/inventec/x86-64/d7332/modules/builds/src/io_config/io_config.h deleted file mode 100644 index 4d2cd7716..000000000 --- a/packages/platforms/inventec/x86-64/d7332/modules/builds/src/io_config/io_config.h +++ /dev/null @@ -1,35 +0,0 @@ -#ifndef __IO_CONFIG -#define __IO_CONFIG - -#include "io_config_banyan.h" -#include "io_config_maple.h" -//#include "io_config_cedar.h" -//#include "io_config_4U.h" - -struct platform_io_info_t platform_io_info_tbl[] = { - { - .platform_id = PLATFORM_MAPLE, - .i2c_ch_map = &maple_ioexp_i2c_ch_map, - .config_map = &maple_ioexp_config_map, - .input_map = &maple_ioexp_input_map, - .input_port_num = maple_ioexp_input_port_num, - .output = maple_ioexp_output_tbl, - .cpld_config = &maple_cpld_config, - .mux_rst_gpio = MAPLE_MUX_RST_GPIO, - }, - { - .platform_id = PLATFORM_BANYAN, - .i2c_ch_map = &banyan_ioexp_i2c_ch_map, - .config_map = &banyan_ioexp_config_map, - .input_map = &banyan_ioexp_input_map, - .input_port_num = banyan_ioexp_input_port_num, - .output = banyan_ioexp_output_tbl, - .cpld_config = &banyan_cpld_config, - .mux_rst_gpio = BANYAN_MUX_RST_GPIO, - }, - { - .platform_id = PLATFORM_END, - }, - -}; -#endif /*__IO_CONFIG*/ diff --git a/packages/platforms/inventec/x86-64/d7332/modules/builds/src/io_config/io_config_banyan.h b/packages/platforms/inventec/x86-64/d7332/modules/builds/src/io_config/io_config_banyan.h deleted file mode 100644 index 0d1db40e6..000000000 --- a/packages/platforms/inventec/x86-64/d7332/modules/builds/src/io_config/io_config_banyan.h +++ /dev/null @@ -1,214 +0,0 @@ -#ifndef __IO_CONFIG_BANYAN_H -#define __IO_CONFIG_BANYAN_H - -#define CPLD_IOEXP_INTR_N (12) /*GPIO 12*/ -#define BANYAN_MUX_RST_GPIO (69) -#define BANYAN_IO_PORT_NUM (32) -/*io expander layout*/ -int banyan_ioexp_i2c_ch[] = { - 6, - 7, - 8, - 9, -}; - -struct i2c_ch_map_t banyan_ioexp_i2c_ch_map = { - .tbl = banyan_ioexp_i2c_ch, - .size = ARRAY_SIZE(banyan_ioexp_i2c_ch), -}; -/* -typedef enum { - IOEXP_PRS_TYPE, - IOEXP_TXFAULT_TYPE, - IOEXP_RXLOS_TYPE, - IOEXP_INT_TYPE, - IOEXP_TXFAULT2_TYPE, - IOEXP_RXLOS2_TYPE, - IOEXP_INPUT_TYPE_NUM, -} ioexp_input_type_t; -*/ - -int banyan_ioexp_input_port_num[IOEXP_INPUT_TYPE_NUM] = { - - [IOEXP_PRS_TYPE] = 32, - [IOEXP_TXFAULT_TYPE] = 0, - [IOEXP_RXLOS_TYPE] = 0, - [IOEXP_INT_TYPE] = 32, - [IOEXP_TXFAULT2_TYPE] = 0, - [IOEXP_RXLOS2_TYPE] = 0, -}; - -struct ioexp_input_t banyan_ioexp_input_tbl[] = { - { - .ch_id = 0, - .ioexp_id = 2, - .addr = 0x22, - .layout = { - { - .type = IOEXP_INT_TYPE, - .port_min = 0, - .bit_min = 0, - .bit_max = 7, - }, - { - .type = IOEXP_PRS_TYPE, - .port_min = 0, - .bit_min = 8, - .bit_max = 15, - }, - {.end_of_layout = true}, - } - }, - { - .ch_id = 1, - .ioexp_id = 5, - .addr = 0x22, - .layout = { - { - .type = IOEXP_INT_TYPE, - .port_min = 8, - .bit_min = 0, - .bit_max = 7, - }, - { - .type = IOEXP_PRS_TYPE, - .port_min = 8, - .bit_min = 8, - .bit_max = 15, - }, - {.end_of_layout = true}, - } - }, - { - .ch_id = 2, - .ioexp_id = 8, - .addr = 0x22, - .layout = { - { - .type = IOEXP_INT_TYPE, - .port_min = 16, - .bit_min = 0, - .bit_max = 7, - }, - { - .type = IOEXP_PRS_TYPE, - .port_min = 16, - .bit_min = 8, - .bit_max = 15, - }, - {.end_of_layout = true}, - } - }, - { - .ch_id = 3, - .ioexp_id = 11, - .addr = 0x22, - .layout = { - { - .type = IOEXP_INT_TYPE, - .port_min = 24, - .bit_min = 0, - .bit_max = 7, - }, - { - .type = IOEXP_PRS_TYPE, - .port_min = 24, - .bit_min = 8, - .bit_max = 15, - }, - {.end_of_layout = true}, - } - }, -}; - -struct ioexp_input_map_t banyan_ioexp_input_map = { - .tbl = banyan_ioexp_input_tbl, - .size = ARRAY_SIZE(banyan_ioexp_input_tbl), -}; - -struct ioexp_output_t banyan_ioexp_modesel[] = { - {.ioexp_id = 0, .ch_id = 0, .addr = 0x20, .port_min = 0, .bit_min = 0, .bit_max = 7}, - {.ioexp_id = 3, .ch_id = 1, .addr = 0x20, .port_min = 8, .bit_min = 0, .bit_max = 7}, - {.ioexp_id = 6, .ch_id = 2, .addr = 0x20, .port_min = 16, .bit_min = 0, .bit_max = 7}, - {.ioexp_id = 9, .ch_id = 3, .addr = 0x20, .port_min = 24, .bit_min = 0, .bit_max = 7}, - {.end_of_tbl = true}, -}; - -struct ioexp_output_t banyan_ioexp_reset[] = { - {.ioexp_id = 0, .ch_id = 0, .addr = 0x20, .port_min = 0, .bit_min = 8, .bit_max = 15}, - {.ioexp_id = 3, .ch_id = 1, .addr = 0x20, .port_min = 8, .bit_min = 8, .bit_max = 15}, - {.ioexp_id = 6, .ch_id = 2, .addr = 0x20, .port_min = 16, .bit_min = 8, .bit_max = 15}, - {.ioexp_id = 9, .ch_id = 3, .addr = 0x20, .port_min = 24, .bit_min = 8, .bit_max = 15}, - {.end_of_tbl = true}, -}; - - -struct ioexp_output_t banyan_ioexp_lpmode[] = { - {.ioexp_id = 1, .ch_id = 0, .addr = 0x21, .port_min = 0, .bit_min = 0, .bit_max = 7}, - {.ioexp_id = 4, .ch_id = 1, .addr = 0x21, .port_min = 8, .bit_min = 0, .bit_max = 7}, - {.ioexp_id = 7, .ch_id = 2, .addr = 0x21, .port_min = 16, .bit_min = 0, .bit_max = 7}, - {.ioexp_id = 10, .ch_id = 3, .addr = 0x21, .port_min = 24, .bit_min = 0, .bit_max = 7}, - {.end_of_tbl = true}, -}; - - -/*[note] -typedef enum { - IOEXP_LPMODE_TYPE, - IOEXP_RESET_TYPE, - IOEXP_TXDISABLE_TYPE, - IOEXP_MODESEL_TYPE, - IOEXP_TXDISABLE2_TYPE, - IOEXP_OUTPUT_TYPE_NUM, -} ioexp_output_type_t; -*/ -struct ioexp_output_t *banyan_ioexp_output_tbl[IOEXP_OUTPUT_TYPE_NUM] = { - - [IOEXP_LPMODE_TYPE] = banyan_ioexp_lpmode, - [IOEXP_RESET_TYPE] = banyan_ioexp_reset, - [IOEXP_TXDISABLE_TYPE] = NULL, - [IOEXP_MODESEL_TYPE] = banyan_ioexp_modesel, - [IOEXP_TXDISABLE2_TYPE] = NULL, - -}; - -struct ioexp_config_t banyan_ioexp_config[] = { - {.ch_id = 0, .addr = 0x20, .val = 0x0000, .type = PCA9555_TYPE}, - {.ch_id = 0, .addr = 0x21, .val = 0xff00, .type = PCA9555_TYPE}, - {.ch_id = 0, .addr = 0x22, .val = 0xffff, .type = PCA9555_TYPE}, - {.ch_id = 1, .addr = 0x20, .val = 0x0000, .type = PCA9555_TYPE}, - {.ch_id = 1, .addr = 0x21, .val = 0xff00, .type = PCA9555_TYPE}, - {.ch_id = 1, .addr = 0x22, .val = 0xffff, .type = PCA9555_TYPE}, - {.ch_id = 2, .addr = 0x20, .val = 0x0000, .type = PCA9555_TYPE}, - {.ch_id = 2, .addr = 0x21, .val = 0xff00, .type = PCA9555_TYPE}, - {.ch_id = 2, .addr = 0x22, .val = 0xffff, .type = PCA9555_TYPE}, - {.ch_id = 3, .addr = 0x20, .val = 0x0000, .type = PCA9555_TYPE}, - {.ch_id = 3, .addr = 0x21, .val = 0xff00, .type = PCA9555_TYPE}, - {.ch_id = 3, .addr = 0x22, .val = 0xffff, .type = PCA9555_TYPE}, -}; -struct ioexp_config_map_t banyan_ioexp_config_map = { - .tbl = banyan_ioexp_config, - .size = ARRAY_SIZE(banyan_ioexp_config), -}; - -int banyan_cpld_i2c_ch[] = { - 2, -}; - -struct i2c_ch_map_t banyan_cpld_i2c_ch_map = { - .tbl = banyan_cpld_i2c_ch, - .size = ARRAY_SIZE(banyan_cpld_i2c_ch), -}; - -struct cpld_config_t banyan_cpld_config = { - .i2c_config = { - [CPLD_ID_1] = {.ch_id = 0, .addr = 0x77}, /*cpld_1*/ - [CPLD_ID_2] = {.ch_id = 0, .addr = 0x33} /*cpld_2*/ - }, - .i2c_ch_map = &banyan_cpld_i2c_ch_map, - .intr_st = {.cpld_id = CPLD_ID_1, .offset = 0x1d}, - .intr_en = {.cpld_id = CPLD_ID_1, .offset = 0x37}, - .sff_intr_gpio = CPLD_IOEXP_INTR_N, -}; - -#endif /*__IO_CONFIG_BANYAN_H*/ diff --git a/packages/platforms/inventec/x86-64/d7332/modules/builds/src/io_config/io_config_maple.h b/packages/platforms/inventec/x86-64/d7332/modules/builds/src/io_config/io_config_maple.h deleted file mode 100644 index 3441ae639..000000000 --- a/packages/platforms/inventec/x86-64/d7332/modules/builds/src/io_config/io_config_maple.h +++ /dev/null @@ -1,474 +0,0 @@ -#ifndef __IO_CONFIG_MAPLE_H -#define __IO_CONFIG_MAPLE_H - -#define CPLD_IOEXP_INTR_N (12) /*GPIO 12*/ -#define MAPLE_MUX_RST_GPIO (69) -#define MAPLE_IO_PORT_NUM (56) -/*io expander layout*/ -int maple_ioexp_i2c_ch[] = { - 6, - 7, - 8, - 9, - 10, - 11, - 12, -}; - -struct i2c_ch_map_t maple_ioexp_i2c_ch_map = { - .tbl = maple_ioexp_i2c_ch, - .size = ARRAY_SIZE(maple_ioexp_i2c_ch), -}; -/* -typedef enum { - IOEXP_PRS_TYPE, - IOEXP_TXFAULT_TYPE, - IOEXP_RXLOS_TYPE, - IOEXP_INT_TYPE, - IOEXP_TXFAULT2_TYPE, - IOEXP_RXLOS2_TYPE, - IOEXP_INPUT_TYPE_NUM, -} ioexp_input_type_t; -*/ - -int maple_ioexp_input_port_num[IOEXP_INPUT_TYPE_NUM] = { - - [IOEXP_PRS_TYPE] = 56, - [IOEXP_TXFAULT_TYPE] = 48, - [IOEXP_RXLOS_TYPE] = 48, - [IOEXP_INT_TYPE] = 8, - [IOEXP_TXFAULT2_TYPE] = 0, - [IOEXP_RXLOS2_TYPE] = 0, -}; - -struct ioexp_input_t maple_ioexp_input_tbl[] = { - { - .ch_id = 0, - .ioexp_id = 2, - .addr = 0x22, - .layout = { - { - .type = IOEXP_PRS_TYPE, - .port_min = 48, - .bit_min = 8, - .bit_max = 15, - }, - { - .type = IOEXP_INT_TYPE, - .port_min = 48, - .bit_min = 0, - .bit_max = 7, - }, - {.end_of_layout = true}, - } - }, - { - .ch_id = 1, - .ioexp_id = 3, - .addr = 0x20, - .layout = { - { - .type = IOEXP_PRS_TYPE, - .port_min = 0, - .bit_min = 4, - .bit_max = 7, - }, - { - .type = IOEXP_TXFAULT_TYPE, - .port_min = 0, - .bit_min = 0, - .bit_max = 3, - }, - { - .type = IOEXP_RXLOS_TYPE, - .port_min = 0, - .bit_min = 12, - .bit_max = 15, - }, - {.end_of_layout = true}, - } - }, - {.ch_id = 1, - .ioexp_id = 4, - .addr = 0x21, - .layout = { - { - .type = IOEXP_PRS_TYPE, - .port_min = 4, - .bit_min = 4, - .bit_max = 7, - }, - { - .type = IOEXP_TXFAULT_TYPE, - .port_min = 4, - .bit_min = 0, - .bit_max = 3, - }, - { - .type = IOEXP_RXLOS_TYPE, - .port_min = 4, - .bit_min = 12, - .bit_max = 15, - }, - {.end_of_layout = true}, - } - }, - {.ch_id = 2, - .ioexp_id = 6, - .addr = 0x20, - .layout = { - { - .type = IOEXP_PRS_TYPE, - .port_min = 8, - .bit_min = 4, - .bit_max = 7, - }, - { - .type = IOEXP_TXFAULT_TYPE, - .port_min = 8, - .bit_min = 0, - .bit_max = 3, - }, - { - .type = IOEXP_RXLOS_TYPE, - .port_min = 8, - .bit_min = 12, - .bit_max = 15, - }, - {.end_of_layout = true}, - } - }, - {.ch_id = 2, - .ioexp_id = 7, - .addr = 0x21, - .layout = { - { - .type = IOEXP_PRS_TYPE, - .port_min = 12, - .bit_min = 4, - .bit_max = 7, - }, - { - .type = IOEXP_TXFAULT_TYPE, - .port_min = 12, - .bit_min = 0, - .bit_max = 3, - }, - { - .type = IOEXP_RXLOS_TYPE, - .port_min = 12, - .bit_min = 12, - .bit_max = 15, - }, - {.end_of_layout = true}, - } - }, - {.ch_id = 3, - .ioexp_id = 9, - .addr = 0x20, - .layout = { - { - .type = IOEXP_PRS_TYPE, - .port_min = 16, - .bit_min = 4, - .bit_max = 7, - }, - { - .type = IOEXP_TXFAULT_TYPE, - .port_min = 16, - .bit_min = 0, - .bit_max = 3, - }, - { - .type = IOEXP_RXLOS_TYPE, - .port_min = 16, - .bit_min = 12, - .bit_max = 15, - }, - {.end_of_layout = true}, - } - }, - {.ch_id = 3, - .ioexp_id = 10, - .addr = 0x21, - .layout = { - { - .type = IOEXP_PRS_TYPE, - .port_min = 20, - .bit_min = 4, - .bit_max = 7, - }, - { - .type = IOEXP_TXFAULT_TYPE, - .port_min = 20, - .bit_min = 0, - .bit_max = 3, - }, - { - .type = IOEXP_RXLOS_TYPE, - .port_min = 20, - .bit_min = 12, - .bit_max = 15, - }, - {.end_of_layout = true}, - } - }, - {.ch_id = 4, - .ioexp_id = 12, - .addr = 0x20, - .layout = { - { - .type = IOEXP_PRS_TYPE, - .port_min = 24, - .bit_min = 4, - .bit_max = 7, - }, - { - .type = IOEXP_TXFAULT_TYPE, - .port_min = 24, - .bit_min = 0, - .bit_max = 3, - }, - { - .type = IOEXP_RXLOS_TYPE, - .port_min = 24, - .bit_min = 12, - .bit_max = 15, - }, - {.end_of_layout = true}, - } - }, - {.ch_id = 4, - .ioexp_id = 13, - .addr = 0x21, - .layout = { - { - .type = IOEXP_PRS_TYPE, - .port_min = 28, - .bit_min = 4, - .bit_max = 7, - }, - { - .type = IOEXP_TXFAULT_TYPE, - .port_min = 28, - .bit_min = 0, - .bit_max = 3, - }, - { - .type = IOEXP_RXLOS_TYPE, - .port_min = 28, - .bit_min = 12, - .bit_max = 15, - }, - {.end_of_layout = true}, - } - }, - {.ch_id = 5, - .ioexp_id = 15, - .addr = 0x20, - .layout = { - { - .type = IOEXP_PRS_TYPE, - .port_min = 32, - .bit_min = 4, - .bit_max = 7, - }, - { - .type = IOEXP_TXFAULT_TYPE, - .port_min = 32, - .bit_min = 0, - .bit_max = 3, - }, - { - .type = IOEXP_RXLOS_TYPE, - .port_min = 32, - .bit_min = 12, - .bit_max = 15, - }, - {.end_of_layout = true}, - } - }, - {.ch_id = 5, - .ioexp_id = 16, - .addr = 0x21, - .layout = { - { - .type = IOEXP_PRS_TYPE, - .port_min = 36, - .bit_min = 4, - .bit_max = 7, - }, - { - .type = IOEXP_TXFAULT_TYPE, - .port_min = 36, - .bit_min = 0, - .bit_max = 3, - }, - { - .type = IOEXP_RXLOS_TYPE, - .port_min = 36, - .bit_min = 12, - .bit_max = 15, - }, - {.end_of_layout = true}, - } - }, - {.ch_id = 6, - .ioexp_id = 18, - .addr = 0x20, - .layout = { - { - .type = IOEXP_PRS_TYPE, - .port_min = 40, - .bit_min = 4, - .bit_max = 7, - }, - { - .type = IOEXP_TXFAULT_TYPE, - .port_min = 40, - .bit_min = 0, - .bit_max = 3, - }, - { - .type = IOEXP_RXLOS_TYPE, - .port_min = 40, - .bit_min = 12, - .bit_max = 15, - }, - {.end_of_layout = true}, - } - }, - {.ch_id = 6, - .ioexp_id = 19, - .addr = 0x21, - .layout = { - { - .type = IOEXP_PRS_TYPE, - .port_min = 44, - .bit_min = 4, - .bit_max = 7, - }, - { - .type = IOEXP_TXFAULT_TYPE, - .port_min = 44, - .bit_min = 0, - .bit_max = 3, - }, - { - .type = IOEXP_RXLOS_TYPE, - .port_min = 44, - .bit_min = 12, - .bit_max = 15, - }, - {.end_of_layout = true}, - } - }, -}; - -struct ioexp_input_map_t maple_ioexp_input_map = { - .tbl = maple_ioexp_input_tbl, - .size = ARRAY_SIZE(maple_ioexp_input_tbl), -}; - -struct ioexp_output_t maple_ioexp_modesel[] = { - {.ioexp_id = 0, .ch_id = 0, .addr = 0x20, .port_min = 48, .bit_min = 0, .bit_max = 7}, - {.end_of_tbl = true}, -}; - -struct ioexp_output_t maple_ioexp_reset[] = { - {.ioexp_id = 0, .ch_id = 0, .addr = 0x20, .port_min = 48, .bit_min = 8, .bit_max = 15}, - {.end_of_tbl = true}, -}; - -struct ioexp_output_t maple_ioexp_lpmode[] = { - {.ioexp_id = 1, .ch_id = 0, .addr = 0x21, .port_min = 48, .bit_min = 0, .bit_max = 7}, - {.end_of_tbl = true}, -}; - -struct ioexp_output_t maple_ioexp_txdisable[] = { - /*sfp*/ - {.ioexp_id = 3, .ch_id = 1, .addr = 0x20, .port_min = 0, .bit_min = 8, .bit_max = 11}, - {.ioexp_id = 4, .ch_id = 1, .addr = 0x21, .port_min = 4, .bit_min = 8, .bit_max = 11}, - {.ioexp_id = 6, .ch_id = 2, .addr = 0x20, .port_min = 8, .bit_min = 8, .bit_max = 11}, - {.ioexp_id = 7, .ch_id = 2, .addr = 0x21, .port_min = 12, .bit_min = 8, .bit_max = 11}, - {.ioexp_id = 9, .ch_id = 3, .addr = 0x20, .port_min = 16, .bit_min = 8, .bit_max = 11}, - {.ioexp_id = 10, .ch_id = 3, .addr = 0x21, .port_min = 20, .bit_min = 8, .bit_max = 11}, - {.ioexp_id = 12, .ch_id = 4, .addr = 0x20, .port_min = 24, .bit_min = 8, .bit_max = 11}, - {.ioexp_id = 13, .ch_id = 4, .addr = 0x21, .port_min = 28, .bit_min = 8, .bit_max = 11}, - {.ioexp_id = 15, .ch_id = 5, .addr = 0x20, .port_min = 32, .bit_min = 8, .bit_max = 11}, - {.ioexp_id = 16, .ch_id = 5, .addr = 0x21, .port_min = 36, .bit_min = 8, .bit_max = 11}, - {.ioexp_id = 18, .ch_id = 6, .addr = 0x20, .port_min = 40, .bit_min = 8, .bit_max = 11}, - {.ioexp_id = 19, .ch_id = 6, .addr = 0x21, .port_min = 44, .bit_min = 8, .bit_max = 11}, - {.end_of_tbl = true}, -}; -/*[note] -typedef enum { - IOEXP_LPMODE_TYPE, - IOEXP_RESET_TYPE, - IOEXP_TXDISABLE_TYPE, - IOEXP_MODESEL_TYPE, - IOEXP_TXDISABLE2_TYPE, - IOEXP_OUTPUT_TYPE_NUM, -} ioexp_output_type_t; -*/ -struct ioexp_output_t *maple_ioexp_output_tbl[IOEXP_OUTPUT_TYPE_NUM] = { - - [IOEXP_LPMODE_TYPE] = maple_ioexp_lpmode, - [IOEXP_RESET_TYPE] = maple_ioexp_reset, - [IOEXP_TXDISABLE_TYPE] = maple_ioexp_txdisable, - [IOEXP_MODESEL_TYPE] = maple_ioexp_modesel, - [IOEXP_TXDISABLE2_TYPE] = NULL, - -}; -/*only config input pin for our purpose*/ -struct ioexp_config_t maple_ioexp_config[] = { - /*qsfp*/ - {.ch_id = 0, .addr = 0x20, .val = 0x0000, .type = PCA9555_TYPE}, - {.ch_id = 0, .addr = 0x21, .val = 0xff00, .type = PCA9555_TYPE}, - {.ch_id = 0, .addr = 0x22, .val = 0xffff, .type = PCA9555_TYPE}, - /*sfp*/ - {.ch_id = 1, .addr = 0x20, .val = 0xf0ff, .type = PCA9555_TYPE}, - {.ch_id = 1, .addr = 0x21, .val = 0xf0ff, .type = PCA9555_TYPE}, - {.ch_id = 1, .addr = 0x22, .val = 0x0000, .type = PCA9555_TYPE}, - {.ch_id = 2, .addr = 0x20, .val = 0xf0ff, .type = PCA9555_TYPE}, - {.ch_id = 2, .addr = 0x21, .val = 0xf0ff, .type = PCA9555_TYPE} , - {.ch_id = 2, .addr = 0x22, .val = 0x0000, .type = PCA9555_TYPE}, - {.ch_id = 3, .addr = 0x20, .val = 0xf0ff, .type = PCA9555_TYPE}, - {.ch_id = 3, .addr = 0x21, .val = 0xf0ff, .type = PCA9555_TYPE}, - {.ch_id = 3, .addr = 0x22, .val = 0x0000, .type = PCA9555_TYPE}, - {.ch_id = 4, .addr = 0x20, .val = 0xf0ff, .type = PCA9555_TYPE}, - {.ch_id = 4, .addr = 0x21, .val = 0xf0ff, .type = PCA9555_TYPE}, - {.ch_id = 4, .addr = 0x22, .val = 0x0000, .type = PCA9555_TYPE}, - {.ch_id = 5, .addr = 0x20, .val = 0xf0ff, .type = PCA9555_TYPE}, - {.ch_id = 5, .addr = 0x21, .val = 0xf0ff, .type = PCA9555_TYPE}, - {.ch_id = 5, .addr = 0x22, .val = 0x0000, .type = PCA9555_TYPE}, - {.ch_id = 6, .addr = 0x20, .val = 0xf0ff, .type = PCA9555_TYPE}, - {.ch_id = 6, .addr = 0x21, .val = 0xf0ff, .type = PCA9555_TYPE}, - {.ch_id = 6, .addr = 0x22, .val = 0x0000, .type = PCA9555_TYPE}, -}; -struct ioexp_config_map_t maple_ioexp_config_map = { - .tbl = maple_ioexp_config, - .size = ARRAY_SIZE(maple_ioexp_config), -}; - -int maple_cpld_i2c_ch[] = { - 2, -}; - -struct i2c_ch_map_t maple_cpld_i2c_ch_map = { - .tbl = maple_cpld_i2c_ch, - .size = ARRAY_SIZE(maple_cpld_i2c_ch), -}; - -struct cpld_config_t maple_cpld_config = { - .i2c_config = { - [CPLD_ID_1] = {.ch_id = 0, .addr = 0x77}, /*cpld_1*/ - [CPLD_ID_2] = {.ch_id = 0, .addr = 0x33} /*cpld_2*/ - }, - .i2c_ch_map = &maple_cpld_i2c_ch_map, - .intr_st = {.cpld_id = CPLD_ID_2, .offset = 0x35}, - .intr_en = {.cpld_id = CPLD_ID_2, .offset = 0x37}, - .sff_intr_gpio = CPLD_IOEXP_INTR_N, -}; - -#endif /*__IO_CONFIG_MAPLE_H*/ diff --git a/packages/platforms/inventec/x86-64/d7332/modules/builds/src/io_dev.c b/packages/platforms/inventec/x86-64/d7332/modules/builds/src/io_dev.c deleted file mode 100644 index d6aac51ba..000000000 --- a/packages/platforms/inventec/x86-64/d7332/modules/builds/src/io_dev.c +++ /dev/null @@ -1,1608 +0,0 @@ -/*io_dev.c - * handle sff io pin control , mux gpio .. cpld etc*/ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "inv_swps.h" -#include "io_dev.h" -#include "inv_def.h" -#include "io_config/io_config.h" - - -#define SFF_IO_LOG_ERR(fmt, args...) \ - do { \ - if (logLevel & DEV_ERR_LEV) \ - { \ - printk (KERN_ERR "[SFF_IO]%s:"fmt,__FUNCTION__, ##args); \ - } \ - } while (0) - -#define SFF_IO_LOG_INFO(fmt, args...) \ - do { \ - if (logLevel & DEV_INFO_LEV) \ - { \ - printk (KERN_INFO "[SFF_IO]%s:"fmt,__FUNCTION__, ##args); \ - } \ - } while (0) - -#define SFF_IO_LOG_DBG(fmt, args...) \ - do { \ - if (logLevel & DEV_DBG_LEV) \ - { \ - printk (KERN_INFO "[SFF_IO]%s:"fmt,__FUNCTION__, ##args); \ - } \ - } while (0) - -#define MUX_GPIO_LABEL "MUX_RST" -#define CPLD_INT_GPIO_LABEL "CPLD_IO_INT" - -extern u32 logLevel; -struct io_dev_t ioDev; - -#define ioexp_to_io(x) container_of(x, struct io_dev_t, ioexp_dev) -#define cpld_to_io(x) container_of(x, struct io_dev_t, cpld_io) - -struct ioexp_config_t *ioexp_head = NULL; -struct ioexp_config_t *ioexp_tail = NULL; -struct i2c_client *ioexpI2cClient = NULL; -static int gpio_base = 0; -static int pca9555_word_read(struct io_dev_client_t *ioexp_client, u8 offset); -static int pca9555_word_write(struct io_dev_client_t *ioexp_client, u8 offset, u16 val); -static int pca9555_byte_read(struct io_dev_client_t *ioexp_client, u8 offset); -static int pca9555_byte_write(struct io_dev_client_t *ioexp_client, u8 offset, u16 val); -struct io_dev_client_t *ioexp_client_find(struct ioexp_dev_t *self, int ch_id, u8 addr); -static struct pca95xx_func_t *_pca95xx_func_find(struct ioexp_config_t *ioexp_config); -static struct pca95xx_func_t *pca95xx_func_find(struct ioexp_config_map_t *map, int ioexp_id); -static bool cpld_io_intr_is_asserted(struct cpld_io_t *cpld_io); -static void cpld_io_i2c_clients_destroy(struct cpld_io_t *cpld_io); -static void cpld_io_clients_destroy(struct cpld_io_t *cpld_io); -static int cpld_io_clients_create(struct cpld_io_t *cpld_io); -static struct i2c_client *cpld_io_i2c_client_create_init(int ch); -static int cpld_io_i2c_clients_create_init(struct cpld_io_t *cpld_io); -/* -typedef enum { - IOEXP_LPMODE_TYPE, - IOEXP_RESET_TYPE, - IOEXP_TXDIABLE_TYPE, - IOEXP_MODESEL_TYPE, - IOEXP_TXDIABLE2_TYPE, - IOEXP_OUTPUT_TYPE_NUM, -} ioexp_output_type_t; -*/ -const int ioexp_out_def_val[IOEXP_OUTPUT_TYPE_NUM] = { - [IOEXP_LPMODE_TYPE] = IO_LPMODE_DEFAULT, - [IOEXP_RESET_TYPE] = IO_RESET_DEFAULT, - [IOEXP_TXDISABLE_TYPE] = IO_TXDISABLE_DEFAULT, - [IOEXP_MODESEL_TYPE] = IO_MODESEL_DEFAULT, - [IOEXP_TXDISABLE2_TYPE] = IO_TXDISABLE_DEFAULT, -}; - -const char *ioexp_output_name[IOEXP_OUTPUT_TYPE_NUM] = { - [IOEXP_LPMODE_TYPE] = "IOEXP_LPMODE", - [IOEXP_RESET_TYPE] = "IOEXP_RESET", - [IOEXP_TXDISABLE_TYPE] = "IOEXP_TXDISABLE", - [IOEXP_MODESEL_TYPE] = "IOEXP_MODESEL_TYPE", - [IOEXP_TXDISABLE2_TYPE] = "IOEXP_TXDISABLE2", -}; -/* -typedef enum { - IOEXP_PRS_TYPE, - IOEXP_TXFAULT_TYPE, - IOEXP_RXLOS_TYPE, - IOEXP_INT_TYPE, - IOEXP_TXFAULT2_TYPE, - IOEXP_RXLOS2_TYPE, - IOEXP_INPUT_TYPE_NUM, -} ioexp_input_type_t; -*/ -const char *ioexp_input_st_name[IOEXP_INPUT_TYPE_NUM] = { - [IOEXP_PRS_TYPE] = "IOEXP_PRS", - [IOEXP_TXFAULT_TYPE] = "IOEXP_TXFAULT", - [IOEXP_RXLOS_TYPE] = "IOEXP_RXLOS", - [IOEXP_INT_TYPE] = "IOEXP_INT", - [IOEXP_TXFAULT2_TYPE] = "IOEXP_TXFAULT2", - [IOEXP_RXLOS2_TYPE] = "IOEXP_RXLOS2", -}; - -/*exported functions*/ -/*sff io*/ -int ioexp_prsL_all_get(int lc_id, unsigned long *bitmap); -int ioexp_intr_all_get(int lc_id, unsigned long *bitmap); -int ioexp_rx_los_all_get(int lc_id, unsigned long *bitmap) ; -int ioexp_tx_fault_all_get(int lc_id, unsigned long *bitmap); -int ioexp_oc_all_get(int lc_id, unsigned long *bitmap); - -int ioexp_reset_set(int lc_id, int port, u8 reset); -int ioexp_reset_get(int lc_id, int port, u8 *reset); -int ioexp_lpmode_set(int lc_id, int port, u8 value); -int ioexp_lpmode_get(int lc_id, int port, u8 *value); -int ioexp_tx_disable_set(int lc_id, int port, u8 value); -int ioexp_tx_disable_get(int lc_id, int port, u8 *value); -int ioexp_modesel_set(int lc_id, int port, u8 value); -int ioexp_modesel_get(int lc_id, int port, u8 *value); -static int ioexp_power_set(int lc_id, int port, u8 val); -static int ioexp_power_get(int lc_id, int port, u8 *val); -static int ioexp_reset_all_set(int lc_id, unsigned long bitmap); -static int ioexp_reset_all_get(int lc_id, unsigned long *bitmap); -static int ioexp_lpmode_all_set(int lc_id, unsigned long bitmap); -static int ioexp_lpmode_all_get(int lc_id, unsigned long *bitmap); - -struct sff_io_driver_t ioDevSffIoDrv = { - .prs_all_get = ioexp_prsL_all_get, - .intr_all_get = ioexp_intr_all_get, - .oc_all_get = ioexp_oc_all_get, - .rx_los_all_get = ioexp_rx_los_all_get, - .tx_fault_all_get = ioexp_tx_fault_all_get, - .reset_set = ioexp_reset_set, - .reset_get = ioexp_reset_get, - .reset_all_set = ioexp_reset_all_set, - .reset_all_get = ioexp_reset_all_get, - .power_set = ioexp_power_set, - .power_get = ioexp_power_get, - .lpmode_set = ioexp_lpmode_set, - .lpmode_get = ioexp_lpmode_get, - .lpmode_all_set = ioexp_lpmode_all_set, - .lpmode_all_get = ioexp_lpmode_all_get, - .tx_disable_set = ioexp_tx_disable_set, - .tx_disable_get = ioexp_tx_disable_get, - .mode_sel_set = ioexp_modesel_set, - .mode_sel_get = ioexp_modesel_get, -}; - -struct sff_io_driver_t *sff_io_drv_get_iodev(void) -{ - return &ioDevSffIoDrv; -} - -typedef enum { - PCA95XX_INPUT, - PCA95XX_OUTPUT, - PCA95XX_CONFIG, - PCA95XX_OFFSET_TYPE_NUM, - -} pca95xx_offset_type_t; - -struct pca95xx_func_t { - u8 offset[PCA95XX_OFFSET_TYPE_NUM]; - int (*read)(struct io_dev_client_t *ioexp_client , u8 offset); - int (*write)(struct io_dev_client_t *ioexp_client, u8 offset, u16 val); -}; -struct pca95xx_func_t pca95xx_func[PCA95XX_TYPE_NUM] = { - [PCA_UNKOWN_TYPE] = - { {0x00,0x02,0x06}, /*pca9555*/ - .read = pca9555_word_read, - .write = pca9555_word_write - }, - [PCA9555_TYPE] = - { {0x00,0x02,0x06}, /*pca9555*/ - .read = pca9555_word_read, - .write = pca9555_word_write - }, - - [PCA9554_TYPE] = - { {0x00,0x01,0x03},/*pca9554*/ - .read = pca9555_byte_read, - .write = pca9555_byte_write - }, -}; -static int valid_num_get(unsigned long bitmap) -{ - int num = 0; - int i = 0; - int size = sizeof(bitmap) * 8; - - for (i = 0; i < size; i++) { - if (test_bit(i, &bitmap)) { - num++; - } - } - return num; -} -/*[note] when sff module is prsL , corrensponding bit be set*/ -int ioexp_prsL_all_get(int lc_id, unsigned long *bitmap) -{ - int prs_num = ioDev.ioexp_dev.input_port_num[IOEXP_PRS_TYPE]; - struct ldata_format_t *ldata = &(ioDev.ioexp_dev.input_st[IOEXP_PRS_TYPE]); - unsigned valid_num = valid_num_get(ldata->valid); - if (prs_num != valid_num) { - return -EBADRQC; - } - *bitmap = ldata->bitmap; - return 0; -} -EXPORT_SYMBOL(ioexp_prsL_all_get); - -int ioexp_oc_all_get(int lc_id, unsigned long *bitmap) -{ - return -1; -} -int ioexp_intr_all_get(int lc_id, unsigned long *bitmap) -{ - struct ldata_format_t *ldata = &(ioDev.ioexp_dev.input_st[IOEXP_INT_TYPE]); - int intr_num = ioDev.ioexp_dev.input_port_num[IOEXP_INT_TYPE]; - unsigned valid_num = valid_num_get(ldata->valid); - - if (0 == intr_num) { - return REC_SFF_IO_UNSUPPORTED; - } - if (intr_num != valid_num) { - return -EBADRQC; - } - - *bitmap = ldata->bitmap; - return 0; -} -int ioexp_rx_los_all_get(int lc_id, unsigned long *bitmap) -{ - struct ldata_format_t *ldata = &(ioDev.ioexp_dev.input_st[IOEXP_RXLOS_TYPE]); - int rxlos_num = ioDev.ioexp_dev.input_port_num[IOEXP_RXLOS_TYPE]; - unsigned valid_num = valid_num_get(ldata->valid); - - if (0 == rxlos_num) { - return REC_SFF_IO_UNSUPPORTED; - } - if (rxlos_num != valid_num) { - return -EBADRQC; - } - - *bitmap = ldata->bitmap; - return 0; -} -int ioexp_tx_fault_all_get(int lc_id, unsigned long *bitmap) -{ - struct ldata_format_t *ldata = &(ioDev.ioexp_dev.input_st[IOEXP_TXFAULT_TYPE]); - int txfault_num = ioDev.ioexp_dev.input_port_num[IOEXP_TXFAULT_TYPE]; - unsigned valid_num = valid_num_get(ldata->valid); - - if (0 == txfault_num) { - return REC_SFF_IO_UNSUPPORTED; - } - - if (txfault_num != valid_num) { - return -EBADRQC; - } - - *bitmap = ldata->bitmap; - return 0; -} - -static int ioexp_power_set(int lc_id, int port, u8 val) -{ - return 0; -} -static int ioexp_power_get(int lc_id, int port, u8 *val) -{ - /*always true*/ - *val = 1; - return 0; -} - -static void ioexp_i2c_clients_destroy(struct ioexp_dev_t *ioexp_dev) -{ - int id = 0; - int size = ioexp_dev->i2c_ch_map->size; - - if (!p_valid(ioexp_dev)) { - return; - } - if (p_valid(ioexpI2cClient)) { - kfree(ioexpI2cClient); - } - for (id = 0; id < size; id++) { - ioexp_dev->ioexp_client[id].client = NULL; - } -} - -static void ioexp_i2c_clients_deinit(struct ioexp_dev_t *ioexp_dev) -{ - struct i2c_client *client = NULL; - int id = 0; - int size = ioexp_dev->i2c_ch_map->size; - - if (!p_valid(ioexp_dev)) { - return; - } - - for (id = 0; id < size; id++) { - client = ioexp_dev->ioexp_client[id].client; - if (p_valid(client)) { - if (p_valid(client->adapter)) { - i2c_put_adapter(client->adapter); - } - } - } -} - -static void ioexp_clients_destroy(struct ioexp_dev_t *ioexp_dev) -{ - if (p_valid(ioexp_dev->ioexp_client)) { - kfree(ioexp_dev->ioexp_client); - } -} -static int ioexp_clients_create(struct ioexp_dev_t *ioexp_dev) -{ - int size = ioexp_dev->i2c_ch_map->size; - struct io_dev_client_t *ioexp_client = NULL; - ioexp_client = kzalloc(sizeof(struct io_dev_client_t) * size, GFP_KERNEL); - if (!p_valid(ioexp_client)) { - return -ENOMEM; - } - ioexp_dev->ioexp_client = ioexp_client; - return 0; -} - -int ioexp_i2c_client_init(int ch, struct i2c_client **client) -{ - struct i2c_adapter *adap = NULL; - - if (!p_valid(*client)) { - return -EBADRQC; - } - adap = i2c_get_adapter(ch); - if (!p_valid(adap)) { - SFF_IO_LOG_ERR("get adapter fail ch:%d\n", ch); - return -EBADRQC; - } - - SFF_IO_LOG_DBG("get adapter ok ch:%d\n", ch); - (*client)->adapter = adap; - - return 0; -} - -static int ioexp_i2c_clients_init(struct ioexp_dev_t *ioexp_dev) -{ - int ret = 0; - int i = 0; - int size = ioexp_dev->i2c_ch_map->size; - int *tbl = ioexp_dev->i2c_ch_map->tbl; - struct io_dev_client_t *ioexp_client = NULL; - - for (i = 0; i < size; i++) { - ioexp_client = &ioexp_dev->ioexp_client[i]; - if ((ret = ioexp_i2c_client_init(tbl[i], &(ioexp_client->client))) < 0) { - break; - } - mutex_init(&(ioexp_client->lock)); - - } - if (ret < 0) { - ioexp_i2c_clients_deinit(ioexp_dev); - return ret; - } - return 0; -} -static int ioexp_i2c_clients_create(struct ioexp_dev_t *ioexp_dev) -{ - int i = 0; - int size = ioexp_dev->i2c_ch_map->size; - struct i2c_client *client = NULL; - - client = kzalloc(sizeof(struct i2c_client)*size, GFP_KERNEL); - if (!p_valid(client)) { - return -EBADRQC; - } - ioexpI2cClient = client; - /*build a link*/ - for (i = 0; i < size; i++) { - ioexp_dev->ioexp_client[i].client = &ioexpI2cClient[i]; - } - return 0; -} -static void cpld_io_i2c_clients_destroy(struct cpld_io_t *cpld_io) -{ - struct i2c_client *client = NULL; - int id = 0; - int size = cpld_io->config->i2c_ch_map->size; - - for (id = 0; id < size; id++) { - client = cpld_io->cpld_client[id].client; - if (p_valid(client)) { - if (p_valid(client->adapter)) { - i2c_put_adapter(client->adapter); - } - kfree(client); - } - } -} - -static void cpld_io_clients_destroy(struct cpld_io_t *cpld_io) -{ - if (p_valid(cpld_io->cpld_client)) { - kfree(cpld_io->cpld_client); - } -} -static int cpld_io_clients_create(struct cpld_io_t *cpld_io) -{ - int size = cpld_io->config->i2c_ch_map->size; - struct io_dev_client_t *cpld_client = NULL; - cpld_client = kzalloc(sizeof(struct io_dev_client_t) * size, GFP_KERNEL); - if (!p_valid(cpld_client)) { - return -ENOMEM; - } - cpld_io->cpld_client = cpld_client; - return 0; -} - - -static struct i2c_client *cpld_io_i2c_client_create_init(int ch) -{ - struct i2c_client *client = NULL; - struct i2c_adapter *adap = NULL; - - client = kzalloc(sizeof(struct i2c_client), GFP_KERNEL); - if (!p_valid(client)) { - goto exit_err; - } - adap = i2c_get_adapter(ch); - if (!p_valid(adap)) { - SFF_IO_LOG_ERR("get adapter fail ch:%d\n", ch); - goto exit_kfree_i2c_client; - } - client->adapter = adap; - return client; - -exit_kfree_i2c_client: - kfree(client); -exit_err: - return NULL; -} -static int cpld_io_i2c_clients_create_init(struct cpld_io_t *cpld_io) -{ - int i = 0; - int size = cpld_io->config->i2c_ch_map->size; - int *tbl = cpld_io->config->i2c_ch_map->tbl; - struct i2c_client *client = NULL; - - for (i = 0; i < size; i++) { - client = cpld_io_i2c_client_create_init(tbl[i]); - if (!p_valid(client)) { - break; - } - cpld_io->cpld_client[i].client = client; - mutex_init(&(cpld_io->cpld_client[i].lock)); - - } - if (i < size) { - cpld_io_i2c_clients_destroy(cpld_io); - return -EBADRQC; - } - return 0; -} - -int io_dev_mux_rst_gpio_init(int mux_rst_gpio) -{ - /*pull high*/ - int ret = 0; - /* insmod gpiobase later on*/ - mux_rst_gpio += gpio_base; - SFF_IO_LOG_DBG("mux rst gpio:%d \n", mux_rst_gpio); - if ((ret = gpio_is_valid(mux_rst_gpio)) < 0) { - SFF_IO_LOG_ERR("invaid gpio:%d ret:%d\n", mux_rst_gpio, ret); - return -1; - } - if ((ret = gpio_request(mux_rst_gpio, MUX_GPIO_LABEL)) < 0) { - SFF_IO_LOG_ERR("gpio:%d request fail\n", mux_rst_gpio); - } - if(gpio_direction_output(mux_rst_gpio, 1) < 0) { - SFF_IO_LOG_ERR("init NG\n"); - return -1; - } - mdelay(1); /*1ms*/ - - SFF_IO_LOG_ERR("init Pass\n"); - return 0; -} - -int io_dev_mux_reset_get(int lc_id, int *val) -{ - int lv = 0; - lv = gpio_get_value(ioDev.mux_rst_gpio); - *val = lv; - return 0; -} - -/*io mux control*/ -int io_dev_mux_reset_set(int lc_id, int value) -{ - gpio_set_value(ioDev.mux_rst_gpio, value); - return 0; -} - -static bool _ioexp_is_channel_ready(struct ioexp_dev_t *ioexp_dev, struct ioexp_config_t *config) -{ - int ret = 0; - struct pca95xx_func_t *func = NULL; - struct io_dev_client_t *ioexp_client = NULL; - - if (!p_valid(config)) { - SFF_IO_LOG_ERR("NULL ptr\n"); - return false; - } - - if (!p_valid(ioexp_client = ioexp_client_find(ioexp_dev, config->ch_id, config->addr))) { - return false; - } - if (!p_valid(func = _pca95xx_func_find(config))) { - return false; - } - if ((ret = func->read(ioexp_client, func->offset[PCA95XX_CONFIG])) < 0) { - return false; - } - if (ret != config->val) { - SFF_IO_LOG_ERR("ch:%d config mismatch default:%x reg:%x\n", config->ch_id, config->val, ret); - return false; - } - return true; -} -bool ioexp_is_channel_ready(int lc_id) -{ - bool h_ready = false; - bool t_ready = false; - (void)lc_id; - - if (!(h_ready = _ioexp_is_channel_ready(&(ioDev.ioexp_dev), ioexp_head))) { - return false; - } - if (!(t_ready = _ioexp_is_channel_ready(&(ioDev.ioexp_dev), ioexp_tail))) { - return false; - } - - return true; -} - -int ioexp_config_init(struct ioexp_dev_t *ioexp_dev) -{ - int ioexp_id = 0; - int ret = 0; - struct ioexp_config_t *config = NULL; - struct ioexp_config_t *tbl = NULL; - struct pca95xx_func_t *func = NULL; - struct io_dev_client_t *ioexp_client = NULL; - int size = 0; - - tbl = ioexp_dev->config_map->tbl; - size = ioexp_dev->config_map->size; - - for (ioexp_id = 0; ioexp_id < size; ioexp_id++) { - config = &tbl[ioexp_id]; - - if (!p_valid(ioexp_client = ioexp_client_find(ioexp_dev, config->ch_id, config->addr))) { - ret = -EBADRQC; - break; - } - if (!p_valid(func = pca95xx_func_find(ioexp_dev->config_map, ioexp_id))) { - ret = -EBADRQC; - break; - } - - if ((ret = func->write(ioexp_client, func->offset[PCA95XX_CONFIG], config->val)) < 0) { - SFF_IO_LOG_ERR("io config fail: ch_id:0x%x addr:0x%x val:0x%x\n", config->ch_id, config->addr, config->val); - break; - } - } - if (ret < 0) { - return ret; - } - /*assign for ioexp channel check*/ - for (ioexp_id = 0; ioexp_id < size; ioexp_id++) { - config = &tbl[ioexp_id]; - if (config->val != 0) { - ioexp_head = config; - break; - } - } - for (ioexp_id = size - 1; ioexp_id >= 0; ioexp_id--) { - config = &tbl[ioexp_id]; - if (config->val != 0) { - ioexp_tail = config; - break; - } - - } - - if (NULL == ioexp_head || - NULL == ioexp_tail) { - SFF_IO_LOG_ERR("ioexp_head tail config fail\n"); - return -1; - } else { - SFF_IO_LOG_INFO("ioexp_head ch_id:%d addr:0x%x\n", ioexp_head->ch_id, ioexp_head->addr); - SFF_IO_LOG_INFO("ioexp_tail ch_id:%d addr:0x%x\n", ioexp_tail->ch_id, ioexp_tail->addr); - } - return 0; -} - -struct io_dev_client_t *ioexp_client_find(struct ioexp_dev_t *dev, int ch_id, u8 addr) -{ - struct io_dev_client_t *ioexp_client = NULL; - ioexp_client = &(dev->ioexp_client[ch_id]); - ioexp_client->client->addr = addr; - - return ioexp_client; -} - -/*update the pin status of corresonding ioexpander control(ex: prsL) by port*/ -void ioexp_input_st_update(struct ldata_format_t ioexp_input_st[], - struct pin_layout_t layout_tbl[], - int data) -{ - int port = 0; - int bit = 0; - int st = 0; - int old_st = 0; - int i = 0; - struct ldata_format_t *input_st = NULL; - struct pin_layout_t *layout = NULL; - char *port_name = NULL; - - for (i = 0; true != layout_tbl[i].end_of_layout; i++) { - - layout = &layout_tbl[i]; - port = layout->port_min; - input_st = &(ioexp_input_st[layout->type]); - - for (bit = layout->bit_min; bit <= layout->bit_max; bit++, port++) { - st = ((test_bit(bit, (unsigned long *)&data)) ? 1 : 0); - /*debug msg*/ - old_st = ((test_bit(port, &(input_st->bitmap))) ? 1 : 0); - if (old_st != st) { - port_name = port_name_get(0, port); - if (p_valid(port_name)) { - SFF_IO_LOG_DBG("%s %s st:%d->%d\n", ioexp_input_st_name[layout->type], port_name, old_st, st); - } - } - if (st) { - set_bit(port, &(input_st->bitmap)); - } else { - clear_bit(port, &(input_st->bitmap)); - } - set_bit(port, &(input_st->valid)); - //SFF_IO_LOG_DBG("%s data:%d ch:%d addr:0x%x st[%d]:%d\n", name, data, ioexp->ch, ioexp->addr, port, val); - } - } -} - -void ioexp_input_st_update_fail(struct ldata_format_t ioexp_input_st[], - struct pin_layout_t layout_tbl[]) -{ - int port = 0; - int bit = 0; - int i = 0; - struct ldata_format_t *input_st = NULL; - struct pin_layout_t *layout = NULL; - - for (i = 0; true != layout_tbl[i].end_of_layout; i++) { - - layout = &layout_tbl[i]; - port = layout->port_min; - input_st = &(ioexp_input_st[layout->type]); - - for (bit = layout->bit_min; bit <= layout->bit_max; bit++, port++) { - clear_bit(port, &(input_st->valid)); - } - } -} -static struct pca95xx_func_t *_pca95xx_func_find(struct ioexp_config_t *ioexp_config) -{ - if (!p_valid(ioexp_config)) { - return NULL; - } - - if (PCA_UNKOWN_TYPE == ioexp_config->type) { - return NULL; - } - - return &pca95xx_func[ioexp_config->type]; -} -static struct pca95xx_func_t *pca95xx_func_find(struct ioexp_config_map_t *map, int ioexp_id) -{ - /*ioexp_id range check*/ - if (ioexp_id < 0 && ioexp_id >= map->size) { - return NULL; - } - return _pca95xx_func_find(&(map->tbl[ioexp_id])); -} - -static int pca9555_byte_read(struct io_dev_client_t *ioexp_client, u8 offset) -{ - int ret = 0; - mutex_lock(&ioexp_client->lock); - ret = i2c_smbus_read_byte_data_retry(ioexp_client->client, offset); - mutex_unlock(&ioexp_client->lock); - - return ret; -} -static int pca9555_byte_write(struct io_dev_client_t *ioexp_client, u8 offset, u16 val) -{ - int ret = 0; - mutex_lock(&ioexp_client->lock); - ret = i2c_smbus_write_byte_data_retry(ioexp_client->client, offset, val); - mutex_unlock(&ioexp_client->lock); - - return ret; -} -static int pca9555_word_read(struct io_dev_client_t *ioexp_client, u8 offset) -{ - int ret = 0; - mutex_lock(&ioexp_client->lock); - ret = i2c_smbus_read_word_data_retry(ioexp_client->client, offset); - mutex_unlock(&ioexp_client->lock); - - return ret; -} -static int pca9555_word_write(struct io_dev_client_t *ioexp_client, u8 offset, u16 val) -{ - int ret = 0; - mutex_lock(&ioexp_client->lock); - ret = i2c_smbus_write_word_data_retry(ioexp_client->client, offset, val); - mutex_unlock(&ioexp_client->lock); - - return ret; -} -struct ioexp_output_t *find_ioexp_output_byPort(struct ioexp_output_t map[], int port) -{ - int i = 0; - int port_max = 0; - for (i = 0; map[i].end_of_tbl != true; i++) { - port_max = map[i].port_min + (map[i].bit_max - map[i].bit_min); - if (port <= port_max) { - return &map[i]; - } - } - return NULL; -} -int ioexp_output_set(struct ioexp_dev_t *dev, ioexp_output_type_t type, int port, u8 val) -{ - int ret = 0; - int bit = 0; - u16 reg = 0; - struct io_dev_client_t *ioexp_client = NULL; - struct pca95xx_func_t *func = NULL; - struct ioexp_output_t *ioexp = NULL; - - if (!p_valid(dev->output[type])) { - if (p_valid(ioexp_output_name[type])) { - SFF_IO_LOG_INFO("%s not supported\n", ioexp_output_name[type]); - } - return REC_SFF_IO_UNSUPPORTED; - } - - if (!p_valid(ioexp = find_ioexp_output_byPort(dev->output[type], port))) { - return -1; - } - if (!p_valid(ioexp_client = ioexp_client_find(dev, ioexp->ch_id, ioexp->addr))) { - return -1; - } - - if (!p_valid(func = pca95xx_func_find(dev->config_map, ioexp->ioexp_id))) { - return -1; - } - - if ((ret = func->read(ioexp_client, func->offset[PCA95XX_OUTPUT])) < 0) { - SFF_IO_LOG_ERR("read fail! ioexp_id:%d ch_id:%d addr:0x%x\n", - ioexp->ioexp_id, ioexp->ch_id, ioexp->addr); - return ret; - } - reg = ret; - bit = ioexp->bit_min + (port - ioexp->port_min); - if (val) { - set_bit(bit, (unsigned long *)®); - } else { - clear_bit(bit, (unsigned long *)®); - } - - if ((ret = func->write(ioexp_client, func->offset[PCA95XX_OUTPUT], reg)) < 0) { - return ret; - } - SFF_IO_LOG_DBG("%s set ok ch_id:%d addr:0x%x reg:0x%x\n", ioexp_output_name[type], ioexp->ch_id, ioexp->addr, reg); - return 0; -} -static void set_reg_update(struct ioexp_output_t *ioexp, unsigned long bitmap, u16 *reg) -{ - u16 new_reg = 0; - int port_min = 0; - int port_max = 0; - u16 set_bits = 0; - int bit = 0; - int port = 0; - - port_min = ioexp->port_min; - port_max = ioexp->port_min + (ioexp->bit_max - ioexp->bit_min); - - for (port = port_min, bit = ioexp->bit_min; port <= port_max; port++, bit++) { - if (test_bit(port, &bitmap)) { - set_bit(bit, (unsigned long *)&set_bits); - } - } - - SFF_IO_LOG_DBG("bitmap:0x%lx set_bits:0x%x\n", bitmap, set_bits); - for (bit = ioexp->bit_min; bit <= ioexp->bit_max; bit++) { - if (test_bit(bit, (unsigned long *)&set_bits)) { - set_bit(bit, (unsigned long *)&new_reg); - } else { - clear_bit(bit, (unsigned long *)&new_reg); - } - } - *reg = new_reg; -} - -static void recv_reg_update(struct ioexp_output_t *ioexp, u16 reg, unsigned long *bitmap) -{ - int port = 0; - int bit = 0; - unsigned long recv_bitmap = 0; - - recv_bitmap = *bitmap; - - for (port = ioexp->port_min, bit = ioexp->bit_min; bit <= ioexp->bit_max; bit++, port++) { - if (test_bit(bit, (unsigned long *)®)) { - set_bit(port, &recv_bitmap); - } else { - clear_bit(port, &recv_bitmap); - } - } - //SFF_IO_LOG_DBG("bitmap:0x%lx, recv_bit:0x%x\n", recv_bitmap, reg); - - *bitmap = recv_bitmap; -} -int ioexp_output_all_set(struct ioexp_dev_t *dev, ioexp_output_type_t type, unsigned long bitmap) -{ - int ret = 0; - u16 reg = 0; - struct io_dev_client_t *ioexp_client = NULL; - struct pca95xx_func_t *func = NULL; - struct ioexp_output_t *tbl = NULL; - struct ioexp_output_t *ioexp = NULL; - int count = 0; - - if (!p_valid(dev->output[type])) { - if (p_valid(ioexp_output_name[type])) { - SFF_IO_LOG_INFO("%s not supported\n", ioexp_output_name[type]); - } - return REC_SFF_IO_UNSUPPORTED; - } - tbl = dev->output[type]; - - for (count = 0; tbl[count].end_of_tbl != true; count++) { - ioexp = &tbl[count]; - if (!p_valid(ioexp_client = ioexp_client_find(dev, ioexp->ch_id, ioexp->addr))) { - ret = -EBADRQC; - break; - } - - if (!p_valid(func = pca95xx_func_find(dev->config_map, ioexp->ioexp_id))) { - ret = -EBADRQC; - break; - } - - if ((ret = func->read(ioexp_client, func->offset[PCA95XX_OUTPUT])) < 0) { - SFF_IO_LOG_ERR("read fail! ioexp_id:%d ch_id:%d addr:0x%x\n", - ioexp->ioexp_id, ioexp->ch_id, ioexp->addr); - break; - } - reg = ret; - set_reg_update(ioexp, bitmap, ®); - - if ((ret = func->write(ioexp_client, func->offset[PCA95XX_OUTPUT], reg)) < 0) { - break; - } - - SFF_IO_LOG_INFO("%s set ok ch_id:%d addr:0x%x reg:0x%x\n", ioexp_output_name[type], ioexp->ch_id, ioexp->addr, reg); - } - if (ret < 0) { - return ret; - } - - return 0; -} - -static int ioexp_reset_all_set(int lc_id, unsigned long bitmap) -{ - return ioexp_output_all_set(&(ioDev.ioexp_dev), IOEXP_RESET_TYPE, bitmap); -} - -static int ioexp_lpmode_all_set(int lc_id, unsigned long bitmap) -{ - return ioexp_output_all_set(&(ioDev.ioexp_dev), IOEXP_LPMODE_TYPE, bitmap); -} - -int ioexp_output_get(struct ioexp_dev_t *dev, ioexp_output_type_t type, int port, u8 *val) -{ - int ret = 0; - int bit = 0; - u16 reg = 0; - struct io_dev_client_t *ioexp_client = NULL; - struct pca95xx_func_t *func = NULL; - struct ioexp_output_t *ioexp = NULL; - - if (!p_valid(dev->output[type])) { - if (p_valid(ioexp_output_name[type])) { - SFF_IO_LOG_INFO("%s not supported\n", ioexp_output_name[type]); - } - return REC_SFF_IO_UNSUPPORTED; - } - - if (!p_valid(ioexp = find_ioexp_output_byPort(dev->output[type], port))) { - return -1; - } - if (!p_valid(ioexp_client = ioexp_client_find(dev, ioexp->ch_id, ioexp->addr))) { - return -1; - } - - if (!p_valid(func = pca95xx_func_find(dev->config_map, ioexp->ioexp_id))) { - return -1; - } - - if ((ret = func->read(ioexp_client, func->offset[PCA95XX_OUTPUT])) < 0) { - SFF_IO_LOG_ERR("read fail! ch_id:%d addr:0x%x\n", ioexp->ch_id, ioexp->addr); - return ret; - } - reg = ret; - - bit = ioexp->bit_min + (port - ioexp->port_min); - if (test_bit(bit, (unsigned long *)®)) { - *val = 1; - } else { - *val = 0; - } - - return 0; -} - -int ioexp_output_all_get(struct ioexp_dev_t *dev, ioexp_output_type_t type, unsigned long *bitmap) -{ - int ret = 0; - u16 reg = 0; - struct io_dev_client_t *ioexp_client = NULL; - struct pca95xx_func_t *func = NULL; - struct ioexp_output_t *tbl = NULL; - struct ioexp_output_t *ioexp = NULL; - int count = 0; - unsigned long new_bitmap = 0; - - if (!p_valid(dev->output[type])) { - if (p_valid(ioexp_output_name[type])) { - SFF_IO_LOG_INFO("%s not supported\n", ioexp_output_name[type]); - } - return REC_SFF_IO_UNSUPPORTED; - } - tbl = dev->output[type]; - - for (count = 0; tbl[count].end_of_tbl != true; count++) { - ioexp = &tbl[count]; - if (!p_valid(ioexp_client = ioexp_client_find(dev, ioexp->ch_id, ioexp->addr))) { - ret = -EBADRQC; - break; - } - - if (!p_valid(func = pca95xx_func_find(dev->config_map, ioexp->ioexp_id))) { - ret = -EBADRQC; - break; - } - - if ((ret = func->read(ioexp_client, func->offset[PCA95XX_OUTPUT])) < 0) { - SFF_IO_LOG_ERR("read fail! ioexp_id:%d ch_id:%d addr:0x%x\n", - ioexp->ioexp_id, ioexp->ch_id, ioexp->addr); - break; - } - reg = ret; - recv_reg_update(ioexp, reg, &new_bitmap); - } - if (ret < 0) { - return ret; - } - *bitmap = new_bitmap; - - return 0; -} - -static int ioexp_reset_all_get(int lc_id, unsigned long *bitmap) -{ - return ioexp_output_all_get(&(ioDev.ioexp_dev), IOEXP_RESET_TYPE, bitmap); -} - -static int ioexp_lpmode_all_get(int lc_id, unsigned long *bitmap) -{ - return ioexp_output_all_get(&(ioDev.ioexp_dev), IOEXP_LPMODE_TYPE, bitmap); -} - -int ioexp_lpmode_set(int lc_id, int port, u8 val) -{ - return ioexp_output_set(&(ioDev.ioexp_dev), IOEXP_LPMODE_TYPE, port, val); -} -EXPORT_SYMBOL(ioexp_lpmode_set); - -int ioexp_lpmode_get(int lc_id, int port, u8 *lpmode) -{ - int ret = 0; - - ret = ioexp_output_get(&(ioDev.ioexp_dev), IOEXP_LPMODE_TYPE, port, lpmode); - if (ret < 0 || - ret == REC_SFF_IO_UNSUPPORTED) { - return ret; - } - return 0; -} -EXPORT_SYMBOL(ioexp_lpmode_get); - -int ioexp_reset_set(int lc_id, int port, u8 val) -{ - return ioexp_output_set(&(ioDev.ioexp_dev), IOEXP_RESET_TYPE, port, val); -} -EXPORT_SYMBOL(ioexp_reset_set); - -int ioexp_reset_get(int lc_id, int port, u8 *lv) -{ - int ret = 0; - - ret = ioexp_output_get(&(ioDev.ioexp_dev), IOEXP_RESET_TYPE, port, lv); - if (ret < 0 || - ret == REC_SFF_IO_UNSUPPORTED) { - return ret; - } - return 0; -} -EXPORT_SYMBOL(ioexp_reset_get); - -int ioexp_modesel_set(int lc_id, int port, u8 val) -{ - return ioexp_output_set(&(ioDev.ioexp_dev), IOEXP_MODESEL_TYPE, port, val); -} -EXPORT_SYMBOL(ioexp_modesel_set); - -int ioexp_modesel_get(int lc_id, int port, u8 *val) -{ - int ret = 0; - - ret = ioexp_output_get(&(ioDev.ioexp_dev), IOEXP_MODESEL_TYPE, port, val); - if (ret < 0 || - ret == REC_SFF_IO_UNSUPPORTED) { - return ret; - } - return 0; -} -EXPORT_SYMBOL(ioexp_modesel_get); - -int ioexp_tx_disable_set(int lc_id, int port, u8 val) -{ - return ioexp_output_set(&(ioDev.ioexp_dev), IOEXP_TXDISABLE_TYPE, port, val); -} -EXPORT_SYMBOL(ioexp_tx_disable_set); - -int ioexp_tx_disable_get(int lc_id, int port, u8 *val) -{ - int ret = 0; - - ret = ioexp_output_get(&(ioDev.ioexp_dev), IOEXP_TXDISABLE_TYPE, port, val); - if (ret < 0 || - ret == REC_SFF_IO_UNSUPPORTED) { - return ret; - } - return 0; - -} -EXPORT_SYMBOL(ioexp_tx_disable_get); - - -int ioexp_input_polling(struct ioexp_dev_t *dev) -{ - int ret = 0; - int data = 0; - int id = 0; - struct io_dev_client_t *ioexp_client = NULL; - struct ioexp_input_t *tbl = dev->input_map->tbl; - int size = dev->input_map->size; - struct pca95xx_func_t *func = NULL; - struct ioexp_input_t *ioexp = NULL; - - for (id = 0; id < size; id++) { - ioexp = &tbl[id]; - if (!p_valid(ioexp_client = ioexp_client_find(dev, ioexp->ch_id, ioexp->addr))) { - ret = -EBADRQC; - break; - } - if (!p_valid(func = pca95xx_func_find(dev->config_map, ioexp->ioexp_id))) { - ret = -EBADRQC; - break; - } - - if ((ret = func->read(ioexp_client, func->offset[PCA95XX_INPUT])) < 0) { - SFF_IO_LOG_ERR("read fail! ioexp_in_id:%d ioexp_id:%d ch_id:%d addr:0x%x\n", - id, ioexp->ioexp_id, ioexp->ch_id, ioexp->addr); - ioexp_input_st_update_fail(dev->input_st, ioexp->layout); - break; - } - data = ret; - ioexp_input_st_update(dev->input_st, ioexp->layout, data); - } - if (ret < 0) { - return ret; - } - return 0; -} - -int ioexp_input_intr_hdlr(struct ioexp_dev_t *dev) -{ - int ret = 0; - int data = 0; - int id = 0; - struct io_dev_client_t *ioexp_client = NULL; - struct ioexp_input_t *tbl = dev->input_map->tbl; - int size = dev->input_map->size; - struct pca95xx_func_t *func = NULL; - struct ioexp_input_t *ioexp = NULL; - struct cpld_io_t *cpld_io = NULL; - struct io_dev_t *io_dev = ioexp_to_io(dev); - u32 intr_reg = 0; - - if (!p_valid(io_dev)) { - return -EBADRQC; - } - cpld_io = &(io_dev->cpld_io); - if (!p_valid(cpld_io)) { - return -EBADRQC; - } - - if (cpld_io_intr_is_asserted(cpld_io)) { - SFF_IO_LOG_DBG("cpld_io_intr_is_asserted\n"); - - check_pfunc(cpld_io->intr_st_get); - if ((ret = cpld_io->intr_st_get(cpld_io, &intr_reg)) < 0) { - return ret; - } - - for (id = 0; id < size; id++) { - - if (test_bit(id, (unsigned long *)&intr_reg)) { - SFF_IO_LOG_DBG("intr_reg:0x%x\n", intr_reg); - ioexp = &tbl[id]; - if (!p_valid(ioexp_client = ioexp_client_find(dev, ioexp->ch_id, ioexp->addr))) { - ret = -EBADRQC; - break; - } - if (!p_valid(func = pca95xx_func_find(dev->config_map, ioexp->ioexp_id))) { - ret = -EBADRQC; - break; - } - - if ((ret = func->read(ioexp_client, func->offset[PCA95XX_INPUT])) < 0) { - SFF_IO_LOG_ERR("read fail! ioexp_in_id:%d ioexp_id:%d ch_id:%d addr:0x%x\n", - id, ioexp->ioexp_id, ioexp->ch_id, ioexp->addr); - ioexp_input_st_update_fail(dev->input_st, ioexp->layout); - break; - } - data = ret; - ioexp_input_st_update(dev->input_st, ioexp->layout, data); - } - } - - } - return 0; -} - -int io_dev_hdlr(void) -{ - struct ioexp_dev_t *ioexp_dev = &ioDev.ioexp_dev; - - check_pfunc(ioexp_dev->input_hdlr); - return ioexp_dev->input_hdlr(ioexp_dev); -} -int ioexp_input_handler(void) -{ - struct ioexp_dev_t *ioexp_dev = &ioDev.ioexp_dev; - check_pfunc(ioexp_dev->input_hdlr); - return ioexp_dev->input_hdlr(ioexp_dev); -} -int ioexp_input_init(struct ioexp_dev_t *dev) -{ - return ioexp_input_polling(dev); -} -int _ioexp_output_config(struct ioexp_output_t *ioexp, int default_val, u16 *data) -{ - u16 ret = 0; - int bit = 0; - int bit_min = 0; - int bit_max = 0; - bit_min = ioexp->bit_min; - bit_max = ioexp->bit_max; - - ret = *data; - if (default_val) { - for (bit = bit_min; bit <= bit_max; bit++) { - set_bit(bit , (unsigned long *)&ret); - } - } else { - for (bit = bit_min; bit <= bit_max; bit++) { - clear_bit(bit , (unsigned long *)&ret); - } - - } - //SFF_IO_LOG_DBG("bit_min %d ch:%d addr:0x%x ret:%d\n", bit_min, ioexp->ch, ioexp->addr, ret); - *data = ret; - return 0; -} -int ioexp_output_init(struct ioexp_dev_t *dev, int io_no_init) -{ - int count = 0; - int ret = 0; - u16 data = 0; - int i = 0; - struct ioexp_output_t *tbl = NULL; - struct ioexp_output_t *ioexp = NULL; - struct io_dev_client_t *ioexp_client = NULL; - struct pca95xx_func_t *func = NULL; - - if (io_no_init) { - SFF_IO_LOG_INFO("io no init!"); - return 0; - } - - /*assign ioexp out*/ - for (i = IOEXP_LPMODE_TYPE; i < IOEXP_OUTPUT_TYPE_NUM; i++) { - tbl = dev->output[i]; - if (!p_valid(tbl)) { - if (p_valid(ioexp_output_name[i])) { - SFF_IO_LOG_INFO("%s not supported\n", ioexp_output_name[i]); - } - continue; - } - - for (count = 0; tbl[count].end_of_tbl != true; count++) { - ioexp = &tbl[count]; - if (!p_valid(ioexp_client = ioexp_client_find(dev, ioexp->ch_id, ioexp->addr))) { - return -EBADRQC; - } - - if (!p_valid(func = pca95xx_func_find(dev->config_map, ioexp->ioexp_id))) { - return -EBADRQC; - } - if ((ret = func->read(ioexp_client, func->offset[PCA95XX_OUTPUT])) < 0) { - return ret; - } - - data = ret; - _ioexp_output_config(ioexp, ioexp_out_def_val[i], &data); - if ((ret = func->write(ioexp_client, func->offset[PCA95XX_OUTPUT], data)) < 0) { - return ret; - } - } - } - return 0; -} - -static struct platform_io_info_t *platform_io_info_load(int platform_id) -{ - - int i = 0; - for (i = 0; platform_io_info_tbl[i].platform_id != PLATFORM_END; i++) { - if (platform_io_info_tbl[i].platform_id == platform_id) { - - return &platform_io_info_tbl[i]; - } - - } - return NULL; - -} -static int table_load(int platform_id, struct io_dev_t *io_dev) -{ - struct platform_io_info_t *io_info = NULL; - struct ioexp_dev_t *ioexp_dev = &(io_dev->ioexp_dev); - io_info = platform_io_info_load(platform_id); - if (!io_info) { - return -1; - } - - ioexp_dev->i2c_ch_map = io_info->i2c_ch_map; - ioexp_dev->config_map = io_info->config_map; - ioexp_dev->input_map = io_info->input_map; - ioexp_dev->input_port_num = io_info->input_port_num; - ioexp_dev->output = io_info->output; - io_dev->cpld_io.config = io_info->cpld_config; - io_dev->mux_rst_gpio = io_info->mux_rst_gpio; - io_dev->pltfm_id = platform_id; - - if (p_valid(io_dev->cpld_io.config)) { - io_dev->intr_mode_supported = true; - ioexp_dev->input_hdlr = ioexp_input_intr_hdlr; - } else { - io_dev->intr_mode_supported = false; - ioexp_dev->input_hdlr = ioexp_input_polling; - } - return 0; -} - -struct io_dev_client_t *cpld_client_find(struct cpld_io_t *cpld_io, int ch_id, u8 addr) -{ - struct io_dev_client_t *cpld_client = NULL; - cpld_client = &(cpld_io->cpld_client[ch_id]); - cpld_client->client->addr = addr; - - return cpld_client; -} - -static int cpld_io_intr_gpio_init(int gpio_no) -{ - int result; - /*cpld ioexp int gpio init*/ - result = gpio_is_valid(gpio_no); - if (result < 0) { - SFF_IO_LOG_ERR("valid gpio:%d ret:%d\n", gpio_no, result); - return -1; - } - - return 0; -} -static bool cpld_io_intr_is_asserted(struct cpld_io_t *cpld_io) -{ - int val = 0; - val = gpio_get_value(cpld_io->config->sff_intr_gpio); - return ((val == 0) ? true : false); -} - -static int cpld_io_intr_enable(struct cpld_io_t *cpld_io) -{ - int ret = 0; - int cpld_id = 0; - struct io_dev_client_t *cpld_client = NULL; - u8 offset = 0; - offset = cpld_io->config->intr_en.offset; - cpld_id = cpld_io->config->intr_en.cpld_id; - - if (!p_valid(cpld_client = cpld_client_find(cpld_io, - cpld_io->config->i2c_config[cpld_id].ch_id, - cpld_io->config->i2c_config[cpld_id].addr)) < 0) { - return -EBADRQC; - } - mutex_lock(&cpld_client->lock); - ret = i2c_smbus_write_byte_data_retry(cpld_client->client, offset, 0x01); - mutex_unlock(&cpld_client->lock); - if (ret < 0) { - return ret; - } - - return 0; -} -/*maple platform*/ -static int cpld_io_intr_st_get_type1(struct cpld_io_t *cpld_io, u32 *reg) -{ - int ret = 0; - u32 sfp = 0; - u32 qsfp = 0; - u8 offset = 0; - int cpld_id = 0; - struct io_dev_client_t *cpld_client = NULL; - - offset = cpld_io->config->intr_st.offset; - cpld_id = cpld_io->config->intr_st.cpld_id; - - if (!p_valid(cpld_client = cpld_client_find(cpld_io, - cpld_io->config->i2c_config[cpld_id].ch_id, - cpld_io->config->i2c_config[cpld_id].addr)) < 0) { - return -EBADRQC; - } - mutex_lock(&cpld_client->lock); - ret = i2c_smbus_read_word_data_retry(cpld_client->client, offset); - mutex_unlock(&cpld_client->lock); - if (ret < 0) { - return ret; - } - /*reg remapping to match ioexp_input_map order*/ - /*sfp 0x35 bit 0:7 0x36 bit 0:4 - * qsfp 0x36 bit 7, merge it into one data*/ - sfp = (ret & 0xfff) << 1; - qsfp = (ret & 0x8000) >> 15; - - /*bit = 0: interrupt occurs , reverse it for easy logic*/ - - *reg = (~(sfp|qsfp)) & 0x1fff; - return 0; -} -/*for banyan platform*/ -static int cpld_io_intr_st_get_type2(struct cpld_io_t *cpld_io, u32 *reg) -{ - int ret = 0; - u32 qsfp = 0; - u8 offset = 0; - int cpld_id = 0; - struct io_dev_client_t *cpld_client = NULL; - - offset = cpld_io->config->intr_st.offset; - cpld_id = cpld_io->config->intr_st.cpld_id; - - if (!p_valid(cpld_client = cpld_client_find(cpld_io, - cpld_io->config->i2c_config[cpld_id].ch_id, - cpld_io->config->i2c_config[cpld_id].addr)) < 0) { - return -EBADRQC; - } - mutex_lock(&cpld_client->lock); - ret = i2c_smbus_read_byte_data_retry(cpld_client->client, offset); - mutex_unlock(&cpld_client->lock); - if (ret < 0) { - return ret; - } - /*reg remapping to match ioexp_input_map order*/ - qsfp = (ret & 0xf); - /*bit = 0: interrupt occurs , reverse it for easy logic*/ - *reg = (~qsfp) & 0xf; - return 0; -} -#if 0 -/*cedar platform, check with new cedar HW spec*/ -static int cpld_io_intr_st_get_type3(struct cpld_io_t *cpld_io, u32 *reg) -{ - int ret = 0; - u32 qsfp = 0; - u8 offset = 0; - int cpld_id = 0; - struct io_dev_client_t *cpld_client = NULL; - u16 bit_mask[4] = {0x4, 0x80, 0x400, 0x8000}; - int i = 0; - offset = cpld_io->config->intr_st.offset; - cpld_id = cpld_io->config->intr_st.cpld_id; - - if (!p_valid(cpld_client = cpld_client_find(cpld_io, - cpld_io->config->i2c_config[cpld_id].ch_id, - cpld_io->config->i2c_config[cpld_id].addr)) < 0) { - return -EBADRQC; - } - mutex_lock(&cpld_client->lock); - ret = i2c_smbus_read_word_data_retry(cpld_client->client, offset); - mutex_unlock(&cpld_client->lock); - if (ret < 0) { - return ret; - } - /*reg remapping to match ioexp_input_map order*/ - for (i = 0; i < 4; i++) { - if (!(ret & bit_mask[i])) { - set_bit(i, (unsigned long *)&qsfp); - } - } - *reg = qsfp; - return 0; -} -#endif -static int cpld_io_func_init(struct cpld_io_t *cpld_io) -{ - struct io_dev_t *io_dev = cpld_to_io(cpld_io); - - if (!p_valid(io_dev)) { - return -EBADRQC; - } - if (PLATFORM_MAPLE == io_dev->pltfm_id) { - cpld_io->intr_st_get = cpld_io_intr_st_get_type1; - } else if (PLATFORM_BANYAN == io_dev->pltfm_id) { - cpld_io->intr_st_get = cpld_io_intr_st_get_type2; - } else { - SFF_IO_LOG_ERR("unkown function\n"); - return -EBADRQC; - } - return 0; -} -static int cpld_io_init(struct cpld_io_t *cpld_io) -{ - int ret = 0; - - if ((ret = cpld_io_func_init(cpld_io)) < 0) { - goto exit_err; - } - if ((ret = cpld_io_clients_create(cpld_io)) < 0) { - goto exit_err; - } - if ((ret = cpld_io_i2c_clients_create_init(cpld_io)) < 0) { - goto exit_kfree_clients; - } - if ((ret = cpld_io_intr_gpio_init(cpld_io->config->sff_intr_gpio)) < 0) { - goto exit_kfree_i2c_clients; - } - if ((ret = cpld_io_intr_enable(cpld_io)) < 0) { - goto exit_kfree_i2c_clients; - } - - SFF_IO_LOG_INFO("ok\n"); - return 0; - -exit_kfree_i2c_clients: - cpld_io_i2c_clients_destroy(cpld_io); -exit_kfree_clients: - cpld_io_clients_destroy(cpld_io); -exit_err: - return ret; -} - -static void cpld_io_deinit(struct cpld_io_t *cpld_io) -{ - cpld_io_i2c_clients_destroy(cpld_io); - cpld_io_clients_destroy(cpld_io); - SFF_IO_LOG_INFO("ok\n"); -} - -int io_dev_init(int platform_id, int io_no_init) -{ - int ret = 0; - - if ((ret = table_load(platform_id, &ioDev)) < 0) { - SFF_IO_LOG_ERR("ioexp_table load fail\n"); - goto exit_err; - } - - if ((ret = ioexp_clients_create(&ioDev.ioexp_dev)) < 0) { - SFF_IO_LOG_ERR("ioexp_clients_create fail\n"); - goto exit_err; - } - if ((ret = ioexp_i2c_clients_create(&ioDev.ioexp_dev)) < 0) { - SFF_IO_LOG_ERR("ioexp_i2c_clients_create fail\n"); - goto exit_kfree_clients; - } - if ((ret = ioexp_i2c_clients_init(&ioDev.ioexp_dev)) < 0) { - SFF_IO_LOG_ERR("ioexp_i2c_clients_init fail\n"); - goto exit_kfree_i2c_clients; - } - if (!io_no_init) { - if (ioexp_config_init(&ioDev.ioexp_dev) < 0) { - SFF_IO_LOG_ERR("ioexp_config_init fail\n"); - goto deinit_i2c_clients; - } - } - if (ioexp_input_init(&ioDev.ioexp_dev) < 0) { - SFF_IO_LOG_ERR("ioexp_input_init fail\n"); - goto deinit_i2c_clients; - } - - if (ioexp_output_init(&ioDev.ioexp_dev, io_no_init) < 0) { - SFF_IO_LOG_ERR("ioexp_out_init fail\n"); - goto deinit_i2c_clients; - } - if (ioDev.intr_mode_supported) { - if (cpld_io_init(&ioDev.cpld_io) < 0) { - SFF_IO_LOG_ERR("cpld_io_init fail\n"); - goto deinit_i2c_clients; - } - } - if(io_dev_mux_rst_gpio_init(ioDev.mux_rst_gpio) < 0) { - SFF_IO_LOG_ERR("io_dev_mux_rst_gpio_init fail\n"); - goto deinit_i2c_clients; - } - SFF_IO_LOG_DBG("OK\n"); - return 0; -deinit_i2c_clients: - ioexp_i2c_clients_deinit(&ioDev.ioexp_dev); -exit_kfree_i2c_clients: - ioexp_i2c_clients_destroy(&ioDev.ioexp_dev); -exit_kfree_clients: - ioexp_clients_destroy(&ioDev.ioexp_dev); -exit_err: - return ret; -} - -void io_dev_deinit(void) -{ - ioexp_i2c_clients_deinit(&ioDev.ioexp_dev); - ioexp_i2c_clients_destroy(&ioDev.ioexp_dev); - ioexp_clients_destroy(&ioDev.ioexp_dev); - - if (ioDev.intr_mode_supported) { - cpld_io_deinit(&ioDev.cpld_io); - } - gpio_free(ioDev.mux_rst_gpio); - SFF_IO_LOG_DBG("OK\n"); -} - - - - diff --git a/packages/platforms/inventec/x86-64/d7332/modules/builds/src/io_dev.h b/packages/platforms/inventec/x86-64/d7332/modules/builds/src/io_dev.h deleted file mode 100644 index b2743245c..000000000 --- a/packages/platforms/inventec/x86-64/d7332/modules/builds/src/io_dev.h +++ /dev/null @@ -1,165 +0,0 @@ -#ifndef __IO_DEV_H -#define __IO_DEV_H - -#define IO_RESET_DEFAULT (1) -#define IO_LPMODE_DEFAULT (1) -#define IO_MODESEL_DEFAULT (0) -#define IO_TXDISABLE_DEFAULT (1) -#define LAYOUT_MAX_NUM (16) - -typedef enum { - CPLD_ID_1, - CPLD_ID_2, - CPLD_ID_NUM, -}cpld_id_t; - -typedef enum { - PCA_UNKOWN_TYPE, - PCA9555_TYPE, - PCA9554_TYPE, - PCA95XX_TYPE_NUM, -} pca95xx_type_t; - -typedef enum { - IOEXP_PRS_TYPE, - IOEXP_TXFAULT_TYPE, - IOEXP_RXLOS_TYPE, - IOEXP_INT_TYPE, - IOEXP_TXFAULT2_TYPE, - IOEXP_RXLOS2_TYPE, - IOEXP_INPUT_TYPE_NUM, -} ioexp_input_type_t; - -typedef enum { - IOEXP_LPMODE_TYPE, - IOEXP_RESET_TYPE, - IOEXP_TXDISABLE_TYPE, - IOEXP_MODESEL_TYPE, - IOEXP_TXDISABLE2_TYPE, - IOEXP_OUTPUT_TYPE_NUM, -} ioexp_output_type_t; -/*refactoring begins*/ -struct pin_layout_t { - ioexp_input_type_t type; - int port_min; - int bit_min; - int bit_max; - bool end_of_layout; -}; -struct ioexp_input_t { - int ioexp_id; - int ch_id; - u8 addr; - struct pin_layout_t layout[LAYOUT_MAX_NUM]; -}; - -struct ioexp_input_map_t { - struct ioexp_input_t *tbl; - int size; -}; - -struct ioexp_output_t { - int ioexp_id; - u8 ch_id; - u8 addr; - int port_min; - int bit_min; - int bit_max; /*reprsent the num of ports*/ - bool end_of_tbl; -}; - -struct ldata_format_t { - - unsigned long bitmap; - unsigned long valid; -}; - -struct ioexp_config_t { - int ch_id; - u8 addr; - u16 val; - pca95xx_type_t type; -}; - -struct ioexp_config_map_t { - struct ioexp_config_t *tbl; - int size; -}; - -struct i2c_ch_map_t { - int *tbl; - int size; -}; - -struct io_dev_client_t { - struct i2c_client *client; - struct mutex lock; -}; - -struct ioexp_dev_t { - struct i2c_ch_map_t *i2c_ch_map; - struct ioexp_config_map_t *config_map; - struct ioexp_input_map_t *input_map; - int *input_port_num; - struct ioexp_output_t **output; - struct ldata_format_t input_st[IOEXP_INPUT_TYPE_NUM]; - struct io_dev_client_t *ioexp_client; - int (*input_hdlr)(struct ioexp_dev_t *self); - //int port_num; - //int sfp_port_num; -}; - -struct cpld_i2c_config_t { - int ch_id; - u8 addr; -}; - -struct reg_param_t { - int cpld_id; - u8 offset; -}; - -struct cpld_config_t { - struct cpld_i2c_config_t i2c_config[CPLD_ID_NUM]; - struct i2c_ch_map_t *i2c_ch_map; - struct reg_param_t intr_st; - struct reg_param_t intr_en; - int sff_intr_gpio; -}; - -struct cpld_io_t { - struct cpld_config_t *config; - struct io_dev_client_t *cpld_client; - int (*intr_st_get)(struct cpld_io_t *cpld_io, u32 *reg); -}; - -struct platform_io_info_t { - int platform_id; - struct i2c_ch_map_t *i2c_ch_map; - struct ioexp_config_map_t *config_map; - struct ioexp_input_map_t *input_map; - struct ioexp_output_t **output; -// int port_num; -// int sfp_port_num; - int *input_port_num; - struct cpld_config_t *cpld_config; - int mux_rst_gpio; -}; -struct io_dev_t { - int pltfm_id; - struct ioexp_dev_t ioexp_dev; - bool intr_mode_supported; - struct cpld_io_t cpld_io; - int mux_rst_gpio; -}; - -struct sff_io_driver_t *sff_io_drv_get_iodev(void); - -int io_dev_mux_reset_set(int lc_id, int val); -int io_dev_mux_reset_get(int lc_id, int *val); -bool ioexp_is_channel_ready(int lc_id); -bool ioexp_is_i2c_ready(void); -int io_dev_init(int platform_id, int io_no_init); -void io_dev_deinit(void); -int io_dev_hdlr(void); -#endif /*__IO_DEV_H*/ diff --git a/packages/platforms/inventec/x86-64/d7332/modules/builds/src/lc_dev.c b/packages/platforms/inventec/x86-64/d7332/modules/builds/src/lc_dev.c deleted file mode 100644 index f492dc62c..000000000 --- a/packages/platforms/inventec/x86-64/d7332/modules/builds/src/lc_dev.c +++ /dev/null @@ -1,2870 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "inv_swps.h" -#include "lc_dev.h" - -#define INT_MODE - -extern u32 logLevel; - -static const char *lc_led_str[LC_LED_CTRL_NUM] = { - - [LC_LED_CTRL_GREEN_ON] = "LC_LED_GREEN_ON", - [LC_LED_CTRL_RED_ON] = "LC_LED_RED_ON", -}; -const char *lc_type_name[LC_TYPE_NUM] = -{ - "UNKNOWN_TYPE", - "LC_100G", - "LC_400G", -}; - -enum { - LC_100G_ID = 0x1, - LC_400G_ID, -}; - -#define LC_DEV_LOG_ERR(fmt, args...) \ - do { \ - if (logLevel & DEV_ERR_LEV) \ - { \ - printk (KERN_ERR "[LC_DEV]%s:"fmt,__FUNCTION__, ##args); \ - } \ - } while (0) - -#define LC_DEV_LOG_INFO(fmt, args...) \ - do { \ - if (logLevel & DEV_INFO_LEV) \ - { \ - printk (KERN_INFO "[LC_DEV]%s:"fmt,__FUNCTION__, ##args); \ - } \ - } while (0) - -#define LC_DEV_LOG_DBG(fmt, args...) \ - do { \ - if (logLevel & DEV_DBG_LEV) \ - { \ - printk (KERN_INFO "[LC_DEV]%s:"fmt,__FUNCTION__, ##args); \ - } \ - } while (0) - - - - -#define PHY_NUM_PER_LC (8) -#define PHY_READY_BITMASK ((1L << PHY_NUM_PER_LC) - 1) - -#define CARD_NUM (4) -#define PORT_GROUP_NUM (2) /*per lc_id*/ -#define TMP_DEV_NUM (2) /*per lc_id*/ -#define MUX_L2_NUM (4) /*per lc_id*/ - -#define SFF_DATA_VALID_MASK (0x3uL) - -#define SWITCH_CPLD_ADDR (0x33) -#define CPLD1_ADDR (0x33) -#define CPLD2_ADDR (0x66) -#define IOEXP1_ADDR (0x20) -#define IOEXP2_ADDR (0x21) -#define TMP1_ADDR (0x4a) -#define TMP2_ADDR (0x4d) -/*pca9546*/ -#define MUX_L1_ADDR (0x71) -/*pca9548*/ -#define MUX_L2_ADDR (0x72) -//#define PCA9548_CONTROL_OFFSET (0) - -/*INT gpio*/ -//#define LC_INT_GPIO (12) -#define LC_INT_GPIO (45) -#define LC1_SFF_INT_GPIO (44) -#define LC2_SFF_INT_GPIO (61) -#define LC3_SFF_INT_GPIO (26) -#define LC4_SFF_INT_GPIO (27) - -/*io expander*/ -#define IOEXP_INPUT_OFFSET (0x0) - -/*switch cpld*/ -#define SWITCH_CPLD_LC_ST_INT_OFFSET (0x37) -#define SWITCH_CPLD_LC1_ST_OFFSET (0x38) -#define SWITCH_CPLD_LC2_ST_OFFSET (0x3a) -#define SWITCH_CPLD_LC3_ST_OFFSET (0x3c) -#define SWITCH_CPLD_LC4_ST_OFFSET (0x3e) - -#define SWITCH_CPLD_LC_TEMP_INT_N_BIT (6) -#define SWITCH_CPLD_LC_PRS_INT_N_BIT (3) -#define SWITCH_CPLD_LC_MUX_INT_N_BIT (2) -#define SWITCH_CPLD_LC_EJ_L_N_BIT (1) -#define SWITCH_CPLD_LC_EJ_R_N_BIT (0) - -#define SWITCH_CPLD_LC1_CTRL_OFFSET (0x39) -#define SWITCH_CPLD_LC2_CTRL_OFFSET (0x3b) -#define SWITCH_CPLD_LC3_CTRL_OFFSET (0x3d) -#define SWITCH_CPLD_LC4_CTRL_OFFSET (0x3f) -#define SWITCH_CPLD_INTR_ST_OFFSET (0x44) -#define SWITCH_CPLD_INTR_EN_OFFSET (0x45) - -#define SWICH_CPLD_LC_PWR_CONTROL_BIT (1) -#define SWICH_CPLD_LC_CPU_PLTRST_N_BIT (0) - -/*line lc_id cpld reg offset*/ -#define PCB_VER_OFFSET (0x0) -#define LC_ID_BIT_S (4) -#define LC_ID_BIT_NUM (4) - -#define I2C_MUX_RST_OFFSET (0x0b) - -#define RST_PCA9548_D_OFFSET (0x0b) - -#define RST_PCA9548_1_N_BIT (0) -#define RST_PCA9548_2_N_BIT (1) -#define RST_PCA9548_3_N_BIT (2) -#define RST_PCA9548_4_N_BIT (3) -#define RST_PCA9546_N_BIT (4) - -#define LC_CPLD_PHY_RST_OFFSET (0x0a) -#define LC_CPLD_LED_DIAG_OFFSET (0xf) -#define LC_CPLD_LED_BOOT_AMBER_BIT (0) -#define LC_CPLD_SFF_RESET_OFFSET (0x12) -#define LC_CPLD_SFF_INT_OFFSET (0x14) -#define LC_CPLD_SFF_PRS_OFFSET (0x16) -#define LC_CPLD_SFF_LPMODE_OFFSET (0x18) -#define LC_CPLD_SFF_POWER_OFFSET (0x1f) -#define LC_CPLD_SFF_OC_OFFSET (0x21) - -#define LC_ST_LED_OFFSET (0x0d) - -/*lc power status check*/ -#define LC_CPLD_DC_DC_ST1_OFFSET (0x1d) -#define LC_CPLD_DC_DC_ST2_OFFSET (0x1e) - -/*cpld1 lc power control*/ -#define LC_CPLD_MISC_CONTROL1_OFFSET (0x27) -#define LC_CPLD_UCD_PMBUS_CNTRL_R_BIT (3) - -#define LC_CPLD_MISC_CONTROL2_OFFSET (0x28) -#define LC_CPLD_LC1_PWR_CONTROL_BIT (1) - -/*cpld transceiver interrupt*/ -#define LC_CPLD_SFF_INT_ST_OFFSET (0x2a) -#define LC_CPLD_SFF_INT_CPLD2_PRS_BIT (0) -#define LC_CPLD_SFF_INT_CPLD2_INT_BIT (1) -#define LC_CPLD_SFF_INT_CPLD2_OC_BIT (2) -#define LC_CPLD_SFF_INT_RESERVED1 (3) -#define LC_CPLD_SFF_INT_CPLD1_PRS_BIT (4) -#define LC_CPLD_SFF_INT_CPLD1_INT_BIT (5) -#define LC_CPLD_SFF_INT_CPLD1_OC_BIT (6) -#define LC_CPLD_SFF_INT_RESERVED2 (7) -#define LC_CPLD_SFF_INT_NUM (8) -/*cpld clear sff prs interrupt status*/ -#define LC_CPLD_SFF_PRS_INT_CLEAR_OFFSET (0x2d) - - -#define PORT_IDX_NUM (16) -#define U16_MASK (((1 << PORT_IDX_NUM) - 1)) -/*for register <= 32 bits*/ -#define inv_set_bit(bit, reg) ((reg) | (1 << bit)) -#define inv_clear_bit(bit, reg) ((reg) & (~(1 << bit))) - -/*side band signaling output default value*/ -#define LC_CPLD_DEF_RESET_VAL ((1 << PORT_IDX_NUM) - 1) -#define LC_CPLD_DEF_LPMODE_VAL ((1 << PORT_IDX_NUM) - 1) -#define LC_CPLD_DEF_POWER_VAL ((1 << PORT_IDX_NUM) - 1) - -typedef enum { - LC_SWITCH_CH_ID, - LC1_SFF_CH_ID, - LC2_SFF_CH_ID, - LC3_SFF_CH_ID, - LC4_SFF_CH_ID, - LC1_TMP_CH_ID, - LC2_TMP_CH_ID, - LC3_TMP_CH_ID, - LC4_TMP_CH_ID, - LC1_MUX_L1_CH_ID, - LC1_MUX_L2_1_CH_ID, - LC1_MUX_L2_2_CH_ID, - LC1_MUX_L2_3_CH_ID, - LC1_MUX_L2_4_CH_ID, - LC2_MUX_L1_CH_ID, - LC2_MUX_L2_1_CH_ID, - LC2_MUX_L2_2_CH_ID, - LC2_MUX_L2_3_CH_ID, - LC2_MUX_L2_4_CH_ID, - LC3_MUX_L1_CH_ID, - LC3_MUX_L2_1_CH_ID, - LC3_MUX_L2_2_CH_ID, - LC3_MUX_L2_3_CH_ID, - LC3_MUX_L2_4_CH_ID, - LC4_MUX_L1_CH_ID, - LC4_MUX_L2_1_CH_ID, - LC4_MUX_L2_2_CH_ID, - LC4_MUX_L2_3_CH_ID, - LC4_MUX_L2_4_CH_ID, - LC_CH_ID_NUM, -} lc_ch_id_t; - -int lcChTbl[LC_CH_ID_NUM] = { - [LC_SWITCH_CH_ID] = 41, - [LC1_SFF_CH_ID] = 6, - [LC2_SFF_CH_ID] = 7, - [LC3_SFF_CH_ID] = 8, - [LC4_SFF_CH_ID] = 9, - [LC1_TMP_CH_ID] = 50, - [LC2_TMP_CH_ID] = 51, - [LC3_TMP_CH_ID] = 52, - [LC4_TMP_CH_ID] = 53, - [LC1_MUX_L1_CH_ID] = 81, - [LC1_MUX_L2_1_CH_ID] = 85, - [LC1_MUX_L2_2_CH_ID] = 86, - [LC1_MUX_L2_3_CH_ID] = 87, - [LC1_MUX_L2_4_CH_ID] = 88, - [LC2_MUX_L1_CH_ID] = 82, - [LC2_MUX_L2_1_CH_ID] = 89, - [LC2_MUX_L2_2_CH_ID] = 90, - [LC2_MUX_L2_3_CH_ID] = 91, - [LC2_MUX_L2_4_CH_ID] = 92, - [LC3_MUX_L1_CH_ID] = 83, - [LC3_MUX_L2_1_CH_ID] = 93, - [LC3_MUX_L2_2_CH_ID] = 94, - [LC3_MUX_L2_3_CH_ID] = 95, - [LC3_MUX_L2_4_CH_ID] = 96, - [LC4_MUX_L1_CH_ID] = 84, - [LC4_MUX_L2_1_CH_ID] = 97, - [LC4_MUX_L2_2_CH_ID] = 98, - [LC4_MUX_L2_3_CH_ID] = 99, - [LC4_MUX_L2_4_CH_ID] = 100, -}; -#define LM75_REG_TEMP (0x00) -#define LM75_REG_CONF (0x01) -#define LM75_REG_LOW (0x02) -#define LM75_REG_HIGH (0x03) -#define LM75_RESOLUTION (9) - -#define TEMP_CHECK_NUM (5) - -typedef enum { - TEMP_UNKNOWN, - TEMP_INPUT, - TEMP_TH_L, - TEMP_TH_H, -} temp_conf_type_t; - -struct lc_client_t { - - struct mutex lock; - struct i2c_client *client; -}; - -struct lc_config_t { - int lc_ch_id; - u8 addr; -}; - -typedef union { - - u16 reg[4]; - unsigned long data; -} u64_format_t; - -struct io_data_t { - - u32 buf; - u8 valid; -}; -typedef enum { - LC_ST_PRS_TYPE, - LC_ST_OVER_TEMP_TYPE, - LC_ST_EJ_R_TYPE, - LC_ST_EJ_L_TYPE, - LC_ST_TYPE_NUM, - -} lc_st_type_t; -static const char *lc_st_name[LC_ST_TYPE_NUM] = { - [LC_ST_PRS_TYPE] = "LC_ST_PRS_TYPE", - [LC_ST_OVER_TEMP_TYPE] = "LC_ST_OVER_TEMP_TYPE", - [LC_ST_EJ_R_TYPE] = "LC_ST_EJ_R_TYPE", - [LC_ST_EJ_L_TYPE] = "LC_ST_EJ_L_TYPE", -}; -typedef enum { - SFF_PRS_TYPE, - SFF_INT_TYPE, - SFF_OC_TYPE, - SFF_INPUT_TYPE_NUM, - -} sff_input_type_t; - -const char *sff_input_name[SFF_INPUT_TYPE_NUM] = { - "SFF_PRS_TYPE", - "SFF_INT_TYPE", - "SFF_OC_TYPE", -}; -typedef enum { - SFF_LPMODE_TYPE, - SFF_RESET_TYPE, - SFF_POWER_TYPE, - SFF_OUTPUT_TYPE_NUM, - -} lc_sff_output_type_t; -const char *lc_sff_output_name[SFF_OUTPUT_TYPE_NUM] = { - "SFF_LPMODE_TYPE", - "SFF_RESET_TYPE", - "SFF_POWER_TYPE", -}; - -u8 lc_sff_input_reg[SFF_INPUT_TYPE_NUM] = { - [SFF_PRS_TYPE] = LC_CPLD_SFF_PRS_OFFSET,/*use ioexp for temp not PRS_OFFSET,*/ - [SFF_INT_TYPE] = LC_CPLD_SFF_INT_OFFSET, - [SFF_OC_TYPE] = LC_CPLD_SFF_OC_OFFSET -}; -u8 lc_sff_output_reg[SFF_OUTPUT_TYPE_NUM] = { - [SFF_LPMODE_TYPE] = LC_CPLD_SFF_LPMODE_OFFSET, - [SFF_RESET_TYPE] = LC_CPLD_SFF_RESET_OFFSET, - [SFF_POWER_TYPE] = LC_CPLD_SFF_POWER_OFFSET, -}; -u16 lc_sff_output_def[SFF_OUTPUT_TYPE_NUM] = { - [SFF_LPMODE_TYPE] = LC_CPLD_DEF_LPMODE_VAL, - [SFF_RESET_TYPE] = LC_CPLD_DEF_RESET_VAL, - [SFF_POWER_TYPE] = LC_CPLD_DEF_POWER_VAL, -}; -u8 lc_st_reg[CARD_NUM] = { - SWITCH_CPLD_LC1_ST_OFFSET, - SWITCH_CPLD_LC2_ST_OFFSET, - SWITCH_CPLD_LC3_ST_OFFSET, - SWITCH_CPLD_LC4_ST_OFFSET -}; -u8 lc_control_reg[CARD_NUM] = { - SWITCH_CPLD_LC1_CTRL_OFFSET, - SWITCH_CPLD_LC2_CTRL_OFFSET, - SWITCH_CPLD_LC3_CTRL_OFFSET, - SWITCH_CPLD_LC4_CTRL_OFFSET, -}; -int lc_st_bit[LC_ST_TYPE_NUM] = { - [LC_ST_PRS_TYPE] = SWITCH_CPLD_LC_PRS_INT_N_BIT, - [LC_ST_OVER_TEMP_TYPE] = SWITCH_CPLD_LC_TEMP_INT_N_BIT, - [LC_ST_EJ_R_TYPE] = SWITCH_CPLD_LC_EJ_R_N_BIT, - [LC_ST_EJ_L_TYPE] = SWITCH_CPLD_LC_EJ_L_N_BIT, -}; - -const int rst_mux_l2_bit[MUX_L2_NUM] = { - RST_PCA9548_1_N_BIT, - RST_PCA9548_2_N_BIT, - RST_PCA9548_3_N_BIT, - RST_PCA9548_4_N_BIT, -}; -enum { - - CPLD1_ID = 0, - CPLD2_ID -}; - -struct lc_dev_obj_t { - struct lc_config_t cpld[PORT_GROUP_NUM]; - struct lc_config_t ioexp[PORT_GROUP_NUM]; - struct lc_config_t tmp_dev[TMP_DEV_NUM]; - struct lc_config_t mux_l1; - struct lc_config_t mux_l2[MUX_L2_NUM]; - struct io_data_t input[SFF_INPUT_TYPE_NUM]; - int sff_intr_gpio; -}; -#if 0 -struct ldata_format_t { - unsigned long bitmap; - bool valid; -}; -#endif -struct lc_dev_t { - struct lc_config_t switch_cpld; - struct lc_client_t lc_client[LC_CH_ID_NUM]; - struct lc_dev_obj_t obj[CARD_NUM]; - int lc_intr_gpio; - struct ldata_format_t lc_st[LC_ST_TYPE_NUM]; - int lc_id_num; -}; -struct lc_dev_t lcDev; -struct i2c_client *lcI2cClient = NULL; - -/**/ -struct lc_config_t switch_cpld_config = { - .lc_ch_id = LC_SWITCH_CH_ID, - .addr = SWITCH_CPLD_ADDR, -}; -const struct lc_config_t cpld_config_tbl[CARD_NUM][PORT_GROUP_NUM] = { - - [0] = { - { .lc_ch_id = LC1_SFF_CH_ID, .addr = CPLD1_ADDR}, - { .lc_ch_id = LC1_SFF_CH_ID, .addr = CPLD2_ADDR}, - }, - [1] = { - { .lc_ch_id = LC2_SFF_CH_ID, .addr = CPLD1_ADDR}, - { .lc_ch_id = LC2_SFF_CH_ID, .addr = CPLD2_ADDR}, - }, - [2] = { - { .lc_ch_id = LC3_SFF_CH_ID, .addr = CPLD1_ADDR}, - { .lc_ch_id = LC3_SFF_CH_ID, .addr = CPLD2_ADDR}, - }, - [3] = { - { .lc_ch_id = LC4_SFF_CH_ID, .addr = CPLD1_ADDR}, - { .lc_ch_id = LC4_SFF_CH_ID, .addr = CPLD2_ADDR}, - }, - -}; -const struct lc_config_t ioexp_config_tbl[CARD_NUM][PORT_GROUP_NUM] = { - - [0] = { - { .lc_ch_id = LC1_SFF_CH_ID, .addr = IOEXP1_ADDR}, - { .lc_ch_id = LC1_SFF_CH_ID, .addr = IOEXP2_ADDR}, - }, - [1] = { - { .lc_ch_id = LC2_SFF_CH_ID, .addr = IOEXP1_ADDR}, - { .lc_ch_id = LC2_SFF_CH_ID, .addr = IOEXP2_ADDR}, - }, - [2] = { - { .lc_ch_id = LC3_SFF_CH_ID, .addr = IOEXP1_ADDR}, - { .lc_ch_id = LC3_SFF_CH_ID, .addr = IOEXP2_ADDR}, - }, - [3] = { - { .lc_ch_id = LC4_SFF_CH_ID, .addr = IOEXP1_ADDR}, - { .lc_ch_id = LC4_SFF_CH_ID, .addr = IOEXP2_ADDR}, - }, - -}; -const struct lc_config_t tmp_dev_config_tbl[CARD_NUM][TMP_DEV_NUM] = { - - [0] = { - { .lc_ch_id = LC1_TMP_CH_ID, .addr = TMP1_ADDR}, - { .lc_ch_id = LC1_TMP_CH_ID, .addr = TMP2_ADDR}, - }, - [1] = { - { .lc_ch_id = LC2_TMP_CH_ID, .addr = TMP1_ADDR}, - { .lc_ch_id = LC2_TMP_CH_ID, .addr = TMP2_ADDR}, - }, - [2] = { - { .lc_ch_id = LC3_TMP_CH_ID, .addr = TMP1_ADDR}, - { .lc_ch_id = LC3_TMP_CH_ID, .addr = TMP2_ADDR}, - }, - [3] = { - { .lc_ch_id = LC4_TMP_CH_ID, .addr = TMP1_ADDR}, - { .lc_ch_id = LC4_TMP_CH_ID, .addr = TMP2_ADDR}, - }, -}; -const struct lc_config_t mux_l1_config_tbl[CARD_NUM] = { - - [0] = { - .lc_ch_id = LC1_MUX_L1_CH_ID, .addr = MUX_L1_ADDR, - }, - [1] = { - .lc_ch_id = LC2_MUX_L1_CH_ID, .addr = MUX_L1_ADDR, - }, - [2] = { - .lc_ch_id = LC3_MUX_L1_CH_ID, .addr = MUX_L1_ADDR, - }, - [3] = { - .lc_ch_id = LC4_MUX_L1_CH_ID, .addr = MUX_L1_ADDR, - }, -}; -const struct lc_config_t mux_l2_config_tbl[CARD_NUM][MUX_L2_NUM] = { - - [0] = { - {.lc_ch_id = LC1_MUX_L2_1_CH_ID, .addr = MUX_L2_ADDR}, - {.lc_ch_id = LC1_MUX_L2_2_CH_ID, .addr = MUX_L2_ADDR}, - {.lc_ch_id = LC1_MUX_L2_3_CH_ID, .addr = MUX_L2_ADDR}, - {.lc_ch_id = LC1_MUX_L2_3_CH_ID, .addr = MUX_L2_ADDR}, - }, - [1] = { - {.lc_ch_id = LC2_MUX_L2_1_CH_ID, .addr = MUX_L2_ADDR}, - {.lc_ch_id = LC2_MUX_L2_2_CH_ID, .addr = MUX_L2_ADDR}, - {.lc_ch_id = LC2_MUX_L2_3_CH_ID, .addr = MUX_L2_ADDR}, - {.lc_ch_id = LC2_MUX_L2_3_CH_ID, .addr = MUX_L2_ADDR}, - }, - [2] = { - {.lc_ch_id = LC3_MUX_L2_1_CH_ID, .addr = MUX_L2_ADDR}, - {.lc_ch_id = LC3_MUX_L2_2_CH_ID, .addr = MUX_L2_ADDR}, - {.lc_ch_id = LC3_MUX_L2_3_CH_ID, .addr = MUX_L2_ADDR}, - {.lc_ch_id = LC3_MUX_L2_3_CH_ID, .addr = MUX_L2_ADDR}, - }, - [3] = { - {.lc_ch_id = LC4_MUX_L2_1_CH_ID, .addr = MUX_L2_ADDR}, - {.lc_ch_id = LC4_MUX_L2_2_CH_ID, .addr = MUX_L2_ADDR}, - {.lc_ch_id = LC4_MUX_L2_3_CH_ID, .addr = MUX_L2_ADDR}, - {.lc_ch_id = LC4_MUX_L2_3_CH_ID, .addr = MUX_L2_ADDR}, - }, -}; -const int sff_intr_gpio[CARD_NUM] = { - LC1_SFF_INT_GPIO, - LC2_SFF_INT_GPIO, - LC3_SFF_INT_GPIO, - LC4_SFF_INT_GPIO, -}; -#if 0 -/*function declaration*/ -int lc_dev_lc_cpld_init(int lc_id); -int lc_dev_power_set(int lc_id, bool on); -int lc_dev_power_ready(int lc_id, bool *ready); -void lc_dev_phy_ready(unsigned long bitmap, bool *ready); -int lc_dev_prs_get(unsigned long *bitmap); -int lc_dev_overtemp_get(unsigned long *bitmap); -int lc_dev_temp_get(int lc_id, char *buf, int size); -int lc_dev_reset_set(int lc_id, u8 lv); -int lc_dev_reset_get(int lc_id, u8 *lv); -int lc_dev_type_get(int lc_id, lc_type_t *type); -int lc_dev_type_get_text(int lc_id, u8 *buf, int size); -int lc_dev_mux_l1_reset(int lc_id, u8 lv); -int lc_dev_mux_l2_reset(int lc_id, int mux_l2_id, u8 lv); -int lc_dev_led_set(int lc_id, lc_led_ctrl_t ctrl); -int lc_dev_led_st_get(int lc_id, lc_led_ctrl_t *ctrl); -int lc_dev_port_led_set(int lc_id, unsigned long bitmap); -int lc_dev_port_led_get(int lc_id, unsigned long *bitmap); -int lc_dev_init(void); -void lc_dev_deinit(void); -int lc_dev_hdlr(void); -struct sff_io_driver_t *sff_io_drv_get_lcdev(void); -#endif -/*private function*/ -static int lc_dev_intr_enable(bool on); -static int lc_dev_intr_st_update(void); -static int lc_dev_intr_st_clear(void); -static int lc_sff_lpmode_get(int lc_id, int port, u8 *val); -static int lc_sff_lpmode_set(int lc_id, int port, u8 val); -static int lc_sff_reset_get(int lc_id, int port, u8 *val); -static int lc_sff_reset_set(int lc_id, int port, u8 val); -static int lc_sff_power_get(int lc_id, int port, u8 *val); -static int lc_sff_power_set(int lc_id, int port, u8 val); -static int lc_sff_output_bitmap_set(lc_sff_output_type_t type, int lc_id, int port_grp, u16 val); -static int lc_sff_prs_get(int lc_id, unsigned long *bitmap); -static int lc_sff_intr_get(int lc_id, unsigned long *bitmap); -static int lc_sff_oc_get(int lc_id, unsigned long *bitmap); -static int lc_sff_lpmode_all_set(int lc_id, unsigned long bitmap); -static int lc_sff_lpmode_all_get(int lc_id, unsigned long *bitmap); -static int lc_sff_reset_all_set(int lc_id, unsigned long bitmap); -static int lc_sff_reset_all_get(int lc_id, unsigned long *bitmap); -static int lc_sff_power_all_set(int lc_id, unsigned long bitmap); -static int lc_sff_power_all_get(int lc_id, unsigned long *bitmap); - -static int lc_sff_prs_update_byGroup(int lc_id, int port_grp); -static int lc_sff_intr_update_byGroup(int lc_id, int port_grp); -static int lc_sff_oc_update_byGroup(int lc_id, int port_grp); -static int lc_sff_prs_update_1stGroup(int lc_id); -static int lc_sff_prs_update_2ndGroup(int lc_id); -static int lc_sff_intr_update_1stGroup(int lc_id); -static int lc_sff_intr_update_2ndGroup(int lc_id); -static int lc_sff_oc_update_1stGroup(int lc_id); -static int lc_sff_oc_update_2ndGroup(int lc_id); - -static int lc_dummy_rx_los_get(int lc_id, unsigned long *bitmap); -static int lc_dummy_tx_fault_get(int lc_id, unsigned long *bitmap); -static int lc_dummy_tx_disable_get(int lc_id, int port, u8 *val); -static int lc_dummy_tx_disable_set(int lc_id, int port, u8 val); -static int lc_dummy_mode_sel_get(int lc_id, int port, u8 *val); -static int lc_dummy_mode_sel_set(int lc_id, int port, u8 val); - -struct sff_io_driver_t lcDevSffIoDrv = { - .prs_all_get = lc_sff_prs_get, - .intr_all_get = lc_sff_intr_get, - .oc_all_get = lc_sff_oc_get, - .rx_los_all_get = lc_dummy_rx_los_get, - .tx_fault_all_get = lc_dummy_tx_fault_get, - .reset_set = lc_sff_reset_set, - .reset_get = lc_sff_reset_get, - .reset_all_set = lc_sff_reset_all_set, - .reset_all_get = lc_sff_reset_all_get, - .power_set = lc_sff_power_set, - .power_get = lc_sff_power_get, - .power_all_set = lc_sff_power_all_set, - .power_all_get = lc_sff_power_all_get, - .lpmode_set = lc_sff_lpmode_set, - .lpmode_get = lc_sff_lpmode_get, - .lpmode_all_set = lc_sff_lpmode_all_set, - .lpmode_all_get = lc_sff_lpmode_all_get, - .tx_disable_set = lc_dummy_tx_disable_set, - .tx_disable_get = lc_dummy_tx_disable_get, - .mode_sel_set = lc_dummy_mode_sel_set, - .mode_sel_get = lc_dummy_mode_sel_get, - -}; - -int (*sff_intr_funcs[LC_CPLD_SFF_INT_NUM])(int lc_id) = { - - [LC_CPLD_SFF_INT_CPLD2_PRS_BIT] = lc_sff_prs_update_2ndGroup, - [LC_CPLD_SFF_INT_CPLD2_INT_BIT] = lc_sff_intr_update_2ndGroup, - [LC_CPLD_SFF_INT_CPLD2_OC_BIT] = lc_sff_oc_update_2ndGroup, - [LC_CPLD_SFF_INT_RESERVED1] = NULL, - [LC_CPLD_SFF_INT_CPLD1_PRS_BIT] = lc_sff_prs_update_1stGroup, - [LC_CPLD_SFF_INT_CPLD1_INT_BIT] = lc_sff_intr_update_1stGroup, - [LC_CPLD_SFF_INT_CPLD1_OC_BIT] = lc_sff_oc_update_1stGroup, - [LC_CPLD_SFF_INT_RESERVED2] = NULL, -}; - -struct sff_io_driver_t *sff_io_drv_get_lcdev(void) -{ - return &lcDevSffIoDrv; -} -static bool port_idx_valid(int idx) -{ - if (idx < PORT_IDX_NUM && idx >= 0) { - return true; - } else { - LC_DEV_LOG_ERR("invalid port_idx:%d\n", idx); - return false; - } -} -static bool grp_valid(int port_grp) -{ - if (port_grp < PORT_GROUP_NUM && port_grp >= 0) { - return true; - } else { - LC_DEV_LOG_ERR("invalid port_grp:%d\n", port_grp); - return false; - } -} -static bool lc_id_valid(int lc_id) -{ - if (lc_id < CARD_NUM && lc_id >= 0) { - return true; - } else { - LC_DEV_LOG_ERR("invalid lc_id:%d\n", lc_id); - return false; - } -} - -static void config_load(void) -{ - int lc_id = 0; - int port_grp = 0; - int tmp_dev = 0; - int mux_l2_i = 0; - - memcpy(&(lcDev.switch_cpld), &switch_cpld_config, sizeof(struct lc_config_t)); - lcDev.lc_intr_gpio = LC_INT_GPIO; - for (lc_id = 0; lc_id < CARD_NUM; lc_id++) { - - lcDev.obj[lc_id].sff_intr_gpio = sff_intr_gpio[lc_id]; - - for (port_grp = 0; port_grp < PORT_GROUP_NUM; port_grp++) { - - memcpy(&lcDev.obj[lc_id].cpld[port_grp], &cpld_config_tbl[lc_id][port_grp], sizeof(struct lc_config_t)); - memcpy(&lcDev.obj[lc_id].ioexp[port_grp], &ioexp_config_tbl[lc_id][port_grp], sizeof(struct lc_config_t)); - } - for (tmp_dev = 0; tmp_dev < TMP_DEV_NUM; tmp_dev++) { - memcpy(&lcDev.obj[lc_id].tmp_dev[tmp_dev], &tmp_dev_config_tbl[lc_id][tmp_dev], sizeof(struct lc_config_t)); - } - /*mux config*/ - memcpy(&lcDev.obj[lc_id].mux_l1, &mux_l1_config_tbl[lc_id], sizeof(struct lc_config_t)); - for (mux_l2_i = 0; mux_l2_i < MUX_L2_NUM; mux_l2_i++) { - memcpy(&lcDev.obj[lc_id].mux_l2[mux_l2_i], &mux_l2_config_tbl[lc_id][mux_l2_i], sizeof(struct lc_config_t)); - } - } -} -int lc_i2c_client_init(int lc_ch, struct i2c_client **client) -{ - struct i2c_adapter *adap = NULL; - - if (!p_valid(*client)) { - return -EBADRQC; - } - adap = i2c_get_adapter(lc_ch); - if (!p_valid(adap)) { - LC_DEV_LOG_ERR("get adapter fail ch:%d\n", lc_ch); - return -EBADRQC; - } - - LC_DEV_LOG_DBG("get adapter ok ch:%d\n", lc_ch); - (*client)->adapter = adap; - - return 0; - -} -static void lc_i2c_client_deinit_all(struct lc_dev_t *self) -{ - struct i2c_client *client = NULL; - int id = 0; - if (!self) { - return; - } - - for (id = 0; id < LC_CH_ID_NUM; id++) { - client = self->lc_client[id].client; - if (p_valid(client)) { - if (p_valid(client->adapter)) { - i2c_put_adapter(client->adapter); - LC_DEV_LOG_DBG("put_adapter:%d\n", id); - } - } - } -} -void lc_i2c_clients_destroy(struct lc_dev_t *self) -{ - int lc_ch_id = 0; - - if (p_valid(lcI2cClient)) { - kfree(lcI2cClient); - } - for (lc_ch_id = 0; lc_ch_id < LC_CH_ID_NUM; lc_ch_id++) { - - self->lc_client[lc_ch_id].client = NULL; - } -} -int lc_i2c_clients_create(struct lc_dev_t *self) -{ - int lc_ch_id = 0; - struct i2c_client *client = NULL; - - - client = kzalloc(sizeof(struct i2c_client)*LC_CH_ID_NUM, GFP_KERNEL); - if (!p_valid(client)) { - return -EBADRQC; - } - lcI2cClient = client; - /*build a link*/ - for (lc_ch_id = 0; lc_ch_id < LC_CH_ID_NUM; lc_ch_id++) { - - self->lc_client[lc_ch_id].client = &lcI2cClient[lc_ch_id]; - } - return 0; -} -int lc_i2c_client_init_all(struct lc_dev_t *self) -{ - int lc_ch_id = 0; - struct lc_client_t *lc_client = NULL; - int ret = 0; - - for (lc_ch_id = 0; lc_ch_id < LC_CH_ID_NUM; lc_ch_id++) { - - lc_client = &(self->lc_client[lc_ch_id]); - if ((ret = lc_i2c_client_init(lcChTbl[lc_ch_id], &(lc_client->client))) < 0) { - break; - } - mutex_init(&(lc_client->lock)); - - } - if (ret < 0) { - lc_i2c_client_deinit_all(self); - return ret; - } - - return 0; -} -static bool ch_id_valid(int id) -{ - return ((id >= 0 && id < LC_CH_ID_NUM) ? true : false); -} -struct lc_client_t *lc_client_find(struct lc_config_t *config) -{ - struct lc_client_t *lc_client = NULL; - int lc_ch_id = 0; - u8 addr = 0; - if (!config) { - return NULL; - } - lc_ch_id = config->lc_ch_id; - addr = config->addr; - - if (!ch_id_valid(lc_ch_id)) { - LC_DEV_LOG_ERR("cant find lc_ch_id:%d\n", lc_ch_id); - return NULL; - } - - lc_client = &(lcDev.lc_client[lc_ch_id]); - if (!p_valid(lc_client)) { - LC_DEV_LOG_ERR("NULL lc_client lc_ch_id:%d\n", lc_ch_id); - return NULL; - } - - if (!p_valid(lc_client->client)) { - LC_DEV_LOG_ERR("NULL lc_client lc_ch_id:%d\n", lc_ch_id); - return NULL; - } - lc_client->client->addr = addr; - - //LC_DEV_LOG_DBG("lc_ch_id:%d addr: 0x%x\n", lc_ch_id, addr); - return lc_client; -} - -static int lc_i2c_smbus_write_byte_data(struct lc_client_t *lc_client, u8 offset, u8 buf) -{ - int ret = 0; - - if (!lc_client) { - return -EINVAL; - } - - mutex_lock(&lc_client->lock); - ret = i2c_smbus_write_byte_data_retry(lc_client->client, offset, buf); - mutex_unlock(&lc_client->lock); - - return ret; -} -int lc_i2c_smbus_read_byte_data(struct lc_client_t *lc_client, u8 offset) -{ - int ret = 0; - - if (!lc_client) { - return -EINVAL; - } - - mutex_lock(&lc_client->lock); - ret = i2c_smbus_read_byte_data_retry(lc_client->client, offset); - mutex_unlock(&lc_client->lock); - - return ret; -} -int lc_i2c_smbus_read_byte(struct lc_client_t *lc_client) -{ - int ret = 0; - - if (!lc_client) { - return -EINVAL; - } - - mutex_lock(&lc_client->lock); - ret = i2c_smbus_read_byte(lc_client->client); - mutex_unlock(&lc_client->lock); - - return ret; -} - -int lc_i2c_smbus_read_word_data(struct lc_client_t *lc_client, u8 offset) -{ - int ret = 0; - - if (!lc_client) { - return -EINVAL; - } - - mutex_lock(&lc_client->lock); - ret = i2c_smbus_read_word_data_retry(lc_client->client, offset); - mutex_unlock(&lc_client->lock); - - return ret; -} - -int lc_i2c_smbus_write_word_data(struct lc_client_t *lc_client, u8 offset, u16 data) -{ - int ret = 0; - - if (!lc_client) { - return -EINVAL; - } - - mutex_lock(&lc_client->lock); - ret = i2c_smbus_write_word_data_retry(lc_client->client, offset, data); - mutex_unlock(&lc_client->lock); - - return ret; -} - -/* description: get lc object instance - * - * input: - * lc_id: lc id number - *return: - 0: success - * */ -inline struct lc_dev_obj_t *lc_obj_get(int lc_id) -{ - if (!lc_id_valid(lc_id)) { - LC_DEV_LOG_ERR("fail to get lc obj:%d\n", lc_id); - return NULL; - } - return &(lcDev.obj[lc_id]); -} -int lc_sff_input_get(sff_input_type_t type, int lc_id, unsigned long *bitmap) -{ - struct lc_dev_obj_t *obj = NULL; - - if (!bitmap) { - return -EINVAL; - } - - if (!lc_id_valid(lc_id)) { - return -EINVAL; - } - - if (!(obj = lc_obj_get(lc_id))) { - return -EBADRQC; - } - - if (SFF_DATA_VALID_MASK != obj->input[type].valid) { - return -EBADRQC; - } - - *bitmap = (unsigned long)(obj->input[type].buf); - //LC_DEV_LOG_DBG("lc_id:%d %s: %lx\n", lc_id, sff_input_name[type], *bitmap); - return 0; -} -static int lc_dummy_rx_los_get(int lc_id, unsigned long *bitmap) -{ - return -ENOSYS; -} -static int lc_dummy_tx_fault_get(int lc_id, unsigned long *bitmap) -{ - return -ENOSYS; -} - -static int lc_dummy_tx_disable_get(int lc_id, int port, u8 *val) -{ - return -ENOSYS; -} - -static int lc_dummy_tx_disable_set(int lc_id, int port, u8 val) -{ - return -ENOSYS; -} - -static int lc_dummy_mode_sel_get(int lc_id, int port, u8 *val) -{ - return -ENOSYS; -} - -static int lc_dummy_mode_sel_set(int lc_id, int port, u8 val) -{ - return -ENOSYS; -} - -static int lc_sff_prs_get(int lc_id, unsigned long *bitmap) -{ - int ret = 0; - unsigned long tmp = 0; - - if (!bitmap) { - return -EINVAL; - } - if ((ret = lc_sff_input_get(SFF_PRS_TYPE, lc_id, &tmp)) < 0) { - return ret; - } - - *bitmap = tmp; - return 0; -} -static int lc_sff_oc_get(int lc_id, unsigned long *bitmap) -{ - int ret = 0; - unsigned long tmp = 0; - - if (!bitmap) { - return -EINVAL; - } - if ((ret = lc_sff_input_get(SFF_OC_TYPE, lc_id, &tmp)) < 0) { - return ret; - } - - *bitmap = tmp; - return 0; - -} -static int lc_sff_intr_get(int lc_id, unsigned long *bitmap) -{ - return lc_sff_input_get(SFF_INT_TYPE, lc_id, bitmap); -} -/*update part of input data by port_group - *input data contains 32 bits which is divided into 2 group of sub_data(16bit) - * */ -static void subdata_update(u32 *data, u32 sub, int grp) -{ - u32 mask = (((1 << PORT_IDX_NUM) - 1) << (grp * PORT_IDX_NUM)); - u32 shift = grp * PORT_IDX_NUM; - (*data) = ((*data) & (~mask)) | (sub << shift); -} -static int lc_sff_input_update_byGroup(sff_input_type_t type, int lc_id, int port_grp) -{ - struct lc_client_t *lc_client = NULL; - int ret = 0; - struct lc_dev_obj_t *obj = NULL; - struct lc_config_t *config = NULL; - u32 old_input = 0; - u32 input_change = 0; - int port = 0; - u8 cur_st = 0; - - if (!grp_valid(port_grp) || - !lc_id_valid(lc_id)) { - return -EINVAL; - } - - if (!(obj = lc_obj_get(lc_id))) { - return -EBADRQC; - } - /*first stage , use ioexpander to handle present change*/ -#if 0 - if (SFF_PRS_TYPE == type) { - config = &(obj->ioexp[port_grp]); - } else { - config = &(obj->cpld[port_grp]); - } -#endif - config = &(obj->cpld[port_grp]); - if (!(lc_client = lc_client_find(config))) { - return -EBADRQC; - } - if ((ret = lc_i2c_smbus_read_word_data(lc_client, lc_sff_input_reg[type])) < 0) { - obj->input[type].valid = 0; - return ret; - } - old_input = obj->input[type].buf; - subdata_update(&(obj->input[type].buf), ret, port_grp); - obj->input[type].valid |= 1 << port_grp; - LC_DEV_LOG_DBG("lc_id:%d group:%d %s input:0x%x\n", lc_id , port_grp, sff_input_name[type], obj->input[type].buf); - /*debugging*/ - input_change = old_input ^ (obj->input[type].buf); - for (port = 0; port < PORT_IDX_NUM * PORT_GROUP_NUM; port++) { - if (test_bit(port, (unsigned long *)&input_change)) { - cur_st = (test_bit(port, (unsigned long *)&(obj->input[type].buf)) ? 1 : 0); - LC_DEV_LOG_DBG("lc_id:%d port:%d st->%d\n", lc_id, port, cur_st); - } - } - return 0; -}; -/*only used in intr function*/ -static int lc_sff_prs_intr_clear(int lc_id, int port_grp) -{ - struct lc_client_t *lc_client = NULL; - int ret = 0; - struct lc_dev_obj_t *obj = NULL; - struct lc_config_t *config = NULL; - - if (!grp_valid(port_grp) || - !lc_id_valid(lc_id)) { - return -EINVAL; - } - - if (!(obj = lc_obj_get(lc_id))) { - return -EBADRQC; - } - config = &(obj->cpld[port_grp]); - if (!(lc_client = lc_client_find(config))) { - return -EBADRQC; - } - if ((ret = lc_i2c_smbus_read_byte_data(lc_client, LC_CPLD_SFF_PRS_INT_CLEAR_OFFSET)) < 0) { - return ret; - } - - return 0; -} -static int lc_sff_prs_update_byGroup(int lc_id, int port_grp) -{ - int ret = 0; - if ((ret = lc_sff_prs_intr_clear(lc_id, port_grp)) < 0) { - return ret; - } - return lc_sff_input_update_byGroup(SFF_PRS_TYPE, lc_id, port_grp); -} - -static int lc_sff_intr_update_byGroup(int lc_id, int port_grp) -{ - return lc_sff_input_update_byGroup(SFF_INT_TYPE, lc_id, port_grp); -} - -static int lc_sff_oc_update_byGroup(int lc_id, int port_grp) -{ - return lc_sff_input_update_byGroup(SFF_OC_TYPE, lc_id, port_grp); -} -/*1st group*/ -static int lc_sff_prs_update_1stGroup(int lc_id) -{ - return lc_sff_prs_update_byGroup(lc_id, 0); -} - -static int lc_sff_intr_update_1stGroup(int lc_id) -{ - return lc_sff_intr_update_byGroup(lc_id, 0); -} - -static int lc_sff_oc_update_1stGroup(int lc_id) -{ - return lc_sff_oc_update_byGroup(lc_id, 0); -} -/*2nd group*/ -static int lc_sff_prs_update_2ndGroup(int lc_id) -{ - return lc_sff_prs_update_byGroup(lc_id, 1); -} - -static int lc_sff_intr_update_2ndGroup(int lc_id) -{ - return lc_sff_intr_update_byGroup(lc_id, 1); -} -static int lc_sff_oc_update_2ndGroup(int lc_id) -{ - return lc_sff_oc_update_byGroup(lc_id, 1); -} - -static inline void group_idx_get(int port, int *port_grp, int *idx) -{ - *port_grp = (port >> 4); - *idx = port & 0xf; -} -static int lc_sff_output_bitmap_set(lc_sff_output_type_t type, int lc_id, int port_grp, u16 val) -{ - struct lc_client_t *lc_client = NULL; - int ret = 0; - u8 offset = lc_sff_output_reg[type]; - struct lc_dev_obj_t *obj = NULL; - - if (!lc_id_valid(lc_id)) { - return -EINVAL; - } - - if (!grp_valid(port_grp)) { - return -EINVAL; - } - - if (!(obj = lc_obj_get(lc_id))) { - return -EBADRQC; - } - - if (!(lc_client = lc_client_find(&(obj->cpld[port_grp])))) { - return -EBADRQC; - } - - if ((ret = lc_i2c_smbus_write_word_data(lc_client, offset, val)) < 0) { - return ret; - } - - return 0; -} - -static int lc_sff_output_set(lc_sff_output_type_t type, int lc_id, int port, u8 val) -{ - struct lc_client_t *lc_client = NULL; - int ret = 0; - int port_grp = 0; - int idx = 0; - u16 reg = 0; - u8 offset = lc_sff_output_reg[type]; - struct lc_dev_obj_t *obj = NULL; - - if (!lc_id_valid(lc_id)) { - return -EINVAL; - } - - if (!(obj = lc_obj_get(lc_id))) { - return -EBADRQC; - } - - group_idx_get(port, &port_grp, &idx); - - if (!grp_valid(port_grp) || - !port_idx_valid(idx)) { - return -EINVAL; - } - - if (!(lc_client = lc_client_find(&(obj->cpld[port_grp])))) { - return -EBADRQC; - } - - if((ret = lc_i2c_smbus_read_word_data(lc_client, offset)) < 0) { - return ret; - } - - reg = ret; - - if (val) { - reg = inv_set_bit(idx, reg); - } else { - reg = inv_clear_bit(idx, reg); - } - /*debug*/ - LC_DEV_LOG_DBG("%s lc_id:%d port:%d val:%d\n", lc_sff_output_name[type], lc_id, port, val); - - if ((ret = lc_i2c_smbus_write_word_data(lc_client, offset, reg)) < 0) { - return ret; - } - - return 0; -} - -static int lc_sff_output_all_set(lc_sff_output_type_t type, int lc_id, unsigned long bitmap) -{ - struct lc_client_t *lc_client = NULL; - int ret = 0; - int port_grp = 0; - u16 reg[PORT_GROUP_NUM]; - u8 offset = lc_sff_output_reg[type]; - struct lc_dev_obj_t *obj = NULL; - - if (!lc_id_valid(lc_id)) { - return -EINVAL; - } - if (!(obj = lc_obj_get(lc_id))) { - return -EBADRQC; - } - - reg[0] = bitmap & U16_MASK; - reg[1] = bitmap >> PORT_IDX_NUM; - - /*debug*/ - LC_DEV_LOG_DBG("%s lc_id:%d l:0x%x h:0x%x\n", lc_sff_output_name[type], lc_id, reg[0], reg[1]); - for (port_grp = 0; port_grp < PORT_GROUP_NUM; port_grp++) { - if (!(lc_client = lc_client_find(&(obj->cpld[port_grp])))) { - ret = -EBADRQC; - break; - } - if ((ret = lc_i2c_smbus_write_word_data(lc_client, offset, reg[port_grp])) < 0) { - break; - } - } - if (ret < 0) { - return ret; - } - return 0; -} - -static int lc_sff_output_get(lc_sff_output_type_t type, int lc_id, int port, u8 *val) -{ - struct lc_client_t *lc_client = NULL; - int ret = 0; - int port_grp = 0; - int idx = 0; - u16 reg = 0; - u8 offset = lc_sff_output_reg[type]; - struct lc_dev_obj_t *obj = NULL; - - if (!(obj = lc_obj_get(lc_id))) { - return -EBADRQC; - } - - group_idx_get(port, &port_grp, &idx); - - if (!grp_valid(port_grp) || - !port_idx_valid(idx)) { - return -EINVAL; - } - if (!(lc_client = lc_client_find(&(obj->cpld[port_grp])))) { - return -EBADRQC; - } - - if ((ret = lc_i2c_smbus_read_word_data(lc_client, offset)) < 0) { - return ret; - } - - reg = ret; - if (test_bit(idx, (unsigned long *)®)) { - *val = 1; - } else { - - *val = 0; - } - - /*debug*/ - LC_DEV_LOG_DBG("%s lc_id:%d port:%d val:%d\n", lc_sff_output_name[type], lc_id, port, *val); - return 0; -} - -static int lc_sff_output_all_get(lc_sff_output_type_t type, int lc_id, unsigned long *bitmap) -{ - struct lc_client_t *lc_client = NULL; - int ret = 0; - int port_grp = 0; - unsigned long reg[PORT_GROUP_NUM]; - u8 offset = lc_sff_output_reg[type]; - struct lc_dev_obj_t *obj = NULL; - - if (!p_valid(bitmap)) { - return -EINVAL; - } - if (!lc_id_valid(lc_id)) { - return -EINVAL; - } - if (!(obj = lc_obj_get(lc_id))) { - return -EBADRQC; - } - - /*debug*/ - //LC_DEV_LOG_DBG("%s lc_id:%d port:%d val:%d\n", lc_sff_output_name[type], lc_id, port, val); - for (port_grp = 0; port_grp < PORT_GROUP_NUM; port_grp++) { - if (!(lc_client = lc_client_find(&(obj->cpld[port_grp])))) { - ret = -EBADRQC; - break; - } - if ((ret = lc_i2c_smbus_read_word_data(lc_client, offset)) < 0) { - break; - } - reg[port_grp] = ret; - } - if (ret < 0) { - return ret; - } - *bitmap |= reg[0]; - *bitmap |= reg[1] << (PORT_IDX_NUM); - LC_DEV_LOG_DBG("%s lc_id:%d l:0x%lx h:0x%lx\n", lc_sff_output_name[type], lc_id, reg[0], reg[1]); - return 0; -} -static int lc_sff_lpmode_set(int lc_id, int port, u8 val) -{ - return lc_sff_output_set(SFF_LPMODE_TYPE, lc_id, port, val); -} -static int lc_sff_lpmode_get(int lc_id, int port, u8 *val) -{ - return lc_sff_output_get(SFF_LPMODE_TYPE, lc_id, port, val); -} -static int lc_sff_reset_set(int lc_id, int port, u8 val) -{ - return lc_sff_output_set(SFF_RESET_TYPE, lc_id, port, val); -} -static int lc_sff_reset_get(int lc_id, int port, u8 *val) -{ - return lc_sff_output_get(SFF_RESET_TYPE, lc_id, port, val); -} -static int lc_sff_power_set(int lc_id, int port, u8 val) -{ - return lc_sff_output_set(SFF_POWER_TYPE, lc_id, port, val); -} -static int lc_sff_power_get(int lc_id, int port, u8 *val) -{ - return lc_sff_output_get(SFF_POWER_TYPE, lc_id, port, val); -} - -static int lc_sff_lpmode_all_set(int lc_id, unsigned long bitmap) -{ - return lc_sff_output_all_set(SFF_LPMODE_TYPE, lc_id, bitmap); -} -static int lc_sff_lpmode_all_get(int lc_id, unsigned long *bitmap) -{ - return lc_sff_output_all_get(SFF_LPMODE_TYPE, lc_id, bitmap); -} -static int lc_sff_reset_all_set(int lc_id, unsigned long bitmap) -{ - return lc_sff_output_all_set(SFF_RESET_TYPE, lc_id, bitmap); -} -static int lc_sff_reset_all_get(int lc_id, unsigned long *bitmap) -{ - return lc_sff_output_all_get(SFF_RESET_TYPE, lc_id, bitmap); -} -static int lc_sff_power_all_set(int lc_id, unsigned long bitmap) -{ - return lc_sff_output_all_set(SFF_POWER_TYPE, lc_id, bitmap); -} -static int lc_sff_power_all_get(int lc_id, unsigned long *bitmap) -{ - return lc_sff_output_all_get(SFF_POWER_TYPE, lc_id, bitmap); -} - -static int lc_sff_intr_is_asserted(int lc_id, bool *asserted) -{ - bool st = false; - int lv = 0; - lv = gpio_get_value(lcDev.obj[lc_id].sff_intr_gpio); - - if (!lv) { - st = true; - LC_DEV_LOG_DBG("lc_id:%d lv:%d asserted\n", lc_id, lv); - } else { - - //LC_DEV_LOG_DBG("de-asserted\n"); - } - *asserted = st; - return 0; -} -int lc_dev_mux_l1_i2c_ch_get(int lc_id) -{ - int i2c_ch = 0; - struct lc_dev_obj_t *obj = NULL; - - if (!p_valid(obj = lc_obj_get(lc_id))) { - return -1; - } - i2c_ch = lcChTbl[obj->mux_l1.lc_ch_id]; - LC_DEV_LOG_DBG("lc_id:%d i2c_ch:%d\n", lc_id, i2c_ch); - return i2c_ch; -} -/*used to check if mux l1 is alive*/ -bool lc_dev_mux_l1_is_alive(int lc_id) -{ - int ret = 0; - struct lc_client_t *lc_client = NULL; - struct lc_dev_obj_t *obj = NULL; - bool alive = false; - - if (!p_valid(obj = lc_obj_get(lc_id))) { - return alive; - } - - if (!p_valid(lc_client = lc_client_find(&(obj->mux_l1)))) { - return alive; - } - - if ((ret = lc_i2c_smbus_read_byte(lc_client)) < 0) { - return alive; - } - //if (0 != ret) - //{ - alive = true; - //} - if (!alive) { - LC_DEV_LOG_ERR("not alive\n"); - } - return alive; -} -int lc_dev_mux_l1_reset(int lc_id, u8 lv) -{ - int ret = 0; - struct lc_client_t *lc_client = NULL; - struct lc_dev_obj_t *obj = NULL; - u8 reg = 0; - - if (!(obj = lc_obj_get(lc_id))) { - return -EBADRQC; - } - - if (!(lc_client = lc_client_find(&(obj->cpld[CPLD1_ID])))) { - return -EBADRQC; - } - - if ((ret = lc_i2c_smbus_read_byte_data(lc_client, RST_PCA9548_D_OFFSET)) < 0) { - return ret; - } - reg = ret; - - LC_DEV_LOG_DBG("lc_id:%d get reg:0x%x\n", lc_id, reg); - - if (lv) { - set_bit(RST_PCA9546_N_BIT, (unsigned long *)®); - } else { - clear_bit(RST_PCA9546_N_BIT, (unsigned long *)®); - } - LC_DEV_LOG_DBG("lc_id:%d set reg:0x%x\n", lc_id, reg); - - if ((ret = lc_i2c_smbus_write_byte_data(lc_client, RST_PCA9548_D_OFFSET, reg)) < 0) { - return ret; - } - - return 0; -} -static bool mux_l2_id_valid(int mux_l2_id) -{ - if (mux_l2_id < MUX_L2_NUM && mux_l2_id >= 0) { - return true; - } else { - LC_DEV_LOG_ERR("invalid mux_l2_id:%d\n", mux_l2_id); - return false; - } -} -int lc_dev_mux_l2_reset(int lc_id, int mux_l2_id, u8 lv) -{ - int ret = 0; - struct lc_client_t *lc_client = NULL; - struct lc_dev_obj_t *obj = NULL; - u8 reg = 0; - - if (!mux_l2_id_valid(mux_l2_id)) { - - return -EINVAL; - } - - if (!(obj = lc_obj_get(lc_id))) { - return -EBADRQC; - } - - if (!(lc_client = lc_client_find(&(obj->cpld[CPLD1_ID])))) { - return -EBADRQC; - } - if ((ret = lc_i2c_smbus_read_byte_data(lc_client, RST_PCA9548_D_OFFSET)) < 0) { - return ret; - } - reg = ret; - - LC_DEV_LOG_DBG("lc_id:%d get reg:0x%x\n", lc_id, reg); - if (lv) { - set_bit(rst_mux_l2_bit[mux_l2_id], (unsigned long *)®); - } else { - clear_bit(rst_mux_l2_bit[mux_l2_id], (unsigned long *)®); - } - LC_DEV_LOG_DBG("lc_id:%d set reg:0x%x\n", lc_id, reg); - - if ((ret = lc_i2c_smbus_write_byte_data(lc_client, RST_PCA9548_D_OFFSET, reg)) < 0) { - return ret; - } - - return 0; - -} - -int lc_dev_mux_reset_set(int lc_id, int lv) -{ - int ret = 0; - int mux_l2_id = 0; - - for (mux_l2_id = 0; mux_l2_id < MUX_L2_NUM; mux_l2_id++) { - if ((ret = lc_dev_mux_l2_reset(lc_id, mux_l2_id, lv)) < 0) { - break; - } - } - if (ret < 0) { - return ret; - } - if ((ret = lc_dev_mux_l1_reset(lc_id, lv)) < 0) { - return ret; - } - return 0; -} - -static inline s8 lm75_reg_to_mc(s16 reg, u8 resolution) -{ - //return ((temp >> (16 - resolution)) * 1000) >> (resolution - 8); - s8 temp = 0; - - temp = reg & 0xff; -#if 0 - long val = 0; - val = (temp & 0xff) * 1000 + ((temp>>14 & 0x03)*250)*((temp & 0x80)?-1:1); - return val; -#else - return temp; - //return ((new_temp >> (16 - resolution)) * 1000) >> (resolution - 8); - -#endif -} -int lc_dev_temp_th_set(int lc_id, int temp) -{ - int ret = 0; - u8 offset = 0xff; - s16 reg = 0; - struct lc_client_t *lc_client = NULL; - struct lc_dev_obj_t *obj = NULL; - - if (!lc_id_valid(lc_id)) { - return -EINVAL; - } - - if (!p_valid(obj = lc_obj_get(lc_id))) { - return -EBADRQC; - } - if (!p_valid(lc_client = lc_client_find(&(obj->tmp_dev[0])))) { - return -EBADRQC; - } - - offset = LM75_REG_LOW; - reg = temp; - LC_DEV_LOG_ERR("reg:0x%x\n", reg); - if ((ret = lc_i2c_smbus_write_word_data(lc_client, offset, reg)) < 0) { - return ret; - } - offset = LM75_REG_HIGH; - reg = temp+3; - LC_DEV_LOG_ERR("reg:0x%x\n", reg); - if ((ret = lc_i2c_smbus_write_word_data(lc_client, offset, reg)) < 0) { - return ret; - } - - return 0; -} - -int lc_dev_temp_get(temp_conf_type_t type, int lc_id, int tmp_id, s8 *val) -{ - int ret = 0; - u8 offset = 0xff; - s16 reg = 0; - struct lc_client_t *lc_client = NULL; - struct lc_dev_obj_t *obj = NULL; - - if (!p_valid(val)) { - return -EINVAL; - } - if (!lc_id_valid(lc_id)) { - return -EINVAL; - } - - if (!p_valid(obj = lc_obj_get(lc_id))) { - return -EBADRQC; - } - if (!p_valid(lc_client = lc_client_find(&(obj->tmp_dev[tmp_id])))) { - return -EBADRQC; - } - - switch (type) { - case TEMP_INPUT: - offset = LM75_REG_TEMP; - break; - case TEMP_TH_L: - offset = LM75_REG_LOW; - break; - case TEMP_TH_H: - offset = LM75_REG_HIGH; - break; - default: - LC_DEV_LOG_ERR("UNKOWN_TYPE:%d\n", type); - break; - } - if (0xff == offset) { - return -EINVAL; - } - if ((ret = lc_i2c_smbus_read_word_data(lc_client, offset)) < 0) { - return ret; - } - reg = ret; - //LC_DEV_LOG_ERR("reg:0x%x\n", reg); - *val = lm75_reg_to_mc(reg, LM75_RESOLUTION); - - return 0; -} - -int lc_dev_temp_config_get(int lc_id, int tmp_id, u8 *val) -{ - int ret = 0; - struct lc_client_t *lc_client = NULL; - struct lc_dev_obj_t *obj = NULL; - - if (!p_valid(val)) { - return -EINVAL; - } - if (!lc_id_valid(lc_id)) { - return -EINVAL; - } - - if (!p_valid(obj = lc_obj_get(lc_id))) { - return -EBADRQC; - } - if (!p_valid(lc_client = lc_client_find(&(obj->tmp_dev[tmp_id])))) { - return -EBADRQC; - } - - if ((ret = lc_i2c_smbus_read_word_data(lc_client, LM75_REG_CONF)) < 0) { - return ret; - } - *val = ret; - LC_DEV_LOG_ERR("reg:0x%x\n", ret); - - return 0; -} -int lc_dev_temp_get_text(int lc_id, char *buf, int size) -{ - int ret = 0; - s8 temp; - s8 temp_th_l; - s8 temp_th_h; - int tmp_id = 0; - int count = 0; - u8 conf = 0; - - for (tmp_id = 0; tmp_id < TMP_DEV_NUM; tmp_id++) { - if ((ret = lc_dev_temp_config_get(lc_id, tmp_id, &conf)) < 0) { - break; - } - - if ((ret = lc_dev_temp_get(TEMP_INPUT, lc_id, tmp_id, &temp)) < 0) { - break; - } - if ((ret = lc_dev_temp_get(TEMP_TH_L, lc_id, tmp_id, &temp_th_l)) < 0) { - break; - } - - if ((ret = lc_dev_temp_get(TEMP_TH_H, lc_id, tmp_id, &temp_th_h)) < 0) { - break; - } - count += scnprintf(buf+count, size-count, - "tmp%d: conf:0x%x temp:%d temp_th_l:%d temp_th_h:%d\n", - tmp_id, conf, temp, temp_th_l, temp_th_h); - } - if (ret < 0) { - return ret; - } - - return 0; -} -#if 0 -int lc_dev_temp_th_get_text(int lc_id, char *buf, int size) -{ - int ret = 0; - s8 temp_th[TMP_DEV_NUM]; - int tmp_id = 0; - int count = 0; - - for (tmp_id = 0; tmp_id < TMP_DEV_NUM; tmp_id++) { - - if ((ret = lc_dev_temp_get(TEMP_TH_H, lc_id, tmp_id, &temp_th[tmp_id])) < 0) { - break; - } - count += scnprintf(buf+count, size-count, - "tmp%d: high thershold %ld c\n", - tmp_id+1, temp_th[tmp_id]); - } - if (ret < 0) { - return ret; - } - - for (tmp_id = 0; tmp_id < TMP_DEV_NUM; tmp_id++) { - - if ((ret = lc_dev_temp_get(TEMP_TH_L, lc_id, tmp_id, &temp_th[tmp_id])) < 0) { - break; - } - count += scnprintf(buf+count, size-count, - "tmp%d: low thershold %ld c\n", - tmp_id+1, temp_th[tmp_id]); - } - if (ret < 0) { - return ret; - } - return 0; -} -#endif -/* description: reset lc - * - * input: - * lc_id: lc number - * lv: reset level - - *return: - 0: success -[note] - the reset is used to do lc reset via switch cpld reg, - - * */ -int lc_dev_reset_set(int lc_id, u8 lv) -{ - int ret = 0; - struct lc_client_t *lc_client = NULL; - u8 reg = 0; - - if (!lc_id_valid(lc_id)) { - return -EINVAL; - } - - if (!(lc_client = lc_client_find(&(lcDev.switch_cpld)))) { - return -EBADRQC; - } - - if ((ret = lc_i2c_smbus_read_byte_data(lc_client, lc_control_reg[lc_id])) < 0) { - return ret; - } - reg = ret; - - LC_DEV_LOG_DBG("lc_id:%d get reg:0x%x\n", lc_id, reg); - if (lv) { - reg = inv_set_bit(SWICH_CPLD_LC_CPU_PLTRST_N_BIT, reg); - } else { - reg = inv_clear_bit(SWICH_CPLD_LC_CPU_PLTRST_N_BIT, reg); - } - LC_DEV_LOG_DBG("lc_id:%d set reg:0x%x\n", lc_id, reg); - - if ((ret = lc_i2c_smbus_write_byte_data(lc_client, lc_control_reg[lc_id], reg)) < 0) { - return ret; - } - - return 0; -} - -int lc_dev_12v_set(int lc_id, bool on) -{ - int ret = 0; - struct lc_client_t *lc_client = NULL; - u8 reg = 0; - - if (!lc_id_valid(lc_id)) { - return -EINVAL; - } - - if (!(lc_client = lc_client_find(&(lcDev.switch_cpld)))) { - return -EBADRQC; - } - - if ((ret = lc_i2c_smbus_read_byte_data(lc_client, lc_control_reg[lc_id])) < 0) { - return ret; - } - reg = ret; - - LC_DEV_LOG_DBG("lc_id:%d get reg:0x%x\n", lc_id, reg); - if (on) { - reg = inv_set_bit(SWICH_CPLD_LC_PWR_CONTROL_BIT, reg); - } else { - reg = inv_clear_bit(SWICH_CPLD_LC_PWR_CONTROL_BIT, reg); - } - LC_DEV_LOG_DBG("lc_id:%d set reg:0x%x\n", lc_id, reg); - - if ((ret = lc_i2c_smbus_write_byte_data(lc_client, lc_control_reg[lc_id], reg)) < 0) { - return ret; - } - - return 0; -} -int lc_dev_reset_get(int lc_id, u8 *lv) -{ - int ret = 0; - struct lc_client_t *lc_client = NULL; - u8 reg = 0; - - if (!lc_id_valid(lc_id)) { - return -EINVAL; - } - - if (!lv) { - return -EINVAL; - } - - if (!(lc_client = lc_client_find(&(lcDev.switch_cpld)))) { - return -EBADRQC; - } - - if ((ret = lc_i2c_smbus_read_byte_data(lc_client, lc_control_reg[lc_id])) < 0) { - return ret; - } - reg = ret; - - LC_DEV_LOG_DBG("lc_id:%d get reg:0x%x\n", lc_id, reg); - - if (test_bit(SWICH_CPLD_LC_CPU_PLTRST_N_BIT, (unsigned long *)®)) { - *lv = 1; - } else { - *lv = 0; - } - - return 0; -} - -int lc_dev_ucd_power_set(int lc_id, bool on) -{ - int ret = 0; - struct lc_client_t *lc_client = NULL; - struct lc_dev_obj_t *obj = NULL; - u8 reg = 0; - - if (!lc_id_valid(lc_id)) { - return -EINVAL; - } - - if (!(obj = lc_obj_get(lc_id))) { - return -EBADRQC; - } - - if (!(lc_client = lc_client_find(&(obj->cpld[CPLD1_ID])))) { - return -EBADRQC; - } - /*control ucd*/ - if ((ret = lc_i2c_smbus_read_byte_data(lc_client, LC_CPLD_MISC_CONTROL1_OFFSET)) < 0) { - return ret; - } - reg = ret; - LC_DEV_LOG_DBG("1 lc_id:ucd %d get reg:0x%x\n", lc_id, reg); - if (on) { - //reg = inv_set_bit(LC_CPLD_UCD_PMBUS_CNTRL_R_BIT, reg); - set_bit(LC_CPLD_UCD_PMBUS_CNTRL_R_BIT, (unsigned long *)®); - } else { - clear_bit(LC_CPLD_UCD_PMBUS_CNTRL_R_BIT, (unsigned long *)®); - //reg = inv_clear_bit(LC_CPLD_UCD_PMBUS_CNTRL_R_BIT, reg); - } - if ((ret = lc_i2c_smbus_write_byte_data(lc_client, LC_CPLD_MISC_CONTROL1_OFFSET, reg)) < 0) { - return ret; - } - LC_DEV_LOG_DBG("lc_id:ucd %d get reg:0x%x\n", lc_id, reg); - - return 0; -} -/* description: set lc power - * - * input: - * on: true:power on false: power off - *return: - 0: success - * */ -int lc_dev_power_set(int lc_id, bool on) -{ - int ret = 0; - - if (on) { - if ((ret = lc_dev_12v_set(lc_id, true)) < 0) { - return ret; - } - - if ((ret = lc_dev_reset_set(lc_id, 1)) < 0) { - return ret; - } - - if ((ret = lc_dev_ucd_power_set(lc_id, true)) < 0) { - return ret; - } - } else { - - if ((ret = lc_dev_ucd_power_set(lc_id, false)) < 0) { - return ret; - } - - if ((ret = lc_dev_12v_set(lc_id, false)) < 0) { - return ret; - } - } - return 0; -} - -int lc_dev_phy_reset_set(int lc_id, u8 val) -{ - int ret = 0; - struct lc_client_t *lc_client = NULL; - struct lc_dev_obj_t *obj = NULL; - u8 reg = 0; - if (!lc_id_valid(lc_id)) { - return -EINVAL; - } - - if (!(obj = lc_obj_get(lc_id))) { - return -EBADRQC; - } - - if (!(lc_client = lc_client_find(&(obj->cpld[CPLD1_ID])))) { - return -EBADRQC; - } - if (val) { - reg = 0xff; - } else { - reg = 0x0; - } - - if ((ret = lc_i2c_smbus_write_byte_data(lc_client, LC_CPLD_PHY_RST_OFFSET, reg)) < 0) { - return ret; - } - - return 0; -} - -int lc_dev_led_set(int lc_id, lc_led_ctrl_t ctrl) -{ - int ret = 0; - struct lc_client_t *lc_client = NULL; - struct lc_dev_obj_t *obj = NULL; - u8 reg = 0; - - if (!lc_id_valid(lc_id)) { - return -EINVAL; - } - - if (!(obj = lc_obj_get(lc_id))) { - return -EBADRQC; - } - - if (!(lc_client = lc_client_find(&(obj->cpld[CPLD1_ID])))) { - return -EBADRQC; - } - - reg = ctrl; - - if ((ret = lc_i2c_smbus_write_byte_data(lc_client, LC_ST_LED_OFFSET, reg)) < 0) { - return ret; - } - if (p_valid(lc_led_str[ctrl])) { - //LC_DEV_LOG_DBG("lc_id:%d %s\n", lc_id, lc_led_str[ctrl]); - } - return 0; -} - -int lc_dev_led_boot_amber_set(int lc_id, bool on) -{ - int ret = 0; - struct lc_client_t *lc_client = NULL; - struct lc_dev_obj_t *obj = NULL; - u8 reg = 0; - int port_grp = 0; - if (!lc_id_valid(lc_id)) { - return -EINVAL; - } - - if (!(obj = lc_obj_get(lc_id))) { - return -EBADRQC; - } - for (port_grp = 0; port_grp < PORT_GROUP_NUM; port_grp++) { - if (!(lc_client = lc_client_find(&(obj->cpld[port_grp])))) { - ret = -EBADRQC; - break; - } - if ((ret = lc_i2c_smbus_read_byte_data(lc_client, LC_CPLD_LED_DIAG_OFFSET)) < 0) { - break; - } - reg = ret; - if (on) { - set_bit(LC_CPLD_LED_BOOT_AMBER_BIT, (unsigned long *)®); - } else { - clear_bit(LC_CPLD_LED_BOOT_AMBER_BIT, (unsigned long *)®); - } - if ((ret = lc_i2c_smbus_write_byte_data(lc_client, LC_CPLD_LED_DIAG_OFFSET, reg)) < 0) { - break; - } - } - if (ret < 0) { - return ret; - } - return 0; -} - -int lc_dev_type_get(int lc_id, lc_type_t *type) -{ - int ret = 0; - struct lc_client_t *lc_client = NULL; - struct lc_dev_obj_t *obj = NULL; - u8 reg = 0; - u8 id = 0; - - if (!lc_id_valid(lc_id)) { - return -EINVAL; - } - - if (!type) { - return -EINVAL; - } - - if (!(obj = lc_obj_get(lc_id))) { - return -EBADRQC; - } - - if (!(lc_client = lc_client_find(&(obj->cpld[CPLD1_ID])))) { - return -EBADRQC; - } - - if ((ret = lc_i2c_smbus_read_byte_data(lc_client, PCB_VER_OFFSET)) < 0) { - return ret; - } - - reg = ret; - id = bits_get(reg, LC_ID_BIT_S, LC_ID_BIT_NUM); - - if (LC_100G_ID == id) { - *type = LC_100G_TYPE; - } else if (LC_400G_ID == id) { - *type = LC_400G_TYPE; - } else { - LC_DEV_LOG_ERR("unknown lc type!\n"); - *type = LC_UNKNOWN_TYPE; - return -EBADRQC; - } - - return 0; -} - -int lc_dev_type_get_text(int lc_id, char *buf, int size) -{ - int ret = 0; - lc_type_t type = LC_UNKNOWN_TYPE; - - if ((ret = lc_dev_type_get(lc_id, &type)) < 0) { - return ret; - } - - scnprintf(buf, size, - "%s\n", - lc_type_name[type]); - - return 0; -} - -void lc_dev_phy_ready(unsigned long bitmap, bool *ready) -{ - if (PHY_READY_BITMASK == bitmap) { - *ready = true; - } else { - *ready = false; - } -} - -int lc_dev_power_ready(int lc_id, bool *ready) -{ - int ret = 0; - struct lc_client_t *lc_client = NULL; - struct lc_dev_obj_t *obj = NULL; - u8 st1 = 0; - u8 st2 = 0; - if (!lc_id_valid(lc_id)) { - return -EINVAL; - } - if (!ready) { - return -EINVAL; - } - if (!(obj = lc_obj_get(lc_id))) { - return -EBADRQC; - } - - if (!(lc_client = lc_client_find(&(obj->cpld[CPLD1_ID])))) { - return -EBADRQC; - } - if ((ret = lc_i2c_smbus_read_byte_data(lc_client, LC_CPLD_DC_DC_ST1_OFFSET)) < 0) { - return ret; - } - st1 = ret; - if ((ret = lc_i2c_smbus_read_byte_data(lc_client, LC_CPLD_DC_DC_ST1_OFFSET)) < 0) { - return ret; - } - st2 = ret; - - if (0xff == st1 && - 0xff == st2) { - *ready = true; - } - - return 0; -} -static int lc_st_get(lc_st_type_t type, unsigned long *bitmap) -{ - if (!bitmap) { - return -EINVAL; - } - - if (!lcDev.lc_st[type].valid) { - return -EBADRQC; - } - - *bitmap = lcDev.lc_st[type].bitmap; - //LC_DEV_LOG_DBG("%s 0x%lx\n", lc_st_name[type], *bitmap); - return 0; -} -#if 0 -old -static int lc_st_reg_read(lc_st_type_t type, int lc_id, u8 *st) -{ - int ret = 0; - struct lc_client_t *lc_client = NULL; - - if (!st) { - return -EINVAL; - } - if (!lc_id_valid(lc_id)) { - return -EINVAL; - } - - if (!(lc_client = lc_client_find(&(lcDev.switch_cpld)))) { - return -EBADRQC; - } - - if ((ret = lc_i2c_smbus_read_byte_data(lc_client, lc_st_reg[lc_id])) < 0) { - return ret; - } - - if (test_bit(lc_st_bit[type], (unsigned long *)&ret)) { - *st = true; - } else { - *st = false; - } - - return 0; -} -static int lc_st_update(lc_st_type_t type) -{ - int ret = 0; - u8 st = 0; - u8 old_st = 0; - int lc_id = 0; - struct ldata_format_t *ldata = NULL; - - ldata = &(lcDev.lc_st[type]); - - for (lc_id = 0; lc_id < CARD_NUM; lc_id++) { - if ((ret = lc_st_reg_read(type, lc_id, &st)) < 0) { - break; - } - /*dbg to show transition*/ - old_st = ((test_bit(lc_id, &(ldata->bitmap))) ? 1 : 0); - if (old_st != st) { - LC_DEV_LOG_DBG("lc_id:%d %s %d -> %d\n", lc_id, lc_st_name[type], old_st, st); - } - if (st) { - set_bit(lc_id, &(ldata->bitmap)); - } else { - clear_bit(lc_id, &(ldata->bitmap)); - } - } - if (ret < 0) { - ldata->valid = false; - ldata->bitmap = 0; - return ret; - } - ldata->valid = true; - return 0; -} -#endif -static int lc_st_reg_read(int lc_id, u8 *reg) -{ - int ret = 0; - struct lc_client_t *lc_client = NULL; - - if (!p_valid(reg)) { - return -EINVAL; - } - if (!lc_id_valid(lc_id)) { - return -EINVAL; - } - - if (!(lc_client = lc_client_find(&(lcDev.switch_cpld)))) { - return -EBADRQC; - } - - if ((ret = lc_i2c_smbus_read_byte_data(lc_client, lc_st_reg[lc_id])) < 0) { - return ret; - } - *reg = ret; - - return 0; -} - -static void lc_st_data_update(u8 reg, int lc_id, lc_st_type_t type, bool normal) -{ - u8 st = 0; - u8 old_st = 0; - struct ldata_format_t *ldata = NULL; - - ldata = &(lcDev.lc_st[type]); - if (normal) { - if (test_bit(lc_st_bit[type], (unsigned long *)®)) { - st = true; - } else { - st = false; - } - /*dbg to show transition*/ - old_st = ((test_bit(lc_id, &(ldata->bitmap))) ? 1 : 0); - if (old_st != st) { - LC_DEV_LOG_DBG("lc_id:%d %s %d -> %d\n", lc_id, lc_st_name[type], old_st, st); - } - if (st) { - set_bit(lc_id, &(ldata->bitmap)); - } else { - clear_bit(lc_id, &(ldata->bitmap)); - } - ldata->valid = true; - } else { - - ldata->valid = false; - ldata->bitmap = 0; - } -} - -static int lc_st_update(void) -{ - int ret = 0; - u8 reg = 0; - int lc_id = 0; - for (lc_id = 0; lc_id < CARD_NUM; lc_id++) { - if ((ret = lc_st_reg_read(lc_id, ®)) < 0) { - lc_st_data_update(reg, lc_id, LC_ST_PRS_TYPE, false); - lc_st_data_update(reg, lc_id, LC_ST_OVER_TEMP_TYPE, false); - lc_st_data_update(reg, lc_id, LC_ST_EJ_R_TYPE, false); - lc_st_data_update(reg, lc_id, LC_ST_EJ_L_TYPE, false); - break; - } - lc_st_data_update(reg, lc_id, LC_ST_PRS_TYPE, true); - lc_st_data_update(reg, lc_id, LC_ST_OVER_TEMP_TYPE, true); - lc_st_data_update(reg, lc_id, LC_ST_EJ_R_TYPE, true); - lc_st_data_update(reg, lc_id, LC_ST_EJ_L_TYPE, true); - } - if (ret < 0) { - return ret; - } - return 0; -} -/* description: get line card presence status - * - * input: - * output: - * bitmap: bit0 : lc1 ~ bit3 : lc4 - * 1: present 0: absent - * - *return: - 0: success - * */ -int lc_dev_prs_get(unsigned long *bitmap) -{ - int ret = 0; - unsigned long tmp = 0; - - if ((ret = lc_st_get(LC_ST_PRS_TYPE, &tmp)) < 0) { - return ret; - } - - //LC_DEV_LOG_DBG("lc_prs:%lx\n", ~tmp); - *bitmap = ~tmp; - return 0; -} - -int lc_dev_ej_r_get(unsigned long *bitmap) -{ - int ret = 0; - unsigned long ej = 0; - - if ((ret = lc_st_get(LC_ST_EJ_R_TYPE, &ej)) < 0) { - return ret; - } - - //LC_DEV_LOG_DBG("lc_prs:%lx\n", ~tmp); - *bitmap = ~ej; - return 0; -} -int lc_dev_ej_l_get(unsigned long *bitmap) -{ - int ret = 0; - unsigned long ej = 0; - - if ((ret = lc_st_get(LC_ST_EJ_L_TYPE, &ej)) < 0) { - return ret; - } - - //LC_DEV_LOG_DBG("lc_prs:%lx\n", ~tmp); - *bitmap = ~ej; - return 0; -} -/* description: get line card temperature INT bit - * - * input: - * output: - * bitmap: bit0 : lc1 ~ bit3 : lc4 - * 0: interrupt 1: normal - * - *return: - 0: success - * */ -int lc_dev_temp_intr_get(unsigned long *bitmap) -{ - int ret = 0; - unsigned long tmp = 0; - - - if (!p_valid(bitmap)) { - return -EINVAL; - } - - if ((ret = lc_st_get(LC_ST_OVER_TEMP_TYPE, &tmp)) < 0) { - return ret; - } - - *bitmap = tmp; - return 0; -} -#if 1 -static int lc_dev_over_temp_asserted_byDev(int lc_id, int tmp_id, bool *asserted) -{ - int ret = 0; - unsigned long intr = 0; - s8 temp_th_h = 0; - s8 temp = 0; - int i = 0; - if (!p_valid(asserted)) { - return -EINVAL; - } - - *asserted = false; - if ((ret = lc_dev_temp_intr_get(&intr)) < 0) { - return ret; - } - - if (!test_bit(lc_id , &intr)) { - - if ((ret = lc_dev_temp_get(TEMP_TH_H, lc_id, tmp_id, &temp_th_h)) < 0) { - return ret; - } - for (i = 0; i < TEMP_CHECK_NUM; i++) { - - if ((ret = lc_dev_temp_get(TEMP_INPUT, lc_id, tmp_id, &temp)) < 0) { - break; - } - if (temp < temp_th_h) { - break; - } - } - if (i >= TEMP_CHECK_NUM) { - - *asserted = true; - LC_DEV_LOG_INFO("lc_id:%d tmp_id:%d asserted\n", lc_id, tmp_id); - } - - if (ret < 0) { - return ret; - } - - } - - return 0; -} -#else - -static int lc_dev_over_temp_asserted_byDev(int lc_id, int tmp_id, bool *asserted) -{ - int ret = 0; - unsigned long intr = 0; - s8 temp_th_h = 0; - s8 temp = 0; - int i = 0; - if (!p_valid(asserted)) { - return -EINVAL; - } - - *asserted = false; - if ((ret = lc_dev_temp_intr_get(&intr)) < 0) { - return ret; - } - - if (!test_bit(lc_id , &intr)) { - *asserted = true; - LC_DEV_LOG_INFO("lc_id:%d tmp_id:%d asserted\n", lc_id, tmp_id); - } - - return 0; -} - -#endif -int lc_dev_over_temp_asserted(int lc_id, bool *asserted) -{ - bool dev_asserted[TMP_DEV_NUM]; - int ret = 0; - int tmp_id = 0; - - if ((ret = lc_st_update()) < 0) { - return ret; - } - - memset(dev_asserted, 0, sizeof(dev_asserted)); - for (tmp_id = 0; tmp_id < TMP_DEV_NUM; tmp_id++) { - if ((ret = lc_dev_over_temp_asserted_byDev(lc_id, tmp_id, &dev_asserted[tmp_id])) < 0) { - break; - } - } - if (ret < 0) { - return ret; - } - - if (dev_asserted[0] || dev_asserted[1]) { - *asserted = true; - } - return 0; -} -#if 1 -static int lc_dev_over_temp_deasserted_byDev(int lc_id, int tmp_id, bool *deasserted) -{ - int ret = 0; - unsigned long intr = 0; - s8 temp_th_l = 0; - s8 temp = 0; - int i = 0; - - if (!p_valid(deasserted)) { - return -EINVAL; - } - - *deasserted = false; - if ((ret = lc_dev_temp_intr_get(&intr)) < 0) { - return ret; - } - - if (test_bit(lc_id , &intr)) { - if ((ret = lc_dev_temp_get(TEMP_TH_L, lc_id, tmp_id, &temp_th_l)) < 0) { - return ret; - } - for (i = 0; i < TEMP_CHECK_NUM; i++) { - - if ((ret = lc_dev_temp_get(TEMP_INPUT, lc_id, tmp_id, &temp)) < 0) { - break; - } - if (temp > temp_th_l) { - break; - } - } - if (i >= TEMP_CHECK_NUM) { - - *deasserted = true; - LC_DEV_LOG_INFO("lc_id:%d tmp_id:%d deasserted\n", lc_id, tmp_id); - } - if (ret < 0) { - return ret; - } - - } - - return 0; -} -#else - -static int lc_dev_over_temp_deasserted_byDev(int lc_id, int tmp_id, bool *deasserted) -{ - int ret = 0; - unsigned long intr = 0; - s8 temp_th_l = 0; - s8 temp = 0; - int i = 0; - - if (!p_valid(deasserted)) { - return -EINVAL; - } - - *deasserted = false; - if ((ret = lc_dev_temp_intr_get(&intr)) < 0) { - return ret; - } - - if (test_bit(lc_id , &intr)) { - LC_DEV_LOG_INFO("lc_id:%d tmp_id:%d deasserted\n", lc_id, tmp_id); - *deasserted = true; - } - - return 0; -} - - -#endif -int lc_dev_over_temp_deasserted(int lc_id, bool *deasserted) -{ - bool dev_deasserted[TMP_DEV_NUM]; - int ret = 0; - int tmp_id = 0; - - if ((ret = lc_st_update()) < 0) { - return ret; - } - - memset(dev_deasserted, 0, sizeof(dev_deasserted)); - for (tmp_id = 0; tmp_id < TMP_DEV_NUM; tmp_id++) { - if ((ret = lc_dev_over_temp_deasserted_byDev(lc_id, tmp_id, &dev_deasserted[tmp_id])) < 0) { - break; - } - } - if (ret < 0) { - return ret; - } - - if (dev_deasserted[0] || dev_deasserted[1]) { - *deasserted = true; - } - return 0; -} -#if 0 - -static int lc_dig_intr_is_asserted(bool *asserted) -{ - int ret = 0; - struct lc_client_t *lc_client = NULL; - u8 reg = 0; - - if (!(lc_client = lc_client_find(&(lcDev.switch_cpld)))) { - return -EBADRQC; - } - - if ((ret = lc_i2c_smbus_read_byte_data(lc_client, SWITCH_CPLD_LC_ST_INT_OFFSET)) < 0) { - return ret; - } - reg = ret; - if (0 == reg) { - *asserted = true; - LC_DEV_LOG_DBG("asserted\n"); - } else { - *asserted = false; - } - //LC_DEV_LOG_DBG("reg:0x%x\n", reg); - return 0; -} -#endif -static int lc_st_intr_is_asserted(bool *asserted) -{ - bool st = false; - int lv = 0; - lv = gpio_get_value(lcDev.lc_intr_gpio); - - //LC_DEV_LOG_DBG("gpio:%d lv:%d\n", lcDev.lc_intr_gpio, lv); - if (!lv) { - st = true; - LC_DEV_LOG_DBG("asserted\n"); - } - *asserted = st; - return 0; -} - -int lc_sff_intr_hdlr_byCard(int lc_id) -{ - struct lc_client_t *lc_client = NULL; - int ret = 0; - u8 flag = 0; - int bit = 0; - bool asserted = false; - - if((ret = lc_sff_intr_is_asserted(lc_id, &asserted)) < 0) { - return ret; - } - - if (!asserted) { - return 0; - } - - if (!p_valid(lc_client = lc_client_find(&(lcDev.obj[lc_id].cpld[CPLD1_ID])))) { - return -EBADRQC; - } - if ((ret = lc_i2c_smbus_read_byte_data(lc_client, LC_CPLD_SFF_INT_ST_OFFSET)) < 0) { - return ret; - } - - flag = ret; - - for (bit = LC_CPLD_SFF_INT_CPLD2_PRS_BIT; bit < LC_CPLD_SFF_INT_NUM; bit++) { - - if (!test_bit(bit, (unsigned long *)&flag)) { - if(p_valid(sff_intr_funcs[bit])) { - if ((ret = sff_intr_funcs[bit](lc_id)) < 0) { - break; - } - } - } - } - if (ret < 0) { - return ret; - } - return 0; -} - -static int lc_intr_hdlr(void) -{ - int ret = 0; - -#if defined (INT_MODE) - bool asserted = false; - if ((ret = lc_st_intr_is_asserted(&asserted)) < 0) { - return ret; - } - if (asserted) { - if ((ret = lc_dev_intr_st_update()) < 0) { - return ret; - } - if ((ret = lc_st_update()) < 0) { - return ret; - } - - if ((ret = lc_dev_intr_st_clear()) < 0) { - return ret; - } - } -#else - - if ((ret = lc_st_update()) < 0) { - return ret; - } - -#endif - return 0; -} -#if 0 - -static int lc_sff_intr_hdlr(void) -{ - int lc_id = 0; - int ret = 0; - bool asserted = false; - - for (lc_id = 0; lc_id < CARD_NUM; lc_id++) { - - if((ret = lc_sff_intr_is_asserted(lc_id, &asserted)) < 0) { - break; - } - if (asserted) { - if((ret = lc_sff_intr_hdlr_byCard(lc_id)) < 0) { - break; - } - } - } - if (ret < 0) { - return ret; - } - return 0; -} -#endif -int lc_dev_hdlr(void) -{ - int ret = 0; - - if ((ret = lc_intr_hdlr()) < 0) { - return ret; - } -#if 0 - if ((ret = lc_sff_intr_hdlr()) < 0) { - return ret; - } -#endif - return 0; -} -static int intr_gpio_init(struct lc_dev_t *mgr) -{ - int ret = 0; - int lc_id = 0; - - if ((ret = gpio_is_valid(mgr->lc_intr_gpio)) < 0) { - - LC_DEV_LOG_ERR("gpio:%d is invalid ret:%d\n", mgr->lc_intr_gpio, ret); - return ret; - } - if ((ret = gpio_direction_input(mgr->lc_intr_gpio)) < 0) { - - LC_DEV_LOG_ERR("gpio:%d set dir fail ret:%d\n", mgr->lc_intr_gpio, ret); - return ret; - } else { - - LC_DEV_LOG_DBG("gpio:%d set dir ok ret:%d\n", mgr->lc_intr_gpio, ret); - } - for (lc_id = 0; lc_id < CARD_NUM; lc_id++) { - - if ((ret = gpio_is_valid(mgr->obj[lc_id].sff_intr_gpio)) < 0) { - - LC_DEV_LOG_ERR("gpio:%d is invalid\n", mgr->obj[lc_id].sff_intr_gpio); - break; - } - } - if (ret < 0) { - return ret; - } - return 0; -} -#if 0 -void intr_gpio_deinit(struct lc_dev_t *mgr) -{ -} -#endif -void lc_dev_deinit(void) -{ - lc_dev_intr_enable(false); - lc_i2c_client_deinit_all(&lcDev); - lc_i2c_clients_destroy(&lcDev); - LC_DEV_LOG_INFO("ok\n"); -} -/*need to run after lc plugged in*/ -int lc_dev_lc_cpld_init(int lc_id) -{ - int ret = 0; - int port_grp = 0; - int mux_l2_id = 0; - - /*line card sff init*/ - for (port_grp = 0; port_grp < PORT_GROUP_NUM; port_grp++) { - - if ((ret = lc_sff_output_bitmap_set(SFF_RESET_TYPE, lc_id, port_grp, lc_sff_output_def[SFF_RESET_TYPE])) < 0) { - break; - } - - if ((ret = lc_sff_output_bitmap_set(SFF_LPMODE_TYPE, lc_id, port_grp, lc_sff_output_def[SFF_LPMODE_TYPE])) < 0) { - break; - } - - if ((ret = lc_sff_output_bitmap_set(SFF_POWER_TYPE, lc_id, port_grp, lc_sff_output_def[SFF_POWER_TYPE])) < 0) { - break; - } - - if ((ret = lc_sff_input_update_byGroup(SFF_PRS_TYPE, lc_id, port_grp)) < 0) { - break; - } - if ((ret = lc_sff_input_update_byGroup(SFF_INT_TYPE, lc_id, port_grp)) < 0) { - break; - } - if ((ret = lc_sff_input_update_byGroup(SFF_OC_TYPE, lc_id, port_grp)) < 0) { - break; - } - } - - if (ret < 0) { - return ret; - } - /*lc mux init*/ - for (mux_l2_id = 0; mux_l2_id < MUX_L2_NUM; mux_l2_id++) { - if ((ret = lc_dev_mux_l2_reset(lc_id, mux_l2_id, 1)) < 0) { - break; - } - } - if (ret < 0) { - return ret; - } - if ((ret = lc_dev_mux_l1_reset(lc_id, 1)) < 0) { - return ret; - } - - return 0; -} - -static int lc_dev_intr_enable(bool on) -{ - int ret = 0; - struct lc_client_t *lc_client = NULL; - u8 reg = 0; - - if (!(lc_client = lc_client_find(&(lcDev.switch_cpld)))) { - return -EBADRQC; - } - - if (on) { - reg = 1; - } else { - reg = 0; - } - - if ((ret = lc_i2c_smbus_write_byte_data(lc_client, SWITCH_CPLD_INTR_EN_OFFSET, reg)) < 0) { - return ret; - } - - return 0; -} - -static int lc_dev_intr_st_update(void) -{ - int ret = 0; - struct lc_client_t *lc_client = NULL; - u8 reg = 0; - - if (!(lc_client = lc_client_find(&(lcDev.switch_cpld)))) { - return -EBADRQC; - } - - if ((ret = lc_i2c_smbus_read_byte_data(lc_client, SWITCH_CPLD_INTR_ST_OFFSET)) < 0) { - return ret; - } - reg = ret; - - LC_DEV_LOG_DBG("reg:0x%x\n", reg); - return 0; -} - -static int lc_dev_intr_st_clear(void) -{ - int ret = 0; - struct lc_client_t *lc_client = NULL; - - if (!(lc_client = lc_client_find(&(lcDev.switch_cpld)))) { - return -EBADRQC; - } - - if ((ret = lc_i2c_smbus_write_byte_data(lc_client, SWITCH_CPLD_INTR_ST_OFFSET, 0)) < 0) { - return ret; - } - return 0; -} - -int lc_dev_init(int platform_id, int io_no_init) -{ - int ret = 0; - (void)platform_id; - (void)io_no_init; - config_load(); - - if (lc_i2c_clients_create(&lcDev) < 0) { - goto err_exit; - } - if (lc_i2c_client_init_all(&lcDev) < 0) { - goto kfree_lc_client; - } - - if (intr_gpio_init(&lcDev) < 0) { - goto deinit_lc_client; - } - if (lc_dev_intr_enable(true) < 0) { - goto deinit_lc_client; - } - if ((ret = lc_st_update()) < 0) { - goto deinit_lc_client; - } - LC_DEV_LOG_INFO("ok\n"); - return 0; -deinit_lc_client: - lc_i2c_client_deinit_all(&lcDev); -kfree_lc_client: - lc_i2c_clients_destroy(&lcDev); -err_exit: - ret = -EBADRQC; - return ret; -} diff --git a/packages/platforms/inventec/x86-64/d7332/modules/builds/src/lc_dev.h b/packages/platforms/inventec/x86-64/d7332/modules/builds/src/lc_dev.h deleted file mode 100644 index 1fc508d52..000000000 --- a/packages/platforms/inventec/x86-64/d7332/modules/builds/src/lc_dev.h +++ /dev/null @@ -1,54 +0,0 @@ -#ifndef __LC_DEV_H -#define __LC_DEV_H - -#define EXTERNAL_RST_DELAY (10) /*ms*/ -typedef enum { - LC_LED_CTRL_OFF = 0, - LC_LED_CTRL_GREEN_ON, - LC_LED_CTRL_RED_ON, - LC_LED_CTRL_AMBER_ON, - LC_LED_CTRL_GREEN_BLINK, - LC_LED_CTRL_RED_BLINK, - LC_LED_CTRL_AMBER_BLINK, - LC_LED_CTRL_NUM, -} lc_led_ctrl_t; - -typedef enum { - LC_UNKNOWN_TYPE = 0, - LC_100G_TYPE, - LC_400G_TYPE, - LC_TYPE_NUM, -} lc_type_t; - -/*function declaration*/ -int lc_dev_lc_cpld_init(int lc_id); -int lc_dev_power_set(int lc_id, bool on); -int lc_dev_power_ready(int lc_id, bool *ready); -void lc_dev_phy_ready(unsigned long bitmap, bool *ready); -int lc_dev_prs_get(unsigned long *bitmap); -int lc_dev_reset_set(int lc_id, u8 lv); -int lc_dev_reset_get(int lc_id, u8 *lv); -int lc_dev_type_get(int lc_id, lc_type_t *type); -int lc_dev_type_get_text(int lc_id, char *buf, int size); -int lc_dev_mux_l1_reset(int lc_id, u8 lv); -bool lc_dev_mux_l1_is_alive(int lc_id); -int lc_dev_mux_l2_reset(int lc_id, int mux_l2_id, u8 lv); -int lc_dev_mux_reset_set(int lc_id, int lv); -int lc_dev_mux_l1_i2c_ch_get(int lc_id); -int lc_dev_led_set(int lc_id, lc_led_ctrl_t ctrl); -int lc_dev_led_st_get(int lc_id, lc_led_ctrl_t *ctrl); -int lc_dev_init(int platform_id, int io_no_init); -void lc_dev_deinit(void); -int lc_dev_hdlr(void); -struct sff_io_driver_t *sff_io_drv_get_lcdev(void); -int lc_dev_over_temp_asserted(int lc_id, bool *asserted); -int lc_dev_over_temp_deasserted(int lc_id, bool *deasserted); -int lc_dev_temp_get_text(int lc_id, char *buf, int size); -int lc_dev_temp_th_get_text(int lc_id, char *buf, int size); -int lc_dev_phy_reset_set(int lc_id, u8 val); -int lc_sff_intr_hdlr_byCard(int lc_id); -int lc_dev_led_boot_amber_set(int lc_id, bool on); -int lc_dev_temp_th_set(int lc_id, int temp); -int lc_dev_ej_r_get(unsigned long *bitmap); -int lc_dev_ej_l_get(unsigned long *bitmap); -#endif /*__LC_DEV_H*/ diff --git a/packages/platforms/inventec/x86-64/d7332/modules/builds/src/onie_tlvinfo.c b/packages/platforms/inventec/x86-64/d7332/modules/builds/src/onie_tlvinfo.c deleted file mode 100644 index 303ffde76..000000000 --- a/packages/platforms/inventec/x86-64/d7332/modules/builds/src/onie_tlvinfo.c +++ /dev/null @@ -1,820 +0,0 @@ -#include -#include -#include -#include -//#include -#include - -//#include -//#include -#include "onie_tlvinfo.h" - -/* Set to 1 if we've read EEPROM into memory */ -static int has_been_read = 0; - -int read_sys_eeprom(struct i2c_client *pi2c_client,void *eeprom_data, int offset, int len); -int write_sys_eeprom(struct i2c_client *pi2c_client, void *eeprom_data, int len); - -static inline int is_multicast_ether_addr(const u_int8_t *addr) -{ - return 0x01 & addr[0]; -} - -static inline int is_zero_ether_addr(const u_int8_t *addr) -{ - return !(addr[0] | addr[1] | addr[2] | addr[3] | addr[4] | addr[5]); -} - -static inline int is_valid_ether_addr(const u_int8_t *addr) -{ - return !is_multicast_ether_addr(addr) && !is_zero_ether_addr(addr); -} - -#if 0 -static unsigned int crc32(unsigned char const *p, unsigned int len) -{ - int i; - unsigned int crc = 0; - while (len--) { - crc ^= *p++; - for (i = 0; i < 8; i++) - crc = (crc >> 1) ^ ((crc & 1) ? 0xedb88320 : 0); - } - return crc; -} -#else -static unsigned long crc32_tab[] = { - 0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f, - 0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988, - 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91, 0x1db71064, 0x6ab020f2, - 0xf3b97148, 0x84be41de, 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7, - 0x136c9856, 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, 0x14015c4f, 0x63066cd9, - 0xfa0f3d63, 0x8d080df5, 0x3b6e20c8, 0x4c69105e, 0xd56041e4, 0xa2677172, - 0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b, 0x35b5a8fa, 0x42b2986c, - 0xdbbbc9d6, 0xacbcf940, 0x32d86ce3, 0x45df5c75, 0xdcd60dcf, 0xabd13d59, - 0x26d930ac, 0x51de003a, 0xc8d75180, 0xbfd06116, 0x21b4f4b5, 0x56b3c423, - 0xcfba9599, 0xb8bda50f, 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924, - 0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d, 0x76dc4190, 0x01db7106, - 0x98d220bc, 0xefd5102a, 0x71b18589, 0x06b6b51f, 0x9fbfe4a5, 0xe8b8d433, - 0x7807c9a2, 0x0f00f934, 0x9609a88e, 0xe10e9818, 0x7f6a0dbb, 0x086d3d2d, - 0x91646c97, 0xe6635c01, 0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e, - 0x6c0695ed, 0x1b01a57b, 0x8208f4c1, 0xf50fc457, 0x65b0d9c6, 0x12b7e950, - 0x8bbeb8ea, 0xfcb9887c, 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, 0xfbd44c65, - 0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2, 0x4adfa541, 0x3dd895d7, - 0xa4d1c46d, 0xd3d6f4fb, 0x4369e96a, 0x346ed9fc, 0xad678846, 0xda60b8d0, - 0x44042d73, 0x33031de5, 0xaa0a4c5f, 0xdd0d7cc9, 0x5005713c, 0x270241aa, - 0xbe0b1010, 0xc90c2086, 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f, - 0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, 0x59b33d17, 0x2eb40d81, - 0xb7bd5c3b, 0xc0ba6cad, 0xedb88320, 0x9abfb3b6, 0x03b6e20c, 0x74b1d29a, - 0xead54739, 0x9dd277af, 0x04db2615, 0x73dc1683, 0xe3630b12, 0x94643b84, - 0x0d6d6a3e, 0x7a6a5aa8, 0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1, - 0xf00f9344, 0x8708a3d2, 0x1e01f268, 0x6906c2fe, 0xf762575d, 0x806567cb, - 0x196c3671, 0x6e6b06e7, 0xfed41b76, 0x89d32be0, 0x10da7a5a, 0x67dd4acc, - 0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5, 0xd6d6a3e8, 0xa1d1937e, - 0x38d8c2c4, 0x4fdff252, 0xd1bb67f1, 0xa6bc5767, 0x3fb506dd, 0x48b2364b, - 0xd80d2bda, 0xaf0a1b4c, 0x36034af6, 0x41047a60, 0xdf60efc3, 0xa867df55, - 0x316e8eef, 0x4669be79, 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236, - 0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f, 0xc5ba3bbe, 0xb2bd0b28, - 0x2bb45a92, 0x5cb36a04, 0xc2d7ffa7, 0xb5d0cf31, 0x2cd99e8b, 0x5bdeae1d, - 0x9b64c2b0, 0xec63f226, 0x756aa39c, 0x026d930a, 0x9c0906a9, 0xeb0e363f, - 0x72076785, 0x05005713, 0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38, - 0x92d28e9b, 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21, 0x86d3d2d4, 0xf1d4e242, - 0x68ddb3f8, 0x1fda836e, 0x81be16cd, 0xf6b9265b, 0x6fb077e1, 0x18b74777, - 0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c, 0x8f659eff, 0xf862ae69, - 0x616bffd3, 0x166ccf45, 0xa00ae278, 0xd70dd2ee, 0x4e048354, 0x3903b3c2, - 0xa7672661, 0xd06016f7, 0x4969474d, 0x3e6e77db, 0xaed16a4a, 0xd9d65adc, - 0x40df0b66, 0x37d83bf0, 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9, - 0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605, 0xcdd70693, - 0x54de5729, 0x23d967bf, 0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94, - 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d -}; - -static unsigned long crc32(unsigned char const *buf, unsigned int size) -{ - unsigned char *p = buf; - unsigned long crc = 0; - - crc = crc ^ ~0U; - - while (size--) - crc = crc32_tab[(crc ^ *p++) & 0xFF] ^ (crc >> 8); - - return crc ^ ~0U; -} -#endif - -static int set_bytes(char *buf, const char *string, int * converted_accum) -{ - char *p = (char *) string; - int i; - uint byte; - - if (!p) { - printk("ERROR: NULL string passed in.\n"); - return -1; - } - /* Convert string to bytes */ - for (i = 0, p = (char *)string; (i < TLV_VALUE_MAX_LEN) && (*p != 0); - i++) { - while ((*p == ' ') || (*p == '\t') || (*p == ',') || - (*p == ';')) { - p++; - } - if (*p != 0) { - if (!isdigit(*p)) { - printk("ERROR: Non-digit found in byte string: (%s)\n", string); - return -1; - } - byte = strtoul(p, &p, 0); - if (byte >= 256) { - printk("ERROR: The value specified is greater than 255: (%u) " \ - "in string: %s\n", byte, string); - return -1; - } - buf[i] = byte & 0xFF; - } - } - if ((i == TLV_VALUE_MAX_LEN) && (*p != 0)) { - printk("ERROR: Trying to assign too many bytes " - "(max: %d) in string: %s\n", TLV_VALUE_MAX_LEN, string); - return -1; - } - *converted_accum = i; - return 0; -} - -/* - * set_date - * - * Validates the format of the data string - * - * This function takes a pointer to a date string (i.e. MM/DD/YYYY hh:mm:ss) - * and validates that the format is correct. If so the string is copied - * to the supplied buffer. - */ -static int set_date(char *buf, const char *string) -{ - int i; - - if (!string) { - printk("ERROR: NULL date string passed in.\n"); - return -1; - } - if (strlen(string) != 19) { - printk("ERROR: Date strlen() != 19 -- %d\n", strlen(string)); - printk("ERROR: Bad date format (MM/DD/YYYY hh:mm:ss): %s\n", string); - return -1; - } - for (i = 0; string[i] != 0; i++) { - switch (i) { - case 2: - case 5: - if (string[i] != '/') { - printk("ERROR: Bad date format (MM/DD/YYYY hh:mm:ss): %s\n", - string); - return -1; - } - break; - case 10: - if (string[i] != ' ') { - printk("ERROR: Bad date format (MM/DD/YYYY hh:mm:ss): %s\n", - string); - return -1; - } - break; - case 13: - case 16: - if (string[i] != ':') { - printk("ERROR: Bad date format (MM/DD/YYYY hh:mm:ss): %s\n", - string); - return -1; - } - break; - default: - if (!isdigit(string[i])) { - printk("ERROR: Bad date format (MM/DD/YYYY hh:mm:ss): %s\n", - string); - return -1; - } - break; - } - } - strcpy(buf, string); - return 0; -} - -/* - * is_valid_tlv - * - * Perform basic sanity checks on a TLV field. The TLV is pointed to - * by the parameter provided. - * 1. The type code is not reserved (0x00 or 0xFF) - */ -static inline bool is_valid_tlv(tlvinfo_tlv_t *tlv) -{ - return((tlv->type != 0x00) && (tlv->type != 0xFF)); -} - -/* - * set_mac - * - * Converts a string MAC address into a binary buffer. - * - * This function takes a pointer to a MAC address string - * (i.e."XX:XX:XX:XX:XX:XX", where "XX" is a two-digit hex number). - * The string format is verified and then converted to binary and - * stored in a buffer. - */ -static int set_mac(char *buf, const char *string) -{ - char *p = (char *) string; - int i; - int err = 0; - char *end; - - if (!p) { - printk("ERROR: NULL mac addr string passed in.\n"); - return -1; - } - if (strlen(p) != 17) { - printk("ERROR: MAC address strlen() != 17 -- %d\n", strlen(p)); - printk("ERROR: Bad MAC address format: %s\n", string); - return -1; - } - for (i = 0; i < 17; i++) { - if ((i % 3) == 2) { - if (p[i] != ':') { - err++; - printk("ERROR: mac: p[%i] != :, found: `%c'\n", - i, p[i]); - break; - } - continue; - } else if (!isxdigit(p[i])) { - err++; - printk("ERROR: mac: p[%i] != hex digit, found: `%c'\n", - i, p[i]); - break; - } - } - if (err != 0) { - printk("ERROR: Bad MAC address format: %s\n", string); - return -1; - } - /* Convert string to binary */ - for (i = 0, p = (char *)string; i < 6; i++) { - buf[i] = p ? strtoul(p, &end, 16) : 0; - if (p) { - p = (*end) ? end + 1 : end; - } - } - if (!is_valid_ether_addr((char *)buf)) { - printk("ERROR: MAC address must not be 00:00:00:00:00:00, " - "a multicast address or FF:FF:FF:FF:FF:FF.\n"); - printk("ERROR: Bad MAC address format: %s\n", string); - return -1; - } - return 0; -} - -/* - * is_valid_tlvinfo_header - * - * Perform sanity checks on the first 11 bytes of the TlvInfo EEPROM - * data pointed to by the parameter: - * 1. First 8 bytes contain null-terminated ASCII string "TlvInfo" - * 2. Version byte is 1 - * 3. Total length bytes contain value which is less than or equal - * to the allowed maximum (2048-11) - * - */ -static inline bool is_valid_tlvinfo_header(tlvinfo_header_t *hdr) -{ - int max_size = TLV_TOTAL_LEN_MAX; - return((strcmp(hdr->signature, TLV_INFO_ID_STRING) == 0) && - (hdr->version == TLV_INFO_VERSION) && - (be16_to_cpu(hdr->totallen) <= max_size) ); -} - -/* - * decode_tlv_value - * - * Decode a single TLV value into a string. - - * The validity of EEPROM contents and the TLV field have been verified - * prior to calling this function. - */ -#define DECODE_NAME_MAX 20 - -static void decode_tlv_value(tlvinfo_tlv_t * tlv, char* value) -{ - int i; - - switch (tlv->type) { - case TLV_CODE_PRODUCT_NAME: - case TLV_CODE_PART_NUMBER: - case TLV_CODE_SERIAL_NUMBER: - case TLV_CODE_MANUF_DATE: - case TLV_CODE_LABEL_REVISION: - case TLV_CODE_PLATFORM_NAME: - case TLV_CODE_ONIE_VERSION: - case TLV_CODE_MANUF_NAME: - case TLV_CODE_MANUF_COUNTRY: - case TLV_CODE_VENDOR_NAME: - case TLV_CODE_DIAG_VERSION: - case TLV_CODE_SERVICE_TAG: - memcpy(value, tlv->value, tlv->length); - value[tlv->length] = 0; - break; - case TLV_CODE_MAC_BASE: - snprintf(value, MAX_STRING_SIZE, "%02X:%02X:%02X:%02X:%02X:%02X", - tlv->value[0], tlv->value[1], tlv->value[2], - tlv->value[3], tlv->value[4], tlv->value[5]); - break; - case TLV_CODE_DEVICE_VERSION: - snprintf(value, MAX_STRING_SIZE, "%u", tlv->value[0]); - break; - case TLV_CODE_MAC_SIZE: - snprintf(value, MAX_STRING_SIZE, "%u", (tlv->value[0] << 8) | tlv->value[1]); - break; - case TLV_CODE_VENDOR_EXT: - value[0] = 0; - for (i = 0; (i < (TLV_DECODE_VALUE_MAX_LEN/5)) && (i < tlv->length); - i++) { - snprintf(value, MAX_STRING_SIZE, "%s 0x%02X", value, tlv->value[i]); - } - break; - case TLV_CODE_CRC_32: - snprintf(value, MAX_STRING_SIZE, "0x%02X%02X%02X%02X", - tlv->value[0], tlv->value[1], tlv->value[2], - tlv->value[3]); - break; - default: - value[0] = 0; - for (i = 0; (i < (TLV_DECODE_VALUE_MAX_LEN/5)) && (i < tlv->length); - i++) { - snprintf(value, MAX_STRING_SIZE, "%s 0x%02X", value, tlv->value[i]); - } - break; - } - -} - -/* - * is_checksum_valid - * - * Validate the checksum in the provided TlvInfo EEPROM data. First, - * verify that the TlvInfo header is valid, then make sure the last - * TLV is a CRC-32 TLV. Then calculate the CRC over the EEPROM data - * and compare it to the value stored in the EEPROM CRC-32 TLV. - */ -static bool is_checksum_valid(u_int8_t *eeprom) -{ - tlvinfo_header_t * eeprom_hdr = (tlvinfo_header_t *) eeprom; - tlvinfo_tlv_t * eeprom_crc; - unsigned int calc_crc; - unsigned int stored_crc; - - // Is the eeprom header valid? - if (!is_valid_tlvinfo_header(eeprom_hdr)) { - return(FALSE); - } - - // Is the last TLV a CRC? - eeprom_crc = (tlvinfo_tlv_t *) &eeprom[sizeof(tlvinfo_header_t) + - be16_to_cpu(eeprom_hdr->totallen) - - (sizeof(tlvinfo_tlv_t) + 4)]; - if ((eeprom_crc->type != TLV_CODE_CRC_32) || (eeprom_crc->length != 4)) { - return(FALSE); - } - - // Calculate the checksum - calc_crc = crc32((void *)eeprom, sizeof(tlvinfo_header_t) + - be16_to_cpu(eeprom_hdr->totallen) - 4); - stored_crc = ((eeprom_crc->value[0] << 24) | (eeprom_crc->value[1] << 16) | - (eeprom_crc->value[2] << 8) | eeprom_crc->value[3]); - - //printk(KERN_ERR "[SWPS] cal_crc =0x%x, stored_crc =0x%x\n", calc_crc, stored_crc); - //return(calc_crc == stored_crc); - return 1; -} - -/* - * update_crc - * - * This function updates the CRC-32 TLV. If there is no CRC-32 TLV, then - * one is added. This function should be called after each update to the - * EEPROM structure, to make sure the CRC is always correct. - */ -static void update_crc(u_int8_t *eeprom) -{ - tlvinfo_header_t * eeprom_hdr = (tlvinfo_header_t *) eeprom; - tlvinfo_tlv_t * eeprom_crc; - unsigned int calc_crc; - - // Is the eeprom header valid? - if (!is_valid_tlvinfo_header(eeprom_hdr)) { - return; - } - // Is the last TLV a CRC? - eeprom_crc = (tlvinfo_tlv_t *) &eeprom[sizeof(tlvinfo_header_t) + - be16_to_cpu(eeprom_hdr->totallen) - - (sizeof(tlvinfo_tlv_t) + 4)]; - if (eeprom_crc->type != TLV_CODE_CRC_32) { - if ((be16_to_cpu(eeprom_hdr->totallen) + sizeof(tlvinfo_tlv_t) + 4) > - TLV_TOTAL_LEN_MAX) { - return; - } - eeprom_crc = (tlvinfo_tlv_t *) &eeprom[sizeof(tlvinfo_header_t) + - be16_to_cpu( - eeprom_hdr->totallen)]; - eeprom_hdr->totallen = cpu_to_be16(be16_to_cpu(eeprom_hdr->totallen) + - sizeof(tlvinfo_tlv_t) + 4); - eeprom_crc->type = TLV_CODE_CRC_32; - } - eeprom_crc->length = 4; - - // Calculate the checksum - calc_crc = crc32((void *)eeprom, - sizeof(tlvinfo_header_t) + - be16_to_cpu(eeprom_hdr->totallen) - 4); - - eeprom_crc->value[0] = (calc_crc >> 24) & 0xFF; - eeprom_crc->value[1] = (calc_crc >> 16) & 0xFF; - eeprom_crc->value[2] = (calc_crc >> 8) & 0xFF; - eeprom_crc->value[3] = (calc_crc >> 0) & 0xFF; -} - -/* - * show_eeprom - * - * Display the contents of the EEPROM - */ - -/* - * read_eeprom - * - * Read the EEPROM into memory, if it hasn't already been read. - */ -int read_eeprom( struct i2c_client *pi2c_client, u_int8_t *eeprom) -{ - int ret; - tlvinfo_header_t *eeprom_hdr = (tlvinfo_header_t *) eeprom; - tlvinfo_tlv_t *eeprom_tlv = (tlvinfo_tlv_t *)&eeprom[ - sizeof(tlvinfo_header_t)]; - - if (has_been_read) - return 0; - - /* Read the header */ - ret = read_sys_eeprom( pi2c_client,(void *)eeprom_hdr, 0, sizeof(tlvinfo_header_t)); - /* If the header was successfully read, read the TLVs */ - if ((ret == 0) && is_valid_tlvinfo_header(eeprom_hdr)) { - ret = read_sys_eeprom( pi2c_client, (void *)eeprom_tlv, sizeof(tlvinfo_header_t), - be16_to_cpu(eeprom_hdr->totallen)); - } - // If the contents are invalid, start over with default contents - if(!is_valid_tlvinfo_header(eeprom_hdr)) - printk(KERN_ERR - "Notice: Invalid TLV header found. Using default contents--1.\n"); - if(!is_checksum_valid(eeprom)) - printk(KERN_ERR - "Notice: Invalid TLV checksum found. Using default contents--2.\n"); - if ( !is_valid_tlvinfo_header(eeprom_hdr) || !is_checksum_valid(eeprom) ){ - strcpy(eeprom_hdr->signature, TLV_INFO_ID_STRING); - eeprom_hdr->version = TLV_INFO_VERSION; - eeprom_hdr->totallen = cpu_to_be16(0); - update_crc(eeprom); - } - has_been_read = 1; - - return ret; -} -EXPORT_SYMBOL(read_eeprom); - -/* - * prog_eeprom - * Write the EEPROM data from CPU memory to the hardware. - */ -int prog_eeprom(struct i2c_client *pi2c_client, u_int8_t * eeprom) -{ - int ret = 0; - tlvinfo_header_t * eeprom_hdr = (tlvinfo_header_t *) eeprom; - int eeprom_len; - - eeprom_len = sizeof(tlvinfo_header_t) + be16_to_cpu(eeprom_hdr->totallen); - ret = write_sys_eeprom( pi2c_client, eeprom, eeprom_len); - if (ret) { - printk("Programming failed.\n"); - return -1; - } - has_been_read = 0; - return 0; -} -EXPORT_SYMBOL(prog_eeprom); - -/* - * tlvinfo_find_tlv - * - * This function finds the TLV with the supplied code in the EERPOM. - * An offset from the beginning of the EEPROM is returned in the - * eeprom_index parameter if the TLV is found. - */ -bool tlvinfo_find_tlv(u_int8_t *eeprom, u_int8_t tcode, - int *eeprom_index) -{ - tlvinfo_header_t * eeprom_hdr = (tlvinfo_header_t *) eeprom; - tlvinfo_tlv_t * eeprom_tlv; - int eeprom_end; - - // Make sure the EEPROM contents are valid - if (!is_valid_tlvinfo_header(eeprom_hdr) || !is_checksum_valid(eeprom)) { - return(FALSE); - } - // Search through the TLVs, looking for the first one which matches the - // supplied type code. - *eeprom_index = sizeof(tlvinfo_header_t); - eeprom_end = sizeof(tlvinfo_header_t) + be16_to_cpu(eeprom_hdr->totallen); - - while (*eeprom_index < eeprom_end) { - eeprom_tlv = (tlvinfo_tlv_t *) &eeprom[*eeprom_index]; - if (!is_valid_tlv(eeprom_tlv)) { - return(FALSE); - } - if (eeprom_tlv->type == tcode) { - return(TRUE); - } - *eeprom_index += sizeof(tlvinfo_tlv_t) + eeprom_tlv->length; - } - return(FALSE); -} - -/* - * tlvinfo_decode_tlv - * - * This function finds the TLV with the supplied code in the EERPOM - * and decodes the value into the buffer provided. - */ -bool tlvinfo_decode_tlv(u_int8_t *eeprom, u_int8_t tcode, char* value) -{ - int eeprom_index; - tlvinfo_tlv_t * eeprom_tlv; - - // Find the TLV and then decode it - - if (tlvinfo_find_tlv(eeprom, tcode, &eeprom_index)) { - eeprom_tlv = (tlvinfo_tlv_t *) &eeprom[eeprom_index]; - decode_tlv_value(eeprom_tlv, value); - return TRUE; - } - - return FALSE; -} -EXPORT_SYMBOL(tlvinfo_decode_tlv); - -/* - * tlvinfo_delete_tlv - * - * This function deletes the TLV with the specified type code from the - * EEPROM. - */ -bool tlvinfo_delete_tlv(u_int8_t * eeprom, u_int8_t code) -{ - int eeprom_index; - int tlength; - tlvinfo_header_t * eeprom_hdr = (tlvinfo_header_t *) eeprom; - tlvinfo_tlv_t * eeprom_tlv; - - // Find the TLV and then move all following TLVs "forward" - if (tlvinfo_find_tlv(eeprom, code, &eeprom_index)) { - eeprom_tlv = (tlvinfo_tlv_t *) &eeprom[eeprom_index]; - tlength = sizeof(tlvinfo_tlv_t) + eeprom_tlv->length; - memcpy(&eeprom[eeprom_index], &eeprom[eeprom_index+tlength], - sizeof(tlvinfo_header_t) + be16_to_cpu(eeprom_hdr->totallen) - - eeprom_index - tlength); - eeprom_hdr->totallen = cpu_to_be16(be16_to_cpu(eeprom_hdr->totallen) - - tlength); - update_crc(eeprom); - return(TRUE); - } - return(FALSE); -} -EXPORT_SYMBOL(tlvinfo_delete_tlv); - -/* - * tlvinfo_add_tlv - * - * This function adds a TLV to the EEPROM, converting the value (a string) to - * the format in which it will be stored in the EEPROM. - */ -#define MAX_TLV_VALUE_LEN 256 -bool tlvinfo_add_tlv(u_int8_t * eeprom, int tcode, char * strval) -{ - tlvinfo_header_t * eeprom_hdr = (tlvinfo_header_t *) eeprom; - tlvinfo_tlv_t * eeprom_tlv; - int new_tlv_len = 0; - u_int32_t value; - char data[MAX_TLV_VALUE_LEN]; - int eeprom_index; - int max_size = TLV_TOTAL_LEN_MAX; - - // Encode each TLV type into the format to be stored in the EERPOM - switch (tcode) { - case TLV_CODE_PRODUCT_NAME: - case TLV_CODE_PART_NUMBER: - case TLV_CODE_SERIAL_NUMBER: - case TLV_CODE_LABEL_REVISION: - case TLV_CODE_PLATFORM_NAME: - case TLV_CODE_ONIE_VERSION: - case TLV_CODE_MANUF_NAME: - case TLV_CODE_MANUF_COUNTRY: - case TLV_CODE_VENDOR_NAME: - case TLV_CODE_DIAG_VERSION: - case TLV_CODE_SERVICE_TAG: - strncpy(data, strval, MAX_TLV_VALUE_LEN); - - if( strlen(strval) >= MAX_TLV_VALUE_LEN ) - new_tlv_len = MAX_TLV_VALUE_LEN; - else - new_tlv_len = strlen(strval); - - break; - case TLV_CODE_DEVICE_VERSION: - value = strtoul(strval, NULL, 0); - if (value >= 256) { - printk("ERROR: Device version must be 255 or less. Value " \ - "supplied: %u", value); - return(FALSE); - } - data[0] = value & 0xFF; - new_tlv_len = 1; - break; - case TLV_CODE_MAC_SIZE: - value = strtoul(strval, NULL, 0); - if (value >= 65536) { - printk("ERROR: MAC Size must be 65535 or less. Value " \ - "supplied: %u", value); - return(FALSE); - } - data[0] = (value >> 8) & 0xFF; - data[1] = value & 0xFF; - new_tlv_len = 2; - break; - case TLV_CODE_MANUF_DATE: - if (set_date(data, strval) != 0) { - return(FALSE); - } - new_tlv_len = 19; - break; - case TLV_CODE_MAC_BASE: - if (set_mac(data, strval) != 0) { - return(FALSE); - } - new_tlv_len = 6; - break; - case TLV_CODE_CRC_32: - printk("WARNING: The CRC TLV is set automatically and cannot be set " \ - "manually.\n"); - return(FALSE); - case TLV_CODE_VENDOR_EXT: - default: - if (set_bytes(data, strval, &new_tlv_len) != 0 ) { - return(FALSE); - } - break; - } - - // Is there room for this TLV? - if ((be16_to_cpu(eeprom_hdr->totallen) + sizeof(tlvinfo_tlv_t) + - new_tlv_len) > max_size) { - printk("ERROR: There is not enough room in the EERPOM to save data.\n"); - return(FALSE); - } - - // Add TLV at the end, overwriting CRC TLV if it exists - if (tlvinfo_find_tlv(eeprom, TLV_CODE_CRC_32, &eeprom_index)) { - eeprom_hdr->totallen = cpu_to_be16(be16_to_cpu(eeprom_hdr->totallen) - - sizeof(tlvinfo_tlv_t) - 4); - } else { - eeprom_index = sizeof(tlvinfo_header_t) + - be16_to_cpu(eeprom_hdr->totallen); - } - eeprom_tlv = (tlvinfo_tlv_t *) &eeprom[eeprom_index]; - eeprom_tlv->type = tcode; - eeprom_tlv->length = new_tlv_len; - memcpy(eeprom_tlv->value, data, new_tlv_len); - - // Update the total length and calculate (add) a new CRC-32 TLV - eeprom_hdr->totallen = cpu_to_be16(be16_to_cpu(eeprom_hdr->totallen) + - sizeof(tlvinfo_tlv_t) + new_tlv_len); - update_crc(eeprom); - - return(TRUE); -} -EXPORT_SYMBOL(tlvinfo_add_tlv); - -/* - * read_sys_eeprom - read the hwinfo from i2c EEPROM - */ -int read_sys_eeprom(struct i2c_client *pi2c_client,void *eeprom_data, int offset, int len) -{ - int iRet = 0; - int i = 0; - unsigned char ucBuf[2]; - u_int8_t *c; - unsigned short usAddr = SYS_EEPROM_OFFSET + offset; - - c = eeprom_data; - for (i = 0; i < len; i++) { - ucBuf[0] = (usAddr & 0xFF00) >> 8; - ucBuf[1] = (usAddr & 0x00FF); - - iRet = i2c_smbus_write_byte_data(pi2c_client, ucBuf[0], ucBuf[1]); - if( iRet < 0 ){ - printk(KERN_ERR"Error!! VPD data read error\n"); - return -1; - } - - *c = i2c_smbus_read_byte(pi2c_client); - c++; usAddr++; - } - return 0; -} - -/* - * write_sys_eeprom - write the hwinfo to i2c EEPROM - */ -int write_sys_eeprom(struct i2c_client *pi2c_client, void *eeprom_data, int len) -{ - int iRet = 0; - int i = 0; - u_int8_t *c; - unsigned short usAddr = SYS_EEPROM_OFFSET; - unsigned char ucBuf[3]; - - c = eeprom_data; - for (i = 0; i < len; i++) { - ucBuf[ 0 ] = (usAddr & 0xFF00) >>8 ; - ucBuf[ 1 ] = (usAddr & 0x00FF); - ucBuf[ 2 ] = *c; - - iRet = i2c_smbus_write_word_data( pi2c_client, ucBuf[0], (ucBuf[2] << 8 | ucBuf[1])); - if (iRet < 0 ){ - printk(KERN_ERR"Error!! VPD data write error . \n"); - return -1; - } - - c++; usAddr++; - msleep_interruptible(10); - } - - return 0; -} - -void update_eeprom_header(u_int8_t *eeprom) -{ - tlvinfo_header_t * eeprom_hdr = (tlvinfo_header_t *) eeprom; - - strcpy(eeprom_hdr->signature, TLV_INFO_ID_STRING); - eeprom_hdr->version = TLV_INFO_VERSION; - eeprom_hdr->totallen = cpu_to_be16(0); - update_crc(eeprom); -} -#if 0 -int find_vpd_data(u_int8_t *eeprom, int i_offset, char *c_buf) -{ - int tlv_end; - int curr_tlv; - tlvinfo_header_t * eeprom_hdr = (tlvinfo_header_t *) eeprom; - tlvinfo_tlv_t * eeprom_tlv; - int iFind = 0; - - if( !is_valid_tlvinfo_header(eeprom_hdr) ) { - printk(KERN_ERR"EEPROM does not contain data in a valid TlvInfo format.\n"); - return -1; - } - - curr_tlv = sizeof(tlvinfo_header_t); - tlv_end = sizeof(tlvinfo_header_t) + be16_to_cpu(eeprom_hdr->totallen); - while(curr_tlv < tlv_end){ - eeprom_tlv = (tlvinfo_tlv_t *) &eeprom[curr_tlv]; - if (!is_valid_tlv(eeprom_tlv)) { - printk(KERN_ERR"Invalid TLV field starting at EEPROM offset %d\n", - curr_tlv); - return -1; - } - - decode_tlv_value(eeprom_tlv, c_buf); - if( eeprom_tlv->type == i_offset){ - iFind = 1; - break; - } - curr_tlv += sizeof(tlvinfo_tlv_t) + eeprom_tlv->length; - } - - if( iFind == 0 ) - return -1; - else - return 0; -} -#endif diff --git a/packages/platforms/inventec/x86-64/d7332/modules/builds/src/onie_tlvinfo.h b/packages/platforms/inventec/x86-64/d7332/modules/builds/src/onie_tlvinfo.h deleted file mode 100644 index 74f3c9604..000000000 --- a/packages/platforms/inventec/x86-64/d7332/modules/builds/src/onie_tlvinfo.h +++ /dev/null @@ -1,150 +0,0 @@ -/* - * The Definition of the TlvInfo EEPROM format can be found at onie.org or - * github.com/onie - */ -#include -#define strtoul simple_strtoul - -#define FALSE 0 -#define TRUE (!FALSE) -#define MAX_STRING_SIZE 128 -/* - * Tlvinf header: Layout of the header for the TlvInfo format - * - * See the end of this file for details of this eeprom format - */ -struct __attribute__ ((__packed__)) tlvinfo_header_s { - char signature[8]; /* 0x00 - 0x07 EEPROM Tag "TlvInfo" */ - u_int8_t version; /* 0x08 Structure version */ - u_int16_t totallen; /* 0x09 - 0x0A Length of all data which follows */ -}; -typedef struct tlvinfo_header_s tlvinfo_header_t; - -// Header Field Constants -#define TLV_INFO_ID_STRING "TlvInfo" -#define TLV_INFO_VERSION 0x01 -#define TLV_TOTAL_LEN_MAX (SYS_EEPROM_SIZE - sizeof(tlvinfo_header_t)) - -/* - * TlvInfo TLV: Layout of a TLV field - */ -struct __attribute__ ((__packed__)) tlvinfo_tlv_s { - u_int8_t type; - u_int8_t length; - u_int8_t value[0]; -}; -typedef struct tlvinfo_tlv_s tlvinfo_tlv_t; - -/* Maximum length of a TLV value in bytes */ -#define TLV_VALUE_MAX_LEN 255 - -/** - * The TLV Types. - * - * Keep these in sync with tlv_code_list in cmd_sys_eeprom.c - */ -#define TLV_CODE_PRODUCT_NAME 0x21 -#define TLV_CODE_PART_NUMBER 0x22 -#define TLV_CODE_SERIAL_NUMBER 0x23 -#define TLV_CODE_MAC_BASE 0x24 -#define TLV_CODE_MANUF_DATE 0x25 -#define TLV_CODE_DEVICE_VERSION 0x26 -#define TLV_CODE_LABEL_REVISION 0x27 -#define TLV_CODE_PLATFORM_NAME 0x28 -#define TLV_CODE_ONIE_VERSION 0x29 -#define TLV_CODE_MAC_SIZE 0x2A -#define TLV_CODE_MANUF_NAME 0x2B -#define TLV_CODE_MANUF_COUNTRY 0x2C -#define TLV_CODE_VENDOR_NAME 0x2D -#define TLV_CODE_DIAG_VERSION 0x2E -#define TLV_CODE_SERVICE_TAG 0x2F -#define TLV_CODE_VENDOR_EXT 0xFD -#define TLV_CODE_CRC_32 0xFE - -/* - * Struct for displaying the TLV codes and names. - */ -struct tlv_code_desc { - u_int8_t m_code; - char* m_name; -}; - -/* - * List of TLV codes and names. - */ -static const struct tlv_code_desc tlv_code_list[] = { - { TLV_CODE_PRODUCT_NAME , "Product Name"}, - { TLV_CODE_PART_NUMBER , "Part Number"}, - { TLV_CODE_SERIAL_NUMBER , "Serial Number"}, - { TLV_CODE_MAC_BASE , "Base MAC Address"}, - { TLV_CODE_MANUF_DATE , "Manufacture Date"}, - { TLV_CODE_DEVICE_VERSION , "Device Version"}, - { TLV_CODE_LABEL_REVISION , "Label Revision"}, - { TLV_CODE_PLATFORM_NAME , "Platform Name"}, - { TLV_CODE_ONIE_VERSION , "Loader Version"}, - { TLV_CODE_MAC_SIZE , "MAC Addresses"}, - { TLV_CODE_MANUF_NAME , "Manufacturer"}, - { TLV_CODE_MANUF_COUNTRY , "Country Code"}, - { TLV_CODE_VENDOR_NAME , "Vendor Name"}, - { TLV_CODE_DIAG_VERSION , "Diag Version"}, - { TLV_CODE_SERVICE_TAG , "Service Tag"}, - { TLV_CODE_VENDOR_EXT , "Vendor Extension"}, - { TLV_CODE_CRC_32 , "CRC-32"}, -}; - -static inline const char* tlv_type2name(u_int8_t type) -{ - char* name = "Unknown"; - int i; - - for (i = 0; i < sizeof(tlv_code_list)/sizeof(tlv_code_list[0]); i++) { - if (tlv_code_list[i].m_code == type) { - name = tlv_code_list[i].m_name; - break; - } - } - return name; -} - -/* - * The max decode value is currently for the 'raw' type or the 'vendor - * extension' type, both of which have the same decode format. The - * max decode string size is computed as follows: - * - * strlen(" 0xFF") * TLV_VALUE_MAX_LEN + 1 - * - */ -#define TLV_DECODE_VALUE_MAX_LEN ((5 * TLV_VALUE_MAX_LEN) + 1) - - -/* - * Each platform must define the following platform-specific macros - * in sys_eeprom_platform.h: - * SYS_EEPROM_SIZE: size of usable eeprom - * SYS_EEPROM_I2C_DEVICE: i2c-bus - * SYS_EEPROM_I2C_ADDR: address on the bus - * The following may also be defined in sys_eeprom_platform.h, else - * the defaults with take over: - * SYS_EEPROM_MAX_SIZE: Total size of the eeprom - * SYS_EEPROM_OFFSET: offset from where the ONIE header starts - */ -#define SYS_EEPROM_MAX_SIZE 2048 -#define SYS_EEPROM_OFFSET 0 -#define SYS_EEPROM_SIZE SYS_EEPROM_MAX_SIZE -#define SYS_EEPROM_I2C_DEVICE "/dev/i2c-0" -#define SYS_EEPROM_I2C_ADDR 0x53 - -#if (SYS_EEPROM_SIZE + SYS_EEPROM_OFFSET > SYS_EEPROM_MAX_SIZE) - #error SYS_EEPROM_SIZE + SYS_EEPROM_OFFSET is greater than SYS_EEPROM_MAX_SIZE -#endif - -// Access functions to onie_tlvinfo -void show_eeprom(u_int8_t *eeprom); -int read_eeprom(struct i2c_client *pi2c_client, u_int8_t *eeprom); -int prog_eeprom(struct i2c_client *pi2c_client,u_int8_t * eeprom); -void update_eeprom_header(u_int8_t *eeprom); -bool tlvinfo_find_tlv(u_int8_t *eeprom, u_int8_t tcode, int *eeprom_index); -bool tlvinfo_delete_tlv(u_int8_t * eeprom, u_int8_t code); -bool tlvinfo_add_tlv(u_int8_t * eeprom, int tcode, char * strval); -bool tlvinfo_decode_tlv(u_int8_t *eeprom, u_int8_t tcode, char* value); -//int find_vpd_data(u_int8_t *eeprom, int i_offset, char *c_buf); diff --git a/packages/platforms/inventec/x86-64/d7332/modules/builds/src/pltfm_info.h b/packages/platforms/inventec/x86-64/d7332/modules/builds/src/pltfm_info.h deleted file mode 100644 index 784a2349b..000000000 --- a/packages/platforms/inventec/x86-64/d7332/modules/builds/src/pltfm_info.h +++ /dev/null @@ -1,38 +0,0 @@ -#ifndef __PLTFM_CONFIG -#define __PLTFM_CONFIG - -#include "port_info/port_info_banyan.h" -#include "port_info/port_info_maple.h" -//#include "port_info/port_info_cedar.h" -#include "port_info/port_info_4U.h" - -struct platform_info_t { - int id; - char *name; - struct port_info_table_t *tbl_1st; - struct port_info_table_t *tbl_2nd; - int lc_num; -}; - -struct platform_info_t platform_info_tbl[] = { - - {.id = PLATFORM_MAPLE, - .name = "MAPLE", - .tbl_1st = &maple_port_info_table, - .tbl_2nd = NULL, - .lc_num = 1}, - - {.id = PLATFORM_BANYAN, - .name = "BANYAN", - .tbl_1st = &banyan_port_info_table, - .tbl_2nd = NULL, - .lc_num = 1}, - {.id = PLATFORM_4U, - .name = "BANYAN_4U", - .tbl_1st = &port_info_4U_table1, - .tbl_2nd = &port_info_4U_table2, - .lc_num = 4}, - - {.id = PLATFORM_END, }, /*keep this at the end of table*/ -}; -#endif /*__PLTFM_CONFIG*/ diff --git a/packages/platforms/inventec/x86-64/d7332/modules/builds/src/port_info/port_info_4U.h b/packages/platforms/inventec/x86-64/d7332/modules/builds/src/port_info/port_info_4U.h deleted file mode 100644 index 1ae71ac68..000000000 --- a/packages/platforms/inventec/x86-64/d7332/modules/builds/src/port_info/port_info_4U.h +++ /dev/null @@ -1,97 +0,0 @@ -#ifndef __PORT_INFO_CONFIG_4U -#define __PORT_INFO_CONFIG_4U - -struct port_info_map_t port_info_4U_map1[] = { -#if 1 - {1, QSFP_TYPE, "port2"}, - {0, QSFP_TYPE, "port1"}, - {3, QSFP_TYPE, "port4"}, - {2, QSFP_TYPE, "port3"}, - {5, QSFP_TYPE, "port6"}, - {4, QSFP_TYPE, "port5"}, - {7, QSFP_TYPE, "port8"}, - {6, QSFP_TYPE, "port7"}, - {9, QSFP_TYPE, "port10"}, - {8, QSFP_TYPE, "port9"}, - {11, QSFP_TYPE, "port12"}, - {10, QSFP_TYPE, "port11"}, - {13, QSFP_TYPE, "port14"}, - {12, QSFP_TYPE, "port13"}, - {15, QSFP_TYPE, "port16"}, - {14, QSFP_TYPE, "port15"}, - {17, QSFP_TYPE, "port18"}, - {16, QSFP_TYPE, "port17"}, - {19, QSFP_TYPE, "port20"}, - {18, QSFP_TYPE, "port19"}, - {21, QSFP_TYPE, "port22"}, - {20, QSFP_TYPE, "port21"}, - {23, QSFP_TYPE, "port24"}, - {22, QSFP_TYPE, "port23"}, - {25, QSFP_TYPE, "port26"}, - {24, QSFP_TYPE, "port25"}, - {27, QSFP_TYPE, "port28"}, - {26, QSFP_TYPE, "port27"}, - {29, QSFP_TYPE, "port30"}, - {28, QSFP_TYPE, "port29"}, - {31, QSFP_TYPE, "port32"}, - {30, QSFP_TYPE, "port31"}, - -#else - {1, SFP_TYPE, "port2"}, - {0, SFP_TYPE, "port1"}, - {3, SFP_TYPE, "port4"}, - {2, SFP_TYPE, "port3"}, - {5, SFP_TYPE, "port6"}, - {4, SFP_TYPE, "port5"}, - {7, SFP_TYPE, "port8"}, - {6, SFP_TYPE, "port7"}, - {9, SFP_TYPE, "port10"}, - {8, SFP_TYPE, "port9"}, - {11, SFP_TYPE, "port12"}, - {10, SFP_TYPE, "port11"}, - {13, SFP_TYPE, "port14"}, - {12, SFP_TYPE, "port13"}, - {15, SFP_TYPE, "port16"}, - {14, SFP_TYPE, "port15"}, - {17, SFP_TYPE, "port18"}, - {16, SFP_TYPE, "port17"}, - {19, SFP_TYPE, "port20"}, - {18, SFP_TYPE, "port19"}, - {21, SFP_TYPE, "port22"}, - {20, SFP_TYPE, "port21"}, - {23, SFP_TYPE, "port24"}, - {22, SFP_TYPE, "port23"}, - {25, SFP_TYPE, "port26"}, - {24, SFP_TYPE, "port25"}, - {27, SFP_TYPE, "port28"}, - {26, SFP_TYPE, "port27"}, - {29, SFP_TYPE, "port30"}, - {28, SFP_TYPE, "port29"}, - {31, SFP_TYPE, "port32"}, - {30, SFP_TYPE, "port31"}, - -#endif - -}; - -struct port_info_map_t port_info_4U_map2[] = { - - {1, QSFP_TYPE, "port2"}, - {0, QSFP_TYPE, "port1"}, - {3, QSFP_TYPE, "port4"}, - {2, QSFP_TYPE, "port3"}, - {5, QSFP_TYPE, "port6"}, - {4, QSFP_TYPE, "port5"}, - {7, QSFP_TYPE, "port8"}, - {6, QSFP_TYPE, "port7"}, -}; -struct port_info_table_t port_info_4U_table1 = { - .map = port_info_4U_map1, - .size = ARRAY_SIZE(port_info_4U_map1), -}; - -struct port_info_table_t port_info_4U_table2 = { - .map = port_info_4U_map2, - .size = ARRAY_SIZE(port_info_4U_map2), -}; -#endif /*__PORT_INFO_CONFIG_4U*/ diff --git a/packages/platforms/inventec/x86-64/d7332/modules/builds/src/port_info/port_info_banyan.h b/packages/platforms/inventec/x86-64/d7332/modules/builds/src/port_info/port_info_banyan.h deleted file mode 100644 index 01c2fe159..000000000 --- a/packages/platforms/inventec/x86-64/d7332/modules/builds/src/port_info/port_info_banyan.h +++ /dev/null @@ -1,47 +0,0 @@ -//port info - -//i2c_eeprom_config_cypress -#ifndef __PORT_INFO_CONFIG_BANYAN -#define __PORT_INFO_CONFIG_BANYAN - -struct port_info_map_t banyan_port_info_map[] = { - {0, QSFP_DD_TYPE, "port1"}, - {1, QSFP_DD_TYPE, "port2"}, - {2, QSFP_DD_TYPE, "port3"}, - {3, QSFP_DD_TYPE, "port4"}, - {4, QSFP_DD_TYPE, "port5"}, - {5, QSFP_DD_TYPE, "port6"}, - {6, QSFP_DD_TYPE, "port7"}, - {7, QSFP_DD_TYPE, "port8"}, - {8, QSFP_DD_TYPE, "port9"}, - {9, QSFP_DD_TYPE, "port10"}, - {10, QSFP_DD_TYPE, "port11"}, - {11, QSFP_DD_TYPE, "port12"}, - {12, QSFP_DD_TYPE, "port13"}, - {13, QSFP_DD_TYPE, "port14"}, - {14, QSFP_DD_TYPE, "port15"}, - {15, QSFP_DD_TYPE, "port16"}, - {16, QSFP_DD_TYPE, "port17"}, - {17, QSFP_DD_TYPE, "port18"}, - {18, QSFP_DD_TYPE, "port19"}, - {19, QSFP_DD_TYPE, "port20"}, - {20, QSFP_DD_TYPE, "port21"}, - {21, QSFP_DD_TYPE, "port22"}, - {22, QSFP_DD_TYPE, "port23"}, - {23, QSFP_DD_TYPE, "port24"}, - {24, QSFP_DD_TYPE, "port25"}, - {25, QSFP_DD_TYPE, "port26"}, - {26, QSFP_DD_TYPE, "port27"}, - {27, QSFP_DD_TYPE, "port28"}, - {28, QSFP_DD_TYPE, "port29"}, - {29, QSFP_DD_TYPE, "port30"}, - {30, QSFP_DD_TYPE, "port31"}, - {31, QSFP_DD_TYPE, "port32"}, -}; - -struct port_info_table_t banyan_port_info_table = { - .map = banyan_port_info_map, - .size = ARRAY_SIZE(banyan_port_info_map), -}; - -#endif /*__PORT_INFO_CONFIG_BANYAN*/ diff --git a/packages/platforms/inventec/x86-64/d7332/modules/builds/src/port_info/port_info_maple.h b/packages/platforms/inventec/x86-64/d7332/modules/builds/src/port_info/port_info_maple.h deleted file mode 100644 index 5f5941e4b..000000000 --- a/packages/platforms/inventec/x86-64/d7332/modules/builds/src/port_info/port_info_maple.h +++ /dev/null @@ -1,68 +0,0 @@ -#ifndef __PORT_INFO_CONFIG_MAPLE -#define __PORT_INFO_CONFIG_MAPLE - -struct port_info_map_t maple_port_info_map[] = { - {1, SFP_TYPE, "port2"}, - {0, SFP_TYPE, "port1"}, - {3, SFP_TYPE, "port4"}, - {2, SFP_TYPE, "port3"}, - {5, SFP_TYPE, "port6"}, - {4, SFP_TYPE, "port5"}, - {7, SFP_TYPE, "port8"}, - {6, SFP_TYPE, "port7"}, - {9, SFP_TYPE, "port10"}, - {8, SFP_TYPE, "port9"}, - {11, SFP_TYPE, "port12"}, - {10, SFP_TYPE, "port11"}, - {13, SFP_TYPE, "port14"}, - {12, SFP_TYPE, "port13"}, - {15, SFP_TYPE, "port16"}, - {14, SFP_TYPE, "port15"}, - {17, SFP_TYPE, "port18"}, - {16, SFP_TYPE, "port17"}, - {19, SFP_TYPE, "port20"}, - {18, SFP_TYPE, "port19"}, - {21, SFP_TYPE, "port22"}, - {20, SFP_TYPE, "port21"}, - {23, SFP_TYPE, "port24"}, - {22, SFP_TYPE, "port23"}, - {25, SFP_TYPE, "port26"}, - {24, SFP_TYPE, "port25"}, - {27, SFP_TYPE, "port28"}, - {26, SFP_TYPE, "port27"}, - {29, SFP_TYPE, "port30"}, - {28, SFP_TYPE, "port29"}, - {31, SFP_TYPE, "port32"}, - {30, SFP_TYPE, "port31"}, - {33, SFP_TYPE, "port34"}, - {32, SFP_TYPE, "port33"}, - {35, SFP_TYPE, "port36"}, - {34, SFP_TYPE, "port35"}, - {37, SFP_TYPE, "port38"}, - {36, SFP_TYPE, "port37"}, - {39, SFP_TYPE, "port40"}, - {38, SFP_TYPE, "port39"}, - {41, SFP_TYPE, "port42"}, - {40, SFP_TYPE, "port41"}, - {43, SFP_TYPE, "port44"}, - {42, SFP_TYPE, "port43"}, - {45, SFP_TYPE, "port46"}, - {44, SFP_TYPE, "port45"}, - {47, SFP_TYPE, "port48"}, - {46, SFP_TYPE, "port47"}, - {49, QSFP_TYPE, "port50"}, - {48, QSFP_TYPE, "port49"}, - {51, QSFP_TYPE, "port52"}, - {50, QSFP_TYPE, "port51"}, - {53, QSFP_TYPE, "port54"}, - {52, QSFP_TYPE, "port53"}, - {55, QSFP_TYPE, "port56"}, - {54, QSFP_TYPE, "port55"}, -}; - -struct port_info_table_t maple_port_info_table = { - .map = maple_port_info_map, - .size = ARRAY_SIZE(maple_port_info_map), -}; - -#endif /*__PORT_INFO_CONFIG_MAPLE*/ diff --git a/packages/platforms/inventec/x86-64/d7332/modules/builds/src/qsfp.c b/packages/platforms/inventec/x86-64/d7332/modules/builds/src/qsfp.c deleted file mode 100644 index d2a722057..000000000 --- a/packages/platforms/inventec/x86-64/d7332/modules/builds/src/qsfp.c +++ /dev/null @@ -1,1204 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "inv_swps.h" -#include "qsfp.h" - -#define QSFP_ID_OFFSET (0) -#define QSFP_ST_INDICATOR2_OFFSET (2) -#define DATA_NOT_READY_BIT (0) -#define FLAT_MEM_BIT (2) -#define QSFP_ETH_COMP_OFFSET (131) -#define QSFP_ETH_EXT_COMP_OFFSET (192) -#define QSFP_VCC_OFFSET (26) -#define QSFP_TEMP_OFFSET (22) -#define QSFP_EXT_ID_OFFSET (129) -#define CDR_RX_PRS_BIT (2) -#define CDR_TX_PRS_BIT (3) -#define QSFP_LN_RX_PWR_OFFSET (34) -#define QSFP_LN_TX_PWR_OFFSET (50) -#define QSFP_LN_TX_BIAS_OFFSET (42) -#define QSFP_PAGE_SEL_OFFSET (127) - -#define QSFP_OPT_LN_CONTROL_TX_EQ_OFFSET (234) -#define QSFP_OPT_LN_CONTROL_RX_EM_OFFSET (236) -#define QSFP_OPT_LN_CONTROL_RX_AM_OFFSET (238) -#define QSFP_CDR_CONTROL_OFFSET (98) -#define QSFP_LN_TX_DISABLE_OFFSET (86) - -#define QSFP_VENDOR_NAME_OFFSET (148) -#define QSFP_VENDOR_PN_OFFSET (168) -#define QSFP_VENDOR_SN_OFFSET (196) -#define QSFP_VENDOR_REV_OFFSET (184) - -#define QSFP_VENDOR_NAME_LEN (16) -#define QSFP_VENDOR_PN_LEN (16) -#define QSFP_VENDOR_SN_LEN (16) -#define QSFP_VENDOR_REV_LEN (2) - - - - -extern u32 logLevel; -extern bool int_flag_monitor_en; -static int qsfp_int_flag_read(struct sff_obj_t *sff_obj); - -int qsfp_vendor_info_get(struct sff_obj_t *sff_obj, int type, u8 *buf, int buf_size); -int qsfp_temperature_get(struct sff_obj_t *sff_obj, u8 *buf, int buf_size); -int qsfp_voltage_get(struct sff_obj_t *sff_obj, u8 *buf, int buf_size); -int qsfp_lane_status_get(struct sff_obj_t *sff_obj, int type, u8 *value); -int qsfp_lane_monitor_get(struct sff_obj_t *sff_obj, int type, u8 *buf, int buf_size); -int qsfp_lane_control_set(struct sff_obj_t *sff_obj, int type, u32 value); -int qsfp_lane_control_get(struct sff_obj_t *sff_obj, int type, u32 *value); -int qsfp_tx_disable_set(struct sff_obj_t *sff_obj, u8 value); -int qsfp_tx_disable_get(struct sff_obj_t *sff_obj, u8 *value); -int qsfp_id_get(struct sff_obj_t *sff_obj, u8 *id); -int qsfp_eeprom_dump(struct sff_obj_t *sff_obj, u8 *buf); -int qsfp_page_sel(struct sff_obj_t *sff_obj, int page); -int qsfp_page_get(struct sff_obj_t *sff_obj, u8 *page); -bool qsfp_is_id_matched(struct sff_obj_t *sff_obj); -static int qsfp_lpmode_set(struct sff_obj_t *sff_obj, u8 value); -static int qsfp_lpmode_get(struct sff_obj_t *sff_obj, u8 *value); -static int qsfp_intL_get(struct sff_obj_t *sff_obj, u8 *value); -static int qsfp_reset_set(struct sff_obj_t *sff_obj, u8 value); -static int qsfp_reset_get(struct sff_obj_t *sff_obj, u8 *value); -static int mode_sel_set(struct sff_obj_t *sff_obj, u8 value); -static int mode_sel_get(struct sff_obj_t *sff_obj, u8 *value); - -const u8 Qsfp_Eth_Comp_Table[] = { - ACTIVE_CABLE, - LR4_40GBASE, - SR4_40GBASE, - CR4_40GBASE, - /*10G Ethernet Compliance Codes*/ - SR_10GBASE, - LR_10GBASE, - LRM_10GBASE, - ER_10GBASE,/*COMPLIANCE_RSVD*/ -}; - -struct func_tbl_t qsfp_func_tbl = { - .eeprom_read = sff_eeprom_read, - .eeprom_write = sff_eeprom_write, - .prs_get = sff_prs_get, - .lpmode_set = qsfp_lpmode_set, - .lpmode_get = qsfp_lpmode_get, - .reset_set = qsfp_reset_set, - .reset_get = qsfp_reset_get, - .power_set = sff_power_set, - .power_get = sff_power_get, - .mode_sel_set = mode_sel_set, - .mode_sel_get = mode_sel_get, - .intL_get = qsfp_intL_get, - .tx_disable_set = qsfp_tx_disable_set, - .tx_disable_get = qsfp_tx_disable_get, - .temperature_get = qsfp_temperature_get, - .voltage_get = qsfp_voltage_get, - .lane_control_set = qsfp_lane_control_set, - .lane_control_get = qsfp_lane_control_get, - .lane_monitor_get = qsfp_lane_monitor_get, - .vendor_info_get = qsfp_vendor_info_get, - .lane_status_get = qsfp_lane_status_get, - .module_st_get = dummy_module_st_get, - .id_get = qsfp_id_get, - .is_id_matched = qsfp_is_id_matched, - .eeprom_dump = qsfp_eeprom_dump, - .page_sel = qsfp_page_sel, - .page_get = qsfp_page_get, -}; -struct func_tbl_t *qsfp_func_load(void) -{ - return &qsfp_func_tbl; -} -static int qsfp_paging_supported(struct sff_obj_t *sff_obj, bool *supported); -static int _page_switch(struct sff_obj_t *sff_obj, u8 page); - -static int qsfp_lpmode_set(struct sff_obj_t *sff_obj, u8 value) -{ - int ret = 0; - check_pfunc(sff_obj->mgr->io_drv->lpmode_set); - if ((ret = sff_obj->mgr->io_drv->lpmode_set(sff_obj->lc_id, sff_obj->port, value)) < 0) { - return ret; - } - return 0; -} -static int qsfp_lpmode_get(struct sff_obj_t *sff_obj, u8 *value) -{ - int ret = 0; - - check_pfunc(sff_obj->mgr->io_drv->lpmode_get); - if ((ret = sff_obj->mgr->io_drv->lpmode_get(sff_obj->lc_id, sff_obj->port, value)) < 0) { - return ret; - } - return 0; -} -static int mode_sel_set(struct sff_obj_t *sff_obj, u8 value) -{ - int ret = 0; - - check_pfunc(sff_obj->mgr->io_drv->mode_sel_set); - if ((ret = sff_obj->mgr->io_drv->mode_sel_set(sff_obj->lc_id, sff_obj->port, value)) < 0) { - return ret; - } - return 0; - -} -static int mode_sel_get(struct sff_obj_t *sff_obj, u8 *value) -{ - int ret = 0; - - check_pfunc(sff_obj->mgr->io_drv->mode_sel_get); - if ((ret = sff_obj->mgr->io_drv->mode_sel_get(sff_obj->lc_id, sff_obj->port, value)) < 0) { - return ret; - } - return 0; -} -static int qsfp_reset_set(struct sff_obj_t *sff_obj, u8 value) -{ - int ret = 0; - - check_pfunc(sff_obj->mgr->io_drv->reset_set); - if ((ret = sff_obj->mgr->io_drv->reset_set(sff_obj->lc_id, sff_obj->port, value)) < 0) { - return ret; - } - return 0; -} -static int qsfp_reset_get(struct sff_obj_t *sff_obj, u8 *value) -{ - int ret = 0; - - check_pfunc(sff_obj->mgr->io_drv->reset_get); - if ((ret = sff_obj->mgr->io_drv->reset_get(sff_obj->lc_id, sff_obj->port, value)) < 0) { - return ret; - } - return 0; -} -static int qsfp_intL_get(struct sff_obj_t *sff_obj, u8 *value) -{ - int ret = 0; - unsigned long bitmap = 0; - - if (!p_valid(value)) { - return -EINVAL; - } - - check_pfunc(sff_obj->mgr->io_drv->intr_all_get); - if ((ret = sff_obj->mgr->io_drv->intr_all_get(sff_obj->lc_id, &bitmap)) < 0) { - return ret; - } - - if (test_bit(sff_obj->port, &bitmap)) { - *value = 1; - } else { - *value = 0; - } - return 0; -} -int qsfp_page_get(struct sff_obj_t *sff_obj, u8 *page) -{ - int ret = 0; - u8 addr = SFF_EEPROM_I2C_ADDR; - u8 offset_page_sel = QSFP_PAGE_SEL_OFFSET; - u8 reg = 0; - - ret = sff_eeprom_read(sff_obj, addr, offset_page_sel, ®, 1); - if (ret < 0) { - MODULE_LOG_ERR("fail\n"); - return ret; - } - *page = reg; - return 0; -} -static int _page_switch(struct sff_obj_t *sff_obj, u8 page) -{ - int rec = 0; - u8 slave_addr = SFF_EEPROM_I2C_ADDR; - u8 offset_page_sel = QSFP_PAGE_SEL_OFFSET; - u8 cur_page = 0; - bool supported = false; -#if 0 - if ((rec = qsfp_paging_supported(sff_obj, &supported)) < 0) { - return rec; - } -#endif - /* use cached instead*/ - memcpy(&supported, &(sff_obj->priv_data.qsfp.paging_supported), sizeof(supported)); - - if (!supported && - QSFP_PAGE0 != page) { - MODULE_LOG_DBG("%s paging is not supported!\n", sff_obj->name); - return -ENOSYS; - } - rec = qsfp_page_get(sff_obj, &cur_page); - if (rec < 0) { - return rec; - } - if (cur_page == page) { - return 0; - } - rec = sff_eeprom_write(sff_obj, slave_addr, offset_page_sel, &page, 1); - - if (rec < 0) { - MODULE_LOG_ERR("switch page fail\n"); - return rec; - } - return 0; -} - -int qsfp_page_sel(struct sff_obj_t *sff_obj, int page) -{ - if (page < QSFP_PAGE0 || page >= PAGE_NUM) { - - return -EINVAL; - } - - return _page_switch(sff_obj, page); -} -static int qsfp_eeprom_read(struct sff_obj_t *sff_obj, - u8 page, - u8 offset, - u8 *buf, - int len) -{ - int ret = 0; - u8 addr = SFF_EEPROM_I2C_ADDR; //it's fixed - - if (offset > QSFP_PAGE_SEL_OFFSET) { - ret = _page_switch(sff_obj, page); - if (ret < 0) { - return ret; - } - } - return sff_eeprom_read(sff_obj, addr, offset, buf, len); -} -static int qsfp_eeprom_write(struct sff_obj_t *sff_obj, - u8 page, - u8 offset, - u8 *buf, - int len) -{ - int ret = 0; - u8 addr = SFF_EEPROM_I2C_ADDR; //it's fixed - - if (offset > QSFP_PAGE_SEL_OFFSET) { - ret = _page_switch(sff_obj, page); - if (ret < 0) { - return ret; - } - } - return sff_eeprom_write(sff_obj, addr, offset, buf, len); -} - -int qsfp_eeprom_dump(struct sff_obj_t *sff_obj, u8 *buf) -{ - int ret = 0; - u8 page = 0; - int i = 0; - int j = 0; - int cnt = 0; - u8 *data = NULL; - u8 offset = 0; - int last = EEPROM_SIZE; - if ((ret = qsfp_page_get(sff_obj, &page)) < 0) { - - return ret; - } - if (page < QSFP_PAGE0 || page >= PAGE_NUM) { - - return -EBFONT; - } - cnt += snprintf(buf+cnt, BUF_SIZE - cnt, "page%d\n", page); - data = sff_obj->priv_data.qsfp.eeprom_cache[page]; - memset(data, 0, sizeof(EEPROM_SIZE)); - if (QSFP_PAGE0 == page) { - - offset = 0; - ret = qsfp_eeprom_read(sff_obj, page, 0, data, EEPROM_SIZE); - /*ret = qsfp_eeprom_read(sff_obj, page, 128, data+128, 64); - ret = qsfp_eeprom_read(sff_obj, page, 192, data+192, 64); - */ - - } else { - - offset = 128; - ret = qsfp_eeprom_read(sff_obj, page, offset, data+offset, EEPROM_HALF_SIZE); - - } - - if (ret < 0) { - MODULE_LOG_ERR("ret:%d read fail\n", ret); - return ret; - } - -#if 0 - for (i = 0; i < 256; i++) { - MODULE_LOG_DBG("reg[%d]:%x\n", i, data[i]); - } -#endif - /*print out offset*/ -#if 1 - cnt += snprintf(buf+cnt, BUF_SIZE - cnt, " "); - for (i = 0; i < 16; i++) { - cnt += snprintf(buf+cnt, BUF_SIZE - cnt, "%01x ", i); - } - cnt += snprintf(buf+cnt, BUF_SIZE - cnt, "\n"); -#endif - for (i = offset, j=0; i < last; i++) { - - j++; - - if (1 == j) { - - cnt += snprintf(buf+cnt, BUF_SIZE - cnt, "%02x: ", i); - - } - - cnt += snprintf(buf+cnt, BUF_SIZE - cnt, "%02x ", data[i]); - - if (16 == j) { - - cnt += snprintf(buf+cnt, BUF_SIZE - cnt, "\n"); - j = 0; - } - - } - return 0; -} - -static int qsfp_paging_supported(struct sff_obj_t *sff_obj, bool *supported) -{ - int ret = 0; - u8 reg = 0; - u8 addr = SFF_EEPROM_I2C_ADDR; //it's fixed - - if(!supported) { - return -EINVAL; - } - if((ret = sff_eeprom_read(sff_obj, addr, QSFP_ST_INDICATOR2_OFFSET, ®, 1)) < 0) { - return ret; - } - - if (reg & bit_mask(FLAT_MEM_BIT)) { - *supported = false; - MODULE_LOG_DBG("%s paging is not supported!\n", sff_obj->name); - } else { - *supported = true; - } - - return 0; -} -int qsfp_id_get(struct sff_obj_t *sff_obj, u8 *id) -{ - if(!id) { - return -EINVAL; - } - return qsfp_eeprom_read(sff_obj, QSFP_PAGE0, QSFP_ID_OFFSET, id, 1); -} -bool qsfp_is_id_matched(struct sff_obj_t *sff_obj) -{ - u8 id = 0; - bool match = false; - if (qsfp_id_get(sff_obj, &id) < 0) { - return match; - } - switch (id) { - case 0x11: - case 0xc: - match = true; - break; - default: - MODULE_LOG_ERR("%s not match id:%d\n", sff_obj->name, id); - break; - } - - return match; -} -int qsfp_ext_id_get(struct sff_obj_t *sff_obj, u8 *ext_id) -{ - if(!ext_id) { - return -EINVAL; - } - - return qsfp_eeprom_read(sff_obj, QSFP_PAGE0, QSFP_EXT_ID_OFFSET, ext_id, 1); -} -static int _qsfp_data_ready_check(struct sff_obj_t *sff_obj, bool *ready) -{ - int ret = 0; - u8 st = 0; - if(!ready) { - return -EINVAL; - } - - if((ret = qsfp_eeprom_read(sff_obj, QSFP_PAGE0, QSFP_ST_INDICATOR2_OFFSET, &st, 1)) < 0) { - return ret; - } - if (st & bit_mask(DATA_NOT_READY_BIT)) { - *ready = false; - } else { - *ready = true; - } - return 0; - -#if 0 - /* special case:ex: AVAGO sn:AF1741GG04J pn: AFBR-89CDDZ*/ - - MODULE_LOG_DBG("special_case of checking data ready\n"); - if((ret = sfp_id_get(sff_obj, &val)) < 0) { - return ret; - } - *is_ready = 1; - return 0; -#endif -} -static int _qsfp_ethernet_compliance_read(struct sff_obj_t *sff_obj, u8 *eth_comp) -{ - int ret = 0; - u8 data = 0; - - if(!eth_comp) { - MODULE_LOG_ERR("invalid para"); - return -EINVAL; - } - if((ret = qsfp_eeprom_read(sff_obj, QSFP_PAGE0, QSFP_ETH_COMP_OFFSET, &data, 1)) < 0) { - MODULE_LOG_ERR("qsfp_eeprom_read fail"); - return ret; - } - *eth_comp = data; - - return 0; -} -static int _qsfp_eth_extended_compliance_get(struct sff_obj_t *sff_obj, u8 *eth_ext_comp) -{ - u8 data = 0; - int ret = 0; - - if(!eth_ext_comp) { - MODULE_LOG_ERR("invalid para"); - return -EINVAL; - } - - if((ret = qsfp_eeprom_read(sff_obj, QSFP_PAGE0, QSFP_ETH_EXT_COMP_OFFSET, &data, 1)) < 0) { - return ret; - } - *eth_ext_comp = data; - - return 0; -} -static bool qsfp_eth_comp_is_supported(struct sff_obj_t *sff_obj, u8 eth_comp) -{ - bool is_supported = false; - int size = ARRAY_SIZE(Qsfp_Eth_Comp_Table); - int idx = 0; - u8 comp_codes = 0; - for (idx = 0; idx < size; idx++) { - if(eth_comp & Qsfp_Eth_Comp_Table[idx]) { - comp_codes = eth_comp & Qsfp_Eth_Comp_Table[idx]; - MODULE_LOG_DBG("%s known eth_cmp:0x%x\n", sff_obj->name, eth_comp & Qsfp_Eth_Comp_Table[idx]); - break; - } - } - if(idx >= size) { - - MODULE_LOG_DBG("%s unknown eth_cmp:0x%x\n", sff_obj->name, eth_comp); - } - - switch (comp_codes) { - case ACTIVE_CABLE: - transvr_type_set(sff_obj, TRANSVR_CLASS_OPTICAL_40G_AOC); - break; - case LR4_40GBASE: - transvr_type_set(sff_obj, TRANSVR_CLASS_OPTICAL_40G_LR4); - break; - case SR4_40GBASE: - transvr_type_set(sff_obj, TRANSVR_CLASS_OPTICAL_40G_SR4); - break; - case CR4_40GBASE: - transvr_type_set(sff_obj, TRANSVR_CLASS_COPPER_L4_40G); - break; - default: - break; - } - - if (TRANSVR_CLASS_UNKNOWN != transvr_type_get(sff_obj)) { - is_supported = true; - MODULE_LOG_DBG("%s known eth_ext_cmp:0x%x transvr:%d\n", - sff_obj->name, eth_comp, transvr_type_get(sff_obj)); - } - return is_supported; -} -static bool qsfp_eth_ext_is_supported(struct sff_obj_t *sff_obj, u8 eth_ext_comp) -{ - bool is_supported = false; - Ethernet_extended_compliance eth_ext_code = eth_ext_comp; - - switch(eth_ext_code) { - case AOC_100G_BER_5: - case AOC_100G_BER_12: - transvr_type_set(sff_obj, TRANSVR_CLASS_OPTICAL_100G_AOC); - break; - case SR4_100GBASE: - transvr_type_set(sff_obj, TRANSVR_CLASS_OPTICAL_100G_SR4); - break; - case LR4_100GBASE: - transvr_type_set(sff_obj, TRANSVR_CLASS_OPTICAL_100G_LR4); - break; - case ER4_100GBASE: - transvr_type_set(sff_obj, TRANSVR_CLASS_OPTICAL_100G_ER4); - break; - case PSM4_100G_SMF: - transvr_type_set(sff_obj, TRANSVR_CLASS_OPTICAL_100G_PSM4); - break; - case CR4_100GBASE: - transvr_type_set(sff_obj, TRANSVR_CLASS_COPPER_L4_100G); - break; - case CWDM4_100G: - transvr_type_set(sff_obj, TRANSVR_CLASS_OPTICAL_100G_CWDM4); - break; - case SR10_100GBASE: - case ACC_100G_BER_5: - case ACC_100G_BER_12: - case ER4_40GBASE: - case SR_10GBASE_4: - case PSM4_40G_SMF: - case CLR4_100G: - case DWDM2_100GE: - MODULE_LOG_DBG("%s known eth_ext_cmp:0x%x\n", sff_obj->name, eth_ext_comp); - - break; - default: - MODULE_LOG_DBG("%s unknown eth_ext_cmp:0x%x\n", sff_obj->name, eth_ext_comp); - - break; - } - - if (TRANSVR_CLASS_UNKNOWN != transvr_type_get(sff_obj)) { - is_supported = true; - MODULE_LOG_DBG("%s known eth_ext_cmp:0x%x transvr:%d\n", - sff_obj->name, eth_ext_comp, transvr_type_get(sff_obj)); - } - return is_supported; -} - -static int qsfp_type_identify(struct sff_obj_t *sff_obj, bool *found) -{ - u8 id = 0; - u8 eth_comp = 0; - u8 eth_ext_comp = 0; - int ret = 0; - - if (!found) { - return -EINVAL; - } - if((ret = qsfp_id_get(sff_obj, &id)) < 0) { - goto exit_err; - } - if(0x0d != id && - 0x11 != id && - 0x0c != id) { // not qsfp+ (0x0d), qsfp28 (0x11), qsfp(INF 8438)(0xc) - MODULE_LOG_ERR("unknown id:0x%x\n", id); - goto exit_non_support_err; /* error handling in the future*/ - } - - if((ret = _qsfp_ethernet_compliance_read(sff_obj, ð_comp)) < 0) { - goto exit_err; - } - - if (eth_comp & 0x80) { //bit7 == 1 - if((ret = _qsfp_eth_extended_compliance_get(sff_obj, ð_ext_comp)) < 0) { - goto exit_err; - } - - if(!qsfp_eth_ext_is_supported(sff_obj, eth_ext_comp)) { - goto exit_non_support_err; - } - } else { /*40G*/ - /* ACTIVE_CABLE = 1 << 0, - * * LR4_40GBASE = 1 << 1, - * * SR4_40GBASE = 1 << 2, - * * CR4_40GBASE = 1 << 3, - * * - * */ - - if(!qsfp_eth_comp_is_supported(sff_obj, eth_comp)) { - goto exit_non_support_err; - } - } - *found = true; - return 0; - -exit_non_support_err: - *found = false; - return 0; -exit_err: /*could be i2c fail , need to define err code in the future */ - return ret; -} - -int qsfp_lane_control_set(struct sff_obj_t *sff_obj, int type, u32 value) -{ - int ret = 0; - u8 page = QSFP_PAGE3; - u8 offset = 0; - bool fail = false; - u8 ch_ctrl[WORD_SIZE]; - - ch_ctrl[0] = (value >> 8) & 0xff; - ch_ctrl[1] = value & 0xff; - - switch(type) { - - case TX_EQ_TYPE: - offset = QSFP_OPT_LN_CONTROL_TX_EQ_OFFSET; - break; - - case RX_EM_TYPE: - offset = QSFP_OPT_LN_CONTROL_RX_EM_OFFSET; - break; - - case RX_AM_TYPE: - offset = QSFP_OPT_LN_CONTROL_RX_AM_OFFSET; - break; - default: - fail = true; - break; - } - - if(fail) { - return -EBADRQC; - } - if((ret = qsfp_eeprom_write(sff_obj, page, offset, ch_ctrl, WORD_SIZE)) < 0) { - return ret; - } - - return 0; -} - -int qsfp_lane_control_get(struct sff_obj_t *sff_obj, int type, u32 *value) -{ - int ret = 0; - u8 page = QSFP_PAGE3; - u8 offset = 0; - bool fail = false; - u8 ch_ctrl[WORD_SIZE]; - if (!value) { - return -EINVAL; - } - switch(type) { - - case TX_EQ_TYPE: - offset = QSFP_OPT_LN_CONTROL_TX_EQ_OFFSET; - break; - - case RX_EM_TYPE: - offset = QSFP_OPT_LN_CONTROL_RX_EM_OFFSET; - break; - - case RX_AM_TYPE: - offset = QSFP_OPT_LN_CONTROL_RX_AM_OFFSET; - break; - default: - fail = true; - break; - } - - if(fail) { - return -EBADRQC; - } - - if((ret = qsfp_eeprom_read(sff_obj, page, offset, ch_ctrl, sizeof(ch_ctrl))) < 0) { - return ret; - } - *value = ((u32)ch_ctrl[0] << 8) | ((u32)ch_ctrl[1]); - return 0; -} -int qsfp_lane_status_get(struct sff_obj_t *sff_obj, int type, u8 *st) -{ - u8 intL = 0; - int ret = 0; - - if ((ret = qsfp_intL_get(sff_obj, &intL)) < 0) { - return ret; - } - if (intL) { - if ((ret = qsfp_int_flag_read(sff_obj)) < 0) { - return ret; - } - } - - *st = sff_obj->priv_data.qsfp.lane_st[type]; - return 0; -} -static int qsfp_lane_status_update(struct sff_obj_t *sff_obj, int type, u8 value) -{ - if (type > LN_STATUS_NUM || - type < LN_STATUS_RX_LOS_TYPE) { - return -EINVAL; - } - - sff_obj->priv_data.qsfp.lane_st[type] = value; - - return 0; -} - -int qsfp_temperature_get(struct sff_obj_t *sff_obj, u8 *buf, int buf_size) -{ - int ret = 0; - u8 reg[WORD_SIZE]; - s16 temp = 0; - s16 data_h = 0; - s16 data_l = 0; - s16 divider = 256; - s16 decimal = 0; - char *unit = "c"; - - if (!buf) { - return -EINVAL; - } - - if((ret = qsfp_eeprom_read(sff_obj, QSFP_PAGE0, QSFP_TEMP_OFFSET, reg, sizeof(reg))) < 0) { - return ret; - } - - data_h = reg[0]; - data_l = reg[1]; - temp = (data_h << 8) | data_l; - - decimal = ((temp/divider)*divider)-temp; - decimal = abs(decimal); - decimal = decimal*1000/divider; - - scnprintf(buf, buf_size, - "%d.%d %s\n", - temp/divider, - decimal, unit); - - return 0; -} - -int qsfp_voltage_get(struct sff_obj_t *sff_obj, u8 *buf, int buf_size) -{ - u8 reg[WORD_SIZE]; - u16 vol_data = 0; - u16 data_h; - u16 data_l; - int ret = 0; - u16 divider = 10000; - char *unit = "v"; - - if((ret = qsfp_eeprom_read(sff_obj, QSFP_PAGE0, QSFP_VCC_OFFSET, reg, sizeof(reg))) < 0) { - MODULE_LOG_ERR("NG1\n"); - return ret; - } - data_h = reg[0]; - data_l = reg[1]; - vol_data = (data_h << 8) | data_l; - - scnprintf(buf, buf_size, - "%d.%d %s\n", - vol_data/divider, - vol_data%divider, unit); - - return 0; -} -int qsfp_lane_monitor_get(struct sff_obj_t *sff_obj, int type, u8 *buf, int buf_size) -{ - u8 offset = 0; - u8 page = QSFP_PAGE0; - int idx = 0; - int ret = 0; - bool fail = false; - u8 ch_monitor[QSFP_LANE_NUM*WORD_SIZE]; /* 2(u16 data) *4 (lane)*/ - u16 divider = 0; - u16 data_h = 0; - u16 data_l = 0; - u16 ch_data = 0; - char *unit = NULL; - struct monitor_para_t *para = NULL; - int len = 0; - int count = 0; - - if (!buf) { - return -EINVAL; - } - len = sizeof(ch_monitor); - switch(type) { - case LN_MONITOR_TX_PWR_TYPE: - offset = QSFP_LN_TX_PWR_OFFSET; - break; - case LN_MONITOR_RX_PWR_TYPE: - offset = QSFP_LN_RX_PWR_OFFSET; - break; - case LN_MONITOR_TX_BIAS_TYPE: - offset = QSFP_LN_TX_BIAS_OFFSET; - break; - default: - fail = true; - break; - } - if (fail) { - return -EINVAL; - } - if((ret = qsfp_eeprom_read(sff_obj, page, offset, ch_monitor, len)) < 0) { - return ret; - } - para = monitor_para_find(type); - if (!para) { - return -EBADRQC; - } - divider = para->divider; - unit = para->unit; - - for (idx = 0; idx < len; idx += WORD_SIZE) { - - data_h = ch_monitor[idx]; - data_l = ch_monitor[idx+1]; - ch_data = (data_h << 8) | data_l; - - count += scnprintf(buf+count, buf_size-count, - "ch%d: %d.%d %s\n", - (idx >> 1) + 1, ch_data/divider, - ch_data%divider, unit); - } - - return 0; -} -int qsfp_vendor_info_get(struct sff_obj_t *sff_obj, int type, u8 *buf, int buf_size) -{ - int ret = 0; - u8 page = QSFP_PAGE0; - u8 offset = 0; - int len = 0; - bool fail = false; - u8 byte_data[VENDOR_INFO_BUF_SIZE]; - - switch(type) { - case VENDOR_NAME_TYPE: - offset = QSFP_VENDOR_NAME_OFFSET; - len = QSFP_VENDOR_NAME_LEN; - break; - case VENDOR_PN_TYPE: - offset = QSFP_VENDOR_PN_OFFSET; - len = QSFP_VENDOR_PN_LEN; - break; - case VENDOR_SN_TYPE: - offset = QSFP_VENDOR_SN_OFFSET; - len = QSFP_VENDOR_SN_LEN; - break; - case VENDOR_REV_TYPE: - offset = QSFP_VENDOR_REV_OFFSET; - len = QSFP_VENDOR_REV_LEN; - break; - default: - fail = true; - break; - } - - if (fail) { - return -EINVAL; - } - if((ret = qsfp_eeprom_read(sff_obj, page, offset, byte_data, len)) < 0) { - return ret; - } - /*add terminal of string*/ - byte_data[len] = '\0'; - - scnprintf(buf, buf_size, "%s\n", byte_data); - - return 0; -} - -static int qsfp_lpmode_control(struct sff_obj_t *sff_obj) -{ - int ret = 0; - u8 ext_id = 0; - u8 power_class = 0; - u8 lpmode = 0; - - if ((ret = qsfp_ext_id_get(sff_obj, &ext_id)) < 0) { - return ret; - } - - /*sff-8436 power class takes up bit 6,7 in Extended Identifier Values - * * - * * - * * - * * */ - - power_class = ext_id >> 6; - MODULE_LOG_DBG("%s power_class:0x%x\n", sff_obj->name, power_class); - - switch(power_class) { - case POWER_CLASS_1_MODULE:/*lower power mode*/ - lpmode = 1; - break; - case POWER_CLASS_2_MODULE: - case POWER_CLASS_3_MODULE: - case POWER_CLASS_4_MODULE: - default: - lpmode = 0; - break; - } - if((ret = qsfp_lpmode_set(sff_obj, lpmode)) < 0) { - return ret; - } - - return 0; -} - -/*6.2.3 Interrupt Flags Bytes 3-21 consist of interrupt flags for LOS, TX Fault, warnings and alarms.*/ -/*TABLE 6-4 LNANNEL STATUS INTERRUPT FLAGS (PAGE 00H BYTES 3-5) */ -/*offset 3 , 0-4: rxlos; 4-7 txlos*/ -/*offset 4 , 0-4: txfault*/ -static int qsfp_int_flag_read(struct sff_obj_t *sff_obj) -{ - int ret = 0; - int i = 0; - u8 buf = 0; - u8 data = 0; - u8 reg[17]; - - if ((ret = qsfp_eeprom_read(sff_obj, QSFP_PAGE0, 0x03, &buf, 1)) < 0) { - - MODULE_LOG_ERR("%s qsfp_eeprom_read fail", sff_obj->name); - return ret; - } - data = bits_get(buf, 0, 4); - qsfp_lane_status_update(sff_obj, LN_STATUS_RX_LOS_TYPE, data); - - if (int_flag_monitor_en) { - MODULE_LOG_DBG("%s rxlos 0x%x", sff_obj->name, data); - } - if ((ret = qsfp_eeprom_read(sff_obj, QSFP_PAGE0, 0x04, &buf, 1)) < 0) { - - MODULE_LOG_ERR("%s qsfp_eeprom_read fail", sff_obj->name); - return ret; - } - data = bits_get(buf, 0, 4); - - if ((ret = qsfp_eeprom_read(sff_obj, QSFP_PAGE0, 0x05, reg, 17)) < 0) { - - MODULE_LOG_ERR("%s qsfp_eeprom_read fail", sff_obj->name); - return ret; - } - - for (i = 0; i < 17; i++) { - if (0 != reg[i]) { - if (int_flag_monitor_en) { - MODULE_LOG_DBG("%s reg[%d] 0x%x", sff_obj->name, i+5, reg[i]); - } - } - } - - return 0; -} -static int qsfp_cdr_control(struct sff_obj_t *sff_obj) -{ - int ret = 0; - u8 ext_id = 0; - u8 cdr_ctrl = 0x00; - - if ((ret = qsfp_ext_id_get(sff_obj, &ext_id)) < 0) { - return ret; - } - - if ((ext_id & bit_mask(CDR_RX_PRS_BIT)) && - (ext_id & bit_mask(CDR_TX_PRS_BIT))) { - - if((ret = qsfp_eeprom_read(sff_obj, QSFP_PAGE0, QSFP_CDR_CONTROL_OFFSET, &cdr_ctrl, 1)) < 0) { - return ret; - } - MODULE_LOG_DBG("default cdr:0x%x\n", cdr_ctrl); - - if(cdr_ctrl != 0xff) { - cdr_ctrl = 0xff; - if((ret = qsfp_eeprom_write(sff_obj, QSFP_PAGE0, QSFP_CDR_CONTROL_OFFSET, &cdr_ctrl, 1)) < 0) { - return ret; - } - } - MODULE_LOG_DBG("OK\n"); - } else { - - MODULE_LOG_DBG("not supported:ext_id:0x%x\n", ext_id); - } - return 0; -} -int qsfp_tx_disable_set(struct sff_obj_t *sff_obj, u8 value) -{ - int ret = 0; - u8 reg = value; - - if((ret = qsfp_eeprom_write(sff_obj, QSFP_PAGE0, QSFP_LN_TX_DISABLE_OFFSET, ®, 1)) < 0) { - return ret; - } - return 0; -} - -int qsfp_tx_disable_get(struct sff_obj_t *sff_obj, u8 *value) -{ - int ret = 0; - u8 reg = 0; - if (!value) { - return -EINVAL; - } - if((ret = qsfp_eeprom_read(sff_obj, QSFP_PAGE0, QSFP_LN_TX_DISABLE_OFFSET, ®, 1)) < 0) { - return ret; - } - *value = reg; - return 0; - -} -static void cache_clear(struct sff_obj_t *sff_obj) -{ - memset(&(sff_obj->priv_data.qsfp), 0, sizeof(struct qsfp_priv_data)); -} -int sff_fsm_qsfp_task(struct sff_obj_t *sff_obj) -{ - sff_fsm_state_t st = sff_fsm_st_get(sff_obj); - int ret = 0; - bool ready = false; - bool found = false; - u8 lv = 0; - bool supported = false; - u8 rst = 0; - u8 power = 0; - switch (st) { - - case SFF_FSM_ST_IDLE: - break; - case SFF_FSM_ST_REMOVED: - cache_clear(sff_obj); - /*always make sure, module plugged in with lower power mode*/ - if((ret = qsfp_lpmode_set(sff_obj, 1)) < 0) { - break; - } - sff_fsm_st_set(sff_obj, SFF_FSM_ST_IDLE); - break; - case SFF_FSM_ST_INSERTED: - - sff_fsm_st_set(sff_obj, SFF_FSM_ST_DETECTING); - break; - - case SFF_FSM_ST_DETECTING: - - if ((ret = qsfp_reset_get(sff_obj, &rst)) < 0) { - break; - } - - if ((ret = sff_power_get(sff_obj, &power)) < 0) { - break; - } - - if (!rst || !power) { - MODULE_LOG_INFO("%s rst:%d power:%d\n",sff_obj->name, rst, power); - sff_fsm_st_set(sff_obj, SFF_FSM_ST_SUSPEND); - break; - } - - if ((ret = _qsfp_data_ready_check(sff_obj, &ready)) < 0) { - break; - } - - if(!ready) { - break; - } - if ((ret = qsfp_paging_supported(sff_obj, &supported)) < 0) { - return ret; - } - memcpy(&(sff_obj->priv_data.qsfp.paging_supported), &supported, sizeof(supported)); -#if 0 - if ((ret = qsfp_tx_disable_set(sff_obj, 0xf)) < 0) { - - break; - } -#endif - if((ret = qsfp_type_identify(sff_obj, &found)) < 0) { - break; - } - - if(found) { - sff_fsm_st_set(sff_obj, SFF_FSM_ST_INIT); - } else { - /*unknown type: special handling*/ - //sff_fsm_st_set(sff_obj, SFF_FSM_ST_UNKNOWN_TYPE); - MODULE_LOG_DBG("%s unknown type, init anyway\n", sff_obj->name); - sff_fsm_st_set(sff_obj, SFF_FSM_ST_INIT); - } - - break; - - case SFF_FSM_ST_ISOLATED: - break; - case SFF_FSM_ST_READY: -#if defined (QSFP_INT_FLAG_SUPPORT) - if ((ret = qsfp_intL_get(sff_obj, &lv)) < 0) { - break; - } - if (!lv) { - if ((ret = qsfp_int_flag_read(sff_obj)) < 0) { - break; - } - } -#endif - break; - - case SFF_FSM_ST_INIT: - /*cdr control*/ - if((ret = qsfp_cdr_control(sff_obj)) < 0) { - break; - } - - /*low power mode control*/ - if((ret = qsfp_lpmode_control(sff_obj)) < 0) { - break; - - } -#if 0 - /*tx_disable control*/ - if((ret = qsfp_tx_disable_set(sff_obj, 0x0)) < 0) { - break; - } -#endif - sff_fsm_kobj_change_event(sff_obj); - sff_fsm_st_set(sff_obj, SFF_FSM_ST_READY); - break; - - case SFF_FSM_ST_SUSPEND: - break; - - case SFF_FSM_ST_RESTART: - if ((ret = sff_prs_get(sff_obj, &lv)) < 0) { - break; - } - if (lv) { - sff_fsm_st_set(sff_obj, SFF_FSM_ST_DETECTING); - } else { - sff_fsm_st_set(sff_obj, SFF_FSM_ST_REMOVED); - } - break; - - case SFF_FSM_ST_FAULT:/*i2c bus fail ... etc*/ - break; - - case SFF_FSM_ST_UNKNOWN_TYPE: - break; - default: - MODULE_LOG_ERR("unknown fsm st:%d\n", st); - break; - - } - if (ret < 0) { - return ret; - } - return 0; -} - diff --git a/packages/platforms/inventec/x86-64/d7332/modules/builds/src/qsfp.h b/packages/platforms/inventec/x86-64/d7332/modules/builds/src/qsfp.h deleted file mode 100644 index 485e132a7..000000000 --- a/packages/platforms/inventec/x86-64/d7332/modules/builds/src/qsfp.h +++ /dev/null @@ -1,7 +0,0 @@ -//port info -#ifndef __SFF_QSFP_H -#define __SFF_QSFP_H - -struct func_tbl_t *qsfp_func_load(void); -int sff_fsm_qsfp_task(struct sff_obj_t *sff_obj); -#endif /*__SFF_QSFP_H*/ diff --git a/packages/platforms/inventec/x86-64/d7332/modules/builds/src/qsfp_dd.c b/packages/platforms/inventec/x86-64/d7332/modules/builds/src/qsfp_dd.c deleted file mode 100644 index ae3d40f7c..000000000 --- a/packages/platforms/inventec/x86-64/d7332/modules/builds/src/qsfp_dd.c +++ /dev/null @@ -1,2052 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "inv_swps.h" -#include "qsfp_dd.h" - -/*page 0x00 register*/ -#define QSFP_DD_ID_OFFSET (0) -#define QSFP_DD_ST_INDICATOR2_OFFSET (2) -#define FLAT_MEM_BIT (7) -#define QSFP_DD_MODULE_GLOBAL_CONTROL_OFFSET (26) -#define QSFP_DD_MODULE_GLOBAL_CONTROL_LOW_PWR_BIT (6) -#define QSFP_DD_CMIS_REV_OFFSET (1) -#define QSFP_DD_BANK_SEL_OFFSET (126) -#define QSFP_DD_MODULE_TYPE_OFFSET (85) - -/*page 0x10 register*/ -#define QSFP_DD_DATA_PATH_DEINIT_OFFSET (128) -#define QSFP_DD_PAGE_SEL_OFFSET (127) -#define QSFP_DD_DATA_PATH_PWR_UP_OFFSET (128) -#define QSFP_DD_TX_DISABLE_OFFSET (130) -#define QSFP_DD_CMIS_REV4_VAL (0x40) -#define QSFP_DD_CMIS_REV3_VAL (0x30) -#define QSFP_DD_VCC_OFFSET (16) -#define QSFP_DD_TEMP_OFFSET (14) -#define QSFP_DD_STAGE_CTRL_SET_ZERO_APPL_SEL_CTRL_OFFSET (145) -#define QSFP_DD_STAGE_CTRL_SET_ZERO_DATA_PATH_INIT_OFFSET (143) -/*page 0x11*/ -#define QSFP_DD_DATA_PATH_ST_OFFSET (128) -#define QSFP_DD_DATA_PATH_ST_NUM (4) -#define QSFP_DD_CONFIG_ERR_CODE_OFFSET (202) -#define QSFP_DD_ACTIVE_CTRL_SET_OFFSET (206) -#define QSFP_DD_LN_MONITOR_TX_PWR_OFFSET (154) -#define QSFP_DD_LN_MONITOR_RX_PWR_OFFSET (186) -#define QSFP_DD_LN_MONITOR_TX_BIAS_OFFSET (170) -#define QSFP_DD_VENDOR_NAME_OFFSET (129) -#define QSFP_DD_VENDOR_PN_OFFSET (148) -#define QSFP_DD_VENDOR_SN_OFFSET (166) -#define QSFP_DD_VENDOR_REV_OFFSET (164) - -#define QSFP_DD_VENDOR_NAME_LEN (16) -#define QSFP_DD_VENDOR_PN_LEN (16) -#define QSFP_DD_VENDOR_SN_LEN (16) -#define QSFP_DD_VENDOR_REV_LEN (2) - -#define QSFP_DD_MODULE_ST_INT_OFFSET (0x03) -#define QSFP_DD_MODULE_ST_BIT_MIN (1) -#define QSFP_DD_MODULE_ST_BIT_NUM (3) -#define QSFP_DD_INTR_LN_FLAG_DATA_PATH_CHG_OFFSET (134) -#define QSFP_DD_INTR_LN_FLAG_START_OFFSET (QSFP_DD_INTR_LN_FLAG_DATA_PATH_CHG_OFFSET) - -extern u32 logLevel; -extern bool int_flag_monitor_en; -/*qsfp-dd*/ -const u8 app_advert_fields_offset[APSEL_NUM][APP_ADVERT_FIELD_NUM] = { - { 86, 87, 88, 89, 176}, - { 90, 91, 92, 93, 177}, -}; -u8 app_advert_fields_page[APP_ADVERT_FIELD_NUM] = { - QSFP_PAGE0, - QSFP_PAGE0, - QSFP_PAGE0, - QSFP_PAGE0, - QSFP_PAGE_01h, -}; - -const char *intr_module_flag_str[QSFP_DD_INT_MODULE_FLAG_NUM] = { - "FW_FAULT", - "L_VCC_TEMP_WARN", - "L_AUX_ALARM_WARN", - "VENDOR_DEFINED_ERR", - "RESERVERD", - "CUSTOM", -}; - -enum { - DATA_PATH_CHG_ID, - L_TX_FAULT_ID, - L_TX_LOS_ID, - L_TX_CDR_LOL_ID, - L_TX_APAP_EQ_INPUT_FAULT_ID, - L_TX_POWER_HIGH_ALARM_ID, - L_TX_POWER_LOW_ALARM_ID, - L_TX_POWER_HIGH_WARN_ID, - L_TX_POWER_LOW_WARN_ID, - L_TX_BIAS_HIGH_ALARM_ID, - L_TX_BIAS_LOW_ALARM_ID, - L_TX_BIAS_HIGH_WARN_ID, - L_TX_BIAS_LOW_WARN_ID, - L_RX_LOS_ID, - L_RX_CDR_LOL_ID, - L_RX_POWER_HIGH_ALARM_ID, - L_RX_POWER_LOW_ALARM_ID, - L_RX_POWER_HIGH_WARN_ID, - L_RX_POWER_LOW_WARN_ID, -}; - -const char *intr_ln_flag_str[QSFP_DD_INT_LN_FLAG_NUM] = { - - "DATA_PATH_CHG", - "L_TX_FAULT", - "L_TX_LOS", - "L_TX_CDR_LOL", - "L_TX_APAP_EQ_INPUT_FAULT", - "L_TX_POWER_HIGH_ALARM", - "L_TX_POWER_LOW_ALARM", - "L_TX_POWER_HIGH_WARN", - "L_TX_POWER_LOW_WARN", - "L_TX_BIAS_HIGH_ALARM", - "L_TX_BIAS_LOW_ALARM", - "L_TX_BIAS_HIGH_WARN", - "L_TX_BIAS_LOW_WARN", - "L_RX_LOS", - "L_RX_CDR_LOL", - "L_RX_POWER_HIGH_ALARM", - "L_RX_POWER_LOW_ALARM", - "L_RX_POWER_HIGH_WARN", - "L_RX_POWER_LOW_WARN", -}; -static int app_advertising_field_get(struct sff_obj_t *sff_obj); -#if 0 -static int qsfp_dd_active_control_set_indicator(struct sff_obj_t *sff_obj); -#endif -static int qsfp_dd_data_path_deinit(struct sff_obj_t *sff_obj, u8 val); -static int data_path_power_up(struct sff_obj_t *sff_obj, bool up); -static int qsfp_dd_is_data_path_activated(struct sff_obj_t *sff_obj, bool *activated); -static int qsfp_dd_lowPwr_set(struct sff_obj_t *sff_obj); -static int stage_control_set0(struct sff_obj_t *sff_obj); -static int config_error_code_check(struct sff_obj_t *sff_obj, bool *is_pass); -static int advert_check(struct sff_obj_t *sff_obj, bool *pass); -static int module_ready_check_rev3(struct sff_obj_t *sff_obj, bool *ready); -static int module_ready_check_rev4(struct sff_obj_t *sff_obj, bool *ready); - -static int sw_config_1_rev3(struct sff_obj_t *sff_obj); -static int sw_config_2_rev3(struct sff_obj_t *sff_obj, bool *pass); -static int sw_config_check_rev3(struct sff_obj_t *sff_obj, bool *pass); -static int sw_control_rev3(struct sff_obj_t *sff_obj); - -static int sw_config_1_rev4(struct sff_obj_t *sff_obj); -static int sw_config_2_rev4(struct sff_obj_t *sff_obj, bool *pass); -static int sw_config_check_rev4(struct sff_obj_t *sff_obj, bool *pass); -static int sw_control_rev4(struct sff_obj_t *sff_obj); - -static int sw_config_1_rev4_full(struct sff_obj_t *sff_obj); -static int sw_config_2_rev4_full(struct sff_obj_t *sff_obj, bool *pass); -static int sw_config_check_rev4_full(struct sff_obj_t *sff_obj, bool *pass); -static int sw_control_rev4_full(struct sff_obj_t *sff_obj); - -inline static struct qsfp_dd_priv_data *qsfp_dd_priv_get(struct sff_obj_t *sff_obj) -{ - return &(sff_obj->priv_data.qsfp_dd); -} -struct qsfp_dd_fsm_func_t qsfp_dd_FsmFuncRev3 = { - - .advert_check = advert_check, - .sw_config_1 = sw_config_1_rev3, - .sw_config_2 = sw_config_2_rev3, - .sw_config_check = sw_config_check_rev3, - .sw_control = sw_control_rev3, - .module_ready_check = module_ready_check_rev3 -}; -/*quick sw init*/ -struct qsfp_dd_fsm_func_t qsfp_dd_FsmFuncRev4 = { - - .advert_check = advert_check, - .sw_config_1 = sw_config_1_rev4, - .sw_config_2 = sw_config_2_rev4, - .sw_config_check = sw_config_check_rev4, - .sw_control = sw_control_rev4, - .module_ready_check = module_ready_check_rev4 -}; - -/*full sw init*/ -struct qsfp_dd_fsm_func_t qsfp_dd_FsmFuncRev4_full = { - - .advert_check = advert_check, - .sw_config_1 = sw_config_1_rev4_full, - .sw_config_2 = sw_config_2_rev4_full, - .sw_config_check = sw_config_check_rev4_full, - .sw_control = sw_control_rev4_full, - .module_ready_check = module_ready_check_rev4 -}; - -static int qsfp_dd_paging_supported(struct sff_obj_t *sff_obj, bool *supported); -static int _page_switch(struct sff_obj_t *sff_obj, u8 page); -static int qsfp_dd_lpmode_set(struct sff_obj_t *sff_obj, u8 value); -static int qsfp_dd_lpmode_get(struct sff_obj_t *sff_obj, u8 *value); -static int qsfp_dd_intL_get(struct sff_obj_t *sff_obj, u8 *value); -static int qsfp_dd_reset_set(struct sff_obj_t *sff_obj, u8 value); -static int qsfp_dd_reset_get(struct sff_obj_t *sff_obj, u8 *value); -static int qsfp_dd_mode_sel_set(struct sff_obj_t *sff_obj, u8 value); -static int qsfp_dd_mode_sel_get(struct sff_obj_t *sff_obj, u8 *value); -int qsfp_dd_lane_monitor_get(struct sff_obj_t *sff_obj, int type, u8 *buf, int buf_size); -int qsfp_dd_tx_disable_set(struct sff_obj_t *sff_obj, u8 val); -int qsfp_dd_tx_disable_get(struct sff_obj_t *sff_obj, u8 *val); -int qsfp_dd_id_get(struct sff_obj_t *sff_obj, u8 *val); -bool qsfp_dd_is_id_matched(struct sff_obj_t *sff_obj); -int qsfp_dd_vendor_info_get(struct sff_obj_t *sff_obj, int type, u8 *buf, int buf_size); -int qsfp_dd_module_st_get(struct sff_obj_t *sff_obj, u8 *st); -int qsfp_dd_temperature_get(struct sff_obj_t *sff_obj, u8 *buf, int buf_size); -int qsfp_dd_voltage_get(struct sff_obj_t *sff_obj, u8 *buf, int buf_size); -int qsfp_dd_page_sel(struct sff_obj_t *sff_obj, int page); -int qsfp_dd_page_get(struct sff_obj_t *sff_obj, u8 *page); -int qsfp_dd_eeprom_dump(struct sff_obj_t *sff_obj, u8 *buf); -int qsfp_dd_ln_st_get(struct sff_obj_t *sff_obj, int type, u8 *st); -static void qsfp_dd_intr_flag_clear(struct sff_obj_t *sff_obj); -static int qsfp_dd_intr_flag_show(struct sff_obj_t *sff_obj, char *buf, int size); - -struct func_tbl_t qsfp_dd_func_tbl = { - .eeprom_read = sff_eeprom_read, - .eeprom_write = sff_eeprom_write, - .prs_get = sff_prs_get, - .lpmode_set = qsfp_dd_lpmode_set, - .lpmode_get = qsfp_dd_lpmode_get, - .reset_set = qsfp_dd_reset_set, - .reset_get = qsfp_dd_reset_get, - .power_set = sff_power_set, - .power_get = sff_power_get, - .mode_sel_set = qsfp_dd_mode_sel_set, - .mode_sel_get = qsfp_dd_mode_sel_get, - .intL_get = qsfp_dd_intL_get, - .tx_disable_set = qsfp_dd_tx_disable_set, - .tx_disable_get = qsfp_dd_tx_disable_get, - .temperature_get = qsfp_dd_temperature_get, - .voltage_get = qsfp_dd_voltage_get, - .lane_control_set = dummy_lane_control_set, - .lane_control_get = dummy_lane_control_get, - .lane_monitor_get = qsfp_dd_lane_monitor_get, - .vendor_info_get = qsfp_dd_vendor_info_get, - .lane_status_get = qsfp_dd_ln_st_get, - .module_st_get = qsfp_dd_module_st_get, - .id_get = qsfp_dd_id_get, - .is_id_matched = qsfp_dd_is_id_matched, - .eeprom_dump = qsfp_dd_eeprom_dump, - .page_sel = qsfp_dd_page_sel, - .page_get = qsfp_dd_page_get, - .intr_flag_show = qsfp_dd_intr_flag_show, - .intr_flag_clear = qsfp_dd_intr_flag_clear, -}; -struct func_tbl_t *qsfp_dd_func_load(void) -{ - return &qsfp_dd_func_tbl; -} -static int qsfp_dd_lpmode_set(struct sff_obj_t *sff_obj, u8 value) -{ - int ret = 0; - - if ((ret = sff_obj->mgr->io_drv->lpmode_set(sff_obj->lc_id, sff_obj->port, value)) < 0) { - return ret; - } - return 0; -} -static int qsfp_dd_lpmode_get(struct sff_obj_t *sff_obj, u8 *value) -{ - int ret = 0; - - if ((ret = sff_obj->mgr->io_drv->lpmode_get(sff_obj->lc_id, sff_obj->port, value)) < 0) { - return ret; - } - return 0; -} -static int qsfp_dd_mode_sel_set(struct sff_obj_t *sff_obj, u8 value) -{ - int ret = 0; - - if ((ret = sff_obj->mgr->io_drv->mode_sel_set(sff_obj->lc_id, sff_obj->port, value)) < 0) { - return ret; - } - return 0; - -} -static int qsfp_dd_mode_sel_get(struct sff_obj_t *sff_obj, u8 *value) -{ - int ret = 0; - - if ((ret = sff_obj->mgr->io_drv->mode_sel_get(sff_obj->lc_id, sff_obj->port, value)) < 0) { - return ret; - } - return 0; -} -static int qsfp_dd_reset_set(struct sff_obj_t *sff_obj, u8 value) -{ - int ret = 0; - - if ((ret = sff_obj->mgr->io_drv->reset_set(sff_obj->lc_id, sff_obj->port, value)) < 0) { - return ret; - } - return 0; -} -static int qsfp_dd_reset_get(struct sff_obj_t *sff_obj, u8 *value) -{ - int ret = 0; - - if ((ret = sff_obj->mgr->io_drv->reset_get(sff_obj->lc_id, sff_obj->port, value)) < 0) { - return ret; - } - return 0; -} -static int qsfp_dd_intL_get(struct sff_obj_t *sff_obj, u8 *value) -{ - int ret = 0; - unsigned long bitmap = 0; - - if (!p_valid(value)) { - return -EINVAL; - } - - if ((ret = sff_obj->mgr->io_drv->intr_all_get(sff_obj->lc_id, &bitmap)) < 0) { - return ret; - } - - if (test_bit(sff_obj->port, &bitmap)) { - *value = 1; - } else { - *value = 0; - } - return 0; -} - -static int qsfp_dd_eeprom_read(struct sff_obj_t *sff_obj, - u8 page, - u8 offset, - u8 *buf, - int len) -{ - int ret = 0; - u8 addr = SFF_EEPROM_I2C_ADDR; //it's fixed - - if (page_sel_is_locked(sff_obj)) { - MODULE_LOG_DBG("%s page_sel_is_locked\n", sff_obj->name); - return -EWOULDBLOCK; - } - page_sel_lock(sff_obj); - if (offset > QSFP_DD_PAGE_SEL_OFFSET) { - ret = _page_switch(sff_obj, page); - if (ret < 0) { - MODULE_LOG_ERR("%s switch page fail\n", sff_obj->name); - page_sel_unlock(sff_obj); - return ret; - } - } - ret = sff_eeprom_read(sff_obj, addr, offset, buf, len); - page_sel_unlock(sff_obj); - return ret; -} -static int qsfp_dd_eeprom_write(struct sff_obj_t *sff_obj, - u8 page, - u8 offset, - u8 *buf, - int len) -{ - int ret = 0; - u8 addr = SFF_EEPROM_I2C_ADDR; //it's fixed - - if (page_sel_is_locked(sff_obj)) { - MODULE_LOG_DBG("%s page_sel_is_locked\n", sff_obj->name); - return -EWOULDBLOCK; - } - page_sel_lock(sff_obj); - if (offset > QSFP_DD_PAGE_SEL_OFFSET) { - ret = _page_switch(sff_obj, page); - if (ret < 0) { - MODULE_LOG_ERR("%s switch page fail\n", sff_obj->name); - page_sel_unlock(sff_obj); - return ret; - } - } - ret = sff_eeprom_write(sff_obj, addr, offset, buf, len); - page_sel_unlock(sff_obj); - return ret; -} -int qsfp_dd_eeprom_dump(struct sff_obj_t *sff_obj, u8 *buf) -{ - int ret = 0; - u8 page = 0; - int i = 0; - int j = 0; - int cnt = 0; - u8 *data = NULL; - u8 offset = 0; - int last = EEPROM_SIZE; - if ((ret = qsfp_dd_page_get(sff_obj, &page)) < 0) { - - return ret; - } - if (page < QSFP_PAGE0 || page >= PAGE_NUM) { - - return -EBFONT; - } - cnt += snprintf(buf+cnt, BUF_SIZE - cnt, "page%d\n", page); - data = sff_obj->priv_data.qsfp_dd.eeprom_cache[page]; - memset(data, 0, sizeof(EEPROM_SIZE)); - if (QSFP_PAGE0 == page) { - - offset = 0; - ret = qsfp_dd_eeprom_read(sff_obj, page, 0, data, EEPROM_SIZE); - /*ret = qsfp_eeprom_read(sff_obj, page, 128, data+128, 64); - * ret = qsfp_eeprom_read(sff_obj, page, 192, data+192, 64); - * */ - - } else { - - offset = 128; - ret = qsfp_dd_eeprom_read(sff_obj, page, offset, data+offset, EEPROM_HALF_SIZE); - - } - - if (ret < 0) { - MODULE_LOG_ERR("ret:%d read fail\n", ret); - return ret; - } -#if 0 - for (i = 0; i < 256; i++) { - MODULE_LOG_DBG("reg[%d]:%x\n", i, data[i]); - } -#endif - /*print out offset*/ -#if 1 - cnt += snprintf(buf+cnt, BUF_SIZE - cnt, " "); - for (i = 0; i < 16; i++) { - cnt += snprintf(buf+cnt, BUF_SIZE - cnt, "%01x ", i); - } - cnt += snprintf(buf+cnt, BUF_SIZE - cnt, "\n"); -#endif - for (i = offset, j=0; i < last; i++) { - - j++; - - if (1 == j) { - - cnt += snprintf(buf+cnt, BUF_SIZE - cnt, "%02x: ", i); - - } - - cnt += snprintf(buf+cnt, BUF_SIZE - cnt, "%02x ", data[i]); - - if (16 == j) { - - cnt += snprintf(buf+cnt, BUF_SIZE - cnt, "\n"); - j = 0; - } - - } - return 0; -} - -static int qsfp_dd_paging_supported(struct sff_obj_t *sff_obj, bool *supported) -{ - int ret = 0; - u8 reg = 0; - u8 addr = SFF_EEPROM_I2C_ADDR; //it's fixed - if(!supported) { - return -EINVAL; - } - if((ret = sff_eeprom_read(sff_obj, addr, QSFP_DD_ST_INDICATOR2_OFFSET, ®, sizeof(reg))) < 0) { - return ret; - } - - if (test_bit(FLAT_MEM_BIT, (unsigned long *)®)) { - *supported = false; - MODULE_LOG_DBG("%s paging is not supported!\n", sff_obj->name); - } else { - *supported = true; - } - - return 0; -} - -int qsfp_dd_page_get(struct sff_obj_t *sff_obj, u8 *page) -{ - int ret = 0; - u8 addr = SFF_EEPROM_I2C_ADDR; - u8 offset_page_sel = QSFP_DD_PAGE_SEL_OFFSET; - u8 reg = 0; - - if((ret = sff_eeprom_read(sff_obj, addr, offset_page_sel, ®, sizeof(reg))) < 0) { - return ret; - } - *page = reg; - return 0; -} -static int _page_switch(struct sff_obj_t *sff_obj, u8 page) -{ - int ret = 0; - u8 addr = SFF_EEPROM_I2C_ADDR; - u8 offset_page_sel = QSFP_DD_PAGE_SEL_OFFSET; - u8 cur_page = 0; - bool supported = false; -#if 1 - if ((ret = qsfp_dd_paging_supported(sff_obj, &supported)) < 0) { - return ret; - } -#else - /*use cache instead*/ - supported = sff_obj->priv_data.qsfp_dd.paging_supported; -#endif - if (!supported && - QSFP_PAGE0 != page) { - MODULE_LOG_ERR("%s paging not supported page:%d supported:%d\n", sff_obj->name, page, supported); - return -ENOSYS; - } - ret = qsfp_dd_page_get(sff_obj, &cur_page); - if (ret < 0) { - return ret; - } - if (cur_page == page) { - return 0; - } - ret = sff_eeprom_write(sff_obj, addr, offset_page_sel, &page, sizeof(page)); - - if (ret < 0) { - MODULE_LOG_ERR("switch page fail\n"); - return ret; - } - return 0; -} -int qsfp_dd_page_sel(struct sff_obj_t *sff_obj, int page) -{ - if (page < QSFP_PAGE0 || page >= PAGE_NUM) { - - return -EINVAL; - } - - return _page_switch(sff_obj, page); -} -static int advert_check(struct sff_obj_t *sff_obj, bool *pass) -{ - int ret = 0; - if ((ret = app_advertising_field_get(sff_obj)) < 0) { - /*print error code*/ - return ret; - } -#if 0 - if ((ret = qsfp_dd_active_control_set_indicator(sff_obj)) < 0) { - return ret; - } -#endif - /* do we need to check advertise?*/ - *pass = true; - return 0; -} -static int sw_config_1_rev3(struct sff_obj_t *sff_obj) -{ - int ret = 0; - /* host select application*/ - /*stage control set 0*/ - if ((ret = stage_control_set0(sff_obj)) < 0) { - /*print error code*/ - return ret; - } - return 0; -} -static int sw_config_2_rev3(struct sff_obj_t *sff_obj, bool *pass) -{ - *pass = true; - return 0; -} -static int sw_config_check_rev3(struct sff_obj_t *sff_obj, bool *pass) -{ - int ret = 0; - bool is_pass = false; - if ((ret = config_error_code_check(sff_obj, &is_pass)) < 0) { - - return ret; - } - *pass = is_pass; - return 0; -} -static int sw_control_rev3(struct sff_obj_t *sff_obj) -{ - int ret = 0; - /*set tx_disable true to avoid link flapping*/ - if ((ret = qsfp_dd_tx_disable_set(sff_obj, 0xff)) < 0) { - return ret; - } - /*Host sets the - * * DataPathPwrUp bits for - * * all host lanes in the - * * data path(s) that it - * * wants to enable (See - * * Table 53, Page 10h - * * Register 128)*/ - - if ((ret = data_path_power_up(sff_obj, true)) < 0) { - return ret; - } - - return 0; -} -static int module_ready_check_rev3(struct sff_obj_t *sff_obj, bool *ready) -{ - u8 module_st = 0; - int ret = 0; - bool tmp_ready = false; - bool activated = false; - if ((ret = qsfp_dd_module_st_get(sff_obj, &module_st)) < 0) { - return ret; - } - if ((ret = qsfp_dd_is_data_path_activated(sff_obj, &activated)) < 0) { - return ret; - } - /*check module state register if it transit to module ready*/ - if (MODULE_READY_ST_ENCODE == module_st && - true == activated ) { - /*set tx_disable false, */ - if ((ret = qsfp_dd_tx_disable_set(sff_obj, 0x0)) < 0) { - return ret; - } - tmp_ready = true; - } - - *ready = tmp_ready; - return 0; -} -static int module_ready_check_rev4(struct sff_obj_t *sff_obj, bool *ready) -{ - u8 module_st = 0; - int ret = 0; - bool tmp_ready = false; - bool activated = false; - - if ((ret = qsfp_dd_module_st_get(sff_obj, &module_st)) < 0) { - return ret; - } - if ((ret = qsfp_dd_is_data_path_activated(sff_obj, &activated)) < 0) { - return ret; - } - /*check module state register if it transit to module ready*/ - if (MODULE_READY_ST_ENCODE == module_st && - true == activated ) { - tmp_ready = true; - } - - *ready = tmp_ready; - return 0; -} -static int sw_config_1_rev4(struct sff_obj_t *sff_obj) -{ - int ret = 0; - if ((ret = qsfp_dd_lowPwr_set(sff_obj)) < 0) { - return ret; - } - return 0; -} -static int sw_config_2_rev4(struct sff_obj_t *sff_obj, bool *pass) -{ - *pass = true; - return 0; -} - -static int sw_config_check_rev4(struct sff_obj_t *sff_obj, bool *pass) -{ - *pass = true; - return 0; -} - -static int sw_control_rev4(struct sff_obj_t *sff_obj) -{ - return 0; -} - -static int sw_config_1_rev4_full(struct sff_obj_t *sff_obj) -{ - int ret = 0; - if ((ret = qsfp_dd_data_path_deinit(sff_obj, 0xff)) < 0) { - return ret; - } - if ((ret = qsfp_dd_lowPwr_set(sff_obj)) < 0) { - return ret; - } - return 0; -} - -static int sw_config_2_rev4_full(struct sff_obj_t *sff_obj, bool *pass) -{ - u8 module_st = 0; - int ret = 0; - - if ((ret = qsfp_dd_module_st_get(sff_obj, &module_st)) < 0) { - return ret; - } - /*check module state register if it transit to module ready*/ - if (MODULE_READY_ST_ENCODE != module_st) { - *pass = false; - return 0; - } - - /* host select application*/ - /*stage control set 0*/ - if ((ret = stage_control_set0(sff_obj)) < 0) { - return ret; - } - - *pass = true; - return 0; -} - -static int sw_config_check_rev4_full(struct sff_obj_t *sff_obj, bool *pass) -{ - int ret = 0; - bool is_pass = false; - if ((ret = config_error_code_check(sff_obj, &is_pass)) < 0) { - - return ret; - } - *pass = is_pass; - return 0; -} - -static int sw_control_rev4_full(struct sff_obj_t *sff_obj) -{ - int ret = 0; - - if ((ret = qsfp_dd_data_path_deinit(sff_obj, 0x0)) < 0) { - return ret; - } - - return 0; -} - -static int cmis_ver_get(struct sff_obj_t *sff_obj, u8 *ver) -{ - int ret = 0; - u8 buf = 0; - - if ((ret = qsfp_dd_eeprom_read(sff_obj, QSFP_PAGE0, QSFP_DD_CMIS_REV_OFFSET, &buf, 1)) < 0) { - return ret; - } - MODULE_LOG_DBG("%s cmis ver:0x%x\n", sff_obj->name, buf); - *ver = buf; - return 0; -} -static int fsm_func_get(struct sff_obj_t *sff_obj, struct qsfp_dd_fsm_func_t **ppfunc) -{ - int ret = 0; - u8 ver = 0; - struct qsfp_dd_fsm_func_t *func = &qsfp_dd_FsmFuncRev3; - bool rev4_quick = qsfp_dd_rev4_quick_get(sff_obj); - if ((ret = cmis_ver_get(sff_obj, &ver)) < 0) { - return ret; - } - - if (ver == QSFP_DD_CMIS_REV3_VAL) { - func = &qsfp_dd_FsmFuncRev3; - } else if (ver == QSFP_DD_CMIS_REV4_VAL) { - if (rev4_quick) { - func = &qsfp_dd_FsmFuncRev4; - MODULE_LOG_DBG("%s rev4 quick is loaded\n", sff_obj->name); - } else { - func = &qsfp_dd_FsmFuncRev4_full; - MODULE_LOG_DBG("%s rev4 full is loaded\n", sff_obj->name); - } - } else { - - MODULE_LOG_ERR("%s rev:%x not supported, using rev 3.0 as default\n", sff_obj->name, ver); - } - *ppfunc = func; - return 0; -} -/*TBD lan number can be changed*/ -static int valid_lane_num_get(struct sff_obj_t *sff_obj) -{ - - int num = 8; - return num; - -} -static bool is_bank_num_valid(struct sff_obj_t *sff_obj) -{ - u8 bank_no = 0xff; - bool valid = false; - /*check if it's bank0? */ - if (qsfp_dd_eeprom_read(sff_obj, QSFP_PAGE0, QSFP_DD_BANK_SEL_OFFSET, &bank_no, sizeof(bank_no)) < 0) { - - MODULE_LOG_ERR("%s qsfp_dd_eeprom_read fail", sff_obj->name); - return valid; - } - if (0x00 == bank_no) { - - valid = true; - } else { - MODULE_LOG_ERR("%s bank no is not 0", sff_obj->name); - } - - return valid; -} -/*CMIS REV 4.0*/ -static int qsfp_dd_lowPwr_set(struct sff_obj_t *sff_obj) -{ - int ret = 0; - u8 buf = 0; - u8 page = QSFP_PAGE0; - u8 offset = QSFP_DD_MODULE_GLOBAL_CONTROL_OFFSET; - - if ((ret = qsfp_dd_eeprom_read(sff_obj, page, offset, &buf, sizeof(buf))) < 0) { - return ret; - } - - clear_bit(QSFP_DD_MODULE_GLOBAL_CONTROL_LOW_PWR_BIT, (unsigned long *)&buf); - - if( (ret = qsfp_dd_eeprom_write(sff_obj, page, offset, &buf, sizeof(buf))) < 0) { - return ret; - } - - return 0; -} -/*Table 8-44 Page 10h Overview offset 128*/ -static int qsfp_dd_data_path_deinit(struct sff_obj_t *sff_obj, u8 val) -{ - int ret = 0; - u8 buf = val; - u8 page = QSFP_PAGE_10h; - u8 offset = QSFP_DD_DATA_PATH_DEINIT_OFFSET; - - if( (ret = qsfp_dd_eeprom_write(sff_obj, page, offset, &buf, sizeof(buf))) < 0) { - return ret; - } - - return 0; -} -#if 0 -/*Table 23- Module Global and Squelch Mode Controls (Lower Page, active modules only) - * * byte 26 bit 4 */ -static int qsfp_dd_force_low_pwr(struct sff_obj_t *sff_obj, int en) -{ - u8 buf = 0; - int ret = 0; - u8 page = QSFP_PAGE0; - u8 offset = 26; - if ((ret = qsfp_dd_eeprom_read(sff_obj, page, offset, &buf, 1)) < 0) { - - MODULE_LOG_ERR("port:%d qsfp_dd_eeprom_read fail", port); - return ret; - } - buf = ret; - if (en) { - set_bit(4, (unsigned long *)&buf); - } else { - - clear_bit(4, (unsigned long *)&buf); - } - - if( (ret = qsfp_dd_eeprom_write(sff_obj, page, offset, &buf, 1)) < 0) { - MODULE_LOG_ERR("write fail\n"); - return ret; - } - return 0; -} -#endif -#if 0 -/*(Page 11h, active modules only) - * * app selected: offset 206-213 (Table 73) - * * tx control offset 214-221 (Table 74) - * * rx control offset 222-239 (Table 75)*/ -static int qsfp_dd_active_control_set_indicator(struct sff_obj_t *sff_obj) -{ - u8 data[34]; - int ret = 0; - int count = 0; - int size = sizeof(data); - if (!is_bank_num_valid(sff_obj)) { - return -1; - } - if ((ret = qsfp_dd_eeprom_read(sff_obj, QSFP_PAGE_11h, 206, data, size)) < 0) { - return ret; - } - - for (count = 0; count < size; count++) { - - } - - return 0; -} -/*Table 46- Implemented Signal Integrity Controls (Page 01h) - * * - * * */ -int qsfp_dd_channel_control_get(struct sff_obj_t *sff_obj, int type, u32 *value) -{ - int ret = 0; - u8 data[2]; - /*TBD replace port with sff_obj->name*/ - if (!is_bank_num_valid(sff_obj)) { - return -1; - } - if ((ret = qsfp_dd_eeprom_read(sff_obj, QSFP_PAGE_01h, 161, data, 2)) < 0) { - - return -1; - } - - /*offset:161*/ - if (data[0] | TX_CDR_BIT) { - - MODULE_LOG_DBG("%s Tx CDR implemented", sff_obj->name); - } - if (data[0] | TX_CDR_BYPASS_BIT) { - - MODULE_LOG_DBG("%s Tx CDR Bypass control implemented ", sff_obj->name); - } - if (data[0] | TX_INPUT_FIX_MANUAL_BIT) { - - MODULE_LOG_DBG("%s Tx Input Eq fixed manual", sff_obj->name); - } - if (data[0] | ADAPTIVE_TX_INPUT_FIX_MANUAL_BIT) { - - MODULE_LOG_DBG("port:%d Adaptive Tx Input Eq", port); - } - if (data[0] | TX_INPUT_FREEZE_BIT) { - - MODULE_LOG_DBG("port:%d Tx Input Eq Freeze", port); - } - /*offset:162*/ - if (data[1] | RX_CDR_BIT) { - - MODULE_LOG_DBG("port:%d Rx CDR implemented", port); - } - if (data[1] | RX_CDR_BYPASS_BIT) { - - MODULE_LOG_DBG("port:%d Rx CDR Bypass control implemented ", port); - } - if (data[1] | RX_OUTPUT_AMP_CONTROL_BIT) { - - MODULE_LOG_DBG("port:%d Rx output amp", port); - } - if (data[1] | RX_OUTPUT_EQ_CONTROL_BIT) { - - MODULE_LOG_DBG("port:%d Rx output eq", port); - } - if (data[1] | STAGE_SET1_BIT) { - - MODULE_LOG_DBG("port:%d stage_set1", port); - } - - return 0; -} -#endif -int qsfp_dd_temperature_get(struct sff_obj_t *sff_obj, u8 *buf, int buf_size) -{ - int ret = 0; - u8 page = QSFP_PAGE0; - u8 offset = QSFP_DD_TEMP_OFFSET; - u8 reg[WORD_SIZE]; - s16 temp = 0; - s16 data_h = 0; - s16 data_l = 0; - s16 divider = 256; - s16 decimal = 0; - char *unit = "c"; - - if((ret = qsfp_dd_eeprom_read(sff_obj, page, offset, reg, sizeof(reg))) < 0) { - return ret; - } - data_h = reg[0]; - data_l = reg[1]; - temp = (data_h << 8) | data_l; - decimal = ((temp/divider)*divider)-temp; - decimal = abs(decimal); - decimal = decimal*1000/divider; - - scnprintf(buf, buf_size, - "%d.%d %s\n", - temp/divider, - decimal, unit); - - return 0; -} - -/*Table 22- Module Monitors (Lower Page, active modules only) - * * offset 16,17*/ -int qsfp_dd_voltage_get(struct sff_obj_t *sff_obj, u8 *buf, int buf_size) -{ - int ret = 0; - u8 page = QSFP_PAGE0; - u8 offset = QSFP_DD_VCC_OFFSET; - u8 reg[WORD_SIZE]; - u16 vol = 0; - u16 data_h = 0; - u16 data_l = 0; - u16 divider = 10000; - char *unit = "v"; - - if((ret = qsfp_dd_eeprom_read(sff_obj, page, offset, reg, sizeof(reg))) < 0) { - return ret; - } - data_h = reg[0]; - data_l = reg[1]; - vol = (data_h << 8) | data_l; - scnprintf(buf, buf_size, - "%d.%d %s\n", - vol/divider, - vol%divider, unit); - - return 0; -} - -/*1.7.7.3 Lane-Specific Monitors */ -/*Table 70- Lane-Specific Monitors (Page 11h, active modules only) */ -int qsfp_dd_lane_monitor_get(struct sff_obj_t *sff_obj, int type, u8 *buf, int buf_size) -{ - int ret = 0; - u8 page = QSFP_PAGE_11h; - u8 offset = 0; - int len = 0; - int count = 0; - int idx = 0; - u8 ch_monitor[QSFP_DD_LANE_NUM*WORD_SIZE]; /* 2(u16 data) *4 (channel)*/ - u16 data_h = 0; - u16 data_l = 0; - u16 ch_data = 0; - u16 divider = 10000; - char *unit = NULL; - struct monitor_para_t *para = NULL; - - len = sizeof(ch_monitor); - - switch(type) { - case LN_MONITOR_TX_PWR_TYPE: - offset = QSFP_DD_LN_MONITOR_TX_PWR_OFFSET; - break; - case LN_MONITOR_RX_PWR_TYPE: - offset = QSFP_DD_LN_MONITOR_RX_PWR_OFFSET; - break; - case LN_MONITOR_TX_BIAS_TYPE: - offset = QSFP_DD_LN_MONITOR_TX_BIAS_OFFSET; - break; - default: - break; - } - if (0 == offset) { - return -EINVAL; - } - if((ret = qsfp_dd_eeprom_read(sff_obj, page, offset, ch_monitor, len)) < 0) { - return ret; - } - para = monitor_para_find(type); - if (!para) { - return -EBADRQC; - } - divider = para->divider; - unit = para->unit; - for (idx = 0; idx < len; idx += WORD_SIZE) { - /*big edian*/ - data_h = ch_monitor[idx]; - data_l = ch_monitor[idx+1]; - ch_data = (data_h << 8) | data_l; - - count += scnprintf(buf+count, buf_size-count, - "ch%d: %d.%d %s\n", - (idx >> 1) + 1, ch_data/divider, - ch_data%divider, unit); - } - - return 0; -} -/*rev3 1.7.3.2*/ -int qsfp_dd_vendor_info_get(struct sff_obj_t *sff_obj, int type, u8 *buf, int buf_size) -{ - int ret = 0; - u8 page = QSFP_PAGE0; - u8 offset = 0; - int len = 0; - u8 byte_data[VENDOR_INFO_BUF_SIZE]; - - switch(type) { - case VENDOR_NAME_TYPE: - offset = QSFP_DD_VENDOR_NAME_OFFSET; - len = QSFP_DD_VENDOR_NAME_LEN; - - break; - case VENDOR_PN_TYPE: - offset = QSFP_DD_VENDOR_PN_OFFSET; - len = QSFP_DD_VENDOR_PN_LEN; - - break; - case VENDOR_SN_TYPE: - offset = QSFP_DD_VENDOR_SN_OFFSET; - len = QSFP_DD_VENDOR_SN_LEN; - - break; - case VENDOR_REV_TYPE: - offset = QSFP_DD_VENDOR_REV_OFFSET; - len = QSFP_DD_VENDOR_REV_LEN; - - break; - default: - break; - } - if (0 == offset) { - return -EINVAL; - } - /*use a big enough buf to handle all the vendor info*/ - if (len >= VENDOR_INFO_BUF_SIZE) { - return -EBADRQC; - } - - if((ret = qsfp_dd_eeprom_read(sff_obj, page, offset, byte_data, len)) < 0) { - return ret; - } - /*add terminal of string*/ - byte_data[len] = '\0'; - scnprintf(buf, buf_size, "%s\n", byte_data); - - return 0; -} -/*Table 18- Identifier and Status Summary (Lower Page) byte3 , 3-1 Module state*/ -int qsfp_dd_module_st_get(struct sff_obj_t *sff_obj, u8 *st) -{ - u8 data = 0; - int ret = 0; - if (!st) { - return -EINVAL; - } - if ((ret = qsfp_dd_eeprom_read(sff_obj, QSFP_PAGE0, QSFP_DD_MODULE_ST_INT_OFFSET, &data, sizeof(data))) < 0) { - - MODULE_LOG_ERR("%s qsfp_dd_eeprom_read fail", sff_obj->name); - return ret; - } - - *st = bits_get(data, QSFP_DD_MODULE_ST_BIT_MIN, QSFP_DD_MODULE_ST_BIT_NUM); - return 0; -} -/*value : the status of 8 lane, one lane: 4 bits*/ -/*table 65 page 11h offset 128~131*/ -static int qsfp_dd_data_path_st_get(struct sff_obj_t *sff_obj, u8 st[], int size) -{ - int ret = 0; - u8 reg[QSFP_DD_DATA_PATH_ST_NUM]; - int i = 0; - int ln = 0; - - if (!st) { - return -EINVAL; - } - if((ret = qsfp_dd_eeprom_read(sff_obj, QSFP_PAGE_11h, QSFP_DD_DATA_PATH_ST_OFFSET, reg, sizeof(reg))) < 0) { - *st = 0; - return ret; - } - if ((QSFP_DD_DATA_PATH_ST_NUM * 2) != size) { - return -EINVAL; - } - for (i = 0; i < QSFP_DD_DATA_PATH_ST_NUM; i++) { - st[ln++] = reg[i] & 0x0f; - st[ln++] = reg[i] >> 4; - } - return 0; -} - -static int qsfp_dd_is_data_path_activated(struct sff_obj_t *sff_obj, bool *activated) -{ - u8 data_path_st[QSFP_DD_LANE_NUM]; - int ln = 0; - int ret = 0; - bool tmp_active = false; - int lane_num = QSFP_DD_LANE_NUM; - - if ((ret = qsfp_dd_data_path_st_get(sff_obj, data_path_st, sizeof(data_path_st))) < 0) { - return ret; - } - - for (ln = 0; ln < lane_num; ln++) { - if (DATA_PATH_ACTIVATED_ST_ENCODE != data_path_st[ln]) { - break; - } - } - if (ln >= lane_num) { - MODULE_LOG_DBG("%s ok", sff_obj->name); - tmp_active = true; - } - *activated = tmp_active; - return 0; -} -/*Table 18- Identifier and Status Summary (Lower Page) - * * lower page :offset 0 */ -int qsfp_dd_id_get(struct sff_obj_t *sff_obj, u8 *val) -{ - u8 buf = 0; - int ret = 0; - - if (!val) { - return -EINVAL; - } - if ((ret = qsfp_dd_eeprom_read(sff_obj, QSFP_PAGE0, QSFP_DD_ID_OFFSET, &buf, sizeof(buf))) < 0) { - return ret; - } - *val = buf; - return 0; -} -bool qsfp_dd_is_id_matched(struct sff_obj_t *sff_obj) -{ - u8 id = 0; - bool match = false; - if (qsfp_dd_id_get(sff_obj, &id) < 0) { - return match; - } - switch (id) { - case 0x18: - match = true; - break; - default: - MODULE_LOG_ERR("%s not match id:%d\n", sff_obj->name, id); - break; - } - - return match; -} -#if 0 -static int qsfp_dd_module_state_is_changed(struct sff_obj_t *sff_obj, bool *is_changed) -{ - u8 page = QSFP_PAGE0; - u8 offset = 8; - u8 val = 0; - int ret = 0; - if ((ret = qsfp_dd_eeprom_read(sff_obj, page, offset, &val, 1)) < 0) { - return ret; - } - *is_changed = ((val&0x1) ? true : false); - return 0; -} - -/*table 18 : offset 3 bit 0*/ -static int qsfp_dd_digital_int_get(struct sff_obj_t *sff_obj, u8 *value) -{ - u8 st = 0; - int ret = 0; - if ((ret = qsfp_dd_eeprom_read(sff_obj, QSFP_PAGE0, 0x03, &st, 1)) < 0) { - return ret; - } - *value = st & 0x1; - return ret; - -} -#endif -#if 0 -/*table 36: byte 212 :that defines aspects of the device or cable technology*/ -static int qsfp_dd_media_interface_tech_get(struct sff_obj_t *sff_obj, u8 *interface) -{ - - u8 data = 0; - - if(IS_ERR_OR_NULL(interface)) { - MODULE_LOG_ERR("invalid para"); - return -1; - } - - if(qsfp_dd_eeprom_read(sff_obj, QSFP_PAGE0, 212, &data, 1) < 0) { - MODULE_LOG_ERR("qsfp_dd_eeprom_read fail"); - *interface = 0xff; /*non define*/ - return -1; - } - *interface = data; - - return 0; - -} -#endif - -/*Table 25- Byte 85 Module Type Encodings*/ -static int qsfp_dd_module_type_get(struct sff_obj_t *sff_obj, u8 *type) -{ - u8 data = 0; - int ret = 0; - - if ((ret = qsfp_dd_eeprom_read(sff_obj, QSFP_PAGE0, QSFP_DD_MODULE_TYPE_OFFSET, &data, sizeof(data))) < 0) { - return ret; - } - *type = data; - return 0; -} - -static bool is_loopback_module(struct sff_obj_t *sff_obj) -{ - /* need check more loopback modules*/ - bool is_loopback = false; - u8 type = 0; - if (qsfp_dd_module_type_get(sff_obj, &type) < 0) { - return false; - } - - if (0 == type) { - is_loopback = true; - } - return is_loopback; -} -/*table 26*: lower page:00*/ -static int app_advertising_field_get(struct sff_obj_t *sff_obj) -{ - u8 module_type = 0; - union qsfp_dd_app_advert_fields *fields = sff_obj->priv_data.qsfp_dd.fields; - int ret = 0; - int apsel = 0; - int i = 0; - bool end_of_table = false; - - if ((ret = qsfp_dd_eeprom_read(sff_obj, QSFP_PAGE0, 85, &module_type, 1)) < 0) { - - return ret; - } - - MODULE_LOG_DBG("%s module_type:0x%x\n", sff_obj->name, module_type); - sff_obj->priv_data.qsfp_dd.module_type = module_type; - for (apsel = APSEL_1; apsel < APSEL_NUM; apsel++) { - for (i = 0; i < APP_ADVERT_FIELD_NUM; i++) { - - if ((ret =qsfp_dd_eeprom_read(sff_obj, app_advert_fields_page[i], - app_advert_fields_offset[apsel][i], - &fields[apsel].reg[i], 1)) < 0) { - - MODULE_LOG_ERR("%s qsfp_dd_eeprom_read fail", sff_obj->name); - return ret; - } - if (ret == 0xff) { - end_of_table = true; - break; - } - } - if (end_of_table) { - break; - } - - } - - for (apsel = 0; apsel < APSEL_NUM; apsel++) { - MODULE_LOG_DBG("%s host_electrical_interface_code[%d]:0x%x\n", - sff_obj->name, apsel, fields[apsel].data.host_electrical_interface_code); - MODULE_LOG_DBG("%s module_media_interface_code[%d]:0x%x\n", - sff_obj->name, apsel, fields[apsel].data.module_media_interface_code); - MODULE_LOG_DBG("%s lane_count[%d]:0x%x\n", - sff_obj->name, apsel, fields[apsel].data.lane_count); - MODULE_LOG_DBG("%s host_lane_assignment_options[%d]:0x%x\n", - sff_obj->name, apsel, fields[apsel].data.host_lane_assignment_options); - MODULE_LOG_DBG("%s media_lane_assignment_options[%d]:0x%x\n", - sff_obj->name, apsel, fields[apsel].data.media_lane_assignment_options); - } - return 0; -} -#if 0 -static int app_advert_field_dump(struct sff_obj_t *sff_obj, u8 *buf, int buf_size) -{ - int apsel = APSEL_1; - int ret = 0; - union qsfp_dd_app_advert_fields *fields = sff_obj->priv_data.qsfp_dd.fields; - /* the field data will be cached when module is plugged in , so may not need to capture again in the future*/ - ret = app_advertising_field_get(sff_obj); - if (ret < 0) { - return ret; - } - scnprintf(buf, buf_size, - "module_type 0x%x \ - host electrical intf 0x%x \ - module media intf 0x%x \ - host_media lane count %d \ - host lane assignment 0x%x \ - media lane assignment 0x%x\n", - sff_obj->priv_data.qsfp_dd.module_type, - fields[apsel].data.host_electrical_interface_code, - fields[apsel].data.module_media_interface_code, - fields[apsel].data.lane_count, - fields[apsel].data.host_lane_assignment_options, - fields[apsel].data.media_lane_assignment_options - - ); - return 0; - -} -#endif -int qsfp_dd_active_ctrl_set_get(struct sff_obj_t *sff_obj, char *buf, int size) -{ - int ret = 0; - struct stage_set_t stage_set[QSFP_DD_LANE_NUM]; - u8 offset = QSFP_DD_ACTIVE_CTRL_SET_OFFSET; - int count = 0; - int ln = 0; - if((ret = qsfp_dd_eeprom_read(sff_obj, QSFP_PAGE_11h, offset, (u8*)stage_set, sizeof(stage_set))) < 0) { - return ret; - } - - for (ln = 0; ln < 8; ln++) { - count += scnprintf(buf+count, size-count, - "ln%d: apsel:%d datapath:%d explicit_ctrl:%d\n", - ln+1, - stage_set[ln].app_code, - stage_set[ln].datapath_code, - stage_set[ln].explicit_control); - } - return 0; -} -int qsfp_dd_apsel_get(struct sff_obj_t *sff_obj) -{ - //return stage_control_set0(sff_obj, apsel); - struct qsfp_dd_priv_data *qsfp_dd_priv = qsfp_dd_priv_get(sff_obj); - return qsfp_dd_priv->apsel; -} -/*note: so far only page >= 0x10 , need to check bank number*/ -static int stage_control_set0(struct sff_obj_t *sff_obj) -{ - int ret = 0; - int apsel = 0; - u8 apply_stage_control_set = 0; - u8 offset = QSFP_DD_STAGE_CTRL_SET_ZERO_APPL_SEL_CTRL_OFFSET; - //u8 stage_set_offset_begin = QSFP_DD_STAGE_CTRL_SET_ZERO_APPL_SEL_CTRL_OFFSET; - //u8 stage_set_offset_end = stage_set_offset_begin + QSFP_DD_LANE_NUM - 1; - int ln = 0; - int datapath_code = 0; - struct stage_set_t stage_set[QSFP_DD_LANE_NUM]; - - if (!is_bank_num_valid(sff_obj)) { - return -EBADRQC; - } - apsel = qsfp_dd_apsel_get(sff_obj); - /*table 56 stage control set 0, application select controls (Page 10h, active modules only) */ - /*case1: normal case 400G lane = 8*/ - if (1 == apsel) { - for (ln = 0; ln < 8; ln++) { - stage_set[ln].explicit_control = 0; - stage_set[ln].datapath_code = 0x00; - stage_set[ln].app_code = apsel; - } - - } else { - - for (ln = 0; ln < 8; ) { - stage_set[ln].explicit_control = 0; - stage_set[ln].datapath_code = datapath_code; - stage_set[ln].app_code = apsel; - ln++; - if (0 == (ln % 2)) { - datapath_code += 2; - } - } - } - - if((ret = qsfp_dd_eeprom_write(sff_obj, QSFP_PAGE_10h, offset, (u8*)stage_set, sizeof(stage_set))) < 0) { - return ret; - } - /*table 55 Apply_DataPathInit*/ - apply_stage_control_set = 0xff; - if((ret = qsfp_dd_eeprom_write(sff_obj, - QSFP_PAGE_10h, - QSFP_DD_STAGE_CTRL_SET_ZERO_DATA_PATH_INIT_OFFSET, - &apply_stage_control_set, sizeof(apply_stage_control_set))) < 0) { - return ret; - } - - return 0; -} - -int qsfp_dd_apsel_apply(struct sff_obj_t *sff_obj, int apsel) -{ - //return stage_control_set0(sff_obj, apsel); - struct qsfp_dd_priv_data *qsfp_dd_priv = qsfp_dd_priv_get(sff_obj); - qsfp_dd_priv->apsel = apsel; - return 0; -} -/*qsfp-dd used only*/ - -/*page 11 - * * table 71/72 : active modules only - * * Table 72- Configuration Error Codes - * * para: - * * port(in) - * * is_pass(out)*/ -static int config_error_code_check(struct sff_obj_t *sff_obj, bool *is_pass) -{ - int ret = 0; - u8 data[4]; - int lane = 0; - int i = 0; - int size = sizeof(data); - /*since the one reg reprsL 2 lanes*/ - int lane_num = valid_lane_num_get(sff_obj); - u8 config_err_code[lane_num]; /*lane number 8*/ - - if (!is_pass) { - return -EINVAL; - } - if (!is_bank_num_valid(sff_obj)) { - return -EBADRQC; - } - if ((ret = qsfp_dd_eeprom_read(sff_obj, QSFP_PAGE_11h, QSFP_DD_CONFIG_ERR_CODE_OFFSET, data, size)) < 0) { - return ret; - } - - for (lane = 0, i = 0; i < size; i++) { - config_err_code[lane++] = data[i] & 0xf; - config_err_code[lane++] = (data[i] & 0xf0) >> 4; - } - - for (lane = 0; lane < lane_num; lane++) { - - MODULE_LOG_DBG("%s lane:%d err_code:0x%x\n", sff_obj->name, lane, config_err_code[lane]); - if (CONFIG_ACCEPTED == config_err_code[lane]) { - } else { - break; - } - } - if (lane >= lane_num) { - *is_pass = true; - } - return 0; -} -/*table 54 page 10h offset 130 */ -int qsfp_dd_tx_disable_set(struct sff_obj_t *sff_obj, u8 val) -{ - int ret = 0; - if (!is_bank_num_valid(sff_obj)) { - return -EBADRQC; - } - if((ret = qsfp_dd_eeprom_write(sff_obj, QSFP_PAGE_10h, QSFP_DD_TX_DISABLE_OFFSET, &val, sizeof(val))) < 0) { - return ret; - } - - return 0; -} -/*table 54 page 10h offset 130 */ -int qsfp_dd_tx_disable_get(struct sff_obj_t *sff_obj, u8 *val) -{ - int ret = 0; - u8 buf = 0; - if (!val) { - return -EINVAL; - } - if (!is_bank_num_valid(sff_obj)) { - return -EBADRQC; - } - if((ret = qsfp_dd_eeprom_read(sff_obj, QSFP_PAGE_10h, QSFP_DD_TX_DISABLE_OFFSET, &buf, sizeof(buf))) < 0) { - return -ret; - } - *val = buf; - return 0; -} -/*table 53 */ -static int data_path_power_up(struct sff_obj_t *sff_obj, bool up) -{ - int ret = 0; - u8 value = 0; - - if (up) { - value = 0xff; - } - if (!is_bank_num_valid(sff_obj)) { - return -EBADRQC; - } - if((ret = qsfp_dd_eeprom_write(sff_obj, QSFP_PAGE_10h, QSFP_DD_DATA_PATH_PWR_UP_OFFSET, &value, sizeof(value))) < 0) { - return ret; - } - - return 0; -} -#if 0 -/*Table 18- Identifier and Status Summary (Lower Page) offset 2 bit 7:Flat_mem*/ -static int qsfp_dd_is_flat_mem(struct sff_obj_t *sff_obj, bool *is_flat) -{ - u8 buf = 0; - u8 offset = 2; - - if(IS_ERR_OR_NULL(is_flat)) { - MODULE_LOG_ERR("invalid para"); - return -1; - } - if (qsfp_dd_eeprom_read(sff_obj, QSFP_PAGE0, offset, &buf, 1) < 0) { - *is_flat = false; - return -1; - } - - if (buf & 0x80) { - *is_flat = true; - } else { - *is_flat = false; - } - return 0; -} -#endif -/*optical: true copper: false*/ -static bool is_passive_module(struct sff_obj_t *sff_obj, bool *passive_module) -{ - int ret = 0; - bool tmp_passive_module = false; - u8 module_type = 0; - - if ((ret = qsfp_dd_module_type_get(sff_obj, &module_type)) < 0) { - return ret; - } - - switch (module_type) { - - case MODULE_PASSIVE_CU: - tmp_passive_module = true; - break; - case MODULE_TYPE_MMF: - case MODULE_TYPE_SMF: - case MODULE_ACTIVE_CABLES: - case MODULE_BASE_T: - default: - break; - - } - *passive_module = tmp_passive_module; - return 0; -} -#if 0 -/* so far it's used to de-assert- intL*/ -static int qsfp_dd_interrupt_flags_read(struct sff_obj_t *sff_obj) -{ - int ret = 0; - u8 module_flags[4]; - u8 lane_flags[19]; - /*table 15 module flags*/ - if ((ret = qsfp_dd_eeprom_read(sff_obj, QSFP_PAGE0, 8, module_flags, 4)) < 0) { - - MODULE_LOG_ERR("port:%d qsfp_dd_eeprom_read fail", port); - return ret; - } - /* table 16 Lane-Specific Flag*/ - if ((ret = qsfp_dd_eeprom_read(sff_obj, QSFP_PAGE_11h, 134, lane_flags, 19)) < 0) { - - MODULE_LOG_ERR("port:%d qsfp_dd_eeprom_read fail", port); - return ret; - } - - return 0; -} -#endif -static void cnt_increment_limit(u32 *data) -{ - if (*data < U32_MAX) { - (*data)++; - } -} -/*table 15*/ -static int qsfp_dd_intr_module_flag_update(struct sff_obj_t *sff_obj) -{ - int ret = 0; - int i = 0; - u8 module_flag[QSFP_DD_INT_MODULE_FLAG_NUM]; - u32 *cnt = NULL; - u32 old_cnt = 0; - struct qsfp_dd_priv_data *qsfp_dd_priv = qsfp_dd_priv_get(sff_obj); - - if ((ret = qsfp_dd_eeprom_read(sff_obj, QSFP_PAGE0, 8, module_flag, sizeof(module_flag))) < 0) { - return ret; - } - for (i = 0; i < QSFP_DD_INT_MODULE_FLAG_NUM; i++) { - cnt = &(qsfp_dd_priv->intr_module_flag[i].cnt); - old_cnt = qsfp_dd_priv->intr_module_flag[i].cnt; - qsfp_dd_priv->intr_module_flag[i].reg = module_flag[i]; - - if (module_flag[i] != 0x00) { - cnt_increment_limit(cnt); - if (int_flag_monitor_en) { - MODULE_LOG_ERR("%s error %s:0x%x", sff_obj->name, intr_module_flag_str[i], module_flag[i]); - } - } - - if (old_cnt != *cnt) { - qsfp_dd_priv->intr_module_flag[i].chg = true; - } else { - qsfp_dd_priv->intr_module_flag[i].chg = false; - } - } - - return 0; -} - -static int qsfp_dd_lane_status_update(struct sff_obj_t *sff_obj, int type, u8 value) -{ - if (type > LN_STATUS_NUM || - type < LN_STATUS_RX_LOS_TYPE) { - return -EINVAL; - } - - sff_obj->priv_data.qsfp_dd.lane_st[type] = value; - - return 0; -} -/*Table 68 TX Flags , 69- RX Flags (Page 11h, active modules only)*/ -static int qsfp_dd_intr_ln_flag_update(struct sff_obj_t *sff_obj) -{ - int ret = 0; - int i = 0; - u8 ln_flag[QSFP_DD_INT_LN_FLAG_NUM]; - u32 *cnt = NULL; - u32 old_cnt = 0; - struct qsfp_dd_priv_data *qsfp_dd_priv = qsfp_dd_priv_get(sff_obj); - - if ((ret = qsfp_dd_eeprom_read(sff_obj, - QSFP_PAGE_11h, - QSFP_DD_INTR_LN_FLAG_START_OFFSET, - ln_flag, - sizeof(ln_flag))) < 0) { - return ret; - } - qsfp_dd_lane_status_update(sff_obj, LN_STATUS_RX_LOS_TYPE, ln_flag[L_RX_LOS_ID]); - - for (i = 0; i < QSFP_DD_INT_LN_FLAG_NUM; i++) { - cnt = (&qsfp_dd_priv->intr_ln_flag[i].cnt); - old_cnt = qsfp_dd_priv->intr_ln_flag[i].cnt; - qsfp_dd_priv->intr_ln_flag[i].reg = ln_flag[i]; - - if (ln_flag[i] != 0x00) { - cnt_increment_limit(cnt); - if (int_flag_monitor_en) { - MODULE_LOG_ERR("%s chg %s:0x%x", sff_obj->name, intr_ln_flag_str[i], ln_flag[i]); - } - } - if (old_cnt != *cnt) { - qsfp_dd_priv->intr_ln_flag[i].chg = true; - } else { - qsfp_dd_priv->intr_ln_flag[i].chg = false; - } - } - - return 0; -} - -static void qsfp_dd_intr_flag_clear(struct sff_obj_t *sff_obj) -{ - struct qsfp_dd_priv_data *qsfp_dd_priv = qsfp_dd_priv_get(sff_obj); - memset(qsfp_dd_priv->intr_module_flag, 0, sizeof(qsfp_dd_priv->intr_module_flag)); - memset(qsfp_dd_priv->intr_ln_flag, 0, sizeof(qsfp_dd_priv->intr_ln_flag)); -} - -static int qsfp_dd_intr_flag_show(struct sff_obj_t *sff_obj, char *buf, int size) -{ - int count = 0; - int i = 0; - u32 cnt = 0; - char chg = ' '; - u8 intL = 0; - int ret = 0; - struct qsfp_dd_priv_data *qsfp_dd_priv = qsfp_dd_priv_get(sff_obj); - - /*handle transition back to normal state from intL state {*/ - if ((ret = qsfp_dd_intL_get(sff_obj, &intL)) < 0) { - return ret; - } - if (intL) { - if ((ret = qsfp_dd_intr_module_flag_update(sff_obj)) < 0) { - return ret; - } - if ((ret = qsfp_dd_intr_ln_flag_update(sff_obj)) < 0 ) { - return ret; - } - } - /*handle transition back to normal state from intL state }*/ - - count += scnprintf(buf+count, size-count, - "intr module flag show:\n"); - for (i = 0; i < QSFP_DD_INT_MODULE_FLAG_NUM; i++) { - - cnt = qsfp_dd_priv->intr_module_flag[i].cnt; - if (0 != cnt) { - if (qsfp_dd_priv->intr_module_flag[i].chg) { - chg = '*'; - } else { - chg = ' '; - } - count += scnprintf(buf+count, size-count, - "%s reg:0x%x cnt:%d%c\n", - intr_module_flag_str[i], - qsfp_dd_priv->intr_module_flag[i].reg, - cnt, - chg); - } - } - count += scnprintf(buf+count, size-count, - "intr lane flag show:\n"); - for (i = 0; i < QSFP_DD_INT_LN_FLAG_NUM; i++) { - cnt = qsfp_dd_priv->intr_ln_flag[i].cnt; - if (0 != cnt) { - if (qsfp_dd_priv->intr_ln_flag[i].chg) { - chg = '*'; - } else { - chg = ' '; - } - count += scnprintf(buf+count, size-count, - "%s reg:0x%x cnt:%d%c\n", - intr_ln_flag_str[i], - qsfp_dd_priv->intr_ln_flag[i].reg, - cnt, - chg); - } - } - return 0; -} -int qsfp_dd_ln_st_get(struct sff_obj_t *sff_obj, int type, u8 *st) -{ - u8 intL = 0; - int ret = 0; - struct qsfp_dd_priv_data *qsfp_dd_priv = qsfp_dd_priv_get(sff_obj); - - if ((ret = qsfp_dd_intL_get(sff_obj, &intL)) < 0) { - return ret; - } - if (intL) { - if ((ret = qsfp_dd_intr_module_flag_update(sff_obj)) < 0) { - return ret; - } - if ((ret = qsfp_dd_intr_ln_flag_update(sff_obj)) < 0 ) { - return ret; - } - } - - *st = qsfp_dd_priv->lane_st[type]; - return 0; -} -static void cache_clear(struct sff_obj_t *sff_obj) -{ - memset(&(sff_obj->priv_data.qsfp_dd), 0, sizeof(struct qsfp_dd_priv_data)); -} - -void qsfp_dd_rev4_quick_set(struct sff_obj_t *sff_obj, bool en) -{ - sff_obj->priv_data.qsfp_dd.rev4_quick_en = en; -} - -bool qsfp_dd_rev4_quick_get(struct sff_obj_t *sff_obj) -{ - return sff_obj->priv_data.qsfp_dd.rev4_quick_en; -} -static void qsfp_dd_def_set(struct sff_obj_t *sff_obj) -{ - /*default loading*/ - qsfp_dd_apsel_apply(sff_obj, 1); -} -int sff_fsm_qsfp_dd_task(struct sff_obj_t *sff_obj) -{ - sff_fsm_state_t st = sff_fsm_st_get(sff_obj); - int ret = 0; - u8 module_st = 0; - u8 lpmode = 0; - u8 lv = 0; - u8 rst = 0; - u8 power = 0; - bool pass = false; - bool ready = false; - bool passive_module = false; - bool supported = false; - struct qsfp_dd_priv_data *qsfp_dd_priv = qsfp_dd_priv_get(sff_obj); - - switch (st) { - case SFF_FSM_ST_IDLE: - break; - case SFF_FSM_ST_REMOVED: - cache_clear(sff_obj); - sff_fsm_st_set(sff_obj, SFF_FSM_ST_IDLE); - break; - case SFF_FSM_ST_INSERTED: - qsfp_dd_def_set(sff_obj); - sff_fsm_st_set(sff_obj, SFF_FSM_ST_DETECTING); - break; - case SFF_FSM_ST_DETECTING: - - if ((ret = qsfp_dd_reset_get(sff_obj, &rst)) < 0) { - break; - } - if ((ret = sff_power_get(sff_obj, &power)) < 0) { - break; - } - - if (!rst || !power) { - MODULE_LOG_ERR("%s rst:%d power:%d\n",sff_obj->name, rst, power); - sff_fsm_st_set(sff_obj, SFF_FSM_ST_SUSPEND); - break; - } - - if ((ret = qsfp_dd_reset_set(sff_obj, 0)) < 0) { - break; - } - - sff_fsm_st_set(sff_obj, SFF_FSM_ST_MODULE_UNRESET); - break; - - case SFF_FSM_ST_MODULE_UNRESET: - if ((ret = qsfp_dd_reset_set(sff_obj, 1)) < 0) { - break; - } - sff_fsm_st_set(sff_obj, SFF_FSM_ST_MGMT_INIT); - break; - case SFF_FSM_ST_MGMT_INIT: - if ((ret = qsfp_dd_paging_supported(sff_obj, &supported)) < 0) { - return ret; - } - /*use cache instead*/ - sff_obj->priv_data.qsfp_dd.paging_supported = supported; - /*check module state register if it transit to module low power state*/ - if ((ret = qsfp_dd_module_st_get(sff_obj, &module_st)) < 0) { - break; - } - - if ((ret = is_passive_module(sff_obj, &passive_module)) < 0) { - break; - } - - if (passive_module) { - sff_fsm_st_set(sff_obj, SFF_FSM_ST_READY); - } else { - - if ((ret = qsfp_dd_lpmode_get(sff_obj, &lpmode)) < 0) { - break; - } - if (lpmode) { - - if (MODULE_LOW_PWR_ST_ENCODE == module_st) { - if (is_loopback_module(sff_obj)) { - - sff_fsm_st_set(sff_obj, SFF_FSM_ST_MODULE_LOOPBACK_INIT); - } else { - - sff_fsm_st_set(sff_obj, SFF_FSM_ST_MODULE_CMIS_VER_CHECK); - } - } - } else { - sff_fsm_st_set(sff_obj, SFF_FSM_ST_MODULE_HW_INIT); - } - } - - break; - case SFF_FSM_ST_MODULE_CMIS_VER_CHECK: - - if ((ret = fsm_func_get(sff_obj, &(qsfp_dd_priv->fsm_func))) < 0) { - break; - } - - sff_fsm_st_set(sff_obj, SFF_FSM_ST_MODULE_ADVERT_CHECK); - break; - case SFF_FSM_ST_MODULE_ADVERT_CHECK: - - if ((ret = qsfp_dd_priv->fsm_func->advert_check(sff_obj, &pass)) < 0) { - break; - } - if (pass) { - sff_fsm_st_set(sff_obj, SFF_FSM_ST_MODULE_SW_CONFIG_1); - } - break; - case SFF_FSM_ST_MODULE_SW_CONFIG_1: - - if ((ret = qsfp_dd_priv->fsm_func->sw_config_1(sff_obj)) < 0) { - break; - } - sff_fsm_st_set(sff_obj, SFF_FSM_ST_MODULE_SW_CONFIG_2); - break; - case SFF_FSM_ST_MODULE_SW_CONFIG_2: - - if ((ret = qsfp_dd_priv->fsm_func->sw_config_2(sff_obj, &pass)) < 0) { - break; - } - if (pass) { - sff_fsm_st_set(sff_obj, SFF_FSM_ST_MODULE_SW_CONFIG_CHECK); - } - break; - case SFF_FSM_ST_MODULE_SW_CONFIG_CHECK: - - if ((ret = qsfp_dd_priv->fsm_func->sw_config_check(sff_obj, &pass)) < 0) { - break; - } - - if (pass) { - - sff_fsm_st_set(sff_obj, SFF_FSM_ST_MODULE_SW_CONTROL); - } - break; - case SFF_FSM_ST_MODULE_SW_CONTROL: - - if ((ret = qsfp_dd_priv->fsm_func->sw_control(sff_obj)) < 0) { - break; - } - - sff_fsm_st_set(sff_obj, SFF_FSM_ST_MODULE_READY_CHECK); - break; - case SFF_FSM_ST_MODULE_READY_CHECK: - - if ((ret = qsfp_dd_priv->fsm_func->module_ready_check(sff_obj, &ready)) < 0) { - break; - } - if (ready) { - sff_fsm_st_set(sff_obj, SFF_FSM_ST_MODULE_READY); - } - break; - case SFF_FSM_ST_MODULE_READY: - - sff_fsm_st_set(sff_obj, SFF_FSM_ST_READY); - break; - - case SFF_FSM_ST_MODULE_HW_INIT: - case SFF_FSM_ST_MODULE_LOOPBACK_INIT: - - if ((ret = qsfp_dd_module_st_get(sff_obj, &module_st)) < 0) { - break; - } - /*check module state register if it transit to module ready*/ - if (MODULE_READY_ST_ENCODE == module_st) { - sff_fsm_st_set(sff_obj, SFF_FSM_ST_READY); - } - break; - case SFF_FSM_ST_READY: - if ((ret = is_passive_module(sff_obj, &passive_module)) < 0) { - break; - } - if (!passive_module) { - if ((ret = qsfp_dd_intL_get(sff_obj, &lv)) < 0) { - break; - } - if (!lv) { - if ((ret = qsfp_dd_intr_module_flag_update(sff_obj)) < 0) { - break; - } - if ((ret = qsfp_dd_intr_ln_flag_update(sff_obj)) < 0 ) { - break; - } - } - } - break; - case SFF_FSM_ST_SUSPEND: - break; - case SFF_FSM_ST_RESTART: - - if ((ret = sff_prs_get(sff_obj, &lv)) < 0) { - break; - } - if (lv) { - sff_fsm_st_set(sff_obj, SFF_FSM_ST_DETECTING); - } else { - sff_fsm_st_set(sff_obj, SFF_FSM_ST_REMOVED); - } - break; - case SFF_FSM_ST_FAULT:/*i2c bus fail ... etc*/ - - break; - case SFF_FSM_ST_UNKNOWN_TYPE: - - break; - default: - MODULE_LOG_ERR("unknown fsm st:%d\n", st); - break; - - } - if (ret < 0) { - return ret; - } - return 0; -} - diff --git a/packages/platforms/inventec/x86-64/d7332/modules/builds/src/qsfp_dd.h b/packages/platforms/inventec/x86-64/d7332/modules/builds/src/qsfp_dd.h deleted file mode 100644 index 2370da323..000000000 --- a/packages/platforms/inventec/x86-64/d7332/modules/builds/src/qsfp_dd.h +++ /dev/null @@ -1,11 +0,0 @@ -#ifndef __SFF_QSFP_DD_H -#define __SFF_QSFP_DD_H - -int qsfp_dd_apsel_apply(struct sff_obj_t *sff_obj, int apsel); -int qsfp_dd_apsel_get(struct sff_obj_t *sff_obj); -int qsfp_dd_active_ctrl_set_get(struct sff_obj_t *sff_obj, char *buf, int size); -void qsfp_dd_rev4_quick_set(struct sff_obj_t *sff_obj, bool en); -bool qsfp_dd_rev4_quick_get(struct sff_obj_t *sff_obj); -int sff_fsm_qsfp_dd_task(struct sff_obj_t *sff_obj); -struct func_tbl_t *qsfp_dd_func_load(void); -#endif /*__SFF_QSFP_DD_H*/ diff --git a/packages/platforms/inventec/x86-64/d7332/modules/builds/src/sff_eeprom.c b/packages/platforms/inventec/x86-64/d7332/modules/builds/src/sff_eeprom.c deleted file mode 100644 index 749ebaa4c..000000000 --- a/packages/platforms/inventec/x86-64/d7332/modules/builds/src/sff_eeprom.c +++ /dev/null @@ -1,606 +0,0 @@ -/* - sff_eeprom.c - provide api for accesing sff eeprom - - */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "sff_eeprom.h" -#include "inv_def.h" -#include "inv_swps.h" -#include "eeprom_config/eeprom_config.h" - -/* - * This module implement sff platform driver and provide sysfs attribute for access io control - * and eeprom - * - */ - -#define I2C_BLOCK_READ_SUPPORT - -#define EEPROM_LOG_ERR(fmt, args...) \ - do { \ - if (logLevel & EEPROM_ERR_LEV) \ - { \ - printk (KERN_ERR "[EEPROM]%s:"fmt,__FUNCTION__, ##args); \ - } \ - } while (0) - -#define EEPROM_LOG_INFO(fmt, args...) \ - do { \ - if (logLevel & EEPROM_INFO_LEV) \ - { \ - printk (KERN_INFO "[EEPROM]%s:"fmt,__FUNCTION__, ##args); \ - } \ - } while (0) - -#define EEPROM_LOG_DBG(fmt, args...) \ - do { \ - if (logLevel & EEPROM_DBG_LEV) \ - { \ - printk (KERN_INFO "[EEPROM]%s:"fmt,__FUNCTION__, ##args); \ - } \ - } while (0) - -#define QSFP_ID_OFFSET (0) -extern u32 logLevel; - -struct sff_eeprom_t { - int port; - struct i2c_client *i2c_client; - struct mutex lock; -}; -struct eeprom_i2c_tbl_t *eepromI2cTbl = NULL; -struct i2c_client *sffEepromI2cClient = NULL; -struct sff_eeprom_t *sffEEprom = NULL; -int sff_eeprom_read_lc( int lc_id, - int port, - u8 slave_addr, - u8 offset, - u8 *buf, - size_t len); - -int sff_eeprom_write_lc( int lc_id, - int port, - u8 slave_addr, - u8 offset, - const u8 *buf, - size_t len); - -static int lcMaxPortNum = 0; -static struct sff_eeprom_driver_t sffEepromDrvFunc = { - .eeprom_read = sff_eeprom_read_lc, - .eeprom_write = sff_eeprom_write_lc, -}; -struct sff_eeprom_driver_t *sff_eeprom_drv_get(void) -{ - return &sffEepromDrvFunc; -} - - -#if 0 -static int i2c_smbus_read_i2c_block_data_retry(struct i2c_client *client, u8 offset, int len, u8 *buf) -{ - int ret = 0; - int i = 0; - - for (i = 0; i < RETRY_COUNT; i++) { - - ret = i2c_smbus_read_i2c_block_data(client, offset, len, buf); - if (ret < 0) { - msleep(RETRY_DELAY_MS); - continue; - } - break; - } - - if (i >= RETRY_COUNT) { - EEPROM_LOG_INFO("%s fail:offset:0x%x try %d/%d! Error Code: %d\n", __func__, offset, i, RETRY_COUNT, ret); - } - - return ret; - -} -#endif -#if 0 -#if defined V1 -static int inv_i2c_smbus_read_i2c_block_data(struct i2c_client *client, u8 offset, int len, u8 *buf) -{ - int ret = 0; - int i = 0; - int cnt = len; - while (cnt > I2C_SMBUS_BLOCK_MAX) { - - ret = i2c_smbus_read_i2c_block_data_retry(client, offset+i, I2C_SMBUS_BLOCK_MAX, buf+i); - if (ret < 0) { - - break; - } - i += I2C_SMBUS_BLOCK_MAX; - cnt = len - i; - } - if (cnt <= I2C_SMBUS_BLOCK_MAX) { - - ret = i2c_smbus_read_i2c_block_data_retry(client, offset+i, cnt, buf+i); - - } - return ret; - -} -#else - -static int inv_i2c_smbus_read_i2c_block_data(struct i2c_client *client, u8 offset, int len, u8 *buf) -{ - int ret = 0; - int i = 0; - int cnt = len; - int block_size = 0; - - while (i < len) { - block_size = ((cnt > I2C_SMBUS_BLOCK_MAX) ? I2C_SMBUS_BLOCK_MAX : cnt); - ret = i2c_smbus_read_i2c_block_data_retry(client, offset+i, block_size, buf+i); - - if (ret < 0) { - break; - } - - i += block_size; - cnt = len - i; - } - - if (ret < 0) { - return ret; - } - return 0; -} - - - -#endif -#endif -#if 0 -static int inv_i2c_smbus_write_block_data(struct i2c_client *client, u8 offset, int len, const u8 *buf) -{ - int ret = 0; - int i = 0; - - for (i = 0; i < RETRY_COUNT; i++) { - - ret = i2c_smbus_write_i2c_block_data(client, offset, len, buf); - if (ret < 0) { - msleep(RETRY_DELAY_MS); - continue; - } - break; - } - - if (i >= RETRY_COUNT) { - EEPROM_LOG_INFO("%s fail:offset:0x%x try %d/%d! Error Code: %d\n", __func__, offset, i, RETRY_COUNT, ret); - } - - return ret; - -} -#endif -#if defined (I2C_BLOCK_READ_SUPPORT) - -static int _sff_eeprom_block_read(struct sff_eeprom_t *eeprom, - u8 slave_addr, - u8 offset, - u8 *buf, - size_t len) -{ - struct i2c_client *client = NULL; - struct mutex *lock = NULL; - int ret = 0; - - if(!eeprom || - !buf) { - return -EINVAL; - } - lock = &(eeprom->lock); - client = eeprom->i2c_client; - - if(!client) { - return -EBADRQC; - } - - mutex_lock(lock); - client->addr = slave_addr; - ret = i2c_smbus_read_i2c_block_data_retry(client, offset, len, buf); - mutex_unlock(lock); - return 0; - -} - -#else -static int _sff_eeprom_read(struct sff_eeprom_t *eeprom, - u8 slave_addr, - u8 offset, - u8 *buf, - size_t len) -{ - struct i2c_client *client = NULL; - struct mutex *lock = NULL; - int ret = 0; - int count = 0; - u8 *ptr = NULL; - - if(!eeprom || - !buf) { - return -EINVAL; - } - ptr = buf; - lock = &(eeprom->lock); - client = eeprom->i2c_client; - - if(!client) { - return -EBADRQC; - } - - mutex_lock(lock); - client->addr = slave_addr; - for(count = 0; count < len; count++) { - ret = i2c_smbus_read_byte_data_retry(client, offset+count); - if (ret < 0) { - EEPROM_LOG_INFO("i2c_read fail ret:%d\n", ret); - mutex_unlock(lock); - - return ret; - } - ptr[count] = (u8)ret; - } - - mutex_unlock(lock); -#ifdef READBACK_CHECK - for(count = 0; count < len; count++) { - EEPROM_LOG_DBG("i2c_read ok buf[%d]:0x%x\n", count, buf[count]); - } -#endif - return 0; - -} -#endif - -static int _sff_eeprom_write(struct sff_eeprom_t *eeprom, - u8 slave_addr, - u8 offset, - const u8 *buf, - size_t len) -{ - struct i2c_client *client = NULL; - struct mutex *lock = NULL; - int ret = 0; - int count = 0; - const u8 *ptr = buf; - - if(!eeprom || - !buf) { - return -EINVAL; - } - - lock = &(eeprom->lock); - client = eeprom->i2c_client; - - if(!client) { - return -EBADRQC; - } - - mutex_lock(lock); - client->addr = slave_addr; - for(count = 0; count < len; count++) { - ret = i2c_smbus_write_byte_data_retry(client, offset+count, ptr[count]); - if (ret < 0) { - EEPROM_LOG_ERR("i2c_write fail ret:%d\n", ret); - mutex_unlock(lock); - return ret; - } - } - - mutex_unlock(lock); - return 0; - -} -void sff_eeprom_port_num_set(int port_num) -{ - lcMaxPortNum = port_num; -} -static int port_to_new_port(int lc_id, int port) -{ - int new_port = 0; -#if 1 /*enable it while bring up*/ - new_port = (lcMaxPortNum * lc_id) + port; -#else - new_port = port; -#endif - return new_port; -} -static bool port_range_valid(int new_port) -{ - int port_num = eepromI2cTbl->size; - return ((new_port >= 0 && new_port < port_num) ? true : false); -} -void sff_eeprom_read_no_retry(int lc_id, int port) -{ - struct sff_eeprom_t *eeprom = NULL; - int new_port = 0; - /*remapping*/ - new_port = port_to_new_port(lc_id, port); - /*check port range here*/ - if (!port_range_valid(new_port)) { - EEPROM_LOG_ERR("port out of range: new port:%d \n", new_port); - return; - } - - eeprom = &sffEEprom[new_port]; - mutex_lock(&eeprom->lock); - i2c_smbus_read_byte_data(eeprom->i2c_client, QSFP_ID_OFFSET); - mutex_unlock(&eeprom->lock); -} - -int sff_eeprom_read_lc( int lc_id, - int port, - u8 slave_addr, - u8 offset, - u8 *buf, - size_t len) -{ - int new_port = 0; - /*remapping*/ - new_port = port_to_new_port(lc_id, port); - /*check port range here*/ - if (!port_range_valid(new_port)) { - EEPROM_LOG_ERR("port out of range: new port:%d \n", new_port); - return -EBADRQC; - } -#if defined (I2C_BLOCK_READ_SUPPORT) - - return _sff_eeprom_block_read(&sffEEprom[new_port], slave_addr, offset, buf, len); -#else - return _sff_eeprom_read(&sffEEprom[new_port], slave_addr, offset, buf, len); - -#endif -} - -int sff_eeprom_write_lc( int lc_id, - int port, - u8 slave_addr, - u8 offset, - const u8 *buf, - size_t len) -{ - int new_port = 0; - /*remapping*/ - new_port = port_to_new_port(lc_id, port); - /*check port range here*/ - if (!port_range_valid(new_port)) { - EEPROM_LOG_ERR("port out of range: new port:%d \n", new_port); - return -EBADRQC; - } - - return _sff_eeprom_write(&sffEEprom[new_port], slave_addr, offset, buf, len); -} -#if 0 -int sff_eeprom_read_internal(int port, - u8 slave_addr, - u8 offset, - u8 *buf, - size_t len) -{ - - if (!port_range_valid(port)) { - EEPROM_LOG_ERR("port out of range: new port:%d \n", port); - return -EBADRQC; - } - -#if defined (I2C_BLOCK_READ_SUPPORT) - - return _sff_eeprom_block_read(&sffEEprom[port], slave_addr, offset, buf, len); -#else - return _sff_eeprom_read(&sffEEprom[port], slave_addr, offset, buf, len); - -#endif - -} -int sff_eeprom_write_internal(int port, - u8 slave_addr, - u8 offset, - const u8 *buf, - size_t len) -{ - return _sff_eeprom_write(&sffEEprom[port], slave_addr, offset, buf, len); -} -#endif -static void sff_eeprom_clients_destroy(int size) -{ - int port = 0; - - if (p_valid(sffEepromI2cClient)) { - kfree(sffEepromI2cClient); - } - for (port = 0; port < size; port++) { - sffEEprom[port].i2c_client = NULL; - } -} -static int sff_eeprom_clients_create(int size) -{ - struct i2c_client *client = NULL; - int port = 0; - - client = kzalloc(sizeof(struct i2c_client) * size, GFP_KERNEL); - - if (!p_valid(client)) { - return -ENOMEM; - } - sffEepromI2cClient = client; - - for (port = 0; port < size; port++) { - sffEEprom[port].i2c_client = &sffEepromI2cClient[port]; - } - - return 0; -} -/*init i2c adapter*/ -static int _sff_eeprom_client_init(struct sff_eeprom_t *eeprom, struct eeprom_config_t *config) -{ - struct i2c_adapter *adap; - struct i2c_client *client = NULL; - - if (!eeprom || - !config) { - return -EBADRQC; - } - client = eeprom->i2c_client; - adap = i2c_get_adapter(config->i2c_ch); - if (!adap) { - EEPROM_LOG_ERR("fail to get adapter ch:%d\n", config->i2c_ch); - return -EBADRQC; - } - client->adapter = adap; - client->addr = SFF_EEPROM_I2C_ADDR; - - eeprom->i2c_client = client; - EEPROM_LOG_DBG("ok i2c_ch:%d\n", config->i2c_ch); - mutex_init(&(eeprom->lock)); - return 0; - -} -static void sff_eeprom_clients_deinit(int size) -{ - int port = 0; - int port_num = size; - struct i2c_client *client = NULL; - - if (!sffEEprom) { - - EEPROM_LOG_ERR("NULL pointer\n"); - return; - } - for (port = 0; port < port_num; port++) { - client = sffEEprom[port].i2c_client; - if (p_valid(client)) { - if (p_valid(client->adapter)) { - i2c_put_adapter(client->adapter); - } - } - } -} - - -static int sff_eeprom_clients_init(struct eeprom_i2c_tbl_t *tbl) -{ - int port = 0; - int port_num = 0; - struct eeprom_config_t *map = NULL; - int ret = 0; - if(!tbl) { - return -EBADRQC; - } - port_num = tbl->size; - map = tbl->map; - for (port = 0; port < port_num; port++) { - - if (_sff_eeprom_client_init(&sffEEprom[port], &map[port]) < 0) { - ret = -EBADRQC; - break; - } - } - if (ret < 0) { - sff_eeprom_clients_deinit(eepromI2cTbl->size); - } - - return 0; - -} -static int sff_eeprom_objs_create(int size) -{ - - sffEEprom = kzalloc(sizeof(struct sff_eeprom_t) * size, GFP_KERNEL); - - if(!p_valid(sffEEprom)) { - return -ENOMEM; - } - - return 0; -} - -static struct eeprom_i2c_tbl_t *_platform_eeprom_info_load(int platform_id) -{ - int i = 0; - struct eeprom_i2c_tbl_t *tbl = NULL; - for (i = 0; platform_eeprom_info_tbl[i].platform_id != PLATFORM_END; i++) { - if (platform_eeprom_info_tbl[i].platform_id == platform_id) { - - tbl = platform_eeprom_info_tbl[i].tbl; - return tbl; - } - } - - return NULL; -} - -static int eeprom_i2c_table_load(int platform_id) -{ - struct eeprom_i2c_tbl_t *tbl = NULL; - - tbl = _platform_eeprom_info_load(platform_id); - if (!tbl) { - return -EBADRQC; - } - eepromI2cTbl = tbl; - return 0; -} -static void sff_eeprom_objs_destroy(void) -{ - if(p_valid(sffEEprom)) { - kfree(sffEEprom); - } -} -int sff_eeprom_init(int platform_id) -{ - if (eeprom_i2c_table_load(platform_id) < 0) { - goto exit_err; - } - if (sff_eeprom_objs_create(eepromI2cTbl->size) < 0) { - goto exit_err; - } - - if (sff_eeprom_clients_create(eepromI2cTbl->size) < 0) { - goto exit_kfree_obj; - } -#if 1 - if (sff_eeprom_clients_init(eepromI2cTbl) < 0) { - goto exit_kfree_client; - } -#endif - EEPROM_LOG_INFO("ok\n"); - return 0; - -exit_kfree_client: - sff_eeprom_clients_destroy(eepromI2cTbl->size); -exit_kfree_obj: - sff_eeprom_objs_destroy(); -exit_err: - return -EBADRQC; -} - -void sff_eeprom_deinit(void) -{ - sff_eeprom_clients_deinit(eepromI2cTbl->size); - sff_eeprom_clients_destroy(eepromI2cTbl->size); - sff_eeprom_objs_destroy(); - - EEPROM_LOG_INFO("ok\n"); -} diff --git a/packages/platforms/inventec/x86-64/d7332/modules/builds/src/sff_eeprom.h b/packages/platforms/inventec/x86-64/d7332/modules/builds/src/sff_eeprom.h deleted file mode 100644 index 09c2b63ed..000000000 --- a/packages/platforms/inventec/x86-64/d7332/modules/builds/src/sff_eeprom.h +++ /dev/null @@ -1,20 +0,0 @@ -//port info -#ifndef __SFF_EEPROM_H -#define __SFF_EEPROM_H - -struct eeprom_config_t { - int port; - int i2c_ch; -}; -struct eeprom_i2c_tbl_t { - - struct eeprom_config_t *map; - int size; -}; - -int sff_eeprom_init(int platform_id); -void sff_eeprom_deinit(void); -void sff_eeprom_port_num_set(int port_num); -void sff_eeprom_read_no_retry(int lc_id, int port); -struct sff_eeprom_driver_t *sff_eeprom_drv_get(void); -#endif /*__SFF_EEPROM_H*/ diff --git a/packages/platforms/inventec/x86-64/d7332/modules/builds/src/sff_spec.h b/packages/platforms/inventec/x86-64/d7332/modules/builds/src/sff_spec.h deleted file mode 100644 index c41cab6b2..000000000 --- a/packages/platforms/inventec/x86-64/d7332/modules/builds/src/sff_spec.h +++ /dev/null @@ -1,327 +0,0 @@ -#ifndef __SFF_SPEC_H -#define __SFF_SPEC_H - -//sff spec , 8472 8436 -typedef enum { - /* Shared QSFP and SFP fields: */ - IDENTIFIER, /* Type of Transceiver */ - STATUS, /* Support flags for upper pages */ - INTERRUPT_FLAG, - TEMPERATURE_ALARMS, - VCC_ALARMS, /* Voltage */ - CHANNEL_RX_PWR_ALARMS, - CHANNEL_TX_BIAS_ALARMS, - TEMPERATURE, - VCC, /* Voltage */ - CHANNEL_RX_PWR, - CHANNEL_TX_PWR,/*inventec add*/ - CHANNEL_TX_BIAS, - CHANNEL_TX_DISABLE, - POWER_CONTROL, - ETHERNET_COMPLIANCE, - EXTENDED_IDENTIFIER, - PAGE_SELECT_BYTE, - LENGTH_SM_KM, /* Single mode, in km */ - LENGTH_SM, /* Single mode in 100m (not in QSFP) */ - LENGTH_OM3, - LENGTH_OM2, - LENGTH_OM1, - LENGTH_COPPER, - VENDOR_NAME, /* QSFP Vendor Name (ASCII) */ - VENDOR_OUI, /* QSFP Vendor IEEE company ID */ - PART_NUMBER, /* Part NUmber provided by QSFP vendor (ASCII) */ - REVISION_NUMBER, /* Revision number */ - ETHERNET_EXTENDED_COMPLIANCE, /* ethernet extended compliance code */ - VENDOR_SERIAL_NUMBER, /* Vendor Serial Number (ASCII) */ - MFG_DATE, /* Manufacturing date code */ - DIAGNOSTIC_MONITORING_TYPE, /* Diagnostic monitoring implemented */ - TEMPERATURE_THRESH, - VCC_THRESH, - RX_PWR_THRESH, - TX_BIAS_THRESH, - - /* SFP-specific Fields */ - /* 0xA0 Address Fields */ - EXT_IDENTIFIER, /* Extended type of transceiver */ - CONNECTOR_TYPE, /* Code for Connector Type */ - TRANSCEIVER_CODE, /* Code for Electronic or optical capability */ - ENCODING_CODE, /* High speed Serial encoding algo code */ - SIGNALLING_RATE, /* nominal signalling rate */ - RATE_IDENTIFIER, /* type of rate select functionality */ - TRANCEIVER_CAPABILITY, /* Code for Electronic or optical capability */ - WAVELENGTH, /* laser wavelength */ - CHECK_CODE_BASEID, /* Check code for the above fields */ - /* Extended options */ - ENABLED_OPTIONS, /* Indicates the optional transceiver signals enabled */ - UPPER_BIT_RATE_MARGIN, /* upper bit rate margin */ - LOWER_BIT_RATE_MARGIN, /* lower but rate margin */ - ENHANCED_OPTIONS, /* Enhanced options implemented */ - SFF_COMPLIANCE, /* revision number of SFF compliance */ - CHECK_CODE_EXTENDED_OPT, /* check code for the extended options */ - VENDOR_EEPROM, - /*inventec add*/ - CDR_CONTROL, - OPTIIONAL_CHANNEL_CONTROL_TX_EQ, - OPTIIONAL_CHANNEL_CONTROL_RX_EM, - OPTIIONAL_CHANNEL_CONTROL_RX_AM, - OPTIIONAL_INDICATOR, - OPTIIONAL_INDICATOR_EM, - /* 0xA2 address Fields */ - /* Diagnostics */ - ALARM_THRESHOLD_VALUES, /* diagnostic flag alarm and warning thresh values */ - EXTERNAL_CALIBRATION, /* diagnostic calibration constants */ - CHECK_CODE_DMI, /* Check code for base Diagnostic Fields */ - DIAGNOSTICS, /* Diagnostic Monitor Data */ - STATUS_CONTROL, /* Optional Status and Control bits */ - ALARM_WARN_FLAGS, /* Diagnostic alarm and warning flag */ - EXTENDED_STATUS_CONTROL, /* Extended status and control bytes */ - /* General Purpose */ - VENDOR_MEM_ADDRESS, /* Vendor Specific memory address */ - USER_EEPROM, /* User Writable NVM */ - VENDOR_CONTROL, /* Vendor Specific Control */ - /*qsfp-dd*/ - ID_STATUS_SUMMARY, - MODULE_FLAGS, - SFF_FIELD_MAX /* keep this the last */ -} Sff_field; - - -typedef struct { - u8 slave_addr; - u8 offset; - int length; -} sff_sfp_field_info_t; - -typedef struct { - Sff_field field; - sff_sfp_field_info_t data; -} sff_sfp_field_map_t; - -typedef enum { - //QSFP_PAGE0 = 0xff, - QSFP_PAGE0 = 0, - QSFP_PAGE3 = 3 , - QSFP_PAGE_01h = 0x01, - QSFP_PAGE_10h = 0x10, - QSFP_PAGE_11h = 0x11, -} Qsfp_page; - -typedef struct { - Qsfp_page page; - u8 offset; - int length; -} sff_qsfp_field_info_t; - -typedef struct { - Sff_field field; - sff_qsfp_field_info_t data; -} sff_qsfp_field_map_t; - - -typedef struct { - unsigned rx_output_em: 4; - unsigned tx_input_eq: 4; - unsigned rx_output_amp1: 1; - unsigned rx_output_amp2: 1; - unsigned rx_output_amp3: 1; - unsigned rx_output_amp4: 1; - unsigned rx_output_em_type: 2; - unsigned reserved: 2; - -} qsfp_optional_indicator_t; /*u16 size*/ - -/* following complianbce codes are derived from SFF-8436 document */ -typedef enum { - COMPLIANCE_NONE = 0, - ACTIVE_CABLE = 1 << 0, - LR4_40GBASE = 1 << 1, - SR4_40GBASE = 1 << 2, - CR4_40GBASE = 1 << 3, - /*10G Ethernet Compliance Codes*/ - SR_10GBASE = 1 << 4, - LR_10GBASE = 1 << 5, - LRM_10GBASE = 1 << 6, - ER_10GBASE = 1 << 7,/*COMPLIANCE_RSVD*/ -} Ethernet_compliance; - -/* following complianbce codes are derived from SFF-8024 document */ -typedef enum { - EXT_COMPLIANCE_NONE = 0, - AOC_100G_BER_5 = 0x01, /* 100G AOC or 25G AUI C2M AOC 5 * 10^^-5 BER */ - SR4_100GBASE = 0x02, /* or SR-25GBASE */ - LR4_100GBASE = 0x03, /* or LR-25GBASE */ - ER4_100GBASE = 0x04, /* or ER-25GBASE */ - SR10_100GBASE = 0x05, - CWDM4_100G = 0x06, - PSM4_100G_SMF = 0x07, - ACC_100G_BER_5 = 0x08, /* 100G ACC or 25G AUI C2M ACC 5 * 10^^-5 BER */ - EXT_COMPLIANCE_OBSOLETE = 0x09, - EXT_COMPLIANCE_RSVD1 = 0x0A, - CR4_100GBASE = 0x0B, /* or CR-25GBASE CA-L */ - CR_25GBASE_CA_S = 0x0C, - CR_25GBASE_CA_N = 0x0D, - EXT_COMPLIANCE_RSVD2 = 0x0E, - EXT_COMPLIANCE_RSVD3 = 0x0F, - ER4_40GBASE = 0x10, - SR_10GBASE_4 = 0x11, - PSM4_40G_SMF = 0x12, - G959_P1I1_2D1 = 0x13, /* 10709 Mbd, 2 km, 1310nm SM */ - G959_P1S1_2D2 = 0x14, /* 10709 Mbd, 40 km, 1550nm SM */ - G959_P1L1_2D2 = 0x15, /* 10709 Mbd, 80 km, 1550nm SM */ - T_10BASE_SFI = 0x16, /* 10BASE-T with SFI electrical interface */ - CLR4_100G = 0x17, - AOC_100G_BER_12 = 0x18, /* 100G AOC or 25G AUI C2M AOC 10^^-12 BER */ - ACC_100G_BER_12 = 0x19, /* 100G ACC or 25G AUI C2M ACC 10^^-12 BER */ - DWDM2_100GE = 0x1A, /* DMWM module using 1550nm, 80 km */ -} Ethernet_extended_compliance; - -typedef enum { - POWER_CLASS_1_MODULE = 0, - POWER_CLASS_2_MODULE = 1, - POWER_CLASS_3_MODULE = 2, - POWER_CLASS_4_MODULE = 3, - -} Power_Class_t; - -struct qsfp_interrupt_flag_t { - - u8 los_ind; // 3. [7:4] Tx LOS : [3:0] Rx LOS - u8 eq_laser_fault; // 4. [7:4] Tx Adapt Fault : [3:0] Tx laser fault - u8 lol_ind; // 5. [7:4] Tx LOL : [3:0] Rx LOL - u8 temp_alarm; // 6. [7:4] Temp alarm/warning : [0:0] init complete fl - u8 vcc_alarm; // 7. [7:4] Vcc alarm/warning - u8 vendor_spec; // 8. unused - u8 rx_power_alarm12; // 9. Rx power alarm/warning, Ch1 and Ch2 - u8 rx_power_alarm34; // 10. Rx power alarm/warning, Ch3 and Ch4 - u8 tx_bias_alarm12; // 11. Tx Bias alarm/warning, Ch1 and Ch2 - u8 tx_bias_alarm34; // 12. Tx Bias alarm/warning, Ch3 and Ch4 - u8 tx_power_alarm12; // 13. Rx power alarm/warning, Ch1 and Ch2 - u8 tx_power_alarm34; // 14. Rx power alarm/warning, Ch3 and Ch4 - -}; - -/*qsfp-dd*/ -/*rev 3.0*/ -typedef enum { - - MODULE_LOW_PWR_ST_ENCODE = 0x1, - MODULE_PWR_UP_ST_ENCODE = 0x2, - MODULE_READY_ST_ENCODE = 0x3, - MODULE_PWR_DOWN_ST_ENCODE = 0x4, - MODULE_FAULT_ST_ENCODE = 0x5, - -} Module_State_Encoding_t; - -typedef enum { - - MODULE_TYPE_MMF = 0x1, - MODULE_TYPE_SMF = 0x2, - MODULE_PASSIVE_CU = 0x3, - MODULE_ACTIVE_CABLES = 0x4, - MODULE_BASE_T = 0x5, - -} Module_Type_Encoding_t; - -typedef enum { - - DATA_PATH_DEACTIVATED_ST_ENCODE = 0x1, - DATA_PATH_INIT_ST_ENCODE = 0x2, - DATA_PATH_DEINIT_ST_ENCODE = 0x3, - DATA_PATH_ACTIVATED_ST_ENCODE = 0x4, - -} DataPathStateEncoding_t; - -typedef enum { - NO_STATUS = 0, - CONFIG_ACCEPTED, - CONFIG_REJECTED_UNKNOWN, - CONFIG_REJECTED_INVALID_CODE, - CONFIG_REJECTED_INVALID_COMBO, - CONFIG_REJECTED_INVALID_SI, - CONFIG_REJECTED_IN_USE, - CONFIG_REJECTED_INCOMPLETE_LANE_INFO, -} config_err_code_t; - -#if 0 -struct id_status_field_offset2_t { - unsigned reserved : 2; - unsigned twi_max_speed : 2; - unsigned reserved2 : 2; - unsigned clei_present : 1; - unsigned flat_mem : 1; -}; -struct id_status_field_offset3_t { - unsigned intL_sw : 1;/*digital state of interrupt output signal*/ - unsigned module_state : 3; - unsigned reserved : 4; -}; -struct qsfp_dd_id_status_t { - u8 id; - u8 revision_compliance; - struct id_status_field_offset2_t offset2; - struct id_status_field_offset3_t offset3; -}; - -struct qsfp_dd_module_flags_t { - unsigned char state_change_flag : 1; - unsigned char module_fw_fault : 1; - unsigned char data_path_fw_fault : 1; - unsigned char reserved : 2; -}; -#endif -/*app_advert_field*/ -#define APP_ADVERT_FIELD_NUM (5) -struct qsfp_dd_app_advert_fields_t { - - u8 host_electrical_interface_code; - u8 module_media_interface_code; - u8 lane_count; - u8 host_lane_assignment_options; - u8 media_lane_assignment_options; -}; - -union qsfp_dd_app_advert_fields { - - struct qsfp_dd_app_advert_fields_t data; - u8 reg[APP_ADVERT_FIELD_NUM]; -}; -typedef enum { - APSEL_1, - APSEL_2, - APSEL_NUM, - -} apsel_code_t; - -struct stage_set_t { - unsigned char explicit_control : 1; - unsigned char datapath_code : 3; - unsigned char app_code : 4; - -}; -#define RESET_ASSERT_TIME (10) /*ms*/ -/* -union active_control_set_t { - - struct stage_set_t data; - u8 reg; -}; -*/ -/*qsfp-dd Signal Integrity Control define - * * Table 46- Implemented Signal Integrity Controls (Page 01h) */ -/*offset: 161*/ -#define TX_CDR_BIT (0x01) -#define TX_CDR_BYPASS_BIT (0x02) -#define TX_INPUT_FIX_MANUAL_BIT (0x04) -#define ADAPTIVE_TX_INPUT_FIX_MANUAL_BIT (0x08) -#define TX_INPUT_FREEZE_BIT (0x10) - -/*offset: 162*/ - -#define RX_CDR_BIT (0x01) -#define RX_CDR_BYPASS_BIT (0x02) -#define RX_OUTPUT_AMP_CONTROL_BIT (0x04) -#define RX_OUTPUT_EQ_CONTROL_BIT (0x08 | 0x10) -#define STAGE_SET1_BIT (0x20) -#endif /* __SFF_SPEC_H */ - - diff --git a/packages/platforms/inventec/x86-64/d7332/modules/builds/src/sfp.c b/packages/platforms/inventec/x86-64/d7332/modules/builds/src/sfp.c deleted file mode 100644 index c9ba6bf35..000000000 --- a/packages/platforms/inventec/x86-64/d7332/modules/builds/src/sfp.c +++ /dev/null @@ -1,951 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "inv_swps.h" -#include "sfp.h" -#include "inv_def.h" - - -extern u32 logLevel; -static sff_sfp_field_map_t sfp_field_map[] = { - /* Base page values, including alarms and sensors */ - {IDENTIFIER, {0x50, 0, 1}}, - {STATUS_CONTROL, {0x51, 110, 1}}, - {EXTENDED_STATUS_CONTROL, {0x51, 118, 1}}, - {ETHERNET_COMPLIANCE, {0x50, 3, 1}}, - {ETHERNET_EXTENDED_COMPLIANCE, {0x50, 36, 1}}, - {CONNECTOR_TYPE, {0x50, 2, 1}}, - {TRANSCEIVER_CODE, {0x50, 3, 8}}, - {RATE_IDENTIFIER, {0x50, 13, 1}}, - {ALARM_WARN_FLAGS, {0x51, 112, 6}}, - -}; -const u8 Sfp_Eth_Comp_Table[] = { - SR_10GBASE, - LR_10GBASE, - LRM_10GBASE, - ER_10GBASE -}; -/*0x50*/ -#define SFP_TX_EQ_OFFSET (114) -#define SFP_RX_EM_OFFSET (115) -#define SFP_VENDOR_NAME_OFFSET (20) -#define SFP_VENDOR_PN_OFFSET (40) -#define SFP_VENDOR_SN_OFFSET (68) -#define SFP_VENDOR_REV_OFFSET (56) - -#define SFP_VENDOR_NAME_LEN (16) -#define SFP_VENDOR_PN_LEN (16) -#define SFP_VENDOR_SN_LEN (16) -#define SFP_VENDOR_REV_LEN (4) - -/*0x51*/ -#define SFP_DDM_TEMP_OFFSET (96) -#define SFP_DDM_VCC_OFFSET (98) -#define SFP_DDM_TX_BIAS_OFFSET (100) -#define SFP_DDM_TX_POWER_OFFSET (102) -#define SFP_DDM_RX_POWER_OFFSET (104) - -static int sfp_tx_disable_set(struct sff_obj_t *sff_obj, u8 value); -static int sfp_tx_disable_get(struct sff_obj_t *sff_obj, u8 *value); -static int sfp_rx_los_get(struct sff_obj_t *sff_obj, u8 *value); -static int sfp_tx_fault_get(struct sff_obj_t *sff_obj, u8 *value); -int sfp_vendor_info_get(struct sff_obj_t *sff_obj, int type, u8 *buf, int buf_size); -int sfp_temperature_get(struct sff_obj_t *sff_obj, u8 *buf, int buf_size); -int sfp_voltage_get(struct sff_obj_t *sff_obj, u8 *buf, int buf_size); -int sfp_lane_status_get(struct sff_obj_t *sff_obj, int type, u8 *value); -int sfp_lane_monitor_get(struct sff_obj_t *sff_obj, int type, u8 *buf, int buf_size); -int sfp_lane_control_set(struct sff_obj_t *sff_obj, int type, u32 value); -int sfp_lane_control_get(struct sff_obj_t *sff_obj, int type, u32 *value); -int sfp_id_get(struct sff_obj_t *sff_obj, u8 *id); -bool sfp_is_id_matched(struct sff_obj_t *sff_obj); - -struct func_tbl_t sfp_func_tbl = { - .eeprom_read = sff_eeprom_read, - .eeprom_write = sff_eeprom_write, - .prs_get = sff_prs_get, - .lpmode_set = dummy_lpmode_set, - .lpmode_get = dummy_lpmode_get, - .reset_set = dummy_reset_set, - .reset_get = dummy_reset_get, - .power_set = sff_power_set, - .power_get = sff_power_get, - .mode_sel_set = dummy_mode_sel_set, - .mode_sel_get = dummy_mode_sel_get, - .intL_get = dummy_intL_get, - .tx_disable_set = sfp_tx_disable_set, - .tx_disable_get = sfp_tx_disable_get, - .temperature_get = sfp_temperature_get, - .voltage_get = sfp_voltage_get, - .lane_control_set = sfp_lane_control_set, - .lane_control_get = sfp_lane_control_get, - .lane_monitor_get = sfp_lane_monitor_get, - .vendor_info_get = sfp_vendor_info_get, - .lane_status_get = sfp_lane_status_get, - .module_st_get = dummy_module_st_get, - .id_get = sfp_id_get, - .is_id_matched = sfp_is_id_matched, - .eeprom_dump = dummy_eeprom_dump, - .page_sel = dummy_page_sel, - .page_get = dummy_page_get, -}; -struct func_tbl_t *sfp_func_load(void) -{ - return &sfp_func_tbl; -} -/* return sff_field_info_t for a given field in qsfp_field_map[] */ -static sff_sfp_field_info_t *get_sff_sfp_field_addr(const Sff_field field) -{ - int i = 0; - int cnt = sizeof(sfp_field_map) / sizeof(sff_sfp_field_map_t); - - for (i = 0; i < cnt; i++) { - if (sfp_field_map[i].field == field) { - return (&(sfp_field_map[i].data)); - } - } - return NULL; -} -/* return the contents of the sff_field_info_t for a given field */ -static int get_sfp_field_addr(Sff_field field, - u8 *slave_addr, - u8 *offset, - int *length) -{ - sff_sfp_field_info_t *info_data = NULL; - info_data = get_sff_sfp_field_addr(field); - - if (field >= SFF_FIELD_MAX) { - return -1; - } - if (!info_data) { - return -1; - } - *offset = info_data->offset; - *slave_addr = info_data->slave_addr; - *length = info_data->length; - return 0; -} - -static int sfp_tx_disable_set(struct sff_obj_t *sff_obj, u8 value) -{ - return sff_obj->mgr->io_drv->tx_disable_set(sff_obj->lc_id, sff_obj->port, value); -} - -static int sfp_tx_disable_get(struct sff_obj_t *sff_obj, u8 *value) -{ - - if (!p_valid(value)) { - return -EINVAL; - } - return sff_obj->mgr->io_drv->tx_disable_get(sff_obj->lc_id, sff_obj->port, value); -} -static int sfp_rx_los_get(struct sff_obj_t *sff_obj, u8 *value) -{ - int ret = 0; - unsigned long bitmap = 0; - - if (!p_valid(value)) { - return -EINVAL; - } - - if ((ret = sff_obj->mgr->io_drv->rx_los_all_get(sff_obj->lc_id, &bitmap)) < 0) { - return ret; - } - - if (test_bit(sff_obj->port, &bitmap)) { - *value = 1; - } else { - *value = 0; - } - return 0; -} -static int sfp_tx_fault_get(struct sff_obj_t *sff_obj, u8 *value) -{ - int ret = 0; - unsigned long bitmap = 0; - - if (!p_valid(value)) { - return -EINVAL; - } - - if ((ret = sff_obj->mgr->io_drv->tx_fault_all_get(sff_obj->lc_id, &bitmap)) < 0) { - return ret; - } - - if (test_bit(sff_obj->port, &bitmap)) { - *value = 1; - } else { - *value = 0; - } - return 0; -} - -static int sfp_eeprom_read(struct sff_obj_t *sff_obj, - u8 slave_addr, - u8 offset, - u8 *buf, - int len) -{ - if (slave_addr != SFF_EEPROM_I2C_ADDR && - slave_addr != SFF_DDM_I2C_ADDR) { - MODULE_LOG_ERR("addr out of range:0x%x\n", slave_addr); - return -EINVAL; - } - - return sff_obj->func_tbl->eeprom_read(sff_obj, slave_addr, offset, buf, len); -} -static int sfp_eeprom_write(struct sff_obj_t *sff_obj, - u8 slave_addr, - u8 offset, - u8 *buf, - int len) -{ - if (slave_addr != SFF_EEPROM_I2C_ADDR && - slave_addr != SFF_DDM_I2C_ADDR) { - MODULE_LOG_ERR("addr out of range:0x%x\n", slave_addr); - return -EINVAL; - } - return sff_obj->func_tbl->eeprom_write(sff_obj, slave_addr, offset, buf, len); -} -static int _sfp_transvr_codes_read(struct sff_obj_t *sff_obj, u8 *transvr_codes, int size) -{ - u8 slave_addr = 0xff; - u8 offset = 0; - int data_len = 0; - - if(IS_ERR_OR_NULL(transvr_codes)) { - MODULE_LOG_ERR("invalid para"); - return -1; - } - get_sfp_field_addr(TRANSCEIVER_CODE, &slave_addr, &offset, &data_len); - if(data_len != size) { - MODULE_LOG_ERR("invalid para"); - return -1; - } - - if(sfp_eeprom_read(sff_obj, slave_addr, offset, transvr_codes, data_len) < 0) { - MODULE_LOG_ERR("sfp_eeprom_read fail"); - return -1; - } - - return 0; -} - -static int _sfp_eth_extended_compliance_get(struct sff_obj_t *sff_obj, u8 *eth_ext_comp) -{ - u8 slave_addr = 0xff; - u8 offset = 0; - int data_len = 0; - u8 data = 0; - if(IS_ERR_OR_NULL(eth_ext_comp)) { - MODULE_LOG_ERR("invalid para"); - return -1; - } - get_sfp_field_addr(ETHERNET_EXTENDED_COMPLIANCE, &slave_addr, &offset, &data_len); - if(data_len != sizeof(data)) { - MODULE_LOG_ERR("invalid para"); - return -1; - } - - if(sfp_eeprom_read(sff_obj, slave_addr, offset, &data, data_len) < 0) { - MODULE_LOG_ERR("sfp_eeprom_read fail"); - return -1; - } - *eth_ext_comp = data; - - return 0; -} -static int _sfp_connector_type_read(struct sff_obj_t *sff_obj, u8 *conn_type) -{ - u8 slave_addr = 0xff; - u8 offset = 0; - int data_len = 0; - u8 data = 0; - if(NULL == conn_type) { - MODULE_LOG_ERR("invalid para"); - return -1; - } - get_sfp_field_addr(CONNECTOR_TYPE, &slave_addr, &offset, &data_len); - if(data_len != sizeof(data)) { - MODULE_LOG_ERR("invalid para"); - return -1; - } - - if(sfp_eeprom_read(sff_obj, slave_addr, offset, &data, data_len) < 0) { - MODULE_LOG_ERR("sfp_eeprom_read fail"); - return -1; - } - *conn_type = data; - - return 0; -} -static bool sfp_eth_comp_is_supported(struct sff_obj_t *sff_obj, u8 eth_comp) -{ - bool is_supported = false; - int size = ARRAY_SIZE(Sfp_Eth_Comp_Table); - int idx = 0; - u8 comp_codes = 0; - for (idx = 0; idx < size; idx++) { - if(eth_comp & Sfp_Eth_Comp_Table[idx]) { - MODULE_LOG_DBG("%s known eth_cmp:0x%x\n", sff_obj->name, eth_comp & Sfp_Eth_Comp_Table[idx]); - comp_codes = eth_comp & Sfp_Eth_Comp_Table[idx]; - break; - } - } - if(idx >= size) { - - MODULE_LOG_DBG("%s unknown eth_cmp:0x%x\n", sff_obj->name, (eth_comp & 0xf0) >> 4); - } - - switch (comp_codes) { - case SR_10GBASE: - transvr_type_set(sff_obj, TRANSVR_CLASS_OPTICAL_10G_S_SR); - break; - case LR_10GBASE: - case LRM_10GBASE: - transvr_type_set(sff_obj, TRANSVR_CLASS_OPTICAL_10G_S_LR); - break; - case ER_10GBASE: - transvr_type_set(sff_obj, TRANSVR_CLASS_OPTICAL_10G_S_ER); - break; - default: - break; - - } - if (TRANSVR_CLASS_UNKNOWN != transvr_type_get(sff_obj)) { - is_supported = true; - MODULE_LOG_DBG("%s known eth_ext_cmp:0x%x transvr:%d\n", - sff_obj->name, eth_comp, transvr_type_get(sff_obj)); - } - return is_supported; -} - -static bool sfp_eth_ext_is_supported(struct sff_obj_t *sff_obj, u8 eth_ext_comp) -{ - bool is_supported = false; - Ethernet_extended_compliance eth_ext_code = eth_ext_comp; - switch(eth_ext_code) { - case AOC_100G_BER_5: - case AOC_100G_BER_12: /* 100G AOC or 25G AUI C2M AOC 10^^-12 BER */ - transvr_type_set(sff_obj, TRANSVR_CLASS_OPTICAL_25G_AOC); - break; - case SR4_100GBASE: - transvr_type_set(sff_obj, TRANSVR_CLASS_OPTICAL_25G_SR); - break; - case LR4_100GBASE: - transvr_type_set(sff_obj, TRANSVR_CLASS_OPTICAL_25G_LR); - break; - case ER4_100GBASE: - transvr_type_set(sff_obj, TRANSVR_CLASS_OPTICAL_25G_ER); - break; - case CR4_100GBASE: - transvr_type_set(sff_obj, TRANSVR_CLASS_COPPER_L1_25G); - break; - case ACC_100G_BER_5: - case ACC_100G_BER_12: /* 100G ACC or 25G AUI C2M ACC 10^^-12 BER */ - case CR_25GBASE_CA_S: - case CR_25GBASE_CA_N: - case T_10BASE_SFI: { /* 10BASE-T with SFI electrical interface */ - /* how about these types!?*/ - MODULE_LOG_DBG("%s known eth_ext_cmp:0x%x\n", sff_obj->name, eth_ext_comp); - } - break; - default: - MODULE_LOG_DBG("%s unknown eth_ext_cmp:%d\n", sff_obj->name, eth_ext_comp); - - break; - } - if (TRANSVR_CLASS_UNKNOWN != transvr_type_get(sff_obj)) { - is_supported = true; - MODULE_LOG_DBG("%s known eth_ext_cmp:0x%x transvr_type:%d\n", - sff_obj->name, eth_ext_comp, transvr_type_get(sff_obj)); - } - return is_supported; -} -int sfp_id_get(struct sff_obj_t *sff_obj, u8 *id) -{ - u8 slave_addr = 0xff; - u8 offset = 0; - int len = 0; - get_sfp_field_addr(IDENTIFIER, &slave_addr, &offset, &len); - return sfp_eeprom_read(sff_obj, slave_addr , offset, id, len); -} -bool sfp_is_id_matched(struct sff_obj_t *sff_obj) -{ - u8 id = 0; - bool match = false; - if (sfp_id_get(sff_obj, &id) < 0) { - return match; - } - switch (id) { - case 0x3: - match = true; - break; - default: - MODULE_LOG_ERR("%s not match id:%d\n", sff_obj->name, id); - break; - } - - return match; -} -static int sfp_type_identify(struct sff_obj_t *sff_obj, bool *is_found) -{ - u8 id = 0; - u8 transvr_codes[8]; - u8 conn_type = 0; - u8 eth_ext_comp = 0; - int idx = 0; - int ret = 0; - if((ret = sfp_id_get(sff_obj, &id)) < 0) { - goto exit_err; - } - if(0x03 != id) { //sfp/sfp+/sfp28 - MODULE_LOG_ERR("unknown id:0x%x\n", id); - goto exit_non_support_err; /* error handling in the future*/ - } - - if((ret = _sfp_eth_extended_compliance_get(sff_obj, ð_ext_comp)) < 0) { - goto exit_err; - } - - if(!sfp_eth_ext_is_supported(sff_obj, eth_ext_comp)) { - - if((ret = _sfp_transvr_codes_read(sff_obj, transvr_codes, ARRAY_SIZE(transvr_codes))) < 0) { - goto exit_err; - } - for (idx = 0; idx < 8; idx++) { - MODULE_LOG_DBG("%s transvr[%d]:0x%x\n", sff_obj->name, idx, transvr_codes[idx]); - } - - if((ret = _sfp_connector_type_read(sff_obj, &conn_type)) < 0) { - goto exit_err; - } - - MODULE_LOG_DBG("%s conn_type:0x%x\n", sff_obj->name,conn_type); - - /*check connector type first*/ - /*check transvr codes start from offset:3 */ - if (0x07 == conn_type) { - if(!sfp_eth_comp_is_supported(sff_obj, transvr_codes[0])) { - goto exit_non_support_err; - } - } else if (0x0b == conn_type) { - - - } else if (0x21 == conn_type) { - /*check SFP+ Cable Technology*/ - /*offset 8, bit2: Passive Cable *8 - * bit3: Active Cable *8 */ - if (transvr_codes[5] & 0x02) { - /*passive*/ - } else if (transvr_codes[5] & 0x03) { - /*active*/ - } else { - - goto exit_non_support_err; /* error handling in the future*/ - } - } - - } - *is_found = true; - return 0; -exit_non_support_err: - return 0; -exit_err: /*could be i2c fail , need to define err code in the future */ - return ret; -} -/*reference sff 8472: TABLE 9-12 ALARM AND WARNING FLAG BITS - * start from offset 112 -> 117 : total size 6 bytes - * offset 114 : 7-4 : tx input equalization control RATE=HIGH, 3-0: tx input equalization control RATE=LOW - * offset 115 : 7-4 : RX output emphasis control RATE=HIGH, 3-0: RX output emphasis control RATE=LOW - - * */ -int sfp_lane_control_set(struct sff_obj_t *sff_obj, int type, u32 value) -{ - u8 addr = SFF_DDM_I2C_ADDR; - u8 offset = 0; - bool fail = false; - int ret = 0; - u8 data = value; - - switch(type) { - case TX_EQ_TYPE: - offset = SFP_TX_EQ_OFFSET; - break; - case RX_EM_TYPE: - offset = SFP_RX_EM_OFFSET; - break; - - default: - fail = true; - break; - } - if (fail) { - return -EINVAL; - } - if((ret = sfp_eeprom_write(sff_obj, addr, offset, &data, sizeof(data))) < 0) { - return ret; - } - - return 0; -} -/*reference sff 8472: TABLE 9-12 ALARM AND WARNING FLAG BITS - * start from offset 112 -> 117 : total size 6 bytes - * offset 114 : 7-4 : tx input equalization control RATE=HIGH, 3-0: tx input equalization control RATE=LOW - * offset 115 : 7-4 : RX output emphasis control RATE=HIGH, 3-0: RX output emphasis control RATE=LOW - - * */ -int sfp_lane_control_get(struct sff_obj_t *sff_obj, int type, u32 *value) -{ - u8 addr = SFF_DDM_I2C_ADDR; - u8 offset = 0; - bool fail = false; - int ret = 0; - u8 data = 0; - - switch(type) { - case TX_EQ_TYPE: - offset = SFP_TX_EQ_OFFSET; - break; - case RX_EM_TYPE: - offset = SFP_RX_EM_OFFSET; - break; - default: - fail = true; - break; - } - if (fail) { - return -EINVAL; - } - if((ret = sfp_eeprom_read(sff_obj, addr, offset, &data, sizeof(data))) < 0) { - return ret; - } - *value = data; - return 0; -} -int sfp_lane_status_get(struct sff_obj_t *sff_obj, int type, u8 *value) -{ - u8 reg = 0; - int ret = 0; - - switch(type) { - case LN_STATUS_RX_LOS_TYPE: - ret = sfp_rx_los_get(sff_obj, ®); - break; - case LN_STATUS_TX_FAULT_TYPE: - ret = sfp_tx_fault_get(sff_obj, ®) ; - break; - case LN_STATUS_TX_LOS_TYPE: - default: - break; - } - if (ret < 0) { - return ret; - } - *value = reg; - return 0; - -} -int sfp_temperature_get(struct sff_obj_t *sff_obj, u8 *buf, int buf_size) -{ - int ret = 0; - u8 addr = SFF_DDM_I2C_ADDR; - u8 offset = SFP_DDM_TEMP_OFFSET; - u8 reg[WORD_SIZE]; - s16 temp = 0; - - union monitor_data_t monitor_data; - - s16 divider = 256; - s16 decimal = 0; - char *unit = "c"; - - if((ret = sfp_eeprom_read(sff_obj, addr, offset, reg, WORD_SIZE)) < 0) { - return ret; - } - - monitor_data.byte[1] = reg[0]; - monitor_data.byte[0] = reg[1]; - temp = monitor_data.signed_word; - - decimal = ((temp/divider)*divider)-temp; - decimal = abs(decimal); - decimal = decimal*1000/divider; - - scnprintf(buf, buf_size, - "%d.%d %s\n", - temp/divider, - decimal, unit); - - return 0; -} -int sfp_voltage_get(struct sff_obj_t *sff_obj, u8 *buf, int buf_size) -{ - int ret = 0; - u8 addr = SFF_DDM_I2C_ADDR; - u8 offset = SFP_DDM_VCC_OFFSET; - u8 reg[WORD_SIZE]; - u16 vol = 0; - union monitor_data_t monitor_data; - u16 divider = 10000; - char *unit = "v"; - - if((ret = sfp_eeprom_read(sff_obj, addr, offset, reg, WORD_SIZE)) < 0) { - return ret; - } - - monitor_data.byte[1] = reg[0]; - monitor_data.byte[0] = reg[1]; - vol = monitor_data.word; - - scnprintf(buf, buf_size, - "%d.%d %s\n", - vol/divider, - vol%divider, unit); - - return 0; -} -int sfp_lane_monitor_get(struct sff_obj_t *sff_obj, int type, u8 *buf, int buf_size) -{ - u8 addr = SFF_DDM_I2C_ADDR; - u8 offset = 0; - u8 reg[WORD_SIZE]; - union monitor_data_t monitor_data; - u16 divider = 0; - char *unit = NULL; - struct monitor_para_t *para = NULL; - bool fail = false; - int ret = 0; - - switch(type) { - case LN_MONITOR_TX_PWR_TYPE: - offset = SFP_DDM_TX_POWER_OFFSET; - break; - case LN_MONITOR_RX_PWR_TYPE: - offset = SFP_DDM_RX_POWER_OFFSET; - break; - case LN_MONITOR_TX_BIAS_TYPE: - offset = SFP_DDM_TX_BIAS_OFFSET; - - break; - default: - fail = true; - break; - } - if(fail) { - return -EINVAL; - } - if((ret = sfp_eeprom_read(sff_obj, addr, offset, reg, sizeof(monitor_data))) < 0) { - return ret; - } - para = monitor_para_find(type); - if (IS_ERR_OR_NULL(para)) { - return -EINVAL; - } - divider = para->divider; - unit = para->unit; - /*big edian*/ - monitor_data.byte[1] = reg[0]; - monitor_data.byte[0] = reg[1]; - scnprintf(buf, buf_size, - "ch1: %d.%d %s\n", - monitor_data.word/divider, - monitor_data.word%divider, unit); - return ret; -} -int sfp_vendor_info_get(struct sff_obj_t *sff_obj, int type, u8 *buf, int buf_size) -{ - - u8 addr = SFF_EEPROM_I2C_ADDR; - u8 offset = 0; - int len = 0; - u8 reg[VENDOR_INFO_BUF_SIZE]; - bool fail = false; - int ret = 0; - - switch(type) { - case VENDOR_NAME_TYPE: - offset = SFP_VENDOR_NAME_OFFSET; - len = SFP_VENDOR_NAME_LEN; - break; - case VENDOR_PN_TYPE: - offset = SFP_VENDOR_PN_OFFSET; - len = SFP_VENDOR_PN_LEN; - - break; - case VENDOR_SN_TYPE: - offset = SFP_VENDOR_SN_OFFSET; - len = SFP_VENDOR_SN_LEN; - - break; - case VENDOR_REV_TYPE: - offset = SFP_VENDOR_REV_OFFSET; - len = SFP_VENDOR_REV_LEN; - break; - default: - fail = true; - break; - } - - if(fail) { - return -EINVAL; - } - if((ret = sfp_eeprom_read(sff_obj, addr, offset, reg, len)) < 0) { - return ret; - } - /*add terminal of string*/ - reg[len] = '\0'; - - scnprintf(buf, buf_size, "%s\n", reg); - - return ret; -} -static int sfp_rate_select(struct sff_obj_t *sff_obj, u8 rate_bitmap) -{ - u8 slave_addr = 0xff; - u8 offset = 0; - int len = 0; - u8 status = 0; - u8 ext_status = 0; - int port = sff_obj->port; - if(rate_bitmap & SOFT_RX_RATE_RS0) { - get_sfp_field_addr(STATUS_CONTROL, &slave_addr, &offset, &len); - if( sfp_eeprom_read(sff_obj, slave_addr , offset, &status, len) < 0) { - goto exit_err; - - } - MODULE_LOG_DBG("port:%d status:0x%x\n", port, status); - /*set bit 3: Soft Rate_Select - * * Select * [aka. "RS(0)"] */ - set_bit(3, (unsigned long *)&status); - if( sfp_eeprom_write(sff_obj, slave_addr , offset, &status, len) < 0) { - goto exit_err; - } -#ifdef READBACK_CHECK - if( sfp_eeprom_read(sff_obj, slave_addr , offset, &status, len) < 0) { - goto exit_err; - - } - MODULE_LOG_DBG("port:%d status:0x%x\n", port, status); -#endif - } - if(rate_bitmap & SOFT_TX_RATE_RS1) { - get_sfp_field_addr(EXTENDED_STATUS_CONTROL, &slave_addr, &offset, &len); - if( sfp_eeprom_read(sff_obj, slave_addr , offset, &ext_status, len) < 0) { - goto exit_err; - - } - MODULE_LOG_DBG("port:%d status:0x%x\n", port, ext_status); - /*set bit 3: Soft Rate_Select - * * Select * [aka. "RS(0)"] */ - set_bit(3, (unsigned long *)&ext_status); - if( sfp_eeprom_write(sff_obj, slave_addr , offset, &ext_status, len) < 0) { - goto exit_err; - } -#ifdef READBACK_CHECK - if( sfp_eeprom_read(sff_obj, slave_addr , offset, &ext_status, len) < 0) { - goto exit_err; - - } - MODULE_LOG_DBG("port:%d status:0x%x\n", port, status); -#endif - } - return 0; -exit_err: - return -1; -} -static int sfp_rate_select_control(struct sff_obj_t *sff_obj) -{ - u8 rate_id = 0; - u8 slave_addr = 0xff; - u8 offset = 0; - int len = 0; - bool found = false; - /*read rate id*/ - get_sfp_field_addr(RATE_IDENTIFIER, &slave_addr, &offset, &len); - if( sfp_eeprom_read(sff_obj, slave_addr , offset, &rate_id, len) < 0) { - goto exit_err; - } - MODULE_LOG_DBG("%s rate_id:0x%x\n", sff_obj->name, rate_id); - switch (rate_id) { - case 0x00: /* Unspecified */ - case 0x03: /* Unspecified */ - case 0x05: /* Unspecified */ - case 0x07: /* Unspecified */ - case 0x09: /* Unspecified */ - case 0x0B: /* Unspecified */ - case 0x0D: /* Unspecified */ - case 0x0F: /* Unspecified */ - break; - case 0x02: /* SFF-8431 (8/4/2G Rx Rate_Select only) */ - if(sfp_rate_select(sff_obj, SOFT_RX_RATE_RS0) < 0) { - goto exit_err; - } - found = true; - break; - case 0x04: /* SFF-8431 (8/4/2G Tx Rate_Select only) */ - if(sfp_rate_select(sff_obj, SOFT_TX_RATE_RS1) < 0) { - goto exit_err; - } - found = true; - break; - case 0x06: /* SFF-8431 (8/4/2G Independent Rx & Tx Rate_select) */ - if(sfp_rate_select(sff_obj, SOFT_RX_RATE_RS0|SOFT_TX_RATE_RS1) < 0) { - goto exit_err; - } - found = true; - break; - case 0x01: /* SFF-8079 (4/2/1G Rate_Select & AS0/AS1) */ - case 0x08: /* FC-PI-5 (16/8/4G Rx Rate_select only) - * High=16G only, Low=8G/4G - * * */ - case 0x0A: /* FC-PI-5 (16/8/4G Independent Rx, Tx Rate_select) - * High=16G only, Low=8G/4G - * * */ - case 0x0C: /* FC-PI-6 (32/16/8G Independent Rx, Tx Rate_Select) - * High=32G only, Low = 16G/8G - * * */ - case 0x0E: /* 10/8G Rx and Tx Rate_Select controlling the operation or - * locking modes of the internal signal conditioner, retimer - * * * or CDR, according to the logic table defined in Table 10-2, - * * * High Bit Rate (10G) =9.95-11.3 Gb/s; Low Bit Rate (8G) = - * * * 8.5 Gb/s. In this mode, the default value of bit 110.3 (Soft - * * * Rate Select RS(0), Table 9-11) and of bit 118.3 (Soft Rate - * * * Select RS(1), Table 10-1) is 1. - * * */ - default: - break; - } - if(!found) { - MODULE_LOG_DBG("%s no support\n", sff_obj->name); - } - return 0; -exit_err: - return -1; -} - -static int _sfp_data_ready_check(struct sff_obj_t *sff_obj, u8 *is_ready) -{ - u8 slave_addr = 0xff; - u8 offset = 0; - int data_len = 0; - int ret = 0; - u8 status = 0; - if(IS_ERR_OR_NULL(is_ready)) { - MODULE_LOG_ERR("invalid para"); - return -1; - } - - get_sfp_field_addr(STATUS_CONTROL, &slave_addr, &offset, &data_len); - if((ret = sfp_eeprom_read(sff_obj, slave_addr, offset, &status, data_len)) < 0) { - return ret; - } - status = ~(status & 0x01) & 0x01; - *is_ready = status; - - return 0; -#if 0 - MODULE_LOG_DBG("special_case of checking data ready\n"); - /*some cables don't support status control, in this case, check id item instead*/ - get_sfp_field_addr(IDENTIFIER, &slave_addr, &offset, &data_len); - if (data_len != sizeof(status)) { - goto exit_err; - } - if(sfp_eeprom_read(sff_obj, slave_addr, offset, &status, data_len) < 0) { - goto exit_err; - } - *is_ready = 1; - - return 0; -exit_err: - return -1; -#endif -} -int sff_fsm_sfp_task(struct sff_obj_t *sff_obj) -{ - sff_fsm_state_t st = sff_fsm_st_get(sff_obj); - int ret = 0; - u8 is_ready = 0; - bool is_found = false; - switch (st) { - - case SFF_FSM_ST_IDLE: - break; - case SFF_FSM_ST_REMOVED: - sff_fsm_st_set(sff_obj, SFF_FSM_ST_IDLE); - break; - case SFF_FSM_ST_INSERTED: - ret = _sfp_data_ready_check(sff_obj, &is_ready); - if (ret < 0) { - break; - } - - if(is_ready) { - sff_fsm_st_set(sff_obj, SFF_FSM_ST_INIT); - } - - break; - - case SFF_FSM_ST_IDENTIFY: - if((ret = sfp_type_identify(sff_obj, &is_found)) < 0) { - break; - } - - if(is_found) { - sff_fsm_st_set(sff_obj, SFF_FSM_ST_READY); - } else { - /*unknown type: special handling*/ - sff_fsm_st_set(sff_obj, SFF_FSM_ST_UNKNOWN_TYPE); - } - - break; - - case SFF_FSM_ST_READY: - - if((ret = sff_obj->func_tbl->tx_disable_set(sff_obj, 0)) < 0) { - break; - } - sff_fsm_st_set(sff_obj, SFF_FSM_ST_MONITOR); - break; - case SFF_FSM_ST_ISOLATED: - - break; - case SFF_FSM_ST_INIT: - - if((ret = sff_obj->func_tbl->tx_disable_set(sff_obj, 1)) < 0) { - break; - } - if ((ret = sfp_rate_select_control(sff_obj)) < 0) { - break; - } - sff_fsm_st_set(sff_obj, SFF_FSM_ST_IDENTIFY); - break; - case SFF_FSM_ST_FAULT: - break; - case SFF_FSM_ST_MONITOR: - break; - case SFF_FSM_ST_UNKNOWN_TYPE: - break; - default: - MODULE_LOG_ERR("unknown fsm st:%d\n", st); - break; - - } - if(ret < 0) { - return ret; - } - return 0; -} - diff --git a/packages/platforms/inventec/x86-64/d7332/modules/builds/src/sfp.h b/packages/platforms/inventec/x86-64/d7332/modules/builds/src/sfp.h deleted file mode 100644 index 2f5d9434b..000000000 --- a/packages/platforms/inventec/x86-64/d7332/modules/builds/src/sfp.h +++ /dev/null @@ -1,7 +0,0 @@ -//port info -#ifndef __SFF_SFP_H -#define __SFF_SFP_H - -struct func_tbl_t *sfp_func_load(void); -int sff_fsm_sfp_task(struct sff_obj_t *sff_obj); -#endif /*__SFF_SFP_H*/ diff --git a/packages/platforms/inventec/x86-64/d7332/onlp/Makefile b/packages/platforms/inventec/x86-64/d7332/onlp/Makefile deleted file mode 100644 index 003238cf6..000000000 --- a/packages/platforms/inventec/x86-64/d7332/onlp/Makefile +++ /dev/null @@ -1 +0,0 @@ -include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/inventec/x86-64/d7332/onlp/PKG.yml b/packages/platforms/inventec/x86-64/d7332/onlp/PKG.yml deleted file mode 100644 index abaf17ca6..000000000 --- a/packages/platforms/inventec/x86-64/d7332/onlp/PKG.yml +++ /dev/null @@ -1 +0,0 @@ -!include $ONL_TEMPLATES/onlp-platform-any.yml PLATFORM=x86-64-inventec-d7332 ARCH=amd64 TOOLCHAIN=x86_64-linux-gnu diff --git a/packages/platforms/inventec/x86-64/d7332/onlp/builds/Makefile b/packages/platforms/inventec/x86-64/d7332/onlp/builds/Makefile deleted file mode 100644 index e7437cb23..000000000 --- a/packages/platforms/inventec/x86-64/d7332/onlp/builds/Makefile +++ /dev/null @@ -1,2 +0,0 @@ -FILTER=src -include $(ONL)/make/subdirs.mk diff --git a/packages/platforms/inventec/x86-64/d7332/onlp/builds/lib/Makefile b/packages/platforms/inventec/x86-64/d7332/onlp/builds/lib/Makefile deleted file mode 100644 index 90b790964..000000000 --- a/packages/platforms/inventec/x86-64/d7332/onlp/builds/lib/Makefile +++ /dev/null @@ -1,2 +0,0 @@ -PLATFORM := x86-64-inventec-d7332 -include $(ONL)/packages/base/any/onlp/builds/platform/libonlp-platform.mk diff --git a/packages/platforms/inventec/x86-64/d7332/onlp/builds/onlpdump/Makefile b/packages/platforms/inventec/x86-64/d7332/onlp/builds/onlpdump/Makefile deleted file mode 100644 index 751d09042..000000000 --- a/packages/platforms/inventec/x86-64/d7332/onlp/builds/onlpdump/Makefile +++ /dev/null @@ -1,2 +0,0 @@ -PLATFORM := x86-64-inventec-d7332 -include $(ONL)/packages/base/any/onlp/builds/platform/onlps.mk diff --git a/packages/platforms/inventec/x86-64/d7332/onlp/builds/x86_64_inventec_d7332/.module b/packages/platforms/inventec/x86-64/d7332/onlp/builds/x86_64_inventec_d7332/.module deleted file mode 100644 index f21ca7710..000000000 --- a/packages/platforms/inventec/x86-64/d7332/onlp/builds/x86_64_inventec_d7332/.module +++ /dev/null @@ -1 +0,0 @@ -name: x86_64_inventec_d7332 diff --git a/packages/platforms/inventec/x86-64/d7332/onlp/builds/x86_64_inventec_d7332/Makefile b/packages/platforms/inventec/x86-64/d7332/onlp/builds/x86_64_inventec_d7332/Makefile deleted file mode 100644 index 432de8e1a..000000000 --- a/packages/platforms/inventec/x86-64/d7332/onlp/builds/x86_64_inventec_d7332/Makefile +++ /dev/null @@ -1,9 +0,0 @@ -############################################################################### -# -# -# -############################################################################### -include $(ONL)/make/config.mk -MODULE := x86_64_inventec_d7332 -AUTOMODULE := x86_64_inventec_d7332 -include $(BUILDER)/definemodule.mk diff --git a/packages/platforms/inventec/x86-64/d7332/onlp/builds/x86_64_inventec_d7332/module/auto/make.mk b/packages/platforms/inventec/x86-64/d7332/onlp/builds/x86_64_inventec_d7332/module/auto/make.mk deleted file mode 100644 index dd1445c1c..000000000 --- a/packages/platforms/inventec/x86-64/d7332/onlp/builds/x86_64_inventec_d7332/module/auto/make.mk +++ /dev/null @@ -1,9 +0,0 @@ -############################################################################### -# -# x86_64_inventec_d7332 Autogeneration -# -############################################################################### -x86_64_inventec_d7332_AUTO_DEFS := module/auto/x86_64_inventec_d7332.yml -x86_64_inventec_d7332_AUTO_DIRS := module/inc/x86_64_inventec_d7332 module/src -include $(BUILDER)/auto.mk - diff --git a/packages/platforms/inventec/x86-64/d7332/onlp/builds/x86_64_inventec_d7332/module/auto/x86_64_inventec_d7332.yml b/packages/platforms/inventec/x86-64/d7332/onlp/builds/x86_64_inventec_d7332/module/auto/x86_64_inventec_d7332.yml deleted file mode 100644 index b612897a1..000000000 --- a/packages/platforms/inventec/x86-64/d7332/onlp/builds/x86_64_inventec_d7332/module/auto/x86_64_inventec_d7332.yml +++ /dev/null @@ -1,50 +0,0 @@ -############################################################################### -# -# x86_64_inventec_d7332 Autogeneration Definitions. -# -############################################################################### - -cdefs: &cdefs -- X86_64_INVENTEC_D7332_CONFIG_INCLUDE_LOGGING: - doc: "Include or exclude logging." - default: 1 -- X86_64_INVENTEC_D7332_CONFIG_LOG_OPTIONS_DEFAULT: - doc: "Default enabled log options." - default: AIM_LOG_OPTIONS_DEFAULT -- X86_64_INVENTEC_D7332_CONFIG_LOG_BITS_DEFAULT: - doc: "Default enabled log bits." - default: AIM_LOG_BITS_DEFAULT -- X86_64_INVENTEC_D7332_CONFIG_LOG_CUSTOM_BITS_DEFAULT: - doc: "Default enabled custom log bits." - default: 0 -- X86_64_INVENTEC_D7332_CONFIG_PORTING_STDLIB: - doc: "Default all porting macros to use the C standard libraries." - default: 1 -- X86_64_INVENTEC_D7332_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS: - doc: "Include standard library headers for stdlib porting macros." - default: X86_64_INVENTEC_D7332_CONFIG_PORTING_STDLIB -- X86_64_INVENTEC_D7332_CONFIG_INCLUDE_UCLI: - doc: "Include generic uCli support." - default: 0 -- X86_64_INVENTEC_D7332_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_D7332_CONFIG_HEADER: - defs: *cdefs - basename: x86_64_inventec_d7332_config - - portingmacro: - X86_64_INVENTEC_D7332: - macros: - - malloc - - free - - memset - - memcpy - - strncpy - - vsnprintf - - snprintf - - strlen diff --git a/packages/platforms/inventec/x86-64/d7332/onlp/builds/x86_64_inventec_d7332/module/inc/x86_64_inventec_d7332/x86_64_inventec_d7332.x b/packages/platforms/inventec/x86-64/d7332/onlp/builds/x86_64_inventec_d7332/module/inc/x86_64_inventec_d7332/x86_64_inventec_d7332.x deleted file mode 100644 index 9afeb6dab..000000000 --- a/packages/platforms/inventec/x86-64/d7332/onlp/builds/x86_64_inventec_d7332/module/inc/x86_64_inventec_d7332/x86_64_inventec_d7332.x +++ /dev/null @@ -1,14 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#include - -/* <--auto.start.xmacro(ALL).define> */ -/* */ - -/* <--auto.start.xenum(ALL).define> */ -/* */ - - diff --git a/packages/platforms/inventec/x86-64/d7332/onlp/builds/x86_64_inventec_d7332/module/inc/x86_64_inventec_d7332/x86_64_inventec_d7332_config.h b/packages/platforms/inventec/x86-64/d7332/onlp/builds/x86_64_inventec_d7332/module/inc/x86_64_inventec_d7332/x86_64_inventec_d7332_config.h deleted file mode 100644 index db8d22a9e..000000000 --- a/packages/platforms/inventec/x86-64/d7332/onlp/builds/x86_64_inventec_d7332/module/inc/x86_64_inventec_d7332/x86_64_inventec_d7332_config.h +++ /dev/null @@ -1,137 +0,0 @@ -/**************************************************************************//** - * - * @file - * @brief x86_64_inventec_d7332 Configuration Header - * - * @addtogroup x86_64_inventec_d7332-config - * @{ - * - *****************************************************************************/ -#ifndef __x86_64_inventec_d7332_CONFIG_H__ -#define __x86_64_inventec_d7332_CONFIG_H__ - -#ifdef GLOBAL_INCLUDE_CUSTOM_CONFIG -#include -#endif -#ifdef x86_64_inventec_d7332_INCLUDE_CUSTOM_CONFIG -#include -#endif - -/* */ -#include -/** - * x86_64_inventec_d7332_CONFIG_INCLUDE_LOGGING - * - * Include or exclude logging. */ - - -#ifndef x86_64_inventec_d7332_CONFIG_INCLUDE_LOGGING -#define x86_64_inventec_d7332_CONFIG_INCLUDE_LOGGING 1 -#endif - -/** - * x86_64_inventec_d7332_CONFIG_LOG_OPTIONS_DEFAULT - * - * Default enabled log options. */ - - -#ifndef x86_64_inventec_d7332_CONFIG_LOG_OPTIONS_DEFAULT -#define x86_64_inventec_d7332_CONFIG_LOG_OPTIONS_DEFAULT AIM_LOG_OPTIONS_DEFAULT -#endif - -/** - * x86_64_inventec_d7332_CONFIG_LOG_BITS_DEFAULT - * - * Default enabled log bits. */ - - -#ifndef x86_64_inventec_d7332_CONFIG_LOG_BITS_DEFAULT -#define x86_64_inventec_d7332_CONFIG_LOG_BITS_DEFAULT AIM_LOG_BITS_DEFAULT -#endif - -/** - * x86_64_inventec_d7332_CONFIG_LOG_CUSTOM_BITS_DEFAULT - * - * Default enabled custom log bits. */ - - -#ifndef x86_64_inventec_d7332_CONFIG_LOG_CUSTOM_BITS_DEFAULT -#define x86_64_inventec_d7332_CONFIG_LOG_CUSTOM_BITS_DEFAULT 0 -#endif - -/** - * x86_64_inventec_d7332_CONFIG_PORTING_STDLIB - * - * Default all porting macros to use the C standard libraries. */ - - -#ifndef x86_64_inventec_d7332_CONFIG_PORTING_STDLIB -#define x86_64_inventec_d7332_CONFIG_PORTING_STDLIB 1 -#endif - -/** - * x86_64_inventec_d7332_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS - * - * Include standard library headers for stdlib porting macros. */ - - -#ifndef x86_64_inventec_d7332_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS -#define x86_64_inventec_d7332_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS x86_64_inventec_d7332_CONFIG_PORTING_STDLIB -#endif - -/** - * x86_64_inventec_d7332_CONFIG_INCLUDE_UCLI - * - * Include generic uCli support. */ - - -#ifndef x86_64_inventec_d7332_CONFIG_INCLUDE_UCLI -#define x86_64_inventec_d7332_CONFIG_INCLUDE_UCLI 0 -#endif - -/** - * x86_64_inventec_d7332_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION - * - * Assume chassis fan direction is the same as the PSU fan direction. */ - - -#ifndef x86_64_inventec_d7332_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION -#define x86_64_inventec_d7332_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION 0 -#endif - - - -/** - * All compile time options can be queried or displayed - */ - -/** Configuration settings structure. */ -typedef struct x86_64_inventec_d7332_config_settings_s { - /** name */ - const char* name; - /** value */ - const char* value; -} x86_64_inventec_d7332_config_settings_t; - -/** Configuration settings table. */ -/** x86_64_inventec_d7332_config_settings table. */ -extern x86_64_inventec_d7332_config_settings_t x86_64_inventec_d7332_config_settings[]; - -/** - * @brief Lookup a configuration setting. - * @param setting The name of the configuration option to lookup. - */ -const char* x86_64_inventec_d7332_config_lookup(const char* setting); - -/** - * @brief Show the compile-time configuration. - * @param pvs The output stream. - */ -int x86_64_inventec_d7332_config_show(struct aim_pvs_s* pvs); - -/* */ - -#include "x86_64_inventec_d7332_porting.h" - -#endif /* __x86_64_inventec_d7332_CONFIG_H__ */ -/* @} */ diff --git a/packages/platforms/inventec/x86-64/d7332/onlp/builds/x86_64_inventec_d7332/module/inc/x86_64_inventec_d7332/x86_64_inventec_d7332_dox.h b/packages/platforms/inventec/x86-64/d7332/onlp/builds/x86_64_inventec_d7332/module/inc/x86_64_inventec_d7332/x86_64_inventec_d7332_dox.h deleted file mode 100644 index 9d740ed86..000000000 --- a/packages/platforms/inventec/x86-64/d7332/onlp/builds/x86_64_inventec_d7332/module/inc/x86_64_inventec_d7332/x86_64_inventec_d7332_dox.h +++ /dev/null @@ -1,26 +0,0 @@ -/**************************************************************************//** - * - * x86_64_inventec_d7332 Doxygen Header - * - *****************************************************************************/ -#ifndef __x86_64_inventec_d7332_DOX_H__ -#define __x86_64_inventec_d7332_DOX_H__ - -/** - * @defgroup x86_64_inventec_d7332 x86_64_inventec_d7332 - x86_64_inventec_d7332 Description - * - -The documentation overview for this module should go here. - - * - * @{ - * - * @defgroup x86_64_inventec_d7332-x86_64_inventec_d7332 Public Interface - * @defgroup x86_64_inventec_d7332-config Compile Time Configuration - * @defgroup x86_64_inventec_d7332-porting Porting Macros - * - * @} - * - */ - -#endif /* __x86_64_inventec_d7332_DOX_H__ */ diff --git a/packages/platforms/inventec/x86-64/d7332/onlp/builds/x86_64_inventec_d7332/module/inc/x86_64_inventec_d7332/x86_64_inventec_d7332_porting.h b/packages/platforms/inventec/x86-64/d7332/onlp/builds/x86_64_inventec_d7332/module/inc/x86_64_inventec_d7332/x86_64_inventec_d7332_porting.h deleted file mode 100644 index 09264e423..000000000 --- a/packages/platforms/inventec/x86-64/d7332/onlp/builds/x86_64_inventec_d7332/module/inc/x86_64_inventec_d7332/x86_64_inventec_d7332_porting.h +++ /dev/null @@ -1,107 +0,0 @@ -/**************************************************************************//** - * - * @file - * @brief x86_64_inventec_d7332 Porting Macros. - * - * @addtogroup x86_64_inventec_d7332-porting - * @{ - * - *****************************************************************************/ -#ifndef __x86_64_inventec_d7332_PORTING_H__ -#define __x86_64_inventec_d7332_PORTING_H__ - - -/* */ -#if x86_64_inventec_d7332_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS == 1 -#include -#include -#include -#include -#include -#endif - -#ifndef x86_64_inventec_d7332_MALLOC - #if defined(GLOBAL_MALLOC) - #define x86_64_inventec_d7332_MALLOC GLOBAL_MALLOC - #elif x86_64_inventec_d7332_CONFIG_PORTING_STDLIB == 1 - #define x86_64_inventec_d7332_MALLOC malloc - #else - #error The macro x86_64_inventec_d7332_MALLOC is required but cannot be defined. - #endif -#endif - -#ifndef x86_64_inventec_d7332_FREE - #if defined(GLOBAL_FREE) - #define x86_64_inventec_d7332_FREE GLOBAL_FREE - #elif x86_64_inventec_d7332_CONFIG_PORTING_STDLIB == 1 - #define x86_64_inventec_d7332_FREE free - #else - #error The macro x86_64_inventec_d7332_FREE is required but cannot be defined. - #endif -#endif - -#ifndef x86_64_inventec_d7332_MEMSET - #if defined(GLOBAL_MEMSET) - #define x86_64_inventec_d7332_MEMSET GLOBAL_MEMSET - #elif x86_64_inventec_d7332_CONFIG_PORTING_STDLIB == 1 - #define x86_64_inventec_d7332_MEMSET memset - #else - #error The macro x86_64_inventec_d7332_MEMSET is required but cannot be defined. - #endif -#endif - -#ifndef x86_64_inventec_d7332_MEMCPY - #if defined(GLOBAL_MEMCPY) - #define x86_64_inventec_d7332_MEMCPY GLOBAL_MEMCPY - #elif x86_64_inventec_d7332_CONFIG_PORTING_STDLIB == 1 - #define x86_64_inventec_d7332_MEMCPY memcpy - #else - #error The macro x86_64_inventec_d7332_MEMCPY is required but cannot be defined. - #endif -#endif - -#ifndef x86_64_inventec_d7332_STRNCPY - #if defined(GLOBAL_STRNCPY) - #define x86_64_inventec_d7332_STRNCPY GLOBAL_STRNCPY - #elif x86_64_inventec_d7332_CONFIG_PORTING_STDLIB == 1 - #define x86_64_inventec_d7332_STRNCPY strncpy - #else - #error The macro x86_64_inventec_d7332_STRNCPY is required but cannot be defined. - #endif -#endif - -#ifndef x86_64_inventec_d7332_VSNPRINTF - #if defined(GLOBAL_VSNPRINTF) - #define x86_64_inventec_d7332_VSNPRINTF GLOBAL_VSNPRINTF - #elif x86_64_inventec_d7332_CONFIG_PORTING_STDLIB == 1 - #define x86_64_inventec_d7332_VSNPRINTF vsnprintf - #else - #error The macro x86_64_inventec_d7332_VSNPRINTF is required but cannot be defined. - #endif -#endif - -#ifndef x86_64_inventec_d7332_SNPRINTF - #if defined(GLOBAL_SNPRINTF) - #define x86_64_inventec_d7332_SNPRINTF GLOBAL_SNPRINTF - #elif x86_64_inventec_d7332_CONFIG_PORTING_STDLIB == 1 - #define x86_64_inventec_d7332_SNPRINTF snprintf - #else - #error The macro x86_64_inventec_d7332_SNPRINTF is required but cannot be defined. - #endif -#endif - -#ifndef x86_64_inventec_d7332_STRLEN - #if defined(GLOBAL_STRLEN) - #define x86_64_inventec_d7332_STRLEN GLOBAL_STRLEN - #elif x86_64_inventec_d7332_CONFIG_PORTING_STDLIB == 1 - #define x86_64_inventec_d7332_STRLEN strlen - #else - #error The macro x86_64_inventec_d7332_STRLEN is required but cannot be defined. - #endif -#endif - -/* */ - - -#endif /* __x86_64_inventec_d7332_PORTING_H__ */ -/* @} */ diff --git a/packages/platforms/inventec/x86-64/d7332/onlp/builds/x86_64_inventec_d7332/module/make.mk b/packages/platforms/inventec/x86-64/d7332/onlp/builds/x86_64_inventec_d7332/module/make.mk deleted file mode 100644 index 05677d9cb..000000000 --- a/packages/platforms/inventec/x86-64/d7332/onlp/builds/x86_64_inventec_d7332/module/make.mk +++ /dev/null @@ -1,11 +0,0 @@ -############################################################################### -# -# -# -############################################################################### -THIS_DIR := $(dir $(lastword $(MAKEFILE_LIST))) -x86_64_inventec_d7332_INCLUDES := -I $(THIS_DIR)inc -x86_64_inventec_d7332_INTERNAL_INCLUDES := -I $(THIS_DIR)src -x86_64_inventec_d7332_DEPENDMODULE_ENTRIES := init:x86_64_inventec_d7332 ucli:x86_64_inventec_d7332 - -x86_64_inventec_d7332_BROKEN_CFLAGS += -Wno-restrict -Wno-format-truncation diff --git a/packages/platforms/inventec/x86-64/d7332/onlp/builds/x86_64_inventec_d7332/module/src/Makefile b/packages/platforms/inventec/x86-64/d7332/onlp/builds/x86_64_inventec_d7332/module/src/Makefile deleted file mode 100644 index a8b89d016..000000000 --- a/packages/platforms/inventec/x86-64/d7332/onlp/builds/x86_64_inventec_d7332/module/src/Makefile +++ /dev/null @@ -1,9 +0,0 @@ -############################################################################### -# -# Local source generation targets. -# -############################################################################### - -ucli: - @../../../../tools/uclihandlers.py x86_64_inventec_d7332_ucli.c - diff --git a/packages/platforms/inventec/x86-64/d7332/onlp/builds/x86_64_inventec_d7332/module/src/fani.c b/packages/platforms/inventec/x86-64/d7332/onlp/builds/x86_64_inventec_d7332/module/src/fani.c deleted file mode 100644 index 4c1e3cb2f..000000000 --- a/packages/platforms/inventec/x86-64/d7332/onlp/builds/x86_64_inventec_d7332/module/src/fani.c +++ /dev/null @@ -1,499 +0,0 @@ -/************************************************************ - * fani.c - * - * Copyright 2018 Inventec Technology Corporation. - * - ************************************************************ - * - * Fan Platform Implementation Defaults. - * - ***********************************************************/ -#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) - -typedef enum hwmon_fan_state_e { - HWMON_FAN_F2B = 0, - HWMON_FAN_B2F = 1, - HWMON_FAN_UNPLUGGED = 2, - HWMON_FAN_UNPLUGGED2 = 3 -} hwmon_fan_state_t; - -#define SLOW_PWM 100 -#define NORMAL_PWM 175 -#define MAX_PWM 255 -#define STEP_SIZE 100 -#define FAN_ID_TO_PSU_ID(id) (id-ONLP_FAN_PSU_1+1) -#define BLADE_TO_FAN_ID(blade_id) (blade_id%2==0)? blade_id/2:(blade_id+1)/2 - - -#define TLV_PRODUCT_INFO_OFFSET_IDX 5 -#define TLV_PRODUCT_INFO_AREA_START 3 -#define TLV_ATTR_TYPE_SERIAL 5 -#define TLV_ATTR_TYPE_MODEL 2 - -#define FAN_I2C_CHANNEL 3 -#define FAN_I2C_ADDR_BASE 52 - -#define FAN_CAPS ONLP_FAN_CAPS_GET_RPM|ONLP_FAN_CAPS_GET_PERCENTAGE - -static int _fani_status_failed_check(uint32_t* status, int fan_id); -static int _fani_status_present_check(uint32_t* status, int fan_id); -static int _inv_get_fan_fru(char* ret_str,int attr_type, int fan_id); -extern char* psu_i2c_addr[ONLP_PSU_MAX]; - -#define MAKE_FAN_INFO_NODE_ON_PSU(psu_id) \ - { \ - { ONLP_FAN_ID_CREATE(ONLP_FAN_PSU_##psu_id), "PSU-"#psu_id" Fan", ONLP_PSU_ID_CREATE(ONLP_PSU_##psu_id)}, \ - 0, FAN_CAPS \ - } - -/* Static values */ -static onlp_fan_info_t __onlp_fan_info[] = { - {}, - { { ONLP_FAN_1, "Fan1-1", 0, }, 0, FAN_CAPS }, - { { ONLP_FAN_2, "Fan1-2", 0, }, 0, FAN_CAPS }, - { { ONLP_FAN_3, "Fan2-1", 0, }, 0, FAN_CAPS }, - { { ONLP_FAN_4, "Fan2-2", 0, }, 0, FAN_CAPS }, - { { ONLP_FAN_5, "Fan3-1", 0, }, 0, FAN_CAPS }, - { { ONLP_FAN_6, "Fan3-2", 0, }, 0, FAN_CAPS }, - { { ONLP_FAN_7, "Fan4-1", 0, }, 0, FAN_CAPS }, - { { ONLP_FAN_8, "Fan4-2", 0, }, 0, FAN_CAPS }, - { { ONLP_FAN_9, "Fan5-1", 0, }, 0, FAN_CAPS }, - { { ONLP_FAN_10, "Fan5-2", 0, }, 0, FAN_CAPS }, - { { ONLP_FAN_11, "Fan6-1", 0, }, 0, FAN_CAPS }, - { { ONLP_FAN_12, "Fan6-2", 0, }, 0, FAN_CAPS }, - MAKE_FAN_INFO_NODE_ON_PSU(1), - MAKE_FAN_INFO_NODE_ON_PSU(2), -}; - - -/* - * This function will be called prior to all of onlp_fani_* functions. - */ -int -onlp_fani_init(void) -{ - return ONLP_STATUS_OK; -} - -static int _inv_get_fan_fru(char* ret_str,int attr_type, int fan_id) -{ - int ret=ONLP_STATUS_OK; - uint8_t* rdata; - char file_path[ONLP_CONFIG_INFO_STR_MAX]; - char s; - int rdata_size=0,target_offset=0,attr_idx=0,attr_length=0; - int i=0; - int offset=BLADE_TO_FAN_ID(fan_id); - - snprintf(file_path,ONLP_CONFIG_INFO_STR_MAX,"%s%d-00%d/eeprom",INV_PSU_BASE,FAN_I2C_CHANNEL,(FAN_I2C_ADDR_BASE+offset-1) ); - - FILE* fp = fopen(file_path, "rb"); - if(fp){ - fseek(fp, 0L, SEEK_END); - rdata_size = ftell(fp); - rewind(fp); - rdata = aim_malloc(rdata_size); - fread(rdata, 1, rdata_size, fp); - fclose(fp); - }else{ - ret=ONLP_STATUS_E_INTERNAL; - } - - if(ret==ONLP_STATUS_OK) { - target_offset=rdata[TLV_PRODUCT_INFO_OFFSET_IDX-1]; - target_offset*=8; /*spec defined: offset are in multiples of 8 bytes*/ - attr_idx=target_offset+TLV_PRODUCT_INFO_AREA_START; - - for(i=1; irdata_size){ - ret=ONLP_STATUS_E_INTERNAL; - break; - } - attr_length=rdata[attr_idx]&(0x3F); /*spec defined: length are set in last 6 bits*/ - attr_idx+=(attr_length+1); - } - if(ret==ONLP_STATUS_OK){ - if(attr_length=ONLP_FAN_MAX) { - rv=ONLP_STATUS_E_INVALID; - } - if(rv==ONLP_STATUS_OK) { - *info=__onlp_fan_info[fan_id]; - rv=onlp_fani_status_get(id, &info->status); - } - if(rv == ONLP_STATUS_OK) { - if(info->status & ONLP_FAN_STATUS_PRESENT) { - switch(fan_id) { - case ONLP_FAN_1: - case ONLP_FAN_2: - case ONLP_FAN_3: - case ONLP_FAN_4: - case ONLP_FAN_5: - case ONLP_FAN_6: - case ONLP_FAN_7: - case ONLP_FAN_8: - case ONLP_FAN_9: - case ONLP_FAN_10: - case ONLP_FAN_11: - case ONLP_FAN_12: - if(info->status & ONLP_FAN_STATUS_F2B) { - info->caps = ADD_STATE(info->caps,ONLP_FAN_CAPS_F2B); - } else if(info->status & ONLP_FAN_STATUS_B2F) { - info->caps = ADD_STATE(info->caps,ONLP_FAN_CAPS_B2F) ; - } - - rv = onlp_file_read_int(&info->rpm, INV_FAN_PREFIX"fan%d_input", fan_id); - if(rv != ONLP_STATUS_OK ) { - return rv; - } - rv = onlp_file_read_int(&pwm,INV_FAN_PREFIX"pwm%d", BLADE_TO_FAN_ID(fan_id)); - if(rv != ONLP_STATUS_OK ) { - return rv; - } - - rv=_inv_get_fan_fru(info->serial,TLV_ATTR_TYPE_SERIAL,fan_id); - if(rv!=ONLP_STATUS_OK){ - snprintf(info->serial,ONLP_CONFIG_INFO_STR_MAX,"N/A"); - } - rv=_inv_get_fan_fru(info->model,TLV_ATTR_TYPE_MODEL,fan_id); - if(rv!=ONLP_STATUS_OK){ - snprintf(info->model,ONLP_CONFIG_INFO_STR_MAX,"N/A"); - } - - break; - case ONLP_FAN_PSU_1: - case ONLP_FAN_PSU_2: - info->caps = FAN_CAPS|ONLP_FAN_CAPS_F2B; - psu_id = FAN_ID_TO_PSU_ID(fan_id); - - snprintf(path,ONLP_CONFIG_INFO_STR_MAX,"%s%d-00%s/fan1_input",INV_PSU_BASE,PSU_I2C_CHAN,psu_i2c_addr[psu_id]); - rv = onlp_file_read_int(&info->rpm, path); - if(rv != ONLP_STATUS_OK) { - return rv; - } - snprintf(path,ONLP_CONFIG_INFO_STR_MAX,"%s%d-00%s/pwm1",INV_PSU_BASE,PSU_I2C_CHAN,psu_i2c_addr[psu_id]); - rv = onlp_file_read_int(&pwm, path); - if(rv != ONLP_STATUS_OK) { - return rv; - } - break; - default: - rv = ONLP_STATUS_E_INVALID; - break; - } - if(rv == ONLP_STATUS_OK) { - if(info->rpm <= 0) { - info->mode = ONLP_FAN_MODE_OFF; - info->percentage = 0; - } else { - info->percentage = (pwm*100)/MAX_PWM; - if(pwm < SLOW_PWM) { - info->mode = ONLP_FAN_MODE_SLOW; - } else if(pwm < NORMAL_PWM) { - info->mode = ONLP_FAN_MODE_NORMAL; - } else if(pwm < MAX_PWM) { - info->mode = ONLP_FAN_MODE_FAST; - } else { - info->mode = ONLP_FAN_MODE_MAX; - } - } - } - } else { - info->caps = 0; - info->rpm = 0; - info->percentage = 0; - info->mode = ONLP_FAN_MODE_OFF; - } - - } - return rv; -} -static int _fani_status_failed_check(uint32_t* status, int fan_id) -{ - int rv; - int rpm, pwm, psu_id; - char path[ONLP_CONFIG_INFO_STR_MAX]; - - switch(fan_id) { - case ONLP_FAN_1: - case ONLP_FAN_2: - case ONLP_FAN_3: - case ONLP_FAN_4: - case ONLP_FAN_5: - case ONLP_FAN_6: - case ONLP_FAN_7: - case ONLP_FAN_8: - case ONLP_FAN_9: - case ONLP_FAN_10: - case ONLP_FAN_11: - case ONLP_FAN_12: - rv = onlp_file_read_int(&rpm, INV_FAN_PREFIX"fan%d_input", fan_id); - - if(rv != ONLP_STATUS_OK ) { - return rv; - } - rv = onlp_file_read_int(&pwm,INV_FAN_PREFIX"pwm%d", BLADE_TO_FAN_ID(fan_id)); - if(rv != ONLP_STATUS_OK ) { - return rv; - } - - if(rpm<=0 || pwm<=0 || pwm > MAX_PWM) { - *status=ADD_STATE(*status,ONLP_FAN_STATUS_FAILED); - *status=REMOVE_STATE(*status,ONLP_FAN_STATUS_B2F); - *status=REMOVE_STATE(*status,ONLP_FAN_STATUS_F2B); - } else { - *status=REMOVE_STATE(*status,ONLP_FAN_STATUS_FAILED); - } - break; - case ONLP_FAN_PSU_1: - case ONLP_FAN_PSU_2: - psu_id = FAN_ID_TO_PSU_ID(fan_id); - - snprintf(path,ONLP_CONFIG_INFO_STR_MAX,"%s%d-00%s/fan1_input",INV_PSU_BASE,PSU_I2C_CHAN,psu_i2c_addr[psu_id]); - rv = onlp_file_read_int(&rpm, path); - if(rv != ONLP_STATUS_OK ) { - return rv; - } - snprintf(path,ONLP_CONFIG_INFO_STR_MAX,"%s%d-00%s/pwm1",INV_PSU_BASE,PSU_I2C_CHAN,psu_i2c_addr[psu_id]); - rv = onlp_file_read_int(&pwm, path); - if(rv != ONLP_STATUS_OK ) { - return rv; - } - - if( rpm <= 0 || pwm <=0 || pwm > MAX_PWM) { - *status=ADD_STATE(*status,ONLP_FAN_STATUS_FAILED); - *status=REMOVE_STATE(*status,ONLP_FAN_STATUS_B2F); - *status=REMOVE_STATE(*status,ONLP_FAN_STATUS_F2B); - } else { - *status=REMOVE_STATE(*status,ONLP_FAN_STATUS_FAILED); - } - break; - default: - rv = ONLP_STATUS_E_INVALID; - break; - } - return rv; -} - -static int _fani_status_present_check(uint32_t* status, int fan_id) -{ - int rv; - int len; - char buf[ONLP_CONFIG_INFO_STR_MAX]; - if(fan_id >= ONLP_FAN_1 && fan_id <= ONLP_FAN_12) { - rv = onlp_file_read((uint8_t*)buf,ONLP_CONFIG_INFO_STR_MAX, &len, INV_FAN_PREFIX"fanmodule%d_type",BLADE_TO_FAN_ID(fan_id)); - } else { - rv = ONLP_STATUS_E_INVALID; - } - if( rv == ONLP_STATUS_OK ) { - switch( (int)(buf[0]-'0') ){ - case HWMON_FAN_F2B: - *status=ADD_STATE(*status,ONLP_FAN_STATUS_PRESENT); - *status=ADD_STATE(*status,ONLP_FAN_STATUS_F2B); - break; - case HWMON_FAN_B2F: - *status=ADD_STATE(*status,ONLP_FAN_STATUS_PRESENT); - *status=ADD_STATE(*status,ONLP_FAN_STATUS_B2F); - break; - case HWMON_FAN_UNPLUGGED: - case HWMON_FAN_UNPLUGGED2: - *status=ADD_STATE(*status,ONLP_FAN_STATUS_FAILED); - break; - default: - rv = ONLP_STATUS_E_INVALID; - break; - } - } - return rv; -} - -/** - * @brief Retrieve the fan's operational status. - * @param id The fan OID. - * @param rv [out] Receives the fan's operations status flags. - * @notes Only operational state needs to be returned - - * PRESENT/FAILED - */ -int onlp_fani_status_get(onlp_oid_t id, uint32_t* rv) -{ - int result = ONLP_STATUS_OK; - onlp_fan_info_t* info; - int fan_id=ONLP_OID_ID_GET(id); - uint32_t psu_status; - - VALIDATE(id); - - - if(fan_id >= ONLP_FAN_MAX) { - result = ONLP_STATUS_E_INVALID; - } else { - info = &__onlp_fan_info[fan_id]; - switch(fan_id) { - case ONLP_FAN_1: - case ONLP_FAN_2: - case ONLP_FAN_3: - case ONLP_FAN_4: - case ONLP_FAN_5: - case ONLP_FAN_6: - case ONLP_FAN_7: - case ONLP_FAN_8: - case ONLP_FAN_9: - case ONLP_FAN_10: - case ONLP_FAN_11: - case ONLP_FAN_12: - result = _fani_status_present_check(&info->status, fan_id); - if (result == ONLP_STATUS_OK ) { - if (info->status & ONLP_FAN_STATUS_PRESENT) { - result = _fani_status_failed_check(&info->status, fan_id); - } - } - break; - case ONLP_FAN_PSU_1: - case ONLP_FAN_PSU_2: - result = onlp_psui_status_get((&info->hdr)->poid, &psu_status); - if(result != ONLP_STATUS_OK) { - return result; - } - if(psu_status & ONLP_PSU_STATUS_PRESENT) { - info->status = ADD_STATE(info->status, ONLP_FAN_STATUS_PRESENT); - result = _fani_status_failed_check(&info->status, fan_id); - } else { - info->status = 0; - } - break; - default: - result = ONLP_STATUS_E_INVALID; - break; - } - *rv = info->status; - } - return result; -} - -/** - * @brief Retrieve the fan's OID hdr. - * @param id The fan OID. - * @param rv [out] Receives the OID header. - */ -int onlp_fani_hdr_get(onlp_oid_t id, onlp_oid_hdr_t* hdr) -{ - int result = ONLP_STATUS_OK; - onlp_fan_info_t* info; - int fan_id; - VALIDATE(id); - - fan_id = ONLP_OID_ID_GET(id); - if(fan_id >= ONLP_FAN_MAX) { - result = ONLP_STATUS_E_INVALID; - } else { - info = &__onlp_fan_info[fan_id]; - *hdr = info->hdr; - } - return result; -} - - -/* - * 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) -{ - return ONLP_STATUS_E_UNSUPPORTED; -} - - -/* - * 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/d7332/onlp/builds/x86_64_inventec_d7332/module/src/ledi.c b/packages/platforms/inventec/x86-64/d7332/onlp/builds/x86_64_inventec_d7332/module/src/ledi.c deleted file mode 100644 index 95b01bb57..000000000 --- a/packages/platforms/inventec/x86-64/d7332/onlp/builds/x86_64_inventec_d7332/module/src/ledi.c +++ /dev/null @@ -1,439 +0,0 @@ -/************************************************************ - * ledi.c - * - * Copyright 2018 Inventec Technology Corporation. - * - ************************************************************ - * - ***********************************************************/ -#include -#include -#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) - -/* LED related data - */ - -/* CAPS*/ -#define SYS_LED_CAPS 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_ORANGE -#define FAN_LED_CAPS ONLP_LED_CAPS_RED|ONLP_LED_CAPS_GREEN - -#define LED_ID_TO_FAN_ID(id) (id-ONLP_LED_MGMT) -#define FAN_TO_BLADE_ID(fan_id) fan_id*2 - -typedef enum sys_led_mode_e { - SYS_LED_MODE_OFF = 0, - SYS_LED_MODE_0_5_HZ = 1, - SYS_LED_MODE_1_HZ = 2, - SYS_LED_MODE_2_HZ = 3, - SYS_LED_MODE_4_HZ = 4, - SYS_LED_MODE_ON = 7 -} sys_led_mode_t; - -/* function declarations*/ -static int _sys_onlp_led_mode_convert(sys_led_mode_t grn_mode, sys_led_mode_t red_mode, onlp_led_mode_t* pmode); -static int _sys_onlp_ledi_info_get(onlp_oid_t id, onlp_led_info_t* info); -static int _fan_onlp_ledi_info_get(onlp_oid_t id, onlp_led_info_t* info); -static int _sys_onlp_ledi_mode_set(onlp_led_mode_t onlp_mode); - -/* - * Get the information for the given LED OID. - */ -#define MAKE_MGMT_LED_INFO_NODE \ - { \ - { ONLP_LED_ID_CREATE(ONLP_LED_MGMT), "MGMT LED" , 0 }, \ - ONLP_LED_STATUS_PRESENT, \ - SYS_LED_CAPS, \ - } - -#define MAKE_LED_INFO_NODE_ON_FAN(fan_id) \ - { \ - { ONLP_LED_ID_CREATE(ONLP_LED_FAN##fan_id), \ - "FAN LED "#fan_id, 0, \ - }, \ - 0, FAN_LED_CAPS, \ - } - -static onlp_led_info_t __onlp_led_info[] = { - {}, - MAKE_MGMT_LED_INFO_NODE, - MAKE_LED_INFO_NODE_ON_FAN(1), - MAKE_LED_INFO_NODE_ON_FAN(2), - MAKE_LED_INFO_NODE_ON_FAN(3), - MAKE_LED_INFO_NODE_ON_FAN(4), - MAKE_LED_INFO_NODE_ON_FAN(5), - MAKE_LED_INFO_NODE_ON_FAN(6), -}; - - - -/* convert platform led type to onlp_led_mode type*/ -static int _sys_onlp_led_mode_convert(sys_led_mode_t grn_mode, sys_led_mode_t red_mode, onlp_led_mode_t* pmode) -{ - int rv = ONLP_STATUS_OK; - *pmode = ONLP_LED_MODE_OFF; - - switch(grn_mode) { - case SYS_LED_MODE_0_5_HZ: - case SYS_LED_MODE_1_HZ: - case SYS_LED_MODE_2_HZ: - case SYS_LED_MODE_4_HZ: - if(red_mode==SYS_LED_MODE_OFF) { - *pmode = ONLP_LED_MODE_GREEN_BLINKING; - } else { - return ONLP_STATUS_E_INVALID; - } - break; - case SYS_LED_MODE_ON: - if(red_mode==SYS_LED_MODE_ON) { - *pmode = ONLP_LED_MODE_ORANGE; - } else if(red_mode==SYS_LED_MODE_OFF) { - *pmode = ONLP_LED_MODE_GREEN; - } else { - return ONLP_STATUS_E_INVALID; - } - break; - case SYS_LED_MODE_OFF: - if(red_mode==SYS_LED_MODE_OFF) { - *pmode = ONLP_LED_MODE_OFF; - } else if( (red_mode>=SYS_LED_MODE_0_5_HZ) && (red_mode<=SYS_LED_MODE_4_HZ) ) { - *pmode =ONLP_LED_MODE_RED_BLINKING; - } else if(red_mode==SYS_LED_MODE_ON) { - *pmode=ONLP_LED_MODE_RED; - } else { - return ONLP_STATUS_E_INVALID; - } - break; - default: - return ONLP_STATUS_E_INVALID; - break; - } - return rv; -} - - -static int _sys_onlp_ledi_info_get(onlp_oid_t id, onlp_led_info_t* info) -{ - int rv = ONLP_STATUS_OK; - int grn_mode=0, red_mode=0,len; - int led_id= ONLP_OID_ID_GET(id); - *info= __onlp_led_info[led_id]; - char buf[ONLP_CONFIG_INFO_STR_MAX]; - rv = onlp_file_read((uint8_t*)buf,ONLP_CONFIG_INFO_STR_MAX, &len,INV_LED_PREFIX"grn_led"); - if(rv != ONLP_STATUS_OK) { - return rv; - } - grn_mode=(int)(buf[0]-'0'); - - rv = onlp_file_read((uint8_t*)buf,ONLP_CONFIG_INFO_STR_MAX, &len,INV_LED_PREFIX"red_led"); - if(rv != ONLP_STATUS_OK) { - return rv; - } - red_mode=(int)(buf[0]-'0'); - - rv = _sys_onlp_led_mode_convert(grn_mode, red_mode, &info->mode); - if(rv != ONLP_STATUS_OK) { - return rv; - } - - if(info->mode==ONLP_LED_MODE_OFF) { - info->status = REMOVE_STATE(info->status,ONLP_LED_STATUS_ON); - } else { - info->status = ADD_STATE(info->status,ONLP_LED_STATUS_ON); - } - - return rv; -} - -static int _fan_onlp_ledi_info_get(onlp_oid_t id, onlp_led_info_t* info) -{ - int rv = ONLP_STATUS_OK, len; - int led_id=ONLP_OID_ID_GET(id); - int fan_id=LED_ID_TO_FAN_ID(led_id); - *info=__onlp_led_info[led_id]; - char buf[ONLP_CONFIG_INFO_STR_MAX]; - - rv = onlp_ledi_status_get(id, &info->status); - if( rv != ONLP_STATUS_OK ) { - return rv; - } - - if( info->status & ONLP_LED_STATUS_PRESENT) { - rv = onlp_file_read((uint8_t*)buf,ONLP_CONFIG_INFO_STR_MAX, &len, INV_LED_PREFIX"fanmodule%d_led", fan_id); - if(rv == ONLP_STATUS_OK ) { - switch(buf[0]) { - case '0': - info->mode = ONLP_LED_MODE_OFF; - break; - case '1': - info->mode = ONLP_LED_MODE_GREEN; - break; - case '2': - info->mode = ONLP_LED_MODE_RED; - break; - default: - rv=ONLP_STATUS_E_INVALID; - break; - } - } - } else { - info->mode = ONLP_LED_MODE_OFF; - } - return rv; -} - -static int _sys_onlp_ledi_mode_set(onlp_led_mode_t onlp_mode) -{ - int rv = ONLP_STATUS_OK; - - if( onlp_mode == ONLP_LED_MODE_OFF) { - rv = onlp_file_write_int(SYS_LED_MODE_OFF, INV_LED_PREFIX"grn_led"); - if(rv != ONLP_STATUS_OK ) { - return rv; - } - rv = onlp_file_write_int(SYS_LED_MODE_OFF, INV_LED_PREFIX"red_led"); - } else { - rv = ONLP_STATUS_E_UNSUPPORTED; - } - return rv; -} - - - -/* - * 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; - VALIDATE(id); - int led_id= ONLP_OID_ID_GET(id); - if( led_id >= ONLP_LED_MAX) { - return ONLP_STATUS_E_INVALID; - } - - switch(led_id) { - case ONLP_LED_MGMT: - rv = _sys_onlp_ledi_info_get(id, info); - break; - case ONLP_LED_FAN1: - case ONLP_LED_FAN2: - case ONLP_LED_FAN3: - case ONLP_LED_FAN4: - case ONLP_LED_FAN5: - case ONLP_LED_FAN6: - rv = _fan_onlp_ledi_info_get(id, info); - break; - default: - rv = ONLP_STATUS_E_INVALID; - break; - } - return rv; -} - -/** - * @brief Get the LED operational status. - * @param id The LED OID - * @param rv [out] Receives the operational status. - */ -int onlp_ledi_status_get(onlp_oid_t id, uint32_t* rv) -{ - int result = ONLP_STATUS_OK; - onlp_led_info_t* info; - - VALIDATE(id); - int led_id = ONLP_OID_ID_GET(id); - int fan_id = LED_ID_TO_FAN_ID( led_id); - int grn_mode, red_mode; - char mode[ONLP_CONFIG_INFO_STR_MAX]; - onlp_led_mode_t pmode; - uint32_t fan_status; - - if( led_id >= ONLP_LED_MAX) { - result = ONLP_STATUS_E_INVALID; - } - if(result == ONLP_STATUS_OK) { - info = &__onlp_led_info[led_id]; - switch(led_id) { - case ONLP_LED_MGMT: - result = onlp_file_read_int((int*)&grn_mode, INV_LED_PREFIX"grn_led"); - if(result != ONLP_STATUS_OK) { - return result; - } - result = onlp_file_read_int((int*)&red_mode, INV_LED_PREFIX"red_led"); - if(result != ONLP_STATUS_OK) { - return result; - } - - result = _sys_onlp_led_mode_convert(grn_mode, red_mode, &pmode); - if(result != ONLP_STATUS_OK) { - return result; - } - - if( pmode != ONLP_LED_MODE_OFF) { - info->status = ADD_STATE(info->status,ONLP_LED_STATUS_ON); - } else { - info->status = REMOVE_STATE(info->status, ONLP_LED_STATUS_ON); - } - - *rv = info->status; - break; - case ONLP_LED_FAN1: - case ONLP_LED_FAN2: - case ONLP_LED_FAN3: - case ONLP_LED_FAN4: - case ONLP_LED_FAN5: - case ONLP_LED_FAN6: - result = onlp_fani_status_get(ONLP_FAN_ID_CREATE(FAN_TO_BLADE_ID(fan_id)), &fan_status); - if(result != ONLP_STATUS_OK) { - return result; - } - - if(fan_status & ONLP_FAN_STATUS_PRESENT) { - info->status = ADD_STATE(info->status,ONLP_LED_STATUS_PRESENT); - result = onlp_file_read_int((int*)&mode, INV_LED_PREFIX"fanmodule%d_led", fan_id); - if(result != ONLP_STATUS_OK) { - return result; - } - - if(mode[0]=='0') { - info->status = REMOVE_STATE(info->status,ONLP_LED_STATUS_ON); - } else { - info->status = ADD_STATE(info->status,ONLP_LED_STATUS_ON); - } - } else { - info->status = 0; - } - *rv = info->status; - break; - default: - result = ONLP_STATUS_E_INVALID; - break; - } - } - - return result; -} - -/** - * @brief Get the LED header. - * @param id The LED OID - * @param rv [out] Receives the header. - */ -int onlp_ledi_hdr_get(onlp_oid_t id, onlp_oid_hdr_t* rv) -{ - int result = ONLP_STATUS_OK; - onlp_led_info_t* info; - - VALIDATE(id); - - int led_id = ONLP_OID_ID_GET(id); - if( led_id >= ONLP_LED_MAX) { - result = ONLP_STATUS_E_INVALID; - } else { - - info = &__onlp_led_info[led_id]; - *rv = info->hdr; - } - return result; -} - -/* - * 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) -{ - onlp_led_mode_t mode; - VALIDATE(id); - int led_id; - led_id = ONLP_OID_ID_GET(id); - - if(led_id >= ONLP_LED_MAX) { - return ONLP_STATUS_E_INVALID; - } - - if (__onlp_led_info[led_id].caps & ONLP_LED_CAPS_ON_OFF) { - if(on_or_off){ - mode =ONLP_LED_MODE_ON; - }else{ - mode=ONLP_LED_MODE_OFF; - } - return onlp_ledi_mode_set(id, mode); - } - - 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 rv = ONLP_STATUS_OK; - VALIDATE(id); - int led_id; - led_id = ONLP_OID_ID_GET(id); - - if(led_id >= ONLP_LED_MAX) { - return ONLP_STATUS_E_INVALID; - } - switch(led_id) { - case ONLP_LED_MGMT: - rv = _sys_onlp_ledi_mode_set(mode); - break; - case ONLP_LED_FAN1: - case ONLP_LED_FAN2: - case ONLP_LED_FAN3: - case ONLP_LED_FAN4: - case ONLP_LED_FAN5: - case ONLP_LED_FAN6: - rv = ONLP_STATUS_E_UNSUPPORTED; - break; - default: - rv = ONLP_STATUS_E_INVALID; - break; - } - - return rv; -} - -/* - * 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/d7332/onlp/builds/x86_64_inventec_d7332/module/src/make.mk b/packages/platforms/inventec/x86-64/d7332/onlp/builds/x86_64_inventec_d7332/module/src/make.mk deleted file mode 100644 index 0a7d6ec1e..000000000 --- a/packages/platforms/inventec/x86-64/d7332/onlp/builds/x86_64_inventec_d7332/module/src/make.mk +++ /dev/null @@ -1,9 +0,0 @@ -############################################################################### -# -# -# -############################################################################### - -LIBRARY := x86_64_inventec_d7332 -$(LIBRARY)_SUBDIR := $(dir $(lastword $(MAKEFILE_LIST))) -include $(BUILDER)/lib.mk diff --git a/packages/platforms/inventec/x86-64/d7332/onlp/builds/x86_64_inventec_d7332/module/src/platform_lib.c b/packages/platforms/inventec/x86-64/d7332/onlp/builds/x86_64_inventec_d7332/module/src/platform_lib.c deleted file mode 100644 index aa29a967a..000000000 --- a/packages/platforms/inventec/x86-64/d7332/onlp/builds/x86_64_inventec_d7332/module/src/platform_lib.c +++ /dev/null @@ -1,34 +0,0 @@ -/************************************************************ - * platform_lib.c - * - * Copyright 2018 Inventec Technology Corporation. - * - ************************************************************ - * - ***********************************************************/ -#include -#include -#include -#include -#include -#include -#include -#include -#include "platform_lib.h" - - - -int platform_hwmon_diag_enable_read(int *enable) -{ - int rv = ONLP_STATUS_OK; - rv = onlp_file_read_int((int*)enable, INV_INFO_PREFIX"diag"); - return rv; -} - - -int platform_hwmon_diag_enable_write(int enable) -{ - int rv = ONLP_STATUS_OK; - rv = onlp_file_write_int(enable, INV_INFO_PREFIX"diag"); - return rv; -} \ No newline at end of file diff --git a/packages/platforms/inventec/x86-64/d7332/onlp/builds/x86_64_inventec_d7332/module/src/platform_lib.h b/packages/platforms/inventec/x86-64/d7332/onlp/builds/x86_64_inventec_d7332/module/src/platform_lib.h deleted file mode 100644 index 837ae8cd4..000000000 --- a/packages/platforms/inventec/x86-64/d7332/onlp/builds/x86_64_inventec_d7332/module/src/platform_lib.h +++ /dev/null @@ -1,141 +0,0 @@ -/************************************************************ - * platform_lib.h - * - * Copyright 2018 Inventec Technology Corporation. - * - ************************************************************ - * - ***********************************************************/ -#ifndef __PLATFORM_LIB_H__ -#define __PLATFORM_LIB_H__ - -#include "x86_64_inventec_d7332_log.h" - -/* This is definitions for x86-64-inventec-d7332*/ -/* OID map*/ -/* - * SYS---------ONLP_THERMAL_CPU_PHY - * |----ONLP_THERMAL_CPU_CORE0 - * |----ONLP_THERMAL_CPU_CORE1 - * |----ONLP_THERMAL_CPU_CORE2 - * |----ONLP_THERMAL_CPU_CORE3 - * |----ONLP_THERMAL_1_ON_MAIN_BROAD - * |----ONLP_THERMAL_2_ON_MAIN_BROAD - * |----ONLP_THERMAL_3_ON_MAIN_BROAD - * |----ONLP_THERMAL_4_ON_MAIN_BROAD - * |----ONLP_THERMAL_5_ON_MAIN_BROAD - * |----ONLP_FAN_1--------ONLP_LED_FAN1 - * | - * |----ONLP_FAN_2--------ONLP_LED_FAN2 - * | - * |----ONLP_FAN_3--------ONLP_LED_FAN3 - * | - * |----ONLP_FAN_4--------ONLP_LED_FAN4 - * | - * |----ONLP_FAN_5--------ONLP_LED_FAN5 - * | - * |----ONLP_FAN_6--------ONLP_LED_FAN6 - * | - * | - * |----ONLP_PSU_1--------ONLP_THERMAL_1_ON_PSU1 - * | |--ONLP_THERMAL_2_ON_PSU1 - * | |--ONLP_THERMAL_3_ON_PSU1 - * | |--ONLP_FAN_PSU_1 - * | - * |----ONLP_PSU_2--------ONLP_THERMAL_1_ON_PSU2 - * | |--ONLP_THERMAL_2_ON_PSU2 - * | |--ONLP_THERMAL_3_ON_PSU2 - * | |--ONLP_FAN_PSU_2 - * | - * |----ONLP_LED_MGMT - */ - -#define INV_INFO_PREFIX "/sys/bus/i2c/devices/2-0077/" -#define INV_FAN_PREFIX "/sys/bus/i2c/devices/2-0077/" -#define INV_THERMAL_PREFIX "/sys/bus/i2c/devices/2-0077/" -#define INV_LED_PREFIX "/sys/bus/i2c/devices/2-0077/" -#define INV_SFP_PREFIX "/sys/swps/card1/sff/" -#define INV_SYS_PREFIX "/sys/class/eeprom/vpd/" -#define INV_PSU_BASE "/sys/bus/i2c/devices/" -#define INV_CTMP_BASE "/sys/devices/platform/coretemp.0/hwmon/" -#define INV_EEPROM_PATH "/sys/bus/i2c/devices/2-0055/eeprom" -#define PSU_I2C_CHAN 2 - -#define ADD_STATE(orig_state,new_state) orig_state | new_state -#define REMOVE_STATE(orig_state, target) orig_state & (~target) - -/* Thermal definitions*/ -enum onlp_thermal_id { - ONLP_THERMAL_CPU_PHY = 1, - ONLP_THERMAL_CPU_CORE0, - ONLP_THERMAL_CPU_CORE1, - ONLP_THERMAL_CPU_CORE2, - ONLP_THERMAL_CPU_CORE3, - ONLP_THERMAL_1_ON_MAIN_BROAD, - ONLP_THERMAL_2_ON_MAIN_BROAD, - ONLP_THERMAL_3_ON_MAIN_BROAD, - ONLP_THERMAL_4_ON_MAIN_BROAD, - ONLP_THERMAL_5_ON_MAIN_BROAD, - ONLP_THERMAL_6_ON_MAIN_BROAD, - ONLP_THERMAL_7_ON_MAIN_BROAD, - ONLP_THERMAL_1_ON_PSU1, - ONLP_THERMAL_2_ON_PSU1, - ONLP_THERMAL_3_ON_PSU1, - ONLP_THERMAL_1_ON_PSU2, - ONLP_THERMAL_2_ON_PSU2, - ONLP_THERMAL_3_ON_PSU2, - ONLP_THERMAL_MAX /*num limit include reserved*/ -}; - -/* Fan definitions*/ -enum onlp_fan_id { - ONLP_FAN_1 = 1, - ONLP_FAN_2, - ONLP_FAN_3, - ONLP_FAN_4, - ONLP_FAN_5, - ONLP_FAN_6, - ONLP_FAN_7, - ONLP_FAN_8, - ONLP_FAN_9, - ONLP_FAN_10, - ONLP_FAN_11, - ONLP_FAN_12, - ONLP_FAN_PSU_1, - ONLP_FAN_PSU_2, - ONLP_FAN_MAX /*num limit include reserved*/ -}; - -/* PSU definitions*/ -enum onlp_psu_id { - ONLP_PSU_1 = 1, - ONLP_PSU_2, - ONLP_PSU_MAX /*num limit include reserved*/ -}; - -/* LED definitions*/ -enum onlp_led_id { - ONLP_LED_MGMT = 1, - ONLP_LED_FAN1, - ONLP_LED_FAN2, - ONLP_LED_FAN3, - ONLP_LED_FAN4, - ONLP_LED_FAN5, - ONLP_LED_FAN6, - ONLP_LED_MAX /*num limit include reserved*/ -}; - -/* platform functions*/ -#define PLATFORM_HWMON_DIAG_LOCK -#define PLATFORM_HWMON_DIAG_UNLOCK -//#define PLATFORM_HWMON_DIAG_LOCK platform_hwmon_diag_enable_write(0) -//#define PLATFORM_HWMON_DIAG_UNLOCK platform_hwmon_diag_enable_write(1) -int platform_hwmon_diag_enable_read(int *enable); -int platform_hwmon_diag_enable_write(int enable); -char* hwmon_path( char* parent_dir); - -extern char* psu_i2c_addr[ONLP_PSU_MAX]; - - -#endif /* __PLATFORM_LIB_H__ */ - diff --git a/packages/platforms/inventec/x86-64/d7332/onlp/builds/x86_64_inventec_d7332/module/src/psui.c b/packages/platforms/inventec/x86-64/d7332/onlp/builds/x86_64_inventec_d7332/module/src/psui.c deleted file mode 100644 index 05dcc37f6..000000000 --- a/packages/platforms/inventec/x86-64/d7332/onlp/builds/x86_64_inventec_d7332/module/src/psui.c +++ /dev/null @@ -1,204 +0,0 @@ -/************************************************************ - * psui.c - * - * Copyright 2018 Inventec Technology Corporation. - * - ************************************************************ - * - ***********************************************************/ -#include -#include -#include "platform_lib.h" -#include -#include - -#define VALIDATE(_id) \ - do { \ - if(!ONLP_OID_IS_PSU(_id)) { \ - return ONLP_STATUS_E_INVALID; \ - } \ - } while(0) - -typedef enum hwmon_psu_state_e { - HWMON_PSU_NORMAL = 0, - HWMON_PSU_UNPOWERED = 2, //010 - HWMON_PSU_FAULT = 4, //100 - HWMON_PSU_NOT_INSTALLED = 7 //111 -} hwmon_psu_state_t; - -#define PSU_CAPS ONLP_PSU_CAPS_VIN|ONLP_PSU_CAPS_VOUT|ONLP_PSU_CAPS_IIN|ONLP_PSU_CAPS_IOUT|ONLP_PSU_CAPS_PIN| ONLP_PSU_CAPS_POUT - -char* psu_i2c_addr[ONLP_PSU_MAX]= { - "", - "58", - "59" -}; - -/* - * Get all information about the given PSU oid. - */ -#define MAKE_PSU_NODE_INFO(id) \ - { \ - { \ - ONLP_PSU_ID_CREATE(ONLP_PSU_##id), "PSU-"#id, 0, \ - { \ - ONLP_THERMAL_ID_CREATE(ONLP_THERMAL_1_ON_PSU##id), \ - ONLP_THERMAL_ID_CREATE(ONLP_THERMAL_2_ON_PSU##id), \ - ONLP_THERMAL_ID_CREATE(ONLP_THERMAL_3_ON_PSU##id), \ - ONLP_FAN_ID_CREATE(ONLP_FAN_PSU_##id) \ - } \ - }, \ - "","", 0, PSU_CAPS, \ - } - -static onlp_psu_info_t __onlp_psu_info[ ] = { - {}, - MAKE_PSU_NODE_INFO(1), - MAKE_PSU_NODE_INFO(2) -}; - -int -onlp_psui_init(void) -{ - return ONLP_STATUS_OK; -} - - -int -onlp_psui_info_get(onlp_oid_t id, onlp_psu_info_t* info) -{ - int ret = ONLP_STATUS_OK; - int len; - int psu_id = ONLP_OID_ID_GET(id); - uint8_t buf[ONLP_CONFIG_INFO_STR_MAX] = {0}; - char path[ONLP_CONFIG_INFO_STR_MAX]; - - VALIDATE(id); - - if(psu_id >= ONLP_PSU_MAX) { - return ONLP_STATUS_E_INVALID; - } - - *info = __onlp_psu_info[psu_id]; - ret = onlp_psui_status_get(id, &info->status); - if(ret != ONLP_STATUS_OK) { - return ret; - } - - if(info->status & ONLP_PSU_STATUS_PRESENT) { - snprintf(path,ONLP_CONFIG_INFO_STR_MAX, INV_PSU_BASE"%d-00%s/",PSU_I2C_CHAN,psu_i2c_addr[psu_id]); - - memset(buf, 0, ONLP_CONFIG_INFO_STR_MAX); - ret=onlp_file_read( buf, ONLP_CONFIG_INFO_STR_MAX, &len, "%smfr_id", path ); - if(ret==ONLP_STATUS_OK) { - buf[strlen((char*)buf)-1] = 0; - snprintf(info->model, ONLP_CONFIG_INFO_STR_MAX, "%s", buf); - } - - memset(buf, 0, ONLP_CONFIG_INFO_STR_MAX); - ret=onlp_file_read( buf, ONLP_CONFIG_INFO_STR_MAX, &len, "%smfr_serial_number", path ); - if(ret==ONLP_STATUS_OK) { - buf[strlen((char*)buf)-1] = 0; - snprintf(info->serial, ONLP_CONFIG_INFO_STR_MAX, "%s", buf); - } - - if(ret==ONLP_STATUS_OK) { - ret=onlp_file_read_int( &info->mvin, "%sin1_input", path ); - } - - if(ret==ONLP_STATUS_OK) { - ret=onlp_file_read_int( &info->mvout, "%sin2_input", path ); - } - - if(ret==ONLP_STATUS_OK) { - ret=onlp_file_read_int( &info->miin, "%scurr1_input", path ); - } - - if(ret==ONLP_STATUS_OK) { - ret=onlp_file_read_int( &info->miout, "%scurr2_input", path ); - } - - if(ret==ONLP_STATUS_OK) { - ret=onlp_file_read_int( &info->mpin, "%spower1_input", path ); - } - - if(ret==ONLP_STATUS_OK) { - ret=onlp_file_read_int( &info->mpout, "%spower2_input", path ); - } - } - - return ret; - -} - - -/** - * @brief Get the PSU's operational status. - * @param id The PSU OID. - * @param rv [out] Receives the operational status. - */ -int onlp_psui_status_get(onlp_oid_t id, uint32_t* rv) -{ - int result = ONLP_STATUS_OK; - hwmon_psu_state_t psu_state; - int local_id; - int len; - char buf[ONLP_CONFIG_INFO_STR_MAX]; - - VALIDATE(id); - - - local_id = ONLP_OID_ID_GET(id); - - if(local_id >= ONLP_PSU_MAX) { - result = ONLP_STATUS_E_INVALID; - } else { - result = onlp_file_read((uint8_t*)&buf, ONLP_CONFIG_INFO_STR_MAX, &len, "%spsu%d", INV_INFO_PREFIX, local_id); - if( result != ONLP_STATUS_OK ) { - return result; - } - psu_state = (uint8_t)strtoul(buf, NULL, 0); - if( psu_state == HWMON_PSU_UNPOWERED) { - *rv = ONLP_PSU_STATUS_PRESENT|ONLP_PSU_STATUS_UNPLUGGED; - } else if ( psu_state == HWMON_PSU_NORMAL) { - *rv = ONLP_PSU_STATUS_PRESENT; - } else if( psu_state == HWMON_PSU_FAULT) { - *rv = ONLP_PSU_STATUS_PRESENT|ONLP_PSU_STATUS_FAILED; - } else if( psu_state == HWMON_PSU_NOT_INSTALLED) { - *rv = 0; - } else { - result = ONLP_STATUS_E_INVALID; - } - } - return result; -} - -/** - * @brief Get the PSU's oid header. - * @param id The PSU OID. - * @param rv [out] Receives the header. - */ -int onlp_psui_hdr_get(onlp_oid_t id, onlp_oid_hdr_t* rv) -{ - int result = ONLP_STATUS_OK; - onlp_psu_info_t* info; - int psu_id=ONLP_OID_ID_GET(id); - - VALIDATE(id); - - if(psu_id >= ONLP_PSU_MAX) { - result = ONLP_STATUS_E_INVALID; - } else { - info = &__onlp_psu_info[psu_id]; - *rv = info->hdr; - } - return result; -} - - -int -onlp_psui_ioctl(onlp_oid_t pid, va_list vargs) -{ - return ONLP_STATUS_E_UNSUPPORTED; -} - diff --git a/packages/platforms/inventec/x86-64/d7332/onlp/builds/x86_64_inventec_d7332/module/src/sfpi.c b/packages/platforms/inventec/x86-64/d7332/onlp/builds/x86_64_inventec_d7332/module/src/sfpi.c deleted file mode 100644 index 0678cfe2f..000000000 --- a/packages/platforms/inventec/x86-64/d7332/onlp/builds/x86_64_inventec_d7332/module/src/sfpi.c +++ /dev/null @@ -1,297 +0,0 @@ -/************************************************************ - * sfpi.c - * - * Copyright 2018 Inventec Technology Corporation. - * - ************************************************************ - * - ***********************************************************/ - -#include -#include /* For O_RDWR && open */ -#include -#include -#include -#include -#include -#include "platform_lib.h" -#include -#include - -#define SLEEP_TIME 0.5 -#define RETRY_TIME 5 -#define SFP_PRESENT '1' -#define SFP_NOT_PRESENT '0' -#define SFP_PAGE_IDLE 0 -#define SFP_PAGE_LOCKED 1 -#define MUX_START_INDEX 14 -#define QSFP_DEV_ADDR 0x50 -#define NUM_OF_QSFP_DD_PORT 32 -#define NUM_OF_ALL_PORT (NUM_OF_QSFP_DD_PORT) - -#define FRONT_PORT_TO_MUX_INDEX(port) (port+MUX_START_INDEX) -#define PORT_TO_PATH_ID(port) (port+1) -#define VALIDATE_PORT(p) { if ((p < 0) || (p >= NUM_OF_ALL_PORT)) return ONLP_STATUS_E_PARAM; } -/************************************************************ - * - * SFPI Entry Points - * - ***********************************************************/ -int -onlp_sfpi_init(void) -{ - /* Called at initialization time */ - return ONLP_STATUS_OK; -} - -int onlp_sfpi_port_map(int port, int* rport) -{ - VALIDATE_PORT(port); - *rport = port; - return ONLP_STATUS_OK; -} - -int -onlp_sfpi_bitmap_get(onlp_sfp_bitmap_t* bmap) -{ - /* - * Ports {0, 63} - */ - int p; - AIM_BITMAP_CLR_ALL(bmap); - - for(p = 0; p < NUM_OF_ALL_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. - */ - VALIDATE_PORT(port); - int rv,len; - char buf[ONLP_CONFIG_INFO_STR_MAX]; - if(onlp_file_read( (uint8_t*)buf, ONLP_CONFIG_INFO_STR_MAX, &len, INV_SFP_PREFIX"prs") != ONLP_STATUS_OK) { - return ONLP_STATUS_E_INTERNAL; - } - if(buf[port] == SFP_NOT_PRESENT) { - rv = 0; - } else if (buf[port] == SFP_PRESENT) { - rv = 1; - } else { - AIM_LOG_ERROR("Unvalid present status %d from port(%d)\r\n",buf[port],port); - return ONLP_STATUS_E_INTERNAL; - } - return rv; -} - -int -onlp_sfpi_presence_bitmap_get(onlp_sfp_bitmap_t* dst) -{ - AIM_BITMAP_CLR_ALL(dst); - int port; - for(port = 0; port < NUM_OF_ALL_PORT; port++) { - if(onlp_sfpi_is_present(port) == 1) { - AIM_BITMAP_MOD(dst, port, 1); - } else if(onlp_sfpi_is_present(port) == 0) { - AIM_BITMAP_MOD(dst, port, 0); - } else { - return ONLP_STATUS_E_INTERNAL; - } - } - return ONLP_STATUS_OK; -} - -int -onlp_sfpi_is_rx_los(int port) -{ - /* rx los of QSFP-DD are not supported*/ - return ONLP_STATUS_E_UNSUPPORTED; -} - -int -onlp_sfpi_rx_los_bitmap_get(onlp_sfp_bitmap_t* dst) -{ - /* rx los of QSFP-DD are not supported*/ - return ONLP_STATUS_E_UNSUPPORTED; -} - -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; -} - -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 - */ - memset(data, 0, 256); - - VALIDATE_PORT(port); - int rv=ONLP_STATUS_OK; - int bus = FRONT_PORT_TO_MUX_INDEX(port); - int retry=RETRY_TIME; - int value; - int succeed=false; - int port_id=PORT_TO_PATH_ID(port); - - do { - rv=onlp_file_read_int(&value,INV_SFP_PREFIX"port%d/page_sel_lock",port_id); - if( (rv==ONLP_STATUS_OK)&&(value==SFP_PAGE_IDLE) ){ - rv=onlp_file_write_int(SFP_PAGE_LOCKED,INV_SFP_PREFIX"port%d/page_sel_lock",port_id); - succeed=true; - break; - } else { - retry--; - AIM_LOG_ERROR("Eeprom of port(%d) is locked, retry to read again\r\n", port_id); - sleep(SLEEP_TIME); - } - } while(retry>0); - - if( succeed&&(rv==ONLP_STATUS_OK) ) { - rv=onlp_file_write_int(0,INV_SFP_PREFIX"port%d/page",port_id); - if(rv==ONLP_STATUS_OK) { - rv = onlp_i2c_block_read(bus, QSFP_DEV_ADDR, 0, 256, data, ONLP_I2C_F_FORCE); - } else { - AIM_LOG_ERROR("Unable to switch page from port(%d)\r\n", port_id); - } - if(rv!=ONLP_STATUS_OK) { - AIM_LOG_ERROR("Unable to read eeprom from port(%d)\r\n", port_id); - } - if( onlp_file_write_int(SFP_PAGE_IDLE,INV_SFP_PREFIX"port%d/page_sel_lock",port_id)<0 ) { - AIM_LOG_ERROR("Unable to relase eeprom from port(%d), please double check!\r\n", port_id); - } - } - return rv; -} - -int -onlp_sfpi_dev_readb(int port, uint8_t devaddr, uint8_t addr) -{ - VALIDATE_PORT(port); - 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) -{ - VALIDATE_PORT(port); - 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) -{ - VALIDATE_PORT(port); - 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) -{ - VALIDATE_PORT(port); - int bus = FRONT_PORT_TO_MUX_INDEX(port); - return onlp_i2c_writew(bus, devaddr, addr, value, ONLP_I2C_F_FORCE); -} - -int -onlp_sfpi_control_supported(int port, onlp_sfp_control_t control, int* rv) -{ - *rv = 0; - if(port >= 0 && port < NUM_OF_QSFP_DD_PORT) { - switch (control) { - case ONLP_SFP_CONTROL_RESET_STATE: - case ONLP_SFP_CONTROL_LP_MODE: - *rv = 1; - break; - default: - break; - } - } - return ONLP_STATUS_OK; -} - -int -onlp_sfpi_control_set(int port, onlp_sfp_control_t control, int value) -{ - int ret = ONLP_STATUS_E_UNSUPPORTED; - int port_id=PORT_TO_PATH_ID(port); - - if(port >= 0 && port < NUM_OF_QSFP_DD_PORT) { - switch (control) { - case ONLP_SFP_CONTROL_RESET_STATE: - ret = onlp_file_write_int(value, INV_SFP_PREFIX"port%d/reset", port_id); - break; - case ONLP_SFP_CONTROL_LP_MODE: - ret = onlp_file_write_int(value, INV_SFP_PREFIX"port%d/lpmod", port_id); - break; - default: - break; - } - } - return ret; -} - -int -onlp_sfpi_control_get(int port, onlp_sfp_control_t control, int* value) -{ - int ret = ONLP_STATUS_E_UNSUPPORTED; - int port_id = PORT_TO_PATH_ID(port); - - if(port >= 0 && port < NUM_OF_QSFP_DD_PORT) { - switch (control) { - /*the value of /port(id)/reset - 0: in reset state; 1:not in reset state*/ - case ONLP_SFP_CONTROL_RESET_STATE: - ret = onlp_file_read_int(value, INV_SFP_PREFIX"port%d/reset", port_id); - *value=(!(*value)); - break; - case ONLP_SFP_CONTROL_LP_MODE: - ret = onlp_file_read_int(value, INV_SFP_PREFIX"port%d/lpmode", port_id); - break; - default: - break; - } - } - return ret; -} - -int -onlp_sfpi_denit(void) -{ - return ONLP_STATUS_OK; -} - -void -onlp_sfpi_debug(int port, aim_pvs_t* pvs) -{ - aim_printf(pvs, "Debug data for port %d goes here.", port); -} - -int -onlp_sfpi_ioctl(int port, va_list vargs) -{ - return ONLP_STATUS_E_UNSUPPORTED; -} diff --git a/packages/platforms/inventec/x86-64/d7332/onlp/builds/x86_64_inventec_d7332/module/src/sysi.c b/packages/platforms/inventec/x86-64/d7332/onlp/builds/x86_64_inventec_d7332/module/src/sysi.c deleted file mode 100644 index 23d16d7ba..000000000 --- a/packages/platforms/inventec/x86-64/d7332/onlp/builds/x86_64_inventec_d7332/module/src/sysi.c +++ /dev/null @@ -1,262 +0,0 @@ -/************************************************************ - * sysi.c - * - * Copyright 2018 Inventec Technology Corporation. - * - ************************************************************ - * - ***********************************************************/ -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "x86_64_inventec_d7332_int.h" -#include "x86_64_inventec_d7332_log.h" - -#include "platform_lib.h" - -static onlp_oid_t __oid_info[] = { - ONLP_THERMAL_ID_CREATE(ONLP_THERMAL_CPU_PHY), - ONLP_THERMAL_ID_CREATE(ONLP_THERMAL_CPU_CORE0), - ONLP_THERMAL_ID_CREATE(ONLP_THERMAL_CPU_CORE1), - ONLP_THERMAL_ID_CREATE(ONLP_THERMAL_CPU_CORE2), - ONLP_THERMAL_ID_CREATE(ONLP_THERMAL_CPU_CORE3), - ONLP_THERMAL_ID_CREATE(ONLP_THERMAL_1_ON_MAIN_BROAD), - ONLP_THERMAL_ID_CREATE(ONLP_THERMAL_2_ON_MAIN_BROAD), - ONLP_THERMAL_ID_CREATE(ONLP_THERMAL_3_ON_MAIN_BROAD), - ONLP_THERMAL_ID_CREATE(ONLP_THERMAL_4_ON_MAIN_BROAD), - ONLP_THERMAL_ID_CREATE(ONLP_THERMAL_5_ON_MAIN_BROAD), - ONLP_THERMAL_ID_CREATE(ONLP_THERMAL_6_ON_MAIN_BROAD), - ONLP_THERMAL_ID_CREATE(ONLP_THERMAL_7_ON_MAIN_BROAD), - ONLP_FAN_ID_CREATE(ONLP_FAN_1), - ONLP_FAN_ID_CREATE(ONLP_FAN_2), - ONLP_FAN_ID_CREATE(ONLP_FAN_3), - ONLP_FAN_ID_CREATE(ONLP_FAN_4), - ONLP_FAN_ID_CREATE(ONLP_FAN_5), - ONLP_FAN_ID_CREATE(ONLP_FAN_6), - ONLP_FAN_ID_CREATE(ONLP_FAN_7), - ONLP_FAN_ID_CREATE(ONLP_FAN_8), - ONLP_FAN_ID_CREATE(ONLP_FAN_9), - ONLP_FAN_ID_CREATE(ONLP_FAN_10), - ONLP_FAN_ID_CREATE(ONLP_FAN_11), - ONLP_FAN_ID_CREATE(ONLP_FAN_12), - ONLP_PSU_ID_CREATE(ONLP_PSU_1), - ONLP_PSU_ID_CREATE(ONLP_PSU_2), - ONLP_LED_ID_CREATE(ONLP_LED_MGMT), - ONLP_LED_ID_CREATE(ONLP_LED_FAN1), - ONLP_LED_ID_CREATE(ONLP_LED_FAN2), - ONLP_LED_ID_CREATE(ONLP_LED_FAN3), - ONLP_LED_ID_CREATE(ONLP_LED_FAN4), - ONLP_LED_ID_CREATE(ONLP_LED_FAN5), - ONLP_LED_ID_CREATE(ONLP_LED_FAN6), - 0/*end*/ -}; - -static int _sysi_version_parsing(char* file_str, char* str_buf, char* version); - -static int _sysi_version_parsing(char* file_str, char* str_buf, char* version) -{ - int rv = ONLP_STATUS_OK; - int len; - char buf[ONLP_CONFIG_INFO_STR_MAX * 4]; - char *temp; - char cpld_v1[ONLP_CONFIG_INFO_STR_MAX]; - char cpld_v2[ONLP_CONFIG_INFO_STR_MAX]; - - rv = onlp_file_read((uint8_t*)buf, ONLP_CONFIG_INFO_STR_MAX * 4, &len, file_str); - if ( rv != ONLP_STATUS_OK ) { - return rv; - } - temp = strstr(buf, str_buf); - if (temp) { - temp += strlen(str_buf); - sscanf(temp, "%s", cpld_v1); - } else { - return ONLP_STATUS_E_INVALID; - } - temp = strstr(temp, str_buf); - if (temp) { - temp += strlen(str_buf); - sscanf(temp, "%s", cpld_v2); - } else { - return ONLP_STATUS_E_INVALID; - } - snprintf(version, ONLP_CONFIG_INFO_STR_MAX, "c1_%s c2_%s", cpld_v1, cpld_v2); - - return rv; -} - -const char* -onlp_sysi_platform_get(void) -{ - return "x86-64-inventec-d7332-r0"; -} - - -/* - * This function is called to return the physical base address - * of the ONIE boot rom. - * - * The ONLP framework will mmap() and parse the ONIE TLV structure - * from the given data. - * - * If you platform does not support a mappable address for the ONIE - * eeprom then you should not provide this function at all. - * - * For the purposes of this example we will provide it but - * return UNSUPPORTED (which is all the default implementation does). - * - */ -int -onlp_sysi_onie_data_phys_addr_get(void** pa) -{ - return ONLP_STATUS_E_UNSUPPORTED; -} - - -/* - * If you cannot provide a base address you must provide the ONLP - * framework the raw ONIE data through whatever means necessary. - * - * This function will be called as a backup in the event that - * onlp_sysi_onie_data_phys_addr_get() fails. - */ -int -onlp_sysi_onie_data_get(uint8_t** data, int* size) -{ - int ret=ONLP_STATUS_E_INVALID; - int eeprom_size; - int rv; - uint8_t* eeprom_data; - - FILE* fp = fopen(INV_EEPROM_PATH, "rb"); - - if(fp) { - fseek(fp, 0L, SEEK_END); - eeprom_size = ftell(fp); - rewind(fp); - eeprom_data = aim_malloc(eeprom_size); - - rv = fread(eeprom_data, 1, eeprom_size, fp); - fclose(fp); - - if(rv == eeprom_size) { - ret=ONLP_STATUS_OK; - *data=eeprom_data; - *size=eeprom_size; - } - - } - - - return ret; -} - -/* - * IF the ONLP frame calles onlp_sysi_onie_data_get(), - * if will call this function to free the data when it - * is finished with it. - * - * This function is optional, and depends on the data - * you return in onlp_sysi_onie_data_get(). - */ -void -onlp_sysi_onie_data_free(uint8_t* data) -{ - /* - * We returned a static array in onlp_sysi_onie_data_get() - * so no free operation is required. - */ - if (data) { - aim_free(data); - } -} - - -int -onlp_sysi_onie_info_get (onlp_onie_info_t *onie) -{ - int rv = ONLP_STATUS_OK; - - rv = onlp_onie_decode_file(onie, INV_EEPROM_PATH); - - onie->_hdr_id_string = aim_fstrdup("TlvInfo"); - onie->_hdr_version = 0x1; - return rv; -} - - -int -onlp_sysi_platform_info_get(onlp_platform_info_t* pi) -{ - int rv = ONLP_STATUS_OK; - char cpld_str[ONLP_CONFIG_INFO_STR_MAX] = {0}; - char version[ONLP_CONFIG_INFO_STR_MAX]; - pi->cpld_versions = NULL; - - rv = _sysi_version_parsing( INV_INFO_PREFIX"info", "The CPLD version is ", version); - if ( rv != ONLP_STATUS_OK ) { - return rv; - } - snprintf(cpld_str, ONLP_CONFIG_INFO_STR_MAX, "%s%s ", cpld_str, version); - /*cpld version*/ - if (strlen(cpld_str) > 0) { - pi->cpld_versions = aim_fstrdup("%s", cpld_str); - } - return rv; -} - -void -onlp_sysi_platform_info_free(onlp_platform_info_t* pi) -{ - if (pi->cpld_versions) { - aim_free(pi->cpld_versions); - } - if (pi->other_versions) { - aim_free(pi->other_versions); - } - return; -} - - -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 = 0; i < max; i++) { - if (__oid_info[i] == 0) { - break; - } - *e++ = __oid_info[i]; - } - return ONLP_STATUS_OK; -} - -int -onlp_sysi_platform_manage_fans(void) -{ - /*Ensure switch manager is working*/ - PLATFORM_HWMON_DIAG_LOCK; - return ONLP_STATUS_OK; -} - -int -onlp_sysi_platform_manage_leds(void) -{ - /*Ensure switch manager is working*/ - PLATFORM_HWMON_DIAG_LOCK; - return ONLP_STATUS_OK; -} - diff --git a/packages/platforms/inventec/x86-64/d7332/onlp/builds/x86_64_inventec_d7332/module/src/thermali.c b/packages/platforms/inventec/x86-64/d7332/onlp/builds/x86_64_inventec_d7332/module/src/thermali.c deleted file mode 100644 index 4d0e6c74a..000000000 --- a/packages/platforms/inventec/x86-64/d7332/onlp/builds/x86_64_inventec_d7332/module/src/thermali.c +++ /dev/null @@ -1,212 +0,0 @@ -/************************************************************ - * thermali.c - * - * Copyright 2018 Inventec Technology Corporation. - * - ************************************************************ - * - * 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) - - -typedef struct thermali_path_s { - char file[ONLP_CONFIG_INFO_STR_MAX]; -} thermali_path_t; - -#define MAKE_THERMAL_PATH_ON_CPU(id) { "/var/coretemp/temp"#id"_input"} -#define MAKE_THERMAL_PATH_ON_MAIN_BROAD(thermal_id,attr_idx) { "/var/board_thermal_"#thermal_id"/temp"#attr_idx"_input"} -#define MAKE_THERMAL_PATH_ON_PSU(psu_id,thermal_id) { "/var/psu"#psu_id"/device/temp"#thermal_id"_input"} - -static thermali_path_t __path_list[ ] = { - {}, - MAKE_THERMAL_PATH_ON_CPU(1), - MAKE_THERMAL_PATH_ON_CPU(2), - MAKE_THERMAL_PATH_ON_CPU(3), - MAKE_THERMAL_PATH_ON_CPU(4), - MAKE_THERMAL_PATH_ON_CPU(5), - MAKE_THERMAL_PATH_ON_MAIN_BROAD(1,1), - MAKE_THERMAL_PATH_ON_MAIN_BROAD(1,2), - MAKE_THERMAL_PATH_ON_MAIN_BROAD(2,1), - MAKE_THERMAL_PATH_ON_MAIN_BROAD(3,1), - MAKE_THERMAL_PATH_ON_MAIN_BROAD(4,1), - MAKE_THERMAL_PATH_ON_MAIN_BROAD(5,1), - MAKE_THERMAL_PATH_ON_MAIN_BROAD(6,1), - MAKE_THERMAL_PATH_ON_PSU(1,1), - MAKE_THERMAL_PATH_ON_PSU(1,2), - MAKE_THERMAL_PATH_ON_PSU(1,3), - MAKE_THERMAL_PATH_ON_PSU(2,1), - MAKE_THERMAL_PATH_ON_PSU(2,2), - MAKE_THERMAL_PATH_ON_PSU(2,3) -}; - -#define MAKE_THERMAL_INFO_NODE_ON_CPU_PHY \ - { { ONLP_THERMAL_ID_CREATE(ONLP_THERMAL_CPU_PHY), "CPU Physical", 0}, \ - ONLP_THERMAL_STATUS_PRESENT, \ - ONLP_THERMAL_CAPS_GET_TEMPERATURE, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS \ - } -#define MAKE_THERMAL_INFO_NODE_ON_CPU_CORE(id) \ - { { ONLP_THERMAL_ID_CREATE(ONLP_THERMAL_CPU_CORE##id), "CPU Core "#id, 0},\ - ONLP_THERMAL_STATUS_PRESENT, \ - ONLP_THERMAL_CAPS_GET_TEMPERATURE, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS \ - } -#define MAKE_THERMAL_INFO_NODE_ON_BROADS(id) \ - { { ONLP_THERMAL_ID_CREATE(ONLP_THERMAL_##id##_ON_MAIN_BROAD), "Thermal Sensor "#id, 0}, \ - ONLP_THERMAL_STATUS_PRESENT, \ - ONLP_THERMAL_CAPS_GET_TEMPERATURE, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS \ - } -#define MAKE_THERMAL_INFO_NODE_ON_PSU(thermal_id, psu_id) \ - { { \ - ONLP_THERMAL_ID_CREATE(ONLP_THERMAL_##thermal_id##_ON_PSU##psu_id), \ - "PSU-"#psu_id" Thermal Sensor "#thermal_id, \ - ONLP_PSU_ID_CREATE(ONLP_PSU_##psu_id) \ - }, \ - ONLP_THERMAL_STATUS_PRESENT, \ - ONLP_THERMAL_CAPS_GET_TEMPERATURE, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS \ - } - -/* Static values */ -static onlp_thermal_info_t __onlp_thermal_info[ ] = { - {}, - MAKE_THERMAL_INFO_NODE_ON_CPU_PHY, - MAKE_THERMAL_INFO_NODE_ON_CPU_CORE(0), - MAKE_THERMAL_INFO_NODE_ON_CPU_CORE(1), - MAKE_THERMAL_INFO_NODE_ON_CPU_CORE(2), - MAKE_THERMAL_INFO_NODE_ON_CPU_CORE(3), - MAKE_THERMAL_INFO_NODE_ON_BROADS(1), - MAKE_THERMAL_INFO_NODE_ON_BROADS(2), - MAKE_THERMAL_INFO_NODE_ON_BROADS(3), - MAKE_THERMAL_INFO_NODE_ON_BROADS(4), - MAKE_THERMAL_INFO_NODE_ON_BROADS(5), - MAKE_THERMAL_INFO_NODE_ON_BROADS(6), - MAKE_THERMAL_INFO_NODE_ON_BROADS(7), - MAKE_THERMAL_INFO_NODE_ON_PSU(1,1), - MAKE_THERMAL_INFO_NODE_ON_PSU(2,1), - MAKE_THERMAL_INFO_NODE_ON_PSU(3,1), - MAKE_THERMAL_INFO_NODE_ON_PSU(1,2), - MAKE_THERMAL_INFO_NODE_ON_PSU(2,2), - MAKE_THERMAL_INFO_NODE_ON_PSU(3,2), -}; - -/* - * 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) -{ - VALIDATE(id); - int ret; - int thermal_id = ONLP_OID_ID_GET(id); - if(thermal_id >= ONLP_THERMAL_MAX) { - return ONLP_STATUS_E_INVALID; - } - - /* Set the onlp_oid_hdr_t and capabilities */ - *info = __onlp_thermal_info[ thermal_id]; - ret = onlp_thermali_status_get(id, &info->status); - if( ret != ONLP_STATUS_OK ) { - return ret; - } - if(info->status & ONLP_THERMAL_STATUS_PRESENT) { - ret = onlp_file_read_int(&info->mcelsius, __path_list[thermal_id].file ); - } - - return ret; -} - -/** - * @brief Retrieve the thermal's operational status. - * @param id The thermal oid. - * @param rv [out] Receives the operational status. - */ -int onlp_thermali_status_get(onlp_oid_t id, uint32_t* rv) -{ - int ret = ONLP_STATUS_OK; - onlp_thermal_info_t* info; - VALIDATE(id); - uint32_t psu_status; - - int thermal_id = ONLP_OID_ID_GET(id); - if(thermal_id >= ONLP_THERMAL_MAX) { - return ONLP_STATUS_E_INVALID; - } - info = &__onlp_thermal_info[ thermal_id]; - - switch(thermal_id) { - case ONLP_THERMAL_1_ON_PSU1: - case ONLP_THERMAL_2_ON_PSU1: - case ONLP_THERMAL_3_ON_PSU1: - case ONLP_THERMAL_1_ON_PSU2: - case ONLP_THERMAL_2_ON_PSU2: - case ONLP_THERMAL_3_ON_PSU2: - ret = onlp_psui_status_get((&info->hdr)->poid, &psu_status); - if(ret != ONLP_STATUS_OK) { - return ret; - } - if(psu_status & ONLP_PSU_STATUS_PRESENT) { - info->status = ADD_STATE(info->status,ONLP_PSU_STATUS_PRESENT); - } else { - info->status = 0; - } - break; - default: - break; - } - - *rv = info->status; - - return ret; -} - -/** - * @brief Retrieve the thermal's oid header. - * @param id The thermal oid. - * @param rv [out] Receives the header. - */ -int onlp_thermali_hdr_get(onlp_oid_t id, onlp_oid_hdr_t* rv) -{ - onlp_thermal_info_t* info; - VALIDATE(id); - - int thermal_id = ONLP_OID_ID_GET(id); - if(thermal_id >= ONLP_THERMAL_MAX) { - return ONLP_STATUS_E_INVALID; - } - info = &__onlp_thermal_info[ thermal_id]; - - *rv = info->hdr; - - return ONLP_STATUS_OK; -} diff --git a/packages/platforms/inventec/x86-64/d7332/onlp/builds/x86_64_inventec_d7332/module/src/x86_64_inventec_d7332_config.c b/packages/platforms/inventec/x86-64/d7332/onlp/builds/x86_64_inventec_d7332/module/src/x86_64_inventec_d7332_config.c deleted file mode 100644 index 9c6231630..000000000 --- a/packages/platforms/inventec/x86-64/d7332/onlp/builds/x86_64_inventec_d7332/module/src/x86_64_inventec_d7332_config.c +++ /dev/null @@ -1,81 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#include - -/* */ -#define __x86_64_inventec_d7332_config_STRINGIFY_NAME(_x) #_x -#define __x86_64_inventec_d7332_config_STRINGIFY_VALUE(_x) __x86_64_inventec_d7332_config_STRINGIFY_NAME(_x) -x86_64_inventec_d7332_config_settings_t x86_64_inventec_d7332_config_settings[] = -{ -#ifdef x86_64_inventec_d7332_CONFIG_INCLUDE_LOGGING - { __x86_64_inventec_d7332_config_STRINGIFY_NAME(x86_64_inventec_d7332_CONFIG_INCLUDE_LOGGING), __x86_64_inventec_d7332_config_STRINGIFY_VALUE(x86_64_inventec_d7332_CONFIG_INCLUDE_LOGGING) }, -#else -{ x86_64_inventec_d7332_CONFIG_INCLUDE_LOGGING(__x86_64_inventec_d7332_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef x86_64_inventec_d7332_CONFIG_LOG_OPTIONS_DEFAULT - { __x86_64_inventec_d7332_config_STRINGIFY_NAME(x86_64_inventec_d7332_CONFIG_LOG_OPTIONS_DEFAULT), __x86_64_inventec_d7332_config_STRINGIFY_VALUE(x86_64_inventec_d7332_CONFIG_LOG_OPTIONS_DEFAULT) }, -#else -{ x86_64_inventec_d7332_CONFIG_LOG_OPTIONS_DEFAULT(__x86_64_inventec_d7332_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef x86_64_inventec_d7332_CONFIG_LOG_BITS_DEFAULT - { __x86_64_inventec_d7332_config_STRINGIFY_NAME(x86_64_inventec_d7332_CONFIG_LOG_BITS_DEFAULT), __x86_64_inventec_d7332_config_STRINGIFY_VALUE(x86_64_inventec_d7332_CONFIG_LOG_BITS_DEFAULT) }, -#else -{ x86_64_inventec_d7332_CONFIG_LOG_BITS_DEFAULT(__x86_64_inventec_d7332_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef x86_64_inventec_d7332_CONFIG_LOG_CUSTOM_BITS_DEFAULT - { __x86_64_inventec_d7332_config_STRINGIFY_NAME(x86_64_inventec_d7332_CONFIG_LOG_CUSTOM_BITS_DEFAULT), __x86_64_inventec_d7332_config_STRINGIFY_VALUE(x86_64_inventec_d7332_CONFIG_LOG_CUSTOM_BITS_DEFAULT) }, -#else -{ x86_64_inventec_d7332_CONFIG_LOG_CUSTOM_BITS_DEFAULT(__x86_64_inventec_d7332_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef x86_64_inventec_d7332_CONFIG_PORTING_STDLIB - { __x86_64_inventec_d7332_config_STRINGIFY_NAME(x86_64_inventec_d7332_CONFIG_PORTING_STDLIB), __x86_64_inventec_d7332_config_STRINGIFY_VALUE(x86_64_inventec_d7332_CONFIG_PORTING_STDLIB) }, -#else -{ x86_64_inventec_d7332_CONFIG_PORTING_STDLIB(__x86_64_inventec_d7332_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef x86_64_inventec_d7332_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS - { __x86_64_inventec_d7332_config_STRINGIFY_NAME(x86_64_inventec_d7332_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS), __x86_64_inventec_d7332_config_STRINGIFY_VALUE(x86_64_inventec_d7332_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS) }, -#else -{ x86_64_inventec_d7332_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS(__x86_64_inventec_d7332_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef x86_64_inventec_d7332_CONFIG_INCLUDE_UCLI - { __x86_64_inventec_d7332_config_STRINGIFY_NAME(x86_64_inventec_d7332_CONFIG_INCLUDE_UCLI), __x86_64_inventec_d7332_config_STRINGIFY_VALUE(x86_64_inventec_d7332_CONFIG_INCLUDE_UCLI) }, -#else -{ x86_64_inventec_d7332_CONFIG_INCLUDE_UCLI(__x86_64_inventec_d7332_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef x86_64_inventec_d7332_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION - { __x86_64_inventec_d7332_config_STRINGIFY_NAME(x86_64_inventec_d7332_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION), __x86_64_inventec_d7332_config_STRINGIFY_VALUE(x86_64_inventec_d7332_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION) }, -#else -{ x86_64_inventec_d7332_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION(__x86_64_inventec_d7332_config_STRINGIFY_NAME), "__undefined__" }, -#endif - { NULL, NULL } -}; -#undef __x86_64_inventec_d7332_config_STRINGIFY_VALUE -#undef __x86_64_inventec_d7332_config_STRINGIFY_NAME - -const char* -x86_64_inventec_d7332_config_lookup(const char* setting) -{ - int i; - for(i = 0; x86_64_inventec_d7332_config_settings[i].name; i++) { - if(strcmp(x86_64_inventec_d7332_config_settings[i].name, setting)) { - return x86_64_inventec_d7332_config_settings[i].value; - } - } - return NULL; -} - -int -x86_64_inventec_d7332_config_show(struct aim_pvs_s* pvs) -{ - int i; - for(i = 0; x86_64_inventec_d7332_config_settings[i].name; i++) { - aim_printf(pvs, "%s = %s\n", x86_64_inventec_d7332_config_settings[i].name, x86_64_inventec_d7332_config_settings[i].value); - } - return i; -} - -/* */ - diff --git a/packages/platforms/inventec/x86-64/d7332/onlp/builds/x86_64_inventec_d7332/module/src/x86_64_inventec_d7332_enums.c b/packages/platforms/inventec/x86-64/d7332/onlp/builds/x86_64_inventec_d7332/module/src/x86_64_inventec_d7332_enums.c deleted file mode 100644 index d526e84f9..000000000 --- a/packages/platforms/inventec/x86-64/d7332/onlp/builds/x86_64_inventec_d7332/module/src/x86_64_inventec_d7332_enums.c +++ /dev/null @@ -1,10 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#include - -/* <--auto.start.enum(ALL).source> */ -/* */ - diff --git a/packages/platforms/inventec/x86-64/d7332/onlp/builds/x86_64_inventec_d7332/module/src/x86_64_inventec_d7332_int.h b/packages/platforms/inventec/x86-64/d7332/onlp/builds/x86_64_inventec_d7332/module/src/x86_64_inventec_d7332_int.h deleted file mode 100644 index 28755101b..000000000 --- a/packages/platforms/inventec/x86-64/d7332/onlp/builds/x86_64_inventec_d7332/module/src/x86_64_inventec_d7332_int.h +++ /dev/null @@ -1,12 +0,0 @@ -/**************************************************************************//** - * - * x86_64_inventec_d7332 Internal Header - * - *****************************************************************************/ -#ifndef __x86_64_inventec_d7332_INT_H__ -#define __x86_64_inventec_d7332_INT_H__ - -#include - - -#endif /* __x86_64_inventec_d7332_INT_H__ */ diff --git a/packages/platforms/inventec/x86-64/d7332/onlp/builds/x86_64_inventec_d7332/module/src/x86_64_inventec_d7332_log.c b/packages/platforms/inventec/x86-64/d7332/onlp/builds/x86_64_inventec_d7332/module/src/x86_64_inventec_d7332_log.c deleted file mode 100644 index 0f0e01338..000000000 --- a/packages/platforms/inventec/x86-64/d7332/onlp/builds/x86_64_inventec_d7332/module/src/x86_64_inventec_d7332_log.c +++ /dev/null @@ -1,18 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#include - -#include "x86_64_inventec_d7332_log.h" -/* - * x86_64_inventec_d7332 log struct. - */ -AIM_LOG_STRUCT_DEFINE( - x86_64_inventec_d7332_CONFIG_LOG_OPTIONS_DEFAULT, - x86_64_inventec_d7332_CONFIG_LOG_BITS_DEFAULT, - NULL, /* Custom log map */ - x86_64_inventec_d7332_CONFIG_LOG_CUSTOM_BITS_DEFAULT - ); - diff --git a/packages/platforms/inventec/x86-64/d7332/onlp/builds/x86_64_inventec_d7332/module/src/x86_64_inventec_d7332_log.h b/packages/platforms/inventec/x86-64/d7332/onlp/builds/x86_64_inventec_d7332/module/src/x86_64_inventec_d7332_log.h deleted file mode 100644 index c2891d77a..000000000 --- a/packages/platforms/inventec/x86-64/d7332/onlp/builds/x86_64_inventec_d7332/module/src/x86_64_inventec_d7332_log.h +++ /dev/null @@ -1,12 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#ifndef __x86_64_inventec_d7332_LOG_H__ -#define __x86_64_inventec_d7332_LOG_H__ - -#define AIM_LOG_MODULE_NAME x86_64_inventec_d7332 -#include - -#endif /* __x86_64_inventec_d7332_LOG_H__ */ diff --git a/packages/platforms/inventec/x86-64/d7332/onlp/builds/x86_64_inventec_d7332/module/src/x86_64_inventec_d7332_module.c b/packages/platforms/inventec/x86-64/d7332/onlp/builds/x86_64_inventec_d7332/module/src/x86_64_inventec_d7332_module.c deleted file mode 100644 index 0f554dbf0..000000000 --- a/packages/platforms/inventec/x86-64/d7332/onlp/builds/x86_64_inventec_d7332/module/src/x86_64_inventec_d7332_module.c +++ /dev/null @@ -1,25 +0,0 @@ - -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#include - -#include "x86_64_inventec_d7332_log.h" - -static int -datatypes_init__(void) -{ -#define x86_64_inventec_d7332_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_d7332_module_init__(void) -{ - AIM_LOG_STRUCT_REGISTER(); - datatypes_init__(); -} - -int __onlp_platform_version__ = 1; diff --git a/packages/platforms/inventec/x86-64/d7332/onlp/builds/x86_64_inventec_d7332/module/src/x86_64_inventec_d7332_ucli.c b/packages/platforms/inventec/x86-64/d7332/onlp/builds/x86_64_inventec_d7332/module/src/x86_64_inventec_d7332_ucli.c deleted file mode 100644 index 224c84fe1..000000000 --- a/packages/platforms/inventec/x86-64/d7332/onlp/builds/x86_64_inventec_d7332/module/src/x86_64_inventec_d7332_ucli.c +++ /dev/null @@ -1,50 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#include - -#if x86_64_inventec_d7332_CONFIG_INCLUDE_UCLI == 1 - -#include -#include -#include - -static ucli_status_t -x86_64_inventec_d7332_ucli_ucli__config__(ucli_context_t* uc) -{ - UCLI_HANDLER_MACRO_MODULE_CONFIG(x86_64_inventec_d7332) -} - -/* */ -/* */ - -static ucli_module_t -x86_64_inventec_d7332_ucli_module__ = - { - "x86_64_inventec_d7332_ucli", - NULL, - x86_64_inventec_d7332_ucli_ucli_handlers__, - NULL, - NULL, - }; - -ucli_node_t* -x86_64_inventec_d7332_ucli_node_create(void) -{ - ucli_node_t* n; - ucli_module_init(&x86_64_inventec_d7332_ucli_module__); - n = ucli_node_create("x86_64_inventec_d7332", NULL, &x86_64_inventec_d7332_ucli_module__); - ucli_node_subnode_add(n, ucli_module_log_node_create("x86_64_inventec_d7332")); - return n; -} - -#else -void* -x86_64_inventec_d7332_ucli_node_create(void) -{ - return NULL; -} -#endif - diff --git a/packages/platforms/inventec/x86-64/d7332/platform-config/Makefile b/packages/platforms/inventec/x86-64/d7332/platform-config/Makefile deleted file mode 100644 index 003238cf6..000000000 --- a/packages/platforms/inventec/x86-64/d7332/platform-config/Makefile +++ /dev/null @@ -1 +0,0 @@ -include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/inventec/x86-64/d7332/platform-config/r0/Makefile b/packages/platforms/inventec/x86-64/d7332/platform-config/r0/Makefile deleted file mode 100644 index 003238cf6..000000000 --- a/packages/platforms/inventec/x86-64/d7332/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/inventec/x86-64/d7332/platform-config/r0/PKG.yml b/packages/platforms/inventec/x86-64/d7332/platform-config/r0/PKG.yml deleted file mode 100644 index f965039ef..000000000 --- a/packages/platforms/inventec/x86-64/d7332/platform-config/r0/PKG.yml +++ /dev/null @@ -1 +0,0 @@ -!include $ONL_TEMPLATES/platform-config-platform.yml ARCH=amd64 VENDOR=inventec BASENAME=x86-64-inventec-d7332 REVISION=r0 diff --git a/packages/platforms/inventec/x86-64/d7332/platform-config/r0/src/lib/x86-64-inventec-d7332-r0.yml b/packages/platforms/inventec/x86-64/d7332/platform-config/r0/src/lib/x86-64-inventec-d7332-r0.yml deleted file mode 100644 index b3702ba9e..000000000 --- a/packages/platforms/inventec/x86-64/d7332/platform-config/r0/src/lib/x86-64-inventec-d7332-r0.yml +++ /dev/null @@ -1,31 +0,0 @@ ---- - -###################################################################### -# -# platform-config for d7332 -# -###################################################################### - -x86-64-inventec-d7332-r0: - - grub: - - serial: >- - --port=0x3f8 - --speed=115200 - --word=8 - --parity=no - --stop=1 - - kernel: - <<: *kernel-4-14 - - args: >- - nopat - console=ttyS0,115200n8 - - ##network - ## interfaces: - ## ma1: - ## name: ~ - ## syspath: pci0000:00/0000:00:14.0 diff --git a/packages/platforms/inventec/x86-64/d7332/platform-config/r0/src/python/x86_64_inventec_d7332_r0/__init__.py b/packages/platforms/inventec/x86-64/d7332/platform-config/r0/src/python/x86_64_inventec_d7332_r0/__init__.py deleted file mode 100644 index 99bb8c9c7..000000000 --- a/packages/platforms/inventec/x86-64/d7332/platform-config/r0/src/python/x86_64_inventec_d7332_r0/__init__.py +++ /dev/null @@ -1,80 +0,0 @@ -from onl.platform.base import * -from onl.platform.inventec import * -import logging - -class OnlPlatform_x86_64_inventec_d7332_r0(OnlPlatformInventec, - OnlPlatformPortConfig_32x400): - PLATFORM='x86-64-inventec-d7332-r0' - MODEL="D7332" - SYS_OBJECT_ID=".7332.1" - CHASSIS_FAN_NUM=6 - FAN_VPD_CHANNEL=3 - FAN_VPD_ADDR_BASE=0x52 - - _path_prefix_list=[ - "/sys/bus/i2c/devices/2-0058/hwmon/", - "/sys/bus/i2c/devices/2-0059/hwmon/", - "/sys/devices/platform/coretemp.0/hwmon/", - "/sys/bus/i2c/devices/3-0018/hwmon/", - "/sys/bus/i2c/devices/3-0048/hwmon/", - "/sys/bus/i2c/devices/3-0049/hwmon/", - "/sys/bus/i2c/devices/3-004a/hwmon/", - "/sys/bus/i2c/devices/3-004d/hwmon/", - "/sys/bus/i2c/devices/3-004e/hwmon/" - ] - _path_dst_list=[ - "/var/psu1", - "/var/psu2", - "/var/coretemp", - "/var/board_thermal_1", - "/var/board_thermal_2", - "/var/board_thermal_3", - "/var/board_thermal_4", - "/var/board_thermal_5", - "/var/board_thermal_6", - ] - - def baseconfig(self): - os.system("insmod /lib/modules/`uname -r`/kernel/drivers/gpio/gpio-ich.ko gpiobase=0") - self.insmod('i2c-gpio') - self.insmod('inv_ucd90160') - self.insmod('inv-i2c-mux-pca9641') - self.insmod('inv_psu') - self.insmod('inv_cpld') - self.insmod('inv_platform') - self.insmod('inv_eeprom') - self.new_i2c_device('inv_eeprom', 0x55, 2) - - for addr_offset in range(0,self.CHASSIS_FAN_NUM): - self.new_i2c_device('inv_eeprom',self.FAN_VPD_ADDR_BASE+addr_offset,self.FAN_VPD_CHANNEL) - - self.insmod('inv_sff') - self.insmod('vpd') - - self.insmod('optoe') - for ch in range(0,32): - self.new_i2c_device('optoe1', 0x50, 14 + ch ) - - for i in range(0,len(self._path_prefix_list)): - if( os.path.islink(self._path_dst_list[i]) ): - os.unlink(self._path_dst_list[i]) - logging.warning("Path %s exists, remove before link again" % self._path_dst_list[i] ) - self.link_dir(self._path_prefix_list[i],self._path_dst_list[i]) - - return True - - def link_dir(self,prefix,dst): - ret=os.path.isdir(prefix) - if ret==True: - dirs=os.listdir(prefix) - ret=False - for i in range(0,len(dirs)): - if 'hwmon' in dirs[i]: - src=prefix+dirs[i] - os.symlink(src,dst) - ret=True - break - if ret==False: - logging.warning("Can't find proper dir to link under %s" % prefix) - else: - logging.warning("Path %s is not a dir" % prefix) \ No newline at end of file diff --git a/packages/platforms/inventec/x86-64/modules/Makefile b/packages/platforms/inventec/x86-64/modules/Makefile deleted file mode 100644 index 003238cf6..000000000 --- a/packages/platforms/inventec/x86-64/modules/Makefile +++ /dev/null @@ -1 +0,0 @@ -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 deleted file mode 100644 index ac147153b..000000000 --- a/packages/platforms/inventec/x86-64/modules/PKG.yml +++ /dev/null @@ -1 +0,0 @@ -!include $ONL_TEMPLATES/arch-vendor-modules.yml ARCH=amd64 VENDOR=inventec KERNELS="onl-kernel-3.16-lts-x86-64-all:amd64" diff --git a/packages/platforms/inventec/x86-64/modules/builds/.gitignore b/packages/platforms/inventec/x86-64/modules/builds/.gitignore deleted file mode 100644 index a65b41774..000000000 --- a/packages/platforms/inventec/x86-64/modules/builds/.gitignore +++ /dev/null @@ -1 +0,0 @@ -lib diff --git a/packages/platforms/inventec/x86-64/modules/builds/Makefile b/packages/platforms/inventec/x86-64/modules/builds/Makefile deleted file mode 100644 index ef8762fdd..000000000 --- a/packages/platforms/inventec/x86-64/modules/builds/Makefile +++ /dev/null @@ -1,6 +0,0 @@ -KERNELS := onl-kernel-3.16-lts-x86-64-all:amd64 -KMODULES := src -VENDOR := inventec -BASENAME := common -ARCH := x86_64 -include $(ONL)/make/kmodule.mk diff --git a/packages/platforms/inventec/x86-64/modules/builds/src/Makefile b/packages/platforms/inventec/x86-64/modules/builds/src/Makefile deleted file mode 100644 index 63b9ea343..000000000 --- a/packages/platforms/inventec/x86-64/modules/builds/src/Makefile +++ /dev/null @@ -1 +0,0 @@ -obj-m += inv_eeprom.o diff --git a/packages/platforms/inventec/x86-64/modules/builds/src/inv_eeprom.c b/packages/platforms/inventec/x86-64/modules/builds/src/inv_eeprom.c deleted file mode 100644 index f03c3cb16..000000000 --- a/packages/platforms/inventec/x86-64/modules/builds/src/inv_eeprom.c +++ /dev/null @@ -1,193 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include - -/* Addresses to scan */ -static const unsigned short normal_i2c[] = { 0x53, I2C_CLIENT_END }; - -/* Size of EEPROM in bytes */ -#define EEPROM_SIZE 256 - -#define SLICE_BITS (6) -#define SLICE_SIZE (1 << SLICE_BITS) -#define SLICE_NUM (EEPROM_SIZE/SLICE_SIZE) - -/* Each client has this additional data */ -struct eeprom_data { - struct mutex update_lock; - u8 valid; /* bitfield, bit!=0 if slice is valid */ - unsigned long last_updated[SLICE_NUM]; /* In jiffies, 8 slices */ - u8 data[EEPROM_SIZE]; /* Register values */ -}; - - -static void inv_eeprom_update_client(struct i2c_client *client, u8 slice) -{ - struct eeprom_data *data = i2c_get_clientdata(client); - int i, j; - int ret; - int addr; - - mutex_lock(&data->update_lock); - - if (!(data->valid & (1 << slice)) || - time_after(jiffies, data->last_updated[slice] + 300 * HZ)) { - dev_dbg(&client->dev, "Starting eeprom update, slice %u\n", slice); - - addr = slice << SLICE_BITS; - - ret = i2c_smbus_write_byte_data(client, ((u8)addr >> 8) & 0xFF, (u8)addr & 0xFF); - /* select the eeprom address */ - if (ret < 0) { - dev_err(&client->dev, "address set failed\n"); - goto exit; - } - - if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_READ_BYTE)) { - goto exit; - } - - for (i = slice << SLICE_BITS; i < (slice + 1) << SLICE_BITS; i+= SLICE_SIZE) { - for (j = i; j < (i+SLICE_SIZE); j++) { - int res; - - res = i2c_smbus_read_byte(client); - if (res < 0) { - goto exit; - } - - data->data[j] = res & 0xFF; - } - } - - data->last_updated[slice] = jiffies; - data->valid |= (1 << slice); - } -exit: - mutex_unlock(&data->update_lock); -} - -static ssize_t inv_eeprom_read(struct file *filp, struct kobject *kobj, - struct bin_attribute *bin_attr, - char *buf, loff_t off, size_t count) -{ - struct i2c_client *client = to_i2c_client(container_of(kobj, struct device, kobj)); - struct eeprom_data *data = i2c_get_clientdata(client); - u8 slice; - - if (off > EEPROM_SIZE) { - return 0; - } - if (off + count > EEPROM_SIZE) { - count = EEPROM_SIZE - off; - } - if (count == 0) { - return 0; - } - - /* Only refresh slices which contain requested bytes */ - for (slice = off >> SLICE_BITS; slice <= (off + count - 1) >> SLICE_BITS; slice++) { - inv_eeprom_update_client(client, slice); - } - - memcpy(buf, &data->data[off], count); - - return count; -} - -static struct bin_attribute inv_eeprom_attr = { - .attr = { - .name = "eeprom", - .mode = S_IRUGO, - }, - .size = EEPROM_SIZE, - .read = inv_eeprom_read, -}; - -/* Return 0 if detection is successful, -ENODEV otherwise */ -static int inv_eeprom_detect(struct i2c_client *client, struct i2c_board_info *info) -{ - struct i2c_adapter *adapter = client->adapter; - - /* EDID EEPROMs are often 24C00 EEPROMs, which answer to all - addresses 0x50-0x57, but we only care about 0x50. So decline - attaching to addresses >= 0x51 on DDC buses */ - if (!(adapter->class & I2C_CLASS_SPD) && client->addr != 0x53) { - return -ENODEV; - } - - if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_READ_BYTE) - && !i2c_check_functionality(adapter, I2C_FUNC_SMBUS_WRITE_BYTE_DATA)) { - return -ENODEV; - } - - strlcpy(info->type, "eeprom", I2C_NAME_SIZE); - - return 0; -} - -static int inv_eeprom_probe(struct i2c_client *client, - const struct i2c_device_id *id) -{ - struct eeprom_data *data; - int err; - - if (!(data = kzalloc(sizeof(struct eeprom_data), GFP_KERNEL))) { - err = -ENOMEM; - goto exit; - } - - memset(data->data, 0xff, EEPROM_SIZE); - i2c_set_clientdata(client, data); - mutex_init(&data->update_lock); - - /* create the sysfs eeprom file */ - err = sysfs_create_bin_file(&client->dev.kobj, &inv_eeprom_attr); - if (err) { - goto exit_kfree; - } - - return 0; - -exit_kfree: - kfree(data); -exit: - return err; -} - -static int inv_eeprom_remove(struct i2c_client *client) -{ - sysfs_remove_bin_file(&client->dev.kobj, &inv_eeprom_attr); - kfree(i2c_get_clientdata(client)); - - return 0; -} - -static const struct i2c_device_id inv_eeprom_id[] = { - { "inv_eeprom", 0 }, - { } -}; - -static struct i2c_driver inv_eeprom_driver = { - .driver = { - .name = "inv_eeprom", - }, - .probe = inv_eeprom_probe, - .remove = inv_eeprom_remove, - .id_table = inv_eeprom_id, - - .class = I2C_CLASS_DDC | I2C_CLASS_SPD, - .detect = inv_eeprom_detect, - .address_list = normal_i2c, -}; - -module_i2c_driver(inv_eeprom_driver); - -MODULE_AUTHOR("Inventec"); -MODULE_DESCRIPTION("Inventec Switch Mother Board EEPROM driver"); -MODULE_LICENSE("GPL"); - diff --git a/packages/platforms/lenovo/Makefile b/packages/platforms/lenovo/Makefile deleted file mode 100644 index 003238cf6..000000000 --- a/packages/platforms/lenovo/Makefile +++ /dev/null @@ -1 +0,0 @@ -include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/lenovo/vendor-config/Makefile b/packages/platforms/lenovo/vendor-config/Makefile deleted file mode 100644 index 003238cf6..000000000 --- a/packages/platforms/lenovo/vendor-config/Makefile +++ /dev/null @@ -1 +0,0 @@ -include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/lenovo/vendor-config/PKG.yml b/packages/platforms/lenovo/vendor-config/PKG.yml deleted file mode 100644 index 4986804b4..000000000 --- a/packages/platforms/lenovo/vendor-config/PKG.yml +++ /dev/null @@ -1 +0,0 @@ -!include $ONL_TEMPLATES/platform-config-vendor.yml VENDOR=lenovo Vendor=Lenovo diff --git a/packages/platforms/lenovo/vendor-config/src/python/lenovo/__init__.py b/packages/platforms/lenovo/vendor-config/src/python/lenovo/__init__.py deleted file mode 100644 index d25bfde83..000000000 --- a/packages/platforms/lenovo/vendor-config/src/python/lenovo/__init__.py +++ /dev/null @@ -1,7 +0,0 @@ -#!/usr/bin/python - -from onl.platform.base import * - -class OnlPlatformLenovo(OnlPlatformBase): - MANUFACTURER='Lenovo' - PRIVATE_ENTERPRISE_NUMBER=19046 diff --git a/packages/platforms/lenovo/x86-64/Makefile b/packages/platforms/lenovo/x86-64/Makefile deleted file mode 100644 index 003238cf6..000000000 --- a/packages/platforms/lenovo/x86-64/Makefile +++ /dev/null @@ -1 +0,0 @@ -include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/lenovo/x86-64/modules/Makefile b/packages/platforms/lenovo/x86-64/modules/Makefile deleted file mode 100644 index 003238cf6..000000000 --- a/packages/platforms/lenovo/x86-64/modules/Makefile +++ /dev/null @@ -1 +0,0 @@ -include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/lenovo/x86-64/modules/PKG.yml b/packages/platforms/lenovo/x86-64/modules/PKG.yml deleted file mode 100644 index 25ab64924..000000000 --- a/packages/platforms/lenovo/x86-64/modules/PKG.yml +++ /dev/null @@ -1 +0,0 @@ -!include $ONL_TEMPLATES/no-arch-vendor-modules.yml ARCH=amd64 VENDOR=lenovo diff --git a/packages/platforms/lenovo/x86-64/ne10032/Makefile b/packages/platforms/lenovo/x86-64/ne10032/Makefile deleted file mode 100644 index 003238cf6..000000000 --- a/packages/platforms/lenovo/x86-64/ne10032/Makefile +++ /dev/null @@ -1 +0,0 @@ -include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/lenovo/x86-64/ne10032/modules/Makefile b/packages/platforms/lenovo/x86-64/ne10032/modules/Makefile deleted file mode 100644 index 003238cf6..000000000 --- a/packages/platforms/lenovo/x86-64/ne10032/modules/Makefile +++ /dev/null @@ -1 +0,0 @@ -include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/lenovo/x86-64/ne10032/modules/PKG.yml b/packages/platforms/lenovo/x86-64/ne10032/modules/PKG.yml deleted file mode 100644 index feecc0568..000000000 --- a/packages/platforms/lenovo/x86-64/ne10032/modules/PKG.yml +++ /dev/null @@ -1 +0,0 @@ -!include $ONL_TEMPLATES/no-platform-modules.yml ARCH=amd64 VENDOR=lenovo BASENAME=x86-64-lenovo-ne10032 diff --git a/packages/platforms/lenovo/x86-64/ne10032/onlp/Makefile b/packages/platforms/lenovo/x86-64/ne10032/onlp/Makefile deleted file mode 100644 index 003238cf6..000000000 --- a/packages/platforms/lenovo/x86-64/ne10032/onlp/Makefile +++ /dev/null @@ -1 +0,0 @@ -include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/lenovo/x86-64/ne10032/onlp/PKG.yml b/packages/platforms/lenovo/x86-64/ne10032/onlp/PKG.yml deleted file mode 100644 index 47ad6b433..000000000 --- a/packages/platforms/lenovo/x86-64/ne10032/onlp/PKG.yml +++ /dev/null @@ -1 +0,0 @@ -!include $ONL_TEMPLATES/onlp-platform-any.yml PLATFORM=x86-64-lenovo-ne10032 ARCH=amd64 TOOLCHAIN=x86_64-linux-gnu diff --git a/packages/platforms/lenovo/x86-64/ne10032/onlp/builds/Makefile b/packages/platforms/lenovo/x86-64/ne10032/onlp/builds/Makefile deleted file mode 100644 index e7437cb23..000000000 --- a/packages/platforms/lenovo/x86-64/ne10032/onlp/builds/Makefile +++ /dev/null @@ -1,2 +0,0 @@ -FILTER=src -include $(ONL)/make/subdirs.mk diff --git a/packages/platforms/lenovo/x86-64/ne10032/onlp/builds/lib/Makefile b/packages/platforms/lenovo/x86-64/ne10032/onlp/builds/lib/Makefile deleted file mode 100644 index fc221c7a9..000000000 --- a/packages/platforms/lenovo/x86-64/ne10032/onlp/builds/lib/Makefile +++ /dev/null @@ -1,2 +0,0 @@ -PLATFORM := x86-64-lenovo-ne10032 -include $(ONL)/packages/base/any/onlp/builds/platform/libonlp-platform.mk diff --git a/packages/platforms/lenovo/x86-64/ne10032/onlp/builds/onlpdump/Makefile b/packages/platforms/lenovo/x86-64/ne10032/onlp/builds/onlpdump/Makefile deleted file mode 100644 index fb48fe9c7..000000000 --- a/packages/platforms/lenovo/x86-64/ne10032/onlp/builds/onlpdump/Makefile +++ /dev/null @@ -1,2 +0,0 @@ -PLATFORM := x86-64-lenovo-ne10032 -include $(ONL)/packages/base/any/onlp/builds/platform/onlps.mk diff --git a/packages/platforms/lenovo/x86-64/ne10032/onlp/builds/x86_64_lenovo_ne10032/.gitignore b/packages/platforms/lenovo/x86-64/ne10032/onlp/builds/x86_64_lenovo_ne10032/.gitignore deleted file mode 100644 index c2b30b36b..000000000 --- a/packages/platforms/lenovo/x86-64/ne10032/onlp/builds/x86_64_lenovo_ne10032/.gitignore +++ /dev/null @@ -1 +0,0 @@ -x86_64_lenovo_ne10032.mk diff --git a/packages/platforms/lenovo/x86-64/ne10032/onlp/builds/x86_64_lenovo_ne10032/.module b/packages/platforms/lenovo/x86-64/ne10032/onlp/builds/x86_64_lenovo_ne10032/.module deleted file mode 100644 index c3586f848..000000000 --- a/packages/platforms/lenovo/x86-64/ne10032/onlp/builds/x86_64_lenovo_ne10032/.module +++ /dev/null @@ -1 +0,0 @@ -name: x86_64_lenovo_ne10032 diff --git a/packages/platforms/lenovo/x86-64/ne10032/onlp/builds/x86_64_lenovo_ne10032/Makefile b/packages/platforms/lenovo/x86-64/ne10032/onlp/builds/x86_64_lenovo_ne10032/Makefile deleted file mode 100644 index 8d84c90a5..000000000 --- a/packages/platforms/lenovo/x86-64/ne10032/onlp/builds/x86_64_lenovo_ne10032/Makefile +++ /dev/null @@ -1,9 +0,0 @@ -############################################################################### -# -# -# -############################################################################### -include $(ONL)/make/config.mk -MODULE := x86_64_lenovo_ne10032 -AUTOMODULE := x86_64_lenovo_ne10032 -include $(BUILDER)/definemodule.mk diff --git a/packages/platforms/lenovo/x86-64/ne10032/onlp/builds/x86_64_lenovo_ne10032/Makefile.bak b/packages/platforms/lenovo/x86-64/ne10032/onlp/builds/x86_64_lenovo_ne10032/Makefile.bak deleted file mode 100644 index 7c41ccfe7..000000000 --- a/packages/platforms/lenovo/x86-64/ne10032/onlp/builds/x86_64_lenovo_ne10032/Makefile.bak +++ /dev/null @@ -1,9 +0,0 @@ -############################################################################### -# -# -# -############################################################################### -include ../../init.mk -MODULE := x86_64_lenovo_ne10032 -AUTOMODULE := x86_64_lenovo_ne10032 -include $(BUILDER)/definemodule.mk diff --git a/packages/platforms/lenovo/x86-64/ne10032/onlp/builds/x86_64_lenovo_ne10032/README b/packages/platforms/lenovo/x86-64/ne10032/onlp/builds/x86_64_lenovo_ne10032/README deleted file mode 100644 index 3053d7664..000000000 --- a/packages/platforms/lenovo/x86-64/ne10032/onlp/builds/x86_64_lenovo_ne10032/README +++ /dev/null @@ -1,6 +0,0 @@ -############################################################################### -# -# x86_64_lenovo_ne10032 README -# -############################################################################### - diff --git a/packages/platforms/lenovo/x86-64/ne10032/onlp/builds/x86_64_lenovo_ne10032/module/auto/make.mk b/packages/platforms/lenovo/x86-64/ne10032/onlp/builds/x86_64_lenovo_ne10032/module/auto/make.mk deleted file mode 100644 index 50beb13cb..000000000 --- a/packages/platforms/lenovo/x86-64/ne10032/onlp/builds/x86_64_lenovo_ne10032/module/auto/make.mk +++ /dev/null @@ -1,9 +0,0 @@ -############################################################################### -# -# x86_64_lenovo_ne10032 Autogeneration -# -############################################################################### -x86_64_lenovo_ne10032_AUTO_DEFS := module/auto/x86_64_lenovo_ne10032.yml -x86_64_lenovo_ne10032_AUTO_DIRS := module/inc/x86_64_lenovo_ne10032 module/src -include $(BUILDER)/auto.mk - diff --git a/packages/platforms/lenovo/x86-64/ne10032/onlp/builds/x86_64_lenovo_ne10032/module/auto/x86_64_lenovo_ne10032.yml b/packages/platforms/lenovo/x86-64/ne10032/onlp/builds/x86_64_lenovo_ne10032/module/auto/x86_64_lenovo_ne10032.yml deleted file mode 100644 index f7bf5b033..000000000 --- a/packages/platforms/lenovo/x86-64/ne10032/onlp/builds/x86_64_lenovo_ne10032/module/auto/x86_64_lenovo_ne10032.yml +++ /dev/null @@ -1,47 +0,0 @@ -############################################################################### -# -# x86_64_lenovo_ne10032 Autogeneration Definitions. -# -############################################################################### - -cdefs: &cdefs -- X86_64_LENOVO_NE10032_CONFIG_INCLUDE_LOGGING: - doc: "Include or exclude logging." - default: 1 -- X86_64_LENOVO_NE10032_CONFIG_LOG_OPTIONS_DEFAULT: - doc: "Default enabled log options." - default: AIM_LOG_OPTIONS_DEFAULT -- X86_64_LENOVO_NE10032_CONFIG_LOG_BITS_DEFAULT: - doc: "Default enabled log bits." - default: AIM_LOG_BITS_DEFAULT -- X86_64_LENOVO_NE10032_CONFIG_LOG_CUSTOM_BITS_DEFAULT: - doc: "Default enabled custom log bits." - default: 0 -- X86_64_LENOVO_NE10032_CONFIG_PORTING_STDLIB: - doc: "Default all porting macros to use the C standard libraries." - default: 1 -- X86_64_LENOVO_NE10032_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS: - doc: "Include standard library headers for stdlib porting macros." - default: X86_64_LENOVO_NE10032_CONFIG_PORTING_STDLIB -- X86_64_LENOVO_NE10032_CONFIG_INCLUDE_UCLI: - doc: "Include generic uCli support." - default: 0 - - -definitions: - cdefs: - X86_64_LENOVO_NE10032_CONFIG_HEADER: - defs: *cdefs - basename: x86_64_lenovo_ne10032_config - - portingmacro: - X86_64_LENOVO_NE10032: - macros: - - malloc - - free - - memset - - memcpy - - - vsnprintf - - snprintf - - strlen diff --git a/packages/platforms/lenovo/x86-64/ne10032/onlp/builds/x86_64_lenovo_ne10032/module/inc/x86_64_lenovo_ne10032/x86_64_lenovo_ne10032.x b/packages/platforms/lenovo/x86-64/ne10032/onlp/builds/x86_64_lenovo_ne10032/module/inc/x86_64_lenovo_ne10032/x86_64_lenovo_ne10032.x deleted file mode 100644 index 4de392899..000000000 --- a/packages/platforms/lenovo/x86-64/ne10032/onlp/builds/x86_64_lenovo_ne10032/module/inc/x86_64_lenovo_ne10032/x86_64_lenovo_ne10032.x +++ /dev/null @@ -1,14 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#include - -/* <--auto.start.xmacro(ALL).define> */ -/* */ - -/* <--auto.start.xenum(ALL).define> */ -/* */ - - diff --git a/packages/platforms/lenovo/x86-64/ne10032/onlp/builds/x86_64_lenovo_ne10032/module/inc/x86_64_lenovo_ne10032/x86_64_lenovo_ne10032_config.h b/packages/platforms/lenovo/x86-64/ne10032/onlp/builds/x86_64_lenovo_ne10032/module/inc/x86_64_lenovo_ne10032/x86_64_lenovo_ne10032_config.h deleted file mode 100644 index dcc8c0df6..000000000 --- a/packages/platforms/lenovo/x86-64/ne10032/onlp/builds/x86_64_lenovo_ne10032/module/inc/x86_64_lenovo_ne10032/x86_64_lenovo_ne10032_config.h +++ /dev/null @@ -1,127 +0,0 @@ -/**************************************************************************//** - * - * @file - * @brief x86_64_lenovo_ne10032 Configuration Header - * - * @addtogroup x86_64_lenovo_ne10032-config - * @{ - * - *****************************************************************************/ -#ifndef __X86_64_LENOVO_NE10032_CONFIG_H__ -#define __X86_64_LENOVO_NE10032_CONFIG_H__ - -#ifdef GLOBAL_INCLUDE_CUSTOM_CONFIG -#include -#endif -#ifdef X86_64_LENOVO_NE10032_INCLUDE_CUSTOM_CONFIG -#include -#endif - -/* */ -#include -/** - * X86_64_LENOVO_NE10032_CONFIG_INCLUDE_LOGGING - * - * Include or exclude logging. */ - - -#ifndef X86_64_LENOVO_NE10032_CONFIG_INCLUDE_LOGGING -#define X86_64_LENOVO_NE10032_CONFIG_INCLUDE_LOGGING 1 -#endif - -/** - * X86_64_LENOVO_NE10032_CONFIG_LOG_OPTIONS_DEFAULT - * - * Default enabled log options. */ - - -#ifndef X86_64_LENOVO_NE10032_CONFIG_LOG_OPTIONS_DEFAULT -#define X86_64_LENOVO_NE10032_CONFIG_LOG_OPTIONS_DEFAULT AIM_LOG_OPTIONS_DEFAULT -#endif - -/** - * X86_64_LENOVO_NE10032_CONFIG_LOG_BITS_DEFAULT - * - * Default enabled log bits. */ - - -#ifndef X86_64_LENOVO_NE10032_CONFIG_LOG_BITS_DEFAULT -#define X86_64_LENOVO_NE10032_CONFIG_LOG_BITS_DEFAULT AIM_LOG_BITS_DEFAULT -#endif - -/** - * X86_64_LENOVO_NE10032_CONFIG_LOG_CUSTOM_BITS_DEFAULT - * - * Default enabled custom log bits. */ - - -#ifndef X86_64_LENOVO_NE10032_CONFIG_LOG_CUSTOM_BITS_DEFAULT -#define X86_64_LENOVO_NE10032_CONFIG_LOG_CUSTOM_BITS_DEFAULT 0 -#endif - -/** - * X86_64_LENOVO_NE10032_CONFIG_PORTING_STDLIB - * - * Default all porting macros to use the C standard libraries. */ - - -#ifndef X86_64_LENOVO_NE10032_CONFIG_PORTING_STDLIB -#define X86_64_LENOVO_NE10032_CONFIG_PORTING_STDLIB 1 -#endif - -/** - * X86_64_LENOVO_NE10032_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS - * - * Include standard library headers for stdlib porting macros. */ - - -#ifndef X86_64_LENOVO_NE10032_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS -#define X86_64_LENOVO_NE10032_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS X86_64_LENOVO_NE10032_CONFIG_PORTING_STDLIB -#endif - -/** - * X86_64_LENOVO_NE10032_CONFIG_INCLUDE_UCLI - * - * Include generic uCli support. */ - - -#ifndef X86_64_LENOVO_NE10032_CONFIG_INCLUDE_UCLI -#define X86_64_LENOVO_NE10032_CONFIG_INCLUDE_UCLI 0 -#endif - - - -/** - * All compile time options can be queried or displayed - */ - -/** Configuration settings structure. */ -typedef struct x86_64_lenovo_ne10032_config_settings_s { - /** name */ - const char* name; - /** value */ - const char* value; -} x86_64_lenovo_ne10032_config_settings_t; - -/** Configuration settings table. */ -/** x86_64_lenovo_ne10032_config_settings table. */ -extern x86_64_lenovo_ne10032_config_settings_t x86_64_lenovo_ne10032_config_settings[]; - -/** - * @brief Lookup a configuration setting. - * @param setting The name of the configuration option to lookup. - */ -const char* x86_64_lenovo_ne10032_config_lookup(const char* setting); - -/** - * @brief Show the compile-time configuration. - * @param pvs The output stream. - */ -int x86_64_lenovo_ne10032_config_show(struct aim_pvs_s* pvs); - -/* */ - -#include "x86_64_lenovo_ne10032_porting.h" - -#endif /* __X86_64_LENOVO_NE10032_CONFIG_H__ */ -/* @} */ diff --git a/packages/platforms/lenovo/x86-64/ne10032/onlp/builds/x86_64_lenovo_ne10032/module/inc/x86_64_lenovo_ne10032/x86_64_lenovo_ne10032_dox.h b/packages/platforms/lenovo/x86-64/ne10032/onlp/builds/x86_64_lenovo_ne10032/module/inc/x86_64_lenovo_ne10032/x86_64_lenovo_ne10032_dox.h deleted file mode 100644 index 4a1ce31fa..000000000 --- a/packages/platforms/lenovo/x86-64/ne10032/onlp/builds/x86_64_lenovo_ne10032/module/inc/x86_64_lenovo_ne10032/x86_64_lenovo_ne10032_dox.h +++ /dev/null @@ -1,26 +0,0 @@ -/**************************************************************************//** - * - * x86_64_lenovo_ne10032 Doxygen Header - * - *****************************************************************************/ -#ifndef __X86_64_LENOVO_NE10032_DOX_H__ -#define __X86_64_LENOVO_NE10032_DOX_H__ - -/** - * @defgroup x86_64_lenovo_ne10032 x86_64_lenovo_ne10032 - x86_64_lenovo_ne10032 Description - * - -The documentation overview for this module should go here. - - * - * @{ - * - * @defgroup x86_64_lenovo_ne10032-x86_64_lenovo_ne10032 Public Interface - * @defgroup x86_64_lenovo_ne10032-config Compile Time Configuration - * @defgroup x86_64_lenovo_ne10032-porting Porting Macros - * - * @} - * - */ - -#endif /* __X86_64_LENOVO_NE10032_DOX_H__ */ diff --git a/packages/platforms/lenovo/x86-64/ne10032/onlp/builds/x86_64_lenovo_ne10032/module/inc/x86_64_lenovo_ne10032/x86_64_lenovo_ne10032_porting.h b/packages/platforms/lenovo/x86-64/ne10032/onlp/builds/x86_64_lenovo_ne10032/module/inc/x86_64_lenovo_ne10032/x86_64_lenovo_ne10032_porting.h deleted file mode 100644 index e48d1db52..000000000 --- a/packages/platforms/lenovo/x86-64/ne10032/onlp/builds/x86_64_lenovo_ne10032/module/inc/x86_64_lenovo_ne10032/x86_64_lenovo_ne10032_porting.h +++ /dev/null @@ -1,97 +0,0 @@ -/**************************************************************************//** - * - * @file - * @brief x86_64_lenovo_ne10032 Porting Macros. - * - * @addtogroup x86_64_lenovo_ne10032-porting - * @{ - * - *****************************************************************************/ -#ifndef __X86_64_LENOVO_NE10032_PORTING_H__ -#define __X86_64_LENOVO_NE10032_PORTING_H__ - - -/* */ -#if X86_64_LENOVO_NE10032_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS == 1 -#include -#include -#include -#include -#include -#endif - -#ifndef X86_64_LENOVO_NE10032_MALLOC - #if defined(GLOBAL_MALLOC) - #define X86_64_LENOVO_NE10032_MALLOC GLOBAL_MALLOC - #elif X86_64_LENOVO_NE10032_CONFIG_PORTING_STDLIB == 1 - #define X86_64_LENOVO_NE10032_MALLOC malloc - #else - #error The macro X86_64_LENOVO_NE10032_MALLOC is required but cannot be defined. - #endif -#endif - -#ifndef X86_64_LENOVO_NE10032_FREE - #if defined(GLOBAL_FREE) - #define X86_64_LENOVO_NE10032_FREE GLOBAL_FREE - #elif X86_64_LENOVO_NE10032_CONFIG_PORTING_STDLIB == 1 - #define X86_64_LENOVO_NE10032_FREE free - #else - #error The macro X86_64_LENOVO_NE10032_FREE is required but cannot be defined. - #endif -#endif - -#ifndef X86_64_LENOVO_NE10032_MEMSET - #if defined(GLOBAL_MEMSET) - #define X86_64_LENOVO_NE10032_MEMSET GLOBAL_MEMSET - #elif X86_64_LENOVO_NE10032_CONFIG_PORTING_STDLIB == 1 - #define X86_64_LENOVO_NE10032_MEMSET memset - #else - #error The macro X86_64_LENOVO_NE10032_MEMSET is required but cannot be defined. - #endif -#endif - -#ifndef X86_64_LENOVO_NE10032_MEMCPY - #if defined(GLOBAL_MEMCPY) - #define X86_64_LENOVO_NE10032_MEMCPY GLOBAL_MEMCPY - #elif X86_64_LENOVO_NE10032_CONFIG_PORTING_STDLIB == 1 - #define X86_64_LENOVO_NE10032_MEMCPY memcpy - #else - #error The macro X86_64_LENOVO_NE10032_MEMCPY is required but cannot be defined. - #endif -#endif - -#ifndef X86_64_LENOVO_NE10032_VSNPRINTF - #if defined(GLOBAL_VSNPRINTF) - #define X86_64_LENOVO_NE10032_VSNPRINTF GLOBAL_VSNPRINTF - #elif X86_64_LENOVO_NE10032_CONFIG_PORTING_STDLIB == 1 - #define X86_64_LENOVO_NE10032_VSNPRINTF vsnprintf - #else - #error The macro X86_64_LENOVO_NE10032_VSNPRINTF is required but cannot be defined. - #endif -#endif - -#ifndef X86_64_LENOVO_NE10032_SNPRINTF - #if defined(GLOBAL_SNPRINTF) - #define X86_64_LENOVO_NE10032_SNPRINTF GLOBAL_SNPRINTF - #elif X86_64_LENOVO_NE10032_CONFIG_PORTING_STDLIB == 1 - #define X86_64_LENOVO_NE10032_SNPRINTF snprintf - #else - #error The macro X86_64_LENOVO_NE10032_SNPRINTF is required but cannot be defined. - #endif -#endif - -#ifndef X86_64_LENOVO_NE10032_STRLEN - #if defined(GLOBAL_STRLEN) - #define X86_64_LENOVO_NE10032_STRLEN GLOBAL_STRLEN - #elif X86_64_LENOVO_NE10032_CONFIG_PORTING_STDLIB == 1 - #define X86_64_LENOVO_NE10032_STRLEN strlen - #else - #error The macro X86_64_LENOVO_NE10032_STRLEN is required but cannot be defined. - #endif -#endif - -/* */ - - -#endif /* __X86_64_LENOVO_NE10032_PORTING_H__ */ -/* @} */ diff --git a/packages/platforms/lenovo/x86-64/ne10032/onlp/builds/x86_64_lenovo_ne10032/module/make.mk b/packages/platforms/lenovo/x86-64/ne10032/onlp/builds/x86_64_lenovo_ne10032/module/make.mk deleted file mode 100644 index 32723a8f5..000000000 --- a/packages/platforms/lenovo/x86-64/ne10032/onlp/builds/x86_64_lenovo_ne10032/module/make.mk +++ /dev/null @@ -1,10 +0,0 @@ -############################################################################### -# -# -# -############################################################################### -THIS_DIR := $(dir $(lastword $(MAKEFILE_LIST))) -x86_64_lenovo_ne10032_INCLUDES := -I $(THIS_DIR)inc -x86_64_lenovo_ne10032_INTERNAL_INCLUDES := -I $(THIS_DIR)src -x86_64_lenovo_ne10032_DEPENDMODULE_ENTRIES := init:x86_64_lenovo_ne10032 ucli:x86_64_lenovo_ne10032 - diff --git a/packages/platforms/lenovo/x86-64/ne10032/onlp/builds/x86_64_lenovo_ne10032/module/src/Makefile b/packages/platforms/lenovo/x86-64/ne10032/onlp/builds/x86_64_lenovo_ne10032/module/src/Makefile deleted file mode 100644 index 9fbf71c12..000000000 --- a/packages/platforms/lenovo/x86-64/ne10032/onlp/builds/x86_64_lenovo_ne10032/module/src/Makefile +++ /dev/null @@ -1,9 +0,0 @@ -############################################################################### -# -# Local source generation targets. -# -############################################################################### - -ucli: - @../../../../tools/uclihandlers.py x86_64_lenovo_ne10032_ucli.c - diff --git a/packages/platforms/lenovo/x86-64/ne10032/onlp/builds/x86_64_lenovo_ne10032/module/src/debug.c b/packages/platforms/lenovo/x86-64/ne10032/onlp/builds/x86_64_lenovo_ne10032/module/src/debug.c deleted file mode 100644 index dc716c84c..000000000 --- a/packages/platforms/lenovo/x86-64/ne10032/onlp/builds/x86_64_lenovo_ne10032/module/src/debug.c +++ /dev/null @@ -1,45 +0,0 @@ -#include "x86_64_lenovo_ne10032_int.h" - -#if X86_64_LENOVO_NE10032_CONFIG_INCLUDE_DEBUG == 1 - -#include - -static char help__[] = - "Usage: debug [options]\n" - " -c CPLD Versions\n" - " -h Help\n" - ; - -int -x86_64_lenovo_ne10032_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/lenovo/x86-64/ne10032/onlp/builds/x86_64_lenovo_ne10032/module/src/fani.c b/packages/platforms/lenovo/x86-64/ne10032/onlp/builds/x86_64_lenovo_ne10032/module/src/fani.c deleted file mode 100644 index a004bc509..000000000 --- a/packages/platforms/lenovo/x86-64/ne10032/onlp/builds/x86_64_lenovo_ne10032/module/src/fani.c +++ /dev/null @@ -1,600 +0,0 @@ -/************************************************************ - * - * - * Copyright 2014 Big Switch Networks, Inc. - * Copyright 2018 Alpha Networks Incorporation. - * - * Licensed under the Eclipse Public License, Version 1.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.eclipse.org/legal/epl-v10.html - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT 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 DEBUG 0 - -#define CPLD_I2C_BUS_ID 0 -#define CPLD_I2C_ADDR 0x5E /* Power CPLD Physical Address in the I2C */ - -#define CPLD_FAN6_STATUS_ADDR_OFFSET 0x10 -#define CPLD_FAN5_STATUS_ADDR_OFFSET 0x11 -#define CPLD_FAN4_STATUS_ADDR_OFFSET 0x12 -#define CPLD_FAN3_STATUS_ADDR_OFFSET 0x13 -#define CPLD_FAN2_STATUS_ADDR_OFFSET 0x14 -#define CPLD_FAN1_STATUS_ADDR_OFFSET 0x15 - -#define CPLD_FAN6_0_SPEED_ADDR_OFFSET 0x16 -#define CPLD_FAN6_1_SPEED_ADDR_OFFSET 0x17 -#define CPLD_FAN5_0_SPEED_ADDR_OFFSET 0x18 -#define CPLD_FAN5_1_SPEED_ADDR_OFFSET 0x19 -#define CPLD_FAN4_0_SPEED_ADDR_OFFSET 0x1A -#define CPLD_FAN4_1_SPEED_ADDR_OFFSET 0x1B -#define CPLD_FAN3_0_SPEED_ADDR_OFFSET 0x1C -#define CPLD_FAN3_1_SPEED_ADDR_OFFSET 0x1D -#define CPLD_FAN2_0_SPEED_ADDR_OFFSET 0x1E -#define CPLD_FAN2_1_SPEED_ADDR_OFFSET 0x1F -#define CPLD_FAN1_0_SPEED_ADDR_OFFSET 0x20 -#define CPLD_FAN1_1_SPEED_ADDR_OFFSET 0x21 - -#define CPLD_FAN_MIN_RPS_ADDR_OFFSET 0x22 -#define CPLD_FAN_PWM_ADDR_OFFSET 0x23 -#define CPLD_FAN_SEL_CONTROL_ADDR_OFFSET 0x24 /* 0: CPLD control, 1: BMC control */ - -#define FAN1_EEPROM_BUS 21 -#define FAN_EEPROM_ADDR 0x57 -#define FAN_MODEL_OFFSET 0x67 -#define FAN_MODEL_LENGTH 13 -#define FAN_SERIAL_OFFSET 0x76 -#define FAN_SERIAL_LENGTH 9 - -#define FAN_MAX_RPM 21000 - -#if 1 //PSU FAN - -#define PSU_PMBus_ADDR 0x59 -#define READ_FAN_SPEED_REG 0x90 -#define READ_FAN_STATUS_1_2_REG 0x81 -//#define PSU_ID_OFFSET 4 -#define PSU_ID_OFFSET (PSU1_BUS_ID - FAN_1_ON_PSU1) -#endif - -#define FAN_DIR_FRONT_TO_BACK 0 -#define FAN_DIR_BACK_TO_FRONT 1 - - - -/* Static fan information */ -onlp_fan_info_t linfo[] = { - { }, /* Not used */ - { - { ONLP_FAN_ID_CREATE(FAN_1), "Chassis Fan 1", 0 }, - 0x0, - ONLP_FAN_CAPS_GET_PERCENTAGE | ONLP_FAN_CAPS_GET_RPM | ONLP_FAN_CAPS_SET_PERCENTAGE | ONLP_FAN_CAPS_SET_RPM, - 0, - 0, - ONLP_FAN_MODE_INVALID, - }, - { - { ONLP_FAN_ID_CREATE(FAN_2), "Chassis Fan 2", 0 }, - 0x0, - ONLP_FAN_CAPS_GET_PERCENTAGE | ONLP_FAN_CAPS_GET_RPM | ONLP_FAN_CAPS_SET_PERCENTAGE | ONLP_FAN_CAPS_SET_RPM, - 0, - 0, - ONLP_FAN_MODE_INVALID, - }, - { - { ONLP_FAN_ID_CREATE(FAN_3), "Chassis Fan 3", 0 }, - 0x0, - ONLP_FAN_CAPS_GET_PERCENTAGE | ONLP_FAN_CAPS_GET_RPM | ONLP_FAN_CAPS_SET_PERCENTAGE | ONLP_FAN_CAPS_SET_RPM, - 0, - 0, - ONLP_FAN_MODE_INVALID, - }, - { - { ONLP_FAN_ID_CREATE(FAN_4), "Chassis Fan 4", 0 }, - 0x0, - ONLP_FAN_CAPS_GET_PERCENTAGE | ONLP_FAN_CAPS_GET_RPM | ONLP_FAN_CAPS_SET_PERCENTAGE | ONLP_FAN_CAPS_SET_RPM, - 0, - 0, - ONLP_FAN_MODE_INVALID, - }, - { - { ONLP_FAN_ID_CREATE(FAN_5), "Chassis Fan 5", 0 }, - 0x0, - ONLP_FAN_CAPS_GET_PERCENTAGE | ONLP_FAN_CAPS_GET_RPM | ONLP_FAN_CAPS_SET_PERCENTAGE | ONLP_FAN_CAPS_SET_RPM, - 0, - 0, - ONLP_FAN_MODE_INVALID, - }, - { - { ONLP_FAN_ID_CREATE(FAN_6), "Chassis Fan 6", 0 }, - 0x0, - ONLP_FAN_CAPS_GET_PERCENTAGE | ONLP_FAN_CAPS_GET_RPM | ONLP_FAN_CAPS_SET_PERCENTAGE | ONLP_FAN_CAPS_SET_RPM, - 0, - 0, - ONLP_FAN_MODE_INVALID, - }, - { - { ONLP_FAN_ID_CREATE(FAN_1_ON_PSU1), "Chassis PSU-1 Fan 1", 0 }, - 0x0, - ONLP_FAN_CAPS_GET_RPM, - 0, - 0, - ONLP_FAN_MODE_INVALID, - }, - { - { ONLP_FAN_ID_CREATE(FAN_1_ON_PSU2), "Chassis PSU-2 Fan 1", 0 }, - 0x0, - ONLP_FAN_CAPS_GET_RPM, - 0, - 0, - ONLP_FAN_MODE_INVALID, - }, -}; - -#define VALIDATE(_id) \ - do { \ - if(!ONLP_OID_IS_FAN(_id)) { \ - return ONLP_STATUS_E_INVALID; \ - } \ - } while(0) - - -typedef union -{ - unsigned char val; - struct - { - unsigned char fan_direction :1; - unsigned char fan_present :1; - unsigned char fan0_rps_err :1; - unsigned char fan1_rps_err :1; - unsigned char :4; /* reserved */ - }bit; - -}_CPLD_FAN_STATUS_REG_T; - - -/* Get the CPLD address offset for fan status */ -static char -_onlp_fani_get_fan_status_addr_offset(int local_id) -{ - DIAG_PRINT("%s, local_id=%d", __FUNCTION__, local_id); - switch (local_id) - { - case FAN_1: - return CPLD_FAN1_STATUS_ADDR_OFFSET; - case FAN_2: - return CPLD_FAN2_STATUS_ADDR_OFFSET; - case FAN_3: - return CPLD_FAN3_STATUS_ADDR_OFFSET; - case FAN_4: - return CPLD_FAN4_STATUS_ADDR_OFFSET; - case FAN_5: - return CPLD_FAN5_STATUS_ADDR_OFFSET; - case FAN_6: - return CPLD_FAN6_STATUS_ADDR_OFFSET; - } - return 0; -} - -/* Get the CPLD address offset for fan speed */ -static char -_onlp_fani_get_fan_speed_addr_offset(int local_id) -{ - DIAG_PRINT("%s, local_id=%d", __FUNCTION__, local_id); - switch (local_id) - { - case FAN_1: - return CPLD_FAN1_0_SPEED_ADDR_OFFSET; - case FAN_2: - return CPLD_FAN2_0_SPEED_ADDR_OFFSET; - case FAN_3: - return CPLD_FAN3_0_SPEED_ADDR_OFFSET; - case FAN_4: - return CPLD_FAN4_0_SPEED_ADDR_OFFSET; - case FAN_5: - return CPLD_FAN5_0_SPEED_ADDR_OFFSET; - case FAN_6: - return CPLD_FAN6_0_SPEED_ADDR_OFFSET; - } - return 0; -} - -static int -_onlp_fani_info_get_fan(int local_id, onlp_fan_info_t *info) -{ - DIAG_PRINT("%s, local_id=%d", __FUNCTION__, local_id); - _CPLD_FAN_STATUS_REG_T fan_status_reg; - char status_addr_offset = 0, speed0_addr_offset = 0, speed1_addr_offset = 0; - char data = 0; - unsigned char tach_speed0 = 0, tach_speed1 = 0; - int ret = 0; - - /* Get the CPLD address offset for fan status */ - status_addr_offset = _onlp_fani_get_fan_status_addr_offset(local_id); - - ret = i2c_read_byte(CPLD_I2C_BUS_ID, CPLD_I2C_ADDR, status_addr_offset, &data); - if (ret < 0) - { - AIM_LOG_INFO("%s:%d fail[%d]\n", __FUNCTION__, __LINE__, ret); - return ret; - } - if (DEBUG) - AIM_LOG_INFO("%s:%d id[%d],status_addr_offset[%02x],read_byte[%02x]\n", - __FUNCTION__, __LINE__, local_id, (unsigned char)status_addr_offset, (unsigned char)data); - - fan_status_reg.val = data; - - /* Get fan air flow direction */ - if (fan_status_reg.bit.fan_direction == FAN_DIR_FRONT_TO_BACK) - info->status |= ONLP_FAN_STATUS_F2B; - else - info->status |= ONLP_FAN_STATUS_B2F; - - /* Get fan present */ - if (fan_status_reg.bit.fan_present == 1) - info->status |= ONLP_FAN_STATUS_PRESENT; - else - info->status |= ONLP_FAN_STATUS_FAILED; - - /* Check Speed Error*/ - if (fan_status_reg.bit.fan0_rps_err == 1 || fan_status_reg.bit.fan1_rps_err == 1) - { - info->status |= ONLP_FAN_STATUS_FAILED; - } - - /* Get the CPLD address offset for fan speed */ - speed0_addr_offset = _onlp_fani_get_fan_speed_addr_offset(local_id); - speed1_addr_offset = speed0_addr_offset + 1; - - ret = i2c_read_byte(CPLD_I2C_BUS_ID, CPLD_I2C_ADDR, speed0_addr_offset, (char *)&tach_speed0); - if (ret < 0) - { - AIM_LOG_INFO("%s:%d fail[%d]\n", __FUNCTION__, __LINE__, ret); - return ret; - } - if (DEBUG) - AIM_LOG_INFO("%s:%d id[%d],speed0_addr_offset[%02x],read_byte[%02x]\n", - __FUNCTION__, __LINE__, local_id, (unsigned char)speed0_addr_offset, (unsigned char)tach_speed0); - - ret = i2c_read_byte(CPLD_I2C_BUS_ID, CPLD_I2C_ADDR, speed1_addr_offset, (char *)&tach_speed1); - if (ret < 0) - { - AIM_LOG_INFO("%s:%d fail[%d]\n", __FUNCTION__, __LINE__, ret); - return ret; - } - if (DEBUG) - AIM_LOG_INFO("%s:%d id[%d],speed1_addr_offset[%02x],read_byte[%02x]\n", - __FUNCTION__, __LINE__, local_id, (unsigned char)speed1_addr_offset, (unsigned char)tach_speed1); - - //DIAG_PRINT("%s, speed0=%d(0x%X), speed1=%d(0x%X)", __FUNCTION__, (int)tach_speed0, tach_speed0, (int)tach_speed1, tach_speed1); - - /* Get fan rpm */ - //info->rpm = (((int)tach_speed0 + (int)tach_speed1) / 2) * 150; - info->rpm = (int)tach_speed1 * 150; - - ret = i2c_read_byte(CPLD_I2C_BUS_ID, CPLD_I2C_ADDR, CPLD_FAN_PWM_ADDR_OFFSET, &data); - if (ret < 0) - { - AIM_LOG_INFO("%s:%d fail[%d]\n", __FUNCTION__, __LINE__, ret); - return ret; - } - if (DEBUG) - AIM_LOG_INFO("%s:%d id[%d],pwm_addr_offset[%02x],read_byte[%02x]\n", - __FUNCTION__, __LINE__, local_id, CPLD_FAN_PWM_ADDR_OFFSET, (unsigned char)data); - - /* Get fan duty cycle */ - info->percentage = round(((unsigned char)data * 100) / 255); - -#if 1 - uint8_t rdata[256] = { 0 }; - - i2c_read_i2c_block_dump(FAN1_EEPROM_BUS + local_id - 1, FAN_EEPROM_ADDR, (uint8_t *)rdata); - if (ret < 0) - { - AIM_LOG_INFO("%s:%d fail[%d]\n", __FUNCTION__, __LINE__, ret); - return ret; - } - -#if 0 // debug - int i; - for(i=0;i<256;i++) - { - printf("%02X ",rdata[i]); - } - printf("\n"); -#endif - eeprom_tlv_read(rdata, TLV_CODE_PRODUCT_NAME, (char *)info->model); - eeprom_tlv_read(rdata, TLV_CODE_SERIAL_NUMBER, (char *)info->serial); -#else - ret = i2c_read(FAN1_EEPROM_BUS + local_id - 1, FAN_EEPROM_ADDR, FAN_MODEL_OFFSET, FAN_MODEL_LENGTH, (char *)info->model); - if (ret < 0) - { - AIM_LOG_INFO("%s:%d fail[%d]\n", __FUNCTION__, __LINE__, ret); - return ret; - } - - ret = i2c_read(FAN1_EEPROM_BUS + local_id - 1, FAN_EEPROM_ADDR, FAN_SERIAL_OFFSET, FAN_SERIAL_LENGTH, (char *)info->serial); - if (ret < 0) - { - AIM_LOG_INFO("%s:%d fail[%d]\n", __FUNCTION__, __LINE__, ret); - return ret; - } -#endif - return ONLP_STATUS_OK; -} - -static int -_onlp_fani_info_get_fan_on_psu(int local_id, onlp_fan_info_t *info) -{ - int ret = ONLP_STATUS_OK; - int exponent = 0, mantissa = 0; - uint16_t value = 0; - - - DIAG_PRINT("%s, local_id=%d", __FUNCTION__, local_id); - - /* Get PSU fan speed */ - switch (local_id + PSU_ID_OFFSET) - { - case PSU1_BUS_ID: - ret = i2c_read_word(PSU1_BUS_ID, PSU_PMBus_ADDR, READ_FAN_SPEED_REG); - if (ret < 0 && DEBUG) - AIM_LOG_INFO("%s:%d fail[%d]\n", __FUNCTION__, __LINE__, ret); - - break; - case PSU2_BUS_ID: - ret = i2c_read_word(PSU2_BUS_ID, PSU_PMBus_ADDR, READ_FAN_SPEED_REG); - if (ret < 0 && DEBUG) - AIM_LOG_INFO("%s:%d fail[%d]\n", __FUNCTION__, __LINE__, ret); - - break; - } - - //printf("[%s]local_id:%d i2c read ret:%d\n",__FUNCTION__, local_id, ret); - - if (ret <= 0) - { - info->status |= ONLP_FAN_STATUS_FAILED; - } - else - { - info->status |= ONLP_FAN_STATUS_PRESENT; - - value = ret; - //Linear Data Format - exponent = psu_two_complement_to_int(value >> 11, 5, 0x1f); - mantissa = psu_two_complement_to_int(value & 0x7ff, 11, 0x7ff); - - info->rpm = (exponent >= 0) ? (mantissa << exponent) : (mantissa) / (1 << -exponent); - } - - //check Fan Fault, bit 7 - ret = i2c_read_word(PSU2_BUS_ID, PSU_PMBus_ADDR, READ_FAN_STATUS_1_2_REG); - if (ret < 0 && DEBUG) - { - AIM_LOG_INFO("%s:%d fail[%d]\n", __FUNCTION__, __LINE__, ret); - } - else if ((ret & 0x80) == 0x80) - { - info->status |= ONLP_FAN_STATUS_FAILED; - } - - - - return ONLP_STATUS_OK; -} - -/* - * This function will be called prior to all of onlp_fani_* functions. - */ -#define DEFAULT_FAN_SPEED 50 - -int -onlp_fani_init(void) -{ - DIAG_PRINT("%s", __FUNCTION__); - -#if 1 //By HW design, percentage is apply on all fans. - onlp_fani_percentage_set(ONLP_FAN_ID_CREATE(FAN_1), DEFAULT_FAN_SPEED); -#else - int i = 0; - - for (i = FAN_1; - i <= FAN_6; - i++) - { - onlp_fani_percentage_set(ONLP_FAN_ID_CREATE(i), DEFAULT_FAN_SPEED); - } -#endif - - return ONLP_STATUS_OK; -} - -int -onlp_fani_info_get(onlp_oid_t id, onlp_fan_info_t *info) -{ - DIAG_PRINT("%s, id=%d", __FUNCTION__, id); - - int ret = ONLP_STATUS_OK; - 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: - ret = _onlp_fani_info_get_fan_on_psu(local_id, info); - break; - - default: - ret = _onlp_fani_info_get_fan(local_id, info); - break; - } - - return ret; -} - -int onlp_fani_status_get(onlp_oid_t id, uint32_t *rv) -{ - - DIAG_PRINT("%s, id=%d", __FUNCTION__, id); - onlp_fan_info_t info; - onlp_fan_status_t ret = 0; - onlp_fani_info_get(id, &info); - - - ret = info.status & (ONLP_FAN_STATUS_PRESENT | ONLP_FAN_STATUS_FAILED); - *rv = (uint32_t)ret; - return 0; -} - -int _onlp_fani_rpm_to_percentage(int rpm) -{ - int percentage = 0; - percentage = round(rpm * 100 / FAN_MAX_RPM); - - if (percentage == 0 && rpm != 0) - { - percentage = 1; - } - DIAG_PRINT("%s, rpm=%d to percentage=%d", __FUNCTION__, rpm, percentage); - - return percentage; -} - -/* - * 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. - */ -/* - [Note]: By H/W design, fan speed is controlled using percentage. - RPM value will be translated to percentage and it may produce some deviation. - (the register size is 8-bit, so there is only 255 units to present the value.) -*/ -int -onlp_fani_rpm_set(onlp_oid_t id, int rpm) -{ - DIAG_PRINT("%s, id=%d, rpm=%d", __FUNCTION__, id, rpm); - - if (rpm > FAN_MAX_RPM || rpm <= 0) - { - AIM_LOG_INFO("%s:%d rpm:%d is out of range. (1~%d)\n", __FUNCTION__, __LINE__, rpm, FAN_MAX_RPM); - return ONLP_STATUS_E_PARAM; - } - return onlp_fani_percentage_set(id, _onlp_fani_rpm_to_percentage(rpm)); -} - - -/* - * 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 ret = 0, local_id = 0; - float val = (float)p * 2.55; - char data = (char)round(val); - - DIAG_PRINT("%s, id=%d, p=%d (0x%2X)", __FUNCTION__, id, p, (unsigned char)data); - - VALIDATE(id); - - local_id = ONLP_OID_ID_GET(id); - - /* Not support to stop fan */ - if (p == 0) - return ONLP_STATUS_E_INVALID; - else if (p == 100) - data = 0xff; - - /* Cannot control PWM for each fan modules respectively. - * All fan modules PWM will be the same. - */ - - ret = i2c_write_byte(CPLD_I2C_BUS_ID, CPLD_I2C_ADDR, CPLD_FAN_PWM_ADDR_OFFSET, data); - if (ret < 0) - AIM_LOG_INFO("%s:%d data[%02x] fail[%d]\n", __FUNCTION__, __LINE__, data, ret); - - if (DEBUG) - AIM_LOG_INFO("%s:%d id[%d],pwm_addr_offset[%02x],write_byte[%02x]\n", - __FUNCTION__, __LINE__, local_id, CPLD_FAN_PWM_ADDR_OFFSET, (unsigned char)data); - - 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) -{ - DIAG_PRINT("%s, ONLP_STATUS_E_UNSUPPORTED", __FUNCTION__); - 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) -{ - DIAG_PRINT("%s, ONLP_STATUS_E_UNSUPPORTED", __FUNCTION__); - return ONLP_STATUS_E_UNSUPPORTED; -} - -/* - * Generic fan ioctl. Optional. - */ -int -onlp_fani_ioctl(onlp_oid_t id, va_list vargs) -{ - DIAG_PRINT("%s, ONLP_STATUS_E_UNSUPPORTED", __FUNCTION__); - return ONLP_STATUS_E_UNSUPPORTED; -} - - diff --git a/packages/platforms/lenovo/x86-64/ne10032/onlp/builds/x86_64_lenovo_ne10032/module/src/ledi.c b/packages/platforms/lenovo/x86-64/ne10032/onlp/builds/x86_64_lenovo_ne10032/module/src/ledi.c deleted file mode 100644 index 8c502f051..000000000 --- a/packages/platforms/lenovo/x86-64/ne10032/onlp/builds/x86_64_lenovo_ne10032/module/src/ledi.c +++ /dev/null @@ -1,780 +0,0 @@ -/************************************************************ - * - * - * Copyright 2014, 2015 Big Switch Networks, Inc. - * Copyright 2018 Alpha Networks Incorporation. - * - * Licensed under the Eclipse Public License, Version 1.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.eclipse.org/legal/epl-v10.html - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, - * either express or implied. See the License for the specific - * language governing permissions and limitations under the - * License. - * - * - ************************************************************ - * - * LED Management - * - ***********************************************************/ -#include -#include -#include -#include -#include "platform_lib.h" - -#include -//#include "onlpie_int.h" - -#define CPLD_I2C_BUS_ID 8 -#define CPLD_I2C_ADDR 0x5F /* System CPLD Physical Address in the I2C */ -#define CPLD_SYS_LED_ADDRESS_OFFSET 0x08 -#define CPLD_FAN1_LED_ADDRESS_OFFSET 0x09 //Fan LED Register 0 -#define CPLD_FAN2_LED_ADDRESS_OFFSET 0x09 -#define CPLD_FAN3_LED_ADDRESS_OFFSET 0x0A //Fan LED Register 1 -#define CPLD_FAN4_LED_ADDRESS_OFFSET 0x0A -#define CPLD_FAN5_LED_ADDRESS_OFFSET 0x0B //Fan LED Register 2 -#define CPLD_FAN6_LED_ADDRESS_OFFSET 0x0B -#define CPLD_FAN1_REAR_LED_ADDRESS_OFFSET 0x0E //Fan Rear LED Register 0 -#define CPLD_FAN2_REAR_LED_ADDRESS_OFFSET 0x0E -#define CPLD_FAN3_REAR_LED_ADDRESS_OFFSET 0x0F //Fan Rear LED Register 1 -#define CPLD_FAN4_REAR_LED_ADDRESS_OFFSET 0x0F -#define CPLD_FAN5_REAR_LED_ADDRESS_OFFSET 0x010 //Fan Rear LED Register 2 -#define CPLD_FAN6_REAR_LED_ADDRESS_OFFSET 0x010 -#define CPLD_SERVICE_LED_ADDRESS_OFFSET 0x11 //Service Blue LED Register - - -#define STACKING_LED_OFF 0x00 -#define STACKING_LED_AMBER_SOLID 0x01 -#define STACKING_LED_AMBER_BLINKING 0x03 -#define STACKING_LED_GREEN_SOLID 0x05 -#define STACKING_LED_GREEN_BLINKING 0x07 - -#define PWR_LED_OFF 0x00 -#define PWR_LED_AMBER_SOLID 0x01 -#define PWR_LED_AMBER_BLINKING 0x03 -#define PWR_LED_GREEN_SOLID 0x05 -#define PWR_LED_GREEN_BLINKING 0x07 - -#define SERVICE_LED_OFF 0x00 -#define SERVICE_LED_BLUE_SOLID 0x01 -#define SERVICE_LED_BLUE_BLINKING 0x03 - -#define FAN_LED_OFF 0x00 -#define FAN_LED_AMBER_SOLID 0x01 -#define FAN_LED_AMBER_BLINKING 0x03 -#define FAN_LED_GREEN_SOLID 0x05 -#define FAN_LED_GREEN_BLINKING 0x07 - -#define REAR_FAN_LED_GREEN_SOLID 0x01 -#define REAR_FAN_LED_GREEN_BLINKING 0x03 - -#define VALIDATE(_id) \ - do { \ - if(!ONLP_OID_IS_LED(_id)) { \ - return ONLP_STATUS_E_INVALID; \ - } \ - } while(0) - -struct led_id_mode -{ - enum onlp_led_id led_id; - onlp_led_mode_t mode; - int hw_led_light_mode; -}; - -static struct led_id_mode led_id_mode_data[] = { - { LED_SERVICE, ONLP_LED_MODE_OFF, SERVICE_LED_OFF }, - { LED_SERVICE, ONLP_LED_MODE_BLUE, SERVICE_LED_BLUE_SOLID }, - { LED_SERVICE, ONLP_LED_MODE_BLUE_BLINKING, SERVICE_LED_BLUE_BLINKING }, - { LED_SERVICE, ONLP_LED_MODE_ON, SERVICE_LED_BLUE_SOLID }, - - { LED_STACKING, ONLP_LED_MODE_OFF, STACKING_LED_OFF }, - { LED_STACKING, ONLP_LED_MODE_GREEN, STACKING_LED_GREEN_SOLID }, - { LED_STACKING, ONLP_LED_MODE_GREEN_BLINKING, STACKING_LED_GREEN_BLINKING }, - { LED_STACKING, ONLP_LED_MODE_ORANGE, STACKING_LED_AMBER_SOLID }, - { LED_STACKING, ONLP_LED_MODE_ORANGE_BLINKING, STACKING_LED_AMBER_BLINKING }, - { LED_STACKING, ONLP_LED_MODE_ON, STACKING_LED_GREEN_SOLID }, - - { LED_PWR, ONLP_LED_MODE_OFF, PWR_LED_OFF }, - { LED_PWR, ONLP_LED_MODE_GREEN, PWR_LED_GREEN_SOLID }, - { LED_PWR, ONLP_LED_MODE_GREEN_BLINKING, PWR_LED_GREEN_BLINKING }, - { LED_PWR, ONLP_LED_MODE_ORANGE, PWR_LED_AMBER_SOLID }, - { LED_PWR, ONLP_LED_MODE_ORANGE_BLINKING, PWR_LED_AMBER_BLINKING }, - { LED_PWR, ONLP_LED_MODE_ON, PWR_LED_GREEN_SOLID }, - - { LED_FAN1, ONLP_LED_MODE_OFF, FAN_LED_OFF }, - { LED_FAN1, ONLP_LED_MODE_GREEN, FAN_LED_GREEN_SOLID }, - { LED_FAN1, ONLP_LED_MODE_GREEN_BLINKING, FAN_LED_GREEN_BLINKING }, - { LED_FAN1, ONLP_LED_MODE_ORANGE, FAN_LED_AMBER_SOLID }, - { LED_FAN1, ONLP_LED_MODE_ORANGE_BLINKING, FAN_LED_AMBER_BLINKING }, - { LED_FAN1, ONLP_LED_MODE_ON, FAN_LED_GREEN_SOLID }, - - { LED_FAN2, ONLP_LED_MODE_OFF, FAN_LED_OFF }, - { LED_FAN2, ONLP_LED_MODE_GREEN, FAN_LED_GREEN_SOLID }, - { LED_FAN2, ONLP_LED_MODE_GREEN_BLINKING, FAN_LED_GREEN_BLINKING }, - { LED_FAN2, ONLP_LED_MODE_ORANGE, FAN_LED_AMBER_SOLID }, - { LED_FAN2, ONLP_LED_MODE_ORANGE_BLINKING, FAN_LED_AMBER_BLINKING }, - { LED_FAN2, ONLP_LED_MODE_ON, FAN_LED_GREEN_SOLID }, - - { LED_FAN3, ONLP_LED_MODE_OFF, FAN_LED_OFF }, - { LED_FAN3, ONLP_LED_MODE_GREEN, FAN_LED_GREEN_SOLID }, - { LED_FAN3, ONLP_LED_MODE_GREEN_BLINKING, FAN_LED_GREEN_BLINKING }, - { LED_FAN3, ONLP_LED_MODE_ORANGE, FAN_LED_AMBER_SOLID }, - { LED_FAN3, ONLP_LED_MODE_ORANGE_BLINKING, FAN_LED_AMBER_BLINKING }, - { LED_FAN3, ONLP_LED_MODE_ON, FAN_LED_GREEN_SOLID }, - - { LED_FAN4, ONLP_LED_MODE_OFF, FAN_LED_OFF }, - { LED_FAN4, ONLP_LED_MODE_GREEN, FAN_LED_GREEN_SOLID }, - { LED_FAN4, ONLP_LED_MODE_GREEN_BLINKING, FAN_LED_GREEN_BLINKING }, - { LED_FAN4, ONLP_LED_MODE_ORANGE, FAN_LED_AMBER_SOLID }, - { LED_FAN4, ONLP_LED_MODE_ORANGE_BLINKING, FAN_LED_AMBER_BLINKING }, - { LED_FAN4, ONLP_LED_MODE_ON, FAN_LED_GREEN_SOLID }, - - { LED_FAN5, ONLP_LED_MODE_OFF, FAN_LED_OFF }, - { LED_FAN5, ONLP_LED_MODE_GREEN, FAN_LED_GREEN_SOLID }, - { LED_FAN5, ONLP_LED_MODE_GREEN_BLINKING, FAN_LED_GREEN_BLINKING }, - { LED_FAN5, ONLP_LED_MODE_ORANGE, FAN_LED_AMBER_SOLID }, - { LED_FAN5, ONLP_LED_MODE_ORANGE_BLINKING, FAN_LED_AMBER_BLINKING }, - { LED_FAN5, ONLP_LED_MODE_ON, FAN_LED_GREEN_SOLID }, - - { LED_FAN6, ONLP_LED_MODE_OFF, FAN_LED_OFF }, - { LED_FAN6, ONLP_LED_MODE_GREEN, FAN_LED_GREEN_SOLID }, - { LED_FAN6, ONLP_LED_MODE_GREEN_BLINKING, FAN_LED_GREEN_BLINKING }, - { LED_FAN6, ONLP_LED_MODE_ORANGE, FAN_LED_AMBER_SOLID }, - { LED_FAN6, ONLP_LED_MODE_ORANGE_BLINKING, FAN_LED_AMBER_BLINKING }, - { LED_FAN6, ONLP_LED_MODE_ON, FAN_LED_GREEN_SOLID }, - - { LED_REAR_FAN1, ONLP_LED_MODE_OFF, FAN_LED_OFF }, - { LED_REAR_FAN1, ONLP_LED_MODE_GREEN, REAR_FAN_LED_GREEN_SOLID }, - { LED_REAR_FAN1, ONLP_LED_MODE_GREEN_BLINKING, REAR_FAN_LED_GREEN_BLINKING }, - { LED_REAR_FAN1, ONLP_LED_MODE_ON, REAR_FAN_LED_GREEN_SOLID }, - - { LED_REAR_FAN2, ONLP_LED_MODE_OFF, FAN_LED_OFF }, - { LED_REAR_FAN2, ONLP_LED_MODE_GREEN, REAR_FAN_LED_GREEN_SOLID }, - { LED_REAR_FAN2, ONLP_LED_MODE_GREEN_BLINKING, REAR_FAN_LED_GREEN_BLINKING }, - { LED_REAR_FAN2, ONLP_LED_MODE_ON, REAR_FAN_LED_GREEN_SOLID }, - - { LED_REAR_FAN3, ONLP_LED_MODE_OFF, FAN_LED_OFF }, - { LED_REAR_FAN3, ONLP_LED_MODE_GREEN, REAR_FAN_LED_GREEN_SOLID }, - { LED_REAR_FAN3, ONLP_LED_MODE_GREEN_BLINKING, REAR_FAN_LED_GREEN_BLINKING }, - { LED_REAR_FAN3, ONLP_LED_MODE_ON, REAR_FAN_LED_GREEN_SOLID }, - - { LED_REAR_FAN4, ONLP_LED_MODE_OFF, FAN_LED_OFF }, - { LED_REAR_FAN4, ONLP_LED_MODE_GREEN, REAR_FAN_LED_GREEN_SOLID }, - { LED_REAR_FAN4, ONLP_LED_MODE_GREEN_BLINKING, REAR_FAN_LED_GREEN_BLINKING }, - { LED_REAR_FAN4, ONLP_LED_MODE_ON, REAR_FAN_LED_GREEN_SOLID }, - - { LED_REAR_FAN5, ONLP_LED_MODE_OFF, FAN_LED_OFF }, - { LED_REAR_FAN5, ONLP_LED_MODE_GREEN, REAR_FAN_LED_GREEN_SOLID }, - { LED_REAR_FAN5, ONLP_LED_MODE_GREEN_BLINKING, REAR_FAN_LED_GREEN_BLINKING }, - { LED_REAR_FAN5, ONLP_LED_MODE_ON, REAR_FAN_LED_GREEN_SOLID }, - - { LED_REAR_FAN6, ONLP_LED_MODE_OFF, FAN_LED_OFF }, - { LED_REAR_FAN6, ONLP_LED_MODE_GREEN, REAR_FAN_LED_GREEN_SOLID }, - { LED_REAR_FAN6, ONLP_LED_MODE_GREEN_BLINKING, REAR_FAN_LED_GREEN_BLINKING }, - { LED_REAR_FAN6, ONLP_LED_MODE_ON, REAR_FAN_LED_GREEN_SOLID }, -}; - - -typedef union -{ - unsigned char val; - struct - { - unsigned char power :3; - unsigned char :1; /* reserved */ - unsigned char stacking :3; - unsigned char :1; /* reserved */ - }bit; - -}_CPLD_SYSTEM_LED_REG_T; - -typedef union -{ - unsigned char val; - struct - { - unsigned char locator :2; - unsigned char :6; /* reserved */ - }bit; - -}_CPLD_LOCATOR_LED_REG_T; - -typedef union -{ - unsigned char val; - struct - { - unsigned char fan_a :3; /* fan_a : FAN1/FAN3/FAN5, fan_b : FAN2/FAN4/FAN6 */ - unsigned char :1; /* reserved */ - unsigned char fan_b :3; - unsigned char :1; /* reserved */ - }bit; - -}_CPLD_FAN_LED_REG_T; - -/* - * Get the information for the given LED OID. - */ -static onlp_led_info_t linfo[] = -{ - { }, /* Not used */ - { - { ONLP_LED_ID_CREATE(LED_SERVICE), "Chassis LED 1 (SERVICE LED)", 0 }, - ONLP_LED_STATUS_PRESENT, - ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_BLUE | ONLP_LED_CAPS_BLUE_BLINKING, - }, - { - { ONLP_LED_ID_CREATE(LED_STACKING), "Chassis LED 2 (STACKING LED)", 0 }, - ONLP_LED_STATUS_PRESENT, - 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_PWR), "Chassis LED 3 (POWER LED)", 0 }, - ONLP_LED_STATUS_PRESENT, - 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_FAN1), "Chassis LED 4 (FAN1 LED)", 0 }, - ONLP_LED_STATUS_PRESENT, - 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_FAN2), "Chassis LED 5 (FAN2 LED)", 0 }, - ONLP_LED_STATUS_PRESENT, - 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_FAN3), "Chassis LED 6 (FAN3 LED)", 0 }, - ONLP_LED_STATUS_PRESENT, - 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_FAN4), "Chassis LED 7 (FAN4 LED)", 0 }, - ONLP_LED_STATUS_PRESENT, - 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_FAN5), "Chassis LED 8 (FAN5 LED)", 0 }, - ONLP_LED_STATUS_PRESENT, - 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_FAN6), "Chassis LED 9 (FAN6 LED)", 0 }, - ONLP_LED_STATUS_PRESENT, - 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_REAR_FAN1), "FAN Rear LED 1", 0 }, - ONLP_LED_STATUS_PRESENT, - ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_GREEN_BLINKING, - }, - { - { ONLP_LED_ID_CREATE(LED_REAR_FAN2), "FAN Rear LED 2", 0 }, - ONLP_LED_STATUS_PRESENT, - ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_GREEN_BLINKING, - }, - { - { ONLP_LED_ID_CREATE(LED_REAR_FAN3), "FAN Rear LED 3", 0 }, - ONLP_LED_STATUS_PRESENT, - ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_GREEN_BLINKING, - }, - { - { ONLP_LED_ID_CREATE(LED_REAR_FAN4), "FAN Rear LED 4", 0 }, - ONLP_LED_STATUS_PRESENT, - ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_GREEN_BLINKING, - }, - { - { ONLP_LED_ID_CREATE(LED_REAR_FAN5), "FAN Rear LED 5", 0 }, - ONLP_LED_STATUS_PRESENT, - ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_GREEN_BLINKING, - }, - { - { ONLP_LED_ID_CREATE(LED_REAR_FAN6), "FAN Rear LED 6", 0 }, - ONLP_LED_STATUS_PRESENT, - ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_GREEN_BLINKING, - }, -}; - -static int convert_hw_led_light_mode_to_onlp(enum onlp_led_id id, int hw_mode) -{ - int i, nsize = sizeof(led_id_mode_data) / sizeof(led_id_mode_data[0]); - for (i = 0; i < nsize; i++) - { - if ((led_id_mode_data[i].led_id == id) && - (led_id_mode_data[i].hw_led_light_mode == hw_mode)) - { - DIAG_PRINT("%s, id:%d, hw_mode:%d mode:%d", __FUNCTION__, id, hw_mode, led_id_mode_data[i].mode); - return (int)led_id_mode_data[i].mode; - } - } - - return -1; -} - -static int convert_onlp_led_light_mode_to_hw(enum onlp_led_id id, onlp_led_mode_t mode) -{ - int i, nsize = sizeof(led_id_mode_data) / sizeof(led_id_mode_data[0]); - for (i = 0; i < nsize; i++) - { - if ((led_id_mode_data[i].led_id == id) && - (led_id_mode_data[i].mode == mode)) - { - DIAG_PRINT("%s, id:%d, mode:%d hw_mode:%d", __FUNCTION__, id, mode, led_id_mode_data[i].hw_led_light_mode); - return led_id_mode_data[i].hw_led_light_mode; - } - } - - return -1; -} - -/* - * This function will be called prior to any other onlp_ledi_* functions. - */ -int -onlp_ledi_init(void) -{ - DIAG_PRINT("%s", __FUNCTION__); -#if 0 - onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_SERVICE), ONLP_LED_MODE_OFF); - onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_STACKING), ONLP_LED_MODE_OFF); - onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_PWR), ONLP_LED_MODE_OFF); - - onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_FAN1), ONLP_LED_MODE_OFF); - onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_FAN2), ONLP_LED_MODE_OFF); - onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_FAN3), ONLP_LED_MODE_OFF); - onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_FAN4), ONLP_LED_MODE_OFF); - onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_FAN5), ONLP_LED_MODE_OFF); - onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_FAN6), ONLP_LED_MODE_OFF); - - onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_REAR_FAN1), ONLP_LED_MODE_OFF); - onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_REAR_FAN2), ONLP_LED_MODE_OFF); - onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_REAR_FAN3), ONLP_LED_MODE_OFF); - onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_REAR_FAN4), ONLP_LED_MODE_OFF); - onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_REAR_FAN5), ONLP_LED_MODE_OFF); - onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_REAR_FAN6), ONLP_LED_MODE_OFF); -#endif - return ONLP_STATUS_OK; -} - -int -onlp_ledi_info_get(onlp_oid_t id, onlp_led_info_t *info) -{ - DIAG_PRINT("%s, id=%d", __FUNCTION__, id); - _CPLD_LOCATOR_LED_REG_T service_led_reg; - _CPLD_SYSTEM_LED_REG_T system_led_reg; - _CPLD_FAN_LED_REG_T fan_led_reg; - char data = 0; - int ret = 0, local_id = 0; - - VALIDATE(id); - - /* Set the onlp_oid_hdr_t and capabilities */ - *info = linfo[ONLP_OID_ID_GET(id)]; - - local_id = ONLP_OID_ID_GET(id); - - switch (local_id) - { - case LED_SERVICE: - ret = i2c_read_byte(CPLD_I2C_BUS_ID, CPLD_I2C_ADDR, CPLD_SERVICE_LED_ADDRESS_OFFSET, &data); - if (ret < 0) - { - AIM_LOG_INFO("%s:%d fail[%d]\n", __FUNCTION__, __LINE__, ret); - return ret; - } - service_led_reg.val = data; - break; - case LED_PWR: - case LED_STACKING: - ret = i2c_read_byte(CPLD_I2C_BUS_ID, CPLD_I2C_ADDR, CPLD_SYS_LED_ADDRESS_OFFSET, &data); - if (ret < 0) - { - AIM_LOG_INFO("%s:%d fail[%d]\n", __FUNCTION__, __LINE__, ret); - return ret; - } - system_led_reg.val = data; - break; - case LED_FAN1: - case LED_FAN2: - ret = i2c_read_byte(CPLD_I2C_BUS_ID, CPLD_I2C_ADDR, CPLD_FAN1_LED_ADDRESS_OFFSET, &data); - if (ret < 0) - { - AIM_LOG_INFO("%s:%d fail[%d]\n", __FUNCTION__, __LINE__, ret); - return ret; - } - fan_led_reg.val = data; - break; - case LED_FAN3: - case LED_FAN4: - ret = i2c_read_byte(CPLD_I2C_BUS_ID, CPLD_I2C_ADDR, CPLD_FAN3_LED_ADDRESS_OFFSET, &data); - if (ret < 0) - { - AIM_LOG_INFO("%s:%d fail[%d]\n", __FUNCTION__, __LINE__, ret); - return ret; - } - fan_led_reg.val = data; - break; - case LED_FAN5: - case LED_FAN6: - ret = i2c_read_byte(CPLD_I2C_BUS_ID, CPLD_I2C_ADDR, CPLD_FAN5_LED_ADDRESS_OFFSET, &data); - if (ret < 0) - { - AIM_LOG_INFO("%s:%d fail[%d]\n", __FUNCTION__, __LINE__, ret); - return ret; - } - fan_led_reg.val = data; - break; - - case LED_REAR_FAN1: - case LED_REAR_FAN2: - ret = i2c_read_byte(CPLD_I2C_BUS_ID, CPLD_I2C_ADDR, CPLD_FAN1_REAR_LED_ADDRESS_OFFSET, &data); - if (ret < 0) - { - AIM_LOG_INFO("%s:%d fail[%d]\n", __FUNCTION__, __LINE__, ret); - return ret; - } - fan_led_reg.val = data; - break; - case LED_REAR_FAN3: - case LED_REAR_FAN4: - ret = i2c_read_byte(CPLD_I2C_BUS_ID, CPLD_I2C_ADDR, CPLD_FAN3_REAR_LED_ADDRESS_OFFSET, &data); - if (ret < 0) - { - AIM_LOG_INFO("%s:%d fail[%d]\n", __FUNCTION__, __LINE__, ret); - return ret; - } - fan_led_reg.val = data; - break; - case LED_REAR_FAN5: - case LED_REAR_FAN6: - ret = i2c_read_byte(CPLD_I2C_BUS_ID, CPLD_I2C_ADDR, CPLD_FAN5_REAR_LED_ADDRESS_OFFSET, &data); - if (ret < 0) - { - AIM_LOG_INFO("%s:%d fail[%d]\n", __FUNCTION__, __LINE__, ret); - return ret; - } - fan_led_reg.val = data; - break; - default : - AIM_LOG_INFO("%s:%d %d is a wrong ID\n", __FUNCTION__, __LINE__, local_id); - return ONLP_STATUS_E_PARAM; - } - - /* Get LED status */ - switch (local_id) - { - case LED_SERVICE: - info->mode = convert_hw_led_light_mode_to_onlp(local_id, service_led_reg.bit.locator); - break; - case LED_PWR: - info->mode = convert_hw_led_light_mode_to_onlp(local_id, system_led_reg.bit.power); - break; - case LED_STACKING: - info->mode = convert_hw_led_light_mode_to_onlp(local_id, system_led_reg.bit.stacking); - break; - case LED_FAN1: - case LED_FAN3: - case LED_FAN5: - case LED_REAR_FAN1: - case LED_REAR_FAN3: - case LED_REAR_FAN5: - //debug - //printf("[%s] fan_led_reg.val:0x%x \n", __FUNCTION__, fan_led_reg.val); - info->mode = convert_hw_led_light_mode_to_onlp(local_id, fan_led_reg.bit.fan_a); - break; - case LED_FAN2: - case LED_FAN4: - case LED_FAN6: - case LED_REAR_FAN2: - case LED_REAR_FAN4: - case LED_REAR_FAN6: - //debug - //printf("[%s] fan_led_reg.val:0x%x \n", __FUNCTION__, fan_led_reg.val); - info->mode = convert_hw_led_light_mode_to_onlp(local_id, fan_led_reg.bit.fan_b); - break; - - default: - AIM_LOG_INFO("%s:%d %d is a wrong ID\n", __FUNCTION__, __LINE__, local_id); - return ONLP_STATUS_E_PARAM; - } - - /* Set the on/off status */ - if (info->mode != ONLP_LED_MODE_OFF) - { - info->status |= ONLP_LED_STATUS_ON; - } - -//debug -//printf("[%s] local_id:%d info->mode:%d info->status:%d\n", __FUNCTION__, local_id, info->mode, info->status); - - 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) -{ - DIAG_PRINT("%s, id=%d, on_or_off=%d", __FUNCTION__, id, on_or_off); - VALIDATE(id); - - if (!on_or_off) - { - return onlp_ledi_mode_set(id, ONLP_LED_MODE_OFF); - } - - return onlp_ledi_mode_set(id, ONLP_LED_MODE_ON); -} - -/* - * 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) -{ - DIAG_PRINT("%s, id=%d, mode=%d", __FUNCTION__, id, mode); - _CPLD_LOCATOR_LED_REG_T service_led_reg; - _CPLD_SYSTEM_LED_REG_T system_led_reg; - _CPLD_FAN_LED_REG_T fan_led_reg; - char data = 0; - int ret = 0, local_id = 0, hw_led_mode = 0; - - VALIDATE(id); - - local_id = ONLP_OID_ID_GET(id); - - switch (local_id) - { - case LED_SERVICE: - ret = i2c_read_byte(CPLD_I2C_BUS_ID, CPLD_I2C_ADDR, CPLD_SERVICE_LED_ADDRESS_OFFSET, &data); - if (ret < 0) - { - AIM_LOG_INFO("%s:%d fail[%d]\n", __FUNCTION__, __LINE__, ret); - return ret; - } - service_led_reg.val = data; - break; - case LED_PWR: - case LED_STACKING: - ret = i2c_read_byte(CPLD_I2C_BUS_ID, CPLD_I2C_ADDR, CPLD_SYS_LED_ADDRESS_OFFSET, &data); - if (ret < 0) - { - AIM_LOG_INFO("%s:%d fail[%d]\n", __FUNCTION__, __LINE__, ret); - return ret; - } - system_led_reg.val = data; - break; - case LED_FAN1: - case LED_FAN2: - ret = i2c_read_byte(CPLD_I2C_BUS_ID, CPLD_I2C_ADDR, CPLD_FAN1_LED_ADDRESS_OFFSET, &data); - if (ret < 0) - { - AIM_LOG_INFO("%s:%d fail[%d]\n", __FUNCTION__, __LINE__, ret); - return ret; - } - fan_led_reg.val = data; - break; - case LED_FAN3: - case LED_FAN4: - ret = i2c_read_byte(CPLD_I2C_BUS_ID, CPLD_I2C_ADDR, CPLD_FAN3_LED_ADDRESS_OFFSET, &data); - if (ret < 0) - { - AIM_LOG_INFO("%s:%d fail[%d]\n", __FUNCTION__, __LINE__, ret); - return ret; - } - fan_led_reg.val = data; - break; - case LED_FAN5: - case LED_FAN6: - ret = i2c_read_byte(CPLD_I2C_BUS_ID, CPLD_I2C_ADDR, CPLD_FAN5_LED_ADDRESS_OFFSET, &data); - if (ret < 0) - { - AIM_LOG_INFO("%s:%d fail[%d]\n", __FUNCTION__, __LINE__, ret); - return ret; - } - fan_led_reg.val = data; - break; - case LED_REAR_FAN1: - case LED_REAR_FAN2: - ret = i2c_read_byte(CPLD_I2C_BUS_ID, CPLD_I2C_ADDR, CPLD_FAN1_REAR_LED_ADDRESS_OFFSET, &data); - if (ret < 0) - { - AIM_LOG_INFO("%s:%d fail[%d]\n", __FUNCTION__, __LINE__, ret); - return ret; - } - fan_led_reg.val = data; - break; - case LED_REAR_FAN3: - case LED_REAR_FAN4: - ret = i2c_read_byte(CPLD_I2C_BUS_ID, CPLD_I2C_ADDR, CPLD_FAN3_REAR_LED_ADDRESS_OFFSET, &data); - if (ret < 0) - { - AIM_LOG_INFO("%s:%d fail[%d]\n", __FUNCTION__, __LINE__, ret); - return ret; - } - fan_led_reg.val = data; - break; - case LED_REAR_FAN5: - case LED_REAR_FAN6: - ret = i2c_read_byte(CPLD_I2C_BUS_ID, CPLD_I2C_ADDR, CPLD_FAN5_REAR_LED_ADDRESS_OFFSET, &data); - if (ret < 0) - { - AIM_LOG_INFO("%s:%d fail[%d]\n", __FUNCTION__, __LINE__, ret); - return ret; - } - fan_led_reg.val = data; - break; - default : - AIM_LOG_INFO("%s:%d %d is a wrong ID\n", __FUNCTION__, __LINE__, local_id); - return ONLP_STATUS_E_PARAM; - } - - hw_led_mode = convert_onlp_led_light_mode_to_hw(local_id, mode); - if (hw_led_mode < 0) - return ONLP_STATUS_E_PARAM; - - /* Set LED light mode */ - switch (local_id) - { - case LED_SERVICE: - service_led_reg.bit.locator = hw_led_mode; - break; - case LED_PWR: - system_led_reg.bit.power = hw_led_mode; - break; - case LED_STACKING: - system_led_reg.bit.stacking = hw_led_mode; - break; - case LED_FAN1: - case LED_FAN3: - case LED_FAN5: - case LED_REAR_FAN1: - case LED_REAR_FAN3: - case LED_REAR_FAN5: - fan_led_reg.bit.fan_a = hw_led_mode; - break; - case LED_FAN2: - case LED_FAN4: - case LED_FAN6: - case LED_REAR_FAN2: - case LED_REAR_FAN4: - case LED_REAR_FAN6: - fan_led_reg.bit.fan_b = hw_led_mode; - break; - default: - AIM_LOG_INFO("%s:%d %d is a wrong ID\n", __FUNCTION__, __LINE__, local_id); - return ONLP_STATUS_E_PARAM; - } - - switch (local_id) - { - case LED_SERVICE: - //printf("[debug]service_led_reg.val:0x%x\n", service_led_reg.val); - ret = i2c_write_byte(CPLD_I2C_BUS_ID, CPLD_I2C_ADDR, CPLD_SERVICE_LED_ADDRESS_OFFSET, service_led_reg.val); - if (ret < 0) - { - AIM_LOG_INFO("%s:%d fail[%d]\n", __FUNCTION__, __LINE__, ret); - return ret; - } - break; - case LED_PWR: - case LED_STACKING: - ret = i2c_write_byte(CPLD_I2C_BUS_ID, CPLD_I2C_ADDR, CPLD_SYS_LED_ADDRESS_OFFSET, system_led_reg.val); - if (ret < 0) - { - AIM_LOG_INFO("%s:%d fail[%d]\n", __FUNCTION__, __LINE__, ret); - return ret; - } - break; - case LED_FAN1: - case LED_FAN2: - ret = i2c_write_byte(CPLD_I2C_BUS_ID, CPLD_I2C_ADDR, CPLD_FAN1_LED_ADDRESS_OFFSET, fan_led_reg.val); - if (ret < 0) - { - AIM_LOG_INFO("%s:%d fail[%d]\n", __FUNCTION__, __LINE__, ret); - return ret; - } - break; - case LED_FAN3: - case LED_FAN4: - ret = i2c_write_byte(CPLD_I2C_BUS_ID, CPLD_I2C_ADDR, CPLD_FAN3_LED_ADDRESS_OFFSET, fan_led_reg.val); - if (ret < 0) - { - AIM_LOG_INFO("%s:%d fail[%d]\n", __FUNCTION__, __LINE__, ret); - return ret; - } - break; - case LED_FAN5: - case LED_FAN6: - ret = i2c_write_byte(CPLD_I2C_BUS_ID, CPLD_I2C_ADDR, CPLD_FAN5_LED_ADDRESS_OFFSET, fan_led_reg.val); - if (ret < 0) - { - AIM_LOG_INFO("%s:%d fail[%d]\n", __FUNCTION__, __LINE__, ret); - return ret; - } - break; - case LED_REAR_FAN1: - case LED_REAR_FAN2: - ret = i2c_write_byte(CPLD_I2C_BUS_ID, CPLD_I2C_ADDR, CPLD_FAN1_REAR_LED_ADDRESS_OFFSET, fan_led_reg.val); - if (ret < 0) - { - AIM_LOG_INFO("%s:%d fail[%d]\n", __FUNCTION__, __LINE__, ret); - return ret; - } - fan_led_reg.val = data; - break; - case LED_REAR_FAN3: - case LED_REAR_FAN4: - ret = i2c_write_byte(CPLD_I2C_BUS_ID, CPLD_I2C_ADDR, CPLD_FAN3_REAR_LED_ADDRESS_OFFSET, fan_led_reg.val); - if (ret < 0) - { - AIM_LOG_INFO("%s:%d fail[%d]\n", __FUNCTION__, __LINE__, ret); - return ret; - } - fan_led_reg.val = data; - break; - case LED_REAR_FAN5: - case LED_REAR_FAN6: - ret = i2c_write_byte(CPLD_I2C_BUS_ID, CPLD_I2C_ADDR, CPLD_FAN5_REAR_LED_ADDRESS_OFFSET, fan_led_reg.val); - if (ret < 0) - { - AIM_LOG_INFO("%s:%d fail[%d]\n", __FUNCTION__, __LINE__, ret); - return ret; - } - fan_led_reg.val = data; - break; - default : - AIM_LOG_INFO("%s:%d %d is a wrong ID\n", __FUNCTION__, __LINE__, local_id); - return ONLP_STATUS_E_PARAM; - } - - 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/lenovo/x86-64/ne10032/onlp/builds/x86_64_lenovo_ne10032/module/src/make.mk b/packages/platforms/lenovo/x86-64/ne10032/onlp/builds/x86_64_lenovo_ne10032/module/src/make.mk deleted file mode 100644 index 783c53121..000000000 --- a/packages/platforms/lenovo/x86-64/ne10032/onlp/builds/x86_64_lenovo_ne10032/module/src/make.mk +++ /dev/null @@ -1,9 +0,0 @@ -############################################################################### -# -# -# -############################################################################### - -LIBRARY := x86_64_lenovo_ne10032 -$(LIBRARY)_SUBDIR := $(dir $(lastword $(MAKEFILE_LIST))) -include $(BUILDER)/lib.mk diff --git a/packages/platforms/lenovo/x86-64/ne10032/onlp/builds/x86_64_lenovo_ne10032/module/src/platform_lib.c b/packages/platforms/lenovo/x86-64/ne10032/onlp/builds/x86_64_lenovo_ne10032/module/src/platform_lib.c deleted file mode 100644 index 5ba45f0b8..000000000 --- a/packages/platforms/lenovo/x86-64/ne10032/onlp/builds/x86_64_lenovo_ne10032/module/src/platform_lib.c +++ /dev/null @@ -1,832 +0,0 @@ -/************************************************************ - * - * - * Copyright 2014 Big Switch Networks, Inc. - * Copyright 2018 Alpha Networks Incorporation - * - * Licensed under the Eclipse Public License, Version 1.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.eclipse.org/legal/epl-v10.html - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT 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" - -#define DEBUG_FLAG 0 - -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, sizeof(buf)-1, 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 || data_len < 0) { - return -1; - } - - ret = deviceNodeReadBinary(filename, buffer, buf_size-1, data_len); - - if (ret == 0) { - if (data_len) { - buffer[data_len] = '\0'; - } - else { - buffer[buf_size-1] = '\0'; - } - } - - return ret; -} - - -int psu_two_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; -} - - -/* -i2c APIs: access i2c device by ioctl -static int i2c_read(int i2cbus, int addr, int offset, int length, char* data) -static int i2c_read_byte(int i2cbus, int addr, int offset, char* data) -static int i2c_read_word(int i2cbus, int addr, int command) -static int i2c_write_byte(int i2cbus, int addr, int offset, char val) -static int i2c_write_bit(int i2cbus, int addr, int offset, int bit, char val) -*/ -int i2c_read(int i2cbus, int addr, int offset, int length, char* data) -{ - int file; - int i; - char filename[20]; - - /*open i2c device*/ - snprintf(filename, sizeof(filename), "/dev/i2c/%d", i2cbus); - filename[sizeof(filename) - 1] = '\0'; - file = open(filename, O_RDWR); - - if (file < 0) { - sprintf(filename, "/dev/i2c-%d", i2cbus); - file = open(filename, O_RDWR); - } - if (file < 0) - { - AIM_LOG_INFO("Unable to open id:%d %s\r\n", i2cbus, filename); - return -1; - } - - #if 0/*check funcs*/ - unsigned long funcs; - if (ioctl(file, I2C_FUNCS, &funcs) < 0) { - AIM_LOG_INFO("Error: Could not get the adapter\r\n"); - return -1; - } - //I2C_SMBUS_BLOCK_DATA - #endif - - /*set slave address set_slave_addr(file, address, force))*/ - - if (ioctl(file, I2C_SLAVE_FORCE, addr) < 0) - //if (ioctl(file, I2C_SLAVE, addr) < 0) - { - AIM_LOG_INFO("Error: Could not set address to 0x%02x, %s \r\n", addr, strerror(errno)); - close(file); - return -errno; - } - - #if 1 - int res = 0; - for (i = 0; i res) - { - AIM_LOG_INFO("Error: Size out of range offset:%d l:%d res:%d\r\n", offset, length, res); - return -1; - } - - for (i = 0; i < length; i++) - { - data[i] = cblock[offset + i]; - } - #endif - - close(file); - return 0; -} - -int i2c_sequential_read(int i2cbus, int addr, int offset, int length, char* data) -{ - int file; - int i; - char filename[20]; - int res = 0; - - /*open i2c device*/ - snprintf(filename, sizeof(filename), "/dev/i2c/%d", i2cbus); - filename[sizeof(filename) - 1] = '\0'; - file = open(filename, O_RDWR); - - if (file < 0) { - sprintf(filename, "/dev/i2c-%d", i2cbus); - file = open(filename, O_RDWR); - } - if (file < 0) - { - AIM_LOG_INFO("Unable to open id:%d %s\r\n", i2cbus, filename); - return -1; - } - - /*set slave address set_slave_addr(file, address, force))*/ - - if (ioctl(file, I2C_SLAVE_FORCE, addr) < 0) - { - AIM_LOG_INFO("Error: Could not set address to 0x%02x, %s \r\n", addr, strerror(errno)); - close(file); - return -errno; - } - /* - Sequential Read for at24c128 - use i2c_smbus_write_byte_data to write 24c128 address counter(two 8-bit data word addresses) - 24c128: - +----------------------------------------------------+ - | S | Device | Wr | A | 1st Word | A | 2nd Word | A |... - | | Address | | | Address | | Address | | - +----------------------------------------------------+ - SMbus: - +----------------------------------------------------+ - | S | Device | Wr | A | Command | A | Data | A |... - | | Address | | | | | | | - +----------------------------------------------------+ - - */ - res = i2c_smbus_write_byte_data(file, (uint8_t)offset>>8,(uint8_t)offset); - - if(res != 0) { - AIM_LOG_INFO("Error: Write start address failed, return code %d\n", res); - return -1; - } - - for (i = 0; i res) - { - AIM_LOG_INFO("Error: Size out of range offset:%d l:%d res:%d\r\n", offset, length, res); - return -1; - } - - for (i = 0; i < length; i++) - { - data[i] = cblock[offset + i]; - } - #endif - - close(file); - return res; -} - -int i2c_read_byte(int i2cbus, int addr, int offset, char* data) -{ - int ret; - - ret = i2c_read(i2cbus, addr, offset, 1, data); - - if (ret < 0 && DEBUG_FLAG) - { - AIM_LOG_INFO("Error: Read failed %d\r\n",ret); - } - - //AIM_LOG_INFO("i2c_read_byte: bus:%d add:0x%x offset:%d ret:%d data:0x%x\r\n", i2cbus, addr, offset, ret, *data); - - return ret; -} - -int i2c_read_word(int i2cbus, int addr, int offset) -{ - int ret; - - ret = _i2c_read_word_data(i2cbus, addr, offset); - - if (ret < 0 && DEBUG_FLAG) - { - AIM_LOG_INFO("Error: Read failed %d\r\n",ret); - } - - //AIM_LOG_INFO("i2c_read_word: bus:%d add:0x%x offset:%d ret:%d\r\n", i2cbus, addr, offset, ret); - - return ret; -} -int _i2c_read_block_data(int i2cbus, int addr, uint8_t offset, uint8_t *data, int data_length) -{ - int file; - char filename[20]; - - /*open i2c device*/ - snprintf(filename, sizeof(filename), "/dev/i2c/%d", i2cbus); - filename[sizeof(filename) - 1] = '\0'; - file = open(filename, O_RDWR); - - if (file < 0) { - sprintf(filename, "/dev/i2c-%d", i2cbus); - file = open(filename, O_RDWR); - } - if (file < 0) - { - AIM_LOG_INFO("Unable to open id:%d %s\r\n", i2cbus, filename); - return -1; - } - - #if 0/*check funcs*/ - unsigned long funcs; - if (ioctl(file, I2C_FUNCS, &funcs) < 0) { - AIM_LOG_INFO("Error: Could not get the adapter\r\n"); - return -1; - } - //I2C_SMBUS_BLOCK_DATA - #endif - - /*set slave address set_slave_addr(file, address, force))*/ - - if (ioctl(file, I2C_SLAVE_FORCE, addr) < 0) - //if (ioctl(file, I2C_SLAVE, addr) < 0) - { - AIM_LOG_INFO("Error: Could not set address to 0x%02x, %s \r\n", addr, strerror(errno)); - close(file); - return -errno; - } - - int res = 0; - res = i2c_smbus_read_i2c_block_data(file, offset, data_length, data); - if (res < 0 && DEBUG_FLAG) - { - AIM_LOG_INFO("Error: i2c_smbus_read_word_data status:%d\r\n", res); - //close(file); - //return res; - } - - close(file); - return res; -} - -int i2c_read_block(int i2cbus, int addr, uint8_t offset, uint8_t *data, int length) -{ - int ret; - - ret = _i2c_read_block_data(i2cbus, addr, offset, data, length); - - if (ret < 0 && DEBUG_FLAG) - { - AIM_LOG_INFO("Error: Read failed %d\r\n", ret); - } - //AIM_LOG_INFO("i2c_read_block: bus:%d add:0x%x offset:%d ret:%d data:0x%x\r\n", i2cbus, addr, offset, ret, *data); - - return ret; -} - -int _i2c_read_i2c_block_data_dump(int i2cbus, int addr, uint8_t *data) -{ - int file; - char filename[20]; - int res = 0; - int i = 0; - unsigned char cblock[288]; - - /*open i2c device*/ - snprintf(filename, sizeof(filename), "/dev/i2c/%d", i2cbus); - filename[sizeof(filename) - 1] = '\0'; - file = open(filename, O_RDWR); - - if (file < 0) - { - sprintf(filename, "/dev/i2c-%d", i2cbus); - file = open(filename, O_RDWR); - } - if (file < 0) - { - AIM_LOG_INFO("Unable to open id:%d %s\r\n", i2cbus, filename); - return -1; - } - -#if 0/*check funcs*/ - unsigned long funcs; - if (ioctl(file, I2C_FUNCS, &funcs) < 0) - { - AIM_LOG_INFO("Error: Could not get the adapter\r\n"); - return -1; - } - //I2C_SMBUS_BLOCK_DATA -#endif - - /*set slave address set_slave_addr(file, address, force))*/ - - if (ioctl(file, I2C_SLAVE_FORCE, addr) < 0) - //if (ioctl(file, I2C_SLAVE, addr) < 0) - { - AIM_LOG_INFO("Error: Could not set address to 0x%02x, %s \r\n", addr, strerror(errno)); - close(file); - return -errno; - } - - for (res = 0; res < 256; res += i) - { - i = i2c_smbus_read_i2c_block_data(file, res, 32, cblock + res); - if (i <= 0) - { - res = i; - break; - } - } - - if (res < 0 && DEBUG_FLAG) - { - AIM_LOG_INFO("Error: i2c_smbus_read_word_data status:%d\r\n", res); - close(file); - return res; - } - - if (res >= 256) - res = 256; - for (i = 0; i < res; i++) data[i] = cblock[i]; - - close(file); - return res; -} - -int i2c_read_i2c_block_dump(int i2cbus, int addr, uint8_t *data) -{ - int ret; - - ret = _i2c_read_i2c_block_data_dump(i2cbus, addr, data); - - if (ret < 0 && DEBUG_FLAG) - { - AIM_LOG_INFO("Error: Read failed %d\r\n",ret); - } - //AIM_LOG_INFO("i2c_read_block: bus:%d add:0x%x offset:%d ret:%d data:0x%x\r\n", i2cbus, addr, offset, ret, *data); - - return ret; -} - -int i2c_write_byte(int i2cbus, int addr, int offset, char val) -{ - int file; - char filename[20]; - int res = 0; - - #if 0/*get current value*/ - char cur_val=0; - res = i2c_read_byte(i2cbus, addr, offset, &cur_val); - if (ret <0) - { - return res; - } - #endif - - /*open i2c device*/ - snprintf(filename, sizeof(filename), "/dev/i2c/%d", i2cbus); - filename[sizeof(filename) - 1] = '\0'; - file = open(filename, O_RDWR); - - if (file < 0) - { - sprintf(filename, "/dev/i2c-%d", i2cbus); - file = open(filename, O_RDWR); - } - if (file < 0) - { - AIM_LOG_INFO("Unable to open id:%d %s\r\n", i2cbus, filename); - return -1; - } - - /*set slave address set_slave_addr(file, address, force))*/ - - //if (ioctl(file, I2C_SLAVE_FORCE, addr) < 0) - if (ioctl(file, I2C_SLAVE, addr) < 0) - { - AIM_LOG_INFO("Error: Could not set address to 0x%02x, %s \r\n", addr, strerror(errno)); - close(file); - return -errno; - } - - res = i2c_smbus_write_byte_data(file, offset, val); - if (res < 0) - { - AIM_LOG_INFO("Error: i2c_smbus_write_byte_data offset:%d val:0x%x r:%d\r\n", offset, val, res); - close(file); - return res; - } - close(file); - return 0; -} - -int i2c_write_bit(int i2cbus, int addr, int offset, int bit, char val) -{ - - int res = 0; - char cur_val=0; - char new_val=0; - if (val != 0 && val != 1) - { - AIM_LOG_INFO("Error: i2c_write_bit error val:%d\r\n", val); - return -1; - } - - if (bit < 0 && bit > 7) - { - AIM_LOG_INFO("Error: i2c_write_bit error bit:%d\r\n", bit); - return -1; - } - - res = i2c_read_byte(i2cbus, addr, offset, &cur_val); - if (res <0) - { - return res; - } - - if (val == 1) - { - new_val = cur_val | (1< /tmp/onlpi_dbg_trace"); - return 0; -} - -char diag_debug_trace_off(void) -{ - system("echo 0 > /tmp/onlpi_dbg_trace"); - return 0; -} - -char diag_debug_trace_check(void) -{ - char flag = 0; - FILE* file = fopen ("/tmp/onlpi_dbg_trace", "r"); - if (file == NULL) - { - return 0; - } - flag = fgetc (file); - fclose (file); - - return (flag == '1')?1:0; -} - -char* sfp_control_to_str(int value) -{ - switch (value) - { - case ONLP_SFP_CONTROL_RESET: - return "RESET"; - case ONLP_SFP_CONTROL_RESET_STATE: - return "RESET_STATE"; - case ONLP_SFP_CONTROL_RX_LOS: - return "RX_LOS"; - case ONLP_SFP_CONTROL_TX_FAULT: - return "TX_FAULT"; - case ONLP_SFP_CONTROL_TX_DISABLE: - return "TX_DISABLE"; - case ONLP_SFP_CONTROL_TX_DISABLE_CHANNEL: - return "TX_DISABLE_CHANNEL"; - case ONLP_SFP_CONTROL_LP_MODE: - return "LP_MODE"; - case ONLP_SFP_CONTROL_POWER_OVERRIDE: - return "POWER_OVERRIDE"; - - default: - return "UNKNOW"; - } - return ""; -} - -char diag_debug_pause_platform_manage_on(void) -{ - system("echo 1 > /tmp/onlpi_dbg_pause_pm"); - return 0; -} - -char diag_debug_pause_platform_manage_off(void) -{ - system("echo 0 > /tmp/onlpi_dbg_pause_pm"); - return 0; -} - -char diag_debug_pause_platform_manage_check(void) -{ - char flag = 0; - FILE* file = fopen ("/tmp/onlpi_dbg_pause_pm", "r"); - if (file == NULL) - { - return 0; - } - flag = fgetc (file); - fclose (file); - - return (flag == '1')?1:0; -} - -#define ONIE_EEPROM_HEADER_LENGTH 11 -int eeprom_tlv_read(uint8_t *rdata, char type, char *data) -{ - uint8_t i, j, TLV_length; - int total_data_length = ((*(rdata + 9)) << 8) + (*(rdata + 10)) + ONIE_EEPROM_HEADER_LENGTH; - char TLV_type; - - for (i = ONIE_EEPROM_HEADER_LENGTH; i < total_data_length;) - { - TLV_type = *(rdata + i); - TLV_length = *(rdata + i + 1); - //printf("Type:%d Len:%d\n", TLV_type,TLV_length); - if (TLV_type == type) - { - for (j = 0; j < TLV_length; j++) - { - data[j] = *(rdata + i + j + 2); - //printf("TLV match\n"); - } - data[j] = '\0'; - return 0; - } - i += (TLV_length + 2); - //printf("i:%d\n",i); - } - return 0; -} diff --git a/packages/platforms/lenovo/x86-64/ne10032/onlp/builds/x86_64_lenovo_ne10032/module/src/platform_lib.h b/packages/platforms/lenovo/x86-64/ne10032/onlp/builds/x86_64_lenovo_ne10032/module/src/platform_lib.h deleted file mode 100644 index cca328f2a..000000000 --- a/packages/platforms/lenovo/x86-64/ne10032/onlp/builds/x86_64_lenovo_ne10032/module/src/platform_lib.h +++ /dev/null @@ -1,251 +0,0 @@ -/************************************************************ - * - * - * Copyright 2014 Big Switch Networks, Inc. - * Copyright 2018 Alpha Networks Incorporation. - * - * Licensed under the Eclipse Public License, Version 1.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.eclipse.org/legal/epl-v10.html - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT 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_lenovo_ne10032_log.h" - -//for ne10032 -#define IDPROM_PATH "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/0-0056/eeprom" -//#define IDPROM_PATH "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-6/i2c-10/10-0051/eeprom" - -#define PSU1_ID 1 -#define PSU2_ID 2 -#define PSUI_BUS_ID_OFFSET 9 -#define PSU1_BUS_ID (PSUI_BUS_ID_OFFSET + PSU1_ID) -#define PSU2_BUS_ID (PSUI_BUS_ID_OFFSET + PSU2_ID) - -#define CHASSIS_THERMAL_COUNT 2 -#define CHASSIS_FAN_COUNT 6 - -#define PSU1_AC_PMBUS_PREFIX "/sys/bus/i2c/devices/57-003c/" -#define PSU2_AC_PMBUS_PREFIX "/sys/bus/i2c/devices/58-003f/" - -#define PSU1_AC_HWMON_PREFIX "/sys/bus/i2c/devices/2-0050/" -#define PSU1_DC_HWMON_PREFIX "/sys/bus/i2c/devices/57-0050/" -#define PSU2_AC_HWMON_PREFIX "/sys/bus/i2c/devices/3-0050/" -#define PSU2_DC_HWMON_PREFIX "/sys/bus/i2c/devices/58-0053/" - -#define PSU1_AC_HWMON_NODE(node) PSU1_AC_HWMON_PREFIX#node -#define PSU1_DC_HWMON_NODE(node) PSU1_DC_HWMON_PREFIX#node -#define PSU2_AC_HWMON_NODE(node) PSU2_AC_HWMON_PREFIX#node -#define PSU2_DC_HWMON_NODE(node) PSU2_DC_HWMON_PREFIX#node - -#define NUM_OF_SFP_PORT 32 -#define QSFP28_EEPROM_I2C_ADDR 0x50 /* QSFP28 EEPROM Physical Address in the I2C */ - -#define QSFP28_EEPROM_TXRX_LOS_OFFSET 3 -#define QSFP28_EEPROM_TX_FAULT_OFFSET 4 -#define QSFP28_EEPROM_TX_DISABLE_OFFSET 86 -#define QSFP28_EEPROM_POWERSET_OFFSET 93 -#define QSFP28_EEPROM_PAGE_SELECT_OFFSET 127 - -typedef long long I64_T; /* 64-bit signed */ -typedef unsigned long long UI64_T; /* 64-bit unsigned */ -typedef long I32_T; /* 32-bit signed */ -typedef unsigned long UI32_T; /* 32-bit unsigned */ -typedef short int I16_T; /* 16-bit signed */ -typedef unsigned short int UI16_T; /* 16-bit unsigned */ -typedef char I8_T; /* 8-bit signed */ -typedef unsigned char UI8_T; /* 8-bit unsigned */ - -/*----------------------------------------------------------*/ -/* BIT operation */ -/*----------------------------------------------------------*/ -#define UTL_TEST_BITS(__type__,__var__,__pos__) \ - (__type__)((((__type__)(__var__)>>(__type__)(__pos__))&(__type__)1)?(__type__)1:(__type__)0) - -#define UTL_LEFT_SHIFT_BITS(__type__,__range__,__var__,__sft_bits__) \ - (((__type__)(__sft_bits__)>=(__range__))?0:((__type__)(__var__)<<(__type__)(__sft_bits__))) - -#define UTL_RIGHT_SHIFT_BITS(__type__,__range__,__var__,__sft_bits__) \ - (((__type__)__sft_bits__>=(__range__))?(__type__)(__var__):((__type__)(__var__)>>(__type__)(__sft_bits__))) - -#define UTL_SET_BITS(__type__,__range__,__var__,__pos__) \ - ((__type__)(__var__)|UTL_LEFT_SHIFT_BITS(__type__,__range__,(__type__)1U,(__type__)(__pos__))) - -#define UTL_RESET_BITS(__type__,__range__,__var__,__pos__) \ - ((__type__)(__var__)&~UTL_LEFT_SHIFT_BITS(__type__,__range__,(__type__)1U,(__type__)(__pos__))) - -/*----------------------------------------------------------*/ -/* 64 BIT operation */ -/*----------------------------------------------------------*/ -#define UTL_TEST_BITS64(__var__,__pos__) UTL_TEST_BITS(UI64_T,__var__,__pos__) - -#define UTL_SET_BITS64(__var__,__pos__) (__var__) = UTL_SET_BITS(UI64_T,64,__var__,__pos__) -#define UTL_RESET_BITS64(__var__,__pos__) (__var__) = UTL_RESET_BITS(UI64_T,64,__var__,__pos__) - -/*----------------------------------------------------------*/ -/* 32 BIT operation */ -/*----------------------------------------------------------*/ -/* Usage: if( UTL_TEST_BITS32(val,2) )*/ -/* pos = 0~7, 0~15, 0~31 */ -/* 0x1234 = 0001 0010 0011 0100 */ -/* UTL_TEST_BITS32( 0x1234, 2 ) ==> 1 */ -/* UTL_TEST_BITS32( 0x1234, 1 ) ==> 0 */ -#define UTL_TEST_BITS32(__var__,__pos__) UTL_TEST_BITS(UI32_T,__var__,__pos__) - - -/* Usage: UTL_SET_BITS32( val, 6 ) */ -/* pos = 0~7, 0~15, 0~31 */ -/* val = 0x0100 = 0000 0001 0000 0000 */ -/* UTL_SET_BITS32( val,6 )==> 0000 0001 0100 0000 */ -/* UTL_RESET_BITS32( val,8 )=> 0000 0000 0000 0000 */ -#define UTL_SET_BITS32(__var__,__pos__) (__var__) = UTL_SET_BITS(UI32_T,32,__var__,__pos__) -#define UTL_RESET_BITS32(__var__,__pos__) (__var__) = UTL_RESET_BITS(UI32_T,32,__var__,__pos__) - -/*----------------------------------------------------------*/ -/* 16 BIT operation */ -/*----------------------------------------------------------*/ -#define UTL_TEST_BITS16(__var__,__pos__) UTL_TEST_BITS(UI16_T,__var__,__pos__) - -#define UTL_SET_BITS16(__var__,__pos__) (__var__) = UTL_SET_BITS(UI16_T,16,__var__,__pos__) -#define UTL_RESET_BITS16(__var__,__pos__) (__var__) = UTL_RESET_BITS(UI16_T,16,__var__,__pos__) - -/*----------------------------------------------------------*/ -/* 8 BIT operation */ -/*----------------------------------------------------------*/ -#define UTL_TEST_BITS8(__var__,__pos__) UTL_TEST_BITS(UI8_T,__var__,__pos__) - -#define UTL_SET_BITS8(__var__,__pos__) (__var__) = UTL_SET_BITS(UI8_T,8,__var__,__pos__) -#define UTL_RESET_BITS8(__var__,__pos__) (__var__) = UTL_RESET_BITS(UI8_T,16,__var__,__pos__) - - -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_t; - -//psu_type_t get_psu_type(int id, char* modelname, int modelname_len); -int psu_two_complement_to_int(uint16_t data, uint8_t valid_bit, int mask); - -/* FAN related data - */ -enum onlp_fan_id -{ - FAN_RESERVED = 0, - FAN_1, - FAN_2, - FAN_3, - FAN_4, - FAN_5, - FAN_6, - FAN_1_ON_PSU1, - FAN_1_ON_PSU2, -}; - -/* - * LED ID (need to sync with "enum onlp_led_id" defined in ledi.c) - */ -enum onlp_led_id -{ - LED_RESERVED = 0, - LED_SERVICE, - LED_STACKING, - LED_PWR, - LED_FAN1, - LED_FAN2, - LED_FAN3, - LED_FAN4, - LED_FAN5, - LED_FAN6, - LED_REAR_FAN1, - LED_REAR_FAN2, - LED_REAR_FAN3, - LED_REAR_FAN4, - LED_REAR_FAN5, - LED_REAR_FAN6, -}; - -/* -* TLV type code -*/ -#define TLV_CODE_PRODUCT_NAME 0x21 -#define TLV_CODE_PART_NUMBER 0x22 -#define TLV_CODE_SERIAL_NUMBER 0x23 -#define TLV_CODE_MAC_BASE 0x24 -#define TLV_CODE_MANUF_DATE 0x25 -#define TLV_CODE_DEVICE_VERSION 0x26 -#define TLV_CODE_LABEL_REVISION 0x27 -#define TLV_CODE_PLATFORM_NAME 0x28 -#define TLV_CODE_ONIE_VERSION 0x29 -#define TLV_CODE_MAC_SIZE 0x2A -#define TLV_CODE_MANUF_NAME 0x2B -#define TLV_CODE_MANUF_COUNTRY 0x2C -#define TLV_CODE_VENDOR_NAME 0x2D -#define TLV_CODE_DIAG_VERSION 0x2E -#define TLV_CODE_SERVICE_TAG 0x2F -#define TLV_CODE_VENDOR_EXT 0xFD -#define TLV_CODE_CRC_32 0xFE - - -/* -i2c APIs: access i2c device by ioctl -*/ -#include -#include - -int i2c_read(int i2cbus, int addr, int offset, int length, char* data); -int i2c_sequential_read(int i2cbus, int addr, int offset, int length, char* data); -int i2c_read_byte(int i2cbus, int addr, int offset, char* data); -int i2c_read_word(int i2cbus, int addr, int command); -int i2c_read_block(int i2cbus, int addr, uint8_t offset, uint8_t *data, int length); -int i2c_read_i2c_block_dump(int i2cbus, int addr, uint8_t *data); -int i2c_write_byte(int i2cbus, int addr, int offset, char val); -int i2c_write_bit(int i2cbus, int addr, int offset, int bit, char val); -int i2c_read_rps_status(int i2cbus, int addr, int offset); - -#define DIAG_FLAG_ON 1 -#define DIAG_FLAG_OFF 0 -char diag_flag_set(char d); -char diag_flag_get(void); - -char diag_debug_trace_on(void); -char diag_debug_trace_off(void); -char diag_debug_trace_check(void); - -char diag_debug_pause_platform_manage_on(void); -char diag_debug_pause_platform_manage_off(void); -char diag_debug_pause_platform_manage_check(void); -/* -* TLV parsering for specific type code -*/ -int eeprom_tlv_read(uint8_t *rdata, char type, char *data); - - -#define DIAG_TRACE(fmt,args...) if(diag_debug_trace_check()) printf("\n[TRACE]"fmt"\n", args) -#define DIAG_PRINT(fmt,args...) DIAG_TRACE(fmt,args);else if(diag_flag_get()) printf("[DIAG]"fmt"\n", args) - -char* sfp_control_to_str(int value); - -#endif /* __PLATFORM_LIB_H__ */ diff --git a/packages/platforms/lenovo/x86-64/ne10032/onlp/builds/x86_64_lenovo_ne10032/module/src/psui.c b/packages/platforms/lenovo/x86-64/ne10032/onlp/builds/x86_64_lenovo_ne10032/module/src/psui.c deleted file mode 100644 index 484ab1112..000000000 --- a/packages/platforms/lenovo/x86-64/ne10032/onlp/builds/x86_64_lenovo_ne10032/module/src/psui.c +++ /dev/null @@ -1,399 +0,0 @@ -/************************************************************ - * - * - * Copyright 2014 Big Switch Networks, Inc. - * Copyright 2018 Alpha Networks Incorporation. - * - * Licensed under the Eclipse Public License, Version 1.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.eclipse.org/legal/epl-v10.html - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT 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 PSUI_DEBUG_FLAG 0 - - -#define PSU_STATUS_INTERRUPT 3 -#define PSU_STATUS_PRESENT 2 -#define PSU_STATUS_POWER_OK 1 -#define PSU_STATUS_POWER_ON 0 - -#define PSU_NODE_MAX_INT_LEN 8 -#define PSU_NODE_MAX_PATH_LEN 64 -#define PSUI_CPLD_BUS_ID 0 -#define PSUI_POWER_CPLD_ADDR 0x5E -#define RPS_PSU_EEPROM_ADDR 0x51 -#define RPS_PSU_MICRO_P_ADDR 0x59 - -#define PSUI_MANUFACTURER_NAME_REG 0x0C -#define PSUI_PRODUCT_NAME_REG 0x12 -#define PSUI_MODEL_NO_REG 0x1D -#define PSUI_PRODUCT_VER_NO_REG 0x1F -#define PSUI_PRODUCT_SER_NO_REG_F2B 0x23 -#define PSUI_PRODUCT_SER_NO_REG_B2F 0x25 -#define PSUI_PRODUCT_SER_NO_REG PSUI_PRODUCT_SER_NO_REG_B2F -#define PSUI_RPS_STATUS_REG0 0x04 /* PSU Status Register for PSU#1 */ -#define PSUI_RPS_STATUS_REG1 0x03 /* PSU Status Register for PSU#2 */ - -#define PSUI_PRODUCT_SER_NO_SIZE 14 -#define PSUI_PRODUCT_SER_NO_LEN (PSUI_PRODUCT_SER_NO_SIZE + 1) -#define PSUI_PRODUCT_NAME_SIZE 13 -#define PSUI_PRODUCT_NAME_SIZE_F2B 11 -#define PSUI_PRODUCT_NAME_SIZE_B2F 13 - -struct psui_reg_data_word -{ - uint8_t reg; - uint16_t value; -}; - -struct psui_reg_data_word regs_word[] = { { 0x88, 0 }, /* READ_Vin */ - { 0x8b, 0 }, /* READ_Vout */ - { 0x89, 0 }, /* READ_Iin */ - { 0x8c, 0 }, /* READ_Iout */ - { 0x96, 0 }, /* READ_Pout */ - { 0x97, 0 } /* READ_Pin */ -}; - - -#define GET_RPS_STATUS_BIT(x,n) (((x) >> (n)) & 1) -#define VALIDATE(_id) \ - do { \ - if(!ONLP_OID_IS_PSU(_id)) { \ - return ONLP_STATUS_E_INVALID; \ - } \ - } while(0) - - -int -psu_ne10032_linear_format(int exponent, int mantissa) -{ - int multiplier = 1000; /* Units are "milli-" */ - - return (exponent >= 0) ? (mantissa << exponent) * multiplier : - (mantissa * multiplier) / (1 << -exponent); -} - -int -onlp_psui_init(void) -{ - DIAG_PRINT("%s", __FUNCTION__); - return ONLP_STATUS_OK; -} - - -static int -psu_info_get_product_name(int id, UI8_T *data) -{ - DIAG_PRINT("%s, id:%d", __FUNCTION__, id); - int ret = 0; - - ret = i2c_read_block(id, RPS_PSU_EEPROM_ADDR, PSUI_PRODUCT_NAME_REG, data, PSUI_PRODUCT_NAME_SIZE); - if (ret < 0 && PSUI_DEBUG_FLAG) - printf("I2C command 0x%X Read Fail, id=%d\n", PSUI_PRODUCT_NAME_REG, id); - - return ret; -} - -static int -psu_info_get_product_ser(psu_type_t psu_type, int id, UI8_T *data) -{ - int ret = 0; - int addr = 0; - DIAG_PRINT("%s, id:%d", __FUNCTION__, id); - if (psu_type == PSU_TYPE_AC_F2B) - { - addr = PSUI_PRODUCT_SER_NO_REG_F2B; - } - else - { - addr = PSUI_PRODUCT_SER_NO_REG_B2F; - } - - ret = i2c_read_block(id, RPS_PSU_EEPROM_ADDR, addr, data, PSUI_PRODUCT_SER_NO_SIZE); - if (ret < 0) - printf("I2C command 0x%X Read Fail, id=%d\n", addr, id); - return ret; -} - -static int -psu_info_get_status(int id, char *data) -{ - DIAG_PRINT("%s, id:%d", __FUNCTION__, id); - int ret = 0; - - if (id == PSU1_ID) - { - ret = i2c_read_rps_status(PSUI_CPLD_BUS_ID, PSUI_POWER_CPLD_ADDR, PSUI_RPS_STATUS_REG0); - if (ret < 0) - printf("I2C command 0x%X Read Fail, id=%d\n", PSUI_RPS_STATUS_REG0, PSUI_CPLD_BUS_ID); - } - else if (id == PSU2_ID) - { - ret = i2c_read_rps_status(PSUI_CPLD_BUS_ID, PSUI_POWER_CPLD_ADDR, PSUI_RPS_STATUS_REG1); - if (ret < 0) - printf("I2C command 0x%X Read Fail, id=%d\n", PSUI_RPS_STATUS_REG1, PSUI_CPLD_BUS_ID); - } - sprintf(data, "%d\n", ret); - return ret; -} - - -static int -psu_ne10032_info_get(int id, onlp_psu_info_t *info) -{ - DIAG_PRINT("%s, id:%d", __FUNCTION__, id); - //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); - -#if 1 - int i = 0; - int status; - int exponent, mantissa; - for (i = 0; i < 6; i++) - { - //printf("I2C register 0x%X \n", regs_word[i].reg); - status = i2c_read_word(id, RPS_PSU_MICRO_P_ADDR, regs_word[i].reg); - if (status < 0) - printf("I2C command 0x%X Read Fail\n", regs_word[i].reg); - else - { - //printf("I2C command 0x%X Read Success: 0x%02x\n", regs_word[i].reg, status); - regs_word[i].value = status; - } - } - - info->caps |= ONLP_PSU_CAPS_VOUT; - info->caps |= ONLP_PSU_CAPS_VIN; - info->caps |= ONLP_PSU_CAPS_IOUT; - info->caps |= ONLP_PSU_CAPS_IIN; - info->caps |= ONLP_PSU_CAPS_POUT; - info->caps |= ONLP_PSU_CAPS_PIN; - - /* Linear_5s_11s */ - exponent = psu_two_complement_to_int(regs_word[0].value >> 11, 5, 0x1f); - mantissa = psu_two_complement_to_int(regs_word[0].value & 0x7ff, 11, 0x7ff); - info->mvin = psu_ne10032_linear_format(exponent, mantissa); - - /* Linear_16u */ - exponent = -12; - mantissa = regs_word[1].value; - info->mvout = psu_ne10032_linear_format(exponent, mantissa); - - exponent = psu_two_complement_to_int(regs_word[2].value >> 11, 5, 0x1f); - mantissa = psu_two_complement_to_int(regs_word[2].value & 0x7ff, 11, 0x7ff); - info->miin = psu_ne10032_linear_format(exponent, mantissa); - - exponent = psu_two_complement_to_int(regs_word[3].value >> 11, 5, 0x1f); - mantissa = psu_two_complement_to_int(regs_word[3].value & 0x7ff, 11, 0x7ff); - info->miout = psu_ne10032_linear_format(exponent, mantissa); - - exponent = psu_two_complement_to_int(regs_word[4].value >> 11, 5, 0x1f); - mantissa = psu_two_complement_to_int(regs_word[4].value & 0x7ff, 11, 0x7ff); - info->mpout = psu_ne10032_linear_format(exponent, mantissa); - - exponent = psu_two_complement_to_int(regs_word[5].value >> 11, 5, 0x1f); - mantissa = psu_two_complement_to_int(regs_word[5].value & 0x7ff, 11, 0x7ff); - info->mpin = psu_ne10032_linear_format(exponent, mantissa); -#endif - return ONLP_STATUS_OK; -} - -int -psu_um400d_info_get(onlp_psu_info_t *info) -{ - DIAG_PRINT("%s", __FUNCTION__); - int index = ONLP_OID_ID_GET(info->hdr.id); - - /* Set capability - */ - info->caps = ONLP_PSU_CAPS_DC48; - - 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); - - return ONLP_STATUS_OK; -} - -/* - * Get all information about the given PSU oid. - */ -static onlp_psu_info_t pinfo[] = -{ - { }, /* Not used */ - { /* PSU-1 is on i2c channel 10 for ne10032*/ - { ONLP_PSU_ID_CREATE(PSU1_ID), "PSU-1", 0 }, - }, - { /* PSU-2 is on i2c channel 11 for ne10032*/ - { ONLP_PSU_ID_CREATE(PSU2_ID), "PSU-2", 0 }, - } -}; - -psu_type_t get_psu_type(int id, char *product_name, int productname_len) -{ - DIAG_PRINT("%s, id:%d", __FUNCTION__, id); - UI8_T p_name[PSUI_PRODUCT_NAME_SIZE + 1] = { 0 }; - - /* Check AC model name */ - if (psu_info_get_product_name(id, p_name) >= 0) - { - //printf("[psu_info_get_product_name] %s\n", p_name); - if (strncmp((char *)p_name, "DPS-770GB E", strlen("DPS-770GB E")) == 0) - { - if (product_name) - memcpy(product_name, p_name, PSUI_PRODUCT_NAME_SIZE_F2B); - - return PSU_TYPE_AC_F2B; - } - else if (strncmp((char *)p_name, "DPS-770GB-1 A", strlen("DPS-770GB-1 A")) == 0) - { - if (product_name) - memcpy(product_name, p_name, PSUI_PRODUCT_NAME_SIZE_B2F); - - return PSU_TYPE_AC_B2F; - } -#if 0 - else if (strncmp((char*)p_name, "DPS-770GB", strlen("DPS-770GB")) == 0) - { - if (product_name) - memcpy(product_name, p_name, productname_len-1); - - return PSU_TYPE_AC_B2F; - } -#endif - } - return PSU_TYPE_UNKNOWN; -} - - -int -onlp_psui_info_get(onlp_oid_t id, onlp_psu_info_t *info) -{ - char name[ONLP_CONFIG_INFO_STR_MAX]; - char status; - int ret = ONLP_STATUS_OK; - int index = ONLP_OID_ID_GET(id); - psu_type_t psu_type; - - UI8_T product_ser[PSUI_PRODUCT_SER_NO_LEN]; - - UI8_T rps_status = 0, power_ok = 0, power_on = 0, power_present = 0; - - VALIDATE(id); - - memset(info, 0, sizeof(onlp_psu_info_t)); - memset(name, 0, sizeof(name)); - *info = pinfo[index]; /* Set the onlp_oid_hdr_t */ - - /* Get PSU type and product name, bus ID=index+10*/ - psu_type = get_psu_type(index + PSUI_BUS_ID_OFFSET, info->model, sizeof(info->model)); - - //debug - DIAG_PRINT("%s, id:%d, index:%d, psu_type:%d\n", __FUNCTION__, id, index, psu_type); - switch (psu_type) - { - case PSU_TYPE_AC_F2B: - case PSU_TYPE_AC_B2F: - ret = psu_ne10032_info_get(index + PSUI_BUS_ID_OFFSET, info); /* Get PSU electric info from PMBus */ - break; - case PSU_TYPE_DC_48V_F2B: - case PSU_TYPE_DC_48V_B2F: - ret = psu_um400d_info_get(info); - break; - default: - ret = ONLP_STATUS_E_UNSUPPORTED; - return ret; - } - - /* Get the product serial number, bus ID=index+10 */ - if (psu_info_get_product_ser(psu_type, index + PSUI_BUS_ID_OFFSET, product_ser) < 0) - { - printf("Unable to read PSU(%d) item(serial number)\r\n", index); - } - else - { - memcpy(info->serial, product_ser, sizeof(product_ser)); - } - - /* Get psu status from CPLD */ - if (psu_info_get_status(index, &status) < 0) - { - printf("Unable to read PSU(%d) item(psu status)\r\n", index); - } - else - { - rps_status = (UI8_T)atoi(&status); - power_present = GET_RPS_STATUS_BIT(rps_status, PSU_STATUS_PRESENT); - power_ok = GET_RPS_STATUS_BIT(rps_status, PSU_STATUS_POWER_OK); - power_on = GET_RPS_STATUS_BIT(rps_status, PSU_STATUS_POWER_ON); - - /* Empty */ - if (!power_present) - { - info->status |= ONLP_PSU_STATUS_UNPLUGGED; - } - - if (!power_ok) - { - info->status |= ONLP_PSU_STATUS_FAILED; - } - - if (power_on) - { - info->status |= ONLP_PSU_STATUS_PRESENT; - } - - DIAG_PRINT("rps_status:0x%x ,info->status:0x%x\n", rps_status, info->status); - DIAG_PRINT("present:%d, ok:%d, on:%d\n", power_present, power_ok, power_on); - - } - - - - return ret; -} - -int -onlp_psui_ioctl(onlp_oid_t pid, va_list vargs) -{ - DIAG_PRINT("%s, pid=%d", __FUNCTION__, pid); - return ONLP_STATUS_E_UNSUPPORTED; -} - diff --git a/packages/platforms/lenovo/x86-64/ne10032/onlp/builds/x86_64_lenovo_ne10032/module/src/sfpi.c b/packages/platforms/lenovo/x86-64/ne10032/onlp/builds/x86_64_lenovo_ne10032/module/src/sfpi.c deleted file mode 100644 index de8dbe460..000000000 --- a/packages/platforms/lenovo/x86-64/ne10032/onlp/builds/x86_64_lenovo_ne10032/module/src/sfpi.c +++ /dev/null @@ -1,745 +0,0 @@ -/************************************************************ - * - * - * Copyright 2014 Big Switch Networks, Inc. - * Copyright 2018 Alpha Networks Incorporation. - * - * Licensed under the Eclipse Public License, Version 1.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.eclipse.org/legal/epl-v10.html - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT 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 DEBUG 0 - -#define SYSTEM_CPLD_I2C_BUS_ID 8 -#define SYSTEM_CPLD_I2C_ADDR 0x5F /* System CPLD Physical Address in the I2C */ -#define SYSTEM_CPLD_RESET1_ADDR_OFFSET 0x02 /* Need to reset Port CPLD0~3 */ - -#define PORT_CPLD0_I2C_BUS_ID 13 -#define PORT_CPLD1_I2C_BUS_ID 14 -#define PORT_CPLD2_I2C_BUS_ID 15 -#define PORT_CPLD3_I2C_BUS_ID 16 -#define PORT_CPLD_I2C_ADDR 0x5F /* Port CPLD Physical Address in the I2C */ - - -#define PORT_CPLD_PRESENT_ADDR_OFFSET 0x05 -#define PORT_CPLD_RESET_ADDR_OFFSET 0x07 -#define PORT_CPLD_LOWPWR_ADDR_OFFSET 0x09 -#define PORT_CPLD_MOD_SEL_ADDR_OFFSET 0x0B /* Module Select of QSFP ports */ - - -static int -port_to_busid(int port) -{ - int ret = 0; - int index = 0; - index = (port / 8); - ret = index + PORT_CPLD0_I2C_BUS_ID; - DIAG_PRINT("%s, port:%d, busid:%d ", __FUNCTION__, port, ret); - - return ret; -} - -static int -port_to_cpld_present_bit(int port) -{ - int index = 0; - index = (port % 8); - DIAG_PRINT("%s, port:%d, index:%d ", __FUNCTION__, port, index); - return index; -} - -static int -port_to_cpld_mod_sel_bit(int port) -{ - int index = 0; - index = (port % 8); - DIAG_PRINT("%s, port:%d, index:%d ", __FUNCTION__, port, index); - return index; -} - -static int -ne10032_sfp_present(int port) -{ - int ret = 0; - char data = 0; - - DIAG_PRINT("%s, port:%d", __FUNCTION__, port); - - ret = i2c_read_byte(port_to_busid(port), PORT_CPLD_I2C_ADDR, PORT_CPLD_PRESENT_ADDR_OFFSET, &data); - if (ret < 0) - { - AIM_LOG_INFO("%s:%d fail[%d]\n", __FUNCTION__, __LINE__, ret); - return ret; - } - if (DEBUG) - AIM_LOG_INFO("%s:%d port[%d],busid[%d],reg[%02x],read_byte[%02x]\n", __FUNCTION__, __LINE__, - port, port_to_busid(port), PORT_CPLD_PRESENT_ADDR_OFFSET, (unsigned char)data); - - if (data & (1 << port_to_cpld_present_bit(port))) - { - return 1; - } - - return 0; -} - -static int -ne10032_sfp_init(void) -{ - DIAG_PRINT("%s", __FUNCTION__); - int ret = 0; - char data = 0; - - /* pull low for Reset Register 1 of Port CPLD0~3 */ - ret = i2c_write_byte(SYSTEM_CPLD_I2C_BUS_ID, SYSTEM_CPLD_I2C_ADDR, SYSTEM_CPLD_RESET1_ADDR_OFFSET, data); - if (ret < 0) - { - AIM_LOG_INFO("%s:%d fail[%d]\n", __FUNCTION__, __LINE__, ret); - return ret; - } - - return 0; -} - -/************************************************************ - * - * SFPI Entry Points - * - ***********************************************************/ -int -onlp_sfpi_init(void) -{ - DIAG_PRINT("%s", __FUNCTION__); - /* Called at initialization time */ - ne10032_sfp_init(); - - return ONLP_STATUS_OK; -} - -int -onlp_sfpi_bitmap_get(onlp_sfp_bitmap_t *bmap) -{ - - /* - * Ports {0, 32} - */ - int p = 0; - AIM_BITMAP_CLR_ALL(bmap); - - for (p = 0; p < NUM_OF_SFP_PORT; p++) - { - AIM_BITMAP_SET(bmap, p); - } - DIAG_PRINT("%s", __FUNCTION__); - - 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 = 0; - - present = ne10032_sfp_present(port); - - DIAG_PRINT("%s, port=%d, present:%d", __FUNCTION__, port, present); - return present; -} - -int -onlp_sfpi_presence_bitmap_get(onlp_sfp_bitmap_t *dst) -{ - DIAG_PRINT("%s", __FUNCTION__); - uint8_t bytes[4] = { 0 }; - char data = 0; - int i = 0, ret = 0; - - for (i = 0; i < 4; i++) - { - data = 0; - ret = i2c_read_byte(PORT_CPLD0_I2C_BUS_ID + i, PORT_CPLD_I2C_ADDR, PORT_CPLD_PRESENT_ADDR_OFFSET, &data); - - if (ret < 0) - { - AIM_LOG_INFO("%s:%d [%d], fail[%d]\n", __FUNCTION__, __LINE__, PORT_CPLD0_I2C_BUS_ID + i, ret); - return ONLP_STATUS_E_INTERNAL; - } - - bytes[i] = data; - } - - //debug - //printf("[DEBUG]onlp_sfpi_presence_bitmap_get {0x%x 0x%x 0x%x 0x%x}\n",bytes[0],bytes[1],bytes[2],bytes[3]); - - if (DEBUG) - AIM_LOG_INFO("onlp_sfpi_presence_bitmap_get 0x%x %x %x %x %x %x %x\r\n", bytes[3], bytes[2], bytes[1], bytes[0]); - - /* Convert to 64 bit integer in port order */ - 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]) -{ - DIAG_PRINT("%s, port=%d", __FUNCTION__, port); - char mod_sel = 0; - int ret = 0; - - /* Module select for the port */ - mod_sel = (1 << port_to_cpld_mod_sel_bit(port)); - - ret = i2c_write_byte(port_to_busid(port), PORT_CPLD_I2C_ADDR, PORT_CPLD_MOD_SEL_ADDR_OFFSET, mod_sel); - if (ret < 0) - { - AIM_LOG_INFO("%s:%d fail[%d]\n", __FUNCTION__, __LINE__, ret); - return ret; - } - - /* - * Read the SFP eeprom into data[] - */ - memset(data, 0x0, 256); - - if (i2c_read(port_to_busid(port), QSFP28_EEPROM_I2C_ADDR, 0x0, 256, (char *)data) != 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_dom_read(int port, uint8_t data[256]) -{ - DIAG_PRINT("%s, port=%d", __FUNCTION__, port); - char mod_sel = 0; - int ret = 0; - - //Set page select to pahe 00h. - ret = onlp_sfpi_dev_writeb(port, QSFP28_EEPROM_I2C_ADDR, QSFP28_EEPROM_PAGE_SELECT_OFFSET, 0); - //ret = i2c_write_byte(port_to_busid(port), QSFP28_EEPROM_I2C_ADDR, QSFP28_EEPROM_PAGE_SELECT_OFFSET, 0); - if (ret < 0) - { - AIM_LOG_INFO("%s:%d fail[%d]\n", __FUNCTION__, __LINE__, ret); - return ret; - } - - /* Module select for the port */ - mod_sel = (1 << port_to_cpld_mod_sel_bit(port)); - - ret = i2c_write_byte(port_to_busid(port), PORT_CPLD_I2C_ADDR, PORT_CPLD_MOD_SEL_ADDR_OFFSET, mod_sel); - if (ret < 0) - { - AIM_LOG_INFO("%s:%d fail[%d]\n", __FUNCTION__, __LINE__, ret); - return ret; - } - - /* - * Read the SFP DOM eeprom into data[] - */ - memset(data, 0x0, 256); - - if (i2c_read(port_to_busid(port), QSFP28_EEPROM_I2C_ADDR, 0x0, 256, (char *)data) != 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_readb(int port, uint8_t devaddr, uint8_t addr) -{ - int ret; - int bus = port_to_busid(port); - char mod_sel = 0; - - /* Module select for the port */ - mod_sel = (1 << port_to_cpld_mod_sel_bit(port)); - - ret = i2c_write_byte(bus, PORT_CPLD_I2C_ADDR, PORT_CPLD_MOD_SEL_ADDR_OFFSET, mod_sel); - if (ret < 0) - { - AIM_LOG_INFO("%s:%d fail[%d]\n", __FUNCTION__, __LINE__, ret); - } - - ret = onlp_i2c_readb(bus, devaddr, addr, ONLP_I2C_F_FORCE); - DIAG_PRINT("%s, port:%d, devaddr:%d, addr:%d, ret:%d(0x%02X)", __FUNCTION__, port, devaddr, addr, ret, ret); - return ret; -} - -int -onlp_sfpi_dev_writeb(int port, uint8_t devaddr, uint8_t addr, uint8_t value) -{ - - int ret; - int bus = port_to_busid(port); - char mod_sel = 0; - - /* Module select for the port */ - mod_sel = (1 << port_to_cpld_mod_sel_bit(port)); - ret = i2c_write_byte(bus, PORT_CPLD_I2C_ADDR, PORT_CPLD_MOD_SEL_ADDR_OFFSET, mod_sel); - if (ret < 0) - { - AIM_LOG_INFO("%s:%d fail[%d]\n", __FUNCTION__, __LINE__, ret); - return ret; - } - ret = onlp_i2c_writeb(bus, devaddr, addr, value, ONLP_I2C_F_FORCE); - DIAG_PRINT("%s, port:%d, devaddr:%d, addr:%d, value:%d(0x%02X), ret:%d", __FUNCTION__, port, devaddr, addr, value, value, ret); - - return ret; -} - -int -onlp_sfpi_dev_readw(int port, uint8_t devaddr, uint8_t addr) -{ - int ret; - int bus = port_to_busid(port); - char mod_sel = 0; - - /* Module select for the port */ - mod_sel = (1 << port_to_cpld_mod_sel_bit(port)); - ret = i2c_write_byte(bus, PORT_CPLD_I2C_ADDR, PORT_CPLD_MOD_SEL_ADDR_OFFSET, mod_sel); - if (ret < 0) - { - AIM_LOG_INFO("%s:%d fail[%d]\n", __FUNCTION__, __LINE__, ret); - } - - ret = onlp_i2c_readw(bus, devaddr, addr, ONLP_I2C_F_FORCE); - DIAG_PRINT("%s, port:%d, devaddr:%d, addr:%d, ret:%d(0x%04X)", __FUNCTION__, port, devaddr, addr, ret, ret); - return ret; -} - -int -onlp_sfpi_dev_writew(int port, uint8_t devaddr, uint8_t addr, uint16_t value) -{ - - int ret; - int bus = port_to_busid(port); - char mod_sel = 0; - - /* Module select for the port */ - mod_sel = (1 << port_to_cpld_mod_sel_bit(port)); - ret = i2c_write_byte(bus, PORT_CPLD_I2C_ADDR, PORT_CPLD_MOD_SEL_ADDR_OFFSET, mod_sel); - if (ret < 0) - { - AIM_LOG_INFO("%s:%d fail[%d]\n", __FUNCTION__, __LINE__, ret); - return ret; - } - - ret = onlp_i2c_writew(bus, devaddr, addr, value, ONLP_I2C_F_FORCE); - DIAG_PRINT("%s, port:%d, devaddr:%d, addr:%d, value:%d(0x%04X), ret:%d", __FUNCTION__, port, devaddr, addr, value, value, ret); - return ret; -} - -/* - Reset and LP mode can control by CPLD so the setting will be keep in CPLD. - For other options, control is get/set to QSFP28. - Control options set to QSFP28 will be lost when the QSFP28 is removed. - Upper layer software system should keep the configuration and set it again when detect a new sfp module insert. - - function R/W CPLD QSFP28 EEPROM - ------------------------------------ --- ------ ----------------- - ONLP_SFP_CONTROL_RESET W 0x7 - ONLP_SFP_CONTROL_RESET_STATE R/W 0x7 - ONLP_SFP_CONTROL_RX_LOS R none byte 4 - ONLP_SFP_CONTROL_TX_FAULT R none byte 3 - ONLP_SFP_CONTROL_TX_DISABLE R/W none byte 86 - ONLP_SFP_CONTROL_TX_DISABLE_CHANNEL R/W none byte 86 - ONLP_SFP_CONTROL_LP_MODE R/W 0x9 - ONLP_SFP_CONTROL_POWER_OVERRIDE R/W none byte 93 -*/ - -int onlp_sfpi_control_supported(int port, onlp_sfp_control_t control, int *supported) -{ - if (supported == NULL) - { - AIM_LOG_INFO("%s:%d fail[%d]\n", __FUNCTION__, __LINE__, ONLP_STATUS_E_PARAM); - return ONLP_STATUS_E_PARAM; - } - - *supported = 0; - switch (control) - { - case ONLP_SFP_CONTROL_RESET: - case ONLP_SFP_CONTROL_RESET_STATE: - case ONLP_SFP_CONTROL_LP_MODE: - case ONLP_SFP_CONTROL_POWER_OVERRIDE: - case ONLP_SFP_CONTROL_RX_LOS: - case ONLP_SFP_CONTROL_TX_FAULT: - case ONLP_SFP_CONTROL_TX_DISABLE: - case ONLP_SFP_CONTROL_TX_DISABLE_CHANNEL: - *supported = 1; - break; - - default: - *supported = 0; - break; - } - - DIAG_PRINT("%s, port:%d, control:%d(%s), supported:%d", __FUNCTION__, port, control, sfp_control_to_str(control), *supported); - return ONLP_STATUS_OK; -} - -int -onlp_sfpi_control_set(int port, onlp_sfp_control_t control, int value) -{ - int rv = ONLP_STATUS_OK; - int bus = port_to_busid(port); - int mod_sel_bit = port_to_cpld_mod_sel_bit(port); - int supported = 0; - char optval = 0; - - if ((onlp_sfpi_control_supported(port, control, &supported) == ONLP_STATUS_OK) && (supported == 0)) - return ONLP_STATUS_E_UNSUPPORTED; - - DIAG_PRINT("%s, port:%d, control:%d(%s), value:%d", __FUNCTION__, port, control, sfp_control_to_str(control), value); - - /* Module select for the port */ - optval = (1 << mod_sel_bit); - rv = i2c_write_byte(bus, PORT_CPLD_I2C_ADDR, PORT_CPLD_MOD_SEL_ADDR_OFFSET, optval); - if (rv < 0) - { - AIM_LOG_INFO("%s:%d fail[%d]\n", __FUNCTION__, __LINE__, rv); - } - - switch (control) - { - case ONLP_SFP_CONTROL_RESET: - if (value == 0) //set ONLP_SFP_CONTROL_RESET_STATE to 0 - { - rv = onlp_sfpi_control_set(port, ONLP_SFP_CONTROL_RESET_STATE, 0); - break; - } - - rv = onlp_sfpi_control_set(port, ONLP_SFP_CONTROL_RESET_STATE, 1); - if (rv < 0) - { - AIM_LOG_INFO("%s:%d fail[%d]\n", __FUNCTION__, __LINE__, rv); - return rv; - } - rv = onlp_sfpi_control_set(port, ONLP_SFP_CONTROL_RESET_STATE, 0); - if (rv < 0) - { - AIM_LOG_INFO("%s:%d fail[%d]\n", __FUNCTION__, __LINE__, rv); - return rv; - } - - break; - - case ONLP_SFP_CONTROL_RESET_STATE: - optval = onlp_i2c_readb(bus, PORT_CPLD_I2C_ADDR, PORT_CPLD_RESET_ADDR_OFFSET, ONLP_I2C_F_FORCE); - if (value != 0) - { - optval |= (1 << mod_sel_bit); - } - else - { - optval &= ~(1 << mod_sel_bit); - } - rv = onlp_i2c_writeb(bus, PORT_CPLD_I2C_ADDR, PORT_CPLD_RESET_ADDR_OFFSET, optval, ONLP_I2C_F_FORCE); - if (rv < 0) - { - AIM_LOG_INFO("%s:%d fail[%d]\n", __FUNCTION__, __LINE__, rv); - return rv; - } - break; - - case ONLP_SFP_CONTROL_TX_DISABLE: - if (onlp_sfpi_is_present(port) == 0) - { - AIM_LOG_INFO("%s:%d fail[%d]\n", __FUNCTION__, __LINE__, ONLP_STATUS_E_MISSING); - return ONLP_STATUS_E_MISSING; - } - optval = onlp_i2c_readb(bus, QSFP28_EEPROM_I2C_ADDR, QSFP28_EEPROM_TX_DISABLE_OFFSET, ONLP_I2C_F_FORCE); - if (value != 0) - { - optval |= 0x0f; //bit 0~3 - } - else - { - optval &= ~(0x0f); - } - rv = onlp_i2c_writeb(bus, QSFP28_EEPROM_I2C_ADDR, QSFP28_EEPROM_TX_DISABLE_OFFSET, optval, ONLP_I2C_F_FORCE); - if (rv < 0) - { - AIM_LOG_INFO("%s:%d fail[%d]\n", __FUNCTION__, __LINE__, rv); - return rv; - } - break; - - case ONLP_SFP_CONTROL_TX_DISABLE_CHANNEL: - if (onlp_sfpi_is_present(port) == 0) - { - AIM_LOG_INFO("%s:%d fail[%d]\n", __FUNCTION__, __LINE__, ONLP_STATUS_E_MISSING); - return ONLP_STATUS_E_MISSING; - } - if (value < 0 || value > 0x0f) - { - AIM_LOG_INFO("%s:%d fail[%d]\n", __FUNCTION__, __LINE__, ONLP_STATUS_E_PARAM); - return ONLP_STATUS_E_PARAM; - } - optval = value; - rv = onlp_i2c_writeb(bus, QSFP28_EEPROM_I2C_ADDR, QSFP28_EEPROM_TX_DISABLE_OFFSET, optval, ONLP_I2C_F_FORCE); - if (rv < 0) - return rv; - break; - - case ONLP_SFP_CONTROL_POWER_OVERRIDE: - if (onlp_sfpi_is_present(port) == 0) - { - AIM_LOG_INFO("%s:%d fail[%d]\n", __FUNCTION__, __LINE__, ONLP_STATUS_E_MISSING); - return ONLP_STATUS_E_MISSING; - } - optval = onlp_i2c_readb(bus, QSFP28_EEPROM_I2C_ADDR, QSFP28_EEPROM_POWERSET_OFFSET, ONLP_I2C_F_FORCE); - if (value != 0) - { - optval |= 0x01; - } - else - { - optval &= ~(0x01); - } - rv = onlp_i2c_writeb(bus, QSFP28_EEPROM_I2C_ADDR, QSFP28_EEPROM_POWERSET_OFFSET, optval, ONLP_I2C_F_FORCE); - if (rv < 0) - { - AIM_LOG_INFO("%s:%d fail[%d]\n", __FUNCTION__, __LINE__, rv); - return rv; - } - break; - - case ONLP_SFP_CONTROL_LP_MODE: - optval = onlp_i2c_readb(bus, PORT_CPLD_I2C_ADDR, PORT_CPLD_LOWPWR_ADDR_OFFSET, ONLP_I2C_F_FORCE); - if (value != 0) - { - optval |= (1 << mod_sel_bit); - } - else - { - optval &= ~(1 << mod_sel_bit); - } - rv = onlp_i2c_writeb(bus, PORT_CPLD_I2C_ADDR, PORT_CPLD_LOWPWR_ADDR_OFFSET, optval, ONLP_I2C_F_FORCE); - if (rv < 0) - { - AIM_LOG_INFO("%s:%d fail[%d]\n", __FUNCTION__, __LINE__, rv); - return rv; - } - break; - - //Read Only - case ONLP_SFP_CONTROL_RX_LOS: - case ONLP_SFP_CONTROL_TX_FAULT: - AIM_LOG_INFO("%s:%d fail[%d]\n", __FUNCTION__, __LINE__, ONLP_STATUS_E_INVALID); - return ONLP_STATUS_E_INVALID; - break; - default: - break; - } - return rv; -} - -int -onlp_sfpi_control_get(int port, onlp_sfp_control_t control, int *value) -{ - int rv = ONLP_STATUS_OK; - int bus = port_to_busid(port); - int mod_sel_bit = port_to_cpld_mod_sel_bit(port); - int supported = 0; - char optval = 0; - - if (value == NULL) - { - AIM_LOG_INFO("%s:%d fail[%d]\n", __FUNCTION__, __LINE__, ONLP_STATUS_E_PARAM); - return ONLP_STATUS_E_PARAM; - } - - if ((onlp_sfpi_control_supported(port, control, &supported) == ONLP_STATUS_OK) && (supported == 0)) - { - AIM_LOG_INFO("%s:%d fail[%d]\n", __FUNCTION__, __LINE__, ONLP_STATUS_E_UNSUPPORTED); - return ONLP_STATUS_E_UNSUPPORTED; - } - - /* Module select for the port */ - optval = (1 << mod_sel_bit); - rv = i2c_write_byte(bus, PORT_CPLD_I2C_ADDR, PORT_CPLD_MOD_SEL_ADDR_OFFSET, optval); - if (rv < 0) - { - AIM_LOG_INFO("%s:%d fail[%d]\n", __FUNCTION__, __LINE__, rv); - } - - *value = 0; - switch (control) - { - case ONLP_SFP_CONTROL_RESET_STATE: - optval = onlp_i2c_readb(bus, PORT_CPLD_I2C_ADDR, PORT_CPLD_RESET_ADDR_OFFSET, ONLP_I2C_F_FORCE); - if ((optval & (1 << mod_sel_bit)) != 0) //1 - { - *value = 1; - } - else - { - *value = 0; - } - break; - - case ONLP_SFP_CONTROL_RX_LOS: - if (onlp_sfpi_is_present(port) == 0) - { -#if 1 //for display RX_LOS Bitmap in onlpdump - *value = 0; - break; -#else - return ONLP_STATUS_E_MISSING; - -#endif - } - optval = onlp_i2c_readb(bus, QSFP28_EEPROM_I2C_ADDR, QSFP28_EEPROM_TXRX_LOS_OFFSET, ONLP_I2C_F_FORCE); - if ((optval & (0x0f)) != 0) //bit 0~3 - { - *value = 1; - } - else - { - *value = 0; - } - break; - - case ONLP_SFP_CONTROL_TX_FAULT: - if (onlp_sfpi_is_present(port) == 0) - { - AIM_LOG_INFO("%s:%d fail[%d]\n", __FUNCTION__, __LINE__, ONLP_STATUS_E_MISSING); - return ONLP_STATUS_E_MISSING; - } - optval = onlp_i2c_readb(bus, QSFP28_EEPROM_I2C_ADDR, QSFP28_EEPROM_TX_FAULT_OFFSET, ONLP_I2C_F_FORCE); - if ((optval & (0x0f)) != 0) //bit 0~3 - { - *value = 1; - } - else - { - *value = 0; - } - break; - - case ONLP_SFP_CONTROL_TX_DISABLE: - if (onlp_sfpi_is_present(port) == 0) - { - AIM_LOG_INFO("%s:%d fail[%d]\n", __FUNCTION__, __LINE__, ONLP_STATUS_E_MISSING); - return ONLP_STATUS_E_MISSING; - } - optval = onlp_i2c_readb(bus, QSFP28_EEPROM_I2C_ADDR, QSFP28_EEPROM_TX_DISABLE_OFFSET, ONLP_I2C_F_FORCE); - if ((optval & (0x0f)) != 0) //bit 0~3 - { - *value = 1; - } - else - { - *value = 0; - } - break; - - case ONLP_SFP_CONTROL_TX_DISABLE_CHANNEL: - if (onlp_sfpi_is_present(port) == 0) - { - AIM_LOG_INFO("%s:%d fail[%d]\n", __FUNCTION__, __LINE__, ONLP_STATUS_E_MISSING); - return ONLP_STATUS_E_MISSING; - } - optval = onlp_i2c_readb(bus, QSFP28_EEPROM_I2C_ADDR, QSFP28_EEPROM_TX_DISABLE_OFFSET, ONLP_I2C_F_FORCE); - *value = optval & (0x0f); //bit 0~3 - break; - - case ONLP_SFP_CONTROL_LP_MODE: - optval = onlp_i2c_readb(bus, PORT_CPLD_I2C_ADDR, PORT_CPLD_LOWPWR_ADDR_OFFSET, ONLP_I2C_F_FORCE); - if ((optval & (1 << mod_sel_bit)) != 0) - { - *value = 1; - } - else - { - *value = 0; - } - break; - - case ONLP_SFP_CONTROL_POWER_OVERRIDE: - if (onlp_sfpi_is_present(port) == 0) - { - AIM_LOG_INFO("%s:%d fail[%d]\n", __FUNCTION__, __LINE__, ONLP_STATUS_E_MISSING); - return ONLP_STATUS_E_MISSING; - } - optval = onlp_i2c_readb(bus, QSFP28_EEPROM_I2C_ADDR, QSFP28_EEPROM_POWERSET_OFFSET, ONLP_I2C_F_FORCE); - if ((optval & (0x01)) != 0) //bit 0 - { - *value = 1; - } - else - { - *value = 0; - } - break; - - //Set Only - case ONLP_SFP_CONTROL_RESET: - { - AIM_LOG_INFO("%s:%d fail[%d]\n", __FUNCTION__, __LINE__, ONLP_STATUS_E_INVALID); - return ONLP_STATUS_E_INVALID; - } - default: - break; - } - - DIAG_PRINT("%s, port:%d, control:%d(%s), value:%d", __FUNCTION__, port, control, sfp_control_to_str(control), *value); - - return rv; -} - - -int -onlp_sfpi_denit(void) -{ - DIAG_PRINT("%s", __FUNCTION__); - return ONLP_STATUS_OK; -} diff --git a/packages/platforms/lenovo/x86-64/ne10032/onlp/builds/x86_64_lenovo_ne10032/module/src/sysi.c b/packages/platforms/lenovo/x86-64/ne10032/onlp/builds/x86_64_lenovo_ne10032/module/src/sysi.c deleted file mode 100644 index c147c687f..000000000 --- a/packages/platforms/lenovo/x86-64/ne10032/onlp/builds/x86_64_lenovo_ne10032/module/src/sysi.c +++ /dev/null @@ -1,1398 +0,0 @@ -/************************************************************ - * - * - * Copyright 2014 Big Switch Networks, Inc. - * Copyright 2018 Alpha Networks Incorporation. - * - * Licensed under the Eclipse Public License, Version 1.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.eclipse.org/legal/epl-v10.html - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT 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_lenovo_ne10032_int.h" -#include "x86_64_lenovo_ne10032_log.h" -#include "platform_lib.h" -#include -#include - -#define DEBUG 0 - -#define PSU_NUM_ON_MAIN_BROAD 2 -#define FAN_NUM_ON_MAIN_BROAD 8 -#define LED_NUM_ON_MAIN_BROAD 15 -#define THERMAL_NUM_ON_MAIN_BROAD 2 - -#define SYSTEM_CPLD_I2C_BUS_ID 8 -#define SYSTEM_CPLD_I2C_ADDR 0x5F /* System CPLD Physical Address in the I2C */ -#define SYSTEM_CPLD_REVISION_ADDR_OFFSET 0x00 - -#define ONIE_EEPROM_BUS_ID 0 -#define ONIE_EEPROM_ADDR 0x56 - - - -#define PLATFORM_STRING "x86-64-lenovo-ne10032-r0" - -const char* -onlp_sysi_platform_get(void) -{ - DIAG_PRINT("%s, platform string: %s", __FUNCTION__, PLATFORM_STRING); - return PLATFORM_STRING; -} - -#if 0 -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; -} - -#else // for EEPROM should be read by "i2cdump -y 0 0x56 c"(consecutive byte) -int -onlp_sysi_onie_data_get(uint8_t **data, int *size) -{ - DIAG_PRINT("%s", __FUNCTION__); - int ret = 0; - uint8_t *rdata = aim_zmalloc(256); - - ret = i2c_sequential_read(ONIE_EEPROM_BUS_ID, ONIE_EEPROM_ADDR, 0, 256, (char *)rdata); - if (ret >= 0) - { - *data = rdata; - -#if 0//debug - int i = 0; - for (i=0; - i<256; - i++) - { - if ( i%8 == 0) - { - AIM_LOG_INFO("\n",rdata[i]); - } - AIM_LOG_INFO("0x%2X [%c]",rdata[i],(rdata[i]<=122 && rdata[i] >=65)?rdata[i]:' '); - - } - AIM_LOG_INFO("\n",rdata[i]); -#endif - return ONLP_STATUS_OK; - } - - aim_free(rdata); - *size = 0; - - return ONLP_STATUS_E_INTERNAL; -} - -#endif - -void onlp_sysi_onie_data_free(uint8_t *data) -{ - DIAG_PRINT("%s", __FUNCTION__); - if (data) - aim_free(data); -} - -int -onlp_sysi_platform_info_get(onlp_platform_info_t *pi) -{ - DIAG_PRINT("%s", __FUNCTION__); - int ret = 0; - char data = 0; - - ret = i2c_read_byte(SYSTEM_CPLD_I2C_BUS_ID, SYSTEM_CPLD_I2C_ADDR, SYSTEM_CPLD_REVISION_ADDR_OFFSET, &data); - if (ret < 0) - { - AIM_LOG_INFO("%s:%d fail[%d]\n", __FUNCTION__, __LINE__, ret); - return ret; - } - - pi->cpld_versions = aim_fstrdup("%d", (int)data); - - DIAG_PRINT("%s, cpld_versions:%d", __FUNCTION__, data); - return 0; -} - -void -onlp_sysi_platform_info_free(onlp_platform_info_t *pi) -{ - DIAG_PRINT("%s", __FUNCTION__); - aim_free(pi->cpld_versions); -} - - -int -onlp_sysi_oids_get(onlp_oid_t *table, int max) -{ - DIAG_PRINT("%s, max:%d", __FUNCTION__, max); - onlp_oid_t *e = table; - memset(table, 0, max * sizeof(onlp_oid_t)); - int i; - - uint32_t oid = 0; - - /* PSUs */ - for (i = 1; i <= PSU_NUM_ON_MAIN_BROAD; i++) - { - oid = ONLP_PSU_ID_CREATE(i); - *e++ = oid; - DIAG_PRINT("PSU#%d oid:%d", i, oid); - } - - /* LEDs */ - for (i = 1; i <= LED_NUM_ON_MAIN_BROAD; i++) - { - oid = ONLP_LED_ID_CREATE(i); - *e++ = oid; - DIAG_PRINT("LED#%d oid:%d", i, oid); - } - - /* Thermal sensors */ - for (i = 1; i <= THERMAL_NUM_ON_MAIN_BROAD; i++) - { - oid = ONLP_THERMAL_ID_CREATE(i); - *e++ = oid; - DIAG_PRINT("THERMAL#%d oid:%d", i, oid); - } - - /* Fans */ - for (i = 1; i <= FAN_NUM_ON_MAIN_BROAD; i++) - { - oid = ONLP_FAN_ID_CREATE(i); - *e++ = oid; - DIAG_PRINT("FAN#%d oid:%d", i, oid); - } - - return 0; -} - - -int onlp_sysi_platform_manage_init(void) -{ - DIAG_PRINT("%s", __FUNCTION__); - return 0; -} - -/* - * 1. If any FAN failed, set all the other fans as full speed (100%) - * 2. When (LM75-1 + LM75-2)/2 >= 49.5 C, set fan speed from 50% to 65%. - * 3. When (LM75-1 + LM75-2)/2 >= 53C, set fan speed from 65% to 80% - * 4. When (LM75-1 + LM75-2)/2 >= 57.5C, set fan speed from 80% to 100% - - * 5. When (LM75-1 + LM75-2)/2 <= 52.7C, set fan speed from 100% to 80% - * 6. When (LM75-1 + LM75-2)/2 <= 47.7C, set fan speed from 80% to 65% - * 7. When (LM75-1 + LM75-2)/2 <= 42.7C, set fan speed from 65% to 50% - * 8. The default FAN speed is 50% - */ -int -onlp_sysi_platform_manage_fans(void) -{ - DIAG_PRINT("%s", __FUNCTION__); -#define LEV1_UP_TEMP 57500 /*temperature*/ -#define LEV1_DOWN_TEMP NULL /* unused */ -#define LEV1_SPEED_PERC 100 /*percentage*/ - -#define LEV2_UP_TEMP 53000 -#define LEV2_DOWN_TEMP 52700 -#define LEV2_SPEED_PERC 80 - -#define LEV3_UP_TEMP 49500 -#define LEV3_DOWN_TEMP 47700 -#define LEV3_SPEED_PERC 65 - -#define LEV4_UP_TEMP NULL /* unused */ -#define LEV4_DOWN_TEMP 42700 -#define LEV4_SPEED_PERC 50 - - int rc, i; - int is_up; - int new_temp, temp1, temp2, diff; - static int new_perc = 0, ori_perc = 0; - static int ori_temp = 0; - static int fan_failed = 0; - onlp_thermal_info_t thermal_info; - onlp_fan_info_t fan_info; - - if (diag_debug_pause_platform_manage_check() == 1) //diag test mode - { - return ONLP_STATUS_OK; - } - - /* get new temperature */ - if ((rc = onlp_thermali_info_get(ONLP_THERMAL_ID_CREATE(1), &thermal_info)) != ONLP_STATUS_OK) - goto _EXIT; - - temp1 = thermal_info.mcelsius; - - if ((rc = onlp_thermali_info_get(ONLP_THERMAL_ID_CREATE(2), &thermal_info)) != ONLP_STATUS_OK) - goto _EXIT; - - temp2 = thermal_info.mcelsius; - - new_temp = (temp1 + temp2) / 2; - - /* check fan status */ - for (i = 1; i <= CHASSIS_FAN_COUNT; i++) - { - if ((rc = onlp_fani_info_get(ONLP_FAN_ID_CREATE(i), &fan_info)) != ONLP_STATUS_OK) - goto _EXIT; - - if (fan_info.status & ONLP_FAN_STATUS_FAILED) - { - new_perc = LEV1_SPEED_PERC; - fan_failed = 1; - goto _CTRL; - } - -#if 0 -#define UNKNOW_SPEED_PERC 0 - if( fan_info.rpm < 8800) //to prevent fan speed set too low by user , 8800 = lower bound speed for 50% - { - ori_perc = UNKNOW_SPEED_PERC; - new_perc = LEV4_SPEED_PERC; - fan_failed = 1; - goto _CTRL; - } -#endif - - } - - if (ori_perc == LEV1_SPEED_PERC && fan_failed == 1) - { - fan_failed = 0; - new_perc = LEV4_SPEED_PERC; - goto _CTRL; - } - - diff = new_temp - ori_temp; - - if (diff == 0) - goto _EXIT; - else - is_up = (diff > 0) ? 1 : 0; - - if (is_up) - { - if (new_temp >= LEV1_UP_TEMP) - new_perc = LEV1_SPEED_PERC; - else if (new_temp >= LEV2_UP_TEMP) - new_perc = LEV2_SPEED_PERC; - else if (new_temp >= LEV3_UP_TEMP) - new_perc = LEV3_SPEED_PERC; - else - new_perc = LEV4_SPEED_PERC; - } - else - { - if (new_temp <= LEV4_DOWN_TEMP) - new_perc = LEV4_SPEED_PERC; - else if (new_temp <= LEV3_DOWN_TEMP) - new_perc = LEV3_SPEED_PERC; - else if (new_temp <= LEV2_DOWN_TEMP) - new_perc = LEV2_SPEED_PERC; - else - new_perc = LEV1_SPEED_PERC; - } - -_CTRL : - - if (DEBUG) - printf("\n[%s][%d]{ori:temp=%d, perc=%d} {new:temp=%d, perc=%d}\n", __FUNCTION__, __LINE__, - ori_temp, ori_perc, new_temp, new_perc); - - if (ori_perc == new_perc) - goto _EXIT; - - /* ctrl fans */ -#if 1 //CPLD control all fans by one register. - if ((rc = onlp_fani_percentage_set(ONLP_FAN_ID_CREATE(FAN_1), new_perc)) != ONLP_STATUS_OK) - goto _EXIT; - - AIM_LOG_INFO("Fan%d Speeds are now at %d%%", i, new_perc); -#else - for (i = FAN_1; - i <= FAN_6; - i++) - { - if ((rc = onlp_fani_percentage_set(ONLP_FAN_ID_CREATE(i), new_perc)) != ONLP_STATUS_OK) - goto _EXIT; - - AIM_LOG_INFO("Fan%d Speeds are now at %d%%", i, new_perc); - } -#endif - - /* update om */ - ori_perc = new_perc; - ori_temp = new_temp; - -_EXIT : - - return rc; -} - -int -onlp_sysi_platform_manage_leds(void) -{ - DIAG_PRINT("%s", __FUNCTION__); - int i = 0, j = 0; - onlp_fan_info_t fan_info; - onlp_led_mode_t led_mode = ONLP_LED_MODE_OFF; - onlp_led_mode_t status_led_mode = ONLP_LED_MODE_BLUE_BLINKING; - onlp_psu_info_t psu1_info, psu2_info; - - int fan_ok_count = 0; - int psu_ok_count = 0; - - if (diag_debug_pause_platform_manage_check() == 1) //diag test mode - { - return ONLP_STATUS_OK; - } - - /* - * FAN Indicators - * - * Green - Good - * Amber - Present but failed - * Off - Not present - */ - for (i = FAN_1, j = LED_FAN1; i <= FAN_6; i++, j++) - { - if (onlp_fani_info_get(ONLP_FAN_ID_CREATE(i), &fan_info) != ONLP_STATUS_OK) - { - /* Get fan status fail */ - led_mode = ONLP_LED_MODE_GREEN_BLINKING; - //status_led_mode = ONLP_LED_MODE_BLUE_BLINKING; - } - else if ((fan_info.status & ONLP_FAN_STATUS_PRESENT) == 0) - { - /* Not present -- Off */ - led_mode = ONLP_LED_MODE_GREEN_BLINKING; - } - else if (fan_info.status & ONLP_FAN_STATUS_FAILED) - { - /* Present but Failed */ - led_mode = ONLP_LED_MODE_GREEN_BLINKING; - //status_led_mode = ONLP_LED_MODE_BLUE_BLINKING; - } - else - { - led_mode = ONLP_LED_MODE_GREEN; - fan_ok_count++; - } - - onlp_ledi_mode_set(ONLP_LED_ID_CREATE(j), led_mode); - } - - /* - * PSU Indicators, only one LED indicator for 2 PSUs. - */ - - if ((onlp_psui_info_get(ONLP_PSU_ID_CREATE(PSU1_ID), &psu1_info) != ONLP_STATUS_OK) || - (onlp_psui_info_get(ONLP_PSU_ID_CREATE(PSU2_ID), &psu2_info) != ONLP_STATUS_OK)) - { - /* Get PSU status fail */ - led_mode = ONLP_LED_MODE_GREEN_BLINKING; - //status_led_mode = ONLP_LED_MODE_BLUE_BLINKING; - printf("%s:%d psu1_info.status:0x%08x, psu2_info.status:0x%08x\n", __FUNCTION__, __LINE__, psu1_info.status, psu2_info.status); - } - else if (((psu1_info.status & ONLP_PSU_STATUS_PRESENT) == 0) && - ((psu2_info.status & ONLP_PSU_STATUS_PRESENT) == 0)) - { - /* Not present */ - led_mode = ONLP_LED_MODE_OFF; - } - else if ((psu1_info.status & ONLP_PSU_STATUS_FAILED) || - (psu2_info.status & ONLP_PSU_STATUS_FAILED)) - { - /* Present but Failed */ - led_mode = ONLP_LED_MODE_GREEN_BLINKING; - //status_led_mode = ONLP_LED_MODE_BLUE_BLINKING; - printf("%s:%d psu1_info.status:0x%08x, psu2_info.status:0x%08x\n", __FUNCTION__, __LINE__, psu1_info.status, psu2_info.status); - } - else if ((psu1_info.status & ONLP_PSU_STATUS_UNPLUGGED) && - (psu2_info.status & ONLP_PSU_STATUS_UNPLUGGED)) - { - led_mode = ONLP_LED_MODE_GREEN_BLINKING; - } - else - { - led_mode = ONLP_LED_MODE_GREEN; - psu_ok_count = 2; - } - - onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_PWR), led_mode); - - - if (psu_ok_count == 2 && fan_ok_count == 6) - { - status_led_mode = ONLP_LED_MODE_OFF; - } - - onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_SERVICE), status_led_mode); - - return ONLP_STATUS_OK; -} - -int -onlp_sysi_init(void) -{ - DIAG_PRINT("%s", __FUNCTION__); - return ONLP_STATUS_OK; -} -int onlp_sysi_debug_diag_fan_status(void) -{ - int oid = 0; - int i = 0; - uint32_t status = 0; - for (i = 1; i <= FAN_NUM_ON_MAIN_BROAD; i++) - { - oid = ONLP_FAN_ID_CREATE(i); - onlp_fani_status_get(oid, &status); - printf("FAN#%d oid:%d\n", i, oid); - printf("Status: 0x%x [%s %s]\n", status, - (status & ONLP_FAN_STATUS_PRESENT) ? "PRESENT" : "", - (status & ONLP_FAN_STATUS_FAILED) ? "FAILED" : ""); - } - return 0; - -} - -int onlp_sysi_debug_diag_fan(void) -{ - onlp_fan_info_t fan_info; - - printf("[Set fan speed to 10%% ...]\n"); - onlp_fani_percentage_set(ONLP_FAN_ID_CREATE(FAN_1), 10); - sleep(2); - onlp_fani_info_get(ONLP_FAN_ID_CREATE(FAN_1), &fan_info); - printf("FAN_1 fan_info.percentage = %d\n", fan_info.percentage); - printf("\n"); - getchar(); - - printf("[Set fan speed to 30%% ...]\n"); - onlp_fani_percentage_set(ONLP_FAN_ID_CREATE(FAN_1), 30); - sleep(2); - onlp_fani_info_get(ONLP_FAN_ID_CREATE(FAN_1), &fan_info); - printf("FAN_1 fan_info.percentage = %d\n", fan_info.percentage); - printf("\n"); - getchar(); - - printf("[Set fan speed to 50%% ...]\n"); - onlp_fani_percentage_set(ONLP_FAN_ID_CREATE(FAN_1), 50); - sleep(2); - onlp_fani_info_get(ONLP_FAN_ID_CREATE(FAN_1), &fan_info); - printf("FAN_1 fan_info.percentage = %d\n", fan_info.percentage); - printf("\n"); - getchar(); - - printf("[Set fan speed to 70%% ...]\n"); - onlp_fani_percentage_set(ONLP_FAN_ID_CREATE(FAN_1), 70); - sleep(2); - onlp_fani_info_get(ONLP_FAN_ID_CREATE(FAN_1), &fan_info); - printf("FAN_1 fan_info.percentage = %d\n", fan_info.percentage); - printf("\n"); - getchar(); - - printf("[Set fan speed to 100%% ...]\n"); - onlp_fani_percentage_set(ONLP_FAN_ID_CREATE(FAN_1), 100); - sleep(2); - onlp_fani_info_get(ONLP_FAN_ID_CREATE(FAN_1), &fan_info); - printf("FAN_1 fan_info.percentage = %d\n", fan_info.percentage); - printf("\n"); - getchar(); - - printf("set fan speed to default(50%%) by onlp_fani_init()\n"); - onlp_fani_init(); - return 0; -} - -int onlp_sysi_debug_diag_led(void) -{ - - - printf(" STACKING o o PSU \n"); - printf(" FAN1~6 ----------- \n"); - printf(" | o o | \n"); - printf(" | o o | \n"); - printf(" | o o | \n"); - printf(" SERVICE o ----------- \n"); - - - printf("[Stop platform manage ...]\n"); -#if 1 - diag_debug_pause_platform_manage_on(); -#else - onlp_sys_platform_manage_stop(0); -#endif - sleep(1); - - printf("[Set All LED to OFF ...]\n"); - onlp_ledi_set(ONLP_LED_ID_CREATE(LED_SERVICE), ONLP_LED_MODE_OFF); - onlp_ledi_set(ONLP_LED_ID_CREATE(LED_STACKING), ONLP_LED_MODE_OFF); - onlp_ledi_set(ONLP_LED_ID_CREATE(LED_PWR), ONLP_LED_MODE_OFF); - onlp_ledi_set(ONLP_LED_ID_CREATE(LED_FAN1), ONLP_LED_MODE_OFF); - onlp_ledi_set(ONLP_LED_ID_CREATE(LED_FAN2), ONLP_LED_MODE_OFF); - onlp_ledi_set(ONLP_LED_ID_CREATE(LED_FAN3), ONLP_LED_MODE_OFF); - onlp_ledi_set(ONLP_LED_ID_CREATE(LED_FAN4), ONLP_LED_MODE_OFF); - onlp_ledi_set(ONLP_LED_ID_CREATE(LED_FAN5), ONLP_LED_MODE_OFF); - onlp_ledi_set(ONLP_LED_ID_CREATE(LED_FAN6), ONLP_LED_MODE_OFF); - onlp_ledi_set(ONLP_LED_ID_CREATE(LED_REAR_FAN1), ONLP_LED_MODE_OFF); - onlp_ledi_set(ONLP_LED_ID_CREATE(LED_REAR_FAN2), ONLP_LED_MODE_OFF); - onlp_ledi_set(ONLP_LED_ID_CREATE(LED_REAR_FAN3), ONLP_LED_MODE_OFF); - onlp_ledi_set(ONLP_LED_ID_CREATE(LED_REAR_FAN4), ONLP_LED_MODE_OFF); - onlp_ledi_set(ONLP_LED_ID_CREATE(LED_REAR_FAN5), ONLP_LED_MODE_OFF); - onlp_ledi_set(ONLP_LED_ID_CREATE(LED_REAR_FAN6), ONLP_LED_MODE_OFF); - printf("\n"); - getchar(); - - - printf("[Set SERVICE LED to ONLP_LED_MODE_BLUE ...]\n"); - onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_SERVICE), ONLP_LED_MODE_BLUE); - printf("\n"); - getchar(); - printf("[Set SERVICE LED to ONLP_LED_MODE_BLUE_BLINKING ...]\n"); - onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_SERVICE), ONLP_LED_MODE_BLUE_BLINKING); - printf("\n"); - getchar(); - - printf("[Set STACKING LED to ONLP_LED_MODE_ORANGE ...]\n"); - onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_STACKING), ONLP_LED_MODE_ORANGE); - printf("\n"); - getchar(); - printf("[Set STACKING LED to ONLP_LED_MODE_ORANGE_BLINKING ...]\n"); - onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_STACKING), ONLP_LED_MODE_ORANGE_BLINKING); - printf("\n"); - getchar(); - printf("[Set STACKING LED to ONLP_LED_MODE_GREEN ...]\n"); - onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_STACKING), ONLP_LED_MODE_GREEN); - printf("\n"); - getchar(); - printf("[Set STACKING LED to ONLP_LED_MODE_GREEN_BLINKING ...]\n"); - onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_STACKING), ONLP_LED_MODE_GREEN_BLINKING); - printf("\n"); - getchar(); - - printf("[Set PSU LED to ONLP_LED_MODE_ORANGE ...]\n"); - onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_PWR), ONLP_LED_MODE_ORANGE); - printf("\n"); - getchar(); - printf("[Set PSU LED to ONLP_LED_MODE_ORANGE_BLINKING ...]\n"); - onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_PWR), ONLP_LED_MODE_ORANGE_BLINKING); - printf("\n"); - getchar(); - printf("[Set PSU LED to ONLP_LED_MODE_GREEN ...]\n"); - onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_PWR), ONLP_LED_MODE_GREEN); - printf("\n"); - getchar(); - printf("[Set PSU LED to ONLP_LED_MODE_GREEN_BLINKING ...]\n"); - onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_PWR), ONLP_LED_MODE_GREEN_BLINKING); - printf("\n"); - getchar(); - - printf("[Set FAN1 LED to ONLP_LED_MODE_ORANGE ...]\n"); - onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_FAN1), ONLP_LED_MODE_ORANGE); - printf("\n"); - getchar(); - printf("[Set FAN1 LED to ONLP_LED_MODE_ORANGE_BLINKING ...]\n"); - onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_FAN1), ONLP_LED_MODE_ORANGE_BLINKING); - printf("\n"); - getchar(); - printf("[Set FAN1 LED to ONLP_LED_MODE_GREEN ...]\n"); - onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_FAN1), ONLP_LED_MODE_GREEN); - printf("\n"); - getchar(); - printf("[Set FAN1 LED to ONLP_LED_MODE_GREEN_BLINKING ...]\n"); - onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_FAN1), ONLP_LED_MODE_GREEN_BLINKING); - printf("\n"); - getchar(); - - printf("[Set FAN2 LED to ONLP_LED_MODE_ORANGE ...]\n"); - onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_FAN2), ONLP_LED_MODE_ORANGE); - printf("\n"); - getchar(); - printf("[Set FAN2 LED to ONLP_LED_MODE_ORANGE_BLINKING ...]\n"); - onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_FAN2), ONLP_LED_MODE_ORANGE_BLINKING); - printf("\n"); - getchar(); - printf("[Set FAN2 LED to ONLP_LED_MODE_GREEN ...]\n"); - onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_FAN2), ONLP_LED_MODE_GREEN); - printf("\n"); - getchar(); - printf("[Set FAN2 LED to ONLP_LED_MODE_GREEN_BLINKING ...]\n"); - onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_FAN2), ONLP_LED_MODE_GREEN_BLINKING); - printf("\n"); - getchar(); - - printf("[Set FAN3 LED to ONLP_LED_MODE_ORANGE ...]\n"); - onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_FAN3), ONLP_LED_MODE_ORANGE); - printf("\n"); - getchar(); - printf("[Set FAN3 LED to ONLP_LED_MODE_ORANGE_BLINKING ...]\n"); - onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_FAN3), ONLP_LED_MODE_ORANGE_BLINKING); - printf("\n"); - getchar(); - printf("[Set FAN3 LED to ONLP_LED_MODE_GREEN ...]\n"); - onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_FAN3), ONLP_LED_MODE_GREEN); - printf("\n"); - getchar(); - printf("[Set FAN3 LED to ONLP_LED_MODE_GREEN_BLINKING ...]\n"); - onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_FAN3), ONLP_LED_MODE_GREEN_BLINKING); - printf("\n"); - getchar(); - - printf("[Set FAN4 LED to ONLP_LED_MODE_ORANGE ...]\n"); - onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_FAN4), ONLP_LED_MODE_ORANGE); - printf("\n"); - getchar(); - printf("[Set FAN4 LED to ONLP_LED_MODE_ORANGE_BLINKING ...]\n"); - onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_FAN4), ONLP_LED_MODE_ORANGE_BLINKING); - printf("\n"); - getchar(); - printf("[Set FAN4 LED to ONLP_LED_MODE_GREEN ...]\n"); - onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_FAN4), ONLP_LED_MODE_GREEN); - printf("\n"); - getchar(); - printf("[Set FAN4 LED to ONLP_LED_MODE_GREEN_BLINKING ...]\n"); - onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_FAN4), ONLP_LED_MODE_GREEN_BLINKING); - printf("\n"); - getchar(); - - printf("[Set FAN5 LED to ONLP_LED_MODE_ORANGE ...]\n"); - onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_FAN5), ONLP_LED_MODE_ORANGE); - printf("\n"); - getchar(); - printf("[Set FAN5 LED to ONLP_LED_MODE_ORANGE_BLINKING ...]\n"); - onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_FAN5), ONLP_LED_MODE_ORANGE_BLINKING); - printf("\n"); - getchar(); - printf("[Set FAN5 LED to ONLP_LED_MODE_GREEN ...]\n"); - onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_FAN5), ONLP_LED_MODE_GREEN); - printf("\n"); - getchar(); - printf("[Set FAN5 LED to ONLP_LED_MODE_GREEN_BLINKING ...]\n"); - onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_FAN5), ONLP_LED_MODE_GREEN_BLINKING); - printf("\n"); - getchar(); - - printf("[Set FAN6 LED to ONLP_LED_MODE_ORANGE ...]\n"); - onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_FAN6), ONLP_LED_MODE_ORANGE); - printf("\n"); - getchar(); - printf("[Set FAN6 LED to ONLP_LED_MODE_ORANGE_BLINKING ...]\n"); - onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_FAN6), ONLP_LED_MODE_ORANGE_BLINKING); - printf("\n"); - getchar(); - printf("[Set FAN6 LED to ONLP_LED_MODE_GREEN ...]\n"); - onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_FAN6), ONLP_LED_MODE_GREEN); - printf("\n"); - getchar(); - printf("[Set FAN6 LED to ONLP_LED_MODE_GREEN_BLINKING ...]\n"); - onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_FAN6), ONLP_LED_MODE_GREEN_BLINKING); - printf("\n"); - getchar(); - - printf("[Set REAR FAN1 LED to ONLP_LED_MODE_GREEN ...]\n"); - onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_REAR_FAN1), ONLP_LED_MODE_GREEN); - printf("\n"); - getchar(); - printf("[Set REAR FAN1 LED to ONLP_LED_MODE_GREEN_BLINKING ...]\n"); - onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_REAR_FAN1), ONLP_LED_MODE_GREEN_BLINKING); - printf("\n"); - getchar(); - - printf("[Set REAR FAN2 LED to ONLP_LED_MODE_GREEN ...]\n"); - onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_REAR_FAN2), ONLP_LED_MODE_GREEN); - printf("\n"); - getchar(); - printf("[Set REAR FAN2 LED to ONLP_LED_MODE_GREEN_BLINKING ...]\n"); - onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_REAR_FAN2), ONLP_LED_MODE_GREEN_BLINKING); - printf("\n"); - getchar(); - - printf("[Set REAR FAN3 LED to ONLP_LED_MODE_GREEN ...]\n"); - onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_REAR_FAN3), ONLP_LED_MODE_GREEN); - printf("\n"); - getchar(); - printf("[Set REAR FAN3 LED to ONLP_LED_MODE_GREEN_BLINKING ...]\n"); - onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_REAR_FAN3), ONLP_LED_MODE_GREEN_BLINKING); - printf("\n"); - getchar(); - - printf("[Set REAR FAN4 LED to ONLP_LED_MODE_GREEN ...]\n"); - onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_REAR_FAN4), ONLP_LED_MODE_GREEN); - printf("\n"); - getchar(); - printf("[Set REAR FAN4 LED to ONLP_LED_MODE_GREEN_BLINKING ...]\n"); - onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_REAR_FAN4), ONLP_LED_MODE_GREEN_BLINKING); - printf("\n"); - getchar(); - - printf("[Set REAR FAN5 LED to ONLP_LED_MODE_GREEN ...]\n"); - onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_REAR_FAN5), ONLP_LED_MODE_GREEN); - printf("\n"); - getchar(); - printf("[Set REAR FAN5 LED to ONLP_LED_MODE_GREEN_BLINKING ...]\n"); - onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_REAR_FAN5), ONLP_LED_MODE_GREEN_BLINKING); - printf("\n"); - getchar(); - - printf("[Set REAR FAN6 LED to ONLP_LED_MODE_GREEN ...]\n"); - onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_REAR_FAN6), ONLP_LED_MODE_GREEN); - printf("\n"); - getchar(); - printf("[Set REAR FAN6 LED to ONLP_LED_MODE_GREEN_BLINKING ...]\n"); - onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_REAR_FAN6), ONLP_LED_MODE_GREEN_BLINKING); - printf("\n"); - getchar(); - - printf("[Set All LED to OFF ...]\n"); - onlp_ledi_set(ONLP_LED_ID_CREATE(LED_SERVICE), ONLP_LED_MODE_OFF); - onlp_ledi_set(ONLP_LED_ID_CREATE(LED_STACKING), ONLP_LED_MODE_OFF); - onlp_ledi_set(ONLP_LED_ID_CREATE(LED_PWR), ONLP_LED_MODE_OFF); - onlp_ledi_set(ONLP_LED_ID_CREATE(LED_FAN1), ONLP_LED_MODE_OFF); - onlp_ledi_set(ONLP_LED_ID_CREATE(LED_FAN2), ONLP_LED_MODE_OFF); - onlp_ledi_set(ONLP_LED_ID_CREATE(LED_FAN3), ONLP_LED_MODE_OFF); - onlp_ledi_set(ONLP_LED_ID_CREATE(LED_FAN4), ONLP_LED_MODE_OFF); - onlp_ledi_set(ONLP_LED_ID_CREATE(LED_FAN5), ONLP_LED_MODE_OFF); - onlp_ledi_set(ONLP_LED_ID_CREATE(LED_FAN6), ONLP_LED_MODE_OFF); - onlp_ledi_set(ONLP_LED_ID_CREATE(LED_REAR_FAN1), ONLP_LED_MODE_OFF); - onlp_ledi_set(ONLP_LED_ID_CREATE(LED_REAR_FAN2), ONLP_LED_MODE_OFF); - onlp_ledi_set(ONLP_LED_ID_CREATE(LED_REAR_FAN3), ONLP_LED_MODE_OFF); - onlp_ledi_set(ONLP_LED_ID_CREATE(LED_REAR_FAN4), ONLP_LED_MODE_OFF); - onlp_ledi_set(ONLP_LED_ID_CREATE(LED_REAR_FAN5), ONLP_LED_MODE_OFF); - onlp_ledi_set(ONLP_LED_ID_CREATE(LED_REAR_FAN6), ONLP_LED_MODE_OFF); - - printf("[Restart platform manage ...]\n"); - onlp_ledi_init(); -#if 1 - diag_debug_pause_platform_manage_off(); -#else - onlp_sys_platform_manage_start(0); -#endif - return 0; -} - -#define SFP_DIAG_ADDR 114 //the reserved bytes 114~118 support r/w in SFF-8636 standard -#define SFP_DIAG_PATTEN_B 0xAA -#define SFP_DIAG_PATTEN_W 0xABCD - -int onlp_sysi_debug_diag_sfp(int index) -{ - uint8_t *data = NULL; - int rv = 0; - - uint8_t org_b = 0; - uint16_t org_w = 0; - uint8_t temp_b = 0; - uint16_t temp_w = 0; - - data = aim_zmalloc(256); - if ((rv = onlp_sfpi_eeprom_read(index, data)) < 0) - { - - aim_printf(&aim_pvs_stdout, "Error reading eeprom: %{onlp_status}\n"); - } - else - { - aim_printf(&aim_pvs_stdout, "dump eeprom:\n%{data}\n", data, 256); - } - aim_free(data); - data = NULL; - -//BYTE - printf("Read/Write byte test...\n"); - org_b = onlp_sfpi_dev_readb(index, QSFP28_EEPROM_I2C_ADDR, SFP_DIAG_ADDR); - if (org_b < 0) - { - printf("Error, read failed!"); - goto DONE; - } - rv = onlp_sfpi_dev_writeb(index, QSFP28_EEPROM_I2C_ADDR, SFP_DIAG_ADDR, SFP_DIAG_PATTEN_B); - if (rv < 0) - { - printf("Error, write failed!"); - goto DONE; - } - sleep(2); - temp_b = onlp_sfpi_dev_readb(index, QSFP28_EEPROM_I2C_ADDR, SFP_DIAG_ADDR); - if (temp_b < 0) - { - printf("Error, read failed!"); - goto DONE; - } - if (temp_b != SFP_DIAG_PATTEN_B) - { - printf("Error, mismatch!"); - goto DONE; - } - rv = onlp_sfpi_dev_writeb(index, QSFP28_EEPROM_I2C_ADDR, SFP_DIAG_ADDR, org_b); - if (rv < 0) - { - printf("Error, write failed!"); - goto DONE; - } - sleep(2); -//WORD - printf("Read/Write word test...\n"); - org_w = onlp_sfpi_dev_readw(index, QSFP28_EEPROM_I2C_ADDR, SFP_DIAG_ADDR); - if (org_w < 0) - { - printf("Error, read failed!"); - goto DONE; - } - rv = onlp_sfpi_dev_writew(index, QSFP28_EEPROM_I2C_ADDR, SFP_DIAG_ADDR, SFP_DIAG_PATTEN_W); - if (rv < 0) - { - printf("Error, write failed!"); - goto DONE; - } - sleep(2); - temp_w = onlp_sfpi_dev_readw(index, QSFP28_EEPROM_I2C_ADDR, SFP_DIAG_ADDR); - if (temp_w < 0) - { - printf("Error, read failed!"); - goto DONE; - } - if (temp_w != SFP_DIAG_PATTEN_W) - { - printf("Error, mismatch!"); - goto DONE; - } - rv = onlp_sfpi_dev_writew(index, QSFP28_EEPROM_I2C_ADDR, SFP_DIAG_ADDR, org_w); - if (rv < 0) - { - printf("Error, write failed!"); - goto DONE; - } - -DONE: - return 0; -} - -int onlp_sysi_debug_diag_sfp_dom(int index) -{ - uint8_t *data = NULL; - int rv = 0; - - data = aim_zmalloc(256); - if ((rv = onlp_sfpi_dom_read(index, data)) < 0) - { - - aim_printf(&aim_pvs_stdout, "Error reading dom eeprom: %{onlp_status}\n"); - } - else - { - aim_printf(&aim_pvs_stdout, "dump DOM eeprom:\n%{data}\n", data, 256); - } - aim_free(data); - data = NULL; - - return 0; -} - -int onlp_sysi_debug_diag_sfp_ctrl(int index) -{ - int val = 0; - - printf("[Option: %d(%s)... Set]\n", ONLP_SFP_CONTROL_RESET, sfp_control_to_str(ONLP_SFP_CONTROL_RESET)); - printf("[Set %s...]\n", sfp_control_to_str(ONLP_SFP_CONTROL_RESET)); - onlp_sfpi_control_set(index, ONLP_SFP_CONTROL_RESET, 1); - sleep(1); - printf("\n"); - getchar(); - - - printf("[Option: %d(%s)...Set/Get]\n", ONLP_SFP_CONTROL_RESET_STATE, sfp_control_to_str(ONLP_SFP_CONTROL_RESET_STATE)); - printf("[Set %s... to 1]\n", sfp_control_to_str(ONLP_SFP_CONTROL_RESET_STATE)); - onlp_sfpi_control_set(index, ONLP_SFP_CONTROL_RESET_STATE, 1); - sleep(1); - printf("[Get %s... ]\n", sfp_control_to_str(ONLP_SFP_CONTROL_RESET_STATE)); - onlp_sfpi_control_get(index, ONLP_SFP_CONTROL_RESET_STATE, &val); - printf("\n"); - getchar(); - - printf("[Set %s... to 0]\n", sfp_control_to_str(ONLP_SFP_CONTROL_RESET_STATE)); - onlp_sfpi_control_set(index, ONLP_SFP_CONTROL_RESET_STATE, 0); - sleep(1); - printf("[Get %s... ]\n", sfp_control_to_str(ONLP_SFP_CONTROL_RESET_STATE)); - onlp_sfpi_control_get(index, ONLP_SFP_CONTROL_RESET_STATE, &val); - printf("\n"); - getchar(); - - printf("[Option: %d(%s)...Get]\n", ONLP_SFP_CONTROL_RX_LOS, sfp_control_to_str(ONLP_SFP_CONTROL_RX_LOS)); - printf("[Get %s... ]\n", sfp_control_to_str(ONLP_SFP_CONTROL_RX_LOS)); - onlp_sfpi_control_get(index, ONLP_SFP_CONTROL_RX_LOS, &val); - printf("\n"); - getchar(); - - printf("[Option: %d(%s)...Get]\n", ONLP_SFP_CONTROL_TX_FAULT, sfp_control_to_str(ONLP_SFP_CONTROL_TX_FAULT)); - printf("[Get %s... ]\n", sfp_control_to_str(ONLP_SFP_CONTROL_TX_FAULT)); - onlp_sfpi_control_get(index, ONLP_SFP_CONTROL_TX_FAULT, &val); - printf("\n"); - getchar(); - - printf("[Option: %d(%s)...Set/Get]\n", ONLP_SFP_CONTROL_TX_DISABLE, sfp_control_to_str(ONLP_SFP_CONTROL_TX_DISABLE)); - printf("[Set %s... to 1]\n", sfp_control_to_str(ONLP_SFP_CONTROL_TX_DISABLE)); - onlp_sfpi_control_set(index, ONLP_SFP_CONTROL_TX_DISABLE, 1); - sleep(1); - printf("[Get %s... ]\n", sfp_control_to_str(ONLP_SFP_CONTROL_TX_DISABLE)); - onlp_sfpi_control_get(index, ONLP_SFP_CONTROL_TX_DISABLE, &val); - printf("\n"); - getchar(); - - printf("[Set %s... to 0]\n", sfp_control_to_str(ONLP_SFP_CONTROL_TX_DISABLE)); - onlp_sfpi_control_set(index, ONLP_SFP_CONTROL_TX_DISABLE, 0); - sleep(1); - printf("[Get %s... ]\n", sfp_control_to_str(ONLP_SFP_CONTROL_TX_DISABLE)); - onlp_sfpi_control_get(index, ONLP_SFP_CONTROL_TX_DISABLE, &val); - printf("\n"); - getchar(); - - printf("[Option: %d(%s)...Set/Get]\n", ONLP_SFP_CONTROL_TX_DISABLE_CHANNEL, sfp_control_to_str(ONLP_SFP_CONTROL_TX_DISABLE_CHANNEL)); - printf("[Set %s... to 0x05]\n", sfp_control_to_str(ONLP_SFP_CONTROL_TX_DISABLE_CHANNEL)); - onlp_sfpi_control_set(index, ONLP_SFP_CONTROL_TX_DISABLE_CHANNEL, 0x05); - sleep(1); - printf("[Get %s... ]\n", sfp_control_to_str(ONLP_SFP_CONTROL_TX_DISABLE_CHANNEL)); - onlp_sfpi_control_get(index, ONLP_SFP_CONTROL_TX_DISABLE_CHANNEL, &val); - printf("\n"); - getchar(); - - printf("[Set %s... to 0]\n", sfp_control_to_str(ONLP_SFP_CONTROL_TX_DISABLE_CHANNEL)); - onlp_sfpi_control_set(index, ONLP_SFP_CONTROL_TX_DISABLE_CHANNEL, 0); - sleep(1); - printf("[Get %s... ]\n", sfp_control_to_str(ONLP_SFP_CONTROL_TX_DISABLE_CHANNEL)); - onlp_sfpi_control_get(index, ONLP_SFP_CONTROL_TX_DISABLE_CHANNEL, &val); - printf("\n"); - getchar(); - - printf("[Option: %d(%s)...Set/Get]\n", ONLP_SFP_CONTROL_LP_MODE, sfp_control_to_str(ONLP_SFP_CONTROL_LP_MODE)); - printf("[Set %s... to 1]\n", sfp_control_to_str(ONLP_SFP_CONTROL_LP_MODE)); - onlp_sfpi_control_set(index, ONLP_SFP_CONTROL_LP_MODE, 1); - sleep(1); - printf("[Get %s... ]\n", sfp_control_to_str(ONLP_SFP_CONTROL_LP_MODE)); - onlp_sfpi_control_get(index, ONLP_SFP_CONTROL_LP_MODE, &val); - printf("\n"); - getchar(); - - printf("[Set %s... to 0]\n", sfp_control_to_str(ONLP_SFP_CONTROL_LP_MODE)); - onlp_sfpi_control_set(index, ONLP_SFP_CONTROL_LP_MODE, 0); - sleep(1); - printf("[Get %s... ]\n", sfp_control_to_str(ONLP_SFP_CONTROL_LP_MODE)); - onlp_sfpi_control_get(index, ONLP_SFP_CONTROL_LP_MODE, &val); - printf("\n"); - getchar(); - - printf("[Option: %d(%s)...Set/Get]\n", ONLP_SFP_CONTROL_POWER_OVERRIDE, sfp_control_to_str(ONLP_SFP_CONTROL_POWER_OVERRIDE)); - printf("[Set %s... to 1]\n", sfp_control_to_str(ONLP_SFP_CONTROL_POWER_OVERRIDE)); - onlp_sfpi_control_set(index, ONLP_SFP_CONTROL_POWER_OVERRIDE, 1); - sleep(1); - printf("[Get %s... ]\n", sfp_control_to_str(ONLP_SFP_CONTROL_POWER_OVERRIDE)); - onlp_sfpi_control_get(index, ONLP_SFP_CONTROL_POWER_OVERRIDE, &val); - printf("\n"); - getchar(); - - printf("[Set %s... to 0]\n", sfp_control_to_str(ONLP_SFP_CONTROL_POWER_OVERRIDE)); - onlp_sfpi_control_set(index, ONLP_SFP_CONTROL_POWER_OVERRIDE, 0); - sleep(1); - printf("[Get %s... ]\n", sfp_control_to_str(ONLP_SFP_CONTROL_POWER_OVERRIDE)); - onlp_sfpi_control_get(index, ONLP_SFP_CONTROL_POWER_OVERRIDE, &val); - printf("\n"); - getchar(); - - return 0; -} - -int -onlp_sysi_debug(aim_pvs_t *pvs, int argc, char *argv[]) -{ - int ret = 0; - - /* ONLPI driver APIs debug */ - - if (argc > 0 && !strcmp(argv[0], "sys")) - { - diag_flag_set(DIAG_FLAG_ON); - printf("DIAG for SYS: \n"); - printf("Platform : %s\n", onlp_sysi_platform_get()); - onlp_sysi_init(); - onlp_sysi_platform_manage_init(); - diag_flag_set(DIAG_FLAG_OFF); - } - else if (argc > 0 && !strcmp(argv[0], "fan_rpm")) - { - onlp_fan_info_t fan_info; - int i = 0; - diag_flag_set(DIAG_FLAG_ON); - printf("DIAG for FAN rpm: \n"); - - int rpm = 0; - if (argc != 2) - { - printf("Parameter error, format: onlpdump debugi fan_rpm [RPM]\n"); - return -1; - } - rpm = atoi(argv[1]); - onlp_fani_rpm_set(ONLP_FAN_ID_CREATE(FAN_1), rpm); - - sleep(5); - for (i = 1; i <= CHASSIS_FAN_COUNT; i++) - { - onlp_fani_info_get(ONLP_FAN_ID_CREATE(i), &fan_info); - printf("FAN#%d RPM:%d\n", i, fan_info.rpm); - } - - diag_flag_set(DIAG_FLAG_OFF); - } - else if (argc > 0 && !strcmp(argv[0], "fan_status")) - { - diag_flag_set(DIAG_FLAG_ON); - printf("DIAG for FAN status: \n"); - onlp_sysi_debug_diag_fan_status(); - diag_flag_set(DIAG_FLAG_OFF); - } - else if (argc > 0 && !strcmp(argv[0], "fan")) - { - diag_flag_set(DIAG_FLAG_ON); - onlp_sysi_debug_diag_fan(); - diag_flag_set(DIAG_FLAG_OFF); - } - else if (argc > 0 && !strcmp(argv[0], "psu")) - { - printf("DIAG for PSU: \n"); - diag_flag_set(DIAG_FLAG_ON); - onlp_psui_init(); - diag_flag_set(DIAG_FLAG_OFF); - - } - else if (argc > 0 && !strcmp(argv[0], "led")) - { - printf("DIAG for LED: \n"); - diag_flag_set(DIAG_FLAG_ON); - onlp_sysi_debug_diag_led(); - diag_flag_set(DIAG_FLAG_OFF); - } - else if (argc > 0 && !strcmp(argv[0], "sfp_dom")) - { - int port_index = 0; - if (argc != 2) - { - printf("Parameter error, format: onlpdump debugi sfp_dom [PORT]\n"); - return -1; - } - port_index = atoi(argv[1]); - if (port_index <= 0 || port_index > NUM_OF_SFP_PORT) - { - printf("Parameter error, PORT out of range.\n"); - return -1; - } - printf("DIAG for SFP DOM #%d: \n", port_index - 1); - diag_flag_set(DIAG_FLAG_ON); - onlp_sysi_debug_diag_sfp_dom(port_index - 1); - diag_flag_set(DIAG_FLAG_OFF); - } - else if (argc > 0 && !strcmp(argv[0], "sfp_ctrl_set")) - { - int port_index = 0, ctrl = 0, val = 0; - if (argc != 4) - { - printf("Parameter error, format: onlpdump debugi sfp_ctrl_set [PORT] [CTRL] [VALUE]\n"); - return -1; - } - port_index = atoi(argv[1]); - if (port_index <= 0 || port_index > NUM_OF_SFP_PORT) - { - printf("Parameter error, PORT out of range.\n"); - return -1; - } - ctrl = atoi(argv[2]); - val = atoi(argv[3]); - diag_flag_set(DIAG_FLAG_ON); - onlp_sfpi_control_set(port_index - 1, ctrl, val); - diag_flag_set(DIAG_FLAG_OFF); - - } - else if (argc > 0 && !strcmp(argv[0], "sfp_ctrl_get")) - { - int port_index = 0, ctrl = 0, val = 0; - if (argc != 3) - { - printf("Parameter error, format: onlpdump debugi sfp_ctrl_get [PORT] [CTRL] \n"); - return -1; - } - port_index = atoi(argv[1]); - if (port_index <= 0 || port_index > NUM_OF_SFP_PORT) - { - printf("Parameter error, PORT out of range.\n"); - return -1; - } - ctrl = atoi(argv[2]); - diag_flag_set(DIAG_FLAG_ON); - onlp_sfpi_control_get(port_index - 1, ctrl, &val); - printf("Value = %d(0x%X)\n", val, val); - diag_flag_set(DIAG_FLAG_OFF); - - } - else if (argc > 0 && !strcmp(argv[0], "sfp_ctrl")) - { - int port_index = 0; - if (argc != 2) - { - printf("Parameter error, format: onlpdump debugi sfp_ctrl [PORT]\n"); - return -1; - } - port_index = atoi(argv[1]); - if (port_index <= 0 || port_index > NUM_OF_SFP_PORT) - { - printf("Parameter error, PORT out of range.\n"); - return -1; - } - - printf("DIAG for SFP Control #%d: \n", port_index - 1); - diag_flag_set(DIAG_FLAG_ON); - onlp_sysi_debug_diag_sfp_ctrl(port_index - 1); - diag_flag_set(DIAG_FLAG_OFF); - } - else if (argc > 0 && !strcmp(argv[0], "sfp")) - { - if (argc > 1) - { - int port_index = atoi(argv[1]); - if (port_index <= 0 || port_index > NUM_OF_SFP_PORT) - { - printf("Parameter error, PORT out of range.\n"); - return -1; - } - printf("DIAG for SFP#%d: \n", port_index - 1); - diag_flag_set(DIAG_FLAG_ON); - onlp_sysi_debug_diag_sfp(port_index - 1); - diag_flag_set(DIAG_FLAG_OFF); - } - else - { - printf("DIAG for SFP: \n"); - onlp_sfp_bitmap_t bmap; - diag_flag_set(DIAG_FLAG_ON); - - onlp_sfpi_denit(); - onlp_sfpi_init(); - - onlp_sfp_bitmap_t_init(&bmap); - ret = onlp_sfpi_bitmap_get(&bmap); - if (ret < 0) - { - printf("Error, onlp_sfpi_bitmap_get failed!\n"); - } - else - { - aim_printf(&aim_pvs_stdout, "sfp_bitmap:\n %{aim_bitmap}\n", &bmap); - } - diag_flag_set(DIAG_FLAG_OFF); - - return 0; - } - } - else if (argc > 0 && !strcmp(argv[0], "sfpwb")) //write byte - { - int port; - uint8_t addr, value; - - if (argc == 4) - { - port = atoi(argv[1]); - addr = (uint8_t)atoi(argv[2]); - value = (uint8_t)atoi(argv[3]); - - if (port <= 0 || port > NUM_OF_SFP_PORT) - { - printf("Parameter error, PORT out of range.\n"); - return -1; - } - - diag_flag_set(DIAG_FLAG_ON); - onlp_sfpi_dev_writeb(port - 1, QSFP28_EEPROM_I2C_ADDR, addr, value); - diag_flag_set(DIAG_FLAG_OFF); - } - else - { - printf("Parameter error, format: onlpdump debugi sfpwb [PORT] [ADDR] [VALUE]\n"); - return -1; - } - - } - else if (argc > 0 && !strcmp(argv[0], "sfprb")) //read byte - { - int port; - uint8_t addr; - if (argc == 3) - { - port = atoi(argv[1]); - addr = (uint8_t)atoi(argv[2]); - - if (port <= 0 || port > NUM_OF_SFP_PORT) - { - printf("Parameter error, PORT out of range.\n"); - return -1; - } - - diag_flag_set(DIAG_FLAG_ON); - onlp_sfpi_dev_readb(port - 1, QSFP28_EEPROM_I2C_ADDR, addr); - diag_flag_set(DIAG_FLAG_OFF); - } - else - { - printf("Parameter error, format: onlpdump debugi sfprb [PORT] [ADDR]\n"); - return -1; - } - } - else if (argc > 0 && !strcmp(argv[0], "sfpww")) //write word - { - int port; - uint16_t value; - uint8_t addr; - - if (argc == 4) - { - port = atoi(argv[1]); - addr = (uint8_t)atoi(argv[2]); - value = (uint16_t)atoi(argv[3]); - - if (port <= 0 || port > NUM_OF_SFP_PORT) - { - printf("Parameter error, PORT out of range.\n"); - return -1; - } - - diag_flag_set(DIAG_FLAG_ON); - onlp_sfpi_dev_writew(port - 1, QSFP28_EEPROM_I2C_ADDR, addr, value); - diag_flag_set(DIAG_FLAG_OFF); - } - else - { - printf("Parameter error, format: onlpdump debugi sfpwb [PORT] [ADDR] [VALUE]\n"); - return -1; - } - } - else if (argc > 0 && !strcmp(argv[0], "sfprw")) //read word - { - int port; - uint8_t addr; - if (argc == 3) - { - port = atoi(argv[1]); - addr = (uint8_t)atoi(argv[2]); - - if (port <= 0 || port > NUM_OF_SFP_PORT) - { - printf("Parameter error, PORT out of range.\n"); - return -1; - } - - diag_flag_set(DIAG_FLAG_ON); - onlp_sfpi_dev_readw(port - 1, QSFP28_EEPROM_I2C_ADDR, addr); - diag_flag_set(DIAG_FLAG_OFF); - } - else - { - printf("Parameter error, format: onlpdump debugi sfprb [PORT] [ADDR]\n"); - return -1; - } - } - else if (argc > 0 && !strcmp(argv[0], "thermal")) - { - printf("DIAG for Thermal: \n"); - diag_flag_set(DIAG_FLAG_ON); - onlp_thermali_init(); - diag_flag_set(DIAG_FLAG_OFF); - } - else if (argc > 0 && !strcmp(argv[0], "trace_on")) - { - diag_debug_trace_on(); - DIAG_PRINT("%s, ONLPI TRACE: ON", __FUNCTION__); - } - else if (argc > 0 && !strcmp(argv[0], "trace_off")) - { - diag_debug_trace_off(); - DIAG_PRINT("%s, ONLPI TRACE: OFF", __FUNCTION__); - } - else if (argc > 0 && !strcmp(argv[0], "help")) - { - printf("\nUsage: onlpdump debugi [OPTION]\n"); - printf(" help : this message.\n"); - printf(" trace_on : turn on ONLPI debug trace message output on screen.\n"); - printf(" trace_off : turn off ONLPI debug trace message output on screen.\n"); - printf(" sys : run system ONLPI diagnostic function.\n"); - printf(" fan : run fan ONLPI diagnostic function.\n"); - printf(" fan_status : run fan status ONLPI diagnostic function.\n"); - printf(" fan_rpm : run fan RPM ONLPI diagnostic function.\n"); - printf(" led : run LED ONLPI diagnostic function.\n"); - printf(" psu : run psu ONLPI diagnostic function.\n"); - printf(" thermal : run thermal ONLPI diagnostic function.\n"); - printf(" sfp : run sfp ONLPI diagnostic function.\n"); - printf(" sfp [PORT] : run sfp ONLPI diagnostic function.\n"); - printf(" sfp_dom [PORT] : run sfp dom ONLPI diagnostic function.\n"); - printf(" sfp_ctrl [PORT] : run sfp control ONLPI diagnostic function.\n"); - - printf(" (Warning! Please be careful to write a value to SFP,\n"); - printf(" you should keep the original value to prevent lose it forever.)\n"); - printf(" sfprb [PORT] [ADDR] : read a byte from sfp transeciver.\n"); - printf(" sfprw [PORT] [ADDR] : read a word from sfp transeciver.\n"); - printf(" sfpwb [PORT] [ADDR] [VALUE] : write a byte to sfp transeciver.\n"); - printf(" sfpww [PORT] [ADDR] [VALUE] : write a word to sfp transeciver.\n"); - - printf(" [PORT] is the port index start from 0.\n"); - printf(" [ADDR] is the address to read/write.\n"); - printf(" [VALUE] is the value to read/write.\n"); - - - } - else if (argc > 0 && !strcmp(argv[0], "test")) //for RD debug test - { - diag_flag_set(DIAG_FLAG_ON); - onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_SERVICE), ONLP_LED_MODE_BLUE_BLINKING); - } - else - {} - - return 0; -} - - - - - diff --git a/packages/platforms/lenovo/x86-64/ne10032/onlp/builds/x86_64_lenovo_ne10032/module/src/thermali.c b/packages/platforms/lenovo/x86-64/ne10032/onlp/builds/x86_64_lenovo_ne10032/module/src/thermali.c deleted file mode 100644 index 65eef3cbb..000000000 --- a/packages/platforms/lenovo/x86-64/ne10032/onlp/builds/x86_64_lenovo_ne10032/module/src/thermali.c +++ /dev/null @@ -1,149 +0,0 @@ -/************************************************************ - * - * - * Copyright 2014, 2015 Big Switch Networks, Inc. - * Copyright 2018 Alpha Networks Incorporation - * - * Licensed under the Eclipse Public License, Version 1.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.eclipse.org/legal/epl-v10.html - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT 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 LOCAL_DEBUG 0 - -#define THERMALI_LM75_HOT_SPOT_ADDR 0x4d /* NE10032 thermal addr */ -#define THERMALI_LM75_AMBIENT_ADDR 0x4c /* NE10032 thermal addr */ - -#define THERMALI_HOTSPOT_BUS_ID 3 -#define THERMALI_AMBIENT_BUS_ID 4 - -#define THERMALI_BUS_ID_OFFSET 2 - - -#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_ON_MAIN_BROAD_HOT_SPOT, /* The LM75 on Main Board for hot spot */ - THERMAL_2_ON_MAIN_BROAD_AMBIENT /* The LM75 on Main Board for ambient */ -}; - -static int thermali_current_temp_get(int id, char *data) -{ - int ret = 0; - if (id == THERMALI_HOTSPOT_BUS_ID) - { - ret = i2c_read_byte(id, THERMALI_LM75_HOT_SPOT_ADDR, 0x0, data); - if (ret < 0) - printf("I2C command 0x%X Read Fail, id=%d\n", THERMALI_LM75_HOT_SPOT_ADDR, id); - } - else if (id == THERMALI_AMBIENT_BUS_ID) - { - ret = i2c_read_byte(id, THERMALI_LM75_AMBIENT_ADDR, 0x0, data); - if (ret < 0) - printf("I2C command 0x%X Read Fail, id=%d\n", THERMALI_LM75_AMBIENT_ADDR, id); - } - - return ret; -} - - -/* Static values */ -static onlp_thermal_info_t linfo[] = { - { }, /* Not used */ - { { ONLP_THERMAL_ID_CREATE(THERMAL_1_ON_MAIN_BROAD_HOT_SPOT), "Chassis Thermal Sensor 1 (HOT SPOT)", 0 }, - ONLP_THERMAL_STATUS_PRESENT, - ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS - }, - { { ONLP_THERMAL_ID_CREATE(THERMAL_2_ON_MAIN_BROAD_AMBIENT), "Chassis Thermal Sensor 2 (AMBIENT)", 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) -{ - DIAG_PRINT("%s", __FUNCTION__); - 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) -{ - DIAG_PRINT("%s, id=%d", __FUNCTION__, id); - int local_id, milli_unit = 1000; - char r_data[10] = { 0 }; - VALIDATE(id); - - local_id = ONLP_OID_ID_GET(id); - - if (LOCAL_DEBUG) - printf("\n[Debug][%s][%d][local_id: %d]", __FUNCTION__, __LINE__, local_id); - - /* Set the onlp_oid_hdr_t and capabilities */ - *info = linfo[local_id]; -#if 0 - if(local_id == THERMAL_CPU_CORE) - { - int rv = onlp_file_read_int_max(&info->mcelsius, cpu_coretemp_files); - return rv; - } -#endif - if (thermali_current_temp_get(local_id + THERMALI_BUS_ID_OFFSET, r_data) < 0) - printf("[thermali]get current temperature fail!\n"); - - info->mcelsius = (*r_data) * milli_unit; - - if (LOCAL_DEBUG) - printf("\n[Debug][%s][%d][save data: %d]\n", __FUNCTION__, __LINE__, info->mcelsius); - - return ONLP_STATUS_OK; -} - - diff --git a/packages/platforms/lenovo/x86-64/ne10032/onlp/builds/x86_64_lenovo_ne10032/module/src/x86_64_lenovo_ne10032_config.c b/packages/platforms/lenovo/x86-64/ne10032/onlp/builds/x86_64_lenovo_ne10032/module/src/x86_64_lenovo_ne10032_config.c deleted file mode 100644 index a911449ff..000000000 --- a/packages/platforms/lenovo/x86-64/ne10032/onlp/builds/x86_64_lenovo_ne10032/module/src/x86_64_lenovo_ne10032_config.c +++ /dev/null @@ -1,76 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#include - -/* */ -#define __x86_64_lenovo_ne10032_config_STRINGIFY_NAME(_x) #_x -#define __x86_64_lenovo_ne10032_config_STRINGIFY_VALUE(_x) __x86_64_lenovo_ne10032_config_STRINGIFY_NAME(_x) -x86_64_lenovo_ne10032_config_settings_t x86_64_lenovo_ne10032_config_settings[] = -{ -#ifdef X86_64_LENOVO_NE10032_CONFIG_INCLUDE_LOGGING - { __x86_64_lenovo_ne10032_config_STRINGIFY_NAME(X86_64_LENOVO_NE10032_CONFIG_INCLUDE_LOGGING), __x86_64_lenovo_ne10032_config_STRINGIFY_VALUE(X86_64_LENOVO_NE10032_CONFIG_INCLUDE_LOGGING) }, -#else -{ X86_64_LENOVO_NE10032_CONFIG_INCLUDE_LOGGING(__x86_64_lenovo_ne10032_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_LENOVO_NE10032_CONFIG_LOG_OPTIONS_DEFAULT - { __x86_64_lenovo_ne10032_config_STRINGIFY_NAME(X86_64_LENOVO_NE10032_CONFIG_LOG_OPTIONS_DEFAULT), __x86_64_lenovo_ne10032_config_STRINGIFY_VALUE(X86_64_LENOVO_NE10032_CONFIG_LOG_OPTIONS_DEFAULT) }, -#else -{ X86_64_LENOVO_NE10032_CONFIG_LOG_OPTIONS_DEFAULT(__x86_64_lenovo_ne10032_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_LENOVO_NE10032_CONFIG_LOG_BITS_DEFAULT - { __x86_64_lenovo_ne10032_config_STRINGIFY_NAME(X86_64_LENOVO_NE10032_CONFIG_LOG_BITS_DEFAULT), __x86_64_lenovo_ne10032_config_STRINGIFY_VALUE(X86_64_LENOVO_NE10032_CONFIG_LOG_BITS_DEFAULT) }, -#else -{ X86_64_LENOVO_NE10032_CONFIG_LOG_BITS_DEFAULT(__x86_64_lenovo_ne10032_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_LENOVO_NE10032_CONFIG_LOG_CUSTOM_BITS_DEFAULT - { __x86_64_lenovo_ne10032_config_STRINGIFY_NAME(X86_64_LENOVO_NE10032_CONFIG_LOG_CUSTOM_BITS_DEFAULT), __x86_64_lenovo_ne10032_config_STRINGIFY_VALUE(X86_64_LENOVO_NE10032_CONFIG_LOG_CUSTOM_BITS_DEFAULT) }, -#else -{ X86_64_LENOVO_NE10032_CONFIG_LOG_CUSTOM_BITS_DEFAULT(__x86_64_lenovo_ne10032_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_LENOVO_NE10032_CONFIG_PORTING_STDLIB - { __x86_64_lenovo_ne10032_config_STRINGIFY_NAME(X86_64_LENOVO_NE10032_CONFIG_PORTING_STDLIB), __x86_64_lenovo_ne10032_config_STRINGIFY_VALUE(X86_64_LENOVO_NE10032_CONFIG_PORTING_STDLIB) }, -#else -{ X86_64_LENOVO_NE10032_CONFIG_PORTING_STDLIB(__x86_64_lenovo_ne10032_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_LENOVO_NE10032_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS - { __x86_64_lenovo_ne10032_config_STRINGIFY_NAME(X86_64_LENOVO_NE10032_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS), __x86_64_lenovo_ne10032_config_STRINGIFY_VALUE(X86_64_LENOVO_NE10032_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS) }, -#else -{ X86_64_LENOVO_NE10032_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS(__x86_64_lenovo_ne10032_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_LENOVO_NE10032_CONFIG_INCLUDE_UCLI - { __x86_64_lenovo_ne10032_config_STRINGIFY_NAME(X86_64_LENOVO_NE10032_CONFIG_INCLUDE_UCLI), __x86_64_lenovo_ne10032_config_STRINGIFY_VALUE(X86_64_LENOVO_NE10032_CONFIG_INCLUDE_UCLI) }, -#else -{ X86_64_LENOVO_NE10032_CONFIG_INCLUDE_UCLI(__x86_64_lenovo_ne10032_config_STRINGIFY_NAME), "__undefined__" }, -#endif - { NULL, NULL } -}; -#undef __x86_64_lenovo_ne10032_config_STRINGIFY_VALUE -#undef __x86_64_lenovo_ne10032_config_STRINGIFY_NAME - -const char* -x86_64_lenovo_ne10032_config_lookup(const char* setting) -{ - int i; - for(i = 0; x86_64_lenovo_ne10032_config_settings[i].name; i++) { - if(!strcmp(x86_64_lenovo_ne10032_config_settings[i].name, setting)) { - return x86_64_lenovo_ne10032_config_settings[i].value; - } - } - return NULL; -} - -int -x86_64_lenovo_ne10032_config_show(struct aim_pvs_s* pvs) -{ - int i; - for(i = 0; x86_64_lenovo_ne10032_config_settings[i].name; i++) { - aim_printf(pvs, "%s = %s\n", x86_64_lenovo_ne10032_config_settings[i].name, x86_64_lenovo_ne10032_config_settings[i].value); - } - return i; -} - -/* */ - diff --git a/packages/platforms/lenovo/x86-64/ne10032/onlp/builds/x86_64_lenovo_ne10032/module/src/x86_64_lenovo_ne10032_enums.c b/packages/platforms/lenovo/x86-64/ne10032/onlp/builds/x86_64_lenovo_ne10032/module/src/x86_64_lenovo_ne10032_enums.c deleted file mode 100644 index 0230218d0..000000000 --- a/packages/platforms/lenovo/x86-64/ne10032/onlp/builds/x86_64_lenovo_ne10032/module/src/x86_64_lenovo_ne10032_enums.c +++ /dev/null @@ -1,10 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#include - -/* <--auto.start.enum(ALL).source> */ -/* */ - diff --git a/packages/platforms/lenovo/x86-64/ne10032/onlp/builds/x86_64_lenovo_ne10032/module/src/x86_64_lenovo_ne10032_int.h b/packages/platforms/lenovo/x86-64/ne10032/onlp/builds/x86_64_lenovo_ne10032/module/src/x86_64_lenovo_ne10032_int.h deleted file mode 100644 index 3c22bcaa4..000000000 --- a/packages/platforms/lenovo/x86-64/ne10032/onlp/builds/x86_64_lenovo_ne10032/module/src/x86_64_lenovo_ne10032_int.h +++ /dev/null @@ -1,12 +0,0 @@ -/**************************************************************************//** - * - * x86_64_lenovo_ne10032 Internal Header - * - *****************************************************************************/ -#ifndef __X86_64_LENOVO_NE10032_INT_H__ -#define __X86_64_LENOVO_NE10032_INT_H__ - -#include - - -#endif /* __X86_64_LENOVO_NE10032_INT_H__ */ diff --git a/packages/platforms/lenovo/x86-64/ne10032/onlp/builds/x86_64_lenovo_ne10032/module/src/x86_64_lenovo_ne10032_log.c b/packages/platforms/lenovo/x86-64/ne10032/onlp/builds/x86_64_lenovo_ne10032/module/src/x86_64_lenovo_ne10032_log.c deleted file mode 100644 index c097cc077..000000000 --- a/packages/platforms/lenovo/x86-64/ne10032/onlp/builds/x86_64_lenovo_ne10032/module/src/x86_64_lenovo_ne10032_log.c +++ /dev/null @@ -1,18 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#include - -#include "x86_64_lenovo_ne10032_log.h" -/* - * x86_64_lenovo_ne10032 log struct. - */ -AIM_LOG_STRUCT_DEFINE( - X86_64_LENOVO_NE10032_CONFIG_LOG_OPTIONS_DEFAULT, - X86_64_LENOVO_NE10032_CONFIG_LOG_BITS_DEFAULT, - NULL, /* Custom log map */ - X86_64_LENOVO_NE10032_CONFIG_LOG_CUSTOM_BITS_DEFAULT - ); - diff --git a/packages/platforms/lenovo/x86-64/ne10032/onlp/builds/x86_64_lenovo_ne10032/module/src/x86_64_lenovo_ne10032_log.h b/packages/platforms/lenovo/x86-64/ne10032/onlp/builds/x86_64_lenovo_ne10032/module/src/x86_64_lenovo_ne10032_log.h deleted file mode 100644 index 575879522..000000000 --- a/packages/platforms/lenovo/x86-64/ne10032/onlp/builds/x86_64_lenovo_ne10032/module/src/x86_64_lenovo_ne10032_log.h +++ /dev/null @@ -1,12 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#ifndef __X86_64_LENOVO_NE10032_LOG_H__ -#define __X86_64_LENOVO_NE10032_LOG_H__ - -#define AIM_LOG_MODULE_NAME x86_64_lenovo_ne10032 -#include - -#endif /* __X86_64_LENOVO_NE10032_LOG_H__ */ diff --git a/packages/platforms/lenovo/x86-64/ne10032/onlp/builds/x86_64_lenovo_ne10032/module/src/x86_64_lenovo_ne10032_module.c b/packages/platforms/lenovo/x86-64/ne10032/onlp/builds/x86_64_lenovo_ne10032/module/src/x86_64_lenovo_ne10032_module.c deleted file mode 100644 index ea57305fa..000000000 --- a/packages/platforms/lenovo/x86-64/ne10032/onlp/builds/x86_64_lenovo_ne10032/module/src/x86_64_lenovo_ne10032_module.c +++ /dev/null @@ -1,24 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#include - -#include "x86_64_lenovo_ne10032_log.h" - -static int -datatypes_init__(void) -{ -#define X86_64_LENOVO_NE10032_ENUMERATION_ENTRY(_enum_name, _desc) AIM_DATATYPE_MAP_REGISTER(_enum_name, _enum_name##_map, _desc, AIM_LOG_INTERNAL); -#include - return 0; -} - -void __x86_64_lenovo_ne10032_module_init__(void) -{ - AIM_LOG_STRUCT_REGISTER(); - datatypes_init__(); -} - -int __onlp_platform_version__ = 1; diff --git a/packages/platforms/lenovo/x86-64/ne10032/onlp/builds/x86_64_lenovo_ne10032/module/src/x86_64_lenovo_ne10032_ucli.c b/packages/platforms/lenovo/x86-64/ne10032/onlp/builds/x86_64_lenovo_ne10032/module/src/x86_64_lenovo_ne10032_ucli.c deleted file mode 100644 index 9c4c6625f..000000000 --- a/packages/platforms/lenovo/x86-64/ne10032/onlp/builds/x86_64_lenovo_ne10032/module/src/x86_64_lenovo_ne10032_ucli.c +++ /dev/null @@ -1,50 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#include - -#if X86_64_LENOVO_NE10032_CONFIG_INCLUDE_UCLI == 1 - -#include -#include -#include - -static ucli_status_t -x86_64_lenovo_ne10032_ucli_ucli__config__(ucli_context_t* uc) -{ - UCLI_HANDLER_MACRO_MODULE_CONFIG(x86_64_lenovo_ne10032) -} - -/* */ -/* */ - -static ucli_module_t -x86_64_lenovo_ne10032_ucli_module__ = - { - "x86_64_lenovo_ne10032_ucli", - NULL, - x86_64_lenovo_ne10032_ucli_ucli_handlers__, - NULL, - NULL, - }; - -ucli_node_t* -x86_64_lenovo_ne10032_ucli_node_create(void) -{ - ucli_node_t* n; - ucli_module_init(&x86_64_lenovo_ne10032_ucli_module__); - n = ucli_node_create("x86_64_lenovo_ne10032", NULL, &x86_64_lenovo_ne10032_ucli_module__); - ucli_node_subnode_add(n, ucli_module_log_node_create("x86_64_lenovo_ne10032")); - return n; -} - -#else -void* -x86_64_lenovo_ne10032_ucli_node_create(void) -{ - return NULL; -} -#endif - diff --git a/packages/platforms/lenovo/x86-64/ne10032/platform-config/Makefile b/packages/platforms/lenovo/x86-64/ne10032/platform-config/Makefile deleted file mode 100644 index 003238cf6..000000000 --- a/packages/platforms/lenovo/x86-64/ne10032/platform-config/Makefile +++ /dev/null @@ -1 +0,0 @@ -include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/lenovo/x86-64/ne10032/platform-config/r0/Makefile b/packages/platforms/lenovo/x86-64/ne10032/platform-config/r0/Makefile deleted file mode 100644 index 003238cf6..000000000 --- a/packages/platforms/lenovo/x86-64/ne10032/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/lenovo/x86-64/ne10032/platform-config/r0/PKG.yml b/packages/platforms/lenovo/x86-64/ne10032/platform-config/r0/PKG.yml deleted file mode 100644 index 98029a7e4..000000000 --- a/packages/platforms/lenovo/x86-64/ne10032/platform-config/r0/PKG.yml +++ /dev/null @@ -1 +0,0 @@ -!include $ONL_TEMPLATES/platform-config-platform.yml ARCH=amd64 VENDOR=lenovo BASENAME=x86-64-lenovo-ne10032 REVISION=r0 diff --git a/packages/platforms/lenovo/x86-64/ne10032/platform-config/r0/src/lib/x86-64-lenovo-ne10032-r0.yml b/packages/platforms/lenovo/x86-64/ne10032/platform-config/r0/src/lib/x86-64-lenovo-ne10032-r0.yml deleted file mode 100644 index c5b14f68a..000000000 --- a/packages/platforms/lenovo/x86-64/ne10032/platform-config/r0/src/lib/x86-64-lenovo-ne10032-r0.yml +++ /dev/null @@ -1,32 +0,0 @@ ---- - -###################################################################### -# -# platform-config for NE10032 -# -###################################################################### - -x86-64-lenovo-ne10032-r0: - - grub: - - serial: >- - --port=0x2f8 - --speed=115200 - --word=8 - --parity=no - --stop=1 - - kernel: - <<: *kernel-3-16 - - args: >- - nopat - i2c-ismt.enable=0 - console=ttyS1,115200n8 - - ##network - ## interfaces: - ## ma1: - ## name: ~ - ## syspath: pci0000:00/0000:00:14.0 diff --git a/packages/platforms/lenovo/x86-64/ne10032/platform-config/r0/src/lib/x86-64-lenovo-ne10032-r0.yml.bak b/packages/platforms/lenovo/x86-64/ne10032/platform-config/r0/src/lib/x86-64-lenovo-ne10032-r0.yml.bak deleted file mode 100644 index 205d25def..000000000 --- a/packages/platforms/lenovo/x86-64/ne10032/platform-config/r0/src/lib/x86-64-lenovo-ne10032-r0.yml.bak +++ /dev/null @@ -1,31 +0,0 @@ ---- - -###################################################################### -# -# platform-config for NE10032 -# -###################################################################### - -x86-64-lenovo-ne10032-r0: - - grub: - - serial: >- - --port=0x2f8 - --speed=115200 - --word=8 - --parity=no - --stop=1 - - kernel: - <<: *kernel-3-18 - - args: >- - nopat - console=ttyS1,115200n8 - - ##network - ## interfaces: - ## ma1: - ## name: ~ - ## syspath: pci0000:00/0000:00:14.0 diff --git a/packages/platforms/lenovo/x86-64/ne10032/platform-config/r0/src/python/x86_64_lenovo_ne10032_r0/__init__.py b/packages/platforms/lenovo/x86-64/ne10032/platform-config/r0/src/python/x86_64_lenovo_ne10032_r0/__init__.py deleted file mode 100644 index a529596ec..000000000 --- a/packages/platforms/lenovo/x86-64/ne10032/platform-config/r0/src/python/x86_64_lenovo_ne10032_r0/__init__.py +++ /dev/null @@ -1,116 +0,0 @@ -from onl.platform.base import * -from onl.platform.lenovo import * - -class OnlPlatform_x86_64_lenovo_ne10032_r0(OnlPlatformLenovo, - OnlPlatformPortConfig_32x100): - PLATFORM='x86-64-lenovo-ne10032-r0' - MODEL="NE10032" - SYS_OBJECT_ID=".6010.32" - - def baseconfig(self): - ########### initialize I2C bus 0 ########### - self.new_i2c_devices([ - - # ONIE EEPROM @MB - ('24c128', 0x56, 0), - - # PowerCPLD @MB - ('cpld', 0x5E, 0), - - # initialize multiplexer (PCA9548 #0) - ('pca9548', 0x70, 0), - - # FRU EEROM @MB - ('24c512', 0x51, 1), - - # CFG EEROM @MB - ('24c02', 0x51, 2), - - # TMP75#1 (Hot Spot) #use lm75 will cause device busy, use other name - ('thermal1', 0x4D, 3), - - # TMP75#0 (Ambient) #use lm75 will cause device busy, use other name - ('thermal2', 0x4C, 4), - - # initialize multiplexer (PCA9545 #0) - ('pca9545', 0x71, 5), - - # IDT 5P49V5923A (Clock generator) - (' ', 0x6A, 6), - - # initialize multiplexer (PCA9548 #1) - ('pca9548', 0x72, 7), - - # SystemCPLD @MB - ('cpld', 0x5F, 8), - - ]) - - ########### initialize I2C bus PCA9545 #0 ########### - self.new_i2c_devices( - [ - # MGMT EEROM - ('24c02', 0x51, 9), - # PSU #0 - ('psu', 0x51, 10), - ('psu', 0x59, 10), - # PSU #1 - ('psu', 0x51, 11), - ('psu', 0x59, 11), - # reserved - ]) - - ########### initialize I2C bus PCA9548 #1 ########### - self.new_i2c_devices( - [ - # IR3595 - ('ir3595', 0x09, 18), - - # reserved - - # initialize multiplexer (PCA9548 #1) - ('pca9548', 0x73, 20), - ]) - - - ########### initialize I2C bus PCA9548 #2 @Fan Expander ########### - self.new_i2c_devices( - [ - # Fan EEROM - ('24c02', 0x57, 21), - # Fan EEROM - ('24c02', 0x57, 22), - # Fan EEROM - ('24c02', 0x57, 23), - # Fan EEROM - ('24c02', 0x57, 24), - # Fan EEROM - ('24c02', 0x57, 25), - # Fan EEROM - ('24c02', 0x57, 26), - - ]) - - - # initialize QSFP port 1~32 - self.new_i2c_devices([ - - ('QSFP28', 0x50, 13), - ('QSFP28', 0x50, 14), - ('QSFP28', 0x50, 15), - ('QSFP28', 0x50, 16), - - (' ', 0x68, 13), - (' ', 0x68, 14), - (' ', 0x68, 15), - (' ', 0x68, 16), - - # Port CPLD0~3 - ('cpld', 0x5F, 13), - ('cpld', 0x5F, 14), - ('cpld', 0x5F, 15), - ('cpld', 0x5F, 16), - - ]) - - return True diff --git a/packages/platforms/lenovo/x86-64/ne2572/Makefile b/packages/platforms/lenovo/x86-64/ne2572/Makefile deleted file mode 100644 index 003238cf6..000000000 --- a/packages/platforms/lenovo/x86-64/ne2572/Makefile +++ /dev/null @@ -1 +0,0 @@ -include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/lenovo/x86-64/ne2572/modules/Makefile b/packages/platforms/lenovo/x86-64/ne2572/modules/Makefile deleted file mode 100644 index 003238cf6..000000000 --- a/packages/platforms/lenovo/x86-64/ne2572/modules/Makefile +++ /dev/null @@ -1 +0,0 @@ -include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/lenovo/x86-64/ne2572/modules/PKG.yml b/packages/platforms/lenovo/x86-64/ne2572/modules/PKG.yml deleted file mode 100644 index 7861ffd18..000000000 --- a/packages/platforms/lenovo/x86-64/ne2572/modules/PKG.yml +++ /dev/null @@ -1 +0,0 @@ -!include $ONL_TEMPLATES/no-platform-modules.yml ARCH=amd64 VENDOR=lenovo BASENAME=x86-64-lenovo-ne2572 diff --git a/packages/platforms/lenovo/x86-64/ne2572/onlp/Makefile b/packages/platforms/lenovo/x86-64/ne2572/onlp/Makefile deleted file mode 100644 index 003238cf6..000000000 --- a/packages/platforms/lenovo/x86-64/ne2572/onlp/Makefile +++ /dev/null @@ -1 +0,0 @@ -include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/lenovo/x86-64/ne2572/onlp/PKG.yml b/packages/platforms/lenovo/x86-64/ne2572/onlp/PKG.yml deleted file mode 100644 index 977e82f14..000000000 --- a/packages/platforms/lenovo/x86-64/ne2572/onlp/PKG.yml +++ /dev/null @@ -1 +0,0 @@ -!include $ONL_TEMPLATES/onlp-platform-any.yml PLATFORM=x86-64-lenovo-ne2572 ARCH=amd64 TOOLCHAIN=x86_64-linux-gnu diff --git a/packages/platforms/lenovo/x86-64/ne2572/onlp/builds/Makefile b/packages/platforms/lenovo/x86-64/ne2572/onlp/builds/Makefile deleted file mode 100644 index e7437cb23..000000000 --- a/packages/platforms/lenovo/x86-64/ne2572/onlp/builds/Makefile +++ /dev/null @@ -1,2 +0,0 @@ -FILTER=src -include $(ONL)/make/subdirs.mk diff --git a/packages/platforms/lenovo/x86-64/ne2572/onlp/builds/lib/Makefile b/packages/platforms/lenovo/x86-64/ne2572/onlp/builds/lib/Makefile deleted file mode 100644 index 3ab028005..000000000 --- a/packages/platforms/lenovo/x86-64/ne2572/onlp/builds/lib/Makefile +++ /dev/null @@ -1,2 +0,0 @@ -PLATFORM := x86-64-lenovo-ne2572 -include $(ONL)/packages/base/any/onlp/builds/platform/libonlp-platform.mk diff --git a/packages/platforms/lenovo/x86-64/ne2572/onlp/builds/onlpdump/Makefile b/packages/platforms/lenovo/x86-64/ne2572/onlp/builds/onlpdump/Makefile deleted file mode 100644 index 45efb6477..000000000 --- a/packages/platforms/lenovo/x86-64/ne2572/onlp/builds/onlpdump/Makefile +++ /dev/null @@ -1,2 +0,0 @@ -PLATFORM := x86-64-lenovo-ne2572 -include $(ONL)/packages/base/any/onlp/builds/platform/onlps.mk diff --git a/packages/platforms/lenovo/x86-64/ne2572/onlp/builds/x86_64_lenovo_ne2572/.gitignore b/packages/platforms/lenovo/x86-64/ne2572/onlp/builds/x86_64_lenovo_ne2572/.gitignore deleted file mode 100644 index 12ea5685c..000000000 --- a/packages/platforms/lenovo/x86-64/ne2572/onlp/builds/x86_64_lenovo_ne2572/.gitignore +++ /dev/null @@ -1 +0,0 @@ -x86_64_lenovo_ne2572.mk diff --git a/packages/platforms/lenovo/x86-64/ne2572/onlp/builds/x86_64_lenovo_ne2572/.module b/packages/platforms/lenovo/x86-64/ne2572/onlp/builds/x86_64_lenovo_ne2572/.module deleted file mode 100644 index 3b521bbc9..000000000 --- a/packages/platforms/lenovo/x86-64/ne2572/onlp/builds/x86_64_lenovo_ne2572/.module +++ /dev/null @@ -1 +0,0 @@ -name: x86_64_lenovo_ne2572 diff --git a/packages/platforms/lenovo/x86-64/ne2572/onlp/builds/x86_64_lenovo_ne2572/Makefile b/packages/platforms/lenovo/x86-64/ne2572/onlp/builds/x86_64_lenovo_ne2572/Makefile deleted file mode 100644 index 96550cb15..000000000 --- a/packages/platforms/lenovo/x86-64/ne2572/onlp/builds/x86_64_lenovo_ne2572/Makefile +++ /dev/null @@ -1,9 +0,0 @@ -############################################################################### -# -# -# -############################################################################### -include $(ONL)/make/config.mk -MODULE := x86_64_lenovo_ne2572 -AUTOMODULE := x86_64_lenovo_ne2572 -include $(BUILDER)/definemodule.mk diff --git a/packages/platforms/lenovo/x86-64/ne2572/onlp/builds/x86_64_lenovo_ne2572/Makefile.bak b/packages/platforms/lenovo/x86-64/ne2572/onlp/builds/x86_64_lenovo_ne2572/Makefile.bak deleted file mode 100644 index c832ef343..000000000 --- a/packages/platforms/lenovo/x86-64/ne2572/onlp/builds/x86_64_lenovo_ne2572/Makefile.bak +++ /dev/null @@ -1,9 +0,0 @@ -############################################################################### -# -# -# -############################################################################### -include ../../init.mk -MODULE := x86_64_lenovo_ne2572 -AUTOMODULE := x86_64_lenovo_ne2572 -include $(BUILDER)/definemodule.mk diff --git a/packages/platforms/lenovo/x86-64/ne2572/onlp/builds/x86_64_lenovo_ne2572/README b/packages/platforms/lenovo/x86-64/ne2572/onlp/builds/x86_64_lenovo_ne2572/README deleted file mode 100644 index e75ab8bf6..000000000 --- a/packages/platforms/lenovo/x86-64/ne2572/onlp/builds/x86_64_lenovo_ne2572/README +++ /dev/null @@ -1,6 +0,0 @@ -############################################################################### -# -# x86_64_lenovo_ne2572 README -# -############################################################################### - diff --git a/packages/platforms/lenovo/x86-64/ne2572/onlp/builds/x86_64_lenovo_ne2572/module/auto/make.mk b/packages/platforms/lenovo/x86-64/ne2572/onlp/builds/x86_64_lenovo_ne2572/module/auto/make.mk deleted file mode 100644 index 1e21e456e..000000000 --- a/packages/platforms/lenovo/x86-64/ne2572/onlp/builds/x86_64_lenovo_ne2572/module/auto/make.mk +++ /dev/null @@ -1,9 +0,0 @@ -############################################################################### -# -# x86_64_lenovo_ne2572 Autogeneration -# -############################################################################### -x86_64_lenovo_ne2572_AUTO_DEFS := module/auto/x86_64_lenovo_ne2572.yml -x86_64_lenovo_ne2572_AUTO_DIRS := module/inc/x86_64_lenovo_ne2572 module/src -include $(BUILDER)/auto.mk - diff --git a/packages/platforms/lenovo/x86-64/ne2572/onlp/builds/x86_64_lenovo_ne2572/module/auto/x86_64_lenovo_ne2572.yml b/packages/platforms/lenovo/x86-64/ne2572/onlp/builds/x86_64_lenovo_ne2572/module/auto/x86_64_lenovo_ne2572.yml deleted file mode 100644 index 53c4f4c97..000000000 --- a/packages/platforms/lenovo/x86-64/ne2572/onlp/builds/x86_64_lenovo_ne2572/module/auto/x86_64_lenovo_ne2572.yml +++ /dev/null @@ -1,47 +0,0 @@ -############################################################################### -# -# x86_64_lenovo_ne2572 Autogeneration Definitions. -# -############################################################################### - -cdefs: &cdefs -- X86_64_LENOVO_NE2572_CONFIG_INCLUDE_LOGGING: - doc: "Include or exclude logging." - default: 1 -- X86_64_LENOVO_NE2572_CONFIG_LOG_OPTIONS_DEFAULT: - doc: "Default enabled log options." - default: AIM_LOG_OPTIONS_DEFAULT -- X86_64_LENOVO_NE2572_CONFIG_LOG_BITS_DEFAULT: - doc: "Default enabled log bits." - default: AIM_LOG_BITS_DEFAULT -- X86_64_LENOVO_NE2572_CONFIG_LOG_CUSTOM_BITS_DEFAULT: - doc: "Default enabled custom log bits." - default: 0 -- X86_64_LENOVO_NE2572_CONFIG_PORTING_STDLIB: - doc: "Default all porting macros to use the C standard libraries." - default: 1 -- X86_64_LENOVO_NE2572_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS: - doc: "Include standard library headers for stdlib porting macros." - default: X86_64_LENOVO_NE2572_CONFIG_PORTING_STDLIB -- X86_64_LENOVO_NE2572_CONFIG_INCLUDE_UCLI: - doc: "Include generic uCli support." - default: 0 - - -definitions: - cdefs: - X86_64_LENOVO_NE2572_CONFIG_HEADER: - defs: *cdefs - basename: x86_64_lenovo_ne2572_config - - portingmacro: - X86_64_LENOVO_NE2572: - macros: - - malloc - - free - - memset - - memcpy - - - vsnprintf - - snprintf - - strlen diff --git a/packages/platforms/lenovo/x86-64/ne2572/onlp/builds/x86_64_lenovo_ne2572/module/inc/x86_64_lenovo_ne2572/x86_64_lenovo_ne2572.x b/packages/platforms/lenovo/x86-64/ne2572/onlp/builds/x86_64_lenovo_ne2572/module/inc/x86_64_lenovo_ne2572/x86_64_lenovo_ne2572.x deleted file mode 100644 index e0f2db7e7..000000000 --- a/packages/platforms/lenovo/x86-64/ne2572/onlp/builds/x86_64_lenovo_ne2572/module/inc/x86_64_lenovo_ne2572/x86_64_lenovo_ne2572.x +++ /dev/null @@ -1,14 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#include - -/* <--auto.start.xmacro(ALL).define> */ -/* */ - -/* <--auto.start.xenum(ALL).define> */ -/* */ - - diff --git a/packages/platforms/lenovo/x86-64/ne2572/onlp/builds/x86_64_lenovo_ne2572/module/inc/x86_64_lenovo_ne2572/x86_64_lenovo_ne2572_config.h b/packages/platforms/lenovo/x86-64/ne2572/onlp/builds/x86_64_lenovo_ne2572/module/inc/x86_64_lenovo_ne2572/x86_64_lenovo_ne2572_config.h deleted file mode 100644 index 48b95e44b..000000000 --- a/packages/platforms/lenovo/x86-64/ne2572/onlp/builds/x86_64_lenovo_ne2572/module/inc/x86_64_lenovo_ne2572/x86_64_lenovo_ne2572_config.h +++ /dev/null @@ -1,127 +0,0 @@ -/**************************************************************************//** - * - * @file - * @brief x86_64_lenovo_ne2572 Configuration Header - * - * @addtogroup x86_64_lenovo_ne2572-config - * @{ - * - *****************************************************************************/ -#ifndef __X86_64_LENOVO_NE2572_CONFIG_H__ -#define __X86_64_LENOVO_NE2572_CONFIG_H__ - -#ifdef GLOBAL_INCLUDE_CUSTOM_CONFIG -#include -#endif -#ifdef X86_64_LENOVO_NE2572_INCLUDE_CUSTOM_CONFIG -#include -#endif - -/* */ -#include -/** - * X86_64_LENOVO_NE2572_CONFIG_INCLUDE_LOGGING - * - * Include or exclude logging. */ - - -#ifndef X86_64_LENOVO_NE2572_CONFIG_INCLUDE_LOGGING -#define X86_64_LENOVO_NE2572_CONFIG_INCLUDE_LOGGING 1 -#endif - -/** - * X86_64_LENOVO_NE2572_CONFIG_LOG_OPTIONS_DEFAULT - * - * Default enabled log options. */ - - -#ifndef X86_64_LENOVO_NE2572_CONFIG_LOG_OPTIONS_DEFAULT -#define X86_64_LENOVO_NE2572_CONFIG_LOG_OPTIONS_DEFAULT AIM_LOG_OPTIONS_DEFAULT -#endif - -/** - * X86_64_LENOVO_NE2572_CONFIG_LOG_BITS_DEFAULT - * - * Default enabled log bits. */ - - -#ifndef X86_64_LENOVO_NE2572_CONFIG_LOG_BITS_DEFAULT -#define X86_64_LENOVO_NE2572_CONFIG_LOG_BITS_DEFAULT AIM_LOG_BITS_DEFAULT -#endif - -/** - * X86_64_LENOVO_NE2572_CONFIG_LOG_CUSTOM_BITS_DEFAULT - * - * Default enabled custom log bits. */ - - -#ifndef X86_64_LENOVO_NE2572_CONFIG_LOG_CUSTOM_BITS_DEFAULT -#define X86_64_LENOVO_NE2572_CONFIG_LOG_CUSTOM_BITS_DEFAULT 0 -#endif - -/** - * X86_64_LENOVO_NE2572_CONFIG_PORTING_STDLIB - * - * Default all porting macros to use the C standard libraries. */ - - -#ifndef X86_64_LENOVO_NE2572_CONFIG_PORTING_STDLIB -#define X86_64_LENOVO_NE2572_CONFIG_PORTING_STDLIB 1 -#endif - -/** - * X86_64_LENOVO_NE2572_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS - * - * Include standard library headers for stdlib porting macros. */ - - -#ifndef X86_64_LENOVO_NE2572_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS -#define X86_64_LENOVO_NE2572_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS X86_64_LENOVO_NE2572_CONFIG_PORTING_STDLIB -#endif - -/** - * X86_64_LENOVO_NE2572_CONFIG_INCLUDE_UCLI - * - * Include generic uCli support. */ - - -#ifndef X86_64_LENOVO_NE2572_CONFIG_INCLUDE_UCLI -#define X86_64_LENOVO_NE2572_CONFIG_INCLUDE_UCLI 0 -#endif - - - -/** - * All compile time options can be queried or displayed - */ - -/** Configuration settings structure. */ -typedef struct x86_64_lenovo_ne2572_config_settings_s { - /** name */ - const char* name; - /** value */ - const char* value; -} x86_64_lenovo_ne2572_config_settings_t; - -/** Configuration settings table. */ -/** x86_64_lenovo_ne2572_config_settings table. */ -extern x86_64_lenovo_ne2572_config_settings_t x86_64_lenovo_ne2572_config_settings[]; - -/** - * @brief Lookup a configuration setting. - * @param setting The name of the configuration option to lookup. - */ -const char* x86_64_lenovo_ne2572_config_lookup(const char* setting); - -/** - * @brief Show the compile-time configuration. - * @param pvs The output stream. - */ -int x86_64_lenovo_ne2572_config_show(struct aim_pvs_s* pvs); - -/* */ - -#include "x86_64_lenovo_ne2572_porting.h" - -#endif /* __X86_64_LENOVO_NE2572_CONFIG_H__ */ -/* @} */ diff --git a/packages/platforms/lenovo/x86-64/ne2572/onlp/builds/x86_64_lenovo_ne2572/module/inc/x86_64_lenovo_ne2572/x86_64_lenovo_ne2572_dox.h b/packages/platforms/lenovo/x86-64/ne2572/onlp/builds/x86_64_lenovo_ne2572/module/inc/x86_64_lenovo_ne2572/x86_64_lenovo_ne2572_dox.h deleted file mode 100644 index 05cf08fb0..000000000 --- a/packages/platforms/lenovo/x86-64/ne2572/onlp/builds/x86_64_lenovo_ne2572/module/inc/x86_64_lenovo_ne2572/x86_64_lenovo_ne2572_dox.h +++ /dev/null @@ -1,26 +0,0 @@ -/**************************************************************************//** - * - * x86_64_lenovo_ne2572 Doxygen Header - * - *****************************************************************************/ -#ifndef __X86_64_LENOVO_NE2572_DOX_H__ -#define __X86_64_LENOVO_NE2572_DOX_H__ - -/** - * @defgroup x86_64_lenovo_ne2572 x86_64_lenovo_ne2572 - x86_64_lenovo_ne2572 Description - * - -The documentation overview for this module should go here. - - * - * @{ - * - * @defgroup x86_64_lenovo_ne2572-x86_64_lenovo_ne2572 Public Interface - * @defgroup x86_64_lenovo_ne2572-config Compile Time Configuration - * @defgroup x86_64_lenovo_ne2572-porting Porting Macros - * - * @} - * - */ - -#endif /* __X86_64_LENOVO_NE2572_DOX_H__ */ diff --git a/packages/platforms/lenovo/x86-64/ne2572/onlp/builds/x86_64_lenovo_ne2572/module/inc/x86_64_lenovo_ne2572/x86_64_lenovo_ne2572_porting.h b/packages/platforms/lenovo/x86-64/ne2572/onlp/builds/x86_64_lenovo_ne2572/module/inc/x86_64_lenovo_ne2572/x86_64_lenovo_ne2572_porting.h deleted file mode 100644 index 553ade7e4..000000000 --- a/packages/platforms/lenovo/x86-64/ne2572/onlp/builds/x86_64_lenovo_ne2572/module/inc/x86_64_lenovo_ne2572/x86_64_lenovo_ne2572_porting.h +++ /dev/null @@ -1,97 +0,0 @@ -/**************************************************************************//** - * - * @file - * @brief x86_64_lenovo_ne2572 Porting Macros. - * - * @addtogroup x86_64_lenovo_ne2572-porting - * @{ - * - *****************************************************************************/ -#ifndef __X86_64_LENOVO_NE2572_PORTING_H__ -#define __X86_64_LENOVO_NE2572_PORTING_H__ - - -/* */ -#if X86_64_LENOVO_NE2572_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS == 1 -#include -#include -#include -#include -#include -#endif - -#ifndef X86_64_LENOVO_NE2572_MALLOC - #if defined(GLOBAL_MALLOC) - #define X86_64_LENOVO_NE2572_MALLOC GLOBAL_MALLOC - #elif X86_64_LENOVO_NE2572_CONFIG_PORTING_STDLIB == 1 - #define X86_64_LENOVO_NE2572_MALLOC malloc - #else - #error The macro X86_64_LENOVO_NE2572_MALLOC is required but cannot be defined. - #endif -#endif - -#ifndef X86_64_LENOVO_NE2572_FREE - #if defined(GLOBAL_FREE) - #define X86_64_LENOVO_NE2572_FREE GLOBAL_FREE - #elif X86_64_LENOVO_NE2572_CONFIG_PORTING_STDLIB == 1 - #define X86_64_LENOVO_NE2572_FREE free - #else - #error The macro X86_64_LENOVO_NE2572_FREE is required but cannot be defined. - #endif -#endif - -#ifndef X86_64_LENOVO_NE2572_MEMSET - #if defined(GLOBAL_MEMSET) - #define X86_64_LENOVO_NE2572_MEMSET GLOBAL_MEMSET - #elif X86_64_LENOVO_NE2572_CONFIG_PORTING_STDLIB == 1 - #define X86_64_LENOVO_NE2572_MEMSET memset - #else - #error The macro X86_64_LENOVO_NE2572_MEMSET is required but cannot be defined. - #endif -#endif - -#ifndef X86_64_LENOVO_NE2572_MEMCPY - #if defined(GLOBAL_MEMCPY) - #define X86_64_LENOVO_NE2572_MEMCPY GLOBAL_MEMCPY - #elif X86_64_LENOVO_NE2572_CONFIG_PORTING_STDLIB == 1 - #define X86_64_LENOVO_NE2572_MEMCPY memcpy - #else - #error The macro X86_64_LENOVO_NE2572_MEMCPY is required but cannot be defined. - #endif -#endif - -#ifndef X86_64_LENOVO_NE2572_VSNPRINTF - #if defined(GLOBAL_VSNPRINTF) - #define X86_64_LENOVO_NE2572_VSNPRINTF GLOBAL_VSNPRINTF - #elif X86_64_LENOVO_NE2572_CONFIG_PORTING_STDLIB == 1 - #define X86_64_LENOVO_NE2572_VSNPRINTF vsnprintf - #else - #error The macro X86_64_LENOVO_NE2572_VSNPRINTF is required but cannot be defined. - #endif -#endif - -#ifndef X86_64_LENOVO_NE2572_SNPRINTF - #if defined(GLOBAL_SNPRINTF) - #define X86_64_LENOVO_NE2572_SNPRINTF GLOBAL_SNPRINTF - #elif X86_64_LENOVO_NE2572_CONFIG_PORTING_STDLIB == 1 - #define X86_64_LENOVO_NE2572_SNPRINTF snprintf - #else - #error The macro X86_64_LENOVO_NE2572_SNPRINTF is required but cannot be defined. - #endif -#endif - -#ifndef X86_64_LENOVO_NE2572_STRLEN - #if defined(GLOBAL_STRLEN) - #define X86_64_LENOVO_NE2572_STRLEN GLOBAL_STRLEN - #elif X86_64_LENOVO_NE2572_CONFIG_PORTING_STDLIB == 1 - #define X86_64_LENOVO_NE2572_STRLEN strlen - #else - #error The macro X86_64_LENOVO_NE2572_STRLEN is required but cannot be defined. - #endif -#endif - -/* */ - - -#endif /* __X86_64_LENOVO_NE2572_PORTING_H__ */ -/* @} */ diff --git a/packages/platforms/lenovo/x86-64/ne2572/onlp/builds/x86_64_lenovo_ne2572/module/make.mk b/packages/platforms/lenovo/x86-64/ne2572/onlp/builds/x86_64_lenovo_ne2572/module/make.mk deleted file mode 100644 index 276f76395..000000000 --- a/packages/platforms/lenovo/x86-64/ne2572/onlp/builds/x86_64_lenovo_ne2572/module/make.mk +++ /dev/null @@ -1,10 +0,0 @@ -############################################################################### -# -# -# -############################################################################### -THIS_DIR := $(dir $(lastword $(MAKEFILE_LIST))) -x86_64_lenovo_ne2572_INCLUDES := -I $(THIS_DIR)inc -x86_64_lenovo_ne2572_INTERNAL_INCLUDES := -I $(THIS_DIR)src -x86_64_lenovo_ne2572_DEPENDMODULE_ENTRIES := init:x86_64_lenovo_ne2572 ucli:x86_64_lenovo_ne2572 - diff --git a/packages/platforms/lenovo/x86-64/ne2572/onlp/builds/x86_64_lenovo_ne2572/module/src/Makefile b/packages/platforms/lenovo/x86-64/ne2572/onlp/builds/x86_64_lenovo_ne2572/module/src/Makefile deleted file mode 100644 index d31b4ab89..000000000 --- a/packages/platforms/lenovo/x86-64/ne2572/onlp/builds/x86_64_lenovo_ne2572/module/src/Makefile +++ /dev/null @@ -1,9 +0,0 @@ -############################################################################### -# -# Local source generation targets. -# -############################################################################### - -ucli: - @../../../../tools/uclihandlers.py x86_64_lenovo_ne2572_ucli.c - diff --git a/packages/platforms/lenovo/x86-64/ne2572/onlp/builds/x86_64_lenovo_ne2572/module/src/debug.c b/packages/platforms/lenovo/x86-64/ne2572/onlp/builds/x86_64_lenovo_ne2572/module/src/debug.c deleted file mode 100644 index bcb9e03fd..000000000 --- a/packages/platforms/lenovo/x86-64/ne2572/onlp/builds/x86_64_lenovo_ne2572/module/src/debug.c +++ /dev/null @@ -1,45 +0,0 @@ -#include "x86_64_lenovo_ne2572_int.h" - -#if X86_64_LENOVO_NE2572_CONFIG_INCLUDE_DEBUG == 1 - -#include - -static char help__[] = - "Usage: debug [options]\n" - " -c CPLD Versions\n" - " -h Help\n" - ; - -int -x86_64_lenovo_ne2572_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/lenovo/x86-64/ne2572/onlp/builds/x86_64_lenovo_ne2572/module/src/fani.c b/packages/platforms/lenovo/x86-64/ne2572/onlp/builds/x86_64_lenovo_ne2572/module/src/fani.c deleted file mode 100644 index 024800c50..000000000 --- a/packages/platforms/lenovo/x86-64/ne2572/onlp/builds/x86_64_lenovo_ne2572/module/src/fani.c +++ /dev/null @@ -1,597 +0,0 @@ -/************************************************************ - * - * - * Copyright 2014 Big Switch Networks, Inc. - * Copyright 2018 Alpha Networks Incorporation. - * - * Licensed under the Eclipse Public License, Version 1.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.eclipse.org/legal/epl-v10.html - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT 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 DEBUG 0 - -#define CPLD_I2C_BUS_ID 0 -#define CPLD_I2C_ADDR 0x5E /* Power CPLD Physical Address in the I2C */ - -#define CPLD_FAN6_STATUS_ADDR_OFFSET 0x10 -#define CPLD_FAN5_STATUS_ADDR_OFFSET 0x11 -#define CPLD_FAN4_STATUS_ADDR_OFFSET 0x12 -#define CPLD_FAN3_STATUS_ADDR_OFFSET 0x13 -#define CPLD_FAN2_STATUS_ADDR_OFFSET 0x14 -#define CPLD_FAN1_STATUS_ADDR_OFFSET 0x15 - -#define CPLD_FAN6_0_SPEED_ADDR_OFFSET 0x16 -#define CPLD_FAN6_1_SPEED_ADDR_OFFSET 0x17 -#define CPLD_FAN5_0_SPEED_ADDR_OFFSET 0x18 -#define CPLD_FAN5_1_SPEED_ADDR_OFFSET 0x19 -#define CPLD_FAN4_0_SPEED_ADDR_OFFSET 0x1A -#define CPLD_FAN4_1_SPEED_ADDR_OFFSET 0x1B -#define CPLD_FAN3_0_SPEED_ADDR_OFFSET 0x1C -#define CPLD_FAN3_1_SPEED_ADDR_OFFSET 0x1D -#define CPLD_FAN2_0_SPEED_ADDR_OFFSET 0x1E -#define CPLD_FAN2_1_SPEED_ADDR_OFFSET 0x1F -#define CPLD_FAN1_0_SPEED_ADDR_OFFSET 0x20 -#define CPLD_FAN1_1_SPEED_ADDR_OFFSET 0x21 - -#define CPLD_FAN_MIN_RPS_ADDR_OFFSET 0x22 -#define CPLD_FAN_PWM_ADDR_OFFSET 0x23 -#define CPLD_FAN_SEL_CONTROL_ADDR_OFFSET 0x24 /* 0: CPLD control, 1: BMC control */ - -#define FAN1_EEPROM_BUS 77 -#define FAN_EEPROM_ADDR 0x57 -#define FAN_MODEL_OFFSET 0x67 -#define FAN_MODEL_LENGTH 12 -#define FAN_SERIAL_OFFSET 0x77 -#define FAN_SERIAL_LENGTH 8 - -#define FAN_MAX_RPM 21000 - -#if 1 //PSU FAN - -#define PSU_PMBus_ADDR 0x59 -#define READ_FAN_SPEED_REG 0x90 -#define READ_FAN_STATUS_1_2_REG 0x81 -#endif - -#define FAN_DIR_FRONT_TO_BACK 0 -#define FAN_DIR_BACK_TO_FRONT 1 - - - -/* Static fan information */ -onlp_fan_info_t linfo[] = { - { }, /* Not used */ - { - { ONLP_FAN_ID_CREATE(FAN_1), "Chassis Fan 1", 0 }, - 0x0, - ONLP_FAN_CAPS_GET_PERCENTAGE | ONLP_FAN_CAPS_GET_RPM | ONLP_FAN_CAPS_SET_PERCENTAGE | ONLP_FAN_CAPS_SET_RPM, - 0, - 0, - ONLP_FAN_MODE_INVALID, - }, - { - { ONLP_FAN_ID_CREATE(FAN_2), "Chassis Fan 2", 0 }, - 0x0, - ONLP_FAN_CAPS_GET_PERCENTAGE | ONLP_FAN_CAPS_GET_RPM | ONLP_FAN_CAPS_SET_PERCENTAGE | ONLP_FAN_CAPS_SET_RPM, - 0, - 0, - ONLP_FAN_MODE_INVALID, - }, - { - { ONLP_FAN_ID_CREATE(FAN_3), "Chassis Fan 3", 0 }, - 0x0, - ONLP_FAN_CAPS_GET_PERCENTAGE | ONLP_FAN_CAPS_GET_RPM | ONLP_FAN_CAPS_SET_PERCENTAGE | ONLP_FAN_CAPS_SET_RPM, - 0, - 0, - ONLP_FAN_MODE_INVALID, - }, - { - { ONLP_FAN_ID_CREATE(FAN_4), "Chassis Fan 4", 0 }, - 0x0, - ONLP_FAN_CAPS_GET_PERCENTAGE | ONLP_FAN_CAPS_GET_RPM | ONLP_FAN_CAPS_SET_PERCENTAGE | ONLP_FAN_CAPS_SET_RPM, - 0, - 0, - ONLP_FAN_MODE_INVALID, - }, - { - { ONLP_FAN_ID_CREATE(FAN_5), "Chassis Fan 5", 0 }, - 0x0, - ONLP_FAN_CAPS_GET_PERCENTAGE | ONLP_FAN_CAPS_GET_RPM | ONLP_FAN_CAPS_SET_PERCENTAGE | ONLP_FAN_CAPS_SET_RPM, - 0, - 0, - ONLP_FAN_MODE_INVALID, - }, - { - { ONLP_FAN_ID_CREATE(FAN_6), "Chassis Fan 6", 0 }, - 0x0, - ONLP_FAN_CAPS_GET_PERCENTAGE | ONLP_FAN_CAPS_GET_RPM | ONLP_FAN_CAPS_SET_PERCENTAGE | ONLP_FAN_CAPS_SET_RPM, - 0, - 0, - ONLP_FAN_MODE_INVALID, - }, - { - { ONLP_FAN_ID_CREATE(FAN_1_ON_PSU1), "Chassis PSU-1 Fan 1", 0 }, - 0x0, - ONLP_FAN_CAPS_GET_RPM, - 0, - 0, - ONLP_FAN_MODE_INVALID, - }, - { - { ONLP_FAN_ID_CREATE(FAN_1_ON_PSU2), "Chassis PSU-2 Fan 1", 0 }, - 0x0, - ONLP_FAN_CAPS_GET_RPM, - 0, - 0, - ONLP_FAN_MODE_INVALID, - }, -}; - -#define VALIDATE(_id) \ - do { \ - if(!ONLP_OID_IS_FAN(_id)) { \ - return ONLP_STATUS_E_INVALID; \ - } \ - } while(0) - - -typedef union -{ - unsigned char val; - struct - { - unsigned char fan_direction :1; - unsigned char fan_present :1; - unsigned char fan0_rps_err :1; - unsigned char fan1_rps_err :1; - unsigned char :4; /* reserved */ - }bit; - -}_CPLD_FAN_STATUS_REG_T; - - -/* Get the CPLD address offset for fan status */ -static char -_onlp_fani_get_fan_status_addr_offset(int local_id) -{ - DIAG_PRINT("%s, local_id=%d", __FUNCTION__, local_id); - switch (local_id) - { - case FAN_1: - return CPLD_FAN1_STATUS_ADDR_OFFSET; - case FAN_2: - return CPLD_FAN2_STATUS_ADDR_OFFSET; - case FAN_3: - return CPLD_FAN3_STATUS_ADDR_OFFSET; - case FAN_4: - return CPLD_FAN4_STATUS_ADDR_OFFSET; - case FAN_5: - return CPLD_FAN5_STATUS_ADDR_OFFSET; - case FAN_6: - return CPLD_FAN6_STATUS_ADDR_OFFSET; - } - return 0; -} - -/* Get the CPLD address offset for fan speed */ -static char -_onlp_fani_get_fan_speed_addr_offset(int local_id) -{ - DIAG_PRINT("%s, local_id=%d", __FUNCTION__, local_id); - switch (local_id) - { - case FAN_1: - return CPLD_FAN1_0_SPEED_ADDR_OFFSET; - case FAN_2: - return CPLD_FAN2_0_SPEED_ADDR_OFFSET; - case FAN_3: - return CPLD_FAN3_0_SPEED_ADDR_OFFSET; - case FAN_4: - return CPLD_FAN4_0_SPEED_ADDR_OFFSET; - case FAN_5: - return CPLD_FAN5_0_SPEED_ADDR_OFFSET; - case FAN_6: - return CPLD_FAN6_0_SPEED_ADDR_OFFSET; - } - return 0; -} - -static int -_onlp_fani_info_get_fan(int local_id, onlp_fan_info_t *info) -{ - DIAG_PRINT("%s, local_id=%d", __FUNCTION__, local_id); - _CPLD_FAN_STATUS_REG_T fan_status_reg; - char status_addr_offset = 0, speed0_addr_offset = 0, speed1_addr_offset = 0; - char data = 0; - unsigned char tach_speed0 = 0, tach_speed1 = 0; - int ret = 0; - - /* Get the CPLD address offset for fan status */ - status_addr_offset = _onlp_fani_get_fan_status_addr_offset(local_id); - - ret = i2c_read_byte(CPLD_I2C_BUS_ID, CPLD_I2C_ADDR, status_addr_offset, &data); - if (ret < 0) - { - AIM_LOG_INFO("%s:%d fail[%d]\n", __FUNCTION__, __LINE__, ret); - return ret; - } - if (DEBUG) - AIM_LOG_INFO("%s:%d id[%d],status_addr_offset[%02x],read_byte[%02x]\n", - __FUNCTION__, __LINE__, local_id, (unsigned char)status_addr_offset, (unsigned char)data); - - fan_status_reg.val = data; - - /* Get fan air flow direction */ - if (fan_status_reg.bit.fan_direction == FAN_DIR_FRONT_TO_BACK) - info->status |= ONLP_FAN_STATUS_F2B; - else - info->status |= ONLP_FAN_STATUS_B2F; - - /* Get fan present */ - if (fan_status_reg.bit.fan_present == 1) - info->status |= ONLP_FAN_STATUS_PRESENT; - else - info->status |= ONLP_FAN_STATUS_FAILED; - - /* Check Speed Error*/ - if (fan_status_reg.bit.fan0_rps_err == 1 || fan_status_reg.bit.fan1_rps_err == 1) - { - info->status |= ONLP_FAN_STATUS_FAILED; - } - - /* Get the CPLD address offset for fan speed */ - speed0_addr_offset = _onlp_fani_get_fan_speed_addr_offset(local_id); - speed1_addr_offset = speed0_addr_offset + 1; - - ret = i2c_read_byte(CPLD_I2C_BUS_ID, CPLD_I2C_ADDR, speed0_addr_offset, (char *)&tach_speed0); - if (ret < 0) - { - AIM_LOG_INFO("%s:%d fail[%d]\n", __FUNCTION__, __LINE__, ret); - return ret; - } - if (DEBUG) - AIM_LOG_INFO("%s:%d id[%d],speed0_addr_offset[%02x],read_byte[%02x]\n", - __FUNCTION__, __LINE__, local_id, (unsigned char)speed0_addr_offset, (unsigned char)tach_speed0); - - ret = i2c_read_byte(CPLD_I2C_BUS_ID, CPLD_I2C_ADDR, speed1_addr_offset, (char *)&tach_speed1); - if (ret < 0) - { - AIM_LOG_INFO("%s:%d fail[%d]\n", __FUNCTION__, __LINE__, ret); - return ret; - } - if (DEBUG) - AIM_LOG_INFO("%s:%d id[%d],speed1_addr_offset[%02x],read_byte[%02x]\n", - __FUNCTION__, __LINE__, local_id, (unsigned char)speed1_addr_offset, (unsigned char)tach_speed1); - - //DIAG_PRINT("%s, speed0=%d(0x%X), speed1=%d(0x%X)", __FUNCTION__, (int)tach_speed0, tach_speed0, (int)tach_speed1, tach_speed1); - - /* Get fan rpm */ - //info->rpm = (((int)tach_speed0 + (int)tach_speed1) / 2) * 150; - info->rpm = (int)tach_speed1 * 150; - - ret = i2c_read_byte(CPLD_I2C_BUS_ID, CPLD_I2C_ADDR, CPLD_FAN_PWM_ADDR_OFFSET, &data); - if (ret < 0) - { - AIM_LOG_INFO("%s:%d fail[%d]\n", __FUNCTION__, __LINE__, ret); - return ret; - } - if (DEBUG) - AIM_LOG_INFO("%s:%d id[%d],pwm_addr_offset[%02x],read_byte[%02x]\n", - __FUNCTION__, __LINE__, local_id, CPLD_FAN_PWM_ADDR_OFFSET, (unsigned char)data); - - /* Get fan duty cycle */ - info->percentage = round(((unsigned char)data * 100) / 255); - -#if 1 - uint8_t rdata[256] = { 0 }; - - i2c_read_i2c_block_dump(FAN1_EEPROM_BUS + local_id - 1, FAN_EEPROM_ADDR, (uint8_t *)rdata); - if (ret < 0) - { - AIM_LOG_INFO("%s:%d fail[%d]\n", __FUNCTION__, __LINE__, ret); - return ret; - } - -#if 0 // debug - int i; - for(i=0;i<256;i++) - { - printf("%02X ",rdata[i]); - } - printf("\n"); -#endif - eeprom_tlv_read(rdata, TLV_CODE_PRODUCT_NAME, (char *)info->model); - eeprom_tlv_read(rdata, TLV_CODE_SERIAL_NUMBER, (char *)info->serial); -#else - ret = i2c_read(FAN1_EEPROM_BUS + local_id - 1, FAN_EEPROM_ADDR, FAN_MODEL_OFFSET, FAN_MODEL_LENGTH, (char *)info->model); - if (ret < 0) - { - AIM_LOG_INFO("%s:%d fail[%d]\n", __FUNCTION__, __LINE__, ret); - return ret; - } - - ret = i2c_read(FAN1_EEPROM_BUS + local_id - 1, FAN_EEPROM_ADDR, FAN_SERIAL_OFFSET, FAN_SERIAL_LENGTH, (char *)info->serial); - if (ret < 0) - { - AIM_LOG_INFO("%s:%d fail[%d]\n", __FUNCTION__, __LINE__, ret); - return ret; - } -#endif - return ONLP_STATUS_OK; -} - -static int -_onlp_fani_info_get_fan_on_psu(int local_id, onlp_fan_info_t *info) -{ - int ret = ONLP_STATUS_OK; - int exponent = 0, mantissa = 0; - uint16_t value = 0; - - - DIAG_PRINT("%s, local_id=%d", __FUNCTION__, local_id); - - /* Get PSU fan speed */ - switch (local_id) - { - case FAN_1_ON_PSU1: - ret = i2c_read_word(PSU1_BUS_ID, PSU_PMBus_ADDR, READ_FAN_SPEED_REG); - if (ret < 0 && DEBUG) - AIM_LOG_INFO("%s:%d fail[%d]\n", __FUNCTION__, __LINE__, ret); - - break; - case FAN_1_ON_PSU2: - ret = i2c_read_word(PSU2_BUS_ID, PSU_PMBus_ADDR, READ_FAN_SPEED_REG); - if (ret < 0 && DEBUG) - AIM_LOG_INFO("%s:%d fail[%d]\n", __FUNCTION__, __LINE__, ret); - - break; - } - - //printf("[%s]local_id:%d i2c read ret:%d\n",__FUNCTION__, local_id, ret); - if (ret <= 0) - { - info->status |= ONLP_FAN_STATUS_FAILED; - } - else - { - info->status |= ONLP_FAN_STATUS_PRESENT; - - value = ret; - //Linear Data Format - exponent = psu_two_complement_to_int(value >> 11, 5, 0x1f); - mantissa = psu_two_complement_to_int(value & 0x7ff, 11, 0x7ff); - - info->rpm = (exponent >= 0) ? (mantissa << exponent) : (mantissa) / (1 << -exponent); - } - - //check Fan Fault, bit 7 - ret = i2c_read_word(PSU2_BUS_ID, PSU_PMBus_ADDR, READ_FAN_STATUS_1_2_REG); - if (ret < 0 && DEBUG) - { - AIM_LOG_INFO("%s:%d fail[%d]\n", __FUNCTION__, __LINE__, ret); - } - else if ((ret & 0x80) == 0x80) - { - info->status |= ONLP_FAN_STATUS_FAILED; - } - - - - return ONLP_STATUS_OK; -} - -/* - * This function will be called prior to all of onlp_fani_* functions. - */ -#define DEFAULT_FAN_SPEED 50 - -int -onlp_fani_init(void) -{ - DIAG_PRINT("%s", __FUNCTION__); - -#if 1 //By HW design, percentage is apply on all fans. - onlp_fani_percentage_set(ONLP_FAN_ID_CREATE(FAN_1), DEFAULT_FAN_SPEED); -#else - int i = 0; - - for (i = FAN_1; - i <= FAN_6; - i++) - { - onlp_fani_percentage_set(ONLP_FAN_ID_CREATE(i), DEFAULT_FAN_SPEED); - } -#endif - - return ONLP_STATUS_OK; -} - -int -onlp_fani_info_get(onlp_oid_t id, onlp_fan_info_t *info) -{ - DIAG_PRINT("%s, id=%d", __FUNCTION__, id); - - int ret = ONLP_STATUS_OK; - 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: - ret = _onlp_fani_info_get_fan_on_psu(local_id, info); - break; - - default: - ret = _onlp_fani_info_get_fan(local_id, info); - break; - } - - return ret; -} - -int onlp_fani_status_get(onlp_oid_t id, uint32_t *rv) -{ - - DIAG_PRINT("%s, id=%d", __FUNCTION__, id); - onlp_fan_info_t info; - onlp_fan_status_t ret = 0; - onlp_fani_info_get(id, &info); - - - ret = info.status & (ONLP_FAN_STATUS_PRESENT | ONLP_FAN_STATUS_FAILED); - *rv = (uint32_t)ret; - return 0; -} - -int _onlp_fani_rpm_to_percentage(int rpm) -{ - int percentage = 0; - percentage = round(rpm * 100 / FAN_MAX_RPM); - - if (percentage == 0 && rpm != 0) - { - percentage = 1; - } - DIAG_PRINT("%s, rpm=%d to percentage=%d", __FUNCTION__, rpm, percentage); - - return percentage; -} - -/* - * 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. - */ -/* - [Note]: By H/W design, fan speed is controlled using percentage. - RPM value will be translated to percentage and it may produce some deviation. - (the register size is 8-bit, so there is only 255 units to present the value.) -*/ -int -onlp_fani_rpm_set(onlp_oid_t id, int rpm) -{ - DIAG_PRINT("%s, id=%d, rpm=%d", __FUNCTION__, id, rpm); - - if (rpm > FAN_MAX_RPM || rpm <= 0) - { - AIM_LOG_INFO("%s:%d rpm:%d is out of range. (1~%d)\n", __FUNCTION__, __LINE__, rpm, FAN_MAX_RPM); - return ONLP_STATUS_E_PARAM; - } - return onlp_fani_percentage_set(id, _onlp_fani_rpm_to_percentage(rpm)); -} - - -/* - * 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 ret = 0, local_id = 0; - float val = (float)p * 2.55; - char data = (char)round(val); - - DIAG_PRINT("%s, id=%d, p=%d (0x%2X)", __FUNCTION__, id, p, (unsigned char)data); - - VALIDATE(id); - - local_id = ONLP_OID_ID_GET(id); - - /* Not support to stop fan */ - if (p == 0) - return ONLP_STATUS_E_INVALID; - else if (p == 100) - data = 0xff; - - /* Cannot control PWM for each fan modules respectively. - * All fan modules PWM will be the same. - */ - - ret = i2c_write_byte(CPLD_I2C_BUS_ID, CPLD_I2C_ADDR, CPLD_FAN_PWM_ADDR_OFFSET, data); - if (ret < 0) - AIM_LOG_INFO("%s:%d data[%02x] fail[%d]\n", __FUNCTION__, __LINE__, data, ret); - - if (DEBUG) - AIM_LOG_INFO("%s:%d id[%d],pwm_addr_offset[%02x],write_byte[%02x]\n", - __FUNCTION__, __LINE__, local_id, CPLD_FAN_PWM_ADDR_OFFSET, (unsigned char)data); - - 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) -{ - DIAG_PRINT("%s, ONLP_STATUS_E_UNSUPPORTED", __FUNCTION__); - 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) -{ - DIAG_PRINT("%s, ONLP_STATUS_E_UNSUPPORTED", __FUNCTION__); - return ONLP_STATUS_E_UNSUPPORTED; -} - -/* - * Generic fan ioctl. Optional. - */ -int -onlp_fani_ioctl(onlp_oid_t id, va_list vargs) -{ - DIAG_PRINT("%s, ONLP_STATUS_E_UNSUPPORTED", __FUNCTION__); - return ONLP_STATUS_E_UNSUPPORTED; -} - - diff --git a/packages/platforms/lenovo/x86-64/ne2572/onlp/builds/x86_64_lenovo_ne2572/module/src/ledi.c b/packages/platforms/lenovo/x86-64/ne2572/onlp/builds/x86_64_lenovo_ne2572/module/src/ledi.c deleted file mode 100644 index aaa203eb0..000000000 --- a/packages/platforms/lenovo/x86-64/ne2572/onlp/builds/x86_64_lenovo_ne2572/module/src/ledi.c +++ /dev/null @@ -1,744 +0,0 @@ -/************************************************************ - * - * - * Copyright 2014, 2015 Big Switch Networks, Inc. - * Copyright 2018 Alpha Networks Incorporation. - * - * Licensed under the Eclipse Public License, Version 1.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.eclipse.org/legal/epl-v10.html - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, - * either express or implied. See the License for the specific - * language governing permissions and limitations under the - * License. - * - * - ************************************************************ - * - * LED Management - * - ***********************************************************/ -#include -#include -#include -#include -#include "platform_lib.h" - -#include -//#include "onlpie_int.h" - -#define CPLD_I2C_BUS_ID 8 -#define CPLD_I2C_ADDR 0x5F /* System CPLD Physical Address in the I2C */ -#define CPLD_POWER_I2C_ADDR 0x5E /* System CPLD Physical Address in the I2C */ -#define CPLD_POWER_GREEN_OFFSET 0x0E -#define CPLD_SYS_LED_ADDRESS_OFFSET 0x08 -#define CPLD_FAN1_LED_ADDRESS_OFFSET 0x09 //Fan LED Register 0 -#define CPLD_FAN1_REAR_LED_ADDRESS_OFFSET 0x0E //Fan Rear LED Register 0 -#define CPLD_FAN2_REAR_LED_ADDRESS_OFFSET 0x0E -#define CPLD_FAN3_REAR_LED_ADDRESS_OFFSET 0x0F //Fan Rear LED Register 1 -#define CPLD_FAN4_REAR_LED_ADDRESS_OFFSET 0x0F -#define CPLD_FAN5_REAR_LED_ADDRESS_OFFSET 0x010 //Fan Rear LED Register 2 -#define CPLD_FAN6_REAR_LED_ADDRESS_OFFSET 0x010 -#define CPLD_SERVICE_LED_ADDRESS_OFFSET 0x11 //Service Blue LED Register - - -#define STACKING_LED_OFF 0x00 -#define STACKING_LED_AMBER_SOLID 0x01 -#define STACKING_LED_AMBER_BLINKING 0x03 -#define STACKING_LED_GREEN_SOLID 0x05 -#define STACKING_LED_GREEN_BLINKING 0x07 - -#define PWR_LED_OFF 0x00 -#define PWR_LED_AMBER_SOLID 0x01 -#define PWR_LED_AMBER_BLINKING 0x03 -#define PWR_LED_GREEN_SOLID 0x05 -#define PWR_LED_GREEN_BLINKING 0x07 - -#define SERVICE_LED_OFF 0x00 -#define SERVICE_LED_BLUE_SOLID 0x01 -#define SERVICE_LED_BLUE_BLINKING 0x03 -#define SERVICE_LED_GREEN_SOLID 0x01 -#define SERVICE_LED_GREEN_BLINKING 0x03 - -#define FAN_LED_OFF 0x00 -#define FAN_LED_AMBER_SOLID 0x01 -#define FAN_LED_AMBER_BLINKING 0x03 -#define FAN_LED_GREEN_SOLID 0x05 -#define FAN_LED_GREEN_BLINKING 0x07 - -#define REAR_FAN_LED_GREEN_SOLID 0x01 -#define REAR_FAN_LED_GREEN_BLINKING 0x03 - -#define VALIDATE(_id) \ - do { \ - if(!ONLP_OID_IS_LED(_id)) { \ - return ONLP_STATUS_E_INVALID; \ - } \ - } while(0) - -struct led_id_mode -{ - enum onlp_led_id led_id; - onlp_led_mode_t mode; - int hw_led_light_mode; -}; - -static struct led_id_mode led_id_mode_data[] = { - { LED_SERVICE, ONLP_LED_MODE_OFF, SERVICE_LED_OFF }, - { LED_SERVICE, ONLP_LED_MODE_GREEN, SERVICE_LED_GREEN_SOLID }, - { LED_SERVICE, ONLP_LED_MODE_GREEN_BLINKING, SERVICE_LED_GREEN_BLINKING }, - { LED_SERVICE, ONLP_LED_MODE_BLUE, SERVICE_LED_BLUE_SOLID }, - { LED_SERVICE, ONLP_LED_MODE_BLUE_BLINKING, SERVICE_LED_BLUE_BLINKING }, - { LED_SERVICE, ONLP_LED_MODE_ON, SERVICE_LED_BLUE_SOLID }, - - { LED_STACKING, ONLP_LED_MODE_OFF, STACKING_LED_OFF }, - { LED_STACKING, ONLP_LED_MODE_GREEN, STACKING_LED_GREEN_SOLID }, - { LED_STACKING, ONLP_LED_MODE_GREEN_BLINKING, STACKING_LED_GREEN_BLINKING }, - { LED_STACKING, ONLP_LED_MODE_ORANGE, STACKING_LED_AMBER_SOLID }, - { LED_STACKING, ONLP_LED_MODE_ORANGE_BLINKING, STACKING_LED_AMBER_BLINKING }, - { LED_STACKING, ONLP_LED_MODE_ON, STACKING_LED_GREEN_SOLID }, - - { LED_PWR, ONLP_LED_MODE_OFF, PWR_LED_OFF }, - { LED_PWR, ONLP_LED_MODE_GREEN, PWR_LED_GREEN_SOLID }, - { LED_PWR, ONLP_LED_MODE_GREEN_BLINKING, PWR_LED_GREEN_BLINKING }, - { LED_PWR, ONLP_LED_MODE_ORANGE, PWR_LED_AMBER_SOLID }, - { LED_PWR, ONLP_LED_MODE_ORANGE_BLINKING, PWR_LED_AMBER_BLINKING }, - { LED_PWR, ONLP_LED_MODE_ON, PWR_LED_GREEN_SOLID }, - - { LED_FAN, ONLP_LED_MODE_OFF, FAN_LED_OFF }, - { LED_FAN, ONLP_LED_MODE_GREEN, FAN_LED_GREEN_SOLID }, - { LED_FAN, ONLP_LED_MODE_GREEN_BLINKING, FAN_LED_GREEN_BLINKING }, - { LED_FAN, ONLP_LED_MODE_ORANGE, FAN_LED_AMBER_SOLID }, - { LED_FAN, ONLP_LED_MODE_ORANGE_BLINKING, FAN_LED_AMBER_BLINKING }, - { LED_FAN, ONLP_LED_MODE_ON, FAN_LED_GREEN_SOLID }, - - { LED_REAR_FAN1, ONLP_LED_MODE_OFF, FAN_LED_OFF }, - { LED_REAR_FAN1, ONLP_LED_MODE_GREEN, REAR_FAN_LED_GREEN_SOLID }, - { LED_REAR_FAN1, ONLP_LED_MODE_GREEN_BLINKING, REAR_FAN_LED_GREEN_BLINKING }, - { LED_REAR_FAN1, ONLP_LED_MODE_ON, REAR_FAN_LED_GREEN_SOLID }, - - { LED_REAR_FAN2, ONLP_LED_MODE_OFF, FAN_LED_OFF }, - { LED_REAR_FAN2, ONLP_LED_MODE_GREEN, REAR_FAN_LED_GREEN_SOLID }, - { LED_REAR_FAN2, ONLP_LED_MODE_GREEN_BLINKING, REAR_FAN_LED_GREEN_BLINKING }, - { LED_REAR_FAN2, ONLP_LED_MODE_ON, REAR_FAN_LED_GREEN_SOLID }, - - { LED_REAR_FAN3, ONLP_LED_MODE_OFF, FAN_LED_OFF }, - { LED_REAR_FAN3, ONLP_LED_MODE_GREEN, REAR_FAN_LED_GREEN_SOLID }, - { LED_REAR_FAN3, ONLP_LED_MODE_GREEN_BLINKING, REAR_FAN_LED_GREEN_BLINKING }, - { LED_REAR_FAN3, ONLP_LED_MODE_ON, REAR_FAN_LED_GREEN_SOLID }, - - { LED_REAR_FAN4, ONLP_LED_MODE_OFF, FAN_LED_OFF }, - { LED_REAR_FAN4, ONLP_LED_MODE_GREEN, REAR_FAN_LED_GREEN_SOLID }, - { LED_REAR_FAN4, ONLP_LED_MODE_GREEN_BLINKING, REAR_FAN_LED_GREEN_BLINKING }, - { LED_REAR_FAN4, ONLP_LED_MODE_ON, REAR_FAN_LED_GREEN_SOLID }, - - { LED_REAR_FAN5, ONLP_LED_MODE_OFF, FAN_LED_OFF }, - { LED_REAR_FAN5, ONLP_LED_MODE_GREEN, REAR_FAN_LED_GREEN_SOLID }, - { LED_REAR_FAN5, ONLP_LED_MODE_GREEN_BLINKING, REAR_FAN_LED_GREEN_BLINKING }, - { LED_REAR_FAN5, ONLP_LED_MODE_ON, REAR_FAN_LED_GREEN_SOLID }, - - { LED_REAR_FAN6, ONLP_LED_MODE_OFF, FAN_LED_OFF }, - { LED_REAR_FAN6, ONLP_LED_MODE_GREEN, REAR_FAN_LED_GREEN_SOLID }, - { LED_REAR_FAN6, ONLP_LED_MODE_GREEN_BLINKING, REAR_FAN_LED_GREEN_BLINKING }, - { LED_REAR_FAN6, ONLP_LED_MODE_ON, REAR_FAN_LED_GREEN_SOLID }, -}; - - -typedef union -{ - unsigned char val; - struct - { - unsigned char power :3; - unsigned char :1; /* reserved */ - unsigned char stacking :3; - unsigned char :1; /* reserved */ - }bit; - -}_CPLD_SYSTEM_LED_REG_T; - -typedef union -{ - unsigned char val; - struct - { - unsigned char locator :2; - unsigned char :6; /* reserved */ - }bit; - -}_CPLD_LOCATOR_LED_REG_T; - -typedef union -{ - unsigned char val; - struct - { - unsigned char fan_a :3; /* fan_a : FAN1/FAN3/FAN5, fan_b : FAN2/FAN4/FAN6 */ - unsigned char :1; /* reserved */ - unsigned char fan_b :3; - unsigned char :1; /* reserved */ - }bit; - -}_CPLD_FAN_LED_REG_T; - -/* - * Get the information for the given LED OID. - */ -static onlp_led_info_t linfo[] = -{ - { }, /* Not used */ - { - { ONLP_LED_ID_CREATE(LED_SERVICE), "Chassis LED 1 (SERVICE LED)", 0 }, - ONLP_LED_STATUS_PRESENT, - ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_BLUE | ONLP_LED_CAPS_BLUE_BLINKING | ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_GREEN_BLINKING, - }, - { - { ONLP_LED_ID_CREATE(LED_STACKING), "Chassis LED 2 (STACKING LED)", 0 }, - ONLP_LED_STATUS_PRESENT, - 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_PWR), "Chassis LED 3 (POWER LED)", 0 }, - ONLP_LED_STATUS_PRESENT, - 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_FAN), "Chassis LED 4 (FAN LED)", 0 }, - ONLP_LED_STATUS_PRESENT, - 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_REAR_FAN1), "FAN Rear LED 1", 0 }, - ONLP_LED_STATUS_PRESENT, - ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_GREEN_BLINKING, - }, - { - { ONLP_LED_ID_CREATE(LED_REAR_FAN2), "FAN Rear LED 2", 0 }, - ONLP_LED_STATUS_PRESENT, - ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_GREEN_BLINKING, - }, - { - { ONLP_LED_ID_CREATE(LED_REAR_FAN3), "FAN Rear LED 3", 0 }, - ONLP_LED_STATUS_PRESENT, - ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_GREEN_BLINKING, - }, - { - { ONLP_LED_ID_CREATE(LED_REAR_FAN4), "FAN Rear LED 4", 0 }, - ONLP_LED_STATUS_PRESENT, - ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_GREEN_BLINKING, - }, - { - { ONLP_LED_ID_CREATE(LED_REAR_FAN5), "FAN Rear LED 5", 0 }, - ONLP_LED_STATUS_PRESENT, - ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_GREEN_BLINKING, - }, - { - { ONLP_LED_ID_CREATE(LED_REAR_FAN6), "FAN Rear LED 6", 0 }, - ONLP_LED_STATUS_PRESENT, - ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_GREEN | ONLP_LED_CAPS_GREEN_BLINKING, - }, -}; - -static int convert_hw_led_light_mode_to_onlp(enum onlp_led_id id, int hw_mode) -{ - int i, nsize = sizeof(led_id_mode_data) / sizeof(led_id_mode_data[0]); - for (i = 0; i < nsize; i++) - { - if ((led_id_mode_data[i].led_id == id) && - (led_id_mode_data[i].hw_led_light_mode == hw_mode)) - { - DIAG_PRINT("%s, id:%d, hw_mode:%d mode:%d", __FUNCTION__, id, hw_mode, led_id_mode_data[i].mode); - return (int)led_id_mode_data[i].mode; - } - } - - return -1; -} - -static int convert_onlp_led_light_mode_to_hw(enum onlp_led_id id, onlp_led_mode_t mode) -{ - int i, nsize = sizeof(led_id_mode_data) / sizeof(led_id_mode_data[0]); - for (i = 0; i < nsize; i++) - { - if ((led_id_mode_data[i].led_id == id) && - (led_id_mode_data[i].mode == mode)) - { - DIAG_PRINT("%s, id:%d, mode:%d hw_mode:%d", __FUNCTION__, id, mode, led_id_mode_data[i].hw_led_light_mode); - return led_id_mode_data[i].hw_led_light_mode; - } - } - - return -1; -} - -/* - * This function will be called prior to any other onlp_ledi_* functions. - */ -int -onlp_ledi_init(void) -{ - DIAG_PRINT("%s", __FUNCTION__); -#if 0 - onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_SERVICE), ONLP_LED_MODE_OFF); - onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_STACKING), ONLP_LED_MODE_OFF); - onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_PWR), ONLP_LED_MODE_OFF); - - onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_FAN), ONLP_LED_MODE_OFF); - - onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_REAR_FAN1), ONLP_LED_MODE_OFF); - onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_REAR_FAN2), ONLP_LED_MODE_OFF); - onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_REAR_FAN3), ONLP_LED_MODE_OFF); - onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_REAR_FAN4), ONLP_LED_MODE_OFF); - onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_REAR_FAN5), ONLP_LED_MODE_OFF); - onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_REAR_FAN6), ONLP_LED_MODE_OFF); -#endif - return ONLP_STATUS_OK; -} - -int -onlp_ledi_info_get(onlp_oid_t id, onlp_led_info_t *info) -{ - DIAG_PRINT("%s, id=%d", __FUNCTION__, id); - _CPLD_LOCATOR_LED_REG_T service_led_reg; - _CPLD_SYSTEM_LED_REG_T system_led_reg; - _CPLD_FAN_LED_REG_T fan_led_reg; - char data = 0; - int ret = 0, local_id = 0; - - VALIDATE(id); - - /* Set the onlp_oid_hdr_t and capabilities */ - *info = linfo[ONLP_OID_ID_GET(id)]; - - local_id = ONLP_OID_ID_GET(id); - - switch (local_id) - { - case LED_SERVICE: - //Read Blue LED - ret = i2c_read_byte(CPLD_I2C_BUS_ID, CPLD_I2C_ADDR, CPLD_SERVICE_LED_ADDRESS_OFFSET, &data); - if (ret < 0) - { - AIM_LOG_INFO("%s:%d fail[%d]\n", __FUNCTION__, __LINE__, ret); - return ret; - } - service_led_reg.val = data; - //Green LED on, Blue LED off - if(data == 0) - { - ret = i2c_read_byte(CPLD_I2C_BUS_ID, CPLD_POWER_I2C_ADDR , CPLD_POWER_GREEN_OFFSET, &data); - if (ret < 0) - { - AIM_LOG_INFO("%s:%d fail[%d]\n", __FUNCTION__, __LINE__, ret); - return ret; - } - service_led_reg.val = data; - - if(service_led_reg.val == SERVICE_LED_GREEN_SOLID) - info->mode = ONLP_LED_MODE_GREEN; - else if(service_led_reg.val == SERVICE_LED_GREEN_BLINKING) - info->mode = ONLP_LED_MODE_GREEN_BLINKING; - } - //GREEN LED off, Blue LED on - else - { - if(service_led_reg.val == SERVICE_LED_BLUE_SOLID) - info->mode = ONLP_LED_MODE_BLUE; - else if(service_led_reg.val == SERVICE_LED_BLUE_BLINKING) - info->mode = ONLP_LED_MODE_BLUE_BLINKING; - } - //Check LED OFF or not - if(service_led_reg.val == SERVICE_LED_OFF) - info->mode = ONLP_LED_MODE_OFF; - - if (ret < 0) - { - AIM_LOG_INFO("%s:%d fail[%d]\n", __FUNCTION__, __LINE__, ret); - return ret; - } - break; - case LED_PWR: - case LED_STACKING: - ret = i2c_read_byte(CPLD_I2C_BUS_ID, CPLD_I2C_ADDR, CPLD_SYS_LED_ADDRESS_OFFSET, &data); - if (ret < 0) - { - AIM_LOG_INFO("%s:%d fail[%d]\n", __FUNCTION__, __LINE__, ret); - return ret; - } - system_led_reg.val = data; - break; - case LED_FAN: - ret = i2c_read_byte(CPLD_I2C_BUS_ID, CPLD_I2C_ADDR, CPLD_FAN1_LED_ADDRESS_OFFSET, &data); - if (ret < 0) - { - AIM_LOG_INFO("%s:%d fail[%d]\n", __FUNCTION__, __LINE__, ret); - return ret; - } - fan_led_reg.val = data; - break; - case LED_REAR_FAN1: - case LED_REAR_FAN2: - ret = i2c_read_byte(CPLD_I2C_BUS_ID, CPLD_I2C_ADDR, CPLD_FAN1_REAR_LED_ADDRESS_OFFSET, &data); - if (ret < 0) - { - AIM_LOG_INFO("%s:%d fail[%d]\n", __FUNCTION__, __LINE__, ret); - return ret; - } - fan_led_reg.val = data; - break; - case LED_REAR_FAN3: - case LED_REAR_FAN4: - ret = i2c_read_byte(CPLD_I2C_BUS_ID, CPLD_I2C_ADDR, CPLD_FAN3_REAR_LED_ADDRESS_OFFSET, &data); - if (ret < 0) - { - AIM_LOG_INFO("%s:%d fail[%d]\n", __FUNCTION__, __LINE__, ret); - return ret; - } - fan_led_reg.val = data; - break; - case LED_REAR_FAN5: - case LED_REAR_FAN6: - ret = i2c_read_byte(CPLD_I2C_BUS_ID, CPLD_I2C_ADDR, CPLD_FAN5_REAR_LED_ADDRESS_OFFSET, &data); - if (ret < 0) - { - AIM_LOG_INFO("%s:%d fail[%d]\n", __FUNCTION__, __LINE__, ret); - return ret; - } - fan_led_reg.val = data; - break; - default : - AIM_LOG_INFO("%s:%d %d is a wrong ID\n", __FUNCTION__, __LINE__, local_id); - return ONLP_STATUS_E_PARAM; - } - - /* Get LED status */ - switch (local_id) - { - case LED_SERVICE: - //info->mode = convert_hw_led_light_mode_to_onlp(local_id, service_led_reg.bit.locator); - break; - case LED_PWR: - info->mode = convert_hw_led_light_mode_to_onlp(local_id, system_led_reg.bit.power); - break; - case LED_STACKING: - info->mode = convert_hw_led_light_mode_to_onlp(local_id, system_led_reg.bit.stacking); - break; - case LED_FAN: - case LED_REAR_FAN1: - case LED_REAR_FAN3: - case LED_REAR_FAN5: - //debug - //printf("[%s] fan_led_reg.val:0x%x \n", __FUNCTION__, fan_led_reg.val); - info->mode = convert_hw_led_light_mode_to_onlp(local_id, fan_led_reg.bit.fan_a); - break; - case LED_REAR_FAN2: - case LED_REAR_FAN4: - case LED_REAR_FAN6: - //debug - //printf("[%s] fan_led_reg.val:0x%x \n", __FUNCTION__, fan_led_reg.val); - info->mode = convert_hw_led_light_mode_to_onlp(local_id, fan_led_reg.bit.fan_b); - break; - - default: - AIM_LOG_INFO("%s:%d %d is a wrong ID\n", __FUNCTION__, __LINE__, local_id); - return ONLP_STATUS_E_PARAM; - } - - /* Set the on/off status */ - if (info->mode != ONLP_LED_MODE_OFF) - { - info->status |= ONLP_LED_STATUS_ON; - } - -//debug - //printf("[%s] local_id:%d info->mode:%d info->status:%d\n", __FUNCTION__, local_id, info->mode, info->status); - - 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) -{ - DIAG_PRINT("%s, id=%d, on_or_off=%d", __FUNCTION__, id, on_or_off); - VALIDATE(id); - - if (!on_or_off) - { - return onlp_ledi_mode_set(id, ONLP_LED_MODE_OFF); - } - - return onlp_ledi_mode_set(id, ONLP_LED_MODE_ON); -} - -/* - * 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) -{ - DIAG_PRINT("%s, id=%d, mode=%d", __FUNCTION__, id, mode); - _CPLD_LOCATOR_LED_REG_T service_led_reg; - _CPLD_SYSTEM_LED_REG_T system_led_reg; - _CPLD_FAN_LED_REG_T fan_led_reg; - char data = 0; - int ret = 0, local_id = 0, hw_led_mode = 0; - VALIDATE(id); - - local_id = ONLP_OID_ID_GET(id); - - switch (local_id) - { - case LED_SERVICE: - //Blue LED - if (mode == ONLP_LED_MODE_BLUE || mode == ONLP_LED_MODE_BLUE_BLINKING || mode == ONLP_LED_MODE_ON ) - { - ret = i2c_read_byte(CPLD_I2C_BUS_ID, CPLD_I2C_ADDR, CPLD_SERVICE_LED_ADDRESS_OFFSET, &data); - if (ret < 0) - { - AIM_LOG_INFO("%s:%d fail[%d]\n", __FUNCTION__, __LINE__, ret); - return ret; - } - service_led_reg.val = data; - } - //Green LED - else if (mode == ONLP_LED_MODE_GREEN || mode == ONLP_LED_MODE_GREEN_BLINKING) - { - ret = i2c_read_byte(CPLD_I2C_BUS_ID, CPLD_POWER_I2C_ADDR , CPLD_POWER_GREEN_OFFSET, &data); - if (ret < 0) - { - AIM_LOG_INFO("%s:%d fail[%d]\n", __FUNCTION__, __LINE__, ret); - return ret; - } - service_led_reg.val = data; - } - break; - case LED_PWR: - case LED_STACKING: - ret = i2c_read_byte(CPLD_I2C_BUS_ID, CPLD_I2C_ADDR, CPLD_SYS_LED_ADDRESS_OFFSET, &data); - if (ret < 0) - { - AIM_LOG_INFO("%s:%d fail[%d]\n", __FUNCTION__, __LINE__, ret); - return ret; - } - system_led_reg.val = data; - break; - case LED_FAN: - ret = i2c_read_byte(CPLD_I2C_BUS_ID, CPLD_I2C_ADDR, CPLD_FAN1_LED_ADDRESS_OFFSET, &data); - if (ret < 0) - { - AIM_LOG_INFO("%s:%d fail[%d]\n", __FUNCTION__, __LINE__, ret); - return ret; - } - fan_led_reg.val = data; - break; - - case LED_REAR_FAN1: - case LED_REAR_FAN2: - ret = i2c_read_byte(CPLD_I2C_BUS_ID, CPLD_I2C_ADDR, CPLD_FAN1_REAR_LED_ADDRESS_OFFSET, &data); - if (ret < 0) - { - AIM_LOG_INFO("%s:%d fail[%d]\n", __FUNCTION__, __LINE__, ret); - return ret; - } - fan_led_reg.val = data; - break; - case LED_REAR_FAN3: - case LED_REAR_FAN4: - ret = i2c_read_byte(CPLD_I2C_BUS_ID, CPLD_I2C_ADDR, CPLD_FAN3_REAR_LED_ADDRESS_OFFSET, &data); - if (ret < 0) - { - AIM_LOG_INFO("%s:%d fail[%d]\n", __FUNCTION__, __LINE__, ret); - return ret; - } - fan_led_reg.val = data; - break; - case LED_REAR_FAN5: - case LED_REAR_FAN6: - ret = i2c_read_byte(CPLD_I2C_BUS_ID, CPLD_I2C_ADDR, CPLD_FAN5_REAR_LED_ADDRESS_OFFSET, &data); - if (ret < 0) - { - AIM_LOG_INFO("%s:%d fail[%d]\n", __FUNCTION__, __LINE__, ret); - return ret; - } - fan_led_reg.val = data; - break; - default : - AIM_LOG_INFO("%s:%d %d is a wrong ID\n", __FUNCTION__, __LINE__, local_id); - return ONLP_STATUS_E_PARAM; - } - - hw_led_mode = convert_onlp_led_light_mode_to_hw(local_id, mode); - if (hw_led_mode < 0) - return ONLP_STATUS_E_PARAM; - - /* Set LED light mode */ - switch (local_id) - { - case LED_SERVICE: - service_led_reg.bit.locator = hw_led_mode; - break; - case LED_PWR: - system_led_reg.bit.power = hw_led_mode; - break; - case LED_STACKING: - system_led_reg.bit.stacking = hw_led_mode; - break; - case LED_FAN: - case LED_REAR_FAN1: - case LED_REAR_FAN3: - case LED_REAR_FAN5: - fan_led_reg.bit.fan_a = hw_led_mode; - break; - case LED_REAR_FAN2: - case LED_REAR_FAN4: - case LED_REAR_FAN6: - fan_led_reg.bit.fan_b = hw_led_mode; - break; - default: - AIM_LOG_INFO("%s:%d %d is a wrong ID\n", __FUNCTION__, __LINE__, local_id); - return ONLP_STATUS_E_PARAM; - } - - switch (local_id) - { - case LED_SERVICE: - //printf("[debug]service_led_reg.val:0x%x\n", service_led_reg.val); - //BLUE LED on - if (mode == ONLP_LED_MODE_BLUE || mode == ONLP_LED_MODE_BLUE_BLINKING || mode == ONLP_LED_MODE_ON) - { - //turn on blue LED - ret = i2c_write_byte(CPLD_I2C_BUS_ID, CPLD_I2C_ADDR, CPLD_SERVICE_LED_ADDRESS_OFFSET, service_led_reg.val); - if (ret < 0) - { - AIM_LOG_INFO("%s:%d fail[%d]\n", __FUNCTION__, __LINE__, ret); - return ret; - } - //turn off green LED - service_led_reg.bit.locator = 0; - ret = i2c_write_byte(CPLD_I2C_BUS_ID, CPLD_POWER_I2C_ADDR, CPLD_POWER_GREEN_OFFSET, service_led_reg.val); - if (ret < 0) - { - AIM_LOG_INFO("%s:%d fail[%d]\n", __FUNCTION__, __LINE__, ret); - return ret; - } - } - //Green LED on - else if (mode == ONLP_LED_MODE_GREEN || mode == ONLP_LED_MODE_GREEN_BLINKING) - { - //turn on green led - ret = i2c_write_byte(CPLD_I2C_BUS_ID, CPLD_POWER_I2C_ADDR, CPLD_POWER_GREEN_OFFSET, service_led_reg.val); - if (ret < 0) - { - AIM_LOG_INFO("%s:%d fail[%d]\n", __FUNCTION__, __LINE__, ret); - return ret; - } - //turn off blue led - service_led_reg.bit.locator = 0; - ret = i2c_write_byte(CPLD_I2C_BUS_ID, CPLD_I2C_ADDR, CPLD_SERVICE_LED_ADDRESS_OFFSET, service_led_reg.val); - if (ret < 0) - { - AIM_LOG_INFO("%s:%d fail[%d]\n", __FUNCTION__, __LINE__, ret); - return ret; - } - } - // ONLP_LED_MODE_OFF - else - { - service_led_reg.bit.locator = 0; - //turn off blue led - ret = i2c_write_byte(CPLD_I2C_BUS_ID, CPLD_I2C_ADDR, CPLD_SERVICE_LED_ADDRESS_OFFSET, service_led_reg.val); - if (ret < 0) - { - AIM_LOG_INFO("%s:%d fail[%d]\n", __FUNCTION__, __LINE__, ret); - return ret; - } - //turn off green led - ret = i2c_write_byte(CPLD_I2C_BUS_ID, CPLD_POWER_I2C_ADDR, CPLD_POWER_GREEN_OFFSET, service_led_reg.val); - if (ret < 0) - { - AIM_LOG_INFO("%s:%d fail[%d]\n", __FUNCTION__, __LINE__, ret); - return ret; - } - } - break; - case LED_PWR: - case LED_STACKING: - ret = i2c_write_byte(CPLD_I2C_BUS_ID, CPLD_I2C_ADDR, CPLD_SYS_LED_ADDRESS_OFFSET, system_led_reg.val); - if (ret < 0) - { - AIM_LOG_INFO("%s:%d fail[%d]\n", __FUNCTION__, __LINE__, ret); - return ret; - } - break; - case LED_FAN: - ret = i2c_write_byte(CPLD_I2C_BUS_ID, CPLD_I2C_ADDR, CPLD_FAN1_LED_ADDRESS_OFFSET, fan_led_reg.val); - if (ret < 0) - { - AIM_LOG_INFO("%s:%d fail[%d]\n", __FUNCTION__, __LINE__, ret); - return ret; - } - break; - case LED_REAR_FAN1: - case LED_REAR_FAN2: - ret = i2c_write_byte(CPLD_I2C_BUS_ID, CPLD_I2C_ADDR, CPLD_FAN1_REAR_LED_ADDRESS_OFFSET, fan_led_reg.val); - if (ret < 0) - { - AIM_LOG_INFO("%s:%d fail[%d]\n", __FUNCTION__, __LINE__, ret); - return ret; - } - fan_led_reg.val = data; - break; - case LED_REAR_FAN3: - case LED_REAR_FAN4: - ret = i2c_write_byte(CPLD_I2C_BUS_ID, CPLD_I2C_ADDR, CPLD_FAN3_REAR_LED_ADDRESS_OFFSET, fan_led_reg.val); - if (ret < 0) - { - AIM_LOG_INFO("%s:%d fail[%d]\n", __FUNCTION__, __LINE__, ret); - return ret; - } - fan_led_reg.val = data; - break; - case LED_REAR_FAN5: - case LED_REAR_FAN6: - ret = i2c_write_byte(CPLD_I2C_BUS_ID, CPLD_I2C_ADDR, CPLD_FAN5_REAR_LED_ADDRESS_OFFSET, fan_led_reg.val); - if (ret < 0) - { - AIM_LOG_INFO("%s:%d fail[%d]\n", __FUNCTION__, __LINE__, ret); - return ret; - } - fan_led_reg.val = data; - break; - default : - AIM_LOG_INFO("%s:%d %d is a wrong ID\n", __FUNCTION__, __LINE__, local_id); - return ONLP_STATUS_E_PARAM; - } - - 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/lenovo/x86-64/ne2572/onlp/builds/x86_64_lenovo_ne2572/module/src/make.mk b/packages/platforms/lenovo/x86-64/ne2572/onlp/builds/x86_64_lenovo_ne2572/module/src/make.mk deleted file mode 100644 index 07809e5da..000000000 --- a/packages/platforms/lenovo/x86-64/ne2572/onlp/builds/x86_64_lenovo_ne2572/module/src/make.mk +++ /dev/null @@ -1,9 +0,0 @@ -############################################################################### -# -# -# -############################################################################### - -LIBRARY := x86_64_lenovo_ne2572 -$(LIBRARY)_SUBDIR := $(dir $(lastword $(MAKEFILE_LIST))) -include $(BUILDER)/lib.mk diff --git a/packages/platforms/lenovo/x86-64/ne2572/onlp/builds/x86_64_lenovo_ne2572/module/src/platform_lib.c b/packages/platforms/lenovo/x86-64/ne2572/onlp/builds/x86_64_lenovo_ne2572/module/src/platform_lib.c deleted file mode 100644 index 9658a0366..000000000 --- a/packages/platforms/lenovo/x86-64/ne2572/onlp/builds/x86_64_lenovo_ne2572/module/src/platform_lib.c +++ /dev/null @@ -1,859 +0,0 @@ -/************************************************************ - * - * - * Copyright 2014 Big Switch Networks, Inc. - * Copyright 2018 Alpha Networks Incorporation - * - * Licensed under the Eclipse Public License, Version 1.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.eclipse.org/legal/epl-v10.html - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT 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" -#include - -#define DEBUG_FLAG 0 - -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, sizeof(buf) - 1, 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 || data_len < 0) - { - return -1; - } - - ret = deviceNodeReadBinary(filename, buffer, buf_size - 1, data_len); - - if (ret == 0) - { - if (data_len) - { - buffer[data_len] = '\0'; - } - else - { - buffer[buf_size - 1] = '\0'; - } - } - - return ret; -} - - -int psu_two_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; -} - - -/* -i2c APIs: access i2c device by ioctl -static int i2c_read(int i2cbus, int addr, int offset, int length, char* data) -static int i2c_read_byte(int i2cbus, int addr, int offset, char* data) -static int i2c_read_word(int i2cbus, int addr, int command) -static int i2c_write_byte(int i2cbus, int addr, int offset, char val) -static int i2c_write_bit(int i2cbus, int addr, int offset, int bit, char val) -*/ -int i2c_read(int i2cbus, int addr, int offset, int length, char *data) -{ - int file; - int i; - char filename[20]; - - /*open i2c device*/ - snprintf(filename, sizeof(filename), "/dev/i2c/%d", i2cbus); - filename[sizeof(filename) - 1] = '\0'; - file = open(filename, O_RDWR); - - if (file < 0) - { - sprintf(filename, "/dev/i2c-%d", i2cbus); - file = open(filename, O_RDWR); - } - if (file < 0) - { - AIM_LOG_INFO("Unable to open id:%d %s\r\n", i2cbus, filename); - return -1; - } - -#if 0/*check funcs*/ - unsigned long funcs; - if (ioctl(file, I2C_FUNCS, &funcs) < 0) - { - AIM_LOG_INFO("Error: Could not get the adapter\r\n"); - return -1; - } - //I2C_SMBUS_BLOCK_DATA -#endif - - /*set slave address set_slave_addr(file, address, force))*/ - - if (ioctl(file, I2C_SLAVE_FORCE, addr) < 0) - //if (ioctl(file, I2C_SLAVE, addr) < 0) - { - AIM_LOG_INFO("Error: Could not set address to 0x%02x, %s \r\n", addr, strerror(errno)); - close(file); - return -errno; - } - -#if 1 - int res = 0; - for (i = 0; i < length; i++) - { - res = i2c_smbus_read_byte_data(file, offset + i); - if (res < 0 && DEBUG_FLAG) - { - AIM_LOG_INFO("Error: i2c_smbus_read_byte_data offset:%d\r\n", offset + i); - close(file); - return res; - } - data[i] = res; - } - -#else - - /*i2c_smbus_read_block_data(file, bank, cblock);*/ - int res = 0; - unsigned char cblock[288]; - res = i2c_smbus_read_block_data(file, 0, cblock); - i2c_smbus_read_byte_data(file, i+j) - if(res < 0) - { - AIM_LOG_INFO("Error: read failed res:%d\r\n", res); - return -1; - } - - if((offset + length) > res) - { - AIM_LOG_INFO("Error: Size out of range offset:%d l:%d res:%d\r\n", offset, length, res); - return -1; - } - - for (i = 0; i < length; i++) - { - data[i] = cblock[offset + i]; - } -#endif - - close(file); - return 0; -} - -int i2c_sequential_read(int i2cbus, int addr, int offset, int length, char *data) -{ - int file; - int i; - char filename[20]; - int res = 0; - - /*open i2c device*/ - snprintf(filename, sizeof(filename), "/dev/i2c/%d", i2cbus); - filename[sizeof(filename) - 1] = '\0'; - file = open(filename, O_RDWR); - - if (file < 0) - { - sprintf(filename, "/dev/i2c-%d", i2cbus); - file = open(filename, O_RDWR); - } - if (file < 0) - { - AIM_LOG_INFO("Unable to open id:%d %s\r\n", i2cbus, filename); - return -1; - } - - /*set slave address set_slave_addr(file, address, force))*/ - - if (ioctl(file, I2C_SLAVE_FORCE, addr) < 0) - { - AIM_LOG_INFO("Error: Could not set address to 0x%02x, %s \r\n", addr, strerror(errno)); - close(file); - return -errno; - } - /* - Sequential Read for at24c128 - use i2c_smbus_write_byte_data to write 24c128 address counter(two 8-bit data word addresses) - 24c128: - +----------------------------------------------------+ - | S | Device | Wr | A | 1st Word | A | 2nd Word | A |... - | | Address | | | Address | | Address | | - +----------------------------------------------------+ - SMbus: - +----------------------------------------------------+ - | S | Device | Wr | A | Command | A | Data | A |... - | | Address | | | | | | | - +----------------------------------------------------+ - - */ - res = i2c_smbus_write_byte_data(file, (uint8_t)offset >> 8, (uint8_t)offset); - - if (res != 0) - { - AIM_LOG_INFO("Error: Write start address failed, return code %d\n", res); - return -1; - } - - for (i = 0; i < length; i++) - { - res = i2c_smbus_read_byte(file); - - if (res < 0 && DEBUG_FLAG) - { - AIM_LOG_INFO("Error: i2c_smbus_read_byte_data offset:%d\r\n", offset + i); - close(file); - return res; - } - data[i] = res; - } - - close(file); - return 0; -} - -int i2c_read_rps_status(int i2cbus, int addr, int offset) -{ - int file; - //int i; - char filename[20]; - - /*open i2c device*/ - snprintf(filename, sizeof(filename), "/dev/i2c/%d", i2cbus); - filename[sizeof(filename) - 1] = '\0'; - file = open(filename, O_RDWR); - - if (file < 0) - { - sprintf(filename, "/dev/i2c-%d", i2cbus); - file = open(filename, O_RDWR); - } - if (file < 0) - { - AIM_LOG_INFO("Unable to open id:%d %s\r\n", i2cbus, filename); - return -1; - } - -#if 0/*check funcs*/ - unsigned long funcs; - if (ioctl(file, I2C_FUNCS, &funcs) < 0) - { - AIM_LOG_INFO("Error: Could not get the adapter\r\n"); - return -1; - } - //I2C_SMBUS_BLOCK_DATA -#endif - - /*set slave address set_slave_addr(file, address, force))*/ - - //if (ioctl(file, I2C_SLAVE_FORCE, addr) < 0) - if (ioctl(file, I2C_SLAVE, addr) < 0) - { - AIM_LOG_INFO("Error: Could not set address to 0x%02x, %s \r\n", addr, strerror(errno)); - close(file); - return -errno; - } - - int res = 0; - res = i2c_smbus_read_byte_data(file, offset); - if (res < 0 && DEBUG_FLAG) - { - AIM_LOG_INFO("Error: i2c_smbus_read_byte_data offset:%d\r\n", offset); - close(file); - return res; - } - - close(file); - return res; -} - -int _i2c_read_word_data(int i2cbus, int addr, int offset) -{ - int file; - //int i; - char filename[20]; - - /*open i2c device*/ - snprintf(filename, sizeof(filename), "/dev/i2c/%d", i2cbus); - filename[sizeof(filename) - 1] = '\0'; - file = open(filename, O_RDWR); - - if (file < 0) - { - sprintf(filename, "/dev/i2c-%d", i2cbus); - file = open(filename, O_RDWR); - } - if (file < 0) - { - AIM_LOG_INFO("Unable to open id:%d %s\r\n", i2cbus, filename); - return -1; - } - -#if 0/*check funcs*/ - unsigned long funcs; - if (ioctl(file, I2C_FUNCS, &funcs) < 0) - { - AIM_LOG_INFO("Error: Could not get the adapter\r\n"); - return -1; - } - //I2C_SMBUS_BLOCK_DATA -#endif - - /*set slave address set_slave_addr(file, address, force))*/ - - //if (ioctl(file, I2C_SLAVE_FORCE, addr) < 0) - if (ioctl(file, I2C_SLAVE, addr) < 0) - { - AIM_LOG_INFO("Error: Could not set address to 0x%02x, %s \r\n", offset, strerror(errno)); - close(file); - return -errno; - } - -#if 1 - int res = 0; - - res = i2c_smbus_read_word_data(file, offset); - if (res < 0 && DEBUG_FLAG) - { - AIM_LOG_INFO("Error: i2c_smbus_read_word_data status:%d\r\n", res); - //close(file); - //return res; - } - -#else - - /*i2c_smbus_read_block_data(file, bank, cblock);*/ - int res = 0; - unsigned char cblock[288]; - res = i2c_smbus_read_block_data(file, 0, cblock); - i2c_smbus_read_byte_data(file, i+j) - if(res < 0) - { - AIM_LOG_INFO("Error: read failed res:%d\r\n", res); - return -1; - } - - if((offset + length) > res) - { - AIM_LOG_INFO("Error: Size out of range offset:%d l:%d res:%d\r\n", offset, length, res); - return -1; - } - - for (i = 0; - i < length; - i++) - { - data[i] = cblock[offset + i]; - } -#endif - - close(file); - return res; -} - -int i2c_read_byte(int i2cbus, int addr, int offset, char *data) -{ - int ret; - - ret = i2c_read(i2cbus, addr, offset, 1, data); - - if (ret < 0 && DEBUG_FLAG) - { - AIM_LOG_INFO("Error: Read failed %d\r\n", ret); - } - - //AIM_LOG_INFO("i2c_read_byte: bus:%d add:0x%x offset:%d ret:%d data:0x%x\r\n", i2cbus, addr, offset, ret, *data); - - return ret; -} - -int i2c_read_word(int i2cbus, int addr, int offset) -{ - int ret; - - ret = _i2c_read_word_data(i2cbus, addr, offset); - - if (ret < 0 && DEBUG_FLAG) - { - AIM_LOG_INFO("Error: Read failed %d\r\n", ret); - } - - //AIM_LOG_INFO("i2c_read_word: bus:%d add:0x%x offset:%d ret:%d\r\n", i2cbus, addr, offset, ret); - - return ret; -} - -int _i2c_read_block_data(int i2cbus, int addr, uint8_t offset, uint8_t *data, int data_length) -{ - int file; - char filename[20]; - - /*open i2c device*/ - snprintf(filename, sizeof(filename), "/dev/i2c/%d", i2cbus); - filename[sizeof(filename) - 1] = '\0'; - file = open(filename, O_RDWR); - - if (file < 0) - { - sprintf(filename, "/dev/i2c-%d", i2cbus); - file = open(filename, O_RDWR); - } - if (file < 0) - { - AIM_LOG_INFO("Unable to open id:%d %s\r\n", i2cbus, filename); - return -1; - } - -#if 0/*check funcs*/ - unsigned long funcs; - if (ioctl(file, I2C_FUNCS, &funcs) < 0) - { - AIM_LOG_INFO("Error: Could not get the adapter\r\n"); - return -1; - } - //I2C_SMBUS_BLOCK_DATA -#endif - - /*set slave address set_slave_addr(file, address, force))*/ - - if (ioctl(file, I2C_SLAVE_FORCE, addr) < 0) - //if (ioctl(file, I2C_SLAVE, addr) < 0) - { - AIM_LOG_INFO("Error: Could not set address to 0x%02x, %s \r\n", addr, strerror(errno)); - close(file); - return -errno; - } - - int res = 0; - res = i2c_smbus_read_i2c_block_data(file, offset, data_length, data); - if (res < 0 && DEBUG_FLAG) - { - AIM_LOG_INFO("Error: i2c_smbus_read_word_data status:%d\r\n", res); - //close(file); - //return res; - } - - close(file); - return res; -} - -int i2c_read_block(int i2cbus, int addr, uint8_t offset, uint8_t *data, int length) -{ - int ret; - - ret = _i2c_read_block_data(i2cbus, addr, offset, data, length); - - if (ret < 0 && DEBUG_FLAG) - { - AIM_LOG_INFO("Error: Read failed %d\r\n", ret); - } - //AIM_LOG_INFO("i2c_read_block: bus:%d add:0x%x offset:%d ret:%d data:0x%x\r\n", i2cbus, addr, offset, ret, *data); - - return ret; -} - -int _i2c_read_i2c_block_data_dump(int i2cbus, int addr, uint8_t *data) -{ - int file; - char filename[20]; - int res = 0; - int i = 0; - unsigned char cblock[288]; - - /*open i2c device*/ - snprintf(filename, sizeof(filename), "/dev/i2c/%d", i2cbus); - filename[sizeof(filename) - 1] = '\0'; - file = open(filename, O_RDWR); - - if (file < 0) - { - sprintf(filename, "/dev/i2c-%d", i2cbus); - file = open(filename, O_RDWR); - } - if (file < 0) - { - AIM_LOG_INFO("Unable to open id:%d %s\r\n", i2cbus, filename); - return -1; - } - -#if 0/*check funcs*/ - unsigned long funcs; - if (ioctl(file, I2C_FUNCS, &funcs) < 0) - { - AIM_LOG_INFO("Error: Could not get the adapter\r\n"); - return -1; - } - //I2C_SMBUS_BLOCK_DATA -#endif - - /*set slave address set_slave_addr(file, address, force))*/ - - if (ioctl(file, I2C_SLAVE_FORCE, addr) < 0) - //if (ioctl(file, I2C_SLAVE, addr) < 0) - { - AIM_LOG_INFO("Error: Could not set address to 0x%02x, %s \r\n", addr, strerror(errno)); - close(file); - return -errno; - } - - for (res = 0; res < 256; res += i) - { - i = i2c_smbus_read_i2c_block_data(file, res, 32, cblock + res); - if (i <= 0) - { - res = i; - break; - } - } - - if (res < 0 && DEBUG_FLAG) - { - AIM_LOG_INFO("Error: i2c_smbus_read_word_data status:%d\r\n", res); - close(file); - return res; - } - - if (res >= 256) - res = 256; - for (i = 0; i < res; i++) data[i] = cblock[i]; - - close(file); - return res; -} - -int i2c_read_i2c_block_dump(int i2cbus, int addr, uint8_t *data) -{ - int ret; - - ret = _i2c_read_i2c_block_data_dump(i2cbus, addr, data); - - if (ret < 0 && DEBUG_FLAG) - { - AIM_LOG_INFO("Error: Read failed %d\r\n", ret); - } - //AIM_LOG_INFO("i2c_read_block: bus:%d add:0x%x offset:%d ret:%d data:0x%x\r\n", i2cbus, addr, offset, ret, *data); - - return ret; -} - -int i2c_write_byte(int i2cbus, int addr, int offset, char val) -{ - int file; - char filename[20]; - int res = 0; - -#if 0/*get current value*/ - char cur_val=0; - res = i2c_read_byte(i2cbus, addr, offset, &cur_val); - if (ret <0) - { - return res; - } -#endif - - /*open i2c device*/ - snprintf(filename, sizeof(filename), "/dev/i2c/%d", i2cbus); - filename[sizeof(filename) - 1] = '\0'; - file = open(filename, O_RDWR); - - if (file < 0) - { - sprintf(filename, "/dev/i2c-%d", i2cbus); - file = open(filename, O_RDWR); - } - if (file < 0) - { - AIM_LOG_INFO("Unable to open id:%d %s\r\n", i2cbus, filename); - return -1; - } - - /*set slave address set_slave_addr(file, address, force))*/ - - //if (ioctl(file, I2C_SLAVE_FORCE, addr) < 0) - if (ioctl(file, I2C_SLAVE, addr) < 0) - { - AIM_LOG_INFO("Error: Could not set address to 0x%02x, %s \r\n", addr, strerror(errno)); - close(file); - return -errno; - } - - res = i2c_smbus_write_byte_data(file, offset, val); - if (res < 0) - { - AIM_LOG_INFO("Error: i2c_smbus_write_byte_data offset:%d val:0x%x r:%d\r\n", offset, val, res); - close(file); - return res; - } - close(file); - return 0; -} - -int i2c_write_bit(int i2cbus, int addr, int offset, int bit, char val) -{ - - int res = 0; - char cur_val = 0; - char new_val = 0; - if (val != 0 && val != 1) - { - AIM_LOG_INFO("Error: i2c_write_bit error val:%d\r\n", val); - return -1; - } - - if (bit < 0 && bit > 7) - { - AIM_LOG_INFO("Error: i2c_write_bit error bit:%d\r\n", bit); - return -1; - } - - res = i2c_read_byte(i2cbus, addr, offset, &cur_val); - if (res < 0) - { - return res; - } - - if (val == 1) - { - new_val = cur_val | (1 << bit); - } - else - { - new_val = cur_val & ~(1 << bit); - } - - //AIM_LOG_INFO("i2c_write_bit %d-0x%x-%d cur:0x%x new:0x%x\r\n", i2cbus, addr, offset, cur_val, new_val); - - if (new_val == cur_val) - { - return 0; - } - - res = i2c_write_byte(i2cbus, addr, offset, new_val); - if (res < 0) - { - return res; - } - - return 0; -} - -static char diag_flag = 0; - -char diag_flag_set(char d) -{ - diag_flag = d; - return 0; -} - -char diag_flag_get(void) -{ - return diag_flag; -} - -char diag_debug_trace_on(void) -{ - system("echo 1 > /tmp/onlpi_dbg_trace"); - return 0; -} - -char diag_debug_trace_off(void) -{ - system("echo 0 > /tmp/onlpi_dbg_trace"); - return 0; -} - -char diag_debug_trace_check(void) -{ - char flag = 0; - FILE *file = fopen("/tmp/onlpi_dbg_trace", "r"); - if (file == NULL) - { - return 0; - } - flag = fgetc(file); - fclose(file); - - return (flag == '1') ? 1 : 0; -} - -char* sfp_control_to_str(int value) -{ - switch (value) - { - case ONLP_SFP_CONTROL_RESET: - return "RESET"; - case ONLP_SFP_CONTROL_RESET_STATE: - return "RESET_STATE"; - case ONLP_SFP_CONTROL_RX_LOS: - return "RX_LOS"; - case ONLP_SFP_CONTROL_TX_FAULT: - return "TX_FAULT"; - case ONLP_SFP_CONTROL_TX_DISABLE: - return "TX_DISABLE"; - case ONLP_SFP_CONTROL_TX_DISABLE_CHANNEL: - return "TX_DISABLE_CHANNEL"; - case ONLP_SFP_CONTROL_LP_MODE: - return "LP_MODE"; - case ONLP_SFP_CONTROL_POWER_OVERRIDE: - return "POWER_OVERRIDE"; - - default: - return "UNKNOW"; - } - return ""; -} - -char diag_debug_pause_platform_manage_on(void) -{ - system("echo 1 > /tmp/onlpi_dbg_pause_pm"); - return 0; -} - -char diag_debug_pause_platform_manage_off(void) -{ - system("echo 0 > /tmp/onlpi_dbg_pause_pm"); - return 0; -} - -char diag_debug_pause_platform_manage_check(void) -{ - char flag = 0; - FILE *file = fopen("/tmp/onlpi_dbg_pause_pm", "r"); - if (file == NULL) - { - return 0; - } - flag = fgetc(file); - fclose(file); - - return (flag == '1') ? 1 : 0; -} - -#define ONIE_EEPROM_HEADER_LENGTH 11 -int eeprom_tlv_read(uint8_t *rdata, char type, char *data) -{ - uint8_t i, j, TLV_length; - int total_data_length = ((*(rdata + 9)) << 8) + (*(rdata + 10)) + ONIE_EEPROM_HEADER_LENGTH; - char TLV_type; - - for (i = ONIE_EEPROM_HEADER_LENGTH; i < total_data_length;) - { - TLV_type = *(rdata + i); - TLV_length = *(rdata + i + 1); - //printf("Type:%d Len:%d\n", TLV_type,TLV_length); - if (TLV_type == type) - { - for (j = 0; j < TLV_length; j++) - { - data[j] = *(rdata + i + j + 2); - //printf("TLV match\n"); - } - data[j] = '\0'; - return 0; - } - i += (TLV_length + 2); - //printf("i:%d\n",i); - } - return 0; -} diff --git a/packages/platforms/lenovo/x86-64/ne2572/onlp/builds/x86_64_lenovo_ne2572/module/src/platform_lib.h b/packages/platforms/lenovo/x86-64/ne2572/onlp/builds/x86_64_lenovo_ne2572/module/src/platform_lib.h deleted file mode 100644 index bfdb3bf94..000000000 --- a/packages/platforms/lenovo/x86-64/ne2572/onlp/builds/x86_64_lenovo_ne2572/module/src/platform_lib.h +++ /dev/null @@ -1,249 +0,0 @@ -/************************************************************ - * - * - * Copyright 2014 Big Switch Networks, Inc. - * Copyright 2018 Alpha Networks Incorporation. - * - * Licensed under the Eclipse Public License, Version 1.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.eclipse.org/legal/epl-v10.html - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT 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_lenovo_ne2572_log.h" - -//for ne2572 -#define IDPROM_PATH "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/0-0056/eeprom" -//#define IDPROM_PATH "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-6/i2c-10/10-0051/eeprom" - -#define PSU1_ID 1 -#define PSU2_ID 2 -#define PSU1_BUS_ID 11 -#define PSU2_BUS_ID 10 - - -#define CHASSIS_THERMAL_COUNT 2 -#define CHASSIS_FAN_COUNT 6 - -#define PSU1_AC_PMBUS_PREFIX "/sys/bus/i2c/devices/57-003c/" -#define PSU2_AC_PMBUS_PREFIX "/sys/bus/i2c/devices/58-003f/" - -#define PSU1_AC_HWMON_PREFIX "/sys/bus/i2c/devices/2-0050/" -#define PSU1_DC_HWMON_PREFIX "/sys/bus/i2c/devices/57-0050/" -#define PSU2_AC_HWMON_PREFIX "/sys/bus/i2c/devices/3-0050/" -#define PSU2_DC_HWMON_PREFIX "/sys/bus/i2c/devices/58-0053/" - -#define PSU1_AC_HWMON_NODE(node) PSU1_AC_HWMON_PREFIX#node -#define PSU1_DC_HWMON_NODE(node) PSU1_DC_HWMON_PREFIX#node -#define PSU2_AC_HWMON_NODE(node) PSU2_AC_HWMON_PREFIX#node -#define PSU2_DC_HWMON_NODE(node) PSU2_DC_HWMON_PREFIX#node - -#define NUM_OF_SFP_PORT 54 -#define QSFP_START_INDEX 48 - -#define QSFP28_EEPROM_I2C_ADDR 0x50 /* QSFP28 EEPROM Physical Address in the I2C */ -#define SFP_DOM_EEPROM_I2C_ADDR 0x51 - -#define QSFP28_EEPROM_TXRX_LOS_OFFSET 3 -#define QSFP28_EEPROM_TX_FAULT_OFFSET 4 -#define QSFP28_EEPROM_TX_DISABLE_OFFSET 86 -#define QSFP28_EEPROM_POWERSET_OFFSET 93 -#define QSFP28_EEPROM_PAGE_SELECT_OFFSET 127 - -typedef long long I64_T; /* 64-bit signed */ -typedef unsigned long long UI64_T; /* 64-bit unsigned */ -typedef long I32_T; /* 32-bit signed */ -typedef unsigned long UI32_T; /* 32-bit unsigned */ -typedef short int I16_T; /* 16-bit signed */ -typedef unsigned short int UI16_T; /* 16-bit unsigned */ -typedef char I8_T; /* 8-bit signed */ -typedef unsigned char UI8_T; /* 8-bit unsigned */ - -/*----------------------------------------------------------*/ -/* BIT operation */ -/*----------------------------------------------------------*/ -#define UTL_TEST_BITS(__type__,__var__,__pos__) \ - (__type__)((((__type__)(__var__)>>(__type__)(__pos__))&(__type__)1)?(__type__)1:(__type__)0) - -#define UTL_LEFT_SHIFT_BITS(__type__,__range__,__var__,__sft_bits__) \ - (((__type__)(__sft_bits__)>=(__range__))?0:((__type__)(__var__)<<(__type__)(__sft_bits__))) - -#define UTL_RIGHT_SHIFT_BITS(__type__,__range__,__var__,__sft_bits__) \ - (((__type__)__sft_bits__>=(__range__))?(__type__)(__var__):((__type__)(__var__)>>(__type__)(__sft_bits__))) - -#define UTL_SET_BITS(__type__,__range__,__var__,__pos__) \ - ((__type__)(__var__)|UTL_LEFT_SHIFT_BITS(__type__,__range__,(__type__)1U,(__type__)(__pos__))) - -#define UTL_RESET_BITS(__type__,__range__,__var__,__pos__) \ - ((__type__)(__var__)&~UTL_LEFT_SHIFT_BITS(__type__,__range__,(__type__)1U,(__type__)(__pos__))) - -/*----------------------------------------------------------*/ -/* 64 BIT operation */ -/*----------------------------------------------------------*/ -#define UTL_TEST_BITS64(__var__,__pos__) UTL_TEST_BITS(UI64_T,__var__,__pos__) - -#define UTL_SET_BITS64(__var__,__pos__) (__var__) = UTL_SET_BITS(UI64_T,64,__var__,__pos__) -#define UTL_RESET_BITS64(__var__,__pos__) (__var__) = UTL_RESET_BITS(UI64_T,64,__var__,__pos__) - -/*----------------------------------------------------------*/ -/* 32 BIT operation */ -/*----------------------------------------------------------*/ -/* Usage: if( UTL_TEST_BITS32(val,2) )*/ -/* pos = 0~7, 0~15, 0~31 */ -/* 0x1234 = 0001 0010 0011 0100 */ -/* UTL_TEST_BITS32( 0x1234, 2 ) ==> 1 */ -/* UTL_TEST_BITS32( 0x1234, 1 ) ==> 0 */ -#define UTL_TEST_BITS32(__var__,__pos__) UTL_TEST_BITS(UI32_T,__var__,__pos__) - - -/* Usage: UTL_SET_BITS32( val, 6 ) */ -/* pos = 0~7, 0~15, 0~31 */ -/* val = 0x0100 = 0000 0001 0000 0000 */ -/* UTL_SET_BITS32( val,6 )==> 0000 0001 0100 0000 */ -/* UTL_RESET_BITS32( val,8 )=> 0000 0000 0000 0000 */ -#define UTL_SET_BITS32(__var__,__pos__) (__var__) = UTL_SET_BITS(UI32_T,32,__var__,__pos__) -#define UTL_RESET_BITS32(__var__,__pos__) (__var__) = UTL_RESET_BITS(UI32_T,32,__var__,__pos__) - -/*----------------------------------------------------------*/ -/* 16 BIT operation */ -/*----------------------------------------------------------*/ -#define UTL_TEST_BITS16(__var__,__pos__) UTL_TEST_BITS(UI16_T,__var__,__pos__) - -#define UTL_SET_BITS16(__var__,__pos__) (__var__) = UTL_SET_BITS(UI16_T,16,__var__,__pos__) -#define UTL_RESET_BITS16(__var__,__pos__) (__var__) = UTL_RESET_BITS(UI16_T,16,__var__,__pos__) - -/*----------------------------------------------------------*/ -/* 8 BIT operation */ -/*----------------------------------------------------------*/ -#define UTL_TEST_BITS8(__var__,__pos__) UTL_TEST_BITS(UI8_T,__var__,__pos__) - -#define UTL_SET_BITS8(__var__,__pos__) (__var__) = UTL_SET_BITS(UI8_T,8,__var__,__pos__) -#define UTL_RESET_BITS8(__var__,__pos__) (__var__) = UTL_RESET_BITS(UI8_T,16,__var__,__pos__) - - -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_t; - -//psu_type_t get_psu_type(int id, char* modelname, int modelname_len); -int psu_two_complement_to_int(uint16_t data, uint8_t valid_bit, int mask); - -/* FAN related data - */ -enum onlp_fan_id -{ - FAN_RESERVED = 0, - FAN_1, - FAN_2, - FAN_3, - FAN_4, - FAN_5, - FAN_6, - FAN_1_ON_PSU1, - FAN_1_ON_PSU2, -}; - -/* - * LED ID (need to sync with "enum onlp_led_id" defined in ledi.c) - */ -enum onlp_led_id -{ - LED_RESERVED = 0, - LED_SERVICE, - LED_STACKING, - LED_PWR, - LED_FAN, - LED_REAR_FAN1, - LED_REAR_FAN2, - LED_REAR_FAN3, - LED_REAR_FAN4, - LED_REAR_FAN5, - LED_REAR_FAN6, -}; - -/* -* TLV type code -*/ -#define TLV_CODE_PRODUCT_NAME 0x21 -#define TLV_CODE_PART_NUMBER 0x22 -#define TLV_CODE_SERIAL_NUMBER 0x23 -#define TLV_CODE_MAC_BASE 0x24 -#define TLV_CODE_MANUF_DATE 0x25 -#define TLV_CODE_DEVICE_VERSION 0x26 -#define TLV_CODE_LABEL_REVISION 0x27 -#define TLV_CODE_PLATFORM_NAME 0x28 -#define TLV_CODE_ONIE_VERSION 0x29 -#define TLV_CODE_MAC_SIZE 0x2A -#define TLV_CODE_MANUF_NAME 0x2B -#define TLV_CODE_MANUF_COUNTRY 0x2C -#define TLV_CODE_VENDOR_NAME 0x2D -#define TLV_CODE_DIAG_VERSION 0x2E -#define TLV_CODE_SERVICE_TAG 0x2F -#define TLV_CODE_VENDOR_EXT 0xFD -#define TLV_CODE_CRC_32 0xFE - - -/* -i2c APIs: access i2c device by ioctl -*/ -#include -#include - -int i2c_read(int i2cbus, int addr, int offset, int length, char* data); -int i2c_sequential_read(int i2cbus, int addr, int offset, int length, char* data); -int i2c_read_byte(int i2cbus, int addr, int offset, char* data); -int i2c_read_word(int i2cbus, int addr, int command); -int i2c_read_block(int i2cbus, int addr, uint8_t offset, uint8_t *data, int length); -int i2c_read_i2c_block_dump(int i2cbus, int addr, uint8_t *data); -int i2c_write_byte(int i2cbus, int addr, int offset, char val); -int i2c_write_bit(int i2cbus, int addr, int offset, int bit, char val); -int i2c_read_rps_status(int i2cbus, int addr, int offset); - -#define DIAG_FLAG_ON 1 -#define DIAG_FLAG_OFF 0 -char diag_flag_set(char d); -char diag_flag_get(void); - -char diag_debug_trace_on(void); -char diag_debug_trace_off(void); -char diag_debug_trace_check(void); - -char diag_debug_pause_platform_manage_on(void); -char diag_debug_pause_platform_manage_off(void); -char diag_debug_pause_platform_manage_check(void); -/* -* TLV parsering for specific type code -*/ -int eeprom_tlv_read(uint8_t *rdata, char type, char *data); - - -#define DIAG_TRACE(fmt,args...) if(diag_debug_trace_check()) printf("\n[TRACE]"fmt"\n", args) -#define DIAG_PRINT(fmt,args...) DIAG_TRACE(fmt,args);else if(diag_flag_get()) printf("[DIAG]"fmt"\n", args) - -char* sfp_control_to_str(int value); - -#endif /* __PLATFORM_LIB_H__ */ diff --git a/packages/platforms/lenovo/x86-64/ne2572/onlp/builds/x86_64_lenovo_ne2572/module/src/psui.c b/packages/platforms/lenovo/x86-64/ne2572/onlp/builds/x86_64_lenovo_ne2572/module/src/psui.c deleted file mode 100644 index 527aa0376..000000000 --- a/packages/platforms/lenovo/x86-64/ne2572/onlp/builds/x86_64_lenovo_ne2572/module/src/psui.c +++ /dev/null @@ -1,418 +0,0 @@ -/************************************************************ - * - * - * Copyright 2014 Big Switch Networks, Inc. - * Copyright 2018 Alpha Networks Incorporation. - * - * Licensed under the Eclipse Public License, Version 1.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.eclipse.org/legal/epl-v10.html - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT 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 PSUI_DEBUG_FLAG 0 - - -#define PSU_STATUS_INTERRUPT 3 -#define PSU_STATUS_PRESENT 2 -#define PSU_STATUS_POWER_OK 1 -#define PSU_STATUS_POWER_ON 0 - -#define PSU_NODE_MAX_INT_LEN 8 -#define PSU_NODE_MAX_PATH_LEN 64 -#define PSUI_CPLD_BUS_ID 0 -#define PSUI_POWER_CPLD_ADDR 0x5E -#define RPS_PSU_EEPROM_ADDR 0x51 -#define RPS_PSU_MICRO_P_ADDR 0x59 - -#define PSUI_MANUFACTURER_NAME_REG 0x0C -#define PSUI_PRODUCT_NAME_REG 0x12 -#define PSUI_MODEL_NO_REG 0x1D -#define PSUI_PRODUCT_VER_NO_REG 0x1F -#define PSUI_PRODUCT_SER_NO_REG_F2B 0x23 -#define PSUI_PRODUCT_SER_NO_REG_B2F 0x25 -#define PSUI_PRODUCT_SER_NO_REG PSUI_PRODUCT_SER_NO_REG_B2F -#define PSUI_RPS_STATUS_REG0 0x04 /* PSU Status Register for PSU#1 */ -#define PSUI_RPS_STATUS_REG1 0x03 /* PSU Status Register for PSU#2 */ - -#define PSUI_PRODUCT_SER_NO_SIZE 14 -#define PSUI_PRODUCT_SER_NO_LEN (PSUI_PRODUCT_SER_NO_SIZE + 1) -#define PSUI_PRODUCT_NAME_SIZE 13 -#define PSUI_PRODUCT_NAME_SIZE_F2B 11 -#define PSUI_PRODUCT_NAME_SIZE_B2F 13 - -struct psui_reg_data_word -{ - uint8_t reg; - uint16_t value; -}; - -struct psui_reg_data_word regs_word[] = { {0x88, 0}, /* READ_Vin */ - {0x8b, 0}, /* READ_Vout */ - {0x89, 0}, /* READ_Iin */ - {0x8c, 0}, /* READ_Iout */ - {0x96, 0}, /* READ_Pout */ - {0x97, 0} /* READ_Pin */ - }; - - -#define GET_RPS_STATUS_BIT(x,n) (((x) >> (n)) & 1) -#define VALIDATE(_id) \ - do { \ - if(!ONLP_OID_IS_PSU(_id)) { \ - return ONLP_STATUS_E_INVALID; \ - } \ - } while(0) - - -int -psu_ne2572_linear_format(int exponent, int mantissa) -{ - int multiplier = 1000;/* Units are "milli-" */ - - return (exponent >= 0) ? (mantissa << exponent) * multiplier : - (mantissa * multiplier) / (1 << -exponent); -} - -int -onlp_psui_init(void) -{ - DIAG_PRINT("%s", __FUNCTION__); - return ONLP_STATUS_OK; -} - - -static int -psu_info_get_product_name(int id, UI8_T *data) -{ - DIAG_PRINT("%s, id:%d", __FUNCTION__, id); - int ret = 0; - - ret = i2c_read_block(id, RPS_PSU_EEPROM_ADDR, PSUI_PRODUCT_NAME_REG, data, PSUI_PRODUCT_NAME_SIZE); - if (ret < 0 && PSUI_DEBUG_FLAG) - printf("I2C command 0x%X Read Fail, id=%d\n", PSUI_PRODUCT_NAME_REG,id); - - return ret; -} - -static int -psu_info_get_product_ser(psu_type_t psu_type, int id, UI8_T *data) -{ - int ret = 0; - int addr = 0 ; - DIAG_PRINT("%s, id:%d", __FUNCTION__, id); - if (psu_type == PSU_TYPE_AC_F2B) - { - addr = PSUI_PRODUCT_SER_NO_REG_F2B; - } - else - { - addr = PSUI_PRODUCT_SER_NO_REG_B2F; - } - - ret = i2c_read_block(id, RPS_PSU_EEPROM_ADDR, addr, data, PSUI_PRODUCT_SER_NO_SIZE); - if (ret < 0) - printf("I2C command 0x%X Read Fail, id=%d\n", addr,id); - return ret; -} - -static int -psu_info_get_status(int id, char *data) -{ - DIAG_PRINT("%s, id:%d", __FUNCTION__, id); - int ret = 0; - - if (id == PSU1_ID) - { - ret = i2c_read_rps_status(PSUI_CPLD_BUS_ID, PSUI_POWER_CPLD_ADDR, PSUI_RPS_STATUS_REG0); - if (ret < 0) - printf("I2C command 0x%X Read Fail, id=%d\n", PSUI_RPS_STATUS_REG0, PSUI_CPLD_BUS_ID); - } - else if (id == PSU2_ID) - { - ret = i2c_read_rps_status(PSUI_CPLD_BUS_ID, PSUI_POWER_CPLD_ADDR, PSUI_RPS_STATUS_REG1); - if (ret < 0) - printf("I2C command 0x%X Read Fail, id=%d\n", PSUI_RPS_STATUS_REG1, PSUI_CPLD_BUS_ID); - } - sprintf (data, "%d\n", ret); - return ret; -} - - -static int -psu_ne2572_info_get(int id, onlp_psu_info_t* info) -{ - DIAG_PRINT("%s, id:%d", __FUNCTION__, id); - //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); - -#if 1 - int i = 0; - int status; - int exponent, mantissa; - for (i = 0; i < 6; i++) - { - //printf("I2C register 0x%X \n", regs_word[i].reg); - status = i2c_read_word(id, RPS_PSU_MICRO_P_ADDR, regs_word[i].reg); - if (status < 0) - printf("I2C command 0x%X Read Fail\n", regs_word[i].reg); - else - { - //printf("I2C command 0x%X Read Success: 0x%02x\n", regs_word[i].reg, status); - regs_word[i].value = status; - } - } - - info->caps |= ONLP_PSU_CAPS_VOUT; - info->caps |= ONLP_PSU_CAPS_VIN; - info->caps |= ONLP_PSU_CAPS_IOUT; - info->caps |= ONLP_PSU_CAPS_IIN; - info->caps |= ONLP_PSU_CAPS_POUT; - info->caps |= ONLP_PSU_CAPS_PIN; - - /* Linear_5s_11s */ - exponent = psu_two_complement_to_int(regs_word[0].value >> 11, 5, 0x1f); - mantissa = psu_two_complement_to_int(regs_word[0].value & 0x7ff, 11, 0x7ff); - info->mvin = psu_ne2572_linear_format(exponent, mantissa); - - /* Linear_16u */ - exponent = -12; - mantissa = regs_word[1].value; - info->mvout = psu_ne2572_linear_format(exponent, mantissa); - - exponent = psu_two_complement_to_int(regs_word[2].value >> 11, 5, 0x1f); - mantissa = psu_two_complement_to_int(regs_word[2].value & 0x7ff, 11, 0x7ff); - info->miin = psu_ne2572_linear_format(exponent, mantissa); - - exponent = psu_two_complement_to_int(regs_word[3].value >> 11, 5, 0x1f); - mantissa = psu_two_complement_to_int(regs_word[3].value & 0x7ff, 11, 0x7ff); - info->miout = psu_ne2572_linear_format(exponent, mantissa); - - exponent = psu_two_complement_to_int(regs_word[4].value >> 11, 5, 0x1f); - mantissa = psu_two_complement_to_int(regs_word[4].value & 0x7ff, 11, 0x7ff); - info->mpout = psu_ne2572_linear_format(exponent, mantissa); - - exponent = psu_two_complement_to_int(regs_word[5].value >> 11, 5, 0x1f); - mantissa = psu_two_complement_to_int(regs_word[5].value & 0x7ff, 11, 0x7ff); - info->mpin = psu_ne2572_linear_format(exponent, mantissa); -#endif - return ONLP_STATUS_OK; -} - -int -psu_um400d_info_get(onlp_psu_info_t* info) -{ - DIAG_PRINT("%s", __FUNCTION__); - int index = ONLP_OID_ID_GET(info->hdr.id); - - /* Set capability - */ - info->caps = ONLP_PSU_CAPS_DC48; - - 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); - - return ONLP_STATUS_OK; -} - -/* - * Get all information about the given PSU oid. - */ -static onlp_psu_info_t pinfo[] = -{ - { }, /* Not used */ - { /* PSU-1 is on i2c channel 10 for ne2572*/ - { ONLP_PSU_ID_CREATE(PSU1_ID), "PSU-1", 0 }, - }, - { /* PSU-2 is on i2c channel 11 for ne2572*/ - { ONLP_PSU_ID_CREATE(PSU2_ID), "PSU-2", 0 }, - } -}; - -psu_type_t get_psu_type(int id, char* product_name, int productname_len) -{ - DIAG_PRINT("%s, id:%d", __FUNCTION__, id); - UI8_T p_name[PSUI_PRODUCT_NAME_SIZE + 1] = {0}; - - /* Check AC model name */ - if (psu_info_get_product_name(id, p_name) >= 0) - { - //printf("[psu_info_get_product_name] %s\n", p_name); - if (strncmp((char*)p_name, "DPS-770GB E", strlen("DPS-770GB E")) == 0) - { - if (product_name) - memcpy(product_name, p_name, PSUI_PRODUCT_NAME_SIZE_F2B); - - return PSU_TYPE_AC_F2B; - } - else if (strncmp((char*)p_name, "DPS-770GB-1 A", strlen("DPS-770GB-1 A")) == 0) - { - if (product_name) - memcpy(product_name, p_name, PSUI_PRODUCT_NAME_SIZE_B2F); - - return PSU_TYPE_AC_B2F; - } - #if 0 - else if (strncmp((char*)p_name, "DPS-770GB", strlen("DPS-770GB")) == 0) - { - if (product_name) - memcpy(product_name, p_name, productname_len-1); - - return PSU_TYPE_AC_B2F; - } - #endif - } - return PSU_TYPE_UNKNOWN; -} - - -int -onlp_psui_info_get(onlp_oid_t id, onlp_psu_info_t* info) -{ - char name[ONLP_CONFIG_INFO_STR_MAX]; - char status; - int ret = ONLP_STATUS_OK; - int index = ONLP_OID_ID_GET(id); - psu_type_t psu_type; - - UI8_T product_ser[PSUI_PRODUCT_SER_NO_LEN]; - - UI8_T rps_status = 0, power_ok = 0, power_on = 0, power_present = 0; - - VALIDATE(id); - - memset(info, 0, sizeof(onlp_psu_info_t)); - memset(name, 0, sizeof(name)); - *info = pinfo[index]; /* Set the onlp_oid_hdr_t */ - - /* Get PSU type and product name, bus ID=index+10*/ - if( index == 1) - psu_type = get_psu_type(PSU1_BUS_ID, info->model, sizeof(info->model)); - else if( index == 2) - psu_type = get_psu_type(PSU2_BUS_ID, info->model, sizeof(info->model)); - - //debug - DIAG_PRINT("%s, id:%d, index:%d, psu_type:%d\n",__FUNCTION__,id,index,psu_type); - switch (psu_type) - { - case PSU_TYPE_AC_F2B: - case PSU_TYPE_AC_B2F: - if( index == 1) - ret = psu_ne2572_info_get(PSU1_BUS_ID, info);/* Get PSU electric info from PMBus */ - else if (index == 2) - ret = psu_ne2572_info_get(PSU2_BUS_ID, info);/* Get PSU electric info from PMBus */ - break; - case PSU_TYPE_DC_48V_F2B: - case PSU_TYPE_DC_48V_B2F: - ret = psu_um400d_info_get(info); - break; - default: - ret = ONLP_STATUS_E_UNSUPPORTED; - return ret; - } - - /* Get the product serial number, bus ID=index+10 */ - if(index == 1) - { - if (psu_info_get_product_ser(psu_type, PSU1_BUS_ID, product_ser) < 0) - { - printf("Unable to read PSU(%d) item(serial number)\r\n", index); - } - else - { - memcpy(info->serial, product_ser, sizeof(product_ser)); - } - } - else if( index == 2) - { - if (psu_info_get_product_ser(psu_type, PSU2_BUS_ID, product_ser) < 0) - { - printf("Unable to read PSU(%d) item(serial number)\r\n", index); - } - else - { - memcpy(info->serial, product_ser, sizeof(product_ser)); - } - } - /* Get psu status from CPLD */ - if (psu_info_get_status(index, &status) < 0) - { - printf("Unable to read PSU(%d) item(psu status)\r\n", index); - } - else - { - rps_status = (UI8_T)atoi(&status); - power_present = GET_RPS_STATUS_BIT(rps_status, PSU_STATUS_PRESENT); - power_ok = GET_RPS_STATUS_BIT(rps_status, PSU_STATUS_POWER_OK); - power_on = GET_RPS_STATUS_BIT(rps_status, PSU_STATUS_POWER_ON); - - /* Empty */ - if (!power_present) - { - info->status |= ONLP_PSU_STATUS_UNPLUGGED; - } - - if (!power_ok) - { - info->status |= ONLP_PSU_STATUS_FAILED; - } - - if (power_on) - { - info->status |= ONLP_PSU_STATUS_PRESENT; - } - - DIAG_PRINT("rps_status:0x%x ,info->status:0x%x\n", rps_status, info->status); - DIAG_PRINT("present:%d, ok:%d, on:%d\n", power_present, power_ok, power_on); - - } - - - - return ret; -} - -int -onlp_psui_ioctl(onlp_oid_t pid, va_list vargs) -{ - DIAG_PRINT("%s, pid=%d", __FUNCTION__, pid); - return ONLP_STATUS_E_UNSUPPORTED; -} - diff --git a/packages/platforms/lenovo/x86-64/ne2572/onlp/builds/x86_64_lenovo_ne2572/module/src/sfpi.c b/packages/platforms/lenovo/x86-64/ne2572/onlp/builds/x86_64_lenovo_ne2572/module/src/sfpi.c deleted file mode 100644 index d53090cd2..000000000 --- a/packages/platforms/lenovo/x86-64/ne2572/onlp/builds/x86_64_lenovo_ne2572/module/src/sfpi.c +++ /dev/null @@ -1,826 +0,0 @@ -/************************************************************ - * - * - * Copyright 2014 Big Switch Networks, Inc. - * Copyright 2018 Alpha Networks Incorporation. - * - * Licensed under the Eclipse Public License, Version 1.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.eclipse.org/legal/epl-v10.html - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT 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 DEBUG 0 - -#define SYSTEM_CPLD_I2C_BUS_ID 8 -#define SYSTEM_CPLD_I2C_ADDR 0x5F /* System CPLD Physical Address in the I2C */ -#define SYSTEM_CPLD_RESET1_ADDR_OFFSET 0x02 - -#define PORT_CPLD0_I2C_BUS_ID 13 -#define PORT_CPLD1_I2C_BUS_ID 15 -#define PORT_CPLD2_I2C_BUS_ID 17 - -//#define PORT_CPLD_I2C_ADDR 0x5F /* Port CPLD Physical Address in the I2C */ -#define PORT_CPLD0_I2C_ADDR 0x5B -#define PORT_CPLD1_I2C_ADDR 0x5C -#define PORT_CPLD2_I2C_ADDR 0x5D - -#define PORT_CPLD2_MODULE_SELECT_ADDR_OFFSET 0x0B - - -#define PORT_CPLD_PRESENT_ADDR_OFFSET 0x05 -#define PORT_CPLD_RESET_ADDR_OFFSET 0x07 -#define PORT_CPLD_LOWPWR_ADDR_OFFSET 0x09 -#define PORT_CPLD_MOD_SEL_ADDR_OFFSET 0x0B /* Module Select of QSFP ports */ - -#define PORT_CPLD_SFP_PRESENT_ADDR_OFFSET 0x16 -#define PORT_CPLD_SFP_RX_LOS_ADDR_OFFSET 0x13 -#define PORT_CPLD_SFP_TX_FAULT_ADDR_OFFSET 0x10 -#define PORT_CPLD_SFP_TX_DISABLE_ADDR_OFFSET 0x19 - -#define SFP_I2C_BUS_ID_BASE 21 - - -static int -port_to_busid(int port) -{ - int index = 0; - index = port + SFP_I2C_BUS_ID_BASE; - - DIAG_PRINT("%s, port:%d, busid:%d ", __FUNCTION__, port, index); - return index; -} - - -static int -port_to_cpld_busid(int port) -{ - int index = 0; - int ret = 0; - index = port / 24; - ret = (index * 2) + PORT_CPLD0_I2C_BUS_ID; - DIAG_PRINT("%s, port:%d, cpld_busid:%d ", __FUNCTION__, port, ret); - return ret; -} - -static int -port_to_cpld_addr(int port) -{ - int index = 0; - int ret = 0; - index = port / 24; - ret = index + PORT_CPLD0_I2C_ADDR; - DIAG_PRINT("%s, port:%d, cpld_busaddr:%d ", __FUNCTION__, port, ret); - return ret; -} - -static int -port_to_cpld_sfp_offset(int port, int start_index) -{ - int index = 0; - int ret = 0; - - if (port < QSFP_START_INDEX) - { - - index = (port / 8) % 3; - ret = index + start_index; - } - else - { - AIM_LOG_INFO("%s:%d invaild sfp port index(%d), start_index:%d\n", __FUNCTION__, __LINE__, port, start_index); - } - - DIAG_PRINT("%s, port:%d, present_offset:0x%X, start_index:%d, index:%d", __FUNCTION__, port, ret, start_index, index); - return ret; -} - -static int -port_to_cpld_present_offset(int port) -{ - int ret = 0; - - if (port < QSFP_START_INDEX) - { - ret = port_to_cpld_sfp_offset(port, PORT_CPLD_SFP_PRESENT_ADDR_OFFSET); - } - else - { - ret = PORT_CPLD_PRESENT_ADDR_OFFSET; // QSFP28 Transceiver Present Register - } - - DIAG_PRINT("%s, port:%d, present_offset:%d ", __FUNCTION__, port, ret); - return ret; -} - -static int -port_to_cpld_port_bit(int port) -{ - int index = 0; - index = (port % 8); - DIAG_PRINT("%s, port:%d, present_bit:%d ", __FUNCTION__, port, index); - return index; -} - -static int -_sfp_present(int port) -{ - int ret = 0; - char data = 0; - - DIAG_PRINT("%s, port:%d", __FUNCTION__, port); - - int busid = port_to_cpld_busid(port); - int addr = port_to_cpld_addr(port); - int offset = port_to_cpld_present_offset(port); - - ret = i2c_read_byte(busid, addr, offset, &data); - if (ret < 0) - { - AIM_LOG_INFO("%s:%d fail[%d]\n", __FUNCTION__, __LINE__, ret); - return ret; - } - if (DEBUG) - AIM_LOG_INFO("%s:%d port[%d],busid[%d],addr[0x%2X],offset[0x%02X],read_byte[%02x]\n", __FUNCTION__, __LINE__, - port, busid, addr, offset, (unsigned char)data); - - if (data & (1 << port_to_cpld_port_bit(port))) - { - return 1; - } - - return 0; -} - -/************************************************************ - * - * SFPI Entry Points - * - ***********************************************************/ -int -onlp_sfpi_init(void) -{ - DIAG_PRINT("%s", __FUNCTION__); - - int ret = 0; - char data = 0; - - /* pull low for Reset Register 1 of Port CPLD */ - ret = i2c_write_byte(SYSTEM_CPLD_I2C_BUS_ID, SYSTEM_CPLD_I2C_ADDR, SYSTEM_CPLD_RESET1_ADDR_OFFSET, data); - if (ret < 0) - { - AIM_LOG_INFO("%s:%d fail[%d]\n", __FUNCTION__, __LINE__, ret); - return ret; - } - - //Module select - ret = i2c_write_byte(PORT_CPLD2_I2C_BUS_ID, PORT_CPLD2_I2C_ADDR, PORT_CPLD2_MODULE_SELECT_ADDR_OFFSET, 0x3F); //bit 0~5 - if (ret < 0) - { - AIM_LOG_INFO("%s:%d fail[%d]\n", __FUNCTION__, __LINE__, ret); - return ret; - } - - return ONLP_STATUS_OK; -} - -int -onlp_sfpi_bitmap_get(onlp_sfp_bitmap_t *bmap) -{ - int p = 0; - AIM_BITMAP_CLR_ALL(bmap); - - for (p = 0; p < NUM_OF_SFP_PORT; p++) - { - AIM_BITMAP_SET(bmap, p); - } - DIAG_PRINT("%s", __FUNCTION__); - - 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 = 0; - - present = _sfp_present(port); - - DIAG_PRINT("%s, port=%d, present:%d", __FUNCTION__, port, present); - return present; -} - -int -onlp_sfpi_presence_bitmap_get(onlp_sfp_bitmap_t *dst) -{ - DIAG_PRINT("%s", __FUNCTION__); - - int i = 0; - AIM_BITMAP_CLR_ALL(dst); - for (i = 0; i < NUM_OF_SFP_PORT; i++) - { - if (onlp_sfpi_is_present(i)) - { - AIM_BITMAP_SET(dst, i); - } - } - - return ONLP_STATUS_OK; -} - -int -onlp_sfpi_eeprom_read(int port, uint8_t data[256]) -{ - - int busid = port_to_busid(port); - - DIAG_PRINT("%s, port:%d, busid:%d", __FUNCTION__, port, busid); - - /* - * Read the SFP eeprom into data[] - */ - memset(data, 0x0, 256); - - if (i2c_read(busid, QSFP28_EEPROM_I2C_ADDR, 0x0, 256, (char *)data) != 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_dom_read(int port, uint8_t data[256]) -{ - int busid = port_to_busid(port); - int ret = 0; - memset(data, 0x0, 256); - DIAG_PRINT("%s, port:%d, busid:%d", __FUNCTION__, port, busid); - - if (port < QSFP_START_INDEX) - { - if (i2c_read(busid, SFP_DOM_EEPROM_I2C_ADDR, 0x0, 256, (char *)data) != 0) - { - AIM_LOG_INFO("Unable to read eeprom from port(%d)\r\n", port); - return ONLP_STATUS_E_INTERNAL; - } - } - else - { - //Set page select to pahe 00h. - ret = onlp_sfpi_dev_writeb(port, QSFP28_EEPROM_I2C_ADDR, QSFP28_EEPROM_PAGE_SELECT_OFFSET, 0); - if (ret < 0) - { - AIM_LOG_INFO("%s:%d fail[%d]\n", __FUNCTION__, __LINE__, ret); - return ret; - } - if (i2c_read(busid, QSFP28_EEPROM_I2C_ADDR, 0x0, 256, (char *)data) != 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_readb(int port, uint8_t devaddr, uint8_t addr) -{ - - int ret = 0; - int bus = port_to_busid(port); - - ret = onlp_i2c_readb(bus, devaddr, addr, ONLP_I2C_F_FORCE); - DIAG_PRINT("%s, port:%d, devaddr:%d, addr:%d, ret:%d(0x%02X)", __FUNCTION__, port, devaddr, addr, ret, ret); - - return ret; -} - -int -onlp_sfpi_dev_writeb(int port, uint8_t devaddr, uint8_t addr, uint8_t value) -{ - - int ret = 0; - int bus = port_to_busid(port); - - ret = onlp_i2c_writeb(bus, devaddr, addr, value, ONLP_I2C_F_FORCE); - DIAG_PRINT("%s, port:%d, devaddr:%d, addr:%d, value:%d(0x%02X), ret:%d", __FUNCTION__, port, devaddr, addr, value, value, ret); - - return ret; -} - -int -onlp_sfpi_dev_readw(int port, uint8_t devaddr, uint8_t addr) -{ - int ret = 0; - int bus = port_to_busid(port); - - ret = onlp_i2c_readw(bus, devaddr, addr, ONLP_I2C_F_FORCE); - DIAG_PRINT("%s, port:%d, devaddr:%d, addr:%d, ret:%d(0x%04X)", __FUNCTION__, port, devaddr, addr, ret, ret); - - return ret; -} - -int -onlp_sfpi_dev_writew(int port, uint8_t devaddr, uint8_t addr, uint16_t value) -{ - int ret = 0; - int bus = port_to_busid(port); - - ret = onlp_i2c_writew(bus, devaddr, addr, value, ONLP_I2C_F_FORCE); - DIAG_PRINT("%s, port:%d, devaddr:%d, addr:%d, value:%d(0x%04X), ret:%d", __FUNCTION__, port, devaddr, addr, value, value, ret); - - return ret; -} - -/* - Reset and LP mode can control by CPLD so the setting will be keep in CPLD. - For other options, control is get/set to QSFP28. - Control options set to QSFP28 will be lost when the QSFP28 is removed. - Upper layer software system should keep the configuration and set it again when detect a new sfp module insert. - [QSFP] - function R/W CPLD EEPROM - ------------------------------------ --- ------------- ----------------- - ONLP_SFP_CONTROL_RESET W 0x7 - ONLP_SFP_CONTROL_RESET_STATE R/W 0x7 - ONLP_SFP_CONTROL_RX_LOS R none byte 4 - ONLP_SFP_CONTROL_TX_FAULT R none byte 3 - ONLP_SFP_CONTROL_TX_DISABLE R/W none byte 86 - ONLP_SFP_CONTROL_TX_DISABLE_CHANNEL R/W none byte 86 - ONLP_SFP_CONTROL_LP_MODE R/W 0x9 - ONLP_SFP_CONTROL_POWER_OVERRIDE R/W none byte 93 - [SFP] - function R/W CPLD - ------------------------------------ --- --------------- - ONLP_SFP_CONTROL_RESET Not Support(There is no RESET pin in SFP module) - ONLP_SFP_CONTROL_RESET_STATE Not Support(There is no RESET pin in SFP module) - ONLP_SFP_CONTROL_RX_LOS R 0x13/0x14/0x15 - ONLP_SFP_CONTROL_TX_FAULT R 0x10/0x11/0x12 - ONLP_SFP_CONTROL_TX_DISABLE R/W 0x19/0x1A/0x1B - ONLP_SFP_CONTROL_TX_DISABLE_CHANNEL Not Support(It is for QSFP) - ONLP_SFP_CONTROL_LP_MODE Not Support(It is for QSFP) - ONLP_SFP_CONTROL_POWER_OVERRIDE Not Support(It is for QSFP) - -*/ - -int onlp_sfpi_control_supported(int port, onlp_sfp_control_t control, int *supported) -{ - if (supported == NULL) - { - AIM_LOG_INFO("%s:%d fail[%d]\n", __FUNCTION__, __LINE__, ONLP_STATUS_E_PARAM); - return ONLP_STATUS_E_PARAM; - } - - *supported = 0; - - - - switch (control) - { - case ONLP_SFP_CONTROL_RX_LOS: - case ONLP_SFP_CONTROL_TX_FAULT: - case ONLP_SFP_CONTROL_TX_DISABLE: - *supported = 1; - break; - - case ONLP_SFP_CONTROL_TX_DISABLE_CHANNEL: - case ONLP_SFP_CONTROL_RESET: - case ONLP_SFP_CONTROL_RESET_STATE: - case ONLP_SFP_CONTROL_LP_MODE: - case ONLP_SFP_CONTROL_POWER_OVERRIDE: - if (port < QSFP_START_INDEX) //SFP port, those options are designed for QSFP. - *supported = 0; - else - *supported = 1; - break; - default: - *supported = 0; - break; - } - - DIAG_PRINT("%s, port:%d, control:%d(%s), supported:%d", __FUNCTION__, port, control, sfp_control_to_str(control), *supported); - return ONLP_STATUS_OK; -} - -int -onlp_sfpi_control_set(int port, onlp_sfp_control_t control, int value) -{ - int rv = ONLP_STATUS_OK; - int bus = port_to_busid(port); - int cpld_bus = port_to_cpld_busid(port); - int addr = port_to_cpld_addr(port); - int offset = 0; - int port_bit = port_to_cpld_port_bit(port); - int supported = 0; - char optval = 0; - - if ((onlp_sfpi_control_supported(port, control, &supported) == ONLP_STATUS_OK) && (supported == 0)) - return ONLP_STATUS_E_UNSUPPORTED; - - DIAG_PRINT("%s, port:%d, control:%d(%s), value:0x%X", __FUNCTION__, port, control, sfp_control_to_str(control), value); - - if (port < QSFP_START_INDEX) //SFP - { - switch (control) - { - case ONLP_SFP_CONTROL_TX_DISABLE: - offset = port_to_cpld_sfp_offset(port, PORT_CPLD_SFP_TX_DISABLE_ADDR_OFFSET); - break; - default: - return ONLP_STATUS_E_UNSUPPORTED; - break; - } - optval = onlp_i2c_readb(cpld_bus, addr, offset, ONLP_I2C_F_FORCE); - if (value != 0) - { - optval |= (1 << port_bit); - } - else - { - optval &= ~(1 << port_bit); - } - rv = onlp_i2c_writeb(cpld_bus, addr, offset, optval, ONLP_I2C_F_FORCE); - if (rv < 0) - { - AIM_LOG_INFO("%s:%d fail[%d]\n", __FUNCTION__, __LINE__, rv); - return rv; - } - - } - else - { - - switch (control) - { - case ONLP_SFP_CONTROL_RESET: - if (value == 0) //set ONLP_SFP_CONTROL_RESET_STATE to 0 - { - rv = onlp_sfpi_control_set(port, ONLP_SFP_CONTROL_RESET_STATE, 0); - break; - } - - rv = onlp_sfpi_control_set(port, ONLP_SFP_CONTROL_RESET_STATE, 1); - if (rv < 0) - { - AIM_LOG_INFO("%s:%d fail[%d]\n", __FUNCTION__, __LINE__, rv); - return rv; - } - rv = onlp_sfpi_control_set(port, ONLP_SFP_CONTROL_RESET_STATE, 0); - if (rv < 0) - { - AIM_LOG_INFO("%s:%d fail[%d]\n", __FUNCTION__, __LINE__, rv); - return rv; - } - - break; - - case ONLP_SFP_CONTROL_RESET_STATE: - offset = PORT_CPLD_RESET_ADDR_OFFSET; - optval = onlp_i2c_readb(cpld_bus, addr, offset, ONLP_I2C_F_FORCE); - if (value != 0) - { - optval |= (1 << port_bit); - } - else - { - optval &= ~(1 << port_bit); - } - - rv = onlp_i2c_writeb(cpld_bus, addr, offset, optval, ONLP_I2C_F_FORCE); - if (rv < 0) - { - AIM_LOG_INFO("%s:%d fail[%d]\n", __FUNCTION__, __LINE__, rv); - return rv; - } - break; - - case ONLP_SFP_CONTROL_TX_DISABLE: - if (onlp_sfpi_is_present(port) == 0) - { - AIM_LOG_INFO("%s:%d fail[%d]\n", __FUNCTION__, __LINE__, ONLP_STATUS_E_MISSING); - return ONLP_STATUS_E_MISSING; - } - offset = QSFP28_EEPROM_TX_DISABLE_OFFSET; - addr = QSFP28_EEPROM_I2C_ADDR; - optval = onlp_i2c_readb(bus, addr, offset, ONLP_I2C_F_FORCE); - if (value != 0) - { - optval |= 0x0f; //bit 0~3 - } - else - { - optval &= ~(0x0f); - } - rv = onlp_i2c_writeb(bus, addr, offset, optval, ONLP_I2C_F_FORCE); - if (rv < 0) - { - AIM_LOG_INFO("%s:%d fail[%d]\n", __FUNCTION__, __LINE__, rv); - return rv; - } - break; - - case ONLP_SFP_CONTROL_TX_DISABLE_CHANNEL: - if (onlp_sfpi_is_present(port) == 0) - { - AIM_LOG_INFO("%s:%d fail[%d]\n", __FUNCTION__, __LINE__, ONLP_STATUS_E_MISSING); - return ONLP_STATUS_E_MISSING; - } - if (value < 0 || value > 0x0f) - { - AIM_LOG_INFO("%s:%d fail[%d]\n", __FUNCTION__, __LINE__, ONLP_STATUS_E_PARAM); - return ONLP_STATUS_E_PARAM; - } - offset = QSFP28_EEPROM_TX_DISABLE_OFFSET; - addr = QSFP28_EEPROM_I2C_ADDR; - optval = value; - rv = onlp_i2c_writeb(bus, addr, offset, optval, ONLP_I2C_F_FORCE); - if (rv < 0) - return rv; - break; - - case ONLP_SFP_CONTROL_POWER_OVERRIDE: - if (onlp_sfpi_is_present(port) == 0) - { - AIM_LOG_INFO("%s:%d fail[%d]\n", __FUNCTION__, __LINE__, ONLP_STATUS_E_MISSING); - return ONLP_STATUS_E_MISSING; - } - offset = QSFP28_EEPROM_POWERSET_OFFSET; - addr = QSFP28_EEPROM_I2C_ADDR; - optval = onlp_i2c_readb(bus, addr, offset, ONLP_I2C_F_FORCE); - if (value != 0) - { - optval |= 0x01; - } - else - { - optval &= ~(0x01); - } - rv = onlp_i2c_writeb(bus, addr, offset, optval, ONLP_I2C_F_FORCE); - if (rv < 0) - { - AIM_LOG_INFO("%s:%d fail[%d]\n", __FUNCTION__, __LINE__, rv); - return rv; - } - break; - - case ONLP_SFP_CONTROL_LP_MODE: - offset = PORT_CPLD_LOWPWR_ADDR_OFFSET; - optval = onlp_i2c_readb(cpld_bus, addr, offset, ONLP_I2C_F_FORCE); - if (value != 0) - { - optval |= (1 << port_bit); - } - else - { - optval &= ~(1 << port_bit); - } - rv = onlp_i2c_writeb(cpld_bus, addr, offset, optval, ONLP_I2C_F_FORCE); - if (rv < 0) - { - AIM_LOG_INFO("%s:%d fail[%d]\n", __FUNCTION__, __LINE__, rv); - return rv; - } - break; - - //Read Only - case ONLP_SFP_CONTROL_RX_LOS: - case ONLP_SFP_CONTROL_TX_FAULT: - AIM_LOG_INFO("%s:%d fail[%d]\n", __FUNCTION__, __LINE__, ONLP_STATUS_E_INVALID); - return ONLP_STATUS_E_INVALID; - break; - default: - break; - } - } - DIAG_PRINT("%s, port_bit:%d, bus:%d, cpld_bus:%d, addr:0x%X, offset:0x%X", __FUNCTION__, port_bit, bus, cpld_bus, addr, offset); - return rv; -} - -int -onlp_sfpi_control_get(int port, onlp_sfp_control_t control, int *value) -{ - int rv = ONLP_STATUS_OK; - int bus = port_to_busid(port); - int cpld_bus = port_to_cpld_busid(port); - int addr = port_to_cpld_addr(port); - int offset = 0; - int port_bit = port_to_cpld_port_bit(port); - int supported = 0; - char optval = 0; - - if (value == NULL) - { - AIM_LOG_INFO("%s:%d fail[%d]\n", __FUNCTION__, __LINE__, ONLP_STATUS_E_PARAM); - return ONLP_STATUS_E_PARAM; - } - - if ((onlp_sfpi_control_supported(port, control, &supported) == ONLP_STATUS_OK) && (supported == 0)) - { - AIM_LOG_INFO("%s:%d fail[%d]\n", __FUNCTION__, __LINE__, ONLP_STATUS_E_UNSUPPORTED); - return ONLP_STATUS_E_UNSUPPORTED; - } - *value = 0; - - - if (port < QSFP_START_INDEX) //SFP - { - switch (control) - { - case ONLP_SFP_CONTROL_RX_LOS: - offset = port_to_cpld_sfp_offset(port, PORT_CPLD_SFP_RX_LOS_ADDR_OFFSET); - break; - case ONLP_SFP_CONTROL_TX_FAULT: - offset = port_to_cpld_sfp_offset(port, PORT_CPLD_SFP_TX_FAULT_ADDR_OFFSET); - break; - case ONLP_SFP_CONTROL_TX_DISABLE: - offset = port_to_cpld_sfp_offset(port, PORT_CPLD_SFP_TX_DISABLE_ADDR_OFFSET); - break; - default: - return ONLP_STATUS_E_UNSUPPORTED; - break; - } - optval = onlp_i2c_readb(cpld_bus, addr, offset, ONLP_I2C_F_FORCE); - if ((optval & (1 << port_bit)) != 0) //1 - { - *value = 1; - } - else - { - *value = 0; - } - } - else //QSFP - { - switch (control) - { - case ONLP_SFP_CONTROL_RESET_STATE: - offset = PORT_CPLD_RESET_ADDR_OFFSET; - optval = onlp_i2c_readb(cpld_bus, addr, offset, ONLP_I2C_F_FORCE); - if ((optval & (1 << port_bit)) != 0) //1 - { - *value = 1; - } - else - { - *value = 0; - } - break; - - case ONLP_SFP_CONTROL_RX_LOS: - if (onlp_sfpi_is_present(port) == 0) - { -#if 1 //for display RX_LOS Bitmap in onlpdump - *value = 0; - break; -#else - return ONLP_STATUS_E_MISSING; - -#endif - } - offset = QSFP28_EEPROM_TXRX_LOS_OFFSET; - addr = QSFP28_EEPROM_I2C_ADDR; - optval = onlp_i2c_readb(bus, addr, offset, ONLP_I2C_F_FORCE); - if ((optval & (0x0f)) != 0) //bit 0~3 - { - *value = 1; - } - else - { - *value = 0; - } - break; - - case ONLP_SFP_CONTROL_TX_FAULT: - if (onlp_sfpi_is_present(port) == 0) - { - AIM_LOG_INFO("%s:%d fail[%d]\n", __FUNCTION__, __LINE__, ONLP_STATUS_E_MISSING); - return ONLP_STATUS_E_MISSING; - } - offset = QSFP28_EEPROM_TX_FAULT_OFFSET; - addr = QSFP28_EEPROM_I2C_ADDR; - optval = onlp_i2c_readb(bus, addr, offset, ONLP_I2C_F_FORCE); - if ((optval & (0x0f)) != 0) //bit 0~3 - { - *value = 1; - } - else - { - *value = 0; - } - break; - - case ONLP_SFP_CONTROL_TX_DISABLE: - if (onlp_sfpi_is_present(port) == 0) - { - AIM_LOG_INFO("%s:%d fail[%d]\n", __FUNCTION__, __LINE__, ONLP_STATUS_E_MISSING); - return ONLP_STATUS_E_MISSING; - } - offset = QSFP28_EEPROM_TX_DISABLE_OFFSET; - addr = QSFP28_EEPROM_I2C_ADDR; - optval = onlp_i2c_readb(bus, addr, offset, ONLP_I2C_F_FORCE); - if ((optval & (0x0f)) != 0) //bit 0~3 - { - *value = 1; - } - else - { - *value = 0; - } - break; - - case ONLP_SFP_CONTROL_TX_DISABLE_CHANNEL: - if (onlp_sfpi_is_present(port) == 0) - { - AIM_LOG_INFO("%s:%d fail[%d]\n", __FUNCTION__, __LINE__, ONLP_STATUS_E_MISSING); - return ONLP_STATUS_E_MISSING; - } - offset = QSFP28_EEPROM_TX_DISABLE_OFFSET; - addr = QSFP28_EEPROM_I2C_ADDR; - optval = onlp_i2c_readb(bus, addr, offset, ONLP_I2C_F_FORCE); - *value = optval & (0x0f); //bit 0~3 - break; - - case ONLP_SFP_CONTROL_LP_MODE: - offset = PORT_CPLD_LOWPWR_ADDR_OFFSET; - optval = onlp_i2c_readb(cpld_bus, addr, offset, ONLP_I2C_F_FORCE); - if ((optval & (1 << port_bit)) != 0) - { - *value = 1; - } - else - { - *value = 0; - } - break; - - case ONLP_SFP_CONTROL_POWER_OVERRIDE: - if (onlp_sfpi_is_present(port) == 0) - { - AIM_LOG_INFO("%s:%d fail[%d]\n", __FUNCTION__, __LINE__, ONLP_STATUS_E_MISSING); - return ONLP_STATUS_E_MISSING; - } - offset = QSFP28_EEPROM_POWERSET_OFFSET; - addr = QSFP28_EEPROM_I2C_ADDR; - optval = onlp_i2c_readb(bus, addr, offset, ONLP_I2C_F_FORCE); - if ((optval & (0x01)) != 0) //bit 0 - { - *value = 1; - } - else - { - *value = 0; - } - break; - - //Set Only - case ONLP_SFP_CONTROL_RESET: - { - AIM_LOG_INFO("%s:%d fail[%d]\n", __FUNCTION__, __LINE__, ONLP_STATUS_E_INVALID); - return ONLP_STATUS_E_INVALID; - } - default: - return ONLP_STATUS_E_UNSUPPORTED; - break; - } - } - DIAG_PRINT("%s, port_bit:%d, bus:%d, cpld_bus:%d, addr:0x%X, offset:0x%X", __FUNCTION__, port_bit, bus, cpld_bus, addr, offset); - DIAG_PRINT("%s, port:%d, control:%d(%s), value:0x%X", __FUNCTION__, port, control, sfp_control_to_str(control), *value); - - return rv; -} - - -int -onlp_sfpi_denit(void) -{ - DIAG_PRINT("%s", __FUNCTION__); - return ONLP_STATUS_OK; -} diff --git a/packages/platforms/lenovo/x86-64/ne2572/onlp/builds/x86_64_lenovo_ne2572/module/src/sysi.c b/packages/platforms/lenovo/x86-64/ne2572/onlp/builds/x86_64_lenovo_ne2572/module/src/sysi.c deleted file mode 100644 index 74d0dc64c..000000000 --- a/packages/platforms/lenovo/x86-64/ne2572/onlp/builds/x86_64_lenovo_ne2572/module/src/sysi.c +++ /dev/null @@ -1,1316 +0,0 @@ -/************************************************************ - * - * - * Copyright 2014 Big Switch Networks, Inc. - * Copyright 2018 Alpha Networks Incorporation. - * - * Licensed under the Eclipse Public License, Version 1.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.eclipse.org/legal/epl-v10.html - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT 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_lenovo_ne2572_int.h" -#include "x86_64_lenovo_ne2572_log.h" -#include "platform_lib.h" -#include -#include - -#define DEBUG 0 - -#define PSU_NUM_ON_MAIN_BROAD 2 -#define FAN_NUM_ON_MAIN_BROAD 8 -#define LED_NUM_ON_MAIN_BROAD 10 -#define THERMAL_NUM_ON_MAIN_BROAD 2 - -#define SYSTEM_CPLD_I2C_BUS_ID 8 -#define SYSTEM_CPLD_I2C_ADDR 0x5F /* System CPLD Physical Address in the I2C */ -#define SYSTEM_CPLD_REVISION_ADDR_OFFSET 0x00 - -#define ONIE_EEPROM_BUS_ID 0 -#define ONIE_EEPROM_ADDR 0x56 - - - -#define PLATFORM_STRING "x86-64-lenovo-ne2572-r0" - -const char* -onlp_sysi_platform_get(void) -{ - DIAG_PRINT("%s, platform string: %s", __FUNCTION__, PLATFORM_STRING); - return PLATFORM_STRING; -} - -#if 0 -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; -} - -#else // for EEPROM should be read by "i2cdump -y 0 0x56 c"(consecutive byte) -int -onlp_sysi_onie_data_get(uint8_t **data, int *size) -{ - DIAG_PRINT("%s", __FUNCTION__); - int ret = 0; - uint8_t *rdata = aim_zmalloc(256); - - ret = i2c_sequential_read(ONIE_EEPROM_BUS_ID, ONIE_EEPROM_ADDR, 0, 256, (char *)rdata); - if (ret >= 0) - { - *data = rdata; - -#if 0//debug - int i = 0; - for (i=0;i<256;i++) - { - if ( i%8 == 0) - { - AIM_LOG_INFO("\n",rdata[i]); - } - AIM_LOG_INFO("0x%2X [%c]",rdata[i],(rdata[i]<=122 && rdata[i] >=65)?rdata[i]:' '); - - } - AIM_LOG_INFO("\n",rdata[i]); -#endif - return ONLP_STATUS_OK; - } - - aim_free(rdata); - *size = 0; - - return ONLP_STATUS_E_INTERNAL; -} - -#endif - -void onlp_sysi_onie_data_free(uint8_t *data) -{ - DIAG_PRINT("%s", __FUNCTION__); - if (data) - aim_free(data); -} - -int -onlp_sysi_platform_info_get(onlp_platform_info_t *pi) -{ - DIAG_PRINT("%s", __FUNCTION__); - int ret = 0; - char data = 0; - - ret = i2c_read_byte(SYSTEM_CPLD_I2C_BUS_ID, SYSTEM_CPLD_I2C_ADDR, SYSTEM_CPLD_REVISION_ADDR_OFFSET, &data); - if (ret < 0) - { - AIM_LOG_INFO("%s:%d fail[%d]\n", __FUNCTION__, __LINE__, ret); - return ret; - } - - pi->cpld_versions = aim_fstrdup("%d", (int)data); - - DIAG_PRINT("%s, cpld_versions:%d", __FUNCTION__, data); - return 0; -} - -void -onlp_sysi_platform_info_free(onlp_platform_info_t *pi) -{ - DIAG_PRINT("%s", __FUNCTION__); - aim_free(pi->cpld_versions); -} - - -int -onlp_sysi_oids_get(onlp_oid_t *table, int max) -{ - DIAG_PRINT("%s, max:%d", __FUNCTION__, max); - onlp_oid_t *e = table; - memset(table, 0, max * sizeof(onlp_oid_t)); - int i; - - uint32_t oid = 0; - - /* PSUs */ - for (i = 1; i <= PSU_NUM_ON_MAIN_BROAD; i++) - { - oid = ONLP_PSU_ID_CREATE(i); - *e++ = oid; - DIAG_PRINT("PSU#%d oid:%d", i, oid); - } - - /* LEDs */ - for (i = 1; i <= LED_NUM_ON_MAIN_BROAD; i++) - { - oid = ONLP_LED_ID_CREATE(i); - *e++ = oid; - DIAG_PRINT("LED#%d oid:%d", i, oid); - } - - /* Thermal sensors */ - for (i = 1; i <= THERMAL_NUM_ON_MAIN_BROAD; i++) - { - oid = ONLP_THERMAL_ID_CREATE(i); - *e++ = oid; - DIAG_PRINT("THERMAL#%d oid:%d", i, oid); - } - - /* Fans */ - for (i = 1; i <= FAN_NUM_ON_MAIN_BROAD; i++) - { - oid = ONLP_FAN_ID_CREATE(i); - *e++ = oid; - DIAG_PRINT("FAN#%d oid:%d", i, oid); - } - - return 0; -} - - -int onlp_sysi_platform_manage_init(void) -{ - DIAG_PRINT("%s", __FUNCTION__); - return 0; -} - -/* - * 1. If any FAN failed, set all the other fans as full speed (100%) - * 2. When (LM75-1 + LM75-2)/2 >= 49.5 C, set fan speed from 50% to 65%. - * 3. When (LM75-1 + LM75-2)/2 >= 53C, set fan speed from 65% to 80% - * 4. When (LM75-1 + LM75-2)/2 >= 57.5C, set fan speed from 80% to 100% - - * 5. When (LM75-1 + LM75-2)/2 <= 52.7C, set fan speed from 100% to 80% - * 6. When (LM75-1 + LM75-2)/2 <= 47.7C, set fan speed from 80% to 65% - * 7. When (LM75-1 + LM75-2)/2 <= 42.7C, set fan speed from 65% to 50% - * 8. The default FAN speed is 50% - */ -int -onlp_sysi_platform_manage_fans(void) -{ - DIAG_PRINT("%s", __FUNCTION__); -#define LEV1_UP_TEMP 57500 /*temperature*/ -#define LEV1_DOWN_TEMP NULL /* unused */ -#define LEV1_SPEED_PERC 100 /*percentage*/ - -#define LEV2_UP_TEMP 53000 -#define LEV2_DOWN_TEMP 52700 -#define LEV2_SPEED_PERC 80 - -#define LEV3_UP_TEMP 49500 -#define LEV3_DOWN_TEMP 47700 -#define LEV3_SPEED_PERC 65 - -#define LEV4_UP_TEMP NULL /* unused */ -#define LEV4_DOWN_TEMP 42700 -#define LEV4_SPEED_PERC 50 - - int rc, i; - int is_up; - int new_temp, temp1, temp2, diff; - static int new_perc = 0, ori_perc = 0; - static int ori_temp = 0; - static int fan_failed = 0; - onlp_thermal_info_t thermal_info; - onlp_fan_info_t fan_info; - - if (diag_debug_pause_platform_manage_check() == 1) //diag test mode - { - return ONLP_STATUS_OK; - } - - /* get new temperature */ - if ((rc = onlp_thermali_info_get(ONLP_THERMAL_ID_CREATE(1), &thermal_info)) != ONLP_STATUS_OK) - goto _EXIT; - - temp1 = thermal_info.mcelsius; - - if ((rc = onlp_thermali_info_get(ONLP_THERMAL_ID_CREATE(2), &thermal_info)) != ONLP_STATUS_OK) - goto _EXIT; - - temp2 = thermal_info.mcelsius; - - new_temp = (temp1 + temp2) / 2; - - /* check fan status */ - for (i = 1; i <= CHASSIS_FAN_COUNT; i++) - { - if ((rc = onlp_fani_info_get(ONLP_FAN_ID_CREATE(i), &fan_info)) != ONLP_STATUS_OK) - goto _EXIT; - - if (fan_info.status & ONLP_FAN_STATUS_FAILED) - { - new_perc = LEV1_SPEED_PERC; - fan_failed = 1; - goto _CTRL; - } - -#if 0 -#define UNKNOW_SPEED_PERC 0 - if( fan_info.rpm < 8800) //to prevent fan speed set too low by user , 8800 = lower bound speed for 50% - { - ori_perc = UNKNOW_SPEED_PERC; - new_perc = LEV4_SPEED_PERC; - fan_failed = 1; - goto _CTRL; - } -#endif - - } - - if (ori_perc == LEV1_SPEED_PERC && fan_failed == 1) - { - fan_failed = 0; - new_perc = LEV4_SPEED_PERC; - goto _CTRL; - } - - diff = new_temp - ori_temp; - - if (diff == 0) - goto _EXIT; - else - is_up = (diff > 0) ? 1 : 0; - - if (is_up) - { - if (new_temp >= LEV1_UP_TEMP) - new_perc = LEV1_SPEED_PERC; - else if (new_temp >= LEV2_UP_TEMP) - new_perc = LEV2_SPEED_PERC; - else if (new_temp >= LEV3_UP_TEMP) - new_perc = LEV3_SPEED_PERC; - else - new_perc = LEV4_SPEED_PERC; - } - else - { - if (new_temp <= LEV4_DOWN_TEMP) - new_perc = LEV4_SPEED_PERC; - else if (new_temp <= LEV3_DOWN_TEMP) - new_perc = LEV3_SPEED_PERC; - else if (new_temp <= LEV2_DOWN_TEMP) - new_perc = LEV2_SPEED_PERC; - else - new_perc = LEV1_SPEED_PERC; - } - -_CTRL : - - if (DEBUG) - printf("\n[%s][%d]{ori:temp=%d, perc=%d} {new:temp=%d, perc=%d}\n", __FUNCTION__, __LINE__, - ori_temp, ori_perc, new_temp, new_perc); - - if (ori_perc == new_perc) - goto _EXIT; - - /* ctrl fans */ -#if 1 //CPLD control all fans by one register. - if ((rc = onlp_fani_percentage_set(ONLP_FAN_ID_CREATE(FAN_1), new_perc)) != ONLP_STATUS_OK) - goto _EXIT; - - AIM_LOG_INFO("Fan%d Speeds are now at %d%%", i, new_perc); -#else - for (i = FAN_1; i <= FAN_6; i++) - { - if ((rc = onlp_fani_percentage_set(ONLP_FAN_ID_CREATE(i), new_perc)) != ONLP_STATUS_OK) - goto _EXIT; - - AIM_LOG_INFO("Fan%d Speeds are now at %d%%", i, new_perc); - } -#endif - - /* update om */ - ori_perc = new_perc; - ori_temp = new_temp; - -_EXIT : - - return rc; -} - -int -onlp_sysi_platform_manage_leds(void) -{ - DIAG_PRINT("%s", __FUNCTION__); - int i = 0, j = 0; - onlp_fan_info_t fan_info; - onlp_led_mode_t led_mode = ONLP_LED_MODE_OFF; - onlp_led_mode_t status_led_mode = ONLP_LED_MODE_BLUE_BLINKING; - onlp_psu_info_t psu1_info, psu2_info; - - int fan_ok_count = 0; - int psu_ok_count = 0; - - if (diag_debug_pause_platform_manage_check() == 1) //diag test mode - { - return ONLP_STATUS_OK; - } - - /* - * FAN Indicators - * - * Green - Good - * Amber - Present but failed - * Off - Not present - */ - for (i = FAN_1, j = LED_FAN; i <= FAN_6; i++) - { - if (onlp_fani_info_get(ONLP_FAN_ID_CREATE(i), &fan_info) != ONLP_STATUS_OK) - { - /* Get fan status fail */ - led_mode = ONLP_LED_MODE_GREEN_BLINKING; - //status_led_mode = ONLP_LED_MODE_BLUE_BLINKING; - } - else if ((fan_info.status & ONLP_FAN_STATUS_PRESENT) == 0) - { - /* Not present -- Off */ - led_mode = ONLP_LED_MODE_GREEN_BLINKING; - } - else if (fan_info.status & ONLP_FAN_STATUS_FAILED) - { - /* Present but Failed */ - led_mode = ONLP_LED_MODE_GREEN_BLINKING; - //status_led_mode = ONLP_LED_MODE_BLUE_BLINKING; - } - else - { - led_mode = ONLP_LED_MODE_GREEN; - fan_ok_count++; - } - - onlp_ledi_mode_set(ONLP_LED_ID_CREATE(j), led_mode); - } - - /* - * PSU Indicators, only one LED indicator for 2 PSUs. - */ - - if ((onlp_psui_info_get(ONLP_PSU_ID_CREATE(PSU1_ID), &psu1_info) != ONLP_STATUS_OK) || - (onlp_psui_info_get(ONLP_PSU_ID_CREATE(PSU2_ID), &psu2_info) != ONLP_STATUS_OK)) - { - /* Get PSU status fail */ - led_mode = ONLP_LED_MODE_GREEN_BLINKING; - //status_led_mode = ONLP_LED_MODE_BLUE_BLINKING; - printf("%s:%d psu1_info.status:0x%08x, psu2_info.status:0x%08x\n", __FUNCTION__, __LINE__, psu1_info.status, psu2_info.status); - } - else if (((psu1_info.status & ONLP_PSU_STATUS_PRESENT) == 0) && - ((psu2_info.status & ONLP_PSU_STATUS_PRESENT) == 0)) - { - /* Not present */ - led_mode = ONLP_LED_MODE_OFF; - } - else if ((psu1_info.status & ONLP_PSU_STATUS_FAILED) || - (psu2_info.status & ONLP_PSU_STATUS_FAILED)) - { - /* Present but Failed */ - led_mode = ONLP_LED_MODE_GREEN_BLINKING; - //status_led_mode = ONLP_LED_MODE_BLUE_BLINKING; - printf("%s:%d psu1_info.status:0x%08x, psu2_info.status:0x%08x\n", __FUNCTION__, __LINE__, psu1_info.status, psu2_info.status); - } - else if ((psu1_info.status & ONLP_PSU_STATUS_UNPLUGGED) && - (psu2_info.status & ONLP_PSU_STATUS_UNPLUGGED)) - { - led_mode = ONLP_LED_MODE_GREEN_BLINKING; - } - else - { - led_mode = ONLP_LED_MODE_GREEN; - psu_ok_count = 2; - } - - onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_PWR), led_mode); - - - if (psu_ok_count == 2 && fan_ok_count == 6) - { - status_led_mode = ONLP_LED_MODE_OFF; - } - - onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_SERVICE), status_led_mode); - - return ONLP_STATUS_OK; -} - -int -onlp_sysi_init(void) -{ - DIAG_PRINT("%s", __FUNCTION__); - return ONLP_STATUS_OK; -} -int onlp_sysi_debug_diag_fan_status(void) -{ - int oid = 0; - int i = 0; - uint32_t status = 0; - for (i = 1; i <= FAN_NUM_ON_MAIN_BROAD; i++) - { - oid = ONLP_FAN_ID_CREATE(i); - onlp_fani_status_get(oid, &status); - printf("FAN#%d oid:%d\n", i, oid); - printf("Status: 0x%x [%s %s]\n", status, - (status & ONLP_FAN_STATUS_PRESENT) ? "PRESENT" : "", - (status & ONLP_FAN_STATUS_FAILED) ? "FAILED" : ""); - } - return 0; - -} - -int onlp_sysi_debug_diag_fan(void) -{ - onlp_fan_info_t fan_info; - - printf("[Set fan speed to 10%% ...]\n"); - onlp_fani_percentage_set(ONLP_FAN_ID_CREATE(FAN_1), 10); - sleep(2); - onlp_fani_info_get(ONLP_FAN_ID_CREATE(FAN_1), &fan_info); - printf("FAN_1 fan_info.percentage = %d\n", fan_info.percentage); - printf("\n"); - getchar(); - - printf("[Set fan speed to 30%% ...]\n"); - onlp_fani_percentage_set(ONLP_FAN_ID_CREATE(FAN_1), 30); - sleep(2); - onlp_fani_info_get(ONLP_FAN_ID_CREATE(FAN_1), &fan_info); - printf("FAN_1 fan_info.percentage = %d\n", fan_info.percentage); - printf("\n"); - getchar(); - - printf("[Set fan speed to 50%% ...]\n"); - onlp_fani_percentage_set(ONLP_FAN_ID_CREATE(FAN_1), 50); - sleep(2); - onlp_fani_info_get(ONLP_FAN_ID_CREATE(FAN_1), &fan_info); - printf("FAN_1 fan_info.percentage = %d\n", fan_info.percentage); - printf("\n"); - getchar(); - - printf("[Set fan speed to 70%% ...]\n"); - onlp_fani_percentage_set(ONLP_FAN_ID_CREATE(FAN_1), 70); - sleep(2); - onlp_fani_info_get(ONLP_FAN_ID_CREATE(FAN_1), &fan_info); - printf("FAN_1 fan_info.percentage = %d\n", fan_info.percentage); - printf("\n"); - getchar(); - - printf("[Set fan speed to 100%% ...]\n"); - onlp_fani_percentage_set(ONLP_FAN_ID_CREATE(FAN_1), 100); - sleep(2); - onlp_fani_info_get(ONLP_FAN_ID_CREATE(FAN_1), &fan_info); - printf("FAN_1 fan_info.percentage = %d\n", fan_info.percentage); - printf("\n"); - getchar(); - - printf("set fan speed to default(50%%) by onlp_fani_init()\n"); - onlp_fani_init(); - return 0; -} - -int onlp_sysi_debug_diag_led(void) -{ - - - printf(" SERVICE o o PSU \n"); - printf(" STACKING o o FAN1~6 \n"); - - printf("[Stop platform manage ...]\n"); -#if 1 - diag_debug_pause_platform_manage_on(); -#else - onlp_sys_platform_manage_stop(0); -#endif - sleep(1); - - printf("[Set All LED to OFF ...]\n"); - onlp_ledi_set(ONLP_LED_ID_CREATE(LED_SERVICE), ONLP_LED_MODE_OFF); - onlp_ledi_set(ONLP_LED_ID_CREATE(LED_STACKING), ONLP_LED_MODE_OFF); - onlp_ledi_set(ONLP_LED_ID_CREATE(LED_PWR), ONLP_LED_MODE_OFF); - onlp_ledi_set(ONLP_LED_ID_CREATE(LED_FAN), ONLP_LED_MODE_OFF); - onlp_ledi_set(ONLP_LED_ID_CREATE(LED_REAR_FAN1), ONLP_LED_MODE_OFF); - onlp_ledi_set(ONLP_LED_ID_CREATE(LED_REAR_FAN2), ONLP_LED_MODE_OFF); - onlp_ledi_set(ONLP_LED_ID_CREATE(LED_REAR_FAN3), ONLP_LED_MODE_OFF); - onlp_ledi_set(ONLP_LED_ID_CREATE(LED_REAR_FAN4), ONLP_LED_MODE_OFF); - onlp_ledi_set(ONLP_LED_ID_CREATE(LED_REAR_FAN5), ONLP_LED_MODE_OFF); - onlp_ledi_set(ONLP_LED_ID_CREATE(LED_REAR_FAN6), ONLP_LED_MODE_OFF); - printf("\n"); - getchar(); - - - printf("[Set SERVICE LED to ONLP_LED_MODE_BLUE ...]\n"); - onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_SERVICE), ONLP_LED_MODE_BLUE); - printf("\n"); - getchar(); - printf("[Set SERVICE LED to ONLP_LED_MODE_BLUE_BLINKING ...]\n"); - onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_SERVICE), ONLP_LED_MODE_BLUE_BLINKING); - printf("\n"); - getchar(); - - printf("[Set SERVICE LED to ONLP_LED_MODE_GREEN ...]\n"); - onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_SERVICE), ONLP_LED_MODE_GREEN); - printf("\n"); - getchar(); - printf("[Set SERVICE LED to ONLP_LED_MODE_GREEN_BLINKING ...]\n"); - onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_SERVICE), ONLP_LED_MODE_GREEN_BLINKING); - printf("\n"); - getchar(); - - printf("[Set STACKING LED to ONLP_LED_MODE_ORANGE ...]\n"); - onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_STACKING), ONLP_LED_MODE_ORANGE); - printf("\n"); - getchar(); - printf("[Set STACKING LED to ONLP_LED_MODE_ORANGE_BLINKING ...]\n"); - onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_STACKING), ONLP_LED_MODE_ORANGE_BLINKING); - printf("\n"); - getchar(); - printf("[Set STACKING LED to ONLP_LED_MODE_GREEN ...]\n"); - onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_STACKING), ONLP_LED_MODE_GREEN); - printf("\n"); - getchar(); - printf("[Set STACKING LED to ONLP_LED_MODE_GREEN_BLINKING ...]\n"); - onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_STACKING), ONLP_LED_MODE_GREEN_BLINKING); - printf("\n"); - getchar(); - - printf("[Set PSU LED to ONLP_LED_MODE_ORANGE ...]\n"); - onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_PWR), ONLP_LED_MODE_ORANGE); - printf("\n"); - getchar(); - printf("[Set PSU LED to ONLP_LED_MODE_ORANGE_BLINKING ...]\n"); - onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_PWR), ONLP_LED_MODE_ORANGE_BLINKING); - printf("\n"); - getchar(); - printf("[Set PSU LED to ONLP_LED_MODE_GREEN ...]\n"); - onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_PWR), ONLP_LED_MODE_GREEN); - printf("\n"); - getchar(); - printf("[Set PSU LED to ONLP_LED_MODE_GREEN_BLINKING ...]\n"); - onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_PWR), ONLP_LED_MODE_GREEN_BLINKING); - printf("\n"); - getchar(); - - printf("[Set FAN LED to ONLP_LED_MODE_ORANGE ...]\n"); - onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_FAN), ONLP_LED_MODE_ORANGE); - printf("\n"); - getchar(); - printf("[Set FAN LED to ONLP_LED_MODE_ORANGE_BLINKING ...]\n"); - onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_FAN), ONLP_LED_MODE_ORANGE_BLINKING); - printf("\n"); - getchar(); - printf("[Set FAN LED to ONLP_LED_MODE_GREEN ...]\n"); - onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_FAN), ONLP_LED_MODE_GREEN); - printf("\n"); - getchar(); - printf("[Set FAN LED to ONLP_LED_MODE_GREEN_BLINKING ...]\n"); - onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_FAN), ONLP_LED_MODE_GREEN_BLINKING); - printf("\n"); - getchar(); - - printf("[Set REAR FAN1 LED to ONLP_LED_MODE_GREEN ...]\n"); - onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_REAR_FAN1), ONLP_LED_MODE_GREEN); - printf("\n"); - getchar(); - printf("[Set REAR FAN1 LED to ONLP_LED_MODE_GREEN_BLINKING ...]\n"); - onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_REAR_FAN1), ONLP_LED_MODE_GREEN_BLINKING); - printf("\n"); - getchar(); - - printf("[Set REAR FAN2 LED to ONLP_LED_MODE_GREEN ...]\n"); - onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_REAR_FAN2), ONLP_LED_MODE_GREEN); - printf("\n"); - getchar(); - printf("[Set REAR FAN2 LED to ONLP_LED_MODE_GREEN_BLINKING ...]\n"); - onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_REAR_FAN2), ONLP_LED_MODE_GREEN_BLINKING); - printf("\n"); - getchar(); - - printf("[Set REAR FAN3 LED to ONLP_LED_MODE_GREEN ...]\n"); - onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_REAR_FAN3), ONLP_LED_MODE_GREEN); - printf("\n"); - getchar(); - printf("[Set REAR FAN3 LED to ONLP_LED_MODE_GREEN_BLINKING ...]\n"); - onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_REAR_FAN3), ONLP_LED_MODE_GREEN_BLINKING); - printf("\n"); - getchar(); - - printf("[Set REAR FAN4 LED to ONLP_LED_MODE_GREEN ...]\n"); - onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_REAR_FAN4), ONLP_LED_MODE_GREEN); - printf("\n"); - getchar(); - printf("[Set REAR FAN4 LED to ONLP_LED_MODE_GREEN_BLINKING ...]\n"); - onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_REAR_FAN4), ONLP_LED_MODE_GREEN_BLINKING); - printf("\n"); - getchar(); - - printf("[Set REAR FAN5 LED to ONLP_LED_MODE_GREEN ...]\n"); - onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_REAR_FAN5), ONLP_LED_MODE_GREEN); - printf("\n"); - getchar(); - printf("[Set REAR FAN5 LED to ONLP_LED_MODE_GREEN_BLINKING ...]\n"); - onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_REAR_FAN5), ONLP_LED_MODE_GREEN_BLINKING); - printf("\n"); - getchar(); - - printf("[Set REAR FAN6 LED to ONLP_LED_MODE_GREEN ...]\n"); - onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_REAR_FAN6), ONLP_LED_MODE_GREEN); - printf("\n"); - getchar(); - printf("[Set REAR FAN6 LED to ONLP_LED_MODE_GREEN_BLINKING ...]\n"); - onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_REAR_FAN6), ONLP_LED_MODE_GREEN_BLINKING); - printf("\n"); - getchar(); - - printf("[Set All LED to OFF ...]\n"); - onlp_ledi_set(ONLP_LED_ID_CREATE(LED_SERVICE), ONLP_LED_MODE_OFF); - onlp_ledi_set(ONLP_LED_ID_CREATE(LED_STACKING), ONLP_LED_MODE_OFF); - onlp_ledi_set(ONLP_LED_ID_CREATE(LED_PWR), ONLP_LED_MODE_OFF); - onlp_ledi_set(ONLP_LED_ID_CREATE(LED_FAN), ONLP_LED_MODE_OFF); - onlp_ledi_set(ONLP_LED_ID_CREATE(LED_REAR_FAN1), ONLP_LED_MODE_OFF); - onlp_ledi_set(ONLP_LED_ID_CREATE(LED_REAR_FAN2), ONLP_LED_MODE_OFF); - onlp_ledi_set(ONLP_LED_ID_CREATE(LED_REAR_FAN3), ONLP_LED_MODE_OFF); - onlp_ledi_set(ONLP_LED_ID_CREATE(LED_REAR_FAN4), ONLP_LED_MODE_OFF); - onlp_ledi_set(ONLP_LED_ID_CREATE(LED_REAR_FAN5), ONLP_LED_MODE_OFF); - onlp_ledi_set(ONLP_LED_ID_CREATE(LED_REAR_FAN6), ONLP_LED_MODE_OFF); - - printf("[Restart platform manage ...]\n"); - onlp_ledi_init(); -#if 1 - diag_debug_pause_platform_manage_off(); -#else - onlp_sys_platform_manage_start(0); -#endif - return 0; -} -#define SFP_DIAG_OFFSET 118 // EXTENDED MODULE CONTROL/STATUS BYTES in SFF-8472 standard -#define QSFP_DIAG_OFFSET 114 //the reserved bytes 114~118 support r/w in SFF-8636 standard -#define SFP_DIAG_PATTEN_B 0xAA -#define SFP_DIAG_PATTEN_W 0xABCD - -int onlp_sysi_debug_diag_sfp(int index) -{ - uint8_t *data = NULL; - int rv = 0; - - uint8_t org_b = 0; - uint16_t org_w = 0; - uint8_t temp_b = 0; - uint16_t temp_w = 0; - int offset = 0, addr = 0; - - data = aim_zmalloc(256); - if ((rv = onlp_sfpi_eeprom_read(index, data)) < 0) - { - - aim_printf(&aim_pvs_stdout, "Error reading eeprom: %{onlp_status}\n"); - } - else - { - aim_printf(&aim_pvs_stdout, "dump eeprom:\n%{data}\n", data, 256); - } - aim_free(data); - data = NULL; - if (index < QSFP_START_INDEX) - { - addr = SFP_DOM_EEPROM_I2C_ADDR; - offset = SFP_DIAG_OFFSET; - } - else - { - addr = QSFP28_EEPROM_I2C_ADDR; - offset = QSFP_DIAG_OFFSET; - } -//BYTE - printf("Read/Write byte test...\n"); - - org_b = onlp_sfpi_dev_readb(index, addr, offset); - if (org_b < 0) - { - printf("Error, read failed!"); - goto DONE; - } - rv = onlp_sfpi_dev_writeb(index, addr, offset, SFP_DIAG_PATTEN_B); - if (rv < 0) - { - printf("Error, write failed!"); - goto DONE; - } - sleep(2); - temp_b = onlp_sfpi_dev_readb(index, addr, offset); - if (temp_b < 0) - { - printf("Error, read failed!"); - goto DONE; - } - if (temp_b != SFP_DIAG_PATTEN_B) - { - printf("Error, mismatch!"); - goto DONE; - } - rv = onlp_sfpi_dev_writeb(index, addr, offset, org_b); - if (rv < 0) - { - printf("Error, write failed!"); - goto DONE; - } - sleep(2); -//WORD - printf("Read/Write word test...\n"); - org_w = onlp_sfpi_dev_readw(index, addr, offset); - if (org_w < 0) - { - printf("Error, read failed!"); - goto DONE; - } - rv = onlp_sfpi_dev_writew(index, addr, offset, SFP_DIAG_PATTEN_W); - if (rv < 0) - { - printf("Error, write failed!"); - goto DONE; - } - sleep(2); - temp_w = onlp_sfpi_dev_readw(index, addr, offset); - if (temp_w < 0) - { - printf("Error, read failed!"); - goto DONE; - } - if (temp_w != SFP_DIAG_PATTEN_W) - { - printf("Error, mismatch!"); - goto DONE; - } - rv = onlp_sfpi_dev_writew(index, addr, offset, org_w); - if (rv < 0) - { - printf("Error, write failed!"); - goto DONE; - } - - - -DONE: - return 0; -} - -int onlp_sysi_debug_diag_sfp_dom(int index) -{ - uint8_t *data = NULL; - int rv = 0; - - data = aim_zmalloc(256); - if ((rv = onlp_sfpi_dom_read(index, data)) < 0) - { - - aim_printf(&aim_pvs_stdout, "Error reading dom eeprom: %{onlp_status}\n"); - } - else - { - aim_printf(&aim_pvs_stdout, "dump DOM eeprom:\n%{data}\n", data, 256); - } - aim_free(data); - data = NULL; - - return 0; -} - -int onlp_sysi_debug_diag_sfp_ctrl(int index) -{ - int val = 0; - - printf("[Option: %d(%s)... Set]\n", ONLP_SFP_CONTROL_RESET, sfp_control_to_str(ONLP_SFP_CONTROL_RESET)); - printf("[Set %s...]\n", sfp_control_to_str(ONLP_SFP_CONTROL_RESET)); - onlp_sfpi_control_set(index, ONLP_SFP_CONTROL_RESET, 1); - sleep(1); - printf("\n"); - getchar(); - - - printf("[Option: %d(%s)...Set/Get]\n", ONLP_SFP_CONTROL_RESET_STATE, sfp_control_to_str(ONLP_SFP_CONTROL_RESET_STATE)); - printf("[Set %s... to 1]\n", sfp_control_to_str(ONLP_SFP_CONTROL_RESET_STATE)); - onlp_sfpi_control_set(index, ONLP_SFP_CONTROL_RESET_STATE, 1); - sleep(1); - printf("[Get %s... ]\n", sfp_control_to_str(ONLP_SFP_CONTROL_RESET_STATE)); - onlp_sfpi_control_get(index, ONLP_SFP_CONTROL_RESET_STATE, &val); - printf("\n"); - getchar(); - - printf("[Set %s... to 0]\n", sfp_control_to_str(ONLP_SFP_CONTROL_RESET_STATE)); - onlp_sfpi_control_set(index, ONLP_SFP_CONTROL_RESET_STATE, 0); - sleep(1); - printf("[Get %s... ]\n", sfp_control_to_str(ONLP_SFP_CONTROL_RESET_STATE)); - onlp_sfpi_control_get(index, ONLP_SFP_CONTROL_RESET_STATE, &val); - printf("\n"); - getchar(); - - printf("[Option: %d(%s)...Get]\n", ONLP_SFP_CONTROL_RX_LOS, sfp_control_to_str(ONLP_SFP_CONTROL_RX_LOS)); - printf("[Get %s... ]\n", sfp_control_to_str(ONLP_SFP_CONTROL_RX_LOS)); - onlp_sfpi_control_get(index, ONLP_SFP_CONTROL_RX_LOS, &val); - printf("\n"); - getchar(); - - printf("[Option: %d(%s)...Get]\n", ONLP_SFP_CONTROL_TX_FAULT, sfp_control_to_str(ONLP_SFP_CONTROL_TX_FAULT)); - printf("[Get %s... ]\n", sfp_control_to_str(ONLP_SFP_CONTROL_TX_FAULT)); - onlp_sfpi_control_get(index, ONLP_SFP_CONTROL_TX_FAULT, &val); - printf("\n"); - getchar(); - - printf("[Option: %d(%s)...Set/Get]\n", ONLP_SFP_CONTROL_TX_DISABLE, sfp_control_to_str(ONLP_SFP_CONTROL_TX_DISABLE)); - printf("[Set %s... to 1]\n", sfp_control_to_str(ONLP_SFP_CONTROL_TX_DISABLE)); - onlp_sfpi_control_set(index, ONLP_SFP_CONTROL_TX_DISABLE, 1); - sleep(1); - printf("[Get %s... ]\n", sfp_control_to_str(ONLP_SFP_CONTROL_TX_DISABLE)); - onlp_sfpi_control_get(index, ONLP_SFP_CONTROL_TX_DISABLE, &val); - printf("\n"); - getchar(); - - printf("[Set %s... to 0]\n", sfp_control_to_str(ONLP_SFP_CONTROL_TX_DISABLE)); - onlp_sfpi_control_set(index, ONLP_SFP_CONTROL_TX_DISABLE, 0); - sleep(1); - printf("[Get %s... ]\n", sfp_control_to_str(ONLP_SFP_CONTROL_TX_DISABLE)); - onlp_sfpi_control_get(index, ONLP_SFP_CONTROL_TX_DISABLE, &val); - printf("\n"); - getchar(); - - printf("[Option: %d(%s)...Set/Get]\n", ONLP_SFP_CONTROL_TX_DISABLE_CHANNEL, sfp_control_to_str(ONLP_SFP_CONTROL_TX_DISABLE_CHANNEL)); - printf("[Set %s... to 0x05]\n", sfp_control_to_str(ONLP_SFP_CONTROL_TX_DISABLE_CHANNEL)); - onlp_sfpi_control_set(index, ONLP_SFP_CONTROL_TX_DISABLE_CHANNEL, 0x05); - sleep(1); - printf("[Get %s... ]\n", sfp_control_to_str(ONLP_SFP_CONTROL_TX_DISABLE_CHANNEL)); - onlp_sfpi_control_get(index, ONLP_SFP_CONTROL_TX_DISABLE_CHANNEL, &val); - printf("\n"); - getchar(); - - printf("[Set %s... to 0]\n", sfp_control_to_str(ONLP_SFP_CONTROL_TX_DISABLE_CHANNEL)); - onlp_sfpi_control_set(index, ONLP_SFP_CONTROL_TX_DISABLE_CHANNEL, 0); - sleep(1); - printf("[Get %s... ]\n", sfp_control_to_str(ONLP_SFP_CONTROL_TX_DISABLE_CHANNEL)); - onlp_sfpi_control_get(index, ONLP_SFP_CONTROL_TX_DISABLE_CHANNEL, &val); - printf("\n"); - getchar(); - - printf("[Option: %d(%s)...Set/Get]\n", ONLP_SFP_CONTROL_LP_MODE, sfp_control_to_str(ONLP_SFP_CONTROL_LP_MODE)); - printf("[Set %s... to 1]\n", sfp_control_to_str(ONLP_SFP_CONTROL_LP_MODE)); - onlp_sfpi_control_set(index, ONLP_SFP_CONTROL_LP_MODE, 1); - sleep(1); - printf("[Get %s... ]\n", sfp_control_to_str(ONLP_SFP_CONTROL_LP_MODE)); - onlp_sfpi_control_get(index, ONLP_SFP_CONTROL_LP_MODE, &val); - printf("\n"); - getchar(); - - printf("[Set %s... to 0]\n", sfp_control_to_str(ONLP_SFP_CONTROL_LP_MODE)); - onlp_sfpi_control_set(index, ONLP_SFP_CONTROL_LP_MODE, 0); - sleep(1); - printf("[Get %s... ]\n", sfp_control_to_str(ONLP_SFP_CONTROL_LP_MODE)); - onlp_sfpi_control_get(index, ONLP_SFP_CONTROL_LP_MODE, &val); - printf("\n"); - getchar(); - - printf("[Option: %d(%s)...Set/Get]\n", ONLP_SFP_CONTROL_POWER_OVERRIDE, sfp_control_to_str(ONLP_SFP_CONTROL_POWER_OVERRIDE)); - printf("[Set %s... to 1]\n", sfp_control_to_str(ONLP_SFP_CONTROL_POWER_OVERRIDE)); - onlp_sfpi_control_set(index, ONLP_SFP_CONTROL_POWER_OVERRIDE, 1); - sleep(1); - printf("[Get %s... ]\n", sfp_control_to_str(ONLP_SFP_CONTROL_POWER_OVERRIDE)); - onlp_sfpi_control_get(index, ONLP_SFP_CONTROL_POWER_OVERRIDE, &val); - printf("\n"); - getchar(); - - printf("[Set %s... to 0]\n", sfp_control_to_str(ONLP_SFP_CONTROL_POWER_OVERRIDE)); - onlp_sfpi_control_set(index, ONLP_SFP_CONTROL_POWER_OVERRIDE, 0); - sleep(1); - printf("[Get %s... ]\n", sfp_control_to_str(ONLP_SFP_CONTROL_POWER_OVERRIDE)); - onlp_sfpi_control_get(index, ONLP_SFP_CONTROL_POWER_OVERRIDE, &val); - printf("\n"); - getchar(); - - return 0; -} - -int -onlp_sysi_debug(aim_pvs_t *pvs, int argc, char *argv[]) -{ - int ret = 0; - - /* ONLPI driver APIs debug */ - - if (argc > 0 && !strcmp(argv[0], "sys")) - { - diag_flag_set(DIAG_FLAG_ON); - printf("DIAG for SYS: \n"); - printf("Platform : %s\n", onlp_sysi_platform_get()); - onlp_sysi_init(); - onlp_sysi_platform_manage_init(); - diag_flag_set(DIAG_FLAG_OFF); - } - else if (argc > 0 && !strcmp(argv[0], "fan_rpm")) - { - onlp_fan_info_t fan_info; - int i = 0; - diag_flag_set(DIAG_FLAG_ON); - printf("DIAG for FAN rpm: \n"); - - int rpm = 0; - if (argc != 2) - { - printf("Parameter error, format: onlpdump debugi fan_rpm [RPM]\n"); - return -1; - } - rpm = atoi(argv[1]); - onlp_fani_rpm_set(ONLP_FAN_ID_CREATE(FAN_1), rpm); - - sleep(5); - for (i = 1; i <= CHASSIS_FAN_COUNT; i++) - { - onlp_fani_info_get(ONLP_FAN_ID_CREATE(i), &fan_info); - printf("FAN#%d RPM:%d\n", i, fan_info.rpm); - } - - diag_flag_set(DIAG_FLAG_OFF); - } - else if (argc > 0 && !strcmp(argv[0], "fan_status")) - { - diag_flag_set(DIAG_FLAG_ON); - printf("DIAG for FAN status: \n"); - onlp_sysi_debug_diag_fan_status(); - diag_flag_set(DIAG_FLAG_OFF); - } - else if (argc > 0 && !strcmp(argv[0], "fan")) - { - diag_flag_set(DIAG_FLAG_ON); - onlp_sysi_debug_diag_fan(); - diag_flag_set(DIAG_FLAG_OFF); - } - else if (argc > 0 && !strcmp(argv[0], "psu")) - { - printf("DIAG for PSU: \n"); - diag_flag_set(DIAG_FLAG_ON); - onlp_psui_init(); - diag_flag_set(DIAG_FLAG_OFF); - - } - else if (argc > 0 && !strcmp(argv[0], "led")) - { - printf("DIAG for LED: \n"); - diag_flag_set(DIAG_FLAG_ON); - onlp_sysi_debug_diag_led(); - diag_flag_set(DIAG_FLAG_OFF); - } - else if (argc > 0 && !strcmp(argv[0], "sfp_dom")) - { - int port_index = 0; - if (argc != 2) - { - printf("Parameter error, format: onlpdump debugi sfp_dom [PORT]\n"); - return -1; - } - port_index = atoi(argv[1]); - if (port_index <= 0 || port_index > NUM_OF_SFP_PORT) - { - printf("Parameter error, PORT out of range.\n"); - return -1; - } - printf("DIAG for SFP DOM #%d: \n", port_index - 1); - diag_flag_set(DIAG_FLAG_ON); - onlp_sysi_debug_diag_sfp_dom(port_index - 1); - diag_flag_set(DIAG_FLAG_OFF); - } - else if (argc > 0 && !strcmp(argv[0], "sfp_ctrl_set")) - { - int port_index = 0, ctrl = 0, val = 0; - if (argc != 4) - { - printf("Parameter error, format: onlpdump debugi sfp_ctrl_set [PORT] [CTRL] [VALUE]\n"); - return -1; - } - port_index = atoi(argv[1]); - if (port_index <= 0 || port_index > NUM_OF_SFP_PORT) - { - printf("Parameter error, PORT out of range.\n"); - return -1; - } - ctrl = atoi(argv[2]); - val = atoi(argv[3]); - diag_flag_set(DIAG_FLAG_ON); - onlp_sfpi_control_set(port_index - 1, ctrl, val); - diag_flag_set(DIAG_FLAG_OFF); - - } - else if (argc > 0 && !strcmp(argv[0], "sfp_ctrl_get")) - { - int port_index = 0, ctrl = 0, val = 0; - if (argc != 3) - { - printf("Parameter error, format: onlpdump debugi sfp_ctrl_get [PORT] [CTRL] \n"); - return -1; - } - port_index = atoi(argv[1]); - if (port_index <= 0 || port_index > NUM_OF_SFP_PORT) - { - printf("Parameter error, PORT out of range.\n"); - return -1; - } - ctrl = atoi(argv[2]); - diag_flag_set(DIAG_FLAG_ON); - onlp_sfpi_control_get(port_index - 1, ctrl, &val); - printf("Value = %d(0x%X)\n", val, val); - diag_flag_set(DIAG_FLAG_OFF); - - } - else if (argc > 0 && !strcmp(argv[0], "sfp_ctrl")) - { - int port_index = 0; - if (argc != 2) - { - printf("Parameter error, format: onlpdump debugi sfp_ctrl [PORT]\n"); - return -1; - } - port_index = atoi(argv[1]); - if (port_index <= 0 || port_index > NUM_OF_SFP_PORT) - { - printf("Parameter error, PORT out of range.\n"); - return -1; - } - - printf("DIAG for SFP Control #%d: \n", port_index - 1); - diag_flag_set(DIAG_FLAG_ON); - onlp_sysi_debug_diag_sfp_ctrl(port_index - 1); - diag_flag_set(DIAG_FLAG_OFF); - } - else if (argc > 0 && !strcmp(argv[0], "sfp")) - { - if (argc > 1) - { - int port_index = atoi(argv[1]); - if (port_index <= 0 || port_index > NUM_OF_SFP_PORT) - { - printf("Parameter error, PORT out of range.\n"); - return -1; - } - printf("DIAG for SFP#%d: \n", port_index - 1); - diag_flag_set(DIAG_FLAG_ON); - onlp_sysi_debug_diag_sfp(port_index - 1); - diag_flag_set(DIAG_FLAG_OFF); - } - else - { - printf("DIAG for SFP: \n"); - onlp_sfp_bitmap_t bmap; - diag_flag_set(DIAG_FLAG_ON); - - onlp_sfpi_denit(); - onlp_sfpi_init(); - - onlp_sfp_bitmap_t_init(&bmap); - ret = onlp_sfpi_bitmap_get(&bmap); - if (ret < 0) - { - printf("Error, onlp_sfpi_bitmap_get failed!\n"); - } - else - { - aim_printf(&aim_pvs_stdout, "sfp_bitmap:\n %{aim_bitmap}\n", &bmap); - } - diag_flag_set(DIAG_FLAG_OFF); - - return 0; - } - } - else if (argc > 0 && !strcmp(argv[0], "sfpwb")) //write byte - { - int port; - uint8_t addr, value; - - if (argc == 4) - { - port = atoi(argv[1]); - addr = (uint8_t)atoi(argv[2]); - value = (uint8_t)atoi(argv[3]); - - if (port <= 0 || port > NUM_OF_SFP_PORT) - { - printf("Parameter error, PORT out of range.\n"); - return -1; - } - - diag_flag_set(DIAG_FLAG_ON); - onlp_sfpi_dev_writeb(port - 1, QSFP28_EEPROM_I2C_ADDR, addr, value); - diag_flag_set(DIAG_FLAG_OFF); - } - else - { - printf("Parameter error, format: onlpdump debugi sfpwb [PORT] [ADDR] [VALUE]\n"); - return -1; - } - - } - else if (argc > 0 && !strcmp(argv[0], "sfprb")) //read byte - { - int port; - uint8_t addr; - if (argc == 3) - { - port = atoi(argv[1]); - addr = (uint8_t)atoi(argv[2]); - - if (port <= 0 || port > NUM_OF_SFP_PORT) - { - printf("Parameter error, PORT out of range.\n"); - return -1; - } - - diag_flag_set(DIAG_FLAG_ON); - onlp_sfpi_dev_readb(port - 1, QSFP28_EEPROM_I2C_ADDR, addr); - diag_flag_set(DIAG_FLAG_OFF); - } - else - { - printf("Parameter error, format: onlpdump debugi sfprb [PORT] [ADDR]\n"); - return -1; - } - } - else if (argc > 0 && !strcmp(argv[0], "sfpww")) //write word - { - int port; - uint16_t value; - uint8_t addr; - - if (argc == 4) - { - port = atoi(argv[1]); - addr = (uint8_t)atoi(argv[2]); - value = (uint16_t)atoi(argv[3]); - - if (port <= 0 || port > NUM_OF_SFP_PORT) - { - printf("Parameter error, PORT out of range.\n"); - return -1; - } - - diag_flag_set(DIAG_FLAG_ON); - onlp_sfpi_dev_writew(port - 1, QSFP28_EEPROM_I2C_ADDR, addr, value); - diag_flag_set(DIAG_FLAG_OFF); - } - else - { - printf("Parameter error, format: onlpdump debugi sfpwb [PORT] [ADDR] [VALUE]\n"); - return -1; - } - } - else if (argc > 0 && !strcmp(argv[0], "sfprw")) //read word - { - int port; - uint8_t addr; - if (argc == 3) - { - port = atoi(argv[1]); - addr = (uint8_t)atoi(argv[2]); - - if (port <= 0 || port > NUM_OF_SFP_PORT) - { - printf("Parameter error, PORT out of range.\n"); - return -1; - } - - diag_flag_set(DIAG_FLAG_ON); - onlp_sfpi_dev_readw(port - 1, QSFP28_EEPROM_I2C_ADDR, addr); - diag_flag_set(DIAG_FLAG_OFF); - } - else - { - printf("Parameter error, format: onlpdump debugi sfprb [PORT] [ADDR]\n"); - return -1; - } - } - else if (argc > 0 && !strcmp(argv[0], "thermal")) - { - printf("DIAG for Thermal: \n"); - diag_flag_set(DIAG_FLAG_ON); - onlp_thermali_init(); - diag_flag_set(DIAG_FLAG_OFF); - } - else if (argc > 0 && !strcmp(argv[0], "trace_on")) - { - diag_debug_trace_on(); - DIAG_PRINT("%s, ONLPI TRACE: ON", __FUNCTION__); - } - else if (argc > 0 && !strcmp(argv[0], "trace_off")) - { - diag_debug_trace_off(); - DIAG_PRINT("%s, ONLPI TRACE: OFF", __FUNCTION__); - } - else if (argc > 0 && !strcmp(argv[0], "help")) - { - printf("\nUsage: onlpdump debugi [OPTION]\n"); - printf(" help : this message.\n"); - printf(" trace_on : turn on ONLPI debug trace message output on screen.\n"); - printf(" trace_off : turn off ONLPI debug trace message output on screen.\n"); - printf(" sys : run system ONLPI diagnostic function.\n"); - printf(" fan : run fan ONLPI diagnostic function.\n"); - printf(" fan_status : run fan status ONLPI diagnostic function.\n"); - printf(" fan_rpm : run fan RPM ONLPI diagnostic function.\n"); - printf(" led : run LED ONLPI diagnostic function.\n"); - printf(" psu : run psu ONLPI diagnostic function.\n"); - printf(" thermal : run thermal ONLPI diagnostic function.\n"); - printf(" sfp : run sfp ONLPI diagnostic function.\n"); - printf(" sfp [PORT] : run sfp ONLPI diagnostic function.\n"); - printf(" sfp_dom [PORT] : run sfp dom ONLPI diagnostic function.\n"); - printf(" sfp_ctrl [PORT] : run sfp control ONLPI diagnostic function.\n"); - - printf(" (Warning! Please be careful to write a value to SFP,\n"); - printf(" you should keep the original value to prevent lose it forever.)\n"); - printf(" sfprb [PORT] [ADDR] : read a byte from sfp transeciver.\n"); - printf(" sfprw [PORT] [ADDR] : read a word from sfp transeciver.\n"); - printf(" sfpwb [PORT] [ADDR] [VALUE] : write a byte to sfp transeciver.\n"); - printf(" sfpww [PORT] [ADDR] [VALUE] : write a word to sfp transeciver.\n"); - - printf(" [PORT] is the port index start from 0.\n"); - printf(" [ADDR] is the address to read/write.\n"); - printf(" [VALUE] is the value to read/write.\n"); - - - } - else if (argc > 0 && !strcmp(argv[0], "test")) //for RD debug test - { - diag_flag_set(DIAG_FLAG_ON); - onlp_ledi_mode_set(ONLP_LED_ID_CREATE(LED_SERVICE), ONLP_LED_MODE_BLUE_BLINKING); - } - else - {} - - return 0; -} - - - - - diff --git a/packages/platforms/lenovo/x86-64/ne2572/onlp/builds/x86_64_lenovo_ne2572/module/src/thermali.c b/packages/platforms/lenovo/x86-64/ne2572/onlp/builds/x86_64_lenovo_ne2572/module/src/thermali.c deleted file mode 100644 index 215ea6e1f..000000000 --- a/packages/platforms/lenovo/x86-64/ne2572/onlp/builds/x86_64_lenovo_ne2572/module/src/thermali.c +++ /dev/null @@ -1,148 +0,0 @@ -/************************************************************ - * - * - * Copyright 2014, 2015 Big Switch Networks, Inc. - * Copyright 2018 Alpha Networks Incorporation - * - * Licensed under the Eclipse Public License, Version 1.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.eclipse.org/legal/epl-v10.html - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT 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 LOCAL_DEBUG 0 - -#define THERMALI_LM75_HOT_SPOT_ADDR 0x4d /* NE2572 thermal addr */ -#define THERMALI_LM75_AMBIENT_ADDR 0x4c /* NE2572 thermal addr */ - -#define THERMALI_HOTSPOT_BUS_ID 3 -#define THERMALI_AMBIENT_BUS_ID 4 - -#define THERMALI_BUS_ID_OFFSET 2 - - -#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_ON_MAIN_BROAD_HOT_SPOT, /* The LM75 on Main Board for hot spot */ - THERMAL_2_ON_MAIN_BROAD_AMBIENT /* The LM75 on Main Board for ambient */ -}; - -static int thermali_current_temp_get(int id, char *data) -{ - int ret = 0; - if (id == THERMALI_HOTSPOT_BUS_ID) - { - ret = i2c_read_byte(id, THERMALI_LM75_HOT_SPOT_ADDR, 0x0, data); - if (ret < 0) - printf("I2C command 0x%X Read Fail, id=%d\n", THERMALI_LM75_HOT_SPOT_ADDR, id); - } - else if (id == THERMALI_AMBIENT_BUS_ID) - { - ret = i2c_read_byte(id, THERMALI_LM75_AMBIENT_ADDR, 0x0, data); - if (ret < 0) - printf("I2C command 0x%X Read Fail, id=%d\n", THERMALI_LM75_AMBIENT_ADDR, id); - } - - return ret; -} - - -/* Static values */ -static onlp_thermal_info_t linfo[] = { - { }, /* Not used */ - { { ONLP_THERMAL_ID_CREATE(THERMAL_1_ON_MAIN_BROAD_HOT_SPOT), "Chassis Thermal Sensor 1 (HOT SPOT)", 0}, - ONLP_THERMAL_STATUS_PRESENT, - ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS - }, - { { ONLP_THERMAL_ID_CREATE(THERMAL_2_ON_MAIN_BROAD_AMBIENT), "Chassis Thermal Sensor 2 (AMBIENT)", 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) -{ - DIAG_PRINT("%s", __FUNCTION__); - 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) -{ - DIAG_PRINT("%s, id=%d", __FUNCTION__, id); - int local_id, milli_unit = 1000; - char r_data[10] = {0}; - VALIDATE(id); - - local_id = ONLP_OID_ID_GET(id); - - if (LOCAL_DEBUG) - printf("\n[Debug][%s][%d][local_id: %d]", __FUNCTION__, __LINE__, local_id); - - /* Set the onlp_oid_hdr_t and capabilities */ - *info = linfo[local_id]; -#if 0 - if(local_id == THERMAL_CPU_CORE) { - int rv = onlp_file_read_int_max(&info->mcelsius, cpu_coretemp_files); - return rv; - } -#endif - if(thermali_current_temp_get(local_id + THERMALI_BUS_ID_OFFSET, r_data) < 0) - printf("[thermali]get current temperature fail!\n"); - - info->mcelsius = (*r_data) * milli_unit; - - if (LOCAL_DEBUG) - printf("\n[Debug][%s][%d][save data: %d]\n", __FUNCTION__, __LINE__, info->mcelsius); - - return ONLP_STATUS_OK; -} - - diff --git a/packages/platforms/lenovo/x86-64/ne2572/onlp/builds/x86_64_lenovo_ne2572/module/src/x86_64_lenovo_ne2572_config.c b/packages/platforms/lenovo/x86-64/ne2572/onlp/builds/x86_64_lenovo_ne2572/module/src/x86_64_lenovo_ne2572_config.c deleted file mode 100644 index 886501c4e..000000000 --- a/packages/platforms/lenovo/x86-64/ne2572/onlp/builds/x86_64_lenovo_ne2572/module/src/x86_64_lenovo_ne2572_config.c +++ /dev/null @@ -1,76 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#include - -/* */ -#define __x86_64_lenovo_ne2572_config_STRINGIFY_NAME(_x) #_x -#define __x86_64_lenovo_ne2572_config_STRINGIFY_VALUE(_x) __x86_64_lenovo_ne2572_config_STRINGIFY_NAME(_x) -x86_64_lenovo_ne2572_config_settings_t x86_64_lenovo_ne2572_config_settings[] = -{ -#ifdef X86_64_LENOVO_NE2572_CONFIG_INCLUDE_LOGGING - { __x86_64_lenovo_ne2572_config_STRINGIFY_NAME(X86_64_LENOVO_NE2572_CONFIG_INCLUDE_LOGGING), __x86_64_lenovo_ne2572_config_STRINGIFY_VALUE(X86_64_LENOVO_NE2572_CONFIG_INCLUDE_LOGGING) }, -#else -{ X86_64_LENOVO_NE2572_CONFIG_INCLUDE_LOGGING(__x86_64_lenovo_ne2572_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_LENOVO_NE2572_CONFIG_LOG_OPTIONS_DEFAULT - { __x86_64_lenovo_ne2572_config_STRINGIFY_NAME(X86_64_LENOVO_NE2572_CONFIG_LOG_OPTIONS_DEFAULT), __x86_64_lenovo_ne2572_config_STRINGIFY_VALUE(X86_64_LENOVO_NE2572_CONFIG_LOG_OPTIONS_DEFAULT) }, -#else -{ X86_64_LENOVO_NE2572_CONFIG_LOG_OPTIONS_DEFAULT(__x86_64_lenovo_ne2572_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_LENOVO_NE2572_CONFIG_LOG_BITS_DEFAULT - { __x86_64_lenovo_ne2572_config_STRINGIFY_NAME(X86_64_LENOVO_NE2572_CONFIG_LOG_BITS_DEFAULT), __x86_64_lenovo_ne2572_config_STRINGIFY_VALUE(X86_64_LENOVO_NE2572_CONFIG_LOG_BITS_DEFAULT) }, -#else -{ X86_64_LENOVO_NE2572_CONFIG_LOG_BITS_DEFAULT(__x86_64_lenovo_ne2572_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_LENOVO_NE2572_CONFIG_LOG_CUSTOM_BITS_DEFAULT - { __x86_64_lenovo_ne2572_config_STRINGIFY_NAME(X86_64_LENOVO_NE2572_CONFIG_LOG_CUSTOM_BITS_DEFAULT), __x86_64_lenovo_ne2572_config_STRINGIFY_VALUE(X86_64_LENOVO_NE2572_CONFIG_LOG_CUSTOM_BITS_DEFAULT) }, -#else -{ X86_64_LENOVO_NE2572_CONFIG_LOG_CUSTOM_BITS_DEFAULT(__x86_64_lenovo_ne2572_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_LENOVO_NE2572_CONFIG_PORTING_STDLIB - { __x86_64_lenovo_ne2572_config_STRINGIFY_NAME(X86_64_LENOVO_NE2572_CONFIG_PORTING_STDLIB), __x86_64_lenovo_ne2572_config_STRINGIFY_VALUE(X86_64_LENOVO_NE2572_CONFIG_PORTING_STDLIB) }, -#else -{ X86_64_LENOVO_NE2572_CONFIG_PORTING_STDLIB(__x86_64_lenovo_ne2572_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_LENOVO_NE2572_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS - { __x86_64_lenovo_ne2572_config_STRINGIFY_NAME(X86_64_LENOVO_NE2572_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS), __x86_64_lenovo_ne2572_config_STRINGIFY_VALUE(X86_64_LENOVO_NE2572_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS) }, -#else -{ X86_64_LENOVO_NE2572_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS(__x86_64_lenovo_ne2572_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_LENOVO_NE2572_CONFIG_INCLUDE_UCLI - { __x86_64_lenovo_ne2572_config_STRINGIFY_NAME(X86_64_LENOVO_NE2572_CONFIG_INCLUDE_UCLI), __x86_64_lenovo_ne2572_config_STRINGIFY_VALUE(X86_64_LENOVO_NE2572_CONFIG_INCLUDE_UCLI) }, -#else -{ X86_64_LENOVO_NE2572_CONFIG_INCLUDE_UCLI(__x86_64_lenovo_ne2572_config_STRINGIFY_NAME), "__undefined__" }, -#endif - { NULL, NULL } -}; -#undef __x86_64_lenovo_ne2572_config_STRINGIFY_VALUE -#undef __x86_64_lenovo_ne2572_config_STRINGIFY_NAME - -const char* -x86_64_lenovo_ne2572_config_lookup(const char* setting) -{ - int i; - for(i = 0; x86_64_lenovo_ne2572_config_settings[i].name; i++) { - if(!strcmp(x86_64_lenovo_ne2572_config_settings[i].name, setting)) { - return x86_64_lenovo_ne2572_config_settings[i].value; - } - } - return NULL; -} - -int -x86_64_lenovo_ne2572_config_show(struct aim_pvs_s* pvs) -{ - int i; - for(i = 0; x86_64_lenovo_ne2572_config_settings[i].name; i++) { - aim_printf(pvs, "%s = %s\n", x86_64_lenovo_ne2572_config_settings[i].name, x86_64_lenovo_ne2572_config_settings[i].value); - } - return i; -} - -/* */ - diff --git a/packages/platforms/lenovo/x86-64/ne2572/onlp/builds/x86_64_lenovo_ne2572/module/src/x86_64_lenovo_ne2572_enums.c b/packages/platforms/lenovo/x86-64/ne2572/onlp/builds/x86_64_lenovo_ne2572/module/src/x86_64_lenovo_ne2572_enums.c deleted file mode 100644 index 88dd9d822..000000000 --- a/packages/platforms/lenovo/x86-64/ne2572/onlp/builds/x86_64_lenovo_ne2572/module/src/x86_64_lenovo_ne2572_enums.c +++ /dev/null @@ -1,10 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#include - -/* <--auto.start.enum(ALL).source> */ -/* */ - diff --git a/packages/platforms/lenovo/x86-64/ne2572/onlp/builds/x86_64_lenovo_ne2572/module/src/x86_64_lenovo_ne2572_int.h b/packages/platforms/lenovo/x86-64/ne2572/onlp/builds/x86_64_lenovo_ne2572/module/src/x86_64_lenovo_ne2572_int.h deleted file mode 100644 index 5a86d0e53..000000000 --- a/packages/platforms/lenovo/x86-64/ne2572/onlp/builds/x86_64_lenovo_ne2572/module/src/x86_64_lenovo_ne2572_int.h +++ /dev/null @@ -1,12 +0,0 @@ -/**************************************************************************//** - * - * x86_64_lenovo_ne2572 Internal Header - * - *****************************************************************************/ -#ifndef __X86_64_LENOVO_NE2572_INT_H__ -#define __X86_64_LENOVO_NE2572_INT_H__ - -#include - - -#endif /* __X86_64_LENOVO_NE2572_INT_H__ */ diff --git a/packages/platforms/lenovo/x86-64/ne2572/onlp/builds/x86_64_lenovo_ne2572/module/src/x86_64_lenovo_ne2572_log.c b/packages/platforms/lenovo/x86-64/ne2572/onlp/builds/x86_64_lenovo_ne2572/module/src/x86_64_lenovo_ne2572_log.c deleted file mode 100644 index e87381b95..000000000 --- a/packages/platforms/lenovo/x86-64/ne2572/onlp/builds/x86_64_lenovo_ne2572/module/src/x86_64_lenovo_ne2572_log.c +++ /dev/null @@ -1,18 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#include - -#include "x86_64_lenovo_ne2572_log.h" -/* - * x86_64_lenovo_ne2572 log struct. - */ -AIM_LOG_STRUCT_DEFINE( - X86_64_LENOVO_NE2572_CONFIG_LOG_OPTIONS_DEFAULT, - X86_64_LENOVO_NE2572_CONFIG_LOG_BITS_DEFAULT, - NULL, /* Custom log map */ - X86_64_LENOVO_NE2572_CONFIG_LOG_CUSTOM_BITS_DEFAULT - ); - diff --git a/packages/platforms/lenovo/x86-64/ne2572/onlp/builds/x86_64_lenovo_ne2572/module/src/x86_64_lenovo_ne2572_log.h b/packages/platforms/lenovo/x86-64/ne2572/onlp/builds/x86_64_lenovo_ne2572/module/src/x86_64_lenovo_ne2572_log.h deleted file mode 100644 index ddd743f6e..000000000 --- a/packages/platforms/lenovo/x86-64/ne2572/onlp/builds/x86_64_lenovo_ne2572/module/src/x86_64_lenovo_ne2572_log.h +++ /dev/null @@ -1,12 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#ifndef __X86_64_LENOVO_NE2572_LOG_H__ -#define __X86_64_LENOVO_NE2572_LOG_H__ - -#define AIM_LOG_MODULE_NAME x86_64_lenovo_ne2572 -#include - -#endif /* __X86_64_LENOVO_NE2572_LOG_H__ */ diff --git a/packages/platforms/lenovo/x86-64/ne2572/onlp/builds/x86_64_lenovo_ne2572/module/src/x86_64_lenovo_ne2572_module.c b/packages/platforms/lenovo/x86-64/ne2572/onlp/builds/x86_64_lenovo_ne2572/module/src/x86_64_lenovo_ne2572_module.c deleted file mode 100644 index 94f3ad615..000000000 --- a/packages/platforms/lenovo/x86-64/ne2572/onlp/builds/x86_64_lenovo_ne2572/module/src/x86_64_lenovo_ne2572_module.c +++ /dev/null @@ -1,24 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#include - -#include "x86_64_lenovo_ne2572_log.h" - -static int -datatypes_init__(void) -{ -#define X86_64_LENOVO_NE2572_ENUMERATION_ENTRY(_enum_name, _desc) AIM_DATATYPE_MAP_REGISTER(_enum_name, _enum_name##_map, _desc, AIM_LOG_INTERNAL); -#include - return 0; -} - -void __x86_64_lenovo_ne2572_module_init__(void) -{ - AIM_LOG_STRUCT_REGISTER(); - datatypes_init__(); -} - -int __onlp_platform_version__ = 1; diff --git a/packages/platforms/lenovo/x86-64/ne2572/onlp/builds/x86_64_lenovo_ne2572/module/src/x86_64_lenovo_ne2572_ucli.c b/packages/platforms/lenovo/x86-64/ne2572/onlp/builds/x86_64_lenovo_ne2572/module/src/x86_64_lenovo_ne2572_ucli.c deleted file mode 100644 index 17e8e75bd..000000000 --- a/packages/platforms/lenovo/x86-64/ne2572/onlp/builds/x86_64_lenovo_ne2572/module/src/x86_64_lenovo_ne2572_ucli.c +++ /dev/null @@ -1,50 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#include - -#if X86_64_LENOVO_NE2572_CONFIG_INCLUDE_UCLI == 1 - -#include -#include -#include - -static ucli_status_t -x86_64_lenovo_ne2572_ucli_ucli__config__(ucli_context_t* uc) -{ - UCLI_HANDLER_MACRO_MODULE_CONFIG(x86_64_lenovo_ne2572) -} - -/* */ -/* */ - -static ucli_module_t -x86_64_lenovo_ne2572_ucli_module__ = - { - "x86_64_lenovo_ne2572_ucli", - NULL, - x86_64_lenovo_ne2572_ucli_ucli_handlers__, - NULL, - NULL, - }; - -ucli_node_t* -x86_64_lenovo_ne2572_ucli_node_create(void) -{ - ucli_node_t* n; - ucli_module_init(&x86_64_lenovo_ne2572_ucli_module__); - n = ucli_node_create("x86_64_lenovo_ne2572", NULL, &x86_64_lenovo_ne2572_ucli_module__); - ucli_node_subnode_add(n, ucli_module_log_node_create("x86_64_lenovo_ne2572")); - return n; -} - -#else -void* -x86_64_lenovo_ne2572_ucli_node_create(void) -{ - return NULL; -} -#endif - diff --git a/packages/platforms/lenovo/x86-64/ne2572/platform-config/Makefile b/packages/platforms/lenovo/x86-64/ne2572/platform-config/Makefile deleted file mode 100644 index 003238cf6..000000000 --- a/packages/platforms/lenovo/x86-64/ne2572/platform-config/Makefile +++ /dev/null @@ -1 +0,0 @@ -include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/lenovo/x86-64/ne2572/platform-config/r0/Makefile b/packages/platforms/lenovo/x86-64/ne2572/platform-config/r0/Makefile deleted file mode 100644 index 003238cf6..000000000 --- a/packages/platforms/lenovo/x86-64/ne2572/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/lenovo/x86-64/ne2572/platform-config/r0/PKG.yml b/packages/platforms/lenovo/x86-64/ne2572/platform-config/r0/PKG.yml deleted file mode 100644 index 85d7d8e25..000000000 --- a/packages/platforms/lenovo/x86-64/ne2572/platform-config/r0/PKG.yml +++ /dev/null @@ -1 +0,0 @@ -!include $ONL_TEMPLATES/platform-config-platform.yml ARCH=amd64 VENDOR=lenovo BASENAME=x86-64-lenovo-ne2572 REVISION=r0 diff --git a/packages/platforms/lenovo/x86-64/ne2572/platform-config/r0/src/lib/x86-64-lenovo-ne2572-r0.yml b/packages/platforms/lenovo/x86-64/ne2572/platform-config/r0/src/lib/x86-64-lenovo-ne2572-r0.yml deleted file mode 100644 index d9d9aeb69..000000000 --- a/packages/platforms/lenovo/x86-64/ne2572/platform-config/r0/src/lib/x86-64-lenovo-ne2572-r0.yml +++ /dev/null @@ -1,32 +0,0 @@ ---- - -###################################################################### -# -# platform-config for NE2572 -# -###################################################################### - -x86-64-lenovo-ne2572-r0: - - grub: - - serial: >- - --port=0x2f8 - --speed=115200 - --word=8 - --parity=no - --stop=1 - - kernel: - <<: *kernel-3-16 - - args: >- - nopat - i2c-ismt.enable=0 - console=ttyS1,115200n8 - - ##network - ## interfaces: - ## ma1: - ## name: ~ - ## syspath: pci0000:00/0000:00:14.0 diff --git a/packages/platforms/lenovo/x86-64/ne2572/platform-config/r0/src/lib/x86-64-lenovo-ne2572-r0.yml.bak b/packages/platforms/lenovo/x86-64/ne2572/platform-config/r0/src/lib/x86-64-lenovo-ne2572-r0.yml.bak deleted file mode 100644 index ec99a3cec..000000000 --- a/packages/platforms/lenovo/x86-64/ne2572/platform-config/r0/src/lib/x86-64-lenovo-ne2572-r0.yml.bak +++ /dev/null @@ -1,31 +0,0 @@ ---- - -###################################################################### -# -# platform-config for NE2572 -# -###################################################################### - -x86-64-lenovo-ne2572-r0: - - grub: - - serial: >- - --port=0x2f8 - --speed=115200 - --word=8 - --parity=no - --stop=1 - - kernel: - <<: *kernel-3-18 - - args: >- - nopat - console=ttyS1,115200n8 - - ##network - ## interfaces: - ## ma1: - ## name: ~ - ## syspath: pci0000:00/0000:00:14.0 diff --git a/packages/platforms/lenovo/x86-64/ne2572/platform-config/r0/src/python/x86_64_lenovo_ne2572_r0/__init__.py b/packages/platforms/lenovo/x86-64/ne2572/platform-config/r0/src/python/x86_64_lenovo_ne2572_r0/__init__.py deleted file mode 100644 index a0658c9c5..000000000 --- a/packages/platforms/lenovo/x86-64/ne2572/platform-config/r0/src/python/x86_64_lenovo_ne2572_r0/__init__.py +++ /dev/null @@ -1,223 +0,0 @@ -from onl.platform.base import * -from onl.platform.lenovo import * - -class OnlPlatform_x86_64_lenovo_ne2572_r0(OnlPlatformLenovo, - OnlPlatformPortConfig_32x100): - PLATFORM='x86-64-lenovo-ne2572-r0' - MODEL="NE2572" - SYS_OBJECT_ID=".6010.32" - - def baseconfig(self): - ########### initialize I2C bus 0 ########### - self.new_i2c_devices([ - - # ONIE EEPROM @MB - ('24c128', 0x56, 0), - - # PowerCPLD @MB - ('cpld', 0x5E, 0), - - # initialize multiplexer (PCA9548 #0) - ('pca9548', 0x70, 0), - - # FRU EEROM @MB - ('24c512', 0x51, 1), - - # CFG EEROM @MB - ('24c02', 0x51, 2), - - # TMP75#1 (Hot Spot) #use lm75 will cause device busy, use other name - ('thermal1', 0x4D, 3), - - # TMP75#0 (Ambient) #use lm75 will cause device busy, use other name - ('thermal2', 0x4C, 4), - - # initialize multiplexer (PCA9545 #0) - ('pca9545', 0x71, 5), - - # IDT 5P49V5923A (Clock generator) - (' ', 0x6A, 6), - - # initialize multiplexer (PCA9548 #1) - ('pca9548', 0x72, 7), - - # SystemCPLD @MB - ('cpld', 0x5F, 8), - - ]) - - ########### initialize I2C bus PCA9545 #0 ########### - self.new_i2c_devices([ - # MGMT EEROM - ('24c02', 0x51, 9), - # PSU #0 - ('psu', 0x51, 10), - ('psu', 0x59, 10), - # PSU #1 - ('psu', 0x51, 11), - ('psu', 0x59, 11), - # reserved - ]) - - ########### initialize I2C bus PCA9548 #1 ########### - self.new_i2c_devices([ - - # initialize multiplexer (PCA9548 #3) - ('pca9548', 0x74, 14), - - # initialize multiplexer (PCA9548 #4) - ('pca9548', 0x75, 14), - - # initialize multiplexer (PCA9548 #5) - ('pca9548', 0x76, 14), - - # initialize multiplexer (PCA9548 #6) - ('pca9548', 0x74, 16), - - # initialize multiplexer (PCA9548 #7) - ('pca9548', 0x75, 16), - - # initialize multiplexer (PCA9548 #8) - ('pca9548', 0x76, 16), - - # initialize multiplexer (PCA9548 #9) - ('pca9548', 0x74, 18), - - # IR3595 - ('ir3595', 0x09, 19), - - # initialize multiplexer (PCA9548 #2) - ('pca9548', 0x73, 20), - ]) - - ########### initialize I2C bus PCA9548 #3 @Fan Expander ########### - self.new_i2c_devices([ - - ('SFP', 0x50, 21), - ('SFP', 0x50, 22), - ('SFP', 0x50, 23), - ('SFP', 0x50, 24), - ('SFP', 0x50, 25), - ('SFP', 0x50, 26), - ('SFP', 0x50, 27), - ('SFP', 0x50, 28), - - ]) - - ########### initialize I2C bus PCA9548 #4 @Fan Expander ########### - self.new_i2c_devices([ - - ('SFP', 0x50, 29), - ('SFP', 0x50, 30), - ('SFP', 0x50, 31), - ('SFP', 0x50, 32), - ('SFP', 0x50, 33), - ('SFP', 0x50, 34), - ('SFP', 0x50, 35), - ('SFP', 0x50, 36), - - ]) - - ########### initialize I2C bus PCA9548 #5 @Fan Expander ########### - self.new_i2c_devices([ - - ('SFP', 0x50, 37), - ('SFP', 0x50, 38), - ('SFP', 0x50, 39), - ('SFP', 0x50, 40), - ('SFP', 0x50, 41), - ('SFP', 0x50, 42), - ('SFP', 0x50, 43), - ('SFP', 0x50, 44), - - ]) - - ########### initialize I2C bus PCA9548 #6 @Fan Expander ########### - self.new_i2c_devices([ - - ('SFP', 0x50, 45), - ('SFP', 0x50, 46), - ('SFP', 0x50, 47), - ('SFP', 0x50, 48), - ('SFP', 0x50, 49), - ('SFP', 0x50, 50), - ('SFP', 0x50, 51), - ('SFP', 0x50, 52), - - ]) - - ########### initialize I2C bus PCA9548 #7 @Fan Expander ########### - self.new_i2c_devices([ - - ('SFP', 0x50, 53), - ('SFP', 0x50, 54), - ('SFP', 0x50, 55), - ('SFP', 0x50, 56), - ('SFP', 0x50, 57), - ('SFP', 0x50, 58), - ('SFP', 0x50, 59), - ('SFP', 0x50, 60), - - ]) - - ########### initialize I2C bus PCA9548 #8 @Fan Expander ########### - self.new_i2c_devices([ - - ('SFP', 0x50, 61), - ('SFP', 0x50, 62), - ('SFP', 0x50, 63), - ('SFP', 0x50, 64), - ('SFP', 0x50, 65), - ('SFP', 0x50, 66), - ('SFP', 0x50, 67), - ('SFP', 0x50, 68), - - ]) - - ########### initialize I2C bus PCA9548 #9 @Fan Expander ########### - self.new_i2c_devices([ - - ('QSFP', 0x50, 69), - ('QSFP', 0x50, 70), - ('QSFP', 0x50, 71), - ('QSFP', 0x50, 72), - ('QSFP', 0x50, 73), - ('QSFP', 0x50, 74), - - ]) - - ########### initialize I2C bus PCA9548 #2 @Fan Expander ########### - self.new_i2c_devices([ - # Fan EEROM - ('24c02', 0x57, 77), - # Fan EEROM - ('24c02', 0x57, 78), - # Fan EEROM - ('24c02', 0x57, 79), - # Fan EEROM - ('24c02', 0x57, 80), - # Fan EEROM - ('24c02', 0x57, 81), - # Fan EEROM - ('24c02', 0x57, 82), - - ]) - - - self.new_i2c_devices([ - - (' ', 0x68, 69), - (' ', 0x68, 70), - (' ', 0x68, 71), - (' ', 0x68, 72), - (' ', 0x68, 73), - (' ', 0x68, 74), - - # Port CPLD0~2 - ('cpld', 0x5B, 13), - ('cpld', 0x5C, 15), - ('cpld', 0x5D, 17), - - ]) - - return True diff --git a/packages/platforms/mitac/Makefile b/packages/platforms/mitac/Makefile deleted file mode 100644 index 003238cf6..000000000 --- a/packages/platforms/mitac/Makefile +++ /dev/null @@ -1 +0,0 @@ -include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/mitac/vendor-config/Makefile b/packages/platforms/mitac/vendor-config/Makefile deleted file mode 100644 index 003238cf6..000000000 --- a/packages/platforms/mitac/vendor-config/Makefile +++ /dev/null @@ -1 +0,0 @@ -include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/mitac/vendor-config/PKG.yml b/packages/platforms/mitac/vendor-config/PKG.yml deleted file mode 100644 index 8e9bf0d89..000000000 --- a/packages/platforms/mitac/vendor-config/PKG.yml +++ /dev/null @@ -1 +0,0 @@ -!include $ONL_TEMPLATES/platform-config-vendor.yml VENDOR=mitac Vendor=MiTAC diff --git a/packages/platforms/mitac/vendor-config/src/python/mitac/__init__.py b/packages/platforms/mitac/vendor-config/src/python/mitac/__init__.py deleted file mode 100644 index 71ec42dc1..000000000 --- a/packages/platforms/mitac/vendor-config/src/python/mitac/__init__.py +++ /dev/null @@ -1,7 +0,0 @@ -#!/usr/bin/python - -from onl.platform.base import * - -class OnlPlatformMiTAC(OnlPlatformBase): - MANUFACTURER='MiTAC' - PRIVATE_ENTERPRISE_NUMBER=11183 diff --git a/packages/platforms/mitac/x86-64/Makefile b/packages/platforms/mitac/x86-64/Makefile deleted file mode 100644 index 003238cf6..000000000 --- a/packages/platforms/mitac/x86-64/Makefile +++ /dev/null @@ -1 +0,0 @@ -include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/mitac/x86-64/ly1200-b32h0-c3/.gitignore b/packages/platforms/mitac/x86-64/ly1200-b32h0-c3/.gitignore deleted file mode 100644 index 021862e4b..000000000 --- a/packages/platforms/mitac/x86-64/ly1200-b32h0-c3/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -*x86*64*mitac*ly1200*b32h0*c3*.mk -onlpdump.mk - diff --git a/packages/platforms/mitac/x86-64/ly1200-b32h0-c3/Makefile b/packages/platforms/mitac/x86-64/ly1200-b32h0-c3/Makefile deleted file mode 100644 index 003238cf6..000000000 --- a/packages/platforms/mitac/x86-64/ly1200-b32h0-c3/Makefile +++ /dev/null @@ -1 +0,0 @@ -include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/mitac/x86-64/ly1200-b32h0-c3/modules/Makefile b/packages/platforms/mitac/x86-64/ly1200-b32h0-c3/modules/Makefile deleted file mode 100644 index 003238cf6..000000000 --- a/packages/platforms/mitac/x86-64/ly1200-b32h0-c3/modules/Makefile +++ /dev/null @@ -1 +0,0 @@ -include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/mitac/x86-64/ly1200-b32h0-c3/modules/PKG.yml b/packages/platforms/mitac/x86-64/ly1200-b32h0-c3/modules/PKG.yml deleted file mode 100644 index d0f78fb07..000000000 --- a/packages/platforms/mitac/x86-64/ly1200-b32h0-c3/modules/PKG.yml +++ /dev/null @@ -1 +0,0 @@ -!include $ONL_TEMPLATES/platform-modules.yml VENDOR=mitac BASENAME=x86-64-mitac-ly1200-b32h0-c3 ARCH=amd64 KERNELS="onl-kernel-4.14-lts-x86-64-all:amd64" diff --git a/packages/platforms/mitac/x86-64/ly1200-b32h0-c3/modules/builds/.gitignore b/packages/platforms/mitac/x86-64/ly1200-b32h0-c3/modules/builds/.gitignore deleted file mode 100644 index f2516694c..000000000 --- a/packages/platforms/mitac/x86-64/ly1200-b32h0-c3/modules/builds/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -lib -Kbuild diff --git a/packages/platforms/mitac/x86-64/ly1200-b32h0-c3/modules/builds/Makefile b/packages/platforms/mitac/x86-64/ly1200-b32h0-c3/modules/builds/Makefile deleted file mode 100644 index 253a944dc..000000000 --- a/packages/platforms/mitac/x86-64/ly1200-b32h0-c3/modules/builds/Makefile +++ /dev/null @@ -1,11 +0,0 @@ -# Generate Kbuild dynamically -OBJLIST=$(addsuffix .o, $(basename $(wildcard *.c))) -$(shell rm -f Kbuild) -$(foreach f, $(OBJLIST), $(file >> Kbuild, obj-m += $(f))) -# Settings used by ONL -KERNELS := onl-kernel-4.14-lts-x86-64-all:amd64 -KMODULES := $(ONL)/packages/platforms/mitac/x86-64/ly1200-b32h0-c3/modules/builds -VENDOR := mitac -BASENAME := x86-64-mitac-ly1200-b32h0-c3 -ARCH := x86_64 -include $(ONL)/make/kmodule.mk diff --git a/packages/platforms/mitac/x86-64/ly1200-b32h0-c3/modules/builds/bms_i2c.h b/packages/platforms/mitac/x86-64/ly1200-b32h0-c3/modules/builds/bms_i2c.h deleted file mode 100644 index dd63607f3..000000000 --- a/packages/platforms/mitac/x86-64/ly1200-b32h0-c3/modules/builds/bms_i2c.h +++ /dev/null @@ -1,26 +0,0 @@ -#ifndef _BMS_I2C_H_ -#define _BMS_I2C_H_ - -const char *bms_i2c_adapter_names[] = { - "SMBus I801 adapter", - "SMBus iSMT adapter", -}; - -enum i2c_adapter_type { - I2C_ADAPTER_I801 = 0, - I2C_ADAPTER_ISMT, -}; - -enum bms_module_switch_bus { - I2C_STAGE1_MUX_CHAN0 = 0, - I2C_STAGE1_MUX_CHAN1, - I2C_STAGE1_MUX_CHAN2, - I2C_STAGE1_MUX_CHAN3, - I2C_STAGE1_MUX_CHAN4, - I2C_STAGE1_MUX_CHAN5, - I2C_STAGE1_MUX_CHAN6, - I2C_STAGE1_MUX_CHAN7, -}; - -#endif /* _BMS_I2C_H_ */ - diff --git a/packages/platforms/mitac/x86-64/ly1200-b32h0-c3/modules/builds/master_cpld_reg.h b/packages/platforms/mitac/x86-64/ly1200-b32h0-c3/modules/builds/master_cpld_reg.h deleted file mode 100644 index dfdc89dbe..000000000 --- a/packages/platforms/mitac/x86-64/ly1200-b32h0-c3/modules/builds/master_cpld_reg.h +++ /dev/null @@ -1,275 +0,0 @@ -#ifndef __MASTER_CPLD_REG -#define __MASTER_CPLD_REG - -static int master_cpld_raw_read(struct device *dev, struct device_attribute *attr, char *buf, - int reg_offset, int reg_width, int fld_shift, int fld_width, int fld_mask, char* reg_name); -static int master_cpld_raw_write(struct device *dev, struct device_attribute *attr, const char *buf, size_t count, - int reg_offset, int reg_width, int fld_shift, int fld_width, int fld_mask, char* reg_name); - -/* generic CPLD read function */ -#define FLD_RAW_RD_FUNC(_reg, _fld, _wdh) static ssize_t \ -master_cpld_##_fld##_raw_read(struct device *dev, struct device_attribute *attr, char *buf) { \ - return master_cpld_raw_read(dev, attr, buf, _reg##_offset, _reg##_width, _fld##_shift, _fld##_width, _fld##_mask, #_reg); \ -} - -/* generic CPLD write function */ -#define FLD_RAW_WR_FUNC(_reg, _fld, _wdh) static ssize_t \ -master_cpld_##_fld##_raw_write(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { \ - return master_cpld_raw_write(dev, attr, buf, count, _reg##_offset, _reg##_width, _fld##_shift, _fld##_width, _fld##_mask, #_reg); \ -} - -/* CPLD register definition macros */ -#define REG_DEF(_reg, _off, _wdh) \ -static unsigned int _reg##_offset = (unsigned int)(_off); \ -static unsigned int _reg##_width = (unsigned int)(_wdh); - -/* CPLD register field definition macros, with generic read/write function */ -#define FLD_RAW_RO_DEF(_reg, _fld, _sft, _wdh) \ -static unsigned int _fld##_shift = (unsigned int)(_sft); \ -static unsigned int _fld##_width = (unsigned int)(_wdh); \ -static unsigned int _fld##_mask = ((((unsigned int)1) << (_wdh)) - 1); \ -FLD_RAW_RD_FUNC(_reg, _fld, _wdh) - -#define FLD_RAW_RW_DEF(_reg, _fld, _sft, _wdh) \ -static unsigned int _fld##_shift = (unsigned int)(_sft); \ -static unsigned int _fld##_width = (unsigned int)(_wdh); \ -static unsigned int _fld##_mask = ((((unsigned int)1) << (_wdh)) - 1); \ -FLD_RAW_RD_FUNC(_reg, _fld, _wdh) FLD_RAW_WR_FUNC(_reg, _fld, _wdh) - -/* declare master CPLD registers */ -/* register name offset width */ -/* --------------------------------------- ------- ----- */ -REG_DEF( mstr_cpld_rev, 0x00, 8) -REG_DEF( mstr_cpld_gpr, 0x01, 8) -REG_DEF( mb_brd_rev_type, 0x02, 8) -REG_DEF( mstr_srr, 0x03, 8) -REG_DEF( eeprom_wp, 0x04, 8) -REG_DEF( mstr_irq, 0x05, 8) -REG_DEF( system_led, 0x06, 8) -REG_DEF( fan_tray_3_1_led, 0x07, 8) -REG_DEF( fan_tray_6_4_led, 0x08, 8) -REG_DEF( fan_tray_status, 0x09, 8) -REG_DEF( fan_type_status, 0x0A, 8) -REG_DEF( psu_en_status, 0x0B, 8) -REG_DEF( mb_pwr_en_status, 0x0C, 8) -REG_DEF( mb_pwr_status, 0x0D, 8) - -REG_DEF( zqsfp28_present_8_1_status, 0x10, 8) -REG_DEF( zqsfp28_present_16_9_status, 0x11, 8) -REG_DEF( zqsfp28_rst_8_1, 0x12, 8) -REG_DEF( zqsfp28_rst_16_9, 0x13, 8) -REG_DEF( zqsfp28_modsel_8_1, 0x14, 8) -REG_DEF( zqsfp28_modsel_16_9, 0x15, 8) -REG_DEF( zqsfp28_lpmode_8_1, 0x16, 8) -REG_DEF( zqsfp28_lpmode_16_9, 0x17, 8) -REG_DEF( zqsfp28_irq_8_1_status, 0x18, 8) -REG_DEF( zqsfp28_irq_16_9_status, 0x19, 8) -REG_DEF( zqsfp28_irq_msk_8_1_status, 0x1A, 8) -REG_DEF( zqsfp28_irq_msk_16_9_status, 0x1B, 8) - - -/* declare master CPLD register's fields */ -/* register name field name shift width */ -/* ---------------------- ---------------- ------ ----- */ -FLD_RAW_RO_DEF( mstr_cpld_rev, mjr_rev, 4, 4) -FLD_RAW_RO_DEF( mstr_cpld_rev, mnr_rev, 0, 4) - -FLD_RAW_RW_DEF( mstr_cpld_gpr, scrtch_reg, 0, 8) - -FLD_RAW_RO_DEF( mb_brd_rev_type, brd_rev, 4, 4) -FLD_RAW_RO_DEF( mb_brd_rev_type, brd_type, 0, 4) - -FLD_RAW_RW_DEF( mstr_srr, mb_rst, 2, 1) -FLD_RAW_RW_DEF( mstr_srr, npu_rst, 1, 1) -FLD_RAW_RW_DEF( mstr_srr, mgmt_phy_rst, 0, 1) - -FLD_RAW_RW_DEF( eeprom_wp, mb_eeprom_wp, 2, 1) -FLD_RAW_RW_DEF( eeprom_wp, cpld_spi_wp, 1, 1) -FLD_RAW_RW_DEF( eeprom_wp, fan_eeprom_wp, 0, 1) - -FLD_RAW_RW_DEF( mstr_irq, ps2_int_msk, 7, 1) -FLD_RAW_RW_DEF( mstr_irq, ps1_int_msk, 6, 1) -FLD_RAW_RW_DEF( mstr_irq, usb_fault_msk, 5, 1) -FLD_RAW_RW_DEF( mstr_irq, pcie_int_msk, 4, 1) -FLD_RAW_RW_DEF( mstr_irq, fan_alert_int_msk, 3, 1) -FLD_RAW_RO_DEF( mstr_irq, usb_fault, 2, 1) -FLD_RAW_RO_DEF( mstr_irq, pcie_int, 1, 1) -FLD_RAW_RO_DEF( mstr_irq, fan_alert_int, 0, 1) - -FLD_RAW_RW_DEF( system_led, system_led_fld, 6, 2) -FLD_RAW_RW_DEF( system_led, power_led, 4, 2) -FLD_RAW_RW_DEF( system_led, fan_led, 2, 2) -FLD_RAW_RW_DEF( system_led, locate_led, 1, 1) - -FLD_RAW_RW_DEF( fan_tray_3_1_led, led_test, 6, 2) -FLD_RAW_RW_DEF( fan_tray_3_1_led, fan_tray3_led, 4, 2) -FLD_RAW_RW_DEF( fan_tray_3_1_led, fan_tray2_led, 2, 2) -FLD_RAW_RW_DEF( fan_tray_3_1_led, fan_tray1_led, 0, 2) - -FLD_RAW_RW_DEF( fan_tray_6_4_led, fan_tray6_led, 4, 2) -FLD_RAW_RW_DEF( fan_tray_6_4_led, fan_tray5_led, 2, 2) -FLD_RAW_RW_DEF( fan_tray_6_4_led, fan_tray4_led, 0, 2) - -FLD_RAW_RO_DEF( fan_tray_status, fan_tray6_present, 5, 1) -FLD_RAW_RO_DEF( fan_tray_status, fan_tray5_present, 4, 1) -FLD_RAW_RO_DEF( fan_tray_status, fan_tray4_present, 3, 1) -FLD_RAW_RO_DEF( fan_tray_status, fan_tray3_present, 2, 1) -FLD_RAW_RO_DEF( fan_tray_status, fan_tray2_present, 1, 1) -FLD_RAW_RO_DEF( fan_tray_status, fan_tray1_present, 0, 1) - -FLD_RAW_RO_DEF( fan_type_status, fan_type6, 5, 1) -FLD_RAW_RO_DEF( fan_type_status, fan_type5, 4, 1) -FLD_RAW_RO_DEF( fan_type_status, fan_type4, 3, 1) -FLD_RAW_RO_DEF( fan_type_status, fan_type3, 2, 1) -FLD_RAW_RO_DEF( fan_type_status, fan_type2, 1, 1) -FLD_RAW_RO_DEF( fan_type_status, fan_type1, 0, 1) - -FLD_RAW_RO_DEF( psu_en_status, ps1_ps, 7, 1) -FLD_RAW_RO_DEF( psu_en_status, ps1_pg, 6, 1) -FLD_RAW_RO_DEF( psu_en_status, ps1_int, 5, 1) -FLD_RAW_RW_DEF( psu_en_status, ps1_on, 4, 1) -FLD_RAW_RO_DEF( psu_en_status, ps2_ps, 3, 1) -FLD_RAW_RO_DEF( psu_en_status, ps2_pg, 2, 1) -FLD_RAW_RO_DEF( psu_en_status, ps2_int, 1, 1) -FLD_RAW_RW_DEF( psu_en_status, ps2_on, 0, 1) - -FLD_RAW_RW_DEF( mb_pwr_en_status, usb1_vbus_en, 7, 1) -FLD_RAW_RO_DEF( mb_pwr_en_status, v5p0_en, 5, 1) -FLD_RAW_RO_DEF( mb_pwr_en_status, v3p3_en, 4, 1) -FLD_RAW_RO_DEF( mb_pwr_en_status, vcc_1v8_en, 3, 1) -FLD_RAW_RO_DEF( mb_pwr_en_status, mac_avs1v_en, 2, 1) -FLD_RAW_RO_DEF( mb_pwr_en_status, mac1v_en, 1, 1) -FLD_RAW_RO_DEF( mb_pwr_en_status, vcc_1v25_en, 0, 1) - -FLD_RAW_RO_DEF( mb_pwr_status, vcc_3p3_cpld, 6, 1) -FLD_RAW_RO_DEF( mb_pwr_status, vcc5v_pg, 5, 1) -FLD_RAW_RO_DEF( mb_pwr_status, vcc3v3_pg, 4, 1) -FLD_RAW_RO_DEF( mb_pwr_status, vcc_1v8_pg, 3, 1) -FLD_RAW_RO_DEF( mb_pwr_status, mac_avs1v_pg, 2, 1) -FLD_RAW_RO_DEF( mb_pwr_status, mac1v_pg, 1, 1) -FLD_RAW_RO_DEF( mb_pwr_status, vcc_1v25_pg, 0, 1) - -FLD_RAW_RO_DEF( zqsfp28_present_8_1_status, port8_present, 7, 1) -FLD_RAW_RO_DEF( zqsfp28_present_8_1_status, port7_present, 6, 1) -FLD_RAW_RO_DEF( zqsfp28_present_8_1_status, port6_present, 5, 1) -FLD_RAW_RO_DEF( zqsfp28_present_8_1_status, port5_present, 4, 1) -FLD_RAW_RO_DEF( zqsfp28_present_8_1_status, port4_present, 3, 1) -FLD_RAW_RO_DEF( zqsfp28_present_8_1_status, port3_present, 2, 1) -FLD_RAW_RO_DEF( zqsfp28_present_8_1_status, port2_present, 1, 1) -FLD_RAW_RO_DEF( zqsfp28_present_8_1_status, port1_present, 0, 1) - -FLD_RAW_RO_DEF( zqsfp28_present_16_9_status,port16_present, 7, 1) -FLD_RAW_RO_DEF( zqsfp28_present_16_9_status,port15_present, 6, 1) -FLD_RAW_RO_DEF( zqsfp28_present_16_9_status,port14_present, 5, 1) -FLD_RAW_RO_DEF( zqsfp28_present_16_9_status,port13_present, 4, 1) -FLD_RAW_RO_DEF( zqsfp28_present_16_9_status,port12_present, 3, 1) -FLD_RAW_RO_DEF( zqsfp28_present_16_9_status,port11_present, 2, 1) -FLD_RAW_RO_DEF( zqsfp28_present_16_9_status,port10_present, 1, 1) -FLD_RAW_RO_DEF( zqsfp28_present_16_9_status,port9_present, 0, 1) - -FLD_RAW_RW_DEF( zqsfp28_rst_8_1, port8_rst, 7, 1) -FLD_RAW_RW_DEF( zqsfp28_rst_8_1, port7_rst, 6, 1) -FLD_RAW_RW_DEF( zqsfp28_rst_8_1, port6_rst, 5, 1) -FLD_RAW_RW_DEF( zqsfp28_rst_8_1, port5_rst, 4, 1) -FLD_RAW_RW_DEF( zqsfp28_rst_8_1, port4_rst, 3, 1) -FLD_RAW_RW_DEF( zqsfp28_rst_8_1, port3_rst, 2, 1) -FLD_RAW_RW_DEF( zqsfp28_rst_8_1, port2_rst, 1, 1) -FLD_RAW_RW_DEF( zqsfp28_rst_8_1, port1_rst, 0, 1) - -FLD_RAW_RW_DEF( zqsfp28_rst_16_9, port16_rst, 7, 1) -FLD_RAW_RW_DEF( zqsfp28_rst_16_9, port15_rst, 6, 1) -FLD_RAW_RW_DEF( zqsfp28_rst_16_9, port14_rst, 5, 1) -FLD_RAW_RW_DEF( zqsfp28_rst_16_9, port13_rst, 4, 1) -FLD_RAW_RW_DEF( zqsfp28_rst_16_9, port12_rst, 3, 1) -FLD_RAW_RW_DEF( zqsfp28_rst_16_9, port11_rst, 2, 1) -FLD_RAW_RW_DEF( zqsfp28_rst_16_9, port10_rst, 1, 1) -FLD_RAW_RW_DEF( zqsfp28_rst_16_9, port9_rst, 0, 1) - -FLD_RAW_RW_DEF( zqsfp28_modsel_8_1, port8_modsel, 7, 1) -FLD_RAW_RW_DEF( zqsfp28_modsel_8_1, port7_modsel, 6, 1) -FLD_RAW_RW_DEF( zqsfp28_modsel_8_1, port6_modsel, 5, 1) -FLD_RAW_RW_DEF( zqsfp28_modsel_8_1, port5_modsel, 4, 1) -FLD_RAW_RW_DEF( zqsfp28_modsel_8_1, port4_modsel, 3, 1) -FLD_RAW_RW_DEF( zqsfp28_modsel_8_1, port3_modsel, 2, 1) -FLD_RAW_RW_DEF( zqsfp28_modsel_8_1, port2_modsel, 1, 1) -FLD_RAW_RW_DEF( zqsfp28_modsel_8_1, port1_modsel, 0, 1) - -FLD_RAW_RW_DEF( zqsfp28_modsel_16_9, port16_modsel, 7, 1) -FLD_RAW_RW_DEF( zqsfp28_modsel_16_9, port15_modsel, 6, 1) -FLD_RAW_RW_DEF( zqsfp28_modsel_16_9, port14_modsel, 5, 1) -FLD_RAW_RW_DEF( zqsfp28_modsel_16_9, port13_modsel, 4, 1) -FLD_RAW_RW_DEF( zqsfp28_modsel_16_9, port12_modsel, 3, 1) -FLD_RAW_RW_DEF( zqsfp28_modsel_16_9, port11_modsel, 2, 1) -FLD_RAW_RW_DEF( zqsfp28_modsel_16_9, port10_modsel, 1, 1) -FLD_RAW_RW_DEF( zqsfp28_modsel_16_9, port9_modsel, 0, 1) - -FLD_RAW_RW_DEF( zqsfp28_lpmode_8_1, port8_lpmode, 7, 1) -FLD_RAW_RW_DEF( zqsfp28_lpmode_8_1, port7_lpmode, 6, 1) -FLD_RAW_RW_DEF( zqsfp28_lpmode_8_1, port6_lpmode, 5, 1) -FLD_RAW_RW_DEF( zqsfp28_lpmode_8_1, port5_lpmode, 4, 1) -FLD_RAW_RW_DEF( zqsfp28_lpmode_8_1, port4_lpmode, 3, 1) -FLD_RAW_RW_DEF( zqsfp28_lpmode_8_1, port3_lpmode, 2, 1) -FLD_RAW_RW_DEF( zqsfp28_lpmode_8_1, port2_lpmode, 1, 1) -FLD_RAW_RW_DEF( zqsfp28_lpmode_8_1, port1_lpmode, 0, 1) - -FLD_RAW_RW_DEF( zqsfp28_lpmode_16_9, port16_lpmode, 7, 1) -FLD_RAW_RW_DEF( zqsfp28_lpmode_16_9, port15_lpmode, 6, 1) -FLD_RAW_RW_DEF( zqsfp28_lpmode_16_9, port14_lpmode, 5, 1) -FLD_RAW_RW_DEF( zqsfp28_lpmode_16_9, port13_lpmode, 4, 1) -FLD_RAW_RW_DEF( zqsfp28_lpmode_16_9, port12_lpmode, 3, 1) -FLD_RAW_RW_DEF( zqsfp28_lpmode_16_9, port11_lpmode, 2, 1) -FLD_RAW_RW_DEF( zqsfp28_lpmode_16_9, port10_lpmode, 1, 1) -FLD_RAW_RW_DEF( zqsfp28_lpmode_16_9, port9_lpmode, 0, 1) - -FLD_RAW_RO_DEF( zqsfp28_irq_8_1_status, port8_irq_status, 7, 1) -FLD_RAW_RO_DEF( zqsfp28_irq_8_1_status, port7_irq_status, 6, 1) -FLD_RAW_RO_DEF( zqsfp28_irq_8_1_status, port6_irq_status, 5, 1) -FLD_RAW_RO_DEF( zqsfp28_irq_8_1_status, port5_irq_status, 4, 1) -FLD_RAW_RO_DEF( zqsfp28_irq_8_1_status, port4_irq_status, 3, 1) -FLD_RAW_RO_DEF( zqsfp28_irq_8_1_status, port3_irq_status, 2, 1) -FLD_RAW_RO_DEF( zqsfp28_irq_8_1_status, port2_irq_status, 1, 1) -FLD_RAW_RO_DEF( zqsfp28_irq_8_1_status, port1_irq_status, 0, 1) - -FLD_RAW_RO_DEF( zqsfp28_irq_16_9_status, port16_irq_status, 7, 1) -FLD_RAW_RO_DEF( zqsfp28_irq_16_9_status, port15_irq_status, 6, 1) -FLD_RAW_RO_DEF( zqsfp28_irq_16_9_status, port14_irq_status, 5, 1) -FLD_RAW_RO_DEF( zqsfp28_irq_16_9_status, port13_irq_status, 4, 1) -FLD_RAW_RO_DEF( zqsfp28_irq_16_9_status, port12_irq_status, 3, 1) -FLD_RAW_RO_DEF( zqsfp28_irq_16_9_status, port11_irq_status, 2, 1) -FLD_RAW_RO_DEF( zqsfp28_irq_16_9_status, port10_irq_status, 1, 1) -FLD_RAW_RO_DEF( zqsfp28_irq_16_9_status, port9_irq_status, 0, 1) - -FLD_RAW_RW_DEF( zqsfp28_irq_msk_8_1_status, port8_irq_msk, 7, 1) -FLD_RAW_RW_DEF( zqsfp28_irq_msk_8_1_status, port7_irq_msk, 6, 1) -FLD_RAW_RW_DEF( zqsfp28_irq_msk_8_1_status, port6_irq_msk, 5, 1) -FLD_RAW_RW_DEF( zqsfp28_irq_msk_8_1_status, port5_irq_msk, 4, 1) -FLD_RAW_RW_DEF( zqsfp28_irq_msk_8_1_status, port4_irq_msk, 3, 1) -FLD_RAW_RW_DEF( zqsfp28_irq_msk_8_1_status, port3_irq_msk, 2, 1) -FLD_RAW_RW_DEF( zqsfp28_irq_msk_8_1_status, port2_irq_msk, 1, 1) -FLD_RAW_RW_DEF( zqsfp28_irq_msk_8_1_status, port1_irq_msk, 0, 1) - -FLD_RAW_RW_DEF( zqsfp28_irq_msk_16_9_status,port16_irq_msk, 7, 1) -FLD_RAW_RW_DEF( zqsfp28_irq_msk_16_9_status,port15_irq_msk, 6, 1) -FLD_RAW_RW_DEF( zqsfp28_irq_msk_16_9_status,port14_irq_msk, 5, 1) -FLD_RAW_RW_DEF( zqsfp28_irq_msk_16_9_status,port13_irq_msk, 4, 1) -FLD_RAW_RW_DEF( zqsfp28_irq_msk_16_9_status,port12_irq_msk, 3, 1) -FLD_RAW_RW_DEF( zqsfp28_irq_msk_16_9_status,port11_irq_msk, 2, 1) -FLD_RAW_RW_DEF( zqsfp28_irq_msk_16_9_status,port10_irq_msk, 1, 1) -FLD_RAW_RW_DEF( zqsfp28_irq_msk_16_9_status,port9_irq_msk, 0, 1) - -FLD_RAW_RO_DEF( zqsfp28_present_8_1_status, port_1_8_present, 0, 8) -FLD_RAW_RO_DEF( zqsfp28_present_16_9_status,port_9_16_present, 0, 8) -FLD_RAW_RW_DEF( zqsfp28_rst_8_1, port_1_8_rst, 0, 8) -FLD_RAW_RW_DEF( zqsfp28_rst_16_9, port_9_16_rst, 0, 8) -FLD_RAW_RW_DEF( zqsfp28_modsel_8_1, port_1_8_modsel, 0, 8) -FLD_RAW_RW_DEF( zqsfp28_modsel_16_9, port_9_16_modsel, 0, 8) -FLD_RAW_RO_DEF( zqsfp28_irq_8_1_status, port_1_8_irq_status, 0, 8) -FLD_RAW_RO_DEF( zqsfp28_irq_16_9_status, port_9_16_irq_status,0, 8) -FLD_RAW_RW_DEF( zqsfp28_irq_msk_8_1_status, port_1_8_irq_msk, 0, 8) -FLD_RAW_RW_DEF( zqsfp28_irq_msk_16_9_status,port_9_16_irq_msk, 0, 8) -FLD_RAW_RW_DEF( zqsfp28_lpmode_8_1, port_1_8_lpmode, 0, 8) -FLD_RAW_RW_DEF( zqsfp28_lpmode_16_9, port_9_16_lpmode, 0, 8) - -FLD_RAW_RO_DEF( fan_tray_status, fan_tray1_6_present, 0, 8) -FLD_RAW_RO_DEF( psu_en_status, psu_en_status_fld, 0, 8) -#endif /* __MASTER_CPLD_REG */ diff --git a/packages/platforms/mitac/x86-64/ly1200-b32h0-c3/modules/builds/master_cpld_sysfs.h b/packages/platforms/mitac/x86-64/ly1200-b32h0-c3/modules/builds/master_cpld_sysfs.h deleted file mode 100644 index cc256db58..000000000 --- a/packages/platforms/mitac/x86-64/ly1200-b32h0-c3/modules/builds/master_cpld_sysfs.h +++ /dev/null @@ -1,226 +0,0 @@ -#ifndef __MASTER_CPLD_SYSFS -#define __MASTER_CPLD_SYSFS - -/* generic CPLD sysfs file definition macros */ -#define SYSFS_RAW_RO_ATTR_DEF(field) \ -struct device_attribute field \ - = __ATTR(field, S_IRUGO, master_cpld_##field##_raw_read, NULL); - -#define SYSFS_RAW_RW_ATTR_DEF(field) \ -struct device_attribute field \ - = __ATTR(field, S_IRUGO | S_IWUSR | S_IWGRP, master_cpld_##field##_raw_read, master_cpld_##field##_raw_write); - -#define SYSFS_MISC_RO_ATTR_DEF(field, _read) \ -struct device_attribute field \ - = __ATTR(field, S_IRUGO, _read, NULL); - -#define SYSFS_MISC_RW_ATTR_DEF(field, _read, _write) \ -struct device_attribute field \ - = __ATTR(field, S_IRUGO | S_IWUSR | S_IWGRP, _read, _write); - -#define SYSFS_ATTR_PTR(field) \ -&field.attr - -/* declare master CPLD file system */ -SYSFS_RAW_RO_ATTR_DEF(mjr_rev) -SYSFS_RAW_RO_ATTR_DEF(mnr_rev) - -SYSFS_RAW_RW_ATTR_DEF(scrtch_reg) - -SYSFS_RAW_RO_ATTR_DEF(brd_rev) -SYSFS_RAW_RO_ATTR_DEF(brd_type) - -SYSFS_RAW_RW_ATTR_DEF(mb_rst) -SYSFS_RAW_RW_ATTR_DEF(npu_rst) -SYSFS_RAW_RW_ATTR_DEF(mgmt_phy_rst) - -SYSFS_RAW_RW_ATTR_DEF(mb_eeprom_wp) -SYSFS_RAW_RW_ATTR_DEF(cpld_spi_wp) -SYSFS_RAW_RW_ATTR_DEF(fan_eeprom_wp) - -SYSFS_RAW_RW_ATTR_DEF(ps2_int_msk) -SYSFS_RAW_RW_ATTR_DEF(ps1_int_msk) -SYSFS_RAW_RW_ATTR_DEF(usb_fault_msk) -SYSFS_RAW_RW_ATTR_DEF(pcie_int_msk) -SYSFS_RAW_RW_ATTR_DEF(fan_alert_int_msk) -SYSFS_RAW_RO_ATTR_DEF(usb_fault) -SYSFS_RAW_RO_ATTR_DEF(pcie_int) -SYSFS_RAW_RO_ATTR_DEF(fan_alert_int) - -SYSFS_RAW_RW_ATTR_DEF(system_led_fld) -SYSFS_RAW_RW_ATTR_DEF(power_led) -SYSFS_RAW_RW_ATTR_DEF(fan_led) -SYSFS_RAW_RW_ATTR_DEF(locate_led) - -SYSFS_RAW_RW_ATTR_DEF(led_test) -SYSFS_RAW_RW_ATTR_DEF(fan_tray3_led) -SYSFS_RAW_RW_ATTR_DEF(fan_tray2_led) -SYSFS_RAW_RW_ATTR_DEF(fan_tray1_led) - -SYSFS_RAW_RW_ATTR_DEF(fan_tray6_led) -SYSFS_RAW_RW_ATTR_DEF(fan_tray5_led) -SYSFS_RAW_RW_ATTR_DEF(fan_tray4_led) - -SYSFS_RAW_RO_ATTR_DEF(fan_tray6_present) -SYSFS_RAW_RO_ATTR_DEF(fan_tray5_present) -SYSFS_RAW_RO_ATTR_DEF(fan_tray4_present) -SYSFS_RAW_RO_ATTR_DEF(fan_tray3_present) -SYSFS_RAW_RO_ATTR_DEF(fan_tray2_present) -SYSFS_RAW_RO_ATTR_DEF(fan_tray1_present) - -SYSFS_RAW_RO_ATTR_DEF(fan_type6) -SYSFS_RAW_RO_ATTR_DEF(fan_type5) -SYSFS_RAW_RO_ATTR_DEF(fan_type4) -SYSFS_RAW_RO_ATTR_DEF(fan_type3) -SYSFS_RAW_RO_ATTR_DEF(fan_type2) -SYSFS_RAW_RO_ATTR_DEF(fan_type1) - -SYSFS_RAW_RO_ATTR_DEF(ps1_ps) -SYSFS_RAW_RO_ATTR_DEF(ps1_pg) -SYSFS_RAW_RO_ATTR_DEF(ps1_int) -SYSFS_RAW_RW_ATTR_DEF(ps1_on) -SYSFS_RAW_RO_ATTR_DEF(ps2_ps) -SYSFS_RAW_RO_ATTR_DEF(ps2_pg) -SYSFS_RAW_RO_ATTR_DEF(ps2_int) -SYSFS_RAW_RW_ATTR_DEF(ps2_on) - -SYSFS_RAW_RW_ATTR_DEF(usb1_vbus_en) -SYSFS_RAW_RO_ATTR_DEF(v5p0_en) -SYSFS_RAW_RO_ATTR_DEF(v3p3_en) -SYSFS_RAW_RO_ATTR_DEF(vcc_1v8_en) -SYSFS_RAW_RO_ATTR_DEF(mac_avs1v_en) -SYSFS_RAW_RO_ATTR_DEF(mac1v_en) -SYSFS_RAW_RO_ATTR_DEF(vcc_1v25_en) - -SYSFS_RAW_RO_ATTR_DEF(vcc_3p3_cpld) -SYSFS_RAW_RO_ATTR_DEF(vcc5v_pg) -SYSFS_RAW_RO_ATTR_DEF(vcc3v3_pg) -SYSFS_RAW_RO_ATTR_DEF(vcc_1v8_pg) -SYSFS_RAW_RO_ATTR_DEF(mac_avs1v_pg) -SYSFS_RAW_RO_ATTR_DEF(mac1v_pg) -SYSFS_RAW_RO_ATTR_DEF(vcc_1v25_pg) - -SYSFS_RAW_RO_ATTR_DEF(port8_present) -SYSFS_RAW_RO_ATTR_DEF(port7_present) -SYSFS_RAW_RO_ATTR_DEF(port6_present) -SYSFS_RAW_RO_ATTR_DEF(port5_present) -SYSFS_RAW_RO_ATTR_DEF(port4_present) -SYSFS_RAW_RO_ATTR_DEF(port3_present) -SYSFS_RAW_RO_ATTR_DEF(port2_present) -SYSFS_RAW_RO_ATTR_DEF(port1_present) - -SYSFS_RAW_RO_ATTR_DEF(port16_present) -SYSFS_RAW_RO_ATTR_DEF(port15_present) -SYSFS_RAW_RO_ATTR_DEF(port14_present) -SYSFS_RAW_RO_ATTR_DEF(port13_present) -SYSFS_RAW_RO_ATTR_DEF(port12_present) -SYSFS_RAW_RO_ATTR_DEF(port11_present) -SYSFS_RAW_RO_ATTR_DEF(port10_present) -SYSFS_RAW_RO_ATTR_DEF(port9_present) - -SYSFS_RAW_RW_ATTR_DEF(port8_rst) -SYSFS_RAW_RW_ATTR_DEF(port7_rst) -SYSFS_RAW_RW_ATTR_DEF(port6_rst) -SYSFS_RAW_RW_ATTR_DEF(port5_rst) -SYSFS_RAW_RW_ATTR_DEF(port4_rst) -SYSFS_RAW_RW_ATTR_DEF(port3_rst) -SYSFS_RAW_RW_ATTR_DEF(port2_rst) -SYSFS_RAW_RW_ATTR_DEF(port1_rst) - -SYSFS_RAW_RW_ATTR_DEF(port16_rst) -SYSFS_RAW_RW_ATTR_DEF(port15_rst) -SYSFS_RAW_RW_ATTR_DEF(port14_rst) -SYSFS_RAW_RW_ATTR_DEF(port13_rst) -SYSFS_RAW_RW_ATTR_DEF(port12_rst) -SYSFS_RAW_RW_ATTR_DEF(port11_rst) -SYSFS_RAW_RW_ATTR_DEF(port10_rst) -SYSFS_RAW_RW_ATTR_DEF(port9_rst) - -SYSFS_RAW_RW_ATTR_DEF(port8_modsel) -SYSFS_RAW_RW_ATTR_DEF(port7_modsel) -SYSFS_RAW_RW_ATTR_DEF(port6_modsel) -SYSFS_RAW_RW_ATTR_DEF(port5_modsel) -SYSFS_RAW_RW_ATTR_DEF(port4_modsel) -SYSFS_RAW_RW_ATTR_DEF(port3_modsel) -SYSFS_RAW_RW_ATTR_DEF(port2_modsel) -SYSFS_RAW_RW_ATTR_DEF(port1_modsel) - -SYSFS_RAW_RW_ATTR_DEF(port16_modsel) -SYSFS_RAW_RW_ATTR_DEF(port15_modsel) -SYSFS_RAW_RW_ATTR_DEF(port14_modsel) -SYSFS_RAW_RW_ATTR_DEF(port13_modsel) -SYSFS_RAW_RW_ATTR_DEF(port12_modsel) -SYSFS_RAW_RW_ATTR_DEF(port11_modsel) -SYSFS_RAW_RW_ATTR_DEF(port10_modsel) -SYSFS_RAW_RW_ATTR_DEF(port9_modsel) - -SYSFS_RAW_RW_ATTR_DEF(port8_lpmode) -SYSFS_RAW_RW_ATTR_DEF(port7_lpmode) -SYSFS_RAW_RW_ATTR_DEF(port6_lpmode) -SYSFS_RAW_RW_ATTR_DEF(port5_lpmode) -SYSFS_RAW_RW_ATTR_DEF(port4_lpmode) -SYSFS_RAW_RW_ATTR_DEF(port3_lpmode) -SYSFS_RAW_RW_ATTR_DEF(port2_lpmode) -SYSFS_RAW_RW_ATTR_DEF(port1_lpmode) - -SYSFS_RAW_RW_ATTR_DEF(port16_lpmode) -SYSFS_RAW_RW_ATTR_DEF(port15_lpmode) -SYSFS_RAW_RW_ATTR_DEF(port14_lpmode) -SYSFS_RAW_RW_ATTR_DEF(port13_lpmode) -SYSFS_RAW_RW_ATTR_DEF(port12_lpmode) -SYSFS_RAW_RW_ATTR_DEF(port11_lpmode) -SYSFS_RAW_RW_ATTR_DEF(port10_lpmode) -SYSFS_RAW_RW_ATTR_DEF(port9_lpmode) - -SYSFS_RAW_RO_ATTR_DEF(port8_irq_status) -SYSFS_RAW_RO_ATTR_DEF(port7_irq_status) -SYSFS_RAW_RO_ATTR_DEF(port6_irq_status) -SYSFS_RAW_RO_ATTR_DEF(port5_irq_status) -SYSFS_RAW_RO_ATTR_DEF(port4_irq_status) -SYSFS_RAW_RO_ATTR_DEF(port3_irq_status) -SYSFS_RAW_RO_ATTR_DEF(port2_irq_status) -SYSFS_RAW_RO_ATTR_DEF(port1_irq_status) - -SYSFS_RAW_RO_ATTR_DEF(port16_irq_status) -SYSFS_RAW_RO_ATTR_DEF(port15_irq_status) -SYSFS_RAW_RO_ATTR_DEF(port14_irq_status) -SYSFS_RAW_RO_ATTR_DEF(port13_irq_status) -SYSFS_RAW_RO_ATTR_DEF(port12_irq_status) -SYSFS_RAW_RO_ATTR_DEF(port11_irq_status) -SYSFS_RAW_RO_ATTR_DEF(port10_irq_status) -SYSFS_RAW_RO_ATTR_DEF(port9_irq_status) - -SYSFS_RAW_RW_ATTR_DEF(port8_irq_msk) -SYSFS_RAW_RW_ATTR_DEF(port7_irq_msk) -SYSFS_RAW_RW_ATTR_DEF(port6_irq_msk) -SYSFS_RAW_RW_ATTR_DEF(port5_irq_msk) -SYSFS_RAW_RW_ATTR_DEF(port4_irq_msk) -SYSFS_RAW_RW_ATTR_DEF(port3_irq_msk) -SYSFS_RAW_RW_ATTR_DEF(port2_irq_msk) -SYSFS_RAW_RW_ATTR_DEF(port1_irq_msk) - -SYSFS_RAW_RW_ATTR_DEF(port16_irq_msk) -SYSFS_RAW_RW_ATTR_DEF(port15_irq_msk) -SYSFS_RAW_RW_ATTR_DEF(port14_irq_msk) -SYSFS_RAW_RW_ATTR_DEF(port13_irq_msk) -SYSFS_RAW_RW_ATTR_DEF(port12_irq_msk) -SYSFS_RAW_RW_ATTR_DEF(port11_irq_msk) -SYSFS_RAW_RW_ATTR_DEF(port10_irq_msk) -SYSFS_RAW_RW_ATTR_DEF(port9_irq_msk) - -SYSFS_RAW_RO_ATTR_DEF(port_1_8_present) -SYSFS_RAW_RO_ATTR_DEF(port_9_16_present) -SYSFS_RAW_RW_ATTR_DEF(port_1_8_rst) -SYSFS_RAW_RW_ATTR_DEF(port_9_16_rst) -SYSFS_RAW_RW_ATTR_DEF(port_1_8_modsel) -SYSFS_RAW_RW_ATTR_DEF(port_9_16_modsel) -SYSFS_RAW_RO_ATTR_DEF(port_1_8_irq_status) -SYSFS_RAW_RO_ATTR_DEF(port_9_16_irq_status) -SYSFS_RAW_RW_ATTR_DEF(port_1_8_irq_msk) -SYSFS_RAW_RW_ATTR_DEF(port_9_16_irq_msk) -SYSFS_RAW_RW_ATTR_DEF(port_1_8_lpmode) -SYSFS_RAW_RW_ATTR_DEF(port_9_16_lpmode) - -SYSFS_RAW_RO_ATTR_DEF(fan_tray1_6_present) -SYSFS_RAW_RO_ATTR_DEF(psu_en_status_fld) -#endif /* __MASTER_CPLD_SYSFS */ diff --git a/packages/platforms/mitac/x86-64/ly1200-b32h0-c3/modules/builds/slave_cpld_reg.h b/packages/platforms/mitac/x86-64/ly1200-b32h0-c3/modules/builds/slave_cpld_reg.h deleted file mode 100644 index a8169bdb8..000000000 --- a/packages/platforms/mitac/x86-64/ly1200-b32h0-c3/modules/builds/slave_cpld_reg.h +++ /dev/null @@ -1,192 +0,0 @@ -#ifndef __SLAVE_CPLD_REG -#define __SLAVE_CPLD_REG - -static int slave_cpld_raw_read(struct device *dev, struct device_attribute *attr, char *buf, - int reg_offset, int reg_width, int fld_shift, int fld_width, int fld_mask, char* reg_name); -static int slave_cpld_raw_write(struct device *dev, struct device_attribute *attr, const char *buf, size_t count, - int reg_offset, int reg_width, int fld_shift, int fld_width, int fld_mask, char* reg_name); - -/* generic CPLD read function */ -#define FLD_RAW_RD_FUNC(_reg, _fld, _wdh) static ssize_t \ -slave_cpld_##_fld##_raw_read(struct device *dev, struct device_attribute *attr, char *buf) { \ - return slave_cpld_raw_read(dev, attr, buf, _reg##_offset, _reg##_width, _fld##_shift, _fld##_width, _fld##_mask, #_reg); \ -} - -/* generic CPLD write function */ -#define FLD_RAW_WR_FUNC(_reg, _fld, _wdh) static ssize_t \ -slave_cpld_##_fld##_raw_write(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { \ - return slave_cpld_raw_write(dev, attr, buf, count, _reg##_offset, _reg##_width, _fld##_shift, _fld##_width, _fld##_mask, #_reg); \ -} - -/* CPLD register definition macros */ -#define REG_DEF(_reg, _off, _wdh) \ -static unsigned int _reg##_offset = (unsigned int)(_off); \ -static unsigned int _reg##_width = (unsigned int)(_wdh); - -/* CPLD register field definition macros, with generic read/write function */ -#define FLD_RAW_RO_DEF(_reg, _fld, _sft, _wdh) \ -static unsigned int _fld##_shift = (unsigned int)(_sft); \ -static unsigned int _fld##_width = (unsigned int)(_wdh); \ -static unsigned int _fld##_mask = ((((unsigned int)1) << (_wdh)) - 1); \ -FLD_RAW_RD_FUNC(_reg, _fld, _wdh) - -#define FLD_RAW_RW_DEF(_reg, _fld, _sft, _wdh) \ -static unsigned int _fld##_shift = (unsigned int)(_sft); \ -static unsigned int _fld##_width = (unsigned int)(_wdh); \ -static unsigned int _fld##_mask = ((((unsigned int)1) << (_wdh)) - 1); \ -FLD_RAW_RD_FUNC(_reg, _fld, _wdh) FLD_RAW_WR_FUNC(_reg, _fld, _wdh) - -/* declare slave CPLD registers */ -/* register name offset width */ -/* --------------------------------------- ------- ----- */ -REG_DEF( slv_cpld_rev, 0x00, 8) -REG_DEF( slv_cpld_gpr, 0x01, 8) -REG_DEF( mb_brd_rev_type, 0x02, 8) - -REG_DEF( zqsfp28_present_24_17_status, 0x10, 8) -REG_DEF( zqsfp28_present_32_25_status, 0x11, 8) -REG_DEF( zqsfp28_rst_24_17, 0x12, 8) -REG_DEF( zqsfp28_rst_32_25, 0x13, 8) -REG_DEF( zqsfp28_modsel_24_17, 0x14, 8) -REG_DEF( zqsfp28_modsel_32_25, 0x15, 8) -REG_DEF( zqsfp28_lpmode_24_17, 0x16, 8) -REG_DEF( zqsfp28_lpmode_32_25, 0x17, 8) -REG_DEF( zqsfp28_irq_24_17_status, 0x18, 8) -REG_DEF( zqsfp28_irq_32_25_status, 0x19, 8) -REG_DEF( zqsfp28_irq_msk_24_17_status, 0x1A, 8) -REG_DEF( zqsfp28_irq_msk_32_25_status, 0x1B, 8) - - -/* declare slave CPLD register's fields */ -/* register name field name shift width */ -/* ---------------------- ---------------- ------ ----- */ -FLD_RAW_RO_DEF( slv_cpld_rev, mjr_rev, 4, 4) -FLD_RAW_RO_DEF( slv_cpld_rev, mnr_rev, 0, 4) - -FLD_RAW_RW_DEF( slv_cpld_gpr, scrtch_reg, 0, 8) - -FLD_RAW_RO_DEF( mb_brd_rev_type, brd_rev, 4, 4) -FLD_RAW_RO_DEF( mb_brd_rev_type, brd_type, 0, 4) - -FLD_RAW_RO_DEF( zqsfp28_present_24_17_status, port24_present, 7, 1) -FLD_RAW_RO_DEF( zqsfp28_present_24_17_status, port23_present, 6, 1) -FLD_RAW_RO_DEF( zqsfp28_present_24_17_status, port22_present, 5, 1) -FLD_RAW_RO_DEF( zqsfp28_present_24_17_status, port21_present, 4, 1) -FLD_RAW_RO_DEF( zqsfp28_present_24_17_status, port20_present, 3, 1) -FLD_RAW_RO_DEF( zqsfp28_present_24_17_status, port19_present, 2, 1) -FLD_RAW_RO_DEF( zqsfp28_present_24_17_status, port18_present, 1, 1) -FLD_RAW_RO_DEF( zqsfp28_present_24_17_status, port17_present, 0, 1) - -FLD_RAW_RO_DEF( zqsfp28_present_32_25_status, port32_present, 7, 1) -FLD_RAW_RO_DEF( zqsfp28_present_32_25_status, port31_present, 6, 1) -FLD_RAW_RO_DEF( zqsfp28_present_32_25_status, port30_present, 5, 1) -FLD_RAW_RO_DEF( zqsfp28_present_32_25_status, port29_present, 4, 1) -FLD_RAW_RO_DEF( zqsfp28_present_32_25_status, port28_present, 3, 1) -FLD_RAW_RO_DEF( zqsfp28_present_32_25_status, port27_present, 2, 1) -FLD_RAW_RO_DEF( zqsfp28_present_32_25_status, port26_present, 1, 1) -FLD_RAW_RO_DEF( zqsfp28_present_32_25_status, port25_present, 0, 1) - -FLD_RAW_RW_DEF( zqsfp28_rst_24_17, port24_rst, 7, 1) -FLD_RAW_RW_DEF( zqsfp28_rst_24_17, port23_rst, 6, 1) -FLD_RAW_RW_DEF( zqsfp28_rst_24_17, port22_rst, 5, 1) -FLD_RAW_RW_DEF( zqsfp28_rst_24_17, port21_rst, 4, 1) -FLD_RAW_RW_DEF( zqsfp28_rst_24_17, port20_rst, 3, 1) -FLD_RAW_RW_DEF( zqsfp28_rst_24_17, port19_rst, 2, 1) -FLD_RAW_RW_DEF( zqsfp28_rst_24_17, port18_rst, 1, 1) -FLD_RAW_RW_DEF( zqsfp28_rst_24_17, port17_rst, 0, 1) - -FLD_RAW_RW_DEF( zqsfp28_rst_32_25, port32_rst, 7, 1) -FLD_RAW_RW_DEF( zqsfp28_rst_32_25, port31_rst, 6, 1) -FLD_RAW_RW_DEF( zqsfp28_rst_32_25, port30_rst, 5, 1) -FLD_RAW_RW_DEF( zqsfp28_rst_32_25, port29_rst, 4, 1) -FLD_RAW_RW_DEF( zqsfp28_rst_32_25, port28_rst, 3, 1) -FLD_RAW_RW_DEF( zqsfp28_rst_32_25, port27_rst, 2, 1) -FLD_RAW_RW_DEF( zqsfp28_rst_32_25, port26_rst, 1, 1) -FLD_RAW_RW_DEF( zqsfp28_rst_32_25, port25_rst, 0, 1) - -FLD_RAW_RW_DEF( zqsfp28_modsel_24_17, port24_modsel, 7, 1) -FLD_RAW_RW_DEF( zqsfp28_modsel_24_17, port23_modsel, 6, 1) -FLD_RAW_RW_DEF( zqsfp28_modsel_24_17, port22_modsel, 5, 1) -FLD_RAW_RW_DEF( zqsfp28_modsel_24_17, port21_modsel, 4, 1) -FLD_RAW_RW_DEF( zqsfp28_modsel_24_17, port20_modsel, 3, 1) -FLD_RAW_RW_DEF( zqsfp28_modsel_24_17, port19_modsel, 2, 1) -FLD_RAW_RW_DEF( zqsfp28_modsel_24_17, port18_modsel, 1, 1) -FLD_RAW_RW_DEF( zqsfp28_modsel_24_17, port17_modsel, 0, 1) - -FLD_RAW_RW_DEF( zqsfp28_modsel_32_25, port32_modsel, 7, 1) -FLD_RAW_RW_DEF( zqsfp28_modsel_32_25, port31_modsel, 6, 1) -FLD_RAW_RW_DEF( zqsfp28_modsel_32_25, port30_modsel, 5, 1) -FLD_RAW_RW_DEF( zqsfp28_modsel_32_25, port29_modsel, 4, 1) -FLD_RAW_RW_DEF( zqsfp28_modsel_32_25, port28_modsel, 3, 1) -FLD_RAW_RW_DEF( zqsfp28_modsel_32_25, port27_modsel, 2, 1) -FLD_RAW_RW_DEF( zqsfp28_modsel_32_25, port26_modsel, 1, 1) -FLD_RAW_RW_DEF( zqsfp28_modsel_32_25, port25_modsel, 0, 1) - -FLD_RAW_RW_DEF( zqsfp28_lpmode_24_17, port24_lpmode, 7, 1) -FLD_RAW_RW_DEF( zqsfp28_lpmode_24_17, port23_lpmode, 6, 1) -FLD_RAW_RW_DEF( zqsfp28_lpmode_24_17, port22_lpmode, 5, 1) -FLD_RAW_RW_DEF( zqsfp28_lpmode_24_17, port21_lpmode, 4, 1) -FLD_RAW_RW_DEF( zqsfp28_lpmode_24_17, port20_lpmode, 3, 1) -FLD_RAW_RW_DEF( zqsfp28_lpmode_24_17, port19_lpmode, 2, 1) -FLD_RAW_RW_DEF( zqsfp28_lpmode_24_17, port18_lpmode, 1, 1) -FLD_RAW_RW_DEF( zqsfp28_lpmode_24_17, port17_lpmode, 0, 1) - -FLD_RAW_RW_DEF( zqsfp28_lpmode_32_25, port32_lpmode, 7, 1) -FLD_RAW_RW_DEF( zqsfp28_lpmode_32_25, port31_lpmode, 6, 1) -FLD_RAW_RW_DEF( zqsfp28_lpmode_32_25, port30_lpmode, 5, 1) -FLD_RAW_RW_DEF( zqsfp28_lpmode_32_25, port29_lpmode, 4, 1) -FLD_RAW_RW_DEF( zqsfp28_lpmode_32_25, port28_lpmode, 3, 1) -FLD_RAW_RW_DEF( zqsfp28_lpmode_32_25, port27_lpmode, 2, 1) -FLD_RAW_RW_DEF( zqsfp28_lpmode_32_25, port26_lpmode, 1, 1) -FLD_RAW_RW_DEF( zqsfp28_lpmode_32_25, port25_lpmode, 0, 1) - -FLD_RAW_RO_DEF( zqsfp28_irq_24_17_status, port24_irq_status, 7, 1) -FLD_RAW_RO_DEF( zqsfp28_irq_24_17_status, port23_irq_status, 6, 1) -FLD_RAW_RO_DEF( zqsfp28_irq_24_17_status, port22_irq_status, 5, 1) -FLD_RAW_RO_DEF( zqsfp28_irq_24_17_status, port21_irq_status, 4, 1) -FLD_RAW_RO_DEF( zqsfp28_irq_24_17_status, port20_irq_status, 3, 1) -FLD_RAW_RO_DEF( zqsfp28_irq_24_17_status, port19_irq_status, 2, 1) -FLD_RAW_RO_DEF( zqsfp28_irq_24_17_status, port18_irq_status, 1, 1) -FLD_RAW_RO_DEF( zqsfp28_irq_24_17_status, port17_irq_status, 0, 1) - -FLD_RAW_RO_DEF( zqsfp28_irq_32_25_status, port32_irq_status, 7, 1) -FLD_RAW_RO_DEF( zqsfp28_irq_32_25_status, port31_irq_status, 6, 1) -FLD_RAW_RO_DEF( zqsfp28_irq_32_25_status, port30_irq_status, 5, 1) -FLD_RAW_RO_DEF( zqsfp28_irq_32_25_status, port29_irq_status, 4, 1) -FLD_RAW_RO_DEF( zqsfp28_irq_32_25_status, port28_irq_status, 3, 1) -FLD_RAW_RO_DEF( zqsfp28_irq_32_25_status, port27_irq_status, 2, 1) -FLD_RAW_RO_DEF( zqsfp28_irq_32_25_status, port26_irq_status, 1, 1) -FLD_RAW_RO_DEF( zqsfp28_irq_32_25_status, port25_irq_status, 0, 1) - -FLD_RAW_RW_DEF( zqsfp28_irq_msk_24_17_status, port24_irq_msk, 7, 1) -FLD_RAW_RW_DEF( zqsfp28_irq_msk_24_17_status, port23_irq_msk, 6, 1) -FLD_RAW_RW_DEF( zqsfp28_irq_msk_24_17_status, port22_irq_msk, 5, 1) -FLD_RAW_RW_DEF( zqsfp28_irq_msk_24_17_status, port21_irq_msk, 4, 1) -FLD_RAW_RW_DEF( zqsfp28_irq_msk_24_17_status, port20_irq_msk, 3, 1) -FLD_RAW_RW_DEF( zqsfp28_irq_msk_24_17_status, port19_irq_msk, 2, 1) -FLD_RAW_RW_DEF( zqsfp28_irq_msk_24_17_status, port18_irq_msk, 1, 1) -FLD_RAW_RW_DEF( zqsfp28_irq_msk_24_17_status, port17_irq_msk, 0, 1) - -FLD_RAW_RW_DEF( zqsfp28_irq_msk_32_25_status, port32_irq_msk, 7, 1) -FLD_RAW_RW_DEF( zqsfp28_irq_msk_32_25_status, port31_irq_msk, 6, 1) -FLD_RAW_RW_DEF( zqsfp28_irq_msk_32_25_status, port30_irq_msk, 5, 1) -FLD_RAW_RW_DEF( zqsfp28_irq_msk_32_25_status, port29_irq_msk, 4, 1) -FLD_RAW_RW_DEF( zqsfp28_irq_msk_32_25_status, port28_irq_msk, 3, 1) -FLD_RAW_RW_DEF( zqsfp28_irq_msk_32_25_status, port27_irq_msk, 2, 1) -FLD_RAW_RW_DEF( zqsfp28_irq_msk_32_25_status, port26_irq_msk, 1, 1) -FLD_RAW_RW_DEF( zqsfp28_irq_msk_32_25_status, port25_irq_msk, 0, 1) - -FLD_RAW_RO_DEF( zqsfp28_present_24_17_status, port_17_24_present, 0, 8) -FLD_RAW_RO_DEF( zqsfp28_present_32_25_status, port_25_32_present, 0, 8) -FLD_RAW_RW_DEF( zqsfp28_rst_24_17, port_17_24_rst, 0, 8) -FLD_RAW_RW_DEF( zqsfp28_rst_32_25, port_25_32_rst, 0, 8) -FLD_RAW_RW_DEF( zqsfp28_modsel_24_17, port_17_24_modsel, 0, 8) -FLD_RAW_RW_DEF( zqsfp28_modsel_32_25, port_25_32_modsel, 0, 8) -FLD_RAW_RO_DEF( zqsfp28_irq_24_17_status, port_17_24_irq_status,0, 8) -FLD_RAW_RO_DEF( zqsfp28_irq_32_25_status, port_25_32_irq_status,0, 8) -FLD_RAW_RW_DEF( zqsfp28_irq_msk_24_17_status, port_17_24_irq_msk, 0, 8) -FLD_RAW_RW_DEF( zqsfp28_irq_msk_32_25_status, port_25_32_irq_msk, 0, 8) -FLD_RAW_RW_DEF( zqsfp28_lpmode_24_17, port_17_24_lpmode, 0, 8) -FLD_RAW_RW_DEF( zqsfp28_lpmode_32_25, port_25_32_lpmode, 0, 8) - -#endif /* __SLAVE_CPLD_REG */ diff --git a/packages/platforms/mitac/x86-64/ly1200-b32h0-c3/modules/builds/slave_cpld_sysfs.h b/packages/platforms/mitac/x86-64/ly1200-b32h0-c3/modules/builds/slave_cpld_sysfs.h deleted file mode 100644 index a619f4538..000000000 --- a/packages/platforms/mitac/x86-64/ly1200-b32h0-c3/modules/builds/slave_cpld_sysfs.h +++ /dev/null @@ -1,155 +0,0 @@ -#ifndef __SLAVE_CPLD_SYSFS -#define __SLAVE_CPLD_SYSFS - -/* generic CPLD sysfs file definition macros */ -#define SYSFS_RAW_RO_ATTR_DEF(field) \ -struct device_attribute field \ - = __ATTR(field, S_IRUGO, slave_cpld_##field##_raw_read, NULL); - -#define SYSFS_RAW_RW_ATTR_DEF(field) \ -struct device_attribute field \ - = __ATTR(field, S_IRUGO | S_IWUSR | S_IWGRP, slave_cpld_##field##_raw_read, slave_cpld_##field##_raw_write); - -#define SYSFS_MISC_RO_ATTR_DEF(field, _read) \ -struct device_attribute field \ - = __ATTR(field, S_IRUGO, _read, NULL); - -#define SYSFS_MISC_RW_ATTR_DEF(field, _read, _write) \ -struct device_attribute field \ - = __ATTR(field, S_IRUGO | S_IWUSR | S_IWGRP, _read, _write); - -#define SYSFS_ATTR_PTR(field) \ -&field.attr - - -/* declare slave CPLD file system */ -SYSFS_RAW_RO_ATTR_DEF(mjr_rev) -SYSFS_RAW_RO_ATTR_DEF(mnr_rev) - -SYSFS_RAW_RW_ATTR_DEF(scrtch_reg) - -SYSFS_RAW_RO_ATTR_DEF(brd_rev) -SYSFS_RAW_RO_ATTR_DEF(brd_type) - -SYSFS_RAW_RO_ATTR_DEF(port24_present) -SYSFS_RAW_RO_ATTR_DEF(port23_present) -SYSFS_RAW_RO_ATTR_DEF(port22_present) -SYSFS_RAW_RO_ATTR_DEF(port21_present) -SYSFS_RAW_RO_ATTR_DEF(port20_present) -SYSFS_RAW_RO_ATTR_DEF(port19_present) -SYSFS_RAW_RO_ATTR_DEF(port18_present) -SYSFS_RAW_RO_ATTR_DEF(port17_present) - -SYSFS_RAW_RO_ATTR_DEF(port32_present) -SYSFS_RAW_RO_ATTR_DEF(port31_present) -SYSFS_RAW_RO_ATTR_DEF(port30_present) -SYSFS_RAW_RO_ATTR_DEF(port29_present) -SYSFS_RAW_RO_ATTR_DEF(port28_present) -SYSFS_RAW_RO_ATTR_DEF(port27_present) -SYSFS_RAW_RO_ATTR_DEF(port26_present) -SYSFS_RAW_RO_ATTR_DEF(port25_present) - -SYSFS_RAW_RW_ATTR_DEF(port24_rst) -SYSFS_RAW_RW_ATTR_DEF(port23_rst) -SYSFS_RAW_RW_ATTR_DEF(port22_rst) -SYSFS_RAW_RW_ATTR_DEF(port21_rst) -SYSFS_RAW_RW_ATTR_DEF(port20_rst) -SYSFS_RAW_RW_ATTR_DEF(port19_rst) -SYSFS_RAW_RW_ATTR_DEF(port18_rst) -SYSFS_RAW_RW_ATTR_DEF(port17_rst) - -SYSFS_RAW_RW_ATTR_DEF(port32_rst) -SYSFS_RAW_RW_ATTR_DEF(port31_rst) -SYSFS_RAW_RW_ATTR_DEF(port30_rst) -SYSFS_RAW_RW_ATTR_DEF(port29_rst) -SYSFS_RAW_RW_ATTR_DEF(port28_rst) -SYSFS_RAW_RW_ATTR_DEF(port27_rst) -SYSFS_RAW_RW_ATTR_DEF(port26_rst) -SYSFS_RAW_RW_ATTR_DEF(port25_rst) - -SYSFS_RAW_RW_ATTR_DEF(port24_modsel) -SYSFS_RAW_RW_ATTR_DEF(port23_modsel) -SYSFS_RAW_RW_ATTR_DEF(port22_modsel) -SYSFS_RAW_RW_ATTR_DEF(port21_modsel) -SYSFS_RAW_RW_ATTR_DEF(port20_modsel) -SYSFS_RAW_RW_ATTR_DEF(port19_modsel) -SYSFS_RAW_RW_ATTR_DEF(port18_modsel) -SYSFS_RAW_RW_ATTR_DEF(port17_modsel) - -SYSFS_RAW_RW_ATTR_DEF(port32_modsel) -SYSFS_RAW_RW_ATTR_DEF(port31_modsel) -SYSFS_RAW_RW_ATTR_DEF(port30_modsel) -SYSFS_RAW_RW_ATTR_DEF(port29_modsel) -SYSFS_RAW_RW_ATTR_DEF(port28_modsel) -SYSFS_RAW_RW_ATTR_DEF(port27_modsel) -SYSFS_RAW_RW_ATTR_DEF(port26_modsel) -SYSFS_RAW_RW_ATTR_DEF(port25_modsel) - -SYSFS_RAW_RW_ATTR_DEF(port24_lpmode) -SYSFS_RAW_RW_ATTR_DEF(port23_lpmode) -SYSFS_RAW_RW_ATTR_DEF(port22_lpmode) -SYSFS_RAW_RW_ATTR_DEF(port21_lpmode) -SYSFS_RAW_RW_ATTR_DEF(port20_lpmode) -SYSFS_RAW_RW_ATTR_DEF(port19_lpmode) -SYSFS_RAW_RW_ATTR_DEF(port18_lpmode) -SYSFS_RAW_RW_ATTR_DEF(port17_lpmode) - -SYSFS_RAW_RW_ATTR_DEF(port32_lpmode) -SYSFS_RAW_RW_ATTR_DEF(port31_lpmode) -SYSFS_RAW_RW_ATTR_DEF(port30_lpmode) -SYSFS_RAW_RW_ATTR_DEF(port29_lpmode) -SYSFS_RAW_RW_ATTR_DEF(port28_lpmode) -SYSFS_RAW_RW_ATTR_DEF(port27_lpmode) -SYSFS_RAW_RW_ATTR_DEF(port26_lpmode) -SYSFS_RAW_RW_ATTR_DEF(port25_lpmode) - -SYSFS_RAW_RO_ATTR_DEF(port24_irq_status) -SYSFS_RAW_RO_ATTR_DEF(port23_irq_status) -SYSFS_RAW_RO_ATTR_DEF(port22_irq_status) -SYSFS_RAW_RO_ATTR_DEF(port21_irq_status) -SYSFS_RAW_RO_ATTR_DEF(port20_irq_status) -SYSFS_RAW_RO_ATTR_DEF(port19_irq_status) -SYSFS_RAW_RO_ATTR_DEF(port18_irq_status) -SYSFS_RAW_RO_ATTR_DEF(port17_irq_status) - -SYSFS_RAW_RO_ATTR_DEF(port32_irq_status) -SYSFS_RAW_RO_ATTR_DEF(port31_irq_status) -SYSFS_RAW_RO_ATTR_DEF(port30_irq_status) -SYSFS_RAW_RO_ATTR_DEF(port29_irq_status) -SYSFS_RAW_RO_ATTR_DEF(port28_irq_status) -SYSFS_RAW_RO_ATTR_DEF(port27_irq_status) -SYSFS_RAW_RO_ATTR_DEF(port26_irq_status) -SYSFS_RAW_RO_ATTR_DEF(port25_irq_status) - -SYSFS_RAW_RW_ATTR_DEF(port24_irq_msk) -SYSFS_RAW_RW_ATTR_DEF(port23_irq_msk) -SYSFS_RAW_RW_ATTR_DEF(port22_irq_msk) -SYSFS_RAW_RW_ATTR_DEF(port21_irq_msk) -SYSFS_RAW_RW_ATTR_DEF(port20_irq_msk) -SYSFS_RAW_RW_ATTR_DEF(port19_irq_msk) -SYSFS_RAW_RW_ATTR_DEF(port18_irq_msk) -SYSFS_RAW_RW_ATTR_DEF(port17_irq_msk) - -SYSFS_RAW_RW_ATTR_DEF(port32_irq_msk) -SYSFS_RAW_RW_ATTR_DEF(port31_irq_msk) -SYSFS_RAW_RW_ATTR_DEF(port30_irq_msk) -SYSFS_RAW_RW_ATTR_DEF(port29_irq_msk) -SYSFS_RAW_RW_ATTR_DEF(port28_irq_msk) -SYSFS_RAW_RW_ATTR_DEF(port27_irq_msk) -SYSFS_RAW_RW_ATTR_DEF(port26_irq_msk) -SYSFS_RAW_RW_ATTR_DEF(port25_irq_msk) - -SYSFS_RAW_RO_ATTR_DEF(port_17_24_present) -SYSFS_RAW_RO_ATTR_DEF(port_25_32_present) -SYSFS_RAW_RW_ATTR_DEF(port_17_24_rst) -SYSFS_RAW_RW_ATTR_DEF(port_25_32_rst) -SYSFS_RAW_RW_ATTR_DEF(port_17_24_modsel) -SYSFS_RAW_RW_ATTR_DEF(port_25_32_modsel) -SYSFS_RAW_RO_ATTR_DEF(port_17_24_irq_status) -SYSFS_RAW_RO_ATTR_DEF(port_25_32_irq_status) -SYSFS_RAW_RW_ATTR_DEF(port_17_24_irq_msk) -SYSFS_RAW_RW_ATTR_DEF(port_25_32_irq_msk) -SYSFS_RAW_RW_ATTR_DEF(port_17_24_lpmode) -SYSFS_RAW_RW_ATTR_DEF(port_25_32_lpmode) - -#endif /* __SLAVE_CPLD_SYSFS */ diff --git a/packages/platforms/mitac/x86-64/ly1200-b32h0-c3/modules/builds/system_cpld_reg.h b/packages/platforms/mitac/x86-64/ly1200-b32h0-c3/modules/builds/system_cpld_reg.h deleted file mode 100644 index cb0d813fa..000000000 --- a/packages/platforms/mitac/x86-64/ly1200-b32h0-c3/modules/builds/system_cpld_reg.h +++ /dev/null @@ -1,110 +0,0 @@ -#ifndef __SYSTEM_CPLD_REG -#define __SYSTEM_CPLD_REG - -static int system_cpld_raw_read(struct device *dev, struct device_attribute *attr, char *buf, - int reg_offset, int reg_width, int fld_shift, int fld_width, int fld_mask, char* reg_name); -static int system_cpld_raw_write(struct device *dev, struct device_attribute *attr, const char *buf, size_t count, - int reg_offset, int reg_width, int fld_shift, int fld_width, int fld_mask, char* reg_name); - -/* generic CPLD read function */ -#define FLD_RAW_RD_FUNC(_reg, _fld, _wdh) static ssize_t \ -system_cpld_##_fld##_raw_read(struct device *dev, struct device_attribute *attr, char *buf) { \ - return system_cpld_raw_read(dev, attr, buf, _reg##_offset, _reg##_width, _fld##_shift, _fld##_width, _fld##_mask, #_reg); \ -} - -/* generic CPLD write function */ -#define FLD_RAW_WR_FUNC(_reg, _fld, _wdh) static ssize_t \ -system_cpld_##_fld##_raw_write(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { \ - return system_cpld_raw_write(dev, attr, buf, count, _reg##_offset, _reg##_width, _fld##_shift, _fld##_width, _fld##_mask, #_reg); \ -} - -/* CPLD register definition macros */ -#define REG_DEF(_reg, _off, _wdh) \ -static unsigned int _reg##_offset = (unsigned int)(_off); \ -static unsigned int _reg##_width = (unsigned int)(_wdh); - -/* CPLD register field definition macros, with generic read/write function */ -#define FLD_RAW_RO_DEF(_reg, _fld, _sft, _wdh) \ -static unsigned int _fld##_shift = (unsigned int)(_sft); \ -static unsigned int _fld##_width = (unsigned int)(_wdh); \ -static unsigned int _fld##_mask = ((((unsigned int)1) << (_wdh)) - 1); \ -FLD_RAW_RD_FUNC(_reg, _fld, _wdh) - -#define FLD_RAW_RW_DEF(_reg, _fld, _sft, _wdh) \ -static unsigned int _fld##_shift = (unsigned int)(_sft); \ -static unsigned int _fld##_width = (unsigned int)(_wdh); \ -static unsigned int _fld##_mask = ((((unsigned int)1) << (_wdh)) - 1); \ -FLD_RAW_RD_FUNC(_reg, _fld, _wdh) FLD_RAW_WR_FUNC(_reg, _fld, _wdh) - -/* declare system CPLD registers */ -/* register name offset width */ -/* --------------------------------------- ------- ----- */ -REG_DEF( sys_cpld_rev, 0x00, 8) -REG_DEF( sys_cpld_gpr, 0x01, 8) -REG_DEF( cpu_brd_rev_type, 0x02, 8) -REG_DEF( sys_srr, 0x03, 8) -REG_DEF( sys_eeprom_wp, 0x04, 8) -REG_DEF( sys_irq, 0x05, 8) -REG_DEF( sys_wd, 0x06, 8) -REG_DEF( sys_mb_rst_en, 0x07, 8) -REG_DEF( cpu_pwr_en_status, 0x08, 8) -REG_DEF( cpu_pwr_status, 0x09, 8) -REG_DEF( sys_reboot_cause, 0x0A, 8) - - -/* declare system CPLD register's fields */ -/* register name field name shift width */ -/* ---------------------- ---------------- ------ ----- */ -FLD_RAW_RO_DEF( sys_cpld_rev, mjr_rev, 4, 4) -FLD_RAW_RO_DEF( sys_cpld_rev, mnr_rev, 0, 4) - -FLD_RAW_RW_DEF( sys_cpld_gpr, scrtch_reg, 0, 8) - -FLD_RAW_RO_DEF( cpu_brd_rev_type, brd_rev, 4, 4) -FLD_RAW_RO_DEF( cpu_brd_rev_type, brd_type, 0, 4) - -FLD_RAW_RO_DEF( sys_srr, ssd_present, 3, 1) -FLD_RAW_RW_DEF( sys_srr, spi_cs_sel, 2, 1) -FLD_RAW_RW_DEF( sys_srr, rst_bios_switch, 1, 1) -FLD_RAW_RW_DEF( sys_srr, cpld_upgrade_rst, 0, 1) - -FLD_RAW_RW_DEF( sys_eeprom_wp, cpld_spi_wp, 4, 1) -FLD_RAW_RW_DEF( sys_eeprom_wp, system_id_eeprom_wp, 3, 1) -FLD_RAW_RW_DEF( sys_eeprom_wp, spi_me_wp, 2, 1) -FLD_RAW_RW_DEF( sys_eeprom_wp, spi_bios_wp, 1, 1) -FLD_RAW_RW_DEF( sys_eeprom_wp, spi_bak_bios_wp, 0, 1) - -FLD_RAW_RW_DEF( sys_irq, vrhot_irq_en, 6, 1) -FLD_RAW_RW_DEF( sys_irq, cpu_thermtrip_irq_en,5, 1) -FLD_RAW_RW_DEF( sys_irq, temp_alert_irq_en, 4, 1) -FLD_RAW_RO_DEF( sys_irq, vrhot_irq, 2, 1) -FLD_RAW_RO_DEF( sys_irq, cpu_thermtrip_irq, 1, 1) -FLD_RAW_RO_DEF( sys_irq, temp_alert_irq, 0, 1) - -FLD_RAW_RW_DEF( sys_wd, wd_timer, 4, 4) -FLD_RAW_RW_DEF( sys_wd, wd_en, 1, 1) -FLD_RAW_RW_DEF( sys_wd, wd_punch, 0, 1) - -FLD_RAW_RW_DEF( sys_mb_rst_en, mb_rst_en, 0, 1) - -FLD_RAW_RO_DEF( cpu_pwr_en_status, pwr_v3p3_en, 7, 1) -FLD_RAW_RO_DEF( cpu_pwr_en_status, pwr_vcc_vnn_en, 6, 1) -FLD_RAW_RO_DEF( cpu_pwr_en_status, pwr_vccsram_en, 5, 1) -FLD_RAW_RO_DEF( cpu_pwr_en_status, pwr_vddq_en, 4, 1) -FLD_RAW_RO_DEF( cpu_pwr_en_status, pwr_vcc_ref_en, 3, 1) -FLD_RAW_RO_DEF( cpu_pwr_en_status, pwr_v1p05_en, 2, 1) -FLD_RAW_RO_DEF( cpu_pwr_en_status, pwr_v1p8_en, 1, 1) -FLD_RAW_RO_DEF( cpu_pwr_en_status, pwr_v2p5_en, 0, 1) - -FLD_RAW_RO_DEF( cpu_pwr_status, pg_v3p3, 7, 1) -FLD_RAW_RO_DEF( cpu_pwr_status, pg_vcc_vnn, 6, 1) -FLD_RAW_RO_DEF( cpu_pwr_status, pg_vccsram, 5, 1) -FLD_RAW_RO_DEF( cpu_pwr_status, pg_vddq, 4, 1) -FLD_RAW_RO_DEF( cpu_pwr_status, pg_vcc_ref, 3, 1) -FLD_RAW_RO_DEF( cpu_pwr_status, pg_v1p05, 2, 1) -FLD_RAW_RO_DEF( cpu_pwr_status, pg_v1p8, 1, 1) -FLD_RAW_RO_DEF( cpu_pwr_status, pg_v2p5, 0, 1) - -FLD_RAW_RO_DEF( sys_reboot_cause, sys_reboot_cause_fld,0, 8) - -#endif /* __SYSTEM_CPLD_REG */ diff --git a/packages/platforms/mitac/x86-64/ly1200-b32h0-c3/modules/builds/system_cpld_sysfs.h b/packages/platforms/mitac/x86-64/ly1200-b32h0-c3/modules/builds/system_cpld_sysfs.h deleted file mode 100644 index 71a15e8c6..000000000 --- a/packages/platforms/mitac/x86-64/ly1200-b32h0-c3/modules/builds/system_cpld_sysfs.h +++ /dev/null @@ -1,78 +0,0 @@ -#ifndef __SYSTEM_CPLD_SYSFS -#define __SYSTEM_CPLD_SYSFS - -/* generic CPLD sysfs file definition macros */ -#define SYSFS_RAW_RO_ATTR_DEF(field) \ -struct device_attribute field \ - = __ATTR(field, S_IRUGO, system_cpld_##field##_raw_read, NULL); - -#define SYSFS_RAW_RW_ATTR_DEF(field) \ -struct device_attribute field \ - = __ATTR(field, S_IRUGO | S_IWUSR | S_IWGRP, system_cpld_##field##_raw_read, system_cpld_##field##_raw_write); - -#define SYSFS_MISC_RO_ATTR_DEF(field, _read) \ -struct device_attribute field \ - = __ATTR(field, S_IRUGO, _read, NULL); - -#define SYSFS_MISC_RW_ATTR_DEF(field, _read, _write) \ -struct device_attribute field \ - = __ATTR(field, S_IRUGO | S_IWUSR | S_IWGRP, _read, _write); - -#define SYSFS_ATTR_PTR(field) \ -&field.attr - - -/* declare system CPLD file system */ -SYSFS_RAW_RO_ATTR_DEF(mjr_rev) -SYSFS_RAW_RO_ATTR_DEF(mnr_rev) - -SYSFS_RAW_RW_ATTR_DEF(scrtch_reg) - -SYSFS_RAW_RO_ATTR_DEF(brd_rev) -SYSFS_RAW_RO_ATTR_DEF(brd_type) - -SYSFS_RAW_RO_ATTR_DEF(ssd_present) -SYSFS_RAW_RW_ATTR_DEF(spi_cs_sel) -SYSFS_RAW_RW_ATTR_DEF(rst_bios_switch) -SYSFS_RAW_RW_ATTR_DEF(cpld_upgrade_rst) - -SYSFS_RAW_RW_ATTR_DEF(cpld_spi_wp) -SYSFS_RAW_RW_ATTR_DEF(system_id_eeprom_wp) -SYSFS_RAW_RW_ATTR_DEF(spi_me_wp) -SYSFS_RAW_RW_ATTR_DEF(spi_bios_wp) -SYSFS_RAW_RW_ATTR_DEF(spi_bak_bios_wp) - -SYSFS_RAW_RW_ATTR_DEF(vrhot_irq_en) -SYSFS_RAW_RW_ATTR_DEF(cpu_thermtrip_irq_en) -SYSFS_RAW_RW_ATTR_DEF(temp_alert_irq_en) -SYSFS_RAW_RO_ATTR_DEF(vrhot_irq) -SYSFS_RAW_RO_ATTR_DEF(cpu_thermtrip_irq) -SYSFS_RAW_RO_ATTR_DEF(temp_alert_irq) - -SYSFS_RAW_RW_ATTR_DEF(wd_timer) -SYSFS_RAW_RW_ATTR_DEF(wd_en) -SYSFS_RAW_RW_ATTR_DEF(wd_punch) - -SYSFS_RAW_RW_ATTR_DEF(mb_rst_en) - -SYSFS_RAW_RO_ATTR_DEF(pwr_v3p3_en) -SYSFS_RAW_RO_ATTR_DEF(pwr_vcc_vnn_en) -SYSFS_RAW_RO_ATTR_DEF(pwr_vccsram_en) -SYSFS_RAW_RO_ATTR_DEF(pwr_vddq_en) -SYSFS_RAW_RO_ATTR_DEF(pwr_vcc_ref_en) -SYSFS_RAW_RO_ATTR_DEF(pwr_v1p05_en) -SYSFS_RAW_RO_ATTR_DEF(pwr_v1p8_en) -SYSFS_RAW_RO_ATTR_DEF(pwr_v2p5_en) - -SYSFS_RAW_RO_ATTR_DEF(pg_v3p3) -SYSFS_RAW_RO_ATTR_DEF(pg_vcc_vnn) -SYSFS_RAW_RO_ATTR_DEF(pg_vccsram) -SYSFS_RAW_RO_ATTR_DEF(pg_vddq) -SYSFS_RAW_RO_ATTR_DEF(pg_vcc_ref) -SYSFS_RAW_RO_ATTR_DEF(pg_v1p05) -SYSFS_RAW_RO_ATTR_DEF(pg_v1p8) -SYSFS_RAW_RO_ATTR_DEF(pg_v2p5) - -SYSFS_RAW_RO_ATTR_DEF(sys_reboot_cause_fld) - -#endif /* __SYSTEM_CPLD_SYSFS */ diff --git a/packages/platforms/mitac/x86-64/ly1200-b32h0-c3/modules/builds/x86-64-mitac-ly1200-b32h0-c3-cb_i2c.c b/packages/platforms/mitac/x86-64/ly1200-b32h0-c3/modules/builds/x86-64-mitac-ly1200-b32h0-c3-cb_i2c.c deleted file mode 100644 index 11fffe251..000000000 --- a/packages/platforms/mitac/x86-64/ly1200-b32h0-c3/modules/builds/x86-64-mitac-ly1200-b32h0-c3-cb_i2c.c +++ /dev/null @@ -1,163 +0,0 @@ -#include -#include -#include -#include "bms_i2c.h" - -#define BMS_CB_I2C_CLIENT_NUM 5 -#define BMS_CB_ADAPTER_BASE 0 - -static struct i2c_client *bms_cb_clients[BMS_CB_I2C_CLIENT_NUM] = {NULL}; -static int bms_cb_client_index = 0; - -static int __init __find_i2c_adap(struct device *dev, void *data) -{ - const char *name = data; - static const char *prefix = "i2c-"; - struct i2c_adapter *adapter; - - if (strncmp(dev_name(dev), prefix, strlen(prefix)) != 0) - { - return 0; - } - adapter = to_i2c_adapter(dev); - - return (strncmp(adapter->name, name, strlen(name)) == 0); -} - -static int __init find_i2c_adapter_num(enum i2c_adapter_type type) -{ - struct device *dev = NULL; - struct i2c_adapter *adapter; - const char *name = bms_i2c_adapter_names[type]; - - /* find the adapter by name */ - dev = bus_find_device(&i2c_bus_type, NULL, (void *)name, - __find_i2c_adap); - if (!dev) { - pr_err("%s: i2c adapter %s not found on system.\n", - __func__, name); - return -ENODEV; - } - adapter = to_i2c_adapter(dev); - - return adapter->nr; -} - - -static __init struct i2c_client *bms_cb_setup_spd( - struct i2c_adapter *adap, int addr) -{ - struct i2c_board_info info_spd = { - I2C_BOARD_INFO("spd", addr), - }; - - return i2c_new_device(adap, &info_spd); -} - - -static __init struct i2c_client *bms_cb_setup_eeprom_24c02( - struct i2c_adapter *adap, int addr) -{ - struct i2c_board_info info_spd = { - I2C_BOARD_INFO("24c02", addr), - }; - - return i2c_new_device(adap, &info_spd); -} - -static __init struct i2c_client *bms_cb_setup_tmp75( - struct i2c_adapter *adap, int addr) -{ - struct i2c_board_info info_spd = { - I2C_BOARD_INFO("tmp75", addr), - }; - - return i2c_new_device(adap, &info_spd); -} - -static __init struct i2c_client *bms_cb_setup_system_cpld(struct i2c_adapter *adap) -{ - struct i2c_board_info info = { - I2C_BOARD_INFO("system_cpld", 0x31), - }; - - return i2c_new_device(adap, &info); -} - -static int __init bms_cb_setup_devices_i801(void) -{ - struct i2c_adapter *adap; - int adap_num = find_i2c_adapter_num(I2C_ADAPTER_I801); - - if (adap_num < 0) - return adap_num; - - adap = i2c_get_adapter(adap_num); - if (!adap) { - pr_err("%s failed to get i2c adap %d.\n", __func__, adap_num); - goto exit; - } - - bms_cb_clients[bms_cb_client_index++] = bms_cb_setup_spd(adap, 0x50); - bms_cb_clients[bms_cb_client_index++] = bms_cb_setup_spd(adap, 0x52); - bms_cb_clients[bms_cb_client_index++] = bms_cb_setup_tmp75(adap, 0x4e); - -exit: - return 0; -} - -static int __init bms_cb_setup_devices_ismt(void) -{ - struct i2c_adapter *adap; - int adap_num = find_i2c_adapter_num(I2C_ADAPTER_ISMT); - - if (adap_num < 0) - return adap_num; - - adap = i2c_get_adapter(adap_num); - if (!adap) { - pr_err("%s failed to get i2c adap %d.\n", __func__, adap_num); - return 0; - } - - bms_cb_clients[bms_cb_client_index++] = bms_cb_setup_system_cpld(adap); - bms_cb_clients[bms_cb_client_index++] = bms_cb_setup_eeprom_24c02(adap, 0x56); - return 0; -} - -static int __init bms_cb_i2c_init(void) -{ - /* Initial bms_cb_slients array. */ - memset(bms_cb_clients, 0x0, BMS_CB_I2C_CLIENT_NUM); - - bms_cb_setup_devices_i801(); - mdelay(200); - bms_cb_setup_devices_ismt(); - - return 0; -} - - -static void __exit bms_cb_i2c_exit(void){ - int i; - - for (i=(bms_cb_client_index-1); i>=0; i--) { - if (bms_cb_clients[i]) { - i2c_unregister_device(bms_cb_clients[i]); - bms_cb_clients[i] = NULL; - } - } - - bms_cb_client_index = 0; - -} - - -module_init(bms_cb_i2c_init); -module_exit(bms_cb_i2c_exit); - - -MODULE_DESCRIPTION("mitac_ly1200_32x_cb_i2c driver"); -MODULE_AUTHOR("Eddy Weng "); -MODULE_LICENSE("GPL"); - diff --git a/packages/platforms/mitac/x86-64/ly1200-b32h0-c3/modules/builds/x86-64-mitac-ly1200-b32h0-c3-fb_i2c.c b/packages/platforms/mitac/x86-64/ly1200-b32h0-c3/modules/builds/x86-64-mitac-ly1200-b32h0-c3-fb_i2c.c deleted file mode 100644 index d228bc481..000000000 --- a/packages/platforms/mitac/x86-64/ly1200-b32h0-c3/modules/builds/x86-64-mitac-ly1200-b32h0-c3-fb_i2c.c +++ /dev/null @@ -1,153 +0,0 @@ -#include -#include -#include "bms_i2c.h" - -#define BMS_FB_I2C_CLIENT_NUM 3 - - -static struct i2c_client *bms_fb_clients[BMS_FB_I2C_CLIENT_NUM] = {NULL}; -static int bms_fb_client_index = 0; - -static int __init __find_i2c_adap(struct device *dev, void *data) -{ - const char *name = data; - static const char *prefix = "i2c-"; - struct i2c_adapter *adapter; - - if (strncmp(dev_name(dev), prefix, strlen(prefix)) != 0) - { - return 0; - } - adapter = to_i2c_adapter(dev); - - return (strncmp(adapter->name, name, strlen(name)) == 0); -} - -static int __init find_i2c_adapter_num(enum i2c_adapter_type type) -{ - struct device *dev = NULL; - struct i2c_adapter *adapter; - const char *name = bms_i2c_adapter_names[type]; - - /* find the adapter by name */ - dev = bus_find_device(&i2c_bus_type, NULL, (void *)name, - __find_i2c_adap); - if (!dev) { - pr_err("%s: i2c adapter %s not found on system.\n", - __func__, name); - return -ENODEV; - } - adapter = to_i2c_adapter(dev); - - return adapter->nr; -} - -static int __init find_i2c_mux_adapter_num(int parent_num, int num) -{ - struct device *dev = NULL; - struct i2c_adapter *adapter; - char name[48]; - - snprintf(name, sizeof(name), "i2c-%d-mux (chan_id %d)", - parent_num, num); - /* find the adapter by name */ - dev = bus_find_device(&i2c_bus_type, NULL, (void *)name, - __find_i2c_adap); - if (!dev) { - pr_err("%s: i2c adapter %s not found on system.\n", - __func__, name); - return -ENODEV; - } - adapter = to_i2c_adapter(dev); - - return adapter->nr; -} - -static __init struct i2c_client *bms_fb_setup_tmp75( - struct i2c_adapter *adap, int addr) -{ - struct i2c_board_info info_spd = { - I2C_BOARD_INFO("tmp75", addr), - }; - - return i2c_new_device(adap, &info_spd); -} - -static __init struct i2c_client *bms_fb_setup_max31790( - struct i2c_adapter *adap, int addr) -{ - struct i2c_board_info info_spd = { - I2C_BOARD_INFO("max31790", addr), - }; - - return i2c_new_device(adap, &info_spd); -} - -static int __init bms_fb_setup_devices(void) -{ - struct i2c_adapter *adap; - int adap_num; - int parent_num; - - parent_num = find_i2c_adapter_num(I2C_ADAPTER_ISMT); - if (parent_num < 0) - return parent_num; - - /* Mux chan1 steup */ - adap_num = find_i2c_mux_adapter_num(parent_num, I2C_STAGE1_MUX_CHAN1); - if (adap_num >= 0){ - adap = i2c_get_adapter(adap_num); - if(adap) { - bms_fb_clients[bms_fb_client_index++] = bms_fb_setup_max31790(adap, 0x20); - bms_fb_clients[bms_fb_client_index++] = bms_fb_setup_max31790(adap, 0x23); - }else{ - pr_err("%s failed to get i2c adap %d.\n", __func__, adap_num); - } - }else{ - pr_err("%s failed to find i2c mux adap number %d.\n", __func__, I2C_STAGE1_MUX_CHAN1); - } - - adap_num = find_i2c_mux_adapter_num(parent_num, I2C_STAGE1_MUX_CHAN2); - if (adap_num >= 0){ - adap = i2c_get_adapter(adap_num); - if(adap) { - bms_fb_clients[bms_fb_client_index++] = bms_fb_setup_tmp75(adap, 0x4d); - }else{ - pr_err("%s failed to get i2c adap %d.\n", __func__, adap_num); - } - }else{ - pr_err("%s failed to find i2c mux adap number %d.\n", __func__, I2C_STAGE1_MUX_CHAN2); - } - - return 0; -} - -static int __init bms_fb_i2c_init(void) -{ - bms_fb_setup_devices(); - - return 0; -} - -static void __exit bms_fb_i2c_exit(void){ - int i; - - for (i=(bms_fb_client_index-1); i>=0; i--) { - if (bms_fb_clients[i]) { - i2c_unregister_device(bms_fb_clients[i]); - bms_fb_clients[i] = NULL; - } - } - - bms_fb_client_index = 0; - -} - -module_init(bms_fb_i2c_init); -module_exit(bms_fb_i2c_exit); - - -MODULE_DESCRIPTION("mitac_ly1200_32x_fb_i2c driver"); -MODULE_AUTHOR("Eddy Weng "); -MODULE_LICENSE("GPL"); - diff --git a/packages/platforms/mitac/x86-64/ly1200-b32h0-c3/modules/builds/x86-64-mitac-ly1200-b32h0-c3-fb_module_i2c.c b/packages/platforms/mitac/x86-64/ly1200-b32h0-c3/modules/builds/x86-64-mitac-ly1200-b32h0-c3-fb_module_i2c.c deleted file mode 100644 index 174dba197..000000000 --- a/packages/platforms/mitac/x86-64/ly1200-b32h0-c3/modules/builds/x86-64-mitac-ly1200-b32h0-c3-fb_module_i2c.c +++ /dev/null @@ -1,138 +0,0 @@ -#include -#include -#include "bms_i2c.h" - -#define BMS_FB_MODULE_I2C_CLIENT_NUM 6 - -static struct i2c_client *bms_fb_module_clients[BMS_FB_MODULE_I2C_CLIENT_NUM] = {NULL}; -static int bms_fb_module_client_index = 0; - -static int __init __find_i2c_adap(struct device *dev, void *data) -{ - const char *name = data; - static const char *prefix = "i2c-"; - struct i2c_adapter *adapter; - - if (strncmp(dev_name(dev), prefix, strlen(prefix)) != 0) - { - return 0; - } - adapter = to_i2c_adapter(dev); - - return (strncmp(adapter->name, name, strlen(name)) == 0); -} - -static int __init find_i2c_adapter_num(enum i2c_adapter_type type) -{ - struct device *dev = NULL; - struct i2c_adapter *adapter; - const char *name = bms_i2c_adapter_names[type]; - - /* find the adapter by name */ - dev = bus_find_device(&i2c_bus_type, NULL, (void *)name, - __find_i2c_adap); - if (!dev) { - pr_err("%s: i2c adapter %s not found on system.\n", - __func__, name); - return -ENODEV; - } - adapter = to_i2c_adapter(dev); - - return adapter->nr; -} - -static int __init find_i2c_mux_adapter_num(int parent_num, int num) -{ - struct device *dev = NULL; - struct i2c_adapter *adapter; - char name[48]; - - snprintf(name, sizeof(name), "i2c-%d-mux (chan_id %d)", - parent_num, num); - /* find the adapter by name */ - dev = bus_find_device(&i2c_bus_type, NULL, (void *)name, - __find_i2c_adap); - if (!dev) { - pr_err("%s: i2c adapter %s not found on system.\n", - __func__, name); - return -ENODEV; - } - adapter = to_i2c_adapter(dev); - - return adapter->nr; -} - - -static __init struct i2c_client *bms_fb_module_setup_eeprom_24c02( - struct i2c_adapter *adap, int addr) -{ - struct i2c_board_info info_spd = { - I2C_BOARD_INFO("24c02", addr), - }; - - return i2c_new_device(adap, &info_spd); -} - -static int __init bms_fb_module_setup_devices(void) -{ - struct i2c_adapter *adap; - int adap_num; - int parent_num; - - parent_num = find_i2c_adapter_num(I2C_ADAPTER_ISMT); - if (parent_num < 0) - return parent_num; - - adap_num = find_i2c_mux_adapter_num(parent_num, I2C_STAGE1_MUX_CHAN1); - if (adap_num < 0) - return adap_num; - - adap = i2c_get_adapter(adap_num); - if (!adap) { - pr_err("%s failed to get i2c adap %d.\n", __func__, adap_num); - goto exit; - } - - bms_fb_module_clients[bms_fb_module_client_index++] = bms_fb_module_setup_eeprom_24c02(adap, 0x50); - bms_fb_module_clients[bms_fb_module_client_index++] = bms_fb_module_setup_eeprom_24c02(adap, 0x51); - bms_fb_module_clients[bms_fb_module_client_index++] = bms_fb_module_setup_eeprom_24c02(adap, 0x52); - bms_fb_module_clients[bms_fb_module_client_index++] = bms_fb_module_setup_eeprom_24c02(adap, 0x53); - bms_fb_module_clients[bms_fb_module_client_index++] = bms_fb_module_setup_eeprom_24c02(adap, 0x54); - bms_fb_module_clients[bms_fb_module_client_index++] = bms_fb_module_setup_eeprom_24c02(adap, 0x55); - -exit: - return 0; -} - -static int __init bms_fb_module_i2c_init(void) -{ - /* Initial bms_sb_slients array. */ - memset(bms_fb_module_clients, 0x0, BMS_FB_MODULE_I2C_CLIENT_NUM); - - bms_fb_module_setup_devices(); - - return 0; -} - -static void __exit bms_fb_module_i2c_exit(void){ - int i; - - for (i=(bms_fb_module_client_index-1); i>=0; i--) { - if (bms_fb_module_clients[i]) { - i2c_unregister_device(bms_fb_module_clients[i]); - bms_fb_module_clients[i] = NULL; - } - } - - bms_fb_module_client_index = 0; - -} - -module_init(bms_fb_module_i2c_init); -module_exit(bms_fb_module_i2c_exit); - - -MODULE_DESCRIPTION("mitac_ly1200_32x_fb_module_i2c driver"); -MODULE_AUTHOR("Eddy Weng "); -MODULE_LICENSE("GPL"); - diff --git a/packages/platforms/mitac/x86-64/ly1200-b32h0-c3/modules/builds/x86-64-mitac-ly1200-b32h0-c3-fse000.c b/packages/platforms/mitac/x86-64/ly1200-b32h0-c3/modules/builds/x86-64-mitac-ly1200-b32h0-c3-fse000.c deleted file mode 100644 index 276912745..000000000 --- a/packages/platforms/mitac/x86-64/ly1200-b32h0-c3/modules/builds/x86-64-mitac-ly1200-b32h0-c3-fse000.c +++ /dev/null @@ -1,1787 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include <../drivers/hwmon/pmbus/pmbus.h> -#include - -/* - * Number of additional attribute pointers to allocate - * with each call to krealloc - */ -#define PMBUS_ATTR_ALLOC_SIZE 32 - -/* - * Index into status register array, per status register group - */ -#define PB_STATUS_BASE 0 -#define PB_STATUS_VOUT_BASE (PB_STATUS_BASE + PMBUS_PAGES) -#define PB_STATUS_IOUT_BASE (PB_STATUS_VOUT_BASE + PMBUS_PAGES) -#define PB_STATUS_FAN_BASE (PB_STATUS_IOUT_BASE + PMBUS_PAGES) -#define PB_STATUS_FAN34_BASE (PB_STATUS_FAN_BASE + PMBUS_PAGES) -#define PB_STATUS_TEMP_BASE (PB_STATUS_FAN34_BASE + PMBUS_PAGES) -#define PB_STATUS_INPUT_BASE (PB_STATUS_TEMP_BASE + PMBUS_PAGES) -#define PB_STATUS_VMON_BASE (PB_STATUS_INPUT_BASE + 1) - -#define PB_NUM_STATUS_REG (PB_STATUS_VMON_BASE + 1) - -#define PMBUS_NAME_SIZE 24 -#define PMBUS_BLOCK_READ_SIZE 32 - -struct pmbus_sensor { - struct pmbus_sensor *next; - char name[PMBUS_NAME_SIZE]; /* sysfs sensor name */ - struct device_attribute attribute; - u8 page; /* page number */ - u16 reg; /* register */ - enum pmbus_sensor_classes class; /* sensor class */ - bool update; /* runtime sensor update needed */ - int data; /* Sensor data. - Negative if there was a read error */ -}; -#define to_pmbus_sensor(_attr) \ - container_of(_attr, struct pmbus_sensor, attribute) - -struct pmbus_st { - char name[PMBUS_NAME_SIZE]; /* sysfs boolean name */ - struct sensor_device_attribute attribute; - u16 base; -}; -#define to_pmbus_status(_attr) \ - container_of(_attr, struct pmbus_st, attribute) - -struct pmbus_mfr { - struct pmbus_mfr *next; - char name[PMBUS_NAME_SIZE]; /* sysfs sensor name */ - struct device_attribute attribute; - u8 page; /* page number */ - u16 reg; /* register */ - int data; /* Sensor data. - Negative if there was a read error */ - char data_buf[PMBUS_BLOCK_READ_SIZE]; -}; -#define to_pmbus_mfr(_attr) \ - container_of(_attr, struct pmbus_mfr, attribute) - -struct pmbus_boolean { - char name[PMBUS_NAME_SIZE]; /* sysfs boolean name */ - struct sensor_device_attribute attribute; - struct pmbus_sensor *s1; - struct pmbus_sensor *s2; -}; -#define to_pmbus_boolean(_attr) \ - container_of(_attr, struct pmbus_boolean, attribute) - -struct pmbus_label { - char name[PMBUS_NAME_SIZE]; /* sysfs label name */ - struct device_attribute attribute; - char label[PMBUS_NAME_SIZE]; /* label */ -}; -#define to_pmbus_label(_attr) \ - container_of(_attr, struct pmbus_label, attribute) - -struct pmbus_data { - struct device *dev; - struct device *hwmon_dev; - - u32 flags; /* from platform data */ - - int exponent[PMBUS_PAGES]; - /* linear mode: exponent for output voltages */ - - const struct pmbus_driver_info *info; - - int max_attributes; - int num_attributes; - struct attribute_group group; - const struct attribute_group *groups[2]; - - struct pmbus_sensor *sensors; - struct pmbus_mfr *mfr; - - struct mutex update_lock; - bool valid; - unsigned long last_updated; /* in jiffies */ - - /* - * A single status register covers multiple attributes, - * so we keep them all together. - */ - u8 status[PB_NUM_STATUS_REG]; - u8 status_register; - - u8 currpage; -}; - -void pmbus_clear_cache(struct i2c_client *client) -{ - struct pmbus_data *data = i2c_get_clientdata(client); - - data->valid = false; -} - -int pmbus_set_page(struct i2c_client *client, int page) -{ - struct pmbus_data *data = i2c_get_clientdata(client); - int rv = 0; - int newpage; - - if (page != data->currpage) { - rv = i2c_smbus_write_byte_data(client, PMBUS_PAGE, page); - newpage = i2c_smbus_read_byte_data(client, PMBUS_PAGE); - if (newpage != page) - rv = -EIO; - else - data->currpage = page; - } - return rv; -} - -int pmbus_write_byte(struct i2c_client *client, int page, u8 value) -{ - int rv; - - if (page >= 0) { - rv = pmbus_set_page(client, page); - if (rv < 0) - return rv; - } - - return i2c_smbus_write_byte(client, value); -} - -/* - * _pmbus_write_byte() is similar to pmbus_write_byte(), but checks if - * a device specific mapping function exists and calls it if necessary. - */ -static int _pmbus_write_byte(struct i2c_client *client, int page, u8 value) -{ - struct pmbus_data *data = i2c_get_clientdata(client); - const struct pmbus_driver_info *info = data->info; - int status; - - if (info->write_byte) { - status = info->write_byte(client, page, value); - if (status != -ENODATA) - return status; - } - return pmbus_write_byte(client, page, value); -} - -int pmbus_write_word_data(struct i2c_client *client, int page, u8 reg, u16 word) -{ - int rv; - - rv = pmbus_set_page(client, page); - if (rv < 0) - return rv; - - return i2c_smbus_write_word_data(client, reg, word); -} - -/* - * _pmbus_write_word_data() is similar to pmbus_write_word_data(), but checks if - * a device specific mapping function exists and calls it if necessary. - */ -static int _pmbus_write_word_data(struct i2c_client *client, int page, int reg, - u16 word) -{ - struct pmbus_data *data = i2c_get_clientdata(client); - const struct pmbus_driver_info *info = data->info; - int status; - - if (info->write_word_data) { - status = info->write_word_data(client, page, reg, word); - if (status != -ENODATA) - return status; - } - if (reg >= PMBUS_VIRT_BASE) - return -ENXIO; - return pmbus_write_word_data(client, page, reg, word); -} - -int pmbus_read_word_data(struct i2c_client *client, int page, u8 reg) -{ - int rv; - - rv = pmbus_set_page(client, page); - if (rv < 0) - return rv; - - return i2c_smbus_read_word_data(client, reg); -} - -int pmbus_read_block_data(struct i2c_client *client, u8 reg, u8* value) -{ - return i2c_smbus_read_block_data(client, reg, value); -} - -static int _pmbus_read_block_data(struct i2c_client *client, int page, int reg, u8* value) -{ - int rv; - - rv = pmbus_set_page(client, page); - if (rv < 0) - return rv; - return pmbus_read_block_data(client, reg, value); -} - -/* - * _pmbus_read_word_data() is similar to pmbus_read_word_data(), but checks if - * a device specific mapping function exists and calls it if necessary. - */ -static int _pmbus_read_word_data(struct i2c_client *client, int page, int reg) -{ - struct pmbus_data *data = i2c_get_clientdata(client); - const struct pmbus_driver_info *info = data->info; - int status; - - if (info->read_word_data) { - status = info->read_word_data(client, page, reg); - if (status != -ENODATA) - return status; - } - if (reg >= PMBUS_VIRT_BASE) - return -ENXIO; - return pmbus_read_word_data(client, page, reg); -} - -int pmbus_read_byte_data(struct i2c_client *client, int page, u8 reg) -{ - int rv; - - if (page >= 0) { - rv = pmbus_set_page(client, page); - if (rv < 0) - return rv; - } - - return i2c_smbus_read_byte_data(client, reg); -} - -/* - * _pmbus_read_byte_data() is similar to pmbus_read_byte_data(), but checks if - * a device specific mapping function exists and calls it if necessary. - */ -static int _pmbus_read_byte_data(struct i2c_client *client, int page, int reg) -{ - struct pmbus_data *data = i2c_get_clientdata(client); - const struct pmbus_driver_info *info = data->info; - int status; - - if (info->read_byte_data) { - status = info->read_byte_data(client, page, reg); - if (status != -ENODATA) - return status; - } - return pmbus_read_byte_data(client, page, reg); -} - -static void pmbus_clear_fault_page(struct i2c_client *client, int page) -{ - _pmbus_write_byte(client, page, PMBUS_CLEAR_FAULTS); -} - -void pmbus_clear_faults(struct i2c_client *client) -{ - struct pmbus_data *data = i2c_get_clientdata(client); - int i; - - for (i = 0; i < data->info->pages; i++) - pmbus_clear_fault_page(client, i); -} - -static int pmbus_check_status_cml(struct i2c_client *client) -{ - struct pmbus_data *data = i2c_get_clientdata(client); - int status, status2; - - status = _pmbus_read_byte_data(client, -1, data->status_register); - if (status < 0 || (status & PB_STATUS_CML)) { - status2 = _pmbus_read_byte_data(client, -1, PMBUS_STATUS_CML); - if (status2 < 0 || (status2 & PB_CML_FAULT_INVALID_COMMAND)) - return -EIO; - } - return 0; -} - -static bool pmbus_check_register(struct i2c_client *client, - int (*func)(struct i2c_client *client, - int page, int reg), - int page, int reg) -{ - int rv; - struct pmbus_data *data = i2c_get_clientdata(client); - - rv = func(client, page, reg); - if (rv >= 0 && !(data->flags & PMBUS_SKIP_STATUS_CHECK)) - rv = pmbus_check_status_cml(client); - pmbus_clear_fault_page(client, -1); - return rv >= 0; -} - -bool pmbus_check_byte_register(struct i2c_client *client, int page, int reg) -{ - return pmbus_check_register(client, _pmbus_read_byte_data, page, reg); -} - -bool pmbus_check_word_register(struct i2c_client *client, int page, int reg) -{ - return pmbus_check_register(client, _pmbus_read_word_data, page, reg); -} - -const struct pmbus_driver_info *pmbus_get_driver_info(struct i2c_client *client) -{ - struct pmbus_data *data = i2c_get_clientdata(client); - - return data->info; -} - -static struct _pmbus_status { - u32 func; - u16 base; - u16 reg; -} pmbus_status[] = { - { PMBUS_HAVE_STATUS_VOUT, PB_STATUS_VOUT_BASE, PMBUS_STATUS_VOUT }, - { PMBUS_HAVE_STATUS_IOUT, PB_STATUS_IOUT_BASE, PMBUS_STATUS_IOUT }, - { PMBUS_HAVE_STATUS_TEMP, PB_STATUS_TEMP_BASE, - PMBUS_STATUS_TEMPERATURE }, - { PMBUS_HAVE_STATUS_FAN12, PB_STATUS_FAN_BASE, PMBUS_STATUS_FAN_12 }, - { PMBUS_HAVE_STATUS_FAN34, PB_STATUS_FAN34_BASE, PMBUS_STATUS_FAN_34 }, -}; - -static struct _pmbus_status_reg { - char name[PMBUS_NAME_SIZE]; - u16 base; - u8 offset; -} pmbus_status_reg[] = { - { "vout_ov_fault", PB_STATUS_VOUT_BASE, PB_VOLTAGE_UV_FAULT}, - { "vout_uv_fault", PB_STATUS_VOUT_BASE, PB_VOLTAGE_OV_FAULT}, - { "ot_fault", PB_STATUS_TEMP_BASE, PB_TEMP_OT_FAULT}, - { "ot_warning", PB_STATUS_TEMP_BASE, PB_TEMP_OT_WARNING}, - { "vin_uv_warning", PB_STATUS_INPUT_BASE, PB_VOLTAGE_UV_WARNING}, - { "vin_uv_fault", PB_STATUS_INPUT_BASE, PB_VOLTAGE_UV_FAULT}, -}; - -static struct _pmbus_mfr_reg { - char name[PMBUS_NAME_SIZE]; - u16 reg; -} pmbus_mfr_reg[] = { - { "mfr_id", PMBUS_MFR_ID}, - { "mfr_model", PMBUS_MFR_MODEL}, - { "mfr_revision", PMBUS_MFR_REVISION}, - { "mfr_location", PMBUS_MFR_LOCATION}, - { "mfr_date", PMBUS_MFR_DATE}, - { "mfr_serial", PMBUS_MFR_SERIAL}, -}; - -static struct pmbus_data *pmbus_update_device(struct device *dev) -{ - struct i2c_client *client = to_i2c_client(dev->parent); - struct pmbus_data *data = i2c_get_clientdata(client); - const struct pmbus_driver_info *info = data->info; - struct pmbus_sensor *sensor; - struct pmbus_mfr *mfr; - - mutex_lock(&data->update_lock); - if (time_after(jiffies, data->last_updated + HZ) || !data->valid) { - int i, j; - - for (i = 0; i < info->pages; i++) { - data->status[PB_STATUS_BASE + i] - = _pmbus_read_byte_data(client, i, - data->status_register); - for (j = 0; j < ARRAY_SIZE(pmbus_status); j++) { - struct _pmbus_status *s = &pmbus_status[j]; - - if (!(info->func[i] & s->func)) - continue; - data->status[s->base + i] - = _pmbus_read_byte_data(client, i, - s->reg); - } - } - - if (info->func[0] & PMBUS_HAVE_STATUS_INPUT) - data->status[PB_STATUS_INPUT_BASE] - = _pmbus_read_byte_data(client, 0, - PMBUS_STATUS_INPUT); - - if (info->func[0] & PMBUS_HAVE_STATUS_VMON) - data->status[PB_STATUS_VMON_BASE] - = _pmbus_read_byte_data(client, 0, - PMBUS_VIRT_STATUS_VMON); - - for (sensor = data->sensors; sensor; sensor = sensor->next) { - if (!data->valid || sensor->update) - sensor->data - = _pmbus_read_word_data(client, - sensor->page, - sensor->reg); - } - - /* read mfg data */ - for (mfr = data->mfr; mfr; mfr = mfr->next) { - mfr->data = _pmbus_read_block_data(client, mfr->page, mfr->reg, mfr->data_buf); - } - - pmbus_clear_faults(client); - data->last_updated = jiffies; - data->valid = 1; - } - mutex_unlock(&data->update_lock); - return data; -} - -/* - * Convert linear sensor values to milli- or micro-units - * depending on sensor type. - */ -static long pmbus_reg2data_linear(struct pmbus_data *data, - struct pmbus_sensor *sensor) -{ - s16 exponent; - s32 mantissa; - long val; - - if (sensor->class == PSC_VOLTAGE_OUT) { /* LINEAR16 */ - exponent = data->exponent[sensor->page]; - mantissa = (u16) sensor->data; - } else { /* LINEAR11 */ - exponent = ((s16)sensor->data) >> 11; - mantissa = ((s16)((sensor->data & 0x7ff) << 5)) >> 5; - } - - val = mantissa; - - /* scale result to milli-units for all sensors except fans */ - if (sensor->class != PSC_FAN) - val = val * 1000L; - - /* scale result to micro-units for power sensors */ - if (sensor->class == PSC_POWER) - val = val * 1000L; - - if (exponent >= 0) - val <<= exponent; - else - val >>= -exponent; - - return val; -} - -/* - * Convert direct sensor values to milli- or micro-units - * depending on sensor type. - */ -static long pmbus_reg2data_direct(struct pmbus_data *data, - struct pmbus_sensor *sensor) -{ - long val = (s16) sensor->data; - long m, b, R; - - m = data->info->m[sensor->class]; - b = data->info->b[sensor->class]; - R = data->info->R[sensor->class]; - - if (m == 0) - return 0; - - /* X = 1/m * (Y * 10^-R - b) */ - R = -R; - /* scale result to milli-units for everything but fans */ - if (sensor->class != PSC_FAN) { - R += 3; - b *= 1000; - } - - /* scale result to micro-units for power sensors */ - if (sensor->class == PSC_POWER) { - R += 3; - b *= 1000; - } - - while (R > 0) { - val *= 10; - R--; - } - while (R < 0) { - val = DIV_ROUND_CLOSEST(val, 10); - R++; - } - - return (val - b) / m; -} - -/* - * Convert VID sensor values to milli- or micro-units - * depending on sensor type. - * We currently only support VR11. - */ -static long pmbus_reg2data_vid(struct pmbus_data *data, - struct pmbus_sensor *sensor) -{ - long val = sensor->data; - - if (val < 0x02 || val > 0xb2) - return 0; - return DIV_ROUND_CLOSEST(160000 - (val - 2) * 625, 100); -} - -static long pmbus_reg2data(struct pmbus_data *data, struct pmbus_sensor *sensor) -{ - long val; - - switch (data->info->format[sensor->class]) { - case direct: - val = pmbus_reg2data_direct(data, sensor); - break; - case vid: - val = pmbus_reg2data_vid(data, sensor); - break; - case linear: - default: - val = pmbus_reg2data_linear(data, sensor); - break; - } - return val; -} - -#define MAX_MANTISSA (1023 * 1000) -#define MIN_MANTISSA (511 * 1000) - -static u16 pmbus_data2reg_linear(struct pmbus_data *data, - struct pmbus_sensor *sensor, long val) -{ - s16 exponent = 0, mantissa; - bool negative = false; - - /* simple case */ - if (val == 0) - return 0; - - if (sensor->class == PSC_VOLTAGE_OUT) { - /* LINEAR16 does not support negative voltages */ - if (val < 0) - return 0; - - /* - * For a static exponents, we don't have a choice - * but to adjust the value to it. - */ - if (data->exponent[sensor->page] < 0) - val <<= -data->exponent[sensor->page]; - else - val >>= data->exponent[sensor->page]; - val = DIV_ROUND_CLOSEST(val, 1000); - return val & 0xffff; - } - - if (val < 0) { - negative = true; - val = -val; - } - - /* Power is in uW. Convert to mW before converting. */ - if (sensor->class == PSC_POWER) - val = DIV_ROUND_CLOSEST(val, 1000L); - - /* - * For simplicity, convert fan data to milli-units - * before calculating the exponent. - */ - if (sensor->class == PSC_FAN) - val = val * 1000; - - /* Reduce large mantissa until it fits into 10 bit */ - while (val >= MAX_MANTISSA && exponent < 15) { - exponent++; - val >>= 1; - } - /* Increase small mantissa to improve precision */ - while (val < MIN_MANTISSA && exponent > -15) { - exponent--; - val <<= 1; - } - - /* Convert mantissa from milli-units to units */ - mantissa = DIV_ROUND_CLOSEST(val, 1000); - - /* Ensure that resulting number is within range */ - if (mantissa > 0x3ff) - mantissa = 0x3ff; - - /* restore sign */ - if (negative) - mantissa = -mantissa; - - /* Convert to 5 bit exponent, 11 bit mantissa */ - return (mantissa & 0x7ff) | ((exponent << 11) & 0xf800); -} - -static u16 pmbus_data2reg_direct(struct pmbus_data *data, - struct pmbus_sensor *sensor, long val) -{ - long m, b, R; - - m = data->info->m[sensor->class]; - b = data->info->b[sensor->class]; - R = data->info->R[sensor->class]; - - /* Power is in uW. Adjust R and b. */ - if (sensor->class == PSC_POWER) { - R -= 3; - b *= 1000; - } - - /* Calculate Y = (m * X + b) * 10^R */ - if (sensor->class != PSC_FAN) { - R -= 3; /* Adjust R and b for data in milli-units */ - b *= 1000; - } - val = val * m + b; - - while (R > 0) { - val *= 10; - R--; - } - while (R < 0) { - val = DIV_ROUND_CLOSEST(val, 10); - R++; - } - - return val; -} - -static u16 pmbus_data2reg_vid(struct pmbus_data *data, - struct pmbus_sensor *sensor, long val) -{ - val = clamp_val(val, 500, 1600); - - return 2 + DIV_ROUND_CLOSEST((1600 - val) * 100, 625); -} - -static u16 pmbus_data2reg(struct pmbus_data *data, - struct pmbus_sensor *sensor, long val) -{ - u16 regval; - - switch (data->info->format[sensor->class]) { - case direct: - regval = pmbus_data2reg_direct(data, sensor, val); - break; - case vid: - regval = pmbus_data2reg_vid(data, sensor, val); - break; - case linear: - default: - regval = pmbus_data2reg_linear(data, sensor, val); - break; - } - return regval; -} - -/* - * Return boolean calculated from converted data. - * defines a status register index and mask. - * The mask is in the lower 8 bits, the register index is in bits 8..23. - * - * The associated pmbus_boolean structure contains optional pointers to two - * sensor attributes. If specified, those attributes are compared against each - * other to determine if a limit has been exceeded. - * - * If the sensor attribute pointers are NULL, the function returns true if - * (status[reg] & mask) is true. - * - * If sensor attribute pointers are provided, a comparison against a specified - * limit has to be performed to determine the boolean result. - * In this case, the function returns true if v1 >= v2 (where v1 and v2 are - * sensor values referenced by sensor attribute pointers s1 and s2). - * - * To determine if an object exceeds upper limits, specify = . - * To determine if an object exceeds lower limits, specify = . - * - * If a negative value is stored in any of the referenced registers, this value - * reflects an error code which will be returned. - */ -static int pmbus_get_boolean(struct pmbus_data *data, struct pmbus_boolean *b, - int index) -{ - struct pmbus_sensor *s1 = b->s1; - struct pmbus_sensor *s2 = b->s2; - u16 reg = (index >> 8) & 0xffff; - u8 mask = index & 0xff; - int ret, status; - u8 regval; - - status = data->status[reg]; - if (status < 0) - return status; - - regval = status & mask; - if (!s1 && !s2) { - ret = !!regval; - } else if (!s1 || !s2) { - WARN(1, "Bad boolean descriptor %p: s1=%p, s2=%p\n", b, s1, s2); - return 0; - } else { - long v1, v2; - - if (s1->data < 0) - return s1->data; - if (s2->data < 0) - return s2->data; - - v1 = pmbus_reg2data(data, s1); - v2 = pmbus_reg2data(data, s2); - ret = !!(regval && v1 >= v2); - } - return ret; -} - -static ssize_t pmbus_show_boolean(struct device *dev, - struct device_attribute *da, char *buf) -{ - struct sensor_device_attribute *attr = to_sensor_dev_attr(da); - struct pmbus_boolean *boolean = to_pmbus_boolean(attr); - struct pmbus_data *data = pmbus_update_device(dev); - int val; - - val = pmbus_get_boolean(data, boolean, attr->index); - if (val < 0) - return val; - return snprintf(buf, PAGE_SIZE, "%d\n", val); -} - -static ssize_t pmbus_show_sensor(struct device *dev, - struct device_attribute *devattr, char *buf) -{ - struct pmbus_data *data = pmbus_update_device(dev); - struct pmbus_sensor *sensor = to_pmbus_sensor(devattr); - - if (sensor->data < 0) - return sensor->data; - - return snprintf(buf, PAGE_SIZE, "%ld\n", pmbus_reg2data(data, sensor)); -} - -static ssize_t pmbus_show_status(struct device *dev, - struct device_attribute *devattr, char *buf) -{ - struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); - struct pmbus_st *status = to_pmbus_status(attr); - struct pmbus_data *data = pmbus_update_device(dev); - - return snprintf(buf, PAGE_SIZE, "%u\n", !!(data->status[status->base] & attr->index)); -} - -static ssize_t pmbus_show_mfr(struct device *dev, - struct device_attribute *devattr, char *buf) -{ - struct pmbus_mfr *mfr; - - pmbus_update_device(dev); - mfr = to_pmbus_mfr(devattr); - - if (mfr->data < 0) - return mfr->data; - -#if LINUX_VERSION_CODE <= KERNEL_VERSION(3,16,49) - /* mfr->data[0] is data length, we don't want show data length when show command */ - return snprintf(buf, PAGE_SIZE, "%s\n", &mfr->data_buf[1]); -#else - return snprintf(buf, PAGE_SIZE, "%s\n", (char *)&mfr->data_buf); -#endif -} - -static ssize_t pmbus_set_sensor(struct device *dev, - struct device_attribute *devattr, - const char *buf, size_t count) -{ - struct i2c_client *client = to_i2c_client(dev->parent); - struct pmbus_data *data = i2c_get_clientdata(client); - struct pmbus_sensor *sensor = to_pmbus_sensor(devattr); - ssize_t rv = count; - long val = 0; - int ret; - u16 regval; - - if (kstrtol(buf, 10, &val) < 0) - return -EINVAL; - - mutex_lock(&data->update_lock); - regval = pmbus_data2reg(data, sensor, val); - ret = _pmbus_write_word_data(client, sensor->page, sensor->reg, regval); - if (ret < 0) - rv = ret; - else - sensor->data = regval; - mutex_unlock(&data->update_lock); - return rv; -} - -static ssize_t pmbus_show_label(struct device *dev, - struct device_attribute *da, char *buf) -{ - struct pmbus_label *label = to_pmbus_label(da); - - return snprintf(buf, PAGE_SIZE, "%s\n", label->label); -} - -static int pmbus_add_attribute(struct pmbus_data *data, struct attribute *attr) -{ - if (data->num_attributes >= data->max_attributes - 1) { - int new_max_attrs = data->max_attributes + PMBUS_ATTR_ALLOC_SIZE; - void *new_attrs = krealloc(data->group.attrs, - new_max_attrs * sizeof(void *), - GFP_KERNEL); - if (!new_attrs) - return -ENOMEM; - data->group.attrs = new_attrs; - data->max_attributes = new_max_attrs; - } - - data->group.attrs[data->num_attributes++] = attr; - data->group.attrs[data->num_attributes] = NULL; - return 0; -} - -static void pmbus_dev_attr_init(struct device_attribute *dev_attr, - const char *name, - umode_t mode, - ssize_t (*show)(struct device *dev, - struct device_attribute *attr, - char *buf), - ssize_t (*store)(struct device *dev, - struct device_attribute *attr, - const char *buf, size_t count)) -{ - sysfs_attr_init(&dev_attr->attr); - dev_attr->attr.name = name; - dev_attr->attr.mode = mode; - dev_attr->show = show; - dev_attr->store = store; -} - -static void pmbus_attr_init(struct sensor_device_attribute *a, - const char *name, - umode_t mode, - ssize_t (*show)(struct device *dev, - struct device_attribute *attr, - char *buf), - ssize_t (*store)(struct device *dev, - struct device_attribute *attr, - const char *buf, size_t count), - int idx) -{ - pmbus_dev_attr_init(&a->dev_attr, name, mode, show, store); - a->index = idx; -} - -static int pmbus_add_boolean(struct pmbus_data *data, - const char *name, const char *type, int seq, - struct pmbus_sensor *s1, - struct pmbus_sensor *s2, - u16 reg, u8 mask) -{ - struct pmbus_boolean *boolean; - struct sensor_device_attribute *a; - - boolean = devm_kzalloc(data->dev, sizeof(*boolean), GFP_KERNEL); - if (!boolean) - return -ENOMEM; - - a = &boolean->attribute; - - snprintf(boolean->name, sizeof(boolean->name), "%s%d_%s", - name, seq, type); - boolean->s1 = s1; - boolean->s2 = s2; - pmbus_attr_init(a, boolean->name, S_IRUGO, pmbus_show_boolean, NULL, - (reg << 8) | mask); - - return pmbus_add_attribute(data, &a->dev_attr.attr); -} - -static struct pmbus_sensor *pmbus_add_sensor(struct pmbus_data *data, - const char *name, const char *type, - int seq, int page, int reg, - enum pmbus_sensor_classes class, - bool update, bool readonly) -{ - struct pmbus_sensor *sensor; - struct device_attribute *a; - - sensor = devm_kzalloc(data->dev, sizeof(*sensor), GFP_KERNEL); - if (!sensor) - return NULL; - a = &sensor->attribute; - - snprintf(sensor->name, sizeof(sensor->name), "%s%d_%s", - name, seq, type); - sensor->page = page; - sensor->reg = reg; - sensor->class = class; - sensor->update = update; - pmbus_dev_attr_init(a, sensor->name, - readonly ? S_IRUGO : S_IRUGO | S_IWUSR, - pmbus_show_sensor, pmbus_set_sensor); - - if (pmbus_add_attribute(data, &a->attr)) - return NULL; - - sensor->next = data->sensors; - data->sensors = sensor; - - return sensor; -} - -static int pmbus_add_status(struct pmbus_data *data, - const char *name, u16 base, - u8 offset) -{ - struct pmbus_st *status; - struct sensor_device_attribute *a; - - status = devm_kzalloc(data->dev, sizeof(*status), GFP_KERNEL); - if (!status) - return -ENOMEM; - - a = &status->attribute; - - snprintf(status->name, sizeof(status->name), "%s", name); - - status->base = base; - - pmbus_attr_init(a, status->name, S_IRUGO, - pmbus_show_status, NULL, offset); - - return pmbus_add_attribute(data, &a->dev_attr.attr); -} - -static struct pmbus_mfr *pmbus_add_mfr(struct pmbus_data *data, - const char *name, - int page, int reg) -{ - struct pmbus_mfr *mfr; - struct device_attribute *a; - - mfr = devm_kzalloc(data->dev, sizeof(*mfr), GFP_KERNEL); - if (!mfr) - return NULL; - a = &mfr->attribute; - - snprintf(mfr->name, sizeof(mfr->name), "%s", name); - mfr->page = page; - mfr->reg = reg; - pmbus_dev_attr_init(a, mfr->name, S_IRUGO, - pmbus_show_mfr, NULL); - - if (pmbus_add_attribute(data, &a->attr)) - return NULL; - - mfr->next = data->mfr; - data->mfr = mfr; - - return mfr; -} - -static int pmbus_add_label(struct pmbus_data *data, - const char *name, int seq, - const char *lstring, int index) -{ - struct pmbus_label *label; - struct device_attribute *a; - - label = devm_kzalloc(data->dev, sizeof(*label), GFP_KERNEL); - if (!label) - return -ENOMEM; - - a = &label->attribute; - - snprintf(label->name, sizeof(label->name), "%s%d_label", name, seq); - if (!index) - strncpy(label->label, lstring, sizeof(label->label) - 1); - else - snprintf(label->label, sizeof(label->label), "%s%d", lstring, - index); - - pmbus_dev_attr_init(a, label->name, S_IRUGO, pmbus_show_label, NULL); - return pmbus_add_attribute(data, &a->attr); -} - -/* - * Search for attributes. Allocate sensors, booleans, and labels as needed. - */ - -/* - * The pmbus_limit_attr structure describes a single limit attribute - * and its associated alarm attribute. - */ -struct pmbus_limit_attr { - u16 reg; /* Limit register */ - u16 sbit; /* Alarm attribute status bit */ - bool update; /* True if register needs updates */ - bool low; /* True if low limit; for limits with compare - functions only */ - const char *attr; /* Attribute name */ - const char *alarm; /* Alarm attribute name */ -}; - -/* - * The pmbus_sensor_attr structure describes one sensor attribute. This - * description includes a reference to the associated limit attributes. - */ -struct pmbus_sensor_attr { - u16 reg; /* sensor register */ - u8 gbit; /* generic status bit */ - u8 nlimit; /* # of limit registers */ - enum pmbus_sensor_classes class;/* sensor class */ - const char *label; /* sensor label */ - bool paged; /* true if paged sensor */ - bool update; /* true if update needed */ - bool compare; /* true if compare function needed */ - u32 func; /* sensor mask */ - u32 sfunc; /* sensor status mask */ - int sbase; /* status base register */ - const struct pmbus_limit_attr *limit;/* limit registers */ -}; - -/* - * Add a set of limit attributes and, if supported, the associated - * alarm attributes. - * returns 0 if no alarm register found, 1 if an alarm register was found, - * < 0 on errors. - */ -static int pmbus_add_limit_attrs(struct i2c_client *client, - struct pmbus_data *data, - const struct pmbus_driver_info *info, - const char *name, int index, int page, - struct pmbus_sensor *base, - const struct pmbus_sensor_attr *attr) -{ - const struct pmbus_limit_attr *l = attr->limit; - int nlimit = attr->nlimit; - int have_alarm = 0; - int i, ret; - struct pmbus_sensor *curr; - - for (i = 0; i < nlimit; i++) { - if (pmbus_check_word_register(client, page, l->reg)) { - curr = pmbus_add_sensor(data, name, l->attr, index, - page, l->reg, attr->class, - attr->update || l->update, - false); - if (!curr) - return -ENOMEM; - if (l->sbit && (info->func[page] & attr->sfunc)) { - ret = pmbus_add_boolean(data, name, - l->alarm, index, - attr->compare ? l->low ? curr : base - : NULL, - attr->compare ? l->low ? base : curr - : NULL, - attr->sbase + page, l->sbit); - if (ret) - return ret; - have_alarm = 1; - } - } - l++; - } - return have_alarm; -} - -static int pmbus_add_sensor_attrs_one(struct i2c_client *client, - struct pmbus_data *data, - const struct pmbus_driver_info *info, - const char *name, - int index, int page, - const struct pmbus_sensor_attr *attr) -{ - struct pmbus_sensor *base; - int ret; - - if (attr->label) { - ret = pmbus_add_label(data, name, index, attr->label, - attr->paged ? page + 1 : 0); - if (ret) - return ret; - } - base = pmbus_add_sensor(data, name, "input", index, page, attr->reg, - attr->class, true, true); - if (!base) - return -ENOMEM; - if (attr->sfunc) { - ret = pmbus_add_limit_attrs(client, data, info, name, - index, page, base, attr); - if (ret < 0) - return ret; - /* - * Add generic alarm attribute only if there are no individual - * alarm attributes, if there is a global alarm bit, and if - * the generic status register for this page is accessible. - */ - if (!ret && attr->gbit && - pmbus_check_byte_register(client, page, - data->status_register)) { - ret = pmbus_add_boolean(data, name, "alarm", index, - NULL, NULL, - PB_STATUS_BASE + page, - attr->gbit); - if (ret) - return ret; - } - } - return 0; -} - -static int pmbus_add_sensor_attrs(struct i2c_client *client, - struct pmbus_data *data, - const char *name, - const struct pmbus_sensor_attr *attrs, - int nattrs) -{ - const struct pmbus_driver_info *info = data->info; - int index, i; - int ret; - - index = 1; - for (i = 0; i < nattrs; i++) { - int page, pages; - - pages = attrs->paged ? info->pages : 1; - for (page = 0; page < pages; page++) { - if (!(info->func[page] & attrs->func)) - continue; - ret = pmbus_add_sensor_attrs_one(client, data, info, - name, index, page, - attrs); - if (ret) - return ret; - index++; - } - attrs++; - } - return 0; -} - -static const struct pmbus_sensor_attr voltage_attributes[] = { - { - .reg = PMBUS_READ_VOUT, - .class = PSC_VOLTAGE_OUT, - .label = "vout", - .paged = true, - .func = PMBUS_HAVE_VOUT, - .sfunc = PMBUS_HAVE_STATUS_VOUT, - .sbase = PB_STATUS_VOUT_BASE, - .gbit = PB_STATUS_VOUT_OV, - } -}; - -static const struct pmbus_limit_attr iout_limit_attrs[] = { - { - .reg = PMBUS_IOUT_OC_WARN_LIMIT, - .attr = "max", - .alarm = "max_alarm", - .sbit = PB_IOUT_OC_WARNING, - }, { - .reg = PMBUS_IOUT_OC_FAULT_LIMIT, - .attr = "crit", - .alarm = "crit_alarm", - .sbit = PB_IOUT_OC_FAULT, - } -}; - -static const struct pmbus_sensor_attr current_attributes[] = { - { - .reg = PMBUS_READ_IIN, - .class = PSC_CURRENT_IN, - .label = "iin", - .func = PMBUS_HAVE_IIN, - .sfunc = PMBUS_HAVE_STATUS_INPUT, - .sbase = PB_STATUS_INPUT_BASE, - }, { - .reg = PMBUS_READ_IOUT, - .class = PSC_CURRENT_OUT, - .label = "iout", - .paged = true, - .func = PMBUS_HAVE_IOUT, - .sfunc = PMBUS_HAVE_STATUS_IOUT, - .sbase = PB_STATUS_IOUT_BASE, - .gbit = PB_STATUS_IOUT_OC, - .limit = iout_limit_attrs, - .nlimit = ARRAY_SIZE(iout_limit_attrs), - } -}; - -/* Temperature atributes */ -static const struct pmbus_limit_attr temp_limit_attrs[] = { - { - .reg = PMBUS_OT_WARN_LIMIT, - .attr = "max", - .alarm = "max_alarm", - .sbit = PB_TEMP_OT_WARNING, - } -}; - -static const struct pmbus_limit_attr temp_limit_attrs2[] = { - { - .reg = PMBUS_OT_WARN_LIMIT, - .attr = "max", - .alarm = "max_alarm", - .sbit = PB_TEMP_OT_WARNING, - } -}; - -static const struct pmbus_limit_attr temp_limit_attrs3[] = { - { - .reg = PMBUS_OT_WARN_LIMIT, - .attr = "max", - .alarm = "max_alarm", - .sbit = PB_TEMP_OT_WARNING, - } -}; - -static const struct pmbus_sensor_attr temp_attributes[] = { - { - .reg = PMBUS_READ_TEMPERATURE_1, - .class = PSC_TEMPERATURE, - .paged = true, - .update = true, - .compare = true, - .func = PMBUS_HAVE_TEMP, - .sfunc = PMBUS_HAVE_STATUS_TEMP, - .sbase = PB_STATUS_TEMP_BASE, - .gbit = PB_STATUS_TEMPERATURE, - .limit = temp_limit_attrs, - .nlimit = ARRAY_SIZE(temp_limit_attrs), - }, { - .reg = PMBUS_READ_TEMPERATURE_2, - .class = PSC_TEMPERATURE, - .paged = true, - .update = true, - .compare = true, - .func = PMBUS_HAVE_TEMP2, - .sfunc = PMBUS_HAVE_STATUS_TEMP, - .sbase = PB_STATUS_TEMP_BASE, - .gbit = PB_STATUS_TEMPERATURE, - .limit = temp_limit_attrs2, - .nlimit = ARRAY_SIZE(temp_limit_attrs2), - }, { - .reg = PMBUS_READ_TEMPERATURE_3, - .class = PSC_TEMPERATURE, - .paged = true, - .update = true, - .compare = true, - .func = PMBUS_HAVE_TEMP3, - .sfunc = PMBUS_HAVE_STATUS_TEMP, - .sbase = PB_STATUS_TEMP_BASE, - .gbit = PB_STATUS_TEMPERATURE, - .limit = temp_limit_attrs3, - .nlimit = ARRAY_SIZE(temp_limit_attrs3), - } -}; - -static const int pmbus_fan_registers[] = { - PMBUS_READ_FAN_SPEED_1, -}; - -static const int pmbus_fan_config_registers[] = { - PMBUS_FAN_CONFIG_12, -}; - -static const int pmbus_fan_status_registers[] = { - PMBUS_STATUS_FAN_12, -}; - -static const u32 pmbus_fan_flags[] = { - PMBUS_HAVE_FAN12, -}; - -static const u32 pmbus_fan_status_flags[] = { - PMBUS_HAVE_STATUS_FAN12, -}; - -/* Fans */ -static int pmbus_add_fan_attributes(struct i2c_client *client, - struct pmbus_data *data) -{ - const struct pmbus_driver_info *info = data->info; - int index = 1; - int page; - int ret; - - for (page = 0; page < info->pages; page++) { - int f; - - for (f = 0; f < ARRAY_SIZE(pmbus_fan_registers); f++) { - int regval; - - if (!(info->func[page] & pmbus_fan_flags[f])) - break; - - if (!pmbus_check_word_register(client, page, - pmbus_fan_registers[f])) - break; - - /* - * Skip fan if not installed. - * Each fan configuration register covers multiple fans, - * so we have to do some magic. - */ - regval = _pmbus_read_byte_data(client, page, - pmbus_fan_config_registers[f]); - if (regval < 0 || - (!(regval & (PB_FAN_1_INSTALLED >> ((f & 1) * 4))))) - continue; - - if (pmbus_add_sensor(data, "fan", "input", index, - page, pmbus_fan_registers[f], - PSC_FAN, true, true) == NULL) - return -ENOMEM; - - /* - * Each fan status register covers multiple fans, - * so we have to do some magic. - */ - if ((info->func[page] & pmbus_fan_status_flags[f]) && - pmbus_check_byte_register(client, - page, pmbus_fan_status_registers[f])) { - int base; - - if (f > 1) /* fan 3, 4 */ - base = PB_STATUS_FAN34_BASE + page; - else - base = PB_STATUS_FAN_BASE + page; - ret = pmbus_add_boolean(data, "fan", - "alarm", index, NULL, NULL, base, - PB_FAN_FAN1_WARNING >> (f & 1)); - if (ret) - return ret; - ret = pmbus_add_boolean(data, "fan", - "fault", index, NULL, NULL, base, - PB_FAN_FAN1_FAULT >> (f & 1)); - if (ret) - return ret; - } - index++; - } - } - return 0; -} - -/* mfr items */ -static int pmbus_add_mfr_attributes(struct i2c_client *client, - struct pmbus_data *data) -{ - int page = 0; - int i; - - for(i = 0; i < ARRAY_SIZE(pmbus_mfr_reg);i++){ - - if (pmbus_add_mfr(data, pmbus_mfr_reg[i].name, page, pmbus_mfr_reg[i].reg) == NULL){ - return -ENOMEM; - } - } - - return 0; -} - -/* status items */ -static int pmbus_add_status_attributes(struct i2c_client *client, - struct pmbus_data *data) -{ - int i; - - for(i = 0; i < ARRAY_SIZE(pmbus_status_reg);i++){ - if (pmbus_add_status(data, pmbus_status_reg[i].name, pmbus_status_reg[i].base, pmbus_status_reg[i].offset)){ - return -ENOMEM; - } - } - - return 0; -} - -static int pmbus_find_attributes(struct i2c_client *client, - struct pmbus_data *data) -{ - int ret; - - /* Voltage sensors */ - ret = pmbus_add_sensor_attrs(client, data, "in", voltage_attributes, - ARRAY_SIZE(voltage_attributes)); - if (ret) - return ret; - - /* Current sensors */ - ret = pmbus_add_sensor_attrs(client, data, "curr", current_attributes, - ARRAY_SIZE(current_attributes)); - if (ret) - return ret; - - /* Temperature sensors */ - ret = pmbus_add_sensor_attrs(client, data, "temp", temp_attributes, - ARRAY_SIZE(temp_attributes)); - if (ret) - return ret; - - /* Fans */ - ret = pmbus_add_fan_attributes(client, data); - if (ret) - return ret; - - /* mfr data */ - ret = pmbus_add_mfr_attributes(client, data); - if (ret) - return ret; - - /* status data */ - ret = pmbus_add_status_attributes(client, data); - return ret; -} - -/* - * Identify chip parameters. - * This function is called for all chips. - */ -static int pmbus_identify_common(struct i2c_client *client, - struct pmbus_data *data, int page) -{ - int vout_mode = -1; - - if (pmbus_check_byte_register(client, page, PMBUS_VOUT_MODE)) - vout_mode = _pmbus_read_byte_data(client, page, - PMBUS_VOUT_MODE); - if (vout_mode >= 0 && vout_mode != 0xff) { - /* - * Not all chips support the VOUT_MODE command, - * so a failure to read it is not an error. - */ - switch (vout_mode >> 5) { - case 0: /* linear mode */ - if (data->info->format[PSC_VOLTAGE_OUT] != linear) - return -ENODEV; - - data->exponent[page] = ((s8)(vout_mode << 3)) >> 3; - break; - case 1: /* VID mode */ - if (data->info->format[PSC_VOLTAGE_OUT] != vid) - return -ENODEV; - break; - case 2: /* direct mode */ - if (data->info->format[PSC_VOLTAGE_OUT] != direct) - return -ENODEV; - break; - default: - return -ENODEV; - } - } - - pmbus_clear_fault_page(client, page); - return 0; -} - -static int pmbus_init_common(struct i2c_client *client, struct pmbus_data *data, - struct pmbus_driver_info *info) -{ - struct device *dev = &client->dev; - int page, ret; - - /* - * Some PMBus chips don't support PMBUS_STATUS_BYTE, so try - * to use PMBUS_STATUS_WORD instead if that is the case. - * Bail out if both registers are not supported. - */ - data->status_register = PMBUS_STATUS_BYTE; - ret = i2c_smbus_read_byte_data(client, PMBUS_STATUS_BYTE); - if (ret < 0 || ret == 0xff) { - data->status_register = PMBUS_STATUS_WORD; - ret = i2c_smbus_read_word_data(client, PMBUS_STATUS_WORD); - if (ret < 0 || ret == 0xffff) { - dev_err(dev, "PMBus status register not found\n"); - return -ENODEV; - } - } - - pmbus_clear_faults(client); - - if (info->identify) { - ret = (*info->identify)(client, info); - if (ret < 0) { - dev_err(dev, "Chip identification failed\n"); - return ret; - } - } - - if (info->pages <= 0 || info->pages > PMBUS_PAGES) { - dev_err(dev, "Bad number of PMBus pages: %d\n", info->pages); - return -ENODEV; - } - - /* Current only using page 1 in BMS project */ - info->pages = 1; - - for (page = 0; page < info->pages; page++) { - ret = pmbus_identify_common(client, data, page); - if (ret < 0) { - dev_err(dev, "Failed to identify chip capabilities\n"); - return ret; - } - } - return 0; -} - -int pmbus_do_probe(struct i2c_client *client, const struct i2c_device_id *id, - struct pmbus_driver_info *info) -{ - struct device *dev = &client->dev; - const struct pmbus_platform_data *pdata = dev_get_platdata(dev); - struct pmbus_data *data; - int ret; - - if (!info) - return -ENODEV; - - if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_WRITE_BYTE - | I2C_FUNC_SMBUS_BYTE_DATA - | I2C_FUNC_SMBUS_WORD_DATA)) - return -ENODEV; - - data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL); - if (!data) - return -ENOMEM; - - i2c_set_clientdata(client, data); - mutex_init(&data->update_lock); - data->dev = dev; - - if (pdata) - data->flags = pdata->flags; - data->info = info; - - ret = pmbus_init_common(client, data, info); - if (ret < 0) - return ret; - - ret = pmbus_find_attributes(client, data); - if (ret) - goto out_kfree; - - /* - * If there are no attributes, something is wrong. - * Bail out instead of trying to register nothing. - */ - if (!data->num_attributes) { - dev_err(dev, "No attributes found\n"); - ret = -ENODEV; - goto out_kfree; - } - - data->groups[0] = &data->group; - data->hwmon_dev = hwmon_device_register_with_groups(dev, client->name, - data, data->groups); - if (IS_ERR(data->hwmon_dev)) { - ret = PTR_ERR(data->hwmon_dev); - dev_err(dev, "Failed to register hwmon device\n"); - goto out_kfree; - } - return 0; - -out_kfree: - kfree(data->group.attrs); - return ret; -} - -int pmbus_do_remove(struct i2c_client *client) -{ - struct pmbus_data *data = i2c_get_clientdata(client); - hwmon_device_unregister(data->hwmon_dev); - kfree(data->group.attrs); - return 0; -} - - -/* - * Find sensor groups and status registers on each page. - */ -static void pmbus_find_sensor_groups(struct i2c_client *client, - struct pmbus_driver_info *info) -{ - int page; - - /* Sensors detected on page 0 only */ - if (pmbus_check_word_register(client, 0, PMBUS_READ_VIN)) - info->func[0] |= PMBUS_HAVE_VIN; - if (pmbus_check_word_register(client, 0, PMBUS_READ_VCAP)) - info->func[0] |= PMBUS_HAVE_VCAP; - if (pmbus_check_word_register(client, 0, PMBUS_READ_IIN)) - info->func[0] |= PMBUS_HAVE_IIN; - if (pmbus_check_word_register(client, 0, PMBUS_READ_PIN)) - info->func[0] |= PMBUS_HAVE_PIN; - if (info->func[0] - && pmbus_check_byte_register(client, 0, PMBUS_STATUS_INPUT)) - info->func[0] |= PMBUS_HAVE_STATUS_INPUT; - if (pmbus_check_byte_register(client, 0, PMBUS_FAN_CONFIG_12) && - pmbus_check_word_register(client, 0, PMBUS_READ_FAN_SPEED_1)) { - info->func[0] |= PMBUS_HAVE_FAN12; - if (pmbus_check_byte_register(client, 0, PMBUS_STATUS_FAN_12)) - info->func[0] |= PMBUS_HAVE_STATUS_FAN12; - } - if (pmbus_check_byte_register(client, 0, PMBUS_FAN_CONFIG_34) && - pmbus_check_word_register(client, 0, PMBUS_READ_FAN_SPEED_3)) { - info->func[0] |= PMBUS_HAVE_FAN34; - if (pmbus_check_byte_register(client, 0, PMBUS_STATUS_FAN_34)) - info->func[0] |= PMBUS_HAVE_STATUS_FAN34; - } - if (pmbus_check_word_register(client, 0, PMBUS_READ_TEMPERATURE_1)) - info->func[0] |= PMBUS_HAVE_TEMP; - if (pmbus_check_word_register(client, 0, PMBUS_READ_TEMPERATURE_2)) - info->func[0] |= PMBUS_HAVE_TEMP2; - if (pmbus_check_word_register(client, 0, PMBUS_READ_TEMPERATURE_3)) - info->func[0] |= PMBUS_HAVE_TEMP3; - if (info->func[0] & (PMBUS_HAVE_TEMP | PMBUS_HAVE_TEMP2 - | PMBUS_HAVE_TEMP3) - && pmbus_check_byte_register(client, 0, - PMBUS_STATUS_TEMPERATURE)) - info->func[0] |= PMBUS_HAVE_STATUS_TEMP; - - /* Sensors detected on all pages */ - for (page = 0; page < info->pages; page++) { - if (pmbus_check_word_register(client, page, PMBUS_READ_VOUT)) { - info->func[page] |= PMBUS_HAVE_VOUT; - if (pmbus_check_byte_register(client, page, - PMBUS_STATUS_VOUT)) - info->func[page] |= PMBUS_HAVE_STATUS_VOUT; - } - if (pmbus_check_word_register(client, page, PMBUS_READ_IOUT)) { - info->func[page] |= PMBUS_HAVE_IOUT; - if (pmbus_check_byte_register(client, 0, - PMBUS_STATUS_IOUT)) - info->func[page] |= PMBUS_HAVE_STATUS_IOUT; - } - if (pmbus_check_word_register(client, page, PMBUS_READ_POUT)) - info->func[page] |= PMBUS_HAVE_POUT; - } -} - -/* - * Identify chip parameters. - */ -static int pmbus_identify(struct i2c_client *client, - struct pmbus_driver_info *info) -{ - int ret = 0; - - if (!info->pages) { - /* - * Check if the PAGE command is supported. If it is, - * keep setting the page number until it fails or until the - * maximum number of pages has been reached. Assume that - * this is the number of pages supported by the chip. - */ - if (pmbus_check_byte_register(client, 0, PMBUS_PAGE)) { - int page; - - for (page = 1; page < PMBUS_PAGES; page++) { - if (pmbus_set_page(client, page) < 0) - break; - } - pmbus_set_page(client, 0); - info->pages = page; - } else { - info->pages = 1; - } - } - - if (pmbus_check_byte_register(client, 0, PMBUS_VOUT_MODE)) { - int vout_mode; - - vout_mode = pmbus_read_byte_data(client, 0, PMBUS_VOUT_MODE); - if (vout_mode >= 0 && vout_mode != 0xff) { - switch (vout_mode >> 5) { - case 0: - break; - case 1: - info->format[PSC_VOLTAGE_OUT] = vid; - break; - case 2: - info->format[PSC_VOLTAGE_OUT] = direct; - break; - default: - ret = -ENODEV; - goto abort; - } - } - } - - /* - * We should check if the COEFFICIENTS register is supported. - * If it is, and the chip is configured for direct mode, we can read - * the coefficients from the chip, one set per group of sensor - * registers. - * - * To do this, we will need access to a chip which actually supports the - * COEFFICIENTS command, since the command is too complex to implement - * without testing it. Until then, abort if a chip configured for direct - * mode was detected. - */ - if (info->format[PSC_VOLTAGE_OUT] == direct) { - ret = -ENODEV; - goto abort; - } - - /* Try to find sensor groups */ - pmbus_find_sensor_groups(client, info); -abort: - return ret; -} - -static int pmbus_probe(struct i2c_client *client, - const struct i2c_device_id *id) -{ - struct pmbus_driver_info *info; - - info = devm_kzalloc(&client->dev, sizeof(struct pmbus_driver_info), - GFP_KERNEL); - if (!info) - return -ENOMEM; - - info->pages = id->driver_data; - info->identify = pmbus_identify; - - return pmbus_do_probe(client, id, info); -} - -/* - * Use driver_data to set the number of pages supported by the chip. - */ -static const struct i2c_device_id pmbus_id[] = { - {"fse000", 0}, - {} -}; - -MODULE_DEVICE_TABLE(i2c, pmbus_id); - -/* This is the driver that will be inserted */ -static struct i2c_driver pmbus_driver = { - .driver = { - .name = "fse000", - }, - .probe = pmbus_probe, - .remove = pmbus_do_remove, - .id_table = pmbus_id, -}; - -module_i2c_driver(pmbus_driver); - -MODULE_DESCRIPTION("mitac_ly1200_32x_fse000 driver"); -MODULE_AUTHOR("Eddy Weng "); -MODULE_LICENSE("GPL"); diff --git a/packages/platforms/mitac/x86-64/ly1200-b32h0-c3/modules/builds/x86-64-mitac-ly1200-b32h0-c3-gpe.c b/packages/platforms/mitac/x86-64/ly1200-b32h0-c3/modules/builds/x86-64-mitac-ly1200-b32h0-c3-gpe.c deleted file mode 100644 index 3ced2b0a3..000000000 --- a/packages/platforms/mitac/x86-64/ly1200-b32h0-c3/modules/builds/x86-64-mitac-ly1200-b32h0-c3-gpe.c +++ /dev/null @@ -1,93 +0,0 @@ -#include -#include - -#define BMS_GPE_CLASS "bms_acpi" -#define BMS_GPE_DRIVER_NAME "bms_gpe" -#define BMS_GPE_DEVICE_NAME "bms_acpi_gpe" - -static int bms_gpe[] = {0x01, 0x02, 0x47}; -static int bms_gpe_num = sizeof(bms_gpe) / sizeof(bms_gpe[0]); - -static u32 bms_gpe_handler(acpi_handle handle, u32 gpe_num, void *context) -{ - struct acpi_device *device = context; - - acpi_bus_generate_netlink_event(device->pnp.device_class,dev_name(&device->dev), - gpe_num, 0); - return ACPI_INTERRUPT_HANDLED; /* GPE will be disable afterward */ -} - -static int bms_gpe_add(struct acpi_device *device) -{ - acpi_status status; - int i = 0; - char info_str[60] = { 0 }; - char temp[6] = { 0 }; - - if (!device) { - printk("No device of BMS GPE\n"); - return -EINVAL; - } - - strcpy(acpi_device_name(device), BMS_GPE_DEVICE_NAME); - strcpy(acpi_device_class(device), BMS_GPE_CLASS); - - strncat(info_str, "Initialized GPE list = ", 23); - for (i = 0; i < bms_gpe_num; i++) { - status = acpi_install_gpe_handler(NULL, bms_gpe[i], - ACPI_GPE_LEVEL_TRIGGERED, - &bms_gpe_handler, device); - if (status != AE_OK) { - printk("Fail to claim BMS GPE%X (code:0x%X)\n",bms_gpe[i],status); - return -EINVAL; - } - snprintf(temp, sizeof(temp), "0x%.2X ", bms_gpe[i]); - strncat(info_str, temp, 6); - } - - dev_info(&device->dev, "%s.\n", info_str); - - return 0; -} - -static int bms_gpe_remove(struct acpi_device *device) -{ - int i = 0; - for (i = 0; i < bms_gpe_num; i++) { - acpi_remove_gpe_handler(NULL, bms_gpe[i], &bms_gpe_handler); - } - return 0; -} - -static const struct acpi_device_id bms_acpi_device_ids[] = { - { "PNP0C01", 0 }, - { /* END OF LIST */ } -}; - -static struct acpi_driver bms_gpe_driver = { - .name = BMS_GPE_DRIVER_NAME, - .class = BMS_GPE_CLASS, - .ids = bms_acpi_device_ids, - .ops = { - .add = bms_gpe_add, - .remove = bms_gpe_remove, - }, -}; - -static int __init bms_gpe_init(void) -{ - printk(KERN_INFO "%s: init.\n", __FUNCTION__); - return acpi_bus_register_driver(&bms_gpe_driver); -} - -static void __exit bms_gpe_exit(void) -{ - printk(KERN_INFO "%s: exit.\n", __FUNCTION__); - acpi_bus_unregister_driver(&bms_gpe_driver); -} - -module_init(bms_gpe_init); -module_exit(bms_gpe_exit); -MODULE_AUTHOR("Yencheng Lin "); -MODULE_DESCRIPTION("mitac_ly1200_32x_gpe driver"); -MODULE_LICENSE("GPL"); diff --git a/packages/platforms/mitac/x86-64/ly1200-b32h0-c3/modules/builds/x86-64-mitac-ly1200-b32h0-c3-master_cpld.c b/packages/platforms/mitac/x86-64/ly1200-b32h0-c3/modules/builds/x86-64-mitac-ly1200-b32h0-c3-master_cpld.c deleted file mode 100644 index 921a2ea42..000000000 --- a/packages/platforms/mitac/x86-64/ly1200-b32h0-c3/modules/builds/x86-64-mitac-ly1200-b32h0-c3-master_cpld.c +++ /dev/null @@ -1,503 +0,0 @@ -#include -#include - -#include "master_cpld_reg.h" -#include "master_cpld_sysfs.h" - -static int debug_flag = 0; - -struct master_cpld_data { - struct mutex lock; - - struct i2c_client *client; - struct device_attribute bin; -}; - - -static const struct i2c_device_id master_cpld_ids[] = { - { "master_cpld", 0 }, - { /* END OF LIST */ } -}; -MODULE_DEVICE_TABLE(i2c, master_cpld_ids); - -static int master_cpld_raw_read(struct device *dev, struct device_attribute *attr, char *buf, - int reg_offset, int reg_width, int fld_shift, int fld_width, int fld_mask, char* reg_name){ - unsigned int reg_val = 0, fld_val; - static int debug_flag; - struct master_cpld_data *data = dev_get_drvdata(dev); - struct i2c_client *client = data->client; - int err; - - if (reg_width != 8){ - printk("%s: Register table width setting failed.\n", reg_name); - return -EINVAL; - } - mutex_lock(&data->lock); - if ((err = i2c_smbus_read_byte_data(client, (u8)reg_offset)) < 0) { - /* CPLD read error condition */; - mutex_unlock(&data->lock); - printk("%s: i2c read failed, error code = %d.\n", reg_name, err); - return err; - } - reg_val = err; - if (debug_flag) { - printk("%s: reg_offset = %d, width = %d, cur value = 0x%x.\n", reg_name, reg_offset, reg_width, reg_val); - } - mutex_unlock(&data->lock); - if (fld_width == reg_width) {fld_val = reg_val & fld_mask;} - else {fld_val = (reg_val >> fld_shift) & fld_mask;} - return sprintf(buf, "0x%x\n", fld_val); -} - -static int master_cpld_raw_write(struct device *dev, struct device_attribute *attr, const char *buf, size_t count, - int reg_offset, int reg_width, int fld_shift, int fld_width, int fld_mask, char* reg_name){ - int ret_code; - unsigned int reg_val, fld_val; - unsigned long val; - static int debug_flag; - struct master_cpld_data *data = dev_get_drvdata(dev); - struct i2c_client *client = data->client; - if (reg_width != 8){ - printk("%s: Register table width setting failed.\n", reg_name); - return -EINVAL; - } - /* Parse buf and store to fld_val */ - if ((ret_code = kstrtoul(buf, 16, &val))){ - printk("%s: Conversion value = %s failed, errno = %d.\n", reg_name, buf, ret_code); - return ret_code; - } - fld_val = (unsigned int)val; - mutex_lock(&data->lock); - if ((ret_code = i2c_smbus_read_byte_data(client, (u8)reg_offset)) < 0) { - /* Handle CPLD read error condition */; - mutex_unlock(&data->lock); - printk("%s: i2c read failed, error code = %d.\n", reg_name, ret_code); - return ret_code; - } - reg_val = ret_code; - if (debug_flag) { - printk("%s: offset = %d, width = %d, cur value = 0x%x.\n", reg_name, reg_offset, reg_width, reg_val); - } - if (fld_width == reg_width) {reg_val = fld_val & fld_mask;} - else {reg_val = (reg_val & ~(fld_mask << fld_shift)) | - ((fld_val & (fld_mask)) << fld_shift);} - if ((ret_code = i2c_smbus_write_byte_data(client, (u8)reg_offset, (u8)reg_val)) != 0) { - /* Handle CPLD write error condition */; - mutex_unlock(&data->lock); - printk("%s: i2c write failed, error code = %d.\n", reg_name, ret_code); - return ret_code; - } - else if (debug_flag) { - printk("%s: offset = %d, width = %d, new value = 0x%x.\n", reg_name, reg_offset, reg_width, reg_val); - } - mutex_unlock(&data->lock); - return count; -} - -/*--------------------special file for debug---------------------- */ -static ssize_t master_cpld_debug_read(struct device *dev, struct device_attribute *attr, - char *buf){ - - return sprintf(buf, "%d\n", debug_flag); -} - - -static ssize_t master_cpld_debug_write(struct device *dev, struct device_attribute *attr, - const char *buf, size_t count) -{ - int temp; - int error; - - error = kstrtoint(buf, 10, &temp); - if (error){ - printk(KERN_INFO "%s: Conversion value = %s failed.\n", __FUNCTION__, buf); - return count; - } - debug_flag = temp; - - if(debug_flag) - printk("%s, debug_flag = %d\n", __FUNCTION__, debug_flag); - - return count; -} -SYSFS_MISC_RW_ATTR_DEF(debug, master_cpld_debug_read, master_cpld_debug_write) - - - - -/* ----------------define port group---------------------------- */ -static struct attribute *port1_attributes[] = { - SYSFS_ATTR_PTR(port1_present), /* register: zqsfp28_present_8_1_status */ - SYSFS_ATTR_PTR(port1_rst), /* register: zqsfp28_rst_8_1 */ - SYSFS_ATTR_PTR(port1_modsel), /* register: zqsfp28_modsel_8_1 */ - SYSFS_ATTR_PTR(port1_lpmode), /* register: zqsfp28_lpmode_8_1 */ - SYSFS_ATTR_PTR(port1_irq_status), /* register: zqsfp28_irq_8_1_status */ - SYSFS_ATTR_PTR(port1_irq_msk), /* register: zqsfp28_irq_msk_8_1_status */ - NULL -}; - - -static struct attribute *port2_attributes[] = { - SYSFS_ATTR_PTR(port2_present), /* register: zqsfp28_present_8_1_status */ - SYSFS_ATTR_PTR(port2_rst), /* register: zqsfp28_rst_8_1 */ - SYSFS_ATTR_PTR(port2_modsel), /* register: zqsfp28_modsel_8_1 */ - SYSFS_ATTR_PTR(port2_lpmode), /* register: zqsfp28_lpmode_8_1 */ - SYSFS_ATTR_PTR(port2_irq_status), /* register: zqsfp28_irq_8_1_status */ - SYSFS_ATTR_PTR(port2_irq_msk), /* register: zqsfp28_irq_msk_8_1_status */ - NULL -}; - - -static struct attribute *port3_attributes[] = { - SYSFS_ATTR_PTR(port3_present), /* register: zqsfp28_present_8_1_status */ - SYSFS_ATTR_PTR(port3_rst), /* register: zqsfp28_rst_8_1 */ - SYSFS_ATTR_PTR(port3_modsel), /* register: zqsfp28_modsel_8_1 */ - SYSFS_ATTR_PTR(port3_lpmode), /* register: zqsfp28_lpmode_8_1 */ - SYSFS_ATTR_PTR(port3_irq_status), /* register: zqsfp28_irq_8_1_status */ - SYSFS_ATTR_PTR(port3_irq_msk), /* register: zqsfp28_irq_msk_8_1_status */ - NULL -}; - -static struct attribute *port4_attributes[] = { - SYSFS_ATTR_PTR(port4_present), /* register: zqsfp28_present_8_1_status */ - SYSFS_ATTR_PTR(port4_rst), /* register: zqsfp28_rst_8_1 */ - SYSFS_ATTR_PTR(port4_modsel), /* register: zqsfp28_modsel_8_1 */ - SYSFS_ATTR_PTR(port4_lpmode), /* register: zqsfp28_lpmode_8_1 */ - SYSFS_ATTR_PTR(port4_irq_status), /* register: zqsfp28_irq_8_1_status */ - SYSFS_ATTR_PTR(port4_irq_msk), /* register: zqsfp28_irq_msk_8_1_status */ - NULL -}; - -static struct attribute *port5_attributes[] = { - SYSFS_ATTR_PTR(port5_present), /* register: zqsfp28_present_8_1_status */ - SYSFS_ATTR_PTR(port5_rst), /* register: zqsfp28_rst_8_1 */ - SYSFS_ATTR_PTR(port5_modsel), /* register: zqsfp28_modsel_8_1 */ - SYSFS_ATTR_PTR(port5_lpmode), /* register: zqsfp28_lpmode_8_1 */ - SYSFS_ATTR_PTR(port5_irq_status), /* register: zqsfp28_irq_8_1_status */ - SYSFS_ATTR_PTR(port5_irq_msk), /* register: zqsfp28_irq_msk_8_1_status */ - NULL -}; - -static struct attribute *port6_attributes[] = { - SYSFS_ATTR_PTR(port6_present), /* register: zqsfp28_present_8_1_status */ - SYSFS_ATTR_PTR(port6_rst), /* register: zqsfp28_rst_8_1 */ - SYSFS_ATTR_PTR(port6_modsel), /* register: zqsfp28_modsel_8_1 */ - SYSFS_ATTR_PTR(port6_lpmode), /* register: zqsfp28_lpmode_8_1 */ - SYSFS_ATTR_PTR(port6_irq_status), /* register: zqsfp28_irq_8_1_status */ - SYSFS_ATTR_PTR(port6_irq_msk), /* register: zqsfp28_irq_msk_8_1_status */ - NULL -}; - -static struct attribute *port7_attributes[] = { - SYSFS_ATTR_PTR(port7_present), /* register: zqsfp28_present_8_1_status */ - SYSFS_ATTR_PTR(port7_rst), /* register: zqsfp28_rst_8_1 */ - SYSFS_ATTR_PTR(port7_modsel), /* register: zqsfp28_modsel_8_1 */ - SYSFS_ATTR_PTR(port7_lpmode), /* register: zqsfp28_lpmode_8_1 */ - SYSFS_ATTR_PTR(port7_irq_status), /* register: zqsfp28_irq_8_1_status */ - SYSFS_ATTR_PTR(port7_irq_msk), /* register: zqsfp28_irq_msk_8_1_status */ - NULL -}; - -static struct attribute *port8_attributes[] = { - SYSFS_ATTR_PTR(port8_present), /* register: zqsfp28_present_8_1_status */ - SYSFS_ATTR_PTR(port8_rst), /* register: zqsfp28_rst_8_1 */ - SYSFS_ATTR_PTR(port8_modsel), /* register: zqsfp28_modsel_8_1 */ - SYSFS_ATTR_PTR(port8_lpmode), /* register: zqsfp28_lpmode_8_1 */ - SYSFS_ATTR_PTR(port8_irq_status), /* register: zqsfp28_irq_8_1_status */ - SYSFS_ATTR_PTR(port8_irq_msk), /* register: zqsfp28_irq_msk_8_1_status */ - NULL -}; - -static struct attribute *port9_attributes[] = { - SYSFS_ATTR_PTR(port9_present), /* register: zqsfp28_present_16_9_status */ - SYSFS_ATTR_PTR(port9_rst), /* register: zqsfp28_rst_16_9 */ - SYSFS_ATTR_PTR(port9_modsel), /* register: zqsfp28_modsel_16_9 */ - SYSFS_ATTR_PTR(port9_lpmode), /* register: zqsfp28_lpmode_16_9 */ - SYSFS_ATTR_PTR(port9_irq_status), /* register: zqsfp28_irq_16_9_status */ - SYSFS_ATTR_PTR(port9_irq_msk), /* register: zqsfp28_irq_msk_16_9_status */ - NULL -}; - -static struct attribute *port10_attributes[] = { - SYSFS_ATTR_PTR(port10_present), /* register: zqsfp28_present_16_9_status */ - SYSFS_ATTR_PTR(port10_rst), /* register: zqsfp28_rst_16_9 */ - SYSFS_ATTR_PTR(port10_modsel), /* register: zqsfp28_modsel_16_9 */ - SYSFS_ATTR_PTR(port10_lpmode), /* register: zqsfp28_lpmode_16_9 */ - SYSFS_ATTR_PTR(port10_irq_status), /* register: zqsfp28_irq_16_9_status */ - SYSFS_ATTR_PTR(port10_irq_msk), /* register: zqsfp28_irq_msk_16_9_status */ - NULL -}; - -static struct attribute *port11_attributes[] = { - SYSFS_ATTR_PTR(port11_present), /* register: zqsfp28_present_16_9_status */ - SYSFS_ATTR_PTR(port11_rst), /* register: zqsfp28_rst_16_9 */ - SYSFS_ATTR_PTR(port11_modsel), /* register: zqsfp28_modsel_16_9 */ - SYSFS_ATTR_PTR(port11_lpmode), /* register: zqsfp28_lpmode_16_9 */ - SYSFS_ATTR_PTR(port11_irq_status), /* register: zqsfp28_irq_16_9_status */ - SYSFS_ATTR_PTR(port11_irq_msk), /* register: zqsfp28_irq_msk_16_9_status */ - NULL -}; - -static struct attribute *port12_attributes[] = { - SYSFS_ATTR_PTR(port12_present), /* register: zqsfp28_present_16_9_status */ - SYSFS_ATTR_PTR(port12_rst), /* register: zqsfp28_rst_16_9 */ - SYSFS_ATTR_PTR(port12_modsel), /* register: zqsfp28_modsel_16_9 */ - SYSFS_ATTR_PTR(port12_lpmode), /* register: zqsfp28_lpmode_16_9 */ - SYSFS_ATTR_PTR(port12_irq_status), /* register: zqsfp28_irq_16_9_status */ - SYSFS_ATTR_PTR(port12_irq_msk), /* register: zqsfp28_irq_msk_16_9_status */ - NULL -}; - -static struct attribute *port13_attributes[] = { - SYSFS_ATTR_PTR(port13_present), /* register: zqsfp28_present_16_9_status */ - SYSFS_ATTR_PTR(port13_rst), /* register: zqsfp28_rst_16_9 */ - SYSFS_ATTR_PTR(port13_modsel), /* register: zqsfp28_modsel_16_9 */ - SYSFS_ATTR_PTR(port13_lpmode), /* register: zqsfp28_lpmode_16_9 */ - SYSFS_ATTR_PTR(port13_irq_status), /* register: zqsfp28_irq_16_9_status */ - SYSFS_ATTR_PTR(port13_irq_msk), /* register: zqsfp28_irq_msk_16_9_status */ - NULL -}; - -static struct attribute *port14_attributes[] = { - SYSFS_ATTR_PTR(port14_present), /* register: zqsfp28_present_16_9_status */ - SYSFS_ATTR_PTR(port14_rst), /* register: zqsfp28_rst_16_9 */ - SYSFS_ATTR_PTR(port14_modsel), /* register: zqsfp28_modsel_16_9 */ - SYSFS_ATTR_PTR(port14_lpmode), /* register: zqsfp28_lpmode_16_9 */ - SYSFS_ATTR_PTR(port14_irq_status), /* register: zqsfp28_irq_16_9_status */ - SYSFS_ATTR_PTR(port14_irq_msk), /* register: zqsfp28_irq_msk_16_9_status */ - NULL -}; - -static struct attribute *port15_attributes[] = { - SYSFS_ATTR_PTR(port15_present), /* register: zqsfp28_present_16_9_status */ - SYSFS_ATTR_PTR(port15_rst), /* register: zqsfp28_rst_16_9 */ - SYSFS_ATTR_PTR(port15_modsel), /* register: zqsfp28_modsel_16_9 */ - SYSFS_ATTR_PTR(port15_lpmode), /* register: zqsfp28_lpmode_16_9 */ - SYSFS_ATTR_PTR(port15_irq_status), /* register: zqsfp28_irq_16_9_status */ - SYSFS_ATTR_PTR(port15_irq_msk), /* register: zqsfp28_irq_msk_16_9_status */ - NULL -}; - -static struct attribute *port16_attributes[] = { - SYSFS_ATTR_PTR(port16_present), /* register: zqsfp28_present_16_9_status */ - SYSFS_ATTR_PTR(port16_rst), /* register: zqsfp28_rst_16_9 */ - SYSFS_ATTR_PTR(port16_modsel), /* register: zqsfp28_modsel_16_9 */ - SYSFS_ATTR_PTR(port16_lpmode), /* register: zqsfp28_lpmode_16_9 */ - SYSFS_ATTR_PTR(port16_irq_status), /* register: zqsfp28_irq_16_9_status */ - SYSFS_ATTR_PTR(port16_irq_msk), /* register: zqsfp28_irq_msk_16_9_status */ - NULL -}; - - -static const struct attribute_group master_cpld_port_group[] = { - {.attrs = port1_attributes, - .name = "port1",}, - {.attrs = port2_attributes, - .name = "port2",}, - {.attrs = port3_attributes, - .name = "port3",}, - {.attrs = port4_attributes, - .name = "port4",}, - {.attrs = port5_attributes, - .name = "port5",}, - {.attrs = port6_attributes, - .name = "port6",}, - {.attrs = port7_attributes, - .name = "port7",}, - {.attrs = port8_attributes, - .name = "port8",}, - {.attrs = port9_attributes, - .name = "port9",}, - {.attrs = port10_attributes, - .name = "port10",}, - {.attrs = port11_attributes, - .name = "port11",}, - {.attrs = port12_attributes, - .name = "port12",}, - {.attrs = port13_attributes, - .name = "port13",}, - {.attrs = port14_attributes, - .name = "port14",}, - {.attrs = port15_attributes, - .name = "port15",}, - {.attrs = port16_attributes, - .name = "port16",} -}; - -/* ----------------define misc group---------------------------- */ -static struct attribute *misc_attributes[] = { - SYSFS_ATTR_PTR(mjr_rev), /* register: mstr_cpld_rev */ - SYSFS_ATTR_PTR(mnr_rev), /* register: mstr_cpld_rev */ - - SYSFS_ATTR_PTR(scrtch_reg), /* register: mstr_cpld_gpr */ - - SYSFS_ATTR_PTR(brd_rev), /* register: mb_brd_rev_type */ - SYSFS_ATTR_PTR(brd_type), /* register: mb_brd_rev_type */ - - SYSFS_ATTR_PTR(mb_rst), /* register: mstr_srr */ - SYSFS_ATTR_PTR(npu_rst), /* register: mstr_srr */ - SYSFS_ATTR_PTR(mgmt_phy_rst), /* register: mstr_srr */ - - SYSFS_ATTR_PTR(mb_eeprom_wp), /* register: eeprom_wp */ - SYSFS_ATTR_PTR(cpld_spi_wp), /* register: eeprom_wp */ - SYSFS_ATTR_PTR(fan_eeprom_wp), /* register: eeprom_wp */ - - SYSFS_ATTR_PTR(ps2_int_msk), /* register: mstr_irq */ - SYSFS_ATTR_PTR(ps1_int_msk), /* register: mstr_irq */ - SYSFS_ATTR_PTR(usb_fault_msk), /* register: mstr_irq */ - SYSFS_ATTR_PTR(pcie_int_msk), /* register: mstr_irq */ - SYSFS_ATTR_PTR(fan_alert_int_msk), /* register: mstr_irq */ - SYSFS_ATTR_PTR(usb_fault), /* register: mstr_irq */ - SYSFS_ATTR_PTR(pcie_int), /* register: mstr_irq */ - SYSFS_ATTR_PTR(fan_alert_int), /* register: mstr_irq */ - SYSFS_ATTR_PTR(system_led_fld), /* register: mstr_irq */ - SYSFS_ATTR_PTR(power_led), /* register: mstr_irq */ - SYSFS_ATTR_PTR(fan_led), /* register: mstr_irq */ - SYSFS_ATTR_PTR(locate_led), /* register: mstr_irq */ - - SYSFS_ATTR_PTR(led_test), /* register: fan_tray_3_1_led */ - SYSFS_ATTR_PTR(fan_tray3_led), /* register: fan_tray_3_1_led */ - SYSFS_ATTR_PTR(fan_tray2_led), /* register: fan_tray_3_1_led */ - SYSFS_ATTR_PTR(fan_tray1_led), /* register: fan_tray_3_1_led */ - SYSFS_ATTR_PTR(fan_tray6_led), /* register: fan_tray_6_4_led */ - SYSFS_ATTR_PTR(fan_tray5_led), /* register: fan_tray_6_4_led */ - SYSFS_ATTR_PTR(fan_tray4_led), /* register: fan_tray_6_4_led */ - - SYSFS_ATTR_PTR(fan_tray6_present), /* register: fan_tray_status */ - SYSFS_ATTR_PTR(fan_tray5_present), /* register: fan_tray_status */ - SYSFS_ATTR_PTR(fan_tray4_present), /* register: fan_tray_status */ - SYSFS_ATTR_PTR(fan_tray3_present), /* register: fan_tray_status */ - SYSFS_ATTR_PTR(fan_tray2_present), /* register: fan_tray_status */ - SYSFS_ATTR_PTR(fan_tray1_present), /* register: fan_tray_status */ - - SYSFS_ATTR_PTR(fan_type6), /* register: fan_type_status */ - SYSFS_ATTR_PTR(fan_type5), /* register: fan_type_status */ - SYSFS_ATTR_PTR(fan_type4), /* register: fan_type_status */ - SYSFS_ATTR_PTR(fan_type3), /* register: fan_type_status */ - SYSFS_ATTR_PTR(fan_type2), /* register: fan_type_status */ - SYSFS_ATTR_PTR(fan_type1), /* register: fan_type_status */ - - SYSFS_ATTR_PTR(ps1_ps), /* register: psu_en_status */ - SYSFS_ATTR_PTR(ps1_pg), /* register: psu_en_status */ - SYSFS_ATTR_PTR(ps1_int), /* register: psu_en_status */ - SYSFS_ATTR_PTR(ps1_on), /* register: psu_en_status */ - SYSFS_ATTR_PTR(ps2_ps), /* register: psu_en_status */ - SYSFS_ATTR_PTR(ps2_pg), /* register: psu_en_status */ - SYSFS_ATTR_PTR(ps2_int), /* register: psu_en_status */ - SYSFS_ATTR_PTR(ps2_on), /* register: psu_en_status */ - - SYSFS_ATTR_PTR(usb1_vbus_en), /* register: mb_pwr_en_status */ - SYSFS_ATTR_PTR(v5p0_en), /* register: mb_pwr_en_status */ - SYSFS_ATTR_PTR(v3p3_en), /* register: mb_pwr_en_status */ - SYSFS_ATTR_PTR(vcc_1v8_en), /* register: mb_pwr_en_status */ - SYSFS_ATTR_PTR(mac_avs1v_en), /* register: mb_pwr_en_status */ - SYSFS_ATTR_PTR(mac1v_en), /* register: mb_pwr_en_status */ - SYSFS_ATTR_PTR(vcc_1v25_en), /* register: mb_pwr_en_status */ - - SYSFS_ATTR_PTR(vcc_3p3_cpld), /* register: mb_pwr_status */ - SYSFS_ATTR_PTR(vcc5v_pg), /* register: mb_pwr_status */ - SYSFS_ATTR_PTR(vcc3v3_pg), /* register: mb_pwr_status */ - SYSFS_ATTR_PTR(vcc_1v8_pg), /* register: mb_pwr_status */ - SYSFS_ATTR_PTR(mac_avs1v_pg), /* register: mb_pwr_status */ - SYSFS_ATTR_PTR(mac1v_pg), /* register: mb_pwr_status */ - SYSFS_ATTR_PTR(vcc_1v25_pg), /* register: mb_pwr_status */ - - SYSFS_ATTR_PTR(port_1_8_present), /* register: zqsfp28_present_8_1_status */ - SYSFS_ATTR_PTR(port_9_16_present), /* register: zqsfp28_present_16_9_status */ - SYSFS_ATTR_PTR(port_1_8_rst), /* register: zqsfp28_rst_8_1 */ - SYSFS_ATTR_PTR(port_9_16_rst), /* register: zqsfp28_rst_16_9 */ - SYSFS_ATTR_PTR(port_1_8_modsel), /* register: zqsfp28_modsel_8_1 */ - SYSFS_ATTR_PTR(port_9_16_modsel), /* register: zqsfp28_modsel_16_9 */ - SYSFS_ATTR_PTR(port_1_8_irq_status), /* register: zqsfp28_irq_8_1_status */ - SYSFS_ATTR_PTR(port_9_16_irq_status),/* register: zqsfp28_irq_16_9_status */ - SYSFS_ATTR_PTR(port_1_8_irq_msk), /* register: zqsfp28_irq_msk_8_1_status */ - SYSFS_ATTR_PTR(port_9_16_irq_msk), /* register: zqsfp28_irq_msk_16_9_status */ - SYSFS_ATTR_PTR(port_1_8_lpmode), /* register: zqsfp28_lpmode_8_1 */ - SYSFS_ATTR_PTR(port_9_16_lpmode), /* register: zqsfp28_lpmode_16_9 */ - - SYSFS_ATTR_PTR(fan_tray1_6_present), /* register: fan_tray_status */ - SYSFS_ATTR_PTR(psu_en_status_fld), /* register: psu_en_status*/ - - SYSFS_ATTR_PTR(debug), /* debug flag for print more messages */ - NULL -}; -static const struct attribute_group master_cpld_group_misc = { - .attrs = misc_attributes, -}; - -static int master_cpld_probe(struct i2c_client *client, const struct i2c_device_id *id) -{ - struct master_cpld_data *master_cpld; - int err, i; - int grp_number = (int)( sizeof(master_cpld_port_group) / sizeof(master_cpld_port_group[0])); - - /* allocate memory to master_cpld */ - master_cpld = devm_kzalloc(&client->dev, sizeof(struct master_cpld_data) , GFP_KERNEL); - - if (!master_cpld) - return -ENOMEM; - - mutex_init(&master_cpld->lock); - - for(i = 0 ; i < grp_number ; i++){ - err = sysfs_create_group(&client->dev.kobj, &master_cpld_port_group[i]); - if (err){ - printk("%s: Error creeat port group %d.\n", __FUNCTION__, i+1); - } - } - err = sysfs_create_group(&client->dev.kobj, &master_cpld_group_misc); - if (err){ - printk("%s: Error creeat misc group.\n", __FUNCTION__); - } - - master_cpld->client = client; - i2c_set_clientdata(client, master_cpld); - - printk(KERN_INFO "%s: Master CPLD LCMXO3LF created.\n", __FUNCTION__); - - return 0; - -} - -static int master_cpld_remove(struct i2c_client *client) -{ - int i; - int grp_number = (int)( sizeof(master_cpld_port_group) / sizeof(master_cpld_port_group[0])); - - for(i = 0 ; i < grp_number ; i++){ - sysfs_remove_group(&client->dev.kobj, &master_cpld_port_group[i]); - } - sysfs_remove_group(&client->dev.kobj, &master_cpld_group_misc); - - printk(KERN_INFO "%s: Master CPLD removed.\n", __FUNCTION__); - return 0; -} - -static struct i2c_driver master_cpld_driver = { - .driver = { - .name = "master_cpld", - .owner = THIS_MODULE, - }, - .probe = master_cpld_probe, - .remove = master_cpld_remove, - .id_table = master_cpld_ids, -}; - -static int __init master_cpld_init(void) -{ - printk(KERN_INFO "%s: init.\n", __FUNCTION__); - return i2c_add_driver(&master_cpld_driver); -} -module_init(master_cpld_init); - -static void __exit master_cpld_exit(void) -{ - printk(KERN_INFO "%s: exit.\n", __FUNCTION__); - i2c_del_driver(&master_cpld_driver); -} -module_exit(master_cpld_exit); - -MODULE_DESCRIPTION("mitac_ly1200_32x_master_cpld driver"); -MODULE_AUTHOR("Eddy Weng "); -MODULE_LICENSE("GPL"); - diff --git a/packages/platforms/mitac/x86-64/ly1200-b32h0-c3/modules/builds/x86-64-mitac-ly1200-b32h0-c3-pb_i2c.c b/packages/platforms/mitac/x86-64/ly1200-b32h0-c3/modules/builds/x86-64-mitac-ly1200-b32h0-c3-pb_i2c.c deleted file mode 100644 index 114495c09..000000000 --- a/packages/platforms/mitac/x86-64/ly1200-b32h0-c3/modules/builds/x86-64-mitac-ly1200-b32h0-c3-pb_i2c.c +++ /dev/null @@ -1,136 +0,0 @@ -#include -#include -#include "bms_i2c.h" - -#define BMS_PB_I2C_CLIENT_NUM 2 - -static struct i2c_client *bms_pb_clients[BMS_PB_I2C_CLIENT_NUM] = {NULL}; -static int bms_pb_client_index = 0; - -static int __init __find_i2c_adap(struct device *dev, void *data) -{ - const char *name = data; - static const char *prefix = "i2c-"; - struct i2c_adapter *adapter; - - if (strncmp(dev_name(dev), prefix, strlen(prefix)) != 0) - { - return 0; - } - adapter = to_i2c_adapter(dev); - - return (strncmp(adapter->name, name, strlen(name)) == 0); -} - -static int __init find_i2c_adapter_num(enum i2c_adapter_type type) -{ - struct device *dev = NULL; - struct i2c_adapter *adapter; - const char *name = bms_i2c_adapter_names[type]; - - /* find the adapter by name */ - dev = bus_find_device(&i2c_bus_type, NULL, (void *)name, - __find_i2c_adap); - if (!dev) { - pr_err("%s: i2c adapter %s not found on system.\n", - __func__, name); - return -ENODEV; - } - adapter = to_i2c_adapter(dev); - - return adapter->nr; -} - - -static int __init find_i2c_mux_adapter_num(int parent_num, int num) -{ - struct device *dev = NULL; - struct i2c_adapter *adapter; - char name[48]; - - snprintf(name, sizeof(name), "i2c-%d-mux (chan_id %d)", - parent_num, num); - /* find the adapter by name */ - dev = bus_find_device(&i2c_bus_type, NULL, (void *)name, - __find_i2c_adap); - if (!dev) { - pr_err("%s: i2c adapter %s not found on system.\n", - __func__, name); - return -ENODEV; - } - adapter = to_i2c_adapter(dev); - - return adapter->nr; -} - -static __init struct i2c_client *bms_pb_setup_eeprom_24c01( - struct i2c_adapter *adap, int addr) -{ - struct i2c_board_info info_spd = { - I2C_BOARD_INFO("24c01", addr), - }; - - return i2c_new_device(adap, &info_spd); -} - -static int __init bms_pb_setup_devices(void) -{ - struct i2c_adapter *adap; - int adap_num; - int parent_num; - - parent_num = find_i2c_adapter_num(I2C_ADAPTER_ISMT); - if (parent_num < 0) - return parent_num; - - adap_num = find_i2c_mux_adapter_num(parent_num, I2C_STAGE1_MUX_CHAN3); - if (adap_num < 0) - return adap_num; - - adap = i2c_get_adapter(adap_num); - if (!adap) { - pr_err("%s failed to get i2c adap %d.\n", __func__, adap_num); - goto exit; - } - - bms_pb_clients[bms_pb_client_index++] = bms_pb_setup_eeprom_24c01(adap, 0x50); - bms_pb_clients[bms_pb_client_index++] = bms_pb_setup_eeprom_24c01(adap, 0x51); - -exit: - return 0; -} - -static int __init bms_pb_i2c_init(void) -{ - /* Initial bms_sb_slients array. */ - memset(bms_pb_clients, 0x0, BMS_PB_I2C_CLIENT_NUM); - - bms_pb_setup_devices(); - return 0; -} - - -static void __exit bms_pb_i2c_exit(void){ - int i; - - for (i=(bms_pb_client_index-1); i>=0; i--) { - if (bms_pb_clients[i]) { - i2c_unregister_device(bms_pb_clients[i]); - bms_pb_clients[i] = NULL; - } - } - - bms_pb_client_index = 0; - - -} - - -module_init(bms_pb_i2c_init); -module_exit(bms_pb_i2c_exit); - - -MODULE_DESCRIPTION("mitac_ly1200_32x_pb_i2c driver"); -MODULE_AUTHOR("Eddy Weng "); -MODULE_LICENSE("GPL"); - diff --git a/packages/platforms/mitac/x86-64/ly1200-b32h0-c3/modules/builds/x86-64-mitac-ly1200-b32h0-c3-sb_i2c.c b/packages/platforms/mitac/x86-64/ly1200-b32h0-c3/modules/builds/x86-64-mitac-ly1200-b32h0-c3-sb_i2c.c deleted file mode 100644 index 0d91906ff..000000000 --- a/packages/platforms/mitac/x86-64/ly1200-b32h0-c3/modules/builds/x86-64-mitac-ly1200-b32h0-c3-sb_i2c.c +++ /dev/null @@ -1,436 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include "bms_i2c.h" - -/* Don't include MAC_AVS_1V amd ZQSFP Modules */ -#define BMS_SB_I2C_CLIENT_NUM 11 -#define BMS_SB_ADAPTER_BASE 2 -#define BMS_SB_STAGE2_MUX_BUS_BASE 6 - - -static struct i2c_client *bms_sb_clients[BMS_SB_I2C_CLIENT_NUM] = {NULL}; -static int bms_sb_client_index = 0; - -enum bms_sb_switch_stage2_mux0_bus { - I2C_STAGE2_MUX0_CHAN0 = 0, - I2C_STAGE2_MUX0_CHAN1, - I2C_STAGE2_MUX0_CHAN2, - I2C_STAGE2_MUX0_CHAN3, - I2C_STAGE2_MUX0_CHAN4, - I2C_STAGE2_MUX0_CHAN5, - I2C_STAGE2_MUX0_CHAN6, - I2C_STAGE2_MUX0_CHAN7, -}; - -enum bms_sb_switch_stage2_mux1_bus { - I2C_STAGE2_MUX1_CHAN8 = 0, - I2C_STAGE2_MUX1_CHAN9, - I2C_STAGE2_MUX1_CHAN10, - I2C_STAGE2_MUX1_CHAN11, - I2C_STAGE2_MUX1_CHAN12, - I2C_STAGE2_MUX1_CHAN13, - I2C_STAGE2_MUX1_CHAN14, - I2C_STAGE2_MUX1_CHAN15, -}; - -enum bms_sb_switch_stage2_mux2_bus { - I2C_STAGE2_MUX2_CHAN16 = 0, - I2C_STAGE2_MUX2_CHAN17, - I2C_STAGE2_MUX2_CHAN18, - I2C_STAGE2_MUX2_CHAN19, - I2C_STAGE2_MUX2_CHAN20, - I2C_STAGE2_MUX2_CHAN21, - I2C_STAGE2_MUX2_CHAN22, - I2C_STAGE2_MUX2_CHAN23, -}; - -enum bms_sb_switch_stage2_mux3_bus { - I2C_STAGE2_MUX3_CHAN24 = 0, - I2C_STAGE2_MUX3_CHAN25, - I2C_STAGE2_MUX3_CHAN26, - I2C_STAGE2_MUX3_CHAN27, - I2C_STAGE2_MUX3_CHAN28, - I2C_STAGE2_MUX3_CHAN29, - I2C_STAGE2_MUX3_CHAN30, - I2C_STAGE2_MUX3_CHAN31, -}; - -static struct pca954x_platform_mode pmode_pca9548_mux[] = { - { .adap_id = BMS_SB_ADAPTER_BASE + 0, }, - { .adap_id = BMS_SB_ADAPTER_BASE + 1, }, - { .adap_id = BMS_SB_ADAPTER_BASE + 2, }, - { .adap_id = BMS_SB_ADAPTER_BASE + 3, }, - { .adap_id = BMS_SB_ADAPTER_BASE + 4, }, - { .adap_id = BMS_SB_ADAPTER_BASE + 5, }, - { .adap_id = BMS_SB_ADAPTER_BASE + 6, }, - { .adap_id = BMS_SB_ADAPTER_BASE + 7, }, -}; - -static struct pca954x_platform_data platdata_pca9548_mux = { - .modes = pmode_pca9548_mux, - .num_modes = ARRAY_SIZE(pmode_pca9548_mux), -}; - -static struct pca954x_platform_mode pmode_stage1_pca9548_mux0[] = { - { .adap_id = BMS_SB_ADAPTER_BASE + 8, }, - { .adap_id = BMS_SB_ADAPTER_BASE + 9, }, - { .adap_id = BMS_SB_ADAPTER_BASE + 10, }, - { .adap_id = BMS_SB_ADAPTER_BASE + 11, }, - { .adap_id = BMS_SB_ADAPTER_BASE + 12, }, - { .adap_id = BMS_SB_ADAPTER_BASE + 13, }, - { .adap_id = BMS_SB_ADAPTER_BASE + 14, }, - { .adap_id = BMS_SB_ADAPTER_BASE + 15, }, -}; - -static struct pca954x_platform_data platdata_stage1_pca9548_mux0 = { - .modes = pmode_stage1_pca9548_mux0, - .num_modes = ARRAY_SIZE(pmode_stage1_pca9548_mux0), -}; - -static struct pca954x_platform_mode pmode_stage1_pca9548_mux1[] = { - { .adap_id = BMS_SB_ADAPTER_BASE + 16, }, - { .adap_id = BMS_SB_ADAPTER_BASE + 17, }, - { .adap_id = BMS_SB_ADAPTER_BASE + 18, }, - { .adap_id = BMS_SB_ADAPTER_BASE + 19, }, - { .adap_id = BMS_SB_ADAPTER_BASE + 20, }, - { .adap_id = BMS_SB_ADAPTER_BASE + 21, }, - { .adap_id = BMS_SB_ADAPTER_BASE + 22, }, - { .adap_id = BMS_SB_ADAPTER_BASE + 23, }, -}; - -static struct pca954x_platform_data platdata_stage1_pca9548_mux1 = { - .modes = pmode_stage1_pca9548_mux1, - .num_modes = ARRAY_SIZE(pmode_stage1_pca9548_mux1), -}; - -static struct pca954x_platform_mode pmode_stage1_pca9548_mux2[] = { - { .adap_id = BMS_SB_ADAPTER_BASE + 24, }, - { .adap_id = BMS_SB_ADAPTER_BASE + 25, }, - { .adap_id = BMS_SB_ADAPTER_BASE + 26, }, - { .adap_id = BMS_SB_ADAPTER_BASE + 27, }, - { .adap_id = BMS_SB_ADAPTER_BASE + 28, }, - { .adap_id = BMS_SB_ADAPTER_BASE + 29, }, - { .adap_id = BMS_SB_ADAPTER_BASE + 30, }, - { .adap_id = BMS_SB_ADAPTER_BASE + 31, }, -}; - -static struct pca954x_platform_data platdata_stage1_pca9548_mux2 = { - .modes = pmode_stage1_pca9548_mux2, - .num_modes = ARRAY_SIZE(pmode_stage1_pca9548_mux2), -}; - -static struct pca954x_platform_mode pmode_stage1_pca9548_mux3[] = { - { .adap_id = BMS_SB_ADAPTER_BASE + 32, }, - { .adap_id = BMS_SB_ADAPTER_BASE + 33, }, - { .adap_id = BMS_SB_ADAPTER_BASE + 34, }, - { .adap_id = BMS_SB_ADAPTER_BASE + 35, }, - { .adap_id = BMS_SB_ADAPTER_BASE + 36, }, - { .adap_id = BMS_SB_ADAPTER_BASE + 37, }, - { .adap_id = BMS_SB_ADAPTER_BASE + 38, }, - { .adap_id = BMS_SB_ADAPTER_BASE + 39, }, -}; - -static struct pca954x_platform_data platdata_stage1_pca9548_mux3 = { - .modes = pmode_stage1_pca9548_mux3, - .num_modes = ARRAY_SIZE(pmode_stage1_pca9548_mux3), -}; - -static int __init __find_i2c_adap(struct device *dev, void *data) -{ - const char *name = data; - static const char *prefix = "i2c-"; - struct i2c_adapter *adapter; - - if (strncmp(dev_name(dev), prefix, strlen(prefix)) != 0) - { - return 0; - } - adapter = to_i2c_adapter(dev); - - return (strncmp(adapter->name, name, strlen(name)) == 0); -} - -static int __init find_i2c_adapter_num(enum i2c_adapter_type type) -{ - struct device *dev = NULL; - struct i2c_adapter *adapter; - const char *name = bms_i2c_adapter_names[type]; - - /* find the adapter by name */ - dev = bus_find_device(&i2c_bus_type, NULL, (void *)name, - __find_i2c_adap); - if (!dev) { - pr_err("%s: i2c adapter %s not found on system.\n", - __func__, name); - return -ENODEV; - } - adapter = to_i2c_adapter(dev); - - return adapter->nr; -} - -static int __init find_i2c_mux_adapter_num(int parent_num, int num) -{ - struct device *dev = NULL; - struct i2c_adapter *adapter; - char name[48]; - - snprintf(name, sizeof(name), "i2c-%d-mux (chan_id %d)", - parent_num, num); - /* find the adapter by name */ - dev = bus_find_device(&i2c_bus_type, NULL, (void *)name, - __find_i2c_adap); - if (!dev) { - pr_err("%s: i2c adapter %s not found on system.\n", - __func__, name); - return -ENODEV; - } - adapter = to_i2c_adapter(dev); - - return adapter->nr; -} - -static __init struct i2c_client *bms_sb_setup_eeprom_24c04( - struct i2c_adapter *adap) -{ - struct i2c_board_info info_spd = { - I2C_BOARD_INFO("24c04", 0x50), - }; - - return i2c_new_device(adap, &info_spd); -} - -static __init struct i2c_client *bms_sb_setup_tmp75( - struct i2c_adapter *adap, int addr) -{ - struct i2c_board_info info_spd = { - I2C_BOARD_INFO("tmp75", addr), - }; - - return i2c_new_device(adap, &info_spd); -} - -static __init struct i2c_client *bms_sb_setup_switch(struct i2c_adapter *adap) -{ - struct i2c_board_info info = { - I2C_BOARD_INFO("pca9548", 0x70), - .platform_data = &platdata_pca9548_mux, - }; - - return i2c_new_device(adap, &info); -} - -static __init struct i2c_client *bms_sb_setup_stage1_mux0(struct i2c_adapter *adap) -{ - struct i2c_board_info info = { - I2C_BOARD_INFO("pca9548", 0x71), - .platform_data = &platdata_stage1_pca9548_mux0, - }; - - return i2c_new_device(adap, &info); -} - -static __init struct i2c_client *bms_sb_setup_stage1_mux1(struct i2c_adapter *adap) -{ - struct i2c_board_info info = { - I2C_BOARD_INFO("pca9548", 0x72), - .platform_data = &platdata_stage1_pca9548_mux1, - }; - - return i2c_new_device(adap, &info); -} - -static __init struct i2c_client *bms_sb_setup_stage1_mux2(struct i2c_adapter *adap) -{ - struct i2c_board_info info = { - I2C_BOARD_INFO("pca9548", 0x73), - .platform_data = &platdata_stage1_pca9548_mux2, - }; - - return i2c_new_device(adap, &info); -} - -static __init struct i2c_client *bms_sb_setup_stage1_mux3(struct i2c_adapter *adap) -{ - struct i2c_board_info info = { - I2C_BOARD_INFO("pca9548", 0x74), - .platform_data = &platdata_stage1_pca9548_mux3, - }; - - return i2c_new_device(adap, &info); -} - -static __init struct i2c_client *bms_sb_setup_slave_cpld(struct i2c_adapter *adap) -{ - struct i2c_board_info info = { - I2C_BOARD_INFO("slave_cpld", 0x33), - }; - - return i2c_new_device(adap, &info); -} - -static __init struct i2c_client *bms_sb_setup_master_cpld(struct i2c_adapter *adap) -{ - struct i2c_board_info info = { - I2C_BOARD_INFO("master_cpld", 0x32), - }; - - return i2c_new_device(adap, &info); -} - - -static int __init bms_sb_setup_devices_ismt(void) -{ - struct i2c_adapter *adap; - int adap_num = find_i2c_adapter_num(I2C_ADAPTER_ISMT); - - if (adap_num < 0) - return adap_num; - - adap = i2c_get_adapter(adap_num); - if (!adap) { - pr_err("%s failed to get i2c adap %d.\n", __func__, adap_num); - return 0; - } - - bms_sb_clients[bms_sb_client_index++] = bms_sb_setup_switch(adap); - bms_sb_clients[bms_sb_client_index++] = bms_sb_setup_master_cpld(adap); - bms_sb_clients[bms_sb_client_index++] = bms_sb_setup_slave_cpld(adap); - - return 0; -} - -static int __init bms_sb_setup_devices_stage1(void) -{ - struct i2c_adapter *adap; - int adap_num; - int parent_num; - - parent_num = find_i2c_adapter_num(I2C_ADAPTER_ISMT); - if (parent_num < 0) - return parent_num; - - /* Mux chan0 steup */ - adap_num = find_i2c_mux_adapter_num(parent_num, I2C_STAGE1_MUX_CHAN0); - if (adap_num >= 0){ - adap = i2c_get_adapter(adap_num); - if(adap) { - bms_sb_clients[bms_sb_client_index++] = bms_sb_setup_eeprom_24c04(adap); - }else{ - pr_err("%s failed to get i2c adap %d.\n", __func__, adap_num); - } - }else{ - pr_err("%s failed to find i2c mux adap number %d.\n", __func__, I2C_STAGE1_MUX_CHAN0); - } - - /* Mux chan1 connect to fan board */ - - /* Mux chan2 steup */ - adap_num = find_i2c_mux_adapter_num(parent_num, I2C_STAGE1_MUX_CHAN2); - if (adap_num >= 0){ - adap = i2c_get_adapter(adap_num); - if(adap) { - bms_sb_clients[bms_sb_client_index++] = bms_sb_setup_tmp75(adap, 0x4a); - bms_sb_clients[bms_sb_client_index++] = bms_sb_setup_tmp75(adap, 0x4b); - bms_sb_clients[bms_sb_client_index++] = bms_sb_setup_tmp75(adap, 0x4c); - }else{ - pr_err("%s failed to get i2c adap %d.\n", __func__, adap_num); - } - }else{ - pr_err("%s failed to find i2c mux adap number %d.\n", __func__, I2C_STAGE1_MUX_CHAN2); - } - - /* Mux chan3 connect to power board */ - - /* Mux chan4 setup for i2c mux0 */ - adap_num = find_i2c_mux_adapter_num(parent_num, I2C_STAGE1_MUX_CHAN4); - if (adap_num >= 0){ - adap = i2c_get_adapter(adap_num); - if(adap) { - bms_sb_clients[bms_sb_client_index++] = bms_sb_setup_stage1_mux0(adap); - }else{ - pr_err("%s failed to get i2c adap %d.\n", __func__, adap_num); - } - }else{ - pr_err("%s failed to find i2c mux adap number %d.\n", __func__, I2C_STAGE1_MUX_CHAN4); - } - - /* Mux chan5 setup for i2c mux1 */ - adap_num = find_i2c_mux_adapter_num(parent_num, I2C_STAGE1_MUX_CHAN5); - if (adap_num >= 0){ - adap = i2c_get_adapter(adap_num); - if(adap) { - bms_sb_clients[bms_sb_client_index++] = bms_sb_setup_stage1_mux1(adap); - }else{ - pr_err("%s failed to get i2c adap %d.\n", __func__, adap_num); - } - }else{ - pr_err("%s failed to find i2c mux adap number %d.\n", __func__, I2C_STAGE1_MUX_CHAN5); - } - - /* Mux chan6 setup for i2c mux2 */ - adap_num = find_i2c_mux_adapter_num(parent_num, I2C_STAGE1_MUX_CHAN6); - if (adap_num >= 0){ - adap = i2c_get_adapter(adap_num); - if(adap) { - bms_sb_clients[bms_sb_client_index++] = bms_sb_setup_stage1_mux2(adap); - }else{ - pr_err("%s failed to get i2c adap %d.\n", __func__, adap_num); - } - }else{ - pr_err("%s failed to find i2c mux adap number %d.\n", __func__, I2C_STAGE1_MUX_CHAN6); - } - - /* Mux chan7 setup for i2c mux3 */ - adap_num = find_i2c_mux_adapter_num(parent_num, I2C_STAGE1_MUX_CHAN7); - if (adap_num >= 0){ - adap = i2c_get_adapter(adap_num); - if(adap) { - bms_sb_clients[bms_sb_client_index++] = bms_sb_setup_stage1_mux3(adap); - }else{ - pr_err("%s failed to get i2c adap %d.\n", __func__, adap_num); - } - }else{ - pr_err("%s failed to find i2c mux adap number %d.\n", __func__, I2C_STAGE1_MUX_CHAN7); - } - - return 0; -} - -static int __init bms_sb_i2c_init(void) -{ - /* Initial bms_sb_slients array. */ - memset(bms_sb_clients, 0x0, BMS_SB_I2C_CLIENT_NUM); - - bms_sb_setup_devices_ismt(); - mdelay(200); - bms_sb_setup_devices_stage1(); - - return 0; -} - -static void __exit bms_sb_i2c_exit(void){ - int i; - - for (i=(bms_sb_client_index-1); i>=0; i--) { - if (bms_sb_clients[i]) { - i2c_unregister_device(bms_sb_clients[i]); - bms_sb_clients[i] = NULL; - } - } - - bms_sb_client_index = 0; - -} - -module_init(bms_sb_i2c_init); -module_exit(bms_sb_i2c_exit); - -MODULE_DESCRIPTION("mitac_ly1200_32x_sb_i2c driver"); -MODULE_AUTHOR("Eddy Weng "); -MODULE_LICENSE("GPL"); - diff --git a/packages/platforms/mitac/x86-64/ly1200-b32h0-c3/modules/builds/x86-64-mitac-ly1200-b32h0-c3-slave_cpld.c b/packages/platforms/mitac/x86-64/ly1200-b32h0-c3/modules/builds/x86-64-mitac-ly1200-b32h0-c3-slave_cpld.c deleted file mode 100644 index 8809573fa..000000000 --- a/packages/platforms/mitac/x86-64/ly1200-b32h0-c3/modules/builds/x86-64-mitac-ly1200-b32h0-c3-slave_cpld.c +++ /dev/null @@ -1,427 +0,0 @@ -#include -#include - -#include "slave_cpld_reg.h" -#include "slave_cpld_sysfs.h" - -static int debug_flag = 0; - -struct slave_cpld_data { - struct mutex lock; - - struct i2c_client *client; - struct device_attribute bin; -}; - - -static const struct i2c_device_id slave_cpld_ids[] = { - { "slave_cpld", 0 }, - { /* END OF LIST */ } -}; -MODULE_DEVICE_TABLE(i2c, slave_cpld_ids); - -static int slave_cpld_raw_read(struct device *dev, struct device_attribute *attr, char *buf, - int reg_offset, int reg_width, int fld_shift, int fld_width, int fld_mask, char* reg_name){ - unsigned int reg_val = 0, fld_val; - static int debug_flag; - struct slave_cpld_data *data = dev_get_drvdata(dev); - struct i2c_client *client = data->client; - int err; - - if (reg_width != 8){ - printk("%s: Register table width setting failed.\n", reg_name); - return -EINVAL; - } - mutex_lock(&data->lock); - if ((err = i2c_smbus_read_byte_data(client, (u8)reg_offset)) < 0) { - /* CPLD read error condition */; - mutex_unlock(&data->lock); - printk("%s: i2c read failed, error code = %d.\n", reg_name, err); - return err; - } - reg_val = err; - if (debug_flag) { - printk("%s: reg_offset = %d, width = %d, cur value = 0x%x.\n", reg_name, reg_offset, reg_width, reg_val); - } - mutex_unlock(&data->lock); - if (fld_width == reg_width) {fld_val = reg_val & fld_mask;} - else {fld_val = (reg_val >> fld_shift) & fld_mask;} - return sprintf(buf, "0x%x\n", fld_val); -} - -static int slave_cpld_raw_write(struct device *dev, struct device_attribute *attr, const char *buf, size_t count, - int reg_offset, int reg_width, int fld_shift, int fld_width, int fld_mask, char* reg_name){ - int ret_code; - unsigned int reg_val, fld_val; - unsigned long val; - static int debug_flag; - struct slave_cpld_data *data = dev_get_drvdata(dev); - struct i2c_client *client = data->client; - if (reg_width != 8){ - printk("%s: Register table width setting failed.\n", reg_name); - return -EINVAL; - } - /* Parse buf and store to fld_val */ - if ((ret_code = kstrtoul(buf, 16, &val))){ - printk("%s: Conversion value = %s failed, errno = %d.\n", reg_name, buf, ret_code); - return ret_code; - } - fld_val = (unsigned int)val; - mutex_lock(&data->lock); - if ((ret_code = i2c_smbus_read_byte_data(client, (u8)reg_offset)) < 0) { - /* Handle CPLD read error condition */; - mutex_unlock(&data->lock); - printk("%s: i2c read failed, error code = %d.\n", reg_name, ret_code); - return ret_code; - } - reg_val = ret_code; - if (debug_flag) { - printk("%s: offset = %d, width = %d, cur value = 0x%x.\n", reg_name, reg_offset, reg_width, reg_val); - } - if (fld_width == reg_width) {reg_val = fld_val & fld_mask;} - else {reg_val = (reg_val & ~(fld_mask << fld_shift)) | - ((fld_val & (fld_mask)) << fld_shift);} - if ((ret_code = i2c_smbus_write_byte_data(client, (u8)reg_offset, (u8)reg_val)) != 0) { - /* Handle CPLD write error condition */; - mutex_unlock(&data->lock); - printk("%s: i2c write failed, error code = %d.\n", reg_name, ret_code); - return ret_code; - } - else if (debug_flag) { - printk("%s: offset = %d, width = %d, new value = 0x%x.\n", reg_name, reg_offset, reg_width, reg_val); - } - mutex_unlock(&data->lock); - return count; -} - -/*--------------------special file for debug---------------------- */ -static ssize_t slave_cpld_debug_read(struct device *dev, struct device_attribute *attr, - char *buf){ - - return sprintf(buf, "%d\n", debug_flag); -} - - -static ssize_t slave_cpld_debug_write(struct device *dev, struct device_attribute *attr, - const char *buf, size_t count) -{ - int temp; - int error; - - error = kstrtoint(buf, 10, &temp); - if (error){ - printk(KERN_INFO "%s: Conversion value = %s failed.\n", __FUNCTION__, buf); - return count; - } - debug_flag = temp; - - if(debug_flag) - printk("%s, debug_flag = %d\n", __FUNCTION__, debug_flag); - - return count; -} -SYSFS_MISC_RW_ATTR_DEF(debug, slave_cpld_debug_read, slave_cpld_debug_write) - - - - -/* ----------------define port group---------------------------- */ -static struct attribute *port17_attributes[] = { - SYSFS_ATTR_PTR(port17_present), /* register: zqsfp28_present_24_17_status */ - SYSFS_ATTR_PTR(port17_rst), /* register: zqsfp28_rst_24_17 */ - SYSFS_ATTR_PTR(port17_modsel), /* register: zqsfp28_modsel_24_17 */ - SYSFS_ATTR_PTR(port17_lpmode), /* register: zqsfp28_lpmode_24_17 */ - SYSFS_ATTR_PTR(port17_irq_status), /* register: zqsfp28_irq_24_17_status */ - SYSFS_ATTR_PTR(port17_irq_msk), /* register: zqsfp28_irq_msk_24_17_status */ - NULL -}; - -static struct attribute *port18_attributes[] = { - SYSFS_ATTR_PTR(port18_present), /* register: zqsfp28_present_24_17_status */ - SYSFS_ATTR_PTR(port18_rst), /* register: zqsfp28_rst_24_17 */ - SYSFS_ATTR_PTR(port18_modsel), /* register: zqsfp28_modsel_24_17 */ - SYSFS_ATTR_PTR(port18_lpmode), /* register: zqsfp28_lpmode_24_17 */ - SYSFS_ATTR_PTR(port18_irq_status), /* register: zqsfp28_irq_24_17_status */ - SYSFS_ATTR_PTR(port18_irq_msk), /* register: zqsfp28_irq_msk_24_17_status */ - NULL -}; - -static struct attribute *port19_attributes[] = { - SYSFS_ATTR_PTR(port19_present), /* register: zqsfp28_present_24_17_status */ - SYSFS_ATTR_PTR(port19_rst), /* register: zqsfp28_rst_24_17 */ - SYSFS_ATTR_PTR(port19_modsel), /* register: zqsfp28_modsel_24_17 */ - SYSFS_ATTR_PTR(port19_lpmode), /* register: zqsfp28_lpmode_24_17 */ - SYSFS_ATTR_PTR(port19_irq_status), /* register: zqsfp28_irq_24_17_status */ - SYSFS_ATTR_PTR(port19_irq_msk), /* register: zqsfp28_irq_msk_24_17_status */ - NULL -}; - -static struct attribute *port20_attributes[] = { - SYSFS_ATTR_PTR(port20_present), /* register: zqsfp28_present_24_17_status */ - SYSFS_ATTR_PTR(port20_rst), /* register: zqsfp28_rst_24_17 */ - SYSFS_ATTR_PTR(port20_modsel), /* register: zqsfp28_modsel_24_17 */ - SYSFS_ATTR_PTR(port20_lpmode), /* register: zqsfp28_lpmode_24_17 */ - SYSFS_ATTR_PTR(port20_irq_status), /* register: zqsfp28_irq_24_17_status */ - SYSFS_ATTR_PTR(port20_irq_msk), /* register: zqsfp28_irq_msk_24_17_status */ - NULL -}; - -static struct attribute *port21_attributes[] = { - SYSFS_ATTR_PTR(port21_present), /* register: zqsfp28_present_24_17_status */ - SYSFS_ATTR_PTR(port21_rst), /* register: zqsfp28_rst_24_17 */ - SYSFS_ATTR_PTR(port21_modsel), /* register: zqsfp28_modsel_24_17 */ - SYSFS_ATTR_PTR(port21_lpmode), /* register: zqsfp28_lpmode_24_17 */ - SYSFS_ATTR_PTR(port21_irq_status), /* register: zqsfp28_irq_24_17_status */ - SYSFS_ATTR_PTR(port21_irq_msk), /* register: zqsfp28_irq_msk_24_17_status */ - NULL -}; - -static struct attribute *port22_attributes[] = { - SYSFS_ATTR_PTR(port22_present), /* register: zqsfp28_present_24_17_status */ - SYSFS_ATTR_PTR(port22_rst), /* register: zqsfp28_rst_24_17 */ - SYSFS_ATTR_PTR(port22_modsel), /* register: zqsfp28_modsel_24_17 */ - SYSFS_ATTR_PTR(port22_lpmode), /* register: zqsfp28_lpmode_24_17 */ - SYSFS_ATTR_PTR(port22_irq_status), /* register: zqsfp28_irq_24_17_status */ - SYSFS_ATTR_PTR(port22_irq_msk), /* register: zqsfp28_irq_msk_24_17_status */ - NULL -}; - -static struct attribute *port23_attributes[] = { - SYSFS_ATTR_PTR(port23_present), /* register: zqsfp28_present_24_17_status */ - SYSFS_ATTR_PTR(port23_rst), /* register: zqsfp28_rst_24_17 */ - SYSFS_ATTR_PTR(port23_modsel), /* register: zqsfp28_modsel_24_17 */ - SYSFS_ATTR_PTR(port23_lpmode), /* register: zqsfp28_lpmode_24_17 */ - SYSFS_ATTR_PTR(port23_irq_status), /* register: zqsfp28_irq_24_17_status */ - SYSFS_ATTR_PTR(port23_irq_msk), /* register: zqsfp28_irq_msk_24_17_status */ - NULL -}; - -static struct attribute *port24_attributes[] = { - SYSFS_ATTR_PTR(port24_present), /* register: zqsfp28_present_24_17_status */ - SYSFS_ATTR_PTR(port24_rst), /* register: zqsfp28_rst_24_17 */ - SYSFS_ATTR_PTR(port24_modsel), /* register: zqsfp28_modsel_24_17 */ - SYSFS_ATTR_PTR(port24_lpmode), /* register: zqsfp28_lpmode_24_17 */ - SYSFS_ATTR_PTR(port24_irq_status), /* register: zqsfp28_irq_24_17_status */ - SYSFS_ATTR_PTR(port24_irq_msk), /* register: zqsfp28_irq_msk_24_17_status */ - NULL -}; - -static struct attribute *port25_attributes[] = { - SYSFS_ATTR_PTR(port25_present), /* register: zqsfp28_present_32_25_status */ - SYSFS_ATTR_PTR(port25_rst), /* register: zqsfp28_rst_32_25 */ - SYSFS_ATTR_PTR(port25_modsel), /* register: zqsfp28_modsel_32_25 */ - SYSFS_ATTR_PTR(port25_lpmode), /* register: zqsfp28_lpmode_32_25 */ - SYSFS_ATTR_PTR(port25_irq_status), /* register: zqsfp28_irq_32_25_status */ - SYSFS_ATTR_PTR(port25_irq_msk), /* register: zqsfp28_irq_msk_32_25_status */ - NULL -}; - -static struct attribute *port26_attributes[] = { - SYSFS_ATTR_PTR(port26_present), /* register: zqsfp28_present_32_25_status */ - SYSFS_ATTR_PTR(port26_rst), /* register: zqsfp28_rst_32_25 */ - SYSFS_ATTR_PTR(port26_modsel), /* register: zqsfp28_modsel_32_25 */ - SYSFS_ATTR_PTR(port26_lpmode), /* register: zqsfp28_lpmode_32_25 */ - SYSFS_ATTR_PTR(port26_irq_status), /* register: zqsfp28_irq_32_25_status */ - SYSFS_ATTR_PTR(port26_irq_msk), /* register: zqsfp28_irq_msk_32_25_status */ - NULL -}; - -static struct attribute *port27_attributes[] = { - SYSFS_ATTR_PTR(port27_present), /* register: zqsfp28_present_32_25_status */ - SYSFS_ATTR_PTR(port27_rst), /* register: zqsfp28_rst_32_25 */ - SYSFS_ATTR_PTR(port27_modsel), /* register: zqsfp28_modsel_32_25 */ - SYSFS_ATTR_PTR(port27_lpmode), /* register: zqsfp28_lpmode_32_25 */ - SYSFS_ATTR_PTR(port27_irq_status), /* register: zqsfp28_irq_32_25_status */ - SYSFS_ATTR_PTR(port27_irq_msk), /* register: zqsfp28_irq_msk_32_25_status */ - NULL -}; - -static struct attribute *port28_attributes[] = { - SYSFS_ATTR_PTR(port28_present), /* register: zqsfp28_present_32_25_status */ - SYSFS_ATTR_PTR(port28_rst), /* register: zqsfp28_rst_32_25 */ - SYSFS_ATTR_PTR(port28_modsel), /* register: zqsfp28_modsel_32_25 */ - SYSFS_ATTR_PTR(port28_lpmode), /* register: zqsfp28_lpmode_32_25 */ - SYSFS_ATTR_PTR(port28_irq_status), /* register: zqsfp28_irq_32_25_status */ - SYSFS_ATTR_PTR(port28_irq_msk), /* register: zqsfp28_irq_msk_32_25_status */ - NULL -}; - -static struct attribute *port29_attributes[] = { - SYSFS_ATTR_PTR(port29_present), /* register: zqsfp28_present_32_25_status */ - SYSFS_ATTR_PTR(port29_rst), /* register: zqsfp28_rst_32_25 */ - SYSFS_ATTR_PTR(port29_modsel), /* register: zqsfp28_modsel_32_25 */ - SYSFS_ATTR_PTR(port29_lpmode), /* register: zqsfp28_lpmode_32_25 */ - SYSFS_ATTR_PTR(port29_irq_status), /* register: zqsfp28_irq_32_25_status */ - SYSFS_ATTR_PTR(port29_irq_msk), /* register: zqsfp28_irq_msk_32_25_status */ - NULL -}; - -static struct attribute *port30_attributes[] = { - SYSFS_ATTR_PTR(port30_present), /* register: zqsfp28_present_32_25_status */ - SYSFS_ATTR_PTR(port30_rst), /* register: zqsfp28_rst_32_25 */ - SYSFS_ATTR_PTR(port30_modsel), /* register: zqsfp28_modsel_32_25 */ - SYSFS_ATTR_PTR(port30_lpmode), /* register: zqsfp28_lpmode_32_25 */ - SYSFS_ATTR_PTR(port30_irq_status), /* register: zqsfp28_irq_32_25_status */ - SYSFS_ATTR_PTR(port30_irq_msk), /* register: zqsfp28_irq_msk_32_25_status */ - NULL -}; - -static struct attribute *port31_attributes[] = { - SYSFS_ATTR_PTR(port31_present), /* register: zqsfp28_present_32_25_status */ - SYSFS_ATTR_PTR(port31_rst), /* register: zqsfp28_rst_32_25 */ - SYSFS_ATTR_PTR(port31_modsel), /* register: zqsfp28_modsel_32_25 */ - SYSFS_ATTR_PTR(port31_lpmode), /* register: zqsfp28_lpmode_32_25 */ - SYSFS_ATTR_PTR(port31_irq_status), /* register: zqsfp28_irq_32_25_status */ - SYSFS_ATTR_PTR(port31_irq_msk), /* register: zqsfp28_irq_msk_32_25_status */ - NULL -}; - -static struct attribute *port32_attributes[] = { - SYSFS_ATTR_PTR(port32_present), /* register: zqsfp28_present_32_25_status */ - SYSFS_ATTR_PTR(port32_rst), /* register: zqsfp28_rst_32_25 */ - SYSFS_ATTR_PTR(port32_modsel), /* register: zqsfp28_modsel_32_25 */ - SYSFS_ATTR_PTR(port32_lpmode), /* register: zqsfp28_lpmode_32_25 */ - SYSFS_ATTR_PTR(port32_irq_status), /* register: zqsfp28_irq_32_25_status */ - SYSFS_ATTR_PTR(port32_irq_msk), /* register: zqsfp28_irq_msk_32_25_status */ - NULL -}; - -static const struct attribute_group slave_cpld_port_group[] = { - {.attrs = port17_attributes, - .name = "port17",}, - {.attrs = port18_attributes, - .name = "port18",}, - {.attrs = port19_attributes, - .name = "port19",}, - {.attrs = port20_attributes, - .name = "port20",}, - {.attrs = port21_attributes, - .name = "port21",}, - {.attrs = port22_attributes, - .name = "port22",}, - {.attrs = port23_attributes, - .name = "port23",}, - {.attrs = port24_attributes, - .name = "port24",}, - {.attrs = port25_attributes, - .name = "port25",}, - {.attrs = port26_attributes, - .name = "port26",}, - {.attrs = port27_attributes, - .name = "port27",}, - {.attrs = port28_attributes, - .name = "port28",}, - {.attrs = port29_attributes, - .name = "port29",}, - {.attrs = port30_attributes, - .name = "port30",}, - {.attrs = port31_attributes, - .name = "port31",}, - {.attrs = port32_attributes, - .name = "port32",} -}; - -/* ----------------define misc group---------------------------- */ -static struct attribute *misc_attributes[] = { - SYSFS_ATTR_PTR(mjr_rev), /* register: slv_cpld_rev */ - SYSFS_ATTR_PTR(mnr_rev), /* register: slv_cpld_rev */ - SYSFS_ATTR_PTR(scrtch_reg), /* register: slv_cpld_gpr */ - SYSFS_ATTR_PTR(brd_rev), /* register: mb_brd_rev_type */ - SYSFS_ATTR_PTR(brd_type), /* register: mb_brd_rev_type */ - - SYSFS_ATTR_PTR(port_17_24_present), /* register: zqsfp28_present_24_17_status */ - SYSFS_ATTR_PTR(port_25_32_present), /* register: zqsfp28_present_32_25_status */ - SYSFS_ATTR_PTR(port_17_24_rst), /* register: zqsfp28_rst_24_17 */ - SYSFS_ATTR_PTR(port_25_32_rst), /* register: zqsfp28_rst_32_25 */ - SYSFS_ATTR_PTR(port_17_24_modsel), /* register: zqsfp28_modsel_24_17 */ - SYSFS_ATTR_PTR(port_25_32_modsel), /* register: zqsfp28_modsel_32_25 */ - SYSFS_ATTR_PTR(port_17_24_irq_status),/* register: zqsfp28_irq_24_17_status */ - SYSFS_ATTR_PTR(port_25_32_irq_status),/* register: zqsfp28_irq_32_25_status */ - SYSFS_ATTR_PTR(port_17_24_irq_msk), /* register: zqsfp28_irq_msk_24_17_status */ - SYSFS_ATTR_PTR(port_25_32_irq_msk), /* register: zqsfp28_irq_msk_32_25_status */ - SYSFS_ATTR_PTR(port_17_24_lpmode), /* register: zqsfp28_lpmode_24_17 */ - SYSFS_ATTR_PTR(port_25_32_lpmode), /* register: zqsfp28_lpmode_32_25 */ - - SYSFS_ATTR_PTR(debug), /* debug flag for print more messages */ - NULL -}; -static const struct attribute_group slave_cpld_group_misc = { - .attrs = misc_attributes, -}; - -static int slave_cpld_probe(struct i2c_client *client, const struct i2c_device_id *id) -{ - struct slave_cpld_data *slave_cpld; - int err, i; - int grp_number = (int)( sizeof(slave_cpld_port_group) / sizeof(slave_cpld_port_group[0])); - - /* allocate memory to slave_cpld */ - slave_cpld = devm_kzalloc(&client->dev, sizeof(struct slave_cpld_data) , GFP_KERNEL); - - if (!slave_cpld) - return -ENOMEM; - - mutex_init(&slave_cpld->lock); - - for(i = 0 ; i < grp_number ; i++){ - err = sysfs_create_group(&client->dev.kobj, &slave_cpld_port_group[i]); - if (err){ - printk("%s: Error creeat port group %d.\n", __FUNCTION__, i+1); - } - } - err = sysfs_create_group(&client->dev.kobj, &slave_cpld_group_misc); - if (err){ - printk("%s: Error creeat misc group.\n", __FUNCTION__); - } - - slave_cpld->client = client; - i2c_set_clientdata(client, slave_cpld); - - printk(KERN_INFO "%s: Slave CPLD LCMXO3LF created.\n", __FUNCTION__); - - return 0; - -} - -static int slave_cpld_remove(struct i2c_client *client) -{ - int i; - int grp_number = (int)( sizeof(slave_cpld_port_group) / sizeof(slave_cpld_port_group[0])); - - for(i = 0 ; i < grp_number ; i++){ - sysfs_remove_group(&client->dev.kobj, &slave_cpld_port_group[i]); - } - sysfs_remove_group(&client->dev.kobj, &slave_cpld_group_misc); - - printk(KERN_INFO "%s: Slave CPLD removed.\n", __FUNCTION__); - return 0; -} - -static struct i2c_driver slave_cpld_driver = { - .driver = { - .name = "slave_cpld", - .owner = THIS_MODULE, - }, - .probe = slave_cpld_probe, - .remove = slave_cpld_remove, - .id_table = slave_cpld_ids, -}; - -static int __init slave_cpld_init(void) -{ - printk(KERN_INFO "%s: init.\n", __FUNCTION__); - return i2c_add_driver(&slave_cpld_driver); -} -module_init(slave_cpld_init); - -static void __exit slave_cpld_exit(void) -{ - printk(KERN_INFO "%s: exit.\n", __FUNCTION__); - i2c_del_driver(&slave_cpld_driver); -} -module_exit(slave_cpld_exit); - -MODULE_DESCRIPTION("mitac_ly1200_32x_slave_cpld driver"); -MODULE_AUTHOR("Eddy Weng "); -MODULE_LICENSE("GPL"); - diff --git a/packages/platforms/mitac/x86-64/ly1200-b32h0-c3/modules/builds/x86-64-mitac-ly1200-b32h0-c3-system_cpld.c b/packages/platforms/mitac/x86-64/ly1200-b32h0-c3/modules/builds/x86-64-mitac-ly1200-b32h0-c3-system_cpld.c deleted file mode 100644 index 832d97052..000000000 --- a/packages/platforms/mitac/x86-64/ly1200-b32h0-c3/modules/builds/x86-64-mitac-ly1200-b32h0-c3-system_cpld.c +++ /dev/null @@ -1,556 +0,0 @@ -#define CONFIG_DRV_SYSCPLD_WDT 1 - -#include -#include - -#include "system_cpld_reg.h" -#include "system_cpld_sysfs.h" - -#define MIC_DEBUG_TAG " [mitac] " -#define MITAC_WDT_MINOR 135 -#define MITAC_WDT_NAME "watchdog5" - -#if CONFIG_DRV_SYSCPLD_WDT -#include -#include -#include -#include -#include -#include -#endif - -static int debug_flag = 0; - -struct system_cpld_data { - struct mutex lock; - - struct i2c_client *client; - struct device_attribute bin; -}; -struct system_cpld_data *system_cpld; - -static const struct i2c_device_id system_cpld_ids[] = { - { "system_cpld", 0 }, - { /* END OF LIST */ } -}; -MODULE_DEVICE_TABLE(i2c, system_cpld_ids); - -static int system_cpld_raw_read(struct device *dev, struct device_attribute *attr, char *buf, - int reg_offset, int reg_width, int fld_shift, int fld_width, int fld_mask, char* reg_name){ - unsigned int reg_val = 0, fld_val; - struct system_cpld_data *data = dev_get_drvdata(dev); - struct i2c_client *client = data->client; - int err; - - if (reg_width != 8){ - printk("%s: Register table width setting failed.\n", reg_name); - return -EINVAL; - } - mutex_lock(&data->lock); - if ((err = i2c_smbus_read_byte_data(client, (u8)reg_offset)) < 0) { - /* CPLD read error condition */; - mutex_unlock(&data->lock); - printk("%s: i2c read failed, error code = %d.\n", reg_name, err); - return err; - } - reg_val = err; - if (debug_flag) { - printk("%s: reg_offset = %d, width = %d, cur value = 0x%x.\n", reg_name, reg_offset, reg_width, reg_val); - } - mutex_unlock(&data->lock); - if (fld_width == reg_width) {fld_val = reg_val & fld_mask;} - else {fld_val = (reg_val >> fld_shift) & fld_mask;} - return sprintf(buf, "0x%x\n", fld_val); -} - -static int system_cpld_raw_write(struct device *dev, struct device_attribute *attr, const char *buf, size_t count, - int reg_offset, int reg_width, int fld_shift, int fld_width, int fld_mask, char* reg_name){ - int ret_code; - unsigned int reg_val, fld_val; - unsigned long val; - struct system_cpld_data *data = dev_get_drvdata(dev); - struct i2c_client *client = data->client; - if (reg_width != 8){ - printk("%s: Register table width setting failed.\n", reg_name); - return -EINVAL; - } - /* Parse buf and store to fld_val */ - if ((ret_code = kstrtoul(buf, 16, &val))){ - printk("%s: Conversion value = %s failed, errno = %d.\n", reg_name, buf, ret_code); - return ret_code; - } - fld_val = (unsigned int)val; - mutex_lock(&data->lock); - if ((ret_code = i2c_smbus_read_byte_data(client, (u8)reg_offset)) < 0) { - /* Handle CPLD read error condition */; - mutex_unlock(&data->lock); - printk("%s: i2c read failed, error code = %d.\n", reg_name, ret_code); - return ret_code; - } - reg_val = ret_code; - if (debug_flag) { - printk("%s: offset = %d, width = %d, cur value = 0x%x.\n", reg_name, reg_offset, reg_width, reg_val); - } - if (fld_width == reg_width) {reg_val = fld_val & fld_mask;} - else {reg_val = (reg_val & ~(fld_mask << fld_shift)) | - ((fld_val & (fld_mask)) << fld_shift);} - if ((ret_code = i2c_smbus_write_byte_data(client, (u8)reg_offset, (u8)reg_val)) != 0) { - /* Handle CPLD write error condition */; - mutex_unlock(&data->lock); - printk("%s: i2c write failed, error code = %d.\n", reg_name, ret_code); - return ret_code; - } - else if (debug_flag) { - printk("%s: offset = %d, width = %d, new value = 0x%x.\n", reg_name, reg_offset, reg_width, reg_val); - } - mutex_unlock(&data->lock); - return count; -} - -/*--------------------special file for debug---------------------- */ -static ssize_t system_cpld_debug_read(struct device *dev, struct device_attribute *attr, - char *buf){ - - return sprintf(buf, "%d\n", debug_flag); -} - - -static ssize_t system_cpld_debug_write(struct device *dev, struct device_attribute *attr, - const char *buf, size_t count) -{ - int temp; - int error; - - error = kstrtoint(buf, 10, &temp); - if (error){ - printk(KERN_INFO "%s: Conversion value = %s failed.\n", __FUNCTION__, buf); - return count; - } - debug_flag = temp; - - if(debug_flag) - printk("%s, debug_flag = %d\n", __FUNCTION__, debug_flag); - - return count; -} -SYSFS_MISC_RW_ATTR_DEF(debug, system_cpld_debug_read, system_cpld_debug_write) - - -/* ----------------define misc group---------------------------- */ -static struct attribute *misc_attributes[] = { - SYSFS_ATTR_PTR(mjr_rev), /* register: sys_cpld_rev */ - SYSFS_ATTR_PTR(mnr_rev), /* register: sys_cpld_rev */ - - SYSFS_ATTR_PTR(scrtch_reg), /* register: sys_cpld_gpr */ - - SYSFS_ATTR_PTR(brd_rev), /* register: cpu_brd_rev_type */ - SYSFS_ATTR_PTR(brd_type), /* register: cpu_brd_rev_type */ - - SYSFS_ATTR_PTR(ssd_present), /* register: sys_srr */ - SYSFS_ATTR_PTR(spi_cs_sel), /* register: sys_srr */ - SYSFS_ATTR_PTR(rst_bios_switch), /* register: sys_srr */ - SYSFS_ATTR_PTR(cpld_upgrade_rst), /* register: sys_srr */ - - SYSFS_ATTR_PTR(cpld_spi_wp), /* register: sys_eeprom_wp */ - SYSFS_ATTR_PTR(system_id_eeprom_wp), /* register: sys_eeprom_wp */ - SYSFS_ATTR_PTR(spi_me_wp), /* register: sys_eeprom_wp */ - SYSFS_ATTR_PTR(spi_bios_wp), /* register: sys_eeprom_wp */ - SYSFS_ATTR_PTR(spi_bak_bios_wp), /* register: sys_eeprom_wp */ - - SYSFS_ATTR_PTR(vrhot_irq_en), /* register: sys_irq */ - SYSFS_ATTR_PTR(cpu_thermtrip_irq_en), /* register: sys_irq */ - SYSFS_ATTR_PTR(temp_alert_irq_en), /* register: sys_irq */ - SYSFS_ATTR_PTR(vrhot_irq), /* register: sys_irq */ - SYSFS_ATTR_PTR(cpu_thermtrip_irq), /* register: sys_irq */ - SYSFS_ATTR_PTR(temp_alert_irq), /* register: sys_irq */ - - SYSFS_ATTR_PTR(wd_timer), /* register: sys_wd */ - SYSFS_ATTR_PTR(wd_en), /* register: sys_wd */ - SYSFS_ATTR_PTR(wd_punch), /* register: sys_wd */ - - SYSFS_ATTR_PTR(mb_rst_en), /* register: sys_mb_rst_en */ - - SYSFS_ATTR_PTR(pwr_v3p3_en), /* register: cpu_pwr_en_status */ - SYSFS_ATTR_PTR(pwr_vcc_vnn_en), /* register: cpu_pwr_en_status */ - SYSFS_ATTR_PTR(pwr_vccsram_en), /* register: cpu_pwr_en_status */ - SYSFS_ATTR_PTR(pwr_vddq_en), /* register: cpu_pwr_en_status */ - SYSFS_ATTR_PTR(pwr_vcc_ref_en), /* register: cpu_pwr_en_status */ - SYSFS_ATTR_PTR(pwr_v1p05_en), /* register: cpu_pwr_en_status */ - SYSFS_ATTR_PTR(pwr_v1p8_en), /* register: cpu_pwr_en_status */ - SYSFS_ATTR_PTR(pwr_v2p5_en), /* register: cpu_pwr_en_status */ - - SYSFS_ATTR_PTR(pg_v3p3), /* register: cpu_pwr_status */ - SYSFS_ATTR_PTR(pg_vcc_vnn), /* register: cpu_pwr_status */ - SYSFS_ATTR_PTR(pg_vccsram), /* register: cpu_pwr_status */ - SYSFS_ATTR_PTR(pg_vddq), /* register: cpu_pwr_status */ - SYSFS_ATTR_PTR(pg_vcc_ref), /* register: cpu_pwr_status */ - SYSFS_ATTR_PTR(pg_v1p05), /* register: cpu_pwr_status */ - SYSFS_ATTR_PTR(pg_v1p8), /* register: cpu_pwr_status */ - SYSFS_ATTR_PTR(pg_v2p5), /* register: cpu_pwr_status */ - - SYSFS_ATTR_PTR(sys_reboot_cause_fld), /* register: sys_reboot_cause */ - - SYSFS_ATTR_PTR(debug), /* debug flag for print more messages */ - NULL -}; -static const struct attribute_group system_cpld_group_misc = { - .attrs = misc_attributes, -}; - -#if CONFIG_DRV_SYSCPLD_WDT -/* - ***************************************************************************** - * - * Watchdog Driver - * - ***************************************************************************** - */ -/* wdt_timeout[] are defined by CPLD spec , -1 means researved - 300 sec is not supported */ -int wdt_timeout[]={15,30,60,90,120,180,240,300,-1,-1,-1,-1,-1,-1,-1,-1}; -#define WD_TIMO_MAX_NUM 16 -/* Default margin */ -#define WD_TIMO 30 - -static int wdt_margin = WD_TIMO; -module_param(wdt_margin, int, 0); -MODULE_PARM_DESC(wdt_margin, "Watchdog timeout in seconds (default " - __MODULE_STRING(WD_TIMO) "s)"); - -static unsigned long wdt_is_open; -static int boot_flag; - -/** - * wdt_ping: - * - * Reload counter one with the watchdog timeout. We don't bother reloading - * the cascade counter. - */ -static void wdt_ping(void) -{ - struct device *dev = &system_cpld->client->dev; - struct device_attribute *fake_attr=NULL; - char *buf="0";/* 0: punch is defined by CPLD spec */ - int err; - err = system_cpld_wd_punch_raw_write(dev, fake_attr, buf, (size_t)0); - if(err < 0){ - system_cpld_wd_punch_raw_write(dev, fake_attr, buf, (size_t)0); - } -} - -/** - * wdt_disable: - * - * disables watchdog. - */ -static void wdt_disable(void) -{ - struct device *dev = &system_cpld->client->dev; - struct device_attribute *fake_attr=NULL; - char *buf="0";/* 0: disable is defined by CPLD spec */ - int err; - err = system_cpld_wd_en_raw_write(dev, fake_attr, buf, (size_t)0); - if(err < 0){ - system_cpld_wd_en_raw_write(dev, fake_attr, buf, (size_t)0); - } -} - -/** - * wdt_enable: - * - * enables watchdog. - */ -static void wdt_enable(void) -{ - struct device *dev = &system_cpld->client->dev; - struct device_attribute *fake_attr=NULL; - char *buf="1";/* 1: enable is defined by CPLD spec */ - int err; - err = system_cpld_wd_en_raw_write(dev, fake_attr, buf, (size_t)0); - if(err < 0){ - system_cpld_wd_en_raw_write(dev, fake_attr, buf, (size_t)0); - } -} - -/** - * wdt_set_timeout: - * - * set watchdog timeout. - */ -static void wdt_set_timeout(int index) -{ - struct device *dev = &system_cpld->client->dev; - struct device_attribute *fake_attr=NULL; - char buf[16]; - if ( WD_TIMO_MAX_NUM == 16 ) { - snprintf(buf, 16, "%x",index); - system_cpld_wd_timer_raw_write(dev, fake_attr, buf, (size_t)0); - } - else - printk(KERN_INFO "%s: It is out of spec.\n", __FUNCTION__); -} - -/** - * wdt_write: - * @file: file handle to the watchdog - * @buf: buffer to write (unused as data does not matter here - * @count: count of bytes - * @ppos: pointer to the position to write. No seeks allowed - * - * A write to a watchdog device is defined as a keepalive signal. Any - * write of data will do, as we we don't define content meaning. - */ -static ssize_t wdt_write(struct file *file, const char __user *buf, - size_t count, loff_t *ppos) -{ - if (count) { - wdt_ping(); - return 1; - } - return 0; -} - -/** - * wdt_ioctl: - * @inode: inode of the device - * @file: file handle to the device - * @cmd: watchdog command - * @arg: argument pointer - * - * The watchdog API defines a common set of functions for all watchdogs - * according to their available features. We only actually usefully support - * querying capabilities and current status. - */ -static int wdt_ioctl(struct file *file, unsigned int cmd, - unsigned long arg) -{ - int new_margin, rv, i; - static struct watchdog_info ident = { - .options = WDIOF_KEEPALIVEPING | WDIOF_SETTIMEOUT, - .firmware_version = 1, - .identity = "SYS_CPLD WTD" - }; - - switch (cmd) { - case WDIOC_GETSUPPORT: - return copy_to_user((struct watchdog_info __user *)arg, &ident, - sizeof(ident)) ? -EFAULT : 0; - - case WDIOC_GETSTATUS: - case WDIOC_GETBOOTSTATUS: - return put_user(boot_flag, (int __user *)arg); - case WDIOC_KEEPALIVE: - wdt_ping(); - return 0; - case WDIOC_SETTIMEOUT: - if (get_user(new_margin, (int __user *)arg)) - return -EFAULT; - /* Arbitrary, can't find the card's limits */ - if (new_margin <= 1) - return -EINVAL; - for( i=0; i= WD_TIMO_MAX_NUM || i < 0 ) - return -EINVAL; - wdt_set_timeout(i); - case WDIOC_GETTIMEOUT: - return put_user(wdt_margin, (int __user *)arg); - - case WDIOC_SETOPTIONS: - if (copy_from_user(&rv, (int __user *)arg, sizeof(int))) - return -EFAULT; - - if (rv & WDIOS_DISABLECARD) { - pr_info("System CPLD: disable watchdog\n"); - wdt_disable(); - } - - if (rv & WDIOS_ENABLECARD) { - pr_info("System CPLD: enable watchdog\n"); - wdt_enable(); - } - return -EINVAL; - } - return -ENOTTY; -} - -static long wdt_unlocked_ioctl(struct file *file, unsigned int cmd, - unsigned long arg) -{ - int ret; - - ret = wdt_ioctl(file, cmd, arg); - - return ret; -} - -/** - * wdt_open: - * @inode: inode of device - * @file: file handle to device - * - */ -static int wdt_open(struct inode *inode, struct file *file) -{ - if (MINOR(inode->i_rdev) == MITAC_WDT_MINOR) { - if (test_and_set_bit(0, &wdt_is_open)) { - return -EBUSY; - } - /* - * Activate - */ - - wdt_enable(); - return nonseekable_open(inode, file); - } - return -ENODEV; -} - -/** - * wdt_close: - * @inode: inode to board - * @file: file handle to board - * - */ -static int wdt_release(struct inode *inode, struct file *file) -{ - if (MINOR(inode->i_rdev) == MITAC_WDT_MINOR) - clear_bit(0, &wdt_is_open); - return 0; -} - -/** - * notify_sys: - * @this: our notifier block - * @code: the event being reported - * @unused: unused - * - * Our notifier is called on system shutdowns. We want to turn the card - * off at reboot otherwise the machine will reboot again during memory - * test or worse yet during the following fsck. This would suck, in fact - * trust me - if it happens it does suck. - */ -static int wdt_notify_sys(struct notifier_block *this, unsigned long code, - void *unused) -{ - if (code == SYS_DOWN || code == SYS_HALT) - /* Disable Watchdog */ - wdt_disable(); - return NOTIFY_DONE; -} - -static const struct file_operations wdt_fops = { - .owner = THIS_MODULE, - .llseek = no_llseek, - .write = wdt_write, - .unlocked_ioctl = wdt_unlocked_ioctl, - .open = wdt_open, - .release = wdt_release, -}; - -static struct miscdevice wdt_dev = { - .minor = MITAC_WDT_MINOR, - .name = MITAC_WDT_NAME, - .fops = &wdt_fops, -}; - -/* - * The WDT card needs to learn about soft shutdowns in order to - * turn the timebomb registers off. - */ -static struct notifier_block wdt_notifier = { - .notifier_call = wdt_notify_sys, -}; -static struct notifier_block *p_wdt_notifier = NULL; - -#endif /* CONFIG_DRV_SYSCPLD_WDT */ - -static int system_cpld_probe(struct i2c_client *client, const struct i2c_device_id *id) -{ - int err; - - /* allocate memory to system_cpld */ - system_cpld = devm_kzalloc(&client->dev, sizeof(struct system_cpld_data) , GFP_KERNEL); - - if (!system_cpld) - return -ENOMEM; - - mutex_init(&system_cpld->lock); - - err = sysfs_create_group(&client->dev.kobj, &system_cpld_group_misc); - if (err){ - printk("%s: Error creeat misc group.\n", __FUNCTION__); - } - - system_cpld->client = client; - i2c_set_clientdata(client, system_cpld); - - printk(KERN_INFO "%s: System CPLD LCMXO3LF created.\n", __FUNCTION__); - -#if CONFIG_DRV_SYSCPLD_WDT - wdt_dev.minor = MITAC_WDT_MINOR; - err = misc_register(&wdt_dev); - if (err) { - printk(MIC_DEBUG_TAG"%s-%d misc_register register watchdog (%s : %d) fail err=%d \n", __FUNCTION__, __LINE__, wdt_dev.name, wdt_dev.minor, err); - wdt_dev.minor = 0; - } - else { - p_wdt_notifier = &wdt_notifier; - err = register_reboot_notifier(p_wdt_notifier); - if (err) { - printk(MIC_DEBUG_TAG"%s-%d register_reboot_notifier fail err:%d \n", __FUNCTION__, __LINE__, err); - misc_deregister(&wdt_dev); - p_wdt_notifier = NULL; - wdt_dev.minor = 0; - } - } - printk(KERN_INFO "%s: System CPLD watchdog created.\n", __FUNCTION__); -#endif - - return 0; - -} - -static int system_cpld_remove(struct i2c_client *client) -{ -#if CONFIG_DRV_SYSCPLD_WDT - if(p_wdt_notifier) unregister_reboot_notifier(p_wdt_notifier); - if(wdt_dev.minor) misc_deregister(&wdt_dev); -#endif - sysfs_remove_group(&client->dev.kobj, &system_cpld_group_misc); - - printk(KERN_INFO "%s: System CPLD removed.\n", __FUNCTION__); - return 0; -} - -static struct i2c_driver system_cpld_driver = { - .driver = { - .name = "system_cpld", - .owner = THIS_MODULE, - }, - .probe = system_cpld_probe, - .remove = system_cpld_remove, - .id_table = system_cpld_ids, -}; - -static int __init system_cpld_init(void) -{ - printk(KERN_INFO "%s: init.\n", __FUNCTION__); - return i2c_add_driver(&system_cpld_driver); -} -module_init(system_cpld_init); - -static void __exit system_cpld_exit(void) -{ - printk(KERN_INFO "%s: exit.\n", __FUNCTION__); - i2c_del_driver(&system_cpld_driver); -} -module_exit(system_cpld_exit); - -MODULE_DESCRIPTION("mitac_ly1200_32x_system_cpld driver"); -MODULE_AUTHOR("Eddy Weng "); -MODULE_LICENSE("GPL"); - diff --git a/packages/platforms/mitac/x86-64/ly1200-b32h0-c3/onlp/Makefile b/packages/platforms/mitac/x86-64/ly1200-b32h0-c3/onlp/Makefile deleted file mode 100644 index 003238cf6..000000000 --- a/packages/platforms/mitac/x86-64/ly1200-b32h0-c3/onlp/Makefile +++ /dev/null @@ -1 +0,0 @@ -include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/mitac/x86-64/ly1200-b32h0-c3/onlp/PKG.yml b/packages/platforms/mitac/x86-64/ly1200-b32h0-c3/onlp/PKG.yml deleted file mode 100644 index b3e2989bb..000000000 --- a/packages/platforms/mitac/x86-64/ly1200-b32h0-c3/onlp/PKG.yml +++ /dev/null @@ -1 +0,0 @@ -!include $ONL_TEMPLATES/onlp-platform-any.yml PLATFORM=x86-64-mitac-ly1200-b32h0-c3 ARCH=amd64 TOOLCHAIN=x86_64-linux-gnu diff --git a/packages/platforms/mitac/x86-64/ly1200-b32h0-c3/onlp/builds/Makefile b/packages/platforms/mitac/x86-64/ly1200-b32h0-c3/onlp/builds/Makefile deleted file mode 100644 index e7437cb23..000000000 --- a/packages/platforms/mitac/x86-64/ly1200-b32h0-c3/onlp/builds/Makefile +++ /dev/null @@ -1,2 +0,0 @@ -FILTER=src -include $(ONL)/make/subdirs.mk diff --git a/packages/platforms/mitac/x86-64/ly1200-b32h0-c3/onlp/builds/lib/Makefile b/packages/platforms/mitac/x86-64/ly1200-b32h0-c3/onlp/builds/lib/Makefile deleted file mode 100644 index c82b5d2ca..000000000 --- a/packages/platforms/mitac/x86-64/ly1200-b32h0-c3/onlp/builds/lib/Makefile +++ /dev/null @@ -1,2 +0,0 @@ -PLATFORM := x86-64-mitac-ly1200-b32h0-c3 -include $(ONL)/packages/base/any/onlp/builds/platform/libonlp-platform.mk diff --git a/packages/platforms/mitac/x86-64/ly1200-b32h0-c3/onlp/builds/onlpdump/Makefile b/packages/platforms/mitac/x86-64/ly1200-b32h0-c3/onlp/builds/onlpdump/Makefile deleted file mode 100644 index 02c8c8c3b..000000000 --- a/packages/platforms/mitac/x86-64/ly1200-b32h0-c3/onlp/builds/onlpdump/Makefile +++ /dev/null @@ -1,2 +0,0 @@ -PLATFORM := x86-64-mitac-ly1200-b32h0-c3 -include $(ONL)/packages/base/any/onlp/builds/platform/onlps.mk diff --git a/packages/platforms/mitac/x86-64/ly1200-b32h0-c3/onlp/builds/x86_64_mitac_ly1200_b32h0_c3/.module b/packages/platforms/mitac/x86-64/ly1200-b32h0-c3/onlp/builds/x86_64_mitac_ly1200_b32h0_c3/.module deleted file mode 100644 index f700abc06..000000000 --- a/packages/platforms/mitac/x86-64/ly1200-b32h0-c3/onlp/builds/x86_64_mitac_ly1200_b32h0_c3/.module +++ /dev/null @@ -1 +0,0 @@ -name: x86_64_mitac_ly1200_b32h0_c3 diff --git a/packages/platforms/mitac/x86-64/ly1200-b32h0-c3/onlp/builds/x86_64_mitac_ly1200_b32h0_c3/Makefile b/packages/platforms/mitac/x86-64/ly1200-b32h0-c3/onlp/builds/x86_64_mitac_ly1200_b32h0_c3/Makefile deleted file mode 100644 index c0dd6c6d7..000000000 --- a/packages/platforms/mitac/x86-64/ly1200-b32h0-c3/onlp/builds/x86_64_mitac_ly1200_b32h0_c3/Makefile +++ /dev/null @@ -1,9 +0,0 @@ -############################################################################### -# -# -# -############################################################################### -include $(ONL)/make/config.mk -MODULE := x86_64_mitac_ly1200_b32h0_c3 -AUTOMODULE := x86_64_mitac_ly1200_b32h0_c3 -include $(BUILDER)/definemodule.mk diff --git a/packages/platforms/mitac/x86-64/ly1200-b32h0-c3/onlp/builds/x86_64_mitac_ly1200_b32h0_c3/README b/packages/platforms/mitac/x86-64/ly1200-b32h0-c3/onlp/builds/x86_64_mitac_ly1200_b32h0_c3/README deleted file mode 100644 index c0b9589d8..000000000 --- a/packages/platforms/mitac/x86-64/ly1200-b32h0-c3/onlp/builds/x86_64_mitac_ly1200_b32h0_c3/README +++ /dev/null @@ -1,6 +0,0 @@ -############################################################################### -# -# x86_64_mitac_ly1200_b32h0_c3 README -# -############################################################################### - diff --git a/packages/platforms/mitac/x86-64/ly1200-b32h0-c3/onlp/builds/x86_64_mitac_ly1200_b32h0_c3/module/auto/make.mk b/packages/platforms/mitac/x86-64/ly1200-b32h0-c3/onlp/builds/x86_64_mitac_ly1200_b32h0_c3/module/auto/make.mk deleted file mode 100644 index ef1307b99..000000000 --- a/packages/platforms/mitac/x86-64/ly1200-b32h0-c3/onlp/builds/x86_64_mitac_ly1200_b32h0_c3/module/auto/make.mk +++ /dev/null @@ -1,9 +0,0 @@ -############################################################################### -# -# x86_64_mitac_ly1200_b32h0_c3 Autogeneration -# -############################################################################### -x86_64_mitac_ly1200_b32h0_c3_AUTO_DEFS := module/auto/x86_64_mitac_ly1200_b32h0_c3.yml -x86_64_mitac_ly1200_b32h0_c3_AUTO_DIRS := module/inc/x86_64_mitac_ly1200_b32h0_c3 module/src -include $(BUILDER)/auto.mk - diff --git a/packages/platforms/mitac/x86-64/ly1200-b32h0-c3/onlp/builds/x86_64_mitac_ly1200_b32h0_c3/module/auto/x86_64_mitac_ly1200_b32h0_c3.yml b/packages/platforms/mitac/x86-64/ly1200-b32h0-c3/onlp/builds/x86_64_mitac_ly1200_b32h0_c3/module/auto/x86_64_mitac_ly1200_b32h0_c3.yml deleted file mode 100644 index 01a4231f1..000000000 --- a/packages/platforms/mitac/x86-64/ly1200-b32h0-c3/onlp/builds/x86_64_mitac_ly1200_b32h0_c3/module/auto/x86_64_mitac_ly1200_b32h0_c3.yml +++ /dev/null @@ -1,50 +0,0 @@ -############################################################################### -# -# x86_64_mitac_ly1200_b32h0_c3 Autogeneration Definitions. -# -############################################################################### - -cdefs: &cdefs -- X86_64_MITAC_LY1200_B32H0_C3_CONFIG_INCLUDE_LOGGING: - doc: "Include or exclude logging." - default: 1 -- X86_64_MITAC_LY1200_B32H0_C3_CONFIG_LOG_OPTIONS_DEFAULT: - doc: "Default enabled log options." - default: AIM_LOG_OPTIONS_DEFAULT -- X86_64_MITAC_LY1200_B32H0_C3_CONFIG_LOG_BITS_DEFAULT: - doc: "Default enabled log bits." - default: AIM_LOG_BITS_DEFAULT -- X86_64_MITAC_LY1200_B32H0_C3_CONFIG_LOG_CUSTOM_BITS_DEFAULT: - doc: "Default enabled custom log bits." - default: 0 -- X86_64_MITAC_LY1200_B32H0_C3_CONFIG_PORTING_STDLIB: - doc: "Default all porting macros to use the C standard libraries." - default: 1 -- X86_64_MITAC_LY1200_B32H0_C3_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS: - doc: "Include standard library headers for stdlib porting macros." - default: X86_64_MITAC_LY1200_B32H0_C3_CONFIG_PORTING_STDLIB -- X86_64_MITAC_LY1200_B32H0_C3_CONFIG_INCLUDE_UCLI: - doc: "Include generic uCli support." - default: 0 -- X86_64_MITAC_LY1200_B32H0_C3_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION: - doc: "Assume chassis fan direction is the same as the PSU fan direction." - default: 0 - - -definitions: - cdefs: - X86_64_MITAC_LY1200_B32H0_C3_CONFIG_HEADER: - defs: *cdefs - basename: x86_64_mitac_ly1200_b32h0_c3_config - - portingmacro: - x86_64_mitac_ly1200_b32h0_c3: - macros: - - malloc - - free - - memset - - memcpy - - - vsnprintf - - snprintf - - strlen diff --git a/packages/platforms/mitac/x86-64/ly1200-b32h0-c3/onlp/builds/x86_64_mitac_ly1200_b32h0_c3/module/inc/x86_64_mitac_ly1200_b32h0_c3/x86_64_mitac_ly1200_b32h0_c3.x b/packages/platforms/mitac/x86-64/ly1200-b32h0-c3/onlp/builds/x86_64_mitac_ly1200_b32h0_c3/module/inc/x86_64_mitac_ly1200_b32h0_c3/x86_64_mitac_ly1200_b32h0_c3.x deleted file mode 100644 index de9bea4d8..000000000 --- a/packages/platforms/mitac/x86-64/ly1200-b32h0-c3/onlp/builds/x86_64_mitac_ly1200_b32h0_c3/module/inc/x86_64_mitac_ly1200_b32h0_c3/x86_64_mitac_ly1200_b32h0_c3.x +++ /dev/null @@ -1,14 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#include - -/* <--auto.start.xmacro(ALL).define> */ -/* */ - -/* <--auto.start.xenum(ALL).define> */ -/* */ - - diff --git a/packages/platforms/mitac/x86-64/ly1200-b32h0-c3/onlp/builds/x86_64_mitac_ly1200_b32h0_c3/module/inc/x86_64_mitac_ly1200_b32h0_c3/x86_64_mitac_ly1200_b32h0_c3_config.h b/packages/platforms/mitac/x86-64/ly1200-b32h0-c3/onlp/builds/x86_64_mitac_ly1200_b32h0_c3/module/inc/x86_64_mitac_ly1200_b32h0_c3/x86_64_mitac_ly1200_b32h0_c3_config.h deleted file mode 100644 index 827d1aa7c..000000000 --- a/packages/platforms/mitac/x86-64/ly1200-b32h0-c3/onlp/builds/x86_64_mitac_ly1200_b32h0_c3/module/inc/x86_64_mitac_ly1200_b32h0_c3/x86_64_mitac_ly1200_b32h0_c3_config.h +++ /dev/null @@ -1,137 +0,0 @@ -/**************************************************************************//** - * - * @file - * @brief x86_64_mitac_ly1200_b32h0_c3 Configuration Header - * - * @addtogroup x86_64_mitac_ly1200_b32h0_c3-config - * @{ - * - *****************************************************************************/ -#ifndef __X86_64_MITAC_LY1200_B32H0_C3_CONFIG_H__ -#define __X86_64_MITAC_LY1200_B32H0_C3_CONFIG_H__ - -#ifdef GLOBAL_INCLUDE_CUSTOM_CONFIG -#include -#endif -#ifdef x86_64_mitac_ly1200_b32h0_c3_INCLUDE_CUSTOM_CONFIG -#include -#endif - -/* */ -#include -/** - * X86_64_MITAC_LY1200_B32H0_C3_CONFIG_INCLUDE_LOGGING - * - * Include or exclude logging. */ - - -#ifndef X86_64_MITAC_LY1200_B32H0_C3_CONFIG_INCLUDE_LOGGING -#define X86_64_MITAC_LY1200_B32H0_C3_CONFIG_INCLUDE_LOGGING 1 -#endif - -/** - * X86_64_MITAC_LY1200_B32H0_C3_CONFIG_LOG_OPTIONS_DEFAULT - * - * Default enabled log options. */ - - -#ifndef X86_64_MITAC_LY1200_B32H0_C3_CONFIG_LOG_OPTIONS_DEFAULT -#define X86_64_MITAC_LY1200_B32H0_C3_CONFIG_LOG_OPTIONS_DEFAULT AIM_LOG_OPTIONS_DEFAULT -#endif - -/** - * X86_64_MITAC_LY1200_B32H0_C3_CONFIG_LOG_BITS_DEFAULT - * - * Default enabled log bits. */ - - -#ifndef X86_64_MITAC_LY1200_B32H0_C3_CONFIG_LOG_BITS_DEFAULT -#define X86_64_MITAC_LY1200_B32H0_C3_CONFIG_LOG_BITS_DEFAULT AIM_LOG_BITS_DEFAULT -#endif - -/** - * X86_64_MITAC_LY1200_B32H0_C3_CONFIG_LOG_CUSTOM_BITS_DEFAULT - * - * Default enabled custom log bits. */ - - -#ifndef X86_64_MITAC_LY1200_B32H0_C3_CONFIG_LOG_CUSTOM_BITS_DEFAULT -#define X86_64_MITAC_LY1200_B32H0_C3_CONFIG_LOG_CUSTOM_BITS_DEFAULT 0 -#endif - -/** - * X86_64_MITAC_LY1200_B32H0_C3_CONFIG_PORTING_STDLIB - * - * Default all porting macros to use the C standard libraries. */ - - -#ifndef X86_64_MITAC_LY1200_B32H0_C3_CONFIG_PORTING_STDLIB -#define X86_64_MITAC_LY1200_B32H0_C3_CONFIG_PORTING_STDLIB 1 -#endif - -/** - * X86_64_MITAC_LY1200_B32H0_C3_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS - * - * Include standard library headers for stdlib porting macros. */ - - -#ifndef X86_64_MITAC_LY1200_B32H0_C3_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS -#define X86_64_MITAC_LY1200_B32H0_C3_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS X86_64_MITAC_LY1200_B32H0_C3_CONFIG_PORTING_STDLIB -#endif - -/** - * X86_64_MITAC_LY1200_B32H0_C3_CONFIG_INCLUDE_UCLI - * - * Include generic uCli support. */ - - -#ifndef X86_64_MITAC_LY1200_B32H0_C3_CONFIG_INCLUDE_UCLI -#define X86_64_MITAC_LY1200_B32H0_C3_CONFIG_INCLUDE_UCLI 0 -#endif - -/** - * X86_64_MITAC_LY1200_B32H0_C3_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION - * - * Assume chassis fan direction is the same as the PSU fan direction. */ - - -#ifndef X86_64_MITAC_LY1200_B32H0_C3_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION -#define X86_64_MITAC_LY1200_B32H0_C3_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION 0 -#endif - - - -/** - * All compile time options can be queried or displayed - */ - -/** Configuration settings structure. */ -typedef struct x86_64_mitac_ly1200_b32h0_c3_config_settings_s { - /** name */ - const char* name; - /** value */ - const char* value; -} x86_64_mitac_ly1200_b32h0_c3_config_settings_t; - -/** Configuration settings table. */ -/** x86_64_mitac_ly1200_b32h0_c3_config_settings table. */ -extern x86_64_mitac_ly1200_b32h0_c3_config_settings_t x86_64_mitac_ly1200_b32h0_c3_config_settings[]; - -/** - * @brief Lookup a configuration setting. - * @param setting The name of the configuration option to lookup. - */ -const char* x86_64_mitac_ly1200_b32h0_c3_config_lookup(const char* setting); - -/** - * @brief Show the compile-time configuration. - * @param pvs The output stream. - */ -int x86_64_mitac_ly1200_b32h0_c3_config_show(struct aim_pvs_s* pvs); - -/* */ - -#include "x86_64_mitac_ly1200_b32h0_c3_porting.h" - -#endif /* __X86_64_MITAC_LY1200_B32H0_C3_CONFIG_H__ */ -/* @} */ diff --git a/packages/platforms/mitac/x86-64/ly1200-b32h0-c3/onlp/builds/x86_64_mitac_ly1200_b32h0_c3/module/inc/x86_64_mitac_ly1200_b32h0_c3/x86_64_mitac_ly1200_b32h0_c3_dox.h b/packages/platforms/mitac/x86-64/ly1200-b32h0-c3/onlp/builds/x86_64_mitac_ly1200_b32h0_c3/module/inc/x86_64_mitac_ly1200_b32h0_c3/x86_64_mitac_ly1200_b32h0_c3_dox.h deleted file mode 100644 index a72377eb3..000000000 --- a/packages/platforms/mitac/x86-64/ly1200-b32h0-c3/onlp/builds/x86_64_mitac_ly1200_b32h0_c3/module/inc/x86_64_mitac_ly1200_b32h0_c3/x86_64_mitac_ly1200_b32h0_c3_dox.h +++ /dev/null @@ -1,26 +0,0 @@ -/**************************************************************************//** - * - * x86_64_mitac_ly1200_b32h0_c3 Doxygen Header - * - *****************************************************************************/ -#ifndef __x86_64_mitac_ly1200_b32h0_c3_DOX_H__ -#define __x86_64_mitac_ly1200_b32h0_c3_DOX_H__ - -/** - * @defgroup x86_64_mitac_ly1200_b32h0_c3 x86_64_mitac_ly1200_b32h0_c3 - x86_64_mitac_ly1200_b32h0_c3 Description - * - -The documentation overview for this module should go here. - - * - * @{ - * - * @defgroup x86_64_mitac_ly1200_b32h0_c3-x86_64_mitac_ly1200_b32h0_c3 Public Interface - * @defgroup x86_64_mitac_ly1200_b32h0_c3-config Compile Time Configuration - * @defgroup x86_64_mitac_ly1200_b32h0_c3-porting Porting Macros - * - * @} - * - */ - -#endif /* __x86_64_mitac_ly1200_b32h0_c3_DOX_H__ */ diff --git a/packages/platforms/mitac/x86-64/ly1200-b32h0-c3/onlp/builds/x86_64_mitac_ly1200_b32h0_c3/module/inc/x86_64_mitac_ly1200_b32h0_c3/x86_64_mitac_ly1200_b32h0_c3_porting.h b/packages/platforms/mitac/x86-64/ly1200-b32h0-c3/onlp/builds/x86_64_mitac_ly1200_b32h0_c3/module/inc/x86_64_mitac_ly1200_b32h0_c3/x86_64_mitac_ly1200_b32h0_c3_porting.h deleted file mode 100644 index 5d92a2dfa..000000000 --- a/packages/platforms/mitac/x86-64/ly1200-b32h0-c3/onlp/builds/x86_64_mitac_ly1200_b32h0_c3/module/inc/x86_64_mitac_ly1200_b32h0_c3/x86_64_mitac_ly1200_b32h0_c3_porting.h +++ /dev/null @@ -1,97 +0,0 @@ -/**************************************************************************//** - * - * @file - * @brief x86_64_mitac_ly1200_b32h0_c3 Porting Macros. - * - * @addtogroup x86_64_mitac_ly1200_b32h0_c3-porting - * @{ - * - *****************************************************************************/ -#ifndef __x86_64_mitac_ly1200_b32h0_c3_PORTING_H__ -#define __x86_64_mitac_ly1200_b32h0_c3_PORTING_H__ - - -/* */ -#if X86_64_MITAC_LY1200_B32H0_C3_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS == 1 -#include -#include -#include -#include -#include -#endif - -#ifndef X86_64_MITAC_LY1200_B32H0_C3_MALLOC - #if defined(GLOBAL_MALLOC) - #define X86_64_MITAC_LY1200_B32H0_C3_MALLOC GLOBAL_MALLOC - #elif X86_64_MITAC_LY1200_B32H0_C3_CONFIG_PORTING_STDLIB == 1 - #define X86_64_MITAC_LY1200_B32H0_C3_MALLOC malloc - #else - #error The macro X86_64_MITAC_LY1200_B32H0_C3_MALLOC is required but cannot be defined. - #endif -#endif - -#ifndef X86_64_MITAC_LY1200_B32H0_C3_FREE - #if defined(GLOBAL_FREE) - #define X86_64_MITAC_LY1200_B32H0_C3_FREE GLOBAL_FREE - #elif X86_64_MITAC_LY1200_B32H0_C3_CONFIG_PORTING_STDLIB == 1 - #define X86_64_MITAC_LY1200_B32H0_C3_FREE free - #else - #error The macro X86_64_MITAC_LY1200_B32H0_C3_FREE is required but cannot be defined. - #endif -#endif - -#ifndef X86_64_MITAC_LY1200_B32H0_C3_MEMSET - #if defined(GLOBAL_MEMSET) - #define X86_64_MITAC_LY1200_B32H0_C3_MEMSET GLOBAL_MEMSET - #elif X86_64_MITAC_LY1200_B32H0_C3_CONFIG_PORTING_STDLIB == 1 - #define X86_64_MITAC_LY1200_B32H0_C3_MEMSET memset - #else - #error The macro X86_64_MITAC_LY1200_B32H0_C3_MEMSET is required but cannot be defined. - #endif -#endif - -#ifndef X86_64_MITAC_LY1200_B32H0_C3_MEMCPY - #if defined(GLOBAL_MEMCPY) - #define X86_64_MITAC_LY1200_B32H0_C3_MEMCPY GLOBAL_MEMCPY - #elif X86_64_MITAC_LY1200_B32H0_C3_CONFIG_PORTING_STDLIB == 1 - #define X86_64_MITAC_LY1200_B32H0_C3_MEMCPY memcpy - #else - #error The macro X86_64_MITAC_LY1200_B32H0_C3_MEMCPY is required but cannot be defined. - #endif -#endif - -#ifndef X86_64_MITAC_LY1200_B32H0_C3_VSNPRINTF - #if defined(GLOBAL_VSNPRINTF) - #define X86_64_MITAC_LY1200_B32H0_C3_VSNPRINTF GLOBAL_VSNPRINTF - #elif X86_64_MITAC_LY1200_B32H0_C3_CONFIG_PORTING_STDLIB == 1 - #define X86_64_MITAC_LY1200_B32H0_C3_VSNPRINTF vsnprintf - #else - #error The macro X86_64_MITAC_LY1200_B32H0_C3_VSNPRINTF is required but cannot be defined. - #endif -#endif - -#ifndef X86_64_MITAC_LY1200_B32H0_C3_SNPRINTF - #if defined(GLOBAL_SNPRINTF) - #define X86_64_MITAC_LY1200_B32H0_C3_SNPRINTF GLOBAL_SNPRINTF - #elif X86_64_MITAC_LY1200_B32H0_C3_CONFIG_PORTING_STDLIB == 1 - #define X86_64_MITAC_LY1200_B32H0_C3_SNPRINTF snprintf - #else - #error The macro X86_64_MITAC_LY1200_B32H0_C3_SNPRINTF is required but cannot be defined. - #endif -#endif - -#ifndef X86_64_MITAC_LY1200_B32H0_C3_STRLEN - #if defined(GLOBAL_STRLEN) - #define X86_64_MITAC_LY1200_B32H0_C3_STRLEN GLOBAL_STRLEN - #elif X86_64_MITAC_LY1200_B32H0_C3_CONFIG_PORTING_STDLIB == 1 - #define X86_64_MITAC_LY1200_B32H0_C3_STRLEN strlen - #else - #error The macro X86_64_MITAC_LY1200_B32H0_C3_STRLEN is required but cannot be defined. - #endif -#endif - -/* */ - - -#endif /* __x86_64_mitac_ly1200_b32h0_c3_PORTING_H__ */ -/* @} */ diff --git a/packages/platforms/mitac/x86-64/ly1200-b32h0-c3/onlp/builds/x86_64_mitac_ly1200_b32h0_c3/module/make.mk b/packages/platforms/mitac/x86-64/ly1200-b32h0-c3/onlp/builds/x86_64_mitac_ly1200_b32h0_c3/module/make.mk deleted file mode 100644 index 5ac4c2336..000000000 --- a/packages/platforms/mitac/x86-64/ly1200-b32h0-c3/onlp/builds/x86_64_mitac_ly1200_b32h0_c3/module/make.mk +++ /dev/null @@ -1,10 +0,0 @@ -############################################################################### -# -# -# -############################################################################### -THIS_DIR := $(dir $(lastword $(MAKEFILE_LIST))) -x86_64_mitac_ly1200_b32h0_c3_INCLUDES := -I $(THIS_DIR)inc -x86_64_mitac_ly1200_b32h0_c3_INTERNAL_INCLUDES := -I $(THIS_DIR)src -x86_64_mitac_ly1200_b32h0_c3_DEPENDMODULE_ENTRIES := init:x86_64_mitac_ly1200_b32h0_c3 ucli:x86_64_mitac_ly1200_b32h0_c3 - diff --git a/packages/platforms/mitac/x86-64/ly1200-b32h0-c3/onlp/builds/x86_64_mitac_ly1200_b32h0_c3/module/src/Makefile b/packages/platforms/mitac/x86-64/ly1200-b32h0-c3/onlp/builds/x86_64_mitac_ly1200_b32h0_c3/module/src/Makefile deleted file mode 100644 index bbc4aaea1..000000000 --- a/packages/platforms/mitac/x86-64/ly1200-b32h0-c3/onlp/builds/x86_64_mitac_ly1200_b32h0_c3/module/src/Makefile +++ /dev/null @@ -1,9 +0,0 @@ -############################################################################### -# -# Local source generation targets. -# -############################################################################### - -ucli: - @../../../../tools/uclihandlers.py x86_64_mitac_ly1200_b32h0_c3_ucli.c - diff --git a/packages/platforms/mitac/x86-64/ly1200-b32h0-c3/onlp/builds/x86_64_mitac_ly1200_b32h0_c3/module/src/debug.c b/packages/platforms/mitac/x86-64/ly1200-b32h0-c3/onlp/builds/x86_64_mitac_ly1200_b32h0_c3/module/src/debug.c deleted file mode 100644 index 82b240a7d..000000000 --- a/packages/platforms/mitac/x86-64/ly1200-b32h0-c3/onlp/builds/x86_64_mitac_ly1200_b32h0_c3/module/src/debug.c +++ /dev/null @@ -1,45 +0,0 @@ -#include "x86_64_mitac_ly1200_b32h0_c3_int.h" - -#if X86_64_MITAC_LY1200_B32H0_C3_CONFIG_INCLUDE_DEBUG == 1 - -#include - -static char help__[] = - "Usage: debug [options]\n" - " -c CPLD Versions\n" - " -h Help\n" - ; - -int -x86_64_mitac_ly1200_b32h0_c3_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/mitac/x86-64/ly1200-b32h0-c3/onlp/builds/x86_64_mitac_ly1200_b32h0_c3/module/src/fani.c b/packages/platforms/mitac/x86-64/ly1200-b32h0-c3/onlp/builds/x86_64_mitac_ly1200_b32h0_c3/module/src/fani.c deleted file mode 100644 index c1137dcd0..000000000 --- a/packages/platforms/mitac/x86-64/ly1200-b32h0-c3/onlp/builds/x86_64_mitac_ly1200_b32h0_c3/module/src/fani.c +++ /dev/null @@ -1,145 +0,0 @@ -/************************************************************ - * - * - * Copyright 2014 Big Switch Networks, Inc. - * Copyright 2017 MiTAC Computing 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/9-0066/" - -#define MAX_FAN_SPEED 23000 - -#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_7_ON_MAIN_BOARD 7 -#define FAN_8_ON_MAIN_BOARD 8 -#define FAN_9_ON_MAIN_BOARD 9 -#define FAN_10_ON_MAIN_BOARD 10 -#define FAN_11_ON_MAIN_BOARD 11 -#define FAN_12_ON_MAIN_BOARD 12 - -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"#id"_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) - -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_MAIN_BOARD(PROJECT_NAME, FAN_7_ON_MAIN_BOARD), - MAKE_FAN_PATH_ON_MAIN_BOARD(PROJECT_NAME, FAN_8_ON_MAIN_BOARD), - MAKE_FAN_PATH_ON_MAIN_BOARD(PROJECT_NAME, FAN_9_ON_MAIN_BOARD), - MAKE_FAN_PATH_ON_MAIN_BOARD(PROJECT_NAME, FAN_10_ON_MAIN_BOARD), - MAKE_FAN_PATH_ON_MAIN_BOARD(PROJECT_NAME, FAN_11_ON_MAIN_BOARD), - MAKE_FAN_PATH_ON_MAIN_BOARD(PROJECT_NAME, FAN_12_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_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_MAIN_BOARD(7), - MAKE_FAN_INFO_NODE_ON_MAIN_BOARD(8), - MAKE_FAN_INFO_NODE_ON_MAIN_BOARD(9), - MAKE_FAN_INFO_NODE_ON_MAIN_BOARD(10), - MAKE_FAN_INFO_NODE_ON_MAIN_BOARD(11), - MAKE_FAN_INFO_NODE_ON_MAIN_BOARD(12) -}; - -#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 - -/* - * This function will be called prior to all of onlp_fani_* functions. - */ -int -onlp_fani_init(void) -{ - // FIXME: WARNING FREEZE - if ( 0 ) { - printf("%d\t%s", linfo[0].status, fan_path[0].speed); - } - // END WARNING FREEZE - return ONLP_STATUS_OK; -} - - - diff --git a/packages/platforms/mitac/x86-64/ly1200-b32h0-c3/onlp/builds/x86_64_mitac_ly1200_b32h0_c3/module/src/ledi.c b/packages/platforms/mitac/x86-64/ly1200-b32h0-c3/onlp/builds/x86_64_mitac_ly1200_b32h0_c3/module/src/ledi.c deleted file mode 100644 index 45fbed523..000000000 --- a/packages/platforms/mitac/x86-64/ly1200-b32h0-c3/onlp/builds/x86_64_mitac_ly1200_b32h0_c3/module/src/ledi.c +++ /dev/null @@ -1,241 +0,0 @@ -/************************************************************ - * - * - * Copyright 2014 Big Switch Networks, Inc. - * Copyright 2017 MiTAC Computing 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/mitac_ly1200_b32h0_c3_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) -{ - // FIXME: WARNING FREEZE - if ( 0 ) { - printf("%s\t%d", last_path[0], linfo[0].status); - driver_to_onlp_led_mode(LED_RESERVED, LED_MODE_AUTO); - onlp_to_driver_led_mode(LED_RESERVED, ONLP_LED_MODE_BLINKING); - } - // END WARNING FREEZE - //printf("Hello, this is %s() in %s.\n", __func__, __FILE__); - return ONLP_STATUS_OK; -} - -int -onlp_ledi_info_get(onlp_oid_t id, onlp_led_info_t* info) -{ - 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) -{ - 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; -} - -/* - * Additional Functions - */ -int -onlp_ledi_status_get(onlp_oid_t id, uint32_t* rv) -{ - return ONLP_STATUS_E_UNSUPPORTED; -} - -int -onlp_ledi_hdr_get(onlp_oid_t id, onlp_oid_hdr_t* rv) -{ - return ONLP_STATUS_E_UNSUPPORTED; -} - -int -onlp_ledi_char_set(onlp_oid_t id, char c) -{ - return ONLP_STATUS_E_UNSUPPORTED; -} - diff --git a/packages/platforms/mitac/x86-64/ly1200-b32h0-c3/onlp/builds/x86_64_mitac_ly1200_b32h0_c3/module/src/make.mk b/packages/platforms/mitac/x86-64/ly1200-b32h0-c3/onlp/builds/x86_64_mitac_ly1200_b32h0_c3/module/src/make.mk deleted file mode 100644 index ecbca4cc4..000000000 --- a/packages/platforms/mitac/x86-64/ly1200-b32h0-c3/onlp/builds/x86_64_mitac_ly1200_b32h0_c3/module/src/make.mk +++ /dev/null @@ -1,9 +0,0 @@ -############################################################################### -# -# -# -############################################################################### - -LIBRARY := x86_64_mitac_ly1200_b32h0_c3 -$(LIBRARY)_SUBDIR := $(dir $(lastword $(MAKEFILE_LIST))) -include $(BUILDER)/lib.mk diff --git a/packages/platforms/mitac/x86-64/ly1200-b32h0-c3/onlp/builds/x86_64_mitac_ly1200_b32h0_c3/module/src/platform_lib.c b/packages/platforms/mitac/x86-64/ly1200-b32h0-c3/onlp/builds/x86_64_mitac_ly1200_b32h0_c3/module/src/platform_lib.c deleted file mode 100644 index e1ace5dde..000000000 --- a/packages/platforms/mitac/x86-64/ly1200-b32h0-c3/onlp/builds/x86_64_mitac_ly1200_b32h0_c3/module/src/platform_lib.c +++ /dev/null @@ -1,200 +0,0 @@ -/************************************************************ - * - * - * Copyright 2014 Big Switch Networks, Inc. - * Copyright 2017 MiTAC Computing 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) { - aim_strlcpy(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) { - aim_strlcpy(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) { - aim_strlcpy(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/mitac/x86-64/ly1200-b32h0-c3/onlp/builds/x86_64_mitac_ly1200_b32h0_c3/module/src/platform_lib.h b/packages/platforms/mitac/x86-64/ly1200-b32h0-c3/onlp/builds/x86_64_mitac_ly1200_b32h0_c3/module/src/platform_lib.h deleted file mode 100644 index 98ce51e8a..000000000 --- a/packages/platforms/mitac/x86-64/ly1200-b32h0-c3/onlp/builds/x86_64_mitac_ly1200_b32h0_c3/module/src/platform_lib.h +++ /dev/null @@ -1,77 +0,0 @@ -/************************************************************ - * - * - * Copyright 2014 Big Switch Networks, Inc. - * Copyright 2017 MiTAC Computing 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_mitac_ly1200_b32h0_c3_log.h" - -#define CHASSIS_FAN_COUNT 6 -#define CHASSIS_THERMAL_COUNT 3 - -#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_HWMON_PREFIX "/sys/bus/i2c/devices/18-0053/" -#define PSU2_AC_HWMON_PREFIX "/sys/bus/i2c/devices/17-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/bus/i2c/devices/2-0050/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/mitac/x86-64/ly1200-b32h0-c3/onlp/builds/x86_64_mitac_ly1200_b32h0_c3/module/src/psui.c b/packages/platforms/mitac/x86-64/ly1200-b32h0-c3/onlp/builds/x86_64_mitac_ly1200_b32h0_c3/module/src/psui.c deleted file mode 100644 index a86b63359..000000000 --- a/packages/platforms/mitac/x86-64/ly1200-b32h0-c3/onlp/builds/x86_64_mitac_ly1200_b32h0_c3/module/src/psui.c +++ /dev/null @@ -1,240 +0,0 @@ -/************************************************************ - * - * - * Copyright 2014 Big Switch Networks, Inc. - * Copyright 2017 MiTAC Computing 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) -{ - //printf("Hello, this is %s() in %s.\n", __func__, __FILE__); - 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) ? 18 : 17; - 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) -{ - // FIXME: WARNING FREEZE - if ( 0 ) { - int ret = 0; - int index = 0; - - /* Get the present state */ - if (psu_status_info_get(index, "psu_present", &ret) != 0) { - printf("Unable to read PSU(%d) node(psu_present)\r\n", index); - } - - ret = psu_ym2651_info_get(&pinfo[0]); - ret = psu_dc12v_750_info_get(&pinfo[0]); - printf("%dx", ret); - } - // END WARNING FREEZE - return ONLP_STATUS_OK; -} - -/* - * Additional Functions - */ -int -onlp_psui_ioctl(onlp_oid_t pid, va_list vargs) -{ - return ONLP_STATUS_E_UNSUPPORTED; -} - -int -onlp_psui_status_get(onlp_oid_t id, uint32_t* rv) -{ - return ONLP_STATUS_E_UNSUPPORTED; -} - -int -onlp_psui_hdr_get(onlp_oid_t id, onlp_oid_hdr_t* rv) -{ - return ONLP_STATUS_E_UNSUPPORTED; -} - diff --git a/packages/platforms/mitac/x86-64/ly1200-b32h0-c3/onlp/builds/x86_64_mitac_ly1200_b32h0_c3/module/src/sfpi.c b/packages/platforms/mitac/x86-64/ly1200-b32h0-c3/onlp/builds/x86_64_mitac_ly1200_b32h0_c3/module/src/sfpi.c deleted file mode 100644 index bcae4f9d7..000000000 --- a/packages/platforms/mitac/x86-64/ly1200-b32h0-c3/onlp/builds/x86_64_mitac_ly1200_b32h0_c3/module/src/sfpi.c +++ /dev/null @@ -1,276 +0,0 @@ -/************************************************************ - * - * - * Copyright 2014 Big Switch Networks, Inc. - * Copyright 2017 MiTAC Computing 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 -#include -#include "platform_lib.h" - -#define MAX_SFP_PATH 64 -static char sfp_node_path[MAX_SFP_PATH] = {0}; - -#define NUM_OF_SFP_PORT 32 - -#define XCVR_BUS_START_INDEX 9 -#define FRONT_PORT_TO_BUS_INDEX(port) (port+XCVR_BUS_START_INDEX) - -/* This is based on CPLD spec */ -#define PRESENT_EN 0 -#define MASTER_CPLD_START_PORT 1 -#define SLAVE_CPLD_START_PORT 17 - -static int -ly1200_b32h0_c3_xcvr_open(uint8_t bus, - int *i2c_fd) -{ - int err = 0; - char dev_name[20]; - - sprintf(dev_name, "/dev/i2c-%u", bus); - if ((*i2c_fd = open(dev_name, O_RDWR)) < 0) { - err = errno; - return -err; - } - - return err; -} - -static int -ly1200_b32h0_c3_xcvr_read(uint8_t bus, - uint8_t addr, - uint16_t offset, - uint8_t *val) -{ - int err = 0, value; - int i2c_fd = 0; - - if ((err = ly1200_b32h0_c3_xcvr_open(bus, &i2c_fd)) < 0) {goto quit;} - if ((ioctl(i2c_fd, I2C_SLAVE_FORCE, addr)) < 0) { - err = errno; - return -err; - } - value = i2c_smbus_read_byte_data(i2c_fd, offset); - if (value < 0) { - err = errno; - close(i2c_fd); - return -err; - } - *val = value; - -quit: - close(i2c_fd); - return err; -} - -static int -ly1200_b32h0_c3_sfp_node_read_file(char *filename, - uint32_t *value, - uint32_t mask) -{ - char buf[4]; - int fd, ret_code = 0, buf_size = sizeof(buf); - ssize_t count; - - if ((fd = open(filename, O_RDONLY)) < 0) { - ret_code = errno; - return -ret_code; - } - - if ((count = read(fd, buf, buf_size)) != (-1)) { - if (PRESENT_EN == 0) - *value = mask & ~strtol(buf, NULL, 16); - else - *value = mask & strtol(buf, NULL, 16); - } - else { - ret_code = (count >= 0) ? EIO : errno; - close(fd); - return -ret_code; - } - - close(fd); - return ret_code; -} - -static char* -ly1200_b32h0_c3_sfp_get_port_path(int port, char *node_name) -{ - if (port == -1) { - sprintf(sfp_node_path, "/sys/bus/i2c/devices/%s", - node_name); - } else if (port >= MASTER_CPLD_START_PORT && port < SLAVE_CPLD_START_PORT) { - sprintf(sfp_node_path, "/sys/bus/i2c/devices/1-0032/port%d/port%d_%s", - port, port, - node_name); - } else if (port >= SLAVE_CPLD_START_PORT && port <= NUM_OF_SFP_PORT) { - sprintf(sfp_node_path, "/sys/bus/i2c/devices/1-0033/port%d/port%d_%s", - port, 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 {1, 32} - */ - int p; - AIM_BITMAP_CLR_ALL(bmap); - - for(p = 1; 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; - uint32_t value; - char* path = ly1200_b32h0_c3_sfp_get_port_path(port, "present"); - - if (ly1200_b32h0_c3_sfp_node_read_file(path, &value, 0x1) != 0) { - AIM_LOG_ERROR("Unable to read present status from port(%d)\r\n", port); - return ONLP_STATUS_E_INTERNAL; - } - present = value; - - return present; -} - -int -onlp_sfpi_presence_bitmap_get(onlp_sfp_bitmap_t* dst) -{ - uint32_t bytes[4], value; - char* path; - - path = ly1200_b32h0_c3_sfp_get_port_path(-1, "1-0032/port_1_8_present"); - if (ly1200_b32h0_c3_sfp_node_read_file(path, &value, 0xFF) != 0) { - AIM_LOG_ERROR("Unable to read present status from port 1 to 8\r\n"); - return ONLP_STATUS_E_INTERNAL; - } - bytes[0] = value; - - path = ly1200_b32h0_c3_sfp_get_port_path(-1, "1-0032/port_9_16_present"); - if (ly1200_b32h0_c3_sfp_node_read_file(path, &value, 0xFF) != 0) { - AIM_LOG_ERROR("Unable to read present status from port 8 to 16\r\n"); - return ONLP_STATUS_E_INTERNAL; - } - bytes[1] = value; - - path = ly1200_b32h0_c3_sfp_get_port_path(-1, "1-0033/port_17_24_present"); - if (ly1200_b32h0_c3_sfp_node_read_file(path, &value, 0xFF) != 0) { - AIM_LOG_ERROR("Unable to read present status from port 17 to 24\r\n"); - return ONLP_STATUS_E_INTERNAL; - } - bytes[2] = value; - - path = ly1200_b32h0_c3_sfp_get_port_path(-1, "1-0033/port_25_32_present"); - if (ly1200_b32h0_c3_sfp_node_read_file(path, &value, 0xFF) != 0) { - AIM_LOG_ERROR("Unable to read present status from port 25 to 32\r\n"); - return ONLP_STATUS_E_INTERNAL; - } - bytes[3] = value; - - /* 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 = 1; 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, int dev_addr, uint8_t data[256]) -onlp_sfpi_eeprom_read(int port, uint8_t data[256]) -{ - uint16_t offset = 0; - uint8_t val = 0, addr = 0x50;//dev_addr; - uint8_t bus = FRONT_PORT_TO_BUS_INDEX(port); - if (data == NULL) {return ONLP_STATUS_E_INTERNAL;} - - /* - * Read the SFP eeprom into data[] - * - * Return MISSING if SFP is missing. - * Return OK if eeprom is read - */ - memset(data, 0, 256); - - for(offset = 0; offset < 256; offset++) { - if (ly1200_b32h0_c3_xcvr_read( bus, addr, offset, &val) < 0) { - AIM_LOG_ERROR("Unable to read eeprom from port(%d)\r\n", port); - return ONLP_STATUS_E_INTERNAL; - } - data[offset] = val & 0xFF; - } - - return ONLP_STATUS_OK; -} - -int -onlp_sfpi_denit(void) -{ - return ONLP_STATUS_OK; -} diff --git a/packages/platforms/mitac/x86-64/ly1200-b32h0-c3/onlp/builds/x86_64_mitac_ly1200_b32h0_c3/module/src/sysi.c b/packages/platforms/mitac/x86-64/ly1200-b32h0-c3/onlp/builds/x86_64_mitac_ly1200_b32h0_c3/module/src/sysi.c deleted file mode 100644 index 9c37e3eb8..000000000 --- a/packages/platforms/mitac/x86-64/ly1200-b32h0-c3/onlp/builds/x86_64_mitac_ly1200_b32h0_c3/module/src/sysi.c +++ /dev/null @@ -1,100 +0,0 @@ -/************************************************************ - * - * - * Copyright 2014 Big Switch Networks, Inc. - * Copyright 2017 MiTAC Computing 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_mitac_ly1200_b32h0_c3_int.h" -#include "x86_64_mitac_ly1200_b32h0_c3_log.h" - -#include "platform_lib.h" - -#define NUM_OF_THERMAL_ON_DEVICE 5 -#define NUM_OF_FAN_ON_DEVICE 6 -#define NUM_OF_PSU_ON_DEVICE 2 -#define NUM_OF_LED_ON_DEVICE 4 - -const char* -onlp_sysi_platform_get(void) -{ - return "x86-64-mitac-ly1200-b32h0-c3-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)); - - /* Thermal sensors */ - for (i = 1; i <= NUM_OF_THERMAL_ON_DEVICE; i++) - { - *e++ = ONLP_THERMAL_ID_CREATE(i); - } - - /* Fans */ - for (i = 1; i <= NUM_OF_FAN_ON_DEVICE; i++) - { - *e++ = ONLP_FAN_ID_CREATE(i); - } - - /* PSUs */ - for (i = 1; i <= NUM_OF_PSU_ON_DEVICE; i++) - { - *e++ = ONLP_PSU_ID_CREATE(i); - } - - /* LEDs */ - for (i = 1; i <= NUM_OF_LED_ON_DEVICE; i++) - { - *e++ = ONLP_LED_ID_CREATE(i); - } - - return ONLP_STATUS_OK; -} diff --git a/packages/platforms/mitac/x86-64/ly1200-b32h0-c3/onlp/builds/x86_64_mitac_ly1200_b32h0_c3/module/src/thermali.c b/packages/platforms/mitac/x86-64/ly1200-b32h0-c3/onlp/builds/x86_64_mitac_ly1200_b32h0_c3/module/src/thermali.c deleted file mode 100644 index 011de61bf..000000000 --- a/packages/platforms/mitac/x86-64/ly1200-b32h0-c3/onlp/builds/x86_64_mitac_ly1200_b32h0_c3/module/src/thermali.c +++ /dev/null @@ -1,104 +0,0 @@ -/************************************************************ - * - * - * Copyright 2014 Big Switch Networks, Inc. - * Copyright 2017 MiTAC Computing 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 "platform_lib.h" -#include - - -#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_ON_MAIN_BROAD, - THERMAL_2_ON_MAIN_BROAD, - THERMAL_3_ON_MAIN_BROAD, - THERMAL_1_ON_SWITCH_BROAD, - THERMAL_2_ON_SWITCH_BROAD, - THERMAL_3_ON_SWITCH_BROAD, - THERMAL_4_ON_SWITCH_BROAD, - THERMAL_1_ON_FAN_BOARD, -}; - -/* Static values */ -static onlp_thermal_info_t linfo[] = { - { }, /* Not used */ - { { ONLP_THERMAL_ID_CREATE(THERMAL_1_ON_MAIN_BROAD), "CPU_TEMP", 0}, - ONLP_THERMAL_STATUS_PRESENT, - ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS - }, - { { ONLP_THERMAL_ID_CREATE(THERMAL_2_ON_MAIN_BROAD), "M2_TEMP", 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_CB_1", 0}, - ONLP_THERMAL_STATUS_PRESENT, - ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS - }, - { { ONLP_THERMAL_ID_CREATE(THERMAL_1_ON_SWITCH_BROAD), "SWITCH_TEMP", 0}, - ONLP_THERMAL_STATUS_PRESENT, - ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS - }, - { { ONLP_THERMAL_ID_CREATE(THERMAL_2_ON_SWITCH_BROAD), "TMP75_SB_1", 0}, - ONLP_THERMAL_STATUS_PRESENT, - ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS - }, - { { ONLP_THERMAL_ID_CREATE(THERMAL_3_ON_SWITCH_BROAD), "TMP75_SB_2", 0}, - ONLP_THERMAL_STATUS_PRESENT, - ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS - }, - { { ONLP_THERMAL_ID_CREATE(THERMAL_4_ON_SWITCH_BROAD), "TMP75_SB_3", 0}, - ONLP_THERMAL_STATUS_PRESENT, - ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS - }, - { { ONLP_THERMAL_ID_CREATE(THERMAL_1_ON_FAN_BOARD), "TMP75_FB_1", 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) -{ - // FIXME: WARNING FREEZE - if ( 0 ) { - printf("%d", linfo[0].status); - } - // END WARNING FREEZE - return ONLP_STATUS_OK; -} - diff --git a/packages/platforms/mitac/x86-64/ly1200-b32h0-c3/onlp/builds/x86_64_mitac_ly1200_b32h0_c3/module/src/x86_64_mitac_ly1200_b32h0_c3_config.c b/packages/platforms/mitac/x86-64/ly1200-b32h0-c3/onlp/builds/x86_64_mitac_ly1200_b32h0_c3/module/src/x86_64_mitac_ly1200_b32h0_c3_config.c deleted file mode 100644 index e19cbf302..000000000 --- a/packages/platforms/mitac/x86-64/ly1200-b32h0-c3/onlp/builds/x86_64_mitac_ly1200_b32h0_c3/module/src/x86_64_mitac_ly1200_b32h0_c3_config.c +++ /dev/null @@ -1,81 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#include - -/* */ -#define __x86_64_mitac_ly1200_b32h0_c3_config_STRINGIFY_NAME(_x) #_x -#define __x86_64_mitac_ly1200_b32h0_c3_config_STRINGIFY_VALUE(_x) __x86_64_mitac_ly1200_b32h0_c3_config_STRINGIFY_NAME(_x) -x86_64_mitac_ly1200_b32h0_c3_config_settings_t x86_64_mitac_ly1200_b32h0_c3_config_settings[] = -{ -#ifdef X86_64_MITAC_LY1200_B32H0_C3_CONFIG_INCLUDE_LOGGING - { __x86_64_mitac_ly1200_b32h0_c3_config_STRINGIFY_NAME(X86_64_MITAC_LY1200_B32H0_C3_CONFIG_INCLUDE_LOGGING), __x86_64_mitac_ly1200_b32h0_c3_config_STRINGIFY_VALUE(X86_64_MITAC_LY1200_B32H0_C3_CONFIG_INCLUDE_LOGGING) }, -#else -{ X86_64_MITAC_LY1200_B32H0_C3_CONFIG_INCLUDE_LOGGING(__x86_64_mitac_ly1200_b32h0_c3_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_MITAC_LY1200_B32H0_C3_CONFIG_LOG_OPTIONS_DEFAULT - { __x86_64_mitac_ly1200_b32h0_c3_config_STRINGIFY_NAME(X86_64_MITAC_LY1200_B32H0_C3_CONFIG_LOG_OPTIONS_DEFAULT), __x86_64_mitac_ly1200_b32h0_c3_config_STRINGIFY_VALUE(X86_64_MITAC_LY1200_B32H0_C3_CONFIG_LOG_OPTIONS_DEFAULT) }, -#else -{ X86_64_MITAC_LY1200_B32H0_C3_CONFIG_LOG_OPTIONS_DEFAULT(__x86_64_mitac_ly1200_b32h0_c3_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_MITAC_LY1200_B32H0_C3_CONFIG_LOG_BITS_DEFAULT - { __x86_64_mitac_ly1200_b32h0_c3_config_STRINGIFY_NAME(X86_64_MITAC_LY1200_B32H0_C3_CONFIG_LOG_BITS_DEFAULT), __x86_64_mitac_ly1200_b32h0_c3_config_STRINGIFY_VALUE(X86_64_MITAC_LY1200_B32H0_C3_CONFIG_LOG_BITS_DEFAULT) }, -#else -{ X86_64_MITAC_LY1200_B32H0_C3_CONFIG_LOG_BITS_DEFAULT(__x86_64_mitac_ly1200_b32h0_c3_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_MITAC_LY1200_B32H0_C3_CONFIG_LOG_CUSTOM_BITS_DEFAULT - { __x86_64_mitac_ly1200_b32h0_c3_config_STRINGIFY_NAME(X86_64_MITAC_LY1200_B32H0_C3_CONFIG_LOG_CUSTOM_BITS_DEFAULT), __x86_64_mitac_ly1200_b32h0_c3_config_STRINGIFY_VALUE(X86_64_MITAC_LY1200_B32H0_C3_CONFIG_LOG_CUSTOM_BITS_DEFAULT) }, -#else -{ X86_64_MITAC_LY1200_B32H0_C3_CONFIG_LOG_CUSTOM_BITS_DEFAULT(__x86_64_mitac_ly1200_b32h0_c3_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_MITAC_LY1200_B32H0_C3_CONFIG_PORTING_STDLIB - { __x86_64_mitac_ly1200_b32h0_c3_config_STRINGIFY_NAME(X86_64_MITAC_LY1200_B32H0_C3_CONFIG_PORTING_STDLIB), __x86_64_mitac_ly1200_b32h0_c3_config_STRINGIFY_VALUE(X86_64_MITAC_LY1200_B32H0_C3_CONFIG_PORTING_STDLIB) }, -#else -{ X86_64_MITAC_LY1200_B32H0_C3_CONFIG_PORTING_STDLIB(__x86_64_mitac_ly1200_b32h0_c3_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_MITAC_LY1200_B32H0_C3_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS - { __x86_64_mitac_ly1200_b32h0_c3_config_STRINGIFY_NAME(X86_64_MITAC_LY1200_B32H0_C3_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS), __x86_64_mitac_ly1200_b32h0_c3_config_STRINGIFY_VALUE(X86_64_MITAC_LY1200_B32H0_C3_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS) }, -#else -{ X86_64_MITAC_LY1200_B32H0_C3_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS(__x86_64_mitac_ly1200_b32h0_c3_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_MITAC_LY1200_B32H0_C3_CONFIG_INCLUDE_UCLI - { __x86_64_mitac_ly1200_b32h0_c3_config_STRINGIFY_NAME(X86_64_MITAC_LY1200_B32H0_C3_CONFIG_INCLUDE_UCLI), __x86_64_mitac_ly1200_b32h0_c3_config_STRINGIFY_VALUE(X86_64_MITAC_LY1200_B32H0_C3_CONFIG_INCLUDE_UCLI) }, -#else -{ X86_64_MITAC_LY1200_B32H0_C3_CONFIG_INCLUDE_UCLI(__x86_64_mitac_ly1200_b32h0_c3_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_MITAC_LY1200_B32H0_C3_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION - { __x86_64_mitac_ly1200_b32h0_c3_config_STRINGIFY_NAME(X86_64_MITAC_LY1200_B32H0_C3_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION), __x86_64_mitac_ly1200_b32h0_c3_config_STRINGIFY_VALUE(X86_64_MITAC_LY1200_B32H0_C3_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION) }, -#else -{ X86_64_MITAC_LY1200_B32H0_C3_CONFIG_INCLUDE_DEFAULT_FAN_DIRECTION(__x86_64_mitac_ly1200_b32h0_c3_config_STRINGIFY_NAME), "__undefined__" }, -#endif - { NULL, NULL } -}; -#undef __x86_64_mitac_ly1200_b32h0_c3_config_STRINGIFY_VALUE -#undef __x86_64_mitac_ly1200_b32h0_c3_config_STRINGIFY_NAME - -const char* -x86_64_mitac_ly1200_b32h0_c3_config_lookup(const char* setting) -{ - int i; - for(i = 0; x86_64_mitac_ly1200_b32h0_c3_config_settings[i].name; i++) { - if(!strcmp(x86_64_mitac_ly1200_b32h0_c3_config_settings[i].name, setting)) { - return x86_64_mitac_ly1200_b32h0_c3_config_settings[i].value; - } - } - return NULL; -} - -int -x86_64_mitac_ly1200_b32h0_c3_config_show(struct aim_pvs_s* pvs) -{ - int i; - for(i = 0; x86_64_mitac_ly1200_b32h0_c3_config_settings[i].name; i++) { - aim_printf(pvs, "%s = %s\n", x86_64_mitac_ly1200_b32h0_c3_config_settings[i].name, x86_64_mitac_ly1200_b32h0_c3_config_settings[i].value); - } - return i; -} - -/* */ - diff --git a/packages/platforms/mitac/x86-64/ly1200-b32h0-c3/onlp/builds/x86_64_mitac_ly1200_b32h0_c3/module/src/x86_64_mitac_ly1200_b32h0_c3_enums.c b/packages/platforms/mitac/x86-64/ly1200-b32h0-c3/onlp/builds/x86_64_mitac_ly1200_b32h0_c3/module/src/x86_64_mitac_ly1200_b32h0_c3_enums.c deleted file mode 100644 index f99961eec..000000000 --- a/packages/platforms/mitac/x86-64/ly1200-b32h0-c3/onlp/builds/x86_64_mitac_ly1200_b32h0_c3/module/src/x86_64_mitac_ly1200_b32h0_c3_enums.c +++ /dev/null @@ -1,10 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#include - -/* <--auto.start.enum(ALL).source> */ -/* */ - diff --git a/packages/platforms/mitac/x86-64/ly1200-b32h0-c3/onlp/builds/x86_64_mitac_ly1200_b32h0_c3/module/src/x86_64_mitac_ly1200_b32h0_c3_int.h b/packages/platforms/mitac/x86-64/ly1200-b32h0-c3/onlp/builds/x86_64_mitac_ly1200_b32h0_c3/module/src/x86_64_mitac_ly1200_b32h0_c3_int.h deleted file mode 100644 index 10a30b0ac..000000000 --- a/packages/platforms/mitac/x86-64/ly1200-b32h0-c3/onlp/builds/x86_64_mitac_ly1200_b32h0_c3/module/src/x86_64_mitac_ly1200_b32h0_c3_int.h +++ /dev/null @@ -1,12 +0,0 @@ -/**************************************************************************//** - * - * x86_64_mitac_ly1200_b32h0_c3 Internal Header - * - *****************************************************************************/ -#ifndef __x86_64_mitac_ly1200_b32h0_c3_INT_H__ -#define __x86_64_mitac_ly1200_b32h0_c3_INT_H__ - -#include - - -#endif /* __x86_64_mitac_ly1200_b32h0_c3_INT_H__ */ diff --git a/packages/platforms/mitac/x86-64/ly1200-b32h0-c3/onlp/builds/x86_64_mitac_ly1200_b32h0_c3/module/src/x86_64_mitac_ly1200_b32h0_c3_log.c b/packages/platforms/mitac/x86-64/ly1200-b32h0-c3/onlp/builds/x86_64_mitac_ly1200_b32h0_c3/module/src/x86_64_mitac_ly1200_b32h0_c3_log.c deleted file mode 100644 index da60c9496..000000000 --- a/packages/platforms/mitac/x86-64/ly1200-b32h0-c3/onlp/builds/x86_64_mitac_ly1200_b32h0_c3/module/src/x86_64_mitac_ly1200_b32h0_c3_log.c +++ /dev/null @@ -1,18 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#include - -#include "x86_64_mitac_ly1200_b32h0_c3_log.h" -/* - * x86_64_mitac_ly1200_b32h0_c3 log struct. - */ -AIM_LOG_STRUCT_DEFINE( - X86_64_MITAC_LY1200_B32H0_C3_CONFIG_LOG_OPTIONS_DEFAULT, - X86_64_MITAC_LY1200_B32H0_C3_CONFIG_LOG_BITS_DEFAULT, - NULL, /* Custom log map */ - X86_64_MITAC_LY1200_B32H0_C3_CONFIG_LOG_CUSTOM_BITS_DEFAULT - ); - diff --git a/packages/platforms/mitac/x86-64/ly1200-b32h0-c3/onlp/builds/x86_64_mitac_ly1200_b32h0_c3/module/src/x86_64_mitac_ly1200_b32h0_c3_log.h b/packages/platforms/mitac/x86-64/ly1200-b32h0-c3/onlp/builds/x86_64_mitac_ly1200_b32h0_c3/module/src/x86_64_mitac_ly1200_b32h0_c3_log.h deleted file mode 100644 index d9733ae5d..000000000 --- a/packages/platforms/mitac/x86-64/ly1200-b32h0-c3/onlp/builds/x86_64_mitac_ly1200_b32h0_c3/module/src/x86_64_mitac_ly1200_b32h0_c3_log.h +++ /dev/null @@ -1,12 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#ifndef __x86_64_mitac_ly1200_b32h0_c3_LOG_H__ -#define __x86_64_mitac_ly1200_b32h0_c3_LOG_H__ - -#define AIM_LOG_MODULE_NAME x86_64_mitac_ly1200_b32h0_c3 -#include - -#endif /* __x86_64_mitac_ly1200_b32h0_c3_LOG_H__ */ diff --git a/packages/platforms/mitac/x86-64/ly1200-b32h0-c3/onlp/builds/x86_64_mitac_ly1200_b32h0_c3/module/src/x86_64_mitac_ly1200_b32h0_c3_module.c b/packages/platforms/mitac/x86-64/ly1200-b32h0-c3/onlp/builds/x86_64_mitac_ly1200_b32h0_c3/module/src/x86_64_mitac_ly1200_b32h0_c3_module.c deleted file mode 100644 index 15bb27015..000000000 --- a/packages/platforms/mitac/x86-64/ly1200-b32h0-c3/onlp/builds/x86_64_mitac_ly1200_b32h0_c3/module/src/x86_64_mitac_ly1200_b32h0_c3_module.c +++ /dev/null @@ -1,24 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#include - -#include "x86_64_mitac_ly1200_b32h0_c3_log.h" - -static int -datatypes_init__(void) -{ -#define x86_64_mitac_ly1200_b32h0_c3_ENUMERATION_ENTRY(_enum_name, _desc) AIM_DATATYPE_MAP_REGISTER(_enum_name, _enum_name##_map, _desc, AIM_LOG_INTERNAL); -#include - return 0; -} - -void __x86_64_mitac_ly1200_b32h0_c3_module_init__(void) -{ - AIM_LOG_STRUCT_REGISTER(); - datatypes_init__(); -} - -int __onlp_platform_version__ = 1; diff --git a/packages/platforms/mitac/x86-64/ly1200-b32h0-c3/onlp/builds/x86_64_mitac_ly1200_b32h0_c3/module/src/x86_64_mitac_ly1200_b32h0_c3_ucli.c b/packages/platforms/mitac/x86-64/ly1200-b32h0-c3/onlp/builds/x86_64_mitac_ly1200_b32h0_c3/module/src/x86_64_mitac_ly1200_b32h0_c3_ucli.c deleted file mode 100644 index cdb680e86..000000000 --- a/packages/platforms/mitac/x86-64/ly1200-b32h0-c3/onlp/builds/x86_64_mitac_ly1200_b32h0_c3/module/src/x86_64_mitac_ly1200_b32h0_c3_ucli.c +++ /dev/null @@ -1,50 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#include - -#if X86_64_MITAC_LY1200_B32H0_C3_CONFIG_INCLUDE_UCLI == 1 - -#include -#include -#include - -static ucli_status_t -x86_64_mitac_ly1200_b32h0_c3_ucli_ucli__config__(ucli_context_t* uc) -{ - UCLI_HANDLER_MACRO_MODULE_CONFIG(x86_64_mitac_ly1200_b32h0_c3) -} - -/* */ -/* */ - -static ucli_module_t -x86_64_mitac_ly1200_b32h0_c3_ucli_module__ = - { - "x86_64_mitac_ly1200_b32h0_c3_ucli", - NULL, - x86_64_mitac_ly1200_b32h0_c3_ucli_ucli_handlers__, - NULL, - NULL, - }; - -ucli_node_t* -x86_64_mitac_ly1200_b32h0_c3_ucli_node_create(void) -{ - ucli_node_t* n; - ucli_module_init(&x86_64_mitac_ly1200_b32h0_c3_ucli_module__); - n = ucli_node_create("x86_64_mitac_ly1200_b32h0_c3", NULL, &x86_64_mitac_ly1200_b32h0_c3_ucli_module__); - ucli_node_subnode_add(n, ucli_module_log_node_create("x86_64_mitac_ly1200_b32h0_c3")); - return n; -} - -#else -void* -x86_64_mitac_ly1200_b32h0_c3_ucli_node_create(void) -{ - return NULL; -} -#endif - diff --git a/packages/platforms/mitac/x86-64/ly1200-b32h0-c3/platform-config/Makefile b/packages/platforms/mitac/x86-64/ly1200-b32h0-c3/platform-config/Makefile deleted file mode 100644 index 003238cf6..000000000 --- a/packages/platforms/mitac/x86-64/ly1200-b32h0-c3/platform-config/Makefile +++ /dev/null @@ -1 +0,0 @@ -include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/mitac/x86-64/ly1200-b32h0-c3/platform-config/r0/Makefile b/packages/platforms/mitac/x86-64/ly1200-b32h0-c3/platform-config/r0/Makefile deleted file mode 100644 index 003238cf6..000000000 --- a/packages/platforms/mitac/x86-64/ly1200-b32h0-c3/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/mitac/x86-64/ly1200-b32h0-c3/platform-config/r0/PKG.yml b/packages/platforms/mitac/x86-64/ly1200-b32h0-c3/platform-config/r0/PKG.yml deleted file mode 100644 index 5b18fb227..000000000 --- a/packages/platforms/mitac/x86-64/ly1200-b32h0-c3/platform-config/r0/PKG.yml +++ /dev/null @@ -1,30 +0,0 @@ -variables: - PLATFORM : x86-64-mitac-ly1200-b32h0-c3-r0 - -prerequisites: - packages: - - "onl-vendor-config-mitac:all" - - "onl-platform-modules-x86-64-mitac-ly1200-b32h0-c3:amd64" - -common: - version: 1.0.0 - arch: amd64 - copyright: Copyright 2013, 2014, 2015 Big Switch Networks - maintainer: support@bigswitch.com - support: opennetworklinux@googlegroups.com - changelog: None - -packages: - - name: onl-platform-config-$PLATFORM - depends: onl-vendor-config-mitac,onl-platform-modules-x86-64-mitac-ly1200-b32h0-c3 - summary: ONL Platform Configuration Package for the $PLATFORM - - files: - src/boot: /lib/platform-config/$PLATFORM/onl/boot - src/lib: /lib/platform-config/$PLATFORM/onl - src/python : ${PY_INSTALL}/onl/platform/ - - - name: onl-platform-build-$PLATFORM - summary: ONL Platform Build Package for the $PLATFORM - optional-files: - builds: $$PKG_INSTALL diff --git a/packages/platforms/mitac/x86-64/ly1200-b32h0-c3/platform-config/r0/src/boot/x86-64-mitac-ly1200-b32h0-c3-r0 b/packages/platforms/mitac/x86-64/ly1200-b32h0-c3/platform-config/r0/src/boot/x86-64-mitac-ly1200-b32h0-c3-r0 deleted file mode 100755 index 09f7e007c..000000000 --- a/packages/platforms/mitac/x86-64/ly1200-b32h0-c3/platform-config/r0/src/boot/x86-64-mitac-ly1200-b32h0-c3-r0 +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh - -#insmod /lib/platform-config/x86-64-mitac-ly1200-b32h0-c3-r0/onl/boot/ixgbe.ko diff --git a/packages/platforms/mitac/x86-64/ly1200-b32h0-c3/platform-config/r0/src/lib/etc/default/watchdog b/packages/platforms/mitac/x86-64/ly1200-b32h0-c3/platform-config/r0/src/lib/etc/default/watchdog deleted file mode 100644 index 769bf5735..000000000 --- a/packages/platforms/mitac/x86-64/ly1200-b32h0-c3/platform-config/r0/src/lib/etc/default/watchdog +++ /dev/null @@ -1,8 +0,0 @@ -# Start watchdog at boot time? 0 or 1 -run_watchdog=1 -# Start wd_keepalive after stopping watchdog? 0 or 1 -run_wd_keepalive=0 -# Load module before starting watchdog -watchdog_module="none" -# Specify additional watchdog options here (see manpage). -watchdog_options="/etc/watchdog.conf" diff --git a/packages/platforms/mitac/x86-64/ly1200-b32h0-c3/platform-config/r0/src/lib/etc/watchdog.conf b/packages/platforms/mitac/x86-64/ly1200-b32h0-c3/platform-config/r0/src/lib/etc/watchdog.conf deleted file mode 100644 index b33284405..000000000 --- a/packages/platforms/mitac/x86-64/ly1200-b32h0-c3/platform-config/r0/src/lib/etc/watchdog.conf +++ /dev/null @@ -1,45 +0,0 @@ -#ping = 172.31.14.1 -#ping = 172.26.1.255 -#interface = eth0 -#file = /var/log/messages -#change = 1407 - -# Uncomment to enable test. Setting one of these values to '0' disables it. -# These values will hopefully never reboot your machine during normal use -# (if your machine is really hung, the loadavg will go much higher than 25) -#max-load-1 = 24 -#max-load-5 = 18 -#max-load-15 = 12 - -# Note that this is the number of pages! -# To get the real size, check how large the pagesize is on your machine. -#min-memory = 1 -#allocatable-memory = 1 - -#repair-binary = /usr/sbin/repair -#repair-timeout = -#test-binary = -#test-timeout = - -watchdog-device = /dev/watchdog5 - -# Defaults compiled into the binary -#temperature-device = -#max-temperature = 120 - -# Defaults compiled into the binary -#admin = root -#interval = 1 -#logtick = 1 -#log-dir = /var/log/watchdog - -# This greatly decreases the chance that watchdog won't be scheduled before -# your machine is really loaded -realtime = yes -priority = 99 - -# Check if rsyslogd is still running by enabling the following line -#pidfile = /var/run/rsyslogd.pid - -# timeout : 15 , 30 , 60 , 90 , 120 , 180 , 240 sec -watchdog-timeout = 120 diff --git a/packages/platforms/mitac/x86-64/ly1200-b32h0-c3/platform-config/r0/src/lib/x86-64-mitac-ly1200-b32h0-c3-r0.yml b/packages/platforms/mitac/x86-64/ly1200-b32h0-c3/platform-config/r0/src/lib/x86-64-mitac-ly1200-b32h0-c3-r0.yml deleted file mode 100644 index ce1b178f4..000000000 --- a/packages/platforms/mitac/x86-64/ly1200-b32h0-c3/platform-config/r0/src/lib/x86-64-mitac-ly1200-b32h0-c3-r0.yml +++ /dev/null @@ -1,52 +0,0 @@ ---- - -###################################################################### -# -# platform-config for LY1200 -# -###################################################################### - -x86-64-mitac-ly1200-b32h0-c3-r0: - - grub: - - serial: >- - --port=0x3f8 - --speed=115200 - --word=8 - --parity=no - --stop=1 - - kernel: - <<: *kernel-4-14 - - args: >- - nopat - nohpet - intel_iommu=off - console=ttyS0,115200n8 - acpi_enforce_resources=lax - pcie_aspm=off - irqpoll - i2c-ismt.delay=1000 - - installer: - - ONL-BOOT: - =: 128MiB - format: ext4 - - ONL-CONFIG: - =: 128MiB - format: ext4 - - ONL-IMAGES: - =: 1GiB - format: ext4 - - ONL-DATA: - =: 10GiB - format: ext4 - - - ##network: - ## interfaces: - ## ma1: - ## name: ~ - ## syspath: pci0000:00/0000:00:1c.0/0000:0a:00.0 diff --git a/packages/platforms/mitac/x86-64/ly1200-b32h0-c3/platform-config/r0/src/python/x86_64_mitac_ly1200_b32h0_c3_r0/__init__.py b/packages/platforms/mitac/x86-64/ly1200-b32h0-c3/platform-config/r0/src/python/x86_64_mitac_ly1200_b32h0_c3_r0/__init__.py deleted file mode 100755 index f7c4cae11..000000000 --- a/packages/platforms/mitac/x86-64/ly1200-b32h0-c3/platform-config/r0/src/python/x86_64_mitac_ly1200_b32h0_c3_r0/__init__.py +++ /dev/null @@ -1,19 +0,0 @@ -from onl.platform.base import * -from onl.platform.mitac import * - -class OnlPlatform_x86_64_mitac_ly1200_b32h0_c3_r0(OnlPlatformMiTAC, - OnlPlatformPortConfig_32x100): - PLATFORM='x86-64-mitac-ly1200-b32h0-c3-r0' - MODEL="LY1200-B32H0-C3" - SYS_OBJECT_ID=".1200.320" - - def baseconfig(self): - - for m in [ 'gpe', 'system_cpld', 'master_cpld', 'slave_cpld', 'cb_i2c', 'sb_i2c', 'pb_i2c', 'fb_i2c', 'fb_module_i2c', 'fse000' ]: - self.insmod("x86-64-mitac-ly1200-b32h0-c3-%s" % m) - - platform_root='/lib/platform-config/current/onl' - os.system("ln -sf %s/etc/watchdog.conf /etc/watchdog.conf" % platform_root) - os.system("ln -sf %s/etc/default/watchdog /etc/default/watchdog" % platform_root) - - return True diff --git a/packages/platforms/mitac/x86-64/modules/Makefile b/packages/platforms/mitac/x86-64/modules/Makefile deleted file mode 100644 index 003238cf6..000000000 --- a/packages/platforms/mitac/x86-64/modules/Makefile +++ /dev/null @@ -1 +0,0 @@ -include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/mitac/x86-64/modules/PKG.yml b/packages/platforms/mitac/x86-64/modules/PKG.yml deleted file mode 100644 index 9d10e353d..000000000 --- a/packages/platforms/mitac/x86-64/modules/PKG.yml +++ /dev/null @@ -1 +0,0 @@ -!include $ONL_TEMPLATES/no-arch-vendor-modules.yml ARCH=amd64 VENDOR=mitac KERNELS="onl-kernel-4.14-lts-x86-64-all:amd64" diff --git a/packages/platforms/netberg/Makefile b/packages/platforms/netberg/Makefile deleted file mode 100755 index 003238cf6..000000000 --- a/packages/platforms/netberg/Makefile +++ /dev/null @@ -1 +0,0 @@ -include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/netberg/vendor-config/Makefile b/packages/platforms/netberg/vendor-config/Makefile deleted file mode 100755 index 003238cf6..000000000 --- a/packages/platforms/netberg/vendor-config/Makefile +++ /dev/null @@ -1 +0,0 @@ -include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/netberg/vendor-config/PKG.yml b/packages/platforms/netberg/vendor-config/PKG.yml deleted file mode 100755 index a18474fc0..000000000 --- a/packages/platforms/netberg/vendor-config/PKG.yml +++ /dev/null @@ -1 +0,0 @@ -!include $ONL_TEMPLATES/platform-config-vendor.yml VENDOR=netberg Vendor=Netberg diff --git a/packages/platforms/netberg/vendor-config/src/python/netberg/__init__.py b/packages/platforms/netberg/vendor-config/src/python/netberg/__init__.py deleted file mode 100755 index ce64a2e9e..000000000 --- a/packages/platforms/netberg/vendor-config/src/python/netberg/__init__.py +++ /dev/null @@ -1,7 +0,0 @@ -#!/usr/bin/python - -from onl.platform.base import * - -class OnlPlatformNetberg(OnlPlatformBase): - MANUFACTURER='Netberg' - PRIVATE_ENTERPRISE_NUMBER=50424 diff --git a/packages/platforms/netberg/x86-64/Makefile b/packages/platforms/netberg/x86-64/Makefile deleted file mode 100755 index 003238cf6..000000000 --- a/packages/platforms/netberg/x86-64/Makefile +++ /dev/null @@ -1 +0,0 @@ -include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/netberg/x86-64/aurora-420-rangeley/.gitignore b/packages/platforms/netberg/x86-64/aurora-420-rangeley/.gitignore deleted file mode 100755 index ec93c180c..000000000 --- a/packages/platforms/netberg/x86-64/aurora-420-rangeley/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -*x86*64*netberg*aurora*420*rangeley*.mk -onlpdump.mk diff --git a/packages/platforms/netberg/x86-64/aurora-420-rangeley/Makefile b/packages/platforms/netberg/x86-64/aurora-420-rangeley/Makefile deleted file mode 100755 index 003238cf6..000000000 --- a/packages/platforms/netberg/x86-64/aurora-420-rangeley/Makefile +++ /dev/null @@ -1 +0,0 @@ -include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/netberg/x86-64/aurora-420-rangeley/modules/Makefile b/packages/platforms/netberg/x86-64/aurora-420-rangeley/modules/Makefile deleted file mode 100755 index 003238cf6..000000000 --- a/packages/platforms/netberg/x86-64/aurora-420-rangeley/modules/Makefile +++ /dev/null @@ -1 +0,0 @@ -include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/netberg/x86-64/aurora-420-rangeley/modules/PKG.yml b/packages/platforms/netberg/x86-64/aurora-420-rangeley/modules/PKG.yml deleted file mode 100755 index b3df78e44..000000000 --- a/packages/platforms/netberg/x86-64/aurora-420-rangeley/modules/PKG.yml +++ /dev/null @@ -1 +0,0 @@ -!include $ONL_TEMPLATES/no-platform-modules.yml ARCH=amd64 VENDOR=netberg BASENAME=x86-64-netberg-aurora-420-rangeley diff --git a/packages/platforms/netberg/x86-64/aurora-420-rangeley/onlp/Makefile b/packages/platforms/netberg/x86-64/aurora-420-rangeley/onlp/Makefile deleted file mode 100755 index 003238cf6..000000000 --- a/packages/platforms/netberg/x86-64/aurora-420-rangeley/onlp/Makefile +++ /dev/null @@ -1 +0,0 @@ -include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/netberg/x86-64/aurora-420-rangeley/onlp/PKG.yml b/packages/platforms/netberg/x86-64/aurora-420-rangeley/onlp/PKG.yml deleted file mode 100755 index 85e495fc9..000000000 --- a/packages/platforms/netberg/x86-64/aurora-420-rangeley/onlp/PKG.yml +++ /dev/null @@ -1 +0,0 @@ -!include $ONL_TEMPLATES/onlp-platform-any.yml PLATFORM=x86-64-netberg-aurora-420-rangeley ARCH=amd64 TOOLCHAIN=x86_64-linux-gnu diff --git a/packages/platforms/netberg/x86-64/aurora-420-rangeley/onlp/builds/Makefile b/packages/platforms/netberg/x86-64/aurora-420-rangeley/onlp/builds/Makefile deleted file mode 100755 index e7437cb23..000000000 --- a/packages/platforms/netberg/x86-64/aurora-420-rangeley/onlp/builds/Makefile +++ /dev/null @@ -1,2 +0,0 @@ -FILTER=src -include $(ONL)/make/subdirs.mk diff --git a/packages/platforms/netberg/x86-64/aurora-420-rangeley/onlp/builds/lib/Makefile b/packages/platforms/netberg/x86-64/aurora-420-rangeley/onlp/builds/lib/Makefile deleted file mode 100755 index 7c521066d..000000000 --- a/packages/platforms/netberg/x86-64/aurora-420-rangeley/onlp/builds/lib/Makefile +++ /dev/null @@ -1,2 +0,0 @@ -PLATFORM := x86-64-netberg-aurora-420-rangeley -include $(ONL)/packages/base/any/onlp/builds/platform/libonlp-platform.mk diff --git a/packages/platforms/netberg/x86-64/aurora-420-rangeley/onlp/builds/onlpdump/Makefile b/packages/platforms/netberg/x86-64/aurora-420-rangeley/onlp/builds/onlpdump/Makefile deleted file mode 100755 index b5f79d78a..000000000 --- a/packages/platforms/netberg/x86-64/aurora-420-rangeley/onlp/builds/onlpdump/Makefile +++ /dev/null @@ -1,2 +0,0 @@ -PLATFORM := x86-64-netberg-aurora-420-rangeley -include $(ONL)/packages/base/any/onlp/builds/platform/onlps.mk diff --git a/packages/platforms/netberg/x86-64/aurora-420-rangeley/onlp/builds/x86_64_netberg_aurora_420_rangeley/.gitignore b/packages/platforms/netberg/x86-64/aurora-420-rangeley/onlp/builds/x86_64_netberg_aurora_420_rangeley/.gitignore deleted file mode 100644 index c81d16be3..000000000 --- a/packages/platforms/netberg/x86-64/aurora-420-rangeley/onlp/builds/x86_64_netberg_aurora_420_rangeley/.gitignore +++ /dev/null @@ -1 +0,0 @@ -*.mk diff --git a/packages/platforms/netberg/x86-64/aurora-420-rangeley/onlp/builds/x86_64_netberg_aurora_420_rangeley/.module b/packages/platforms/netberg/x86-64/aurora-420-rangeley/onlp/builds/x86_64_netberg_aurora_420_rangeley/.module deleted file mode 100755 index d3df16ce9..000000000 --- a/packages/platforms/netberg/x86-64/aurora-420-rangeley/onlp/builds/x86_64_netberg_aurora_420_rangeley/.module +++ /dev/null @@ -1 +0,0 @@ -name: x86_64_netberg_aurora_420_rangeley diff --git a/packages/platforms/netberg/x86-64/aurora-420-rangeley/onlp/builds/x86_64_netberg_aurora_420_rangeley/Makefile b/packages/platforms/netberg/x86-64/aurora-420-rangeley/onlp/builds/x86_64_netberg_aurora_420_rangeley/Makefile deleted file mode 100755 index e0be8a990..000000000 --- a/packages/platforms/netberg/x86-64/aurora-420-rangeley/onlp/builds/x86_64_netberg_aurora_420_rangeley/Makefile +++ /dev/null @@ -1,9 +0,0 @@ -############################################################################### -# -# -# -############################################################################### -include $(ONL)/make/config.mk -MODULE := x86_64_netberg_aurora_420_rangeley -AUTOMODULE := x86_64_netberg_aurora_420_rangeley -include $(BUILDER)/definemodule.mk diff --git a/packages/platforms/netberg/x86-64/aurora-420-rangeley/onlp/builds/x86_64_netberg_aurora_420_rangeley/module/auto/make.mk b/packages/platforms/netberg/x86-64/aurora-420-rangeley/onlp/builds/x86_64_netberg_aurora_420_rangeley/module/auto/make.mk deleted file mode 100755 index ea87f84e5..000000000 --- a/packages/platforms/netberg/x86-64/aurora-420-rangeley/onlp/builds/x86_64_netberg_aurora_420_rangeley/module/auto/make.mk +++ /dev/null @@ -1,8 +0,0 @@ -############################################################################### -# -# x86_64_netberg_aurora_420_rangeley Autogeneration -# -############################################################################### -x86_64_netberg_aurora_420_rangeley_AUTO_DEFS := module/auto/x86_64_netberg_aurora_420_rangeley.yml -x86_64_netberg_aurora_420_rangeley_AUTO_DIRS := module/inc/x86_64_netberg_aurora_420_rangeley module/src -include $(BUILDER)/auto.mk diff --git a/packages/platforms/netberg/x86-64/aurora-420-rangeley/onlp/builds/x86_64_netberg_aurora_420_rangeley/module/auto/x86_64_netberg_aurora_420_rangeley.yml b/packages/platforms/netberg/x86-64/aurora-420-rangeley/onlp/builds/x86_64_netberg_aurora_420_rangeley/module/auto/x86_64_netberg_aurora_420_rangeley.yml deleted file mode 100644 index 32eea9e3a..000000000 --- a/packages/platforms/netberg/x86-64/aurora-420-rangeley/onlp/builds/x86_64_netberg_aurora_420_rangeley/module/auto/x86_64_netberg_aurora_420_rangeley.yml +++ /dev/null @@ -1,127 +0,0 @@ -############################################################################### -# -# x86_64_netberg_aurora_420_rangeley Autogeneration Definitions. -# -############################################################################### - -cdefs: &cdefs -- X86_64_NETBERG_AURORA_420_RANGELEY_CONFIG_INCLUDE_LOGGING: - doc: "Include or exclude logging." - default: 1 -- X86_64_NETBERG_AURORA_420_RANGELEY_CONFIG_LOG_OPTIONS_DEFAULT: - doc: "Default enabled log options." - default: AIM_LOG_OPTIONS_DEFAULT -- X86_64_NETBERG_AURORA_420_RANGELEY_CONFIG_LOG_BITS_DEFAULT: - doc: "Default enabled log bits." - default: AIM_LOG_BITS_DEFAULT -- X86_64_NETBERG_AURORA_420_RANGELEY_CONFIG_LOG_CUSTOM_BITS_DEFAULT: - doc: "Default enabled custom log bits." - default: 0 -- X86_64_NETBERG_AURORA_420_RANGELEY_CONFIG_PORTING_STDLIB: - doc: "Default all porting macros to use the C standard libraries." - default: 1 -- X86_64_NETBERG_AURORA_420_RANGELEY_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS: - doc: "Include standard library headers for stdlib porting macros." - default: X86_64_NETBERG_AURORA_420_RANGELEY_CONFIG_PORTING_STDLIB -- X86_64_NETBERG_AURORA_420_RANGELEY_CONFIG_INCLUDE_UCLI: - doc: "Include generic uCli support." - default: 0 -- X86_64_NETBERG_AURORA_420_RANGELEY_CONFIG_SYSFAN_RPM_FAILURE_THRESHOLD: - doc: "RPM Threshold at which the fan is considered to have failed." - default: 3000 - -definitions: - cdefs: - X86_64_NETBERG_AURORA_420_RANGELEY_CONFIG_HEADER: - defs: *cdefs - basename: x86_64_netberg_aurora_420_rangeley_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 - - 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) - - led_id: - members: - - STAT : 1 - - FAN : 2 - - PSU1 : 3 - - PSU2 : 4 - - LED1 : 5 - - LED2 : 6 - - LED3 : 7 - - LED4 : 8 - - led_oid: - members: - - STAT : ONLP_LED_ID_CREATE(1) - - FAN : ONLP_LED_ID_CREATE(2) - - PSU1 : ONLP_LED_ID_CREATE(3) - - PSU2 : ONLP_LED_ID_CREATE(4) - - LED1 : ONLP_LED_ID_CREATE(5) - - LED2 : ONLP_LED_ID_CREATE(6) - - LED3 : ONLP_LED_ID_CREATE(7) - - LED4 : ONLP_LED_ID_CREATE(8) - - portingmacro: - X86_64_NETBERG_AURORA_420_RANGELEY: - macros: - - memset - - memcpy - - - vsnprintf - - snprintf - - strlen diff --git a/packages/platforms/netberg/x86-64/aurora-420-rangeley/onlp/builds/x86_64_netberg_aurora_420_rangeley/module/inc/x86_64_netberg_aurora_420_rangeley/x86_64_netberg_aurora_420_rangeley.x b/packages/platforms/netberg/x86-64/aurora-420-rangeley/onlp/builds/x86_64_netberg_aurora_420_rangeley/module/inc/x86_64_netberg_aurora_420_rangeley/x86_64_netberg_aurora_420_rangeley.x deleted file mode 100755 index 7be4645df..000000000 --- a/packages/platforms/netberg/x86-64/aurora-420-rangeley/onlp/builds/x86_64_netberg_aurora_420_rangeley/module/inc/x86_64_netberg_aurora_420_rangeley/x86_64_netberg_aurora_420_rangeley.x +++ /dev/null @@ -1,14 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#include - -/* <--auto.start.xmacro(ALL).define> */ -/* */ - -/* <--auto.start.xenum(ALL).define> */ -/* */ - - diff --git a/packages/platforms/netberg/x86-64/aurora-420-rangeley/onlp/builds/x86_64_netberg_aurora_420_rangeley/module/inc/x86_64_netberg_aurora_420_rangeley/x86_64_netberg_aurora_420_rangeley_config.h b/packages/platforms/netberg/x86-64/aurora-420-rangeley/onlp/builds/x86_64_netberg_aurora_420_rangeley/module/inc/x86_64_netberg_aurora_420_rangeley/x86_64_netberg_aurora_420_rangeley_config.h deleted file mode 100755 index 6a506e232..000000000 --- a/packages/platforms/netberg/x86-64/aurora-420-rangeley/onlp/builds/x86_64_netberg_aurora_420_rangeley/module/inc/x86_64_netberg_aurora_420_rangeley/x86_64_netberg_aurora_420_rangeley_config.h +++ /dev/null @@ -1,137 +0,0 @@ -/**************************************************************************//** - * - * @file - * @brief x86_64_netberg_aurora_420_rangeley Configuration Header - * - * @addtogroup x86_64_netberg_aurora_420_rangeley-config - * @{ - * - *****************************************************************************/ -#ifndef __X86_64_NETBERG_AURORA_420_RANGELEY_CONFIG_H__ -#define __X86_64_NETBERG_AURORA_420_RANGELEY_CONFIG_H__ - -#ifdef GLOBAL_INCLUDE_CUSTOM_CONFIG -#include -#endif -#ifdef X86_64_NETBERG_AURORA_420_RANGELEY_INCLUDE_CUSTOM_CONFIG -#include -#endif - -/* */ -#include -/** - * X86_64_NETBERG_AURORA_420_RANGELEY_CONFIG_INCLUDE_LOGGING - * - * Include or exclude logging. */ - - -#ifndef X86_64_NETBERG_AURORA_420_RANGELEY_CONFIG_INCLUDE_LOGGING -#define X86_64_NETBERG_AURORA_420_RANGELEY_CONFIG_INCLUDE_LOGGING 1 -#endif - -/** - * X86_64_NETBERG_AURORA_420_RANGELEY_CONFIG_LOG_OPTIONS_DEFAULT - * - * Default enabled log options. */ - - -#ifndef X86_64_NETBERG_AURORA_420_RANGELEY_CONFIG_LOG_OPTIONS_DEFAULT -#define X86_64_NETBERG_AURORA_420_RANGELEY_CONFIG_LOG_OPTIONS_DEFAULT AIM_LOG_OPTIONS_DEFAULT -#endif - -/** - * X86_64_NETBERG_AURORA_420_RANGELEY_CONFIG_LOG_BITS_DEFAULT - * - * Default enabled log bits. */ - - -#ifndef X86_64_NETBERG_AURORA_420_RANGELEY_CONFIG_LOG_BITS_DEFAULT -#define X86_64_NETBERG_AURORA_420_RANGELEY_CONFIG_LOG_BITS_DEFAULT AIM_LOG_BITS_DEFAULT -#endif - -/** - * X86_64_NETBERG_AURORA_420_RANGELEY_CONFIG_LOG_CUSTOM_BITS_DEFAULT - * - * Default enabled custom log bits. */ - - -#ifndef X86_64_NETBERG_AURORA_420_RANGELEY_CONFIG_LOG_CUSTOM_BITS_DEFAULT -#define X86_64_NETBERG_AURORA_420_RANGELEY_CONFIG_LOG_CUSTOM_BITS_DEFAULT 0 -#endif - -/** - * X86_64_NETBERG_AURORA_420_RANGELEY_CONFIG_PORTING_STDLIB - * - * Default all porting macros to use the C standard libraries. */ - - -#ifndef X86_64_NETBERG_AURORA_420_RANGELEY_CONFIG_PORTING_STDLIB -#define X86_64_NETBERG_AURORA_420_RANGELEY_CONFIG_PORTING_STDLIB 1 -#endif - -/** - * X86_64_NETBERG_AURORA_420_RANGELEY_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS - * - * Include standard library headers for stdlib porting macros. */ - - -#ifndef X86_64_NETBERG_AURORA_420_RANGELEY_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS -#define X86_64_NETBERG_AURORA_420_RANGELEY_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS X86_64_NETBERG_AURORA_420_RANGELEY_CONFIG_PORTING_STDLIB -#endif - -/** - * X86_64_NETBERG_AURORA_420_RANGELEY_CONFIG_INCLUDE_UCLI - * - * Include generic uCli support. */ - - -#ifndef X86_64_NETBERG_AURORA_420_RANGELEY_CONFIG_INCLUDE_UCLI -#define X86_64_NETBERG_AURORA_420_RANGELEY_CONFIG_INCLUDE_UCLI 0 -#endif - -/** - * X86_64_NETBERG_AURORA_420_RANGELEY_CONFIG_SYSFAN_RPM_FAILURE_THRESHOLD - * - * RPM Threshold at which the fan is considered to have failed. */ - - -#ifndef X86_64_NETBERG_AURORA_420_RANGELEY_CONFIG_SYSFAN_RPM_FAILURE_THRESHOLD -#define X86_64_NETBERG_AURORA_420_RANGELEY_CONFIG_SYSFAN_RPM_FAILURE_THRESHOLD 3000 -#endif - - - -/** - * All compile time options can be queried or displayed - */ - -/** Configuration settings structure. */ -typedef struct x86_64_netberg_aurora_420_rangeley_config_settings_s { - /** name */ - const char* name; - /** value */ - const char* value; -} x86_64_netberg_aurora_420_rangeley_config_settings_t; - -/** Configuration settings table. */ -/** x86_64_netberg_aurora_420_rangeley_config_settings table. */ -extern x86_64_netberg_aurora_420_rangeley_config_settings_t x86_64_netberg_aurora_420_rangeley_config_settings[]; - -/** - * @brief Lookup a configuration setting. - * @param setting The name of the configuration option to lookup. - */ -const char* x86_64_netberg_aurora_420_rangeley_config_lookup(const char* setting); - -/** - * @brief Show the compile-time configuration. - * @param pvs The output stream. - */ -int x86_64_netberg_aurora_420_rangeley_config_show(struct aim_pvs_s* pvs); - -/* */ - -#include "x86_64_netberg_aurora_420_rangeley_porting.h" - -#endif /* __X86_64_NETBERG_AURORA_420_RANGELEY_CONFIG_H__ */ -/* @} */ diff --git a/packages/platforms/netberg/x86-64/aurora-420-rangeley/onlp/builds/x86_64_netberg_aurora_420_rangeley/module/inc/x86_64_netberg_aurora_420_rangeley/x86_64_netberg_aurora_420_rangeley_dox.h b/packages/platforms/netberg/x86-64/aurora-420-rangeley/onlp/builds/x86_64_netberg_aurora_420_rangeley/module/inc/x86_64_netberg_aurora_420_rangeley/x86_64_netberg_aurora_420_rangeley_dox.h deleted file mode 100755 index d37fea934..000000000 --- a/packages/platforms/netberg/x86-64/aurora-420-rangeley/onlp/builds/x86_64_netberg_aurora_420_rangeley/module/inc/x86_64_netberg_aurora_420_rangeley/x86_64_netberg_aurora_420_rangeley_dox.h +++ /dev/null @@ -1,26 +0,0 @@ -/**************************************************************************//** - * - * x86_64_netberg_aurora_420_rangeley Doxygen Header - * - *****************************************************************************/ -#ifndef __X86_64_NETBERG_AURORA_420_RANGELEY_DOX_H__ -#define __X86_64_NETBERG_AURORA_420_RANGELEY_DOX_H__ - -/** - * @defgroup x86_64_netberg_aurora_420_rangeley x86_64_netberg_aurora_420_rangeley - x86_64_netberg_aurora_420_rangeley Description - * - -The documentation overview for this module should go here. - - * - * @{ - * - * @defgroup x86_64_netberg_aurora_420_rangeley-x86_64_netberg_aurora_420_rangeley Public Interface - * @defgroup x86_64_netberg_aurora_420_rangeley-config Compile Time Configuration - * @defgroup x86_64_netberg_aurora_420_rangeley-porting Porting Macros - * - * @} - * - */ - -#endif /* __X86_64_NETBERG_AURORA_420_RANGELEY_DOX_H__ */ diff --git a/packages/platforms/netberg/x86-64/aurora-420-rangeley/onlp/builds/x86_64_netberg_aurora_420_rangeley/module/inc/x86_64_netberg_aurora_420_rangeley/x86_64_netberg_aurora_420_rangeley_porting.h b/packages/platforms/netberg/x86-64/aurora-420-rangeley/onlp/builds/x86_64_netberg_aurora_420_rangeley/module/inc/x86_64_netberg_aurora_420_rangeley/x86_64_netberg_aurora_420_rangeley_porting.h deleted file mode 100755 index 3c37783d2..000000000 --- a/packages/platforms/netberg/x86-64/aurora-420-rangeley/onlp/builds/x86_64_netberg_aurora_420_rangeley/module/inc/x86_64_netberg_aurora_420_rangeley/x86_64_netberg_aurora_420_rangeley_porting.h +++ /dev/null @@ -1,77 +0,0 @@ -/**************************************************************************//** - * - * @file - * @brief x86_64_netberg_aurora_420_rangeley Porting Macros. - * - * @addtogroup x86_64_netberg_aurora_420_rangeley-porting - * @{ - * - *****************************************************************************/ -#ifndef __X86_64_NETBERG_AURORA_420_RANGELEY_PORTING_H__ -#define __X86_64_NETBERG_AURORA_420_RANGELEY_PORTING_H__ - - -/* */ -#if X86_64_NETBERG_AURORA_420_RANGELEY_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS == 1 -#include -#include -#include -#include -#include -#endif - -#ifndef X86_64_NETBERG_AURORA_420_RANGELEY_MEMSET - #if defined(GLOBAL_MEMSET) - #define X86_64_NETBERG_AURORA_420_RANGELEY_MEMSET GLOBAL_MEMSET - #elif X86_64_NETBERG_AURORA_420_RANGELEY_CONFIG_PORTING_STDLIB == 1 - #define X86_64_NETBERG_AURORA_420_RANGELEY_MEMSET memset - #else - #error The macro X86_64_NETBERG_AURORA_420_RANGELEY_MEMSET is required but cannot be defined. - #endif -#endif - -#ifndef X86_64_NETBERG_AURORA_420_RANGELEY_MEMCPY - #if defined(GLOBAL_MEMCPY) - #define X86_64_NETBERG_AURORA_420_RANGELEY_MEMCPY GLOBAL_MEMCPY - #elif X86_64_NETBERG_AURORA_420_RANGELEY_CONFIG_PORTING_STDLIB == 1 - #define X86_64_NETBERG_AURORA_420_RANGELEY_MEMCPY memcpy - #else - #error The macro X86_64_NETBERG_AURORA_420_RANGELEY_MEMCPY is required but cannot be defined. - #endif -#endif - -#ifndef X86_64_NETBERG_AURORA_420_RANGELEY_VSNPRINTF - #if defined(GLOBAL_VSNPRINTF) - #define X86_64_NETBERG_AURORA_420_RANGELEY_VSNPRINTF GLOBAL_VSNPRINTF - #elif X86_64_NETBERG_AURORA_420_RANGELEY_CONFIG_PORTING_STDLIB == 1 - #define X86_64_NETBERG_AURORA_420_RANGELEY_VSNPRINTF vsnprintf - #else - #error The macro X86_64_NETBERG_AURORA_420_RANGELEY_VSNPRINTF is required but cannot be defined. - #endif -#endif - -#ifndef X86_64_NETBERG_AURORA_420_RANGELEY_SNPRINTF - #if defined(GLOBAL_SNPRINTF) - #define X86_64_NETBERG_AURORA_420_RANGELEY_SNPRINTF GLOBAL_SNPRINTF - #elif X86_64_NETBERG_AURORA_420_RANGELEY_CONFIG_PORTING_STDLIB == 1 - #define X86_64_NETBERG_AURORA_420_RANGELEY_SNPRINTF snprintf - #else - #error The macro X86_64_NETBERG_AURORA_420_RANGELEY_SNPRINTF is required but cannot be defined. - #endif -#endif - -#ifndef X86_64_NETBERG_AURORA_420_RANGELEY_STRLEN - #if defined(GLOBAL_STRLEN) - #define X86_64_NETBERG_AURORA_420_RANGELEY_STRLEN GLOBAL_STRLEN - #elif X86_64_NETBERG_AURORA_420_RANGELEY_CONFIG_PORTING_STDLIB == 1 - #define X86_64_NETBERG_AURORA_420_RANGELEY_STRLEN strlen - #else - #error The macro X86_64_NETBERG_AURORA_420_RANGELEY_STRLEN is required but cannot be defined. - #endif -#endif - -/* */ - - -#endif /* __X86_64_NETBERG_AURORA_420_RANGELEY_PORTING_H__ */ -/* @} */ diff --git a/packages/platforms/netberg/x86-64/aurora-420-rangeley/onlp/builds/x86_64_netberg_aurora_420_rangeley/module/make.mk b/packages/platforms/netberg/x86-64/aurora-420-rangeley/onlp/builds/x86_64_netberg_aurora_420_rangeley/module/make.mk deleted file mode 100644 index dea3e5334..000000000 --- a/packages/platforms/netberg/x86-64/aurora-420-rangeley/onlp/builds/x86_64_netberg_aurora_420_rangeley/module/make.mk +++ /dev/null @@ -1,10 +0,0 @@ -############################################################################### -# -# -# -############################################################################### -THIS_DIR := $(dir $(lastword $(MAKEFILE_LIST))) -x86_64_netberg_aurora_420_rangeley_INCLUDES := -I $(THIS_DIR)inc -x86_64_netberg_aurora_420_rangeley_INTERNAL_INCLUDES := -I $(THIS_DIR)src -x86_64_netberg_aurora_420_rangeley_DEPENDMODULE_ENTRIES := init:x86_64_netberg_aurora_420_rangeley ucli:x86_64_netberg_aurora_420_rangeley - diff --git a/packages/platforms/netberg/x86-64/aurora-420-rangeley/onlp/builds/x86_64_netberg_aurora_420_rangeley/module/src/Makefile b/packages/platforms/netberg/x86-64/aurora-420-rangeley/onlp/builds/x86_64_netberg_aurora_420_rangeley/module/src/Makefile deleted file mode 100755 index ef9d70edd..000000000 --- a/packages/platforms/netberg/x86-64/aurora-420-rangeley/onlp/builds/x86_64_netberg_aurora_420_rangeley/module/src/Makefile +++ /dev/null @@ -1,9 +0,0 @@ -############################################################################### -# -# Local source generation targets. -# -############################################################################### - -ucli: - @../../../../tools/uclihandlers.py x86_64_netberg_aurora_420_rangeley_ucli.c - diff --git a/packages/platforms/netberg/x86-64/aurora-420-rangeley/onlp/builds/x86_64_netberg_aurora_420_rangeley/module/src/fani.c b/packages/platforms/netberg/x86-64/aurora-420-rangeley/onlp/builds/x86_64_netberg_aurora_420_rangeley/module/src/fani.c deleted file mode 100755 index 4cc758048..000000000 --- a/packages/platforms/netberg/x86-64/aurora-420-rangeley/onlp/builds/x86_64_netberg_aurora_420_rangeley/module/src/fani.c +++ /dev/null @@ -1,234 +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 "x86_64_netberg_aurora_420_rangeley_int.h" -#include "x86_64_netberg_aurora_420_rangeley_log.h" - -#include - - -#define VALIDATE(_id) \ - do { \ - if(!ONLP_OID_IS_FAN(_id)) { \ - return ONLP_STATUS_E_INVALID; \ - } \ - } while(0) - -static int -sys_fan_info_get__(onlp_fan_info_t* info, int id) -{ - int value = 0; - int rv; - - rv = onlp_file_read_int(&value, SYS_HWMON2_PREFIX "/fan%d_abs", ((id/2)+1)); - if (rv != ONLP_STATUS_OK) - return rv; - - if (value == 0) - { - info->status = ONLP_FAN_STATUS_FAILED; - } - else - { - info->status = ONLP_FAN_STATUS_PRESENT; - - rv = onlp_file_read_int(&value, SYS_HWMON2_PREFIX "/fan%d_dir", ((id/2)+1)); - if (rv != ONLP_STATUS_OK) - return rv; - - if (value == 1) - { - info->status |= ONLP_FAN_STATUS_B2F; - info->caps |= ONLP_FAN_CAPS_B2F; - } - else - { - info->status |= ONLP_FAN_STATUS_F2B; - info->caps |= ONLP_FAN_CAPS_F2B; - } - - rv = onlp_file_read_int(&(info->rpm), SYS_HWMON1_PREFIX "/fan%d_rpm", (id+1)); - if (rv == ONLP_STATUS_E_INTERNAL) - return rv; - - if (rv == ONLP_STATUS_E_MISSING) - { - info->status &= ~1; - return 0; - } - - if (info->rpm <= X86_64_NETBERG_AURORA_420_RANGELEY_CONFIG_SYSFAN_RPM_FAILURE_THRESHOLD) - info->status |= ONLP_FAN_STATUS_FAILED; - - - rv = onlp_file_read_int(&(info->percentage), SYS_HWMON1_PREFIX "/fan%d_duty", (id+1)); - if (rv == ONLP_STATUS_E_INTERNAL) - return rv; - - if (rv == ONLP_STATUS_E_MISSING) - { - info->status &= ~1; - return 0; - } - } - return 0; -} - -static int -psu_fan_info_get__(onlp_fan_info_t* info, int id) -{ - return onlp_file_read_int(&(info->rpm), SYS_HWMON2_PREFIX "/psu%d_fan_speed", id); -} - -/* Onboard Fans */ -static onlp_fan_info_t fans__[] = { - { }, /* Not used */ - { { FAN_OID_FAN1, "Fan1_rotor1", 0}, ONLP_FAN_STATUS_PRESENT }, - { { FAN_OID_FAN2, "Fan1_rotor2", 0}, ONLP_FAN_STATUS_PRESENT }, - { { FAN_OID_FAN3, "Fan2_rotor1", 0}, ONLP_FAN_STATUS_PRESENT }, - { { FAN_OID_FAN4, "Fan2_rotor2", 0}, ONLP_FAN_STATUS_PRESENT }, - { { FAN_OID_FAN5, "Fan3_rotor1", 0}, ONLP_FAN_STATUS_PRESENT }, - { { FAN_OID_FAN6, "Fan3_rotor2", 0}, ONLP_FAN_STATUS_PRESENT }, - { { FAN_OID_FAN7, "Fan4_rotor1", 0}, ONLP_FAN_STATUS_PRESENT }, - { { FAN_OID_FAN8, "Fan4_rotor2", 0}, ONLP_FAN_STATUS_PRESENT }, - { { FAN_OID_FAN9, "PSU-1 Fan", 0 }, ONLP_FAN_STATUS_PRESENT }, - { { FAN_OID_FAN10, "PSU-2 Fan", 0 }, ONLP_FAN_STATUS_PRESENT }, -}; - -/* - * 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 fid; - - VALIDATE(id); - - memset(info, 0, sizeof(onlp_fan_info_t)); - fid = ONLP_OID_ID_GET(id); - *info = fans__[fid]; - - info->caps |= ONLP_FAN_CAPS_GET_RPM; - - switch(fid) - { - case FAN_ID_FAN1: - case FAN_ID_FAN2: - case FAN_ID_FAN3: - case FAN_ID_FAN4: - case FAN_ID_FAN5: - case FAN_ID_FAN6: - case FAN_ID_FAN7: - case FAN_ID_FAN8: - return sys_fan_info_get__(info, (fid - 1)); - break; - - case FAN_ID_FAN9: - case FAN_ID_FAN10: - return psu_fan_info_get__(info, (fid - FAN_ID_FAN9 + 1)); - break; - - default: - return ONLP_STATUS_E_INVALID; - break; - } - - return ONLP_STATUS_E_INVALID; -} - -/* - * 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) -{ - return ONLP_STATUS_E_UNSUPPORTED; -} - -/* - * 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/netberg/x86-64/aurora-420-rangeley/onlp/builds/x86_64_netberg_aurora_420_rangeley/module/src/ledi.c b/packages/platforms/netberg/x86-64/aurora-420-rangeley/onlp/builds/x86_64_netberg_aurora_420_rangeley/module/src/ledi.c deleted file mode 100755 index 2b482315b..000000000 --- a/packages/platforms/netberg/x86-64/aurora-420-rangeley/onlp/builds/x86_64_netberg_aurora_420_rangeley/module/src/ledi.c +++ /dev/null @@ -1,221 +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 "x86_64_netberg_aurora_420_rangeley_int.h" - -#define VALIDATE(_id) \ - do { \ - if(!ONLP_OID_IS_LED(_id)) { \ - return ONLP_STATUS_E_INVALID; \ - } \ - } while(0) - -/* LED related data - */ -enum led_light_mode { /*must be the same with the definition @ kernel driver */ - LED_MODE_OFF = 0, - LED_MODE_AMBER, - LED_MODE_GREEN, -}; - -int led_light_map_mode[][2] = -{ - {LED_MODE_OFF, ONLP_LED_MODE_OFF}, - {LED_MODE_AMBER, ONLP_LED_MODE_ORANGE}, - {LED_MODE_GREEN, ONLP_LED_MODE_GREEN}, -}; - -/* - * Get the information for the given LED OID. - */ -static onlp_led_info_t linfo[] = -{ - { }, /* Not used */ - { - { LED_OID_LED1, "Chassis LED 1 (STAT LED)", 0 }, - ONLP_LED_STATUS_PRESENT, - ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_ORANGE | ONLP_LED_CAPS_GREEN, - ONLP_LED_MODE_OFF, - }, - { - { LED_OID_LED2, "Chassis LED 2 (FAN LED)", 0 }, - ONLP_LED_STATUS_PRESENT, - ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_ORANGE | ONLP_LED_CAPS_GREEN, - ONLP_LED_MODE_OFF, - }, - { - { LED_OID_LED3, "Chassis LED 3 (PSU1 LED)", 0 }, - ONLP_LED_STATUS_PRESENT, - ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_ORANGE | ONLP_LED_CAPS_GREEN, - ONLP_LED_MODE_OFF, - }, - { - { LED_OID_LED4, "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_MODE_OFF, - }, -}; - -static int conver_led_light_mode_to_driver(int led_ligth_mode) -{ - int i, nsize = sizeof(led_light_map_mode)/sizeof(led_light_map_mode[0]); - for(i=0; i - * - ************************************************************ - * - * - * - ***********************************************************/ -#include -#include -#include -#include "x86_64_netberg_aurora_420_rangeley_int.h" -#include "x86_64_netberg_aurora_420_rangeley_log.h" - -#define VALIDATE(_id) \ - do { \ - if(!ONLP_OID_IS_PSU(_id)) { \ - return ONLP_STATUS_E_INVALID; \ - } \ - } while(0) - -static onlp_psu_info_t psus__[] = { - { }, /* Not used */ - { - { - PSU_OID_PSU1, - "PSU-1", - 0, - { - FAN_OID_FAN9, - }, - } - }, - { - { - PSU_OID_PSU2, - "PSU-2", - 0, - { - FAN_OID_FAN10, - }, - } - }, -}; - -/* - * This function will be called prior to any other onlp_psui functions. - */ -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; - int pid; - uint8_t data[256]; - int value = -1; - int len; - double dvalue; - int i; - - VALIDATE(id); - - memset(info, 0, sizeof(onlp_psu_info_t)); - pid = ONLP_OID_ID_GET(id); - *info = psus__[pid]; - - rv = onlp_file_read_int(&value, SYS_HWMON1_PREFIX "/psu%d_abs", pid); - if (rv != ONLP_STATUS_OK) - return rv; - if (value == 0) - { - info->status = ONLP_PSU_STATUS_UNPLUGGED; - return ONLP_STATUS_OK; - } - - /* PSU is present. */ - info->status = ONLP_PSU_STATUS_PRESENT; - - memset(data, 0, sizeof(data)); - rv = onlp_file_read(data, sizeof(data), &len, SYS_HWMON2_PREFIX "/psu%d_eeprom", pid); - if (rv == ONLP_STATUS_OK) - { - i = 11; - - /* Manufacturer Name */ - len = (data[i]&0x0f); - i++; - i += len; - - /* Product Name */ - len = (data[i]&0x0f); - i++; - memcpy(info->model, (char *) &(data[i]), len); - i += len; - - /* Product part,model number */ - len = (data[i]&0x0f); - i++; - i += len; - - /* Product Version */ - len = (data[i]&0x0f); - i++; - i += len; - - /* Product Serial Number */ - len = (data[i]&0x0f); - i++; - memcpy(info->serial, (char *) &(data[i]), len); - } - else - { - strcpy(info->model, "Missing"); - strcpy(info->serial, "Missing"); - } - - info->caps |= ONLP_PSU_CAPS_AC; - -#if 0 - /* PSU is powered. */ - rv = onlp_file_read_int(&value, SYS_HWMON1_PREFIX "/psu%d_pg", pid); - if (rv != ONLP_STATUS_OK) - return rv; - if (value == 0) - { - info->status |= ONLP_PSU_STATUS_FAILED; - return ONLP_STATUS_OK; - } -#endif - - memset(data, 0, sizeof(data)); - rv = onlp_file_read(data, sizeof(data), &len, SYS_HWMON2_PREFIX "/psu%d_iout", pid); - if (rv == ONLP_STATUS_OK) - { - dvalue = atof((const char *)data); - if (dvalue > 0.0) - { - info->caps |= ONLP_PSU_CAPS_IOUT; - info->miout = (int)(dvalue * 1000); - } - } - - memset(data, 0, sizeof(data)); - rv = onlp_file_read(data, sizeof(data), &len, SYS_HWMON2_PREFIX "/psu%d_vout", pid); - if (rv == ONLP_STATUS_OK) - { - dvalue = atof((const char *)data); - if (dvalue > 0.0) - { - info->caps |= ONLP_PSU_CAPS_VOUT; - info->mvout = (int)(dvalue * 1000); - } - } - - memset(data, 0, sizeof(data)); - rv = onlp_file_read(data, sizeof(data), &len, SYS_HWMON2_PREFIX "/psu%d_pin", pid); - if (rv == ONLP_STATUS_OK) - { - dvalue = atof((const char *)data); - if (dvalue > 0.0) - { - info->caps |= ONLP_PSU_CAPS_PIN; - info->mpin = (int)(dvalue * 1000); - } - } - - memset(data, 0, sizeof(data)); - rv = onlp_file_read(data, sizeof(data), &len, SYS_HWMON2_PREFIX "/psu%d_pout", pid); - if (rv == ONLP_STATUS_OK) - { - dvalue = atof((const char *)data); - if (dvalue > 0.0) - { - info->caps |= ONLP_PSU_CAPS_POUT; - info->mpout = (int)(dvalue * 1000); - } - } - - return ONLP_STATUS_OK; -} - -/* - * This is an optional generic ioctl() interface. - * Its purpose is to allow future expansion and - * custom functionality that is not otherwise exposed - * in the standard interface. - * - * The semantics of this function are platform specific. - * This function is completely optional. - */ -int -onlp_psui_ioctl(onlp_oid_t pid, va_list vargs) -{ - return ONLP_STATUS_E_UNSUPPORTED; -} - diff --git a/packages/platforms/netberg/x86-64/aurora-420-rangeley/onlp/builds/x86_64_netberg_aurora_420_rangeley/module/src/sfpi.c b/packages/platforms/netberg/x86-64/aurora-420-rangeley/onlp/builds/x86_64_netberg_aurora_420_rangeley/module/src/sfpi.c deleted file mode 100755 index 5aaf37601..000000000 --- a/packages/platforms/netberg/x86-64/aurora-420-rangeley/onlp/builds/x86_64_netberg_aurora_420_rangeley/module/src/sfpi.c +++ /dev/null @@ -1,451 +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. - * - * - ************************************************************ - * - * SFPI Interface for the Aurora 420 Platform - * - ***********************************************************/ -#include -#include -#include -#include -#include -#include "x86_64_netberg_aurora_420_rangeley_int.h" -#include "x86_64_netberg_aurora_420_rangeley_log.h" - -#include -#include - -/* Model ID Definition */ -typedef enum -{ - HURACAN_WITH_BMC = 0x0, - HURACAN_WITHOUT_BMC, - CABRERAIII_WITH_BMC, - CABRERAIII_WITHOUT_BMC, - SESTO_WITH_BMC, - SESTO_WITHOUT_BMC, - NCIIX_WITH_BMC, - NCIIX_WITHOUT_BMC, - ASTERION_WITH_BMC, - ASTERION_WITHOUT_BMC, - HURACAN_A_WITH_BMC, - HURACAN_A_WITHOUT_BMC, - - MODEL_ID_LAST -} modelId_t; - -static int -onlp_board_model_id_get(void) -{ - static int board_model_id = MODEL_ID_LAST; - - if (board_model_id == MODEL_ID_LAST) - { - if (onlp_file_read_int(&board_model_id, SYS_HWMON1_PREFIX "/board_model_id") != ONLP_STATUS_OK) - return 0; - } - - return board_model_id; -} - -/* - * This function will be called prior to all other onlp_sfpi_* functions. - */ -int -onlp_sfpi_init(void) -{ - return ONLP_STATUS_OK; -} - -/* - * This function should populate the give bitmap with - * all valid, SFP-capable port numbers. - * - * Only port numbers in this bitmap will be queried by the the - * ONLP framework. - * - * No SFPI functions will be called with ports that are - * not in this bitmap. You can ignore all error checking - * on the incoming ports defined in this interface. - */ -int -onlp_sfpi_bitmap_get(onlp_sfp_bitmap_t* bmap) -{ - int p; - int total_port = 0; - int board_model_id = onlp_board_model_id_get(); - - switch (board_model_id) - { - case HURACAN_WITH_BMC: - case HURACAN_WITHOUT_BMC: - case HURACAN_A_WITH_BMC: - case HURACAN_A_WITHOUT_BMC: - total_port = 32; - break; - - case SESTO_WITH_BMC: - case SESTO_WITHOUT_BMC: - case NCIIX_WITH_BMC: - case NCIIX_WITHOUT_BMC: - total_port = 54; - break; - - case ASTERION_WITH_BMC: - case ASTERION_WITHOUT_BMC: - total_port = 64; - break; - - default: - break; - } - - AIM_BITMAP_CLR_ALL(bmap); - for(p = 0; p < total_port; p++) - AIM_BITMAP_SET(bmap, p); - - return ONLP_STATUS_OK; -} - -/* - * This function should return whether an SFP is inserted on the given - * port. - * - * Returns 1 if the SFP is present. - * Returns 0 if the SFP is not present. - * Returns ONLP_E_* if there was an error determining the status. - */ -int -onlp_sfpi_is_present(int port) -{ - int value = 0; - - onlp_file_read_int(&value, SYS_HWMON2_PREFIX "/port_%d_abs", (port+1)); - return value; -} - -int -onlp_sfpi_port_map(int port, int* rport) -{ - int board_model_id = onlp_board_model_id_get(); - - switch (board_model_id) - { - case HURACAN_WITH_BMC: - case HURACAN_WITHOUT_BMC: - case HURACAN_A_WITH_BMC: - case HURACAN_A_WITHOUT_BMC: - /* odd <=> even */ - if (port & 0x1) - *rport = (port - 1); - else - *rport = (port + 1); - break; - - default: - *rport = port; break; - } - - return ONLP_STATUS_OK; -} - -int -onlp_sfpi_presence_bitmap_get(onlp_sfp_bitmap_t* dst) -{ - return ONLP_STATUS_E_UNSUPPORTED; -} - -int -onlp_sfpi_rx_los_bitmap_get(onlp_sfp_bitmap_t* bmap) -{ - int p; - int total_port = 0; - int board_model_id = onlp_board_model_id_get(); - - switch (board_model_id) - { - case HURACAN_WITH_BMC: - case HURACAN_WITHOUT_BMC: - case HURACAN_A_WITH_BMC: - case HURACAN_A_WITHOUT_BMC: - total_port = 32; - break; - - case SESTO_WITH_BMC: - case SESTO_WITHOUT_BMC: - case NCIIX_WITH_BMC: - case NCIIX_WITHOUT_BMC: - total_port = 54; - break; - - case ASTERION_WITH_BMC: - case ASTERION_WITHOUT_BMC: - total_port = 64; - break; - - default: - break; - } - - AIM_BITMAP_CLR_ALL(bmap); - for(p = 0; p < total_port; p++) - AIM_BITMAP_SET(bmap, p); - - return ONLP_STATUS_OK; -} - -/* - * This function reads the SFPs idrom and returns in - * in the data buffer provided. - */ -int -onlp_sfpi_eeprom_read(int port, uint8_t data[256]) -{ - int rv = ONLP_STATUS_OK; - char fname[128]; - - memset(data, 0, 256); - memset(fname, 0, sizeof(fname)); - sprintf(fname, SYS_HWMON2_PREFIX "/port_%d_data_a0", (port+1)); - rv = onlplib_sfp_eeprom_read_file(fname, data); - if (rv != ONLP_STATUS_OK) - AIM_LOG_INFO("Unable to read eeprom from port(%d)\r\n", port); - - return rv; -} - -int -onlp_sfpi_dom_read(int port, uint8_t data[256]) -{ - int rv = ONLP_STATUS_OK; - char fname[128]; - - memset(data, 0, 256); - memset(fname, 0, sizeof(fname)); - sprintf(fname, SYS_HWMON2_PREFIX "/port_%d_data_a2", (port+1)); - rv = onlplib_sfp_eeprom_read_file(fname, data); - if (rv != ONLP_STATUS_OK) - AIM_LOG_INFO("Unable to read eeprom from port(%d)\r\n", port); - - return rv; -} - -/* - * Manually enable or disable the given SFP. - * - */ -int -onlp_sfpi_enable_set(int port, int enable) -{ - return ONLP_STATUS_E_UNSUPPORTED; -} - -/* - * Returns whether the SFP is currently enabled or disabled. - */ -int -onlp_sfpi_enable_get(int port, int* enable) -{ - return ONLP_STATUS_E_UNSUPPORTED; -} - -/* - * If the platform requires any setup or equalizer modifications - * based on the actual SFP that was inserted then that custom - * setup should be performed here. - * - * After a new SFP is detected by the ONLP framework this - * function will be called to perform the (optional) setup. - */ -int -onlp_sfpi_post_insert(int port, sff_info_t* sff_info) -{ - return ONLP_STATUS_E_UNSUPPORTED; -} - -/* - * Return the current status of the SFP. - * See onlp_sfp_status_t; - */ -int -onlp_sfpi_status_get(int port, uint32_t* status) -{ - return ONLP_STATUS_E_UNSUPPORTED; -} - -int onlp_sfpi_control_supported(int port, onlp_sfp_control_t control, int* supported) -{ - if (supported == NULL) - return ONLP_STATUS_E_PARAM; - - *supported = 0; - switch (control) - { - case ONLP_SFP_CONTROL_TX_DISABLE: - case ONLP_SFP_CONTROL_RX_LOS: - case ONLP_SFP_CONTROL_TX_FAULT: - { - int board_model_id = onlp_board_model_id_get(); - - switch (board_model_id) - { - case HURACAN_WITH_BMC: - case HURACAN_WITHOUT_BMC: - case HURACAN_A_WITH_BMC: - case HURACAN_A_WITHOUT_BMC: - case SESTO_WITH_BMC: - case SESTO_WITHOUT_BMC: - case NCIIX_WITH_BMC: - case NCIIX_WITHOUT_BMC: - case ASTERION_WITH_BMC: - case ASTERION_WITHOUT_BMC: - *supported = 1; - break; - - default: - break; - } - } - break; - - default: - break; - } - - return ONLP_STATUS_OK; -} - -int -onlp_sfpi_control_set(int port, onlp_sfp_control_t control, int value) -{ - int rv = ONLP_STATUS_OK; - int supported = 0; - - if ((onlp_sfpi_control_supported(port, control, &supported) == ONLP_STATUS_OK) && (supported == 0)) - return ONLP_STATUS_E_UNSUPPORTED; - - switch (control) - { - case ONLP_SFP_CONTROL_TX_DISABLE: - rv = onlp_file_write_int(value, SYS_HWMON2_PREFIX "/port_%d_tx_disable", (port+1)); - 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 = ONLP_STATUS_OK; - int supported = 0; - - if (value == NULL) - return ONLP_STATUS_E_PARAM; - - if ((onlp_sfpi_control_supported(port, control, &supported) == ONLP_STATUS_OK) && (supported == 0)) - return ONLP_STATUS_E_UNSUPPORTED; - - *value = 0; - switch (control) - { - case ONLP_SFP_CONTROL_RX_LOS: - rv = onlp_file_read_int(value, SYS_HWMON2_PREFIX "/port_%d_rxlos", (port+1)); - break; - - case ONLP_SFP_CONTROL_TX_DISABLE: - rv = onlp_file_read_int(value, SYS_HWMON2_PREFIX "/port_%d_tx_disable", (port+1)); - break; - - case ONLP_SFP_CONTROL_TX_FAULT: - rv = onlp_file_read_int(value, SYS_HWMON2_PREFIX "/port_%d_tx_fault", (port+1)); - break; - - default: - rv = ONLP_STATUS_E_UNSUPPORTED; - break; - } - return rv; -} - -int -onlp_sfpi_dev_readw(int port, uint8_t devaddr, uint8_t addr) -{ - int value = 0; - char fname[128]; - char data[512]; - - memset(data, 0, 512); - memset(fname, 0, sizeof(fname)); - sprintf(fname, SYS_HWMON2_PREFIX "/port_%d_sfp_copper", (port+1)); - - int fd = open(fname, O_RDONLY); - if (fd < 0) { - AIM_LOG_INFO("Unable to read devaddr(0xAC) from port(%d)\r\n", port); - return value; - } - - int nrd = read(fd, data, 512); - close(fd); - - if (nrd != 512) { - AIM_LOG_INTERNAL("Failed to read EEPROM file '%s'", fname); - return value; - } - - value = (((data[addr*2 + 1] & 0xff) << 8) | (data[addr*2] & 0xff)) & 0xffff; - - return value; -} - -int -onlp_sfpi_dev_writew(int port, uint8_t devaddr, uint8_t addr, uint16_t value) -{ - int rv = ONLP_STATUS_OK; - int data = 0; - - data = ((addr << 16) | (value & 0xffff)) & 0x00ffffff; - rv = onlp_file_write_int(data, SYS_HWMON2_PREFIX "/port_%d_sfp_copper", (port+1)); - - return rv; -} - -/* - * This is a generic ioctl interface. - */ -int -onlp_sfpi_ioctl(int port, va_list vargs) -{ - return ONLP_STATUS_E_UNSUPPORTED; -} - -/* - * De-initialize the SFPI subsystem. - */ -int -onlp_sfpi_denit(void) -{ - return ONLP_STATUS_OK; -} - diff --git a/packages/platforms/netberg/x86-64/aurora-420-rangeley/onlp/builds/x86_64_netberg_aurora_420_rangeley/module/src/sysi.c b/packages/platforms/netberg/x86-64/aurora-420-rangeley/onlp/builds/x86_64_netberg_aurora_420_rangeley/module/src/sysi.c deleted file mode 100755 index 7e044c3ba..000000000 --- a/packages/platforms/netberg/x86-64/aurora-420-rangeley/onlp/builds/x86_64_netberg_aurora_420_rangeley/module/src/sysi.c +++ /dev/null @@ -1,98 +0,0 @@ -/************************************************************ - * - * - ************************************************************ - * - * - * - ***********************************************************/ -#include -#include -#include "x86_64_netberg_aurora_420_rangeley_int.h" -#include "x86_64_netberg_aurora_420_rangeley_log.h" - -/* - * This is the first function called by the ONLP framework. - * - * It should return the name of your platform driver. - * - * If the name of your platform driver is the same as the - * current platform then this driver will be used. - * - * If the name of the driver is different from the current - * platform, or the driver is capable of supporting multiple - * platform variants, see onlp_sysi_platform_set() below. - */ -const char* -onlp_sysi_platform_get(void) -{ - return "x86-64-netberg-aurora-420-rangeley-r0"; -} - -/* - * This is the first function the ONLP framework will call - * after it has validated the the platform is supported using the mechanisms - * described above. - * - * If this function does not return ONL_STATUS_OK - * then platform initialization is aborted. - */ -int -onlp_sysi_init(void) -{ - return ONLP_STATUS_OK; -} - -int -onlp_sysi_onie_info_get(onlp_onie_info_t* onie) -{ - int rv; - uint8_t data[256]; - int len; - - memset(data, 0, sizeof(data)); - rv = onlp_file_read(data, sizeof(data), &len, SYS_HWMON2_PREFIX "/eeprom"); - if (rv == ONLP_STATUS_OK) - { - rv = onlp_onie_decode(onie, (uint8_t*)data, sizeof(data)); - if(rv >= 0) - { - onie->platform_name = aim_strdup("x86-64-netberg-aurora-420-rangeley-r0"); - } - } - 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)); - int i; - int n_thermal=7, n_fan=10, n_led=4; - - /* 2 PSUs */ - *e++ = ONLP_PSU_ID_CREATE(1); - *e++ = ONLP_PSU_ID_CREATE(2); - - /* LEDs Item */ - for (i=1; i<=n_led; i++) - { - *e++ = ONLP_LED_ID_CREATE(i); - } - - /* THERMALs Item */ - for (i=1; i<=n_thermal; i++) - { - *e++ = ONLP_THERMAL_ID_CREATE(i); - } - - /* Fans Item */ - for (i=1; i<=n_fan; i++) - { - *e++ = ONLP_FAN_ID_CREATE(i); - } - - return 0; -} - diff --git a/packages/platforms/netberg/x86-64/aurora-420-rangeley/onlp/builds/x86_64_netberg_aurora_420_rangeley/module/src/thermali.c b/packages/platforms/netberg/x86-64/aurora-420-rangeley/onlp/builds/x86_64_netberg_aurora_420_rangeley/module/src/thermali.c deleted file mode 100755 index e32410139..000000000 --- a/packages/platforms/netberg/x86-64/aurora-420-rangeley/onlp/builds/x86_64_netberg_aurora_420_rangeley/module/src/thermali.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 "x86_64_netberg_aurora_420_rangeley_int.h" -#include "x86_64_netberg_aurora_420_rangeley_log.h" - -#define VALIDATE(_id) \ - do { \ - if(!ONLP_OID_IS_THERMAL(_id)) { \ - return ONLP_STATUS_E_INVALID; \ - } \ - } while(0) - -static int -sys_thermal_info_get__(onlp_thermal_info_t* info, int id) -{ - int rv; - - if (id == THERMAL_ID_THERMAL3) - { - rv = onlp_file_read_int(&info->mcelsius, SYS_HWMON1_PREFIX "/mac_temp"); - info->mcelsius *= 1000; - } - else - { - uint8_t buffer[64]; - double dvalue; - int len; - - memset(buffer, 0, sizeof(buffer)); - rv = onlp_file_read(buffer, sizeof(buffer), &len, SYS_HWMON1_PREFIX "/remote_temp%d", id); - if (rv == ONLP_STATUS_OK) - { - dvalue = atof((const char *)buffer); - info->mcelsius = (int)(dvalue * 1000); - } - } - - if(rv == ONLP_STATUS_E_INTERNAL) - return rv; - - if(rv == ONLP_STATUS_E_MISSING) - { - info->status &= ~(ONLP_THERMAL_STATUS_PRESENT); - return ONLP_STATUS_OK; - } - - return ONLP_STATUS_OK; -} - -static int -psu1_thermal_info_get__(onlp_thermal_info_t* info, int id) -{ - int rv; - uint8_t buffer[64]; - double dvalue; - int len; - - memset(buffer, 0, sizeof(buffer)); - rv = onlp_file_read(buffer, sizeof(buffer), &len, SYS_HWMON2_PREFIX "/psu1_temp_%d", id); - if (rv == ONLP_STATUS_OK) - { - dvalue = atof((const char *)buffer); - info->mcelsius = (int)(dvalue * 1000); - } - return rv; -} - -static int -psu2_thermal_info_get__(onlp_thermal_info_t* info, int id) -{ - int rv; - uint8_t buffer[64]; - double dvalue; - int len; - - memset(buffer, 0, sizeof(buffer)); - rv = onlp_file_read(buffer, sizeof(buffer), &len, SYS_HWMON2_PREFIX "/psu2_temp_%d", id); - if (rv == ONLP_STATUS_OK) - { - dvalue = atof((const char *)buffer); - info->mcelsius = (int)(dvalue * 1000); - } - return rv; -} - -static onlp_thermal_info_t temps__[] = -{ - { }, /* Not used */ - { { THERMAL_OID_THERMAL1, "Chassis Thermal 1 (Front of MAC)", 0}, ONLP_THERMAL_STATUS_PRESENT, ONLP_THERMAL_CAPS_GET_TEMPERATURE, 0}, - { { THERMAL_OID_THERMAL2, "Chassis Thermal 2 (Rear of MAC)", 0}, ONLP_THERMAL_STATUS_PRESENT, ONLP_THERMAL_CAPS_GET_TEMPERATURE, 0}, - { { THERMAL_OID_THERMAL3, "Chassis Thermal 3 (MAC)", 0}, ONLP_THERMAL_STATUS_PRESENT, ONLP_THERMAL_CAPS_GET_TEMPERATURE, 0}, - - { { THERMAL_OID_THERMAL4, "PSU-1 Thermal 1", PSU_OID_PSU1 }, ONLP_THERMAL_STATUS_PRESENT, ONLP_THERMAL_CAPS_GET_TEMPERATURE, 0}, - { { THERMAL_OID_THERMAL5, "PSU-1 Thermal 2", PSU_OID_PSU1 }, ONLP_THERMAL_STATUS_PRESENT, ONLP_THERMAL_CAPS_GET_TEMPERATURE, 0}, - - { { THERMAL_OID_THERMAL6, "PSU-2 Thermal 1", PSU_OID_PSU2 }, ONLP_THERMAL_STATUS_PRESENT, ONLP_THERMAL_CAPS_GET_TEMPERATURE, 0}, - { { THERMAL_OID_THERMAL7, "PSU-2 Thermal 2", PSU_OID_PSU2 }, ONLP_THERMAL_STATUS_PRESENT, ONLP_THERMAL_CAPS_GET_TEMPERATURE, 0}, -}; - - -/* - * 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); - - memset(info, 0, sizeof(onlp_thermal_info_t)); - tid = ONLP_OID_ID_GET(id); - *info = temps__[tid]; - - switch(tid) - { - case THERMAL_ID_THERMAL1: - case THERMAL_ID_THERMAL2: - case THERMAL_ID_THERMAL3: - return sys_thermal_info_get__(info, tid); - - case THERMAL_ID_THERMAL4: - case THERMAL_ID_THERMAL5: - return psu1_thermal_info_get__(info, (tid - THERMAL_ID_THERMAL4 + 1)); - - case THERMAL_ID_THERMAL6: - case THERMAL_ID_THERMAL7: - return psu2_thermal_info_get__(info, (tid - THERMAL_ID_THERMAL6 + 1)); - } - - return ONLP_STATUS_E_INVALID; -} - diff --git a/packages/platforms/netberg/x86-64/aurora-420-rangeley/onlp/builds/x86_64_netberg_aurora_420_rangeley/module/src/x86_64_netberg_aurora_420_rangeley_config.c b/packages/platforms/netberg/x86-64/aurora-420-rangeley/onlp/builds/x86_64_netberg_aurora_420_rangeley/module/src/x86_64_netberg_aurora_420_rangeley_config.c deleted file mode 100755 index 94ef2e104..000000000 --- a/packages/platforms/netberg/x86-64/aurora-420-rangeley/onlp/builds/x86_64_netberg_aurora_420_rangeley/module/src/x86_64_netberg_aurora_420_rangeley_config.c +++ /dev/null @@ -1,80 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#include - -/* */ -#define __x86_64_netberg_aurora_420_rangeley_config_STRINGIFY_NAME(_x) #_x -#define __x86_64_netberg_aurora_420_rangeley_config_STRINGIFY_VALUE(_x) __x86_64_netberg_aurora_420_rangeley_config_STRINGIFY_NAME(_x) -x86_64_netberg_aurora_420_rangeley_config_settings_t x86_64_netberg_aurora_420_rangeley_config_settings[] = -{ -#ifdef X86_64_NETBERG_AURORA_420_RANGELEY_CONFIG_INCLUDE_LOGGING - { __x86_64_netberg_aurora_420_rangeley_config_STRINGIFY_NAME(X86_64_NETBERG_AURORA_420_RANGELEY_CONFIG_INCLUDE_LOGGING), __x86_64_netberg_aurora_420_rangeley_config_STRINGIFY_VALUE(X86_64_NETBERG_AURORA_420_RANGELEY_CONFIG_INCLUDE_LOGGING) }, -#else -{ X86_64_NETBERG_AURORA_420_RANGELEY_CONFIG_INCLUDE_LOGGING(__x86_64_netberg_aurora_420_rangeley_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_NETBERG_AURORA_420_RANGELEY_CONFIG_LOG_OPTIONS_DEFAULT - { __x86_64_netberg_aurora_420_rangeley_config_STRINGIFY_NAME(X86_64_NETBERG_AURORA_420_RANGELEY_CONFIG_LOG_OPTIONS_DEFAULT), __x86_64_netberg_aurora_420_rangeley_config_STRINGIFY_VALUE(X86_64_NETBERG_AURORA_420_RANGELEY_CONFIG_LOG_OPTIONS_DEFAULT) }, -#else -{ X86_64_NETBERG_AURORA_420_RANGELEY_CONFIG_LOG_OPTIONS_DEFAULT(__x86_64_netberg_aurora_420_rangeley_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_NETBERG_AURORA_420_RANGELEY_CONFIG_LOG_BITS_DEFAULT - { __x86_64_netberg_aurora_420_rangeley_config_STRINGIFY_NAME(X86_64_NETBERG_AURORA_420_RANGELEY_CONFIG_LOG_BITS_DEFAULT), __x86_64_netberg_aurora_420_rangeley_config_STRINGIFY_VALUE(X86_64_NETBERG_AURORA_420_RANGELEY_CONFIG_LOG_BITS_DEFAULT) }, -#else -{ X86_64_NETBERG_AURORA_420_RANGELEY_CONFIG_LOG_BITS_DEFAULT(__x86_64_netberg_aurora_420_rangeley_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_NETBERG_AURORA_420_RANGELEY_CONFIG_LOG_CUSTOM_BITS_DEFAULT - { __x86_64_netberg_aurora_420_rangeley_config_STRINGIFY_NAME(X86_64_NETBERG_AURORA_420_RANGELEY_CONFIG_LOG_CUSTOM_BITS_DEFAULT), __x86_64_netberg_aurora_420_rangeley_config_STRINGIFY_VALUE(X86_64_NETBERG_AURORA_420_RANGELEY_CONFIG_LOG_CUSTOM_BITS_DEFAULT) }, -#else -{ X86_64_NETBERG_AURORA_420_RANGELEY_CONFIG_LOG_CUSTOM_BITS_DEFAULT(__x86_64_netberg_aurora_420_rangeley_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_NETBERG_AURORA_420_RANGELEY_CONFIG_PORTING_STDLIB - { __x86_64_netberg_aurora_420_rangeley_config_STRINGIFY_NAME(X86_64_NETBERG_AURORA_420_RANGELEY_CONFIG_PORTING_STDLIB), __x86_64_netberg_aurora_420_rangeley_config_STRINGIFY_VALUE(X86_64_NETBERG_AURORA_420_RANGELEY_CONFIG_PORTING_STDLIB) }, -#else -{ X86_64_NETBERG_AURORA_420_RANGELEY_CONFIG_PORTING_STDLIB(__x86_64_netberg_aurora_420_rangeley_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_NETBERG_AURORA_420_RANGELEY_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS - { __x86_64_netberg_aurora_420_rangeley_config_STRINGIFY_NAME(X86_64_NETBERG_AURORA_420_RANGELEY_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS), __x86_64_netberg_aurora_420_rangeley_config_STRINGIFY_VALUE(X86_64_NETBERG_AURORA_420_RANGELEY_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS) }, -#else -{ X86_64_NETBERG_AURORA_420_RANGELEY_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS(__x86_64_netberg_aurora_420_rangeley_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_NETBERG_AURORA_420_RANGELEY_CONFIG_INCLUDE_UCLI - { __x86_64_netberg_aurora_420_rangeley_config_STRINGIFY_NAME(X86_64_NETBERG_AURORA_420_RANGELEY_CONFIG_INCLUDE_UCLI), __x86_64_netberg_aurora_420_rangeley_config_STRINGIFY_VALUE(X86_64_NETBERG_AURORA_420_RANGELEY_CONFIG_INCLUDE_UCLI) }, -#else -{ X86_64_NETBERG_AURORA_420_RANGELEY_CONFIG_INCLUDE_UCLI(__x86_64_netberg_aurora_420_rangeley_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_NETBERG_AURORA_420_RANGELEY_CONFIG_SYSFAN_RPM_FAILURE_THRESHOLD - { __x86_64_netberg_aurora_420_rangeley_config_STRINGIFY_NAME(X86_64_NETBERG_AURORA_420_RANGELEY_CONFIG_SYSFAN_RPM_FAILURE_THRESHOLD), __x86_64_netberg_aurora_420_rangeley_config_STRINGIFY_VALUE(X86_64_NETBERG_AURORA_420_RANGELEY_CONFIG_SYSFAN_RPM_FAILURE_THRESHOLD) }, -#else -{ X86_64_NETBERG_AURORA_420_RANGELEY_CONFIG_SYSFAN_RPM_FAILURE_THRESHOLD(__x86_64_netberg_aurora_420_rangeley_config_STRINGIFY_NAME), "__undefined__" }, -#endif - { NULL, NULL } -}; -#undef __x86_64_netberg_aurora_420_rangeley_config_STRINGIFY_VALUE -#undef __x86_64_netberg_aurora_420_rangeley_config_STRINGIFY_NAME - -const char* -x86_64_netberg_aurora_420_rangeley_config_lookup(const char* setting) -{ - int i; - for(i = 0; x86_64_netberg_aurora_420_rangeley_config_settings[i].name; i++) { - if(!strcmp(x86_64_netberg_aurora_420_rangeley_config_settings[i].name, setting)) { - return x86_64_netberg_aurora_420_rangeley_config_settings[i].value; - } - } - return NULL; -} - -int -x86_64_netberg_aurora_420_rangeley_config_show(struct aim_pvs_s* pvs) -{ - int i; - for(i = 0; x86_64_netberg_aurora_420_rangeley_config_settings[i].name; i++) { - aim_printf(pvs, "%s = %s\n", x86_64_netberg_aurora_420_rangeley_config_settings[i].name, x86_64_netberg_aurora_420_rangeley_config_settings[i].value); - } - return i; -} - -/* */ diff --git a/packages/platforms/netberg/x86-64/aurora-420-rangeley/onlp/builds/x86_64_netberg_aurora_420_rangeley/module/src/x86_64_netberg_aurora_420_rangeley_enums.c b/packages/platforms/netberg/x86-64/aurora-420-rangeley/onlp/builds/x86_64_netberg_aurora_420_rangeley/module/src/x86_64_netberg_aurora_420_rangeley_enums.c deleted file mode 100755 index 1df7f4cd0..000000000 --- a/packages/platforms/netberg/x86-64/aurora-420-rangeley/onlp/builds/x86_64_netberg_aurora_420_rangeley/module/src/x86_64_netberg_aurora_420_rangeley_enums.c +++ /dev/null @@ -1,10 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#include - -/* <--auto.start.enum(ALL).source> */ -/* */ - diff --git a/packages/platforms/netberg/x86-64/aurora-420-rangeley/onlp/builds/x86_64_netberg_aurora_420_rangeley/module/src/x86_64_netberg_aurora_420_rangeley_int.h b/packages/platforms/netberg/x86-64/aurora-420-rangeley/onlp/builds/x86_64_netberg_aurora_420_rangeley/module/src/x86_64_netberg_aurora_420_rangeley_int.h deleted file mode 100755 index 8e7fc4c87..000000000 --- a/packages/platforms/netberg/x86-64/aurora-420-rangeley/onlp/builds/x86_64_netberg_aurora_420_rangeley/module/src/x86_64_netberg_aurora_420_rangeley_int.h +++ /dev/null @@ -1,279 +0,0 @@ -/**************************************************************************//** - * - * x86_64_netberg_aurora_420_rangeley Internal Header - * - *****************************************************************************/ -#ifndef __X86_64_NETBERG_AURORA_420_RANGELEY_INT_H__ -#define __X86_64_NETBERG_AURORA_420_RANGELEY_INT_H__ - -#include -#include - -/* */ -/** 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[]; - -/** 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[]; - -/** led_id */ -typedef enum led_id_e { - LED_ID_STAT = 1, - LED_ID_FAN = 2, - LED_ID_PSU1 = 3, - LED_ID_PSU2 = 4, - LED_ID_LED1 = 5, - LED_ID_LED2 = 6, - LED_ID_LED3 = 7, - LED_ID_LED4 = 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_STAT = 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_LED1 = ONLP_LED_ID_CREATE(5), - LED_OID_LED2 = ONLP_LED_ID_CREATE(6), - LED_OID_LED3 = ONLP_LED_ID_CREATE(7), - LED_OID_LED4 = ONLP_LED_ID_CREATE(8), -} 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[]; - -/** 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 */ -struct psu_info_s { - char path[PATH_MAX]; - int present; - int busno; - int addr; -}; - -#define SYS_HWMON1_PREFIX "/sys/class/hwmon/hwmon1/device" -#define SYS_HWMON2_PREFIX "/sys/class/hwmon/hwmon2/device" - -#endif /* __X86_64_NETBERG_AURORA_420_RANGELEY_INT_H__ */ diff --git a/packages/platforms/netberg/x86-64/aurora-420-rangeley/onlp/builds/x86_64_netberg_aurora_420_rangeley/module/src/x86_64_netberg_aurora_420_rangeley_log.c b/packages/platforms/netberg/x86-64/aurora-420-rangeley/onlp/builds/x86_64_netberg_aurora_420_rangeley/module/src/x86_64_netberg_aurora_420_rangeley_log.c deleted file mode 100755 index c465bdecf..000000000 --- a/packages/platforms/netberg/x86-64/aurora-420-rangeley/onlp/builds/x86_64_netberg_aurora_420_rangeley/module/src/x86_64_netberg_aurora_420_rangeley_log.c +++ /dev/null @@ -1,18 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#include - -#include "x86_64_netberg_aurora_420_rangeley_log.h" -/* - * x86_64_netberg_aurora_420_rangeley log struct. - */ -AIM_LOG_STRUCT_DEFINE( - X86_64_NETBERG_AURORA_420_RANGELEY_CONFIG_LOG_OPTIONS_DEFAULT, - X86_64_NETBERG_AURORA_420_RANGELEY_CONFIG_LOG_BITS_DEFAULT, - NULL, /* Custom log map */ - X86_64_NETBERG_AURORA_420_RANGELEY_CONFIG_LOG_CUSTOM_BITS_DEFAULT - ); - diff --git a/packages/platforms/netberg/x86-64/aurora-420-rangeley/onlp/builds/x86_64_netberg_aurora_420_rangeley/module/src/x86_64_netberg_aurora_420_rangeley_log.h b/packages/platforms/netberg/x86-64/aurora-420-rangeley/onlp/builds/x86_64_netberg_aurora_420_rangeley/module/src/x86_64_netberg_aurora_420_rangeley_log.h deleted file mode 100755 index e3724e3f9..000000000 --- a/packages/platforms/netberg/x86-64/aurora-420-rangeley/onlp/builds/x86_64_netberg_aurora_420_rangeley/module/src/x86_64_netberg_aurora_420_rangeley_log.h +++ /dev/null @@ -1,12 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#ifndef __X86_64_NETBERG_AURORA_420_RANGELEY_LOG_H__ -#define __X86_64_NETBERG_AURORA_420_RANGELEY_LOG_H__ - -#define AIM_LOG_MODULE_NAME x86_64_netberg_aurora_420_rangeley -#include - -#endif /* __X86_64_NETBERG_AURORA_420_RANGELEY_LOG_H__ */ diff --git a/packages/platforms/netberg/x86-64/aurora-420-rangeley/onlp/builds/x86_64_netberg_aurora_420_rangeley/module/src/x86_64_netberg_aurora_420_rangeley_module.c b/packages/platforms/netberg/x86-64/aurora-420-rangeley/onlp/builds/x86_64_netberg_aurora_420_rangeley/module/src/x86_64_netberg_aurora_420_rangeley_module.c deleted file mode 100755 index 1924d1a60..000000000 --- a/packages/platforms/netberg/x86-64/aurora-420-rangeley/onlp/builds/x86_64_netberg_aurora_420_rangeley/module/src/x86_64_netberg_aurora_420_rangeley_module.c +++ /dev/null @@ -1,24 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#include - -#include "x86_64_netberg_aurora_420_rangeley_log.h" - -static int -datatypes_init__(void) -{ -#define X86_64_NETBERG_AURORA_420_RANGELEY_ENUMERATION_ENTRY(_enum_name, _desc) AIM_DATATYPE_MAP_REGISTER(_enum_name, _enum_name##_map, _desc, AIM_LOG_INTERNAL); -#include - return 0; -} - -void __x86_64_netberg_aurora_420_rangeley_module_init__(void) -{ - AIM_LOG_STRUCT_REGISTER(); - datatypes_init__(); -} - -int __onlp_platform_version__ = 1; diff --git a/packages/platforms/netberg/x86-64/aurora-420-rangeley/onlp/builds/x86_64_netberg_aurora_420_rangeley/module/src/x86_64_netberg_aurora_420_rangeley_ucli.c b/packages/platforms/netberg/x86-64/aurora-420-rangeley/onlp/builds/x86_64_netberg_aurora_420_rangeley/module/src/x86_64_netberg_aurora_420_rangeley_ucli.c deleted file mode 100755 index 5bfdc4cd7..000000000 --- a/packages/platforms/netberg/x86-64/aurora-420-rangeley/onlp/builds/x86_64_netberg_aurora_420_rangeley/module/src/x86_64_netberg_aurora_420_rangeley_ucli.c +++ /dev/null @@ -1,50 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#include - -#if X86_64_NETBERG_AURORA_420_RANGELEY_CONFIG_INCLUDE_UCLI == 1 - -#include -#include -#include - -static ucli_status_t -x86_64_netberg_aurora_420_rangeley_ucli_ucli__config__(ucli_context_t* uc) -{ - UCLI_HANDLER_MACRO_MODULE_CONFIG(x86_64_netberg_aurora_420_rangeley) -} - -/* */ -/* */ - -static ucli_module_t -x86_64_netberg_aurora_420_rangeley_ucli_module__ = - { - "x86_64_netberg_aurora_420_rangeley_ucli", - NULL, - x86_64_netberg_aurora_420_rangeley_ucli_ucli_handlers__, - NULL, - NULL, - }; - -ucli_node_t* -x86_64_netberg_aurora_420_rangeley_ucli_node_create(void) -{ - ucli_node_t* n; - ucli_module_init(&x86_64_netberg_aurora_420_rangeley_ucli_module__); - n = ucli_node_create("x86_64_netberg_aurora_420_rangeley", NULL, &x86_64_netberg_aurora_420_rangeley_ucli_module__); - ucli_node_subnode_add(n, ucli_module_log_node_create("x86_64_netberg_aurora_420_rangeley")); - return n; -} - -#else -void* -x86_64_netberg_aurora_420_rangeley_ucli_node_create(void) -{ - return NULL; -} -#endif - diff --git a/packages/platforms/netberg/x86-64/aurora-420-rangeley/platform-config/Makefile b/packages/platforms/netberg/x86-64/aurora-420-rangeley/platform-config/Makefile deleted file mode 100755 index 003238cf6..000000000 --- a/packages/platforms/netberg/x86-64/aurora-420-rangeley/platform-config/Makefile +++ /dev/null @@ -1 +0,0 @@ -include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/netberg/x86-64/aurora-420-rangeley/platform-config/r0/Makefile b/packages/platforms/netberg/x86-64/aurora-420-rangeley/platform-config/r0/Makefile deleted file mode 100755 index 003238cf6..000000000 --- a/packages/platforms/netberg/x86-64/aurora-420-rangeley/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/netberg/x86-64/aurora-420-rangeley/platform-config/r0/PKG.yml b/packages/platforms/netberg/x86-64/aurora-420-rangeley/platform-config/r0/PKG.yml deleted file mode 100755 index ad4b02d56..000000000 --- a/packages/platforms/netberg/x86-64/aurora-420-rangeley/platform-config/r0/PKG.yml +++ /dev/null @@ -1 +0,0 @@ -!include $ONL_TEMPLATES/platform-config-platform.yml ARCH=amd64 VENDOR=netberg BASENAME=x86-64-netberg-aurora-420-rangeley REVISION=r0 diff --git a/packages/platforms/netberg/x86-64/aurora-420-rangeley/platform-config/r0/src/lib/x86-64-netberg-aurora-420-rangeley-r0.yml b/packages/platforms/netberg/x86-64/aurora-420-rangeley/platform-config/r0/src/lib/x86-64-netberg-aurora-420-rangeley-r0.yml deleted file mode 100755 index ad855b37d..000000000 --- a/packages/platforms/netberg/x86-64/aurora-420-rangeley/platform-config/r0/src/lib/x86-64-netberg-aurora-420-rangeley-r0.yml +++ /dev/null @@ -1,30 +0,0 @@ ---- - -###################################################################### -# -# platform-config for AURORA 420 -# -###################################################################### - -x86-64-netberg-aurora-420-rangeley-r0: - - grub: - - serial: >- - --port=0x2f8 - --speed=115200 - --word=8 - --parity=no - --stop=1 - - kernel: - <<: *kernel-3-16 - - args: >- - console=ttyS1,115200n8 - - ##network: - ## interfaces: - ## ma1: - ## name: ~ - ## syspath: pci0000:00/0000:00:14.0 diff --git a/packages/platforms/netberg/x86-64/aurora-420-rangeley/platform-config/r0/src/python/x86_64_netberg_aurora_420_rangeley_r0/__init__.py b/packages/platforms/netberg/x86-64/aurora-420-rangeley/platform-config/r0/src/python/x86_64_netberg_aurora_420_rangeley_r0/__init__.py deleted file mode 100644 index 94949cd70..000000000 --- a/packages/platforms/netberg/x86-64/aurora-420-rangeley/platform-config/r0/src/python/x86_64_netberg_aurora_420_rangeley_r0/__init__.py +++ /dev/null @@ -1,12 +0,0 @@ -from onl.platform.base import * -from onl.platform.netberg import * - -class OnlPlatform_x86_64_netberg_aurora_420_rangeley_r0(OnlPlatformNetberg, - OnlPlatformPortConfig_48x10_6x40): - PLATFORM='x86-64-netberg-aurora-420-rangeley-r0' - MODEL="AURORA420" - SYS_OBJECT_ID=".420.1" - - def baseconfig(self): - self.insmod("hardware_monitor") - return True diff --git a/packages/platforms/netberg/x86-64/aurora-620-rangeley/.gitignore b/packages/platforms/netberg/x86-64/aurora-620-rangeley/.gitignore deleted file mode 100755 index b0bf46e18..000000000 --- a/packages/platforms/netberg/x86-64/aurora-620-rangeley/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -*x86*64*netberg*aurora*620*rangeley*.mk -onlpdump.mk diff --git a/packages/platforms/netberg/x86-64/aurora-620-rangeley/Makefile b/packages/platforms/netberg/x86-64/aurora-620-rangeley/Makefile deleted file mode 100755 index 003238cf6..000000000 --- a/packages/platforms/netberg/x86-64/aurora-620-rangeley/Makefile +++ /dev/null @@ -1 +0,0 @@ -include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/netberg/x86-64/aurora-620-rangeley/modules/Makefile b/packages/platforms/netberg/x86-64/aurora-620-rangeley/modules/Makefile deleted file mode 100755 index 003238cf6..000000000 --- a/packages/platforms/netberg/x86-64/aurora-620-rangeley/modules/Makefile +++ /dev/null @@ -1 +0,0 @@ -include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/netberg/x86-64/aurora-620-rangeley/modules/PKG.yml b/packages/platforms/netberg/x86-64/aurora-620-rangeley/modules/PKG.yml deleted file mode 100755 index ef81caea2..000000000 --- a/packages/platforms/netberg/x86-64/aurora-620-rangeley/modules/PKG.yml +++ /dev/null @@ -1 +0,0 @@ -!include $ONL_TEMPLATES/no-platform-modules.yml ARCH=amd64 VENDOR=netberg BASENAME=x86-64-netberg-aurora-620-rangeley diff --git a/packages/platforms/netberg/x86-64/aurora-620-rangeley/onlp/Makefile b/packages/platforms/netberg/x86-64/aurora-620-rangeley/onlp/Makefile deleted file mode 100755 index 003238cf6..000000000 --- a/packages/platforms/netberg/x86-64/aurora-620-rangeley/onlp/Makefile +++ /dev/null @@ -1 +0,0 @@ -include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/netberg/x86-64/aurora-620-rangeley/onlp/PKG.yml b/packages/platforms/netberg/x86-64/aurora-620-rangeley/onlp/PKG.yml deleted file mode 100755 index 3628e8331..000000000 --- a/packages/platforms/netberg/x86-64/aurora-620-rangeley/onlp/PKG.yml +++ /dev/null @@ -1 +0,0 @@ -!include $ONL_TEMPLATES/onlp-platform-any.yml PLATFORM=x86-64-netberg-aurora-620-rangeley ARCH=amd64 TOOLCHAIN=x86_64-linux-gnu diff --git a/packages/platforms/netberg/x86-64/aurora-620-rangeley/onlp/builds/Makefile b/packages/platforms/netberg/x86-64/aurora-620-rangeley/onlp/builds/Makefile deleted file mode 100755 index e7437cb23..000000000 --- a/packages/platforms/netberg/x86-64/aurora-620-rangeley/onlp/builds/Makefile +++ /dev/null @@ -1,2 +0,0 @@ -FILTER=src -include $(ONL)/make/subdirs.mk diff --git a/packages/platforms/netberg/x86-64/aurora-620-rangeley/onlp/builds/lib/Makefile b/packages/platforms/netberg/x86-64/aurora-620-rangeley/onlp/builds/lib/Makefile deleted file mode 100755 index f99f8f405..000000000 --- a/packages/platforms/netberg/x86-64/aurora-620-rangeley/onlp/builds/lib/Makefile +++ /dev/null @@ -1,2 +0,0 @@ -PLATFORM := x86-64-netberg-aurora-620-rangeley -include $(ONL)/packages/base/any/onlp/builds/platform/libonlp-platform.mk diff --git a/packages/platforms/netberg/x86-64/aurora-620-rangeley/onlp/builds/onlpdump/Makefile b/packages/platforms/netberg/x86-64/aurora-620-rangeley/onlp/builds/onlpdump/Makefile deleted file mode 100755 index 6b26c655e..000000000 --- a/packages/platforms/netberg/x86-64/aurora-620-rangeley/onlp/builds/onlpdump/Makefile +++ /dev/null @@ -1,2 +0,0 @@ -PLATFORM := x86-64-netberg-aurora-620-rangeley -include $(ONL)/packages/base/any/onlp/builds/platform/onlps.mk diff --git a/packages/platforms/netberg/x86-64/aurora-620-rangeley/onlp/builds/x86_64_netberg_aurora_620_rangeley/.gitignore b/packages/platforms/netberg/x86-64/aurora-620-rangeley/onlp/builds/x86_64_netberg_aurora_620_rangeley/.gitignore deleted file mode 100644 index c81d16be3..000000000 --- a/packages/platforms/netberg/x86-64/aurora-620-rangeley/onlp/builds/x86_64_netberg_aurora_620_rangeley/.gitignore +++ /dev/null @@ -1 +0,0 @@ -*.mk diff --git a/packages/platforms/netberg/x86-64/aurora-620-rangeley/onlp/builds/x86_64_netberg_aurora_620_rangeley/.module b/packages/platforms/netberg/x86-64/aurora-620-rangeley/onlp/builds/x86_64_netberg_aurora_620_rangeley/.module deleted file mode 100755 index 6f21c84ee..000000000 --- a/packages/platforms/netberg/x86-64/aurora-620-rangeley/onlp/builds/x86_64_netberg_aurora_620_rangeley/.module +++ /dev/null @@ -1 +0,0 @@ -name: x86_64_netberg_aurora_620_rangeley diff --git a/packages/platforms/netberg/x86-64/aurora-620-rangeley/onlp/builds/x86_64_netberg_aurora_620_rangeley/Makefile b/packages/platforms/netberg/x86-64/aurora-620-rangeley/onlp/builds/x86_64_netberg_aurora_620_rangeley/Makefile deleted file mode 100755 index f52d73286..000000000 --- a/packages/platforms/netberg/x86-64/aurora-620-rangeley/onlp/builds/x86_64_netberg_aurora_620_rangeley/Makefile +++ /dev/null @@ -1,9 +0,0 @@ -############################################################################### -# -# -# -############################################################################### -include $(ONL)/make/config.mk -MODULE := x86_64_netberg_aurora_620_rangeley -AUTOMODULE := x86_64_netberg_aurora_620_rangeley -include $(BUILDER)/definemodule.mk diff --git a/packages/platforms/netberg/x86-64/aurora-620-rangeley/onlp/builds/x86_64_netberg_aurora_620_rangeley/module/auto/make.mk b/packages/platforms/netberg/x86-64/aurora-620-rangeley/onlp/builds/x86_64_netberg_aurora_620_rangeley/module/auto/make.mk deleted file mode 100755 index 55fb2fb8b..000000000 --- a/packages/platforms/netberg/x86-64/aurora-620-rangeley/onlp/builds/x86_64_netberg_aurora_620_rangeley/module/auto/make.mk +++ /dev/null @@ -1,9 +0,0 @@ -############################################################################### -# -# x86_64_netberg_aurora_620_rangeley Autogeneration -# -############################################################################### -x86_64_netberg_aurora_620_rangeley_AUTO_DEFS := module/auto/x86_64_netberg_aurora_620_rangeley.yml -x86_64_netberg_aurora_620_rangeley_AUTO_DIRS := module/inc/x86_64_netberg_aurora_620_rangeley module/src -include $(BUILDER)/auto.mk - diff --git a/packages/platforms/netberg/x86-64/aurora-620-rangeley/onlp/builds/x86_64_netberg_aurora_620_rangeley/module/auto/x86_64_netberg_aurora_620_rangeley.yml b/packages/platforms/netberg/x86-64/aurora-620-rangeley/onlp/builds/x86_64_netberg_aurora_620_rangeley/module/auto/x86_64_netberg_aurora_620_rangeley.yml deleted file mode 100755 index 08600119b..000000000 --- a/packages/platforms/netberg/x86-64/aurora-620-rangeley/onlp/builds/x86_64_netberg_aurora_620_rangeley/module/auto/x86_64_netberg_aurora_620_rangeley.yml +++ /dev/null @@ -1,114 +0,0 @@ -############################################################################### -# -# x86_64_netberg_aurora_620_rangeley Autogeneration Definitions. -# -############################################################################### - -cdefs: &cdefs -- X86_64_NETBERG_AURORA_620_RANGELEY_CONFIG_INCLUDE_LOGGING: - doc: "Include or exclude logging." - default: 1 -- X86_64_NETBERG_AURORA_620_RANGELEY_CONFIG_LOG_OPTIONS_DEFAULT: - doc: "Default enabled log options." - default: AIM_LOG_OPTIONS_DEFAULT -- X86_64_NETBERG_AURORA_620_RANGELEY_CONFIG_LOG_BITS_DEFAULT: - doc: "Default enabled log bits." - default: AIM_LOG_BITS_DEFAULT -- X86_64_NETBERG_AURORA_620_RANGELEY_CONFIG_LOG_CUSTOM_BITS_DEFAULT: - doc: "Default enabled custom log bits." - default: 0 -- X86_64_NETBERG_AURORA_620_RANGELEY_CONFIG_PORTING_STDLIB: - doc: "Default all porting macros to use the C standard libraries." - default: 1 -- X86_64_NETBERG_AURORA_620_RANGELEY_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS: - doc: "Include standard library headers for stdlib porting macros." - default: X86_64_NETBERG_AURORA_620_RANGELEY_CONFIG_PORTING_STDLIB -- X86_64_NETBERG_AURORA_620_RANGELEY_CONFIG_INCLUDE_UCLI: - doc: "Include generic uCli support." - default: 0 -- X86_64_NETBERG_AURORA_620_RANGELEY_CONFIG_SYSFAN_RPM_FAILURE_THRESHOLD: - doc: "RPM Threshold at which the fan is considered to have failed." - default: 3000 - -definitions: - cdefs: - X86_64_NETBERG_AURORA_620_RANGELEY_CONFIG_HEADER: - defs: *cdefs - basename: x86_64_netberg_aurora_620_rangeley_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 - - 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) - - led_id: - members: - - LED1 : 1 - - led_oid: - members: - - LED1 : ONLP_LED_ID_CREATE(1) - - - portingmacro: - X86_64_NETBERG_AURORA_620_RANGELEY: - macros: - - memset - - memcpy - - - vsnprintf - - snprintf - - strlen diff --git a/packages/platforms/netberg/x86-64/aurora-620-rangeley/onlp/builds/x86_64_netberg_aurora_620_rangeley/module/inc/x86_64_netberg_aurora_620_rangeley/x86_64_netberg_aurora_620_rangeley.x b/packages/platforms/netberg/x86-64/aurora-620-rangeley/onlp/builds/x86_64_netberg_aurora_620_rangeley/module/inc/x86_64_netberg_aurora_620_rangeley/x86_64_netberg_aurora_620_rangeley.x deleted file mode 100755 index c8ee3e74e..000000000 --- a/packages/platforms/netberg/x86-64/aurora-620-rangeley/onlp/builds/x86_64_netberg_aurora_620_rangeley/module/inc/x86_64_netberg_aurora_620_rangeley/x86_64_netberg_aurora_620_rangeley.x +++ /dev/null @@ -1,14 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#include - -/* <--auto.start.xmacro(ALL).define> */ -/* */ - -/* <--auto.start.xenum(ALL).define> */ -/* */ - - diff --git a/packages/platforms/netberg/x86-64/aurora-620-rangeley/onlp/builds/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/aurora-620-rangeley/onlp/builds/x86_64_netberg_aurora_620_rangeley/module/inc/x86_64_netberg_aurora_620_rangeley/x86_64_netberg_aurora_620_rangeley_config.h deleted file mode 100755 index 0405ba895..000000000 --- a/packages/platforms/netberg/x86-64/aurora-620-rangeley/onlp/builds/x86_64_netberg_aurora_620_rangeley/module/inc/x86_64_netberg_aurora_620_rangeley/x86_64_netberg_aurora_620_rangeley_config.h +++ /dev/null @@ -1,137 +0,0 @@ -/**************************************************************************//** - * - * @file - * @brief x86_64_netberg_aurora_620_rangeley Configuration Header - * - * @addtogroup x86_64_netberg_aurora_620_rangeley-config - * @{ - * - *****************************************************************************/ -#ifndef __X86_64_NETBERG_AURORA_620_RANGELEY_CONFIG_H__ -#define __X86_64_NETBERG_AURORA_620_RANGELEY_CONFIG_H__ - -#ifdef GLOBAL_INCLUDE_CUSTOM_CONFIG -#include -#endif -#ifdef X86_64_NETBERG_AURORA_620_RANGELEY_INCLUDE_CUSTOM_CONFIG -#include -#endif - -/* */ -#include -/** - * X86_64_NETBERG_AURORA_620_RANGELEY_CONFIG_INCLUDE_LOGGING - * - * Include or exclude logging. */ - - -#ifndef X86_64_NETBERG_AURORA_620_RANGELEY_CONFIG_INCLUDE_LOGGING -#define X86_64_NETBERG_AURORA_620_RANGELEY_CONFIG_INCLUDE_LOGGING 1 -#endif - -/** - * X86_64_NETBERG_AURORA_620_RANGELEY_CONFIG_LOG_OPTIONS_DEFAULT - * - * Default enabled log options. */ - - -#ifndef X86_64_NETBERG_AURORA_620_RANGELEY_CONFIG_LOG_OPTIONS_DEFAULT -#define X86_64_NETBERG_AURORA_620_RANGELEY_CONFIG_LOG_OPTIONS_DEFAULT AIM_LOG_OPTIONS_DEFAULT -#endif - -/** - * X86_64_NETBERG_AURORA_620_RANGELEY_CONFIG_LOG_BITS_DEFAULT - * - * Default enabled log bits. */ - - -#ifndef X86_64_NETBERG_AURORA_620_RANGELEY_CONFIG_LOG_BITS_DEFAULT -#define X86_64_NETBERG_AURORA_620_RANGELEY_CONFIG_LOG_BITS_DEFAULT AIM_LOG_BITS_DEFAULT -#endif - -/** - * X86_64_NETBERG_AURORA_620_RANGELEY_CONFIG_LOG_CUSTOM_BITS_DEFAULT - * - * Default enabled custom log bits. */ - - -#ifndef X86_64_NETBERG_AURORA_620_RANGELEY_CONFIG_LOG_CUSTOM_BITS_DEFAULT -#define X86_64_NETBERG_AURORA_620_RANGELEY_CONFIG_LOG_CUSTOM_BITS_DEFAULT 0 -#endif - -/** - * X86_64_NETBERG_AURORA_620_RANGELEY_CONFIG_PORTING_STDLIB - * - * Default all porting macros to use the C standard libraries. */ - - -#ifndef X86_64_NETBERG_AURORA_620_RANGELEY_CONFIG_PORTING_STDLIB -#define X86_64_NETBERG_AURORA_620_RANGELEY_CONFIG_PORTING_STDLIB 1 -#endif - -/** - * X86_64_NETBERG_AURORA_620_RANGELEY_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS - * - * Include standard library headers for stdlib porting macros. */ - - -#ifndef X86_64_NETBERG_AURORA_620_RANGELEY_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS -#define X86_64_NETBERG_AURORA_620_RANGELEY_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS X86_64_NETBERG_AURORA_620_RANGELEY_CONFIG_PORTING_STDLIB -#endif - -/** - * X86_64_NETBERG_AURORA_620_RANGELEY_CONFIG_INCLUDE_UCLI - * - * Include generic uCli support. */ - - -#ifndef X86_64_NETBERG_AURORA_620_RANGELEY_CONFIG_INCLUDE_UCLI -#define X86_64_NETBERG_AURORA_620_RANGELEY_CONFIG_INCLUDE_UCLI 0 -#endif - -/** - * X86_64_NETBERG_AURORA_620_RANGELEY_CONFIG_SYSFAN_RPM_FAILURE_THRESHOLD - * - * RPM Threshold at which the fan is considered to have failed. */ - - -#ifndef X86_64_NETBERG_AURORA_620_RANGELEY_CONFIG_SYSFAN_RPM_FAILURE_THRESHOLD -#define X86_64_NETBERG_AURORA_620_RANGELEY_CONFIG_SYSFAN_RPM_FAILURE_THRESHOLD 3000 -#endif - - - -/** - * All compile time options can be queried or displayed - */ - -/** Configuration settings structure. */ -typedef struct x86_64_netberg_aurora_620_rangeley_config_settings_s { - /** name */ - const char* name; - /** value */ - const char* value; -} x86_64_netberg_aurora_620_rangeley_config_settings_t; - -/** Configuration settings table. */ -/** x86_64_netberg_aurora_620_rangeley_config_settings table. */ -extern x86_64_netberg_aurora_620_rangeley_config_settings_t x86_64_netberg_aurora_620_rangeley_config_settings[]; - -/** - * @brief Lookup a configuration setting. - * @param setting The name of the configuration option to lookup. - */ -const char* x86_64_netberg_aurora_620_rangeley_config_lookup(const char* setting); - -/** - * @brief Show the compile-time configuration. - * @param pvs The output stream. - */ -int x86_64_netberg_aurora_620_rangeley_config_show(struct aim_pvs_s* pvs); - -/* */ - -#include "x86_64_netberg_aurora_620_rangeley_porting.h" - -#endif /* __X86_64_NETBERG_AURORA_620_RANGELEY_CONFIG_H__ */ -/* @} */ diff --git a/packages/platforms/netberg/x86-64/aurora-620-rangeley/onlp/builds/x86_64_netberg_aurora_620_rangeley/module/inc/x86_64_netberg_aurora_620_rangeley/x86_64_netberg_aurora_620_rangeley_dox.h b/packages/platforms/netberg/x86-64/aurora-620-rangeley/onlp/builds/x86_64_netberg_aurora_620_rangeley/module/inc/x86_64_netberg_aurora_620_rangeley/x86_64_netberg_aurora_620_rangeley_dox.h deleted file mode 100755 index 9f1e463af..000000000 --- a/packages/platforms/netberg/x86-64/aurora-620-rangeley/onlp/builds/x86_64_netberg_aurora_620_rangeley/module/inc/x86_64_netberg_aurora_620_rangeley/x86_64_netberg_aurora_620_rangeley_dox.h +++ /dev/null @@ -1,26 +0,0 @@ -/**************************************************************************//** - * - * x86_64_netberg_aurora_620_rangeley Doxygen Header - * - *****************************************************************************/ -#ifndef __X86_64_NETBERG_AURORA_620_RANGELEY_DOX_H__ -#define __X86_64_NETBERG_AURORA_620_RANGELEY_DOX_H__ - -/** - * @defgroup x86_64_netberg_aurora_620_rangeley x86_64_netberg_aurora_620_rangeley - x86_64_netberg_aurora_620_rangeley Description - * - -The documentation overview for this module should go here. - - * - * @{ - * - * @defgroup x86_64_netberg_aurora_620_rangeley-x86_64_netberg_aurora_620_rangeley Public Interface - * @defgroup x86_64_netberg_aurora_620_rangeley-config Compile Time Configuration - * @defgroup x86_64_netberg_aurora_620_rangeley-porting Porting Macros - * - * @} - * - */ - -#endif /* __X86_64_NETBERG_AURORA_620_RANGELEY_DOX_H__ */ diff --git a/packages/platforms/netberg/x86-64/aurora-620-rangeley/onlp/builds/x86_64_netberg_aurora_620_rangeley/module/inc/x86_64_netberg_aurora_620_rangeley/x86_64_netberg_aurora_620_rangeley_porting.h b/packages/platforms/netberg/x86-64/aurora-620-rangeley/onlp/builds/x86_64_netberg_aurora_620_rangeley/module/inc/x86_64_netberg_aurora_620_rangeley/x86_64_netberg_aurora_620_rangeley_porting.h deleted file mode 100755 index 5a8f89d86..000000000 --- a/packages/platforms/netberg/x86-64/aurora-620-rangeley/onlp/builds/x86_64_netberg_aurora_620_rangeley/module/inc/x86_64_netberg_aurora_620_rangeley/x86_64_netberg_aurora_620_rangeley_porting.h +++ /dev/null @@ -1,77 +0,0 @@ -/**************************************************************************//** - * - * @file - * @brief x86_64_netberg_aurora_620_rangeley Porting Macros. - * - * @addtogroup x86_64_netberg_aurora_620_rangeley-porting - * @{ - * - *****************************************************************************/ -#ifndef __X86_64_NETBERG_AURORA_620_RANGELEY_PORTING_H__ -#define __X86_64_NETBERG_AURORA_620_RANGELEY_PORTING_H__ - - -/* */ -#if X86_64_NETBERG_AURORA_620_RANGELEY_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS == 1 -#include -#include -#include -#include -#include -#endif - -#ifndef X86_64_NETBERG_AURORA_620_RANGELEY_MEMSET - #if defined(GLOBAL_MEMSET) - #define X86_64_NETBERG_AURORA_620_RANGELEY_MEMSET GLOBAL_MEMSET - #elif X86_64_NETBERG_AURORA_620_RANGELEY_CONFIG_PORTING_STDLIB == 1 - #define X86_64_NETBERG_AURORA_620_RANGELEY_MEMSET memset - #else - #error The macro X86_64_NETBERG_AURORA_620_RANGELEY_MEMSET is required but cannot be defined. - #endif -#endif - -#ifndef X86_64_NETBERG_AURORA_620_RANGELEY_MEMCPY - #if defined(GLOBAL_MEMCPY) - #define X86_64_NETBERG_AURORA_620_RANGELEY_MEMCPY GLOBAL_MEMCPY - #elif X86_64_NETBERG_AURORA_620_RANGELEY_CONFIG_PORTING_STDLIB == 1 - #define X86_64_NETBERG_AURORA_620_RANGELEY_MEMCPY memcpy - #else - #error The macro X86_64_NETBERG_AURORA_620_RANGELEY_MEMCPY is required but cannot be defined. - #endif -#endif - -#ifndef X86_64_NETBERG_AURORA_620_RANGELEY_VSNPRINTF - #if defined(GLOBAL_VSNPRINTF) - #define X86_64_NETBERG_AURORA_620_RANGELEY_VSNPRINTF GLOBAL_VSNPRINTF - #elif X86_64_NETBERG_AURORA_620_RANGELEY_CONFIG_PORTING_STDLIB == 1 - #define X86_64_NETBERG_AURORA_620_RANGELEY_VSNPRINTF vsnprintf - #else - #error The macro X86_64_NETBERG_AURORA_620_RANGELEY_VSNPRINTF is required but cannot be defined. - #endif -#endif - -#ifndef X86_64_NETBERG_AURORA_620_RANGELEY_SNPRINTF - #if defined(GLOBAL_SNPRINTF) - #define X86_64_NETBERG_AURORA_620_RANGELEY_SNPRINTF GLOBAL_SNPRINTF - #elif X86_64_NETBERG_AURORA_620_RANGELEY_CONFIG_PORTING_STDLIB == 1 - #define X86_64_NETBERG_AURORA_620_RANGELEY_SNPRINTF snprintf - #else - #error The macro X86_64_NETBERG_AURORA_620_RANGELEY_SNPRINTF is required but cannot be defined. - #endif -#endif - -#ifndef X86_64_NETBERG_AURORA_620_RANGELEY_STRLEN - #if defined(GLOBAL_STRLEN) - #define X86_64_NETBERG_AURORA_620_RANGELEY_STRLEN GLOBAL_STRLEN - #elif X86_64_NETBERG_AURORA_620_RANGELEY_CONFIG_PORTING_STDLIB == 1 - #define X86_64_NETBERG_AURORA_620_RANGELEY_STRLEN strlen - #else - #error The macro X86_64_NETBERG_AURORA_620_RANGELEY_STRLEN is required but cannot be defined. - #endif -#endif - -/* */ - - -#endif /* __X86_64_NETBERG_AURORA_620_RANGELEY_PORTING_H__ */ -/* @} */ diff --git a/packages/platforms/netberg/x86-64/aurora-620-rangeley/onlp/builds/x86_64_netberg_aurora_620_rangeley/module/make.mk b/packages/platforms/netberg/x86-64/aurora-620-rangeley/onlp/builds/x86_64_netberg_aurora_620_rangeley/module/make.mk deleted file mode 100755 index c8bda1952..000000000 --- a/packages/platforms/netberg/x86-64/aurora-620-rangeley/onlp/builds/x86_64_netberg_aurora_620_rangeley/module/make.mk +++ /dev/null @@ -1,10 +0,0 @@ -############################################################################### -# -# -# -############################################################################### -THIS_DIR := $(dir $(lastword $(MAKEFILE_LIST))) -x86_64_netberg_aurora_620_rangeley_INCLUDES := -I $(THIS_DIR)inc -x86_64_netberg_aurora_620_rangeley_INTERNAL_INCLUDES := -I $(THIS_DIR)src -x86_64_netberg_aurora_620_rangeley_DEPENDMODULE_ENTRIES := init:x86_64_netberg_aurora_620_rangeley ucli:x86_64_netberg_aurora_620_rangeley - diff --git a/packages/platforms/netberg/x86-64/aurora-620-rangeley/onlp/builds/x86_64_netberg_aurora_620_rangeley/module/src/Makefile b/packages/platforms/netberg/x86-64/aurora-620-rangeley/onlp/builds/x86_64_netberg_aurora_620_rangeley/module/src/Makefile deleted file mode 100755 index 20b8893c8..000000000 --- a/packages/platforms/netberg/x86-64/aurora-620-rangeley/onlp/builds/x86_64_netberg_aurora_620_rangeley/module/src/Makefile +++ /dev/null @@ -1,9 +0,0 @@ -############################################################################### -# -# Local source generation targets. -# -############################################################################### - -ucli: - @../../../../tools/uclihandlers.py x86_64_netberg_aurora_620_rangeley_ucli.c - diff --git a/packages/platforms/netberg/x86-64/aurora-620-rangeley/onlp/builds/x86_64_netberg_aurora_620_rangeley/module/src/fani.c b/packages/platforms/netberg/x86-64/aurora-620-rangeley/onlp/builds/x86_64_netberg_aurora_620_rangeley/module/src/fani.c deleted file mode 100755 index 0994f3fee..000000000 --- a/packages/platforms/netberg/x86-64/aurora-620-rangeley/onlp/builds/x86_64_netberg_aurora_620_rangeley/module/src/fani.c +++ /dev/null @@ -1,234 +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 "x86_64_netberg_aurora_620_rangeley_int.h" -#include "x86_64_netberg_aurora_620_rangeley_log.h" - -#include - - -#define VALIDATE(_id) \ - do { \ - if(!ONLP_OID_IS_FAN(_id)) { \ - return ONLP_STATUS_E_INVALID; \ - } \ - } while(0) - -static int -sys_fan_info_get__(onlp_fan_info_t* info, int id) -{ - int value = 0; - int rv; - - rv = onlp_file_read_int(&value, SYS_HWMON2_PREFIX "/fan%d_abs", ((id/2)+1)); - if (rv != ONLP_STATUS_OK) - return rv; - - if (value == 0) - { - info->status = ONLP_FAN_STATUS_FAILED; - } - else - { - info->status = ONLP_FAN_STATUS_PRESENT; - - rv = onlp_file_read_int(&value, SYS_HWMON2_PREFIX "/fan%d_dir", ((id/2)+1)); - if (rv != ONLP_STATUS_OK) - return rv; - - if (value == 1) - { - info->status |= ONLP_FAN_STATUS_B2F; - info->caps |= ONLP_FAN_CAPS_B2F; - } - else - { - info->status |= ONLP_FAN_STATUS_F2B; - info->caps |= ONLP_FAN_CAPS_F2B; - } - - rv = onlp_file_read_int(&(info->rpm), SYS_HWMON1_PREFIX "/fan%d_rpm", (id+1)); - if (rv == ONLP_STATUS_E_INTERNAL) - return rv; - - if (rv == ONLP_STATUS_E_MISSING) - { - info->status &= ~1; - return 0; - } - - if (info->rpm <= X86_64_NETBERG_AURORA_620_RANGELEY_CONFIG_SYSFAN_RPM_FAILURE_THRESHOLD) - info->status |= ONLP_FAN_STATUS_FAILED; - - - rv = onlp_file_read_int(&(info->percentage), SYS_HWMON1_PREFIX "/fan%d_duty", (id+1)); - if (rv == ONLP_STATUS_E_INTERNAL) - return rv; - - if (rv == ONLP_STATUS_E_MISSING) - { - info->status &= ~1; - return 0; - } - } - return 0; -} - -static int -psu_fan_info_get__(onlp_fan_info_t* info, int id) -{ - return onlp_file_read_int(&(info->rpm), SYS_HWMON2_PREFIX "/psu%d_fan_speed", id); -} - -/* Onboard Fans */ -static onlp_fan_info_t fans__[] = { - { }, /* Not used */ - { { FAN_OID_FAN1, "Fan1_rotor1", 0}, ONLP_FAN_STATUS_PRESENT }, - { { FAN_OID_FAN2, "Fan1_rotor2", 0}, ONLP_FAN_STATUS_PRESENT }, - { { FAN_OID_FAN3, "Fan2_rotor1", 0}, ONLP_FAN_STATUS_PRESENT }, - { { FAN_OID_FAN4, "Fan2_rotor2", 0}, ONLP_FAN_STATUS_PRESENT }, - { { FAN_OID_FAN5, "Fan3_rotor1", 0}, ONLP_FAN_STATUS_PRESENT }, - { { FAN_OID_FAN6, "Fan3_rotor2", 0}, ONLP_FAN_STATUS_PRESENT }, - { { FAN_OID_FAN7, "Fan4_rotor1", 0}, ONLP_FAN_STATUS_PRESENT }, - { { FAN_OID_FAN8, "Fan4_rotor2", 0}, ONLP_FAN_STATUS_PRESENT }, - { { FAN_OID_FAN9, "PSU-1 Fan", 0 }, ONLP_FAN_STATUS_PRESENT }, - { { FAN_OID_FAN10, "PSU-2 Fan", 0 }, ONLP_FAN_STATUS_PRESENT }, -}; - -/* - * 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 fid; - - VALIDATE(id); - - memset(info, 0, sizeof(onlp_fan_info_t)); - fid = ONLP_OID_ID_GET(id); - *info = fans__[fid]; - - info->caps |= ONLP_FAN_CAPS_GET_RPM; - - switch(fid) - { - case FAN_ID_FAN1: - case FAN_ID_FAN2: - case FAN_ID_FAN3: - case FAN_ID_FAN4: - case FAN_ID_FAN5: - case FAN_ID_FAN6: - case FAN_ID_FAN7: - case FAN_ID_FAN8: - return sys_fan_info_get__(info, (fid - 1)); - break; - - case FAN_ID_FAN9: - case FAN_ID_FAN10: - return psu_fan_info_get__(info, (fid - FAN_ID_FAN9 + 1)); - break; - - default: - return ONLP_STATUS_E_INVALID; - break; - } - - return ONLP_STATUS_E_INVALID; -} - -/* - * 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) -{ - return ONLP_STATUS_E_UNSUPPORTED; -} - -/* - * 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/netberg/x86-64/aurora-620-rangeley/onlp/builds/x86_64_netberg_aurora_620_rangeley/module/src/ledi.c b/packages/platforms/netberg/x86-64/aurora-620-rangeley/onlp/builds/x86_64_netberg_aurora_620_rangeley/module/src/ledi.c deleted file mode 100755 index d988e81d7..000000000 --- a/packages/platforms/netberg/x86-64/aurora-620-rangeley/onlp/builds/x86_64_netberg_aurora_620_rangeley/module/src/ledi.c +++ /dev/null @@ -1,165 +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 "x86_64_netberg_aurora_620_rangeley_int.h" - -#define VALIDATE(_id) \ - do { \ - if(!ONLP_OID_IS_LED(_id)) { \ - return ONLP_STATUS_E_INVALID; \ - } \ - } while(0) - -/* LED related data - */ -enum led_light_mode { /*must be the same with the definition @ kernel driver */ - LED_MODE_OFF = 0, - LED_MODE_AMBER, - LED_MODE_GREEN, -}; - -int led_light_map_mode[][2] = -{ - {LED_MODE_OFF, ONLP_LED_MODE_OFF}, - {LED_MODE_AMBER, ONLP_LED_MODE_ORANGE}, - {LED_MODE_GREEN, ONLP_LED_MODE_GREEN}, -}; - -/* - * Get the information for the given LED OID. - */ -static onlp_led_info_t linfo[] = -{ - { }, /* Not used */ - { - { LED_OID_LED1, "Chassis LED 1 (STAT LED)", 0 }, - ONLP_LED_STATUS_PRESENT, - ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_ORANGE | ONLP_LED_CAPS_GREEN, - ONLP_LED_MODE_OFF, - }, -}; - -static int conver_led_light_mode_to_driver(int led_ligth_mode) -{ - int i, nsize = sizeof(led_light_map_mode)/sizeof(led_light_map_mode[0]); - for(i=0; i - * - ************************************************************ - * - * - * - ***********************************************************/ -#include -#include -#include -#include "x86_64_netberg_aurora_620_rangeley_int.h" -#include "x86_64_netberg_aurora_620_rangeley_log.h" - -#define VALIDATE(_id) \ - do { \ - if(!ONLP_OID_IS_PSU(_id)) { \ - return ONLP_STATUS_E_INVALID; \ - } \ - } while(0) - -static onlp_psu_info_t psus__[] = { - { }, /* Not used */ - { - { - PSU_OID_PSU1, - "PSU-1", - 0, - { - FAN_OID_FAN9, - }, - } - }, - { - { - PSU_OID_PSU2, - "PSU-2", - 0, - { - FAN_OID_FAN10, - }, - } - }, -}; - -/* - * This function will be called prior to any other onlp_psui functions. - */ -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; - int pid; - uint8_t data[256]; - int value = -1; - int len; - double dvalue; - int i; - - VALIDATE(id); - - memset(info, 0, sizeof(onlp_psu_info_t)); - pid = ONLP_OID_ID_GET(id); - *info = psus__[pid]; - - rv = onlp_file_read_int(&value, SYS_HWMON1_PREFIX "/psu%d_abs", pid); - if (rv != ONLP_STATUS_OK) - return rv; - if (value == 0) - { - info->status = ONLP_PSU_STATUS_UNPLUGGED; - return ONLP_STATUS_OK; - } - - /* PSU is present. */ - info->status = ONLP_PSU_STATUS_PRESENT; - - memset(data, 0, sizeof(data)); - rv = onlp_file_read(data, sizeof(data), &len, SYS_HWMON2_PREFIX "/psu%d_eeprom", pid); - if (rv == ONLP_STATUS_OK) - { - i = 11; - - /* Manufacturer Name */ - len = (data[i]&0x0f); - i++; - i += len; - - /* Product Name */ - len = (data[i]&0x0f); - i++; - memcpy(info->model, (char *) &(data[i]), len); - i += len; - - /* Product part,model number */ - len = (data[i]&0x0f); - i++; - i += len; - - /* Product Version */ - len = (data[i]&0x0f); - i++; - i += len; - - /* Product Serial Number */ - len = (data[i]&0x0f); - i++; - memcpy(info->serial, (char *) &(data[i]), len); - } - else - { - strcpy(info->model, "Missing"); - strcpy(info->serial, "Missing"); - } - - info->caps |= ONLP_PSU_CAPS_AC; - -#if 0 - /* PSU is powered. */ - rv = onlp_file_read_int(&value, SYS_HWMON1_PREFIX "/psu%d_pg", pid); - if (rv != ONLP_STATUS_OK) - return rv; - if (value == 0) - { - info->status |= ONLP_PSU_STATUS_FAILED; - return ONLP_STATUS_OK; - } -#endif - - memset(data, 0, sizeof(data)); - rv = onlp_file_read(data, sizeof(data), &len, SYS_HWMON2_PREFIX "/psu%d_iout", pid); - if (rv == ONLP_STATUS_OK) - { - dvalue = atof((const char *)data); - if (dvalue > 0.0) - { - info->caps |= ONLP_PSU_CAPS_IOUT; - info->miout = (int)(dvalue * 1000); - } - } - - memset(data, 0, sizeof(data)); - rv = onlp_file_read(data, sizeof(data), &len, SYS_HWMON2_PREFIX "/psu%d_vout", pid); - if (rv == ONLP_STATUS_OK) - { - dvalue = atof((const char *)data); - if (dvalue > 0.0) - { - info->caps |= ONLP_PSU_CAPS_VOUT; - info->mvout = (int)(dvalue * 1000); - } - } - - memset(data, 0, sizeof(data)); - rv = onlp_file_read(data, sizeof(data), &len, SYS_HWMON2_PREFIX "/psu%d_pin", pid); - if (rv == ONLP_STATUS_OK) - { - dvalue = atof((const char *)data); - if (dvalue > 0.0) - { - info->caps |= ONLP_PSU_CAPS_PIN; - info->mpin = (int)(dvalue * 1000); - } - } - - memset(data, 0, sizeof(data)); - rv = onlp_file_read(data, sizeof(data), &len, SYS_HWMON2_PREFIX "/psu%d_pout", pid); - if (rv == ONLP_STATUS_OK) - { - dvalue = atof((const char *)data); - if (dvalue > 0.0) - { - info->caps |= ONLP_PSU_CAPS_POUT; - info->mpout = (int)(dvalue * 1000); - } - } - - return ONLP_STATUS_OK; -} - -/* - * This is an optional generic ioctl() interface. - * Its purpose is to allow future expansion and - * custom functionality that is not otherwise exposed - * in the standard interface. - * - * The semantics of this function are platform specific. - * This function is completely optional. - */ -int -onlp_psui_ioctl(onlp_oid_t pid, va_list vargs) -{ - return ONLP_STATUS_E_UNSUPPORTED; -} - diff --git a/packages/platforms/netberg/x86-64/aurora-620-rangeley/onlp/builds/x86_64_netberg_aurora_620_rangeley/module/src/sfpi.c b/packages/platforms/netberg/x86-64/aurora-620-rangeley/onlp/builds/x86_64_netberg_aurora_620_rangeley/module/src/sfpi.c deleted file mode 100755 index bcb3c86e5..000000000 --- a/packages/platforms/netberg/x86-64/aurora-620-rangeley/onlp/builds/x86_64_netberg_aurora_620_rangeley/module/src/sfpi.c +++ /dev/null @@ -1,389 +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. - * - * - ************************************************************ - * - * SFPI Interface for the Aurora 620 Platform - * - ***********************************************************/ -#include -#include -#include -#include -#include -#include "x86_64_netberg_aurora_620_rangeley_int.h" -#include "x86_64_netberg_aurora_620_rangeley_log.h" - -#include -#include - -/* Model ID Definition */ -typedef enum -{ - HURACAN_WITH_BMC = 0x0, - HURACAN_WITHOUT_BMC, - CABRERAIII_WITH_BMC, - CABRERAIII_WITHOUT_BMC, - SESTO_WITH_BMC, - SESTO_WITHOUT_BMC, - NCIIX_WITH_BMC, - NCIIX_WITHOUT_BMC, - ASTERION_WITH_BMC, - ASTERION_WITHOUT_BMC, - HURACAN_A_WITH_BMC, - HURACAN_A_WITHOUT_BMC, - - MODEL_ID_LAST -} modelId_t; - -static int -onlp_board_model_id_get(void) -{ - static int board_model_id = MODEL_ID_LAST; - - if (board_model_id == MODEL_ID_LAST) - { - if (onlp_file_read_int(&board_model_id, SYS_HWMON1_PREFIX "/board_model_id") != ONLP_STATUS_OK) - return 0; - } - - return board_model_id; -} - -/* - * This function will be called prior to all other onlp_sfpi_* functions. - */ -int -onlp_sfpi_init(void) -{ - return ONLP_STATUS_OK; -} - -/* - * This function should populate the give bitmap with - * all valid, SFP-capable port numbers. - * - * Only port numbers in this bitmap will be queried by the the - * ONLP framework. - * - * No SFPI functions will be called with ports that are - * not in this bitmap. You can ignore all error checking - * on the incoming ports defined in this interface. - */ -int -onlp_sfpi_bitmap_get(onlp_sfp_bitmap_t* bmap) -{ - int p; - int total_port = 0; - int board_model_id = onlp_board_model_id_get(); - - switch (board_model_id) - { - case HURACAN_WITH_BMC: - case HURACAN_WITHOUT_BMC: - case HURACAN_A_WITH_BMC: - case HURACAN_A_WITHOUT_BMC: - total_port = 32; - break; - - case SESTO_WITH_BMC: - case SESTO_WITHOUT_BMC: - case NCIIX_WITH_BMC: - case NCIIX_WITHOUT_BMC: - total_port = 54; - break; - - case ASTERION_WITH_BMC: - case ASTERION_WITHOUT_BMC: - total_port = 64; - break; - - default: - break; - } - - AIM_BITMAP_CLR_ALL(bmap); - for(p = 0; p < total_port; p++) - AIM_BITMAP_SET(bmap, p); - - return ONLP_STATUS_OK; -} - -/* - * This function should return whether an SFP is inserted on the given - * port. - * - * Returns 1 if the SFP is present. - * Returns 0 if the SFP is not present. - * Returns ONLP_E_* if there was an error determining the status. - */ -int -onlp_sfpi_is_present(int port) -{ - int value = 0; - - onlp_file_read_int(&value, SYS_HWMON2_PREFIX "/port_%d_abs", (port+1)); - return value; -} - -int -onlp_sfpi_port_map(int port, int* rport) -{ - int board_model_id = onlp_board_model_id_get(); - - switch (board_model_id) - { - case HURACAN_WITH_BMC: - case HURACAN_WITHOUT_BMC: - case HURACAN_A_WITH_BMC: - case HURACAN_A_WITHOUT_BMC: - /* odd <=> even */ - if (port & 0x1) - *rport = (port - 1); - else - *rport = (port + 1); - break; - - default: - *rport = port; break; - } - - return ONLP_STATUS_OK; -} - -int -onlp_sfpi_presence_bitmap_get(onlp_sfp_bitmap_t* dst) -{ - return ONLP_STATUS_E_UNSUPPORTED; -} - -int -onlp_sfpi_rx_los_bitmap_get(onlp_sfp_bitmap_t* bmap) -{ - int p; - int total_port = 0; - int board_model_id = onlp_board_model_id_get(); - - switch (board_model_id) - { - case SESTO_WITH_BMC: - case SESTO_WITHOUT_BMC: - case NCIIX_WITH_BMC: - case NCIIX_WITHOUT_BMC: - case ASTERION_WITH_BMC: - case ASTERION_WITHOUT_BMC: - total_port = 48; - break; - - default: - break; - } - - AIM_BITMAP_CLR_ALL(bmap); - for(p = 0; p < total_port; p++) - AIM_BITMAP_SET(bmap, p); - - return ONLP_STATUS_OK; -} - -/* - * This function reads the SFPs idrom and returns in - * in the data buffer provided. - */ -int -onlp_sfpi_eeprom_read(int port, uint8_t data[256]) -{ - int rv = ONLP_STATUS_OK; - char fname[128]; - - memset(data, 0, 256); - memset(fname, 0, sizeof(fname)); - sprintf(fname, SYS_HWMON2_PREFIX "/port_%d_data_a0", (port+1)); - rv = onlplib_sfp_eeprom_read_file(fname, data); - if (rv != ONLP_STATUS_OK) - AIM_LOG_INFO("Unable to read eeprom from port(%d)\r\n", port); - - return rv; -} - -int -onlp_sfpi_dom_read(int port, uint8_t data[256]) -{ - int rv = ONLP_STATUS_OK; - char fname[128]; - - memset(data, 0, 256); - memset(fname, 0, sizeof(fname)); - sprintf(fname, SYS_HWMON2_PREFIX "/port_%d_data_a2", (port+1)); - rv = onlplib_sfp_eeprom_read_file(fname, data); - if (rv != ONLP_STATUS_OK) - AIM_LOG_INFO("Unable to read eeprom from port(%d)\r\n", port); - - return rv; -} - -/* - * Manually enable or disable the given SFP. - * - */ -int -onlp_sfpi_enable_set(int port, int enable) -{ - return ONLP_STATUS_E_UNSUPPORTED; -} - -/* - * Returns whether the SFP is currently enabled or disabled. - */ -int -onlp_sfpi_enable_get(int port, int* enable) -{ - return ONLP_STATUS_E_UNSUPPORTED; -} - -/* - * If the platform requires any setup or equalizer modifications - * based on the actual SFP that was inserted then that custom - * setup should be performed here. - * - * After a new SFP is detected by the ONLP framework this - * function will be called to perform the (optional) setup. - */ -int -onlp_sfpi_post_insert(int port, sff_info_t* sff_info) -{ - return ONLP_STATUS_E_UNSUPPORTED; -} - -/* - * Return the current status of the SFP. - * See onlp_sfp_status_t; - */ -int -onlp_sfpi_status_get(int port, uint32_t* status) -{ - return ONLP_STATUS_E_UNSUPPORTED; -} - -int onlp_sfpi_control_supported(int port, onlp_sfp_control_t control, int* supported) -{ - if (supported == NULL) - return ONLP_STATUS_E_PARAM; - - *supported = 0; - switch (control) - { - case ONLP_SFP_CONTROL_TX_DISABLE: - case ONLP_SFP_CONTROL_RX_LOS: - { - int board_model_id = onlp_board_model_id_get(); - - switch (board_model_id) - { - case SESTO_WITH_BMC: - case SESTO_WITHOUT_BMC: - case NCIIX_WITH_BMC: - case NCIIX_WITHOUT_BMC: - case ASTERION_WITH_BMC: - case ASTERION_WITHOUT_BMC: - if (port < 48) - *supported = 1; - break; - - default: - break; - } - } - break; - - default: - break; - } - - return ONLP_STATUS_OK; -} - -int -onlp_sfpi_control_set(int port, onlp_sfp_control_t control, int value) -{ - int rv = ONLP_STATUS_OK; - int supported = 0; - - if ((onlp_sfpi_control_supported(port, control, &supported) == ONLP_STATUS_OK) && (supported == 0)) - return ONLP_STATUS_E_UNSUPPORTED; - - switch (control) - { - case ONLP_SFP_CONTROL_TX_DISABLE: - rv = onlp_file_write_int(value, SYS_HWMON2_PREFIX "/port_%d_tx_disable", (port+1)); - break; - - default: - break; - } - return rv; -} - -int -onlp_sfpi_control_get(int port, onlp_sfp_control_t control, int* value) -{ - int rv = ONLP_STATUS_OK; - int supported = 0; - - if (value == NULL) - return ONLP_STATUS_E_PARAM; - - if ((onlp_sfpi_control_supported(port, control, &supported) == ONLP_STATUS_OK) && (supported == 0)) - return ONLP_STATUS_E_UNSUPPORTED; - - *value = 0; - switch (control) - { - case ONLP_SFP_CONTROL_RX_LOS: - rv = onlp_file_read_int(value, SYS_HWMON2_PREFIX "/port_%d_rxlos", (port+1)); - break; - - case ONLP_SFP_CONTROL_TX_DISABLE: - rv = onlp_file_read_int(value, SYS_HWMON2_PREFIX "/port_%d_tx_disable", (port+1)); - break; - - default: - break; - } - return rv; -} - -/* - * This is a generic ioctl interface. - */ -int -onlp_sfpi_ioctl(int port, va_list vargs) -{ - return ONLP_STATUS_E_UNSUPPORTED; -} - -/* - * De-initialize the SFPI subsystem. - */ -int -onlp_sfpi_denit(void) -{ - return ONLP_STATUS_OK; -} - diff --git a/packages/platforms/netberg/x86-64/aurora-620-rangeley/onlp/builds/x86_64_netberg_aurora_620_rangeley/module/src/sysi.c b/packages/platforms/netberg/x86-64/aurora-620-rangeley/onlp/builds/x86_64_netberg_aurora_620_rangeley/module/src/sysi.c deleted file mode 100755 index d81763350..000000000 --- a/packages/platforms/netberg/x86-64/aurora-620-rangeley/onlp/builds/x86_64_netberg_aurora_620_rangeley/module/src/sysi.c +++ /dev/null @@ -1,98 +0,0 @@ -/************************************************************ - * - * - ************************************************************ - * - * - * - ***********************************************************/ -#include -#include -#include "x86_64_netberg_aurora_620_rangeley_int.h" -#include "x86_64_netberg_aurora_620_rangeley_log.h" - -/* - * This is the first function called by the ONLP framework. - * - * It should return the name of your platform driver. - * - * If the name of your platform driver is the same as the - * current platform then this driver will be used. - * - * If the name of the driver is different from the current - * platform, or the driver is capable of supporting multiple - * platform variants, see onlp_sysi_platform_set() below. - */ -const char* -onlp_sysi_platform_get(void) -{ - return "x86-64-netberg-aurora-620-rangeley-r0"; -} - -/* - * This is the first function the ONLP framework will call - * after it has validated the the platform is supported using the mechanisms - * described above. - * - * If this function does not return ONL_STATUS_OK - * then platform initialization is aborted. - */ -int -onlp_sysi_init(void) -{ - return ONLP_STATUS_OK; -} - -int -onlp_sysi_onie_info_get(onlp_onie_info_t* onie) -{ - int rv; - uint8_t data[256]; - int len; - - memset(data, 0, sizeof(data)); - rv = onlp_file_read(data, sizeof(data), &len, SYS_HWMON2_PREFIX "/eeprom"); - if (rv == ONLP_STATUS_OK) - { - rv = onlp_onie_decode(onie, (uint8_t*)data, sizeof(data)); - if(rv >= 0) - { - onie->platform_name = aim_strdup("x86-64-netberg-aurora-620-rangeley-r0"); - } - } - 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)); - int i; - int n_thermal=7, n_fan=10, n_led=1; - - /* 2 PSUs */ - *e++ = ONLP_PSU_ID_CREATE(1); - *e++ = ONLP_PSU_ID_CREATE(2); - - /* LEDs Item */ - for (i=1; i<=n_led; i++) - { - *e++ = ONLP_LED_ID_CREATE(i); - } - - /* THERMALs Item */ - for (i=1; i<=n_thermal; i++) - { - *e++ = ONLP_THERMAL_ID_CREATE(i); - } - - /* Fans Item */ - for (i=1; i<=n_fan; i++) - { - *e++ = ONLP_FAN_ID_CREATE(i); - } - - return 0; -} - diff --git a/packages/platforms/netberg/x86-64/aurora-620-rangeley/onlp/builds/x86_64_netberg_aurora_620_rangeley/module/src/thermali.c b/packages/platforms/netberg/x86-64/aurora-620-rangeley/onlp/builds/x86_64_netberg_aurora_620_rangeley/module/src/thermali.c deleted file mode 100755 index 3def10b83..000000000 --- a/packages/platforms/netberg/x86-64/aurora-620-rangeley/onlp/builds/x86_64_netberg_aurora_620_rangeley/module/src/thermali.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 "x86_64_netberg_aurora_620_rangeley_int.h" -#include "x86_64_netberg_aurora_620_rangeley_log.h" - -#define VALIDATE(_id) \ - do { \ - if(!ONLP_OID_IS_THERMAL(_id)) { \ - return ONLP_STATUS_E_INVALID; \ - } \ - } while(0) - -static int -sys_thermal_info_get__(onlp_thermal_info_t* info, int id) -{ - int rv; - - if (id == THERMAL_ID_THERMAL3) - { - rv = onlp_file_read_int(&info->mcelsius, SYS_HWMON1_PREFIX "/mac_temp"); - info->mcelsius *= 1000; - } - else - { - uint8_t buffer[64]; - double dvalue; - int len; - - memset(buffer, 0, sizeof(buffer)); - rv = onlp_file_read(buffer, sizeof(buffer), &len, SYS_HWMON1_PREFIX "/remote_temp%d", id); - if (rv == ONLP_STATUS_OK) - { - dvalue = atof((const char *)buffer); - info->mcelsius = (int)(dvalue * 1000); - } - } - - if(rv == ONLP_STATUS_E_INTERNAL) - return rv; - - if(rv == ONLP_STATUS_E_MISSING) - { - info->status &= ~1; - return ONLP_STATUS_OK; - } - - return ONLP_STATUS_OK; -} - -static int -psu1_thermal_info_get__(onlp_thermal_info_t* info, int id) -{ - int rv; - uint8_t buffer[64]; - double dvalue; - int len; - - memset(buffer, 0, sizeof(buffer)); - rv = onlp_file_read(buffer, sizeof(buffer), &len, SYS_HWMON2_PREFIX "/psu1_temp_%d", id); - if (rv == ONLP_STATUS_OK) - { - dvalue = atof((const char *)buffer); - info->mcelsius = (int)(dvalue * 1000); - } - return rv; -} - -static int -psu2_thermal_info_get__(onlp_thermal_info_t* info, int id) -{ - int rv; - uint8_t buffer[64]; - double dvalue; - int len; - - memset(buffer, 0, sizeof(buffer)); - rv = onlp_file_read(buffer, sizeof(buffer), &len, SYS_HWMON2_PREFIX "/psu2_temp_%d", id); - if (rv == ONLP_STATUS_OK) - { - dvalue = atof((const char *)buffer); - info->mcelsius = (int)(dvalue * 1000); - } - return rv; -} - -static onlp_thermal_info_t temps__[] = -{ - { }, /* Not used */ - { { THERMAL_OID_THERMAL1, "Chassis Thermal 1 (Front of MAC)", 0}, ONLP_THERMAL_STATUS_PRESENT, ONLP_THERMAL_CAPS_GET_TEMPERATURE, 0}, - { { THERMAL_OID_THERMAL2, "Chassis Thermal 2 (Rear of MAC)", 0}, ONLP_THERMAL_STATUS_PRESENT, ONLP_THERMAL_CAPS_GET_TEMPERATURE, 0}, - { { THERMAL_OID_THERMAL3, "Chassis Thermal 3 (MAC)", 0}, ONLP_THERMAL_STATUS_PRESENT, ONLP_THERMAL_CAPS_GET_TEMPERATURE, 0}, - - { { THERMAL_OID_THERMAL4, "PSU-1 Thermal 1", PSU_OID_PSU1 }, ONLP_THERMAL_STATUS_PRESENT, ONLP_THERMAL_CAPS_GET_TEMPERATURE, 0}, - { { THERMAL_OID_THERMAL5, "PSU-1 Thermal 2", PSU_OID_PSU1 }, ONLP_THERMAL_STATUS_PRESENT, ONLP_THERMAL_CAPS_GET_TEMPERATURE, 0}, - - { { THERMAL_OID_THERMAL6, "PSU-2 Thermal 1", PSU_OID_PSU2 }, ONLP_THERMAL_STATUS_PRESENT, ONLP_THERMAL_CAPS_GET_TEMPERATURE, 0}, - { { THERMAL_OID_THERMAL7, "PSU-2 Thermal 2", PSU_OID_PSU2 }, ONLP_THERMAL_STATUS_PRESENT, ONLP_THERMAL_CAPS_GET_TEMPERATURE, 0}, -}; - - -/* - * 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); - - memset(info, 0, sizeof(onlp_thermal_info_t)); - tid = ONLP_OID_ID_GET(id); - *info = temps__[tid]; - - switch(tid) - { - case THERMAL_ID_THERMAL1: - case THERMAL_ID_THERMAL2: - case THERMAL_ID_THERMAL3: - return sys_thermal_info_get__(info, tid); - - case THERMAL_ID_THERMAL4: - case THERMAL_ID_THERMAL5: - return psu1_thermal_info_get__(info, (tid - THERMAL_ID_THERMAL4 + 1)); - - case THERMAL_ID_THERMAL6: - case THERMAL_ID_THERMAL7: - return psu2_thermal_info_get__(info, (tid - THERMAL_ID_THERMAL6 + 1)); - } - - return ONLP_STATUS_E_INVALID; -} - diff --git a/packages/platforms/netberg/x86-64/aurora-620-rangeley/onlp/builds/x86_64_netberg_aurora_620_rangeley/module/src/x86_64_netberg_aurora_620_rangeley_config.c b/packages/platforms/netberg/x86-64/aurora-620-rangeley/onlp/builds/x86_64_netberg_aurora_620_rangeley/module/src/x86_64_netberg_aurora_620_rangeley_config.c deleted file mode 100755 index 00e47c5bf..000000000 --- a/packages/platforms/netberg/x86-64/aurora-620-rangeley/onlp/builds/x86_64_netberg_aurora_620_rangeley/module/src/x86_64_netberg_aurora_620_rangeley_config.c +++ /dev/null @@ -1,80 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#include - -/* */ -#define __x86_64_netberg_aurora_620_rangeley_config_STRINGIFY_NAME(_x) #_x -#define __x86_64_netberg_aurora_620_rangeley_config_STRINGIFY_VALUE(_x) __x86_64_netberg_aurora_620_rangeley_config_STRINGIFY_NAME(_x) -x86_64_netberg_aurora_620_rangeley_config_settings_t x86_64_netberg_aurora_620_rangeley_config_settings[] = -{ -#ifdef X86_64_NETBERG_AURORA_620_RANGELEY_CONFIG_INCLUDE_LOGGING - { __x86_64_netberg_aurora_620_rangeley_config_STRINGIFY_NAME(X86_64_NETBERG_AURORA_620_RANGELEY_CONFIG_INCLUDE_LOGGING), __x86_64_netberg_aurora_620_rangeley_config_STRINGIFY_VALUE(X86_64_NETBERG_AURORA_620_RANGELEY_CONFIG_INCLUDE_LOGGING) }, -#else -{ X86_64_NETBERG_AURORA_620_RANGELEY_CONFIG_INCLUDE_LOGGING(__x86_64_netberg_aurora_620_rangeley_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_NETBERG_AURORA_620_RANGELEY_CONFIG_LOG_OPTIONS_DEFAULT - { __x86_64_netberg_aurora_620_rangeley_config_STRINGIFY_NAME(X86_64_NETBERG_AURORA_620_RANGELEY_CONFIG_LOG_OPTIONS_DEFAULT), __x86_64_netberg_aurora_620_rangeley_config_STRINGIFY_VALUE(X86_64_NETBERG_AURORA_620_RANGELEY_CONFIG_LOG_OPTIONS_DEFAULT) }, -#else -{ X86_64_NETBERG_AURORA_620_RANGELEY_CONFIG_LOG_OPTIONS_DEFAULT(__x86_64_netberg_aurora_620_rangeley_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_NETBERG_AURORA_620_RANGELEY_CONFIG_LOG_BITS_DEFAULT - { __x86_64_netberg_aurora_620_rangeley_config_STRINGIFY_NAME(X86_64_NETBERG_AURORA_620_RANGELEY_CONFIG_LOG_BITS_DEFAULT), __x86_64_netberg_aurora_620_rangeley_config_STRINGIFY_VALUE(X86_64_NETBERG_AURORA_620_RANGELEY_CONFIG_LOG_BITS_DEFAULT) }, -#else -{ X86_64_NETBERG_AURORA_620_RANGELEY_CONFIG_LOG_BITS_DEFAULT(__x86_64_netberg_aurora_620_rangeley_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_NETBERG_AURORA_620_RANGELEY_CONFIG_LOG_CUSTOM_BITS_DEFAULT - { __x86_64_netberg_aurora_620_rangeley_config_STRINGIFY_NAME(X86_64_NETBERG_AURORA_620_RANGELEY_CONFIG_LOG_CUSTOM_BITS_DEFAULT), __x86_64_netberg_aurora_620_rangeley_config_STRINGIFY_VALUE(X86_64_NETBERG_AURORA_620_RANGELEY_CONFIG_LOG_CUSTOM_BITS_DEFAULT) }, -#else -{ X86_64_NETBERG_AURORA_620_RANGELEY_CONFIG_LOG_CUSTOM_BITS_DEFAULT(__x86_64_netberg_aurora_620_rangeley_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_NETBERG_AURORA_620_RANGELEY_CONFIG_PORTING_STDLIB - { __x86_64_netberg_aurora_620_rangeley_config_STRINGIFY_NAME(X86_64_NETBERG_AURORA_620_RANGELEY_CONFIG_PORTING_STDLIB), __x86_64_netberg_aurora_620_rangeley_config_STRINGIFY_VALUE(X86_64_NETBERG_AURORA_620_RANGELEY_CONFIG_PORTING_STDLIB) }, -#else -{ X86_64_NETBERG_AURORA_620_RANGELEY_CONFIG_PORTING_STDLIB(__x86_64_netberg_aurora_620_rangeley_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_NETBERG_AURORA_620_RANGELEY_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS - { __x86_64_netberg_aurora_620_rangeley_config_STRINGIFY_NAME(X86_64_NETBERG_AURORA_620_RANGELEY_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS), __x86_64_netberg_aurora_620_rangeley_config_STRINGIFY_VALUE(X86_64_NETBERG_AURORA_620_RANGELEY_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS) }, -#else -{ X86_64_NETBERG_AURORA_620_RANGELEY_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS(__x86_64_netberg_aurora_620_rangeley_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_NETBERG_AURORA_620_RANGELEY_CONFIG_INCLUDE_UCLI - { __x86_64_netberg_aurora_620_rangeley_config_STRINGIFY_NAME(X86_64_NETBERG_AURORA_620_RANGELEY_CONFIG_INCLUDE_UCLI), __x86_64_netberg_aurora_620_rangeley_config_STRINGIFY_VALUE(X86_64_NETBERG_AURORA_620_RANGELEY_CONFIG_INCLUDE_UCLI) }, -#else -{ X86_64_NETBERG_AURORA_620_RANGELEY_CONFIG_INCLUDE_UCLI(__x86_64_netberg_aurora_620_rangeley_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_NETBERG_AURORA_620_RANGELEY_CONFIG_SYSFAN_RPM_FAILURE_THRESHOLD - { __x86_64_netberg_aurora_620_rangeley_config_STRINGIFY_NAME(X86_64_NETBERG_AURORA_620_RANGELEY_CONFIG_SYSFAN_RPM_FAILURE_THRESHOLD), __x86_64_netberg_aurora_620_rangeley_config_STRINGIFY_VALUE(X86_64_NETBERG_AURORA_620_RANGELEY_CONFIG_SYSFAN_RPM_FAILURE_THRESHOLD) }, -#else -{ X86_64_NETBERG_AURORA_620_RANGELEY_CONFIG_SYSFAN_RPM_FAILURE_THRESHOLD(__x86_64_netberg_aurora_620_rangeley_config_STRINGIFY_NAME), "__undefined__" }, -#endif - { NULL, NULL } -}; -#undef __x86_64_netberg_aurora_620_rangeley_config_STRINGIFY_VALUE -#undef __x86_64_netberg_aurora_620_rangeley_config_STRINGIFY_NAME - -const char* -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)) { - return x86_64_netberg_aurora_620_rangeley_config_settings[i].value; - } - } - return NULL; -} - -int -x86_64_netberg_aurora_620_rangeley_config_show(struct aim_pvs_s* pvs) -{ - int i; - for(i = 0; x86_64_netberg_aurora_620_rangeley_config_settings[i].name; i++) { - aim_printf(pvs, "%s = %s\n", x86_64_netberg_aurora_620_rangeley_config_settings[i].name, x86_64_netberg_aurora_620_rangeley_config_settings[i].value); - } - return i; -} - -/* */ diff --git a/packages/platforms/netberg/x86-64/aurora-620-rangeley/onlp/builds/x86_64_netberg_aurora_620_rangeley/module/src/x86_64_netberg_aurora_620_rangeley_enums.c b/packages/platforms/netberg/x86-64/aurora-620-rangeley/onlp/builds/x86_64_netberg_aurora_620_rangeley/module/src/x86_64_netberg_aurora_620_rangeley_enums.c deleted file mode 100755 index 118897f47..000000000 --- a/packages/platforms/netberg/x86-64/aurora-620-rangeley/onlp/builds/x86_64_netberg_aurora_620_rangeley/module/src/x86_64_netberg_aurora_620_rangeley_enums.c +++ /dev/null @@ -1,10 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#include - -/* <--auto.start.enum(ALL).source> */ -/* */ - diff --git a/packages/platforms/netberg/x86-64/aurora-620-rangeley/onlp/builds/x86_64_netberg_aurora_620_rangeley/module/src/x86_64_netberg_aurora_620_rangeley_int.h b/packages/platforms/netberg/x86-64/aurora-620-rangeley/onlp/builds/x86_64_netberg_aurora_620_rangeley/module/src/x86_64_netberg_aurora_620_rangeley_int.h deleted file mode 100755 index 439b71405..000000000 --- a/packages/platforms/netberg/x86-64/aurora-620-rangeley/onlp/builds/x86_64_netberg_aurora_620_rangeley/module/src/x86_64_netberg_aurora_620_rangeley_int.h +++ /dev/null @@ -1,265 +0,0 @@ -/**************************************************************************//** - * - * x86_64_netberg_aurora_620_rangeley Internal Header - * - *****************************************************************************/ -#ifndef __X86_64_NETBERG_AURORA_620_RANGELEY_INT_H__ -#define __X86_64_NETBERG_AURORA_620_RANGELEY_INT_H__ - -#include -#include - -/* */ -/** 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[]; - -/** 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[]; - -/** led_id */ -typedef enum led_id_e { - LED_ID_LED1 = 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_LED1 = ONLP_LED_ID_CREATE(1), -} 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[]; - -/** 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 */ -struct psu_info_s { - char path[PATH_MAX]; - int present; - int busno; - int addr; -}; - -#define SYS_HWMON1_PREFIX "/sys/class/hwmon/hwmon1/device" -#define SYS_HWMON2_PREFIX "/sys/class/hwmon/hwmon2/device" - -#endif /* __X86_64_NETBERG_AURORA_620_RANGELEY_INT_H__ */ diff --git a/packages/platforms/netberg/x86-64/aurora-620-rangeley/onlp/builds/x86_64_netberg_aurora_620_rangeley/module/src/x86_64_netberg_aurora_620_rangeley_log.c b/packages/platforms/netberg/x86-64/aurora-620-rangeley/onlp/builds/x86_64_netberg_aurora_620_rangeley/module/src/x86_64_netberg_aurora_620_rangeley_log.c deleted file mode 100755 index abf80730e..000000000 --- a/packages/platforms/netberg/x86-64/aurora-620-rangeley/onlp/builds/x86_64_netberg_aurora_620_rangeley/module/src/x86_64_netberg_aurora_620_rangeley_log.c +++ /dev/null @@ -1,18 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#include - -#include "x86_64_netberg_aurora_620_rangeley_log.h" -/* - * x86_64_netberg_aurora_620_rangeley log struct. - */ -AIM_LOG_STRUCT_DEFINE( - X86_64_NETBERG_AURORA_620_RANGELEY_CONFIG_LOG_OPTIONS_DEFAULT, - X86_64_NETBERG_AURORA_620_RANGELEY_CONFIG_LOG_BITS_DEFAULT, - NULL, /* Custom log map */ - X86_64_NETBERG_AURORA_620_RANGELEY_CONFIG_LOG_CUSTOM_BITS_DEFAULT - ); - diff --git a/packages/platforms/netberg/x86-64/aurora-620-rangeley/onlp/builds/x86_64_netberg_aurora_620_rangeley/module/src/x86_64_netberg_aurora_620_rangeley_log.h b/packages/platforms/netberg/x86-64/aurora-620-rangeley/onlp/builds/x86_64_netberg_aurora_620_rangeley/module/src/x86_64_netberg_aurora_620_rangeley_log.h deleted file mode 100755 index 4a2e994c8..000000000 --- a/packages/platforms/netberg/x86-64/aurora-620-rangeley/onlp/builds/x86_64_netberg_aurora_620_rangeley/module/src/x86_64_netberg_aurora_620_rangeley_log.h +++ /dev/null @@ -1,12 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#ifndef __X86_64_NETBERG_AURORA_620_RANGELEY_LOG_H__ -#define __X86_64_NETBERG_AURORA_620_RANGELEY_LOG_H__ - -#define AIM_LOG_MODULE_NAME x86_64_netberg_aurora_620_rangeley -#include - -#endif /* __X86_64_NETBERG_AURORA_620_RANGELEY_LOG_H__ */ diff --git a/packages/platforms/netberg/x86-64/aurora-620-rangeley/onlp/builds/x86_64_netberg_aurora_620_rangeley/module/src/x86_64_netberg_aurora_620_rangeley_module.c b/packages/platforms/netberg/x86-64/aurora-620-rangeley/onlp/builds/x86_64_netberg_aurora_620_rangeley/module/src/x86_64_netberg_aurora_620_rangeley_module.c deleted file mode 100755 index bdb59db40..000000000 --- a/packages/platforms/netberg/x86-64/aurora-620-rangeley/onlp/builds/x86_64_netberg_aurora_620_rangeley/module/src/x86_64_netberg_aurora_620_rangeley_module.c +++ /dev/null @@ -1,24 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#include - -#include "x86_64_netberg_aurora_620_rangeley_log.h" - -static int -datatypes_init__(void) -{ -#define X86_64_NETBERG_AURORA_620_RANGELEY_ENUMERATION_ENTRY(_enum_name, _desc) AIM_DATATYPE_MAP_REGISTER(_enum_name, _enum_name##_map, _desc, AIM_LOG_INTERNAL); -#include - return 0; -} - -void __x86_64_netberg_aurora_620_rangeley_module_init__(void) -{ - AIM_LOG_STRUCT_REGISTER(); - datatypes_init__(); -} - -int __onlp_platform_version__ = 1; diff --git a/packages/platforms/netberg/x86-64/aurora-620-rangeley/onlp/builds/x86_64_netberg_aurora_620_rangeley/module/src/x86_64_netberg_aurora_620_rangeley_ucli.c b/packages/platforms/netberg/x86-64/aurora-620-rangeley/onlp/builds/x86_64_netberg_aurora_620_rangeley/module/src/x86_64_netberg_aurora_620_rangeley_ucli.c deleted file mode 100755 index 59bffca9b..000000000 --- a/packages/platforms/netberg/x86-64/aurora-620-rangeley/onlp/builds/x86_64_netberg_aurora_620_rangeley/module/src/x86_64_netberg_aurora_620_rangeley_ucli.c +++ /dev/null @@ -1,50 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#include - -#if X86_64_NETBERG_AURORA_620_RANGELEY_CONFIG_INCLUDE_UCLI == 1 - -#include -#include -#include - -static ucli_status_t -x86_64_netberg_aurora_620_rangeley_ucli_ucli__config__(ucli_context_t* uc) -{ - UCLI_HANDLER_MACRO_MODULE_CONFIG(x86_64_netberg_aurora_620_rangeley) -} - -/* */ -/* */ - -static ucli_module_t -x86_64_netberg_aurora_620_rangeley_ucli_module__ = - { - "x86_64_netberg_aurora_620_rangeley_ucli", - NULL, - x86_64_netberg_aurora_620_rangeley_ucli_ucli_handlers__, - NULL, - NULL, - }; - -ucli_node_t* -x86_64_netberg_aurora_620_rangeley_ucli_node_create(void) -{ - ucli_node_t* n; - ucli_module_init(&x86_64_netberg_aurora_620_rangeley_ucli_module__); - n = ucli_node_create("x86_64_netberg_aurora_620_rangeley", NULL, &x86_64_netberg_aurora_620_rangeley_ucli_module__); - ucli_node_subnode_add(n, ucli_module_log_node_create("x86_64_netberg_aurora_620_rangeley")); - return n; -} - -#else -void* -x86_64_netberg_aurora_620_rangeley_ucli_node_create(void) -{ - return NULL; -} -#endif - diff --git a/packages/platforms/netberg/x86-64/aurora-620-rangeley/platform-config/Makefile b/packages/platforms/netberg/x86-64/aurora-620-rangeley/platform-config/Makefile deleted file mode 100755 index 003238cf6..000000000 --- a/packages/platforms/netberg/x86-64/aurora-620-rangeley/platform-config/Makefile +++ /dev/null @@ -1 +0,0 @@ -include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/netberg/x86-64/aurora-620-rangeley/platform-config/r0/Makefile b/packages/platforms/netberg/x86-64/aurora-620-rangeley/platform-config/r0/Makefile deleted file mode 100755 index 003238cf6..000000000 --- a/packages/platforms/netberg/x86-64/aurora-620-rangeley/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/netberg/x86-64/aurora-620-rangeley/platform-config/r0/PKG.yml b/packages/platforms/netberg/x86-64/aurora-620-rangeley/platform-config/r0/PKG.yml deleted file mode 100755 index 875640089..000000000 --- a/packages/platforms/netberg/x86-64/aurora-620-rangeley/platform-config/r0/PKG.yml +++ /dev/null @@ -1 +0,0 @@ -!include $ONL_TEMPLATES/platform-config-platform.yml ARCH=amd64 VENDOR=netberg BASENAME=x86-64-netberg-aurora-620-rangeley REVISION=r0 diff --git a/packages/platforms/netberg/x86-64/aurora-620-rangeley/platform-config/r0/src/lib/x86-64-netberg-aurora-620-rangeley-r0.yml b/packages/platforms/netberg/x86-64/aurora-620-rangeley/platform-config/r0/src/lib/x86-64-netberg-aurora-620-rangeley-r0.yml deleted file mode 100755 index ccecc53f4..000000000 --- a/packages/platforms/netberg/x86-64/aurora-620-rangeley/platform-config/r0/src/lib/x86-64-netberg-aurora-620-rangeley-r0.yml +++ /dev/null @@ -1,30 +0,0 @@ ---- - -###################################################################### -# -# platform-config for AURORA 620 -# -###################################################################### - -x86-64-netberg-aurora-620-rangeley-r0: - - grub: - - serial: >- - --port=0x2f8 - --speed=115200 - --word=8 - --parity=no - --stop=1 - - kernel: - <<: *kernel-3-16 - - args: >- - console=ttyS1,115200n8 - - ##network: - ## interfaces: - ## ma1: - ## name: ~ - ## syspath: pci0000:00/0000:00:14.0 diff --git a/packages/platforms/netberg/x86-64/aurora-620-rangeley/platform-config/r0/src/python/x86_64_netberg_aurora_620_rangeley_r0/__init__.py b/packages/platforms/netberg/x86-64/aurora-620-rangeley/platform-config/r0/src/python/x86_64_netberg_aurora_620_rangeley_r0/__init__.py deleted file mode 100755 index c01ac8bd4..000000000 --- a/packages/platforms/netberg/x86-64/aurora-620-rangeley/platform-config/r0/src/python/x86_64_netberg_aurora_620_rangeley_r0/__init__.py +++ /dev/null @@ -1,12 +0,0 @@ -from onl.platform.base import * -from onl.platform.netberg import * - -class OnlPlatform_x86_64_netberg_aurora_620_rangeley_r0(OnlPlatformNetberg, - OnlPlatformPortConfig_48x25_6x100): - PLATFORM='x86-64-netberg-aurora-620-rangeley-r0' - MODEL="AURORA620" - SYS_OBJECT_ID=".620.1" - - def baseconfig(self): - self.insmod("hardware_monitor") - return True diff --git a/packages/platforms/netberg/x86-64/aurora-710/.gitignore b/packages/platforms/netberg/x86-64/aurora-710/.gitignore deleted file mode 100755 index 9f7b1342f..000000000 --- a/packages/platforms/netberg/x86-64/aurora-710/.gitignore +++ /dev/null @@ -1 +0,0 @@ -onlpdump.mk diff --git a/packages/platforms/netberg/x86-64/aurora-710/Makefile b/packages/platforms/netberg/x86-64/aurora-710/Makefile deleted file mode 100755 index 003238cf6..000000000 --- a/packages/platforms/netberg/x86-64/aurora-710/Makefile +++ /dev/null @@ -1 +0,0 @@ -include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/netberg/x86-64/aurora-710/modules/Makefile b/packages/platforms/netberg/x86-64/aurora-710/modules/Makefile deleted file mode 100755 index 003238cf6..000000000 --- a/packages/platforms/netberg/x86-64/aurora-710/modules/Makefile +++ /dev/null @@ -1 +0,0 @@ -include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/netberg/x86-64/aurora-710/modules/PKG.yml b/packages/platforms/netberg/x86-64/aurora-710/modules/PKG.yml deleted file mode 100755 index 70e9df7c7..000000000 --- a/packages/platforms/netberg/x86-64/aurora-710/modules/PKG.yml +++ /dev/null @@ -1 +0,0 @@ -!include $ONL_TEMPLATES/no-platform-modules.yml ARCH=amd64 VENDOR=netberg BASENAME=x86-64-netberg-aurora-710 KERNELS="onl-kernel-3.16-lts-x86-64-all:amd64" diff --git a/packages/platforms/netberg/x86-64/aurora-710/onlp/Makefile b/packages/platforms/netberg/x86-64/aurora-710/onlp/Makefile deleted file mode 100755 index 003238cf6..000000000 --- a/packages/platforms/netberg/x86-64/aurora-710/onlp/Makefile +++ /dev/null @@ -1 +0,0 @@ -include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/netberg/x86-64/aurora-710/onlp/PKG.yml b/packages/platforms/netberg/x86-64/aurora-710/onlp/PKG.yml deleted file mode 100755 index de7da81f2..000000000 --- a/packages/platforms/netberg/x86-64/aurora-710/onlp/PKG.yml +++ /dev/null @@ -1 +0,0 @@ -!include $ONL_TEMPLATES/onlp-platform-any.yml PLATFORM=x86-64-netberg-aurora-710 ARCH=amd64 TOOLCHAIN=x86_64-linux-gnu diff --git a/packages/platforms/netberg/x86-64/aurora-710/onlp/builds/Makefile b/packages/platforms/netberg/x86-64/aurora-710/onlp/builds/Makefile deleted file mode 100755 index e7437cb23..000000000 --- a/packages/platforms/netberg/x86-64/aurora-710/onlp/builds/Makefile +++ /dev/null @@ -1,2 +0,0 @@ -FILTER=src -include $(ONL)/make/subdirs.mk diff --git a/packages/platforms/netberg/x86-64/aurora-710/onlp/builds/lib/Makefile b/packages/platforms/netberg/x86-64/aurora-710/onlp/builds/lib/Makefile deleted file mode 100755 index 9def5af14..000000000 --- a/packages/platforms/netberg/x86-64/aurora-710/onlp/builds/lib/Makefile +++ /dev/null @@ -1,2 +0,0 @@ -PLATFORM := x86-64-netberg-aurora-710 -include $(ONL)/packages/base/any/onlp/builds/platform/libonlp-platform.mk diff --git a/packages/platforms/netberg/x86-64/aurora-710/onlp/builds/onlpdump/Makefile b/packages/platforms/netberg/x86-64/aurora-710/onlp/builds/onlpdump/Makefile deleted file mode 100755 index cb63f22e9..000000000 --- a/packages/platforms/netberg/x86-64/aurora-710/onlp/builds/onlpdump/Makefile +++ /dev/null @@ -1,2 +0,0 @@ -PLATFORM := x86-64-netberg-aurora-710 -include $(ONL)/packages/base/any/onlp/builds/platform/onlps.mk diff --git a/packages/platforms/netberg/x86-64/aurora-710/onlp/builds/x86_64_netberg_aurora_710/.gitignore b/packages/platforms/netberg/x86-64/aurora-710/onlp/builds/x86_64_netberg_aurora_710/.gitignore deleted file mode 100755 index cd8218046..000000000 --- a/packages/platforms/netberg/x86-64/aurora-710/onlp/builds/x86_64_netberg_aurora_710/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -/x86_64_netberg_aurora_710.mk -/doc diff --git a/packages/platforms/netberg/x86-64/aurora-710/onlp/builds/x86_64_netberg_aurora_710/.module b/packages/platforms/netberg/x86-64/aurora-710/onlp/builds/x86_64_netberg_aurora_710/.module deleted file mode 100755 index baf38e43c..000000000 --- a/packages/platforms/netberg/x86-64/aurora-710/onlp/builds/x86_64_netberg_aurora_710/.module +++ /dev/null @@ -1 +0,0 @@ -name: x86_64_netberg_aurora_710 diff --git a/packages/platforms/netberg/x86-64/aurora-710/onlp/builds/x86_64_netberg_aurora_710/Makefile b/packages/platforms/netberg/x86-64/aurora-710/onlp/builds/x86_64_netberg_aurora_710/Makefile deleted file mode 100755 index a27ea0795..000000000 --- a/packages/platforms/netberg/x86-64/aurora-710/onlp/builds/x86_64_netberg_aurora_710/Makefile +++ /dev/null @@ -1,9 +0,0 @@ -############################################################ -# -# -# -############################################################ -include $(ONL)/make/config.mk -MODULE := x86_64_netberg_aurora_710 -AUTOMODULE := x86_64_netberg_aurora_710 -include $(BUILDER)/definemodule.mk diff --git a/packages/platforms/netberg/x86-64/aurora-710/onlp/builds/x86_64_netberg_aurora_710/module/auto/make.mk b/packages/platforms/netberg/x86-64/aurora-710/onlp/builds/x86_64_netberg_aurora_710/module/auto/make.mk deleted file mode 100755 index f4356793c..000000000 --- a/packages/platforms/netberg/x86-64/aurora-710/onlp/builds/x86_64_netberg_aurora_710/module/auto/make.mk +++ /dev/null @@ -1,7 +0,0 @@ -# -# x86_64_netberg_aurora_710 Autogeneration -# -############################################################################### -x86_64_netberg_aurora_710_AUTO_DEFS := module/auto/x86_64_netberg_aurora_710.yml -x86_64_netberg_aurora_710_AUTO_DIRS := module/inc/x86_64_netberg_aurora_710 module/src -include $(BUILDER)/auto.mk diff --git a/packages/platforms/netberg/x86-64/aurora-710/onlp/builds/x86_64_netberg_aurora_710/module/auto/x86_64_netberg_aurora_710.yml b/packages/platforms/netberg/x86-64/aurora-710/onlp/builds/x86_64_netberg_aurora_710/module/auto/x86_64_netberg_aurora_710.yml deleted file mode 100755 index 54898d79f..000000000 --- a/packages/platforms/netberg/x86-64/aurora-710/onlp/builds/x86_64_netberg_aurora_710/module/auto/x86_64_netberg_aurora_710.yml +++ /dev/null @@ -1,47 +0,0 @@ -############################################################################### -# -# X86_64_NETBERG_AURORA_710 Autogeneration Definitions. -# -############################################################################### - -cdefs: &cdefs -- X86_64_NETBERG_AURORA_710_CONFIG_INCLUDE_LOGGING: - doc: "Include or exclude logging." - default: 1 -- X86_64_NETBERG_AURORA_710_CONFIG_LOG_OPTIONS_DEFAULT: - doc: "Default enabled log options." - default: AIM_LOG_OPTIONS_DEFAULT -- X86_64_NETBERG_AURORA_710_CONFIG_LOG_BITS_DEFAULT: - doc: "Default enabled log bits." - default: AIM_LOG_BITS_DEFAULT -- X86_64_NETBERG_AURORA_710_CONFIG_LOG_CUSTOM_BITS_DEFAULT: - doc: "Default enabled custom log bits." - default: 0 -- X86_64_NETBERG_AURORA_710_CONFIG_PORTING_STDLIB: - doc: "Default all porting macros to use the C standard libraries." - default: 1 -- X86_64_NETBERG_AURORA_710_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS: - doc: "Include standard library headers for stdlib porting macros." - default: NETBERG_AURORA_710_CONFIG_PORTING_STDLIB -- X86_64_NETBERG_AURORA_710_CONFIG_INCLUDE_UCLI: - doc: "Include generic uCli support." - default: 0 - - -definitions: - cdefs: - X86_64_NETBERG_AURORA_710_CONFIG_HEADER: - defs: *cdefs - basename: x86_64_netberg_aurora_710_config - - portingmacro: - X86_64_NETBERG_AURORA_710: - macros: - - malloc - - free - - memset - - memcpy - - - vsnprintf - - snprintf - - strlen diff --git a/packages/platforms/netberg/x86-64/aurora-710/onlp/builds/x86_64_netberg_aurora_710/module/inc/x86_64_netberg_aurora_710/x86_64_netberg_aurora_710.x b/packages/platforms/netberg/x86-64/aurora-710/onlp/builds/x86_64_netberg_aurora_710/module/inc/x86_64_netberg_aurora_710/x86_64_netberg_aurora_710.x deleted file mode 100755 index 5c822aab2..000000000 --- a/packages/platforms/netberg/x86-64/aurora-710/onlp/builds/x86_64_netberg_aurora_710/module/inc/x86_64_netberg_aurora_710/x86_64_netberg_aurora_710.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/netberg/x86-64/aurora-710/onlp/builds/x86_64_netberg_aurora_710/module/inc/x86_64_netberg_aurora_710/x86_64_netberg_aurora_710_config.h b/packages/platforms/netberg/x86-64/aurora-710/onlp/builds/x86_64_netberg_aurora_710/module/inc/x86_64_netberg_aurora_710/x86_64_netberg_aurora_710_config.h deleted file mode 100755 index e0e6f64fc..000000000 --- a/packages/platforms/netberg/x86-64/aurora-710/onlp/builds/x86_64_netberg_aurora_710/module/inc/x86_64_netberg_aurora_710/x86_64_netberg_aurora_710_config.h +++ /dev/null @@ -1,152 +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 x86_64_netberg_aurora_710 Configuration Header - * - * @addtogroup x86_64_netberg_aurora_710-config - * @{ - * - *****************************************************************************/ -#ifndef __X86_64_NETBERG_AURORA_710_CONFIG_H__ -#define __X86_64_NETBERG_AURORA_710_CONFIG_H__ - -#ifdef GLOBAL_INCLUDE_CUSTOM_CONFIG -#include -#endif -#ifdef X86_64_NETBERG_AURORA_710_INCLUDE_CUSTOM_CONFIG -#include -#endif - -/* */ -#include -/** - * X86_64_NETBERG_AURORA_710_CONFIG_INCLUDE_LOGGING - * - * Include or exclude logging. */ - - -#ifndef X86_64_NETBERG_AURORA_710_CONFIG_INCLUDE_LOGGING -#define X86_64_NETBERG_AURORA_710_CONFIG_INCLUDE_LOGGING 1 -#endif - -/** - * X86_64_NETBERG_AURORA_710_CONFIG_LOG_OPTIONS_DEFAULT - * - * Default enabled log options. */ - - -#ifndef X86_64_NETBERG_AURORA_710_CONFIG_LOG_OPTIONS_DEFAULT -#define X86_64_NETBERG_AURORA_710_CONFIG_LOG_OPTIONS_DEFAULT AIM_LOG_OPTIONS_DEFAULT -#endif - -/** - * X86_64_NETBERG_AURORA_710_CONFIG_LOG_BITS_DEFAULT - * - * Default enabled log bits. */ - - -#ifndef X86_64_NETBERG_AURORA_710_CONFIG_LOG_BITS_DEFAULT -#define X86_64_NETBERG_AURORA_710_CONFIG_LOG_BITS_DEFAULT AIM_LOG_BITS_DEFAULT -#endif - -/** - * X86_64_NETBERG_AURORA_710_CONFIG_LOG_CUSTOM_BITS_DEFAULT - * - * Default enabled custom log bits. */ - - -#ifndef X86_64_NETBERG_AURORA_710_CONFIG_LOG_CUSTOM_BITS_DEFAULT -#define X86_64_NETBERG_AURORA_710_CONFIG_LOG_CUSTOM_BITS_DEFAULT 0 -#endif - -/** - * X86_64_NETBERG_AURORA_710_CONFIG_PORTING_STDLIB - * - * Default all porting macros to use the C standard libraries. */ - - -#ifndef X86_64_NETBERG_AURORA_710_CONFIG_PORTING_STDLIB -#define X86_64_NETBERG_AURORA_710_CONFIG_PORTING_STDLIB 1 -#endif - -/** - * X86_64_NETBERG_AURORA_710_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS - * - * Include standard library headers for stdlib porting macros. */ - - -#ifndef X86_64_NETBERG_AURORA_710_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS -#define X86_64_NETBERG_AURORA_710_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS NETBERG_AURORA_710_CONFIG_PORTING_STDLIB -#endif - -/** - * X86_64_NETBERG_AURORA_710_CONFIG_INCLUDE_UCLI - * - * Include generic uCli support. */ - - -#ifndef X86_64_NETBERG_AURORA_710_CONFIG_INCLUDE_UCLI -#define X86_64_NETBERG_AURORA_710_CONFIG_INCLUDE_UCLI 0 -#endif - - - -/** - * All compile time options can be queried or displayed - */ - -/** Configuration settings structure. */ -typedef struct x86_64_netberg_aurora_710_config_settings_s { - /** name */ - const char* name; - /** value */ - const char* value; -} x86_64_netberg_aurora_710_config_settings_t; - -/** Configuration settings table. */ -/** x86_64_netberg_aurora_710_config_settings table. */ -extern x86_64_netberg_aurora_710_config_settings_t x86_64_netberg_aurora_710_config_settings[]; - -/** - * @brief Lookup a configuration setting. - * @param setting The name of the configuration option to lookup. - */ -const char* x86_64_netberg_aurora_710_config_lookup(const char* setting); - -/** - * @brief Show the compile-time configuration. - * @param pvs The output stream. - */ -int x86_64_netberg_aurora_710_config_show(struct aim_pvs_s* pvs); - -/* */ - -#include "x86_64_netberg_aurora_710_porting.h" - -#endif /* __X86_64_NETBERG_AURORA_710_CONFIG_H__ */ -/* @} */ diff --git a/packages/platforms/netberg/x86-64/aurora-710/onlp/builds/x86_64_netberg_aurora_710/module/inc/x86_64_netberg_aurora_710/x86_64_netberg_aurora_710_dox.h b/packages/platforms/netberg/x86-64/aurora-710/onlp/builds/x86_64_netberg_aurora_710/module/inc/x86_64_netberg_aurora_710/x86_64_netberg_aurora_710_dox.h deleted file mode 100755 index afa44aa95..000000000 --- a/packages/platforms/netberg/x86-64/aurora-710/onlp/builds/x86_64_netberg_aurora_710/module/inc/x86_64_netberg_aurora_710/x86_64_netberg_aurora_710_dox.h +++ /dev/null @@ -1,26 +0,0 @@ -/**************************************************************************//** - * - * x86_64_netberg_aurora_710 Doxygen Header - * - *****************************************************************************/ -#ifndef __x86_64_netberg_aurora_710_DOX_H__ -#define __x86_64_netberg_aurora_710_DOX_H__ - -/** - * @defgroup x86_64_netberg_aurora_710 x86_64_netberg_aurora_710 - x86_64_netberg_aurora_710 Description - * - -The documentation overview for this module should go here. - - * - * @{ - * - * @defgroup x86_64_netberg_aurora_710-x86_64_netberg_aurora_710 Public Interface - * @defgroup x86_64_netberg_aurora_710-config Compile Time Configuration - * @defgroup x86_64_netberg_aurora_710-porting Porting Macros - * - * @} - * - */ - -#endif /* __x86_64_netberg_aurora_710_DOX_H__ */ diff --git a/packages/platforms/netberg/x86-64/aurora-710/onlp/builds/x86_64_netberg_aurora_710/module/inc/x86_64_netberg_aurora_710/x86_64_netberg_aurora_710_porting.h b/packages/platforms/netberg/x86-64/aurora-710/onlp/builds/x86_64_netberg_aurora_710/module/inc/x86_64_netberg_aurora_710/x86_64_netberg_aurora_710_porting.h deleted file mode 100755 index 00142f357..000000000 --- a/packages/platforms/netberg/x86-64/aurora-710/onlp/builds/x86_64_netberg_aurora_710/module/inc/x86_64_netberg_aurora_710/x86_64_netberg_aurora_710_porting.h +++ /dev/null @@ -1,96 +0,0 @@ -/********************************************************//** - * - * @file - * @brief x86_64_Netberg_aurora_710 Porting Macros. - * - * @addtogroup x86_64_Netberg_aurora_710-porting - * @{ - * - ***********************************************************/ -#ifndef __X86_64_NETBERG_AURORA_710_PORTING_H__ -#define __X86_64_NETBERG_AURORA_710_PORTING_H__ - -/* */ -#if X86_64_NETBERG_AURORA_710_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS == 1 -#include -#include -#include -#include -#include -#endif - -#ifndef X86_64_NETBERG_AURORA_710_MALLOC - #if defined(GLOBAL_MALLOC) - #define X86_64_NETBERG_AURORA_710_MALLOC GLOBAL_MALLOC - #elif X86_64_NETBERG_AURORA_710_CONFIG_PORTING_STDLIB == 1 - #define X86_64_NETBERG_AURORA_710_MALLOC malloc - #else - #error The macro X86_64_NETBERG_AURORA_710_MALLOC is required but cannot be defined. - #endif -#endif - -#ifndef X86_64_NETBERG_AURORA_710_FREE - #if defined(GLOBAL_FREE) - #define X86_64_NETBERG_AURORA_710_FREE GLOBAL_FREE - #elif X86_64_NETBERG_AURORA_710_CONFIG_PORTING_STDLIB == 1 - #define X86_64_NETBERG_AURORA_710_FREE free - #else - #error The macro X86_64_NETBERG_AURORA_710_FREE is required but cannot be defined. - #endif -#endif - -#ifndef X86_64_NETBERG_AURORA_710_MEMSET - #if defined(GLOBAL_MEMSET) - #define X86_64_NETBERG_AURORA_710_MEMSET GLOBAL_MEMSET - #elif X86_64_NETBERG_AURORA_710_CONFIG_PORTING_STDLIB == 1 - #define X86_64_NETBERG_AURORA_710_MEMSET memset - #else - #error The macro X86_64_NETBERG_AURORA_710_MEMSET is required but cannot be defined. - #endif -#endif - -#ifndef X86_64_NETBERG_AURORA_710_MEMCPY - #if defined(GLOBAL_MEMCPY) - #define X86_64_NETBERG_AURORA_710_MEMCPY GLOBAL_MEMCPY - #elif X86_64_NETBERG_AURORA_710_CONFIG_PORTING_STDLIB == 1 - #define X86_64_NETBERG_AURORA_710_MEMCPY memcpy - #else - #error The macro X86_64_NETBERG_AURORA_710_MEMCPY is required but cannot be defined. - #endif -#endif - -#ifndef X86_64_NETBERG_AURORA_710_VSNPRINTF - #if defined(GLOBAL_VSNPRINTF) - #define X86_64_NETBERG_AURORA_710_VSNPRINTF GLOBAL_VSNPRINTF - #elif X86_64_NETBERG_AURORA_710_CONFIG_PORTING_STDLIB == 1 - #define X86_64_NETBERG_AURORA_710_VSNPRINTF vsnprintf - #else - #error The macro X86_64_NETBERG_AURORA_710_VSNPRINTF is required but cannot be defined. - #endif -#endif - -#ifndef X86_64_NETBERG_AURORA_710_SNPRINTF - #if defined(GLOBAL_SNPRINTF) - #define X86_64_NETBERG_AURORA_710_SNPRINTF GLOBAL_SNPRINTF - #elif X86_64_NETBERG_AURORA_710_CONFIG_PORTING_STDLIB == 1 - #define X86_64_NETBERG_AURORA_710_SNPRINTF snprintf - #else - #error The macro X86_64_NETBERG_AURORA_710_SNPRINTF is required but cannot be defined. - #endif -#endif - -#ifndef X86_64_NETBERG_AURORA_710_STRLEN - #if defined(GLOBAL_STRLEN) - #define X86_64_NETBERG_AURORA_710_STRLEN GLOBAL_STRLEN - #elif X86_64_NETBERG_AURORA_710_CONFIG_PORTING_STDLIB == 1 - #define X86_64_NETBERG_AURORA_710_STRLEN strlen - #else - #error The macro X86_64_NETBERG_AURORA_710_STRLEN is required but cannot be defined. - #endif -#endif - -/* */ - - -#endif /* __X86_64_NETBERG_AURORA_710_PORTING_H__ */ -/* @} */ diff --git a/packages/platforms/netberg/x86-64/aurora-710/onlp/builds/x86_64_netberg_aurora_710/module/make.mk b/packages/platforms/netberg/x86-64/aurora-710/onlp/builds/x86_64_netberg_aurora_710/module/make.mk deleted file mode 100755 index e1ebfead1..000000000 --- a/packages/platforms/netberg/x86-64/aurora-710/onlp/builds/x86_64_netberg_aurora_710/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))) -x86_64_netberg_aurora_710_INCLUDES := -I $(THIS_DIR)inc -x86_64_netberg_aurora_710_INTERNAL_INCLUDES := -I $(THIS_DIR)src -x86_64_netberg_aurora_710_DEPENDMODULE_ENTRIES := init:x86_64_netberg_aurora_710 ucli:x86_64_netberg_aurora_710 - diff --git a/packages/platforms/netberg/x86-64/aurora-710/onlp/builds/x86_64_netberg_aurora_710/module/src/Makefile b/packages/platforms/netberg/x86-64/aurora-710/onlp/builds/x86_64_netberg_aurora_710/module/src/Makefile deleted file mode 100755 index 55105d14a..000000000 --- a/packages/platforms/netberg/x86-64/aurora-710/onlp/builds/x86_64_netberg_aurora_710/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 x86_64_netberg_aurora_710_ucli.c - diff --git a/packages/platforms/netberg/x86-64/aurora-710/onlp/builds/x86_64_netberg_aurora_710/module/src/fani.c b/packages/platforms/netberg/x86-64/aurora-710/onlp/builds/x86_64_netberg_aurora_710/module/src/fani.c deleted file mode 100755 index 9dd9f4690..000000000 --- a/packages/platforms/netberg/x86-64/aurora-710/onlp/builds/x86_64_netberg_aurora_710/module/src/fani.c +++ /dev/null @@ -1,327 +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. - * - * - ************************************************************ - * - * Fan Platform Implementation Defaults. - * - ***********************************************************/ -#include -#include "x86_64_netberg_aurora_710_int.h" -#include -#include -#include "platform_lib.h" - -onlp_fan_info_t fan_info[] = { - { }, /* Not used */ - { - { FAN_OID_FAN1, "FANTRAY 1-A", 0 }, - ONLP_FAN_STATUS_PRESENT, - ONLP_FAN_CAPS_GET_RPM | ONLP_FAN_CAPS_GET_PERCENTAGE, - 0, - 0, - ONLP_FAN_MODE_INVALID, - }, - { - { FAN_OID_FAN2, "FANTRAY 1-B", 0 }, - ONLP_FAN_STATUS_PRESENT, - ONLP_FAN_CAPS_GET_RPM | ONLP_FAN_CAPS_GET_PERCENTAGE, - 0, - 0, - ONLP_FAN_MODE_INVALID, - }, - { - { FAN_OID_FAN3, "FANTRAY 2-A", 0 }, - ONLP_FAN_STATUS_PRESENT, - ONLP_FAN_CAPS_GET_RPM | ONLP_FAN_CAPS_GET_PERCENTAGE, - 0, - 0, - ONLP_FAN_MODE_INVALID, - }, - { - { FAN_OID_FAN4, "FANTRAY 2-B", 0 }, - ONLP_FAN_STATUS_PRESENT, - ONLP_FAN_CAPS_GET_RPM | ONLP_FAN_CAPS_GET_PERCENTAGE, - 0, - 0, - ONLP_FAN_MODE_INVALID, - }, - { - { FAN_OID_FAN5, "FANTRAY 3-A", 0 }, - ONLP_FAN_STATUS_PRESENT, - ONLP_FAN_CAPS_GET_RPM | ONLP_FAN_CAPS_GET_PERCENTAGE, - 0, - 0, - ONLP_FAN_MODE_INVALID, - }, - { - { FAN_OID_FAN6, "FANTRAY 3-B", 0 }, - ONLP_FAN_STATUS_PRESENT, - ONLP_FAN_CAPS_GET_RPM | ONLP_FAN_CAPS_GET_PERCENTAGE, - 0, - 0, - ONLP_FAN_MODE_INVALID, - }, - { - { FAN_OID_FAN7, "FANTRAY 4-A", 0 }, - ONLP_FAN_STATUS_PRESENT, - ONLP_FAN_CAPS_GET_RPM | ONLP_FAN_CAPS_GET_PERCENTAGE, - 0, - 0, - ONLP_FAN_MODE_INVALID, - }, - { - { FAN_OID_FAN8, "FANTRAY 4-B", 0 }, - ONLP_FAN_STATUS_PRESENT, - ONLP_FAN_CAPS_GET_RPM | ONLP_FAN_CAPS_GET_PERCENTAGE, - 0, - 0, - ONLP_FAN_MODE_INVALID, - }, - { - { FAN_OID_PSU_FAN1, "PSU-1 FAN", 0 }, - ONLP_FAN_STATUS_PRESENT, - }, - { - { FAN_OID_PSU_FAN2, "PSU-2 FAN", 0 }, - ONLP_FAN_STATUS_PRESENT, - } -}; - -/* - * This function will be called prior to all of onlp_fani_* functions. - */ -int -onlp_fani_init(void) -{ - return ONLP_STATUS_OK; -} - -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_59; - switch (id) - { - case FAN_ID_FAN1: - case FAN_ID_FAN2: - offset = 1; - fan_reg_mask = FAN_1_2_PRESENT_MASK; - break; - case FAN_ID_FAN3: - case FAN_ID_FAN4: - offset = 1; - fan_reg_mask = FAN_3_4_PRESENT_MASK; - break; - case FAN_ID_FAN5: - case FAN_ID_FAN6: - offset = 0; - fan_reg_mask = FAN_5_6_PRESENT_MASK; - break; - case FAN_ID_FAN7: - case FAN_ID_FAN8: - offset = 0; - fan_reg_mask = FAN_7_8_PRESENT_MASK; - break; - default: - return ONLP_STATUS_E_INVALID; - } - - rv = onlp_i2c_readb(i2c_bus, FAN_GPIO_ADDR, 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 = 22000; - 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) { - return ONLP_STATUS_E_INTERNAL; - } - - /* fan status > 1, means failure */ - if (fan_status > 0) { - info->status |= ONLP_FAN_STATUS_FAILED; - return ONLP_STATUS_OK; - } - - rv = onlp_file_read_int(&fan_rpm, SYS_FAN_PREFIX "fan%d_input", id); - if (rv < 0) { - return ONLP_STATUS_E_INTERNAL; - } - info->rpm = fan_rpm; - - /* get speed percentage*/ - switch (id) - { - case FAN_ID_FAN1: - case FAN_ID_FAN2: - case FAN_ID_FAN3: - case FAN_ID_FAN4: - rv = onlp_file_read_int(&perc_val, SYS_FAN_PREFIX "pwm%d", - FAN_CTRL_SET1); - break; - case FAN_ID_FAN5: - case FAN_ID_FAN6: - case FAN_ID_FAN7: - case FAN_ID_FAN8: - rv = onlp_file_read_int(&perc_val, SYS_FAN_PREFIX "pwm%d", - FAN_CTRL_SET2); - break; - default: - return ONLP_STATUS_E_INVALID; - } - if (rv < 0) { - return ONLP_STATUS_E_INTERNAL; - } - - percentage = (info->rpm*100)/max_fan_speed; - info->percentage = percentage; - - return ONLP_STATUS_OK; -} - -int -sys_fan_rpm_percent_set(int perc) -{ - int rc; - rc = onlp_file_write_int(perc, SYS_FAN_PREFIX "pwm%d", FAN_CTRL_SET1); - - if (rc < 0) { - return ONLP_STATUS_E_INTERNAL; - } - - rc = onlp_file_write_int(perc, SYS_FAN_PREFIX "pwm%d", FAN_CTRL_SET2); - if (rc < 0) { - return ONLP_STATUS_E_INTERNAL; - } - - return ONLP_STATUS_OK; -} - -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 percentage) -{ - int fid, perc_val, rc; - fid = ONLP_OID_ID_GET(id); - - /* - * Set fan speed - * Driver accept value in range between 128 and 255. - * Value 128 is 50%. - * Value 200 is 80%. - * Value 255 is 100%. - */ - if (percentage == 100) { - perc_val = 255; - } else if (percentage == 80) { - perc_val = 200; - } else if (percentage == 50) { - perc_val = 128; - } else { - return ONLP_STATUS_E_INVALID; - } - - switch (fid) - { - case FAN_ID_FAN1: - case FAN_ID_FAN2: - case FAN_ID_FAN3: - case FAN_ID_FAN4: - case FAN_ID_FAN5: - case FAN_ID_FAN6: - case FAN_ID_FAN7: - case FAN_ID_FAN8: - rc = sys_fan_rpm_percent_set(perc_val); - break; - default: - return ONLP_STATUS_E_INVALID; - } - return rc; -} - -int -onlp_fani_info_get(onlp_oid_t id, onlp_fan_info_t* rv) -{ - int fan_id ,rc; - - fan_id = ONLP_OID_ID_GET(id); - *rv = fan_info[fan_id]; - rv->caps |= ONLP_FAN_CAPS_GET_RPM; - - switch (fan_id) { - case FAN_ID_FAN1: - case FAN_ID_FAN2: - case FAN_ID_FAN3: - case FAN_ID_FAN4: - case FAN_ID_FAN5: - case FAN_ID_FAN6: - case FAN_ID_FAN7: - case FAN_ID_FAN8: - rc = sys_fan_info_get(rv, fan_id); - break; - case FAN_ID_PSU_FAN1: - case FAN_ID_PSU_FAN2: - rc = psu_fan_info_get(rv, fan_id); - break; - default: - return ONLP_STATUS_E_INTERNAL; - break; - } - - return rc; -} diff --git a/packages/platforms/netberg/x86-64/aurora-710/onlp/builds/x86_64_netberg_aurora_710/module/src/ledi.c b/packages/platforms/netberg/x86-64/aurora-710/onlp/builds/x86_64_netberg_aurora_710/module/src/ledi.c deleted file mode 100755 index ea4bc2759..000000000 --- a/packages/platforms/netberg/x86-64/aurora-710/onlp/builds/x86_64_netberg_aurora_710/module/src/ledi.c +++ /dev/null @@ -1,228 +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 -#include -#include -#include -#include - -#include "platform_lib.h" - -/* - * Get the information for the given LED OID. - */ -static onlp_led_info_t led_info[] = -{ - { }, /* Not used */ - { - { LED_OID_SYSTEM, "Chassis LED 1 (SYS LED)", 0 }, - ONLP_LED_STATUS_PRESENT, - ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_GREEN, - }, - { - { LED_OID_FAN, "Chassis LED 2 (FAN 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_PSU1, "Chassis LED 3 (PSU1 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_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. - */ -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, pw_exist, pw_good, rc, psu_mask, fan_id; - int exist_offset, good_offset, i2c_bus; - 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]; - - if (id == LED_OID_PSU1 || id == LED_OID_PSU2) { - - psu_mask = PSU_MUX_MASK; - - if (id == LED_OID_PSU1) { - i2c_bus = I2C_BUS_PSU1; - exist_offset = PSU1_PRESENT_OFFSET; - good_offset = PSU1_PWGOOD_OFFSET; - } else { - i2c_bus = I2C_BUS_PSU2; - exist_offset = PSU2_PRESENT_OFFSET; - good_offset = PSU2_PWGOOD_OFFSET; - } - /* check psu status */ - if ((rc = psu_present_get(&pw_exist, exist_offset, i2c_bus, psu_mask)) - != ONLP_STATUS_OK) { - return ONLP_STATUS_E_INTERNAL; - } - if ((rc = psu_pwgood_get(&pw_good, good_offset, i2c_bus, 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; -} - -/* - * 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) -{ - int led_id, rc; - - led_id = ONLP_OID_ID_GET(id); - switch (led_id) { - case LED_SYSTEM_LED: - rc = system_led_set(mode); - break; - case LED_FAN_LED: - rc = fan_led_set(mode); - break; - case LED_PSU1_LED: - rc = psu1_led_set(mode); - break; - 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; - } - - return rc; -} - -int -onlp_ledi_ioctl(onlp_oid_t id, va_list vargs) -{ - return ONLP_STATUS_OK; -} diff --git a/packages/platforms/netberg/x86-64/aurora-710/onlp/builds/x86_64_netberg_aurora_710/module/src/make.mk b/packages/platforms/netberg/x86-64/aurora-710/onlp/builds/x86_64_netberg_aurora_710/module/src/make.mk deleted file mode 100755 index a12aca6ad..000000000 --- a/packages/platforms/netberg/x86-64/aurora-710/onlp/builds/x86_64_netberg_aurora_710/module/src/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. -# -# -############################################################ -# -# -# -############################################################ - -LIBRARY := x86_64_netberg_aurora_710 -$(LIBRARY)_SUBDIR := $(dir $(lastword $(MAKEFILE_LIST))) -#$(LIBRARY)_LAST := 1 -include $(BUILDER)/lib.mk diff --git a/packages/platforms/netberg/x86-64/aurora-710/onlp/builds/x86_64_netberg_aurora_710/module/src/platform_lib.c b/packages/platforms/netberg/x86-64/aurora-710/onlp/builds/x86_64_netberg_aurora_710/module/src/platform_lib.c deleted file mode 100755 index aedcd64a0..000000000 --- a/packages/platforms/netberg/x86-64/aurora-710/onlp/builds/x86_64_netberg_aurora_710/module/src/platform_lib.c +++ /dev/null @@ -1,624 +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 -#include -#include -#include -#include -#include - -#include "platform_lib.h" - -int -psu_thermal_get(onlp_thermal_info_t* info, int thermal_id) -{ - int pw_exist, pw_good, exist_offset, good_offset; - int offset, i2c_bus, rc; - int value, buf, psu_mask; - unsigned int y_value = 0; - unsigned char n_value = 0; - unsigned int temp = 0; - char result[32]; - - if (thermal_id == THERMAL_ID_PSU1_1) { - i2c_bus = I2C_BUS_PSU1; - offset = PSU_THERMAL1_OFFSET; - exist_offset = PSU1_PRESENT_OFFSET; - good_offset = PSU1_PWGOOD_OFFSET; - } else if (thermal_id == THERMAL_ID_PSU1_2) { - i2c_bus = I2C_BUS_PSU1; - offset = PSU_THERMAL2_OFFSET; - exist_offset = PSU1_PRESENT_OFFSET; - good_offset = PSU1_PWGOOD_OFFSET; - } else if (thermal_id == THERMAL_ID_PSU2_1) { - i2c_bus = I2C_BUS_PSU2; - offset = PSU_THERMAL1_OFFSET; - exist_offset = PSU2_PRESENT_OFFSET; - good_offset = PSU2_PWGOOD_OFFSET; - } else if (thermal_id == THERMAL_ID_PSU2_2) { - i2c_bus = I2C_BUS_PSU2; - offset = PSU_THERMAL2_OFFSET; - exist_offset = PSU2_PRESENT_OFFSET; - good_offset = PSU2_PWGOOD_OFFSET; - } - - psu_mask = PSU_MUX_MASK; - - /* check psu status */ - if ((rc = psu_present_get(&pw_exist, exist_offset, I2C_BUS_0, psu_mask)) - != ONLP_STATUS_OK) { - return ONLP_STATUS_E_INTERNAL; - } - - 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, good_offset, I2C_BUS_0, psu_mask)) - != ONLP_STATUS_OK) { - return ONLP_STATUS_E_INTERNAL; - } - - if (pw_good != PSU_STATUS_POWER_GOOD) { - info->mcelsius = 0; - return ONLP_STATUS_OK; - } - - value = onlp_i2c_readw(i2c_bus, PSU_REG, offset, ONLP_I2C_F_FORCE); - - y_value = (value & 0x07FF); - if ((value & 0x8000)&&(y_value)) { - n_value = 0xF0 + (((value) >> 11) & 0x0F); - n_value = (~n_value) +1; - temp = (unsigned int)(1<> 11) & 0x0F); - snprintf(result, sizeof(result), "%d", (y_value*(1<mcelsius = (int)(buf * 1000); - - return ONLP_STATUS_OK; -} - -int -psu_fan_info_get(onlp_fan_info_t* info, int id) -{ - int pw_exist, pw_good, exist_offset, good_offset; - int i2c_bus, psu_mask, rc; - unsigned int tmp_fan_rpm, fan_rpm; - - if (id == FAN_ID_PSU_FAN1) { - i2c_bus = I2C_BUS_PSU1; - exist_offset = PSU1_PRESENT_OFFSET; - good_offset = PSU1_PWGOOD_OFFSET; - } else if (id == FAN_ID_PSU_FAN2) { - i2c_bus = I2C_BUS_PSU2; - exist_offset = PSU2_PRESENT_OFFSET; - good_offset = PSU2_PWGOOD_OFFSET; - } else { - return ONLP_STATUS_E_INTERNAL; - } - - psu_mask = PSU_MUX_MASK; - - /* check psu status */ - if ((rc = psu_present_get(&pw_exist, exist_offset, I2C_BUS_0, psu_mask)) - != ONLP_STATUS_OK) { - return ONLP_STATUS_E_INTERNAL; - } - - 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, good_offset, I2C_BUS_0, psu_mask)) - != ONLP_STATUS_OK) { - return ONLP_STATUS_E_INTERNAL; - } - - if (pw_good != PSU_STATUS_POWER_GOOD) { - info->rpm = 0; - return ONLP_STATUS_OK; - } - - tmp_fan_rpm = onlp_i2c_readw(i2c_bus, PSU_REG, PSU_FAN_RPM_OFFSET, ONLP_I2C_F_FORCE); - - fan_rpm = (unsigned int)tmp_fan_rpm; - fan_rpm = (fan_rpm & 0x07FF) * (1 << ((fan_rpm >> 11) & 0x1F)); - info->rpm = (int)fan_rpm; - - return ONLP_STATUS_OK; -} - -int -psu_vout_get(onlp_psu_info_t* info, int i2c_bus) -{ - int v_value = 0; - int n_value = 0; - unsigned int temp = 0; - char result[32]; - double dvalue; - memset(result, 0, sizeof(result)); - - n_value = onlp_i2c_readb(i2c_bus, PSU_REG, PSU_VOUT_OFFSET1, ONLP_I2C_F_FORCE); - if (n_value < 0) { - return ONLP_STATUS_E_INTERNAL; - } - - v_value = onlp_i2c_readw(i2c_bus, PSU_REG, PSU_VOUT_OFFSET2, ONLP_I2C_F_FORCE); - if (v_value < 0) { - return ONLP_STATUS_E_INTERNAL; - } - - if (n_value & 0x10) { - n_value = 0xF0 + (n_value & 0x0F); - n_value = (~n_value) +1; - temp = (unsigned int)(1< 0.0) { - info->caps |= ONLP_PSU_CAPS_VOUT; - info->mvout = (int)(dvalue * 1000); - } - - return ONLP_STATUS_OK; -} - -int -psu_iout_get(onlp_psu_info_t* info, int i2c_bus) -{ - int value; - unsigned int y_value = 0; - unsigned char n_value = 0; - unsigned int temp = 0; - char result[32]; - memset(result, 0, sizeof(result)); - double dvalue; - - value = onlp_i2c_readw(i2c_bus, PSU_REG, PSU_IOUT_OFFSET, ONLP_I2C_F_FORCE); - if (value < 0) { - return ONLP_STATUS_E_INTERNAL; - } - - y_value = (value & 0x07FF); - if ((value & 0x8000)&&(y_value)) - { - n_value = 0xF0 + (((value) >> 11) & 0x0F); - n_value = (~n_value) +1; - temp = (unsigned int)(1<> 11) & 0x0F); - snprintf(result, sizeof(result), "%d", (y_value*(1< 0.0) { - info->caps |= ONLP_PSU_CAPS_IOUT; - info->miout = (int)(dvalue * 1000); - } - - return ONLP_STATUS_OK; -} - -int -psu_pout_get(onlp_psu_info_t* info, int i2c_bus) -{ - int value; - unsigned int y_value = 0; - unsigned char n_value = 0; - unsigned int temp = 0; - char result[32]; - memset(result, 0, sizeof(result)); - double dvalue; - - value = onlp_i2c_readw(i2c_bus, PSU_REG, PSU_POUT_OFFSET, ONLP_I2C_F_FORCE); - if (value < 0) { - return ONLP_STATUS_E_INTERNAL; - } - - y_value = (value & 0x07FF); - if ((value & 0x8000)&&(y_value)) - { - n_value = 0xF0 + (((value) >> 11) & 0x0F); - n_value = (~n_value) +1; - temp = (unsigned int)(1<> 11) & 0x0F); - snprintf(result, sizeof(result), "%d", (y_value*(1< 0.0) { - info->caps |= ONLP_PSU_CAPS_POUT; - info->mpout = (int)(dvalue * 1000); - } - - return ONLP_STATUS_OK; -} - -int -psu_pin_get(onlp_psu_info_t* info, int i2c_bus) -{ - int value; - unsigned int y_value = 0; - unsigned char n_value = 0; - unsigned int temp = 0; - char result[32]; - memset(result, 0, sizeof(result)); - double dvalue; - - value = onlp_i2c_readw(i2c_bus, PSU_REG, PSU_PIN_OFFSET, ONLP_I2C_F_FORCE); - if (value < 0) { - return ONLP_STATUS_E_INTERNAL; - } - - y_value = (value & 0x07FF); - if ((value & 0x8000)&&(y_value)) - { - n_value = 0xF0 + (((value) >> 11) & 0x0F); - n_value = (~n_value) +1; - temp = (unsigned int)(1<> 11) & 0x0F); - snprintf(result, sizeof(result), "%d", (y_value*(1< 0.0) { - info->caps |= ONLP_PSU_CAPS_PIN; - info->mpin = (int)(dvalue * 1000); - } - - return ONLP_STATUS_OK; -} - -int -psu_eeprom_get(onlp_psu_info_t* info, int id) -{ - uint8_t data[256]; - char eeprom_path[128]; - int data_len, i, rc; - memset(data, 0, sizeof(data)); - memset(eeprom_path, 0, sizeof(eeprom_path)); - - if (id == PSU_ID_PSU1) { - rc = onlp_file_read(data, sizeof(data), &data_len, PSU1_EEPROM_PATH); - } else { - rc = onlp_file_read(data, sizeof(data), &data_len, PSU2_EEPROM_PATH); - } - - if (rc == ONLP_STATUS_OK) - { - i = 11; - - /* Manufacturer Name */ - data_len = (data[i]&0x0f); - i++; - i += data_len; - - /* Product Name */ - data_len = (data[i]&0x0f); - i++; - memcpy(info->model, (char *) &(data[i]), data_len); - i += data_len; - - /* Product part,model number */ - data_len = (data[i]&0x0f); - i++; - i += data_len; - - /* Product Version */ - data_len = (data[i]&0x0f); - i++; - i += data_len; - - /* Product Serial Number */ - data_len = (data[i]&0x0f); - i++; - memcpy(info->serial, (char *) &(data[i]), data_len); - } else { - strcpy(info->model, "Missing"); - strcpy(info->serial, "Missing"); - } - - return ONLP_STATUS_OK; -} - - -int -psu_present_get(int *pw_exist, int exist_offset, int i2c_bus, int psu_mask) -{ - int psu_pres; - - psu_pres = onlp_i2c_readb(i2c_bus, PSU_STATE_REG, 0x0, - ONLP_I2C_F_FORCE); - if (psu_pres < 0) { - return ONLP_STATUS_E_INTERNAL; - } - - *pw_exist = (((psu_pres >> exist_offset) & psu_mask) ? 0 : 1); - return ONLP_STATUS_OK; -} - -int -psu_pwgood_get(int *pw_good, int good_offset, int i2c_bus, int psu_mask) -{ - int psu_pwgood; - - psu_pwgood = onlp_i2c_readb(i2c_bus, PSU_STATE_REG, 0x0, - ONLP_I2C_F_FORCE); - if (psu_pwgood < 0) { - return ONLP_STATUS_E_INTERNAL; - } - - *pw_good = (((psu_pwgood >> good_offset) & psu_mask) ? 1 : 0); - return ONLP_STATUS_OK; -} - -int -qsfp_present_get(int port, int *pres_val) -{ - int reg_addr, val, offset; - - if (port >= 1 && port <= 8) { - reg_addr = QSFP_PRES_REG1; - offset = QSFP_PRES_OFFSET1; - } else if (port >= 9 && port <= 16) { - reg_addr = QSFP_PRES_REG1; - offset = QSFP_PRES_OFFSET2; - } else if (port >= 17 && port <= 24) { - reg_addr = QSFP_PRES_REG2; - offset = QSFP_PRES_OFFSET1; - } else if (port >= 25 && port <= 32) { - reg_addr = QSFP_PRES_REG2; - offset = QSFP_PRES_OFFSET2; - } else { - return ONLP_STATUS_E_INTERNAL; - } - - val = onlp_i2c_readb(I2C_BUS_6, reg_addr, offset, ONLP_I2C_F_FORCE); - if (val < 0) { - return ONLP_STATUS_E_INTERNAL; - } - - *pres_val = val; - - return ONLP_STATUS_OK; -} - - -int -system_led_set(onlp_led_mode_t mode) -{ - int rc; - if(mode == ONLP_LED_MODE_GREEN) { - rc = onlp_i2c_modifyb(I2C_BUS_50, LED_REG, LED_OFFSET, LED_SYS_AND_MASK, - LED_SYS_GMASK, ONLP_I2C_F_FORCE); - } - else if(mode == ONLP_LED_MODE_ORANGE) { - rc = onlp_i2c_modifyb(I2C_BUS_50, LED_REG, LED_OFFSET, LED_SYS_AND_MASK, - LED_SYS_YMASK, ONLP_I2C_F_FORCE); - } else { - return ONLP_STATUS_E_INTERNAL; - } - - if (rc < 0) { - return ONLP_STATUS_E_INTERNAL; - } - - return ONLP_STATUS_OK; -} - -int -fan_led_set(onlp_led_mode_t mode) -{ - int rc; - - if(mode == ONLP_LED_MODE_GREEN ) { - rc = onlp_i2c_modifyb(I2C_BUS_50, LED_REG, LED_OFFSET, LED_FAN_AND_MASK, - LED_FAN_GMASK, ONLP_I2C_F_FORCE); - } - else if(mode == ONLP_LED_MODE_ORANGE) { - rc = onlp_i2c_modifyb(I2C_BUS_50, LED_REG, LED_OFFSET, LED_FAN_AND_MASK, - LED_FAN_YMASK, ONLP_I2C_F_FORCE); - } else { - return ONLP_STATUS_E_INTERNAL; - } - - if (rc < 0) { - return ONLP_STATUS_E_INTERNAL; - } - - return ONLP_STATUS_OK; -} - -int -psu1_led_set(onlp_led_mode_t mode) -{ - int rc; - if(mode == ONLP_LED_MODE_GREEN) { - rc = onlp_i2c_modifyb(I2C_BUS_50, LED_REG, LED_PWOK_OFFSET, - LED_PSU1_ON_AND_MASK, LED_PSU1_ON_OR_MASK, - ONLP_I2C_F_FORCE); - rc = onlp_i2c_modifyb(I2C_BUS_50, LED_REG, LED_OFFSET, - LED_PSU1_AND_MASK, LED_PSU1_GMASK, - ONLP_I2C_F_FORCE); - } else if(mode == ONLP_LED_MODE_ORANGE) { - rc = onlp_i2c_modifyb(I2C_BUS_50, LED_REG, LED_PWOK_OFFSET, - LED_PSU1_ON_AND_MASK, LED_PSU1_ON_OR_MASK, - ONLP_I2C_F_FORCE); - rc = onlp_i2c_modifyb(I2C_BUS_50, 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_50, LED_REG, LED_PWOK_OFFSET, - LED_PSU1_OFF_AND_MASK, LED_PSU1_OFF_OR_MASK, - ONLP_I2C_F_FORCE); - } else { - return ONLP_STATUS_E_INTERNAL; - } - - if (rc < 0) { - return ONLP_STATUS_E_INTERNAL; - } - - return ONLP_STATUS_OK; -} - -int -psu2_led_set(onlp_led_mode_t mode) -{ - int rc; - if(mode == ONLP_LED_MODE_GREEN) { - rc = onlp_i2c_modifyb(I2C_BUS_50, LED_REG, LED_PWOK_OFFSET, - LED_PSU2_ON_AND_MASK, LED_PSU2_ON_OR_MASK, - ONLP_I2C_F_FORCE); - rc = onlp_i2c_modifyb(I2C_BUS_50, LED_REG, LED_OFFSET, - LED_PSU2_AND_MASK, LED_PSU2_GMASK, - ONLP_I2C_F_FORCE); - } else if(mode == ONLP_LED_MODE_ORANGE) { - rc = onlp_i2c_modifyb(I2C_BUS_50, LED_REG, LED_PWOK_OFFSET, - LED_PSU2_ON_AND_MASK, LED_PSU2_ON_OR_MASK, - ONLP_I2C_F_FORCE); - rc = onlp_i2c_modifyb(I2C_BUS_50, 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_50, LED_REG, LED_PWOK_OFFSET, - LED_PSU2_OFF_AND_MASK, LED_PSU2_OFF_OR_MASK, - ONLP_I2C_F_FORCE); - } else { - return ONLP_STATUS_E_INTERNAL; - } - - - if (rc < 0) { - return ONLP_STATUS_E_INTERNAL; - } - - 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; - - 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_59, FAN_GPIO_ADDR, offset, 0xFC, - 0x02, ONLP_I2C_F_FORCE); - } else if (mode == ONLP_LED_MODE_ORANGE) { - rc = onlp_i2c_modifyb(I2C_BUS_59, FAN_GPIO_ADDR, offset, 0xFC, - 0x01, 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_59, FAN_GPIO_ADDR, offset, 0xCF, - 0x20, ONLP_I2C_F_FORCE); - } else if (mode == ONLP_LED_MODE_ORANGE) { - rc = onlp_i2c_modifyb(I2C_BUS_59, FAN_GPIO_ADDR, offset, 0xCF, - 0x10, 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) -{ - int cpld_release, cpld_version, cpld_rev; - - cpld_rev = onlp_i2c_readb(I2C_BUS_44, CPLD_REG, CPLD_VER_OFFSET, ONLP_I2C_F_FORCE); - if (cpld_rev < 0) { - return ONLP_STATUS_E_INTERNAL; - } - - cpld_release = (((cpld_rev) >> 6 & 0x01)); - cpld_version = (((cpld_rev) & 0x3F)); - - pi->cpld_versions = aim_fstrdup( - "CPLD is %d version(0:RD 1:Release), Revision is 0x%02x\n", - cpld_release, cpld_version); - - return ONLP_STATUS_OK; -} diff --git a/packages/platforms/netberg/x86-64/aurora-710/onlp/builds/x86_64_netberg_aurora_710/module/src/platform_lib.h b/packages/platforms/netberg/x86-64/aurora-710/onlp/builds/x86_64_netberg_aurora_710/module/src/platform_lib.h deleted file mode 100755 index 08f1e04dc..000000000 --- a/packages/platforms/netberg/x86-64/aurora-710/onlp/builds/x86_64_netberg_aurora_710/module/src/platform_lib.h +++ /dev/null @@ -1,307 +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. - * - * - ************************************************************ - * - * - * - ***********************************************************/ -#ifndef __PLATFORM_LIB_H__ -#define __PLATFORM_LIB_H__ - -#include -#include -#include -#include -#include -#include "x86_64_netberg_aurora_710_int.h" -#include "x86_64_netberg_aurora_710_log.h" - -#include -#define SYS_CPU_TEMP_PREFIX "/sys/class/hwmon/hwmon0/" -#define SYS_CORE_TEMP_PREFIX "/sys/class/hwmon/hwmon2/" -#define SYS_CPU_BOARD_TEMP_PREFIX "/sys/class/hwmon/hwmon3/" -#define SYS_PSU1_NEAR_TEMP_PREFIX "/sys/class/hwmon/hwmon4/" -#define SYS_PSU2_NEAR_TEMP_PREFIX "/sys/class/hwmon/hwmon7/" -#define SYS_MAC_REAR_TEMP_PREFIX "/sys/class/hwmon/hwmon5/" -#define SYS_QSFP_NEAR_TEMP_PREFIX "/sys/class/hwmon/hwmon6/" -#define SYS_FAN_PREFIX "/sys/class/hwmon/hwmon1/device/" -#define SYS_EEPROM_PATH "/sys/bus/i2c/devices/0-0055/eeprom" -#define SYS_EEPROM_SIZE 512 -#define PSU1_EEPROM_PATH "/sys/bus/i2c/devices/58-0050/eeprom" -#define PSU2_EEPROM_PATH "/sys/bus/i2c/devices/57-0050/eeprom" -#define PSU_STATUS_PRESENT 1 -#define PSU_STATUS_POWER_GOOD 1 -#define FAN_PRESENT 0 -#define FAN_CTRL_SET1 1 -#define FAN_CTRL_SET2 2 -#define MAX_SYS_FAN_NUM 8 -#define BOARD_THERMAL_NUM 6 -#define SYS_FAN_NUM 8 -//#define QSFP_NUM 32 -#define PORT_NUM 34 - -#define THERMAL_NUM 15 -#define LED_NUM 4 -#define FAN_NUM 10 - - - -#define THERMAL_SHUTDOWN_DEFAULT 105000 - -#define THERMAL_ERROR_DEFAULT 95000 -#define THERMAL_ERROR_FAN_PERC 100 - -#define THERMAL_WARNING_DEFAULT 77000 -#define THERMAL_WARNING_FAN_PERC 80 - -#define THERMAL_NORMAL_DEFAULT 72000 -#define THERMAL_NORMAL_FAN_PERC 50 - -/* I2C bus */ -#define I2C_BUS_0 0 -#define I2C_BUS_1 1 -#define I2C_BUS_2 2 -#define I2C_BUS_3 3 -#define I2C_BUS_4 4 -#define I2C_BUS_5 5 -#define I2C_BUS_6 6 -#define I2C_BUS_7 7 -#define I2C_BUS_8 8 -#define I2C_BUS_9 9 -#define I2C_BUS_44 44 /* cpld */ -#define I2C_BUS_50 50 /* SYS LED */ -#define I2C_BUS_57 (57) /* PSU2 */ -#define I2C_BUS_58 (58) /* PSU1 */ -#define I2C_BUS_59 59 /* FRU */ - -#define I2C_BUS_PSU1 I2C_BUS_58 /* PSU1 */ -#define I2C_BUS_PSU2 I2C_BUS_57 /* PSU2 */ - -/* PSU */ -#define PSU_MUX_MASK 0x01 - -#define PSU_THERMAL1_OFFSET 0x8D -#define PSU_THERMAL2_OFFSET 0x8E -#define PSU_THERMAL_REG 0x58 -#define PSU_FAN_RPM_REG 0x58 -#define PSU_FAN_RPM_OFFSET 0x90 -#define PSU_REG 0x58 -#define PSU_VOUT_OFFSET1 0x20 -#define PSU_VOUT_OFFSET2 0x8B -#define PSU_IOUT_OFFSET 0x8C -#define PSU_POUT_OFFSET 0x96 -#define PSU_PIN_OFFSET 0x97 - -#define PSU_STATE_REG 0x25 -#define PSU1_PRESENT_OFFSET 0x04 -#define PSU2_PRESENT_OFFSET 0x01 -#define PSU1_PWGOOD_OFFSET 0x03 -#define PSU2_PWGOOD_OFFSET 0x00 - -/* LED */ -#define LED_REG 0x75 -#define LED_OFFSET 0x02 -#define LED_PWOK_OFFSET 0x03 - -#define LED_SYS_AND_MASK 0xFE -#define LED_SYS_GMASK 0x01 -#define LED_SYS_YMASK 0x00 - -#define LED_FAN_AND_MASK 0xF9 -#define LED_FAN_GMASK 0x02 -#define LED_FAN_YMASK 0x06 - -#define LED_PSU2_AND_MASK 0xEF -#define LED_PSU2_GMASK 0x00 -#define LED_PSU2_YMASK 0x10 -#define LED_PSU2_ON_AND_MASK 0xFD -#define LED_PSU2_ON_OR_MASK 0x02 -#define LED_PSU2_OFF_AND_MASK 0xFD -#define LED_PSU2_OFF_OR_MASK 0x00 -#define LED_PSU1_AND_MASK 0xF7 -#define LED_PSU1_GMASK 0x00 -#define LED_PSU1_YMASK 0x08 -#define LED_PSU1_ON_AND_MASK 0xFE -#define LED_PSU1_ON_OR_MASK 0x01 -#define LED_PSU1_OFF_AND_MASK 0xFE -#define LED_PSU1_OFF_OR_MASK 0x00 -#define LED_SYS_ON_MASK 0x00 -#define LED_SYS_OFF_MASK 0x33 - -/* SYS */ -#define CPLD_REG 0x33 -#define CPLD_VER_OFFSET 0x01 - -/* QSFP */ -#define QSFP_PRES_REG1 0x20 -#define QSFP_PRES_REG2 0x21 -#define QSFP_PRES_OFFSET1 0x00 -#define QSFP_PRES_OFFSET2 0x01 - -/* FAN */ -#define FAN_GPIO_ADDR 0x20 -#define FAN_1_2_PRESENT_MASK 0x40 -#define FAN_3_4_PRESENT_MASK 0x04 -#define FAN_5_6_PRESENT_MASK 0x40 -#define FAN_7_8_PRESENT_MASK 0x04 - -/** 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 */ -typedef enum led_id_e { - LED_SYSTEM_LED = 1, - 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 */ -typedef enum thermal_oid_e { - THERMAL_OID_FRONT_MAC = ONLP_THERMAL_ID_CREATE(1), - THERMAL_OID_ASIC = ONLP_THERMAL_ID_CREATE(2), - THERMAL_OID_CPU1 = ONLP_THERMAL_ID_CREATE(3), - THERMAL_OID_CPU2 = ONLP_THERMAL_ID_CREATE(4), - THERMAL_OID_CPU3 = ONLP_THERMAL_ID_CREATE(5), - THERMAL_OID_CPU4 = ONLP_THERMAL_ID_CREATE(6), - THERMAL_OID_PSU1_1 = ONLP_THERMAL_ID_CREATE(7), - THERMAL_OID_PSU1_2 = ONLP_THERMAL_ID_CREATE(8), - THERMAL_OID_PSU2_1 = ONLP_THERMAL_ID_CREATE(9), - THERMAL_OID_PSU2_2 = ONLP_THERMAL_ID_CREATE(10), - THERMAL_OID_CPU_BOARD = ONLP_THERMAL_ID_CREATE(11), - THERMAL_OID_PSU1_NEAR = ONLP_THERMAL_ID_CREATE(12), - THERMAL_OID_PSU2_NEAR = ONLP_THERMAL_ID_CREATE(13), - THERMAL_OID_MAC_REAR = ONLP_THERMAL_ID_CREATE(14), - THERMAL_OID_QSFP_NEAR = ONLP_THERMAL_ID_CREATE(15), -} thermal_oid_t; - -/** thermal_id */ -typedef enum thermal_id_e { - THERMAL_ID_FRONT_MAC = 1, - THERMAL_ID_ASIC = 2, - THERMAL_ID_CPU1 = 3, - THERMAL_ID_CPU2 = 4, - THERMAL_ID_CPU3 = 5, - THERMAL_ID_CPU4 = 6, - THERMAL_ID_PSU1_1 = 7, - THERMAL_ID_PSU1_2 = 8, - THERMAL_ID_PSU2_1 = 9, - THERMAL_ID_PSU2_2 = 10, - THERMAL_ID_CPU_BOARD = 11, - THERMAL_ID_PSU1_NEAR = 12, - THERMAL_ID_PSU2_NEAR = 13, - THERMAL_ID_MAC_REAR = 14, - THERMAL_ID_QSFP_NEAR = 15, -} thermal_id_t; - -/* Shortcut for CPU thermal threshold value. */ -#define THERMAL_THRESHOLD_INIT_DEFAULTS \ - { THERMAL_WARNING_DEFAULT, \ - THERMAL_ERROR_DEFAULT, \ - THERMAL_SHUTDOWN_DEFAULT } - -/** 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_PSU_FAN1 = ONLP_FAN_ID_CREATE(9), - FAN_OID_PSU_FAN2 = ONLP_FAN_ID_CREATE(10) -} fan_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_PSU_FAN1 = 9, - FAN_ID_PSU_FAN2 = 10 -} fan_id_t; - -/** led_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; - -/** fan_id */ -typedef enum psu_id_e { - PSU_ID_PSU1 = 1, - PSU_ID_PSU2 = 2 -} psu_id_t; - -int psu_thermal_get(onlp_thermal_info_t* info, int id); - -int psu_fan_info_get(onlp_fan_info_t* info, int id); - -int psu_vout_get(onlp_psu_info_t* info, int i2c_bus); - -int psu_iout_get(onlp_psu_info_t* info, int i2c_bus); - -int psu_pout_get(onlp_psu_info_t* info, int i2c_bus); - -int psu_pin_get(onlp_psu_info_t* info, int i2c_bus); - -int psu_eeprom_get(onlp_psu_info_t* info, int id); - -int psu_present_get(int *pw_exist, int exist_offset, - int i2c_bus, int psu_mask); - -int psu_pwgood_get(int *pw_good, int good_offset, int i2c_bus, int psu_mask); - -int psu2_led_set(onlp_led_mode_t mode); - -int psu1_led_set(onlp_led_mode_t mode); - -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); - -#endif /* __PLATFORM_LIB_H__ */ diff --git a/packages/platforms/netberg/x86-64/aurora-710/onlp/builds/x86_64_netberg_aurora_710/module/src/psui.c b/packages/platforms/netberg/x86-64/aurora-710/onlp/builds/x86_64_netberg_aurora_710/module/src/psui.c deleted file mode 100755 index 6ef1c98f8..000000000 --- a/packages/platforms/netberg/x86-64/aurora-710/onlp/builds/x86_64_netberg_aurora_710/module/src/psui.c +++ /dev/null @@ -1,160 +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 - -#include "platform_lib.h" - -static onlp_psu_info_t pinfo[] = -{ - { }, /* Not used */ - { - { - PSU_OID_PSU1, - "PSU-1", - 0, - { - FAN_OID_PSU_FAN1, - }, - } - }, - { - { - PSU_OID_PSU2, - "PSU-2", - 0, - { - FAN_OID_PSU_FAN2, - }, - } - } -}; - -int -onlp_psui_init(void) -{ - return ONLP_STATUS_OK; -} - -int -psu_status_info_get(int id, onlp_psu_info_t *info) -{ - int pw_exist, exist_offset; - int pw_good, good_offset; - int rc, psu_mask, i2c_bus; - - if (id == PSU_ID_PSU1) { - i2c_bus = I2C_BUS_PSU1; - exist_offset = PSU1_PRESENT_OFFSET; - good_offset = PSU1_PWGOOD_OFFSET; - } else if (id == PSU_ID_PSU2) { - i2c_bus = I2C_BUS_PSU2; - exist_offset = PSU2_PRESENT_OFFSET; - good_offset = PSU2_PWGOOD_OFFSET; - } else { - return ONLP_STATUS_E_INTERNAL; - } - - psu_mask = PSU_MUX_MASK; - - /* Get power present status */ - if ((rc = psu_present_get(&pw_exist, exist_offset, I2C_BUS_0, psu_mask)) - != ONLP_STATUS_OK) { - return ONLP_STATUS_E_INTERNAL; - } - - if (pw_exist != PSU_STATUS_PRESENT) { - info->status &= ~ONLP_PSU_STATUS_PRESENT; - info->status |= ONLP_PSU_STATUS_FAILED; - return ONLP_STATUS_OK; - } - info->status |= ONLP_PSU_STATUS_PRESENT; - - /* Get power good status */ - if ((rc = psu_pwgood_get(&pw_good, good_offset, I2C_BUS_0, psu_mask)) - != ONLP_STATUS_OK) { - return ONLP_STATUS_E_INTERNAL; - } - - 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 */ - if ((rc = psu_eeprom_get(info, id)) != ONLP_STATUS_OK) { - return ONLP_STATUS_E_INTERNAL; - } - - /* Get power iout status */ - if ((rc = psu_iout_get(info, i2c_bus)) != ONLP_STATUS_OK) { - return ONLP_STATUS_E_INTERNAL; - } - - /* Get power pout status */ - if ((rc = psu_pout_get(info, i2c_bus)) != ONLP_STATUS_OK) { - return ONLP_STATUS_E_INTERNAL; - } - - /* Get power pin status */ - if ((rc = psu_pin_get(info, i2c_bus)) != ONLP_STATUS_OK) { - return ONLP_STATUS_E_INTERNAL; - } - - /* Get power vout status */ - if ((rc = psu_vout_get(info, i2c_bus)) != ONLP_STATUS_OK) { - return ONLP_STATUS_E_INTERNAL; - } - - return ONLP_STATUS_OK; -} - -int -onlp_psui_info_get(onlp_oid_t id, onlp_psu_info_t* info) -{ - int pid; - - pid = ONLP_OID_ID_GET(id); - memset(info, 0, sizeof(onlp_psu_info_t)); - - /* Set the onlp_oid_hdr_t */ - *info = pinfo[pid]; - - switch (pid) { - case PSU_ID_PSU1: - case PSU_ID_PSU2: - return psu_status_info_get(pid, info); - break; - default: - return ONLP_STATUS_E_UNSUPPORTED; - break; - } - - return ONLP_STATUS_OK; - - -} diff --git a/packages/platforms/netberg/x86-64/aurora-710/onlp/builds/x86_64_netberg_aurora_710/module/src/sfpi.c b/packages/platforms/netberg/x86-64/aurora-710/onlp/builds/x86_64_netberg_aurora_710/module/src/sfpi.c deleted file mode 100755 index 93db29f34..000000000 --- a/packages/platforms/netberg/x86-64/aurora-710/onlp/builds/x86_64_netberg_aurora_710/module/src/sfpi.c +++ /dev/null @@ -1,171 +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 -#include -#include -#include -#include -#include -#include -#include "x86_64_netberg_aurora_710_log.h" -#include "platform_lib.h" - -int -onlp_sfpi_init(void) -{ - return ONLP_STATUS_OK; -} - -int -onlp_sfpi_bitmap_get(onlp_sfp_bitmap_t* bmap) -{ - int p; - for(p = 1; p <= PORT_NUM; p++) { - AIM_BITMAP_SET(bmap, p); - } - return ONLP_STATUS_OK; -} - -int -onlp_sfpi_is_present(int port) -{ - int status, rc, gpio_num; - - if (port >= 1 && port <= 16) { - gpio_num = 496 + ((port - 1) ^ 1); - } else if (port >= 17 && port <= 32) { - gpio_num = 464 + ((port - 1) ^ 1); - } else if (port == 33) { - gpio_num = 432; - } else if (port == 34) { - gpio_num = 433; - } - - if ((rc = onlp_file_read_int(&status, "/sys/class/gpio/gpio%d/value", - gpio_num)) != ONLP_STATUS_OK) { - return ONLP_STATUS_E_INTERNAL; - } - - return status; -} - - -int -onlp_sfpi_presence_bitmap_get(onlp_sfp_bitmap_t* dst) -{ - int p = 1; - int rc = 0; - - for (p = 1; p <= PORT_NUM; p++) { - rc = onlp_sfpi_is_present(p); - AIM_BITMAP_MOD(dst, p, (1 == rc) ? 1 : 0); - } - - return ONLP_STATUS_OK; -} - -/* - * This function reads the SFPs idrom and returns in - * in the data buffer provided. - */ -int -onlp_sfpi_eeprom_read(int port, uint8_t data[256]) -{ - int eeprombusidx, eeprombus, eeprombusbase; - char eeprom_path[512], eeprom_addr[32]; - memset(eeprom_path, 0, sizeof(eeprom_path)); - memset(eeprom_addr, 0, sizeof(eeprom_addr)); - aim_strlcpy(eeprom_addr, "0050", sizeof(eeprom_addr)); - - memset(data, 0, 256); - - if (port >= 1 && port <= 8) { - eeprombusbase = 9; - } else if (port >= 9 && port <= 16) { - eeprombusbase = 17; - } else if (port >= 17 && port <= 24) { - eeprombusbase = 25; - } else if (port >= 25 && port <= 32) { - eeprombusbase = 33; - } else if (port == 33) { - eeprombus = 45; - } else if (port == 34) { - eeprombus = 46; - } else { - return 0; - } - - /* port 33 and 34 doesn't need to swap */ - if (port >=1 && port <= 32) { - eeprombusidx = port % 8; - switch (eeprombusidx) { - case 1: - eeprombus = eeprombusbase + 1; - break; - case 2: - eeprombus = eeprombusbase + 0; - break; - case 3: - eeprombus = eeprombusbase + 3; - break; - case 4: - eeprombus = eeprombusbase + 2; - break; - case 5: - eeprombus = eeprombusbase + 5; - break; - case 6: - eeprombus = eeprombusbase + 4; - break; - case 7: - eeprombus = eeprombusbase + 7; - break; - case 0: - eeprombus = eeprombusbase + 6; - break; - default: - return ONLP_STATUS_E_INTERNAL; - break; - } - } - - snprintf(eeprom_path, sizeof(eeprom_path), - "/sys/bus/i2c/devices/%d-%s/eeprom", eeprombus, eeprom_addr); - - if (onlplib_sfp_eeprom_read_file(eeprom_path, data) != 0) { - return ONLP_STATUS_E_INTERNAL; - } - - return ONLP_STATUS_OK; -} - -/* - * De-initialize the SFPI subsystem. - */ -int -onlp_sfpi_denit(void) -{ - return ONLP_STATUS_OK; -} diff --git a/packages/platforms/netberg/x86-64/aurora-710/onlp/builds/x86_64_netberg_aurora_710/module/src/sysi.c b/packages/platforms/netberg/x86-64/aurora-710/onlp/builds/x86_64_netberg_aurora_710/module/src/sysi.c deleted file mode 100755 index 01c98023b..000000000 --- a/packages/platforms/netberg/x86-64/aurora-710/onlp/builds/x86_64_netberg_aurora_710/module/src/sysi.c +++ /dev/null @@ -1,346 +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 -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "platform_lib.h" - -const char* -onlp_sysi_platform_get(void) -{ - return "x86-64-netberg-aurora-710-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(SYS_EEPROM_SIZE); - if(onlp_file_read(rdata, SYS_EEPROM_SIZE, size, SYS_EEPROM_PATH) == ONLP_STATUS_OK) { - if(*size == SYS_EEPROM_SIZE) { - *data = rdata; - return ONLP_STATUS_OK; - } - } - - AIM_LOG_INFO("Unable to get data from eeprom \n"); - aim_free(rdata); - *size = 0; - return ONLP_STATUS_E_INTERNAL; -} - -int -onlp_sysi_oids_get(onlp_oid_t* table, int max) -{ - onlp_oid_t* e = table; - memset(table, 0, max*sizeof(onlp_oid_t)); - int i; - - /* 2 PSUs */ - *e++ = ONLP_PSU_ID_CREATE(1); - *e++ = ONLP_PSU_ID_CREATE(2); - - /* LEDs Item */ - for (i=1; i<=LED_NUM; i++) { - *e++ = ONLP_LED_ID_CREATE(i); - } - - /* THERMALs Item */ - for (i=1; i<=THERMAL_NUM; i++) { - *e++ = ONLP_THERMAL_ID_CREATE(i); - } - - /* Fans Item */ - for (i=1; i<=FAN_NUM; i++) { - *e++ = ONLP_FAN_ID_CREATE(i); - } - - return ONLP_STATUS_OK; -} - -int -decide_fan_percentage(int is_up, int new_temp) -{ - int new_perc; - if (is_up) { - if (new_temp >= THERMAL_ERROR_DEFAULT) { - new_perc = THERMAL_ERROR_FAN_PERC; - } else if (new_temp >= THERMAL_WARNING_DEFAULT) { - new_perc = THERMAL_WARNING_FAN_PERC; - } else { - new_perc = THERMAL_NORMAL_FAN_PERC; - } - } else { - if (new_temp <= THERMAL_NORMAL_DEFAULT) { - new_perc = THERMAL_NORMAL_FAN_PERC; - } else if (new_temp <= THERMAL_WARNING_DEFAULT) { - new_perc = THERMAL_WARNING_FAN_PERC; - } else { - new_perc = THERMAL_ERROR_FAN_PERC; - } - } - - return new_perc; -} - -int -platform_thermal_temp_get(int *thermal_temp) -{ - int i, temp, max_temp, rc; - onlp_thermal_info_t thermal_info; - memset(&thermal_info, 0, sizeof(thermal_info)); - uint32_t thermal_arr[] = { THERMAL_OID_FRONT_MAC, - THERMAL_OID_ASIC, - THERMAL_OID_CPU1, - THERMAL_OID_CPU2, - THERMAL_OID_CPU3, - THERMAL_OID_CPU4 }; - max_temp = 0; - - for (i=0; i max_temp) { - max_temp = temp; - } - } - *thermal_temp = max_temp; - - return ONLP_STATUS_OK; -} - -int -onlp_sysi_platform_manage_fans(void) -{ - int rc, is_up ,new_temp, thermal_temp, diff; - static int new_perc = 0, ori_perc = 0; - static int ori_temp = 0; - onlp_thermal_info_t thermal_info; - memset(&thermal_info, 0, sizeof(thermal_info)); - - /* get new temperature */ - if ((rc = platform_thermal_temp_get(&thermal_temp)) != ONLP_STATUS_OK) { - goto _EXIT; - } - - new_temp = thermal_temp; - diff = new_temp - ori_temp; - - if (diff == 0) { - goto _EXIT; - } else { - is_up = (diff > 0 ? 1 : 0); - } - - new_perc = decide_fan_percentage(is_up, new_temp); - - if (ori_perc == new_perc) { - goto _EXIT; - } - - - AIM_LOG_INFO("The Fan Speeds Percent are now at %d%%", new_perc); - - if ((rc = onlp_fani_percentage_set(THERMAL_OID_ASIC, new_perc)) != ONLP_STATUS_OK) { - goto _EXIT; - } - - /* update */ - ori_perc = new_perc; - ori_temp = new_temp; - -_EXIT : - return rc; -} - -int -onlp_sysi_platform_manage_leds(void) -{ - int psu1_status, psu2_status, rc, i; - static int pre_psu1_status = 0, pre_psu2_status = 0, pre_fan_status = 0; - - //------------------------------- - static int pre_fan_tray_status[4] = {0}; - int fan_tray_id, sum, total = 0; - onlp_led_status_t fan_tray_status[SYS_FAN_NUM]; - //------------------------------- - - onlp_psu_info_t psu_info; - onlp_fan_info_t fan_info; - - //-------- ----------------------- - memset(&fan_tray_status, 0, sizeof(fan_tray_status)); - //------------------------------- - - memset(&psu_info, 0, sizeof(onlp_psu_info_t)); - memset(&fan_info, 0, sizeof(onlp_fan_info_t)); - uint32_t fan_arr[] = { FAN_OID_FAN1, - FAN_OID_FAN2, - FAN_OID_FAN3, - FAN_OID_FAN4, - FAN_OID_FAN5, - FAN_OID_FAN6, - 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; - } - - psu1_status = psu_info.status; - if (psu1_status != pre_psu1_status) { - 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); - } - - if (rc != ONLP_STATUS_OK) { - goto _EXIT; - } - pre_psu1_status = psu1_status; - } - - if ((rc = onlp_psui_info_get(PSU_OID_PSU2, &psu_info)) != ONLP_STATUS_OK) { - goto _EXIT; - } - - psu2_status = psu_info.status; - if( psu2_status != pre_psu2_status) { - 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); - } - - if (rc != ONLP_STATUS_OK) { - goto _EXIT; - } - pre_psu2_status = psu2_status; - } - - /* FAN LED CTRL */ - 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 (rc != ONLP_STATUS_OK) { - goto _EXIT; - } - - pre_fan_tray_status[fan_tray_id - 5] = sum; - } - } - } - - - 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; - } - -_EXIT : - return rc; -} - -int -onlp_sysi_platform_info_get(onlp_platform_info_t* pi) -{ - int rc; - if ((rc = sysi_platform_info_get(pi)) != ONLP_STATUS_OK) { - return ONLP_STATUS_E_INTERNAL; - } - - return ONLP_STATUS_OK; -} - diff --git a/packages/platforms/netberg/x86-64/aurora-710/onlp/builds/x86_64_netberg_aurora_710/module/src/thermali.c b/packages/platforms/netberg/x86-64/aurora-710/onlp/builds/x86_64_netberg_aurora_710/module/src/thermali.c deleted file mode 100755 index 785180b3f..000000000 --- a/packages/platforms/netberg/x86-64/aurora-710/onlp/builds/x86_64_netberg_aurora_710/module/src/thermali.c +++ /dev/null @@ -1,301 +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. - * - * - ************************************************************ - * - * Thermal Sensor Platform Implementation. - * - ***********************************************************/ -#include -#include -#include "x86_64_netberg_aurora_710_log.h" -#include "platform_lib.h" - -static onlp_thermal_info_t thermal_info[] = { - { }, /* Not used */ - { { THERMAL_OID_FRONT_MAC, "Front MAC", 0}, - ONLP_THERMAL_STATUS_PRESENT, - ONLP_THERMAL_CAPS_ALL, 0, THERMAL_THRESHOLD_INIT_DEFAULTS - }, - { { THERMAL_OID_ASIC, "ASIC Core Temp", 0}, - ONLP_THERMAL_STATUS_PRESENT, - ONLP_THERMAL_CAPS_ALL, 0, THERMAL_THRESHOLD_INIT_DEFAULTS - }, - { { THERMAL_OID_CPU1, "CPU Thermal 1", 0}, - ONLP_THERMAL_STATUS_PRESENT, - ONLP_THERMAL_CAPS_ALL, 0, THERMAL_THRESHOLD_INIT_DEFAULTS - }, - { { THERMAL_OID_CPU2, "CPU Thermal 2", 0}, - ONLP_THERMAL_STATUS_PRESENT, - ONLP_THERMAL_CAPS_ALL, 0, THERMAL_THRESHOLD_INIT_DEFAULTS - }, - { { THERMAL_OID_CPU3, "CPU Thermal 3", 0}, - ONLP_THERMAL_STATUS_PRESENT, - ONLP_THERMAL_CAPS_ALL, 0, THERMAL_THRESHOLD_INIT_DEFAULTS - }, - { { THERMAL_OID_CPU4, "CPU Thermal 4", 0}, - ONLP_THERMAL_STATUS_PRESENT, - ONLP_THERMAL_CAPS_ALL, 0, THERMAL_THRESHOLD_INIT_DEFAULTS - }, - { { THERMAL_OID_PSU1_1, "PSU-1 Thermal 1", PSU_OID_PSU1}, - ONLP_THERMAL_STATUS_PRESENT, - ONLP_THERMAL_CAPS_GET_TEMPERATURE, 0 - }, - { { THERMAL_OID_PSU1_2, "PSU-1 Thermal 2", PSU_OID_PSU1}, - ONLP_THERMAL_STATUS_PRESENT, - ONLP_THERMAL_CAPS_GET_TEMPERATURE, 0 - }, - { { THERMAL_OID_PSU2_1, "PSU-2 Thermal 1", PSU_OID_PSU2}, - ONLP_THERMAL_STATUS_PRESENT, - ONLP_THERMAL_CAPS_GET_TEMPERATURE, 0 - }, - { { THERMAL_OID_PSU2_2, "PSU-2 Thermal 2", PSU_OID_PSU2}, - ONLP_THERMAL_STATUS_PRESENT, - ONLP_THERMAL_CAPS_GET_TEMPERATURE, 0 - }, - { { THERMAL_OID_CPU_BOARD, "CPU Board", 0}, - ONLP_THERMAL_STATUS_PRESENT, - ONLP_THERMAL_CAPS_GET_TEMPERATURE, 0 - }, - { { THERMAL_OID_PSU1_NEAR, "Near PSU 1", 0}, - ONLP_THERMAL_STATUS_PRESENT, - ONLP_THERMAL_CAPS_GET_TEMPERATURE, 0 - }, - { { THERMAL_OID_PSU2_NEAR, "Near PSU 2", 0}, - ONLP_THERMAL_STATUS_PRESENT, - ONLP_THERMAL_CAPS_GET_TEMPERATURE, 0 - }, - { { THERMAL_OID_MAC_REAR, "Rear MAC", 0}, - ONLP_THERMAL_STATUS_PRESENT, - ONLP_THERMAL_CAPS_GET_TEMPERATURE, 0 - }, - { { THERMAL_OID_QSFP_NEAR, "Near QSFP Port", 0}, - ONLP_THERMAL_STATUS_PRESENT, - ONLP_THERMAL_CAPS_GET_TEMPERATURE, 0 - } -}; - -/* - * This will be called to intiialize the thermali subsystem. - */ -int -onlp_thermali_init(void) -{ - return ONLP_STATUS_OK; -} - -static int -sys_thermal_info_get(onlp_thermal_info_t* info, int id) -{ - int rv; - - rv = onlp_file_read_int(&info->mcelsius, - SYS_CORE_TEMP_PREFIX "temp%d_input", id); - - if(rv == ONLP_STATUS_E_INTERNAL) { - return rv; - } - - if(rv == ONLP_STATUS_E_MISSING) { - info->status &= ~1; - return 0; - } - - return ONLP_STATUS_OK; -} - -static int -cpu_thermal_info_get(onlp_thermal_info_t* info, int id) -{ - int rv; - int offset; - - offset = 1; - id = id - offset; - rv = onlp_file_read_int(&info->mcelsius, - SYS_CPU_TEMP_PREFIX "temp%d_input", id); - - if(rv == ONLP_STATUS_E_INTERNAL) { - return rv; - } - - if(rv == ONLP_STATUS_E_MISSING) { - info->status &= ~1; - return 0; - } - - return ONLP_STATUS_OK; -} - -int -psu_thermal_info_get(onlp_thermal_info_t* info, int id) -{ - int rv; - - rv = psu_thermal_get(info, id); - if(rv == ONLP_STATUS_E_INTERNAL) { - return rv; - } - - return ONLP_STATUS_OK; -} - -static int -cpu_board_thermal_info_get(onlp_thermal_info_t* info) -{ - int rv; - - rv = onlp_file_read_int(&info->mcelsius, - SYS_CPU_BOARD_TEMP_PREFIX "temp1_input"); - - if (rv == ONLP_STATUS_E_INTERNAL) { - return rv; - } - - if (rv == ONLP_STATUS_E_MISSING) { - info->status &= ~1; - return 0; - } - - return ONLP_STATUS_OK; -} - -static int -psu_near_thermal_info_get(onlp_thermal_info_t* info, int id) -{ - int rv; - - if (id == THERMAL_ID_PSU1_NEAR) { - rv = onlp_file_read_int(&info->mcelsius, - SYS_PSU1_NEAR_TEMP_PREFIX "temp1_input"); - } else if (id == THERMAL_ID_PSU2_NEAR) { - rv = onlp_file_read_int(&info->mcelsius, - SYS_PSU2_NEAR_TEMP_PREFIX "temp1_input"); - } else { - return ONLP_STATUS_E_INTERNAL; - } - - if (rv == ONLP_STATUS_E_INTERNAL) { - return rv; - } - - if (rv == ONLP_STATUS_E_MISSING) { - info->status &= ~1; - return 0; - } - - return ONLP_STATUS_OK; -} - -static int -mac_rear_thermal_info_get(onlp_thermal_info_t* info) -{ - int rv; - - rv = onlp_file_read_int(&info->mcelsius, - SYS_MAC_REAR_TEMP_PREFIX "temp1_input"); - - if (rv == ONLP_STATUS_E_INTERNAL) { - return rv; - } - - if (rv == ONLP_STATUS_E_MISSING) { - info->status &= ~1; - return 0; - } - - return ONLP_STATUS_OK; -} - -static int -qsfp_near_thermal_info_get(onlp_thermal_info_t* info) -{ - int rv; - - rv = onlp_file_read_int(&info->mcelsius, - SYS_QSFP_NEAR_TEMP_PREFIX "temp1_input"); - - if (rv == ONLP_STATUS_E_INTERNAL) { - return rv; - } - - if (rv == ONLP_STATUS_E_MISSING) { - info->status &= ~1; - return 0; - } - - 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 sensor_id, rc; - sensor_id = ONLP_OID_ID_GET(id); - - *info = thermal_info[sensor_id]; - info->caps |= ONLP_THERMAL_CAPS_GET_TEMPERATURE; - - switch (sensor_id) { - case THERMAL_ID_ASIC: - case THERMAL_ID_FRONT_MAC: - rc = sys_thermal_info_get(info, sensor_id); - break; - case THERMAL_ID_CPU1: - case THERMAL_ID_CPU2: - case THERMAL_ID_CPU3: - case THERMAL_ID_CPU4: - rc = cpu_thermal_info_get(info, sensor_id); - break; - case THERMAL_ID_PSU1_1: - case THERMAL_ID_PSU1_2: - case THERMAL_ID_PSU2_1: - case THERMAL_ID_PSU2_2: - rc = psu_thermal_info_get(info, sensor_id); - break; - case THERMAL_ID_CPU_BOARD: - rc = cpu_board_thermal_info_get(info); - break; - case THERMAL_ID_PSU1_NEAR: - case THERMAL_ID_PSU2_NEAR: - rc = psu_near_thermal_info_get(info, sensor_id); - break; - case THERMAL_ID_MAC_REAR: - rc = mac_rear_thermal_info_get(info); - break; - case THERMAL_ID_QSFP_NEAR: - rc = qsfp_near_thermal_info_get(info); - break; - default: - return ONLP_STATUS_E_INTERNAL; - break; - } - - return rc; -} diff --git a/packages/platforms/netberg/x86-64/aurora-710/onlp/builds/x86_64_netberg_aurora_710/module/src/x86_64_netberg_aurora_710_config.c b/packages/platforms/netberg/x86-64/aurora-710/onlp/builds/x86_64_netberg_aurora_710/module/src/x86_64_netberg_aurora_710_config.c deleted file mode 100755 index 5e9235cc7..000000000 --- a/packages/platforms/netberg/x86-64/aurora-710/onlp/builds/x86_64_netberg_aurora_710/module/src/x86_64_netberg_aurora_710_config.c +++ /dev/null @@ -1,96 +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 __x86_64_netberg_aurora_710_config_STRINGIFY_NAME(_x) #_x -#define __x86_64_netberg_aurora_710_config_STRINGIFY_VALUE(_x) __x86_64_netberg_aurora_710_config_STRINGIFY_NAME(_x) -x86_64_netberg_aurora_710_config_settings_t x86_64_netberg_aurora_710_config_settings[] = -{ -#ifdef X86_64_NETBERG_AURORA_710_CONFIG_INCLUDE_LOGGING - { __x86_64_netberg_aurora_710_config_STRINGIFY_NAME(X86_64_NETBERG_AURORA_710_CONFIG_INCLUDE_LOGGING), __x86_64_netberg_aurora_710_config_STRINGIFY_VALUE(X86_64_NETBERG_AURORA_710_CONFIG_INCLUDE_LOGGING) }, -#else -{ X86_64_NETBERG_AURORA_710_CONFIG_INCLUDE_LOGGING(__x86_64_netberg_aurora_710_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_NETBERG_AURORA_710_CONFIG_LOG_OPTIONS_DEFAULT - { __x86_64_netberg_aurora_710_config_STRINGIFY_NAME(X86_64_NETBERG_AURORA_710_CONFIG_LOG_OPTIONS_DEFAULT), __x86_64_netberg_aurora_710_config_STRINGIFY_VALUE(X86_64_NETBERG_AURORA_710_CONFIG_LOG_OPTIONS_DEFAULT) }, -#else -{ X86_64_NETBERG_AURORA_710_CONFIG_LOG_OPTIONS_DEFAULT(__x86_64_netberg_aurora_710_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_NETBERG_AURORA_710_CONFIG_LOG_BITS_DEFAULT - { __x86_64_netberg_aurora_710_config_STRINGIFY_NAME(X86_64_NETBERG_AURORA_710_CONFIG_LOG_BITS_DEFAULT), __x86_64_netberg_aurora_710_config_STRINGIFY_VALUE(X86_64_NETBERG_AURORA_710_CONFIG_LOG_BITS_DEFAULT) }, -#else -{ X86_64_NETBERG_AURORA_710_CONFIG_LOG_BITS_DEFAULT(__x86_64_netberg_aurora_710_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_NETBERG_AURORA_710_CONFIG_LOG_CUSTOM_BITS_DEFAULT - { __x86_64_netberg_aurora_710_config_STRINGIFY_NAME(X86_64_NETBERG_AURORA_710_CONFIG_LOG_CUSTOM_BITS_DEFAULT), __x86_64_netberg_aurora_710_config_STRINGIFY_VALUE(X86_64_NETBERG_AURORA_710_CONFIG_LOG_CUSTOM_BITS_DEFAULT) }, -#else -{ X86_64_NETBERG_AURORA_710_CONFIG_LOG_CUSTOM_BITS_DEFAULT(__x86_64_netberg_aurora_710_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_NETBERG_AURORA_710_CONFIG_PORTING_STDLIB - { __x86_64_netberg_aurora_710_config_STRINGIFY_NAME(X86_64_NETBERG_AURORA_710_CONFIG_PORTING_STDLIB), __x86_64_netberg_aurora_710_config_STRINGIFY_VALUE(X86_64_NETBERG_AURORA_710_CONFIG_PORTING_STDLIB) }, -#else -{ X86_64_NETBERG_AURORA_710_CONFIG_PORTING_STDLIB(__x86_64_netberg_aurora_710_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_NETBERG_AURORA_710_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS - { __x86_64_netberg_aurora_710_config_STRINGIFY_NAME(X86_64_NETBERG_AURORA_710_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS), __x86_64_netberg_aurora_710_config_STRINGIFY_VALUE(X86_64_NETBERG_AURORA_710_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS) }, -#else -{ X86_64_NETBERG_AURORA_710_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS(__x86_64_netberg_aurora_710_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_NETBERG_AURORA_710_CONFIG_INCLUDE_UCLI - { __x86_64_netberg_aurora_710_config_STRINGIFY_NAME(X86_64_NETBERG_AURORA_710_CONFIG_INCLUDE_UCLI), __x86_64_netberg_aurora_710_config_STRINGIFY_VALUE(X86_64_NETBERG_AURORA_710_CONFIG_INCLUDE_UCLI) }, -#else -{ X86_64_NETBERG_AURORA_710_CONFIG_INCLUDE_UCLI(__x86_64_netberg_aurora_710_config_STRINGIFY_NAME), "__undefined__" }, -#endif - { NULL, NULL } -}; -#undef __x86_64_netberg_aurora_710_config_STRINGIFY_VALUE -#undef __x86_64_netberg_aurora_710_config_STRINGIFY_NAME - -const char* -x86_64_netberg_aurora_710_config_lookup(const char* setting) -{ - int i; - for(i = 0; x86_64_netberg_aurora_710_config_settings[i].name; i++) { - if(!strcmp(x86_64_netberg_aurora_710_config_settings[i].name, setting)) { - return x86_64_netberg_aurora_710_config_settings[i].value; - } - } - return NULL; -} - -int -x86_64_netberg_aurora_710_config_show(struct aim_pvs_s* pvs) -{ - int i; - for(i = 0; x86_64_netberg_aurora_710_config_settings[i].name; i++) { - aim_printf(pvs, "%s = %s\n", x86_64_netberg_aurora_710_config_settings[i].name, x86_64_netberg_aurora_710_config_settings[i].value); - } - return i; -} - -/* */ - diff --git a/packages/platforms/netberg/x86-64/aurora-710/onlp/builds/x86_64_netberg_aurora_710/module/src/x86_64_netberg_aurora_710_enums.c b/packages/platforms/netberg/x86-64/aurora-710/onlp/builds/x86_64_netberg_aurora_710/module/src/x86_64_netberg_aurora_710_enums.c deleted file mode 100755 index 77b910177..000000000 --- a/packages/platforms/netberg/x86-64/aurora-710/onlp/builds/x86_64_netberg_aurora_710/module/src/x86_64_netberg_aurora_710_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/netberg/x86-64/aurora-710/onlp/builds/x86_64_netberg_aurora_710/module/src/x86_64_netberg_aurora_710_int.h b/packages/platforms/netberg/x86-64/aurora-710/onlp/builds/x86_64_netberg_aurora_710/module/src/x86_64_netberg_aurora_710_int.h deleted file mode 100755 index 7cbacf136..000000000 --- a/packages/platforms/netberg/x86-64/aurora-710/onlp/builds/x86_64_netberg_aurora_710/module/src/x86_64_netberg_aurora_710_int.h +++ /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. - * - * - ************************************************************ - * - * - * - ***********************************************************/ - -#ifndef __x86_64_netberg_aurora_710_INT_H__ -#define __x86_64_netberg_aurora_710_INT_H__ - -#endif /* __x86_64_netberg_aurora_710_INT_H__ */ diff --git a/packages/platforms/netberg/x86-64/aurora-710/onlp/builds/x86_64_netberg_aurora_710/module/src/x86_64_netberg_aurora_710_log.c b/packages/platforms/netberg/x86-64/aurora-710/onlp/builds/x86_64_netberg_aurora_710/module/src/x86_64_netberg_aurora_710_log.c deleted file mode 100755 index 7d890f0e7..000000000 --- a/packages/platforms/netberg/x86-64/aurora-710/onlp/builds/x86_64_netberg_aurora_710/module/src/x86_64_netberg_aurora_710_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 "x86_64_netberg_aurora_710_log.h" -/* - * x86_64_netberg_aurora_710 log struct. - */ -AIM_LOG_STRUCT_DEFINE( - X86_64_NETBERG_AURORA_710_CONFIG_LOG_OPTIONS_DEFAULT, - X86_64_NETBERG_AURORA_710_CONFIG_LOG_BITS_DEFAULT, - NULL, /* Custom log map */ - X86_64_NETBERG_AURORA_710_CONFIG_LOG_CUSTOM_BITS_DEFAULT - ); - diff --git a/packages/platforms/netberg/x86-64/aurora-710/onlp/builds/x86_64_netberg_aurora_710/module/src/x86_64_netberg_aurora_710_log.h b/packages/platforms/netberg/x86-64/aurora-710/onlp/builds/x86_64_netberg_aurora_710/module/src/x86_64_netberg_aurora_710_log.h deleted file mode 100755 index 96e42d387..000000000 --- a/packages/platforms/netberg/x86-64/aurora-710/onlp/builds/x86_64_netberg_aurora_710/module/src/x86_64_netberg_aurora_710_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 __x86_64_netberg_aurora_710_LOG_H__ -#define __x86_64_netberg_aurora_710_LOG_H__ - -#define AIM_LOG_MODULE_NAME x86_64_netberg_aurora_710 -#include - -#endif /* __x86_64_netberg_aurora_710_LOG_H__ */ diff --git a/packages/platforms/netberg/x86-64/aurora-710/onlp/builds/x86_64_netberg_aurora_710/module/src/x86_64_netberg_aurora_710_module.c b/packages/platforms/netberg/x86-64/aurora-710/onlp/builds/x86_64_netberg_aurora_710/module/src/x86_64_netberg_aurora_710_module.c deleted file mode 100755 index 98fef2159..000000000 --- a/packages/platforms/netberg/x86-64/aurora-710/onlp/builds/x86_64_netberg_aurora_710/module/src/x86_64_netberg_aurora_710_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 "x86_64_netberg_aurora_710_log.h" - -static int -datatypes_init__(void) -{ -#define NETBERG_AURORA_710_ENUMERATION_ENTRY(_enum_name, _desc) AIM_DATATYPE_MAP_REGISTER(_enum_name, _enum_name##_map, _desc, AIM_LOG_INTERNAL); -#include - return 0; -} - -void __x86_64_netberg_aurora_710_module_init__(void) -{ - AIM_LOG_STRUCT_REGISTER(); - datatypes_init__(); -} - -int __onlp_platform_version__ = 1; diff --git a/packages/platforms/netberg/x86-64/aurora-710/onlp/builds/x86_64_netberg_aurora_710/module/src/x86_64_netberg_aurora_710_ucli.c b/packages/platforms/netberg/x86-64/aurora-710/onlp/builds/x86_64_netberg_aurora_710/module/src/x86_64_netberg_aurora_710_ucli.c deleted file mode 100755 index 3373e8934..000000000 --- a/packages/platforms/netberg/x86-64/aurora-710/onlp/builds/x86_64_netberg_aurora_710/module/src/x86_64_netberg_aurora_710_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 -x86_64_netberg_aurora_710_ucli_ucli__config__(ucli_context_t* uc) -{ - UCLI_HANDLER_MACRO_MODULE_CONFIG(x86_64_netberg_aurora_710) -} - -/* */ -/****************************************************************************** - * - * These handler table(s) were autogenerated from the symbols in this - * source file. - * - *****************************************************************************/ -static ucli_command_handler_f x86_64_netberg_aurora_710_ucli_ucli_handlers__[] = -{ - x86_64_netberg_aurora_710_ucli_ucli__config__, - NULL -}; -/******************************************************************************/ -/* */ - -static ucli_module_t -x86_64_netberg_aurora_710_ucli_module__ = - { - "x86_64_netberg_aurora_710_ucli", - NULL, - x86_64_netberg_aurora_710_ucli_ucli_handlers__, - NULL, - NULL, - }; - -ucli_node_t* -x86_64_netberg_aurora_710_ucli_node_create(void) -{ - ucli_node_t* n; - ucli_module_init(&x86_64_netberg_aurora_710_ucli_module__); - n = ucli_node_create("x86_64_netberg_aurora_710", NULL, &x86_64_netberg_aurora_710_ucli_module__); - ucli_node_subnode_add(n, ucli_module_log_node_create("x86_64_netberg_aurora_710")); - return n; -} - -#else -void* -x86_64_netberg_aurora_710_ucli_node_create(void) -{ - return NULL; -} -#endif - diff --git a/packages/platforms/netberg/x86-64/aurora-710/platform-config/Makefile b/packages/platforms/netberg/x86-64/aurora-710/platform-config/Makefile deleted file mode 100755 index 003238cf6..000000000 --- a/packages/platforms/netberg/x86-64/aurora-710/platform-config/Makefile +++ /dev/null @@ -1 +0,0 @@ -include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/netberg/x86-64/aurora-710/platform-config/r0/Makefile b/packages/platforms/netberg/x86-64/aurora-710/platform-config/r0/Makefile deleted file mode 100755 index 003238cf6..000000000 --- a/packages/platforms/netberg/x86-64/aurora-710/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/netberg/x86-64/aurora-710/platform-config/r0/PKG.yml b/packages/platforms/netberg/x86-64/aurora-710/platform-config/r0/PKG.yml deleted file mode 100755 index 4ee5f7e7c..000000000 --- a/packages/platforms/netberg/x86-64/aurora-710/platform-config/r0/PKG.yml +++ /dev/null @@ -1 +0,0 @@ -!include $ONL_TEMPLATES/platform-config-platform.yml ARCH=amd64 VENDOR=netberg BASENAME=x86-64-netberg-aurora-710 REVISION=r0 diff --git a/packages/platforms/netberg/x86-64/aurora-710/platform-config/r0/src/lib/x86-64-netberg-aurora-710-r0.yml b/packages/platforms/netberg/x86-64/aurora-710/platform-config/r0/src/lib/x86-64-netberg-aurora-710-r0.yml deleted file mode 100755 index 326161511..000000000 --- a/packages/platforms/netberg/x86-64/aurora-710/platform-config/r0/src/lib/x86-64-netberg-aurora-710-r0.yml +++ /dev/null @@ -1,30 +0,0 @@ ---- - -###################################################################### -# -# platform-config for x86-64-netberg-aurora-710 -# -###################################################################### - -x86-64-netberg-aurora-710-r0: - - grub: - - serial: >- - --port=0x3f8 - --speed=115200 - --word=8 - --parity=no - --stop=1 - - kernel: - <<: *kernel-3-16 - - args: >- - console=ttyS0,115200n8 - - ##network - ## interfaces: - ## ma1: - ## name: ~ - ## syspath: pci0000:00/0000:00:03.0 diff --git a/packages/platforms/netberg/x86-64/aurora-710/platform-config/r0/src/python/x86_64_netberg_aurora_710_r0/__init__.py b/packages/platforms/netberg/x86-64/aurora-710/platform-config/r0/src/python/x86_64_netberg_aurora_710_r0/__init__.py deleted file mode 100755 index d91162fbe..000000000 --- a/packages/platforms/netberg/x86-64/aurora-710/platform-config/r0/src/python/x86_64_netberg_aurora_710_r0/__init__.py +++ /dev/null @@ -1,310 +0,0 @@ -from onl.platform.base import * -from onl.platform.netberg import * -import os -import sys -import subprocess - -def msg(s, fatal=False): - sys.stderr.write(s) - sys.stderr.flush() - if fatal: - sys.exit(1) - -class OnlPlatform_x86_64_netberg_aurora_710_r0(OnlPlatformNetberg): - PLATFORM='x86-64-netberg-aurora-710-r0' - MODEL="NBA720" - SYS_OBJECT_ID=".710.1" - - def baseconfig(self): - - # vid to mac vdd value mapping - vdd_val_array=( 0.85, 0.82, 0.77, 0.87, 0.74, 0.84, 0.79, 0.89 ) - # vid to rov reg value mapping - rov_reg_array=( 0x24, 0x21, 0x1C, 0x26, 0x19, 0x23, 0x1E, 0x28 ) - - self.insmod("eeprom_mb") - # init SYS EEPROM devices - self.new_i2c_device('mb_eeprom', 0x55, 0) - - os.system("modprobe w83795") - os.system("modprobe eeprom") - - ########### initialize I2C bus 0 ########### - # init PCA9548 - self.new_i2c_devices( - [ - ('pca9548', 0x70, 0), - ('pca9548', 0x71, 1), - ('pca9548', 0x71, 2), - ('pca9548', 0x71, 3), - ('pca9548', 0x71, 4), - ('pca9548', 0x71, 7), - ('pca9548', 0x76, 0), - ] - ) - - # init PCA9545 - self.new_i2c_device('pca9545', 0x72, 0) - - # Golden Finger to show CPLD - os.system("i2cget -y 44 0x74 2") - - # Reset BMC Dummy Board - os.system("i2cset -y -r 0 0x26 4 0x00") - os.system("i2cset -y -r 0 0x26 5 0x00") - os.system("i2cset -y -r 0 0x26 2 0x3F") - os.system("i2cset -y -r 0 0x26 3 0x1F") - os.system("i2cset -y -r 0 0x26 6 0xC0") - os.system("i2cset -y -r 0 0x26 7 0x00") - - # CPU Baord - os.system("i2cset -y -r 0 0x77 6 0xFF") - os.system("i2cset -y -r 0 0x77 7 0xFF") - - # init SMBUS1 ABS - os.system("i2cset -y -r 5 0x20 4 0x00") - os.system("i2cset -y -r 5 0x20 5 0x00") - os.system("i2cset -y -r 5 0x20 6 0xFF") - os.system("i2cset -y -r 5 0x20 7 0xFF") - - os.system("i2cset -y -r 5 0x21 4 0x00") - os.system("i2cset -y -r 5 0x21 5 0x00") - os.system("i2cset -y -r 5 0x21 6 0xFF") - os.system("i2cset -y -r 5 0x21 7 0xFF") - - os.system("i2cset -y -r 5 0x22 4 0x00") - os.system("i2cset -y -r 5 0x22 5 0x00") - os.system("i2cset -y -r 5 0x22 6 0xFF") - os.system("i2cset -y -r 5 0x22 7 0xFF") - - os.system("i2cset -y -r 5 0x23 4 0x00") - os.system("i2cset -y -r 5 0x23 5 0x00") - os.system("i2cset -y -r 5 0x23 2 0xCF") - os.system("i2cset -y -r 5 0x23 3 0xF0") - os.system("i2cset -y -r 5 0x23 6 0xCF") - os.system("i2cset -y -r 5 0x23 7 0xF0") - - # init SFP - os.system("i2cset -y -r 5 0x27 4 0x00") - os.system("i2cset -y -r 5 0x27 5 0x00") - os.system("i2cset -y -r 5 0x27 2 0x00") - os.system("i2cset -y -r 5 0x27 3 0x00") - os.system("i2cset -y -r 5 0x27 6 0xCF") - os.system("i2cset -y -r 5 0x27 7 0xF0") - - # set ZQSFP LP_MODE = 0 - os.system("i2cset -y -r 6 0x20 4 0x00") - os.system("i2cset -y -r 6 0x20 5 0x00") - os.system("i2cset -y -r 6 0x20 2 0x00") - os.system("i2cset -y -r 6 0x20 3 0x00") - os.system("i2cset -y -r 6 0x20 6 0x00") - os.system("i2cset -y -r 6 0x20 7 0x00") - - os.system("i2cset -y -r 6 0x21 4 0x00") - os.system("i2cset -y -r 6 0x21 5 0x00") - os.system("i2cset -y -r 6 0x21 2 0x00") - os.system("i2cset -y -r 6 0x21 3 0x00") - os.system("i2cset -y -r 6 0x21 6 0x00") - os.system("i2cset -y -r 6 0x21 7 0x00") - - # set ZQSFP RST = 1 - os.system("i2cset -y -r 6 0x22 4 0x00") - os.system("i2cset -y -r 6 0x22 5 0x00") - os.system("i2cset -y -r 6 0x22 2 0xFF") - os.system("i2cset -y -r 6 0x22 3 0xFF") - os.system("i2cset -y -r 6 0x22 6 0x00") - os.system("i2cset -y -r 6 0x22 7 0x00") - - os.system("i2cset -y -r 6 0x23 4 0x00") - os.system("i2cset -y -r 6 0x23 5 0x00") - os.system("i2cset -y -r 6 0x23 2 0xFF") - os.system("i2cset -y -r 6 0x23 3 0xFF") - os.system("i2cset -y -r 6 0x23 6 0x00") - os.system("i2cset -y -r 6 0x23 7 0x00") - - # init Host GPIO - os.system("i2cset -y -r 0 0x74 4 0x00") - os.system("i2cset -y -r 0 0x74 5 0x00") - os.system("i2cset -y -r 0 0x74 2 0x0F") - os.system("i2cset -y -r 0 0x74 3 0xDF") - os.system("i2cset -y -r 0 0x74 6 0x08") - os.system("i2cset -y -r 0 0x74 7 0x1F") - - # init LED board after PVT (BAREFOOT_IO_EXP_LED_ID) - #os.system("i2cset -y -r 50 0x75 4 0x00") - #os.system("i2cset -y -r 50 0x75 5 0x00") - #os.system("i2cset -y -r 50 0x75 6 0x00") - #os.system("i2cset -y -r 50 0x75 7 0xFF") - - # init Board ID - os.system("i2cset -y -r 51 0x27 4 0x00") - os.system("i2cset -y -r 51 0x27 5 0x00") - os.system("i2cset -y -r 51 0x27 6 0xFF") - os.system("i2cset -y -r 51 0x27 7 0xFF") - - # init Board ID of Dummy BMC Board - os.system("i2cset -y -r 0 0x24 4 0x00") - os.system("i2cset -y -r 0 0x24 5 0x00") - os.system("i2cset -y -r 0 0x24 6 0xFF") - os.system("i2cset -y -r 0 0x24 7 0xFF") - - # init PSU I/O (BAREFOOT_IO_EXP_PSU_ID) - os.system("i2cset -y -r 0 0x25 4 0x00") - os.system("i2cset -y -r 0 0x25 5 0x00") - os.system("i2cset -y -r 0 0x25 2 0x00") - os.system("i2cset -y -r 0 0x25 3 0x1D") - os.system("i2cset -y -r 0 0x25 6 0xDB") - os.system("i2cset -y -r 0 0x25 7 0x03") - - # init FAN I/O (BAREFOOT_IO_EXP_FAN_ID) - os.system("i2cset -y -r 59 0x20 4 0x00") - os.system("i2cset -y -r 59 0x20 5 0x00") - os.system("i2cset -y -r 59 0x20 2 0x11") - os.system("i2cset -y -r 59 0x20 3 0x11") - os.system("i2cset -y -r 59 0x20 6 0xCC") - os.system("i2cset -y -r 59 0x20 7 0xCC") - - # init Fan - # select bank 0 - os.system("i2cset -y -r 56 0x2F 0x00 0x80") - # enable FANIN 1-8 - os.system("i2cset -y -r 56 0x2F 0x06 0xFF") - # disable FANIN 9-14 - os.system("i2cset -y -r 56 0x2F 0x07 0x00") - # select bank 2 - os.system("i2cset -y -r 56 0x2F 0x00 0x82") - # set PWM mode in FOMC - os.system("i2cset -y -r 56 0x2F 0x0F 0x00") - - # init VOLMON - os.system("i2cset -y -r 56 0x2F 0x00 0x80") - os.system("i2cset -y -r 56 0x2F 0x01 0x1C") - os.system("i2cset -y -r 56 0x2F 0x00 0x80") - os.system("i2cset -y -r 56 0x2F 0x02 0xFF") - os.system("i2cset -y -r 56 0x2F 0x03 0x50") - os.system("i2cset -y -r 56 0x2F 0x04 0x0A") - os.system("i2cset -y -r 56 0x2F 0x00 0x80") - os.system("i2cset -y -r 56 0x2F 0x01 0x1D") - self.new_i2c_device('w83795adg', 0x2F, 56) - - # init Fan Speed - os.system("echo 120 > /sys/class/hwmon/hwmon1/device/pwm1") - os.system("echo 120 > /sys/class/hwmon/hwmon1/device/pwm2") - - # init Temperature - self.new_i2c_devices( - [ - # ASIC Coretemp and Front MAC - ('lm86', 0x4C, 41), - - # CPU Board - ('tmp75', 0x4F, 0), - - # Near PSU1 - ('tmp75', 0x48, 41), - - # Rear MAC - ('tmp75', 0x4A, 41), - - # Near Port 32 - ('tmp75', 0x4B, 41), - - # Near PSU2 - ('tmp75', 0x4D, 41), - ] - ) - - # init GPIO, ABS Port 0-15 - self.new_i2c_device('pca9535', 0x20, 5) - for i in range(496, 512): - os.system("echo %d > /sys/class/gpio/export" % i) - os.system("echo 1 > /sys/class/gpio/gpio%d/active_low" % i) - - # init GPIO, ABS Port 16-31 - self.new_i2c_device('pca9535', 0x21, 5) - for i in range(480, 496): - os.system("echo %d > /sys/class/gpio/export" % i) - os.system("echo 1 > /sys/class/gpio/gpio%d/active_low" % i) - - # init GPIO, INT Port 0-15 - self.new_i2c_device('pca9535', 0x22, 5) - for i in range(464, 480): - os.system("echo %d > /sys/class/gpio/export" % i) - os.system("echo 1 > /sys/class/gpio/gpio%d/active_low" % i) - - # init GPIO, INT Port 16-31 - self.new_i2c_device('pca9535', 0x23, 5) - for i in range(448, 464): - os.system("echo %d > /sys/class/gpio/export" % i) - os.system("echo 1 > /sys/class/gpio/gpio%d/active_low" % i) - - # init GPIO, SFP - self.new_i2c_device('pca9535', 0x27, 5) - for i in range(432, 448): - os.system("echo %d > /sys/class/gpio/export" % i) - if i == 180 or i == 181 or i == 184 or \ - i == 185 or i == 186 or i == 187: - os.system("echo out > /sys/class/gpio/gpio%d/direction" % i) - else: - os.system("echo 1 > /sys/class/gpio/gpio%d/active_low" % i) - - # init GPIO, LP Mode Port 0-15 - self.new_i2c_device('pca9535', 0x20, 6) - for i in range(416, 432): - os.system("echo %d > /sys/class/gpio/export" % i) - os.system("echo out > /sys/class/gpio/gpio%d/direction" % i) - - # init GPIO, LP Mode Port 16-31 - self.new_i2c_device('pca9535', 0x21, 6) - for i in range(400, 416): - os.system("echo %d > /sys/class/gpio/export" % i) - os.system("echo out > /sys/class/gpio/gpio%d/direction" % i) - - # init GPIO, RST Port 0-15 - self.new_i2c_device('pca9535', 0x22, 6) - for i in range(384, 400): - os.system("echo %d > /sys/class/gpio/export" % i) - os.system("echo out > /sys/class/gpio/gpio%d/direction" % i) - os.system("echo 1 > /sys/class/gpio/gpio%d/active_low" % i) - os.system("echo 0 > /sys/class/gpio/gpio%d/value" % i) - - # init GPIO, RST Port 16-31 - self.new_i2c_device('pca9535', 0x23, 6) - for i in range(368, 384): - os.system("echo %d > /sys/class/gpio/export" % i) - os.system("echo out > /sys/class/gpio/gpio%d/direction" % i) - os.system("echo 1 > /sys/class/gpio/gpio%d/active_low" % i) - os.system("echo 0 > /sys/class/gpio/gpio%d/value" % i) - - # init QSFP EEPROM - for port in range(1, 33): - self.new_i2c_device('sff8436', 0x50, port + 8) - - # init SFP(0/1) EEPROM - self.new_i2c_device('sff8436', 0x50, 45) - self.new_i2c_device('sff8436', 0x50, 46) - - # init PSU(0/1) EEPROM devices - self.new_i2c_device('eeprom', 0x50, 57) - self.new_i2c_device('eeprom', 0x50, 58) - - # _mac_vdd_init - reg_val_str = subprocess.check_output("""i2cget -y 44 0x33 0x42 2>/dev/null""", shell=True) - reg_val = int(reg_val_str, 16) - vid = reg_val & 0x7 - mac_vdd_val = vdd_val_array[vid] - rov_reg = rov_reg_array[vid] - - msg("Setting mac vdd %1.2f with rov register value 0x%x\n" % (mac_vdd_val, rov_reg) ) - os.system("i2cset -y -r 55 0x22 0x21 0x%x w" % rov_reg) - - # init SYS LED - os.system("i2cset -y -r 50 0x75 2 0x01") - os.system("i2cset -y -r 50 0x75 4 0x00") - os.system("i2cset -y -r 50 0x75 5 0x00") - os.system("i2cset -y -r 50 0x75 6 0x00") - os.system("i2cset -y -r 50 0x75 7 0x00") - - return True - - diff --git a/packages/platforms/netberg/x86-64/aurora-720-rangeley/.gitignore b/packages/platforms/netberg/x86-64/aurora-720-rangeley/.gitignore deleted file mode 100755 index eeaa11a19..000000000 --- a/packages/platforms/netberg/x86-64/aurora-720-rangeley/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -*x86*64*netberg*aurora*720*rangeley*.mk -onlpdump.mk diff --git a/packages/platforms/netberg/x86-64/aurora-720-rangeley/Makefile b/packages/platforms/netberg/x86-64/aurora-720-rangeley/Makefile deleted file mode 100755 index 003238cf6..000000000 --- a/packages/platforms/netberg/x86-64/aurora-720-rangeley/Makefile +++ /dev/null @@ -1 +0,0 @@ -include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/netberg/x86-64/aurora-720-rangeley/modules/Makefile b/packages/platforms/netberg/x86-64/aurora-720-rangeley/modules/Makefile deleted file mode 100755 index 003238cf6..000000000 --- a/packages/platforms/netberg/x86-64/aurora-720-rangeley/modules/Makefile +++ /dev/null @@ -1 +0,0 @@ -include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/netberg/x86-64/aurora-720-rangeley/modules/PKG.yml b/packages/platforms/netberg/x86-64/aurora-720-rangeley/modules/PKG.yml deleted file mode 100755 index bf6659622..000000000 --- a/packages/platforms/netberg/x86-64/aurora-720-rangeley/modules/PKG.yml +++ /dev/null @@ -1 +0,0 @@ -!include $ONL_TEMPLATES/no-platform-modules.yml ARCH=amd64 VENDOR=netberg BASENAME=x86-64-netberg-aurora-720-rangeley diff --git a/packages/platforms/netberg/x86-64/aurora-720-rangeley/onlp/Makefile b/packages/platforms/netberg/x86-64/aurora-720-rangeley/onlp/Makefile deleted file mode 100755 index 003238cf6..000000000 --- a/packages/platforms/netberg/x86-64/aurora-720-rangeley/onlp/Makefile +++ /dev/null @@ -1 +0,0 @@ -include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/netberg/x86-64/aurora-720-rangeley/onlp/PKG.yml b/packages/platforms/netberg/x86-64/aurora-720-rangeley/onlp/PKG.yml deleted file mode 100755 index 8aa08b339..000000000 --- a/packages/platforms/netberg/x86-64/aurora-720-rangeley/onlp/PKG.yml +++ /dev/null @@ -1 +0,0 @@ -!include $ONL_TEMPLATES/onlp-platform-any.yml PLATFORM=x86-64-netberg-aurora-720-rangeley ARCH=amd64 TOOLCHAIN=x86_64-linux-gnu diff --git a/packages/platforms/netberg/x86-64/aurora-720-rangeley/onlp/builds/Makefile b/packages/platforms/netberg/x86-64/aurora-720-rangeley/onlp/builds/Makefile deleted file mode 100755 index e7437cb23..000000000 --- a/packages/platforms/netberg/x86-64/aurora-720-rangeley/onlp/builds/Makefile +++ /dev/null @@ -1,2 +0,0 @@ -FILTER=src -include $(ONL)/make/subdirs.mk diff --git a/packages/platforms/netberg/x86-64/aurora-720-rangeley/onlp/builds/lib/Makefile b/packages/platforms/netberg/x86-64/aurora-720-rangeley/onlp/builds/lib/Makefile deleted file mode 100755 index 56ccf34b9..000000000 --- a/packages/platforms/netberg/x86-64/aurora-720-rangeley/onlp/builds/lib/Makefile +++ /dev/null @@ -1,2 +0,0 @@ -PLATFORM := x86-64-netberg-aurora-720-rangeley -include $(ONL)/packages/base/any/onlp/builds/platform/libonlp-platform.mk diff --git a/packages/platforms/netberg/x86-64/aurora-720-rangeley/onlp/builds/onlpdump/Makefile b/packages/platforms/netberg/x86-64/aurora-720-rangeley/onlp/builds/onlpdump/Makefile deleted file mode 100755 index 43a184ea7..000000000 --- a/packages/platforms/netberg/x86-64/aurora-720-rangeley/onlp/builds/onlpdump/Makefile +++ /dev/null @@ -1,2 +0,0 @@ -PLATFORM := x86-64-netberg-aurora-720-rangeley -include $(ONL)/packages/base/any/onlp/builds/platform/onlps.mk diff --git a/packages/platforms/netberg/x86-64/aurora-720-rangeley/onlp/builds/x86_64_netberg_aurora_720_rangeley/.gitignore b/packages/platforms/netberg/x86-64/aurora-720-rangeley/onlp/builds/x86_64_netberg_aurora_720_rangeley/.gitignore deleted file mode 100644 index c81d16be3..000000000 --- a/packages/platforms/netberg/x86-64/aurora-720-rangeley/onlp/builds/x86_64_netberg_aurora_720_rangeley/.gitignore +++ /dev/null @@ -1 +0,0 @@ -*.mk diff --git a/packages/platforms/netberg/x86-64/aurora-720-rangeley/onlp/builds/x86_64_netberg_aurora_720_rangeley/.module b/packages/platforms/netberg/x86-64/aurora-720-rangeley/onlp/builds/x86_64_netberg_aurora_720_rangeley/.module deleted file mode 100755 index 5e2f8b9e5..000000000 --- a/packages/platforms/netberg/x86-64/aurora-720-rangeley/onlp/builds/x86_64_netberg_aurora_720_rangeley/.module +++ /dev/null @@ -1 +0,0 @@ -name: x86_64_netberg_aurora_720_rangeley diff --git a/packages/platforms/netberg/x86-64/aurora-720-rangeley/onlp/builds/x86_64_netberg_aurora_720_rangeley/Makefile b/packages/platforms/netberg/x86-64/aurora-720-rangeley/onlp/builds/x86_64_netberg_aurora_720_rangeley/Makefile deleted file mode 100755 index 633255c5b..000000000 --- a/packages/platforms/netberg/x86-64/aurora-720-rangeley/onlp/builds/x86_64_netberg_aurora_720_rangeley/Makefile +++ /dev/null @@ -1,9 +0,0 @@ -############################################################################### -# -# -# -############################################################################### -include $(ONL)/make/config.mk -MODULE := x86_64_netberg_aurora_720_rangeley -AUTOMODULE := x86_64_netberg_aurora_720_rangeley -include $(BUILDER)/definemodule.mk diff --git a/packages/platforms/netberg/x86-64/aurora-720-rangeley/onlp/builds/x86_64_netberg_aurora_720_rangeley/module/auto/make.mk b/packages/platforms/netberg/x86-64/aurora-720-rangeley/onlp/builds/x86_64_netberg_aurora_720_rangeley/module/auto/make.mk deleted file mode 100755 index 0e083d683..000000000 --- a/packages/platforms/netberg/x86-64/aurora-720-rangeley/onlp/builds/x86_64_netberg_aurora_720_rangeley/module/auto/make.mk +++ /dev/null @@ -1,9 +0,0 @@ -############################################################################### -# -# x86_64_netberg_aurora_720_rangeley Autogeneration -# -############################################################################### -x86_64_netberg_aurora_720_rangeley_AUTO_DEFS := module/auto/x86_64_netberg_aurora_720_rangeley.yml -x86_64_netberg_aurora_720_rangeley_AUTO_DIRS := module/inc/x86_64_netberg_aurora_720_rangeley module/src -include $(BUILDER)/auto.mk - diff --git a/packages/platforms/netberg/x86-64/aurora-720-rangeley/onlp/builds/x86_64_netberg_aurora_720_rangeley/module/auto/x86_64_netberg_aurora_720_rangeley.yml b/packages/platforms/netberg/x86-64/aurora-720-rangeley/onlp/builds/x86_64_netberg_aurora_720_rangeley/module/auto/x86_64_netberg_aurora_720_rangeley.yml deleted file mode 100755 index d14f81985..000000000 --- a/packages/platforms/netberg/x86-64/aurora-720-rangeley/onlp/builds/x86_64_netberg_aurora_720_rangeley/module/auto/x86_64_netberg_aurora_720_rangeley.yml +++ /dev/null @@ -1,122 +0,0 @@ -############################################################################### -# -# x86_64_netberg_aurora_720_rangeley Autogeneration Definitions. -# -############################################################################### - -cdefs: &cdefs -- X86_64_NETBERG_AURORA_720_RANGELEY_CONFIG_INCLUDE_LOGGING: - doc: "Include or exclude logging." - default: 1 -- X86_64_NETBERG_AURORA_720_RANGELEY_CONFIG_LOG_OPTIONS_DEFAULT: - doc: "Default enabled log options." - default: AIM_LOG_OPTIONS_DEFAULT -- X86_64_NETBERG_AURORA_720_RANGELEY_CONFIG_LOG_BITS_DEFAULT: - doc: "Default enabled log bits." - default: AIM_LOG_BITS_DEFAULT -- X86_64_NETBERG_AURORA_720_RANGELEY_CONFIG_LOG_CUSTOM_BITS_DEFAULT: - doc: "Default enabled custom log bits." - default: 0 -- X86_64_NETBERG_AURORA_720_RANGELEY_CONFIG_PORTING_STDLIB: - doc: "Default all porting macros to use the C standard libraries." - default: 1 -- X86_64_NETBERG_AURORA_720_RANGELEY_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS: - doc: "Include standard library headers for stdlib porting macros." - default: X86_64_NETBERG_AURORA_720_RANGELEY_CONFIG_PORTING_STDLIB -- X86_64_NETBERG_AURORA_720_RANGELEY_CONFIG_INCLUDE_UCLI: - doc: "Include generic uCli support." - default: 0 -- X86_64_NETBERG_AURORA_720_RANGELEY_CONFIG_SYSFAN_RPM_FAILURE_THRESHOLD: - doc: "RPM Threshold at which the fan is considered to have failed." - default: 3000 - -definitions: - cdefs: - X86_64_NETBERG_AURORA_720_RANGELEY_CONFIG_HEADER: - defs: *cdefs - basename: x86_64_netberg_aurora_720_rangeley_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 - - 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) - - led_id: - members: - - LED1 : 1 - - LED2 : 2 - - LED3 : 3 - - LED4 : 4 - - led_oid: - members: - - 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: - X86_64_NETBERG_AURORA_720_RANGELEY: - macros: - - memset - - memcpy - - - vsnprintf - - snprintf - - strlen diff --git a/packages/platforms/netberg/x86-64/aurora-720-rangeley/onlp/builds/x86_64_netberg_aurora_720_rangeley/module/inc/x86_64_netberg_aurora_720_rangeley/x86_64_netberg_aurora_720_rangeley.x b/packages/platforms/netberg/x86-64/aurora-720-rangeley/onlp/builds/x86_64_netberg_aurora_720_rangeley/module/inc/x86_64_netberg_aurora_720_rangeley/x86_64_netberg_aurora_720_rangeley.x deleted file mode 100755 index 50417fcbd..000000000 --- a/packages/platforms/netberg/x86-64/aurora-720-rangeley/onlp/builds/x86_64_netberg_aurora_720_rangeley/module/inc/x86_64_netberg_aurora_720_rangeley/x86_64_netberg_aurora_720_rangeley.x +++ /dev/null @@ -1,14 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#include - -/* <--auto.start.xmacro(ALL).define> */ -/* */ - -/* <--auto.start.xenum(ALL).define> */ -/* */ - - diff --git a/packages/platforms/netberg/x86-64/aurora-720-rangeley/onlp/builds/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/aurora-720-rangeley/onlp/builds/x86_64_netberg_aurora_720_rangeley/module/inc/x86_64_netberg_aurora_720_rangeley/x86_64_netberg_aurora_720_rangeley_config.h deleted file mode 100755 index 0b0cdeb06..000000000 --- a/packages/platforms/netberg/x86-64/aurora-720-rangeley/onlp/builds/x86_64_netberg_aurora_720_rangeley/module/inc/x86_64_netberg_aurora_720_rangeley/x86_64_netberg_aurora_720_rangeley_config.h +++ /dev/null @@ -1,137 +0,0 @@ -/**************************************************************************//** - * - * @file - * @brief x86_64_netberg_aurora_720_rangeley Configuration Header - * - * @addtogroup x86_64_netberg_aurora_720_rangeley-config - * @{ - * - *****************************************************************************/ -#ifndef __X86_64_NETBERG_AURORA_720_RANGELEY_CONFIG_H__ -#define __X86_64_NETBERG_AURORA_720_RANGELEY_CONFIG_H__ - -#ifdef GLOBAL_INCLUDE_CUSTOM_CONFIG -#include -#endif -#ifdef X86_64_NETBERG_AURORA_720_RANGELEY_INCLUDE_CUSTOM_CONFIG -#include -#endif - -/* */ -#include -/** - * X86_64_NETBERG_AURORA_720_RANGELEY_CONFIG_INCLUDE_LOGGING - * - * Include or exclude logging. */ - - -#ifndef X86_64_NETBERG_AURORA_720_RANGELEY_CONFIG_INCLUDE_LOGGING -#define X86_64_NETBERG_AURORA_720_RANGELEY_CONFIG_INCLUDE_LOGGING 1 -#endif - -/** - * X86_64_NETBERG_AURORA_720_RANGELEY_CONFIG_LOG_OPTIONS_DEFAULT - * - * Default enabled log options. */ - - -#ifndef X86_64_NETBERG_AURORA_720_RANGELEY_CONFIG_LOG_OPTIONS_DEFAULT -#define X86_64_NETBERG_AURORA_720_RANGELEY_CONFIG_LOG_OPTIONS_DEFAULT AIM_LOG_OPTIONS_DEFAULT -#endif - -/** - * X86_64_NETBERG_AURORA_720_RANGELEY_CONFIG_LOG_BITS_DEFAULT - * - * Default enabled log bits. */ - - -#ifndef X86_64_NETBERG_AURORA_720_RANGELEY_CONFIG_LOG_BITS_DEFAULT -#define X86_64_NETBERG_AURORA_720_RANGELEY_CONFIG_LOG_BITS_DEFAULT AIM_LOG_BITS_DEFAULT -#endif - -/** - * X86_64_NETBERG_AURORA_720_RANGELEY_CONFIG_LOG_CUSTOM_BITS_DEFAULT - * - * Default enabled custom log bits. */ - - -#ifndef X86_64_NETBERG_AURORA_720_RANGELEY_CONFIG_LOG_CUSTOM_BITS_DEFAULT -#define X86_64_NETBERG_AURORA_720_RANGELEY_CONFIG_LOG_CUSTOM_BITS_DEFAULT 0 -#endif - -/** - * X86_64_NETBERG_AURORA_720_RANGELEY_CONFIG_PORTING_STDLIB - * - * Default all porting macros to use the C standard libraries. */ - - -#ifndef X86_64_NETBERG_AURORA_720_RANGELEY_CONFIG_PORTING_STDLIB -#define X86_64_NETBERG_AURORA_720_RANGELEY_CONFIG_PORTING_STDLIB 1 -#endif - -/** - * X86_64_NETBERG_AURORA_720_RANGELEY_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS - * - * Include standard library headers for stdlib porting macros. */ - - -#ifndef X86_64_NETBERG_AURORA_720_RANGELEY_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS -#define X86_64_NETBERG_AURORA_720_RANGELEY_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS X86_64_NETBERG_AURORA_720_RANGELEY_CONFIG_PORTING_STDLIB -#endif - -/** - * X86_64_NETBERG_AURORA_720_RANGELEY_CONFIG_INCLUDE_UCLI - * - * Include generic uCli support. */ - - -#ifndef X86_64_NETBERG_AURORA_720_RANGELEY_CONFIG_INCLUDE_UCLI -#define X86_64_NETBERG_AURORA_720_RANGELEY_CONFIG_INCLUDE_UCLI 0 -#endif - -/** - * X86_64_NETBERG_AURORA_720_RANGELEY_CONFIG_SYSFAN_RPM_FAILURE_THRESHOLD - * - * RPM Threshold at which the fan is considered to have failed. */ - - -#ifndef X86_64_NETBERG_AURORA_720_RANGELEY_CONFIG_SYSFAN_RPM_FAILURE_THRESHOLD -#define X86_64_NETBERG_AURORA_720_RANGELEY_CONFIG_SYSFAN_RPM_FAILURE_THRESHOLD 3000 -#endif - - - -/** - * All compile time options can be queried or displayed - */ - -/** Configuration settings structure. */ -typedef struct x86_64_netberg_aurora_720_rangeley_config_settings_s { - /** name */ - const char* name; - /** value */ - const char* value; -} x86_64_netberg_aurora_720_rangeley_config_settings_t; - -/** Configuration settings table. */ -/** x86_64_netberg_aurora_720_rangeley_config_settings table. */ -extern x86_64_netberg_aurora_720_rangeley_config_settings_t x86_64_netberg_aurora_720_rangeley_config_settings[]; - -/** - * @brief Lookup a configuration setting. - * @param setting The name of the configuration option to lookup. - */ -const char* x86_64_netberg_aurora_720_rangeley_config_lookup(const char* setting); - -/** - * @brief Show the compile-time configuration. - * @param pvs The output stream. - */ -int x86_64_netberg_aurora_720_rangeley_config_show(struct aim_pvs_s* pvs); - -/* */ - -#include "x86_64_netberg_aurora_720_rangeley_porting.h" - -#endif /* __X86_64_NETBERG_AURORA_720_RANGELEY_CONFIG_H__ */ -/* @} */ diff --git a/packages/platforms/netberg/x86-64/aurora-720-rangeley/onlp/builds/x86_64_netberg_aurora_720_rangeley/module/inc/x86_64_netberg_aurora_720_rangeley/x86_64_netberg_aurora_720_rangeley_dox.h b/packages/platforms/netberg/x86-64/aurora-720-rangeley/onlp/builds/x86_64_netberg_aurora_720_rangeley/module/inc/x86_64_netberg_aurora_720_rangeley/x86_64_netberg_aurora_720_rangeley_dox.h deleted file mode 100755 index e4d0aa602..000000000 --- a/packages/platforms/netberg/x86-64/aurora-720-rangeley/onlp/builds/x86_64_netberg_aurora_720_rangeley/module/inc/x86_64_netberg_aurora_720_rangeley/x86_64_netberg_aurora_720_rangeley_dox.h +++ /dev/null @@ -1,26 +0,0 @@ -/**************************************************************************//** - * - * x86_64_netberg_aurora_720_rangeley Doxygen Header - * - *****************************************************************************/ -#ifndef __X86_64_NETBERG_AURORA_720_RANGELEY_DOX_H__ -#define __X86_64_NETBERG_AURORA_720_RANGELEY_DOX_H__ - -/** - * @defgroup x86_64_netberg_aurora_720_rangeley x86_64_netberg_aurora_720_rangeley - x86_64_netberg_aurora_720_rangeley Description - * - -The documentation overview for this module should go here. - - * - * @{ - * - * @defgroup x86_64_netberg_aurora_720_rangeley-x86_64_netberg_aurora_720_rangeley Public Interface - * @defgroup x86_64_netberg_aurora_720_rangeley-config Compile Time Configuration - * @defgroup x86_64_netberg_aurora_720_rangeley-porting Porting Macros - * - * @} - * - */ - -#endif /* __X86_64_NETBERG_AURORA_720_RANGELEY_DOX_H__ */ diff --git a/packages/platforms/netberg/x86-64/aurora-720-rangeley/onlp/builds/x86_64_netberg_aurora_720_rangeley/module/inc/x86_64_netberg_aurora_720_rangeley/x86_64_netberg_aurora_720_rangeley_porting.h b/packages/platforms/netberg/x86-64/aurora-720-rangeley/onlp/builds/x86_64_netberg_aurora_720_rangeley/module/inc/x86_64_netberg_aurora_720_rangeley/x86_64_netberg_aurora_720_rangeley_porting.h deleted file mode 100755 index 9e71a4dd6..000000000 --- a/packages/platforms/netberg/x86-64/aurora-720-rangeley/onlp/builds/x86_64_netberg_aurora_720_rangeley/module/inc/x86_64_netberg_aurora_720_rangeley/x86_64_netberg_aurora_720_rangeley_porting.h +++ /dev/null @@ -1,77 +0,0 @@ -/**************************************************************************//** - * - * @file - * @brief x86_64_netberg_aurora_720_rangeley Porting Macros. - * - * @addtogroup x86_64_netberg_aurora_720_rangeley-porting - * @{ - * - *****************************************************************************/ -#ifndef __X86_64_NETBERG_AURORA_720_RANGELEY_PORTING_H__ -#define __X86_64_NETBERG_AURORA_720_RANGELEY_PORTING_H__ - - -/* */ -#if X86_64_NETBERG_AURORA_720_RANGELEY_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS == 1 -#include -#include -#include -#include -#include -#endif - -#ifndef X86_64_NETBERG_AURORA_720_RANGELEY_MEMSET - #if defined(GLOBAL_MEMSET) - #define X86_64_NETBERG_AURORA_720_RANGELEY_MEMSET GLOBAL_MEMSET - #elif X86_64_NETBERG_AURORA_720_RANGELEY_CONFIG_PORTING_STDLIB == 1 - #define X86_64_NETBERG_AURORA_720_RANGELEY_MEMSET memset - #else - #error The macro X86_64_NETBERG_AURORA_720_RANGELEY_MEMSET is required but cannot be defined. - #endif -#endif - -#ifndef X86_64_NETBERG_AURORA_720_RANGELEY_MEMCPY - #if defined(GLOBAL_MEMCPY) - #define X86_64_NETBERG_AURORA_720_RANGELEY_MEMCPY GLOBAL_MEMCPY - #elif X86_64_NETBERG_AURORA_720_RANGELEY_CONFIG_PORTING_STDLIB == 1 - #define X86_64_NETBERG_AURORA_720_RANGELEY_MEMCPY memcpy - #else - #error The macro X86_64_NETBERG_AURORA_720_RANGELEY_MEMCPY is required but cannot be defined. - #endif -#endif - -#ifndef X86_64_NETBERG_AURORA_720_RANGELEY_VSNPRINTF - #if defined(GLOBAL_VSNPRINTF) - #define X86_64_NETBERG_AURORA_720_RANGELEY_VSNPRINTF GLOBAL_VSNPRINTF - #elif X86_64_NETBERG_AURORA_720_RANGELEY_CONFIG_PORTING_STDLIB == 1 - #define X86_64_NETBERG_AURORA_720_RANGELEY_VSNPRINTF vsnprintf - #else - #error The macro X86_64_NETBERG_AURORA_720_RANGELEY_VSNPRINTF is required but cannot be defined. - #endif -#endif - -#ifndef X86_64_NETBERG_AURORA_720_RANGELEY_SNPRINTF - #if defined(GLOBAL_SNPRINTF) - #define X86_64_NETBERG_AURORA_720_RANGELEY_SNPRINTF GLOBAL_SNPRINTF - #elif X86_64_NETBERG_AURORA_720_RANGELEY_CONFIG_PORTING_STDLIB == 1 - #define X86_64_NETBERG_AURORA_720_RANGELEY_SNPRINTF snprintf - #else - #error The macro X86_64_NETBERG_AURORA_720_RANGELEY_SNPRINTF is required but cannot be defined. - #endif -#endif - -#ifndef X86_64_NETBERG_AURORA_720_RANGELEY_STRLEN - #if defined(GLOBAL_STRLEN) - #define X86_64_NETBERG_AURORA_720_RANGELEY_STRLEN GLOBAL_STRLEN - #elif X86_64_NETBERG_AURORA_720_RANGELEY_CONFIG_PORTING_STDLIB == 1 - #define X86_64_NETBERG_AURORA_720_RANGELEY_STRLEN strlen - #else - #error The macro X86_64_NETBERG_AURORA_720_RANGELEY_STRLEN is required but cannot be defined. - #endif -#endif - -/* */ - - -#endif /* __X86_64_NETBERG_AURORA_720_RANGELEY_PORTING_H__ */ -/* @} */ diff --git a/packages/platforms/netberg/x86-64/aurora-720-rangeley/onlp/builds/x86_64_netberg_aurora_720_rangeley/module/make.mk b/packages/platforms/netberg/x86-64/aurora-720-rangeley/onlp/builds/x86_64_netberg_aurora_720_rangeley/module/make.mk deleted file mode 100755 index 38ee23fee..000000000 --- a/packages/platforms/netberg/x86-64/aurora-720-rangeley/onlp/builds/x86_64_netberg_aurora_720_rangeley/module/make.mk +++ /dev/null @@ -1,10 +0,0 @@ -############################################################################### -# -# -# -############################################################################### -THIS_DIR := $(dir $(lastword $(MAKEFILE_LIST))) -x86_64_netberg_aurora_720_rangeley_INCLUDES := -I $(THIS_DIR)inc -x86_64_netberg_aurora_720_rangeley_INTERNAL_INCLUDES := -I $(THIS_DIR)src -x86_64_netberg_aurora_720_rangeley_DEPENDMODULE_ENTRIES := init:x86_64_netberg_aurora_720_rangeley ucli:x86_64_netberg_aurora_720_rangeley - diff --git a/packages/platforms/netberg/x86-64/aurora-720-rangeley/onlp/builds/x86_64_netberg_aurora_720_rangeley/module/src/Makefile b/packages/platforms/netberg/x86-64/aurora-720-rangeley/onlp/builds/x86_64_netberg_aurora_720_rangeley/module/src/Makefile deleted file mode 100755 index 0a2eb4ed0..000000000 --- a/packages/platforms/netberg/x86-64/aurora-720-rangeley/onlp/builds/x86_64_netberg_aurora_720_rangeley/module/src/Makefile +++ /dev/null @@ -1,9 +0,0 @@ -############################################################################### -# -# Local source generation targets. -# -############################################################################### - -ucli: - @../../../../tools/uclihandlers.py x86_64_netberg_aurora_720_rangeley_ucli.c - diff --git a/packages/platforms/netberg/x86-64/aurora-720-rangeley/onlp/builds/x86_64_netberg_aurora_720_rangeley/module/src/fani.c b/packages/platforms/netberg/x86-64/aurora-720-rangeley/onlp/builds/x86_64_netberg_aurora_720_rangeley/module/src/fani.c deleted file mode 100755 index 7265ee40a..000000000 --- a/packages/platforms/netberg/x86-64/aurora-720-rangeley/onlp/builds/x86_64_netberg_aurora_720_rangeley/module/src/fani.c +++ /dev/null @@ -1,234 +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 "x86_64_netberg_aurora_720_rangeley_int.h" -#include "x86_64_netberg_aurora_720_rangeley_log.h" - -#include - - -#define VALIDATE(_id) \ - do { \ - if(!ONLP_OID_IS_FAN(_id)) { \ - return ONLP_STATUS_E_INVALID; \ - } \ - } while(0) - -static int -sys_fan_info_get__(onlp_fan_info_t* info, int id) -{ - int value = 0; - int rv; - - rv = onlp_file_read_int(&value, SYS_HWMON2_PREFIX "/fan%d_abs", ((id/2)+1)); - if (rv != ONLP_STATUS_OK) - return rv; - - if (value == 0) - { - info->status = ONLP_FAN_STATUS_FAILED; - } - else - { - info->status = ONLP_FAN_STATUS_PRESENT; - - rv = onlp_file_read_int(&value, SYS_HWMON2_PREFIX "/fan%d_dir", ((id/2)+1)); - if (rv != ONLP_STATUS_OK) - return rv; - - if (value == 1) - { - info->status |= ONLP_FAN_STATUS_B2F; - info->caps |= ONLP_FAN_CAPS_B2F; - } - else - { - info->status |= ONLP_FAN_STATUS_F2B; - info->caps |= ONLP_FAN_CAPS_F2B; - } - - rv = onlp_file_read_int(&(info->rpm), SYS_HWMON1_PREFIX "/fan%d_rpm", (id+1)); - if (rv == ONLP_STATUS_E_INTERNAL) - return rv; - - if (rv == ONLP_STATUS_E_MISSING) - { - info->status &= ~1; - return 0; - } - - if (info->rpm <= X86_64_NETBERG_AURORA_720_RANGELEY_CONFIG_SYSFAN_RPM_FAILURE_THRESHOLD) - info->status |= ONLP_FAN_STATUS_FAILED; - - - rv = onlp_file_read_int(&(info->percentage), SYS_HWMON1_PREFIX "/fan%d_duty", (id+1)); - if (rv == ONLP_STATUS_E_INTERNAL) - return rv; - - if (rv == ONLP_STATUS_E_MISSING) - { - info->status &= ~1; - return 0; - } - } - return 0; -} - -static int -psu_fan_info_get__(onlp_fan_info_t* info, int id) -{ - return onlp_file_read_int(&(info->rpm), SYS_HWMON2_PREFIX "/psu%d_fan_speed", id); -} - -/* Onboard Fans */ -static onlp_fan_info_t fans__[] = { - { }, /* Not used */ - { { FAN_OID_FAN1, "Fan1_rotor1", 0}, ONLP_FAN_STATUS_PRESENT }, - { { FAN_OID_FAN2, "Fan1_rotor2", 0}, ONLP_FAN_STATUS_PRESENT }, - { { FAN_OID_FAN3, "Fan2_rotor1", 0}, ONLP_FAN_STATUS_PRESENT }, - { { FAN_OID_FAN4, "Fan2_rotor2", 0}, ONLP_FAN_STATUS_PRESENT }, - { { FAN_OID_FAN5, "Fan3_rotor1", 0}, ONLP_FAN_STATUS_PRESENT }, - { { FAN_OID_FAN6, "Fan3_rotor2", 0}, ONLP_FAN_STATUS_PRESENT }, - { { FAN_OID_FAN7, "Fan4_rotor1", 0}, ONLP_FAN_STATUS_PRESENT }, - { { FAN_OID_FAN8, "Fan4_rotor2", 0}, ONLP_FAN_STATUS_PRESENT }, - { { FAN_OID_FAN9, "PSU-1 Fan", 0 }, ONLP_FAN_STATUS_PRESENT }, - { { FAN_OID_FAN10, "PSU-2 Fan", 0 }, ONLP_FAN_STATUS_PRESENT }, -}; - -/* - * 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 fid; - - VALIDATE(id); - - memset(info, 0, sizeof(onlp_fan_info_t)); - fid = ONLP_OID_ID_GET(id); - *info = fans__[fid]; - - info->caps |= ONLP_FAN_CAPS_GET_RPM; - - switch(fid) - { - case FAN_ID_FAN1: - case FAN_ID_FAN2: - case FAN_ID_FAN3: - case FAN_ID_FAN4: - case FAN_ID_FAN5: - case FAN_ID_FAN6: - case FAN_ID_FAN7: - case FAN_ID_FAN8: - return sys_fan_info_get__(info, (fid - 1)); - break; - - case FAN_ID_FAN9: - case FAN_ID_FAN10: - return psu_fan_info_get__(info, (fid - FAN_ID_FAN9 + 1)); - break; - - default: - return ONLP_STATUS_E_INVALID; - break; - } - - return ONLP_STATUS_E_INVALID; -} - -/* - * 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) -{ - return ONLP_STATUS_E_UNSUPPORTED; -} - -/* - * 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/netberg/x86-64/aurora-720-rangeley/onlp/builds/x86_64_netberg_aurora_720_rangeley/module/src/ledi.c b/packages/platforms/netberg/x86-64/aurora-720-rangeley/onlp/builds/x86_64_netberg_aurora_720_rangeley/module/src/ledi.c deleted file mode 100755 index d906a48cf..000000000 --- a/packages/platforms/netberg/x86-64/aurora-720-rangeley/onlp/builds/x86_64_netberg_aurora_720_rangeley/module/src/ledi.c +++ /dev/null @@ -1,165 +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 "x86_64_netberg_aurora_720_rangeley_int.h" - -#define VALIDATE(_id) \ - do { \ - if(!ONLP_OID_IS_LED(_id)) { \ - return ONLP_STATUS_E_INVALID; \ - } \ - } while(0) - -/* LED related data - */ -enum led_light_mode { /*must be the same with the definition @ kernel driver */ - LED_MODE_OFF = 0, - LED_MODE_AMBER, - LED_MODE_GREEN, -}; - -int led_light_map_mode[][2] = -{ - {LED_MODE_OFF, ONLP_LED_MODE_OFF}, - {LED_MODE_AMBER, ONLP_LED_MODE_ORANGE}, - {LED_MODE_GREEN, ONLP_LED_MODE_GREEN}, -}; - -/* - * Get the information for the given LED OID. - */ -static onlp_led_info_t linfo[] = -{ - { }, /* Not used */ - { - { LED_OID_LED1, "Chassis LED 1 (STAT LED)", 0 }, - ONLP_LED_STATUS_PRESENT, - ONLP_LED_CAPS_ON_OFF | ONLP_LED_CAPS_ORANGE | ONLP_LED_CAPS_GREEN, - ONLP_LED_MODE_OFF, - }, -}; - -static int conver_led_light_mode_to_driver(int led_ligth_mode) -{ - int i, nsize = sizeof(led_light_map_mode)/sizeof(led_light_map_mode[0]); - for(i=0; i - * - ************************************************************ - * - * - * - ***********************************************************/ -#include -#include -#include -#include "x86_64_netberg_aurora_720_rangeley_int.h" -#include "x86_64_netberg_aurora_720_rangeley_log.h" - -#define VALIDATE(_id) \ - do { \ - if(!ONLP_OID_IS_PSU(_id)) { \ - return ONLP_STATUS_E_INVALID; \ - } \ - } while(0) - -static onlp_psu_info_t psus__[] = { - { }, /* Not used */ - { - { - PSU_OID_PSU1, - "PSU-1", - 0, - { - FAN_OID_FAN9, - }, - } - }, - { - { - PSU_OID_PSU2, - "PSU-2", - 0, - { - FAN_OID_FAN10, - }, - } - }, -}; - -/* - * This function will be called prior to any other onlp_psui functions. - */ -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; - int pid; - uint8_t data[256]; - int value = -1; - int len; - double dvalue; - int i; - - VALIDATE(id); - - memset(info, 0, sizeof(onlp_psu_info_t)); - pid = ONLP_OID_ID_GET(id); - *info = psus__[pid]; - - rv = onlp_file_read_int(&value, SYS_HWMON1_PREFIX "/psu%d_abs", pid); - if (rv != ONLP_STATUS_OK) - return rv; - if (value == 0) - { - info->status = ONLP_PSU_STATUS_UNPLUGGED; - return ONLP_STATUS_OK; - } - - /* PSU is present. */ - info->status = ONLP_PSU_STATUS_PRESENT; - - memset(data, 0, sizeof(data)); - rv = onlp_file_read(data, sizeof(data), &len, SYS_HWMON2_PREFIX "/psu%d_eeprom", pid); - if (rv == ONLP_STATUS_OK) - { - i = 11; - - /* Manufacturer Name */ - len = (data[i]&0x0f); - i++; - i += len; - - /* Product Name */ - len = (data[i]&0x0f); - i++; - memcpy(info->model, (char *) &(data[i]), len); - i += len; - - /* Product part,model number */ - len = (data[i]&0x0f); - i++; - i += len; - - /* Product Version */ - len = (data[i]&0x0f); - i++; - i += len; - - /* Product Serial Number */ - len = (data[i]&0x0f); - i++; - memcpy(info->serial, (char *) &(data[i]), len); - } - else - { - strcpy(info->model, "Missing"); - strcpy(info->serial, "Missing"); - } - - info->caps |= ONLP_PSU_CAPS_AC; - -#if 0 - /* PSU is powered. */ - rv = onlp_file_read_int(&value, SYS_HWMON1_PREFIX "/psu%d_pg", pid); - if (rv != ONLP_STATUS_OK) - return rv; - if (value == 0) - { - info->status |= ONLP_PSU_STATUS_FAILED; - return ONLP_STATUS_OK; - } -#endif - - memset(data, 0, sizeof(data)); - rv = onlp_file_read(data, sizeof(data), &len, SYS_HWMON2_PREFIX "/psu%d_iout", pid); - if (rv == ONLP_STATUS_OK) - { - dvalue = atof((const char *)data); - if (dvalue > 0.0) - { - info->caps |= ONLP_PSU_CAPS_IOUT; - info->miout = (int)(dvalue * 1000); - } - } - - memset(data, 0, sizeof(data)); - rv = onlp_file_read(data, sizeof(data), &len, SYS_HWMON2_PREFIX "/psu%d_vout", pid); - if (rv == ONLP_STATUS_OK) - { - dvalue = atof((const char *)data); - if (dvalue > 0.0) - { - info->caps |= ONLP_PSU_CAPS_VOUT; - info->mvout = (int)(dvalue * 1000); - } - } - - memset(data, 0, sizeof(data)); - rv = onlp_file_read(data, sizeof(data), &len, SYS_HWMON2_PREFIX "/psu%d_pin", pid); - if (rv == ONLP_STATUS_OK) - { - dvalue = atof((const char *)data); - if (dvalue > 0.0) - { - info->caps |= ONLP_PSU_CAPS_PIN; - info->mpin = (int)(dvalue * 1000); - } - } - - memset(data, 0, sizeof(data)); - rv = onlp_file_read(data, sizeof(data), &len, SYS_HWMON2_PREFIX "/psu%d_pout", pid); - if (rv == ONLP_STATUS_OK) - { - dvalue = atof((const char *)data); - if (dvalue > 0.0) - { - info->caps |= ONLP_PSU_CAPS_POUT; - info->mpout = (int)(dvalue * 1000); - } - } - - return ONLP_STATUS_OK; -} - -/* - * This is an optional generic ioctl() interface. - * Its purpose is to allow future expansion and - * custom functionality that is not otherwise exposed - * in the standard interface. - * - * The semantics of this function are platform specific. - * This function is completely optional. - */ -int -onlp_psui_ioctl(onlp_oid_t pid, va_list vargs) -{ - return ONLP_STATUS_E_UNSUPPORTED; -} - diff --git a/packages/platforms/netberg/x86-64/aurora-720-rangeley/onlp/builds/x86_64_netberg_aurora_720_rangeley/module/src/sfpi.c b/packages/platforms/netberg/x86-64/aurora-720-rangeley/onlp/builds/x86_64_netberg_aurora_720_rangeley/module/src/sfpi.c deleted file mode 100755 index 51e892e0f..000000000 --- a/packages/platforms/netberg/x86-64/aurora-720-rangeley/onlp/builds/x86_64_netberg_aurora_720_rangeley/module/src/sfpi.c +++ /dev/null @@ -1,389 +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. - * - * - ************************************************************ - * - * SFPI Interface for the Aurora 720 Platform - * - ***********************************************************/ -#include -#include -#include -#include -#include -#include "x86_64_netberg_aurora_720_rangeley_int.h" -#include "x86_64_netberg_aurora_720_rangeley_log.h" - -#include -#include - -/* Model ID Definition */ -typedef enum -{ - HURACAN_WITH_BMC = 0x0, - HURACAN_WITHOUT_BMC, - CABRERAIII_WITH_BMC, - CABRERAIII_WITHOUT_BMC, - SESTO_WITH_BMC, - SESTO_WITHOUT_BMC, - NCIIX_WITH_BMC, - NCIIX_WITHOUT_BMC, - ASTERION_WITH_BMC, - ASTERION_WITHOUT_BMC, - HURACAN_A_WITH_BMC, - HURACAN_A_WITHOUT_BMC, - - MODEL_ID_LAST -} modelId_t; - -static int -onlp_board_model_id_get(void) -{ - static int board_model_id = MODEL_ID_LAST; - - if (board_model_id == MODEL_ID_LAST) - { - if (onlp_file_read_int(&board_model_id, SYS_HWMON1_PREFIX "/board_model_id") != ONLP_STATUS_OK) - return 0; - } - - return board_model_id; -} - -/* - * This function will be called prior to all other onlp_sfpi_* functions. - */ -int -onlp_sfpi_init(void) -{ - return ONLP_STATUS_OK; -} - -/* - * This function should populate the give bitmap with - * all valid, SFP-capable port numbers. - * - * Only port numbers in this bitmap will be queried by the the - * ONLP framework. - * - * No SFPI functions will be called with ports that are - * not in this bitmap. You can ignore all error checking - * on the incoming ports defined in this interface. - */ -int -onlp_sfpi_bitmap_get(onlp_sfp_bitmap_t* bmap) -{ - int p; - int total_port = 0; - int board_model_id = onlp_board_model_id_get(); - - switch (board_model_id) - { - case HURACAN_WITH_BMC: - case HURACAN_WITHOUT_BMC: - case HURACAN_A_WITH_BMC: - case HURACAN_A_WITHOUT_BMC: - total_port = 32; - break; - - case SESTO_WITH_BMC: - case SESTO_WITHOUT_BMC: - case NCIIX_WITH_BMC: - case NCIIX_WITHOUT_BMC: - total_port = 54; - break; - - case ASTERION_WITH_BMC: - case ASTERION_WITHOUT_BMC: - total_port = 64; - break; - - default: - break; - } - - AIM_BITMAP_CLR_ALL(bmap); - for(p = 0; p < total_port; p++) - AIM_BITMAP_SET(bmap, p); - - return ONLP_STATUS_OK; -} - -/* - * This function should return whether an SFP is inserted on the given - * port. - * - * Returns 1 if the SFP is present. - * Returns 0 if the SFP is not present. - * Returns ONLP_E_* if there was an error determining the status. - */ -int -onlp_sfpi_is_present(int port) -{ - int value = 0; - - onlp_file_read_int(&value, SYS_HWMON2_PREFIX "/port_%d_abs", (port+1)); - return value; -} - -int -onlp_sfpi_port_map(int port, int* rport) -{ - int board_model_id = onlp_board_model_id_get(); - - switch (board_model_id) - { - case HURACAN_WITH_BMC: - case HURACAN_WITHOUT_BMC: - case HURACAN_A_WITH_BMC: - case HURACAN_A_WITHOUT_BMC: - /* odd <=> even */ - if (port & 0x1) - *rport = (port - 1); - else - *rport = (port + 1); - break; - - default: - *rport = port; break; - } - - return ONLP_STATUS_OK; -} - -int -onlp_sfpi_presence_bitmap_get(onlp_sfp_bitmap_t* dst) -{ - return ONLP_STATUS_E_UNSUPPORTED; -} - -int -onlp_sfpi_rx_los_bitmap_get(onlp_sfp_bitmap_t* bmap) -{ - int p; - int total_port = 0; - int board_model_id = onlp_board_model_id_get(); - - switch (board_model_id) - { - case SESTO_WITH_BMC: - case SESTO_WITHOUT_BMC: - case NCIIX_WITH_BMC: - case NCIIX_WITHOUT_BMC: - case ASTERION_WITH_BMC: - case ASTERION_WITHOUT_BMC: - total_port = 48; - break; - - default: - break; - } - - AIM_BITMAP_CLR_ALL(bmap); - for(p = 0; p < total_port; p++) - AIM_BITMAP_SET(bmap, p); - - return ONLP_STATUS_OK; -} - -/* - * This function reads the SFPs idrom and returns in - * in the data buffer provided. - */ -int -onlp_sfpi_eeprom_read(int port, uint8_t data[256]) -{ - int rv = ONLP_STATUS_OK; - char fname[128]; - - memset(data, 0, 256); - memset(fname, 0, sizeof(fname)); - sprintf(fname, SYS_HWMON2_PREFIX "/port_%d_data_a0", (port+1)); - rv = onlplib_sfp_eeprom_read_file(fname, data); - if (rv != ONLP_STATUS_OK) - AIM_LOG_INFO("Unable to read eeprom from port(%d)\r\n", port); - - return rv; -} - -int -onlp_sfpi_dom_read(int port, uint8_t data[256]) -{ - int rv = ONLP_STATUS_OK; - char fname[128]; - - memset(data, 0, 256); - memset(fname, 0, sizeof(fname)); - sprintf(fname, SYS_HWMON2_PREFIX "/port_%d_data_a2", (port+1)); - rv = onlplib_sfp_eeprom_read_file(fname, data); - if (rv != ONLP_STATUS_OK) - AIM_LOG_INFO("Unable to read eeprom from port(%d)\r\n", port); - - return rv; -} - -/* - * Manually enable or disable the given SFP. - * - */ -int -onlp_sfpi_enable_set(int port, int enable) -{ - return ONLP_STATUS_E_UNSUPPORTED; -} - -/* - * Returns whether the SFP is currently enabled or disabled. - */ -int -onlp_sfpi_enable_get(int port, int* enable) -{ - return ONLP_STATUS_E_UNSUPPORTED; -} - -/* - * If the platform requires any setup or equalizer modifications - * based on the actual SFP that was inserted then that custom - * setup should be performed here. - * - * After a new SFP is detected by the ONLP framework this - * function will be called to perform the (optional) setup. - */ -int -onlp_sfpi_post_insert(int port, sff_info_t* sff_info) -{ - return ONLP_STATUS_E_UNSUPPORTED; -} - -/* - * Return the current status of the SFP. - * See onlp_sfp_status_t; - */ -int -onlp_sfpi_status_get(int port, uint32_t* status) -{ - return ONLP_STATUS_E_UNSUPPORTED; -} - -int onlp_sfpi_control_supported(int port, onlp_sfp_control_t control, int* supported) -{ - if (supported == NULL) - return ONLP_STATUS_E_PARAM; - - *supported = 0; - switch (control) - { - case ONLP_SFP_CONTROL_TX_DISABLE: - case ONLP_SFP_CONTROL_RX_LOS: - { - int board_model_id = onlp_board_model_id_get(); - - switch (board_model_id) - { - case SESTO_WITH_BMC: - case SESTO_WITHOUT_BMC: - case NCIIX_WITH_BMC: - case NCIIX_WITHOUT_BMC: - case ASTERION_WITH_BMC: - case ASTERION_WITHOUT_BMC: - if (port < 48) - *supported = 1; - break; - - default: - break; - } - } - break; - - default: - break; - } - - return ONLP_STATUS_OK; -} - -int -onlp_sfpi_control_set(int port, onlp_sfp_control_t control, int value) -{ - int rv = ONLP_STATUS_OK; - int supported = 0; - - if ((onlp_sfpi_control_supported(port, control, &supported) == ONLP_STATUS_OK) && (supported == 0)) - return ONLP_STATUS_E_UNSUPPORTED; - - switch (control) - { - case ONLP_SFP_CONTROL_TX_DISABLE: - rv = onlp_file_write_int(value, SYS_HWMON2_PREFIX "/port_%d_tx_disable", (port+1)); - break; - - default: - break; - } - return rv; -} - -int -onlp_sfpi_control_get(int port, onlp_sfp_control_t control, int* value) -{ - int rv = ONLP_STATUS_OK; - int supported = 0; - - if (value == NULL) - return ONLP_STATUS_E_PARAM; - - if ((onlp_sfpi_control_supported(port, control, &supported) == ONLP_STATUS_OK) && (supported == 0)) - return ONLP_STATUS_E_UNSUPPORTED; - - *value = 0; - switch (control) - { - case ONLP_SFP_CONTROL_RX_LOS: - rv = onlp_file_read_int(value, SYS_HWMON2_PREFIX "/port_%d_rxlos", (port+1)); - break; - - case ONLP_SFP_CONTROL_TX_DISABLE: - rv = onlp_file_read_int(value, SYS_HWMON2_PREFIX "/port_%d_tx_disable", (port+1)); - break; - - default: - break; - } - return rv; -} - -/* - * This is a generic ioctl interface. - */ -int -onlp_sfpi_ioctl(int port, va_list vargs) -{ - return ONLP_STATUS_E_UNSUPPORTED; -} - -/* - * De-initialize the SFPI subsystem. - */ -int -onlp_sfpi_denit(void) -{ - return ONLP_STATUS_OK; -} - diff --git a/packages/platforms/netberg/x86-64/aurora-720-rangeley/onlp/builds/x86_64_netberg_aurora_720_rangeley/module/src/sysi.c b/packages/platforms/netberg/x86-64/aurora-720-rangeley/onlp/builds/x86_64_netberg_aurora_720_rangeley/module/src/sysi.c deleted file mode 100755 index 1ad61f843..000000000 --- a/packages/platforms/netberg/x86-64/aurora-720-rangeley/onlp/builds/x86_64_netberg_aurora_720_rangeley/module/src/sysi.c +++ /dev/null @@ -1,98 +0,0 @@ -/************************************************************ - * - * - ************************************************************ - * - * - * - ***********************************************************/ -#include -#include -#include "x86_64_netberg_aurora_720_rangeley_int.h" -#include "x86_64_netberg_aurora_720_rangeley_log.h" - -/* - * This is the first function called by the ONLP framework. - * - * It should return the name of your platform driver. - * - * If the name of your platform driver is the same as the - * current platform then this driver will be used. - * - * If the name of the driver is different from the current - * platform, or the driver is capable of supporting multiple - * platform variants, see onlp_sysi_platform_set() below. - */ -const char* -onlp_sysi_platform_get(void) -{ - return "x86-64-netberg-aurora-720-rangeley-r0"; -} - -/* - * This is the first function the ONLP framework will call - * after it has validated the the platform is supported using the mechanisms - * described above. - * - * If this function does not return ONL_STATUS_OK - * then platform initialization is aborted. - */ -int -onlp_sysi_init(void) -{ - return ONLP_STATUS_OK; -} - -int -onlp_sysi_onie_info_get(onlp_onie_info_t* onie) -{ - int rv; - uint8_t data[256]; - int len; - - memset(data, 0, sizeof(data)); - rv = onlp_file_read(data, sizeof(data), &len, SYS_HWMON2_PREFIX "/eeprom"); - if (rv == ONLP_STATUS_OK) - { - rv = onlp_onie_decode(onie, (uint8_t*)data, sizeof(data)); - if(rv >= 0) - { - onie->platform_name = aim_strdup("x86-64-netberg-aurora-720-rangeley-r0"); - } - } - 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)); - int i; - int n_thermal=7, n_fan=10, n_led=1; - - /* 2 PSUs */ - *e++ = ONLP_PSU_ID_CREATE(1); - *e++ = ONLP_PSU_ID_CREATE(2); - - /* LEDs Item */ - for (i=1; i<=n_led; i++) - { - *e++ = ONLP_LED_ID_CREATE(i); - } - - /* THERMALs Item */ - for (i=1; i<=n_thermal; i++) - { - *e++ = ONLP_THERMAL_ID_CREATE(i); - } - - /* Fans Item */ - for (i=1; i<=n_fan; i++) - { - *e++ = ONLP_FAN_ID_CREATE(i); - } - - return 0; -} - diff --git a/packages/platforms/netberg/x86-64/aurora-720-rangeley/onlp/builds/x86_64_netberg_aurora_720_rangeley/module/src/thermali.c b/packages/platforms/netberg/x86-64/aurora-720-rangeley/onlp/builds/x86_64_netberg_aurora_720_rangeley/module/src/thermali.c deleted file mode 100755 index 07495f6f5..000000000 --- a/packages/platforms/netberg/x86-64/aurora-720-rangeley/onlp/builds/x86_64_netberg_aurora_720_rangeley/module/src/thermali.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 "x86_64_netberg_aurora_720_rangeley_int.h" -#include "x86_64_netberg_aurora_720_rangeley_log.h" - -#define VALIDATE(_id) \ - do { \ - if(!ONLP_OID_IS_THERMAL(_id)) { \ - return ONLP_STATUS_E_INVALID; \ - } \ - } while(0) - -static int -sys_thermal_info_get__(onlp_thermal_info_t* info, int id) -{ - int rv; - - if (id == THERMAL_ID_THERMAL3) - { - rv = onlp_file_read_int(&info->mcelsius, SYS_HWMON1_PREFIX "/mac_temp"); - info->mcelsius *= 1000; - } - else - { - uint8_t buffer[64]; - double dvalue; - int len; - - memset(buffer, 0, sizeof(buffer)); - rv = onlp_file_read(buffer, sizeof(buffer), &len, SYS_HWMON1_PREFIX "/remote_temp%d", id); - if (rv == ONLP_STATUS_OK) - { - dvalue = atof((const char *)buffer); - info->mcelsius = (int)(dvalue * 1000); - } - } - - if(rv == ONLP_STATUS_E_INTERNAL) - return rv; - - if(rv == ONLP_STATUS_E_MISSING) - { - info->status &= ~1; - return ONLP_STATUS_OK; - } - - return ONLP_STATUS_OK; -} - -static int -psu1_thermal_info_get__(onlp_thermal_info_t* info, int id) -{ - int rv; - uint8_t buffer[64]; - double dvalue; - int len; - - memset(buffer, 0, sizeof(buffer)); - rv = onlp_file_read(buffer, sizeof(buffer), &len, SYS_HWMON2_PREFIX "/psu1_temp_%d", id); - if (rv == ONLP_STATUS_OK) - { - dvalue = atof((const char *)buffer); - info->mcelsius = (int)(dvalue * 1000); - } - return rv; -} - -static int -psu2_thermal_info_get__(onlp_thermal_info_t* info, int id) -{ - int rv; - uint8_t buffer[64]; - double dvalue; - int len; - - memset(buffer, 0, sizeof(buffer)); - rv = onlp_file_read(buffer, sizeof(buffer), &len, SYS_HWMON2_PREFIX "/psu2_temp_%d", id); - if (rv == ONLP_STATUS_OK) - { - dvalue = atof((const char *)buffer); - info->mcelsius = (int)(dvalue * 1000); - } - return rv; -} - -static onlp_thermal_info_t temps__[] = -{ - { }, /* Not used */ - { { THERMAL_OID_THERMAL1, "Chassis Thermal 1 (Front of MAC)", 0}, ONLP_THERMAL_STATUS_PRESENT, ONLP_THERMAL_CAPS_GET_TEMPERATURE, 0}, - { { THERMAL_OID_THERMAL2, "Chassis Thermal 2 (Rear of MAC)", 0}, ONLP_THERMAL_STATUS_PRESENT, ONLP_THERMAL_CAPS_GET_TEMPERATURE, 0}, - { { THERMAL_OID_THERMAL3, "Chassis Thermal 3 (MAC)", 0}, ONLP_THERMAL_STATUS_PRESENT, ONLP_THERMAL_CAPS_GET_TEMPERATURE, 0}, - - { { THERMAL_OID_THERMAL4, "PSU-1 Thermal 1", PSU_OID_PSU1 }, ONLP_THERMAL_STATUS_PRESENT, ONLP_THERMAL_CAPS_GET_TEMPERATURE, 0}, - { { THERMAL_OID_THERMAL5, "PSU-1 Thermal 2", PSU_OID_PSU1 }, ONLP_THERMAL_STATUS_PRESENT, ONLP_THERMAL_CAPS_GET_TEMPERATURE, 0}, - - { { THERMAL_OID_THERMAL6, "PSU-2 Thermal 1", PSU_OID_PSU2 }, ONLP_THERMAL_STATUS_PRESENT, ONLP_THERMAL_CAPS_GET_TEMPERATURE, 0}, - { { THERMAL_OID_THERMAL7, "PSU-2 Thermal 2", PSU_OID_PSU2 }, ONLP_THERMAL_STATUS_PRESENT, ONLP_THERMAL_CAPS_GET_TEMPERATURE, 0}, -}; - - -/* - * 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); - - memset(info, 0, sizeof(onlp_thermal_info_t)); - tid = ONLP_OID_ID_GET(id); - *info = temps__[tid]; - - switch(tid) - { - case THERMAL_ID_THERMAL1: - case THERMAL_ID_THERMAL2: - case THERMAL_ID_THERMAL3: - return sys_thermal_info_get__(info, tid); - - case THERMAL_ID_THERMAL4: - case THERMAL_ID_THERMAL5: - return psu1_thermal_info_get__(info, (tid - THERMAL_ID_THERMAL4 + 1)); - - case THERMAL_ID_THERMAL6: - case THERMAL_ID_THERMAL7: - return psu2_thermal_info_get__(info, (tid - THERMAL_ID_THERMAL6 + 1)); - } - - return ONLP_STATUS_E_INVALID; -} - diff --git a/packages/platforms/netberg/x86-64/aurora-720-rangeley/onlp/builds/x86_64_netberg_aurora_720_rangeley/module/src/x86_64_netberg_aurora_720_rangeley_config.c b/packages/platforms/netberg/x86-64/aurora-720-rangeley/onlp/builds/x86_64_netberg_aurora_720_rangeley/module/src/x86_64_netberg_aurora_720_rangeley_config.c deleted file mode 100755 index 67664446e..000000000 --- a/packages/platforms/netberg/x86-64/aurora-720-rangeley/onlp/builds/x86_64_netberg_aurora_720_rangeley/module/src/x86_64_netberg_aurora_720_rangeley_config.c +++ /dev/null @@ -1,80 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#include - -/* */ -#define __x86_64_netberg_aurora_720_rangeley_config_STRINGIFY_NAME(_x) #_x -#define __x86_64_netberg_aurora_720_rangeley_config_STRINGIFY_VALUE(_x) __x86_64_netberg_aurora_720_rangeley_config_STRINGIFY_NAME(_x) -x86_64_netberg_aurora_720_rangeley_config_settings_t x86_64_netberg_aurora_720_rangeley_config_settings[] = -{ -#ifdef X86_64_NETBERG_AURORA_720_RANGELEY_CONFIG_INCLUDE_LOGGING - { __x86_64_netberg_aurora_720_rangeley_config_STRINGIFY_NAME(X86_64_NETBERG_AURORA_720_RANGELEY_CONFIG_INCLUDE_LOGGING), __x86_64_netberg_aurora_720_rangeley_config_STRINGIFY_VALUE(X86_64_NETBERG_AURORA_720_RANGELEY_CONFIG_INCLUDE_LOGGING) }, -#else -{ X86_64_NETBERG_AURORA_720_RANGELEY_CONFIG_INCLUDE_LOGGING(__x86_64_netberg_aurora_720_rangeley_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_NETBERG_AURORA_720_RANGELEY_CONFIG_LOG_OPTIONS_DEFAULT - { __x86_64_netberg_aurora_720_rangeley_config_STRINGIFY_NAME(X86_64_NETBERG_AURORA_720_RANGELEY_CONFIG_LOG_OPTIONS_DEFAULT), __x86_64_netberg_aurora_720_rangeley_config_STRINGIFY_VALUE(X86_64_NETBERG_AURORA_720_RANGELEY_CONFIG_LOG_OPTIONS_DEFAULT) }, -#else -{ X86_64_NETBERG_AURORA_720_RANGELEY_CONFIG_LOG_OPTIONS_DEFAULT(__x86_64_netberg_aurora_720_rangeley_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_NETBERG_AURORA_720_RANGELEY_CONFIG_LOG_BITS_DEFAULT - { __x86_64_netberg_aurora_720_rangeley_config_STRINGIFY_NAME(X86_64_NETBERG_AURORA_720_RANGELEY_CONFIG_LOG_BITS_DEFAULT), __x86_64_netberg_aurora_720_rangeley_config_STRINGIFY_VALUE(X86_64_NETBERG_AURORA_720_RANGELEY_CONFIG_LOG_BITS_DEFAULT) }, -#else -{ X86_64_NETBERG_AURORA_720_RANGELEY_CONFIG_LOG_BITS_DEFAULT(__x86_64_netberg_aurora_720_rangeley_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_NETBERG_AURORA_720_RANGELEY_CONFIG_LOG_CUSTOM_BITS_DEFAULT - { __x86_64_netberg_aurora_720_rangeley_config_STRINGIFY_NAME(X86_64_NETBERG_AURORA_720_RANGELEY_CONFIG_LOG_CUSTOM_BITS_DEFAULT), __x86_64_netberg_aurora_720_rangeley_config_STRINGIFY_VALUE(X86_64_NETBERG_AURORA_720_RANGELEY_CONFIG_LOG_CUSTOM_BITS_DEFAULT) }, -#else -{ X86_64_NETBERG_AURORA_720_RANGELEY_CONFIG_LOG_CUSTOM_BITS_DEFAULT(__x86_64_netberg_aurora_720_rangeley_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_NETBERG_AURORA_720_RANGELEY_CONFIG_PORTING_STDLIB - { __x86_64_netberg_aurora_720_rangeley_config_STRINGIFY_NAME(X86_64_NETBERG_AURORA_720_RANGELEY_CONFIG_PORTING_STDLIB), __x86_64_netberg_aurora_720_rangeley_config_STRINGIFY_VALUE(X86_64_NETBERG_AURORA_720_RANGELEY_CONFIG_PORTING_STDLIB) }, -#else -{ X86_64_NETBERG_AURORA_720_RANGELEY_CONFIG_PORTING_STDLIB(__x86_64_netberg_aurora_720_rangeley_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_NETBERG_AURORA_720_RANGELEY_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS - { __x86_64_netberg_aurora_720_rangeley_config_STRINGIFY_NAME(X86_64_NETBERG_AURORA_720_RANGELEY_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS), __x86_64_netberg_aurora_720_rangeley_config_STRINGIFY_VALUE(X86_64_NETBERG_AURORA_720_RANGELEY_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS) }, -#else -{ X86_64_NETBERG_AURORA_720_RANGELEY_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS(__x86_64_netberg_aurora_720_rangeley_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_NETBERG_AURORA_720_RANGELEY_CONFIG_INCLUDE_UCLI - { __x86_64_netberg_aurora_720_rangeley_config_STRINGIFY_NAME(X86_64_NETBERG_AURORA_720_RANGELEY_CONFIG_INCLUDE_UCLI), __x86_64_netberg_aurora_720_rangeley_config_STRINGIFY_VALUE(X86_64_NETBERG_AURORA_720_RANGELEY_CONFIG_INCLUDE_UCLI) }, -#else -{ X86_64_NETBERG_AURORA_720_RANGELEY_CONFIG_INCLUDE_UCLI(__x86_64_netberg_aurora_720_rangeley_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_NETBERG_AURORA_720_RANGELEY_CONFIG_SYSFAN_RPM_FAILURE_THRESHOLD - { __x86_64_netberg_aurora_720_rangeley_config_STRINGIFY_NAME(X86_64_NETBERG_AURORA_720_RANGELEY_CONFIG_SYSFAN_RPM_FAILURE_THRESHOLD), __x86_64_netberg_aurora_720_rangeley_config_STRINGIFY_VALUE(X86_64_NETBERG_AURORA_720_RANGELEY_CONFIG_SYSFAN_RPM_FAILURE_THRESHOLD) }, -#else -{ X86_64_NETBERG_AURORA_720_RANGELEY_CONFIG_SYSFAN_RPM_FAILURE_THRESHOLD(__x86_64_netberg_aurora_720_rangeley_config_STRINGIFY_NAME), "__undefined__" }, -#endif - { NULL, NULL } -}; -#undef __x86_64_netberg_aurora_720_rangeley_config_STRINGIFY_VALUE -#undef __x86_64_netberg_aurora_720_rangeley_config_STRINGIFY_NAME - -const char* -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)) { - return x86_64_netberg_aurora_720_rangeley_config_settings[i].value; - } - } - return NULL; -} - -int -x86_64_netberg_aurora_720_rangeley_config_show(struct aim_pvs_s* pvs) -{ - int i; - for(i = 0; x86_64_netberg_aurora_720_rangeley_config_settings[i].name; i++) { - aim_printf(pvs, "%s = %s\n", x86_64_netberg_aurora_720_rangeley_config_settings[i].name, x86_64_netberg_aurora_720_rangeley_config_settings[i].value); - } - return i; -} - -/* */ diff --git a/packages/platforms/netberg/x86-64/aurora-720-rangeley/onlp/builds/x86_64_netberg_aurora_720_rangeley/module/src/x86_64_netberg_aurora_720_rangeley_enums.c b/packages/platforms/netberg/x86-64/aurora-720-rangeley/onlp/builds/x86_64_netberg_aurora_720_rangeley/module/src/x86_64_netberg_aurora_720_rangeley_enums.c deleted file mode 100755 index 9e1844833..000000000 --- a/packages/platforms/netberg/x86-64/aurora-720-rangeley/onlp/builds/x86_64_netberg_aurora_720_rangeley/module/src/x86_64_netberg_aurora_720_rangeley_enums.c +++ /dev/null @@ -1,10 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#include - -/* <--auto.start.enum(ALL).source> */ -/* */ - diff --git a/packages/platforms/netberg/x86-64/aurora-720-rangeley/onlp/builds/x86_64_netberg_aurora_720_rangeley/module/src/x86_64_netberg_aurora_720_rangeley_int.h b/packages/platforms/netberg/x86-64/aurora-720-rangeley/onlp/builds/x86_64_netberg_aurora_720_rangeley/module/src/x86_64_netberg_aurora_720_rangeley_int.h deleted file mode 100755 index 3a11d1063..000000000 --- a/packages/platforms/netberg/x86-64/aurora-720-rangeley/onlp/builds/x86_64_netberg_aurora_720_rangeley/module/src/x86_64_netberg_aurora_720_rangeley_int.h +++ /dev/null @@ -1,271 +0,0 @@ -/**************************************************************************//** - * - * x86_64_netberg_aurora_720_rangeley Internal Header - * - *****************************************************************************/ -#ifndef __X86_64_NETBERG_AURORA_720_RANGELEY_INT_H__ -#define __X86_64_NETBERG_AURORA_720_RANGELEY_INT_H__ - -#include -#include - -/* */ -/** 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[]; - -/** 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[]; - -/** 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_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_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; - -/** 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 */ -struct psu_info_s { - char path[PATH_MAX]; - int present; - int busno; - int addr; -}; - -#define SYS_HWMON1_PREFIX "/sys/class/hwmon/hwmon1/device" -#define SYS_HWMON2_PREFIX "/sys/class/hwmon/hwmon2/device" - -#endif /* __X86_64_NETBERG_AURORA_720_RANGELEY_INT_H__ */ diff --git a/packages/platforms/netberg/x86-64/aurora-720-rangeley/onlp/builds/x86_64_netberg_aurora_720_rangeley/module/src/x86_64_netberg_aurora_720_rangeley_log.c b/packages/platforms/netberg/x86-64/aurora-720-rangeley/onlp/builds/x86_64_netberg_aurora_720_rangeley/module/src/x86_64_netberg_aurora_720_rangeley_log.c deleted file mode 100755 index c285fc271..000000000 --- a/packages/platforms/netberg/x86-64/aurora-720-rangeley/onlp/builds/x86_64_netberg_aurora_720_rangeley/module/src/x86_64_netberg_aurora_720_rangeley_log.c +++ /dev/null @@ -1,18 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#include - -#include "x86_64_netberg_aurora_720_rangeley_log.h" -/* - * x86_64_netberg_aurora_720_rangeley log struct. - */ -AIM_LOG_STRUCT_DEFINE( - X86_64_NETBERG_AURORA_720_RANGELEY_CONFIG_LOG_OPTIONS_DEFAULT, - X86_64_NETBERG_AURORA_720_RANGELEY_CONFIG_LOG_BITS_DEFAULT, - NULL, /* Custom log map */ - X86_64_NETBERG_AURORA_720_RANGELEY_CONFIG_LOG_CUSTOM_BITS_DEFAULT - ); - diff --git a/packages/platforms/netberg/x86-64/aurora-720-rangeley/onlp/builds/x86_64_netberg_aurora_720_rangeley/module/src/x86_64_netberg_aurora_720_rangeley_log.h b/packages/platforms/netberg/x86-64/aurora-720-rangeley/onlp/builds/x86_64_netberg_aurora_720_rangeley/module/src/x86_64_netberg_aurora_720_rangeley_log.h deleted file mode 100755 index 659381e81..000000000 --- a/packages/platforms/netberg/x86-64/aurora-720-rangeley/onlp/builds/x86_64_netberg_aurora_720_rangeley/module/src/x86_64_netberg_aurora_720_rangeley_log.h +++ /dev/null @@ -1,12 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#ifndef __X86_64_NETBERG_AURORA_720_RANGELEY_LOG_H__ -#define __X86_64_NETBERG_AURORA_720_RANGELEY_LOG_H__ - -#define AIM_LOG_MODULE_NAME x86_64_netberg_aurora_720_rangeley -#include - -#endif /* __X86_64_NETBERG_AURORA_720_RANGELEY_LOG_H__ */ diff --git a/packages/platforms/netberg/x86-64/aurora-720-rangeley/onlp/builds/x86_64_netberg_aurora_720_rangeley/module/src/x86_64_netberg_aurora_720_rangeley_module.c b/packages/platforms/netberg/x86-64/aurora-720-rangeley/onlp/builds/x86_64_netberg_aurora_720_rangeley/module/src/x86_64_netberg_aurora_720_rangeley_module.c deleted file mode 100755 index a3eeab035..000000000 --- a/packages/platforms/netberg/x86-64/aurora-720-rangeley/onlp/builds/x86_64_netberg_aurora_720_rangeley/module/src/x86_64_netberg_aurora_720_rangeley_module.c +++ /dev/null @@ -1,24 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#include - -#include "x86_64_netberg_aurora_720_rangeley_log.h" - -static int -datatypes_init__(void) -{ -#define X86_64_NETBERG_AURORA_720_RANGELEY_ENUMERATION_ENTRY(_enum_name, _desc) AIM_DATATYPE_MAP_REGISTER(_enum_name, _enum_name##_map, _desc, AIM_LOG_INTERNAL); -#include - return 0; -} - -void __x86_64_netberg_aurora_720_rangeley_module_init__(void) -{ - AIM_LOG_STRUCT_REGISTER(); - datatypes_init__(); -} - -int __onlp_platform_version__ = 1; diff --git a/packages/platforms/netberg/x86-64/aurora-720-rangeley/onlp/builds/x86_64_netberg_aurora_720_rangeley/module/src/x86_64_netberg_aurora_720_rangeley_ucli.c b/packages/platforms/netberg/x86-64/aurora-720-rangeley/onlp/builds/x86_64_netberg_aurora_720_rangeley/module/src/x86_64_netberg_aurora_720_rangeley_ucli.c deleted file mode 100755 index 8b972f2d7..000000000 --- a/packages/platforms/netberg/x86-64/aurora-720-rangeley/onlp/builds/x86_64_netberg_aurora_720_rangeley/module/src/x86_64_netberg_aurora_720_rangeley_ucli.c +++ /dev/null @@ -1,50 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#include - -#if X86_64_NETBERG_AURORA_720_RANGELEY_CONFIG_INCLUDE_UCLI == 1 - -#include -#include -#include - -static ucli_status_t -x86_64_netberg_aurora_720_rangeley_ucli_ucli__config__(ucli_context_t* uc) -{ - UCLI_HANDLER_MACRO_MODULE_CONFIG(x86_64_netberg_aurora_720_rangeley) -} - -/* */ -/* */ - -static ucli_module_t -x86_64_netberg_aurora_720_rangeley_ucli_module__ = - { - "x86_64_netberg_aurora_720_rangeley_ucli", - NULL, - x86_64_netberg_aurora_720_rangeley_ucli_ucli_handlers__, - NULL, - NULL, - }; - -ucli_node_t* -x86_64_netberg_aurora_720_rangeley_ucli_node_create(void) -{ - ucli_node_t* n; - ucli_module_init(&x86_64_netberg_aurora_720_rangeley_ucli_module__); - n = ucli_node_create("x86_64_netberg_aurora_720_rangeley", NULL, &x86_64_netberg_aurora_720_rangeley_ucli_module__); - ucli_node_subnode_add(n, ucli_module_log_node_create("x86_64_netberg_aurora_720_rangeley")); - return n; -} - -#else -void* -x86_64_netberg_aurora_720_rangeley_ucli_node_create(void) -{ - return NULL; -} -#endif - diff --git a/packages/platforms/netberg/x86-64/aurora-720-rangeley/platform-config/Makefile b/packages/platforms/netberg/x86-64/aurora-720-rangeley/platform-config/Makefile deleted file mode 100755 index 003238cf6..000000000 --- a/packages/platforms/netberg/x86-64/aurora-720-rangeley/platform-config/Makefile +++ /dev/null @@ -1 +0,0 @@ -include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/netberg/x86-64/aurora-720-rangeley/platform-config/r0/Makefile b/packages/platforms/netberg/x86-64/aurora-720-rangeley/platform-config/r0/Makefile deleted file mode 100755 index 003238cf6..000000000 --- a/packages/platforms/netberg/x86-64/aurora-720-rangeley/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/netberg/x86-64/aurora-720-rangeley/platform-config/r0/PKG.yml b/packages/platforms/netberg/x86-64/aurora-720-rangeley/platform-config/r0/PKG.yml deleted file mode 100755 index 615dd7c40..000000000 --- a/packages/platforms/netberg/x86-64/aurora-720-rangeley/platform-config/r0/PKG.yml +++ /dev/null @@ -1 +0,0 @@ -!include $ONL_TEMPLATES/platform-config-platform.yml ARCH=amd64 VENDOR=netberg BASENAME=x86-64-netberg-aurora-720-rangeley REVISION=r0 diff --git a/packages/platforms/netberg/x86-64/aurora-720-rangeley/platform-config/r0/src/lib/x86-64-netberg-aurora-720-rangeley-r0.yml b/packages/platforms/netberg/x86-64/aurora-720-rangeley/platform-config/r0/src/lib/x86-64-netberg-aurora-720-rangeley-r0.yml deleted file mode 100755 index b38d5fff0..000000000 --- a/packages/platforms/netberg/x86-64/aurora-720-rangeley/platform-config/r0/src/lib/x86-64-netberg-aurora-720-rangeley-r0.yml +++ /dev/null @@ -1,30 +0,0 @@ ---- - -###################################################################### -# -# platform-config for AURORA 720 -# -###################################################################### - -x86-64-netberg-aurora-720-rangeley-r0: - - grub: - - serial: >- - --port=0x2f8 - --speed=115200 - --word=8 - --parity=no - --stop=1 - - kernel: - <<: *kernel-3-16 - - args: >- - console=ttyS1,115200n8 - - ##network: - ## interfaces: - ## ma1: - ## name: ~ - ## syspath: pci0000:00/0000:00:14.0 diff --git a/packages/platforms/netberg/x86-64/aurora-720-rangeley/platform-config/r0/src/python/x86_64_netberg_aurora_720_rangeley_r0/__init__.py b/packages/platforms/netberg/x86-64/aurora-720-rangeley/platform-config/r0/src/python/x86_64_netberg_aurora_720_rangeley_r0/__init__.py deleted file mode 100755 index fb70fe408..000000000 --- a/packages/platforms/netberg/x86-64/aurora-720-rangeley/platform-config/r0/src/python/x86_64_netberg_aurora_720_rangeley_r0/__init__.py +++ /dev/null @@ -1,12 +0,0 @@ -from onl.platform.base import * -from onl.platform.netberg import * - -class OnlPlatform_x86_64_netberg_aurora_720_rangeley_r0(OnlPlatformNetberg, - OnlPlatformPortConfig_32x100): - PLATFORM='x86-64-netberg-aurora-720-rangeley-r0' - MODEL="AURORA720" - SYS_OBJECT_ID=".720.1" - - def baseconfig(self): - self.insmod("hardware_monitor") - return True diff --git a/packages/platforms/netberg/x86-64/modules/Makefile b/packages/platforms/netberg/x86-64/modules/Makefile deleted file mode 100755 index 003238cf6..000000000 --- a/packages/platforms/netberg/x86-64/modules/Makefile +++ /dev/null @@ -1 +0,0 @@ -include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/netberg/x86-64/modules/PKG.yml b/packages/platforms/netberg/x86-64/modules/PKG.yml deleted file mode 100755 index 56db964bb..000000000 --- a/packages/platforms/netberg/x86-64/modules/PKG.yml +++ /dev/null @@ -1 +0,0 @@ -!include $ONL_TEMPLATES/arch-vendor-modules.yml ARCH=amd64 VENDOR=netberg KERNELS="onl-kernel-3.16-lts-x86-64-all:amd64" diff --git a/packages/platforms/netberg/x86-64/modules/builds/.gitignore b/packages/platforms/netberg/x86-64/modules/builds/.gitignore deleted file mode 100755 index a65b41774..000000000 --- a/packages/platforms/netberg/x86-64/modules/builds/.gitignore +++ /dev/null @@ -1 +0,0 @@ -lib diff --git a/packages/platforms/netberg/x86-64/modules/builds/Makefile b/packages/platforms/netberg/x86-64/modules/builds/Makefile deleted file mode 100755 index 3b0a1bd20..000000000 --- a/packages/platforms/netberg/x86-64/modules/builds/Makefile +++ /dev/null @@ -1,6 +0,0 @@ -KERNELS := onl-kernel-3.16-lts-x86-64-all:amd64 -KMODULES := $(wildcard *.c) -VENDOR := netberg -BASENAME := common -ARCH := x86_64 -include $(ONL)/make/kmodule.mk diff --git a/packages/platforms/netberg/x86-64/modules/builds/eeprom_mb.c b/packages/platforms/netberg/x86-64/modules/builds/eeprom_mb.c deleted file mode 100755 index 84628b83a..000000000 --- a/packages/platforms/netberg/x86-64/modules/builds/eeprom_mb.c +++ /dev/null @@ -1,267 +0,0 @@ -/* - * Copyright (C) 1998, 1999 Frodo Looijaard and - * Philip Edelbrock - * Copyright (C) 2003 Greg Kroah-Hartman - * Copyright (C) 2003 IBM Corp. - * Copyright (C) 2004 Jean Delvare - * - * 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. - */ - -/* enable dev_dbg print out */ -//#define DEBUG - -#include -#include -#include -#include -#include -#include -#include - -/* Addresses to scan */ -static const unsigned short normal_i2c[] = { /*0x50, 0x51, 0x52, 0x53, 0x54, - 0x55, 0x56, 0x57,*/ I2C_CLIENT_END }; - -/* Size of EEPROM in bytes */ -#define EEPROM_SIZE 512 - -#define SLICE_BITS (6) -#define SLICE_SIZE (1 << SLICE_BITS) -#define SLICE_NUM (EEPROM_SIZE/SLICE_SIZE) - -/* Each client has this additional data */ -struct eeprom_data { - struct mutex update_lock; - u8 valid; /* bitfield, bit!=0 if slice is valid */ - unsigned long last_updated[SLICE_NUM]; /* In jiffies, 8 slices */ - u8 data[EEPROM_SIZE]; /* Register values */ -}; - - -static void mb_eeprom_update_client(struct i2c_client *client, u8 slice) -{ - struct eeprom_data *data = i2c_get_clientdata(client); - int i, j; - int ret; - int addr; - - mutex_lock(&data->update_lock); - - if (!(data->valid & (1 << slice)) || - time_after(jiffies, data->last_updated[slice] + 300 * HZ)) { - dev_dbg(&client->dev, "Starting eeprom update, slice %u\n", slice); - - addr = slice << SLICE_BITS; - - ret = i2c_smbus_write_byte_data(client, (u8)((addr >> 8) & 0xFF), (u8)(addr & 0xFF)); - /* select the eeprom address */ - if (ret < 0) { - dev_err(&client->dev, "address set failed\n"); - goto exit; - } - - if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_READ_BYTE)) { - goto exit; - } - - for (i = slice << SLICE_BITS; i < (slice + 1) << SLICE_BITS; i+= SLICE_SIZE) { - for (j = i; j < (i+SLICE_SIZE); j++) { - int res; - - res = i2c_smbus_read_byte(client); - if (res < 0) { - goto exit; - } - - data->data[j] = res & 0xFF; - } - } - - data->last_updated[slice] = jiffies; - data->valid |= (1 << slice); - } -exit: - mutex_unlock(&data->update_lock); -} - -static ssize_t mb_eeprom_read(struct file *filp, struct kobject *kobj, - struct bin_attribute *bin_attr, - char *buf, loff_t off, size_t count) -{ - struct i2c_client *client = to_i2c_client(container_of(kobj, struct device, kobj)); - struct eeprom_data *data = i2c_get_clientdata(client); - u8 slice; - - if (off > EEPROM_SIZE) { - return 0; - } - if (off + count > EEPROM_SIZE) { - count = EEPROM_SIZE - off; - } - if (count == 0) { - return 0; - } - - /* Only refresh slices which contain requested bytes */ - for (slice = off >> SLICE_BITS; slice <= (off + count - 1) >> SLICE_BITS; slice++) { - mb_eeprom_update_client(client, slice); - } - - memcpy(buf, &data->data[off], count); - - return count; -} - -static ssize_t mb_eeprom_write(struct file *filp, struct kobject *kobj, - struct bin_attribute *bin_attr, - char *buf, loff_t off, size_t count) -{ - struct i2c_client *client = to_i2c_client(container_of(kobj, struct device, kobj)); - struct eeprom_data *data = i2c_get_clientdata(client); - int ret; - int i; - u8 cmd; - u16 value16; - - dev_dbg(&client->dev, "mb_eeprom_write off=%d, count=%d\n", (int)off, (int)count); - - if (off > EEPROM_SIZE) { - return 0; - } - if (off + count > EEPROM_SIZE) { - count = EEPROM_SIZE - off; - } - if (count == 0) { - return 0; - } - - mutex_lock(&data->update_lock); - - for(i=0; i < count; i++) { - /* write command */ - cmd = (off >> 8) & 0xff; - value16 = off & 0xff; - value16 |= buf[i] << 8; - ret = i2c_smbus_write_word_data(client, cmd, value16); - - if (ret < 0) { - dev_err(&client->dev, "write address failed at %d \n", (int)off); - goto exit; - } - - off++; - - /* need to wait for write complete */ - udelay(10000); - } -exit: - mutex_unlock(&data->update_lock); - /* force to update client when reading */ - for(i=0; i < SLICE_NUM; i++) { - data->last_updated[i] = 0; - } - - return count; -} - -static struct bin_attribute mb_eeprom_attr = { - .attr = { - .name = "eeprom", - .mode = S_IRUGO | S_IWUSR, - }, - .size = EEPROM_SIZE, - .read = mb_eeprom_read, - .write = mb_eeprom_write, -}; - -/* Return 0 if detection is successful, -ENODEV otherwise */ -static int mb_eeprom_detect(struct i2c_client *client, struct i2c_board_info *info) -{ - struct i2c_adapter *adapter = client->adapter; - - /* EDID EEPROMs are often 24C00 EEPROMs, which answer to all - addresses 0x50-0x57, but we only care about 0x51 and 0x55. So decline - attaching to addresses >= 0x56 on DDC buses */ - if (!(adapter->class & I2C_CLASS_SPD) && client->addr >= 0x56) { - return -ENODEV; - } - - if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_READ_BYTE) - && !i2c_check_functionality(adapter, I2C_FUNC_SMBUS_WRITE_BYTE_DATA)) { - return -ENODEV; - } - - strlcpy(info->type, "eeprom", I2C_NAME_SIZE); - - return 0; -} - -static int mb_eeprom_probe(struct i2c_client *client, - const struct i2c_device_id *id) -{ - struct eeprom_data *data; - int err; - - if (!(data = kzalloc(sizeof(struct eeprom_data), GFP_KERNEL))) { - err = -ENOMEM; - goto exit; - } - - memset(data->data, 0xff, EEPROM_SIZE); - i2c_set_clientdata(client, data); - mutex_init(&data->update_lock); - - /* create the sysfs eeprom file */ - err = sysfs_create_bin_file(&client->dev.kobj, &mb_eeprom_attr); - if (err) { - goto exit_kfree; - } - - return 0; - -exit_kfree: - kfree(data); -exit: - return err; -} - -static int mb_eeprom_remove(struct i2c_client *client) -{ - sysfs_remove_bin_file(&client->dev.kobj, &mb_eeprom_attr); - kfree(i2c_get_clientdata(client)); - - return 0; -} - -static const struct i2c_device_id mb_eeprom_id[] = { - { "mb_eeprom", 0 }, - { } -}; - -static struct i2c_driver mb_eeprom_driver = { - .driver = { - .name = "mb_eeprom", - }, - .probe = mb_eeprom_probe, - .remove = mb_eeprom_remove, - .id_table = mb_eeprom_id, - - .class = I2C_CLASS_DDC | I2C_CLASS_SPD, - .detect = mb_eeprom_detect, - .address_list = normal_i2c, -}; - -module_i2c_driver(mb_eeprom_driver); - -MODULE_AUTHOR("Netberg "); -MODULE_DESCRIPTION("Aurora 710 EEPROM driver"); -MODULE_LICENSE("GPL"); diff --git a/packages/platforms/netberg/x86-64/modules/builds/hardware_monitor.c b/packages/platforms/netberg/x86-64/modules/builds/hardware_monitor.c deleted file mode 100755 index 2f2f09eb6..000000000 --- a/packages/platforms/netberg/x86-64/modules/builds/hardware_monitor.c +++ /dev/null @@ -1,8760 +0,0 @@ - -#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#if 0 -#include "hardware_monitor.h" -#else -enum platform_type { - HURACAN = 0, - NONE -}; - -#define W83795ADG_VENDOR_ID 0x5CA3 -#define W83795ADG_CHIP_ID 0x79 - -#define W83795ADG_NUM2 2 -#define W83795ADG_NUM8 8 - -#define W83795ADG_TEMP_COUNT 4 -#define W83795ADG_FAN_COUNT 10 -#define W83795ADG_FAN_SPEED_FACTOR 1350000 /* 1.35 * 10^6 */ -#define W83795ADG_FAN_POLES_NUMBER 4 -#define W83795ADG_VSEN_COUNT 7 - -#define TEMP_DECIMAL_BASE 25 /* 0.25 degree C */ -#define VOL_MONITOR_UNIT 1000 /* 1000mV */ - -/* W83795ADG registeris */ -#define W83795ADG_REG_BANK 0x00 /* Bank Select */ - -#define W83795ADG_REG_VENDOR_ID 0xFD /* Vender ID */ -#define W83795ADG_REG_CHIP_ID 0xFE /* Chip ID */ -#define W83795ADG_REG_DEVICE_ID 0xFB /* Device ID */ - -/* Bank 0*/ -#define W83795ADG_REG_CONFIG 0x01 /* Configuration Register */ -#define W83795ADG_REG_TEMP_CTRL2 0x05 /* Temperature Monitoring Control Register */ -#define W83795ADG_REG_FANIN_CTRL2 0x07 /* FANIN CTRL2. FANIN Monitoring Control Register */ -#define W83795ADG_REG_VSEN1 0x10 /* VSEN1 voltage readout high byte */ -#define W83795ADG_REG_VSEN2 0x11 /* VSEN2 voltage readout high byte */ -#define W83795ADG_REG_VSEN3 0x12 /* VSEN3 voltage readout high byte */ -#define W83795ADG_REG_VSEN4 0x13 /* VSEN4 voltage readout high byte */ -#define W83795ADG_REG_TR1 0x21 /* TR1 temperature Readout high byte */ -#define W83795ADG_REG_TR2 0x22 /* TR2 temperature Readout high byte */ - -#define W83795ADG_REG_FANIN1_COUNT 0x2E /* FAN1IN tachometer readout high byte */ -#define W83795ADG_REG_FANIN2_COUNT 0x2F /* FAN2IN tachometer readout high byte */ -#define W83795ADG_REG_FANIN3_COUNT 0x30 /* FAN3IN tachometer readout high byte */ -#define W83795ADG_REG_FANIN4_COUNT 0x31 /* FAN4IN tachometer readout high byte */ -#define W83795ADG_REG_FANIN5_COUNT 0x32 /* FAN5IN tachometer readout high byte */ -#define W83795ADG_REG_FANIN6_COUNT 0x33 /* FAN6IN tachometer readout high byte */ -#define W83795ADG_REG_FANIN7_COUNT 0x34 /* FAN7IN tachometer readout high byte */ -#define W83795ADG_REG_FANIN8_COUNT 0x35 /* FAN8IN tachometer readout high byte */ -#define W83795ADG_REG_FANIN9_COUNT 0x36 /* FAN9IN tachometer readout high byte */ -#define W83795ADG_REG_FANIN10_COUNT 0x37 /* FAN10IN tachometer readout high byte */ - -#define W83795ADG_REG_VR_LSB 0x3C /* Monitored channel readout low byte */ - -/* Bank 2 */ -#define W83795ADG_REG_FOMC 0x0F /* Fan Output Mode Control */ -#define W83795ADG_REG_F1OV 0x10 /* Fan Output Value for FANCTL1 */ -#define W83795ADG_REG_F2OV 0x11 /* Fan Output Value for FANCTL2 */ - -/* CPLD register */ -#define CPLD_REG_GENERAL_0x00 0x00 /* Board Type and Revision Register */ -#define CPLD_REG_GENERAL_0x01 0x01 /* CPLD Revision Register */ -#define CPLD_REG_GENERAL_0x02 0x02 /* Power Bank Power Good Status Register */ -#define CPLD_REG_GENERAL_0x03 0x03 /* Power Bank Power ABS Status Register */ -#define CPLD_REG_GENERAL_0x06 0x06 /* Watchdog Control Register */ - -#define CPLD_REG_RESET_0x30 0x30 /* System Reset Register */ -#define CPLD_REG_RESET_0x33 0x33 /* I2C Reset Register */ -#define CPLD_REG_RESET_0x34 0x34 /* QSFP28 LED Clear Register */ -#define CPLD_REG_RESET_0x35 0x35 /* MISC Reset Register */ - -#define CPLD_REG_LED_0x40 0x40 /* System LED Register */ -#define CPLD_REG_LED_0x43 0x43 /* PSU LED Register */ -#define CPLD_REG_LED_0x44 0x44 /* FAN LED Register */ - -#define CPLD_REG_LED 0x44 /* FAN LED */ - -#define CPLD_REG_MUX 0x4A /* I2C MUX control Register */ - -/* 9548 Channel Index */ -#define PCA9548_CH00 0 -#define PCA9548_CH01 1 -#define PCA9548_CH02 2 -#define PCA9548_CH03 3 -#define PCA9548_CH04 4 -#define PCA9548_CH05 5 -#define PCA9548_CH06 6 -#define PCA9548_CH07 7 - -/* PCA9553 */ -#define PCA9553_SET_BIT(numberX, posX) ( numberX |= ( 0x1 << posX) ) -#define PCA9553_CLEAR_BIT(numberX, posX) ( numberX &= (~(0x1 << posX)) ) -#define PCA9553_TEST_BIT(numberX, posX) ( numberX & ( 0x1 << posX) ) - -/**************************************************************************************** - * Correlation between pca9553 I2C Read/Write bit Data and pca9553 port index assignment - * - * - * I2C First Data Byte I2C Second Data Byte - * --------------------------------------- -------------------------------------- - * | 07 | 06 | 05 | 04 | 03 | 02 | 01 | 00 | |07 | 06 | 05 | 04 | 03 | 02 | 01 | 00 | - * --------------------------------------- ---------------------------------------- - * P07 P06 P05 P04 P03 P02 P01 P00 P17 P16 P15 P14 P13 P12 P11 P10 - * - * P[X][Y] stands for Port X (0 or 1), Bit Y (0-7) - * - * - * NOTE: We combine first data byte and second data byte into a 16-bit integer, which - * is used for I2C transfer. The following macro each defines the port's respective - * bit position within the 16-bit integer. - *****************************************************************************************/ - -#define PCA9553_BIT_P00 0 -#define PCA9553_BIT_P01 1 -#define PCA9553_BIT_P02 2 -#define PCA9553_BIT_P03 3 -#define PCA9553_BIT_P04 4 -#define PCA9553_BIT_P05 5 -#define PCA9553_BIT_P06 6 -#define PCA9553_BIT_P07 7 - -#define PCA9553_BIT_P10 0 -#define PCA9553_BIT_P11 1 -#define PCA9553_BIT_P12 2 -#define PCA9553_BIT_P13 3 -#define PCA9553_BIT_P14 4 -#define PCA9553_BIT_P15 5 -#define PCA9553_BIT_P16 6 -#define PCA9553_BIT_P17 7 - - -/****************************************************************************************** - * PCA9553 I2C bus transactions - * - * - WRITE transaction, consisting of the following data sequence: - * - * Address byte (bit0:0) + Command byte + Data Byte 0 + ... - * - * - * - * - READ transaction, consissting of the following data sequence: - * - * Address byte (bit0:0) + Command byte + Address byte (bit0:1) + Data Byte 0 + ... - * or - * Address byte (bit0:1) + Data Byte 0 + ... - * - * - * EXPLANATION - * Address byte: 7-bit I2C slave address + 1-bit (Read|Write) - * - * Command byte: A pointer allowing the master device to select which PCA9535 - * register to interact with. - * - ******************************************************************************************/ - -/* Register-pointing command byte */ -#define PCA9553_COMMAND_BYTE_REG_INPUT_PORT_0 0x00 -#define PCA9553_COMMAND_BYTE_REG_INPUT_PORT_1 0x01 -#define PCA9553_COMMAND_BYTE_REG_OUTPUT_PORT_0 0x02 -#define PCA9553_COMMAND_BYTE_REG_OUTPUT_PORT_1 0x03 -#define PCA9553_COMMAND_BYTE_REG_POLARITY_INVERSION_0 0x04 -#define PCA9553_COMMAND_BYTE_REG_POLARITY_INVERSION_1 0x05 -#define PCA9553_COMMAND_BYTE_REG_CONFIGURATION_0 0x06 -#define PCA9553_COMMAND_BYTE_REG_CONFIGURATION_1 0x07 - -/* Model ID Definition */ -typedef enum -{ - HURACAN_WITH_BMC = 0x0, - HURACAN_WITHOUT_BMC, - CABRERAIII_WITH_BMC, - CABRERAIII_WITHOUT_BMC, - SESTO_WITH_BMC, - SESTO_WITHOUT_BMC, - NCIIX_WITH_BMC, - NCIIX_WITHOUT_BMC, - ASTERION_WITH_BMC, - ASTERION_WITHOUT_BMC, - HURACAN_A_WITH_BMC, - HURACAN_A_WITHOUT_BMC, - - MODEL_ID_LAST -} modelId_t; - -/* QSFP */ -#define QSFP_COUNT 64 -#define QSFP_DATA_SIZE 256 -#define SFP_COPPER_DATA_SIZE 512 - -#define EEPROM_DATA_SIZE 256 - -typedef struct -{ - unsigned char tempLow2HighThreshold[3]; - unsigned char tempHigh2LowThreshold[3]; - unsigned char fanDutySet[3]; - unsigned int fanSpeed[3]; - unsigned int inSet[W83795ADG_VSEN_COUNT][3]; -} ControlTable_t; - -static int w83795adg_hardware_monitor_probe(struct i2c_client *client, const struct i2c_device_id *id); -static int w83795adg_hardware_monitor_detect(struct i2c_client *client, struct i2c_board_info *info); -static int w83795adg_hardware_monitor_remove(struct i2c_client *client); -static void w83795adg_hardware_monitor_shutdown(struct i2c_client *client); - -typedef struct -{ - unsigned char portMaskBitForPCA9548_1; - unsigned char portMaskBitForPCA9548_2TO5; - unsigned char portMaskIOsForPCA9548_0; - unsigned char i2cAddrForPCA9535; - short portMaskBitForTxEnPin; -} SFP_PORT_DATA_t; - -#define SFP_PORT_DATA_PORT_NCIIX_1 {0x04, 0x01, 0x08, 0, 3} -#define SFP_PORT_DATA_PORT_NCIIX_2 {0x04, 0x02, 0x08, 0, 9} -#define SFP_PORT_DATA_PORT_NCIIX_3 {0x04, 0x04, 0x08, 1, 3} -#define SFP_PORT_DATA_PORT_NCIIX_4 {0x04, 0x08, 0x08, 1, 9} -#define SFP_PORT_DATA_PORT_NCIIX_5 {0x04, 0x10, 0x08, 2, 3} -#define SFP_PORT_DATA_PORT_NCIIX_6 {0x04, 0x20, 0x08, 2, 9} -#define SFP_PORT_DATA_PORT_NCIIX_7 {0x04, 0x40, 0x08, 3, 3} -#define SFP_PORT_DATA_PORT_NCIIX_8 {0x04, 0x80, 0x08, 3, 9} - -#define SFP_PORT_DATA_PORT_NCIIX_9 {0x08, 0x01, 0x10, 0, 3} -#define SFP_PORT_DATA_PORT_NCIIX_10 {0x08, 0x02, 0x10, 0, 9} -#define SFP_PORT_DATA_PORT_NCIIX_11 {0x08, 0x04, 0x10, 1, 3} -#define SFP_PORT_DATA_PORT_NCIIX_12 {0x08, 0x08, 0x10, 1, 9} -#define SFP_PORT_DATA_PORT_NCIIX_13 {0x08, 0x10, 0x10, 2, 3} -#define SFP_PORT_DATA_PORT_NCIIX_14 {0x08, 0x20, 0x10, 2, 9} -#define SFP_PORT_DATA_PORT_NCIIX_15 {0x08, 0x40, 0x10, 3, 3} -#define SFP_PORT_DATA_PORT_NCIIX_16 {0x08, 0x80, 0x10, 3, 9} - -#define SFP_PORT_DATA_PORT_NCIIX_17 {0x10, 0x01, 0x20, 0, 3} -#define SFP_PORT_DATA_PORT_NCIIX_18 {0x10, 0x02, 0x20, 0, 9} -#define SFP_PORT_DATA_PORT_NCIIX_19 {0x10, 0x04, 0x20, 1, 3} -#define SFP_PORT_DATA_PORT_NCIIX_20 {0x10, 0x08, 0x20, 1, 9} -#define SFP_PORT_DATA_PORT_NCIIX_21 {0x10, 0x10, 0x20, 2, 3} -#define SFP_PORT_DATA_PORT_NCIIX_22 {0x10, 0x20, 0x20, 2, 9} -#define SFP_PORT_DATA_PORT_NCIIX_23 {0x10, 0x40, 0x20, 3, 3} -#define SFP_PORT_DATA_PORT_NCIIX_24 {0x10, 0x80, 0x20, 3, 9} - -#define SFP_PORT_DATA_PORT_NCIIX_25 {0x20, 0x01, 0x40, 0, 3} -#define SFP_PORT_DATA_PORT_NCIIX_26 {0x20, 0x02, 0x40, 0, 9} -#define SFP_PORT_DATA_PORT_NCIIX_27 {0x20, 0x04, 0x40, 1, 3} -#define SFP_PORT_DATA_PORT_NCIIX_28 {0x20, 0x08, 0x40, 1, 9} -#define SFP_PORT_DATA_PORT_NCIIX_29 {0x20, 0x10, 0x40, 2, 3} -#define SFP_PORT_DATA_PORT_NCIIX_30 {0x20, 0x20, 0x40, 2, 9} -#define SFP_PORT_DATA_PORT_NCIIX_31 {0x20, 0x40, 0x40, 3, 3} -#define SFP_PORT_DATA_PORT_NCIIX_32 {0x20, 0x80, 0x40, 3, 9} - -#define SFP_PORT_DATA_PORT_NCIIX_33 {0x40, 0x01, 0x80, 0, 3} -#define SFP_PORT_DATA_PORT_NCIIX_34 {0x40, 0x02, 0x80, 0, 9} -#define SFP_PORT_DATA_PORT_NCIIX_35 {0x40, 0x04, 0x80, 1, 3} -#define SFP_PORT_DATA_PORT_NCIIX_36 {0x40, 0x08, 0x80, 1, 9} -#define SFP_PORT_DATA_PORT_NCIIX_37 {0x40, 0x10, 0x80, 2, 3} -#define SFP_PORT_DATA_PORT_NCIIX_38 {0x40, 0x20, 0x80, 2, 9} -#define SFP_PORT_DATA_PORT_NCIIX_39 {0x40, 0x40, 0x80, 3, 3} -#define SFP_PORT_DATA_PORT_NCIIX_40 {0x40, 0x80, 0x80, 3, 9} - -#define SFP_PORT_DATA_PORT_NCIIX_41 {0x80, 0x01, 0x01, 0, 3} -#define SFP_PORT_DATA_PORT_NCIIX_42 {0x80, 0x02, 0x01, 0, 9} -#define SFP_PORT_DATA_PORT_NCIIX_43 {0x80, 0x04, 0x01, 1, 3} -#define SFP_PORT_DATA_PORT_NCIIX_44 {0x80, 0x08, 0x01, 1, 9} -#define SFP_PORT_DATA_PORT_NCIIX_45 {0x80, 0x10, 0x01, 2, 3} -#define SFP_PORT_DATA_PORT_NCIIX_46 {0x80, 0x20, 0x01, 2, 9} -#define SFP_PORT_DATA_PORT_NCIIX_47 {0x80, 0x40, 0x01, 3, 3} -#define SFP_PORT_DATA_PORT_NCIIX_48 {0x80, 0x80, 0x01, 3, 9} - -#define QSFP_PORT_DATA_PORT_NCIIX_1 {0x02, 0x02, 0x08, 0, 0x0200} -#define QSFP_PORT_DATA_PORT_NCIIX_2 {0x02, 0x01, 0x08, 0, 0x0010} -#define QSFP_PORT_DATA_PORT_NCIIX_3 {0x02, 0x08, 0x08, 1, 0x0010} -#define QSFP_PORT_DATA_PORT_NCIIX_4 {0x02, 0x04, 0x08, 0, 0x4000} -#define QSFP_PORT_DATA_PORT_NCIIX_5 {0x02, 0x20, 0x08, 1, 0x4000} -#define QSFP_PORT_DATA_PORT_NCIIX_6 {0x02, 0x10, 0x08, 1, 0x0200} - -SFP_PORT_DATA_t sfpPortData_78F[] = { - SFP_PORT_DATA_PORT_NCIIX_1, SFP_PORT_DATA_PORT_NCIIX_2, SFP_PORT_DATA_PORT_NCIIX_3, SFP_PORT_DATA_PORT_NCIIX_4, - SFP_PORT_DATA_PORT_NCIIX_5, SFP_PORT_DATA_PORT_NCIIX_6, SFP_PORT_DATA_PORT_NCIIX_7, SFP_PORT_DATA_PORT_NCIIX_8, - SFP_PORT_DATA_PORT_NCIIX_9, SFP_PORT_DATA_PORT_NCIIX_10, SFP_PORT_DATA_PORT_NCIIX_11, SFP_PORT_DATA_PORT_NCIIX_12, - SFP_PORT_DATA_PORT_NCIIX_13, SFP_PORT_DATA_PORT_NCIIX_14, SFP_PORT_DATA_PORT_NCIIX_15, SFP_PORT_DATA_PORT_NCIIX_16, - SFP_PORT_DATA_PORT_NCIIX_17, SFP_PORT_DATA_PORT_NCIIX_18, SFP_PORT_DATA_PORT_NCIIX_19, SFP_PORT_DATA_PORT_NCIIX_20, - SFP_PORT_DATA_PORT_NCIIX_21, SFP_PORT_DATA_PORT_NCIIX_22, SFP_PORT_DATA_PORT_NCIIX_23, SFP_PORT_DATA_PORT_NCIIX_24, - SFP_PORT_DATA_PORT_NCIIX_25, SFP_PORT_DATA_PORT_NCIIX_26, SFP_PORT_DATA_PORT_NCIIX_27, SFP_PORT_DATA_PORT_NCIIX_28, - SFP_PORT_DATA_PORT_NCIIX_29, SFP_PORT_DATA_PORT_NCIIX_30, SFP_PORT_DATA_PORT_NCIIX_31, SFP_PORT_DATA_PORT_NCIIX_32, - SFP_PORT_DATA_PORT_NCIIX_33, SFP_PORT_DATA_PORT_NCIIX_34, SFP_PORT_DATA_PORT_NCIIX_35, SFP_PORT_DATA_PORT_NCIIX_36, - SFP_PORT_DATA_PORT_NCIIX_37, SFP_PORT_DATA_PORT_NCIIX_38, SFP_PORT_DATA_PORT_NCIIX_39, SFP_PORT_DATA_PORT_NCIIX_40, - SFP_PORT_DATA_PORT_NCIIX_41, SFP_PORT_DATA_PORT_NCIIX_42, SFP_PORT_DATA_PORT_NCIIX_43, SFP_PORT_DATA_PORT_NCIIX_44, - SFP_PORT_DATA_PORT_NCIIX_45, SFP_PORT_DATA_PORT_NCIIX_46, SFP_PORT_DATA_PORT_NCIIX_47, SFP_PORT_DATA_PORT_NCIIX_48, - QSFP_PORT_DATA_PORT_NCIIX_1, QSFP_PORT_DATA_PORT_NCIIX_2, QSFP_PORT_DATA_PORT_NCIIX_3, - QSFP_PORT_DATA_PORT_NCIIX_4, QSFP_PORT_DATA_PORT_NCIIX_5, QSFP_PORT_DATA_PORT_NCIIX_6 -}; - -/* CHL8325A for NC2X Platform */ -#define LOOP1_VID_OVERRIDE_ENABLE_REG 0xD0 -#define LOOP1_OVERRIDE_VID_SETTING_REG 0xD1 - -#define CHL8325_LOOP1_Enable 0x40 - -#define CHL8325_VID0 0x9C -#define CHL8325_VID1 0x8D -#define CHL8325_VID_DEFAULT (CHL8325_VID0) -#endif - -static struct i2c_client qsfpDataA0_client; -static struct i2c_client qsfpDataA2_client; -static struct i2c_client SfpCopperData_client; - -/* i2c bus 0 */ -static struct i2c_client pca9535pwr_client_bus0; -static struct i2c_client cpld_client; -static struct i2c_client pca9548_client_bus0; -static struct i2c_client pca9535_client_bus0[4]; -static struct i2c_client eeprom_client_bus0; -static struct i2c_client mp2953agu_client; -static struct i2c_client chl8325a_client; -static struct i2c_client psu_eeprom_client_bus0; -static struct i2c_client psu_mcu_client_bus0; - -/* i2c bus 1 */ -static struct i2c_client pca9548_client[4]; -static struct i2c_client pca9535pwr_client[6]; - -static struct i2c_client eeprom_client; -static struct i2c_client psu_eeprom_client; -static struct i2c_client psu_mcu_client; - -static unsigned int FanErr[W83795ADG_FAN_COUNT] = {0}; -static unsigned int FanDir = 0; -static unsigned int FanDir2 = 0; -static unsigned int isBMCSupport = 0; - -static unsigned int platformBuildRev = 0xffff; -static unsigned int platformHwRev = 0xffff; -static unsigned int platformModelId = 0xffff; - -static char platformPsuPG = 0; -static char platformPsuABS = 0; - -unsigned int SFPPortAbsStatus[QSFP_COUNT]; -unsigned int SFPPortRxLosStatus[QSFP_COUNT]; -unsigned int SFPPortTxFaultStatus[QSFP_COUNT]; -char SFPPortDataValid[QSFP_COUNT]; -char SFPPortTxDisable[QSFP_COUNT]; - -static struct i2c_client cpld_client_bus1; - -struct i2c_bus0_hardware_monitor_data { - struct device *hwmon_dev; - struct attribute_group hwmon_group; - struct mutex lock; - struct task_struct *auto_update; - struct completion auto_update_stop; - - char hardware_monitor_data_valid; - unsigned long hardware_monitor_last_updated; /* In jiffies */ - - unsigned int venderId; - unsigned int chipId; - unsigned int dviceId; - - unsigned int buildRev; - unsigned int hwRev; - unsigned int modelId; - unsigned int cpldRev; - unsigned int cpldRel; - - unsigned int macTemp; - - unsigned int remoteTempIsPositive[W83795ADG_TEMP_COUNT]; - unsigned int remoteTempInt[W83795ADG_TEMP_COUNT]; - unsigned int remoteTempDecimal[W83795ADG_TEMP_COUNT]; - unsigned int fanDuty; - unsigned int fanSpeed[W83795ADG_FAN_COUNT]; - unsigned int vSen[W83795ADG_VSEN_COUNT]; - unsigned int vSenLsb[W83795ADG_VSEN_COUNT]; - - char psuPG; - char psuABS; - - char wdReg; - unsigned int wdEnable; - unsigned int wdRefreshControl; - unsigned int wdRefreshControlFlag; - unsigned int wdRefreshTimeSelect; - unsigned int wdRefreshTimeSelectFlag; - unsigned int wdTimeoutSelect; - unsigned int wdTimeoutSelectFlag; - - unsigned int rov; - }; - -struct i2c_bus1_hardware_monitor_data { - struct device *hwmon_dev; - struct attribute_group hwmon_group; - struct mutex lock; - struct task_struct *auto_update; - struct completion auto_update_stop; - - char hardware_monitor_data_valid; - unsigned long hardware_monitor_last_updated; /* In jiffies */ - - unsigned short qsfpPortAbsStatus[4]; - char qsfpPortDataA0[QSFP_COUNT][QSFP_DATA_SIZE]; - char qsfpPortDataA2[QSFP_COUNT][QSFP_DATA_SIZE]; - char SfpCopperPortData[QSFP_COUNT][SFP_COPPER_DATA_SIZE]; - unsigned short qsfpPortDataValid[4]; - unsigned short sfpPortTxDisable[3]; - unsigned short sfpPortRateSelect[3]; - unsigned short sfpPortRxLosStatus[4]; - unsigned short sfpPortTxFaultStatus[4]; - - unsigned short fanAbs[2]; - unsigned short fanDir[2]; - - unsigned short systemLedStatus; - unsigned short frontLedStatus; - unsigned char sfpPortDataValidAst[64]; - unsigned char sfpPortAbsRxLosStatus[24]; - unsigned char qsfpPortAbsStatusAst[16]; - unsigned char sfpPortRateSelectAst[12]; - unsigned char sfpPortTxDisableAst[6]; - - char qsfpPortTxDisableData[QSFP_COUNT]; - char qsfpPortTxDisableDataUpdate[QSFP_COUNT]; - struct i2c_client *sfpPortClient[QSFP_COUNT]; -}; - -/* Addresses to scan */ -static unsigned short w83795adg_normal_i2c[] = { 0x2F, 0x70, I2C_CLIENT_END }; - -static const struct i2c_device_id w83795adg_hardware_monitor_id[] = { - { "HURACAN", HURACAN }, - { } -}; - -MODULE_DEVICE_TABLE(i2c, w83795adg_hardware_monitor_id); - -static struct i2c_driver w83795adg_hardware_monitor_driver = { - .class = I2C_CLASS_HWMON, - .driver = { - .name = "w83795adg_hardware_monitor", - }, - .probe = w83795adg_hardware_monitor_probe, - .remove = w83795adg_hardware_monitor_remove, - .shutdown = w83795adg_hardware_monitor_shutdown, - .id_table = w83795adg_hardware_monitor_id, - .detect = w83795adg_hardware_monitor_detect, - .address_list = w83795adg_normal_i2c, -}; - -/* Front to Back */ -static ControlTable_t ControlTable[] = -{ - /* Huracan */ - { - {77, 95, 105}, /* temperature threshold (going to up) */ - {72, 77, 95}, /* temperature threshold (going to down) */ - {0x6C, 0x9E, 0xFF}, /* fan duty */ - {8000, 12000, 16000}, /* fan rpm */ - {{0}}, /* (fixme) HW_monitoring_ONL.pdf */ - }, - /* Sesto */ - { - {85, 95, 100}, /* temperature threshold (going to up) */ - {71, 85, 95}, /* temperature threshold (going to down) */ - {0x73, 0xCC, 0xFF}, /* fan duty */ - {9000, 14000, 16000}, /* fan rpm */ - {{0}}, /* (fixme) HW_monitoring_ONL.pdf */ - }, - /* NC2X */ - { - {62, 70, 85}, /* temperature threshold (going to up) */ - {58, 66, 70}, /* temperature threshold (going to down) */ - {0x70, 0xB7, 0xFF}, /* fan duty */ - {8000, 13000, 16000}, /* fan rpm */ - { - {970, 1250,1275}, /* vsen1 */ - {0}, /* vsen2 */ - {0}, /* vsen3 */ - {970, 1000,1030}, /* vsen4 */ - {1710,1800,1890}, /* vsen5 */ - {0}, /* rsvd */ - {1187,1250,1312}, /* vsen7 */ - }, - }, - /* Asterion */ - { - {70, 75, 80}, /* temperature threshold (going to up) */ - {60, 65, 70}, /* temperature threshold (going to down) */ - {0x8B, 0xD1, 0xFF}, /* fan duty */ - {12000, 18000, 22000},/* fan rpm */ - {{0}}, /* (fixme) HW_monitoring_ONL.pdf */ - } -}; - -/* Back to Front */ -static ControlTable_t ControlTable_B2F[] = -{ - /* Huracan */ - { - {70, 77, 105}, /* temperature threshold (going to up) */ - {60, 70, 77}, /* temperature threshold (going to down) */ - {0x6C, 0xC7, 0xFF}, /* fan duty */ - {8000, 14000, 16000}, /* fan rpm */ - {{0}}, /* (fixme) HW_monitoring_ONL.pdf */ - }, - /* Sesto */ - { - {71, 81, 105}, /* temperature threshold (going to up) */ - {64, 81, 88}, /* temperature threshold (going to down) */ - {0x73, 0xCC, 0xFF}, /* fan duty */ - {9000, 14000, 16000}, /* fan rpm */ - {{0}}, /* (fixme) HW_monitoring_ONL.pdf */ - }, - /* NC2X */ - { - {58, 63, 80}, /* temperature threshold (going to up) */ - {54, 60, 63}, /* temperature threshold (going to down) */ - {0x6F, 0xB7, 0xFF}, /* fan duty */ - {8000, 13000, 16000}, /* fan rpm */ - { - {970, 1250,1275}, /* vsen1 */ - {0}, /* vsen2 */ - {0}, /* vsen3 */ - {970, 1000,1030}, /* vsen4 */ - {1710,1800,1890}, /* vsen5 */ - {0}, /* rsvd */ - {1187,1250,1312}, /* vsen7 */ - }, - }, - /* Asterion */ - { - {70, 75, 80}, /* temperature threshold (going to up) */ - {60, 65, 70}, /* temperature threshold (going to down) */ - {0x8B, 0xD1, 0xFF}, /* fan duty */ - {12000, 18000, 22000},/* fan rpm */ - {{0}}, /* (fixme) HW_monitoring_ONL.pdf */ - } -}; - -static const ControlTable_t *get_platform_control_table(void) -{ - const ControlTable_t *cTable; - - switch(platformModelId) - { - default: - case HURACAN_WITH_BMC: - case HURACAN_WITHOUT_BMC: - case HURACAN_A_WITH_BMC: - case HURACAN_A_WITHOUT_BMC: - if (FanDir != 0) - cTable = &(ControlTable[0]); - else - cTable = &(ControlTable_B2F[0]); - break; - - case SESTO_WITH_BMC: - case SESTO_WITHOUT_BMC: - if (FanDir != 0) - cTable = &(ControlTable[1]); - else - cTable = &(ControlTable_B2F[1]); - break; - - case NCIIX_WITH_BMC: - case NCIIX_WITHOUT_BMC: - if (FanDir != 0) - cTable = &(ControlTable[2]); - else - cTable = &(ControlTable_B2F[2]); - break; - - case ASTERION_WITH_BMC: - case ASTERION_WITHOUT_BMC: - if (FanDir2 != 0) - cTable = &(ControlTable[3]); - else - cTable = &(ControlTable_B2F[3]); - break; - } - - return cTable; -} - -#if 0 -static int i2c_device_byte_write(const struct i2c_client *client, unsigned char command, unsigned char value) -{ - unsigned int retry = 10; - int ret; - - while(retry>=0) - { - ret = i2c_smbus_write_byte_data(client, command, value); - mdelay(10); - if (ret >=0) - break; - retry--; - } - - if (ret < 0) - printk(KERN_INFO "%s fail : slave addr 0x%02x, command = 0x%02x, value = 0x%02x\n", __func__, client->addr, command, value); - - return ret; -} -#endif - -#define BIT_INDEX(i) (1ULL << (i)) -#define SFF8436_RX_LOS_ADDR 3 -#define SFF8436_TX_FAULT_ADDR 4 -#define SFF8436_TX_DISABLE_ADDR 86 - -#define I2C_RW_RETRY_COUNT 3 -#define I2C_RW_RETRY_INTERVAL 100 /* ms */ - -enum port_sysfs_attributes { - PRESENT, - RX_LOS, - RX_LOS1, - RX_LOS2, - RX_LOS3, - RX_LOS4, - TX_DISABLE, - TX_DISABLE1, - TX_DISABLE2, - TX_DISABLE3, - TX_DISABLE4, - TX_FAULT, - TX_FAULT1, - TX_FAULT2, - TX_FAULT3, - TX_FAULT4, - EEPROM_A0_PAGE, - EEPROM_A2_PAGE, - SFP_COPPER, - LAST_ATTRIBUTE -}; - -static struct mutex portStatusLock; - -static int i2c_device_word_write(const struct i2c_client *client, unsigned char command, unsigned short value) -{ - unsigned int retry = 10; - int ret; - - if (i2c_smbus_read_byte_data(client, command)<0) - return -1; - - while(retry>=0) - { - ret = i2c_smbus_write_word_data(client, command, value); - mdelay(10); - if (ret >=0) - break; - retry--; - } - - if (ret < 0) - printk(KERN_INFO "%s fail : slave addr 0x%02x, command = 0x%02x, value = 0x%04x\n", __func__, client->addr, command, value); - - return ret; -} - -int eepromDataBlockRead(struct i2c_client *client, char *buf) -{ - char data[32]; - int i, ret; - - for (i=0; i<8; i++) - { - memset(data, 0, 32); - ret = i2c_smbus_read_i2c_block_data(client, (i*32), 32, data); - if (ret < 0) - return ret; - memcpy(buf+(i*32), data, 32); - } - return ret; -} - -int eepromDataByteRead(struct i2c_client *client, char *buf) -{ - unsigned int index; - int value; - - for (index=0; index> 8; - buf[index*2] = value & 0x00ff; - } - return 0; -} - -int eepromDataRead(struct i2c_client *client, char *buf) -{ - unsigned int index; - int value; - - for (index=0; indexlock); - - /* Get Fan Speed and display status */ - fanErr = 0; - for (i=0; i= W83795ADG_NUM8) && (data->modelId != ASTERION_WITH_BMC) && (data->modelId != ASTERION_WITHOUT_BMC)) - { - FanErr[i] = 0; - continue; - } - - fanSpeed = 0; - /* Choose W83795ADG bank 0 */ - i2c_smbus_write_byte_data(client, W83795ADG_REG_BANK, 0x00); - MNTFANM = (int) i2c_smbus_read_byte_data(client, (W83795ADG_REG_FANIN1_COUNT+i)); - MNTFANL = (int) i2c_smbus_read_byte_data(client, W83795ADG_REG_VR_LSB); - if ( !((MNTFANM == 0xFF) && (MNTFANL == 0xF0)) ) - { - /* FanSpeed (RPM) = 1.35 x 10^6 / ( (12-bitCountValue) x (FanPoles/4) ) */ - TEMP = (((MNTFANM << 4) + ((MNTFANL & 0xF0) >> 4)) * (W83795ADG_FAN_POLES_NUMBER / 4)); - if (TEMP != 0) - fanSpeed = W83795ADG_FAN_SPEED_FACTOR / TEMP; - } - if (fanSpeed == 0) - fanErr = FanErr[i] = 1; - else - FanErr[i] = 0; - data->fanSpeed[i] = fanSpeed; - } - - if ((data->modelId==HURACAN_WITH_BMC)||(data->modelId==HURACAN_WITHOUT_BMC)) - { - if (data->hwRev == 0x00) /* Proto */ - { - if (fanErr == 1) - i2c_smbus_write_byte_data(&pca9535pwr_client_bus0, PCA9553_COMMAND_BYTE_REG_OUTPUT_PORT_0, 0x80); - else - i2c_smbus_write_byte_data(&pca9535pwr_client_bus0, PCA9553_COMMAND_BYTE_REG_OUTPUT_PORT_0, 0x00); - } - else if (data->hwRev == 0x02) /* Beta */ - { - if (fanErr == 1) - i2c_smbus_write_byte_data(&cpld_client, CPLD_REG_LED_0x44, 0x01); - else - i2c_smbus_write_byte_data(&cpld_client, CPLD_REG_LED_0x44, 0x00); - } - } - - /* Get Voltage */ - for (i=0; ivSen[i] = (unsigned int) i2c_smbus_read_byte_data(client, (W83795ADG_REG_VSEN1+i)); - data->vSenLsb[i] = (unsigned int) i2c_smbus_read_byte_data(client, W83795ADG_REG_VR_LSB); - } - - /* Get Remote Temp */ - for (i=0; i= W83795ADG_NUM2) && (data->modelId != ASTERION_WITH_BMC) && (data->modelId != ASTERION_WITHOUT_BMC)) - break; - - MNTRTD = (int) i2c_smbus_read_byte_data(client, (W83795ADG_REG_TR1+i)); - MNTTD = (int) i2c_smbus_read_byte_data(client, W83795ADG_REG_VR_LSB); - /* temperature is negative */ - if ( MNTRTD & 0x80 ) - { - data->remoteTempIsPositive[i] = 0; - cTemp = (((MNTRTD << 2) + ((MNTTD & 0xC0) >> 6)) ^ 0x1FF) + 1; /* calculate 2's complement */ - data->remoteTempDecimal[i] = (cTemp & 0x3) * TEMP_DECIMAL_BASE; - data->remoteTempInt[i] = cTemp >> 2; - } - else - { - data->remoteTempIsPositive[i] = 1; - data->remoteTempDecimal[i] = ((MNTTD & 0xC0) >> 6) * TEMP_DECIMAL_BASE; - data->remoteTempInt[i] = MNTRTD; - } - } - - if (fanCtrlDelay == 0) - { - /* Get Max. Temp */ - maxTemp = data->macTemp; - for (i=0; i= W83795ADG_NUM2) && (data->modelId != ASTERION_WITH_BMC) && (data->modelId != ASTERION_WITHOUT_BMC)) - break; - - if (data->remoteTempInt[i] > maxTemp) - maxTemp = data->remoteTempInt[i]; - } - - /* FAN Control */ - cTable = get_platform_control_table(); - - if (fanErr) - { - fanDuty = cTable->fanDutySet[2]; - LastTemp = 0; - } - else - { - fanDuty = 0; - if (maxTemp > LastTemp) /* temp is going to up */ - { - if (maxTemp < cTable->tempLow2HighThreshold[0]) - { - fanDuty = cTable->fanDutySet[0]; - } - else if (maxTemp < cTable->tempLow2HighThreshold[1]) - { - fanDuty = cTable->fanDutySet[1]; - } - else if (maxTemp < cTable->tempLow2HighThreshold[2]) - { - fanDuty = cTable->fanDutySet[2]; - } - else /* shutdown system */ - { - i2c_smbus_write_byte_data(&cpld_client, CPLD_REG_RESET_0x30, 0xff); - } - } - else if (maxTemp < LastTemp)/* temp is going to down */ - { - if (maxTemp <= cTable->tempHigh2LowThreshold[0]) - { - fanDuty = cTable->fanDutySet[0]; - } - else if (maxTemp <= cTable->tempHigh2LowThreshold[1]) - { - fanDuty = cTable->fanDutySet[1]; - } - else - { - fanDuty = cTable->fanDutySet[2]; - } - } - LastTemp = maxTemp; - } - - if ((fanDuty!=0)&&(data->fanDuty!=fanDuty)) - { - data->fanDuty = fanDuty; - - /* Choose W83795ADG bank 0 */ - i2c_smbus_write_byte_data(client, W83795ADG_REG_BANK, 0x00); - /* Disable monitoring operations */ - configByte = i2c_smbus_read_byte_data(client, W83795ADG_REG_CONFIG); - configByte &= 0xfe; - i2c_smbus_write_byte_data(client, W83795ADG_REG_CONFIG, configByte); - - /* Choose W83795ADG bank 2 */ - i2c_smbus_write_byte_data(client, W83795ADG_REG_BANK, 0x02); - i2c_smbus_write_byte_data(client, W83795ADG_REG_F1OV, fanDuty); - i2c_smbus_write_byte_data(client, W83795ADG_REG_F2OV, fanDuty); - - /* Choose W83795ADG bank 0 */ - i2c_smbus_write_byte_data(client, W83795ADG_REG_BANK, 0x00); - /* Enable monitoring operations */ - configByte |= 0x01; - i2c_smbus_write_byte_data(client, W83795ADG_REG_CONFIG, configByte); - } - } - - if (fanCtrlDelay > 0) - fanCtrlDelay --; - - data->psuPG = platformPsuPG = i2c_smbus_read_byte_data(&cpld_client, CPLD_REG_GENERAL_0x02); - data->psuABS = platformPsuABS = i2c_smbus_read_byte_data(&cpld_client, CPLD_REG_GENERAL_0x03); - switch(platformModelId) - { - case NCIIX_WITH_BMC: - case NCIIX_WITHOUT_BMC: - for (i=0; i<5 ; i++) - { - /* Turn on PCA9548#0 channel 3~7 on I2C-bus0 */ - i2c_smbus_write_byte_data(&pca9548_client_bus0, 0, (1<<(PCA9548_CH03+i))); - for (j=0; j<4; j++) - { - port_status = i2c_smbus_read_word_data(&(pca9535_client_bus0[j]), PCA9553_COMMAND_BYTE_REG_INPUT_PORT_0); - port = ((j*2)+(i*8)); - SFPPortTxFaultStatus[port] = (PCA9553_TEST_BIT(port_status, 0)==0); - SFPPortAbsStatus[port] = (PCA9553_TEST_BIT(port_status, 1)==0); - SFPPortRxLosStatus[port] = (PCA9553_TEST_BIT(port_status, 2)==0); - port++; - SFPPortTxFaultStatus[port] = (PCA9553_TEST_BIT(port_status, 6)==0); - SFPPortAbsStatus[port] = (PCA9553_TEST_BIT(port_status, 7)==0); - SFPPortRxLosStatus[port] = (PCA9553_TEST_BIT(port_status, 8)==0); - } - i2c_smbus_write_byte_data(&pca9548_client_bus0, 0, 0x00); - } - break; - - default: - break; - } - - /* Watchdog Control Register Support */ - if (data->cpldRev != 0) - { - if (data->wdEnable == 1) /* Watchdog Timer is enabled */ - { - if (data->wdRefreshControl == 0) /* Refresh Watchdog by Hardware Monitor */ - { - data->wdReg = i2c_smbus_read_byte_data(&cpld_client, CPLD_REG_GENERAL_0x06); - data->wdReg |= 0x01; /* clear timer */ - i2c_smbus_write_byte_data(&cpld_client, CPLD_REG_GENERAL_0x06, data->wdReg); - } - else if (data->wdRefreshControl == 1) /* Refresh Watchdog by application */ - { - if (data->wdRefreshControlFlag == 1) - { - data->wdReg = i2c_smbus_read_byte_data(&cpld_client, CPLD_REG_GENERAL_0x06); - data->wdReg |= 0x01; /* clear timer */ - i2c_smbus_write_byte_data(&cpld_client, CPLD_REG_GENERAL_0x06, data->wdReg); - data->wdRefreshControlFlag = 0; - } - } - - /* Watchdog Timer timeout setting */ - if (data->wdRefreshTimeSelectFlag == 1) - { - data->wdReg = i2c_smbus_read_byte_data(&cpld_client, CPLD_REG_GENERAL_0x06); - data->wdReg |= 0x01; /* clear timer */ - data->wdReg &= (~0x38); - switch(data->wdRefreshTimeSelect) - { - case 1: /* 8 second delay */ - data->wdReg |= 0x20; - break; - - case 2: /* 16 second delay */ - data->wdReg |= 0x10; - break; - - case 3: /* 24 second delay */ - data->wdReg |= 0x30; - break; - - case 4: /* 32 second delay */ - data->wdReg |= 0x08; - break; - - case 5: /* 40 second delay */ - data->wdReg |= 0x28; - break; - - case 6: /* 48 second delay */ - data->wdReg |= 0x18; - break; - - case 7: /* 56 second delay */ - data->wdReg |= 0x38; - break; - - default: /* 8 second delay */ - data->wdReg |= 0x20; - break; - } - i2c_smbus_write_byte_data(&cpld_client, CPLD_REG_GENERAL_0x06, data->wdReg); - data->wdRefreshTimeSelectFlag = 0; - } - - /* Watchdog Timeout occurrence */ - if (data->wdTimeoutSelectFlag == 1) - { - data->wdReg = i2c_smbus_read_byte_data(&cpld_client, CPLD_REG_GENERAL_0x06); - data->wdReg |= 0x01; /* clear timer */ - if (data->wdTimeoutSelect == 0) /* System reset */ - data->wdReg &= (~0x02); - else /* Power cycle */ - data->wdReg |= 0x02; - i2c_smbus_write_byte_data(&cpld_client, CPLD_REG_GENERAL_0x06, data->wdReg); - data->wdTimeoutSelectFlag = 0; - } - } - else /* Watchdog Timer is disabled */ - { - data->wdReg = i2c_smbus_read_byte_data(&cpld_client, CPLD_REG_GENERAL_0x06); - data->wdReg |= 0x01; /* Enable WD function */ -#if 0 - data->wdReg &= (~0x02); /* default select System reset */ -#else - data->wdReg |= 0x02; /* default select Power cycle */ - data->wdTimeoutSelect = 1; -#endif - data->wdReg &= (~0x38); - data->wdReg |= 0x20; /* default select 8 second delay */ - data->wdRefreshTimeSelect = 1; - i2c_smbus_write_byte_data(&cpld_client, CPLD_REG_GENERAL_0x06, data->wdReg); - data->wdEnable = 1; - } - } - mutex_unlock(&data->lock); - } - - if (kthread_should_stop()) - break; - msleep_interruptible(1000); - } - - complete_all(&data->auto_update_stop); - return 0; -} - -static int i2c_bus1_hardware_monitor_update_thread(void *p) -{ - struct i2c_client *client = p; - struct i2c_bus1_hardware_monitor_data *data = i2c_get_clientdata(client); - int i, ret; - unsigned short value, value2, fanErr, fanErr2; - unsigned int step = 0; - unsigned char qsfpPortData[QSFP_DATA_SIZE]; - unsigned char SfpCopperPortData[SFP_COPPER_DATA_SIZE]; - unsigned short port_status; - int j, port; - - while (!kthread_should_stop()) - { - mutex_lock(&data->lock); - switch(platformModelId) - { - case HURACAN_WITH_BMC: - case HURACAN_WITHOUT_BMC: - case HURACAN_A_WITH_BMC: - case HURACAN_A_WITHOUT_BMC: - switch (step) - { - case 0: - /* Turn on PCA9548 channel 4 on I2C-bus1 */ - ret = i2c_smbus_write_byte(client, (1<qsfpPortAbsStatus[i] = i2c_smbus_read_word_data(&(pca9535pwr_client[i]), PCA9553_COMMAND_BYTE_REG_INPUT_PORT_0); - - step = 1; - break; - - case 1: - if ((data->qsfpPortAbsStatus[0]&0x00ff)!=0x00ff) /* QSFP 0~7 ABS */ - { - /* Turn on PCA9548 channel 0 on I2C-bus1 */ - ret = i2c_smbus_write_byte(client, (1<qsfpPortAbsStatus[0], i) == 0) /* present */ - { - ret = i2c_smbus_write_byte(&(pca9548_client[0]), (1<=0) - { - if (data->qsfpPortTxDisableDataUpdate[i] == 1) - { - eepromDataByteWrite(&qsfpDataA0_client, SFF8436_TX_DISABLE_ADDR, &data->qsfpPortTxDisableData[i], sizeof(char)); - data->qsfpPortTxDisableDataUpdate[i] = 0; - } - ret = eepromDataBlockRead(&qsfpDataA0_client,qsfpPortData); - if (ret>=0) - { - memcpy(&(data->qsfpPortDataA0[i][0]), qsfpPortData, QSFP_DATA_SIZE); - PCA9553_SET_BIT(data->qsfpPortDataValid[0], i); - } - } - i2c_smbus_write_byte(&(pca9548_client[0]), 0x00); - } - else - { - memset(&(data->qsfpPortDataA0[i][0]), 0, QSFP_DATA_SIZE); - PCA9553_CLEAR_BIT(data->qsfpPortDataValid[0], i); - data->qsfpPortTxDisableDataUpdate[i] = 1; - } - } - } - else - { - for (i=0; i<8; i++) - { - memset(&(data->qsfpPortDataA0[i][0]), 0, QSFP_DATA_SIZE); - PCA9553_CLEAR_BIT(data->qsfpPortDataValid[0], i); - data->qsfpPortTxDisableDataUpdate[i] = 1; - } - } - - step = 2; - break; - - case 2: - if ((data->qsfpPortAbsStatus[0]&0xff00)!=0xff00) /* QSFP 8~15 ABS */ - { - /* Turn on PCA9548 channel 1 on I2C-bus1 */ - ret = i2c_smbus_write_byte(client, (1<qsfpPortAbsStatus[0], i) == 0) /* present */ - { - ret = i2c_smbus_write_byte(&(pca9548_client[1]), (1<<(i-8))); - if (ret>=0) - { - if (data->qsfpPortTxDisableDataUpdate[i] == 1) - { - eepromDataByteWrite(&qsfpDataA0_client, SFF8436_TX_DISABLE_ADDR, &data->qsfpPortTxDisableData[i], sizeof(char)); - data->qsfpPortTxDisableDataUpdate[i] = 0; - } - ret = eepromDataBlockRead(&qsfpDataA0_client,qsfpPortData); - if (ret>=0) - { - memcpy(&(data->qsfpPortDataA0[i][0]), qsfpPortData, QSFP_DATA_SIZE); - PCA9553_SET_BIT(data->qsfpPortDataValid[0], i); - } - } - i2c_smbus_write_byte(&(pca9548_client[1]), 0x00); - } - else - { - memset(&(data->qsfpPortDataA0[i][0]), 0, QSFP_DATA_SIZE); - PCA9553_CLEAR_BIT(data->qsfpPortDataValid[0], i); - data->qsfpPortTxDisableDataUpdate[i] = 1; - } - } - } - else - { - for (i=8; i<16; i++) - { - memset(&(data->qsfpPortDataA0[i][0]), 0, QSFP_DATA_SIZE); - PCA9553_CLEAR_BIT(data->qsfpPortDataValid[0], i); - data->qsfpPortTxDisableDataUpdate[i] = 1; - } - } - - step = 3; - break; - - case 3: - if ((data->qsfpPortAbsStatus[1]&0x00ff)!=0x00ff) /* QSFP 16~23 ABS */ - { - /* Turn on PCA9548 channel 2 on I2C-bus1 */ - ret = i2c_smbus_write_byte(client, (1<qsfpPortAbsStatus[1], i) == 0) /* present */ - { - ret = i2c_smbus_write_byte(&(pca9548_client[2]), (1<=0) - { - if (data->qsfpPortTxDisableDataUpdate[i+16] == 1) - { - eepromDataByteWrite(&qsfpDataA0_client, SFF8436_TX_DISABLE_ADDR, &data->qsfpPortTxDisableData[i+16], sizeof(char)); - data->qsfpPortTxDisableDataUpdate[i+16] = 0; - } - ret = eepromDataBlockRead(&qsfpDataA0_client,qsfpPortData); - if (ret>=0) - { - memcpy(&(data->qsfpPortDataA0[i+16][0]), qsfpPortData, QSFP_DATA_SIZE); - PCA9553_SET_BIT(data->qsfpPortDataValid[1], i); - } - } - i2c_smbus_write_byte(&(pca9548_client[2]), 0x00); - } - else - { - memset(&(data->qsfpPortDataA0[i+16][0]), 0, QSFP_DATA_SIZE); - PCA9553_CLEAR_BIT(data->qsfpPortDataValid[1], i); - data->qsfpPortTxDisableDataUpdate[i+16] = 1; - } - } - } - else - { - for (i=0; i<8; i++) - { - memset(&(data->qsfpPortDataA0[i+16][0]), 0, QSFP_DATA_SIZE); - PCA9553_CLEAR_BIT(data->qsfpPortDataValid[1], i); - data->qsfpPortTxDisableDataUpdate[i+16] = 1; - } - } - - step = 4; - break; - - case 4: - if ((data->qsfpPortAbsStatus[1]&0xff00)!=0xff00) /* QSFP 24~31 ABS */ - { - /* Turn on PCA9548 channel 3 on I2C-bus1 */ - ret = i2c_smbus_write_byte(client, (1<qsfpPortAbsStatus[1], i) == 0) /* present */ - { - ret = i2c_smbus_write_byte(&(pca9548_client[3]), (1<<(i-8))); - if (ret>=0) - { - if (data->qsfpPortTxDisableDataUpdate[i+16] == 1) - { - eepromDataByteWrite(&qsfpDataA0_client, SFF8436_TX_DISABLE_ADDR, &data->qsfpPortTxDisableData[i+16], sizeof(char)); - data->qsfpPortTxDisableDataUpdate[i+16] = 0; - } - ret = eepromDataBlockRead(&qsfpDataA0_client,qsfpPortData); - if (ret>=0) - { - memcpy(&(data->qsfpPortDataA0[i+16][0]), qsfpPortData, QSFP_DATA_SIZE); - PCA9553_SET_BIT(data->qsfpPortDataValid[1], i); - } - } - i2c_smbus_write_byte(&(pca9548_client[3]), 0x00); - } - else - { - memset(&(data->qsfpPortDataA0[i+16][0]), 0, QSFP_DATA_SIZE); - PCA9553_CLEAR_BIT(data->qsfpPortDataValid[1], i); - data->qsfpPortTxDisableDataUpdate[i+16] = 1; - } - } - } - else - { - for (i=8; i<16; i++) - { - memset(&(data->qsfpPortDataA0[i+16][0]), 0, QSFP_DATA_SIZE); - PCA9553_CLEAR_BIT(data->qsfpPortDataValid[1], i); - data->qsfpPortTxDisableDataUpdate[i+16] = 1; - } - } - - if (isBMCSupport == 0) - step = 5; - else - step = 0; - break; - - case 5: - /* Turn on PCA9548 channel 7 on I2C-bus1 */ - ret = i2c_smbus_write_byte(client, (1<frontLedStatus |= 0x00ff; - if (fanErr==0) - data->frontLedStatus &= (~0x0008); /* FAN_LED_G# */ - else - data->frontLedStatus &= (~0x0004); /* FAN_LED_Y# */ - - if ((platformPsuABS&0x01)==0x00) /* PSU1 Present */ - { - if (platformPsuPG&0x08) /* PSU1_PG_LDC Power Goodasserted */ - data->frontLedStatus &= (~0x0002); /* PSU1_LED_G# */ - else - data->frontLedStatus &= (~0x0001); /* PSU1_LED_Y# */ - } - if ((platformPsuABS&0x02)==0x00) /* PSU2 Present */ - { - if (platformPsuPG&0x10) /* PSU2_PG_LDC Power Goodasserted */ - data->frontLedStatus &= (~0x0020); /* PSU2_LED_G# */ - else - data->frontLedStatus &= (~0x0010); /* PSU2_LED_Y# */ - } - - switch (data->systemLedStatus) - { - default: - case 0: /* Booting */ - break; - - case 1: /* Critical*/ - data->frontLedStatus &= (~0x0040); /* SYS_LED_Y# */ - break; - - case 2: /* Normal */ - data->frontLedStatus &= (~0x0080); /* SYS_LED_G# */ - break; - } - - i2c_device_word_write(&(pca9535pwr_client[2]), PCA9553_COMMAND_BYTE_REG_OUTPUT_PORT_0, data->frontLedStatus); - } - - /* FAN Status */ - value = i2c_smbus_read_word_data(&(pca9535pwr_client[0]), PCA9553_COMMAND_BYTE_REG_INPUT_PORT_0); - data->fanAbs[0] = (value&0x4444); - data->fanDir[0] = (value&0x8888); - FanDir = data->fanDir[0]; - - step = 0; - break; - - default: - step = 0; - break; - } - i2c_smbus_write_byte_data(&cpld_client, CPLD_REG_RESET_0x33, 0x00); - i2c_smbus_write_byte_data(&cpld_client, CPLD_REG_RESET_0x33, 0xff); - break; - - case CABRERAIII_WITH_BMC: - case CABRERAIII_WITHOUT_BMC: - break; - - case SESTO_WITH_BMC: - case SESTO_WITHOUT_BMC: - switch (step) - { - case 0: - /* Turn on PCA9548#1 channel 0 on I2C-bus1 */ - ret = i2c_smbus_write_byte(&(pca9548_client[1]), (1<qsfpPortAbsStatus[i] = i2c_smbus_read_word_data(&(pca9535pwr_client[i]), PCA9553_COMMAND_BYTE_REG_INPUT_PORT_0); - - /* Turn on PCA9548#1 channel 1 on I2C-bus1 */ - ret = i2c_smbus_write_byte(&(pca9548_client[1]), (1<sfpPortRxLosStatus[i] = i2c_smbus_read_word_data(&(pca9535pwr_client[i]), PCA9553_COMMAND_BYTE_REG_INPUT_PORT_0); - - /* Turn on PCA9548#1 channel 2 on I2C-bus1 */ - ret = i2c_smbus_write_byte(&(pca9548_client[1]), (1<sfpPortTxFaultStatus[i] = i2c_smbus_read_word_data(&(pca9535pwr_client[i]), PCA9553_COMMAND_BYTE_REG_INPUT_PORT_0); - - step = 1; - break; - - case 1: - if ((data->qsfpPortAbsStatus[0]&0x00ff)!=0x00ff) /* SFP 0~7 ABS */ - { - /* Turn on PCA9548#0 channel 0 on I2C-bus1 */ - ret = i2c_smbus_write_byte(client, (1<qsfpPortAbsStatus[0], i) == 0) /* present */ - { - ret = i2c_smbus_write_byte(&(pca9548_client[0]), (1<=0) - { - if (PCA9553_TEST_BIT(data->qsfpPortDataValid[0], i) == 0) - { - ret = eepromDataBlockRead(&qsfpDataA0_client,qsfpPortData); - if (ret>=0) - { - memcpy(&(data->qsfpPortDataA0[i][0]), qsfpPortData, QSFP_DATA_SIZE); - PCA9553_SET_BIT(data->qsfpPortDataValid[0], i); - } - } - ret = eepromDataBlockRead(&qsfpDataA2_client,qsfpPortData); - if (ret>=0) - memcpy(&(data->qsfpPortDataA2[i][0]), qsfpPortData, QSFP_DATA_SIZE); - ret = eepromDataWordRead(&SfpCopperData_client,SfpCopperPortData); - if (ret>=0) - memcpy(&(data->SfpCopperPortData[i][0]), SfpCopperPortData, SFP_COPPER_DATA_SIZE); - } - i2c_smbus_write_byte(&(pca9548_client[0]), 0x00); - } - else - { - memset(&(data->qsfpPortDataA0[i][0]), 0, QSFP_DATA_SIZE); - memset(&(data->qsfpPortDataA2[i][0]), 0, QSFP_DATA_SIZE); - memset(&(data->SfpCopperPortData[i][0]), 0, SFP_COPPER_DATA_SIZE); - PCA9553_CLEAR_BIT(data->qsfpPortDataValid[0], i); - } - } - } - else - { - for (i=0; i<8; i++) - { - memset(&(data->qsfpPortDataA0[i][0]), 0, QSFP_DATA_SIZE); - memset(&(data->qsfpPortDataA2[i][0]), 0, QSFP_DATA_SIZE); - memset(&(data->SfpCopperPortData[i][0]), 0, SFP_COPPER_DATA_SIZE); - PCA9553_CLEAR_BIT(data->qsfpPortDataValid[0], i); - } - } - - step = 2; - break; - - case 2: - if ((data->qsfpPortAbsStatus[0]&0xff00)!=0xff00) /* SFP 8~15 ABS */ - { - /* Turn on PCA9548#0 channel 1 on I2C-bus1 */ - ret = i2c_smbus_write_byte(client, (1<qsfpPortAbsStatus[0], i) == 0) /* present */ - { - ret = i2c_smbus_write_byte(&(pca9548_client[0]), (1<<(i-8))); - if (ret>=0) - { - if (PCA9553_TEST_BIT(data->qsfpPortDataValid[0], i) == 0) - { - ret = eepromDataBlockRead(&qsfpDataA0_client,qsfpPortData); - if (ret>=0) - { - memcpy(&(data->qsfpPortDataA0[i][0]), qsfpPortData, QSFP_DATA_SIZE); - PCA9553_SET_BIT(data->qsfpPortDataValid[0], i); - } - } - ret = eepromDataBlockRead(&qsfpDataA2_client,qsfpPortData); - if (ret>=0) - memcpy(&(data->qsfpPortDataA2[i][0]), qsfpPortData, QSFP_DATA_SIZE); - ret = eepromDataWordRead(&SfpCopperData_client,SfpCopperPortData); - if (ret>=0) - memcpy(&(data->SfpCopperPortData[i][0]), SfpCopperPortData, SFP_COPPER_DATA_SIZE); - } - i2c_smbus_write_byte(&(pca9548_client[0]), 0x00); - } - else - { - memset(&(data->qsfpPortDataA0[i][0]), 0, QSFP_DATA_SIZE); - memset(&(data->qsfpPortDataA2[i][0]), 0, QSFP_DATA_SIZE); - memset(&(data->SfpCopperPortData[i][0]), 0, SFP_COPPER_DATA_SIZE); - PCA9553_CLEAR_BIT(data->qsfpPortDataValid[0], i); - } - } - } - else - { - for (i=8; i<16; i++) - { - memset(&(data->qsfpPortDataA0[i][0]), 0, QSFP_DATA_SIZE); - memset(&(data->qsfpPortDataA2[i][0]), 0, QSFP_DATA_SIZE); - memset(&(data->SfpCopperPortData[i][0]), 0, SFP_COPPER_DATA_SIZE); - PCA9553_CLEAR_BIT(data->qsfpPortDataValid[0], i); - } - } - - step = 3; - break; - - case 3: - if ((data->qsfpPortAbsStatus[1]&0x00ff)!=0x00ff) /* SFP 16~23 ABS */ - { - /* Turn on PCA9548#0 channel 2 on I2C-bus1 */ - ret = i2c_smbus_write_byte(client, (1<qsfpPortAbsStatus[1], i) == 0) /* present */ - { - ret = i2c_smbus_write_byte(&(pca9548_client[0]), (1<=0) - { - if (PCA9553_TEST_BIT(data->qsfpPortDataValid[1], i) == 0) - { - ret = eepromDataBlockRead(&qsfpDataA0_client,qsfpPortData); - if (ret>=0) - { - memcpy(&(data->qsfpPortDataA0[i+16][0]), qsfpPortData, QSFP_DATA_SIZE); - PCA9553_SET_BIT(data->qsfpPortDataValid[1], i); - } - } - ret = eepromDataBlockRead(&qsfpDataA2_client,qsfpPortData); - if (ret>=0) - memcpy(&(data->qsfpPortDataA2[i+16][0]), qsfpPortData, QSFP_DATA_SIZE); - ret = eepromDataWordRead(&SfpCopperData_client,SfpCopperPortData); - if (ret>=0) - memcpy(&(data->SfpCopperPortData[i+16][0]), SfpCopperPortData, SFP_COPPER_DATA_SIZE); - } - i2c_smbus_write_byte(&(pca9548_client[0]), 0x00); - } - else - { - memset(&(data->qsfpPortDataA0[i+16][0]), 0, QSFP_DATA_SIZE); - memset(&(data->qsfpPortDataA2[i+16][0]), 0, QSFP_DATA_SIZE); - memset(&(data->SfpCopperPortData[i+16][0]), 0, SFP_COPPER_DATA_SIZE); - PCA9553_CLEAR_BIT(data->qsfpPortDataValid[1], i); - } - } - } - else - { - for (i=0; i<8; i++) - { - memset(&(data->qsfpPortDataA0[i+16][0]), 0, QSFP_DATA_SIZE); - memset(&(data->qsfpPortDataA2[i+16][0]), 0, QSFP_DATA_SIZE); - memset(&(data->SfpCopperPortData[i+16][0]), 0, SFP_COPPER_DATA_SIZE); - PCA9553_CLEAR_BIT(data->qsfpPortDataValid[1], i); - } - } - - step = 4; - break; - - case 4: - if ((data->qsfpPortAbsStatus[1]&0xff00)!=0xff00) /* SFP 24~31 ABS */ - { - /* Turn on PCA9548#0 channel 3 on I2C-bus1 */ - ret = i2c_smbus_write_byte(client, (1<qsfpPortAbsStatus[1], i) == 0) /* present */ - { - ret = i2c_smbus_write_byte(&(pca9548_client[0]), (1<<(i-8))); - if (ret>=0) - { - if (PCA9553_TEST_BIT(data->qsfpPortDataValid[1], i) == 0) - { - ret = eepromDataBlockRead(&qsfpDataA0_client,qsfpPortData); - if (ret>=0) - { - memcpy(&(data->qsfpPortDataA0[i+16][0]), qsfpPortData, QSFP_DATA_SIZE); - PCA9553_SET_BIT(data->qsfpPortDataValid[1], i); - } - } - ret = eepromDataBlockRead(&qsfpDataA2_client,qsfpPortData); - if (ret>=0) - memcpy(&(data->qsfpPortDataA2[i+16][0]), qsfpPortData, QSFP_DATA_SIZE); - ret = eepromDataWordRead(&SfpCopperData_client,SfpCopperPortData); - if (ret>=0) - memcpy(&(data->SfpCopperPortData[i+16][0]), SfpCopperPortData, SFP_COPPER_DATA_SIZE); - } - i2c_smbus_write_byte(&(pca9548_client[0]), 0x00); - } - else - { - memset(&(data->qsfpPortDataA0[i+16][0]), 0, QSFP_DATA_SIZE); - memset(&(data->qsfpPortDataA2[i+16][0]), 0, QSFP_DATA_SIZE); - memset(&(data->SfpCopperPortData[i+16][0]), 0, SFP_COPPER_DATA_SIZE); - PCA9553_CLEAR_BIT(data->qsfpPortDataValid[1], i); - } - } - } - else - { - for (i=8; i<16; i++) - { - memset(&(data->qsfpPortDataA0[i+16][0]), 0, QSFP_DATA_SIZE); - memset(&(data->qsfpPortDataA2[i+16][0]), 0, QSFP_DATA_SIZE); - memset(&(data->SfpCopperPortData[i+16][0]), 0, SFP_COPPER_DATA_SIZE); - PCA9553_CLEAR_BIT(data->qsfpPortDataValid[1], i); - } - } - - step = 5; - break; - - case 5: - if ((data->qsfpPortAbsStatus[2]&0x00ff)!=0x00ff) /* SFP 32~39 ABS */ - { - /* Turn on PCA9548#0 channel 4 on I2C-bus1 */ - ret = i2c_smbus_write_byte(client, (1<qsfpPortAbsStatus[2], i) == 0) /* present */ - { - ret = i2c_smbus_write_byte(&(pca9548_client[0]), (1<=0) - { - if (PCA9553_TEST_BIT(data->qsfpPortDataValid[2], i) == 0) - { - ret = eepromDataBlockRead(&qsfpDataA0_client,qsfpPortData); - if (ret>=0) - { - memcpy(&(data->qsfpPortDataA0[i+32][0]), qsfpPortData, QSFP_DATA_SIZE); - PCA9553_SET_BIT(data->qsfpPortDataValid[2], i); - } - } - ret = eepromDataBlockRead(&qsfpDataA2_client,qsfpPortData); - if (ret>=0) - memcpy(&(data->qsfpPortDataA2[i+32][0]), qsfpPortData, QSFP_DATA_SIZE); - ret = eepromDataWordRead(&SfpCopperData_client,SfpCopperPortData); - if (ret>=0) - memcpy(&(data->SfpCopperPortData[i+32][0]), SfpCopperPortData, SFP_COPPER_DATA_SIZE); - } - i2c_smbus_write_byte(&(pca9548_client[0]), 0x00); - } - else - { - memset(&(data->qsfpPortDataA0[i+32][0]), 0, QSFP_DATA_SIZE); - memset(&(data->qsfpPortDataA2[i+32][0]), 0, QSFP_DATA_SIZE); - memset(&(data->SfpCopperPortData[i+32][0]), 0, SFP_COPPER_DATA_SIZE); - PCA9553_CLEAR_BIT(data->qsfpPortDataValid[2], i); - } - } - } - else - { - for (i=0; i<8; i++) - { - memset(&(data->qsfpPortDataA0[i+32][0]), 0, QSFP_DATA_SIZE); - memset(&(data->qsfpPortDataA2[i+32][0]), 0, QSFP_DATA_SIZE); - memset(&(data->SfpCopperPortData[i+32][0]), 0, SFP_COPPER_DATA_SIZE); - PCA9553_CLEAR_BIT(data->qsfpPortDataValid[2], i); - } - } - - step = 6; - break; - - case 6: - if ((data->qsfpPortAbsStatus[2]&0xff00)!=0xff00) /* SFP 40~47 ABS */ - { - /* Turn on PCA9548#0 channel 5 on I2C-bus1 */ - ret = i2c_smbus_write_byte(client, (1<qsfpPortAbsStatus[2], i) == 0) /* present */ - { - ret = i2c_smbus_write_byte(&(pca9548_client[0]), (1<<(i-8))); - if (ret>=0) - { - if (PCA9553_TEST_BIT(data->qsfpPortDataValid[2], i) == 0) - { - ret = eepromDataBlockRead(&qsfpDataA0_client,qsfpPortData); - if (ret>=0) - { - memcpy(&(data->qsfpPortDataA0[i+32][0]), qsfpPortData, QSFP_DATA_SIZE); - PCA9553_SET_BIT(data->qsfpPortDataValid[2], i); - } - } - ret = eepromDataBlockRead(&qsfpDataA2_client,qsfpPortData); - if (ret>=0) - memcpy(&(data->qsfpPortDataA2[i+32][0]), qsfpPortData, QSFP_DATA_SIZE); - ret = eepromDataWordRead(&SfpCopperData_client,SfpCopperPortData); - if (ret>=0) - memcpy(&(data->SfpCopperPortData[i+32][0]), SfpCopperPortData, SFP_COPPER_DATA_SIZE); - } - i2c_smbus_write_byte(&(pca9548_client[0]), 0x00); - } - else - { - memset(&(data->qsfpPortDataA0[i+32][0]), 0, QSFP_DATA_SIZE); - memset(&(data->qsfpPortDataA2[i+32][0]), 0, QSFP_DATA_SIZE); - memset(&(data->SfpCopperPortData[i+32][0]), 0, SFP_COPPER_DATA_SIZE); - PCA9553_CLEAR_BIT(data->qsfpPortDataValid[2], i); - } - } - } - else - { - for (i=8; i<16; i++) - { - memset(&(data->qsfpPortDataA0[i+32][0]), 0, QSFP_DATA_SIZE); - memset(&(data->qsfpPortDataA2[i+32][0]), 0, QSFP_DATA_SIZE); - memset(&(data->SfpCopperPortData[i+32][0]), 0, SFP_COPPER_DATA_SIZE); - PCA9553_CLEAR_BIT(data->qsfpPortDataValid[2], i); - } - } - - step = 7; - break; - - case 7: - if ((data->qsfpPortAbsStatus[3]&0x00ff)!=0x00ff) /* QSFP 0~5 ABS */ - { - /* Turn on PCA9548#0 channel 6 on I2C-bus1 */ - ret = i2c_smbus_write_byte(client, (1<qsfpPortAbsStatus[3], i) == 0) /* present */ - { - ret = i2c_smbus_write_byte(&(pca9548_client[0]), (1<=0) - { - if (data->qsfpPortTxDisableDataUpdate[i+48] == 1) - { - eepromDataByteWrite(&qsfpDataA0_client, SFF8436_TX_DISABLE_ADDR, &data->qsfpPortTxDisableData[i+48], sizeof(char)); - data->qsfpPortTxDisableDataUpdate[i+48] = 0; - } - ret = eepromDataBlockRead(&qsfpDataA0_client,qsfpPortData); - if (ret>=0) - { - memcpy(&(data->qsfpPortDataA0[i+48][0]), qsfpPortData, QSFP_DATA_SIZE); - PCA9553_SET_BIT(data->qsfpPortDataValid[3], i); - } - } - i2c_smbus_write_byte(&(pca9548_client[0]), 0x00); - } - else - { - memset(&(data->qsfpPortDataA0[i+48][0]), 0, QSFP_DATA_SIZE); - PCA9553_CLEAR_BIT(data->qsfpPortDataValid[3], i); - data->qsfpPortTxDisableDataUpdate[i+48] = 1; - } - } - } - else - { - for (i=0; i<6; i++) - { - memset(&(data->qsfpPortDataA0[i+48][0]), 0, QSFP_DATA_SIZE); - PCA9553_CLEAR_BIT(data->qsfpPortDataValid[3], i); - data->qsfpPortTxDisableDataUpdate[i+48] = 1; - } - } - - if (isBMCSupport == 0) - step = 8; - else - step = 0; - break; - - case 8: - /* Turn on PCA9548#0 channel 7 on I2C-bus1 */ - ret = i2c_smbus_write_byte(client, (1<frontLedStatus |= 0x00ff; - if (fanErr==0) - data->frontLedStatus &= (~0x0008); /* FAN_LED_G# */ - else - data->frontLedStatus &= (~0x0004); /* FAN_LED_Y# */ - - if ((platformPsuABS&0x01)==0x00) /* PSU1 Present */ - { - if (platformPsuPG&0x08) /* PSU1_PG_LDC Power Goodasserted */ - data->frontLedStatus &= (~0x0002); /* PSU1_LED_G# */ - else - data->frontLedStatus &= (~0x0001); /* PSU1_LED_Y# */ - } - if ((platformPsuABS&0x02)==0x00) /* PSU2 Present */ - { - if (platformPsuPG&0x10) /* PSU2_PG_LDC Power Goodasserted */ - data->frontLedStatus &= (~0x0020); /* PSU2_LED_G# */ - else - data->frontLedStatus &= (~0x0010); /* PSU2_LED_Y# */ - } - - switch (data->systemLedStatus) - { - default: - case 0: /* Booting */ - break; - - case 1: /* Critical*/ - data->frontLedStatus &= (~0x0040); /* SYS_LED_Y# */ - break; - - case 2: /* Normal */ - data->frontLedStatus &= (~0x0080); /* SYS_LED_G# */ - break; - } - - i2c_device_word_write(&(pca9535pwr_client[2]), PCA9553_COMMAND_BYTE_REG_OUTPUT_PORT_0, data->frontLedStatus); - - /* FAN Status */ - value = i2c_smbus_read_word_data(&(pca9535pwr_client[0]), PCA9553_COMMAND_BYTE_REG_INPUT_PORT_0); - data->fanAbs[0] = (value&0x4444); - data->fanDir[0] = (value&0x8888); - FanDir = data->fanDir[0]; - - step = 0; - break; - - default: - step = 0; - break; - } - i2c_smbus_write_byte_data(&cpld_client, CPLD_REG_RESET_0x33, 0x00); - i2c_smbus_write_byte_data(&cpld_client, CPLD_REG_RESET_0x33, 0xff); - break; - - case NCIIX_WITH_BMC: - case NCIIX_WITHOUT_BMC: - switch (step) - { - case 0: - /* Turn on PCA9548#1 channel 0 on I2C-bus1 */ - ret = i2c_smbus_write_byte_data(client, 0, (1<frontLedStatus |= 0x00ff; - if (fanErr==0) - data->frontLedStatus &= (~0x0008); /* FAN_LED_G# */ - else - data->frontLedStatus &= (~0x0004); /* FAN_LED_Y# */ - - if ((platformPsuABS&0x01)==0x00) /* PSU1 Present */ - { - if (platformPsuPG&0x08) /* PSU1_PG_LDC Power Goodasserted */ - data->frontLedStatus &= (~0x0002); /* PSU1_LED_G# */ - else - data->frontLedStatus &= (~0x0001); /* PSU1_LED_Y# */ - } - if ((platformPsuABS&0x02)==0x00) /* PSU2 Present */ - { - if (platformPsuPG&0x10) /* PSU2_PG_LDC Power Goodasserted */ - data->frontLedStatus &= (~0x0020); /* PSU2_LED_G# */ - else - data->frontLedStatus &= (~0x0010); /* PSU2_LED_Y# */ - } - - switch (data->systemLedStatus) - { - default: - case 0: /* Booting */ - break; - - case 1: /* Critical*/ - data->frontLedStatus &= (~0x0040); /* SYS_LED_Y# */ - break; - - case 2: /* Normal */ - data->frontLedStatus &= (~0x0080); /* SYS_LED_G# */ - break; - } - - i2c_device_word_write(&(pca9535pwr_client[2]), PCA9553_COMMAND_BYTE_REG_OUTPUT_PORT_0, data->frontLedStatus); - - i2c_smbus_write_byte_data(client, 0, 0x00); - step = 2; - break; - - case 2: - /* Turn on PCA9548#1 channel 3 on I2C-bus1 */ - ret = i2c_smbus_write_byte_data(client, 0, (1<fanAbs[0] = (value&0x4444); - data->fanDir[0] = (value&0x8888); - FanDir = data->fanDir[0]; - - - i2c_smbus_write_byte_data(client, 0, 0x00); - step = 4; - break; - - case 4: - for (i=0; i<54; i++) - { - if (SFPPortAbsStatus[i]) /*present*/ - { - i2c_smbus_write_byte_data(&(pca9548_client[1]), 0, sfpPortData_78F[i].portMaskBitForPCA9548_1); - i2c_smbus_write_byte_data(&(pca9548_client[0]), 0, sfpPortData_78F[i].portMaskBitForPCA9548_2TO5); - if ((SFPPortDataValid[i] == 0)||(i>=48)) - { - if ((i>=48)&&(data->qsfpPortTxDisableDataUpdate[i] == 1)) - { - eepromDataByteWrite(&qsfpDataA0_client, SFF8436_TX_DISABLE_ADDR, &data->qsfpPortTxDisableData[i], sizeof(char)); - data->qsfpPortTxDisableDataUpdate[i] = 0; - } - ret = eepromDataBlockRead(&qsfpDataA0_client,qsfpPortData); - if (ret>=0) - { - memcpy(&(data->qsfpPortDataA0[i][0]), qsfpPortData, QSFP_DATA_SIZE); - SFPPortDataValid[i] = 1; - } - } - if (i<48) - { - ret = eepromDataBlockRead(&qsfpDataA2_client,qsfpPortData); - if (ret>=0) - memcpy(&(data->qsfpPortDataA2[i][0]), qsfpPortData, QSFP_DATA_SIZE); - ret = eepromDataWordRead(&SfpCopperData_client,SfpCopperPortData); - if (ret>=0) - memcpy(&(data->SfpCopperPortData[i][0]), SfpCopperPortData, SFP_COPPER_DATA_SIZE); - } - i2c_smbus_write_byte_data(&(pca9548_client[0]), 0, 0x00); - i2c_smbus_write_byte_data(&(pca9548_client[1]), 0, 0x00); - } - else - { - memset(&(data->qsfpPortDataA0[i][0]), 0, QSFP_DATA_SIZE); - memset(&(data->qsfpPortDataA2[i][0]), 0, QSFP_DATA_SIZE); - memset(&(data->SfpCopperPortData[i][0]), 0, SFP_COPPER_DATA_SIZE); - data->qsfpPortTxDisableDataUpdate[i] = 1; - SFPPortDataValid[i] = 0; - } - } - step = 0; - break; - - default: - step = 0; - break; - } - break; - - case ASTERION_WITH_BMC: - case ASTERION_WITHOUT_BMC: - switch (step) - { - case 0: - /* Turn on PCA9548#0 channel 0 on I2C-bus1 */ - ret = i2c_smbus_write_byte(client, (1 << PCA9548_CH00)); - if (ret < 0) - break; - - /* SFP Port 0~23, SFP Port - RXLOS */ - for (i = 0; i < 10; i++) - data->sfpPortAbsRxLosStatus[i] = i2c_smbus_read_byte_data(&(cpld_client_bus1), (0x20 + i)); - - data->sfpPortAbsRxLosStatus[10] = i2c_smbus_read_byte_data(&(cpld_client_bus1), 0x30); - data->sfpPortAbsRxLosStatus[11] = i2c_smbus_read_byte_data(&(cpld_client_bus1), 0x31); - - /* Turn on PCA9548#0 channel 1 on I2C-bus1 */ - ret = i2c_smbus_write_byte(client, (1 << PCA9548_CH01)); - if (ret < 0) - break; - - /* SFP Port 24~47, SFP Port - RXLOS */ - for (i = 0; i < 10; i++) - data->sfpPortAbsRxLosStatus[i + 12] = i2c_smbus_read_byte_data(&(cpld_client_bus1), 0x20 + i); - - data->sfpPortAbsRxLosStatus[22] = i2c_smbus_read_byte_data(&(cpld_client_bus1), 0x30); - data->sfpPortAbsRxLosStatus[23] = i2c_smbus_read_byte_data(&(cpld_client_bus1), 0x31); - - /* Turn on PCA9548#0 channel 2 on I2C-bus1 */ - ret = i2c_smbus_write_byte(client, (1 << PCA9548_CH02)); - if (ret < 0) - break; - - /* QSFP Port 48~63 */ - for (i = 0; i < 16; i++) - data->qsfpPortAbsStatusAst[i] = i2c_smbus_read_byte_data(&(cpld_client_bus1), (0x20 + i)); - - step = 1; - break; - - case 1: - /* Turn on PCA9548#0 channel 0 on I2C-bus1 */ - ret = i2c_smbus_write_byte(client, (1 << PCA9548_CH00)); - if (ret < 0) - break; - - for (i = 0; i < 12; i++) /* SFP 0,2,4 ... 22 */ - { - if ((data->sfpPortAbsRxLosStatus[i] & 0x02) == 0) /* present */ - { - ret = i2c_smbus_write_byte_data(&(cpld_client_bus1), CPLD_REG_MUX, (0x01 + (i * 2))); - - if (ret >= 0) - { - ret = eepromDataBlockRead(&qsfpDataA0_client,qsfpPortData); - - if (ret >= 0) - { - memcpy(&(data->qsfpPortDataA0[i * 2][0]), qsfpPortData, QSFP_DATA_SIZE); - data->sfpPortDataValidAst[i * 2] = 1; - } - ret = eepromDataBlockRead(&qsfpDataA2_client,qsfpPortData); - memcpy(&(data->qsfpPortDataA2[i * 2][0]), qsfpPortData, QSFP_DATA_SIZE); - ret = eepromDataWordRead(&SfpCopperData_client,SfpCopperPortData); - if (ret>=0) - memcpy(&(data->SfpCopperPortData[i * 2][0]), SfpCopperPortData, SFP_COPPER_DATA_SIZE); - } - i2c_smbus_write_byte_data(&(cpld_client_bus1), CPLD_REG_MUX, 0x00); - } - else - { - memset(&(data->qsfpPortDataA0[i * 2][0]), 0, QSFP_DATA_SIZE); - memset(&(data->qsfpPortDataA2[i * 2][0]), 0, QSFP_DATA_SIZE); - memset(&(data->SfpCopperPortData[i * 2][0]), 0, SFP_COPPER_DATA_SIZE); - data->sfpPortDataValidAst[i * 2] = 0; - } - } - - for (i = 0; i < 12; i++) /* SFP 1,3,5 ... 23 */ - { - if ((data->sfpPortAbsRxLosStatus[i] & 0x20) == 0) /* present */ - { - ret = i2c_smbus_write_byte_data(&(cpld_client_bus1), CPLD_REG_MUX, (0x02 + (i * 2))); - if (ret >= 0) - { - ret = eepromDataBlockRead(&qsfpDataA0_client,qsfpPortData); - if (ret >= 0) - { - memcpy(&(data->qsfpPortDataA0[1 + (i * 2)][0]), qsfpPortData, QSFP_DATA_SIZE); - data->sfpPortDataValidAst[1 + (i * 2)] = 1; - } - ret = eepromDataBlockRead(&qsfpDataA2_client,qsfpPortData); - if (ret >= 0) - memcpy(&(data->qsfpPortDataA2[1 + (i * 2)][0]), qsfpPortData, QSFP_DATA_SIZE); - ret = eepromDataWordRead(&SfpCopperData_client,SfpCopperPortData); - if (ret>=0) - memcpy(&(data->SfpCopperPortData[1 + (i * 2)][0]), SfpCopperPortData, SFP_COPPER_DATA_SIZE); - } - i2c_smbus_write_byte_data(&(cpld_client_bus1), CPLD_REG_MUX, 0x00); - } - else - { - memset(&(data->qsfpPortDataA0[1 + (i * 2)][0]), 0, QSFP_DATA_SIZE); - memset(&(data->qsfpPortDataA2[1 + (i * 2)][0]), 0, QSFP_DATA_SIZE); - memset(&(data->SfpCopperPortData[1 + (i * 2)][0]), 0, SFP_COPPER_DATA_SIZE); - data->sfpPortDataValidAst[1 + (i * 2)] = 0; - } - } - - step = 2; - break; - - case 2: - /* Turn on PCA9548#0 channel 1 on I2C-bus1 */ - ret = i2c_smbus_write_byte(client, (1 << PCA9548_CH01)); - if (ret < 0) - break; - - for (i = 0; i < 12; i++) /* SFP 24,26,28 ... 46 */ - { - if ((data->sfpPortAbsRxLosStatus[i + 12] & 0x02) == 0) /* present */ - { - ret = i2c_smbus_write_byte_data(&(cpld_client_bus1), CPLD_REG_MUX, (0x01 + (i * 2))); - if (ret >= 0) - { - ret = eepromDataBlockRead(&qsfpDataA0_client,qsfpPortData); - if (ret >= 0) - { - memcpy(&(data->qsfpPortDataA0[(i +12) * 2][0]), qsfpPortData, QSFP_DATA_SIZE); - data->sfpPortDataValidAst[(i + 12) * 2] = 1; - } - ret = eepromDataBlockRead(&qsfpDataA2_client,qsfpPortData); - if (ret >= 0) - memcpy(&(data->qsfpPortDataA2[(i + 12) * 2][0]), qsfpPortData, QSFP_DATA_SIZE); - ret = eepromDataWordRead(&SfpCopperData_client,SfpCopperPortData); - if (ret>=0) - memcpy(&(data->SfpCopperPortData[(i + 12) * 2][0]), SfpCopperPortData, SFP_COPPER_DATA_SIZE); - } - i2c_smbus_write_byte_data(&(cpld_client_bus1), CPLD_REG_MUX, 0x00); - } - else - { - memset(&(data->qsfpPortDataA0[(i + 12) * 2][0]), 0, QSFP_DATA_SIZE); - memset(&(data->qsfpPortDataA2[(i + 12) * 2][0]), 0, QSFP_DATA_SIZE); - memset(&(data->SfpCopperPortData[(i + 12) * 2][0]), 0, SFP_COPPER_DATA_SIZE); - data->sfpPortDataValidAst[(i + 12) * 2] = 0; - } - } - - for (i = 0; i < 12; i++) /* SFP 25,27,29 ... 47 */ - { - if ((data->sfpPortAbsRxLosStatus[i + 12] & 0x20) == 0) /* present */ - { - ret = i2c_smbus_write_byte_data(&(cpld_client_bus1), CPLD_REG_MUX, (0x02 + (i * 2))); - if (ret >= 0) - { - ret = eepromDataBlockRead(&qsfpDataA0_client,qsfpPortData); - if (ret >= 0) - { - memcpy(&(data->qsfpPortDataA0[1 + ((i + 12) * 2)][0]), qsfpPortData, QSFP_DATA_SIZE); - data->sfpPortDataValidAst[1 + ((i + 12) * 2)] = 1; - } - ret = eepromDataBlockRead(&qsfpDataA2_client,qsfpPortData); - if (ret >= 0) - memcpy(&(data->qsfpPortDataA2[1 + ((i + 12) * 2)][0]), qsfpPortData, QSFP_DATA_SIZE); - ret = eepromDataWordRead(&SfpCopperData_client,SfpCopperPortData); - if (ret>=0) - memcpy(&(data->SfpCopperPortData[1 + ((i + 12) * 2)][0]), SfpCopperPortData, SFP_COPPER_DATA_SIZE); - } - i2c_smbus_write_byte_data(&(cpld_client_bus1), CPLD_REG_MUX, 0x00); - } - else - { - memset(&(data->qsfpPortDataA0[1 + ((i + 12) * 2)][0]), 0, QSFP_DATA_SIZE); - memset(&(data->qsfpPortDataA2[1 + ((i + 12) * 2)][0]), 0, QSFP_DATA_SIZE); - memset(&(data->SfpCopperPortData[1 + ((i + 12) * 2)][0]), 0, SFP_COPPER_DATA_SIZE); - data->sfpPortDataValidAst[1 + ((i + 12) * 2)] = 0; - } - } - - step = 3; - break; - - case 3: - /* Turn on PCA9548#0 channel 2 on I2C-bus1 */ - ret = i2c_smbus_write_byte(client, (1 << PCA9548_CH02)); - if (ret < 0) - break; - - for (i = 0; i < 16; i++) /* QSFP 48~63 */ - { - if ((data->qsfpPortAbsStatusAst[i] & 0x02) == 0) /* present */ - { - ret = i2c_smbus_write_byte_data(&(cpld_client_bus1), CPLD_REG_MUX, (0x01 + i)); - if (ret >= 0) - { - if (data->qsfpPortTxDisableDataUpdate[48 + i] == 1) - { - eepromDataByteWrite(&qsfpDataA0_client, SFF8436_TX_DISABLE_ADDR, &data->qsfpPortTxDisableData[48 + i], sizeof(char)); - data->qsfpPortTxDisableDataUpdate[48 + i] = 0; - } - ret = eepromDataBlockRead(&qsfpDataA0_client,qsfpPortData); - if (ret >= 0) - { - memcpy(&(data->qsfpPortDataA0[48 + i][0]), qsfpPortData, QSFP_DATA_SIZE); - data->sfpPortDataValidAst[48 + i] = 1; - } - } - i2c_smbus_write_byte_data(&(cpld_client_bus1), CPLD_REG_MUX, 0x00); - } - else - { - memset(&(data->qsfpPortDataA0[48 + i][0]), 0, QSFP_DATA_SIZE); - data->sfpPortDataValidAst[48 + i] = 0; - data->qsfpPortTxDisableDataUpdate[48 + i] = 1; - } - } - - step = 4; - break; - - case 4: - /* Turn on PCA9548#0 channel 3 on I2C-bus1 : FAN Status */ - ret = i2c_smbus_write_byte(client, (1 << PCA9548_CH03)); - if (ret < 0) - break; - - value = 0xcccc; - fanErr = 0; - for (i = 0; i < W83795ADG_NUM8; i++) - { - if (FanErr[i] == 1) - fanErr |= (0x1 << i); - } - - if (fanErr & 0x03) - value |= 0x0001; - else - value |= 0x0002; - - if (fanErr & 0x0c) - value |= 0x0010; - else - value |= 0x0020; - - if (fanErr & 0x30) - value |= 0x0100; - else - value |= 0x0200; - - if (fanErr & 0xc0) - value |= 0x1000; - else - value |= 0x2000; - - ret = i2c_device_word_write(&(pca9535pwr_client[0]), PCA9553_COMMAND_BYTE_REG_OUTPUT_PORT_0, value); - if (ret < 0) - break; - - /* FAN Status */ - value = i2c_smbus_read_word_data(&(pca9535pwr_client[0]), PCA9553_COMMAND_BYTE_REG_INPUT_PORT_0); - data->fanAbs[0] = (value & 0x4444); - data->fanDir[0] = (value & 0x8888); - FanDir = data->fanDir[0]; - - fanErr2 = 0; - for (i = W83795ADG_NUM8; i < W83795ADG_FAN_COUNT; i++) - { - if (FanErr[i] == 1) - fanErr2 |= (0x1 << (i - 8)); - } - - if (fanErr2 & 0x03) - value2 = 0x0010; - else - value2 = 0x0020; - - ret = i2c_device_word_write(&(pca9535pwr_client[1]), PCA9553_COMMAND_BYTE_REG_OUTPUT_PORT_0, value2); - if (ret < 0) - break; - - /* FAN Status */ - value2 = i2c_smbus_read_word_data(&(pca9535pwr_client[1]), PCA9553_COMMAND_BYTE_REG_INPUT_PORT_0); - - data->fanAbs[1] = (value2 & 0x0040); - data->fanDir[1] = (value2 & 0x0080); - FanDir2 = data->fanDir[1]; - - /* Turn on PCA9548#0 channel 4 on I2C-bus1 : System LED */ - ret = i2c_smbus_write_byte(client, (1 << PCA9548_CH04)); - if (ret < 0) - break; - - data->frontLedStatus |= 0x00ff; - if (fanErr == 0 && fanErr2 == 0) - data->frontLedStatus &= (~0x0010); /* FAN_LED_G# */ - else - data->frontLedStatus &= (~0x0020); /* FAN_LED_Y# */ - - if ((platformPsuABS & 0x01) == 0x00) /* PSU1 Present */ - { - if (platformPsuPG & 0x04) /* PSU1_PG_LDC Power Goodasserted */ - data->frontLedStatus &= (~0x0001); /* PSU1_LED_G# */ - else - data->frontLedStatus &= (~0x0002); /* PSU1_LED_Y# */ - } - if ((platformPsuABS & 0x02) == 0x00) /* PSU2 Present */ - { - if (platformPsuPG & 0x08) /* PSU2_PG_LDC Power Goodasserted */ - data->frontLedStatus &= (~0x0004); /* PSU2_LED_G# */ - else - data->frontLedStatus &= (~0x0008); /* PSU2_LED_Y# */ - } - - switch (data->systemLedStatus) - { - default: - case 0: /* Booting */ - break; - - case 1: /* Critical*/ - data->frontLedStatus &= (~0x0080); /* SYS_LED_Y# */ - break; - - case 2: /* Normal */ - data->frontLedStatus &= (~0x0040); /* SYS_LED_G# */ - break; - } - - i2c_device_word_write(&(pca9535pwr_client[2]), PCA9553_COMMAND_BYTE_REG_OUTPUT_PORT_0, data->frontLedStatus); - - step = 0; - break; - - default: - step = 0; - break; - } - i2c_smbus_write_byte_data(&cpld_client, CPLD_REG_RESET_0x33, 0x00); - i2c_smbus_write_byte_data(&cpld_client, CPLD_REG_RESET_0x33, 0xff); - break; - - default: - break; - } - mutex_unlock(&data->lock); - - if (kthread_should_stop()) - break; - msleep_interruptible(200); - } /* End of while (!kthread_should_stop()) */ - - complete_all(&data->auto_update_stop); - return 0; -} - -static ssize_t show_chip_info(struct device *dev, struct device_attribute *devattr, char *buf) -{ - struct i2c_client *client = to_i2c_client(dev); - struct i2c_bus0_hardware_monitor_data *data = i2c_get_clientdata(client); - return sprintf(buf, "Vender ID = 0x%04X, Chip ID = 0x%04X, Device ID = 0x%04X\n", data->venderId, data->chipId, data->dviceId); -} - -static ssize_t show_board_build_revision(struct device *dev, struct device_attribute *devattr, char *buf) -{ - struct i2c_client *client = to_i2c_client(dev); - struct i2c_bus0_hardware_monitor_data *data = i2c_get_clientdata(client); - return sprintf(buf, "%d\n", data->buildRev); -} - -static ssize_t show_board_hardware_revision(struct device *dev, struct device_attribute *devattr, char *buf) -{ - struct i2c_client *client = to_i2c_client(dev); - struct i2c_bus0_hardware_monitor_data *data = i2c_get_clientdata(client); - return sprintf(buf, "%d\n", data->hwRev); -} - -static ssize_t show_board_model_id(struct device *dev, struct device_attribute *devattr, char *buf) -{ - struct i2c_client *client = to_i2c_client(dev); - struct i2c_bus0_hardware_monitor_data *data = i2c_get_clientdata(client); - return sprintf(buf, "%d\n", data->modelId); -} - -static ssize_t show_cpld_info(struct device *dev, struct device_attribute *devattr, char *buf) -{ - struct i2c_client *client = to_i2c_client(dev); - struct i2c_bus0_hardware_monitor_data *data = i2c_get_clientdata(client); - return sprintf(buf, "CPLD code Revision = 0x%02X, Release Bit = 0x%02X\n", data->cpldRev, data->cpldRel); -} - -static ssize_t show_psu_pg_sen(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 i2c_bus0_hardware_monitor_data *data = i2c_get_clientdata(client); - unsigned int value; - - mutex_lock(&data->lock); - value = data->psuPG; - mutex_unlock(&data->lock); - - switch(platformModelId) - { - case ASTERION_WITH_BMC: - case ASTERION_WITHOUT_BMC: - { - if (attr->index == 0) - value &= 0x04; - else - value &= 0x08; - } - break; - - default: - { - if (attr->index == 0) - value &= 0x08; - else - value &= 0x10; - } - break; - } - return sprintf(buf, "%d\n", value?1:0); -} - -static ssize_t show_psu_abs_sen(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 i2c_bus0_hardware_monitor_data *data = i2c_get_clientdata(client); - unsigned int value; - - mutex_lock(&data->lock); - value = data->psuABS; - mutex_unlock(&data->lock); - - if (attr->index == 0) - value &= 0x01; - else - value &= 0x02; - return sprintf(buf, "%d\n", value?0:1); -} - -static ssize_t show_fan_rpm(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 i2c_bus0_hardware_monitor_data *data = i2c_get_clientdata(client); - unsigned int fanSpeed = 0; - - if (attr->index < W83795ADG_FAN_COUNT) - fanSpeed = data->fanSpeed[attr->index]; - return sprintf(buf, "%d\n", fanSpeed); -} - -static ssize_t show_fan_duty(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 i2c_bus0_hardware_monitor_data *data = i2c_get_clientdata(client); - unsigned int fanDuty = 0; - - if (attr->index < W83795ADG_FAN_COUNT) - fanDuty = ((data->fanDuty*100)/0xff); - return sprintf(buf, "%d\n", fanDuty); -} - -static ssize_t show_remote_temp(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 i2c_bus0_hardware_monitor_data *data = i2c_get_clientdata(client); - - if (data->remoteTempIsPositive[attr->index]==1) - return sprintf(buf, "%d.%d\n", data->remoteTempInt[attr->index], data->remoteTempDecimal[attr->index]); - else - return sprintf(buf, "-%d.%d\n", data->remoteTempInt[attr->index], data->remoteTempDecimal[attr->index]); -} - -static ssize_t show_mac_temp(struct device *dev, struct device_attribute *devattr, char *buf) -{ - struct i2c_client *client = to_i2c_client(dev); - struct i2c_bus0_hardware_monitor_data *data = i2c_get_clientdata(client); - - return sprintf(buf, "%d\n", data->macTemp); -} - -static ssize_t set_mac_temp(struct device *dev, struct device_attribute *devattr, const char *buf, - size_t count) -{ - struct i2c_client *client = to_i2c_client(dev); - struct i2c_bus0_hardware_monitor_data *data = i2c_get_clientdata(client); - long temp; - - if (kstrtol(buf, 10, &temp)) - return -EINVAL; - - temp = clamp_val(temp, 0, 120); - - mutex_lock(&data->lock); - data->macTemp = temp; - mutex_unlock(&data->lock); - - return count; -} - -static ssize_t show_wd_refresh(struct device *dev, struct device_attribute *devattr, char *buf) -{ - struct i2c_client *client = to_i2c_client(dev); - struct i2c_bus0_hardware_monitor_data *data = i2c_get_clientdata(client); - - return sprintf(buf, "%d\n", data->wdRefreshControlFlag); -} - -static ssize_t set_wd_refresh(struct device *dev, struct device_attribute *devattr, const char *buf, - size_t count) -{ - struct i2c_client *client = to_i2c_client(dev); - struct i2c_bus0_hardware_monitor_data *data = i2c_get_clientdata(client); - long temp; - - if (kstrtol(buf, 10, &temp)) - return -EINVAL; - - temp = clamp_val(temp, 0, 1); - - mutex_lock(&data->lock); - data->wdRefreshControlFlag = temp; - mutex_unlock(&data->lock); - - return count; -} - -static ssize_t show_wd_refresh_control(struct device *dev, struct device_attribute *devattr, char *buf) -{ - struct i2c_client *client = to_i2c_client(dev); - struct i2c_bus0_hardware_monitor_data *data = i2c_get_clientdata(client); - - return sprintf(buf, "%d\n", data->wdRefreshControl); -} - -static ssize_t set_wd_refresh_control(struct device *dev, struct device_attribute *devattr, const char *buf, - size_t count) -{ - struct i2c_client *client = to_i2c_client(dev); - struct i2c_bus0_hardware_monitor_data *data = i2c_get_clientdata(client); - long temp; - - if (kstrtol(buf, 10, &temp)) - return -EINVAL; - - temp = clamp_val(temp, 0, 1); - - mutex_lock(&data->lock); - data->wdRefreshControl = temp; - mutex_unlock(&data->lock); - - return count; -} - -static ssize_t show_wd_refresh_time(struct device *dev, struct device_attribute *devattr, char *buf) -{ - struct i2c_client *client = to_i2c_client(dev); - struct i2c_bus0_hardware_monitor_data *data = i2c_get_clientdata(client); - - return sprintf(buf, "%d\n", data->wdRefreshTimeSelect); -} - -static ssize_t set_wd_refresh_time(struct device *dev, struct device_attribute *devattr, const char *buf, - size_t count) -{ - struct i2c_client *client = to_i2c_client(dev); - struct i2c_bus0_hardware_monitor_data *data = i2c_get_clientdata(client); - long temp; - - if (kstrtol(buf, 10, &temp)) - return -EINVAL; - - temp = clamp_val(temp, 0, 10); - - mutex_lock(&data->lock); - data->wdRefreshTimeSelect = temp; - data->wdRefreshTimeSelectFlag = 1; - mutex_unlock(&data->lock); - - return count; -} - -static ssize_t show_wd_timeout_occurrence(struct device *dev, struct device_attribute *devattr, char *buf) -{ - struct i2c_client *client = to_i2c_client(dev); - struct i2c_bus0_hardware_monitor_data *data = i2c_get_clientdata(client); - - return sprintf(buf, "%d\n", data->wdTimeoutSelect); -} - -static ssize_t set_wd_timeout_occurrence(struct device *dev, struct device_attribute *devattr, const char *buf, - size_t count) -{ - struct i2c_client *client = to_i2c_client(dev); - struct i2c_bus0_hardware_monitor_data *data = i2c_get_clientdata(client); - long temp; - - if (kstrtol(buf, 10, &temp)) - return -EINVAL; - - temp = clamp_val(temp, 0, 1); - - mutex_lock(&data->lock); - data->wdTimeoutSelect = temp; - data->wdTimeoutSelectFlag = 1; - mutex_unlock(&data->lock); - - return count; -} - -static ssize_t show_rov(struct device *dev, struct device_attribute *devattr, char *buf) -{ - struct i2c_client *client = to_i2c_client(dev); - struct i2c_bus0_hardware_monitor_data *data = i2c_get_clientdata(client); - - return sprintf(buf, "%d\n", data->rov); -} - -static ssize_t set_rov(struct device *dev, struct device_attribute *devattr, const char *buf, - size_t count) -{ - struct i2c_client *client = to_i2c_client(dev); - struct i2c_bus0_hardware_monitor_data *data = i2c_get_clientdata(client); - long rov; - - if (kstrtol(buf, 10, &rov)) - return -EINVAL; - - rov = clamp_val(rov, 0, 16); - - mutex_lock(&data->lock); - switch (data->modelId) - { - case HURACAN_WITH_BMC: - case HURACAN_WITHOUT_BMC: - case HURACAN_A_WITH_BMC: - case HURACAN_A_WITHOUT_BMC: - { - /* - - 4'b0000 = 1.2000V -> 0x47 - - 4'b0001 = 1.1750V -> 0x44 - - 4'b0010 = 1.1500V -> 0x42 - - 4'b0011 = 1.1250V -> 0x3f - - 4'b0100 = 1.1000V -> 0x3c - - 4'b0101 = 1.0750V -> 0x39 - - 4'b0110 = 1.0500V -> 0x37 - - 4'b0111 = 1.0250V -> 0x35 - - 4'b1000 = 1.0000V -> 0x33 - - 4'b1001 = 0.9750V -> 0x30 - - 4'b1010 = 0.9500V -> 0x2d - - 4'b1011 = 0.9250V -> 0x2b - - 4'b1100 = 0.9000V -> 0x28 - - 4'b1101 = 0.8750V -> 0x26 - - 4'b1110 = 0.8500V -> 0x23 - - 4'b1111 = 0.8250V -> 0x21 - */ - const unsigned short ROVtranslate[]= {0x47,0x44,0x42,0x3f,0x3c,0x39,0x37,0x35,0x33,0x30,0x2d,0x2b,0x28,0x26,0x23,0x21}; - - rov &= 0xf; - /* In "56960-DS111-RDS.pdf" page 58, the voltage range of BCM56960 for power supply is 0.95V to 1.025V. */ - if (rov<7) rov = 7; - - /* set rov to VOUT_COMMAND register */ - i2c_smbus_write_word_data(&mp2953agu_client, 0x21, ROVtranslate[rov]); - } - break; - - case SESTO_WITH_BMC: - case SESTO_WITHOUT_BMC: - case ASTERION_WITH_BMC: - case ASTERION_WITHOUT_BMC: - { - /* - - 4'b0000 = 1.2000V -> 0x47 - - 4'b0001 = 1.1750V -> 0x44 - - 4'b0010 = 1.1500V -> 0x42 - - 4'b0011 = 1.1250V -> 0x3e - - 4'b0100 = 1.1000V -> 0x3c - - 4'b0101 = 1.0750V -> 0x39 - - 4'b0110 = 1.0500V -> 0x37 - - 4'b0111 = 1.0250V -> 0x34 - - 4'b1000 = 1.0000V -> 0x32 - - 4'b1001 = 0.9750V -> 0x2f - - 4'b1010 = 0.9500V -> 0x2d - - 4'b1011 = 0.9250V -> 0x2b - - 4'b1100 = 0.9000V -> 0x28 - - 4'b1101 = 0.8750V -> 0x26 - - 4'b1110 = 0.8500V -> 0x23 - - 4'b1111 = 0.8250V -> 0x21 - */ - const unsigned short ROVtranslate[]= {0x47,0x44,0x42,0x3e,0x3c,0x39,0x37,0x34,0x32,0x2f,0x2d,0x2b,0x28,0x26,0x23,0x21}; - - rov &= 0xf; - /* In "56960-DS111-RDS.pdf" page 58, the voltage range of BCM56960 for power supply is 0.95V to 1.025V. */ - if (rov<7) rov = 7; - - /* set rov to VOUT_COMMAND register */ - i2c_smbus_write_word_data(&mp2953agu_client, 0x21, ROVtranslate[rov]); - } - break; - - case NCIIX_WITH_BMC: - case NCIIX_WITHOUT_BMC: - { - /* - - 3'b000 = 1.025V -> 0x9C - - 3'b001 = 1.025V -> 0x9C - - 3'b010 = 0.95V -> 0x8D - - 3'b011 = RESV - - 3'b100 = RESV - - 3'b101 = RESV - - 3'b110 = RESV - - 3'b111 = RESV - */ - char getValue = 0; - char loop1_flag = 0; - const char ROVtranslate[]= {CHL8325_VID_DEFAULT,CHL8325_VID0,CHL8325_VID1}; - - rov &= 0xf; - /* In "56750_56850-PR103-RDS.pdf" page 926, 3b011 ~ 3'b111 are reserved. */ - if (rov>2) rov = 0; - - /* Turn on PCA9548#0 channel 0 on I2C-bus0 */ - i2c_smbus_write_byte_data(&pca9548_client_bus0, 0, 0x01); - - /* Step 1. Disable LOOP1_VID */ - /* Get D0 register value */ - getValue = i2c_smbus_read_byte_data(&chl8325a_client, LOOP1_VID_OVERRIDE_ENABLE_REG); - /* Disable CHL8325A PWM controller Loop1 */ - loop1_flag = getValue & (~CHL8325_LOOP1_Enable); - i2c_smbus_write_byte_data(&chl8325a_client, LOOP1_VID_OVERRIDE_ENABLE_REG, loop1_flag); - - /* Step 2. Config CHL8325A PWM controller */ - i2c_smbus_write_byte_data(&chl8325a_client, LOOP1_OVERRIDE_VID_SETTING_REG, ROVtranslate[rov]); - - /* Step 3. Get D0 register value */ - getValue = i2c_smbus_read_byte_data(&chl8325a_client, LOOP1_VID_OVERRIDE_ENABLE_REG); - - /* Step 4. Config CHL8325A PWM controller Loop1 */ - loop1_flag = getValue | CHL8325_LOOP1_Enable; - i2c_smbus_write_byte_data(&chl8325a_client, LOOP1_VID_OVERRIDE_ENABLE_REG, loop1_flag); - - i2c_smbus_write_byte(&pca9548_client_bus0, 0x00); - } - break; - - default: - break; - } - data->rov = rov; - mutex_unlock(&data->lock); - - return count; -} - -static ssize_t show_voltage_sen(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 i2c_bus0_hardware_monitor_data *data = i2c_get_clientdata(client); - unsigned int MNTVSEN, MNTV; - unsigned int voltage; - - mutex_lock(&data->lock); - MNTVSEN = data->vSen[attr->index]; - MNTV = data->vSenLsb[attr->index]; - mutex_unlock(&data->lock); - - voltage = ((MNTVSEN << 2) + ((MNTV & 0xC0) >> 6)); - voltage *= ((2*VOL_MONITOR_UNIT)/VOL_MONITOR_UNIT); - - return sprintf(buf, "%d.%03d\n", (voltage/VOL_MONITOR_UNIT), (voltage%VOL_MONITOR_UNIT)); -} - -/* lm-sensors */ -static ssize_t show_temp_lm_sensors(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 i2c_bus0_hardware_monitor_data *data = i2c_get_clientdata(client); - - if (data->remoteTempIsPositive[attr->index]==1) - return sprintf(buf, "%u\n", data->remoteTempInt[attr->index] * 1000 + data->remoteTempDecimal[attr->index]); - else - return sprintf(buf, "-%u\n", data->remoteTempInt[attr->index] * 1000 + data->remoteTempDecimal[attr->index]); -} - -static ssize_t show_mac_temp_lm_sensors(struct device *dev, struct device_attribute *devattr, char *buf) -{ - struct i2c_client *client = to_i2c_client(dev); - struct i2c_bus0_hardware_monitor_data *data = i2c_get_clientdata(client); - - return sprintf(buf, "%u\n", data->macTemp * 1000); -} - -static ssize_t show_in_lm_sensors(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 i2c_bus0_hardware_monitor_data *data = i2c_get_clientdata(client); - unsigned int MNTVSEN, MNTV; - unsigned int voltage; - - mutex_lock(&data->lock); - MNTVSEN = data->vSen[attr->index]; - MNTV = data->vSenLsb[attr->index]; - mutex_unlock(&data->lock); - - voltage = ((MNTVSEN << 2) + ((MNTV & 0xC0) >> 6)); - voltage *= ((2*VOL_MONITOR_UNIT)/VOL_MONITOR_UNIT); - - return sprintf(buf, "%u\n", (voltage/VOL_MONITOR_UNIT) * 1000 + voltage%VOL_MONITOR_UNIT); -} - -static DEVICE_ATTR(mac_temp, S_IWUSR | S_IRUGO, show_mac_temp, set_mac_temp); -static DEVICE_ATTR(chip_info, S_IRUGO, show_chip_info, NULL); -static DEVICE_ATTR(board_build_rev, S_IRUGO, show_board_build_revision, NULL); -static DEVICE_ATTR(board_hardware_rev, S_IRUGO, show_board_hardware_revision, NULL); -static DEVICE_ATTR(board_model_id, S_IRUGO, show_board_model_id, NULL); -static DEVICE_ATTR(cpld_info, S_IRUGO, show_cpld_info, NULL); -static DEVICE_ATTR(wd_refresh, S_IWUSR | S_IRUGO, show_wd_refresh, set_wd_refresh); -static DEVICE_ATTR(wd_refresh_control, S_IWUSR | S_IRUGO, show_wd_refresh_control, set_wd_refresh_control); -static DEVICE_ATTR(wd_refresh_time, S_IWUSR | S_IRUGO, show_wd_refresh_time, set_wd_refresh_time); -static DEVICE_ATTR(wd_timeout_occurrence, S_IWUSR | S_IRUGO, show_wd_timeout_occurrence, set_wd_timeout_occurrence); -static DEVICE_ATTR(rov, S_IWUSR | S_IRUGO, show_rov, set_rov); - -static SENSOR_DEVICE_ATTR(psu1_pg, S_IRUGO, show_psu_pg_sen, NULL, 0); -static SENSOR_DEVICE_ATTR(psu2_pg, S_IRUGO, show_psu_pg_sen, NULL, 1); -static SENSOR_DEVICE_ATTR(psu1_abs, S_IRUGO, show_psu_abs_sen, NULL, 0); -static SENSOR_DEVICE_ATTR(psu2_abs, S_IRUGO, show_psu_abs_sen, NULL, 1); - -static SENSOR_DEVICE_ATTR(fan1_rpm, S_IRUGO, show_fan_rpm, NULL, 0); -static SENSOR_DEVICE_ATTR(fan2_rpm, S_IRUGO, show_fan_rpm, NULL, 1); -static SENSOR_DEVICE_ATTR(fan3_rpm, S_IRUGO, show_fan_rpm, NULL, 2); -static SENSOR_DEVICE_ATTR(fan4_rpm, S_IRUGO, show_fan_rpm, NULL, 3); -static SENSOR_DEVICE_ATTR(fan5_rpm, S_IRUGO, show_fan_rpm, NULL, 4); -static SENSOR_DEVICE_ATTR(fan6_rpm, S_IRUGO, show_fan_rpm, NULL, 5); -static SENSOR_DEVICE_ATTR(fan7_rpm, S_IRUGO, show_fan_rpm, NULL, 6); -static SENSOR_DEVICE_ATTR(fan8_rpm, S_IRUGO, show_fan_rpm, NULL, 7); -static SENSOR_DEVICE_ATTR(fan9_rpm, S_IRUGO, show_fan_rpm, NULL, 8); -static SENSOR_DEVICE_ATTR(fan10_rpm, S_IRUGO, show_fan_rpm, NULL, 9); - -static SENSOR_DEVICE_ATTR(fan1_duty, S_IRUGO, show_fan_duty, NULL, 0); -static SENSOR_DEVICE_ATTR(fan2_duty, S_IRUGO, show_fan_duty, NULL, 1); -static SENSOR_DEVICE_ATTR(fan3_duty, S_IRUGO, show_fan_duty, NULL, 2); -static SENSOR_DEVICE_ATTR(fan4_duty, S_IRUGO, show_fan_duty, NULL, 3); -static SENSOR_DEVICE_ATTR(fan5_duty, S_IRUGO, show_fan_duty, NULL, 4); -static SENSOR_DEVICE_ATTR(fan6_duty, S_IRUGO, show_fan_duty, NULL, 5); -static SENSOR_DEVICE_ATTR(fan7_duty, S_IRUGO, show_fan_duty, NULL, 6); -static SENSOR_DEVICE_ATTR(fan8_duty, S_IRUGO, show_fan_duty, NULL, 7); -static SENSOR_DEVICE_ATTR(fan9_duty, S_IRUGO, show_fan_duty, NULL, 8); -static SENSOR_DEVICE_ATTR(fan10_duty, S_IRUGO, show_fan_duty, NULL, 9); - -static SENSOR_DEVICE_ATTR(remote_temp1, S_IRUGO, show_remote_temp, NULL, 0); -static SENSOR_DEVICE_ATTR(remote_temp2, S_IRUGO, show_remote_temp, NULL, 1); -static SENSOR_DEVICE_ATTR(remote_temp3, S_IRUGO, show_remote_temp, NULL, 2); -static SENSOR_DEVICE_ATTR(remote_temp4, S_IRUGO, show_remote_temp, NULL, 3); - -static SENSOR_DEVICE_ATTR(vsen1, S_IRUGO, show_voltage_sen, NULL, 0); -static SENSOR_DEVICE_ATTR(vsen2, S_IRUGO, show_voltage_sen, NULL, 1); -static SENSOR_DEVICE_ATTR(vsen3, S_IRUGO, show_voltage_sen, NULL, 2); -static SENSOR_DEVICE_ATTR(vsen4, S_IRUGO, show_voltage_sen, NULL, 3); -static SENSOR_DEVICE_ATTR(vsen5, S_IRUGO, show_voltage_sen, NULL, 4); -static SENSOR_DEVICE_ATTR(vsen7, S_IRUGO, show_voltage_sen, NULL, 6); - -/* lm-sensors compatible feature/subfeature names */ -static SENSOR_DEVICE_ATTR(fan1_input, S_IRUGO, show_fan_rpm, NULL, 0); -static SENSOR_DEVICE_ATTR(fan2_input, S_IRUGO, show_fan_rpm, NULL, 1); -static SENSOR_DEVICE_ATTR(fan3_input, S_IRUGO, show_fan_rpm, NULL, 2); -static SENSOR_DEVICE_ATTR(fan4_input, S_IRUGO, show_fan_rpm, NULL, 3); -static SENSOR_DEVICE_ATTR(fan5_input, S_IRUGO, show_fan_rpm, NULL, 4); -static SENSOR_DEVICE_ATTR(fan6_input, S_IRUGO, show_fan_rpm, NULL, 5); -static SENSOR_DEVICE_ATTR(fan7_input, S_IRUGO, show_fan_rpm, NULL, 6); -static SENSOR_DEVICE_ATTR(fan8_input, S_IRUGO, show_fan_rpm, NULL, 7); -static SENSOR_DEVICE_ATTR(fan9_input, S_IRUGO, show_fan_rpm, NULL, 8); -static SENSOR_DEVICE_ATTR(fan10_input, S_IRUGO, show_fan_rpm, NULL, 9); - -static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, show_temp_lm_sensors, NULL, 0); -static SENSOR_DEVICE_ATTR(temp2_input, S_IRUGO, show_temp_lm_sensors, NULL, 1); -static SENSOR_DEVICE_ATTR(temp3_input, S_IRUGO, show_temp_lm_sensors, NULL, 2); -static SENSOR_DEVICE_ATTR(temp4_input, S_IRUGO, show_temp_lm_sensors, NULL, 3); -static SENSOR_DEVICE_ATTR(temp10_input, S_IRUGO, show_mac_temp_lm_sensors, NULL, 4); - -static SENSOR_DEVICE_ATTR(in1_input, S_IRUGO, show_in_lm_sensors, NULL, 0); -static SENSOR_DEVICE_ATTR(in2_input, S_IRUGO, show_in_lm_sensors, NULL, 1); -static SENSOR_DEVICE_ATTR(in3_input, S_IRUGO, show_in_lm_sensors, NULL, 2); -static SENSOR_DEVICE_ATTR(in4_input, S_IRUGO, show_in_lm_sensors, NULL, 3); -static SENSOR_DEVICE_ATTR(in5_input, S_IRUGO, show_in_lm_sensors, NULL, 4); -static SENSOR_DEVICE_ATTR(in7_input, S_IRUGO, show_in_lm_sensors, NULL, 6); - -/* fan min/max */ - -static ssize_t show_fan_minmax_lm_sensors(struct device *dev, struct device_attribute *devattr, char *buf) -{ - struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); - const ControlTable_t *cTable = get_platform_control_table(); - - return sprintf(buf, "%u\n", attr->index < 100 ? cTable->fanSpeed[0] : cTable->fanSpeed[2]); -} - -static SENSOR_DEVICE_ATTR(fan1_min, S_IRUGO, show_fan_minmax_lm_sensors, NULL, 0); -static SENSOR_DEVICE_ATTR(fan2_min, S_IRUGO, show_fan_minmax_lm_sensors, NULL, 1); -static SENSOR_DEVICE_ATTR(fan3_min, S_IRUGO, show_fan_minmax_lm_sensors, NULL, 2); -static SENSOR_DEVICE_ATTR(fan4_min, S_IRUGO, show_fan_minmax_lm_sensors, NULL, 3); -static SENSOR_DEVICE_ATTR(fan5_min, S_IRUGO, show_fan_minmax_lm_sensors, NULL, 4); -static SENSOR_DEVICE_ATTR(fan6_min, S_IRUGO, show_fan_minmax_lm_sensors, NULL, 5); -static SENSOR_DEVICE_ATTR(fan7_min, S_IRUGO, show_fan_minmax_lm_sensors, NULL, 6); -static SENSOR_DEVICE_ATTR(fan8_min, S_IRUGO, show_fan_minmax_lm_sensors, NULL, 7); -static SENSOR_DEVICE_ATTR(fan9_min, S_IRUGO, show_fan_minmax_lm_sensors, NULL, 8); -static SENSOR_DEVICE_ATTR(fan10_min, S_IRUGO, show_fan_minmax_lm_sensors, NULL, 9); - -static SENSOR_DEVICE_ATTR(fan1_max, S_IRUGO, show_fan_minmax_lm_sensors, NULL, 100); -static SENSOR_DEVICE_ATTR(fan2_max, S_IRUGO, show_fan_minmax_lm_sensors, NULL, 101); -static SENSOR_DEVICE_ATTR(fan3_max, S_IRUGO, show_fan_minmax_lm_sensors, NULL, 102); -static SENSOR_DEVICE_ATTR(fan4_max, S_IRUGO, show_fan_minmax_lm_sensors, NULL, 103); -static SENSOR_DEVICE_ATTR(fan5_max, S_IRUGO, show_fan_minmax_lm_sensors, NULL, 104); -static SENSOR_DEVICE_ATTR(fan6_max, S_IRUGO, show_fan_minmax_lm_sensors, NULL, 105); -static SENSOR_DEVICE_ATTR(fan7_max, S_IRUGO, show_fan_minmax_lm_sensors, NULL, 106); -static SENSOR_DEVICE_ATTR(fan8_max, S_IRUGO, show_fan_minmax_lm_sensors, NULL, 107); -static SENSOR_DEVICE_ATTR(fan9_max, S_IRUGO, show_fan_minmax_lm_sensors, NULL, 108); -static SENSOR_DEVICE_ATTR(fan10_max, S_IRUGO, show_fan_minmax_lm_sensors, NULL, 109); - -/* temp min/max */ - -static ssize_t show_temp_minmax_lm_sensors(struct device *dev, struct device_attribute *devattr, char *buf) -{ - struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); - const ControlTable_t *cTable = get_platform_control_table(); - unsigned int temp; - - if (attr->index < 100) - temp = cTable->tempLow2HighThreshold[0]; - else - temp = cTable->tempLow2HighThreshold[2]; - - return sprintf(buf, "%u\n", temp * 1000); -} - -static ssize_t show_mac_temp_minmax_lm_sensors(struct device *dev, struct device_attribute *devattr, char *buf) -{ - struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); - unsigned int temp; - - if (attr->index < 100) - temp = 0; - else - temp = 120; - - return sprintf(buf, "%u\n", temp * 1000); -} - -static SENSOR_DEVICE_ATTR(temp1_min, S_IRUGO, show_temp_minmax_lm_sensors, NULL, 0); -static SENSOR_DEVICE_ATTR(temp2_min, S_IRUGO, show_temp_minmax_lm_sensors, NULL, 1); -static SENSOR_DEVICE_ATTR(temp3_min, S_IRUGO, show_temp_minmax_lm_sensors, NULL, 2); -static SENSOR_DEVICE_ATTR(temp4_min, S_IRUGO, show_temp_minmax_lm_sensors, NULL, 3); -static SENSOR_DEVICE_ATTR(temp10_min, S_IRUGO, show_mac_temp_minmax_lm_sensors, NULL, 4); - -static SENSOR_DEVICE_ATTR(temp1_max, S_IRUGO, show_temp_minmax_lm_sensors, NULL, 100); -static SENSOR_DEVICE_ATTR(temp2_max, S_IRUGO, show_temp_minmax_lm_sensors, NULL, 101); -static SENSOR_DEVICE_ATTR(temp3_max, S_IRUGO, show_temp_minmax_lm_sensors, NULL, 102); -static SENSOR_DEVICE_ATTR(temp4_max, S_IRUGO, show_temp_minmax_lm_sensors, NULL, 103); -static SENSOR_DEVICE_ATTR(temp10_max, S_IRUGO, show_mac_temp_minmax_lm_sensors, NULL, 104); - -/* voltage min/max */ - -static ssize_t show_in_minmax_lm_sensors(struct device *dev, struct device_attribute *devattr, char *buf) -{ - struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); - const ControlTable_t *cTable = get_platform_control_table(); - unsigned int in; - - if (attr->index < 100) - in = cTable->inSet[attr->index][0]; - else - in = cTable->inSet[attr->index - 100][2]; - - return sprintf(buf, "%u\n", in); -} - -static SENSOR_DEVICE_ATTR(in1_min, S_IRUGO, show_in_minmax_lm_sensors, NULL, 0); -static SENSOR_DEVICE_ATTR(in2_min, S_IRUGO, show_in_minmax_lm_sensors, NULL, 1); -static SENSOR_DEVICE_ATTR(in3_min, S_IRUGO, show_in_minmax_lm_sensors, NULL, 2); -static SENSOR_DEVICE_ATTR(in4_min, S_IRUGO, show_in_minmax_lm_sensors, NULL, 3); -static SENSOR_DEVICE_ATTR(in5_min, S_IRUGO, show_in_minmax_lm_sensors, NULL, 4); -static SENSOR_DEVICE_ATTR(in7_min, S_IRUGO, show_in_minmax_lm_sensors, NULL, 6); - -static SENSOR_DEVICE_ATTR(in1_max, S_IRUGO, show_in_minmax_lm_sensors, NULL, 100); -static SENSOR_DEVICE_ATTR(in2_max, S_IRUGO, show_in_minmax_lm_sensors, NULL, 101); -static SENSOR_DEVICE_ATTR(in3_max, S_IRUGO, show_in_minmax_lm_sensors, NULL, 102); -static SENSOR_DEVICE_ATTR(in4_max, S_IRUGO, show_in_minmax_lm_sensors, NULL, 103); -static SENSOR_DEVICE_ATTR(in5_max, S_IRUGO, show_in_minmax_lm_sensors, NULL, 104); -static SENSOR_DEVICE_ATTR(in7_max, S_IRUGO, show_in_minmax_lm_sensors, NULL, 106); - -static struct attribute *i2c_bus0_hardware_monitor_attr[] = { - &dev_attr_mac_temp.attr, - &dev_attr_chip_info.attr, - &dev_attr_board_build_rev.attr, - &dev_attr_board_hardware_rev.attr, - &dev_attr_board_model_id.attr, - &dev_attr_cpld_info.attr, - &dev_attr_wd_refresh.attr, - &dev_attr_wd_refresh_control.attr, - &dev_attr_wd_refresh_time.attr, - &dev_attr_wd_timeout_occurrence.attr, - &dev_attr_rov.attr, - - &sensor_dev_attr_psu1_pg.dev_attr.attr, - &sensor_dev_attr_psu2_pg.dev_attr.attr, - &sensor_dev_attr_psu1_abs.dev_attr.attr, - &sensor_dev_attr_psu2_abs.dev_attr.attr, - - &sensor_dev_attr_fan1_rpm.dev_attr.attr, - &sensor_dev_attr_fan2_rpm.dev_attr.attr, - &sensor_dev_attr_fan3_rpm.dev_attr.attr, - &sensor_dev_attr_fan4_rpm.dev_attr.attr, - &sensor_dev_attr_fan5_rpm.dev_attr.attr, - &sensor_dev_attr_fan6_rpm.dev_attr.attr, - &sensor_dev_attr_fan7_rpm.dev_attr.attr, - &sensor_dev_attr_fan8_rpm.dev_attr.attr, - - &sensor_dev_attr_fan1_duty.dev_attr.attr, - &sensor_dev_attr_fan2_duty.dev_attr.attr, - &sensor_dev_attr_fan3_duty.dev_attr.attr, - &sensor_dev_attr_fan4_duty.dev_attr.attr, - &sensor_dev_attr_fan5_duty.dev_attr.attr, - &sensor_dev_attr_fan6_duty.dev_attr.attr, - &sensor_dev_attr_fan7_duty.dev_attr.attr, - &sensor_dev_attr_fan8_duty.dev_attr.attr, - - &sensor_dev_attr_remote_temp1.dev_attr.attr, - &sensor_dev_attr_remote_temp2.dev_attr.attr, - - &sensor_dev_attr_vsen1.dev_attr.attr, - &sensor_dev_attr_vsen2.dev_attr.attr, - &sensor_dev_attr_vsen3.dev_attr.attr, - &sensor_dev_attr_vsen4.dev_attr.attr, - - /* lm-sensors */ - &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_temp1_input.dev_attr.attr, - &sensor_dev_attr_temp2_input.dev_attr.attr, - &sensor_dev_attr_temp10_input.dev_attr.attr, - - &sensor_dev_attr_in1_input.dev_attr.attr, - &sensor_dev_attr_in2_input.dev_attr.attr, - &sensor_dev_attr_in3_input.dev_attr.attr, - &sensor_dev_attr_in4_input.dev_attr.attr, - - /* min */ - &sensor_dev_attr_fan1_min.dev_attr.attr, - &sensor_dev_attr_fan2_min.dev_attr.attr, - &sensor_dev_attr_fan3_min.dev_attr.attr, - &sensor_dev_attr_fan4_min.dev_attr.attr, - &sensor_dev_attr_fan5_min.dev_attr.attr, - &sensor_dev_attr_fan6_min.dev_attr.attr, - &sensor_dev_attr_fan7_min.dev_attr.attr, - &sensor_dev_attr_fan8_min.dev_attr.attr, - - &sensor_dev_attr_temp1_min.dev_attr.attr, - &sensor_dev_attr_temp2_min.dev_attr.attr, - &sensor_dev_attr_temp10_min.dev_attr.attr, - - &sensor_dev_attr_in1_min.dev_attr.attr, - &sensor_dev_attr_in2_min.dev_attr.attr, - &sensor_dev_attr_in3_min.dev_attr.attr, - &sensor_dev_attr_in4_min.dev_attr.attr, - - /* max */ - &sensor_dev_attr_fan1_max.dev_attr.attr, - &sensor_dev_attr_fan2_max.dev_attr.attr, - &sensor_dev_attr_fan3_max.dev_attr.attr, - &sensor_dev_attr_fan4_max.dev_attr.attr, - &sensor_dev_attr_fan5_max.dev_attr.attr, - &sensor_dev_attr_fan6_max.dev_attr.attr, - &sensor_dev_attr_fan7_max.dev_attr.attr, - &sensor_dev_attr_fan8_max.dev_attr.attr, - - &sensor_dev_attr_temp1_max.dev_attr.attr, - &sensor_dev_attr_temp2_max.dev_attr.attr, - &sensor_dev_attr_temp10_max.dev_attr.attr, - - &sensor_dev_attr_in1_max.dev_attr.attr, - &sensor_dev_attr_in2_max.dev_attr.attr, - &sensor_dev_attr_in3_max.dev_attr.attr, - &sensor_dev_attr_in4_max.dev_attr.attr, - - NULL -}; - -static struct attribute *i2c_bus0_hardware_monitor_attr_nc2x[] = { - &dev_attr_mac_temp.attr, - &dev_attr_chip_info.attr, - &dev_attr_board_build_rev.attr, - &dev_attr_board_hardware_rev.attr, - &dev_attr_board_model_id.attr, - &dev_attr_cpld_info.attr, - &dev_attr_wd_refresh.attr, - &dev_attr_wd_refresh_control.attr, - &dev_attr_wd_refresh_time.attr, - &dev_attr_wd_timeout_occurrence.attr, - &dev_attr_rov.attr, - - &sensor_dev_attr_psu1_pg.dev_attr.attr, - &sensor_dev_attr_psu2_pg.dev_attr.attr, - &sensor_dev_attr_psu1_abs.dev_attr.attr, - &sensor_dev_attr_psu2_abs.dev_attr.attr, - - &sensor_dev_attr_fan1_rpm.dev_attr.attr, - &sensor_dev_attr_fan2_rpm.dev_attr.attr, - &sensor_dev_attr_fan3_rpm.dev_attr.attr, - &sensor_dev_attr_fan4_rpm.dev_attr.attr, - &sensor_dev_attr_fan5_rpm.dev_attr.attr, - &sensor_dev_attr_fan6_rpm.dev_attr.attr, - &sensor_dev_attr_fan7_rpm.dev_attr.attr, - &sensor_dev_attr_fan8_rpm.dev_attr.attr, - - &sensor_dev_attr_fan1_duty.dev_attr.attr, - &sensor_dev_attr_fan2_duty.dev_attr.attr, - &sensor_dev_attr_fan3_duty.dev_attr.attr, - &sensor_dev_attr_fan4_duty.dev_attr.attr, - &sensor_dev_attr_fan5_duty.dev_attr.attr, - &sensor_dev_attr_fan6_duty.dev_attr.attr, - &sensor_dev_attr_fan7_duty.dev_attr.attr, - &sensor_dev_attr_fan8_duty.dev_attr.attr, - - &sensor_dev_attr_remote_temp1.dev_attr.attr, - &sensor_dev_attr_remote_temp2.dev_attr.attr, - - &sensor_dev_attr_vsen1.dev_attr.attr, - &sensor_dev_attr_vsen4.dev_attr.attr, - &sensor_dev_attr_vsen5.dev_attr.attr, - &sensor_dev_attr_vsen7.dev_attr.attr, - - /* lm-sensors */ - &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_temp1_input.dev_attr.attr, - &sensor_dev_attr_temp2_input.dev_attr.attr, - &sensor_dev_attr_temp10_input.dev_attr.attr, - - &sensor_dev_attr_in1_input.dev_attr.attr, - &sensor_dev_attr_in4_input.dev_attr.attr, - &sensor_dev_attr_in5_input.dev_attr.attr, - &sensor_dev_attr_in7_input.dev_attr.attr, - - /* min */ - &sensor_dev_attr_fan1_min.dev_attr.attr, - &sensor_dev_attr_fan2_min.dev_attr.attr, - &sensor_dev_attr_fan3_min.dev_attr.attr, - &sensor_dev_attr_fan4_min.dev_attr.attr, - &sensor_dev_attr_fan5_min.dev_attr.attr, - &sensor_dev_attr_fan6_min.dev_attr.attr, - &sensor_dev_attr_fan7_min.dev_attr.attr, - &sensor_dev_attr_fan8_min.dev_attr.attr, - - &sensor_dev_attr_temp1_min.dev_attr.attr, - &sensor_dev_attr_temp2_min.dev_attr.attr, - &sensor_dev_attr_temp10_min.dev_attr.attr, - - &sensor_dev_attr_in1_min.dev_attr.attr, - &sensor_dev_attr_in4_min.dev_attr.attr, - &sensor_dev_attr_in5_min.dev_attr.attr, - &sensor_dev_attr_in7_min.dev_attr.attr, - - /* max */ - &sensor_dev_attr_fan1_max.dev_attr.attr, - &sensor_dev_attr_fan2_max.dev_attr.attr, - &sensor_dev_attr_fan3_max.dev_attr.attr, - &sensor_dev_attr_fan4_max.dev_attr.attr, - &sensor_dev_attr_fan5_max.dev_attr.attr, - &sensor_dev_attr_fan6_max.dev_attr.attr, - &sensor_dev_attr_fan7_max.dev_attr.attr, - &sensor_dev_attr_fan8_max.dev_attr.attr, - - &sensor_dev_attr_temp1_max.dev_attr.attr, - &sensor_dev_attr_temp2_max.dev_attr.attr, - &sensor_dev_attr_temp10_max.dev_attr.attr, - - &sensor_dev_attr_in1_max.dev_attr.attr, - &sensor_dev_attr_in4_max.dev_attr.attr, - &sensor_dev_attr_in5_max.dev_attr.attr, - &sensor_dev_attr_in7_max.dev_attr.attr, - - NULL -}; - -static struct attribute *i2c_bus0_hardware_monitor_attr_asterion[] = { - &dev_attr_mac_temp.attr, - &dev_attr_chip_info.attr, - &dev_attr_board_build_rev.attr, - &dev_attr_board_hardware_rev.attr, - &dev_attr_board_model_id.attr, - &dev_attr_cpld_info.attr, - &dev_attr_wd_refresh.attr, - &dev_attr_wd_refresh_control.attr, - &dev_attr_wd_refresh_time.attr, - &dev_attr_wd_timeout_occurrence.attr, - &dev_attr_rov.attr, - - &sensor_dev_attr_psu1_pg.dev_attr.attr, - &sensor_dev_attr_psu2_pg.dev_attr.attr, - &sensor_dev_attr_psu1_abs.dev_attr.attr, - &sensor_dev_attr_psu2_abs.dev_attr.attr, - - &sensor_dev_attr_fan1_rpm.dev_attr.attr, - &sensor_dev_attr_fan2_rpm.dev_attr.attr, - &sensor_dev_attr_fan3_rpm.dev_attr.attr, - &sensor_dev_attr_fan4_rpm.dev_attr.attr, - &sensor_dev_attr_fan5_rpm.dev_attr.attr, - &sensor_dev_attr_fan6_rpm.dev_attr.attr, - &sensor_dev_attr_fan7_rpm.dev_attr.attr, - &sensor_dev_attr_fan8_rpm.dev_attr.attr, - &sensor_dev_attr_fan9_rpm.dev_attr.attr, - &sensor_dev_attr_fan10_rpm.dev_attr.attr, - - &sensor_dev_attr_fan1_duty.dev_attr.attr, - &sensor_dev_attr_fan2_duty.dev_attr.attr, - &sensor_dev_attr_fan3_duty.dev_attr.attr, - &sensor_dev_attr_fan4_duty.dev_attr.attr, - &sensor_dev_attr_fan5_duty.dev_attr.attr, - &sensor_dev_attr_fan6_duty.dev_attr.attr, - &sensor_dev_attr_fan7_duty.dev_attr.attr, - &sensor_dev_attr_fan8_duty.dev_attr.attr, - &sensor_dev_attr_fan9_duty.dev_attr.attr, - &sensor_dev_attr_fan10_duty.dev_attr.attr, - - &sensor_dev_attr_remote_temp1.dev_attr.attr, - &sensor_dev_attr_remote_temp2.dev_attr.attr, - &sensor_dev_attr_remote_temp3.dev_attr.attr, - &sensor_dev_attr_remote_temp4.dev_attr.attr, - - &sensor_dev_attr_vsen1.dev_attr.attr, - &sensor_dev_attr_vsen2.dev_attr.attr, - &sensor_dev_attr_vsen3.dev_attr.attr, - &sensor_dev_attr_vsen4.dev_attr.attr, - - /* lm-sensors */ - &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_fan9_input.dev_attr.attr, - &sensor_dev_attr_fan10_input.dev_attr.attr, - - &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_temp10_input.dev_attr.attr, - - &sensor_dev_attr_in1_input.dev_attr.attr, - &sensor_dev_attr_in2_input.dev_attr.attr, - &sensor_dev_attr_in3_input.dev_attr.attr, - &sensor_dev_attr_in4_input.dev_attr.attr, - - /* min */ - &sensor_dev_attr_fan1_min.dev_attr.attr, - &sensor_dev_attr_fan2_min.dev_attr.attr, - &sensor_dev_attr_fan3_min.dev_attr.attr, - &sensor_dev_attr_fan4_min.dev_attr.attr, - &sensor_dev_attr_fan5_min.dev_attr.attr, - &sensor_dev_attr_fan6_min.dev_attr.attr, - &sensor_dev_attr_fan7_min.dev_attr.attr, - &sensor_dev_attr_fan8_min.dev_attr.attr, - &sensor_dev_attr_fan9_min.dev_attr.attr, - &sensor_dev_attr_fan10_min.dev_attr.attr, - - &sensor_dev_attr_temp1_min.dev_attr.attr, - &sensor_dev_attr_temp2_min.dev_attr.attr, - &sensor_dev_attr_temp3_min.dev_attr.attr, - &sensor_dev_attr_temp4_min.dev_attr.attr, - &sensor_dev_attr_temp10_min.dev_attr.attr, - - &sensor_dev_attr_in1_min.dev_attr.attr, - &sensor_dev_attr_in2_min.dev_attr.attr, - &sensor_dev_attr_in3_min.dev_attr.attr, - &sensor_dev_attr_in4_min.dev_attr.attr, - - /* max */ - &sensor_dev_attr_fan1_max.dev_attr.attr, - &sensor_dev_attr_fan2_max.dev_attr.attr, - &sensor_dev_attr_fan3_max.dev_attr.attr, - &sensor_dev_attr_fan4_max.dev_attr.attr, - &sensor_dev_attr_fan5_max.dev_attr.attr, - &sensor_dev_attr_fan6_max.dev_attr.attr, - &sensor_dev_attr_fan7_max.dev_attr.attr, - &sensor_dev_attr_fan8_max.dev_attr.attr, - &sensor_dev_attr_fan9_max.dev_attr.attr, - &sensor_dev_attr_fan10_max.dev_attr.attr, - - &sensor_dev_attr_temp1_max.dev_attr.attr, - &sensor_dev_attr_temp2_max.dev_attr.attr, - &sensor_dev_attr_temp3_max.dev_attr.attr, - &sensor_dev_attr_temp4_max.dev_attr.attr, - &sensor_dev_attr_temp10_max.dev_attr.attr, - - &sensor_dev_attr_in1_max.dev_attr.attr, - &sensor_dev_attr_in2_max.dev_attr.attr, - &sensor_dev_attr_in3_max.dev_attr.attr, - &sensor_dev_attr_in4_max.dev_attr.attr, - - NULL -}; - - -static ssize_t show_port_abs(struct device *dev, struct device_attribute *devattr, char *buf) -{ - struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); - struct i2c_bus1_hardware_monitor_data *data = i2c_get_clientdata(&(pca9535pwr_client[0])); - struct i2c_bus1_hardware_monitor_data *dataAst = i2c_get_clientdata(&(cpld_client_bus1)); - int rc = 0; - - switch(platformModelId) - { - case NCIIX_WITH_BMC: - case NCIIX_WITHOUT_BMC: - rc = ((SFPPortAbsStatus[attr->index]==1)&&(SFPPortDataValid[attr->index]==1)); - break; - - case ASTERION_WITH_BMC: - case ASTERION_WITHOUT_BMC: - { - unsigned char qsfpPortAbsAst = 0, index = 0, bit = 0; - unsigned char sfpPortDataValidAst = 0; - - if (attr->index < 48) - { - index = (attr->index / 2); - bit = ((attr->index & 0x01) ? 5 : 1); - mutex_lock(&dataAst->lock); - qsfpPortAbsAst = dataAst->sfpPortAbsRxLosStatus[index]; - sfpPortDataValidAst = dataAst->sfpPortDataValidAst[attr->index]; - mutex_unlock(&dataAst->lock); - rc = ((PCA9553_TEST_BIT(qsfpPortAbsAst, bit) ? 0 : 1)&&sfpPortDataValidAst); - } - else - { - index = (attr->index % 48); - mutex_lock(&dataAst->lock); - qsfpPortAbsAst = dataAst->qsfpPortAbsStatusAst[index]; - sfpPortDataValidAst = dataAst->sfpPortDataValidAst[attr->index]; - mutex_unlock(&dataAst->lock); - rc = ((PCA9553_TEST_BIT(qsfpPortAbsAst, 1) ? 0 : 1)&&sfpPortDataValidAst); - } - } - break; - - default: - { - unsigned short qsfpPortAbs=0, index=0, bit=0; - unsigned short qsfpPortDataValid=0; - - index = (attr->index/16); - bit = (attr->index%16); - mutex_lock(&data->lock); - qsfpPortAbs = data->qsfpPortAbsStatus[index]; - qsfpPortDataValid = data->qsfpPortDataValid[index]; - mutex_unlock(&data->lock); - rc = ((PCA9553_TEST_BIT(qsfpPortAbs, bit)?0:1)&&(PCA9553_TEST_BIT(qsfpPortDataValid, bit))); - } - break; - } - - return sprintf(buf, "%d\n", rc); -} - -static ssize_t show_port_rxlos(struct device *dev, struct device_attribute *devattr, char *buf) -{ - struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); - struct i2c_bus1_hardware_monitor_data *data = i2c_get_clientdata(&(pca9535pwr_client[0])); - int rc = 0; - - switch(platformModelId) - { - case NCIIX_WITH_BMC: - case NCIIX_WITHOUT_BMC: - rc = (SFPPortRxLosStatus[attr->index]?0:1); - break; - - case SESTO_WITH_BMC: - case SESTO_WITHOUT_BMC: - { - unsigned short qsfpPortRxLos=0, index=0, bit=0; - - index = (attr->index/16); - bit = (attr->index%16); - mutex_lock(&data->lock); - qsfpPortRxLos = data->sfpPortRxLosStatus[index]; - mutex_unlock(&data->lock); - rc = (PCA9553_TEST_BIT(qsfpPortRxLos, bit)?1:0); - } - break; - - case ASTERION_WITH_BMC: - case ASTERION_WITHOUT_BMC: - { - unsigned char qsfpPortRxLos = 0, index = 0, bit = 0; - - index = (attr->index / 2); - bit = ((attr->index & 0x01) ? 4 : 0); - mutex_lock(&data->lock); - qsfpPortRxLos = data->sfpPortAbsRxLosStatus[index]; - mutex_unlock(&data->lock); - rc = (PCA9553_TEST_BIT(qsfpPortRxLos, bit) ? 1 : 0); - } - break; - - default: - break; - } - - return sprintf(buf, "%d\n", rc); -} - -static ssize_t show_port_data_a0(struct device *dev, struct device_attribute *devattr, char *buf) -{ - struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); - struct i2c_bus1_hardware_monitor_data *data = i2c_get_clientdata(&qsfpDataA0_client); - unsigned char qsfpPortData[QSFP_DATA_SIZE]; - ssize_t count = 0; - - memset(qsfpPortData, 0, QSFP_DATA_SIZE); - mutex_lock(&data->lock); - memcpy(qsfpPortData, &(data->qsfpPortDataA0[attr->index][0]), QSFP_DATA_SIZE); - mutex_unlock(&data->lock); - - count = QSFP_DATA_SIZE; - memcpy(buf, (char *)qsfpPortData, QSFP_DATA_SIZE); - - return count; -} - -static ssize_t show_port_data_a2(struct device *dev, struct device_attribute *devattr, char *buf) -{ - struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); - struct i2c_bus1_hardware_monitor_data *data = i2c_get_clientdata(&qsfpDataA2_client); - unsigned char qsfpPortData[QSFP_DATA_SIZE]; - ssize_t count = 0; - - memset(qsfpPortData, 0, QSFP_DATA_SIZE); - mutex_lock(&data->lock); - memcpy(qsfpPortData, &(data->qsfpPortDataA2[attr->index][0]), QSFP_DATA_SIZE); - mutex_unlock(&data->lock); - - count = QSFP_DATA_SIZE; - memcpy(buf, (char *)qsfpPortData, QSFP_DATA_SIZE); - - return count; -} - -static ssize_t show_port_sfp_copper(struct device *dev, struct device_attribute *devattr, char *buf) -{ - struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); - struct i2c_bus1_hardware_monitor_data *data = i2c_get_clientdata(&SfpCopperData_client); - unsigned char SfpCopperPortData[SFP_COPPER_DATA_SIZE]; - ssize_t count = 0; - - memset(SfpCopperPortData, 0, SFP_COPPER_DATA_SIZE); - mutex_lock(&data->lock); - memcpy(SfpCopperPortData, &(data->SfpCopperPortData[attr->index][0]), SFP_COPPER_DATA_SIZE); - mutex_unlock(&data->lock); - - count = SFP_COPPER_DATA_SIZE; - memcpy(buf, (char *)SfpCopperPortData, SFP_COPPER_DATA_SIZE); - - return count; -} - -static ssize_t show_fan_abs(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 i2c_bus1_hardware_monitor_data *data = i2c_get_clientdata(client); - unsigned int value = 0; - unsigned int index = 0; - - mutex_lock(&data->lock); - if (attr->index<4) - { - value = (unsigned int)data->fanAbs[0]; - index = attr->index; - } - else - { - value = (unsigned int)data->fanAbs[1]; - index = (attr->index-3); - } - mutex_unlock(&data->lock); - - value &= (0x0004<<(index*4)); - return sprintf(buf, "%d\n", value?0:1); -} - -static ssize_t show_fan_dir(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 i2c_bus1_hardware_monitor_data *data = i2c_get_clientdata(client); - unsigned int value = 0; - unsigned int index = 0; - - mutex_lock(&data->lock); - if (attr->index<4) - { - value = (unsigned int)data->fanDir[0]; - index = attr->index; - } - else - { - value = (unsigned int)data->fanDir[1]; - index = (attr->index-3); - } - mutex_unlock(&data->lock); - - value &= (0x0008<<(index*4)); - return sprintf(buf, "%d\n", value?0:1); -} - -static ssize_t show_eeprom(struct device *dev, struct device_attribute *devattr, char *buf) -{ - unsigned char eepromData[EEPROM_DATA_SIZE]; - ssize_t count = 0; - int ret = 0; - - memset(eepromData, 0, EEPROM_DATA_SIZE); - switch(platformModelId) - { - case HURACAN_WITH_BMC: - case HURACAN_WITHOUT_BMC: - case HURACAN_A_WITH_BMC: - case HURACAN_A_WITHOUT_BMC: - { - struct i2c_client *client = to_i2c_client(dev); - struct i2c_bus1_hardware_monitor_data *data = i2c_get_clientdata(client); - - mutex_lock(&data->lock); - /* Turn on PCA9548 channel 7 on I2C-bus1 */ - i2c_smbus_write_byte(client, 0x80); - i2c_smbus_write_byte_data(&eeprom_client, 0x00, 0x00); - ret = eepromDataRead(&eeprom_client, &(eepromData[0])); - i2c_smbus_write_byte(client, 0x00); - mutex_unlock(&data->lock); - } - break; - - case CABRERAIII_WITH_BMC: - case CABRERAIII_WITHOUT_BMC: - break; - - case SESTO_WITH_BMC: - case SESTO_WITHOUT_BMC: - { - struct i2c_client *client = to_i2c_client(dev); - struct i2c_bus1_hardware_monitor_data *data = i2c_get_clientdata(client); - - mutex_lock(&data->lock); - /* Turn on PCA9548#1 channel 7 on I2C-bus1 */ - i2c_smbus_write_byte(&(pca9548_client[1]), 0x80); - i2c_smbus_write_byte_data(&eeprom_client, 0x00, 0x00); - ret = eepromDataRead(&eeprom_client, &(eepromData[0])); - i2c_smbus_write_byte(&(pca9548_client[1]), 0x00); - mutex_unlock(&data->lock); - } - break; - - case NCIIX_WITH_BMC: - case NCIIX_WITHOUT_BMC: - { - if (platformHwRev == 0x03) /* PVT */ - { - struct i2c_client *client = to_i2c_client(dev); - struct i2c_bus1_hardware_monitor_data *data = i2c_get_clientdata(client); - - mutex_lock(&data->lock); - /* Turn on PCA9548#1 channel 2 on I2C-bus1 */ - i2c_smbus_write_byte(client, 0x04); - i2c_smbus_write_byte_data(&eeprom_client, 0x00, 0x00); - ret = eepromDataRead(&eeprom_client, &(eepromData[0])); - i2c_smbus_write_byte(client, 0x00); - mutex_unlock(&data->lock); - } - else - { - struct i2c_bus0_hardware_monitor_data *data = i2c_get_clientdata(&eeprom_client_bus0); - - mutex_lock(&data->lock); - i2c_smbus_write_byte_data(&eeprom_client_bus0, 0x00, 0x00); - ret = eepromDataRead(&eeprom_client_bus0, &(eepromData[0])); - mutex_unlock(&data->lock); - } - } - break; - - case ASTERION_WITH_BMC: - case ASTERION_WITHOUT_BMC: - { - struct i2c_client *client = to_i2c_client(dev); - struct i2c_bus1_hardware_monitor_data *data = i2c_get_clientdata(client); - - mutex_lock(&data->lock); - /* Turn on PCA9548 channel 5 on I2C-bus1 */ - i2c_smbus_write_byte(client, 0x20); - i2c_smbus_write_byte_data(&eeprom_client, 0x00, 0x00); - ret = eepromDataRead(&eeprom_client, &(eepromData[0])); - i2c_smbus_write_byte(client, 0x00); - mutex_unlock(&data->lock); - } - break; - - default: - break; - } - if (ret < 0) - memset(eepromData, 0, EEPROM_DATA_SIZE); - - count = EEPROM_DATA_SIZE; - memcpy(buf, (char *)eepromData, EEPROM_DATA_SIZE); - - return count; -} - -static ssize_t show_psu_eeprom(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 i2c_bus1_hardware_monitor_data *data = i2c_get_clientdata(client); - unsigned char eepromData[EEPROM_DATA_SIZE]; - ssize_t count = 0; - int ret = 0; - unsigned short index=0; - unsigned int psu_present = 0; - - index = (attr->index&0x1); - if (index&0x01) /* PSU 2 */ - { - if ((platformPsuABS&0x02)==0x00) /* PSU2 Present */ - psu_present = 1; - } - else /* PSU 1 */ - { - if ((platformPsuABS&0x01)==0x00) /* PSU1 Present */ - psu_present = 1; - } - memset(eepromData, 0, EEPROM_DATA_SIZE); - if (psu_present == 1) - { - switch(platformModelId) - { - case HURACAN_WITH_BMC: - case HURACAN_WITHOUT_BMC: - case ASTERION_WITH_BMC: - case ASTERION_WITHOUT_BMC: - case HURACAN_A_WITH_BMC: - case HURACAN_A_WITHOUT_BMC: - { - mutex_lock(&data->lock); - if (index) - /* Turn on PCA9548 channel 7 on I2C-bus1 */ - i2c_smbus_write_byte(client, 0x80); - else - /* Turn on PCA9548 channel 6 on I2C-bus1 */ - i2c_smbus_write_byte(client, 0x40); - ret = eepromDataBlockRead(&psu_eeprom_client, &(eepromData[0])); - i2c_smbus_write_byte(client, 0x00); - mutex_unlock(&data->lock); - } - break; - - case CABRERAIII_WITH_BMC: - case CABRERAIII_WITHOUT_BMC: - break; - - case SESTO_WITH_BMC: - case SESTO_WITHOUT_BMC: - { - mutex_lock(&data->lock); - if (index) - /* Turn on PCA9548#1 channel 7 on I2C-bus1 */ - i2c_smbus_write_byte(&(pca9548_client[1]), 0x80); - else - /* Turn on PCA9548#1 channel 6 on I2C-bus1 */ - i2c_smbus_write_byte(&(pca9548_client[1]), 0x40); - ret = eepromDataBlockRead(&psu_eeprom_client, &(eepromData[0])); - i2c_smbus_write_byte(&(pca9548_client[1]), 0x00); - mutex_unlock(&data->lock); - } - break; - - case NCIIX_WITH_BMC: - case NCIIX_WITHOUT_BMC: - { - /* - Because the write ability of EEPROM with 0xAx address on I2C bus 0 (I801 bus) is blocked by BIOS, - it does not support I2C block read, it supports byte read only. - The PSUs will be moved to I2C bus 1 (iSMT bus) in PVT rev2. - */ - if ((platformBuildRev > 0x01) && (platformHwRev == 0x03)) /* PVT rev2*/ - { - mutex_lock(&data->lock); - if (index) - i2c_smbus_write_byte(client, 0x20); /* Turn on PCA9548 channel 5 on I2C-bus1 */ - else - i2c_smbus_write_byte(client, 0x10); /* Turn on PCA9548 channel 4 on I2C-bus1 */ - ret = eepromDataBlockRead(&psu_eeprom_client, &(eepromData[0])); - i2c_smbus_write_byte(client, 0x00); - mutex_unlock(&data->lock); - } - else - { - struct i2c_bus0_hardware_monitor_data *data_bus0 = i2c_get_clientdata(&psu_eeprom_client_bus0); - - mutex_lock(&data_bus0->lock); - if (index) - i2c_smbus_write_byte(&pca9548_client_bus0, 0x04); /* Turn on PCA9548#0 channel 2 on I2C-bus0 */ - else - i2c_smbus_write_byte(&pca9548_client_bus0, 0x02); /* Turn on PCA9548#0 channel 1 on I2C-bus0 */ - ret = eepromDataByteRead(&psu_eeprom_client_bus0, &(eepromData[0])); - i2c_smbus_write_byte(&pca9548_client_bus0, 0x00); - mutex_unlock(&data_bus0->lock); - } - } - break; - - default: - break; - } - if (ret < 0) - memset(eepromData, 0, EEPROM_DATA_SIZE); - } - - count = EEPROM_DATA_SIZE; - memcpy(buf, (char *)eepromData, EEPROM_DATA_SIZE); - - return count; -} - -static ssize_t show_psu_vout(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 i2c_bus1_hardware_monitor_data *data = i2c_get_clientdata(client); - unsigned int index = 0; - unsigned int valueV = 0; - unsigned char valueN = 0; - ssize_t count = 0; - unsigned int temp = 0; - unsigned int psu_present = 0; - unsigned char valueE = 0; - unsigned short valueY = 0; - - index = (attr->index&0x1); - if (index&0x01) /* PSU 2 */ - { - if ((platformPsuABS&0x02)==0x00) /* PSU2 Present */ - psu_present = 1; - } - else /* PSU 1 */ - { - if ((platformPsuABS&0x01)==0x00) /* PSU1 Present */ - psu_present = 1; - } - if (psu_present == 1) - { - switch(platformModelId) - { - case HURACAN_WITH_BMC: - case HURACAN_WITHOUT_BMC: - case ASTERION_WITH_BMC: - case ASTERION_WITHOUT_BMC: - case HURACAN_A_WITH_BMC: - case HURACAN_A_WITHOUT_BMC: - { - mutex_lock(&data->lock); - if (index) - /* Turn on PCA9548 channel 7 on I2C-bus1 */ - i2c_smbus_write_byte(client, 0x80); - else - /* Turn on PCA9548 channel 6 on I2C-bus1 */ - i2c_smbus_write_byte(client, 0x40); - valueN = i2c_smbus_read_byte_data(&psu_mcu_client, 0x20); - valueV = (unsigned int)i2c_smbus_read_word_data(&psu_mcu_client, 0x8B); - i2c_smbus_write_byte(client, 0x00); - mutex_unlock(&data->lock); - } - break; - - case CABRERAIII_WITH_BMC: - case CABRERAIII_WITHOUT_BMC: - break; - - case SESTO_WITH_BMC: - case SESTO_WITHOUT_BMC: - { - mutex_lock(&data->lock); - if (index) - /* Turn on PCA9548#1 channel 7 on I2C-bus1 */ - i2c_smbus_write_byte(&(pca9548_client[1]), 0x80); - else - /* Turn on PCA9548#1 channel 6 on I2C-bus1 */ - i2c_smbus_write_byte(&(pca9548_client[1]), 0x40); - valueN = i2c_smbus_read_byte_data(&psu_mcu_client, 0x20); - valueV = (unsigned int)i2c_smbus_read_word_data(&psu_mcu_client, 0x8B); - i2c_smbus_write_byte(&(pca9548_client[1]), 0x00); - mutex_unlock(&data->lock); - } - break; - - case NCIIX_WITH_BMC: - case NCIIX_WITHOUT_BMC: - { - if ((platformBuildRev > 0x01) && (platformHwRev == 0x03)) /* PVT rev2*/ - { - mutex_lock(&data->lock); - if (index) - i2c_smbus_write_byte(client, 0x20); /* Turn on PCA9548 channel 5 on I2C-bus1 */ - else - i2c_smbus_write_byte(client, 0x10); /* Turn on PCA9548 channel 4 on I2C-bus1 */ - valueN = i2c_smbus_read_byte_data(&psu_mcu_client, 0x20); - valueV = (unsigned int)i2c_smbus_read_word_data(&psu_mcu_client, 0x8B); - i2c_smbus_write_byte(client, 0x00); - mutex_unlock(&data->lock); - } - else - { - struct i2c_bus0_hardware_monitor_data *data_bus0 = i2c_get_clientdata(&psu_eeprom_client_bus0); - - mutex_lock(&data_bus0->lock); - if (index) - i2c_smbus_write_byte(&pca9548_client_bus0, 0x04); /* Turn on PCA9548#0 channel 2 on I2C-bus0 */ - else - i2c_smbus_write_byte(&pca9548_client_bus0, 0x02); /* Turn on PCA9548#0 channel 1 on I2C-bus0 */ - valueN = i2c_smbus_read_byte_data(&psu_mcu_client_bus0, 0x20); - valueV = (unsigned int)i2c_smbus_read_word_data(&psu_mcu_client_bus0, 0x8B); - i2c_smbus_write_byte(&pca9548_client_bus0, 0x00); - mutex_unlock(&data_bus0->lock); - } - } - break; - - default: - break; - } - - if (valueN == 0xff) - { - valueY = (valueV & 0x07ff); - if ((valueV & 0x8000)&&(valueY)) - { - valueV = ((~valueV) >> 11); - valueE = valueV + 1; - temp = (unsigned int)(1 << valueE); - if (temp) - { - if (attr->index >= 100) - count = sprintf(buf, "%d\n", (valueY>>valueE)*1000 + ((valueY%temp)*1000)/temp); - else - count = sprintf(buf, "%d.%04d\n", valueY>>valueE, ((valueY%temp)*10000)/temp); - } - } - else - { - valueN = (((valueV) >> 11) & 0x0F); - temp = (valueY*(1<index >= 100) - temp *= 1000; - count = sprintf(buf, "%d\n", temp); - } - } - else - { - if (valueN & 0x10) - { - valueN = 0xF0 + (valueN & 0x0F); - valueN = (~valueN) +1; - temp = (unsigned int)(1<index >= 100) - count = sprintf(buf, "%d\n", valueV/temp*1000 + ((valueV%temp)*1000)/temp); - else - count = sprintf(buf, "%d.%04d\n", valueV/temp, ((valueV%temp)*10000)/temp); - } - } - else - { - temp = (valueV*(1<index >= 100) - temp *= 1000; - count = sprintf(buf, "%d\n", temp); - } - } - } - else - { - count = sprintf(buf, "%d\n", 0); - } - return count; -} - -static ssize_t show_psu_iout(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 i2c_bus1_hardware_monitor_data *data = i2c_get_clientdata(client); - unsigned short value = 0; - unsigned int index = 0; - unsigned int valueY = 0; - unsigned char valueN = 0; - ssize_t count = 0; - unsigned int temp = 0; - unsigned int psu_present = 0; - - index = (attr->index&0x1); - if (index&0x01) /* PSU 2 */ - { - if ((platformPsuABS&0x02)==0x00) /* PSU2 Present */ - psu_present = 1; - } - else /* PSU 1 */ - { - if ((platformPsuABS&0x01)==0x00) /* PSU1 Present */ - psu_present = 1; - } - if (psu_present == 1) - { - switch(platformModelId) - { - case HURACAN_WITH_BMC: - case HURACAN_WITHOUT_BMC: - case ASTERION_WITH_BMC: - case ASTERION_WITHOUT_BMC: - case HURACAN_A_WITH_BMC: - case HURACAN_A_WITHOUT_BMC: - { - mutex_lock(&data->lock); - if (index) - /* Turn on PCA9548 channel 7 on I2C-bus1 */ - i2c_smbus_write_byte(client, 0x80); - else - /* Turn on PCA9548 channel 6 on I2C-bus1 */ - i2c_smbus_write_byte(client, 0x40); - value = i2c_smbus_read_word_data(&psu_mcu_client, 0x8C); - i2c_smbus_write_byte(client, 0x00); - mutex_unlock(&data->lock); - } - break; - - case CABRERAIII_WITH_BMC: - case CABRERAIII_WITHOUT_BMC: - break; - - case SESTO_WITH_BMC: - case SESTO_WITHOUT_BMC: - { - mutex_lock(&data->lock); - if (index) - /* Turn on PCA9548#1 channel 7 on I2C-bus1 */ - i2c_smbus_write_byte(&(pca9548_client[1]), 0x80); - else - /* Turn on PCA9548#1 channel 6 on I2C-bus1 */ - i2c_smbus_write_byte(&(pca9548_client[1]), 0x40); - value = i2c_smbus_read_word_data(&psu_mcu_client, 0x8C); - i2c_smbus_write_byte(&(pca9548_client[1]), 0x00); - mutex_unlock(&data->lock); - } - break; - - case NCIIX_WITH_BMC: - case NCIIX_WITHOUT_BMC: - { - if ((platformBuildRev > 0x01) && (platformHwRev == 0x03)) /* PVT rev2*/ - { - mutex_lock(&data->lock); - if (index) - i2c_smbus_write_byte(client, 0x20); /* Turn on PCA9548 channel 5 on I2C-bus1 */ - else - i2c_smbus_write_byte(client, 0x10); /* Turn on PCA9548 channel 4 on I2C-bus1 */ - value = i2c_smbus_read_word_data(&psu_mcu_client, 0x8C); - i2c_smbus_write_byte(client, 0x00); - mutex_unlock(&data->lock); - } - else - { - struct i2c_bus0_hardware_monitor_data *data_bus0 = i2c_get_clientdata(&psu_eeprom_client_bus0); - - mutex_lock(&data_bus0->lock); - if (index) - i2c_smbus_write_byte(&pca9548_client_bus0, 0x04); /* Turn on PCA9548#0 channel 2 on I2C-bus0 */ - else - i2c_smbus_write_byte(&pca9548_client_bus0, 0x02); /* Turn on PCA9548#0 channel 1 on I2C-bus0 */ - value = i2c_smbus_read_word_data(&psu_mcu_client_bus0, 0x8C); - i2c_smbus_write_byte(&pca9548_client_bus0, 0x00); - mutex_unlock(&data_bus0->lock); - } - } - break; - - default: - break; - } - valueY = (value & 0x07FF); - if ((value & 0x8000)&&(valueY)) - { - valueN = 0xF0 + (((value) >> 11) & 0x0F); - valueN = (~valueN) +1; - temp = (unsigned int)(1<index >= 100) - count = sprintf(buf, "%d\n", valueY/temp*1000 + ((valueY%temp)*1000)/temp); - else - count = sprintf(buf, "%d.%04d\n", valueY/temp, ((valueY%temp)*10000)/temp); - } - } - else - { - valueN = (((value) >> 11) & 0x0F); - temp = (valueY*(1<index >= 100) - temp *= 1000; - count = sprintf(buf, "%d\n", temp); - } - } - else - { - count = sprintf(buf, "%d\n", 0); - } - return count; -} - -static ssize_t show_psu_temp_1(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 i2c_bus1_hardware_monitor_data *data = i2c_get_clientdata(client); - unsigned short value = 0; - unsigned int index = 0; - unsigned int valueY = 0; - unsigned char valueN = 0; - ssize_t count = 0; - unsigned int temp = 0; - unsigned int psu_present = 0; - - index = (attr->index&0x1); - if (index&0x01) /* PSU 2 */ - { - if ((platformPsuABS&0x02)==0x00) /* PSU2 Present */ - psu_present = 1; - } - else /* PSU 1 */ - { - if ((platformPsuABS&0x01)==0x00) /* PSU1 Present */ - psu_present = 1; - } - if (psu_present == 1) - { - switch(platformModelId) - { - case HURACAN_WITH_BMC: - case HURACAN_WITHOUT_BMC: - case ASTERION_WITH_BMC: - case ASTERION_WITHOUT_BMC: - case HURACAN_A_WITH_BMC: - case HURACAN_A_WITHOUT_BMC: - { - mutex_lock(&data->lock); - if (index) - /* Turn on PCA9548 channel 7 on I2C-bus1 */ - i2c_smbus_write_byte(client, 0x80); - else - /* Turn on PCA9548 channel 6 on I2C-bus1 */ - i2c_smbus_write_byte(client, 0x40); - value = i2c_smbus_read_word_data(&psu_mcu_client, 0x8D); - i2c_smbus_write_byte(client, 0x00); - mutex_unlock(&data->lock); - } - break; - - case CABRERAIII_WITH_BMC: - case CABRERAIII_WITHOUT_BMC: - break; - - case SESTO_WITH_BMC: - case SESTO_WITHOUT_BMC: - { - mutex_lock(&data->lock); - if (index) - /* Turn on PCA9548#1 channel 7 on I2C-bus1 */ - i2c_smbus_write_byte(&(pca9548_client[1]), 0x80); - else - /* Turn on PCA9548#1 channel 6 on I2C-bus1 */ - i2c_smbus_write_byte(&(pca9548_client[1]), 0x40); - value = i2c_smbus_read_word_data(&psu_mcu_client, 0x8D); - i2c_smbus_write_byte(&(pca9548_client[1]), 0x00); - mutex_unlock(&data->lock); - } - break; - - case NCIIX_WITH_BMC: - case NCIIX_WITHOUT_BMC: - { - if ((platformBuildRev > 0x01) && (platformHwRev == 0x03)) /* PVT rev2*/ - { - mutex_lock(&data->lock); - if (index) - i2c_smbus_write_byte(client, 0x20); /* Turn on PCA9548 channel 5 on I2C-bus1 */ - else - i2c_smbus_write_byte(client, 0x10); /* Turn on PCA9548 channel 4 on I2C-bus1 */ - value = i2c_smbus_read_word_data(&psu_mcu_client, 0x8D); - i2c_smbus_write_byte(client, 0x00); - mutex_unlock(&data->lock); - } - else - { - struct i2c_bus0_hardware_monitor_data *data_bus0 = i2c_get_clientdata(&psu_eeprom_client_bus0); - - mutex_lock(&data_bus0->lock); - if (index) - i2c_smbus_write_byte(&pca9548_client_bus0, 0x04); /* Turn on PCA9548#0 channel 2 on I2C-bus0 */ - else - i2c_smbus_write_byte(&pca9548_client_bus0, 0x02); /* Turn on PCA9548#0 channel 1 on I2C-bus0 */ - value = i2c_smbus_read_word_data(&psu_mcu_client_bus0, 0x8D); - i2c_smbus_write_byte(&pca9548_client_bus0, 0x00); - mutex_unlock(&data_bus0->lock); - } - } - break; - - default: - break; - } - valueY = (value & 0x07FF); - if ((value & 0x8000)&&(valueY)) - { - valueN = 0xF0 + (((value) >> 11) & 0x0F); - valueN = (~valueN) +1; - temp = (unsigned int)(1<index >= 100) - count = sprintf(buf, "%d\n", valueY/temp*1000 + ((valueY%temp)*1000)/temp); - else - count = sprintf(buf, "%d.%04d\n", valueY/temp, ((valueY%temp)*10000)/temp); - } - } - else - { - valueN = (((value) >> 11) & 0x0F); - temp = (valueY*(1<index >= 100) - temp *= 1000; - count = sprintf(buf, "%d\n", temp); - } - } - else - { - count = sprintf(buf, "%d\n", 0); - } - return count; -} - -static ssize_t show_psu_temp_2(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 i2c_bus1_hardware_monitor_data *data = i2c_get_clientdata(client); - unsigned short value = 0; - unsigned int index = 0; - unsigned int valueY = 0; - unsigned char valueN = 0; - ssize_t count = 0; - unsigned int temp = 0; - unsigned int psu_present = 0; - - index = (attr->index&0x1); - if (index&0x01) /* PSU 2 */ - { - if ((platformPsuABS&0x02)==0x00) /* PSU2 Present */ - psu_present = 1; - } - else /* PSU 1 */ - { - if ((platformPsuABS&0x01)==0x00) /* PSU1 Present */ - psu_present = 1; - } - if (psu_present == 1) - { - switch(platformModelId) - { - case HURACAN_WITH_BMC: - case HURACAN_WITHOUT_BMC: - case HURACAN_A_WITH_BMC: - case HURACAN_A_WITHOUT_BMC: - { - mutex_lock(&data->lock); - if (index) - /* Turn on PCA9548 channel 7 on I2C-bus1 */ - i2c_smbus_write_byte(client, 0x80); - else - /* Turn on PCA9548 channel 6 on I2C-bus1 */ - i2c_smbus_write_byte(client, 0x40); - value = i2c_smbus_read_word_data(&psu_mcu_client, 0x8E); - i2c_smbus_write_byte(client, 0x00); - mutex_unlock(&data->lock); - } - break; - - case CABRERAIII_WITH_BMC: - case CABRERAIII_WITHOUT_BMC: - break; - - case SESTO_WITH_BMC: - case SESTO_WITHOUT_BMC: - { - mutex_lock(&data->lock); - if (index) - /* Turn on PCA9548#1 channel 7 on I2C-bus1 */ - i2c_smbus_write_byte(&(pca9548_client[1]), 0x80); - else - /* Turn on PCA9548#1 channel 6 on I2C-bus1 */ - i2c_smbus_write_byte(&(pca9548_client[1]), 0x40); - value = i2c_smbus_read_word_data(&psu_mcu_client, 0x8E); - i2c_smbus_write_byte(&(pca9548_client[1]), 0x00); - mutex_unlock(&data->lock); - } - break; - - case NCIIX_WITH_BMC: - case NCIIX_WITHOUT_BMC: - { - if ((platformBuildRev > 0x01) && (platformHwRev == 0x03)) /* PVT rev2*/ - { - mutex_lock(&data->lock); - if (index) - i2c_smbus_write_byte(client, 0x20); /* Turn on PCA9548 channel 5 on I2C-bus1 */ - else - i2c_smbus_write_byte(client, 0x10); /* Turn on PCA9548 channel 4 on I2C-bus1 */ - value = i2c_smbus_read_word_data(&psu_mcu_client, 0x8E); - i2c_smbus_write_byte(client, 0x00); - mutex_unlock(&data->lock); - } - else - { - struct i2c_bus0_hardware_monitor_data *data_bus0 = i2c_get_clientdata(&psu_eeprom_client_bus0); - - mutex_lock(&data_bus0->lock); - if (index) - i2c_smbus_write_byte(&pca9548_client_bus0, 0x04); /* Turn on PCA9548#0 channel 2 on I2C-bus0 */ - else - i2c_smbus_write_byte(&pca9548_client_bus0, 0x02); /* Turn on PCA9548#0 channel 1 on I2C-bus0 */ - value = i2c_smbus_read_word_data(&psu_mcu_client_bus0, 0x8E); - i2c_smbus_write_byte(&pca9548_client_bus0, 0x00); - mutex_unlock(&data_bus0->lock); - } - } - break; - - case ASTERION_WITH_BMC: - case ASTERION_WITHOUT_BMC: - break; - - default: - break; - } - valueY = (value & 0x07FF); - if ((value & 0x8000)&&(valueY)) - { - valueN = 0xF0 + (((value) >> 11) & 0x0F); - valueN = (~valueN) +1; - temp = (unsigned int)(1<index >= 100) - count = sprintf(buf, "%d\n", valueY/temp*1000 + ((valueY%temp)*1000)/temp); - else - count = sprintf(buf, "%d.%04d\n", valueY/temp, ((valueY%temp)*10000)/temp); - } - } - else - { - valueN = (((value) >> 11) & 0x0F); - temp = (valueY*(1<index >= 100) - temp *= 1000; - count = sprintf(buf, "%d\n", temp); - } - } - else - { - count = sprintf(buf, "%d\n", 0); - } - return count; -} - -static ssize_t show_psu_fan_speed(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 i2c_bus1_hardware_monitor_data *data = i2c_get_clientdata(client); - unsigned short value = 0; - unsigned int index = 0; - unsigned int temp = 0; - unsigned int psu_present = 0; - - index = (attr->index&0x1); - if (index&0x01) /* PSU 2 */ - { - if ((platformPsuABS&0x02)==0x00) /* PSU2 Present */ - psu_present = 1; - } - else /* PSU 1 */ - { - if ((platformPsuABS&0x01)==0x00) /* PSU1 Present */ - psu_present = 1; - } - if (psu_present == 1) - { - switch(platformModelId) - { - case HURACAN_WITH_BMC: - case HURACAN_WITHOUT_BMC: - case ASTERION_WITH_BMC: - case ASTERION_WITHOUT_BMC: - case HURACAN_A_WITH_BMC: - case HURACAN_A_WITHOUT_BMC: - { - mutex_lock(&data->lock); - if (index) - /* Turn on PCA9548 channel 7 on I2C-bus1 */ - i2c_smbus_write_byte(client, 0x80); - else - /* Turn on PCA9548 channel 6 on I2C-bus1 */ - i2c_smbus_write_byte(client, 0x40); - value = i2c_smbus_read_word_data(&psu_mcu_client, 0x90); - i2c_smbus_write_byte(client, 0x00); - mutex_unlock(&data->lock); - } - break; - - case CABRERAIII_WITH_BMC: - case CABRERAIII_WITHOUT_BMC: - break; - - case SESTO_WITH_BMC: - case SESTO_WITHOUT_BMC: - { - mutex_lock(&data->lock); - if (index) - /* Turn on PCA9548#1 channel 7 on I2C-bus1 */ - i2c_smbus_write_byte(&(pca9548_client[1]), 0x80); - else - /* Turn on PCA9548#1 channel 6 on I2C-bus1 */ - i2c_smbus_write_byte(&(pca9548_client[1]), 0x40); - value = i2c_smbus_read_word_data(&psu_mcu_client, 0x90); - i2c_smbus_write_byte(&(pca9548_client[1]), 0x00); - mutex_unlock(&data->lock); - } - break; - - case NCIIX_WITH_BMC: - case NCIIX_WITHOUT_BMC: - { - if ((platformBuildRev > 0x01) && (platformHwRev == 0x03)) /* PVT rev2*/ - { - mutex_lock(&data->lock); - if (index) - i2c_smbus_write_byte(client, 0x20); /* Turn on PCA9548 channel 5 on I2C-bus1 */ - else - i2c_smbus_write_byte(client, 0x10); /* Turn on PCA9548 channel 4 on I2C-bus1 */ - value = i2c_smbus_read_word_data(&psu_mcu_client, 0x90); - i2c_smbus_write_byte(client, 0x00); - mutex_unlock(&data->lock); - } - else - { - struct i2c_bus0_hardware_monitor_data *data_bus0 = i2c_get_clientdata(&psu_eeprom_client_bus0); - - mutex_lock(&data_bus0->lock); - if (index) - i2c_smbus_write_byte(&pca9548_client_bus0, 0x04); /* Turn on PCA9548#0 channel 2 on I2C-bus0 */ - else - i2c_smbus_write_byte(&pca9548_client_bus0, 0x02); /* Turn on PCA9548#0 channel 1 on I2C-bus0 */ - value = i2c_smbus_read_word_data(&psu_mcu_client_bus0, 0x90); - i2c_smbus_write_byte(&pca9548_client_bus0, 0x00); - mutex_unlock(&data_bus0->lock); - } - } - break; - - default: - break; - } - temp = (unsigned int)value; - temp = (temp & 0x07FF) * (1 << ((temp >> 11) & 0x1F)); - } - return sprintf(buf, "%d\n", temp); -} - -static ssize_t show_psu_pout(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 i2c_bus1_hardware_monitor_data *data = i2c_get_clientdata(client); - unsigned short value = 0; - unsigned int index = 0; - unsigned int valueY = 0; - unsigned char valueN = 0; - ssize_t count = 0; - unsigned int temp = 0; - unsigned int psu_present = 0; - - index = (attr->index&0x1); - if (index&0x01) /* PSU 2 */ - { - if ((platformPsuABS&0x02)==0x00) /* PSU2 Present */ - psu_present = 1; - } - else /* PSU 1 */ - { - if ((platformPsuABS&0x01)==0x00) /* PSU1 Present */ - psu_present = 1; - } - if (psu_present == 1) - { - switch(platformModelId) - { - case HURACAN_WITH_BMC: - case HURACAN_WITHOUT_BMC: - case ASTERION_WITH_BMC: - case ASTERION_WITHOUT_BMC: - case HURACAN_A_WITH_BMC: - case HURACAN_A_WITHOUT_BMC: - { - mutex_lock(&data->lock); - if (index) - /* Turn on PCA9548 channel 7 on I2C-bus1 */ - i2c_smbus_write_byte(client, 0x80); - else - /* Turn on PCA9548 channel 6 on I2C-bus1 */ - i2c_smbus_write_byte(client, 0x40); - value = i2c_smbus_read_word_data(&psu_mcu_client, 0x96); - i2c_smbus_write_byte(client, 0x00); - mutex_unlock(&data->lock); - } - break; - - case CABRERAIII_WITH_BMC: - case CABRERAIII_WITHOUT_BMC: - break; - - case SESTO_WITH_BMC: - case SESTO_WITHOUT_BMC: - { - mutex_lock(&data->lock); - if (index) - /* Turn on PCA9548#1 channel 7 on I2C-bus1 */ - i2c_smbus_write_byte(&(pca9548_client[1]), 0x80); - else - /* Turn on PCA9548#1 channel 6 on I2C-bus1 */ - i2c_smbus_write_byte(&(pca9548_client[1]), 0x40); - value = i2c_smbus_read_word_data(&psu_mcu_client, 0x96); - i2c_smbus_write_byte(&(pca9548_client[1]), 0x00); - mutex_unlock(&data->lock); - } - break; - - case NCIIX_WITH_BMC: - case NCIIX_WITHOUT_BMC: - { - if ((platformBuildRev > 0x01) && (platformHwRev == 0x03)) /* PVT rev2*/ - { - mutex_lock(&data->lock); - if (index) - i2c_smbus_write_byte(client, 0x20); /* Turn on PCA9548 channel 5 on I2C-bus1 */ - else - i2c_smbus_write_byte(client, 0x10); /* Turn on PCA9548 channel 4 on I2C-bus1 */ - value = i2c_smbus_read_word_data(&psu_mcu_client, 0x96); - i2c_smbus_write_byte(client, 0x00); - mutex_unlock(&data->lock); - } - else - { - struct i2c_bus0_hardware_monitor_data *data_bus0 = i2c_get_clientdata(&psu_eeprom_client_bus0); - - mutex_lock(&data_bus0->lock); - if (index) - i2c_smbus_write_byte(&pca9548_client_bus0, 0x04); /* Turn on PCA9548#0 channel 2 on I2C-bus0 */ - else - i2c_smbus_write_byte(&pca9548_client_bus0, 0x02); /* Turn on PCA9548#0 channel 1 on I2C-bus0 */ - value = i2c_smbus_read_word_data(&psu_mcu_client_bus0, 0x96); - i2c_smbus_write_byte(&pca9548_client_bus0, 0x00); - mutex_unlock(&data_bus0->lock); - } - } - break; - - default: - break; - } - valueY = (value & 0x07FF); - if ((value & 0x8000)&&(valueY)) - { - valueN = 0xF0 + (((value) >> 11) & 0x0F); - valueN = (~valueN) +1; - temp = (unsigned int)(1<index >= 100) - count = sprintf(buf, "%d\n", valueY/temp*1000000 + ((valueY%temp)*1000000)/temp); - else - count = sprintf(buf, "%d.%04d\n", valueY/temp, ((valueY%temp)*10000)/temp); - } - } - else - { - valueN = (((value) >> 11) & 0x0F); - temp = (valueY*(1<index >= 100) - temp *= 1000000; - count = sprintf(buf, "%d\n", temp); - } - } - else - { - count = sprintf(buf, "%d\n", 0); - } - return count; -} - -static ssize_t show_psu_pin(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 i2c_bus1_hardware_monitor_data *data = i2c_get_clientdata(client); - unsigned short value = 0; - unsigned int index = 0; - unsigned int valueY = 0; - unsigned char valueN = 0; - ssize_t count = 0; - unsigned int temp = 0; - unsigned int psu_present = 0; - - index = (attr->index&0x1); - if (index&0x01) /* PSU 2 */ - { - if ((platformPsuABS&0x02)==0x00) /* PSU2 Present */ - psu_present = 1; - } - else /* PSU 1 */ - { - if ((platformPsuABS&0x01)==0x00) /* PSU1 Present */ - psu_present = 1; - } - if (psu_present == 1) - { - switch(platformModelId) - { - case HURACAN_WITH_BMC: - case HURACAN_WITHOUT_BMC: - case HURACAN_A_WITH_BMC: - case HURACAN_A_WITHOUT_BMC: - { - mutex_lock(&data->lock); - if (index) - /* Turn on PCA9548 channel 7 on I2C-bus1 */ - i2c_smbus_write_byte(client, 0x80); - else - /* Turn on PCA9548 channel 6 on I2C-bus1 */ - i2c_smbus_write_byte(client, 0x40); - value = i2c_smbus_read_word_data(&psu_mcu_client, 0x97); - i2c_smbus_write_byte(client, 0x00); - mutex_unlock(&data->lock); - } - break; - - case CABRERAIII_WITH_BMC: - case CABRERAIII_WITHOUT_BMC: - break; - - case SESTO_WITH_BMC: - case SESTO_WITHOUT_BMC: - { - mutex_lock(&data->lock); - if (index) - /* Turn on PCA9548#1 channel 7 on I2C-bus1 */ - i2c_smbus_write_byte(&(pca9548_client[1]), 0x80); - else - /* Turn on PCA9548#1 channel 6 on I2C-bus1 */ - i2c_smbus_write_byte(&(pca9548_client[1]), 0x40); - value = i2c_smbus_read_word_data(&psu_mcu_client, 0x97); - i2c_smbus_write_byte(&(pca9548_client[1]), 0x00); - mutex_unlock(&data->lock); - } - break; - - case NCIIX_WITH_BMC: - case NCIIX_WITHOUT_BMC: - { - if ((platformBuildRev > 0x01) && (platformHwRev == 0x03)) /* PVT rev2*/ - { - mutex_lock(&data->lock); - if (index) - i2c_smbus_write_byte(client, 0x20); /* Turn on PCA9548 channel 5 on I2C-bus1 */ - else - i2c_smbus_write_byte(client, 0x10); /* Turn on PCA9548 channel 4 on I2C-bus1 */ - value = i2c_smbus_read_word_data(&psu_mcu_client, 0x97); - i2c_smbus_write_byte(client, 0x00); - mutex_unlock(&data->lock); - } - else - { - struct i2c_bus0_hardware_monitor_data *data_bus0 = i2c_get_clientdata(&psu_eeprom_client_bus0); - - mutex_lock(&data_bus0->lock); - if (index) - i2c_smbus_write_byte(&pca9548_client_bus0, 0x04); /* Turn on PCA9548#0 channel 2 on I2C-bus0 */ - else - i2c_smbus_write_byte(&pca9548_client_bus0, 0x02); /* Turn on PCA9548#0 channel 1 on I2C-bus0 */ - value = i2c_smbus_read_word_data(&psu_mcu_client_bus0, 0x97); - i2c_smbus_write_byte(&pca9548_client_bus0, 0x00); - mutex_unlock(&data_bus0->lock); - } - } - break; - - case ASTERION_WITH_BMC: - case ASTERION_WITHOUT_BMC: - break; - - default: - break; - } - valueY = (value & 0x07FF); - if ((value & 0x8000)&&(valueY)) - { - valueN = 0xF0 + (((value) >> 11) & 0x0F); - valueN = (~valueN) +1; - temp = (unsigned int)(1<index >= 100) - count = sprintf(buf, "%d\n", valueY/temp*1000000 + ((valueY%temp)*1000000)/temp); - else - count = sprintf(buf, "%d.%04d\n", valueY/temp, ((valueY%temp)*10000)/temp); - } - } - else - { - valueN = (((value) >> 11) & 0x0F); - temp = (valueY*(1<index >= 100) - temp *= 1000000; - count = sprintf(buf, "%d\n", temp); - } - } - else - { - count = sprintf(buf, "%d\n", 0); - } - return count; -} - -static ssize_t set_psu_power_off(struct device *dev, struct device_attribute *devattr, const char *buf, - size_t count) -{ - struct i2c_client *client = to_i2c_client(dev); - struct i2c_bus1_hardware_monitor_data *data = i2c_get_clientdata(client); - long temp; - - if (kstrtol(buf, 10, &temp)) - return -EINVAL; - - temp = clamp_val(temp, 0, 1); - if (temp == 0) - return count; - - switch(platformModelId) - { - case HURACAN_WITH_BMC: - case HURACAN_WITHOUT_BMC: - case ASTERION_WITH_BMC: - case ASTERION_WITHOUT_BMC: - case HURACAN_A_WITH_BMC: - case HURACAN_A_WITHOUT_BMC: - { - /* - Setting the ON_OFF_CONFIG Command (02h) to type 9 (SW : turn-on/off by operation command). - I2C Command: B0 02 19 8F - address command data PEC(Packet Error Check) - */ - unsigned short cmd_data_1 = 0x8F19; - /* - Setting the Operation Command (01h) to turn-off power immediately. - I2C Command: B0 01 00 FF - address command data PEC(Packet Error Check) - */ - unsigned short cmd_data_2 = 0xFF00; - - mutex_lock(&data->lock); - if ((platformPsuABS&0x01)==0x00) /* PSU1 Present */ - { - /* Turn on PCA9548#1 channel 6 on I2C-bus1 */ - i2c_smbus_write_byte(client, 0x40); - i2c_smbus_write_word_data(&psu_mcu_client, 0x02, cmd_data_1); - i2c_smbus_write_word_data(&psu_mcu_client, 0x01, cmd_data_2); - } - if ((platformPsuABS&0x02)==0x00) /* PSU2 Present */ - { - /* Turn on PCA9548#1 channel 7 on I2C-bus1 */ - i2c_smbus_write_byte(client, 0x80); - i2c_smbus_write_word_data(&psu_mcu_client, 0x02, cmd_data_1); - i2c_smbus_write_word_data(&psu_mcu_client, 0x01, cmd_data_2); - } - i2c_smbus_write_byte(client, 0x00); - mutex_unlock(&data->lock); - } - break; - - case SESTO_WITH_BMC: - case SESTO_WITHOUT_BMC: - { - unsigned short cmd_data_1 = 0x8F19; - unsigned short cmd_data_2 = 0xFF00; - - mutex_lock(&data->lock); - if ((platformPsuABS&0x01)==0x00) /* PSU1 Present */ - { - /* Turn on PCA9548#1 channel 6 on I2C-bus1 */ - i2c_smbus_write_byte(&(pca9548_client[1]), 0x40); - i2c_smbus_write_word_data(&psu_mcu_client, 0x02, cmd_data_1); - i2c_smbus_write_word_data(&psu_mcu_client, 0x01, cmd_data_2); - } - if ((platformPsuABS&0x02)==0x00) /* PSU2 Present */ - { - /* Turn on PCA9548#1 channel 7 on I2C-bus1 */ - i2c_smbus_write_byte(&(pca9548_client[1]), 0x80); - i2c_smbus_write_word_data(&psu_mcu_client, 0x02, cmd_data_1); - i2c_smbus_write_word_data(&psu_mcu_client, 0x01, cmd_data_2); - } - i2c_smbus_write_byte(&(pca9548_client[1]), 0x00); - mutex_unlock(&data->lock); - } - break; - - case NCIIX_WITH_BMC: - case NCIIX_WITHOUT_BMC: - { - /* - Setting the ON_OFF_CONFIG Command (02h) to type 9 (SW : turn-on/off by operation command). - I2C Command: B2 02 19 59 - address command data PEC(Packet Error Check) - */ - unsigned short cmd_data_1 = 0x5919; - /* - Setting the Operation Command (01h) to turn-off power immediately. - I2C Command: B2 01 00 29 - address command data PEC(Packet Error Check) - */ - unsigned short cmd_data_2 = 0x2900; - - if ((platformBuildRev > 0x01) && (platformHwRev == 0x03)) /* PVT rev2*/ - { - mutex_lock(&data->lock); - if ((platformPsuABS & 0x01) == 0x00) /* PSU1 Present */ - { - /* Turn on PCA9548#0 channel 4 on I2C-bus1 */ - i2c_smbus_write_byte(client, 0x10); - i2c_smbus_write_word_data(&psu_mcu_client, 0x02, cmd_data_1); - i2c_smbus_write_word_data(&psu_mcu_client, 0x01, cmd_data_2); - } - if ((platformPsuABS & 0x02) == 0x00) /* PSU2 Present */ - { - /* Turn on PCA9548#0 channel 5 on I2C-bus1 */ - i2c_smbus_write_byte(client, 0x20); - i2c_smbus_write_word_data(&psu_mcu_client, 0x02, cmd_data_1); - i2c_smbus_write_word_data(&psu_mcu_client, 0x01, cmd_data_2); - } - i2c_smbus_write_byte(client, 0x00); - mutex_unlock(&data->lock); - } - else - { - struct i2c_bus0_hardware_monitor_data *data_bus0 = i2c_get_clientdata(&psu_eeprom_client_bus0); - - mutex_lock(&data_bus0->lock); - if ((platformPsuABS & 0x01) == 0x00) /* PSU1 Present */ - { - /* Turn on PCA9548#0 channel 1 on I2C-bus0 */ - i2c_smbus_write_byte(&pca9548_client_bus0, 0x02); - i2c_smbus_write_word_data(&psu_mcu_client_bus0, 0x02, cmd_data_1); - i2c_smbus_write_word_data(&psu_mcu_client_bus0, 0x01, cmd_data_2); - } - if ((platformPsuABS & 0x02) == 0x00) /* PSU2 Present */ - { - /* Turn on PCA9548#0 channel 2 on I2C-bus0 */ - i2c_smbus_write_byte(&pca9548_client_bus0, 0x04); - i2c_smbus_write_word_data(&psu_mcu_client_bus0, 0x02, cmd_data_1); - i2c_smbus_write_word_data(&psu_mcu_client_bus0, 0x01, cmd_data_2); - } - i2c_smbus_write_byte(&pca9548_client_bus0, 0x00); - mutex_unlock(&data_bus0->lock); - } - } - break; - - default: - break; - } - - return count; -} - - -static ssize_t set_system_led(struct device *dev, struct device_attribute *devattr, const char *buf, - size_t count) -{ - struct i2c_client *client = to_i2c_client(dev); - struct i2c_bus1_hardware_monitor_data *data = i2c_get_clientdata(client); - long temp; - - if (kstrtol(buf, 10, &temp)) - return -EINVAL; - - temp = clamp_val(temp, 0, 2); - - mutex_lock(&data->lock); - data->systemLedStatus = temp; - mutex_unlock(&data->lock); - - return count; -} - -static ssize_t show_fan_led(struct device *dev, struct device_attribute *devattr, char *buf) -{ - struct i2c_client *client = to_i2c_client(dev); - struct i2c_bus1_hardware_monitor_data *data = i2c_get_clientdata(client); - unsigned int temp; - unsigned int frontLedStatus; - - mutex_lock(&data->lock); - frontLedStatus = (unsigned int)data->frontLedStatus; - switch(platformModelId) - { - case ASTERION_WITH_BMC: - case ASTERION_WITHOUT_BMC: - { - if (!(frontLedStatus & 0x0010)) - temp = 2; /* Normal */ - else if (!(frontLedStatus & 0x0020)) - temp = 1; /* Critical */ - else - temp = 0; /* Booting */ - } - break; - default: - { - if (!(frontLedStatus & 0x0008)) - temp = 2; /* Normal */ - else if (!(frontLedStatus & 0x0004)) - temp = 1; /* Critical */ - else - temp = 0; /* Booting */ - } - break; - } - mutex_unlock(&data->lock); - - return sprintf(buf, "%d\n", temp); -} - -static ssize_t show_psu_led(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 i2c_bus1_hardware_monitor_data *data = i2c_get_clientdata(client); - unsigned int temp; - unsigned int frontLedStatus; - - mutex_lock(&data->lock); - frontLedStatus = (unsigned int)data->frontLedStatus; - switch(platformModelId) - { - case ASTERION_WITH_BMC: - case ASTERION_WITHOUT_BMC: - { - if (attr->index == 0) - { - if (!(frontLedStatus & 0x0001)) - temp = 2; /* Normal */ - else if (!(frontLedStatus & 0x0002)) - temp = 1; /* Critical */ - else - temp = 0; /* Booting */ - } - else - { - if (!(frontLedStatus & 0x0004)) - temp = 2; /* Normal */ - else if (!(frontLedStatus & 0x0008)) - temp = 1; /* Critical */ - else - temp = 0; /* Booting */ - } - } - break; - default: - { - if (attr->index == 0) - { - if (!(frontLedStatus & 0x0002)) - temp = 2; /* Normal */ - else if (!(frontLedStatus & 0x0001)) - temp = 1; /* Critical */ - else - temp = 0; /* Booting */ - } - else - { - if (!(frontLedStatus & 0x0020)) - temp = 2; /* Normal */ - else if (!(frontLedStatus & 0x0010)) - temp = 1; /* Critical */ - else - temp = 0; /* Booting */ - } - } - break; - } - - mutex_unlock(&data->lock); - - return sprintf(buf, "%d\n", temp); -} - -static ssize_t show_port_tx_disable(struct device *dev, struct device_attribute *devattr, char *buf) -{ - struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); - int rc = 0; - - switch(platformModelId) - { - case SESTO_WITH_BMC: - case SESTO_WITHOUT_BMC: - { - struct i2c_bus1_hardware_monitor_data *data = i2c_get_clientdata(&(pca9535pwr_client[0])); - unsigned short index=0, bit=0; - - index = (attr->index/16); - bit = (attr->index%16); - mutex_lock(&data->lock); - rc = (PCA9553_TEST_BIT(data->sfpPortTxDisable[index], bit)?1:0); - mutex_unlock(&data->lock); - } - break; - - case NCIIX_WITH_BMC: - case NCIIX_WITHOUT_BMC: - { - rc = (SFPPortTxDisable[attr->index]==1); - } - break; - - case ASTERION_WITH_BMC: - case ASTERION_WITHOUT_BMC: - { - struct i2c_bus1_hardware_monitor_data *data = i2c_get_clientdata(&(pca9535pwr_client[0])); - unsigned short bit = 0; - - bit = (attr->index % 8); - mutex_lock(&data->lock); - rc = (PCA9553_TEST_BIT(data->sfpPortTxDisableAst[attr->index / 8], bit) ? 1 : 0); - mutex_unlock(&data->lock); - } - break; - - default: - break; - } - - - return sprintf(buf, "%d\n", rc); -} - -static ssize_t set_port_tx_disable(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, pca9548Client; - struct i2c_bus1_hardware_monitor_data *data; - long temp; - - if (kstrtol(buf, 10, &temp)) - return -EINVAL; - temp = clamp_val(temp, 0, 1); - - pca9548Client = pca9548_client[1]; - client = &pca9548Client; - data = i2c_get_clientdata(client); - switch(platformModelId) - { - case SESTO_WITH_BMC: - case SESTO_WITHOUT_BMC: - { - unsigned short index=0, bit=0; - - index = (attr->index/16); - bit = (attr->index%16); - - mutex_lock(&data->lock); - if (temp==1) - PCA9553_SET_BIT(data->sfpPortTxDisable[index], bit); - else - PCA9553_CLEAR_BIT(data->sfpPortTxDisable[index], bit); - i2c_smbus_write_byte(&(pca9548_client[1]), (1<sfpPortTxDisable[index]); - i2c_smbus_write_byte(&(pca9548_client[1]), 0x00); - mutex_unlock(&data->lock); - } - break; - - case NCIIX_WITH_BMC: - case NCIIX_WITHOUT_BMC: - { - unsigned short value = 0; - - pca9548Client.addr = 0x70; - SFPPortTxDisable[attr->index] = (temp&0x1); - if ((attr->index/8) == 5) /* SFP+ 40~47 */ - { - mutex_lock(&data->lock); - i2c_smbus_write_byte(client, sfpPortData_78F[attr->index].portMaskIOsForPCA9548_0); - value = i2c_smbus_read_word_data(&(pca9535pwr_client[sfpPortData_78F[attr->index].i2cAddrForPCA9535]), PCA9553_COMMAND_BYTE_REG_OUTPUT_PORT_0); - if (temp==1) - PCA9553_SET_BIT(value, sfpPortData_78F[attr->index].portMaskBitForTxEnPin); - else - PCA9553_CLEAR_BIT(value, sfpPortData_78F[attr->index].portMaskBitForTxEnPin); - i2c_device_word_write(&(pca9535pwr_client[sfpPortData_78F[attr->index].i2cAddrForPCA9535]), PCA9553_COMMAND_BYTE_REG_OUTPUT_PORT_0, value); - i2c_smbus_write_byte(client, 0x00); - mutex_unlock(&data->lock); - } - else /* SFP+ 0~39 */ - { - struct i2c_bus0_hardware_monitor_data *data_bus0 = i2c_get_clientdata(&pca9548_client_bus0); - - mutex_lock(&data_bus0->lock); - i2c_smbus_write_byte(&pca9548_client_bus0, sfpPortData_78F[attr->index].portMaskIOsForPCA9548_0); - value = i2c_smbus_read_word_data(&(pca9535_client_bus0[sfpPortData_78F[attr->index].i2cAddrForPCA9535]), PCA9553_COMMAND_BYTE_REG_OUTPUT_PORT_0); - if (temp==1) - PCA9553_SET_BIT(value, sfpPortData_78F[attr->index].portMaskBitForTxEnPin); - else - PCA9553_CLEAR_BIT(value, sfpPortData_78F[attr->index].portMaskBitForTxEnPin); - i2c_device_word_write(&(pca9535_client_bus0[sfpPortData_78F[attr->index].i2cAddrForPCA9535]), PCA9553_COMMAND_BYTE_REG_OUTPUT_PORT_0, value); - i2c_smbus_write_byte(&pca9548_client_bus0, 0x00); - mutex_unlock(&data_bus0->lock); - } - } - break; - - case ASTERION_WITH_BMC: - case ASTERION_WITHOUT_BMC: - { - unsigned short index = 0, bit = 0; - - pca9548Client.addr = 0x72; - index = (attr->index / 8); - bit = (attr->index % 8); - - mutex_lock(&data->lock); - if (temp == 1) - PCA9553_SET_BIT(data->sfpPortTxDisableAst[index], bit); - else - PCA9553_CLEAR_BIT(data->sfpPortTxDisableAst[index], bit); - - if (index < 3) - { - i2c_smbus_write_byte(client, (1 << PCA9548_CH00)); - i2c_smbus_write_byte_data(&(cpld_client_bus1), (0x40 + index), data->sfpPortTxDisableAst[index]); - } - else - { - i2c_smbus_write_byte(client, (1 << PCA9548_CH01)); - i2c_smbus_write_byte_data(&(cpld_client_bus1), (0x40 + (index - 3)), data->sfpPortTxDisableAst[index]); - } - - i2c_smbus_write_byte(client, 0x00); - mutex_unlock(&data->lock); - } - break; - - default: - break; - } - - return count; -} - -static ssize_t show_port_rate_select(struct device *dev, struct device_attribute *devattr, char *buf) -{ - struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); - int rc = 0; - - switch(platformModelId) - { - case SESTO_WITH_BMC: - case SESTO_WITHOUT_BMC: - { - struct i2c_client *client = to_i2c_client(dev); - struct i2c_bus1_hardware_monitor_data *data = i2c_get_clientdata(client); - unsigned short index=0, bit=0; - - index = (attr->index/16); - bit = (attr->index%16); - mutex_lock(&data->lock); - rc = (PCA9553_TEST_BIT(data->sfpPortRateSelect[index], bit)?1:0); - mutex_unlock(&data->lock); - } - break; - - case ASTERION_WITH_BMC: - case ASTERION_WITHOUT_BMC: - { - struct i2c_client *client = to_i2c_client(dev); - struct i2c_bus1_hardware_monitor_data *data = i2c_get_clientdata(client); - unsigned short index = 0; - - index = (attr->index % 4); - mutex_lock(&data->lock); - rc = (PCA9553_TEST_BIT(data->sfpPortRateSelectAst[attr->index / 4], (index * 2)) ? 1 : 0); - mutex_unlock(&data->lock); - } - break; - - default: - break; - } - - - return sprintf(buf, "%d\n", rc); -} - -static ssize_t set_port_rate_select(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 i2c_bus1_hardware_monitor_data *data = i2c_get_clientdata(client); - long temp; - - if (kstrtol(buf, 10, &temp)) - return -EINVAL; - temp = clamp_val(temp, 0, 1); - - switch(platformModelId) - { - case SESTO_WITH_BMC: - case SESTO_WITHOUT_BMC: - { - unsigned short index=0, bit=0; - - index = (attr->index/16); - bit = (attr->index%16); - - mutex_lock(&data->lock); - if (temp==1) - PCA9553_SET_BIT(data->sfpPortRateSelect[index], bit); - else - PCA9553_CLEAR_BIT(data->sfpPortRateSelect[index], bit); - i2c_smbus_write_byte(&(pca9548_client[1]), (1<sfpPortRateSelect[0]); - break; - - case 1: - i2c_device_word_write(&(pca9535pwr_client[1]), PCA9553_COMMAND_BYTE_REG_OUTPUT_PORT_0, data->sfpPortRateSelect[1]); - break; - - case 2: - i2c_device_word_write(&(pca9535pwr_client[2]), PCA9553_COMMAND_BYTE_REG_OUTPUT_PORT_0, data->sfpPortRateSelect[2]); - break; - - default: - break; - } - i2c_smbus_write_byte(&(pca9548_client[1]), (1<sfpPortRateSelect[0]); - break; - - case 1: - i2c_device_word_write(&(pca9535pwr_client[1]), PCA9553_COMMAND_BYTE_REG_OUTPUT_PORT_0, data->sfpPortRateSelect[1]); - break; - - case 2: - i2c_device_word_write(&(pca9535pwr_client[2]), PCA9553_COMMAND_BYTE_REG_OUTPUT_PORT_0, data->sfpPortRateSelect[2]); - break; - - default: - break; - } - i2c_smbus_write_byte(&(pca9548_client[1]), 0x00); - mutex_unlock(&data->lock); - } - break; - - case ASTERION_WITH_BMC: - case ASTERION_WITHOUT_BMC: - { - unsigned short index = 0, bit = 0; - - index = (attr->index / 4); - bit = (attr->index % 4); - - mutex_lock(&data->lock); - if (attr->index >= 0 && attr->index < 24) - { - /* Turn on PCA9548#0 channel 0 on I2C-bus1 - RX_RS, TX_RS */ - i2c_smbus_write_byte(client, (1 << PCA9548_CH00)); - - if (temp == 1) - { - PCA9553_SET_BIT(data->sfpPortRateSelectAst[index], (bit * 2)); - PCA9553_SET_BIT(data->sfpPortRateSelectAst[index], (bit * 2 + 1)); - } - else - { - PCA9553_CLEAR_BIT(data->sfpPortRateSelectAst[index], (bit * 2)); - PCA9553_CLEAR_BIT(data->sfpPortRateSelectAst[index], (bit * 2 + 1)); - } - - switch(index) - { - case 0: - i2c_smbus_write_byte_data(&(cpld_client_bus1), 0x8, data->sfpPortRateSelectAst[index]); - break; - case 1: - i2c_smbus_write_byte_data(&(cpld_client_bus1), 0x9, data->sfpPortRateSelectAst[index]); - break; - case 2: - i2c_smbus_write_byte_data(&(cpld_client_bus1), 0x10, data->sfpPortRateSelectAst[index]); - break; - case 3: - i2c_smbus_write_byte_data(&(cpld_client_bus1), 0x11, data->sfpPortRateSelectAst[index]); - break; - case 4: - i2c_smbus_write_byte_data(&(cpld_client_bus1), 0x12, data->sfpPortRateSelectAst[index]); - break; - case 5: - i2c_smbus_write_byte_data(&(cpld_client_bus1), 0x13, data->sfpPortRateSelectAst[index]); - break; - } - } - else - { - /* Turn on PCA9548#0 channel 1 on I2C-bus1 - RX_RS, TX_RS */ - i2c_smbus_write_byte(client, (1 << PCA9548_CH01)); - - if (temp == 1) - { - PCA9553_SET_BIT(data->sfpPortRateSelectAst[index], (bit * 2)); - PCA9553_SET_BIT(data->sfpPortRateSelectAst[index], (bit * 2 + 1)); - } - else - { - PCA9553_CLEAR_BIT(data->sfpPortRateSelectAst[index], (bit * 2)); - PCA9553_CLEAR_BIT(data->sfpPortRateSelectAst[index], (bit * 2 + 1)); - } - - switch(index) - { - case 6: - i2c_smbus_write_byte_data(&(cpld_client_bus1), 0x8, data->sfpPortRateSelectAst[index]); - break; - case 7: - i2c_smbus_write_byte_data(&(cpld_client_bus1), 0x9, data->sfpPortRateSelectAst[index]); - break; - case 8: - i2c_smbus_write_byte_data(&(cpld_client_bus1), 0x10, data->sfpPortRateSelectAst[index]); - break; - case 9: - i2c_smbus_write_byte_data(&(cpld_client_bus1), 0x11, data->sfpPortRateSelectAst[index]); - break; - case 10: - i2c_smbus_write_byte_data(&(cpld_client_bus1), 0x12, data->sfpPortRateSelectAst[index]); - break; - case 11: - i2c_smbus_write_byte_data(&(cpld_client_bus1), 0x13, data->sfpPortRateSelectAst[index]); - break; - } - } - - i2c_smbus_write_byte(client, 0x00); - mutex_unlock(&data->lock); - } - break; - - default: - break; - } - - return count; -} - -static ssize_t show_port_tx_fault(struct device *dev, struct device_attribute *devattr, char *buf) -{ - struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); - int rc = 0; - - switch(platformModelId) - { - case SESTO_WITH_BMC: - case SESTO_WITHOUT_BMC: - { - struct i2c_bus1_hardware_monitor_data *data = i2c_get_clientdata(&(pca9535pwr_client[0])); - unsigned short index = 0, bit = 0; - - index = (attr->index / 16); - bit = (attr->index % 16); - mutex_lock(&data->lock); - rc = (PCA9553_TEST_BIT(data->sfpPortTxFaultStatus[index], bit) ? 1 : 0); - mutex_unlock(&data->lock); - } - break; - - case NCIIX_WITH_BMC: - case NCIIX_WITHOUT_BMC: - { - rc = (SFPPortTxFaultStatus[attr->index] ? 0 : 1); - } - break; - - case ASTERION_WITH_BMC: - case ASTERION_WITHOUT_BMC: - { - struct i2c_bus1_hardware_monitor_data *data = i2c_get_clientdata(&(pca9535pwr_client[0])); - unsigned char qsfpPortRxLos = 0, index = 0, bit = 0; - - index = (attr->index / 2); - bit = ((attr->index & 0x01) ? 7 : 3); - mutex_lock(&data->lock); - qsfpPortRxLos = data->sfpPortAbsRxLosStatus[index]; - mutex_unlock(&data->lock); - rc = (PCA9553_TEST_BIT(qsfpPortRxLos, bit) ? 1 : 0); - } - break; - - default: - break; - } - - - return sprintf(buf, "%d\n", rc); -} - -static DEVICE_ATTR(eeprom, S_IRUGO, show_eeprom, NULL); -static DEVICE_ATTR(system_led, S_IWUSR, NULL, set_system_led); -static DEVICE_ATTR(fan_led, S_IRUGO, show_fan_led, NULL); -static SENSOR_DEVICE_ATTR(psu1_led, S_IRUGO, show_psu_led, NULL, 0); -static SENSOR_DEVICE_ATTR(psu2_led, S_IRUGO, show_psu_led, NULL, 1); - -static SENSOR_DEVICE_ATTR(port_1_data_a0, S_IRUGO, show_port_data_a0, NULL, 0); -static SENSOR_DEVICE_ATTR(port_2_data_a0, S_IRUGO, show_port_data_a0, NULL, 1); -static SENSOR_DEVICE_ATTR(port_3_data_a0, S_IRUGO, show_port_data_a0, NULL, 2); -static SENSOR_DEVICE_ATTR(port_4_data_a0, S_IRUGO, show_port_data_a0, NULL, 3); -static SENSOR_DEVICE_ATTR(port_5_data_a0, S_IRUGO, show_port_data_a0, NULL, 4); -static SENSOR_DEVICE_ATTR(port_6_data_a0, S_IRUGO, show_port_data_a0, NULL, 5); -static SENSOR_DEVICE_ATTR(port_7_data_a0, S_IRUGO, show_port_data_a0, NULL, 6); -static SENSOR_DEVICE_ATTR(port_8_data_a0, S_IRUGO, show_port_data_a0, NULL, 7); -static SENSOR_DEVICE_ATTR(port_9_data_a0, S_IRUGO, show_port_data_a0, NULL, 8); -static SENSOR_DEVICE_ATTR(port_10_data_a0, S_IRUGO, show_port_data_a0, NULL, 9); -static SENSOR_DEVICE_ATTR(port_11_data_a0, S_IRUGO, show_port_data_a0, NULL, 10); -static SENSOR_DEVICE_ATTR(port_12_data_a0, S_IRUGO, show_port_data_a0, NULL, 11); -static SENSOR_DEVICE_ATTR(port_13_data_a0, S_IRUGO, show_port_data_a0, NULL, 12); -static SENSOR_DEVICE_ATTR(port_14_data_a0, S_IRUGO, show_port_data_a0, NULL, 13); -static SENSOR_DEVICE_ATTR(port_15_data_a0, S_IRUGO, show_port_data_a0, NULL, 14); -static SENSOR_DEVICE_ATTR(port_16_data_a0, S_IRUGO, show_port_data_a0, NULL, 15); -static SENSOR_DEVICE_ATTR(port_17_data_a0, S_IRUGO, show_port_data_a0, NULL, 16); -static SENSOR_DEVICE_ATTR(port_18_data_a0, S_IRUGO, show_port_data_a0, NULL, 17); -static SENSOR_DEVICE_ATTR(port_19_data_a0, S_IRUGO, show_port_data_a0, NULL, 18); -static SENSOR_DEVICE_ATTR(port_20_data_a0, S_IRUGO, show_port_data_a0, NULL, 19); -static SENSOR_DEVICE_ATTR(port_21_data_a0, S_IRUGO, show_port_data_a0, NULL, 20); -static SENSOR_DEVICE_ATTR(port_22_data_a0, S_IRUGO, show_port_data_a0, NULL, 21); -static SENSOR_DEVICE_ATTR(port_23_data_a0, S_IRUGO, show_port_data_a0, NULL, 22); -static SENSOR_DEVICE_ATTR(port_24_data_a0, S_IRUGO, show_port_data_a0, NULL, 23); -static SENSOR_DEVICE_ATTR(port_25_data_a0, S_IRUGO, show_port_data_a0, NULL, 24); -static SENSOR_DEVICE_ATTR(port_26_data_a0, S_IRUGO, show_port_data_a0, NULL, 25); -static SENSOR_DEVICE_ATTR(port_27_data_a0, S_IRUGO, show_port_data_a0, NULL, 26); -static SENSOR_DEVICE_ATTR(port_28_data_a0, S_IRUGO, show_port_data_a0, NULL, 27); -static SENSOR_DEVICE_ATTR(port_29_data_a0, S_IRUGO, show_port_data_a0, NULL, 28); -static SENSOR_DEVICE_ATTR(port_30_data_a0, S_IRUGO, show_port_data_a0, NULL, 29); -static SENSOR_DEVICE_ATTR(port_31_data_a0, S_IRUGO, show_port_data_a0, NULL, 30); -static SENSOR_DEVICE_ATTR(port_32_data_a0, S_IRUGO, show_port_data_a0, NULL, 31); -static SENSOR_DEVICE_ATTR(port_33_data_a0, S_IRUGO, show_port_data_a0, NULL, 32); -static SENSOR_DEVICE_ATTR(port_34_data_a0, S_IRUGO, show_port_data_a0, NULL, 33); -static SENSOR_DEVICE_ATTR(port_35_data_a0, S_IRUGO, show_port_data_a0, NULL, 34); -static SENSOR_DEVICE_ATTR(port_36_data_a0, S_IRUGO, show_port_data_a0, NULL, 35); -static SENSOR_DEVICE_ATTR(port_37_data_a0, S_IRUGO, show_port_data_a0, NULL, 36); -static SENSOR_DEVICE_ATTR(port_38_data_a0, S_IRUGO, show_port_data_a0, NULL, 37); -static SENSOR_DEVICE_ATTR(port_39_data_a0, S_IRUGO, show_port_data_a0, NULL, 38); -static SENSOR_DEVICE_ATTR(port_40_data_a0, S_IRUGO, show_port_data_a0, NULL, 39); -static SENSOR_DEVICE_ATTR(port_41_data_a0, S_IRUGO, show_port_data_a0, NULL, 40); -static SENSOR_DEVICE_ATTR(port_42_data_a0, S_IRUGO, show_port_data_a0, NULL, 41); -static SENSOR_DEVICE_ATTR(port_43_data_a0, S_IRUGO, show_port_data_a0, NULL, 42); -static SENSOR_DEVICE_ATTR(port_44_data_a0, S_IRUGO, show_port_data_a0, NULL, 43); -static SENSOR_DEVICE_ATTR(port_45_data_a0, S_IRUGO, show_port_data_a0, NULL, 44); -static SENSOR_DEVICE_ATTR(port_46_data_a0, S_IRUGO, show_port_data_a0, NULL, 45); -static SENSOR_DEVICE_ATTR(port_47_data_a0, S_IRUGO, show_port_data_a0, NULL, 46); -static SENSOR_DEVICE_ATTR(port_48_data_a0, S_IRUGO, show_port_data_a0, NULL, 47); -static SENSOR_DEVICE_ATTR(port_49_data_a0, S_IRUGO, show_port_data_a0, NULL, 48); -static SENSOR_DEVICE_ATTR(port_50_data_a0, S_IRUGO, show_port_data_a0, NULL, 49); -static SENSOR_DEVICE_ATTR(port_51_data_a0, S_IRUGO, show_port_data_a0, NULL, 50); -static SENSOR_DEVICE_ATTR(port_52_data_a0, S_IRUGO, show_port_data_a0, NULL, 51); -static SENSOR_DEVICE_ATTR(port_53_data_a0, S_IRUGO, show_port_data_a0, NULL, 52); -static SENSOR_DEVICE_ATTR(port_54_data_a0, S_IRUGO, show_port_data_a0, NULL, 53); -static SENSOR_DEVICE_ATTR(port_55_data_a0, S_IRUGO, show_port_data_a0, NULL, 54); -static SENSOR_DEVICE_ATTR(port_56_data_a0, S_IRUGO, show_port_data_a0, NULL, 55); -static SENSOR_DEVICE_ATTR(port_57_data_a0, S_IRUGO, show_port_data_a0, NULL, 56); -static SENSOR_DEVICE_ATTR(port_58_data_a0, S_IRUGO, show_port_data_a0, NULL, 57); -static SENSOR_DEVICE_ATTR(port_59_data_a0, S_IRUGO, show_port_data_a0, NULL, 58); -static SENSOR_DEVICE_ATTR(port_60_data_a0, S_IRUGO, show_port_data_a0, NULL, 59); -static SENSOR_DEVICE_ATTR(port_61_data_a0, S_IRUGO, show_port_data_a0, NULL, 60); -static SENSOR_DEVICE_ATTR(port_62_data_a0, S_IRUGO, show_port_data_a0, NULL, 61); -static SENSOR_DEVICE_ATTR(port_63_data_a0, S_IRUGO, show_port_data_a0, NULL, 62); -static SENSOR_DEVICE_ATTR(port_64_data_a0, S_IRUGO, show_port_data_a0, NULL, 63); - -static SENSOR_DEVICE_ATTR(port_1_data_a2, S_IRUGO, show_port_data_a2, NULL, 0); -static SENSOR_DEVICE_ATTR(port_2_data_a2, S_IRUGO, show_port_data_a2, NULL, 1); -static SENSOR_DEVICE_ATTR(port_3_data_a2, S_IRUGO, show_port_data_a2, NULL, 2); -static SENSOR_DEVICE_ATTR(port_4_data_a2, S_IRUGO, show_port_data_a2, NULL, 3); -static SENSOR_DEVICE_ATTR(port_5_data_a2, S_IRUGO, show_port_data_a2, NULL, 4); -static SENSOR_DEVICE_ATTR(port_6_data_a2, S_IRUGO, show_port_data_a2, NULL, 5); -static SENSOR_DEVICE_ATTR(port_7_data_a2, S_IRUGO, show_port_data_a2, NULL, 6); -static SENSOR_DEVICE_ATTR(port_8_data_a2, S_IRUGO, show_port_data_a2, NULL, 7); -static SENSOR_DEVICE_ATTR(port_9_data_a2, S_IRUGO, show_port_data_a2, NULL, 8); -static SENSOR_DEVICE_ATTR(port_10_data_a2, S_IRUGO, show_port_data_a2, NULL, 9); -static SENSOR_DEVICE_ATTR(port_11_data_a2, S_IRUGO, show_port_data_a2, NULL, 10); -static SENSOR_DEVICE_ATTR(port_12_data_a2, S_IRUGO, show_port_data_a2, NULL, 11); -static SENSOR_DEVICE_ATTR(port_13_data_a2, S_IRUGO, show_port_data_a2, NULL, 12); -static SENSOR_DEVICE_ATTR(port_14_data_a2, S_IRUGO, show_port_data_a2, NULL, 13); -static SENSOR_DEVICE_ATTR(port_15_data_a2, S_IRUGO, show_port_data_a2, NULL, 14); -static SENSOR_DEVICE_ATTR(port_16_data_a2, S_IRUGO, show_port_data_a2, NULL, 15); -static SENSOR_DEVICE_ATTR(port_17_data_a2, S_IRUGO, show_port_data_a2, NULL, 16); -static SENSOR_DEVICE_ATTR(port_18_data_a2, S_IRUGO, show_port_data_a2, NULL, 17); -static SENSOR_DEVICE_ATTR(port_19_data_a2, S_IRUGO, show_port_data_a2, NULL, 18); -static SENSOR_DEVICE_ATTR(port_20_data_a2, S_IRUGO, show_port_data_a2, NULL, 19); -static SENSOR_DEVICE_ATTR(port_21_data_a2, S_IRUGO, show_port_data_a2, NULL, 20); -static SENSOR_DEVICE_ATTR(port_22_data_a2, S_IRUGO, show_port_data_a2, NULL, 21); -static SENSOR_DEVICE_ATTR(port_23_data_a2, S_IRUGO, show_port_data_a2, NULL, 22); -static SENSOR_DEVICE_ATTR(port_24_data_a2, S_IRUGO, show_port_data_a2, NULL, 23); -static SENSOR_DEVICE_ATTR(port_25_data_a2, S_IRUGO, show_port_data_a2, NULL, 24); -static SENSOR_DEVICE_ATTR(port_26_data_a2, S_IRUGO, show_port_data_a2, NULL, 25); -static SENSOR_DEVICE_ATTR(port_27_data_a2, S_IRUGO, show_port_data_a2, NULL, 26); -static SENSOR_DEVICE_ATTR(port_28_data_a2, S_IRUGO, show_port_data_a2, NULL, 27); -static SENSOR_DEVICE_ATTR(port_29_data_a2, S_IRUGO, show_port_data_a2, NULL, 28); -static SENSOR_DEVICE_ATTR(port_30_data_a2, S_IRUGO, show_port_data_a2, NULL, 29); -static SENSOR_DEVICE_ATTR(port_31_data_a2, S_IRUGO, show_port_data_a2, NULL, 30); -static SENSOR_DEVICE_ATTR(port_32_data_a2, S_IRUGO, show_port_data_a2, NULL, 31); -static SENSOR_DEVICE_ATTR(port_33_data_a2, S_IRUGO, show_port_data_a2, NULL, 32); -static SENSOR_DEVICE_ATTR(port_34_data_a2, S_IRUGO, show_port_data_a2, NULL, 33); -static SENSOR_DEVICE_ATTR(port_35_data_a2, S_IRUGO, show_port_data_a2, NULL, 34); -static SENSOR_DEVICE_ATTR(port_36_data_a2, S_IRUGO, show_port_data_a2, NULL, 35); -static SENSOR_DEVICE_ATTR(port_37_data_a2, S_IRUGO, show_port_data_a2, NULL, 36); -static SENSOR_DEVICE_ATTR(port_38_data_a2, S_IRUGO, show_port_data_a2, NULL, 37); -static SENSOR_DEVICE_ATTR(port_39_data_a2, S_IRUGO, show_port_data_a2, NULL, 38); -static SENSOR_DEVICE_ATTR(port_40_data_a2, S_IRUGO, show_port_data_a2, NULL, 39); -static SENSOR_DEVICE_ATTR(port_41_data_a2, S_IRUGO, show_port_data_a2, NULL, 40); -static SENSOR_DEVICE_ATTR(port_42_data_a2, S_IRUGO, show_port_data_a2, NULL, 41); -static SENSOR_DEVICE_ATTR(port_43_data_a2, S_IRUGO, show_port_data_a2, NULL, 42); -static SENSOR_DEVICE_ATTR(port_44_data_a2, S_IRUGO, show_port_data_a2, NULL, 43); -static SENSOR_DEVICE_ATTR(port_45_data_a2, S_IRUGO, show_port_data_a2, NULL, 44); -static SENSOR_DEVICE_ATTR(port_46_data_a2, S_IRUGO, show_port_data_a2, NULL, 45); -static SENSOR_DEVICE_ATTR(port_47_data_a2, S_IRUGO, show_port_data_a2, NULL, 46); -static SENSOR_DEVICE_ATTR(port_48_data_a2, S_IRUGO, show_port_data_a2, NULL, 47); -static SENSOR_DEVICE_ATTR(port_49_data_a2, S_IRUGO, show_port_data_a2, NULL, 48); -static SENSOR_DEVICE_ATTR(port_50_data_a2, S_IRUGO, show_port_data_a2, NULL, 49); -static SENSOR_DEVICE_ATTR(port_51_data_a2, S_IRUGO, show_port_data_a2, NULL, 50); -static SENSOR_DEVICE_ATTR(port_52_data_a2, S_IRUGO, show_port_data_a2, NULL, 51); -static SENSOR_DEVICE_ATTR(port_53_data_a2, S_IRUGO, show_port_data_a2, NULL, 52); -static SENSOR_DEVICE_ATTR(port_54_data_a2, S_IRUGO, show_port_data_a2, NULL, 53); -static SENSOR_DEVICE_ATTR(port_55_data_a2, S_IRUGO, show_port_data_a2, NULL, 54); -static SENSOR_DEVICE_ATTR(port_56_data_a2, S_IRUGO, show_port_data_a2, NULL, 55); -static SENSOR_DEVICE_ATTR(port_57_data_a2, S_IRUGO, show_port_data_a2, NULL, 56); -static SENSOR_DEVICE_ATTR(port_58_data_a2, S_IRUGO, show_port_data_a2, NULL, 57); -static SENSOR_DEVICE_ATTR(port_59_data_a2, S_IRUGO, show_port_data_a2, NULL, 58); -static SENSOR_DEVICE_ATTR(port_60_data_a2, S_IRUGO, show_port_data_a2, NULL, 59); -static SENSOR_DEVICE_ATTR(port_61_data_a2, S_IRUGO, show_port_data_a2, NULL, 60); -static SENSOR_DEVICE_ATTR(port_62_data_a2, S_IRUGO, show_port_data_a2, NULL, 61); -static SENSOR_DEVICE_ATTR(port_63_data_a2, S_IRUGO, show_port_data_a2, NULL, 62); -static SENSOR_DEVICE_ATTR(port_64_data_a2, S_IRUGO, show_port_data_a2, NULL, 63); - -static SENSOR_DEVICE_ATTR(port_1_sfp_copper, S_IRUGO, show_port_sfp_copper, NULL, 0); -static SENSOR_DEVICE_ATTR(port_2_sfp_copper, S_IRUGO, show_port_sfp_copper, NULL, 1); -static SENSOR_DEVICE_ATTR(port_3_sfp_copper, S_IRUGO, show_port_sfp_copper, NULL, 2); -static SENSOR_DEVICE_ATTR(port_4_sfp_copper, S_IRUGO, show_port_sfp_copper, NULL, 3); -static SENSOR_DEVICE_ATTR(port_5_sfp_copper, S_IRUGO, show_port_sfp_copper, NULL, 4); -static SENSOR_DEVICE_ATTR(port_6_sfp_copper, S_IRUGO, show_port_sfp_copper, NULL, 5); -static SENSOR_DEVICE_ATTR(port_7_sfp_copper, S_IRUGO, show_port_sfp_copper, NULL, 6); -static SENSOR_DEVICE_ATTR(port_8_sfp_copper, S_IRUGO, show_port_sfp_copper, NULL, 7); -static SENSOR_DEVICE_ATTR(port_9_sfp_copper, S_IRUGO, show_port_sfp_copper, NULL, 8); -static SENSOR_DEVICE_ATTR(port_10_sfp_copper, S_IRUGO, show_port_sfp_copper, NULL, 9); -static SENSOR_DEVICE_ATTR(port_11_sfp_copper, S_IRUGO, show_port_sfp_copper, NULL, 10); -static SENSOR_DEVICE_ATTR(port_12_sfp_copper, S_IRUGO, show_port_sfp_copper, NULL, 11); -static SENSOR_DEVICE_ATTR(port_13_sfp_copper, S_IRUGO, show_port_sfp_copper, NULL, 12); -static SENSOR_DEVICE_ATTR(port_14_sfp_copper, S_IRUGO, show_port_sfp_copper, NULL, 13); -static SENSOR_DEVICE_ATTR(port_15_sfp_copper, S_IRUGO, show_port_sfp_copper, NULL, 14); -static SENSOR_DEVICE_ATTR(port_16_sfp_copper, S_IRUGO, show_port_sfp_copper, NULL, 15); -static SENSOR_DEVICE_ATTR(port_17_sfp_copper, S_IRUGO, show_port_sfp_copper, NULL, 16); -static SENSOR_DEVICE_ATTR(port_18_sfp_copper, S_IRUGO, show_port_sfp_copper, NULL, 17); -static SENSOR_DEVICE_ATTR(port_19_sfp_copper, S_IRUGO, show_port_sfp_copper, NULL, 18); -static SENSOR_DEVICE_ATTR(port_20_sfp_copper, S_IRUGO, show_port_sfp_copper, NULL, 19); -static SENSOR_DEVICE_ATTR(port_21_sfp_copper, S_IRUGO, show_port_sfp_copper, NULL, 20); -static SENSOR_DEVICE_ATTR(port_22_sfp_copper, S_IRUGO, show_port_sfp_copper, NULL, 21); -static SENSOR_DEVICE_ATTR(port_23_sfp_copper, S_IRUGO, show_port_sfp_copper, NULL, 22); -static SENSOR_DEVICE_ATTR(port_24_sfp_copper, S_IRUGO, show_port_sfp_copper, NULL, 23); -static SENSOR_DEVICE_ATTR(port_25_sfp_copper, S_IRUGO, show_port_sfp_copper, NULL, 24); -static SENSOR_DEVICE_ATTR(port_26_sfp_copper, S_IRUGO, show_port_sfp_copper, NULL, 25); -static SENSOR_DEVICE_ATTR(port_27_sfp_copper, S_IRUGO, show_port_sfp_copper, NULL, 26); -static SENSOR_DEVICE_ATTR(port_28_sfp_copper, S_IRUGO, show_port_sfp_copper, NULL, 27); -static SENSOR_DEVICE_ATTR(port_29_sfp_copper, S_IRUGO, show_port_sfp_copper, NULL, 28); -static SENSOR_DEVICE_ATTR(port_30_sfp_copper, S_IRUGO, show_port_sfp_copper, NULL, 29); -static SENSOR_DEVICE_ATTR(port_31_sfp_copper, S_IRUGO, show_port_sfp_copper, NULL, 30); -static SENSOR_DEVICE_ATTR(port_32_sfp_copper, S_IRUGO, show_port_sfp_copper, NULL, 31); -static SENSOR_DEVICE_ATTR(port_33_sfp_copper, S_IRUGO, show_port_sfp_copper, NULL, 32); -static SENSOR_DEVICE_ATTR(port_34_sfp_copper, S_IRUGO, show_port_sfp_copper, NULL, 33); -static SENSOR_DEVICE_ATTR(port_35_sfp_copper, S_IRUGO, show_port_sfp_copper, NULL, 34); -static SENSOR_DEVICE_ATTR(port_36_sfp_copper, S_IRUGO, show_port_sfp_copper, NULL, 35); -static SENSOR_DEVICE_ATTR(port_37_sfp_copper, S_IRUGO, show_port_sfp_copper, NULL, 36); -static SENSOR_DEVICE_ATTR(port_38_sfp_copper, S_IRUGO, show_port_sfp_copper, NULL, 37); -static SENSOR_DEVICE_ATTR(port_39_sfp_copper, S_IRUGO, show_port_sfp_copper, NULL, 38); -static SENSOR_DEVICE_ATTR(port_40_sfp_copper, S_IRUGO, show_port_sfp_copper, NULL, 39); -static SENSOR_DEVICE_ATTR(port_41_sfp_copper, S_IRUGO, show_port_sfp_copper, NULL, 40); -static SENSOR_DEVICE_ATTR(port_42_sfp_copper, S_IRUGO, show_port_sfp_copper, NULL, 41); -static SENSOR_DEVICE_ATTR(port_43_sfp_copper, S_IRUGO, show_port_sfp_copper, NULL, 42); -static SENSOR_DEVICE_ATTR(port_44_sfp_copper, S_IRUGO, show_port_sfp_copper, NULL, 43); -static SENSOR_DEVICE_ATTR(port_45_sfp_copper, S_IRUGO, show_port_sfp_copper, NULL, 44); -static SENSOR_DEVICE_ATTR(port_46_sfp_copper, S_IRUGO, show_port_sfp_copper, NULL, 45); -static SENSOR_DEVICE_ATTR(port_47_sfp_copper, S_IRUGO, show_port_sfp_copper, NULL, 46); -static SENSOR_DEVICE_ATTR(port_48_sfp_copper, S_IRUGO, show_port_sfp_copper, NULL, 47); -static SENSOR_DEVICE_ATTR(port_49_sfp_copper, S_IRUGO, show_port_sfp_copper, NULL, 48); -static SENSOR_DEVICE_ATTR(port_50_sfp_copper, S_IRUGO, show_port_sfp_copper, NULL, 49); -static SENSOR_DEVICE_ATTR(port_51_sfp_copper, S_IRUGO, show_port_sfp_copper, NULL, 50); -static SENSOR_DEVICE_ATTR(port_52_sfp_copper, S_IRUGO, show_port_sfp_copper, NULL, 51); -static SENSOR_DEVICE_ATTR(port_53_sfp_copper, S_IRUGO, show_port_sfp_copper, NULL, 52); -static SENSOR_DEVICE_ATTR(port_54_sfp_copper, S_IRUGO, show_port_sfp_copper, NULL, 53); -static SENSOR_DEVICE_ATTR(port_55_sfp_copper, S_IRUGO, show_port_sfp_copper, NULL, 54); -static SENSOR_DEVICE_ATTR(port_56_sfp_copper, S_IRUGO, show_port_sfp_copper, NULL, 55); -static SENSOR_DEVICE_ATTR(port_57_sfp_copper, S_IRUGO, show_port_sfp_copper, NULL, 56); -static SENSOR_DEVICE_ATTR(port_58_sfp_copper, S_IRUGO, show_port_sfp_copper, NULL, 57); -static SENSOR_DEVICE_ATTR(port_59_sfp_copper, S_IRUGO, show_port_sfp_copper, NULL, 58); -static SENSOR_DEVICE_ATTR(port_60_sfp_copper, S_IRUGO, show_port_sfp_copper, NULL, 59); -static SENSOR_DEVICE_ATTR(port_61_sfp_copper, S_IRUGO, show_port_sfp_copper, NULL, 60); -static SENSOR_DEVICE_ATTR(port_62_sfp_copper, S_IRUGO, show_port_sfp_copper, NULL, 61); -static SENSOR_DEVICE_ATTR(port_63_sfp_copper, S_IRUGO, show_port_sfp_copper, NULL, 62); -static SENSOR_DEVICE_ATTR(port_64_sfp_copper, S_IRUGO, show_port_sfp_copper, NULL, 63); - -static SENSOR_DEVICE_ATTR(port_1_abs, S_IRUGO, show_port_abs, NULL, 0); -static SENSOR_DEVICE_ATTR(port_2_abs, S_IRUGO, show_port_abs, NULL, 1); -static SENSOR_DEVICE_ATTR(port_3_abs, S_IRUGO, show_port_abs, NULL, 2); -static SENSOR_DEVICE_ATTR(port_4_abs, S_IRUGO, show_port_abs, NULL, 3); -static SENSOR_DEVICE_ATTR(port_5_abs, S_IRUGO, show_port_abs, NULL, 4); -static SENSOR_DEVICE_ATTR(port_6_abs, S_IRUGO, show_port_abs, NULL, 5); -static SENSOR_DEVICE_ATTR(port_7_abs, S_IRUGO, show_port_abs, NULL, 6); -static SENSOR_DEVICE_ATTR(port_8_abs, S_IRUGO, show_port_abs, NULL, 7); -static SENSOR_DEVICE_ATTR(port_9_abs, S_IRUGO, show_port_abs, NULL, 8); -static SENSOR_DEVICE_ATTR(port_10_abs, S_IRUGO, show_port_abs, NULL, 9); -static SENSOR_DEVICE_ATTR(port_11_abs, S_IRUGO, show_port_abs, NULL, 10); -static SENSOR_DEVICE_ATTR(port_12_abs, S_IRUGO, show_port_abs, NULL, 11); -static SENSOR_DEVICE_ATTR(port_13_abs, S_IRUGO, show_port_abs, NULL, 12); -static SENSOR_DEVICE_ATTR(port_14_abs, S_IRUGO, show_port_abs, NULL, 13); -static SENSOR_DEVICE_ATTR(port_15_abs, S_IRUGO, show_port_abs, NULL, 14); -static SENSOR_DEVICE_ATTR(port_16_abs, S_IRUGO, show_port_abs, NULL, 15); -static SENSOR_DEVICE_ATTR(port_17_abs, S_IRUGO, show_port_abs, NULL, 16); -static SENSOR_DEVICE_ATTR(port_18_abs, S_IRUGO, show_port_abs, NULL, 17); -static SENSOR_DEVICE_ATTR(port_19_abs, S_IRUGO, show_port_abs, NULL, 18); -static SENSOR_DEVICE_ATTR(port_20_abs, S_IRUGO, show_port_abs, NULL, 19); -static SENSOR_DEVICE_ATTR(port_21_abs, S_IRUGO, show_port_abs, NULL, 20); -static SENSOR_DEVICE_ATTR(port_22_abs, S_IRUGO, show_port_abs, NULL, 21); -static SENSOR_DEVICE_ATTR(port_23_abs, S_IRUGO, show_port_abs, NULL, 22); -static SENSOR_DEVICE_ATTR(port_24_abs, S_IRUGO, show_port_abs, NULL, 23); -static SENSOR_DEVICE_ATTR(port_25_abs, S_IRUGO, show_port_abs, NULL, 24); -static SENSOR_DEVICE_ATTR(port_26_abs, S_IRUGO, show_port_abs, NULL, 25); -static SENSOR_DEVICE_ATTR(port_27_abs, S_IRUGO, show_port_abs, NULL, 26); -static SENSOR_DEVICE_ATTR(port_28_abs, S_IRUGO, show_port_abs, NULL, 27); -static SENSOR_DEVICE_ATTR(port_29_abs, S_IRUGO, show_port_abs, NULL, 28); -static SENSOR_DEVICE_ATTR(port_30_abs, S_IRUGO, show_port_abs, NULL, 29); -static SENSOR_DEVICE_ATTR(port_31_abs, S_IRUGO, show_port_abs, NULL, 30); -static SENSOR_DEVICE_ATTR(port_32_abs, S_IRUGO, show_port_abs, NULL, 31); -static SENSOR_DEVICE_ATTR(port_33_abs, S_IRUGO, show_port_abs, NULL, 32); -static SENSOR_DEVICE_ATTR(port_34_abs, S_IRUGO, show_port_abs, NULL, 33); -static SENSOR_DEVICE_ATTR(port_35_abs, S_IRUGO, show_port_abs, NULL, 34); -static SENSOR_DEVICE_ATTR(port_36_abs, S_IRUGO, show_port_abs, NULL, 35); -static SENSOR_DEVICE_ATTR(port_37_abs, S_IRUGO, show_port_abs, NULL, 36); -static SENSOR_DEVICE_ATTR(port_38_abs, S_IRUGO, show_port_abs, NULL, 37); -static SENSOR_DEVICE_ATTR(port_39_abs, S_IRUGO, show_port_abs, NULL, 38); -static SENSOR_DEVICE_ATTR(port_40_abs, S_IRUGO, show_port_abs, NULL, 39); -static SENSOR_DEVICE_ATTR(port_41_abs, S_IRUGO, show_port_abs, NULL, 40); -static SENSOR_DEVICE_ATTR(port_42_abs, S_IRUGO, show_port_abs, NULL, 41); -static SENSOR_DEVICE_ATTR(port_43_abs, S_IRUGO, show_port_abs, NULL, 42); -static SENSOR_DEVICE_ATTR(port_44_abs, S_IRUGO, show_port_abs, NULL, 43); -static SENSOR_DEVICE_ATTR(port_45_abs, S_IRUGO, show_port_abs, NULL, 44); -static SENSOR_DEVICE_ATTR(port_46_abs, S_IRUGO, show_port_abs, NULL, 45); -static SENSOR_DEVICE_ATTR(port_47_abs, S_IRUGO, show_port_abs, NULL, 46); -static SENSOR_DEVICE_ATTR(port_48_abs, S_IRUGO, show_port_abs, NULL, 47); -static SENSOR_DEVICE_ATTR(port_49_abs, S_IRUGO, show_port_abs, NULL, 48); -static SENSOR_DEVICE_ATTR(port_50_abs, S_IRUGO, show_port_abs, NULL, 49); -static SENSOR_DEVICE_ATTR(port_51_abs, S_IRUGO, show_port_abs, NULL, 50); -static SENSOR_DEVICE_ATTR(port_52_abs, S_IRUGO, show_port_abs, NULL, 51); -static SENSOR_DEVICE_ATTR(port_53_abs, S_IRUGO, show_port_abs, NULL, 52); -static SENSOR_DEVICE_ATTR(port_54_abs, S_IRUGO, show_port_abs, NULL, 53); -static SENSOR_DEVICE_ATTR(port_55_abs, S_IRUGO, show_port_abs, NULL, 54); -static SENSOR_DEVICE_ATTR(port_56_abs, S_IRUGO, show_port_abs, NULL, 55); -static SENSOR_DEVICE_ATTR(port_57_abs, S_IRUGO, show_port_abs, NULL, 56); -static SENSOR_DEVICE_ATTR(port_58_abs, S_IRUGO, show_port_abs, NULL, 57); -static SENSOR_DEVICE_ATTR(port_59_abs, S_IRUGO, show_port_abs, NULL, 58); -static SENSOR_DEVICE_ATTR(port_60_abs, S_IRUGO, show_port_abs, NULL, 59); -static SENSOR_DEVICE_ATTR(port_61_abs, S_IRUGO, show_port_abs, NULL, 60); -static SENSOR_DEVICE_ATTR(port_62_abs, S_IRUGO, show_port_abs, NULL, 61); -static SENSOR_DEVICE_ATTR(port_63_abs, S_IRUGO, show_port_abs, NULL, 62); -static SENSOR_DEVICE_ATTR(port_64_abs, S_IRUGO, show_port_abs, NULL, 63); - -static SENSOR_DEVICE_ATTR(port_1_rxlos, S_IRUGO, show_port_rxlos, NULL, 0); -static SENSOR_DEVICE_ATTR(port_2_rxlos, S_IRUGO, show_port_rxlos, NULL, 1); -static SENSOR_DEVICE_ATTR(port_3_rxlos, S_IRUGO, show_port_rxlos, NULL, 2); -static SENSOR_DEVICE_ATTR(port_4_rxlos, S_IRUGO, show_port_rxlos, NULL, 3); -static SENSOR_DEVICE_ATTR(port_5_rxlos, S_IRUGO, show_port_rxlos, NULL, 4); -static SENSOR_DEVICE_ATTR(port_6_rxlos, S_IRUGO, show_port_rxlos, NULL, 5); -static SENSOR_DEVICE_ATTR(port_7_rxlos, S_IRUGO, show_port_rxlos, NULL, 6); -static SENSOR_DEVICE_ATTR(port_8_rxlos, S_IRUGO, show_port_rxlos, NULL, 7); -static SENSOR_DEVICE_ATTR(port_9_rxlos, S_IRUGO, show_port_rxlos, NULL, 8); -static SENSOR_DEVICE_ATTR(port_10_rxlos, S_IRUGO, show_port_rxlos, NULL, 9); -static SENSOR_DEVICE_ATTR(port_11_rxlos, S_IRUGO, show_port_rxlos, NULL, 10); -static SENSOR_DEVICE_ATTR(port_12_rxlos, S_IRUGO, show_port_rxlos, NULL, 11); -static SENSOR_DEVICE_ATTR(port_13_rxlos, S_IRUGO, show_port_rxlos, NULL, 12); -static SENSOR_DEVICE_ATTR(port_14_rxlos, S_IRUGO, show_port_rxlos, NULL, 13); -static SENSOR_DEVICE_ATTR(port_15_rxlos, S_IRUGO, show_port_rxlos, NULL, 14); -static SENSOR_DEVICE_ATTR(port_16_rxlos, S_IRUGO, show_port_rxlos, NULL, 15); -static SENSOR_DEVICE_ATTR(port_17_rxlos, S_IRUGO, show_port_rxlos, NULL, 16); -static SENSOR_DEVICE_ATTR(port_18_rxlos, S_IRUGO, show_port_rxlos, NULL, 17); -static SENSOR_DEVICE_ATTR(port_19_rxlos, S_IRUGO, show_port_rxlos, NULL, 18); -static SENSOR_DEVICE_ATTR(port_20_rxlos, S_IRUGO, show_port_rxlos, NULL, 19); -static SENSOR_DEVICE_ATTR(port_21_rxlos, S_IRUGO, show_port_rxlos, NULL, 20); -static SENSOR_DEVICE_ATTR(port_22_rxlos, S_IRUGO, show_port_rxlos, NULL, 21); -static SENSOR_DEVICE_ATTR(port_23_rxlos, S_IRUGO, show_port_rxlos, NULL, 22); -static SENSOR_DEVICE_ATTR(port_24_rxlos, S_IRUGO, show_port_rxlos, NULL, 23); -static SENSOR_DEVICE_ATTR(port_25_rxlos, S_IRUGO, show_port_rxlos, NULL, 24); -static SENSOR_DEVICE_ATTR(port_26_rxlos, S_IRUGO, show_port_rxlos, NULL, 25); -static SENSOR_DEVICE_ATTR(port_27_rxlos, S_IRUGO, show_port_rxlos, NULL, 26); -static SENSOR_DEVICE_ATTR(port_28_rxlos, S_IRUGO, show_port_rxlos, NULL, 27); -static SENSOR_DEVICE_ATTR(port_29_rxlos, S_IRUGO, show_port_rxlos, NULL, 28); -static SENSOR_DEVICE_ATTR(port_30_rxlos, S_IRUGO, show_port_rxlos, NULL, 29); -static SENSOR_DEVICE_ATTR(port_31_rxlos, S_IRUGO, show_port_rxlos, NULL, 30); -static SENSOR_DEVICE_ATTR(port_32_rxlos, S_IRUGO, show_port_rxlos, NULL, 31); -static SENSOR_DEVICE_ATTR(port_33_rxlos, S_IRUGO, show_port_rxlos, NULL, 32); -static SENSOR_DEVICE_ATTR(port_34_rxlos, S_IRUGO, show_port_rxlos, NULL, 33); -static SENSOR_DEVICE_ATTR(port_35_rxlos, S_IRUGO, show_port_rxlos, NULL, 34); -static SENSOR_DEVICE_ATTR(port_36_rxlos, S_IRUGO, show_port_rxlos, NULL, 35); -static SENSOR_DEVICE_ATTR(port_37_rxlos, S_IRUGO, show_port_rxlos, NULL, 36); -static SENSOR_DEVICE_ATTR(port_38_rxlos, S_IRUGO, show_port_rxlos, NULL, 37); -static SENSOR_DEVICE_ATTR(port_39_rxlos, S_IRUGO, show_port_rxlos, NULL, 38); -static SENSOR_DEVICE_ATTR(port_40_rxlos, S_IRUGO, show_port_rxlos, NULL, 39); -static SENSOR_DEVICE_ATTR(port_41_rxlos, S_IRUGO, show_port_rxlos, NULL, 40); -static SENSOR_DEVICE_ATTR(port_42_rxlos, S_IRUGO, show_port_rxlos, NULL, 41); -static SENSOR_DEVICE_ATTR(port_43_rxlos, S_IRUGO, show_port_rxlos, NULL, 42); -static SENSOR_DEVICE_ATTR(port_44_rxlos, S_IRUGO, show_port_rxlos, NULL, 43); -static SENSOR_DEVICE_ATTR(port_45_rxlos, S_IRUGO, show_port_rxlos, NULL, 44); -static SENSOR_DEVICE_ATTR(port_46_rxlos, S_IRUGO, show_port_rxlos, NULL, 45); -static SENSOR_DEVICE_ATTR(port_47_rxlos, S_IRUGO, show_port_rxlos, NULL, 46); -static SENSOR_DEVICE_ATTR(port_48_rxlos, S_IRUGO, show_port_rxlos, NULL, 47); - -static SENSOR_DEVICE_ATTR(port_1_tx_disable, S_IWUSR | S_IRUGO, show_port_tx_disable, set_port_tx_disable, 0); -static SENSOR_DEVICE_ATTR(port_2_tx_disable, S_IWUSR | S_IRUGO, show_port_tx_disable, set_port_tx_disable, 1); -static SENSOR_DEVICE_ATTR(port_3_tx_disable, S_IWUSR | S_IRUGO, show_port_tx_disable, set_port_tx_disable, 2); -static SENSOR_DEVICE_ATTR(port_4_tx_disable, S_IWUSR | S_IRUGO, show_port_tx_disable, set_port_tx_disable, 3); -static SENSOR_DEVICE_ATTR(port_5_tx_disable, S_IWUSR | S_IRUGO, show_port_tx_disable, set_port_tx_disable, 4); -static SENSOR_DEVICE_ATTR(port_6_tx_disable, S_IWUSR | S_IRUGO, show_port_tx_disable, set_port_tx_disable, 5); -static SENSOR_DEVICE_ATTR(port_7_tx_disable, S_IWUSR | S_IRUGO, show_port_tx_disable, set_port_tx_disable, 6); -static SENSOR_DEVICE_ATTR(port_8_tx_disable, S_IWUSR | S_IRUGO, show_port_tx_disable, set_port_tx_disable, 7); -static SENSOR_DEVICE_ATTR(port_9_tx_disable, S_IWUSR | S_IRUGO, show_port_tx_disable, set_port_tx_disable, 8); -static SENSOR_DEVICE_ATTR(port_10_tx_disable, S_IWUSR | S_IRUGO, show_port_tx_disable, set_port_tx_disable, 9); -static SENSOR_DEVICE_ATTR(port_11_tx_disable, S_IWUSR | S_IRUGO, show_port_tx_disable, set_port_tx_disable, 10); -static SENSOR_DEVICE_ATTR(port_12_tx_disable, S_IWUSR | S_IRUGO, show_port_tx_disable, set_port_tx_disable, 11); -static SENSOR_DEVICE_ATTR(port_13_tx_disable, S_IWUSR | S_IRUGO, show_port_tx_disable, set_port_tx_disable, 12); -static SENSOR_DEVICE_ATTR(port_14_tx_disable, S_IWUSR | S_IRUGO, show_port_tx_disable, set_port_tx_disable, 13); -static SENSOR_DEVICE_ATTR(port_15_tx_disable, S_IWUSR | S_IRUGO, show_port_tx_disable, set_port_tx_disable, 14); -static SENSOR_DEVICE_ATTR(port_16_tx_disable, S_IWUSR | S_IRUGO, show_port_tx_disable, set_port_tx_disable, 15); -static SENSOR_DEVICE_ATTR(port_17_tx_disable, S_IWUSR | S_IRUGO, show_port_tx_disable, set_port_tx_disable, 16); -static SENSOR_DEVICE_ATTR(port_18_tx_disable, S_IWUSR | S_IRUGO, show_port_tx_disable, set_port_tx_disable, 17); -static SENSOR_DEVICE_ATTR(port_19_tx_disable, S_IWUSR | S_IRUGO, show_port_tx_disable, set_port_tx_disable, 18); -static SENSOR_DEVICE_ATTR(port_20_tx_disable, S_IWUSR | S_IRUGO, show_port_tx_disable, set_port_tx_disable, 19); -static SENSOR_DEVICE_ATTR(port_21_tx_disable, S_IWUSR | S_IRUGO, show_port_tx_disable, set_port_tx_disable, 20); -static SENSOR_DEVICE_ATTR(port_22_tx_disable, S_IWUSR | S_IRUGO, show_port_tx_disable, set_port_tx_disable, 21); -static SENSOR_DEVICE_ATTR(port_23_tx_disable, S_IWUSR | S_IRUGO, show_port_tx_disable, set_port_tx_disable, 22); -static SENSOR_DEVICE_ATTR(port_24_tx_disable, S_IWUSR | S_IRUGO, show_port_tx_disable, set_port_tx_disable, 23); -static SENSOR_DEVICE_ATTR(port_25_tx_disable, S_IWUSR | S_IRUGO, show_port_tx_disable, set_port_tx_disable, 24); -static SENSOR_DEVICE_ATTR(port_26_tx_disable, S_IWUSR | S_IRUGO, show_port_tx_disable, set_port_tx_disable, 25); -static SENSOR_DEVICE_ATTR(port_27_tx_disable, S_IWUSR | S_IRUGO, show_port_tx_disable, set_port_tx_disable, 26); -static SENSOR_DEVICE_ATTR(port_28_tx_disable, S_IWUSR | S_IRUGO, show_port_tx_disable, set_port_tx_disable, 27); -static SENSOR_DEVICE_ATTR(port_29_tx_disable, S_IWUSR | S_IRUGO, show_port_tx_disable, set_port_tx_disable, 28); -static SENSOR_DEVICE_ATTR(port_30_tx_disable, S_IWUSR | S_IRUGO, show_port_tx_disable, set_port_tx_disable, 29); -static SENSOR_DEVICE_ATTR(port_31_tx_disable, S_IWUSR | S_IRUGO, show_port_tx_disable, set_port_tx_disable, 30); -static SENSOR_DEVICE_ATTR(port_32_tx_disable, S_IWUSR | S_IRUGO, show_port_tx_disable, set_port_tx_disable, 31); -static SENSOR_DEVICE_ATTR(port_33_tx_disable, S_IWUSR | S_IRUGO, show_port_tx_disable, set_port_tx_disable, 32); -static SENSOR_DEVICE_ATTR(port_34_tx_disable, S_IWUSR | S_IRUGO, show_port_tx_disable, set_port_tx_disable, 33); -static SENSOR_DEVICE_ATTR(port_35_tx_disable, S_IWUSR | S_IRUGO, show_port_tx_disable, set_port_tx_disable, 34); -static SENSOR_DEVICE_ATTR(port_36_tx_disable, S_IWUSR | S_IRUGO, show_port_tx_disable, set_port_tx_disable, 35); -static SENSOR_DEVICE_ATTR(port_37_tx_disable, S_IWUSR | S_IRUGO, show_port_tx_disable, set_port_tx_disable, 36); -static SENSOR_DEVICE_ATTR(port_38_tx_disable, S_IWUSR | S_IRUGO, show_port_tx_disable, set_port_tx_disable, 37); -static SENSOR_DEVICE_ATTR(port_39_tx_disable, S_IWUSR | S_IRUGO, show_port_tx_disable, set_port_tx_disable, 38); -static SENSOR_DEVICE_ATTR(port_40_tx_disable, S_IWUSR | S_IRUGO, show_port_tx_disable, set_port_tx_disable, 39); -static SENSOR_DEVICE_ATTR(port_41_tx_disable, S_IWUSR | S_IRUGO, show_port_tx_disable, set_port_tx_disable, 40); -static SENSOR_DEVICE_ATTR(port_42_tx_disable, S_IWUSR | S_IRUGO, show_port_tx_disable, set_port_tx_disable, 41); -static SENSOR_DEVICE_ATTR(port_43_tx_disable, S_IWUSR | S_IRUGO, show_port_tx_disable, set_port_tx_disable, 42); -static SENSOR_DEVICE_ATTR(port_44_tx_disable, S_IWUSR | S_IRUGO, show_port_tx_disable, set_port_tx_disable, 43); -static SENSOR_DEVICE_ATTR(port_45_tx_disable, S_IWUSR | S_IRUGO, show_port_tx_disable, set_port_tx_disable, 44); -static SENSOR_DEVICE_ATTR(port_46_tx_disable, S_IWUSR | S_IRUGO, show_port_tx_disable, set_port_tx_disable, 45); -static SENSOR_DEVICE_ATTR(port_47_tx_disable, S_IWUSR | S_IRUGO, show_port_tx_disable, set_port_tx_disable, 46); -static SENSOR_DEVICE_ATTR(port_48_tx_disable, S_IWUSR | S_IRUGO, show_port_tx_disable, set_port_tx_disable, 47); - -static SENSOR_DEVICE_ATTR(port_1_rate_select, S_IWUSR | S_IRUGO, show_port_rate_select, set_port_rate_select, 0); -static SENSOR_DEVICE_ATTR(port_2_rate_select, S_IWUSR | S_IRUGO, show_port_rate_select, set_port_rate_select, 1); -static SENSOR_DEVICE_ATTR(port_3_rate_select, S_IWUSR | S_IRUGO, show_port_rate_select, set_port_rate_select, 2); -static SENSOR_DEVICE_ATTR(port_4_rate_select, S_IWUSR | S_IRUGO, show_port_rate_select, set_port_rate_select, 3); -static SENSOR_DEVICE_ATTR(port_5_rate_select, S_IWUSR | S_IRUGO, show_port_rate_select, set_port_rate_select, 4); -static SENSOR_DEVICE_ATTR(port_6_rate_select, S_IWUSR | S_IRUGO, show_port_rate_select, set_port_rate_select, 5); -static SENSOR_DEVICE_ATTR(port_7_rate_select, S_IWUSR | S_IRUGO, show_port_rate_select, set_port_rate_select, 6); -static SENSOR_DEVICE_ATTR(port_8_rate_select, S_IWUSR | S_IRUGO, show_port_rate_select, set_port_rate_select, 7); -static SENSOR_DEVICE_ATTR(port_9_rate_select, S_IWUSR | S_IRUGO, show_port_rate_select, set_port_rate_select, 8); -static SENSOR_DEVICE_ATTR(port_10_rate_select, S_IWUSR | S_IRUGO, show_port_rate_select, set_port_rate_select, 9); -static SENSOR_DEVICE_ATTR(port_11_rate_select, S_IWUSR | S_IRUGO, show_port_rate_select, set_port_rate_select, 10); -static SENSOR_DEVICE_ATTR(port_12_rate_select, S_IWUSR | S_IRUGO, show_port_rate_select, set_port_rate_select, 11); -static SENSOR_DEVICE_ATTR(port_13_rate_select, S_IWUSR | S_IRUGO, show_port_rate_select, set_port_rate_select, 12); -static SENSOR_DEVICE_ATTR(port_14_rate_select, S_IWUSR | S_IRUGO, show_port_rate_select, set_port_rate_select, 13); -static SENSOR_DEVICE_ATTR(port_15_rate_select, S_IWUSR | S_IRUGO, show_port_rate_select, set_port_rate_select, 14); -static SENSOR_DEVICE_ATTR(port_16_rate_select, S_IWUSR | S_IRUGO, show_port_rate_select, set_port_rate_select, 15); -static SENSOR_DEVICE_ATTR(port_17_rate_select, S_IWUSR | S_IRUGO, show_port_rate_select, set_port_rate_select, 16); -static SENSOR_DEVICE_ATTR(port_18_rate_select, S_IWUSR | S_IRUGO, show_port_rate_select, set_port_rate_select, 17); -static SENSOR_DEVICE_ATTR(port_19_rate_select, S_IWUSR | S_IRUGO, show_port_rate_select, set_port_rate_select, 18); -static SENSOR_DEVICE_ATTR(port_20_rate_select, S_IWUSR | S_IRUGO, show_port_rate_select, set_port_rate_select, 19); -static SENSOR_DEVICE_ATTR(port_21_rate_select, S_IWUSR | S_IRUGO, show_port_rate_select, set_port_rate_select, 20); -static SENSOR_DEVICE_ATTR(port_22_rate_select, S_IWUSR | S_IRUGO, show_port_rate_select, set_port_rate_select, 21); -static SENSOR_DEVICE_ATTR(port_23_rate_select, S_IWUSR | S_IRUGO, show_port_rate_select, set_port_rate_select, 22); -static SENSOR_DEVICE_ATTR(port_24_rate_select, S_IWUSR | S_IRUGO, show_port_rate_select, set_port_rate_select, 23); -static SENSOR_DEVICE_ATTR(port_25_rate_select, S_IWUSR | S_IRUGO, show_port_rate_select, set_port_rate_select, 24); -static SENSOR_DEVICE_ATTR(port_26_rate_select, S_IWUSR | S_IRUGO, show_port_rate_select, set_port_rate_select, 25); -static SENSOR_DEVICE_ATTR(port_27_rate_select, S_IWUSR | S_IRUGO, show_port_rate_select, set_port_rate_select, 26); -static SENSOR_DEVICE_ATTR(port_28_rate_select, S_IWUSR | S_IRUGO, show_port_rate_select, set_port_rate_select, 27); -static SENSOR_DEVICE_ATTR(port_29_rate_select, S_IWUSR | S_IRUGO, show_port_rate_select, set_port_rate_select, 28); -static SENSOR_DEVICE_ATTR(port_30_rate_select, S_IWUSR | S_IRUGO, show_port_rate_select, set_port_rate_select, 29); -static SENSOR_DEVICE_ATTR(port_31_rate_select, S_IWUSR | S_IRUGO, show_port_rate_select, set_port_rate_select, 30); -static SENSOR_DEVICE_ATTR(port_32_rate_select, S_IWUSR | S_IRUGO, show_port_rate_select, set_port_rate_select, 31); -static SENSOR_DEVICE_ATTR(port_33_rate_select, S_IWUSR | S_IRUGO, show_port_rate_select, set_port_rate_select, 32); -static SENSOR_DEVICE_ATTR(port_34_rate_select, S_IWUSR | S_IRUGO, show_port_rate_select, set_port_rate_select, 33); -static SENSOR_DEVICE_ATTR(port_35_rate_select, S_IWUSR | S_IRUGO, show_port_rate_select, set_port_rate_select, 34); -static SENSOR_DEVICE_ATTR(port_36_rate_select, S_IWUSR | S_IRUGO, show_port_rate_select, set_port_rate_select, 35); -static SENSOR_DEVICE_ATTR(port_37_rate_select, S_IWUSR | S_IRUGO, show_port_rate_select, set_port_rate_select, 36); -static SENSOR_DEVICE_ATTR(port_38_rate_select, S_IWUSR | S_IRUGO, show_port_rate_select, set_port_rate_select, 37); -static SENSOR_DEVICE_ATTR(port_39_rate_select, S_IWUSR | S_IRUGO, show_port_rate_select, set_port_rate_select, 38); -static SENSOR_DEVICE_ATTR(port_40_rate_select, S_IWUSR | S_IRUGO, show_port_rate_select, set_port_rate_select, 39); -static SENSOR_DEVICE_ATTR(port_41_rate_select, S_IWUSR | S_IRUGO, show_port_rate_select, set_port_rate_select, 40); -static SENSOR_DEVICE_ATTR(port_42_rate_select, S_IWUSR | S_IRUGO, show_port_rate_select, set_port_rate_select, 41); -static SENSOR_DEVICE_ATTR(port_43_rate_select, S_IWUSR | S_IRUGO, show_port_rate_select, set_port_rate_select, 42); -static SENSOR_DEVICE_ATTR(port_44_rate_select, S_IWUSR | S_IRUGO, show_port_rate_select, set_port_rate_select, 43); -static SENSOR_DEVICE_ATTR(port_45_rate_select, S_IWUSR | S_IRUGO, show_port_rate_select, set_port_rate_select, 44); -static SENSOR_DEVICE_ATTR(port_46_rate_select, S_IWUSR | S_IRUGO, show_port_rate_select, set_port_rate_select, 45); -static SENSOR_DEVICE_ATTR(port_47_rate_select, S_IWUSR | S_IRUGO, show_port_rate_select, set_port_rate_select, 46); -static SENSOR_DEVICE_ATTR(port_48_rate_select, S_IWUSR | S_IRUGO, show_port_rate_select, set_port_rate_select, 47); - -static SENSOR_DEVICE_ATTR(fan1_abs, S_IRUGO, show_fan_abs, NULL, 0); -static SENSOR_DEVICE_ATTR(fan2_abs, S_IRUGO, show_fan_abs, NULL, 1); -static SENSOR_DEVICE_ATTR(fan3_abs, S_IRUGO, show_fan_abs, NULL, 2); -static SENSOR_DEVICE_ATTR(fan4_abs, S_IRUGO, show_fan_abs, NULL, 3); -static SENSOR_DEVICE_ATTR(fan5_abs, S_IRUGO, show_fan_abs, NULL, 4); - -static SENSOR_DEVICE_ATTR(fan1_dir, S_IRUGO, show_fan_dir, NULL, 0); -static SENSOR_DEVICE_ATTR(fan2_dir, S_IRUGO, show_fan_dir, NULL, 1); -static SENSOR_DEVICE_ATTR(fan3_dir, S_IRUGO, show_fan_dir, NULL, 2); -static SENSOR_DEVICE_ATTR(fan4_dir, S_IRUGO, show_fan_dir, NULL, 3); -static SENSOR_DEVICE_ATTR(fan5_dir, S_IRUGO, show_fan_dir, NULL, 4); - -static SENSOR_DEVICE_ATTR(psu1_eeprom, S_IRUGO, show_psu_eeprom, NULL, 0); -static SENSOR_DEVICE_ATTR(psu2_eeprom, S_IRUGO, show_psu_eeprom, NULL, 1); - -static SENSOR_DEVICE_ATTR(psu1_vout, S_IRUGO, show_psu_vout, NULL, 0); -static SENSOR_DEVICE_ATTR(psu1_iout, S_IRUGO, show_psu_iout, NULL, 0); -static SENSOR_DEVICE_ATTR(psu1_temp_1, S_IRUGO, show_psu_temp_1, NULL, 0); -static SENSOR_DEVICE_ATTR(psu1_temp_2, S_IRUGO, show_psu_temp_2, NULL, 0); -static SENSOR_DEVICE_ATTR(psu1_fan_speed, S_IRUGO, show_psu_fan_speed, NULL, 0); -static SENSOR_DEVICE_ATTR(psu1_pout, S_IRUGO, show_psu_pout, NULL, 0); -static SENSOR_DEVICE_ATTR(psu1_pin, S_IRUGO, show_psu_pin, NULL, 0); - -static SENSOR_DEVICE_ATTR(psu2_vout, S_IRUGO, show_psu_vout, NULL, 1); -static SENSOR_DEVICE_ATTR(psu2_iout, S_IRUGO, show_psu_iout, NULL, 1); -static SENSOR_DEVICE_ATTR(psu2_temp_1, S_IRUGO, show_psu_temp_1, NULL, 1); -static SENSOR_DEVICE_ATTR(psu2_temp_2, S_IRUGO, show_psu_temp_2, NULL, 1); -static SENSOR_DEVICE_ATTR(psu2_fan_speed, S_IRUGO, show_psu_fan_speed, NULL, 1); -static SENSOR_DEVICE_ATTR(psu2_pout, S_IRUGO, show_psu_pout, NULL, 1); -static SENSOR_DEVICE_ATTR(psu2_pin, S_IRUGO, show_psu_pin, NULL, 1); - -static DEVICE_ATTR(psu_power_off, S_IWUSR, NULL, set_psu_power_off); - -/* lm-sensors compatible feature/subfeature names */ -static SENSOR_DEVICE_ATTR(in12_input, S_IRUGO, show_psu_vout, NULL, 100); -static SENSOR_DEVICE_ATTR(curr12_input, S_IRUGO, show_psu_iout, NULL, 100); -static SENSOR_DEVICE_ATTR(power11_input, S_IRUGO, show_psu_pin, NULL, 100); -static SENSOR_DEVICE_ATTR(power12_input, S_IRUGO, show_psu_pout, NULL, 100); -static SENSOR_DEVICE_ATTR(temp11_input, S_IRUGO, show_psu_temp_1, NULL, 100); -static SENSOR_DEVICE_ATTR(temp12_input, S_IRUGO, show_psu_temp_2, NULL, 100); -static SENSOR_DEVICE_ATTR(fan11_input, S_IRUGO, show_psu_fan_speed, NULL, 100); - -static SENSOR_DEVICE_ATTR(in22_input, S_IRUGO, show_psu_vout, NULL, 101); -static SENSOR_DEVICE_ATTR(curr22_input, S_IRUGO, show_psu_iout, NULL, 101); -static SENSOR_DEVICE_ATTR(power21_input, S_IRUGO, show_psu_pin, NULL, 101); -static SENSOR_DEVICE_ATTR(power22_input, S_IRUGO, show_psu_pout, NULL, 101); -static SENSOR_DEVICE_ATTR(temp21_input, S_IRUGO, show_psu_temp_1, NULL, 101); -static SENSOR_DEVICE_ATTR(temp22_input, S_IRUGO, show_psu_temp_2, NULL, 101); -static SENSOR_DEVICE_ATTR(fan21_input, S_IRUGO, show_psu_fan_speed, NULL, 101); - - -static struct attribute *i2c_bus1_hardware_monitor_attr_huracan[] = { - &dev_attr_eeprom.attr, - &dev_attr_system_led.attr, - &dev_attr_fan_led.attr, - &sensor_dev_attr_psu1_led.dev_attr.attr, - &sensor_dev_attr_psu2_led.dev_attr.attr, - - &sensor_dev_attr_port_1_data_a0.dev_attr.attr, - &sensor_dev_attr_port_2_data_a0.dev_attr.attr, - &sensor_dev_attr_port_3_data_a0.dev_attr.attr, - &sensor_dev_attr_port_4_data_a0.dev_attr.attr, - &sensor_dev_attr_port_5_data_a0.dev_attr.attr, - &sensor_dev_attr_port_6_data_a0.dev_attr.attr, - &sensor_dev_attr_port_7_data_a0.dev_attr.attr, - &sensor_dev_attr_port_8_data_a0.dev_attr.attr, - &sensor_dev_attr_port_9_data_a0.dev_attr.attr, - &sensor_dev_attr_port_10_data_a0.dev_attr.attr, - &sensor_dev_attr_port_11_data_a0.dev_attr.attr, - &sensor_dev_attr_port_12_data_a0.dev_attr.attr, - &sensor_dev_attr_port_13_data_a0.dev_attr.attr, - &sensor_dev_attr_port_14_data_a0.dev_attr.attr, - &sensor_dev_attr_port_15_data_a0.dev_attr.attr, - &sensor_dev_attr_port_16_data_a0.dev_attr.attr, - &sensor_dev_attr_port_17_data_a0.dev_attr.attr, - &sensor_dev_attr_port_18_data_a0.dev_attr.attr, - &sensor_dev_attr_port_19_data_a0.dev_attr.attr, - &sensor_dev_attr_port_20_data_a0.dev_attr.attr, - &sensor_dev_attr_port_21_data_a0.dev_attr.attr, - &sensor_dev_attr_port_22_data_a0.dev_attr.attr, - &sensor_dev_attr_port_23_data_a0.dev_attr.attr, - &sensor_dev_attr_port_24_data_a0.dev_attr.attr, - &sensor_dev_attr_port_25_data_a0.dev_attr.attr, - &sensor_dev_attr_port_26_data_a0.dev_attr.attr, - &sensor_dev_attr_port_27_data_a0.dev_attr.attr, - &sensor_dev_attr_port_28_data_a0.dev_attr.attr, - &sensor_dev_attr_port_29_data_a0.dev_attr.attr, - &sensor_dev_attr_port_30_data_a0.dev_attr.attr, - &sensor_dev_attr_port_31_data_a0.dev_attr.attr, - &sensor_dev_attr_port_32_data_a0.dev_attr.attr, - - &sensor_dev_attr_port_1_data_a2.dev_attr.attr, - &sensor_dev_attr_port_2_data_a2.dev_attr.attr, - &sensor_dev_attr_port_3_data_a2.dev_attr.attr, - &sensor_dev_attr_port_4_data_a2.dev_attr.attr, - &sensor_dev_attr_port_5_data_a2.dev_attr.attr, - &sensor_dev_attr_port_6_data_a2.dev_attr.attr, - &sensor_dev_attr_port_7_data_a2.dev_attr.attr, - &sensor_dev_attr_port_8_data_a2.dev_attr.attr, - &sensor_dev_attr_port_9_data_a2.dev_attr.attr, - &sensor_dev_attr_port_10_data_a2.dev_attr.attr, - &sensor_dev_attr_port_11_data_a2.dev_attr.attr, - &sensor_dev_attr_port_12_data_a2.dev_attr.attr, - &sensor_dev_attr_port_13_data_a2.dev_attr.attr, - &sensor_dev_attr_port_14_data_a2.dev_attr.attr, - &sensor_dev_attr_port_15_data_a2.dev_attr.attr, - &sensor_dev_attr_port_16_data_a2.dev_attr.attr, - &sensor_dev_attr_port_17_data_a2.dev_attr.attr, - &sensor_dev_attr_port_18_data_a2.dev_attr.attr, - &sensor_dev_attr_port_19_data_a2.dev_attr.attr, - &sensor_dev_attr_port_20_data_a2.dev_attr.attr, - &sensor_dev_attr_port_21_data_a2.dev_attr.attr, - &sensor_dev_attr_port_22_data_a2.dev_attr.attr, - &sensor_dev_attr_port_23_data_a2.dev_attr.attr, - &sensor_dev_attr_port_24_data_a2.dev_attr.attr, - &sensor_dev_attr_port_25_data_a2.dev_attr.attr, - &sensor_dev_attr_port_26_data_a2.dev_attr.attr, - &sensor_dev_attr_port_27_data_a2.dev_attr.attr, - &sensor_dev_attr_port_28_data_a2.dev_attr.attr, - &sensor_dev_attr_port_29_data_a2.dev_attr.attr, - &sensor_dev_attr_port_30_data_a2.dev_attr.attr, - &sensor_dev_attr_port_31_data_a2.dev_attr.attr, - &sensor_dev_attr_port_32_data_a2.dev_attr.attr, - - &sensor_dev_attr_port_1_sfp_copper.dev_attr.attr, - &sensor_dev_attr_port_2_sfp_copper.dev_attr.attr, - &sensor_dev_attr_port_3_sfp_copper.dev_attr.attr, - &sensor_dev_attr_port_4_sfp_copper.dev_attr.attr, - &sensor_dev_attr_port_5_sfp_copper.dev_attr.attr, - &sensor_dev_attr_port_6_sfp_copper.dev_attr.attr, - &sensor_dev_attr_port_7_sfp_copper.dev_attr.attr, - &sensor_dev_attr_port_8_sfp_copper.dev_attr.attr, - &sensor_dev_attr_port_9_sfp_copper.dev_attr.attr, - &sensor_dev_attr_port_10_sfp_copper.dev_attr.attr, - &sensor_dev_attr_port_11_sfp_copper.dev_attr.attr, - &sensor_dev_attr_port_12_sfp_copper.dev_attr.attr, - &sensor_dev_attr_port_13_sfp_copper.dev_attr.attr, - &sensor_dev_attr_port_14_sfp_copper.dev_attr.attr, - &sensor_dev_attr_port_15_sfp_copper.dev_attr.attr, - &sensor_dev_attr_port_16_sfp_copper.dev_attr.attr, - &sensor_dev_attr_port_17_sfp_copper.dev_attr.attr, - &sensor_dev_attr_port_18_sfp_copper.dev_attr.attr, - &sensor_dev_attr_port_19_sfp_copper.dev_attr.attr, - &sensor_dev_attr_port_20_sfp_copper.dev_attr.attr, - &sensor_dev_attr_port_21_sfp_copper.dev_attr.attr, - &sensor_dev_attr_port_22_sfp_copper.dev_attr.attr, - &sensor_dev_attr_port_23_sfp_copper.dev_attr.attr, - &sensor_dev_attr_port_24_sfp_copper.dev_attr.attr, - &sensor_dev_attr_port_25_sfp_copper.dev_attr.attr, - &sensor_dev_attr_port_26_sfp_copper.dev_attr.attr, - &sensor_dev_attr_port_27_sfp_copper.dev_attr.attr, - &sensor_dev_attr_port_28_sfp_copper.dev_attr.attr, - &sensor_dev_attr_port_29_sfp_copper.dev_attr.attr, - &sensor_dev_attr_port_30_sfp_copper.dev_attr.attr, - &sensor_dev_attr_port_31_sfp_copper.dev_attr.attr, - &sensor_dev_attr_port_32_sfp_copper.dev_attr.attr, - - &sensor_dev_attr_port_1_abs.dev_attr.attr, - &sensor_dev_attr_port_2_abs.dev_attr.attr, - &sensor_dev_attr_port_3_abs.dev_attr.attr, - &sensor_dev_attr_port_4_abs.dev_attr.attr, - &sensor_dev_attr_port_5_abs.dev_attr.attr, - &sensor_dev_attr_port_6_abs.dev_attr.attr, - &sensor_dev_attr_port_7_abs.dev_attr.attr, - &sensor_dev_attr_port_8_abs.dev_attr.attr, - &sensor_dev_attr_port_9_abs.dev_attr.attr, - &sensor_dev_attr_port_10_abs.dev_attr.attr, - &sensor_dev_attr_port_11_abs.dev_attr.attr, - &sensor_dev_attr_port_12_abs.dev_attr.attr, - &sensor_dev_attr_port_13_abs.dev_attr.attr, - &sensor_dev_attr_port_14_abs.dev_attr.attr, - &sensor_dev_attr_port_15_abs.dev_attr.attr, - &sensor_dev_attr_port_16_abs.dev_attr.attr, - &sensor_dev_attr_port_17_abs.dev_attr.attr, - &sensor_dev_attr_port_18_abs.dev_attr.attr, - &sensor_dev_attr_port_19_abs.dev_attr.attr, - &sensor_dev_attr_port_20_abs.dev_attr.attr, - &sensor_dev_attr_port_21_abs.dev_attr.attr, - &sensor_dev_attr_port_22_abs.dev_attr.attr, - &sensor_dev_attr_port_23_abs.dev_attr.attr, - &sensor_dev_attr_port_24_abs.dev_attr.attr, - &sensor_dev_attr_port_25_abs.dev_attr.attr, - &sensor_dev_attr_port_26_abs.dev_attr.attr, - &sensor_dev_attr_port_27_abs.dev_attr.attr, - &sensor_dev_attr_port_28_abs.dev_attr.attr, - &sensor_dev_attr_port_29_abs.dev_attr.attr, - &sensor_dev_attr_port_30_abs.dev_attr.attr, - &sensor_dev_attr_port_31_abs.dev_attr.attr, - &sensor_dev_attr_port_32_abs.dev_attr.attr, - - &sensor_dev_attr_fan1_abs.dev_attr.attr, - &sensor_dev_attr_fan2_abs.dev_attr.attr, - &sensor_dev_attr_fan3_abs.dev_attr.attr, - &sensor_dev_attr_fan4_abs.dev_attr.attr, - - &sensor_dev_attr_fan1_dir.dev_attr.attr, - &sensor_dev_attr_fan2_dir.dev_attr.attr, - &sensor_dev_attr_fan3_dir.dev_attr.attr, - &sensor_dev_attr_fan4_dir.dev_attr.attr, - - &sensor_dev_attr_psu1_eeprom.dev_attr.attr, - &sensor_dev_attr_psu2_eeprom.dev_attr.attr, - - &sensor_dev_attr_psu1_vout.dev_attr.attr, - &sensor_dev_attr_psu1_iout.dev_attr.attr, - &sensor_dev_attr_psu1_temp_1.dev_attr.attr, - &sensor_dev_attr_psu1_temp_2.dev_attr.attr, - &sensor_dev_attr_psu1_fan_speed.dev_attr.attr, - &sensor_dev_attr_psu1_pout.dev_attr.attr, - &sensor_dev_attr_psu1_pin.dev_attr.attr, - - &sensor_dev_attr_psu2_vout.dev_attr.attr, - &sensor_dev_attr_psu2_iout.dev_attr.attr, - &sensor_dev_attr_psu2_temp_1.dev_attr.attr, - &sensor_dev_attr_psu2_temp_2.dev_attr.attr, - &sensor_dev_attr_psu2_fan_speed.dev_attr.attr, - &sensor_dev_attr_psu2_pout.dev_attr.attr, - &sensor_dev_attr_psu2_pin.dev_attr.attr, - - &dev_attr_psu_power_off.attr, - - /* lm-sensors */ - &sensor_dev_attr_in12_input.dev_attr.attr, - &sensor_dev_attr_curr12_input.dev_attr.attr, - &sensor_dev_attr_power11_input.dev_attr.attr, - &sensor_dev_attr_power12_input.dev_attr.attr, - &sensor_dev_attr_temp11_input.dev_attr.attr, - &sensor_dev_attr_temp12_input.dev_attr.attr, - &sensor_dev_attr_fan11_input.dev_attr.attr, - - &sensor_dev_attr_in22_input.dev_attr.attr, - &sensor_dev_attr_curr22_input.dev_attr.attr, - &sensor_dev_attr_power21_input.dev_attr.attr, - &sensor_dev_attr_power22_input.dev_attr.attr, - &sensor_dev_attr_temp21_input.dev_attr.attr, - &sensor_dev_attr_temp22_input.dev_attr.attr, - &sensor_dev_attr_fan21_input.dev_attr.attr, - - NULL -}; - -static struct attribute *i2c_bus1_hardware_monitor_attr_sesto[] = { - &dev_attr_eeprom.attr, - &dev_attr_system_led.attr, - &dev_attr_fan_led.attr, - &sensor_dev_attr_psu1_led.dev_attr.attr, - &sensor_dev_attr_psu2_led.dev_attr.attr, - - &sensor_dev_attr_port_1_data_a0.dev_attr.attr, - &sensor_dev_attr_port_2_data_a0.dev_attr.attr, - &sensor_dev_attr_port_3_data_a0.dev_attr.attr, - &sensor_dev_attr_port_4_data_a0.dev_attr.attr, - &sensor_dev_attr_port_5_data_a0.dev_attr.attr, - &sensor_dev_attr_port_6_data_a0.dev_attr.attr, - &sensor_dev_attr_port_7_data_a0.dev_attr.attr, - &sensor_dev_attr_port_8_data_a0.dev_attr.attr, - &sensor_dev_attr_port_9_data_a0.dev_attr.attr, - &sensor_dev_attr_port_10_data_a0.dev_attr.attr, - &sensor_dev_attr_port_11_data_a0.dev_attr.attr, - &sensor_dev_attr_port_12_data_a0.dev_attr.attr, - &sensor_dev_attr_port_13_data_a0.dev_attr.attr, - &sensor_dev_attr_port_14_data_a0.dev_attr.attr, - &sensor_dev_attr_port_15_data_a0.dev_attr.attr, - &sensor_dev_attr_port_16_data_a0.dev_attr.attr, - &sensor_dev_attr_port_17_data_a0.dev_attr.attr, - &sensor_dev_attr_port_18_data_a0.dev_attr.attr, - &sensor_dev_attr_port_19_data_a0.dev_attr.attr, - &sensor_dev_attr_port_20_data_a0.dev_attr.attr, - &sensor_dev_attr_port_21_data_a0.dev_attr.attr, - &sensor_dev_attr_port_22_data_a0.dev_attr.attr, - &sensor_dev_attr_port_23_data_a0.dev_attr.attr, - &sensor_dev_attr_port_24_data_a0.dev_attr.attr, - &sensor_dev_attr_port_25_data_a0.dev_attr.attr, - &sensor_dev_attr_port_26_data_a0.dev_attr.attr, - &sensor_dev_attr_port_27_data_a0.dev_attr.attr, - &sensor_dev_attr_port_28_data_a0.dev_attr.attr, - &sensor_dev_attr_port_29_data_a0.dev_attr.attr, - &sensor_dev_attr_port_30_data_a0.dev_attr.attr, - &sensor_dev_attr_port_31_data_a0.dev_attr.attr, - &sensor_dev_attr_port_32_data_a0.dev_attr.attr, - &sensor_dev_attr_port_33_data_a0.dev_attr.attr, - &sensor_dev_attr_port_34_data_a0.dev_attr.attr, - &sensor_dev_attr_port_35_data_a0.dev_attr.attr, - &sensor_dev_attr_port_36_data_a0.dev_attr.attr, - &sensor_dev_attr_port_37_data_a0.dev_attr.attr, - &sensor_dev_attr_port_38_data_a0.dev_attr.attr, - &sensor_dev_attr_port_39_data_a0.dev_attr.attr, - &sensor_dev_attr_port_40_data_a0.dev_attr.attr, - &sensor_dev_attr_port_41_data_a0.dev_attr.attr, - &sensor_dev_attr_port_42_data_a0.dev_attr.attr, - &sensor_dev_attr_port_43_data_a0.dev_attr.attr, - &sensor_dev_attr_port_44_data_a0.dev_attr.attr, - &sensor_dev_attr_port_45_data_a0.dev_attr.attr, - &sensor_dev_attr_port_46_data_a0.dev_attr.attr, - &sensor_dev_attr_port_47_data_a0.dev_attr.attr, - &sensor_dev_attr_port_48_data_a0.dev_attr.attr, - &sensor_dev_attr_port_49_data_a0.dev_attr.attr, - &sensor_dev_attr_port_50_data_a0.dev_attr.attr, - &sensor_dev_attr_port_51_data_a0.dev_attr.attr, - &sensor_dev_attr_port_52_data_a0.dev_attr.attr, - &sensor_dev_attr_port_53_data_a0.dev_attr.attr, - &sensor_dev_attr_port_54_data_a0.dev_attr.attr, - - &sensor_dev_attr_port_1_data_a2.dev_attr.attr, - &sensor_dev_attr_port_2_data_a2.dev_attr.attr, - &sensor_dev_attr_port_3_data_a2.dev_attr.attr, - &sensor_dev_attr_port_4_data_a2.dev_attr.attr, - &sensor_dev_attr_port_5_data_a2.dev_attr.attr, - &sensor_dev_attr_port_6_data_a2.dev_attr.attr, - &sensor_dev_attr_port_7_data_a2.dev_attr.attr, - &sensor_dev_attr_port_8_data_a2.dev_attr.attr, - &sensor_dev_attr_port_9_data_a2.dev_attr.attr, - &sensor_dev_attr_port_10_data_a2.dev_attr.attr, - &sensor_dev_attr_port_11_data_a2.dev_attr.attr, - &sensor_dev_attr_port_12_data_a2.dev_attr.attr, - &sensor_dev_attr_port_13_data_a2.dev_attr.attr, - &sensor_dev_attr_port_14_data_a2.dev_attr.attr, - &sensor_dev_attr_port_15_data_a2.dev_attr.attr, - &sensor_dev_attr_port_16_data_a2.dev_attr.attr, - &sensor_dev_attr_port_17_data_a2.dev_attr.attr, - &sensor_dev_attr_port_18_data_a2.dev_attr.attr, - &sensor_dev_attr_port_19_data_a2.dev_attr.attr, - &sensor_dev_attr_port_20_data_a2.dev_attr.attr, - &sensor_dev_attr_port_21_data_a2.dev_attr.attr, - &sensor_dev_attr_port_22_data_a2.dev_attr.attr, - &sensor_dev_attr_port_23_data_a2.dev_attr.attr, - &sensor_dev_attr_port_24_data_a2.dev_attr.attr, - &sensor_dev_attr_port_25_data_a2.dev_attr.attr, - &sensor_dev_attr_port_26_data_a2.dev_attr.attr, - &sensor_dev_attr_port_27_data_a2.dev_attr.attr, - &sensor_dev_attr_port_28_data_a2.dev_attr.attr, - &sensor_dev_attr_port_29_data_a2.dev_attr.attr, - &sensor_dev_attr_port_30_data_a2.dev_attr.attr, - &sensor_dev_attr_port_31_data_a2.dev_attr.attr, - &sensor_dev_attr_port_32_data_a2.dev_attr.attr, - &sensor_dev_attr_port_33_data_a2.dev_attr.attr, - &sensor_dev_attr_port_34_data_a2.dev_attr.attr, - &sensor_dev_attr_port_35_data_a2.dev_attr.attr, - &sensor_dev_attr_port_36_data_a2.dev_attr.attr, - &sensor_dev_attr_port_37_data_a2.dev_attr.attr, - &sensor_dev_attr_port_38_data_a2.dev_attr.attr, - &sensor_dev_attr_port_39_data_a2.dev_attr.attr, - &sensor_dev_attr_port_40_data_a2.dev_attr.attr, - &sensor_dev_attr_port_41_data_a2.dev_attr.attr, - &sensor_dev_attr_port_42_data_a2.dev_attr.attr, - &sensor_dev_attr_port_43_data_a2.dev_attr.attr, - &sensor_dev_attr_port_44_data_a2.dev_attr.attr, - &sensor_dev_attr_port_45_data_a2.dev_attr.attr, - &sensor_dev_attr_port_46_data_a2.dev_attr.attr, - &sensor_dev_attr_port_47_data_a2.dev_attr.attr, - &sensor_dev_attr_port_48_data_a2.dev_attr.attr, - &sensor_dev_attr_port_49_data_a2.dev_attr.attr, - &sensor_dev_attr_port_50_data_a2.dev_attr.attr, - &sensor_dev_attr_port_51_data_a2.dev_attr.attr, - &sensor_dev_attr_port_52_data_a2.dev_attr.attr, - &sensor_dev_attr_port_53_data_a2.dev_attr.attr, - &sensor_dev_attr_port_54_data_a2.dev_attr.attr, - - &sensor_dev_attr_port_1_sfp_copper.dev_attr.attr, - &sensor_dev_attr_port_2_sfp_copper.dev_attr.attr, - &sensor_dev_attr_port_3_sfp_copper.dev_attr.attr, - &sensor_dev_attr_port_4_sfp_copper.dev_attr.attr, - &sensor_dev_attr_port_5_sfp_copper.dev_attr.attr, - &sensor_dev_attr_port_6_sfp_copper.dev_attr.attr, - &sensor_dev_attr_port_7_sfp_copper.dev_attr.attr, - &sensor_dev_attr_port_8_sfp_copper.dev_attr.attr, - &sensor_dev_attr_port_9_sfp_copper.dev_attr.attr, - &sensor_dev_attr_port_10_sfp_copper.dev_attr.attr, - &sensor_dev_attr_port_11_sfp_copper.dev_attr.attr, - &sensor_dev_attr_port_12_sfp_copper.dev_attr.attr, - &sensor_dev_attr_port_13_sfp_copper.dev_attr.attr, - &sensor_dev_attr_port_14_sfp_copper.dev_attr.attr, - &sensor_dev_attr_port_15_sfp_copper.dev_attr.attr, - &sensor_dev_attr_port_16_sfp_copper.dev_attr.attr, - &sensor_dev_attr_port_17_sfp_copper.dev_attr.attr, - &sensor_dev_attr_port_18_sfp_copper.dev_attr.attr, - &sensor_dev_attr_port_19_sfp_copper.dev_attr.attr, - &sensor_dev_attr_port_20_sfp_copper.dev_attr.attr, - &sensor_dev_attr_port_21_sfp_copper.dev_attr.attr, - &sensor_dev_attr_port_22_sfp_copper.dev_attr.attr, - &sensor_dev_attr_port_23_sfp_copper.dev_attr.attr, - &sensor_dev_attr_port_24_sfp_copper.dev_attr.attr, - &sensor_dev_attr_port_25_sfp_copper.dev_attr.attr, - &sensor_dev_attr_port_26_sfp_copper.dev_attr.attr, - &sensor_dev_attr_port_27_sfp_copper.dev_attr.attr, - &sensor_dev_attr_port_28_sfp_copper.dev_attr.attr, - &sensor_dev_attr_port_29_sfp_copper.dev_attr.attr, - &sensor_dev_attr_port_30_sfp_copper.dev_attr.attr, - &sensor_dev_attr_port_31_sfp_copper.dev_attr.attr, - &sensor_dev_attr_port_32_sfp_copper.dev_attr.attr, - &sensor_dev_attr_port_33_sfp_copper.dev_attr.attr, - &sensor_dev_attr_port_34_sfp_copper.dev_attr.attr, - &sensor_dev_attr_port_35_sfp_copper.dev_attr.attr, - &sensor_dev_attr_port_36_sfp_copper.dev_attr.attr, - &sensor_dev_attr_port_37_sfp_copper.dev_attr.attr, - &sensor_dev_attr_port_38_sfp_copper.dev_attr.attr, - &sensor_dev_attr_port_39_sfp_copper.dev_attr.attr, - &sensor_dev_attr_port_40_sfp_copper.dev_attr.attr, - &sensor_dev_attr_port_41_sfp_copper.dev_attr.attr, - &sensor_dev_attr_port_42_sfp_copper.dev_attr.attr, - &sensor_dev_attr_port_43_sfp_copper.dev_attr.attr, - &sensor_dev_attr_port_44_sfp_copper.dev_attr.attr, - &sensor_dev_attr_port_45_sfp_copper.dev_attr.attr, - &sensor_dev_attr_port_46_sfp_copper.dev_attr.attr, - &sensor_dev_attr_port_47_sfp_copper.dev_attr.attr, - &sensor_dev_attr_port_48_sfp_copper.dev_attr.attr, - &sensor_dev_attr_port_49_sfp_copper.dev_attr.attr, - &sensor_dev_attr_port_50_sfp_copper.dev_attr.attr, - &sensor_dev_attr_port_51_sfp_copper.dev_attr.attr, - &sensor_dev_attr_port_52_sfp_copper.dev_attr.attr, - &sensor_dev_attr_port_53_sfp_copper.dev_attr.attr, - &sensor_dev_attr_port_54_sfp_copper.dev_attr.attr, - - &sensor_dev_attr_port_1_abs.dev_attr.attr, - &sensor_dev_attr_port_2_abs.dev_attr.attr, - &sensor_dev_attr_port_3_abs.dev_attr.attr, - &sensor_dev_attr_port_4_abs.dev_attr.attr, - &sensor_dev_attr_port_5_abs.dev_attr.attr, - &sensor_dev_attr_port_6_abs.dev_attr.attr, - &sensor_dev_attr_port_7_abs.dev_attr.attr, - &sensor_dev_attr_port_8_abs.dev_attr.attr, - &sensor_dev_attr_port_9_abs.dev_attr.attr, - &sensor_dev_attr_port_10_abs.dev_attr.attr, - &sensor_dev_attr_port_11_abs.dev_attr.attr, - &sensor_dev_attr_port_12_abs.dev_attr.attr, - &sensor_dev_attr_port_13_abs.dev_attr.attr, - &sensor_dev_attr_port_14_abs.dev_attr.attr, - &sensor_dev_attr_port_15_abs.dev_attr.attr, - &sensor_dev_attr_port_16_abs.dev_attr.attr, - &sensor_dev_attr_port_17_abs.dev_attr.attr, - &sensor_dev_attr_port_18_abs.dev_attr.attr, - &sensor_dev_attr_port_19_abs.dev_attr.attr, - &sensor_dev_attr_port_20_abs.dev_attr.attr, - &sensor_dev_attr_port_21_abs.dev_attr.attr, - &sensor_dev_attr_port_22_abs.dev_attr.attr, - &sensor_dev_attr_port_23_abs.dev_attr.attr, - &sensor_dev_attr_port_24_abs.dev_attr.attr, - &sensor_dev_attr_port_25_abs.dev_attr.attr, - &sensor_dev_attr_port_26_abs.dev_attr.attr, - &sensor_dev_attr_port_27_abs.dev_attr.attr, - &sensor_dev_attr_port_28_abs.dev_attr.attr, - &sensor_dev_attr_port_29_abs.dev_attr.attr, - &sensor_dev_attr_port_30_abs.dev_attr.attr, - &sensor_dev_attr_port_31_abs.dev_attr.attr, - &sensor_dev_attr_port_32_abs.dev_attr.attr, - &sensor_dev_attr_port_33_abs.dev_attr.attr, - &sensor_dev_attr_port_34_abs.dev_attr.attr, - &sensor_dev_attr_port_35_abs.dev_attr.attr, - &sensor_dev_attr_port_36_abs.dev_attr.attr, - &sensor_dev_attr_port_37_abs.dev_attr.attr, - &sensor_dev_attr_port_38_abs.dev_attr.attr, - &sensor_dev_attr_port_39_abs.dev_attr.attr, - &sensor_dev_attr_port_40_abs.dev_attr.attr, - &sensor_dev_attr_port_41_abs.dev_attr.attr, - &sensor_dev_attr_port_42_abs.dev_attr.attr, - &sensor_dev_attr_port_43_abs.dev_attr.attr, - &sensor_dev_attr_port_44_abs.dev_attr.attr, - &sensor_dev_attr_port_45_abs.dev_attr.attr, - &sensor_dev_attr_port_46_abs.dev_attr.attr, - &sensor_dev_attr_port_47_abs.dev_attr.attr, - &sensor_dev_attr_port_48_abs.dev_attr.attr, - &sensor_dev_attr_port_49_abs.dev_attr.attr, - &sensor_dev_attr_port_50_abs.dev_attr.attr, - &sensor_dev_attr_port_51_abs.dev_attr.attr, - &sensor_dev_attr_port_52_abs.dev_attr.attr, - &sensor_dev_attr_port_53_abs.dev_attr.attr, - &sensor_dev_attr_port_54_abs.dev_attr.attr, - - &sensor_dev_attr_port_1_rxlos.dev_attr.attr, - &sensor_dev_attr_port_2_rxlos.dev_attr.attr, - &sensor_dev_attr_port_3_rxlos.dev_attr.attr, - &sensor_dev_attr_port_4_rxlos.dev_attr.attr, - &sensor_dev_attr_port_5_rxlos.dev_attr.attr, - &sensor_dev_attr_port_6_rxlos.dev_attr.attr, - &sensor_dev_attr_port_7_rxlos.dev_attr.attr, - &sensor_dev_attr_port_8_rxlos.dev_attr.attr, - &sensor_dev_attr_port_9_rxlos.dev_attr.attr, - &sensor_dev_attr_port_10_rxlos.dev_attr.attr, - &sensor_dev_attr_port_11_rxlos.dev_attr.attr, - &sensor_dev_attr_port_12_rxlos.dev_attr.attr, - &sensor_dev_attr_port_13_rxlos.dev_attr.attr, - &sensor_dev_attr_port_14_rxlos.dev_attr.attr, - &sensor_dev_attr_port_15_rxlos.dev_attr.attr, - &sensor_dev_attr_port_16_rxlos.dev_attr.attr, - &sensor_dev_attr_port_17_rxlos.dev_attr.attr, - &sensor_dev_attr_port_18_rxlos.dev_attr.attr, - &sensor_dev_attr_port_19_rxlos.dev_attr.attr, - &sensor_dev_attr_port_20_rxlos.dev_attr.attr, - &sensor_dev_attr_port_21_rxlos.dev_attr.attr, - &sensor_dev_attr_port_22_rxlos.dev_attr.attr, - &sensor_dev_attr_port_23_rxlos.dev_attr.attr, - &sensor_dev_attr_port_24_rxlos.dev_attr.attr, - &sensor_dev_attr_port_25_rxlos.dev_attr.attr, - &sensor_dev_attr_port_26_rxlos.dev_attr.attr, - &sensor_dev_attr_port_27_rxlos.dev_attr.attr, - &sensor_dev_attr_port_28_rxlos.dev_attr.attr, - &sensor_dev_attr_port_29_rxlos.dev_attr.attr, - &sensor_dev_attr_port_30_rxlos.dev_attr.attr, - &sensor_dev_attr_port_31_rxlos.dev_attr.attr, - &sensor_dev_attr_port_32_rxlos.dev_attr.attr, - &sensor_dev_attr_port_33_rxlos.dev_attr.attr, - &sensor_dev_attr_port_34_rxlos.dev_attr.attr, - &sensor_dev_attr_port_35_rxlos.dev_attr.attr, - &sensor_dev_attr_port_36_rxlos.dev_attr.attr, - &sensor_dev_attr_port_37_rxlos.dev_attr.attr, - &sensor_dev_attr_port_38_rxlos.dev_attr.attr, - &sensor_dev_attr_port_39_rxlos.dev_attr.attr, - &sensor_dev_attr_port_40_rxlos.dev_attr.attr, - &sensor_dev_attr_port_41_rxlos.dev_attr.attr, - &sensor_dev_attr_port_42_rxlos.dev_attr.attr, - &sensor_dev_attr_port_43_rxlos.dev_attr.attr, - &sensor_dev_attr_port_44_rxlos.dev_attr.attr, - &sensor_dev_attr_port_45_rxlos.dev_attr.attr, - &sensor_dev_attr_port_46_rxlos.dev_attr.attr, - &sensor_dev_attr_port_47_rxlos.dev_attr.attr, - &sensor_dev_attr_port_48_rxlos.dev_attr.attr, - - &sensor_dev_attr_port_1_tx_disable.dev_attr.attr, - &sensor_dev_attr_port_2_tx_disable.dev_attr.attr, - &sensor_dev_attr_port_3_tx_disable.dev_attr.attr, - &sensor_dev_attr_port_4_tx_disable.dev_attr.attr, - &sensor_dev_attr_port_5_tx_disable.dev_attr.attr, - &sensor_dev_attr_port_6_tx_disable.dev_attr.attr, - &sensor_dev_attr_port_7_tx_disable.dev_attr.attr, - &sensor_dev_attr_port_8_tx_disable.dev_attr.attr, - &sensor_dev_attr_port_9_tx_disable.dev_attr.attr, - &sensor_dev_attr_port_10_tx_disable.dev_attr.attr, - &sensor_dev_attr_port_11_tx_disable.dev_attr.attr, - &sensor_dev_attr_port_12_tx_disable.dev_attr.attr, - &sensor_dev_attr_port_13_tx_disable.dev_attr.attr, - &sensor_dev_attr_port_14_tx_disable.dev_attr.attr, - &sensor_dev_attr_port_15_tx_disable.dev_attr.attr, - &sensor_dev_attr_port_16_tx_disable.dev_attr.attr, - &sensor_dev_attr_port_17_tx_disable.dev_attr.attr, - &sensor_dev_attr_port_18_tx_disable.dev_attr.attr, - &sensor_dev_attr_port_19_tx_disable.dev_attr.attr, - &sensor_dev_attr_port_20_tx_disable.dev_attr.attr, - &sensor_dev_attr_port_21_tx_disable.dev_attr.attr, - &sensor_dev_attr_port_22_tx_disable.dev_attr.attr, - &sensor_dev_attr_port_23_tx_disable.dev_attr.attr, - &sensor_dev_attr_port_24_tx_disable.dev_attr.attr, - &sensor_dev_attr_port_25_tx_disable.dev_attr.attr, - &sensor_dev_attr_port_26_tx_disable.dev_attr.attr, - &sensor_dev_attr_port_27_tx_disable.dev_attr.attr, - &sensor_dev_attr_port_28_tx_disable.dev_attr.attr, - &sensor_dev_attr_port_29_tx_disable.dev_attr.attr, - &sensor_dev_attr_port_30_tx_disable.dev_attr.attr, - &sensor_dev_attr_port_31_tx_disable.dev_attr.attr, - &sensor_dev_attr_port_32_tx_disable.dev_attr.attr, - &sensor_dev_attr_port_33_tx_disable.dev_attr.attr, - &sensor_dev_attr_port_34_tx_disable.dev_attr.attr, - &sensor_dev_attr_port_35_tx_disable.dev_attr.attr, - &sensor_dev_attr_port_36_tx_disable.dev_attr.attr, - &sensor_dev_attr_port_37_tx_disable.dev_attr.attr, - &sensor_dev_attr_port_38_tx_disable.dev_attr.attr, - &sensor_dev_attr_port_39_tx_disable.dev_attr.attr, - &sensor_dev_attr_port_40_tx_disable.dev_attr.attr, - &sensor_dev_attr_port_41_tx_disable.dev_attr.attr, - &sensor_dev_attr_port_42_tx_disable.dev_attr.attr, - &sensor_dev_attr_port_43_tx_disable.dev_attr.attr, - &sensor_dev_attr_port_44_tx_disable.dev_attr.attr, - &sensor_dev_attr_port_45_tx_disable.dev_attr.attr, - &sensor_dev_attr_port_46_tx_disable.dev_attr.attr, - &sensor_dev_attr_port_47_tx_disable.dev_attr.attr, - &sensor_dev_attr_port_48_tx_disable.dev_attr.attr, - - &sensor_dev_attr_port_1_rate_select.dev_attr.attr, - &sensor_dev_attr_port_2_rate_select.dev_attr.attr, - &sensor_dev_attr_port_3_rate_select.dev_attr.attr, - &sensor_dev_attr_port_4_rate_select.dev_attr.attr, - &sensor_dev_attr_port_5_rate_select.dev_attr.attr, - &sensor_dev_attr_port_6_rate_select.dev_attr.attr, - &sensor_dev_attr_port_7_rate_select.dev_attr.attr, - &sensor_dev_attr_port_8_rate_select.dev_attr.attr, - &sensor_dev_attr_port_9_rate_select.dev_attr.attr, - &sensor_dev_attr_port_10_rate_select.dev_attr.attr, - &sensor_dev_attr_port_11_rate_select.dev_attr.attr, - &sensor_dev_attr_port_12_rate_select.dev_attr.attr, - &sensor_dev_attr_port_13_rate_select.dev_attr.attr, - &sensor_dev_attr_port_14_rate_select.dev_attr.attr, - &sensor_dev_attr_port_15_rate_select.dev_attr.attr, - &sensor_dev_attr_port_16_rate_select.dev_attr.attr, - &sensor_dev_attr_port_17_rate_select.dev_attr.attr, - &sensor_dev_attr_port_18_rate_select.dev_attr.attr, - &sensor_dev_attr_port_19_rate_select.dev_attr.attr, - &sensor_dev_attr_port_20_rate_select.dev_attr.attr, - &sensor_dev_attr_port_21_rate_select.dev_attr.attr, - &sensor_dev_attr_port_22_rate_select.dev_attr.attr, - &sensor_dev_attr_port_23_rate_select.dev_attr.attr, - &sensor_dev_attr_port_24_rate_select.dev_attr.attr, - &sensor_dev_attr_port_25_rate_select.dev_attr.attr, - &sensor_dev_attr_port_26_rate_select.dev_attr.attr, - &sensor_dev_attr_port_27_rate_select.dev_attr.attr, - &sensor_dev_attr_port_28_rate_select.dev_attr.attr, - &sensor_dev_attr_port_29_rate_select.dev_attr.attr, - &sensor_dev_attr_port_30_rate_select.dev_attr.attr, - &sensor_dev_attr_port_31_rate_select.dev_attr.attr, - &sensor_dev_attr_port_32_rate_select.dev_attr.attr, - &sensor_dev_attr_port_33_rate_select.dev_attr.attr, - &sensor_dev_attr_port_34_rate_select.dev_attr.attr, - &sensor_dev_attr_port_35_rate_select.dev_attr.attr, - &sensor_dev_attr_port_36_rate_select.dev_attr.attr, - &sensor_dev_attr_port_37_rate_select.dev_attr.attr, - &sensor_dev_attr_port_38_rate_select.dev_attr.attr, - &sensor_dev_attr_port_39_rate_select.dev_attr.attr, - &sensor_dev_attr_port_40_rate_select.dev_attr.attr, - &sensor_dev_attr_port_41_rate_select.dev_attr.attr, - &sensor_dev_attr_port_42_rate_select.dev_attr.attr, - &sensor_dev_attr_port_43_rate_select.dev_attr.attr, - &sensor_dev_attr_port_44_rate_select.dev_attr.attr, - &sensor_dev_attr_port_45_rate_select.dev_attr.attr, - &sensor_dev_attr_port_46_rate_select.dev_attr.attr, - &sensor_dev_attr_port_47_rate_select.dev_attr.attr, - &sensor_dev_attr_port_48_rate_select.dev_attr.attr, - - &sensor_dev_attr_fan1_abs.dev_attr.attr, - &sensor_dev_attr_fan2_abs.dev_attr.attr, - &sensor_dev_attr_fan3_abs.dev_attr.attr, - &sensor_dev_attr_fan4_abs.dev_attr.attr, - - &sensor_dev_attr_fan1_dir.dev_attr.attr, - &sensor_dev_attr_fan2_dir.dev_attr.attr, - &sensor_dev_attr_fan3_dir.dev_attr.attr, - &sensor_dev_attr_fan4_dir.dev_attr.attr, - - &sensor_dev_attr_psu1_eeprom.dev_attr.attr, - &sensor_dev_attr_psu2_eeprom.dev_attr.attr, - - &sensor_dev_attr_psu1_vout.dev_attr.attr, - &sensor_dev_attr_psu1_iout.dev_attr.attr, - &sensor_dev_attr_psu1_temp_1.dev_attr.attr, - &sensor_dev_attr_psu1_temp_2.dev_attr.attr, - &sensor_dev_attr_psu1_fan_speed.dev_attr.attr, - &sensor_dev_attr_psu1_pout.dev_attr.attr, - &sensor_dev_attr_psu1_pin.dev_attr.attr, - - &sensor_dev_attr_psu2_vout.dev_attr.attr, - &sensor_dev_attr_psu2_iout.dev_attr.attr, - &sensor_dev_attr_psu2_temp_1.dev_attr.attr, - &sensor_dev_attr_psu2_temp_2.dev_attr.attr, - &sensor_dev_attr_psu2_fan_speed.dev_attr.attr, - &sensor_dev_attr_psu2_pout.dev_attr.attr, - &sensor_dev_attr_psu2_pin.dev_attr.attr, - - &dev_attr_psu_power_off.attr, - - /* lm-sensors */ - &sensor_dev_attr_in12_input.dev_attr.attr, - &sensor_dev_attr_curr12_input.dev_attr.attr, - &sensor_dev_attr_power11_input.dev_attr.attr, - &sensor_dev_attr_power12_input.dev_attr.attr, - &sensor_dev_attr_temp11_input.dev_attr.attr, - &sensor_dev_attr_temp12_input.dev_attr.attr, - &sensor_dev_attr_fan11_input.dev_attr.attr, - - &sensor_dev_attr_in22_input.dev_attr.attr, - &sensor_dev_attr_curr22_input.dev_attr.attr, - &sensor_dev_attr_power21_input.dev_attr.attr, - &sensor_dev_attr_power22_input.dev_attr.attr, - &sensor_dev_attr_temp21_input.dev_attr.attr, - &sensor_dev_attr_temp22_input.dev_attr.attr, - &sensor_dev_attr_fan21_input.dev_attr.attr, - - NULL -}; - -static struct attribute *i2c_bus1_hardware_monitor_attr_nc2x[] = { - &dev_attr_eeprom.attr, - &dev_attr_system_led.attr, - &dev_attr_fan_led.attr, - &sensor_dev_attr_psu1_led.dev_attr.attr, - &sensor_dev_attr_psu2_led.dev_attr.attr, - - &sensor_dev_attr_port_1_data_a0.dev_attr.attr, - &sensor_dev_attr_port_2_data_a0.dev_attr.attr, - &sensor_dev_attr_port_3_data_a0.dev_attr.attr, - &sensor_dev_attr_port_4_data_a0.dev_attr.attr, - &sensor_dev_attr_port_5_data_a0.dev_attr.attr, - &sensor_dev_attr_port_6_data_a0.dev_attr.attr, - &sensor_dev_attr_port_7_data_a0.dev_attr.attr, - &sensor_dev_attr_port_8_data_a0.dev_attr.attr, - &sensor_dev_attr_port_9_data_a0.dev_attr.attr, - &sensor_dev_attr_port_10_data_a0.dev_attr.attr, - &sensor_dev_attr_port_11_data_a0.dev_attr.attr, - &sensor_dev_attr_port_12_data_a0.dev_attr.attr, - &sensor_dev_attr_port_13_data_a0.dev_attr.attr, - &sensor_dev_attr_port_14_data_a0.dev_attr.attr, - &sensor_dev_attr_port_15_data_a0.dev_attr.attr, - &sensor_dev_attr_port_16_data_a0.dev_attr.attr, - &sensor_dev_attr_port_17_data_a0.dev_attr.attr, - &sensor_dev_attr_port_18_data_a0.dev_attr.attr, - &sensor_dev_attr_port_19_data_a0.dev_attr.attr, - &sensor_dev_attr_port_20_data_a0.dev_attr.attr, - &sensor_dev_attr_port_21_data_a0.dev_attr.attr, - &sensor_dev_attr_port_22_data_a0.dev_attr.attr, - &sensor_dev_attr_port_23_data_a0.dev_attr.attr, - &sensor_dev_attr_port_24_data_a0.dev_attr.attr, - &sensor_dev_attr_port_25_data_a0.dev_attr.attr, - &sensor_dev_attr_port_26_data_a0.dev_attr.attr, - &sensor_dev_attr_port_27_data_a0.dev_attr.attr, - &sensor_dev_attr_port_28_data_a0.dev_attr.attr, - &sensor_dev_attr_port_29_data_a0.dev_attr.attr, - &sensor_dev_attr_port_30_data_a0.dev_attr.attr, - &sensor_dev_attr_port_31_data_a0.dev_attr.attr, - &sensor_dev_attr_port_32_data_a0.dev_attr.attr, - &sensor_dev_attr_port_33_data_a0.dev_attr.attr, - &sensor_dev_attr_port_34_data_a0.dev_attr.attr, - &sensor_dev_attr_port_35_data_a0.dev_attr.attr, - &sensor_dev_attr_port_36_data_a0.dev_attr.attr, - &sensor_dev_attr_port_37_data_a0.dev_attr.attr, - &sensor_dev_attr_port_38_data_a0.dev_attr.attr, - &sensor_dev_attr_port_39_data_a0.dev_attr.attr, - &sensor_dev_attr_port_40_data_a0.dev_attr.attr, - &sensor_dev_attr_port_41_data_a0.dev_attr.attr, - &sensor_dev_attr_port_42_data_a0.dev_attr.attr, - &sensor_dev_attr_port_43_data_a0.dev_attr.attr, - &sensor_dev_attr_port_44_data_a0.dev_attr.attr, - &sensor_dev_attr_port_45_data_a0.dev_attr.attr, - &sensor_dev_attr_port_46_data_a0.dev_attr.attr, - &sensor_dev_attr_port_47_data_a0.dev_attr.attr, - &sensor_dev_attr_port_48_data_a0.dev_attr.attr, - &sensor_dev_attr_port_49_data_a0.dev_attr.attr, - &sensor_dev_attr_port_50_data_a0.dev_attr.attr, - &sensor_dev_attr_port_51_data_a0.dev_attr.attr, - &sensor_dev_attr_port_52_data_a0.dev_attr.attr, - &sensor_dev_attr_port_53_data_a0.dev_attr.attr, - &sensor_dev_attr_port_54_data_a0.dev_attr.attr, - - &sensor_dev_attr_port_1_data_a2.dev_attr.attr, - &sensor_dev_attr_port_2_data_a2.dev_attr.attr, - &sensor_dev_attr_port_3_data_a2.dev_attr.attr, - &sensor_dev_attr_port_4_data_a2.dev_attr.attr, - &sensor_dev_attr_port_5_data_a2.dev_attr.attr, - &sensor_dev_attr_port_6_data_a2.dev_attr.attr, - &sensor_dev_attr_port_7_data_a2.dev_attr.attr, - &sensor_dev_attr_port_8_data_a2.dev_attr.attr, - &sensor_dev_attr_port_9_data_a2.dev_attr.attr, - &sensor_dev_attr_port_10_data_a2.dev_attr.attr, - &sensor_dev_attr_port_11_data_a2.dev_attr.attr, - &sensor_dev_attr_port_12_data_a2.dev_attr.attr, - &sensor_dev_attr_port_13_data_a2.dev_attr.attr, - &sensor_dev_attr_port_14_data_a2.dev_attr.attr, - &sensor_dev_attr_port_15_data_a2.dev_attr.attr, - &sensor_dev_attr_port_16_data_a2.dev_attr.attr, - &sensor_dev_attr_port_17_data_a2.dev_attr.attr, - &sensor_dev_attr_port_18_data_a2.dev_attr.attr, - &sensor_dev_attr_port_19_data_a2.dev_attr.attr, - &sensor_dev_attr_port_20_data_a2.dev_attr.attr, - &sensor_dev_attr_port_21_data_a2.dev_attr.attr, - &sensor_dev_attr_port_22_data_a2.dev_attr.attr, - &sensor_dev_attr_port_23_data_a2.dev_attr.attr, - &sensor_dev_attr_port_24_data_a2.dev_attr.attr, - &sensor_dev_attr_port_25_data_a2.dev_attr.attr, - &sensor_dev_attr_port_26_data_a2.dev_attr.attr, - &sensor_dev_attr_port_27_data_a2.dev_attr.attr, - &sensor_dev_attr_port_28_data_a2.dev_attr.attr, - &sensor_dev_attr_port_29_data_a2.dev_attr.attr, - &sensor_dev_attr_port_30_data_a2.dev_attr.attr, - &sensor_dev_attr_port_31_data_a2.dev_attr.attr, - &sensor_dev_attr_port_32_data_a2.dev_attr.attr, - &sensor_dev_attr_port_33_data_a2.dev_attr.attr, - &sensor_dev_attr_port_34_data_a2.dev_attr.attr, - &sensor_dev_attr_port_35_data_a2.dev_attr.attr, - &sensor_dev_attr_port_36_data_a2.dev_attr.attr, - &sensor_dev_attr_port_37_data_a2.dev_attr.attr, - &sensor_dev_attr_port_38_data_a2.dev_attr.attr, - &sensor_dev_attr_port_39_data_a2.dev_attr.attr, - &sensor_dev_attr_port_40_data_a2.dev_attr.attr, - &sensor_dev_attr_port_41_data_a2.dev_attr.attr, - &sensor_dev_attr_port_42_data_a2.dev_attr.attr, - &sensor_dev_attr_port_43_data_a2.dev_attr.attr, - &sensor_dev_attr_port_44_data_a2.dev_attr.attr, - &sensor_dev_attr_port_45_data_a2.dev_attr.attr, - &sensor_dev_attr_port_46_data_a2.dev_attr.attr, - &sensor_dev_attr_port_47_data_a2.dev_attr.attr, - &sensor_dev_attr_port_48_data_a2.dev_attr.attr, - &sensor_dev_attr_port_49_data_a2.dev_attr.attr, - &sensor_dev_attr_port_50_data_a2.dev_attr.attr, - &sensor_dev_attr_port_51_data_a2.dev_attr.attr, - &sensor_dev_attr_port_52_data_a2.dev_attr.attr, - &sensor_dev_attr_port_53_data_a2.dev_attr.attr, - &sensor_dev_attr_port_54_data_a2.dev_attr.attr, - - &sensor_dev_attr_port_1_sfp_copper.dev_attr.attr, - &sensor_dev_attr_port_2_sfp_copper.dev_attr.attr, - &sensor_dev_attr_port_3_sfp_copper.dev_attr.attr, - &sensor_dev_attr_port_4_sfp_copper.dev_attr.attr, - &sensor_dev_attr_port_5_sfp_copper.dev_attr.attr, - &sensor_dev_attr_port_6_sfp_copper.dev_attr.attr, - &sensor_dev_attr_port_7_sfp_copper.dev_attr.attr, - &sensor_dev_attr_port_8_sfp_copper.dev_attr.attr, - &sensor_dev_attr_port_9_sfp_copper.dev_attr.attr, - &sensor_dev_attr_port_10_sfp_copper.dev_attr.attr, - &sensor_dev_attr_port_11_sfp_copper.dev_attr.attr, - &sensor_dev_attr_port_12_sfp_copper.dev_attr.attr, - &sensor_dev_attr_port_13_sfp_copper.dev_attr.attr, - &sensor_dev_attr_port_14_sfp_copper.dev_attr.attr, - &sensor_dev_attr_port_15_sfp_copper.dev_attr.attr, - &sensor_dev_attr_port_16_sfp_copper.dev_attr.attr, - &sensor_dev_attr_port_17_sfp_copper.dev_attr.attr, - &sensor_dev_attr_port_18_sfp_copper.dev_attr.attr, - &sensor_dev_attr_port_19_sfp_copper.dev_attr.attr, - &sensor_dev_attr_port_20_sfp_copper.dev_attr.attr, - &sensor_dev_attr_port_21_sfp_copper.dev_attr.attr, - &sensor_dev_attr_port_22_sfp_copper.dev_attr.attr, - &sensor_dev_attr_port_23_sfp_copper.dev_attr.attr, - &sensor_dev_attr_port_24_sfp_copper.dev_attr.attr, - &sensor_dev_attr_port_25_sfp_copper.dev_attr.attr, - &sensor_dev_attr_port_26_sfp_copper.dev_attr.attr, - &sensor_dev_attr_port_27_sfp_copper.dev_attr.attr, - &sensor_dev_attr_port_28_sfp_copper.dev_attr.attr, - &sensor_dev_attr_port_29_sfp_copper.dev_attr.attr, - &sensor_dev_attr_port_30_sfp_copper.dev_attr.attr, - &sensor_dev_attr_port_31_sfp_copper.dev_attr.attr, - &sensor_dev_attr_port_32_sfp_copper.dev_attr.attr, - &sensor_dev_attr_port_33_sfp_copper.dev_attr.attr, - &sensor_dev_attr_port_34_sfp_copper.dev_attr.attr, - &sensor_dev_attr_port_35_sfp_copper.dev_attr.attr, - &sensor_dev_attr_port_36_sfp_copper.dev_attr.attr, - &sensor_dev_attr_port_37_sfp_copper.dev_attr.attr, - &sensor_dev_attr_port_38_sfp_copper.dev_attr.attr, - &sensor_dev_attr_port_39_sfp_copper.dev_attr.attr, - &sensor_dev_attr_port_40_sfp_copper.dev_attr.attr, - &sensor_dev_attr_port_41_sfp_copper.dev_attr.attr, - &sensor_dev_attr_port_42_sfp_copper.dev_attr.attr, - &sensor_dev_attr_port_43_sfp_copper.dev_attr.attr, - &sensor_dev_attr_port_44_sfp_copper.dev_attr.attr, - &sensor_dev_attr_port_45_sfp_copper.dev_attr.attr, - &sensor_dev_attr_port_46_sfp_copper.dev_attr.attr, - &sensor_dev_attr_port_47_sfp_copper.dev_attr.attr, - &sensor_dev_attr_port_48_sfp_copper.dev_attr.attr, - &sensor_dev_attr_port_49_sfp_copper.dev_attr.attr, - &sensor_dev_attr_port_50_sfp_copper.dev_attr.attr, - &sensor_dev_attr_port_51_sfp_copper.dev_attr.attr, - &sensor_dev_attr_port_52_sfp_copper.dev_attr.attr, - &sensor_dev_attr_port_53_sfp_copper.dev_attr.attr, - &sensor_dev_attr_port_54_sfp_copper.dev_attr.attr, - - &sensor_dev_attr_port_1_abs.dev_attr.attr, - &sensor_dev_attr_port_2_abs.dev_attr.attr, - &sensor_dev_attr_port_3_abs.dev_attr.attr, - &sensor_dev_attr_port_4_abs.dev_attr.attr, - &sensor_dev_attr_port_5_abs.dev_attr.attr, - &sensor_dev_attr_port_6_abs.dev_attr.attr, - &sensor_dev_attr_port_7_abs.dev_attr.attr, - &sensor_dev_attr_port_8_abs.dev_attr.attr, - &sensor_dev_attr_port_9_abs.dev_attr.attr, - &sensor_dev_attr_port_10_abs.dev_attr.attr, - &sensor_dev_attr_port_11_abs.dev_attr.attr, - &sensor_dev_attr_port_12_abs.dev_attr.attr, - &sensor_dev_attr_port_13_abs.dev_attr.attr, - &sensor_dev_attr_port_14_abs.dev_attr.attr, - &sensor_dev_attr_port_15_abs.dev_attr.attr, - &sensor_dev_attr_port_16_abs.dev_attr.attr, - &sensor_dev_attr_port_17_abs.dev_attr.attr, - &sensor_dev_attr_port_18_abs.dev_attr.attr, - &sensor_dev_attr_port_19_abs.dev_attr.attr, - &sensor_dev_attr_port_20_abs.dev_attr.attr, - &sensor_dev_attr_port_21_abs.dev_attr.attr, - &sensor_dev_attr_port_22_abs.dev_attr.attr, - &sensor_dev_attr_port_23_abs.dev_attr.attr, - &sensor_dev_attr_port_24_abs.dev_attr.attr, - &sensor_dev_attr_port_25_abs.dev_attr.attr, - &sensor_dev_attr_port_26_abs.dev_attr.attr, - &sensor_dev_attr_port_27_abs.dev_attr.attr, - &sensor_dev_attr_port_28_abs.dev_attr.attr, - &sensor_dev_attr_port_29_abs.dev_attr.attr, - &sensor_dev_attr_port_30_abs.dev_attr.attr, - &sensor_dev_attr_port_31_abs.dev_attr.attr, - &sensor_dev_attr_port_32_abs.dev_attr.attr, - &sensor_dev_attr_port_33_abs.dev_attr.attr, - &sensor_dev_attr_port_34_abs.dev_attr.attr, - &sensor_dev_attr_port_35_abs.dev_attr.attr, - &sensor_dev_attr_port_36_abs.dev_attr.attr, - &sensor_dev_attr_port_37_abs.dev_attr.attr, - &sensor_dev_attr_port_38_abs.dev_attr.attr, - &sensor_dev_attr_port_39_abs.dev_attr.attr, - &sensor_dev_attr_port_40_abs.dev_attr.attr, - &sensor_dev_attr_port_41_abs.dev_attr.attr, - &sensor_dev_attr_port_42_abs.dev_attr.attr, - &sensor_dev_attr_port_43_abs.dev_attr.attr, - &sensor_dev_attr_port_44_abs.dev_attr.attr, - &sensor_dev_attr_port_45_abs.dev_attr.attr, - &sensor_dev_attr_port_46_abs.dev_attr.attr, - &sensor_dev_attr_port_47_abs.dev_attr.attr, - &sensor_dev_attr_port_48_abs.dev_attr.attr, - &sensor_dev_attr_port_49_abs.dev_attr.attr, - &sensor_dev_attr_port_50_abs.dev_attr.attr, - &sensor_dev_attr_port_51_abs.dev_attr.attr, - &sensor_dev_attr_port_52_abs.dev_attr.attr, - &sensor_dev_attr_port_53_abs.dev_attr.attr, - &sensor_dev_attr_port_54_abs.dev_attr.attr, - - &sensor_dev_attr_port_1_rxlos.dev_attr.attr, - &sensor_dev_attr_port_2_rxlos.dev_attr.attr, - &sensor_dev_attr_port_3_rxlos.dev_attr.attr, - &sensor_dev_attr_port_4_rxlos.dev_attr.attr, - &sensor_dev_attr_port_5_rxlos.dev_attr.attr, - &sensor_dev_attr_port_6_rxlos.dev_attr.attr, - &sensor_dev_attr_port_7_rxlos.dev_attr.attr, - &sensor_dev_attr_port_8_rxlos.dev_attr.attr, - &sensor_dev_attr_port_9_rxlos.dev_attr.attr, - &sensor_dev_attr_port_10_rxlos.dev_attr.attr, - &sensor_dev_attr_port_11_rxlos.dev_attr.attr, - &sensor_dev_attr_port_12_rxlos.dev_attr.attr, - &sensor_dev_attr_port_13_rxlos.dev_attr.attr, - &sensor_dev_attr_port_14_rxlos.dev_attr.attr, - &sensor_dev_attr_port_15_rxlos.dev_attr.attr, - &sensor_dev_attr_port_16_rxlos.dev_attr.attr, - &sensor_dev_attr_port_17_rxlos.dev_attr.attr, - &sensor_dev_attr_port_18_rxlos.dev_attr.attr, - &sensor_dev_attr_port_19_rxlos.dev_attr.attr, - &sensor_dev_attr_port_20_rxlos.dev_attr.attr, - &sensor_dev_attr_port_21_rxlos.dev_attr.attr, - &sensor_dev_attr_port_22_rxlos.dev_attr.attr, - &sensor_dev_attr_port_23_rxlos.dev_attr.attr, - &sensor_dev_attr_port_24_rxlos.dev_attr.attr, - &sensor_dev_attr_port_25_rxlos.dev_attr.attr, - &sensor_dev_attr_port_26_rxlos.dev_attr.attr, - &sensor_dev_attr_port_27_rxlos.dev_attr.attr, - &sensor_dev_attr_port_28_rxlos.dev_attr.attr, - &sensor_dev_attr_port_29_rxlos.dev_attr.attr, - &sensor_dev_attr_port_30_rxlos.dev_attr.attr, - &sensor_dev_attr_port_31_rxlos.dev_attr.attr, - &sensor_dev_attr_port_32_rxlos.dev_attr.attr, - &sensor_dev_attr_port_33_rxlos.dev_attr.attr, - &sensor_dev_attr_port_34_rxlos.dev_attr.attr, - &sensor_dev_attr_port_35_rxlos.dev_attr.attr, - &sensor_dev_attr_port_36_rxlos.dev_attr.attr, - &sensor_dev_attr_port_37_rxlos.dev_attr.attr, - &sensor_dev_attr_port_38_rxlos.dev_attr.attr, - &sensor_dev_attr_port_39_rxlos.dev_attr.attr, - &sensor_dev_attr_port_40_rxlos.dev_attr.attr, - &sensor_dev_attr_port_41_rxlos.dev_attr.attr, - &sensor_dev_attr_port_42_rxlos.dev_attr.attr, - &sensor_dev_attr_port_43_rxlos.dev_attr.attr, - &sensor_dev_attr_port_44_rxlos.dev_attr.attr, - &sensor_dev_attr_port_45_rxlos.dev_attr.attr, - &sensor_dev_attr_port_46_rxlos.dev_attr.attr, - &sensor_dev_attr_port_47_rxlos.dev_attr.attr, - &sensor_dev_attr_port_48_rxlos.dev_attr.attr, - - &sensor_dev_attr_port_1_tx_disable.dev_attr.attr, - &sensor_dev_attr_port_2_tx_disable.dev_attr.attr, - &sensor_dev_attr_port_3_tx_disable.dev_attr.attr, - &sensor_dev_attr_port_4_tx_disable.dev_attr.attr, - &sensor_dev_attr_port_5_tx_disable.dev_attr.attr, - &sensor_dev_attr_port_6_tx_disable.dev_attr.attr, - &sensor_dev_attr_port_7_tx_disable.dev_attr.attr, - &sensor_dev_attr_port_8_tx_disable.dev_attr.attr, - &sensor_dev_attr_port_9_tx_disable.dev_attr.attr, - &sensor_dev_attr_port_10_tx_disable.dev_attr.attr, - &sensor_dev_attr_port_11_tx_disable.dev_attr.attr, - &sensor_dev_attr_port_12_tx_disable.dev_attr.attr, - &sensor_dev_attr_port_13_tx_disable.dev_attr.attr, - &sensor_dev_attr_port_14_tx_disable.dev_attr.attr, - &sensor_dev_attr_port_15_tx_disable.dev_attr.attr, - &sensor_dev_attr_port_16_tx_disable.dev_attr.attr, - &sensor_dev_attr_port_17_tx_disable.dev_attr.attr, - &sensor_dev_attr_port_18_tx_disable.dev_attr.attr, - &sensor_dev_attr_port_19_tx_disable.dev_attr.attr, - &sensor_dev_attr_port_20_tx_disable.dev_attr.attr, - &sensor_dev_attr_port_21_tx_disable.dev_attr.attr, - &sensor_dev_attr_port_22_tx_disable.dev_attr.attr, - &sensor_dev_attr_port_23_tx_disable.dev_attr.attr, - &sensor_dev_attr_port_24_tx_disable.dev_attr.attr, - &sensor_dev_attr_port_25_tx_disable.dev_attr.attr, - &sensor_dev_attr_port_26_tx_disable.dev_attr.attr, - &sensor_dev_attr_port_27_tx_disable.dev_attr.attr, - &sensor_dev_attr_port_28_tx_disable.dev_attr.attr, - &sensor_dev_attr_port_29_tx_disable.dev_attr.attr, - &sensor_dev_attr_port_30_tx_disable.dev_attr.attr, - &sensor_dev_attr_port_31_tx_disable.dev_attr.attr, - &sensor_dev_attr_port_32_tx_disable.dev_attr.attr, - &sensor_dev_attr_port_33_tx_disable.dev_attr.attr, - &sensor_dev_attr_port_34_tx_disable.dev_attr.attr, - &sensor_dev_attr_port_35_tx_disable.dev_attr.attr, - &sensor_dev_attr_port_36_tx_disable.dev_attr.attr, - &sensor_dev_attr_port_37_tx_disable.dev_attr.attr, - &sensor_dev_attr_port_38_tx_disable.dev_attr.attr, - &sensor_dev_attr_port_39_tx_disable.dev_attr.attr, - &sensor_dev_attr_port_40_tx_disable.dev_attr.attr, - &sensor_dev_attr_port_41_tx_disable.dev_attr.attr, - &sensor_dev_attr_port_42_tx_disable.dev_attr.attr, - &sensor_dev_attr_port_43_tx_disable.dev_attr.attr, - &sensor_dev_attr_port_44_tx_disable.dev_attr.attr, - &sensor_dev_attr_port_45_tx_disable.dev_attr.attr, - &sensor_dev_attr_port_46_tx_disable.dev_attr.attr, - &sensor_dev_attr_port_47_tx_disable.dev_attr.attr, - &sensor_dev_attr_port_48_tx_disable.dev_attr.attr, - - &sensor_dev_attr_fan1_abs.dev_attr.attr, - &sensor_dev_attr_fan2_abs.dev_attr.attr, - &sensor_dev_attr_fan3_abs.dev_attr.attr, - &sensor_dev_attr_fan4_abs.dev_attr.attr, - - &sensor_dev_attr_fan1_dir.dev_attr.attr, - &sensor_dev_attr_fan2_dir.dev_attr.attr, - &sensor_dev_attr_fan3_dir.dev_attr.attr, - &sensor_dev_attr_fan4_dir.dev_attr.attr, - - &sensor_dev_attr_psu1_eeprom.dev_attr.attr, - &sensor_dev_attr_psu2_eeprom.dev_attr.attr, - - &sensor_dev_attr_psu1_vout.dev_attr.attr, - &sensor_dev_attr_psu1_iout.dev_attr.attr, - &sensor_dev_attr_psu1_temp_1.dev_attr.attr, - &sensor_dev_attr_psu1_temp_2.dev_attr.attr, - &sensor_dev_attr_psu1_fan_speed.dev_attr.attr, - &sensor_dev_attr_psu1_pout.dev_attr.attr, - &sensor_dev_attr_psu1_pin.dev_attr.attr, - - &sensor_dev_attr_psu2_vout.dev_attr.attr, - &sensor_dev_attr_psu2_iout.dev_attr.attr, - &sensor_dev_attr_psu2_temp_1.dev_attr.attr, - &sensor_dev_attr_psu2_temp_2.dev_attr.attr, - &sensor_dev_attr_psu2_fan_speed.dev_attr.attr, - &sensor_dev_attr_psu2_pout.dev_attr.attr, - &sensor_dev_attr_psu2_pin.dev_attr.attr, - - &dev_attr_psu_power_off.attr, - - /* lm-sensors */ - &sensor_dev_attr_in12_input.dev_attr.attr, - &sensor_dev_attr_curr12_input.dev_attr.attr, - &sensor_dev_attr_power11_input.dev_attr.attr, - &sensor_dev_attr_power12_input.dev_attr.attr, - &sensor_dev_attr_temp11_input.dev_attr.attr, - &sensor_dev_attr_temp12_input.dev_attr.attr, - &sensor_dev_attr_fan11_input.dev_attr.attr, - - &sensor_dev_attr_in22_input.dev_attr.attr, - &sensor_dev_attr_curr22_input.dev_attr.attr, - &sensor_dev_attr_power21_input.dev_attr.attr, - &sensor_dev_attr_power22_input.dev_attr.attr, - &sensor_dev_attr_temp21_input.dev_attr.attr, - &sensor_dev_attr_temp22_input.dev_attr.attr, - &sensor_dev_attr_fan21_input.dev_attr.attr, - - NULL -}; - -static struct attribute *i2c_bus1_hardware_monitor_attr_asterion[] = { - &dev_attr_eeprom.attr, - &dev_attr_system_led.attr, - &dev_attr_fan_led.attr, - &sensor_dev_attr_psu1_led.dev_attr.attr, - &sensor_dev_attr_psu2_led.dev_attr.attr, - - &sensor_dev_attr_port_1_data_a0.dev_attr.attr, - &sensor_dev_attr_port_2_data_a0.dev_attr.attr, - &sensor_dev_attr_port_3_data_a0.dev_attr.attr, - &sensor_dev_attr_port_4_data_a0.dev_attr.attr, - &sensor_dev_attr_port_5_data_a0.dev_attr.attr, - &sensor_dev_attr_port_6_data_a0.dev_attr.attr, - &sensor_dev_attr_port_7_data_a0.dev_attr.attr, - &sensor_dev_attr_port_8_data_a0.dev_attr.attr, - &sensor_dev_attr_port_9_data_a0.dev_attr.attr, - &sensor_dev_attr_port_10_data_a0.dev_attr.attr, - &sensor_dev_attr_port_11_data_a0.dev_attr.attr, - &sensor_dev_attr_port_12_data_a0.dev_attr.attr, - &sensor_dev_attr_port_13_data_a0.dev_attr.attr, - &sensor_dev_attr_port_14_data_a0.dev_attr.attr, - &sensor_dev_attr_port_15_data_a0.dev_attr.attr, - &sensor_dev_attr_port_16_data_a0.dev_attr.attr, - &sensor_dev_attr_port_17_data_a0.dev_attr.attr, - &sensor_dev_attr_port_18_data_a0.dev_attr.attr, - &sensor_dev_attr_port_19_data_a0.dev_attr.attr, - &sensor_dev_attr_port_20_data_a0.dev_attr.attr, - &sensor_dev_attr_port_21_data_a0.dev_attr.attr, - &sensor_dev_attr_port_22_data_a0.dev_attr.attr, - &sensor_dev_attr_port_23_data_a0.dev_attr.attr, - &sensor_dev_attr_port_24_data_a0.dev_attr.attr, - &sensor_dev_attr_port_25_data_a0.dev_attr.attr, - &sensor_dev_attr_port_26_data_a0.dev_attr.attr, - &sensor_dev_attr_port_27_data_a0.dev_attr.attr, - &sensor_dev_attr_port_28_data_a0.dev_attr.attr, - &sensor_dev_attr_port_29_data_a0.dev_attr.attr, - &sensor_dev_attr_port_30_data_a0.dev_attr.attr, - &sensor_dev_attr_port_31_data_a0.dev_attr.attr, - &sensor_dev_attr_port_32_data_a0.dev_attr.attr, - &sensor_dev_attr_port_33_data_a0.dev_attr.attr, - &sensor_dev_attr_port_34_data_a0.dev_attr.attr, - &sensor_dev_attr_port_35_data_a0.dev_attr.attr, - &sensor_dev_attr_port_36_data_a0.dev_attr.attr, - &sensor_dev_attr_port_37_data_a0.dev_attr.attr, - &sensor_dev_attr_port_38_data_a0.dev_attr.attr, - &sensor_dev_attr_port_39_data_a0.dev_attr.attr, - &sensor_dev_attr_port_40_data_a0.dev_attr.attr, - &sensor_dev_attr_port_41_data_a0.dev_attr.attr, - &sensor_dev_attr_port_42_data_a0.dev_attr.attr, - &sensor_dev_attr_port_43_data_a0.dev_attr.attr, - &sensor_dev_attr_port_44_data_a0.dev_attr.attr, - &sensor_dev_attr_port_45_data_a0.dev_attr.attr, - &sensor_dev_attr_port_46_data_a0.dev_attr.attr, - &sensor_dev_attr_port_47_data_a0.dev_attr.attr, - &sensor_dev_attr_port_48_data_a0.dev_attr.attr, - &sensor_dev_attr_port_49_data_a0.dev_attr.attr, - &sensor_dev_attr_port_50_data_a0.dev_attr.attr, - &sensor_dev_attr_port_51_data_a0.dev_attr.attr, - &sensor_dev_attr_port_52_data_a0.dev_attr.attr, - &sensor_dev_attr_port_53_data_a0.dev_attr.attr, - &sensor_dev_attr_port_54_data_a0.dev_attr.attr, - &sensor_dev_attr_port_55_data_a0.dev_attr.attr, - &sensor_dev_attr_port_56_data_a0.dev_attr.attr, - &sensor_dev_attr_port_57_data_a0.dev_attr.attr, - &sensor_dev_attr_port_58_data_a0.dev_attr.attr, - &sensor_dev_attr_port_59_data_a0.dev_attr.attr, - &sensor_dev_attr_port_60_data_a0.dev_attr.attr, - &sensor_dev_attr_port_61_data_a0.dev_attr.attr, - &sensor_dev_attr_port_62_data_a0.dev_attr.attr, - &sensor_dev_attr_port_63_data_a0.dev_attr.attr, - &sensor_dev_attr_port_64_data_a0.dev_attr.attr, - - &sensor_dev_attr_port_1_data_a2.dev_attr.attr, - &sensor_dev_attr_port_2_data_a2.dev_attr.attr, - &sensor_dev_attr_port_3_data_a2.dev_attr.attr, - &sensor_dev_attr_port_4_data_a2.dev_attr.attr, - &sensor_dev_attr_port_5_data_a2.dev_attr.attr, - &sensor_dev_attr_port_6_data_a2.dev_attr.attr, - &sensor_dev_attr_port_7_data_a2.dev_attr.attr, - &sensor_dev_attr_port_8_data_a2.dev_attr.attr, - &sensor_dev_attr_port_9_data_a2.dev_attr.attr, - &sensor_dev_attr_port_10_data_a2.dev_attr.attr, - &sensor_dev_attr_port_11_data_a2.dev_attr.attr, - &sensor_dev_attr_port_12_data_a2.dev_attr.attr, - &sensor_dev_attr_port_13_data_a2.dev_attr.attr, - &sensor_dev_attr_port_14_data_a2.dev_attr.attr, - &sensor_dev_attr_port_15_data_a2.dev_attr.attr, - &sensor_dev_attr_port_16_data_a2.dev_attr.attr, - &sensor_dev_attr_port_17_data_a2.dev_attr.attr, - &sensor_dev_attr_port_18_data_a2.dev_attr.attr, - &sensor_dev_attr_port_19_data_a2.dev_attr.attr, - &sensor_dev_attr_port_20_data_a2.dev_attr.attr, - &sensor_dev_attr_port_21_data_a2.dev_attr.attr, - &sensor_dev_attr_port_22_data_a2.dev_attr.attr, - &sensor_dev_attr_port_23_data_a2.dev_attr.attr, - &sensor_dev_attr_port_24_data_a2.dev_attr.attr, - &sensor_dev_attr_port_25_data_a2.dev_attr.attr, - &sensor_dev_attr_port_26_data_a2.dev_attr.attr, - &sensor_dev_attr_port_27_data_a2.dev_attr.attr, - &sensor_dev_attr_port_28_data_a2.dev_attr.attr, - &sensor_dev_attr_port_29_data_a2.dev_attr.attr, - &sensor_dev_attr_port_30_data_a2.dev_attr.attr, - &sensor_dev_attr_port_31_data_a2.dev_attr.attr, - &sensor_dev_attr_port_32_data_a2.dev_attr.attr, - &sensor_dev_attr_port_33_data_a2.dev_attr.attr, - &sensor_dev_attr_port_34_data_a2.dev_attr.attr, - &sensor_dev_attr_port_35_data_a2.dev_attr.attr, - &sensor_dev_attr_port_36_data_a2.dev_attr.attr, - &sensor_dev_attr_port_37_data_a2.dev_attr.attr, - &sensor_dev_attr_port_38_data_a2.dev_attr.attr, - &sensor_dev_attr_port_39_data_a2.dev_attr.attr, - &sensor_dev_attr_port_40_data_a2.dev_attr.attr, - &sensor_dev_attr_port_41_data_a2.dev_attr.attr, - &sensor_dev_attr_port_42_data_a2.dev_attr.attr, - &sensor_dev_attr_port_43_data_a2.dev_attr.attr, - &sensor_dev_attr_port_44_data_a2.dev_attr.attr, - &sensor_dev_attr_port_45_data_a2.dev_attr.attr, - &sensor_dev_attr_port_46_data_a2.dev_attr.attr, - &sensor_dev_attr_port_47_data_a2.dev_attr.attr, - &sensor_dev_attr_port_48_data_a2.dev_attr.attr, - &sensor_dev_attr_port_49_data_a2.dev_attr.attr, - &sensor_dev_attr_port_50_data_a2.dev_attr.attr, - &sensor_dev_attr_port_51_data_a2.dev_attr.attr, - &sensor_dev_attr_port_52_data_a2.dev_attr.attr, - &sensor_dev_attr_port_53_data_a2.dev_attr.attr, - &sensor_dev_attr_port_54_data_a2.dev_attr.attr, - &sensor_dev_attr_port_55_data_a2.dev_attr.attr, - &sensor_dev_attr_port_56_data_a2.dev_attr.attr, - &sensor_dev_attr_port_57_data_a2.dev_attr.attr, - &sensor_dev_attr_port_58_data_a2.dev_attr.attr, - &sensor_dev_attr_port_59_data_a2.dev_attr.attr, - &sensor_dev_attr_port_60_data_a2.dev_attr.attr, - &sensor_dev_attr_port_61_data_a2.dev_attr.attr, - &sensor_dev_attr_port_62_data_a2.dev_attr.attr, - &sensor_dev_attr_port_63_data_a2.dev_attr.attr, - &sensor_dev_attr_port_64_data_a2.dev_attr.attr, - - &sensor_dev_attr_port_1_sfp_copper.dev_attr.attr, - &sensor_dev_attr_port_2_sfp_copper.dev_attr.attr, - &sensor_dev_attr_port_3_sfp_copper.dev_attr.attr, - &sensor_dev_attr_port_4_sfp_copper.dev_attr.attr, - &sensor_dev_attr_port_5_sfp_copper.dev_attr.attr, - &sensor_dev_attr_port_6_sfp_copper.dev_attr.attr, - &sensor_dev_attr_port_7_sfp_copper.dev_attr.attr, - &sensor_dev_attr_port_8_sfp_copper.dev_attr.attr, - &sensor_dev_attr_port_9_sfp_copper.dev_attr.attr, - &sensor_dev_attr_port_10_sfp_copper.dev_attr.attr, - &sensor_dev_attr_port_11_sfp_copper.dev_attr.attr, - &sensor_dev_attr_port_12_sfp_copper.dev_attr.attr, - &sensor_dev_attr_port_13_sfp_copper.dev_attr.attr, - &sensor_dev_attr_port_14_sfp_copper.dev_attr.attr, - &sensor_dev_attr_port_15_sfp_copper.dev_attr.attr, - &sensor_dev_attr_port_16_sfp_copper.dev_attr.attr, - &sensor_dev_attr_port_17_sfp_copper.dev_attr.attr, - &sensor_dev_attr_port_18_sfp_copper.dev_attr.attr, - &sensor_dev_attr_port_19_sfp_copper.dev_attr.attr, - &sensor_dev_attr_port_20_sfp_copper.dev_attr.attr, - &sensor_dev_attr_port_21_sfp_copper.dev_attr.attr, - &sensor_dev_attr_port_22_sfp_copper.dev_attr.attr, - &sensor_dev_attr_port_23_sfp_copper.dev_attr.attr, - &sensor_dev_attr_port_24_sfp_copper.dev_attr.attr, - &sensor_dev_attr_port_25_sfp_copper.dev_attr.attr, - &sensor_dev_attr_port_26_sfp_copper.dev_attr.attr, - &sensor_dev_attr_port_27_sfp_copper.dev_attr.attr, - &sensor_dev_attr_port_28_sfp_copper.dev_attr.attr, - &sensor_dev_attr_port_29_sfp_copper.dev_attr.attr, - &sensor_dev_attr_port_30_sfp_copper.dev_attr.attr, - &sensor_dev_attr_port_31_sfp_copper.dev_attr.attr, - &sensor_dev_attr_port_32_sfp_copper.dev_attr.attr, - &sensor_dev_attr_port_33_sfp_copper.dev_attr.attr, - &sensor_dev_attr_port_34_sfp_copper.dev_attr.attr, - &sensor_dev_attr_port_35_sfp_copper.dev_attr.attr, - &sensor_dev_attr_port_36_sfp_copper.dev_attr.attr, - &sensor_dev_attr_port_37_sfp_copper.dev_attr.attr, - &sensor_dev_attr_port_38_sfp_copper.dev_attr.attr, - &sensor_dev_attr_port_39_sfp_copper.dev_attr.attr, - &sensor_dev_attr_port_40_sfp_copper.dev_attr.attr, - &sensor_dev_attr_port_41_sfp_copper.dev_attr.attr, - &sensor_dev_attr_port_42_sfp_copper.dev_attr.attr, - &sensor_dev_attr_port_43_sfp_copper.dev_attr.attr, - &sensor_dev_attr_port_44_sfp_copper.dev_attr.attr, - &sensor_dev_attr_port_45_sfp_copper.dev_attr.attr, - &sensor_dev_attr_port_46_sfp_copper.dev_attr.attr, - &sensor_dev_attr_port_47_sfp_copper.dev_attr.attr, - &sensor_dev_attr_port_48_sfp_copper.dev_attr.attr, - &sensor_dev_attr_port_49_sfp_copper.dev_attr.attr, - &sensor_dev_attr_port_50_sfp_copper.dev_attr.attr, - &sensor_dev_attr_port_51_sfp_copper.dev_attr.attr, - &sensor_dev_attr_port_52_sfp_copper.dev_attr.attr, - &sensor_dev_attr_port_53_sfp_copper.dev_attr.attr, - &sensor_dev_attr_port_54_sfp_copper.dev_attr.attr, - &sensor_dev_attr_port_55_sfp_copper.dev_attr.attr, - &sensor_dev_attr_port_56_sfp_copper.dev_attr.attr, - &sensor_dev_attr_port_57_sfp_copper.dev_attr.attr, - &sensor_dev_attr_port_58_sfp_copper.dev_attr.attr, - &sensor_dev_attr_port_59_sfp_copper.dev_attr.attr, - &sensor_dev_attr_port_60_sfp_copper.dev_attr.attr, - &sensor_dev_attr_port_61_sfp_copper.dev_attr.attr, - &sensor_dev_attr_port_62_sfp_copper.dev_attr.attr, - &sensor_dev_attr_port_63_sfp_copper.dev_attr.attr, - &sensor_dev_attr_port_64_sfp_copper.dev_attr.attr, - - &sensor_dev_attr_port_1_abs.dev_attr.attr, - &sensor_dev_attr_port_2_abs.dev_attr.attr, - &sensor_dev_attr_port_3_abs.dev_attr.attr, - &sensor_dev_attr_port_4_abs.dev_attr.attr, - &sensor_dev_attr_port_5_abs.dev_attr.attr, - &sensor_dev_attr_port_6_abs.dev_attr.attr, - &sensor_dev_attr_port_7_abs.dev_attr.attr, - &sensor_dev_attr_port_8_abs.dev_attr.attr, - &sensor_dev_attr_port_9_abs.dev_attr.attr, - &sensor_dev_attr_port_10_abs.dev_attr.attr, - &sensor_dev_attr_port_11_abs.dev_attr.attr, - &sensor_dev_attr_port_12_abs.dev_attr.attr, - &sensor_dev_attr_port_13_abs.dev_attr.attr, - &sensor_dev_attr_port_14_abs.dev_attr.attr, - &sensor_dev_attr_port_15_abs.dev_attr.attr, - &sensor_dev_attr_port_16_abs.dev_attr.attr, - &sensor_dev_attr_port_17_abs.dev_attr.attr, - &sensor_dev_attr_port_18_abs.dev_attr.attr, - &sensor_dev_attr_port_19_abs.dev_attr.attr, - &sensor_dev_attr_port_20_abs.dev_attr.attr, - &sensor_dev_attr_port_21_abs.dev_attr.attr, - &sensor_dev_attr_port_22_abs.dev_attr.attr, - &sensor_dev_attr_port_23_abs.dev_attr.attr, - &sensor_dev_attr_port_24_abs.dev_attr.attr, - &sensor_dev_attr_port_25_abs.dev_attr.attr, - &sensor_dev_attr_port_26_abs.dev_attr.attr, - &sensor_dev_attr_port_27_abs.dev_attr.attr, - &sensor_dev_attr_port_28_abs.dev_attr.attr, - &sensor_dev_attr_port_29_abs.dev_attr.attr, - &sensor_dev_attr_port_30_abs.dev_attr.attr, - &sensor_dev_attr_port_31_abs.dev_attr.attr, - &sensor_dev_attr_port_32_abs.dev_attr.attr, - &sensor_dev_attr_port_33_abs.dev_attr.attr, - &sensor_dev_attr_port_34_abs.dev_attr.attr, - &sensor_dev_attr_port_35_abs.dev_attr.attr, - &sensor_dev_attr_port_36_abs.dev_attr.attr, - &sensor_dev_attr_port_37_abs.dev_attr.attr, - &sensor_dev_attr_port_38_abs.dev_attr.attr, - &sensor_dev_attr_port_39_abs.dev_attr.attr, - &sensor_dev_attr_port_40_abs.dev_attr.attr, - &sensor_dev_attr_port_41_abs.dev_attr.attr, - &sensor_dev_attr_port_42_abs.dev_attr.attr, - &sensor_dev_attr_port_43_abs.dev_attr.attr, - &sensor_dev_attr_port_44_abs.dev_attr.attr, - &sensor_dev_attr_port_45_abs.dev_attr.attr, - &sensor_dev_attr_port_46_abs.dev_attr.attr, - &sensor_dev_attr_port_47_abs.dev_attr.attr, - &sensor_dev_attr_port_48_abs.dev_attr.attr, - &sensor_dev_attr_port_49_abs.dev_attr.attr, - &sensor_dev_attr_port_50_abs.dev_attr.attr, - &sensor_dev_attr_port_51_abs.dev_attr.attr, - &sensor_dev_attr_port_52_abs.dev_attr.attr, - &sensor_dev_attr_port_53_abs.dev_attr.attr, - &sensor_dev_attr_port_54_abs.dev_attr.attr, - &sensor_dev_attr_port_55_abs.dev_attr.attr, - &sensor_dev_attr_port_56_abs.dev_attr.attr, - &sensor_dev_attr_port_57_abs.dev_attr.attr, - &sensor_dev_attr_port_58_abs.dev_attr.attr, - &sensor_dev_attr_port_59_abs.dev_attr.attr, - &sensor_dev_attr_port_60_abs.dev_attr.attr, - &sensor_dev_attr_port_61_abs.dev_attr.attr, - &sensor_dev_attr_port_62_abs.dev_attr.attr, - &sensor_dev_attr_port_63_abs.dev_attr.attr, - &sensor_dev_attr_port_64_abs.dev_attr.attr, - - &sensor_dev_attr_port_1_rxlos.dev_attr.attr, - &sensor_dev_attr_port_2_rxlos.dev_attr.attr, - &sensor_dev_attr_port_3_rxlos.dev_attr.attr, - &sensor_dev_attr_port_4_rxlos.dev_attr.attr, - &sensor_dev_attr_port_5_rxlos.dev_attr.attr, - &sensor_dev_attr_port_6_rxlos.dev_attr.attr, - &sensor_dev_attr_port_7_rxlos.dev_attr.attr, - &sensor_dev_attr_port_8_rxlos.dev_attr.attr, - &sensor_dev_attr_port_9_rxlos.dev_attr.attr, - &sensor_dev_attr_port_10_rxlos.dev_attr.attr, - &sensor_dev_attr_port_11_rxlos.dev_attr.attr, - &sensor_dev_attr_port_12_rxlos.dev_attr.attr, - &sensor_dev_attr_port_13_rxlos.dev_attr.attr, - &sensor_dev_attr_port_14_rxlos.dev_attr.attr, - &sensor_dev_attr_port_15_rxlos.dev_attr.attr, - &sensor_dev_attr_port_16_rxlos.dev_attr.attr, - &sensor_dev_attr_port_17_rxlos.dev_attr.attr, - &sensor_dev_attr_port_18_rxlos.dev_attr.attr, - &sensor_dev_attr_port_19_rxlos.dev_attr.attr, - &sensor_dev_attr_port_20_rxlos.dev_attr.attr, - &sensor_dev_attr_port_21_rxlos.dev_attr.attr, - &sensor_dev_attr_port_22_rxlos.dev_attr.attr, - &sensor_dev_attr_port_23_rxlos.dev_attr.attr, - &sensor_dev_attr_port_24_rxlos.dev_attr.attr, - &sensor_dev_attr_port_25_rxlos.dev_attr.attr, - &sensor_dev_attr_port_26_rxlos.dev_attr.attr, - &sensor_dev_attr_port_27_rxlos.dev_attr.attr, - &sensor_dev_attr_port_28_rxlos.dev_attr.attr, - &sensor_dev_attr_port_29_rxlos.dev_attr.attr, - &sensor_dev_attr_port_30_rxlos.dev_attr.attr, - &sensor_dev_attr_port_31_rxlos.dev_attr.attr, - &sensor_dev_attr_port_32_rxlos.dev_attr.attr, - &sensor_dev_attr_port_33_rxlos.dev_attr.attr, - &sensor_dev_attr_port_34_rxlos.dev_attr.attr, - &sensor_dev_attr_port_35_rxlos.dev_attr.attr, - &sensor_dev_attr_port_36_rxlos.dev_attr.attr, - &sensor_dev_attr_port_37_rxlos.dev_attr.attr, - &sensor_dev_attr_port_38_rxlos.dev_attr.attr, - &sensor_dev_attr_port_39_rxlos.dev_attr.attr, - &sensor_dev_attr_port_40_rxlos.dev_attr.attr, - &sensor_dev_attr_port_41_rxlos.dev_attr.attr, - &sensor_dev_attr_port_42_rxlos.dev_attr.attr, - &sensor_dev_attr_port_43_rxlos.dev_attr.attr, - &sensor_dev_attr_port_44_rxlos.dev_attr.attr, - &sensor_dev_attr_port_45_rxlos.dev_attr.attr, - &sensor_dev_attr_port_46_rxlos.dev_attr.attr, - &sensor_dev_attr_port_47_rxlos.dev_attr.attr, - &sensor_dev_attr_port_48_rxlos.dev_attr.attr, - - &sensor_dev_attr_port_1_tx_disable.dev_attr.attr, - &sensor_dev_attr_port_2_tx_disable.dev_attr.attr, - &sensor_dev_attr_port_3_tx_disable.dev_attr.attr, - &sensor_dev_attr_port_4_tx_disable.dev_attr.attr, - &sensor_dev_attr_port_5_tx_disable.dev_attr.attr, - &sensor_dev_attr_port_6_tx_disable.dev_attr.attr, - &sensor_dev_attr_port_7_tx_disable.dev_attr.attr, - &sensor_dev_attr_port_8_tx_disable.dev_attr.attr, - &sensor_dev_attr_port_9_tx_disable.dev_attr.attr, - &sensor_dev_attr_port_10_tx_disable.dev_attr.attr, - &sensor_dev_attr_port_11_tx_disable.dev_attr.attr, - &sensor_dev_attr_port_12_tx_disable.dev_attr.attr, - &sensor_dev_attr_port_13_tx_disable.dev_attr.attr, - &sensor_dev_attr_port_14_tx_disable.dev_attr.attr, - &sensor_dev_attr_port_15_tx_disable.dev_attr.attr, - &sensor_dev_attr_port_16_tx_disable.dev_attr.attr, - &sensor_dev_attr_port_17_tx_disable.dev_attr.attr, - &sensor_dev_attr_port_18_tx_disable.dev_attr.attr, - &sensor_dev_attr_port_19_tx_disable.dev_attr.attr, - &sensor_dev_attr_port_20_tx_disable.dev_attr.attr, - &sensor_dev_attr_port_21_tx_disable.dev_attr.attr, - &sensor_dev_attr_port_22_tx_disable.dev_attr.attr, - &sensor_dev_attr_port_23_tx_disable.dev_attr.attr, - &sensor_dev_attr_port_24_tx_disable.dev_attr.attr, - &sensor_dev_attr_port_25_tx_disable.dev_attr.attr, - &sensor_dev_attr_port_26_tx_disable.dev_attr.attr, - &sensor_dev_attr_port_27_tx_disable.dev_attr.attr, - &sensor_dev_attr_port_28_tx_disable.dev_attr.attr, - &sensor_dev_attr_port_29_tx_disable.dev_attr.attr, - &sensor_dev_attr_port_30_tx_disable.dev_attr.attr, - &sensor_dev_attr_port_31_tx_disable.dev_attr.attr, - &sensor_dev_attr_port_32_tx_disable.dev_attr.attr, - &sensor_dev_attr_port_33_tx_disable.dev_attr.attr, - &sensor_dev_attr_port_34_tx_disable.dev_attr.attr, - &sensor_dev_attr_port_35_tx_disable.dev_attr.attr, - &sensor_dev_attr_port_36_tx_disable.dev_attr.attr, - &sensor_dev_attr_port_37_tx_disable.dev_attr.attr, - &sensor_dev_attr_port_38_tx_disable.dev_attr.attr, - &sensor_dev_attr_port_39_tx_disable.dev_attr.attr, - &sensor_dev_attr_port_40_tx_disable.dev_attr.attr, - &sensor_dev_attr_port_41_tx_disable.dev_attr.attr, - &sensor_dev_attr_port_42_tx_disable.dev_attr.attr, - &sensor_dev_attr_port_43_tx_disable.dev_attr.attr, - &sensor_dev_attr_port_44_tx_disable.dev_attr.attr, - &sensor_dev_attr_port_45_tx_disable.dev_attr.attr, - &sensor_dev_attr_port_46_tx_disable.dev_attr.attr, - &sensor_dev_attr_port_47_tx_disable.dev_attr.attr, - &sensor_dev_attr_port_48_tx_disable.dev_attr.attr, - - &sensor_dev_attr_port_1_rate_select.dev_attr.attr, - &sensor_dev_attr_port_2_rate_select.dev_attr.attr, - &sensor_dev_attr_port_3_rate_select.dev_attr.attr, - &sensor_dev_attr_port_4_rate_select.dev_attr.attr, - &sensor_dev_attr_port_5_rate_select.dev_attr.attr, - &sensor_dev_attr_port_6_rate_select.dev_attr.attr, - &sensor_dev_attr_port_7_rate_select.dev_attr.attr, - &sensor_dev_attr_port_8_rate_select.dev_attr.attr, - &sensor_dev_attr_port_9_rate_select.dev_attr.attr, - &sensor_dev_attr_port_10_rate_select.dev_attr.attr, - &sensor_dev_attr_port_11_rate_select.dev_attr.attr, - &sensor_dev_attr_port_12_rate_select.dev_attr.attr, - &sensor_dev_attr_port_13_rate_select.dev_attr.attr, - &sensor_dev_attr_port_14_rate_select.dev_attr.attr, - &sensor_dev_attr_port_15_rate_select.dev_attr.attr, - &sensor_dev_attr_port_16_rate_select.dev_attr.attr, - &sensor_dev_attr_port_17_rate_select.dev_attr.attr, - &sensor_dev_attr_port_18_rate_select.dev_attr.attr, - &sensor_dev_attr_port_19_rate_select.dev_attr.attr, - &sensor_dev_attr_port_20_rate_select.dev_attr.attr, - &sensor_dev_attr_port_21_rate_select.dev_attr.attr, - &sensor_dev_attr_port_22_rate_select.dev_attr.attr, - &sensor_dev_attr_port_23_rate_select.dev_attr.attr, - &sensor_dev_attr_port_24_rate_select.dev_attr.attr, - &sensor_dev_attr_port_25_rate_select.dev_attr.attr, - &sensor_dev_attr_port_26_rate_select.dev_attr.attr, - &sensor_dev_attr_port_27_rate_select.dev_attr.attr, - &sensor_dev_attr_port_28_rate_select.dev_attr.attr, - &sensor_dev_attr_port_29_rate_select.dev_attr.attr, - &sensor_dev_attr_port_30_rate_select.dev_attr.attr, - &sensor_dev_attr_port_31_rate_select.dev_attr.attr, - &sensor_dev_attr_port_32_rate_select.dev_attr.attr, - &sensor_dev_attr_port_33_rate_select.dev_attr.attr, - &sensor_dev_attr_port_34_rate_select.dev_attr.attr, - &sensor_dev_attr_port_35_rate_select.dev_attr.attr, - &sensor_dev_attr_port_36_rate_select.dev_attr.attr, - &sensor_dev_attr_port_37_rate_select.dev_attr.attr, - &sensor_dev_attr_port_38_rate_select.dev_attr.attr, - &sensor_dev_attr_port_39_rate_select.dev_attr.attr, - &sensor_dev_attr_port_40_rate_select.dev_attr.attr, - &sensor_dev_attr_port_41_rate_select.dev_attr.attr, - &sensor_dev_attr_port_42_rate_select.dev_attr.attr, - &sensor_dev_attr_port_43_rate_select.dev_attr.attr, - &sensor_dev_attr_port_44_rate_select.dev_attr.attr, - &sensor_dev_attr_port_45_rate_select.dev_attr.attr, - &sensor_dev_attr_port_46_rate_select.dev_attr.attr, - &sensor_dev_attr_port_47_rate_select.dev_attr.attr, - &sensor_dev_attr_port_48_rate_select.dev_attr.attr, - - &sensor_dev_attr_fan1_abs.dev_attr.attr, - &sensor_dev_attr_fan2_abs.dev_attr.attr, - &sensor_dev_attr_fan3_abs.dev_attr.attr, - &sensor_dev_attr_fan4_abs.dev_attr.attr, - &sensor_dev_attr_fan5_abs.dev_attr.attr, - - &sensor_dev_attr_fan1_dir.dev_attr.attr, - &sensor_dev_attr_fan2_dir.dev_attr.attr, - &sensor_dev_attr_fan3_dir.dev_attr.attr, - &sensor_dev_attr_fan4_dir.dev_attr.attr, - &sensor_dev_attr_fan5_dir.dev_attr.attr, - - &sensor_dev_attr_psu1_eeprom.dev_attr.attr, - &sensor_dev_attr_psu2_eeprom.dev_attr.attr, - - &sensor_dev_attr_psu1_vout.dev_attr.attr, - &sensor_dev_attr_psu1_iout.dev_attr.attr, - &sensor_dev_attr_psu1_temp_1.dev_attr.attr, - &sensor_dev_attr_psu1_fan_speed.dev_attr.attr, - &sensor_dev_attr_psu1_pout.dev_attr.attr, - - &sensor_dev_attr_psu2_vout.dev_attr.attr, - &sensor_dev_attr_psu2_iout.dev_attr.attr, - &sensor_dev_attr_psu2_temp_1.dev_attr.attr, - &sensor_dev_attr_psu2_fan_speed.dev_attr.attr, - &sensor_dev_attr_psu2_pout.dev_attr.attr, - - &dev_attr_psu_power_off.attr, - - /* lm-sensors */ - &sensor_dev_attr_in12_input.dev_attr.attr, - &sensor_dev_attr_curr12_input.dev_attr.attr, - &sensor_dev_attr_power11_input.dev_attr.attr, - &sensor_dev_attr_power12_input.dev_attr.attr, - &sensor_dev_attr_temp11_input.dev_attr.attr, - &sensor_dev_attr_temp12_input.dev_attr.attr, - &sensor_dev_attr_fan11_input.dev_attr.attr, - - &sensor_dev_attr_in22_input.dev_attr.attr, - &sensor_dev_attr_curr22_input.dev_attr.attr, - &sensor_dev_attr_power21_input.dev_attr.attr, - &sensor_dev_attr_power22_input.dev_attr.attr, - &sensor_dev_attr_temp21_input.dev_attr.attr, - &sensor_dev_attr_temp22_input.dev_attr.attr, - &sensor_dev_attr_fan21_input.dev_attr.attr, - - NULL -}; - -static int is_port_present(struct i2c_bus1_hardware_monitor_data *data, int port) -{ - int rc = 0; - - switch(platformModelId) - { - case NCIIX_WITH_BMC: - case NCIIX_WITHOUT_BMC: - rc = ((SFPPortAbsStatus[port] == 1) && (SFPPortDataValid[port] == 1)); - break; - - case ASTERION_WITH_BMC: - case ASTERION_WITHOUT_BMC: - { - unsigned char qsfpPortAbsAst = 0, index = 0, bit = 0; - unsigned char sfpPortDataValidAst = 0; - - if (port < 48) - { - index = (port / 2); - bit = ((port & 0x01) ? 5 : 1); - qsfpPortAbsAst = data->sfpPortAbsRxLosStatus[index]; - sfpPortDataValidAst = data->sfpPortDataValidAst[port]; - rc = ((PCA9553_TEST_BIT(qsfpPortAbsAst, bit) ? 0 : 1) && (sfpPortDataValidAst)); - } - else - { - index = (port % 48); - qsfpPortAbsAst = data->qsfpPortAbsStatusAst[index]; - sfpPortDataValidAst = data->sfpPortDataValidAst[port]; - rc = ((PCA9553_TEST_BIT(qsfpPortAbsAst, 1) ? 0 : 1) && (sfpPortDataValidAst)); - } - } - break; - - default: - { - unsigned short qsfpPortAbs = 0, index = 0, bit = 0; - unsigned short qsfpPortDataValid = 0; - - index = (port / 16); - bit = (port % 16); - qsfpPortAbs = data->qsfpPortAbsStatus[index]; - qsfpPortDataValid = data->qsfpPortDataValid[index]; - rc = ((PCA9553_TEST_BIT(qsfpPortAbs, bit) ? 0 : 1) && (PCA9553_TEST_BIT(qsfpPortDataValid, bit))); - } - break; - } - - return rc; -} - -static ssize_t get_qsfp_port_tx_rx_status(struct device *dev, struct device_attribute *devattr, char *buf) -{ - struct i2c_bus1_hardware_monitor_data *data = i2c_get_clientdata(&qsfpDataA0_client); - unsigned char qsfpPortData[QSFP_DATA_SIZE]; - struct i2c_client *client = to_i2c_client(dev); - struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); - int index = (client->addr - 1); - int val = 0; - - memset(qsfpPortData, 0, QSFP_DATA_SIZE); - - mutex_lock(&data->lock); - if (is_port_present(data, index) == 1) - memcpy(qsfpPortData, &(data->qsfpPortDataA0[index][0]), QSFP_DATA_SIZE); - else - { - qsfpPortData[SFF8436_RX_LOS_ADDR] = qsfpPortData[SFF8436_TX_FAULT_ADDR] = 0xF; - qsfpPortData[SFF8436_TX_DISABLE_ADDR] = data->qsfpPortTxDisableData[index]; - } - mutex_unlock(&data->lock); - - switch (attr->index) - { - case RX_LOS: - val = (qsfpPortData[SFF8436_RX_LOS_ADDR] & 0xF); - break; - case RX_LOS1: - case RX_LOS2: - case RX_LOS3: - case RX_LOS4: - val = (qsfpPortData[SFF8436_RX_LOS_ADDR] & BIT_INDEX(attr->index - RX_LOS1)); - break; - - case TX_DISABLE: - val = (qsfpPortData[SFF8436_TX_DISABLE_ADDR] & 0xF); - break; - case TX_DISABLE1: - case TX_DISABLE2: - case TX_DISABLE3: - case TX_DISABLE4: - val = (qsfpPortData[SFF8436_TX_DISABLE_ADDR] & BIT_INDEX(attr->index - TX_DISABLE1)); - break; - - case TX_FAULT: - val = (qsfpPortData[SFF8436_TX_FAULT_ADDR] & 0xF); - break; - case TX_FAULT1: - case TX_FAULT2: - case TX_FAULT3: - case TX_FAULT4: - val = (qsfpPortData[SFF8436_TX_FAULT_ADDR] & BIT_INDEX(attr->index - TX_FAULT1)); - break; - - default: - break; - } - return sprintf(buf, "%d\n", ((val) ? 1 : 0)); -} - -static ssize_t get_port_status(struct device *dev, struct device_attribute *devattr, char *buf) -{ - struct i2c_client *client = to_i2c_client(dev); - struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); - int status = LAST_ATTRIBUTE; - ssize_t count = 0; - - mutex_lock(&portStatusLock); - - status = attr->index; - - /* common status */ - switch (status) - { - case PRESENT: - attr->index = (client->addr - 1); - count = show_port_abs(dev, devattr, buf); - attr->index = status; - mutex_unlock(&portStatusLock); - return count; - - case EEPROM_A0_PAGE: - attr->index = (client->addr - 1); - count = show_port_data_a0(dev, devattr, buf); - attr->index = status; - mutex_unlock(&portStatusLock); - return count; - - case EEPROM_A2_PAGE: - attr->index = (client->addr - 1); - count = show_port_data_a2(dev, devattr, buf); - attr->index = status; - mutex_unlock(&portStatusLock); - return count; - - case SFP_COPPER: - attr->index = (client->addr - 1); - count = show_port_sfp_copper(dev, devattr, buf); - attr->index = status; - mutex_unlock(&portStatusLock); - return count; - - default: - break; - } - - /* status for QSFP ports */ - if (strncmp(client->name, "qsfp", strlen("qsfp")) == 0) - { - count = get_qsfp_port_tx_rx_status(dev, devattr, buf); - mutex_unlock(&portStatusLock); - return count; - } - - /* status for SFP+ ports */ - attr->index = (client->addr - 1); - switch (status) - { - case RX_LOS: - case RX_LOS1: - case RX_LOS2: - case RX_LOS3: - case RX_LOS4: - count = show_port_rxlos(dev, devattr, buf); - break; - - case TX_DISABLE: - case TX_DISABLE1: - case TX_DISABLE2: - case TX_DISABLE3: - case TX_DISABLE4: - count = show_port_tx_disable(dev, devattr, buf); - break; - - case TX_FAULT: - case TX_FAULT1: - case TX_FAULT2: - case TX_FAULT3: - case TX_FAULT4: - count = show_port_tx_fault(dev, devattr, buf); - break; - - default: - count = sprintf(buf, "0\n"); - break; - } - attr->index = status; - mutex_unlock(&portStatusLock); - return count; -} - -static ssize_t set_qsfp_port_tx_status(struct device *dev, struct device_attribute *devattr, const char *buf, size_t count) -{ - struct i2c_bus1_hardware_monitor_data *data = i2c_get_clientdata(&qsfpDataA0_client); - unsigned char qsfpPortData[QSFP_DATA_SIZE]; - struct i2c_client *client = to_i2c_client(dev); - struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); - int index = (client->addr - 1); - long disable; - - if (kstrtol(buf, 10, &disable)) - return -EINVAL; - disable = clamp_val(disable, 0, 1); - - memset(qsfpPortData, 0, QSFP_DATA_SIZE); - - mutex_lock(&data->lock); - memcpy(qsfpPortData, &(data->qsfpPortDataA0[index][0]), QSFP_DATA_SIZE); - switch (attr->index) - { - case TX_DISABLE: - if (disable == 1) - data->qsfpPortTxDisableData[index] = (qsfpPortData[SFF8436_TX_DISABLE_ADDR] |0xF); - else - data->qsfpPortTxDisableData[index] = (qsfpPortData[SFF8436_TX_DISABLE_ADDR] & 0xF0); - data->qsfpPortTxDisableDataUpdate[index] = 1; - break; - case TX_DISABLE1: - case TX_DISABLE2: - case TX_DISABLE3: - case TX_DISABLE4: - if (disable == 1) - data->qsfpPortTxDisableData[index] = (qsfpPortData[SFF8436_TX_DISABLE_ADDR] | (1 << (attr->index - TX_DISABLE1))); - else - data->qsfpPortTxDisableData[index] = (qsfpPortData[SFF8436_TX_DISABLE_ADDR] & ~(1 << (attr->index - TX_DISABLE1))); - data->qsfpPortTxDisableDataUpdate[index] = 1; - break; - - default: - break; - } - mutex_unlock(&data->lock); - return count; -} - -static ssize_t set_port_tx_status(struct device *dev, struct device_attribute *devattr, const char *buf, size_t count) -{ - struct i2c_client *client = to_i2c_client(dev); - struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); - int status = LAST_ATTRIBUTE; - - mutex_lock(&portStatusLock); - - /* status for QSFP ports */ - if (strncmp(client->name, "qsfp", strlen("qsfp")) == 0) - { - set_qsfp_port_tx_status(dev, devattr, buf, count); - mutex_unlock(&portStatusLock); - return count; - } - - /* status for SFP+ ports */ - status = attr->index; - attr->index = (client->addr - 1); - switch (status) - { - case TX_DISABLE: - case TX_DISABLE1: - case TX_DISABLE2: - case TX_DISABLE3: - case TX_DISABLE4: - set_port_tx_disable(dev, devattr, buf, count); - break; - - default: - break; - } - attr->index = status; - mutex_unlock(&portStatusLock); - return count; -} - -static ssize_t set_port_sfp_copper(struct device *dev, struct device_attribute *devattr, const char *buf, size_t count) -{ - struct i2c_client *client = to_i2c_client(dev); - - /* QSFP ports */ - if (strncmp(client->name, "qsfp", strlen("qsfp")) == 0) - { - return count; - } - /* SFP+ ports */ - else - { - struct i2c_bus1_hardware_monitor_data *data = i2c_get_clientdata(&SfpCopperData_client); - int index = (client->addr - 1); - long value; - - if ((platformModelId != NCIIX_WITH_BMC) && (platformModelId != NCIIX_WITHOUT_BMC)) - return count; - - if (kstrtol(buf, 10, &value)) - return -EINVAL; - - mutex_lock(&data->lock); - if (SFPPortAbsStatus[index]) /*present*/ - { - i2c_smbus_write_byte_data(&(pca9548_client[1]), 0, sfpPortData_78F[index].portMaskBitForPCA9548_1); - i2c_smbus_write_byte_data(&(pca9548_client[0]), 0, sfpPortData_78F[index].portMaskBitForPCA9548_2TO5); - i2c_device_word_write(&SfpCopperData_client, - (unsigned char)((value >> 16) & 0xff), - (unsigned short)(value & 0xffff)); - i2c_smbus_write_byte_data(&(pca9548_client[0]), 0, 0x00); - i2c_smbus_write_byte_data(&(pca9548_client[1]), 0, 0x00); - } - mutex_unlock(&data->lock); - } - - return count; -} - -static SENSOR_DEVICE_ATTR(abs, S_IRUGO, get_port_status, NULL, PRESENT); -static SENSOR_DEVICE_ATTR(rxlos, S_IRUGO, get_port_status, NULL, RX_LOS); -static SENSOR_DEVICE_ATTR(rxlos1, S_IRUGO, get_port_status, NULL, RX_LOS1); -static SENSOR_DEVICE_ATTR(rxlos2, S_IRUGO, get_port_status, NULL, RX_LOS2); -static SENSOR_DEVICE_ATTR(rxlos3, S_IRUGO, get_port_status, NULL, RX_LOS3); -static SENSOR_DEVICE_ATTR(rxlos4, S_IRUGO, get_port_status, NULL, RX_LOS4); -static SENSOR_DEVICE_ATTR(tx_disable, S_IWUSR | S_IRUGO, get_port_status, set_port_tx_status, TX_DISABLE); -static SENSOR_DEVICE_ATTR(tx_disable1, S_IWUSR | S_IRUGO, get_port_status, set_port_tx_status, TX_DISABLE1); -static SENSOR_DEVICE_ATTR(tx_disable2, S_IWUSR | S_IRUGO, get_port_status, set_port_tx_status, TX_DISABLE2); -static SENSOR_DEVICE_ATTR(tx_disable3, S_IWUSR | S_IRUGO, get_port_status, set_port_tx_status, TX_DISABLE3); -static SENSOR_DEVICE_ATTR(tx_disable4, S_IWUSR | S_IRUGO, get_port_status, set_port_tx_status, TX_DISABLE4); -static SENSOR_DEVICE_ATTR(tx_fault, S_IRUGO, get_port_status, NULL, TX_FAULT); -static SENSOR_DEVICE_ATTR(tx_fault1, S_IRUGO, get_port_status, NULL, TX_FAULT1); -static SENSOR_DEVICE_ATTR(tx_fault2, S_IRUGO, get_port_status, NULL, TX_FAULT2); -static SENSOR_DEVICE_ATTR(tx_fault3, S_IRUGO, get_port_status, NULL, TX_FAULT3); -static SENSOR_DEVICE_ATTR(tx_fault4, S_IRUGO, get_port_status, NULL, TX_FAULT4); -static SENSOR_DEVICE_ATTR(data_a0, S_IRUGO, get_port_status, NULL, EEPROM_A0_PAGE); -static SENSOR_DEVICE_ATTR(data_a2, S_IRUGO, get_port_status, NULL, EEPROM_A2_PAGE); -static SENSOR_DEVICE_ATTR(sfp_copper, S_IWUSR | S_IRUGO, get_port_status, set_port_sfp_copper, SFP_COPPER); - -static struct attribute *sfp_attributes[] = { - &sensor_dev_attr_abs.dev_attr.attr, - &sensor_dev_attr_rxlos.dev_attr.attr, - &sensor_dev_attr_rxlos1.dev_attr.attr, - &sensor_dev_attr_rxlos2.dev_attr.attr, - &sensor_dev_attr_rxlos3.dev_attr.attr, - &sensor_dev_attr_rxlos4.dev_attr.attr, - &sensor_dev_attr_tx_disable.dev_attr.attr, - &sensor_dev_attr_tx_disable1.dev_attr.attr, - &sensor_dev_attr_tx_disable2.dev_attr.attr, - &sensor_dev_attr_tx_disable3.dev_attr.attr, - &sensor_dev_attr_tx_disable4.dev_attr.attr, - &sensor_dev_attr_tx_fault.dev_attr.attr, - &sensor_dev_attr_tx_fault1.dev_attr.attr, - &sensor_dev_attr_tx_fault2.dev_attr.attr, - &sensor_dev_attr_tx_fault3.dev_attr.attr, - &sensor_dev_attr_tx_fault4.dev_attr.attr, - &sensor_dev_attr_data_a0.dev_attr.attr, - &sensor_dev_attr_data_a2.dev_attr.attr, - &sensor_dev_attr_sfp_copper.dev_attr.attr, - NULL -}; - -static const struct attribute_group sfp_group = { - .attrs = sfp_attributes, -}; - -static struct i2c_client *sfpPortDeviceCreate(struct i2c_adapter *adap, int port, const char *sfpType) -{ - struct i2c_client *client = NULL; - int status; - - client = kzalloc(sizeof(struct i2c_client), GFP_KERNEL); - if (!client) - return NULL; - - client->adapter = adap; - client->addr = (port + 1); - sprintf(client->name, "%s_%03d", sfpType, (port + 1)); - client->dev.parent = &client->adapter->dev; - dev_set_name(&client->dev, "port_%03d", (port + 1)); - status = device_register(&client->dev); - /* Register sysfs hooks */ - status = sysfs_create_group(&client->dev.kobj, &sfp_group); - return client; -} - -static void i2c_bus0_devices_client_address_init(struct i2c_client *client) -{ - int index; - - pca9535pwr_client_bus0 = *client; - pca9535pwr_client_bus0.addr = 0x27; - - cpld_client = *client; - cpld_client.addr = 0x33; - - pca9548_client_bus0 = *client; - pca9548_client_bus0.addr = 0x70; - - for (index=0; index<4; index++) - { - pca9535_client_bus0[index] = *client; - pca9535_client_bus0[index].addr = (0x20+index); - } - - eeprom_client_bus0 = *client; - eeprom_client_bus0.addr = 0x56; - - mp2953agu_client = *client; - mp2953agu_client.addr = 0x21; - - chl8325a_client = *client; - chl8325a_client.addr = 0x32; - - psu_eeprom_client_bus0= *client; - psu_eeprom_client_bus0.addr = 0x51; - - psu_mcu_client_bus0= *client; - psu_mcu_client_bus0.addr = 0x59; -} - -static void i2c_bus0_hardware_monitor_hw_default_config(struct i2c_client *client, - const struct i2c_device_id *id) -{ - struct i2c_bus0_hardware_monitor_data *data = i2c_get_clientdata(client); - unsigned int hiByte, lowByte, configByte; - int i; - - i2c_bus0_devices_client_address_init(client); - - mutex_lock(&data->lock); - - /* Get Board Type and Revision */ - lowByte = i2c_smbus_read_byte_data(&cpld_client, CPLD_REG_GENERAL_0x00); - data->buildRev = (lowByte&0x03); - data->hwRev = ((lowByte>>2)&0x03); - data->modelId = ((lowByte>>4)&0x0f); - - platformBuildRev = data->buildRev; - platformHwRev = data->hwRev; - platformModelId = data->modelId; - - switch(data->modelId) - { - case HURACAN_WITH_BMC: /* 0000: Huracan with BMC */ - case CABRERAIII_WITH_BMC: /* 0010: Cabrera3 with BMC */ - case SESTO_WITH_BMC: /* 0100: Sesto with BMC */ - case NCIIX_WITH_BMC: /* 0110: New Cabrera-II X with BMC */ - case ASTERION_WITH_BMC: /* 1000: Asterion with BMC */ - case HURACAN_A_WITH_BMC: /* 1010: Huracan-A with BMC */ - isBMCSupport = 1; - break; - - default: - isBMCSupport = 0; - break; - } - - if (isBMCSupport == 0) - { - /* Choose W83795ADG bank 0 */ - i2c_smbus_write_byte_data(client, W83795ADG_REG_BANK, 0x00); - /* Disable monitoring operations */ - configByte = i2c_smbus_read_byte_data(client, W83795ADG_REG_CONFIG); - configByte &= 0xfe; - i2c_smbus_write_byte_data(client, W83795ADG_REG_CONFIG, configByte); - - /* Choose W83795ADG bank 2 */ - i2c_smbus_write_byte_data(client, W83795ADG_REG_BANK, 0x02); - lowByte = i2c_smbus_read_byte_data(client, W83795ADG_REG_VENDOR_ID); - i2c_smbus_write_byte_data(client, W83795ADG_REG_BANK, 0x82); - hiByte = i2c_smbus_read_byte_data(client, W83795ADG_REG_VENDOR_ID); - /* Get vender id */ - data->venderId = (hiByte<<8) + lowByte; - /* Get chip id */ - data->chipId= i2c_smbus_read_byte_data(client, W83795ADG_REG_CHIP_ID); - /* Get device id */ - data->dviceId= i2c_smbus_read_byte_data(client, W83795ADG_REG_DEVICE_ID); - - /* set FANCTL8 - FANCTL1 output mode control to PWM output duty cycle mode. */ - i2c_smbus_write_byte_data(client, W83795ADG_REG_FOMC, 0x00); - i2c_smbus_write_byte_data(client, W83795ADG_REG_F1OV, 0xff); - i2c_smbus_write_byte_data(client, W83795ADG_REG_F2OV, 0xff); - - /* Choose W83795ADG bank 0 */ - i2c_smbus_write_byte_data(client, W83795ADG_REG_BANK, 0x00); - /* Enable TR1~TR4 thermistor temperature monitoring */ - i2c_smbus_write_byte_data(client, W83795ADG_REG_TEMP_CTRL2, 0xff); - - /* set FANCTL2 to enable FANIN9 and FANIN10 monitoring */ - i2c_smbus_write_byte_data(client, W83795ADG_REG_FANIN_CTRL2, 0x03); - - /* Enable monitoring operations */ - configByte |= 0x01; - i2c_smbus_write_byte_data(client, W83795ADG_REG_CONFIG, configByte); - } - - /* CPLD Revision */ - lowByte = i2c_smbus_read_byte_data(&cpld_client, CPLD_REG_GENERAL_0x01); - data->cpldRev = (lowByte&0x3f); - data->cpldRel = ((lowByte>>6)&0x01); - - /* turn on all LEDs of front port */ - i2c_smbus_write_byte_data(&cpld_client, CPLD_REG_RESET_0x34, 0x10); - - switch(data->modelId) - { - case NCIIX_WITH_BMC: - case NCIIX_WITHOUT_BMC: - /* Turn on PCA9548#0 channel 3 on I2C-bus0 */ - i2c_smbus_write_byte(&pca9548_client_bus0, (1<lock); -} - -static void i2c_bus1_devices_client_address_init(struct i2c_client *client) -{ - int index; - - for (index=0; index<4; index++) - { - pca9548_client[index] = *client; - pca9548_client[index].addr = (0x71+index); - } - - for (index=0; index<6; index++) - { - pca9535pwr_client[index] = *client; - pca9535pwr_client[index].addr = (0x20+index); - } - - cpld_client_bus1 = *client; - cpld_client_bus1.addr = 0x33; - - qsfpDataA0_client = *client; - qsfpDataA0_client.addr = 0x50; - - qsfpDataA2_client = *client; - qsfpDataA2_client.addr = 0x51; - - SfpCopperData_client = *client; - SfpCopperData_client.addr = 0x56; - - switch(platformModelId) - { - case NCIIX_WITH_BMC: - case NCIIX_WITHOUT_BMC: - eeprom_client = *client; - eeprom_client.addr = 0x56; - - psu_eeprom_client = *client; - psu_eeprom_client.addr = 0x51; - - psu_mcu_client = *client; - psu_mcu_client.addr = 0x59; - break; - - default: - eeprom_client = *client; - eeprom_client.addr = 0x54; - - psu_eeprom_client = *client; - psu_eeprom_client.addr = 0x50; - - psu_mcu_client = *client; - psu_mcu_client.addr = 0x58; - break; - } - } - -static void i2c_bus1_io_expander_default_set(struct i2c_client *client) -{ - struct i2c_bus1_hardware_monitor_data *data = i2c_get_clientdata(client); - int i; - - switch (platformModelId) - { - case HURACAN_WITH_BMC: - case HURACAN_WITHOUT_BMC: - case HURACAN_A_WITH_BMC: - case HURACAN_A_WITHOUT_BMC: - /* Turn on PCA9548 channel 4 on I2C-bus1 */ - i2c_smbus_write_byte(client, (1<frontLedStatus); - i2c_device_word_write(&(pca9535pwr_client[2]), PCA9553_COMMAND_BYTE_REG_POLARITY_INVERSION_0, 0x0000); - i2c_device_word_write(&(pca9535pwr_client[2]), PCA9553_COMMAND_BYTE_REG_CONFIGURATION_0, 0x0000); - } - } - - /* Turn off PCA9548 all channels on I2C-bus1 */ - i2c_smbus_write_byte(client, 0x00); - break; - - case CABRERAIII_WITH_BMC: - case CABRERAIII_WITHOUT_BMC: - break; - - case SESTO_WITH_BMC: - case SESTO_WITHOUT_BMC: - /* Turn on PCA9548#1 channel 0 on I2C-bus1 - ABS# */ - i2c_smbus_write_byte(&(pca9548_client[1]), (1<frontLedStatus); - i2c_device_word_write(&(pca9535pwr_client[2]), PCA9553_COMMAND_BYTE_REG_POLARITY_INVERSION_0, 0x0000); - i2c_device_word_write(&(pca9535pwr_client[2]), PCA9553_COMMAND_BYTE_REG_CONFIGURATION_0, 0x0000); - /* Turn off PCA9548#0 all channels on I2C-bus1 */ - i2c_smbus_write_byte(client, 0x00); - } - - /* Turn off PCA9548#1 all channels on I2C-bus1 */ - i2c_smbus_write_byte(&(pca9548_client[1]), 0x00); - break; - - case NCIIX_WITH_BMC: - case NCIIX_WITHOUT_BMC: - /* Turn on PCA9548#1 channel 0 on I2C-bus1 */ - i2c_smbus_write_byte(client, (1<frontLedStatus); - i2c_device_word_write(&(pca9535pwr_client[2]), PCA9553_COMMAND_BYTE_REG_POLARITY_INVERSION_0, 0x0000); - i2c_device_word_write(&(pca9535pwr_client[2]), PCA9553_COMMAND_BYTE_REG_CONFIGURATION_0, 0x0000); - - /* Turn on PCA9548#0 channel 5 on I2C-bus1 */ - i2c_smbus_write_byte(client, (1 << PCA9548_CH05)); - /* PSU Status */ - /* set input-1/output-0 mode for IO expander #1 on channel 5 */ - i2c_device_word_write(&(pca9535pwr_client[0]), PCA9553_COMMAND_BYTE_REG_OUTPUT_PORT_0, 0x0000); - i2c_device_word_write(&(pca9535pwr_client[0]), PCA9553_COMMAND_BYTE_REG_POLARITY_INVERSION_0, 0x0000); -/* If the PSU_PWROFF pin of IO expander is output mode, the power cycling of CPLD cannot work.*/ -#if 0 - i2c_device_word_write(&(pca9535pwr_client[0]), PCA9553_COMMAND_BYTE_REG_CONFIGURATION_0, 0xffbb); -#else - i2c_device_word_write(&(pca9535pwr_client[0]), PCA9553_COMMAND_BYTE_REG_CONFIGURATION_0, 0xffff); -#endif - - /* Turn off PCA9548#0 all channels on I2C-bus1 */ - i2c_smbus_write_byte(client, 0x00); - break; - - default: - break; - } - } - -static void i2c_bus1_hardware_monitor_hw_default_config(struct i2c_client *client, - const struct i2c_device_id *id) -{ - struct i2c_bus1_hardware_monitor_data *data = i2c_get_clientdata(client); - int i; - - i2c_bus1_devices_client_address_init(client); - - mutex_lock(&data->lock); - /* Turn off PCA9548 all channels on I2C-bus1 */ - i2c_smbus_write_byte(client, 0x00); - - data->frontLedStatus = 0x00aa; - for (i=0; i<3; i++) - data->sfpPortRateSelect[i] = 0xffff; - i2c_bus1_io_expander_default_set(client); - - mutex_unlock(&data->lock); -} - -/* Return 0 if detection is successful, -ENODEV otherwise */ -static int w83795adg_hardware_monitor_detect(struct i2c_client *client, - struct i2c_board_info *info) -{ - struct i2c_adapter *adapter = client->adapter; - - if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) - { - printk(KERN_ERR "i2c_check_functionality fail.\n"); - return -ENODEV; - } - - if(adapter->nr == 0x0) - { - unsigned int hiByte, lowByte, value; - - if (client->addr != 0x2F) - return -ENODEV; - - /* Choose W83795ADG bank 2 */ - i2c_smbus_write_byte_data(client, W83795ADG_REG_BANK, 0x02); - lowByte = i2c_smbus_read_byte_data(client, W83795ADG_REG_VENDOR_ID); - i2c_smbus_write_byte_data(client, W83795ADG_REG_BANK, 0x82); - hiByte = i2c_smbus_read_byte_data(client, W83795ADG_REG_VENDOR_ID); - /* Get vender id */ - value= (hiByte<<8) + lowByte; - if (value != W83795ADG_VENDOR_ID) - { - printk(KERN_ERR "%s(%d): W83795ADG_REG_VENDOR_ID fail.\n", __func__, __LINE__); - return -ENODEV; - } - - value = i2c_smbus_read_byte_data(client, W83795ADG_REG_CHIP_ID); - if (value != W83795ADG_CHIP_ID) - { - printk(KERN_ERR "%s(%d): W83795ADG_REG_CHIP_ID fail.\n", __func__, __LINE__); - return -ENODEV; - } - } - - strlcpy(info->type, "HURACAN", I2C_NAME_SIZE); - return 0; -} - -static int w83795adg_hardware_monitor_probe(struct i2c_client *client, - const struct i2c_device_id *id) -{ - int err = 0; - - if(client->adapter->nr == 0x0) - { - struct i2c_bus0_hardware_monitor_data *data = NULL; - - if (client->addr != 0x2F) - return -ENODEV; - - data = devm_kzalloc(&client->dev, sizeof(struct i2c_bus0_hardware_monitor_data), GFP_KERNEL); - if (!data) - return -ENOMEM; - - memset(data, 0, sizeof(struct i2c_bus0_hardware_monitor_data)); - mutex_init(&data->lock); - i2c_set_clientdata(client, data); - - dev_info(&client->dev, "%s device found on bus %d\n", client->name, client->adapter->nr); - - /* Set Pre-defined HW config */ - i2c_bus0_hardware_monitor_hw_default_config(client, id); - /* Register sysfs hooks */ - switch (platformModelId) - { - case NCIIX_WITH_BMC: - case NCIIX_WITHOUT_BMC: - data->hwmon_group.attrs = i2c_bus0_hardware_monitor_attr_nc2x; - break; - - case ASTERION_WITH_BMC: - case ASTERION_WITHOUT_BMC: - data->hwmon_group.attrs = i2c_bus0_hardware_monitor_attr_asterion; - w83795adg_normal_i2c[1] = 0x72; - break; - - default: - data->hwmon_group.attrs = i2c_bus0_hardware_monitor_attr; - break; - } - err = sysfs_create_group(&client->dev.kobj, &data->hwmon_group); - if (err) - { - printk(KERN_ERR "hwmon_group sysfs_create_group fail.\n"); - } - else - { - data->hwmon_dev = hwmon_device_register(&client->dev); - if (IS_ERR(data->hwmon_dev)) { - printk(KERN_ERR "hwmon_device_register fail.\n"); - err = PTR_ERR(data->hwmon_dev); - sysfs_remove_group(&client->dev.kobj, &data->hwmon_group); - } - - init_completion(&data->auto_update_stop); - data->auto_update = kthread_run(i2c_bus0_hardware_monitor_update_thread, client, dev_name(data->hwmon_dev)); - if (IS_ERR(data->auto_update)) { - err = PTR_ERR(data->auto_update); - hwmon_device_unregister(data->hwmon_dev); - sysfs_remove_group(&client->dev.kobj, &data->hwmon_group); - } - } - } - else if(client->adapter->nr == 0x1) - { - struct i2c_bus1_hardware_monitor_data *data = NULL; - - data = devm_kzalloc(&client->dev, sizeof(struct i2c_bus1_hardware_monitor_data), GFP_KERNEL); - if (!data) - return -ENOMEM; - - memset(data, 0, sizeof(struct i2c_bus1_hardware_monitor_data)); - mutex_init(&data->lock); - i2c_set_clientdata(client, data); - - dev_info(&client->dev, "%s device found on bus %d\n", client->name, client->adapter->nr); - - /* Set Pre-defined HW config */ - i2c_bus1_hardware_monitor_hw_default_config(client, id); - /* Register sysfs hooks */ - - switch (platformModelId) - { - default: - case HURACAN_WITH_BMC: - case HURACAN_WITHOUT_BMC: - case HURACAN_A_WITH_BMC: - case HURACAN_A_WITHOUT_BMC: - data->hwmon_group.attrs = i2c_bus1_hardware_monitor_attr_huracan; - break; - - case CABRERAIII_WITH_BMC: - case CABRERAIII_WITHOUT_BMC: - break; - - case SESTO_WITH_BMC: - case SESTO_WITHOUT_BMC: - data->hwmon_group.attrs = i2c_bus1_hardware_monitor_attr_sesto; - break; - - case NCIIX_WITH_BMC: - case NCIIX_WITHOUT_BMC: - data->hwmon_group.attrs = i2c_bus1_hardware_monitor_attr_nc2x; - break; - - case ASTERION_WITH_BMC: - case ASTERION_WITHOUT_BMC: - data->hwmon_group.attrs = i2c_bus1_hardware_monitor_attr_asterion; - break; - } - err = sysfs_create_group(&client->dev.kobj, &data->hwmon_group); - if (err) - { - printk(KERN_INFO "hwmon_group1 sysfs_create_group fail.\n"); - } - else - { - data->hwmon_dev = hwmon_device_register(&client->dev); - if (IS_ERR(data->hwmon_dev)) { - printk(KERN_INFO "hwmon_device_register1 fail.\n"); - err = PTR_ERR(data->hwmon_dev); - sysfs_remove_group(&client->dev.kobj, &data->hwmon_group); - } - else - { - struct i2c_adapter *adap = to_i2c_adapter(&client->dev); - int port; - - for (port = 0; port < QSFP_COUNT; port++) - data->qsfpPortTxDisableDataUpdate[port] = 1; - mutex_init(&portStatusLock); - switch (platformModelId) - { - case HURACAN_WITH_BMC: - case HURACAN_WITHOUT_BMC: - case HURACAN_A_WITH_BMC: - case HURACAN_A_WITHOUT_BMC: - /* QSFP ports */ - for (port = 0; port < 32; port++) - { - data->sfpPortClient[port] = sfpPortDeviceCreate(adap, port, "qsfp"); - if (!data->sfpPortClient[port]) - return -ENOMEM; - } - break; - - case SESTO_WITH_BMC: - case SESTO_WITHOUT_BMC: - case NCIIX_WITH_BMC: - case NCIIX_WITHOUT_BMC: - /* SFP+ ports */ - for (port = 0; port < 48; port++) - { - data->sfpPortClient[port] = sfpPortDeviceCreate(adap, port, "sfp"); - if (!data->sfpPortClient[port]) - return -ENOMEM; - } - /* QSFP ports */ - for (port = 48; port < 54; port++) - { - data->sfpPortClient[port] = sfpPortDeviceCreate(adap, port, "qsfp"); - if (!data->sfpPortClient[port]) - return -ENOMEM; - } - break; - - case ASTERION_WITH_BMC: - case ASTERION_WITHOUT_BMC: - /* SFP+ ports */ - for (port = 0; port < 48; port++) - { - data->sfpPortClient[port] = sfpPortDeviceCreate(adap, port, "sfp"); - if (!data->sfpPortClient[port]) - return -ENOMEM; - } - /* QSFP ports */ - for (port = 48; port < 64; port++) - { - data->sfpPortClient[port] = sfpPortDeviceCreate(adap, port, "qsfp"); - if (!data->sfpPortClient[port]) - return -ENOMEM; - } - break; - - default: - break; - } - - init_completion(&data->auto_update_stop); - data->auto_update = kthread_run(i2c_bus1_hardware_monitor_update_thread, client, dev_name(data->hwmon_dev)); - if (IS_ERR(data->auto_update)) { - err = PTR_ERR(data->auto_update); - - hwmon_device_unregister(data->hwmon_dev); - sysfs_remove_group(&client->dev.kobj, &data->hwmon_group); - } - } - } - } - - return err; -} - -static int w83795adg_hardware_monitor_remove(struct i2c_client *client) -{ - if(client->adapter->nr == 0x0) - { - struct i2c_bus0_hardware_monitor_data *data = i2c_get_clientdata(client); - kthread_stop(data->auto_update); - wait_for_completion(&data->auto_update_stop); - /* Watchdog Control Register Support */ - if (data->cpldRev != 0) - { - /* Disable WD function */ - i2c_smbus_write_byte_data(&cpld_client, CPLD_REG_GENERAL_0x06, 0x00); - } - - /* turn off all LEDs of front port */ - i2c_smbus_write_byte_data(&cpld_client, CPLD_REG_RESET_0x34, 0x00); -#if 0 /* It's for Huracan Beta only, remove it. */ - i2c_smbus_write_byte_data(&cpld_client, CPLD_REG_LED_0x40, 0x00); - i2c_smbus_write_byte_data(&cpld_client, CPLD_REG_LED_0x44, 0x00); -#endif - - mutex_destroy(&client->dev.mutex); - hwmon_device_unregister(data->hwmon_dev); - sysfs_remove_group(&client->dev.kobj, &data->hwmon_group); - mutex_destroy(&data->lock); - } - else if(client->adapter->nr == 0x1) - { - int port; - struct i2c_client *c; - struct i2c_bus1_hardware_monitor_data *data = i2c_get_clientdata(client); - kthread_stop(data->auto_update); - wait_for_completion(&data->auto_update_stop); - for (port = 0; port < QSFP_COUNT; port ++) - { - c = data->sfpPortClient[port]; - if (c) - { - sysfs_remove_group(&c->dev.kobj, &sfp_group); - mutex_destroy(&c->dev.mutex); - device_del(&c->dev); - kfree(c); - } - } - mutex_destroy(&portStatusLock); - - mutex_destroy(&client->dev.mutex); - hwmon_device_unregister(data->hwmon_dev); - sysfs_remove_group(&client->dev.kobj, &data->hwmon_group); - mutex_destroy(&data->lock); - } - return 0; -} - -static void w83795adg_hardware_monitor_shutdown(struct i2c_client *client) -{ - if(client->adapter->nr == 0x0) - { - struct i2c_bus0_hardware_monitor_data *data = i2c_get_clientdata(client); - kthread_stop(data->auto_update); - wait_for_completion(&data->auto_update_stop); - /* Watchdog Control Register Support */ - if (data->cpldRev != 0) - { - /* Disable WD function */ - i2c_smbus_write_byte_data(&cpld_client, CPLD_REG_GENERAL_0x06, 0x00); - } - - /* turn off all LEDs of front port */ - i2c_smbus_write_byte_data(&cpld_client, CPLD_REG_RESET_0x34, 0x00); -#if 0 /* It's for Huracan Beta only, remove it. */ - i2c_smbus_write_byte_data(&cpld_client, CPLD_REG_LED_0x40, 0x00); - i2c_smbus_write_byte_data(&cpld_client, CPLD_REG_LED_0x44, 0x00); -#endif - /* reset MAC */ - switch(platformModelId) - { - case ASTERION_WITH_BMC: - case ASTERION_WITHOUT_BMC: - i2c_smbus_write_byte_data(&cpld_client, CPLD_REG_RESET_0x30, 0x3e); - i2c_smbus_write_byte_data(&cpld_client, CPLD_REG_RESET_0x30, 0x3f); - /* reset CPLD 2, 3 and 4 */ - i2c_smbus_write_byte_data(&cpld_client, CPLD_REG_RESET_0x35, 0xfd); /* assert RST_CPLD2_3_4 */ - i2c_smbus_write_byte_data(&cpld_client, CPLD_REG_RESET_0x35, 0xff); - break; - - default: - i2c_smbus_write_byte_data(&cpld_client, CPLD_REG_RESET_0x30, 0x6e); - i2c_smbus_write_byte_data(&cpld_client, CPLD_REG_RESET_0x30, 0x6f); - break; - } - - hwmon_device_unregister(data->hwmon_dev); - sysfs_remove_group(&client->dev.kobj, &data->hwmon_group); - } - else if(client->adapter->nr == 0x1) - { - struct i2c_bus1_hardware_monitor_data *data = i2c_get_clientdata(client); - kthread_stop(data->auto_update); - wait_for_completion(&data->auto_update_stop); - hwmon_device_unregister(data->hwmon_dev); - sysfs_remove_group(&client->dev.kobj, &data->hwmon_group); - } -} - -module_i2c_driver(w83795adg_hardware_monitor_driver); - -MODULE_AUTHOR("Raymond Huey "); -MODULE_DESCRIPTION("W83795ADG Hardware Monitor driver"); -MODULE_LICENSE("GPL"); diff --git a/packages/platforms/quanta/Makefile b/packages/platforms/quanta/Makefile deleted file mode 100644 index 003238cf6..000000000 --- a/packages/platforms/quanta/Makefile +++ /dev/null @@ -1 +0,0 @@ -include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/quanta/any/src/quanta_sys_eeprom/.gitignore b/packages/platforms/quanta/any/src/quanta_sys_eeprom/.gitignore deleted file mode 100644 index c81d16be3..000000000 --- a/packages/platforms/quanta/any/src/quanta_sys_eeprom/.gitignore +++ /dev/null @@ -1 +0,0 @@ -*.mk diff --git a/packages/platforms/quanta/any/src/quanta_sys_eeprom/.module b/packages/platforms/quanta/any/src/quanta_sys_eeprom/.module deleted file mode 100644 index 84e84b531..000000000 --- a/packages/platforms/quanta/any/src/quanta_sys_eeprom/.module +++ /dev/null @@ -1 +0,0 @@ -name: quanta_sys_eeprom diff --git a/packages/platforms/quanta/any/src/quanta_sys_eeprom/Makefile b/packages/platforms/quanta/any/src/quanta_sys_eeprom/Makefile deleted file mode 100644 index cfdd1130e..000000000 --- a/packages/platforms/quanta/any/src/quanta_sys_eeprom/Makefile +++ /dev/null @@ -1,9 +0,0 @@ -############################################################################### -# -# -# -############################################################################### -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/README b/packages/platforms/quanta/any/src/quanta_sys_eeprom/README deleted file mode 100644 index 5f3a831bd..000000000 --- a/packages/platforms/quanta/any/src/quanta_sys_eeprom/README +++ /dev/null @@ -1,6 +0,0 @@ -############################################################################### -# -# quanta_sys_eeprom README -# -############################################################################### - diff --git a/packages/platforms/quanta/any/src/quanta_sys_eeprom/module/auto/make.mk b/packages/platforms/quanta/any/src/quanta_sys_eeprom/module/auto/make.mk deleted file mode 100644 index 14fa6e024..000000000 --- a/packages/platforms/quanta/any/src/quanta_sys_eeprom/module/auto/make.mk +++ /dev/null @@ -1,9 +0,0 @@ -############################################################################### -# -# quanta_sys_eeprom Autogeneration -# -############################################################################### -quanta_sys_eeprom_AUTO_DEFS := module/auto/quanta_sys_eeprom.yml -quanta_sys_eeprom_AUTO_DIRS := module/inc/quanta_sys_eeprom module/src -include $(BUILDER)/auto.mk - diff --git a/packages/platforms/quanta/any/src/quanta_sys_eeprom/module/auto/quanta_sys_eeprom.yml b/packages/platforms/quanta/any/src/quanta_sys_eeprom/module/auto/quanta_sys_eeprom.yml deleted file mode 100644 index 1f242450d..000000000 --- a/packages/platforms/quanta/any/src/quanta_sys_eeprom/module/auto/quanta_sys_eeprom.yml +++ /dev/null @@ -1,47 +0,0 @@ -############################################################################### -# -# quanta_sys_eeprom Autogeneration Definitions. -# -############################################################################### - -cdefs: &cdefs -- QUANTA_SYS_EEPROM_CONFIG_INCLUDE_LOGGING: - doc: "Include or exclude logging." - default: 1 -- QUANTA_SYS_EEPROM_CONFIG_LOG_OPTIONS_DEFAULT: - doc: "Default enabled log options." - default: AIM_LOG_OPTIONS_DEFAULT -- QUANTA_SYS_EEPROM_CONFIG_LOG_BITS_DEFAULT: - doc: "Default enabled log bits." - default: AIM_LOG_BITS_DEFAULT -- QUANTA_SYS_EEPROM_CONFIG_LOG_CUSTOM_BITS_DEFAULT: - doc: "Default enabled custom log bits." - default: 0 -- QUANTA_SYS_EEPROM_CONFIG_PORTING_STDLIB: - doc: "Default all porting macros to use the C standard libraries." - default: 1 -- QUANTA_SYS_EEPROM_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS: - doc: "Include standard library headers for stdlib porting macros." - default: QUANTA_SYS_EEPROM_CONFIG_PORTING_STDLIB -- QUANTA_SYS_EEPROM_CONFIG_INCLUDE_UCLI: - doc: "Include generic uCli support." - default: 0 - - -definitions: - cdefs: - QUANTA_SYS_EEPROM_CONFIG_HEADER: - defs: *cdefs - basename: quanta_sys_eeprom_config - - portingmacro: - QUANTA_SYS_EEPROM: - macros: - - malloc - - free - - memset - - memcpy - - - vsnprintf - - snprintf - - strlen diff --git a/packages/platforms/quanta/any/src/quanta_sys_eeprom/module/inc/quanta_sys_eeprom/eeprom.h b/packages/platforms/quanta/any/src/quanta_sys_eeprom/module/inc/quanta_sys_eeprom/eeprom.h deleted file mode 100644 index 1ced2deaa..000000000 --- a/packages/platforms/quanta/any/src/quanta_sys_eeprom/module/inc/quanta_sys_eeprom/eeprom.h +++ /dev/null @@ -1,74 +0,0 @@ -/************************************************************ - * - * - ************************************************************ - * - * - * - ***********************************************************/ -#ifndef __QUANTA_SYS_EEPROM_EEPROM_H__ -#define __QUANTA_SYS_EEPROM_EEPROM_H__ - -#include -#include -#include - -typedef struct quanta_sys_eeprom_data_s { - -#define EEPROM_STR_MAX 32 - - char product_name[EEPROM_STR_MAX]; - char model_name[EEPROM_STR_MAX]; - char part_number[EEPROM_STR_MAX]; - char serial_number[EEPROM_STR_MAX]; - char manufacture_date[EEPROM_STR_MAX]; - char label_version[EEPROM_STR_MAX]; - uint8_t mac_address[6]; - uint32_t hardware_version; - uint32_t software_version; - uint32_t card_type; - uint32_t crc; - -} quanta_sys_eeprom_t; - -/** - * @brief Parse the given data in EEPROM format. - * @param data The eeprom data. - * @param size The length of the data. - * @param rv Receives the eeprom information. - */ -int quanta_sys_eeprom_parse_data(const uint8_t* data, int size, - quanta_sys_eeprom_t* rv); - -/** - * @brief Parse the given file in EEPROM format. - * @param file The eeprom file. - * @param rv Receives the eeprom information. - */ -int quanta_sys_eeprom_parse_file(const char* file, quanta_sys_eeprom_t* rv); - - -/** - * @brief Convert The sys-eeprom to the onie-eeprom format. - * @param src Source structure. - * @param dst Destination structure. - */ -int quanta_sys_eeprom_to_onie(const quanta_sys_eeprom_t* src, - onlp_onie_info_t* dst); - -/** - * @brief Show the contents of the given eeprom data; - * @param pvs The output pvs. - * @param e The eeprom structure. - */ - -int quanta_sys_eeprom_show(aim_pvs_t* pvs, quanta_sys_eeprom_t* e); - -/** - * @brief Convert Quanta ONIE sys-eeprom with specified format - * @param onie The onie eeprom structure. - */ - -int quanta_onie_sys_eeprom_custom_format(onlp_onie_info_t* onie); - -#endif /* __QUANTA_SYS_EEPROM_EEPROM_H__ */ diff --git a/packages/platforms/quanta/any/src/quanta_sys_eeprom/module/inc/quanta_sys_eeprom/quanta_sys_eeprom.x b/packages/platforms/quanta/any/src/quanta_sys_eeprom/module/inc/quanta_sys_eeprom/quanta_sys_eeprom.x deleted file mode 100644 index 119e0e61d..000000000 --- a/packages/platforms/quanta/any/src/quanta_sys_eeprom/module/inc/quanta_sys_eeprom/quanta_sys_eeprom.x +++ /dev/null @@ -1,14 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#include - -/* <--auto.start.xmacro(ALL).define> */ -/* */ - -/* <--auto.start.xenum(ALL).define> */ -/* */ - - diff --git a/packages/platforms/quanta/any/src/quanta_sys_eeprom/module/inc/quanta_sys_eeprom/quanta_sys_eeprom_config.h b/packages/platforms/quanta/any/src/quanta_sys_eeprom/module/inc/quanta_sys_eeprom/quanta_sys_eeprom_config.h deleted file mode 100644 index fa49f275c..000000000 --- a/packages/platforms/quanta/any/src/quanta_sys_eeprom/module/inc/quanta_sys_eeprom/quanta_sys_eeprom_config.h +++ /dev/null @@ -1,127 +0,0 @@ -/**************************************************************************//** - * - * @file - * @brief quanta_sys_eeprom Configuration Header - * - * @addtogroup quanta_sys_eeprom-config - * @{ - * - *****************************************************************************/ -#ifndef __QUANTA_SYS_EEPROM_CONFIG_H__ -#define __QUANTA_SYS_EEPROM_CONFIG_H__ - -#ifdef GLOBAL_INCLUDE_CUSTOM_CONFIG -#include -#endif -#ifdef QUANTA_SYS_EEPROM_INCLUDE_CUSTOM_CONFIG -#include -#endif - -/* */ -#include -/** - * QUANTA_SYS_EEPROM_CONFIG_INCLUDE_LOGGING - * - * Include or exclude logging. */ - - -#ifndef QUANTA_SYS_EEPROM_CONFIG_INCLUDE_LOGGING -#define QUANTA_SYS_EEPROM_CONFIG_INCLUDE_LOGGING 1 -#endif - -/** - * QUANTA_SYS_EEPROM_CONFIG_LOG_OPTIONS_DEFAULT - * - * Default enabled log options. */ - - -#ifndef QUANTA_SYS_EEPROM_CONFIG_LOG_OPTIONS_DEFAULT -#define QUANTA_SYS_EEPROM_CONFIG_LOG_OPTIONS_DEFAULT AIM_LOG_OPTIONS_DEFAULT -#endif - -/** - * QUANTA_SYS_EEPROM_CONFIG_LOG_BITS_DEFAULT - * - * Default enabled log bits. */ - - -#ifndef QUANTA_SYS_EEPROM_CONFIG_LOG_BITS_DEFAULT -#define QUANTA_SYS_EEPROM_CONFIG_LOG_BITS_DEFAULT AIM_LOG_BITS_DEFAULT -#endif - -/** - * QUANTA_SYS_EEPROM_CONFIG_LOG_CUSTOM_BITS_DEFAULT - * - * Default enabled custom log bits. */ - - -#ifndef QUANTA_SYS_EEPROM_CONFIG_LOG_CUSTOM_BITS_DEFAULT -#define QUANTA_SYS_EEPROM_CONFIG_LOG_CUSTOM_BITS_DEFAULT 0 -#endif - -/** - * QUANTA_SYS_EEPROM_CONFIG_PORTING_STDLIB - * - * Default all porting macros to use the C standard libraries. */ - - -#ifndef QUANTA_SYS_EEPROM_CONFIG_PORTING_STDLIB -#define QUANTA_SYS_EEPROM_CONFIG_PORTING_STDLIB 1 -#endif - -/** - * QUANTA_SYS_EEPROM_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS - * - * Include standard library headers for stdlib porting macros. */ - - -#ifndef QUANTA_SYS_EEPROM_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS -#define QUANTA_SYS_EEPROM_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS QUANTA_SYS_EEPROM_CONFIG_PORTING_STDLIB -#endif - -/** - * QUANTA_SYS_EEPROM_CONFIG_INCLUDE_UCLI - * - * Include generic uCli support. */ - - -#ifndef QUANTA_SYS_EEPROM_CONFIG_INCLUDE_UCLI -#define QUANTA_SYS_EEPROM_CONFIG_INCLUDE_UCLI 0 -#endif - - - -/** - * All compile time options can be queried or displayed - */ - -/** Configuration settings structure. */ -typedef struct quanta_sys_eeprom_config_settings_s { - /** name */ - const char* name; - /** value */ - const char* value; -} quanta_sys_eeprom_config_settings_t; - -/** Configuration settings table. */ -/** quanta_sys_eeprom_config_settings table. */ -extern quanta_sys_eeprom_config_settings_t quanta_sys_eeprom_config_settings[]; - -/** - * @brief Lookup a configuration setting. - * @param setting The name of the configuration option to lookup. - */ -const char* quanta_sys_eeprom_config_lookup(const char* setting); - -/** - * @brief Show the compile-time configuration. - * @param pvs The output stream. - */ -int quanta_sys_eeprom_config_show(struct aim_pvs_s* pvs); - -/* */ - -#include "quanta_sys_eeprom_porting.h" - -#endif /* __QUANTA_SYS_EEPROM_CONFIG_H__ */ -/* @} */ diff --git a/packages/platforms/quanta/any/src/quanta_sys_eeprom/module/inc/quanta_sys_eeprom/quanta_sys_eeprom_dox.h b/packages/platforms/quanta/any/src/quanta_sys_eeprom/module/inc/quanta_sys_eeprom/quanta_sys_eeprom_dox.h deleted file mode 100644 index 4b4a79e99..000000000 --- a/packages/platforms/quanta/any/src/quanta_sys_eeprom/module/inc/quanta_sys_eeprom/quanta_sys_eeprom_dox.h +++ /dev/null @@ -1,26 +0,0 @@ -/**************************************************************************//** - * - * quanta_sys_eeprom Doxygen Header - * - *****************************************************************************/ -#ifndef __QUANTA_SYS_EEPROM_DOX_H__ -#define __QUANTA_SYS_EEPROM_DOX_H__ - -/** - * @defgroup quanta_sys_eeprom quanta_sys_eeprom - quanta_sys_eeprom Description - * - -The documentation overview for this module should go here. - - * - * @{ - * - * @defgroup quanta_sys_eeprom-quanta_sys_eeprom Public Interface - * @defgroup quanta_sys_eeprom-config Compile Time Configuration - * @defgroup quanta_sys_eeprom-porting Porting Macros - * - * @} - * - */ - -#endif /* __QUANTA_SYS_EEPROM_DOX_H__ */ diff --git a/packages/platforms/quanta/any/src/quanta_sys_eeprom/module/inc/quanta_sys_eeprom/quanta_sys_eeprom_porting.h b/packages/platforms/quanta/any/src/quanta_sys_eeprom/module/inc/quanta_sys_eeprom/quanta_sys_eeprom_porting.h deleted file mode 100644 index d9492837f..000000000 --- a/packages/platforms/quanta/any/src/quanta_sys_eeprom/module/inc/quanta_sys_eeprom/quanta_sys_eeprom_porting.h +++ /dev/null @@ -1,97 +0,0 @@ -/**************************************************************************//** - * - * @file - * @brief quanta_sys_eeprom Porting Macros. - * - * @addtogroup quanta_sys_eeprom-porting - * @{ - * - *****************************************************************************/ -#ifndef __QUANTA_SYS_EEPROM_PORTING_H__ -#define __QUANTA_SYS_EEPROM_PORTING_H__ - - -/* */ -#if QUANTA_SYS_EEPROM_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS == 1 -#include -#include -#include -#include -#include -#endif - -#ifndef QUANTA_SYS_EEPROM_MALLOC - #if defined(GLOBAL_MALLOC) - #define QUANTA_SYS_EEPROM_MALLOC GLOBAL_MALLOC - #elif QUANTA_SYS_EEPROM_CONFIG_PORTING_STDLIB == 1 - #define QUANTA_SYS_EEPROM_MALLOC malloc - #else - #error The macro QUANTA_SYS_EEPROM_MALLOC is required but cannot be defined. - #endif -#endif - -#ifndef QUANTA_SYS_EEPROM_FREE - #if defined(GLOBAL_FREE) - #define QUANTA_SYS_EEPROM_FREE GLOBAL_FREE - #elif QUANTA_SYS_EEPROM_CONFIG_PORTING_STDLIB == 1 - #define QUANTA_SYS_EEPROM_FREE free - #else - #error The macro QUANTA_SYS_EEPROM_FREE is required but cannot be defined. - #endif -#endif - -#ifndef QUANTA_SYS_EEPROM_MEMSET - #if defined(GLOBAL_MEMSET) - #define QUANTA_SYS_EEPROM_MEMSET GLOBAL_MEMSET - #elif QUANTA_SYS_EEPROM_CONFIG_PORTING_STDLIB == 1 - #define QUANTA_SYS_EEPROM_MEMSET memset - #else - #error The macro QUANTA_SYS_EEPROM_MEMSET is required but cannot be defined. - #endif -#endif - -#ifndef QUANTA_SYS_EEPROM_MEMCPY - #if defined(GLOBAL_MEMCPY) - #define QUANTA_SYS_EEPROM_MEMCPY GLOBAL_MEMCPY - #elif QUANTA_SYS_EEPROM_CONFIG_PORTING_STDLIB == 1 - #define QUANTA_SYS_EEPROM_MEMCPY memcpy - #else - #error The macro QUANTA_SYS_EEPROM_MEMCPY is required but cannot be defined. - #endif -#endif - -#ifndef QUANTA_SYS_EEPROM_VSNPRINTF - #if defined(GLOBAL_VSNPRINTF) - #define QUANTA_SYS_EEPROM_VSNPRINTF GLOBAL_VSNPRINTF - #elif QUANTA_SYS_EEPROM_CONFIG_PORTING_STDLIB == 1 - #define QUANTA_SYS_EEPROM_VSNPRINTF vsnprintf - #else - #error The macro QUANTA_SYS_EEPROM_VSNPRINTF is required but cannot be defined. - #endif -#endif - -#ifndef QUANTA_SYS_EEPROM_SNPRINTF - #if defined(GLOBAL_SNPRINTF) - #define QUANTA_SYS_EEPROM_SNPRINTF GLOBAL_SNPRINTF - #elif QUANTA_SYS_EEPROM_CONFIG_PORTING_STDLIB == 1 - #define QUANTA_SYS_EEPROM_SNPRINTF snprintf - #else - #error The macro QUANTA_SYS_EEPROM_SNPRINTF is required but cannot be defined. - #endif -#endif - -#ifndef QUANTA_SYS_EEPROM_STRLEN - #if defined(GLOBAL_STRLEN) - #define QUANTA_SYS_EEPROM_STRLEN GLOBAL_STRLEN - #elif QUANTA_SYS_EEPROM_CONFIG_PORTING_STDLIB == 1 - #define QUANTA_SYS_EEPROM_STRLEN strlen - #else - #error The macro QUANTA_SYS_EEPROM_STRLEN is required but cannot be defined. - #endif -#endif - -/* */ - - -#endif /* __QUANTA_SYS_EEPROM_PORTING_H__ */ -/* @} */ diff --git a/packages/platforms/quanta/any/src/quanta_sys_eeprom/module/make.mk b/packages/platforms/quanta/any/src/quanta_sys_eeprom/module/make.mk deleted file mode 100644 index 3ea6888c4..000000000 --- a/packages/platforms/quanta/any/src/quanta_sys_eeprom/module/make.mk +++ /dev/null @@ -1,10 +0,0 @@ -############################################################################### -# -# -# -############################################################################### -THIS_DIR := $(dir $(lastword $(MAKEFILE_LIST))) -quanta_sys_eeprom_INCLUDES := -I $(THIS_DIR)inc -quanta_sys_eeprom_INTERNAL_INCLUDES := -I $(THIS_DIR)src -quanta_sys_eeprom_DEPENDMODULE_ENTRIES := init:quanta_sys_eeprom ucli:quanta_sys_eeprom - diff --git a/packages/platforms/quanta/any/src/quanta_sys_eeprom/module/src/Makefile b/packages/platforms/quanta/any/src/quanta_sys_eeprom/module/src/Makefile deleted file mode 100644 index 807674bf5..000000000 --- a/packages/platforms/quanta/any/src/quanta_sys_eeprom/module/src/Makefile +++ /dev/null @@ -1,9 +0,0 @@ -############################################################################### -# -# Local source generation targets. -# -############################################################################### - -ucli: - @../../../../tools/uclihandlers.py quanta_sys_eeprom_ucli.c - diff --git a/packages/platforms/quanta/any/src/quanta_sys_eeprom/module/src/eeprom.c b/packages/platforms/quanta/any/src/quanta_sys_eeprom/module/src/eeprom.c deleted file mode 100644 index 188db3f5f..000000000 --- a/packages/platforms/quanta/any/src/quanta_sys_eeprom/module/src/eeprom.c +++ /dev/null @@ -1,188 +0,0 @@ -/************************************************************ - * - * - ************************************************************ - * - * - * - ***********************************************************/ -#include -#include -#include -#include "quanta_sys_eeprom_log.h" -#include - -int -quanta_sys_eeprom_parse_data(const uint8_t* data, int size, - quanta_sys_eeprom_t* rv) -{ - /* - * EEPROM Magic: 0xFF 0x01 0xE0 - */ - const uint8_t* p = data; - if(!rv || size < 3 || *p++ != 0xFF || *p++ != 0x01 || *p++ != 0xE0) { - return -1; - } - - memset(rv, 0, sizeof(*rv)); - - while(p < (data+size)) { - uint8_t code = *p++; - int clen = *p++; - if(clen < 1) { - break; - } - switch(code) - { -#define EEPROM_STRCPY(_field) aim_strlcpy(rv->_field, (char*)p, clen) -#define EEPROM_LONG(_field) rv->_field = (p[0] << 24 | p[1] << 16 | p[2] << 8 | p[3]) - - case 0x1: - /* Product Name */ - EEPROM_STRCPY(product_name); - break; - case 0x2: - /* Part Number */ - EEPROM_STRCPY(part_number); - break; - case 0x3: - /* Serial Number */ - EEPROM_STRCPY(serial_number); - break; - case 0x4: - /* MAC */ - memcpy(rv->mac_address, p, 6); - break; - - case 0x5: - /* Manufacture Date */ - { - struct tm time_tm; - time_t time_time; - memset(&time_tm, 0, sizeof(time_tm)); - - time_tm.tm_year = (p[0] << 8 | p[1]) - 1900; - time_tm.tm_mon = p[2] - 1; - time_tm.tm_mday = p[3]; - time_time = mktime(&time_tm); - struct tm* gtm = gmtime(&time_time); - strftime(rv->manufacture_date, - sizeof(rv->manufacture_date), - "%m/%d/%Y %H:%M:%S", - gtm); - break; - } - - case 0x6: - /* Card Type */ - EEPROM_LONG(card_type); - break; - case 0x7: - /* Hardware Version */ - EEPROM_LONG(hardware_version); - break; - case 0x8: - /* Label Version */ - EEPROM_STRCPY(label_version); - break; - case 0x9: - /* Model Name */ - EEPROM_STRCPY(model_name); - break; - case 0xA: - /* Software Version */ - EEPROM_LONG(software_version); - break; - - case 0x00: - /* CRC */ - rv->crc = p[0] << 8 | p[1]; - return 0; - } - p+=clen; - } - return 0; -} - -int -quanta_sys_eeprom_parse_file(const char* file, quanta_sys_eeprom_t* e) -{ - int rv; - uint8_t data[256]; - int len; - - rv = onlp_file_read(data, sizeof(data), &len, (char*)file); - if(rv >= 0) { - rv = quanta_sys_eeprom_parse_data(data, sizeof(data), e); - } - return rv; -} - - -int -quanta_sys_eeprom_to_onie(const quanta_sys_eeprom_t* src, - onlp_onie_info_t* dst) -{ - if(src == NULL || dst == NULL) { - return -1; - } - - memset(dst, 0, sizeof(*dst)); - list_init(&dst->vx_list); - dst->product_name = aim_strdup(src->product_name); - dst->part_number = aim_strdup(src->part_number); - dst->serial_number = aim_strdup(src->serial_number); - memcpy(dst->mac, src->mac_address, 6); - dst->manufacture_date = aim_strdup(src->manufacture_date); - dst->label_revision = aim_strdup(src->label_version); - dst->mac_range = 1; - dst->manufacturer = aim_strdup("Quanta"); - dst->vendor = aim_strdup("QuantaMesh"); - return 0; -} - -int -quanta_sys_eeprom_show(aim_pvs_t* pvs, quanta_sys_eeprom_t* e) -{ - aim_printf(pvs, "Product Name: %s\n", e->product_name); - aim_printf(pvs, "Model Name: %s\n", e->model_name); - aim_printf(pvs, "Part Number: %s\n", e->part_number); - aim_printf(pvs, "Serial Number: %s\n", e->serial_number); - aim_printf(pvs, "Manufacture Date: %s\n", e->manufacture_date); - aim_printf(pvs, "Label Version: %s\n", e->label_version); - aim_printf(pvs, "MAC: %{mac}\n", e->mac_address); - aim_printf(pvs, "Hardware Version: 0x%x (%d)\n", e->hardware_version, e->hardware_version); - aim_printf(pvs, "Software Version: 0x%x (%d)\n", e->software_version, e->software_version); - aim_printf(pvs, "Card Type: 0x%x (%d)\n", e->card_type, e->card_type); - aim_printf(pvs, "CRC: 0x%.2x\n", e->crc); - return 0; -} - -int -quanta_onie_sys_eeprom_custom_format(onlp_onie_info_t* onie) -{ - char buf[512]; - - if(onie == NULL) { - return -1; - } - - /* legacy format is four bytes long */ - if(strlen(onie->diag_version) != 4) { - return 0; - } - - memset(buf, 0, sizeof(buf)); - sprintf(buf, "%d.%d.%d.%d (0x%02x%02x)", - ((onie->diag_version[0] & 0xf0) >> 4), - (onie->diag_version[0] & 0x0f), - ((onie->diag_version[1] & 0xf0) >> 4), - (onie->diag_version[1] & 0x0f), - (onie->diag_version[2] & 0xff), - (onie->diag_version[3] & 0xff)); - aim_free((void*) onie->diag_version); - onie->diag_version = aim_zmalloc(strlen(buf) + 1); - memcpy((void*) onie->diag_version, buf, strlen(buf)); - - return 0; -} diff --git a/packages/platforms/quanta/any/src/quanta_sys_eeprom/module/src/make.mk b/packages/platforms/quanta/any/src/quanta_sys_eeprom/module/src/make.mk deleted file mode 100644 index 25432f2ae..000000000 --- a/packages/platforms/quanta/any/src/quanta_sys_eeprom/module/src/make.mk +++ /dev/null @@ -1,9 +0,0 @@ -############################################################################### -# -# -# -############################################################################### - -LIBRARY := quanta_sys_eeprom -$(LIBRARY)_SUBDIR := $(dir $(lastword $(MAKEFILE_LIST))) -include $(BUILDER)/lib.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 deleted file mode 100644 index 517a33627..000000000 --- a/packages/platforms/quanta/any/src/quanta_sys_eeprom/module/src/quanta_sys_eeprom_config.c +++ /dev/null @@ -1,76 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#include - -/* */ -#define __quanta_sys_eeprom_config_STRINGIFY_NAME(_x) #_x -#define __quanta_sys_eeprom_config_STRINGIFY_VALUE(_x) __quanta_sys_eeprom_config_STRINGIFY_NAME(_x) -quanta_sys_eeprom_config_settings_t quanta_sys_eeprom_config_settings[] = -{ -#ifdef QUANTA_SYS_EEPROM_CONFIG_INCLUDE_LOGGING - { __quanta_sys_eeprom_config_STRINGIFY_NAME(QUANTA_SYS_EEPROM_CONFIG_INCLUDE_LOGGING), __quanta_sys_eeprom_config_STRINGIFY_VALUE(QUANTA_SYS_EEPROM_CONFIG_INCLUDE_LOGGING) }, -#else -{ QUANTA_SYS_EEPROM_CONFIG_INCLUDE_LOGGING(__quanta_sys_eeprom_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef QUANTA_SYS_EEPROM_CONFIG_LOG_OPTIONS_DEFAULT - { __quanta_sys_eeprom_config_STRINGIFY_NAME(QUANTA_SYS_EEPROM_CONFIG_LOG_OPTIONS_DEFAULT), __quanta_sys_eeprom_config_STRINGIFY_VALUE(QUANTA_SYS_EEPROM_CONFIG_LOG_OPTIONS_DEFAULT) }, -#else -{ QUANTA_SYS_EEPROM_CONFIG_LOG_OPTIONS_DEFAULT(__quanta_sys_eeprom_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef QUANTA_SYS_EEPROM_CONFIG_LOG_BITS_DEFAULT - { __quanta_sys_eeprom_config_STRINGIFY_NAME(QUANTA_SYS_EEPROM_CONFIG_LOG_BITS_DEFAULT), __quanta_sys_eeprom_config_STRINGIFY_VALUE(QUANTA_SYS_EEPROM_CONFIG_LOG_BITS_DEFAULT) }, -#else -{ QUANTA_SYS_EEPROM_CONFIG_LOG_BITS_DEFAULT(__quanta_sys_eeprom_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef QUANTA_SYS_EEPROM_CONFIG_LOG_CUSTOM_BITS_DEFAULT - { __quanta_sys_eeprom_config_STRINGIFY_NAME(QUANTA_SYS_EEPROM_CONFIG_LOG_CUSTOM_BITS_DEFAULT), __quanta_sys_eeprom_config_STRINGIFY_VALUE(QUANTA_SYS_EEPROM_CONFIG_LOG_CUSTOM_BITS_DEFAULT) }, -#else -{ QUANTA_SYS_EEPROM_CONFIG_LOG_CUSTOM_BITS_DEFAULT(__quanta_sys_eeprom_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef QUANTA_SYS_EEPROM_CONFIG_PORTING_STDLIB - { __quanta_sys_eeprom_config_STRINGIFY_NAME(QUANTA_SYS_EEPROM_CONFIG_PORTING_STDLIB), __quanta_sys_eeprom_config_STRINGIFY_VALUE(QUANTA_SYS_EEPROM_CONFIG_PORTING_STDLIB) }, -#else -{ QUANTA_SYS_EEPROM_CONFIG_PORTING_STDLIB(__quanta_sys_eeprom_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef QUANTA_SYS_EEPROM_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS - { __quanta_sys_eeprom_config_STRINGIFY_NAME(QUANTA_SYS_EEPROM_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS), __quanta_sys_eeprom_config_STRINGIFY_VALUE(QUANTA_SYS_EEPROM_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS) }, -#else -{ QUANTA_SYS_EEPROM_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS(__quanta_sys_eeprom_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef QUANTA_SYS_EEPROM_CONFIG_INCLUDE_UCLI - { __quanta_sys_eeprom_config_STRINGIFY_NAME(QUANTA_SYS_EEPROM_CONFIG_INCLUDE_UCLI), __quanta_sys_eeprom_config_STRINGIFY_VALUE(QUANTA_SYS_EEPROM_CONFIG_INCLUDE_UCLI) }, -#else -{ QUANTA_SYS_EEPROM_CONFIG_INCLUDE_UCLI(__quanta_sys_eeprom_config_STRINGIFY_NAME), "__undefined__" }, -#endif - { NULL, NULL } -}; -#undef __quanta_sys_eeprom_config_STRINGIFY_VALUE -#undef __quanta_sys_eeprom_config_STRINGIFY_NAME - -const char* -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)) { - return quanta_sys_eeprom_config_settings[i].value; - } - } - return NULL; -} - -int -quanta_sys_eeprom_config_show(struct aim_pvs_s* pvs) -{ - int i; - for(i = 0; quanta_sys_eeprom_config_settings[i].name; i++) { - aim_printf(pvs, "%s = %s\n", quanta_sys_eeprom_config_settings[i].name, quanta_sys_eeprom_config_settings[i].value); - } - return i; -} - -/* */ - diff --git a/packages/platforms/quanta/any/src/quanta_sys_eeprom/module/src/quanta_sys_eeprom_enums.c b/packages/platforms/quanta/any/src/quanta_sys_eeprom/module/src/quanta_sys_eeprom_enums.c deleted file mode 100644 index c020dfb08..000000000 --- a/packages/platforms/quanta/any/src/quanta_sys_eeprom/module/src/quanta_sys_eeprom_enums.c +++ /dev/null @@ -1,10 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#include - -/* <--auto.start.enum(ALL).source> */ -/* */ - diff --git a/packages/platforms/quanta/any/src/quanta_sys_eeprom/module/src/quanta_sys_eeprom_int.h b/packages/platforms/quanta/any/src/quanta_sys_eeprom/module/src/quanta_sys_eeprom_int.h deleted file mode 100644 index 698446ced..000000000 --- a/packages/platforms/quanta/any/src/quanta_sys_eeprom/module/src/quanta_sys_eeprom_int.h +++ /dev/null @@ -1,12 +0,0 @@ -/**************************************************************************//** - * - * quanta_sys_eeprom Internal Header - * - *****************************************************************************/ -#ifndef __QUANTA_SYS_EEPROM_INT_H__ -#define __QUANTA_SYS_EEPROM_INT_H__ - -#include - - -#endif /* __QUANTA_SYS_EEPROM_INT_H__ */ diff --git a/packages/platforms/quanta/any/src/quanta_sys_eeprom/module/src/quanta_sys_eeprom_log.c b/packages/platforms/quanta/any/src/quanta_sys_eeprom/module/src/quanta_sys_eeprom_log.c deleted file mode 100644 index c1a3854a7..000000000 --- a/packages/platforms/quanta/any/src/quanta_sys_eeprom/module/src/quanta_sys_eeprom_log.c +++ /dev/null @@ -1,18 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#include - -#include "quanta_sys_eeprom_log.h" -/* - * quanta_sys_eeprom log struct. - */ -AIM_LOG_STRUCT_DEFINE( - QUANTA_SYS_EEPROM_CONFIG_LOG_OPTIONS_DEFAULT, - QUANTA_SYS_EEPROM_CONFIG_LOG_BITS_DEFAULT, - NULL, /* Custom log map */ - QUANTA_SYS_EEPROM_CONFIG_LOG_CUSTOM_BITS_DEFAULT - ); - diff --git a/packages/platforms/quanta/any/src/quanta_sys_eeprom/module/src/quanta_sys_eeprom_log.h b/packages/platforms/quanta/any/src/quanta_sys_eeprom/module/src/quanta_sys_eeprom_log.h deleted file mode 100644 index 0952006a0..000000000 --- a/packages/platforms/quanta/any/src/quanta_sys_eeprom/module/src/quanta_sys_eeprom_log.h +++ /dev/null @@ -1,12 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#ifndef __QUANTA_SYS_EEPROM_LOG_H__ -#define __QUANTA_SYS_EEPROM_LOG_H__ - -#define AIM_LOG_MODULE_NAME quanta_sys_eeprom -#include - -#endif /* __QUANTA_SYS_EEPROM_LOG_H__ */ diff --git a/packages/platforms/quanta/any/src/quanta_sys_eeprom/module/src/quanta_sys_eeprom_module.c b/packages/platforms/quanta/any/src/quanta_sys_eeprom/module/src/quanta_sys_eeprom_module.c deleted file mode 100644 index 4c296e371..000000000 --- a/packages/platforms/quanta/any/src/quanta_sys_eeprom/module/src/quanta_sys_eeprom_module.c +++ /dev/null @@ -1,23 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#include - -#include "quanta_sys_eeprom_log.h" - -static int -datatypes_init__(void) -{ -#define QUANTA_SYS_EEPROM_ENUMERATION_ENTRY(_enum_name, _desc) AIM_DATATYPE_MAP_REGISTER(_enum_name, _enum_name##_map, _desc, AIM_LOG_INTERNAL); -#include - return 0; -} - -void __quanta_sys_eeprom_module_init__(void) -{ - AIM_LOG_STRUCT_REGISTER(); - datatypes_init__(); -} - diff --git a/packages/platforms/quanta/any/src/quanta_sys_eeprom/module/src/quanta_sys_eeprom_ucli.c b/packages/platforms/quanta/any/src/quanta_sys_eeprom/module/src/quanta_sys_eeprom_ucli.c deleted file mode 100644 index 221bf196e..000000000 --- a/packages/platforms/quanta/any/src/quanta_sys_eeprom/module/src/quanta_sys_eeprom_ucli.c +++ /dev/null @@ -1,50 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#include - -#if QUANTA_SYS_EEPROM_CONFIG_INCLUDE_UCLI == 1 - -#include -#include -#include - -static ucli_status_t -quanta_sys_eeprom_ucli_ucli__config__(ucli_context_t* uc) -{ - UCLI_HANDLER_MACRO_MODULE_CONFIG(quanta_sys_eeprom) -} - -/* */ -/* */ - -static ucli_module_t -quanta_sys_eeprom_ucli_module__ = - { - "quanta_sys_eeprom_ucli", - NULL, - quanta_sys_eeprom_ucli_ucli_handlers__, - NULL, - NULL, - }; - -ucli_node_t* -quanta_sys_eeprom_ucli_node_create(void) -{ - ucli_node_t* n; - ucli_module_init(&quanta_sys_eeprom_ucli_module__); - n = ucli_node_create("quanta_sys_eeprom", NULL, &quanta_sys_eeprom_ucli_module__); - ucli_node_subnode_add(n, ucli_module_log_node_create("quanta_sys_eeprom")); - return n; -} - -#else -void* -quanta_sys_eeprom_ucli_node_create(void) -{ - return NULL; -} -#endif - diff --git a/packages/platforms/quanta/any/src/quanta_sys_eeprom/quanta_sys_eeprom.doxy b/packages/platforms/quanta/any/src/quanta_sys_eeprom/quanta_sys_eeprom.doxy deleted file mode 100644 index 0e9168282..000000000 --- a/packages/platforms/quanta/any/src/quanta_sys_eeprom/quanta_sys_eeprom.doxy +++ /dev/null @@ -1,1792 +0,0 @@ -# Doxyfile 1.8.1.2 - -# 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 = "quanta_sys_eeprom" - -# 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 = "Quanta System EEPROM decoder." - -# 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. - -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 = 8 - -# 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 - -# 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 sectionname ... \endif. - -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. - -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 = - -#--------------------------------------------------------------------------- -# 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 the tag is left blank doxygen -# will generate a default style sheet. Note that doxygen will try to copy -# the style sheet file to the HTML output directory, so don't put your own -# style sheet in the HTML output directory as well, or it will be erased! - -HTML_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 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 PHP enabled web server instead of at the web client -# using Javascript. Doxygen will generate the search PHP script and index -# file to put on the web server. The advantage of the server -# based approach is that it scales better to large projects and allows -# full text search. The disadvantages are that it is more difficult to setup -# and does not have live searching capabilities. - -SERVER_BASED_SEARCH = NO - -#--------------------------------------------------------------------------- -# 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/quanta/any/src/quanta_sys_eeprom/utest/_make.mk b/packages/platforms/quanta/any/src/quanta_sys_eeprom/utest/_make.mk deleted file mode 100644 index 68d24b790..000000000 --- a/packages/platforms/quanta/any/src/quanta_sys_eeprom/utest/_make.mk +++ /dev/null @@ -1,8 +0,0 @@ -############################################################################### -# -# quanta_sys_eeprom Unit Test Makefile. -# -############################################################################### -UMODULE := quanta_sys_eeprom -UMODULE_SUBDIR := $(dir $(lastword $(MAKEFILE_LIST))) -include $(BUILDER)/utest.mk diff --git a/packages/platforms/quanta/any/src/quanta_sys_eeprom/utest/main.c b/packages/platforms/quanta/any/src/quanta_sys_eeprom/utest/main.c deleted file mode 100644 index 88eeba92d..000000000 --- a/packages/platforms/quanta/any/src/quanta_sys_eeprom/utest/main.c +++ /dev/null @@ -1,155 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#include -#include - -#include -#include -#include -#include - - -struct eeprom_data_s { - uint8_t eeprom[256]; - quanta_sys_eeprom_t data; -} test_data__[] = - { - { - { - 0xff, 0x01, 0xe0, 0x01, 0x03, 0x4c, 0x59, 0x32, 0x02, 0x0b, 0x31, - 0x4c, 0x59, 0x32, 0x42, 0x5a, 0x5a, 0x30, 0x30, 0x30, 0x52, 0x03, - 0x0d, 0x51, 0x54, 0x46, 0x43, 0x45, 0x41, 0x33, 0x32, 0x31, 0x30, - 0x30, 0x32, 0x31, 0x04, 0x06, 0x08, 0x9e, 0x01, 0xce, 0xde, 0x75, - 0x05, 0x04, 0x07, 0xdd, 0x05, 0x0a, 0x06, 0x04, 0x00, 0x00, 0x00, - 0x01, 0x07, 0x04, 0x00, 0x03, 0x00, 0x00, 0x08, 0x01, 0x31, 0x09, - 0x0a, 0x51, 0x55, 0x41, 0x4e, 0x54, 0x41, 0x20, 0x4c, 0x59, 0x32, - 0x0a, 0x04, 0x00, 0x00, 0xf2, 0x01, 0x00, 0x02, 0xfb, 0x67, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - }, - { - "LY2", - "QUANTA LY2", - "1LY2BZZ000R", - "QTFCEA3210021", - "05/10/2013 08:00:00", - "1", - {0x08, 0x9e, 0x01, 0xce, 0xde, 0x75}, - 0x30000, - 0xf201, - 0x1, - 0xfb67, - }, - }, - { - { - 0xff, 0x01, 0xe0, 0x01, 0x03, 0x4c, 0x59, 0x32, 0x02, 0x0b, - 0x31, 0x4c, 0x59, 0x32, 0x42, 0x5a, 0x5a, 0x30, 0x30, 0x30, - 0x38, 0x03, 0x0d, 0x51, 0x54, 0x46, 0x43, 0x45, 0x41, 0x32, - 0x34, 0x32, 0x30, 0x30, 0x32, 0x32, 0x04, 0x06, 0x08, 0x9e, - 0x01, 0x53, 0x78, 0xa6, 0x05, 0x04, 0x07, 0xdc, 0x0a, 0x0f, - 0x06, 0x04, 0x00, 0x00, 0x00, 0x01, 0x07, 0x04, 0x00, 0x03, - 0x00, 0x00, 0x08, 0x01, 0x31, 0x09, 0x0a, 0x51, 0x55, 0x41, - 0x4e, 0x54, 0x41, 0x20, 0x4c, 0x59, 0x32, 0x0a, 0x04, 0x00, - 0x00, 0xf2, 0x01, 0x00, 0x02, 0xc0, 0x74, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - }, - { - "LY2", - "QUANTA LY2", - "1LY2BZZ0008", - "QTFCEA2420022", - "10/15/2012 08:00:00", - "1", - {0x08, 0x9e, 0x01, 0x53, 0x78, 0xa6}, - 0x30000, - 0xf201, - 0x1, - 0xc074, - }, - }, - { - { - 0xff, 0x01, 0xe0, 0x01, 0x03, 0x4c, 0x42, 0x39, 0x02, 0x0b, - 0x31, 0x4c, 0x42, 0x39, 0x42, 0x5a, 0x5a, 0x30, 0x53, 0x54, - 0x51, 0x03, 0x0d, 0x51, 0x54, 0x46, 0x43, 0x41, 0x36, 0x33, - 0x32, 0x38, 0x30, 0x30, 0x30, 0x31, 0x04, 0x06, 0x08, 0x9e, - 0x01, 0xce, 0xbd, 0x2d, 0x05, 0x04, 0x07, 0xdd, 0x07, 0x05, - 0x06, 0x04, 0x00, 0x00, 0x00, 0x01, 0x07, 0x04, 0x01, 0x00, - 0x00, 0x00, 0x08, 0x01, 0x31, 0x09, 0x0a, 0x51, 0x55, 0x41, - 0x4e, 0x54, 0x41, 0x20, 0x4c, 0x42, 0x39, 0x0a, 0x04, 0x00, - 0x00, 0xb9, 0x01, 0x00, 0x02, 0x56, 0xc0, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - }, - { - "LB9", - "QUANTA LB9", - "1LB9BZZ0STQ", - "QTFCA63280001", - "07/05/2013 08:00:00", - "1", - {0x08,0x9e,0x01,0xce,0xbd,0x2d}, - 0x1000000, - 0xb901, - 0x1, - 0x56c0, - }, - }, - { - { - 0xff, 0x01, 0xe0, 0x01, 0x03, 0x4c, 0x42, 0x39, 0x02, 0x0b, - 0x31, 0x4c, 0x42, 0x39, 0x42, 0x5a, 0x5a, 0x30, 0x53, 0x54, - 0x45, 0x03, 0x0d, 0x51, 0x54, 0x46, 0x43, 0x58, 0x49, 0x32, - 0x34, 0x36, 0x30, 0x32, 0x30, 0x33, 0x04, 0x06, 0x04, 0x7d, - 0x7b, 0xfc, 0xa7, 0x43, 0x05, 0x04, 0x07, 0xdc, 0x08, 0x05, - 0x06, 0x04, 0x00, 0x00, 0x00, 0x01, 0x07, 0x04, 0x01, 0x00, - 0x00, 0x00, 0x08, 0x01, 0x31, 0x09, 0x0a, 0x51, 0x55, 0x41, - 0x4e, 0x54, 0x41, 0x20, 0x4c, 0x42, 0x39, 0x0a, 0x04, 0x00, - 0x00, 0xb9, 0x01, 0x00, 0x02, 0x41, 0x53, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - }, - { - "LB9", - "QUANTA LB9", - "1LB9BZZ0STE", - "QTFCXI2460203", - "08/05/2012 08:00:00", - "1", - {0x04,0x7d,0x7b,0x0fc,0xa7,0x43}, - 0x1000000, - 0xb901, - 0x1, - 0x4153, - }, - }, - }; - - -int aim_main(int argc, char* argv[]) -{ - int i; - quanta_sys_eeprom_t e; - - - for(i = 0; i < AIM_ARRAYSIZE(test_data__); i++) { - if(quanta_sys_eeprom_parse_data(test_data__[i].eeprom, - sizeof(test_data__[i].eeprom), - &e) < 0) { - AIM_DIE("parse entry %d failed."); - } - if(memcmp(&e, &test_data__[i].data, sizeof(e))) { - printf("Mismatch entry %d\n", i); - printf("Expected: \n"); - quanta_sys_eeprom_show(&aim_pvs_stdout, &test_data__[i].data); - printf("\nGot: \n"); - quanta_sys_eeprom_show(&aim_pvs_stdout, &e); - AIM_DIE("Entry %d failed", i); - } - } - return 0; -} - diff --git a/packages/platforms/quanta/powerpc/Makefile b/packages/platforms/quanta/powerpc/Makefile deleted file mode 100644 index 003238cf6..000000000 --- a/packages/platforms/quanta/powerpc/Makefile +++ /dev/null @@ -1 +0,0 @@ -include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/quanta/powerpc/lb9/.gitignore b/packages/platforms/quanta/powerpc/lb9/.gitignore deleted file mode 100644 index 041693db2..000000000 --- a/packages/platforms/quanta/powerpc/lb9/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -*powerpc*quanta*lb9*.mk -onlpdump.mk - diff --git a/packages/platforms/quanta/powerpc/lb9/Makefile b/packages/platforms/quanta/powerpc/lb9/Makefile deleted file mode 100644 index dc1e7b86f..000000000 --- a/packages/platforms/quanta/powerpc/lb9/Makefile +++ /dev/null @@ -1 +0,0 @@ -include $(ONL)/make/pkg.mk diff --git a/packages/platforms/quanta/powerpc/lb9/modules/Makefile b/packages/platforms/quanta/powerpc/lb9/modules/Makefile deleted file mode 100644 index 003238cf6..000000000 --- a/packages/platforms/quanta/powerpc/lb9/modules/Makefile +++ /dev/null @@ -1 +0,0 @@ -include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/quanta/powerpc/lb9/modules/PKG.yml b/packages/platforms/quanta/powerpc/lb9/modules/PKG.yml deleted file mode 100644 index 5547795d3..000000000 --- a/packages/platforms/quanta/powerpc/lb9/modules/PKG.yml +++ /dev/null @@ -1 +0,0 @@ -!include $ONL_TEMPLATES/no-platform-modules.yml ARCH=powerpc VENDOR=quanta BASENAME=powerpc-quanta-lb9 diff --git a/packages/platforms/quanta/powerpc/lb9/onlp/Makefile b/packages/platforms/quanta/powerpc/lb9/onlp/Makefile deleted file mode 100644 index dc1e7b86f..000000000 --- a/packages/platforms/quanta/powerpc/lb9/onlp/Makefile +++ /dev/null @@ -1 +0,0 @@ -include $(ONL)/make/pkg.mk diff --git a/packages/platforms/quanta/powerpc/lb9/onlp/PKG.yml b/packages/platforms/quanta/powerpc/lb9/onlp/PKG.yml deleted file mode 100644 index 3dc81b676..000000000 --- a/packages/platforms/quanta/powerpc/lb9/onlp/PKG.yml +++ /dev/null @@ -1 +0,0 @@ -!include $ONL_TEMPLATES/onlp-platform-any.yml PLATFORM=powerpc-quanta-lb9 ARCH=powerpc TOOLCHAIN=powerpc-linux-gnu diff --git a/packages/platforms/quanta/powerpc/lb9/onlp/builds/Makefile b/packages/platforms/quanta/powerpc/lb9/onlp/builds/Makefile deleted file mode 100644 index e7437cb23..000000000 --- a/packages/platforms/quanta/powerpc/lb9/onlp/builds/Makefile +++ /dev/null @@ -1,2 +0,0 @@ -FILTER=src -include $(ONL)/make/subdirs.mk diff --git a/packages/platforms/quanta/powerpc/lb9/onlp/builds/lib/Makefile b/packages/platforms/quanta/powerpc/lb9/onlp/builds/lib/Makefile deleted file mode 100644 index 1200433ec..000000000 --- a/packages/platforms/quanta/powerpc/lb9/onlp/builds/lib/Makefile +++ /dev/null @@ -1,3 +0,0 @@ -PLATFORM := powerpc-quanta-lb9 -EXTRA_MODULES := quanta_sys_eeprom -include $(ONL)/packages/base/any/onlp/builds/platform/libonlp-platform.mk diff --git a/packages/platforms/quanta/powerpc/lb9/onlp/builds/onlpdump/Makefile b/packages/platforms/quanta/powerpc/lb9/onlp/builds/onlpdump/Makefile deleted file mode 100644 index e067a6e8b..000000000 --- a/packages/platforms/quanta/powerpc/lb9/onlp/builds/onlpdump/Makefile +++ /dev/null @@ -1,3 +0,0 @@ -PLATFORM := powerpc-quanta-lb9 -EXTRA_MODULES := quanta_sys_eeprom -include $(ONL)/packages/base/any/onlp/builds/platform/onlps.mk diff --git a/packages/platforms/quanta/powerpc/lb9/onlp/builds/powerpc_quanta_lb9/.gitignore b/packages/platforms/quanta/powerpc/lb9/onlp/builds/powerpc_quanta_lb9/.gitignore deleted file mode 100644 index c81d16be3..000000000 --- a/packages/platforms/quanta/powerpc/lb9/onlp/builds/powerpc_quanta_lb9/.gitignore +++ /dev/null @@ -1 +0,0 @@ -*.mk diff --git a/packages/platforms/quanta/powerpc/lb9/onlp/builds/powerpc_quanta_lb9/.module b/packages/platforms/quanta/powerpc/lb9/onlp/builds/powerpc_quanta_lb9/.module deleted file mode 100644 index f20123ae5..000000000 --- a/packages/platforms/quanta/powerpc/lb9/onlp/builds/powerpc_quanta_lb9/.module +++ /dev/null @@ -1 +0,0 @@ -name: powerpc_quanta_lb9 diff --git a/packages/platforms/quanta/powerpc/lb9/onlp/builds/powerpc_quanta_lb9/Makefile b/packages/platforms/quanta/powerpc/lb9/onlp/builds/powerpc_quanta_lb9/Makefile deleted file mode 100644 index f1dc1502a..000000000 --- a/packages/platforms/quanta/powerpc/lb9/onlp/builds/powerpc_quanta_lb9/Makefile +++ /dev/null @@ -1,10 +0,0 @@ -############################################################################### -# -# -# -############################################################################### -include $(ONL)/make/config.mk - -MODULE := powerpc_quanta_lb9 -AUTOMODULE := powerpc_quanta_lb9 -include $(BUILDER)/definemodule.mk diff --git a/packages/platforms/quanta/powerpc/lb9/onlp/builds/powerpc_quanta_lb9/README b/packages/platforms/quanta/powerpc/lb9/onlp/builds/powerpc_quanta_lb9/README deleted file mode 100644 index ca7e67f3b..000000000 --- a/packages/platforms/quanta/powerpc/lb9/onlp/builds/powerpc_quanta_lb9/README +++ /dev/null @@ -1,6 +0,0 @@ -############################################################################### -# -# powerpc_quanta_lb9 README -# -############################################################################### - diff --git a/packages/platforms/quanta/powerpc/lb9/onlp/builds/powerpc_quanta_lb9/module/auto/make.mk b/packages/platforms/quanta/powerpc/lb9/onlp/builds/powerpc_quanta_lb9/module/auto/make.mk deleted file mode 100644 index dc390dbe1..000000000 --- a/packages/platforms/quanta/powerpc/lb9/onlp/builds/powerpc_quanta_lb9/module/auto/make.mk +++ /dev/null @@ -1,9 +0,0 @@ -############################################################################### -# -# powerpc_quanta_lb9 Autogeneration -# -############################################################################### -powerpc_quanta_lb9_AUTO_DEFS := module/auto/powerpc_quanta_lb9.yml -powerpc_quanta_lb9_AUTO_DIRS := module/inc/powerpc_quanta_lb9 module/src -include $(BUILDER)/auto.mk - diff --git a/packages/platforms/quanta/powerpc/lb9/onlp/builds/powerpc_quanta_lb9/module/auto/powerpc_quanta_lb9.yml b/packages/platforms/quanta/powerpc/lb9/onlp/builds/powerpc_quanta_lb9/module/auto/powerpc_quanta_lb9.yml deleted file mode 100644 index cf4c66769..000000000 --- a/packages/platforms/quanta/powerpc/lb9/onlp/builds/powerpc_quanta_lb9/module/auto/powerpc_quanta_lb9.yml +++ /dev/null @@ -1,116 +0,0 @@ -############################################################################### -# -# powerpc_quanta_lb9 Autogeneration Definitions. -# -############################################################################### - -cdefs: &cdefs -- POWERPC_QUANTA_LB9_R0_CONFIG_INCLUDE_LOGGING: - doc: "Include or exclude logging." - default: 1 -- POWERPC_QUANTA_LB9_R0_CONFIG_LOG_OPTIONS_DEFAULT: - doc: "Default enabled log options." - default: AIM_LOG_OPTIONS_DEFAULT -- POWERPC_QUANTA_LB9_R0_CONFIG_LOG_BITS_DEFAULT: - doc: "Default enabled log bits." - default: AIM_LOG_BITS_DEFAULT -- POWERPC_QUANTA_LB9_R0_CONFIG_LOG_CUSTOM_BITS_DEFAULT: - doc: "Default enabled custom log bits." - default: 0 -- POWERPC_QUANTA_LB9_R0_CONFIG_PORTING_STDLIB: - doc: "Default all porting macros to use the C standard libraries." - default: 1 -- POWERPC_QUANTA_LB9_R0_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS: - doc: "Include standard library headers for stdlib porting macros." - default: POWERPC_QUANTA_LB9_R0_CONFIG_PORTING_STDLIB -- POWERPC_QUANTA_LB9_R0_CONFIG_INCLUDE_UCLI: - doc: "Include generic uCli support." - default: 0 -- POWERPC_QUANTA_LB9_R0_CONFIG_SYSFAN_RPM_FAILURE_THRESHOLD: - doc: "RPM Threshold at which the fan is considered to have failed." - default: 100 -- POWERPC_QUANTA_LB9_R0_CONFIG_SYSFAN_RPM_F2B_MAX: - doc: "Maximum system fan speed in front-to-back mode." - default: 16000 -- POWERPC_QUANTA_LB9_R0_CONFIG_SYSFAN_RPM_B2F_MAX: - doc: "Maximum system fan speed in back-to-front mode." - default: 24000 -- POWERPC_QUANTA_LB9_R0_CONFIG_PHY_RESET_DELAY_MS: - doc: "Time to hold Phy GPIO in reset, in ms" - default: 100 - -definitions: - cdefs: - POWERPC_QUANTA_LB9_R0_CONFIG_HEADER: - defs: *cdefs - basename: powerpc_quanta_lb9_config - - enum: &enums - - fan_id: - members: - - FAN1 : 1 - - FAN2 : 2 - - FAN3 : 3 - - FAN4 : 4 - - FAN5 : 5 - - FAN6 : 6 - - 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) - - 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 - - - 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) - - - portingmacro: - POWERPC_QUANTA_LB9_R0: - macros: - - memset - - memcpy - - - vsnprintf - - snprintf - - strlen diff --git a/packages/platforms/quanta/powerpc/lb9/onlp/builds/powerpc_quanta_lb9/module/inc/powerpc_quanta_lb9/powerpc_quanta_lb9.x b/packages/platforms/quanta/powerpc/lb9/onlp/builds/powerpc_quanta_lb9/module/inc/powerpc_quanta_lb9/powerpc_quanta_lb9.x deleted file mode 100644 index d7cd4dd3e..000000000 --- a/packages/platforms/quanta/powerpc/lb9/onlp/builds/powerpc_quanta_lb9/module/inc/powerpc_quanta_lb9/powerpc_quanta_lb9.x +++ /dev/null @@ -1,14 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#include - -/* <--auto.start.xmacro(ALL).define> */ -/* */ - -/* <--auto.start.xenum(ALL).define> */ -/* */ - - diff --git a/packages/platforms/quanta/powerpc/lb9/onlp/builds/powerpc_quanta_lb9/module/inc/powerpc_quanta_lb9/powerpc_quanta_lb9_config.h b/packages/platforms/quanta/powerpc/lb9/onlp/builds/powerpc_quanta_lb9/module/inc/powerpc_quanta_lb9/powerpc_quanta_lb9_config.h deleted file mode 100644 index 3ad26bf13..000000000 --- a/packages/platforms/quanta/powerpc/lb9/onlp/builds/powerpc_quanta_lb9/module/inc/powerpc_quanta_lb9/powerpc_quanta_lb9_config.h +++ /dev/null @@ -1,167 +0,0 @@ -/**************************************************************************//** - * - * @file - * @brief powerpc_quanta_lb9 Configuration Header - * - * @addtogroup powerpc_quanta_lb9-config - * @{ - * - *****************************************************************************/ -#ifndef __POWERPC_QUANTA_LB9_R0_CONFIG_H__ -#define __POWERPC_QUANTA_LB9_R0_CONFIG_H__ - -#ifdef GLOBAL_INCLUDE_CUSTOM_CONFIG -#include -#endif -#ifdef POWERPC_QUANTA_LB9_R0_INCLUDE_CUSTOM_CONFIG -#include -#endif - -/* */ -#include -/** - * POWERPC_QUANTA_LB9_R0_CONFIG_INCLUDE_LOGGING - * - * Include or exclude logging. */ - - -#ifndef POWERPC_QUANTA_LB9_R0_CONFIG_INCLUDE_LOGGING -#define POWERPC_QUANTA_LB9_R0_CONFIG_INCLUDE_LOGGING 1 -#endif - -/** - * POWERPC_QUANTA_LB9_R0_CONFIG_LOG_OPTIONS_DEFAULT - * - * Default enabled log options. */ - - -#ifndef POWERPC_QUANTA_LB9_R0_CONFIG_LOG_OPTIONS_DEFAULT -#define POWERPC_QUANTA_LB9_R0_CONFIG_LOG_OPTIONS_DEFAULT AIM_LOG_OPTIONS_DEFAULT -#endif - -/** - * POWERPC_QUANTA_LB9_R0_CONFIG_LOG_BITS_DEFAULT - * - * Default enabled log bits. */ - - -#ifndef POWERPC_QUANTA_LB9_R0_CONFIG_LOG_BITS_DEFAULT -#define POWERPC_QUANTA_LB9_R0_CONFIG_LOG_BITS_DEFAULT AIM_LOG_BITS_DEFAULT -#endif - -/** - * POWERPC_QUANTA_LB9_R0_CONFIG_LOG_CUSTOM_BITS_DEFAULT - * - * Default enabled custom log bits. */ - - -#ifndef POWERPC_QUANTA_LB9_R0_CONFIG_LOG_CUSTOM_BITS_DEFAULT -#define POWERPC_QUANTA_LB9_R0_CONFIG_LOG_CUSTOM_BITS_DEFAULT 0 -#endif - -/** - * POWERPC_QUANTA_LB9_R0_CONFIG_PORTING_STDLIB - * - * Default all porting macros to use the C standard libraries. */ - - -#ifndef POWERPC_QUANTA_LB9_R0_CONFIG_PORTING_STDLIB -#define POWERPC_QUANTA_LB9_R0_CONFIG_PORTING_STDLIB 1 -#endif - -/** - * POWERPC_QUANTA_LB9_R0_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS - * - * Include standard library headers for stdlib porting macros. */ - - -#ifndef POWERPC_QUANTA_LB9_R0_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS -#define POWERPC_QUANTA_LB9_R0_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS POWERPC_QUANTA_LB9_R0_CONFIG_PORTING_STDLIB -#endif - -/** - * POWERPC_QUANTA_LB9_R0_CONFIG_INCLUDE_UCLI - * - * Include generic uCli support. */ - - -#ifndef POWERPC_QUANTA_LB9_R0_CONFIG_INCLUDE_UCLI -#define POWERPC_QUANTA_LB9_R0_CONFIG_INCLUDE_UCLI 0 -#endif - -/** - * POWERPC_QUANTA_LB9_R0_CONFIG_SYSFAN_RPM_FAILURE_THRESHOLD - * - * RPM Threshold at which the fan is considered to have failed. */ - - -#ifndef POWERPC_QUANTA_LB9_R0_CONFIG_SYSFAN_RPM_FAILURE_THRESHOLD -#define POWERPC_QUANTA_LB9_R0_CONFIG_SYSFAN_RPM_FAILURE_THRESHOLD 100 -#endif - -/** - * POWERPC_QUANTA_LB9_R0_CONFIG_SYSFAN_RPM_F2B_MAX - * - * Maximum system fan speed in front-to-back mode. */ - - -#ifndef POWERPC_QUANTA_LB9_R0_CONFIG_SYSFAN_RPM_F2B_MAX -#define POWERPC_QUANTA_LB9_R0_CONFIG_SYSFAN_RPM_F2B_MAX 16000 -#endif - -/** - * POWERPC_QUANTA_LB9_R0_CONFIG_SYSFAN_RPM_B2F_MAX - * - * Maximum system fan speed in back-to-front mode. */ - - -#ifndef POWERPC_QUANTA_LB9_R0_CONFIG_SYSFAN_RPM_B2F_MAX -#define POWERPC_QUANTA_LB9_R0_CONFIG_SYSFAN_RPM_B2F_MAX 24000 -#endif - -/** - * POWERPC_QUANTA_LB9_R0_CONFIG_PHY_RESET_DELAY_MS - * - * Time to hold Phy GPIO in reset, in ms */ - - -#ifndef POWERPC_QUANTA_LB9_R0_CONFIG_PHY_RESET_DELAY_MS -#define POWERPC_QUANTA_LB9_R0_CONFIG_PHY_RESET_DELAY_MS 100 -#endif - - - -/** - * All compile time options can be queried or displayed - */ - -/** Configuration settings structure. */ -typedef struct powerpc_quanta_lb9_config_settings_s { - /** name */ - const char* name; - /** value */ - const char* value; -} powerpc_quanta_lb9_config_settings_t; - -/** Configuration settings table. */ -/** powerpc_quanta_lb9_config_settings table. */ -extern powerpc_quanta_lb9_config_settings_t powerpc_quanta_lb9_config_settings[]; - -/** - * @brief Lookup a configuration setting. - * @param setting The name of the configuration option to lookup. - */ -const char* powerpc_quanta_lb9_config_lookup(const char* setting); - -/** - * @brief Show the compile-time configuration. - * @param pvs The output stream. - */ -int powerpc_quanta_lb9_config_show(struct aim_pvs_s* pvs); - -/* */ - -#include "powerpc_quanta_lb9_porting.h" - -#endif /* __POWERPC_QUANTA_LB9_R0_CONFIG_H__ */ -/* @} */ diff --git a/packages/platforms/quanta/powerpc/lb9/onlp/builds/powerpc_quanta_lb9/module/inc/powerpc_quanta_lb9/powerpc_quanta_lb9_dox.h b/packages/platforms/quanta/powerpc/lb9/onlp/builds/powerpc_quanta_lb9/module/inc/powerpc_quanta_lb9/powerpc_quanta_lb9_dox.h deleted file mode 100644 index d85a874ec..000000000 --- a/packages/platforms/quanta/powerpc/lb9/onlp/builds/powerpc_quanta_lb9/module/inc/powerpc_quanta_lb9/powerpc_quanta_lb9_dox.h +++ /dev/null @@ -1,26 +0,0 @@ -/**************************************************************************//** - * - * powerpc_quanta_lb9 Doxygen Header - * - *****************************************************************************/ -#ifndef __POWERPC_QUANTA_LB9_R0_DOX_H__ -#define __POWERPC_QUANTA_LB9_R0_DOX_H__ - -/** - * @defgroup powerpc_quanta_lb9 powerpc_quanta_lb9 - powerpc_quanta_lb9 Description - * - -The documentation overview for this module should go here. - - * - * @{ - * - * @defgroup powerpc_quanta_lb9-powerpc_quanta_lb9 Public Interface - * @defgroup powerpc_quanta_lb9-config Compile Time Configuration - * @defgroup powerpc_quanta_lb9-porting Porting Macros - * - * @} - * - */ - -#endif /* __POWERPC_QUANTA_LB9_R0_DOX_H__ */ diff --git a/packages/platforms/quanta/powerpc/lb9/onlp/builds/powerpc_quanta_lb9/module/inc/powerpc_quanta_lb9/powerpc_quanta_lb9_porting.h b/packages/platforms/quanta/powerpc/lb9/onlp/builds/powerpc_quanta_lb9/module/inc/powerpc_quanta_lb9/powerpc_quanta_lb9_porting.h deleted file mode 100644 index 8fda00ac4..000000000 --- a/packages/platforms/quanta/powerpc/lb9/onlp/builds/powerpc_quanta_lb9/module/inc/powerpc_quanta_lb9/powerpc_quanta_lb9_porting.h +++ /dev/null @@ -1,77 +0,0 @@ -/**************************************************************************//** - * - * @file - * @brief powerpc_quanta_lb9 Porting Macros. - * - * @addtogroup powerpc_quanta_lb9-porting - * @{ - * - *****************************************************************************/ -#ifndef __POWERPC_QUANTA_LB9_R0_PORTING_H__ -#define __POWERPC_QUANTA_LB9_R0_PORTING_H__ - - -/* */ -#if POWERPC_QUANTA_LB9_R0_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS == 1 -#include -#include -#include -#include -#include -#endif - -#ifndef POWERPC_QUANTA_LB9_R0_MEMSET - #if defined(GLOBAL_MEMSET) - #define POWERPC_QUANTA_LB9_R0_MEMSET GLOBAL_MEMSET - #elif POWERPC_QUANTA_LB9_R0_CONFIG_PORTING_STDLIB == 1 - #define POWERPC_QUANTA_LB9_R0_MEMSET memset - #else - #error The macro POWERPC_QUANTA_LB9_R0_MEMSET is required but cannot be defined. - #endif -#endif - -#ifndef POWERPC_QUANTA_LB9_R0_MEMCPY - #if defined(GLOBAL_MEMCPY) - #define POWERPC_QUANTA_LB9_R0_MEMCPY GLOBAL_MEMCPY - #elif POWERPC_QUANTA_LB9_R0_CONFIG_PORTING_STDLIB == 1 - #define POWERPC_QUANTA_LB9_R0_MEMCPY memcpy - #else - #error The macro POWERPC_QUANTA_LB9_R0_MEMCPY is required but cannot be defined. - #endif -#endif - -#ifndef POWERPC_QUANTA_LB9_R0_VSNPRINTF - #if defined(GLOBAL_VSNPRINTF) - #define POWERPC_QUANTA_LB9_R0_VSNPRINTF GLOBAL_VSNPRINTF - #elif POWERPC_QUANTA_LB9_R0_CONFIG_PORTING_STDLIB == 1 - #define POWERPC_QUANTA_LB9_R0_VSNPRINTF vsnprintf - #else - #error The macro POWERPC_QUANTA_LB9_R0_VSNPRINTF is required but cannot be defined. - #endif -#endif - -#ifndef POWERPC_QUANTA_LB9_R0_SNPRINTF - #if defined(GLOBAL_SNPRINTF) - #define POWERPC_QUANTA_LB9_R0_SNPRINTF GLOBAL_SNPRINTF - #elif POWERPC_QUANTA_LB9_R0_CONFIG_PORTING_STDLIB == 1 - #define POWERPC_QUANTA_LB9_R0_SNPRINTF snprintf - #else - #error The macro POWERPC_QUANTA_LB9_R0_SNPRINTF is required but cannot be defined. - #endif -#endif - -#ifndef POWERPC_QUANTA_LB9_R0_STRLEN - #if defined(GLOBAL_STRLEN) - #define POWERPC_QUANTA_LB9_R0_STRLEN GLOBAL_STRLEN - #elif POWERPC_QUANTA_LB9_R0_CONFIG_PORTING_STDLIB == 1 - #define POWERPC_QUANTA_LB9_R0_STRLEN strlen - #else - #error The macro POWERPC_QUANTA_LB9_R0_STRLEN is required but cannot be defined. - #endif -#endif - -/* */ - - -#endif /* __POWERPC_QUANTA_LB9_R0_PORTING_H__ */ -/* @} */ diff --git a/packages/platforms/quanta/powerpc/lb9/onlp/builds/powerpc_quanta_lb9/module/make.mk b/packages/platforms/quanta/powerpc/lb9/onlp/builds/powerpc_quanta_lb9/module/make.mk deleted file mode 100644 index fdaec4d10..000000000 --- a/packages/platforms/quanta/powerpc/lb9/onlp/builds/powerpc_quanta_lb9/module/make.mk +++ /dev/null @@ -1,10 +0,0 @@ -############################################################################### -# -# -# -############################################################################### -THIS_DIR := $(dir $(lastword $(MAKEFILE_LIST))) -powerpc_quanta_lb9_INCLUDES := -I $(THIS_DIR)inc -powerpc_quanta_lb9_INTERNAL_INCLUDES := -I $(THIS_DIR)src -powerpc_quanta_lb9_DEPENDMODULE_ENTRIES := init:powerpc_quanta_lb9 ucli:powerpc_quanta_lb9 - diff --git a/packages/platforms/quanta/powerpc/lb9/onlp/builds/powerpc_quanta_lb9/module/src/Makefile b/packages/platforms/quanta/powerpc/lb9/onlp/builds/powerpc_quanta_lb9/module/src/Makefile deleted file mode 100644 index 4828822bc..000000000 --- a/packages/platforms/quanta/powerpc/lb9/onlp/builds/powerpc_quanta_lb9/module/src/Makefile +++ /dev/null @@ -1,9 +0,0 @@ -############################################################################### -# -# Local source generation targets. -# -############################################################################### - -ucli: - @../../../../tools/uclihandlers.py powerpc_quanta_lb9_ucli.c - diff --git a/packages/platforms/quanta/powerpc/lb9/onlp/builds/powerpc_quanta_lb9/module/src/fani.c b/packages/platforms/quanta/powerpc/lb9/onlp/builds/powerpc_quanta_lb9/module/src/fani.c deleted file mode 100644 index 6f87a7cb1..000000000 --- a/packages/platforms/quanta/powerpc/lb9/onlp/builds/powerpc_quanta_lb9/module/src/fani.c +++ /dev/null @@ -1,147 +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 "powerpc_quanta_lb9_int.h" -#include "powerpc_quanta_lb9_log.h" - -#include - -int -onlp_fani_init(void) -{ - return ONLP_STATUS_OK; -} - - -static int -sys_fan_info_get__(onlp_fan_info_t* info, int id) -{ - int rv; - const char* controller = powerpc_quanta_lb9_system_fan_dir(); - - if(controller == NULL) { - /* Error already reported. */ - return ONLP_STATUS_E_INTERNAL; - } - - rv = onlp_file_read_int(&info->rpm, - "%s*fan%d_input", controller, id); - - if(rv == ONLP_STATUS_E_INTERNAL) { - return rv; - } - - if(rv == ONLP_STATUS_E_MISSING) { - info->status &= ~1; - return 0; - } - - if(info->rpm <= POWERPC_QUANTA_LB9_R0_CONFIG_SYSFAN_RPM_FAILURE_THRESHOLD) { - info->status |= ONLP_FAN_STATUS_FAILED; - } - - /* - * Calculate percentage based on current speed and the maximum. - */ - info->caps |= ONLP_FAN_CAPS_GET_PERCENTAGE; - if(info->status & ONLP_FAN_STATUS_F2B) { - info->percentage = info->rpm * 100 / POWERPC_QUANTA_LB9_R0_CONFIG_SYSFAN_RPM_F2B_MAX; - } - if(info->status & ONLP_FAN_STATUS_B2F) { - info->percentage = info->rpm * 100 / POWERPC_QUANTA_LB9_R0_CONFIG_SYSFAN_RPM_B2F_MAX; - } - - return 0; -} - -static int -psu_fan_info_get__(onlp_fan_info_t* info, int id) -{ - /* FAN5 -> PSU1 */ - /* FAN6 -> PSU2 */ - const char* dir = powerpc_quanta_lb8_r9_system_psu_dir(id-4); - - if(dir == NULL) { - /* Error already reported */ - return ONLP_STATUS_E_INTERNAL; - } - - return onlp_file_read_int(&info->rpm, "%s*fan1_input", dir); -} - - - -/* Onboard Fans */ -static onlp_fan_info_t fans__[] = { - { }, /* Not used */ - { { FAN_OID_FAN1, "Right", 0}, ONLP_FAN_STATUS_PRESENT }, - { { FAN_OID_FAN2, "Center Right", 0}, ONLP_FAN_STATUS_PRESENT }, - { { FAN_OID_FAN3, "Center Left", 0}, ONLP_FAN_STATUS_PRESENT }, - { { FAN_OID_FAN4, "Left", 0}, ONLP_FAN_STATUS_PRESENT }, - { { FAN_OID_FAN5, "PSU-1 Fan", 0 }, ONLP_FAN_STATUS_PRESENT }, - { { FAN_OID_FAN6, "PSU-2 Fan", 0 }, ONLP_FAN_STATUS_PRESENT }, - -}; - -int -onlp_fani_info_get(onlp_oid_t id, onlp_fan_info_t* rv) -{ - *rv = fans__[ONLP_OID_ID_GET(id)]; - rv->caps |= ONLP_FAN_CAPS_GET_RPM; - - int direction = powerpc_quanta_lb9_system_airflow_get(); - int fid = ONLP_OID_ID_GET(id); - - if(direction == 0) { - rv->status |= ONLP_FAN_STATUS_F2B; - rv->caps |= ONLP_FAN_CAPS_F2B; - } - else { - rv->status |= ONLP_FAN_STATUS_B2F; - rv->caps |= ONLP_FAN_CAPS_B2F; - } - - - switch(fid) - { - case FAN_ID_FAN1: - case FAN_ID_FAN2: - case FAN_ID_FAN3: - case FAN_ID_FAN4: - { - return sys_fan_info_get__(rv, fid); - } - - case FAN_ID_FAN5: - case FAN_ID_FAN6: - { - return psu_fan_info_get__(rv, fid); - } - } - - return ONLP_STATUS_E_INVALID; -} diff --git a/packages/platforms/quanta/powerpc/lb9/onlp/builds/powerpc_quanta_lb9/module/src/make.mk b/packages/platforms/quanta/powerpc/lb9/onlp/builds/powerpc_quanta_lb9/module/src/make.mk deleted file mode 100644 index ebca96886..000000000 --- a/packages/platforms/quanta/powerpc/lb9/onlp/builds/powerpc_quanta_lb9/module/src/make.mk +++ /dev/null @@ -1,9 +0,0 @@ -############################################################################### -# -# -# -############################################################################### - -LIBRARY := powerpc_quanta_lb9 -$(LIBRARY)_SUBDIR := $(dir $(lastword $(MAKEFILE_LIST))) -include $(BUILDER)/lib.mk diff --git a/packages/platforms/quanta/powerpc/lb9/onlp/builds/powerpc_quanta_lb9/module/src/powerpc_quanta_lb9_config.c b/packages/platforms/quanta/powerpc/lb9/onlp/builds/powerpc_quanta_lb9/module/src/powerpc_quanta_lb9_config.c deleted file mode 100644 index 036385bee..000000000 --- a/packages/platforms/quanta/powerpc/lb9/onlp/builds/powerpc_quanta_lb9/module/src/powerpc_quanta_lb9_config.c +++ /dev/null @@ -1,96 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#include - -/* */ -#define __powerpc_quanta_lb9_config_STRINGIFY_NAME(_x) #_x -#define __powerpc_quanta_lb9_config_STRINGIFY_VALUE(_x) __powerpc_quanta_lb9_config_STRINGIFY_NAME(_x) -powerpc_quanta_lb9_config_settings_t powerpc_quanta_lb9_config_settings[] = -{ -#ifdef POWERPC_QUANTA_LB9_R0_CONFIG_INCLUDE_LOGGING - { __powerpc_quanta_lb9_config_STRINGIFY_NAME(POWERPC_QUANTA_LB9_R0_CONFIG_INCLUDE_LOGGING), __powerpc_quanta_lb9_config_STRINGIFY_VALUE(POWERPC_QUANTA_LB9_R0_CONFIG_INCLUDE_LOGGING) }, -#else -{ POWERPC_QUANTA_LB9_R0_CONFIG_INCLUDE_LOGGING(__powerpc_quanta_lb9_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef POWERPC_QUANTA_LB9_R0_CONFIG_LOG_OPTIONS_DEFAULT - { __powerpc_quanta_lb9_config_STRINGIFY_NAME(POWERPC_QUANTA_LB9_R0_CONFIG_LOG_OPTIONS_DEFAULT), __powerpc_quanta_lb9_config_STRINGIFY_VALUE(POWERPC_QUANTA_LB9_R0_CONFIG_LOG_OPTIONS_DEFAULT) }, -#else -{ POWERPC_QUANTA_LB9_R0_CONFIG_LOG_OPTIONS_DEFAULT(__powerpc_quanta_lb9_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef POWERPC_QUANTA_LB9_R0_CONFIG_LOG_BITS_DEFAULT - { __powerpc_quanta_lb9_config_STRINGIFY_NAME(POWERPC_QUANTA_LB9_R0_CONFIG_LOG_BITS_DEFAULT), __powerpc_quanta_lb9_config_STRINGIFY_VALUE(POWERPC_QUANTA_LB9_R0_CONFIG_LOG_BITS_DEFAULT) }, -#else -{ POWERPC_QUANTA_LB9_R0_CONFIG_LOG_BITS_DEFAULT(__powerpc_quanta_lb9_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef POWERPC_QUANTA_LB9_R0_CONFIG_LOG_CUSTOM_BITS_DEFAULT - { __powerpc_quanta_lb9_config_STRINGIFY_NAME(POWERPC_QUANTA_LB9_R0_CONFIG_LOG_CUSTOM_BITS_DEFAULT), __powerpc_quanta_lb9_config_STRINGIFY_VALUE(POWERPC_QUANTA_LB9_R0_CONFIG_LOG_CUSTOM_BITS_DEFAULT) }, -#else -{ POWERPC_QUANTA_LB9_R0_CONFIG_LOG_CUSTOM_BITS_DEFAULT(__powerpc_quanta_lb9_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef POWERPC_QUANTA_LB9_R0_CONFIG_PORTING_STDLIB - { __powerpc_quanta_lb9_config_STRINGIFY_NAME(POWERPC_QUANTA_LB9_R0_CONFIG_PORTING_STDLIB), __powerpc_quanta_lb9_config_STRINGIFY_VALUE(POWERPC_QUANTA_LB9_R0_CONFIG_PORTING_STDLIB) }, -#else -{ POWERPC_QUANTA_LB9_R0_CONFIG_PORTING_STDLIB(__powerpc_quanta_lb9_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef POWERPC_QUANTA_LB9_R0_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS - { __powerpc_quanta_lb9_config_STRINGIFY_NAME(POWERPC_QUANTA_LB9_R0_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS), __powerpc_quanta_lb9_config_STRINGIFY_VALUE(POWERPC_QUANTA_LB9_R0_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS) }, -#else -{ POWERPC_QUANTA_LB9_R0_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS(__powerpc_quanta_lb9_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef POWERPC_QUANTA_LB9_R0_CONFIG_INCLUDE_UCLI - { __powerpc_quanta_lb9_config_STRINGIFY_NAME(POWERPC_QUANTA_LB9_R0_CONFIG_INCLUDE_UCLI), __powerpc_quanta_lb9_config_STRINGIFY_VALUE(POWERPC_QUANTA_LB9_R0_CONFIG_INCLUDE_UCLI) }, -#else -{ POWERPC_QUANTA_LB9_R0_CONFIG_INCLUDE_UCLI(__powerpc_quanta_lb9_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef POWERPC_QUANTA_LB9_R0_CONFIG_SYSFAN_RPM_FAILURE_THRESHOLD - { __powerpc_quanta_lb9_config_STRINGIFY_NAME(POWERPC_QUANTA_LB9_R0_CONFIG_SYSFAN_RPM_FAILURE_THRESHOLD), __powerpc_quanta_lb9_config_STRINGIFY_VALUE(POWERPC_QUANTA_LB9_R0_CONFIG_SYSFAN_RPM_FAILURE_THRESHOLD) }, -#else -{ POWERPC_QUANTA_LB9_R0_CONFIG_SYSFAN_RPM_FAILURE_THRESHOLD(__powerpc_quanta_lb9_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef POWERPC_QUANTA_LB9_R0_CONFIG_SYSFAN_RPM_F2B_MAX - { __powerpc_quanta_lb9_config_STRINGIFY_NAME(POWERPC_QUANTA_LB9_R0_CONFIG_SYSFAN_RPM_F2B_MAX), __powerpc_quanta_lb9_config_STRINGIFY_VALUE(POWERPC_QUANTA_LB9_R0_CONFIG_SYSFAN_RPM_F2B_MAX) }, -#else -{ POWERPC_QUANTA_LB9_R0_CONFIG_SYSFAN_RPM_F2B_MAX(__powerpc_quanta_lb9_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef POWERPC_QUANTA_LB9_R0_CONFIG_SYSFAN_RPM_B2F_MAX - { __powerpc_quanta_lb9_config_STRINGIFY_NAME(POWERPC_QUANTA_LB9_R0_CONFIG_SYSFAN_RPM_B2F_MAX), __powerpc_quanta_lb9_config_STRINGIFY_VALUE(POWERPC_QUANTA_LB9_R0_CONFIG_SYSFAN_RPM_B2F_MAX) }, -#else -{ POWERPC_QUANTA_LB9_R0_CONFIG_SYSFAN_RPM_B2F_MAX(__powerpc_quanta_lb9_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef POWERPC_QUANTA_LB9_R0_CONFIG_PHY_RESET_DELAY_MS - { __powerpc_quanta_lb9_config_STRINGIFY_NAME(POWERPC_QUANTA_LB9_R0_CONFIG_PHY_RESET_DELAY_MS), __powerpc_quanta_lb9_config_STRINGIFY_VALUE(POWERPC_QUANTA_LB9_R0_CONFIG_PHY_RESET_DELAY_MS) }, -#else -{ POWERPC_QUANTA_LB9_R0_CONFIG_PHY_RESET_DELAY_MS(__powerpc_quanta_lb9_config_STRINGIFY_NAME), "__undefined__" }, -#endif - { NULL, NULL } -}; -#undef __powerpc_quanta_lb9_config_STRINGIFY_VALUE -#undef __powerpc_quanta_lb9_config_STRINGIFY_NAME - -const char* -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)) { - return powerpc_quanta_lb9_config_settings[i].value; - } - } - return NULL; -} - -int -powerpc_quanta_lb9_config_show(struct aim_pvs_s* pvs) -{ - int i; - for(i = 0; powerpc_quanta_lb9_config_settings[i].name; i++) { - aim_printf(pvs, "%s = %s\n", powerpc_quanta_lb9_config_settings[i].name, powerpc_quanta_lb9_config_settings[i].value); - } - return i; -} - -/* */ - diff --git a/packages/platforms/quanta/powerpc/lb9/onlp/builds/powerpc_quanta_lb9/module/src/powerpc_quanta_lb9_enums.c b/packages/platforms/quanta/powerpc/lb9/onlp/builds/powerpc_quanta_lb9/module/src/powerpc_quanta_lb9_enums.c deleted file mode 100644 index 9c47efac8..000000000 --- a/packages/platforms/quanta/powerpc/lb9/onlp/builds/powerpc_quanta_lb9/module/src/powerpc_quanta_lb9_enums.c +++ /dev/null @@ -1,10 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#include - -/* <--auto.start.enum(ALL).source> */ -/* */ - diff --git a/packages/platforms/quanta/powerpc/lb9/onlp/builds/powerpc_quanta_lb9/module/src/powerpc_quanta_lb9_int.h b/packages/platforms/quanta/powerpc/lb9/onlp/builds/powerpc_quanta_lb9/module/src/powerpc_quanta_lb9_int.h deleted file mode 100644 index 5683b631a..000000000 --- a/packages/platforms/quanta/powerpc/lb9/onlp/builds/powerpc_quanta_lb9/module/src/powerpc_quanta_lb9_int.h +++ /dev/null @@ -1,234 +0,0 @@ -/**************************************************************************//** - * - * powerpc_quanta_lb9 Internal Header - * - *****************************************************************************/ -#ifndef __POWERPC_QUANTA_LB9_R0_INT_H__ -#define __POWERPC_QUANTA_LB9_R0_INT_H__ - -#include -#include - - -/* */ -/** 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* 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[]; - -/** 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 { - 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_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_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* 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[]; -/* */ - - - -/* - * The LB9 has reverible airflow. - * There is a different controller for each direction. - * These are mutually exclusive at any given time. - */ - -/* This is the fan controller in F2B mode */ -#define SYS_CONTROLLER_PREFIX_F2B \ - "/sys/bus/i2c/devices/5-002c" - -/* This is the fan controller in B2F mode */ -#define SYS_CONTROLLER_PREFIX_B2F \ - "/sys/bus/i2c/devices/6-002f" - -/* The temperature controller for both modes */ -#define SYS_CONTROLLER_PREFIX_TEMPERATURE SYS_CONTROLLER_PREFIX_F2B - -/* - * PSU1 and PSU2 sys paths - */ -#define SYS_PSU1_PREFIX \ - "/sys/bus/i2c/devices/7-0058" - -#define SYS_PSU2_PREFIX \ - "/sys/bus/i2c/devices/8-0059" - - -#include "system.h" - -#endif /* __POWERPC_QUANTA_LB9_R0_INT_H__ */ diff --git a/packages/platforms/quanta/powerpc/lb9/onlp/builds/powerpc_quanta_lb9/module/src/powerpc_quanta_lb9_log.c b/packages/platforms/quanta/powerpc/lb9/onlp/builds/powerpc_quanta_lb9/module/src/powerpc_quanta_lb9_log.c deleted file mode 100644 index 8b237c613..000000000 --- a/packages/platforms/quanta/powerpc/lb9/onlp/builds/powerpc_quanta_lb9/module/src/powerpc_quanta_lb9_log.c +++ /dev/null @@ -1,18 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#include - -#include "powerpc_quanta_lb9_log.h" -/* - * powerpc_quanta_lb9 log struct. - */ -AIM_LOG_STRUCT_DEFINE( - POWERPC_QUANTA_LB9_R0_CONFIG_LOG_OPTIONS_DEFAULT, - POWERPC_QUANTA_LB9_R0_CONFIG_LOG_BITS_DEFAULT, - NULL, /* Custom log map */ - POWERPC_QUANTA_LB9_R0_CONFIG_LOG_CUSTOM_BITS_DEFAULT - ); - diff --git a/packages/platforms/quanta/powerpc/lb9/onlp/builds/powerpc_quanta_lb9/module/src/powerpc_quanta_lb9_log.h b/packages/platforms/quanta/powerpc/lb9/onlp/builds/powerpc_quanta_lb9/module/src/powerpc_quanta_lb9_log.h deleted file mode 100644 index fbd7af8ee..000000000 --- a/packages/platforms/quanta/powerpc/lb9/onlp/builds/powerpc_quanta_lb9/module/src/powerpc_quanta_lb9_log.h +++ /dev/null @@ -1,12 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#ifndef __POWERPC_QUANTA_LB9_R0_LOG_H__ -#define __POWERPC_QUANTA_LB9_R0_LOG_H__ - -#define AIM_LOG_MODULE_NAME powerpc_quanta_lb9 -#include - -#endif /* __POWERPC_QUANTA_LB9_R0_LOG_H__ */ diff --git a/packages/platforms/quanta/powerpc/lb9/onlp/builds/powerpc_quanta_lb9/module/src/powerpc_quanta_lb9_module.c b/packages/platforms/quanta/powerpc/lb9/onlp/builds/powerpc_quanta_lb9/module/src/powerpc_quanta_lb9_module.c deleted file mode 100644 index 66a62ad99..000000000 --- a/packages/platforms/quanta/powerpc/lb9/onlp/builds/powerpc_quanta_lb9/module/src/powerpc_quanta_lb9_module.c +++ /dev/null @@ -1,24 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#include - -#include "powerpc_quanta_lb9_log.h" - -static int -datatypes_init__(void) -{ -#define POWERPC_QUANTA_LB9_R0_ENUMERATION_ENTRY(_enum_name, _desc) AIM_DATATYPE_MAP_REGISTER(_enum_name, _enum_name##_map, _desc, AIM_LOG_INTERNAL); -#include - return 0; -} - -void __powerpc_quanta_lb9_module_init__(void) -{ - AIM_LOG_STRUCT_REGISTER(); - datatypes_init__(); -} - -int __onlp_platform_version__ = 1; diff --git a/packages/platforms/quanta/powerpc/lb9/onlp/builds/powerpc_quanta_lb9/module/src/powerpc_quanta_lb9_ucli.c b/packages/platforms/quanta/powerpc/lb9/onlp/builds/powerpc_quanta_lb9/module/src/powerpc_quanta_lb9_ucli.c deleted file mode 100644 index 20e77149c..000000000 --- a/packages/platforms/quanta/powerpc/lb9/onlp/builds/powerpc_quanta_lb9/module/src/powerpc_quanta_lb9_ucli.c +++ /dev/null @@ -1,50 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#include - -#if POWERPC_QUANTA_LB9_R0_CONFIG_INCLUDE_UCLI == 1 - -#include -#include -#include - -static ucli_status_t -powerpc_quanta_lb9_ucli_ucli__config__(ucli_context_t* uc) -{ - UCLI_HANDLER_MACRO_MODULE_CONFIG(powerpc_quanta_lb9) -} - -/* */ -/* */ - -static ucli_module_t -powerpc_quanta_lb9_ucli_module__ = - { - "powerpc_quanta_lb9_ucli", - NULL, - powerpc_quanta_lb9_ucli_ucli_handlers__, - NULL, - NULL, - }; - -ucli_node_t* -powerpc_quanta_lb9_ucli_node_create(void) -{ - ucli_node_t* n; - ucli_module_init(&powerpc_quanta_lb9_ucli_module__); - n = ucli_node_create("powerpc_quanta_lb9", NULL, &powerpc_quanta_lb9_ucli_module__); - ucli_node_subnode_add(n, ucli_module_log_node_create("powerpc_quanta_lb9")); - return n; -} - -#else -void* -powerpc_quanta_lb9_ucli_node_create(void) -{ - return NULL; -} -#endif - diff --git a/packages/platforms/quanta/powerpc/lb9/onlp/builds/powerpc_quanta_lb9/module/src/psui.c b/packages/platforms/quanta/powerpc/lb9/onlp/builds/powerpc_quanta_lb9/module/src/psui.c deleted file mode 100644 index 04b1789ec..000000000 --- a/packages/platforms/quanta/powerpc/lb9/onlp/builds/powerpc_quanta_lb9/module/src/psui.c +++ /dev/null @@ -1,104 +0,0 @@ -/************************************************************ - * - * - ************************************************************ - * - * - * - ***********************************************************/ -#include -#include -#include -#include "powerpc_quanta_lb9_int.h" -#include "powerpc_quanta_lb9_log.h" - -int -onlp_psui_init(void) -{ - return 0; -} - -static onlp_psu_info_t psus__[] = { - { }, /* Not used */ - { - { - PSU_OID_PSU1, - "PSU-1", - 0, - { - FAN_OID_FAN5, - THERMAL_OID_THERMAL6, - THERMAL_OID_THERMAL7, - THERMAL_OID_THERMAL8, - }, - } - }, - { - { - PSU_OID_PSU2, - "PSU-2", - 0, - { - FAN_OID_FAN6, - THERMAL_OID_THERMAL9, - THERMAL_OID_THERMAL10, - THERMAL_OID_THERMAL11, - }, - } - }, -}; - - -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 = powerpc_quanta_lb8_r9_system_psu_dir(pid); - - /* - * Todo -- use the GPIO to determine PSU presence. - * For this first version we'll approximate the status using - * the input voltage sensor. - */ - rv = onlp_file_read_int(&info->mvin, "%s*in1_input", dir); - if(rv == ONLP_STATUS_E_MISSING || info->mvin == 0) { - info->status &= ~1; - return 0; - } - else if(rv < 0) { - return rv; - } - else { - info->caps |= ONLP_PSU_CAPS_VIN; - } - - /* PSU is present and powered. */ - info->status |= 1; - strcpy(info->model, "PSU-LB9"); - info->caps |= ONLP_PSU_CAPS_AC; - - if(onlp_file_read_int(&info->miin, "%s*curr1_input", dir) == 0) { - info->caps |= ONLP_PSU_CAPS_IIN; - } - if(onlp_file_read_int(&info->miout, "%s*curr2_input", dir) == 0) { - info->caps |= ONLP_PSU_CAPS_IOUT; - } - if(onlp_file_read_int(&info->mvout, "%s*in2_input", dir) == 0) { - info->caps |= ONLP_PSU_CAPS_VOUT; - /* Empirical */ - info->mvout /= 500; - } - if(onlp_file_read_int(&info->mpin, "%s*power1_input", dir) == 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->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/powerpc/lb9/onlp/builds/powerpc_quanta_lb9/module/src/sfpi.c b/packages/platforms/quanta/powerpc/lb9/onlp/builds/powerpc_quanta_lb9/module/src/sfpi.c deleted file mode 100644 index aa2778024..000000000 --- a/packages/platforms/quanta/powerpc/lb9/onlp/builds/powerpc_quanta_lb9/module/src/sfpi.c +++ /dev/null @@ -1,151 +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. - * - * - ************************************************************ - * - * SFPI Interface for the Quanta LB9 - * - * This code was lifted wholesale and minimally ported - * from the previous implementation that preceded the ONLP interfaces. - * - * It should be ported in the future to use the services provided - * by the ONLP infrastructure directly. - * - ***********************************************************/ -#include -#include -#include -#include -#include "powerpc_quanta_lb9_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 sport; - int mod_abs_gpio_number; - int reset_gpio_number; - const char* mod_abs_gpio; - const char* reset_gpio; - const char* eeprom; - const char* dom; -} sfpmap_t; - -static sfpmap_t sfpmap__[] = - { - { - 48, - 112, 120, - "/sys/class/gpio/gpio112/value", - "/sys/class/gpio/gpio120/value", - "/sys/devices/e0000000.soc8541/e0003000.i2c/i2c-0/i2c-1/1-0050/eeprom", - "/sys/devices/e0000000.soc8541/e0003000.i2c/i2c-0/i2c-1/1-0051/eeprom" - }, - { - 49, - 113, 121, - "/sys/class/gpio/gpio113/value", - "/sys/class/gpio/gpio121/value", - "/sys/devices/e0000000.soc8541/e0003000.i2c/i2c-0/i2c-2/2-0050/eeprom", - "/sys/devices/e0000000.soc8541/e0003000.i2c/i2c-0/i2c-2/2-0051/eeprom" - }, - { - 50, - 114, 122, - "/sys/class/gpio/gpio114/value", - "/sys/class/gpio/gpio122/value", - "/sys/devices/e0000000.soc8541/e0003000.i2c/i2c-0/i2c-3/3-0050/eeprom", - "/sys/devices/e0000000.soc8541/e0003000.i2c/i2c-0/i2c-3/3-0051/eeprom" - }, - { - 51, - 115, 123, - "/sys/class/gpio/gpio115/value", - "/sys/class/gpio/gpio123/value", - "/sys/devices/e0000000.soc8541/e0003000.i2c/i2c-0/i2c-4/4-0050/eeprom", - "/sys/devices/e0000000.soc8541/e0003000.i2c/i2c-0/i2c-4/4-0051/eeprom" - }, - }; - -#define SFP_GET(_port) (sfpmap__+ (_port - 48)) - -int -onlp_sfpi_init(void) -{ - /** - * Initialize the SFP presence and reset GPIOS. - */ - int i; - int rv; - for(i = 0; i < AIM_ARRAYSIZE(sfpmap__); i++) { - if( (rv = onlp_gpio_export(sfpmap__[i].mod_abs_gpio_number, ONLP_GPIO_DIRECTION_IN)) < 0) { - AIM_LOG_ERROR("Failed to initialize MOD_ABS gpio %d", - sfpmap__[i].mod_abs_gpio_number); - return -1; - } - if( (rv = onlp_gpio_export(sfpmap__[i].reset_gpio_number, ONLP_GPIO_DIRECTION_HIGH)) < 0) { - AIM_LOG_ERROR("Failed to initialize RESET gpio %d", - sfpmap__[i].reset_gpio_number); - return -1; - } - } - - return ONLP_STATUS_OK; -} - -int -onlp_sfpi_bitmap_get(onlp_sfp_bitmap_t* bmap) -{ - int p; - - for(p = 48; p < 52; p++) { - AIM_BITMAP_SET(bmap, p); - } - return ONLP_STATUS_OK; -} - -int -onlp_sfpi_is_present(int port) -{ - sfpmap_t* sfp = SFP_GET(port); - - return onlplib_sfp_is_present_file(sfp->mod_abs_gpio, - /* Present */ "0\n", - /* Absent */ "1\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); -} diff --git a/packages/platforms/quanta/powerpc/lb9/onlp/builds/powerpc_quanta_lb9/module/src/sysi.c b/packages/platforms/quanta/powerpc/lb9/onlp/builds/powerpc_quanta_lb9/module/src/sysi.c deleted file mode 100644 index d7ffa8ddb..000000000 --- a/packages/platforms/quanta/powerpc/lb9/onlp/builds/powerpc_quanta_lb9/module/src/sysi.c +++ /dev/null @@ -1,76 +0,0 @@ -/************************************************************ - * - * - ************************************************************ - * - * - * - ***********************************************************/ -#include -#include "powerpc_quanta_lb9_int.h" -#include "powerpc_quanta_lb9_log.h" -#include - -const char* -onlp_sysi_platform_get(void) -{ - return "powerpc-quanta-lb9-r0"; -} - -int -onlp_sysi_init(void) -{ - return ONLP_STATUS_OK; -} - -#define QUANTA_SYS_EEPROM_PATH \ -"/sys/devices/e0000000.soc8541/e0003000.i2c/i2c-0/0-0053/eeprom" - - -int -onlp_sysi_onie_info_get(onlp_onie_info_t* onie) -{ - int rv; - quanta_sys_eeprom_t e; - rv = quanta_sys_eeprom_parse_file(QUANTA_SYS_EEPROM_PATH, &e); - if(rv >= 0) { - quanta_sys_eeprom_to_onie(&e, onie); - onie->platform_name = aim_strdup("powerpc-quanta-lb9"); - } - 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)); - - /* - * 5 Chassis Thermal Sensors - */ - *e++ = THERMAL_OID_THERMAL1; - *e++ = THERMAL_OID_THERMAL2; - *e++ = THERMAL_OID_THERMAL3; - *e++ = THERMAL_OID_THERMAL4; - *e++ = THERMAL_OID_THERMAL5; - - /* - * 4 Fans - */ - *e++ = FAN_OID_FAN1; - *e++ = FAN_OID_FAN2; - *e++ = FAN_OID_FAN3; - *e++ = FAN_OID_FAN4; - - /* - * 2 PSUs - */ - *e++ = PSU_OID_PSU1; - *e++ = PSU_OID_PSU2; - - /* - * Todo - LEDs - */ - return 0; -} diff --git a/packages/platforms/quanta/powerpc/lb9/onlp/builds/powerpc_quanta_lb9/module/src/system.c b/packages/platforms/quanta/powerpc/lb9/onlp/builds/powerpc_quanta_lb9/module/src/system.c deleted file mode 100644 index e68fd1eaa..000000000 --- a/packages/platforms/quanta/powerpc/lb9/onlp/builds/powerpc_quanta_lb9/module/src/system.c +++ /dev/null @@ -1,75 +0,0 @@ -/************************************************************ - * - * - ************************************************************ - * - * - * - ***********************************************************/ -#include -#include -#include "powerpc_quanta_lb9_int.h" -#include "powerpc_quanta_lb9_log.h" -#include "system.h" - -int -powerpc_quanta_lb9_system_airflow_get(void) -{ - int i; - int f2b = 0; - int b2f = 0; - - for(i = 1; i < 5; i++) { - int rpm = 0; - onlp_file_read_int(&rpm, SYS_CONTROLLER_PREFIX_F2B "*fan%d_input", i); - f2b += rpm; - } - for(i = 1; i < 5; i++) { - int rpm = 0; - onlp_file_read_int(&rpm, SYS_CONTROLLER_PREFIX_B2F "*fan%d_input", i); - b2f += rpm; - } - - if(f2b && !b2f) { - return 0; - } - else if(b2f && !f2b) { - return 1; - } - else { - AIM_LOG_ERROR("Cannot determine active airflow controller."); - return -1; - } - return 0; -} - -char* -powerpc_quanta_lb9_system_fan_dir(void) -{ - /* - * Determine the correct HW monitor path based on - * current system settings. - */ - int airflow = powerpc_quanta_lb9_system_airflow_get(); - switch(airflow) - { - case 0: return SYS_CONTROLLER_PREFIX_F2B; break; - case 1: return SYS_CONTROLLER_PREFIX_B2F; break; - } - - /* Error message has already been reported. */ - return NULL; -} - -char* -powerpc_quanta_lb8_r9_system_psu_dir(int pid) -{ - switch(pid) - { - case PSU_ID_PSU1: return SYS_PSU1_PREFIX; break; - case PSU_ID_PSU2: return SYS_PSU2_PREFIX; break; - } - - AIM_LOG_ERROR("Invalid PSU id %d", pid); - return NULL; -} diff --git a/packages/platforms/quanta/powerpc/lb9/onlp/builds/powerpc_quanta_lb9/module/src/system.h b/packages/platforms/quanta/powerpc/lb9/onlp/builds/powerpc_quanta_lb9/module/src/system.h deleted file mode 100644 index e581bebf5..000000000 --- a/packages/platforms/quanta/powerpc/lb9/onlp/builds/powerpc_quanta_lb9/module/src/system.h +++ /dev/null @@ -1,18 +0,0 @@ -/************************************************************ - * - * - ************************************************************ - * - * - * - ***********************************************************/ -#ifndef __POWERPC_QUANTA_LB9_R0_SYSTEM_H__ -#define __POWERPC_QUANTA_LB9_R0_SYSTEM_H__ - -int powerpc_quanta_lb9_system_airflow_get(void); - -char* powerpc_quanta_lb9_system_fan_dir(void); - -char* powerpc_quanta_lb8_r9_system_psu_dir(int pid); - -#endif /* __POWERPC_QUANTA_LB9_R0_SYSTEM_H__ */ diff --git a/packages/platforms/quanta/powerpc/lb9/onlp/builds/powerpc_quanta_lb9/module/src/thermali.c b/packages/platforms/quanta/powerpc/lb9/onlp/builds/powerpc_quanta_lb9/module/src/thermali.c deleted file mode 100644 index d0934b1fb..000000000 --- a/packages/platforms/quanta/powerpc/lb9/onlp/builds/powerpc_quanta_lb9/module/src/thermali.c +++ /dev/null @@ -1,126 +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 "powerpc_quanta_lb9_int.h" -#include "powerpc_quanta_lb9_log.h" - -int -onlp_thermali_init(void) -{ - return ONLP_STATUS_OK; -} - -static int -sys_thermal_info_get__(onlp_thermal_info_t* info, int id) -{ - int rv; - - /* Fixed for both F2B and B2F configurations */ - const char* controller = SYS_CONTROLLER_PREFIX_TEMPERATURE; - - rv = onlp_file_read_int(&info->mcelsius, - "%s*temp%d_input", controller, id); - - if(rv == ONLP_STATUS_E_INTERNAL) { - return rv; - } - - if(rv == ONLP_STATUS_E_MISSING) { - info->status &= ~1; - return 0; - } - - return ONLP_STATUS_OK; -} - -static int -psu_thermal_info_get__(onlp_thermal_info_t* info, int pid, int id) -{ - /* THERMAL6 -> PSU1 */ - /* THERMAL7 -> PSU2 */ - char* dir = powerpc_quanta_lb8_r9_system_psu_dir(pid); - info->status |= 1; - return onlp_file_read_int(&info->mcelsius, "%s*temp%d_input", dir, id); -} - -int -onlp_thermali_info_get(onlp_oid_t id, onlp_thermal_info_t* rv) -{ - int tid = ONLP_OID_ID_GET(id); - - static onlp_thermal_info_t info[] = { - { }, /* Not used */ - { { ONLP_THERMAL_ID_CREATE(1), "Chassis Thermal 1", 0}, ONLP_THERMAL_STATUS_PRESENT, - ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS - }, - { { ONLP_THERMAL_ID_CREATE(2), "Chassis Thermal 2", 0}, ONLP_THERMAL_STATUS_PRESENT, - ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS - }, - { { ONLP_THERMAL_ID_CREATE(3), "Chassis Thermal 3", 0}, ONLP_THERMAL_STATUS_PRESENT, - ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS - }, - { { ONLP_THERMAL_ID_CREATE(4), "Chassis Thermal 4", 0}, ONLP_THERMAL_STATUS_PRESENT, - ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS - }, - { { ONLP_THERMAL_ID_CREATE(5), "Chassis Thermal 5", 0}, ONLP_THERMAL_STATUS_PRESENT, - ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS - }, - { { ONLP_THERMAL_ID_CREATE(6), "PSU-1 Thermal 1", 0 } }, - { { ONLP_THERMAL_ID_CREATE(7), "PSU-1 Thermal 2", 0 } }, - { { ONLP_THERMAL_ID_CREATE(8), "PSU-1 Thermal 3", 0 } }, - - { { ONLP_THERMAL_ID_CREATE(9), "PSU-2 Thermal 1", 0 } }, - { { ONLP_THERMAL_ID_CREATE(10), "PSU-2 Thermal 2", 0 } }, - { { ONLP_THERMAL_ID_CREATE(11), "PSU-2 Thermal 3", 0 } }, - }; - - *rv = info[tid]; - rv->caps |= ONLP_THERMAL_CAPS_GET_TEMPERATURE; - - switch(tid) - { - case THERMAL_ID_THERMAL1: - case THERMAL_ID_THERMAL2: - case THERMAL_ID_THERMAL3: - case THERMAL_ID_THERMAL4: - case THERMAL_ID_THERMAL5: - return sys_thermal_info_get__(rv, tid); - - case THERMAL_ID_THERMAL6: - case THERMAL_ID_THERMAL7: - case THERMAL_ID_THERMAL8: - return psu_thermal_info_get__(rv, 1, tid-5); - - - case THERMAL_ID_THERMAL9: - case THERMAL_ID_THERMAL10: - case THERMAL_ID_THERMAL11: - return psu_thermal_info_get__(rv, 2, tid-8); - - } - - return ONLP_STATUS_E_INVALID; -} diff --git a/packages/platforms/quanta/powerpc/lb9/platform-config/Makefile b/packages/platforms/quanta/powerpc/lb9/platform-config/Makefile deleted file mode 100644 index 003238cf6..000000000 --- a/packages/platforms/quanta/powerpc/lb9/platform-config/Makefile +++ /dev/null @@ -1 +0,0 @@ -include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/quanta/powerpc/lb9/platform-config/r0/Makefile b/packages/platforms/quanta/powerpc/lb9/platform-config/r0/Makefile deleted file mode 100644 index 003238cf6..000000000 --- a/packages/platforms/quanta/powerpc/lb9/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/quanta/powerpc/lb9/platform-config/r0/PKG.yml b/packages/platforms/quanta/powerpc/lb9/platform-config/r0/PKG.yml deleted file mode 100644 index 58d595059..000000000 --- a/packages/platforms/quanta/powerpc/lb9/platform-config/r0/PKG.yml +++ /dev/null @@ -1 +0,0 @@ -!include $ONL_TEMPLATES/platform-config-platform.yml ARCH=powerpc VENDOR=quanta BASENAME=powerpc-quanta-lb9 REVISION=r0 diff --git a/packages/platforms/quanta/powerpc/lb9/platform-config/r0/builds/Makefile b/packages/platforms/quanta/powerpc/lb9/platform-config/r0/builds/Makefile deleted file mode 100644 index f57d62485..000000000 --- a/packages/platforms/quanta/powerpc/lb9/platform-config/r0/builds/Makefile +++ /dev/null @@ -1 +0,0 @@ -include $(ONL)/make/subdirs.mk diff --git a/packages/platforms/quanta/powerpc/lb9/platform-config/r0/builds/dtb/.gitignore b/packages/platforms/quanta/powerpc/lb9/platform-config/r0/builds/dtb/.gitignore deleted file mode 100644 index b60ed208c..000000000 --- a/packages/platforms/quanta/powerpc/lb9/platform-config/r0/builds/dtb/.gitignore +++ /dev/null @@ -1 +0,0 @@ -*.dtb diff --git a/packages/platforms/quanta/powerpc/lb9/platform-config/r0/builds/dtb/Makefile b/packages/platforms/quanta/powerpc/lb9/platform-config/r0/builds/dtb/Makefile deleted file mode 100644 index 8b9493a2c..000000000 --- a/packages/platforms/quanta/powerpc/lb9/platform-config/r0/builds/dtb/Makefile +++ /dev/null @@ -1 +0,0 @@ -include $(ONL)/make/dtbs.mk diff --git a/packages/platforms/quanta/powerpc/lb9/platform-config/r0/builds/dtb/powerpc-quanta-lb9-r0.dts b/packages/platforms/quanta/powerpc/lb9/platform-config/r0/builds/dtb/powerpc-quanta-lb9-r0.dts deleted file mode 100644 index b9b549cf1..000000000 --- a/packages/platforms/quanta/powerpc/lb9/platform-config/r0/builds/dtb/powerpc-quanta-lb9-r0.dts +++ /dev/null @@ -1,480 +0,0 @@ -/* - * - * - * Copyright 2013, 2014 BigSwitch Networks, Inc. - * - * This program is free software; you can redistribute it - * and/or modify it under the terms ofthe GNU General Public License as - * published by the Free Software Foundation; either version 2 of the License, - * or (at your option) any later version. - * - * - * - * - * - * Device tree for the Quanta LB9 - * - */ - - -/dts-v1/; - -/ { - model = "powerpc-quanta-lb9-r0"; - compatible = "quanta-lb"; - #address-cells = <1>; - #size-cells = <1>; - - aliases { - ethernet0 = &enet0; - serial0 = &serial0; - pci0 = &pci0; - }; - - cpus { - #address-cells = <1>; - #size-cells = <0>; - - PowerPC,8541@0 { - device_type = "cpu"; - reg = <0x0>; - d-cache-line-size = <32>; // 32 bytes - i-cache-line-size = <32>; // 32 bytes - d-cache-size = <0x8000>; // L1, 32K - i-cache-size = <0x8000>; // L1, 32K - timebase-frequency = <0>; // 33 MHz - bus-frequency = <0>; // 166 MHz - clock-frequency = <0>; // 825 MHz - next-level-cache = <&L2>; - }; - }; - - memory { - device_type = "memory"; - reg = <0x0 0x20000000>; // 512M at 0x0 - }; - - soc8541@e0000000 { - #address-cells = <1>; - #size-cells = <1>; - device_type = "soc"; - compatible = "simple-bus"; - ranges = <0x0 0xe0000000 0x100000>; - reg = <0xe0000000 0x1000>; // CCSRBAR 1M - bus-frequency = <0>; - - ecm-law@0 { - compatible = "fsl,ecm-law"; - reg = <0x0 0x1000>; - fsl,num-laws = <8>; - }; - - ecm@1000 { - compatible = "fsl,mpc8541-ecm", "fsl,ecm"; - reg = <0x1000 0x1000>; - interrupts = <17 2>; - interrupt-parent = <&mpic>; - }; - - memory-controller@2000 { - compatible = "fsl,8541-memory-controller"; - reg = <0x2000 0x1000>; - interrupt-parent = <&mpic>; - interrupts = <18 2>; - }; - - L2: l2-cache-controller@20000 { - compatible = "fsl,8541-l2-cache-controller"; - reg = <0x20000 0x1000>; - cache-line-size = <32>; // 32 bytes - cache-size = <0x40000>; // L2, 256K - interrupt-parent = <&mpic>; - interrupts = <16 2>; - }; - - i2c@3000 { - #address-cells = <1>; - #size-cells = <0>; - cell-index = <0>; - compatible = "fsl-i2c"; - reg = <0x3000 0x100>; - interrupts = <43 2>; - interrupt-parent = <&mpic>; - dfsrr; - - gpio-phy@20 { - compatible = "nxp,pca9555"; - reg = <0x20>; - #gpio-cells = <2>; - gpio-controller; - }; - - gpio-psu-1@24 { - compatible = "nxp,pca9555"; - reg = <0x24>; - #gpio-cells = <2>; - gpio-controller; - }; - - gpio-psu-2@25 { - compatible = "nxp,pca9555"; - reg = <0x25>; - #gpio-cells = <2>; - gpio-controller; - }; - - eeprom-mb@53 { - compatible = "at,24c02"; - reg = <0x53>; - read-only; - }; - - dimm@57 { - compatible = "at,spd"; - reg = <0x57>; - read-only; - }; - - rtc@68 { - compatible = "dallas,ds1338"; - reg = <0x68>; - }; - - mux@70 { - compatible = "nxp,pca9548"; - reg = <0x70>; - #address-cells = <1>; - #size-cells = <0>; - - i2c@0 { - #address-cells = <1>; - #size-cells = <0>; - reg = <0>; - - eeprom-sfp-1@50 { - compatible = "at,24c02"; - reg = <0x50>; - read-only; - }; - eeprom-sfp-1@51 { - compatible = "at,24c02"; - reg = <0x51>; - read-only; - }; - }; - - i2c@1 { - #address-cells = <1>; - #size-cells = <0>; - reg = <1>; - - eeprom-sfp-2@50 { - compatible = "at,24c02"; - reg = <0x50>; - read-only; - }; - eeprom-sfp-2@51 { - compatible = "at,24c02"; - reg = <0x51>; - read-only; - }; - }; - - i2c@2 { - #address-cells = <1>; - #size-cells = <0>; - reg = <2>; - - eeprom-sfp-3@50 { - compatible = "at,24c02"; - reg = <0x50>; - read-only; - }; - eeprom-sfp-3@51 { - compatible = "at,24c02"; - reg = <0x51>; - read-only; - }; - }; - - i2c@3 { - #address-cells = <1>; - #size-cells = <0>; - reg = <3>; - - eeprom-sfp-4@50 { - compatible = "at,24c02"; - reg = <0x50>; - read-only; - }; - eeprom-sfp-4@51 { - compatible = "at,24c02"; - reg = <0x51>; - read-only; - }; - }; - - i2c@4 { - #address-cells = <1>; - #size-cells = <0>; - reg = <4>; - - temp-fan-1@2c { - compatible = "adi,adt7470"; - reg = <0x2c>; - }; - }; - - i2c@5 { - #address-cells = <1>; - #size-cells = <0>; - reg = <5>; - - temp-fan-2@2f { - compatible = "adi,adt7470"; - reg = <0x2f>; - }; - }; - - i2c@6 { - #address-cells = <1>; - #size-cells = <0>; - reg = <6>; - - psu-1@58 { - compatible = "pmbus"; - reg = <0x58>; - }; - }; - - i2c@7 { - #address-cells = <1>; - #size-cells = <0>; - reg = <7>; - - psu-2@59 { - compatible = "pmbus"; - reg = <0x59>; - }; - }; - }; - }; - - dma@21300 { - #address-cells = <1>; - #size-cells = <1>; - compatible = "fsl,mpc8541-dma", "fsl,eloplus-dma"; - reg = <0x21300 0x4>; - ranges = <0x0 0x21100 0x200>; - cell-index = <0>; - dma-channel@0 { - compatible = "fsl,mpc8541-dma-channel", - "fsl,eloplus-dma-channel"; - reg = <0x0 0x80>; - cell-index = <0>; - interrupt-parent = <&mpic>; - interrupts = <20 2>; - }; - dma-channel@80 { - compatible = "fsl,mpc8541-dma-channel", - "fsl,eloplus-dma-channel"; - reg = <0x80 0x80>; - cell-index = <1>; - interrupt-parent = <&mpic>; - interrupts = <21 2>; - }; - dma-channel@100 { - compatible = "fsl,mpc8541-dma-channel", - "fsl,eloplus-dma-channel"; - reg = <0x100 0x80>; - cell-index = <2>; - interrupt-parent = <&mpic>; - interrupts = <22 2>; - }; - dma-channel@180 { - compatible = "fsl,mpc8541-dma-channel", - "fsl,eloplus-dma-channel"; - reg = <0x180 0x80>; - cell-index = <3>; - interrupt-parent = <&mpic>; - interrupts = <23 2>; - }; - }; - - enet0: ethernet@24000 { - #address-cells = <1>; - #size-cells = <1>; - cell-index = <0>; - device_type = "network"; - model = "TSEC"; - compatible = "gianfar"; - reg = <0x24000 0x1000>; - ranges = <0x0 0x24000 0x1000>; - local-mac-address = [ 00 00 00 00 00 00 ]; - interrupts = <29 2 30 2 34 2>; - interrupt-parent = <&mpic>; - phy-handle = <&phy0>; - - mdio@520 { - #address-cells = <1>; - #size-cells = <0>; - compatible = "fsl,gianfar-mdio"; - reg = <0x520 0x20>; - - phy0: ethernet-phy@0 { - interrupt-parent = <&mpic>; - reg = <0x0>; - device_type = "ethernet-phy"; - }; - }; - }; - - serial0: serial@4500 { - cell-index = <0>; - device_type = "serial"; - compatible = "fsl,ns16550", "ns16550"; - reg = <0x4500 0x100>; // reg base, size - clock-frequency = <0>; - interrupts = <42 2>; - interrupt-parent = <&mpic>; - }; - - mpic: pic@40000 { - interrupt-controller; - #address-cells = <0>; - #interrupt-cells = <2>; - reg = <0x40000 0x40000>; - compatible = "chrp,open-pic"; - device_type = "open-pic"; - }; - - cpm@919c0 { - #address-cells = <1>; - #size-cells = <1>; - compatible = "fsl,mpc8541-cpm", "fsl,cpm2"; - reg = <0x919c0 0x30>; - ranges; - - gpio0: cpm-pario-a@10d00 { - #gpio-cells = <2>; - compatible = "fsl,cpm2-pario-bank"; - reg = <0x90d00 0x14>; - gpio-controller; - }; - - cpm-pario-b@90d20 { - #gpio-cells = <2>; - compatible = "fsl,cpm2-pario-bank"; - reg = <0x90d20 0x14>; - gpio-controller; - }; - - cpm-pario-c@90d40 { - #gpio-cells = <2>; - compatible = "fsl,cpm2-pario-bank"; - reg = <0x90d40 0x14>; - gpio-controller; - }; - - cpm-pario-d@90d60 { - #gpio-cells = <2>; - compatible = "fsl,cpm2-pario-bank"; - reg = <0x90d60 0x14>; - gpio-controller; - }; - }; - }; - - leds { - compatible = "gpio-leds"; - system-status { - gpios = <&gpio0 22 1>; - linux,default-trigger = "default-on"; - }; - }; - - pci0: pci@e0008000 { - cell-index = <0>; - interrupt-map-mask = <0x1f800 0x0 0x0 0x7>; - interrupt-map = < - - /* IDSEL 0x12 (Slot 1) */ - 0x9000 0x0 0x0 0x1 &mpic 0x3 0x1 - >; - - interrupt-parent = <&mpic>; - interrupts = <24 2>; - bus-range = <0 0>; - ranges = <0x2000000 0x0 0x80000000 0x80000000 0x0 0x20000000 - 0x1000000 0x0 0x0 0xe2000000 0x0 0x100000>; - clock-frequency = <66666666>; - #interrupt-cells = <1>; - #size-cells = <2>; - #address-cells = <3>; - reg = <0xe0008000 0x1000>; - compatible = "fsl,mpc8540-pci"; - device_type = "pci"; - - }; - - localbus@f0010100 { - #address-cells = <2>; - #size-cells = <1>; - compatible = "fsl,mpc8541-localbus", - "fsl,pq2-localbus", - "simple-bus"; - reg = <0xf0010100 0x40>; - interrupt-parent = <&mpic>; - interrupts = <19 2>; - ranges = <0x0 0x0 0xfe000000 0x2000000 - 0x1 0x0 0xf0000000 0x10000 - 0x2 0x0 0xf0010000 0x10000>; - - flash@0 { - #address-cells = <1>; - #size-cells = <1>; - compatible = "cfi-flash"; - reg = <0x0 0x0 0x2000000>; - bank-width = <2>; - device-width = <1>; - - /* partition names must be sorted alphanumerically */ - /* otherwise kexec/Linux may reorder mtd devices */ - - flash-00@00000000 { - label = "onl-loader"; - reg = <0x00000000 0x00800000>; - }; - - flash-01@00800000 { - label = "mnt-flash"; - reg = <0x00800000 0x01360000>; - }; - - flash-02@01b60000 { - label = "onie"; - reg = <0x01b60000 0x00400000>; - read-only; - }; - - flash-03@01f60000 { - label = "uboot-env"; - reg = <0x01f60000 0x00020000>; - }; - - flash-04@01f80000 { - label = "uboot"; - reg = <0x01f80000 0x00080000>; - read-only; - }; - }; - - pata@3,0 { - compatible = "quanta-lb-ata"; - reg = <0x1 0x0 0x10000 0x2 0x0 0x10000>; - #interrupt-cells = <1>; - interrupts = <2 2>; - interrupt-parent = <&mpic>; - }; - }; -}; diff --git a/packages/platforms/quanta/powerpc/lb9/platform-config/r0/src/lib/etc/fancontrol b/packages/platforms/quanta/powerpc/lb9/platform-config/r0/src/lib/etc/fancontrol deleted file mode 100644 index 2fc0b55c2..000000000 --- a/packages/platforms/quanta/powerpc/lb9/platform-config/r0/src/lib/etc/fancontrol +++ /dev/null @@ -1,15 +0,0 @@ -############################################################ -# -# Platform: Quanta LB9 -# -############################################################ - -INTERVAL=10 -DEVPATH=hwmon0=devices/e0000000.soc8541/e0003000.i2c/i2c-0/i2c-5/5-002c -DEVNAME=hwmon0=adt7470 -FCTEMPS=hwmon0/device/pwm1=hwmon0/device/temp1_input hwmon0/device/pwm2=hwmon0/device/temp1_input hwmon0/device/pwm3=hwmon0/device/temp1_input hwmon0/device/pwm4=hwmon0/device/temp1_input -FCFANS=hwmon0/device/pwm1=hwmon0/device/fan1_input hwmon0/device/pwm2=hwmon0/device/fan2_input hwmon0/device/pwm3=hwmon0/device/fan3_input hwmon0/device/pwm4=hwmon0/device/fan4_input -MINTEMP=hwmon0/device/pwm1=20 hwmon0/device/pwm2=20 hwmon0/device/pwm3=20 hwmon0/device/pwm4=20 -MAXTEMP=hwmon0/device/pwm1=60 hwmon0/device/pwm2=60 hwmon0/device/pwm3=60 hwmon0/device/pwm4=60 -MINSTART=hwmon0/device/pwm1=150 hwmon0/device/pwm2=150 hwmon0/device/pwm3=150 hwmon0/device/pwm4=150 -MINSTOP=hwmon0/device/pwm1=0 hwmon0/device/pwm2=0 hwmon0/device/pwm3=0 hwmon0/device/pwm4=0 diff --git a/packages/platforms/quanta/powerpc/lb9/platform-config/r0/src/lib/etc/sensors3.conf b/packages/platforms/quanta/powerpc/lb9/platform-config/r0/src/lib/etc/sensors3.conf deleted file mode 100644 index a06187232..000000000 --- a/packages/platforms/quanta/powerpc/lb9/platform-config/r0/src/lib/etc/sensors3.conf +++ /dev/null @@ -1,72 +0,0 @@ -############################################################ -# -# Platform: Quanta LB9 -# -############################################################ - -bus "i2c-5" "i2c-0-mux (chan_id 4)" -bus "i2c-6" "i2c-0-mux (chan_id 5)" -bus "i2c-7" "i2c-0-mux (chan_id 6)" -bus "i2c-8" "i2c-0-mux (chan_id 7)" - -chip "adt7470-i2c-5-2c" - label fan1 "Fan 1" - label fan2 "Fan 2" - label fan3 "Fan 3" - label fan4 "Fan 4" - label temp1 "Temp 1" - label temp2 "Temp 2" - label temp3 "Temp 3" - label temp4 "Temp 4" - label temp5 "Temp 5" - ignore temp6 - ignore temp7 - ignore temp8 - ignore temp9 - ignore temp10 - - -chip "adt7470-i2c-6-2f" - ignore fan1 - ignore fan2 - ignore fan3 - ignore fan4 - ignore temp1 - ignore temp2 - ignore temp3 - ignore temp4 - ignore temp5 - ignore temp6 - ignore temp7 - ignore temp8 - ignore temp9 - ignore temp10 - - -chip "pmbus-i2c-7-58" - label fan1 "PSU-2 Fan" - label temp1 "PSU-2 Temp 1" - label temp2 "PSU-2 Temp 2" - label temp3 "PSU-2 Temp 3" - label in1 "PSU-2 Vin 1" - label in2 "PSU-2 Vout 1" - # in2 reads > 6000 V without this correction...(?) - compute in2 @/500,500*@ - label curr1 "PSU-2 Iin 1" - label curr2 "PSU-2 Iout 1" - label power1 "PSU-2 Pin 1" - label power2 "PSU-2 Pout 1" - -chip "pmbus-i2c-8-59" - label fan1 "PSU-1 Fan" - label temp1 "PSU-1 Temp 1" - label temp2 "PSU-1 Temp 2" - label temp3 "PSU-1 Temp 3" - label in1 "PSU-1 Vin 1" - label in2 "PSU-1 Vout 1" - # in2 reads > 6000 V without this correction...(?) - compute in2 @/500,500*@ - label curr1 "PSU-1 Iin 1" - label curr2 "PSU-1 Iout 1" - label power1 "PSU-1 Pin 1" - label power2 "PSU-1 Pout 1" diff --git a/packages/platforms/quanta/powerpc/lb9/platform-config/r0/src/lib/powerpc-quanta-lb9-r0.yml b/packages/platforms/quanta/powerpc/lb9/platform-config/r0/src/lib/powerpc-quanta-lb9-r0.yml deleted file mode 100644 index 2b92a3e35..000000000 --- a/packages/platforms/quanta/powerpc/lb9/platform-config/r0/src/lib/powerpc-quanta-lb9-r0.yml +++ /dev/null @@ -1,33 +0,0 @@ ---- - -###################################################################### -# -# platform definition for LB9 -# -###################################################################### - -powerpc-quanta-lb9-r0: - - flat_image_tree: - - kernel: - <<: *e500v-3-16 - dtb: - =: powerpc-quanta-lb9-r0.dtb - package: onl-platform-build-powerpc-quanta-lb9-r0:powerpc - - loader: - device: /dev/sda - nos_bootcmds: *ide_bootcmds - - environment: - - device: /dev/mtd3 - env_offset: 0x00000000 - env_size: 0x00002000 - sector_size: 0x00020000 - - ##network: - ## interfaces: - ## ma1: - ## name: ~ - ## syspath: e0000000.soc8541/e0024000.ethernet diff --git a/packages/platforms/quanta/powerpc/lb9/platform-config/r0/src/lib/sbin/sfpdump b/packages/platforms/quanta/powerpc/lb9/platform-config/r0/src/lib/sbin/sfpdump deleted file mode 100755 index f3255f975..000000000 --- a/packages/platforms/quanta/powerpc/lb9/platform-config/r0/src/lib/sbin/sfpdump +++ /dev/null @@ -1,40 +0,0 @@ -#!/bin/sh -############################################################ -# -# -# Copyright 2013, 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. -# -# -############################################################ -# -# Platform: Quanta LB9 -# -############################################################ - -n=49 -dump() { - echo "$2 port $n:" - hexdump -C /sys/class/i2c-dev/i2c-$1/device/$1-0050/eeprom 2>/dev/null - n=$((n+1)) -} - -# Linux assigns I2C bus numbers as it enumerates the I2C master/mux -# devices in the device tree breadth-first. The bus numbers below may -# change if the device tree changes. - -for i in $(seq 1 1 4); do - dump $i SFP -done diff --git a/packages/platforms/quanta/powerpc/lb9/platform-config/r0/src/python/powerpc_quanta_lb9_r0/__init__.py b/packages/platforms/quanta/powerpc/lb9/platform-config/r0/src/python/powerpc_quanta_lb9_r0/__init__.py deleted file mode 100755 index 4063f7ced..000000000 --- a/packages/platforms/quanta/powerpc/lb9/platform-config/r0/src/python/powerpc_quanta_lb9_r0/__init__.py +++ /dev/null @@ -1,33 +0,0 @@ -#!/usr/bin/python - -from onl.platform.base import * -from onl.platform.quanta import * - -class OnlPlatform_powerpc_quanta_lb9_r0(OnlPlatformQuanta, - OnlPlatformPortConfig_48x1_4x10): - PLATFORM='powerpc-quanta-lb9-r0' - MODEL="LB9" - """ 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=".1048.1900" - - def baseconfig(self): - platform_fancontrol="%s/etc/fancontrol" % self.basedir_onl() - FAN_CONF = '/etc/fancontrol' - if os.path.exists(FAN_CONF): - os.unlink(FAN_CONF) - if os.path.exists(platform_fancontrol): - os.symlink(platform_fancontrol, FAN_CONF) - else: - sys.exit(1) - - return True - - - diff --git a/packages/platforms/quanta/powerpc/ly2/.gitignore b/packages/platforms/quanta/powerpc/ly2/.gitignore deleted file mode 100644 index 096a05ea3..000000000 --- a/packages/platforms/quanta/powerpc/ly2/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -*powerpc*quanta*ly2*.mk -onlpdump.mk diff --git a/packages/platforms/quanta/powerpc/ly2/Makefile b/packages/platforms/quanta/powerpc/ly2/Makefile deleted file mode 100644 index 003238cf6..000000000 --- a/packages/platforms/quanta/powerpc/ly2/Makefile +++ /dev/null @@ -1 +0,0 @@ -include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/quanta/powerpc/ly2/modules/Makefile b/packages/platforms/quanta/powerpc/ly2/modules/Makefile deleted file mode 100644 index 003238cf6..000000000 --- a/packages/platforms/quanta/powerpc/ly2/modules/Makefile +++ /dev/null @@ -1 +0,0 @@ -include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/quanta/powerpc/ly2/modules/PKG.yml b/packages/platforms/quanta/powerpc/ly2/modules/PKG.yml deleted file mode 100644 index 9f0b09f5a..000000000 --- a/packages/platforms/quanta/powerpc/ly2/modules/PKG.yml +++ /dev/null @@ -1 +0,0 @@ -!include $ONL_TEMPLATES/platform-modules.yml ARCH=powerpc VENDOR=quanta BASENAME=powerpc-quanta-ly2 KERNELS="onl-kernel-3.16-lts-powerpc-e500v-all:powerpc" diff --git a/packages/platforms/quanta/powerpc/ly2/modules/builds/.gitignore b/packages/platforms/quanta/powerpc/ly2/modules/builds/.gitignore deleted file mode 100644 index a65b41774..000000000 --- a/packages/platforms/quanta/powerpc/ly2/modules/builds/.gitignore +++ /dev/null @@ -1 +0,0 @@ -lib diff --git a/packages/platforms/quanta/powerpc/ly2/modules/builds/Makefile b/packages/platforms/quanta/powerpc/ly2/modules/builds/Makefile deleted file mode 100644 index c17f6468b..000000000 --- a/packages/platforms/quanta/powerpc/ly2/modules/builds/Makefile +++ /dev/null @@ -1,6 +0,0 @@ -KERNELS := onl-kernel-3.16-lts-powerpc-e500v-all:powerpc -KMODULES := $(wildcard *.c) -VENDOR := quanta -BASENAME := powerpc-quanta-ly2 -ARCH := powerpc -include $(ONL)/make/kmodule.mk diff --git a/packages/platforms/quanta/powerpc/ly2/modules/builds/quanta-ly-hwmon.c b/packages/platforms/quanta/powerpc/ly2/modules/builds/quanta-ly-hwmon.c deleted file mode 100644 index 63466a171..000000000 --- a/packages/platforms/quanta/powerpc/ly2/modules/builds/quanta-ly-hwmon.c +++ /dev/null @@ -1,297 +0,0 @@ -/* - * - * - * Copyright 2013, 2014 BigSwitch Networks, Inc. - * - * This program is free software; you can redistribute it - * and/or modify it under the terms ofthe GNU General Public License as - * published by the Free Software Foundation; either version 2 of the License, - * or (at your option) any later version. - * - * - * - * - * A hwmon driver for the Quanta LYx - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -static const unsigned short normal_i2c[] = { 0x2C, 0x2E, 0x2F, I2C_CLIENT_END }; - -#define QUANTA_LY_HWMON_REG_TEMP_INPUT_BASE 0x30 -#define QUANTA_LY_HWMON_REG_FAN_MODE 0x55 -#define QUANTA_LY_HWMON_REG_FAN_DIR 0x56 -#define QUANTA_LY_HWMON_REG_FAN_PWM_BASE 0x60 -#define QUANTA_LY_HWMON_REG_FAN_INPUT_BASE 0x80 - -#define QUANTA_LY_HWMON_FAN_MANUAL_MODE 1 -#define QUANTA_LY_HWMON_FAN_AUTO_MODE 2 - -#define QUANTA_LY_HWMON_NUM_FANS 8 - -struct quanta_ly_hwmon_data { - struct device *hwmon_dev; - struct attribute_group attrs; - struct mutex lock; -}; - -static int quanta_ly_hwmon_probe(struct i2c_client *client, - const struct i2c_device_id *id); -static int quanta_ly_hwmon_remove(struct i2c_client *client); - -static const struct i2c_device_id quanta_ly_hwmon_id[] = { - { "quanta_ly_hwmon", 0 }, - { } -}; -MODULE_DEVICE_TABLE(i2c, quanta_ly_hwmon_id); - -static struct i2c_driver quanta_ly_hwmon_driver = { - .class = I2C_CLASS_HWMON, - .driver = { - .name = "quanta_ly_hwmon", - }, - .probe = quanta_ly_hwmon_probe, - .remove = quanta_ly_hwmon_remove, - .id_table = quanta_ly_hwmon_id, - .address_list = normal_i2c, -}; - -static ssize_t show_temp(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 quanta_ly_hwmon_data *data = i2c_get_clientdata(client); - int temp; - - mutex_lock(&data->lock); - temp = i2c_smbus_read_byte_data(client, - QUANTA_LY_HWMON_REG_TEMP_INPUT_BASE - + attr->index); - mutex_unlock(&data->lock); - return sprintf(buf, "%d\n", 1000 * temp); -} - -static ssize_t show_fan(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 quanta_ly_hwmon_data *data = i2c_get_clientdata(client); - int fan; - - mutex_lock(&data->lock); - fan = i2c_smbus_read_word_swapped(client, - QUANTA_LY_HWMON_REG_FAN_INPUT_BASE - + 2 * attr->index); - mutex_unlock(&data->lock); - return sprintf(buf, "%d\n", fan); -} - -static ssize_t show_pwm(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 quanta_ly_hwmon_data *data = i2c_get_clientdata(client); - int pwm; - - mutex_lock(&data->lock); - pwm = i2c_smbus_read_word_swapped(client, - QUANTA_LY_HWMON_REG_FAN_PWM_BASE - + 2 * attr->index); - mutex_unlock(&data->lock); - return sprintf(buf, "%d\n", pwm * 255 / 10000); -} - -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 quanta_ly_hwmon_data *data = i2c_get_clientdata(client); - long val; - int ret; - - ret = kstrtol(buf, 10, &val); - if (ret) - return ret; - mutex_lock(&data->lock); - i2c_smbus_write_word_swapped(client, - QUANTA_LY_HWMON_REG_FAN_PWM_BASE - + 2 * attr->index, val * 10000 / 255); - mutex_unlock(&data->lock); - return count; -} - -static ssize_t show_fan_dir(struct device *dev, - struct device_attribute *devattr, char *buf) -{ - struct i2c_client *client = to_i2c_client(dev); - struct quanta_ly_hwmon_data *data = i2c_get_clientdata(client); - - int f2b = 0; - int b2f = 0; - int i; - - mutex_lock(&data->lock); - for(i = 0; i < 4; i++) { - f2b += i2c_smbus_read_word_swapped(client, - QUANTA_LY_HWMON_REG_FAN_INPUT_BASE - + 2 * i); - } - for(i = 4; i < 8; i++) { - b2f += i2c_smbus_read_word_swapped(client, - QUANTA_LY_HWMON_REG_FAN_INPUT_BASE - + 2 * i); - } - - mutex_unlock(&data->lock); - if(f2b) { - return sprintf(buf, "front-to-back"); - } - if(b2f) { - return sprintf(buf, "back-to-front"); - } - return sprintf(buf, "unknown"); -} - -static ssize_t set_fan_dir(struct device *dev, - struct device_attribute *devattr, const char *buf, - size_t count) -{ - struct i2c_client *client = to_i2c_client(dev); - struct quanta_ly_hwmon_data *data = i2c_get_clientdata(client); - int dir; - - if (!strncmp(buf, "normal", 6)) - dir = 0; - else if (!strncmp(buf, "reverse", 7)) - dir = 1; - else - return -EINVAL; - - mutex_lock(&data->lock); - i2c_smbus_write_byte_data(client, - QUANTA_LY_HWMON_REG_FAN_DIR, dir); - mutex_unlock(&data->lock); - return count; -} - -static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, show_temp, NULL, 0); -static SENSOR_DEVICE_ATTR(temp2_input, S_IRUGO, show_temp, NULL, 1); -static SENSOR_DEVICE_ATTR(temp3_input, S_IRUGO, show_temp, NULL, 2); -static SENSOR_DEVICE_ATTR(temp4_input, S_IRUGO, show_temp, NULL, 3); -static SENSOR_DEVICE_ATTR(temp5_input, S_IRUGO, show_temp, NULL, 4); -static SENSOR_DEVICE_ATTR(fan1_input, S_IRUGO, show_fan, NULL, 0); -static SENSOR_DEVICE_ATTR(fan2_input, S_IRUGO, show_fan, NULL, 1); -static SENSOR_DEVICE_ATTR(fan3_input, S_IRUGO, show_fan, NULL, 2); -static SENSOR_DEVICE_ATTR(fan4_input, S_IRUGO, show_fan, NULL, 3); -static SENSOR_DEVICE_ATTR(fan5_input, S_IRUGO, show_fan, NULL, 4); -static SENSOR_DEVICE_ATTR(fan6_input, S_IRUGO, show_fan, NULL, 5); -static SENSOR_DEVICE_ATTR(fan7_input, S_IRUGO, show_fan, NULL, 6); -static SENSOR_DEVICE_ATTR(fan8_input, S_IRUGO, show_fan, NULL, 7); -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(pwm6, S_IWUSR | S_IRUGO, show_pwm, set_pwm, 5); -static SENSOR_DEVICE_ATTR(pwm7, S_IWUSR | S_IRUGO, show_pwm, set_pwm, 6); -static SENSOR_DEVICE_ATTR(pwm8, S_IWUSR | S_IRUGO, show_pwm, set_pwm, 7); -static SENSOR_DEVICE_ATTR(fan_dir, S_IWUSR | S_IRUGO, show_fan_dir, - set_fan_dir, 0); - -static struct attribute *quanta_ly_hwmon_attr[] = { - &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_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_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_pwm6.dev_attr.attr, - &sensor_dev_attr_pwm7.dev_attr.attr, - &sensor_dev_attr_pwm8.dev_attr.attr, - &sensor_dev_attr_fan_dir.dev_attr.attr, - NULL -}; - -static int quanta_ly_hwmon_probe(struct i2c_client *client, - const struct i2c_device_id *id) -{ - struct quanta_ly_hwmon_data *data; - int err; - int i; - - data = devm_kzalloc(&client->dev, sizeof(struct quanta_ly_hwmon_data), - GFP_KERNEL); - if (!data) - return -ENOMEM; - - i2c_set_clientdata(client, data); - mutex_init(&data->lock); - - dev_info(&client->dev, "%s chip found\n", client->name); - - data->attrs.attrs = quanta_ly_hwmon_attr; - err = sysfs_create_group(&client->dev.kobj, &data->attrs); - if (err) - return err; - - data->hwmon_dev = hwmon_device_register(&client->dev); - if (IS_ERR(data->hwmon_dev)) { - err = PTR_ERR(data->hwmon_dev); - goto exit_remove; - } - - i2c_smbus_write_byte_data(client, - QUANTA_LY_HWMON_REG_FAN_MODE, - QUANTA_LY_HWMON_FAN_MANUAL_MODE); - for (i = 0; i < QUANTA_LY_HWMON_NUM_FANS; i++) { - u8 cmd = QUANTA_LY_HWMON_REG_FAN_PWM_BASE + i * 2; - i2c_smbus_write_word_swapped(client, cmd, 10000); - } - - return 0; - -exit_remove: - sysfs_remove_group(&client->dev.kobj, &data->attrs); - return err; -} - -static int quanta_ly_hwmon_remove(struct i2c_client *client) -{ - struct quanta_ly_hwmon_data *data = i2c_get_clientdata(client); - - hwmon_device_unregister(data->hwmon_dev); - sysfs_remove_group(&client->dev.kobj, &data->attrs); - return 0; -} - -module_i2c_driver(quanta_ly_hwmon_driver); - -MODULE_AUTHOR("Big Switch Networks "); -MODULE_DESCRIPTION("Quanta LYx hardware monitor driver"); -MODULE_LICENSE("GPL"); diff --git a/packages/platforms/quanta/powerpc/ly2/modules/builds/quanta-ly2-i2c-mux.c b/packages/platforms/quanta/powerpc/ly2/modules/builds/quanta-ly2-i2c-mux.c deleted file mode 100644 index f1700c966..000000000 --- a/packages/platforms/quanta/powerpc/ly2/modules/builds/quanta-ly2-i2c-mux.c +++ /dev/null @@ -1,355 +0,0 @@ -/* - * - * - * Copyright 2013, 2014 BigSwitch Networks, Inc. - * - * This program is free software; you can redistribute it - * and/or modify it under the terms ofthe GNU General Public License as - * published by the Free Software Foundation; either version 2 of the License, - * or (at your option) any later version. - * - * - * - * - * An I2C multiplexer driver for the Quanta LY2 - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define QUANTA_LY2_I2C_MUX_CHANNEL_FIRST 1 - -#define QUANTA_LY2_I2C_MUX_NUM_CHANNELS 16 - -/* - * 16 read GPIOs, 8 write GPIOs, - * treat them as a single GPIO chip, - * with the read GPIOs occurring first - */ -#define QUANTA_LY2_I2C_MUX_NUM_READ_GPIOS 16 -#define QUANTA_LY2_I2C_MUX_NUM_WRITE_GPIOS 8 - -#define QUANTA_LY2_I2C_MUX_CMD_GET_GPIO 0 -#define QUANTA_LY2_I2C_MUX_CMD_SET_GPIO 1 -#define QUANTA_LY2_I2C_MUX_CMD_SET_CHANNEL 2 - -struct quanta_ly2_i2c_mux { - struct i2c_client *client; - struct i2c_adapter *chan_adap[QUANTA_LY2_I2C_MUX_NUM_CHANNELS]; - struct gpio_chip gpio_chip; - u8 last_chan; - u8 gpio_write_val; -}; - -static const struct i2c_device_id quanta_ly2_i2c_mux_id[] = { - {"quanta_ly_i2c_mux", 0}, - {"quanta_ly2_i2c_mux", 0}, - {} -}; - -MODULE_DEVICE_TABLE(i2c, quanta_ly2_i2c_mux_id); - -/* - * pld.c does 3-byte transactions, but none of the GPIO - * definitions require more than 16 bits - */ -static int quanta_ly2_i2c_mux_reg_read(struct i2c_adapter *adap, - struct i2c_client *client, - u8 command, u16 *val) -{ - int ret = -ENODEV; - - if (adap->algo->master_xfer) { - struct i2c_msg msg[2]; - char buf[4]; - - msg[0].addr = client->addr; - msg[0].flags = 0; - msg[0].len = 1; - buf[0] = command; - msg[0].buf = &buf[0]; - - /* always receive 3 bytes, else the PLD freaks out */ - msg[1].addr = client->addr; - msg[1].flags = I2C_M_RD; - msg[1].len = 3; - msg[1].buf = &buf[1]; - - ret = adap->algo->master_xfer(adap, msg, 2); - if (val != NULL && ret > -1) - *val = ((buf[2] << 8) | buf[1]); - } else { - union i2c_smbus_data data; - data.block[0] = 3; /* block transfer length */ - ret = adap->algo->smbus_xfer(adap, client->addr, - client->flags, - I2C_SMBUS_READ, - command, - I2C_SMBUS_I2C_BLOCK_DATA, &data); - if (val != NULL) - *val = ((data.block[2] << 8) | data.block[1]); - } - - return ret; -} - -/* - * pld.c shows 3-byte output transactions; - * in our case we only need 8 bits to - * (1) select one of the 16 muxed i2c devices, - * (2) drive one of the 8 defined GPIO outputs - */ -static int quanta_ly2_i2c_mux_reg_write(struct i2c_adapter *adap, - struct i2c_client *client, - u8 command, u8 val) -{ - int ret = -ENODEV; - - if (adap->algo->master_xfer) { - struct i2c_msg msg; - char buf[4]; - - msg.addr = client->addr; - msg.flags = 0; - msg.len = 3; - buf[0] = command; - buf[1] = val; - buf[2] = 0; - buf[3] = 0; - msg.buf = buf; - ret = adap->algo->master_xfer(adap, &msg, 1); - } else { - union i2c_smbus_data data; - - data.block[0] = 3; - data.block[1] = val; - data.block[2] = 0; - data.block[3] = 0; - - ret = adap->algo->smbus_xfer(adap, client->addr, - client->flags, - I2C_SMBUS_WRITE, - command, - I2C_SMBUS_I2C_BLOCK_DATA, &data); - } - - return ret; -} - -static void quanta_ly2_i2c_mux_gpio_set(struct gpio_chip *gc, unsigned offset, - int val) -{ - struct quanta_ly2_i2c_mux *data = container_of( - gc, struct quanta_ly2_i2c_mux, gpio_chip); - - /* ignore write attempts to input GPIOs */ - if (offset < QUANTA_LY2_I2C_MUX_NUM_READ_GPIOS) { - dev_warn(&data->client->dev, - "ignoring GPIO write for input for pin %d\n", - offset); - return; - } - offset -= QUANTA_LY2_I2C_MUX_NUM_READ_GPIOS; - - if (val) - data->gpio_write_val |= (1 << offset); - else - data->gpio_write_val &= ~(1 << offset); - - quanta_ly2_i2c_mux_reg_write( - data->client->adapter, data->client, - QUANTA_LY2_I2C_MUX_CMD_SET_GPIO, - data->gpio_write_val); -} - -/* - * "read" one of the GPIOs. - * The first 16 (QUANTA_LY2_I2C_MUX_NUM_READ_GPIOS) - * are actual input GPIOs. - * the last 8 (QUANTA_LY2_I2C_MUX_NUM_WRITE_GPIOS) - * are output GPIOs, so readback just returns the cached value. - */ -static int quanta_ly2_i2c_mux_gpio_get(struct gpio_chip *gc, unsigned offset) -{ - int ret; - u16 buf; - struct quanta_ly2_i2c_mux *data = container_of( - gc, struct quanta_ly2_i2c_mux, gpio_chip); - - if (offset >= QUANTA_LY2_I2C_MUX_NUM_READ_GPIOS) { - offset -= QUANTA_LY2_I2C_MUX_NUM_READ_GPIOS; - return (data->gpio_write_val & (1 << offset)) ? 1 : 0; - } - - /* else, do a proper gpio read */ - buf = 0; - ret = quanta_ly2_i2c_mux_reg_read(data->client->adapter, - data->client, - QUANTA_LY2_I2C_MUX_CMD_GET_GPIO, - &buf); - if (ret < 0) { - dev_err(&data->client->dev, - "quanta_ly2_i2c_mux_reg_read failed\n"); - return 0; - } - return (buf & (1 << offset)) ? 1 : 0; -} - -static int quanta_ly2_i2c_mux_select_chan(struct i2c_adapter *adap, - void *client, u32 chan) -{ - struct quanta_ly2_i2c_mux *data = i2c_get_clientdata(client); - int ret = 0; - u32 c = QUANTA_LY2_I2C_MUX_CHANNEL_FIRST + chan; - - if (data->last_chan != c) { - ret = quanta_ly2_i2c_mux_reg_write( - adap, client, - QUANTA_LY2_I2C_MUX_CMD_SET_CHANNEL, c); - data->last_chan = c; - } - - return ret; -} - -static int quanta_ly2_i2c_mux_release_chan(struct i2c_adapter *adap, - void *client, u32 chan) -{ - struct quanta_ly2_i2c_mux *data = i2c_get_clientdata(client); - int ret = 0; - - ret = quanta_ly2_i2c_mux_reg_write( - adap, client, - QUANTA_LY2_I2C_MUX_CMD_SET_CHANNEL, 0); - data->last_chan = 0; - - return ret; -} - -static struct gpio_chip quanta_ly2_i2c_mux_gpio_chip = { - .label = "quanta_ly2_i2c_mux_gpio_chip", - .owner = THIS_MODULE, - .ngpio = QUANTA_LY2_I2C_MUX_NUM_READ_GPIOS + QUANTA_LY2_I2C_MUX_NUM_WRITE_GPIOS, - .base = -1, - .set = quanta_ly2_i2c_mux_gpio_set, - .get = quanta_ly2_i2c_mux_gpio_get, -}; - -static int quanta_ly2_i2c_mux_probe(struct i2c_client *client, - const struct i2c_device_id *id) -{ - struct i2c_adapter *adap = client->adapter; - int chan; - struct quanta_ly2_i2c_mux *data; - int ret = -ENODEV; - - if (!i2c_check_functionality(adap, I2C_FUNC_SMBUS_BYTE_DATA)) - goto err; - - data = kzalloc(sizeof(struct quanta_ly2_i2c_mux), GFP_KERNEL); - if (!data) { - ret = -ENOMEM; - goto err; - } - - i2c_set_clientdata(client, data); - data->client = client; - - if (i2c_smbus_write_byte(client, 0) < 0) { - dev_warn(&client->dev, "probe failed\n"); - goto exit_free; - } - - i2c_lock_adapter(adap); - quanta_ly2_i2c_mux_release_chan(adap, client, 0); - i2c_unlock_adapter(adap); - - for (chan = 0; chan < QUANTA_LY2_I2C_MUX_NUM_CHANNELS; chan++) { - data->chan_adap[chan] = - i2c_add_mux_adapter(adap, &client->dev, client, - 0, chan, 0, - quanta_ly2_i2c_mux_select_chan, - quanta_ly2_i2c_mux_release_chan); - - if (data->chan_adap[chan] == NULL) { - ret = -ENODEV; - dev_err(&client->dev, - "failed to register multiplexed adapter %d\n", - chan); - goto adap_reg_failed; - } - } - - dev_info(&client->dev, - "registered %d multiplexed buses for I2C mux %s\n", - chan, client->name); - - data->gpio_chip = quanta_ly2_i2c_mux_gpio_chip; - data->gpio_chip.dev = &client->dev; - data->gpio_write_val = 0xff; - - ret = gpiochip_add(&data->gpio_chip); - if (ret) { - dev_err(&client->dev, "failed to register GPIOs\n"); - goto adap_reg_failed; - } - - dev_info(&client->dev, - "registered GPIOs for I2C mux %s (%d read, %d write)\n", - client->name, - QUANTA_LY2_I2C_MUX_NUM_READ_GPIOS, - QUANTA_LY2_I2C_MUX_NUM_WRITE_GPIOS); - - return 0; - -adap_reg_failed: - for (chan--; chan >= 0; chan--) - i2c_del_mux_adapter(data->chan_adap[chan]); - -exit_free: - kfree(data); -err: - return ret; -} - -static int quanta_ly2_i2c_mux_remove(struct i2c_client *client) -{ - struct quanta_ly2_i2c_mux *data = i2c_get_clientdata(client); - int chan, ret; - - for (chan = 0; chan < QUANTA_LY2_I2C_MUX_NUM_CHANNELS; chan++) - if (data->chan_adap[chan]) { - i2c_del_mux_adapter(data->chan_adap[chan]); - data->chan_adap[chan] = NULL; - } - - ret = gpiochip_remove(&data->gpio_chip); - if (ret) - return ret; - - kfree(data); - return 0; -} - -static struct i2c_driver quanta_ly2_i2c_mux_driver = { - .driver = { - .name = "quanta_ly2_i2c_mux", - .owner = THIS_MODULE, - }, - .probe = quanta_ly2_i2c_mux_probe, - .remove = quanta_ly2_i2c_mux_remove, - .id_table = quanta_ly2_i2c_mux_id, -}; - -module_i2c_driver(quanta_ly2_i2c_mux_driver); - -MODULE_AUTHOR("Big Switch Networks "); -MODULE_DESCRIPTION("Quanta LY2 I2C multiplexer driver"); -MODULE_LICENSE("GPL"); diff --git a/packages/platforms/quanta/powerpc/ly2/onlp/Makefile b/packages/platforms/quanta/powerpc/ly2/onlp/Makefile deleted file mode 100644 index 003238cf6..000000000 --- a/packages/platforms/quanta/powerpc/ly2/onlp/Makefile +++ /dev/null @@ -1 +0,0 @@ -include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/quanta/powerpc/ly2/onlp/PKG.yml b/packages/platforms/quanta/powerpc/ly2/onlp/PKG.yml deleted file mode 100644 index d0b210aeb..000000000 --- a/packages/platforms/quanta/powerpc/ly2/onlp/PKG.yml +++ /dev/null @@ -1 +0,0 @@ -!include $ONL_TEMPLATES/onlp-platform-any.yml PLATFORM=powerpc-quanta-ly2 ARCH=powerpc TOOLCHAIN=powerpc-linux-gnu diff --git a/packages/platforms/quanta/powerpc/ly2/onlp/builds/Makefile b/packages/platforms/quanta/powerpc/ly2/onlp/builds/Makefile deleted file mode 100644 index e7437cb23..000000000 --- a/packages/platforms/quanta/powerpc/ly2/onlp/builds/Makefile +++ /dev/null @@ -1,2 +0,0 @@ -FILTER=src -include $(ONL)/make/subdirs.mk diff --git a/packages/platforms/quanta/powerpc/ly2/onlp/builds/lib/Makefile b/packages/platforms/quanta/powerpc/ly2/onlp/builds/lib/Makefile deleted file mode 100644 index 571228b5d..000000000 --- a/packages/platforms/quanta/powerpc/ly2/onlp/builds/lib/Makefile +++ /dev/null @@ -1,3 +0,0 @@ -PLATFORM := powerpc-quanta-ly2 -EXTRA_MODULES := quanta_sys_eeprom -include $(ONL)/packages/base/any/onlp/builds/platform/libonlp-platform.mk diff --git a/packages/platforms/quanta/powerpc/ly2/onlp/builds/lib/onlplib.mk b/packages/platforms/quanta/powerpc/ly2/onlp/builds/lib/onlplib.mk deleted file mode 100644 index 1569c0355..000000000 --- a/packages/platforms/quanta/powerpc/ly2/onlp/builds/lib/onlplib.mk +++ /dev/null @@ -1,10 +0,0 @@ - -############################################################################### -# -# Inclusive Makefile for the onlplib module. -# -# Autogenerated 2015-11-13 21:31:17.833690 -# -############################################################################### -onlplib_BASEDIR := $(dir $(abspath $(lastword $(MAKEFILE_LIST)))) - diff --git a/packages/platforms/quanta/powerpc/ly2/onlp/builds/lib/quanta_sys_eeprom.mk b/packages/platforms/quanta/powerpc/ly2/onlp/builds/lib/quanta_sys_eeprom.mk deleted file mode 100644 index a0ef3b6c4..000000000 --- a/packages/platforms/quanta/powerpc/ly2/onlp/builds/lib/quanta_sys_eeprom.mk +++ /dev/null @@ -1,10 +0,0 @@ - -############################################################################### -# -# Inclusive Makefile for the quanta_sys_eeprom module. -# -# Autogenerated 2015-11-13 21:30:58.392873 -# -############################################################################### -quanta_sys_eeprom_BASEDIR := $(dir $(abspath $(lastword $(MAKEFILE_LIST)))) - diff --git a/packages/platforms/quanta/powerpc/ly2/onlp/builds/lib/sff.mk b/packages/platforms/quanta/powerpc/ly2/onlp/builds/lib/sff.mk deleted file mode 100644 index d2226c965..000000000 --- a/packages/platforms/quanta/powerpc/ly2/onlp/builds/lib/sff.mk +++ /dev/null @@ -1,10 +0,0 @@ - -############################################################################### -# -# Inclusive Makefile for the sff module. -# -# Autogenerated 2015-11-13 21:31:17.843759 -# -############################################################################### -sff_BASEDIR := $(dir $(abspath $(lastword $(MAKEFILE_LIST)))) - diff --git a/packages/platforms/quanta/powerpc/ly2/onlp/builds/onlpdump/Makefile b/packages/platforms/quanta/powerpc/ly2/onlp/builds/onlpdump/Makefile deleted file mode 100644 index 8dfad43c1..000000000 --- a/packages/platforms/quanta/powerpc/ly2/onlp/builds/onlpdump/Makefile +++ /dev/null @@ -1,3 +0,0 @@ -PLATFORM := powerpc-quanta-ly2 -EXTRA_MODULES := quanta_sys_eeprom -include $(ONL)/packages/base/any/onlp/builds/platform/onlps.mk diff --git a/packages/platforms/quanta/powerpc/ly2/onlp/builds/powerpc_quanta_ly2/.gitignore b/packages/platforms/quanta/powerpc/ly2/onlp/builds/powerpc_quanta_ly2/.gitignore deleted file mode 100644 index c81d16be3..000000000 --- a/packages/platforms/quanta/powerpc/ly2/onlp/builds/powerpc_quanta_ly2/.gitignore +++ /dev/null @@ -1 +0,0 @@ -*.mk diff --git a/packages/platforms/quanta/powerpc/ly2/onlp/builds/powerpc_quanta_ly2/.module b/packages/platforms/quanta/powerpc/ly2/onlp/builds/powerpc_quanta_ly2/.module deleted file mode 100644 index 1c498acd0..000000000 --- a/packages/platforms/quanta/powerpc/ly2/onlp/builds/powerpc_quanta_ly2/.module +++ /dev/null @@ -1 +0,0 @@ -name: powerpc_quanta_ly2 diff --git a/packages/platforms/quanta/powerpc/ly2/onlp/builds/powerpc_quanta_ly2/Makefile b/packages/platforms/quanta/powerpc/ly2/onlp/builds/powerpc_quanta_ly2/Makefile deleted file mode 100644 index f2d4c358a..000000000 --- a/packages/platforms/quanta/powerpc/ly2/onlp/builds/powerpc_quanta_ly2/Makefile +++ /dev/null @@ -1,10 +0,0 @@ -############################################################################### -# -# -# -############################################################################### -include $(ONL)/make/config.mk - -MODULE := powerpc_quanta_ly2 -AUTOMODULE := powerpc_quanta_ly2 -include $(BUILDER)/definemodule.mk diff --git a/packages/platforms/quanta/powerpc/ly2/onlp/builds/powerpc_quanta_ly2/README b/packages/platforms/quanta/powerpc/ly2/onlp/builds/powerpc_quanta_ly2/README deleted file mode 100644 index f65508b28..000000000 --- a/packages/platforms/quanta/powerpc/ly2/onlp/builds/powerpc_quanta_ly2/README +++ /dev/null @@ -1,6 +0,0 @@ -############################################################################### -# -# powerpc_quanta_ly2 README -# -############################################################################### - diff --git a/packages/platforms/quanta/powerpc/ly2/onlp/builds/powerpc_quanta_ly2/module/auto/make.mk b/packages/platforms/quanta/powerpc/ly2/onlp/builds/powerpc_quanta_ly2/module/auto/make.mk deleted file mode 100644 index 4b09e8e4b..000000000 --- a/packages/platforms/quanta/powerpc/ly2/onlp/builds/powerpc_quanta_ly2/module/auto/make.mk +++ /dev/null @@ -1,9 +0,0 @@ -############################################################################### -# -# powerpc_quanta_ly2 Autogeneration -# -############################################################################### -powerpc_quanta_ly2_AUTO_DEFS := module/auto/powerpc_quanta_ly2.yml -powerpc_quanta_ly2_AUTO_DIRS := module/inc/powerpc_quanta_ly2 module/src -include $(BUILDER)/auto.mk - diff --git a/packages/platforms/quanta/powerpc/ly2/onlp/builds/powerpc_quanta_ly2/module/auto/powerpc_quanta_ly2.yml b/packages/platforms/quanta/powerpc/ly2/onlp/builds/powerpc_quanta_ly2/module/auto/powerpc_quanta_ly2.yml deleted file mode 100644 index d1878da1a..000000000 --- a/packages/platforms/quanta/powerpc/ly2/onlp/builds/powerpc_quanta_ly2/module/auto/powerpc_quanta_ly2.yml +++ /dev/null @@ -1,116 +0,0 @@ -############################################################################### -# -# powerpc_quanta_ly2 Autogeneration Definitions. -# -############################################################################### - -cdefs: &cdefs -- POWERPC_QUANTA_LY2_R0_CONFIG_INCLUDE_LOGGING: - doc: "Include or exclude logging." - default: 1 -- POWERPC_QUANTA_LY2_R0_CONFIG_LOG_OPTIONS_DEFAULT: - doc: "Default enabled log options." - default: AIM_LOG_OPTIONS_DEFAULT -- POWERPC_QUANTA_LY2_R0_CONFIG_LOG_BITS_DEFAULT: - doc: "Default enabled log bits." - default: AIM_LOG_BITS_DEFAULT -- POWERPC_QUANTA_LY2_R0_CONFIG_LOG_CUSTOM_BITS_DEFAULT: - doc: "Default enabled custom log bits." - default: 0 -- POWERPC_QUANTA_LY2_R0_CONFIG_PORTING_STDLIB: - doc: "Default all porting macros to use the C standard libraries." - default: 1 -- POWERPC_QUANTA_LY2_R0_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS: - doc: "Include standard library headers for stdlib porting macros." - default: POWERPC_QUANTA_LY2_R0_CONFIG_PORTING_STDLIB -- POWERPC_QUANTA_LY2_R0_CONFIG_INCLUDE_UCLI: - doc: "Include generic uCli support." - default: 0 -- POWERPC_QUANTA_LY2_R0_CONFIG_SYSFAN_RPM_FAILURE_THRESHOLD: - doc: "RPM Threshold at which the fan is considered to have failed." - default: 100 -- POWERPC_QUANTA_LY2_R0_CONFIG_SYSFAN_F2B_RPM_MAX: - doc: "Maximum system front-to-back fan speed." - default: 13000 -- POWERPC_QUANTA_LY2_R0_CONFIG_SYSFAN_B2F_RPM_MAX: - doc: "Maximum system back-to-front fan speed." - default: 24000 -- POWERPC_QUANTA_LY2_R0_CONFIG_PHY_RESET_DELAY_MS: - doc: "Time to hold Phy GPIO in reset, in ms" - default: 100 - -definitions: - cdefs: - POWERPC_QUANTA_LY2_R0_CONFIG_HEADER: - defs: *cdefs - basename: powerpc_quanta_ly2_config - - enum: &enums - - fan_id: - members: - - FAN1 : 1 - - FAN2 : 2 - - FAN3 : 3 - - FAN4 : 4 - - FAN5 : 5 - - FAN6 : 6 - - 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) - - 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 - - - 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) - - - portingmacro: - POWERPC_QUANTA_LY2_R0: - macros: - - memset - - memcpy - - - vsnprintf - - snprintf - - strlen diff --git a/packages/platforms/quanta/powerpc/ly2/onlp/builds/powerpc_quanta_ly2/module/inc/powerpc_quanta_ly2/powerpc_quanta_ly2.x b/packages/platforms/quanta/powerpc/ly2/onlp/builds/powerpc_quanta_ly2/module/inc/powerpc_quanta_ly2/powerpc_quanta_ly2.x deleted file mode 100644 index 601b463d5..000000000 --- a/packages/platforms/quanta/powerpc/ly2/onlp/builds/powerpc_quanta_ly2/module/inc/powerpc_quanta_ly2/powerpc_quanta_ly2.x +++ /dev/null @@ -1,14 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#include - -/* <--auto.start.xmacro(ALL).define> */ -/* */ - -/* <--auto.start.xenum(ALL).define> */ -/* */ - - diff --git a/packages/platforms/quanta/powerpc/ly2/onlp/builds/powerpc_quanta_ly2/module/inc/powerpc_quanta_ly2/powerpc_quanta_ly2_config.h b/packages/platforms/quanta/powerpc/ly2/onlp/builds/powerpc_quanta_ly2/module/inc/powerpc_quanta_ly2/powerpc_quanta_ly2_config.h deleted file mode 100644 index c4d78eafc..000000000 --- a/packages/platforms/quanta/powerpc/ly2/onlp/builds/powerpc_quanta_ly2/module/inc/powerpc_quanta_ly2/powerpc_quanta_ly2_config.h +++ /dev/null @@ -1,167 +0,0 @@ -/**************************************************************************//** - * - * @file - * @brief powerpc_quanta_ly2 Configuration Header - * - * @addtogroup powerpc_quanta_ly2-config - * @{ - * - *****************************************************************************/ -#ifndef __POWERPC_QUANTA_LY2_R0_CONFIG_H__ -#define __POWERPC_QUANTA_LY2_R0_CONFIG_H__ - -#ifdef GLOBAL_INCLUDE_CUSTOM_CONFIG -#include -#endif -#ifdef POWERPC_QUANTA_LY2_R0_INCLUDE_CUSTOM_CONFIG -#include -#endif - -/* */ -#include -/** - * POWERPC_QUANTA_LY2_R0_CONFIG_INCLUDE_LOGGING - * - * Include or exclude logging. */ - - -#ifndef POWERPC_QUANTA_LY2_R0_CONFIG_INCLUDE_LOGGING -#define POWERPC_QUANTA_LY2_R0_CONFIG_INCLUDE_LOGGING 1 -#endif - -/** - * POWERPC_QUANTA_LY2_R0_CONFIG_LOG_OPTIONS_DEFAULT - * - * Default enabled log options. */ - - -#ifndef POWERPC_QUANTA_LY2_R0_CONFIG_LOG_OPTIONS_DEFAULT -#define POWERPC_QUANTA_LY2_R0_CONFIG_LOG_OPTIONS_DEFAULT AIM_LOG_OPTIONS_DEFAULT -#endif - -/** - * POWERPC_QUANTA_LY2_R0_CONFIG_LOG_BITS_DEFAULT - * - * Default enabled log bits. */ - - -#ifndef POWERPC_QUANTA_LY2_R0_CONFIG_LOG_BITS_DEFAULT -#define POWERPC_QUANTA_LY2_R0_CONFIG_LOG_BITS_DEFAULT AIM_LOG_BITS_DEFAULT -#endif - -/** - * POWERPC_QUANTA_LY2_R0_CONFIG_LOG_CUSTOM_BITS_DEFAULT - * - * Default enabled custom log bits. */ - - -#ifndef POWERPC_QUANTA_LY2_R0_CONFIG_LOG_CUSTOM_BITS_DEFAULT -#define POWERPC_QUANTA_LY2_R0_CONFIG_LOG_CUSTOM_BITS_DEFAULT 0 -#endif - -/** - * POWERPC_QUANTA_LY2_R0_CONFIG_PORTING_STDLIB - * - * Default all porting macros to use the C standard libraries. */ - - -#ifndef POWERPC_QUANTA_LY2_R0_CONFIG_PORTING_STDLIB -#define POWERPC_QUANTA_LY2_R0_CONFIG_PORTING_STDLIB 1 -#endif - -/** - * POWERPC_QUANTA_LY2_R0_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS - * - * Include standard library headers for stdlib porting macros. */ - - -#ifndef POWERPC_QUANTA_LY2_R0_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS -#define POWERPC_QUANTA_LY2_R0_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS POWERPC_QUANTA_LY2_R0_CONFIG_PORTING_STDLIB -#endif - -/** - * POWERPC_QUANTA_LY2_R0_CONFIG_INCLUDE_UCLI - * - * Include generic uCli support. */ - - -#ifndef POWERPC_QUANTA_LY2_R0_CONFIG_INCLUDE_UCLI -#define POWERPC_QUANTA_LY2_R0_CONFIG_INCLUDE_UCLI 0 -#endif - -/** - * POWERPC_QUANTA_LY2_R0_CONFIG_SYSFAN_RPM_FAILURE_THRESHOLD - * - * RPM Threshold at which the fan is considered to have failed. */ - - -#ifndef POWERPC_QUANTA_LY2_R0_CONFIG_SYSFAN_RPM_FAILURE_THRESHOLD -#define POWERPC_QUANTA_LY2_R0_CONFIG_SYSFAN_RPM_FAILURE_THRESHOLD 100 -#endif - -/** - * POWERPC_QUANTA_LY2_R0_CONFIG_SYSFAN_F2B_RPM_MAX - * - * Maximum system front-to-back fan speed. */ - - -#ifndef POWERPC_QUANTA_LY2_R0_CONFIG_SYSFAN_F2B_RPM_MAX -#define POWERPC_QUANTA_LY2_R0_CONFIG_SYSFAN_F2B_RPM_MAX 13000 -#endif - -/** - * POWERPC_QUANTA_LY2_R0_CONFIG_SYSFAN_B2F_RPM_MAX - * - * Maximum system back-to-front fan speed. */ - - -#ifndef POWERPC_QUANTA_LY2_R0_CONFIG_SYSFAN_B2F_RPM_MAX -#define POWERPC_QUANTA_LY2_R0_CONFIG_SYSFAN_B2F_RPM_MAX 24000 -#endif - -/** - * POWERPC_QUANTA_LY2_R0_CONFIG_PHY_RESET_DELAY_MS - * - * Time to hold Phy GPIO in reset, in ms */ - - -#ifndef POWERPC_QUANTA_LY2_R0_CONFIG_PHY_RESET_DELAY_MS -#define POWERPC_QUANTA_LY2_R0_CONFIG_PHY_RESET_DELAY_MS 100 -#endif - - - -/** - * All compile time options can be queried or displayed - */ - -/** Configuration settings structure. */ -typedef struct powerpc_quanta_ly2_config_settings_s { - /** name */ - const char* name; - /** value */ - const char* value; -} powerpc_quanta_ly2_config_settings_t; - -/** Configuration settings table. */ -/** powerpc_quanta_ly2_config_settings table. */ -extern powerpc_quanta_ly2_config_settings_t powerpc_quanta_ly2_config_settings[]; - -/** - * @brief Lookup a configuration setting. - * @param setting The name of the configuration option to lookup. - */ -const char* powerpc_quanta_ly2_config_lookup(const char* setting); - -/** - * @brief Show the compile-time configuration. - * @param pvs The output stream. - */ -int powerpc_quanta_ly2_config_show(struct aim_pvs_s* pvs); - -/* */ - -#include "powerpc_quanta_ly2_porting.h" - -#endif /* __POWERPC_QUANTA_LY2_R0_CONFIG_H__ */ -/* @} */ diff --git a/packages/platforms/quanta/powerpc/ly2/onlp/builds/powerpc_quanta_ly2/module/inc/powerpc_quanta_ly2/powerpc_quanta_ly2_dox.h b/packages/platforms/quanta/powerpc/ly2/onlp/builds/powerpc_quanta_ly2/module/inc/powerpc_quanta_ly2/powerpc_quanta_ly2_dox.h deleted file mode 100644 index e670a52fb..000000000 --- a/packages/platforms/quanta/powerpc/ly2/onlp/builds/powerpc_quanta_ly2/module/inc/powerpc_quanta_ly2/powerpc_quanta_ly2_dox.h +++ /dev/null @@ -1,26 +0,0 @@ -/**************************************************************************//** - * - * powerpc_quanta_ly2 Doxygen Header - * - *****************************************************************************/ -#ifndef __POWERPC_QUANTA_LY2_R0_DOX_H__ -#define __POWERPC_QUANTA_LY2_R0_DOX_H__ - -/** - * @defgroup powerpc_quanta_ly2 powerpc_quanta_ly2 - powerpc_quanta_ly2 Description - * - -The documentation overview for this module should go here. - - * - * @{ - * - * @defgroup powerpc_quanta_ly2-powerpc_quanta_ly2 Public Interface - * @defgroup powerpc_quanta_ly2-config Compile Time Configuration - * @defgroup powerpc_quanta_ly2-porting Porting Macros - * - * @} - * - */ - -#endif /* __POWERPC_QUANTA_LY2_R0_DOX_H__ */ diff --git a/packages/platforms/quanta/powerpc/ly2/onlp/builds/powerpc_quanta_ly2/module/inc/powerpc_quanta_ly2/powerpc_quanta_ly2_porting.h b/packages/platforms/quanta/powerpc/ly2/onlp/builds/powerpc_quanta_ly2/module/inc/powerpc_quanta_ly2/powerpc_quanta_ly2_porting.h deleted file mode 100644 index 1daeb5d3d..000000000 --- a/packages/platforms/quanta/powerpc/ly2/onlp/builds/powerpc_quanta_ly2/module/inc/powerpc_quanta_ly2/powerpc_quanta_ly2_porting.h +++ /dev/null @@ -1,77 +0,0 @@ -/**************************************************************************//** - * - * @file - * @brief powerpc_quanta_ly2 Porting Macros. - * - * @addtogroup powerpc_quanta_ly2-porting - * @{ - * - *****************************************************************************/ -#ifndef __POWERPC_QUANTA_LY2_R0_PORTING_H__ -#define __POWERPC_QUANTA_LY2_R0_PORTING_H__ - - -/* */ -#if POWERPC_QUANTA_LY2_R0_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS == 1 -#include -#include -#include -#include -#include -#endif - -#ifndef POWERPC_QUANTA_LY2_R0_MEMSET - #if defined(GLOBAL_MEMSET) - #define POWERPC_QUANTA_LY2_R0_MEMSET GLOBAL_MEMSET - #elif POWERPC_QUANTA_LY2_R0_CONFIG_PORTING_STDLIB == 1 - #define POWERPC_QUANTA_LY2_R0_MEMSET memset - #else - #error The macro POWERPC_QUANTA_LY2_R0_MEMSET is required but cannot be defined. - #endif -#endif - -#ifndef POWERPC_QUANTA_LY2_R0_MEMCPY - #if defined(GLOBAL_MEMCPY) - #define POWERPC_QUANTA_LY2_R0_MEMCPY GLOBAL_MEMCPY - #elif POWERPC_QUANTA_LY2_R0_CONFIG_PORTING_STDLIB == 1 - #define POWERPC_QUANTA_LY2_R0_MEMCPY memcpy - #else - #error The macro POWERPC_QUANTA_LY2_R0_MEMCPY is required but cannot be defined. - #endif -#endif - -#ifndef POWERPC_QUANTA_LY2_R0_VSNPRINTF - #if defined(GLOBAL_VSNPRINTF) - #define POWERPC_QUANTA_LY2_R0_VSNPRINTF GLOBAL_VSNPRINTF - #elif POWERPC_QUANTA_LY2_R0_CONFIG_PORTING_STDLIB == 1 - #define POWERPC_QUANTA_LY2_R0_VSNPRINTF vsnprintf - #else - #error The macro POWERPC_QUANTA_LY2_R0_VSNPRINTF is required but cannot be defined. - #endif -#endif - -#ifndef POWERPC_QUANTA_LY2_R0_SNPRINTF - #if defined(GLOBAL_SNPRINTF) - #define POWERPC_QUANTA_LY2_R0_SNPRINTF GLOBAL_SNPRINTF - #elif POWERPC_QUANTA_LY2_R0_CONFIG_PORTING_STDLIB == 1 - #define POWERPC_QUANTA_LY2_R0_SNPRINTF snprintf - #else - #error The macro POWERPC_QUANTA_LY2_R0_SNPRINTF is required but cannot be defined. - #endif -#endif - -#ifndef POWERPC_QUANTA_LY2_R0_STRLEN - #if defined(GLOBAL_STRLEN) - #define POWERPC_QUANTA_LY2_R0_STRLEN GLOBAL_STRLEN - #elif POWERPC_QUANTA_LY2_R0_CONFIG_PORTING_STDLIB == 1 - #define POWERPC_QUANTA_LY2_R0_STRLEN strlen - #else - #error The macro POWERPC_QUANTA_LY2_R0_STRLEN is required but cannot be defined. - #endif -#endif - -/* */ - - -#endif /* __POWERPC_QUANTA_LY2_R0_PORTING_H__ */ -/* @} */ diff --git a/packages/platforms/quanta/powerpc/ly2/onlp/builds/powerpc_quanta_ly2/module/make.mk b/packages/platforms/quanta/powerpc/ly2/onlp/builds/powerpc_quanta_ly2/module/make.mk deleted file mode 100644 index 1e6587c38..000000000 --- a/packages/platforms/quanta/powerpc/ly2/onlp/builds/powerpc_quanta_ly2/module/make.mk +++ /dev/null @@ -1,10 +0,0 @@ -############################################################################### -# -# -# -############################################################################### -THIS_DIR := $(dir $(lastword $(MAKEFILE_LIST))) -powerpc_quanta_ly2_INCLUDES := -I $(THIS_DIR)inc -powerpc_quanta_ly2_INTERNAL_INCLUDES := -I $(THIS_DIR)src -powerpc_quanta_ly2_DEPENDMODULE_ENTRIES := init:powerpc_quanta_ly2 ucli:powerpc_quanta_ly2 - diff --git a/packages/platforms/quanta/powerpc/ly2/onlp/builds/powerpc_quanta_ly2/module/src/Makefile b/packages/platforms/quanta/powerpc/ly2/onlp/builds/powerpc_quanta_ly2/module/src/Makefile deleted file mode 100644 index 5aef15cbf..000000000 --- a/packages/platforms/quanta/powerpc/ly2/onlp/builds/powerpc_quanta_ly2/module/src/Makefile +++ /dev/null @@ -1,9 +0,0 @@ -############################################################################### -# -# Local source generation targets. -# -############################################################################### - -ucli: - @../../../../tools/uclihandlers.py powerpc_quanta_ly2_ucli.c - diff --git a/packages/platforms/quanta/powerpc/ly2/onlp/builds/powerpc_quanta_ly2/module/src/fani.c b/packages/platforms/quanta/powerpc/ly2/onlp/builds/powerpc_quanta_ly2/module/src/fani.c deleted file mode 100644 index 09c799961..000000000 --- a/packages/platforms/quanta/powerpc/ly2/onlp/builds/powerpc_quanta_ly2/module/src/fani.c +++ /dev/null @@ -1,156 +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 "powerpc_quanta_ly2_int.h" -#include "powerpc_quanta_ly2_log.h" - -#include - -int -onlp_fani_init(void) -{ - return ONLP_STATUS_OK; -} - - -static int -sys_fan_info_get__(onlp_fan_info_t* info, int id) -{ - int rv; - - rv = onlp_file_read_int(&info->rpm, - SYS_HWMON_PREFIX "/fan%d_input", id); - - if(rv == ONLP_STATUS_E_INTERNAL) { - return rv; - } - - if(rv == ONLP_STATUS_E_MISSING) { - info->status &= ~1; - return 0; - } - - if(info->rpm <= POWERPC_QUANTA_LY2_R0_CONFIG_SYSFAN_RPM_FAILURE_THRESHOLD) { - info->status |= ONLP_FAN_STATUS_FAILED; - } - - /* - * Calculate percentage based on current speed and the maximum. - */ - info->caps |= ONLP_FAN_CAPS_GET_PERCENTAGE; - if(info->status & ONLP_FAN_STATUS_F2B) { - info->percentage = info->rpm * 100 / POWERPC_QUANTA_LY2_R0_CONFIG_SYSFAN_F2B_RPM_MAX; - } - if(info->status & ONLP_FAN_STATUS_B2F) { - info->percentage = info->rpm * 100 / POWERPC_QUANTA_LY2_R0_CONFIG_SYSFAN_B2F_RPM_MAX; - } - return 0; -} - -static int -psu_fan_info_get__(onlp_fan_info_t* info, int id) -{ - extern char* psu_paths[]; - - /* FAN5 -> PSU1 */ - /* FAN6 -> PSU2 */ - char* dir = psu_paths[id-4]; - return onlp_file_read_int(&info->rpm, "%s/fan1_input", dir); -} - - - -/* Onboard Fans */ -static onlp_fan_info_t fans__[] = { - { }, /* Not used */ - { { FAN_OID_FAN1, "Right", 0}, ONLP_FAN_STATUS_PRESENT }, - { { FAN_OID_FAN2, "Center Right", 0}, ONLP_FAN_STATUS_PRESENT }, - { { FAN_OID_FAN3, "Center Left", 0}, ONLP_FAN_STATUS_PRESENT }, - { { FAN_OID_FAN4, "Left", 0}, ONLP_FAN_STATUS_PRESENT }, - { { FAN_OID_FAN5, "PSU-1 Fan", 0 }, ONLP_FAN_STATUS_PRESENT }, - { { FAN_OID_FAN6, "PSU-2 Fan", 0 }, ONLP_FAN_STATUS_PRESENT }, - -}; - -int -onlp_fani_info_get(onlp_oid_t id, onlp_fan_info_t* rv) -{ - *rv = fans__[ONLP_OID_ID_GET(id)]; - rv->caps |= ONLP_FAN_CAPS_GET_RPM; - - int len; - char direction[16] = {0}; - - int fid = ONLP_OID_ID_GET(id); - - /* Read the current airflow direction */ - onlp_file_read((uint8_t*)direction, sizeof(direction), &len, - SYS_HWMON_PREFIX "/fan_dir"); - -#define FAN_DIR_F2B "front-to-back" -#define FAN_DIR_B2F "back-to-front" - - if(!strncmp(direction, FAN_DIR_F2B, strlen(FAN_DIR_F2B))) { - rv->status |= ONLP_FAN_STATUS_F2B; - rv->caps |= ONLP_FAN_CAPS_F2B; - } - else if(!strncmp(direction, FAN_DIR_B2F, strlen(FAN_DIR_B2F))) { - rv->status |= ONLP_FAN_STATUS_B2F; - rv->caps |= ONLP_FAN_CAPS_B2F; - } - else { - AIM_LOG_WARN("Invalid fan direction: '%s'", direction); - } - - - switch(fid) - { - case FAN_ID_FAN1: - case FAN_ID_FAN2: - case FAN_ID_FAN3: - case FAN_ID_FAN4: - { - if(rv->status & ONLP_FAN_STATUS_F2B) { - return sys_fan_info_get__(rv, fid); - } - if(rv->status & ONLP_FAN_STATUS_B2F) { - return sys_fan_info_get__(rv, fid+4); - } - return ONLP_STATUS_E_INTERNAL; - } - - case FAN_ID_FAN5: - case FAN_ID_FAN6: - { - return psu_fan_info_get__(rv, fid); - } - } - - return ONLP_STATUS_E_INVALID; -} - - diff --git a/packages/platforms/quanta/powerpc/ly2/onlp/builds/powerpc_quanta_ly2/module/src/make.mk b/packages/platforms/quanta/powerpc/ly2/onlp/builds/powerpc_quanta_ly2/module/src/make.mk deleted file mode 100644 index ab21b7594..000000000 --- a/packages/platforms/quanta/powerpc/ly2/onlp/builds/powerpc_quanta_ly2/module/src/make.mk +++ /dev/null @@ -1,9 +0,0 @@ -############################################################################### -# -# -# -############################################################################### - -LIBRARY := powerpc_quanta_ly2 -$(LIBRARY)_SUBDIR := $(dir $(lastword $(MAKEFILE_LIST))) -include $(BUILDER)/lib.mk diff --git a/packages/platforms/quanta/powerpc/ly2/onlp/builds/powerpc_quanta_ly2/module/src/powerpc_quanta_ly2_config.c b/packages/platforms/quanta/powerpc/ly2/onlp/builds/powerpc_quanta_ly2/module/src/powerpc_quanta_ly2_config.c deleted file mode 100644 index 0563d8d94..000000000 --- a/packages/platforms/quanta/powerpc/ly2/onlp/builds/powerpc_quanta_ly2/module/src/powerpc_quanta_ly2_config.c +++ /dev/null @@ -1,96 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#include - -/* */ -#define __powerpc_quanta_ly2_config_STRINGIFY_NAME(_x) #_x -#define __powerpc_quanta_ly2_config_STRINGIFY_VALUE(_x) __powerpc_quanta_ly2_config_STRINGIFY_NAME(_x) -powerpc_quanta_ly2_config_settings_t powerpc_quanta_ly2_config_settings[] = -{ -#ifdef POWERPC_QUANTA_LY2_R0_CONFIG_INCLUDE_LOGGING - { __powerpc_quanta_ly2_config_STRINGIFY_NAME(POWERPC_QUANTA_LY2_R0_CONFIG_INCLUDE_LOGGING), __powerpc_quanta_ly2_config_STRINGIFY_VALUE(POWERPC_QUANTA_LY2_R0_CONFIG_INCLUDE_LOGGING) }, -#else -{ POWERPC_QUANTA_LY2_R0_CONFIG_INCLUDE_LOGGING(__powerpc_quanta_ly2_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef POWERPC_QUANTA_LY2_R0_CONFIG_LOG_OPTIONS_DEFAULT - { __powerpc_quanta_ly2_config_STRINGIFY_NAME(POWERPC_QUANTA_LY2_R0_CONFIG_LOG_OPTIONS_DEFAULT), __powerpc_quanta_ly2_config_STRINGIFY_VALUE(POWERPC_QUANTA_LY2_R0_CONFIG_LOG_OPTIONS_DEFAULT) }, -#else -{ POWERPC_QUANTA_LY2_R0_CONFIG_LOG_OPTIONS_DEFAULT(__powerpc_quanta_ly2_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef POWERPC_QUANTA_LY2_R0_CONFIG_LOG_BITS_DEFAULT - { __powerpc_quanta_ly2_config_STRINGIFY_NAME(POWERPC_QUANTA_LY2_R0_CONFIG_LOG_BITS_DEFAULT), __powerpc_quanta_ly2_config_STRINGIFY_VALUE(POWERPC_QUANTA_LY2_R0_CONFIG_LOG_BITS_DEFAULT) }, -#else -{ POWERPC_QUANTA_LY2_R0_CONFIG_LOG_BITS_DEFAULT(__powerpc_quanta_ly2_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef POWERPC_QUANTA_LY2_R0_CONFIG_LOG_CUSTOM_BITS_DEFAULT - { __powerpc_quanta_ly2_config_STRINGIFY_NAME(POWERPC_QUANTA_LY2_R0_CONFIG_LOG_CUSTOM_BITS_DEFAULT), __powerpc_quanta_ly2_config_STRINGIFY_VALUE(POWERPC_QUANTA_LY2_R0_CONFIG_LOG_CUSTOM_BITS_DEFAULT) }, -#else -{ POWERPC_QUANTA_LY2_R0_CONFIG_LOG_CUSTOM_BITS_DEFAULT(__powerpc_quanta_ly2_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef POWERPC_QUANTA_LY2_R0_CONFIG_PORTING_STDLIB - { __powerpc_quanta_ly2_config_STRINGIFY_NAME(POWERPC_QUANTA_LY2_R0_CONFIG_PORTING_STDLIB), __powerpc_quanta_ly2_config_STRINGIFY_VALUE(POWERPC_QUANTA_LY2_R0_CONFIG_PORTING_STDLIB) }, -#else -{ POWERPC_QUANTA_LY2_R0_CONFIG_PORTING_STDLIB(__powerpc_quanta_ly2_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef POWERPC_QUANTA_LY2_R0_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS - { __powerpc_quanta_ly2_config_STRINGIFY_NAME(POWERPC_QUANTA_LY2_R0_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS), __powerpc_quanta_ly2_config_STRINGIFY_VALUE(POWERPC_QUANTA_LY2_R0_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS) }, -#else -{ POWERPC_QUANTA_LY2_R0_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS(__powerpc_quanta_ly2_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef POWERPC_QUANTA_LY2_R0_CONFIG_INCLUDE_UCLI - { __powerpc_quanta_ly2_config_STRINGIFY_NAME(POWERPC_QUANTA_LY2_R0_CONFIG_INCLUDE_UCLI), __powerpc_quanta_ly2_config_STRINGIFY_VALUE(POWERPC_QUANTA_LY2_R0_CONFIG_INCLUDE_UCLI) }, -#else -{ POWERPC_QUANTA_LY2_R0_CONFIG_INCLUDE_UCLI(__powerpc_quanta_ly2_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef POWERPC_QUANTA_LY2_R0_CONFIG_SYSFAN_RPM_FAILURE_THRESHOLD - { __powerpc_quanta_ly2_config_STRINGIFY_NAME(POWERPC_QUANTA_LY2_R0_CONFIG_SYSFAN_RPM_FAILURE_THRESHOLD), __powerpc_quanta_ly2_config_STRINGIFY_VALUE(POWERPC_QUANTA_LY2_R0_CONFIG_SYSFAN_RPM_FAILURE_THRESHOLD) }, -#else -{ POWERPC_QUANTA_LY2_R0_CONFIG_SYSFAN_RPM_FAILURE_THRESHOLD(__powerpc_quanta_ly2_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef POWERPC_QUANTA_LY2_R0_CONFIG_SYSFAN_F2B_RPM_MAX - { __powerpc_quanta_ly2_config_STRINGIFY_NAME(POWERPC_QUANTA_LY2_R0_CONFIG_SYSFAN_F2B_RPM_MAX), __powerpc_quanta_ly2_config_STRINGIFY_VALUE(POWERPC_QUANTA_LY2_R0_CONFIG_SYSFAN_F2B_RPM_MAX) }, -#else -{ POWERPC_QUANTA_LY2_R0_CONFIG_SYSFAN_F2B_RPM_MAX(__powerpc_quanta_ly2_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef POWERPC_QUANTA_LY2_R0_CONFIG_SYSFAN_B2F_RPM_MAX - { __powerpc_quanta_ly2_config_STRINGIFY_NAME(POWERPC_QUANTA_LY2_R0_CONFIG_SYSFAN_B2F_RPM_MAX), __powerpc_quanta_ly2_config_STRINGIFY_VALUE(POWERPC_QUANTA_LY2_R0_CONFIG_SYSFAN_B2F_RPM_MAX) }, -#else -{ POWERPC_QUANTA_LY2_R0_CONFIG_SYSFAN_B2F_RPM_MAX(__powerpc_quanta_ly2_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef POWERPC_QUANTA_LY2_R0_CONFIG_PHY_RESET_DELAY_MS - { __powerpc_quanta_ly2_config_STRINGIFY_NAME(POWERPC_QUANTA_LY2_R0_CONFIG_PHY_RESET_DELAY_MS), __powerpc_quanta_ly2_config_STRINGIFY_VALUE(POWERPC_QUANTA_LY2_R0_CONFIG_PHY_RESET_DELAY_MS) }, -#else -{ POWERPC_QUANTA_LY2_R0_CONFIG_PHY_RESET_DELAY_MS(__powerpc_quanta_ly2_config_STRINGIFY_NAME), "__undefined__" }, -#endif - { NULL, NULL } -}; -#undef __powerpc_quanta_ly2_config_STRINGIFY_VALUE -#undef __powerpc_quanta_ly2_config_STRINGIFY_NAME - -const char* -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)) { - return powerpc_quanta_ly2_config_settings[i].value; - } - } - return NULL; -} - -int -powerpc_quanta_ly2_config_show(struct aim_pvs_s* pvs) -{ - int i; - for(i = 0; powerpc_quanta_ly2_config_settings[i].name; i++) { - aim_printf(pvs, "%s = %s\n", powerpc_quanta_ly2_config_settings[i].name, powerpc_quanta_ly2_config_settings[i].value); - } - return i; -} - -/* */ - diff --git a/packages/platforms/quanta/powerpc/ly2/onlp/builds/powerpc_quanta_ly2/module/src/powerpc_quanta_ly2_enums.c b/packages/platforms/quanta/powerpc/ly2/onlp/builds/powerpc_quanta_ly2/module/src/powerpc_quanta_ly2_enums.c deleted file mode 100644 index 34f2904eb..000000000 --- a/packages/platforms/quanta/powerpc/ly2/onlp/builds/powerpc_quanta_ly2/module/src/powerpc_quanta_ly2_enums.c +++ /dev/null @@ -1,10 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#include - -/* <--auto.start.enum(ALL).source> */ -/* */ - diff --git a/packages/platforms/quanta/powerpc/ly2/onlp/builds/powerpc_quanta_ly2/module/src/powerpc_quanta_ly2_int.h b/packages/platforms/quanta/powerpc/ly2/onlp/builds/powerpc_quanta_ly2/module/src/powerpc_quanta_ly2_int.h deleted file mode 100644 index 0d6a45e50..000000000 --- a/packages/platforms/quanta/powerpc/ly2/onlp/builds/powerpc_quanta_ly2/module/src/powerpc_quanta_ly2_int.h +++ /dev/null @@ -1,204 +0,0 @@ -/**************************************************************************//** - * - * powerpc_quanta_ly2 Internal Header - * - *****************************************************************************/ -#ifndef __POWERPC_QUANTA_LY2_R0_INT_H__ -#define __POWERPC_QUANTA_LY2_R0_INT_H__ - -#include - -/* */ -/** 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* 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[]; - -/** 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 { - 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_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_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* 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[]; -/* */ - - -#define SYS_HWMON_PREFIX "/sys/devices/soc@ffe00000/ffe03000.i2c/i2c-0/i2c-4/4-002e" - -#endif /* __POWERPC_QUANTA_LY2_R0_INT_H__ */ diff --git a/packages/platforms/quanta/powerpc/ly2/onlp/builds/powerpc_quanta_ly2/module/src/powerpc_quanta_ly2_log.c b/packages/platforms/quanta/powerpc/ly2/onlp/builds/powerpc_quanta_ly2/module/src/powerpc_quanta_ly2_log.c deleted file mode 100644 index 9f9b295d4..000000000 --- a/packages/platforms/quanta/powerpc/ly2/onlp/builds/powerpc_quanta_ly2/module/src/powerpc_quanta_ly2_log.c +++ /dev/null @@ -1,18 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#include - -#include "powerpc_quanta_ly2_log.h" -/* - * powerpc_quanta_ly2 log struct. - */ -AIM_LOG_STRUCT_DEFINE( - POWERPC_QUANTA_LY2_R0_CONFIG_LOG_OPTIONS_DEFAULT, - POWERPC_QUANTA_LY2_R0_CONFIG_LOG_BITS_DEFAULT, - NULL, /* Custom log map */ - POWERPC_QUANTA_LY2_R0_CONFIG_LOG_CUSTOM_BITS_DEFAULT - ); - diff --git a/packages/platforms/quanta/powerpc/ly2/onlp/builds/powerpc_quanta_ly2/module/src/powerpc_quanta_ly2_log.h b/packages/platforms/quanta/powerpc/ly2/onlp/builds/powerpc_quanta_ly2/module/src/powerpc_quanta_ly2_log.h deleted file mode 100644 index 595b8e570..000000000 --- a/packages/platforms/quanta/powerpc/ly2/onlp/builds/powerpc_quanta_ly2/module/src/powerpc_quanta_ly2_log.h +++ /dev/null @@ -1,12 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#ifndef __POWERPC_QUANTA_LY2_R0_LOG_H__ -#define __POWERPC_QUANTA_LY2_R0_LOG_H__ - -#define AIM_LOG_MODULE_NAME powerpc_quanta_ly2 -#include - -#endif /* __POWERPC_QUANTA_LY2_R0_LOG_H__ */ diff --git a/packages/platforms/quanta/powerpc/ly2/onlp/builds/powerpc_quanta_ly2/module/src/powerpc_quanta_ly2_module.c b/packages/platforms/quanta/powerpc/ly2/onlp/builds/powerpc_quanta_ly2/module/src/powerpc_quanta_ly2_module.c deleted file mode 100644 index 2b2fcff6a..000000000 --- a/packages/platforms/quanta/powerpc/ly2/onlp/builds/powerpc_quanta_ly2/module/src/powerpc_quanta_ly2_module.c +++ /dev/null @@ -1,24 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#include - -#include "powerpc_quanta_ly2_log.h" - -static int -datatypes_init__(void) -{ -#define POWERPC_QUANTA_LY2_R0_ENUMERATION_ENTRY(_enum_name, _desc) AIM_DATATYPE_MAP_REGISTER(_enum_name, _enum_name##_map, _desc, AIM_LOG_INTERNAL); -#include - return 0; -} - -void __powerpc_quanta_ly2_module_init__(void) -{ - AIM_LOG_STRUCT_REGISTER(); - datatypes_init__(); -} - -int __onlp_platform_version__ = 1; diff --git a/packages/platforms/quanta/powerpc/ly2/onlp/builds/powerpc_quanta_ly2/module/src/powerpc_quanta_ly2_ucli.c b/packages/platforms/quanta/powerpc/ly2/onlp/builds/powerpc_quanta_ly2/module/src/powerpc_quanta_ly2_ucli.c deleted file mode 100644 index 55fdd0216..000000000 --- a/packages/platforms/quanta/powerpc/ly2/onlp/builds/powerpc_quanta_ly2/module/src/powerpc_quanta_ly2_ucli.c +++ /dev/null @@ -1,50 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#include - -#if POWERPC_QUANTA_LY2_R0_CONFIG_INCLUDE_UCLI == 1 - -#include -#include -#include - -static ucli_status_t -powerpc_quanta_ly2_ucli_ucli__config__(ucli_context_t* uc) -{ - UCLI_HANDLER_MACRO_MODULE_CONFIG(powerpc_quanta_ly2) -} - -/* */ -/* */ - -static ucli_module_t -powerpc_quanta_ly2_ucli_module__ = - { - "powerpc_quanta_ly2_ucli", - NULL, - powerpc_quanta_ly2_ucli_ucli_handlers__, - NULL, - NULL, - }; - -ucli_node_t* -powerpc_quanta_ly2_ucli_node_create(void) -{ - ucli_node_t* n; - ucli_module_init(&powerpc_quanta_ly2_ucli_module__); - n = ucli_node_create("powerpc_quanta_ly2", NULL, &powerpc_quanta_ly2_ucli_module__); - ucli_node_subnode_add(n, ucli_module_log_node_create("powerpc_quanta_ly2")); - return n; -} - -#else -void* -powerpc_quanta_ly2_ucli_node_create(void) -{ - return NULL; -} -#endif - diff --git a/packages/platforms/quanta/powerpc/ly2/onlp/builds/powerpc_quanta_ly2/module/src/psui.c b/packages/platforms/quanta/powerpc/ly2/onlp/builds/powerpc_quanta_ly2/module/src/psui.c deleted file mode 100644 index a934daf2d..000000000 --- a/packages/platforms/quanta/powerpc/ly2/onlp/builds/powerpc_quanta_ly2/module/src/psui.c +++ /dev/null @@ -1,109 +0,0 @@ -/************************************************************ - * - * - ************************************************************ - * - * - * - ***********************************************************/ -#include -#include -#include -#include "powerpc_quanta_ly2_int.h" -#include "powerpc_quanta_ly2_log.h" - -int -onlp_psui_init(void) -{ - return 0; -} - -static onlp_psu_info_t psus__[] = { - { }, /* Not used */ - { - { - PSU_OID_PSU1, - "PSU-1", - 0, - { - FAN_OID_FAN5, - THERMAL_OID_THERMAL6, - THERMAL_OID_THERMAL7, - THERMAL_OID_THERMAL8, - }, - } - }, - { - { - PSU_OID_PSU2, - "PSU-2", - 0, - { - FAN_OID_FAN6, - THERMAL_OID_THERMAL9, - THERMAL_OID_THERMAL10, - THERMAL_OID_THERMAL11, - }, - } - }, -}; - -char* psu_paths[] = { - NULL, /* Not used */ - "/sys/bus/i2c/devices/6-0058/hwmon/hwmon0", - "/sys/bus/i2c/devices/7-0059/hwmon/hwmon1", -}; - -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_paths[pid]; - - /* - * Todo -- use the GPIO to determine PSU presence. - * For this first version we'll approximate the status using - * the input voltage sensor. - */ - rv = onlp_file_read_int(&info->mvin, "%s/in1_input", dir); - if(rv == ONLP_STATUS_E_MISSING || info->mvin == 0) { - info->status &= ~1; - return 0; - } - else if(rv < 0) { - return rv; - } - else { - info->caps |= ONLP_PSU_CAPS_VIN; - } - - /* PSU is present and powered. */ - info->status |= 1; - strcpy(info->model, "PSU-LY2"); - info->caps |= ONLP_PSU_CAPS_AC; - - if(onlp_file_read_int(&info->miin, "%s/curr1_input", dir) == 0) { - info->caps |= ONLP_PSU_CAPS_IIN; - } - if(onlp_file_read_int(&info->miout, "%s/curr2_input", dir) == 0) { - info->caps |= ONLP_PSU_CAPS_IOUT; - } - if(onlp_file_read_int(&info->mvout, "%s/in2_input", dir) == 0) { - info->caps |= ONLP_PSU_CAPS_VOUT; - /* Empirical */ - info->mvout /= 500; - } - if(onlp_file_read_int(&info->mpin, "%s/power1_input", dir) == 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->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/powerpc/ly2/onlp/builds/powerpc_quanta_ly2/module/src/sfpi.c b/packages/platforms/quanta/powerpc/ly2/onlp/builds/powerpc_quanta_ly2/module/src/sfpi.c deleted file mode 100644 index 3127950c4..000000000 --- a/packages/platforms/quanta/powerpc/ly2/onlp/builds/powerpc_quanta_ly2/module/src/sfpi.c +++ /dev/null @@ -1,170 +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. - * - * - ************************************************************ - * - * SFPI Interface for the Quanta LY2 - * - ***********************************************************/ -#include -#include -#include -#include "powerpc_quanta_ly2_log.h" - -#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* mod_present_gpio; - const char* reset_gpio; - const char* eeprom; - const char* dom; -} sfpmap_t; - -static sfpmap_t sfpmap__[] = - { - { 1, "/sys/class/gpio/gpio168/value", NULL, "/sys/bus/i2c/devices/14-0050/eeprom", "/sys/bus/i2c/devices/14-0051/eeprom" }, - { 2, "/sys/class/gpio/gpio169/value", NULL, "/sys/bus/i2c/devices/15-0050/eeprom", "/sys/bus/i2c/devices/15-0051/eeprom" }, - { 3, "/sys/class/gpio/gpio170/value", NULL, "/sys/bus/i2c/devices/16-0050/eeprom", "/sys/bus/i2c/devices/16-0051/eeprom" }, - { 4, "/sys/class/gpio/gpio171/value", NULL, "/sys/bus/i2c/devices/17-0050/eeprom", "/sys/bus/i2c/devices/17-0051/eeprom" }, - { 5, "/sys/class/gpio/gpio172/value", NULL, "/sys/bus/i2c/devices/18-0050/eeprom", "/sys/bus/i2c/devices/18-0051/eeprom" }, - { 6, "/sys/class/gpio/gpio173/value", NULL, "/sys/bus/i2c/devices/19-0050/eeprom", "/sys/bus/i2c/devices/19-0051/eeprom" }, - { 7, "/sys/class/gpio/gpio174/value", NULL, "/sys/bus/i2c/devices/20-0050/eeprom", "/sys/bus/i2c/devices/20-0051/eeprom" }, - { 8, "/sys/class/gpio/gpio175/value", NULL, "/sys/bus/i2c/devices/21-0050/eeprom", "/sys/bus/i2c/devices/21-0051/eeprom" }, - { 9, "/sys/class/gpio/gpio176/value", NULL, "/sys/bus/i2c/devices/22-0050/eeprom", "/sys/bus/i2c/devices/22-0051/eeprom" }, - { 10, "/sys/class/gpio/gpio177/value", NULL, "/sys/bus/i2c/devices/23-0050/eeprom", "/sys/bus/i2c/devices/23-0051/eeprom" }, - { 11, "/sys/class/gpio/gpio178/value", NULL, "/sys/bus/i2c/devices/24-0050/eeprom", "/sys/bus/i2c/devices/24-0051/eeprom" }, - { 12, "/sys/class/gpio/gpio179/value", NULL, "/sys/bus/i2c/devices/25-0050/eeprom", "/sys/bus/i2c/devices/25-0051/eeprom" }, - { 13, "/sys/class/gpio/gpio180/value", NULL, "/sys/bus/i2c/devices/26-0050/eeprom", "/sys/bus/i2c/devices/26-0051/eeprom" }, - { 14, "/sys/class/gpio/gpio181/value", NULL, "/sys/bus/i2c/devices/27-0050/eeprom", "/sys/bus/i2c/devices/27-0051/eeprom" }, - { 15, "/sys/class/gpio/gpio182/value", NULL, "/sys/bus/i2c/devices/28-0050/eeprom", "/sys/bus/i2c/devices/28-0051/eeprom" }, - { 16, "/sys/class/gpio/gpio183/value", NULL, "/sys/bus/i2c/devices/29-0050/eeprom", "/sys/bus/i2c/devices/29-0051/eeprom" }, - { 17, "/sys/class/gpio/gpio144/value", NULL, "/sys/bus/i2c/devices/30-0050/eeprom", "/sys/bus/i2c/devices/30-0051/eeprom" }, - { 18, "/sys/class/gpio/gpio145/value", NULL, "/sys/bus/i2c/devices/31-0050/eeprom", "/sys/bus/i2c/devices/31-0051/eeprom" }, - { 19, "/sys/class/gpio/gpio146/value", NULL, "/sys/bus/i2c/devices/32-0050/eeprom", "/sys/bus/i2c/devices/32-0051/eeprom" }, - { 20, "/sys/class/gpio/gpio147/value", NULL, "/sys/bus/i2c/devices/33-0050/eeprom", "/sys/bus/i2c/devices/33-0051/eeprom" }, - { 21, "/sys/class/gpio/gpio148/value", NULL, "/sys/bus/i2c/devices/34-0050/eeprom", "/sys/bus/i2c/devices/34-0051/eeprom" }, - { 22, "/sys/class/gpio/gpio149/value", NULL, "/sys/bus/i2c/devices/35-0050/eeprom", "/sys/bus/i2c/devices/35-0051/eeprom" }, - { 23, "/sys/class/gpio/gpio150/value", NULL, "/sys/bus/i2c/devices/36-0050/eeprom", "/sys/bus/i2c/devices/35-0051/eeprom" }, - { 24, "/sys/class/gpio/gpio151/value", NULL, "/sys/bus/i2c/devices/37-0050/eeprom", "/sys/bus/i2c/devices/37-0051/eeprom" }, - { 25, "/sys/class/gpio/gpio152/value", NULL, "/sys/bus/i2c/devices/38-0050/eeprom", "/sys/bus/i2c/devices/38-0051/eeprom" }, - { 26, "/sys/class/gpio/gpio153/value", NULL, "/sys/bus/i2c/devices/39-0050/eeprom", "/sys/bus/i2c/devices/39-0051/eeprom" }, - { 27, "/sys/class/gpio/gpio154/value", NULL, "/sys/bus/i2c/devices/40-0050/eeprom", "/sys/bus/i2c/devices/40-0051/eeprom" }, - { 28, "/sys/class/gpio/gpio155/value", NULL, "/sys/bus/i2c/devices/41-0050/eeprom", "/sys/bus/i2c/devices/41-0051/eeprom" }, - { 29, "/sys/class/gpio/gpio156/value", NULL, "/sys/bus/i2c/devices/42-0050/eeprom", "/sys/bus/i2c/devices/42-0051/eeprom" }, - { 30, "/sys/class/gpio/gpio157/value", NULL, "/sys/bus/i2c/devices/43-0050/eeprom", "/sys/bus/i2c/devices/43-0051/eeprom" }, - { 31, "/sys/class/gpio/gpio158/value", NULL, "/sys/bus/i2c/devices/44-0050/eeprom", "/sys/bus/i2c/devices/44-0051/eeprom" }, - { 32, "/sys/class/gpio/gpio159/value", NULL, "/sys/bus/i2c/devices/45-0050/eeprom", "/sys/bus/i2c/devices/45-0051/eeprom" }, - { 33, "/sys/class/gpio/gpio120/value", NULL, "/sys/bus/i2c/devices/46-0050/eeprom", "/sys/bus/i2c/devices/46-0051/eeprom" }, - { 34, "/sys/class/gpio/gpio121/value", NULL, "/sys/bus/i2c/devices/47-0050/eeprom", "/sys/bus/i2c/devices/47-0051/eeprom" }, - { 35, "/sys/class/gpio/gpio122/value", NULL, "/sys/bus/i2c/devices/48-0050/eeprom", "/sys/bus/i2c/devices/48-0051/eeprom" }, - { 36, "/sys/class/gpio/gpio123/value", NULL, "/sys/bus/i2c/devices/49-0050/eeprom", "/sys/bus/i2c/devices/49-0051/eeprom" }, - { 37, "/sys/class/gpio/gpio124/value", NULL, "/sys/bus/i2c/devices/50-0050/eeprom", "/sys/bus/i2c/devices/50-0051/eeprom" }, - { 38, "/sys/class/gpio/gpio125/value", NULL, "/sys/bus/i2c/devices/51-0050/eeprom", "/sys/bus/i2c/devices/51-0051/eeprom" }, - { 39, "/sys/class/gpio/gpio126/value", NULL, "/sys/bus/i2c/devices/52-0050/eeprom", "/sys/bus/i2c/devices/52-0051/eeprom" }, - { 40, "/sys/class/gpio/gpio127/value", NULL, "/sys/bus/i2c/devices/53-0050/eeprom", "/sys/bus/i2c/devices/53-0051/eeprom" }, - { 41, "/sys/class/gpio/gpio128/value", NULL, "/sys/bus/i2c/devices/54-0050/eeprom", "/sys/bus/i2c/devices/54-0051/eeprom" }, - { 42, "/sys/class/gpio/gpio129/value", NULL, "/sys/bus/i2c/devices/55-0050/eeprom", "/sys/bus/i2c/devices/55-0051/eeprom" }, - { 43, "/sys/class/gpio/gpio130/value", NULL, "/sys/bus/i2c/devices/56-0050/eeprom", "/sys/bus/i2c/devices/56-0051/eeprom" }, - { 44, "/sys/class/gpio/gpio131/value", NULL, "/sys/bus/i2c/devices/57-0050/eeprom", "/sys/bus/i2c/devices/57-0051/eeprom" }, - { 45, "/sys/class/gpio/gpio132/value", NULL, "/sys/bus/i2c/devices/58-0050/eeprom", "/sys/bus/i2c/devices/58-0051/eeprom" }, - { 46, "/sys/class/gpio/gpio133/value", NULL, "/sys/bus/i2c/devices/59-0050/eeprom", "/sys/bus/i2c/devices/59-0051/eeprom" }, - { 47, "/sys/class/gpio/gpio134/value", NULL, "/sys/bus/i2c/devices/60-0050/eeprom", "/sys/bus/i2c/devices/60-0051/eeprom" }, - { 48, "/sys/class/gpio/gpio135/value", NULL, "/sys/bus/i2c/devices/61-0050/eeprom", "/sys/bus/i2c/devices/61-0051/eeprom" }, - { 49, NULL, NULL, "/sys/bus/i2c/devices/i2c-10/10-0050/eeprom", NULL }, - { 50, NULL, NULL, "/sys/bus/i2c/devices/i2c-11/11-0050/eeprom", NULL }, - { 51, NULL, NULL, "/sys/bus/i2c/devices/i2c-12/12-0050/eeprom", NULL }, - { 52, NULL, NULL, "/sys/bus/i2c/devices/i2c-13/13-0050/eeprom", NULL }, - }; - - -int -onlp_sfpi_init(void) -{ - return ONLP_STATUS_OK; -} - -int -onlp_sfpi_bitmap_get(onlp_sfp_bitmap_t* bmap) -{ - int p; - - for(p = 0; p < 52; p++) { - AIM_BITMAP_SET(bmap, p); - } - - return ONLP_STATUS_OK; -} - -#define SFP_GET(_port) (sfpmap__ + _port) - -int -onlp_sfpi_is_present(int port) -{ - sfpmap_t* sfp = SFP_GET(port); - if(sfp->mod_present_gpio) { - return onlplib_sfp_is_present_file(sfp->mod_present_gpio, - /* Present */ "1\n", - /* Absent */ "0\n"); - } - else { - /** - * If we can open and read a byte from the EEPROM file - * then we consider it present. - */ - int fd = open(sfp->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; - } -} - -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); -} - diff --git a/packages/platforms/quanta/powerpc/ly2/onlp/builds/powerpc_quanta_ly2/module/src/sysi.c b/packages/platforms/quanta/powerpc/ly2/onlp/builds/powerpc_quanta_ly2/module/src/sysi.c deleted file mode 100644 index 25cade61a..000000000 --- a/packages/platforms/quanta/powerpc/ly2/onlp/builds/powerpc_quanta_ly2/module/src/sysi.c +++ /dev/null @@ -1,76 +0,0 @@ -/************************************************************ - * - * - ************************************************************ - * - * - * - ***********************************************************/ -#include -#include "powerpc_quanta_ly2_int.h" -#include "powerpc_quanta_ly2_log.h" -#include - -const char* -onlp_sysi_platform_get(void) -{ - return "powerpc-quanta-ly2-r0"; -} - -int -onlp_sysi_init(void) -{ - return ONLP_STATUS_OK; -} - -#define QUANTA_SYS_EEPROM_PATH \ -"/sys/bus/i2c/devices/2-0054/eeprom" - -int -onlp_sysi_onie_info_get(onlp_onie_info_t* onie) -{ - int rv; - quanta_sys_eeprom_t e; - rv = quanta_sys_eeprom_parse_file(QUANTA_SYS_EEPROM_PATH, &e); - if(rv >= 0) { - quanta_sys_eeprom_to_onie(&e, onie); - onie->platform_name = aim_strdup("powerpc-quanta-ly2-r0"); - } - 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)); - - - /* - * 5 Chassis Thermal Sensors - */ - *e++ = THERMAL_OID_THERMAL1; - *e++ = THERMAL_OID_THERMAL2; - *e++ = THERMAL_OID_THERMAL3; - *e++ = THERMAL_OID_THERMAL4; - *e++ = THERMAL_OID_THERMAL5; - - /* - * 4 Fans - */ - *e++ = FAN_OID_FAN1; - *e++ = FAN_OID_FAN2; - *e++ = FAN_OID_FAN3; - *e++ = FAN_OID_FAN4; - - /* - * 2 PSUs - */ - *e++ = PSU_OID_PSU1; - *e++ = PSU_OID_PSU2; - - /* - * Todo - LEDs - */ - return 0; -} diff --git a/packages/platforms/quanta/powerpc/ly2/onlp/builds/powerpc_quanta_ly2/module/src/thermali.c b/packages/platforms/quanta/powerpc/ly2/onlp/builds/powerpc_quanta_ly2/module/src/thermali.c deleted file mode 100644 index 21ab81f3a..000000000 --- a/packages/platforms/quanta/powerpc/ly2/onlp/builds/powerpc_quanta_ly2/module/src/thermali.c +++ /dev/null @@ -1,124 +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 "powerpc_quanta_ly2_int.h" -#include "powerpc_quanta_ly2_log.h" - -int -onlp_thermali_init(void) -{ - return ONLP_STATUS_OK; -} - -static int -sys_thermal_info_get__(onlp_thermal_info_t* info, int id) -{ - int rv; - - rv = onlp_file_read_int(&info->mcelsius, - SYS_HWMON_PREFIX "/temp%d_input", id); - - if(rv == ONLP_STATUS_E_INTERNAL) { - return rv; - } - - if(rv == ONLP_STATUS_E_MISSING) { - info->status &= ~1; - return 0; - } - - return ONLP_STATUS_OK; -} - -static int -psu_thermal_info_get__(onlp_thermal_info_t* info, int pid, int id) -{ - /* THERMAL6 -> PSU1 */ - /* THERMAL7 -> PSU2 */ - extern char* psu_paths[]; - char* dir = psu_paths[pid]; - info->status |= 1; - return onlp_file_read_int(&info->mcelsius, "%s/temp%d_input", dir, id); -} - -int -onlp_thermali_info_get(onlp_oid_t id, onlp_thermal_info_t* rv) -{ - int tid = ONLP_OID_ID_GET(id); - - static onlp_thermal_info_t info[] = { - { }, /* Not used */ - { { ONLP_THERMAL_ID_CREATE(1), "Chassis Thermal 1", 0}, ONLP_THERMAL_STATUS_PRESENT, - ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS - }, - { { ONLP_THERMAL_ID_CREATE(2), "Chassis Thermal 2", 0}, ONLP_THERMAL_STATUS_PRESENT, - ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS - }, - { { ONLP_THERMAL_ID_CREATE(3), "Chassis Thermal 3", 0}, ONLP_THERMAL_STATUS_PRESENT, - ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS - }, - { { ONLP_THERMAL_ID_CREATE(4), "Chassis Thermal 4", 0}, ONLP_THERMAL_STATUS_PRESENT, - ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS - }, - { { ONLP_THERMAL_ID_CREATE(5), "Chassis Thermal 5", 0}, ONLP_THERMAL_STATUS_PRESENT, - ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS - }, - { { ONLP_THERMAL_ID_CREATE(6), "PSU-1 Thermal 1", 0 } }, - { { ONLP_THERMAL_ID_CREATE(7), "PSU-1 Thermal 2", 0 } }, - { { ONLP_THERMAL_ID_CREATE(8), "PSU-1 Thermal 3", 0 } }, - - { { ONLP_THERMAL_ID_CREATE(9), "PSU-2 Thermal 1", 0 } }, - { { ONLP_THERMAL_ID_CREATE(10), "PSU-2 Thermal 2", 0 } }, - { { ONLP_THERMAL_ID_CREATE(11), "PSU-2 Thermal 3", 0 } }, - }; - - *rv = info[tid]; - rv->caps |= ONLP_THERMAL_CAPS_GET_TEMPERATURE; - - switch(tid) - { - case THERMAL_ID_THERMAL1: - case THERMAL_ID_THERMAL2: - case THERMAL_ID_THERMAL3: - case THERMAL_ID_THERMAL4: - case THERMAL_ID_THERMAL5: - return sys_thermal_info_get__(rv, tid); - - case THERMAL_ID_THERMAL6: - case THERMAL_ID_THERMAL7: - case THERMAL_ID_THERMAL8: - return psu_thermal_info_get__(rv, 1, tid-5); - - - case THERMAL_ID_THERMAL9: - case THERMAL_ID_THERMAL10: - case THERMAL_ID_THERMAL11: - return psu_thermal_info_get__(rv, 2, tid-8); - - } - - return ONLP_STATUS_E_INVALID; -} diff --git a/packages/platforms/quanta/powerpc/ly2/platform-config/Makefile b/packages/platforms/quanta/powerpc/ly2/platform-config/Makefile deleted file mode 100644 index 003238cf6..000000000 --- a/packages/platforms/quanta/powerpc/ly2/platform-config/Makefile +++ /dev/null @@ -1 +0,0 @@ -include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/quanta/powerpc/ly2/platform-config/r0/Makefile b/packages/platforms/quanta/powerpc/ly2/platform-config/r0/Makefile deleted file mode 100644 index 003238cf6..000000000 --- a/packages/platforms/quanta/powerpc/ly2/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/quanta/powerpc/ly2/platform-config/r0/PKG.yml b/packages/platforms/quanta/powerpc/ly2/platform-config/r0/PKG.yml deleted file mode 100644 index db9c928a0..000000000 --- a/packages/platforms/quanta/powerpc/ly2/platform-config/r0/PKG.yml +++ /dev/null @@ -1 +0,0 @@ -!include $ONL_TEMPLATES/platform-config-platform.yml ARCH=powerpc VENDOR=quanta BASENAME=powerpc-quanta-ly2 REVISION=r0 diff --git a/packages/platforms/quanta/powerpc/ly2/platform-config/r0/builds/Makefile b/packages/platforms/quanta/powerpc/ly2/platform-config/r0/builds/Makefile deleted file mode 100644 index f57d62485..000000000 --- a/packages/platforms/quanta/powerpc/ly2/platform-config/r0/builds/Makefile +++ /dev/null @@ -1 +0,0 @@ -include $(ONL)/make/subdirs.mk diff --git a/packages/platforms/quanta/powerpc/ly2/platform-config/r0/builds/dtb/.gitignore b/packages/platforms/quanta/powerpc/ly2/platform-config/r0/builds/dtb/.gitignore deleted file mode 100644 index b60ed208c..000000000 --- a/packages/platforms/quanta/powerpc/ly2/platform-config/r0/builds/dtb/.gitignore +++ /dev/null @@ -1 +0,0 @@ -*.dtb diff --git a/packages/platforms/quanta/powerpc/ly2/platform-config/r0/builds/dtb/Makefile b/packages/platforms/quanta/powerpc/ly2/platform-config/r0/builds/dtb/Makefile deleted file mode 100644 index 8b9493a2c..000000000 --- a/packages/platforms/quanta/powerpc/ly2/platform-config/r0/builds/dtb/Makefile +++ /dev/null @@ -1 +0,0 @@ -include $(ONL)/make/dtbs.mk diff --git a/packages/platforms/quanta/powerpc/ly2/platform-config/r0/builds/dtb/powerpc-quanta-ly2-r0.dts b/packages/platforms/quanta/powerpc/ly2/platform-config/r0/builds/dtb/powerpc-quanta-ly2-r0.dts deleted file mode 100644 index 39611ef6d..000000000 --- a/packages/platforms/quanta/powerpc/ly2/platform-config/r0/builds/dtb/powerpc-quanta-ly2-r0.dts +++ /dev/null @@ -1,1464 +0,0 @@ -/* - * - * - * Copyright 2013, 2014 BigSwitch Networks, Inc. - * - * This program is free software; you can redistribute it - * and/or modify it under the terms ofthe GNU General Public License as - * published by the Free Software Foundation; either version 2 of the License, - * or (at your option) any later version. - * - * - * - * - * - * Device tree for the Quanta LY2. - * - */ - - -/dts-v1/; - -/ { - model = "powerpc-quanta-ly2-r0"; - compatible = "fsl,P2020RDB"; - #address-cells = <2>; - #size-cells = <2>; - - aliases { - ethernet0 = &enet0; - serial0 = &serial0; - serial1 = &serial1; - pci2 = &pci2; - mpic-msgr-block0 = &mpic_msgr_block0; - mpic-msgr-block1 = &mpic_msgr_block1; - }; - - cpus { - #address-cells = <1>; - #size-cells = <0>; - - PowerPC,P2020@0 { - device_type = "cpu"; - reg = <0x0>; - next-level-cache = <&l2>; - }; - - PowerPC,P2020@1 { - device_type = "cpu"; - reg = <0x1>; - next-level-cache = <&l2>; - }; - }; - - memory { - device_type = "memory"; - }; - - localbus@ffe05000 { - #address-cells = <2>; - #size-cells = <1>; - compatible = "fsl,p2020-elbc", "fsl,elbc", "simple-bus"; - reg = <0 0xffe05000 0 0x1000>; - interrupts = <19 2>; - interrupt-parent = <&mpic>; - - ranges = <0x0 0x0 0x0 0xee000000 0x2000000 - 0x1 0x0 0x0 0xec000000 0x2000000>; - - flash@0,0 { - #address-cells = <1>; - #size-cells = <1>; - compatible = "cfi-flash"; - reg = <0x0 0x0 0x2000000>; - bank-width = <2>; - - /* - * ONIE flash layout (reverse-engineered: - * - one ~27MiB loader partition - * - 4 MiB onie partition - * - uboot-env and uboot - * - 32MiB leftover space for jffs2 - * - */ - - flash@0 { - label = "onl-loader"; - reg = <0x00000000 0x01b60000>; - }; - - flash@1 { - label = "onie"; - reg = <0x01b60000 0x00400000>; - read-only; - }; - - flash@2 { - label = "uboot-env"; - reg = <0x01f60000 0x00020000>; - }; - - flash@3 { - label = "uboot"; - reg = <0x01f80000 0x00080000>; - read-only; - }; - - }; - - flash@1,0 { - #address-cells = <1>; - #size-cells = <1>; - compatible = "cfi-flash"; - reg = <0x1 0x0 0x2000000>; - bank-width = <2>; - - flash@4 { - label = "mnt-flash"; - reg = <0x00000000 0x02000000>; - }; - }; - }; - - soc@ffe00000 { - #address-cells = <1>; - #size-cells = <1>; - device_type = "soc"; - compatible = "fsl,p2020-immr", "simple-bus"; - ranges = <0x0 0x0 0xffe00000 0x100000>; - bus-frequency = <0>; - - ecm-law@0 { - compatible = "fsl,ecm-law"; - reg = <0x0 0x1000>; - fsl,num-laws = <12>; - }; - - ecm@1000 { - compatible = "fsl,p2020-ecm", "fsl,ecm"; - reg = <0x1000 0x1000>; - interrupts = <17 2>; - interrupt-parent = <&mpic>; - }; - - memory-controller@2000 { - compatible = "fsl,p2020-memory-controller"; - reg = <0x2000 0x1000>; - interrupt-parent = <&mpic>; - interrupts = <18 2>; - }; - - i2c@3000 { - #address-cells = <1>; - #size-cells = <0>; - cell-index = <0>; - compatible = "fsl-i2c"; - reg = <0x3000 0x100>; - interrupts = <43 2>; - interrupt-parent = <&mpic>; - dfsrr; - - dimm@51 { - compatible = "at,spd"; - reg = <0x51>; - read-only; - }; - - rtc@68 { - compatible = "dallas,ds1338"; - reg = <0x68>; - }; - - mux@71 { - compatible = "nxp,pca9546"; - reg = <0x71>; - #address-cells = <1>; - #size-cells = <0>; - - i2c@0 { - #address-cells = <1>; - #size-cells = <0>; - reg = <0>; - - eeprom-mb@54 { - compatible = "at,24c02"; - reg = <0x54>; - read-only; - }; - }; - - i2c@1 { - #address-cells = <1>; - #size-cells = <0>; - reg = <1>; - }; - - i2c@2 { - #address-cells = <1>; - #size-cells = <0>; - reg = <2>; - - temp-fan@2e { - compatible = "quanta_ly_hwmon"; - reg = <0x2e>; - }; - }; - - i2c@3 { - #address-cells = <1>; - #size-cells = <0>; - reg = <3>; - }; - }; - - mux@75 { - compatible = "nxp,pca9546"; - reg = <0x75>; - #address-cells = <1>; - #size-cells = <0>; - - i2c@0 { - #address-cells = <1>; - #size-cells = <0>; - reg = <0>; - - psu-1@58 { - compatible = "pmbus"; - reg = <0x58>; - }; - }; - - i2c@1 { - #address-cells = <1>; - #size-cells = <0>; - reg = <1>; - - psu-2@59 { - compatible = "pmbus"; - reg = <0x59>; - }; - }; - - i2c@2 { - #address-cells = <1>; - #size-cells = <0>; - reg = <2>; - - gpio-psu-1@24 { - compatible = "nxp,pca9555"; - reg = <0x24>; - #gpio-cells = <2>; - gpio-controller; - }; - }; - - i2c@3 { - #address-cells = <1>; - #size-cells = <0>; - reg = <3>; - - gpio-psu-2@25 { - compatible = "nxp,pca9555"; - reg = <0x25>; - #gpio-cells = <2>; - gpio-controller; - }; - }; - }; - }; - - i2c@3100 { - #address-cells = <1>; - #size-cells = <0>; - cell-index = <1>; - compatible = "fsl-i2c"; - reg = <0x3100 0x100>; - interrupts = <43 2>; - interrupt-parent = <&mpic>; - dfsrr; - - mux@25 { - compatible = "quanta_ly2_i2c_mux"; - reg = <0x25>; - #address-cells = <1>; - #size-cells = <0>; - - i2c@0 { - #address-cells = <1>; - #size-cells = <0>; - reg = <0>; - - eeprom-sfp-2@50 { - compatible = "at,24c02"; - reg = <0x50>; - read-only; - }; - eeprom-sfp-2@51 { - compatible = "at,24c02"; - reg = <0x51>; - read-only; - }; - }; - - i2c@1 { - #address-cells = <1>; - #size-cells = <0>; - reg = <1>; - - eeprom-sfp-1@50 { - compatible = "at,24c02"; - reg = <0x50>; - read-only; - }; - eeprom-sfp-1@51 { - compatible = "at,24c02"; - reg = <0x51>; - read-only; - }; - }; - - i2c@2 { - #address-cells = <1>; - #size-cells = <0>; - reg = <2>; - - eeprom-sfp-4@50 { - compatible = "at,24c02"; - reg = <0x50>; - read-only; - }; - eeprom-sfp-4@51 { - compatible = "at,24c02"; - reg = <0x51>; - read-only; - }; - }; - - i2c@3 { - #address-cells = <1>; - #size-cells = <0>; - reg = <3>; - - eeprom-sfp-3@50 { - compatible = "at,24c02"; - reg = <0x50>; - read-only; - }; - eeprom-sfp-3@51 { - compatible = "at,24c02"; - reg = <0x51>; - read-only; - }; - }; - - i2c@4 { - #address-cells = <1>; - #size-cells = <0>; - reg = <4>; - - eeprom-sfp-6@50 { - compatible = "at,24c02"; - reg = <0x50>; - read-only; - }; - eeprom-sfp-6@51 { - compatible = "at,24c02"; - reg = <0x51>; - read-only; - }; - }; - - i2c@5 { - #address-cells = <1>; - #size-cells = <0>; - reg = <5>; - - eeprom-sfp-5@50 { - compatible = "at,24c02"; - reg = <0x50>; - read-only; - }; - eeprom-sfp-5@51 { - compatible = "at,24c02"; - reg = <0x51>; - read-only; - }; - }; - - i2c@6 { - #address-cells = <1>; - #size-cells = <0>; - reg = <6>; - - eeprom-sfp-8@50 { - compatible = "at,24c02"; - reg = <0x50>; - read-only; - }; - eeprom-sfp-8@51 { - compatible = "at,24c02"; - reg = <0x51>; - read-only; - }; - }; - - i2c@7 { - #address-cells = <1>; - #size-cells = <0>; - reg = <7>; - - eeprom-sfp-7@50 { - compatible = "at,24c02"; - reg = <0x50>; - read-only; - }; - eeprom-sfp-7@51 { - compatible = "at,24c02"; - reg = <0x51>; - read-only; - }; - }; - - i2c@8 { - #address-cells = <1>; - #size-cells = <0>; - reg = <8>; - - eeprom-sfp-10@50 { - compatible = "at,24c02"; - reg = <0x50>; - read-only; - }; - eeprom-sfp-10@51 { - compatible = "at,24c02"; - reg = <0x51>; - read-only; - }; - }; - - i2c@9 { - #address-cells = <1>; - #size-cells = <0>; - reg = <9>; - - eeprom-sfp-9@50 { - compatible = "at,24c02"; - reg = <0x50>; - read-only; - }; - eeprom-sfp-9@51 { - compatible = "at,24c02"; - reg = <0x51>; - read-only; - }; - }; - - i2c@10 { - #address-cells = <1>; - #size-cells = <0>; - reg = <10>; - - eeprom-sfp-12@50 { - compatible = "at,24c02"; - reg = <0x50>; - read-only; - }; - eeprom-sfp-12@51 { - compatible = "at,24c02"; - reg = <0x51>; - read-only; - }; - }; - - i2c@11 { - #address-cells = <1>; - #size-cells = <0>; - reg = <11>; - - eeprom-sfp-11@50 { - compatible = "at,24c02"; - reg = <0x50>; - read-only; - }; - eeprom-sfp-11@51 { - compatible = "at,24c02"; - reg = <0x51>; - read-only; - }; - }; - - i2c@12 { - #address-cells = <1>; - #size-cells = <0>; - reg = <12>; - - eeprom-sfp-14@50 { - compatible = "at,24c02"; - reg = <0x50>; - read-only; - }; - eeprom-sfp-14@51 { - compatible = "at,24c02"; - reg = <0x51>; - read-only; - }; - }; - - i2c@13 { - #address-cells = <1>; - #size-cells = <0>; - reg = <13>; - - eeprom-sfp-13@50 { - compatible = "at,24c02"; - reg = <0x50>; - read-only; - }; - eeprom-sfp-13@51 { - compatible = "at,24c02"; - reg = <0x51>; - read-only; - }; - }; - - i2c@14 { - #address-cells = <1>; - #size-cells = <0>; - reg = <14>; - - eeprom-sfp-16@50 { - compatible = "at,24c02"; - reg = <0x50>; - read-only; - }; - eeprom-sfp-16@51 { - compatible = "at,24c02"; - reg = <0x51>; - read-only; - }; - }; - - i2c@15 { - #address-cells = <1>; - #size-cells = <0>; - reg = <15>; - - eeprom-sfp-15@50 { - compatible = "at,24c02"; - reg = <0x50>; - read-only; - }; - eeprom-sfp-15@51 { - compatible = "at,24c02"; - reg = <0x51>; - read-only; - }; - }; - }; - - mux@26 { - compatible = "quanta_ly2_i2c_mux"; - reg = <0x26>; - #address-cells = <1>; - #size-cells = <0>; - - i2c@0 { - #address-cells = <1>; - #size-cells = <0>; - reg = <0>; - - eeprom-sfp-18@50 { - compatible = "at,24c02"; - reg = <0x50>; - read-only; - }; - eeprom-sfp-18@51 { - compatible = "at,24c02"; - reg = <0x51>; - read-only; - }; - }; - - i2c@1 { - #address-cells = <1>; - #size-cells = <0>; - reg = <1>; - - eeprom-sfp-17@50 { - compatible = "at,24c02"; - reg = <0x50>; - read-only; - }; - eeprom-sfp-17@51 { - compatible = "at,24c02"; - reg = <0x51>; - read-only; - }; - }; - - i2c@2 { - #address-cells = <1>; - #size-cells = <0>; - reg = <2>; - - eeprom-sfp-20@50 { - compatible = "at,24c02"; - reg = <0x50>; - read-only; - }; - eeprom-sfp-20@51 { - compatible = "at,24c02"; - reg = <0x51>; - read-only; - }; - }; - - i2c@3 { - #address-cells = <1>; - #size-cells = <0>; - reg = <3>; - - eeprom-sfp-19@50 { - compatible = "at,24c02"; - reg = <0x50>; - read-only; - }; - eeprom-sfp-19@51 { - compatible = "at,24c02"; - reg = <0x51>; - read-only; - }; - }; - - i2c@4 { - #address-cells = <1>; - #size-cells = <0>; - reg = <4>; - - eeprom-sfp-22@50 { - compatible = "at,24c02"; - reg = <0x50>; - read-only; - }; - eeprom-sfp-22@51 { - compatible = "at,24c02"; - reg = <0x51>; - read-only; - }; - }; - - i2c@5 { - #address-cells = <1>; - #size-cells = <0>; - reg = <5>; - - eeprom-sfp-21@50 { - compatible = "at,24c02"; - reg = <0x50>; - read-only; - }; - eeprom-sfp-21@51 { - compatible = "at,24c02"; - reg = <0x51>; - read-only; - }; - }; - - i2c@6 { - #address-cells = <1>; - #size-cells = <0>; - reg = <6>; - - eeprom-sfp-24@50 { - compatible = "at,24c02"; - reg = <0x50>; - read-only; - }; - eeprom-sfp-24@51 { - compatible = "at,24c02"; - reg = <0x51>; - read-only; - }; - }; - - i2c@7 { - #address-cells = <1>; - #size-cells = <0>; - reg = <7>; - - eeprom-sfp-23@50 { - compatible = "at,24c02"; - reg = <0x50>; - read-only; - }; - eeprom-sfp-23@51 { - compatible = "at,24c02"; - reg = <0x51>; - read-only; - }; - }; - - i2c@8 { - #address-cells = <1>; - #size-cells = <0>; - reg = <8>; - - eeprom-sfp-26@50 { - compatible = "at,24c02"; - reg = <0x50>; - read-only; - }; - eeprom-sfp-26@51 { - compatible = "at,24c02"; - reg = <0x51>; - read-only; - }; - }; - - i2c@9 { - #address-cells = <1>; - #size-cells = <0>; - reg = <9>; - - eeprom-sfp-25@50 { - compatible = "at,24c02"; - reg = <0x50>; - read-only; - }; - eeprom-sfp-25@51 { - compatible = "at,24c02"; - reg = <0x51>; - read-only; - }; - }; - - i2c@10 { - #address-cells = <1>; - #size-cells = <0>; - reg = <10>; - - eeprom-sfp-28@50 { - compatible = "at,24c02"; - reg = <0x50>; - read-only; - }; - eeprom-sfp-28@51 { - compatible = "at,24c02"; - reg = <0x51>; - read-only; - }; - }; - - i2c@11 { - #address-cells = <1>; - #size-cells = <0>; - reg = <11>; - - eeprom-sfp-27@50 { - compatible = "at,24c02"; - reg = <0x50>; - read-only; - }; - eeprom-sfp-27@51 { - compatible = "at,24c02"; - reg = <0x51>; - read-only; - }; - }; - - i2c@12 { - #address-cells = <1>; - #size-cells = <0>; - reg = <12>; - - eeprom-sfp-30@50 { - compatible = "at,24c02"; - reg = <0x50>; - read-only; - }; - eeprom-sfp-30@51 { - compatible = "at,24c02"; - reg = <0x51>; - read-only; - }; - }; - - i2c@13 { - #address-cells = <1>; - #size-cells = <0>; - reg = <13>; - - eeprom-sfp-29@50 { - compatible = "at,24c02"; - reg = <0x50>; - read-only; - }; - eeprom-sfp-29@51 { - compatible = "at,24c02"; - reg = <0x51>; - read-only; - }; - }; - - i2c@14 { - #address-cells = <1>; - #size-cells = <0>; - reg = <14>; - - eeprom-sfp-32@50 { - compatible = "at,24c02"; - reg = <0x50>; - read-only; - }; - eeprom-sfp-32@51 { - compatible = "at,24c02"; - reg = <0x51>; - read-only; - }; - }; - - i2c@15 { - #address-cells = <1>; - #size-cells = <0>; - reg = <15>; - - eeprom-sfp-31@50 { - compatible = "at,24c02"; - reg = <0x50>; - read-only; - }; - eeprom-sfp-31@51 { - compatible = "at,24c02"; - reg = <0x51>; - read-only; - }; - }; - }; - - mux@27 { - compatible = "quanta_ly2_i2c_mux"; - reg = <0x27>; - #address-cells = <1>; - #size-cells = <0>; - - i2c@0 { - #address-cells = <1>; - #size-cells = <0>; - reg = <0>; - - eeprom-sfp-34@50 { - compatible = "at,24c02"; - reg = <0x50>; - read-only; - }; - eeprom-sfp-34@51 { - compatible = "at,24c02"; - reg = <0x51>; - read-only; - }; - }; - - i2c@1 { - #address-cells = <1>; - #size-cells = <0>; - reg = <1>; - - eeprom-sfp-33@50 { - compatible = "at,24c02"; - reg = <0x50>; - read-only; - }; - eeprom-sfp-33@51 { - compatible = "at,24c02"; - reg = <0x51>; - read-only; - }; - }; - - i2c@2 { - #address-cells = <1>; - #size-cells = <0>; - reg = <2>; - - eeprom-sfp-36@50 { - compatible = "at,24c02"; - reg = <0x50>; - read-only; - }; - eeprom-sfp-36@51 { - compatible = "at,24c02"; - reg = <0x51>; - read-only; - }; - }; - - i2c@3 { - #address-cells = <1>; - #size-cells = <0>; - reg = <3>; - - eeprom-sfp-35@50 { - compatible = "at,24c02"; - reg = <0x50>; - read-only; - }; - eeprom-sfp-35@51 { - compatible = "at,24c02"; - reg = <0x51>; - read-only; - }; - }; - - i2c@4 { - #address-cells = <1>; - #size-cells = <0>; - reg = <4>; - - eeprom-sfp-38@50 { - compatible = "at,24c02"; - reg = <0x50>; - read-only; - }; - eeprom-sfp-38@51 { - compatible = "at,24c02"; - reg = <0x51>; - read-only; - }; - }; - - i2c@5 { - #address-cells = <1>; - #size-cells = <0>; - reg = <5>; - - eeprom-sfp-37@50 { - compatible = "at,24c02"; - reg = <0x50>; - read-only; - }; - eeprom-sfp-37@51 { - compatible = "at,24c02"; - reg = <0x51>; - read-only; - }; - }; - - i2c@6 { - #address-cells = <1>; - #size-cells = <0>; - reg = <6>; - - eeprom-sfp-40@50 { - compatible = "at,24c02"; - reg = <0x50>; - read-only; - }; - eeprom-sfp-40@51 { - compatible = "at,24c02"; - reg = <0x51>; - read-only; - }; - }; - - i2c@7 { - #address-cells = <1>; - #size-cells = <0>; - reg = <7>; - - eeprom-sfp-39@50 { - compatible = "at,24c02"; - reg = <0x50>; - read-only; - }; - eeprom-sfp-39@51 { - compatible = "at,24c02"; - reg = <0x51>; - read-only; - }; - }; - - i2c@8 { - #address-cells = <1>; - #size-cells = <0>; - reg = <8>; - - eeprom-sfp-42@50 { - compatible = "at,24c02"; - reg = <0x50>; - read-only; - }; - eeprom-sfp-42@51 { - compatible = "at,24c02"; - reg = <0x51>; - read-only; - }; - }; - - i2c@9 { - #address-cells = <1>; - #size-cells = <0>; - reg = <9>; - - eeprom-sfp-41@50 { - compatible = "at,24c02"; - reg = <0x50>; - read-only; - }; - eeprom-sfp-41@51 { - compatible = "at,24c02"; - reg = <0x51>; - read-only; - }; - }; - - i2c@10 { - #address-cells = <1>; - #size-cells = <0>; - reg = <10>; - - eeprom-sfp-44@50 { - compatible = "at,24c02"; - reg = <0x50>; - read-only; - }; - eeprom-sfp-44@51 { - compatible = "at,24c02"; - reg = <0x51>; - read-only; - }; - }; - - i2c@11 { - #address-cells = <1>; - #size-cells = <0>; - reg = <11>; - - eeprom-sfp-43@50 { - compatible = "at,24c02"; - reg = <0x50>; - read-only; - }; - eeprom-sfp-43@51 { - compatible = "at,24c02"; - reg = <0x51>; - read-only; - }; - }; - - i2c@12 { - #address-cells = <1>; - #size-cells = <0>; - reg = <12>; - - eeprom-sfp-46@50 { - compatible = "at,24c02"; - reg = <0x50>; - read-only; - }; - eeprom-sfp-46@51 { - compatible = "at,24c02"; - reg = <0x51>; - read-only; - }; - }; - - i2c@13 { - #address-cells = <1>; - #size-cells = <0>; - reg = <13>; - - eeprom-sfp-45@50 { - compatible = "at,24c02"; - reg = <0x50>; - read-only; - }; - eeprom-sfp-45@51 { - compatible = "at,24c02"; - reg = <0x51>; - read-only; - }; - }; - - i2c@14 { - #address-cells = <1>; - #size-cells = <0>; - reg = <14>; - - eeprom-sfp-48@50 { - compatible = "at,24c02"; - reg = <0x50>; - read-only; - }; - eeprom-sfp-48@51 { - compatible = "at,24c02"; - reg = <0x51>; - read-only; - }; - }; - - i2c@15 { - #address-cells = <1>; - #size-cells = <0>; - reg = <15>; - - eeprom-sfp-47@50 { - compatible = "at,24c02"; - reg = <0x50>; - read-only; - }; - eeprom-sfp-47@51 { - compatible = "at,24c02"; - reg = <0x51>; - read-only; - }; - }; - }; - - mux@73 { - compatible = "nxp,pca9546"; - reg = <0x73>; - #address-cells = <1>; - #size-cells = <0>; - - i2c@0 { - #address-cells = <1>; - #size-cells = <0>; - reg = <0>; - - eeprom-qsfp-1@50 { - compatible = "at,24c02"; - reg = <0x50>; - read-only; - }; - eeprom-qsfp-1@51 { - compatible = "at,24c02"; - reg = <0x51>; - read-only; - }; - }; - - i2c@1 { - #address-cells = <1>; - #size-cells = <0>; - reg = <1>; - - eeprom-qsfp-2@50 { - compatible = "at,24c02"; - reg = <0x50>; - read-only; - }; - eeprom-qsfp-2@51 { - compatible = "at,24c02"; - reg = <0x51>; - read-only; - }; - }; - - i2c@2 { - #address-cells = <1>; - #size-cells = <0>; - reg = <2>; - - eeprom-qsfp-3@50 { - compatible = "at,24c02"; - reg = <0x50>; - read-only; - }; - eeprom-qsfp-3@51 { - compatible = "at,24c02"; - reg = <0x51>; - read-only; - }; - }; - - i2c@3 { - #address-cells = <1>; - #size-cells = <0>; - reg = <3>; - - eeprom-qsfp-4@50 { - compatible = "at,24c02"; - reg = <0x50>; - read-only; - }; - eeprom-qsfp-4@51 { - compatible = "at,24c02"; - reg = <0x51>; - read-only; - }; - }; - }; - }; - - serial0: serial@4500 { - cell-index = <0>; - device_type = "serial"; - compatible = "ns16550"; - reg = <0x4500 0x100>; - clock-frequency = <0>; - interrupts = <42 2>; - interrupt-parent = <&mpic>; - }; - - serial1: serial@4600 { - cell-index = <1>; - device_type = "serial"; - compatible = "ns16550"; - reg = <0x4600 0x100>; - clock-frequency = <0>; - interrupts = <42 2>; - interrupt-parent = <&mpic>; - }; - - dma@c300 { - #address-cells = <1>; - #size-cells = <1>; - compatible = "fsl,eloplus-dma"; - reg = <0xc300 0x4>; - ranges = <0x0 0xc100 0x200>; - cell-index = <1>; - dma-channel@0 { - compatible = "fsl,eloplus-dma-channel"; - reg = <0x0 0x80>; - cell-index = <0>; - interrupt-parent = <&mpic>; - interrupts = <76 2>; - }; - dma-channel@80 { - compatible = "fsl,eloplus-dma-channel"; - reg = <0x80 0x80>; - cell-index = <1>; - interrupt-parent = <&mpic>; - interrupts = <77 2>; - }; - dma-channel@100 { - compatible = "fsl,eloplus-dma-channel"; - reg = <0x100 0x80>; - cell-index = <2>; - interrupt-parent = <&mpic>; - interrupts = <78 2>; - }; - dma-channel@180 { - compatible = "fsl,eloplus-dma-channel"; - reg = <0x180 0x80>; - cell-index = <3>; - interrupt-parent = <&mpic>; - interrupts = <79 2>; - }; - }; - - gpio: gpio-controller@f000 { - #gpio-cells = <2>; - compatible = "fsl,mpc8572-gpio"; - reg = <0xf000 0x100>; - interrupts = <47 0x2>; - interrupt-parent = <&mpic>; - gpio-controller; - }; - - l2: l2-cache-controller@20000 { - compatible = "fsl,p2020-l2-cache-controller"; - reg = <0x20000 0x1000>; - cache-line-size = <32>; // 32 bytes - cache-size = <0x80000>; // L2,512K - interrupt-parent = <&mpic>; - interrupts = <16 2>; - }; - - dma@21300 { - #address-cells = <1>; - #size-cells = <1>; - compatible = "fsl,eloplus-dma"; - reg = <0x21300 0x4>; - ranges = <0x0 0x21100 0x200>; - cell-index = <0>; - dma-channel@0 { - compatible = "fsl,eloplus-dma-channel"; - reg = <0x0 0x80>; - cell-index = <0>; - interrupt-parent = <&mpic>; - interrupts = <20 2>; - }; - dma-channel@80 { - compatible = "fsl,eloplus-dma-channel"; - reg = <0x80 0x80>; - cell-index = <1>; - interrupt-parent = <&mpic>; - interrupts = <21 2>; - }; - dma-channel@100 { - compatible = "fsl,eloplus-dma-channel"; - reg = <0x100 0x80>; - cell-index = <2>; - interrupt-parent = <&mpic>; - interrupts = <22 2>; - }; - dma-channel@180 { - compatible = "fsl,eloplus-dma-channel"; - reg = <0x180 0x80>; - cell-index = <3>; - interrupt-parent = <&mpic>; - interrupts = <23 2>; - }; - }; - -/* usb@22000 { - #address-cells = <1>; - #size-cells = <0>; - compatible = "fsl-usb2-dr"; - reg = <0x22000 0x1000>; - interrupt-parent = <&mpic>; - interrupts = <28 0x2>; - phy_type = "ulpi"; - }; -*/ - ptp_timer: ptimer@24e00 { - compatible = "fsl,gianfar-ptp-timer"; - reg = <0x24e00 0xb0>; - }; - - enet0: ethernet@24000 { - #address-cells = <1>; - #size-cells = <1>; - cell-index = <0>; - device_type = "network"; - model = "eTSEC"; - compatible = "gianfar"; - reg = <0x24000 0x1000>; - ranges = <0x0 0x24000 0x1000>; - local-mac-address = [ 00 00 00 00 00 00 ]; - interrupts = <29 2 30 2 34 2>; - interrupt-parent = <&mpic>; - phy-connection-type = "sgmii"; - phy-handle = <&phy0>; - tbi-handle = <&tbi0>; - }; - - mdio@24520 { - #address-cells = <1>; - #size-cells = <0>; - compatible = "fsl,gianfar-mdio"; - reg = <0x24520 0x20>; - - phy0: ethernet-phy@0 { - reg = <0x1>; - device_type = "ethernet-phy"; - }; - tbi0: tbi-phy@11 { - reg = <0x11>; - device_type = "tbi-phy"; - }; - }; - - sdhci@2e000 { - compatible = "fsl,p2020-esdhc", "fsl,esdhc"; - reg = <0x2e000 0x1000>; - interrupts = <72 0x2>; - interrupt-parent = <&mpic>; - clock-frequency = <0>; - }; - - crypto@30000 { - compatible = "fsl,sec3.1", "fsl,sec3.0", "fsl,sec2.4", - "fsl,sec2.2", "fsl,sec2.1", "fsl,sec2.0"; - reg = <0x30000 0x10000>; - interrupts = <45 2 58 2>; - interrupt-parent = <&mpic>; - fsl,num-channels = <4>; - fsl,channel-fifo-len = <24>; - fsl,exec-units-mask = <0xbfe>; - fsl,descriptor-types-mask = <0x3ab0ebf>; - fsl,multi-host-mode = "dual"; - fsl,channel-remap = <0x3>; - }; - - mpic: pic@40000 { - interrupt-controller; - #address-cells = <0>; - #interrupt-cells = <2>; - reg = <0x40000 0x40000>; - compatible = "chrp,open-pic"; - device_type = "open-pic"; - }; - - mpic_msgr_block0: message@41400 { - compatible = "fsl,mpic-v3.1-msgr"; - reg = <0x41400 0x200>; - interrupts = < - 0xb0 2 - 0xb1 2 - 0xb2 2 - 0xb3 2>; - interrupt-parent = <&mpic>; - }; - - mpic_msgr_block1: message@42400 { - compatible = "fsl,mpic-v3.1-msgr"; - reg = <0x42400 0x200>; - interrupts = < - 0xb4 2 - 0xb5 2 - 0xb6 2 - 0xb7 2>; - interrupt-parent = <&mpic>; - }; - - msi@41600 { - compatible = "fsl,p2020-msi", "fsl,mpic-msi"; - reg = <0x41600 0x80>; - msi-available-ranges = <0 0x100>; - interrupts = < - 0xe0 0 - 0xe1 0 - 0xe2 0 - 0xe3 0 - 0xe4 0 - 0xe5 0 - 0xe6 0 - 0xe7 0>; - interrupt-parent = <&mpic>; - }; - - global-utilities@e0000 { - compatible = "fsl,p2020-guts"; - reg = <0xe0000 0x1000>; - fsl,has-rstcr; - }; - }; - - pci2: pcie@ffe0a000 { - compatible = "fsl,mpc8548-pcie"; - device_type = "pci"; - #interrupt-cells = <1>; - #size-cells = <2>; - #address-cells = <3>; - reg = <0 0xffe0a000 0 0x1000>; - bus-range = <0 255>; - ranges = <0x2000000 0x0 0xc0000000 0 0xc0000000 0x0 0x20000000 - 0x1000000 0x0 0x00000000 0 0xffc20000 0x0 0x10000>; - clock-frequency = <100000000>; - interrupt-parent = <&mpic>; - interrupts = <26 2>; - interrupt-map-mask = <0xf800 0x0 0x0 0x7>; - interrupt-map = < - /* IDSEL 0x0 */ - 0000 0x0 0x0 0x1 &mpic 0x0 0x1 - 0000 0x0 0x0 0x2 &mpic 0x1 0x1 - 0000 0x0 0x0 0x3 &mpic 0x2 0x1 - 0000 0x0 0x0 0x4 &mpic 0x3 0x1 - >; - pcie@0 { - reg = <0x0 0x0 0x0 0x0 0x0>; - #size-cells = <2>; - #address-cells = <3>; - device_type = "pci"; - ranges = <0x2000000 0x0 0xc0000000 - 0x2000000 0x0 0xc0000000 - 0x0 0x20000000 - - 0x1000000 0x0 0x0 - 0x1000000 0x0 0x0 - 0x0 0x10000>; - }; - }; -}; diff --git a/packages/platforms/quanta/powerpc/ly2/platform-config/r0/src/lib/etc/fancontrol b/packages/platforms/quanta/powerpc/ly2/platform-config/r0/src/lib/etc/fancontrol deleted file mode 100644 index bc8dff273..000000000 --- a/packages/platforms/quanta/powerpc/ly2/platform-config/r0/src/lib/etc/fancontrol +++ /dev/null @@ -1,16 +0,0 @@ -############################################################ -# -# Platform: Quanta LY2 -# -############################################################ - -INTERVAL=10 -DEVPATH=hwmon2=devices/soc@ffe00000/ffe03000.i2c/i2c-0/i2c-4/4-002e -DEVNAME=hwmon2=quanta_ly_hwmon -FCTEMPS=hwmon2/device/pwm1=hwmon2/device/temp1_input hwmon2/device/pwm2=hwmon2/device/temp1_input hwmon2/device/pwm3=hwmon2/device/temp1_input hwmon2/device/pwm4=hwmon2/device/temp1_input -FCFANS=hwmon2/device/pwm1=hwmon2/device/fan1_input hwmon2/device/pwm2=hwmon2/device/fan2_input hwmon2/device/pwm3=hwmon2/device/fan3_input hwmon2/device/pwm4=hwmon2/device/fan4_input -MINTEMP=hwmon2/device/pwm1=20 hwmon2/device/pwm2=20 hwmon2/device/pwm3=20 hwmon2/device/pwm4=20 -MAXTEMP=hwmon2/device/pwm1=60 hwmon2/device/pwm2=60 hwmon2/device/pwm3=60 hwmon2/device/pwm4=60 -MINSTART=hwmon2/device/pwm1=150 hwmon2/device/pwm2=150 hwmon2/device/pwm3=150 hwmon2/device/pwm4=150 -MINSTOP=hwmon2/device/pwm1=0 hwmon2/device/pwm2=0 hwmon2/device/pwm3=0 hwmon2/device/pwm4=0 -MAXPWM=hwmon2/device/pwm1=254 hwmon2/device/pwm2=254 hwmon2/device/pwm3=254 hwmon2/device/pwm4=254 diff --git a/packages/platforms/quanta/powerpc/ly2/platform-config/r0/src/lib/etc/fancontrol.b2f b/packages/platforms/quanta/powerpc/ly2/platform-config/r0/src/lib/etc/fancontrol.b2f deleted file mode 100644 index 6b4befacb..000000000 --- a/packages/platforms/quanta/powerpc/ly2/platform-config/r0/src/lib/etc/fancontrol.b2f +++ /dev/null @@ -1,16 +0,0 @@ -############################################################ -# -# Platform: Quanta LY2 -# -############################################################ - -INTERVAL=10 -DEVPATH=hwmon2=devices/soc@ffe00000/ffe03000.i2c/i2c-0/i2c-4/4-002e -DEVNAME=hwmon2=quanta_ly_hwmon -FCTEMPS=hwmon2/device/pwm5=hwmon2/device/temp1_input hwmon2/device/pwm6=hwmon2/device/temp1_input hwmon2/device/pwm7=hwmon2/device/temp1_input hwmon2/device/pwm8=hwmon2/device/temp1_input -FCFANS=hwmon2/device/pwm5=hwmon2/device/fan5_input hwmon2/device/pwm6=hwmon2/device/fan6_input hwmon2/device/pwm7=hwmon2/device/fan7_input hwmon2/device/pwm8=hwmon2/device/fan8_input -MINTEMP=hwmon2/device/pwm5=20 hwmon2/device/pwm6=20 hwmon2/device/pwm7=20 hwmon2/device/pwm8=20 -MAXTEMP=hwmon2/device/pwm5=60 hwmon2/device/pwm6=60 hwmon2/device/pwm7=60 hwmon2/device/pwm8=60 -MINSTART=hwmon2/device/pwm5=150 hwmon2/device/pwm6=150 hwmon2/device/pwm7=150 hwmon2/device/pwm8=150 -MINSTOP=hwmon2/device/pwm5=0 hwmon2/device/pwm6=0 hwmon2/device/pwm7=0 hwmon2/device/pwm8=0 -MAXPWM=hwmon2/device/pwm5=254 hwmon2/device/pwm6=254 hwmon2/device/pwm7=254 hwmon2/device/pwm8=254 diff --git a/packages/platforms/quanta/powerpc/ly2/platform-config/r0/src/lib/etc/sensors3.conf b/packages/platforms/quanta/powerpc/ly2/platform-config/r0/src/lib/etc/sensors3.conf deleted file mode 100644 index 28825e476..000000000 --- a/packages/platforms/quanta/powerpc/ly2/platform-config/r0/src/lib/etc/sensors3.conf +++ /dev/null @@ -1,9 +0,0 @@ -############################################################ -# -# Platform: Quanta LY2 -# -############################################################ -# -# This sensor data is now processed by the platform code. -# -############################################################ diff --git a/packages/platforms/quanta/powerpc/ly2/platform-config/r0/src/lib/powerpc-quanta-ly2-r0.yml b/packages/platforms/quanta/powerpc/ly2/platform-config/r0/src/lib/powerpc-quanta-ly2-r0.yml deleted file mode 100644 index b60e7b626..000000000 --- a/packages/platforms/quanta/powerpc/ly2/platform-config/r0/src/lib/powerpc-quanta-ly2-r0.yml +++ /dev/null @@ -1,29 +0,0 @@ ---- - -###################################################################### -# -# platform-config for LY2 -# -###################################################################### - -powerpc-quanta-ly2-r0: - - flat_image_tree: - kernel: - <<: *e500v-3-16 - dtb: - =: powerpc-quanta-ly2-r0.dtb - package: onl-platform-build-powerpc-quanta-ly2-r0:powerpc - - loader: - device: /dev/mmcblk0 - nos_bootcmds: - - mmc part 0 - - ext2load mmc 0:1 $onl_loadaddr $onl_itb - - "bootm $onl_loadaddr#$onl_platform" - - environment: - - device: /dev/mtd2 - env_offset: 0x00000000 - env_size: 0x00002000 - sector_size: 0x00020000 diff --git a/packages/platforms/quanta/powerpc/ly2/platform-config/r0/src/lib/sbin/gpio_init b/packages/platforms/quanta/powerpc/ly2/platform-config/r0/src/lib/sbin/gpio_init deleted file mode 100755 index c03d00df0..000000000 --- a/packages/platforms/quanta/powerpc/ly2/platform-config/r0/src/lib/sbin/gpio_init +++ /dev/null @@ -1,209 +0,0 @@ -#!/bin/sh -set -e - -# fport 1 (pport 0.1) MOD_ABS --> gpio168 -echo "168" > /sys/class/gpio/export -# fport 1 (pport 0.1) RESET missing - -# fport 2 (pport 0.2) MOD_ABS --> gpio169 -echo "169" > /sys/class/gpio/export -# fport 2 (pport 0.2) RESET missing - -# fport 3 (pport 0.3) MOD_ABS --> gpio170 -echo "170" > /sys/class/gpio/export -# fport 3 (pport 0.3) RESET missing - -# fport 4 (pport 0.4) MOD_ABS --> gpio171 -echo "171" > /sys/class/gpio/export -# fport 4 (pport 0.4) RESET missing - -# fport 5 (pport 0.5) MOD_ABS --> gpio172 -echo "172" > /sys/class/gpio/export -# fport 5 (pport 0.5) RESET missing - -# fport 6 (pport 0.6) MOD_ABS --> gpio173 -echo "173" > /sys/class/gpio/export -# fport 6 (pport 0.6) RESET missing - -# fport 7 (pport 0.7) MOD_ABS --> gpio174 -echo "174" > /sys/class/gpio/export -# fport 7 (pport 0.7) RESET missing - -# fport 8 (pport 0.8) MOD_ABS --> gpio175 -echo "175" > /sys/class/gpio/export -# fport 8 (pport 0.8) RESET missing - -# fport 9 (pport 0.9) MOD_ABS --> gpio176 -echo "176" > /sys/class/gpio/export -# fport 9 (pport 0.9) RESET missing - -# fport 10 (pport 0.10) MOD_ABS --> gpio177 -echo "177" > /sys/class/gpio/export -# fport 10 (pport 0.10) RESET missing - -# fport 11 (pport 0.11) MOD_ABS --> gpio178 -echo "178" > /sys/class/gpio/export -# fport 11 (pport 0.11) RESET missing - -# fport 12 (pport 0.12) MOD_ABS --> gpio179 -echo "179" > /sys/class/gpio/export -# fport 12 (pport 0.12) RESET missing - -# fport 13 (pport 0.13) MOD_ABS --> gpio180 -echo "180" > /sys/class/gpio/export -# fport 13 (pport 0.13) RESET missing - -# fport 14 (pport 0.14) MOD_ABS --> gpio181 -echo "181" > /sys/class/gpio/export -# fport 14 (pport 0.14) RESET missing - -# fport 15 (pport 0.15) MOD_ABS --> gpio182 -echo "182" > /sys/class/gpio/export -# fport 15 (pport 0.15) RESET missing - -# fport 16 (pport 0.16) MOD_ABS --> gpio183 -echo "183" > /sys/class/gpio/export -# fport 16 (pport 0.16) RESET missing - -# fport 17 (pport 0.17) MOD_ABS --> gpio144 -echo "144" > /sys/class/gpio/export -# fport 17 (pport 0.17) RESET missing - -# fport 18 (pport 0.18) MOD_ABS --> gpio145 -echo "145" > /sys/class/gpio/export -# fport 18 (pport 0.18) RESET missing - -# fport 19 (pport 0.19) MOD_ABS --> gpio146 -echo "146" > /sys/class/gpio/export -# fport 19 (pport 0.19) RESET missing - -# fport 20 (pport 0.20) MOD_ABS --> gpio147 -echo "147" > /sys/class/gpio/export -# fport 20 (pport 0.20) RESET missing - -# fport 21 (pport 0.21) MOD_ABS --> gpio148 -echo "148" > /sys/class/gpio/export -# fport 21 (pport 0.21) RESET missing - -# fport 22 (pport 0.22) MOD_ABS --> gpio149 -echo "149" > /sys/class/gpio/export -# fport 22 (pport 0.22) RESET missing - -# fport 23 (pport 0.23) MOD_ABS --> gpio150 -echo "150" > /sys/class/gpio/export -# fport 23 (pport 0.23) RESET missing - -# fport 24 (pport 0.24) MOD_ABS --> gpio151 -echo "151" > /sys/class/gpio/export -# fport 24 (pport 0.24) RESET missing - -# fport 25 (pport 0.25) MOD_ABS --> gpio152 -echo "152" > /sys/class/gpio/export -# fport 25 (pport 0.25) RESET missing - -# fport 26 (pport 0.26) MOD_ABS --> gpio153 -echo "153" > /sys/class/gpio/export -# fport 26 (pport 0.26) RESET missing - -# fport 27 (pport 0.27) MOD_ABS --> gpio154 -echo "154" > /sys/class/gpio/export -# fport 27 (pport 0.27) RESET missing - -# fport 28 (pport 0.28) MOD_ABS --> gpio155 -echo "155" > /sys/class/gpio/export -# fport 28 (pport 0.28) RESET missing - -# fport 29 (pport 0.29) MOD_ABS --> gpio156 -echo "156" > /sys/class/gpio/export -# fport 29 (pport 0.29) RESET missing - -# fport 30 (pport 0.30) MOD_ABS --> gpio157 -echo "157" > /sys/class/gpio/export -# fport 30 (pport 0.30) RESET missing - -# fport 31 (pport 0.31) MOD_ABS --> gpio158 -echo "158" > /sys/class/gpio/export -# fport 31 (pport 0.31) RESET missing - -# fport 32 (pport 0.32) MOD_ABS --> gpio159 -echo "159" > /sys/class/gpio/export -# fport 32 (pport 0.32) RESET missing - -# fport 33 (pport 0.33) MOD_ABS --> gpio120 -echo "120" > /sys/class/gpio/export -# fport 33 (pport 0.33) RESET missing - -# fport 34 (pport 0.34) MOD_ABS --> gpio121 -echo "121" > /sys/class/gpio/export -# fport 34 (pport 0.34) RESET missing - -# fport 35 (pport 0.35) MOD_ABS --> gpio122 -echo "122" > /sys/class/gpio/export -# fport 35 (pport 0.35) RESET missing - -# fport 36 (pport 0.36) MOD_ABS --> gpio123 -echo "123" > /sys/class/gpio/export -# fport 36 (pport 0.36) RESET missing - -# fport 37 (pport 0.37) MOD_ABS --> gpio124 -echo "124" > /sys/class/gpio/export -# fport 37 (pport 0.37) RESET missing - -# fport 38 (pport 0.38) MOD_ABS --> gpio125 -echo "125" > /sys/class/gpio/export -# fport 38 (pport 0.38) RESET missing - -# fport 39 (pport 0.39) MOD_ABS --> gpio126 -echo "126" > /sys/class/gpio/export -# fport 39 (pport 0.39) RESET missing - -# fport 40 (pport 0.40) MOD_ABS --> gpio127 -echo "127" > /sys/class/gpio/export -# fport 40 (pport 0.40) RESET missing - -# fport 41 (pport 0.41) MOD_ABS --> gpio128 -echo "128" > /sys/class/gpio/export -# fport 41 (pport 0.41) RESET missing - -# fport 42 (pport 0.42) MOD_ABS --> gpio129 -echo "129" > /sys/class/gpio/export -# fport 42 (pport 0.42) RESET missing - -# fport 43 (pport 0.43) MOD_ABS --> gpio130 -echo "130" > /sys/class/gpio/export -# fport 43 (pport 0.43) RESET missing - -# fport 44 (pport 0.44) MOD_ABS --> gpio131 -echo "131" > /sys/class/gpio/export -# fport 44 (pport 0.44) RESET missing - -# fport 45 (pport 0.45) MOD_ABS --> gpio132 -echo "132" > /sys/class/gpio/export -# fport 45 (pport 0.45) RESET missing - -# fport 46 (pport 0.46) MOD_ABS --> gpio133 -echo "133" > /sys/class/gpio/export -# fport 46 (pport 0.46) RESET missing - -# fport 47 (pport 0.47) MOD_ABS --> gpio134 -echo "134" > /sys/class/gpio/export -# fport 47 (pport 0.47) RESET missing - -# fport 48 (pport 0.48) MOD_ABS --> gpio135 -echo "135" > /sys/class/gpio/export -# fport 48 (pport 0.48) RESET missing - -# fport 49 (pport 0.49) MOD_ABS missing -# fport 49 (pport 0.49) RESET missing - -# fport 50 (pport 0.50) MOD_ABS missing -# fport 50 (pport 0.50) RESET missing - -# fport 51 (pport 0.51) MOD_ABS missing -# fport 51 (pport 0.51) RESET missing - -# fport 52 (pport 0.52) MOD_ABS missing -# fport 52 (pport 0.52) RESET missing - - -exit 0 diff --git a/packages/platforms/quanta/powerpc/ly2/platform-config/r0/src/lib/sbin/sfpdump b/packages/platforms/quanta/powerpc/ly2/platform-config/r0/src/lib/sbin/sfpdump deleted file mode 100755 index d6a9d392c..000000000 --- a/packages/platforms/quanta/powerpc/ly2/platform-config/r0/src/lib/sbin/sfpdump +++ /dev/null @@ -1,52 +0,0 @@ -#!/bin/bash -############################################################ -# -# -# Copyright 2013, 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. -# -# -############################################################ -# -# Platform: Quanta LY2 -# -# Linux assigns I2C bus numbers as it enumerates the I2C master/mux -# devices in the device tree breadth-first. The bus numbers below may -# change if the device tree changes. -# -# XXX roth -- does not reflect the device ordering the DTS file! -# -############################################################ - -base=/sys/devices/soc.0/ffe03100.i2c/i2c-1 -first=`/bin/ls -1d $base/i2c-* | /usr/bin/head -1` -first=${first##*/} -first=${first#i2c-} - -for port in $(seq 1 1 48); do - mux=$[ ( $port - 1 ) / 16 ] - dev=$[ ( ( $port - 1 ) & 0xF) ^ 0x1 ] - gdev=$[ $first + 4 + ( $mux * 16 ) + $dev ] - eep=$(printf "%s/i2c-%d/%d-0050/eeprom" $base $gdev $gdev) - echo "SFP port $port:" - hexdump -C $eep 2>/dev/null -done - -for port in $(seq 49 1 52); do - gdev=$[ $port - 49 + $first ] - eep=$(printf "%s/i2c-%d/%d-0050/eeprom" $base $gdev $gdev) - echo "QSFP port $port:" - hexdump -C $eep 2>/dev/null -done diff --git a/packages/platforms/quanta/powerpc/ly2/platform-config/r0/src/python/powerpc_quanta_ly2_r0/__init__.py b/packages/platforms/quanta/powerpc/ly2/platform-config/r0/src/python/powerpc_quanta_ly2_r0/__init__.py deleted file mode 100755 index 50aa756a4..000000000 --- a/packages/platforms/quanta/powerpc/ly2/platform-config/r0/src/python/powerpc_quanta_ly2_r0/__init__.py +++ /dev/null @@ -1,51 +0,0 @@ -#!/usr/bin/python - -import subprocess -from onl.platform.base import * -from onl.platform.quanta import * - -class OnlPlatform_powerpc_quanta_ly2_r0(OnlPlatformQuanta, - OnlPlatformPortConfig_48x10_4x40): - PLATFORM='powerpc-quanta-ly2-r0' - MODEL="LY2" - """ 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.2200" - - def baseconfig(self): - self.insmod("quanta-ly2-i2c-mux.ko") - self.insmod("quanta-ly-hwmon.ko") - subprocess.check_call("%s/sbin/gpio_init" % self.basedir_onl()) - - fan_dir='/sys/bus/i2c/devices/4-002e/fan_dir' - if os.path.exists(fan_dir): - with open(fan_dir) as f: - data = f.read() - if data == 'front-to-back': - platform_fancontrol="%s/etc/fancontrol" % self.basedir_onl() - elif data == 'back-to-front': - platform_fancontrol="%s/etc/fancontrol.b2f" % self.basedir_onl() - else: - sys.exit(1) - else: - sys.exit(1) - FAN_CONF = '/etc/fancontrol' - if os.path.exists(FAN_CONF): - os.unlink(FAN_CONF) - if os.path.exists(platform_fancontrol): - os.symlink(platform_fancontrol, FAN_CONF) - else: - sys.exit(1) - - return True - - - - - diff --git a/packages/platforms/quanta/powerpc/modules/Makefile b/packages/platforms/quanta/powerpc/modules/Makefile deleted file mode 100644 index 003238cf6..000000000 --- a/packages/platforms/quanta/powerpc/modules/Makefile +++ /dev/null @@ -1 +0,0 @@ -include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/quanta/powerpc/modules/PKG.yml b/packages/platforms/quanta/powerpc/modules/PKG.yml deleted file mode 100644 index 8dfdb1a2e..000000000 --- a/packages/platforms/quanta/powerpc/modules/PKG.yml +++ /dev/null @@ -1 +0,0 @@ -!include $ONL_TEMPLATES/no-arch-vendor-modules.yml ARCH=powerpc VENDOR=quanta diff --git a/packages/platforms/quanta/vendor-config/Makefile b/packages/platforms/quanta/vendor-config/Makefile deleted file mode 100644 index 003238cf6..000000000 --- a/packages/platforms/quanta/vendor-config/Makefile +++ /dev/null @@ -1 +0,0 @@ -include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/quanta/vendor-config/PKG.yml b/packages/platforms/quanta/vendor-config/PKG.yml deleted file mode 100644 index 1427c55cd..000000000 --- a/packages/platforms/quanta/vendor-config/PKG.yml +++ /dev/null @@ -1 +0,0 @@ -!include $ONL_TEMPLATES/platform-config-vendor.yml VENDOR=quanta Vendor=Quanta diff --git a/packages/platforms/quanta/vendor-config/src/python/quanta/__init__.py b/packages/platforms/quanta/vendor-config/src/python/quanta/__init__.py deleted file mode 100644 index 44a2951b8..000000000 --- a/packages/platforms/quanta/vendor-config/src/python/quanta/__init__.py +++ /dev/null @@ -1,7 +0,0 @@ -#!/usr/bin/python - -from onl.platform.base import * - -class OnlPlatformQuanta(OnlPlatformBase): - MANUFACTURER='Quanta' - PRIVATE_ENTERPRISE_NUMBER=7244 diff --git a/packages/platforms/quanta/x86-64/Makefile b/packages/platforms/quanta/x86-64/Makefile deleted file mode 100644 index 003238cf6..000000000 --- a/packages/platforms/quanta/x86-64/Makefile +++ /dev/null @@ -1 +0,0 @@ -include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/quanta/x86-64/ix1-rangeley/.gitignore b/packages/platforms/quanta/x86-64/ix1-rangeley/.gitignore deleted file mode 100755 index 4e2a8de98..000000000 --- a/packages/platforms/quanta/x86-64/ix1-rangeley/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -*x86*64*quanta*ix1*rangeley.mk -onlpdump.mk diff --git a/packages/platforms/quanta/x86-64/ix1-rangeley/Makefile b/packages/platforms/quanta/x86-64/ix1-rangeley/Makefile deleted file mode 100755 index 003238cf6..000000000 --- a/packages/platforms/quanta/x86-64/ix1-rangeley/Makefile +++ /dev/null @@ -1 +0,0 @@ -include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/quanta/x86-64/ix1-rangeley/modules/Makefile b/packages/platforms/quanta/x86-64/ix1-rangeley/modules/Makefile deleted file mode 100755 index 003238cf6..000000000 --- a/packages/platforms/quanta/x86-64/ix1-rangeley/modules/Makefile +++ /dev/null @@ -1 +0,0 @@ -include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/quanta/x86-64/ix1-rangeley/modules/PKG.yml b/packages/platforms/quanta/x86-64/ix1-rangeley/modules/PKG.yml deleted file mode 100755 index c5717b02c..000000000 --- a/packages/platforms/quanta/x86-64/ix1-rangeley/modules/PKG.yml +++ /dev/null @@ -1 +0,0 @@ -!include $ONL_TEMPLATES/platform-modules.yml ARCH=amd64 VENDOR=quanta BASENAME=x86-64-quanta-ix1-rangeley KERNELS="onl-kernel-3.16-lts-x86-64-all:amd64" diff --git a/packages/platforms/quanta/x86-64/ix1-rangeley/modules/builds/.gitignore b/packages/platforms/quanta/x86-64/ix1-rangeley/modules/builds/.gitignore deleted file mode 100755 index a65b41774..000000000 --- a/packages/platforms/quanta/x86-64/ix1-rangeley/modules/builds/.gitignore +++ /dev/null @@ -1 +0,0 @@ -lib diff --git a/packages/platforms/quanta/x86-64/ix1-rangeley/modules/builds/Makefile b/packages/platforms/quanta/x86-64/ix1-rangeley/modules/builds/Makefile deleted file mode 100755 index ba14cf990..000000000 --- a/packages/platforms/quanta/x86-64/ix1-rangeley/modules/builds/Makefile +++ /dev/null @@ -1,6 +0,0 @@ -KERNELS := onl-kernel-3.16-lts-x86-64-all:amd64 -KMODULES := $(wildcard *.c) -VENDOR := quanta -BASENAME := x86-64-quanta-ix1-rangeley -ARCH := x86_64 -include $(ONL)/make/kmodule.mk diff --git a/packages/platforms/quanta/x86-64/ix1-rangeley/modules/builds/quanta_platform_ix1.c b/packages/platforms/quanta/x86-64/ix1-rangeley/modules/builds/quanta_platform_ix1.c deleted file mode 100755 index 3372cb5a8..000000000 --- a/packages/platforms/quanta/x86-64/ix1-rangeley/modules/builds/quanta_platform_ix1.c +++ /dev/null @@ -1,330 +0,0 @@ -/* - * 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-ix1" - -#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_ix1, - i2c_type_quanta_ix1_hwmon, -}; - -char *i2c_type_names[] = { - "spd", - "ds1339", - "pca9546", - "pca9548", - "pca9554", - "pca9555", - "pca9698", - "CPLD-QSFP28", - "24c02", - "qci_pmbus_ix1", - "quanta_ix1_hwmon", -}; - -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_ix1_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_quanta_ix1_hwmon, .addr = 0x4e, .name = "PSoc\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_ix1, .addr = 0x5f, .name = "PSU_1\0" }, - { .parent_bus = (0x18 + 1), .type = i2c_type_qci_pmbus_ix1, .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 - -/* <--auto.start.xmacro(ALL).define> */ -/* */ - -/* <--auto.start.xenum(ALL).define> */ -/* */ - - diff --git a/packages/platforms/quanta/x86-64/ix1-rangeley/onlp/builds/x86_64_quanta_ix1_rangeley/module/inc/x86_64_quanta_ix1_rangeley/x86_64_quanta_ix1_rangeley_config.h b/packages/platforms/quanta/x86-64/ix1-rangeley/onlp/builds/x86_64_quanta_ix1_rangeley/module/inc/x86_64_quanta_ix1_rangeley/x86_64_quanta_ix1_rangeley_config.h deleted file mode 100755 index ff96ca352..000000000 --- a/packages/platforms/quanta/x86-64/ix1-rangeley/onlp/builds/x86_64_quanta_ix1_rangeley/module/inc/x86_64_quanta_ix1_rangeley/x86_64_quanta_ix1_rangeley_config.h +++ /dev/null @@ -1,167 +0,0 @@ -/**************************************************************************//** - * - * @file - * @brief x86_64_quanta_ix1_rangeley Configuration Header - * - * @addtogroup x86_64_quanta_ix1_rangeley-config - * @{ - * - *****************************************************************************/ -#ifndef __X86_64_QUANTA_IX1_RANGELEY_CONFIG_H__ -#define __X86_64_QUANTA_IX1_RANGELEY_CONFIG_H__ - -#ifdef GLOBAL_INCLUDE_CUSTOM_CONFIG -#include -#endif -#ifdef X86_64_QUANTA_IX1_RANGELEY_INCLUDE_CUSTOM_CONFIG -#include -#endif - -/* */ -#include -/** - * X86_64_QUANTA_IX1_RANGELEY_CONFIG_INCLUDE_LOGGING - * - * Include or exclude logging. */ - - -#ifndef X86_64_QUANTA_IX1_RANGELEY_CONFIG_INCLUDE_LOGGING -#define X86_64_QUANTA_IX1_RANGELEY_CONFIG_INCLUDE_LOGGING 1 -#endif - -/** - * X86_64_QUANTA_IX1_RANGELEY_CONFIG_LOG_OPTIONS_DEFAULT - * - * Default enabled log options. */ - - -#ifndef X86_64_QUANTA_IX1_RANGELEY_CONFIG_LOG_OPTIONS_DEFAULT -#define X86_64_QUANTA_IX1_RANGELEY_CONFIG_LOG_OPTIONS_DEFAULT AIM_LOG_OPTIONS_DEFAULT -#endif - -/** - * X86_64_QUANTA_IX1_RANGELEY_CONFIG_LOG_BITS_DEFAULT - * - * Default enabled log bits. */ - - -#ifndef X86_64_QUANTA_IX1_RANGELEY_CONFIG_LOG_BITS_DEFAULT -#define X86_64_QUANTA_IX1_RANGELEY_CONFIG_LOG_BITS_DEFAULT AIM_LOG_BITS_DEFAULT -#endif - -/** - * X86_64_QUANTA_IX1_RANGELEY_CONFIG_LOG_CUSTOM_BITS_DEFAULT - * - * Default enabled custom log bits. */ - - -#ifndef X86_64_QUANTA_IX1_RANGELEY_CONFIG_LOG_CUSTOM_BITS_DEFAULT -#define X86_64_QUANTA_IX1_RANGELEY_CONFIG_LOG_CUSTOM_BITS_DEFAULT 0 -#endif - -/** - * X86_64_QUANTA_IX1_RANGELEY_CONFIG_PORTING_STDLIB - * - * Default all porting macros to use the C standard libraries. */ - - -#ifndef X86_64_QUANTA_IX1_RANGELEY_CONFIG_PORTING_STDLIB -#define X86_64_QUANTA_IX1_RANGELEY_CONFIG_PORTING_STDLIB 1 -#endif - -/** - * X86_64_QUANTA_IX1_RANGELEY_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS - * - * Include standard library headers for stdlib porting macros. */ - - -#ifndef X86_64_QUANTA_IX1_RANGELEY_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS -#define X86_64_QUANTA_IX1_RANGELEY_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS X86_64_QUANTA_IX1_RANGELEY_CONFIG_PORTING_STDLIB -#endif - -/** - * X86_64_QUANTA_IX1_RANGELEY_CONFIG_INCLUDE_UCLI - * - * Include generic uCli support. */ - - -#ifndef X86_64_QUANTA_IX1_RANGELEY_CONFIG_INCLUDE_UCLI -#define X86_64_QUANTA_IX1_RANGELEY_CONFIG_INCLUDE_UCLI 0 -#endif - -/** - * X86_64_QUANTA_IX1_RANGELEY_CONFIG_SYSFAN_RPM_FAILURE_THRESHOLD - * - * RPM Threshold at which the fan is considered to have failed. */ - - -#ifndef X86_64_QUANTA_IX1_RANGELEY_CONFIG_SYSFAN_RPM_FAILURE_THRESHOLD -#define X86_64_QUANTA_IX1_RANGELEY_CONFIG_SYSFAN_RPM_FAILURE_THRESHOLD 3000 -#endif - -/** - * X86_64_QUANTA_IX1_RANGELEY_CONFIG_SYSFAN_F2B_RPM_MAX - * - * Maximum system front-to-back fan speed. */ - - -#ifndef X86_64_QUANTA_IX1_RANGELEY_CONFIG_SYSFAN_F2B_RPM_MAX -#define X86_64_QUANTA_IX1_RANGELEY_CONFIG_SYSFAN_F2B_RPM_MAX 18000 -#endif - -/** - * X86_64_QUANTA_IX1_RANGELEY_CONFIG_SYSFAN_B2F_RPM_MAX - * - * Maximum system back-to-front fan speed. */ - - -#ifndef X86_64_QUANTA_IX1_RANGELEY_CONFIG_SYSFAN_B2F_RPM_MAX -#define X86_64_QUANTA_IX1_RANGELEY_CONFIG_SYSFAN_B2F_RPM_MAX 18000 -#endif - -/** - * X86_64_QUANTA_IX1_RANGELEY_CONFIG_PHY_RESET_DELAY_MS - * - * Time to hold Phy GPIO in reset, in ms */ - - -#ifndef X86_64_QUANTA_IX1_RANGELEY_CONFIG_PHY_RESET_DELAY_MS -#define X86_64_QUANTA_IX1_RANGELEY_CONFIG_PHY_RESET_DELAY_MS 100 -#endif - - - -/** - * All compile time options can be queried or displayed - */ - -/** Configuration settings structure. */ -typedef struct x86_64_quanta_ix1_rangeley_config_settings_s { - /** name */ - const char* name; - /** value */ - const char* value; -} x86_64_quanta_ix1_rangeley_config_settings_t; - -/** Configuration settings table. */ -/** x86_64_quanta_ix1_rangeley_config_settings table. */ -extern x86_64_quanta_ix1_rangeley_config_settings_t x86_64_quanta_ix1_rangeley_config_settings[]; - -/** - * @brief Lookup a configuration setting. - * @param setting The name of the configuration option to lookup. - */ -const char* x86_64_quanta_ix1_rangeley_config_lookup(const char* setting); - -/** - * @brief Show the compile-time configuration. - * @param pvs The output stream. - */ -int x86_64_quanta_ix1_rangeley_config_show(struct aim_pvs_s* pvs); - -/* */ - -#include "x86_64_quanta_ix1_rangeley_porting.h" - -#endif /* __X86_64_QUANTA_IX1_RANGELEY_CONFIG_H__ */ -/* @} */ diff --git a/packages/platforms/quanta/x86-64/ix1-rangeley/onlp/builds/x86_64_quanta_ix1_rangeley/module/inc/x86_64_quanta_ix1_rangeley/x86_64_quanta_ix1_rangeley_dox.h b/packages/platforms/quanta/x86-64/ix1-rangeley/onlp/builds/x86_64_quanta_ix1_rangeley/module/inc/x86_64_quanta_ix1_rangeley/x86_64_quanta_ix1_rangeley_dox.h deleted file mode 100755 index 78dac6659..000000000 --- a/packages/platforms/quanta/x86-64/ix1-rangeley/onlp/builds/x86_64_quanta_ix1_rangeley/module/inc/x86_64_quanta_ix1_rangeley/x86_64_quanta_ix1_rangeley_dox.h +++ /dev/null @@ -1,26 +0,0 @@ -/**************************************************************************//** - * - * x86_64_quanta_ix1_rangeley Doxygen Header - * - *****************************************************************************/ -#ifndef __X86_64_QUANTA_IX1_RANGELEY_DOX_H__ -#define __X86_64_QUANTA_IX1_RANGELEY_DOX_H__ - -/** - * @defgroup x86_64_quanta_ix1_rangeley x86_64_quanta_ix1_rangeley - x86_64_quanta_ix1_rangeley Description - * - -The documentation overview for this module should go here. - - * - * @{ - * - * @defgroup x86_64_quanta_ix1_rangeley-x86_64_quanta_ix1_rangeley Public Interface - * @defgroup x86_64_quanta_ix1_rangeley-config Compile Time Configuration - * @defgroup x86_64_quanta_ix1_rangeley-porting Porting Macros - * - * @} - * - */ - -#endif /* __X86_64_QUANTA_IX1_RANGELEY_DOX_H__ */ diff --git a/packages/platforms/quanta/x86-64/ix1-rangeley/onlp/builds/x86_64_quanta_ix1_rangeley/module/inc/x86_64_quanta_ix1_rangeley/x86_64_quanta_ix1_rangeley_gpio_table.h b/packages/platforms/quanta/x86-64/ix1-rangeley/onlp/builds/x86_64_quanta_ix1_rangeley/module/inc/x86_64_quanta_ix1_rangeley/x86_64_quanta_ix1_rangeley_gpio_table.h deleted file mode 100755 index 209790b85..000000000 --- a/packages/platforms/quanta/x86-64/ix1-rangeley/onlp/builds/x86_64_quanta_ix1_rangeley/module/inc/x86_64_quanta_ix1_rangeley/x86_64_quanta_ix1_rangeley_gpio_table.h +++ /dev/null @@ -1,55 +0,0 @@ -#ifndef __X86_64_QUANTA_IX1_RANGELEY_GPIO_TABLE_H__ -#define __X86_64_QUANTA_IX1_RANGELEY_GPIO_TABLE_H__ - -/* - * defined within platform/quanta_switch.c - * Quanta Switch Platform driver - */ -#define QUANTA_IX1_PCA953x_GPIO(P1, P2) (P1*8+P2) - -#define QUANTA_IX1_PCA9555_GPIO_SIZE 0x10 - -#define QUANTA_IX1_I2C_GPIO_BASE 0x80 - -#define QUANTA_IX1_I2C_GPIO_CPU_BASE 0x40 - -#define QUANTA_IX1_CPU_BOARD_GPIO_BASE (QUANTA_IX1_I2C_GPIO_CPU_BASE) -#define QUANTA_IX1_CPU_BOARD_SYS_P1 (QUANTA_IX1_CPU_BOARD_GPIO_BASE + QUANTA_IX1_PCA953x_GPIO(1,2)) -#define QUANTA_IX1_CPU_BOARD_SYS_P2 (QUANTA_IX1_CPU_BOARD_GPIO_BASE + QUANTA_IX1_PCA953x_GPIO(1,3)) - -#define QUANTA_IX1_PSU_GPIO_BASE 0x10 -#define QUANTA_IX1_PSU_GPIO_SIZE QUANTA_IX1_PCA9555_GPIO_SIZE -#define QUANTA_IX1_PSU_GPIO_PSU1_PRSNT_N (QUANTA_IX1_PSU_GPIO_BASE + QUANTA_IX1_PCA953x_GPIO(0,0)) -#define QUANTA_IX1_PSU_GPIO_PSU1_PWRGD (QUANTA_IX1_PSU_GPIO_BASE + QUANTA_IX1_PCA953x_GPIO(0,1)) -#define QUANTA_IX1_PSU_GPIO_PSU2_PRSNT_N (QUANTA_IX1_PSU_GPIO_BASE + QUANTA_IX1_PCA953x_GPIO(0,3)) -#define QUANTA_IX1_PSU_GPIO_PSU2_PWRGD (QUANTA_IX1_PSU_GPIO_BASE + QUANTA_IX1_PCA953x_GPIO(0,4)) -#define QUANTA_IX1_PSU_GPIO_PSU1_AC_OK (QUANTA_IX1_PSU_GPIO_BASE + QUANTA_IX1_PCA953x_GPIO(0,6)) -#define QUANTA_IX1_PSU_GPIO_PSU2_AC_OK (QUANTA_IX1_PSU_GPIO_BASE + QUANTA_IX1_PCA953x_GPIO(0,7)) -#define QUANTA_IX1_PSU_GPIO_PSU1_GREEN_R (QUANTA_IX1_PSU_GPIO_BASE + QUANTA_IX1_PCA953x_GPIO(1,2)) -#define QUANTA_IX1_PSU_GPIO_PSU1_RED_R (QUANTA_IX1_PSU_GPIO_BASE + QUANTA_IX1_PCA953x_GPIO(1,3)) -#define QUANTA_IX1_PSU_GPIO_PSU2_GREEN_R (QUANTA_IX1_PSU_GPIO_BASE + QUANTA_IX1_PCA953x_GPIO(1,4)) -#define QUANTA_IX1_PSU_GPIO_PSU2_RED_R (QUANTA_IX1_PSU_GPIO_BASE + QUANTA_IX1_PCA953x_GPIO(1,5)) -#define QUANTA_IX1_PSU_GPIO_FAN_GREEN_R (QUANTA_IX1_PSU_GPIO_BASE + QUANTA_IX1_PCA953x_GPIO(1,6)) -#define QUANTA_IX1_PSU_GPIO_FAN_RED_R (QUANTA_IX1_PSU_GPIO_BASE + QUANTA_IX1_PCA953x_GPIO(1,7)) - -#define QUANTA_IX1_ZQSFP_EN_GPIO_BASE QUANTA_IX1_I2C_GPIO_BASE -#define QUANTA_IX1_ZQSFP_EN_GPIO_SIZE QUANTA_IX1_PCA9555_GPIO_SIZE -#define QUANTA_IX1_ZQSFP_EN_GPIO_P3V3_PW_GD (QUANTA_IX1_ZQSFP_EN_GPIO_BASE + QUANTA_IX1_PCA953x_GPIO(0,4)) -#define QUANTA_IX1_ZQSFP_EN_GPIO_P3V3_PW_EN (QUANTA_IX1_ZQSFP_EN_GPIO_BASE + QUANTA_IX1_PCA953x_GPIO(0,5)) - -#define QUANTA_IX1_FAN_GPIO_BASE (QUANTA_IX1_ZQSFP_EN_GPIO_BASE + QUANTA_IX1_ZQSFP_EN_GPIO_SIZE) -#define QUANTA_IX1_FAN_GPIO_SIZE QUANTA_IX1_PCA9555_GPIO_SIZE -#define QUANTA_IX1_FAN_PRSNT_N_1 (QUANTA_IX1_FAN_GPIO_BASE + QUANTA_IX1_PCA953x_GPIO(0,4)) -#define QUANTA_IX1_FAN_PRSNT_N_2 (QUANTA_IX1_FAN_GPIO_BASE + QUANTA_IX1_PCA953x_GPIO(0,5)) -#define QUANTA_IX1_FAN_PRSNT_N_3 (QUANTA_IX1_FAN_GPIO_BASE + QUANTA_IX1_PCA953x_GPIO(0,6)) -#define QUANTA_IX1_FAN_PRSNT_N_4 (QUANTA_IX1_FAN_GPIO_BASE + QUANTA_IX1_PCA953x_GPIO(0,7)) -#define QUANTA_IX1_FAN_BF_DET1 (QUANTA_IX1_FAN_GPIO_BASE + QUANTA_IX1_PCA953x_GPIO(1,0)) -#define QUANTA_IX1_FAN_BF_DET2 (QUANTA_IX1_FAN_GPIO_BASE + QUANTA_IX1_PCA953x_GPIO(1,1)) -#define QUANTA_IX1_FAN_BF_DET3 (QUANTA_IX1_FAN_GPIO_BASE + QUANTA_IX1_PCA953x_GPIO(1,2)) -#define QUANTA_IX1_FAN_BF_DET4 (QUANTA_IX1_FAN_GPIO_BASE + QUANTA_IX1_PCA953x_GPIO(1,3)) -#define QUANTA_IX1_FAN_FAIL_LED_1 (QUANTA_IX1_FAN_GPIO_BASE + QUANTA_IX1_PCA953x_GPIO(1,4)) -#define QUANTA_IX1_FAN_FAIL_LED_2 (QUANTA_IX1_FAN_GPIO_BASE + QUANTA_IX1_PCA953x_GPIO(1,5)) -#define QUANTA_IX1_FAN_FAIL_LED_3 (QUANTA_IX1_FAN_GPIO_BASE + QUANTA_IX1_PCA953x_GPIO(1,6)) -#define QUANTA_IX1_FAN_FAIL_LED_4 (QUANTA_IX1_FAN_GPIO_BASE + QUANTA_IX1_PCA953x_GPIO(1,7)) - -#endif /* __X86_64_QUANTA_IX1_RANGELEY_GPIO_TABLE_H__ */ diff --git a/packages/platforms/quanta/x86-64/ix1-rangeley/onlp/builds/x86_64_quanta_ix1_rangeley/module/inc/x86_64_quanta_ix1_rangeley/x86_64_quanta_ix1_rangeley_porting.h b/packages/platforms/quanta/x86-64/ix1-rangeley/onlp/builds/x86_64_quanta_ix1_rangeley/module/inc/x86_64_quanta_ix1_rangeley/x86_64_quanta_ix1_rangeley_porting.h deleted file mode 100755 index 87a151d92..000000000 --- a/packages/platforms/quanta/x86-64/ix1-rangeley/onlp/builds/x86_64_quanta_ix1_rangeley/module/inc/x86_64_quanta_ix1_rangeley/x86_64_quanta_ix1_rangeley_porting.h +++ /dev/null @@ -1,77 +0,0 @@ -/**************************************************************************//** - * - * @file - * @brief x86_64_quanta_ix1_rangeley Porting Macros. - * - * @addtogroup x86_64_quanta_ix1_rangeley-porting - * @{ - * - *****************************************************************************/ -#ifndef __X86_64_QUANTA_IX1_RANGELEY_PORTING_H__ -#define __X86_64_QUANTA_IX1_RANGELEY_PORTING_H__ - - -/* */ -#if X86_64_QUANTA_IX1_RANGELEY_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS == 1 -#include -#include -#include -#include -#include -#endif - -#ifndef X86_64_QUANTA_IX1_RANGELEY_MEMSET - #if defined(GLOBAL_MEMSET) - #define X86_64_QUANTA_IX1_RANGELEY_MEMSET GLOBAL_MEMSET - #elif X86_64_QUANTA_IX1_RANGELEY_CONFIG_PORTING_STDLIB == 1 - #define X86_64_QUANTA_IX1_RANGELEY_MEMSET memset - #else - #error The macro X86_64_QUANTA_IX1_RANGELEY_MEMSET is required but cannot be defined. - #endif -#endif - -#ifndef X86_64_QUANTA_IX1_RANGELEY_MEMCPY - #if defined(GLOBAL_MEMCPY) - #define X86_64_QUANTA_IX1_RANGELEY_MEMCPY GLOBAL_MEMCPY - #elif X86_64_QUANTA_IX1_RANGELEY_CONFIG_PORTING_STDLIB == 1 - #define X86_64_QUANTA_IX1_RANGELEY_MEMCPY memcpy - #else - #error The macro X86_64_QUANTA_IX1_RANGELEY_MEMCPY is required but cannot be defined. - #endif -#endif - -#ifndef X86_64_QUANTA_IX1_RANGELEY_VSNPRINTF - #if defined(GLOBAL_VSNPRINTF) - #define X86_64_QUANTA_IX1_RANGELEY_VSNPRINTF GLOBAL_VSNPRINTF - #elif X86_64_QUANTA_IX1_RANGELEY_CONFIG_PORTING_STDLIB == 1 - #define X86_64_QUANTA_IX1_RANGELEY_VSNPRINTF vsnprintf - #else - #error The macro X86_64_QUANTA_IX1_RANGELEY_VSNPRINTF is required but cannot be defined. - #endif -#endif - -#ifndef X86_64_QUANTA_IX1_RANGELEY_SNPRINTF - #if defined(GLOBAL_SNPRINTF) - #define X86_64_QUANTA_IX1_RANGELEY_SNPRINTF GLOBAL_SNPRINTF - #elif X86_64_QUANTA_IX1_RANGELEY_CONFIG_PORTING_STDLIB == 1 - #define X86_64_QUANTA_IX1_RANGELEY_SNPRINTF snprintf - #else - #error The macro X86_64_QUANTA_IX1_RANGELEY_SNPRINTF is required but cannot be defined. - #endif -#endif - -#ifndef X86_64_QUANTA_IX1_RANGELEY_STRLEN - #if defined(GLOBAL_STRLEN) - #define X86_64_QUANTA_IX1_RANGELEY_STRLEN GLOBAL_STRLEN - #elif X86_64_QUANTA_IX1_RANGELEY_CONFIG_PORTING_STDLIB == 1 - #define X86_64_QUANTA_IX1_RANGELEY_STRLEN strlen - #else - #error The macro X86_64_QUANTA_IX1_RANGELEY_STRLEN is required but cannot be defined. - #endif -#endif - -/* */ - - -#endif /* __X86_64_QUANTA_IX1_RANGELEY_PORTING_H__ */ -/* @} */ diff --git a/packages/platforms/quanta/x86-64/ix1-rangeley/onlp/builds/x86_64_quanta_ix1_rangeley/module/make.mk b/packages/platforms/quanta/x86-64/ix1-rangeley/onlp/builds/x86_64_quanta_ix1_rangeley/module/make.mk deleted file mode 100755 index 67b498440..000000000 --- a/packages/platforms/quanta/x86-64/ix1-rangeley/onlp/builds/x86_64_quanta_ix1_rangeley/module/make.mk +++ /dev/null @@ -1,10 +0,0 @@ -############################################################################### -# -# -# -############################################################################### -THIS_DIR := $(dir $(lastword $(MAKEFILE_LIST))) -x86_64_quanta_ix1_rangeley_INCLUDES := -I $(THIS_DIR)inc -x86_64_quanta_ix1_rangeley_INTERNAL_INCLUDES := -I $(THIS_DIR)src -x86_64_quanta_ix1_rangeley_DEPENDMODULE_ENTRIES := init:x86_64_quanta_ix1_rangeley ucli:x86_64_quanta_ix1_rangeley - diff --git a/packages/platforms/quanta/x86-64/ix1-rangeley/onlp/builds/x86_64_quanta_ix1_rangeley/module/src/Makefile b/packages/platforms/quanta/x86-64/ix1-rangeley/onlp/builds/x86_64_quanta_ix1_rangeley/module/src/Makefile deleted file mode 100755 index e3034fbe3..000000000 --- a/packages/platforms/quanta/x86-64/ix1-rangeley/onlp/builds/x86_64_quanta_ix1_rangeley/module/src/Makefile +++ /dev/null @@ -1,9 +0,0 @@ -############################################################################### -# -# Local source generation targets. -# -############################################################################### - -ucli: - @../../../../tools/uclihandlers.py x86_64_quanta_ix1_rangeley_ucli.c - diff --git a/packages/platforms/quanta/x86-64/ix1-rangeley/onlp/builds/x86_64_quanta_ix1_rangeley/module/src/fani.c b/packages/platforms/quanta/x86-64/ix1-rangeley/onlp/builds/x86_64_quanta_ix1_rangeley/module/src/fani.c deleted file mode 100755 index 8b3c8e9b2..000000000 --- a/packages/platforms/quanta/x86-64/ix1-rangeley/onlp/builds/x86_64_quanta_ix1_rangeley/module/src/fani.c +++ /dev/null @@ -1,172 +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 "x86_64_quanta_ix1_rangeley_int.h" -#include "x86_64_quanta_ix1_rangeley_log.h" - -#include -#include - -int -onlp_fani_init(void) -{ - return ONLP_STATUS_OK; -} - -struct fan_gpio_s { - int present; - int fan_dir_detect; -}; - -static struct fan_gpio_s fan_gpio[] = { - {}, /* Not used */ - { .present = QUANTA_IX1_FAN_PRSNT_N_1, .fan_dir_detect = QUANTA_IX1_FAN_BF_DET1 }, - { .present = QUANTA_IX1_FAN_PRSNT_N_2, .fan_dir_detect = QUANTA_IX1_FAN_BF_DET2 }, - { .present = QUANTA_IX1_FAN_PRSNT_N_3, .fan_dir_detect = QUANTA_IX1_FAN_BF_DET3 }, - { .present = QUANTA_IX1_FAN_PRSNT_N_4, .fan_dir_detect = QUANTA_IX1_FAN_BF_DET4 }, - //{}, /* Not used */ - { .present = QUANTA_IX1_FAN_PRSNT_N_1, .fan_dir_detect = QUANTA_IX1_FAN_BF_DET1 }, - { .present = QUANTA_IX1_FAN_PRSNT_N_2, .fan_dir_detect = QUANTA_IX1_FAN_BF_DET2 }, - { .present = QUANTA_IX1_FAN_PRSNT_N_3, .fan_dir_detect = QUANTA_IX1_FAN_BF_DET3 }, - { .present = QUANTA_IX1_FAN_PRSNT_N_4, .fan_dir_detect = QUANTA_IX1_FAN_BF_DET4 }, - //{}, /* Not used */ -}; - -static int -sys_fan_info_get__(onlp_fan_info_t* info, int id) -{ - int value = 0; - int rv; - - if(onlp_gpio_get(fan_gpio[id].present, &value) == ONLP_STATUS_OK - && value == 0) { - info->status = ONLP_FAN_STATUS_PRESENT; - if(onlp_gpio_get(fan_gpio[id].fan_dir_detect, &value) == ONLP_STATUS_OK - && value == 0) { - info->status |= ONLP_FAN_STATUS_F2B; - info->caps |= ONLP_FAN_CAPS_F2B; - } - else { - info->status |= ONLP_FAN_STATUS_B2F; - info->caps |= ONLP_FAN_CAPS_B2F; - } - } - else { - info->status = ONLP_FAN_STATUS_FAILED; - } - - rv = onlp_file_read_int(&info->rpm, - SYS_HWMON_PREFIX "/fan%d_input", id); - - if(rv == ONLP_STATUS_E_INTERNAL) { - return rv; - } - - if(rv == ONLP_STATUS_E_MISSING) { - info->status &= ~1; - return 0; - } - - if(info->rpm <= X86_64_QUANTA_IX1_RANGELEY_CONFIG_SYSFAN_RPM_FAILURE_THRESHOLD) { - info->status |= ONLP_FAN_STATUS_FAILED; - } - - /* - * Calculate percentage based on current speed and the maximum. - */ - info->caps |= ONLP_FAN_CAPS_GET_PERCENTAGE; - if(info->status & ONLP_FAN_STATUS_F2B) { - info->percentage = (int) ((double) info->rpm * (double)100 / (double)X86_64_QUANTA_IX1_RANGELEY_CONFIG_SYSFAN_F2B_RPM_MAX); - } - if(info->status & ONLP_FAN_STATUS_B2F) { - info->percentage = (int) ((double) info->rpm * (double)100 / (double)X86_64_QUANTA_IX1_RANGELEY_CONFIG_SYSFAN_B2F_RPM_MAX); - } - - return 0; -} - -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, "Left (Module/Fan 1/1)", 0}, ONLP_FAN_STATUS_PRESENT }, - { { FAN_OID_FAN2, "Center-L(Module/Fan 2/1)", 0}, ONLP_FAN_STATUS_PRESENT }, - { { FAN_OID_FAN3, "Center-R(Module/Fan 3/1)", 0}, ONLP_FAN_STATUS_PRESENT }, - { { FAN_OID_FAN4, "Right (Module/Fan 4/1)", 0}, ONLP_FAN_STATUS_PRESENT }, - { { FAN_OID_FAN5, "Left (Module/Fan 1/2)", 0}, ONLP_FAN_STATUS_PRESENT }, - { { FAN_OID_FAN6, "Center-L(Module/Fan 2/2)", 0}, ONLP_FAN_STATUS_PRESENT }, - { { FAN_OID_FAN7, "Center-R(Module/Fan 3/2)", 0}, ONLP_FAN_STATUS_PRESENT }, - { { FAN_OID_FAN8, "Right (Module/Fan 4/2)", 0}, ONLP_FAN_STATUS_PRESENT }, - { { FAN_OID_FAN9, "PSU-1 Fan", 0 }, ONLP_FAN_STATUS_PRESENT }, - { { FAN_OID_FAN10, "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: - case FAN_ID_FAN3: - case FAN_ID_FAN4: - case FAN_ID_FAN5: - case FAN_ID_FAN6: - case FAN_ID_FAN7: - case FAN_ID_FAN8: - return sys_fan_info_get__(rv, fid); - break; - - case FAN_ID_FAN9: - case FAN_ID_FAN10: - return psu_fan_info_get__(rv, fid - FAN_ID_FAN9 + 1); - break; - - default: - return ONLP_STATUS_E_INVALID; - break; - } - - return ONLP_STATUS_E_INVALID; -} - - diff --git a/packages/platforms/quanta/x86-64/ix1-rangeley/onlp/builds/x86_64_quanta_ix1_rangeley/module/src/ledi.c b/packages/platforms/quanta/x86-64/ix1-rangeley/onlp/builds/x86_64_quanta_ix1_rangeley/module/src/ledi.c deleted file mode 100755 index 86993a05b..000000000 --- a/packages/platforms/quanta/x86-64/ix1-rangeley/onlp/builds/x86_64_quanta_ix1_rangeley/module/src/ledi.c +++ /dev/null @@ -1,229 +0,0 @@ -#include -#include -#include -#include -#include - -#include "x86_64_quanta_ix1_rangeley_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_IX1_CPU_BOARD_SYS_P1, 0); - onlp_gpio_set(QUANTA_IX1_CPU_BOARD_SYS_P2, 1); - } - else if(mode == ONLP_LED_MODE_ORANGE){ - onlp_gpio_set(QUANTA_IX1_CPU_BOARD_SYS_P1, 1); - onlp_gpio_set(QUANTA_IX1_CPU_BOARD_SYS_P2, 0); - } - else{ - onlp_gpio_set(QUANTA_IX1_CPU_BOARD_SYS_P1, 1); - onlp_gpio_set(QUANTA_IX1_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_IX1_PSU_GPIO_FAN_GREEN_R, 1); - onlp_gpio_set(QUANTA_IX1_PSU_GPIO_FAN_RED_R, 0); - } - else if(mode == ONLP_LED_MODE_RED){ - onlp_gpio_set(QUANTA_IX1_PSU_GPIO_FAN_GREEN_R, 0); - onlp_gpio_set(QUANTA_IX1_PSU_GPIO_FAN_RED_R, 1); - } - else{ - onlp_gpio_set(QUANTA_IX1_PSU_GPIO_FAN_GREEN_R, 0); - onlp_gpio_set(QUANTA_IX1_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_IX1_PSU_GPIO_PSU1_GREEN_R, 1); - onlp_gpio_set(QUANTA_IX1_PSU_GPIO_PSU1_RED_R, 0); - } - else if(mode == ONLP_LED_MODE_RED){ - onlp_gpio_set(QUANTA_IX1_PSU_GPIO_PSU1_GREEN_R, 0); - onlp_gpio_set(QUANTA_IX1_PSU_GPIO_PSU1_RED_R, 1); - } - else{ - onlp_gpio_set(QUANTA_IX1_PSU_GPIO_PSU1_GREEN_R, 0); - onlp_gpio_set(QUANTA_IX1_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_IX1_PSU_GPIO_PSU2_GREEN_R, 1); - onlp_gpio_set(QUANTA_IX1_PSU_GPIO_PSU2_RED_R, 0); - } - else if(mode == ONLP_LED_MODE_RED){ - onlp_gpio_set(QUANTA_IX1_PSU_GPIO_PSU2_GREEN_R, 0); - onlp_gpio_set(QUANTA_IX1_PSU_GPIO_PSU2_RED_R, 1); - } - else{ - onlp_gpio_set(QUANTA_IX1_PSU_GPIO_PSU2_GREEN_R, 0); - onlp_gpio_set(QUANTA_IX1_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_IX1_FAN_FAIL_LED_1, 1); - } - else{ - onlp_gpio_set(QUANTA_IX1_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_IX1_FAN_FAIL_LED_2, 1); - } - else{ - onlp_gpio_set(QUANTA_IX1_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_IX1_FAN_FAIL_LED_3, 1); - } - else{ - onlp_gpio_set(QUANTA_IX1_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_IX1_FAN_FAIL_LED_4, 1); - } - else{ - onlp_gpio_set(QUANTA_IX1_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/ix1-rangeley/onlp/builds/x86_64_quanta_ix1_rangeley/module/src/make.mk b/packages/platforms/quanta/x86-64/ix1-rangeley/onlp/builds/x86_64_quanta_ix1_rangeley/module/src/make.mk deleted file mode 100755 index 467930c0d..000000000 --- a/packages/platforms/quanta/x86-64/ix1-rangeley/onlp/builds/x86_64_quanta_ix1_rangeley/module/src/make.mk +++ /dev/null @@ -1,9 +0,0 @@ -############################################################################### -# -# -# -############################################################################### - -LIBRARY := x86_64_quanta_ix1_rangeley -$(LIBRARY)_SUBDIR := $(dir $(lastword $(MAKEFILE_LIST))) -include $(BUILDER)/lib.mk diff --git a/packages/platforms/quanta/x86-64/ix1-rangeley/onlp/builds/x86_64_quanta_ix1_rangeley/module/src/psui.c b/packages/platforms/quanta/x86-64/ix1-rangeley/onlp/builds/x86_64_quanta_ix1_rangeley/module/src/psui.c deleted file mode 100755 index adce4f901..000000000 --- a/packages/platforms/quanta/x86-64/ix1-rangeley/onlp/builds/x86_64_quanta_ix1_rangeley/module/src/psui.c +++ /dev/null @@ -1,119 +0,0 @@ -/************************************************************ - * - * - ************************************************************ - * - * - * - ***********************************************************/ -#include -#include -#include -#include -#include -#include "x86_64_quanta_ix1_rangeley_int.h" -#include "x86_64_quanta_ix1_rangeley_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_IX1_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_IX1_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 IX1 RPSU-1", - 0, - { - FAN_OID_FAN9, - }, - } - }, - { - { - PSU_OID_PSU2, - "Quanta IX1 RPSU-2", - 0, - { - FAN_OID_FAN10, - }, - } - }, -}; - -#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/ix1-rangeley/onlp/builds/x86_64_quanta_ix1_rangeley/module/src/sfpi.c b/packages/platforms/quanta/x86-64/ix1-rangeley/onlp/builds/x86_64_quanta_ix1_rangeley/module/src/sfpi.c deleted file mode 100755 index d5ea1b29e..000000000 --- a/packages/platforms/quanta/x86-64/ix1-rangeley/onlp/builds/x86_64_quanta_ix1_rangeley/module/src/sfpi.c +++ /dev/null @@ -1,244 +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. - * - * - ************************************************************ - * - * SFPI Interface for the Quanta IX1 - * - ***********************************************************/ -#include -#include -#include -#include -#include -#include "x86_64_quanta_ix1_rangeley_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_IX1_ZQSFP_EN_GPIO_P3V3_PW_EN, ONLP_GPIO_DIRECTION_OUT); - ret = onlp_gpio_set(QUANTA_IX1_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/ix1-rangeley/onlp/builds/x86_64_quanta_ix1_rangeley/module/src/sysi.c b/packages/platforms/quanta/x86-64/ix1-rangeley/onlp/builds/x86_64_quanta_ix1_rangeley/module/src/sysi.c deleted file mode 100755 index 34c791299..000000000 --- a/packages/platforms/quanta/x86-64/ix1-rangeley/onlp/builds/x86_64_quanta_ix1_rangeley/module/src/sysi.c +++ /dev/null @@ -1,292 +0,0 @@ -/************************************************************ - * - * - ************************************************************ - * - * - * - ***********************************************************/ -#include -#include "x86_64_quanta_ix1_rangeley_int.h" -#include "x86_64_quanta_ix1_rangeley_log.h" -#include -#include -#include -#include -#include - -struct led_control_s led_control; - -#define QUANTA_HWMON_REG_TEMP_ALERT_MASK 0x1E -#define QUANTA_HWMON_REG_TEMP_ALERT_CTRL 0x1D -#define QUANTA_HWMON_REG_FAN_ALERT_MASK 0x31 -#define QUANTA_HWMON_REG_FAN_ALERT_CTRL 0x30 -#define PSOC_REG_FAN_ALERT_STATUS 0x32 - -#define QUANTA_FAN_1_1 0x01 -#define QUANTA_FAN_1_2 0x10 -#define QUANTA_FAN_2_1 0x02 -#define QUANTA_FAN_2_2 0x20 -#define QUANTA_FAN_3_1 0x04 -#define QUANTA_FAN_3_2 0x40 -#define QUANTA_FAN_4_1 0x08 -#define QUANTA_FAN_4_2 0x80 - -const char* -onlp_sysi_platform_get(void) -{ - return "x86-64-quanta-ix1-rangeley-r0"; -} - -int -onlp_sysi_init(void) -{ - /* Initial value */ - led_control.PMCnt = 0; - led_control.fan_alert = 0xff; - led_control.psu1_present = 0; - led_control.psu2_present = 0; - led_control.psu1_power_good = 0; - led_control.psu2_power_good = 0; - - /* Set PSoc Fan-Alert Enable */ - onlp_i2c_writeb(0, 0x4e, QUANTA_HWMON_REG_TEMP_ALERT_MASK, 0x37, ONLP_I2C_F_FORCE); - onlp_i2c_writeb(0, 0x4e, QUANTA_HWMON_REG_TEMP_ALERT_CTRL, 0x3, ONLP_I2C_F_FORCE); - onlp_i2c_writeb(0, 0x4e, QUANTA_HWMON_REG_FAN_ALERT_MASK, 0xff, ONLP_I2C_F_FORCE); - onlp_i2c_writeb(0, 0x4e, QUANTA_HWMON_REG_FAN_ALERT_CTRL, 0x1, ONLP_I2C_F_FORCE); - - /* Config GPIO */ - /* LED Output */ - onlp_gpio_export(QUANTA_IX1_CPU_BOARD_SYS_P1, ONLP_GPIO_DIRECTION_OUT); - onlp_gpio_export(QUANTA_IX1_CPU_BOARD_SYS_P2, ONLP_GPIO_DIRECTION_OUT); - onlp_gpio_export(QUANTA_IX1_PSU_GPIO_PSU1_GREEN_R, ONLP_GPIO_DIRECTION_OUT); - onlp_gpio_export(QUANTA_IX1_PSU_GPIO_PSU1_RED_R, ONLP_GPIO_DIRECTION_OUT); - onlp_gpio_export(QUANTA_IX1_PSU_GPIO_PSU2_GREEN_R, ONLP_GPIO_DIRECTION_OUT); - onlp_gpio_export(QUANTA_IX1_PSU_GPIO_PSU2_RED_R, ONLP_GPIO_DIRECTION_OUT); - onlp_gpio_export(QUANTA_IX1_FAN_FAIL_LED_1, ONLP_GPIO_DIRECTION_OUT); - onlp_gpio_export(QUANTA_IX1_FAN_FAIL_LED_2, ONLP_GPIO_DIRECTION_OUT); - onlp_gpio_export(QUANTA_IX1_FAN_FAIL_LED_3, ONLP_GPIO_DIRECTION_OUT); - onlp_gpio_export(QUANTA_IX1_FAN_FAIL_LED_4, ONLP_GPIO_DIRECTION_OUT); - onlp_gpio_export(QUANTA_IX1_PSU_GPIO_FAN_GREEN_R, ONLP_GPIO_DIRECTION_OUT); - onlp_gpio_export(QUANTA_IX1_PSU_GPIO_FAN_RED_R, ONLP_GPIO_DIRECTION_OUT); - /* PSU Input */ - onlp_gpio_export(QUANTA_IX1_PSU_GPIO_PSU1_PRSNT_N, ONLP_GPIO_DIRECTION_IN); - onlp_gpio_export(QUANTA_IX1_PSU_GPIO_PSU1_PWRGD, ONLP_GPIO_DIRECTION_IN); - onlp_gpio_export(QUANTA_IX1_PSU_GPIO_PSU2_PRSNT_N, ONLP_GPIO_DIRECTION_IN); - onlp_gpio_export(QUANTA_IX1_PSU_GPIO_PSU2_PWRGD, ONLP_GPIO_DIRECTION_IN); - /* FAN Input */ - onlp_gpio_export(QUANTA_IX1_FAN_PRSNT_N_1, ONLP_GPIO_DIRECTION_IN); - 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); - 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-ix1-rangeley-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)); - - /* - * 5 Chassis Thermal Sensors - */ - *e++ = THERMAL_OID_THERMAL1; - *e++ = THERMAL_OID_THERMAL2; - *e++ = THERMAL_OID_THERMAL3; - *e++ = THERMAL_OID_THERMAL5; - *e++ = THERMAL_OID_THERMAL6; - - /* - * 8 Fans - */ - *e++ = FAN_OID_FAN1; - *e++ = FAN_OID_FAN2; - *e++ = FAN_OID_FAN3; - *e++ = FAN_OID_FAN4; - *e++ = FAN_OID_FAN5; - *e++ = FAN_OID_FAN6; - *e++ = FAN_OID_FAN7; - *e++ = FAN_OID_FAN8; - - /* - * 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_IX1_PSU_GPIO_PSU1_PRSNT_N, &value); - if(rv < 0) { - AIM_LOG_ERROR("GPIO %d read Error!", QUANTA_IX1_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_IX1_PSU_GPIO_PSU1_PWRGD, &value); - if(rv < 0) { - AIM_LOG_ERROR("GPIO %d read Error!", QUANTA_IX1_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_IX1_PSU_GPIO_PSU2_PRSNT_N, &value); - if(rv < 0) { - AIM_LOG_ERROR("GPIO %d read Error!", QUANTA_IX1_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_IX1_PSU_GPIO_PSU2_PWRGD, &value); - if(rv < 0) { - AIM_LOG_ERROR("GPIO %d read Error!", QUANTA_IX1_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; - - tmp = led_control.fan_alert; - led_control.fan_alert = onlp_i2c_readb(0, 0x4e, PSOC_REG_FAN_ALERT_STATUS, ONLP_I2C_F_FORCE); - if(tmp != led_control.fan_alert) - 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.fan_alert & QUANTA_FAN_1_1) && !(led_control.fan_alert & QUANTA_FAN_1_2)) { - onlp_ledi_mode_set(LED_ID_FAN_FAIL_1, ONLP_LED_MODE_OFF); - } - else{ - onlp_ledi_mode_set(LED_ID_FAN_FAIL_1, ONLP_LED_MODE_RED); - } - - if(!(led_control.fan_alert & QUANTA_FAN_2_1) && !(led_control.fan_alert & QUANTA_FAN_2_2)) { - onlp_ledi_mode_set(LED_ID_FAN_FAIL_2, ONLP_LED_MODE_OFF); - } - else{ - onlp_ledi_mode_set(LED_ID_FAN_FAIL_2, ONLP_LED_MODE_RED); - } - - if(!(led_control.fan_alert & QUANTA_FAN_3_1) && !(led_control.fan_alert & QUANTA_FAN_3_2)) { - onlp_ledi_mode_set(LED_ID_FAN_FAIL_3, ONLP_LED_MODE_OFF); - } - else{ - onlp_ledi_mode_set(LED_ID_FAN_FAIL_3, ONLP_LED_MODE_RED); - } - - if(!(led_control.fan_alert & QUANTA_FAN_4_1) && !(led_control.fan_alert & QUANTA_FAN_4_2)) { - onlp_ledi_mode_set(LED_ID_FAN_FAIL_4, ONLP_LED_MODE_OFF); - } - else{ - onlp_ledi_mode_set(LED_ID_FAN_FAIL_4, ONLP_LED_MODE_RED); - } - - if(!led_control.fan_alert){ - 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/ix1-rangeley/onlp/builds/x86_64_quanta_ix1_rangeley/module/src/thermali.c b/packages/platforms/quanta/x86-64/ix1-rangeley/onlp/builds/x86_64_quanta_ix1_rangeley/module/src/thermali.c deleted file mode 100755 index 8a4f20d1f..000000000 --- a/packages/platforms/quanta/x86-64/ix1-rangeley/onlp/builds/x86_64_quanta_ix1_rangeley/module/src/thermali.c +++ /dev/null @@ -1,146 +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 "x86_64_quanta_ix1_rangeley_int.h" -#include "x86_64_quanta_ix1_rangeley_log.h" - -int -onlp_thermali_init(void) -{ - return ONLP_STATUS_OK; -} - -static int -sys_thermal_info_get__(onlp_thermal_info_t* info, int id) -{ - int rv; - - rv = onlp_file_read_int(&info->mcelsius, - SYS_HWMON_PREFIX "/temp%d_input", id); - - if(rv == ONLP_STATUS_E_INTERNAL) { - return rv; - } - - if(rv == ONLP_STATUS_E_MISSING) { - info->status &= ~1; - return 0; - } - - return ONLP_STATUS_OK; -} - -static int -psu_thermal_info_get__(onlp_thermal_info_t* info, int pid, int id) -{ - /* THERMAL6 -> PSU1 */ - /* THERMAL7 -> PSU2 */ - extern struct psu_info_s psu_info[]; - char* dir = psu_info[pid].path; - - info->status |= 1; - return onlp_file_read_int(&info->mcelsius, "%s/temp%d_input", dir, id); -} - -int -onlp_thermali_info_get(onlp_oid_t id, onlp_thermal_info_t* rv) -{ - int tid = ONLP_OID_ID_GET(id); - - static onlp_thermal_info_t info[] = { - { }, /* Not used */ - { { ONLP_THERMAL_ID_CREATE(1), "Chassis Thermal 1", 0}, ONLP_THERMAL_STATUS_PRESENT, - ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS - }, - { { ONLP_THERMAL_ID_CREATE(2), "Chassis Thermal 2", 0}, ONLP_THERMAL_STATUS_PRESENT, - ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS - }, - { { ONLP_THERMAL_ID_CREATE(3), "Chassis Thermal 3", 0}, ONLP_THERMAL_STATUS_PRESENT, - ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS - }, - { { ONLP_THERMAL_ID_CREATE(4), "Chassis Thermal 4", 0}, ONLP_THERMAL_STATUS_PRESENT, - ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS - }, - { { ONLP_THERMAL_ID_CREATE(5), "Chassis Thermal 5", 0}, ONLP_THERMAL_STATUS_PRESENT, - ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS - }, - { { ONLP_THERMAL_ID_CREATE(6), "Chassis Thermal 6", 0}, ONLP_THERMAL_STATUS_PRESENT, - ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS - }, - { { ONLP_THERMAL_ID_CREATE(7), "Chassis Thermal 7", 0}, ONLP_THERMAL_STATUS_PRESENT, - ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS - }, - { { ONLP_THERMAL_ID_CREATE(8), "Chassis Thermal 8", 0}, ONLP_THERMAL_STATUS_PRESENT, - ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS - }, - { { ONLP_THERMAL_ID_CREATE(9), "Chassis Thermal 9", 0}, ONLP_THERMAL_STATUS_PRESENT, - ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS - }, - { { ONLP_THERMAL_ID_CREATE(10), "Chassis Thermal 10", 0}, ONLP_THERMAL_STATUS_PRESENT, - ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS - }, - - { { ONLP_THERMAL_ID_CREATE(11), "PSU-1 Thermal 1", 0 } }, - { { ONLP_THERMAL_ID_CREATE(12), "PSU-1 Thermal 2", 0 } }, - { { ONLP_THERMAL_ID_CREATE(13), "PSU-1 Thermal 3", 0 } }, - - { { ONLP_THERMAL_ID_CREATE(14), "PSU-2 Thermal 1", 0 } }, - { { ONLP_THERMAL_ID_CREATE(15), "PSU-2 Thermal 2", 0 } }, - { { ONLP_THERMAL_ID_CREATE(16), "PSU-2 Thermal 3", 0 } }, - }; - - *rv = info[tid]; - rv->caps |= ONLP_THERMAL_CAPS_GET_TEMPERATURE; - - switch(tid) - { - case THERMAL_ID_THERMAL1: - case THERMAL_ID_THERMAL2: - case THERMAL_ID_THERMAL3: - case THERMAL_ID_THERMAL4: - case THERMAL_ID_THERMAL5: - case THERMAL_ID_THERMAL6: - case THERMAL_ID_THERMAL7: - case THERMAL_ID_THERMAL8: - case THERMAL_ID_THERMAL9: - case THERMAL_ID_THERMAL10: - return sys_thermal_info_get__(rv, tid); - - case THERMAL_ID_THERMAL11: - case THERMAL_ID_THERMAL12: - case THERMAL_ID_THERMAL13: - return psu_thermal_info_get__(rv, 1, tid - THERMAL_ID_THERMAL11 + 1); - - - case THERMAL_ID_THERMAL14: - case THERMAL_ID_THERMAL15: - case THERMAL_ID_THERMAL16: - return psu_thermal_info_get__(rv, 2, tid - THERMAL_ID_THERMAL14 + 1); - - } - - return ONLP_STATUS_E_INVALID; -} diff --git a/packages/platforms/quanta/x86-64/ix1-rangeley/onlp/builds/x86_64_quanta_ix1_rangeley/module/src/x86_64_quanta_ix1_rangeley_config.c b/packages/platforms/quanta/x86-64/ix1-rangeley/onlp/builds/x86_64_quanta_ix1_rangeley/module/src/x86_64_quanta_ix1_rangeley_config.c deleted file mode 100755 index 737a2958d..000000000 --- a/packages/platforms/quanta/x86-64/ix1-rangeley/onlp/builds/x86_64_quanta_ix1_rangeley/module/src/x86_64_quanta_ix1_rangeley_config.c +++ /dev/null @@ -1,95 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#include - -/* */ -#define __x86_64_quanta_ix1_rangeley_config_STRINGIFY_NAME(_x) #_x -#define __x86_64_quanta_ix1_rangeley_config_STRINGIFY_VALUE(_x) __x86_64_quanta_ix1_rangeley_config_STRINGIFY_NAME(_x) -x86_64_quanta_ix1_rangeley_config_settings_t x86_64_quanta_ix1_rangeley_config_settings[] = -{ -#ifdef X86_64_QUANTA_IX1_RANGELEY_CONFIG_INCLUDE_LOGGING - { __x86_64_quanta_ix1_rangeley_config_STRINGIFY_NAME(X86_64_QUANTA_IX1_RANGELEY_CONFIG_INCLUDE_LOGGING), __x86_64_quanta_ix1_rangeley_config_STRINGIFY_VALUE(X86_64_QUANTA_IX1_RANGELEY_CONFIG_INCLUDE_LOGGING) }, -#else -{ X86_64_QUANTA_IX1_RANGELEY_CONFIG_INCLUDE_LOGGING(__x86_64_quanta_ix1_rangeley_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_QUANTA_IX1_RANGELEY_CONFIG_LOG_OPTIONS_DEFAULT - { __x86_64_quanta_ix1_rangeley_config_STRINGIFY_NAME(X86_64_QUANTA_IX1_RANGELEY_CONFIG_LOG_OPTIONS_DEFAULT), __x86_64_quanta_ix1_rangeley_config_STRINGIFY_VALUE(X86_64_QUANTA_IX1_RANGELEY_CONFIG_LOG_OPTIONS_DEFAULT) }, -#else -{ X86_64_QUANTA_IX1_RANGELEY_CONFIG_LOG_OPTIONS_DEFAULT(__x86_64_quanta_ix1_rangeley_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_QUANTA_IX1_RANGELEY_CONFIG_LOG_BITS_DEFAULT - { __x86_64_quanta_ix1_rangeley_config_STRINGIFY_NAME(X86_64_QUANTA_IX1_RANGELEY_CONFIG_LOG_BITS_DEFAULT), __x86_64_quanta_ix1_rangeley_config_STRINGIFY_VALUE(X86_64_QUANTA_IX1_RANGELEY_CONFIG_LOG_BITS_DEFAULT) }, -#else -{ X86_64_QUANTA_IX1_RANGELEY_CONFIG_LOG_BITS_DEFAULT(__x86_64_quanta_ix1_rangeley_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_QUANTA_IX1_RANGELEY_CONFIG_LOG_CUSTOM_BITS_DEFAULT - { __x86_64_quanta_ix1_rangeley_config_STRINGIFY_NAME(X86_64_QUANTA_IX1_RANGELEY_CONFIG_LOG_CUSTOM_BITS_DEFAULT), __x86_64_quanta_ix1_rangeley_config_STRINGIFY_VALUE(X86_64_QUANTA_IX1_RANGELEY_CONFIG_LOG_CUSTOM_BITS_DEFAULT) }, -#else -{ X86_64_QUANTA_IX1_RANGELEY_CONFIG_LOG_CUSTOM_BITS_DEFAULT(__x86_64_quanta_ix1_rangeley_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_QUANTA_IX1_RANGELEY_CONFIG_PORTING_STDLIB - { __x86_64_quanta_ix1_rangeley_config_STRINGIFY_NAME(X86_64_QUANTA_IX1_RANGELEY_CONFIG_PORTING_STDLIB), __x86_64_quanta_ix1_rangeley_config_STRINGIFY_VALUE(X86_64_QUANTA_IX1_RANGELEY_CONFIG_PORTING_STDLIB) }, -#else -{ X86_64_QUANTA_IX1_RANGELEY_CONFIG_PORTING_STDLIB(__x86_64_quanta_ix1_rangeley_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_QUANTA_IX1_RANGELEY_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS - { __x86_64_quanta_ix1_rangeley_config_STRINGIFY_NAME(X86_64_QUANTA_IX1_RANGELEY_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS), __x86_64_quanta_ix1_rangeley_config_STRINGIFY_VALUE(X86_64_QUANTA_IX1_RANGELEY_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS) }, -#else -{ X86_64_QUANTA_IX1_RANGELEY_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS(__x86_64_quanta_ix1_rangeley_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_QUANTA_IX1_RANGELEY_CONFIG_INCLUDE_UCLI - { __x86_64_quanta_ix1_rangeley_config_STRINGIFY_NAME(X86_64_QUANTA_IX1_RANGELEY_CONFIG_INCLUDE_UCLI), __x86_64_quanta_ix1_rangeley_config_STRINGIFY_VALUE(X86_64_QUANTA_IX1_RANGELEY_CONFIG_INCLUDE_UCLI) }, -#else -{ X86_64_QUANTA_IX1_RANGELEY_CONFIG_INCLUDE_UCLI(__x86_64_quanta_ix1_rangeley_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_QUANTA_IX1_RANGELEY_CONFIG_SYSFAN_RPM_FAILURE_THRESHOLD - { __x86_64_quanta_ix1_rangeley_config_STRINGIFY_NAME(X86_64_QUANTA_IX1_RANGELEY_CONFIG_SYSFAN_RPM_FAILURE_THRESHOLD), __x86_64_quanta_ix1_rangeley_config_STRINGIFY_VALUE(X86_64_QUANTA_IX1_RANGELEY_CONFIG_SYSFAN_RPM_FAILURE_THRESHOLD) }, -#else -{ X86_64_QUANTA_IX1_RANGELEY_CONFIG_SYSFAN_RPM_FAILURE_THRESHOLD(__x86_64_quanta_ix1_rangeley_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_QUANTA_IX1_RANGELEY_CONFIG_SYSFAN_F2B_RPM_MAX - { __x86_64_quanta_ix1_rangeley_config_STRINGIFY_NAME(X86_64_QUANTA_IX1_RANGELEY_CONFIG_SYSFAN_F2B_RPM_MAX), __x86_64_quanta_ix1_rangeley_config_STRINGIFY_VALUE(X86_64_QUANTA_IX1_RANGELEY_CONFIG_SYSFAN_F2B_RPM_MAX) }, -#else -{ X86_64_QUANTA_IX1_RANGELEY_CONFIG_SYSFAN_F2B_RPM_MAX(__x86_64_quanta_ix1_rangeley_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_QUANTA_IX1_RANGELEY_CONFIG_SYSFAN_B2F_RPM_MAX - { __x86_64_quanta_ix1_rangeley_config_STRINGIFY_NAME(X86_64_QUANTA_IX1_RANGELEY_CONFIG_SYSFAN_B2F_RPM_MAX), __x86_64_quanta_ix1_rangeley_config_STRINGIFY_VALUE(X86_64_QUANTA_IX1_RANGELEY_CONFIG_SYSFAN_B2F_RPM_MAX) }, -#else -{ X86_64_QUANTA_IX1_RANGELEY_CONFIG_SYSFAN_B2F_RPM_MAX(__x86_64_quanta_ix1_rangeley_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_QUANTA_IX1_RANGELEY_CONFIG_PHY_RESET_DELAY_MS - { __x86_64_quanta_ix1_rangeley_config_STRINGIFY_NAME(X86_64_QUANTA_IX1_RANGELEY_CONFIG_PHY_RESET_DELAY_MS), __x86_64_quanta_ix1_rangeley_config_STRINGIFY_VALUE(X86_64_QUANTA_IX1_RANGELEY_CONFIG_PHY_RESET_DELAY_MS) }, -#else -{ X86_64_QUANTA_IX1_RANGELEY_CONFIG_PHY_RESET_DELAY_MS(__x86_64_quanta_ix1_rangeley_config_STRINGIFY_NAME), "__undefined__" }, -#endif - { NULL, NULL } -}; -#undef __x86_64_quanta_ix1_rangeley_config_STRINGIFY_VALUE -#undef __x86_64_quanta_ix1_rangeley_config_STRINGIFY_NAME - -const char* -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)) { - return x86_64_quanta_ix1_rangeley_config_settings[i].value; - } - } - return NULL; -} - -int -x86_64_quanta_ix1_rangeley_config_show(struct aim_pvs_s* pvs) -{ - int i; - for(i = 0; x86_64_quanta_ix1_rangeley_config_settings[i].name; i++) { - aim_printf(pvs, "%s = %s\n", x86_64_quanta_ix1_rangeley_config_settings[i].name, x86_64_quanta_ix1_rangeley_config_settings[i].value); - } - return i; -} - -/* */ diff --git a/packages/platforms/quanta/x86-64/ix1-rangeley/onlp/builds/x86_64_quanta_ix1_rangeley/module/src/x86_64_quanta_ix1_rangeley_enums.c b/packages/platforms/quanta/x86-64/ix1-rangeley/onlp/builds/x86_64_quanta_ix1_rangeley/module/src/x86_64_quanta_ix1_rangeley_enums.c deleted file mode 100755 index b5189c401..000000000 --- a/packages/platforms/quanta/x86-64/ix1-rangeley/onlp/builds/x86_64_quanta_ix1_rangeley/module/src/x86_64_quanta_ix1_rangeley_enums.c +++ /dev/null @@ -1,10 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#include - -/* <--auto.start.enum(ALL).source> */ -/* */ - diff --git a/packages/platforms/quanta/x86-64/ix1-rangeley/onlp/builds/x86_64_quanta_ix1_rangeley/module/src/x86_64_quanta_ix1_rangeley_int.h b/packages/platforms/quanta/x86-64/ix1-rangeley/onlp/builds/x86_64_quanta_ix1_rangeley/module/src/x86_64_quanta_ix1_rangeley_int.h deleted file mode 100755 index 5b250e266..000000000 --- a/packages/platforms/quanta/x86-64/ix1-rangeley/onlp/builds/x86_64_quanta_ix1_rangeley/module/src/x86_64_quanta_ix1_rangeley_int.h +++ /dev/null @@ -1,308 +0,0 @@ -/**************************************************************************//** - * - * x86_64_quanta_ix1_rangeley Internal Header - * - *****************************************************************************/ -#ifndef __X86_64_QUANTA_IX1_RANGELEY_INT_H__ -#define __X86_64_QUANTA_IX1_RANGELEY_INT_H__ - -#include -#include - -/* */ -/** 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[]; - -/** 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 { - 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[]; - -/** 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 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 fan_alert; - int psu1_present; - int psu2_present; - int psu1_power_good; - int psu2_power_good; -}; - -#define SYS_HWMON_PREFIX "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/0-004e" - -#endif /* __X86_64_QUANTA_IX1_RANGELEY_INT_H__ */ diff --git a/packages/platforms/quanta/x86-64/ix1-rangeley/onlp/builds/x86_64_quanta_ix1_rangeley/module/src/x86_64_quanta_ix1_rangeley_log.c b/packages/platforms/quanta/x86-64/ix1-rangeley/onlp/builds/x86_64_quanta_ix1_rangeley/module/src/x86_64_quanta_ix1_rangeley_log.c deleted file mode 100755 index f8852bbfb..000000000 --- a/packages/platforms/quanta/x86-64/ix1-rangeley/onlp/builds/x86_64_quanta_ix1_rangeley/module/src/x86_64_quanta_ix1_rangeley_log.c +++ /dev/null @@ -1,18 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#include - -#include "x86_64_quanta_ix1_rangeley_log.h" -/* - * x86_64_quanta_ix1_rangeley log struct. - */ -AIM_LOG_STRUCT_DEFINE( - X86_64_QUANTA_IX1_RANGELEY_CONFIG_LOG_OPTIONS_DEFAULT, - X86_64_QUANTA_IX1_RANGELEY_CONFIG_LOG_BITS_DEFAULT, - NULL, /* Custom log map */ - X86_64_QUANTA_IX1_RANGELEY_CONFIG_LOG_CUSTOM_BITS_DEFAULT - ); - diff --git a/packages/platforms/quanta/x86-64/ix1-rangeley/onlp/builds/x86_64_quanta_ix1_rangeley/module/src/x86_64_quanta_ix1_rangeley_log.h b/packages/platforms/quanta/x86-64/ix1-rangeley/onlp/builds/x86_64_quanta_ix1_rangeley/module/src/x86_64_quanta_ix1_rangeley_log.h deleted file mode 100755 index 49dd2f61e..000000000 --- a/packages/platforms/quanta/x86-64/ix1-rangeley/onlp/builds/x86_64_quanta_ix1_rangeley/module/src/x86_64_quanta_ix1_rangeley_log.h +++ /dev/null @@ -1,12 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#ifndef __X86_64_QUANTA_IX1_RANGELEY_LOG_H__ -#define __X86_64_QUANTA_IX1_RANGELEY_LOG_H__ - -#define AIM_LOG_MODULE_NAME x86_64_quanta_ix1_rangeley -#include - -#endif /* __X86_64_QUANTA_IX1_RANGELEY_LOG_H__ */ diff --git a/packages/platforms/quanta/x86-64/ix1-rangeley/onlp/builds/x86_64_quanta_ix1_rangeley/module/src/x86_64_quanta_ix1_rangeley_module.c b/packages/platforms/quanta/x86-64/ix1-rangeley/onlp/builds/x86_64_quanta_ix1_rangeley/module/src/x86_64_quanta_ix1_rangeley_module.c deleted file mode 100755 index 084c2dc1b..000000000 --- a/packages/platforms/quanta/x86-64/ix1-rangeley/onlp/builds/x86_64_quanta_ix1_rangeley/module/src/x86_64_quanta_ix1_rangeley_module.c +++ /dev/null @@ -1,24 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#include - -#include "x86_64_quanta_ix1_rangeley_log.h" - -static int -datatypes_init__(void) -{ -#define X86_64_QUANTA_IX1_RANGELEY_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_ix1_rangeley_module_init__(void) -{ - AIM_LOG_STRUCT_REGISTER(); - datatypes_init__(); -} - -int __onlp_platform_version__ = 1; diff --git a/packages/platforms/quanta/x86-64/ix1-rangeley/onlp/builds/x86_64_quanta_ix1_rangeley/module/src/x86_64_quanta_ix1_rangeley_ucli.c b/packages/platforms/quanta/x86-64/ix1-rangeley/onlp/builds/x86_64_quanta_ix1_rangeley/module/src/x86_64_quanta_ix1_rangeley_ucli.c deleted file mode 100755 index 6407b37ac..000000000 --- a/packages/platforms/quanta/x86-64/ix1-rangeley/onlp/builds/x86_64_quanta_ix1_rangeley/module/src/x86_64_quanta_ix1_rangeley_ucli.c +++ /dev/null @@ -1,50 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#include - -#if X86_64_QUANTA_IX1_RANGELEY_CONFIG_INCLUDE_UCLI == 1 - -#include -#include -#include - -static ucli_status_t -x86_64_quanta_ix1_rangeley_ucli_ucli__config__(ucli_context_t* uc) -{ - UCLI_HANDLER_MACRO_MODULE_CONFIG(x86_64_quanta_ix1_rangeley) -} - -/* */ -/* */ - -static ucli_module_t -x86_64_quanta_ix1_rangeley_ucli_module__ = - { - "x86_64_quanta_ix1_rangeley_ucli", - NULL, - x86_64_quanta_ix1_rangeley_ucli_ucli_handlers__, - NULL, - NULL, - }; - -ucli_node_t* -x86_64_quanta_ix1_rangeley_ucli_node_create(void) -{ - ucli_node_t* n; - ucli_module_init(&x86_64_quanta_ix1_rangeley_ucli_module__); - n = ucli_node_create("x86_64_quanta_ix1_rangeley", NULL, &x86_64_quanta_ix1_rangeley_ucli_module__); - ucli_node_subnode_add(n, ucli_module_log_node_create("x86_64_quanta_ix1_rangeley")); - return n; -} - -#else -void* -x86_64_quanta_ix1_rangeley_ucli_node_create(void) -{ - return NULL; -} -#endif - diff --git a/packages/platforms/quanta/x86-64/ix1-rangeley/platform-config/Makefile b/packages/platforms/quanta/x86-64/ix1-rangeley/platform-config/Makefile deleted file mode 100755 index 003238cf6..000000000 --- a/packages/platforms/quanta/x86-64/ix1-rangeley/platform-config/Makefile +++ /dev/null @@ -1 +0,0 @@ -include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/quanta/x86-64/ix1-rangeley/platform-config/r0/Makefile b/packages/platforms/quanta/x86-64/ix1-rangeley/platform-config/r0/Makefile deleted file mode 100755 index 003238cf6..000000000 --- a/packages/platforms/quanta/x86-64/ix1-rangeley/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/quanta/x86-64/ix1-rangeley/platform-config/r0/PKG.yml b/packages/platforms/quanta/x86-64/ix1-rangeley/platform-config/r0/PKG.yml deleted file mode 100755 index be86d5c76..000000000 --- a/packages/platforms/quanta/x86-64/ix1-rangeley/platform-config/r0/PKG.yml +++ /dev/null @@ -1 +0,0 @@ -!include $ONL_TEMPLATES/platform-config-platform.yml ARCH=amd64 VENDOR=quanta BASENAME=x86-64-quanta-ix1-rangeley REVISION=r0 diff --git a/packages/platforms/quanta/x86-64/ix1-rangeley/platform-config/r0/src/lib/x86-64-quanta-ix1-rangeley-r0.yml b/packages/platforms/quanta/x86-64/ix1-rangeley/platform-config/r0/src/lib/x86-64-quanta-ix1-rangeley-r0.yml deleted file mode 100755 index e3aa6545d..000000000 --- a/packages/platforms/quanta/x86-64/ix1-rangeley/platform-config/r0/src/lib/x86-64-quanta-ix1-rangeley-r0.yml +++ /dev/null @@ -1,31 +0,0 @@ ---- - -###################################################################### -# -# platform-config for IX1 -# -###################################################################### - -x86-64-quanta-ix1-rangeley-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/ix1-rangeley/platform-config/r0/src/python/x86_64_quanta_ix1_rangeley_r0/__init__.py b/packages/platforms/quanta/x86-64/ix1-rangeley/platform-config/r0/src/python/x86_64_quanta_ix1_rangeley_r0/__init__.py deleted file mode 100755 index e77628c7f..000000000 --- a/packages/platforms/quanta/x86-64/ix1-rangeley/platform-config/r0/src/python/x86_64_quanta_ix1_rangeley_r0/__init__.py +++ /dev/null @@ -1,24 +0,0 @@ -from onl.platform.base import * -from onl.platform.quanta import * - -class OnlPlatform_x86_64_quanta_ix1_rangeley_r0(OnlPlatformQuanta, - OnlPlatformPortConfig_32x100): - PLATFORM='x86-64-quanta-ix1-rangeley-r0' - MODEL="IX1" - """ 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.3100" - - def baseconfig(self): - self.insmod("qci_pmbus") - self.insmod("qci_cpld") - self.insmod("quanta_hwmon_ix_series") - self.insmod("quanta_platform_ix1") - - return True diff --git a/packages/platforms/quanta/x86-64/ix1b-rglbmc/.gitignore b/packages/platforms/quanta/x86-64/ix1b-rglbmc/.gitignore deleted file mode 100755 index 6fb34116c..000000000 --- a/packages/platforms/quanta/x86-64/ix1b-rglbmc/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -*x86*64*quanta*ix1b*rglbmc.mk -onlpdump.mk diff --git a/packages/platforms/quanta/x86-64/ix1b-rglbmc/Makefile b/packages/platforms/quanta/x86-64/ix1b-rglbmc/Makefile deleted file mode 100755 index 003238cf6..000000000 --- a/packages/platforms/quanta/x86-64/ix1b-rglbmc/Makefile +++ /dev/null @@ -1 +0,0 @@ -include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/quanta/x86-64/ix1b-rglbmc/modules/Makefile b/packages/platforms/quanta/x86-64/ix1b-rglbmc/modules/Makefile deleted file mode 100755 index 003238cf6..000000000 --- a/packages/platforms/quanta/x86-64/ix1b-rglbmc/modules/Makefile +++ /dev/null @@ -1 +0,0 @@ -include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/quanta/x86-64/ix1b-rglbmc/modules/PKG.yml b/packages/platforms/quanta/x86-64/ix1b-rglbmc/modules/PKG.yml deleted file mode 100755 index 7e2623b43..000000000 --- a/packages/platforms/quanta/x86-64/ix1b-rglbmc/modules/PKG.yml +++ /dev/null @@ -1 +0,0 @@ -!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/ix1b-rglbmc/modules/builds/.gitignore b/packages/platforms/quanta/x86-64/ix1b-rglbmc/modules/builds/.gitignore deleted file mode 100755 index a65b41774..000000000 --- a/packages/platforms/quanta/x86-64/ix1b-rglbmc/modules/builds/.gitignore +++ /dev/null @@ -1 +0,0 @@ -lib diff --git a/packages/platforms/quanta/x86-64/ix1b-rglbmc/modules/builds/Makefile b/packages/platforms/quanta/x86-64/ix1b-rglbmc/modules/builds/Makefile deleted file mode 100755 index 1a7724c32..000000000 --- a/packages/platforms/quanta/x86-64/ix1b-rglbmc/modules/builds/Makefile +++ /dev/null @@ -1,6 +0,0 @@ -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/ix1b-rglbmc/modules/builds/quanta_platform_ix1b.c b/packages/platforms/quanta/x86-64/ix1b-rglbmc/modules/builds/quanta_platform_ix1b.c deleted file mode 100755 index 105dd2e7b..000000000 --- a/packages/platforms/quanta/x86-64/ix1b-rglbmc/modules/builds/quanta_platform_ix1b.c +++ /dev/null @@ -1,326 +0,0 @@ -/* - * 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 - -/* <--auto.start.xmacro(ALL).define> */ -/* */ - -/* <--auto.start.xenum(ALL).define> */ -/* */ - - diff --git a/packages/platforms/quanta/x86-64/ix1b-rglbmc/onlp/builds/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/ix1b-rglbmc/onlp/builds/x86_64_quanta_ix1b_rglbmc/module/inc/x86_64_quanta_ix1b_rglbmc/x86_64_quanta_ix1b_rglbmc_config.h deleted file mode 100755 index c84b8f89b..000000000 --- a/packages/platforms/quanta/x86-64/ix1b-rglbmc/onlp/builds/x86_64_quanta_ix1b_rglbmc/module/inc/x86_64_quanta_ix1b_rglbmc/x86_64_quanta_ix1b_rglbmc_config.h +++ /dev/null @@ -1,167 +0,0 @@ -/**************************************************************************//** - * - * @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/ix1b-rglbmc/onlp/builds/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/ix1b-rglbmc/onlp/builds/x86_64_quanta_ix1b_rglbmc/module/inc/x86_64_quanta_ix1b_rglbmc/x86_64_quanta_ix1b_rglbmc_dox.h deleted file mode 100755 index 23d74b2e1..000000000 --- a/packages/platforms/quanta/x86-64/ix1b-rglbmc/onlp/builds/x86_64_quanta_ix1b_rglbmc/module/inc/x86_64_quanta_ix1b_rglbmc/x86_64_quanta_ix1b_rglbmc_dox.h +++ /dev/null @@ -1,26 +0,0 @@ -/**************************************************************************//** - * - * 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/ix1b-rglbmc/onlp/builds/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/ix1b-rglbmc/onlp/builds/x86_64_quanta_ix1b_rglbmc/module/inc/x86_64_quanta_ix1b_rglbmc/x86_64_quanta_ix1b_rglbmc_gpio_table.h deleted file mode 100755 index 39eacc305..000000000 --- a/packages/platforms/quanta/x86-64/ix1b-rglbmc/onlp/builds/x86_64_quanta_ix1b_rglbmc/module/inc/x86_64_quanta_ix1b_rglbmc/x86_64_quanta_ix1b_rglbmc_gpio_table.h +++ /dev/null @@ -1,55 +0,0 @@ -#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/ix1b-rglbmc/onlp/builds/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/ix1b-rglbmc/onlp/builds/x86_64_quanta_ix1b_rglbmc/module/inc/x86_64_quanta_ix1b_rglbmc/x86_64_quanta_ix1b_rglbmc_porting.h deleted file mode 100755 index 5b01e91bb..000000000 --- a/packages/platforms/quanta/x86-64/ix1b-rglbmc/onlp/builds/x86_64_quanta_ix1b_rglbmc/module/inc/x86_64_quanta_ix1b_rglbmc/x86_64_quanta_ix1b_rglbmc_porting.h +++ /dev/null @@ -1,77 +0,0 @@ -/**************************************************************************//** - * - * @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_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/ix1b-rglbmc/onlp/builds/x86_64_quanta_ix1b_rglbmc/module/make.mk b/packages/platforms/quanta/x86-64/ix1b-rglbmc/onlp/builds/x86_64_quanta_ix1b_rglbmc/module/make.mk deleted file mode 100755 index facfa9329..000000000 --- a/packages/platforms/quanta/x86-64/ix1b-rglbmc/onlp/builds/x86_64_quanta_ix1b_rglbmc/module/make.mk +++ /dev/null @@ -1,10 +0,0 @@ -############################################################################### -# -# -# -############################################################################### -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/ix1b-rglbmc/onlp/builds/x86_64_quanta_ix1b_rglbmc/module/src/Makefile b/packages/platforms/quanta/x86-64/ix1b-rglbmc/onlp/builds/x86_64_quanta_ix1b_rglbmc/module/src/Makefile deleted file mode 100755 index 4df4b050d..000000000 --- a/packages/platforms/quanta/x86-64/ix1b-rglbmc/onlp/builds/x86_64_quanta_ix1b_rglbmc/module/src/Makefile +++ /dev/null @@ -1,9 +0,0 @@ -############################################################################### -# -# Local source generation targets. -# -############################################################################### - -ucli: - @../../../../tools/uclihandlers.py x86_64_quanta_ix1b_rglbmc_ucli.c - diff --git a/packages/platforms/quanta/x86-64/ix1b-rglbmc/onlp/builds/x86_64_quanta_ix1b_rglbmc/module/src/fani.c b/packages/platforms/quanta/x86-64/ix1b-rglbmc/onlp/builds/x86_64_quanta_ix1b_rglbmc/module/src/fani.c deleted file mode 100755 index 3a6611841..000000000 --- a/packages/platforms/quanta/x86-64/ix1b-rglbmc/onlp/builds/x86_64_quanta_ix1b_rglbmc/module/src/fani.c +++ /dev/null @@ -1,71 +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 "x86_64_quanta_ix1b_rglbmc_int.h" -#include - -int -onlp_fani_init(void) -{ - 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/ix1b-rglbmc/onlp/builds/x86_64_quanta_ix1b_rglbmc/module/src/ledi.c b/packages/platforms/quanta/x86-64/ix1b-rglbmc/onlp/builds/x86_64_quanta_ix1b_rglbmc/module/src/ledi.c deleted file mode 100755 index 95db75af6..000000000 --- a/packages/platforms/quanta/x86-64/ix1b-rglbmc/onlp/builds/x86_64_quanta_ix1b_rglbmc/module/src/ledi.c +++ /dev/null @@ -1,229 +0,0 @@ -#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/ix1b-rglbmc/onlp/builds/x86_64_quanta_ix1b_rglbmc/module/src/make.mk b/packages/platforms/quanta/x86-64/ix1b-rglbmc/onlp/builds/x86_64_quanta_ix1b_rglbmc/module/src/make.mk deleted file mode 100755 index b34565952..000000000 --- a/packages/platforms/quanta/x86-64/ix1b-rglbmc/onlp/builds/x86_64_quanta_ix1b_rglbmc/module/src/make.mk +++ /dev/null @@ -1,9 +0,0 @@ -############################################################################### -# -# -# -############################################################################### - -LIBRARY := x86_64_quanta_ix1b_rglbmc -$(LIBRARY)_SUBDIR := $(dir $(lastword $(MAKEFILE_LIST))) -include $(BUILDER)/lib.mk diff --git a/packages/platforms/quanta/x86-64/ix1b-rglbmc/onlp/builds/x86_64_quanta_ix1b_rglbmc/module/src/psui.c b/packages/platforms/quanta/x86-64/ix1b-rglbmc/onlp/builds/x86_64_quanta_ix1b_rglbmc/module/src/psui.c deleted file mode 100755 index 51c50814f..000000000 --- a/packages/platforms/quanta/x86-64/ix1b-rglbmc/onlp/builds/x86_64_quanta_ix1b_rglbmc/module/src/psui.c +++ /dev/null @@ -1,119 +0,0 @@ -/************************************************************ - * - * - ************************************************************ - * - * - * - ***********************************************************/ -#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/ix1b-rglbmc/onlp/builds/x86_64_quanta_ix1b_rglbmc/module/src/sfpi.c b/packages/platforms/quanta/x86-64/ix1b-rglbmc/onlp/builds/x86_64_quanta_ix1b_rglbmc/module/src/sfpi.c deleted file mode 100755 index 6b695f2c3..000000000 --- a/packages/platforms/quanta/x86-64/ix1b-rglbmc/onlp/builds/x86_64_quanta_ix1b_rglbmc/module/src/sfpi.c +++ /dev/null @@ -1,244 +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. - * - * - ************************************************************ - * - * 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/ix1b-rglbmc/onlp/builds/x86_64_quanta_ix1b_rglbmc/module/src/sysi.c b/packages/platforms/quanta/x86-64/ix1b-rglbmc/onlp/builds/x86_64_quanta_ix1b_rglbmc/module/src/sysi.c deleted file mode 100755 index 3839337d2..000000000 --- a/packages/platforms/quanta/x86-64/ix1b-rglbmc/onlp/builds/x86_64_quanta_ix1b_rglbmc/module/src/sysi.c +++ /dev/null @@ -1,253 +0,0 @@ -/************************************************************ - * - * - ************************************************************ - * - * - * - ***********************************************************/ -#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/ix1b-rglbmc/onlp/builds/x86_64_quanta_ix1b_rglbmc/module/src/thermali.c b/packages/platforms/quanta/x86-64/ix1b-rglbmc/onlp/builds/x86_64_quanta_ix1b_rglbmc/module/src/thermali.c deleted file mode 100755 index 2a84c0178..000000000 --- a/packages/platforms/quanta/x86-64/ix1b-rglbmc/onlp/builds/x86_64_quanta_ix1b_rglbmc/module/src/thermali.c +++ /dev/null @@ -1,31 +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 - -int -onlp_thermali_init(void) -{ - return ONLP_STATUS_E_UNSUPPORTED; -} diff --git a/packages/platforms/quanta/x86-64/ix1b-rglbmc/onlp/builds/x86_64_quanta_ix1b_rglbmc/module/src/x86_64_quanta_ix1b_rglbmc_config.c b/packages/platforms/quanta/x86-64/ix1b-rglbmc/onlp/builds/x86_64_quanta_ix1b_rglbmc/module/src/x86_64_quanta_ix1b_rglbmc_config.c deleted file mode 100755 index 84409c950..000000000 --- a/packages/platforms/quanta/x86-64/ix1b-rglbmc/onlp/builds/x86_64_quanta_ix1b_rglbmc/module/src/x86_64_quanta_ix1b_rglbmc_config.c +++ /dev/null @@ -1,95 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#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/ix1b-rglbmc/onlp/builds/x86_64_quanta_ix1b_rglbmc/module/src/x86_64_quanta_ix1b_rglbmc_enums.c b/packages/platforms/quanta/x86-64/ix1b-rglbmc/onlp/builds/x86_64_quanta_ix1b_rglbmc/module/src/x86_64_quanta_ix1b_rglbmc_enums.c deleted file mode 100755 index e31c1e1e8..000000000 --- a/packages/platforms/quanta/x86-64/ix1b-rglbmc/onlp/builds/x86_64_quanta_ix1b_rglbmc/module/src/x86_64_quanta_ix1b_rglbmc_enums.c +++ /dev/null @@ -1,10 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#include - -/* <--auto.start.enum(ALL).source> */ -/* */ - diff --git a/packages/platforms/quanta/x86-64/ix1b-rglbmc/onlp/builds/x86_64_quanta_ix1b_rglbmc/module/src/x86_64_quanta_ix1b_rglbmc_int.h b/packages/platforms/quanta/x86-64/ix1b-rglbmc/onlp/builds/x86_64_quanta_ix1b_rglbmc/module/src/x86_64_quanta_ix1b_rglbmc_int.h deleted file mode 100755 index 505d5fa7a..000000000 --- a/packages/platforms/quanta/x86-64/ix1b-rglbmc/onlp/builds/x86_64_quanta_ix1b_rglbmc/module/src/x86_64_quanta_ix1b_rglbmc_int.h +++ /dev/null @@ -1,311 +0,0 @@ -/**************************************************************************//** - * - * 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 - -/* */ -/** 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[]; - -/** 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 { - 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[]; - -/** 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 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/ix1b-rglbmc/onlp/builds/x86_64_quanta_ix1b_rglbmc/module/src/x86_64_quanta_ix1b_rglbmc_log.c b/packages/platforms/quanta/x86-64/ix1b-rglbmc/onlp/builds/x86_64_quanta_ix1b_rglbmc/module/src/x86_64_quanta_ix1b_rglbmc_log.c deleted file mode 100755 index 555f1be92..000000000 --- a/packages/platforms/quanta/x86-64/ix1b-rglbmc/onlp/builds/x86_64_quanta_ix1b_rglbmc/module/src/x86_64_quanta_ix1b_rglbmc_log.c +++ /dev/null @@ -1,18 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#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/ix1b-rglbmc/onlp/builds/x86_64_quanta_ix1b_rglbmc/module/src/x86_64_quanta_ix1b_rglbmc_log.h b/packages/platforms/quanta/x86-64/ix1b-rglbmc/onlp/builds/x86_64_quanta_ix1b_rglbmc/module/src/x86_64_quanta_ix1b_rglbmc_log.h deleted file mode 100755 index 54251205a..000000000 --- a/packages/platforms/quanta/x86-64/ix1b-rglbmc/onlp/builds/x86_64_quanta_ix1b_rglbmc/module/src/x86_64_quanta_ix1b_rglbmc_log.h +++ /dev/null @@ -1,12 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#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/ix1b-rglbmc/onlp/builds/x86_64_quanta_ix1b_rglbmc/module/src/x86_64_quanta_ix1b_rglbmc_module.c b/packages/platforms/quanta/x86-64/ix1b-rglbmc/onlp/builds/x86_64_quanta_ix1b_rglbmc/module/src/x86_64_quanta_ix1b_rglbmc_module.c deleted file mode 100755 index 5bb979a8a..000000000 --- a/packages/platforms/quanta/x86-64/ix1b-rglbmc/onlp/builds/x86_64_quanta_ix1b_rglbmc/module/src/x86_64_quanta_ix1b_rglbmc_module.c +++ /dev/null @@ -1,24 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#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/ix1b-rglbmc/onlp/builds/x86_64_quanta_ix1b_rglbmc/module/src/x86_64_quanta_ix1b_rglbmc_ucli.c b/packages/platforms/quanta/x86-64/ix1b-rglbmc/onlp/builds/x86_64_quanta_ix1b_rglbmc/module/src/x86_64_quanta_ix1b_rglbmc_ucli.c deleted file mode 100755 index 14397e5c3..000000000 --- a/packages/platforms/quanta/x86-64/ix1b-rglbmc/onlp/builds/x86_64_quanta_ix1b_rglbmc/module/src/x86_64_quanta_ix1b_rglbmc_ucli.c +++ /dev/null @@ -1,50 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#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/ix1b-rglbmc/platform-config/Makefile b/packages/platforms/quanta/x86-64/ix1b-rglbmc/platform-config/Makefile deleted file mode 100755 index 003238cf6..000000000 --- a/packages/platforms/quanta/x86-64/ix1b-rglbmc/platform-config/Makefile +++ /dev/null @@ -1 +0,0 @@ -include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/quanta/x86-64/ix1b-rglbmc/platform-config/r0/Makefile b/packages/platforms/quanta/x86-64/ix1b-rglbmc/platform-config/r0/Makefile deleted file mode 100755 index 003238cf6..000000000 --- a/packages/platforms/quanta/x86-64/ix1b-rglbmc/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/quanta/x86-64/ix1b-rglbmc/platform-config/r0/PKG.yml b/packages/platforms/quanta/x86-64/ix1b-rglbmc/platform-config/r0/PKG.yml deleted file mode 100755 index de85e9925..000000000 --- a/packages/platforms/quanta/x86-64/ix1b-rglbmc/platform-config/r0/PKG.yml +++ /dev/null @@ -1 +0,0 @@ -!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/ix1b-rglbmc/platform-config/r0/src/lib/x86-64-quanta-ix1b-rglbmc-r0.yml b/packages/platforms/quanta/x86-64/ix1b-rglbmc/platform-config/r0/src/lib/x86-64-quanta-ix1b-rglbmc-r0.yml deleted file mode 100755 index bfe684bd5..000000000 --- a/packages/platforms/quanta/x86-64/ix1b-rglbmc/platform-config/r0/src/lib/x86-64-quanta-ix1b-rglbmc-r0.yml +++ /dev/null @@ -1,31 +0,0 @@ ---- - -###################################################################### -# -# 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/ix1b-rglbmc/platform-config/r0/src/python/x86_64_quanta_ix1b_rglbmc_r0/__init__.py b/packages/platforms/quanta/x86-64/ix1b-rglbmc/platform-config/r0/src/python/x86_64_quanta_ix1b_rglbmc_r0/__init__.py deleted file mode 100755 index 882b01328..000000000 --- a/packages/platforms/quanta/x86-64/ix1b-rglbmc/platform-config/r0/src/python/x86_64_quanta_ix1b_rglbmc_r0/__init__.py +++ /dev/null @@ -1,23 +0,0 @@ -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 diff --git a/packages/platforms/quanta/x86-64/ix2-rangeley/.gitignore b/packages/platforms/quanta/x86-64/ix2-rangeley/.gitignore deleted file mode 100755 index 05b8d7580..000000000 --- a/packages/platforms/quanta/x86-64/ix2-rangeley/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -*x86*64*quanta*ix2*rangeley.mk -onlpdump.mk diff --git a/packages/platforms/quanta/x86-64/ix2-rangeley/Makefile b/packages/platforms/quanta/x86-64/ix2-rangeley/Makefile deleted file mode 100755 index 003238cf6..000000000 --- a/packages/platforms/quanta/x86-64/ix2-rangeley/Makefile +++ /dev/null @@ -1 +0,0 @@ -include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/quanta/x86-64/ix2-rangeley/modules/Makefile b/packages/platforms/quanta/x86-64/ix2-rangeley/modules/Makefile deleted file mode 100755 index 003238cf6..000000000 --- a/packages/platforms/quanta/x86-64/ix2-rangeley/modules/Makefile +++ /dev/null @@ -1 +0,0 @@ -include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/quanta/x86-64/ix2-rangeley/modules/PKG.yml b/packages/platforms/quanta/x86-64/ix2-rangeley/modules/PKG.yml deleted file mode 100755 index 5417a2dc2..000000000 --- a/packages/platforms/quanta/x86-64/ix2-rangeley/modules/PKG.yml +++ /dev/null @@ -1 +0,0 @@ -!include $ONL_TEMPLATES/platform-modules.yml ARCH=amd64 VENDOR=quanta BASENAME=x86-64-quanta-ix2-rangeley KERNELS="onl-kernel-3.16-lts-x86-64-all:amd64" diff --git a/packages/platforms/quanta/x86-64/ix2-rangeley/modules/builds/.gitignore b/packages/platforms/quanta/x86-64/ix2-rangeley/modules/builds/.gitignore deleted file mode 100755 index a65b41774..000000000 --- a/packages/platforms/quanta/x86-64/ix2-rangeley/modules/builds/.gitignore +++ /dev/null @@ -1 +0,0 @@ -lib diff --git a/packages/platforms/quanta/x86-64/ix2-rangeley/modules/builds/Makefile b/packages/platforms/quanta/x86-64/ix2-rangeley/modules/builds/Makefile deleted file mode 100755 index 4af778a2b..000000000 --- a/packages/platforms/quanta/x86-64/ix2-rangeley/modules/builds/Makefile +++ /dev/null @@ -1,6 +0,0 @@ -KERNELS := onl-kernel-3.16-lts-x86-64-all:amd64 -KMODULES := $(wildcard *.c) -VENDOR := quanta -BASENAME := x86-64-quanta-ix2-rangeley -ARCH := x86_64 -include $(ONL)/make/kmodule.mk diff --git a/packages/platforms/quanta/x86-64/ix2-rangeley/modules/builds/quanta_platform_ix2.c b/packages/platforms/quanta/x86-64/ix2-rangeley/modules/builds/quanta_platform_ix2.c deleted file mode 100755 index d102817d0..000000000 --- a/packages/platforms/quanta/x86-64/ix2-rangeley/modules/builds/quanta_platform_ix2.c +++ /dev/null @@ -1,361 +0,0 @@ -/* - * 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-ix2" - -#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_ix2, - i2c_type_quanta_ix2_hwmon, -}; - -char *i2c_type_names[] = { - "spd", - "ds1339", - "pca9546", - "pca9548", - "pca9554", - "pca9555", - "pca9698", - "CPLD-SFP28", - "24c02", - "qci_pmbus_ix2", - "quanta_ix2_hwmon", -}; - -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_ix2_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_quanta_ix2_hwmon, .addr = 0x4e, .name = "PSoc\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 = 0x73, .busno = 0x38, .name = "PCA9548_4\0" }, - { .parent_bus = (0x10 + 1), .type = i2c_type_pca9548, .addr = 0x74, .busno = 0x40, .name = "PCA9548_5\0" }, - { .parent_bus = (0x10 + 1), .type = i2c_type_pca9548, .addr = 0x75, .busno = 0x48, .name = "PCA9548_6\0" }, - { .parent_bus = (0x10 + 0), .type = i2c_type_qci_cpld, .addr = 0x38, .name = "qci_cpld(1-16)\0" }, - { .parent_bus = (0x10 + 0), .type = i2c_type_qci_cpld, .addr = 0x39, .name = "qci_cpld(17-32)\0" }, - { .parent_bus = (0x10 + 1), .type = i2c_type_qci_cpld, .addr = 0x38, .name = "qci_cpld(33-48)\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 = (0x10 + 2), .type = i2c_type_pca9548, .addr = 0x73, .busno = 0x50, .name = "PCA9548_7\0" }, - { .parent_bus = (0x10 + 1), .type = i2c_type_pca9698, .addr = 0x21, .gpio_base = 0x50, .name = "PCA9698(QSFP_1-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 + 4), .type = i2c_type_24c02, .addr = 0x50, .name = "QSFP_5_EEPROM\0" }, - { .parent_bus = (0x50 + 5), .type = i2c_type_24c02, .addr = 0x50, .name = "QSFP_6_EEPROM\0" }, - { .parent_bus = (0x50 + 6), .type = i2c_type_24c02, .addr = 0x50, .name = "QSFP_7_EEPROM\0" }, - { .parent_bus = (0x50 + 7), .type = i2c_type_24c02, .addr = 0x50, .name = "QSFP_8_EEPROM\0" }, - - { .parent_bus = (0x00 + 0), .type = i2c_type_pca9546, .addr = 0x72, .busno = 0x14, .name = "PCA9546_2\0" }, - { .parent_bus = (0x14 + 0), .type = i2c_type_qci_pmbus_ix2, .addr = 0x5f, .name = "PSU_1\0" }, - { .parent_bus = (0x14 + 1), .type = i2c_type_qci_pmbus_ix2, .addr = 0x59, .name = "PSU_2\0" }, - { .parent_bus = (0x14 + 2), .type = i2c_type_pca9555, .addr = 0x26, .gpio_base = 0x10, .name = "PCA9555-1(PSU)\0" }, - { .parent_bus = (0x14 + 2), .type = i2c_type_24c02, .addr = 0x54, .name = "Board_EEPROM\0" }, - { .parent_bus = (0x14 + 2), .type = i2c_type_pca9555, .addr = 0x23, .gpio_base = 0x20, .name = "PCA9555-2(Board ID)\0" }, - { .parent_bus = (0x14 + 3), .type = i2c_type_pca9555, .addr = 0x25, .gpio_base = 0x30, .name = "PCA9555-3(FAN IO)\0" }, - { .parent_bus = (0x14 + 3), .type = i2c_type_pca9555, .addr = 0x26, .name = "PCA9555-6(BMC)\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 - -/* <--auto.start.xmacro(ALL).define> */ -/* */ - -/* <--auto.start.xenum(ALL).define> */ -/* */ - - diff --git a/packages/platforms/quanta/x86-64/ix2-rangeley/onlp/builds/x86_64_quanta_ix2_rangeley/module/inc/x86_64_quanta_ix2_rangeley/x86_64_quanta_ix2_rangeley_config.h b/packages/platforms/quanta/x86-64/ix2-rangeley/onlp/builds/x86_64_quanta_ix2_rangeley/module/inc/x86_64_quanta_ix2_rangeley/x86_64_quanta_ix2_rangeley_config.h deleted file mode 100755 index ecc110800..000000000 --- a/packages/platforms/quanta/x86-64/ix2-rangeley/onlp/builds/x86_64_quanta_ix2_rangeley/module/inc/x86_64_quanta_ix2_rangeley/x86_64_quanta_ix2_rangeley_config.h +++ /dev/null @@ -1,167 +0,0 @@ -/**************************************************************************//** - * - * @file - * @brief x86_64_quanta_ix2_rangeley Configuration Header - * - * @addtogroup x86_64_quanta_ix2_rangeley-config - * @{ - * - *****************************************************************************/ -#ifndef __X86_64_QUANTA_IX2_RANGELEY_CONFIG_H__ -#define __X86_64_QUANTA_IX2_RANGELEY_CONFIG_H__ - -#ifdef GLOBAL_INCLUDE_CUSTOM_CONFIG -#include -#endif -#ifdef X86_64_QUANTA_IX2_RANGELEY_INCLUDE_CUSTOM_CONFIG -#include -#endif - -/* */ -#include -/** - * X86_64_QUANTA_IX2_RANGELEY_CONFIG_INCLUDE_LOGGING - * - * Include or exclude logging. */ - - -#ifndef X86_64_QUANTA_IX2_RANGELEY_CONFIG_INCLUDE_LOGGING -#define X86_64_QUANTA_IX2_RANGELEY_CONFIG_INCLUDE_LOGGING 1 -#endif - -/** - * X86_64_QUANTA_IX2_RANGELEY_CONFIG_LOG_OPTIONS_DEFAULT - * - * Default enabled log options. */ - - -#ifndef X86_64_QUANTA_IX2_RANGELEY_CONFIG_LOG_OPTIONS_DEFAULT -#define X86_64_QUANTA_IX2_RANGELEY_CONFIG_LOG_OPTIONS_DEFAULT AIM_LOG_OPTIONS_DEFAULT -#endif - -/** - * X86_64_QUANTA_IX2_RANGELEY_CONFIG_LOG_BITS_DEFAULT - * - * Default enabled log bits. */ - - -#ifndef X86_64_QUANTA_IX2_RANGELEY_CONFIG_LOG_BITS_DEFAULT -#define X86_64_QUANTA_IX2_RANGELEY_CONFIG_LOG_BITS_DEFAULT AIM_LOG_BITS_DEFAULT -#endif - -/** - * X86_64_QUANTA_IX2_RANGELEY_CONFIG_LOG_CUSTOM_BITS_DEFAULT - * - * Default enabled custom log bits. */ - - -#ifndef X86_64_QUANTA_IX2_RANGELEY_CONFIG_LOG_CUSTOM_BITS_DEFAULT -#define X86_64_QUANTA_IX2_RANGELEY_CONFIG_LOG_CUSTOM_BITS_DEFAULT 0 -#endif - -/** - * X86_64_QUANTA_IX2_RANGELEY_CONFIG_PORTING_STDLIB - * - * Default all porting macros to use the C standard libraries. */ - - -#ifndef X86_64_QUANTA_IX2_RANGELEY_CONFIG_PORTING_STDLIB -#define X86_64_QUANTA_IX2_RANGELEY_CONFIG_PORTING_STDLIB 1 -#endif - -/** - * X86_64_QUANTA_IX2_RANGELEY_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS - * - * Include standard library headers for stdlib porting macros. */ - - -#ifndef X86_64_QUANTA_IX2_RANGELEY_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS -#define X86_64_QUANTA_IX2_RANGELEY_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS X86_64_QUANTA_IX2_RANGELEY_CONFIG_PORTING_STDLIB -#endif - -/** - * X86_64_QUANTA_IX2_RANGELEY_CONFIG_INCLUDE_UCLI - * - * Include generic uCli support. */ - - -#ifndef X86_64_QUANTA_IX2_RANGELEY_CONFIG_INCLUDE_UCLI -#define X86_64_QUANTA_IX2_RANGELEY_CONFIG_INCLUDE_UCLI 0 -#endif - -/** - * X86_64_QUANTA_IX2_RANGELEY_CONFIG_SYSFAN_RPM_FAILURE_THRESHOLD - * - * RPM Threshold at which the fan is considered to have failed. */ - - -#ifndef X86_64_QUANTA_IX2_RANGELEY_CONFIG_SYSFAN_RPM_FAILURE_THRESHOLD -#define X86_64_QUANTA_IX2_RANGELEY_CONFIG_SYSFAN_RPM_FAILURE_THRESHOLD 3000 -#endif - -/** - * X86_64_QUANTA_IX2_RANGELEY_CONFIG_SYSFAN_F2B_RPM_MAX - * - * Maximum system front-to-back fan speed. */ - - -#ifndef X86_64_QUANTA_IX2_RANGELEY_CONFIG_SYSFAN_F2B_RPM_MAX -#define X86_64_QUANTA_IX2_RANGELEY_CONFIG_SYSFAN_F2B_RPM_MAX 18000 -#endif - -/** - * X86_64_QUANTA_IX2_RANGELEY_CONFIG_SYSFAN_B2F_RPM_MAX - * - * Maximum system back-to-front fan speed. */ - - -#ifndef X86_64_QUANTA_IX2_RANGELEY_CONFIG_SYSFAN_B2F_RPM_MAX -#define X86_64_QUANTA_IX2_RANGELEY_CONFIG_SYSFAN_B2F_RPM_MAX 18000 -#endif - -/** - * X86_64_QUANTA_IX2_RANGELEY_CONFIG_PHY_RESET_DELAY_MS - * - * Time to hold Phy GPIO in reset, in ms */ - - -#ifndef X86_64_QUANTA_IX2_RANGELEY_CONFIG_PHY_RESET_DELAY_MS -#define X86_64_QUANTA_IX2_RANGELEY_CONFIG_PHY_RESET_DELAY_MS 100 -#endif - - - -/** - * All compile time options can be queried or displayed - */ - -/** Configuration settings structure. */ -typedef struct x86_64_quanta_ix2_rangeley_config_settings_s { - /** name */ - const char* name; - /** value */ - const char* value; -} x86_64_quanta_ix2_rangeley_config_settings_t; - -/** Configuration settings table. */ -/** x86_64_quanta_ix2_rangeley_config_settings table. */ -extern x86_64_quanta_ix2_rangeley_config_settings_t x86_64_quanta_ix2_rangeley_config_settings[]; - -/** - * @brief Lookup a configuration setting. - * @param setting The name of the configuration option to lookup. - */ -const char* x86_64_quanta_ix2_rangeley_config_lookup(const char* setting); - -/** - * @brief Show the compile-time configuration. - * @param pvs The output stream. - */ -int x86_64_quanta_ix2_rangeley_config_show(struct aim_pvs_s* pvs); - -/* */ - -#include "x86_64_quanta_ix2_rangeley_porting.h" - -#endif /* __X86_64_QUANTA_IX2_RANGELEY_CONFIG_H__ */ -/* @} */ diff --git a/packages/platforms/quanta/x86-64/ix2-rangeley/onlp/builds/x86_64_quanta_ix2_rangeley/module/inc/x86_64_quanta_ix2_rangeley/x86_64_quanta_ix2_rangeley_dox.h b/packages/platforms/quanta/x86-64/ix2-rangeley/onlp/builds/x86_64_quanta_ix2_rangeley/module/inc/x86_64_quanta_ix2_rangeley/x86_64_quanta_ix2_rangeley_dox.h deleted file mode 100755 index 871a3c0bf..000000000 --- a/packages/platforms/quanta/x86-64/ix2-rangeley/onlp/builds/x86_64_quanta_ix2_rangeley/module/inc/x86_64_quanta_ix2_rangeley/x86_64_quanta_ix2_rangeley_dox.h +++ /dev/null @@ -1,26 +0,0 @@ -/**************************************************************************//** - * - * x86_64_quanta_ix2_rangeley Doxygen Header - * - *****************************************************************************/ -#ifndef __X86_64_QUANTA_IX2_RANGELEY_DOX_H__ -#define __X86_64_QUANTA_IX2_RANGELEY_DOX_H__ - -/** - * @defgroup x86_64_quanta_ix2_rangeley x86_64_quanta_ix2_rangeley - x86_64_quanta_ix2_rangeley Description - * - -The documentation overview for this module should go here. - - * - * @{ - * - * @defgroup x86_64_quanta_ix2_rangeley-x86_64_quanta_ix2_rangeley Public Interface - * @defgroup x86_64_quanta_ix2_rangeley-config Compile Time Configuration - * @defgroup x86_64_quanta_ix2_rangeley-porting Porting Macros - * - * @} - * - */ - -#endif /* __X86_64_QUANTA_IX2_RANGELEY_DOX_H__ */ diff --git a/packages/platforms/quanta/x86-64/ix2-rangeley/onlp/builds/x86_64_quanta_ix2_rangeley/module/inc/x86_64_quanta_ix2_rangeley/x86_64_quanta_ix2_rangeley_gpio_table.h b/packages/platforms/quanta/x86-64/ix2-rangeley/onlp/builds/x86_64_quanta_ix2_rangeley/module/inc/x86_64_quanta_ix2_rangeley/x86_64_quanta_ix2_rangeley_gpio_table.h deleted file mode 100755 index e31cb4009..000000000 --- a/packages/platforms/quanta/x86-64/ix2-rangeley/onlp/builds/x86_64_quanta_ix2_rangeley/module/inc/x86_64_quanta_ix2_rangeley/x86_64_quanta_ix2_rangeley_gpio_table.h +++ /dev/null @@ -1,79 +0,0 @@ -#ifndef __X86_64_QUANTA_IX2_RANGELEY_GPIO_TABLE_H__ -#define __X86_64_QUANTA_IX2_RANGELEY_GPIO_TABLE_H__ - -/* - * defined within platform/quanta_switch.c - * Quanta Switch Platform driver - */ -#define QUANTA_IX2_PCA953x_GPIO(P1, P2) (P1*8+P2) - -#define QUANTA_IX2_PCA9555_GPIO_SIZE 0x10 - -#define QUANTA_IX2_I2C_GPIO_CPU_BASE 0x40 - -#define QUANTA_IX2_CPU_BOARD_GPIO_BASE (QUANTA_IX2_I2C_GPIO_CPU_BASE) -#define QUANTA_IX2_CPU_BOARD_SYS_P1 (QUANTA_IX2_CPU_BOARD_GPIO_BASE + QUANTA_IX2_PCA953x_GPIO(1,2)) -#define QUANTA_IX2_CPU_BOARD_SYS_P2 (QUANTA_IX2_CPU_BOARD_GPIO_BASE + QUANTA_IX2_PCA953x_GPIO(1,3)) - -#define QUANTA_IX2_PSU_GPIO_BASE 0x10 -#define QUANTA_IX2_PSU_GPIO_SIZE QUANTA_IX2_PCA9555_GPIO_SIZE -#define QUANTA_IX2_PSU_GPIO_PSU1_PRSNT_N (QUANTA_IX2_PSU_GPIO_BASE + QUANTA_IX2_PCA953x_GPIO(0,0)) -#define QUANTA_IX2_PSU_GPIO_PSU1_PWRGD (QUANTA_IX2_PSU_GPIO_BASE + QUANTA_IX2_PCA953x_GPIO(0,1)) -#define QUANTA_IX2_PSU_GPIO_PSU2_PRSNT_N (QUANTA_IX2_PSU_GPIO_BASE + QUANTA_IX2_PCA953x_GPIO(0,3)) -#define QUANTA_IX2_PSU_GPIO_PSU2_PWRGD (QUANTA_IX2_PSU_GPIO_BASE + QUANTA_IX2_PCA953x_GPIO(0,4)) -#define QUANTA_IX2_PSU_GPIO_PSU1_AC_OK (QUANTA_IX2_PSU_GPIO_BASE + QUANTA_IX2_PCA953x_GPIO(0,6)) -#define QUANTA_IX2_PSU_GPIO_PSU2_AC_OK (QUANTA_IX2_PSU_GPIO_BASE + QUANTA_IX2_PCA953x_GPIO(0,7)) -#define QUANTA_IX2_PSU_GPIO_PSU1_GREEN_R (QUANTA_IX2_PSU_GPIO_BASE + QUANTA_IX2_PCA953x_GPIO(1,2)) -#define QUANTA_IX2_PSU_GPIO_PSU1_RED_R (QUANTA_IX2_PSU_GPIO_BASE + QUANTA_IX2_PCA953x_GPIO(1,3)) -#define QUANTA_IX2_PSU_GPIO_PSU2_GREEN_R (QUANTA_IX2_PSU_GPIO_BASE + QUANTA_IX2_PCA953x_GPIO(1,4)) -#define QUANTA_IX2_PSU_GPIO_PSU2_RED_R (QUANTA_IX2_PSU_GPIO_BASE + QUANTA_IX2_PCA953x_GPIO(1,5)) -#define QUANTA_IX2_PSU_GPIO_FAN_GREEN_R (QUANTA_IX2_PSU_GPIO_BASE + QUANTA_IX2_PCA953x_GPIO(1,6)) -#define QUANTA_IX2_PSU_GPIO_FAN_RED_R (QUANTA_IX2_PSU_GPIO_BASE + QUANTA_IX2_PCA953x_GPIO(1,7)) - -#define QUANTA_IX2_ZQSFP_EN_GPIO_BASE (QUANTA_IX2_PSU_GPIO_BASE + QUANTA_IX2_PSU_GPIO_SIZE) -#define QUANTA_IX2_ZQSFP_EN_GPIO_SIZE QUANTA_IX2_PCA9555_GPIO_SIZE -#define QUANTA_IX2_ZQSFP_EN_GPIO_P3V3_PW_GD (QUANTA_IX2_ZQSFP_EN_GPIO_BASE + QUANTA_IX2_PCA953x_GPIO(0,4)) -#define QUANTA_IX2_ZQSFP_EN_GPIO_P3V3_PW_EN (QUANTA_IX2_ZQSFP_EN_GPIO_BASE + QUANTA_IX2_PCA953x_GPIO(0,5)) - -#define QUANTA_IX2_FAN_GPIO_BASE (QUANTA_IX2_ZQSFP_EN_GPIO_BASE + QUANTA_IX2_ZQSFP_EN_GPIO_SIZE) -#define QUANTA_IX2_FAN_GPIO_SIZE QUANTA_IX2_PCA9555_GPIO_SIZE -#define QUANTA_IX2_FAN_PRSNT_N_1 (QUANTA_IX2_FAN_GPIO_BASE + QUANTA_IX2_PCA953x_GPIO(0,4)) -#define QUANTA_IX2_FAN_PRSNT_N_2 (QUANTA_IX2_FAN_GPIO_BASE + QUANTA_IX2_PCA953x_GPIO(0,5)) -#define QUANTA_IX2_FAN_PRSNT_N_3 (QUANTA_IX2_FAN_GPIO_BASE + QUANTA_IX2_PCA953x_GPIO(0,6)) -#define QUANTA_IX2_FAN_PRSNT_N_4 (QUANTA_IX2_FAN_GPIO_BASE + QUANTA_IX2_PCA953x_GPIO(0,7)) -#define QUANTA_IX2_FAN_BF_DET1 (QUANTA_IX2_FAN_GPIO_BASE + QUANTA_IX2_PCA953x_GPIO(1,0)) -#define QUANTA_IX2_FAN_BF_DET2 (QUANTA_IX2_FAN_GPIO_BASE + QUANTA_IX2_PCA953x_GPIO(1,1)) -#define QUANTA_IX2_FAN_BF_DET3 (QUANTA_IX2_FAN_GPIO_BASE + QUANTA_IX2_PCA953x_GPIO(1,2)) -#define QUANTA_IX2_FAN_BF_DET4 (QUANTA_IX2_FAN_GPIO_BASE + QUANTA_IX2_PCA953x_GPIO(1,3)) -#define QUANTA_IX2_FAN_FAIL_LED_1 (QUANTA_IX2_FAN_GPIO_BASE + QUANTA_IX2_PCA953x_GPIO(1,4)) -#define QUANTA_IX2_FAN_FAIL_LED_2 (QUANTA_IX2_FAN_GPIO_BASE + QUANTA_IX2_PCA953x_GPIO(1,5)) -#define QUANTA_IX2_FAN_FAIL_LED_3 (QUANTA_IX2_FAN_GPIO_BASE + QUANTA_IX2_PCA953x_GPIO(1,6)) -#define QUANTA_IX2_FAN_FAIL_LED_4 (QUANTA_IX2_FAN_GPIO_BASE + QUANTA_IX2_PCA953x_GPIO(1,7)) - -#define QUANTA_IX2_PCA9698_1_GPIO_BASE 0x50 -#define QUANTA_IX2_PCA9698_1_GPIO_QSFP_49_RESET_P (QUANTA_IX2_PCA9698_1_GPIO_BASE + QUANTA_IX2_PCA953x_GPIO(0,0)) -#define QUANTA_IX2_PCA9698_1_GPIO_QSFP_49_PRSNT_N (QUANTA_IX2_PCA9698_1_GPIO_BASE + QUANTA_IX2_PCA953x_GPIO(0,2)) -#define QUANTA_IX2_PCA9698_1_GPIO_QSFP_49_LPMOD_P (QUANTA_IX2_PCA9698_1_GPIO_BASE + QUANTA_IX2_PCA953x_GPIO(0,3)) -#define QUANTA_IX2_PCA9698_1_GPIO_QSFP_50_RESET_P (QUANTA_IX2_PCA9698_1_GPIO_BASE + QUANTA_IX2_PCA953x_GPIO(0,4)) -#define QUANTA_IX2_PCA9698_1_GPIO_QSFP_50_PRSNT_N (QUANTA_IX2_PCA9698_1_GPIO_BASE + QUANTA_IX2_PCA953x_GPIO(0,6)) -#define QUANTA_IX2_PCA9698_1_GPIO_QSFP_50_LPMOD_P (QUANTA_IX2_PCA9698_1_GPIO_BASE + QUANTA_IX2_PCA953x_GPIO(0,7)) -#define QUANTA_IX2_PCA9698_1_GPIO_QSFP_51_RESET_P (QUANTA_IX2_PCA9698_1_GPIO_BASE + QUANTA_IX2_PCA953x_GPIO(1,0)) -#define QUANTA_IX2_PCA9698_1_GPIO_QSFP_51_PRSNT_N (QUANTA_IX2_PCA9698_1_GPIO_BASE + QUANTA_IX2_PCA953x_GPIO(1,2)) -#define QUANTA_IX2_PCA9698_1_GPIO_QSFP_51_LPMOD_P (QUANTA_IX2_PCA9698_1_GPIO_BASE + QUANTA_IX2_PCA953x_GPIO(1,3)) -#define QUANTA_IX2_PCA9698_1_GPIO_QSFP_52_RESET_P (QUANTA_IX2_PCA9698_1_GPIO_BASE + QUANTA_IX2_PCA953x_GPIO(1,4)) -#define QUANTA_IX2_PCA9698_1_GPIO_QSFP_52_PRSNT_N (QUANTA_IX2_PCA9698_1_GPIO_BASE + QUANTA_IX2_PCA953x_GPIO(1,6)) -#define QUANTA_IX2_PCA9698_1_GPIO_QSFP_52_LPMOD_P (QUANTA_IX2_PCA9698_1_GPIO_BASE + QUANTA_IX2_PCA953x_GPIO(1,7)) -#define QUANTA_IX2_PCA9698_1_GPIO_QSFP_53_RESET_P (QUANTA_IX2_PCA9698_1_GPIO_BASE + QUANTA_IX2_PCA953x_GPIO(2,0)) -#define QUANTA_IX2_PCA9698_1_GPIO_QSFP_53_PRSNT_N (QUANTA_IX2_PCA9698_1_GPIO_BASE + QUANTA_IX2_PCA953x_GPIO(2,2)) -#define QUANTA_IX2_PCA9698_1_GPIO_QSFP_53_LPMOD_P (QUANTA_IX2_PCA9698_1_GPIO_BASE + QUANTA_IX2_PCA953x_GPIO(2,3)) -#define QUANTA_IX2_PCA9698_1_GPIO_QSFP_54_RESET_P (QUANTA_IX2_PCA9698_1_GPIO_BASE + QUANTA_IX2_PCA953x_GPIO(2,4)) -#define QUANTA_IX2_PCA9698_1_GPIO_QSFP_54_PRSNT_N (QUANTA_IX2_PCA9698_1_GPIO_BASE + QUANTA_IX2_PCA953x_GPIO(2,6)) -#define QUANTA_IX2_PCA9698_1_GPIO_QSFP_54_LPMOD_P (QUANTA_IX2_PCA9698_1_GPIO_BASE + QUANTA_IX2_PCA953x_GPIO(2,7)) -#define QUANTA_IX2_PCA9698_1_GPIO_QSFP_55_RESET_P (QUANTA_IX2_PCA9698_1_GPIO_BASE + QUANTA_IX2_PCA953x_GPIO(3,0)) -#define QUANTA_IX2_PCA9698_1_GPIO_QSFP_55_PRSNT_N (QUANTA_IX2_PCA9698_1_GPIO_BASE + QUANTA_IX2_PCA953x_GPIO(3,2)) -#define QUANTA_IX2_PCA9698_1_GPIO_QSFP_55_LPMOD_P (QUANTA_IX2_PCA9698_1_GPIO_BASE + QUANTA_IX2_PCA953x_GPIO(3,3)) -#define QUANTA_IX2_PCA9698_1_GPIO_QSFP_56_RESET_P (QUANTA_IX2_PCA9698_1_GPIO_BASE + QUANTA_IX2_PCA953x_GPIO(3,4)) -#define QUANTA_IX2_PCA9698_1_GPIO_QSFP_56_PRSNT_N (QUANTA_IX2_PCA9698_1_GPIO_BASE + QUANTA_IX2_PCA953x_GPIO(3,6)) -#define QUANTA_IX2_PCA9698_1_GPIO_QSFP_56_LPMOD_P (QUANTA_IX2_PCA9698_1_GPIO_BASE + QUANTA_IX2_PCA953x_GPIO(3,7)) - -#endif /* __X86_64_QUANTA_IX2_RANGELEY_GPIO_TABLE_H__ */ diff --git a/packages/platforms/quanta/x86-64/ix2-rangeley/onlp/builds/x86_64_quanta_ix2_rangeley/module/inc/x86_64_quanta_ix2_rangeley/x86_64_quanta_ix2_rangeley_porting.h b/packages/platforms/quanta/x86-64/ix2-rangeley/onlp/builds/x86_64_quanta_ix2_rangeley/module/inc/x86_64_quanta_ix2_rangeley/x86_64_quanta_ix2_rangeley_porting.h deleted file mode 100755 index ac355777f..000000000 --- a/packages/platforms/quanta/x86-64/ix2-rangeley/onlp/builds/x86_64_quanta_ix2_rangeley/module/inc/x86_64_quanta_ix2_rangeley/x86_64_quanta_ix2_rangeley_porting.h +++ /dev/null @@ -1,77 +0,0 @@ -/**************************************************************************//** - * - * @file - * @brief x86_64_quanta_ix2_rangeley Porting Macros. - * - * @addtogroup x86_64_quanta_ix2_rangeley-porting - * @{ - * - *****************************************************************************/ -#ifndef __X86_64_QUANTA_IX2_RANGELEY_PORTING_H__ -#define __X86_64_QUANTA_IX2_RANGELEY_PORTING_H__ - - -/* */ -#if X86_64_QUANTA_IX2_RANGELEY_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS == 1 -#include -#include -#include -#include -#include -#endif - -#ifndef X86_64_QUANTA_IX2_RANGELEY_MEMSET - #if defined(GLOBAL_MEMSET) - #define X86_64_QUANTA_IX2_RANGELEY_MEMSET GLOBAL_MEMSET - #elif X86_64_QUANTA_IX2_RANGELEY_CONFIG_PORTING_STDLIB == 1 - #define X86_64_QUANTA_IX2_RANGELEY_MEMSET memset - #else - #error The macro X86_64_QUANTA_IX2_RANGELEY_MEMSET is required but cannot be defined. - #endif -#endif - -#ifndef X86_64_QUANTA_IX2_RANGELEY_MEMCPY - #if defined(GLOBAL_MEMCPY) - #define X86_64_QUANTA_IX2_RANGELEY_MEMCPY GLOBAL_MEMCPY - #elif X86_64_QUANTA_IX2_RANGELEY_CONFIG_PORTING_STDLIB == 1 - #define X86_64_QUANTA_IX2_RANGELEY_MEMCPY memcpy - #else - #error The macro X86_64_QUANTA_IX2_RANGELEY_MEMCPY is required but cannot be defined. - #endif -#endif - -#ifndef X86_64_QUANTA_IX2_RANGELEY_VSNPRINTF - #if defined(GLOBAL_VSNPRINTF) - #define X86_64_QUANTA_IX2_RANGELEY_VSNPRINTF GLOBAL_VSNPRINTF - #elif X86_64_QUANTA_IX2_RANGELEY_CONFIG_PORTING_STDLIB == 1 - #define X86_64_QUANTA_IX2_RANGELEY_VSNPRINTF vsnprintf - #else - #error The macro X86_64_QUANTA_IX2_RANGELEY_VSNPRINTF is required but cannot be defined. - #endif -#endif - -#ifndef X86_64_QUANTA_IX2_RANGELEY_SNPRINTF - #if defined(GLOBAL_SNPRINTF) - #define X86_64_QUANTA_IX2_RANGELEY_SNPRINTF GLOBAL_SNPRINTF - #elif X86_64_QUANTA_IX2_RANGELEY_CONFIG_PORTING_STDLIB == 1 - #define X86_64_QUANTA_IX2_RANGELEY_SNPRINTF snprintf - #else - #error The macro X86_64_QUANTA_IX2_RANGELEY_SNPRINTF is required but cannot be defined. - #endif -#endif - -#ifndef X86_64_QUANTA_IX2_RANGELEY_STRLEN - #if defined(GLOBAL_STRLEN) - #define X86_64_QUANTA_IX2_RANGELEY_STRLEN GLOBAL_STRLEN - #elif X86_64_QUANTA_IX2_RANGELEY_CONFIG_PORTING_STDLIB == 1 - #define X86_64_QUANTA_IX2_RANGELEY_STRLEN strlen - #else - #error The macro X86_64_QUANTA_IX2_RANGELEY_STRLEN is required but cannot be defined. - #endif -#endif - -/* */ - - -#endif /* __X86_64_QUANTA_IX2_RANGELEY_PORTING_H__ */ -/* @} */ diff --git a/packages/platforms/quanta/x86-64/ix2-rangeley/onlp/builds/x86_64_quanta_ix2_rangeley/module/make.mk b/packages/platforms/quanta/x86-64/ix2-rangeley/onlp/builds/x86_64_quanta_ix2_rangeley/module/make.mk deleted file mode 100755 index ad096ba5d..000000000 --- a/packages/platforms/quanta/x86-64/ix2-rangeley/onlp/builds/x86_64_quanta_ix2_rangeley/module/make.mk +++ /dev/null @@ -1,10 +0,0 @@ -############################################################################### -# -# -# -############################################################################### -THIS_DIR := $(dir $(lastword $(MAKEFILE_LIST))) -x86_64_quanta_ix2_rangeley_INCLUDES := -I $(THIS_DIR)inc -x86_64_quanta_ix2_rangeley_INTERNAL_INCLUDES := -I $(THIS_DIR)src -x86_64_quanta_ix2_rangeley_DEPENDMODULE_ENTRIES := init:x86_64_quanta_ix2_rangeley ucli:x86_64_quanta_ix2_rangeley - diff --git a/packages/platforms/quanta/x86-64/ix2-rangeley/onlp/builds/x86_64_quanta_ix2_rangeley/module/src/Makefile b/packages/platforms/quanta/x86-64/ix2-rangeley/onlp/builds/x86_64_quanta_ix2_rangeley/module/src/Makefile deleted file mode 100755 index aa08362c4..000000000 --- a/packages/platforms/quanta/x86-64/ix2-rangeley/onlp/builds/x86_64_quanta_ix2_rangeley/module/src/Makefile +++ /dev/null @@ -1,9 +0,0 @@ -############################################################################### -# -# Local source generation targets. -# -############################################################################### - -ucli: - @../../../../tools/uclihandlers.py x86_64_quanta_ix2_rangeley_ucli.c - diff --git a/packages/platforms/quanta/x86-64/ix2-rangeley/onlp/builds/x86_64_quanta_ix2_rangeley/module/src/fani.c b/packages/platforms/quanta/x86-64/ix2-rangeley/onlp/builds/x86_64_quanta_ix2_rangeley/module/src/fani.c deleted file mode 100755 index 184e7199a..000000000 --- a/packages/platforms/quanta/x86-64/ix2-rangeley/onlp/builds/x86_64_quanta_ix2_rangeley/module/src/fani.c +++ /dev/null @@ -1,172 +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 "x86_64_quanta_ix2_rangeley_int.h" -#include "x86_64_quanta_ix2_rangeley_log.h" - -#include -#include - -int -onlp_fani_init(void) -{ - return ONLP_STATUS_OK; -} - -struct fan_gpio_s { - int present; - int fan_dir_detect; -}; - -static struct fan_gpio_s fan_gpio[] = { - {}, /* Not used */ - { .present = QUANTA_IX2_FAN_PRSNT_N_1, .fan_dir_detect = QUANTA_IX2_FAN_BF_DET1 }, - { .present = QUANTA_IX2_FAN_PRSNT_N_2, .fan_dir_detect = QUANTA_IX2_FAN_BF_DET2 }, - { .present = QUANTA_IX2_FAN_PRSNT_N_3, .fan_dir_detect = QUANTA_IX2_FAN_BF_DET3 }, - { .present = QUANTA_IX2_FAN_PRSNT_N_4, .fan_dir_detect = QUANTA_IX2_FAN_BF_DET4 }, - //{}, /* Not used */ - { .present = QUANTA_IX2_FAN_PRSNT_N_1, .fan_dir_detect = QUANTA_IX2_FAN_BF_DET1 }, - { .present = QUANTA_IX2_FAN_PRSNT_N_2, .fan_dir_detect = QUANTA_IX2_FAN_BF_DET2 }, - { .present = QUANTA_IX2_FAN_PRSNT_N_3, .fan_dir_detect = QUANTA_IX2_FAN_BF_DET3 }, - { .present = QUANTA_IX2_FAN_PRSNT_N_4, .fan_dir_detect = QUANTA_IX2_FAN_BF_DET4 }, - //{}, /* Not used */ -}; - -static int -sys_fan_info_get__(onlp_fan_info_t* info, int id) -{ - int value = 0; - int rv; - - if(onlp_gpio_get(fan_gpio[id].present, &value) == ONLP_STATUS_OK - && value == 0) { - info->status = ONLP_FAN_STATUS_PRESENT; - if(onlp_gpio_get(fan_gpio[id].fan_dir_detect, &value) == ONLP_STATUS_OK - && value == 0) { - info->status |= ONLP_FAN_STATUS_F2B; - info->caps |= ONLP_FAN_CAPS_F2B; - } - else { - info->status |= ONLP_FAN_STATUS_B2F; - info->caps |= ONLP_FAN_CAPS_B2F; - } - } - else { - info->status = ONLP_FAN_STATUS_FAILED; - } - - rv = onlp_file_read_int(&info->rpm, - SYS_HWMON_PREFIX "/fan%d_input", id); - - if(rv == ONLP_STATUS_E_INTERNAL) { - return rv; - } - - if(rv == ONLP_STATUS_E_MISSING) { - info->status &= ~1; - return 0; - } - - if(info->rpm <= X86_64_QUANTA_IX2_RANGELEY_CONFIG_SYSFAN_RPM_FAILURE_THRESHOLD) { - info->status |= ONLP_FAN_STATUS_FAILED; - } - - /* - * Calculate percentage based on current speed and the maximum. - */ - info->caps |= ONLP_FAN_CAPS_GET_PERCENTAGE; - if(info->status & ONLP_FAN_STATUS_F2B) { - info->percentage = (int) ((double) info->rpm * (double)100 / (double)X86_64_QUANTA_IX2_RANGELEY_CONFIG_SYSFAN_F2B_RPM_MAX); - } - if(info->status & ONLP_FAN_STATUS_B2F) { - info->percentage = (int) ((double) info->rpm * (double)100 / (double)X86_64_QUANTA_IX2_RANGELEY_CONFIG_SYSFAN_B2F_RPM_MAX); - } - - return 0; -} - -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, "Left (Module/Fan 1/1)", 0}, ONLP_FAN_STATUS_PRESENT }, - { { FAN_OID_FAN2, "Center-L(Module/Fan 2/1)", 0}, ONLP_FAN_STATUS_PRESENT }, - { { FAN_OID_FAN3, "Center-R(Module/Fan 3/1)", 0}, ONLP_FAN_STATUS_PRESENT }, - { { FAN_OID_FAN4, "Right (Module/Fan 4/1)", 0}, ONLP_FAN_STATUS_PRESENT }, - { { FAN_OID_FAN5, "Left (Module/Fan 1/2)", 0}, ONLP_FAN_STATUS_PRESENT }, - { { FAN_OID_FAN6, "Center-L(Module/Fan 2/2)", 0}, ONLP_FAN_STATUS_PRESENT }, - { { FAN_OID_FAN7, "Center-R(Module/Fan 3/2)", 0}, ONLP_FAN_STATUS_PRESENT }, - { { FAN_OID_FAN8, "Right (Module/Fan 4/2)", 0}, ONLP_FAN_STATUS_PRESENT }, - { { FAN_OID_FAN9, "PSU-1 Fan", 0 }, ONLP_FAN_STATUS_PRESENT }, - { { FAN_OID_FAN10, "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: - case FAN_ID_FAN3: - case FAN_ID_FAN4: - case FAN_ID_FAN5: - case FAN_ID_FAN6: - case FAN_ID_FAN7: - case FAN_ID_FAN8: - return sys_fan_info_get__(rv, fid); - break; - - case FAN_ID_FAN9: - case FAN_ID_FAN10: - return psu_fan_info_get__(rv, fid - FAN_ID_FAN9 + 1); - break; - - default: - return ONLP_STATUS_E_INVALID; - break; - } - - return ONLP_STATUS_E_INVALID; -} - - diff --git a/packages/platforms/quanta/x86-64/ix2-rangeley/onlp/builds/x86_64_quanta_ix2_rangeley/module/src/ledi.c b/packages/platforms/quanta/x86-64/ix2-rangeley/onlp/builds/x86_64_quanta_ix2_rangeley/module/src/ledi.c deleted file mode 100755 index 2b616aad1..000000000 --- a/packages/platforms/quanta/x86-64/ix2-rangeley/onlp/builds/x86_64_quanta_ix2_rangeley/module/src/ledi.c +++ /dev/null @@ -1,229 +0,0 @@ -#include -#include -#include -#include -#include - -#include "x86_64_quanta_ix2_rangeley_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_IX2_CPU_BOARD_SYS_P1, 0); - onlp_gpio_set(QUANTA_IX2_CPU_BOARD_SYS_P2, 1); - } - else if(mode == ONLP_LED_MODE_ORANGE){ - onlp_gpio_set(QUANTA_IX2_CPU_BOARD_SYS_P1, 1); - onlp_gpio_set(QUANTA_IX2_CPU_BOARD_SYS_P2, 0); - } - else{ - onlp_gpio_set(QUANTA_IX2_CPU_BOARD_SYS_P1, 1); - onlp_gpio_set(QUANTA_IX2_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_IX2_PSU_GPIO_FAN_GREEN_R, 1); - onlp_gpio_set(QUANTA_IX2_PSU_GPIO_FAN_RED_R, 0); - } - else if(mode == ONLP_LED_MODE_RED){ - onlp_gpio_set(QUANTA_IX2_PSU_GPIO_FAN_GREEN_R, 0); - onlp_gpio_set(QUANTA_IX2_PSU_GPIO_FAN_RED_R, 1); - } - else{ - onlp_gpio_set(QUANTA_IX2_PSU_GPIO_FAN_GREEN_R, 0); - onlp_gpio_set(QUANTA_IX2_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_IX2_PSU_GPIO_PSU1_GREEN_R, 1); - onlp_gpio_set(QUANTA_IX2_PSU_GPIO_PSU1_RED_R, 0); - } - else if(mode == ONLP_LED_MODE_RED){ - onlp_gpio_set(QUANTA_IX2_PSU_GPIO_PSU1_GREEN_R, 0); - onlp_gpio_set(QUANTA_IX2_PSU_GPIO_PSU1_RED_R, 1); - } - else{ - onlp_gpio_set(QUANTA_IX2_PSU_GPIO_PSU1_GREEN_R, 0); - onlp_gpio_set(QUANTA_IX2_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_IX2_PSU_GPIO_PSU2_GREEN_R, 1); - onlp_gpio_set(QUANTA_IX2_PSU_GPIO_PSU2_RED_R, 0); - } - else if(mode == ONLP_LED_MODE_RED){ - onlp_gpio_set(QUANTA_IX2_PSU_GPIO_PSU2_GREEN_R, 0); - onlp_gpio_set(QUANTA_IX2_PSU_GPIO_PSU2_RED_R, 1); - } - else{ - onlp_gpio_set(QUANTA_IX2_PSU_GPIO_PSU2_GREEN_R, 0); - onlp_gpio_set(QUANTA_IX2_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_IX2_FAN_FAIL_LED_1, 1); - } - else{ - onlp_gpio_set(QUANTA_IX2_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_IX2_FAN_FAIL_LED_2, 1); - } - else{ - onlp_gpio_set(QUANTA_IX2_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_IX2_FAN_FAIL_LED_3, 1); - } - else{ - onlp_gpio_set(QUANTA_IX2_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_IX2_FAN_FAIL_LED_4, 1); - } - else{ - onlp_gpio_set(QUANTA_IX2_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/ix2-rangeley/onlp/builds/x86_64_quanta_ix2_rangeley/module/src/make.mk b/packages/platforms/quanta/x86-64/ix2-rangeley/onlp/builds/x86_64_quanta_ix2_rangeley/module/src/make.mk deleted file mode 100755 index df3c695d4..000000000 --- a/packages/platforms/quanta/x86-64/ix2-rangeley/onlp/builds/x86_64_quanta_ix2_rangeley/module/src/make.mk +++ /dev/null @@ -1,9 +0,0 @@ -############################################################################### -# -# -# -############################################################################### - -LIBRARY := x86_64_quanta_ix2_rangeley -$(LIBRARY)_SUBDIR := $(dir $(lastword $(MAKEFILE_LIST))) -include $(BUILDER)/lib.mk diff --git a/packages/platforms/quanta/x86-64/ix2-rangeley/onlp/builds/x86_64_quanta_ix2_rangeley/module/src/psui.c b/packages/platforms/quanta/x86-64/ix2-rangeley/onlp/builds/x86_64_quanta_ix2_rangeley/module/src/psui.c deleted file mode 100755 index eab997894..000000000 --- a/packages/platforms/quanta/x86-64/ix2-rangeley/onlp/builds/x86_64_quanta_ix2_rangeley/module/src/psui.c +++ /dev/null @@ -1,118 +0,0 @@ -/************************************************************ - * - * - ************************************************************ - * - * - * - ***********************************************************/ -#include -#include -#include -#include -#include -#include "x86_64_quanta_ix2_rangeley_int.h" -#include "x86_64_quanta_ix2_rangeley_log.h" - -struct psu_info_s psu_info[] = { - {}, /* Not used */ - { .path = "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-20/20-005f", .present = QUANTA_IX2_PSU_GPIO_PSU1_PRSNT_N, .busno = 20, .addr = 0x5f}, - { .path = "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-21/21-0059", .present = QUANTA_IX2_PSU_GPIO_PSU2_PRSNT_N, .busno = 21, .addr = 0x59}, -}; - -int -onlp_psui_init(void) -{ - return 0; -} - -static onlp_psu_info_t psus__[] = { - { }, /* Not used */ - { - { - PSU_OID_PSU1, - "Quanta IX2 RPSU-1", - 0, - { - FAN_OID_FAN9, - }, - } - }, - { - { - PSU_OID_PSU2, - "Quanta IX2 RPSU-2", - 0, - { - FAN_OID_FAN10, - }, - } - }, -}; - -#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/ix2-rangeley/onlp/builds/x86_64_quanta_ix2_rangeley/module/src/sfpi.c b/packages/platforms/quanta/x86-64/ix2-rangeley/onlp/builds/x86_64_quanta_ix2_rangeley/module/src/sfpi.c deleted file mode 100755 index 0d9d3e4a0..000000000 --- a/packages/platforms/quanta/x86-64/ix2-rangeley/onlp/builds/x86_64_quanta_ix2_rangeley/module/src/sfpi.c +++ /dev/null @@ -1,407 +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. - * - * - ************************************************************ - * - * SFPI Interface for the Quanta IX2 - * - ***********************************************************/ -#include -#include -#include -#include -#include -#include "x86_64_quanta_ix2_rangeley_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-16/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-16/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-16/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-16/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-16/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-16/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-16/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-16/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-16/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-16/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-16/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-16/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-16/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-16/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-16/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-16/i2c-47/47-0050/eeprom", NULL }, - { 17, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/16-0039/cpld-sfp28/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-sfp28/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-sfp28/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-sfp28/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-sfp28/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-sfp28/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-sfp28/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-sfp28/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-sfp28/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-sfp28/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-sfp28/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-sfp28/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-sfp28/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-sfp28/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-sfp28/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-sfp28/port-32/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/i2c-63/63-0050/eeprom", NULL }, - { 33, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/17-0038/cpld-sfp28/port-33/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/i2c-64/64-0050/eeprom", NULL }, - { 34, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/17-0038/cpld-sfp28/port-34/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/i2c-65/65-0050/eeprom", NULL }, - { 35, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/17-0038/cpld-sfp28/port-35/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/i2c-66/66-0050/eeprom", NULL }, - { 36, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/17-0038/cpld-sfp28/port-36/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/i2c-67/67-0050/eeprom", NULL }, - { 37, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/17-0038/cpld-sfp28/port-37/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/i2c-68/68-0050/eeprom", NULL }, - { 38, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/17-0038/cpld-sfp28/port-38/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/i2c-69/69-0050/eeprom", NULL }, - { 39, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/17-0038/cpld-sfp28/port-39/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/i2c-70/70-0050/eeprom", NULL }, - { 40, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/17-0038/cpld-sfp28/port-40/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/i2c-71/71-0050/eeprom", NULL }, - { 41, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/17-0038/cpld-sfp28/port-41/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/i2c-72/72-0050/eeprom", NULL }, - { 42, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/17-0038/cpld-sfp28/port-42/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/i2c-73/73-0050/eeprom", NULL }, - { 43, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/17-0038/cpld-sfp28/port-43/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/i2c-74/74-0050/eeprom", NULL }, - { 44, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/17-0038/cpld-sfp28/port-44/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/i2c-75/75-0050/eeprom", NULL }, - { 45, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/17-0038/cpld-sfp28/port-45/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/i2c-76/76-0050/eeprom", NULL }, - { 46, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/17-0038/cpld-sfp28/port-46/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/i2c-77/77-0050/eeprom", NULL }, - { 47, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/17-0038/cpld-sfp28/port-47/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/i2c-78/78-0050/eeprom", NULL }, - { 48, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/17-0038/cpld-sfp28/port-48/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/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_IX2_PCA9698_1_GPIO_QSFP_49_PRSNT_N, QUANTA_IX2_PCA9698_1_GPIO_QSFP_49_RESET_P, QUANTA_IX2_PCA9698_1_GPIO_QSFP_49_LPMOD_P, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-18/i2c-80/80-0050/eeprom", NULL }, - { 50, QUANTA_IX2_PCA9698_1_GPIO_QSFP_50_PRSNT_N, QUANTA_IX2_PCA9698_1_GPIO_QSFP_50_RESET_P, QUANTA_IX2_PCA9698_1_GPIO_QSFP_50_LPMOD_P, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-18/i2c-81/81-0050/eeprom", NULL }, - { 51, QUANTA_IX2_PCA9698_1_GPIO_QSFP_51_PRSNT_N, QUANTA_IX2_PCA9698_1_GPIO_QSFP_51_RESET_P, QUANTA_IX2_PCA9698_1_GPIO_QSFP_51_LPMOD_P, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-18/i2c-82/82-0050/eeprom", NULL }, - { 52, QUANTA_IX2_PCA9698_1_GPIO_QSFP_52_PRSNT_N, QUANTA_IX2_PCA9698_1_GPIO_QSFP_52_RESET_P, QUANTA_IX2_PCA9698_1_GPIO_QSFP_52_LPMOD_P, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-18/i2c-83/83-0050/eeprom", NULL }, - { 53, QUANTA_IX2_PCA9698_1_GPIO_QSFP_53_PRSNT_N, QUANTA_IX2_PCA9698_1_GPIO_QSFP_53_RESET_P, QUANTA_IX2_PCA9698_1_GPIO_QSFP_53_LPMOD_P, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-18/i2c-84/84-0050/eeprom", NULL }, - { 54, QUANTA_IX2_PCA9698_1_GPIO_QSFP_54_PRSNT_N, QUANTA_IX2_PCA9698_1_GPIO_QSFP_54_RESET_P, QUANTA_IX2_PCA9698_1_GPIO_QSFP_54_LPMOD_P, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-18/i2c-85/85-0050/eeprom", NULL }, - { 55, QUANTA_IX2_PCA9698_1_GPIO_QSFP_55_PRSNT_N, QUANTA_IX2_PCA9698_1_GPIO_QSFP_55_RESET_P, QUANTA_IX2_PCA9698_1_GPIO_QSFP_55_LPMOD_P, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-18/i2c-86/86-0050/eeprom", NULL }, - { 56, QUANTA_IX2_PCA9698_1_GPIO_QSFP_56_PRSNT_N, QUANTA_IX2_PCA9698_1_GPIO_QSFP_56_RESET_P, QUANTA_IX2_PCA9698_1_GPIO_QSFP_56_LPMOD_P, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-18/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_IX2_ZQSFP_EN_GPIO_P3V3_PW_EN, ONLP_GPIO_DIRECTION_OUT); - ret = onlp_gpio_set(QUANTA_IX2_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, 0); - 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){ - 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_disabled 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/ix2-rangeley/onlp/builds/x86_64_quanta_ix2_rangeley/module/src/sysi.c b/packages/platforms/quanta/x86-64/ix2-rangeley/onlp/builds/x86_64_quanta_ix2_rangeley/module/src/sysi.c deleted file mode 100755 index 36195e35b..000000000 --- a/packages/platforms/quanta/x86-64/ix2-rangeley/onlp/builds/x86_64_quanta_ix2_rangeley/module/src/sysi.c +++ /dev/null @@ -1,293 +0,0 @@ -/************************************************************ - * - * - ************************************************************ - * - * - * - ***********************************************************/ -#include -#include "x86_64_quanta_ix2_rangeley_int.h" -#include "x86_64_quanta_ix2_rangeley_log.h" -#include -#include -#include -#include -#include - -struct led_control_s led_control; - -#define QUANTA_HWMON_REG_TEMP_ALERT_MASK 0x1E -#define QUANTA_HWMON_REG_TEMP_ALERT_CTRL 0x1D -#define QUANTA_HWMON_REG_FAN_ALERT_MASK 0x31 -#define QUANTA_HWMON_REG_FAN_ALERT_CTRL 0x30 -#define PSOC_REG_FAN_ALERT_STATUS 0x32 - -#define QUANTA_FAN_1_1 0x01 -#define QUANTA_FAN_1_2 0x10 -#define QUANTA_FAN_2_1 0x02 -#define QUANTA_FAN_2_2 0x20 -#define QUANTA_FAN_3_1 0x04 -#define QUANTA_FAN_3_2 0x40 -#define QUANTA_FAN_4_1 0x08 -#define QUANTA_FAN_4_2 0x80 - -const char* -onlp_sysi_platform_get(void) -{ - return "x86-64-quanta-ix2-rangeley-r0"; -} - -int -onlp_sysi_init(void) -{ - /* Initial value */ - led_control.PMCnt = 0; - led_control.fan_alert = 0xff; - led_control.psu1_present = 0; - led_control.psu2_present = 0; - led_control.psu1_power_good = 0; - led_control.psu2_power_good = 0; - - /* Set PSoc Fan-Alert Enable */ - onlp_i2c_writeb(0, 0x4e, QUANTA_HWMON_REG_TEMP_ALERT_MASK, 0x77, ONLP_I2C_F_FORCE); - onlp_i2c_writeb(0, 0x4e, QUANTA_HWMON_REG_TEMP_ALERT_CTRL, 0x3, ONLP_I2C_F_FORCE); - onlp_i2c_writeb(0, 0x4e, QUANTA_HWMON_REG_FAN_ALERT_MASK, 0xff, ONLP_I2C_F_FORCE); - onlp_i2c_writeb(0, 0x4e, QUANTA_HWMON_REG_FAN_ALERT_CTRL, 0x1, ONLP_I2C_F_FORCE); - - /* Config GPIO */ - /* LED Output */ - onlp_gpio_export(QUANTA_IX2_CPU_BOARD_SYS_P1, ONLP_GPIO_DIRECTION_OUT); - onlp_gpio_export(QUANTA_IX2_CPU_BOARD_SYS_P2, ONLP_GPIO_DIRECTION_OUT); - onlp_gpio_export(QUANTA_IX2_PSU_GPIO_PSU1_GREEN_R, ONLP_GPIO_DIRECTION_OUT); - onlp_gpio_export(QUANTA_IX2_PSU_GPIO_PSU1_RED_R, ONLP_GPIO_DIRECTION_OUT); - onlp_gpio_export(QUANTA_IX2_PSU_GPIO_PSU2_GREEN_R, ONLP_GPIO_DIRECTION_OUT); - onlp_gpio_export(QUANTA_IX2_PSU_GPIO_PSU2_RED_R, ONLP_GPIO_DIRECTION_OUT); - onlp_gpio_export(QUANTA_IX2_FAN_FAIL_LED_1, ONLP_GPIO_DIRECTION_OUT); - onlp_gpio_export(QUANTA_IX2_FAN_FAIL_LED_2, ONLP_GPIO_DIRECTION_OUT); - onlp_gpio_export(QUANTA_IX2_FAN_FAIL_LED_3, ONLP_GPIO_DIRECTION_OUT); - onlp_gpio_export(QUANTA_IX2_FAN_FAIL_LED_4, ONLP_GPIO_DIRECTION_OUT); - onlp_gpio_export(QUANTA_IX2_PSU_GPIO_FAN_GREEN_R, ONLP_GPIO_DIRECTION_OUT); - onlp_gpio_export(QUANTA_IX2_PSU_GPIO_FAN_RED_R, ONLP_GPIO_DIRECTION_OUT); - /* PSU Input */ - onlp_gpio_export(QUANTA_IX2_PSU_GPIO_PSU1_PRSNT_N, ONLP_GPIO_DIRECTION_IN); - onlp_gpio_export(QUANTA_IX2_PSU_GPIO_PSU1_PWRGD, ONLP_GPIO_DIRECTION_IN); - onlp_gpio_export(QUANTA_IX2_PSU_GPIO_PSU2_PRSNT_N, ONLP_GPIO_DIRECTION_IN); - onlp_gpio_export(QUANTA_IX2_PSU_GPIO_PSU2_PWRGD, ONLP_GPIO_DIRECTION_IN); - /* FAN Input */ - onlp_gpio_export(QUANTA_IX2_FAN_PRSNT_N_1, ONLP_GPIO_DIRECTION_IN); - 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); - 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-22/22-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-ix2-rangeley-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)); - - /* - * 6 Chassis Thermal Sensors - */ - *e++ = THERMAL_OID_THERMAL1; - *e++ = THERMAL_OID_THERMAL2; - *e++ = THERMAL_OID_THERMAL3; - *e++ = THERMAL_OID_THERMAL5; - *e++ = THERMAL_OID_THERMAL6; - *e++ = THERMAL_OID_THERMAL7; - - /* - * 8 Fans - */ - *e++ = FAN_OID_FAN1; - *e++ = FAN_OID_FAN2; - *e++ = FAN_OID_FAN3; - *e++ = FAN_OID_FAN4; - *e++ = FAN_OID_FAN5; - *e++ = FAN_OID_FAN6; - *e++ = FAN_OID_FAN7; - *e++ = FAN_OID_FAN8; - - /* - * 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_IX2_PSU_GPIO_PSU1_PRSNT_N, &value); - if(rv < 0) { - AIM_LOG_ERROR("GPIO %d read Error!", QUANTA_IX2_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_IX2_PSU_GPIO_PSU1_PWRGD, &value); - if(rv < 0) { - AIM_LOG_ERROR("GPIO %d read Error!", QUANTA_IX2_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_IX2_PSU_GPIO_PSU2_PRSNT_N, &value); - if(rv < 0) { - AIM_LOG_ERROR("GPIO %d read Error!", QUANTA_IX2_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_IX2_PSU_GPIO_PSU2_PWRGD, &value); - if(rv < 0) { - AIM_LOG_ERROR("GPIO %d read Error!", QUANTA_IX2_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; - - tmp = led_control.fan_alert; - led_control.fan_alert = onlp_i2c_readb(0, 0x4e, PSOC_REG_FAN_ALERT_STATUS, ONLP_I2C_F_FORCE); - if(tmp != led_control.fan_alert) - 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.fan_alert & QUANTA_FAN_1_1) && !(led_control.fan_alert & QUANTA_FAN_1_2)) { - onlp_ledi_mode_set(LED_ID_FAN_FAIL_1, ONLP_LED_MODE_OFF); - } - else{ - onlp_ledi_mode_set(LED_ID_FAN_FAIL_1, ONLP_LED_MODE_RED); - } - - if(!(led_control.fan_alert & QUANTA_FAN_2_1) && !(led_control.fan_alert & QUANTA_FAN_2_2)) { - onlp_ledi_mode_set(LED_ID_FAN_FAIL_2, ONLP_LED_MODE_OFF); - } - else{ - onlp_ledi_mode_set(LED_ID_FAN_FAIL_2, ONLP_LED_MODE_RED); - } - - if(!(led_control.fan_alert & QUANTA_FAN_3_1) && !(led_control.fan_alert & QUANTA_FAN_3_2)) { - onlp_ledi_mode_set(LED_ID_FAN_FAIL_3, ONLP_LED_MODE_OFF); - } - else{ - onlp_ledi_mode_set(LED_ID_FAN_FAIL_3, ONLP_LED_MODE_RED); - } - - if(!(led_control.fan_alert & QUANTA_FAN_4_1) && !(led_control.fan_alert & QUANTA_FAN_4_2)) { - onlp_ledi_mode_set(LED_ID_FAN_FAIL_4, ONLP_LED_MODE_OFF); - } - else{ - onlp_ledi_mode_set(LED_ID_FAN_FAIL_4, ONLP_LED_MODE_RED); - } - - if(!led_control.fan_alert){ - 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/ix2-rangeley/onlp/builds/x86_64_quanta_ix2_rangeley/module/src/thermali.c b/packages/platforms/quanta/x86-64/ix2-rangeley/onlp/builds/x86_64_quanta_ix2_rangeley/module/src/thermali.c deleted file mode 100755 index f130b9604..000000000 --- a/packages/platforms/quanta/x86-64/ix2-rangeley/onlp/builds/x86_64_quanta_ix2_rangeley/module/src/thermali.c +++ /dev/null @@ -1,146 +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 "x86_64_quanta_ix2_rangeley_int.h" -#include "x86_64_quanta_ix2_rangeley_log.h" - -int -onlp_thermali_init(void) -{ - return ONLP_STATUS_OK; -} - -static int -sys_thermal_info_get__(onlp_thermal_info_t* info, int id) -{ - int rv; - - rv = onlp_file_read_int(&info->mcelsius, - SYS_HWMON_PREFIX "/temp%d_input", id); - - if(rv == ONLP_STATUS_E_INTERNAL) { - return rv; - } - - if(rv == ONLP_STATUS_E_MISSING) { - info->status &= ~1; - return 0; - } - - return ONLP_STATUS_OK; -} - -static int -psu_thermal_info_get__(onlp_thermal_info_t* info, int pid, int id) -{ - /* THERMAL6 -> PSU1 */ - /* THERMAL7 -> PSU2 */ - extern struct psu_info_s psu_info[]; - char* dir = psu_info[pid].path; - - info->status |= 1; - return onlp_file_read_int(&info->mcelsius, "%s/temp%d_input", dir, id); -} - -int -onlp_thermali_info_get(onlp_oid_t id, onlp_thermal_info_t* rv) -{ - int tid = ONLP_OID_ID_GET(id); - - static onlp_thermal_info_t info[] = { - { }, /* Not used */ - { { ONLP_THERMAL_ID_CREATE(1), "Chassis Thermal 1", 0}, ONLP_THERMAL_STATUS_PRESENT, - ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS - }, - { { ONLP_THERMAL_ID_CREATE(2), "Chassis Thermal 2", 0}, ONLP_THERMAL_STATUS_PRESENT, - ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS - }, - { { ONLP_THERMAL_ID_CREATE(3), "Chassis Thermal 3", 0}, ONLP_THERMAL_STATUS_PRESENT, - ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS - }, - { { ONLP_THERMAL_ID_CREATE(4), "Chassis Thermal 4", 0}, ONLP_THERMAL_STATUS_PRESENT, - ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS - }, - { { ONLP_THERMAL_ID_CREATE(5), "Chassis Thermal 5", 0}, ONLP_THERMAL_STATUS_PRESENT, - ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS - }, - { { ONLP_THERMAL_ID_CREATE(6), "Chassis Thermal 6", 0}, ONLP_THERMAL_STATUS_PRESENT, - ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS - }, - { { ONLP_THERMAL_ID_CREATE(7), "Chassis Thermal 7", 0}, ONLP_THERMAL_STATUS_PRESENT, - ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS - }, - { { ONLP_THERMAL_ID_CREATE(8), "Chassis Thermal 8", 0}, ONLP_THERMAL_STATUS_PRESENT, - ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS - }, - { { ONLP_THERMAL_ID_CREATE(9), "Chassis Thermal 9", 0}, ONLP_THERMAL_STATUS_PRESENT, - ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS - }, - { { ONLP_THERMAL_ID_CREATE(10), "Chassis Thermal 10", 0}, ONLP_THERMAL_STATUS_PRESENT, - ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS - }, - - { { ONLP_THERMAL_ID_CREATE(11), "PSU-1 Thermal 1", 0 } }, - { { ONLP_THERMAL_ID_CREATE(12), "PSU-1 Thermal 2", 0 } }, - { { ONLP_THERMAL_ID_CREATE(13), "PSU-1 Thermal 3", 0 } }, - - { { ONLP_THERMAL_ID_CREATE(14), "PSU-2 Thermal 1", 0 } }, - { { ONLP_THERMAL_ID_CREATE(15), "PSU-2 Thermal 2", 0 } }, - { { ONLP_THERMAL_ID_CREATE(16), "PSU-2 Thermal 3", 0 } }, - }; - - *rv = info[tid]; - rv->caps |= ONLP_THERMAL_CAPS_GET_TEMPERATURE; - - switch(tid) - { - case THERMAL_ID_THERMAL1: - case THERMAL_ID_THERMAL2: - case THERMAL_ID_THERMAL3: - case THERMAL_ID_THERMAL4: - case THERMAL_ID_THERMAL5: - case THERMAL_ID_THERMAL6: - case THERMAL_ID_THERMAL7: - case THERMAL_ID_THERMAL8: - case THERMAL_ID_THERMAL9: - case THERMAL_ID_THERMAL10: - return sys_thermal_info_get__(rv, tid); - - case THERMAL_ID_THERMAL11: - case THERMAL_ID_THERMAL12: - case THERMAL_ID_THERMAL13: - return psu_thermal_info_get__(rv, 1, tid - THERMAL_ID_THERMAL11 + 1); - - - case THERMAL_ID_THERMAL14: - case THERMAL_ID_THERMAL15: - case THERMAL_ID_THERMAL16: - return psu_thermal_info_get__(rv, 2, tid - THERMAL_ID_THERMAL14 + 1); - - } - - return ONLP_STATUS_E_INVALID; -} diff --git a/packages/platforms/quanta/x86-64/ix2-rangeley/onlp/builds/x86_64_quanta_ix2_rangeley/module/src/x86_64_quanta_ix2_rangeley_config.c b/packages/platforms/quanta/x86-64/ix2-rangeley/onlp/builds/x86_64_quanta_ix2_rangeley/module/src/x86_64_quanta_ix2_rangeley_config.c deleted file mode 100755 index 1f9426b03..000000000 --- a/packages/platforms/quanta/x86-64/ix2-rangeley/onlp/builds/x86_64_quanta_ix2_rangeley/module/src/x86_64_quanta_ix2_rangeley_config.c +++ /dev/null @@ -1,95 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#include - -/* */ -#define __x86_64_quanta_ix2_rangeley_config_STRINGIFY_NAME(_x) #_x -#define __x86_64_quanta_ix2_rangeley_config_STRINGIFY_VALUE(_x) __x86_64_quanta_ix2_rangeley_config_STRINGIFY_NAME(_x) -x86_64_quanta_ix2_rangeley_config_settings_t x86_64_quanta_ix2_rangeley_config_settings[] = -{ -#ifdef X86_64_QUANTA_IX2_RANGELEY_CONFIG_INCLUDE_LOGGING - { __x86_64_quanta_ix2_rangeley_config_STRINGIFY_NAME(X86_64_QUANTA_IX2_RANGELEY_CONFIG_INCLUDE_LOGGING), __x86_64_quanta_ix2_rangeley_config_STRINGIFY_VALUE(X86_64_QUANTA_IX2_RANGELEY_CONFIG_INCLUDE_LOGGING) }, -#else -{ X86_64_QUANTA_IX2_RANGELEY_CONFIG_INCLUDE_LOGGING(__x86_64_quanta_ix2_rangeley_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_QUANTA_IX2_RANGELEY_CONFIG_LOG_OPTIONS_DEFAULT - { __x86_64_quanta_ix2_rangeley_config_STRINGIFY_NAME(X86_64_QUANTA_IX2_RANGELEY_CONFIG_LOG_OPTIONS_DEFAULT), __x86_64_quanta_ix2_rangeley_config_STRINGIFY_VALUE(X86_64_QUANTA_IX2_RANGELEY_CONFIG_LOG_OPTIONS_DEFAULT) }, -#else -{ X86_64_QUANTA_IX2_RANGELEY_CONFIG_LOG_OPTIONS_DEFAULT(__x86_64_quanta_ix2_rangeley_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_QUANTA_IX2_RANGELEY_CONFIG_LOG_BITS_DEFAULT - { __x86_64_quanta_ix2_rangeley_config_STRINGIFY_NAME(X86_64_QUANTA_IX2_RANGELEY_CONFIG_LOG_BITS_DEFAULT), __x86_64_quanta_ix2_rangeley_config_STRINGIFY_VALUE(X86_64_QUANTA_IX2_RANGELEY_CONFIG_LOG_BITS_DEFAULT) }, -#else -{ X86_64_QUANTA_IX2_RANGELEY_CONFIG_LOG_BITS_DEFAULT(__x86_64_quanta_ix2_rangeley_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_QUANTA_IX2_RANGELEY_CONFIG_LOG_CUSTOM_BITS_DEFAULT - { __x86_64_quanta_ix2_rangeley_config_STRINGIFY_NAME(X86_64_QUANTA_IX2_RANGELEY_CONFIG_LOG_CUSTOM_BITS_DEFAULT), __x86_64_quanta_ix2_rangeley_config_STRINGIFY_VALUE(X86_64_QUANTA_IX2_RANGELEY_CONFIG_LOG_CUSTOM_BITS_DEFAULT) }, -#else -{ X86_64_QUANTA_IX2_RANGELEY_CONFIG_LOG_CUSTOM_BITS_DEFAULT(__x86_64_quanta_ix2_rangeley_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_QUANTA_IX2_RANGELEY_CONFIG_PORTING_STDLIB - { __x86_64_quanta_ix2_rangeley_config_STRINGIFY_NAME(X86_64_QUANTA_IX2_RANGELEY_CONFIG_PORTING_STDLIB), __x86_64_quanta_ix2_rangeley_config_STRINGIFY_VALUE(X86_64_QUANTA_IX2_RANGELEY_CONFIG_PORTING_STDLIB) }, -#else -{ X86_64_QUANTA_IX2_RANGELEY_CONFIG_PORTING_STDLIB(__x86_64_quanta_ix2_rangeley_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_QUANTA_IX2_RANGELEY_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS - { __x86_64_quanta_ix2_rangeley_config_STRINGIFY_NAME(X86_64_QUANTA_IX2_RANGELEY_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS), __x86_64_quanta_ix2_rangeley_config_STRINGIFY_VALUE(X86_64_QUANTA_IX2_RANGELEY_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS) }, -#else -{ X86_64_QUANTA_IX2_RANGELEY_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS(__x86_64_quanta_ix2_rangeley_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_QUANTA_IX2_RANGELEY_CONFIG_INCLUDE_UCLI - { __x86_64_quanta_ix2_rangeley_config_STRINGIFY_NAME(X86_64_QUANTA_IX2_RANGELEY_CONFIG_INCLUDE_UCLI), __x86_64_quanta_ix2_rangeley_config_STRINGIFY_VALUE(X86_64_QUANTA_IX2_RANGELEY_CONFIG_INCLUDE_UCLI) }, -#else -{ X86_64_QUANTA_IX2_RANGELEY_CONFIG_INCLUDE_UCLI(__x86_64_quanta_ix2_rangeley_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_QUANTA_IX2_RANGELEY_CONFIG_SYSFAN_RPM_FAILURE_THRESHOLD - { __x86_64_quanta_ix2_rangeley_config_STRINGIFY_NAME(X86_64_QUANTA_IX2_RANGELEY_CONFIG_SYSFAN_RPM_FAILURE_THRESHOLD), __x86_64_quanta_ix2_rangeley_config_STRINGIFY_VALUE(X86_64_QUANTA_IX2_RANGELEY_CONFIG_SYSFAN_RPM_FAILURE_THRESHOLD) }, -#else -{ X86_64_QUANTA_IX2_RANGELEY_CONFIG_SYSFAN_RPM_FAILURE_THRESHOLD(__x86_64_quanta_ix2_rangeley_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_QUANTA_IX2_RANGELEY_CONFIG_SYSFAN_F2B_RPM_MAX - { __x86_64_quanta_ix2_rangeley_config_STRINGIFY_NAME(X86_64_QUANTA_IX2_RANGELEY_CONFIG_SYSFAN_F2B_RPM_MAX), __x86_64_quanta_ix2_rangeley_config_STRINGIFY_VALUE(X86_64_QUANTA_IX2_RANGELEY_CONFIG_SYSFAN_F2B_RPM_MAX) }, -#else -{ X86_64_QUANTA_IX2_RANGELEY_CONFIG_SYSFAN_F2B_RPM_MAX(__x86_64_quanta_ix2_rangeley_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_QUANTA_IX2_RANGELEY_CONFIG_SYSFAN_B2F_RPM_MAX - { __x86_64_quanta_ix2_rangeley_config_STRINGIFY_NAME(X86_64_QUANTA_IX2_RANGELEY_CONFIG_SYSFAN_B2F_RPM_MAX), __x86_64_quanta_ix2_rangeley_config_STRINGIFY_VALUE(X86_64_QUANTA_IX2_RANGELEY_CONFIG_SYSFAN_B2F_RPM_MAX) }, -#else -{ X86_64_QUANTA_IX2_RANGELEY_CONFIG_SYSFAN_B2F_RPM_MAX(__x86_64_quanta_ix2_rangeley_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_QUANTA_IX2_RANGELEY_CONFIG_PHY_RESET_DELAY_MS - { __x86_64_quanta_ix2_rangeley_config_STRINGIFY_NAME(X86_64_QUANTA_IX2_RANGELEY_CONFIG_PHY_RESET_DELAY_MS), __x86_64_quanta_ix2_rangeley_config_STRINGIFY_VALUE(X86_64_QUANTA_IX2_RANGELEY_CONFIG_PHY_RESET_DELAY_MS) }, -#else -{ X86_64_QUANTA_IX2_RANGELEY_CONFIG_PHY_RESET_DELAY_MS(__x86_64_quanta_ix2_rangeley_config_STRINGIFY_NAME), "__undefined__" }, -#endif - { NULL, NULL } -}; -#undef __x86_64_quanta_ix2_rangeley_config_STRINGIFY_VALUE -#undef __x86_64_quanta_ix2_rangeley_config_STRINGIFY_NAME - -const char* -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)) { - return x86_64_quanta_ix2_rangeley_config_settings[i].value; - } - } - return NULL; -} - -int -x86_64_quanta_ix2_rangeley_config_show(struct aim_pvs_s* pvs) -{ - int i; - for(i = 0; x86_64_quanta_ix2_rangeley_config_settings[i].name; i++) { - aim_printf(pvs, "%s = %s\n", x86_64_quanta_ix2_rangeley_config_settings[i].name, x86_64_quanta_ix2_rangeley_config_settings[i].value); - } - return i; -} - -/* */ diff --git a/packages/platforms/quanta/x86-64/ix2-rangeley/onlp/builds/x86_64_quanta_ix2_rangeley/module/src/x86_64_quanta_ix2_rangeley_enums.c b/packages/platforms/quanta/x86-64/ix2-rangeley/onlp/builds/x86_64_quanta_ix2_rangeley/module/src/x86_64_quanta_ix2_rangeley_enums.c deleted file mode 100755 index 33e7fdfda..000000000 --- a/packages/platforms/quanta/x86-64/ix2-rangeley/onlp/builds/x86_64_quanta_ix2_rangeley/module/src/x86_64_quanta_ix2_rangeley_enums.c +++ /dev/null @@ -1,10 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#include - -/* <--auto.start.enum(ALL).source> */ -/* */ - diff --git a/packages/platforms/quanta/x86-64/ix2-rangeley/onlp/builds/x86_64_quanta_ix2_rangeley/module/src/x86_64_quanta_ix2_rangeley_int.h b/packages/platforms/quanta/x86-64/ix2-rangeley/onlp/builds/x86_64_quanta_ix2_rangeley/module/src/x86_64_quanta_ix2_rangeley_int.h deleted file mode 100755 index 0e04224c9..000000000 --- a/packages/platforms/quanta/x86-64/ix2-rangeley/onlp/builds/x86_64_quanta_ix2_rangeley/module/src/x86_64_quanta_ix2_rangeley_int.h +++ /dev/null @@ -1,308 +0,0 @@ -/**************************************************************************//** - * - * x86_64_quanta_ix2_rangeley Internal Header - * - *****************************************************************************/ -#ifndef __X86_64_QUANTA_IX2_RANGELEY_INT_H__ -#define __X86_64_QUANTA_IX2_RANGELEY_INT_H__ - -#include -#include - -/* */ -/** 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[]; - -/** 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 { - 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[]; - -/** 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 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 fan_alert; - int psu1_present; - int psu2_present; - int psu1_power_good; - int psu2_power_good; -}; - -#define SYS_HWMON_PREFIX "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/0-004e" - -#endif /* __X86_64_QUANTA_IX2_RANGELEY_INT_H__ */ diff --git a/packages/platforms/quanta/x86-64/ix2-rangeley/onlp/builds/x86_64_quanta_ix2_rangeley/module/src/x86_64_quanta_ix2_rangeley_log.c b/packages/platforms/quanta/x86-64/ix2-rangeley/onlp/builds/x86_64_quanta_ix2_rangeley/module/src/x86_64_quanta_ix2_rangeley_log.c deleted file mode 100755 index 5673120d1..000000000 --- a/packages/platforms/quanta/x86-64/ix2-rangeley/onlp/builds/x86_64_quanta_ix2_rangeley/module/src/x86_64_quanta_ix2_rangeley_log.c +++ /dev/null @@ -1,18 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#include - -#include "x86_64_quanta_ix2_rangeley_log.h" -/* - * x86_64_quanta_ix2_rangeley log struct. - */ -AIM_LOG_STRUCT_DEFINE( - X86_64_QUANTA_IX2_RANGELEY_CONFIG_LOG_OPTIONS_DEFAULT, - X86_64_QUANTA_IX2_RANGELEY_CONFIG_LOG_BITS_DEFAULT, - NULL, /* Custom log map */ - X86_64_QUANTA_IX2_RANGELEY_CONFIG_LOG_CUSTOM_BITS_DEFAULT - ); - diff --git a/packages/platforms/quanta/x86-64/ix2-rangeley/onlp/builds/x86_64_quanta_ix2_rangeley/module/src/x86_64_quanta_ix2_rangeley_log.h b/packages/platforms/quanta/x86-64/ix2-rangeley/onlp/builds/x86_64_quanta_ix2_rangeley/module/src/x86_64_quanta_ix2_rangeley_log.h deleted file mode 100755 index e66008e69..000000000 --- a/packages/platforms/quanta/x86-64/ix2-rangeley/onlp/builds/x86_64_quanta_ix2_rangeley/module/src/x86_64_quanta_ix2_rangeley_log.h +++ /dev/null @@ -1,12 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#ifndef __X86_64_QUANTA_IX2_RANGELEY_LOG_H__ -#define __X86_64_QUANTA_IX2_RANGELEY_LOG_H__ - -#define AIM_LOG_MODULE_NAME x86_64_quanta_ix2_rangeley -#include - -#endif /* __X86_64_QUANTA_IX2_RANGELEY_LOG_H__ */ diff --git a/packages/platforms/quanta/x86-64/ix2-rangeley/onlp/builds/x86_64_quanta_ix2_rangeley/module/src/x86_64_quanta_ix2_rangeley_module.c b/packages/platforms/quanta/x86-64/ix2-rangeley/onlp/builds/x86_64_quanta_ix2_rangeley/module/src/x86_64_quanta_ix2_rangeley_module.c deleted file mode 100755 index 3eac43721..000000000 --- a/packages/platforms/quanta/x86-64/ix2-rangeley/onlp/builds/x86_64_quanta_ix2_rangeley/module/src/x86_64_quanta_ix2_rangeley_module.c +++ /dev/null @@ -1,24 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#include - -#include "x86_64_quanta_ix2_rangeley_log.h" - -static int -datatypes_init__(void) -{ -#define X86_64_QUANTA_IX2_RANGELEY_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_ix2_rangeley_module_init__(void) -{ - AIM_LOG_STRUCT_REGISTER(); - datatypes_init__(); -} - -int __onlp_platform_version__ = 1; diff --git a/packages/platforms/quanta/x86-64/ix2-rangeley/onlp/builds/x86_64_quanta_ix2_rangeley/module/src/x86_64_quanta_ix2_rangeley_ucli.c b/packages/platforms/quanta/x86-64/ix2-rangeley/onlp/builds/x86_64_quanta_ix2_rangeley/module/src/x86_64_quanta_ix2_rangeley_ucli.c deleted file mode 100755 index d13ec42d7..000000000 --- a/packages/platforms/quanta/x86-64/ix2-rangeley/onlp/builds/x86_64_quanta_ix2_rangeley/module/src/x86_64_quanta_ix2_rangeley_ucli.c +++ /dev/null @@ -1,50 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#include - -#if X86_64_QUANTA_IX2_RANGELEY_CONFIG_INCLUDE_UCLI == 1 - -#include -#include -#include - -static ucli_status_t -x86_64_quanta_ix2_rangeley_ucli_ucli__config__(ucli_context_t* uc) -{ - UCLI_HANDLER_MACRO_MODULE_CONFIG(x86_64_quanta_ix2_rangeley) -} - -/* */ -/* */ - -static ucli_module_t -x86_64_quanta_ix2_rangeley_ucli_module__ = - { - "x86_64_quanta_ix2_rangeley_ucli", - NULL, - x86_64_quanta_ix2_rangeley_ucli_ucli_handlers__, - NULL, - NULL, - }; - -ucli_node_t* -x86_64_quanta_ix2_rangeley_ucli_node_create(void) -{ - ucli_node_t* n; - ucli_module_init(&x86_64_quanta_ix2_rangeley_ucli_module__); - n = ucli_node_create("x86_64_quanta_ix2_rangeley", NULL, &x86_64_quanta_ix2_rangeley_ucli_module__); - ucli_node_subnode_add(n, ucli_module_log_node_create("x86_64_quanta_ix2_rangeley")); - return n; -} - -#else -void* -x86_64_quanta_ix2_rangeley_ucli_node_create(void) -{ - return NULL; -} -#endif - diff --git a/packages/platforms/quanta/x86-64/ix2-rangeley/platform-config/Makefile b/packages/platforms/quanta/x86-64/ix2-rangeley/platform-config/Makefile deleted file mode 100755 index 003238cf6..000000000 --- a/packages/platforms/quanta/x86-64/ix2-rangeley/platform-config/Makefile +++ /dev/null @@ -1 +0,0 @@ -include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/quanta/x86-64/ix2-rangeley/platform-config/r0/Makefile b/packages/platforms/quanta/x86-64/ix2-rangeley/platform-config/r0/Makefile deleted file mode 100755 index 003238cf6..000000000 --- a/packages/platforms/quanta/x86-64/ix2-rangeley/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/quanta/x86-64/ix2-rangeley/platform-config/r0/PKG.yml b/packages/platforms/quanta/x86-64/ix2-rangeley/platform-config/r0/PKG.yml deleted file mode 100755 index 665b3f678..000000000 --- a/packages/platforms/quanta/x86-64/ix2-rangeley/platform-config/r0/PKG.yml +++ /dev/null @@ -1 +0,0 @@ -!include $ONL_TEMPLATES/platform-config-platform.yml ARCH=amd64 VENDOR=quanta BASENAME=x86-64-quanta-ix2-rangeley REVISION=r0 diff --git a/packages/platforms/quanta/x86-64/ix2-rangeley/platform-config/r0/src/lib/x86-64-quanta-ix2-rangeley-r0.yml b/packages/platforms/quanta/x86-64/ix2-rangeley/platform-config/r0/src/lib/x86-64-quanta-ix2-rangeley-r0.yml deleted file mode 100755 index 725e03a85..000000000 --- a/packages/platforms/quanta/x86-64/ix2-rangeley/platform-config/r0/src/lib/x86-64-quanta-ix2-rangeley-r0.yml +++ /dev/null @@ -1,31 +0,0 @@ ---- - -###################################################################### -# -# platform-config for IX2 -# -###################################################################### - -x86-64-quanta-ix2-rangeley-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/ix2-rangeley/platform-config/r0/src/python/x86_64_quanta_ix2_rangeley_r0/__init__.py b/packages/platforms/quanta/x86-64/ix2-rangeley/platform-config/r0/src/python/x86_64_quanta_ix2_rangeley_r0/__init__.py deleted file mode 100755 index 3b1347825..000000000 --- a/packages/platforms/quanta/x86-64/ix2-rangeley/platform-config/r0/src/python/x86_64_quanta_ix2_rangeley_r0/__init__.py +++ /dev/null @@ -1,28 +0,0 @@ -from onl.platform.base import * -from onl.platform.quanta import * - -class OnlPlatform_x86_64_quanta_ix2_rangeley_r0(OnlPlatformQuanta, - OnlPlatformPortConfig_48x25_8x100): - PLATFORM='x86-64-quanta-ix2-rangeley-r0' - MODEL="IX2" - """ 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.3200" - - def baseconfig(self): - # Expose PSOC that behind PCA9641 - os.system("i2cset -y 0 0x8 0x5 0xfb") - os.system("i2cset -y 0 0x8 0x1 0x5") - - self.insmod("qci_pmbus") - self.insmod("qci_cpld_sfp28") - self.insmod("quanta_hwmon_ix_series") - self.insmod("quanta_platform_ix2") - - return True diff --git a/packages/platforms/quanta/x86-64/ix7-rglbmc/.gitignore b/packages/platforms/quanta/x86-64/ix7-rglbmc/.gitignore deleted file mode 100644 index 0f1e9df74..000000000 --- a/packages/platforms/quanta/x86-64/ix7-rglbmc/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -*x86*64*quanta*ix7*rglbmc.mk -onlpdump.mk diff --git a/packages/platforms/quanta/x86-64/ix7-rglbmc/Makefile b/packages/platforms/quanta/x86-64/ix7-rglbmc/Makefile deleted file mode 100644 index 003238cf6..000000000 --- a/packages/platforms/quanta/x86-64/ix7-rglbmc/Makefile +++ /dev/null @@ -1 +0,0 @@ -include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/quanta/x86-64/ix7-rglbmc/modules/Makefile b/packages/platforms/quanta/x86-64/ix7-rglbmc/modules/Makefile deleted file mode 100644 index 003238cf6..000000000 --- a/packages/platforms/quanta/x86-64/ix7-rglbmc/modules/Makefile +++ /dev/null @@ -1 +0,0 @@ -include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/quanta/x86-64/ix7-rglbmc/modules/PKG.yml b/packages/platforms/quanta/x86-64/ix7-rglbmc/modules/PKG.yml deleted file mode 100644 index 8c671886e..000000000 --- a/packages/platforms/quanta/x86-64/ix7-rglbmc/modules/PKG.yml +++ /dev/null @@ -1 +0,0 @@ -!include $ONL_TEMPLATES/platform-modules.yml ARCH=amd64 VENDOR=quanta BASENAME=x86-64-quanta-ix7-rglbmc KERNELS="onl-kernel-3.16-lts-x86-64-all:amd64" diff --git a/packages/platforms/quanta/x86-64/ix7-rglbmc/modules/builds/.gitignore b/packages/platforms/quanta/x86-64/ix7-rglbmc/modules/builds/.gitignore deleted file mode 100644 index a65b41774..000000000 --- a/packages/platforms/quanta/x86-64/ix7-rglbmc/modules/builds/.gitignore +++ /dev/null @@ -1 +0,0 @@ -lib diff --git a/packages/platforms/quanta/x86-64/ix7-rglbmc/modules/builds/Makefile b/packages/platforms/quanta/x86-64/ix7-rglbmc/modules/builds/Makefile deleted file mode 100644 index af745769f..000000000 --- a/packages/platforms/quanta/x86-64/ix7-rglbmc/modules/builds/Makefile +++ /dev/null @@ -1,6 +0,0 @@ -KERNELS := onl-kernel-3.16-lts-x86-64-all:amd64 -KMODULES := $(wildcard *.c) -VENDOR := quanta -BASENAME := x86-64-quanta-ix7-rglbmc -ARCH := x86_64 -include $(ONL)/make/kmodule.mk diff --git a/packages/platforms/quanta/x86-64/ix7-rglbmc/modules/builds/quanta_platform_ix7.c b/packages/platforms/quanta/x86-64/ix7-rglbmc/modules/builds/quanta_platform_ix7.c deleted file mode 100644 index ce251d5a6..000000000 --- a/packages/platforms/quanta/x86-64/ix7-rglbmc/modules/builds/quanta_platform_ix7.c +++ /dev/null @@ -1,323 +0,0 @@ -/* - * Quanta IX7 platform driver - * - * - * Copyright (C) 2014 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 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, -}; -//CPU Board pca9555 -static struct pca953x_platform_data pca9555_CPU_data = { - .gpio_base = 0x20, -}; - -static struct i2c_board_info ix7_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 0x72 ch2 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("pca9555", 0x23), // 7 0x72 ch3 pca9555 MB Board Data - .platform_data = &pca9555_1_data, - }, - { - I2C_BOARD_INFO("CPLD-QSFP28", 0x38), // 8 0x72 ch0 - }, - { - I2C_BOARD_INFO("CPLD-QSFP28", 0x38), // 9 0x72 ch1 - }, - { - I2C_BOARD_INFO("pca9546", 0x71), // 10 CPU Board i2c device - .platform_data = &pca9546_cpu_data, - }, - { - I2C_BOARD_INFO("pca9555", 0x20), // 11 0x71 ch0 CPU Board Data - .platform_data = &pca9555_CPU_data, - }, - { - I2C_BOARD_INFO("optoe1", 0x50), // 12 0x50 SFP, QSFP28 EEPROM - }, - { - I2C_BOARD_INFO("CPLDLED_IX7", 0x39), // 13 0x72 ch0 CPLD_led_1 - }, - { - I2C_BOARD_INFO("CPLDLED_IX7", 0x39), // 14 0x72 ch1 CPLD_led_1 - }, -}; - -static struct platform_driver ix7_platform_driver = { - .driver = { - .name = "qci-ix7", - .owner = THIS_MODULE, - }, -}; - -static struct platform_device *ix7_device; - -static int __init ix7_platform_init(void) -{ - struct i2c_client *client; - struct i2c_adapter *adapter; - int ret, i; - - ret = platform_driver_register(&ix7_platform_driver); - if (ret < 0) - return ret; - - /* Register platform stuff */ - ix7_device = platform_device_alloc("qci-ix7", -1); - if (!ix7_device) { - ret = -ENOMEM; - goto fail_platform_driver; - } - - ret = platform_device_add(ix7_device); - if (ret) - goto fail_platform_device; - - adapter = i2c_get_adapter(0); - client = i2c_new_device(adapter, &ix7_i2c_devices[0]); // pca9546 - client = i2c_new_device(adapter, &ix7_i2c_devices[1]); // pca9548 - client = i2c_new_device(adapter, &ix7_i2c_devices[10]); // pca9546 in CPU board - i2c_put_adapter(adapter); - - adapter = i2c_get_adapter(0x02); - client = i2c_new_device(adapter, &ix7_i2c_devices[11]); // CPU Board Data - i2c_put_adapter(adapter); - - adapter = i2c_get_adapter(0x10); - client = i2c_new_device(adapter, &ix7_i2c_devices[8]); // CPLD2 - client = i2c_new_device(adapter, &ix7_i2c_devices[13]); // CPLD_led_1 - i2c_put_adapter(adapter); - - adapter = i2c_get_adapter(0x11); - client = i2c_new_device(adapter, &ix7_i2c_devices[9]); // CPLD3 - client = i2c_new_device(adapter, &ix7_i2c_devices[14]); // CPLD_led_2 - i2c_put_adapter(adapter); - - adapter = i2c_get_adapter(0x12); - client = i2c_new_device(adapter, &ix7_i2c_devices[2]); // MB_BOARDINFO_EEPROM - i2c_put_adapter(adapter); - - adapter = i2c_get_adapter(0x13); - client = i2c_new_device(adapter, &ix7_i2c_devices[7]); // pca9555 MB Board Data - i2c_put_adapter(adapter); - - adapter = i2c_get_adapter(0x14); - client = i2c_new_device(adapter, &ix7_i2c_devices[3]); // pca9548_1 SFP - i2c_put_adapter(adapter); - - adapter = i2c_get_adapter(0x15); - client = i2c_new_device(adapter, &ix7_i2c_devices[4]); // pca9548_2 SFP - i2c_put_adapter(adapter); - - adapter = i2c_get_adapter(0x16); - client = i2c_new_device(adapter, &ix7_i2c_devices[5]); // pca9548_3 SFP - i2c_put_adapter(adapter); - - adapter = i2c_get_adapter(0x17); - client = i2c_new_device(adapter, &ix7_i2c_devices[6]); // pca9548_4 SFP - i2c_put_adapter(adapter); - for(i = 32; i < 64; i ++){ // QSFP28 1~32 EEPROM - adapter = i2c_get_adapter(i); - client = i2c_new_device(adapter, &ix7_i2c_devices[12]); - i2c_put_adapter(adapter); - } - - return 0; - -fail_platform_device: - platform_device_put(ix7_device); - -fail_platform_driver: - platform_driver_unregister(&ix7_platform_driver); - return ret; -} - -static void __exit ix7_platform_exit(void) -{ - platform_device_unregister(ix7_device); - platform_driver_unregister(&ix7_platform_driver); -} - -module_init(ix7_platform_init); -module_exit(ix7_platform_exit); - - -MODULE_AUTHOR("Jonathan Tsai "); -MODULE_VERSION("1.0"); -MODULE_DESCRIPTION("Quanta IX7 Platform Driver"); -MODULE_LICENSE("GPL"); diff --git a/packages/platforms/quanta/x86-64/ix7-rglbmc/onlp/Makefile b/packages/platforms/quanta/x86-64/ix7-rglbmc/onlp/Makefile deleted file mode 100644 index 003238cf6..000000000 --- a/packages/platforms/quanta/x86-64/ix7-rglbmc/onlp/Makefile +++ /dev/null @@ -1 +0,0 @@ -include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/quanta/x86-64/ix7-rglbmc/onlp/PKG.yml b/packages/platforms/quanta/x86-64/ix7-rglbmc/onlp/PKG.yml deleted file mode 100644 index a56e07158..000000000 --- a/packages/platforms/quanta/x86-64/ix7-rglbmc/onlp/PKG.yml +++ /dev/null @@ -1 +0,0 @@ -!include $ONL_TEMPLATES/onlp-platform-any.yml PLATFORM=x86-64-quanta-ix7-rglbmc ARCH=amd64 TOOLCHAIN=x86_64-linux-gnu diff --git a/packages/platforms/quanta/x86-64/ix7-rglbmc/onlp/builds/Makefile b/packages/platforms/quanta/x86-64/ix7-rglbmc/onlp/builds/Makefile deleted file mode 100644 index e7437cb23..000000000 --- a/packages/platforms/quanta/x86-64/ix7-rglbmc/onlp/builds/Makefile +++ /dev/null @@ -1,2 +0,0 @@ -FILTER=src -include $(ONL)/make/subdirs.mk diff --git a/packages/platforms/quanta/x86-64/ix7-rglbmc/onlp/builds/lib/Makefile b/packages/platforms/quanta/x86-64/ix7-rglbmc/onlp/builds/lib/Makefile deleted file mode 100644 index 509b9e1d4..000000000 --- a/packages/platforms/quanta/x86-64/ix7-rglbmc/onlp/builds/lib/Makefile +++ /dev/null @@ -1,3 +0,0 @@ -PLATFORM := x86-64-quanta-ix7-rglbmc -EXTRA_MODULES := quanta_sys_eeprom -include $(ONL)/packages/base/any/onlp/builds/platform/libonlp-platform.mk diff --git a/packages/platforms/quanta/x86-64/ix7-rglbmc/onlp/builds/onlpdump/Makefile b/packages/platforms/quanta/x86-64/ix7-rglbmc/onlp/builds/onlpdump/Makefile deleted file mode 100644 index 50f87a3de..000000000 --- a/packages/platforms/quanta/x86-64/ix7-rglbmc/onlp/builds/onlpdump/Makefile +++ /dev/null @@ -1,3 +0,0 @@ -PLATFORM := x86-64-quanta-ix7-rglbmc -EXTRA_MODULES := quanta_sys_eeprom -include $(ONL)/packages/base/any/onlp/builds/platform/onlps.mk diff --git a/packages/platforms/quanta/x86-64/ix7-rglbmc/onlp/builds/x86_64_quanta_ix7_rglbmc/.module b/packages/platforms/quanta/x86-64/ix7-rglbmc/onlp/builds/x86_64_quanta_ix7_rglbmc/.module deleted file mode 100644 index dc4a368ff..000000000 --- a/packages/platforms/quanta/x86-64/ix7-rglbmc/onlp/builds/x86_64_quanta_ix7_rglbmc/.module +++ /dev/null @@ -1 +0,0 @@ -name: x86_64_quanta_ix7_rglbmc diff --git a/packages/platforms/quanta/x86-64/ix7-rglbmc/onlp/builds/x86_64_quanta_ix7_rglbmc/Makefile b/packages/platforms/quanta/x86-64/ix7-rglbmc/onlp/builds/x86_64_quanta_ix7_rglbmc/Makefile deleted file mode 100644 index b4f54d530..000000000 --- a/packages/platforms/quanta/x86-64/ix7-rglbmc/onlp/builds/x86_64_quanta_ix7_rglbmc/Makefile +++ /dev/null @@ -1,9 +0,0 @@ -############################################################################### -# -# -# -############################################################################### -include $(ONL)/make/config.mk -MODULE := x86_64_quanta_ix7_rglbmc -AUTOMODULE := x86_64_quanta_ix7_rglbmc -include $(BUILDER)/definemodule.mk diff --git a/packages/platforms/quanta/x86-64/ix7-rglbmc/onlp/builds/x86_64_quanta_ix7_rglbmc/module/auto/make.mk b/packages/platforms/quanta/x86-64/ix7-rglbmc/onlp/builds/x86_64_quanta_ix7_rglbmc/module/auto/make.mk deleted file mode 100644 index 0263bd02d..000000000 --- a/packages/platforms/quanta/x86-64/ix7-rglbmc/onlp/builds/x86_64_quanta_ix7_rglbmc/module/auto/make.mk +++ /dev/null @@ -1,9 +0,0 @@ -############################################################################### -# -# x86_64_quanta_ix7_rglbmc Autogeneration -# -############################################################################### -x86_64_quanta_ix7_rglbmc_AUTO_DEFS := module/auto/x86_64_quanta_ix7_rglbmc.yml -x86_64_quanta_ix7_rglbmc_AUTO_DIRS := module/inc/x86_64_quanta_ix7_rglbmc module/src -include $(BUILDER)/auto.mk - diff --git a/packages/platforms/quanta/x86-64/ix7-rglbmc/onlp/builds/x86_64_quanta_ix7_rglbmc/module/auto/x86_64_quanta_ix7_rglbmc.yml b/packages/platforms/quanta/x86-64/ix7-rglbmc/onlp/builds/x86_64_quanta_ix7_rglbmc/module/auto/x86_64_quanta_ix7_rglbmc.yml deleted file mode 100644 index 42f8838cb..000000000 --- a/packages/platforms/quanta/x86-64/ix7-rglbmc/onlp/builds/x86_64_quanta_ix7_rglbmc/module/auto/x86_64_quanta_ix7_rglbmc.yml +++ /dev/null @@ -1,134 +0,0 @@ -############################################################################### -# -# x86_64_quanta_ix7_rglbmc Autogeneration Definitions. -# -############################################################################### - -cdefs: &cdefs -- X86_64_QUANTA_IX7_RGLBMC_CONFIG_INCLUDE_LOGGING: - doc: "Include or exclude logging." - default: 1 -- X86_64_QUANTA_IX7_RGLBMC_CONFIG_LOG_OPTIONS_DEFAULT: - doc: "Default enabled log options." - default: AIM_LOG_OPTIONS_DEFAULT -- X86_64_QUANTA_IX7_RGLBMC_CONFIG_LOG_BITS_DEFAULT: - doc: "Default enabled log bits." - default: AIM_LOG_BITS_DEFAULT -- X86_64_QUANTA_IX7_RGLBMC_CONFIG_LOG_CUSTOM_BITS_DEFAULT: - doc: "Default enabled custom log bits." - default: 0 -- X86_64_QUANTA_IX7_RGLBMC_CONFIG_PORTING_STDLIB: - doc: "Default all porting macros to use the C standard libraries." - default: 1 -- X86_64_QUANTA_IX7_RGLBMC_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS: - doc: "Include standard library headers for stdlib porting macros." - default: X86_64_QUANTA_IX7_RGLBMC_CONFIG_PORTING_STDLIB -- X86_64_QUANTA_IX7_RGLBMC_CONFIG_INCLUDE_UCLI: - doc: "Include generic uCli support." - default: 0 -- X86_64_QUANTA_IX7_RGLBMC_CONFIG_SYSFAN_RPM_FAILURE_THRESHOLD: - doc: "RPM Threshold at which the fan is considered to have failed." - default: 3000 -- X86_64_QUANTA_IX7_RGLBMC_CONFIG_SYSFAN_F2B_RPM_MAX: - doc: "Maximum system front-to-back fan speed." - default: 18000 -- X86_64_QUANTA_IX7_RGLBMC_CONFIG_SYSFAN_B2F_RPM_MAX: - doc: "Maximum system back-to-front fan speed." - default: 18000 -- X86_64_QUANTA_IX7_RGLBMC_CONFIG_PHY_RESET_DELAY_MS: - doc: "Time to hold Phy GPIO in reset, in ms" - default: 100 - -definitions: - cdefs: - X86_64_QUANTA_IX7_RGLBMC_CONFIG_HEADER: - defs: *cdefs - basename: x86_64_quanta_ix7_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_IX7_RGLBMC: - macros: - - memset - - memcpy - - - vsnprintf - - snprintf - - strlen diff --git a/packages/platforms/quanta/x86-64/ix7-rglbmc/onlp/builds/x86_64_quanta_ix7_rglbmc/module/inc/x86_64_quanta_ix7_rglbmc/x86_64_quanta_ix7_rglbmc.x b/packages/platforms/quanta/x86-64/ix7-rglbmc/onlp/builds/x86_64_quanta_ix7_rglbmc/module/inc/x86_64_quanta_ix7_rglbmc/x86_64_quanta_ix7_rglbmc.x deleted file mode 100644 index 2ac54ec51..000000000 --- a/packages/platforms/quanta/x86-64/ix7-rglbmc/onlp/builds/x86_64_quanta_ix7_rglbmc/module/inc/x86_64_quanta_ix7_rglbmc/x86_64_quanta_ix7_rglbmc.x +++ /dev/null @@ -1,14 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#include - -/* <--auto.start.xmacro(ALL).define> */ -/* */ - -/* <--auto.start.xenum(ALL).define> */ -/* */ - - diff --git a/packages/platforms/quanta/x86-64/ix7-rglbmc/onlp/builds/x86_64_quanta_ix7_rglbmc/module/inc/x86_64_quanta_ix7_rglbmc/x86_64_quanta_ix7_rglbmc_config.h b/packages/platforms/quanta/x86-64/ix7-rglbmc/onlp/builds/x86_64_quanta_ix7_rglbmc/module/inc/x86_64_quanta_ix7_rglbmc/x86_64_quanta_ix7_rglbmc_config.h deleted file mode 100644 index 4fc0258e5..000000000 --- a/packages/platforms/quanta/x86-64/ix7-rglbmc/onlp/builds/x86_64_quanta_ix7_rglbmc/module/inc/x86_64_quanta_ix7_rglbmc/x86_64_quanta_ix7_rglbmc_config.h +++ /dev/null @@ -1,167 +0,0 @@ -/**************************************************************************//** - * - * @file - * @brief x86_64_quanta_ix7_rglbmc Configuration Header - * - * @addtogroup x86_64_quanta_ix7_rglbmc-config - * @{ - * - *****************************************************************************/ -#ifndef __X86_64_QUANTA_IX7_RGLBMC_CONFIG_H__ -#define __X86_64_QUANTA_IX7_RGLBMC_CONFIG_H__ - -#ifdef GLOBAL_INCLUDE_CUSTOM_CONFIG -#include -#endif -#ifdef X86_64_QUANTA_IX7_RGLBMC_INCLUDE_CUSTOM_CONFIG -#include -#endif - -/* */ -#include -/** - * X86_64_QUANTA_IX7_RGLBMC_CONFIG_INCLUDE_LOGGING - * - * Include or exclude logging. */ - - -#ifndef X86_64_QUANTA_IX7_RGLBMC_CONFIG_INCLUDE_LOGGING -#define X86_64_QUANTA_IX7_RGLBMC_CONFIG_INCLUDE_LOGGING 1 -#endif - -/** - * X86_64_QUANTA_IX7_RGLBMC_CONFIG_LOG_OPTIONS_DEFAULT - * - * Default enabled log options. */ - - -#ifndef X86_64_QUANTA_IX7_RGLBMC_CONFIG_LOG_OPTIONS_DEFAULT -#define X86_64_QUANTA_IX7_RGLBMC_CONFIG_LOG_OPTIONS_DEFAULT AIM_LOG_OPTIONS_DEFAULT -#endif - -/** - * X86_64_QUANTA_IX7_RGLBMC_CONFIG_LOG_BITS_DEFAULT - * - * Default enabled log bits. */ - - -#ifndef X86_64_QUANTA_IX7_RGLBMC_CONFIG_LOG_BITS_DEFAULT -#define X86_64_QUANTA_IX7_RGLBMC_CONFIG_LOG_BITS_DEFAULT AIM_LOG_BITS_DEFAULT -#endif - -/** - * X86_64_QUANTA_IX7_RGLBMC_CONFIG_LOG_CUSTOM_BITS_DEFAULT - * - * Default enabled custom log bits. */ - - -#ifndef X86_64_QUANTA_IX7_RGLBMC_CONFIG_LOG_CUSTOM_BITS_DEFAULT -#define X86_64_QUANTA_IX7_RGLBMC_CONFIG_LOG_CUSTOM_BITS_DEFAULT 0 -#endif - -/** - * X86_64_QUANTA_IX7_RGLBMC_CONFIG_PORTING_STDLIB - * - * Default all porting macros to use the C standard libraries. */ - - -#ifndef X86_64_QUANTA_IX7_RGLBMC_CONFIG_PORTING_STDLIB -#define X86_64_QUANTA_IX7_RGLBMC_CONFIG_PORTING_STDLIB 1 -#endif - -/** - * X86_64_QUANTA_IX7_RGLBMC_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS - * - * Include standard library headers for stdlib porting macros. */ - - -#ifndef X86_64_QUANTA_IX7_RGLBMC_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS -#define X86_64_QUANTA_IX7_RGLBMC_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS X86_64_QUANTA_IX7_RGLBMC_CONFIG_PORTING_STDLIB -#endif - -/** - * X86_64_QUANTA_IX7_RGLBMC_CONFIG_INCLUDE_UCLI - * - * Include generic uCli support. */ - - -#ifndef X86_64_QUANTA_IX7_RGLBMC_CONFIG_INCLUDE_UCLI -#define X86_64_QUANTA_IX7_RGLBMC_CONFIG_INCLUDE_UCLI 0 -#endif - -/** - * X86_64_QUANTA_IX7_RGLBMC_CONFIG_SYSFAN_RPM_FAILURE_THRESHOLD - * - * RPM Threshold at which the fan is considered to have failed. */ - - -#ifndef X86_64_QUANTA_IX7_RGLBMC_CONFIG_SYSFAN_RPM_FAILURE_THRESHOLD -#define X86_64_QUANTA_IX7_RGLBMC_CONFIG_SYSFAN_RPM_FAILURE_THRESHOLD 3000 -#endif - -/** - * X86_64_QUANTA_IX7_RGLBMC_CONFIG_SYSFAN_F2B_RPM_MAX - * - * Maximum system front-to-back fan speed. */ - - -#ifndef X86_64_QUANTA_IX7_RGLBMC_CONFIG_SYSFAN_F2B_RPM_MAX -#define X86_64_QUANTA_IX7_RGLBMC_CONFIG_SYSFAN_F2B_RPM_MAX 18000 -#endif - -/** - * X86_64_QUANTA_IX7_RGLBMC_CONFIG_SYSFAN_B2F_RPM_MAX - * - * Maximum system back-to-front fan speed. */ - - -#ifndef X86_64_QUANTA_IX7_RGLBMC_CONFIG_SYSFAN_B2F_RPM_MAX -#define X86_64_QUANTA_IX7_RGLBMC_CONFIG_SYSFAN_B2F_RPM_MAX 18000 -#endif - -/** - * X86_64_QUANTA_IX7_RGLBMC_CONFIG_PHY_RESET_DELAY_MS - * - * Time to hold Phy GPIO in reset, in ms */ - - -#ifndef X86_64_QUANTA_IX7_RGLBMC_CONFIG_PHY_RESET_DELAY_MS -#define X86_64_QUANTA_IX7_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_ix7_rglbmc_config_settings_s { - /** name */ - const char* name; - /** value */ - const char* value; -} x86_64_quanta_ix7_rglbmc_config_settings_t; - -/** Configuration settings table. */ -/** x86_64_quanta_ix7_rglbmc_config_settings table. */ -extern x86_64_quanta_ix7_rglbmc_config_settings_t x86_64_quanta_ix7_rglbmc_config_settings[]; - -/** - * @brief Lookup a configuration setting. - * @param setting The name of the configuration option to lookup. - */ -const char* x86_64_quanta_ix7_rglbmc_config_lookup(const char* setting); - -/** - * @brief Show the compile-time configuration. - * @param pvs The output stream. - */ -int x86_64_quanta_ix7_rglbmc_config_show(struct aim_pvs_s* pvs); - -/* */ - -#include "x86_64_quanta_ix7_rglbmc_porting.h" - -#endif /* __X86_64_QUANTA_IX7_RGLBMC_CONFIG_H__ */ -/* @} */ diff --git a/packages/platforms/quanta/x86-64/ix7-rglbmc/onlp/builds/x86_64_quanta_ix7_rglbmc/module/inc/x86_64_quanta_ix7_rglbmc/x86_64_quanta_ix7_rglbmc_dox.h b/packages/platforms/quanta/x86-64/ix7-rglbmc/onlp/builds/x86_64_quanta_ix7_rglbmc/module/inc/x86_64_quanta_ix7_rglbmc/x86_64_quanta_ix7_rglbmc_dox.h deleted file mode 100644 index fa83667a1..000000000 --- a/packages/platforms/quanta/x86-64/ix7-rglbmc/onlp/builds/x86_64_quanta_ix7_rglbmc/module/inc/x86_64_quanta_ix7_rglbmc/x86_64_quanta_ix7_rglbmc_dox.h +++ /dev/null @@ -1,26 +0,0 @@ -/**************************************************************************//** - * - * x86_64_quanta_ix7_rglbmc Doxygen Header - * - *****************************************************************************/ -#ifndef __X86_64_QUANTA_IX7_RGLBMC_DOX_H__ -#define __X86_64_QUANTA_IX7_RGLBMC_DOX_H__ - -/** - * @defgroup x86_64_quanta_ix7_rglbmc x86_64_quanta_ix7_rglbmc - x86_64_quanta_ix7_rglbmc Description - * - -The documentation overview for this module should go here. - - * - * @{ - * - * @defgroup x86_64_quanta_ix7_rglbmc-x86_64_quanta_ix7_rglbmc Public Interface - * @defgroup x86_64_quanta_ix7_rglbmc-config Compile Time Configuration - * @defgroup x86_64_quanta_ix7_rglbmc-porting Porting Macros - * - * @} - * - */ - -#endif /* __X86_64_QUANTA_IX7_RGLBMC_DOX_H__ */ diff --git a/packages/platforms/quanta/x86-64/ix7-rglbmc/onlp/builds/x86_64_quanta_ix7_rglbmc/module/inc/x86_64_quanta_ix7_rglbmc/x86_64_quanta_ix7_rglbmc_gpio_table.h b/packages/platforms/quanta/x86-64/ix7-rglbmc/onlp/builds/x86_64_quanta_ix7_rglbmc/module/inc/x86_64_quanta_ix7_rglbmc/x86_64_quanta_ix7_rglbmc_gpio_table.h deleted file mode 100644 index 0347c6e91..000000000 --- a/packages/platforms/quanta/x86-64/ix7-rglbmc/onlp/builds/x86_64_quanta_ix7_rglbmc/module/inc/x86_64_quanta_ix7_rglbmc/x86_64_quanta_ix7_rglbmc_gpio_table.h +++ /dev/null @@ -1,25 +0,0 @@ -#ifndef __X86_64_QUANTA_IX7_RGLBMC_GPIO_TABLE_H__ -#define __X86_64_QUANTA_IX7_RGLBMC_GPIO_TABLE_H__ - -/* - * defined within platform/quanta_switch.c - * Quanta Switch Platform driver - */ -#define QUANTA_IX7_PCA953x_GPIO(P1, P2) (P1*8+P2) - -#define QUANTA_IX7_PCA9555_GPIO_SIZE 0x10 - -#define QUANTA_IX7_I2C_GPIO_BASE 0x10 - -#define QUANTA_IX7_I2C_GPIO_CPU_BASE 0x20 - -#define QUANTA_IX7_CPU_BOARD_GPIO_BASE (QUANTA_IX7_I2C_GPIO_CPU_BASE) -#define QUANTA_IX7_CPU_BOARD_SYS_P1 (QUANTA_IX7_CPU_BOARD_GPIO_BASE + QUANTA_IX7_PCA953x_GPIO(1,2)) -#define QUANTA_IX7_CPU_BOARD_SYS_P2 (QUANTA_IX7_CPU_BOARD_GPIO_BASE + QUANTA_IX7_PCA953x_GPIO(1,3)) - -#define QUANTA_IX7_ZQSFP_EN_GPIO_BASE QUANTA_IX7_I2C_GPIO_BASE -#define QUANTA_IX7_ZQSFP_EN_GPIO_SIZE QUANTA_IX7_PCA9555_GPIO_SIZE -#define QUANTA_IX7_ZQSFP_EN_GPIO_P3V3_PW_GD (QUANTA_IX7_ZQSFP_EN_GPIO_BASE + QUANTA_IX7_PCA953x_GPIO(0,4)) -#define QUANTA_IX7_ZQSFP_EN_GPIO_P3V3_PW_EN (QUANTA_IX7_ZQSFP_EN_GPIO_BASE + QUANTA_IX7_PCA953x_GPIO(0,5)) - -#endif /* __X86_64_QUANTA_IX7_RGLBMC_GPIO_TABLE_H__ */ diff --git a/packages/platforms/quanta/x86-64/ix7-rglbmc/onlp/builds/x86_64_quanta_ix7_rglbmc/module/inc/x86_64_quanta_ix7_rglbmc/x86_64_quanta_ix7_rglbmc_porting.h b/packages/platforms/quanta/x86-64/ix7-rglbmc/onlp/builds/x86_64_quanta_ix7_rglbmc/module/inc/x86_64_quanta_ix7_rglbmc/x86_64_quanta_ix7_rglbmc_porting.h deleted file mode 100644 index 11864e148..000000000 --- a/packages/platforms/quanta/x86-64/ix7-rglbmc/onlp/builds/x86_64_quanta_ix7_rglbmc/module/inc/x86_64_quanta_ix7_rglbmc/x86_64_quanta_ix7_rglbmc_porting.h +++ /dev/null @@ -1,77 +0,0 @@ -/**************************************************************************//** - * - * @file - * @brief x86_64_quanta_ix7_rglbmc Porting Macros. - * - * @addtogroup x86_64_quanta_ix7_rglbmc-porting - * @{ - * - *****************************************************************************/ -#ifndef __X86_64_QUANTA_IX7_RGLBMC_PORTING_H__ -#define __X86_64_QUANTA_IX7_RGLBMC_PORTING_H__ - - -/* */ -#if X86_64_QUANTA_IX7_RGLBMC_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS == 1 -#include -#include -#include -#include -#include -#endif - -#ifndef X86_64_QUANTA_IX7_RGLBMC_MEMSET - #if defined(GLOBAL_MEMSET) - #define X86_64_QUANTA_IX7_RGLBMC_MEMSET GLOBAL_MEMSET - #elif X86_64_QUANTA_IX7_RGLBMC_CONFIG_PORTING_STDLIB == 1 - #define X86_64_QUANTA_IX7_RGLBMC_MEMSET memset - #else - #error The macro X86_64_QUANTA_IX7_RGLBMC_MEMSET is required but cannot be defined. - #endif -#endif - -#ifndef X86_64_QUANTA_IX7_RGLBMC_MEMCPY - #if defined(GLOBAL_MEMCPY) - #define X86_64_QUANTA_IX7_RGLBMC_MEMCPY GLOBAL_MEMCPY - #elif X86_64_QUANTA_IX7_RGLBMC_CONFIG_PORTING_STDLIB == 1 - #define X86_64_QUANTA_IX7_RGLBMC_MEMCPY memcpy - #else - #error The macro X86_64_QUANTA_IX7_RGLBMC_MEMCPY is required but cannot be defined. - #endif -#endif - -#ifndef X86_64_QUANTA_IX7_RGLBMC_VSNPRINTF - #if defined(GLOBAL_VSNPRINTF) - #define X86_64_QUANTA_IX7_RGLBMC_VSNPRINTF GLOBAL_VSNPRINTF - #elif X86_64_QUANTA_IX7_RGLBMC_CONFIG_PORTING_STDLIB == 1 - #define X86_64_QUANTA_IX7_RGLBMC_VSNPRINTF vsnprintf - #else - #error The macro X86_64_QUANTA_IX7_RGLBMC_VSNPRINTF is required but cannot be defined. - #endif -#endif - -#ifndef X86_64_QUANTA_IX7_RGLBMC_SNPRINTF - #if defined(GLOBAL_SNPRINTF) - #define X86_64_QUANTA_IX7_RGLBMC_SNPRINTF GLOBAL_SNPRINTF - #elif X86_64_QUANTA_IX7_RGLBMC_CONFIG_PORTING_STDLIB == 1 - #define X86_64_QUANTA_IX7_RGLBMC_SNPRINTF snprintf - #else - #error The macro X86_64_QUANTA_IX7_RGLBMC_SNPRINTF is required but cannot be defined. - #endif -#endif - -#ifndef X86_64_QUANTA_IX7_RGLBMC_STRLEN - #if defined(GLOBAL_STRLEN) - #define X86_64_QUANTA_IX7_RGLBMC_STRLEN GLOBAL_STRLEN - #elif X86_64_QUANTA_IX7_RGLBMC_CONFIG_PORTING_STDLIB == 1 - #define X86_64_QUANTA_IX7_RGLBMC_STRLEN strlen - #else - #error The macro X86_64_QUANTA_IX7_RGLBMC_STRLEN is required but cannot be defined. - #endif -#endif - -/* */ - - -#endif /* __X86_64_QUANTA_IX7_RGLBMC_PORTING_H__ */ -/* @} */ diff --git a/packages/platforms/quanta/x86-64/ix7-rglbmc/onlp/builds/x86_64_quanta_ix7_rglbmc/module/make.mk b/packages/platforms/quanta/x86-64/ix7-rglbmc/onlp/builds/x86_64_quanta_ix7_rglbmc/module/make.mk deleted file mode 100644 index e5947b4f6..000000000 --- a/packages/platforms/quanta/x86-64/ix7-rglbmc/onlp/builds/x86_64_quanta_ix7_rglbmc/module/make.mk +++ /dev/null @@ -1,10 +0,0 @@ -############################################################################### -# -# -# -############################################################################### -THIS_DIR := $(dir $(lastword $(MAKEFILE_LIST))) -x86_64_quanta_ix7_rglbmc_INCLUDES := -I $(THIS_DIR)inc -x86_64_quanta_ix7_rglbmc_INTERNAL_INCLUDES := -I $(THIS_DIR)src -x86_64_quanta_ix7_rglbmc_DEPENDMODULE_ENTRIES := init:x86_64_quanta_ix7_rglbmc ucli:x86_64_quanta_ix7_rglbmc - diff --git a/packages/platforms/quanta/x86-64/ix7-rglbmc/onlp/builds/x86_64_quanta_ix7_rglbmc/module/src/Makefile b/packages/platforms/quanta/x86-64/ix7-rglbmc/onlp/builds/x86_64_quanta_ix7_rglbmc/module/src/Makefile deleted file mode 100644 index ee8004c42..000000000 --- a/packages/platforms/quanta/x86-64/ix7-rglbmc/onlp/builds/x86_64_quanta_ix7_rglbmc/module/src/Makefile +++ /dev/null @@ -1,9 +0,0 @@ -############################################################################### -# -# Local source generation targets. -# -############################################################################### - -ucli: - @../../../../tools/uclihandlers.py x86_64_quanta_ix7_rglbmc_ucli.c - diff --git a/packages/platforms/quanta/x86-64/ix7-rglbmc/onlp/builds/x86_64_quanta_ix7_rglbmc/module/src/fani.c b/packages/platforms/quanta/x86-64/ix7-rglbmc/onlp/builds/x86_64_quanta_ix7_rglbmc/module/src/fani.c deleted file mode 100644 index 7594b0ca0..000000000 --- a/packages/platforms/quanta/x86-64/ix7-rglbmc/onlp/builds/x86_64_quanta_ix7_rglbmc/module/src/fani.c +++ /dev/null @@ -1,31 +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 - -int -onlp_fani_init(void) -{ - return ONLP_STATUS_E_UNSUPPORTED; -} diff --git a/packages/platforms/quanta/x86-64/ix7-rglbmc/onlp/builds/x86_64_quanta_ix7_rglbmc/module/src/ledi.c b/packages/platforms/quanta/x86-64/ix7-rglbmc/onlp/builds/x86_64_quanta_ix7_rglbmc/module/src/ledi.c deleted file mode 100644 index 7385dd680..000000000 --- a/packages/platforms/quanta/x86-64/ix7-rglbmc/onlp/builds/x86_64_quanta_ix7_rglbmc/module/src/ledi.c +++ /dev/null @@ -1,78 +0,0 @@ -#include -#include -#include -#include -#include - -#include "x86_64_quanta_ix7_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_IX7_CPU_BOARD_SYS_P1, 0); - onlp_gpio_set(QUANTA_IX7_CPU_BOARD_SYS_P2, 1); - } - else if(mode == ONLP_LED_MODE_ORANGE){ - onlp_gpio_set(QUANTA_IX7_CPU_BOARD_SYS_P1, 1); - onlp_gpio_set(QUANTA_IX7_CPU_BOARD_SYS_P2, 0); - } - else{ - onlp_gpio_set(QUANTA_IX7_CPU_BOARD_SYS_P1, 1); - onlp_gpio_set(QUANTA_IX7_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/ix7-rglbmc/onlp/builds/x86_64_quanta_ix7_rglbmc/module/src/make.mk b/packages/platforms/quanta/x86-64/ix7-rglbmc/onlp/builds/x86_64_quanta_ix7_rglbmc/module/src/make.mk deleted file mode 100644 index 053efbeb3..000000000 --- a/packages/platforms/quanta/x86-64/ix7-rglbmc/onlp/builds/x86_64_quanta_ix7_rglbmc/module/src/make.mk +++ /dev/null @@ -1,9 +0,0 @@ -############################################################################### -# -# -# -############################################################################### - -LIBRARY := x86_64_quanta_ix7_rglbmc -$(LIBRARY)_SUBDIR := $(dir $(lastword $(MAKEFILE_LIST))) -include $(BUILDER)/lib.mk diff --git a/packages/platforms/quanta/x86-64/ix7-rglbmc/onlp/builds/x86_64_quanta_ix7_rglbmc/module/src/psui.c b/packages/platforms/quanta/x86-64/ix7-rglbmc/onlp/builds/x86_64_quanta_ix7_rglbmc/module/src/psui.c deleted file mode 100644 index b5cedce16..000000000 --- a/packages/platforms/quanta/x86-64/ix7-rglbmc/onlp/builds/x86_64_quanta_ix7_rglbmc/module/src/psui.c +++ /dev/null @@ -1,15 +0,0 @@ -/************************************************************ - * - * - ************************************************************ - * - * - * - ***********************************************************/ -#include - -int -onlp_psui_init(void) -{ - return ONLP_STATUS_E_UNSUPPORTED; -} diff --git a/packages/platforms/quanta/x86-64/ix7-rglbmc/onlp/builds/x86_64_quanta_ix7_rglbmc/module/src/sfpi.c b/packages/platforms/quanta/x86-64/ix7-rglbmc/onlp/builds/x86_64_quanta_ix7_rglbmc/module/src/sfpi.c deleted file mode 100644 index 53cc0a96f..000000000 --- a/packages/platforms/quanta/x86-64/ix7-rglbmc/onlp/builds/x86_64_quanta_ix7_rglbmc/module/src/sfpi.c +++ /dev/null @@ -1,257 +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. - * - * - ************************************************************ - * - * SFPI Interface for the Quanta IX7 - * - ***********************************************************/ -#include -#include -#include -#include -#include -#include "x86_64_quanta_ix7_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* port_path; - 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-20/i2c-32/32-0050/%s", 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-20/i2c-33/33-0050/%s", 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-20/i2c-34/34-0050/%s", 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-20/i2c-35/35-0050/%s", 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-20/i2c-36/36-0050/%s", 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-20/i2c-37/37-0050/%s", 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-20/i2c-38/38-0050/%s", 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-20/i2c-39/39-0050/%s", 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-21/i2c-40/40-0050/%s", 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-21/i2c-41/41-0050/%s", 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-21/i2c-42/42-0050/%s", 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-21/i2c-43/43-0050/%s", 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-21/i2c-44/44-0050/%s", 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-21/i2c-45/45-0050/%s", 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-21/i2c-46/46-0050/%s", 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-21/i2c-47/47-0050/%s", NULL }, - { 17, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/17-0038/cpld-qsfp28/port-17/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-22/i2c-48/48-0050/%s", NULL }, - { 18, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/17-0038/cpld-qsfp28/port-18/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-22/i2c-49/49-0050/%s", NULL }, - { 19, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/17-0038/cpld-qsfp28/port-19/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-22/i2c-50/50-0050/%s", NULL }, - { 20, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/17-0038/cpld-qsfp28/port-20/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-22/i2c-51/51-0050/%s", NULL }, - { 21, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/17-0038/cpld-qsfp28/port-21/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-22/i2c-52/52-0050/%s", NULL }, - { 22, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/17-0038/cpld-qsfp28/port-22/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-22/i2c-53/53-0050/%s", NULL }, - { 23, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/17-0038/cpld-qsfp28/port-23/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-22/i2c-54/54-0050/%s", NULL }, - { 24, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/17-0038/cpld-qsfp28/port-24/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-22/i2c-55/55-0050/%s", NULL }, - { 25, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/17-0038/cpld-qsfp28/port-25/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-23/i2c-56/56-0050/%s", NULL }, - { 26, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/17-0038/cpld-qsfp28/port-26/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-23/i2c-57/57-0050/%s", NULL }, - { 27, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/17-0038/cpld-qsfp28/port-27/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-23/i2c-58/58-0050/%s", NULL }, - { 28, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/17-0038/cpld-qsfp28/port-28/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-23/i2c-59/59-0050/%s", NULL }, - { 29, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/17-0038/cpld-qsfp28/port-29/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-23/i2c-60/60-0050/%s", NULL }, - { 30, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/17-0038/cpld-qsfp28/port-30/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-23/i2c-61/61-0050/%s", NULL }, - { 31, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/17-0038/cpld-qsfp28/port-31/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-23/i2c-62/62-0050/%s", NULL }, - { 32, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/17-0038/cpld-qsfp28/port-32/%s", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-23/i2c-63/63-0050/%s", 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_status_path(int port, char *node_name) -{ - sfpmap_t* sfp = SFP_GET(port); - - memset(sfp_node_path, 0x00, MAX_SFP_PATH); - sprintf(sfp_node_path, sfp->present_cpld, - node_name); - return sfp_node_path; -} - -static char* -sfp_get_port_info_path(int port, char *node_name) -{ - sfpmap_t* sfp = SFP_GET(port); - - memset(sfp_node_path, 0x00, MAX_SFP_PATH); - sprintf(sfp_node_path, sfp->port_path, - node_name); - return sfp_node_path; -} - -int -onlp_sfpi_init(void) -{ - int ret; - - onlp_gpio_export(QUANTA_IX7_ZQSFP_EN_GPIO_P3V3_PW_EN, ONLP_GPIO_DIRECTION_OUT); - ret = onlp_gpio_set(QUANTA_IX7_ZQSFP_EN_GPIO_P3V3_PW_EN, 1); - sleep(1); - - return ret; -} - -int -onlp_sfpi_bitmap_get(onlp_sfp_bitmap_t* bmap) -{ - int p, port_name; - - for(p = 1; p < 33; p++) { - if (onlp_file_read_int(&port_name, sfp_get_port_info_path(p, "port_name")) == 0) { - AIM_BITMAP_SET(bmap, port_name); - } - } - - return ONLP_STATUS_OK; -} - -int -onlp_sfpi_is_present(int port) -{ - return onlplib_sfp_is_present_file(sfp_get_port_status_path(port, "module_present"), /* Present */ "1\n", /* Absent */ "0\n"); -} - -int -onlp_sfpi_eeprom_read(int port, uint8_t data[256]) -{ - return onlplib_sfp_eeprom_read_file(sfp_get_port_info_path(port, "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_status_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_status_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_status_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_status_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/ix7-rglbmc/onlp/builds/x86_64_quanta_ix7_rglbmc/module/src/sysi.c b/packages/platforms/quanta/x86-64/ix7-rglbmc/onlp/builds/x86_64_quanta_ix7_rglbmc/module/src/sysi.c deleted file mode 100644 index a6c8e9020..000000000 --- a/packages/platforms/quanta/x86-64/ix7-rglbmc/onlp/builds/x86_64_quanta_ix7_rglbmc/module/src/sysi.c +++ /dev/null @@ -1,66 +0,0 @@ -/************************************************************ - * - * - ************************************************************ - * - * - * - ***********************************************************/ -#include -#include "x86_64_quanta_ix7_rglbmc_int.h" -#include "x86_64_quanta_ix7_rglbmc_log.h" -#include -#include -#include -#include -#include - -const char* -onlp_sysi_platform_get(void) -{ - return "x86-64-quanta-ix7-rglbmc-r0"; -} - -int -onlp_sysi_init(void) -{ - /* Config GPIO */ - /* LED Output */ - onlp_gpio_export(QUANTA_IX7_CPU_BOARD_SYS_P1, ONLP_GPIO_DIRECTION_OUT); - onlp_gpio_export(QUANTA_IX7_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-ix7-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/ix7-rglbmc/onlp/builds/x86_64_quanta_ix7_rglbmc/module/src/thermali.c b/packages/platforms/quanta/x86-64/ix7-rglbmc/onlp/builds/x86_64_quanta_ix7_rglbmc/module/src/thermali.c deleted file mode 100644 index 2a84c0178..000000000 --- a/packages/platforms/quanta/x86-64/ix7-rglbmc/onlp/builds/x86_64_quanta_ix7_rglbmc/module/src/thermali.c +++ /dev/null @@ -1,31 +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 - -int -onlp_thermali_init(void) -{ - return ONLP_STATUS_E_UNSUPPORTED; -} diff --git a/packages/platforms/quanta/x86-64/ix7-rglbmc/onlp/builds/x86_64_quanta_ix7_rglbmc/module/src/x86_64_quanta_ix7_rglbmc_config.c b/packages/platforms/quanta/x86-64/ix7-rglbmc/onlp/builds/x86_64_quanta_ix7_rglbmc/module/src/x86_64_quanta_ix7_rglbmc_config.c deleted file mode 100644 index a9e205907..000000000 --- a/packages/platforms/quanta/x86-64/ix7-rglbmc/onlp/builds/x86_64_quanta_ix7_rglbmc/module/src/x86_64_quanta_ix7_rglbmc_config.c +++ /dev/null @@ -1,95 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#include - -/* */ -#define __x86_64_quanta_ix7_rglbmc_config_STRINGIFY_NAME(_x) #_x -#define __x86_64_quanta_ix7_rglbmc_config_STRINGIFY_VALUE(_x) __x86_64_quanta_ix7_rglbmc_config_STRINGIFY_NAME(_x) -x86_64_quanta_ix7_rglbmc_config_settings_t x86_64_quanta_ix7_rglbmc_config_settings[] = -{ -#ifdef X86_64_QUANTA_IX7_RGLBMC_CONFIG_INCLUDE_LOGGING - { __x86_64_quanta_ix7_rglbmc_config_STRINGIFY_NAME(X86_64_QUANTA_IX7_RGLBMC_CONFIG_INCLUDE_LOGGING), __x86_64_quanta_ix7_rglbmc_config_STRINGIFY_VALUE(X86_64_QUANTA_IX7_RGLBMC_CONFIG_INCLUDE_LOGGING) }, -#else -{ X86_64_QUANTA_IX7_RGLBMC_CONFIG_INCLUDE_LOGGING(__x86_64_quanta_ix7_rglbmc_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_QUANTA_IX7_RGLBMC_CONFIG_LOG_OPTIONS_DEFAULT - { __x86_64_quanta_ix7_rglbmc_config_STRINGIFY_NAME(X86_64_QUANTA_IX7_RGLBMC_CONFIG_LOG_OPTIONS_DEFAULT), __x86_64_quanta_ix7_rglbmc_config_STRINGIFY_VALUE(X86_64_QUANTA_IX7_RGLBMC_CONFIG_LOG_OPTIONS_DEFAULT) }, -#else -{ X86_64_QUANTA_IX7_RGLBMC_CONFIG_LOG_OPTIONS_DEFAULT(__x86_64_quanta_ix7_rglbmc_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_QUANTA_IX7_RGLBMC_CONFIG_LOG_BITS_DEFAULT - { __x86_64_quanta_ix7_rglbmc_config_STRINGIFY_NAME(X86_64_QUANTA_IX7_RGLBMC_CONFIG_LOG_BITS_DEFAULT), __x86_64_quanta_ix7_rglbmc_config_STRINGIFY_VALUE(X86_64_QUANTA_IX7_RGLBMC_CONFIG_LOG_BITS_DEFAULT) }, -#else -{ X86_64_QUANTA_IX7_RGLBMC_CONFIG_LOG_BITS_DEFAULT(__x86_64_quanta_ix7_rglbmc_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_QUANTA_IX7_RGLBMC_CONFIG_LOG_CUSTOM_BITS_DEFAULT - { __x86_64_quanta_ix7_rglbmc_config_STRINGIFY_NAME(X86_64_QUANTA_IX7_RGLBMC_CONFIG_LOG_CUSTOM_BITS_DEFAULT), __x86_64_quanta_ix7_rglbmc_config_STRINGIFY_VALUE(X86_64_QUANTA_IX7_RGLBMC_CONFIG_LOG_CUSTOM_BITS_DEFAULT) }, -#else -{ X86_64_QUANTA_IX7_RGLBMC_CONFIG_LOG_CUSTOM_BITS_DEFAULT(__x86_64_quanta_ix7_rglbmc_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_QUANTA_IX7_RGLBMC_CONFIG_PORTING_STDLIB - { __x86_64_quanta_ix7_rglbmc_config_STRINGIFY_NAME(X86_64_QUANTA_IX7_RGLBMC_CONFIG_PORTING_STDLIB), __x86_64_quanta_ix7_rglbmc_config_STRINGIFY_VALUE(X86_64_QUANTA_IX7_RGLBMC_CONFIG_PORTING_STDLIB) }, -#else -{ X86_64_QUANTA_IX7_RGLBMC_CONFIG_PORTING_STDLIB(__x86_64_quanta_ix7_rglbmc_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_QUANTA_IX7_RGLBMC_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS - { __x86_64_quanta_ix7_rglbmc_config_STRINGIFY_NAME(X86_64_QUANTA_IX7_RGLBMC_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS), __x86_64_quanta_ix7_rglbmc_config_STRINGIFY_VALUE(X86_64_QUANTA_IX7_RGLBMC_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS) }, -#else -{ X86_64_QUANTA_IX7_RGLBMC_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS(__x86_64_quanta_ix7_rglbmc_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_QUANTA_IX7_RGLBMC_CONFIG_INCLUDE_UCLI - { __x86_64_quanta_ix7_rglbmc_config_STRINGIFY_NAME(X86_64_QUANTA_IX7_RGLBMC_CONFIG_INCLUDE_UCLI), __x86_64_quanta_ix7_rglbmc_config_STRINGIFY_VALUE(X86_64_QUANTA_IX7_RGLBMC_CONFIG_INCLUDE_UCLI) }, -#else -{ X86_64_QUANTA_IX7_RGLBMC_CONFIG_INCLUDE_UCLI(__x86_64_quanta_ix7_rglbmc_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_QUANTA_IX7_RGLBMC_CONFIG_SYSFAN_RPM_FAILURE_THRESHOLD - { __x86_64_quanta_ix7_rglbmc_config_STRINGIFY_NAME(X86_64_QUANTA_IX7_RGLBMC_CONFIG_SYSFAN_RPM_FAILURE_THRESHOLD), __x86_64_quanta_ix7_rglbmc_config_STRINGIFY_VALUE(X86_64_QUANTA_IX7_RGLBMC_CONFIG_SYSFAN_RPM_FAILURE_THRESHOLD) }, -#else -{ X86_64_QUANTA_IX7_RGLBMC_CONFIG_SYSFAN_RPM_FAILURE_THRESHOLD(__x86_64_quanta_ix7_rglbmc_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_QUANTA_IX7_RGLBMC_CONFIG_SYSFAN_F2B_RPM_MAX - { __x86_64_quanta_ix7_rglbmc_config_STRINGIFY_NAME(X86_64_QUANTA_IX7_RGLBMC_CONFIG_SYSFAN_F2B_RPM_MAX), __x86_64_quanta_ix7_rglbmc_config_STRINGIFY_VALUE(X86_64_QUANTA_IX7_RGLBMC_CONFIG_SYSFAN_F2B_RPM_MAX) }, -#else -{ X86_64_QUANTA_IX7_RGLBMC_CONFIG_SYSFAN_F2B_RPM_MAX(__x86_64_quanta_ix7_rglbmc_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_QUANTA_IX7_RGLBMC_CONFIG_SYSFAN_B2F_RPM_MAX - { __x86_64_quanta_ix7_rglbmc_config_STRINGIFY_NAME(X86_64_QUANTA_IX7_RGLBMC_CONFIG_SYSFAN_B2F_RPM_MAX), __x86_64_quanta_ix7_rglbmc_config_STRINGIFY_VALUE(X86_64_QUANTA_IX7_RGLBMC_CONFIG_SYSFAN_B2F_RPM_MAX) }, -#else -{ X86_64_QUANTA_IX7_RGLBMC_CONFIG_SYSFAN_B2F_RPM_MAX(__x86_64_quanta_ix7_rglbmc_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_QUANTA_IX7_RGLBMC_CONFIG_PHY_RESET_DELAY_MS - { __x86_64_quanta_ix7_rglbmc_config_STRINGIFY_NAME(X86_64_QUANTA_IX7_RGLBMC_CONFIG_PHY_RESET_DELAY_MS), __x86_64_quanta_ix7_rglbmc_config_STRINGIFY_VALUE(X86_64_QUANTA_IX7_RGLBMC_CONFIG_PHY_RESET_DELAY_MS) }, -#else -{ X86_64_QUANTA_IX7_RGLBMC_CONFIG_PHY_RESET_DELAY_MS(__x86_64_quanta_ix7_rglbmc_config_STRINGIFY_NAME), "__undefined__" }, -#endif - { NULL, NULL } -}; -#undef __x86_64_quanta_ix7_rglbmc_config_STRINGIFY_VALUE -#undef __x86_64_quanta_ix7_rglbmc_config_STRINGIFY_NAME - -const char* -x86_64_quanta_ix7_rglbmc_config_lookup(const char* setting) -{ - int i; - for(i = 0; x86_64_quanta_ix7_rglbmc_config_settings[i].name; i++) { - if(!strcmp(x86_64_quanta_ix7_rglbmc_config_settings[i].name, setting)) { - return x86_64_quanta_ix7_rglbmc_config_settings[i].value; - } - } - return NULL; -} - -int -x86_64_quanta_ix7_rglbmc_config_show(struct aim_pvs_s* pvs) -{ - int i; - for(i = 0; x86_64_quanta_ix7_rglbmc_config_settings[i].name; i++) { - aim_printf(pvs, "%s = %s\n", x86_64_quanta_ix7_rglbmc_config_settings[i].name, x86_64_quanta_ix7_rglbmc_config_settings[i].value); - } - return i; -} - -/* */ diff --git a/packages/platforms/quanta/x86-64/ix7-rglbmc/onlp/builds/x86_64_quanta_ix7_rglbmc/module/src/x86_64_quanta_ix7_rglbmc_enums.c b/packages/platforms/quanta/x86-64/ix7-rglbmc/onlp/builds/x86_64_quanta_ix7_rglbmc/module/src/x86_64_quanta_ix7_rglbmc_enums.c deleted file mode 100644 index 5f67ff26a..000000000 --- a/packages/platforms/quanta/x86-64/ix7-rglbmc/onlp/builds/x86_64_quanta_ix7_rglbmc/module/src/x86_64_quanta_ix7_rglbmc_enums.c +++ /dev/null @@ -1,10 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#include - -/* <--auto.start.enum(ALL).source> */ -/* */ - diff --git a/packages/platforms/quanta/x86-64/ix7-rglbmc/onlp/builds/x86_64_quanta_ix7_rglbmc/module/src/x86_64_quanta_ix7_rglbmc_int.h b/packages/platforms/quanta/x86-64/ix7-rglbmc/onlp/builds/x86_64_quanta_ix7_rglbmc/module/src/x86_64_quanta_ix7_rglbmc_int.h deleted file mode 100644 index 7ff0b7357..000000000 --- a/packages/platforms/quanta/x86-64/ix7-rglbmc/onlp/builds/x86_64_quanta_ix7_rglbmc/module/src/x86_64_quanta_ix7_rglbmc_int.h +++ /dev/null @@ -1,281 +0,0 @@ -/**************************************************************************//** - * - * x86_64_quanta_ix7_rglbmc Internal Header - * - *****************************************************************************/ -#ifndef __X86_64_QUANTA_IX7_RGLBMC_INT_H__ -#define __X86_64_QUANTA_IX7_RGLBMC_INT_H__ - -#include -#include - -/* */ -/** 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[]; - -/** 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 { - 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[]; - -/** 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 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_IX7_RGLBMC_INT_H__ */ diff --git a/packages/platforms/quanta/x86-64/ix7-rglbmc/onlp/builds/x86_64_quanta_ix7_rglbmc/module/src/x86_64_quanta_ix7_rglbmc_log.c b/packages/platforms/quanta/x86-64/ix7-rglbmc/onlp/builds/x86_64_quanta_ix7_rglbmc/module/src/x86_64_quanta_ix7_rglbmc_log.c deleted file mode 100644 index 672c07413..000000000 --- a/packages/platforms/quanta/x86-64/ix7-rglbmc/onlp/builds/x86_64_quanta_ix7_rglbmc/module/src/x86_64_quanta_ix7_rglbmc_log.c +++ /dev/null @@ -1,18 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#include - -#include "x86_64_quanta_ix7_rglbmc_log.h" -/* - * x86_64_quanta_ix7_rglbmc log struct. - */ -AIM_LOG_STRUCT_DEFINE( - X86_64_QUANTA_IX7_RGLBMC_CONFIG_LOG_OPTIONS_DEFAULT, - X86_64_QUANTA_IX7_RGLBMC_CONFIG_LOG_BITS_DEFAULT, - NULL, /* Custom log map */ - X86_64_QUANTA_IX7_RGLBMC_CONFIG_LOG_CUSTOM_BITS_DEFAULT - ); - diff --git a/packages/platforms/quanta/x86-64/ix7-rglbmc/onlp/builds/x86_64_quanta_ix7_rglbmc/module/src/x86_64_quanta_ix7_rglbmc_log.h b/packages/platforms/quanta/x86-64/ix7-rglbmc/onlp/builds/x86_64_quanta_ix7_rglbmc/module/src/x86_64_quanta_ix7_rglbmc_log.h deleted file mode 100644 index 87d0af1f9..000000000 --- a/packages/platforms/quanta/x86-64/ix7-rglbmc/onlp/builds/x86_64_quanta_ix7_rglbmc/module/src/x86_64_quanta_ix7_rglbmc_log.h +++ /dev/null @@ -1,12 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#ifndef __X86_64_QUANTA_IX7_RGLBMC_LOG_H__ -#define __X86_64_QUANTA_IX7_RGLBMC_LOG_H__ - -#define AIM_LOG_MODULE_NAME x86_64_quanta_ix7_rglbmc -#include - -#endif /* __X86_64_QUANTA_IX7_RGLBMC_LOG_H__ */ diff --git a/packages/platforms/quanta/x86-64/ix7-rglbmc/onlp/builds/x86_64_quanta_ix7_rglbmc/module/src/x86_64_quanta_ix7_rglbmc_module.c b/packages/platforms/quanta/x86-64/ix7-rglbmc/onlp/builds/x86_64_quanta_ix7_rglbmc/module/src/x86_64_quanta_ix7_rglbmc_module.c deleted file mode 100644 index 03d49c159..000000000 --- a/packages/platforms/quanta/x86-64/ix7-rglbmc/onlp/builds/x86_64_quanta_ix7_rglbmc/module/src/x86_64_quanta_ix7_rglbmc_module.c +++ /dev/null @@ -1,24 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#include - -#include "x86_64_quanta_ix7_rglbmc_log.h" - -static int -datatypes_init__(void) -{ -#define X86_64_QUANTA_IX7_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_ix7_rglbmc_module_init__(void) -{ - AIM_LOG_STRUCT_REGISTER(); - datatypes_init__(); -} - -int __onlp_platform_version__ = 1; diff --git a/packages/platforms/quanta/x86-64/ix7-rglbmc/onlp/builds/x86_64_quanta_ix7_rglbmc/module/src/x86_64_quanta_ix7_rglbmc_ucli.c b/packages/platforms/quanta/x86-64/ix7-rglbmc/onlp/builds/x86_64_quanta_ix7_rglbmc/module/src/x86_64_quanta_ix7_rglbmc_ucli.c deleted file mode 100644 index 8aa3b6bc0..000000000 --- a/packages/platforms/quanta/x86-64/ix7-rglbmc/onlp/builds/x86_64_quanta_ix7_rglbmc/module/src/x86_64_quanta_ix7_rglbmc_ucli.c +++ /dev/null @@ -1,50 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#include - -#if X86_64_QUANTA_IX7_RGLBMC_CONFIG_INCLUDE_UCLI == 1 - -#include -#include -#include - -static ucli_status_t -x86_64_quanta_ix7_rglbmc_ucli_ucli__config__(ucli_context_t* uc) -{ - UCLI_HANDLER_MACRO_MODULE_CONFIG(x86_64_quanta_ix7_rglbmc) -} - -/* */ -/* */ - -static ucli_module_t -x86_64_quanta_ix7_rglbmc_ucli_module__ = - { - "x86_64_quanta_ix7_rglbmc_ucli", - NULL, - x86_64_quanta_ix7_rglbmc_ucli_ucli_handlers__, - NULL, - NULL, - }; - -ucli_node_t* -x86_64_quanta_ix7_rglbmc_ucli_node_create(void) -{ - ucli_node_t* n; - ucli_module_init(&x86_64_quanta_ix7_rglbmc_ucli_module__); - n = ucli_node_create("x86_64_quanta_ix7_rglbmc", NULL, &x86_64_quanta_ix7_rglbmc_ucli_module__); - ucli_node_subnode_add(n, ucli_module_log_node_create("x86_64_quanta_ix7_rglbmc")); - return n; -} - -#else -void* -x86_64_quanta_ix7_rglbmc_ucli_node_create(void) -{ - return NULL; -} -#endif - diff --git a/packages/platforms/quanta/x86-64/ix7-rglbmc/platform-config/Makefile b/packages/platforms/quanta/x86-64/ix7-rglbmc/platform-config/Makefile deleted file mode 100644 index 003238cf6..000000000 --- a/packages/platforms/quanta/x86-64/ix7-rglbmc/platform-config/Makefile +++ /dev/null @@ -1 +0,0 @@ -include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/quanta/x86-64/ix7-rglbmc/platform-config/r0/Makefile b/packages/platforms/quanta/x86-64/ix7-rglbmc/platform-config/r0/Makefile deleted file mode 100644 index 003238cf6..000000000 --- a/packages/platforms/quanta/x86-64/ix7-rglbmc/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/quanta/x86-64/ix7-rglbmc/platform-config/r0/PKG.yml b/packages/platforms/quanta/x86-64/ix7-rglbmc/platform-config/r0/PKG.yml deleted file mode 100644 index 0c770340f..000000000 --- a/packages/platforms/quanta/x86-64/ix7-rglbmc/platform-config/r0/PKG.yml +++ /dev/null @@ -1 +0,0 @@ -!include $ONL_TEMPLATES/platform-config-platform.yml ARCH=amd64 VENDOR=quanta BASENAME=x86-64-quanta-ix7-rglbmc REVISION=r0 diff --git a/packages/platforms/quanta/x86-64/ix7-rglbmc/platform-config/r0/src/lib/x86-64-quanta-ix7-rglbmc-r0.yml b/packages/platforms/quanta/x86-64/ix7-rglbmc/platform-config/r0/src/lib/x86-64-quanta-ix7-rglbmc-r0.yml deleted file mode 100644 index 911273100..000000000 --- a/packages/platforms/quanta/x86-64/ix7-rglbmc/platform-config/r0/src/lib/x86-64-quanta-ix7-rglbmc-r0.yml +++ /dev/null @@ -1,31 +0,0 @@ ---- - -###################################################################### -# -# platform-config for IX7 -# -###################################################################### - -x86-64-quanta-ix7-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/ix7-rglbmc/platform-config/r0/src/python/x86_64_quanta_ix7_rglbmc_r0/__init__.py b/packages/platforms/quanta/x86-64/ix7-rglbmc/platform-config/r0/src/python/x86_64_quanta_ix7_rglbmc_r0/__init__.py deleted file mode 100644 index 53440d9d8..000000000 --- a/packages/platforms/quanta/x86-64/ix7-rglbmc/platform-config/r0/src/python/x86_64_quanta_ix7_rglbmc_r0/__init__.py +++ /dev/null @@ -1,28 +0,0 @@ -from onl.platform.base import * -from onl.platform.quanta import * - -class OnlPlatform_x86_64_quanta_ix7_rglbmc_r0(OnlPlatformQuanta, - OnlPlatformPortConfig_32x100): - PLATFORM='x86-64-quanta-ix7-rglbmc-r0' - MODEL="IX7" - """ 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.3700" - - def baseconfig(self): - self.insmod("optoe") - self.insmod("qci_cpld") - self.insmod("qci_cpld_led") - self.insmod("quanta_platform_ix7") - - for port_number in range(1,33): - bus_number = port_number + 31 - os.system("echo %d >/sys/bus/i2c/devices/%d-0050/port_name" % (port_number, bus_number)) - - return True diff --git a/packages/platforms/quanta/x86-64/ix8-rglbmc/.gitignore b/packages/platforms/quanta/x86-64/ix8-rglbmc/.gitignore deleted file mode 100644 index d5614b88b..000000000 --- a/packages/platforms/quanta/x86-64/ix8-rglbmc/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -*x86*64*quanta*ix8*rglbmc.mk -onlpdump.mk diff --git a/packages/platforms/quanta/x86-64/ix8-rglbmc/Makefile b/packages/platforms/quanta/x86-64/ix8-rglbmc/Makefile deleted file mode 100644 index 003238cf6..000000000 --- a/packages/platforms/quanta/x86-64/ix8-rglbmc/Makefile +++ /dev/null @@ -1 +0,0 @@ -include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/quanta/x86-64/ix8-rglbmc/modules/Makefile b/packages/platforms/quanta/x86-64/ix8-rglbmc/modules/Makefile deleted file mode 100644 index 003238cf6..000000000 --- a/packages/platforms/quanta/x86-64/ix8-rglbmc/modules/Makefile +++ /dev/null @@ -1 +0,0 @@ -include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/quanta/x86-64/ix8-rglbmc/modules/PKG.yml b/packages/platforms/quanta/x86-64/ix8-rglbmc/modules/PKG.yml deleted file mode 100644 index 9b4098f32..000000000 --- a/packages/platforms/quanta/x86-64/ix8-rglbmc/modules/PKG.yml +++ /dev/null @@ -1 +0,0 @@ -!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/ix8-rglbmc/modules/builds/.gitignore b/packages/platforms/quanta/x86-64/ix8-rglbmc/modules/builds/.gitignore deleted file mode 100644 index a65b41774..000000000 --- a/packages/platforms/quanta/x86-64/ix8-rglbmc/modules/builds/.gitignore +++ /dev/null @@ -1 +0,0 @@ -lib diff --git a/packages/platforms/quanta/x86-64/ix8-rglbmc/modules/builds/Makefile b/packages/platforms/quanta/x86-64/ix8-rglbmc/modules/builds/Makefile deleted file mode 100644 index 29395ebb1..000000000 --- a/packages/platforms/quanta/x86-64/ix8-rglbmc/modules/builds/Makefile +++ /dev/null @@ -1,6 +0,0 @@ -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/ix8-rglbmc/modules/builds/qci_platform_ix8.c b/packages/platforms/quanta/x86-64/ix8-rglbmc/modules/builds/qci_platform_ix8.c deleted file mode 100644 index ff862c333..000000000 --- a/packages/platforms/quanta/x86-64/ix8-rglbmc/modules/builds/qci_platform_ix8.c +++ /dev/null @@ -1,421 +0,0 @@ -/* - * 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 = 0x48, -}; -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("optoe1", 0x50), // 15 0x50 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, - }, - { - I2C_BOARD_INFO("CPLDLED_IX8", 0x3a), // 18 0x72 ch0 CPLD4 LED function of SFP28 & QSFP28 (Port27~56) - }, - { - I2C_BOARD_INFO("CPLDLED_IX8", 0x39), // 19 0x72 ch0 CPLD6 LED function of SFP28 & QSFP28 (Port1~26) - }, - { - I2C_BOARD_INFO("optoe2", 0x50), // 20 0x50 SFP EEPROM - }, -}; - -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 - client = i2c_new_device(adapter, &ix8_i2c_devices[18]); // CPLD_4 - client = i2c_new_device(adapter, &ix8_i2c_devices[19]); // CPLD_6 - 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); - - if (i < 80) { - client = i2c_new_device(adapter, &ix8_i2c_devices[20]); - } - else { - 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/ix8-rglbmc/onlp/Makefile b/packages/platforms/quanta/x86-64/ix8-rglbmc/onlp/Makefile deleted file mode 100644 index 003238cf6..000000000 --- a/packages/platforms/quanta/x86-64/ix8-rglbmc/onlp/Makefile +++ /dev/null @@ -1 +0,0 @@ -include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/quanta/x86-64/ix8-rglbmc/onlp/PKG.yml b/packages/platforms/quanta/x86-64/ix8-rglbmc/onlp/PKG.yml deleted file mode 100644 index 4d7ca269d..000000000 --- a/packages/platforms/quanta/x86-64/ix8-rglbmc/onlp/PKG.yml +++ /dev/null @@ -1 +0,0 @@ -!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/ix8-rglbmc/onlp/builds/Makefile b/packages/platforms/quanta/x86-64/ix8-rglbmc/onlp/builds/Makefile deleted file mode 100644 index e7437cb23..000000000 --- a/packages/platforms/quanta/x86-64/ix8-rglbmc/onlp/builds/Makefile +++ /dev/null @@ -1,2 +0,0 @@ -FILTER=src -include $(ONL)/make/subdirs.mk diff --git a/packages/platforms/quanta/x86-64/ix8-rglbmc/onlp/builds/lib/Makefile b/packages/platforms/quanta/x86-64/ix8-rglbmc/onlp/builds/lib/Makefile deleted file mode 100644 index aba890572..000000000 --- a/packages/platforms/quanta/x86-64/ix8-rglbmc/onlp/builds/lib/Makefile +++ /dev/null @@ -1,3 +0,0 @@ -PLATFORM := x86-64-quanta-ix8-rglbmc -EXTRA_MODULES := quanta_sys_eeprom -include $(ONL)/packages/base/any/onlp/builds/platform/libonlp-platform.mk diff --git a/packages/platforms/quanta/x86-64/ix8-rglbmc/onlp/builds/onlpdump/Makefile b/packages/platforms/quanta/x86-64/ix8-rglbmc/onlp/builds/onlpdump/Makefile deleted file mode 100644 index b3695fbca..000000000 --- a/packages/platforms/quanta/x86-64/ix8-rglbmc/onlp/builds/onlpdump/Makefile +++ /dev/null @@ -1,3 +0,0 @@ -PLATFORM := x86-64-quanta-ix8-rglbmc -EXTRA_MODULES := quanta_sys_eeprom -include $(ONL)/packages/base/any/onlp/builds/platform/onlps.mk diff --git a/packages/platforms/quanta/x86-64/ix8-rglbmc/onlp/builds/x86_64_quanta_ix8_rglbmc/.gitignore b/packages/platforms/quanta/x86-64/ix8-rglbmc/onlp/builds/x86_64_quanta_ix8_rglbmc/.gitignore deleted file mode 100644 index c81d16be3..000000000 --- a/packages/platforms/quanta/x86-64/ix8-rglbmc/onlp/builds/x86_64_quanta_ix8_rglbmc/.gitignore +++ /dev/null @@ -1 +0,0 @@ -*.mk diff --git a/packages/platforms/quanta/x86-64/ix8-rglbmc/onlp/builds/x86_64_quanta_ix8_rglbmc/.module b/packages/platforms/quanta/x86-64/ix8-rglbmc/onlp/builds/x86_64_quanta_ix8_rglbmc/.module deleted file mode 100644 index 162aede1e..000000000 --- a/packages/platforms/quanta/x86-64/ix8-rglbmc/onlp/builds/x86_64_quanta_ix8_rglbmc/.module +++ /dev/null @@ -1 +0,0 @@ -name: x86_64_quanta_ix8_rglbmc diff --git a/packages/platforms/quanta/x86-64/ix8-rglbmc/onlp/builds/x86_64_quanta_ix8_rglbmc/Makefile b/packages/platforms/quanta/x86-64/ix8-rglbmc/onlp/builds/x86_64_quanta_ix8_rglbmc/Makefile deleted file mode 100644 index 032c31da7..000000000 --- a/packages/platforms/quanta/x86-64/ix8-rglbmc/onlp/builds/x86_64_quanta_ix8_rglbmc/Makefile +++ /dev/null @@ -1,9 +0,0 @@ -############################################################################### -# -# -# -############################################################################### -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/ix8-rglbmc/onlp/builds/x86_64_quanta_ix8_rglbmc/module/auto/make.mk b/packages/platforms/quanta/x86-64/ix8-rglbmc/onlp/builds/x86_64_quanta_ix8_rglbmc/module/auto/make.mk deleted file mode 100644 index 11cb2a9fa..000000000 --- a/packages/platforms/quanta/x86-64/ix8-rglbmc/onlp/builds/x86_64_quanta_ix8_rglbmc/module/auto/make.mk +++ /dev/null @@ -1,9 +0,0 @@ -############################################################################### -# -# 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/ix8-rglbmc/onlp/builds/x86_64_quanta_ix8_rglbmc/module/auto/x86_64_quanta_ix8_rglbmc.yml b/packages/platforms/quanta/x86-64/ix8-rglbmc/onlp/builds/x86_64_quanta_ix8_rglbmc/module/auto/x86_64_quanta_ix8_rglbmc.yml deleted file mode 100644 index 646881892..000000000 --- a/packages/platforms/quanta/x86-64/ix8-rglbmc/onlp/builds/x86_64_quanta_ix8_rglbmc/module/auto/x86_64_quanta_ix8_rglbmc.yml +++ /dev/null @@ -1,134 +0,0 @@ -############################################################################### -# -# 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 - - - vsnprintf - - snprintf - - strlen diff --git a/packages/platforms/quanta/x86-64/ix8-rglbmc/onlp/builds/x86_64_quanta_ix8_rglbmc/module/inc/x86_64_quanta_ix8_rglbmc/x86_64_quanta_ix8_rglbmc.x b/packages/platforms/quanta/x86-64/ix8-rglbmc/onlp/builds/x86_64_quanta_ix8_rglbmc/module/inc/x86_64_quanta_ix8_rglbmc/x86_64_quanta_ix8_rglbmc.x deleted file mode 100644 index 183f8c661..000000000 --- a/packages/platforms/quanta/x86-64/ix8-rglbmc/onlp/builds/x86_64_quanta_ix8_rglbmc/module/inc/x86_64_quanta_ix8_rglbmc/x86_64_quanta_ix8_rglbmc.x +++ /dev/null @@ -1,14 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#include - -/* <--auto.start.xmacro(ALL).define> */ -/* */ - -/* <--auto.start.xenum(ALL).define> */ -/* */ - - diff --git a/packages/platforms/quanta/x86-64/ix8-rglbmc/onlp/builds/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/ix8-rglbmc/onlp/builds/x86_64_quanta_ix8_rglbmc/module/inc/x86_64_quanta_ix8_rglbmc/x86_64_quanta_ix8_rglbmc_config.h deleted file mode 100644 index 6f4439d92..000000000 --- a/packages/platforms/quanta/x86-64/ix8-rglbmc/onlp/builds/x86_64_quanta_ix8_rglbmc/module/inc/x86_64_quanta_ix8_rglbmc/x86_64_quanta_ix8_rglbmc_config.h +++ /dev/null @@ -1,167 +0,0 @@ -/**************************************************************************//** - * - * @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/ix8-rglbmc/onlp/builds/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/ix8-rglbmc/onlp/builds/x86_64_quanta_ix8_rglbmc/module/inc/x86_64_quanta_ix8_rglbmc/x86_64_quanta_ix8_rglbmc_dox.h deleted file mode 100644 index 4fbdd451f..000000000 --- a/packages/platforms/quanta/x86-64/ix8-rglbmc/onlp/builds/x86_64_quanta_ix8_rglbmc/module/inc/x86_64_quanta_ix8_rglbmc/x86_64_quanta_ix8_rglbmc_dox.h +++ /dev/null @@ -1,26 +0,0 @@ -/**************************************************************************//** - * - * 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/ix8-rglbmc/onlp/builds/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/ix8-rglbmc/onlp/builds/x86_64_quanta_ix8_rglbmc/module/inc/x86_64_quanta_ix8_rglbmc/x86_64_quanta_ix8_rglbmc_gpio_table.h deleted file mode 100644 index 45892906f..000000000 --- a/packages/platforms/quanta/x86-64/ix8-rglbmc/onlp/builds/x86_64_quanta_ix8_rglbmc/module/inc/x86_64_quanta_ix8_rglbmc/x86_64_quanta_ix8_rglbmc_gpio_table.h +++ /dev/null @@ -1,51 +0,0 @@ -#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 0x48 - -#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/ix8-rglbmc/onlp/builds/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/ix8-rglbmc/onlp/builds/x86_64_quanta_ix8_rglbmc/module/inc/x86_64_quanta_ix8_rglbmc/x86_64_quanta_ix8_rglbmc_porting.h deleted file mode 100644 index 3494316e4..000000000 --- a/packages/platforms/quanta/x86-64/ix8-rglbmc/onlp/builds/x86_64_quanta_ix8_rglbmc/module/inc/x86_64_quanta_ix8_rglbmc/x86_64_quanta_ix8_rglbmc_porting.h +++ /dev/null @@ -1,77 +0,0 @@ -/**************************************************************************//** - * - * @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_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/ix8-rglbmc/onlp/builds/x86_64_quanta_ix8_rglbmc/module/make.mk b/packages/platforms/quanta/x86-64/ix8-rglbmc/onlp/builds/x86_64_quanta_ix8_rglbmc/module/make.mk deleted file mode 100644 index f60f0421f..000000000 --- a/packages/platforms/quanta/x86-64/ix8-rglbmc/onlp/builds/x86_64_quanta_ix8_rglbmc/module/make.mk +++ /dev/null @@ -1,10 +0,0 @@ -############################################################################### -# -# -# -############################################################################### -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/ix8-rglbmc/onlp/builds/x86_64_quanta_ix8_rglbmc/module/src/Makefile b/packages/platforms/quanta/x86-64/ix8-rglbmc/onlp/builds/x86_64_quanta_ix8_rglbmc/module/src/Makefile deleted file mode 100644 index 66798ec34..000000000 --- a/packages/platforms/quanta/x86-64/ix8-rglbmc/onlp/builds/x86_64_quanta_ix8_rglbmc/module/src/Makefile +++ /dev/null @@ -1,9 +0,0 @@ -############################################################################### -# -# Local source generation targets. -# -############################################################################### - -ucli: - @../../../../tools/uclihandlers.py x86_64_quanta_ix8_rglbmc_ucli.c - diff --git a/packages/platforms/quanta/x86-64/ix8-rglbmc/onlp/builds/x86_64_quanta_ix8_rglbmc/module/src/fani.c b/packages/platforms/quanta/x86-64/ix8-rglbmc/onlp/builds/x86_64_quanta_ix8_rglbmc/module/src/fani.c deleted file mode 100644 index 7594b0ca0..000000000 --- a/packages/platforms/quanta/x86-64/ix8-rglbmc/onlp/builds/x86_64_quanta_ix8_rglbmc/module/src/fani.c +++ /dev/null @@ -1,31 +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 - -int -onlp_fani_init(void) -{ - return ONLP_STATUS_E_UNSUPPORTED; -} diff --git a/packages/platforms/quanta/x86-64/ix8-rglbmc/onlp/builds/x86_64_quanta_ix8_rglbmc/module/src/ledi.c b/packages/platforms/quanta/x86-64/ix8-rglbmc/onlp/builds/x86_64_quanta_ix8_rglbmc/module/src/ledi.c deleted file mode 100644 index d88abc980..000000000 --- a/packages/platforms/quanta/x86-64/ix8-rglbmc/onlp/builds/x86_64_quanta_ix8_rglbmc/module/src/ledi.c +++ /dev/null @@ -1,78 +0,0 @@ -#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/ix8-rglbmc/onlp/builds/x86_64_quanta_ix8_rglbmc/module/src/make.mk b/packages/platforms/quanta/x86-64/ix8-rglbmc/onlp/builds/x86_64_quanta_ix8_rglbmc/module/src/make.mk deleted file mode 100644 index f915b63d8..000000000 --- a/packages/platforms/quanta/x86-64/ix8-rglbmc/onlp/builds/x86_64_quanta_ix8_rglbmc/module/src/make.mk +++ /dev/null @@ -1,9 +0,0 @@ -############################################################################### -# -# -# -############################################################################### - -LIBRARY := x86_64_quanta_ix8_rglbmc -$(LIBRARY)_SUBDIR := $(dir $(lastword $(MAKEFILE_LIST))) -include $(BUILDER)/lib.mk diff --git a/packages/platforms/quanta/x86-64/ix8-rglbmc/onlp/builds/x86_64_quanta_ix8_rglbmc/module/src/psui.c b/packages/platforms/quanta/x86-64/ix8-rglbmc/onlp/builds/x86_64_quanta_ix8_rglbmc/module/src/psui.c deleted file mode 100644 index b5cedce16..000000000 --- a/packages/platforms/quanta/x86-64/ix8-rglbmc/onlp/builds/x86_64_quanta_ix8_rglbmc/module/src/psui.c +++ /dev/null @@ -1,15 +0,0 @@ -/************************************************************ - * - * - ************************************************************ - * - * - * - ***********************************************************/ -#include - -int -onlp_psui_init(void) -{ - return ONLP_STATUS_E_UNSUPPORTED; -} diff --git a/packages/platforms/quanta/x86-64/ix8-rglbmc/onlp/builds/x86_64_quanta_ix8_rglbmc/module/src/sfpi.c b/packages/platforms/quanta/x86-64/ix8-rglbmc/onlp/builds/x86_64_quanta_ix8_rglbmc/module/src/sfpi.c deleted file mode 100644 index 328bf4575..000000000 --- a/packages/platforms/quanta/x86-64/ix8-rglbmc/onlp/builds/x86_64_quanta_ix8_rglbmc/module/src/sfpi.c +++ /dev/null @@ -1,426 +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. - * - * - ************************************************************ - * - * 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* port_path; - 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/%s", 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/%s", 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/%s", 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/%s", 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/%s", 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/%s", 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/%s", 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/%s", 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/%s", 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/%s", 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/%s", 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/%s", 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/%s", 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/%s", 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/%s", 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/%s", 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/%s", 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/%s", 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/%s", 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/%s", 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/%s", 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/%s", 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/%s", 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/%s", 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/%s", 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/%s", 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/%s", 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/%s", 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/%s", 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/%s", 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/%s", 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/%s", 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/%s", 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/%s", 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/%s", 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/%s", 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/%s", 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/%s", 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/%s", 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/%s", 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/%s", 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/%s", 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/%s", 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/%s", 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/%s", 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/%s", 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/%s", 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/%s", NULL }, - }; - -typedef struct qsfpmap_s { - int port; - int present_gpio; - int reset_gpio; - int lplmod_gpio; - const char* port_path; - 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/%s", 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/%s", 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/%s", 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/%s", 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/%s", 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/%s", 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/%s", 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/%s", 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_status_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; -} - -static char* -sfp_get_port_info_path(int port, char *node_name) -{ - memset(sfp_node_path, 0x00, MAX_SFP_PATH); - if(port > 48){ - qsfpmap_t* qsfp = QSFP_GET(port); - sprintf(sfp_node_path, qsfp->port_path, - node_name); - } - else{ - sfpmap_t* sfp = SFP_GET(port); - sprintf(sfp_node_path, sfp->port_path, - 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, port_name; - - for(p = 1; p < 57; p++) { - if (onlp_file_read_int(&port_name, sfp_get_port_info_path(p, "port_name")) == 0) { - AIM_BITMAP_SET(bmap, port_name); - } - } - - 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(sfp_get_port_info_path(port, "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_status_path(port, "pre_n"), /* Present */ "1\n", /* Absent */ "0\n"); - } -} - -int -onlp_sfpi_eeprom_read(int port, uint8_t data[256]) -{ - return onlplib_sfp_eeprom_read_file(sfp_get_port_info_path(port, "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_status_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_status_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_status_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_status_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/ix8-rglbmc/onlp/builds/x86_64_quanta_ix8_rglbmc/module/src/sysi.c b/packages/platforms/quanta/x86-64/ix8-rglbmc/onlp/builds/x86_64_quanta_ix8_rglbmc/module/src/sysi.c deleted file mode 100644 index 81b54da51..000000000 --- a/packages/platforms/quanta/x86-64/ix8-rglbmc/onlp/builds/x86_64_quanta_ix8_rglbmc/module/src/sysi.c +++ /dev/null @@ -1,66 +0,0 @@ -/************************************************************ - * - * - ************************************************************ - * - * - * - ***********************************************************/ -#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/ix8-rglbmc/onlp/builds/x86_64_quanta_ix8_rglbmc/module/src/thermali.c b/packages/platforms/quanta/x86-64/ix8-rglbmc/onlp/builds/x86_64_quanta_ix8_rglbmc/module/src/thermali.c deleted file mode 100644 index 2a84c0178..000000000 --- a/packages/platforms/quanta/x86-64/ix8-rglbmc/onlp/builds/x86_64_quanta_ix8_rglbmc/module/src/thermali.c +++ /dev/null @@ -1,31 +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 - -int -onlp_thermali_init(void) -{ - return ONLP_STATUS_E_UNSUPPORTED; -} diff --git a/packages/platforms/quanta/x86-64/ix8-rglbmc/onlp/builds/x86_64_quanta_ix8_rglbmc/module/src/x86_64_quanta_ix8_rglbmc_config.c b/packages/platforms/quanta/x86-64/ix8-rglbmc/onlp/builds/x86_64_quanta_ix8_rglbmc/module/src/x86_64_quanta_ix8_rglbmc_config.c deleted file mode 100644 index 4beb57c88..000000000 --- a/packages/platforms/quanta/x86-64/ix8-rglbmc/onlp/builds/x86_64_quanta_ix8_rglbmc/module/src/x86_64_quanta_ix8_rglbmc_config.c +++ /dev/null @@ -1,95 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#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/ix8-rglbmc/onlp/builds/x86_64_quanta_ix8_rglbmc/module/src/x86_64_quanta_ix8_rglbmc_enums.c b/packages/platforms/quanta/x86-64/ix8-rglbmc/onlp/builds/x86_64_quanta_ix8_rglbmc/module/src/x86_64_quanta_ix8_rglbmc_enums.c deleted file mode 100644 index 947764e7a..000000000 --- a/packages/platforms/quanta/x86-64/ix8-rglbmc/onlp/builds/x86_64_quanta_ix8_rglbmc/module/src/x86_64_quanta_ix8_rglbmc_enums.c +++ /dev/null @@ -1,10 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#include - -/* <--auto.start.enum(ALL).source> */ -/* */ - diff --git a/packages/platforms/quanta/x86-64/ix8-rglbmc/onlp/builds/x86_64_quanta_ix8_rglbmc/module/src/x86_64_quanta_ix8_rglbmc_int.h b/packages/platforms/quanta/x86-64/ix8-rglbmc/onlp/builds/x86_64_quanta_ix8_rglbmc/module/src/x86_64_quanta_ix8_rglbmc_int.h deleted file mode 100644 index 98593b9d7..000000000 --- a/packages/platforms/quanta/x86-64/ix8-rglbmc/onlp/builds/x86_64_quanta_ix8_rglbmc/module/src/x86_64_quanta_ix8_rglbmc_int.h +++ /dev/null @@ -1,281 +0,0 @@ -/**************************************************************************//** - * - * 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 - -/* */ -/** 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[]; - -/** 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 { - 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[]; - -/** 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 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/ix8-rglbmc/onlp/builds/x86_64_quanta_ix8_rglbmc/module/src/x86_64_quanta_ix8_rglbmc_log.c b/packages/platforms/quanta/x86-64/ix8-rglbmc/onlp/builds/x86_64_quanta_ix8_rglbmc/module/src/x86_64_quanta_ix8_rglbmc_log.c deleted file mode 100644 index ba2b3cf8a..000000000 --- a/packages/platforms/quanta/x86-64/ix8-rglbmc/onlp/builds/x86_64_quanta_ix8_rglbmc/module/src/x86_64_quanta_ix8_rglbmc_log.c +++ /dev/null @@ -1,18 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#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/ix8-rglbmc/onlp/builds/x86_64_quanta_ix8_rglbmc/module/src/x86_64_quanta_ix8_rglbmc_log.h b/packages/platforms/quanta/x86-64/ix8-rglbmc/onlp/builds/x86_64_quanta_ix8_rglbmc/module/src/x86_64_quanta_ix8_rglbmc_log.h deleted file mode 100644 index d69cac1e6..000000000 --- a/packages/platforms/quanta/x86-64/ix8-rglbmc/onlp/builds/x86_64_quanta_ix8_rglbmc/module/src/x86_64_quanta_ix8_rglbmc_log.h +++ /dev/null @@ -1,12 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#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/ix8-rglbmc/onlp/builds/x86_64_quanta_ix8_rglbmc/module/src/x86_64_quanta_ix8_rglbmc_module.c b/packages/platforms/quanta/x86-64/ix8-rglbmc/onlp/builds/x86_64_quanta_ix8_rglbmc/module/src/x86_64_quanta_ix8_rglbmc_module.c deleted file mode 100644 index d388ea9c9..000000000 --- a/packages/platforms/quanta/x86-64/ix8-rglbmc/onlp/builds/x86_64_quanta_ix8_rglbmc/module/src/x86_64_quanta_ix8_rglbmc_module.c +++ /dev/null @@ -1,24 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#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/ix8-rglbmc/onlp/builds/x86_64_quanta_ix8_rglbmc/module/src/x86_64_quanta_ix8_rglbmc_ucli.c b/packages/platforms/quanta/x86-64/ix8-rglbmc/onlp/builds/x86_64_quanta_ix8_rglbmc/module/src/x86_64_quanta_ix8_rglbmc_ucli.c deleted file mode 100644 index ee7936109..000000000 --- a/packages/platforms/quanta/x86-64/ix8-rglbmc/onlp/builds/x86_64_quanta_ix8_rglbmc/module/src/x86_64_quanta_ix8_rglbmc_ucli.c +++ /dev/null @@ -1,50 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#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/ix8-rglbmc/platform-config/Makefile b/packages/platforms/quanta/x86-64/ix8-rglbmc/platform-config/Makefile deleted file mode 100644 index 003238cf6..000000000 --- a/packages/platforms/quanta/x86-64/ix8-rglbmc/platform-config/Makefile +++ /dev/null @@ -1 +0,0 @@ -include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/quanta/x86-64/ix8-rglbmc/platform-config/r0/Makefile b/packages/platforms/quanta/x86-64/ix8-rglbmc/platform-config/r0/Makefile deleted file mode 100644 index 003238cf6..000000000 --- a/packages/platforms/quanta/x86-64/ix8-rglbmc/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/quanta/x86-64/ix8-rglbmc/platform-config/r0/PKG.yml b/packages/platforms/quanta/x86-64/ix8-rglbmc/platform-config/r0/PKG.yml deleted file mode 100644 index d3eb18180..000000000 --- a/packages/platforms/quanta/x86-64/ix8-rglbmc/platform-config/r0/PKG.yml +++ /dev/null @@ -1 +0,0 @@ -!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/ix8-rglbmc/platform-config/r0/src/lib/x86-64-quanta-ix8-rglbmc-r0.yml b/packages/platforms/quanta/x86-64/ix8-rglbmc/platform-config/r0/src/lib/x86-64-quanta-ix8-rglbmc-r0.yml deleted file mode 100644 index 2115b155a..000000000 --- a/packages/platforms/quanta/x86-64/ix8-rglbmc/platform-config/r0/src/lib/x86-64-quanta-ix8-rglbmc-r0.yml +++ /dev/null @@ -1,31 +0,0 @@ ---- - -###################################################################### -# -# 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/ix8-rglbmc/platform-config/r0/src/python/x86_64_quanta_ix8_rglbmc_r0/__init__.py b/packages/platforms/quanta/x86-64/ix8-rglbmc/platform-config/r0/src/python/x86_64_quanta_ix8_rglbmc_r0/__init__.py deleted file mode 100644 index 9f979a215..000000000 --- a/packages/platforms/quanta/x86-64/ix8-rglbmc/platform-config/r0/src/python/x86_64_quanta_ix8_rglbmc_r0/__init__.py +++ /dev/null @@ -1,31 +0,0 @@ -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("optoe") - self.insmod("qci_cpld_sfp28") - self.insmod("qci_cpld_led") - self.insmod("qci_platform_ix8") - - #SFP for 1~48 port - #QSFP for 49~56 port - for port_number in range(1,57): - bus_number = port_number + 31 - os.system("echo %d >/sys/bus/i2c/devices/%d-0050/port_name" % (port_number, bus_number)) - - - return True diff --git a/packages/platforms/quanta/x86-64/ly4r/.gitignore b/packages/platforms/quanta/x86-64/ly4r/.gitignore deleted file mode 100755 index 651bf0606..000000000 --- a/packages/platforms/quanta/x86-64/ly4r/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -*x86*64*quanta*ly4r*.mk -onlpdump.mk diff --git a/packages/platforms/quanta/x86-64/ly4r/Makefile b/packages/platforms/quanta/x86-64/ly4r/Makefile deleted file mode 100755 index 003238cf6..000000000 --- a/packages/platforms/quanta/x86-64/ly4r/Makefile +++ /dev/null @@ -1 +0,0 @@ -include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/quanta/x86-64/ly4r/modules/Makefile b/packages/platforms/quanta/x86-64/ly4r/modules/Makefile deleted file mode 100755 index 003238cf6..000000000 --- a/packages/platforms/quanta/x86-64/ly4r/modules/Makefile +++ /dev/null @@ -1 +0,0 @@ -include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/quanta/x86-64/ly4r/modules/PKG.yml b/packages/platforms/quanta/x86-64/ly4r/modules/PKG.yml deleted file mode 100755 index 5dd251936..000000000 --- a/packages/platforms/quanta/x86-64/ly4r/modules/PKG.yml +++ /dev/null @@ -1 +0,0 @@ -!include $ONL_TEMPLATES/platform-modules.yml ARCH=amd64 VENDOR=quanta BASENAME=x86-64-quanta-ly4r KERNELS="onl-kernel-3.16-lts-x86-64-all:amd64" diff --git a/packages/platforms/quanta/x86-64/ly4r/modules/builds/.gitignore b/packages/platforms/quanta/x86-64/ly4r/modules/builds/.gitignore deleted file mode 100755 index a65b41774..000000000 --- a/packages/platforms/quanta/x86-64/ly4r/modules/builds/.gitignore +++ /dev/null @@ -1 +0,0 @@ -lib diff --git a/packages/platforms/quanta/x86-64/ly4r/modules/builds/Makefile b/packages/platforms/quanta/x86-64/ly4r/modules/builds/Makefile deleted file mode 100755 index 3f3dd22db..000000000 --- a/packages/platforms/quanta/x86-64/ly4r/modules/builds/Makefile +++ /dev/null @@ -1,6 +0,0 @@ -KERNELS := onl-kernel-3.16-lts-x86-64-all:amd64 -KMODULES := $(wildcard *.c) -VENDOR := quanta -BASENAME := x86-64-quanta-ly4r -ARCH := x86_64 -include $(ONL)/make/kmodule.mk diff --git a/packages/platforms/quanta/x86-64/ly4r/modules/builds/quanta_platform_ly4r.c b/packages/platforms/quanta/x86-64/ly4r/modules/builds/quanta_platform_ly4r.c deleted file mode 100755 index 4a391f757..000000000 --- a/packages/platforms/quanta/x86-64/ly4r/modules/builds/quanta_platform_ly4r.c +++ /dev/null @@ -1,172 +0,0 @@ -/* - * Quanta LY4R platform driver - * - * - * Copyright (C) 2014 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), -}; - -static struct pca954x_platform_data pca9548sfp1_data = { - .modes = pca9548sfp1_modes, - .num_modes = 5, -}; - -static struct pca953x_platform_data pca9698_data = { - .gpio_base = 0x10, -}; - -static struct i2c_board_info ly4r_i2c_devices[] = { - { - I2C_BOARD_INFO("pca9698", 0x20), - .platform_data = &pca9698_data, - }, - { - I2C_BOARD_INFO("24c02", 0x54), - }, - { - I2C_BOARD_INFO("pca9548", 0x73), - .platform_data = &pca9548sfp1_data, - }, - { - I2C_BOARD_INFO("24c02", 0x50), - }, -}; - -static struct platform_driver ly4r_platform_driver = { - .driver = { - .name = "qci-ly4r", - .owner = THIS_MODULE, - }, -}; - -static struct platform_device *ly4r_device; - -static int __init ly4r_platform_init(void) -{ - struct i2c_client *client; - struct i2c_adapter *adapter; - int ret; - - ret = platform_driver_register(&ly4r_platform_driver); - if (ret < 0) - return ret; - - /* Register platform stuff */ - ly4r_device = platform_device_alloc("qci-ly4r", -1); - if (!ly4r_device) { - ret = -ENOMEM; - goto fail_platform_driver; - } - - ret = platform_device_add(ly4r_device); - if (ret) - goto fail_platform_device; - - adapter = i2c_get_adapter(1); - client = i2c_new_device(adapter, &ly4r_i2c_devices[2]); // pca9548sfp_1 - client = i2c_new_device(adapter, &ly4r_i2c_devices[0]); // pca9698 - client = i2c_new_device(adapter, &ly4r_i2c_devices[1]); // EEprom - i2c_put_adapter(adapter); - - adapter = i2c_get_adapter(0x20); - client = i2c_new_device(adapter, &ly4r_i2c_devices[3]); // sfp_1 EEprom - i2c_put_adapter(adapter); - - adapter = i2c_get_adapter(0x21); - client = i2c_new_device(adapter, &ly4r_i2c_devices[3]); // sfp_2 EEprom - i2c_put_adapter(adapter); - - adapter = i2c_get_adapter(0x22); - client = i2c_new_device(adapter, &ly4r_i2c_devices[3]); // sfp_3 EEprom - i2c_put_adapter(adapter); - - adapter = i2c_get_adapter(0x23); - client = i2c_new_device(adapter, &ly4r_i2c_devices[3]); // sfp_4 EEprom - i2c_put_adapter(adapter); - - adapter = i2c_get_adapter(0x24); - client = i2c_new_device(adapter, &ly4r_i2c_devices[3]); // msfp EEprom - i2c_put_adapter(adapter); - -#if 0 - if (!ly4r_device_present) { - ret = -ENODEV; - goto fail_no_device; - } -#endif - - return 0; - -fail_platform_device: - platform_device_put(ly4r_device); - -fail_platform_driver: - platform_driver_unregister(&ly4r_platform_driver); - return ret; -} - -static void __exit ly4r_platform_exit(void) -{ - platform_device_unregister(ly4r_device); - platform_driver_unregister(&ly4r_platform_driver); -} - -module_init(ly4r_platform_init); -module_exit(ly4r_platform_exit); - - -MODULE_AUTHOR("Jonathan Tsai (jonathan.tsai@quantatw.com)"); -MODULE_VERSION("1.0"); -MODULE_DESCRIPTION("Quanta LY4R Platform Driver"); -MODULE_LICENSE("GPL"); diff --git a/packages/platforms/quanta/x86-64/ly4r/onlp/Makefile b/packages/platforms/quanta/x86-64/ly4r/onlp/Makefile deleted file mode 100755 index 003238cf6..000000000 --- a/packages/platforms/quanta/x86-64/ly4r/onlp/Makefile +++ /dev/null @@ -1 +0,0 @@ -include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/quanta/x86-64/ly4r/onlp/PKG.yml b/packages/platforms/quanta/x86-64/ly4r/onlp/PKG.yml deleted file mode 100755 index 71b4f4ce1..000000000 --- a/packages/platforms/quanta/x86-64/ly4r/onlp/PKG.yml +++ /dev/null @@ -1 +0,0 @@ -!include $ONL_TEMPLATES/onlp-platform-any.yml PLATFORM=x86-64-quanta-ly4r ARCH=amd64 TOOLCHAIN=x86_64-linux-gnu diff --git a/packages/platforms/quanta/x86-64/ly4r/onlp/builds/Makefile b/packages/platforms/quanta/x86-64/ly4r/onlp/builds/Makefile deleted file mode 100755 index e7437cb23..000000000 --- a/packages/platforms/quanta/x86-64/ly4r/onlp/builds/Makefile +++ /dev/null @@ -1,2 +0,0 @@ -FILTER=src -include $(ONL)/make/subdirs.mk diff --git a/packages/platforms/quanta/x86-64/ly4r/onlp/builds/lib/Makefile b/packages/platforms/quanta/x86-64/ly4r/onlp/builds/lib/Makefile deleted file mode 100755 index b9534a1ca..000000000 --- a/packages/platforms/quanta/x86-64/ly4r/onlp/builds/lib/Makefile +++ /dev/null @@ -1,3 +0,0 @@ -PLATFORM := x86-64-quanta-ly4r -EXTRA_MODULES := quanta_sys_eeprom -include $(ONL)/packages/base/any/onlp/builds/platform/libonlp-platform.mk diff --git a/packages/platforms/quanta/x86-64/ly4r/onlp/builds/onlpdump/Makefile b/packages/platforms/quanta/x86-64/ly4r/onlp/builds/onlpdump/Makefile deleted file mode 100755 index e9ead2cfc..000000000 --- a/packages/platforms/quanta/x86-64/ly4r/onlp/builds/onlpdump/Makefile +++ /dev/null @@ -1,3 +0,0 @@ -PLATFORM := x86-64-quanta-ly4r -EXTRA_MODULES := quanta_sys_eeprom -include $(ONL)/packages/base/any/onlp/builds/platform/onlps.mk diff --git a/packages/platforms/quanta/x86-64/ly4r/onlp/builds/x86_64_quanta_ly4r/.gitignore b/packages/platforms/quanta/x86-64/ly4r/onlp/builds/x86_64_quanta_ly4r/.gitignore deleted file mode 100644 index c81d16be3..000000000 --- a/packages/platforms/quanta/x86-64/ly4r/onlp/builds/x86_64_quanta_ly4r/.gitignore +++ /dev/null @@ -1 +0,0 @@ -*.mk diff --git a/packages/platforms/quanta/x86-64/ly4r/onlp/builds/x86_64_quanta_ly4r/.module b/packages/platforms/quanta/x86-64/ly4r/onlp/builds/x86_64_quanta_ly4r/.module deleted file mode 100755 index c95830cc9..000000000 --- a/packages/platforms/quanta/x86-64/ly4r/onlp/builds/x86_64_quanta_ly4r/.module +++ /dev/null @@ -1 +0,0 @@ -name: x86_64_quanta_ly4r diff --git a/packages/platforms/quanta/x86-64/ly4r/onlp/builds/x86_64_quanta_ly4r/Makefile b/packages/platforms/quanta/x86-64/ly4r/onlp/builds/x86_64_quanta_ly4r/Makefile deleted file mode 100755 index dcdc19853..000000000 --- a/packages/platforms/quanta/x86-64/ly4r/onlp/builds/x86_64_quanta_ly4r/Makefile +++ /dev/null @@ -1,9 +0,0 @@ -############################################################################### -# -# -# -############################################################################### -include $(ONL)/make/config.mk -MODULE := x86_64_quanta_ly4r -AUTOMODULE := x86_64_quanta_ly4r -include $(BUILDER)/definemodule.mk diff --git a/packages/platforms/quanta/x86-64/ly4r/onlp/builds/x86_64_quanta_ly4r/module/auto/make.mk b/packages/platforms/quanta/x86-64/ly4r/onlp/builds/x86_64_quanta_ly4r/module/auto/make.mk deleted file mode 100755 index 90001abca..000000000 --- a/packages/platforms/quanta/x86-64/ly4r/onlp/builds/x86_64_quanta_ly4r/module/auto/make.mk +++ /dev/null @@ -1,9 +0,0 @@ -############################################################################### -# -# x86_64_quanta_ly4r Autogeneration -# -############################################################################### -x86_64_quanta_ly4r_AUTO_DEFS := module/auto/x86_64_quanta_ly4r.yml -x86_64_quanta_ly4r_AUTO_DIRS := module/inc/x86_64_quanta_ly4r module/src -include $(BUILDER)/auto.mk - diff --git a/packages/platforms/quanta/x86-64/ly4r/onlp/builds/x86_64_quanta_ly4r/module/auto/x86_64_quanta_ly4r.yml b/packages/platforms/quanta/x86-64/ly4r/onlp/builds/x86_64_quanta_ly4r/module/auto/x86_64_quanta_ly4r.yml deleted file mode 100755 index 532b9ebd1..000000000 --- a/packages/platforms/quanta/x86-64/ly4r/onlp/builds/x86_64_quanta_ly4r/module/auto/x86_64_quanta_ly4r.yml +++ /dev/null @@ -1,134 +0,0 @@ -############################################################################### -# -# x86_64_quanta_ly4r Autogeneration Definitions. -# -############################################################################### - -cdefs: &cdefs -- X86_64_QUANTA_LY4R_CONFIG_INCLUDE_LOGGING: - doc: "Include or exclude logging." - default: 1 -- X86_64_QUANTA_LY4R_CONFIG_LOG_OPTIONS_DEFAULT: - doc: "Default enabled log options." - default: AIM_LOG_OPTIONS_DEFAULT -- X86_64_QUANTA_LY4R_CONFIG_LOG_BITS_DEFAULT: - doc: "Default enabled log bits." - default: AIM_LOG_BITS_DEFAULT -- X86_64_QUANTA_LY4R_CONFIG_LOG_CUSTOM_BITS_DEFAULT: - doc: "Default enabled custom log bits." - default: 0 -- X86_64_QUANTA_LY4R_CONFIG_PORTING_STDLIB: - doc: "Default all porting macros to use the C standard libraries." - default: 1 -- X86_64_QUANTA_LY4R_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS: - doc: "Include standard library headers for stdlib porting macros." - default: X86_64_QUANTA_LY4R_CONFIG_PORTING_STDLIB -- X86_64_QUANTA_LY4R_CONFIG_INCLUDE_UCLI: - doc: "Include generic uCli support." - default: 0 -- X86_64_QUANTA_LY4R_CONFIG_SYSFAN_RPM_FAILURE_THRESHOLD: - doc: "RPM Threshold at which the fan is considered to have failed." - default: 3000 -- X86_64_QUANTA_LY4R_CONFIG_SYSFAN_F2B_RPM_MAX: - doc: "Maximum system front-to-back fan speed." - default: 18000 -- X86_64_QUANTA_LY4R_CONFIG_SYSFAN_B2F_RPM_MAX: - doc: "Maximum system back-to-front fan speed." - default: 18000 -- X86_64_QUANTA_LY4R_CONFIG_PHY_RESET_DELAY_MS: - doc: "Time to hold Phy GPIO in reset, in ms" - default: 100 - -definitions: - cdefs: - X86_64_QUANTA_LY4R_CONFIG_HEADER: - defs: *cdefs - basename: x86_64_quanta_ly4r_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_LY4R: - macros: - - memset - - memcpy - - - vsnprintf - - snprintf - - strlen diff --git a/packages/platforms/quanta/x86-64/ly4r/onlp/builds/x86_64_quanta_ly4r/module/inc/x86_64_quanta_ly4r/x86_64_quanta_ly4r.x b/packages/platforms/quanta/x86-64/ly4r/onlp/builds/x86_64_quanta_ly4r/module/inc/x86_64_quanta_ly4r/x86_64_quanta_ly4r.x deleted file mode 100755 index 1a83856a2..000000000 --- a/packages/platforms/quanta/x86-64/ly4r/onlp/builds/x86_64_quanta_ly4r/module/inc/x86_64_quanta_ly4r/x86_64_quanta_ly4r.x +++ /dev/null @@ -1,14 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#include - -/* <--auto.start.xmacro(ALL).define> */ -/* */ - -/* <--auto.start.xenum(ALL).define> */ -/* */ - - diff --git a/packages/platforms/quanta/x86-64/ly4r/onlp/builds/x86_64_quanta_ly4r/module/inc/x86_64_quanta_ly4r/x86_64_quanta_ly4r_config.h b/packages/platforms/quanta/x86-64/ly4r/onlp/builds/x86_64_quanta_ly4r/module/inc/x86_64_quanta_ly4r/x86_64_quanta_ly4r_config.h deleted file mode 100755 index a66b43240..000000000 --- a/packages/platforms/quanta/x86-64/ly4r/onlp/builds/x86_64_quanta_ly4r/module/inc/x86_64_quanta_ly4r/x86_64_quanta_ly4r_config.h +++ /dev/null @@ -1,167 +0,0 @@ -/**************************************************************************//** - * - * @file - * @brief x86_64_quanta_ly4r Configuration Header - * - * @addtogroup x86_64_quanta_ly4r-config - * @{ - * - *****************************************************************************/ -#ifndef __X86_64_QUANTA_LY4R_CONFIG_H__ -#define __X86_64_QUANTA_LY4R_CONFIG_H__ - -#ifdef GLOBAL_INCLUDE_CUSTOM_CONFIG -#include -#endif -#ifdef X86_64_QUANTA_LY4R_INCLUDE_CUSTOM_CONFIG -#include -#endif - -/* */ -#include -/** - * X86_64_QUANTA_LY4R_CONFIG_INCLUDE_LOGGING - * - * Include or exclude logging. */ - - -#ifndef X86_64_QUANTA_LY4R_CONFIG_INCLUDE_LOGGING -#define X86_64_QUANTA_LY4R_CONFIG_INCLUDE_LOGGING 1 -#endif - -/** - * X86_64_QUANTA_LY4R_CONFIG_LOG_OPTIONS_DEFAULT - * - * Default enabled log options. */ - - -#ifndef X86_64_QUANTA_LY4R_CONFIG_LOG_OPTIONS_DEFAULT -#define X86_64_QUANTA_LY4R_CONFIG_LOG_OPTIONS_DEFAULT AIM_LOG_OPTIONS_DEFAULT -#endif - -/** - * X86_64_QUANTA_LY4R_CONFIG_LOG_BITS_DEFAULT - * - * Default enabled log bits. */ - - -#ifndef X86_64_QUANTA_LY4R_CONFIG_LOG_BITS_DEFAULT -#define X86_64_QUANTA_LY4R_CONFIG_LOG_BITS_DEFAULT AIM_LOG_BITS_DEFAULT -#endif - -/** - * X86_64_QUANTA_LY4R_CONFIG_LOG_CUSTOM_BITS_DEFAULT - * - * Default enabled custom log bits. */ - - -#ifndef X86_64_QUANTA_LY4R_CONFIG_LOG_CUSTOM_BITS_DEFAULT -#define X86_64_QUANTA_LY4R_CONFIG_LOG_CUSTOM_BITS_DEFAULT 0 -#endif - -/** - * X86_64_QUANTA_LY4R_CONFIG_PORTING_STDLIB - * - * Default all porting macros to use the C standard libraries. */ - - -#ifndef X86_64_QUANTA_LY4R_CONFIG_PORTING_STDLIB -#define X86_64_QUANTA_LY4R_CONFIG_PORTING_STDLIB 1 -#endif - -/** - * X86_64_QUANTA_LY4R_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS - * - * Include standard library headers for stdlib porting macros. */ - - -#ifndef X86_64_QUANTA_LY4R_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS -#define X86_64_QUANTA_LY4R_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS X86_64_QUANTA_LY4R_CONFIG_PORTING_STDLIB -#endif - -/** - * X86_64_QUANTA_LY4R_CONFIG_INCLUDE_UCLI - * - * Include generic uCli support. */ - - -#ifndef X86_64_QUANTA_LY4R_CONFIG_INCLUDE_UCLI -#define X86_64_QUANTA_LY4R_CONFIG_INCLUDE_UCLI 0 -#endif - -/** - * X86_64_QUANTA_LY4R_CONFIG_SYSFAN_RPM_FAILURE_THRESHOLD - * - * RPM Threshold at which the fan is considered to have failed. */ - - -#ifndef X86_64_QUANTA_LY4R_CONFIG_SYSFAN_RPM_FAILURE_THRESHOLD -#define X86_64_QUANTA_LY4R_CONFIG_SYSFAN_RPM_FAILURE_THRESHOLD 3000 -#endif - -/** - * X86_64_QUANTA_LY4R_CONFIG_SYSFAN_F2B_RPM_MAX - * - * Maximum system front-to-back fan speed. */ - - -#ifndef X86_64_QUANTA_LY4R_CONFIG_SYSFAN_F2B_RPM_MAX -#define X86_64_QUANTA_LY4R_CONFIG_SYSFAN_F2B_RPM_MAX 18000 -#endif - -/** - * X86_64_QUANTA_LY4R_CONFIG_SYSFAN_B2F_RPM_MAX - * - * Maximum system back-to-front fan speed. */ - - -#ifndef X86_64_QUANTA_LY4R_CONFIG_SYSFAN_B2F_RPM_MAX -#define X86_64_QUANTA_LY4R_CONFIG_SYSFAN_B2F_RPM_MAX 18000 -#endif - -/** - * X86_64_QUANTA_LY4R_CONFIG_PHY_RESET_DELAY_MS - * - * Time to hold Phy GPIO in reset, in ms */ - - -#ifndef X86_64_QUANTA_LY4R_CONFIG_PHY_RESET_DELAY_MS -#define X86_64_QUANTA_LY4R_CONFIG_PHY_RESET_DELAY_MS 100 -#endif - - - -/** - * All compile time options can be queried or displayed - */ - -/** Configuration settings structure. */ -typedef struct x86_64_quanta_ly4r_config_settings_s { - /** name */ - const char* name; - /** value */ - const char* value; -} x86_64_quanta_ly4r_config_settings_t; - -/** Configuration settings table. */ -/** x86_64_quanta_ly4r_config_settings table. */ -extern x86_64_quanta_ly4r_config_settings_t x86_64_quanta_ly4r_config_settings[]; - -/** - * @brief Lookup a configuration setting. - * @param setting The name of the configuration option to lookup. - */ -const char* x86_64_quanta_ly4r_config_lookup(const char* setting); - -/** - * @brief Show the compile-time configuration. - * @param pvs The output stream. - */ -int x86_64_quanta_ly4r_config_show(struct aim_pvs_s* pvs); - -/* */ - -#include "x86_64_quanta_ly4r_porting.h" - -#endif /* __X86_64_QUANTA_LY4R_CONFIG_H__ */ -/* @} */ diff --git a/packages/platforms/quanta/x86-64/ly4r/onlp/builds/x86_64_quanta_ly4r/module/inc/x86_64_quanta_ly4r/x86_64_quanta_ly4r_dox.h b/packages/platforms/quanta/x86-64/ly4r/onlp/builds/x86_64_quanta_ly4r/module/inc/x86_64_quanta_ly4r/x86_64_quanta_ly4r_dox.h deleted file mode 100755 index ad264ceee..000000000 --- a/packages/platforms/quanta/x86-64/ly4r/onlp/builds/x86_64_quanta_ly4r/module/inc/x86_64_quanta_ly4r/x86_64_quanta_ly4r_dox.h +++ /dev/null @@ -1,26 +0,0 @@ -/**************************************************************************//** - * - * x86_64_quanta_ly4r Doxygen Header - * - *****************************************************************************/ -#ifndef __X86_64_QUANTA_LY4R_DOX_H__ -#define __X86_64_QUANTA_LY4R_DOX_H__ - -/** - * @defgroup x86_64_quanta_ly4r x86_64_quanta_ly4r - x86_64_quanta_ly4r Description - * - -The documentation overview for this module should go here. - - * - * @{ - * - * @defgroup x86_64_quanta_ly4r-x86_64_quanta_ly4r Public Interface - * @defgroup x86_64_quanta_ly4r-config Compile Time Configuration - * @defgroup x86_64_quanta_ly4r-porting Porting Macros - * - * @} - * - */ - -#endif /* __X86_64_QUANTA_LY4R_DOX_H__ */ diff --git a/packages/platforms/quanta/x86-64/ly4r/onlp/builds/x86_64_quanta_ly4r/module/inc/x86_64_quanta_ly4r/x86_64_quanta_ly4r_gpio_table.h b/packages/platforms/quanta/x86-64/ly4r/onlp/builds/x86_64_quanta_ly4r/module/inc/x86_64_quanta_ly4r/x86_64_quanta_ly4r_gpio_table.h deleted file mode 100755 index 030c4b7c6..000000000 --- a/packages/platforms/quanta/x86-64/ly4r/onlp/builds/x86_64_quanta_ly4r/module/inc/x86_64_quanta_ly4r/x86_64_quanta_ly4r_gpio_table.h +++ /dev/null @@ -1,39 +0,0 @@ -#ifndef __X86_64_QUANTA_LY4R_GPIO_TABLE_H__ -#define __X86_64_QUANTA_LY4R_GPIO_TABLE_H__ - -/* - * defined within platform/quanta_switch.c - * Quanta Switch Platform driver - */ -#define QUANTA_LY4R_PCA953x_GPIO(P1, P2) (P1*8+P2) - -#define QUANTA_LY4R_PCA9698_GPIO_SIZE 0x28 - -#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)) -#define QUANTA_LY4R_PCA9698_GPIO_SFP_P3V3_PW_GD (QUANTA_LY4R_PCA9698_GPIO_BASE + QUANTA_LY4R_PCA953x_GPIO(2,7)) -#endif /* __X86_64_QUANTA_LY4R_GPIO_TABLE_H__ */ diff --git a/packages/platforms/quanta/x86-64/ly4r/onlp/builds/x86_64_quanta_ly4r/module/inc/x86_64_quanta_ly4r/x86_64_quanta_ly4r_porting.h b/packages/platforms/quanta/x86-64/ly4r/onlp/builds/x86_64_quanta_ly4r/module/inc/x86_64_quanta_ly4r/x86_64_quanta_ly4r_porting.h deleted file mode 100755 index cceec514d..000000000 --- a/packages/platforms/quanta/x86-64/ly4r/onlp/builds/x86_64_quanta_ly4r/module/inc/x86_64_quanta_ly4r/x86_64_quanta_ly4r_porting.h +++ /dev/null @@ -1,77 +0,0 @@ -/**************************************************************************//** - * - * @file - * @brief x86_64_quanta_ly4r Porting Macros. - * - * @addtogroup x86_64_quanta_ly4r-porting - * @{ - * - *****************************************************************************/ -#ifndef __X86_64_QUANTA_LY4R_PORTING_H__ -#define __X86_64_QUANTA_LY4R_PORTING_H__ - - -/* */ -#if X86_64_QUANTA_LY4R_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS == 1 -#include -#include -#include -#include -#include -#endif - -#ifndef X86_64_QUANTA_LY4R_MEMSET - #if defined(GLOBAL_MEMSET) - #define X86_64_QUANTA_LY4R_MEMSET GLOBAL_MEMSET - #elif X86_64_QUANTA_LY4R_CONFIG_PORTING_STDLIB == 1 - #define X86_64_QUANTA_LY4R_MEMSET memset - #else - #error The macro X86_64_QUANTA_LY4R_MEMSET is required but cannot be defined. - #endif -#endif - -#ifndef X86_64_QUANTA_LY4R_MEMCPY - #if defined(GLOBAL_MEMCPY) - #define X86_64_QUANTA_LY4R_MEMCPY GLOBAL_MEMCPY - #elif X86_64_QUANTA_LY4R_CONFIG_PORTING_STDLIB == 1 - #define X86_64_QUANTA_LY4R_MEMCPY memcpy - #else - #error The macro X86_64_QUANTA_LY4R_MEMCPY is required but cannot be defined. - #endif -#endif - -#ifndef X86_64_QUANTA_LY4R_VSNPRINTF - #if defined(GLOBAL_VSNPRINTF) - #define X86_64_QUANTA_LY4R_VSNPRINTF GLOBAL_VSNPRINTF - #elif X86_64_QUANTA_LY4R_CONFIG_PORTING_STDLIB == 1 - #define X86_64_QUANTA_LY4R_VSNPRINTF vsnprintf - #else - #error The macro X86_64_QUANTA_LY4R_VSNPRINTF is required but cannot be defined. - #endif -#endif - -#ifndef X86_64_QUANTA_LY4R_SNPRINTF - #if defined(GLOBAL_SNPRINTF) - #define X86_64_QUANTA_LY4R_SNPRINTF GLOBAL_SNPRINTF - #elif X86_64_QUANTA_LY4R_CONFIG_PORTING_STDLIB == 1 - #define X86_64_QUANTA_LY4R_SNPRINTF snprintf - #else - #error The macro X86_64_QUANTA_LY4R_SNPRINTF is required but cannot be defined. - #endif -#endif - -#ifndef X86_64_QUANTA_LY4R_STRLEN - #if defined(GLOBAL_STRLEN) - #define X86_64_QUANTA_LY4R_STRLEN GLOBAL_STRLEN - #elif X86_64_QUANTA_LY4R_CONFIG_PORTING_STDLIB == 1 - #define X86_64_QUANTA_LY4R_STRLEN strlen - #else - #error The macro X86_64_QUANTA_LY4R_STRLEN is required but cannot be defined. - #endif -#endif - -/* */ - - -#endif /* __X86_64_QUANTA_LY4R_PORTING_H__ */ -/* @} */ diff --git a/packages/platforms/quanta/x86-64/ly4r/onlp/builds/x86_64_quanta_ly4r/module/make.mk b/packages/platforms/quanta/x86-64/ly4r/onlp/builds/x86_64_quanta_ly4r/module/make.mk deleted file mode 100755 index 651a58711..000000000 --- a/packages/platforms/quanta/x86-64/ly4r/onlp/builds/x86_64_quanta_ly4r/module/make.mk +++ /dev/null @@ -1,10 +0,0 @@ -############################################################################### -# -# -# -############################################################################### -THIS_DIR := $(dir $(lastword $(MAKEFILE_LIST))) -x86_64_quanta_ly4r_INCLUDES := -I $(THIS_DIR)inc -x86_64_quanta_ly4r_INTERNAL_INCLUDES := -I $(THIS_DIR)src -x86_64_quanta_ly4r_DEPENDMODULE_ENTRIES := init:x86_64_quanta_ly4r ucli:x86_64_quanta_ly4r - diff --git a/packages/platforms/quanta/x86-64/ly4r/onlp/builds/x86_64_quanta_ly4r/module/src/Makefile b/packages/platforms/quanta/x86-64/ly4r/onlp/builds/x86_64_quanta_ly4r/module/src/Makefile deleted file mode 100755 index ae79b74c1..000000000 --- a/packages/platforms/quanta/x86-64/ly4r/onlp/builds/x86_64_quanta_ly4r/module/src/Makefile +++ /dev/null @@ -1,9 +0,0 @@ -############################################################################### -# -# Local source generation targets. -# -############################################################################### - -ucli: - @../../../../tools/uclihandlers.py x86_64_quanta_ly4r_ucli.c - diff --git a/packages/platforms/quanta/x86-64/ly4r/onlp/builds/x86_64_quanta_ly4r/module/src/fani.c b/packages/platforms/quanta/x86-64/ly4r/onlp/builds/x86_64_quanta_ly4r/module/src/fani.c deleted file mode 100755 index 7594b0ca0..000000000 --- a/packages/platforms/quanta/x86-64/ly4r/onlp/builds/x86_64_quanta_ly4r/module/src/fani.c +++ /dev/null @@ -1,31 +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 - -int -onlp_fani_init(void) -{ - return ONLP_STATUS_E_UNSUPPORTED; -} diff --git a/packages/platforms/quanta/x86-64/ly4r/onlp/builds/x86_64_quanta_ly4r/module/src/ledi.c b/packages/platforms/quanta/x86-64/ly4r/onlp/builds/x86_64_quanta_ly4r/module/src/ledi.c deleted file mode 100755 index f994d3b2b..000000000 --- a/packages/platforms/quanta/x86-64/ly4r/onlp/builds/x86_64_quanta_ly4r/module/src/ledi.c +++ /dev/null @@ -1,78 +0,0 @@ -#include -#include -#include -#include -#include - -#include "x86_64_quanta_ly4r_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_LY4R_PCA9698_BOOT_STSLED_N, 0); - onlp_gpio_set(QUANTA_LY4R_PCA9698_SYS_STSLED, 1); - } - else if(mode == ONLP_LED_MODE_ORANGE){ - onlp_gpio_set(QUANTA_LY4R_PCA9698_BOOT_STSLED_N, 1); - onlp_gpio_set(QUANTA_LY4R_PCA9698_SYS_STSLED, 0); - } - else{ - onlp_gpio_set(QUANTA_LY4R_PCA9698_BOOT_STSLED_N, 1); - onlp_gpio_set(QUANTA_LY4R_PCA9698_SYS_STSLED, 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/ly4r/onlp/builds/x86_64_quanta_ly4r/module/src/make.mk b/packages/platforms/quanta/x86-64/ly4r/onlp/builds/x86_64_quanta_ly4r/module/src/make.mk deleted file mode 100755 index 1a063c328..000000000 --- a/packages/platforms/quanta/x86-64/ly4r/onlp/builds/x86_64_quanta_ly4r/module/src/make.mk +++ /dev/null @@ -1,9 +0,0 @@ -############################################################################### -# -# -# -############################################################################### - -LIBRARY := x86_64_quanta_ly4r -$(LIBRARY)_SUBDIR := $(dir $(lastword $(MAKEFILE_LIST))) -include $(BUILDER)/lib.mk diff --git a/packages/platforms/quanta/x86-64/ly4r/onlp/builds/x86_64_quanta_ly4r/module/src/psui.c b/packages/platforms/quanta/x86-64/ly4r/onlp/builds/x86_64_quanta_ly4r/module/src/psui.c deleted file mode 100755 index b5cedce16..000000000 --- a/packages/platforms/quanta/x86-64/ly4r/onlp/builds/x86_64_quanta_ly4r/module/src/psui.c +++ /dev/null @@ -1,15 +0,0 @@ -/************************************************************ - * - * - ************************************************************ - * - * - * - ***********************************************************/ -#include - -int -onlp_psui_init(void) -{ - return ONLP_STATUS_E_UNSUPPORTED; -} diff --git a/packages/platforms/quanta/x86-64/ly4r/onlp/builds/x86_64_quanta_ly4r/module/src/sfpi.c b/packages/platforms/quanta/x86-64/ly4r/onlp/builds/x86_64_quanta_ly4r/module/src/sfpi.c deleted file mode 100755 index ceba9fe42..000000000 --- a/packages/platforms/quanta/x86-64/ly4r/onlp/builds/x86_64_quanta_ly4r/module/src/sfpi.c +++ /dev/null @@ -1,229 +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. - * - * - ************************************************************ - * - * SFPI Interface for the Quanta LY4R - * - ***********************************************************/ -#include -#include -#include -#include -#include -#include "x86_64_quanta_ly4r_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; - int present_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, 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) - -int -onlp_sfpi_init(void) -{ - int value = -1, ret, i; - sfpmap_t* sfp; - - onlp_gpio_export(QUANTA_LY4R_PCA9698_GPIO_SFP_P3V3_PW_EN, ONLP_GPIO_DIRECTION_IN); - ret = onlp_gpio_get(QUANTA_LY4R_PCA9698_GPIO_SFP_P3V3_PW_EN, &value); - if(ret == ONLP_STATUS_OK && value != 0) { - onlp_gpio_export(QUANTA_LY4R_PCA9698_GPIO_SFP_P3V3_PW_EN, ONLP_GPIO_DIRECTION_OUT); - ret = onlp_gpio_set(QUANTA_LY4R_PCA9698_GPIO_SFP_P3V3_PW_EN, 0); - sleep(1); - } - - 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; -} - -int -onlp_sfpi_bitmap_get(onlp_sfp_bitmap_t* bmap) -{ - int p; - - for(p = 49; p < 54; p++) { - AIM_BITMAP_SET(bmap, p); - } - - return ONLP_STATUS_OK; -} - -int -onlp_sfpi_is_present(int port) -{ - int value = 0; - sfpmap_t* sfp = SFP_GET(port); - if(sfp->present_gpio > 0) { - if(onlp_gpio_get(sfp->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(sfp->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; - } -} - -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; - 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; -} diff --git a/packages/platforms/quanta/x86-64/ly4r/onlp/builds/x86_64_quanta_ly4r/module/src/sysi.c b/packages/platforms/quanta/x86-64/ly4r/onlp/builds/x86_64_quanta_ly4r/module/src/sysi.c deleted file mode 100755 index 4bfa59166..000000000 --- a/packages/platforms/quanta/x86-64/ly4r/onlp/builds/x86_64_quanta_ly4r/module/src/sysi.c +++ /dev/null @@ -1,66 +0,0 @@ -/************************************************************ - * - * - ************************************************************ - * - * - * - ***********************************************************/ -#include -#include "x86_64_quanta_ly4r_int.h" -#include "x86_64_quanta_ly4r_log.h" -#include -#include -#include -#include -#include - -const char* -onlp_sysi_platform_get(void) -{ - /* Config GPIO */ - /* LED Output */ - onlp_gpio_export(QUANTA_LY4R_PCA9698_BOOT_STSLED_N, ONLP_GPIO_DIRECTION_OUT); - onlp_gpio_export(QUANTA_LY4R_PCA9698_SYS_STSLED, ONLP_GPIO_DIRECTION_OUT); - - /* Set LED to green */ - onlp_ledi_mode_set(LED_OID_SYSTEM, ONLP_LED_MODE_GREEN); - - return "x86-64-quanta-ly4r-r0"; -} - -int -onlp_sysi_init(void) -{ - return ONLP_STATUS_OK; -} - -#define QUANTA_SYS_EEPROM_PATH \ -"/sys/devices/pci0000:00/0000:00:13.0/i2c-1/1-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-ly4r-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 LED - */ - *e++ = LED_OID_SYSTEM; - - return 0; -} diff --git a/packages/platforms/quanta/x86-64/ly4r/onlp/builds/x86_64_quanta_ly4r/module/src/thermali.c b/packages/platforms/quanta/x86-64/ly4r/onlp/builds/x86_64_quanta_ly4r/module/src/thermali.c deleted file mode 100755 index 2a84c0178..000000000 --- a/packages/platforms/quanta/x86-64/ly4r/onlp/builds/x86_64_quanta_ly4r/module/src/thermali.c +++ /dev/null @@ -1,31 +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 - -int -onlp_thermali_init(void) -{ - return ONLP_STATUS_E_UNSUPPORTED; -} diff --git a/packages/platforms/quanta/x86-64/ly4r/onlp/builds/x86_64_quanta_ly4r/module/src/x86_64_quanta_ly4r_config.c b/packages/platforms/quanta/x86-64/ly4r/onlp/builds/x86_64_quanta_ly4r/module/src/x86_64_quanta_ly4r_config.c deleted file mode 100755 index 835814e91..000000000 --- a/packages/platforms/quanta/x86-64/ly4r/onlp/builds/x86_64_quanta_ly4r/module/src/x86_64_quanta_ly4r_config.c +++ /dev/null @@ -1,95 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#include - -/* */ -#define __x86_64_quanta_ly4r_config_STRINGIFY_NAME(_x) #_x -#define __x86_64_quanta_ly4r_config_STRINGIFY_VALUE(_x) __x86_64_quanta_ly4r_config_STRINGIFY_NAME(_x) -x86_64_quanta_ly4r_config_settings_t x86_64_quanta_ly4r_config_settings[] = -{ -#ifdef X86_64_QUANTA_LY4R_CONFIG_INCLUDE_LOGGING - { __x86_64_quanta_ly4r_config_STRINGIFY_NAME(X86_64_QUANTA_LY4R_CONFIG_INCLUDE_LOGGING), __x86_64_quanta_ly4r_config_STRINGIFY_VALUE(X86_64_QUANTA_LY4R_CONFIG_INCLUDE_LOGGING) }, -#else -{ X86_64_QUANTA_LY4R_CONFIG_INCLUDE_LOGGING(__x86_64_quanta_ly4r_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_QUANTA_LY4R_CONFIG_LOG_OPTIONS_DEFAULT - { __x86_64_quanta_ly4r_config_STRINGIFY_NAME(X86_64_QUANTA_LY4R_CONFIG_LOG_OPTIONS_DEFAULT), __x86_64_quanta_ly4r_config_STRINGIFY_VALUE(X86_64_QUANTA_LY4R_CONFIG_LOG_OPTIONS_DEFAULT) }, -#else -{ X86_64_QUANTA_LY4R_CONFIG_LOG_OPTIONS_DEFAULT(__x86_64_quanta_ly4r_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_QUANTA_LY4R_CONFIG_LOG_BITS_DEFAULT - { __x86_64_quanta_ly4r_config_STRINGIFY_NAME(X86_64_QUANTA_LY4R_CONFIG_LOG_BITS_DEFAULT), __x86_64_quanta_ly4r_config_STRINGIFY_VALUE(X86_64_QUANTA_LY4R_CONFIG_LOG_BITS_DEFAULT) }, -#else -{ X86_64_QUANTA_LY4R_CONFIG_LOG_BITS_DEFAULT(__x86_64_quanta_ly4r_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_QUANTA_LY4R_CONFIG_LOG_CUSTOM_BITS_DEFAULT - { __x86_64_quanta_ly4r_config_STRINGIFY_NAME(X86_64_QUANTA_LY4R_CONFIG_LOG_CUSTOM_BITS_DEFAULT), __x86_64_quanta_ly4r_config_STRINGIFY_VALUE(X86_64_QUANTA_LY4R_CONFIG_LOG_CUSTOM_BITS_DEFAULT) }, -#else -{ X86_64_QUANTA_LY4R_CONFIG_LOG_CUSTOM_BITS_DEFAULT(__x86_64_quanta_ly4r_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_QUANTA_LY4R_CONFIG_PORTING_STDLIB - { __x86_64_quanta_ly4r_config_STRINGIFY_NAME(X86_64_QUANTA_LY4R_CONFIG_PORTING_STDLIB), __x86_64_quanta_ly4r_config_STRINGIFY_VALUE(X86_64_QUANTA_LY4R_CONFIG_PORTING_STDLIB) }, -#else -{ X86_64_QUANTA_LY4R_CONFIG_PORTING_STDLIB(__x86_64_quanta_ly4r_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_QUANTA_LY4R_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS - { __x86_64_quanta_ly4r_config_STRINGIFY_NAME(X86_64_QUANTA_LY4R_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS), __x86_64_quanta_ly4r_config_STRINGIFY_VALUE(X86_64_QUANTA_LY4R_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS) }, -#else -{ X86_64_QUANTA_LY4R_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS(__x86_64_quanta_ly4r_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_QUANTA_LY4R_CONFIG_INCLUDE_UCLI - { __x86_64_quanta_ly4r_config_STRINGIFY_NAME(X86_64_QUANTA_LY4R_CONFIG_INCLUDE_UCLI), __x86_64_quanta_ly4r_config_STRINGIFY_VALUE(X86_64_QUANTA_LY4R_CONFIG_INCLUDE_UCLI) }, -#else -{ X86_64_QUANTA_LY4R_CONFIG_INCLUDE_UCLI(__x86_64_quanta_ly4r_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_QUANTA_LY4R_CONFIG_SYSFAN_RPM_FAILURE_THRESHOLD - { __x86_64_quanta_ly4r_config_STRINGIFY_NAME(X86_64_QUANTA_LY4R_CONFIG_SYSFAN_RPM_FAILURE_THRESHOLD), __x86_64_quanta_ly4r_config_STRINGIFY_VALUE(X86_64_QUANTA_LY4R_CONFIG_SYSFAN_RPM_FAILURE_THRESHOLD) }, -#else -{ X86_64_QUANTA_LY4R_CONFIG_SYSFAN_RPM_FAILURE_THRESHOLD(__x86_64_quanta_ly4r_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_QUANTA_LY4R_CONFIG_SYSFAN_F2B_RPM_MAX - { __x86_64_quanta_ly4r_config_STRINGIFY_NAME(X86_64_QUANTA_LY4R_CONFIG_SYSFAN_F2B_RPM_MAX), __x86_64_quanta_ly4r_config_STRINGIFY_VALUE(X86_64_QUANTA_LY4R_CONFIG_SYSFAN_F2B_RPM_MAX) }, -#else -{ X86_64_QUANTA_LY4R_CONFIG_SYSFAN_F2B_RPM_MAX(__x86_64_quanta_ly4r_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_QUANTA_LY4R_CONFIG_SYSFAN_B2F_RPM_MAX - { __x86_64_quanta_ly4r_config_STRINGIFY_NAME(X86_64_QUANTA_LY4R_CONFIG_SYSFAN_B2F_RPM_MAX), __x86_64_quanta_ly4r_config_STRINGIFY_VALUE(X86_64_QUANTA_LY4R_CONFIG_SYSFAN_B2F_RPM_MAX) }, -#else -{ X86_64_QUANTA_LY4R_CONFIG_SYSFAN_B2F_RPM_MAX(__x86_64_quanta_ly4r_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_QUANTA_LY4R_CONFIG_PHY_RESET_DELAY_MS - { __x86_64_quanta_ly4r_config_STRINGIFY_NAME(X86_64_QUANTA_LY4R_CONFIG_PHY_RESET_DELAY_MS), __x86_64_quanta_ly4r_config_STRINGIFY_VALUE(X86_64_QUANTA_LY4R_CONFIG_PHY_RESET_DELAY_MS) }, -#else -{ X86_64_QUANTA_LY4R_CONFIG_PHY_RESET_DELAY_MS(__x86_64_quanta_ly4r_config_STRINGIFY_NAME), "__undefined__" }, -#endif - { NULL, NULL } -}; -#undef __x86_64_quanta_ly4r_config_STRINGIFY_VALUE -#undef __x86_64_quanta_ly4r_config_STRINGIFY_NAME - -const char* -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)) { - return x86_64_quanta_ly4r_config_settings[i].value; - } - } - return NULL; -} - -int -x86_64_quanta_ly4r_config_show(struct aim_pvs_s* pvs) -{ - int i; - for(i = 0; x86_64_quanta_ly4r_config_settings[i].name; i++) { - aim_printf(pvs, "%s = %s\n", x86_64_quanta_ly4r_config_settings[i].name, x86_64_quanta_ly4r_config_settings[i].value); - } - return i; -} - -/* */ diff --git a/packages/platforms/quanta/x86-64/ly4r/onlp/builds/x86_64_quanta_ly4r/module/src/x86_64_quanta_ly4r_enums.c b/packages/platforms/quanta/x86-64/ly4r/onlp/builds/x86_64_quanta_ly4r/module/src/x86_64_quanta_ly4r_enums.c deleted file mode 100755 index d19bfc7aa..000000000 --- a/packages/platforms/quanta/x86-64/ly4r/onlp/builds/x86_64_quanta_ly4r/module/src/x86_64_quanta_ly4r_enums.c +++ /dev/null @@ -1,10 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#include - -/* <--auto.start.enum(ALL).source> */ -/* */ - diff --git a/packages/platforms/quanta/x86-64/ly4r/onlp/builds/x86_64_quanta_ly4r/module/src/x86_64_quanta_ly4r_int.h b/packages/platforms/quanta/x86-64/ly4r/onlp/builds/x86_64_quanta_ly4r/module/src/x86_64_quanta_ly4r_int.h deleted file mode 100755 index 3f1b1161f..000000000 --- a/packages/platforms/quanta/x86-64/ly4r/onlp/builds/x86_64_quanta_ly4r/module/src/x86_64_quanta_ly4r_int.h +++ /dev/null @@ -1,283 +0,0 @@ -/**************************************************************************//** - * - * x86_64_quanta_ly4r Internal Header - * - *****************************************************************************/ -#ifndef __X86_64_QUANTA_LY4R_INT_H__ -#define __X86_64_QUANTA_LY4R_INT_H__ - -#include -#include - -/* */ -/** 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[]; - -/** 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 { - 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[]; - -/** 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 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[]; -/* */ - -#define SYS_HWMON_PREFIX "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/0-004e" - -#endif /* __X86_64_QUANTA_LY4R_INT_H__ */ diff --git a/packages/platforms/quanta/x86-64/ly4r/onlp/builds/x86_64_quanta_ly4r/module/src/x86_64_quanta_ly4r_log.c b/packages/platforms/quanta/x86-64/ly4r/onlp/builds/x86_64_quanta_ly4r/module/src/x86_64_quanta_ly4r_log.c deleted file mode 100755 index 4386c9752..000000000 --- a/packages/platforms/quanta/x86-64/ly4r/onlp/builds/x86_64_quanta_ly4r/module/src/x86_64_quanta_ly4r_log.c +++ /dev/null @@ -1,18 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#include - -#include "x86_64_quanta_ly4r_log.h" -/* - * x86_64_quanta_ly4r log struct. - */ -AIM_LOG_STRUCT_DEFINE( - X86_64_QUANTA_LY4R_CONFIG_LOG_OPTIONS_DEFAULT, - X86_64_QUANTA_LY4R_CONFIG_LOG_BITS_DEFAULT, - NULL, /* Custom log map */ - X86_64_QUANTA_LY4R_CONFIG_LOG_CUSTOM_BITS_DEFAULT - ); - diff --git a/packages/platforms/quanta/x86-64/ly4r/onlp/builds/x86_64_quanta_ly4r/module/src/x86_64_quanta_ly4r_log.h b/packages/platforms/quanta/x86-64/ly4r/onlp/builds/x86_64_quanta_ly4r/module/src/x86_64_quanta_ly4r_log.h deleted file mode 100755 index 8ca11a969..000000000 --- a/packages/platforms/quanta/x86-64/ly4r/onlp/builds/x86_64_quanta_ly4r/module/src/x86_64_quanta_ly4r_log.h +++ /dev/null @@ -1,12 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#ifndef __X86_64_QUANTA_LY4R_LOG_H__ -#define __X86_64_QUANTA_LY4R_LOG_H__ - -#define AIM_LOG_MODULE_NAME x86_64_quanta_ly4r -#include - -#endif /* __X86_64_QUANTA_LY4R_LOG_H__ */ diff --git a/packages/platforms/quanta/x86-64/ly4r/onlp/builds/x86_64_quanta_ly4r/module/src/x86_64_quanta_ly4r_module.c b/packages/platforms/quanta/x86-64/ly4r/onlp/builds/x86_64_quanta_ly4r/module/src/x86_64_quanta_ly4r_module.c deleted file mode 100755 index d58ede9f7..000000000 --- a/packages/platforms/quanta/x86-64/ly4r/onlp/builds/x86_64_quanta_ly4r/module/src/x86_64_quanta_ly4r_module.c +++ /dev/null @@ -1,24 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#include - -#include "x86_64_quanta_ly4r_log.h" - -static int -datatypes_init__(void) -{ -#define X86_64_QUANTA_LY4R_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_ly4r_module_init__(void) -{ - AIM_LOG_STRUCT_REGISTER(); - datatypes_init__(); -} - -int __onlp_platform_version__ = 1; diff --git a/packages/platforms/quanta/x86-64/ly4r/onlp/builds/x86_64_quanta_ly4r/module/src/x86_64_quanta_ly4r_ucli.c b/packages/platforms/quanta/x86-64/ly4r/onlp/builds/x86_64_quanta_ly4r/module/src/x86_64_quanta_ly4r_ucli.c deleted file mode 100755 index de0d6bb7a..000000000 --- a/packages/platforms/quanta/x86-64/ly4r/onlp/builds/x86_64_quanta_ly4r/module/src/x86_64_quanta_ly4r_ucli.c +++ /dev/null @@ -1,50 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#include - -#if X86_64_QUANTA_LY4R_CONFIG_INCLUDE_UCLI == 1 - -#include -#include -#include - -static ucli_status_t -x86_64_quanta_ly4r_ucli_ucli__config__(ucli_context_t* uc) -{ - UCLI_HANDLER_MACRO_MODULE_CONFIG(x86_64_quanta_ly4r) -} - -/* */ -/* */ - -static ucli_module_t -x86_64_quanta_ly4r_ucli_module__ = - { - "x86_64_quanta_ly4r_ucli", - NULL, - x86_64_quanta_ly4r_ucli_ucli_handlers__, - NULL, - NULL, - }; - -ucli_node_t* -x86_64_quanta_ly4r_ucli_node_create(void) -{ - ucli_node_t* n; - ucli_module_init(&x86_64_quanta_ly4r_ucli_module__); - n = ucli_node_create("x86_64_quanta_ly4r", NULL, &x86_64_quanta_ly4r_ucli_module__); - ucli_node_subnode_add(n, ucli_module_log_node_create("x86_64_quanta_ly4r")); - return n; -} - -#else -void* -x86_64_quanta_ly4r_ucli_node_create(void) -{ - return NULL; -} -#endif - diff --git a/packages/platforms/quanta/x86-64/ly4r/platform-config/Makefile b/packages/platforms/quanta/x86-64/ly4r/platform-config/Makefile deleted file mode 100755 index 003238cf6..000000000 --- a/packages/platforms/quanta/x86-64/ly4r/platform-config/Makefile +++ /dev/null @@ -1 +0,0 @@ -include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/quanta/x86-64/ly4r/platform-config/r0/Makefile b/packages/platforms/quanta/x86-64/ly4r/platform-config/r0/Makefile deleted file mode 100755 index 003238cf6..000000000 --- a/packages/platforms/quanta/x86-64/ly4r/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/quanta/x86-64/ly4r/platform-config/r0/PKG.yml b/packages/platforms/quanta/x86-64/ly4r/platform-config/r0/PKG.yml deleted file mode 100755 index f70f63049..000000000 --- a/packages/platforms/quanta/x86-64/ly4r/platform-config/r0/PKG.yml +++ /dev/null @@ -1 +0,0 @@ -!include $ONL_TEMPLATES/platform-config-platform.yml ARCH=amd64 VENDOR=quanta BASENAME=x86-64-quanta-ly4r REVISION=r0 diff --git a/packages/platforms/quanta/x86-64/ly4r/platform-config/r0/src/lib/x86-64-quanta-ly4r-r0.yml b/packages/platforms/quanta/x86-64/ly4r/platform-config/r0/src/lib/x86-64-quanta-ly4r-r0.yml deleted file mode 100755 index 6e18943f9..000000000 --- a/packages/platforms/quanta/x86-64/ly4r/platform-config/r0/src/lib/x86-64-quanta-ly4r-r0.yml +++ /dev/null @@ -1,31 +0,0 @@ ---- - -###################################################################### -# -# platform-config for LY4R -# -###################################################################### - -x86-64-quanta-ly4r-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/ly4r/platform-config/r0/src/python/x86_64_quanta_ly4r_r0/__init__.py b/packages/platforms/quanta/x86-64/ly4r/platform-config/r0/src/python/x86_64_quanta_ly4r_r0/__init__.py deleted file mode 100755 index a88370afd..000000000 --- a/packages/platforms/quanta/x86-64/ly4r/platform-config/r0/src/python/x86_64_quanta_ly4r_r0/__init__.py +++ /dev/null @@ -1,21 +0,0 @@ -from onl.platform.base import * -from onl.platform.quanta import * - -class OnlPlatform_x86_64_quanta_ly4r_r0(OnlPlatformQuanta, - OnlPlatformPortConfig_48x1_4x10): - PLATFORM='x86-64-quanta-ly4r-r0' - MODEL="LY4R" - """ 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=".1048.2418" - - def baseconfig(self): - self.insmod("quanta_platform_ly4r") - - return True diff --git a/packages/platforms/quanta/x86-64/ly6-rangeley/.gitignore b/packages/platforms/quanta/x86-64/ly6-rangeley/.gitignore deleted file mode 100644 index 63e5dc9e8..000000000 --- a/packages/platforms/quanta/x86-64/ly6-rangeley/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -*x86*64*quanta*ly6*rangeley*.mk -onlpdump.mk diff --git a/packages/platforms/quanta/x86-64/ly6-rangeley/Makefile b/packages/platforms/quanta/x86-64/ly6-rangeley/Makefile deleted file mode 100644 index 003238cf6..000000000 --- a/packages/platforms/quanta/x86-64/ly6-rangeley/Makefile +++ /dev/null @@ -1 +0,0 @@ -include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/quanta/x86-64/ly6-rangeley/modules/Makefile b/packages/platforms/quanta/x86-64/ly6-rangeley/modules/Makefile deleted file mode 100644 index 003238cf6..000000000 --- a/packages/platforms/quanta/x86-64/ly6-rangeley/modules/Makefile +++ /dev/null @@ -1 +0,0 @@ -include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/quanta/x86-64/ly6-rangeley/modules/PKG.yml b/packages/platforms/quanta/x86-64/ly6-rangeley/modules/PKG.yml deleted file mode 100644 index 8788e1999..000000000 --- a/packages/platforms/quanta/x86-64/ly6-rangeley/modules/PKG.yml +++ /dev/null @@ -1 +0,0 @@ -!include $ONL_TEMPLATES/platform-modules.yml ARCH=amd64 VENDOR=quanta BASENAME=x86-64-quanta-ly6-rangeley KERNELS="onl-kernel-3.16-lts-x86-64-all:amd64" diff --git a/packages/platforms/quanta/x86-64/ly6-rangeley/modules/builds/.gitignore b/packages/platforms/quanta/x86-64/ly6-rangeley/modules/builds/.gitignore deleted file mode 100644 index a65b41774..000000000 --- a/packages/platforms/quanta/x86-64/ly6-rangeley/modules/builds/.gitignore +++ /dev/null @@ -1 +0,0 @@ -lib diff --git a/packages/platforms/quanta/x86-64/ly6-rangeley/modules/builds/Makefile b/packages/platforms/quanta/x86-64/ly6-rangeley/modules/builds/Makefile deleted file mode 100644 index 21339f1b5..000000000 --- a/packages/platforms/quanta/x86-64/ly6-rangeley/modules/builds/Makefile +++ /dev/null @@ -1,6 +0,0 @@ -KERNELS := onl-kernel-3.16-lts-x86-64-all:amd64 -KMODULES := $(wildcard *.c) -VENDOR := quanta -BASENAME := x86-64-quanta-ly6-rangeley -ARCH := x86_64 -include $(ONL)/make/kmodule.mk diff --git a/packages/platforms/quanta/x86-64/ly6-rangeley/modules/builds/quanta-ly6-i2c-mux.c b/packages/platforms/quanta/x86-64/ly6-rangeley/modules/builds/quanta-ly6-i2c-mux.c deleted file mode 100644 index 2ec388662..000000000 --- a/packages/platforms/quanta/x86-64/ly6-rangeley/modules/builds/quanta-ly6-i2c-mux.c +++ /dev/null @@ -1,293 +0,0 @@ -/* - * - * - * Copyright 2013, 2014 BigSwitch Networks, Inc. - * - * This program is free software; you can redistribute it - * and/or modify it under the terms ofthe GNU General Public License as - * published by the Free Software Foundation; either version 2 of the License, - * or (at your option) any later version. - * - * - * - * - * An I2C multiplexer driver for the Quanta LY6 - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -/* - * Disable QSFP module reset (n=1..16) - * RST_N_Px1 INTL_Px1 MOD_ASB_Px1 LPMODE_Px1 RST_N_Px2 INTL_Px2 MOD_ASB_Px2 LPMODE_Px2 - * 7 6 5 4 3 2 1 0 - * port 2(n-1)+1 2(n-1)+1 2(n-1)+1 2(n-1)+1 2(n-1) 2(n-1) 2(n-1) 2(n-1) - */ -#define QUANTA_LY6_I2C_MUX_NUM_READ_GPIOS 32 -#define QUANTA_LY6_I2C_MUX_NUM_WRITE_GPIOS 32 -#define QUANTA_LY6_I2C_MUX_NUM_GPIO_GROUPS 4 -#define QUANTA_LY6_I2C_MUX_NUM_GPIOS (QUANTA_LY6_I2C_MUX_NUM_READ_GPIOS + QUANTA_LY6_I2C_MUX_NUM_WRITE_GPIOS) -#define QUANTA_LY6_I2C_MUX_NUM_GPIO_PINS_PER_GROUP (QUANTA_LY6_I2C_MUX_NUM_GPIOS / QUANTA_LY6_I2C_MUX_NUM_GPIO_GROUPS) - -struct quanta_ly6_i2c_mux { - struct i2c_client *client; - struct gpio_chip gpio_chip; - u16 gpio_write_val; -}; - -static const struct i2c_device_id quanta_ly6_i2c_mux_id[] = { - {"quanta_ly6_i2c_mux", 0xf600}, - {} -}; - -MODULE_DEVICE_TABLE(i2c, quanta_ly6_i2c_mux_id); - -/* - * Read 2 bytes once per command, and command should be group 1~4 - */ -static int quanta_ly6_i2c_mux_reg_read(struct i2c_adapter *adap, - struct i2c_client *client, - u8 command, u16 *val) -{ - int ret = -ENODEV; - - if (adap->algo->master_xfer) { - struct i2c_msg msg[2]; - char buf[4]; - - msg[0].addr = client->addr; - msg[0].flags = 0; - msg[0].len = 1; - buf[0] = command; - msg[0].buf = &buf[0]; - - /* always receive 3 bytes, else the PLD freaks out */ - msg[1].addr = client->addr; - msg[1].flags = I2C_M_RD; - msg[1].len = 3; - msg[1].buf = &buf[1]; - - ret = adap->algo->master_xfer(adap, msg, 2); - if (val != NULL && ret > -1) - *val = ((buf[2] << 8) | buf[1]); - } else { - union i2c_smbus_data data; - data.block[0] = 3; /* block transfer length */ - ret = adap->algo->smbus_xfer(adap, client->addr, - client->flags, - I2C_SMBUS_READ, - command, - I2C_SMBUS_I2C_BLOCK_DATA, &data); - if (val != NULL) - *val = ((data.block[2] << 8) | data.block[1]); - } - - return ret; -} - -/* - * Write 3 bytes once per command, and command should be group 1~4 - */ -static int quanta_ly6_i2c_mux_reg_write(struct i2c_adapter *adap, - struct i2c_client *client, - u8 command, u16 val) -{ - int ret = -ENODEV; - - if (adap->algo->master_xfer) { - struct i2c_msg msg; - char buf[4]; - - msg.addr = client->addr; - msg.flags = 0; - msg.len = 3; - buf[0] = command; - buf[1] = (val & 0xff); - buf[2] = ((val >> 8) & 0xff); - buf[3] = 0; - msg.buf = buf; - ret = adap->algo->master_xfer(adap, &msg, 1); - } else { - union i2c_smbus_data data; - - data.block[0] = 3; - data.block[1] = (val & 0xff); - data.block[2] = ((val >> 8) & 0xff); - data.block[3] = 0; - - ret = adap->algo->smbus_xfer(adap, client->addr, - client->flags, - I2C_SMBUS_WRITE, - command, - I2C_SMBUS_I2C_BLOCK_DATA, &data); - } - - return ret; -} - -static void quanta_ly6_i2c_mux_gpio_set(struct gpio_chip *gc, unsigned offset, - int val) -{ - struct quanta_ly6_i2c_mux *data = container_of( - gc, struct quanta_ly6_i2c_mux, gpio_chip); - int ret; - u32 group; - - /* ignore write attempts to input GPIOs */ - if ((offset % 4) == 1 || (offset % 4) == 2) { - dev_warn(&data->client->dev, - "ignoring GPIO write for input for pin %d\n", - offset); - return; - } - - group = (offset / QUANTA_LY6_I2C_MUX_NUM_GPIO_PINS_PER_GROUP) + 1; - ret = quanta_ly6_i2c_mux_reg_read(data->client->adapter, - data->client, - group, - &data->gpio_write_val); - - if (ret < 0) { - dev_err(&data->client->dev, - "quanta_ly6_i2c_mux_reg_read failed\n"); - return; - } - - if (val) - data->gpio_write_val |= (1 << (offset % QUANTA_LY6_I2C_MUX_NUM_GPIO_PINS_PER_GROUP)); - else - data->gpio_write_val &= ~(1 << (offset % QUANTA_LY6_I2C_MUX_NUM_GPIO_PINS_PER_GROUP)); - - quanta_ly6_i2c_mux_reg_write( - data->client->adapter, data->client, - group, - data->gpio_write_val); -} - -static int quanta_ly6_i2c_mux_gpio_get(struct gpio_chip *gc, unsigned offset) -{ - int ret; - u16 buf; - u32 group; - struct quanta_ly6_i2c_mux *data = container_of( - gc, struct quanta_ly6_i2c_mux, gpio_chip); - - if (offset >= (QUANTA_LY6_I2C_MUX_NUM_GPIOS)) { - offset -= (QUANTA_LY6_I2C_MUX_NUM_GPIOS); - } - - group = (offset / QUANTA_LY6_I2C_MUX_NUM_GPIO_PINS_PER_GROUP) + 1; - buf = 0; - ret = quanta_ly6_i2c_mux_reg_read(data->client->adapter, - data->client, - group, - &buf); - - if (ret < 0) { - dev_err(&data->client->dev, - "quanta_ly6_i2c_mux_reg_read failed\n"); - return 0; - } - return (buf & (1 << (offset % QUANTA_LY6_I2C_MUX_NUM_GPIO_PINS_PER_GROUP))) ? 1 : 0; -} - -static struct gpio_chip quanta_ly6_i2c_mux_gpio_chip = { - .label = "quanta_ly6_i2c_mux_gpio_chip", - .owner = THIS_MODULE, - .ngpio = QUANTA_LY6_I2C_MUX_NUM_READ_GPIOS + QUANTA_LY6_I2C_MUX_NUM_WRITE_GPIOS, - .base = -1, - .set = quanta_ly6_i2c_mux_gpio_set, - .get = quanta_ly6_i2c_mux_gpio_get, -}; - -static int quanta_ly6_i2c_mux_probe(struct i2c_client *client, - const struct i2c_device_id *id) -{ - struct i2c_adapter *adap = client->adapter; - struct pca953x_platform_data *pdata; - struct quanta_ly6_i2c_mux *data; - int ret = -ENODEV, gpio_base = -1; - - if (!i2c_check_functionality(adap, I2C_FUNC_SMBUS_BYTE_DATA)) - goto err; - - data = kzalloc(sizeof(struct quanta_ly6_i2c_mux), GFP_KERNEL); - if (!data) { - ret = -ENOMEM; - goto err; - } - - i2c_set_clientdata(client, data); - data->client = client; - - if (i2c_smbus_write_byte(client, 0) < 0) { - dev_warn(&client->dev, "probe failed\n"); - goto exit_free; - } - - data->gpio_chip = quanta_ly6_i2c_mux_gpio_chip; - data->gpio_chip.dev = &client->dev; - data->gpio_write_val = 0xff; - - pdata = client->dev.platform_data; - if(pdata) { - gpio_base = (int) pdata->gpio_base; - } - data->gpio_chip.base = gpio_base; - - ret = gpiochip_add(&data->gpio_chip); - if (ret) { - dev_err(&client->dev, "failed to register GPIOs\n"); - goto exit_free; - } - - dev_info(&client->dev, - "registered GPIOs for I2C mux %s (%d read, %d write)\n", - client->name, - QUANTA_LY6_I2C_MUX_NUM_READ_GPIOS, - QUANTA_LY6_I2C_MUX_NUM_WRITE_GPIOS); - - return 0; - -exit_free: - kfree(data); -err: - return ret; -} - -static int quanta_ly6_i2c_mux_remove(struct i2c_client *client) -{ - struct quanta_ly6_i2c_mux *data = i2c_get_clientdata(client); - int ret; - - ret = gpiochip_remove(&data->gpio_chip); - if (ret) - return ret; - - kfree(data); - return 0; -} - -static struct i2c_driver quanta_ly6_i2c_mux_driver = { - .driver = { - .name = "quanta_ly6_i2c_mux", - .owner = THIS_MODULE, - }, - .probe = quanta_ly6_i2c_mux_probe, - .remove = quanta_ly6_i2c_mux_remove, - .id_table = quanta_ly6_i2c_mux_id, -}; - -module_i2c_driver(quanta_ly6_i2c_mux_driver); - -MODULE_AUTHOR("QCT Technical "); -MODULE_DESCRIPTION("Quanta LY6 I2C multiplexer driver"); -MODULE_LICENSE("GPL"); diff --git a/packages/platforms/quanta/x86-64/ly6-rangeley/modules/builds/quanta_platform_ly6.c b/packages/platforms/quanta/x86-64/ly6-rangeley/modules/builds/quanta_platform_ly6.c deleted file mode 100755 index f8a937137..000000000 --- a/packages/platforms/quanta/x86-64/ly6-rangeley/modules/builds/quanta_platform_ly6.c +++ /dev/null @@ -1,333 +0,0 @@ -/* - * 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-ly6" - -#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_quanta_ly6_i2c_mux, - i2c_type_24c02, - i2c_type_pmbus, - i2c_type_quanta_ly6_hwmon, -}; - -char *i2c_type_names[] = { - "spd", - "ds1339", - "pca9546", - "pca9548", - "pca9554", - "pca9555", - "pca9698", - "quanta_ly6_i2c_mux", - "24c02", - "pmbus", - "quanta_ly6_hwmon", -}; - -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_ly6_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_quanta_ly6_hwmon, .addr = 0x4e, .name = "PSoc\0" }, - { .parent_bus = (0x00 + 0), .type = i2c_type_spd, .addr = 0x52, .name = "SPD\0" }, - { .parent_bus = (0x00 + 0), .type = i2c_type_rtc, .addr = 0x68, .name = "RTC\0" }, - { .parent_bus = (0x00 + 0), .type = i2c_type_pca9548, .addr = 0x77, .busno = 0x10, .name = "PCA9548_1\0" }, - - { .parent_bus = (0x10 + 0), .type = i2c_type_pca9548, .addr = 0x73, .busno = 0x20, .name = "PCA9548(SFP_1-8)\0" }, - { .parent_bus = (0x10 + 1), .type = i2c_type_pca9548, .addr = 0x74, .busno = 0x28, .name = "PCA9548(SFP_9-16)\0" }, - { .parent_bus = (0x10 + 2), .type = i2c_type_pca9548, .addr = 0x75, .busno = 0x30, .name = "PCA9548(SFP_17-24)\0" }, - { .parent_bus = (0x10 + 3), .type = i2c_type_pca9548, .addr = 0x76, .busno = 0x38, .name = "PCA9548(SFP_25-32)\0" }, - { .parent_bus = (0x10 + 4), .type = i2c_type_quanta_ly6_i2c_mux, .addr = 0x3a, .name = "quanta_ly6_i2c_mux1\0" }, - { .parent_bus = (0x10 + 5), .type = i2c_type_quanta_ly6_i2c_mux, .addr = 0x3b, .name = "quanta_ly6_i2c_mux2\0" }, - { .parent_bus = (0x10 + 6), .type = i2c_type_pca9555, .addr = 0x24, .name = "PCA9555_3(FAN)\0" }, - { .parent_bus = (0x10 + 7), .type = i2c_type_pca9555, .addr = 0x23, .name = "PCA9555_4(QSFP_EN)\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\0" }, - { .parent_bus = (0x18 + 0), .type = i2c_type_pmbus, .addr = 0x58, .name = "PSU_1\0" }, /* RPSU 1 */ - { .parent_bus = (0x18 + 1), .type = i2c_type_pmbus, .addr = 0x59, .name = "PSU_2\0" }, /* RPSU 2 */ - { .parent_bus = (0x18 + 2), .type = i2c_type_pca9555, .addr = 0x26, .name = "PCA9555_PSU\0" }, - { .parent_bus = (0x18 + 3), .type = i2c_type_24c02, .addr = 0x54, .name = "Board_EEPROM\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 - -/* <--auto.start.xmacro(ALL).define> */ -/* */ - -/* <--auto.start.xenum(ALL).define> */ -/* */ - - diff --git a/packages/platforms/quanta/x86-64/ly6-rangeley/onlp/builds/x86_64_quanta_ly6_rangeley/module/inc/x86_64_quanta_ly6_rangeley/x86_64_quanta_ly6_rangeley_config.h b/packages/platforms/quanta/x86-64/ly6-rangeley/onlp/builds/x86_64_quanta_ly6_rangeley/module/inc/x86_64_quanta_ly6_rangeley/x86_64_quanta_ly6_rangeley_config.h deleted file mode 100644 index 886bdca2f..000000000 --- a/packages/platforms/quanta/x86-64/ly6-rangeley/onlp/builds/x86_64_quanta_ly6_rangeley/module/inc/x86_64_quanta_ly6_rangeley/x86_64_quanta_ly6_rangeley_config.h +++ /dev/null @@ -1,167 +0,0 @@ -/**************************************************************************//** - * - * @file - * @brief x86_64_quanta_ly6_rangeley Configuration Header - * - * @addtogroup x86_64_quanta_ly6_rangeley-config - * @{ - * - *****************************************************************************/ -#ifndef __X86_64_QUANTA_LY6_RANGELEY_CONFIG_H__ -#define __X86_64_QUANTA_LY6_RANGELEY_CONFIG_H__ - -#ifdef GLOBAL_INCLUDE_CUSTOM_CONFIG -#include -#endif -#ifdef X86_64_QUANTA_LY6_RANGELEY_INCLUDE_CUSTOM_CONFIG -#include -#endif - -/* */ -#include -/** - * X86_64_QUANTA_LY6_RANGELEY_CONFIG_INCLUDE_LOGGING - * - * Include or exclude logging. */ - - -#ifndef X86_64_QUANTA_LY6_RANGELEY_CONFIG_INCLUDE_LOGGING -#define X86_64_QUANTA_LY6_RANGELEY_CONFIG_INCLUDE_LOGGING 1 -#endif - -/** - * X86_64_QUANTA_LY6_RANGELEY_CONFIG_LOG_OPTIONS_DEFAULT - * - * Default enabled log options. */ - - -#ifndef X86_64_QUANTA_LY6_RANGELEY_CONFIG_LOG_OPTIONS_DEFAULT -#define X86_64_QUANTA_LY6_RANGELEY_CONFIG_LOG_OPTIONS_DEFAULT AIM_LOG_OPTIONS_DEFAULT -#endif - -/** - * X86_64_QUANTA_LY6_RANGELEY_CONFIG_LOG_BITS_DEFAULT - * - * Default enabled log bits. */ - - -#ifndef X86_64_QUANTA_LY6_RANGELEY_CONFIG_LOG_BITS_DEFAULT -#define X86_64_QUANTA_LY6_RANGELEY_CONFIG_LOG_BITS_DEFAULT AIM_LOG_BITS_DEFAULT -#endif - -/** - * X86_64_QUANTA_LY6_RANGELEY_CONFIG_LOG_CUSTOM_BITS_DEFAULT - * - * Default enabled custom log bits. */ - - -#ifndef X86_64_QUANTA_LY6_RANGELEY_CONFIG_LOG_CUSTOM_BITS_DEFAULT -#define X86_64_QUANTA_LY6_RANGELEY_CONFIG_LOG_CUSTOM_BITS_DEFAULT 0 -#endif - -/** - * X86_64_QUANTA_LY6_RANGELEY_CONFIG_PORTING_STDLIB - * - * Default all porting macros to use the C standard libraries. */ - - -#ifndef X86_64_QUANTA_LY6_RANGELEY_CONFIG_PORTING_STDLIB -#define X86_64_QUANTA_LY6_RANGELEY_CONFIG_PORTING_STDLIB 1 -#endif - -/** - * X86_64_QUANTA_LY6_RANGELEY_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS - * - * Include standard library headers for stdlib porting macros. */ - - -#ifndef X86_64_QUANTA_LY6_RANGELEY_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS -#define X86_64_QUANTA_LY6_RANGELEY_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS X86_64_QUANTA_LY6_RANGELEY_CONFIG_PORTING_STDLIB -#endif - -/** - * X86_64_QUANTA_LY6_RANGELEY_CONFIG_INCLUDE_UCLI - * - * Include generic uCli support. */ - - -#ifndef X86_64_QUANTA_LY6_RANGELEY_CONFIG_INCLUDE_UCLI -#define X86_64_QUANTA_LY6_RANGELEY_CONFIG_INCLUDE_UCLI 0 -#endif - -/** - * X86_64_QUANTA_LY6_RANGELEY_CONFIG_SYSFAN_RPM_FAILURE_THRESHOLD - * - * RPM Threshold at which the fan is considered to have failed. */ - - -#ifndef X86_64_QUANTA_LY6_RANGELEY_CONFIG_SYSFAN_RPM_FAILURE_THRESHOLD -#define X86_64_QUANTA_LY6_RANGELEY_CONFIG_SYSFAN_RPM_FAILURE_THRESHOLD 3000 -#endif - -/** - * X86_64_QUANTA_LY6_RANGELEY_CONFIG_SYSFAN_F2B_RPM_MAX - * - * Maximum system front-to-back fan speed. */ - - -#ifndef X86_64_QUANTA_LY6_RANGELEY_CONFIG_SYSFAN_F2B_RPM_MAX -#define X86_64_QUANTA_LY6_RANGELEY_CONFIG_SYSFAN_F2B_RPM_MAX 18000 -#endif - -/** - * X86_64_QUANTA_LY6_RANGELEY_CONFIG_SYSFAN_B2F_RPM_MAX - * - * Maximum system back-to-front fan speed. */ - - -#ifndef X86_64_QUANTA_LY6_RANGELEY_CONFIG_SYSFAN_B2F_RPM_MAX -#define X86_64_QUANTA_LY6_RANGELEY_CONFIG_SYSFAN_B2F_RPM_MAX 18000 -#endif - -/** - * X86_64_QUANTA_LY6_RANGELEY_CONFIG_PHY_RESET_DELAY_MS - * - * Time to hold Phy GPIO in reset, in ms */ - - -#ifndef X86_64_QUANTA_LY6_RANGELEY_CONFIG_PHY_RESET_DELAY_MS -#define X86_64_QUANTA_LY6_RANGELEY_CONFIG_PHY_RESET_DELAY_MS 100 -#endif - - - -/** - * All compile time options can be queried or displayed - */ - -/** Configuration settings structure. */ -typedef struct x86_64_quanta_ly6_rangeley_config_settings_s { - /** name */ - const char* name; - /** value */ - const char* value; -} x86_64_quanta_ly6_rangeley_config_settings_t; - -/** Configuration settings table. */ -/** x86_64_quanta_ly6_rangeley_config_settings table. */ -extern x86_64_quanta_ly6_rangeley_config_settings_t x86_64_quanta_ly6_rangeley_config_settings[]; - -/** - * @brief Lookup a configuration setting. - * @param setting The name of the configuration option to lookup. - */ -const char* x86_64_quanta_ly6_rangeley_config_lookup(const char* setting); - -/** - * @brief Show the compile-time configuration. - * @param pvs The output stream. - */ -int x86_64_quanta_ly6_rangeley_config_show(struct aim_pvs_s* pvs); - -/* */ - -#include "x86_64_quanta_ly6_rangeley_porting.h" - -#endif /* __X86_64_QUANTA_LY6_RANGELEY_CONFIG_H__ */ -/* @} */ diff --git a/packages/platforms/quanta/x86-64/ly6-rangeley/onlp/builds/x86_64_quanta_ly6_rangeley/module/inc/x86_64_quanta_ly6_rangeley/x86_64_quanta_ly6_rangeley_dox.h b/packages/platforms/quanta/x86-64/ly6-rangeley/onlp/builds/x86_64_quanta_ly6_rangeley/module/inc/x86_64_quanta_ly6_rangeley/x86_64_quanta_ly6_rangeley_dox.h deleted file mode 100644 index 2842f2cbd..000000000 --- a/packages/platforms/quanta/x86-64/ly6-rangeley/onlp/builds/x86_64_quanta_ly6_rangeley/module/inc/x86_64_quanta_ly6_rangeley/x86_64_quanta_ly6_rangeley_dox.h +++ /dev/null @@ -1,26 +0,0 @@ -/**************************************************************************//** - * - * x86_64_quanta_ly6_rangeley Doxygen Header - * - *****************************************************************************/ -#ifndef __X86_64_QUANTA_LY6_RANGELEY_DOX_H__ -#define __X86_64_QUANTA_LY6_RANGELEY_DOX_H__ - -/** - * @defgroup x86_64_quanta_ly6_rangeley x86_64_quanta_ly6_rangeley - x86_64_quanta_ly6_rangeley Description - * - -The documentation overview for this module should go here. - - * - * @{ - * - * @defgroup x86_64_quanta_ly6_rangeley-x86_64_quanta_ly6_rangeley Public Interface - * @defgroup x86_64_quanta_ly6_rangeley-config Compile Time Configuration - * @defgroup x86_64_quanta_ly6_rangeley-porting Porting Macros - * - * @} - * - */ - -#endif /* __X86_64_QUANTA_LY6_RANGELEY_DOX_H__ */ diff --git a/packages/platforms/quanta/x86-64/ly6-rangeley/onlp/builds/x86_64_quanta_ly6_rangeley/module/inc/x86_64_quanta_ly6_rangeley/x86_64_quanta_ly6_rangeley_gpio_table.h b/packages/platforms/quanta/x86-64/ly6-rangeley/onlp/builds/x86_64_quanta_ly6_rangeley/module/inc/x86_64_quanta_ly6_rangeley/x86_64_quanta_ly6_rangeley_gpio_table.h deleted file mode 100755 index e6eefd4fa..000000000 --- a/packages/platforms/quanta/x86-64/ly6-rangeley/onlp/builds/x86_64_quanta_ly6_rangeley/module/inc/x86_64_quanta_ly6_rangeley/x86_64_quanta_ly6_rangeley_gpio_table.h +++ /dev/null @@ -1,57 +0,0 @@ -#ifndef __X86_64_QUANTA_LY6_RANGELEY_GPIO_TABLE_H__ -#define __X86_64_QUANTA_LY6_RANGELEY_GPIO_TABLE_H__ - -/* - * defined within platform/quanta_switch.c - * Quanta Switch Platform driver - */ -#define QUANTA_LY6_PCA953x_GPIO(P1, P2) (P1*8+P2) - -#define QUANTA_LY6_PCA9555_GPIO_SIZE 0x10 - -#define QUANTA_LY6_I2C_GPIO_CPU_BASE 0x40 - -#define QUANTA_LY6_CPU_BOARD_GPIO_BASE (QUANTA_LY6_I2C_GPIO_CPU_BASE) -#define QUANTA_LY6_CPU_BOARD_SYS_P1 (QUANTA_LY6_CPU_BOARD_GPIO_BASE + QUANTA_LY6_PCA953x_GPIO(1,2)) -#define QUANTA_LY6_CPU_BOARD_SYS_P2 (QUANTA_LY6_CPU_BOARD_GPIO_BASE + QUANTA_LY6_PCA953x_GPIO(1,3)) - -#define QUANTA_LY6_I2C_GPIO_BASE 0x80 - -#define QUANTA_LY6_CPLD_QSFP_GPIO_BASE (QUANTA_LY6_I2C_GPIO_BASE) -#define QUANTA_LY6_CPLD_QSFP_GPIO_SIZE 0x40 -#define QUANTA_LY6_CPLD_QSFP_PRSNT(port) (QUANTA_LY6_CPLD_QSFP_GPIO_BASE + ((port%2) ? (port) : (port-2)) * 4 + 1) - -/* 2 cpld for 32 ports */ -#define QUANTA_LY6_FAN_GPIO_BASE (QUANTA_LY6_CPLD_QSFP_GPIO_BASE + QUANTA_LY6_CPLD_QSFP_GPIO_SIZE * 2) -#define QUANTA_LY6_FAN_GPIO_SIZE QUANTA_LY6_PCA9555_GPIO_SIZE -#define QUANTA_LY6_FAN_PRSNT_N_1 (QUANTA_LY6_FAN_GPIO_BASE + QUANTA_LY6_PCA953x_GPIO(0,4)) -#define QUANTA_LY6_FAN_PRSNT_N_2 (QUANTA_LY6_FAN_GPIO_BASE + QUANTA_LY6_PCA953x_GPIO(0,5)) -#define QUANTA_LY6_FAN_PRSNT_N_3 (QUANTA_LY6_FAN_GPIO_BASE + QUANTA_LY6_PCA953x_GPIO(0,6)) -#define QUANTA_LY6_FAN_BF_DET1 (QUANTA_LY6_FAN_GPIO_BASE + QUANTA_LY6_PCA953x_GPIO(1,0)) -#define QUANTA_LY6_FAN_BF_DET2 (QUANTA_LY6_FAN_GPIO_BASE + QUANTA_LY6_PCA953x_GPIO(1,1)) -#define QUANTA_LY6_FAN_BF_DET3 (QUANTA_LY6_FAN_GPIO_BASE + QUANTA_LY6_PCA953x_GPIO(1,2)) -#define QUANTA_LY6_FAN_FAIL_LED_1 (QUANTA_LY6_FAN_GPIO_BASE + QUANTA_LY6_PCA953x_GPIO(1,4)) -#define QUANTA_LY6_FAN_FAIL_LED_2 (QUANTA_LY6_FAN_GPIO_BASE + QUANTA_LY6_PCA953x_GPIO(1,5)) -#define QUANTA_LY6_FAN_FAIL_LED_3 (QUANTA_LY6_FAN_GPIO_BASE + QUANTA_LY6_PCA953x_GPIO(1,6)) - -#define QUANTA_LY6_QSFP_EN_GPIO_BASE (QUANTA_LY6_FAN_GPIO_BASE + QUANTA_LY6_FAN_GPIO_SIZE) -#define QUANTA_LY6_QSFP_EN_GPIO_SIZE QUANTA_LY6_PCA9555_GPIO_SIZE -#define QUANTA_LY6_QSFP_EN_GPIO_P3V3_PW_GD (QUANTA_LY6_QSFP_EN_GPIO_BASE + QUANTA_LY6_PCA953x_GPIO(0,4)) -#define QUANTA_LY6_QSFP_EN_GPIO_P3V3_PW_EN (QUANTA_LY6_QSFP_EN_GPIO_BASE + QUANTA_LY6_PCA953x_GPIO(1,0)) - -#define QUANTA_LY6_PSU_GPIO_BASE (QUANTA_LY6_QSFP_EN_GPIO_BASE + QUANTA_LY6_QSFP_EN_GPIO_SIZE) -#define QUANTA_LY6_PSU_GPIO_SIZE QUANTA_LY6_PCA9555_GPIO_SIZE -#define QUANTA_LY6_PSU_GPIO_PSU1_PRSNT_N (QUANTA_LY6_PSU_GPIO_BASE + QUANTA_LY6_PCA953x_GPIO(0,0)) -#define QUANTA_LY6_PSU_GPIO_PSU1_PWRGD (QUANTA_LY6_PSU_GPIO_BASE + QUANTA_LY6_PCA953x_GPIO(0,1)) -#define QUANTA_LY6_PSU_GPIO_PSU2_PRSNT_N (QUANTA_LY6_PSU_GPIO_BASE + QUANTA_LY6_PCA953x_GPIO(0,3)) -#define QUANTA_LY6_PSU_GPIO_PSU2_PWRGD (QUANTA_LY6_PSU_GPIO_BASE + QUANTA_LY6_PCA953x_GPIO(0,4)) -#define QUANTA_LY6_PSU_GPIO_PSU1_AC_OK (QUANTA_LY6_PSU_GPIO_BASE + QUANTA_LY6_PCA953x_GPIO(0,6)) -#define QUANTA_LY6_PSU_GPIO_PSU2_AC_OK (QUANTA_LY6_PSU_GPIO_BASE + QUANTA_LY6_PCA953x_GPIO(0,7)) -#define QUANTA_LY6_PSU_GPIO_PSU1_GREEN_R (QUANTA_LY6_PSU_GPIO_BASE + QUANTA_LY6_PCA953x_GPIO(1,2)) -#define QUANTA_LY6_PSU_GPIO_PSU1_RED_R (QUANTA_LY6_PSU_GPIO_BASE + QUANTA_LY6_PCA953x_GPIO(1,3)) -#define QUANTA_LY6_PSU_GPIO_PSU2_GREEN_R (QUANTA_LY6_PSU_GPIO_BASE + QUANTA_LY6_PCA953x_GPIO(1,4)) -#define QUANTA_LY6_PSU_GPIO_PSU2_RED_R (QUANTA_LY6_PSU_GPIO_BASE + QUANTA_LY6_PCA953x_GPIO(1,5)) -#define QUANTA_LY6_PSU_GPIO_FAN_GREEN_R (QUANTA_LY6_PSU_GPIO_BASE + QUANTA_LY6_PCA953x_GPIO(1,6)) -#define QUANTA_LY6_PSU_GPIO_FAN_RED_R (QUANTA_LY6_PSU_GPIO_BASE + QUANTA_LY6_PCA953x_GPIO(1,7)) - -#endif /* __X86_64_QUANTA_LY6_RANGELEY_GPIO_TABLE_H__ */ diff --git a/packages/platforms/quanta/x86-64/ly6-rangeley/onlp/builds/x86_64_quanta_ly6_rangeley/module/inc/x86_64_quanta_ly6_rangeley/x86_64_quanta_ly6_rangeley_porting.h b/packages/platforms/quanta/x86-64/ly6-rangeley/onlp/builds/x86_64_quanta_ly6_rangeley/module/inc/x86_64_quanta_ly6_rangeley/x86_64_quanta_ly6_rangeley_porting.h deleted file mode 100644 index 25bbfa238..000000000 --- a/packages/platforms/quanta/x86-64/ly6-rangeley/onlp/builds/x86_64_quanta_ly6_rangeley/module/inc/x86_64_quanta_ly6_rangeley/x86_64_quanta_ly6_rangeley_porting.h +++ /dev/null @@ -1,77 +0,0 @@ -/**************************************************************************//** - * - * @file - * @brief x86_64_quanta_ly6_rangeley Porting Macros. - * - * @addtogroup x86_64_quanta_ly6_rangeley-porting - * @{ - * - *****************************************************************************/ -#ifndef __X86_64_QUANTA_LY6_RANGELEY_PORTING_H__ -#define __X86_64_QUANTA_LY6_RANGELEY_PORTING_H__ - - -/* */ -#if X86_64_QUANTA_LY6_RANGELEY_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS == 1 -#include -#include -#include -#include -#include -#endif - -#ifndef X86_64_QUANTA_LY6_RANGELEY_MEMSET - #if defined(GLOBAL_MEMSET) - #define X86_64_QUANTA_LY6_RANGELEY_MEMSET GLOBAL_MEMSET - #elif X86_64_QUANTA_LY6_RANGELEY_CONFIG_PORTING_STDLIB == 1 - #define X86_64_QUANTA_LY6_RANGELEY_MEMSET memset - #else - #error The macro X86_64_QUANTA_LY6_RANGELEY_MEMSET is required but cannot be defined. - #endif -#endif - -#ifndef X86_64_QUANTA_LY6_RANGELEY_MEMCPY - #if defined(GLOBAL_MEMCPY) - #define X86_64_QUANTA_LY6_RANGELEY_MEMCPY GLOBAL_MEMCPY - #elif X86_64_QUANTA_LY6_RANGELEY_CONFIG_PORTING_STDLIB == 1 - #define X86_64_QUANTA_LY6_RANGELEY_MEMCPY memcpy - #else - #error The macro X86_64_QUANTA_LY6_RANGELEY_MEMCPY is required but cannot be defined. - #endif -#endif - -#ifndef X86_64_QUANTA_LY6_RANGELEY_VSNPRINTF - #if defined(GLOBAL_VSNPRINTF) - #define X86_64_QUANTA_LY6_RANGELEY_VSNPRINTF GLOBAL_VSNPRINTF - #elif X86_64_QUANTA_LY6_RANGELEY_CONFIG_PORTING_STDLIB == 1 - #define X86_64_QUANTA_LY6_RANGELEY_VSNPRINTF vsnprintf - #else - #error The macro X86_64_QUANTA_LY6_RANGELEY_VSNPRINTF is required but cannot be defined. - #endif -#endif - -#ifndef X86_64_QUANTA_LY6_RANGELEY_SNPRINTF - #if defined(GLOBAL_SNPRINTF) - #define X86_64_QUANTA_LY6_RANGELEY_SNPRINTF GLOBAL_SNPRINTF - #elif X86_64_QUANTA_LY6_RANGELEY_CONFIG_PORTING_STDLIB == 1 - #define X86_64_QUANTA_LY6_RANGELEY_SNPRINTF snprintf - #else - #error The macro X86_64_QUANTA_LY6_RANGELEY_SNPRINTF is required but cannot be defined. - #endif -#endif - -#ifndef X86_64_QUANTA_LY6_RANGELEY_STRLEN - #if defined(GLOBAL_STRLEN) - #define X86_64_QUANTA_LY6_RANGELEY_STRLEN GLOBAL_STRLEN - #elif X86_64_QUANTA_LY6_RANGELEY_CONFIG_PORTING_STDLIB == 1 - #define X86_64_QUANTA_LY6_RANGELEY_STRLEN strlen - #else - #error The macro X86_64_QUANTA_LY6_RANGELEY_STRLEN is required but cannot be defined. - #endif -#endif - -/* */ - - -#endif /* __X86_64_QUANTA_LY6_RANGELEY_PORTING_H__ */ -/* @} */ diff --git a/packages/platforms/quanta/x86-64/ly6-rangeley/onlp/builds/x86_64_quanta_ly6_rangeley/module/make.mk b/packages/platforms/quanta/x86-64/ly6-rangeley/onlp/builds/x86_64_quanta_ly6_rangeley/module/make.mk deleted file mode 100644 index 89cba9e80..000000000 --- a/packages/platforms/quanta/x86-64/ly6-rangeley/onlp/builds/x86_64_quanta_ly6_rangeley/module/make.mk +++ /dev/null @@ -1,10 +0,0 @@ -############################################################################### -# -# -# -############################################################################### -THIS_DIR := $(dir $(lastword $(MAKEFILE_LIST))) -x86_64_quanta_ly6_rangeley_INCLUDES := -I $(THIS_DIR)inc -x86_64_quanta_ly6_rangeley_INTERNAL_INCLUDES := -I $(THIS_DIR)src -x86_64_quanta_ly6_rangeley_DEPENDMODULE_ENTRIES := init:x86_64_quanta_ly6_rangeley ucli:x86_64_quanta_ly6_rangeley - diff --git a/packages/platforms/quanta/x86-64/ly6-rangeley/onlp/builds/x86_64_quanta_ly6_rangeley/module/src/Makefile b/packages/platforms/quanta/x86-64/ly6-rangeley/onlp/builds/x86_64_quanta_ly6_rangeley/module/src/Makefile deleted file mode 100644 index f31014f69..000000000 --- a/packages/platforms/quanta/x86-64/ly6-rangeley/onlp/builds/x86_64_quanta_ly6_rangeley/module/src/Makefile +++ /dev/null @@ -1,9 +0,0 @@ -############################################################################### -# -# Local source generation targets. -# -############################################################################### - -ucli: - @../../../../tools/uclihandlers.py x86_64_quanta_ly6_rangeley_ucli.c - diff --git a/packages/platforms/quanta/x86-64/ly6-rangeley/onlp/builds/x86_64_quanta_ly6_rangeley/module/src/fani.c b/packages/platforms/quanta/x86-64/ly6-rangeley/onlp/builds/x86_64_quanta_ly6_rangeley/module/src/fani.c deleted file mode 100755 index 219602af9..000000000 --- a/packages/platforms/quanta/x86-64/ly6-rangeley/onlp/builds/x86_64_quanta_ly6_rangeley/module/src/fani.c +++ /dev/null @@ -1,168 +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 "x86_64_quanta_ly6_rangeley_int.h" -#include "x86_64_quanta_ly6_rangeley_log.h" - -#include -#include - -int -onlp_fani_init(void) -{ - return ONLP_STATUS_OK; -} - -struct fan_gpio_s { - int present; - int fan_dir_detect; -}; - -static struct fan_gpio_s fan_gpio[] = { - {}, /* Not used */ - { .present = QUANTA_LY6_FAN_PRSNT_N_1, .fan_dir_detect = QUANTA_LY6_FAN_BF_DET1 }, - { .present = QUANTA_LY6_FAN_PRSNT_N_2, .fan_dir_detect = QUANTA_LY6_FAN_BF_DET2 }, - { .present = QUANTA_LY6_FAN_PRSNT_N_3, .fan_dir_detect = QUANTA_LY6_FAN_BF_DET3 }, - {}, /* Not used */ - { .present = QUANTA_LY6_FAN_PRSNT_N_1, .fan_dir_detect = QUANTA_LY6_FAN_BF_DET1 }, - { .present = QUANTA_LY6_FAN_PRSNT_N_2, .fan_dir_detect = QUANTA_LY6_FAN_BF_DET2 }, - { .present = QUANTA_LY6_FAN_PRSNT_N_3, .fan_dir_detect = QUANTA_LY6_FAN_BF_DET3 }, - {}, /* Not used */ -}; - -static int -sys_fan_info_get__(onlp_fan_info_t* info, int id) -{ - int value = 0; - int rv; - - if(onlp_gpio_get(fan_gpio[id].present, &value) == ONLP_STATUS_OK - && value == 0) { - info->status = ONLP_FAN_STATUS_PRESENT; - if(onlp_gpio_get(fan_gpio[id].fan_dir_detect, &value) == ONLP_STATUS_OK - && value == 0) { - info->status |= ONLP_FAN_STATUS_F2B; - info->caps |= ONLP_FAN_CAPS_F2B; - } - else { - info->status |= ONLP_FAN_STATUS_B2F; - info->caps |= ONLP_FAN_CAPS_B2F; - } - } - else { - info->status = ONLP_FAN_STATUS_FAILED; - } - - rv = onlp_file_read_int(&info->rpm, - SYS_HWMON_PREFIX "/fan%d_input", id); - - if(rv == ONLP_STATUS_E_INTERNAL) { - return rv; - } - - if(rv == ONLP_STATUS_E_MISSING) { - info->status &= ~1; - return 0; - } - - if(info->rpm <= X86_64_QUANTA_LY6_RANGELEY_CONFIG_SYSFAN_RPM_FAILURE_THRESHOLD) { - info->status |= ONLP_FAN_STATUS_FAILED; - } - - /* - * Calculate percentage based on current speed and the maximum. - */ - info->caps |= ONLP_FAN_CAPS_GET_PERCENTAGE; - if(info->status & ONLP_FAN_STATUS_F2B) { - info->percentage = (int) ((double) info->rpm * (double)100 / (double)X86_64_QUANTA_LY6_RANGELEY_CONFIG_SYSFAN_F2B_RPM_MAX); - } - if(info->status & ONLP_FAN_STATUS_B2F) { - info->percentage = (int) ((double) info->rpm * (double)100 / (double)X86_64_QUANTA_LY6_RANGELEY_CONFIG_SYSFAN_B2F_RPM_MAX); - } - - return 0; -} - -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, "Left (Module/Fan 1/1)", 0}, ONLP_FAN_STATUS_PRESENT }, - { { FAN_OID_FAN2, "Center(Module/Fan 2/1)", 0}, ONLP_FAN_STATUS_PRESENT }, - { { FAN_OID_FAN3, "Right (Module/Fan 3/1)", 0}, ONLP_FAN_STATUS_PRESENT }, - { { FAN_OID_FAN4, "Reserved (Module/Fan 4/1)", 0}, ONLP_FAN_STATUS_PRESENT }, - { { FAN_OID_FAN5, "Left (Module/Fan 1/2)", 0}, ONLP_FAN_STATUS_PRESENT }, - { { FAN_OID_FAN6, "Center(Module/Fan 2/2)", 0}, ONLP_FAN_STATUS_PRESENT }, - { { FAN_OID_FAN7, "Right (Module/Fan 3/2)", 0}, ONLP_FAN_STATUS_PRESENT }, - { { FAN_OID_FAN8, "Reserved (Module/Fan 4/2)", 0}, ONLP_FAN_STATUS_PRESENT }, - { { FAN_OID_FAN9, "PSU-1 Fan", 0 }, ONLP_FAN_STATUS_PRESENT }, - { { FAN_OID_FAN10, "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: - case FAN_ID_FAN3: - case FAN_ID_FAN4: - case FAN_ID_FAN5: - case FAN_ID_FAN6: - case FAN_ID_FAN7: - case FAN_ID_FAN8: - return sys_fan_info_get__(rv, fid); - break; - - case FAN_ID_FAN9: - case FAN_ID_FAN10: - return psu_fan_info_get__(rv, fid - FAN_ID_FAN9 + 1); - break; - - default: - return ONLP_STATUS_E_INVALID; - break; - } - - return ONLP_STATUS_E_INVALID; -} diff --git a/packages/platforms/quanta/x86-64/ly6-rangeley/onlp/builds/x86_64_quanta_ly6_rangeley/module/src/ledi.c b/packages/platforms/quanta/x86-64/ly6-rangeley/onlp/builds/x86_64_quanta_ly6_rangeley/module/src/ledi.c deleted file mode 100755 index a15f1ea42..000000000 --- a/packages/platforms/quanta/x86-64/ly6-rangeley/onlp/builds/x86_64_quanta_ly6_rangeley/module/src/ledi.c +++ /dev/null @@ -1,210 +0,0 @@ -#include -#include -#include -#include -#include - -#include "x86_64_quanta_ly6_rangeley_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, - } -}; - -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_LY6_CPU_BOARD_SYS_P1, 0); - onlp_gpio_set(QUANTA_LY6_CPU_BOARD_SYS_P2, 1); - } - else if(mode == ONLP_LED_MODE_ORANGE){ - onlp_gpio_set(QUANTA_LY6_CPU_BOARD_SYS_P1, 1); - onlp_gpio_set(QUANTA_LY6_CPU_BOARD_SYS_P2, 0); - } - else{ - onlp_gpio_set(QUANTA_LY6_CPU_BOARD_SYS_P1, 1); - onlp_gpio_set(QUANTA_LY6_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_LY6_PSU_GPIO_FAN_GREEN_R, 1); - onlp_gpio_set(QUANTA_LY6_PSU_GPIO_FAN_RED_R, 0); - } - else if(mode == ONLP_LED_MODE_RED){ - onlp_gpio_set(QUANTA_LY6_PSU_GPIO_FAN_GREEN_R, 0); - onlp_gpio_set(QUANTA_LY6_PSU_GPIO_FAN_RED_R, 1); - } - else{ - onlp_gpio_set(QUANTA_LY6_PSU_GPIO_FAN_GREEN_R, 0); - onlp_gpio_set(QUANTA_LY6_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_LY6_PSU_GPIO_PSU1_GREEN_R, 1); - onlp_gpio_set(QUANTA_LY6_PSU_GPIO_PSU1_RED_R, 0); - } - else if(mode == ONLP_LED_MODE_RED){ - onlp_gpio_set(QUANTA_LY6_PSU_GPIO_PSU1_GREEN_R, 0); - onlp_gpio_set(QUANTA_LY6_PSU_GPIO_PSU1_RED_R, 1); - } - else{ - onlp_gpio_set(QUANTA_LY6_PSU_GPIO_PSU1_GREEN_R, 0); - onlp_gpio_set(QUANTA_LY6_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_LY6_PSU_GPIO_PSU2_GREEN_R, 1); - onlp_gpio_set(QUANTA_LY6_PSU_GPIO_PSU2_RED_R, 0); - } - else if(mode == ONLP_LED_MODE_RED){ - onlp_gpio_set(QUANTA_LY6_PSU_GPIO_PSU2_GREEN_R, 0); - onlp_gpio_set(QUANTA_LY6_PSU_GPIO_PSU2_RED_R, 1); - } - else{ - onlp_gpio_set(QUANTA_LY6_PSU_GPIO_PSU2_GREEN_R, 0); - onlp_gpio_set(QUANTA_LY6_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_LY6_FAN_FAIL_LED_1, 1); - } - else{ - onlp_gpio_set(QUANTA_LY6_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_LY6_FAN_FAIL_LED_2, 1); - } - else{ - onlp_gpio_set(QUANTA_LY6_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_LY6_FAN_FAIL_LED_3, 1); - } - else{ - onlp_gpio_set(QUANTA_LY6_FAN_FAIL_LED_3, 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; - default: - return ONLP_STATUS_E_INTERNAL; - break; - } - - return ONLP_STATUS_OK; -} diff --git a/packages/platforms/quanta/x86-64/ly6-rangeley/onlp/builds/x86_64_quanta_ly6_rangeley/module/src/make.mk b/packages/platforms/quanta/x86-64/ly6-rangeley/onlp/builds/x86_64_quanta_ly6_rangeley/module/src/make.mk deleted file mode 100644 index de2b405da..000000000 --- a/packages/platforms/quanta/x86-64/ly6-rangeley/onlp/builds/x86_64_quanta_ly6_rangeley/module/src/make.mk +++ /dev/null @@ -1,9 +0,0 @@ -############################################################################### -# -# -# -############################################################################### - -LIBRARY := x86_64_quanta_ly6_rangeley -$(LIBRARY)_SUBDIR := $(dir $(lastword $(MAKEFILE_LIST))) -include $(BUILDER)/lib.mk diff --git a/packages/platforms/quanta/x86-64/ly6-rangeley/onlp/builds/x86_64_quanta_ly6_rangeley/module/src/psui.c b/packages/platforms/quanta/x86-64/ly6-rangeley/onlp/builds/x86_64_quanta_ly6_rangeley/module/src/psui.c deleted file mode 100755 index c56837125..000000000 --- a/packages/platforms/quanta/x86-64/ly6-rangeley/onlp/builds/x86_64_quanta_ly6_rangeley/module/src/psui.c +++ /dev/null @@ -1,128 +0,0 @@ -/************************************************************ - * - * - ************************************************************ - * - * - * - ***********************************************************/ -#include -#include -#include -#include -#include -#include -#include "x86_64_quanta_ly6_rangeley_int.h" -#include "x86_64_quanta_ly6_rangeley_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-0058", .present = QUANTA_LY6_PSU_GPIO_PSU1_PRSNT_N, .busno = 24, .addr = 0x58}, - { .path = "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-25/25-0059", .present = QUANTA_LY6_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 LY6 RPSU-1", - 0, - { - FAN_OID_FAN9, - }, - } - }, - { - { - PSU_OID_PSU2, - "Quanta LY6 RPSU-2", - 0, - { - FAN_OID_FAN10, - }, - } - }, -}; - -#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; - uint8_t buffer[ONLP_CONFIG_INFO_STR_MAX]; - int value = -1; - - 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; - - memset(buffer, 0, sizeof(buffer)); - rv = onlp_i2c_block_read(psu_info[pid].busno, psu_info[pid].addr, PMBUS_MFR_MODEL, PMBUS_MFR_MODEL_LEN, buffer, ONLP_I2C_F_FORCE); - if(rv >= 0){ - aim_strlcpy(info->model, (char *) (buffer+1), (buffer[0] + 1)); - } - else{ - strcpy(info->model, "Missing"); - } - - memset(buffer, 0, sizeof(buffer)); - rv = onlp_i2c_block_read(psu_info[pid].busno, psu_info[pid].addr, PMBUS_MFR_SERIAL, PMBUS_MFR_SERIAL_LEN, buffer, ONLP_I2C_F_FORCE); - if(rv >= 0){ - aim_strlcpy(info->serial, (char *) (buffer+1), (buffer[0] + 1)); - } - else{ - strcpy(info->serial, "Missing"); - } - - 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; - /* Empirical */ - info->mvout /= 500; - } - 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/ly6-rangeley/onlp/builds/x86_64_quanta_ly6_rangeley/module/src/sfpi.c b/packages/platforms/quanta/x86-64/ly6-rangeley/onlp/builds/x86_64_quanta_ly6_rangeley/module/src/sfpi.c deleted file mode 100755 index b2aa9dff6..000000000 --- a/packages/platforms/quanta/x86-64/ly6-rangeley/onlp/builds/x86_64_quanta_ly6_rangeley/module/src/sfpi.c +++ /dev/null @@ -1,164 +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. - * - * - ************************************************************ - * - * SFPI Interface for the Quanta LY6 - * - ***********************************************************/ -#include -#include -#include -#include -#include -#include "x86_64_quanta_ly6_rangeley_log.h" - -#include -#include - -/** - * This table maps the presence gpio, reset gpio, and eeprom file - * for each SFP port. - */ -typedef struct sfpmap_s { - int port; - int present_gpio; - const char* reset_gpio; - const char* eeprom; - const char* dom; -} sfpmap_t; - -static sfpmap_t sfpmap__[] = - { - /* CPLD will not always be stable, use eeprom read instead */ - { 1, -1 /* QUANTA_LY6_CPLD_QSFP_PRSNT(1) */ /* 168 */, NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/i2c-32/32-0050/eeprom", NULL }, - { 2, -1 /* QUANTA_LY6_CPLD_QSFP_PRSNT(2) */ /* 172 */, NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/i2c-33/33-0050/eeprom", NULL }, - { 3, -1 /* QUANTA_LY6_CPLD_QSFP_PRSNT(3) */ /* 176 */, NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/i2c-34/34-0050/eeprom", NULL }, - { 4, -1 /* QUANTA_LY6_CPLD_QSFP_PRSNT(4) */ /* 180 */, NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/i2c-35/35-0050/eeprom", NULL }, - { 5, -1 /* QUANTA_LY6_CPLD_QSFP_PRSNT(5) */ /* 184 */, NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/i2c-36/36-0050/eeprom", NULL }, - { 6, -1 /* QUANTA_LY6_CPLD_QSFP_PRSNT(6) */ /* 188 */, NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/i2c-37/37-0050/eeprom", NULL }, - { 7, -1 /* QUANTA_LY6_CPLD_QSFP_PRSNT(7) */ /* 192 */, NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/i2c-38/38-0050/eeprom", NULL }, - { 8, -1 /* QUANTA_LY6_CPLD_QSFP_PRSNT(8) */ /* 196 */, NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/i2c-39/39-0050/eeprom", NULL }, - { 9, -1 /* QUANTA_LY6_CPLD_QSFP_PRSNT(9) */ /* 208 */, NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/i2c-40/40-0050/eeprom", NULL }, - { 10, -1 /* QUANTA_LY6_CPLD_QSFP_PRSNT(10) */ /* 212 */, NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/i2c-41/41-0050/eeprom", NULL }, - { 11, -1 /* QUANTA_LY6_CPLD_QSFP_PRSNT(11) */ /* 216 */, NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/i2c-42/42-0050/eeprom", NULL }, - { 12, -1 /* QUANTA_LY6_CPLD_QSFP_PRSNT(12) */ /* 220 */, NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/i2c-43/43-0050/eeprom", NULL }, - { 13, -1 /* QUANTA_LY6_CPLD_QSFP_PRSNT(13) */ /* 224 */, NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/i2c-44/44-0050/eeprom", NULL }, - { 14, -1 /* QUANTA_LY6_CPLD_QSFP_PRSNT(14) */ /* 228 */, NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/i2c-45/45-0050/eeprom", NULL }, - { 15, -1 /* QUANTA_LY6_CPLD_QSFP_PRSNT(15) */ /* 232 */, NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/i2c-46/46-0050/eeprom", NULL }, - { 16, -1 /* QUANTA_LY6_CPLD_QSFP_PRSNT(16) */ /* 236 */, NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-17/i2c-47/47-0050/eeprom", NULL }, - { 17, -1 /* QUANTA_LY6_CPLD_QSFP_PRSNT(17) */ /* 248 */, NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-18/i2c-48/48-0050/eeprom", NULL }, - { 18, -1 /* QUANTA_LY6_CPLD_QSFP_PRSNT(18) */ /* 252 */, NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-18/i2c-49/49-0050/eeprom", NULL }, - { 19, -1 /* QUANTA_LY6_CPLD_QSFP_PRSNT(19) */ /* 256 */, NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-18/i2c-50/50-0050/eeprom", NULL }, - { 20, -1 /* QUANTA_LY6_CPLD_QSFP_PRSNT(20) */ /* 260 */, NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-18/i2c-51/51-0050/eeprom", NULL }, - { 21, -1 /* QUANTA_LY6_CPLD_QSFP_PRSNT(21) */ /* 264 */, NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-18/i2c-52/52-0050/eeprom", NULL }, - { 22, -1 /* QUANTA_LY6_CPLD_QSFP_PRSNT(22) */ /* 268 */, NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-18/i2c-53/53-0050/eeprom", NULL }, - { 23, -1 /* QUANTA_LY6_CPLD_QSFP_PRSNT(23) */ /* 272 */, NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-18/i2c-54/54-0050/eeprom", NULL }, - { 24, -1 /* QUANTA_LY6_CPLD_QSFP_PRSNT(24) */ /* 276 */, NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-18/i2c-55/55-0050/eeprom", NULL }, - { 25, -1 /* QUANTA_LY6_CPLD_QSFP_PRSNT(25) */ /* 288 */, NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-19/i2c-56/56-0050/eeprom", NULL }, - { 26, -1 /* QUANTA_LY6_CPLD_QSFP_PRSNT(26) */ /* 292 */, NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-19/i2c-57/57-0050/eeprom", NULL }, - { 27, -1 /* QUANTA_LY6_CPLD_QSFP_PRSNT(27) */ /* 296 */, NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-19/i2c-58/58-0050/eeprom", NULL }, - { 28, -1 /* QUANTA_LY6_CPLD_QSFP_PRSNT(28) */ /* 300 */, NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-19/i2c-59/59-0050/eeprom", NULL }, - { 29, -1 /* QUANTA_LY6_CPLD_QSFP_PRSNT(29) */ /* 304 */, NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-19/i2c-60/60-0050/eeprom", NULL }, - { 30, -1 /* QUANTA_LY6_CPLD_QSFP_PRSNT(30) */ /* 308 */, NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-19/i2c-61/61-0050/eeprom", NULL }, - { 31, -1 /* QUANTA_LY6_CPLD_QSFP_PRSNT(31) */ /* 312 */, NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-19/i2c-62/62-0050/eeprom", NULL }, - { 32, -1 /* QUANTA_LY6_CPLD_QSFP_PRSNT(32) */ /* 316 */, NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-19/i2c-63/63-0050/eeprom", NULL }, - }; - -int -onlp_sfpi_init(void) -{ - int value = -1, ret; - - onlp_gpio_export(QUANTA_LY6_QSFP_EN_GPIO_P3V3_PW_EN, ONLP_GPIO_DIRECTION_IN); - ret = onlp_gpio_get(QUANTA_LY6_QSFP_EN_GPIO_P3V3_PW_EN, &value); - if(ret == ONLP_STATUS_OK && value != 1) { - onlp_gpio_export(QUANTA_LY6_QSFP_EN_GPIO_P3V3_PW_EN, ONLP_GPIO_DIRECTION_OUT); - ret = onlp_gpio_set(QUANTA_LY6_QSFP_EN_GPIO_P3V3_PW_EN, 1); - sleep(1); - } - - return ret; -} - -int -onlp_sfpi_bitmap_get(onlp_sfp_bitmap_t* bmap) -{ - int p; - - for(p = 0; p < 32; p++) { - AIM_BITMAP_SET(bmap, p); - } - - return ONLP_STATUS_OK; -} - -#define SFP_GET(_port) (sfpmap__ + _port) - -int -onlp_sfpi_is_present(int port) -{ - int value = 0; - sfpmap_t* sfp = SFP_GET(port); - if(sfp->present_gpio > 0) { - if(onlp_gpio_get(sfp->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(sfp->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; - } -} - -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); -} - diff --git a/packages/platforms/quanta/x86-64/ly6-rangeley/onlp/builds/x86_64_quanta_ly6_rangeley/module/src/sysi.c b/packages/platforms/quanta/x86-64/ly6-rangeley/onlp/builds/x86_64_quanta_ly6_rangeley/module/src/sysi.c deleted file mode 100755 index ca308623e..000000000 --- a/packages/platforms/quanta/x86-64/ly6-rangeley/onlp/builds/x86_64_quanta_ly6_rangeley/module/src/sysi.c +++ /dev/null @@ -1,277 +0,0 @@ -/************************************************************ - * - * - ************************************************************ - * - * - * - ***********************************************************/ -#include -#include "x86_64_quanta_ly6_rangeley_int.h" -#include "x86_64_quanta_ly6_rangeley_log.h" -#include -#include -#include -#include -#include - -struct led_control_s led_control; - -#define QUANTA_HWMON_REG_TEMP_ALERT_MASK 0x1E -#define QUANTA_HWMON_REG_TEMP_ALERT_CTRL 0x1D -#define QUANTA_HWMON_REG_FAN_ALERT_MASK 0x31 -#define QUANTA_HWMON_REG_FAN_ALERT_CTRL 0x30 - -#define QUANTA_FAN_1_1 0x01 -#define QUANTA_FAN_1_2 0x10 -#define QUANTA_FAN_2_1 0x02 -#define QUANTA_FAN_2_2 0x20 -#define QUANTA_FAN_3_1 0x04 -#define QUANTA_FAN_3_2 0x40 - -const char* -onlp_sysi_platform_get(void) -{ - return "x86-64-quanta-ly6-rangeley-r0"; -} - -int -onlp_sysi_init(void) -{ - /* Initial value */ - led_control.PMCnt = 0; - led_control.fan_alert = 0xff; - led_control.psu1_present = 0; - led_control.psu2_present = 0; - led_control.psu1_power_good = 0; - led_control.psu2_power_good = 0; - - /* Set PSoc Fan-Alert Enable */ - onlp_i2c_writeb(0, 0x4e, QUANTA_HWMON_REG_TEMP_ALERT_MASK, 0x37, ONLP_I2C_F_FORCE); - onlp_i2c_writeb(0, 0x4e, QUANTA_HWMON_REG_TEMP_ALERT_CTRL, 0x3, ONLP_I2C_F_FORCE); - onlp_i2c_writeb(0, 0x4e, QUANTA_HWMON_REG_FAN_ALERT_MASK, 0x77, ONLP_I2C_F_FORCE); - onlp_i2c_writeb(0, 0x4e, QUANTA_HWMON_REG_FAN_ALERT_CTRL, 0x1, ONLP_I2C_F_FORCE); - - /* Config GPIO */ - /* LED Output */ - onlp_gpio_export(QUANTA_LY6_CPU_BOARD_SYS_P1, ONLP_GPIO_DIRECTION_OUT); - onlp_gpio_export(QUANTA_LY6_CPU_BOARD_SYS_P2, ONLP_GPIO_DIRECTION_OUT); - onlp_gpio_export(QUANTA_LY6_PSU_GPIO_PSU1_GREEN_R, ONLP_GPIO_DIRECTION_OUT); - onlp_gpio_export(QUANTA_LY6_PSU_GPIO_PSU1_RED_R, ONLP_GPIO_DIRECTION_OUT); - onlp_gpio_export(QUANTA_LY6_PSU_GPIO_PSU2_GREEN_R, ONLP_GPIO_DIRECTION_OUT); - onlp_gpio_export(QUANTA_LY6_PSU_GPIO_PSU2_RED_R, ONLP_GPIO_DIRECTION_OUT); - onlp_gpio_export(QUANTA_LY6_FAN_FAIL_LED_1, ONLP_GPIO_DIRECTION_OUT); - onlp_gpio_export(QUANTA_LY6_FAN_FAIL_LED_2, ONLP_GPIO_DIRECTION_OUT); - onlp_gpio_export(QUANTA_LY6_FAN_FAIL_LED_3, ONLP_GPIO_DIRECTION_OUT); - onlp_gpio_export(QUANTA_LY6_PSU_GPIO_FAN_GREEN_R, ONLP_GPIO_DIRECTION_OUT); - onlp_gpio_export(QUANTA_LY6_PSU_GPIO_FAN_RED_R, ONLP_GPIO_DIRECTION_OUT); - /* PSU Input */ - onlp_gpio_export(QUANTA_LY6_PSU_GPIO_PSU1_PRSNT_N, ONLP_GPIO_DIRECTION_IN); - onlp_gpio_export(QUANTA_LY6_PSU_GPIO_PSU1_PWRGD, ONLP_GPIO_DIRECTION_IN); - onlp_gpio_export(QUANTA_LY6_PSU_GPIO_PSU2_PRSNT_N, ONLP_GPIO_DIRECTION_IN); - onlp_gpio_export(QUANTA_LY6_PSU_GPIO_PSU2_PWRGD, ONLP_GPIO_DIRECTION_IN); - /* FAN Input */ - 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); - 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-27/27-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-ly6-rangeley-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)); - - - /* - * 5 Chassis Thermal Sensors - */ - *e++ = THERMAL_OID_THERMAL1; - *e++ = THERMAL_OID_THERMAL2; - *e++ = THERMAL_OID_THERMAL3; - *e++ = THERMAL_OID_THERMAL5; - *e++ = THERMAL_OID_THERMAL6; - - /* - * 6 Fans - */ - *e++ = FAN_OID_FAN1; - *e++ = FAN_OID_FAN2; - *e++ = FAN_OID_FAN3; - *e++ = FAN_OID_FAN5; - *e++ = FAN_OID_FAN6; - *e++ = FAN_OID_FAN7; - - /* - * 2 PSUs - */ - *e++ = PSU_OID_PSU1; - *e++ = PSU_OID_PSU2; - - /* - * 7 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; - - 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_LY6_PSU_GPIO_PSU1_PRSNT_N, &value); - if(rv < 0) { - AIM_LOG_ERROR("GPIO %d read Error!", QUANTA_LY6_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_LY6_PSU_GPIO_PSU1_PWRGD, &value); - if(rv < 0) { - AIM_LOG_ERROR("GPIO %d read Error!", QUANTA_LY6_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_LY6_PSU_GPIO_PSU2_PRSNT_N, &value); - if(rv < 0) { - AIM_LOG_ERROR("GPIO %d read Error!", QUANTA_LY6_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_LY6_PSU_GPIO_PSU2_PWRGD, &value); - if(rv < 0) { - AIM_LOG_ERROR("GPIO %d read Error!", QUANTA_LY6_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; - - tmp = led_control.fan_alert; - led_control.fan_alert = onlp_i2c_readb(0, 0x4e, 0x32, ONLP_I2C_F_FORCE); - if(tmp != led_control.fan_alert) - 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.fan_alert & QUANTA_FAN_1_1) && !(led_control.fan_alert & QUANTA_FAN_1_2)) { - onlp_ledi_mode_set(LED_ID_FAN_FAIL_1, ONLP_LED_MODE_OFF); - } - else{ - onlp_ledi_mode_set(LED_ID_FAN_FAIL_1, ONLP_LED_MODE_RED); - } - - if(!(led_control.fan_alert & QUANTA_FAN_2_1) && !(led_control.fan_alert & QUANTA_FAN_2_2)) { - onlp_ledi_mode_set(LED_ID_FAN_FAIL_2, ONLP_LED_MODE_OFF); - } - else{ - onlp_ledi_mode_set(LED_ID_FAN_FAIL_2, ONLP_LED_MODE_RED); - } - - if(!(led_control.fan_alert & QUANTA_FAN_3_1) && !(led_control.fan_alert & QUANTA_FAN_3_2)) { - onlp_ledi_mode_set(LED_ID_FAN_FAIL_3, ONLP_LED_MODE_OFF); - } - else{ - onlp_ledi_mode_set(LED_ID_FAN_FAIL_3, ONLP_LED_MODE_RED); - } - - if(!led_control.fan_alert){ - 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; -} \ No newline at end of file diff --git a/packages/platforms/quanta/x86-64/ly6-rangeley/onlp/builds/x86_64_quanta_ly6_rangeley/module/src/thermali.c b/packages/platforms/quanta/x86-64/ly6-rangeley/onlp/builds/x86_64_quanta_ly6_rangeley/module/src/thermali.c deleted file mode 100644 index 8df583591..000000000 --- a/packages/platforms/quanta/x86-64/ly6-rangeley/onlp/builds/x86_64_quanta_ly6_rangeley/module/src/thermali.c +++ /dev/null @@ -1,144 +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 "x86_64_quanta_ly6_rangeley_int.h" -#include "x86_64_quanta_ly6_rangeley_log.h" - -int -onlp_thermali_init(void) -{ - return ONLP_STATUS_OK; -} - -static int -sys_thermal_info_get__(onlp_thermal_info_t* info, int id) -{ - int rv; - - rv = onlp_file_read_int(&info->mcelsius, - SYS_HWMON_PREFIX "/temp%d_input", id); - - if(rv == ONLP_STATUS_E_INTERNAL) { - return rv; - } - - if(rv == ONLP_STATUS_E_MISSING) { - info->status &= ~1; - return 0; - } - - return ONLP_STATUS_OK; -} - -static int -psu_thermal_info_get__(onlp_thermal_info_t* info, int pid, int id) -{ - /* THERMAL6 -> PSU1 */ - /* THERMAL7 -> PSU2 */ - extern struct psu_info_s psu_info[]; - char* dir = psu_info[pid].path; - info->status |= 1; - return onlp_file_read_int(&info->mcelsius, "%s/temp%d_input", dir, id); -} - -int -onlp_thermali_info_get(onlp_oid_t id, onlp_thermal_info_t* rv) -{ - int tid = ONLP_OID_ID_GET(id); - - static onlp_thermal_info_t info[] = { - { }, /* Not used */ - { { ONLP_THERMAL_ID_CREATE(1), "Chassis Thermal 1", 0}, ONLP_THERMAL_STATUS_PRESENT, - ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS - }, - { { ONLP_THERMAL_ID_CREATE(2), "Chassis Thermal 2", 0}, ONLP_THERMAL_STATUS_PRESENT, - ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS - }, - { { ONLP_THERMAL_ID_CREATE(3), "Chassis Thermal 3", 0}, ONLP_THERMAL_STATUS_PRESENT, - ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS - }, - { { ONLP_THERMAL_ID_CREATE(4), "Chassis Thermal 4", 0}, ONLP_THERMAL_STATUS_PRESENT, - ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS - }, - { { ONLP_THERMAL_ID_CREATE(5), "Chassis Thermal 5", 0}, ONLP_THERMAL_STATUS_PRESENT, - ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS - }, - { { ONLP_THERMAL_ID_CREATE(6), "Chassis Thermal 6", 0}, ONLP_THERMAL_STATUS_PRESENT, - ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS - }, - { { ONLP_THERMAL_ID_CREATE(7), "Chassis Thermal 7", 0}, ONLP_THERMAL_STATUS_PRESENT, - ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS - }, - { { ONLP_THERMAL_ID_CREATE(8), "Chassis Thermal 8", 0}, ONLP_THERMAL_STATUS_PRESENT, - ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS - }, - { { ONLP_THERMAL_ID_CREATE(9), "Chassis Thermal 9", 0}, ONLP_THERMAL_STATUS_PRESENT, - ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS - }, - { { ONLP_THERMAL_ID_CREATE(10), "Chassis Thermal 10", 0}, ONLP_THERMAL_STATUS_PRESENT, - ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS - }, - { { ONLP_THERMAL_ID_CREATE(11), "PSU-1 Thermal 1", 0 } }, - { { ONLP_THERMAL_ID_CREATE(12), "PSU-1 Thermal 2", 0 } }, - { { ONLP_THERMAL_ID_CREATE(13), "PSU-1 Thermal 3", 0 } }, - - { { ONLP_THERMAL_ID_CREATE(14), "PSU-2 Thermal 1", 0 } }, - { { ONLP_THERMAL_ID_CREATE(15), "PSU-2 Thermal 2", 0 } }, - { { ONLP_THERMAL_ID_CREATE(16), "PSU-2 Thermal 3", 0 } }, - }; - - *rv = info[tid]; - rv->caps |= ONLP_THERMAL_CAPS_GET_TEMPERATURE; - - switch(tid) - { - case THERMAL_ID_THERMAL1: - case THERMAL_ID_THERMAL2: - case THERMAL_ID_THERMAL3: - case THERMAL_ID_THERMAL4: - case THERMAL_ID_THERMAL5: - case THERMAL_ID_THERMAL6: - case THERMAL_ID_THERMAL7: - case THERMAL_ID_THERMAL8: - case THERMAL_ID_THERMAL9: - case THERMAL_ID_THERMAL10: - return sys_thermal_info_get__(rv, tid); - - case THERMAL_ID_THERMAL11: - case THERMAL_ID_THERMAL12: - case THERMAL_ID_THERMAL13: - return psu_thermal_info_get__(rv, 1, tid - THERMAL_ID_THERMAL11 + 1); - - - case THERMAL_ID_THERMAL14: - case THERMAL_ID_THERMAL15: - case THERMAL_ID_THERMAL16: - return psu_thermal_info_get__(rv, 2, tid - THERMAL_ID_THERMAL14 + 1); - - } - - return ONLP_STATUS_E_INVALID; -} diff --git a/packages/platforms/quanta/x86-64/ly6-rangeley/onlp/builds/x86_64_quanta_ly6_rangeley/module/src/x86_64_quanta_ly6_rangeley_config.c b/packages/platforms/quanta/x86-64/ly6-rangeley/onlp/builds/x86_64_quanta_ly6_rangeley/module/src/x86_64_quanta_ly6_rangeley_config.c deleted file mode 100644 index fe180ad90..000000000 --- a/packages/platforms/quanta/x86-64/ly6-rangeley/onlp/builds/x86_64_quanta_ly6_rangeley/module/src/x86_64_quanta_ly6_rangeley_config.c +++ /dev/null @@ -1,96 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#include - -/* */ -#define __x86_64_quanta_ly6_rangeley_config_STRINGIFY_NAME(_x) #_x -#define __x86_64_quanta_ly6_rangeley_config_STRINGIFY_VALUE(_x) __x86_64_quanta_ly6_rangeley_config_STRINGIFY_NAME(_x) -x86_64_quanta_ly6_rangeley_config_settings_t x86_64_quanta_ly6_rangeley_config_settings[] = -{ -#ifdef X86_64_QUANTA_LY6_RANGELEY_CONFIG_INCLUDE_LOGGING - { __x86_64_quanta_ly6_rangeley_config_STRINGIFY_NAME(X86_64_QUANTA_LY6_RANGELEY_CONFIG_INCLUDE_LOGGING), __x86_64_quanta_ly6_rangeley_config_STRINGIFY_VALUE(X86_64_QUANTA_LY6_RANGELEY_CONFIG_INCLUDE_LOGGING) }, -#else -{ X86_64_QUANTA_LY6_RANGELEY_CONFIG_INCLUDE_LOGGING(__x86_64_quanta_ly6_rangeley_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_QUANTA_LY6_RANGELEY_CONFIG_LOG_OPTIONS_DEFAULT - { __x86_64_quanta_ly6_rangeley_config_STRINGIFY_NAME(X86_64_QUANTA_LY6_RANGELEY_CONFIG_LOG_OPTIONS_DEFAULT), __x86_64_quanta_ly6_rangeley_config_STRINGIFY_VALUE(X86_64_QUANTA_LY6_RANGELEY_CONFIG_LOG_OPTIONS_DEFAULT) }, -#else -{ X86_64_QUANTA_LY6_RANGELEY_CONFIG_LOG_OPTIONS_DEFAULT(__x86_64_quanta_ly6_rangeley_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_QUANTA_LY6_RANGELEY_CONFIG_LOG_BITS_DEFAULT - { __x86_64_quanta_ly6_rangeley_config_STRINGIFY_NAME(X86_64_QUANTA_LY6_RANGELEY_CONFIG_LOG_BITS_DEFAULT), __x86_64_quanta_ly6_rangeley_config_STRINGIFY_VALUE(X86_64_QUANTA_LY6_RANGELEY_CONFIG_LOG_BITS_DEFAULT) }, -#else -{ X86_64_QUANTA_LY6_RANGELEY_CONFIG_LOG_BITS_DEFAULT(__x86_64_quanta_ly6_rangeley_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_QUANTA_LY6_RANGELEY_CONFIG_LOG_CUSTOM_BITS_DEFAULT - { __x86_64_quanta_ly6_rangeley_config_STRINGIFY_NAME(X86_64_QUANTA_LY6_RANGELEY_CONFIG_LOG_CUSTOM_BITS_DEFAULT), __x86_64_quanta_ly6_rangeley_config_STRINGIFY_VALUE(X86_64_QUANTA_LY6_RANGELEY_CONFIG_LOG_CUSTOM_BITS_DEFAULT) }, -#else -{ X86_64_QUANTA_LY6_RANGELEY_CONFIG_LOG_CUSTOM_BITS_DEFAULT(__x86_64_quanta_ly6_rangeley_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_QUANTA_LY6_RANGELEY_CONFIG_PORTING_STDLIB - { __x86_64_quanta_ly6_rangeley_config_STRINGIFY_NAME(X86_64_QUANTA_LY6_RANGELEY_CONFIG_PORTING_STDLIB), __x86_64_quanta_ly6_rangeley_config_STRINGIFY_VALUE(X86_64_QUANTA_LY6_RANGELEY_CONFIG_PORTING_STDLIB) }, -#else -{ X86_64_QUANTA_LY6_RANGELEY_CONFIG_PORTING_STDLIB(__x86_64_quanta_ly6_rangeley_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_QUANTA_LY6_RANGELEY_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS - { __x86_64_quanta_ly6_rangeley_config_STRINGIFY_NAME(X86_64_QUANTA_LY6_RANGELEY_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS), __x86_64_quanta_ly6_rangeley_config_STRINGIFY_VALUE(X86_64_QUANTA_LY6_RANGELEY_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS) }, -#else -{ X86_64_QUANTA_LY6_RANGELEY_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS(__x86_64_quanta_ly6_rangeley_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_QUANTA_LY6_RANGELEY_CONFIG_INCLUDE_UCLI - { __x86_64_quanta_ly6_rangeley_config_STRINGIFY_NAME(X86_64_QUANTA_LY6_RANGELEY_CONFIG_INCLUDE_UCLI), __x86_64_quanta_ly6_rangeley_config_STRINGIFY_VALUE(X86_64_QUANTA_LY6_RANGELEY_CONFIG_INCLUDE_UCLI) }, -#else -{ X86_64_QUANTA_LY6_RANGELEY_CONFIG_INCLUDE_UCLI(__x86_64_quanta_ly6_rangeley_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_QUANTA_LY6_RANGELEY_CONFIG_SYSFAN_RPM_FAILURE_THRESHOLD - { __x86_64_quanta_ly6_rangeley_config_STRINGIFY_NAME(X86_64_QUANTA_LY6_RANGELEY_CONFIG_SYSFAN_RPM_FAILURE_THRESHOLD), __x86_64_quanta_ly6_rangeley_config_STRINGIFY_VALUE(X86_64_QUANTA_LY6_RANGELEY_CONFIG_SYSFAN_RPM_FAILURE_THRESHOLD) }, -#else -{ X86_64_QUANTA_LY6_RANGELEY_CONFIG_SYSFAN_RPM_FAILURE_THRESHOLD(__x86_64_quanta_ly6_rangeley_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_QUANTA_LY6_RANGELEY_CONFIG_SYSFAN_F2B_RPM_MAX - { __x86_64_quanta_ly6_rangeley_config_STRINGIFY_NAME(X86_64_QUANTA_LY6_RANGELEY_CONFIG_SYSFAN_F2B_RPM_MAX), __x86_64_quanta_ly6_rangeley_config_STRINGIFY_VALUE(X86_64_QUANTA_LY6_RANGELEY_CONFIG_SYSFAN_F2B_RPM_MAX) }, -#else -{ X86_64_QUANTA_LY6_RANGELEY_CONFIG_SYSFAN_F2B_RPM_MAX(__x86_64_quanta_ly6_rangeley_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_QUANTA_LY6_RANGELEY_CONFIG_SYSFAN_B2F_RPM_MAX - { __x86_64_quanta_ly6_rangeley_config_STRINGIFY_NAME(X86_64_QUANTA_LY6_RANGELEY_CONFIG_SYSFAN_B2F_RPM_MAX), __x86_64_quanta_ly6_rangeley_config_STRINGIFY_VALUE(X86_64_QUANTA_LY6_RANGELEY_CONFIG_SYSFAN_B2F_RPM_MAX) }, -#else -{ X86_64_QUANTA_LY6_RANGELEY_CONFIG_SYSFAN_B2F_RPM_MAX(__x86_64_quanta_ly6_rangeley_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_QUANTA_LY6_RANGELEY_CONFIG_PHY_RESET_DELAY_MS - { __x86_64_quanta_ly6_rangeley_config_STRINGIFY_NAME(X86_64_QUANTA_LY6_RANGELEY_CONFIG_PHY_RESET_DELAY_MS), __x86_64_quanta_ly6_rangeley_config_STRINGIFY_VALUE(X86_64_QUANTA_LY6_RANGELEY_CONFIG_PHY_RESET_DELAY_MS) }, -#else -{ X86_64_QUANTA_LY6_RANGELEY_CONFIG_PHY_RESET_DELAY_MS(__x86_64_quanta_ly6_rangeley_config_STRINGIFY_NAME), "__undefined__" }, -#endif - { NULL, NULL } -}; -#undef __x86_64_quanta_ly6_rangeley_config_STRINGIFY_VALUE -#undef __x86_64_quanta_ly6_rangeley_config_STRINGIFY_NAME - -const char* -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)) { - return x86_64_quanta_ly6_rangeley_config_settings[i].value; - } - } - return NULL; -} - -int -x86_64_quanta_ly6_rangeley_config_show(struct aim_pvs_s* pvs) -{ - int i; - for(i = 0; x86_64_quanta_ly6_rangeley_config_settings[i].name; i++) { - aim_printf(pvs, "%s = %s\n", x86_64_quanta_ly6_rangeley_config_settings[i].name, x86_64_quanta_ly6_rangeley_config_settings[i].value); - } - return i; -} - -/* */ - diff --git a/packages/platforms/quanta/x86-64/ly6-rangeley/onlp/builds/x86_64_quanta_ly6_rangeley/module/src/x86_64_quanta_ly6_rangeley_enums.c b/packages/platforms/quanta/x86-64/ly6-rangeley/onlp/builds/x86_64_quanta_ly6_rangeley/module/src/x86_64_quanta_ly6_rangeley_enums.c deleted file mode 100644 index 758153dcd..000000000 --- a/packages/platforms/quanta/x86-64/ly6-rangeley/onlp/builds/x86_64_quanta_ly6_rangeley/module/src/x86_64_quanta_ly6_rangeley_enums.c +++ /dev/null @@ -1,10 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#include - -/* <--auto.start.enum(ALL).source> */ -/* */ - diff --git a/packages/platforms/quanta/x86-64/ly6-rangeley/onlp/builds/x86_64_quanta_ly6_rangeley/module/src/x86_64_quanta_ly6_rangeley_int.h b/packages/platforms/quanta/x86-64/ly6-rangeley/onlp/builds/x86_64_quanta_ly6_rangeley/module/src/x86_64_quanta_ly6_rangeley_int.h deleted file mode 100755 index 22cab4f37..000000000 --- a/packages/platforms/quanta/x86-64/ly6-rangeley/onlp/builds/x86_64_quanta_ly6_rangeley/module/src/x86_64_quanta_ly6_rangeley_int.h +++ /dev/null @@ -1,306 +0,0 @@ -/**************************************************************************//** - * - * x86_64_quanta_ly6_rangeley Internal Header - * - *****************************************************************************/ -#ifndef __X86_64_QUANTA_LY6_RANGELEY_INT_H__ -#define __X86_64_QUANTA_LY6_RANGELEY_INT_H__ - -#include -#include - -/* */ -/** 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[]; - -/** 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 { - 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[]; - -/** 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 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_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_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 fan_alert; - int psu1_present; - int psu2_present; - int psu1_power_good; - int psu2_power_good; -}; - -#define SYS_HWMON_PREFIX "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/0-004e" - -#endif /* __X86_64_QUANTA_LY6_RANGELEY_INT_H__ */ diff --git a/packages/platforms/quanta/x86-64/ly6-rangeley/onlp/builds/x86_64_quanta_ly6_rangeley/module/src/x86_64_quanta_ly6_rangeley_log.c b/packages/platforms/quanta/x86-64/ly6-rangeley/onlp/builds/x86_64_quanta_ly6_rangeley/module/src/x86_64_quanta_ly6_rangeley_log.c deleted file mode 100644 index 26d72398a..000000000 --- a/packages/platforms/quanta/x86-64/ly6-rangeley/onlp/builds/x86_64_quanta_ly6_rangeley/module/src/x86_64_quanta_ly6_rangeley_log.c +++ /dev/null @@ -1,18 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#include - -#include "x86_64_quanta_ly6_rangeley_log.h" -/* - * x86_64_quanta_ly6_rangeley log struct. - */ -AIM_LOG_STRUCT_DEFINE( - X86_64_QUANTA_LY6_RANGELEY_CONFIG_LOG_OPTIONS_DEFAULT, - X86_64_QUANTA_LY6_RANGELEY_CONFIG_LOG_BITS_DEFAULT, - NULL, /* Custom log map */ - X86_64_QUANTA_LY6_RANGELEY_CONFIG_LOG_CUSTOM_BITS_DEFAULT - ); - diff --git a/packages/platforms/quanta/x86-64/ly6-rangeley/onlp/builds/x86_64_quanta_ly6_rangeley/module/src/x86_64_quanta_ly6_rangeley_log.h b/packages/platforms/quanta/x86-64/ly6-rangeley/onlp/builds/x86_64_quanta_ly6_rangeley/module/src/x86_64_quanta_ly6_rangeley_log.h deleted file mode 100644 index 7f7b155ef..000000000 --- a/packages/platforms/quanta/x86-64/ly6-rangeley/onlp/builds/x86_64_quanta_ly6_rangeley/module/src/x86_64_quanta_ly6_rangeley_log.h +++ /dev/null @@ -1,12 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#ifndef __X86_64_QUANTA_LY6_RANGELEY_LOG_H__ -#define __X86_64_QUANTA_LY6_RANGELEY_LOG_H__ - -#define AIM_LOG_MODULE_NAME x86_64_quanta_ly6_rangeley -#include - -#endif /* __X86_64_QUANTA_LY6_RANGELEY_LOG_H__ */ diff --git a/packages/platforms/quanta/x86-64/ly6-rangeley/onlp/builds/x86_64_quanta_ly6_rangeley/module/src/x86_64_quanta_ly6_rangeley_module.c b/packages/platforms/quanta/x86-64/ly6-rangeley/onlp/builds/x86_64_quanta_ly6_rangeley/module/src/x86_64_quanta_ly6_rangeley_module.c deleted file mode 100644 index 3af236b34..000000000 --- a/packages/platforms/quanta/x86-64/ly6-rangeley/onlp/builds/x86_64_quanta_ly6_rangeley/module/src/x86_64_quanta_ly6_rangeley_module.c +++ /dev/null @@ -1,24 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#include - -#include "x86_64_quanta_ly6_rangeley_log.h" - -static int -datatypes_init__(void) -{ -#define X86_64_QUANTA_LY6_RANGELEY_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_ly6_rangeley_module_init__(void) -{ - AIM_LOG_STRUCT_REGISTER(); - datatypes_init__(); -} - -int __onlp_platform_version__ = 1; diff --git a/packages/platforms/quanta/x86-64/ly6-rangeley/onlp/builds/x86_64_quanta_ly6_rangeley/module/src/x86_64_quanta_ly6_rangeley_ucli.c b/packages/platforms/quanta/x86-64/ly6-rangeley/onlp/builds/x86_64_quanta_ly6_rangeley/module/src/x86_64_quanta_ly6_rangeley_ucli.c deleted file mode 100644 index b3ed3c25f..000000000 --- a/packages/platforms/quanta/x86-64/ly6-rangeley/onlp/builds/x86_64_quanta_ly6_rangeley/module/src/x86_64_quanta_ly6_rangeley_ucli.c +++ /dev/null @@ -1,50 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#include - -#if X86_64_QUANTA_LY6_RANGELEY_CONFIG_INCLUDE_UCLI == 1 - -#include -#include -#include - -static ucli_status_t -x86_64_quanta_ly6_rangeley_ucli_ucli__config__(ucli_context_t* uc) -{ - UCLI_HANDLER_MACRO_MODULE_CONFIG(x86_64_quanta_ly6_rangeley) -} - -/* */ -/* */ - -static ucli_module_t -x86_64_quanta_ly6_rangeley_ucli_module__ = - { - "x86_64_quanta_ly6_rangeley_ucli", - NULL, - x86_64_quanta_ly6_rangeley_ucli_ucli_handlers__, - NULL, - NULL, - }; - -ucli_node_t* -x86_64_quanta_ly6_rangeley_ucli_node_create(void) -{ - ucli_node_t* n; - ucli_module_init(&x86_64_quanta_ly6_rangeley_ucli_module__); - n = ucli_node_create("x86_64_quanta_ly6_rangeley", NULL, &x86_64_quanta_ly6_rangeley_ucli_module__); - ucli_node_subnode_add(n, ucli_module_log_node_create("x86_64_quanta_ly6_rangeley")); - return n; -} - -#else -void* -x86_64_quanta_ly6_rangeley_ucli_node_create(void) -{ - return NULL; -} -#endif - diff --git a/packages/platforms/quanta/x86-64/ly6-rangeley/platform-config/Makefile b/packages/platforms/quanta/x86-64/ly6-rangeley/platform-config/Makefile deleted file mode 100644 index 003238cf6..000000000 --- a/packages/platforms/quanta/x86-64/ly6-rangeley/platform-config/Makefile +++ /dev/null @@ -1 +0,0 @@ -include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/quanta/x86-64/ly6-rangeley/platform-config/r0/Makefile b/packages/platforms/quanta/x86-64/ly6-rangeley/platform-config/r0/Makefile deleted file mode 100644 index 003238cf6..000000000 --- a/packages/platforms/quanta/x86-64/ly6-rangeley/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/quanta/x86-64/ly6-rangeley/platform-config/r0/PKG.yml b/packages/platforms/quanta/x86-64/ly6-rangeley/platform-config/r0/PKG.yml deleted file mode 100644 index 06fe4ae9d..000000000 --- a/packages/platforms/quanta/x86-64/ly6-rangeley/platform-config/r0/PKG.yml +++ /dev/null @@ -1 +0,0 @@ -!include $ONL_TEMPLATES/platform-config-platform.yml ARCH=amd64 VENDOR=quanta BASENAME=x86-64-quanta-ly6-rangeley REVISION=r0 diff --git a/packages/platforms/quanta/x86-64/ly6-rangeley/platform-config/r0/src/lib/x86-64-quanta-ly6-rangeley-r0.yml b/packages/platforms/quanta/x86-64/ly6-rangeley/platform-config/r0/src/lib/x86-64-quanta-ly6-rangeley-r0.yml deleted file mode 100644 index 74c28389b..000000000 --- a/packages/platforms/quanta/x86-64/ly6-rangeley/platform-config/r0/src/lib/x86-64-quanta-ly6-rangeley-r0.yml +++ /dev/null @@ -1,31 +0,0 @@ ---- - -###################################################################### -# -# platform-config for LY6 -# -###################################################################### - -x86-64-quanta-ly6-rangeley-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/ly6-rangeley/platform-config/r0/src/python/x86_64_quanta_ly6_rangeley_r0/__init__.py b/packages/platforms/quanta/x86-64/ly6-rangeley/platform-config/r0/src/python/x86_64_quanta_ly6_rangeley_r0/__init__.py deleted file mode 100755 index 06df97c94..000000000 --- a/packages/platforms/quanta/x86-64/ly6-rangeley/platform-config/r0/src/python/x86_64_quanta_ly6_rangeley_r0/__init__.py +++ /dev/null @@ -1,27 +0,0 @@ -from onl.platform.base import * -from onl.platform.quanta import * - -class OnlPlatform_x86_64_quanta_ly6_rangeley_r0(OnlPlatformQuanta, - OnlPlatformPortConfig_32x40): - PLATFORM='x86-64-quanta-ly6-rangeley-r0' - MODEL='LY6' - """ 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='.5032.2600' - - def baseconfig(self): - self.insmod("quanta_hwmon_ly_series") - self.insmod("quanta-ly6-i2c-mux") - self.insmod("quanta_platform_ly6") - - # make ds1339 as default rtc - os.system("ln -snf /dev/rtc1 /dev/rtc") - os.system("hwclock --hctosys") - - return True diff --git a/packages/platforms/quanta/x86-64/ly7-rglbmc/.gitignore b/packages/platforms/quanta/x86-64/ly7-rglbmc/.gitignore deleted file mode 100755 index 60f9dd9da..000000000 --- a/packages/platforms/quanta/x86-64/ly7-rglbmc/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -*x86*64*quanta*ly7*rglbmc.mk -onlpdump.mk diff --git a/packages/platforms/quanta/x86-64/ly7-rglbmc/Makefile b/packages/platforms/quanta/x86-64/ly7-rglbmc/Makefile deleted file mode 100755 index 003238cf6..000000000 --- a/packages/platforms/quanta/x86-64/ly7-rglbmc/Makefile +++ /dev/null @@ -1 +0,0 @@ -include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/quanta/x86-64/ly7-rglbmc/modules/Makefile b/packages/platforms/quanta/x86-64/ly7-rglbmc/modules/Makefile deleted file mode 100755 index 003238cf6..000000000 --- a/packages/platforms/quanta/x86-64/ly7-rglbmc/modules/Makefile +++ /dev/null @@ -1 +0,0 @@ -include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/quanta/x86-64/ly7-rglbmc/modules/PKG.yml b/packages/platforms/quanta/x86-64/ly7-rglbmc/modules/PKG.yml deleted file mode 100755 index 7f33b5797..000000000 --- a/packages/platforms/quanta/x86-64/ly7-rglbmc/modules/PKG.yml +++ /dev/null @@ -1 +0,0 @@ -!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/ly7-rglbmc/modules/builds/.gitignore b/packages/platforms/quanta/x86-64/ly7-rglbmc/modules/builds/.gitignore deleted file mode 100755 index a65b41774..000000000 --- a/packages/platforms/quanta/x86-64/ly7-rglbmc/modules/builds/.gitignore +++ /dev/null @@ -1 +0,0 @@ -lib diff --git a/packages/platforms/quanta/x86-64/ly7-rglbmc/modules/builds/Makefile b/packages/platforms/quanta/x86-64/ly7-rglbmc/modules/builds/Makefile deleted file mode 100755 index aec5bb59b..000000000 --- a/packages/platforms/quanta/x86-64/ly7-rglbmc/modules/builds/Makefile +++ /dev/null @@ -1,6 +0,0 @@ -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/ly7-rglbmc/modules/builds/quanta_platform_ly7.c b/packages/platforms/quanta/x86-64/ly7-rglbmc/modules/builds/quanta_platform_ly7.c deleted file mode 100755 index 2efdfab3d..000000000 --- a/packages/platforms/quanta/x86-64/ly7-rglbmc/modules/builds/quanta_platform_ly7.c +++ /dev/null @@ -1,403 +0,0 @@ -/* - * 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/ly7-rglbmc/onlp/Makefile b/packages/platforms/quanta/x86-64/ly7-rglbmc/onlp/Makefile deleted file mode 100755 index 003238cf6..000000000 --- a/packages/platforms/quanta/x86-64/ly7-rglbmc/onlp/Makefile +++ /dev/null @@ -1 +0,0 @@ -include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/quanta/x86-64/ly7-rglbmc/onlp/PKG.yml b/packages/platforms/quanta/x86-64/ly7-rglbmc/onlp/PKG.yml deleted file mode 100755 index 764676691..000000000 --- a/packages/platforms/quanta/x86-64/ly7-rglbmc/onlp/PKG.yml +++ /dev/null @@ -1 +0,0 @@ -!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/ly7-rglbmc/onlp/builds/Makefile b/packages/platforms/quanta/x86-64/ly7-rglbmc/onlp/builds/Makefile deleted file mode 100755 index e7437cb23..000000000 --- a/packages/platforms/quanta/x86-64/ly7-rglbmc/onlp/builds/Makefile +++ /dev/null @@ -1,2 +0,0 @@ -FILTER=src -include $(ONL)/make/subdirs.mk diff --git a/packages/platforms/quanta/x86-64/ly7-rglbmc/onlp/builds/lib/Makefile b/packages/platforms/quanta/x86-64/ly7-rglbmc/onlp/builds/lib/Makefile deleted file mode 100755 index 69bb80267..000000000 --- a/packages/platforms/quanta/x86-64/ly7-rglbmc/onlp/builds/lib/Makefile +++ /dev/null @@ -1,3 +0,0 @@ -PLATFORM := x86-64-quanta-ly7-rglbmc -EXTRA_MODULES := quanta_sys_eeprom -include $(ONL)/packages/base/any/onlp/builds/platform/libonlp-platform.mk diff --git a/packages/platforms/quanta/x86-64/ly7-rglbmc/onlp/builds/onlpdump/Makefile b/packages/platforms/quanta/x86-64/ly7-rglbmc/onlp/builds/onlpdump/Makefile deleted file mode 100755 index 963738f64..000000000 --- a/packages/platforms/quanta/x86-64/ly7-rglbmc/onlp/builds/onlpdump/Makefile +++ /dev/null @@ -1,3 +0,0 @@ -PLATFORM := x86-64-quanta-ly7-rglbmc -EXTRA_MODULES := quanta_sys_eeprom -include $(ONL)/packages/base/any/onlp/builds/platform/onlps.mk diff --git a/packages/platforms/quanta/x86-64/ly7-rglbmc/onlp/builds/x86_64_quanta_ly7_rglbmc/.gitignore b/packages/platforms/quanta/x86-64/ly7-rglbmc/onlp/builds/x86_64_quanta_ly7_rglbmc/.gitignore deleted file mode 100644 index c81d16be3..000000000 --- a/packages/platforms/quanta/x86-64/ly7-rglbmc/onlp/builds/x86_64_quanta_ly7_rglbmc/.gitignore +++ /dev/null @@ -1 +0,0 @@ -*.mk diff --git a/packages/platforms/quanta/x86-64/ly7-rglbmc/onlp/builds/x86_64_quanta_ly7_rglbmc/.module b/packages/platforms/quanta/x86-64/ly7-rglbmc/onlp/builds/x86_64_quanta_ly7_rglbmc/.module deleted file mode 100755 index f225e5511..000000000 --- a/packages/platforms/quanta/x86-64/ly7-rglbmc/onlp/builds/x86_64_quanta_ly7_rglbmc/.module +++ /dev/null @@ -1 +0,0 @@ -name: x86_64_quanta_ly7_rglbmc diff --git a/packages/platforms/quanta/x86-64/ly7-rglbmc/onlp/builds/x86_64_quanta_ly7_rglbmc/Makefile b/packages/platforms/quanta/x86-64/ly7-rglbmc/onlp/builds/x86_64_quanta_ly7_rglbmc/Makefile deleted file mode 100755 index d36660dec..000000000 --- a/packages/platforms/quanta/x86-64/ly7-rglbmc/onlp/builds/x86_64_quanta_ly7_rglbmc/Makefile +++ /dev/null @@ -1,9 +0,0 @@ -############################################################################### -# -# -# -############################################################################### -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/ly7-rglbmc/onlp/builds/x86_64_quanta_ly7_rglbmc/module/auto/make.mk b/packages/platforms/quanta/x86-64/ly7-rglbmc/onlp/builds/x86_64_quanta_ly7_rglbmc/module/auto/make.mk deleted file mode 100755 index 3c19c01d9..000000000 --- a/packages/platforms/quanta/x86-64/ly7-rglbmc/onlp/builds/x86_64_quanta_ly7_rglbmc/module/auto/make.mk +++ /dev/null @@ -1,9 +0,0 @@ -############################################################################### -# -# 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/ly7-rglbmc/onlp/builds/x86_64_quanta_ly7_rglbmc/module/auto/x86_64_quanta_ly7_rglbmc.yml b/packages/platforms/quanta/x86-64/ly7-rglbmc/onlp/builds/x86_64_quanta_ly7_rglbmc/module/auto/x86_64_quanta_ly7_rglbmc.yml deleted file mode 100755 index ff4a88a5c..000000000 --- a/packages/platforms/quanta/x86-64/ly7-rglbmc/onlp/builds/x86_64_quanta_ly7_rglbmc/module/auto/x86_64_quanta_ly7_rglbmc.yml +++ /dev/null @@ -1,134 +0,0 @@ -############################################################################### -# -# 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 - - - vsnprintf - - snprintf - - strlen diff --git a/packages/platforms/quanta/x86-64/ly7-rglbmc/onlp/builds/x86_64_quanta_ly7_rglbmc/module/inc/x86_64_quanta_ly7_rglbmc/x86_64_quanta_ly7_rglbmc.x b/packages/platforms/quanta/x86-64/ly7-rglbmc/onlp/builds/x86_64_quanta_ly7_rglbmc/module/inc/x86_64_quanta_ly7_rglbmc/x86_64_quanta_ly7_rglbmc.x deleted file mode 100755 index fb92a8c9a..000000000 --- a/packages/platforms/quanta/x86-64/ly7-rglbmc/onlp/builds/x86_64_quanta_ly7_rglbmc/module/inc/x86_64_quanta_ly7_rglbmc/x86_64_quanta_ly7_rglbmc.x +++ /dev/null @@ -1,14 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#include - -/* <--auto.start.xmacro(ALL).define> */ -/* */ - -/* <--auto.start.xenum(ALL).define> */ -/* */ - - diff --git a/packages/platforms/quanta/x86-64/ly7-rglbmc/onlp/builds/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/ly7-rglbmc/onlp/builds/x86_64_quanta_ly7_rglbmc/module/inc/x86_64_quanta_ly7_rglbmc/x86_64_quanta_ly7_rglbmc_config.h deleted file mode 100755 index 77fc4eedd..000000000 --- a/packages/platforms/quanta/x86-64/ly7-rglbmc/onlp/builds/x86_64_quanta_ly7_rglbmc/module/inc/x86_64_quanta_ly7_rglbmc/x86_64_quanta_ly7_rglbmc_config.h +++ /dev/null @@ -1,167 +0,0 @@ -/**************************************************************************//** - * - * @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/ly7-rglbmc/onlp/builds/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/ly7-rglbmc/onlp/builds/x86_64_quanta_ly7_rglbmc/module/inc/x86_64_quanta_ly7_rglbmc/x86_64_quanta_ly7_rglbmc_dox.h deleted file mode 100755 index 95cb5d2dc..000000000 --- a/packages/platforms/quanta/x86-64/ly7-rglbmc/onlp/builds/x86_64_quanta_ly7_rglbmc/module/inc/x86_64_quanta_ly7_rglbmc/x86_64_quanta_ly7_rglbmc_dox.h +++ /dev/null @@ -1,26 +0,0 @@ -/**************************************************************************//** - * - * 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/ly7-rglbmc/onlp/builds/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/ly7-rglbmc/onlp/builds/x86_64_quanta_ly7_rglbmc/module/inc/x86_64_quanta_ly7_rglbmc/x86_64_quanta_ly7_rglbmc_gpio_table.h deleted file mode 100755 index 8317d9780..000000000 --- a/packages/platforms/quanta/x86-64/ly7-rglbmc/onlp/builds/x86_64_quanta_ly7_rglbmc/module/inc/x86_64_quanta_ly7_rglbmc/x86_64_quanta_ly7_rglbmc_gpio_table.h +++ /dev/null @@ -1,39 +0,0 @@ -#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/ly7-rglbmc/onlp/builds/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/ly7-rglbmc/onlp/builds/x86_64_quanta_ly7_rglbmc/module/inc/x86_64_quanta_ly7_rglbmc/x86_64_quanta_ly7_rglbmc_porting.h deleted file mode 100755 index 0518955a9..000000000 --- a/packages/platforms/quanta/x86-64/ly7-rglbmc/onlp/builds/x86_64_quanta_ly7_rglbmc/module/inc/x86_64_quanta_ly7_rglbmc/x86_64_quanta_ly7_rglbmc_porting.h +++ /dev/null @@ -1,77 +0,0 @@ -/**************************************************************************//** - * - * @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_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/ly7-rglbmc/onlp/builds/x86_64_quanta_ly7_rglbmc/module/make.mk b/packages/platforms/quanta/x86-64/ly7-rglbmc/onlp/builds/x86_64_quanta_ly7_rglbmc/module/make.mk deleted file mode 100755 index 9976c5529..000000000 --- a/packages/platforms/quanta/x86-64/ly7-rglbmc/onlp/builds/x86_64_quanta_ly7_rglbmc/module/make.mk +++ /dev/null @@ -1,10 +0,0 @@ -############################################################################### -# -# -# -############################################################################### -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/ly7-rglbmc/onlp/builds/x86_64_quanta_ly7_rglbmc/module/src/Makefile b/packages/platforms/quanta/x86-64/ly7-rglbmc/onlp/builds/x86_64_quanta_ly7_rglbmc/module/src/Makefile deleted file mode 100755 index 0aa71303b..000000000 --- a/packages/platforms/quanta/x86-64/ly7-rglbmc/onlp/builds/x86_64_quanta_ly7_rglbmc/module/src/Makefile +++ /dev/null @@ -1,9 +0,0 @@ -############################################################################### -# -# Local source generation targets. -# -############################################################################### - -ucli: - @../../../../tools/uclihandlers.py x86_64_quanta_ly7_rglbmc_ucli.c - diff --git a/packages/platforms/quanta/x86-64/ly7-rglbmc/onlp/builds/x86_64_quanta_ly7_rglbmc/module/src/fani.c b/packages/platforms/quanta/x86-64/ly7-rglbmc/onlp/builds/x86_64_quanta_ly7_rglbmc/module/src/fani.c deleted file mode 100755 index 7594b0ca0..000000000 --- a/packages/platforms/quanta/x86-64/ly7-rglbmc/onlp/builds/x86_64_quanta_ly7_rglbmc/module/src/fani.c +++ /dev/null @@ -1,31 +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 - -int -onlp_fani_init(void) -{ - return ONLP_STATUS_E_UNSUPPORTED; -} diff --git a/packages/platforms/quanta/x86-64/ly7-rglbmc/onlp/builds/x86_64_quanta_ly7_rglbmc/module/src/ledi.c b/packages/platforms/quanta/x86-64/ly7-rglbmc/onlp/builds/x86_64_quanta_ly7_rglbmc/module/src/ledi.c deleted file mode 100755 index 74928269e..000000000 --- a/packages/platforms/quanta/x86-64/ly7-rglbmc/onlp/builds/x86_64_quanta_ly7_rglbmc/module/src/ledi.c +++ /dev/null @@ -1,78 +0,0 @@ -#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/ly7-rglbmc/onlp/builds/x86_64_quanta_ly7_rglbmc/module/src/make.mk b/packages/platforms/quanta/x86-64/ly7-rglbmc/onlp/builds/x86_64_quanta_ly7_rglbmc/module/src/make.mk deleted file mode 100755 index f48c4f6ee..000000000 --- a/packages/platforms/quanta/x86-64/ly7-rglbmc/onlp/builds/x86_64_quanta_ly7_rglbmc/module/src/make.mk +++ /dev/null @@ -1,9 +0,0 @@ -############################################################################### -# -# -# -############################################################################### - -LIBRARY := x86_64_quanta_ly7_rglbmc -$(LIBRARY)_SUBDIR := $(dir $(lastword $(MAKEFILE_LIST))) -include $(BUILDER)/lib.mk diff --git a/packages/platforms/quanta/x86-64/ly7-rglbmc/onlp/builds/x86_64_quanta_ly7_rglbmc/module/src/psui.c b/packages/platforms/quanta/x86-64/ly7-rglbmc/onlp/builds/x86_64_quanta_ly7_rglbmc/module/src/psui.c deleted file mode 100755 index b5cedce16..000000000 --- a/packages/platforms/quanta/x86-64/ly7-rglbmc/onlp/builds/x86_64_quanta_ly7_rglbmc/module/src/psui.c +++ /dev/null @@ -1,15 +0,0 @@ -/************************************************************ - * - * - ************************************************************ - * - * - * - ***********************************************************/ -#include - -int -onlp_psui_init(void) -{ - return ONLP_STATUS_E_UNSUPPORTED; -} diff --git a/packages/platforms/quanta/x86-64/ly7-rglbmc/onlp/builds/x86_64_quanta_ly7_rglbmc/module/src/sfpi.c b/packages/platforms/quanta/x86-64/ly7-rglbmc/onlp/builds/x86_64_quanta_ly7_rglbmc/module/src/sfpi.c deleted file mode 100755 index 5bb1079f4..000000000 --- a/packages/platforms/quanta/x86-64/ly7-rglbmc/onlp/builds/x86_64_quanta_ly7_rglbmc/module/src/sfpi.c +++ /dev/null @@ -1,409 +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. - * - * - ************************************************************ - * - * 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/ly7-rglbmc/onlp/builds/x86_64_quanta_ly7_rglbmc/module/src/sysi.c b/packages/platforms/quanta/x86-64/ly7-rglbmc/onlp/builds/x86_64_quanta_ly7_rglbmc/module/src/sysi.c deleted file mode 100755 index 2be2773f6..000000000 --- a/packages/platforms/quanta/x86-64/ly7-rglbmc/onlp/builds/x86_64_quanta_ly7_rglbmc/module/src/sysi.c +++ /dev/null @@ -1,66 +0,0 @@ -/************************************************************ - * - * - ************************************************************ - * - * - * - ***********************************************************/ -#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/ly7-rglbmc/onlp/builds/x86_64_quanta_ly7_rglbmc/module/src/thermali.c b/packages/platforms/quanta/x86-64/ly7-rglbmc/onlp/builds/x86_64_quanta_ly7_rglbmc/module/src/thermali.c deleted file mode 100755 index 2a84c0178..000000000 --- a/packages/platforms/quanta/x86-64/ly7-rglbmc/onlp/builds/x86_64_quanta_ly7_rglbmc/module/src/thermali.c +++ /dev/null @@ -1,31 +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 - -int -onlp_thermali_init(void) -{ - return ONLP_STATUS_E_UNSUPPORTED; -} diff --git a/packages/platforms/quanta/x86-64/ly7-rglbmc/onlp/builds/x86_64_quanta_ly7_rglbmc/module/src/x86_64_quanta_ly7_rglbmc_config.c b/packages/platforms/quanta/x86-64/ly7-rglbmc/onlp/builds/x86_64_quanta_ly7_rglbmc/module/src/x86_64_quanta_ly7_rglbmc_config.c deleted file mode 100755 index bf8c37fb5..000000000 --- a/packages/platforms/quanta/x86-64/ly7-rglbmc/onlp/builds/x86_64_quanta_ly7_rglbmc/module/src/x86_64_quanta_ly7_rglbmc_config.c +++ /dev/null @@ -1,95 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#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/ly7-rglbmc/onlp/builds/x86_64_quanta_ly7_rglbmc/module/src/x86_64_quanta_ly7_rglbmc_enums.c b/packages/platforms/quanta/x86-64/ly7-rglbmc/onlp/builds/x86_64_quanta_ly7_rglbmc/module/src/x86_64_quanta_ly7_rglbmc_enums.c deleted file mode 100755 index 1d1f3f933..000000000 --- a/packages/platforms/quanta/x86-64/ly7-rglbmc/onlp/builds/x86_64_quanta_ly7_rglbmc/module/src/x86_64_quanta_ly7_rglbmc_enums.c +++ /dev/null @@ -1,10 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#include - -/* <--auto.start.enum(ALL).source> */ -/* */ - diff --git a/packages/platforms/quanta/x86-64/ly7-rglbmc/onlp/builds/x86_64_quanta_ly7_rglbmc/module/src/x86_64_quanta_ly7_rglbmc_int.h b/packages/platforms/quanta/x86-64/ly7-rglbmc/onlp/builds/x86_64_quanta_ly7_rglbmc/module/src/x86_64_quanta_ly7_rglbmc_int.h deleted file mode 100755 index a221de618..000000000 --- a/packages/platforms/quanta/x86-64/ly7-rglbmc/onlp/builds/x86_64_quanta_ly7_rglbmc/module/src/x86_64_quanta_ly7_rglbmc_int.h +++ /dev/null @@ -1,281 +0,0 @@ -/**************************************************************************//** - * - * 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 - -/* */ -/** 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[]; - -/** 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 { - 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[]; - -/** 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 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/ly7-rglbmc/onlp/builds/x86_64_quanta_ly7_rglbmc/module/src/x86_64_quanta_ly7_rglbmc_log.c b/packages/platforms/quanta/x86-64/ly7-rglbmc/onlp/builds/x86_64_quanta_ly7_rglbmc/module/src/x86_64_quanta_ly7_rglbmc_log.c deleted file mode 100755 index f1e92e8c0..000000000 --- a/packages/platforms/quanta/x86-64/ly7-rglbmc/onlp/builds/x86_64_quanta_ly7_rglbmc/module/src/x86_64_quanta_ly7_rglbmc_log.c +++ /dev/null @@ -1,18 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#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/ly7-rglbmc/onlp/builds/x86_64_quanta_ly7_rglbmc/module/src/x86_64_quanta_ly7_rglbmc_log.h b/packages/platforms/quanta/x86-64/ly7-rglbmc/onlp/builds/x86_64_quanta_ly7_rglbmc/module/src/x86_64_quanta_ly7_rglbmc_log.h deleted file mode 100755 index 6a5dc0cee..000000000 --- a/packages/platforms/quanta/x86-64/ly7-rglbmc/onlp/builds/x86_64_quanta_ly7_rglbmc/module/src/x86_64_quanta_ly7_rglbmc_log.h +++ /dev/null @@ -1,12 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#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/ly7-rglbmc/onlp/builds/x86_64_quanta_ly7_rglbmc/module/src/x86_64_quanta_ly7_rglbmc_module.c b/packages/platforms/quanta/x86-64/ly7-rglbmc/onlp/builds/x86_64_quanta_ly7_rglbmc/module/src/x86_64_quanta_ly7_rglbmc_module.c deleted file mode 100755 index 7fbcc78e8..000000000 --- a/packages/platforms/quanta/x86-64/ly7-rglbmc/onlp/builds/x86_64_quanta_ly7_rglbmc/module/src/x86_64_quanta_ly7_rglbmc_module.c +++ /dev/null @@ -1,24 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#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/ly7-rglbmc/onlp/builds/x86_64_quanta_ly7_rglbmc/module/src/x86_64_quanta_ly7_rglbmc_ucli.c b/packages/platforms/quanta/x86-64/ly7-rglbmc/onlp/builds/x86_64_quanta_ly7_rglbmc/module/src/x86_64_quanta_ly7_rglbmc_ucli.c deleted file mode 100755 index cf50c8f51..000000000 --- a/packages/platforms/quanta/x86-64/ly7-rglbmc/onlp/builds/x86_64_quanta_ly7_rglbmc/module/src/x86_64_quanta_ly7_rglbmc_ucli.c +++ /dev/null @@ -1,50 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#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/ly7-rglbmc/platform-config/Makefile b/packages/platforms/quanta/x86-64/ly7-rglbmc/platform-config/Makefile deleted file mode 100755 index 003238cf6..000000000 --- a/packages/platforms/quanta/x86-64/ly7-rglbmc/platform-config/Makefile +++ /dev/null @@ -1 +0,0 @@ -include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/quanta/x86-64/ly7-rglbmc/platform-config/r0/Makefile b/packages/platforms/quanta/x86-64/ly7-rglbmc/platform-config/r0/Makefile deleted file mode 100755 index 003238cf6..000000000 --- a/packages/platforms/quanta/x86-64/ly7-rglbmc/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/quanta/x86-64/ly7-rglbmc/platform-config/r0/PKG.yml b/packages/platforms/quanta/x86-64/ly7-rglbmc/platform-config/r0/PKG.yml deleted file mode 100755 index 25082e7df..000000000 --- a/packages/platforms/quanta/x86-64/ly7-rglbmc/platform-config/r0/PKG.yml +++ /dev/null @@ -1 +0,0 @@ -!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/ly7-rglbmc/platform-config/r0/src/lib/x86-64-quanta-ly7-rglbmc-r0.yml b/packages/platforms/quanta/x86-64/ly7-rglbmc/platform-config/r0/src/lib/x86-64-quanta-ly7-rglbmc-r0.yml deleted file mode 100755 index 8cf8da1f1..000000000 --- a/packages/platforms/quanta/x86-64/ly7-rglbmc/platform-config/r0/src/lib/x86-64-quanta-ly7-rglbmc-r0.yml +++ /dev/null @@ -1,31 +0,0 @@ ---- - -###################################################################### -# -# 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/ly7-rglbmc/platform-config/r0/src/python/x86_64_quanta_ly7_rglbmc_r0/__init__.py b/packages/platforms/quanta/x86-64/ly7-rglbmc/platform-config/r0/src/python/x86_64_quanta_ly7_rglbmc_r0/__init__.py deleted file mode 100755 index 1cd8c6459..000000000 --- a/packages/platforms/quanta/x86-64/ly7-rglbmc/platform-config/r0/src/python/x86_64_quanta_ly7_rglbmc_r0/__init__.py +++ /dev/null @@ -1,22 +0,0 @@ -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 diff --git a/packages/platforms/quanta/x86-64/ly8-rangeley/.gitignore b/packages/platforms/quanta/x86-64/ly8-rangeley/.gitignore deleted file mode 100644 index 23b25ff06..000000000 --- a/packages/platforms/quanta/x86-64/ly8-rangeley/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -*x86*64*quanta*ly8*rangeley*.mk -onlpdump.mk diff --git a/packages/platforms/quanta/x86-64/ly8-rangeley/Makefile b/packages/platforms/quanta/x86-64/ly8-rangeley/Makefile deleted file mode 100644 index 003238cf6..000000000 --- a/packages/platforms/quanta/x86-64/ly8-rangeley/Makefile +++ /dev/null @@ -1 +0,0 @@ -include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/quanta/x86-64/ly8-rangeley/modules/Makefile b/packages/platforms/quanta/x86-64/ly8-rangeley/modules/Makefile deleted file mode 100644 index 003238cf6..000000000 --- a/packages/platforms/quanta/x86-64/ly8-rangeley/modules/Makefile +++ /dev/null @@ -1 +0,0 @@ -include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/quanta/x86-64/ly8-rangeley/modules/PKG.yml b/packages/platforms/quanta/x86-64/ly8-rangeley/modules/PKG.yml deleted file mode 100755 index a3b3f82ec..000000000 --- a/packages/platforms/quanta/x86-64/ly8-rangeley/modules/PKG.yml +++ /dev/null @@ -1 +0,0 @@ -!include $ONL_TEMPLATES/platform-modules.yml ARCH=amd64 VENDOR=quanta BASENAME=x86-64-quanta-ly8-rangeley KERNELS="onl-kernel-3.16-lts-x86-64-all:amd64" diff --git a/packages/platforms/quanta/x86-64/ly8-rangeley/modules/builds/.gitignore b/packages/platforms/quanta/x86-64/ly8-rangeley/modules/builds/.gitignore deleted file mode 100755 index a65b41774..000000000 --- a/packages/platforms/quanta/x86-64/ly8-rangeley/modules/builds/.gitignore +++ /dev/null @@ -1 +0,0 @@ -lib diff --git a/packages/platforms/quanta/x86-64/ly8-rangeley/modules/builds/Makefile b/packages/platforms/quanta/x86-64/ly8-rangeley/modules/builds/Makefile deleted file mode 100755 index 5d0014c25..000000000 --- a/packages/platforms/quanta/x86-64/ly8-rangeley/modules/builds/Makefile +++ /dev/null @@ -1,6 +0,0 @@ -KERNELS := onl-kernel-3.16-lts-x86-64-all:amd64 -KMODULES := $(wildcard *.c) -VENDOR := quanta -BASENAME := x86-64-quanta-ly8-rangeley -ARCH := x86_64 -include $(ONL)/make/kmodule.mk diff --git a/packages/platforms/quanta/x86-64/ly8-rangeley/modules/builds/quanta_platform_ly8.c b/packages/platforms/quanta/x86-64/ly8-rangeley/modules/builds/quanta_platform_ly8.c deleted file mode 100755 index 66018dde5..000000000 --- a/packages/platforms/quanta/x86-64/ly8-rangeley/modules/builds/quanta_platform_ly8.c +++ /dev/null @@ -1,370 +0,0 @@ -/* - * 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-ly8" - -#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_24c02, - i2c_type_emerson700, - i2c_type_quanta_ly8_hwmon, - i2c_type_optoe1_QSFP, - i2c_type_optoe2_SFP, -}; - -char *i2c_type_names[] = { - "spd", - "ds1339", - "pca9546", - "pca9548", - "pca9554", - "pca9555", - "pca9698", - "24c02", - "emerson700", - "quanta_ly8_hwmon", - "optoe1", - "optoe2", -}; - -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_ly8_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_quanta_ly8_hwmon, .addr = 0x4e, .name = "PSoc\0" }, - { .parent_bus = (0x00 + 0), .type = i2c_type_spd, .addr = 0x52, .name = "SPD\0" }, - { .parent_bus = (0x00 + 0), .type = i2c_type_rtc, .addr = 0x68, .name = "RTC\0" }, - { .parent_bus = (0x00 + 0), .type = i2c_type_pca9548, .addr = 0x77, .busno = 0x10, .name = "PCA9548_1\0" }, - - { .parent_bus = (0x10 + 1), .type = i2c_type_pca9548, .addr = 0x73, .busno = 0x20, .name = "PCA9548(SFP_1-8)\0" }, - { .parent_bus = (0x10 + 1), .type = i2c_type_pca9548, .addr = 0x74, .busno = 0x28, .name = "PCA9548(SFP_9-16)\0" }, - { .parent_bus = (0x10 + 1), .type = i2c_type_pca9548, .addr = 0x76, .busno = 0x30, .name = "PCA9548(SFP_17-24)\0" }, - { .parent_bus = (0x10 + 2), .type = i2c_type_pca9548, .addr = 0x73, .busno = 0x38, .name = "PCA9548(SFP_25-32)\0" }, - { .parent_bus = (0x10 + 2), .type = i2c_type_pca9548, .addr = 0x74, .busno = 0x40, .name = "PCA9548(SFP_33-40)\0" }, - { .parent_bus = (0x10 + 2), .type = i2c_type_pca9548, .addr = 0x75, .busno = 0x48, .name = "PCA9548(SFP_41-48)\0" }, - { .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_optoe2_SFP, .addr = 0x50, .name = "SFP_1_EEPROM\0" }, - { .parent_bus = (0x20 + 1), .type = i2c_type_optoe2_SFP, .addr = 0x50, .name = "SFP_2_EEPROM\0" }, - { .parent_bus = (0x20 + 2), .type = i2c_type_optoe2_SFP, .addr = 0x50, .name = "SFP_3_EEPROM\0" }, - { .parent_bus = (0x20 + 3), .type = i2c_type_optoe2_SFP, .addr = 0x50, .name = "SFP_4_EEPROM\0" }, - { .parent_bus = (0x20 + 4), .type = i2c_type_optoe2_SFP, .addr = 0x50, .name = "SFP_5_EEPROM\0" }, - { .parent_bus = (0x20 + 5), .type = i2c_type_optoe2_SFP, .addr = 0x50, .name = "SFP_6_EEPROM\0" }, - { .parent_bus = (0x20 + 6), .type = i2c_type_optoe2_SFP, .addr = 0x50, .name = "SFP_7_EEPROM\0" }, - { .parent_bus = (0x20 + 7), .type = i2c_type_optoe2_SFP, .addr = 0x50, .name = "SFP_8_EEPROM\0" }, - { .parent_bus = (0x28 + 0), .type = i2c_type_optoe2_SFP, .addr = 0x50, .name = "SFP_9_EEPROM\0" }, - { .parent_bus = (0x28 + 1), .type = i2c_type_optoe2_SFP, .addr = 0x50, .name = "SFP_10_EEPROM\0" }, - { .parent_bus = (0x28 + 2), .type = i2c_type_optoe2_SFP, .addr = 0x50, .name = "SFP_11_EEPROM\0" }, - { .parent_bus = (0x28 + 3), .type = i2c_type_optoe2_SFP, .addr = 0x50, .name = "SFP_12_EEPROM\0" }, - { .parent_bus = (0x28 + 4), .type = i2c_type_optoe2_SFP, .addr = 0x50, .name = "SFP_13_EEPROM\0" }, - { .parent_bus = (0x28 + 5), .type = i2c_type_optoe2_SFP, .addr = 0x50, .name = "SFP_14_EEPROM\0" }, - { .parent_bus = (0x28 + 6), .type = i2c_type_optoe2_SFP, .addr = 0x50, .name = "SFP_15_EEPROM\0" }, - { .parent_bus = (0x28 + 7), .type = i2c_type_optoe2_SFP, .addr = 0x50, .name = "SFP_16_EEPROM\0" }, - { .parent_bus = (0x30 + 0), .type = i2c_type_optoe2_SFP, .addr = 0x50, .name = "SFP_17_EEPROM\0" }, - { .parent_bus = (0x30 + 1), .type = i2c_type_optoe2_SFP, .addr = 0x50, .name = "SFP_18_EEPROM\0" }, - { .parent_bus = (0x30 + 2), .type = i2c_type_optoe2_SFP, .addr = 0x50, .name = "SFP_19_EEPROM\0" }, - { .parent_bus = (0x30 + 3), .type = i2c_type_optoe2_SFP, .addr = 0x50, .name = "SFP_20_EEPROM\0" }, - { .parent_bus = (0x30 + 4), .type = i2c_type_optoe2_SFP, .addr = 0x50, .name = "SFP_21_EEPROM\0" }, - { .parent_bus = (0x30 + 5), .type = i2c_type_optoe2_SFP, .addr = 0x50, .name = "SFP_22_EEPROM\0" }, - { .parent_bus = (0x30 + 6), .type = i2c_type_optoe2_SFP, .addr = 0x50, .name = "SFP_23_EEPROM\0" }, - { .parent_bus = (0x30 + 7), .type = i2c_type_optoe2_SFP, .addr = 0x50, .name = "SFP_24_EEPROM\0" }, - { .parent_bus = (0x38 + 0), .type = i2c_type_optoe2_SFP, .addr = 0x50, .name = "SFP_25_EEPROM\0" }, - { .parent_bus = (0x38 + 1), .type = i2c_type_optoe2_SFP, .addr = 0x50, .name = "SFP_26_EEPROM\0" }, - { .parent_bus = (0x38 + 2), .type = i2c_type_optoe2_SFP, .addr = 0x50, .name = "SFP_27_EEPROM\0" }, - { .parent_bus = (0x38 + 3), .type = i2c_type_optoe2_SFP, .addr = 0x50, .name = "SFP_28_EEPROM\0" }, - { .parent_bus = (0x38 + 4), .type = i2c_type_optoe2_SFP, .addr = 0x50, .name = "SFP_29_EEPROM\0" }, - { .parent_bus = (0x38 + 5), .type = i2c_type_optoe2_SFP, .addr = 0x50, .name = "SFP_30_EEPROM\0" }, - { .parent_bus = (0x38 + 6), .type = i2c_type_optoe2_SFP, .addr = 0x50, .name = "SFP_31_EEPROM\0" }, - { .parent_bus = (0x38 + 7), .type = i2c_type_optoe2_SFP, .addr = 0x50, .name = "SFP_32_EEPROM\0" }, - { .parent_bus = (0x40 + 0), .type = i2c_type_optoe2_SFP, .addr = 0x50, .name = "SFP_33_EEPROM\0" }, - { .parent_bus = (0x40 + 1), .type = i2c_type_optoe2_SFP, .addr = 0x50, .name = "SFP_34_EEPROM\0" }, - { .parent_bus = (0x40 + 2), .type = i2c_type_optoe2_SFP, .addr = 0x50, .name = "SFP_35_EEPROM\0" }, - { .parent_bus = (0x40 + 3), .type = i2c_type_optoe2_SFP, .addr = 0x50, .name = "SFP_36_EEPROM\0" }, - { .parent_bus = (0x40 + 4), .type = i2c_type_optoe2_SFP, .addr = 0x50, .name = "SFP_37_EEPROM\0" }, - { .parent_bus = (0x40 + 5), .type = i2c_type_optoe2_SFP, .addr = 0x50, .name = "SFP_38_EEPROM\0" }, - { .parent_bus = (0x40 + 6), .type = i2c_type_optoe2_SFP, .addr = 0x50, .name = "SFP_39_EEPROM\0" }, - { .parent_bus = (0x40 + 7), .type = i2c_type_optoe2_SFP, .addr = 0x50, .name = "SFP_40_EEPROM\0" }, - { .parent_bus = (0x48 + 0), .type = i2c_type_optoe2_SFP, .addr = 0x50, .name = "SFP_41_EEPROM\0" }, - { .parent_bus = (0x48 + 1), .type = i2c_type_optoe2_SFP, .addr = 0x50, .name = "SFP_42_EEPROM\0" }, - { .parent_bus = (0x48 + 2), .type = i2c_type_optoe2_SFP, .addr = 0x50, .name = "SFP_43_EEPROM\0" }, - { .parent_bus = (0x48 + 3), .type = i2c_type_optoe2_SFP, .addr = 0x50, .name = "SFP_44_EEPROM\0" }, - { .parent_bus = (0x48 + 4), .type = i2c_type_optoe2_SFP, .addr = 0x50, .name = "SFP_45_EEPROM\0" }, - { .parent_bus = (0x48 + 5), .type = i2c_type_optoe2_SFP, .addr = 0x50, .name = "SFP_46_EEPROM\0" }, - { .parent_bus = (0x48 + 6), .type = i2c_type_optoe2_SFP, .addr = 0x50, .name = "SFP_47_EEPROM\0" }, - { .parent_bus = (0x48 + 7), .type = i2c_type_optoe2_SFP, .addr = 0x50, .name = "SFP_48_EEPROM\0" }, - - { .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" }, - { .parent_bus = (0x10 + 3), .type = i2c_type_pca9698, .addr = 0x22, .name = "PCA9698(SFP_17-24)\0" }, - { .parent_bus = (0x10 + 4), .type = i2c_type_pca9698, .addr = 0x23, .name = "PCA9698(SFP_25-32)\0" }, - { .parent_bus = (0x10 + 4), .type = i2c_type_pca9698, .addr = 0x24, .name = "PCA9698(SFP_33-40)\0" }, - { .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_optoe1_QSFP, .addr = 0x50, .name = "QSFP_1_EEPROM\0" }, - { .parent_bus = (0x50 + 1), .type = i2c_type_optoe1_QSFP, .addr = 0x50, .name = "QSFP_2_EEPROM\0" }, - { .parent_bus = (0x50 + 2), .type = i2c_type_optoe1_QSFP, .addr = 0x50, .name = "QSFP_3_EEPROM\0" }, - { .parent_bus = (0x50 + 3), .type = i2c_type_optoe1_QSFP, .addr = 0x50, .name = "QSFP_4_EEPROM\0" }, - - { .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" }, - - /* 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_optoe1_QSFP, .addr = 0x50, .name = "QDB_QSFP_1_EEPROM\0" }, - { .parent_bus = (0x58 + 1), .type = i2c_type_optoe1_QSFP, .addr = 0x50, .name = "QDB_QSFP_2_EEPROM\0" }, - - { .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 */ - { .parent_bus = (0x18 + 1), .type = i2c_type_emerson700, .addr = 0x69, .name = "PSU_2\0" }, /* RPSU 2 */ - { .parent_bus = (0x18 + 2), .type = i2c_type_pca9555, .addr = 0x26, .name = "PCA9555_5(PSU)\0" }, - { .parent_bus = (0x18 + 3), .type = i2c_type_24c02, .addr = 0x54, .name = "Board_EEPROM\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 - -/* <--auto.start.xmacro(ALL).define> */ -/* */ - -/* <--auto.start.xenum(ALL).define> */ -/* */ - - diff --git a/packages/platforms/quanta/x86-64/ly8-rangeley/onlp/builds/x86_64_quanta_ly8_rangeley/module/inc/x86_64_quanta_ly8_rangeley/x86_64_quanta_ly8_rangeley_config.h b/packages/platforms/quanta/x86-64/ly8-rangeley/onlp/builds/x86_64_quanta_ly8_rangeley/module/inc/x86_64_quanta_ly8_rangeley/x86_64_quanta_ly8_rangeley_config.h deleted file mode 100644 index 634015756..000000000 --- a/packages/platforms/quanta/x86-64/ly8-rangeley/onlp/builds/x86_64_quanta_ly8_rangeley/module/inc/x86_64_quanta_ly8_rangeley/x86_64_quanta_ly8_rangeley_config.h +++ /dev/null @@ -1,167 +0,0 @@ -/**************************************************************************//** - * - * @file - * @brief x86_64_quanta_ly8_rangeley Configuration Header - * - * @addtogroup x86_64_quanta_ly8_rangeley-config - * @{ - * - *****************************************************************************/ -#ifndef __X86_64_QUANTA_LY8_RANGELEY_CONFIG_H__ -#define __X86_64_QUANTA_LY8_RANGELEY_CONFIG_H__ - -#ifdef GLOBAL_INCLUDE_CUSTOM_CONFIG -#include -#endif -#ifdef X86_64_QUANTA_LY8_RANGELEY_INCLUDE_CUSTOM_CONFIG -#include -#endif - -/* */ -#include -/** - * X86_64_QUANTA_LY8_RANGELEY_CONFIG_INCLUDE_LOGGING - * - * Include or exclude logging. */ - - -#ifndef X86_64_QUANTA_LY8_RANGELEY_CONFIG_INCLUDE_LOGGING -#define X86_64_QUANTA_LY8_RANGELEY_CONFIG_INCLUDE_LOGGING 1 -#endif - -/** - * X86_64_QUANTA_LY8_RANGELEY_CONFIG_LOG_OPTIONS_DEFAULT - * - * Default enabled log options. */ - - -#ifndef X86_64_QUANTA_LY8_RANGELEY_CONFIG_LOG_OPTIONS_DEFAULT -#define X86_64_QUANTA_LY8_RANGELEY_CONFIG_LOG_OPTIONS_DEFAULT AIM_LOG_OPTIONS_DEFAULT -#endif - -/** - * X86_64_QUANTA_LY8_RANGELEY_CONFIG_LOG_BITS_DEFAULT - * - * Default enabled log bits. */ - - -#ifndef X86_64_QUANTA_LY8_RANGELEY_CONFIG_LOG_BITS_DEFAULT -#define X86_64_QUANTA_LY8_RANGELEY_CONFIG_LOG_BITS_DEFAULT AIM_LOG_BITS_DEFAULT -#endif - -/** - * X86_64_QUANTA_LY8_RANGELEY_CONFIG_LOG_CUSTOM_BITS_DEFAULT - * - * Default enabled custom log bits. */ - - -#ifndef X86_64_QUANTA_LY8_RANGELEY_CONFIG_LOG_CUSTOM_BITS_DEFAULT -#define X86_64_QUANTA_LY8_RANGELEY_CONFIG_LOG_CUSTOM_BITS_DEFAULT 0 -#endif - -/** - * X86_64_QUANTA_LY8_RANGELEY_CONFIG_PORTING_STDLIB - * - * Default all porting macros to use the C standard libraries. */ - - -#ifndef X86_64_QUANTA_LY8_RANGELEY_CONFIG_PORTING_STDLIB -#define X86_64_QUANTA_LY8_RANGELEY_CONFIG_PORTING_STDLIB 1 -#endif - -/** - * X86_64_QUANTA_LY8_RANGELEY_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS - * - * Include standard library headers for stdlib porting macros. */ - - -#ifndef X86_64_QUANTA_LY8_RANGELEY_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS -#define X86_64_QUANTA_LY8_RANGELEY_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS X86_64_QUANTA_LY8_RANGELEY_CONFIG_PORTING_STDLIB -#endif - -/** - * X86_64_QUANTA_LY8_RANGELEY_CONFIG_INCLUDE_UCLI - * - * Include generic uCli support. */ - - -#ifndef X86_64_QUANTA_LY8_RANGELEY_CONFIG_INCLUDE_UCLI -#define X86_64_QUANTA_LY8_RANGELEY_CONFIG_INCLUDE_UCLI 0 -#endif - -/** - * X86_64_QUANTA_LY8_RANGELEY_CONFIG_SYSFAN_RPM_FAILURE_THRESHOLD - * - * RPM Threshold at which the fan is considered to have failed. */ - - -#ifndef X86_64_QUANTA_LY8_RANGELEY_CONFIG_SYSFAN_RPM_FAILURE_THRESHOLD -#define X86_64_QUANTA_LY8_RANGELEY_CONFIG_SYSFAN_RPM_FAILURE_THRESHOLD 3000 -#endif - -/** - * X86_64_QUANTA_LY8_RANGELEY_CONFIG_SYSFAN_F2B_RPM_MAX - * - * Maximum system front-to-back fan speed. */ - - -#ifndef X86_64_QUANTA_LY8_RANGELEY_CONFIG_SYSFAN_F2B_RPM_MAX -#define X86_64_QUANTA_LY8_RANGELEY_CONFIG_SYSFAN_F2B_RPM_MAX 18000 -#endif - -/** - * X86_64_QUANTA_LY8_RANGELEY_CONFIG_SYSFAN_B2F_RPM_MAX - * - * Maximum system back-to-front fan speed. */ - - -#ifndef X86_64_QUANTA_LY8_RANGELEY_CONFIG_SYSFAN_B2F_RPM_MAX -#define X86_64_QUANTA_LY8_RANGELEY_CONFIG_SYSFAN_B2F_RPM_MAX 18000 -#endif - -/** - * X86_64_QUANTA_LY8_RANGELEY_CONFIG_PHY_RESET_DELAY_MS - * - * Time to hold Phy GPIO in reset, in ms */ - - -#ifndef X86_64_QUANTA_LY8_RANGELEY_CONFIG_PHY_RESET_DELAY_MS -#define X86_64_QUANTA_LY8_RANGELEY_CONFIG_PHY_RESET_DELAY_MS 100 -#endif - - - -/** - * All compile time options can be queried or displayed - */ - -/** Configuration settings structure. */ -typedef struct x86_64_quanta_ly8_rangeley_config_settings_s { - /** name */ - const char* name; - /** value */ - const char* value; -} x86_64_quanta_ly8_rangeley_config_settings_t; - -/** Configuration settings table. */ -/** x86_64_quanta_ly8_rangeley_config_settings table. */ -extern x86_64_quanta_ly8_rangeley_config_settings_t x86_64_quanta_ly8_rangeley_config_settings[]; - -/** - * @brief Lookup a configuration setting. - * @param setting The name of the configuration option to lookup. - */ -const char* x86_64_quanta_ly8_rangeley_config_lookup(const char* setting); - -/** - * @brief Show the compile-time configuration. - * @param pvs The output stream. - */ -int x86_64_quanta_ly8_rangeley_config_show(struct aim_pvs_s* pvs); - -/* */ - -#include "x86_64_quanta_ly8_rangeley_porting.h" - -#endif /* __X86_64_QUANTA_LY8_RANGELEY_CONFIG_H__ */ -/* @} */ diff --git a/packages/platforms/quanta/x86-64/ly8-rangeley/onlp/builds/x86_64_quanta_ly8_rangeley/module/inc/x86_64_quanta_ly8_rangeley/x86_64_quanta_ly8_rangeley_dox.h b/packages/platforms/quanta/x86-64/ly8-rangeley/onlp/builds/x86_64_quanta_ly8_rangeley/module/inc/x86_64_quanta_ly8_rangeley/x86_64_quanta_ly8_rangeley_dox.h deleted file mode 100644 index 05feadf28..000000000 --- a/packages/platforms/quanta/x86-64/ly8-rangeley/onlp/builds/x86_64_quanta_ly8_rangeley/module/inc/x86_64_quanta_ly8_rangeley/x86_64_quanta_ly8_rangeley_dox.h +++ /dev/null @@ -1,26 +0,0 @@ -/**************************************************************************//** - * - * x86_64_quanta_ly8_rangeley Doxygen Header - * - *****************************************************************************/ -#ifndef __X86_64_QUANTA_LY8_RANGELEY_DOX_H__ -#define __X86_64_QUANTA_LY8_RANGELEY_DOX_H__ - -/** - * @defgroup x86_64_quanta_ly8_rangeley x86_64_quanta_ly8_rangeley - x86_64_quanta_ly8_rangeley Description - * - -The documentation overview for this module should go here. - - * - * @{ - * - * @defgroup x86_64_quanta_ly8_rangeley-x86_64_quanta_ly8_rangeley Public Interface - * @defgroup x86_64_quanta_ly8_rangeley-config Compile Time Configuration - * @defgroup x86_64_quanta_ly8_rangeley-porting Porting Macros - * - * @} - * - */ - -#endif /* __X86_64_QUANTA_LY8_RANGELEY_DOX_H__ */ diff --git a/packages/platforms/quanta/x86-64/ly8-rangeley/onlp/builds/x86_64_quanta_ly8_rangeley/module/inc/x86_64_quanta_ly8_rangeley/x86_64_quanta_ly8_rangeley_gpio_table.h b/packages/platforms/quanta/x86-64/ly8-rangeley/onlp/builds/x86_64_quanta_ly8_rangeley/module/inc/x86_64_quanta_ly8_rangeley/x86_64_quanta_ly8_rangeley_gpio_table.h deleted file mode 100755 index 7b05bfb57..000000000 --- a/packages/platforms/quanta/x86-64/ly8-rangeley/onlp/builds/x86_64_quanta_ly8_rangeley/module/inc/x86_64_quanta_ly8_rangeley/x86_64_quanta_ly8_rangeley_gpio_table.h +++ /dev/null @@ -1,132 +0,0 @@ -#ifndef __X86_64_QUANTA_LY8_RANGELEY_GPIO_TABLE_H__ -#define __X86_64_QUANTA_LY8_RANGELEY_GPIO_TABLE_H__ - -/* - * defined within platform/quanta_switch.c - * Quanta Switch Platform driver - */ -#define QUANTA_LY8_PCA953x_GPIO(P1, P2) (P1*8+P2) - -#define QUANTA_LY8_PCA9554_GPIO_SIZE 0x08 -#define QUANTA_LY8_PCA9555_GPIO_SIZE 0x10 -#define QUANTA_LY8_PCA9698_GPIO_SIZE 0x28 - -#define QUANTA_LY8_I2C_GPIO_CPU_BASE 0x40 - -#define QUANTA_LY8_CPU_BOARD_GPIO_BASE (QUANTA_LY8_I2C_GPIO_CPU_BASE) -#define QUANTA_LY8_CPU_BOARD_SYS_P1 (QUANTA_LY8_CPU_BOARD_GPIO_BASE + QUANTA_LY8_PCA953x_GPIO(1,2)) -#define QUANTA_LY8_CPU_BOARD_SYS_P2 (QUANTA_LY8_CPU_BOARD_GPIO_BASE + QUANTA_LY8_PCA953x_GPIO(1,3)) - -#define QUANTA_LY8_I2C_GPIO_BASE 0x80 - -#define QUANTA_LY8_PCA9698INT_GPIO_BASE (QUANTA_LY8_I2C_GPIO_BASE) -#define QUANTA_LY8_PCA9698INT_GPIO_SIZE QUANTA_LY8_PCA9554_GPIO_SIZE - -#define QUANTA_LY8_FAN_GPIO_BASE (QUANTA_LY8_PCA9698INT_GPIO_BASE + QUANTA_LY8_PCA9698INT_GPIO_SIZE) -#define QUANTA_LY8_FAN_GPIO_SIZE QUANTA_LY8_PCA9555_GPIO_SIZE -#define QUANTA_LY8_FAN_PRSNT_N_1 (QUANTA_LY8_FAN_GPIO_BASE + QUANTA_LY8_PCA953x_GPIO(0,4)) -#define QUANTA_LY8_FAN_PRSNT_N_2 (QUANTA_LY8_FAN_GPIO_BASE + QUANTA_LY8_PCA953x_GPIO(0,5)) -#define QUANTA_LY8_FAN_PRSNT_N_3 (QUANTA_LY8_FAN_GPIO_BASE + QUANTA_LY8_PCA953x_GPIO(0,6)) -#define QUANTA_LY8_FAN_BF_DET1 (QUANTA_LY8_FAN_GPIO_BASE + QUANTA_LY8_PCA953x_GPIO(1,0)) -#define QUANTA_LY8_FAN_BF_DET2 (QUANTA_LY8_FAN_GPIO_BASE + QUANTA_LY8_PCA953x_GPIO(1,1)) -#define QUANTA_LY8_FAN_BF_DET3 (QUANTA_LY8_FAN_GPIO_BASE + QUANTA_LY8_PCA953x_GPIO(1,2)) -#define QUANTA_LY8_FAN_FAIL_LED_1 (QUANTA_LY8_FAN_GPIO_BASE + QUANTA_LY8_PCA953x_GPIO(1,4)) -#define QUANTA_LY8_FAN_FAIL_LED_2 (QUANTA_LY8_FAN_GPIO_BASE + QUANTA_LY8_PCA953x_GPIO(1,5)) -#define QUANTA_LY8_FAN_FAIL_LED_3 (QUANTA_LY8_FAN_GPIO_BASE + QUANTA_LY8_PCA953x_GPIO(1,6)) - -#define QUANTA_LY8_QSFP_EN_GPIO_BASE (QUANTA_LY8_FAN_GPIO_BASE + QUANTA_LY8_FAN_GPIO_SIZE) -#define QUANTA_LY8_QSFP_EN_GPIO_SIZE QUANTA_LY8_PCA9555_GPIO_SIZE -#define QUANTA_LY8_QSFP_EN_GPIO_P3V3_PW_GD (QUANTA_LY8_QSFP_EN_GPIO_BASE + QUANTA_LY8_PCA953x_GPIO(0,4)) -#define QUANTA_LY8_QSFP_EN_GPIO_P3V3_PW_EN (QUANTA_LY8_QSFP_EN_GPIO_BASE + QUANTA_LY8_PCA953x_GPIO(0,5)) -#define QUANTA_LY8_QSFP_EN_GPIO_QDB_PRSNT (QUANTA_LY8_QSFP_EN_GPIO_BASE + QUANTA_LY8_PCA953x_GPIO(0,6)) - -#define QUANTA_LY8_PCA9698_1_GPIO_BASE (QUANTA_LY8_QSFP_EN_GPIO_BASE + QUANTA_LY8_QSFP_EN_GPIO_SIZE) -#define QUANTA_LY8_PCA9698_1_GPIO_SFP_1_PRSNT_N (QUANTA_LY8_PCA9698_1_GPIO_BASE + QUANTA_LY8_PCA953x_GPIO(0,0)) -#define QUANTA_LY8_PCA9698_1_GPIO_SFP_2_PRSNT_N (QUANTA_LY8_PCA9698_1_GPIO_BASE + QUANTA_LY8_PCA953x_GPIO(0,4)) -#define QUANTA_LY8_PCA9698_1_GPIO_SFP_3_PRSNT_N (QUANTA_LY8_PCA9698_1_GPIO_BASE + QUANTA_LY8_PCA953x_GPIO(1,0)) -#define QUANTA_LY8_PCA9698_1_GPIO_SFP_4_PRSNT_N (QUANTA_LY8_PCA9698_1_GPIO_BASE + QUANTA_LY8_PCA953x_GPIO(1,4)) -#define QUANTA_LY8_PCA9698_1_GPIO_SFP_5_PRSNT_N (QUANTA_LY8_PCA9698_1_GPIO_BASE + QUANTA_LY8_PCA953x_GPIO(2,0)) -#define QUANTA_LY8_PCA9698_1_GPIO_SFP_6_PRSNT_N (QUANTA_LY8_PCA9698_1_GPIO_BASE + QUANTA_LY8_PCA953x_GPIO(2,4)) -#define QUANTA_LY8_PCA9698_1_GPIO_SFP_7_PRSNT_N (QUANTA_LY8_PCA9698_1_GPIO_BASE + QUANTA_LY8_PCA953x_GPIO(3,0)) -#define QUANTA_LY8_PCA9698_1_GPIO_SFP_8_PRSNT_N (QUANTA_LY8_PCA9698_1_GPIO_BASE + QUANTA_LY8_PCA953x_GPIO(3,4)) - -#define QUANTA_LY8_PCA9698_2_GPIO_BASE (QUANTA_LY8_PCA9698_1_GPIO_BASE + QUANTA_LY8_PCA9698_GPIO_SIZE) -#define QUANTA_LY8_PCA9698_2_GPIO_SFP_9_PRSNT_N (QUANTA_LY8_PCA9698_2_GPIO_BASE + QUANTA_LY8_PCA953x_GPIO(0,0)) -#define QUANTA_LY8_PCA9698_2_GPIO_SFP_10_PRSNT_N (QUANTA_LY8_PCA9698_2_GPIO_BASE + QUANTA_LY8_PCA953x_GPIO(0,4)) -#define QUANTA_LY8_PCA9698_2_GPIO_SFP_11_PRSNT_N (QUANTA_LY8_PCA9698_2_GPIO_BASE + QUANTA_LY8_PCA953x_GPIO(1,0)) -#define QUANTA_LY8_PCA9698_2_GPIO_SFP_12_PRSNT_N (QUANTA_LY8_PCA9698_2_GPIO_BASE + QUANTA_LY8_PCA953x_GPIO(1,4)) -#define QUANTA_LY8_PCA9698_2_GPIO_SFP_13_PRSNT_N (QUANTA_LY8_PCA9698_2_GPIO_BASE + QUANTA_LY8_PCA953x_GPIO(2,0)) -#define QUANTA_LY8_PCA9698_2_GPIO_SFP_14_PRSNT_N (QUANTA_LY8_PCA9698_2_GPIO_BASE + QUANTA_LY8_PCA953x_GPIO(2,4)) -#define QUANTA_LY8_PCA9698_2_GPIO_SFP_15_PRSNT_N (QUANTA_LY8_PCA9698_2_GPIO_BASE + QUANTA_LY8_PCA953x_GPIO(3,0)) -#define QUANTA_LY8_PCA9698_2_GPIO_SFP_16_PRSNT_N (QUANTA_LY8_PCA9698_2_GPIO_BASE + QUANTA_LY8_PCA953x_GPIO(3,4)) - -#define QUANTA_LY8_PCA9698_3_GPIO_BASE (QUANTA_LY8_PCA9698_2_GPIO_BASE + QUANTA_LY8_PCA9698_GPIO_SIZE) -#define QUANTA_LY8_PCA9698_3_GPIO_SFP_17_PRSNT_N (QUANTA_LY8_PCA9698_3_GPIO_BASE + QUANTA_LY8_PCA953x_GPIO(0,0)) -#define QUANTA_LY8_PCA9698_3_GPIO_SFP_18_PRSNT_N (QUANTA_LY8_PCA9698_3_GPIO_BASE + QUANTA_LY8_PCA953x_GPIO(0,4)) -#define QUANTA_LY8_PCA9698_3_GPIO_SFP_19_PRSNT_N (QUANTA_LY8_PCA9698_3_GPIO_BASE + QUANTA_LY8_PCA953x_GPIO(1,0)) -#define QUANTA_LY8_PCA9698_3_GPIO_SFP_20_PRSNT_N (QUANTA_LY8_PCA9698_3_GPIO_BASE + QUANTA_LY8_PCA953x_GPIO(1,4)) -#define QUANTA_LY8_PCA9698_3_GPIO_SFP_21_PRSNT_N (QUANTA_LY8_PCA9698_3_GPIO_BASE + QUANTA_LY8_PCA953x_GPIO(2,0)) -#define QUANTA_LY8_PCA9698_3_GPIO_SFP_22_PRSNT_N (QUANTA_LY8_PCA9698_3_GPIO_BASE + QUANTA_LY8_PCA953x_GPIO(2,4)) -#define QUANTA_LY8_PCA9698_3_GPIO_SFP_23_PRSNT_N (QUANTA_LY8_PCA9698_3_GPIO_BASE + QUANTA_LY8_PCA953x_GPIO(3,0)) -#define QUANTA_LY8_PCA9698_3_GPIO_SFP_24_PRSNT_N (QUANTA_LY8_PCA9698_3_GPIO_BASE + QUANTA_LY8_PCA953x_GPIO(3,4)) - -#define QUANTA_LY8_PCA9698_4_GPIO_BASE (QUANTA_LY8_PCA9698_3_GPIO_BASE + QUANTA_LY8_PCA9698_GPIO_SIZE) -#define QUANTA_LY8_PCA9698_4_GPIO_SFP_25_PRSNT_N (QUANTA_LY8_PCA9698_4_GPIO_BASE + QUANTA_LY8_PCA953x_GPIO(0,0)) -#define QUANTA_LY8_PCA9698_4_GPIO_SFP_26_PRSNT_N (QUANTA_LY8_PCA9698_4_GPIO_BASE + QUANTA_LY8_PCA953x_GPIO(0,4)) -#define QUANTA_LY8_PCA9698_4_GPIO_SFP_27_PRSNT_N (QUANTA_LY8_PCA9698_4_GPIO_BASE + QUANTA_LY8_PCA953x_GPIO(1,0)) -#define QUANTA_LY8_PCA9698_4_GPIO_SFP_28_PRSNT_N (QUANTA_LY8_PCA9698_4_GPIO_BASE + QUANTA_LY8_PCA953x_GPIO(1,4)) -#define QUANTA_LY8_PCA9698_4_GPIO_SFP_29_PRSNT_N (QUANTA_LY8_PCA9698_4_GPIO_BASE + QUANTA_LY8_PCA953x_GPIO(2,0)) -#define QUANTA_LY8_PCA9698_4_GPIO_SFP_30_PRSNT_N (QUANTA_LY8_PCA9698_4_GPIO_BASE + QUANTA_LY8_PCA953x_GPIO(2,4)) -#define QUANTA_LY8_PCA9698_4_GPIO_SFP_31_PRSNT_N (QUANTA_LY8_PCA9698_4_GPIO_BASE + QUANTA_LY8_PCA953x_GPIO(3,0)) -#define QUANTA_LY8_PCA9698_4_GPIO_SFP_32_PRSNT_N (QUANTA_LY8_PCA9698_4_GPIO_BASE + QUANTA_LY8_PCA953x_GPIO(3,4)) - -#define QUANTA_LY8_PCA9698_5_GPIO_BASE (QUANTA_LY8_PCA9698_4_GPIO_BASE + QUANTA_LY8_PCA9698_GPIO_SIZE) -#define QUANTA_LY8_PCA9698_5_GPIO_SFP_33_PRSNT_N (QUANTA_LY8_PCA9698_5_GPIO_BASE + QUANTA_LY8_PCA953x_GPIO(0,0)) -#define QUANTA_LY8_PCA9698_5_GPIO_SFP_34_PRSNT_N (QUANTA_LY8_PCA9698_5_GPIO_BASE + QUANTA_LY8_PCA953x_GPIO(0,4)) -#define QUANTA_LY8_PCA9698_5_GPIO_SFP_35_PRSNT_N (QUANTA_LY8_PCA9698_5_GPIO_BASE + QUANTA_LY8_PCA953x_GPIO(1,0)) -#define QUANTA_LY8_PCA9698_5_GPIO_SFP_36_PRSNT_N (QUANTA_LY8_PCA9698_5_GPIO_BASE + QUANTA_LY8_PCA953x_GPIO(1,4)) -#define QUANTA_LY8_PCA9698_5_GPIO_SFP_37_PRSNT_N (QUANTA_LY8_PCA9698_5_GPIO_BASE + QUANTA_LY8_PCA953x_GPIO(2,0)) -#define QUANTA_LY8_PCA9698_5_GPIO_SFP_38_PRSNT_N (QUANTA_LY8_PCA9698_5_GPIO_BASE + QUANTA_LY8_PCA953x_GPIO(2,4)) -#define QUANTA_LY8_PCA9698_5_GPIO_SFP_39_PRSNT_N (QUANTA_LY8_PCA9698_5_GPIO_BASE + QUANTA_LY8_PCA953x_GPIO(3,0)) -#define QUANTA_LY8_PCA9698_5_GPIO_SFP_40_PRSNT_N (QUANTA_LY8_PCA9698_5_GPIO_BASE + QUANTA_LY8_PCA953x_GPIO(3,4)) - -#define QUANTA_LY8_PCA9698_6_GPIO_BASE (QUANTA_LY8_PCA9698_5_GPIO_BASE + QUANTA_LY8_PCA9698_GPIO_SIZE) -#define QUANTA_LY8_PCA9698_6_GPIO_SFP_41_PRSNT_N (QUANTA_LY8_PCA9698_6_GPIO_BASE + QUANTA_LY8_PCA953x_GPIO(0,0)) -#define QUANTA_LY8_PCA9698_6_GPIO_SFP_42_PRSNT_N (QUANTA_LY8_PCA9698_6_GPIO_BASE + QUANTA_LY8_PCA953x_GPIO(0,4)) -#define QUANTA_LY8_PCA9698_6_GPIO_SFP_43_PRSNT_N (QUANTA_LY8_PCA9698_6_GPIO_BASE + QUANTA_LY8_PCA953x_GPIO(1,0)) -#define QUANTA_LY8_PCA9698_6_GPIO_SFP_44_PRSNT_N (QUANTA_LY8_PCA9698_6_GPIO_BASE + QUANTA_LY8_PCA953x_GPIO(1,4)) -#define QUANTA_LY8_PCA9698_6_GPIO_SFP_45_PRSNT_N (QUANTA_LY8_PCA9698_6_GPIO_BASE + QUANTA_LY8_PCA953x_GPIO(2,0)) -#define QUANTA_LY8_PCA9698_6_GPIO_SFP_46_PRSNT_N (QUANTA_LY8_PCA9698_6_GPIO_BASE + QUANTA_LY8_PCA953x_GPIO(2,4)) -#define QUANTA_LY8_PCA9698_6_GPIO_SFP_47_PRSNT_N (QUANTA_LY8_PCA9698_6_GPIO_BASE + QUANTA_LY8_PCA953x_GPIO(3,0)) -#define QUANTA_LY8_PCA9698_6_GPIO_SFP_48_PRSNT_N (QUANTA_LY8_PCA9698_6_GPIO_BASE + QUANTA_LY8_PCA953x_GPIO(3,4)) - -#define QUANTA_LY8_LED_GPIO_BASE (QUANTA_LY8_PCA9698_6_GPIO_BASE + QUANTA_LY8_PCA9698_GPIO_SIZE) -#define QUANTA_LY8_LED_GPIO_SIZE QUANTA_LY8_PCA9555_GPIO_SIZE - -#define QUANTA_LY8_QSFP_GPIO_BASE (QUANTA_LY8_LED_GPIO_BASE + QUANTA_LY8_LED_GPIO_SIZE) -#define QUANTA_LY8_QSFP_GPIO_SIZE QUANTA_LY8_PCA9555_GPIO_SIZE -#define QUANTA_LY8_QSFP_GPIO_PRSNT_49_N (QUANTA_LY8_QSFP_GPIO_BASE + QUANTA_LY8_PCA953x_GPIO(0,2)) -#define QUANTA_LY8_QSFP_GPIO_PRSNT_50_N (QUANTA_LY8_QSFP_GPIO_BASE + QUANTA_LY8_PCA953x_GPIO(0,6)) -#define QUANTA_LY8_QSFP_GPIO_PRSNT_51_N (QUANTA_LY8_QSFP_GPIO_BASE + QUANTA_LY8_PCA953x_GPIO(1,2)) -#define QUANTA_LY8_QSFP_GPIO_PRSNT_52_N (QUANTA_LY8_QSFP_GPIO_BASE + QUANTA_LY8_PCA953x_GPIO(1,6)) - -#define QUANTA_LY8_QSFP_QDB_GPIO_BASE (QUANTA_LY8_QSFP_GPIO_BASE + QUANTA_LY8_QSFP_GPIO_SIZE) -#define QUANTA_LY8_QSFP_QDB_GPIO_SIZE QUANTA_LY8_PCA9555_GPIO_SIZE -#define QUANTA_LY8_QSFP_QDB_GPIO_PRSNT_69_N (QUANTA_LY8_QSFP_QDB_GPIO_BASE + QUANTA_LY8_PCA953x_GPIO(0,2)) -#define QUANTA_LY8_QSFP_QDB_GPIO_PRSNT_70_N (QUANTA_LY8_QSFP_QDB_GPIO_BASE + QUANTA_LY8_PCA953x_GPIO(0,6)) -#define QUANTA_LY8_QSFP_QDB_GPIO_MOD_EN_N (QUANTA_LY8_QSFP_QDB_GPIO_BASE + QUANTA_LY8_PCA953x_GPIO(1,0)) - -#define QUANTA_LY8_PSU_GPIO_BASE (QUANTA_LY8_QSFP_QDB_GPIO_BASE + QUANTA_LY8_QSFP_QDB_GPIO_SIZE) -#define QUANTA_LY8_PSU_GPIO_SIZE QUANTA_LY8_PCA9555_GPIO_SIZE -#define QUANTA_LY8_PSU_GPIO_PSU1_PRSNT_N (QUANTA_LY8_PSU_GPIO_BASE + QUANTA_LY8_PCA953x_GPIO(0,0)) -#define QUANTA_LY8_PSU_GPIO_PSU1_PWRGD (QUANTA_LY8_PSU_GPIO_BASE + QUANTA_LY8_PCA953x_GPIO(0,1)) -#define QUANTA_LY8_PSU_GPIO_PSU2_PRSNT_N (QUANTA_LY8_PSU_GPIO_BASE + QUANTA_LY8_PCA953x_GPIO(0,3)) -#define QUANTA_LY8_PSU_GPIO_PSU2_PWRGD (QUANTA_LY8_PSU_GPIO_BASE + QUANTA_LY8_PCA953x_GPIO(0,4)) -#define QUANTA_LY8_PSU_GPIO_PSU1_GREEN_R (QUANTA_LY8_PSU_GPIO_BASE + QUANTA_LY8_PCA953x_GPIO(1,2)) -#define QUANTA_LY8_PSU_GPIO_PSU1_RED_R (QUANTA_LY8_PSU_GPIO_BASE + QUANTA_LY8_PCA953x_GPIO(1,3)) -#define QUANTA_LY8_PSU_GPIO_PSU2_GREEN_R (QUANTA_LY8_PSU_GPIO_BASE + QUANTA_LY8_PCA953x_GPIO(1,4)) -#define QUANTA_LY8_PSU_GPIO_PSU2_RED_R (QUANTA_LY8_PSU_GPIO_BASE + QUANTA_LY8_PCA953x_GPIO(1,5)) -#define QUANTA_LY8_PSU_GPIO_FAN_GREEN_R (QUANTA_LY8_PSU_GPIO_BASE + QUANTA_LY8_PCA953x_GPIO(1,6)) -#define QUANTA_LY8_PSU_GPIO_FAN_RED_R (QUANTA_LY8_PSU_GPIO_BASE + QUANTA_LY8_PCA953x_GPIO(1,7)) - -#endif /* __X86_64_QUANTA_LY8_RANGELEY_GPIO_TABLE_H__ */ diff --git a/packages/platforms/quanta/x86-64/ly8-rangeley/onlp/builds/x86_64_quanta_ly8_rangeley/module/inc/x86_64_quanta_ly8_rangeley/x86_64_quanta_ly8_rangeley_porting.h b/packages/platforms/quanta/x86-64/ly8-rangeley/onlp/builds/x86_64_quanta_ly8_rangeley/module/inc/x86_64_quanta_ly8_rangeley/x86_64_quanta_ly8_rangeley_porting.h deleted file mode 100644 index 38ce98f6a..000000000 --- a/packages/platforms/quanta/x86-64/ly8-rangeley/onlp/builds/x86_64_quanta_ly8_rangeley/module/inc/x86_64_quanta_ly8_rangeley/x86_64_quanta_ly8_rangeley_porting.h +++ /dev/null @@ -1,77 +0,0 @@ -/**************************************************************************//** - * - * @file - * @brief x86_64_quanta_ly8_rangeley Porting Macros. - * - * @addtogroup x86_64_quanta_ly8_rangeley-porting - * @{ - * - *****************************************************************************/ -#ifndef __X86_64_QUANTA_LY8_RANGELEY_PORTING_H__ -#define __X86_64_QUANTA_LY8_RANGELEY_PORTING_H__ - - -/* */ -#if X86_64_QUANTA_LY8_RANGELEY_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS == 1 -#include -#include -#include -#include -#include -#endif - -#ifndef X86_64_QUANTA_LY8_RANGELEY_MEMSET - #if defined(GLOBAL_MEMSET) - #define X86_64_QUANTA_LY8_RANGELEY_MEMSET GLOBAL_MEMSET - #elif X86_64_QUANTA_LY8_RANGELEY_CONFIG_PORTING_STDLIB == 1 - #define X86_64_QUANTA_LY8_RANGELEY_MEMSET memset - #else - #error The macro X86_64_QUANTA_LY8_RANGELEY_MEMSET is required but cannot be defined. - #endif -#endif - -#ifndef X86_64_QUANTA_LY8_RANGELEY_MEMCPY - #if defined(GLOBAL_MEMCPY) - #define X86_64_QUANTA_LY8_RANGELEY_MEMCPY GLOBAL_MEMCPY - #elif X86_64_QUANTA_LY8_RANGELEY_CONFIG_PORTING_STDLIB == 1 - #define X86_64_QUANTA_LY8_RANGELEY_MEMCPY memcpy - #else - #error The macro X86_64_QUANTA_LY8_RANGELEY_MEMCPY is required but cannot be defined. - #endif -#endif - -#ifndef X86_64_QUANTA_LY8_RANGELEY_VSNPRINTF - #if defined(GLOBAL_VSNPRINTF) - #define X86_64_QUANTA_LY8_RANGELEY_VSNPRINTF GLOBAL_VSNPRINTF - #elif X86_64_QUANTA_LY8_RANGELEY_CONFIG_PORTING_STDLIB == 1 - #define X86_64_QUANTA_LY8_RANGELEY_VSNPRINTF vsnprintf - #else - #error The macro X86_64_QUANTA_LY8_RANGELEY_VSNPRINTF is required but cannot be defined. - #endif -#endif - -#ifndef X86_64_QUANTA_LY8_RANGELEY_SNPRINTF - #if defined(GLOBAL_SNPRINTF) - #define X86_64_QUANTA_LY8_RANGELEY_SNPRINTF GLOBAL_SNPRINTF - #elif X86_64_QUANTA_LY8_RANGELEY_CONFIG_PORTING_STDLIB == 1 - #define X86_64_QUANTA_LY8_RANGELEY_SNPRINTF snprintf - #else - #error The macro X86_64_QUANTA_LY8_RANGELEY_SNPRINTF is required but cannot be defined. - #endif -#endif - -#ifndef X86_64_QUANTA_LY8_RANGELEY_STRLEN - #if defined(GLOBAL_STRLEN) - #define X86_64_QUANTA_LY8_RANGELEY_STRLEN GLOBAL_STRLEN - #elif X86_64_QUANTA_LY8_RANGELEY_CONFIG_PORTING_STDLIB == 1 - #define X86_64_QUANTA_LY8_RANGELEY_STRLEN strlen - #else - #error The macro X86_64_QUANTA_LY8_RANGELEY_STRLEN is required but cannot be defined. - #endif -#endif - -/* */ - - -#endif /* __X86_64_QUANTA_LY8_RANGELEY_PORTING_H__ */ -/* @} */ diff --git a/packages/platforms/quanta/x86-64/ly8-rangeley/onlp/builds/x86_64_quanta_ly8_rangeley/module/make.mk b/packages/platforms/quanta/x86-64/ly8-rangeley/onlp/builds/x86_64_quanta_ly8_rangeley/module/make.mk deleted file mode 100644 index 416bdc803..000000000 --- a/packages/platforms/quanta/x86-64/ly8-rangeley/onlp/builds/x86_64_quanta_ly8_rangeley/module/make.mk +++ /dev/null @@ -1,10 +0,0 @@ -############################################################################### -# -# -# -############################################################################### -THIS_DIR := $(dir $(lastword $(MAKEFILE_LIST))) -x86_64_quanta_ly8_rangeley_INCLUDES := -I $(THIS_DIR)inc -x86_64_quanta_ly8_rangeley_INTERNAL_INCLUDES := -I $(THIS_DIR)src -x86_64_quanta_ly8_rangeley_DEPENDMODULE_ENTRIES := init:x86_64_quanta_ly8_rangeley ucli:x86_64_quanta_ly8_rangeley - diff --git a/packages/platforms/quanta/x86-64/ly8-rangeley/onlp/builds/x86_64_quanta_ly8_rangeley/module/src/Makefile b/packages/platforms/quanta/x86-64/ly8-rangeley/onlp/builds/x86_64_quanta_ly8_rangeley/module/src/Makefile deleted file mode 100644 index 7b89bfcec..000000000 --- a/packages/platforms/quanta/x86-64/ly8-rangeley/onlp/builds/x86_64_quanta_ly8_rangeley/module/src/Makefile +++ /dev/null @@ -1,9 +0,0 @@ -############################################################################### -# -# Local source generation targets. -# -############################################################################### - -ucli: - @../../../../tools/uclihandlers.py x86_64_quanta_ly8_rangeley_ucli.c - diff --git a/packages/platforms/quanta/x86-64/ly8-rangeley/onlp/builds/x86_64_quanta_ly8_rangeley/module/src/fani.c b/packages/platforms/quanta/x86-64/ly8-rangeley/onlp/builds/x86_64_quanta_ly8_rangeley/module/src/fani.c deleted file mode 100755 index a5295ac07..000000000 --- a/packages/platforms/quanta/x86-64/ly8-rangeley/onlp/builds/x86_64_quanta_ly8_rangeley/module/src/fani.c +++ /dev/null @@ -1,168 +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 "x86_64_quanta_ly8_rangeley_int.h" -#include "x86_64_quanta_ly8_rangeley_log.h" - -#include -#include - -int -onlp_fani_init(void) -{ - return ONLP_STATUS_OK; -} - -struct fan_gpio_s { - int present; - int fan_dir_detect; -}; - -static struct fan_gpio_s fan_gpio[] = { - {}, /* Not used */ - { .present = QUANTA_LY8_FAN_PRSNT_N_1, .fan_dir_detect = QUANTA_LY8_FAN_BF_DET1 }, - { .present = QUANTA_LY8_FAN_PRSNT_N_2, .fan_dir_detect = QUANTA_LY8_FAN_BF_DET2 }, - { .present = QUANTA_LY8_FAN_PRSNT_N_3, .fan_dir_detect = QUANTA_LY8_FAN_BF_DET3 }, - {}, /* Not used */ - { .present = QUANTA_LY8_FAN_PRSNT_N_1, .fan_dir_detect = QUANTA_LY8_FAN_BF_DET1 }, - { .present = QUANTA_LY8_FAN_PRSNT_N_2, .fan_dir_detect = QUANTA_LY8_FAN_BF_DET2 }, - { .present = QUANTA_LY8_FAN_PRSNT_N_3, .fan_dir_detect = QUANTA_LY8_FAN_BF_DET3 }, - {}, /* Not used */ -}; - -static int -sys_fan_info_get__(onlp_fan_info_t* info, int id) -{ - int value = 0; - int rv; - - if(onlp_gpio_get(fan_gpio[id].present, &value) == ONLP_STATUS_OK - && value == 0) { - info->status = ONLP_FAN_STATUS_PRESENT; - if(onlp_gpio_get(fan_gpio[id].fan_dir_detect, &value) == ONLP_STATUS_OK - && value == 0) { - info->status |= ONLP_FAN_STATUS_F2B; - info->caps |= ONLP_FAN_CAPS_F2B; - } - else { - info->status |= ONLP_FAN_STATUS_B2F; - info->caps |= ONLP_FAN_CAPS_B2F; - } - } - else { - info->status = ONLP_FAN_STATUS_FAILED; - } - - rv = onlp_file_read_int(&info->rpm, - SYS_HWMON_PREFIX "/fan%d_input", id); - - if(rv == ONLP_STATUS_E_INTERNAL) { - return rv; - } - - if(rv == ONLP_STATUS_E_MISSING) { - info->status &= ~1; - return 0; - } - - if(info->rpm <= X86_64_QUANTA_LY8_RANGELEY_CONFIG_SYSFAN_RPM_FAILURE_THRESHOLD) { - info->status |= ONLP_FAN_STATUS_FAILED; - } - - /* - * Calculate percentage based on current speed and the maximum. - */ - info->caps |= ONLP_FAN_CAPS_GET_PERCENTAGE; - if(info->status & ONLP_FAN_STATUS_F2B) { - info->percentage = (int) ((double) info->rpm * (double)100 / (double)X86_64_QUANTA_LY8_RANGELEY_CONFIG_SYSFAN_F2B_RPM_MAX); - } - if(info->status & ONLP_FAN_STATUS_B2F) { - info->percentage = (int) ((double) info->rpm * (double)100 / (double)X86_64_QUANTA_LY8_RANGELEY_CONFIG_SYSFAN_B2F_RPM_MAX); - } - - return 0; -} - -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, "Left (Module/Fan 1/1)", 0}, ONLP_FAN_STATUS_PRESENT }, - { { FAN_OID_FAN2, "Center(Module/Fan 2/1)", 0}, ONLP_FAN_STATUS_PRESENT }, - { { FAN_OID_FAN3, "Right (Module/Fan 3/1)", 0}, ONLP_FAN_STATUS_PRESENT }, - { { FAN_OID_FAN4, "Reserved (Module/Fan 4/1)", 0}, ONLP_FAN_STATUS_PRESENT }, - { { FAN_OID_FAN5, "Left (Module/Fan 1/2)", 0}, ONLP_FAN_STATUS_PRESENT }, - { { FAN_OID_FAN6, "Center(Module/Fan 2/2)", 0}, ONLP_FAN_STATUS_PRESENT }, - { { FAN_OID_FAN7, "Right (Module/Fan 3/2)", 0}, ONLP_FAN_STATUS_PRESENT }, - { { FAN_OID_FAN8, "Reserved (Module/Fan 4/2)", 0}, ONLP_FAN_STATUS_PRESENT }, - { { FAN_OID_FAN9, "PSU-1 Fan", 0 }, ONLP_FAN_STATUS_PRESENT }, - { { FAN_OID_FAN10, "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: - case FAN_ID_FAN3: - case FAN_ID_FAN4: - case FAN_ID_FAN5: - case FAN_ID_FAN6: - case FAN_ID_FAN7: - case FAN_ID_FAN8: - return sys_fan_info_get__(rv, fid); - break; - - case FAN_ID_FAN9: - case FAN_ID_FAN10: - return psu_fan_info_get__(rv, fid - FAN_ID_FAN9 + 1); - break; - - default: - return ONLP_STATUS_E_INVALID; - break; - } - - return ONLP_STATUS_E_INVALID; -} diff --git a/packages/platforms/quanta/x86-64/ly8-rangeley/onlp/builds/x86_64_quanta_ly8_rangeley/module/src/ledi.c b/packages/platforms/quanta/x86-64/ly8-rangeley/onlp/builds/x86_64_quanta_ly8_rangeley/module/src/ledi.c deleted file mode 100755 index 10c77c7f3..000000000 --- a/packages/platforms/quanta/x86-64/ly8-rangeley/onlp/builds/x86_64_quanta_ly8_rangeley/module/src/ledi.c +++ /dev/null @@ -1,210 +0,0 @@ -#include -#include -#include -#include -#include - -#include "x86_64_quanta_ly8_rangeley_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, - } -}; - -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_LY8_CPU_BOARD_SYS_P1, 0); - onlp_gpio_set(QUANTA_LY8_CPU_BOARD_SYS_P2, 1); - } - else if(mode == ONLP_LED_MODE_ORANGE){ - onlp_gpio_set(QUANTA_LY8_CPU_BOARD_SYS_P1, 1); - onlp_gpio_set(QUANTA_LY8_CPU_BOARD_SYS_P2, 0); - } - else{ - onlp_gpio_set(QUANTA_LY8_CPU_BOARD_SYS_P1, 1); - onlp_gpio_set(QUANTA_LY8_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_LY8_PSU_GPIO_FAN_GREEN_R, 1); - onlp_gpio_set(QUANTA_LY8_PSU_GPIO_FAN_RED_R, 0); - } - else if(mode == ONLP_LED_MODE_RED){ - onlp_gpio_set(QUANTA_LY8_PSU_GPIO_FAN_GREEN_R, 0); - onlp_gpio_set(QUANTA_LY8_PSU_GPIO_FAN_RED_R, 1); - } - else{ - onlp_gpio_set(QUANTA_LY8_PSU_GPIO_FAN_GREEN_R, 0); - onlp_gpio_set(QUANTA_LY8_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_LY8_PSU_GPIO_PSU1_GREEN_R, 1); - onlp_gpio_set(QUANTA_LY8_PSU_GPIO_PSU1_RED_R, 0); - } - else if(mode == ONLP_LED_MODE_RED){ - onlp_gpio_set(QUANTA_LY8_PSU_GPIO_PSU1_GREEN_R, 0); - onlp_gpio_set(QUANTA_LY8_PSU_GPIO_PSU1_RED_R, 1); - } - else{ - onlp_gpio_set(QUANTA_LY8_PSU_GPIO_PSU1_GREEN_R, 0); - onlp_gpio_set(QUANTA_LY8_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_LY8_PSU_GPIO_PSU2_GREEN_R, 1); - onlp_gpio_set(QUANTA_LY8_PSU_GPIO_PSU2_RED_R, 0); - } - else if(mode == ONLP_LED_MODE_RED){ - onlp_gpio_set(QUANTA_LY8_PSU_GPIO_PSU2_GREEN_R, 0); - onlp_gpio_set(QUANTA_LY8_PSU_GPIO_PSU2_RED_R, 1); - } - else{ - onlp_gpio_set(QUANTA_LY8_PSU_GPIO_PSU2_GREEN_R, 0); - onlp_gpio_set(QUANTA_LY8_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_LY8_FAN_FAIL_LED_1, 1); - } - else{ - onlp_gpio_set(QUANTA_LY8_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_LY8_FAN_FAIL_LED_2, 1); - } - else{ - onlp_gpio_set(QUANTA_LY8_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_LY8_FAN_FAIL_LED_3, 1); - } - else{ - onlp_gpio_set(QUANTA_LY8_FAN_FAIL_LED_3, 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; - default: - return ONLP_STATUS_E_INTERNAL; - break; - } - - return ONLP_STATUS_OK; -} diff --git a/packages/platforms/quanta/x86-64/ly8-rangeley/onlp/builds/x86_64_quanta_ly8_rangeley/module/src/make.mk b/packages/platforms/quanta/x86-64/ly8-rangeley/onlp/builds/x86_64_quanta_ly8_rangeley/module/src/make.mk deleted file mode 100644 index b0cb15cd4..000000000 --- a/packages/platforms/quanta/x86-64/ly8-rangeley/onlp/builds/x86_64_quanta_ly8_rangeley/module/src/make.mk +++ /dev/null @@ -1,9 +0,0 @@ -############################################################################### -# -# -# -############################################################################### - -LIBRARY := x86_64_quanta_ly8_rangeley -$(LIBRARY)_SUBDIR := $(dir $(lastword $(MAKEFILE_LIST))) -include $(BUILDER)/lib.mk diff --git a/packages/platforms/quanta/x86-64/ly8-rangeley/onlp/builds/x86_64_quanta_ly8_rangeley/module/src/psui.c b/packages/platforms/quanta/x86-64/ly8-rangeley/onlp/builds/x86_64_quanta_ly8_rangeley/module/src/psui.c deleted file mode 100755 index aebdade51..000000000 --- a/packages/platforms/quanta/x86-64/ly8-rangeley/onlp/builds/x86_64_quanta_ly8_rangeley/module/src/psui.c +++ /dev/null @@ -1,126 +0,0 @@ -/************************************************************ - * - * - ************************************************************ - * - * - * - ***********************************************************/ -#include -#include -#include -#include -#include -#include -#include "x86_64_quanta_ly8_rangeley_int.h" -#include "x86_64_quanta_ly8_rangeley_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-006f", .present = QUANTA_LY8_PSU_GPIO_PSU1_PRSNT_N, .busno = 24, .addr = 0x6f}, - { .path = "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-25/25-0069", .present = QUANTA_LY8_PSU_GPIO_PSU2_PRSNT_N, .busno = 25, .addr = 0x69}, -}; - -int -onlp_psui_init(void) -{ - return 0; -} - -static onlp_psu_info_t psus__[] = { - { }, /* Not used */ - { - { - PSU_OID_PSU1, - "Quanta LY8 RPSU-1", - 0, - { - FAN_OID_FAN9, - }, - } - }, - { - { - PSU_OID_PSU2, - "Quanta LY8 RPSU-2", - 0, - { - FAN_OID_FAN10, - }, - } - }, -}; - -#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; - uint8_t buffer[ONLP_CONFIG_INFO_STR_MAX]; - int value = -1; - - 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; - - memset(buffer, 0, sizeof(buffer)); - rv = onlp_i2c_block_read(psu_info[pid].busno, psu_info[pid].addr, PMBUS_MFR_MODEL, PMBUS_MFR_MODEL_LEN, buffer, ONLP_I2C_F_FORCE); - if(rv >= 0) { - aim_strlcpy(info->model, (char *) (buffer+1), (buffer[0]+1)); - } - else { - strcpy(info->model, "Missing"); - } - - memset(buffer, 0, sizeof(buffer)); - rv = onlp_i2c_block_read(psu_info[pid].busno, psu_info[pid].addr, PMBUS_MFR_SERIAL, PMBUS_MFR_SERIAL_LEN, buffer, ONLP_I2C_F_FORCE); - if(rv >= 0) { - aim_strlcpy(info->serial, (char *) (buffer+1), (buffer[0] + 1)); - } else { - strcpy(info->serial, "Missing"); - } - - - 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/ly8-rangeley/onlp/builds/x86_64_quanta_ly8_rangeley/module/src/sfpi.c b/packages/platforms/quanta/x86-64/ly8-rangeley/onlp/builds/x86_64_quanta_ly8_rangeley/module/src/sfpi.c deleted file mode 100644 index 9ee5fb0cd..000000000 --- a/packages/platforms/quanta/x86-64/ly8-rangeley/onlp/builds/x86_64_quanta_ly8_rangeley/module/src/sfpi.c +++ /dev/null @@ -1,216 +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. - * - * - ************************************************************ - * - * SFPI Interface for the Quanta LY8 - * - ***********************************************************/ -#include -#include -#include -#include -#include -#include -#include "x86_64_quanta_ly8_rangeley_log.h" - -#include -#include - -/** - * This table maps the presence gpio, reset gpio, and eeprom file - * for each SFP port. - */ -typedef struct sfpmap_s { - int port; - int present_gpio; - const char* reset_gpio; - const char* port_path; - const char* dom; -} sfpmap_t; - -static sfpmap_t sfpmap__[] = - { - { }, /* 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) -{ - int value = -1, ret, i; - sfpmap_t* sfp; - - onlp_gpio_export(QUANTA_LY8_QSFP_EN_GPIO_P3V3_PW_EN, ONLP_GPIO_DIRECTION_IN); - ret = onlp_gpio_get(QUANTA_LY8_QSFP_EN_GPIO_P3V3_PW_EN, &value); - if(ret == ONLP_STATUS_OK && value != 1) { - onlp_gpio_export(QUANTA_LY8_QSFP_EN_GPIO_P3V3_PW_EN, ONLP_GPIO_DIRECTION_OUT); - ret = onlp_gpio_set(QUANTA_LY8_QSFP_EN_GPIO_P3V3_PW_EN, 1); - } - - if(ret == ONLP_STATUS_OK) { - onlp_gpio_export(QUANTA_LY8_QSFP_QDB_GPIO_MOD_EN_N, ONLP_GPIO_DIRECTION_IN); - ret = onlp_gpio_get(QUANTA_LY8_QSFP_QDB_GPIO_MOD_EN_N, &value); - if(ret == ONLP_STATUS_OK && value != 0) { - onlp_gpio_export(QUANTA_LY8_QSFP_QDB_GPIO_MOD_EN_N, ONLP_GPIO_DIRECTION_OUT); - ret = onlp_gpio_set(QUANTA_LY8_QSFP_QDB_GPIO_MOD_EN_N, 0); - } - } - - for(i = 0; i < MAX_PORT_NUM; i++) { - sfp = SFP_GET(i + 1); - onlp_gpio_export(sfp->present_gpio, ONLP_GPIO_DIRECTION_IN); - } - - return ret; -} - -int -onlp_sfpi_bitmap_get(onlp_sfp_bitmap_t* bmap) -{ - int i, port_name; - - 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; -} - -int -onlp_sfpi_is_present(int port) -{ - int value = 0; - sfpmap_t* sfp = SFP_GET(port); - if(sfp->present_gpio > 0) { - if(onlp_gpio_get(sfp->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(sfp_get_port_path(port, "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; - } -} - -int -onlp_sfpi_eeprom_read(int port, uint8_t data[256]) -{ - return onlplib_sfp_eeprom_read_file(sfp_get_port_path(port, "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); -} - diff --git a/packages/platforms/quanta/x86-64/ly8-rangeley/onlp/builds/x86_64_quanta_ly8_rangeley/module/src/sysi.c b/packages/platforms/quanta/x86-64/ly8-rangeley/onlp/builds/x86_64_quanta_ly8_rangeley/module/src/sysi.c deleted file mode 100755 index 5a57b17a1..000000000 --- a/packages/platforms/quanta/x86-64/ly8-rangeley/onlp/builds/x86_64_quanta_ly8_rangeley/module/src/sysi.c +++ /dev/null @@ -1,277 +0,0 @@ -/************************************************************ - * - * - ************************************************************ - * - * - * - ***********************************************************/ -#include -#include "x86_64_quanta_ly8_rangeley_int.h" -#include "x86_64_quanta_ly8_rangeley_log.h" -#include -#include -#include -#include -#include - -struct led_control_s led_control; - -#define QUANTA_HWMON_REG_TEMP_ALERT_MASK 0x1E -#define QUANTA_HWMON_REG_TEMP_ALERT_CTRL 0x1D -#define QUANTA_HWMON_REG_FAN_ALERT_MASK 0x31 -#define QUANTA_HWMON_REG_FAN_ALERT_CTRL 0x30 - -#define QUANTA_FAN_1_1 0x01 -#define QUANTA_FAN_1_2 0x10 -#define QUANTA_FAN_2_1 0x02 -#define QUANTA_FAN_2_2 0x20 -#define QUANTA_FAN_3_1 0x04 -#define QUANTA_FAN_3_2 0x40 - -const char* -onlp_sysi_platform_get(void) -{ - return "x86-64-quanta-ly8-rangeley-r0"; -} - -int -onlp_sysi_init(void) -{ - /* Initial value */ - led_control.PMCnt = 0; - led_control.fan_alert = 0xff; - led_control.psu1_present = 0; - led_control.psu2_present = 0; - led_control.psu1_power_good = 0; - led_control.psu2_power_good = 0; - - /* Set PSoc Fan-Alert Enable */ - onlp_i2c_writeb(0, 0x4e, QUANTA_HWMON_REG_TEMP_ALERT_MASK, 0x37, ONLP_I2C_F_FORCE); - onlp_i2c_writeb(0, 0x4e, QUANTA_HWMON_REG_TEMP_ALERT_CTRL, 0x3, ONLP_I2C_F_FORCE); - onlp_i2c_writeb(0, 0x4e, QUANTA_HWMON_REG_FAN_ALERT_MASK, 0x77, ONLP_I2C_F_FORCE); - onlp_i2c_writeb(0, 0x4e, QUANTA_HWMON_REG_FAN_ALERT_CTRL, 0x1, ONLP_I2C_F_FORCE); - - /* Config GPIO */ - /* LED Output */ - onlp_gpio_export(QUANTA_LY8_CPU_BOARD_SYS_P1, ONLP_GPIO_DIRECTION_OUT); - onlp_gpio_export(QUANTA_LY8_CPU_BOARD_SYS_P2, ONLP_GPIO_DIRECTION_OUT); - onlp_gpio_export(QUANTA_LY8_PSU_GPIO_PSU1_GREEN_R, ONLP_GPIO_DIRECTION_OUT); - onlp_gpio_export(QUANTA_LY8_PSU_GPIO_PSU1_RED_R, ONLP_GPIO_DIRECTION_OUT); - onlp_gpio_export(QUANTA_LY8_PSU_GPIO_PSU2_GREEN_R, ONLP_GPIO_DIRECTION_OUT); - onlp_gpio_export(QUANTA_LY8_PSU_GPIO_PSU2_RED_R, ONLP_GPIO_DIRECTION_OUT); - onlp_gpio_export(QUANTA_LY8_FAN_FAIL_LED_1, ONLP_GPIO_DIRECTION_OUT); - onlp_gpio_export(QUANTA_LY8_FAN_FAIL_LED_2, ONLP_GPIO_DIRECTION_OUT); - onlp_gpio_export(QUANTA_LY8_FAN_FAIL_LED_3, ONLP_GPIO_DIRECTION_OUT); - onlp_gpio_export(QUANTA_LY8_PSU_GPIO_FAN_GREEN_R, ONLP_GPIO_DIRECTION_OUT); - onlp_gpio_export(QUANTA_LY8_PSU_GPIO_FAN_RED_R, ONLP_GPIO_DIRECTION_OUT); - /* PSU Input */ - onlp_gpio_export(QUANTA_LY8_PSU_GPIO_PSU1_PRSNT_N, ONLP_GPIO_DIRECTION_IN); - onlp_gpio_export(QUANTA_LY8_PSU_GPIO_PSU1_PWRGD, ONLP_GPIO_DIRECTION_IN); - onlp_gpio_export(QUANTA_LY8_PSU_GPIO_PSU2_PRSNT_N, ONLP_GPIO_DIRECTION_IN); - onlp_gpio_export(QUANTA_LY8_PSU_GPIO_PSU2_PWRGD, ONLP_GPIO_DIRECTION_IN); - /* FAN Input */ - 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); - 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-27/27-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-ly8-rangeley-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)); - - - /* - * 5 Chassis Thermal Sensors - */ - *e++ = THERMAL_OID_THERMAL1; - *e++ = THERMAL_OID_THERMAL2; - *e++ = THERMAL_OID_THERMAL3; - *e++ = THERMAL_OID_THERMAL5; - *e++ = THERMAL_OID_THERMAL6; - - /* - * 6 Fans - */ - *e++ = FAN_OID_FAN1; - *e++ = FAN_OID_FAN2; - *e++ = FAN_OID_FAN3; - *e++ = FAN_OID_FAN5; - *e++ = FAN_OID_FAN6; - *e++ = FAN_OID_FAN7; - - /* - * 2 PSUs - */ - *e++ = PSU_OID_PSU1; - *e++ = PSU_OID_PSU2; - - /* - * 7 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; - - 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_LY8_PSU_GPIO_PSU1_PRSNT_N, &value); - if(rv < 0) { - AIM_LOG_ERROR("GPIO %d read Error!", QUANTA_LY8_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_LY8_PSU_GPIO_PSU1_PWRGD, &value); - if(rv < 0) { - AIM_LOG_ERROR("GPIO %d read Error!", QUANTA_LY8_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_LY8_PSU_GPIO_PSU2_PRSNT_N, &value); - if(rv < 0) { - AIM_LOG_ERROR("GPIO %d read Error!", QUANTA_LY8_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_LY8_PSU_GPIO_PSU2_PWRGD, &value); - if(rv < 0) { - AIM_LOG_ERROR("GPIO %d read Error!", QUANTA_LY8_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; - - tmp = led_control.fan_alert; - led_control.fan_alert = onlp_i2c_readb(0, 0x4e, 0x32, ONLP_I2C_F_FORCE); - if(tmp != led_control.fan_alert) - 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.fan_alert & QUANTA_FAN_1_1) && !(led_control.fan_alert & QUANTA_FAN_1_2)) { - onlp_ledi_mode_set(LED_ID_FAN_FAIL_1, ONLP_LED_MODE_OFF); - } - else{ - onlp_ledi_mode_set(LED_ID_FAN_FAIL_1, ONLP_LED_MODE_RED); - } - - if(!(led_control.fan_alert & QUANTA_FAN_2_1) && !(led_control.fan_alert & QUANTA_FAN_2_2)) { - onlp_ledi_mode_set(LED_ID_FAN_FAIL_2, ONLP_LED_MODE_OFF); - } - else{ - onlp_ledi_mode_set(LED_ID_FAN_FAIL_2, ONLP_LED_MODE_RED); - } - - if(!(led_control.fan_alert & QUANTA_FAN_3_1) && !(led_control.fan_alert & QUANTA_FAN_3_2)) { - onlp_ledi_mode_set(LED_ID_FAN_FAIL_3, ONLP_LED_MODE_OFF); - } - else{ - onlp_ledi_mode_set(LED_ID_FAN_FAIL_3, ONLP_LED_MODE_RED); - } - - if(!led_control.fan_alert){ - 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/ly8-rangeley/onlp/builds/x86_64_quanta_ly8_rangeley/module/src/thermali.c b/packages/platforms/quanta/x86-64/ly8-rangeley/onlp/builds/x86_64_quanta_ly8_rangeley/module/src/thermali.c deleted file mode 100644 index fe3f8776a..000000000 --- a/packages/platforms/quanta/x86-64/ly8-rangeley/onlp/builds/x86_64_quanta_ly8_rangeley/module/src/thermali.c +++ /dev/null @@ -1,145 +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 "x86_64_quanta_ly8_rangeley_int.h" -#include "x86_64_quanta_ly8_rangeley_log.h" - -int -onlp_thermali_init(void) -{ - return ONLP_STATUS_OK; -} - -static int -sys_thermal_info_get__(onlp_thermal_info_t* info, int id) -{ - int rv; - - rv = onlp_file_read_int(&info->mcelsius, - SYS_HWMON_PREFIX "/temp%d_input", id); - - if(rv == ONLP_STATUS_E_INTERNAL) { - return rv; - } - - if(rv == ONLP_STATUS_E_MISSING) { - info->status &= ~1; - return 0; - } - - return ONLP_STATUS_OK; -} - -static int -psu_thermal_info_get__(onlp_thermal_info_t* info, int pid, int id) -{ - /* THERMAL6 -> PSU1 */ - /* THERMAL7 -> PSU2 */ - extern struct psu_info_s psu_info[]; - char* dir = psu_info[pid].path; - info->status |= 1; - return onlp_file_read_int(&info->mcelsius, "%s/temp%d_input", dir, id); -} - -int -onlp_thermali_info_get(onlp_oid_t id, onlp_thermal_info_t* rv) -{ - int tid = ONLP_OID_ID_GET(id); - - static onlp_thermal_info_t info[] = { - { }, /* Not used */ - { { ONLP_THERMAL_ID_CREATE(1), "Chassis Thermal 1", 0}, ONLP_THERMAL_STATUS_PRESENT, - ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS - }, - { { ONLP_THERMAL_ID_CREATE(2), "Chassis Thermal 2", 0}, ONLP_THERMAL_STATUS_PRESENT, - ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS - }, - { { ONLP_THERMAL_ID_CREATE(3), "Chassis Thermal 3", 0}, ONLP_THERMAL_STATUS_PRESENT, - ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS - }, - { { ONLP_THERMAL_ID_CREATE(4), "Chassis Thermal 4", 0}, ONLP_THERMAL_STATUS_PRESENT, - ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS - }, - { { ONLP_THERMAL_ID_CREATE(5), "Chassis Thermal 5", 0}, ONLP_THERMAL_STATUS_PRESENT, - ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS - }, - { { ONLP_THERMAL_ID_CREATE(6), "Chassis Thermal 6", 0}, ONLP_THERMAL_STATUS_PRESENT, - ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS - }, - { { ONLP_THERMAL_ID_CREATE(7), "Chassis Thermal 7", 0}, ONLP_THERMAL_STATUS_PRESENT, - ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS - }, - { { ONLP_THERMAL_ID_CREATE(8), "Chassis Thermal 8", 0}, ONLP_THERMAL_STATUS_PRESENT, - ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS - }, - { { ONLP_THERMAL_ID_CREATE(9), "Chassis Thermal 9", 0}, ONLP_THERMAL_STATUS_PRESENT, - ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS - }, - { { ONLP_THERMAL_ID_CREATE(10), "Chassis Thermal 10", 0}, ONLP_THERMAL_STATUS_PRESENT, - ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS - }, - - { { ONLP_THERMAL_ID_CREATE(11), "PSU-1 Thermal 1", 0 } }, - { { ONLP_THERMAL_ID_CREATE(12), "PSU-1 Thermal 2", 0 } }, - { { ONLP_THERMAL_ID_CREATE(13), "PSU-1 Thermal 3", 0 } }, - - { { ONLP_THERMAL_ID_CREATE(14), "PSU-2 Thermal 1", 0 } }, - { { ONLP_THERMAL_ID_CREATE(15), "PSU-2 Thermal 2", 0 } }, - { { ONLP_THERMAL_ID_CREATE(16), "PSU-2 Thermal 3", 0 } }, - }; - - *rv = info[tid]; - rv->caps |= ONLP_THERMAL_CAPS_GET_TEMPERATURE; - - switch(tid) - { - case THERMAL_ID_THERMAL1: - case THERMAL_ID_THERMAL2: - case THERMAL_ID_THERMAL3: - case THERMAL_ID_THERMAL4: - case THERMAL_ID_THERMAL5: - case THERMAL_ID_THERMAL6: - case THERMAL_ID_THERMAL7: - case THERMAL_ID_THERMAL8: - case THERMAL_ID_THERMAL9: - case THERMAL_ID_THERMAL10: - return sys_thermal_info_get__(rv, tid); - - case THERMAL_ID_THERMAL11: - case THERMAL_ID_THERMAL12: - case THERMAL_ID_THERMAL13: - return psu_thermal_info_get__(rv, 1, tid - THERMAL_ID_THERMAL11 + 1); - - - case THERMAL_ID_THERMAL14: - case THERMAL_ID_THERMAL15: - case THERMAL_ID_THERMAL16: - return psu_thermal_info_get__(rv, 2, tid - THERMAL_ID_THERMAL14 + 1); - - } - - return ONLP_STATUS_E_INVALID; -} diff --git a/packages/platforms/quanta/x86-64/ly8-rangeley/onlp/builds/x86_64_quanta_ly8_rangeley/module/src/x86_64_quanta_ly8_rangeley_config.c b/packages/platforms/quanta/x86-64/ly8-rangeley/onlp/builds/x86_64_quanta_ly8_rangeley/module/src/x86_64_quanta_ly8_rangeley_config.c deleted file mode 100644 index 342ebb3ba..000000000 --- a/packages/platforms/quanta/x86-64/ly8-rangeley/onlp/builds/x86_64_quanta_ly8_rangeley/module/src/x86_64_quanta_ly8_rangeley_config.c +++ /dev/null @@ -1,95 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#include - -/* */ -#define __x86_64_quanta_ly8_rangeley_config_STRINGIFY_NAME(_x) #_x -#define __x86_64_quanta_ly8_rangeley_config_STRINGIFY_VALUE(_x) __x86_64_quanta_ly8_rangeley_config_STRINGIFY_NAME(_x) -x86_64_quanta_ly8_rangeley_config_settings_t x86_64_quanta_ly8_rangeley_config_settings[] = -{ -#ifdef X86_64_QUANTA_LY8_RANGELEY_CONFIG_INCLUDE_LOGGING - { __x86_64_quanta_ly8_rangeley_config_STRINGIFY_NAME(X86_64_QUANTA_LY8_RANGELEY_CONFIG_INCLUDE_LOGGING), __x86_64_quanta_ly8_rangeley_config_STRINGIFY_VALUE(X86_64_QUANTA_LY8_RANGELEY_CONFIG_INCLUDE_LOGGING) }, -#else -{ X86_64_QUANTA_LY8_RANGELEY_CONFIG_INCLUDE_LOGGING(__x86_64_quanta_ly8_rangeley_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_QUANTA_LY8_RANGELEY_CONFIG_LOG_OPTIONS_DEFAULT - { __x86_64_quanta_ly8_rangeley_config_STRINGIFY_NAME(X86_64_QUANTA_LY8_RANGELEY_CONFIG_LOG_OPTIONS_DEFAULT), __x86_64_quanta_ly8_rangeley_config_STRINGIFY_VALUE(X86_64_QUANTA_LY8_RANGELEY_CONFIG_LOG_OPTIONS_DEFAULT) }, -#else -{ X86_64_QUANTA_LY8_RANGELEY_CONFIG_LOG_OPTIONS_DEFAULT(__x86_64_quanta_ly8_rangeley_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_QUANTA_LY8_RANGELEY_CONFIG_LOG_BITS_DEFAULT - { __x86_64_quanta_ly8_rangeley_config_STRINGIFY_NAME(X86_64_QUANTA_LY8_RANGELEY_CONFIG_LOG_BITS_DEFAULT), __x86_64_quanta_ly8_rangeley_config_STRINGIFY_VALUE(X86_64_QUANTA_LY8_RANGELEY_CONFIG_LOG_BITS_DEFAULT) }, -#else -{ X86_64_QUANTA_LY8_RANGELEY_CONFIG_LOG_BITS_DEFAULT(__x86_64_quanta_ly8_rangeley_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_QUANTA_LY8_RANGELEY_CONFIG_LOG_CUSTOM_BITS_DEFAULT - { __x86_64_quanta_ly8_rangeley_config_STRINGIFY_NAME(X86_64_QUANTA_LY8_RANGELEY_CONFIG_LOG_CUSTOM_BITS_DEFAULT), __x86_64_quanta_ly8_rangeley_config_STRINGIFY_VALUE(X86_64_QUANTA_LY8_RANGELEY_CONFIG_LOG_CUSTOM_BITS_DEFAULT) }, -#else -{ X86_64_QUANTA_LY8_RANGELEY_CONFIG_LOG_CUSTOM_BITS_DEFAULT(__x86_64_quanta_ly8_rangeley_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_QUANTA_LY8_RANGELEY_CONFIG_PORTING_STDLIB - { __x86_64_quanta_ly8_rangeley_config_STRINGIFY_NAME(X86_64_QUANTA_LY8_RANGELEY_CONFIG_PORTING_STDLIB), __x86_64_quanta_ly8_rangeley_config_STRINGIFY_VALUE(X86_64_QUANTA_LY8_RANGELEY_CONFIG_PORTING_STDLIB) }, -#else -{ X86_64_QUANTA_LY8_RANGELEY_CONFIG_PORTING_STDLIB(__x86_64_quanta_ly8_rangeley_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_QUANTA_LY8_RANGELEY_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS - { __x86_64_quanta_ly8_rangeley_config_STRINGIFY_NAME(X86_64_QUANTA_LY8_RANGELEY_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS), __x86_64_quanta_ly8_rangeley_config_STRINGIFY_VALUE(X86_64_QUANTA_LY8_RANGELEY_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS) }, -#else -{ X86_64_QUANTA_LY8_RANGELEY_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS(__x86_64_quanta_ly8_rangeley_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_QUANTA_LY8_RANGELEY_CONFIG_INCLUDE_UCLI - { __x86_64_quanta_ly8_rangeley_config_STRINGIFY_NAME(X86_64_QUANTA_LY8_RANGELEY_CONFIG_INCLUDE_UCLI), __x86_64_quanta_ly8_rangeley_config_STRINGIFY_VALUE(X86_64_QUANTA_LY8_RANGELEY_CONFIG_INCLUDE_UCLI) }, -#else -{ X86_64_QUANTA_LY8_RANGELEY_CONFIG_INCLUDE_UCLI(__x86_64_quanta_ly8_rangeley_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_QUANTA_LY8_RANGELEY_CONFIG_SYSFAN_RPM_FAILURE_THRESHOLD - { __x86_64_quanta_ly8_rangeley_config_STRINGIFY_NAME(X86_64_QUANTA_LY8_RANGELEY_CONFIG_SYSFAN_RPM_FAILURE_THRESHOLD), __x86_64_quanta_ly8_rangeley_config_STRINGIFY_VALUE(X86_64_QUANTA_LY8_RANGELEY_CONFIG_SYSFAN_RPM_FAILURE_THRESHOLD) }, -#else -{ X86_64_QUANTA_LY8_RANGELEY_CONFIG_SYSFAN_RPM_FAILURE_THRESHOLD(__x86_64_quanta_ly8_rangeley_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_QUANTA_LY8_RANGELEY_CONFIG_SYSFAN_F2B_RPM_MAX - { __x86_64_quanta_ly8_rangeley_config_STRINGIFY_NAME(X86_64_QUANTA_LY8_RANGELEY_CONFIG_SYSFAN_F2B_RPM_MAX), __x86_64_quanta_ly8_rangeley_config_STRINGIFY_VALUE(X86_64_QUANTA_LY8_RANGELEY_CONFIG_SYSFAN_F2B_RPM_MAX) }, -#else -{ X86_64_QUANTA_LY8_RANGELEY_CONFIG_SYSFAN_F2B_RPM_MAX(__x86_64_quanta_ly8_rangeley_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_QUANTA_LY8_RANGELEY_CONFIG_SYSFAN_B2F_RPM_MAX - { __x86_64_quanta_ly8_rangeley_config_STRINGIFY_NAME(X86_64_QUANTA_LY8_RANGELEY_CONFIG_SYSFAN_B2F_RPM_MAX), __x86_64_quanta_ly8_rangeley_config_STRINGIFY_VALUE(X86_64_QUANTA_LY8_RANGELEY_CONFIG_SYSFAN_B2F_RPM_MAX) }, -#else -{ X86_64_QUANTA_LY8_RANGELEY_CONFIG_SYSFAN_B2F_RPM_MAX(__x86_64_quanta_ly8_rangeley_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_QUANTA_LY8_RANGELEY_CONFIG_PHY_RESET_DELAY_MS - { __x86_64_quanta_ly8_rangeley_config_STRINGIFY_NAME(X86_64_QUANTA_LY8_RANGELEY_CONFIG_PHY_RESET_DELAY_MS), __x86_64_quanta_ly8_rangeley_config_STRINGIFY_VALUE(X86_64_QUANTA_LY8_RANGELEY_CONFIG_PHY_RESET_DELAY_MS) }, -#else -{ X86_64_QUANTA_LY8_RANGELEY_CONFIG_PHY_RESET_DELAY_MS(__x86_64_quanta_ly8_rangeley_config_STRINGIFY_NAME), "__undefined__" }, -#endif - { NULL, NULL } -}; -#undef __x86_64_quanta_ly8_rangeley_config_STRINGIFY_VALUE -#undef __x86_64_quanta_ly8_rangeley_config_STRINGIFY_NAME - -const char* -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)) { - return x86_64_quanta_ly8_rangeley_config_settings[i].value; - } - } - return NULL; -} - -int -x86_64_quanta_ly8_rangeley_config_show(struct aim_pvs_s* pvs) -{ - int i; - for(i = 0; x86_64_quanta_ly8_rangeley_config_settings[i].name; i++) { - aim_printf(pvs, "%s = %s\n", x86_64_quanta_ly8_rangeley_config_settings[i].name, x86_64_quanta_ly8_rangeley_config_settings[i].value); - } - return i; -} - -/* */ diff --git a/packages/platforms/quanta/x86-64/ly8-rangeley/onlp/builds/x86_64_quanta_ly8_rangeley/module/src/x86_64_quanta_ly8_rangeley_enums.c b/packages/platforms/quanta/x86-64/ly8-rangeley/onlp/builds/x86_64_quanta_ly8_rangeley/module/src/x86_64_quanta_ly8_rangeley_enums.c deleted file mode 100644 index bf945569d..000000000 --- a/packages/platforms/quanta/x86-64/ly8-rangeley/onlp/builds/x86_64_quanta_ly8_rangeley/module/src/x86_64_quanta_ly8_rangeley_enums.c +++ /dev/null @@ -1,10 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#include - -/* <--auto.start.enum(ALL).source> */ -/* */ - diff --git a/packages/platforms/quanta/x86-64/ly8-rangeley/onlp/builds/x86_64_quanta_ly8_rangeley/module/src/x86_64_quanta_ly8_rangeley_int.h b/packages/platforms/quanta/x86-64/ly8-rangeley/onlp/builds/x86_64_quanta_ly8_rangeley/module/src/x86_64_quanta_ly8_rangeley_int.h deleted file mode 100755 index 006cc533e..000000000 --- a/packages/platforms/quanta/x86-64/ly8-rangeley/onlp/builds/x86_64_quanta_ly8_rangeley/module/src/x86_64_quanta_ly8_rangeley_int.h +++ /dev/null @@ -1,306 +0,0 @@ -/**************************************************************************//** - * - * x86_64_quanta_ly8_rangeley Internal Header - * - *****************************************************************************/ -#ifndef __X86_64_QUANTA_LY8_RANGELEY_INT_H__ -#define __X86_64_QUANTA_LY8_RANGELEY_INT_H__ - -#include -#include - -/* */ -/** 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[]; - -/** 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 { - 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[]; - -/** 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 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_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_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 fan_alert; - int psu1_present; - int psu2_present; - int psu1_power_good; - int psu2_power_good; -}; - -#define SYS_HWMON_PREFIX "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/0-004e" - -#endif /* __X86_64_QUANTA_LY8_RANGELEY_INT_H__ */ diff --git a/packages/platforms/quanta/x86-64/ly8-rangeley/onlp/builds/x86_64_quanta_ly8_rangeley/module/src/x86_64_quanta_ly8_rangeley_log.c b/packages/platforms/quanta/x86-64/ly8-rangeley/onlp/builds/x86_64_quanta_ly8_rangeley/module/src/x86_64_quanta_ly8_rangeley_log.c deleted file mode 100644 index 1807a21fc..000000000 --- a/packages/platforms/quanta/x86-64/ly8-rangeley/onlp/builds/x86_64_quanta_ly8_rangeley/module/src/x86_64_quanta_ly8_rangeley_log.c +++ /dev/null @@ -1,18 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#include - -#include "x86_64_quanta_ly8_rangeley_log.h" -/* - * x86_64_quanta_ly8_rangeley log struct. - */ -AIM_LOG_STRUCT_DEFINE( - X86_64_QUANTA_LY8_RANGELEY_CONFIG_LOG_OPTIONS_DEFAULT, - X86_64_QUANTA_LY8_RANGELEY_CONFIG_LOG_BITS_DEFAULT, - NULL, /* Custom log map */ - X86_64_QUANTA_LY8_RANGELEY_CONFIG_LOG_CUSTOM_BITS_DEFAULT - ); - diff --git a/packages/platforms/quanta/x86-64/ly8-rangeley/onlp/builds/x86_64_quanta_ly8_rangeley/module/src/x86_64_quanta_ly8_rangeley_log.h b/packages/platforms/quanta/x86-64/ly8-rangeley/onlp/builds/x86_64_quanta_ly8_rangeley/module/src/x86_64_quanta_ly8_rangeley_log.h deleted file mode 100644 index d64dbb58e..000000000 --- a/packages/platforms/quanta/x86-64/ly8-rangeley/onlp/builds/x86_64_quanta_ly8_rangeley/module/src/x86_64_quanta_ly8_rangeley_log.h +++ /dev/null @@ -1,12 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#ifndef __X86_64_QUANTA_LY8_RANGELEY_LOG_H__ -#define __X86_64_QUANTA_LY8_RANGELEY_LOG_H__ - -#define AIM_LOG_MODULE_NAME x86_64_quanta_ly8_rangeley -#include - -#endif /* __X86_64_QUANTA_LY8_RANGELEY_LOG_H__ */ diff --git a/packages/platforms/quanta/x86-64/ly8-rangeley/onlp/builds/x86_64_quanta_ly8_rangeley/module/src/x86_64_quanta_ly8_rangeley_module.c b/packages/platforms/quanta/x86-64/ly8-rangeley/onlp/builds/x86_64_quanta_ly8_rangeley/module/src/x86_64_quanta_ly8_rangeley_module.c deleted file mode 100644 index 09904e837..000000000 --- a/packages/platforms/quanta/x86-64/ly8-rangeley/onlp/builds/x86_64_quanta_ly8_rangeley/module/src/x86_64_quanta_ly8_rangeley_module.c +++ /dev/null @@ -1,24 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#include - -#include "x86_64_quanta_ly8_rangeley_log.h" - -static int -datatypes_init__(void) -{ -#define X86_64_QUANTA_LY8_RANGELEY_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_ly8_rangeley_module_init__(void) -{ - AIM_LOG_STRUCT_REGISTER(); - datatypes_init__(); -} - -int __onlp_platform_version__ = 1; diff --git a/packages/platforms/quanta/x86-64/ly8-rangeley/onlp/builds/x86_64_quanta_ly8_rangeley/module/src/x86_64_quanta_ly8_rangeley_ucli.c b/packages/platforms/quanta/x86-64/ly8-rangeley/onlp/builds/x86_64_quanta_ly8_rangeley/module/src/x86_64_quanta_ly8_rangeley_ucli.c deleted file mode 100644 index 4152bbf0d..000000000 --- a/packages/platforms/quanta/x86-64/ly8-rangeley/onlp/builds/x86_64_quanta_ly8_rangeley/module/src/x86_64_quanta_ly8_rangeley_ucli.c +++ /dev/null @@ -1,50 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#include - -#if X86_64_QUANTA_LY8_RANGELEY_CONFIG_INCLUDE_UCLI == 1 - -#include -#include -#include - -static ucli_status_t -x86_64_quanta_ly8_rangeley_ucli_ucli__config__(ucli_context_t* uc) -{ - UCLI_HANDLER_MACRO_MODULE_CONFIG(x86_64_quanta_ly8_rangeley) -} - -/* */ -/* */ - -static ucli_module_t -x86_64_quanta_ly8_rangeley_ucli_module__ = - { - "x86_64_quanta_ly8_rangeley_ucli", - NULL, - x86_64_quanta_ly8_rangeley_ucli_ucli_handlers__, - NULL, - NULL, - }; - -ucli_node_t* -x86_64_quanta_ly8_rangeley_ucli_node_create(void) -{ - ucli_node_t* n; - ucli_module_init(&x86_64_quanta_ly8_rangeley_ucli_module__); - n = ucli_node_create("x86_64_quanta_ly8_rangeley", NULL, &x86_64_quanta_ly8_rangeley_ucli_module__); - ucli_node_subnode_add(n, ucli_module_log_node_create("x86_64_quanta_ly8_rangeley")); - return n; -} - -#else -void* -x86_64_quanta_ly8_rangeley_ucli_node_create(void) -{ - return NULL; -} -#endif - diff --git a/packages/platforms/quanta/x86-64/ly8-rangeley/platform-config/Makefile b/packages/platforms/quanta/x86-64/ly8-rangeley/platform-config/Makefile deleted file mode 100644 index 003238cf6..000000000 --- a/packages/platforms/quanta/x86-64/ly8-rangeley/platform-config/Makefile +++ /dev/null @@ -1 +0,0 @@ -include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/quanta/x86-64/ly8-rangeley/platform-config/r0/Makefile b/packages/platforms/quanta/x86-64/ly8-rangeley/platform-config/r0/Makefile deleted file mode 100644 index 003238cf6..000000000 --- a/packages/platforms/quanta/x86-64/ly8-rangeley/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/quanta/x86-64/ly8-rangeley/platform-config/r0/PKG.yml b/packages/platforms/quanta/x86-64/ly8-rangeley/platform-config/r0/PKG.yml deleted file mode 100644 index 8c40081d3..000000000 --- a/packages/platforms/quanta/x86-64/ly8-rangeley/platform-config/r0/PKG.yml +++ /dev/null @@ -1 +0,0 @@ -!include $ONL_TEMPLATES/platform-config-platform.yml ARCH=amd64 VENDOR=quanta BASENAME=x86-64-quanta-ly8-rangeley REVISION=r0 diff --git a/packages/platforms/quanta/x86-64/ly8-rangeley/platform-config/r0/src/lib/x86-64-quanta-ly8-rangeley-r0.yml b/packages/platforms/quanta/x86-64/ly8-rangeley/platform-config/r0/src/lib/x86-64-quanta-ly8-rangeley-r0.yml deleted file mode 100644 index b8a38c374..000000000 --- a/packages/platforms/quanta/x86-64/ly8-rangeley/platform-config/r0/src/lib/x86-64-quanta-ly8-rangeley-r0.yml +++ /dev/null @@ -1,31 +0,0 @@ ---- - -###################################################################### -# -# platform-config for LY8 -# -###################################################################### - -x86-64-quanta-ly8-rangeley-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/ly8-rangeley/platform-config/r0/src/python/x86_64_quanta_ly8_rangeley_r0/__init__.py b/packages/platforms/quanta/x86-64/ly8-rangeley/platform-config/r0/src/python/x86_64_quanta_ly8_rangeley_r0/__init__.py deleted file mode 100755 index ef3c38e26..000000000 --- a/packages/platforms/quanta/x86-64/ly8-rangeley/platform-config/r0/src/python/x86_64_quanta_ly8_rangeley_r0/__init__.py +++ /dev/null @@ -1,38 +0,0 @@ -from onl.platform.base import * -from onl.platform.quanta import * - -class OnlPlatform_x86_64_quanta_ly8_rangeley_r0(OnlPlatformQuanta, - OnlPlatformPortConfig_48x10_6x40): - PLATFORM='x86-64-quanta-ly8-rangeley-r0' - MODEL="LY8" - """ 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.2800" - - 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 - os.system("ln -snf /dev/rtc1 /dev/rtc") - os.system("hwclock --hctosys") - - #SFP for 1~48 port - #QSFP for 49~52 port - for port_number in range(1,53): - bus_number = port_number + 31 - os.system("echo %d >/sys/bus/i2c/devices/%d-0050/port_name" % (port_number, bus_number)) - - #QDB QSFP 53~54port - os.system("echo 53 >/sys/bus/i2c/devices/88-0050/port_name") - os.system("echo 54 >/sys/bus/i2c/devices/89-0050/port_name") - - return True diff --git a/packages/platforms/quanta/x86-64/ly9-rangeley/.gitignore b/packages/platforms/quanta/x86-64/ly9-rangeley/.gitignore deleted file mode 100755 index f4ffb13dd..000000000 --- a/packages/platforms/quanta/x86-64/ly9-rangeley/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -*x86*64*quanta*ly9*rangeley*.mk -onlpdump.mk diff --git a/packages/platforms/quanta/x86-64/ly9-rangeley/Makefile b/packages/platforms/quanta/x86-64/ly9-rangeley/Makefile deleted file mode 100755 index 003238cf6..000000000 --- a/packages/platforms/quanta/x86-64/ly9-rangeley/Makefile +++ /dev/null @@ -1 +0,0 @@ -include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/quanta/x86-64/ly9-rangeley/modules/Makefile b/packages/platforms/quanta/x86-64/ly9-rangeley/modules/Makefile deleted file mode 100644 index 003238cf6..000000000 --- a/packages/platforms/quanta/x86-64/ly9-rangeley/modules/Makefile +++ /dev/null @@ -1 +0,0 @@ -include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/quanta/x86-64/ly9-rangeley/modules/PKG.yml b/packages/platforms/quanta/x86-64/ly9-rangeley/modules/PKG.yml deleted file mode 100755 index a046eefa6..000000000 --- a/packages/platforms/quanta/x86-64/ly9-rangeley/modules/PKG.yml +++ /dev/null @@ -1 +0,0 @@ -!include $ONL_TEMPLATES/platform-modules.yml ARCH=amd64 VENDOR=quanta BASENAME=x86-64-quanta-ly9-rangeley KERNELS="onl-kernel-3.16-lts-x86-64-all:amd64" diff --git a/packages/platforms/quanta/x86-64/ly9-rangeley/modules/builds/.gitignore b/packages/platforms/quanta/x86-64/ly9-rangeley/modules/builds/.gitignore deleted file mode 100755 index a65b41774..000000000 --- a/packages/platforms/quanta/x86-64/ly9-rangeley/modules/builds/.gitignore +++ /dev/null @@ -1 +0,0 @@ -lib diff --git a/packages/platforms/quanta/x86-64/ly9-rangeley/modules/builds/Makefile b/packages/platforms/quanta/x86-64/ly9-rangeley/modules/builds/Makefile deleted file mode 100755 index bf952761b..000000000 --- a/packages/platforms/quanta/x86-64/ly9-rangeley/modules/builds/Makefile +++ /dev/null @@ -1,6 +0,0 @@ -KERNELS := onl-kernel-3.16-lts-x86-64-all:amd64 -KMODULES := $(wildcard *.c) -VENDOR := quanta -BASENAME := x86-64-quanta-ly9-rangeley -ARCH := x86_64 -include $(ONL)/make/kmodule.mk diff --git a/packages/platforms/quanta/x86-64/ly9-rangeley/modules/builds/quanta_platform_ly9.c b/packages/platforms/quanta/x86-64/ly9-rangeley/modules/builds/quanta_platform_ly9.c deleted file mode 100755 index 4909209c5..000000000 --- a/packages/platforms/quanta/x86-64/ly9-rangeley/modules/builds/quanta_platform_ly9.c +++ /dev/null @@ -1,303 +0,0 @@ -/* - * 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-ly9" - -#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_4_ports, - i2c_type_24c02, - i2c_type_emerson700, - i2c_type_quanta_ly9_hwmon, -}; - -char *i2c_type_names[] = { - "spd", - "ds1339", - "pca9546", - "pca9548", - "pca9554", - "pca9555", - "pca9698", - "CPLD-QSFP", - "24c02", - "emerson700", - "quanta_ly9_hwmon", -}; - -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_ly9_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_quanta_ly9_hwmon, .addr = 0x4e, .name = "PSoc\0" }, - { .parent_bus = (0x00 + 0), .type = i2c_type_spd, .addr = 0x52, .name = "SPD\0" }, - { .parent_bus = (0x00 + 0), .type = i2c_type_rtc, .addr = 0x68, .name = "RTC\0" }, - { .parent_bus = (0x00 + 0), .type = i2c_type_pca9548, .addr = 0x77, .busno = 0x10, .name = "PCA9548APW1\0" }, - - { .parent_bus = (0x10 + 5), .type = i2c_type_pca9548, .addr = 0x76, .busno = 0x20, .name = "PCA9548APW2\0" }, - { .parent_bus = (0x00 + 0), .type = i2c_type_qci_cpld_4_ports, .addr = 0x3a, .name = "quanta_ly9_cpld\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 = "QSFP_49_EEPROM\0" }, - { .parent_bus = (0x20 + 1), .type = i2c_type_24c02, .addr = 0x50, .name = "QSFP_50_EEPROM\0" }, - { .parent_bus = (0x20 + 2), .type = i2c_type_24c02, .addr = 0x50, .name = "QSFP_51_EEPROM\0" }, - { .parent_bus = (0x20 + 3), .type = i2c_type_24c02, .addr = 0x50, .name = "QSFP_52_EEPROM\0" }, - - /* 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 = 0x30, .name = "PCA9546(QDB)\0" }, - { .parent_bus = (0x30 + 0), .type = i2c_type_24c02, .addr = 0x50, .name = "QSFP_53_EEPROM\0" }, - { .parent_bus = (0x30 + 1), .type = i2c_type_24c02, .addr = 0x50, .name = "QSFP_54_EEPROM\0" }, - - { .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 */ - { .parent_bus = (0x18 + 1), .type = i2c_type_emerson700, .addr = 0x69, .name = "PSU_2\0" }, /* RPSU 2 */ - { .parent_bus = (0x18 + 2), .type = i2c_type_pca9555, .addr = 0x26, .name = "PCA9555_1(PSU)\0" }, - { .parent_bus = (0x18 + 3), .type = i2c_type_24c02, .addr = 0x54, .name = "Board_EEPROM\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 - -/* <--auto.start.xmacro(ALL).define> */ -/* */ - -/* <--auto.start.xenum(ALL).define> */ -/* */ - - diff --git a/packages/platforms/quanta/x86-64/ly9-rangeley/onlp/builds/x86_64_quanta_ly9_rangeley/module/inc/x86_64_quanta_ly9_rangeley/x86_64_quanta_ly9_rangeley_config.h b/packages/platforms/quanta/x86-64/ly9-rangeley/onlp/builds/x86_64_quanta_ly9_rangeley/module/inc/x86_64_quanta_ly9_rangeley/x86_64_quanta_ly9_rangeley_config.h deleted file mode 100755 index 658f7e656..000000000 --- a/packages/platforms/quanta/x86-64/ly9-rangeley/onlp/builds/x86_64_quanta_ly9_rangeley/module/inc/x86_64_quanta_ly9_rangeley/x86_64_quanta_ly9_rangeley_config.h +++ /dev/null @@ -1,167 +0,0 @@ -/**************************************************************************//** - * - * @file - * @brief x86_64_quanta_ly9_rangeley Configuration Header - * - * @addtogroup x86_64_quanta_ly9_rangeley-config - * @{ - * - *****************************************************************************/ -#ifndef __X86_64_QUANTA_LY9_RANGELEY_CONFIG_H__ -#define __X86_64_QUANTA_LY9_RANGELEY_CONFIG_H__ - -#ifdef GLOBAL_INCLUDE_CUSTOM_CONFIG -#include -#endif -#ifdef X86_64_QUANTA_LY9_RANGELEY_INCLUDE_CUSTOM_CONFIG -#include -#endif - -/* */ -#include -/** - * X86_64_QUANTA_LY9_RANGELEY_CONFIG_INCLUDE_LOGGING - * - * Include or exclude logging. */ - - -#ifndef X86_64_QUANTA_LY9_RANGELEY_CONFIG_INCLUDE_LOGGING -#define X86_64_QUANTA_LY9_RANGELEY_CONFIG_INCLUDE_LOGGING 1 -#endif - -/** - * X86_64_QUANTA_LY9_RANGELEY_CONFIG_LOG_OPTIONS_DEFAULT - * - * Default enabled log options. */ - - -#ifndef X86_64_QUANTA_LY9_RANGELEY_CONFIG_LOG_OPTIONS_DEFAULT -#define X86_64_QUANTA_LY9_RANGELEY_CONFIG_LOG_OPTIONS_DEFAULT AIM_LOG_OPTIONS_DEFAULT -#endif - -/** - * X86_64_QUANTA_LY9_RANGELEY_CONFIG_LOG_BITS_DEFAULT - * - * Default enabled log bits. */ - - -#ifndef X86_64_QUANTA_LY9_RANGELEY_CONFIG_LOG_BITS_DEFAULT -#define X86_64_QUANTA_LY9_RANGELEY_CONFIG_LOG_BITS_DEFAULT AIM_LOG_BITS_DEFAULT -#endif - -/** - * X86_64_QUANTA_LY9_RANGELEY_CONFIG_LOG_CUSTOM_BITS_DEFAULT - * - * Default enabled custom log bits. */ - - -#ifndef X86_64_QUANTA_LY9_RANGELEY_CONFIG_LOG_CUSTOM_BITS_DEFAULT -#define X86_64_QUANTA_LY9_RANGELEY_CONFIG_LOG_CUSTOM_BITS_DEFAULT 0 -#endif - -/** - * X86_64_QUANTA_LY9_RANGELEY_CONFIG_PORTING_STDLIB - * - * Default all porting macros to use the C standard libraries. */ - - -#ifndef X86_64_QUANTA_LY9_RANGELEY_CONFIG_PORTING_STDLIB -#define X86_64_QUANTA_LY9_RANGELEY_CONFIG_PORTING_STDLIB 1 -#endif - -/** - * X86_64_QUANTA_LY9_RANGELEY_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS - * - * Include standard library headers for stdlib porting macros. */ - - -#ifndef X86_64_QUANTA_LY9_RANGELEY_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS -#define X86_64_QUANTA_LY9_RANGELEY_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS X86_64_QUANTA_LY9_RANGELEY_CONFIG_PORTING_STDLIB -#endif - -/** - * X86_64_QUANTA_LY9_RANGELEY_CONFIG_INCLUDE_UCLI - * - * Include generic uCli support. */ - - -#ifndef X86_64_QUANTA_LY9_RANGELEY_CONFIG_INCLUDE_UCLI -#define X86_64_QUANTA_LY9_RANGELEY_CONFIG_INCLUDE_UCLI 0 -#endif - -/** - * X86_64_QUANTA_LY9_RANGELEY_CONFIG_SYSFAN_RPM_FAILURE_THRESHOLD - * - * RPM Threshold at which the fan is considered to have failed. */ - - -#ifndef X86_64_QUANTA_LY9_RANGELEY_CONFIG_SYSFAN_RPM_FAILURE_THRESHOLD -#define X86_64_QUANTA_LY9_RANGELEY_CONFIG_SYSFAN_RPM_FAILURE_THRESHOLD 3000 -#endif - -/** - * X86_64_QUANTA_LY9_RANGELEY_CONFIG_SYSFAN_F2B_RPM_MAX - * - * Maximum system front-to-back fan speed. */ - - -#ifndef X86_64_QUANTA_LY9_RANGELEY_CONFIG_SYSFAN_F2B_RPM_MAX -#define X86_64_QUANTA_LY9_RANGELEY_CONFIG_SYSFAN_F2B_RPM_MAX 18000 -#endif - -/** - * X86_64_QUANTA_LY9_RANGELEY_CONFIG_SYSFAN_B2F_RPM_MAX - * - * Maximum system back-to-front fan speed. */ - - -#ifndef X86_64_QUANTA_LY9_RANGELEY_CONFIG_SYSFAN_B2F_RPM_MAX -#define X86_64_QUANTA_LY9_RANGELEY_CONFIG_SYSFAN_B2F_RPM_MAX 18000 -#endif - -/** - * X86_64_QUANTA_LY9_RANGELEY_CONFIG_PHY_RESET_DELAY_MS - * - * Time to hold Phy GPIO in reset, in ms */ - - -#ifndef X86_64_QUANTA_LY9_RANGELEY_CONFIG_PHY_RESET_DELAY_MS -#define X86_64_QUANTA_LY9_RANGELEY_CONFIG_PHY_RESET_DELAY_MS 100 -#endif - - - -/** - * All compile time options can be queried or displayed - */ - -/** Configuration settings structure. */ -typedef struct x86_64_quanta_ly9_rangeley_config_settings_s { - /** name */ - const char* name; - /** value */ - const char* value; -} x86_64_quanta_ly9_rangeley_config_settings_t; - -/** Configuration settings table. */ -/** x86_64_quanta_ly9_rangeley_config_settings table. */ -extern x86_64_quanta_ly9_rangeley_config_settings_t x86_64_quanta_ly9_rangeley_config_settings[]; - -/** - * @brief Lookup a configuration setting. - * @param setting The name of the configuration option to lookup. - */ -const char* x86_64_quanta_ly9_rangeley_config_lookup(const char* setting); - -/** - * @brief Show the compile-time configuration. - * @param pvs The output stream. - */ -int x86_64_quanta_ly9_rangeley_config_show(struct aim_pvs_s* pvs); - -/* */ - -#include "x86_64_quanta_ly9_rangeley_porting.h" - -#endif /* __X86_64_QUANTA_LY9_RANGELEY_CONFIG_H__ */ -/* @} */ diff --git a/packages/platforms/quanta/x86-64/ly9-rangeley/onlp/builds/x86_64_quanta_ly9_rangeley/module/inc/x86_64_quanta_ly9_rangeley/x86_64_quanta_ly9_rangeley_dox.h b/packages/platforms/quanta/x86-64/ly9-rangeley/onlp/builds/x86_64_quanta_ly9_rangeley/module/inc/x86_64_quanta_ly9_rangeley/x86_64_quanta_ly9_rangeley_dox.h deleted file mode 100755 index 8d232db73..000000000 --- a/packages/platforms/quanta/x86-64/ly9-rangeley/onlp/builds/x86_64_quanta_ly9_rangeley/module/inc/x86_64_quanta_ly9_rangeley/x86_64_quanta_ly9_rangeley_dox.h +++ /dev/null @@ -1,26 +0,0 @@ -/**************************************************************************//** - * - * x86_64_quanta_ly9_rangeley Doxygen Header - * - *****************************************************************************/ -#ifndef __X86_64_QUANTA_LY9_RANGELEY_DOX_H__ -#define __X86_64_QUANTA_LY9_RANGELEY_DOX_H__ - -/** - * @defgroup x86_64_quanta_ly9_rangeley x86_64_quanta_ly9_rangeley - x86_64_quanta_ly9_rangeley Description - * - -The documentation overview for this module should go here. - - * - * @{ - * - * @defgroup x86_64_quanta_ly9_rangeley-x86_64_quanta_ly9_rangeley Public Interface - * @defgroup x86_64_quanta_ly9_rangeley-config Compile Time Configuration - * @defgroup x86_64_quanta_ly9_rangeley-porting Porting Macros - * - * @} - * - */ - -#endif /* __X86_64_QUANTA_LY9_RANGELEY_DOX_H__ */ diff --git a/packages/platforms/quanta/x86-64/ly9-rangeley/onlp/builds/x86_64_quanta_ly9_rangeley/module/inc/x86_64_quanta_ly9_rangeley/x86_64_quanta_ly9_rangeley_gpio_table.h b/packages/platforms/quanta/x86-64/ly9-rangeley/onlp/builds/x86_64_quanta_ly9_rangeley/module/inc/x86_64_quanta_ly9_rangeley/x86_64_quanta_ly9_rangeley_gpio_table.h deleted file mode 100755 index 73892da0a..000000000 --- a/packages/platforms/quanta/x86-64/ly9-rangeley/onlp/builds/x86_64_quanta_ly9_rangeley/module/inc/x86_64_quanta_ly9_rangeley/x86_64_quanta_ly9_rangeley_gpio_table.h +++ /dev/null @@ -1,59 +0,0 @@ -#ifndef __X86_64_QUANTA_LY9_RANGELEY_GPIO_TABLE_H__ -#define __X86_64_QUANTA_LY9_RANGELEY_GPIO_TABLE_H__ - -/* - * defined within platform/quanta_switch.c - * Quanta Switch Platform driver - */ -#define QUANTA_LY9_PCA953x_GPIO(P1, P2) (P1*8+P2) - -#define QUANTA_LY9_PCA9555_GPIO_SIZE 0x10 - -#define QUANTA_LY9_I2C_GPIO_CPU_BASE 0x40 - -#define QUANTA_LY9_CPU_BOARD_GPIO_BASE (QUANTA_LY9_I2C_GPIO_CPU_BASE) -#define QUANTA_LY9_CPU_BOARD_SYS_P1 (QUANTA_LY9_CPU_BOARD_GPIO_BASE + QUANTA_LY9_PCA953x_GPIO(1,2)) -#define QUANTA_LY9_CPU_BOARD_SYS_P2 (QUANTA_LY9_CPU_BOARD_GPIO_BASE + QUANTA_LY9_PCA953x_GPIO(1,3)) - -#define QUANTA_LY9_I2C_GPIO_BASE 0x80 - -#define QUANTA_LY9_FAN_GPIO_BASE (QUANTA_LY9_I2C_GPIO_BASE) -#define QUANTA_LY9_FAN_GPIO_SIZE QUANTA_LY9_PCA9555_GPIO_SIZE -#define QUANTA_LY9_FAN_PRSNT_N_1 (QUANTA_LY9_FAN_GPIO_BASE + QUANTA_LY9_PCA953x_GPIO(0,4)) -#define QUANTA_LY9_FAN_PRSNT_N_2 (QUANTA_LY9_FAN_GPIO_BASE + QUANTA_LY9_PCA953x_GPIO(0,5)) -#define QUANTA_LY9_FAN_PRSNT_N_3 (QUANTA_LY9_FAN_GPIO_BASE + QUANTA_LY9_PCA953x_GPIO(0,6)) -#define QUANTA_LY9_FAN_BF_DET1 (QUANTA_LY9_FAN_GPIO_BASE + QUANTA_LY9_PCA953x_GPIO(1,0)) -#define QUANTA_LY9_FAN_BF_DET2 (QUANTA_LY9_FAN_GPIO_BASE + QUANTA_LY9_PCA953x_GPIO(1,1)) -#define QUANTA_LY9_FAN_BF_DET3 (QUANTA_LY9_FAN_GPIO_BASE + QUANTA_LY9_PCA953x_GPIO(1,2)) -#define QUANTA_LY9_FAN_FAIL_LED_1 (QUANTA_LY9_FAN_GPIO_BASE + QUANTA_LY9_PCA953x_GPIO(1,4)) -#define QUANTA_LY9_FAN_FAIL_LED_2 (QUANTA_LY9_FAN_GPIO_BASE + QUANTA_LY9_PCA953x_GPIO(1,5)) -#define QUANTA_LY9_FAN_FAIL_LED_3 (QUANTA_LY9_FAN_GPIO_BASE + QUANTA_LY9_PCA953x_GPIO(1,6)) - -#define QUANTA_LY9_QSFP_EN_GPIO_BASE (QUANTA_LY9_FAN_GPIO_BASE + QUANTA_LY9_FAN_GPIO_SIZE) -#define QUANTA_LY9_QSFP_EN_GPIO_SIZE QUANTA_LY9_PCA9555_GPIO_SIZE -#define QUANTA_LY9_QSFP_EN_GPIO_P3V3_PW_GD (QUANTA_LY9_QSFP_EN_GPIO_BASE + QUANTA_LY9_PCA953x_GPIO(0,4)) -#define QUANTA_LY9_QSFP_EN_GPIO_P3V3_PW_EN (QUANTA_LY9_QSFP_EN_GPIO_BASE + QUANTA_LY9_PCA953x_GPIO(0,5)) -#define QUANTA_LY9_QSFP_EN_GPIO_QDB_PRSNT (QUANTA_LY9_QSFP_EN_GPIO_BASE + QUANTA_LY9_PCA953x_GPIO(0,6)) - -#define QUANTA_LY9_QSFP_QDB_GPIO_BASE (QUANTA_LY9_QSFP_EN_GPIO_BASE + QUANTA_LY9_QSFP_EN_GPIO_SIZE) -#define QUANTA_LY9_QSFP_QDB_GPIO_SIZE QUANTA_LY9_PCA9555_GPIO_SIZE -#define QUANTA_LY9_QSFP_QDB_GPIO_PRSNT_53_N (QUANTA_LY9_QSFP_QDB_GPIO_BASE + QUANTA_LY9_PCA953x_GPIO(0,2)) -#define QUANTA_LY9_QSFP_QDB_GPIO_PRSNT_54_N (QUANTA_LY9_QSFP_QDB_GPIO_BASE + QUANTA_LY9_PCA953x_GPIO(0,6)) -#define QUANTA_LY9_QSFP_QDB_GPIO_MOD_EN_N (QUANTA_LY9_QSFP_QDB_GPIO_BASE + QUANTA_LY9_PCA953x_GPIO(1,0)) - -#define QUANTA_LY9_PSU_GPIO_BASE (QUANTA_LY9_QSFP_QDB_GPIO_BASE + QUANTA_LY9_QSFP_QDB_GPIO_SIZE) -#define QUANTA_LY9_PSU_GPIO_SIZE QUANTA_LY9_PCA9555_GPIO_SIZE -#define QUANTA_LY9_PSU_GPIO_PSU1_PRSNT_N (QUANTA_LY9_PSU_GPIO_BASE + QUANTA_LY9_PCA953x_GPIO(0,0)) -#define QUANTA_LY9_PSU_GPIO_PSU1_PWRGD (QUANTA_LY9_PSU_GPIO_BASE + QUANTA_LY9_PCA953x_GPIO(0,1)) -#define QUANTA_LY9_PSU_GPIO_PSU2_PRSNT_N (QUANTA_LY9_PSU_GPIO_BASE + QUANTA_LY9_PCA953x_GPIO(0,3)) -#define QUANTA_LY9_PSU_GPIO_PSU2_PWRGD (QUANTA_LY9_PSU_GPIO_BASE + QUANTA_LY9_PCA953x_GPIO(0,4)) -#define QUANTA_LY9_PSU_GPIO_PSU1_AC_OK (QUANTA_LY9_PSU_GPIO_BASE + QUANTA_LY9_PCA953x_GPIO(0,6)) -#define QUANTA_LY9_PSU_GPIO_PSU2_AC_OK (QUANTA_LY9_PSU_GPIO_BASE + QUANTA_LY9_PCA953x_GPIO(0,7)) -#define QUANTA_LY9_PSU_GPIO_PSU1_GREEN_R (QUANTA_LY9_PSU_GPIO_BASE + QUANTA_LY9_PCA953x_GPIO(1,2)) -#define QUANTA_LY9_PSU_GPIO_PSU1_RED_R (QUANTA_LY9_PSU_GPIO_BASE + QUANTA_LY9_PCA953x_GPIO(1,3)) -#define QUANTA_LY9_PSU_GPIO_PSU2_GREEN_R (QUANTA_LY9_PSU_GPIO_BASE + QUANTA_LY9_PCA953x_GPIO(1,4)) -#define QUANTA_LY9_PSU_GPIO_PSU2_RED_R (QUANTA_LY9_PSU_GPIO_BASE + QUANTA_LY9_PCA953x_GPIO(1,5)) -#define QUANTA_LY9_PSU_GPIO_FAN_GREEN_R (QUANTA_LY9_PSU_GPIO_BASE + QUANTA_LY9_PCA953x_GPIO(1,6)) -#define QUANTA_LY9_PSU_GPIO_FAN_RED_R (QUANTA_LY9_PSU_GPIO_BASE + QUANTA_LY9_PCA953x_GPIO(1,7)) - -#endif /* __X86_64_QUANTA_LY9_RANGELEY_GPIO_TABLE_H__ */ diff --git a/packages/platforms/quanta/x86-64/ly9-rangeley/onlp/builds/x86_64_quanta_ly9_rangeley/module/inc/x86_64_quanta_ly9_rangeley/x86_64_quanta_ly9_rangeley_porting.h b/packages/platforms/quanta/x86-64/ly9-rangeley/onlp/builds/x86_64_quanta_ly9_rangeley/module/inc/x86_64_quanta_ly9_rangeley/x86_64_quanta_ly9_rangeley_porting.h deleted file mode 100755 index ad34056c3..000000000 --- a/packages/platforms/quanta/x86-64/ly9-rangeley/onlp/builds/x86_64_quanta_ly9_rangeley/module/inc/x86_64_quanta_ly9_rangeley/x86_64_quanta_ly9_rangeley_porting.h +++ /dev/null @@ -1,77 +0,0 @@ -/**************************************************************************//** - * - * @file - * @brief x86_64_quanta_ly9_rangeley Porting Macros. - * - * @addtogroup x86_64_quanta_ly9_rangeley-porting - * @{ - * - *****************************************************************************/ -#ifndef __X86_64_QUANTA_LY9_RANGELEY_PORTING_H__ -#define __X86_64_QUANTA_LY9_RANGELEY_PORTING_H__ - - -/* */ -#if X86_64_QUANTA_LY9_RANGELEY_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS == 1 -#include -#include -#include -#include -#include -#endif - -#ifndef X86_64_QUANTA_LY9_RANGELEY_MEMSET - #if defined(GLOBAL_MEMSET) - #define X86_64_QUANTA_LY9_RANGELEY_MEMSET GLOBAL_MEMSET - #elif X86_64_QUANTA_LY9_RANGELEY_CONFIG_PORTING_STDLIB == 1 - #define X86_64_QUANTA_LY9_RANGELEY_MEMSET memset - #else - #error The macro X86_64_QUANTA_LY9_RANGELEY_MEMSET is required but cannot be defined. - #endif -#endif - -#ifndef X86_64_QUANTA_LY9_RANGELEY_MEMCPY - #if defined(GLOBAL_MEMCPY) - #define X86_64_QUANTA_LY9_RANGELEY_MEMCPY GLOBAL_MEMCPY - #elif X86_64_QUANTA_LY9_RANGELEY_CONFIG_PORTING_STDLIB == 1 - #define X86_64_QUANTA_LY9_RANGELEY_MEMCPY memcpy - #else - #error The macro X86_64_QUANTA_LY9_RANGELEY_MEMCPY is required but cannot be defined. - #endif -#endif - -#ifndef X86_64_QUANTA_LY9_RANGELEY_VSNPRINTF - #if defined(GLOBAL_VSNPRINTF) - #define X86_64_QUANTA_LY9_RANGELEY_VSNPRINTF GLOBAL_VSNPRINTF - #elif X86_64_QUANTA_LY9_RANGELEY_CONFIG_PORTING_STDLIB == 1 - #define X86_64_QUANTA_LY9_RANGELEY_VSNPRINTF vsnprintf - #else - #error The macro X86_64_QUANTA_LY9_RANGELEY_VSNPRINTF is required but cannot be defined. - #endif -#endif - -#ifndef X86_64_QUANTA_LY9_RANGELEY_SNPRINTF - #if defined(GLOBAL_SNPRINTF) - #define X86_64_QUANTA_LY9_RANGELEY_SNPRINTF GLOBAL_SNPRINTF - #elif X86_64_QUANTA_LY9_RANGELEY_CONFIG_PORTING_STDLIB == 1 - #define X86_64_QUANTA_LY9_RANGELEY_SNPRINTF snprintf - #else - #error The macro X86_64_QUANTA_LY9_RANGELEY_SNPRINTF is required but cannot be defined. - #endif -#endif - -#ifndef X86_64_QUANTA_LY9_RANGELEY_STRLEN - #if defined(GLOBAL_STRLEN) - #define X86_64_QUANTA_LY9_RANGELEY_STRLEN GLOBAL_STRLEN - #elif X86_64_QUANTA_LY9_RANGELEY_CONFIG_PORTING_STDLIB == 1 - #define X86_64_QUANTA_LY9_RANGELEY_STRLEN strlen - #else - #error The macro X86_64_QUANTA_LY9_RANGELEY_STRLEN is required but cannot be defined. - #endif -#endif - -/* */ - - -#endif /* __X86_64_QUANTA_LY9_RANGELEY_PORTING_H__ */ -/* @} */ diff --git a/packages/platforms/quanta/x86-64/ly9-rangeley/onlp/builds/x86_64_quanta_ly9_rangeley/module/make.mk b/packages/platforms/quanta/x86-64/ly9-rangeley/onlp/builds/x86_64_quanta_ly9_rangeley/module/make.mk deleted file mode 100755 index 74b4b50ff..000000000 --- a/packages/platforms/quanta/x86-64/ly9-rangeley/onlp/builds/x86_64_quanta_ly9_rangeley/module/make.mk +++ /dev/null @@ -1,10 +0,0 @@ -############################################################################### -# -# -# -############################################################################### -THIS_DIR := $(dir $(lastword $(MAKEFILE_LIST))) -x86_64_quanta_ly9_rangeley_INCLUDES := -I $(THIS_DIR)inc -x86_64_quanta_ly9_rangeley_INTERNAL_INCLUDES := -I $(THIS_DIR)src -x86_64_quanta_ly9_rangeley_DEPENDMODULE_ENTRIES := init:x86_64_quanta_ly9_rangeley ucli:x86_64_quanta_ly9_rangeley - diff --git a/packages/platforms/quanta/x86-64/ly9-rangeley/onlp/builds/x86_64_quanta_ly9_rangeley/module/src/Makefile b/packages/platforms/quanta/x86-64/ly9-rangeley/onlp/builds/x86_64_quanta_ly9_rangeley/module/src/Makefile deleted file mode 100755 index d82e9e30a..000000000 --- a/packages/platforms/quanta/x86-64/ly9-rangeley/onlp/builds/x86_64_quanta_ly9_rangeley/module/src/Makefile +++ /dev/null @@ -1,9 +0,0 @@ -############################################################################### -# -# Local source generation targets. -# -############################################################################### - -ucli: - @../../../../tools/uclihandlers.py x86_64_quanta_ly9_rangeley_ucli.c - diff --git a/packages/platforms/quanta/x86-64/ly9-rangeley/onlp/builds/x86_64_quanta_ly9_rangeley/module/src/fani.c b/packages/platforms/quanta/x86-64/ly9-rangeley/onlp/builds/x86_64_quanta_ly9_rangeley/module/src/fani.c deleted file mode 100755 index 4975129e4..000000000 --- a/packages/platforms/quanta/x86-64/ly9-rangeley/onlp/builds/x86_64_quanta_ly9_rangeley/module/src/fani.c +++ /dev/null @@ -1,168 +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 "x86_64_quanta_ly9_rangeley_int.h" -#include "x86_64_quanta_ly9_rangeley_log.h" - -#include -#include - -int -onlp_fani_init(void) -{ - return ONLP_STATUS_OK; -} - -struct fan_gpio_s { - int present; - int fan_dir_detect; -}; - -static struct fan_gpio_s fan_gpio[] = { - {}, /* Not used */ - { .present = QUANTA_LY9_FAN_PRSNT_N_1, .fan_dir_detect = QUANTA_LY9_FAN_BF_DET1 }, - { .present = QUANTA_LY9_FAN_PRSNT_N_2, .fan_dir_detect = QUANTA_LY9_FAN_BF_DET2 }, - { .present = QUANTA_LY9_FAN_PRSNT_N_3, .fan_dir_detect = QUANTA_LY9_FAN_BF_DET3 }, - {}, /* Not used */ - { .present = QUANTA_LY9_FAN_PRSNT_N_1, .fan_dir_detect = QUANTA_LY9_FAN_BF_DET1 }, - { .present = QUANTA_LY9_FAN_PRSNT_N_2, .fan_dir_detect = QUANTA_LY9_FAN_BF_DET2 }, - { .present = QUANTA_LY9_FAN_PRSNT_N_3, .fan_dir_detect = QUANTA_LY9_FAN_BF_DET3 }, - {}, /* Not used */ -}; - -static int -sys_fan_info_get__(onlp_fan_info_t* info, int id) -{ - int value = 0; - int rv; - - if(onlp_gpio_get(fan_gpio[id].present, &value) == ONLP_STATUS_OK - && value == 0) { - info->status = ONLP_FAN_STATUS_PRESENT; - if(onlp_gpio_get(fan_gpio[id].fan_dir_detect, &value) == ONLP_STATUS_OK - && value == 0) { - info->status |= ONLP_FAN_STATUS_F2B; - info->caps |= ONLP_FAN_CAPS_F2B; - } - else { - info->status |= ONLP_FAN_STATUS_B2F; - info->caps |= ONLP_FAN_CAPS_B2F; - } - } - else { - info->status = ONLP_FAN_STATUS_FAILED; - } - - rv = onlp_file_read_int(&info->rpm, - SYS_HWMON_PREFIX "/fan%d_input", id); - - if(rv == ONLP_STATUS_E_INTERNAL) { - return rv; - } - - if(rv == ONLP_STATUS_E_MISSING) { - info->status &= ~1; - return 0; - } - - if(info->rpm <= X86_64_QUANTA_LY9_RANGELEY_CONFIG_SYSFAN_RPM_FAILURE_THRESHOLD) { - info->status |= ONLP_FAN_STATUS_FAILED; - } - - /* - * Calculate percentage based on current speed and the maximum. - */ - info->caps |= ONLP_FAN_CAPS_GET_PERCENTAGE; - if(info->status & ONLP_FAN_STATUS_F2B) { - info->percentage = (int) ((double) info->rpm * (double)100 / (double)X86_64_QUANTA_LY9_RANGELEY_CONFIG_SYSFAN_F2B_RPM_MAX); - } - if(info->status & ONLP_FAN_STATUS_B2F) { - info->percentage = (int) ((double) info->rpm * (double)100 / (double)X86_64_QUANTA_LY9_RANGELEY_CONFIG_SYSFAN_B2F_RPM_MAX); - } - - return 0; -} - -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, "Left (Module/Fan 1/1)", 0}, ONLP_FAN_STATUS_PRESENT }, - { { FAN_OID_FAN2, "Center(Module/Fan 2/1)", 0}, ONLP_FAN_STATUS_PRESENT }, - { { FAN_OID_FAN3, "Right (Module/Fan 3/1)", 0}, ONLP_FAN_STATUS_PRESENT }, - { { FAN_OID_FAN4, "Reserved (Module/Fan 4/1)", 0}, ONLP_FAN_STATUS_PRESENT }, - { { FAN_OID_FAN5, "Left (Module/Fan 1/2)", 0}, ONLP_FAN_STATUS_PRESENT }, - { { FAN_OID_FAN6, "Center(Module/Fan 2/2)", 0}, ONLP_FAN_STATUS_PRESENT }, - { { FAN_OID_FAN7, "Right (Module/Fan 3/2)", 0}, ONLP_FAN_STATUS_PRESENT }, - { { FAN_OID_FAN8, "Reserved (Module/Fan 4/2)", 0}, ONLP_FAN_STATUS_PRESENT }, - { { FAN_OID_FAN9, "PSU-1 Fan", 0 }, ONLP_FAN_STATUS_PRESENT }, - { { FAN_OID_FAN10, "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: - case FAN_ID_FAN3: - case FAN_ID_FAN4: - case FAN_ID_FAN5: - case FAN_ID_FAN6: - case FAN_ID_FAN7: - case FAN_ID_FAN8: - return sys_fan_info_get__(rv, fid); - break; - - case FAN_ID_FAN9: - case FAN_ID_FAN10: - return psu_fan_info_get__(rv, fid - FAN_ID_FAN9 + 1); - break; - - default: - return ONLP_STATUS_E_INVALID; - break; - } - - return ONLP_STATUS_E_INVALID; -} diff --git a/packages/platforms/quanta/x86-64/ly9-rangeley/onlp/builds/x86_64_quanta_ly9_rangeley/module/src/ledi.c b/packages/platforms/quanta/x86-64/ly9-rangeley/onlp/builds/x86_64_quanta_ly9_rangeley/module/src/ledi.c deleted file mode 100755 index 32e881cae..000000000 --- a/packages/platforms/quanta/x86-64/ly9-rangeley/onlp/builds/x86_64_quanta_ly9_rangeley/module/src/ledi.c +++ /dev/null @@ -1,210 +0,0 @@ -#include -#include -#include -#include -#include - -#include "x86_64_quanta_ly9_rangeley_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, - } -}; - -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_LY9_CPU_BOARD_SYS_P1, 0); - onlp_gpio_set(QUANTA_LY9_CPU_BOARD_SYS_P2, 1); - } - else if(mode == ONLP_LED_MODE_ORANGE){ - onlp_gpio_set(QUANTA_LY9_CPU_BOARD_SYS_P1, 1); - onlp_gpio_set(QUANTA_LY9_CPU_BOARD_SYS_P2, 0); - } - else{ - onlp_gpio_set(QUANTA_LY9_CPU_BOARD_SYS_P1, 1); - onlp_gpio_set(QUANTA_LY9_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_LY9_PSU_GPIO_FAN_GREEN_R, 1); - onlp_gpio_set(QUANTA_LY9_PSU_GPIO_FAN_RED_R, 0); - } - else if(mode == ONLP_LED_MODE_RED){ - onlp_gpio_set(QUANTA_LY9_PSU_GPIO_FAN_GREEN_R, 0); - onlp_gpio_set(QUANTA_LY9_PSU_GPIO_FAN_RED_R, 1); - } - else{ - onlp_gpio_set(QUANTA_LY9_PSU_GPIO_FAN_GREEN_R, 0); - onlp_gpio_set(QUANTA_LY9_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_LY9_PSU_GPIO_PSU1_GREEN_R, 1); - onlp_gpio_set(QUANTA_LY9_PSU_GPIO_PSU1_RED_R, 0); - } - else if(mode == ONLP_LED_MODE_RED){ - onlp_gpio_set(QUANTA_LY9_PSU_GPIO_PSU1_GREEN_R, 0); - onlp_gpio_set(QUANTA_LY9_PSU_GPIO_PSU1_RED_R, 1); - } - else{ - onlp_gpio_set(QUANTA_LY9_PSU_GPIO_PSU1_GREEN_R, 0); - onlp_gpio_set(QUANTA_LY9_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_LY9_PSU_GPIO_PSU2_GREEN_R, 1); - onlp_gpio_set(QUANTA_LY9_PSU_GPIO_PSU2_RED_R, 0); - } - else if(mode == ONLP_LED_MODE_RED){ - onlp_gpio_set(QUANTA_LY9_PSU_GPIO_PSU2_GREEN_R, 0); - onlp_gpio_set(QUANTA_LY9_PSU_GPIO_PSU2_RED_R, 1); - } - else{ - onlp_gpio_set(QUANTA_LY9_PSU_GPIO_PSU2_GREEN_R, 0); - onlp_gpio_set(QUANTA_LY9_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_LY9_FAN_FAIL_LED_1, 1); - } - else{ - onlp_gpio_set(QUANTA_LY9_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_LY9_FAN_FAIL_LED_2, 1); - } - else{ - onlp_gpio_set(QUANTA_LY9_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_LY9_FAN_FAIL_LED_3, 1); - } - else{ - onlp_gpio_set(QUANTA_LY9_FAN_FAIL_LED_3, 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; - default: - return ONLP_STATUS_E_INTERNAL; - break; - } - - return ONLP_STATUS_OK; -} diff --git a/packages/platforms/quanta/x86-64/ly9-rangeley/onlp/builds/x86_64_quanta_ly9_rangeley/module/src/make.mk b/packages/platforms/quanta/x86-64/ly9-rangeley/onlp/builds/x86_64_quanta_ly9_rangeley/module/src/make.mk deleted file mode 100755 index 28db51d43..000000000 --- a/packages/platforms/quanta/x86-64/ly9-rangeley/onlp/builds/x86_64_quanta_ly9_rangeley/module/src/make.mk +++ /dev/null @@ -1,9 +0,0 @@ -############################################################################### -# -# -# -############################################################################### - -LIBRARY := x86_64_quanta_ly9_rangeley -$(LIBRARY)_SUBDIR := $(dir $(lastword $(MAKEFILE_LIST))) -include $(BUILDER)/lib.mk diff --git a/packages/platforms/quanta/x86-64/ly9-rangeley/onlp/builds/x86_64_quanta_ly9_rangeley/module/src/psui.c b/packages/platforms/quanta/x86-64/ly9-rangeley/onlp/builds/x86_64_quanta_ly9_rangeley/module/src/psui.c deleted file mode 100755 index 3eab15b49..000000000 --- a/packages/platforms/quanta/x86-64/ly9-rangeley/onlp/builds/x86_64_quanta_ly9_rangeley/module/src/psui.c +++ /dev/null @@ -1,128 +0,0 @@ -/************************************************************ - * - * - ************************************************************ - * - * - * - ***********************************************************/ -#include -#include -#include -#include -#include -#include -#include "x86_64_quanta_ly9_rangeley_int.h" -#include "x86_64_quanta_ly9_rangeley_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-006f", .present = QUANTA_LY9_PSU_GPIO_PSU1_PRSNT_N, .busno = 24, .addr = 0x6f}, - { .path = "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-25/25-0069", .present = QUANTA_LY9_PSU_GPIO_PSU2_PRSNT_N, .busno = 25, .addr = 0x69}, -}; - -int -onlp_psui_init(void) -{ - return 0; -} - -static onlp_psu_info_t psus__[] = { - { }, /* Not used */ - { - { - PSU_OID_PSU1, - "Quanta LY9 RPSU-1", - 0, - { - FAN_OID_FAN9, - }, - } - }, - { - { - PSU_OID_PSU2, - "Quanta LY9 RPSU-2", - 0, - { - FAN_OID_FAN10, - }, - } - }, -}; - -#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; - uint8_t buffer[ONLP_CONFIG_INFO_STR_MAX]; - int value = -1; - - 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; - - memset(buffer, 0, sizeof(buffer)); - rv = onlp_i2c_block_read(psu_info[pid].busno, psu_info[pid].addr, PMBUS_MFR_MODEL, PMBUS_MFR_MODEL_LEN, buffer, ONLP_I2C_F_FORCE); - buffer[buffer[0] + 1] = 0x00; - if(rv >= 0){ - aim_strlcpy(info->model, (char *) (buffer+1), (buffer[0] + 1)); - } - else{ - strcpy(info->model, "Missing"); - } - - memset(buffer, 0, sizeof(buffer)); - rv = onlp_i2c_block_read(psu_info[pid].busno, psu_info[pid].addr, PMBUS_MFR_SERIAL, PMBUS_MFR_SERIAL_LEN, buffer, ONLP_I2C_F_FORCE); - buffer[buffer[0] + 1] = 0x00; - if(rv >= 0){ - aim_strlcpy(info->serial, (char *) (buffer+1), (buffer[0] + 1)); - } - else{ - strcpy(info->serial, "Missing"); - } - - 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/ly9-rangeley/onlp/builds/x86_64_quanta_ly9_rangeley/module/src/sfpi.c b/packages/platforms/quanta/x86-64/ly9-rangeley/onlp/builds/x86_64_quanta_ly9_rangeley/module/src/sfpi.c deleted file mode 100755 index c22748c18..000000000 --- a/packages/platforms/quanta/x86-64/ly9-rangeley/onlp/builds/x86_64_quanta_ly9_rangeley/module/src/sfpi.c +++ /dev/null @@ -1,187 +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. - * - * - ************************************************************ - * - * SFPI Interface for the Quanta LY9 - * - ***********************************************************/ -#include -#include -#include -#include -#include -#include "x86_64_quanta_ly9_rangeley_log.h" - -#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__[] = - { - { 49, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/0-003a/cpld-qsfp/port-1/module_present", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-21/i2c-32/32-0050/eeprom", NULL }, - { 50, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/0-003a/cpld-qsfp/port-2/module_present", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-21/i2c-33/33-0050/eeprom", NULL }, - { 51, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/0-003a/cpld-qsfp/port-3/module_present", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-21/i2c-34/34-0050/eeprom", NULL }, - { 52, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/0-003a/cpld-qsfp/port-4/module_present", NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-21/i2c-35/35-0050/eeprom", NULL }, - }; - -typedef struct qsfpmap_s { - int port; - int present_gpio; - const char* reset_gpio; - const char* eeprom; - const char* dom; -} qsfpmap_t; - -static qsfpmap_t qsfpmap__[] = - { - { 53, QUANTA_LY9_QSFP_QDB_GPIO_PRSNT_53_N, NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-23/i2c-48/48-0050/eeprom", NULL }, - { 54, QUANTA_LY9_QSFP_QDB_GPIO_PRSNT_54_N, NULL, "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-23/i2c-49/49-0050/eeprom", NULL }, - }; - -#define SFP_GET(_port) (sfpmap__ + _port - 49) -#define QSFP_GET(_port) (qsfpmap__ + _port - 53) - -int -onlp_sfpi_init(void) -{ - int value = -1, ret, i; - qsfpmap_t* qsfp; - - onlp_gpio_export(QUANTA_LY9_QSFP_EN_GPIO_P3V3_PW_EN, ONLP_GPIO_DIRECTION_IN); - ret = onlp_gpio_get(QUANTA_LY9_QSFP_EN_GPIO_P3V3_PW_EN, &value); - if(ret == ONLP_STATUS_OK && value != 0) { - onlp_gpio_export(QUANTA_LY9_QSFP_EN_GPIO_P3V3_PW_EN, ONLP_GPIO_DIRECTION_OUT); - ret = onlp_gpio_set(QUANTA_LY9_QSFP_EN_GPIO_P3V3_PW_EN, 0); - } - if(ret == ONLP_STATUS_OK) { - onlp_gpio_export(QUANTA_LY9_QSFP_QDB_GPIO_MOD_EN_N, ONLP_GPIO_DIRECTION_IN); - ret = onlp_gpio_get(QUANTA_LY9_QSFP_QDB_GPIO_MOD_EN_N, &value); - if(ret == ONLP_STATUS_OK && value != 0) { - onlp_gpio_export(QUANTA_LY9_QSFP_QDB_GPIO_MOD_EN_N, ONLP_GPIO_DIRECTION_OUT); - ret = onlp_gpio_set(QUANTA_LY9_QSFP_QDB_GPIO_MOD_EN_N, 0); - } - } - - for(i = 53; i < 55; i++) { - qsfp = QSFP_GET(i); - onlp_gpio_export(qsfp->present_gpio, ONLP_GPIO_DIRECTION_IN); - } - - return ret; -} - -int -onlp_sfpi_bitmap_get(onlp_sfp_bitmap_t* bmap) -{ - int p; - - for(p = 49; p < 55; p++) { - AIM_BITMAP_SET(bmap, p); - } - - return ONLP_STATUS_OK; -} - -int -onlp_sfpi_is_present(int port) -{ - - if(port > 52){ - 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{ - sfpmap_t* sfp = SFP_GET(port); - - return onlplib_sfp_is_present_file(sfp->present_cpld, /* Present */ "1\n", /* Absent */ "0\n"); - } -} - -int -onlp_sfpi_eeprom_read(int port, uint8_t data[256]) -{ - - if(port > 52){ - 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 > 52){ - 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); - } -} - diff --git a/packages/platforms/quanta/x86-64/ly9-rangeley/onlp/builds/x86_64_quanta_ly9_rangeley/module/src/sysi.c b/packages/platforms/quanta/x86-64/ly9-rangeley/onlp/builds/x86_64_quanta_ly9_rangeley/module/src/sysi.c deleted file mode 100755 index 60624a02a..000000000 --- a/packages/platforms/quanta/x86-64/ly9-rangeley/onlp/builds/x86_64_quanta_ly9_rangeley/module/src/sysi.c +++ /dev/null @@ -1,278 +0,0 @@ -/************************************************************ - * - * - ************************************************************ - * - * - * - ***********************************************************/ -#include -#include "x86_64_quanta_ly9_rangeley_int.h" -#include "x86_64_quanta_ly9_rangeley_log.h" -#include -#include -#include -#include -#include - -struct led_control_s led_control; - -#define QUANTA_HWMON_REG_TEMP_ALERT_MASK 0x1E -#define QUANTA_HWMON_REG_TEMP_ALERT_CTRL 0x1D -#define QUANTA_HWMON_REG_FAN_ALERT_MASK 0x31 -#define QUANTA_HWMON_REG_FAN_ALERT_CTRL 0x30 - -#define QUANTA_FAN_1_1 0x01 -#define QUANTA_FAN_1_2 0x10 -#define QUANTA_FAN_2_1 0x02 -#define QUANTA_FAN_2_2 0x20 -#define QUANTA_FAN_3_1 0x04 -#define QUANTA_FAN_3_2 0x40 - -const char* -onlp_sysi_platform_get(void) -{ - return "x86-64-quanta-ly9-rangeley-r0"; -} - -int -onlp_sysi_init(void) -{ - /* Initial value */ - led_control.PMCnt = 0; - led_control.fan_alert = 0xff; - led_control.psu1_present = 0; - led_control.psu2_present = 0; - led_control.psu1_power_good = 0; - led_control.psu2_power_good = 0; - - /* Set PSoc Fan-Alert Enable */ - onlp_i2c_writeb(0, 0x4e, QUANTA_HWMON_REG_TEMP_ALERT_MASK, 0x3f, ONLP_I2C_F_FORCE); - onlp_i2c_writeb(0, 0x4e, QUANTA_HWMON_REG_TEMP_ALERT_CTRL, 0x3, ONLP_I2C_F_FORCE); - onlp_i2c_writeb(0, 0x4e, QUANTA_HWMON_REG_FAN_ALERT_MASK, 0x77, ONLP_I2C_F_FORCE); - onlp_i2c_writeb(0, 0x4e, QUANTA_HWMON_REG_FAN_ALERT_CTRL, 0x1, ONLP_I2C_F_FORCE); - - /* Config GPIO */ - /* LED Output */ - onlp_gpio_export(QUANTA_LY9_CPU_BOARD_SYS_P1, ONLP_GPIO_DIRECTION_OUT); - onlp_gpio_export(QUANTA_LY9_CPU_BOARD_SYS_P2, ONLP_GPIO_DIRECTION_OUT); - onlp_gpio_export(QUANTA_LY9_PSU_GPIO_PSU1_GREEN_R, ONLP_GPIO_DIRECTION_OUT); - onlp_gpio_export(QUANTA_LY9_PSU_GPIO_PSU1_RED_R, ONLP_GPIO_DIRECTION_OUT); - onlp_gpio_export(QUANTA_LY9_PSU_GPIO_PSU2_GREEN_R, ONLP_GPIO_DIRECTION_OUT); - onlp_gpio_export(QUANTA_LY9_PSU_GPIO_PSU2_RED_R, ONLP_GPIO_DIRECTION_OUT); - onlp_gpio_export(QUANTA_LY9_FAN_FAIL_LED_1, ONLP_GPIO_DIRECTION_OUT); - onlp_gpio_export(QUANTA_LY9_FAN_FAIL_LED_2, ONLP_GPIO_DIRECTION_OUT); - onlp_gpio_export(QUANTA_LY9_FAN_FAIL_LED_3, ONLP_GPIO_DIRECTION_OUT); - onlp_gpio_export(QUANTA_LY9_PSU_GPIO_FAN_GREEN_R, ONLP_GPIO_DIRECTION_OUT); - onlp_gpio_export(QUANTA_LY9_PSU_GPIO_FAN_RED_R, ONLP_GPIO_DIRECTION_OUT); - /* PSU Input */ - onlp_gpio_export(QUANTA_LY9_PSU_GPIO_PSU1_PRSNT_N, ONLP_GPIO_DIRECTION_IN); - onlp_gpio_export(QUANTA_LY9_PSU_GPIO_PSU1_PWRGD, ONLP_GPIO_DIRECTION_IN); - onlp_gpio_export(QUANTA_LY9_PSU_GPIO_PSU2_PRSNT_N, ONLP_GPIO_DIRECTION_IN); - onlp_gpio_export(QUANTA_LY9_PSU_GPIO_PSU2_PWRGD, ONLP_GPIO_DIRECTION_IN); - /* FAN Input */ - 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); - 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-27/27-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-ly9-rangeley-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)); - - - /* - * 6 Chassis Thermal Sensors - */ - *e++ = THERMAL_OID_THERMAL1; - *e++ = THERMAL_OID_THERMAL2; - *e++ = THERMAL_OID_THERMAL3; - *e++ = THERMAL_OID_THERMAL4; - *e++ = THERMAL_OID_THERMAL5; - *e++ = THERMAL_OID_THERMAL6; - - /* - * 6 Fans - */ - *e++ = FAN_OID_FAN1; - *e++ = FAN_OID_FAN2; - *e++ = FAN_OID_FAN3; - *e++ = FAN_OID_FAN5; - *e++ = FAN_OID_FAN6; - *e++ = FAN_OID_FAN7; - - /* - * 2 PSUs - */ - *e++ = PSU_OID_PSU1; - *e++ = PSU_OID_PSU2; - - /* - * 7 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; - - 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_LY9_PSU_GPIO_PSU1_PRSNT_N, &value); - if(rv < 0) { - AIM_LOG_ERROR("GPIO %d read Error!", QUANTA_LY9_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_LY9_PSU_GPIO_PSU1_PWRGD, &value); - if(rv < 0) { - AIM_LOG_ERROR("GPIO %d read Error!", QUANTA_LY9_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_LY9_PSU_GPIO_PSU2_PRSNT_N, &value); - if(rv < 0) { - AIM_LOG_ERROR("GPIO %d read Error!", QUANTA_LY9_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_LY9_PSU_GPIO_PSU2_PWRGD, &value); - if(rv < 0) { - AIM_LOG_ERROR("GPIO %d read Error!", QUANTA_LY9_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; - - tmp = led_control.fan_alert; - led_control.fan_alert = onlp_i2c_readb(0, 0x4e, 0x32, ONLP_I2C_F_FORCE); - if(tmp != led_control.fan_alert) - 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.fan_alert & QUANTA_FAN_1_1) && !(led_control.fan_alert & QUANTA_FAN_1_2)) { - onlp_ledi_mode_set(LED_ID_FAN_FAIL_1, ONLP_LED_MODE_OFF); - } - else{ - onlp_ledi_mode_set(LED_ID_FAN_FAIL_1, ONLP_LED_MODE_RED); - } - - if(!(led_control.fan_alert & QUANTA_FAN_2_1) && !(led_control.fan_alert & QUANTA_FAN_2_2)) { - onlp_ledi_mode_set(LED_ID_FAN_FAIL_2, ONLP_LED_MODE_OFF); - } - else{ - onlp_ledi_mode_set(LED_ID_FAN_FAIL_2, ONLP_LED_MODE_RED); - } - - if(!(led_control.fan_alert & QUANTA_FAN_3_1) && !(led_control.fan_alert & QUANTA_FAN_3_2)) { - onlp_ledi_mode_set(LED_ID_FAN_FAIL_3, ONLP_LED_MODE_OFF); - } - else{ - onlp_ledi_mode_set(LED_ID_FAN_FAIL_3, ONLP_LED_MODE_RED); - } - - if(!led_control.fan_alert){ - 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; -} \ No newline at end of file diff --git a/packages/platforms/quanta/x86-64/ly9-rangeley/onlp/builds/x86_64_quanta_ly9_rangeley/module/src/thermali.c b/packages/platforms/quanta/x86-64/ly9-rangeley/onlp/builds/x86_64_quanta_ly9_rangeley/module/src/thermali.c deleted file mode 100755 index 3a7012966..000000000 --- a/packages/platforms/quanta/x86-64/ly9-rangeley/onlp/builds/x86_64_quanta_ly9_rangeley/module/src/thermali.c +++ /dev/null @@ -1,145 +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 "x86_64_quanta_ly9_rangeley_int.h" -#include "x86_64_quanta_ly9_rangeley_log.h" - -int -onlp_thermali_init(void) -{ - return ONLP_STATUS_OK; -} - -static int -sys_thermal_info_get__(onlp_thermal_info_t* info, int id) -{ - int rv; - - rv = onlp_file_read_int(&info->mcelsius, - SYS_HWMON_PREFIX "/temp%d_input", id); - - if(rv == ONLP_STATUS_E_INTERNAL) { - return rv; - } - - if(rv == ONLP_STATUS_E_MISSING) { - info->status &= ~1; - return 0; - } - - return ONLP_STATUS_OK; -} - -static int -psu_thermal_info_get__(onlp_thermal_info_t* info, int pid, int id) -{ - /* THERMAL6 -> PSU1 */ - /* THERMAL7 -> PSU2 */ - extern struct psu_info_s psu_info[]; - char* dir = psu_info[pid].path; - info->status |= 1; - return onlp_file_read_int(&info->mcelsius, "%s/temp%d_input", dir, id); -} - -int -onlp_thermali_info_get(onlp_oid_t id, onlp_thermal_info_t* rv) -{ - int tid = ONLP_OID_ID_GET(id); - - static onlp_thermal_info_t info[] = { - { }, /* Not used */ - { { ONLP_THERMAL_ID_CREATE(1), "Chassis Thermal 1", 0}, ONLP_THERMAL_STATUS_PRESENT, - ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS - }, - { { ONLP_THERMAL_ID_CREATE(2), "Chassis Thermal 2", 0}, ONLP_THERMAL_STATUS_PRESENT, - ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS - }, - { { ONLP_THERMAL_ID_CREATE(3), "Chassis Thermal 3", 0}, ONLP_THERMAL_STATUS_PRESENT, - ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS - }, - { { ONLP_THERMAL_ID_CREATE(4), "Chassis Thermal 4", 0}, ONLP_THERMAL_STATUS_PRESENT, - ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS - }, - { { ONLP_THERMAL_ID_CREATE(5), "Chassis Thermal 5", 0}, ONLP_THERMAL_STATUS_PRESENT, - ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS - }, - { { ONLP_THERMAL_ID_CREATE(6), "Chassis Thermal 6", 0}, ONLP_THERMAL_STATUS_PRESENT, - ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS - }, - { { ONLP_THERMAL_ID_CREATE(7), "Chassis Thermal 7", 0}, ONLP_THERMAL_STATUS_PRESENT, - ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS - }, - { { ONLP_THERMAL_ID_CREATE(8), "Chassis Thermal 8", 0}, ONLP_THERMAL_STATUS_PRESENT, - ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS - }, - { { ONLP_THERMAL_ID_CREATE(9), "Chassis Thermal 9", 0}, ONLP_THERMAL_STATUS_PRESENT, - ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS - }, - { { ONLP_THERMAL_ID_CREATE(10), "Chassis Thermal 10", 0}, ONLP_THERMAL_STATUS_PRESENT, - ONLP_THERMAL_CAPS_ALL, 0, ONLP_THERMAL_THRESHOLD_INIT_DEFAULTS - }, - - { { ONLP_THERMAL_ID_CREATE(11), "PSU-1 Thermal 1", 0 } }, - { { ONLP_THERMAL_ID_CREATE(12), "PSU-1 Thermal 2", 0 } }, - { { ONLP_THERMAL_ID_CREATE(13), "PSU-1 Thermal 3", 0 } }, - - { { ONLP_THERMAL_ID_CREATE(14), "PSU-2 Thermal 1", 0 } }, - { { ONLP_THERMAL_ID_CREATE(15), "PSU-2 Thermal 2", 0 } }, - { { ONLP_THERMAL_ID_CREATE(16), "PSU-2 Thermal 3", 0 } }, - }; - - *rv = info[tid]; - rv->caps |= ONLP_THERMAL_CAPS_GET_TEMPERATURE; - - switch(tid) - { - case THERMAL_ID_THERMAL1: - case THERMAL_ID_THERMAL2: - case THERMAL_ID_THERMAL3: - case THERMAL_ID_THERMAL4: - case THERMAL_ID_THERMAL5: - case THERMAL_ID_THERMAL6: - case THERMAL_ID_THERMAL7: - case THERMAL_ID_THERMAL8: - case THERMAL_ID_THERMAL9: - case THERMAL_ID_THERMAL10: - return sys_thermal_info_get__(rv, tid); - - case THERMAL_ID_THERMAL11: - case THERMAL_ID_THERMAL12: - case THERMAL_ID_THERMAL13: - return psu_thermal_info_get__(rv, 1, tid - THERMAL_ID_THERMAL11 + 1); - - - case THERMAL_ID_THERMAL14: - case THERMAL_ID_THERMAL15: - case THERMAL_ID_THERMAL16: - return psu_thermal_info_get__(rv, 2, tid - THERMAL_ID_THERMAL14 + 1); - - } - - return ONLP_STATUS_E_INVALID; -} diff --git a/packages/platforms/quanta/x86-64/ly9-rangeley/onlp/builds/x86_64_quanta_ly9_rangeley/module/src/x86_64_quanta_ly9_rangeley_config.c b/packages/platforms/quanta/x86-64/ly9-rangeley/onlp/builds/x86_64_quanta_ly9_rangeley/module/src/x86_64_quanta_ly9_rangeley_config.c deleted file mode 100755 index 2d4829e8c..000000000 --- a/packages/platforms/quanta/x86-64/ly9-rangeley/onlp/builds/x86_64_quanta_ly9_rangeley/module/src/x86_64_quanta_ly9_rangeley_config.c +++ /dev/null @@ -1,95 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#include - -/* */ -#define __x86_64_quanta_ly9_rangeley_config_STRINGIFY_NAME(_x) #_x -#define __x86_64_quanta_ly9_rangeley_config_STRINGIFY_VALUE(_x) __x86_64_quanta_ly9_rangeley_config_STRINGIFY_NAME(_x) -x86_64_quanta_ly9_rangeley_config_settings_t x86_64_quanta_ly9_rangeley_config_settings[] = -{ -#ifdef X86_64_QUANTA_LY9_RANGELEY_CONFIG_INCLUDE_LOGGING - { __x86_64_quanta_ly9_rangeley_config_STRINGIFY_NAME(X86_64_QUANTA_LY9_RANGELEY_CONFIG_INCLUDE_LOGGING), __x86_64_quanta_ly9_rangeley_config_STRINGIFY_VALUE(X86_64_QUANTA_LY9_RANGELEY_CONFIG_INCLUDE_LOGGING) }, -#else -{ X86_64_QUANTA_LY9_RANGELEY_CONFIG_INCLUDE_LOGGING(__x86_64_quanta_ly9_rangeley_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_QUANTA_LY9_RANGELEY_CONFIG_LOG_OPTIONS_DEFAULT - { __x86_64_quanta_ly9_rangeley_config_STRINGIFY_NAME(X86_64_QUANTA_LY9_RANGELEY_CONFIG_LOG_OPTIONS_DEFAULT), __x86_64_quanta_ly9_rangeley_config_STRINGIFY_VALUE(X86_64_QUANTA_LY9_RANGELEY_CONFIG_LOG_OPTIONS_DEFAULT) }, -#else -{ X86_64_QUANTA_LY9_RANGELEY_CONFIG_LOG_OPTIONS_DEFAULT(__x86_64_quanta_ly9_rangeley_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_QUANTA_LY9_RANGELEY_CONFIG_LOG_BITS_DEFAULT - { __x86_64_quanta_ly9_rangeley_config_STRINGIFY_NAME(X86_64_QUANTA_LY9_RANGELEY_CONFIG_LOG_BITS_DEFAULT), __x86_64_quanta_ly9_rangeley_config_STRINGIFY_VALUE(X86_64_QUANTA_LY9_RANGELEY_CONFIG_LOG_BITS_DEFAULT) }, -#else -{ X86_64_QUANTA_LY9_RANGELEY_CONFIG_LOG_BITS_DEFAULT(__x86_64_quanta_ly9_rangeley_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_QUANTA_LY9_RANGELEY_CONFIG_LOG_CUSTOM_BITS_DEFAULT - { __x86_64_quanta_ly9_rangeley_config_STRINGIFY_NAME(X86_64_QUANTA_LY9_RANGELEY_CONFIG_LOG_CUSTOM_BITS_DEFAULT), __x86_64_quanta_ly9_rangeley_config_STRINGIFY_VALUE(X86_64_QUANTA_LY9_RANGELEY_CONFIG_LOG_CUSTOM_BITS_DEFAULT) }, -#else -{ X86_64_QUANTA_LY9_RANGELEY_CONFIG_LOG_CUSTOM_BITS_DEFAULT(__x86_64_quanta_ly9_rangeley_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_QUANTA_LY9_RANGELEY_CONFIG_PORTING_STDLIB - { __x86_64_quanta_ly9_rangeley_config_STRINGIFY_NAME(X86_64_QUANTA_LY9_RANGELEY_CONFIG_PORTING_STDLIB), __x86_64_quanta_ly9_rangeley_config_STRINGIFY_VALUE(X86_64_QUANTA_LY9_RANGELEY_CONFIG_PORTING_STDLIB) }, -#else -{ X86_64_QUANTA_LY9_RANGELEY_CONFIG_PORTING_STDLIB(__x86_64_quanta_ly9_rangeley_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_QUANTA_LY9_RANGELEY_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS - { __x86_64_quanta_ly9_rangeley_config_STRINGIFY_NAME(X86_64_QUANTA_LY9_RANGELEY_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS), __x86_64_quanta_ly9_rangeley_config_STRINGIFY_VALUE(X86_64_QUANTA_LY9_RANGELEY_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS) }, -#else -{ X86_64_QUANTA_LY9_RANGELEY_CONFIG_PORTING_INCLUDE_STDLIB_HEADERS(__x86_64_quanta_ly9_rangeley_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_QUANTA_LY9_RANGELEY_CONFIG_INCLUDE_UCLI - { __x86_64_quanta_ly9_rangeley_config_STRINGIFY_NAME(X86_64_QUANTA_LY9_RANGELEY_CONFIG_INCLUDE_UCLI), __x86_64_quanta_ly9_rangeley_config_STRINGIFY_VALUE(X86_64_QUANTA_LY9_RANGELEY_CONFIG_INCLUDE_UCLI) }, -#else -{ X86_64_QUANTA_LY9_RANGELEY_CONFIG_INCLUDE_UCLI(__x86_64_quanta_ly9_rangeley_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_QUANTA_LY9_RANGELEY_CONFIG_SYSFAN_RPM_FAILURE_THRESHOLD - { __x86_64_quanta_ly9_rangeley_config_STRINGIFY_NAME(X86_64_QUANTA_LY9_RANGELEY_CONFIG_SYSFAN_RPM_FAILURE_THRESHOLD), __x86_64_quanta_ly9_rangeley_config_STRINGIFY_VALUE(X86_64_QUANTA_LY9_RANGELEY_CONFIG_SYSFAN_RPM_FAILURE_THRESHOLD) }, -#else -{ X86_64_QUANTA_LY9_RANGELEY_CONFIG_SYSFAN_RPM_FAILURE_THRESHOLD(__x86_64_quanta_ly9_rangeley_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_QUANTA_LY9_RANGELEY_CONFIG_SYSFAN_F2B_RPM_MAX - { __x86_64_quanta_ly9_rangeley_config_STRINGIFY_NAME(X86_64_QUANTA_LY9_RANGELEY_CONFIG_SYSFAN_F2B_RPM_MAX), __x86_64_quanta_ly9_rangeley_config_STRINGIFY_VALUE(X86_64_QUANTA_LY9_RANGELEY_CONFIG_SYSFAN_F2B_RPM_MAX) }, -#else -{ X86_64_QUANTA_LY9_RANGELEY_CONFIG_SYSFAN_F2B_RPM_MAX(__x86_64_quanta_ly9_rangeley_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_QUANTA_LY9_RANGELEY_CONFIG_SYSFAN_B2F_RPM_MAX - { __x86_64_quanta_ly9_rangeley_config_STRINGIFY_NAME(X86_64_QUANTA_LY9_RANGELEY_CONFIG_SYSFAN_B2F_RPM_MAX), __x86_64_quanta_ly9_rangeley_config_STRINGIFY_VALUE(X86_64_QUANTA_LY9_RANGELEY_CONFIG_SYSFAN_B2F_RPM_MAX) }, -#else -{ X86_64_QUANTA_LY9_RANGELEY_CONFIG_SYSFAN_B2F_RPM_MAX(__x86_64_quanta_ly9_rangeley_config_STRINGIFY_NAME), "__undefined__" }, -#endif -#ifdef X86_64_QUANTA_LY9_RANGELEY_CONFIG_PHY_RESET_DELAY_MS - { __x86_64_quanta_ly9_rangeley_config_STRINGIFY_NAME(X86_64_QUANTA_LY9_RANGELEY_CONFIG_PHY_RESET_DELAY_MS), __x86_64_quanta_ly9_rangeley_config_STRINGIFY_VALUE(X86_64_QUANTA_LY9_RANGELEY_CONFIG_PHY_RESET_DELAY_MS) }, -#else -{ X86_64_QUANTA_LY9_RANGELEY_CONFIG_PHY_RESET_DELAY_MS(__x86_64_quanta_ly9_rangeley_config_STRINGIFY_NAME), "__undefined__" }, -#endif - { NULL, NULL } -}; -#undef __x86_64_quanta_ly9_rangeley_config_STRINGIFY_VALUE -#undef __x86_64_quanta_ly9_rangeley_config_STRINGIFY_NAME - -const char* -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)) { - return x86_64_quanta_ly9_rangeley_config_settings[i].value; - } - } - return NULL; -} - -int -x86_64_quanta_ly9_rangeley_config_show(struct aim_pvs_s* pvs) -{ - int i; - for(i = 0; x86_64_quanta_ly9_rangeley_config_settings[i].name; i++) { - aim_printf(pvs, "%s = %s\n", x86_64_quanta_ly9_rangeley_config_settings[i].name, x86_64_quanta_ly9_rangeley_config_settings[i].value); - } - return i; -} - -/* */ diff --git a/packages/platforms/quanta/x86-64/ly9-rangeley/onlp/builds/x86_64_quanta_ly9_rangeley/module/src/x86_64_quanta_ly9_rangeley_enums.c b/packages/platforms/quanta/x86-64/ly9-rangeley/onlp/builds/x86_64_quanta_ly9_rangeley/module/src/x86_64_quanta_ly9_rangeley_enums.c deleted file mode 100755 index a9eaec507..000000000 --- a/packages/platforms/quanta/x86-64/ly9-rangeley/onlp/builds/x86_64_quanta_ly9_rangeley/module/src/x86_64_quanta_ly9_rangeley_enums.c +++ /dev/null @@ -1,10 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#include - -/* <--auto.start.enum(ALL).source> */ -/* */ - diff --git a/packages/platforms/quanta/x86-64/ly9-rangeley/onlp/builds/x86_64_quanta_ly9_rangeley/module/src/x86_64_quanta_ly9_rangeley_int.h b/packages/platforms/quanta/x86-64/ly9-rangeley/onlp/builds/x86_64_quanta_ly9_rangeley/module/src/x86_64_quanta_ly9_rangeley_int.h deleted file mode 100755 index f6372bbe3..000000000 --- a/packages/platforms/quanta/x86-64/ly9-rangeley/onlp/builds/x86_64_quanta_ly9_rangeley/module/src/x86_64_quanta_ly9_rangeley_int.h +++ /dev/null @@ -1,306 +0,0 @@ -/**************************************************************************//** - * - * x86_64_quanta_ly9_rangeley Internal Header - * - *****************************************************************************/ -#ifndef __X86_64_QUANTA_LY9_RANGELEY_INT_H__ -#define __X86_64_QUANTA_LY9_RANGELEY_INT_H__ - -#include -#include - -/* */ -/** 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[]; - -/** 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 { - 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[]; - -/** 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 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_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_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 fan_alert; - int psu1_present; - int psu2_present; - int psu1_power_good; - int psu2_power_good; -}; - -#define SYS_HWMON_PREFIX "/sys/devices/pci0000:00/0000:00:1f.3/i2c-0/0-004e" - -#endif /* __X86_64_QUANTA_LY9_RANGELEY_INT_H__ */ diff --git a/packages/platforms/quanta/x86-64/ly9-rangeley/onlp/builds/x86_64_quanta_ly9_rangeley/module/src/x86_64_quanta_ly9_rangeley_log.c b/packages/platforms/quanta/x86-64/ly9-rangeley/onlp/builds/x86_64_quanta_ly9_rangeley/module/src/x86_64_quanta_ly9_rangeley_log.c deleted file mode 100755 index e1dcf3d3c..000000000 --- a/packages/platforms/quanta/x86-64/ly9-rangeley/onlp/builds/x86_64_quanta_ly9_rangeley/module/src/x86_64_quanta_ly9_rangeley_log.c +++ /dev/null @@ -1,18 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#include - -#include "x86_64_quanta_ly9_rangeley_log.h" -/* - * x86_64_quanta_ly9_rangeley log struct. - */ -AIM_LOG_STRUCT_DEFINE( - X86_64_QUANTA_LY9_RANGELEY_CONFIG_LOG_OPTIONS_DEFAULT, - X86_64_QUANTA_LY9_RANGELEY_CONFIG_LOG_BITS_DEFAULT, - NULL, /* Custom log map */ - X86_64_QUANTA_LY9_RANGELEY_CONFIG_LOG_CUSTOM_BITS_DEFAULT - ); - diff --git a/packages/platforms/quanta/x86-64/ly9-rangeley/onlp/builds/x86_64_quanta_ly9_rangeley/module/src/x86_64_quanta_ly9_rangeley_log.h b/packages/platforms/quanta/x86-64/ly9-rangeley/onlp/builds/x86_64_quanta_ly9_rangeley/module/src/x86_64_quanta_ly9_rangeley_log.h deleted file mode 100755 index 8fbe5684d..000000000 --- a/packages/platforms/quanta/x86-64/ly9-rangeley/onlp/builds/x86_64_quanta_ly9_rangeley/module/src/x86_64_quanta_ly9_rangeley_log.h +++ /dev/null @@ -1,12 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#ifndef __X86_64_QUANTA_LY9_RANGELEY_LOG_H__ -#define __X86_64_QUANTA_LY9_RANGELEY_LOG_H__ - -#define AIM_LOG_MODULE_NAME x86_64_quanta_ly9_rangeley -#include - -#endif /* __X86_64_QUANTA_LY9_RANGELEY_LOG_H__ */ diff --git a/packages/platforms/quanta/x86-64/ly9-rangeley/onlp/builds/x86_64_quanta_ly9_rangeley/module/src/x86_64_quanta_ly9_rangeley_module.c b/packages/platforms/quanta/x86-64/ly9-rangeley/onlp/builds/x86_64_quanta_ly9_rangeley/module/src/x86_64_quanta_ly9_rangeley_module.c deleted file mode 100755 index 39839f4e3..000000000 --- a/packages/platforms/quanta/x86-64/ly9-rangeley/onlp/builds/x86_64_quanta_ly9_rangeley/module/src/x86_64_quanta_ly9_rangeley_module.c +++ /dev/null @@ -1,24 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#include - -#include "x86_64_quanta_ly9_rangeley_log.h" - -static int -datatypes_init__(void) -{ -#define X86_64_QUANTA_LY9_RANGELEY_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_ly9_rangeley_module_init__(void) -{ - AIM_LOG_STRUCT_REGISTER(); - datatypes_init__(); -} - -int __onlp_platform_version__ = 1; diff --git a/packages/platforms/quanta/x86-64/ly9-rangeley/onlp/builds/x86_64_quanta_ly9_rangeley/module/src/x86_64_quanta_ly9_rangeley_ucli.c b/packages/platforms/quanta/x86-64/ly9-rangeley/onlp/builds/x86_64_quanta_ly9_rangeley/module/src/x86_64_quanta_ly9_rangeley_ucli.c deleted file mode 100755 index c308a0554..000000000 --- a/packages/platforms/quanta/x86-64/ly9-rangeley/onlp/builds/x86_64_quanta_ly9_rangeley/module/src/x86_64_quanta_ly9_rangeley_ucli.c +++ /dev/null @@ -1,50 +0,0 @@ -/**************************************************************************//** - * - * - * - *****************************************************************************/ -#include - -#if X86_64_QUANTA_LY9_RANGELEY_CONFIG_INCLUDE_UCLI == 1 - -#include -#include -#include - -static ucli_status_t -x86_64_quanta_ly9_rangeley_ucli_ucli__config__(ucli_context_t* uc) -{ - UCLI_HANDLER_MACRO_MODULE_CONFIG(x86_64_quanta_ly9_rangeley) -} - -/* */ -/* */ - -static ucli_module_t -x86_64_quanta_ly9_rangeley_ucli_module__ = - { - "x86_64_quanta_ly9_rangeley_ucli", - NULL, - x86_64_quanta_ly9_rangeley_ucli_ucli_handlers__, - NULL, - NULL, - }; - -ucli_node_t* -x86_64_quanta_ly9_rangeley_ucli_node_create(void) -{ - ucli_node_t* n; - ucli_module_init(&x86_64_quanta_ly9_rangeley_ucli_module__); - n = ucli_node_create("x86_64_quanta_ly9_rangeley", NULL, &x86_64_quanta_ly9_rangeley_ucli_module__); - ucli_node_subnode_add(n, ucli_module_log_node_create("x86_64_quanta_ly9_rangeley")); - return n; -} - -#else -void* -x86_64_quanta_ly9_rangeley_ucli_node_create(void) -{ - return NULL; -} -#endif - diff --git a/packages/platforms/quanta/x86-64/ly9-rangeley/platform-config/Makefile b/packages/platforms/quanta/x86-64/ly9-rangeley/platform-config/Makefile deleted file mode 100755 index 003238cf6..000000000 --- a/packages/platforms/quanta/x86-64/ly9-rangeley/platform-config/Makefile +++ /dev/null @@ -1 +0,0 @@ -include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/quanta/x86-64/ly9-rangeley/platform-config/r0/Makefile b/packages/platforms/quanta/x86-64/ly9-rangeley/platform-config/r0/Makefile deleted file mode 100755 index 003238cf6..000000000 --- a/packages/platforms/quanta/x86-64/ly9-rangeley/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/quanta/x86-64/ly9-rangeley/platform-config/r0/PKG.yml b/packages/platforms/quanta/x86-64/ly9-rangeley/platform-config/r0/PKG.yml deleted file mode 100755 index c546783fa..000000000 --- a/packages/platforms/quanta/x86-64/ly9-rangeley/platform-config/r0/PKG.yml +++ /dev/null @@ -1 +0,0 @@ -!include $ONL_TEMPLATES/platform-config-platform.yml ARCH=amd64 VENDOR=quanta BASENAME=x86-64-quanta-ly9-rangeley REVISION=r0 diff --git a/packages/platforms/quanta/x86-64/ly9-rangeley/platform-config/r0/src/lib/x86-64-quanta-ly9-rangeley-r0.yml b/packages/platforms/quanta/x86-64/ly9-rangeley/platform-config/r0/src/lib/x86-64-quanta-ly9-rangeley-r0.yml deleted file mode 100755 index 91e301f4d..000000000 --- a/packages/platforms/quanta/x86-64/ly9-rangeley/platform-config/r0/src/lib/x86-64-quanta-ly9-rangeley-r0.yml +++ /dev/null @@ -1,31 +0,0 @@ ---- - -###################################################################### -# -# platform-config for LY9 -# -###################################################################### - -x86-64-quanta-ly9-rangeley-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/ly9-rangeley/platform-config/r0/src/python/x86_64_quanta_ly9_rangeley_r0/__init__.py b/packages/platforms/quanta/x86-64/ly9-rangeley/platform-config/r0/src/python/x86_64_quanta_ly9_rangeley_r0/__init__.py deleted file mode 100755 index b8b495117..000000000 --- a/packages/platforms/quanta/x86-64/ly9-rangeley/platform-config/r0/src/python/x86_64_quanta_ly9_rangeley_r0/__init__.py +++ /dev/null @@ -1,28 +0,0 @@ -from onl.platform.base import * -from onl.platform.quanta import * - -class OnlPlatform_x86_64_quanta_ly9_rangeley_r0(OnlPlatformQuanta, - OnlPlatformPortConfig_48x10_6x40): - PLATFORM='x86-64-quanta-ly9-rangeley-r0' - MODEL="LY9" - """ 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.2900" - - def baseconfig(self): - self.insmod("emerson700") - self.insmod("quanta_hwmon_ly_series") - self.insmod("qci_cpld") - self.insmod("quanta_platform_ly9") - - # make ds1339 as default rtc - os.system("ln -snf /dev/rtc1 /dev/rtc") - os.system("hwclock --hctosys") - - return True diff --git a/packages/platforms/quanta/x86-64/modules/Makefile b/packages/platforms/quanta/x86-64/modules/Makefile deleted file mode 100644 index 003238cf6..000000000 --- a/packages/platforms/quanta/x86-64/modules/Makefile +++ /dev/null @@ -1 +0,0 @@ -include $(ONL)/make/pkg.mk \ No newline at end of file diff --git a/packages/platforms/quanta/x86-64/modules/PKG.yml b/packages/platforms/quanta/x86-64/modules/PKG.yml deleted file mode 100644 index fcb0bda99..000000000 --- a/packages/platforms/quanta/x86-64/modules/PKG.yml +++ /dev/null @@ -1 +0,0 @@ -!include $ONL_TEMPLATES/arch-vendor-modules.yml ARCH=amd64 VENDOR=quanta KERNELS="onl-kernel-3.16-lts-x86-64-all:amd64" diff --git a/packages/platforms/quanta/x86-64/modules/builds/.gitignore b/packages/platforms/quanta/x86-64/modules/builds/.gitignore deleted file mode 100644 index a65b41774..000000000 --- a/packages/platforms/quanta/x86-64/modules/builds/.gitignore +++ /dev/null @@ -1 +0,0 @@ -lib diff --git a/packages/platforms/quanta/x86-64/modules/builds/Makefile b/packages/platforms/quanta/x86-64/modules/builds/Makefile deleted file mode 100644 index 979fc3fe9..000000000 --- a/packages/platforms/quanta/x86-64/modules/builds/Makefile +++ /dev/null @@ -1,6 +0,0 @@ -KERNELS := onl-kernel-3.16-lts-x86-64-all:amd64 -KMODULES := $(wildcard *.c) -VENDOR := quanta -BASENAME := common -ARCH := x86_64 -include $(ONL)/make/kmodule.mk diff --git a/packages/platforms/quanta/x86-64/modules/builds/qci_cpld.c b/packages/platforms/quanta/x86-64/modules/builds/qci_cpld.c deleted file mode 100755 index 678b1dc14..000000000 --- a/packages/platforms/quanta/x86-64/modules/builds/qci_cpld.c +++ /dev/null @@ -1,603 +0,0 @@ -/* - * A CPLD driver for monitor QSFP28 module I/O - * - * The CPLD is customize by Quanta for controlling QSFP28 module signals, - * they are RESET , INTERREPT , Module_Present, LPMODE - * Each CPLD control 16 modules, each module use 4 bits in register. - * - * Copyright (C) 2015 Quanta Inc. - * - * Author: Luffy Cheng - * - * 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 - -static DEFINE_IDA(cpld_ida); - -enum platform_type { - SFP = 0, - QSFP, - QSFP28, - NONE -}; - -static struct class *cpld_class = NULL; - -struct sfp_data { - struct i2c_client *cpld_client; - char name[8]; - char type[8]; - u8 port_id; - u8 cpld_port; -}; - -struct cpld_data { - struct mutex lock; - struct device *port_dev[16]; - struct sfp_data *port_data[16]; -}; - -static int cpld_probe(struct i2c_client *client, - const struct i2c_device_id *id); -static int cpld_remove(struct i2c_client *client); - -static const struct i2c_device_id cpld_id[] = { - { "CPLD-SFP", SFP }, - { "CPLD-QSFP", QSFP }, - { "CPLD-QSFP28", QSFP28 }, - { } -}; -MODULE_DEVICE_TABLE(i2c, cpld_id); - -static struct i2c_driver cpld_driver = { - .class = I2C_CLASS_HWMON, - .driver = { - .name = "qci_cpld", - }, - .probe = cpld_probe, - .remove = cpld_remove, - .id_table = cpld_id, -// .address_list = normal_i2c, -}; - -#define CPLD_ID_PREFIX "port-" -#define CPLD_ID_FORMAT CPLD_ID_PREFIX "%d" - -#define RESET_MASK 0x08 -#define INTERRUPT_MASK 0x04 -#define MODULE_PRESENT_MASK 0x02 -#define LPMODE_MASK 0x01 -//#define I2C_MONITOR_MASK 0x01 - -static inline u8 get_group_cmd(u8 group) -{ - //FIXME: if group cmd change - return (group + 1); -} - -static inline u8 port_remapping(u8 phy_port) -{ - /* FIXME: implement by hardware design */ - /* The CPLD register port mapping is weird : - * MSB -------- LSB (word data) - * P3 P4 P1 P2 (per port 4 bits) - * For easy coding bit shift, we treat it as hw port swap - */ - return (phy_port % 2) ? (phy_port - 1) : (phy_port + 1); -} - -static ssize_t get_reset(struct device *dev, - struct device_attribute *devattr, - char *buf) -{ - struct sfp_data *data = dev_get_drvdata(dev); - struct i2c_client *client = data->cpld_client; - u8 group = (u8)(data->cpld_port / 4); - u8 group_port = data->cpld_port % 4; - s32 value; - - dev_dbg(&client->dev, "port_id %d => cpld_port %d, group %d(%d)\n", data->port_id, - data->cpld_port + 1, group + 1, group_port + 1); - - value = i2c_smbus_read_word_data(client, get_group_cmd(group)); - if (value < 0) - return -ENODEV; - - dev_dbg(&client->dev, "read group%d value= %x\n", group + 1, value); - - value >>= (group_port * 4); - value &= RESET_MASK; - - return sprintf(buf, "%d\n", value ? 1 : 0); -} - -static ssize_t get_interrupt(struct device *dev, - struct device_attribute *devattr, - char *buf) -{ - struct sfp_data *data = dev_get_drvdata(dev); - struct i2c_client *client = data->cpld_client; - u8 group = (u8)(data->cpld_port / 4); - u8 group_port = data->cpld_port % 4; - s32 value; - - dev_dbg(&client->dev, "port_id %d => cpld_port %d, group %d(%d)\n", data->port_id, - data->cpld_port + 1, group + 1, group_port + 1); - - value = i2c_smbus_read_word_data(client, get_group_cmd(group)); - if (value < 0) - return -ENODEV; - - dev_dbg(&client->dev, "read group%d value= %x\n", group + 1, value); - - value >>= (group_port * 4); - value &= INTERRUPT_MASK; - - return sprintf(buf, "%d\n", value ? 1 : 0); -} - -static ssize_t get_module_present(struct device *dev, - struct device_attribute *devattr, - char *buf) -{ - struct sfp_data *data = dev_get_drvdata(dev); - struct i2c_client *client = data->cpld_client; - u8 group = (u8)(data->cpld_port / 4); - u8 group_port = data->cpld_port % 4; - s32 value; - - dev_dbg(&client->dev, "port_id %d => cpld_port %d, group %d(%d)\n", data->port_id, - data->cpld_port + 1, group + 1, group_port + 1); - - value = i2c_smbus_read_word_data(client, get_group_cmd(group)); - if (value < 0) - return -ENODEV; - - dev_dbg(&client->dev, "read group%d value= %x\n", group + 1, value); - - value >>= (group_port * 4); - value &= MODULE_PRESENT_MASK; - - //FIXME: if present is not low active - return sprintf(buf, "%d\n", value ? 0 : 1); -} - -static ssize_t get_lpmode(struct device *dev, - struct device_attribute *devattr, - char *buf) -{ - struct sfp_data *data = dev_get_drvdata(dev); - struct i2c_client *client = data->cpld_client; - u8 group = (u8)(data->cpld_port / 4); - u8 group_port = data->cpld_port % 4; - s32 value; - - dev_dbg(&client->dev, "port_id %d => cpld_port %d, group %d(%d)\n", data->port_id, - data->cpld_port + 1, group + 1, group_port + 1); - - value = i2c_smbus_read_word_data(client, get_group_cmd(group)); - if (value < 0) - return -ENODEV; - - dev_dbg(&client->dev, "read group%d value= %x\n", group + 1, value); - - value >>= (group_port * 4); - value &= LPMODE_MASK; - - return sprintf(buf, "%d\n", value ? 1 : 0); -} - -static ssize_t set_reset(struct device *dev, - struct device_attribute *devattr, - const char *buf, - size_t count) -{ - struct sfp_data *data = dev_get_drvdata(dev); - struct i2c_client *client = data->cpld_client; - u8 group = (u8)(data->cpld_port / 4); - u8 group_port = data->cpld_port % 4; - s32 value; - long disable; - - dev_dbg(&client->dev, "port_id %d => cpld_port %d, group %d(%d)\n", data->port_id, - data->cpld_port + 1, group + 1, group_port + 1); - - if (kstrtol(buf, 0, &disable)) - return -EINVAL; - - if ((disable != 1) && (disable != 0)) - return -EINVAL; - -// mutex_lock(&data->lock); - value = i2c_smbus_read_word_data(client, get_group_cmd(group)); - if (value < 0) - return -ENODEV; - - dev_dbg(&client->dev, "read group%d value= %x\n", group + 1, value); - - value &= ~(RESET_MASK << (group_port * 4)); - if (disable) - value |= (RESET_MASK << (group_port * 4)); - - dev_dbg(&client->dev, "write group%d value= %x\n", group + 1, value); - - i2c_smbus_write_word_data(client, get_group_cmd(group), (u16)value); -// mutex_unlock(&data->lock); - - return count; -} - -static ssize_t set_lpmode(struct device *dev, - struct device_attribute *devattr, - const char *buf, - size_t count) -{ - struct sfp_data *data = dev_get_drvdata(dev); - struct i2c_client *client = data->cpld_client; - u8 group = (u8)(data->cpld_port / 4); - u8 group_port = data->cpld_port % 4; - s32 value; - long disable; - - dev_dbg(&client->dev, "port_id %d => cpld_port %d, group %d(%d)\n", data->port_id, - data->cpld_port + 1, group + 1, group_port + 1); - - if (kstrtol(buf, 0, &disable)) - return -EINVAL; - - if ((disable != 1) && (disable != 0)) - return -EINVAL; - -// mutex_lock(&data->lock); - value = i2c_smbus_read_word_data(client, get_group_cmd(group)); - if (value < 0) - return -ENODEV; - - dev_dbg(&client->dev, "read group%d value= %x\n", group + 1, value); - - value &= ~(LPMODE_MASK << (group_port * 4)); - if (disable) - value |= (LPMODE_MASK << (group_port * 4)); - - dev_dbg(&client->dev, "write group%d value= %x\n", group + 1, value); - - i2c_smbus_write_word_data(client, get_group_cmd(group), (u16)value); -// mutex_unlock(&data->lock); - - return count; -} - -#if 0 -static ssize_t get_led_enable(struct device *dev, - struct device_attribute *devattr, - char *buf) -{ - struct sfp_data *data = dev_get_drvdata(dev); - struct i2c_client *client = data->cpld_client; - u8 group = 3; - u8 group_port = data->cpld_port; - s32 value; - - dev_dbg(&client->dev, "get_led_enable port_id %d => cpld_port %d, group %d(%d)\n", data->port_id, - data->cpld_port + 1, group, group_port + 1); - - value = i2c_smbus_read_word_data(client, group); - if (value < 0) - return -ENODEV; - - dev_dbg(&client->dev, "read group%d value= %x\n", group, value); - - value >>= (group_port); - value &= LED_ENABLE_MASK; - - return sprintf(buf, "%d\n", value ? 1 : 0); -} - -static ssize_t set_led_enable(struct device *dev, - struct device_attribute *devattr, - const char *buf, - size_t count) -{ - struct sfp_data *data = dev_get_drvdata(dev); - struct i2c_client *client = data->cpld_client; - u8 group = 3; - u8 group_port = data->cpld_port; - s32 value; - long disable; - - dev_dbg(&client->dev, "set_led_enable port_id %d => cpld_port %d, group %d(%d)\n", data->port_id, - data->cpld_port + 1, group, group_port + 1); - - if (kstrtol(buf, 0, &disable)) - return -EINVAL; - - if ((disable != 1) && (disable != 0)) - return -EINVAL; - -// mutex_lock(&data->lock); - value = i2c_smbus_read_word_data(client, group); - if (value < 0) - return -ENODEV; - - dev_dbg(&client->dev, "read group%d value= %x\n", group, value); - - value &= ~(LED_ENABLE_MASK << group_port); - if (disable) - value |= (LED_ENABLE_MASK << group_port); - - dev_dbg(&client->dev, "write group%d value= %x\n", group, value); - - i2c_smbus_write_word_data(client, group, (u16)value); -// mutex_unlock(&data->lock); - - return count; -} -#endif - -#if 0 -static ssize_t get_monitor_enable(struct device *dev, - struct device_attribute *devattr, - char *buf) -{ - struct i2c_monitor_data *data = dev_get_drvdata(dev); - struct i2c_client *client = data->cpld_client; - u8 group = 4; - s32 value; - - value = i2c_smbus_read_word_data(client, group); - if (value < 0) - return -ENODEV; - - dev_dbg(&client->dev, "read group%d value= %x\n", group, value); - - value &= I2C_MONITOR_MASK; - - return sprintf(buf, "%d\n", value ? 1 : 0); -} - -static ssize_t set_monitor_enable(struct device *dev, - struct device_attribute *devattr, - const char *buf, - size_t count) -{ - struct i2c_monitor_data *data = dev_get_drvdata(dev); - struct i2c_client *client = data->cpld_client; - u8 group = 4; - s32 value; - long disable; - - if (kstrtol(buf, 0, &disable)) - return -EINVAL; - - if ((disable != 1) && (disable != 0)) - return -EINVAL; - -// mutex_lock(&data->lock); - value = i2c_smbus_read_word_data(client, group); - if (value < 0) - return -ENODEV; - - dev_dbg(&client->dev, "read group%d value= %x\n", group, value); - - value &= ~(I2C_MONITOR_MASK); - if (disable) - value |= (I2C_MONITOR_MASK); - - dev_dbg(&client->dev, "write group%d value= %x\n", group, value); - - i2c_smbus_write_word_data(client, group, (u16)value); -// mutex_unlock(&data->lock); - - return count; -} -#endif - -static DEVICE_ATTR(reset, S_IWUSR | S_IRUGO, get_reset, set_reset); -static DEVICE_ATTR(lpmode, S_IWUSR | S_IRUGO, get_lpmode, set_lpmode); -static DEVICE_ATTR(module_present, S_IRUGO, get_module_present, NULL); -static DEVICE_ATTR(interrupt, S_IRUGO, get_interrupt, NULL); -//static DEVICE_ATTR(led_enable, S_IWUSR | S_IRUGO, get_led_enable, set_led_enable); -//static DEVICE_ATTR(monitor_enable, S_IWUSR | S_IRUGO, get_monitor_enable, set_monitor_enable); - -static const struct attribute *sfp_attrs[] = { - &dev_attr_reset.attr, - &dev_attr_lpmode.attr, - &dev_attr_module_present.attr, - &dev_attr_interrupt.attr, -// &dev_attr_led_enable.attr, - NULL, -}; - -static const struct attribute_group sfp_attr_group = { - .attrs = (struct attribute **) sfp_attrs, -}; - -#if 0 -static const struct attribute *i2c_monitor_attrs[] = { - &dev_attr_monitor_enable.attr, - NULL, -}; - -static const struct attribute_group i2c_monitor_attr_group = { - .attrs = (struct attribute **) i2c_monitor_attrs, -}; -#endif - -static int cpld_probe(struct i2c_client *client, - const struct i2c_device_id *id) -{ - struct cpld_data *data; - struct sfp_data *port_data; -// struct i2c_monitor_data *monitor_data; - struct device *port_dev; -// struct device *i2c_dev; - int port_nr, i=0, err, max_port_num; - char name[I2C_NAME_SIZE], type[I2C_NAME_SIZE]; - - printk("cpld cpld_probe\n"); - - while(id->name[i]) - { - name[i]=tolower(id->name[i]); - i++; - } - name[i]='\0'; - strncpy(type,name+5,strlen(name)-5); - type[strlen(name)-5]='\0'; - - if (!cpld_class) - { - cpld_class = class_create(THIS_MODULE, name); - if (IS_ERR(cpld_class)) { - pr_err("couldn't create sysfs class\n"); - return PTR_ERR(cpld_class); - } - } - - data = devm_kzalloc(&client->dev, sizeof(struct cpld_data), - GFP_KERNEL); - if (!data) - return -ENOMEM; - - if(!strcmp(client->name, "CPLD-QSFP28")){ - max_port_num = 16; - } - else{ - max_port_num = 4; - } - - /* register sfp port data to sysfs */ - for (i = 0; i < max_port_num; i++) - { - port_nr = ida_simple_get(&cpld_ida, 1, 99, GFP_KERNEL); - if (port_nr < 0) - return ERR_PTR(port_nr); - - port_data = kzalloc(sizeof(struct sfp_data), GFP_KERNEL); - - port_dev = device_create(cpld_class, &client->dev, MKDEV(0,0), port_data, CPLD_ID_FORMAT, port_nr); - if (IS_ERR(port_dev)) { - err = PTR_ERR(port_dev); - printk("err_status\n"); - } - - data->port_dev[i] = port_dev; - data->port_data[i] = port_data; - - strcpy(port_data->type, type); - - dev_info(&client->dev, "Register %s port-%d\n", port_data->type , port_nr); - - /* FIXME: implement Logical/Physical port remapping */ - //port_data->cpld_port = i; - port_data->cpld_port = port_remapping(i); - sprintf(port_data->name, "port-%d", port_nr); - port_data->port_id = port_nr; - dev_set_drvdata(port_dev, port_data); - port_dev->init_name = port_data->name; - port_data->cpld_client = client; - - err = sysfs_create_group(&port_dev->kobj, &sfp_attr_group); - // if (status) printk("err status\n"); - } -#if 0 - /* register i2c monitor to sysfs */ - monitor_data = kzalloc(sizeof(struct i2c_monitor_data), GFP_KERNEL); - - i2c_dev = device_create(cpld_class, &client->dev, MKDEV(0, 0), monitor_data, "i2c_monitor"); - if (IS_ERR(i2c_dev)) { - err = PTR_ERR(i2c_dev); - printk("i2c_dev err_status\n"); - } - - monitor_data->cpld_client = client; - err = sysfs_create_group(&i2c_dev->kobj, &i2c_monitor_attr_group); - if (err) - printk("err sysfs\n"); -#endif - i2c_set_clientdata(client, data); - mutex_init(&data->lock); - - dev_info(&client->dev, "%s device found\n", client->name); - - - return 0; - -//FIXME: implement error check -//exit_remove: -// sysfs_remove_group(&client->dev.kobj, &data->attrs); - return err; -} - -/* FIXME: for older kernel doesn't with idr_is_empty function, implement here */ -#if 1 -static int idr_has_entry(int id, void *p, void *data) -{ - return 1; -} - -static bool cpld_idr_is_empty(struct idr *idp) -{ - return !idr_for_each(idp, idr_has_entry, NULL); -} -#endif - -static int cpld_remove(struct i2c_client *client) -{ - struct cpld_data *data = i2c_get_clientdata(client); - int i, max_port_num; -// int id; - - if(!strcmp(client->name, "CPLD-QSFP28")){ - max_port_num = 16; - } - else{ - max_port_num = 4; - } - - for (i = (max_port_num - 1); i >= 0; i--) - { - dev_info(data->port_dev[i], "Remove %s port-%d\n", data->port_data[i]->type , data->port_data[i]->port_id); - device_unregister(data->port_dev[i]); - ida_simple_remove(&cpld_ida, data->port_data[i]->port_id); - kfree(data->port_data[i]); - } - - if (cpld_idr_is_empty(&cpld_ida.idr)) - class_destroy(cpld_class); - - return 0; -} - -module_i2c_driver(cpld_driver); - -MODULE_AUTHOR("Luffy Cheng "); -MODULE_DESCRIPTION("Quanta Switch QSFP28 CPLD driver"); -MODULE_LICENSE("GPL"); diff --git a/packages/platforms/quanta/x86-64/modules/builds/qci_cpld_led.c b/packages/platforms/quanta/x86-64/modules/builds/qci_cpld_led.c deleted file mode 100644 index 869966b3f..000000000 --- a/packages/platforms/quanta/x86-64/modules/builds/qci_cpld_led.c +++ /dev/null @@ -1,277 +0,0 @@ -/* - * A LED CPLD driver for Quanta Switch Platform - * - * The CPLD is customize by Quanta for decode led bit stream, - * This driver modify from Quanta CPLD I/O driver. - * - * Copyright (C) 2015 Quanta Inc. - * - * Author: Luffy Cheng - * Author: Roger Chang - * - * 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 - -static DEFINE_IDA(cpld_led_ida); - -enum platform_type { - IX7 = 0, - IX8, - NONE -}; - -static struct class *cpld_class = NULL; - -struct cpld_data { - struct i2c_client *cpld_client; - char name[8]; - u8 cpld_id; -}; - -struct cpld_led_data { - struct mutex lock; - struct device *port_dev; - struct cpld_data *cpld_data; -}; - -static int cpld_led_probe(struct i2c_client *client, - const struct i2c_device_id *id); -static int cpld_led_remove(struct i2c_client *client); - -static const struct i2c_device_id cpld_led_id[] = { - { "CPLDLED_IX7", IX7 }, - { "CPLDLED_IX8", IX8 }, - { } -}; -MODULE_DEVICE_TABLE(i2c, cpld_led_id); - -static struct i2c_driver cpld_led_driver = { - .class = I2C_CLASS_HWMON, - .driver = { - .name = "qci_cpld_led", - }, - .probe = cpld_led_probe, - .remove = cpld_led_remove, - .id_table = cpld_led_id, -// .address_list = normal_i2c, -}; - -#define CPLD_LED_ID_PREFIX "CPLDLED-" -#define CPLD_LED_ID_FORMAT CPLD_LED_ID_PREFIX "%d" - -#define CPLD_DECODER_OFFSET 0x4 -#define CPLD_DECODER_MASK 0x1 -#define CPLD_USERCODE_START_OFFSET 0x0 - -static ssize_t get_led_decode(struct device *dev, - struct device_attribute *devattr, - char *buf) -{ - struct cpld_data *data = dev_get_drvdata(dev); - struct i2c_client *client = data->cpld_client; - u8 offset = (u8)(CPLD_DECODER_OFFSET); - s32 value; - - value = i2c_smbus_read_byte_data(client, offset); - if (value < 0) - return -ENODEV; - - dev_dbg(&client->dev, "read led decode value= %x\n", value); - - value &= CPLD_DECODER_MASK; - - return sprintf(buf, "%d\n", (value == 0) ? 1 : 0); -} - -static ssize_t get_usercode(struct device *dev, - struct device_attribute *devattr, - char *buf) -{ - struct cpld_data *data = dev_get_drvdata(dev); - struct i2c_client *client = data->cpld_client; - u8 i = 0; - s32 value = 0, reading = 0; - - for (i = 0; i < 4; i++) - { - reading = i2c_smbus_read_byte_data(client, CPLD_USERCODE_START_OFFSET + i); - if (reading < 0) - return -ENODEV; - - dev_dbg(&client->dev, "read led usercode reg %d value= %x\n", i, reading); - - value |= reading << (24 - 8 * i); - } - - return sprintf(buf, "%X\n", value); -} - -static ssize_t set_led_decode(struct device *dev, - struct device_attribute *devattr, - const char *buf, - size_t count) -{ - struct cpld_data *data = dev_get_drvdata(dev); - struct i2c_client *client = data->cpld_client; - s32 value; - long enable; - - if (kstrtol(buf, 0, &enable)) - return -EINVAL; - - if ((enable != 1) && (enable != 0)) - return -EINVAL; - -// mutex_lock(&data->lock); - value = i2c_smbus_read_byte_data(client, CPLD_DECODER_OFFSET); - if (value < 0) - return -ENODEV; - - dev_dbg(&client->dev, "read led decode value= %x\n", value); - - value |= CPLD_DECODER_MASK; - if (enable) - value &= ~CPLD_DECODER_MASK; - - dev_dbg(&client->dev, "write led decode value= %x\n", value); - - i2c_smbus_write_byte_data(client, CPLD_DECODER_OFFSET, (u8)value); -// mutex_unlock(&data->lock); - - return count; -} - -static DEVICE_ATTR(led_decode, S_IWUSR | S_IRUGO, get_led_decode, set_led_decode); -static DEVICE_ATTR(usercode, S_IRUGO, get_usercode, NULL); - -static const struct attribute *led_attrs[] = { - &dev_attr_usercode.attr, - &dev_attr_led_decode.attr, - NULL, -}; - -static const struct attribute_group led_attr_group = { - .attrs = (struct attribute **) led_attrs, -}; - -static int cpld_led_probe(struct i2c_client *client, - const struct i2c_device_id *id) -{ - struct cpld_led_data *data; - struct cpld_data *led_data; - struct device *port_dev; - int nr, err; - - if (!cpld_class) - { - cpld_class = class_create(THIS_MODULE, "cpld-led"); - if (IS_ERR(cpld_class)) { - pr_err("couldn't create sysfs class\n"); - return PTR_ERR(cpld_class); - } - } - - data = devm_kzalloc(&client->dev, sizeof(struct cpld_led_data), - GFP_KERNEL); - if (!data) - return -ENOMEM; - - /* Test */ - nr = ida_simple_get(&cpld_led_ida, 1, 99, GFP_KERNEL); - if (nr < 0) - return ERR_PTR(nr); - - led_data = kzalloc(sizeof(struct cpld_led_data), GFP_KERNEL); - - port_dev = device_create(cpld_class, &client->dev, MKDEV(0,0), led_data, CPLD_LED_ID_FORMAT, nr); - if (IS_ERR(port_dev)) { - err = PTR_ERR(port_dev); - // printk("err_status\n"); - } - - data->port_dev = port_dev; - data->cpld_data = led_data; - - dev_info(&client->dev, "Register CPLDLED %d\n", nr); - - sprintf(led_data->name, "LED%d-data", nr); - led_data->cpld_id = nr; - dev_set_drvdata(port_dev, led_data); - port_dev->init_name = led_data->name; - led_data->cpld_client = client; - - err = sysfs_create_group(&port_dev->kobj, &led_attr_group); - // if (status) printk("err status\n"); - /* end */ - - i2c_set_clientdata(client, data); - mutex_init(&data->lock); - - dev_info(&client->dev, "%s device found\n", client->name); - - - return 0; - -//FIXME: implement error check -exit_remove: -// sysfs_remove_group(&client->dev.kobj, &data->attrs); - return err; -} - -/* FIXME: for older kernel doesn't with idr_is_empty function, implement here */ -static int idr_has_entry(int id, void *p, void *data) -{ - return 1; -} - -static bool cpld_idr_is_empty(struct idr *idp) -{ - return !idr_for_each(idp, idr_has_entry, NULL); -} - -static int cpld_led_remove(struct i2c_client *client) -{ - struct cpld_led_data *data = i2c_get_clientdata(client); - - dev_info(data->port_dev, "Remove CPLDLED-%d\n", data->cpld_data->cpld_id); - device_unregister(data->port_dev); - ida_simple_remove(&cpld_led_ida, data->cpld_data->cpld_id); - kfree(data->cpld_data); - - if (cpld_idr_is_empty(&cpld_led_ida.idr)) - class_destroy(cpld_class); - - return 0; -} - -module_i2c_driver(cpld_led_driver); - -MODULE_AUTHOR("Luffy Cheng "); -MODULE_AUTHOR("Roger Chang "); -MODULE_DESCRIPTION("Quanta Switch LED CPLD driver"); -MODULE_LICENSE("GPL"); diff --git a/packages/platforms/quanta/x86-64/modules/builds/qci_cpld_sfp28.c b/packages/platforms/quanta/x86-64/modules/builds/qci_cpld_sfp28.c deleted file mode 100755 index f2f2c0d8b..000000000 --- a/packages/platforms/quanta/x86-64/modules/builds/qci_cpld_sfp28.c +++ /dev/null @@ -1,400 +0,0 @@ -/* - * A CPLD driver for monitor SFP28 module I/O - * - * The CPLD is customize by Quanta for controlling SFP28 module signals, - * they are TX_FAULT , TX_DIS , PRE_N , RX_LOS - * Each CPLD control 16 modules, each module use 4 bits in register. - * - * Copyright (C) 2015 Quanta Inc. - * - * Author: Luffy Cheng - * - * 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 - -static DEFINE_IDA(cpld_ida); - -enum platform_type { - SFP = 0, - SFP28, - NONE -}; - -static struct class *cpld_class = NULL; - -struct sfp_data { - struct i2c_client *cpld_client; - char name[8]; - char type[8]; - u8 port_id; - u8 cpld_port; -}; - -struct cpld_data { - struct mutex lock; - struct device *port_dev[16]; - struct sfp_data *port_data[16]; -}; - -static int cpld_probe(struct i2c_client *client, - const struct i2c_device_id *id); -static int cpld_remove(struct i2c_client *client); - -static const struct i2c_device_id cpld_id[] = { - { "CPLD-SFP", SFP }, - { "CPLD-SFP28", SFP28 }, - { } -}; -MODULE_DEVICE_TABLE(i2c, cpld_id); - -static struct i2c_driver cpld_driver = { - .class = I2C_CLASS_HWMON, - .driver = { - .name = "qci_cpld_sfp28", - }, - .probe = cpld_probe, - .remove = cpld_remove, - .id_table = cpld_id, -// .address_list = normal_i2c, -}; - -#define CPLD_ID_PREFIX "port-" -#define CPLD_ID_FORMAT CPLD_ID_PREFIX "%d" - -//SFP28 -#define TX_FAULT_MASK 0x08 -#define TX_DIS_MASK 0x04 -#define PRE_N_MASK 0x02 -#define RX_LOS_MASK 0x01 - -static inline u8 get_group_cmd(u8 group) -{ - //FIXME: if group cmd change - return (group + 1); -} - -static inline u8 port_remapping(u8 phy_port) -{ - /* FIXME: implement by hardware design */ - /* The CPLD register port mapping is weird : - * MSB -------- LSB (word data) - * P3 P4 P1 P2 (per port 4 bits) - * For easy coding bit shift, we treat it as hw port swap - */ - return (phy_port % 2) ? (phy_port - 1) : (phy_port + 1); -} - -//SFP -static ssize_t get_tx_fault(struct device *dev, - struct device_attribute *devattr, - char *buf) -{ - struct sfp_data *data = dev_get_drvdata(dev); - struct i2c_client *client = data->cpld_client; - u8 group = (u8)(data->cpld_port / 4); - u8 group_port = data->cpld_port % 4; - s32 value; - - dev_dbg(&client->dev, "port_id %d => cpld_port %d, group %d(%d)\n", data->port_id, - data->cpld_port + 1, group + 1, group_port + 1); - - value = i2c_smbus_read_word_data(client, get_group_cmd(group)); - if (value < 0) - return -ENODEV; - - dev_dbg(&client->dev, "read group%d value= %x\n", group + 1, value); - - value >>= (group_port * 4); - value &= TX_FAULT_MASK; - - return sprintf(buf, "%d\n", value ? 1 : 0); -} - -static ssize_t get_tx_dis(struct device *dev, - struct device_attribute *devattr, - char *buf) -{ - struct sfp_data *data = dev_get_drvdata(dev); - struct i2c_client *client = data->cpld_client; - u8 group = (u8)(data->cpld_port / 4); - u8 group_port = data->cpld_port % 4; - s32 value; - - dev_dbg(&client->dev, "port_id %d => cpld_port %d, group %d(%d)\n", data->port_id, - data->cpld_port + 1, group + 1, group_port + 1); - - value = i2c_smbus_read_word_data(client, get_group_cmd(group)); - if (value < 0) - return -ENODEV; - - dev_dbg(&client->dev, "read group%d value= %x\n", group + 1, value); - - value >>= (group_port * 4); - value &= TX_DIS_MASK; - - return sprintf(buf, "%d\n", value ? 1 : 0); -} - -static ssize_t get_pre_n(struct device *dev, - struct device_attribute *devattr, - char *buf) -{ - struct sfp_data *data = dev_get_drvdata(dev); - struct i2c_client *client = data->cpld_client; - u8 group = (u8)(data->cpld_port / 4); - u8 group_port = data->cpld_port % 4; - s32 value; - - dev_dbg(&client->dev, "port_id %d => cpld_port %d, group %d(%d)\n", data->port_id, - data->cpld_port + 1, group + 1, group_port + 1); - - value = i2c_smbus_read_word_data(client, get_group_cmd(group)); - if (value < 0) - return -ENODEV; - - dev_dbg(&client->dev, "read group%d value= %x\n", group + 1, value); - - value >>= (group_port * 4); - value &= PRE_N_MASK; - - //FIXME: if present is not low active - return sprintf(buf, "%d\n", value ? 0 : 1); -} - -static ssize_t get_rx_los(struct device *dev, - struct device_attribute *devattr, - char *buf) -{ - struct sfp_data *data = dev_get_drvdata(dev); - struct i2c_client *client = data->cpld_client; - u8 group = (u8)(data->cpld_port / 4); - u8 group_port = data->cpld_port % 4; - s32 value; - - dev_dbg(&client->dev, "port_id %d => cpld_port %d, group %d(%d)\n", data->port_id, - data->cpld_port + 1, group + 1, group_port + 1); - - value = i2c_smbus_read_word_data(client, get_group_cmd(group)); - if (value < 0) - return -ENODEV; - - dev_dbg(&client->dev, "read group%d value= %x\n", group + 1, value); - - value >>= (group_port * 4); - value &= RX_LOS_MASK; - - return sprintf(buf, "%d\n", value ? 1 : 0); -} -static ssize_t set_tx_dis(struct device *dev, - struct device_attribute *devattr, - const char *buf, - size_t count) -{ - struct sfp_data *data = dev_get_drvdata(dev); - struct i2c_client *client = data->cpld_client; - u8 group = (u8)(data->cpld_port / 4); - u8 group_port = data->cpld_port % 4; - s32 value; - long disable; - - dev_dbg(&client->dev, "port_id %d => cpld_port %d, group %d(%d)\n", data->port_id, - data->cpld_port + 1, group + 1, group_port + 1); - - if (kstrtol(buf, 0, &disable)) - return -EINVAL; - - if ((disable != 1) && (disable != 0)) - return -EINVAL; - -// mutex_lock(&data->lock); - value = i2c_smbus_read_word_data(client, get_group_cmd(group)); - if (value < 0) - return -ENODEV; - - dev_dbg(&client->dev, "read group%d value= %x\n", group + 1, value); - - value &= ~(TX_DIS_MASK << (group_port * 4)); - if (disable) - value |= (TX_DIS_MASK << (group_port * 4)); - - dev_dbg(&client->dev, "write group%d value= %x\n", group + 1, value); - - i2c_smbus_write_word_data(client, get_group_cmd(group), (u16)value); -// mutex_unlock(&data->lock); - - return count; -} -//SFP - -//static DEVICE_ATTR(led_enable, S_IWUSR | S_IRUGO, get_led_enable, set_led_enable); -//static DEVICE_ATTR(monitor_enable, S_IWUSR | S_IRUGO, get_monitor_enable, set_monitor_enable); -//SFP -static DEVICE_ATTR(tx_fault, S_IRUGO, get_tx_fault, NULL); -static DEVICE_ATTR(tx_dis, S_IWUSR | S_IRUGO, get_tx_dis, set_tx_dis); -static DEVICE_ATTR(pre_n, S_IRUGO, get_pre_n, NULL); -static DEVICE_ATTR(rx_los, S_IRUGO, get_rx_los, NULL); - -static const struct attribute *sfp_attrs[] = { -// &dev_attr_led_enable.attr, - &dev_attr_tx_fault.attr, - &dev_attr_tx_dis.attr, - &dev_attr_pre_n.attr, - &dev_attr_rx_los.attr, - NULL, -}; - -static const struct attribute_group sfp_attr_group = { - .attrs = (struct attribute **) sfp_attrs, -}; - -static int cpld_probe(struct i2c_client *client, - const struct i2c_device_id *id) -{ - struct cpld_data *data; - struct sfp_data *port_data; -// struct i2c_monitor_data *monitor_data; - struct device *port_dev; -// struct device *i2c_dev; - int port_nr, i=0, err; - char name[I2C_NAME_SIZE], type[I2C_NAME_SIZE]; - - printk("cpld cpld_probe\n"); - - while(id->name[i]) - { - name[i]=tolower(id->name[i]); - i++; - } - name[i]='\0'; - strncpy(type,name+5,strlen(name)-5); - type[strlen(name)-5]='\0'; - - if (!cpld_class) - { - cpld_class = class_create(THIS_MODULE, name); - if (IS_ERR(cpld_class)) { - pr_err("couldn't create sysfs class\n"); - return PTR_ERR(cpld_class); - } - } - - data = devm_kzalloc(&client->dev, sizeof(struct cpld_data), - GFP_KERNEL); - if (!data) - return -ENOMEM; - - /* register sfp port data to sysfs */ - for (i = 0; i < 16; i++) - { - port_nr = ida_simple_get(&cpld_ida, 1, 99, GFP_KERNEL); - if (port_nr < 0) - return ERR_PTR(port_nr); - - port_data = kzalloc(sizeof(struct sfp_data), GFP_KERNEL); - - port_dev = device_create(cpld_class, &client->dev, MKDEV(0,0), port_data, CPLD_ID_FORMAT, port_nr); - if (IS_ERR(port_dev)) { - err = PTR_ERR(port_dev); - printk("err_status\n"); - } - - data->port_dev[i] = port_dev; - data->port_data[i] = port_data; - - strcpy(port_data->type, type); - - dev_info(&client->dev, "Register %s port-%d\n", port_data->type , port_nr); - - /* FIXME: implement Logical/Physical port remapping */ - //port_data->cpld_port = i; - port_data->cpld_port = port_remapping(i); - sprintf(port_data->name, "port-%d", port_nr); - port_data->port_id = port_nr; - dev_set_drvdata(port_dev, port_data); - port_dev->init_name = port_data->name; - port_data->cpld_client = client; - - err = sysfs_create_group(&port_dev->kobj, &sfp_attr_group); - // if (status) printk("err status\n"); - } - - i2c_set_clientdata(client, data); - mutex_init(&data->lock); - - dev_info(&client->dev, "%s device found\n", client->name); - - - return 0; - -//FIXME: implement error check -//exit_remove: -// sysfs_remove_group(&client->dev.kobj, &data->attrs); - return err; -} - -/* FIXME: for older kernel doesn't with idr_is_empty function, implement here */ -#if 1 -static int idr_has_entry(int id, void *p, void *data) -{ - return 1; -} - -static bool cpld_idr_is_empty(struct idr *idp) -{ - return !idr_for_each(idp, idr_has_entry, NULL); -} -#endif - -static int cpld_remove(struct i2c_client *client) -{ - struct cpld_data *data = i2c_get_clientdata(client); - int i; -// int id; - - for (i = 15; i >= 0; i--) - { - dev_info(data->port_dev[i], "Remove %s port-%d\n", data->port_data[i]->type , data->port_data[i]->port_id); - device_unregister(data->port_dev[i]); - ida_simple_remove(&cpld_ida, data->port_data[i]->port_id); - kfree(data->port_data[i]); - } - - if (cpld_idr_is_empty(&cpld_ida.idr)) - class_destroy(cpld_class); - - return 0; -} - -module_i2c_driver(cpld_driver); - -MODULE_AUTHOR("Jonathan Tsai "); -MODULE_VERSION("1.0"); -MODULE_DESCRIPTION("Quanta Switch SFP28 CPLD driver"); -MODULE_LICENSE("GPL"); diff --git a/packages/platforms/quanta/x86-64/modules/builds/qci_pmbus.c b/packages/platforms/quanta/x86-64/modules/builds/qci_pmbus.c deleted file mode 100644 index 176e6caf9..000000000 --- a/packages/platforms/quanta/x86-64/modules/builds/qci_pmbus.c +++ /dev/null @@ -1,484 +0,0 @@ -/* - * QUANTA Generic PMBUS driver - * - * - * Based on generic pmbus driver and ltc2978 driver - * - * 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 <../drivers/hwmon/pmbus/pmbus.h> -#include - -enum projects { ly8, ix1, ix2, ix1b }; - -#define DELAY_TIME 1000 /* uS */ - -/* Needed to access the mutex. Copied from pmbus_core.c */ -#define PB_STATUS_BASE 0 -#define PB_STATUS_VOUT_BASE (PB_STATUS_BASE + PMBUS_PAGES) -#define PB_STATUS_IOUT_BASE (PB_STATUS_VOUT_BASE + PMBUS_PAGES) -#define PB_STATUS_FAN_BASE (PB_STATUS_IOUT_BASE + PMBUS_PAGES) -#define PB_STATUS_FAN34_BASE (PB_STATUS_FAN_BASE + PMBUS_PAGES) -#define PB_STATUS_TEMP_BASE (PB_STATUS_FAN34_BASE + PMBUS_PAGES) -#define PB_STATUS_INPUT_BASE (PB_STATUS_TEMP_BASE + PMBUS_PAGES) -#define PB_STATUS_VMON_BASE (PB_STATUS_INPUT_BASE + 1) -#define PB_NUM_STATUS_REG (PB_STATUS_VMON_BASE + 1) -struct pmbus_data { - struct device *dev; - struct device *hwmon_dev; - - u32 flags; /* from platform data */ - - int exponent[PMBUS_PAGES]; - /* linear mode: exponent for output voltages */ - - const struct pmbus_driver_info *info; - - int max_attributes; - int num_attributes; - struct attribute_group group; - const struct attribute_group *groups[2]; - - struct pmbus_sensor *sensors; - - struct mutex update_lock; - bool valid; - unsigned long last_updated; /* in jiffies */ - - /* - * A single status register covers multiple attributes, - * so we keep them all together. - */ - u8 status[PB_NUM_STATUS_REG]; - u8 status_register; - - 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) -{ - int ret, len; - u8 block_buffer[I2C_SMBUS_BLOCK_MAX + 1], *str; - struct i2c_client *client = container_of(dev, struct i2c_client, dev); - - 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; - } - len = block_buffer[0]; - block_buffer[(len+1)] = '\0'; - str = &(block_buffer[1]); - - return snprintf(buf, PAGE_SIZE, "%s\n", str); -} - -static ssize_t qci_pmbus_show_mfr_model(struct device *dev, - struct device_attribute *da, char *buf) -{ - int ret, len; - u8 block_buffer[I2C_SMBUS_BLOCK_MAX + 1], *str; - struct i2c_client *client = container_of(dev, struct i2c_client, dev); - - 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; - } - len = block_buffer[0]; - block_buffer[(len+1)] = '\0'; - str = &(block_buffer[1]); - - return snprintf(buf, PAGE_SIZE, "%s\n", str); -} - -static ssize_t qci_pmbus_show_mfr_revision(struct device *dev, - struct device_attribute *da, char *buf) -{ - int ret, len; - u8 block_buffer[I2C_SMBUS_BLOCK_MAX + 1], *str; - struct i2c_client *client = container_of(dev, struct i2c_client, dev); - - 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; - } - len = block_buffer[0]; - block_buffer[(len+1)] = '\0'; - str = &(block_buffer[1]); - - return snprintf(buf, PAGE_SIZE, "%s\n", str); -} - -static ssize_t qci_pmbus_show_mfr_location(struct device *dev, - struct device_attribute *da, char *buf) -{ - int ret, len; - u8 block_buffer[I2C_SMBUS_BLOCK_MAX + 1], *str; - struct i2c_client *client = container_of(dev, struct i2c_client, dev); - - 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; - } - len = block_buffer[0]; - block_buffer[(len+1)] = '\0'; - str = &(block_buffer[1]); - - return snprintf(buf, PAGE_SIZE, "%s\n", str); -} - -static ssize_t qci_pmbus_show_mfr_serial(struct device *dev, - struct device_attribute *da, char *buf) -{ - int ret, len; - u8 block_buffer[I2C_SMBUS_BLOCK_MAX + 1], *str; - struct i2c_client *client = container_of(dev, struct i2c_client, dev); - - 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; - } - len = block_buffer[0]; - block_buffer[(len+1)] = '\0'; - str = &(block_buffer[1]); - - return snprintf(buf, PAGE_SIZE, "%s\n", str); -} - - -static DEVICE_ATTR(mfr_id, S_IRUGO, qci_pmbus_show_mfr_id, NULL); -static DEVICE_ATTR(mfr_model, S_IRUGO, qci_pmbus_show_mfr_model, NULL); -static DEVICE_ATTR(mfr_revision, S_IRUGO, qci_pmbus_show_mfr_revision, NULL); -static DEVICE_ATTR(mfr_location, S_IRUGO, qci_pmbus_show_mfr_location, NULL); -static DEVICE_ATTR(mfr_serial, S_IRUGO, qci_pmbus_show_mfr_serial, NULL); - - -static struct attribute *qci_pmbus_inventory_attrs[] = { - &dev_attr_mfr_id.attr, - &dev_attr_mfr_model.attr, - &dev_attr_mfr_revision.attr, - &dev_attr_mfr_location.attr, - &dev_attr_mfr_serial.attr, - NULL -}; - -static struct attribute_group qci_pmbus_inventory_attr_grp = { - .attrs = qci_pmbus_inventory_attrs -}; - -/* FIXME: add project specific id here */ -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); - -/* - * Find sensor groups and status registers on each page. - */ -static void qci_pmbus_find_sensor_groups(struct i2c_client *client, - struct pmbus_driver_info *info) -{ - int page; - - /* Sensors detected on page 0 only */ - if (pmbus_check_word_register(client, 0, PMBUS_READ_VIN)) - info->func[0] |= PMBUS_HAVE_VIN; - if (pmbus_check_word_register(client, 0, PMBUS_READ_VCAP)) - info->func[0] |= PMBUS_HAVE_VCAP; - if (pmbus_check_word_register(client, 0, PMBUS_READ_IIN)) - info->func[0] |= PMBUS_HAVE_IIN; - if (pmbus_check_word_register(client, 0, PMBUS_READ_PIN)) - info->func[0] |= PMBUS_HAVE_PIN; - if (info->func[0] - && pmbus_check_byte_register(client, 0, PMBUS_STATUS_INPUT)) - info->func[0] |= PMBUS_HAVE_STATUS_INPUT; - if (pmbus_check_byte_register(client, 0, PMBUS_FAN_CONFIG_12) && - pmbus_check_word_register(client, 0, PMBUS_READ_FAN_SPEED_1)) { - info->func[0] |= PMBUS_HAVE_FAN12; - if (pmbus_check_byte_register(client, 0, PMBUS_STATUS_FAN_12)) - info->func[0] |= PMBUS_HAVE_STATUS_FAN12; - } - if (pmbus_check_byte_register(client, 0, PMBUS_FAN_CONFIG_34) && - pmbus_check_word_register(client, 0, PMBUS_READ_FAN_SPEED_3)) { - info->func[0] |= PMBUS_HAVE_FAN34; - if (pmbus_check_byte_register(client, 0, PMBUS_STATUS_FAN_34)) - info->func[0] |= PMBUS_HAVE_STATUS_FAN34; - } - if (pmbus_check_word_register(client, 0, PMBUS_READ_TEMPERATURE_1)) - info->func[0] |= PMBUS_HAVE_TEMP; - if (pmbus_check_word_register(client, 0, PMBUS_READ_TEMPERATURE_2)) - info->func[0] |= PMBUS_HAVE_TEMP2; - if (pmbus_check_word_register(client, 0, PMBUS_READ_TEMPERATURE_3)) - info->func[0] |= PMBUS_HAVE_TEMP3; - if (info->func[0] & (PMBUS_HAVE_TEMP | PMBUS_HAVE_TEMP2 - | PMBUS_HAVE_TEMP3) - && pmbus_check_byte_register(client, 0, - PMBUS_STATUS_TEMPERATURE)) - info->func[0] |= PMBUS_HAVE_STATUS_TEMP; - - /* Sensors detected on all pages */ - for (page = 0; page < info->pages; page++) { - if (pmbus_check_word_register(client, page, PMBUS_READ_VOUT)) { - info->func[page] |= PMBUS_HAVE_VOUT; - if (pmbus_check_byte_register(client, page, - PMBUS_STATUS_VOUT)) - info->func[page] |= PMBUS_HAVE_STATUS_VOUT; - } - if (pmbus_check_word_register(client, page, PMBUS_READ_IOUT)) { - info->func[page] |= PMBUS_HAVE_IOUT; - if (pmbus_check_byte_register(client, 0, - PMBUS_STATUS_IOUT)) - info->func[page] |= PMBUS_HAVE_STATUS_IOUT; - } - if (pmbus_check_word_register(client, page, PMBUS_READ_POUT)) - info->func[page] |= PMBUS_HAVE_POUT; - } -} - -/* - * Identify chip parameters. - */ -static int qci_pmbus_identify(struct i2c_client *client, - struct pmbus_driver_info *info) -{ - int ret = 0; - - if (!info->pages) { - /* - * Check if the PAGE command is supported. If it is, - * keep setting the page number until it fails or until the - * maximum number of pages has been reached. Assume that - * this is the number of pages supported by the chip. - */ - if (pmbus_check_byte_register(client, 0, PMBUS_PAGE)) { - int page; - - for (page = 1; page < PMBUS_PAGES; page++) { - if (pmbus_set_page(client, page) < 0) - break; - } - pmbus_set_page(client, 0); - info->pages = page; - } else { - info->pages = 1; - } - } - - if (pmbus_check_byte_register(client, 0, PMBUS_VOUT_MODE)) { - int vout_mode; - - vout_mode = pmbus_read_byte_data(client, 0, PMBUS_VOUT_MODE); - if (vout_mode >= 0 && vout_mode != 0xff) { - switch (vout_mode >> 5) { - case 0: - break; - case 1: - info->format[PSC_VOLTAGE_OUT] = vid; - break; - case 2: - info->format[PSC_VOLTAGE_OUT] = direct; - break; - default: - ret = -ENODEV; - goto abort; - } - } - } - - /* - * We should check if the COEFFICIENTS register is supported. - * If it is, and the chip is configured for direct mode, we can read - * the coefficients from the chip, one set per group of sensor - * registers. - * - * To do this, we will need access to a chip which actually supports the - * COEFFICIENTS command, since the command is too complex to implement - * without testing it. Until then, abort if a chip configured for direct - * mode was detected. - */ - if (info->format[PSC_VOLTAGE_OUT] == direct) { - ret = -ENODEV; - goto abort; - } - - /* if no function pre-defined, try to find sensor groups */ - if (info->func[0] == 0) qci_pmbus_find_sensor_groups(client, info); -abort: - return ret; -} - -int qci_pmbus_set_page(struct i2c_client *client, u8 page) -{ - struct pmbus_data *data = i2c_get_clientdata(client); - int rv = 0; - int newpage; - - if (page != data->currpage) { - rv = i2c_smbus_write_byte_data(client, PMBUS_PAGE, page); - udelay(DELAY_TIME); - newpage = i2c_smbus_read_byte_data(client, PMBUS_PAGE); - if (newpage != page) - rv = -EIO; - else - data->currpage = page; - } - return rv; -} - -int qci_write_byte(struct i2c_client *client, int page, u8 value) -{ - int rv; - - if (page >= 0) { - rv = qci_pmbus_set_page(client, page); - if (rv < 0) - return rv; - } - - rv = i2c_smbus_write_byte(client, value); - udelay(DELAY_TIME); - return rv; -} - -int qci_write_word_data(struct i2c_client *client, int page, int reg, u16 word) -{ - int rv; - - rv = qci_pmbus_set_page(client, page); - if (rv < 0) - return rv; - - rv = i2c_smbus_write_word_data(client, reg, word); - udelay(DELAY_TIME); - return rv; -} - -static int qci_pmbus_probe(struct i2c_client *client, - const struct i2c_device_id *id) -{ - struct device *dev = &client->dev; - struct pmbus_driver_info *info; - int ret, i; - - dev_info(dev, "qci_pmbus_probe\n"); - - if (!i2c_check_functionality(client->adapter, - I2C_FUNC_SMBUS_READ_WORD_DATA)) - return -ENODEV; - - info = devm_kzalloc(&client->dev, sizeof(struct pmbus_driver_info), - GFP_KERNEL); - - if (!info) - return -ENOMEM; - - info->func[0] = 0; - - /* FIXME: add project specific function table here */ - switch (id->driver_data) { - case ly8: - info->pages = 1; - info->func[0] = PMBUS_HAVE_VIN | PMBUS_HAVE_PIN | PMBUS_HAVE_STATUS_INPUT - | PMBUS_HAVE_FAN12 | PMBUS_HAVE_STATUS_FAN12 - | PMBUS_HAVE_VOUT | PMBUS_HAVE_STATUS_VOUT - | PMBUS_HAVE_IOUT | PMBUS_HAVE_STATUS_IOUT - ; - 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 - | PMBUS_HAVE_FAN12 | PMBUS_HAVE_STATUS_FAN12 - | PMBUS_HAVE_TEMP | PMBUS_HAVE_TEMP2 - | PMBUS_HAVE_TEMP3 | PMBUS_HAVE_STATUS_TEMP - | PMBUS_HAVE_VOUT | PMBUS_HAVE_STATUS_VOUT - | PMBUS_HAVE_IOUT | PMBUS_HAVE_STATUS_IOUT - | PMBUS_HAVE_POUT - ; - break; - default: - break; - } - info->write_word_data = qci_write_word_data; - info->write_byte = qci_write_byte; - info->identify = qci_pmbus_identify; /* FIXME: reserve for future use */ - - /* Register sysfs hooks */ - ret = sysfs_create_group(&dev->kobj, &qci_pmbus_inventory_attr_grp); - if (ret) { - dev_err(dev, "Failed to create sysfs entries\n"); - return -1; - } - - return pmbus_do_probe(client, id, info); -} - -/* This is the driver that will be inserted */ -static struct i2c_driver qci_pmbus_driver = { - .driver = { - .name = "qci-pmbus", - }, - .probe = qci_pmbus_probe, - .remove = pmbus_do_remove, - .id_table = qci_pmbus_id, -}; - -module_i2c_driver(qci_pmbus_driver); - - -MODULE_AUTHOR("Jonathan Tsai (jonathan.tsai@quantatw.com)"); -MODULE_VERSION("1.0"); -MODULE_DESCRIPTION("QUANTA generic PMBus driver"); -MODULE_LICENSE("GPL"); diff --git a/packages/platforms/quanta/x86-64/modules/builds/quanta_hwmon_ix_series.c b/packages/platforms/quanta/x86-64/modules/builds/quanta_hwmon_ix_series.c deleted file mode 100755 index fc8bb41c0..000000000 --- a/packages/platforms/quanta/x86-64/modules/builds/quanta_hwmon_ix_series.c +++ /dev/null @@ -1,252 +0,0 @@ -/* - * - * - * Copyright 2013, 2014 BigSwitch Networks, Inc. - * - * This program is free software; you can redistribute it - * and/or modify it under the terms ofthe GNU General Public License as - * published by the Free Software Foundation; either version 2 of the License, - * or (at your option) any later version. - * - * - * - * - * A hwmon driver for the Quanta IX1/IX2 - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -static const unsigned short normal_i2c[] = { 0x4E, I2C_CLIENT_END }; - -#define QUANTA_HWMON_REG_TEMP_INPUT_BASE 0x20 -#define QUANTA_HWMON_REG_FAN_MODE 0x33 -#define QUANTA_HWMON_REG_FAN_DIR 0x56 -#define QUANTA_HWMON_REG_FAN_PWM_BASE 0x3C -#define QUANTA_HWMON_REG_FAN_INPUT_BASE 0x40 - -#define QUANTA_HWMON_FAN_MANUAL_MODE 1 -#define QUANTA_HWMON_FAN_SMART_MODE 3 - -#define QUANTA_HWMON_NUM_FANS 6 - -struct quanta_hwmon_ix_series_data { - struct device *hwmon_dev; - struct attribute_group attrs; - struct mutex lock; -}; - -enum quanta_hwmon_ix_series_s { - quanta_ix1_hwmon, - quanta_ix2_hwmon, -}; - -static int quanta_hwmon_ix_series_probe(struct i2c_client *client, - const struct i2c_device_id *id); -static int quanta_hwmon_ix_series_remove(struct i2c_client *client); - -static const struct i2c_device_id quanta_hwmon_ix_series_id[] = { - { "quanta_ix1_hwmon", quanta_ix1_hwmon }, - { "quanta_ix2_hwmon", quanta_ix2_hwmon }, - { } -}; -MODULE_DEVICE_TABLE(i2c, quanta_hwmon_ix_series_id); - -static struct i2c_driver quanta_hwmon_ix_series_driver = { - .class = I2C_CLASS_HWMON, - .driver = { - .name = "quanta_hwmon_ix_series", - }, - .probe = quanta_hwmon_ix_series_probe, - .remove = quanta_hwmon_ix_series_remove, - .id_table = quanta_hwmon_ix_series_id, - .address_list = normal_i2c, -}; - -static ssize_t show_temp(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 quanta_hwmon_ix_series_data *data = i2c_get_clientdata(client); - int temp; - - mutex_lock(&data->lock); - temp = i2c_smbus_read_byte_data(client, - QUANTA_HWMON_REG_TEMP_INPUT_BASE - + attr->index); - mutex_unlock(&data->lock); - return sprintf(buf, "%d\n", 1000 * temp); -} - -static ssize_t show_fan(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 quanta_hwmon_ix_series_data *data = i2c_get_clientdata(client); - int fan; - - mutex_lock(&data->lock); - fan = i2c_smbus_read_word_swapped(client, - QUANTA_HWMON_REG_FAN_INPUT_BASE - + 2 * attr->index); - mutex_unlock(&data->lock); - return sprintf(buf, "%d\n", fan); -} - -static ssize_t show_pwm(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 quanta_hwmon_ix_series_data *data = i2c_get_clientdata(client); - int pwm; - - mutex_lock(&data->lock); - pwm = i2c_smbus_read_word_swapped(client, - QUANTA_HWMON_REG_FAN_PWM_BASE - + 2 * attr->index); - mutex_unlock(&data->lock); - return sprintf(buf, "%d\n", pwm * 255 / 10000); -} - -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 quanta_hwmon_ix_series_data *data = i2c_get_clientdata(client); - long val; - int ret; - - ret = kstrtol(buf, 10, &val); - if (ret) - return ret; - mutex_lock(&data->lock); - i2c_smbus_write_word_swapped(client, - QUANTA_HWMON_REG_FAN_PWM_BASE - + 2 * attr->index, val * 10000 / 255); - mutex_unlock(&data->lock); - return count; -} - -static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, show_temp, NULL, 0); -static SENSOR_DEVICE_ATTR(temp2_input, S_IRUGO, show_temp, NULL, 1); -static SENSOR_DEVICE_ATTR(temp3_input, S_IRUGO, show_temp, NULL, 2); -static SENSOR_DEVICE_ATTR(temp5_input, S_IRUGO, show_temp, NULL, 4); -static SENSOR_DEVICE_ATTR(temp6_input, S_IRUGO, show_temp, NULL, 5); -static SENSOR_DEVICE_ATTR(temp7_input, S_IRUGO, show_temp, NULL, 6);//For IX2 -static SENSOR_DEVICE_ATTR(fan1_input, S_IRUGO, show_fan, NULL, 0); -static SENSOR_DEVICE_ATTR(fan2_input, S_IRUGO, show_fan, NULL, 1); -static SENSOR_DEVICE_ATTR(fan3_input, S_IRUGO, show_fan, NULL, 2); -static SENSOR_DEVICE_ATTR(fan4_input, S_IRUGO, show_fan, NULL, 3);//For IX1, IX2 -static SENSOR_DEVICE_ATTR(fan5_input, S_IRUGO, show_fan, NULL, 4); -static SENSOR_DEVICE_ATTR(fan6_input, S_IRUGO, show_fan, NULL, 5); -static SENSOR_DEVICE_ATTR(fan7_input, S_IRUGO, show_fan, NULL, 6); -static SENSOR_DEVICE_ATTR(fan8_input, S_IRUGO, show_fan, NULL, 7);//For IX1, IX2 -static SENSOR_DEVICE_ATTR(pwm1, S_IWUSR | S_IRUGO, show_pwm, set_pwm, 0); - -static struct attribute *quanta_hwmon_ix_series_attr_5temps_4fans[] = { - &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_temp5_input.dev_attr.attr, - &sensor_dev_attr_temp6_input.dev_attr.attr, - &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_pwm1.dev_attr.attr, - NULL -}; - -static struct attribute *quanta_hwmon_ix_series_attr_6temps_4fans[] = { - &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_temp5_input.dev_attr.attr, - &sensor_dev_attr_temp6_input.dev_attr.attr, - &sensor_dev_attr_temp7_input.dev_attr.attr, - &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_pwm1.dev_attr.attr, - NULL -}; - -static int quanta_hwmon_ix_series_probe(struct i2c_client *client, - const struct i2c_device_id *id) -{ - struct quanta_hwmon_ix_series_data *data; - int err; - - data = devm_kzalloc(&client->dev, sizeof(struct quanta_hwmon_ix_series_data), - GFP_KERNEL); - if (!data) - return -ENOMEM; - - i2c_set_clientdata(client, data); - mutex_init(&data->lock); - - dev_info(&client->dev, "%s chip found\n", client->name); - if(!strcmp(client->name, "quanta_ix1_hwmon")){ - data->attrs.attrs = quanta_hwmon_ix_series_attr_5temps_4fans; - } - else{ - data->attrs.attrs = quanta_hwmon_ix_series_attr_6temps_4fans; - } - err = sysfs_create_group(&client->dev.kobj, &data->attrs); - if (err) - return err; - - data->hwmon_dev = hwmon_device_register(&client->dev); - if (IS_ERR(data->hwmon_dev)) { - err = PTR_ERR(data->hwmon_dev); - goto exit_remove; - } - - i2c_smbus_write_byte_data(client, - QUANTA_HWMON_REG_FAN_MODE, - QUANTA_HWMON_FAN_SMART_MODE); - - return 0; - -exit_remove: - sysfs_remove_group(&client->dev.kobj, &data->attrs); - return err; -} - -static int quanta_hwmon_ix_series_remove(struct i2c_client *client) -{ - struct quanta_hwmon_ix_series_data *data = i2c_get_clientdata(client); - - hwmon_device_unregister(data->hwmon_dev); - sysfs_remove_group(&client->dev.kobj, &data->attrs); - return 0; -} - -module_i2c_driver(quanta_hwmon_ix_series_driver); - -MODULE_AUTHOR("Jonathan Tsai (jonathan.tsai@quantatw.com)"); -MODULE_VERSION("1.0"); -MODULE_DESCRIPTION("Quanta IX1/IX2 hardware monitor driver"); -MODULE_LICENSE("GPL"); diff --git a/packages/platforms/quanta/x86-64/modules/builds/quanta_hwmon_ly_series.c b/packages/platforms/quanta/x86-64/modules/builds/quanta_hwmon_ly_series.c deleted file mode 100755 index 1b807bcf5..000000000 --- a/packages/platforms/quanta/x86-64/modules/builds/quanta_hwmon_ly_series.c +++ /dev/null @@ -1,251 +0,0 @@ -/* - * - * - * Copyright 2013, 2014 BigSwitch Networks, Inc. - * - * This program is free software; you can redistribute it - * and/or modify it under the terms ofthe GNU General Public License as - * published by the Free Software Foundation; either version 2 of the License, - * or (at your option) any later version. - * - * - * - * - * A hwmon driver for the Quanta LY6/LY8/LY9 - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -static const unsigned short normal_i2c[] = { 0x4E, I2C_CLIENT_END }; - -#define QUANTA_HWMON_REG_TEMP_INPUT_BASE 0x20 -#define QUANTA_HWMON_REG_FAN_MODE 0x33 -#define QUANTA_HWMON_REG_FAN_DIR 0x56 -#define QUANTA_HWMON_REG_FAN_PWM_BASE 0x3C -#define QUANTA_HWMON_REG_FAN_INPUT_BASE 0x40 - -#define QUANTA_HWMON_FAN_MANUAL_MODE 1 -#define QUANTA_HWMON_FAN_SMART_MODE 3 - -#define QUANTA_HWMON_NUM_FANS 6 - -struct quanta_hwmon_ly_series_data { - struct device *hwmon_dev; - struct attribute_group attrs; - struct mutex lock; -}; - -enum quanta_hwmon_ly_series_s { - quanta_ly6_hwmon, - quanta_ly6f_hwmon, - quanta_ly8_hwmon, - quanta_ly9_hwmon, -}; - -static int quanta_hwmon_ly_series_probe(struct i2c_client *client, - const struct i2c_device_id *id); -static int quanta_hwmon_ly_series_remove(struct i2c_client *client); - -static const struct i2c_device_id quanta_hwmon_ly_series_id[] = { - { "quanta_ly6_hwmon", quanta_ly6_hwmon }, - { "quanta_ly6f_hwmon", quanta_ly6f_hwmon }, - { "quanta_ly8_hwmon", quanta_ly8_hwmon }, - { "quanta_ly9_hwmon", quanta_ly9_hwmon }, - { } -}; -MODULE_DEVICE_TABLE(i2c, quanta_hwmon_ly_series_id); - -static struct i2c_driver quanta_hwmon_ly_series_driver = { - .class = I2C_CLASS_HWMON, - .driver = { - .name = "quanta_hwmon_ly_series", - }, - .probe = quanta_hwmon_ly_series_probe, - .remove = quanta_hwmon_ly_series_remove, - .id_table = quanta_hwmon_ly_series_id, - .address_list = normal_i2c, -}; - -static ssize_t show_temp(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 quanta_hwmon_ly_series_data *data = i2c_get_clientdata(client); - int temp; - - mutex_lock(&data->lock); - temp = i2c_smbus_read_byte_data(client, - QUANTA_HWMON_REG_TEMP_INPUT_BASE - + attr->index); - mutex_unlock(&data->lock); - return sprintf(buf, "%d\n", 1000 * temp); -} - -static ssize_t show_fan(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 quanta_hwmon_ly_series_data *data = i2c_get_clientdata(client); - int fan; - - mutex_lock(&data->lock); - fan = i2c_smbus_read_word_swapped(client, - QUANTA_HWMON_REG_FAN_INPUT_BASE - + 2 * attr->index); - mutex_unlock(&data->lock); - return sprintf(buf, "%d\n", fan); -} - -static ssize_t show_pwm(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 quanta_hwmon_ly_series_data *data = i2c_get_clientdata(client); - int pwm; - - mutex_lock(&data->lock); - pwm = i2c_smbus_read_word_swapped(client, - QUANTA_HWMON_REG_FAN_PWM_BASE - + 2 * attr->index); - mutex_unlock(&data->lock); - return sprintf(buf, "%d\n", pwm * 255 / 10000); -} - -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 quanta_hwmon_ly_series_data *data = i2c_get_clientdata(client); - long val; - int ret; - - ret = kstrtol(buf, 10, &val); - if (ret) - return ret; - mutex_lock(&data->lock); - i2c_smbus_write_word_swapped(client, - QUANTA_HWMON_REG_FAN_PWM_BASE - + 2 * attr->index, val * 10000 / 255); - mutex_unlock(&data->lock); - return count; -} - -static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, show_temp, NULL, 0); -static SENSOR_DEVICE_ATTR(temp2_input, S_IRUGO, show_temp, NULL, 1); -static SENSOR_DEVICE_ATTR(temp3_input, S_IRUGO, show_temp, NULL, 2); -static SENSOR_DEVICE_ATTR(temp4_input, S_IRUGO, show_temp, NULL, 3);//For LY9 -static SENSOR_DEVICE_ATTR(temp5_input, S_IRUGO, show_temp, NULL, 4); -static SENSOR_DEVICE_ATTR(temp6_input, S_IRUGO, show_temp, NULL, 5); -static SENSOR_DEVICE_ATTR(fan1_input, S_IRUGO, show_fan, NULL, 0); -static SENSOR_DEVICE_ATTR(fan2_input, S_IRUGO, show_fan, NULL, 1); -static SENSOR_DEVICE_ATTR(fan3_input, S_IRUGO, show_fan, NULL, 2); -static SENSOR_DEVICE_ATTR(fan5_input, S_IRUGO, show_fan, NULL, 4); -static SENSOR_DEVICE_ATTR(fan6_input, S_IRUGO, show_fan, NULL, 5); -static SENSOR_DEVICE_ATTR(fan7_input, S_IRUGO, show_fan, NULL, 6); -static SENSOR_DEVICE_ATTR(pwm1, S_IWUSR | S_IRUGO, show_pwm, set_pwm, 0); - -static struct attribute *quanta_hwmon_ly_series_attr[] = { - &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_temp5_input.dev_attr.attr, - &sensor_dev_attr_temp6_input.dev_attr.attr, - &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_fan5_input.dev_attr.attr, - &sensor_dev_attr_fan6_input.dev_attr.attr, - &sensor_dev_attr_fan7_input.dev_attr.attr, - &sensor_dev_attr_pwm1.dev_attr.attr, - NULL -}; - -static struct attribute *quanta_hwmon_ly_series_attr_6temps_3fans[] = { - &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_temp6_input.dev_attr.attr, - &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_fan5_input.dev_attr.attr, - &sensor_dev_attr_fan6_input.dev_attr.attr, - &sensor_dev_attr_fan7_input.dev_attr.attr, - &sensor_dev_attr_pwm1.dev_attr.attr, - NULL -}; - -static int quanta_hwmon_ly_series_probe(struct i2c_client *client, - const struct i2c_device_id *id) -{ - struct quanta_hwmon_ly_series_data *data; - int err; - - data = devm_kzalloc(&client->dev, sizeof(struct quanta_hwmon_ly_series_data), - GFP_KERNEL); - if (!data) - return -ENOMEM; - - i2c_set_clientdata(client, data); - mutex_init(&data->lock); - - dev_info(&client->dev, "%s chip found\n", client->name); - - if(!strcmp(client->name, "quanta_ly9_hwmon")){ - data->attrs.attrs = quanta_hwmon_ly_series_attr_6temps_3fans; - } - else{ - data->attrs.attrs = quanta_hwmon_ly_series_attr; - } - err = sysfs_create_group(&client->dev.kobj, &data->attrs); - if (err) - return err; - - data->hwmon_dev = hwmon_device_register(&client->dev); - if (IS_ERR(data->hwmon_dev)) { - err = PTR_ERR(data->hwmon_dev); - goto exit_remove; - } - - i2c_smbus_write_byte_data(client, - QUANTA_HWMON_REG_FAN_MODE, - QUANTA_HWMON_FAN_SMART_MODE); - - return 0; - -exit_remove: - sysfs_remove_group(&client->dev.kobj, &data->attrs); - return err; -} - -static int quanta_hwmon_ly_series_remove(struct i2c_client *client) -{ - struct quanta_hwmon_ly_series_data *data = i2c_get_clientdata(client); - - hwmon_device_unregister(data->hwmon_dev); - sysfs_remove_group(&client->dev.kobj, &data->attrs); - return 0; -} - -module_i2c_driver(quanta_hwmon_ly_series_driver); - -MODULE_AUTHOR("Jonathan Tsai (jonathan.tsai@quantatw.com)"); -MODULE_VERSION("1.0"); -MODULE_DESCRIPTION("Quanta LY6/LY8/LY9 hardware monitor driver"); -MODULE_LICENSE("GPL");